From ba7fadeb1228f9c8f0217b18e5090688613f1b9e Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Tue, 30 Jun 2015 20:40:06 -0400 Subject: [PATCH 001/227] Add support to tell whether output directs to a terminal emulator. --- src/compiler/sys.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/compiler/sys.ts b/src/compiler/sys.ts index a47d6959ba8..f3244af0df7 100644 --- a/src/compiler/sys.ts +++ b/src/compiler/sys.ts @@ -6,6 +6,7 @@ namespace ts { newLine: string; useCaseSensitiveFileNames: boolean; write(s: string): void; + writesToTty?(): boolean; readFile(path: string, encoding?: string): string; writeFile(path: string, data: string, writeByteOrderMark?: boolean): void; watchFile?(path: string, callback: (path: string) => void): FileWatcher; @@ -187,7 +188,8 @@ namespace ts { function getNodeSystem(): System { var _fs = require("fs"); var _path = require("path"); - var _os = require('os'); + var _os = require("os"); + var _tty = require("tty"); var platform: string = _os.platform(); // win32\win64 are case insensitive platforms, MacOS (darwin) by default is also case insensitive @@ -271,6 +273,7 @@ namespace ts { // 1 is a standard descriptor for stdout _fs.writeSync(1, s); }, + writesToTty: () => _tty.isatty(1), readFile, writeFile, watchFile: (fileName, callback) => { From f660bd3652fd567c4c13fd5afafd35a070e2aed0 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Tue, 30 Jun 2015 22:35:17 -0400 Subject: [PATCH 002/227] Got "prettier" error printing working. --- src/compiler/tsc.ts | 84 +++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 78 insertions(+), 6 deletions(-) diff --git a/src/compiler/tsc.ts b/src/compiler/tsc.ts index 2a01774fbca..5f474b861fe 100644 --- a/src/compiler/tsc.ts +++ b/src/compiler/tsc.ts @@ -80,24 +80,96 @@ namespace ts { return diagnostic.messageText; } - function reportDiagnostic(diagnostic: Diagnostic) { - var output = ""; + function reportDiagnostic(diagnostic: Diagnostic): void { + let output = ""; if (diagnostic.file) { - var loc = getLineAndCharacterOfPosition(diagnostic.file, diagnostic.start); + let { line, character } = getLineAndCharacterOfPosition(diagnostic.file, diagnostic.start); - output += `${ diagnostic.file.fileName }(${ loc.line + 1 },${ loc.character + 1 }): `; + output += `${ diagnostic.file.fileName }(${ line + 1 },${ character + 1 }): `; } - var category = DiagnosticCategory[diagnostic.category].toLowerCase(); + let category = DiagnosticCategory[diagnostic.category].toLowerCase(); output += `${ category } TS${ diagnostic.code }: ${ flattenDiagnosticMessageText(diagnostic.messageText, sys.newLine) }${ sys.newLine }`; sys.write(output); } + const redColorControlChar = "\u001b[31m"; + const resetColorControlChar = "\u001b[0m"; + + function reportDiagnosticAllPrettyLike(diagnostic: Diagnostic): void { + let output = ""; + + if (diagnostic.file) { + let { start, length, file } = diagnostic; + let { line: firstLine, character: firstLineChar } = getLineAndCharacterOfPosition(file, start); + let { line: lastLine, character: lastLineChar } = getLineAndCharacterOfPosition(file, start + length); + + output += sys.newLine; + for (let i = 0, indexOfLastLine = lastLine - firstLine; i <= indexOfLastLine; i++) { + let lineStart = getPositionOfLineAndCharacter(file, firstLine + i, 0); + let lineEnd = getPositionOfLineAndCharacter(file, firstLine + i + 1, 0); + let lineContent = file.text.slice(lineStart, lineEnd); + lineContent = lineContent.replace(/\s+$/g, ""); // trim from end + lineContent = lineContent.replace("\t", " "); // normalize tabs to 4 spaces + + output += lineContent + sys.newLine; + + if (i === 0) { + let lastCharForLine = i === indexOfLastLine ? lastLineChar : undefined; + + output += lineContent.slice(0, firstLineChar).replace(/\S/g, " "); + output += redColorControlChar; + output += lineContent.slice(firstLineChar, lastCharForLine).replace(/./g, "~"); + output += resetColorControlChar; + } + else if (i === indexOfLastLine) { + output += redColorControlChar; + output += lineContent.slice(0, lastLineChar).replace(/./g, "~"); + output += resetColorControlChar; + // Don't bother "filling" at the end. + } + else { + output += lineContent.replace(/^(\s*)(.*)$/, replaceLineWithRedSquiggles); + } + + output += sys.newLine; + } + + output += `${ file.fileName }(${ firstLine + 1 },${ firstLineChar + 1 }): `; + } + + let category = DiagnosticCategory[diagnostic.category].toLowerCase(); + output += `${ category } TS${ diagnostic.code }: ${ flattenDiagnosticMessageText(diagnostic.messageText, sys.newLine) }`; + output += sys.newLine + sys.newLine; + + sys.write(output); + } + + function replaceLineWithRedSquiggles(orig: string, leadingWhitespace: string, content: string): string { + return leadingWhitespace + redColorControlChar + content.replace(/./g, "~") + resetColorControlChar; + } + + /** Splits the given string on \r\n, or on only \n if that fails, or on only \r if *that* fails. */ + function splitContentByNewlines(content: string) { + // Split up the input file by line + // Note: IE JS engine incorrectly handles consecutive delimiters here when using RegExp split, so + // we have to use string-based splitting instead and try to figure out the delimiting chars + var lines = content.split('\r\n'); + if (lines.length === 1) { + lines = content.split('\n'); + + if (lines.length === 1) { + lines = content.split("\r"); + } + } + return lines; + } + function reportDiagnostics(diagnostics: Diagnostic[]) { for (var i = 0; i < diagnostics.length; i++) { - reportDiagnostic(diagnostics[i]); + reportDiagnosticAllPrettyLike(diagnostics[i]); } } From 17f443ac3be562a93cb45b34dd7e9ad4d3ea1366 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Wed, 1 Jul 2015 03:49:58 -0400 Subject: [PATCH 003/227] Just squiggle the entire line for middle lines (sans trailing space). --- src/compiler/tsc.ts | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/src/compiler/tsc.ts b/src/compiler/tsc.ts index 5f474b861fe..b920949c004 100644 --- a/src/compiler/tsc.ts +++ b/src/compiler/tsc.ts @@ -116,23 +116,21 @@ namespace ts { output += lineContent + sys.newLine; + output += redColorControlChar; if (i === 0) { let lastCharForLine = i === indexOfLastLine ? lastLineChar : undefined; output += lineContent.slice(0, firstLineChar).replace(/\S/g, " "); - output += redColorControlChar; output += lineContent.slice(firstLineChar, lastCharForLine).replace(/./g, "~"); - output += resetColorControlChar; } else if (i === indexOfLastLine) { - output += redColorControlChar; output += lineContent.slice(0, lastLineChar).replace(/./g, "~"); - output += resetColorControlChar; // Don't bother "filling" at the end. } else { - output += lineContent.replace(/^(\s*)(.*)$/, replaceLineWithRedSquiggles); + output += lineContent.replace(/./g, "~"); } + output += resetColorControlChar; output += sys.newLine; } @@ -147,10 +145,6 @@ namespace ts { sys.write(output); } - function replaceLineWithRedSquiggles(orig: string, leadingWhitespace: string, content: string): string { - return leadingWhitespace + redColorControlChar + content.replace(/./g, "~") + resetColorControlChar; - } - /** Splits the given string on \r\n, or on only \n if that fails, or on only \r if *that* fails. */ function splitContentByNewlines(content: string) { // Split up the input file by line From fdbea8b6828d8dd5822b21634fd6c3057ff7a81d Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Wed, 1 Jul 2015 12:23:10 -0400 Subject: [PATCH 004/227] Give the new reporter a more reasonable name. --- src/compiler/tsc.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/compiler/tsc.ts b/src/compiler/tsc.ts index b920949c004..d724a54742f 100644 --- a/src/compiler/tsc.ts +++ b/src/compiler/tsc.ts @@ -98,7 +98,7 @@ namespace ts { const redColorControlChar = "\u001b[31m"; const resetColorControlChar = "\u001b[0m"; - function reportDiagnosticAllPrettyLike(diagnostic: Diagnostic): void { + function reportDiagnosticWithColorAndContext(diagnostic: Diagnostic): void { let output = ""; if (diagnostic.file) { @@ -163,7 +163,7 @@ namespace ts { function reportDiagnostics(diagnostics: Diagnostic[]) { for (var i = 0; i < diagnostics.length; i++) { - reportDiagnosticAllPrettyLike(diagnostics[i]); + reportDiagnosticWithColorAndContext(diagnostics[i]); } } From d8e462d6e767893ae6ac2bff997f509e3d605ba8 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Wed, 1 Jul 2015 12:40:01 -0400 Subject: [PATCH 005/227] Make output reliant on whether stdout redirects to a terminal; use forEach. --- src/compiler/tsc.ts | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/src/compiler/tsc.ts b/src/compiler/tsc.ts index d724a54742f..2e577b8b0f9 100644 --- a/src/compiler/tsc.ts +++ b/src/compiler/tsc.ts @@ -145,6 +145,10 @@ namespace ts { sys.write(output); } + const diagnosticReporter = sys.writesToTty && sys.writesToTty() ? + reportDiagnosticWithColorAndContext : + reportDiagnostic; + /** Splits the given string on \r\n, or on only \n if that fails, or on only \r if *that* fails. */ function splitContentByNewlines(content: string) { // Split up the input file by line @@ -161,12 +165,6 @@ namespace ts { return lines; } - function reportDiagnostics(diagnostics: Diagnostic[]) { - for (var i = 0; i < diagnostics.length; i++) { - reportDiagnosticWithColorAndContext(diagnostics[i]); - } - } - function padLeft(s: string, length: number) { while (s.length < length) { s = " " + s; @@ -220,7 +218,7 @@ namespace ts { // If there are any errors due to command line parsing and/or // setting up localization, report them and quit. if (commandLine.errors.length > 0) { - reportDiagnostics(commandLine.errors); + forEach(commandLine.errors, diagnosticReporter); return sys.exit(ExitStatus.DiagnosticsPresent_OutputsSkipped); } @@ -285,7 +283,7 @@ namespace ts { let configObject = result.config; let configParseResult = parseConfigFile(configObject, sys, getDirectoryPath(configFileName)); if (configParseResult.errors.length > 0) { - reportDiagnostics(configParseResult.errors); + forEach(configParseResult.errors, diagnosticReporter); return sys.exit(ExitStatus.DiagnosticsPresent_OutputsSkipped); } rootFileNames = configParseResult.fileNames; @@ -422,17 +420,17 @@ namespace ts { function compileProgram(): ExitStatus { // First get any syntactic errors. var diagnostics = program.getSyntacticDiagnostics(); - reportDiagnostics(diagnostics); + forEach(diagnostics, diagnosticReporter); // If we didn't have any syntactic errors, then also try getting the global and // semantic errors. if (diagnostics.length === 0) { var diagnostics = program.getGlobalDiagnostics(); - reportDiagnostics(diagnostics); + forEach(diagnostics, diagnosticReporter); if (diagnostics.length === 0) { var diagnostics = program.getSemanticDiagnostics(); - reportDiagnostics(diagnostics); + forEach(diagnostics, diagnosticReporter); } } @@ -445,7 +443,7 @@ namespace ts { // Otherwise, emit and report any errors we ran into. var emitOutput = program.emit(); - reportDiagnostics(emitOutput.diagnostics); + forEach(emitOutput.diagnostics, diagnosticReporter); // If the emitter didn't emit anything, then pass that value along. if (emitOutput.emitSkipped) { From cc6b04c7a62cf42d6e4423fd702d4989a509c3d0 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Wed, 1 Jul 2015 12:49:46 -0400 Subject: [PATCH 006/227] Bring back 'reportDiagnostics'. --- src/compiler/tsc.ts | 44 +++++++++++++++++++++++++------------------- 1 file changed, 25 insertions(+), 19 deletions(-) diff --git a/src/compiler/tsc.ts b/src/compiler/tsc.ts index 2e577b8b0f9..c3b80b800c8 100644 --- a/src/compiler/tsc.ts +++ b/src/compiler/tsc.ts @@ -6,6 +6,16 @@ namespace ts { fileWatcher: FileWatcher; } + const reportDiagnostic = sys.writesToTty && sys.writesToTty() ? + reportDiagnosticWithColorAndContext : + reportDiagnosticSimply; + + function reportDiagnostics(diagnostics: Diagnostic[]): void { + for (let diagnostic of diagnostics) { + reportDiagnostic(diagnostic); + } + } + /** * Checks to see if the locale is in the appropriate format, * and if it is, attempts to set the appropriate language. @@ -80,7 +90,7 @@ namespace ts { return diagnostic.messageText; } - function reportDiagnostic(diagnostic: Diagnostic): void { + function reportDiagnosticSimply(diagnostic: Diagnostic): void { let output = ""; if (diagnostic.file) { @@ -145,10 +155,6 @@ namespace ts { sys.write(output); } - const diagnosticReporter = sys.writesToTty && sys.writesToTty() ? - reportDiagnosticWithColorAndContext : - reportDiagnostic; - /** Splits the given string on \r\n, or on only \n if that fails, or on only \r if *that* fails. */ function splitContentByNewlines(content: string) { // Split up the input file by line @@ -209,7 +215,7 @@ namespace ts { if (commandLine.options.locale) { if (!isJSONSupported()) { - reportDiagnostic(createCompilerDiagnostic(Diagnostics.The_current_host_does_not_support_the_0_option, "--locale")); + reportDiagnosticSimply(createCompilerDiagnostic(Diagnostics.The_current_host_does_not_support_the_0_option, "--locale")); return sys.exit(ExitStatus.DiagnosticsPresent_OutputsSkipped); } validateLocaleAndSetLanguage(commandLine.options.locale, commandLine.errors); @@ -218,12 +224,12 @@ namespace ts { // If there are any errors due to command line parsing and/or // setting up localization, report them and quit. if (commandLine.errors.length > 0) { - forEach(commandLine.errors, diagnosticReporter); + reportDiagnostics(commandLine.errors); return sys.exit(ExitStatus.DiagnosticsPresent_OutputsSkipped); } if (commandLine.options.version) { - reportDiagnostic(createCompilerDiagnostic(Diagnostics.Version_0, ts.version)); + reportDiagnosticSimply(createCompilerDiagnostic(Diagnostics.Version_0, ts.version)); return sys.exit(ExitStatus.Success); } @@ -235,12 +241,12 @@ namespace ts { if (commandLine.options.project) { if (!isJSONSupported()) { - reportDiagnostic(createCompilerDiagnostic(Diagnostics.The_current_host_does_not_support_the_0_option, "--project")); + reportDiagnosticSimply(createCompilerDiagnostic(Diagnostics.The_current_host_does_not_support_the_0_option, "--project")); return sys.exit(ExitStatus.DiagnosticsPresent_OutputsSkipped); } configFileName = normalizePath(combinePaths(commandLine.options.project, "tsconfig.json")); if (commandLine.fileNames.length !== 0) { - reportDiagnostic(createCompilerDiagnostic(Diagnostics.Option_project_cannot_be_mixed_with_source_files_on_a_command_line)); + reportDiagnosticSimply(createCompilerDiagnostic(Diagnostics.Option_project_cannot_be_mixed_with_source_files_on_a_command_line)); return sys.exit(ExitStatus.DiagnosticsPresent_OutputsSkipped); } } @@ -258,7 +264,7 @@ namespace ts { // Firefox has Object.prototype.watch if (commandLine.options.watch && commandLine.options.hasOwnProperty("watch")) { if (!sys.watchFile) { - reportDiagnostic(createCompilerDiagnostic(Diagnostics.The_current_host_does_not_support_the_0_option, "--watch")); + reportDiagnosticSimply(createCompilerDiagnostic(Diagnostics.The_current_host_does_not_support_the_0_option, "--watch")); return sys.exit(ExitStatus.DiagnosticsPresent_OutputsSkipped); } if (configFileName) { @@ -276,14 +282,14 @@ namespace ts { let result = readConfigFile(configFileName); if (result.error) { - reportDiagnostic(result.error); + reportDiagnosticSimply(result.error); return sys.exit(ExitStatus.DiagnosticsPresent_OutputsSkipped); } let configObject = result.config; let configParseResult = parseConfigFile(configObject, sys, getDirectoryPath(configFileName)); if (configParseResult.errors.length > 0) { - forEach(configParseResult.errors, diagnosticReporter); + reportDiagnostics(configParseResult.errors); return sys.exit(ExitStatus.DiagnosticsPresent_OutputsSkipped); } rootFileNames = configParseResult.fileNames; @@ -305,7 +311,7 @@ namespace ts { } setCachedProgram(compileResult.program); - reportDiagnostic(createCompilerDiagnostic(Diagnostics.Compilation_complete_Watching_for_file_changes)); + reportDiagnosticSimply(createCompilerDiagnostic(Diagnostics.Compilation_complete_Watching_for_file_changes)); } function getSourceFile(fileName: string, languageVersion: ScriptTarget, onError ?: (message: string) => void) { @@ -367,7 +373,7 @@ namespace ts { function recompile() { timerHandle = undefined; - reportDiagnostic(createCompilerDiagnostic(Diagnostics.File_change_detected_Starting_incremental_compilation)); + reportDiagnosticSimply(createCompilerDiagnostic(Diagnostics.File_change_detected_Starting_incremental_compilation)); performCompilation(); } } @@ -420,17 +426,17 @@ namespace ts { function compileProgram(): ExitStatus { // First get any syntactic errors. var diagnostics = program.getSyntacticDiagnostics(); - forEach(diagnostics, diagnosticReporter); + reportDiagnostics(diagnostics); // If we didn't have any syntactic errors, then also try getting the global and // semantic errors. if (diagnostics.length === 0) { var diagnostics = program.getGlobalDiagnostics(); - forEach(diagnostics, diagnosticReporter); + reportDiagnostics(diagnostics); if (diagnostics.length === 0) { var diagnostics = program.getSemanticDiagnostics(); - forEach(diagnostics, diagnosticReporter); + reportDiagnostics(diagnostics); } } @@ -443,7 +449,7 @@ namespace ts { // Otherwise, emit and report any errors we ran into. var emitOutput = program.emit(); - forEach(emitOutput.diagnostics, diagnosticReporter); + reportDiagnostics(emitOutput.diagnostics); // If the emitter didn't emit anything, then pass that value along. if (emitOutput.emitSkipped) { From 99f6985115cfe26ed6f850d0d6943af3d80492f6 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Thu, 16 Jul 2015 19:41:23 -0700 Subject: [PATCH 007/227] Don't expand tabs; just use a space. --- src/compiler/tsc.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compiler/tsc.ts b/src/compiler/tsc.ts index c3b80b800c8..dbd70e7557c 100644 --- a/src/compiler/tsc.ts +++ b/src/compiler/tsc.ts @@ -122,7 +122,7 @@ namespace ts { let lineEnd = getPositionOfLineAndCharacter(file, firstLine + i + 1, 0); let lineContent = file.text.slice(lineStart, lineEnd); lineContent = lineContent.replace(/\s+$/g, ""); // trim from end - lineContent = lineContent.replace("\t", " "); // normalize tabs to 4 spaces + lineContent = lineContent.replace("\t", " "); // convert tabs to single spaces output += lineContent + sys.newLine; From 85b54e8946f9c19f3237d017cff181fd199618fc Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Thu, 16 Jul 2015 22:45:31 -0700 Subject: [PATCH 008/227] Fixed out of bounds error; made index start directly at the line number. --- src/compiler/tsc.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/compiler/tsc.ts b/src/compiler/tsc.ts index dbd70e7557c..5105d2d3719 100644 --- a/src/compiler/tsc.ts +++ b/src/compiler/tsc.ts @@ -117,9 +117,9 @@ namespace ts { let { line: lastLine, character: lastLineChar } = getLineAndCharacterOfPosition(file, start + length); output += sys.newLine; - for (let i = 0, indexOfLastLine = lastLine - firstLine; i <= indexOfLastLine; i++) { - let lineStart = getPositionOfLineAndCharacter(file, firstLine + i, 0); - let lineEnd = getPositionOfLineAndCharacter(file, firstLine + i + 1, 0); + for (let i = firstLine; i <= lastLine; i++) { + let lineStart = getPositionOfLineAndCharacter(file, i, 0); + let lineEnd = i < lastLine ? getPositionOfLineAndCharacter(file, i + 1, 0) : file.text.length; let lineContent = file.text.slice(lineStart, lineEnd); lineContent = lineContent.replace(/\s+$/g, ""); // trim from end lineContent = lineContent.replace("\t", " "); // convert tabs to single spaces @@ -127,13 +127,13 @@ namespace ts { output += lineContent + sys.newLine; output += redColorControlChar; - if (i === 0) { - let lastCharForLine = i === indexOfLastLine ? lastLineChar : undefined; + if (i === firstLine) { + let lastCharForLine = i === lastLine ? lastLineChar : undefined; output += lineContent.slice(0, firstLineChar).replace(/\S/g, " "); output += lineContent.slice(firstLineChar, lastCharForLine).replace(/./g, "~"); } - else if (i === indexOfLastLine) { + else if (i === lastLine) { output += lineContent.slice(0, lastLineChar).replace(/./g, "~"); // Don't bother "filling" at the end. } From dda058b85e73da1166f80364d26aaa5e62df57fb Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Fri, 24 Jul 2015 12:18:18 -0700 Subject: [PATCH 009/227] Use 'process.stdout.write' to ensure colors get displayed correctly on Windows. --- src/compiler/sys.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compiler/sys.ts b/src/compiler/sys.ts index f3244af0df7..8564eafa472 100644 --- a/src/compiler/sys.ts +++ b/src/compiler/sys.ts @@ -271,7 +271,7 @@ namespace ts { useCaseSensitiveFileNames: useCaseSensitiveFileNames, write(s: string): void { // 1 is a standard descriptor for stdout - _fs.writeSync(1, s); + process.stdout.write(s); }, writesToTty: () => _tty.isatty(1), readFile, From 3c04dff0593acc423c9167c96f80bd6a38feee60 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Tue, 18 Aug 2015 00:47:09 -0700 Subject: [PATCH 010/227] Limit errors to 5 lines, fixed some other issues. --- src/compiler/tsc.ts | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/src/compiler/tsc.ts b/src/compiler/tsc.ts index 5105d2d3719..069f87dae1f 100644 --- a/src/compiler/tsc.ts +++ b/src/compiler/tsc.ts @@ -105,7 +105,7 @@ namespace ts { sys.write(output); } - const redColorControlChar = "\u001b[31m"; + const redColorControlChar = "\u001b[91m"; const resetColorControlChar = "\u001b[0m"; function reportDiagnosticWithColorAndContext(diagnostic: Diagnostic): void { @@ -115,19 +115,38 @@ namespace ts { let { start, length, file } = diagnostic; let { line: firstLine, character: firstLineChar } = getLineAndCharacterOfPosition(file, start); let { line: lastLine, character: lastLineChar } = getLineAndCharacterOfPosition(file, start + length); - + const lastLineInFile = getLineAndCharacterOfPosition(file, file.text.length).line; + + let hasMoreThanFiveLines = (lastLine - firstLine) >= 4; + let gutterWidth = (lastLine + 1 + "").length; + if (hasMoreThanFiveLines) { + gutterWidth = Math.max("...".length, gutterWidth); + } + output += sys.newLine; for (let i = firstLine; i <= lastLine; i++) { + // If the error spans over 5 lines, we'll only show the first 2 and last 2 lines, + // so we'll skip ahead to the second-to-last line. + if (hasMoreThanFiveLines && firstLine + 1 < i && i < lastLine - 1) { + output += padLeft("...", gutterWidth) + " ||" + sys.newLine; + i = lastLine - 1; + } + let lineStart = getPositionOfLineAndCharacter(file, i, 0); - let lineEnd = i < lastLine ? getPositionOfLineAndCharacter(file, i + 1, 0) : file.text.length; + let lineEnd = i < lastLineInFile ? getPositionOfLineAndCharacter(file, i + 1, 0) : file.text.length; let lineContent = file.text.slice(lineStart, lineEnd); lineContent = lineContent.replace(/\s+$/g, ""); // trim from end lineContent = lineContent.replace("\t", " "); // convert tabs to single spaces - output += lineContent + sys.newLine; + // Output the actual contents of the line. + output += padLeft(i + 1 + "", gutterWidth) + " ||" + lineContent + sys.newLine; + // Output the error span for the line using tildes. + output += padLeft("", gutterWidth) + " ||"; output += redColorControlChar; if (i === firstLine) { + // If we're on the last line, then limit it to the last character of the last line. + // Otherwise, we'll just squiggle the rest of the line, giving 'slice' no end position. let lastCharForLine = i === lastLine ? lastLineChar : undefined; output += lineContent.slice(0, firstLineChar).replace(/\S/g, " "); @@ -135,9 +154,9 @@ namespace ts { } else if (i === lastLine) { output += lineContent.slice(0, lastLineChar).replace(/./g, "~"); - // Don't bother "filling" at the end. } else { + // Squiggle the entire line. output += lineContent.replace(/./g, "~"); } output += resetColorControlChar; @@ -145,6 +164,7 @@ namespace ts { output += sys.newLine; } + output += sys.newLine; output += `${ file.fileName }(${ firstLine + 1 },${ firstLineChar + 1 }): `; } From 44f3c0ca8a4198ec17952888c038657f8e50dd61 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Wed, 19 Aug 2015 12:30:50 -0700 Subject: [PATCH 011/227] Stylize gutter. --- src/compiler/tsc.ts | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/compiler/tsc.ts b/src/compiler/tsc.ts index 0d8e3341312..10eddc41b7e 100644 --- a/src/compiler/tsc.ts +++ b/src/compiler/tsc.ts @@ -106,8 +106,9 @@ namespace ts { sys.write(output); } - const redColorControlChar = "\u001b[91m"; - const resetColorControlChar = "\u001b[0m"; + const redForegroundEscapeSequence = "\u001b[91m"; + const gutterStyleSequence = "\u001b[100;30m"; + const resetEscapeSequence = "\u001b[0m"; function reportDiagnosticWithColorAndContext(diagnostic: Diagnostic): void { let output = ""; @@ -129,7 +130,7 @@ namespace ts { // If the error spans over 5 lines, we'll only show the first 2 and last 2 lines, // so we'll skip ahead to the second-to-last line. if (hasMoreThanFiveLines && firstLine + 1 < i && i < lastLine - 1) { - output += padLeft("...", gutterWidth) + " ||" + sys.newLine; + output += gutterStyleSequence + padLeft("...", gutterWidth) + resetEscapeSequence + " " + sys.newLine; i = lastLine - 1; } @@ -140,11 +141,11 @@ namespace ts { lineContent = lineContent.replace("\t", " "); // convert tabs to single spaces // Output the actual contents of the line. - output += padLeft(i + 1 + "", gutterWidth) + " ||" + lineContent + sys.newLine; + output += gutterStyleSequence + padLeft(i + 1 + "", gutterWidth) + resetEscapeSequence + " " + lineContent + sys.newLine; // Output the error span for the line using tildes. - output += padLeft("", gutterWidth) + " ||"; - output += redColorControlChar; + output += gutterStyleSequence + padLeft("", gutterWidth) + resetEscapeSequence + " "; + output += redForegroundEscapeSequence; if (i === firstLine) { // If we're on the last line, then limit it to the last character of the last line. // Otherwise, we'll just squiggle the rest of the line, giving 'slice' no end position. @@ -160,7 +161,7 @@ namespace ts { // Squiggle the entire line. output += lineContent.replace(/./g, "~"); } - output += resetColorControlChar; + output += resetEscapeSequence; output += sys.newLine; } From b62ef0d452d0b285cda913665fe360c2b5aa43b5 Mon Sep 17 00:00:00 2001 From: Vladimir Matveev Date: Thu, 3 Sep 2015 10:49:39 -0700 Subject: [PATCH 012/227] initial revision of reachability checks in binder --- src/compiler/binder.ts | 430 +++++++++++++++++- src/compiler/checker.ts | 58 +-- src/compiler/commandLineParser.ts | 22 +- .../diagnosticInformationMap.generated.ts | 12 +- src/compiler/diagnosticMessages.json | 39 +- src/compiler/types.ts | 8 +- src/harness/harness.ts | 12 + src/services/breakpoints.ts | 5 +- src/services/formatting/smartIndenter.ts | 1 - src/services/navigateTo.ts | 5 +- src/services/services.ts | 6 +- src/services/shims.ts | 1 - .../reference/ParameterList5.errors.txt | 4 +- .../YieldExpression17_es6.errors.txt | 4 +- .../asyncArrowFunction10_es6.errors.txt | 4 +- .../asyncFunctionDeclaration12_es6.errors.txt | 4 +- .../reference/asyncGetter_es6.errors.txt | 4 +- .../computedPropertyNames2_ES5.errors.txt | 8 +- .../computedPropertyNames2_ES6.errors.txt | 8 +- .../computedPropertyNames3_ES5.errors.txt | 8 +- .../computedPropertyNames3_ES6.errors.txt | 8 +- .../conflictingTypeAnnotatedVar.errors.txt | 8 +- ...orOnContextuallyTypedReturnType.errors.txt | 4 +- .../functionImplementationErrors.errors.txt | 9 +- .../functionWithThrowButNoReturn1.errors.txt | 11 - .../functionWithThrowButNoReturn1.symbols | 11 + .../functionWithThrowButNoReturn1.types | 13 + ...gReturnStatementsAndExpressions.errors.txt | 16 +- .../getterMissingReturnError.errors.txt | 4 +- .../invalidReturnStatements.errors.txt | 16 +- .../methodInAmbientClass1.errors.txt | 4 +- .../missingReturnStatement.errors.txt | 4 +- .../missingReturnStatement1.errors.txt | 4 +- .../reference/multiLineErrors.errors.txt | 4 +- ...jectLiteralMemberWithModifiers2.errors.txt | 4 +- .../objectLiteralWithSemicolons5.errors.txt | 4 +- .../reference/parserAccessors1.errors.txt | 4 +- .../reference/parserAccessors10.errors.txt | 4 +- .../reference/parserAccessors3.errors.txt | 4 +- .../reference/parserAccessors7.errors.txt | 4 +- .../parserComputedPropertyName4.errors.txt | 4 +- .../parserComputedPropertyName5.errors.txt | 4 +- .../reference/parserES3Accessors1.errors.txt | 4 +- .../reference/parserES3Accessors3.errors.txt | 4 +- .../parserES5ComputedPropertyName4.errors.txt | 4 +- .../parserErrorRecovery_Block3.errors.txt | 8 +- ...rGetAccessorWithTypeParameters1.errors.txt | 4 +- .../parserMemberAccessor1.errors.txt | 4 +- ...arserMemberAccessorDeclaration1.errors.txt | 4 +- ...rserMemberAccessorDeclaration10.errors.txt | 4 +- ...rserMemberAccessorDeclaration12.errors.txt | 4 +- ...arserMemberAccessorDeclaration2.errors.txt | 4 +- ...arserMemberAccessorDeclaration3.errors.txt | 4 +- ...arserMemberAccessorDeclaration7.errors.txt | 4 +- ...arserMemberAccessorDeclaration8.errors.txt | 4 +- ...arserMemberAccessorDeclaration9.errors.txt | 4 +- .../reference/parserParameterList5.errors.txt | 4 +- .../reference/reachabilityChecks1.errors.txt | 70 +++ .../reference/reachabilityChecks1.js | 100 ++++ .../reference/reachabilityChecks2.js | 9 + .../reference/reachabilityChecks2.symbols | 8 + .../reference/reachabilityChecks2.types | 10 + .../reference/reachabilityChecks3.errors.txt | 16 + .../reference/reachabilityChecks3.js | 22 + .../reference/reachabilityChecks4.errors.txt | 20 + .../reference/reachabilityChecks4.js | 30 ++ .../reference/reachabilityChecks5.errors.txt | 162 +++++++ .../reference/reachabilityChecks5.js | 247 ++++++++++ .../recursiveFunctionTypes.errors.txt | 8 +- .../reference/returnTypeParameter.errors.txt | 4 +- tests/cases/compiler/reachabilityChecks1.ts | 50 ++ tests/cases/compiler/reachabilityChecks2.ts | 6 + tests/cases/compiler/reachabilityChecks3.ts | 11 + tests/cases/compiler/reachabilityChecks4.ts | 15 + tests/cases/compiler/reachabilityChecks5.ts | 131 ++++++ 75 files changed, 1570 insertions(+), 204 deletions(-) delete mode 100644 tests/baselines/reference/functionWithThrowButNoReturn1.errors.txt create mode 100644 tests/baselines/reference/functionWithThrowButNoReturn1.symbols create mode 100644 tests/baselines/reference/functionWithThrowButNoReturn1.types create mode 100644 tests/baselines/reference/reachabilityChecks1.errors.txt create mode 100644 tests/baselines/reference/reachabilityChecks1.js create mode 100644 tests/baselines/reference/reachabilityChecks2.js create mode 100644 tests/baselines/reference/reachabilityChecks2.symbols create mode 100644 tests/baselines/reference/reachabilityChecks2.types create mode 100644 tests/baselines/reference/reachabilityChecks3.errors.txt create mode 100644 tests/baselines/reference/reachabilityChecks3.js create mode 100644 tests/baselines/reference/reachabilityChecks4.errors.txt create mode 100644 tests/baselines/reference/reachabilityChecks4.js create mode 100644 tests/baselines/reference/reachabilityChecks5.errors.txt create mode 100644 tests/baselines/reference/reachabilityChecks5.js create mode 100644 tests/cases/compiler/reachabilityChecks1.ts create mode 100644 tests/cases/compiler/reachabilityChecks2.ts create mode 100644 tests/cases/compiler/reachabilityChecks3.ts create mode 100644 tests/cases/compiler/reachabilityChecks4.ts create mode 100644 tests/cases/compiler/reachabilityChecks5.ts diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index 16f2a59a58d..c29c761c28a 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -9,6 +9,21 @@ namespace ts { Instantiated = 1, ConstEnumOnly = 2 } + + const enum Reachability { + Unintialized = 1 << 0, + Reachable = 1 << 1, + Unreachable = 1 << 2, + ReportedUnreachable = 1 << 3 + } + + function or(state1: Reachability, state2: Reachability): Reachability { + return (state1 | state2) & Reachability.Reachable + ? Reachability.Reachable + : (state1 & state2) & Reachability.ReportedUnreachable + ? Reachability.ReportedUnreachable + : Reachability.Unreachable; + } export function getModuleInstanceState(node: Node): ModuleInstanceState { // A module is uninstantiated if it contains only @@ -77,18 +92,25 @@ namespace ts { IsContainerWithLocals = IsContainer | HasLocals } - export function bindSourceFile(file: SourceFile) { + export function bindSourceFile(file: SourceFile, options: CompilerOptions) { let start = new Date().getTime(); - bindSourceFileWorker(file); + bindSourceFileWorker(file, options); bindTime += new Date().getTime() - start; } - function bindSourceFileWorker(file: SourceFile) { + function bindSourceFileWorker(file: SourceFile, options: CompilerOptions) { let parent: Node; let container: Node; let blockScopeContainer: Node; let lastContainer: Node; + // state used by reachability checks + let hasExplicitReturn: boolean; + let currentReachabilityState: Reachability; + let labelStack: Reachability[]; + let labels: Map; + let implicitLabels: number[]; + // 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). @@ -329,12 +351,273 @@ namespace ts { blockScopeContainer.locals = undefined; } - forEachChild(node, bind); + bindWithReachabilityChecks(node); container = saveContainer; parent = saveParent; blockScopeContainer = savedBlockScopeContainer; } + + function shouldSaveReachabilityState(n: Node): boolean { + return n.kind === SyntaxKind.SourceFile || n.kind === SyntaxKind.ModuleBlock || isFunctionLike(n); + } + + function bindWithReachabilityChecks(node: Node): void { + let savedReachabilityState: Reachability; + let savedLabelStack: Reachability[]; + let savedLabels: Map; + let savedImplicitLabels: number[]; + let savedHasExplicitReturn: boolean; + + let saveState = shouldSaveReachabilityState(node); + if (saveState) { + savedReachabilityState = currentReachabilityState; + savedLabelStack = labelStack; + savedLabels = labels; + savedImplicitLabels = implicitLabels; + savedHasExplicitReturn = hasExplicitReturn; + + currentReachabilityState = Reachability.Reachable; + hasExplicitReturn = false; + labelStack = labels = implicitLabels = undefined; + } + + if (!bindReachableStatement(node)) { + forEachChild(node, bind); + } + + if (currentReachabilityState === Reachability.Reachable && isFunctionLike(node) && nodeIsPresent((node).body)) { + node.flags |= NodeFlags.HasImplicitReturn; + if (hasExplicitReturn) { + node.flags |= NodeFlags.HasExplicitReturn; + } + } + + if (saveState) { + hasExplicitReturn = savedHasExplicitReturn; + currentReachabilityState = savedReachabilityState; + labelStack = savedLabelStack; + labels = savedLabels; + implicitLabels = savedImplicitLabels; + } + } + + function bindReachableStatement(n: Node): boolean { + if (checkUnreachable(n)) { + return false; + } + + switch(n.kind) { + case SyntaxKind.WhileStatement: + return bindWhileStatement(n); + case SyntaxKind.DoStatement: + return bindDoStatement(n); + case SyntaxKind.ForStatement: + return bindForStatement(n); + case SyntaxKind.ForInStatement: + case SyntaxKind.ForOfStatement: + return bindForInOrForOfStatement(n); + case SyntaxKind.IfStatement: + return bindIfStatement(n); + case SyntaxKind.ReturnStatement: + case SyntaxKind.ThrowStatement: + return bindReturnOrThrow(n); + case SyntaxKind.BreakStatement: + case SyntaxKind.ContinueStatement: + return bindBreakOrContinueStatement(n); + case SyntaxKind.TryStatement: + return bindTryStatement(n); + case SyntaxKind.SwitchStatement: + return bindSwitchStatement(n); + case SyntaxKind.CaseBlock: + return bindCaseBlock(n); + case SyntaxKind.LabeledStatement: + return bindLabeledStatement(n); + default: + return false; + } + } + + function bindWhileStatement(n: WhileStatement): boolean { + const preWhileState = + n.expression.kind === SyntaxKind.FalseKeyword ? Reachability.Unreachable : currentReachabilityState; + const postWhileState = + n.expression.kind === SyntaxKind.TrueKeyword ? Reachability.Unreachable : currentReachabilityState; + + // bind expressions (don't affect reachability) + bind(n.expression); + + currentReachabilityState = preWhileState; + const postWhileLabel = pushImplicitLabel(); + bind(n.statement); + popImplicitLabel(postWhileLabel, postWhileState) + + return true; + } + + function bindDoStatement(n: DoStatement): boolean { + const preDoState = currentReachabilityState; + + const postDoLabel = pushImplicitLabel(); + bind(n.statement); + var postDoState = n.expression.kind === SyntaxKind.TrueKeyword ? Reachability.Unreachable : preDoState; + popImplicitLabel(postDoLabel, postDoState); + + // bind expressions (don't affect reachability) + bind(n.expression); + + return true; + } + + function bindForStatement(n: ForStatement): boolean { + const preForState = currentReachabilityState; + const postForLabel = pushImplicitLabel(); + + // bind expressions (don't affect reachability) + bind(n.initializer); + bind(n.condition); + bind(n.incrementor); + + bind(n.statement); + + // for statement is considered infinite when it condition is either omitted or is true keyword + // - for(..;;..) + // - for(..;true;..) + const isInfiniteLoop = (!n.condition || n.condition.kind === SyntaxKind.TrueKeyword); + const postForState = isInfiniteLoop ? Reachability.Unreachable : preForState; + popImplicitLabel(postForLabel, postForState); + + return true; + } + + function bindForInOrForOfStatement(n: ForInStatement | ForOfStatement): boolean { + const preStatementState = currentReachabilityState; + const postStatementLabel = pushImplicitLabel(); + + // bind expressions (don't affect reachability) + bind(n.initializer); + bind(n.expression); + + bind(n.statement); + popImplicitLabel(postStatementLabel, preStatementState); + + return true; + } + + function bindIfStatement(n: IfStatement): boolean { + const ifTrueState = n.expression.kind === SyntaxKind.FalseKeyword ? Reachability.Unreachable : currentReachabilityState; + const ifFalseState = n.expression.kind === SyntaxKind.TrueKeyword ? Reachability.Unreachable : currentReachabilityState; + + currentReachabilityState = ifTrueState; + + // bind expression (don't affect reachability) + bind(n.expression); + + bind(n.thenStatement); + if (n.elseStatement) { + const preElseState = currentReachabilityState; + currentReachabilityState = ifFalseState; + bind(n.elseStatement); + currentReachabilityState = or(currentReachabilityState, preElseState); + } + else { + currentReachabilityState = or(currentReachabilityState, ifFalseState); + } + + return true; + } + + function bindReturnOrThrow(n: ReturnStatement | ThrowStatement): boolean { + // bind expression (don't affect reachability) + bind(n.expression); + if (n.kind === SyntaxKind.ReturnStatement) { + hasExplicitReturn = true; + } + currentReachabilityState = Reachability.Unreachable; + + return true; + } + + function bindBreakOrContinueStatement(n: BreakOrContinueStatement): boolean { + // call bind on label (don't affect reachability) + bind(n.label); + if (n.kind === SyntaxKind.BreakStatement) { + jumpToLabel(n.label, currentReachabilityState); + } + else { + jumpToLabel(n.label, Reachability.Unreachable); // touch label so it will be marked a used + } + currentReachabilityState = Reachability.Unreachable; + + return true; + } + + function bindTryStatement(n: TryStatement): boolean { + // catch\finally blocks has the same reachability as try block + const preTryState = currentReachabilityState; + bind(n.tryBlock); + const postTryState = currentReachabilityState; + + currentReachabilityState = preTryState; + bind(n.catchClause); + const postCatchState = currentReachabilityState; + + currentReachabilityState = preTryState; + bind(n.finallyBlock); + + // post catch/finally state is reachable if + // - post try state is reachable - control flow can fall out of try block + // - post catch state is reachable - control flow can fall out of catch block + currentReachabilityState = or(postTryState, postCatchState); + + return true; + } + + function bindSwitchStatement(n: SwitchStatement): boolean { + const preSwitchState = currentReachabilityState; + const postSwitchLabel = pushImplicitLabel(); + + // bind expression (don't affect reachability) + bind(n.expression); + + bind(n.caseBlock); + + const hasDefault = forEach(n.caseBlock.clauses, c => c.kind === SyntaxKind.DefaultClause); + + // post switch state is unreachable if switch is exaustive (has a default case ) and does not have fallthrough from the last case + var postSwitchState = hasDefault && currentReachabilityState !== Reachability.Reachable ? Reachability.Unreachable : preSwitchState; + + popImplicitLabel(postSwitchLabel, postSwitchState); + + return true; + } + + function bindCaseBlock(n: CaseBlock): boolean { + const startState = currentReachabilityState; + + for(let clause of n.clauses) { + currentReachabilityState = startState; + bind(clause); + if (clause.statements.length && currentReachabilityState === Reachability.Reachable && options.noFallthroughCasesInSwitch) { + errorOnFirstToken(clause, Diagnostics.Fallthrough_case_in_switch); + } + } + + return true; + } + + function bindLabeledStatement(n: LabeledStatement): boolean { + // call bind on label (don't affect reachability) + bind(n.label); + + var ok = pushNamedLabel(n.label); + bind(n.statement); + if (ok) { + popNamedLabel(n.label, currentReachabilityState); + } + + return true; + } function getContainerFlags(node: Node): ContainerFlags { switch (node.kind) { @@ -472,17 +755,6 @@ namespace ts { : declareSymbol(file.locals, undefined, node, symbolFlags, symbolExcludes); } - function isAmbientContext(node: Node): boolean { - while (node) { - if (node.flags & NodeFlags.Ambient) { - return true; - } - - node = node.parent; - } - return false; - } - function hasExportDeclarations(node: ModuleDeclaration | SourceFile): boolean { let body = node.kind === SyntaxKind.SourceFile ? node : (node).body; if (body.kind === SyntaxKind.SourceFile || body.kind === SyntaxKind.ModuleBlock) { @@ -498,7 +770,7 @@ namespace ts { 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 (isAmbientContext(node) && !hasExportDeclarations(node)) { + if (isInAmbientContext(node) && !hasExportDeclarations(node)) { node.flags |= NodeFlags.ExportContext; } else { @@ -750,11 +1022,11 @@ namespace ts { function checkStrictModeWithStatement(node: WithStatement) { // Grammar checking for withStatement if (inStrictMode) { - grammarErrorOnFirstToken(node, Diagnostics.with_statements_are_not_allowed_in_strict_mode); + errorOnFirstToken(node, Diagnostics.with_statements_are_not_allowed_in_strict_mode); } } - function grammarErrorOnFirstToken(node: Node, message: DiagnosticMessage, arg0?: any, arg1?: any, arg2?: any) { + function errorOnFirstToken(node: Node, message: DiagnosticMessage, arg0?: any, arg1?: any, arg2?: any) { let span = getSpanOfTokenAtPosition(file, node.pos); file.bindDiagnostics.push(createFileDiagnostic(file, span.start, span.length, message, arg0, arg1, arg2)); } @@ -764,6 +1036,10 @@ namespace ts { } function bind(node: Node) { + if (!node) { + return; + } + node.parent = parent; let savedInStrictMode = inStrictMode; @@ -1065,5 +1341,123 @@ namespace ts { ? bindAnonymousDeclaration(node, symbolFlags, "__computed") : declareSymbolAndAddToSymbolTable(node, symbolFlags, symbolExcludes); } + + // reachability checks + + function pushNamedLabel(name: Identifier): boolean { + initializeReachabilityStateIfNecessary(); + + if (hasProperty(labels, name.text)) { + return false; + } + labels[name.text] = labelStack.push(Reachability.Unintialized) - 1; + return true; + } + + function pushImplicitLabel(): number { + initializeReachabilityStateIfNecessary(); + + let index = labelStack.push(Reachability.Unintialized) - 1; + implicitLabels.push(index); + return index; + } + + function popNamedLabel(label: Identifier, outerState: Reachability): void { + initializeReachabilityStateIfNecessary(); + + let index = labels[label.text]; + Debug.assert(index !== undefined); + Debug.assert(labelStack.length == index + 1); + + labels[label.text] = undefined; + + setCurrentStateAtLabel(labelStack.pop(), outerState, label); + } + + function popImplicitLabel(implicitLabelIndex: number, outerState: Reachability): void { + initializeReachabilityStateIfNecessary(); + + Debug.assert(labelStack.length === implicitLabelIndex + 1, `Label stack: ${labelStack.length}, index:${implicitLabelIndex}`); + let i = implicitLabels.pop(); + Debug.assert(implicitLabelIndex === i, `i: ${i}, index: ${implicitLabelIndex}`); + setCurrentStateAtLabel(labelStack.pop(), outerState, /*name*/ undefined); + } + + function setCurrentStateAtLabel(innerMergedState: Reachability, outerState: Reachability, label: Identifier): void { + initializeReachabilityStateIfNecessary(); + + if (innerMergedState === Reachability.Unintialized) { + if (label && options.noUnusedLabels) { + file.bindDiagnostics.push(createDiagnosticForNode(label, Diagnostics.Unused_label)); + } + currentReachabilityState = outerState; + } + else { + currentReachabilityState = or(innerMergedState, outerState); + } + } + + function jumpToLabel(label: Identifier, outerState: Reachability): void { + initializeReachabilityStateIfNecessary(); + + const index = label ? labels[label.text] : lastOrUndefined(implicitLabels); + if (index === undefined) { + // reference to unknown label or + // break/continue used outside of loops + return; + } + const stateAtLabel = labelStack[index]; + labelStack[index] = stateAtLabel === Reachability.Unintialized ? outerState : or(stateAtLabel, outerState); + } + + function checkUnreachable(node: Node): boolean { + switch(currentReachabilityState) { + case Reachability.Unreachable: + const reportError = + isStatement(node) || + node.kind === SyntaxKind.ClassDeclaration || + node.kind === SyntaxKind.ModuleDeclaration || + (node.kind === SyntaxKind.EnumDeclaration && (!isConstEnumDeclaration(node) || options.preserveConstEnums)); + + if (reportError) { + currentReachabilityState = Reachability.ReportedUnreachable; + + // unreachable code is reported if + // - user has explicitly asked about it AND + // - statement is in ambient context (statements in ambient context is already an error so we shoult 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.noUnreachableCode && + !isInAmbientContext(node) && + ( + node.kind !== SyntaxKind.VariableStatement || + getCombinedNodeFlags((node).declarationList) & NodeFlags.BlockScoped || + forEach((node).declarationList.declarations, d => d.initializer) + ) + + if (reportUnreachableCode) { + file.bindDiagnostics.push(createDiagnosticForNode(node, Diagnostics.Unreachable_code_detected)); + } + } + case Reachability.ReportedUnreachable: + return true; + default: + return false; + } + } + + function initializeReachabilityStateIfNecessary(): void { + if (labels) { + return; + } + currentReachabilityState = Reachability.Reachable; + labels = {}; + labelStack = []; + implicitLabels = []; + } } } diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index f71009c7b65..0d795be0091 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -158,6 +158,8 @@ namespace ts { let getGlobalPromiseConstructorLikeType: () => ObjectType; let getGlobalThenableType: () => ObjectType; + let jsxElementClassType: Type; + let tupleTypes: Map = {}; let unionTypes: Map = {}; let intersectionTypes: Map = {}; @@ -7560,7 +7562,6 @@ namespace ts { return prop || unknownSymbol; } - let jsxElementClassType: Type = undefined; function getJsxGlobalElementClassType(): Type { if (!jsxElementClassType) { jsxElementClassType = getExportedTypeFromNamespace(JsxNames.JSX, JsxNames.ElementClass); @@ -9277,21 +9278,11 @@ namespace ts { return aggregatedTypes; } - function bodyContainsAReturnStatement(funcBody: Block) { - return forEachReturnStatement(funcBody, returnStatement => { - return true; - }); - } - - function bodyContainsSingleThrowStatement(body: Block) { - return (body.statements.length === 1) && (body.statements[0].kind === SyntaxKind.ThrowStatement); - } - // TypeScript Specification 1.0 (6.3) - July 2014 // An explicitly typed function whose return type isn't the Void or the Any type // must have at least one return statement somewhere in its body. // An exception to this rule is if the function implementation consists of a single 'throw' statement. - function checkIfNonVoidFunctionHasReturnExpressionsOrSingleThrowStatment(func: FunctionLikeDeclaration, returnType: Type): void { + function checkAllCodePathsInNonVoidFunctionReturnOrThrow(func: FunctionLikeDeclaration, returnType: Type): void { if (!produceDiagnostics) { return; } @@ -9302,26 +9293,20 @@ namespace ts { } // If all we have is a function signature, or an arrow function with an expression body, then there is nothing to check. - if (nodeIsMissing(func.body) || func.body.kind !== SyntaxKind.Block) { + // also if HasImplicitReturnValue flags is not set this means that all codepaths in function body end with return of throw + if (nodeIsMissing(func.body) || func.body.kind !== SyntaxKind.Block || !(func.flags & NodeFlags.HasImplicitReturn)) { return; } - - let bodyBlock = func.body; - - // Ensure the body has at least one return expression. - if (bodyContainsAReturnStatement(bodyBlock)) { - return; + + if (func.flags & NodeFlags.HasExplicitReturn) { + if (compilerOptions.noImplicitReturns) { + error(func.type, Diagnostics.Not_all_code_paths_return_a_value); + } } - - // If there are no return expressions, then we need to check if - // the function body consists solely of a throw statement; - // this is to make an exception for unimplemented functions. - if (bodyContainsSingleThrowStatement(bodyBlock)) { - return; + else { + // This function does not conform to the specification. + error(func.type, Diagnostics.A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value); } - - // This function does not conform to the specification. - error(func.type, Diagnostics.A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value_or_consist_of_a_single_throw_statement); } function checkFunctionExpressionOrObjectLiteralMethod(node: FunctionExpression | MethodDeclaration, contextualMapper?: TypeMapper): Type { @@ -9401,7 +9386,7 @@ namespace ts { } if (returnType && !node.asteriskToken) { - checkIfNonVoidFunctionHasReturnExpressionsOrSingleThrowStatment(node, isAsync ? promisedType : returnType); + checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, isAsync ? promisedType : returnType); } if (node.body) { @@ -10579,8 +10564,15 @@ namespace ts { checkGrammarFunctionLikeDeclaration(node) || checkGrammarAccessor(node) || checkGrammarComputedPropertyName(node.name); if (node.kind === SyntaxKind.GetAccessor) { - if (!isInAmbientContext(node) && nodeIsPresent(node.body) && !(bodyContainsAReturnStatement(node.body) || bodyContainsSingleThrowStatement(node.body))) { - error(node.name, Diagnostics.A_get_accessor_must_return_a_value_or_consist_of_a_single_throw_statement); + if (!isInAmbientContext(node) && nodeIsPresent(node.body) && (node.flags & NodeFlags.HasImplicitReturn)) { + if (node.flags & NodeFlags.HasExplicitReturn) { + if (compilerOptions.noImplicitReturns) { + error(node.name, Diagnostics.Not_all_code_paths_return_a_value); + } + } + else { + error(node.name, Diagnostics.A_get_accessor_must_return_a_value); + } } } @@ -11505,7 +11497,7 @@ namespace ts { promisedType = checkAsyncFunctionReturnType(node); } - checkIfNonVoidFunctionHasReturnExpressionsOrSingleThrowStatment(node, isAsync ? promisedType : returnType); + checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, isAsync ? promisedType : returnType); } if (produceDiagnostics && !node.type) { @@ -14524,7 +14516,7 @@ namespace ts { function initializeTypeChecker() { // Bind all source files and propagate errors forEach(host.getSourceFiles(), file => { - bindSourceFile(file); + bindSourceFile(file, compilerOptions); }); // Initialize global symbol table diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index c56a18b3ab2..c773be4dfb8 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -244,7 +244,27 @@ namespace ts { "classic": ModuleResolutionKind.Classic }, description: Diagnostics.Specifies_module_resolution_strategy_Colon_node_Node_or_classic_TypeScript_pre_1_6 - } + }, + { + name: "noUnusedLabels", + type: "boolean", + description: Diagnostics.Report_error_on_unused_labels + }, + { + name: "noImplicitReturns", + type: "boolean", + description: Diagnostics.Report_error_when_not_all_code_paths_in_function_return_a_value + }, + { + name: "noFallthroughCasesInSwitch", + type: "boolean", + description: Diagnostics.Report_errors_for_fallthrough_cases_in_switch_statement + }, + { + name: "noUnreachableCode", + type: "boolean", + description: Diagnostics.Report_errors_on_unreachable_code + } ]; /* @internal */ diff --git a/src/compiler/diagnosticInformationMap.generated.ts b/src/compiler/diagnosticInformationMap.generated.ts index f7351bf6912..2fc382c1ea9 100644 --- a/src/compiler/diagnosticInformationMap.generated.ts +++ b/src/compiler/diagnosticInformationMap.generated.ts @@ -256,7 +256,7 @@ namespace ts { Neither_type_0_nor_type_1_is_assignable_to_the_other: { code: 2352, category: DiagnosticCategory.Error, key: "Neither type '{0}' nor type '{1}' is assignable to the other." }, Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1: { code: 2353, category: DiagnosticCategory.Error, key: "Object literal may only specify known properties, and '{0}' does not exist in type '{1}'." }, No_best_common_type_exists_among_return_expressions: { code: 2354, category: DiagnosticCategory.Error, key: "No best common type exists among return expressions." }, - A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value_or_consist_of_a_single_throw_statement: { code: 2355, category: DiagnosticCategory.Error, key: "A function whose declared type is neither 'void' nor 'any' must return a value or consist of a single 'throw' statement." }, + A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value: { code: 2355, category: DiagnosticCategory.Error, key: "A function whose declared type is neither 'void' nor 'any' must return a value." }, An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type: { code: 2356, category: DiagnosticCategory.Error, key: "An arithmetic operand must be of type 'any', 'number' or an enum type." }, The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_property_or_indexer: { code: 2357, category: DiagnosticCategory.Error, key: "The operand of an increment or decrement operator must be a variable, property or indexer." }, The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_parameter: { code: 2358, category: DiagnosticCategory.Error, key: "The left-hand side of an 'instanceof' expression must be of type 'any', an object type or a type parameter." }, @@ -277,7 +277,7 @@ namespace ts { Duplicate_number_index_signature: { code: 2375, category: DiagnosticCategory.Error, key: "Duplicate number index signature." }, A_super_call_must_be_the_first_statement_in_the_constructor_when_a_class_contains_initialized_properties_or_has_parameter_properties: { code: 2376, category: DiagnosticCategory.Error, key: "A 'super' call must be the first statement in the constructor when a class contains initialized properties or has parameter properties." }, Constructors_for_derived_classes_must_contain_a_super_call: { code: 2377, category: DiagnosticCategory.Error, key: "Constructors for derived classes must contain a 'super' call." }, - A_get_accessor_must_return_a_value_or_consist_of_a_single_throw_statement: { code: 2378, category: DiagnosticCategory.Error, key: "A 'get' accessor must return a value or consist of a single 'throw' statement." }, + A_get_accessor_must_return_a_value: { code: 2378, category: DiagnosticCategory.Error, key: "A 'get' accessor must return a value." }, Getter_and_setter_accessors_do_not_agree_in_visibility: { code: 2379, category: DiagnosticCategory.Error, key: "Getter and setter accessors do not agree in visibility." }, get_and_set_accessor_must_have_the_same_type: { code: 2380, category: DiagnosticCategory.Error, key: "'get' and 'set' accessor must have the same type." }, A_signature_with_an_implementation_cannot_use_a_string_literal_type: { code: 2381, category: DiagnosticCategory.Error, key: "A signature with an implementation cannot use a string literal type." }, @@ -570,6 +570,10 @@ namespace ts { Initializes_a_TypeScript_project_and_creates_a_tsconfig_json_file: { code: 6070, category: DiagnosticCategory.Message, key: "Initializes a TypeScript project and creates a tsconfig.json file." }, Successfully_created_a_tsconfig_json_file: { code: 6071, category: DiagnosticCategory.Message, key: "Successfully created a tsconfig.json file." }, Suppress_excess_property_checks_for_object_literals: { code: 6072, category: DiagnosticCategory.Message, key: "Suppress excess property checks for object literals." }, + Report_error_on_unused_labels: { code: 6073, category: DiagnosticCategory.Message, key: "Report error on unused labels." }, + Report_error_when_not_all_code_paths_in_function_return_a_value: { code: 6074, category: DiagnosticCategory.Message, key: "Report error when not all code paths in function return a value." }, + Report_errors_for_fallthrough_cases_in_switch_statement: { code: 6075, category: DiagnosticCategory.Message, key: "Report errors for fallthrough cases in switch statement." }, + Report_errors_on_unreachable_code: { code: 6076, category: DiagnosticCategory.Message, key: "Report errors on unreachable code." }, Variable_0_implicitly_has_an_1_type: { code: 7005, category: DiagnosticCategory.Error, key: "Variable '{0}' implicitly has an '{1}' type." }, Parameter_0_implicitly_has_an_1_type: { code: 7006, category: DiagnosticCategory.Error, key: "Parameter '{0}' implicitly has an '{1}' type." }, Member_0_implicitly_has_an_1_type: { code: 7008, category: DiagnosticCategory.Error, key: "Member '{0}' implicitly has an '{1}' type." }, @@ -587,6 +591,10 @@ namespace ts { Function_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions: { code: 7024, category: DiagnosticCategory.Error, key: "Function implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions." }, Generator_implicitly_has_type_0_because_it_does_not_yield_any_values_Consider_supplying_a_return_type: { code: 7025, category: DiagnosticCategory.Error, key: "Generator implicitly has type '{0}' because it does not yield any values. Consider supplying a return type." }, JSX_element_implicitly_has_type_any_because_no_interface_JSX_0_exists: { code: 7026, category: DiagnosticCategory.Error, key: "JSX element implicitly has type 'any' because no interface 'JSX.{0}' exists" }, + Unreachable_code_detected: { code: 7027, category: DiagnosticCategory.Error, key: "Unreachable code detected." }, + Unused_label: { code: 7028, category: DiagnosticCategory.Error, key: "Unused label." }, + Fallthrough_case_in_switch: { code: 7029, category: DiagnosticCategory.Error, key: "Fallthrough case in switch." }, + Not_all_code_paths_return_a_value: { code: 7030, category: DiagnosticCategory.Error, key: "Not all code paths return a value." }, You_cannot_rename_this_element: { code: 8000, category: DiagnosticCategory.Error, key: "You cannot rename this element." }, You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library: { code: 8001, category: DiagnosticCategory.Error, key: "You cannot rename elements that are defined in the standard TypeScript library." }, import_can_only_be_used_in_a_ts_file: { code: 8002, category: DiagnosticCategory.Error, key: "'import ... =' can only be used in a .ts file." }, diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 9fd08ef9bca..d62b837ea5b 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -1013,7 +1013,7 @@ "category": "Error", "code": 2354 }, - "A function whose declared type is neither 'void' nor 'any' must return a value or consist of a single 'throw' statement.": { + "A function whose declared type is neither 'void' nor 'any' must return a value.": { "category": "Error", "code": 2355 }, @@ -1097,7 +1097,7 @@ "category": "Error", "code": 2377 }, - "A 'get' accessor must return a value or consist of a single 'throw' statement.": { + "A 'get' accessor must return a value.": { "category": "Error", "code": 2378 }, @@ -2270,7 +2270,22 @@ "category": "Message", "code": 6072 }, - + "Report error on unused labels.": { + "category": "Message", + "code": 6073 + }, + "Report error when not all code paths in function return a value.": { + "category": "Message", + "code": 6074 + }, + "Report errors for fallthrough cases in switch statement.": { + "category": "Message", + "code": 6075 + }, + "Report errors on unreachable code.": { + "category": "Message", + "code": 6076 + }, "Variable '{0}' implicitly has an '{1}' type.": { "category": "Error", "code": 7005 @@ -2339,8 +2354,22 @@ "category": "Error", "code": 7026 }, - - + "Unreachable code detected.": { + "category": "Error", + "code": 7027 + }, + "Unused label.": { + "category": "Error", + "code": 7028 + }, + "Fallthrough case in switch.": { + "category": "Error", + "code": 7029 + }, + "Not all code paths return a value.": { + "category": "Error", + "code": 7030 + }, "You cannot rename this element.": { "category": "Error", "code": 8000 diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 47182e39527..0d2526cef98 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -376,6 +376,8 @@ namespace ts { OctalLiteral = 0x00010000, // Octal numeric literal Namespace = 0x00020000, // Namespace declaration ExportContext = 0x00040000, // Export context (initialized by binding) + HasImplicitReturn = 0x00080000, // If function implicitly returns on one of codepaths (initialized by binding) + HasExplicitReturn = 0x00100000, // If function has explicit reachable return on one of codepaths (initialized by binding) Modifier = Export | Ambient | Public | Private | Protected | Static | Abstract | Default | Async, AccessibilityModifier = Public | Private | Protected, @@ -2057,7 +2059,11 @@ namespace ts { experimentalDecorators?: boolean; experimentalAsyncFunctions?: boolean; emitDecoratorMetadata?: boolean; - moduleResolution?: ModuleResolutionKind + moduleResolution?: ModuleResolutionKind, + noUnusedLabels?: boolean, + noImplicitReturns?: boolean, + noFallthroughCasesInSwitch?: boolean, + noUnreachableCode?: boolean, /* @internal */ stripInternal?: boolean; // Skip checking lib.d.ts to help speed up tests. diff --git a/src/harness/harness.ts b/src/harness/harness.ts index f65a4f88730..a23f19e36b7 100644 --- a/src/harness/harness.ts +++ b/src/harness/harness.ts @@ -1242,6 +1242,18 @@ module Harness { setting.value.toLowerCase() === "preserve" ? ts.JsxEmit.Preserve : ts.JsxEmit.None; break; + case "nounusedlabels": + options.noUnusedLabels = setting.value === "true" + break; + case "noimplicitreturns": + options.noImplicitReturns = setting.value === "true" + break; + case "nofallthroughcasesinswitch": + options.noFallthroughCasesInSwitch = setting.value === "true" + break; + case "nounreachablecode": + options.noUnreachableCode = setting.value === "true" + break; default: throw new Error("Unsupported compiler setting " + setting.flag); diff --git a/src/services/breakpoints.ts b/src/services/breakpoints.ts index 227ba6a7970..e307b21979e 100644 --- a/src/services/breakpoints.ts +++ b/src/services/breakpoints.ts @@ -446,7 +446,7 @@ namespace ts.BreakpointResolver { // fall through. case SyntaxKind.CatchClause: - return spanInNode(lastOrUndefined((node.parent).statements));; + return spanInNode(lastOrUndefined((node.parent).statements)); case SyntaxKind.CaseBlock: // breakpoint in last statement of the last clause @@ -493,9 +493,6 @@ namespace ts.BreakpointResolver { default: return spanInNode(node.parent); } - - // Default to parent node - return spanInNode(node.parent); } function spanInColonToken(node: Node): TextSpan { diff --git a/src/services/formatting/smartIndenter.ts b/src/services/formatting/smartIndenter.ts index ebbf09e9feb..760ee16a507 100644 --- a/src/services/formatting/smartIndenter.ts +++ b/src/services/formatting/smartIndenter.ts @@ -340,7 +340,6 @@ namespace ts.formatting { return node; } } - return node; } } diff --git a/src/services/navigateTo.ts b/src/services/navigateTo.ts index bc506bc22f9..2a0abba8695 100644 --- a/src/services/navigateTo.ts +++ b/src/services/navigateTo.ts @@ -6,6 +6,9 @@ namespace ts.NavigateTo { let patternMatcher = createPatternMatcher(searchValue); let rawItems: RawNavigateToItem[] = []; + // This means "compare in a case insensitive manner." + let baseSensitivity: Intl.CollatorOptions = { sensitivity: "base" }; + // Search the declarations in all files and output matched NavigateToItem into array of NavigateToItem[] forEach(program.getSourceFiles(), sourceFile => { cancellationToken.throwIfCancellationRequested(); @@ -162,8 +165,6 @@ namespace ts.NavigateTo { return bestMatchKind; } - // This means "compare in a case insensitive manner." - let baseSensitivity: Intl.CollatorOptions = { sensitivity: "base" }; function compareNavigateToItems(i1: RawNavigateToItem, i2: RawNavigateToItem) { // TODO(cyrusn): get the gamut of comparisons that VS already uses here. // Right now we just sort by kind first, and then by name of the item. diff --git a/src/services/services.ts b/src/services/services.ts index 752fb93cd00..44d9786566b 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -4863,7 +4863,7 @@ namespace ts { else if (!isFunctionLike(node)) { forEachChild(node, aggregate); } - }; + } } /** @@ -4910,7 +4910,7 @@ namespace ts { else if (!isFunctionLike(node)) { forEachChild(node, aggregate); } - }; + } } function ownsBreakOrContinueStatement(owner: Node, statement: BreakOrContinueStatement): boolean { @@ -6219,8 +6219,6 @@ namespace ts { } return SemanticMeaning.Value | SemanticMeaning.Type | SemanticMeaning.Namespace; - - Debug.fail("Unknown declaration type"); } function isTypeReference(node: Node): boolean { diff --git a/src/services/shims.ts b/src/services/shims.ts index 307062cebd8..ace438b2778 100644 --- a/src/services/shims.ts +++ b/src/services/shims.ts @@ -320,7 +320,6 @@ namespace ts { // TODO: should this be '==='? if (settingsJson == null || settingsJson == "") { throw Error("LanguageServiceShimHostAdapter.getCompilationSettings: empty compilationSettings"); - return null; } return JSON.parse(settingsJson); } diff --git a/tests/baselines/reference/ParameterList5.errors.txt b/tests/baselines/reference/ParameterList5.errors.txt index 02b86633b95..618ce740915 100644 --- a/tests/baselines/reference/ParameterList5.errors.txt +++ b/tests/baselines/reference/ParameterList5.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/ParameterList5.ts(1,15): error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value or consist of a single 'throw' statement. +tests/cases/compiler/ParameterList5.ts(1,15): error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. tests/cases/compiler/ParameterList5.ts(1,16): error TS2369: A parameter property is only allowed in a constructor implementation. tests/cases/compiler/ParameterList5.ts(1,29): error TS2304: Cannot find name 'C'. @@ -6,7 +6,7 @@ tests/cases/compiler/ParameterList5.ts(1,29): error TS2304: Cannot find name 'C' ==== tests/cases/compiler/ParameterList5.ts (3 errors) ==== function A(): (public B) => C { ~~~~~~~~~~~~~~~ -!!! error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value or consist of a single 'throw' statement. +!!! error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. ~~~~~~~~ !!! error TS2369: A parameter property is only allowed in a constructor implementation. ~ diff --git a/tests/baselines/reference/YieldExpression17_es6.errors.txt b/tests/baselines/reference/YieldExpression17_es6.errors.txt index bc262212526..f987517371f 100644 --- a/tests/baselines/reference/YieldExpression17_es6.errors.txt +++ b/tests/baselines/reference/YieldExpression17_es6.errors.txt @@ -1,5 +1,5 @@ tests/cases/conformance/es6/yieldExpressions/YieldExpression17_es6.ts(1,15): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/conformance/es6/yieldExpressions/YieldExpression17_es6.ts(1,15): error TS2378: A 'get' accessor must return a value or consist of a single 'throw' statement. +tests/cases/conformance/es6/yieldExpressions/YieldExpression17_es6.ts(1,15): error TS2378: A 'get' accessor must return a value. tests/cases/conformance/es6/yieldExpressions/YieldExpression17_es6.ts(1,23): error TS1163: A 'yield' expression is only allowed in a generator body. @@ -8,6 +8,6 @@ tests/cases/conformance/es6/yieldExpressions/YieldExpression17_es6.ts(1,23): err ~~~ !!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. ~~~ -!!! error TS2378: A 'get' accessor must return a value or consist of a single 'throw' statement. +!!! error TS2378: A 'get' accessor must return a value. ~~~~~ !!! error TS1163: A 'yield' expression is only allowed in a generator body. \ No newline at end of file diff --git a/tests/baselines/reference/asyncArrowFunction10_es6.errors.txt b/tests/baselines/reference/asyncArrowFunction10_es6.errors.txt index 2476eaec6e3..08e59e69b9f 100644 --- a/tests/baselines/reference/asyncArrowFunction10_es6.errors.txt +++ b/tests/baselines/reference/asyncArrowFunction10_es6.errors.txt @@ -1,7 +1,7 @@ tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction10_es6.ts(2,11): error TS2304: Cannot find name 'async'. tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction10_es6.ts(2,17): error TS1005: ',' expected. tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction10_es6.ts(2,20): error TS1005: '=' expected. -tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction10_es6.ts(2,24): error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value or consist of a single 'throw' statement. +tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction10_es6.ts(2,24): error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction10_es6.ts(4,11): error TS2304: Cannot find name 'await'. @@ -15,7 +15,7 @@ tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction10_es6.ts ~ !!! error TS1005: '=' expected. ~~~~~~~~~~~~~ -!!! error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value or consist of a single 'throw' statement. +!!! error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. // Legal to use 'await' in a type context. var v: await; ~~~~~ diff --git a/tests/baselines/reference/asyncFunctionDeclaration12_es6.errors.txt b/tests/baselines/reference/asyncFunctionDeclaration12_es6.errors.txt index 978492f0744..43df8e21659 100644 --- a/tests/baselines/reference/asyncFunctionDeclaration12_es6.errors.txt +++ b/tests/baselines/reference/asyncFunctionDeclaration12_es6.errors.txt @@ -1,6 +1,6 @@ tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration12_es6.ts(1,24): error TS1005: '(' expected. tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration12_es6.ts(1,29): error TS1005: '=' expected. -tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration12_es6.ts(1,33): error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value or consist of a single 'throw' statement. +tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration12_es6.ts(1,33): error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration12_es6.ts(1,47): error TS1005: '=>' expected. @@ -11,6 +11,6 @@ tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration1 ~ !!! error TS1005: '=' expected. ~~~~~~~~~~~~~ -!!! error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value or consist of a single 'throw' statement. +!!! 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/asyncGetter_es6.errors.txt b/tests/baselines/reference/asyncGetter_es6.errors.txt index 5f5a9f6b1d7..f6deea16d06 100644 --- a/tests/baselines/reference/asyncGetter_es6.errors.txt +++ b/tests/baselines/reference/asyncGetter_es6.errors.txt @@ -1,5 +1,5 @@ tests/cases/conformance/async/es6/asyncGetter_es6.ts(2,3): error TS1042: 'async' modifier cannot be used here. -tests/cases/conformance/async/es6/asyncGetter_es6.ts(2,13): error TS2378: A 'get' accessor must return a value or consist of a single 'throw' statement. +tests/cases/conformance/async/es6/asyncGetter_es6.ts(2,13): error TS2378: A 'get' accessor must return a value. ==== tests/cases/conformance/async/es6/asyncGetter_es6.ts (2 errors) ==== @@ -8,6 +8,6 @@ tests/cases/conformance/async/es6/asyncGetter_es6.ts(2,13): error TS2378: A 'get ~~~~~ !!! error TS1042: 'async' modifier cannot be used here. ~~~ -!!! error TS2378: A 'get' accessor must return a value or consist of a single 'throw' statement. +!!! error TS2378: A 'get' accessor must return a value. } } \ No newline at end of file diff --git a/tests/baselines/reference/computedPropertyNames2_ES5.errors.txt b/tests/baselines/reference/computedPropertyNames2_ES5.errors.txt index 2fbf68b4437..e704126c055 100644 --- a/tests/baselines/reference/computedPropertyNames2_ES5.errors.txt +++ b/tests/baselines/reference/computedPropertyNames2_ES5.errors.txt @@ -1,5 +1,5 @@ -tests/cases/conformance/es6/computedProperties/computedPropertyNames2_ES5.ts(6,9): error TS2378: A 'get' accessor must return a value or consist of a single 'throw' statement. -tests/cases/conformance/es6/computedProperties/computedPropertyNames2_ES5.ts(8,16): error TS2378: A 'get' accessor must return a value or consist of a single 'throw' statement. +tests/cases/conformance/es6/computedProperties/computedPropertyNames2_ES5.ts(6,9): error TS2378: A 'get' accessor must return a value. +tests/cases/conformance/es6/computedProperties/computedPropertyNames2_ES5.ts(8,16): error TS2378: A 'get' accessor must return a value. ==== tests/cases/conformance/es6/computedProperties/computedPropertyNames2_ES5.ts (2 errors) ==== @@ -10,10 +10,10 @@ tests/cases/conformance/es6/computedProperties/computedPropertyNames2_ES5.ts(8,1 static [methodName]() { } get [accessorName]() { } ~~~~~~~~~~~~~~ -!!! error TS2378: A 'get' accessor must return a value or consist of a single 'throw' statement. +!!! error TS2378: A 'get' accessor must return a value. set [accessorName](v) { } static get [accessorName]() { } ~~~~~~~~~~~~~~ -!!! error TS2378: A 'get' accessor must return a value or consist of a single 'throw' statement. +!!! error TS2378: A 'get' accessor must return a value. static set [accessorName](v) { } } \ No newline at end of file diff --git a/tests/baselines/reference/computedPropertyNames2_ES6.errors.txt b/tests/baselines/reference/computedPropertyNames2_ES6.errors.txt index 3f18a8764b4..6b294981638 100644 --- a/tests/baselines/reference/computedPropertyNames2_ES6.errors.txt +++ b/tests/baselines/reference/computedPropertyNames2_ES6.errors.txt @@ -1,5 +1,5 @@ -tests/cases/conformance/es6/computedProperties/computedPropertyNames2_ES6.ts(6,9): error TS2378: A 'get' accessor must return a value or consist of a single 'throw' statement. -tests/cases/conformance/es6/computedProperties/computedPropertyNames2_ES6.ts(8,16): error TS2378: A 'get' accessor must return a value or consist of a single 'throw' statement. +tests/cases/conformance/es6/computedProperties/computedPropertyNames2_ES6.ts(6,9): error TS2378: A 'get' accessor must return a value. +tests/cases/conformance/es6/computedProperties/computedPropertyNames2_ES6.ts(8,16): error TS2378: A 'get' accessor must return a value. ==== tests/cases/conformance/es6/computedProperties/computedPropertyNames2_ES6.ts (2 errors) ==== @@ -10,10 +10,10 @@ tests/cases/conformance/es6/computedProperties/computedPropertyNames2_ES6.ts(8,1 static [methodName]() { } get [accessorName]() { } ~~~~~~~~~~~~~~ -!!! error TS2378: A 'get' accessor must return a value or consist of a single 'throw' statement. +!!! error TS2378: A 'get' accessor must return a value. set [accessorName](v) { } static get [accessorName]() { } ~~~~~~~~~~~~~~ -!!! error TS2378: A 'get' accessor must return a value or consist of a single 'throw' statement. +!!! error TS2378: A 'get' accessor must return a value. static set [accessorName](v) { } } \ No newline at end of file diff --git a/tests/baselines/reference/computedPropertyNames3_ES5.errors.txt b/tests/baselines/reference/computedPropertyNames3_ES5.errors.txt index a31965dc69e..fd6f8e8bdc1 100644 --- a/tests/baselines/reference/computedPropertyNames3_ES5.errors.txt +++ b/tests/baselines/reference/computedPropertyNames3_ES5.errors.txt @@ -1,9 +1,9 @@ tests/cases/conformance/es6/computedProperties/computedPropertyNames3_ES5.ts(4,12): error TS2464: A computed property name must be of type 'string', 'number', 'symbol', or 'any'. -tests/cases/conformance/es6/computedProperties/computedPropertyNames3_ES5.ts(5,9): error TS2378: A 'get' accessor must return a value or consist of a single 'throw' statement. +tests/cases/conformance/es6/computedProperties/computedPropertyNames3_ES5.ts(5,9): error TS2378: A 'get' accessor must return a value. tests/cases/conformance/es6/computedProperties/computedPropertyNames3_ES5.ts(5,9): error TS2464: A computed property name must be of type 'string', 'number', 'symbol', or 'any'. tests/cases/conformance/es6/computedProperties/computedPropertyNames3_ES5.ts(5,17): error TS1102: 'delete' cannot be called on an identifier in strict mode. tests/cases/conformance/es6/computedProperties/computedPropertyNames3_ES5.ts(6,9): error TS2464: A computed property name must be of type 'string', 'number', 'symbol', or 'any'. -tests/cases/conformance/es6/computedProperties/computedPropertyNames3_ES5.ts(7,16): error TS2378: A 'get' accessor must return a value or consist of a single 'throw' statement. +tests/cases/conformance/es6/computedProperties/computedPropertyNames3_ES5.ts(7,16): error TS2378: A 'get' accessor must return a value. tests/cases/conformance/es6/computedProperties/computedPropertyNames3_ES5.ts(7,16): error TS2464: A computed property name must be of type 'string', 'number', 'symbol', or 'any'. @@ -16,7 +16,7 @@ tests/cases/conformance/es6/computedProperties/computedPropertyNames3_ES5.ts(7,1 !!! error TS2464: A computed property name must be of type 'string', 'number', 'symbol', or 'any'. get [delete id]() { } ~~~~~~~~~~~ -!!! error TS2378: A 'get' accessor must return a value or consist of a single 'throw' statement. +!!! error TS2378: A 'get' accessor must return a value. ~~~~~~~~~~~ !!! error TS2464: A computed property name must be of type 'string', 'number', 'symbol', or 'any'. ~~ @@ -26,7 +26,7 @@ tests/cases/conformance/es6/computedProperties/computedPropertyNames3_ES5.ts(7,1 !!! error TS2464: A computed property name must be of type 'string', 'number', 'symbol', or 'any'. static get [""]() { } ~~~~~~~~~~~~ -!!! error TS2378: A 'get' accessor must return a value or consist of a single 'throw' statement. +!!! error TS2378: A 'get' accessor must return a value. ~~~~~~~~~~~~ !!! error TS2464: A computed property name must be of type 'string', 'number', 'symbol', or 'any'. static set [id.toString()](v) { } diff --git a/tests/baselines/reference/computedPropertyNames3_ES6.errors.txt b/tests/baselines/reference/computedPropertyNames3_ES6.errors.txt index b9009112347..4299437777d 100644 --- a/tests/baselines/reference/computedPropertyNames3_ES6.errors.txt +++ b/tests/baselines/reference/computedPropertyNames3_ES6.errors.txt @@ -1,9 +1,9 @@ tests/cases/conformance/es6/computedProperties/computedPropertyNames3_ES6.ts(4,12): error TS2464: A computed property name must be of type 'string', 'number', 'symbol', or 'any'. -tests/cases/conformance/es6/computedProperties/computedPropertyNames3_ES6.ts(5,9): error TS2378: A 'get' accessor must return a value or consist of a single 'throw' statement. +tests/cases/conformance/es6/computedProperties/computedPropertyNames3_ES6.ts(5,9): error TS2378: A 'get' accessor must return a value. tests/cases/conformance/es6/computedProperties/computedPropertyNames3_ES6.ts(5,9): error TS2464: A computed property name must be of type 'string', 'number', 'symbol', or 'any'. tests/cases/conformance/es6/computedProperties/computedPropertyNames3_ES6.ts(5,17): error TS1102: 'delete' cannot be called on an identifier in strict mode. tests/cases/conformance/es6/computedProperties/computedPropertyNames3_ES6.ts(6,9): error TS2464: A computed property name must be of type 'string', 'number', 'symbol', or 'any'. -tests/cases/conformance/es6/computedProperties/computedPropertyNames3_ES6.ts(7,16): error TS2378: A 'get' accessor must return a value or consist of a single 'throw' statement. +tests/cases/conformance/es6/computedProperties/computedPropertyNames3_ES6.ts(7,16): error TS2378: A 'get' accessor must return a value. tests/cases/conformance/es6/computedProperties/computedPropertyNames3_ES6.ts(7,16): error TS2464: A computed property name must be of type 'string', 'number', 'symbol', or 'any'. @@ -16,7 +16,7 @@ tests/cases/conformance/es6/computedProperties/computedPropertyNames3_ES6.ts(7,1 !!! error TS2464: A computed property name must be of type 'string', 'number', 'symbol', or 'any'. get [delete id]() { } ~~~~~~~~~~~ -!!! error TS2378: A 'get' accessor must return a value or consist of a single 'throw' statement. +!!! error TS2378: A 'get' accessor must return a value. ~~~~~~~~~~~ !!! error TS2464: A computed property name must be of type 'string', 'number', 'symbol', or 'any'. ~~ @@ -26,7 +26,7 @@ tests/cases/conformance/es6/computedProperties/computedPropertyNames3_ES6.ts(7,1 !!! error TS2464: A computed property name must be of type 'string', 'number', 'symbol', or 'any'. static get [""]() { } ~~~~~~~~~~~~ -!!! error TS2378: A 'get' accessor must return a value or consist of a single 'throw' statement. +!!! error TS2378: A 'get' accessor must return a value. ~~~~~~~~~~~~ !!! error TS2464: A computed property name must be of type 'string', 'number', 'symbol', or 'any'. static set [id.toString()](v) { } diff --git a/tests/baselines/reference/conflictingTypeAnnotatedVar.errors.txt b/tests/baselines/reference/conflictingTypeAnnotatedVar.errors.txt index 0b667108b5f..afae9d40431 100644 --- a/tests/baselines/reference/conflictingTypeAnnotatedVar.errors.txt +++ b/tests/baselines/reference/conflictingTypeAnnotatedVar.errors.txt @@ -1,8 +1,8 @@ tests/cases/compiler/conflictingTypeAnnotatedVar.ts(1,5): error TS2300: Duplicate identifier 'foo'. tests/cases/compiler/conflictingTypeAnnotatedVar.ts(2,10): error TS2300: Duplicate identifier 'foo'. -tests/cases/compiler/conflictingTypeAnnotatedVar.ts(2,17): error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value or consist of a single 'throw' statement. +tests/cases/compiler/conflictingTypeAnnotatedVar.ts(2,17): error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. tests/cases/compiler/conflictingTypeAnnotatedVar.ts(3,10): error TS2300: Duplicate identifier 'foo'. -tests/cases/compiler/conflictingTypeAnnotatedVar.ts(3,17): error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value or consist of a single 'throw' statement. +tests/cases/compiler/conflictingTypeAnnotatedVar.ts(3,17): error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. ==== tests/cases/compiler/conflictingTypeAnnotatedVar.ts (5 errors) ==== @@ -13,9 +13,9 @@ tests/cases/compiler/conflictingTypeAnnotatedVar.ts(3,17): error TS2355: A funct ~~~ !!! error TS2300: Duplicate identifier 'foo'. ~~~~~~ -!!! error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value or consist of a single 'throw' statement. +!!! error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. function foo(): number { } ~~~ !!! error TS2300: Duplicate identifier 'foo'. ~~~~~~ -!!! error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value or consist of a single 'throw' statement. \ No newline at end of file +!!! error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. \ No newline at end of file diff --git a/tests/baselines/reference/errorOnContextuallyTypedReturnType.errors.txt b/tests/baselines/reference/errorOnContextuallyTypedReturnType.errors.txt index 5b66a377307..403e79b8742 100644 --- a/tests/baselines/reference/errorOnContextuallyTypedReturnType.errors.txt +++ b/tests/baselines/reference/errorOnContextuallyTypedReturnType.errors.txt @@ -1,6 +1,6 @@ tests/cases/compiler/errorOnContextuallyTypedReturnType.ts(1,5): error TS2322: Type '() => void' is not assignable to type '() => boolean'. Type 'void' is not assignable to type 'boolean'. -tests/cases/compiler/errorOnContextuallyTypedReturnType.ts(2,37): error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value or consist of a single 'throw' statement. +tests/cases/compiler/errorOnContextuallyTypedReturnType.ts(2,37): error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. ==== tests/cases/compiler/errorOnContextuallyTypedReturnType.ts (2 errors) ==== @@ -10,5 +10,5 @@ tests/cases/compiler/errorOnContextuallyTypedReturnType.ts(2,37): error TS2355: !!! error TS2322: Type 'void' is not assignable to type 'boolean'. var n2: () => boolean = function ():boolean { }; // expect an error here ~~~~~~~ -!!! error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value or consist of a single 'throw' statement. +!!! error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. \ No newline at end of file diff --git a/tests/baselines/reference/functionImplementationErrors.errors.txt b/tests/baselines/reference/functionImplementationErrors.errors.txt index 0c74588c316..1ab438e340b 100644 --- a/tests/baselines/reference/functionImplementationErrors.errors.txt +++ b/tests/baselines/reference/functionImplementationErrors.errors.txt @@ -2,10 +2,9 @@ tests/cases/conformance/functions/functionImplementationErrors.ts(2,10): error T tests/cases/conformance/functions/functionImplementationErrors.ts(6,19): error TS2354: No best common type exists among return expressions. tests/cases/conformance/functions/functionImplementationErrors.ts(10,10): error TS2354: No best common type exists among return expressions. tests/cases/conformance/functions/functionImplementationErrors.ts(16,10): error TS2354: No best common type exists among return expressions. -tests/cases/conformance/functions/functionImplementationErrors.ts(25,16): error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value or consist of a single 'throw' statement. +tests/cases/conformance/functions/functionImplementationErrors.ts(25,16): error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. tests/cases/conformance/functions/functionImplementationErrors.ts(30,17): error TS2373: Initializer of parameter 'n' cannot reference identifier 'm' declared after it. tests/cases/conformance/functions/functionImplementationErrors.ts(35,17): error TS2373: Initializer of parameter 'n' cannot reference identifier 'm' declared after it. -tests/cases/conformance/functions/functionImplementationErrors.ts(40,28): error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value or consist of a single 'throw' statement. tests/cases/conformance/functions/functionImplementationErrors.ts(49,10): error TS2354: No best common type exists among return expressions. tests/cases/conformance/functions/functionImplementationErrors.ts(53,10): error TS2354: No best common type exists among return expressions. tests/cases/conformance/functions/functionImplementationErrors.ts(57,11): error TS2354: No best common type exists among return expressions. @@ -14,7 +13,7 @@ tests/cases/conformance/functions/functionImplementationErrors.ts(65,11): error tests/cases/conformance/functions/functionImplementationErrors.ts(69,11): error TS2354: No best common type exists among return expressions. -==== tests/cases/conformance/functions/functionImplementationErrors.ts (14 errors) ==== +==== tests/cases/conformance/functions/functionImplementationErrors.ts (13 errors) ==== // FunctionExpression with no return type annotation with multiple return statements with unrelated types var f1 = function () { ~~~~~~~~ @@ -52,7 +51,7 @@ tests/cases/conformance/functions/functionImplementationErrors.ts(69,11): error // Function implemetnation with non -void return type annotation with no return function f5(): number { ~~~~~~ -!!! error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value or consist of a single 'throw' statement. +!!! error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. } var m; @@ -72,8 +71,6 @@ tests/cases/conformance/functions/functionImplementationErrors.ts(69,11): error // FunctionExpression with non -void return type annotation with a throw, no return, and other code // Should be error but isn't undefined === function (): number { - ~~~~~~ -!!! error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value or consist of a single 'throw' statement. throw undefined; var x = 4; }; diff --git a/tests/baselines/reference/functionWithThrowButNoReturn1.errors.txt b/tests/baselines/reference/functionWithThrowButNoReturn1.errors.txt deleted file mode 100644 index 72f45da8d97..00000000000 --- a/tests/baselines/reference/functionWithThrowButNoReturn1.errors.txt +++ /dev/null @@ -1,11 +0,0 @@ -tests/cases/compiler/functionWithThrowButNoReturn1.ts(1,16): error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value or consist of a single 'throw' statement. - - -==== tests/cases/compiler/functionWithThrowButNoReturn1.ts (1 errors) ==== - function fn(): number { - ~~~~~~ -!!! error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value or consist of a single 'throw' statement. - throw new Error('NYI'); - var t; - } - \ No newline at end of file diff --git a/tests/baselines/reference/functionWithThrowButNoReturn1.symbols b/tests/baselines/reference/functionWithThrowButNoReturn1.symbols new file mode 100644 index 00000000000..7dde523701d --- /dev/null +++ b/tests/baselines/reference/functionWithThrowButNoReturn1.symbols @@ -0,0 +1,11 @@ +=== tests/cases/compiler/functionWithThrowButNoReturn1.ts === +function fn(): number { +>fn : Symbol(fn, Decl(functionWithThrowButNoReturn1.ts, 0, 0)) + + throw new Error('NYI'); +>Error : Symbol(Error, Decl(lib.d.ts, 876, 38), Decl(lib.d.ts, 889, 11)) + + var t; +>t : Symbol(t, Decl(functionWithThrowButNoReturn1.ts, 2, 5)) +} + diff --git a/tests/baselines/reference/functionWithThrowButNoReturn1.types b/tests/baselines/reference/functionWithThrowButNoReturn1.types new file mode 100644 index 00000000000..c136d8a4076 --- /dev/null +++ b/tests/baselines/reference/functionWithThrowButNoReturn1.types @@ -0,0 +1,13 @@ +=== tests/cases/compiler/functionWithThrowButNoReturn1.ts === +function fn(): number { +>fn : () => number + + throw new Error('NYI'); +>new Error('NYI') : Error +>Error : ErrorConstructor +>'NYI' : string + + var t; +>t : any +} + diff --git a/tests/baselines/reference/functionsMissingReturnStatementsAndExpressions.errors.txt b/tests/baselines/reference/functionsMissingReturnStatementsAndExpressions.errors.txt index 2c5ff15f863..88b0c8d5e14 100644 --- a/tests/baselines/reference/functionsMissingReturnStatementsAndExpressions.errors.txt +++ b/tests/baselines/reference/functionsMissingReturnStatementsAndExpressions.errors.txt @@ -1,15 +1,13 @@ -tests/cases/compiler/functionsMissingReturnStatementsAndExpressions.ts(2,16): error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value or consist of a single 'throw' statement. -tests/cases/compiler/functionsMissingReturnStatementsAndExpressions.ts(64,17): error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value or consist of a single 'throw' statement. -tests/cases/compiler/functionsMissingReturnStatementsAndExpressions.ts(94,16): error TS2378: A 'get' accessor must return a value or consist of a single 'throw' statement. -tests/cases/compiler/functionsMissingReturnStatementsAndExpressions.ts(112,16): error TS2378: A 'get' accessor must return a value or consist of a single 'throw' statement. +tests/cases/compiler/functionsMissingReturnStatementsAndExpressions.ts(2,16): error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. +tests/cases/compiler/functionsMissingReturnStatementsAndExpressions.ts(94,16): error TS2378: A 'get' accessor must return a value. tests/cases/compiler/functionsMissingReturnStatementsAndExpressions.ts(117,5): error TS1003: Identifier expected. -==== tests/cases/compiler/functionsMissingReturnStatementsAndExpressions.ts (5 errors) ==== +==== tests/cases/compiler/functionsMissingReturnStatementsAndExpressions.ts (3 errors) ==== function f1(): string { ~~~~~~ -!!! error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value or consist of a single 'throw' statement. +!!! error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. // errors because there are no return statements } @@ -72,8 +70,6 @@ tests/cases/compiler/functionsMissingReturnStatementsAndExpressions.ts(117,5): e } function f14(): number { - ~~~~~~ -!!! error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value or consist of a single 'throw' statement. // Not fine, since we can *only* consist of a single throw statement // if no return statements are present but we are annotated. throw undefined; @@ -105,7 +101,7 @@ tests/cases/compiler/functionsMissingReturnStatementsAndExpressions.ts(117,5): e class C { public get m1() { ~~ -!!! error TS2378: A 'get' accessor must return a value or consist of a single 'throw' statement. +!!! error TS2378: A 'get' accessor must return a value. // Errors; get accessors must return a value. } @@ -124,8 +120,6 @@ tests/cases/compiler/functionsMissingReturnStatementsAndExpressions.ts(117,5): e } public get m5() { - ~~ -!!! error TS2378: A 'get' accessor must return a value or consist of a single 'throw' statement. // Not fine, since we can *only* consist of a single throw statement // if no return statements are present but we are a get accessor. throw null; diff --git a/tests/baselines/reference/getterMissingReturnError.errors.txt b/tests/baselines/reference/getterMissingReturnError.errors.txt index 8900cc5e78f..e504de07ef4 100644 --- a/tests/baselines/reference/getterMissingReturnError.errors.txt +++ b/tests/baselines/reference/getterMissingReturnError.errors.txt @@ -1,5 +1,5 @@ tests/cases/compiler/getterMissingReturnError.ts(2,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/compiler/getterMissingReturnError.ts(2,16): error TS2378: A 'get' accessor must return a value or consist of a single 'throw' statement. +tests/cases/compiler/getterMissingReturnError.ts(2,16): error TS2378: A 'get' accessor must return a value. ==== tests/cases/compiler/getterMissingReturnError.ts (2 errors) ==== @@ -8,7 +8,7 @@ tests/cases/compiler/getterMissingReturnError.ts(2,16): error TS2378: A 'get' ac ~~ !!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. ~~ -!!! error TS2378: A 'get' accessor must return a value or consist of a single 'throw' statement. +!!! error TS2378: A 'get' accessor must return a value. } } diff --git a/tests/baselines/reference/invalidReturnStatements.errors.txt b/tests/baselines/reference/invalidReturnStatements.errors.txt index 780166e07c2..6fbe961cd54 100644 --- a/tests/baselines/reference/invalidReturnStatements.errors.txt +++ b/tests/baselines/reference/invalidReturnStatements.errors.txt @@ -1,7 +1,7 @@ -tests/cases/conformance/statements/returnStatements/invalidReturnStatements.ts(2,17): error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value or consist of a single 'throw' statement. -tests/cases/conformance/statements/returnStatements/invalidReturnStatements.ts(3,17): error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value or consist of a single 'throw' statement. -tests/cases/conformance/statements/returnStatements/invalidReturnStatements.ts(4,17): error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value or consist of a single 'throw' statement. -tests/cases/conformance/statements/returnStatements/invalidReturnStatements.ts(5,17): error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value or consist of a single 'throw' statement. +tests/cases/conformance/statements/returnStatements/invalidReturnStatements.ts(2,17): error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. +tests/cases/conformance/statements/returnStatements/invalidReturnStatements.ts(3,17): error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. +tests/cases/conformance/statements/returnStatements/invalidReturnStatements.ts(4,17): error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. +tests/cases/conformance/statements/returnStatements/invalidReturnStatements.ts(5,17): error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. tests/cases/conformance/statements/returnStatements/invalidReturnStatements.ts(16,29): error TS2322: Type '{ id: number; }' is not assignable to type 'D'. Property 'name' is missing in type '{ id: number; }'. tests/cases/conformance/statements/returnStatements/invalidReturnStatements.ts(18,29): error TS2322: Type 'C' is not assignable to type 'D'. @@ -12,16 +12,16 @@ tests/cases/conformance/statements/returnStatements/invalidReturnStatements.ts(1 // all the following should be error function fn1(): number { } ~~~~~~ -!!! error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value or consist of a single 'throw' statement. +!!! error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. function fn2(): string { } ~~~~~~ -!!! error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value or consist of a single 'throw' statement. +!!! error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. function fn3(): boolean { } ~~~~~~~ -!!! error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value or consist of a single 'throw' statement. +!!! error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. function fn4(): Date { } ~~~~ -!!! error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value or consist of a single 'throw' statement. +!!! error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. function fn7(): any { } // should be valid: any includes void interface I { id: number } diff --git a/tests/baselines/reference/methodInAmbientClass1.errors.txt b/tests/baselines/reference/methodInAmbientClass1.errors.txt index 05183378a85..7032d715629 100644 --- a/tests/baselines/reference/methodInAmbientClass1.errors.txt +++ b/tests/baselines/reference/methodInAmbientClass1.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/methodInAmbientClass1.ts(2,12): error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value or consist of a single 'throw' statement. +tests/cases/compiler/methodInAmbientClass1.ts(2,12): error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. tests/cases/compiler/methodInAmbientClass1.ts(2,20): error TS1184: An implementation cannot be declared in ambient contexts. @@ -6,7 +6,7 @@ tests/cases/compiler/methodInAmbientClass1.ts(2,20): error TS1184: An implementa declare class Foo { fn(): boolean { ~~~~~~~ -!!! error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value or consist of a single 'throw' statement. +!!! error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. ~ !!! error TS1184: An implementation cannot be declared in ambient contexts. } diff --git a/tests/baselines/reference/missingReturnStatement.errors.txt b/tests/baselines/reference/missingReturnStatement.errors.txt index c7cedd793de..8926d22be3d 100644 --- a/tests/baselines/reference/missingReturnStatement.errors.txt +++ b/tests/baselines/reference/missingReturnStatement.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/missingReturnStatement.ts(3,22): error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value or consist of a single 'throw' statement. +tests/cases/compiler/missingReturnStatement.ts(3,22): error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. ==== tests/cases/compiler/missingReturnStatement.ts (1 errors) ==== @@ -6,7 +6,7 @@ tests/cases/compiler/missingReturnStatement.ts(3,22): error TS2355: A function w export class Bug { public foo():string { ~~~~~~ -!!! error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value or consist of a single 'throw' statement. +!!! error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. } } } diff --git a/tests/baselines/reference/missingReturnStatement1.errors.txt b/tests/baselines/reference/missingReturnStatement1.errors.txt index de471f90ac4..9d3cf78411e 100644 --- a/tests/baselines/reference/missingReturnStatement1.errors.txt +++ b/tests/baselines/reference/missingReturnStatement1.errors.txt @@ -1,11 +1,11 @@ -tests/cases/compiler/missingReturnStatement1.ts(2,12): error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value or consist of a single 'throw' statement. +tests/cases/compiler/missingReturnStatement1.ts(2,12): error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. ==== tests/cases/compiler/missingReturnStatement1.ts (1 errors) ==== class Foo { foo(): number { ~~~~~~ -!!! error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value or consist of a single 'throw' statement. +!!! error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. //return 4; } } diff --git a/tests/baselines/reference/multiLineErrors.errors.txt b/tests/baselines/reference/multiLineErrors.errors.txt index 23a6278b4fb..70366aeabed 100644 --- a/tests/baselines/reference/multiLineErrors.errors.txt +++ b/tests/baselines/reference/multiLineErrors.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/multiLineErrors.ts(3,22): error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value or consist of a single 'throw' statement. +tests/cases/compiler/multiLineErrors.ts(3,22): error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. tests/cases/compiler/multiLineErrors.ts(21,1): error TS2322: Type 'A2' is not assignable to type 'A1'. Types of property 'x' are incompatible. Type '{ y: string; }' is not assignable to type '{ y: number; }'. @@ -17,7 +17,7 @@ tests/cases/compiler/multiLineErrors.ts(21,1): error TS2322: Type 'A2' is not as ~~~~~~~~~~~~~~ } ~ -!!! error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value or consist of a single 'throw' statement. +!!! error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. { var x = 4; var y = 10; diff --git a/tests/baselines/reference/objectLiteralMemberWithModifiers2.errors.txt b/tests/baselines/reference/objectLiteralMemberWithModifiers2.errors.txt index e939725ea6e..be2bea5e241 100644 --- a/tests/baselines/reference/objectLiteralMemberWithModifiers2.errors.txt +++ b/tests/baselines/reference/objectLiteralMemberWithModifiers2.errors.txt @@ -1,5 +1,5 @@ tests/cases/compiler/objectLiteralMemberWithModifiers2.ts(1,22): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/compiler/objectLiteralMemberWithModifiers2.ts(1,22): error TS2378: A 'get' accessor must return a value or consist of a single 'throw' statement. +tests/cases/compiler/objectLiteralMemberWithModifiers2.ts(1,22): error TS2378: A 'get' accessor must return a value. ==== tests/cases/compiler/objectLiteralMemberWithModifiers2.ts (2 errors) ==== @@ -7,4 +7,4 @@ tests/cases/compiler/objectLiteralMemberWithModifiers2.ts(1,22): error TS2378: A ~~~ !!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. ~~~ -!!! error TS2378: A 'get' accessor must return a value or consist of a single 'throw' statement. \ No newline at end of file +!!! error TS2378: A 'get' accessor must return a value. \ No newline at end of file diff --git a/tests/baselines/reference/objectLiteralWithSemicolons5.errors.txt b/tests/baselines/reference/objectLiteralWithSemicolons5.errors.txt index 7373c3d535d..5a24f29252c 100644 --- a/tests/baselines/reference/objectLiteralWithSemicolons5.errors.txt +++ b/tests/baselines/reference/objectLiteralWithSemicolons5.errors.txt @@ -1,7 +1,7 @@ tests/cases/compiler/objectLiteralWithSemicolons5.ts(1,20): error TS1005: ',' expected. tests/cases/compiler/objectLiteralWithSemicolons5.ts(1,25): error TS2304: Cannot find name 'b'. tests/cases/compiler/objectLiteralWithSemicolons5.ts(1,26): error TS1005: ',' expected. -tests/cases/compiler/objectLiteralWithSemicolons5.ts(1,32): error TS2378: A 'get' accessor must return a value or consist of a single 'throw' statement. +tests/cases/compiler/objectLiteralWithSemicolons5.ts(1,32): error TS2378: A 'get' accessor must return a value. tests/cases/compiler/objectLiteralWithSemicolons5.ts(1,41): error TS1005: ',' expected. @@ -14,6 +14,6 @@ tests/cases/compiler/objectLiteralWithSemicolons5.ts(1,41): error TS1005: ',' ex ~ !!! error TS1005: ',' expected. ~~~ -!!! error TS2378: A 'get' accessor must return a value or consist of a single 'throw' statement. +!!! error TS2378: A 'get' accessor must return a value. ~ !!! error TS1005: ',' expected. \ No newline at end of file diff --git a/tests/baselines/reference/parserAccessors1.errors.txt b/tests/baselines/reference/parserAccessors1.errors.txt index 8c5033da0c4..2ef8d4e37ab 100644 --- a/tests/baselines/reference/parserAccessors1.errors.txt +++ b/tests/baselines/reference/parserAccessors1.errors.txt @@ -1,9 +1,9 @@ -tests/cases/conformance/parser/ecmascript5/Accessors/parserAccessors1.ts(2,9): error TS2378: A 'get' accessor must return a value or consist of a single 'throw' statement. +tests/cases/conformance/parser/ecmascript5/Accessors/parserAccessors1.ts(2,9): error TS2378: A 'get' accessor must return a value. ==== tests/cases/conformance/parser/ecmascript5/Accessors/parserAccessors1.ts (1 errors) ==== class C { get Foo() { } ~~~ -!!! error TS2378: A 'get' accessor must return a value or consist of a single 'throw' statement. +!!! error TS2378: A 'get' accessor must return a value. } \ No newline at end of file diff --git a/tests/baselines/reference/parserAccessors10.errors.txt b/tests/baselines/reference/parserAccessors10.errors.txt index a5228f47443..d6a2b99eaca 100644 --- a/tests/baselines/reference/parserAccessors10.errors.txt +++ b/tests/baselines/reference/parserAccessors10.errors.txt @@ -1,9 +1,9 @@ -tests/cases/conformance/parser/ecmascript5/Accessors/parserAccessors10.ts(2,14): error TS2378: A 'get' accessor must return a value or consist of a single 'throw' statement. +tests/cases/conformance/parser/ecmascript5/Accessors/parserAccessors10.ts(2,14): error TS2378: A 'get' accessor must return a value. ==== tests/cases/conformance/parser/ecmascript5/Accessors/parserAccessors10.ts (1 errors) ==== var v = { public get foo() { } ~~~ -!!! error TS2378: A 'get' accessor must return a value or consist of a single 'throw' statement. +!!! error TS2378: A 'get' accessor must return a value. }; \ No newline at end of file diff --git a/tests/baselines/reference/parserAccessors3.errors.txt b/tests/baselines/reference/parserAccessors3.errors.txt index 2987b606451..5411cd544eb 100644 --- a/tests/baselines/reference/parserAccessors3.errors.txt +++ b/tests/baselines/reference/parserAccessors3.errors.txt @@ -1,7 +1,7 @@ -tests/cases/conformance/parser/ecmascript5/Accessors/parserAccessors3.ts(1,15): error TS2378: A 'get' accessor must return a value or consist of a single 'throw' statement. +tests/cases/conformance/parser/ecmascript5/Accessors/parserAccessors3.ts(1,15): error TS2378: A 'get' accessor must return a value. ==== tests/cases/conformance/parser/ecmascript5/Accessors/parserAccessors3.ts (1 errors) ==== var v = { get Foo() { } }; ~~~ -!!! error TS2378: A 'get' accessor must return a value or consist of a single 'throw' statement. \ No newline at end of file +!!! error TS2378: A 'get' accessor must return a value. \ No newline at end of file diff --git a/tests/baselines/reference/parserAccessors7.errors.txt b/tests/baselines/reference/parserAccessors7.errors.txt index 857833a7673..3938280e6d5 100644 --- a/tests/baselines/reference/parserAccessors7.errors.txt +++ b/tests/baselines/reference/parserAccessors7.errors.txt @@ -1,5 +1,5 @@ tests/cases/conformance/parser/ecmascript5/Accessors/parserAccessors7.ts(1,15): error TS1054: A 'get' accessor cannot have parameters. -tests/cases/conformance/parser/ecmascript5/Accessors/parserAccessors7.ts(1,15): error TS2378: A 'get' accessor must return a value or consist of a single 'throw' statement. +tests/cases/conformance/parser/ecmascript5/Accessors/parserAccessors7.ts(1,15): error TS2378: A 'get' accessor must return a value. ==== tests/cases/conformance/parser/ecmascript5/Accessors/parserAccessors7.ts (2 errors) ==== @@ -7,4 +7,4 @@ tests/cases/conformance/parser/ecmascript5/Accessors/parserAccessors7.ts(1,15): ~~~ !!! error TS1054: A 'get' accessor cannot have parameters. ~~~ -!!! error TS2378: A 'get' accessor must return a value or consist of a single 'throw' statement. \ No newline at end of file +!!! error TS2378: A 'get' accessor must return a value. \ No newline at end of file diff --git a/tests/baselines/reference/parserComputedPropertyName4.errors.txt b/tests/baselines/reference/parserComputedPropertyName4.errors.txt index bfc78b162fd..3430e75b82f 100644 --- a/tests/baselines/reference/parserComputedPropertyName4.errors.txt +++ b/tests/baselines/reference/parserComputedPropertyName4.errors.txt @@ -1,10 +1,10 @@ -tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName4.ts(1,15): error TS2378: A 'get' accessor must return a value or consist of a single 'throw' statement. +tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName4.ts(1,15): error TS2378: A 'get' accessor must return a value. tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName4.ts(1,16): error TS2304: Cannot find name 'e'. ==== tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName4.ts (2 errors) ==== var v = { get [e]() { } }; ~~~ -!!! error TS2378: A 'get' accessor must return a value or consist of a single 'throw' statement. +!!! error TS2378: A 'get' accessor must return a value. ~ !!! error TS2304: Cannot find name 'e'. \ No newline at end of file diff --git a/tests/baselines/reference/parserComputedPropertyName5.errors.txt b/tests/baselines/reference/parserComputedPropertyName5.errors.txt index 07cc6f3a9f0..09c38ecbef5 100644 --- a/tests/baselines/reference/parserComputedPropertyName5.errors.txt +++ b/tests/baselines/reference/parserComputedPropertyName5.errors.txt @@ -1,10 +1,10 @@ -tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName5.ts(1,22): error TS2378: A 'get' accessor must return a value or consist of a single 'throw' statement. +tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName5.ts(1,22): error TS2378: A 'get' accessor must return a value. tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName5.ts(1,23): error TS2304: Cannot find name 'e'. ==== tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName5.ts (2 errors) ==== var v = { public get [e]() { } }; ~~~ -!!! error TS2378: A 'get' accessor must return a value or consist of a single 'throw' statement. +!!! error TS2378: A 'get' accessor must return a value. ~ !!! error TS2304: Cannot find name 'e'. \ No newline at end of file diff --git a/tests/baselines/reference/parserES3Accessors1.errors.txt b/tests/baselines/reference/parserES3Accessors1.errors.txt index 5e2ca9f97bc..9c6dbf0e76f 100644 --- a/tests/baselines/reference/parserES3Accessors1.errors.txt +++ b/tests/baselines/reference/parserES3Accessors1.errors.txt @@ -1,5 +1,5 @@ tests/cases/conformance/parser/ecmascript3/Accessors/parserES3Accessors1.ts(2,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/conformance/parser/ecmascript3/Accessors/parserES3Accessors1.ts(2,9): error TS2378: A 'get' accessor must return a value or consist of a single 'throw' statement. +tests/cases/conformance/parser/ecmascript3/Accessors/parserES3Accessors1.ts(2,9): error TS2378: A 'get' accessor must return a value. ==== tests/cases/conformance/parser/ecmascript3/Accessors/parserES3Accessors1.ts (2 errors) ==== @@ -8,5 +8,5 @@ tests/cases/conformance/parser/ecmascript3/Accessors/parserES3Accessors1.ts(2,9) ~~~ !!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. ~~~ -!!! error TS2378: A 'get' accessor must return a value or consist of a single 'throw' statement. +!!! error TS2378: A 'get' accessor must return a value. } \ No newline at end of file diff --git a/tests/baselines/reference/parserES3Accessors3.errors.txt b/tests/baselines/reference/parserES3Accessors3.errors.txt index 6d262e2a855..70ab3f2072e 100644 --- a/tests/baselines/reference/parserES3Accessors3.errors.txt +++ b/tests/baselines/reference/parserES3Accessors3.errors.txt @@ -1,5 +1,5 @@ tests/cases/conformance/parser/ecmascript3/Accessors/parserES3Accessors3.ts(1,15): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/conformance/parser/ecmascript3/Accessors/parserES3Accessors3.ts(1,15): error TS2378: A 'get' accessor must return a value or consist of a single 'throw' statement. +tests/cases/conformance/parser/ecmascript3/Accessors/parserES3Accessors3.ts(1,15): error TS2378: A 'get' accessor must return a value. ==== tests/cases/conformance/parser/ecmascript3/Accessors/parserES3Accessors3.ts (2 errors) ==== @@ -7,4 +7,4 @@ tests/cases/conformance/parser/ecmascript3/Accessors/parserES3Accessors3.ts(1,15 ~~~ !!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. ~~~ -!!! error TS2378: A 'get' accessor must return a value or consist of a single 'throw' statement. \ No newline at end of file +!!! error TS2378: A 'get' accessor must return a value. \ No newline at end of file diff --git a/tests/baselines/reference/parserES5ComputedPropertyName4.errors.txt b/tests/baselines/reference/parserES5ComputedPropertyName4.errors.txt index cfb12152c94..854bb364842 100644 --- a/tests/baselines/reference/parserES5ComputedPropertyName4.errors.txt +++ b/tests/baselines/reference/parserES5ComputedPropertyName4.errors.txt @@ -1,10 +1,10 @@ -tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName4.ts(1,15): error TS2378: A 'get' accessor must return a value or consist of a single 'throw' statement. +tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName4.ts(1,15): error TS2378: A 'get' accessor must return a value. tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName4.ts(1,16): error TS2304: Cannot find name 'e'. ==== tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName4.ts (2 errors) ==== var v = { get [e]() { } }; ~~~ -!!! error TS2378: A 'get' accessor must return a value or consist of a single 'throw' statement. +!!! error TS2378: A 'get' accessor must return a value. ~ !!! error TS2304: Cannot find name 'e'. \ No newline at end of file diff --git a/tests/baselines/reference/parserErrorRecovery_Block3.errors.txt b/tests/baselines/reference/parserErrorRecovery_Block3.errors.txt index 9d391e39007..e6033d05215 100644 --- a/tests/baselines/reference/parserErrorRecovery_Block3.errors.txt +++ b/tests/baselines/reference/parserErrorRecovery_Block3.errors.txt @@ -1,18 +1,18 @@ -tests/cases/conformance/parser/ecmascript5/ErrorRecovery/Blocks/parserErrorRecovery_Block3.ts(2,18): error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value or consist of a single 'throw' statement. +tests/cases/conformance/parser/ecmascript5/ErrorRecovery/Blocks/parserErrorRecovery_Block3.ts(2,18): error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. tests/cases/conformance/parser/ecmascript5/ErrorRecovery/Blocks/parserErrorRecovery_Block3.ts(4,5): error TS1128: Declaration or statement expected. -tests/cases/conformance/parser/ecmascript5/ErrorRecovery/Blocks/parserErrorRecovery_Block3.ts(4,18): error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value or consist of a single 'throw' statement. +tests/cases/conformance/parser/ecmascript5/ErrorRecovery/Blocks/parserErrorRecovery_Block3.ts(4,18): error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. ==== tests/cases/conformance/parser/ecmascript5/ErrorRecovery/Blocks/parserErrorRecovery_Block3.ts (3 errors) ==== class C { private a(): boolean { ~~~~~~~ -!!! error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value or consist of a single 'throw' statement. +!!! error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. private b(): boolean { ~~~~~~~ !!! error TS1128: Declaration or statement expected. ~~~~~~~ -!!! error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value or consist of a single 'throw' statement. +!!! error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. } } \ No newline at end of file diff --git a/tests/baselines/reference/parserGetAccessorWithTypeParameters1.errors.txt b/tests/baselines/reference/parserGetAccessorWithTypeParameters1.errors.txt index 0cf731cb516..09502f6b888 100644 --- a/tests/baselines/reference/parserGetAccessorWithTypeParameters1.errors.txt +++ b/tests/baselines/reference/parserGetAccessorWithTypeParameters1.errors.txt @@ -1,5 +1,5 @@ tests/cases/conformance/parser/ecmascript5/Accessors/parserGetAccessorWithTypeParameters1.ts(2,7): error TS1094: An accessor cannot have type parameters. -tests/cases/conformance/parser/ecmascript5/Accessors/parserGetAccessorWithTypeParameters1.ts(2,7): error TS2378: A 'get' accessor must return a value or consist of a single 'throw' statement. +tests/cases/conformance/parser/ecmascript5/Accessors/parserGetAccessorWithTypeParameters1.ts(2,7): error TS2378: A 'get' accessor must return a value. ==== tests/cases/conformance/parser/ecmascript5/Accessors/parserGetAccessorWithTypeParameters1.ts (2 errors) ==== @@ -8,5 +8,5 @@ tests/cases/conformance/parser/ecmascript5/Accessors/parserGetAccessorWithTypePa ~~~ !!! error TS1094: An accessor cannot have type parameters. ~~~ -!!! error TS2378: A 'get' accessor must return a value or consist of a single 'throw' statement. +!!! error TS2378: A 'get' accessor must return a value. } \ No newline at end of file diff --git a/tests/baselines/reference/parserMemberAccessor1.errors.txt b/tests/baselines/reference/parserMemberAccessor1.errors.txt index aa7cdcdafa3..2a3fd7d7028 100644 --- a/tests/baselines/reference/parserMemberAccessor1.errors.txt +++ b/tests/baselines/reference/parserMemberAccessor1.errors.txt @@ -1,10 +1,10 @@ -tests/cases/conformance/parser/ecmascript5/MemberAccessorDeclarations/parserMemberAccessor1.ts(2,7): error TS2378: A 'get' accessor must return a value or consist of a single 'throw' statement. +tests/cases/conformance/parser/ecmascript5/MemberAccessorDeclarations/parserMemberAccessor1.ts(2,7): error TS2378: A 'get' accessor must return a value. ==== tests/cases/conformance/parser/ecmascript5/MemberAccessorDeclarations/parserMemberAccessor1.ts (1 errors) ==== class C { get foo() { } ~~~ -!!! error TS2378: A 'get' accessor must return a value or consist of a single 'throw' statement. +!!! error TS2378: A 'get' accessor must return a value. set foo(a) { } } \ No newline at end of file diff --git a/tests/baselines/reference/parserMemberAccessorDeclaration1.errors.txt b/tests/baselines/reference/parserMemberAccessorDeclaration1.errors.txt index ac96e7d94b7..c2db31a5398 100644 --- a/tests/baselines/reference/parserMemberAccessorDeclaration1.errors.txt +++ b/tests/baselines/reference/parserMemberAccessorDeclaration1.errors.txt @@ -1,9 +1,9 @@ -tests/cases/conformance/parser/ecmascript5/MemberAccessorDeclarations/parserMemberAccessorDeclaration1.ts(2,7): error TS2378: A 'get' accessor must return a value or consist of a single 'throw' statement. +tests/cases/conformance/parser/ecmascript5/MemberAccessorDeclarations/parserMemberAccessorDeclaration1.ts(2,7): error TS2378: A 'get' accessor must return a value. ==== tests/cases/conformance/parser/ecmascript5/MemberAccessorDeclarations/parserMemberAccessorDeclaration1.ts (1 errors) ==== class C { get a() { } ~ -!!! error TS2378: A 'get' accessor must return a value or consist of a single 'throw' statement. +!!! error TS2378: A 'get' accessor must return a value. } \ No newline at end of file diff --git a/tests/baselines/reference/parserMemberAccessorDeclaration10.errors.txt b/tests/baselines/reference/parserMemberAccessorDeclaration10.errors.txt index 9a04674d6d7..ece110db165 100644 --- a/tests/baselines/reference/parserMemberAccessorDeclaration10.errors.txt +++ b/tests/baselines/reference/parserMemberAccessorDeclaration10.errors.txt @@ -1,5 +1,5 @@ tests/cases/conformance/parser/ecmascript5/MemberAccessorDeclarations/parserMemberAccessorDeclaration10.ts(2,5): error TS1031: 'export' modifier cannot appear on a class element. -tests/cases/conformance/parser/ecmascript5/MemberAccessorDeclarations/parserMemberAccessorDeclaration10.ts(2,16): error TS2378: A 'get' accessor must return a value or consist of a single 'throw' statement. +tests/cases/conformance/parser/ecmascript5/MemberAccessorDeclarations/parserMemberAccessorDeclaration10.ts(2,16): error TS2378: A 'get' accessor must return a value. ==== tests/cases/conformance/parser/ecmascript5/MemberAccessorDeclarations/parserMemberAccessorDeclaration10.ts (2 errors) ==== @@ -8,5 +8,5 @@ tests/cases/conformance/parser/ecmascript5/MemberAccessorDeclarations/parserMemb ~~~~~~ !!! error TS1031: 'export' modifier cannot appear on a class element. ~~~ -!!! error TS2378: A 'get' accessor must return a value or consist of a single 'throw' statement. +!!! error TS2378: A 'get' accessor must return a value. } \ No newline at end of file diff --git a/tests/baselines/reference/parserMemberAccessorDeclaration12.errors.txt b/tests/baselines/reference/parserMemberAccessorDeclaration12.errors.txt index 0d14a2adab8..a4ea29518d1 100644 --- a/tests/baselines/reference/parserMemberAccessorDeclaration12.errors.txt +++ b/tests/baselines/reference/parserMemberAccessorDeclaration12.errors.txt @@ -1,5 +1,5 @@ tests/cases/conformance/parser/ecmascript5/MemberAccessorDeclarations/parserMemberAccessorDeclaration12.ts(2,8): error TS1054: A 'get' accessor cannot have parameters. -tests/cases/conformance/parser/ecmascript5/MemberAccessorDeclarations/parserMemberAccessorDeclaration12.ts(2,8): error TS2378: A 'get' accessor must return a value or consist of a single 'throw' statement. +tests/cases/conformance/parser/ecmascript5/MemberAccessorDeclarations/parserMemberAccessorDeclaration12.ts(2,8): error TS2378: A 'get' accessor must return a value. ==== tests/cases/conformance/parser/ecmascript5/MemberAccessorDeclarations/parserMemberAccessorDeclaration12.ts (2 errors) ==== @@ -8,5 +8,5 @@ tests/cases/conformance/parser/ecmascript5/MemberAccessorDeclarations/parserMemb ~~~ !!! error TS1054: A 'get' accessor cannot have parameters. ~~~ -!!! error TS2378: A 'get' accessor must return a value or consist of a single 'throw' statement. +!!! error TS2378: A 'get' accessor must return a value. } \ No newline at end of file diff --git a/tests/baselines/reference/parserMemberAccessorDeclaration2.errors.txt b/tests/baselines/reference/parserMemberAccessorDeclaration2.errors.txt index 69e87dff659..7b66bee844f 100644 --- a/tests/baselines/reference/parserMemberAccessorDeclaration2.errors.txt +++ b/tests/baselines/reference/parserMemberAccessorDeclaration2.errors.txt @@ -1,9 +1,9 @@ -tests/cases/conformance/parser/ecmascript5/MemberAccessorDeclarations/parserMemberAccessorDeclaration2.ts(2,7): error TS2378: A 'get' accessor must return a value or consist of a single 'throw' statement. +tests/cases/conformance/parser/ecmascript5/MemberAccessorDeclarations/parserMemberAccessorDeclaration2.ts(2,7): error TS2378: A 'get' accessor must return a value. ==== tests/cases/conformance/parser/ecmascript5/MemberAccessorDeclarations/parserMemberAccessorDeclaration2.ts (1 errors) ==== class C { get "b"() { } ~~~ -!!! error TS2378: A 'get' accessor must return a value or consist of a single 'throw' statement. +!!! error TS2378: A 'get' accessor must return a value. } \ No newline at end of file diff --git a/tests/baselines/reference/parserMemberAccessorDeclaration3.errors.txt b/tests/baselines/reference/parserMemberAccessorDeclaration3.errors.txt index 93a1a5d14e1..a37fe230f76 100644 --- a/tests/baselines/reference/parserMemberAccessorDeclaration3.errors.txt +++ b/tests/baselines/reference/parserMemberAccessorDeclaration3.errors.txt @@ -1,9 +1,9 @@ -tests/cases/conformance/parser/ecmascript5/MemberAccessorDeclarations/parserMemberAccessorDeclaration3.ts(2,7): error TS2378: A 'get' accessor must return a value or consist of a single 'throw' statement. +tests/cases/conformance/parser/ecmascript5/MemberAccessorDeclarations/parserMemberAccessorDeclaration3.ts(2,7): error TS2378: A 'get' accessor must return a value. ==== tests/cases/conformance/parser/ecmascript5/MemberAccessorDeclarations/parserMemberAccessorDeclaration3.ts (1 errors) ==== class C { get 0() { } ~ -!!! error TS2378: A 'get' accessor must return a value or consist of a single 'throw' statement. +!!! error TS2378: A 'get' accessor must return a value. } \ No newline at end of file diff --git a/tests/baselines/reference/parserMemberAccessorDeclaration7.errors.txt b/tests/baselines/reference/parserMemberAccessorDeclaration7.errors.txt index b7f67da49b7..2b0bd40a4f2 100644 --- a/tests/baselines/reference/parserMemberAccessorDeclaration7.errors.txt +++ b/tests/baselines/reference/parserMemberAccessorDeclaration7.errors.txt @@ -1,5 +1,5 @@ tests/cases/conformance/parser/ecmascript5/MemberAccessorDeclarations/parserMemberAccessorDeclaration7.ts(2,12): error TS1028: Accessibility modifier already seen. -tests/cases/conformance/parser/ecmascript5/MemberAccessorDeclarations/parserMemberAccessorDeclaration7.ts(2,23): error TS2378: A 'get' accessor must return a value or consist of a single 'throw' statement. +tests/cases/conformance/parser/ecmascript5/MemberAccessorDeclarations/parserMemberAccessorDeclaration7.ts(2,23): error TS2378: A 'get' accessor must return a value. ==== tests/cases/conformance/parser/ecmascript5/MemberAccessorDeclarations/parserMemberAccessorDeclaration7.ts (2 errors) ==== @@ -8,5 +8,5 @@ tests/cases/conformance/parser/ecmascript5/MemberAccessorDeclarations/parserMemb ~~~~~~ !!! error TS1028: Accessibility modifier already seen. ~~~ -!!! error TS2378: A 'get' accessor must return a value or consist of a single 'throw' statement. +!!! error TS2378: A 'get' accessor must return a value. } \ No newline at end of file diff --git a/tests/baselines/reference/parserMemberAccessorDeclaration8.errors.txt b/tests/baselines/reference/parserMemberAccessorDeclaration8.errors.txt index e5a39c149f6..67ba09b8c72 100644 --- a/tests/baselines/reference/parserMemberAccessorDeclaration8.errors.txt +++ b/tests/baselines/reference/parserMemberAccessorDeclaration8.errors.txt @@ -1,5 +1,5 @@ tests/cases/conformance/parser/ecmascript5/MemberAccessorDeclarations/parserMemberAccessorDeclaration8.ts(2,12): error TS1030: 'static' modifier already seen. -tests/cases/conformance/parser/ecmascript5/MemberAccessorDeclarations/parserMemberAccessorDeclaration8.ts(2,23): error TS2378: A 'get' accessor must return a value or consist of a single 'throw' statement. +tests/cases/conformance/parser/ecmascript5/MemberAccessorDeclarations/parserMemberAccessorDeclaration8.ts(2,23): error TS2378: A 'get' accessor must return a value. ==== tests/cases/conformance/parser/ecmascript5/MemberAccessorDeclarations/parserMemberAccessorDeclaration8.ts (2 errors) ==== @@ -8,5 +8,5 @@ tests/cases/conformance/parser/ecmascript5/MemberAccessorDeclarations/parserMemb ~~~~~~ !!! error TS1030: 'static' modifier already seen. ~~~ -!!! error TS2378: A 'get' accessor must return a value or consist of a single 'throw' statement. +!!! error TS2378: A 'get' accessor must return a value. } \ No newline at end of file diff --git a/tests/baselines/reference/parserMemberAccessorDeclaration9.errors.txt b/tests/baselines/reference/parserMemberAccessorDeclaration9.errors.txt index 2da32a5807b..31d001aeafc 100644 --- a/tests/baselines/reference/parserMemberAccessorDeclaration9.errors.txt +++ b/tests/baselines/reference/parserMemberAccessorDeclaration9.errors.txt @@ -1,5 +1,5 @@ tests/cases/conformance/parser/ecmascript5/MemberAccessorDeclarations/parserMemberAccessorDeclaration9.ts(2,12): error TS1029: 'public' modifier must precede 'static' modifier. -tests/cases/conformance/parser/ecmascript5/MemberAccessorDeclarations/parserMemberAccessorDeclaration9.ts(2,23): error TS2378: A 'get' accessor must return a value or consist of a single 'throw' statement. +tests/cases/conformance/parser/ecmascript5/MemberAccessorDeclarations/parserMemberAccessorDeclaration9.ts(2,23): error TS2378: A 'get' accessor must return a value. ==== tests/cases/conformance/parser/ecmascript5/MemberAccessorDeclarations/parserMemberAccessorDeclaration9.ts (2 errors) ==== @@ -8,5 +8,5 @@ tests/cases/conformance/parser/ecmascript5/MemberAccessorDeclarations/parserMemb ~~~~~~ !!! error TS1029: 'public' modifier must precede 'static' modifier. ~~~ -!!! error TS2378: A 'get' accessor must return a value or consist of a single 'throw' statement. +!!! error TS2378: A 'get' accessor must return a value. } \ No newline at end of file diff --git a/tests/baselines/reference/parserParameterList5.errors.txt b/tests/baselines/reference/parserParameterList5.errors.txt index 231a5bbb162..5f0899fa1a2 100644 --- a/tests/baselines/reference/parserParameterList5.errors.txt +++ b/tests/baselines/reference/parserParameterList5.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/parser/ecmascript5/ParameterLists/parserParameterList5.ts(1,15): error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value or consist of a single 'throw' statement. +tests/cases/conformance/parser/ecmascript5/ParameterLists/parserParameterList5.ts(1,15): error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. tests/cases/conformance/parser/ecmascript5/ParameterLists/parserParameterList5.ts(1,16): error TS2369: A parameter property is only allowed in a constructor implementation. tests/cases/conformance/parser/ecmascript5/ParameterLists/parserParameterList5.ts(1,29): error TS2304: Cannot find name 'C'. @@ -6,7 +6,7 @@ tests/cases/conformance/parser/ecmascript5/ParameterLists/parserParameterList5.t ==== tests/cases/conformance/parser/ecmascript5/ParameterLists/parserParameterList5.ts (3 errors) ==== function A(): (public B) => C { ~~~~~~~~~~~~~~~ -!!! error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value or consist of a single 'throw' statement. +!!! error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. ~~~~~~~~ !!! error TS2369: A parameter property is only allowed in a constructor implementation. ~ diff --git a/tests/baselines/reference/reachabilityChecks1.errors.txt b/tests/baselines/reference/reachabilityChecks1.errors.txt new file mode 100644 index 00000000000..ebf1019e7e9 --- /dev/null +++ b/tests/baselines/reference/reachabilityChecks1.errors.txt @@ -0,0 +1,70 @@ +tests/cases/compiler/reachabilityChecks1.ts(3,1): error TS7027: Unreachable code detected. +tests/cases/compiler/reachabilityChecks1.ts(7,5): error TS7027: Unreachable code detected. +tests/cases/compiler/reachabilityChecks1.ts(22,11): error TS7027: Unreachable code detected. +tests/cases/compiler/reachabilityChecks1.ts(28,12): error TS7027: Unreachable code detected. +tests/cases/compiler/reachabilityChecks1.ts(35,10): error TS7027: Unreachable code detected. +tests/cases/compiler/reachabilityChecks1.ts(44,16): error TS7027: Unreachable code detected. + + +==== tests/cases/compiler/reachabilityChecks1.ts (6 errors) ==== + + while (true); + var x = 1; + ~~~~~~~~~~ +!!! error TS7027: Unreachable code detected. + + module A { + while (true); + let x; + ~~~~~~ +!!! error TS7027: Unreachable code detected. + } + + function f1(x) { + if (x) { + return; + } + else { + throw new Error("123"); + } + var x; + } + + function f2() { + return; + class A { + ~ +!!! error TS7027: Unreachable code detected. + } + } + + module B { + for (; ;); + module C { + ~ +!!! error TS7027: Unreachable code detected. + } + } + + function f3() { + do { + } while (true); + enum E { + ~ +!!! error TS7027: Unreachable code detected. + X = 1 + } + } + + function f4() { + if (true) { + throw new Error(); + } + const enum E { + ~ +!!! error TS7027: Unreachable code detected. + X = 1 + } + } + + \ No newline at end of file diff --git a/tests/baselines/reference/reachabilityChecks1.js b/tests/baselines/reference/reachabilityChecks1.js new file mode 100644 index 00000000000..3f9ca87422a --- /dev/null +++ b/tests/baselines/reference/reachabilityChecks1.js @@ -0,0 +1,100 @@ +//// [reachabilityChecks1.ts] + +while (true); +var x = 1; + +module A { + while (true); + let x; +} + +function f1(x) { + if (x) { + return; + } + else { + throw new Error("123"); + } + var x; +} + +function f2() { + return; + class A { + } +} + +module B { + for (; ;); + module C { + } +} + +function f3() { + do { + } while (true); + enum E { + X = 1 + } +} + +function f4() { + if (true) { + throw new Error(); + } + const enum E { + X = 1 + } +} + + + +//// [reachabilityChecks1.js] +while (true) + ; +var x = 1; +var A; +(function (A) { + while (true) + ; + var x; +})(A || (A = {})); +function f1(x) { + if (x) { + return; + } + else { + throw new Error("123"); + } + var x; +} +function f2() { + return; + var A = (function () { + function A() { + } + return A; + })(); +} +var B; +(function (B) { + for (;;) + ; +})(B || (B = {})); +function f3() { + do { + } while (true); + var E; + (function (E) { + E[E["X"] = 1] = "X"; + })(E || (E = {})); +} +function f4() { + if (true) { + throw new Error(); + } + var E; + (function (E) { + E[E["X"] = 1] = "X"; + })(E || (E = {})); +} diff --git a/tests/baselines/reference/reachabilityChecks2.js b/tests/baselines/reference/reachabilityChecks2.js new file mode 100644 index 00000000000..80534c0d7de --- /dev/null +++ b/tests/baselines/reference/reachabilityChecks2.js @@ -0,0 +1,9 @@ +//// [reachabilityChecks2.ts] + +while (true) { } +const enum E { X } + + + +//// [reachabilityChecks2.js] +while (true) { } diff --git a/tests/baselines/reference/reachabilityChecks2.symbols b/tests/baselines/reference/reachabilityChecks2.symbols new file mode 100644 index 00000000000..d289304dffa --- /dev/null +++ b/tests/baselines/reference/reachabilityChecks2.symbols @@ -0,0 +1,8 @@ +=== tests/cases/compiler/reachabilityChecks2.ts === + +while (true) { } +const enum E { X } +>E : Symbol(E, Decl(reachabilityChecks2.ts, 1, 16)) +>X : Symbol(E.X, Decl(reachabilityChecks2.ts, 2, 14)) + + diff --git a/tests/baselines/reference/reachabilityChecks2.types b/tests/baselines/reference/reachabilityChecks2.types new file mode 100644 index 00000000000..38dad87c6a1 --- /dev/null +++ b/tests/baselines/reference/reachabilityChecks2.types @@ -0,0 +1,10 @@ +=== tests/cases/compiler/reachabilityChecks2.ts === + +while (true) { } +>true : boolean + +const enum E { X } +>E : E +>X : E + + diff --git a/tests/baselines/reference/reachabilityChecks3.errors.txt b/tests/baselines/reference/reachabilityChecks3.errors.txt new file mode 100644 index 00000000000..993ab571b2e --- /dev/null +++ b/tests/baselines/reference/reachabilityChecks3.errors.txt @@ -0,0 +1,16 @@ +tests/cases/compiler/reachabilityChecks3.ts(3,1): error TS7028: Unused label. + + +==== tests/cases/compiler/reachabilityChecks3.ts (1 errors) ==== + + let x = 1; + loop: while (true) { + ~~~~ +!!! error TS7028: Unused label. + if (x == 100) { + break; + } + else { + x++; + } + } \ No newline at end of file diff --git a/tests/baselines/reference/reachabilityChecks3.js b/tests/baselines/reference/reachabilityChecks3.js new file mode 100644 index 00000000000..4de316d1ddc --- /dev/null +++ b/tests/baselines/reference/reachabilityChecks3.js @@ -0,0 +1,22 @@ +//// [reachabilityChecks3.ts] + +let x = 1; +loop: while (true) { + if (x == 100) { + break; + } + else { + x++; + } +} + +//// [reachabilityChecks3.js] +var x = 1; +loop: while (true) { + if (x == 100) { + break; + } + else { + x++; + } +} diff --git a/tests/baselines/reference/reachabilityChecks4.errors.txt b/tests/baselines/reference/reachabilityChecks4.errors.txt new file mode 100644 index 00000000000..ba9519462e7 --- /dev/null +++ b/tests/baselines/reference/reachabilityChecks4.errors.txt @@ -0,0 +1,20 @@ +tests/cases/compiler/reachabilityChecks4.ts(7,9): error TS7029: Fallthrough case in switch. + + +==== tests/cases/compiler/reachabilityChecks4.ts (1 errors) ==== + + function foo(x, y) { + switch (x) { + case 1: + case 2: + return 1; + case 3: + ~~~~ +!!! error TS7029: Fallthrough case in switch. + if (y) { + return 2; + } + case 4: + return 3; + } + } \ No newline at end of file diff --git a/tests/baselines/reference/reachabilityChecks4.js b/tests/baselines/reference/reachabilityChecks4.js new file mode 100644 index 00000000000..588644c5a05 --- /dev/null +++ b/tests/baselines/reference/reachabilityChecks4.js @@ -0,0 +1,30 @@ +//// [reachabilityChecks4.ts] + +function foo(x, y) { + switch (x) { + case 1: + case 2: + return 1; + case 3: + if (y) { + return 2; + } + case 4: + return 3; + } +} + +//// [reachabilityChecks4.js] +function foo(x, y) { + switch (x) { + case 1: + case 2: + return 1; + case 3: + if (y) { + return 2; + } + case 4: + return 3; + } +} diff --git a/tests/baselines/reference/reachabilityChecks5.errors.txt b/tests/baselines/reference/reachabilityChecks5.errors.txt new file mode 100644 index 00000000000..c30dfa71817 --- /dev/null +++ b/tests/baselines/reference/reachabilityChecks5.errors.txt @@ -0,0 +1,162 @@ +tests/cases/compiler/reachabilityChecks5.ts(6,17): error TS7030: Not all code paths return a value. +tests/cases/compiler/reachabilityChecks5.ts(19,17): error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. +tests/cases/compiler/reachabilityChecks5.ts(31,17): error TS7030: Not all code paths return a value. +tests/cases/compiler/reachabilityChecks5.ts(41,17): error TS7030: Not all code paths return a value. +tests/cases/compiler/reachabilityChecks5.ts(52,17): error TS7030: Not all code paths return a value. +tests/cases/compiler/reachabilityChecks5.ts(80,17): error TS7030: Not all code paths return a value. +tests/cases/compiler/reachabilityChecks5.ts(86,13): error TS7027: Unreachable code detected. +tests/cases/compiler/reachabilityChecks5.ts(94,17): error TS7030: Not all code paths return a value. +tests/cases/compiler/reachabilityChecks5.ts(116,18): error TS7030: Not all code paths return a value. +tests/cases/compiler/reachabilityChecks5.ts(123,13): error TS7027: Unreachable code detected. + + +==== tests/cases/compiler/reachabilityChecks5.ts (10 errors) ==== + + function f0(x): number { + while (true); + } + + function f1(x): number { + ~~~~~~ +!!! error TS7030: Not all code paths return a value. + if (x) { + return 1 + } + } + + function f2(x): number { + while (x) { + throw new Error(); + } + return 1; + } + + function f3(x): number { + ~~~~~~ +!!! error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. + while (x) { + throw new Error(); + } + } + + function f3_1 (x): number { + while (x) { + } + throw new Error(); + } + + function f4(x): number { + ~~~~~~ +!!! error TS7030: Not all code paths return a value. + try { + if (x) { + return 1; + } + } + catch (e) { + } + } + + function f5(x): number { + ~~~~~~ +!!! error TS7030: Not all code paths return a value. + try { + if (x) { + return 1; + } + } + catch (e) { + return 2; + } + } + + function f6(x): number { + ~~~~~~ +!!! error TS7030: Not all code paths return a value. + try { + if (x) { + return 1; + } + else + { + throw new Error(); + } + } + catch (e) { + } + } + + function f7(x): number { + try { + if (x) { + return 1; + } + else { + throw new Error(); + } + } + catch (e) { + return 1; + } + } + + function f8(x): number { + ~~~~~~ +!!! error TS7030: Not all code paths return a value. + try { + if (true) { + x++; + } + else { + return 1; + ~~~~~~~~~ +!!! error TS7027: Unreachable code detected. + } + } + catch (e) { + return 1; + } + } + + function f9(x): number { + ~~~~~~ +!!! error TS7030: Not all code paths return a value. + try { + while (false) { + return 1; + } + } + catch (e) { + return 1; + } + } + + function f10(x): number { + try { + do { + x++; + } while (true); + } + catch (e) { + return 1; + } + } + + function f11(x): number { + ~~~~~~ +!!! error TS7030: Not all code paths return a value. + test: + try { + do { + do { + break test; + } while (true); + x++; + ~~~~ +!!! error TS7027: Unreachable code detected. + } while (true); + } + catch (e) { + return 1; + } + } \ No newline at end of file diff --git a/tests/baselines/reference/reachabilityChecks5.js b/tests/baselines/reference/reachabilityChecks5.js new file mode 100644 index 00000000000..a6c507ac87b --- /dev/null +++ b/tests/baselines/reference/reachabilityChecks5.js @@ -0,0 +1,247 @@ +//// [reachabilityChecks5.ts] + +function f0(x): number { + while (true); +} + +function f1(x): number { + if (x) { + return 1 + } +} + +function f2(x): number { + while (x) { + throw new Error(); + } + return 1; +} + +function f3(x): number { + while (x) { + throw new Error(); + } +} + +function f3_1 (x): number { + while (x) { + } + throw new Error(); +} + +function f4(x): number { + try { + if (x) { + return 1; + } + } + catch (e) { + } +} + +function f5(x): number { + try { + if (x) { + return 1; + } + } + catch (e) { + return 2; + } +} + +function f6(x): number { + try { + if (x) { + return 1; + } + else + { + throw new Error(); + } + } + catch (e) { + } +} + +function f7(x): number { + try { + if (x) { + return 1; + } + else { + throw new Error(); + } + } + catch (e) { + return 1; + } +} + +function f8(x): number { + try { + if (true) { + x++; + } + else { + return 1; + } + } + catch (e) { + return 1; + } +} + +function f9(x): number { + try { + while (false) { + return 1; + } + } + catch (e) { + return 1; + } +} + +function f10(x): number { + try { + do { + x++; + } while (true); + } + catch (e) { + return 1; + } +} + +function f11(x): number { + test: + try { + do { + do { + break test; + } while (true); + x++; + } while (true); + } + catch (e) { + return 1; + } +} + +//// [reachabilityChecks5.js] +function f0(x) { + while (true) + ; +} +function f1(x) { + if (x) { + return 1; + } +} +function f2(x) { + while (x) { + throw new Error(); + } + return 1; +} +function f3(x) { + while (x) { + throw new Error(); + } +} +function f3_1(x) { + while (x) { + } + throw new Error(); +} +function f4(x) { + try { + if (x) { + return 1; + } + } + catch (e) { + } +} +function f5(x) { + try { + if (x) { + return 1; + } + } + catch (e) { + return 2; + } +} +function f6(x) { + try { + if (x) { + return 1; + } + else { + throw new Error(); + } + } + catch (e) { + } +} +function f7(x) { + try { + if (x) { + return 1; + } + else { + throw new Error(); + } + } + catch (e) { + return 1; + } +} +function f8(x) { + try { + if (true) { + x++; + } + else { + return 1; + } + } + catch (e) { + return 1; + } +} +function f9(x) { + try { + while (false) { + return 1; + } + } + catch (e) { + return 1; + } +} +function f10(x) { + try { + do { + x++; + } while (true); + } + catch (e) { + return 1; + } +} +function f11(x) { + test: try { + do { + do { + break test; + } while (true); + x++; + } while (true); + } + catch (e) { + return 1; + } +} diff --git a/tests/baselines/reference/recursiveFunctionTypes.errors.txt b/tests/baselines/reference/recursiveFunctionTypes.errors.txt index c69549403c4..8d5303c0669 100644 --- a/tests/baselines/reference/recursiveFunctionTypes.errors.txt +++ b/tests/baselines/reference/recursiveFunctionTypes.errors.txt @@ -2,8 +2,8 @@ tests/cases/compiler/recursiveFunctionTypes.ts(1,35): error TS2322: Type 'number tests/cases/compiler/recursiveFunctionTypes.ts(3,5): error TS2322: Type '() => typeof fn' is not assignable to type 'number'. tests/cases/compiler/recursiveFunctionTypes.ts(4,5): error TS2322: Type '() => typeof fn' is not assignable to type '() => number'. Type '() => typeof fn' is not assignable to type 'number'. -tests/cases/compiler/recursiveFunctionTypes.ts(11,16): error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value or consist of a single 'throw' statement. -tests/cases/compiler/recursiveFunctionTypes.ts(12,16): error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value or consist of a single 'throw' statement. +tests/cases/compiler/recursiveFunctionTypes.ts(11,16): error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. +tests/cases/compiler/recursiveFunctionTypes.ts(12,16): error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. tests/cases/compiler/recursiveFunctionTypes.ts(17,5): error TS2322: Type '() => I' is not assignable to type 'number'. tests/cases/compiler/recursiveFunctionTypes.ts(22,5): error TS2345: Argument of type 'number' is not assignable to parameter of type '(t: typeof g) => void'. tests/cases/compiler/recursiveFunctionTypes.ts(25,1): error TS2322: Type 'number' is not assignable to type '() => any'. @@ -34,10 +34,10 @@ tests/cases/compiler/recursiveFunctionTypes.ts(43,4): error TS2345: Argument of function f2(): typeof g2 { } ~~~~~~~~~ -!!! error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value or consist of a single 'throw' statement. +!!! error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. function g2(): typeof f2 { } ~~~~~~~~~ -!!! error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value or consist of a single 'throw' statement. +!!! error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. interface I { } function f3(): I { return f3; } diff --git a/tests/baselines/reference/returnTypeParameter.errors.txt b/tests/baselines/reference/returnTypeParameter.errors.txt index 11c0888f47c..1bd9f6a63f6 100644 --- a/tests/baselines/reference/returnTypeParameter.errors.txt +++ b/tests/baselines/reference/returnTypeParameter.errors.txt @@ -1,11 +1,11 @@ -tests/cases/compiler/returnTypeParameter.ts(1,22): error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value or consist of a single 'throw' statement. +tests/cases/compiler/returnTypeParameter.ts(1,22): error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. tests/cases/compiler/returnTypeParameter.ts(2,34): error TS2304: Cannot find name 'T'. ==== tests/cases/compiler/returnTypeParameter.ts (2 errors) ==== function f(a: T): T { } // error, no return statement ~ -!!! error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value or consist of a single 'throw' statement. +!!! error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. function f2(a: T): T { return T; } // bug was that this satisfied the return statement requirement ~ !!! error TS2304: Cannot find name 'T'. \ No newline at end of file diff --git a/tests/cases/compiler/reachabilityChecks1.ts b/tests/cases/compiler/reachabilityChecks1.ts new file mode 100644 index 00000000000..bc7662486a6 --- /dev/null +++ b/tests/cases/compiler/reachabilityChecks1.ts @@ -0,0 +1,50 @@ +// @noUnreachableCode: true +// @preserveConstEnums: true + +while (true); +var x = 1; + +module A { + while (true); + let x; +} + +function f1(x) { + if (x) { + return; + } + else { + throw new Error("123"); + } + var x; +} + +function f2() { + return; + class A { + } +} + +module B { + for (; ;); + module C { + } +} + +function f3() { + do { + } while (true); + enum E { + X = 1 + } +} + +function f4() { + if (true) { + throw new Error(); + } + const enum E { + X = 1 + } +} + diff --git a/tests/cases/compiler/reachabilityChecks2.ts b/tests/cases/compiler/reachabilityChecks2.ts new file mode 100644 index 00000000000..fc8d53bde8f --- /dev/null +++ b/tests/cases/compiler/reachabilityChecks2.ts @@ -0,0 +1,6 @@ +// @noUnreachableCode: true +// @preserveConstEnums: false + +while (true) { } +const enum E { X } + diff --git a/tests/cases/compiler/reachabilityChecks3.ts b/tests/cases/compiler/reachabilityChecks3.ts new file mode 100644 index 00000000000..362c64e1349 --- /dev/null +++ b/tests/cases/compiler/reachabilityChecks3.ts @@ -0,0 +1,11 @@ +// @noUnusedLabels: true + +let x = 1; +loop: while (true) { + if (x == 100) { + break; + } + else { + x++; + } +} \ No newline at end of file diff --git a/tests/cases/compiler/reachabilityChecks4.ts b/tests/cases/compiler/reachabilityChecks4.ts new file mode 100644 index 00000000000..f07395ac38e --- /dev/null +++ b/tests/cases/compiler/reachabilityChecks4.ts @@ -0,0 +1,15 @@ +// @noFallthroughCasesInSwitch: true + +function foo(x, y) { + switch (x) { + case 1: + case 2: + return 1; + case 3: + if (y) { + return 2; + } + case 4: + return 3; + } +} \ No newline at end of file diff --git a/tests/cases/compiler/reachabilityChecks5.ts b/tests/cases/compiler/reachabilityChecks5.ts new file mode 100644 index 00000000000..24134e238b9 --- /dev/null +++ b/tests/cases/compiler/reachabilityChecks5.ts @@ -0,0 +1,131 @@ +// @noUnreachableCode: true +// @noImplicitReturns: true + +function f0(x): number { + while (true); +} + +function f1(x): number { + if (x) { + return 1 + } +} + +function f2(x): number { + while (x) { + throw new Error(); + } + return 1; +} + +function f3(x): number { + while (x) { + throw new Error(); + } +} + +function f3_1 (x): number { + while (x) { + } + throw new Error(); +} + +function f4(x): number { + try { + if (x) { + return 1; + } + } + catch (e) { + } +} + +function f5(x): number { + try { + if (x) { + return 1; + } + } + catch (e) { + return 2; + } +} + +function f6(x): number { + try { + if (x) { + return 1; + } + else + { + throw new Error(); + } + } + catch (e) { + } +} + +function f7(x): number { + try { + if (x) { + return 1; + } + else { + throw new Error(); + } + } + catch (e) { + return 1; + } +} + +function f8(x): number { + try { + if (true) { + x++; + } + else { + return 1; + } + } + catch (e) { + return 1; + } +} + +function f9(x): number { + try { + while (false) { + return 1; + } + } + catch (e) { + return 1; + } +} + +function f10(x): number { + try { + do { + x++; + } while (true); + } + catch (e) { + return 1; + } +} + +function f11(x): number { + test: + try { + do { + do { + break test; + } while (true); + x++; + } while (true); + } + catch (e) { + return 1; + } +} \ No newline at end of file From beb1aa3d0a01291388d8565d1a60f2be281be513 Mon Sep 17 00:00:00 2001 From: Vladimir Matveev Date: Tue, 15 Sep 2015 10:36:55 -0700 Subject: [PATCH 013/227] addressed PR feedback --- src/compiler/binder.ts | 55 +++++++++++------- .../reference/reachabilityChecks1.errors.txt | 43 +++++++++++--- .../reference/reachabilityChecks1.js | 56 +++++++++++++++++++ .../reference/reachabilityChecks2.errors.txt | 18 ++++++ .../reference/reachabilityChecks2.js | 12 ++++ .../reference/reachabilityChecks2.symbols | 8 --- .../reference/reachabilityChecks2.types | 10 ---- tests/cases/compiler/reachabilityChecks1.ts | 26 +++++++++ tests/cases/compiler/reachabilityChecks2.ts | 7 +++ 9 files changed, 191 insertions(+), 44 deletions(-) create mode 100644 tests/baselines/reference/reachabilityChecks2.errors.txt delete mode 100644 tests/baselines/reference/reachabilityChecks2.symbols delete mode 100644 tests/baselines/reference/reachabilityChecks2.types diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index c29c761c28a..cebc930d328 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -108,7 +108,7 @@ namespace ts { let hasExplicitReturn: boolean; let currentReachabilityState: Reachability; let labelStack: Reachability[]; - let labels: Map; + let labelIndexMap: Map; let implicitLabels: number[]; // If this file is an external module, then it is automatically in strict-mode according to @@ -373,13 +373,13 @@ namespace ts { if (saveState) { savedReachabilityState = currentReachabilityState; savedLabelStack = labelStack; - savedLabels = labels; + savedLabels = labelIndexMap; savedImplicitLabels = implicitLabels; savedHasExplicitReturn = hasExplicitReturn; currentReachabilityState = Reachability.Reachable; hasExplicitReturn = false; - labelStack = labels = implicitLabels = undefined; + labelStack = labelIndexMap = implicitLabels = undefined; } if (!bindReachableStatement(node)) { @@ -397,17 +397,21 @@ namespace ts { hasExplicitReturn = savedHasExplicitReturn; currentReachabilityState = savedReachabilityState; labelStack = savedLabelStack; - labels = savedLabels; + labelIndexMap = savedLabels; implicitLabels = savedImplicitLabels; } } + /** + * Returns true if node and its subnodes were successfully traversed. + * Returning false means that node was not examined and caller needs to dive into the node himself. + */ function bindReachableStatement(n: Node): boolean { if (checkUnreachable(n)) { return false; } - switch(n.kind) { + switch (n.kind) { case SyntaxKind.WhileStatement: return bindWhileStatement(n); case SyntaxKind.DoStatement: @@ -460,7 +464,7 @@ namespace ts { const postDoLabel = pushImplicitLabel(); bind(n.statement); - var postDoState = n.expression.kind === SyntaxKind.TrueKeyword ? Reachability.Unreachable : preDoState; + const postDoState = n.expression.kind === SyntaxKind.TrueKeyword ? Reachability.Unreachable : preDoState; popImplicitLabel(postDoLabel, postDoState); // bind expressions (don't affect reachability) @@ -505,7 +509,11 @@ namespace ts { } function bindIfStatement(n: IfStatement): boolean { + // denotes reachability state when entering 'thenStatement' part of the if statement: + // i.e. if condition is false then thenStatement is unreachable const ifTrueState = n.expression.kind === SyntaxKind.FalseKeyword ? Reachability.Unreachable : currentReachabilityState; + // denotes reachability state when entering 'elseStatement': + // i.e. if condition is true then elseStatement is unreachable const ifFalseState = n.expression.kind === SyntaxKind.TrueKeyword ? Reachability.Unreachable : currentReachabilityState; currentReachabilityState = ifTrueState; @@ -585,7 +593,7 @@ namespace ts { const hasDefault = forEach(n.caseBlock.clauses, c => c.kind === SyntaxKind.DefaultClause); // post switch state is unreachable if switch is exaustive (has a default case ) and does not have fallthrough from the last case - var postSwitchState = hasDefault && currentReachabilityState !== Reachability.Reachable ? Reachability.Unreachable : preSwitchState; + const postSwitchState = hasDefault && currentReachabilityState !== Reachability.Reachable ? Reachability.Unreachable : preSwitchState; popImplicitLabel(postSwitchLabel, postSwitchState); @@ -595,7 +603,7 @@ namespace ts { function bindCaseBlock(n: CaseBlock): boolean { const startState = currentReachabilityState; - for(let clause of n.clauses) { + for (let clause of n.clauses) { currentReachabilityState = startState; bind(clause); if (clause.statements.length && currentReachabilityState === Reachability.Reachable && options.noFallthroughCasesInSwitch) { @@ -610,7 +618,7 @@ namespace ts { // call bind on label (don't affect reachability) bind(n.label); - var ok = pushNamedLabel(n.label); + const ok = pushNamedLabel(n.label); bind(n.statement); if (ok) { popNamedLabel(n.label, currentReachabilityState); @@ -1347,10 +1355,10 @@ namespace ts { function pushNamedLabel(name: Identifier): boolean { initializeReachabilityStateIfNecessary(); - if (hasProperty(labels, name.text)) { + if (hasProperty(labelIndexMap, name.text)) { return false; } - labels[name.text] = labelStack.push(Reachability.Unintialized) - 1; + labelIndexMap[name.text] = labelStack.push(Reachability.Unintialized) - 1; return true; } @@ -1365,11 +1373,11 @@ namespace ts { function popNamedLabel(label: Identifier, outerState: Reachability): void { initializeReachabilityStateIfNecessary(); - let index = labels[label.text]; + let index = labelIndexMap[label.text]; Debug.assert(index !== undefined); Debug.assert(labelStack.length == index + 1); - labels[label.text] = undefined; + labelIndexMap[label.text] = undefined; setCurrentStateAtLabel(labelStack.pop(), outerState, label); } @@ -1400,7 +1408,7 @@ namespace ts { function jumpToLabel(label: Identifier, outerState: Reachability): void { initializeReachabilityStateIfNecessary(); - const index = label ? labels[label.text] : lastOrUndefined(implicitLabels); + const index = label ? labelIndexMap[label.text] : lastOrUndefined(implicitLabels); if (index === undefined) { // reference to unknown label or // break/continue used outside of loops @@ -1411,12 +1419,16 @@ namespace ts { } function checkUnreachable(node: Node): boolean { - switch(currentReachabilityState) { + switch (currentReachabilityState) { case Reachability.Unreachable: const reportError = + // report error on all statements isStatement(node) || + // report error on class declarations node.kind === SyntaxKind.ClassDeclaration || - node.kind === SyntaxKind.ModuleDeclaration || + // 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) { @@ -1424,7 +1436,7 @@ namespace ts { // unreachable code is reported if // - user has explicitly asked about it AND - // - statement is in ambient context (statements in ambient context is already an error so we shoult not report extras) AND + // - statement is in not ambient context (statements in ambient context is already an error so we shoult 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 @@ -1448,14 +1460,19 @@ namespace ts { default: return false; } + + function shouldReportErrorOnModuleDeclaration(node: ModuleDeclaration): boolean { + const instanceState = getModuleInstanceState(node); + return instanceState === ModuleInstanceState.Instantiated || (instanceState === ModuleInstanceState.ConstEnumOnly && options.preserveConstEnums); + } } function initializeReachabilityStateIfNecessary(): void { - if (labels) { + if (labelIndexMap) { return; } currentReachabilityState = Reachability.Reachable; - labels = {}; + labelIndexMap = {}; labelStack = []; implicitLabels = []; } diff --git a/tests/baselines/reference/reachabilityChecks1.errors.txt b/tests/baselines/reference/reachabilityChecks1.errors.txt index ebf1019e7e9..7708867c26c 100644 --- a/tests/baselines/reference/reachabilityChecks1.errors.txt +++ b/tests/baselines/reference/reachabilityChecks1.errors.txt @@ -1,12 +1,13 @@ tests/cases/compiler/reachabilityChecks1.ts(3,1): error TS7027: Unreachable code detected. tests/cases/compiler/reachabilityChecks1.ts(7,5): error TS7027: Unreachable code detected. -tests/cases/compiler/reachabilityChecks1.ts(22,11): error TS7027: Unreachable code detected. -tests/cases/compiler/reachabilityChecks1.ts(28,12): error TS7027: Unreachable code detected. -tests/cases/compiler/reachabilityChecks1.ts(35,10): error TS7027: Unreachable code detected. -tests/cases/compiler/reachabilityChecks1.ts(44,16): error TS7027: Unreachable code detected. +tests/cases/compiler/reachabilityChecks1.ts(19,12): error TS7027: Unreachable code detected. +tests/cases/compiler/reachabilityChecks1.ts(31,12): error TS7027: Unreachable code detected. +tests/cases/compiler/reachabilityChecks1.ts(48,11): error TS7027: Unreachable code detected. +tests/cases/compiler/reachabilityChecks1.ts(61,10): error TS7027: Unreachable code detected. +tests/cases/compiler/reachabilityChecks1.ts(70,16): error TS7027: Unreachable code detected. -==== tests/cases/compiler/reachabilityChecks1.ts (6 errors) ==== +==== tests/cases/compiler/reachabilityChecks1.ts (7 errors) ==== while (true); var x = 1; @@ -20,6 +21,36 @@ tests/cases/compiler/reachabilityChecks1.ts(44,16): error TS7027: Unreachable co !!! error TS7027: Unreachable code detected. } + module A1 { + do {} while(true); + module A { + interface F {} + } + } + + module A2 { + while (true); + module A { + ~ +!!! error TS7027: Unreachable code detected. + var x = 1; + } + } + + module A3 { + while (true); + type T = string; + } + + module A4 { + while (true); + module A { + ~ +!!! error TS7027: Unreachable code detected. + const enum E { X } + } + } + function f1(x) { if (x) { return; @@ -41,8 +72,6 @@ tests/cases/compiler/reachabilityChecks1.ts(44,16): error TS7027: Unreachable co module B { for (; ;); module C { - ~ -!!! error TS7027: Unreachable code detected. } } diff --git a/tests/baselines/reference/reachabilityChecks1.js b/tests/baselines/reference/reachabilityChecks1.js index 3f9ca87422a..dcbfbe89de4 100644 --- a/tests/baselines/reference/reachabilityChecks1.js +++ b/tests/baselines/reference/reachabilityChecks1.js @@ -8,6 +8,32 @@ module A { let x; } +module A1 { + do {} while(true); + module A { + interface F {} + } +} + +module A2 { + while (true); + module A { + var x = 1; + } +} + +module A3 { + while (true); + type T = string; +} + +module A4 { + while (true); + module A { + const enum E { X } + } +} + function f1(x) { if (x) { return; @@ -59,6 +85,36 @@ var A; ; var x; })(A || (A = {})); +var A1; +(function (A1) { + do { } while (true); +})(A1 || (A1 = {})); +var A2; +(function (A2) { + while (true) + ; + var A; + (function (A) { + var x = 1; + })(A || (A = {})); +})(A2 || (A2 = {})); +var A3; +(function (A3) { + while (true) + ; +})(A3 || (A3 = {})); +var A4; +(function (A4) { + while (true) + ; + var A; + (function (A) { + var E; + (function (E) { + E[E["X"] = 0] = "X"; + })(E || (E = {})); + })(A || (A = {})); +})(A4 || (A4 = {})); function f1(x) { if (x) { return; diff --git a/tests/baselines/reference/reachabilityChecks2.errors.txt b/tests/baselines/reference/reachabilityChecks2.errors.txt new file mode 100644 index 00000000000..3de7adc50a6 --- /dev/null +++ b/tests/baselines/reference/reachabilityChecks2.errors.txt @@ -0,0 +1,18 @@ +tests/cases/compiler/reachabilityChecks2.ts(5,8): error TS7027: Unreachable code detected. + + +==== tests/cases/compiler/reachabilityChecks2.ts (1 errors) ==== + + while (true) { } + const enum E { X } + + module A4 { + ~~ +!!! error TS7027: Unreachable code detected. + while (true); + module A { + const enum E { X } + } + } + + \ No newline at end of file diff --git a/tests/baselines/reference/reachabilityChecks2.js b/tests/baselines/reference/reachabilityChecks2.js index 80534c0d7de..a17b51b4ca6 100644 --- a/tests/baselines/reference/reachabilityChecks2.js +++ b/tests/baselines/reference/reachabilityChecks2.js @@ -3,7 +3,19 @@ while (true) { } const enum E { X } +module A4 { + while (true); + module A { + const enum E { X } + } +} + //// [reachabilityChecks2.js] while (true) { } +var A4; +(function (A4) { + while (true) + ; +})(A4 || (A4 = {})); diff --git a/tests/baselines/reference/reachabilityChecks2.symbols b/tests/baselines/reference/reachabilityChecks2.symbols deleted file mode 100644 index d289304dffa..00000000000 --- a/tests/baselines/reference/reachabilityChecks2.symbols +++ /dev/null @@ -1,8 +0,0 @@ -=== tests/cases/compiler/reachabilityChecks2.ts === - -while (true) { } -const enum E { X } ->E : Symbol(E, Decl(reachabilityChecks2.ts, 1, 16)) ->X : Symbol(E.X, Decl(reachabilityChecks2.ts, 2, 14)) - - diff --git a/tests/baselines/reference/reachabilityChecks2.types b/tests/baselines/reference/reachabilityChecks2.types deleted file mode 100644 index 38dad87c6a1..00000000000 --- a/tests/baselines/reference/reachabilityChecks2.types +++ /dev/null @@ -1,10 +0,0 @@ -=== tests/cases/compiler/reachabilityChecks2.ts === - -while (true) { } ->true : boolean - -const enum E { X } ->E : E ->X : E - - diff --git a/tests/cases/compiler/reachabilityChecks1.ts b/tests/cases/compiler/reachabilityChecks1.ts index bc7662486a6..ce009e13456 100644 --- a/tests/cases/compiler/reachabilityChecks1.ts +++ b/tests/cases/compiler/reachabilityChecks1.ts @@ -9,6 +9,32 @@ module A { let x; } +module A1 { + do {} while(true); + module A { + interface F {} + } +} + +module A2 { + while (true); + module A { + var x = 1; + } +} + +module A3 { + while (true); + type T = string; +} + +module A4 { + while (true); + module A { + const enum E { X } + } +} + function f1(x) { if (x) { return; diff --git a/tests/cases/compiler/reachabilityChecks2.ts b/tests/cases/compiler/reachabilityChecks2.ts index fc8d53bde8f..9a2b519ca4c 100644 --- a/tests/cases/compiler/reachabilityChecks2.ts +++ b/tests/cases/compiler/reachabilityChecks2.ts @@ -4,3 +4,10 @@ while (true) { } const enum E { X } +module A4 { + while (true); + module A { + const enum E { X } + } +} + From 682c14cc7f42dcaeef9cce90644173cea29aebfc Mon Sep 17 00:00:00 2001 From: Vladimir Matveev Date: Wed, 16 Sep 2015 12:43:52 -0700 Subject: [PATCH 014/227] addressed PR feedback --- src/compiler/binder.ts | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index cebc930d328..d22222b785e 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -406,37 +406,37 @@ namespace ts { * Returns true if node and its subnodes were successfully traversed. * Returning false means that node was not examined and caller needs to dive into the node himself. */ - function bindReachableStatement(n: Node): boolean { - if (checkUnreachable(n)) { + function bindReachableStatement(node: Node): boolean { + if (checkUnreachable(node)) { return false; } - switch (n.kind) { + switch (node.kind) { case SyntaxKind.WhileStatement: - return bindWhileStatement(n); + return bindWhileStatement(node); case SyntaxKind.DoStatement: - return bindDoStatement(n); + return bindDoStatement(node); case SyntaxKind.ForStatement: - return bindForStatement(n); + return bindForStatement(node); case SyntaxKind.ForInStatement: case SyntaxKind.ForOfStatement: - return bindForInOrForOfStatement(n); + return bindForInOrForOfStatement(node); case SyntaxKind.IfStatement: - return bindIfStatement(n); + return bindIfStatement(node); case SyntaxKind.ReturnStatement: case SyntaxKind.ThrowStatement: - return bindReturnOrThrow(n); + return bindReturnOrThrow(node); case SyntaxKind.BreakStatement: case SyntaxKind.ContinueStatement: - return bindBreakOrContinueStatement(n); + return bindBreakOrContinueStatement(node); case SyntaxKind.TryStatement: - return bindTryStatement(n); + return bindTryStatement(node); case SyntaxKind.SwitchStatement: - return bindSwitchStatement(n); + return bindSwitchStatement(node); case SyntaxKind.CaseBlock: - return bindCaseBlock(n); + return bindCaseBlock(node); case SyntaxKind.LabeledStatement: - return bindLabeledStatement(n); + return bindLabeledStatement(node); default: return false; } @@ -1436,7 +1436,8 @@ namespace ts { // 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 shoult not report extras) 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 From 311a0cff55e5837f9972fb43d65e06768babccc5 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Thu, 10 Sep 2015 17:58:54 -0700 Subject: [PATCH 015/227] Added tests. --- .../stringLiteralTypesAsTags01.ts | 43 +++++++++++++++ .../stringLiteralTypesInUnionTypes01.ts | 21 ++++++++ .../stringLiteralTypesInUnionTypes02.ts | 21 ++++++++ .../stringLiteralTypesInUnionTypes03.ts | 21 ++++++++ .../stringLiteralTypesInUnionTypes04.ts | 38 +++++++++++++ ...ingLiteralTypesInVariableDeclarations01.ts | 19 +++++++ .../stringLiteralTypesOverloads01.ts | 53 +++++++++++++++++++ .../stringLiteralTypesOverloads02.ts | 51 ++++++++++++++++++ .../stringLiteralTypesTypePredicates01.ts | 25 +++++++++ 9 files changed, 292 insertions(+) create mode 100644 tests/cases/conformance/types/stringLiteral/stringLiteralTypesAsTags01.ts create mode 100644 tests/cases/conformance/types/stringLiteral/stringLiteralTypesInUnionTypes01.ts create mode 100644 tests/cases/conformance/types/stringLiteral/stringLiteralTypesInUnionTypes02.ts create mode 100644 tests/cases/conformance/types/stringLiteral/stringLiteralTypesInUnionTypes03.ts create mode 100644 tests/cases/conformance/types/stringLiteral/stringLiteralTypesInUnionTypes04.ts create mode 100644 tests/cases/conformance/types/stringLiteral/stringLiteralTypesInVariableDeclarations01.ts create mode 100644 tests/cases/conformance/types/stringLiteral/stringLiteralTypesOverloads01.ts create mode 100644 tests/cases/conformance/types/stringLiteral/stringLiteralTypesOverloads02.ts create mode 100644 tests/cases/conformance/types/stringLiteral/stringLiteralTypesTypePredicates01.ts diff --git a/tests/cases/conformance/types/stringLiteral/stringLiteralTypesAsTags01.ts b/tests/cases/conformance/types/stringLiteral/stringLiteralTypesAsTags01.ts new file mode 100644 index 00000000000..cea04f0818e --- /dev/null +++ b/tests/cases/conformance/types/stringLiteral/stringLiteralTypesAsTags01.ts @@ -0,0 +1,43 @@ +// @declaration: true + +type Kind = "A" | "B" + +interface Entity { + kind: Kind; +} + +interface A extends Entity { + kind: "A"; + a: number; +} + +interface B extends Entity { + kind: "B"; + b: string; +} + +function hasKind(entity: Entity, kind: "A"): entity is A; +function hasKind(entity: Entity, kind: "B"): entity is B; +function hasKind(entity: Entity, kind: Kind): entity is Entity; +function hasKind(entity: Entity, kind: Kind): boolean { + return kind === is; +} + +let x: A = { + kind: "A", + a: 100, +} + +if (hasKind(x, "A")) { + let a = x; +} +else { + let b = x; +} + +if (!hasKind(x, "B")) { + let c = x; +} +else { + let d = x; +} \ No newline at end of file diff --git a/tests/cases/conformance/types/stringLiteral/stringLiteralTypesInUnionTypes01.ts b/tests/cases/conformance/types/stringLiteral/stringLiteralTypesInUnionTypes01.ts new file mode 100644 index 00000000000..b8ed1b47dd4 --- /dev/null +++ b/tests/cases/conformance/types/stringLiteral/stringLiteralTypesInUnionTypes01.ts @@ -0,0 +1,21 @@ +// @declaration: true + +type T = "foo" | "bar" | "baz"; + +var x: "foo" | "bar" | "baz" = "foo"; +var y: T = "bar"; + +if (x === "foo") { + let a = x; +} +else if (x !== "bar") { + let b = x || y; +} +else { + let c = x; + let d = y; + let e: (typeof x) | (typeof y) = c || d; +} + +x = y; +y = x; \ No newline at end of file diff --git a/tests/cases/conformance/types/stringLiteral/stringLiteralTypesInUnionTypes02.ts b/tests/cases/conformance/types/stringLiteral/stringLiteralTypesInUnionTypes02.ts new file mode 100644 index 00000000000..2cc63ab4460 --- /dev/null +++ b/tests/cases/conformance/types/stringLiteral/stringLiteralTypesInUnionTypes02.ts @@ -0,0 +1,21 @@ +// @declaration: true + +type T = string | "foo" | "bar" | "baz"; + +var x: "foo" | "bar" | "baz" | string = "foo"; +var y: T = "bar"; + +if (x === "foo") { + let a = x; +} +else if (x !== "bar") { + let b = x || y; +} +else { + let c = x; + let d = y; + let e: (typeof x) | (typeof y) = c || d; +} + +x = y; +y = x; \ No newline at end of file diff --git a/tests/cases/conformance/types/stringLiteral/stringLiteralTypesInUnionTypes03.ts b/tests/cases/conformance/types/stringLiteral/stringLiteralTypesInUnionTypes03.ts new file mode 100644 index 00000000000..d5c6a38af79 --- /dev/null +++ b/tests/cases/conformance/types/stringLiteral/stringLiteralTypesInUnionTypes03.ts @@ -0,0 +1,21 @@ +// @declaration: true + +type T = number | "foo" | "bar"; + +var x: "foo" | "bar" | number; +var y: T = "bar"; + +if (x === "foo") { + let a = x; +} +else if (x !== "bar") { + let b = x || y; +} +else { + let c = x; + let d = y; + let e: (typeof x) | (typeof y) = c || d; +} + +x = y; +y = x; \ No newline at end of file diff --git a/tests/cases/conformance/types/stringLiteral/stringLiteralTypesInUnionTypes04.ts b/tests/cases/conformance/types/stringLiteral/stringLiteralTypesInUnionTypes04.ts new file mode 100644 index 00000000000..e9d062b0e5c --- /dev/null +++ b/tests/cases/conformance/types/stringLiteral/stringLiteralTypesInUnionTypes04.ts @@ -0,0 +1,38 @@ +// @declaration: true + +type T = "" | "foo"; + +let x: T = ""; +let y: T = "foo"; + +if (x === "") { + let a = x; +} + +if (x !== "") { + let b = x; +} + +if (x == "") { + let c = x; +} + +if (x != "") { + let d = x; +} + +if (x) { + let e = x; +} + +if (!x) { + let f = x; +} + +if (!!x) { + let g = x; +} + +if (!!!x) { + let h = x; +} \ No newline at end of file diff --git a/tests/cases/conformance/types/stringLiteral/stringLiteralTypesInVariableDeclarations01.ts b/tests/cases/conformance/types/stringLiteral/stringLiteralTypesInVariableDeclarations01.ts new file mode 100644 index 00000000000..4f006387687 --- /dev/null +++ b/tests/cases/conformance/types/stringLiteral/stringLiteralTypesInVariableDeclarations01.ts @@ -0,0 +1,19 @@ +// @declaration: true + +let a: ""; +var b: "foo"; +let c: "bar"; +const d: "baz"; + +a = ""; +b = "foo"; +c = "bar"; + +let e: "" = ""; +var f: "foo" = "foo"; +let g: "bar" = "bar"; +const h: "baz" = "baz"; + +e = ""; +f = "foo"; +g = "bar"; \ No newline at end of file diff --git a/tests/cases/conformance/types/stringLiteral/stringLiteralTypesOverloads01.ts b/tests/cases/conformance/types/stringLiteral/stringLiteralTypesOverloads01.ts new file mode 100644 index 00000000000..d88167eaeff --- /dev/null +++ b/tests/cases/conformance/types/stringLiteral/stringLiteralTypesOverloads01.ts @@ -0,0 +1,53 @@ +// @declaration: true + +type PrimitiveName = 'string' | 'number' | 'boolean'; + +function getFalsyPrimitive(x: "string"): string; +function getFalsyPrimitive(x: "number"): number; +function getFalsyPrimitive(x: "boolean"): boolean; +function getFalsyPrimitive(x: "boolean" | "string"): boolean | string; +function getFalsyPrimitive(x: "boolean" | "number"): boolean | number; +function getFalsyPrimitive(x: "number" | "string"): number | string; +function getFalsyPrimitive(x: "number" | "string" | "boolean"): number | string | boolean; +function getFalsyPrimitive(x: PrimitiveName) { + if (x === "string") { + return ""; + } + if (x === "number") { + return 0; + } + if (x === "boolean") { + return false; + } + + // Should be unreachable. + throw "Invalid value"; +} + +namespace Consts1 { + const EMPTY_STRING = getFalsyPrimitive("string"); + const ZERO = getFalsyPrimitive('number'); + const FALSE = getFalsyPrimitive("boolean"); +} + +const string: "string" = "string" +const number: "number" = "number" +const boolean: "boolean" = "boolean" + +const stringOrNumber = string || number; +const stringOrBoolean = string || boolean; +const booleanOrNumber = number || boolean; +const stringOrBooleanOrNumber = stringOrBoolean || number; + +namespace Consts2 { + const EMPTY_STRING = getFalsyPrimitive(string); + const ZERO = getFalsyPrimitive(number); + const FALSE = getFalsyPrimitive(boolean); + + const a = getFalsyPrimitive(stringOrNumber); + const b = getFalsyPrimitive(stringOrBoolean); + const c = getFalsyPrimitive(booleanOrNumber); + const d = getFalsyPrimitive(stringOrBooleanOrNumber); +} + + diff --git a/tests/cases/conformance/types/stringLiteral/stringLiteralTypesOverloads02.ts b/tests/cases/conformance/types/stringLiteral/stringLiteralTypesOverloads02.ts new file mode 100644 index 00000000000..5801aa50076 --- /dev/null +++ b/tests/cases/conformance/types/stringLiteral/stringLiteralTypesOverloads02.ts @@ -0,0 +1,51 @@ +// @declaration: true + +function getFalsyPrimitive(x: "string"): string; +function getFalsyPrimitive(x: "number"): number; +function getFalsyPrimitive(x: "boolean"): boolean; +function getFalsyPrimitive(x: "boolean" | "string"): boolean | string; +function getFalsyPrimitive(x: "boolean" | "number"): boolean | number; +function getFalsyPrimitive(x: "number" | "string"): number | string; +function getFalsyPrimitive(x: "number" | "string" | "boolean"): number | string | boolean; +function getFalsyPrimitive(x: string) { + if (x === "string") { + return ""; + } + if (x === "number") { + return 0; + } + if (x === "boolean") { + return false; + } + + // Should be unreachable. + throw "Invalid value"; +} + +namespace Consts1 { + const EMPTY_STRING = getFalsyPrimitive("string"); + const ZERO = getFalsyPrimitive('number'); + const FALSE = getFalsyPrimitive("boolean"); +} + +const string: "string" = "string" +const number: "number" = "number" +const boolean: "boolean" = "boolean" + +const stringOrNumber = string || number; +const stringOrBoolean = string || boolean; +const booleanOrNumber = number || boolean; +const stringOrBooleanOrNumber = stringOrBoolean || number; + +namespace Consts2 { + const EMPTY_STRING = getFalsyPrimitive(string); + const ZERO = getFalsyPrimitive(number); + const FALSE = getFalsyPrimitive(boolean); + + const a = getFalsyPrimitive(stringOrNumber); + const b = getFalsyPrimitive(stringOrBoolean); + const c = getFalsyPrimitive(booleanOrNumber); + const d = getFalsyPrimitive(stringOrBooleanOrNumber); +} + + diff --git a/tests/cases/conformance/types/stringLiteral/stringLiteralTypesTypePredicates01.ts b/tests/cases/conformance/types/stringLiteral/stringLiteralTypesTypePredicates01.ts new file mode 100644 index 00000000000..a78918c8122 --- /dev/null +++ b/tests/cases/conformance/types/stringLiteral/stringLiteralTypesTypePredicates01.ts @@ -0,0 +1,25 @@ +// @declaration: true + +type Kind = "A" | "B" + +function kindIs(kind: Kind, is: "A"): kind is "A"; +function kindIs(kind: Kind, is: "B"): kind is "B"; +function kindIs(kind: Kind, is: Kind): boolean { + return kind === is; +} + +var x: Kind = "A"; + +if (kindIs(x, "A")) { + let a = x; +} +else { + let b = x; +} + +if (!kindIs(x, "B")) { + let c = x; +} +else { + let d = x; +} \ No newline at end of file From 7d067890ce808fd57439d4cf9f6aec40d3e5c412 Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Wed, 30 Sep 2015 14:46:33 -0700 Subject: [PATCH 016/227] naive change --- src/compiler/emitter.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index bec17b813cb..60864e411fc 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -469,6 +469,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi if (!isExternalModuleOrDeclarationFile(sourceFile)) { emitSourceFile(sourceFile); } + else if (isExternalModule(sourceFile)) { + emitConcatenatedModule(sourceFile); + } }); } @@ -482,6 +485,12 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi emit(sourceFile); } + function emitConcatenatedModule(sourceFile: SourceFile): void { + currentSourceFile = sourceFile; + exportFunctionForFile = undefined; + moduleEmitDelegates[modulekind](sourceFile, 0); + } + function isUniqueName(name: string): boolean { return !resolver.hasGlobalName(name) && !hasProperty(currentSourceFile.identifiers, name) && From b6a57ea8afa8072a87a46ba3841ed82af1112004 Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Thu, 1 Oct 2015 12:44:24 -0700 Subject: [PATCH 017/227] Concatenated module emit fixes up all included paths --- src/compiler/emitter.ts | 56 ++++++++++++++++++++++++++++++++------- src/compiler/program.ts | 6 +++++ src/compiler/utilities.ts | 32 ++++++++++++++++++++-- 3 files changed, 82 insertions(+), 12 deletions(-) diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index 60864e411fc..df2687768fc 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -448,7 +448,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi /** If removeComments is true, no leading-comments needed to be emitted **/ let emitLeadingCommentsOfPosition = compilerOptions.removeComments ? function (pos: number) { } : emitLeadingCommentsOfPositionWorker; - let moduleEmitDelegates: Map<(node: SourceFile, startIndex: number) => void> = { + let moduleEmitDelegates: Map<(node: SourceFile, startIndex: number, resolvePath?: boolean) => void> = { [ModuleKind.ES6]: emitES6Module, [ModuleKind.AMD]: emitAMDModule, [ModuleKind.System]: emitSystemModule, @@ -456,6 +456,14 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi [ModuleKind.CommonJS]: emitCommonJSModule, }; + let bundleEmitDelegates: Map<(node: SourceFile, startIndex: number, resolvePath?: boolean) => void> = { + [ModuleKind.ES6]: () => {}, + [ModuleKind.AMD]: emitAMDModule, + [ModuleKind.System]: emitSystemModule, + [ModuleKind.UMD]: emitUMDModule, + [ModuleKind.CommonJS]: () => {}, + }; + if (compilerOptions.sourceMap || compilerOptions.inlineSourceMap) { initializeEmitterWithSourceMaps(); } @@ -465,6 +473,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi emitSourceFile(root); } else { + forEach(host.getSourceFiles(), emitEmitHelpers); forEach(host.getSourceFiles(), sourceFile => { if (!isExternalModuleOrDeclarationFile(sourceFile)) { emitSourceFile(sourceFile); @@ -488,7 +497,16 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi function emitConcatenatedModule(sourceFile: SourceFile): void { currentSourceFile = sourceFile; exportFunctionForFile = undefined; - moduleEmitDelegates[modulekind](sourceFile, 0); + let canonicalName = resolveToSemiabsolutePath(sourceFile.fileName); + sourceFile.moduleName = sourceFile.moduleName || canonicalName; + bundleEmitDelegates[modulekind](sourceFile, 0, /*resolvePath*/true); + } + + function resolveToSemiabsolutePath(path: string): string { + let dir = host.getCurrentDirectory(); + return removeFileExtension( + getRelativePathToDirectoryOrUrl(dir, path, dir, f => host.getCanonicalFileName(f), /*isAbsolutePathAnUrl*/false) + ); } function isUniqueName(name: string): boolean { @@ -6620,7 +6638,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi write("}"); // execute } - function emitSystemModule(node: SourceFile, startIndex: number): void { + function emitSystemModule(node: SourceFile, startIndex: number, resolvePath?: boolean): void { collectExternalModuleInfo(node); // System modules has the following shape // System.register(['dep-1', ... 'dep-n'], function(exports) {/* module body function */}) @@ -6660,6 +6678,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi write(", "); } + if (resolvePath) { + text = makeModulePathSemiabsolute(text); + } write(text); } write(`], function(${exportFunctionForFile}) {`); @@ -6679,7 +6700,18 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi importAliasNames: string[]; } - function getAMDDependencyNames(node: SourceFile, includeNonAmdDependencies: boolean): AMDDependencyNames { + function makeModulePathSemiabsolute(externalModuleName: string): string { + let quotemark = externalModuleName.charAt(0); + let unquotedModuleName = externalModuleName.substring(1, externalModuleName.length - 1); + let resolvedFileName = host.resolveModuleName(unquotedModuleName, currentSourceFile.fileName); + if (resolvedFileName) { + let semiabsoluteName = resolveToSemiabsolutePath(resolvedFileName); + externalModuleName = quoteString(semiabsoluteName, quotemark); + } + return externalModuleName; + } + + function getAMDDependencyNames(node: SourceFile, includeNonAmdDependencies: boolean, resolvePath?: boolean): AMDDependencyNames { // names of modules with corresponding parameter in the factory function let aliasedModuleNames: string[] = []; // names of modules with no corresponding parameters in factory function @@ -6703,6 +6735,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi // Find the name of the external module let externalModuleName = getExternalModuleNameText(importNode); + if (resolvePath) { + externalModuleName = makeModulePathSemiabsolute(externalModuleName); + } + // Find the name of the module alias, if there is one let importAliasName = getLocalNameForExternalImport(importNode); if (includeNonAmdDependencies && importAliasName) { @@ -6717,7 +6753,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi return { aliasedModuleNames, unaliasedModuleNames, importAliasNames }; } - function emitAMDDependencies(node: SourceFile, includeNonAmdDependencies: boolean) { + function emitAMDDependencies(node: SourceFile, includeNonAmdDependencies: boolean, resolvePath?: boolean) { // An AMD define function has the following shape: // define(id?, dependencies?, factory); // @@ -6730,7 +6766,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi // `import "module"` or `` // we need to add modules without alias names to the end of the dependencies list - let dependencyNames = getAMDDependencyNames(node, includeNonAmdDependencies); + let dependencyNames = getAMDDependencyNames(node, includeNonAmdDependencies, resolvePath); emitAMDDependencyList(dependencyNames); write(", "); emitAMDFactoryHeader(dependencyNames); @@ -6758,7 +6794,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi write(") {"); } - function emitAMDModule(node: SourceFile, startIndex: number) { + function emitAMDModule(node: SourceFile, startIndex: number, resolvePath?: boolean) { emitEmitHelpers(node); collectExternalModuleInfo(node); @@ -6767,7 +6803,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi if (node.moduleName) { write("\"" + node.moduleName + "\", "); } - emitAMDDependencies(node, /*includeNonAmdDependencies*/ true); + emitAMDDependencies(node, /*includeNonAmdDependencies*/ true, resolvePath); increaseIndent(); emitExportStarHelper(); emitCaptureThisForNodeIfNecessary(node); @@ -6789,11 +6825,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi emitExportEquals(/*emitAsReturn*/ false); } - function emitUMDModule(node: SourceFile, startIndex: number) { + function emitUMDModule(node: SourceFile, startIndex: number, resolvePath?: boolean) { emitEmitHelpers(node); collectExternalModuleInfo(node); - let dependencyNames = getAMDDependencyNames(node, /*includeNonAmdDependencies*/ false); + let dependencyNames = getAMDDependencyNames(node, /*includeNonAmdDependencies*/ false, resolvePath); // Module is detected first to support Browserify users that load into a browser with an AMD loader writeLines(`(function (factory) { diff --git a/src/compiler/program.ts b/src/compiler/program.ts index c6d3a245a8d..b595d48dc57 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -522,6 +522,12 @@ namespace ts { getSourceFiles: program.getSourceFiles, writeFile: writeFileCallback || ( (fileName, data, writeByteOrderMark, onError) => host.writeFile(fileName, data, writeByteOrderMark, onError)), + resolveModuleName: (name: string, containingFile?: string) => { + let resolvedModule = resolveModuleNamesWorker([name], containingFile || "dummy.ts")[0]; + if (!resolvedModule) + return; + return resolvedModule.resolvedFileName; + }, }; } diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 452f59f0f03..9ae65af046e 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -40,6 +40,7 @@ namespace ts { getNewLine(): string; writeFile: WriteFileCallback; + resolveModuleName(path: string, containingFile?: string): string; } // Pool writers to avoid needing to allocate them for every symbol we write. @@ -1619,21 +1620,48 @@ namespace ts { "\u0085": "\\u0085" // nextLine }; + let singleQuoteEscapedCharsRegExp = /[\\\'\u0000-\u001f\t\v\f\b\r\n\u2028\u2029\u0085]/g; + let singleQuoteEscapedCharsMap: Map = { + "\0": "\\0", + "\t": "\\t", + "\v": "\\v", + "\f": "\\f", + "\b": "\\b", + "\r": "\\r", + "\n": "\\n", + "\\": "\\\\", + "\'": "\\\'", + "\u2028": "\\u2028", // lineSeparator + "\u2029": "\\u2029", // paragraphSeparator + "\u0085": "\\u0085" // nextLine + }; + /** * Based heavily on the abstract 'Quote'/'QuoteJSONString' operation from ECMA-262 (24.3.2.2), * but augmented for a few select characters (e.g. lineSeparator, paragraphSeparator, nextLine) * Note that this doesn't actually wrap the input in double quotes. */ export function escapeString(s: string): string { - s = escapedCharsRegExp.test(s) ? s.replace(escapedCharsRegExp, getReplacement) : s; + return escapeStringByQuote(s, "\""); + } + + export function escapeStringByQuote(s: string, quotemark: string): string { + let regex = quotemark === "'" ? singleQuoteEscapedCharsRegExp : escapedCharsRegExp; + let replacementMap = quotemark === "'" ? singleQuoteEscapedCharsMap : escapedCharsMap; + + s = regex.test(s) ? s.replace(regex, getReplacement) : s; return s; function getReplacement(c: string) { - return escapedCharsMap[c] || get16BitUnicodeEscapeSequence(c.charCodeAt(0)); + return replacementMap[c] || get16BitUnicodeEscapeSequence(c.charCodeAt(0)); } } + export function quoteString(s: string, quotemark: string): string { + return quotemark + escapeStringByQuote(s, quotemark) + quotemark; + } + export function isIntrinsicJsxName(name: string) { let ch = name.substr(0, 1); return ch.toLowerCase() === ch; From 911e90730601f35a24dcd16d2e6d5f4fc6b12529 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Thu, 1 Oct 2015 15:26:48 -0700 Subject: [PATCH 018/227] Added test for string literal types in type arguments. --- .../typeArgumentsWithStringLiteralTypes01.ts | 113 ++++++++++++++++++ 1 file changed, 113 insertions(+) create mode 100644 tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts diff --git a/tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts b/tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts new file mode 100644 index 00000000000..08c971458e3 --- /dev/null +++ b/tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts @@ -0,0 +1,113 @@ +// @declaration: true + +declare function randBool(): boolean; +declare function takeReturnString(str: string): string; +declare function takeReturnHello(str: "Hello"): "Hello"; +declare function takeReturnHelloWorld(str: "Hello" | "World"): "Hello" | "World"; + +function fun1(x: T, y: T) { + return randBool() ? x : y; +} + +function fun2(x: T, y: U) { + return randBool() ? x : y; +} + +function fun3(...args: T[]): T { + return args[+randBool()]; +} + +namespace n1 { + // The following should all come back as strings. + // They should be assignable to/from something of a type 'string'. + // They should not be assignable to either "Hello" or "World". + export let a = fun1("Hello", "World"); + export let b = fun1("Hello", "Hello"); + export let c = fun2("Hello", "World"); + export let d = fun2("Hello", "Hello"); + export let e = fun3("Hello", "Hello", "World", "Foo"); + + // Should be valid + a = takeReturnString(a); + b = takeReturnString(b); + c = takeReturnString(c); + d = takeReturnString(d); + e = takeReturnString(e); + + // Passing these as arguments should cause an error. + a = takeReturnHello(a); + b = takeReturnHello(b); + c = takeReturnHello(c); + d = takeReturnHello(d); + e = takeReturnHello(e); + + // Passing these as arguments should cause an error. + a = takeReturnHelloWorld(a); + b = takeReturnHelloWorld(b); + c = takeReturnHelloWorld(c); + d = takeReturnHelloWorld(d); + e = takeReturnHelloWorld(e); +} + +namespace n2 { + // The following (regardless of errors) should come back typed + // as "Hello" (or "Hello" | "Hello"). + export let a = fun1<"Hello">("Hello", "Hello"); + export let b = fun1<"Hello">("Hello", "World"); + export let c = fun2<"Hello", "Hello">("Hello", "Hello"); + export let d = fun2<"Hello", "Hello">("Hello", "World"); + export let e = fun3<"Hello">("Hello", "World"); + + // Assignment from the returned value should cause an error. + a = takeReturnString(a); + b = takeReturnString(b); + c = takeReturnString(c); + d = takeReturnString(d); + e = takeReturnString(e); + + // Should be valid + a = takeReturnHello(a); + b = takeReturnHello(b); + c = takeReturnHello(c); + d = takeReturnHello(d); + e = takeReturnHello(e); + + // Assignment from the returned value should cause an error. + a = takeReturnHelloWorld(a); + b = takeReturnHelloWorld(b); + c = takeReturnHelloWorld(c); + d = takeReturnHelloWorld(d); + e = takeReturnHelloWorld(e); +} + + +namespace n3 { + // The following (regardless of errors) should come back typed + // as "Hello" | "World" (or "World" | "Hello"). + export let a = fun2<"Hello", "World">("Hello", "World"); + export let b = fun2<"Hello", "World">("World", "Hello"); + export let c = fun2<"World", "Hello">("Hello", "Hello"); + export let d = fun2<"World", "Hello">("World", "World"); + export let e = fun3<"Hello" | "World">("Hello", "World"); + + // Assignment from the returned value should cause an error. + a = takeReturnString(a); + b = takeReturnString(b); + c = takeReturnString(c); + d = takeReturnString(d); + e = takeReturnString(e); + + // Passing these as arguments should cause an error. + a = takeReturnHello(a); + b = takeReturnHello(b); + c = takeReturnHello(c); + d = takeReturnHello(d); + e = takeReturnHello(e); + + // Both should be valid. + a = takeReturnHelloWorld(a); + b = takeReturnHelloWorld(b); + c = takeReturnHelloWorld(c); + d = takeReturnHelloWorld(d); + e = takeReturnHelloWorld(e); +} \ No newline at end of file From f04cc39a68a7a576ca9e6b7149b076cd9eb95fd9 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Thu, 1 Oct 2015 15:54:16 -0700 Subject: [PATCH 019/227] Accepted baselines. --- .../stringLiteralTypesAsTags01.errors.txt | 86 +++++ .../reference/stringLiteralTypesAsTags01.js | 65 ++++ ...tringLiteralTypesInUnionTypes01.errors.txt | 59 ++++ .../stringLiteralTypesInUnionTypes01.js | 40 +++ ...tringLiteralTypesInUnionTypes02.errors.txt | 62 ++++ .../stringLiteralTypesInUnionTypes02.js | 40 +++ ...tringLiteralTypesInUnionTypes03.errors.txt | 50 +++ .../stringLiteralTypesInUnionTypes03.js | 39 +++ ...tringLiteralTypesInUnionTypes04.errors.txt | 52 +++ .../stringLiteralTypesInUnionTypes04.js | 67 ++++ ...alTypesInVariableDeclarations01.errors.txt | 81 +++++ ...ingLiteralTypesInVariableDeclarations01.js | 35 ++ .../stringLiteralTypesOverloads01.errors.txt | 146 ++++++++ .../stringLiteralTypesOverloads01.js | 93 +++++ .../stringLiteralTypesOverloads02.errors.txt | 129 +++++++ .../stringLiteralTypesOverloads02.js | 90 +++++ ...ingLiteralTypesTypePredicates01.errors.txt | 57 +++ .../stringLiteralTypesTypePredicates01.js | 46 +++ ...gumentsWithStringLiteralTypes01.errors.txt | 325 ++++++++++++++++++ .../typeArgumentsWithStringLiteralTypes01.js | 221 ++++++++++++ 20 files changed, 1783 insertions(+) create mode 100644 tests/baselines/reference/stringLiteralTypesAsTags01.errors.txt create mode 100644 tests/baselines/reference/stringLiteralTypesAsTags01.js create mode 100644 tests/baselines/reference/stringLiteralTypesInUnionTypes01.errors.txt create mode 100644 tests/baselines/reference/stringLiteralTypesInUnionTypes01.js create mode 100644 tests/baselines/reference/stringLiteralTypesInUnionTypes02.errors.txt create mode 100644 tests/baselines/reference/stringLiteralTypesInUnionTypes02.js create mode 100644 tests/baselines/reference/stringLiteralTypesInUnionTypes03.errors.txt create mode 100644 tests/baselines/reference/stringLiteralTypesInUnionTypes03.js create mode 100644 tests/baselines/reference/stringLiteralTypesInUnionTypes04.errors.txt create mode 100644 tests/baselines/reference/stringLiteralTypesInUnionTypes04.js create mode 100644 tests/baselines/reference/stringLiteralTypesInVariableDeclarations01.errors.txt create mode 100644 tests/baselines/reference/stringLiteralTypesInVariableDeclarations01.js create mode 100644 tests/baselines/reference/stringLiteralTypesOverloads01.errors.txt create mode 100644 tests/baselines/reference/stringLiteralTypesOverloads01.js create mode 100644 tests/baselines/reference/stringLiteralTypesOverloads02.errors.txt create mode 100644 tests/baselines/reference/stringLiteralTypesOverloads02.js create mode 100644 tests/baselines/reference/stringLiteralTypesTypePredicates01.errors.txt create mode 100644 tests/baselines/reference/stringLiteralTypesTypePredicates01.js create mode 100644 tests/baselines/reference/typeArgumentsWithStringLiteralTypes01.errors.txt create mode 100644 tests/baselines/reference/typeArgumentsWithStringLiteralTypes01.js diff --git a/tests/baselines/reference/stringLiteralTypesAsTags01.errors.txt b/tests/baselines/reference/stringLiteralTypesAsTags01.errors.txt new file mode 100644 index 00000000000..292cc8ea5b7 --- /dev/null +++ b/tests/baselines/reference/stringLiteralTypesAsTags01.errors.txt @@ -0,0 +1,86 @@ +tests/cases/conformance/types/stringLiteral/stringLiteralTypesAsTags01.ts(2,12): error TS4081: Exported type alias 'Kind' has or is using private name ''. +tests/cases/conformance/types/stringLiteral/stringLiteralTypesAsTags01.ts(2,13): error TS1110: Type expected. +tests/cases/conformance/types/stringLiteral/stringLiteralTypesAsTags01.ts(2,13): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/types/stringLiteral/stringLiteralTypesAsTags01.ts(2,19): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/types/stringLiteral/stringLiteralTypesAsTags01.ts(9,10): error TS4033: Property 'kind' of exported interface has or is using private name ''. +tests/cases/conformance/types/stringLiteral/stringLiteralTypesAsTags01.ts(9,11): error TS1110: Type expected. +tests/cases/conformance/types/stringLiteral/stringLiteralTypesAsTags01.ts(14,10): error TS4033: Property 'kind' of exported interface has or is using private name ''. +tests/cases/conformance/types/stringLiteral/stringLiteralTypesAsTags01.ts(14,11): error TS1110: Type expected. +tests/cases/conformance/types/stringLiteral/stringLiteralTypesAsTags01.ts(18,10): error TS2382: Specialized overload signature is not assignable to any non-specialized signature. +tests/cases/conformance/types/stringLiteral/stringLiteralTypesAsTags01.ts(19,10): error TS2382: Specialized overload signature is not assignable to any non-specialized signature. +tests/cases/conformance/types/stringLiteral/stringLiteralTypesAsTags01.ts(20,10): error TS2394: Overload signature is not compatible with function implementation. +tests/cases/conformance/types/stringLiteral/stringLiteralTypesAsTags01.ts(22,21): error TS2304: Cannot find name 'is'. +tests/cases/conformance/types/stringLiteral/stringLiteralTypesAsTags01.ts(25,5): error TS2322: Type '{ kind: string; a: number; }' is not assignable to type 'A'. + Property '"A"' is missing in type '{ kind: string; a: number; }'. + + +==== tests/cases/conformance/types/stringLiteral/stringLiteralTypesAsTags01.ts (13 errors) ==== + + type Kind = "A" | "B" + +!!! error TS4081: Exported type alias 'Kind' has or is using private name ''. + ~~~ +!!! error TS1110: Type expected. + ~~~ +!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + ~~~ +!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + + interface Entity { + kind: Kind; + } + + interface A extends Entity { + kind: "A"; + +!!! error TS4033: Property 'kind' of exported interface has or is using private name ''. + ~~~ +!!! error TS1110: Type expected. + a: number; + } + + interface B extends Entity { + kind: "B"; + +!!! error TS4033: Property 'kind' of exported interface has or is using private name ''. + ~~~ +!!! error TS1110: Type expected. + b: string; + } + + function hasKind(entity: Entity, kind: "A"): entity is A; + ~~~~~~~ +!!! error TS2382: Specialized overload signature is not assignable to any non-specialized signature. + function hasKind(entity: Entity, kind: "B"): entity is B; + ~~~~~~~ +!!! error TS2382: Specialized overload signature is not assignable to any non-specialized signature. + function hasKind(entity: Entity, kind: Kind): entity is Entity; + ~~~~~~~ +!!! error TS2394: Overload signature is not compatible with function implementation. + function hasKind(entity: Entity, kind: Kind): boolean { + return kind === is; + ~~ +!!! error TS2304: Cannot find name 'is'. + } + + let x: A = { + ~ +!!! error TS2322: Type '{ kind: string; a: number; }' is not assignable to type 'A'. +!!! error TS2322: Property '"A"' is missing in type '{ kind: string; a: number; }'. + kind: "A", + a: 100, + } + + if (hasKind(x, "A")) { + let a = x; + } + else { + let b = x; + } + + if (!hasKind(x, "B")) { + let c = x; + } + else { + let d = x; + } \ No newline at end of file diff --git a/tests/baselines/reference/stringLiteralTypesAsTags01.js b/tests/baselines/reference/stringLiteralTypesAsTags01.js new file mode 100644 index 00000000000..2ce20607790 --- /dev/null +++ b/tests/baselines/reference/stringLiteralTypesAsTags01.js @@ -0,0 +1,65 @@ +//// [stringLiteralTypesAsTags01.ts] + +type Kind = "A" | "B" + +interface Entity { + kind: Kind; +} + +interface A extends Entity { + kind: "A"; + a: number; +} + +interface B extends Entity { + kind: "B"; + b: string; +} + +function hasKind(entity: Entity, kind: "A"): entity is A; +function hasKind(entity: Entity, kind: "B"): entity is B; +function hasKind(entity: Entity, kind: Kind): entity is Entity; +function hasKind(entity: Entity, kind: Kind): boolean { + return kind === is; +} + +let x: A = { + kind: "A", + a: 100, +} + +if (hasKind(x, "A")) { + let a = x; +} +else { + let b = x; +} + +if (!hasKind(x, "B")) { + let c = x; +} +else { + let d = x; +} + +//// [stringLiteralTypesAsTags01.js] +"A" | "B"; +function hasKind(entity, kind) { + return kind === is; +} +var x = { + kind: "A", + a: 100 +}; +if (hasKind(x, "A")) { + var a = x; +} +else { + var b = x; +} +if (!hasKind(x, "B")) { + var c = x; +} +else { + var d = x; +} diff --git a/tests/baselines/reference/stringLiteralTypesInUnionTypes01.errors.txt b/tests/baselines/reference/stringLiteralTypesInUnionTypes01.errors.txt new file mode 100644 index 00000000000..fcc13629ceb --- /dev/null +++ b/tests/baselines/reference/stringLiteralTypesInUnionTypes01.errors.txt @@ -0,0 +1,59 @@ +tests/cases/conformance/types/stringLiteral/stringLiteralTypesInUnionTypes01.ts(2,9): error TS4081: Exported type alias 'T' has or is using private name ''. +tests/cases/conformance/types/stringLiteral/stringLiteralTypesInUnionTypes01.ts(2,10): error TS1110: Type expected. +tests/cases/conformance/types/stringLiteral/stringLiteralTypesInUnionTypes01.ts(2,10): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/types/stringLiteral/stringLiteralTypesInUnionTypes01.ts(2,18): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/types/stringLiteral/stringLiteralTypesInUnionTypes01.ts(2,26): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/types/stringLiteral/stringLiteralTypesInUnionTypes01.ts(4,7): error TS4025: Exported variable 'x' has or is using private name ''. +tests/cases/conformance/types/stringLiteral/stringLiteralTypesInUnionTypes01.ts(4,8): error TS1110: Type expected. +tests/cases/conformance/types/stringLiteral/stringLiteralTypesInUnionTypes01.ts(4,8): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/types/stringLiteral/stringLiteralTypesInUnionTypes01.ts(4,16): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/types/stringLiteral/stringLiteralTypesInUnionTypes01.ts(4,24): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/types/stringLiteral/stringLiteralTypesInUnionTypes01.ts(4,30): error TS1005: ',' expected. +tests/cases/conformance/types/stringLiteral/stringLiteralTypesInUnionTypes01.ts(4,32): error TS1134: Variable declaration expected. + + +==== tests/cases/conformance/types/stringLiteral/stringLiteralTypesInUnionTypes01.ts (12 errors) ==== + + type T = "foo" | "bar" | "baz"; + +!!! error TS4081: Exported type alias 'T' has or is using private name ''. + ~~~~~ +!!! error TS1110: Type expected. + ~~~~~ +!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + ~~~~~ +!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + ~~~~~ +!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + + var x: "foo" | "bar" | "baz" = "foo"; + +!!! error TS4025: Exported variable 'x' has or is using private name ''. + ~~~~~ +!!! error TS1110: Type expected. + ~~~~~ +!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + ~~~~~ +!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + ~~~~~ +!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + ~ +!!! error TS1005: ',' expected. + ~~~~~ +!!! error TS1134: Variable declaration expected. + var y: T = "bar"; + + if (x === "foo") { + let a = x; + } + else if (x !== "bar") { + let b = x || y; + } + else { + let c = x; + let d = y; + let e: (typeof x) | (typeof y) = c || d; + } + + x = y; + y = x; \ No newline at end of file diff --git a/tests/baselines/reference/stringLiteralTypesInUnionTypes01.js b/tests/baselines/reference/stringLiteralTypesInUnionTypes01.js new file mode 100644 index 00000000000..4eaaec42ceb --- /dev/null +++ b/tests/baselines/reference/stringLiteralTypesInUnionTypes01.js @@ -0,0 +1,40 @@ +//// [stringLiteralTypesInUnionTypes01.ts] + +type T = "foo" | "bar" | "baz"; + +var x: "foo" | "bar" | "baz" = "foo"; +var y: T = "bar"; + +if (x === "foo") { + let a = x; +} +else if (x !== "bar") { + let b = x || y; +} +else { + let c = x; + let d = y; + let e: (typeof x) | (typeof y) = c || d; +} + +x = y; +y = x; + +//// [stringLiteralTypesInUnionTypes01.js] +"foo" | "bar" | "baz"; +var x = "foo" | "bar" | "baz"; +"foo"; +var y = "bar"; +if (x === "foo") { + var a = x; +} +else if (x !== "bar") { + var b = x || y; +} +else { + var c = x; + var d = y; + var e = c || d; +} +x = y; +y = x; diff --git a/tests/baselines/reference/stringLiteralTypesInUnionTypes02.errors.txt b/tests/baselines/reference/stringLiteralTypesInUnionTypes02.errors.txt new file mode 100644 index 00000000000..dc8523051aa --- /dev/null +++ b/tests/baselines/reference/stringLiteralTypesInUnionTypes02.errors.txt @@ -0,0 +1,62 @@ +tests/cases/conformance/types/stringLiteral/stringLiteralTypesInUnionTypes02.ts(2,18): error TS4081: Exported type alias 'T' has or is using private name ''. +tests/cases/conformance/types/stringLiteral/stringLiteralTypesInUnionTypes02.ts(2,19): error TS1110: Type expected. +tests/cases/conformance/types/stringLiteral/stringLiteralTypesInUnionTypes02.ts(2,19): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/types/stringLiteral/stringLiteralTypesInUnionTypes02.ts(2,27): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/types/stringLiteral/stringLiteralTypesInUnionTypes02.ts(2,35): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/types/stringLiteral/stringLiteralTypesInUnionTypes02.ts(4,7): error TS4025: Exported variable 'x' has or is using private name ''. +tests/cases/conformance/types/stringLiteral/stringLiteralTypesInUnionTypes02.ts(4,8): error TS1110: Type expected. +tests/cases/conformance/types/stringLiteral/stringLiteralTypesInUnionTypes02.ts(4,8): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/types/stringLiteral/stringLiteralTypesInUnionTypes02.ts(4,16): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/types/stringLiteral/stringLiteralTypesInUnionTypes02.ts(4,24): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/types/stringLiteral/stringLiteralTypesInUnionTypes02.ts(4,32): error TS2304: Cannot find name 'string'. +tests/cases/conformance/types/stringLiteral/stringLiteralTypesInUnionTypes02.ts(4,39): error TS1005: ',' expected. +tests/cases/conformance/types/stringLiteral/stringLiteralTypesInUnionTypes02.ts(4,41): error TS1134: Variable declaration expected. + + +==== tests/cases/conformance/types/stringLiteral/stringLiteralTypesInUnionTypes02.ts (13 errors) ==== + + type T = string | "foo" | "bar" | "baz"; + +!!! error TS4081: Exported type alias 'T' has or is using private name ''. + ~~~~~ +!!! error TS1110: Type expected. + ~~~~~ +!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + ~~~~~ +!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + ~~~~~ +!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + + var x: "foo" | "bar" | "baz" | string = "foo"; + +!!! error TS4025: Exported variable 'x' has or is using private name ''. + ~~~~~ +!!! error TS1110: Type expected. + ~~~~~ +!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + ~~~~~ +!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + ~~~~~ +!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + ~~~~~~ +!!! error TS2304: Cannot find name 'string'. + ~ +!!! error TS1005: ',' expected. + ~~~~~ +!!! error TS1134: Variable declaration expected. + var y: T = "bar"; + + if (x === "foo") { + let a = x; + } + else if (x !== "bar") { + let b = x || y; + } + else { + let c = x; + let d = y; + let e: (typeof x) | (typeof y) = c || d; + } + + x = y; + y = x; \ No newline at end of file diff --git a/tests/baselines/reference/stringLiteralTypesInUnionTypes02.js b/tests/baselines/reference/stringLiteralTypesInUnionTypes02.js new file mode 100644 index 00000000000..19b309980f8 --- /dev/null +++ b/tests/baselines/reference/stringLiteralTypesInUnionTypes02.js @@ -0,0 +1,40 @@ +//// [stringLiteralTypesInUnionTypes02.ts] + +type T = string | "foo" | "bar" | "baz"; + +var x: "foo" | "bar" | "baz" | string = "foo"; +var y: T = "bar"; + +if (x === "foo") { + let a = x; +} +else if (x !== "bar") { + let b = x || y; +} +else { + let c = x; + let d = y; + let e: (typeof x) | (typeof y) = c || d; +} + +x = y; +y = x; + +//// [stringLiteralTypesInUnionTypes02.js] +"foo" | "bar" | "baz"; +var x = "foo" | "bar" | "baz" | string; +"foo"; +var y = "bar"; +if (x === "foo") { + var a = x; +} +else if (x !== "bar") { + var b = x || y; +} +else { + var c = x; + var d = y; + var e = c || d; +} +x = y; +y = x; diff --git a/tests/baselines/reference/stringLiteralTypesInUnionTypes03.errors.txt b/tests/baselines/reference/stringLiteralTypesInUnionTypes03.errors.txt new file mode 100644 index 00000000000..1595c625322 --- /dev/null +++ b/tests/baselines/reference/stringLiteralTypesInUnionTypes03.errors.txt @@ -0,0 +1,50 @@ +tests/cases/conformance/types/stringLiteral/stringLiteralTypesInUnionTypes03.ts(2,18): error TS4081: Exported type alias 'T' has or is using private name ''. +tests/cases/conformance/types/stringLiteral/stringLiteralTypesInUnionTypes03.ts(2,19): error TS1110: Type expected. +tests/cases/conformance/types/stringLiteral/stringLiteralTypesInUnionTypes03.ts(2,19): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/types/stringLiteral/stringLiteralTypesInUnionTypes03.ts(2,27): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/types/stringLiteral/stringLiteralTypesInUnionTypes03.ts(4,7): error TS4025: Exported variable 'x' has or is using private name ''. +tests/cases/conformance/types/stringLiteral/stringLiteralTypesInUnionTypes03.ts(4,8): error TS1110: Type expected. +tests/cases/conformance/types/stringLiteral/stringLiteralTypesInUnionTypes03.ts(4,8): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/types/stringLiteral/stringLiteralTypesInUnionTypes03.ts(4,16): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/types/stringLiteral/stringLiteralTypesInUnionTypes03.ts(4,24): error TS2304: Cannot find name 'number'. + + +==== tests/cases/conformance/types/stringLiteral/stringLiteralTypesInUnionTypes03.ts (9 errors) ==== + + type T = number | "foo" | "bar"; + +!!! error TS4081: Exported type alias 'T' has or is using private name ''. + ~~~~~ +!!! error TS1110: Type expected. + ~~~~~ +!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + ~~~~~ +!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + + var x: "foo" | "bar" | number; + +!!! error TS4025: Exported variable 'x' has or is using private name ''. + ~~~~~ +!!! error TS1110: Type expected. + ~~~~~ +!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + ~~~~~ +!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + ~~~~~~ +!!! error TS2304: Cannot find name 'number'. + var y: T = "bar"; + + if (x === "foo") { + let a = x; + } + else if (x !== "bar") { + let b = x || y; + } + else { + let c = x; + let d = y; + let e: (typeof x) | (typeof y) = c || d; + } + + x = y; + y = x; \ No newline at end of file diff --git a/tests/baselines/reference/stringLiteralTypesInUnionTypes03.js b/tests/baselines/reference/stringLiteralTypesInUnionTypes03.js new file mode 100644 index 00000000000..7705848be2b --- /dev/null +++ b/tests/baselines/reference/stringLiteralTypesInUnionTypes03.js @@ -0,0 +1,39 @@ +//// [stringLiteralTypesInUnionTypes03.ts] + +type T = number | "foo" | "bar"; + +var x: "foo" | "bar" | number; +var y: T = "bar"; + +if (x === "foo") { + let a = x; +} +else if (x !== "bar") { + let b = x || y; +} +else { + let c = x; + let d = y; + let e: (typeof x) | (typeof y) = c || d; +} + +x = y; +y = x; + +//// [stringLiteralTypesInUnionTypes03.js] +"foo" | "bar"; +var x = "foo" | "bar" | number; +var y = "bar"; +if (x === "foo") { + var a = x; +} +else if (x !== "bar") { + var b = x || y; +} +else { + var c = x; + var d = y; + var e = c || d; +} +x = y; +y = x; diff --git a/tests/baselines/reference/stringLiteralTypesInUnionTypes04.errors.txt b/tests/baselines/reference/stringLiteralTypesInUnionTypes04.errors.txt new file mode 100644 index 00000000000..66d3e215237 --- /dev/null +++ b/tests/baselines/reference/stringLiteralTypesInUnionTypes04.errors.txt @@ -0,0 +1,52 @@ +tests/cases/conformance/types/stringLiteral/stringLiteralTypesInUnionTypes04.ts(2,9): error TS4081: Exported type alias 'T' has or is using private name ''. +tests/cases/conformance/types/stringLiteral/stringLiteralTypesInUnionTypes04.ts(2,10): error TS1110: Type expected. +tests/cases/conformance/types/stringLiteral/stringLiteralTypesInUnionTypes04.ts(2,10): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/types/stringLiteral/stringLiteralTypesInUnionTypes04.ts(2,15): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + + +==== tests/cases/conformance/types/stringLiteral/stringLiteralTypesInUnionTypes04.ts (4 errors) ==== + + type T = "" | "foo"; + +!!! error TS4081: Exported type alias 'T' has or is using private name ''. + ~~ +!!! error TS1110: Type expected. + ~~ +!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + ~~~~~ +!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + + let x: T = ""; + let y: T = "foo"; + + if (x === "") { + let a = x; + } + + if (x !== "") { + let b = x; + } + + if (x == "") { + let c = x; + } + + if (x != "") { + let d = x; + } + + if (x) { + let e = x; + } + + if (!x) { + let f = x; + } + + if (!!x) { + let g = x; + } + + if (!!!x) { + let h = x; + } \ No newline at end of file diff --git a/tests/baselines/reference/stringLiteralTypesInUnionTypes04.js b/tests/baselines/reference/stringLiteralTypesInUnionTypes04.js new file mode 100644 index 00000000000..5817d16ec8f --- /dev/null +++ b/tests/baselines/reference/stringLiteralTypesInUnionTypes04.js @@ -0,0 +1,67 @@ +//// [stringLiteralTypesInUnionTypes04.ts] + +type T = "" | "foo"; + +let x: T = ""; +let y: T = "foo"; + +if (x === "") { + let a = x; +} + +if (x !== "") { + let b = x; +} + +if (x == "") { + let c = x; +} + +if (x != "") { + let d = x; +} + +if (x) { + let e = x; +} + +if (!x) { + let f = x; +} + +if (!!x) { + let g = x; +} + +if (!!!x) { + let h = x; +} + +//// [stringLiteralTypesInUnionTypes04.js] +"" | "foo"; +var x = ""; +var y = "foo"; +if (x === "") { + var a = x; +} +if (x !== "") { + var b = x; +} +if (x == "") { + var c = x; +} +if (x != "") { + var d = x; +} +if (x) { + var e = x; +} +if (!x) { + var f = x; +} +if (!!x) { + var g = x; +} +if (!!!x) { + var h = x; +} diff --git a/tests/baselines/reference/stringLiteralTypesInVariableDeclarations01.errors.txt b/tests/baselines/reference/stringLiteralTypesInVariableDeclarations01.errors.txt new file mode 100644 index 00000000000..14233db44cd --- /dev/null +++ b/tests/baselines/reference/stringLiteralTypesInVariableDeclarations01.errors.txt @@ -0,0 +1,81 @@ +tests/cases/conformance/types/stringLiteral/stringLiteralTypesInVariableDeclarations01.ts(2,7): error TS4025: Exported variable 'a' has or is using private name ''. +tests/cases/conformance/types/stringLiteral/stringLiteralTypesInVariableDeclarations01.ts(2,8): error TS1110: Type expected. +tests/cases/conformance/types/stringLiteral/stringLiteralTypesInVariableDeclarations01.ts(3,7): error TS4025: Exported variable 'b' has or is using private name ''. +tests/cases/conformance/types/stringLiteral/stringLiteralTypesInVariableDeclarations01.ts(3,8): error TS1110: Type expected. +tests/cases/conformance/types/stringLiteral/stringLiteralTypesInVariableDeclarations01.ts(4,7): error TS4025: Exported variable 'c' has or is using private name ''. +tests/cases/conformance/types/stringLiteral/stringLiteralTypesInVariableDeclarations01.ts(4,8): error TS1110: Type expected. +tests/cases/conformance/types/stringLiteral/stringLiteralTypesInVariableDeclarations01.ts(5,9): error TS4025: Exported variable 'd' has or is using private name ''. +tests/cases/conformance/types/stringLiteral/stringLiteralTypesInVariableDeclarations01.ts(5,10): error TS1110: Type expected. +tests/cases/conformance/types/stringLiteral/stringLiteralTypesInVariableDeclarations01.ts(11,7): error TS4025: Exported variable 'e' has or is using private name ''. +tests/cases/conformance/types/stringLiteral/stringLiteralTypesInVariableDeclarations01.ts(11,8): error TS1110: Type expected. +tests/cases/conformance/types/stringLiteral/stringLiteralTypesInVariableDeclarations01.ts(11,8): error TS2364: Invalid left-hand side of assignment expression. +tests/cases/conformance/types/stringLiteral/stringLiteralTypesInVariableDeclarations01.ts(12,7): error TS4025: Exported variable 'f' has or is using private name ''. +tests/cases/conformance/types/stringLiteral/stringLiteralTypesInVariableDeclarations01.ts(12,8): error TS1110: Type expected. +tests/cases/conformance/types/stringLiteral/stringLiteralTypesInVariableDeclarations01.ts(12,8): error TS2364: Invalid left-hand side of assignment expression. +tests/cases/conformance/types/stringLiteral/stringLiteralTypesInVariableDeclarations01.ts(13,7): error TS4025: Exported variable 'g' has or is using private name ''. +tests/cases/conformance/types/stringLiteral/stringLiteralTypesInVariableDeclarations01.ts(13,8): error TS1110: Type expected. +tests/cases/conformance/types/stringLiteral/stringLiteralTypesInVariableDeclarations01.ts(13,8): error TS2364: Invalid left-hand side of assignment expression. +tests/cases/conformance/types/stringLiteral/stringLiteralTypesInVariableDeclarations01.ts(14,9): error TS4025: Exported variable 'h' has or is using private name ''. +tests/cases/conformance/types/stringLiteral/stringLiteralTypesInVariableDeclarations01.ts(14,10): error TS1110: Type expected. +tests/cases/conformance/types/stringLiteral/stringLiteralTypesInVariableDeclarations01.ts(14,10): error TS2364: Invalid left-hand side of assignment expression. + + +==== tests/cases/conformance/types/stringLiteral/stringLiteralTypesInVariableDeclarations01.ts (20 errors) ==== + + let a: ""; + +!!! error TS4025: Exported variable 'a' has or is using private name ''. + ~~ +!!! error TS1110: Type expected. + var b: "foo"; + +!!! error TS4025: Exported variable 'b' has or is using private name ''. + ~~~~~ +!!! error TS1110: Type expected. + let c: "bar"; + +!!! error TS4025: Exported variable 'c' has or is using private name ''. + ~~~~~ +!!! error TS1110: Type expected. + const d: "baz"; + +!!! error TS4025: Exported variable 'd' has or is using private name ''. + ~~~~~ +!!! error TS1110: Type expected. + + a = ""; + b = "foo"; + c = "bar"; + + let e: "" = ""; + +!!! error TS4025: Exported variable 'e' has or is using private name ''. + ~~ +!!! error TS1110: Type expected. + ~~ +!!! error TS2364: Invalid left-hand side of assignment expression. + var f: "foo" = "foo"; + +!!! error TS4025: Exported variable 'f' has or is using private name ''. + ~~~~~ +!!! error TS1110: Type expected. + ~~~~~ +!!! error TS2364: Invalid left-hand side of assignment expression. + let g: "bar" = "bar"; + +!!! error TS4025: Exported variable 'g' has or is using private name ''. + ~~~~~ +!!! error TS1110: Type expected. + ~~~~~ +!!! error TS2364: Invalid left-hand side of assignment expression. + const h: "baz" = "baz"; + +!!! error TS4025: Exported variable 'h' has or is using private name ''. + ~~~~~ +!!! error TS1110: Type expected. + ~~~~~ +!!! error TS2364: Invalid left-hand side of assignment expression. + + e = ""; + f = "foo"; + g = "bar"; \ No newline at end of file diff --git a/tests/baselines/reference/stringLiteralTypesInVariableDeclarations01.js b/tests/baselines/reference/stringLiteralTypesInVariableDeclarations01.js new file mode 100644 index 00000000000..4aae2a2438a --- /dev/null +++ b/tests/baselines/reference/stringLiteralTypesInVariableDeclarations01.js @@ -0,0 +1,35 @@ +//// [stringLiteralTypesInVariableDeclarations01.ts] + +let a: ""; +var b: "foo"; +let c: "bar"; +const d: "baz"; + +a = ""; +b = "foo"; +c = "bar"; + +let e: "" = ""; +var f: "foo" = "foo"; +let g: "bar" = "bar"; +const h: "baz" = "baz"; + +e = ""; +f = "foo"; +g = "bar"; + +//// [stringLiteralTypesInVariableDeclarations01.js] +var a = ""; +var b = "foo"; +var c = "bar"; +var d = "baz"; +a = ""; +b = "foo"; +c = "bar"; +var e = "" = ""; +var f = "foo" = "foo"; +var g = "bar" = "bar"; +var h = "baz" = "baz"; +e = ""; +f = "foo"; +g = "bar"; diff --git a/tests/baselines/reference/stringLiteralTypesOverloads01.errors.txt b/tests/baselines/reference/stringLiteralTypesOverloads01.errors.txt new file mode 100644 index 00000000000..e41de718dfa --- /dev/null +++ b/tests/baselines/reference/stringLiteralTypesOverloads01.errors.txt @@ -0,0 +1,146 @@ +tests/cases/conformance/types/stringLiteral/stringLiteralTypesOverloads01.ts(2,21): error TS4081: Exported type alias 'PrimitiveName' has or is using private name ''. +tests/cases/conformance/types/stringLiteral/stringLiteralTypesOverloads01.ts(2,22): error TS1110: Type expected. +tests/cases/conformance/types/stringLiteral/stringLiteralTypesOverloads01.ts(2,22): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/types/stringLiteral/stringLiteralTypesOverloads01.ts(2,33): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/types/stringLiteral/stringLiteralTypesOverloads01.ts(2,44): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/types/stringLiteral/stringLiteralTypesOverloads01.ts(4,10): error TS2382: Specialized overload signature is not assignable to any non-specialized signature. +tests/cases/conformance/types/stringLiteral/stringLiteralTypesOverloads01.ts(5,10): error TS2382: Specialized overload signature is not assignable to any non-specialized signature. +tests/cases/conformance/types/stringLiteral/stringLiteralTypesOverloads01.ts(6,10): error TS2382: Specialized overload signature is not assignable to any non-specialized signature. +tests/cases/conformance/types/stringLiteral/stringLiteralTypesOverloads01.ts(7,10): error TS2382: Specialized overload signature is not assignable to any non-specialized signature. +tests/cases/conformance/types/stringLiteral/stringLiteralTypesOverloads01.ts(7,28): error TS2371: A parameter initializer is only allowed in a function or constructor implementation. +tests/cases/conformance/types/stringLiteral/stringLiteralTypesOverloads01.ts(7,41): error TS1005: '=' expected. +tests/cases/conformance/types/stringLiteral/stringLiteralTypesOverloads01.ts(8,10): error TS2382: Specialized overload signature is not assignable to any non-specialized signature. +tests/cases/conformance/types/stringLiteral/stringLiteralTypesOverloads01.ts(8,28): error TS2371: A parameter initializer is only allowed in a function or constructor implementation. +tests/cases/conformance/types/stringLiteral/stringLiteralTypesOverloads01.ts(8,41): error TS1005: '=' expected. +tests/cases/conformance/types/stringLiteral/stringLiteralTypesOverloads01.ts(9,10): error TS2382: Specialized overload signature is not assignable to any non-specialized signature. +tests/cases/conformance/types/stringLiteral/stringLiteralTypesOverloads01.ts(9,28): error TS2371: A parameter initializer is only allowed in a function or constructor implementation. +tests/cases/conformance/types/stringLiteral/stringLiteralTypesOverloads01.ts(9,40): error TS1005: '=' expected. +tests/cases/conformance/types/stringLiteral/stringLiteralTypesOverloads01.ts(10,10): error TS2382: Specialized overload signature is not assignable to any non-specialized signature. +tests/cases/conformance/types/stringLiteral/stringLiteralTypesOverloads01.ts(10,28): error TS2371: A parameter initializer is only allowed in a function or constructor implementation. +tests/cases/conformance/types/stringLiteral/stringLiteralTypesOverloads01.ts(10,40): error TS1005: '=' expected. +tests/cases/conformance/types/stringLiteral/stringLiteralTypesOverloads01.ts(11,10): error TS2354: No best common type exists among return expressions. +tests/cases/conformance/types/stringLiteral/stringLiteralTypesOverloads01.ts(32,14): error TS4025: Exported variable 'string' has or is using private name ''. +tests/cases/conformance/types/stringLiteral/stringLiteralTypesOverloads01.ts(32,15): error TS1110: Type expected. +tests/cases/conformance/types/stringLiteral/stringLiteralTypesOverloads01.ts(32,15): error TS2364: Invalid left-hand side of assignment expression. +tests/cases/conformance/types/stringLiteral/stringLiteralTypesOverloads01.ts(33,14): error TS4025: Exported variable 'number' has or is using private name ''. +tests/cases/conformance/types/stringLiteral/stringLiteralTypesOverloads01.ts(33,15): error TS1110: Type expected. +tests/cases/conformance/types/stringLiteral/stringLiteralTypesOverloads01.ts(33,15): error TS2364: Invalid left-hand side of assignment expression. +tests/cases/conformance/types/stringLiteral/stringLiteralTypesOverloads01.ts(34,15): error TS4025: Exported variable 'boolean' has or is using private name ''. +tests/cases/conformance/types/stringLiteral/stringLiteralTypesOverloads01.ts(34,16): error TS1110: Type expected. +tests/cases/conformance/types/stringLiteral/stringLiteralTypesOverloads01.ts(34,16): error TS2364: Invalid left-hand side of assignment expression. + + +==== tests/cases/conformance/types/stringLiteral/stringLiteralTypesOverloads01.ts (30 errors) ==== + + type PrimitiveName = 'string' | 'number' | 'boolean'; + +!!! error TS4081: Exported type alias 'PrimitiveName' has or is using private name ''. + ~~~~~~~~ +!!! error TS1110: Type expected. + ~~~~~~~~ +!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + ~~~~~~~~ +!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + ~~~~~~~~~ +!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + + function getFalsyPrimitive(x: "string"): string; + ~~~~~~~~~~~~~~~~~ +!!! error TS2382: Specialized overload signature is not assignable to any non-specialized signature. + function getFalsyPrimitive(x: "number"): number; + ~~~~~~~~~~~~~~~~~ +!!! error TS2382: Specialized overload signature is not assignable to any non-specialized signature. + function getFalsyPrimitive(x: "boolean"): boolean; + ~~~~~~~~~~~~~~~~~ +!!! error TS2382: Specialized overload signature is not assignable to any non-specialized signature. + function getFalsyPrimitive(x: "boolean" | "string"): boolean | string; + ~~~~~~~~~~~~~~~~~ +!!! error TS2382: Specialized overload signature is not assignable to any non-specialized signature. + ~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2371: A parameter initializer is only allowed in a function or constructor implementation. + ~ +!!! error TS1005: '=' expected. + function getFalsyPrimitive(x: "boolean" | "number"): boolean | number; + ~~~~~~~~~~~~~~~~~ +!!! error TS2382: Specialized overload signature is not assignable to any non-specialized signature. + ~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2371: A parameter initializer is only allowed in a function or constructor implementation. + ~ +!!! error TS1005: '=' expected. + function getFalsyPrimitive(x: "number" | "string"): number | string; + ~~~~~~~~~~~~~~~~~ +!!! error TS2382: Specialized overload signature is not assignable to any non-specialized signature. + ~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2371: A parameter initializer is only allowed in a function or constructor implementation. + ~ +!!! error TS1005: '=' expected. + function getFalsyPrimitive(x: "number" | "string" | "boolean"): number | string | boolean; + ~~~~~~~~~~~~~~~~~ +!!! error TS2382: Specialized overload signature is not assignable to any non-specialized signature. + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2371: A parameter initializer is only allowed in a function or constructor implementation. + ~ +!!! error TS1005: '=' expected. + function getFalsyPrimitive(x: PrimitiveName) { + ~~~~~~~~~~~~~~~~~ +!!! error TS2354: No best common type exists among return expressions. + if (x === "string") { + return ""; + } + if (x === "number") { + return 0; + } + if (x === "boolean") { + return false; + } + + // Should be unreachable. + throw "Invalid value"; + } + + namespace Consts1 { + const EMPTY_STRING = getFalsyPrimitive("string"); + const ZERO = getFalsyPrimitive('number'); + const FALSE = getFalsyPrimitive("boolean"); + } + + const string: "string" = "string" + +!!! error TS4025: Exported variable 'string' has or is using private name ''. + ~~~~~~~~ +!!! error TS1110: Type expected. + ~~~~~~~~ +!!! error TS2364: Invalid left-hand side of assignment expression. + const number: "number" = "number" + +!!! error TS4025: Exported variable 'number' has or is using private name ''. + ~~~~~~~~ +!!! error TS1110: Type expected. + ~~~~~~~~ +!!! error TS2364: Invalid left-hand side of assignment expression. + const boolean: "boolean" = "boolean" + +!!! error TS4025: Exported variable 'boolean' has or is using private name ''. + ~~~~~~~~~ +!!! error TS1110: Type expected. + ~~~~~~~~~ +!!! error TS2364: Invalid left-hand side of assignment expression. + + const stringOrNumber = string || number; + const stringOrBoolean = string || boolean; + const booleanOrNumber = number || boolean; + const stringOrBooleanOrNumber = stringOrBoolean || number; + + namespace Consts2 { + const EMPTY_STRING = getFalsyPrimitive(string); + const ZERO = getFalsyPrimitive(number); + const FALSE = getFalsyPrimitive(boolean); + + const a = getFalsyPrimitive(stringOrNumber); + const b = getFalsyPrimitive(stringOrBoolean); + const c = getFalsyPrimitive(booleanOrNumber); + const d = getFalsyPrimitive(stringOrBooleanOrNumber); + } + + + \ No newline at end of file diff --git a/tests/baselines/reference/stringLiteralTypesOverloads01.js b/tests/baselines/reference/stringLiteralTypesOverloads01.js new file mode 100644 index 00000000000..a001f02c9c9 --- /dev/null +++ b/tests/baselines/reference/stringLiteralTypesOverloads01.js @@ -0,0 +1,93 @@ +//// [stringLiteralTypesOverloads01.ts] + +type PrimitiveName = 'string' | 'number' | 'boolean'; + +function getFalsyPrimitive(x: "string"): string; +function getFalsyPrimitive(x: "number"): number; +function getFalsyPrimitive(x: "boolean"): boolean; +function getFalsyPrimitive(x: "boolean" | "string"): boolean | string; +function getFalsyPrimitive(x: "boolean" | "number"): boolean | number; +function getFalsyPrimitive(x: "number" | "string"): number | string; +function getFalsyPrimitive(x: "number" | "string" | "boolean"): number | string | boolean; +function getFalsyPrimitive(x: PrimitiveName) { + if (x === "string") { + return ""; + } + if (x === "number") { + return 0; + } + if (x === "boolean") { + return false; + } + + // Should be unreachable. + throw "Invalid value"; +} + +namespace Consts1 { + const EMPTY_STRING = getFalsyPrimitive("string"); + const ZERO = getFalsyPrimitive('number'); + const FALSE = getFalsyPrimitive("boolean"); +} + +const string: "string" = "string" +const number: "number" = "number" +const boolean: "boolean" = "boolean" + +const stringOrNumber = string || number; +const stringOrBoolean = string || boolean; +const booleanOrNumber = number || boolean; +const stringOrBooleanOrNumber = stringOrBoolean || number; + +namespace Consts2 { + const EMPTY_STRING = getFalsyPrimitive(string); + const ZERO = getFalsyPrimitive(number); + const FALSE = getFalsyPrimitive(boolean); + + const a = getFalsyPrimitive(stringOrNumber); + const b = getFalsyPrimitive(stringOrBoolean); + const c = getFalsyPrimitive(booleanOrNumber); + const d = getFalsyPrimitive(stringOrBooleanOrNumber); +} + + + + +//// [stringLiteralTypesOverloads01.js] +'string' | 'number' | 'boolean'; +function getFalsyPrimitive(x) { + if (x === "string") { + return ""; + } + if (x === "number") { + return 0; + } + if (x === "boolean") { + return false; + } + // Should be unreachable. + throw "Invalid value"; +} +var Consts1; +(function (Consts1) { + var EMPTY_STRING = getFalsyPrimitive("string"); + var ZERO = getFalsyPrimitive('number'); + var FALSE = getFalsyPrimitive("boolean"); +})(Consts1 || (Consts1 = {})); +var string = "string" = "string"; +var number = "number" = "number"; +var boolean = "boolean" = "boolean"; +var stringOrNumber = string || number; +var stringOrBoolean = string || boolean; +var booleanOrNumber = number || boolean; +var stringOrBooleanOrNumber = stringOrBoolean || number; +var Consts2; +(function (Consts2) { + var EMPTY_STRING = getFalsyPrimitive(string); + var ZERO = getFalsyPrimitive(number); + var FALSE = getFalsyPrimitive(boolean); + var a = getFalsyPrimitive(stringOrNumber); + var b = getFalsyPrimitive(stringOrBoolean); + var c = getFalsyPrimitive(booleanOrNumber); + var d = getFalsyPrimitive(stringOrBooleanOrNumber); +})(Consts2 || (Consts2 = {})); diff --git a/tests/baselines/reference/stringLiteralTypesOverloads02.errors.txt b/tests/baselines/reference/stringLiteralTypesOverloads02.errors.txt new file mode 100644 index 00000000000..ff1e212c071 --- /dev/null +++ b/tests/baselines/reference/stringLiteralTypesOverloads02.errors.txt @@ -0,0 +1,129 @@ +tests/cases/conformance/types/stringLiteral/stringLiteralTypesOverloads02.ts(2,10): error TS2382: Specialized overload signature is not assignable to any non-specialized signature. +tests/cases/conformance/types/stringLiteral/stringLiteralTypesOverloads02.ts(3,10): error TS2382: Specialized overload signature is not assignable to any non-specialized signature. +tests/cases/conformance/types/stringLiteral/stringLiteralTypesOverloads02.ts(4,10): error TS2382: Specialized overload signature is not assignable to any non-specialized signature. +tests/cases/conformance/types/stringLiteral/stringLiteralTypesOverloads02.ts(5,10): error TS2382: Specialized overload signature is not assignable to any non-specialized signature. +tests/cases/conformance/types/stringLiteral/stringLiteralTypesOverloads02.ts(5,28): error TS2371: A parameter initializer is only allowed in a function or constructor implementation. +tests/cases/conformance/types/stringLiteral/stringLiteralTypesOverloads02.ts(5,41): error TS1005: '=' expected. +tests/cases/conformance/types/stringLiteral/stringLiteralTypesOverloads02.ts(6,10): error TS2382: Specialized overload signature is not assignable to any non-specialized signature. +tests/cases/conformance/types/stringLiteral/stringLiteralTypesOverloads02.ts(6,28): error TS2371: A parameter initializer is only allowed in a function or constructor implementation. +tests/cases/conformance/types/stringLiteral/stringLiteralTypesOverloads02.ts(6,41): error TS1005: '=' expected. +tests/cases/conformance/types/stringLiteral/stringLiteralTypesOverloads02.ts(7,10): error TS2382: Specialized overload signature is not assignable to any non-specialized signature. +tests/cases/conformance/types/stringLiteral/stringLiteralTypesOverloads02.ts(7,28): error TS2371: A parameter initializer is only allowed in a function or constructor implementation. +tests/cases/conformance/types/stringLiteral/stringLiteralTypesOverloads02.ts(7,40): error TS1005: '=' expected. +tests/cases/conformance/types/stringLiteral/stringLiteralTypesOverloads02.ts(8,10): error TS2382: Specialized overload signature is not assignable to any non-specialized signature. +tests/cases/conformance/types/stringLiteral/stringLiteralTypesOverloads02.ts(8,28): error TS2371: A parameter initializer is only allowed in a function or constructor implementation. +tests/cases/conformance/types/stringLiteral/stringLiteralTypesOverloads02.ts(8,40): error TS1005: '=' expected. +tests/cases/conformance/types/stringLiteral/stringLiteralTypesOverloads02.ts(9,10): error TS2354: No best common type exists among return expressions. +tests/cases/conformance/types/stringLiteral/stringLiteralTypesOverloads02.ts(30,14): error TS4025: Exported variable 'string' has or is using private name ''. +tests/cases/conformance/types/stringLiteral/stringLiteralTypesOverloads02.ts(30,15): error TS1110: Type expected. +tests/cases/conformance/types/stringLiteral/stringLiteralTypesOverloads02.ts(30,15): error TS2364: Invalid left-hand side of assignment expression. +tests/cases/conformance/types/stringLiteral/stringLiteralTypesOverloads02.ts(31,14): error TS4025: Exported variable 'number' has or is using private name ''. +tests/cases/conformance/types/stringLiteral/stringLiteralTypesOverloads02.ts(31,15): error TS1110: Type expected. +tests/cases/conformance/types/stringLiteral/stringLiteralTypesOverloads02.ts(31,15): error TS2364: Invalid left-hand side of assignment expression. +tests/cases/conformance/types/stringLiteral/stringLiteralTypesOverloads02.ts(32,15): error TS4025: Exported variable 'boolean' has or is using private name ''. +tests/cases/conformance/types/stringLiteral/stringLiteralTypesOverloads02.ts(32,16): error TS1110: Type expected. +tests/cases/conformance/types/stringLiteral/stringLiteralTypesOverloads02.ts(32,16): error TS2364: Invalid left-hand side of assignment expression. + + +==== tests/cases/conformance/types/stringLiteral/stringLiteralTypesOverloads02.ts (25 errors) ==== + + function getFalsyPrimitive(x: "string"): string; + ~~~~~~~~~~~~~~~~~ +!!! error TS2382: Specialized overload signature is not assignable to any non-specialized signature. + function getFalsyPrimitive(x: "number"): number; + ~~~~~~~~~~~~~~~~~ +!!! error TS2382: Specialized overload signature is not assignable to any non-specialized signature. + function getFalsyPrimitive(x: "boolean"): boolean; + ~~~~~~~~~~~~~~~~~ +!!! error TS2382: Specialized overload signature is not assignable to any non-specialized signature. + function getFalsyPrimitive(x: "boolean" | "string"): boolean | string; + ~~~~~~~~~~~~~~~~~ +!!! error TS2382: Specialized overload signature is not assignable to any non-specialized signature. + ~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2371: A parameter initializer is only allowed in a function or constructor implementation. + ~ +!!! error TS1005: '=' expected. + function getFalsyPrimitive(x: "boolean" | "number"): boolean | number; + ~~~~~~~~~~~~~~~~~ +!!! error TS2382: Specialized overload signature is not assignable to any non-specialized signature. + ~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2371: A parameter initializer is only allowed in a function or constructor implementation. + ~ +!!! error TS1005: '=' expected. + function getFalsyPrimitive(x: "number" | "string"): number | string; + ~~~~~~~~~~~~~~~~~ +!!! error TS2382: Specialized overload signature is not assignable to any non-specialized signature. + ~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2371: A parameter initializer is only allowed in a function or constructor implementation. + ~ +!!! error TS1005: '=' expected. + function getFalsyPrimitive(x: "number" | "string" | "boolean"): number | string | boolean; + ~~~~~~~~~~~~~~~~~ +!!! error TS2382: Specialized overload signature is not assignable to any non-specialized signature. + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2371: A parameter initializer is only allowed in a function or constructor implementation. + ~ +!!! error TS1005: '=' expected. + function getFalsyPrimitive(x: string) { + ~~~~~~~~~~~~~~~~~ +!!! error TS2354: No best common type exists among return expressions. + if (x === "string") { + return ""; + } + if (x === "number") { + return 0; + } + if (x === "boolean") { + return false; + } + + // Should be unreachable. + throw "Invalid value"; + } + + namespace Consts1 { + const EMPTY_STRING = getFalsyPrimitive("string"); + const ZERO = getFalsyPrimitive('number'); + const FALSE = getFalsyPrimitive("boolean"); + } + + const string: "string" = "string" + +!!! error TS4025: Exported variable 'string' has or is using private name ''. + ~~~~~~~~ +!!! error TS1110: Type expected. + ~~~~~~~~ +!!! error TS2364: Invalid left-hand side of assignment expression. + const number: "number" = "number" + +!!! error TS4025: Exported variable 'number' has or is using private name ''. + ~~~~~~~~ +!!! error TS1110: Type expected. + ~~~~~~~~ +!!! error TS2364: Invalid left-hand side of assignment expression. + const boolean: "boolean" = "boolean" + +!!! error TS4025: Exported variable 'boolean' has or is using private name ''. + ~~~~~~~~~ +!!! error TS1110: Type expected. + ~~~~~~~~~ +!!! error TS2364: Invalid left-hand side of assignment expression. + + const stringOrNumber = string || number; + const stringOrBoolean = string || boolean; + const booleanOrNumber = number || boolean; + const stringOrBooleanOrNumber = stringOrBoolean || number; + + namespace Consts2 { + const EMPTY_STRING = getFalsyPrimitive(string); + const ZERO = getFalsyPrimitive(number); + const FALSE = getFalsyPrimitive(boolean); + + const a = getFalsyPrimitive(stringOrNumber); + const b = getFalsyPrimitive(stringOrBoolean); + const c = getFalsyPrimitive(booleanOrNumber); + const d = getFalsyPrimitive(stringOrBooleanOrNumber); + } + + + \ No newline at end of file diff --git a/tests/baselines/reference/stringLiteralTypesOverloads02.js b/tests/baselines/reference/stringLiteralTypesOverloads02.js new file mode 100644 index 00000000000..ae38acebb95 --- /dev/null +++ b/tests/baselines/reference/stringLiteralTypesOverloads02.js @@ -0,0 +1,90 @@ +//// [stringLiteralTypesOverloads02.ts] + +function getFalsyPrimitive(x: "string"): string; +function getFalsyPrimitive(x: "number"): number; +function getFalsyPrimitive(x: "boolean"): boolean; +function getFalsyPrimitive(x: "boolean" | "string"): boolean | string; +function getFalsyPrimitive(x: "boolean" | "number"): boolean | number; +function getFalsyPrimitive(x: "number" | "string"): number | string; +function getFalsyPrimitive(x: "number" | "string" | "boolean"): number | string | boolean; +function getFalsyPrimitive(x: string) { + if (x === "string") { + return ""; + } + if (x === "number") { + return 0; + } + if (x === "boolean") { + return false; + } + + // Should be unreachable. + throw "Invalid value"; +} + +namespace Consts1 { + const EMPTY_STRING = getFalsyPrimitive("string"); + const ZERO = getFalsyPrimitive('number'); + const FALSE = getFalsyPrimitive("boolean"); +} + +const string: "string" = "string" +const number: "number" = "number" +const boolean: "boolean" = "boolean" + +const stringOrNumber = string || number; +const stringOrBoolean = string || boolean; +const booleanOrNumber = number || boolean; +const stringOrBooleanOrNumber = stringOrBoolean || number; + +namespace Consts2 { + const EMPTY_STRING = getFalsyPrimitive(string); + const ZERO = getFalsyPrimitive(number); + const FALSE = getFalsyPrimitive(boolean); + + const a = getFalsyPrimitive(stringOrNumber); + const b = getFalsyPrimitive(stringOrBoolean); + const c = getFalsyPrimitive(booleanOrNumber); + const d = getFalsyPrimitive(stringOrBooleanOrNumber); +} + + + + +//// [stringLiteralTypesOverloads02.js] +function getFalsyPrimitive(x) { + if (x === "string") { + return ""; + } + if (x === "number") { + return 0; + } + if (x === "boolean") { + return false; + } + // Should be unreachable. + throw "Invalid value"; +} +var Consts1; +(function (Consts1) { + var EMPTY_STRING = getFalsyPrimitive("string"); + var ZERO = getFalsyPrimitive('number'); + var FALSE = getFalsyPrimitive("boolean"); +})(Consts1 || (Consts1 = {})); +var string = "string" = "string"; +var number = "number" = "number"; +var boolean = "boolean" = "boolean"; +var stringOrNumber = string || number; +var stringOrBoolean = string || boolean; +var booleanOrNumber = number || boolean; +var stringOrBooleanOrNumber = stringOrBoolean || number; +var Consts2; +(function (Consts2) { + var EMPTY_STRING = getFalsyPrimitive(string); + var ZERO = getFalsyPrimitive(number); + var FALSE = getFalsyPrimitive(boolean); + var a = getFalsyPrimitive(stringOrNumber); + var b = getFalsyPrimitive(stringOrBoolean); + var c = getFalsyPrimitive(booleanOrNumber); + var d = getFalsyPrimitive(stringOrBooleanOrNumber); +})(Consts2 || (Consts2 = {})); diff --git a/tests/baselines/reference/stringLiteralTypesTypePredicates01.errors.txt b/tests/baselines/reference/stringLiteralTypesTypePredicates01.errors.txt new file mode 100644 index 00000000000..a4cc525cdd2 --- /dev/null +++ b/tests/baselines/reference/stringLiteralTypesTypePredicates01.errors.txt @@ -0,0 +1,57 @@ +tests/cases/conformance/types/stringLiteral/stringLiteralTypesTypePredicates01.ts(2,12): error TS4081: Exported type alias 'Kind' has or is using private name ''. +tests/cases/conformance/types/stringLiteral/stringLiteralTypesTypePredicates01.ts(2,13): error TS1110: Type expected. +tests/cases/conformance/types/stringLiteral/stringLiteralTypesTypePredicates01.ts(2,13): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/types/stringLiteral/stringLiteralTypesTypePredicates01.ts(2,19): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/types/stringLiteral/stringLiteralTypesTypePredicates01.ts(4,10): error TS2391: Function implementation is missing or not immediately following the declaration. +tests/cases/conformance/types/stringLiteral/stringLiteralTypesTypePredicates01.ts(4,46): error TS4060: Return type of exported function has or is using private name ''. +tests/cases/conformance/types/stringLiteral/stringLiteralTypesTypePredicates01.ts(4,47): error TS1110: Type expected. +tests/cases/conformance/types/stringLiteral/stringLiteralTypesTypePredicates01.ts(5,10): error TS2391: Function implementation is missing or not immediately following the declaration. +tests/cases/conformance/types/stringLiteral/stringLiteralTypesTypePredicates01.ts(5,46): error TS4060: Return type of exported function has or is using private name ''. +tests/cases/conformance/types/stringLiteral/stringLiteralTypesTypePredicates01.ts(5,47): error TS1110: Type expected. + + +==== tests/cases/conformance/types/stringLiteral/stringLiteralTypesTypePredicates01.ts (10 errors) ==== + + type Kind = "A" | "B" + +!!! error TS4081: Exported type alias 'Kind' has or is using private name ''. + ~~~ +!!! error TS1110: Type expected. + ~~~ +!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + ~~~ +!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + + function kindIs(kind: Kind, is: "A"): kind is "A"; + ~~~~~~ +!!! error TS2391: Function implementation is missing or not immediately following the declaration. + +!!! error TS4060: Return type of exported function has or is using private name ''. + ~~~ +!!! error TS1110: Type expected. + function kindIs(kind: Kind, is: "B"): kind is "B"; + ~~~~~~ +!!! error TS2391: Function implementation is missing or not immediately following the declaration. + +!!! error TS4060: Return type of exported function has or is using private name ''. + ~~~ +!!! error TS1110: Type expected. + function kindIs(kind: Kind, is: Kind): boolean { + return kind === is; + } + + var x: Kind = "A"; + + if (kindIs(x, "A")) { + let a = x; + } + else { + let b = x; + } + + if (!kindIs(x, "B")) { + let c = x; + } + else { + let d = x; + } \ No newline at end of file diff --git a/tests/baselines/reference/stringLiteralTypesTypePredicates01.js b/tests/baselines/reference/stringLiteralTypesTypePredicates01.js new file mode 100644 index 00000000000..791caed9b31 --- /dev/null +++ b/tests/baselines/reference/stringLiteralTypesTypePredicates01.js @@ -0,0 +1,46 @@ +//// [stringLiteralTypesTypePredicates01.ts] + +type Kind = "A" | "B" + +function kindIs(kind: Kind, is: "A"): kind is "A"; +function kindIs(kind: Kind, is: "B"): kind is "B"; +function kindIs(kind: Kind, is: Kind): boolean { + return kind === is; +} + +var x: Kind = "A"; + +if (kindIs(x, "A")) { + let a = x; +} +else { + let b = x; +} + +if (!kindIs(x, "B")) { + let c = x; +} +else { + let d = x; +} + +//// [stringLiteralTypesTypePredicates01.js] +"A" | "B"; +"A"; +"B"; +function kindIs(kind, is) { + return kind === is; +} +var x = "A"; +if (kindIs(x, "A")) { + var a = x; +} +else { + var b = x; +} +if (!kindIs(x, "B")) { + var c = x; +} +else { + var d = x; +} diff --git a/tests/baselines/reference/typeArgumentsWithStringLiteralTypes01.errors.txt b/tests/baselines/reference/typeArgumentsWithStringLiteralTypes01.errors.txt new file mode 100644 index 00000000000..626d0e3d6f4 --- /dev/null +++ b/tests/baselines/reference/typeArgumentsWithStringLiteralTypes01.errors.txt @@ -0,0 +1,325 @@ +tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(4,18): error TS2382: Specialized overload signature is not assignable to any non-specialized signature. +tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(4,48): error TS4060: Return type of exported function has or is using private name ''. +tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(4,49): error TS1110: Type expected. +tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(5,18): error TS2382: Specialized overload signature is not assignable to any non-specialized signature. +tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(5,39): error TS2371: A parameter initializer is only allowed in a function or constructor implementation. +tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(5,52): error TS1005: '=' expected. +tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(5,63): error TS4060: Return type of exported function has or is using private name ''. +tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(5,64): error TS1110: Type expected. +tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(5,64): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(5,74): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(37,25): error TS2345: Argument of type 'string' is not assignable to parameter of type '"Hello"'. +tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(38,25): error TS2345: Argument of type 'string' is not assignable to parameter of type '"Hello"'. +tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(39,25): error TS2345: Argument of type 'string' is not assignable to parameter of type '"Hello"'. +tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(40,25): error TS2345: Argument of type 'string' is not assignable to parameter of type '"Hello"'. +tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(41,25): error TS2345: Argument of type 'string' is not assignable to parameter of type '"Hello"'. +tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(44,30): error TS2345: Argument of type 'string' is not assignable to parameter of type '"Hello"'. +tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(45,30): error TS2345: Argument of type 'string' is not assignable to parameter of type '"Hello"'. +tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(46,30): error TS2345: Argument of type 'string' is not assignable to parameter of type '"Hello"'. +tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(47,30): error TS2345: Argument of type 'string' is not assignable to parameter of type '"Hello"'. +tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(48,30): error TS2345: Argument of type 'string' is not assignable to parameter of type '"Hello"'. +tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(54,20): error TS2365: Operator '<' cannot be applied to types '(x: T, y: T) => T' and 'string'. +tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(54,20): error TS2365: Operator '>' cannot be applied to types 'boolean' and 'string'. +tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(55,20): error TS2365: Operator '<' cannot be applied to types '(x: T, y: T) => T' and 'string'. +tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(55,20): error TS2365: Operator '>' cannot be applied to types 'boolean' and 'string'. +tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(56,20): error TS2365: Operator '<' cannot be applied to types '(x: T, y: U) => T | U' and 'string'. +tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(56,34): error TS1134: Variable declaration expected. +tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(57,20): error TS2365: Operator '<' cannot be applied to types '(x: T, y: U) => T | U' and 'string'. +tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(57,34): error TS1134: Variable declaration expected. +tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(58,20): error TS2365: Operator '<' cannot be applied to types '(...args: T[]) => T' and 'string'. +tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(58,20): error TS2365: Operator '>' cannot be applied to types 'boolean' and 'string'. +tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(61,26): error TS2345: Argument of type 'boolean' is not assignable to parameter of type 'string'. +tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(62,26): error TS2345: Argument of type 'boolean' is not assignable to parameter of type 'string'. +tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(63,26): error TS2345: Argument of type 'boolean' is not assignable to parameter of type 'string'. +tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(64,26): error TS2345: Argument of type 'boolean' is not assignable to parameter of type 'string'. +tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(65,26): error TS2345: Argument of type 'boolean' is not assignable to parameter of type 'string'. +tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(68,25): error TS2345: Argument of type 'boolean' is not assignable to parameter of type '"Hello"'. +tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(69,25): error TS2345: Argument of type 'boolean' is not assignable to parameter of type '"Hello"'. +tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(70,25): error TS2345: Argument of type 'boolean' is not assignable to parameter of type '"Hello"'. +tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(71,25): error TS2345: Argument of type 'boolean' is not assignable to parameter of type '"Hello"'. +tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(72,25): error TS2345: Argument of type 'boolean' is not assignable to parameter of type '"Hello"'. +tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(75,30): error TS2345: Argument of type 'boolean' is not assignable to parameter of type '"Hello"'. +tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(76,30): error TS2345: Argument of type 'boolean' is not assignable to parameter of type '"Hello"'. +tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(77,30): error TS2345: Argument of type 'boolean' is not assignable to parameter of type '"Hello"'. +tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(78,30): error TS2345: Argument of type 'boolean' is not assignable to parameter of type '"Hello"'. +tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(79,30): error TS2345: Argument of type 'boolean' is not assignable to parameter of type '"Hello"'. +tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(86,20): error TS2365: Operator '<' cannot be applied to types '(x: T, y: U) => T | U' and 'string'. +tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(86,34): error TS1134: Variable declaration expected. +tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(87,20): error TS2365: Operator '<' cannot be applied to types '(x: T, y: U) => T | U' and 'string'. +tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(87,34): error TS1134: Variable declaration expected. +tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(88,20): error TS2365: Operator '<' cannot be applied to types '(x: T, y: U) => T | U' and 'string'. +tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(88,34): error TS1134: Variable declaration expected. +tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(89,20): error TS2365: Operator '<' cannot be applied to types '(x: T, y: U) => T | U' and 'string'. +tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(89,34): error TS1134: Variable declaration expected. +tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(90,20): error TS2365: Operator '<' cannot be applied to types '(...args: T[]) => T' and 'string'. +tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(90,20): error TS2447: The '|' operator is not allowed for boolean types. Consider using '||' instead. +tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(93,26): error TS2345: Argument of type 'boolean' is not assignable to parameter of type 'string'. +tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(94,26): error TS2345: Argument of type 'boolean' is not assignable to parameter of type 'string'. +tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(95,26): error TS2345: Argument of type 'boolean' is not assignable to parameter of type 'string'. +tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(96,26): error TS2345: Argument of type 'boolean' is not assignable to parameter of type 'string'. +tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(97,26): error TS2345: Argument of type 'number' is not assignable to parameter of type 'string'. +tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(100,25): error TS2345: Argument of type 'boolean' is not assignable to parameter of type '"Hello"'. +tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(101,25): error TS2345: Argument of type 'boolean' is not assignable to parameter of type '"Hello"'. +tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(102,25): error TS2345: Argument of type 'boolean' is not assignable to parameter of type '"Hello"'. +tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(103,25): error TS2345: Argument of type 'boolean' is not assignable to parameter of type '"Hello"'. +tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(104,25): error TS2345: Argument of type 'number' is not assignable to parameter of type '"Hello"'. +tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(107,30): error TS2345: Argument of type 'boolean' is not assignable to parameter of type '"Hello"'. +tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(108,30): error TS2345: Argument of type 'boolean' is not assignable to parameter of type '"Hello"'. +tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(109,30): error TS2345: Argument of type 'boolean' is not assignable to parameter of type '"Hello"'. +tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(110,30): error TS2345: Argument of type 'boolean' is not assignable to parameter of type '"Hello"'. +tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(111,30): error TS2345: Argument of type 'number' is not assignable to parameter of type '"Hello"'. + + +==== tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts (70 errors) ==== + + declare function randBool(): boolean; + declare function takeReturnString(str: string): string; + declare function takeReturnHello(str: "Hello"): "Hello"; + ~~~~~~~~~~~~~~~ +!!! error TS2382: Specialized overload signature is not assignable to any non-specialized signature. + +!!! error TS4060: Return type of exported function has or is using private name ''. + ~~~~~~~ +!!! error TS1110: Type expected. + declare function takeReturnHelloWorld(str: "Hello" | "World"): "Hello" | "World"; + ~~~~~~~~~~~~~~~~~~~~ +!!! error TS2382: Specialized overload signature is not assignable to any non-specialized signature. + ~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2371: A parameter initializer is only allowed in a function or constructor implementation. + ~ +!!! error TS1005: '=' expected. + +!!! error TS4060: Return type of exported function has or is using private name ''. + ~~~~~~~ +!!! error TS1110: Type expected. + ~~~~~~~ +!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + ~~~~~~~ +!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + + function fun1(x: T, y: T) { + return randBool() ? x : y; + } + + function fun2(x: T, y: U) { + return randBool() ? x : y; + } + + function fun3(...args: T[]): T { + return args[+randBool()]; + } + + namespace n1 { + // The following should all come back as strings. + // They should be assignable to/from something of a type 'string'. + // They should not be assignable to either "Hello" or "World". + export let a = fun1("Hello", "World"); + export let b = fun1("Hello", "Hello"); + export let c = fun2("Hello", "World"); + export let d = fun2("Hello", "Hello"); + export let e = fun3("Hello", "Hello", "World", "Foo"); + + // Should be valid + a = takeReturnString(a); + b = takeReturnString(b); + c = takeReturnString(c); + d = takeReturnString(d); + e = takeReturnString(e); + + // Passing these as arguments should cause an error. + a = takeReturnHello(a); + ~ +!!! error TS2345: Argument of type 'string' is not assignable to parameter of type '"Hello"'. + b = takeReturnHello(b); + ~ +!!! error TS2345: Argument of type 'string' is not assignable to parameter of type '"Hello"'. + c = takeReturnHello(c); + ~ +!!! error TS2345: Argument of type 'string' is not assignable to parameter of type '"Hello"'. + d = takeReturnHello(d); + ~ +!!! error TS2345: Argument of type 'string' is not assignable to parameter of type '"Hello"'. + e = takeReturnHello(e); + ~ +!!! error TS2345: Argument of type 'string' is not assignable to parameter of type '"Hello"'. + + // Passing these as arguments should cause an error. + a = takeReturnHelloWorld(a); + ~ +!!! error TS2345: Argument of type 'string' is not assignable to parameter of type '"Hello"'. + b = takeReturnHelloWorld(b); + ~ +!!! error TS2345: Argument of type 'string' is not assignable to parameter of type '"Hello"'. + c = takeReturnHelloWorld(c); + ~ +!!! error TS2345: Argument of type 'string' is not assignable to parameter of type '"Hello"'. + d = takeReturnHelloWorld(d); + ~ +!!! error TS2345: Argument of type 'string' is not assignable to parameter of type '"Hello"'. + e = takeReturnHelloWorld(e); + ~ +!!! error TS2345: Argument of type 'string' is not assignable to parameter of type '"Hello"'. + } + + namespace n2 { + // The following (regardless of errors) should come back typed + // as "Hello" (or "Hello" | "Hello"). + export let a = fun1<"Hello">("Hello", "Hello"); + ~~~~~~~~~~~~ +!!! error TS2365: Operator '<' cannot be applied to types '(x: T, y: T) => T' and 'string'. + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2365: Operator '>' cannot be applied to types 'boolean' and 'string'. + export let b = fun1<"Hello">("Hello", "World"); + ~~~~~~~~~~~~ +!!! error TS2365: Operator '<' cannot be applied to types '(x: T, y: T) => T' and 'string'. + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2365: Operator '>' cannot be applied to types 'boolean' and 'string'. + export let c = fun2<"Hello", "Hello">("Hello", "Hello"); + ~~~~~~~~~~~~ +!!! error TS2365: Operator '<' cannot be applied to types '(x: T, y: U) => T | U' and 'string'. + ~~~~~~~ +!!! error TS1134: Variable declaration expected. + export let d = fun2<"Hello", "Hello">("Hello", "World"); + ~~~~~~~~~~~~ +!!! error TS2365: Operator '<' cannot be applied to types '(x: T, y: U) => T | U' and 'string'. + ~~~~~~~ +!!! error TS1134: Variable declaration expected. + export let e = fun3<"Hello">("Hello", "World"); + ~~~~~~~~~~~~ +!!! error TS2365: Operator '<' cannot be applied to types '(...args: T[]) => T' and 'string'. + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2365: Operator '>' cannot be applied to types 'boolean' and 'string'. + + // Assignment from the returned value should cause an error. + a = takeReturnString(a); + ~ +!!! error TS2345: Argument of type 'boolean' is not assignable to parameter of type 'string'. + b = takeReturnString(b); + ~ +!!! error TS2345: Argument of type 'boolean' is not assignable to parameter of type 'string'. + c = takeReturnString(c); + ~ +!!! error TS2345: Argument of type 'boolean' is not assignable to parameter of type 'string'. + d = takeReturnString(d); + ~ +!!! error TS2345: Argument of type 'boolean' is not assignable to parameter of type 'string'. + e = takeReturnString(e); + ~ +!!! error TS2345: Argument of type 'boolean' is not assignable to parameter of type 'string'. + + // Should be valid + a = takeReturnHello(a); + ~ +!!! error TS2345: Argument of type 'boolean' is not assignable to parameter of type '"Hello"'. + b = takeReturnHello(b); + ~ +!!! error TS2345: Argument of type 'boolean' is not assignable to parameter of type '"Hello"'. + c = takeReturnHello(c); + ~ +!!! error TS2345: Argument of type 'boolean' is not assignable to parameter of type '"Hello"'. + d = takeReturnHello(d); + ~ +!!! error TS2345: Argument of type 'boolean' is not assignable to parameter of type '"Hello"'. + e = takeReturnHello(e); + ~ +!!! error TS2345: Argument of type 'boolean' is not assignable to parameter of type '"Hello"'. + + // Assignment from the returned value should cause an error. + a = takeReturnHelloWorld(a); + ~ +!!! error TS2345: Argument of type 'boolean' is not assignable to parameter of type '"Hello"'. + b = takeReturnHelloWorld(b); + ~ +!!! error TS2345: Argument of type 'boolean' is not assignable to parameter of type '"Hello"'. + c = takeReturnHelloWorld(c); + ~ +!!! error TS2345: Argument of type 'boolean' is not assignable to parameter of type '"Hello"'. + d = takeReturnHelloWorld(d); + ~ +!!! error TS2345: Argument of type 'boolean' is not assignable to parameter of type '"Hello"'. + e = takeReturnHelloWorld(e); + ~ +!!! error TS2345: Argument of type 'boolean' is not assignable to parameter of type '"Hello"'. + } + + + namespace n3 { + // The following (regardless of errors) should come back typed + // as "Hello" | "World" (or "World" | "Hello"). + export let a = fun2<"Hello", "World">("Hello", "World"); + ~~~~~~~~~~~~ +!!! error TS2365: Operator '<' cannot be applied to types '(x: T, y: U) => T | U' and 'string'. + ~~~~~~~ +!!! error TS1134: Variable declaration expected. + export let b = fun2<"Hello", "World">("World", "Hello"); + ~~~~~~~~~~~~ +!!! error TS2365: Operator '<' cannot be applied to types '(x: T, y: U) => T | U' and 'string'. + ~~~~~~~ +!!! error TS1134: Variable declaration expected. + export let c = fun2<"World", "Hello">("Hello", "Hello"); + ~~~~~~~~~~~~ +!!! error TS2365: Operator '<' cannot be applied to types '(x: T, y: U) => T | U' and 'string'. + ~~~~~~~ +!!! error TS1134: Variable declaration expected. + export let d = fun2<"World", "Hello">("World", "World"); + ~~~~~~~~~~~~ +!!! error TS2365: Operator '<' cannot be applied to types '(x: T, y: U) => T | U' and 'string'. + ~~~~~~~ +!!! error TS1134: Variable declaration expected. + export let e = fun3<"Hello" | "World">("Hello", "World"); + ~~~~~~~~~~~~ +!!! error TS2365: Operator '<' cannot be applied to types '(...args: T[]) => T' and 'string'. + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2447: The '|' operator is not allowed for boolean types. Consider using '||' instead. + + // Assignment from the returned value should cause an error. + a = takeReturnString(a); + ~ +!!! error TS2345: Argument of type 'boolean' is not assignable to parameter of type 'string'. + b = takeReturnString(b); + ~ +!!! error TS2345: Argument of type 'boolean' is not assignable to parameter of type 'string'. + c = takeReturnString(c); + ~ +!!! error TS2345: Argument of type 'boolean' is not assignable to parameter of type 'string'. + d = takeReturnString(d); + ~ +!!! error TS2345: Argument of type 'boolean' is not assignable to parameter of type 'string'. + e = takeReturnString(e); + ~ +!!! error TS2345: Argument of type 'number' is not assignable to parameter of type 'string'. + + // Passing these as arguments should cause an error. + a = takeReturnHello(a); + ~ +!!! error TS2345: Argument of type 'boolean' is not assignable to parameter of type '"Hello"'. + b = takeReturnHello(b); + ~ +!!! error TS2345: Argument of type 'boolean' is not assignable to parameter of type '"Hello"'. + c = takeReturnHello(c); + ~ +!!! error TS2345: Argument of type 'boolean' is not assignable to parameter of type '"Hello"'. + d = takeReturnHello(d); + ~ +!!! error TS2345: Argument of type 'boolean' is not assignable to parameter of type '"Hello"'. + e = takeReturnHello(e); + ~ +!!! error TS2345: Argument of type 'number' is not assignable to parameter of type '"Hello"'. + + // Both should be valid. + a = takeReturnHelloWorld(a); + ~ +!!! error TS2345: Argument of type 'boolean' is not assignable to parameter of type '"Hello"'. + b = takeReturnHelloWorld(b); + ~ +!!! error TS2345: Argument of type 'boolean' is not assignable to parameter of type '"Hello"'. + c = takeReturnHelloWorld(c); + ~ +!!! error TS2345: Argument of type 'boolean' is not assignable to parameter of type '"Hello"'. + d = takeReturnHelloWorld(d); + ~ +!!! error TS2345: Argument of type 'boolean' is not assignable to parameter of type '"Hello"'. + e = takeReturnHelloWorld(e); + ~ +!!! error TS2345: Argument of type 'number' is not assignable to parameter of type '"Hello"'. + } \ No newline at end of file diff --git a/tests/baselines/reference/typeArgumentsWithStringLiteralTypes01.js b/tests/baselines/reference/typeArgumentsWithStringLiteralTypes01.js new file mode 100644 index 00000000000..15c7cf5ef2d --- /dev/null +++ b/tests/baselines/reference/typeArgumentsWithStringLiteralTypes01.js @@ -0,0 +1,221 @@ +//// [typeArgumentsWithStringLiteralTypes01.ts] + +declare function randBool(): boolean; +declare function takeReturnString(str: string): string; +declare function takeReturnHello(str: "Hello"): "Hello"; +declare function takeReturnHelloWorld(str: "Hello" | "World"): "Hello" | "World"; + +function fun1(x: T, y: T) { + return randBool() ? x : y; +} + +function fun2(x: T, y: U) { + return randBool() ? x : y; +} + +function fun3(...args: T[]): T { + return args[+randBool()]; +} + +namespace n1 { + // The following should all come back as strings. + // They should be assignable to/from something of a type 'string'. + // They should not be assignable to either "Hello" or "World". + export let a = fun1("Hello", "World"); + export let b = fun1("Hello", "Hello"); + export let c = fun2("Hello", "World"); + export let d = fun2("Hello", "Hello"); + export let e = fun3("Hello", "Hello", "World", "Foo"); + + // Should be valid + a = takeReturnString(a); + b = takeReturnString(b); + c = takeReturnString(c); + d = takeReturnString(d); + e = takeReturnString(e); + + // Passing these as arguments should cause an error. + a = takeReturnHello(a); + b = takeReturnHello(b); + c = takeReturnHello(c); + d = takeReturnHello(d); + e = takeReturnHello(e); + + // Passing these as arguments should cause an error. + a = takeReturnHelloWorld(a); + b = takeReturnHelloWorld(b); + c = takeReturnHelloWorld(c); + d = takeReturnHelloWorld(d); + e = takeReturnHelloWorld(e); +} + +namespace n2 { + // The following (regardless of errors) should come back typed + // as "Hello" (or "Hello" | "Hello"). + export let a = fun1<"Hello">("Hello", "Hello"); + export let b = fun1<"Hello">("Hello", "World"); + export let c = fun2<"Hello", "Hello">("Hello", "Hello"); + export let d = fun2<"Hello", "Hello">("Hello", "World"); + export let e = fun3<"Hello">("Hello", "World"); + + // Assignment from the returned value should cause an error. + a = takeReturnString(a); + b = takeReturnString(b); + c = takeReturnString(c); + d = takeReturnString(d); + e = takeReturnString(e); + + // Should be valid + a = takeReturnHello(a); + b = takeReturnHello(b); + c = takeReturnHello(c); + d = takeReturnHello(d); + e = takeReturnHello(e); + + // Assignment from the returned value should cause an error. + a = takeReturnHelloWorld(a); + b = takeReturnHelloWorld(b); + c = takeReturnHelloWorld(c); + d = takeReturnHelloWorld(d); + e = takeReturnHelloWorld(e); +} + + +namespace n3 { + // The following (regardless of errors) should come back typed + // as "Hello" | "World" (or "World" | "Hello"). + export let a = fun2<"Hello", "World">("Hello", "World"); + export let b = fun2<"Hello", "World">("World", "Hello"); + export let c = fun2<"World", "Hello">("Hello", "Hello"); + export let d = fun2<"World", "Hello">("World", "World"); + export let e = fun3<"Hello" | "World">("Hello", "World"); + + // Assignment from the returned value should cause an error. + a = takeReturnString(a); + b = takeReturnString(b); + c = takeReturnString(c); + d = takeReturnString(d); + e = takeReturnString(e); + + // Passing these as arguments should cause an error. + a = takeReturnHello(a); + b = takeReturnHello(b); + c = takeReturnHello(c); + d = takeReturnHello(d); + e = takeReturnHello(e); + + // Both should be valid. + a = takeReturnHelloWorld(a); + b = takeReturnHelloWorld(b); + c = takeReturnHelloWorld(c); + d = takeReturnHelloWorld(d); + e = takeReturnHelloWorld(e); +} + +//// [typeArgumentsWithStringLiteralTypes01.js] +"Hello"; +"Hello" | "World"; +function fun1(x, y) { + return randBool() ? x : y; +} +function fun2(x, y) { + return randBool() ? x : y; +} +function fun3() { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i - 0] = arguments[_i]; + } + return args[+randBool()]; +} +var n1; +(function (n1) { + // The following should all come back as strings. + // They should be assignable to/from something of a type 'string'. + // They should not be assignable to either "Hello" or "World". + n1.a = fun1("Hello", "World"); + n1.b = fun1("Hello", "Hello"); + n1.c = fun2("Hello", "World"); + n1.d = fun2("Hello", "Hello"); + n1.e = fun3("Hello", "Hello", "World", "Foo"); + // Should be valid + n1.a = takeReturnString(n1.a); + n1.b = takeReturnString(n1.b); + n1.c = takeReturnString(n1.c); + n1.d = takeReturnString(n1.d); + n1.e = takeReturnString(n1.e); + // Passing these as arguments should cause an error. + n1.a = takeReturnHello(n1.a); + n1.b = takeReturnHello(n1.b); + n1.c = takeReturnHello(n1.c); + n1.d = takeReturnHello(n1.d); + n1.e = takeReturnHello(n1.e); + // Passing these as arguments should cause an error. + n1.a = takeReturnHelloWorld(n1.a); + n1.b = takeReturnHelloWorld(n1.b); + n1.c = takeReturnHelloWorld(n1.c); + n1.d = takeReturnHelloWorld(n1.d); + n1.e = takeReturnHelloWorld(n1.e); +})(n1 || (n1 = {})); +var n2; +(function (n2) { + // The following (regardless of errors) should come back typed + // as "Hello" (or "Hello" | "Hello"). + n2.a = fun1 < "Hello" > ("Hello", "Hello"); + n2.b = fun1 < "Hello" > ("Hello", "World"); + n2.c = fun2 < "Hello"; + "Hello" > ("Hello", "Hello"); + n2.d = fun2 < "Hello"; + "Hello" > ("Hello", "World"); + n2.e = fun3 < "Hello" > ("Hello", "World"); + // Assignment from the returned value should cause an error. + n2.a = takeReturnString(n2.a); + n2.b = takeReturnString(n2.b); + n2.c = takeReturnString(n2.c); + n2.d = takeReturnString(n2.d); + n2.e = takeReturnString(n2.e); + // Should be valid + n2.a = takeReturnHello(n2.a); + n2.b = takeReturnHello(n2.b); + n2.c = takeReturnHello(n2.c); + n2.d = takeReturnHello(n2.d); + n2.e = takeReturnHello(n2.e); + // Assignment from the returned value should cause an error. + n2.a = takeReturnHelloWorld(n2.a); + n2.b = takeReturnHelloWorld(n2.b); + n2.c = takeReturnHelloWorld(n2.c); + n2.d = takeReturnHelloWorld(n2.d); + n2.e = takeReturnHelloWorld(n2.e); +})(n2 || (n2 = {})); +var n3; +(function (n3) { + // The following (regardless of errors) should come back typed + // as "Hello" | "World" (or "World" | "Hello"). + n3.a = fun2 < "Hello"; + "World" > ("Hello", "World"); + n3.b = fun2 < "Hello"; + "World" > ("World", "Hello"); + n3.c = fun2 < "World"; + "Hello" > ("Hello", "Hello"); + n3.d = fun2 < "World"; + "Hello" > ("World", "World"); + n3.e = fun3 < "Hello" | "World" > ("Hello", "World"); + // Assignment from the returned value should cause an error. + n3.a = takeReturnString(n3.a); + n3.b = takeReturnString(n3.b); + n3.c = takeReturnString(n3.c); + n3.d = takeReturnString(n3.d); + n3.e = takeReturnString(n3.e); + // Passing these as arguments should cause an error. + n3.a = takeReturnHello(n3.a); + n3.b = takeReturnHello(n3.b); + n3.c = takeReturnHello(n3.c); + n3.d = takeReturnHello(n3.d); + n3.e = takeReturnHello(n3.e); + // Both should be valid. + n3.a = takeReturnHelloWorld(n3.a); + n3.b = takeReturnHelloWorld(n3.b); + n3.c = takeReturnHelloWorld(n3.c); + n3.d = takeReturnHelloWorld(n3.d); + n3.e = takeReturnHelloWorld(n3.e); +})(n3 || (n3 = {})); From 191be4f8fea8f176c7abffeeb1346f2bfe436fc8 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Thu, 1 Oct 2015 15:55:36 -0700 Subject: [PATCH 020/227] Make string literals valid constituent types nodes in the parser. --- src/compiler/parser.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 23fb846c0b4..769415dd94b 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -1969,9 +1969,7 @@ namespace ts { function parseParameterType(): TypeNode { if (parseOptional(SyntaxKind.ColonToken)) { - return token === SyntaxKind.StringLiteral - ? parseLiteralNode(/*internName*/ true) - : parseType(); + return parseType(); } return undefined; @@ -2359,6 +2357,8 @@ namespace ts { // If these are followed by a dot, then parse these out as a dotted type reference instead. let node = tryParse(parseKeywordAndNoDot); return node || parseTypeReferenceOrTypePredicate(); + case SyntaxKind.StringLiteral: + return parseLiteralNode(/*internName*/ true) case SyntaxKind.VoidKeyword: return parseTokenNode(); case SyntaxKind.TypeOfKeyword: From 84786d82c14e3fae0f86d22e6fc635ecbac9dab8 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Thu, 1 Oct 2015 16:33:08 -0700 Subject: [PATCH 021/227] Accepted baselines. --- ...overy_IncompleteMemberVariable1.errors.txt | 34 ----- ...ErrorRecovery_IncompleteMemberVariable1.js | 1 - ...Recovery_IncompleteMemberVariable1.symbols | 67 ++++++++++ ...orRecovery_IncompleteMemberVariable1.types | 78 ++++++++++++ .../reference/stringLiteralType.errors.txt | 12 -- .../baselines/reference/stringLiteralType.js | 2 +- .../reference/stringLiteralType.symbols | 16 +++ .../reference/stringLiteralType.types | 16 +++ .../stringLiteralTypesAsTags01.errors.txt | 32 +---- .../reference/stringLiteralTypesAsTags01.js | 20 ++- ...tringLiteralTypesInUnionTypes01.errors.txt | 48 ++----- .../stringLiteralTypesInUnionTypes01.js | 10 +- ...tringLiteralTypesInUnionTypes02.errors.txt | 62 --------- .../stringLiteralTypesInUnionTypes02.js | 10 +- .../stringLiteralTypesInUnionTypes02.symbols | 52 ++++++++ .../stringLiteralTypesInUnionTypes02.types | 62 +++++++++ ...tringLiteralTypesInUnionTypes03.errors.txt | 40 ++---- .../stringLiteralTypesInUnionTypes03.js | 9 +- ...tringLiteralTypesInUnionTypes04.errors.txt | 24 ++-- .../stringLiteralTypesInUnionTypes04.js | 7 +- ...alTypesInVariableDeclarations01.errors.txt | 97 ++++++-------- ...ingLiteralTypesInVariableDeclarations01.js | 27 ++-- .../stringLiteralTypesOverloads01.errors.txt | 98 ++------------- .../stringLiteralTypesOverloads01.js | 29 ++++- .../stringLiteralTypesOverloads02.errors.txt | 83 ++---------- .../stringLiteralTypesOverloads02.js | 27 +++- ...ingLiteralTypesTypePredicates01.errors.txt | 39 ++---- .../stringLiteralTypesTypePredicates01.js | 10 +- ...gumentsWithStringLiteralTypes01.errors.txt | 119 +++++++++--------- .../typeArgumentsWithStringLiteralTypes01.js | 33 ++++- 30 files changed, 609 insertions(+), 555 deletions(-) delete mode 100644 tests/baselines/reference/parserErrorRecovery_IncompleteMemberVariable1.errors.txt create mode 100644 tests/baselines/reference/parserErrorRecovery_IncompleteMemberVariable1.symbols create mode 100644 tests/baselines/reference/parserErrorRecovery_IncompleteMemberVariable1.types delete mode 100644 tests/baselines/reference/stringLiteralType.errors.txt create mode 100644 tests/baselines/reference/stringLiteralType.symbols create mode 100644 tests/baselines/reference/stringLiteralType.types delete mode 100644 tests/baselines/reference/stringLiteralTypesInUnionTypes02.errors.txt create mode 100644 tests/baselines/reference/stringLiteralTypesInUnionTypes02.symbols create mode 100644 tests/baselines/reference/stringLiteralTypesInUnionTypes02.types diff --git a/tests/baselines/reference/parserErrorRecovery_IncompleteMemberVariable1.errors.txt b/tests/baselines/reference/parserErrorRecovery_IncompleteMemberVariable1.errors.txt deleted file mode 100644 index 707e68c2c45..00000000000 --- a/tests/baselines/reference/parserErrorRecovery_IncompleteMemberVariable1.errors.txt +++ /dev/null @@ -1,34 +0,0 @@ -tests/cases/conformance/parser/ecmascript5/ErrorRecovery/IncompleteMemberVariables/parserErrorRecovery_IncompleteMemberVariable1.ts(12,21): error TS1110: Type expected. - - -==== tests/cases/conformance/parser/ecmascript5/ErrorRecovery/IncompleteMemberVariables/parserErrorRecovery_IncompleteMemberVariable1.ts (1 errors) ==== - // Interface - interface IPoint { - getDist(): number; - } - - // Module - module Shapes { - - // Class - export class Point implements IPoint { - - public con: "hello"; - ~~~~~~~ -!!! error TS1110: Type expected. - // Constructor - constructor (public x: number, public y: number) { } - - // Instance member - getDist() { return Math.sqrt(this.x * this.x + this.y * this.y); } - - // Static member - static origin = new Point(0, 0); - } - - } - - // Local variables - var p: IPoint = new Shapes.Point(3, 4); - var dist = p.getDist(); - \ No newline at end of file diff --git a/tests/baselines/reference/parserErrorRecovery_IncompleteMemberVariable1.js b/tests/baselines/reference/parserErrorRecovery_IncompleteMemberVariable1.js index ae2509c3f49..8055cd9d494 100644 --- a/tests/baselines/reference/parserErrorRecovery_IncompleteMemberVariable1.js +++ b/tests/baselines/reference/parserErrorRecovery_IncompleteMemberVariable1.js @@ -38,7 +38,6 @@ var Shapes; function Point(x, y) { this.x = x; this.y = y; - this.con = "hello"; } // Instance member Point.prototype.getDist = function () { return Math.sqrt(this.x * this.x + this.y * this.y); }; diff --git a/tests/baselines/reference/parserErrorRecovery_IncompleteMemberVariable1.symbols b/tests/baselines/reference/parserErrorRecovery_IncompleteMemberVariable1.symbols new file mode 100644 index 00000000000..db9cefbf642 --- /dev/null +++ b/tests/baselines/reference/parserErrorRecovery_IncompleteMemberVariable1.symbols @@ -0,0 +1,67 @@ +=== tests/cases/conformance/parser/ecmascript5/ErrorRecovery/IncompleteMemberVariables/parserErrorRecovery_IncompleteMemberVariable1.ts === +// Interface +interface IPoint { +>IPoint : Symbol(IPoint, Decl(parserErrorRecovery_IncompleteMemberVariable1.ts, 0, 0)) + + getDist(): number; +>getDist : Symbol(getDist, Decl(parserErrorRecovery_IncompleteMemberVariable1.ts, 1, 18)) +} + +// Module +module Shapes { +>Shapes : Symbol(Shapes, Decl(parserErrorRecovery_IncompleteMemberVariable1.ts, 3, 1)) + + // Class + export class Point implements IPoint { +>Point : Symbol(Point, Decl(parserErrorRecovery_IncompleteMemberVariable1.ts, 6, 15)) +>IPoint : Symbol(IPoint, Decl(parserErrorRecovery_IncompleteMemberVariable1.ts, 0, 0)) + + public con: "hello"; +>con : Symbol(con, Decl(parserErrorRecovery_IncompleteMemberVariable1.ts, 9, 42)) + + // Constructor + constructor (public x: number, public y: number) { } +>x : Symbol(x, Decl(parserErrorRecovery_IncompleteMemberVariable1.ts, 13, 21)) +>y : Symbol(y, Decl(parserErrorRecovery_IncompleteMemberVariable1.ts, 13, 38)) + + // Instance member + getDist() { return Math.sqrt(this.x * this.x + this.y * this.y); } +>getDist : Symbol(getDist, Decl(parserErrorRecovery_IncompleteMemberVariable1.ts, 13, 60)) +>Math.sqrt : Symbol(Math.sqrt, Decl(lib.d.ts, 620, 27)) +>Math : Symbol(Math, Decl(lib.d.ts, 522, 1), Decl(lib.d.ts, 633, 11)) +>sqrt : Symbol(Math.sqrt, Decl(lib.d.ts, 620, 27)) +>this.x : Symbol(x, Decl(parserErrorRecovery_IncompleteMemberVariable1.ts, 13, 21)) +>this : Symbol(Point, Decl(parserErrorRecovery_IncompleteMemberVariable1.ts, 6, 15)) +>x : Symbol(x, Decl(parserErrorRecovery_IncompleteMemberVariable1.ts, 13, 21)) +>this.x : Symbol(x, Decl(parserErrorRecovery_IncompleteMemberVariable1.ts, 13, 21)) +>this : Symbol(Point, Decl(parserErrorRecovery_IncompleteMemberVariable1.ts, 6, 15)) +>x : Symbol(x, Decl(parserErrorRecovery_IncompleteMemberVariable1.ts, 13, 21)) +>this.y : Symbol(y, Decl(parserErrorRecovery_IncompleteMemberVariable1.ts, 13, 38)) +>this : Symbol(Point, Decl(parserErrorRecovery_IncompleteMemberVariable1.ts, 6, 15)) +>y : Symbol(y, Decl(parserErrorRecovery_IncompleteMemberVariable1.ts, 13, 38)) +>this.y : Symbol(y, Decl(parserErrorRecovery_IncompleteMemberVariable1.ts, 13, 38)) +>this : Symbol(Point, Decl(parserErrorRecovery_IncompleteMemberVariable1.ts, 6, 15)) +>y : Symbol(y, Decl(parserErrorRecovery_IncompleteMemberVariable1.ts, 13, 38)) + + // Static member + static origin = new Point(0, 0); +>origin : Symbol(Point.origin, Decl(parserErrorRecovery_IncompleteMemberVariable1.ts, 16, 74)) +>Point : Symbol(Point, Decl(parserErrorRecovery_IncompleteMemberVariable1.ts, 6, 15)) + } + +} + +// Local variables +var p: IPoint = new Shapes.Point(3, 4); +>p : Symbol(p, Decl(parserErrorRecovery_IncompleteMemberVariable1.ts, 25, 3)) +>IPoint : Symbol(IPoint, Decl(parserErrorRecovery_IncompleteMemberVariable1.ts, 0, 0)) +>Shapes.Point : Symbol(Shapes.Point, Decl(parserErrorRecovery_IncompleteMemberVariable1.ts, 6, 15)) +>Shapes : Symbol(Shapes, Decl(parserErrorRecovery_IncompleteMemberVariable1.ts, 3, 1)) +>Point : Symbol(Shapes.Point, Decl(parserErrorRecovery_IncompleteMemberVariable1.ts, 6, 15)) + +var dist = p.getDist(); +>dist : Symbol(dist, Decl(parserErrorRecovery_IncompleteMemberVariable1.ts, 26, 3)) +>p.getDist : Symbol(IPoint.getDist, Decl(parserErrorRecovery_IncompleteMemberVariable1.ts, 1, 18)) +>p : Symbol(p, Decl(parserErrorRecovery_IncompleteMemberVariable1.ts, 25, 3)) +>getDist : Symbol(IPoint.getDist, Decl(parserErrorRecovery_IncompleteMemberVariable1.ts, 1, 18)) + diff --git a/tests/baselines/reference/parserErrorRecovery_IncompleteMemberVariable1.types b/tests/baselines/reference/parserErrorRecovery_IncompleteMemberVariable1.types new file mode 100644 index 00000000000..bb51151cfd7 --- /dev/null +++ b/tests/baselines/reference/parserErrorRecovery_IncompleteMemberVariable1.types @@ -0,0 +1,78 @@ +=== tests/cases/conformance/parser/ecmascript5/ErrorRecovery/IncompleteMemberVariables/parserErrorRecovery_IncompleteMemberVariable1.ts === +// Interface +interface IPoint { +>IPoint : IPoint + + getDist(): number; +>getDist : () => number +} + +// Module +module Shapes { +>Shapes : typeof Shapes + + // Class + export class Point implements IPoint { +>Point : Point +>IPoint : IPoint + + public con: "hello"; +>con : "hello" + + // Constructor + constructor (public x: number, public y: number) { } +>x : number +>y : number + + // Instance member + getDist() { return Math.sqrt(this.x * this.x + this.y * this.y); } +>getDist : () => number +>Math.sqrt(this.x * this.x + this.y * this.y) : number +>Math.sqrt : (x: number) => number +>Math : Math +>sqrt : (x: number) => number +>this.x * this.x + this.y * this.y : number +>this.x * this.x : number +>this.x : number +>this : Point +>x : number +>this.x : number +>this : Point +>x : number +>this.y * this.y : number +>this.y : number +>this : Point +>y : number +>this.y : number +>this : Point +>y : number + + // Static member + static origin = new Point(0, 0); +>origin : Point +>new Point(0, 0) : Point +>Point : typeof Point +>0 : number +>0 : number + } + +} + +// Local variables +var p: IPoint = new Shapes.Point(3, 4); +>p : IPoint +>IPoint : IPoint +>new Shapes.Point(3, 4) : Shapes.Point +>Shapes.Point : typeof Shapes.Point +>Shapes : typeof Shapes +>Point : typeof Shapes.Point +>3 : number +>4 : number + +var dist = p.getDist(); +>dist : number +>p.getDist() : number +>p.getDist : () => number +>p : IPoint +>getDist : () => number + diff --git a/tests/baselines/reference/stringLiteralType.errors.txt b/tests/baselines/reference/stringLiteralType.errors.txt deleted file mode 100644 index 275db139cf7..00000000000 --- a/tests/baselines/reference/stringLiteralType.errors.txt +++ /dev/null @@ -1,12 +0,0 @@ -tests/cases/conformance/types/primitives/stringLiteral/stringLiteralType.ts(1,8): error TS1110: Type expected. - - -==== tests/cases/conformance/types/primitives/stringLiteral/stringLiteralType.ts (1 errors) ==== - var x: 'hi'; - ~~~~ -!!! error TS1110: Type expected. - - function f(x: 'hi'); - function f(x: string); - function f(x: any) { - } \ No newline at end of file diff --git a/tests/baselines/reference/stringLiteralType.js b/tests/baselines/reference/stringLiteralType.js index 35f35f1cbef..a6926453c47 100644 --- a/tests/baselines/reference/stringLiteralType.js +++ b/tests/baselines/reference/stringLiteralType.js @@ -7,6 +7,6 @@ function f(x: any) { } //// [stringLiteralType.js] -var x = 'hi'; +var x; function f(x) { } diff --git a/tests/baselines/reference/stringLiteralType.symbols b/tests/baselines/reference/stringLiteralType.symbols new file mode 100644 index 00000000000..687d3052442 --- /dev/null +++ b/tests/baselines/reference/stringLiteralType.symbols @@ -0,0 +1,16 @@ +=== tests/cases/conformance/types/primitives/stringLiteral/stringLiteralType.ts === +var x: 'hi'; +>x : Symbol(x, Decl(stringLiteralType.ts, 0, 3)) + +function f(x: 'hi'); +>f : Symbol(f, Decl(stringLiteralType.ts, 0, 12), Decl(stringLiteralType.ts, 2, 20), Decl(stringLiteralType.ts, 3, 22)) +>x : Symbol(x, Decl(stringLiteralType.ts, 2, 11)) + +function f(x: string); +>f : Symbol(f, Decl(stringLiteralType.ts, 0, 12), Decl(stringLiteralType.ts, 2, 20), Decl(stringLiteralType.ts, 3, 22)) +>x : Symbol(x, Decl(stringLiteralType.ts, 3, 11)) + +function f(x: any) { +>f : Symbol(f, Decl(stringLiteralType.ts, 0, 12), Decl(stringLiteralType.ts, 2, 20), Decl(stringLiteralType.ts, 3, 22)) +>x : Symbol(x, Decl(stringLiteralType.ts, 4, 11)) +} diff --git a/tests/baselines/reference/stringLiteralType.types b/tests/baselines/reference/stringLiteralType.types new file mode 100644 index 00000000000..5d2e13c4ba5 --- /dev/null +++ b/tests/baselines/reference/stringLiteralType.types @@ -0,0 +1,16 @@ +=== tests/cases/conformance/types/primitives/stringLiteral/stringLiteralType.ts === +var x: 'hi'; +>x : 'hi' + +function f(x: 'hi'); +>f : { (x: 'hi'): any; (x: string): any; } +>x : 'hi' + +function f(x: string); +>f : { (x: 'hi'): any; (x: string): any; } +>x : string + +function f(x: any) { +>f : { (x: 'hi'): any; (x: string): any; } +>x : any +} diff --git a/tests/baselines/reference/stringLiteralTypesAsTags01.errors.txt b/tests/baselines/reference/stringLiteralTypesAsTags01.errors.txt index 292cc8ea5b7..df05e25304f 100644 --- a/tests/baselines/reference/stringLiteralTypesAsTags01.errors.txt +++ b/tests/baselines/reference/stringLiteralTypesAsTags01.errors.txt @@ -1,30 +1,15 @@ -tests/cases/conformance/types/stringLiteral/stringLiteralTypesAsTags01.ts(2,12): error TS4081: Exported type alias 'Kind' has or is using private name ''. -tests/cases/conformance/types/stringLiteral/stringLiteralTypesAsTags01.ts(2,13): error TS1110: Type expected. -tests/cases/conformance/types/stringLiteral/stringLiteralTypesAsTags01.ts(2,13): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/types/stringLiteral/stringLiteralTypesAsTags01.ts(2,19): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/types/stringLiteral/stringLiteralTypesAsTags01.ts(9,10): error TS4033: Property 'kind' of exported interface has or is using private name ''. -tests/cases/conformance/types/stringLiteral/stringLiteralTypesAsTags01.ts(9,11): error TS1110: Type expected. -tests/cases/conformance/types/stringLiteral/stringLiteralTypesAsTags01.ts(14,10): error TS4033: Property 'kind' of exported interface has or is using private name ''. -tests/cases/conformance/types/stringLiteral/stringLiteralTypesAsTags01.ts(14,11): error TS1110: Type expected. tests/cases/conformance/types/stringLiteral/stringLiteralTypesAsTags01.ts(18,10): error TS2382: Specialized overload signature is not assignable to any non-specialized signature. tests/cases/conformance/types/stringLiteral/stringLiteralTypesAsTags01.ts(19,10): error TS2382: Specialized overload signature is not assignable to any non-specialized signature. tests/cases/conformance/types/stringLiteral/stringLiteralTypesAsTags01.ts(20,10): error TS2394: Overload signature is not compatible with function implementation. tests/cases/conformance/types/stringLiteral/stringLiteralTypesAsTags01.ts(22,21): error TS2304: Cannot find name 'is'. tests/cases/conformance/types/stringLiteral/stringLiteralTypesAsTags01.ts(25,5): error TS2322: Type '{ kind: string; a: number; }' is not assignable to type 'A'. - Property '"A"' is missing in type '{ kind: string; a: number; }'. + Types of property 'kind' are incompatible. + Type 'string' is not assignable to type '"A"'. -==== tests/cases/conformance/types/stringLiteral/stringLiteralTypesAsTags01.ts (13 errors) ==== +==== tests/cases/conformance/types/stringLiteral/stringLiteralTypesAsTags01.ts (5 errors) ==== type Kind = "A" | "B" - -!!! error TS4081: Exported type alias 'Kind' has or is using private name ''. - ~~~ -!!! error TS1110: Type expected. - ~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. - ~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. interface Entity { kind: Kind; @@ -32,19 +17,11 @@ tests/cases/conformance/types/stringLiteral/stringLiteralTypesAsTags01.ts(25,5): interface A extends Entity { kind: "A"; - -!!! error TS4033: Property 'kind' of exported interface has or is using private name ''. - ~~~ -!!! error TS1110: Type expected. a: number; } interface B extends Entity { kind: "B"; - -!!! error TS4033: Property 'kind' of exported interface has or is using private name ''. - ~~~ -!!! error TS1110: Type expected. b: string; } @@ -66,7 +43,8 @@ tests/cases/conformance/types/stringLiteral/stringLiteralTypesAsTags01.ts(25,5): let x: A = { ~ !!! error TS2322: Type '{ kind: string; a: number; }' is not assignable to type 'A'. -!!! error TS2322: Property '"A"' is missing in type '{ kind: string; a: number; }'. +!!! error TS2322: Types of property 'kind' are incompatible. +!!! error TS2322: Type 'string' is not assignable to type '"A"'. kind: "A", a: 100, } diff --git a/tests/baselines/reference/stringLiteralTypesAsTags01.js b/tests/baselines/reference/stringLiteralTypesAsTags01.js index 2ce20607790..3fe33ace487 100644 --- a/tests/baselines/reference/stringLiteralTypesAsTags01.js +++ b/tests/baselines/reference/stringLiteralTypesAsTags01.js @@ -43,7 +43,6 @@ else { } //// [stringLiteralTypesAsTags01.js] -"A" | "B"; function hasKind(entity, kind) { return kind === is; } @@ -63,3 +62,22 @@ if (!hasKind(x, "B")) { else { var d = x; } + + +//// [stringLiteralTypesAsTags01.d.ts] +declare type Kind = "A" | "B"; +interface Entity { + kind: Kind; +} +interface A extends Entity { + kind: "A"; + a: number; +} +interface B extends Entity { + kind: "B"; + b: string; +} +declare function hasKind(entity: Entity, kind: "A"): entity is A; +declare function hasKind(entity: Entity, kind: "B"): entity is B; +declare function hasKind(entity: Entity, kind: Kind): entity is Entity; +declare let x: A; diff --git a/tests/baselines/reference/stringLiteralTypesInUnionTypes01.errors.txt b/tests/baselines/reference/stringLiteralTypesInUnionTypes01.errors.txt index fcc13629ceb..14d0a892f55 100644 --- a/tests/baselines/reference/stringLiteralTypesInUnionTypes01.errors.txt +++ b/tests/baselines/reference/stringLiteralTypesInUnionTypes01.errors.txt @@ -1,47 +1,21 @@ -tests/cases/conformance/types/stringLiteral/stringLiteralTypesInUnionTypes01.ts(2,9): error TS4081: Exported type alias 'T' has or is using private name ''. -tests/cases/conformance/types/stringLiteral/stringLiteralTypesInUnionTypes01.ts(2,10): error TS1110: Type expected. -tests/cases/conformance/types/stringLiteral/stringLiteralTypesInUnionTypes01.ts(2,10): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/types/stringLiteral/stringLiteralTypesInUnionTypes01.ts(2,18): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/types/stringLiteral/stringLiteralTypesInUnionTypes01.ts(2,26): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/types/stringLiteral/stringLiteralTypesInUnionTypes01.ts(4,7): error TS4025: Exported variable 'x' has or is using private name ''. -tests/cases/conformance/types/stringLiteral/stringLiteralTypesInUnionTypes01.ts(4,8): error TS1110: Type expected. -tests/cases/conformance/types/stringLiteral/stringLiteralTypesInUnionTypes01.ts(4,8): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/types/stringLiteral/stringLiteralTypesInUnionTypes01.ts(4,16): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/types/stringLiteral/stringLiteralTypesInUnionTypes01.ts(4,24): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/types/stringLiteral/stringLiteralTypesInUnionTypes01.ts(4,30): error TS1005: ',' expected. -tests/cases/conformance/types/stringLiteral/stringLiteralTypesInUnionTypes01.ts(4,32): error TS1134: Variable declaration expected. +tests/cases/conformance/types/stringLiteral/stringLiteralTypesInUnionTypes01.ts(4,5): error TS2322: Type 'string' is not assignable to type '"foo" | "bar" | "baz"'. + Type 'string' is not assignable to type '"baz"'. +tests/cases/conformance/types/stringLiteral/stringLiteralTypesInUnionTypes01.ts(5,5): error TS2322: Type 'string' is not assignable to type '"foo" | "bar" | "baz"'. + Type 'string' is not assignable to type '"baz"'. -==== tests/cases/conformance/types/stringLiteral/stringLiteralTypesInUnionTypes01.ts (12 errors) ==== +==== tests/cases/conformance/types/stringLiteral/stringLiteralTypesInUnionTypes01.ts (2 errors) ==== type T = "foo" | "bar" | "baz"; - -!!! error TS4081: Exported type alias 'T' has or is using private name ''. - ~~~~~ -!!! error TS1110: Type expected. - ~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. - ~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. - ~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var x: "foo" | "bar" | "baz" = "foo"; - -!!! error TS4025: Exported variable 'x' has or is using private name ''. - ~~~~~ -!!! error TS1110: Type expected. - ~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. - ~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. - ~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. - ~ -!!! error TS1005: ',' expected. - ~~~~~ -!!! error TS1134: Variable declaration expected. + ~ +!!! error TS2322: Type 'string' is not assignable to type '"foo" | "bar" | "baz"'. +!!! error TS2322: Type 'string' is not assignable to type '"baz"'. var y: T = "bar"; + ~ +!!! error TS2322: Type 'string' is not assignable to type '"foo" | "bar" | "baz"'. +!!! error TS2322: Type 'string' is not assignable to type '"baz"'. if (x === "foo") { let a = x; diff --git a/tests/baselines/reference/stringLiteralTypesInUnionTypes01.js b/tests/baselines/reference/stringLiteralTypesInUnionTypes01.js index 4eaaec42ceb..d970310d68e 100644 --- a/tests/baselines/reference/stringLiteralTypesInUnionTypes01.js +++ b/tests/baselines/reference/stringLiteralTypesInUnionTypes01.js @@ -21,9 +21,7 @@ x = y; y = x; //// [stringLiteralTypesInUnionTypes01.js] -"foo" | "bar" | "baz"; -var x = "foo" | "bar" | "baz"; -"foo"; +var x = "foo"; var y = "bar"; if (x === "foo") { var a = x; @@ -38,3 +36,9 @@ else { } x = y; y = x; + + +//// [stringLiteralTypesInUnionTypes01.d.ts] +declare type T = "foo" | "bar" | "baz"; +declare var x: "foo" | "bar" | "baz"; +declare var y: T; diff --git a/tests/baselines/reference/stringLiteralTypesInUnionTypes02.errors.txt b/tests/baselines/reference/stringLiteralTypesInUnionTypes02.errors.txt deleted file mode 100644 index dc8523051aa..00000000000 --- a/tests/baselines/reference/stringLiteralTypesInUnionTypes02.errors.txt +++ /dev/null @@ -1,62 +0,0 @@ -tests/cases/conformance/types/stringLiteral/stringLiteralTypesInUnionTypes02.ts(2,18): error TS4081: Exported type alias 'T' has or is using private name ''. -tests/cases/conformance/types/stringLiteral/stringLiteralTypesInUnionTypes02.ts(2,19): error TS1110: Type expected. -tests/cases/conformance/types/stringLiteral/stringLiteralTypesInUnionTypes02.ts(2,19): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/types/stringLiteral/stringLiteralTypesInUnionTypes02.ts(2,27): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/types/stringLiteral/stringLiteralTypesInUnionTypes02.ts(2,35): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/types/stringLiteral/stringLiteralTypesInUnionTypes02.ts(4,7): error TS4025: Exported variable 'x' has or is using private name ''. -tests/cases/conformance/types/stringLiteral/stringLiteralTypesInUnionTypes02.ts(4,8): error TS1110: Type expected. -tests/cases/conformance/types/stringLiteral/stringLiteralTypesInUnionTypes02.ts(4,8): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/types/stringLiteral/stringLiteralTypesInUnionTypes02.ts(4,16): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/types/stringLiteral/stringLiteralTypesInUnionTypes02.ts(4,24): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/types/stringLiteral/stringLiteralTypesInUnionTypes02.ts(4,32): error TS2304: Cannot find name 'string'. -tests/cases/conformance/types/stringLiteral/stringLiteralTypesInUnionTypes02.ts(4,39): error TS1005: ',' expected. -tests/cases/conformance/types/stringLiteral/stringLiteralTypesInUnionTypes02.ts(4,41): error TS1134: Variable declaration expected. - - -==== tests/cases/conformance/types/stringLiteral/stringLiteralTypesInUnionTypes02.ts (13 errors) ==== - - type T = string | "foo" | "bar" | "baz"; - -!!! error TS4081: Exported type alias 'T' has or is using private name ''. - ~~~~~ -!!! error TS1110: Type expected. - ~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. - ~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. - ~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. - - var x: "foo" | "bar" | "baz" | string = "foo"; - -!!! error TS4025: Exported variable 'x' has or is using private name ''. - ~~~~~ -!!! error TS1110: Type expected. - ~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. - ~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. - ~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. - ~~~~~~ -!!! error TS2304: Cannot find name 'string'. - ~ -!!! error TS1005: ',' expected. - ~~~~~ -!!! error TS1134: Variable declaration expected. - var y: T = "bar"; - - if (x === "foo") { - let a = x; - } - else if (x !== "bar") { - let b = x || y; - } - else { - let c = x; - let d = y; - let e: (typeof x) | (typeof y) = c || d; - } - - x = y; - y = x; \ No newline at end of file diff --git a/tests/baselines/reference/stringLiteralTypesInUnionTypes02.js b/tests/baselines/reference/stringLiteralTypesInUnionTypes02.js index 19b309980f8..19b9c837c9d 100644 --- a/tests/baselines/reference/stringLiteralTypesInUnionTypes02.js +++ b/tests/baselines/reference/stringLiteralTypesInUnionTypes02.js @@ -21,9 +21,7 @@ x = y; y = x; //// [stringLiteralTypesInUnionTypes02.js] -"foo" | "bar" | "baz"; -var x = "foo" | "bar" | "baz" | string; -"foo"; +var x = "foo"; var y = "bar"; if (x === "foo") { var a = x; @@ -38,3 +36,9 @@ else { } x = y; y = x; + + +//// [stringLiteralTypesInUnionTypes02.d.ts] +declare type T = string | "foo" | "bar" | "baz"; +declare var x: "foo" | "bar" | "baz" | string; +declare var y: T; diff --git a/tests/baselines/reference/stringLiteralTypesInUnionTypes02.symbols b/tests/baselines/reference/stringLiteralTypesInUnionTypes02.symbols new file mode 100644 index 00000000000..c9b31dc710a --- /dev/null +++ b/tests/baselines/reference/stringLiteralTypesInUnionTypes02.symbols @@ -0,0 +1,52 @@ +=== tests/cases/conformance/types/stringLiteral/stringLiteralTypesInUnionTypes02.ts === + +type T = string | "foo" | "bar" | "baz"; +>T : Symbol(T, Decl(stringLiteralTypesInUnionTypes02.ts, 0, 0)) + +var x: "foo" | "bar" | "baz" | string = "foo"; +>x : Symbol(x, Decl(stringLiteralTypesInUnionTypes02.ts, 3, 3)) + +var y: T = "bar"; +>y : Symbol(y, Decl(stringLiteralTypesInUnionTypes02.ts, 4, 3)) +>T : Symbol(T, Decl(stringLiteralTypesInUnionTypes02.ts, 0, 0)) + +if (x === "foo") { +>x : Symbol(x, Decl(stringLiteralTypesInUnionTypes02.ts, 3, 3)) + + let a = x; +>a : Symbol(a, Decl(stringLiteralTypesInUnionTypes02.ts, 7, 7)) +>x : Symbol(x, Decl(stringLiteralTypesInUnionTypes02.ts, 3, 3)) +} +else if (x !== "bar") { +>x : Symbol(x, Decl(stringLiteralTypesInUnionTypes02.ts, 3, 3)) + + let b = x || y; +>b : Symbol(b, Decl(stringLiteralTypesInUnionTypes02.ts, 10, 7)) +>x : Symbol(x, Decl(stringLiteralTypesInUnionTypes02.ts, 3, 3)) +>y : Symbol(y, Decl(stringLiteralTypesInUnionTypes02.ts, 4, 3)) +} +else { + let c = x; +>c : Symbol(c, Decl(stringLiteralTypesInUnionTypes02.ts, 13, 7)) +>x : Symbol(x, Decl(stringLiteralTypesInUnionTypes02.ts, 3, 3)) + + let d = y; +>d : Symbol(d, Decl(stringLiteralTypesInUnionTypes02.ts, 14, 7)) +>y : Symbol(y, Decl(stringLiteralTypesInUnionTypes02.ts, 4, 3)) + + let e: (typeof x) | (typeof y) = c || d; +>e : Symbol(e, Decl(stringLiteralTypesInUnionTypes02.ts, 15, 7)) +>x : Symbol(x, Decl(stringLiteralTypesInUnionTypes02.ts, 3, 3)) +>y : Symbol(y, Decl(stringLiteralTypesInUnionTypes02.ts, 4, 3)) +>c : Symbol(c, Decl(stringLiteralTypesInUnionTypes02.ts, 13, 7)) +>d : Symbol(d, Decl(stringLiteralTypesInUnionTypes02.ts, 14, 7)) +} + +x = y; +>x : Symbol(x, Decl(stringLiteralTypesInUnionTypes02.ts, 3, 3)) +>y : Symbol(y, Decl(stringLiteralTypesInUnionTypes02.ts, 4, 3)) + +y = x; +>y : Symbol(y, Decl(stringLiteralTypesInUnionTypes02.ts, 4, 3)) +>x : Symbol(x, Decl(stringLiteralTypesInUnionTypes02.ts, 3, 3)) + diff --git a/tests/baselines/reference/stringLiteralTypesInUnionTypes02.types b/tests/baselines/reference/stringLiteralTypesInUnionTypes02.types new file mode 100644 index 00000000000..569edc77815 --- /dev/null +++ b/tests/baselines/reference/stringLiteralTypesInUnionTypes02.types @@ -0,0 +1,62 @@ +=== tests/cases/conformance/types/stringLiteral/stringLiteralTypesInUnionTypes02.ts === + +type T = string | "foo" | "bar" | "baz"; +>T : string | "foo" | "bar" | "baz" + +var x: "foo" | "bar" | "baz" | string = "foo"; +>x : "foo" | "bar" | "baz" | string +>"foo" : string + +var y: T = "bar"; +>y : string | "foo" | "bar" | "baz" +>T : string | "foo" | "bar" | "baz" +>"bar" : string + +if (x === "foo") { +>x === "foo" : boolean +>x : "foo" | "bar" | "baz" | string +>"foo" : string + + let a = x; +>a : "foo" | "bar" | "baz" | string +>x : "foo" | "bar" | "baz" | string +} +else if (x !== "bar") { +>x !== "bar" : boolean +>x : "foo" | "bar" | "baz" | string +>"bar" : string + + let b = x || y; +>b : string +>x || y : string +>x : "foo" | "bar" | "baz" | string +>y : string | "foo" | "bar" | "baz" +} +else { + let c = x; +>c : "foo" | "bar" | "baz" | string +>x : "foo" | "bar" | "baz" | string + + let d = y; +>d : string | "foo" | "bar" | "baz" +>y : string | "foo" | "bar" | "baz" + + let e: (typeof x) | (typeof y) = c || d; +>e : "foo" | "bar" | "baz" | string +>x : "foo" | "bar" | "baz" | string +>y : string | "foo" | "bar" | "baz" +>c || d : string +>c : "foo" | "bar" | "baz" | string +>d : string | "foo" | "bar" | "baz" +} + +x = y; +>x = y : string | "foo" | "bar" | "baz" +>x : "foo" | "bar" | "baz" | string +>y : string | "foo" | "bar" | "baz" + +y = x; +>y = x : "foo" | "bar" | "baz" | string +>y : string | "foo" | "bar" | "baz" +>x : "foo" | "bar" | "baz" | string + diff --git a/tests/baselines/reference/stringLiteralTypesInUnionTypes03.errors.txt b/tests/baselines/reference/stringLiteralTypesInUnionTypes03.errors.txt index 1595c625322..8ff377b2e72 100644 --- a/tests/baselines/reference/stringLiteralTypesInUnionTypes03.errors.txt +++ b/tests/baselines/reference/stringLiteralTypesInUnionTypes03.errors.txt @@ -1,43 +1,27 @@ -tests/cases/conformance/types/stringLiteral/stringLiteralTypesInUnionTypes03.ts(2,18): error TS4081: Exported type alias 'T' has or is using private name ''. -tests/cases/conformance/types/stringLiteral/stringLiteralTypesInUnionTypes03.ts(2,19): error TS1110: Type expected. -tests/cases/conformance/types/stringLiteral/stringLiteralTypesInUnionTypes03.ts(2,19): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/types/stringLiteral/stringLiteralTypesInUnionTypes03.ts(2,27): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/types/stringLiteral/stringLiteralTypesInUnionTypes03.ts(4,7): error TS4025: Exported variable 'x' has or is using private name ''. -tests/cases/conformance/types/stringLiteral/stringLiteralTypesInUnionTypes03.ts(4,8): error TS1110: Type expected. -tests/cases/conformance/types/stringLiteral/stringLiteralTypesInUnionTypes03.ts(4,8): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/types/stringLiteral/stringLiteralTypesInUnionTypes03.ts(4,16): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/types/stringLiteral/stringLiteralTypesInUnionTypes03.ts(4,24): error TS2304: Cannot find name 'number'. +tests/cases/conformance/types/stringLiteral/stringLiteralTypesInUnionTypes03.ts(5,5): error TS2322: Type 'string' is not assignable to type 'number | "foo" | "bar"'. + Type 'string' is not assignable to type '"bar"'. +tests/cases/conformance/types/stringLiteral/stringLiteralTypesInUnionTypes03.ts(7,5): error TS2365: Operator '===' cannot be applied to types '"foo" | "bar" | number' and 'string'. +tests/cases/conformance/types/stringLiteral/stringLiteralTypesInUnionTypes03.ts(10,10): error TS2365: Operator '!==' cannot be applied to types '"foo" | "bar" | number' and 'string'. -==== tests/cases/conformance/types/stringLiteral/stringLiteralTypesInUnionTypes03.ts (9 errors) ==== +==== tests/cases/conformance/types/stringLiteral/stringLiteralTypesInUnionTypes03.ts (3 errors) ==== type T = number | "foo" | "bar"; - -!!! error TS4081: Exported type alias 'T' has or is using private name ''. - ~~~~~ -!!! error TS1110: Type expected. - ~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. - ~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var x: "foo" | "bar" | number; - -!!! error TS4025: Exported variable 'x' has or is using private name ''. - ~~~~~ -!!! error TS1110: Type expected. - ~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. - ~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. - ~~~~~~ -!!! error TS2304: Cannot find name 'number'. var y: T = "bar"; + ~ +!!! error TS2322: Type 'string' is not assignable to type 'number | "foo" | "bar"'. +!!! error TS2322: Type 'string' is not assignable to type '"bar"'. if (x === "foo") { + ~~~~~~~~~~~ +!!! error TS2365: Operator '===' cannot be applied to types '"foo" | "bar" | number' and 'string'. let a = x; } else if (x !== "bar") { + ~~~~~~~~~~~ +!!! error TS2365: Operator '!==' cannot be applied to types '"foo" | "bar" | number' and 'string'. let b = x || y; } else { diff --git a/tests/baselines/reference/stringLiteralTypesInUnionTypes03.js b/tests/baselines/reference/stringLiteralTypesInUnionTypes03.js index 7705848be2b..f6728e0b2fb 100644 --- a/tests/baselines/reference/stringLiteralTypesInUnionTypes03.js +++ b/tests/baselines/reference/stringLiteralTypesInUnionTypes03.js @@ -21,8 +21,7 @@ x = y; y = x; //// [stringLiteralTypesInUnionTypes03.js] -"foo" | "bar"; -var x = "foo" | "bar" | number; +var x; var y = "bar"; if (x === "foo") { var a = x; @@ -37,3 +36,9 @@ else { } x = y; y = x; + + +//// [stringLiteralTypesInUnionTypes03.d.ts] +declare type T = number | "foo" | "bar"; +declare var x: "foo" | "bar" | number; +declare var y: T; diff --git a/tests/baselines/reference/stringLiteralTypesInUnionTypes04.errors.txt b/tests/baselines/reference/stringLiteralTypesInUnionTypes04.errors.txt index 66d3e215237..77cb9c09531 100644 --- a/tests/baselines/reference/stringLiteralTypesInUnionTypes04.errors.txt +++ b/tests/baselines/reference/stringLiteralTypesInUnionTypes04.errors.txt @@ -1,23 +1,21 @@ -tests/cases/conformance/types/stringLiteral/stringLiteralTypesInUnionTypes04.ts(2,9): error TS4081: Exported type alias 'T' has or is using private name ''. -tests/cases/conformance/types/stringLiteral/stringLiteralTypesInUnionTypes04.ts(2,10): error TS1110: Type expected. -tests/cases/conformance/types/stringLiteral/stringLiteralTypesInUnionTypes04.ts(2,10): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/types/stringLiteral/stringLiteralTypesInUnionTypes04.ts(2,15): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/types/stringLiteral/stringLiteralTypesInUnionTypes04.ts(4,5): error TS2322: Type 'string' is not assignable to type '"" | "foo"'. + Type 'string' is not assignable to type '"foo"'. +tests/cases/conformance/types/stringLiteral/stringLiteralTypesInUnionTypes04.ts(5,5): error TS2322: Type 'string' is not assignable to type '"" | "foo"'. + Type 'string' is not assignable to type '"foo"'. -==== tests/cases/conformance/types/stringLiteral/stringLiteralTypesInUnionTypes04.ts (4 errors) ==== +==== tests/cases/conformance/types/stringLiteral/stringLiteralTypesInUnionTypes04.ts (2 errors) ==== type T = "" | "foo"; - -!!! error TS4081: Exported type alias 'T' has or is using private name ''. - ~~ -!!! error TS1110: Type expected. - ~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. - ~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. let x: T = ""; + ~ +!!! error TS2322: Type 'string' is not assignable to type '"" | "foo"'. +!!! error TS2322: Type 'string' is not assignable to type '"foo"'. let y: T = "foo"; + ~ +!!! error TS2322: Type 'string' is not assignable to type '"" | "foo"'. +!!! error TS2322: Type 'string' is not assignable to type '"foo"'. if (x === "") { let a = x; diff --git a/tests/baselines/reference/stringLiteralTypesInUnionTypes04.js b/tests/baselines/reference/stringLiteralTypesInUnionTypes04.js index 5817d16ec8f..dc6cf51ad1e 100644 --- a/tests/baselines/reference/stringLiteralTypesInUnionTypes04.js +++ b/tests/baselines/reference/stringLiteralTypesInUnionTypes04.js @@ -38,7 +38,6 @@ if (!!!x) { } //// [stringLiteralTypesInUnionTypes04.js] -"" | "foo"; var x = ""; var y = "foo"; if (x === "") { @@ -65,3 +64,9 @@ if (!!x) { if (!!!x) { var h = x; } + + +//// [stringLiteralTypesInUnionTypes04.d.ts] +declare type T = "" | "foo"; +declare let x: T; +declare let y: T; diff --git a/tests/baselines/reference/stringLiteralTypesInVariableDeclarations01.errors.txt b/tests/baselines/reference/stringLiteralTypesInVariableDeclarations01.errors.txt index 14233db44cd..3dd2adbbce0 100644 --- a/tests/baselines/reference/stringLiteralTypesInVariableDeclarations01.errors.txt +++ b/tests/baselines/reference/stringLiteralTypesInVariableDeclarations01.errors.txt @@ -1,81 +1,54 @@ -tests/cases/conformance/types/stringLiteral/stringLiteralTypesInVariableDeclarations01.ts(2,7): error TS4025: Exported variable 'a' has or is using private name ''. -tests/cases/conformance/types/stringLiteral/stringLiteralTypesInVariableDeclarations01.ts(2,8): error TS1110: Type expected. -tests/cases/conformance/types/stringLiteral/stringLiteralTypesInVariableDeclarations01.ts(3,7): error TS4025: Exported variable 'b' has or is using private name ''. -tests/cases/conformance/types/stringLiteral/stringLiteralTypesInVariableDeclarations01.ts(3,8): error TS1110: Type expected. -tests/cases/conformance/types/stringLiteral/stringLiteralTypesInVariableDeclarations01.ts(4,7): error TS4025: Exported variable 'c' has or is using private name ''. -tests/cases/conformance/types/stringLiteral/stringLiteralTypesInVariableDeclarations01.ts(4,8): error TS1110: Type expected. -tests/cases/conformance/types/stringLiteral/stringLiteralTypesInVariableDeclarations01.ts(5,9): error TS4025: Exported variable 'd' has or is using private name ''. -tests/cases/conformance/types/stringLiteral/stringLiteralTypesInVariableDeclarations01.ts(5,10): error TS1110: Type expected. -tests/cases/conformance/types/stringLiteral/stringLiteralTypesInVariableDeclarations01.ts(11,7): error TS4025: Exported variable 'e' has or is using private name ''. -tests/cases/conformance/types/stringLiteral/stringLiteralTypesInVariableDeclarations01.ts(11,8): error TS1110: Type expected. -tests/cases/conformance/types/stringLiteral/stringLiteralTypesInVariableDeclarations01.ts(11,8): error TS2364: Invalid left-hand side of assignment expression. -tests/cases/conformance/types/stringLiteral/stringLiteralTypesInVariableDeclarations01.ts(12,7): error TS4025: Exported variable 'f' has or is using private name ''. -tests/cases/conformance/types/stringLiteral/stringLiteralTypesInVariableDeclarations01.ts(12,8): error TS1110: Type expected. -tests/cases/conformance/types/stringLiteral/stringLiteralTypesInVariableDeclarations01.ts(12,8): error TS2364: Invalid left-hand side of assignment expression. -tests/cases/conformance/types/stringLiteral/stringLiteralTypesInVariableDeclarations01.ts(13,7): error TS4025: Exported variable 'g' has or is using private name ''. -tests/cases/conformance/types/stringLiteral/stringLiteralTypesInVariableDeclarations01.ts(13,8): error TS1110: Type expected. -tests/cases/conformance/types/stringLiteral/stringLiteralTypesInVariableDeclarations01.ts(13,8): error TS2364: Invalid left-hand side of assignment expression. -tests/cases/conformance/types/stringLiteral/stringLiteralTypesInVariableDeclarations01.ts(14,9): error TS4025: Exported variable 'h' has or is using private name ''. -tests/cases/conformance/types/stringLiteral/stringLiteralTypesInVariableDeclarations01.ts(14,10): error TS1110: Type expected. -tests/cases/conformance/types/stringLiteral/stringLiteralTypesInVariableDeclarations01.ts(14,10): error TS2364: Invalid left-hand side of assignment expression. +tests/cases/conformance/types/stringLiteral/stringLiteralTypesInVariableDeclarations01.ts(5,7): error TS1155: 'const' declarations must be initialized +tests/cases/conformance/types/stringLiteral/stringLiteralTypesInVariableDeclarations01.ts(7,1): error TS2322: Type 'string' is not assignable to type '""'. +tests/cases/conformance/types/stringLiteral/stringLiteralTypesInVariableDeclarations01.ts(8,1): error TS2322: Type 'string' is not assignable to type '"foo"'. +tests/cases/conformance/types/stringLiteral/stringLiteralTypesInVariableDeclarations01.ts(9,1): error TS2322: Type 'string' is not assignable to type '"bar"'. +tests/cases/conformance/types/stringLiteral/stringLiteralTypesInVariableDeclarations01.ts(11,5): error TS2322: Type 'string' is not assignable to type '""'. +tests/cases/conformance/types/stringLiteral/stringLiteralTypesInVariableDeclarations01.ts(12,5): error TS2322: Type 'string' is not assignable to type '"foo"'. +tests/cases/conformance/types/stringLiteral/stringLiteralTypesInVariableDeclarations01.ts(13,5): error TS2322: Type 'string' is not assignable to type '"bar"'. +tests/cases/conformance/types/stringLiteral/stringLiteralTypesInVariableDeclarations01.ts(14,7): error TS2322: Type 'string' is not assignable to type '"baz"'. +tests/cases/conformance/types/stringLiteral/stringLiteralTypesInVariableDeclarations01.ts(16,1): error TS2322: Type 'string' is not assignable to type '""'. +tests/cases/conformance/types/stringLiteral/stringLiteralTypesInVariableDeclarations01.ts(17,1): error TS2322: Type 'string' is not assignable to type '"foo"'. +tests/cases/conformance/types/stringLiteral/stringLiteralTypesInVariableDeclarations01.ts(18,1): error TS2322: Type 'string' is not assignable to type '"bar"'. -==== tests/cases/conformance/types/stringLiteral/stringLiteralTypesInVariableDeclarations01.ts (20 errors) ==== +==== tests/cases/conformance/types/stringLiteral/stringLiteralTypesInVariableDeclarations01.ts (11 errors) ==== let a: ""; - -!!! error TS4025: Exported variable 'a' has or is using private name ''. - ~~ -!!! error TS1110: Type expected. var b: "foo"; - -!!! error TS4025: Exported variable 'b' has or is using private name ''. - ~~~~~ -!!! error TS1110: Type expected. let c: "bar"; - -!!! error TS4025: Exported variable 'c' has or is using private name ''. - ~~~~~ -!!! error TS1110: Type expected. const d: "baz"; - -!!! error TS4025: Exported variable 'd' has or is using private name ''. - ~~~~~ -!!! error TS1110: Type expected. + ~ +!!! error TS1155: 'const' declarations must be initialized a = ""; + ~ +!!! error TS2322: Type 'string' is not assignable to type '""'. b = "foo"; + ~ +!!! error TS2322: Type 'string' is not assignable to type '"foo"'. c = "bar"; + ~ +!!! error TS2322: Type 'string' is not assignable to type '"bar"'. let e: "" = ""; - -!!! error TS4025: Exported variable 'e' has or is using private name ''. - ~~ -!!! error TS1110: Type expected. - ~~ -!!! error TS2364: Invalid left-hand side of assignment expression. + ~ +!!! error TS2322: Type 'string' is not assignable to type '""'. var f: "foo" = "foo"; - -!!! error TS4025: Exported variable 'f' has or is using private name ''. - ~~~~~ -!!! error TS1110: Type expected. - ~~~~~ -!!! error TS2364: Invalid left-hand side of assignment expression. + ~ +!!! error TS2322: Type 'string' is not assignable to type '"foo"'. let g: "bar" = "bar"; - -!!! error TS4025: Exported variable 'g' has or is using private name ''. - ~~~~~ -!!! error TS1110: Type expected. - ~~~~~ -!!! error TS2364: Invalid left-hand side of assignment expression. + ~ +!!! error TS2322: Type 'string' is not assignable to type '"bar"'. const h: "baz" = "baz"; - -!!! error TS4025: Exported variable 'h' has or is using private name ''. - ~~~~~ -!!! error TS1110: Type expected. - ~~~~~ -!!! error TS2364: Invalid left-hand side of assignment expression. + ~ +!!! error TS2322: Type 'string' is not assignable to type '"baz"'. e = ""; + ~ +!!! error TS2322: Type 'string' is not assignable to type '""'. f = "foo"; - g = "bar"; \ No newline at end of file + ~ +!!! error TS2322: Type 'string' is not assignable to type '"foo"'. + g = "bar"; + ~ +!!! error TS2322: Type 'string' is not assignable to type '"bar"'. \ No newline at end of file diff --git a/tests/baselines/reference/stringLiteralTypesInVariableDeclarations01.js b/tests/baselines/reference/stringLiteralTypesInVariableDeclarations01.js index 4aae2a2438a..15a4ca5d580 100644 --- a/tests/baselines/reference/stringLiteralTypesInVariableDeclarations01.js +++ b/tests/baselines/reference/stringLiteralTypesInVariableDeclarations01.js @@ -19,17 +19,28 @@ f = "foo"; g = "bar"; //// [stringLiteralTypesInVariableDeclarations01.js] -var a = ""; -var b = "foo"; -var c = "bar"; -var d = "baz"; +var a; +var b; +var c; +var d; a = ""; b = "foo"; c = "bar"; -var e = "" = ""; -var f = "foo" = "foo"; -var g = "bar" = "bar"; -var h = "baz" = "baz"; +var e = ""; +var f = "foo"; +var g = "bar"; +var h = "baz"; e = ""; f = "foo"; g = "bar"; + + +//// [stringLiteralTypesInVariableDeclarations01.d.ts] +declare let a: ""; +declare var b: "foo"; +declare let c: "bar"; +declare const d: "baz"; +declare let e: ""; +declare var f: "foo"; +declare let g: "bar"; +declare const h: "baz"; diff --git a/tests/baselines/reference/stringLiteralTypesOverloads01.errors.txt b/tests/baselines/reference/stringLiteralTypesOverloads01.errors.txt index e41de718dfa..378857dc277 100644 --- a/tests/baselines/reference/stringLiteralTypesOverloads01.errors.txt +++ b/tests/baselines/reference/stringLiteralTypesOverloads01.errors.txt @@ -1,86 +1,20 @@ -tests/cases/conformance/types/stringLiteral/stringLiteralTypesOverloads01.ts(2,21): error TS4081: Exported type alias 'PrimitiveName' has or is using private name ''. -tests/cases/conformance/types/stringLiteral/stringLiteralTypesOverloads01.ts(2,22): error TS1110: Type expected. -tests/cases/conformance/types/stringLiteral/stringLiteralTypesOverloads01.ts(2,22): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/types/stringLiteral/stringLiteralTypesOverloads01.ts(2,33): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/types/stringLiteral/stringLiteralTypesOverloads01.ts(2,44): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/types/stringLiteral/stringLiteralTypesOverloads01.ts(4,10): error TS2382: Specialized overload signature is not assignable to any non-specialized signature. -tests/cases/conformance/types/stringLiteral/stringLiteralTypesOverloads01.ts(5,10): error TS2382: Specialized overload signature is not assignable to any non-specialized signature. -tests/cases/conformance/types/stringLiteral/stringLiteralTypesOverloads01.ts(6,10): error TS2382: Specialized overload signature is not assignable to any non-specialized signature. -tests/cases/conformance/types/stringLiteral/stringLiteralTypesOverloads01.ts(7,10): error TS2382: Specialized overload signature is not assignable to any non-specialized signature. -tests/cases/conformance/types/stringLiteral/stringLiteralTypesOverloads01.ts(7,28): error TS2371: A parameter initializer is only allowed in a function or constructor implementation. -tests/cases/conformance/types/stringLiteral/stringLiteralTypesOverloads01.ts(7,41): error TS1005: '=' expected. -tests/cases/conformance/types/stringLiteral/stringLiteralTypesOverloads01.ts(8,10): error TS2382: Specialized overload signature is not assignable to any non-specialized signature. -tests/cases/conformance/types/stringLiteral/stringLiteralTypesOverloads01.ts(8,28): error TS2371: A parameter initializer is only allowed in a function or constructor implementation. -tests/cases/conformance/types/stringLiteral/stringLiteralTypesOverloads01.ts(8,41): error TS1005: '=' expected. -tests/cases/conformance/types/stringLiteral/stringLiteralTypesOverloads01.ts(9,10): error TS2382: Specialized overload signature is not assignable to any non-specialized signature. -tests/cases/conformance/types/stringLiteral/stringLiteralTypesOverloads01.ts(9,28): error TS2371: A parameter initializer is only allowed in a function or constructor implementation. -tests/cases/conformance/types/stringLiteral/stringLiteralTypesOverloads01.ts(9,40): error TS1005: '=' expected. -tests/cases/conformance/types/stringLiteral/stringLiteralTypesOverloads01.ts(10,10): error TS2382: Specialized overload signature is not assignable to any non-specialized signature. -tests/cases/conformance/types/stringLiteral/stringLiteralTypesOverloads01.ts(10,28): error TS2371: A parameter initializer is only allowed in a function or constructor implementation. -tests/cases/conformance/types/stringLiteral/stringLiteralTypesOverloads01.ts(10,40): error TS1005: '=' expected. tests/cases/conformance/types/stringLiteral/stringLiteralTypesOverloads01.ts(11,10): error TS2354: No best common type exists among return expressions. -tests/cases/conformance/types/stringLiteral/stringLiteralTypesOverloads01.ts(32,14): error TS4025: Exported variable 'string' has or is using private name ''. -tests/cases/conformance/types/stringLiteral/stringLiteralTypesOverloads01.ts(32,15): error TS1110: Type expected. -tests/cases/conformance/types/stringLiteral/stringLiteralTypesOverloads01.ts(32,15): error TS2364: Invalid left-hand side of assignment expression. -tests/cases/conformance/types/stringLiteral/stringLiteralTypesOverloads01.ts(33,14): error TS4025: Exported variable 'number' has or is using private name ''. -tests/cases/conformance/types/stringLiteral/stringLiteralTypesOverloads01.ts(33,15): error TS1110: Type expected. -tests/cases/conformance/types/stringLiteral/stringLiteralTypesOverloads01.ts(33,15): error TS2364: Invalid left-hand side of assignment expression. -tests/cases/conformance/types/stringLiteral/stringLiteralTypesOverloads01.ts(34,15): error TS4025: Exported variable 'boolean' has or is using private name ''. -tests/cases/conformance/types/stringLiteral/stringLiteralTypesOverloads01.ts(34,16): error TS1110: Type expected. -tests/cases/conformance/types/stringLiteral/stringLiteralTypesOverloads01.ts(34,16): error TS2364: Invalid left-hand side of assignment expression. +tests/cases/conformance/types/stringLiteral/stringLiteralTypesOverloads01.ts(32,7): error TS2322: Type 'string' is not assignable to type '"string"'. +tests/cases/conformance/types/stringLiteral/stringLiteralTypesOverloads01.ts(33,7): error TS2322: Type 'string' is not assignable to type ''number''. +tests/cases/conformance/types/stringLiteral/stringLiteralTypesOverloads01.ts(34,7): error TS2322: Type 'string' is not assignable to type '"boolean"'. -==== tests/cases/conformance/types/stringLiteral/stringLiteralTypesOverloads01.ts (30 errors) ==== +==== tests/cases/conformance/types/stringLiteral/stringLiteralTypesOverloads01.ts (4 errors) ==== type PrimitiveName = 'string' | 'number' | 'boolean'; - -!!! error TS4081: Exported type alias 'PrimitiveName' has or is using private name ''. - ~~~~~~~~ -!!! error TS1110: Type expected. - ~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. - ~~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. - ~~~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. function getFalsyPrimitive(x: "string"): string; - ~~~~~~~~~~~~~~~~~ -!!! error TS2382: Specialized overload signature is not assignable to any non-specialized signature. function getFalsyPrimitive(x: "number"): number; - ~~~~~~~~~~~~~~~~~ -!!! error TS2382: Specialized overload signature is not assignable to any non-specialized signature. function getFalsyPrimitive(x: "boolean"): boolean; - ~~~~~~~~~~~~~~~~~ -!!! error TS2382: Specialized overload signature is not assignable to any non-specialized signature. function getFalsyPrimitive(x: "boolean" | "string"): boolean | string; - ~~~~~~~~~~~~~~~~~ -!!! error TS2382: Specialized overload signature is not assignable to any non-specialized signature. - ~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2371: A parameter initializer is only allowed in a function or constructor implementation. - ~ -!!! error TS1005: '=' expected. function getFalsyPrimitive(x: "boolean" | "number"): boolean | number; - ~~~~~~~~~~~~~~~~~ -!!! error TS2382: Specialized overload signature is not assignable to any non-specialized signature. - ~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2371: A parameter initializer is only allowed in a function or constructor implementation. - ~ -!!! error TS1005: '=' expected. function getFalsyPrimitive(x: "number" | "string"): number | string; - ~~~~~~~~~~~~~~~~~ -!!! error TS2382: Specialized overload signature is not assignable to any non-specialized signature. - ~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2371: A parameter initializer is only allowed in a function or constructor implementation. - ~ -!!! error TS1005: '=' expected. function getFalsyPrimitive(x: "number" | "string" | "boolean"): number | string | boolean; - ~~~~~~~~~~~~~~~~~ -!!! error TS2382: Specialized overload signature is not assignable to any non-specialized signature. - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2371: A parameter initializer is only allowed in a function or constructor implementation. - ~ -!!! error TS1005: '=' expected. function getFalsyPrimitive(x: PrimitiveName) { ~~~~~~~~~~~~~~~~~ !!! error TS2354: No best common type exists among return expressions. @@ -105,26 +39,14 @@ tests/cases/conformance/types/stringLiteral/stringLiteralTypesOverloads01.ts(34, } const string: "string" = "string" - -!!! error TS4025: Exported variable 'string' has or is using private name ''. - ~~~~~~~~ -!!! error TS1110: Type expected. - ~~~~~~~~ -!!! error TS2364: Invalid left-hand side of assignment expression. + ~~~~~~ +!!! error TS2322: Type 'string' is not assignable to type '"string"'. const number: "number" = "number" - -!!! error TS4025: Exported variable 'number' has or is using private name ''. - ~~~~~~~~ -!!! error TS1110: Type expected. - ~~~~~~~~ -!!! error TS2364: Invalid left-hand side of assignment expression. + ~~~~~~ +!!! error TS2322: Type 'string' is not assignable to type ''number''. const boolean: "boolean" = "boolean" - -!!! error TS4025: Exported variable 'boolean' has or is using private name ''. - ~~~~~~~~~ -!!! error TS1110: Type expected. - ~~~~~~~~~ -!!! error TS2364: Invalid left-hand side of assignment expression. + ~~~~~~~ +!!! error TS2322: Type 'string' is not assignable to type '"boolean"'. const stringOrNumber = string || number; const stringOrBoolean = string || boolean; diff --git a/tests/baselines/reference/stringLiteralTypesOverloads01.js b/tests/baselines/reference/stringLiteralTypesOverloads01.js index a001f02c9c9..23483776a9b 100644 --- a/tests/baselines/reference/stringLiteralTypesOverloads01.js +++ b/tests/baselines/reference/stringLiteralTypesOverloads01.js @@ -54,7 +54,6 @@ namespace Consts2 { //// [stringLiteralTypesOverloads01.js] -'string' | 'number' | 'boolean'; function getFalsyPrimitive(x) { if (x === "string") { return ""; @@ -74,9 +73,9 @@ var Consts1; var ZERO = getFalsyPrimitive('number'); var FALSE = getFalsyPrimitive("boolean"); })(Consts1 || (Consts1 = {})); -var string = "string" = "string"; -var number = "number" = "number"; -var boolean = "boolean" = "boolean"; +var string = "string"; +var number = "number"; +var boolean = "boolean"; var stringOrNumber = string || number; var stringOrBoolean = string || boolean; var booleanOrNumber = number || boolean; @@ -91,3 +90,25 @@ var Consts2; var c = getFalsyPrimitive(booleanOrNumber); var d = getFalsyPrimitive(stringOrBooleanOrNumber); })(Consts2 || (Consts2 = {})); + + +//// [stringLiteralTypesOverloads01.d.ts] +declare type PrimitiveName = 'string' | 'number' | 'boolean'; +declare function getFalsyPrimitive(x: "string"): string; +declare function getFalsyPrimitive(x: "number"): number; +declare function getFalsyPrimitive(x: "boolean"): boolean; +declare function getFalsyPrimitive(x: "boolean" | "string"): boolean | string; +declare function getFalsyPrimitive(x: "boolean" | "number"): boolean | number; +declare function getFalsyPrimitive(x: "number" | "string"): number | string; +declare function getFalsyPrimitive(x: "number" | "string" | "boolean"): number | string | boolean; +declare namespace Consts1 { +} +declare const string: "string"; +declare const number: "number"; +declare const boolean: "boolean"; +declare const stringOrNumber: "string" | 'number'; +declare const stringOrBoolean: "string" | "boolean"; +declare const booleanOrNumber: 'number' | "boolean"; +declare const stringOrBooleanOrNumber: "string" | "boolean" | 'number'; +declare namespace Consts2 { +} diff --git a/tests/baselines/reference/stringLiteralTypesOverloads02.errors.txt b/tests/baselines/reference/stringLiteralTypesOverloads02.errors.txt index ff1e212c071..ae9fb9ce4f6 100644 --- a/tests/baselines/reference/stringLiteralTypesOverloads02.errors.txt +++ b/tests/baselines/reference/stringLiteralTypesOverloads02.errors.txt @@ -1,69 +1,18 @@ -tests/cases/conformance/types/stringLiteral/stringLiteralTypesOverloads02.ts(2,10): error TS2382: Specialized overload signature is not assignable to any non-specialized signature. -tests/cases/conformance/types/stringLiteral/stringLiteralTypesOverloads02.ts(3,10): error TS2382: Specialized overload signature is not assignable to any non-specialized signature. -tests/cases/conformance/types/stringLiteral/stringLiteralTypesOverloads02.ts(4,10): error TS2382: Specialized overload signature is not assignable to any non-specialized signature. -tests/cases/conformance/types/stringLiteral/stringLiteralTypesOverloads02.ts(5,10): error TS2382: Specialized overload signature is not assignable to any non-specialized signature. -tests/cases/conformance/types/stringLiteral/stringLiteralTypesOverloads02.ts(5,28): error TS2371: A parameter initializer is only allowed in a function or constructor implementation. -tests/cases/conformance/types/stringLiteral/stringLiteralTypesOverloads02.ts(5,41): error TS1005: '=' expected. -tests/cases/conformance/types/stringLiteral/stringLiteralTypesOverloads02.ts(6,10): error TS2382: Specialized overload signature is not assignable to any non-specialized signature. -tests/cases/conformance/types/stringLiteral/stringLiteralTypesOverloads02.ts(6,28): error TS2371: A parameter initializer is only allowed in a function or constructor implementation. -tests/cases/conformance/types/stringLiteral/stringLiteralTypesOverloads02.ts(6,41): error TS1005: '=' expected. -tests/cases/conformance/types/stringLiteral/stringLiteralTypesOverloads02.ts(7,10): error TS2382: Specialized overload signature is not assignable to any non-specialized signature. -tests/cases/conformance/types/stringLiteral/stringLiteralTypesOverloads02.ts(7,28): error TS2371: A parameter initializer is only allowed in a function or constructor implementation. -tests/cases/conformance/types/stringLiteral/stringLiteralTypesOverloads02.ts(7,40): error TS1005: '=' expected. -tests/cases/conformance/types/stringLiteral/stringLiteralTypesOverloads02.ts(8,10): error TS2382: Specialized overload signature is not assignable to any non-specialized signature. -tests/cases/conformance/types/stringLiteral/stringLiteralTypesOverloads02.ts(8,28): error TS2371: A parameter initializer is only allowed in a function or constructor implementation. -tests/cases/conformance/types/stringLiteral/stringLiteralTypesOverloads02.ts(8,40): error TS1005: '=' expected. tests/cases/conformance/types/stringLiteral/stringLiteralTypesOverloads02.ts(9,10): error TS2354: No best common type exists among return expressions. -tests/cases/conformance/types/stringLiteral/stringLiteralTypesOverloads02.ts(30,14): error TS4025: Exported variable 'string' has or is using private name ''. -tests/cases/conformance/types/stringLiteral/stringLiteralTypesOverloads02.ts(30,15): error TS1110: Type expected. -tests/cases/conformance/types/stringLiteral/stringLiteralTypesOverloads02.ts(30,15): error TS2364: Invalid left-hand side of assignment expression. -tests/cases/conformance/types/stringLiteral/stringLiteralTypesOverloads02.ts(31,14): error TS4025: Exported variable 'number' has or is using private name ''. -tests/cases/conformance/types/stringLiteral/stringLiteralTypesOverloads02.ts(31,15): error TS1110: Type expected. -tests/cases/conformance/types/stringLiteral/stringLiteralTypesOverloads02.ts(31,15): error TS2364: Invalid left-hand side of assignment expression. -tests/cases/conformance/types/stringLiteral/stringLiteralTypesOverloads02.ts(32,15): error TS4025: Exported variable 'boolean' has or is using private name ''. -tests/cases/conformance/types/stringLiteral/stringLiteralTypesOverloads02.ts(32,16): error TS1110: Type expected. -tests/cases/conformance/types/stringLiteral/stringLiteralTypesOverloads02.ts(32,16): error TS2364: Invalid left-hand side of assignment expression. +tests/cases/conformance/types/stringLiteral/stringLiteralTypesOverloads02.ts(30,7): error TS2322: Type 'string' is not assignable to type '"string"'. +tests/cases/conformance/types/stringLiteral/stringLiteralTypesOverloads02.ts(31,7): error TS2322: Type 'string' is not assignable to type '"number"'. +tests/cases/conformance/types/stringLiteral/stringLiteralTypesOverloads02.ts(32,7): error TS2322: Type 'string' is not assignable to type '"boolean"'. -==== tests/cases/conformance/types/stringLiteral/stringLiteralTypesOverloads02.ts (25 errors) ==== +==== tests/cases/conformance/types/stringLiteral/stringLiteralTypesOverloads02.ts (4 errors) ==== function getFalsyPrimitive(x: "string"): string; - ~~~~~~~~~~~~~~~~~ -!!! error TS2382: Specialized overload signature is not assignable to any non-specialized signature. function getFalsyPrimitive(x: "number"): number; - ~~~~~~~~~~~~~~~~~ -!!! error TS2382: Specialized overload signature is not assignable to any non-specialized signature. function getFalsyPrimitive(x: "boolean"): boolean; - ~~~~~~~~~~~~~~~~~ -!!! error TS2382: Specialized overload signature is not assignable to any non-specialized signature. function getFalsyPrimitive(x: "boolean" | "string"): boolean | string; - ~~~~~~~~~~~~~~~~~ -!!! error TS2382: Specialized overload signature is not assignable to any non-specialized signature. - ~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2371: A parameter initializer is only allowed in a function or constructor implementation. - ~ -!!! error TS1005: '=' expected. function getFalsyPrimitive(x: "boolean" | "number"): boolean | number; - ~~~~~~~~~~~~~~~~~ -!!! error TS2382: Specialized overload signature is not assignable to any non-specialized signature. - ~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2371: A parameter initializer is only allowed in a function or constructor implementation. - ~ -!!! error TS1005: '=' expected. function getFalsyPrimitive(x: "number" | "string"): number | string; - ~~~~~~~~~~~~~~~~~ -!!! error TS2382: Specialized overload signature is not assignable to any non-specialized signature. - ~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2371: A parameter initializer is only allowed in a function or constructor implementation. - ~ -!!! error TS1005: '=' expected. function getFalsyPrimitive(x: "number" | "string" | "boolean"): number | string | boolean; - ~~~~~~~~~~~~~~~~~ -!!! error TS2382: Specialized overload signature is not assignable to any non-specialized signature. - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2371: A parameter initializer is only allowed in a function or constructor implementation. - ~ -!!! error TS1005: '=' expected. function getFalsyPrimitive(x: string) { ~~~~~~~~~~~~~~~~~ !!! error TS2354: No best common type exists among return expressions. @@ -88,26 +37,14 @@ tests/cases/conformance/types/stringLiteral/stringLiteralTypesOverloads02.ts(32, } const string: "string" = "string" - -!!! error TS4025: Exported variable 'string' has or is using private name ''. - ~~~~~~~~ -!!! error TS1110: Type expected. - ~~~~~~~~ -!!! error TS2364: Invalid left-hand side of assignment expression. + ~~~~~~ +!!! error TS2322: Type 'string' is not assignable to type '"string"'. const number: "number" = "number" - -!!! error TS4025: Exported variable 'number' has or is using private name ''. - ~~~~~~~~ -!!! error TS1110: Type expected. - ~~~~~~~~ -!!! error TS2364: Invalid left-hand side of assignment expression. + ~~~~~~ +!!! error TS2322: Type 'string' is not assignable to type '"number"'. const boolean: "boolean" = "boolean" - -!!! error TS4025: Exported variable 'boolean' has or is using private name ''. - ~~~~~~~~~ -!!! error TS1110: Type expected. - ~~~~~~~~~ -!!! error TS2364: Invalid left-hand side of assignment expression. + ~~~~~~~ +!!! error TS2322: Type 'string' is not assignable to type '"boolean"'. const stringOrNumber = string || number; const stringOrBoolean = string || boolean; diff --git a/tests/baselines/reference/stringLiteralTypesOverloads02.js b/tests/baselines/reference/stringLiteralTypesOverloads02.js index ae38acebb95..3c53f9380a8 100644 --- a/tests/baselines/reference/stringLiteralTypesOverloads02.js +++ b/tests/baselines/reference/stringLiteralTypesOverloads02.js @@ -71,9 +71,9 @@ var Consts1; var ZERO = getFalsyPrimitive('number'); var FALSE = getFalsyPrimitive("boolean"); })(Consts1 || (Consts1 = {})); -var string = "string" = "string"; -var number = "number" = "number"; -var boolean = "boolean" = "boolean"; +var string = "string"; +var number = "number"; +var boolean = "boolean"; var stringOrNumber = string || number; var stringOrBoolean = string || boolean; var booleanOrNumber = number || boolean; @@ -88,3 +88,24 @@ var Consts2; var c = getFalsyPrimitive(booleanOrNumber); var d = getFalsyPrimitive(stringOrBooleanOrNumber); })(Consts2 || (Consts2 = {})); + + +//// [stringLiteralTypesOverloads02.d.ts] +declare function getFalsyPrimitive(x: "string"): string; +declare function getFalsyPrimitive(x: "number"): number; +declare function getFalsyPrimitive(x: "boolean"): boolean; +declare function getFalsyPrimitive(x: "boolean" | "string"): boolean | string; +declare function getFalsyPrimitive(x: "boolean" | "number"): boolean | number; +declare function getFalsyPrimitive(x: "number" | "string"): number | string; +declare function getFalsyPrimitive(x: "number" | "string" | "boolean"): number | string | boolean; +declare namespace Consts1 { +} +declare const string: "string"; +declare const number: "number"; +declare const boolean: "boolean"; +declare const stringOrNumber: "string" | "number"; +declare const stringOrBoolean: "string" | "boolean"; +declare const booleanOrNumber: "number" | "boolean"; +declare const stringOrBooleanOrNumber: "string" | "boolean" | "number"; +declare namespace Consts2 { +} diff --git a/tests/baselines/reference/stringLiteralTypesTypePredicates01.errors.txt b/tests/baselines/reference/stringLiteralTypesTypePredicates01.errors.txt index a4cc525cdd2..3e412a6c770 100644 --- a/tests/baselines/reference/stringLiteralTypesTypePredicates01.errors.txt +++ b/tests/baselines/reference/stringLiteralTypesTypePredicates01.errors.txt @@ -1,46 +1,27 @@ -tests/cases/conformance/types/stringLiteral/stringLiteralTypesTypePredicates01.ts(2,12): error TS4081: Exported type alias 'Kind' has or is using private name ''. -tests/cases/conformance/types/stringLiteral/stringLiteralTypesTypePredicates01.ts(2,13): error TS1110: Type expected. -tests/cases/conformance/types/stringLiteral/stringLiteralTypesTypePredicates01.ts(2,13): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/types/stringLiteral/stringLiteralTypesTypePredicates01.ts(2,19): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/types/stringLiteral/stringLiteralTypesTypePredicates01.ts(4,10): error TS2391: Function implementation is missing or not immediately following the declaration. -tests/cases/conformance/types/stringLiteral/stringLiteralTypesTypePredicates01.ts(4,46): error TS4060: Return type of exported function has or is using private name ''. -tests/cases/conformance/types/stringLiteral/stringLiteralTypesTypePredicates01.ts(4,47): error TS1110: Type expected. -tests/cases/conformance/types/stringLiteral/stringLiteralTypesTypePredicates01.ts(5,10): error TS2391: Function implementation is missing or not immediately following the declaration. -tests/cases/conformance/types/stringLiteral/stringLiteralTypesTypePredicates01.ts(5,46): error TS4060: Return type of exported function has or is using private name ''. -tests/cases/conformance/types/stringLiteral/stringLiteralTypesTypePredicates01.ts(5,47): error TS1110: Type expected. +tests/cases/conformance/types/stringLiteral/stringLiteralTypesTypePredicates01.ts(4,10): error TS2382: Specialized overload signature is not assignable to any non-specialized signature. +tests/cases/conformance/types/stringLiteral/stringLiteralTypesTypePredicates01.ts(5,10): error TS2382: Specialized overload signature is not assignable to any non-specialized signature. +tests/cases/conformance/types/stringLiteral/stringLiteralTypesTypePredicates01.ts(10,5): error TS2322: Type 'string' is not assignable to type '"A" | "B"'. + Type 'string' is not assignable to type '"B"'. -==== tests/cases/conformance/types/stringLiteral/stringLiteralTypesTypePredicates01.ts (10 errors) ==== +==== tests/cases/conformance/types/stringLiteral/stringLiteralTypesTypePredicates01.ts (3 errors) ==== type Kind = "A" | "B" - -!!! error TS4081: Exported type alias 'Kind' has or is using private name ''. - ~~~ -!!! error TS1110: Type expected. - ~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. - ~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. function kindIs(kind: Kind, is: "A"): kind is "A"; ~~~~~~ -!!! error TS2391: Function implementation is missing or not immediately following the declaration. - -!!! error TS4060: Return type of exported function has or is using private name ''. - ~~~ -!!! error TS1110: Type expected. +!!! error TS2382: Specialized overload signature is not assignable to any non-specialized signature. function kindIs(kind: Kind, is: "B"): kind is "B"; ~~~~~~ -!!! error TS2391: Function implementation is missing or not immediately following the declaration. - -!!! error TS4060: Return type of exported function has or is using private name ''. - ~~~ -!!! error TS1110: Type expected. +!!! error TS2382: Specialized overload signature is not assignable to any non-specialized signature. function kindIs(kind: Kind, is: Kind): boolean { return kind === is; } var x: Kind = "A"; + ~ +!!! error TS2322: Type 'string' is not assignable to type '"A" | "B"'. +!!! error TS2322: Type 'string' is not assignable to type '"B"'. if (kindIs(x, "A")) { let a = x; diff --git a/tests/baselines/reference/stringLiteralTypesTypePredicates01.js b/tests/baselines/reference/stringLiteralTypesTypePredicates01.js index 791caed9b31..fd4129d272d 100644 --- a/tests/baselines/reference/stringLiteralTypesTypePredicates01.js +++ b/tests/baselines/reference/stringLiteralTypesTypePredicates01.js @@ -25,9 +25,6 @@ else { } //// [stringLiteralTypesTypePredicates01.js] -"A" | "B"; -"A"; -"B"; function kindIs(kind, is) { return kind === is; } @@ -44,3 +41,10 @@ if (!kindIs(x, "B")) { else { var d = x; } + + +//// [stringLiteralTypesTypePredicates01.d.ts] +declare type Kind = "A" | "B"; +declare function kindIs(kind: Kind, is: "A"): kind is "A"; +declare function kindIs(kind: Kind, is: "B"): kind is "B"; +declare var x: Kind; diff --git a/tests/baselines/reference/typeArgumentsWithStringLiteralTypes01.errors.txt b/tests/baselines/reference/typeArgumentsWithStringLiteralTypes01.errors.txt index 626d0e3d6f4..f6421445ae1 100644 --- a/tests/baselines/reference/typeArgumentsWithStringLiteralTypes01.errors.txt +++ b/tests/baselines/reference/typeArgumentsWithStringLiteralTypes01.errors.txt @@ -1,23 +1,19 @@ tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(4,18): error TS2382: Specialized overload signature is not assignable to any non-specialized signature. -tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(4,48): error TS4060: Return type of exported function has or is using private name ''. -tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(4,49): error TS1110: Type expected. -tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(5,18): error TS2382: Specialized overload signature is not assignable to any non-specialized signature. -tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(5,39): error TS2371: A parameter initializer is only allowed in a function or constructor implementation. -tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(5,52): error TS1005: '=' expected. -tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(5,63): error TS4060: Return type of exported function has or is using private name ''. -tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(5,64): error TS1110: Type expected. -tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(5,64): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(5,74): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(37,25): error TS2345: Argument of type 'string' is not assignable to parameter of type '"Hello"'. tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(38,25): error TS2345: Argument of type 'string' is not assignable to parameter of type '"Hello"'. tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(39,25): error TS2345: Argument of type 'string' is not assignable to parameter of type '"Hello"'. tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(40,25): error TS2345: Argument of type 'string' is not assignable to parameter of type '"Hello"'. tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(41,25): error TS2345: Argument of type 'string' is not assignable to parameter of type '"Hello"'. -tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(44,30): error TS2345: Argument of type 'string' is not assignable to parameter of type '"Hello"'. -tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(45,30): error TS2345: Argument of type 'string' is not assignable to parameter of type '"Hello"'. -tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(46,30): error TS2345: Argument of type 'string' is not assignable to parameter of type '"Hello"'. -tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(47,30): error TS2345: Argument of type 'string' is not assignable to parameter of type '"Hello"'. -tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(48,30): error TS2345: Argument of type 'string' is not assignable to parameter of type '"Hello"'. +tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(44,30): error TS2345: Argument of type 'string' is not assignable to parameter of type '"Hello" | "World"'. + Type 'string' is not assignable to type '"World"'. +tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(45,30): error TS2345: Argument of type 'string' is not assignable to parameter of type '"Hello" | "World"'. + Type 'string' is not assignable to type '"World"'. +tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(46,30): error TS2345: Argument of type 'string' is not assignable to parameter of type '"Hello" | "World"'. + Type 'string' is not assignable to type '"World"'. +tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(47,30): error TS2345: Argument of type 'string' is not assignable to parameter of type '"Hello" | "World"'. + Type 'string' is not assignable to type '"World"'. +tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(48,30): error TS2345: Argument of type 'string' is not assignable to parameter of type '"Hello" | "World"'. + Type 'string' is not assignable to type '"World"'. tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(54,20): error TS2365: Operator '<' cannot be applied to types '(x: T, y: T) => T' and 'string'. tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(54,20): error TS2365: Operator '>' cannot be applied to types 'boolean' and 'string'. tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(55,20): error TS2365: Operator '<' cannot be applied to types '(x: T, y: T) => T' and 'string'. @@ -38,11 +34,16 @@ tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes0 tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(70,25): error TS2345: Argument of type 'boolean' is not assignable to parameter of type '"Hello"'. tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(71,25): error TS2345: Argument of type 'boolean' is not assignable to parameter of type '"Hello"'. tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(72,25): error TS2345: Argument of type 'boolean' is not assignable to parameter of type '"Hello"'. -tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(75,30): error TS2345: Argument of type 'boolean' is not assignable to parameter of type '"Hello"'. -tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(76,30): error TS2345: Argument of type 'boolean' is not assignable to parameter of type '"Hello"'. -tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(77,30): error TS2345: Argument of type 'boolean' is not assignable to parameter of type '"Hello"'. -tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(78,30): error TS2345: Argument of type 'boolean' is not assignable to parameter of type '"Hello"'. -tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(79,30): error TS2345: Argument of type 'boolean' is not assignable to parameter of type '"Hello"'. +tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(75,30): error TS2345: Argument of type 'boolean' is not assignable to parameter of type '"Hello" | "World"'. + Type 'boolean' is not assignable to type '"World"'. +tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(76,30): error TS2345: Argument of type 'boolean' is not assignable to parameter of type '"Hello" | "World"'. + Type 'boolean' is not assignable to type '"World"'. +tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(77,30): error TS2345: Argument of type 'boolean' is not assignable to parameter of type '"Hello" | "World"'. + Type 'boolean' is not assignable to type '"World"'. +tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(78,30): error TS2345: Argument of type 'boolean' is not assignable to parameter of type '"Hello" | "World"'. + Type 'boolean' is not assignable to type '"World"'. +tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(79,30): error TS2345: Argument of type 'boolean' is not assignable to parameter of type '"Hello" | "World"'. + Type 'boolean' is not assignable to type '"World"'. tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(86,20): error TS2365: Operator '<' cannot be applied to types '(x: T, y: U) => T | U' and 'string'. tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(86,34): error TS1134: Variable declaration expected. tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(87,20): error TS2365: Operator '<' cannot be applied to types '(x: T, y: U) => T | U' and 'string'. @@ -63,39 +64,26 @@ tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes0 tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(102,25): error TS2345: Argument of type 'boolean' is not assignable to parameter of type '"Hello"'. tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(103,25): error TS2345: Argument of type 'boolean' is not assignable to parameter of type '"Hello"'. tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(104,25): error TS2345: Argument of type 'number' is not assignable to parameter of type '"Hello"'. -tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(107,30): error TS2345: Argument of type 'boolean' is not assignable to parameter of type '"Hello"'. -tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(108,30): error TS2345: Argument of type 'boolean' is not assignable to parameter of type '"Hello"'. -tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(109,30): error TS2345: Argument of type 'boolean' is not assignable to parameter of type '"Hello"'. -tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(110,30): error TS2345: Argument of type 'boolean' is not assignable to parameter of type '"Hello"'. -tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(111,30): error TS2345: Argument of type 'number' is not assignable to parameter of type '"Hello"'. +tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(107,30): error TS2345: Argument of type 'boolean' is not assignable to parameter of type '"Hello" | "World"'. + Type 'boolean' is not assignable to type '"World"'. +tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(108,30): error TS2345: Argument of type 'boolean' is not assignable to parameter of type '"Hello" | "World"'. + Type 'boolean' is not assignable to type '"World"'. +tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(109,30): error TS2345: Argument of type 'boolean' is not assignable to parameter of type '"Hello" | "World"'. + Type 'boolean' is not assignable to type '"World"'. +tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(110,30): error TS2345: Argument of type 'boolean' is not assignable to parameter of type '"Hello" | "World"'. + Type 'boolean' is not assignable to type '"World"'. +tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(111,30): error TS2345: Argument of type 'number' is not assignable to parameter of type '"Hello" | "World"'. + Type 'number' is not assignable to type '"World"'. -==== tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts (70 errors) ==== +==== tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts (61 errors) ==== declare function randBool(): boolean; declare function takeReturnString(str: string): string; declare function takeReturnHello(str: "Hello"): "Hello"; ~~~~~~~~~~~~~~~ !!! error TS2382: Specialized overload signature is not assignable to any non-specialized signature. - -!!! error TS4060: Return type of exported function has or is using private name ''. - ~~~~~~~ -!!! error TS1110: Type expected. declare function takeReturnHelloWorld(str: "Hello" | "World"): "Hello" | "World"; - ~~~~~~~~~~~~~~~~~~~~ -!!! error TS2382: Specialized overload signature is not assignable to any non-specialized signature. - ~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2371: A parameter initializer is only allowed in a function or constructor implementation. - ~ -!!! error TS1005: '=' expected. - -!!! error TS4060: Return type of exported function has or is using private name ''. - ~~~~~~~ -!!! error TS1110: Type expected. - ~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. - ~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. function fun1(x: T, y: T) { return randBool() ? x : y; @@ -146,19 +134,24 @@ tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes0 // Passing these as arguments should cause an error. a = takeReturnHelloWorld(a); ~ -!!! error TS2345: Argument of type 'string' is not assignable to parameter of type '"Hello"'. +!!! error TS2345: Argument of type 'string' is not assignable to parameter of type '"Hello" | "World"'. +!!! error TS2345: Type 'string' is not assignable to type '"World"'. b = takeReturnHelloWorld(b); ~ -!!! error TS2345: Argument of type 'string' is not assignable to parameter of type '"Hello"'. +!!! error TS2345: Argument of type 'string' is not assignable to parameter of type '"Hello" | "World"'. +!!! error TS2345: Type 'string' is not assignable to type '"World"'. c = takeReturnHelloWorld(c); ~ -!!! error TS2345: Argument of type 'string' is not assignable to parameter of type '"Hello"'. +!!! error TS2345: Argument of type 'string' is not assignable to parameter of type '"Hello" | "World"'. +!!! error TS2345: Type 'string' is not assignable to type '"World"'. d = takeReturnHelloWorld(d); ~ -!!! error TS2345: Argument of type 'string' is not assignable to parameter of type '"Hello"'. +!!! error TS2345: Argument of type 'string' is not assignable to parameter of type '"Hello" | "World"'. +!!! error TS2345: Type 'string' is not assignable to type '"World"'. e = takeReturnHelloWorld(e); ~ -!!! error TS2345: Argument of type 'string' is not assignable to parameter of type '"Hello"'. +!!! error TS2345: Argument of type 'string' is not assignable to parameter of type '"Hello" | "World"'. +!!! error TS2345: Type 'string' is not assignable to type '"World"'. } namespace n2 { @@ -227,19 +220,24 @@ tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes0 // Assignment from the returned value should cause an error. a = takeReturnHelloWorld(a); ~ -!!! error TS2345: Argument of type 'boolean' is not assignable to parameter of type '"Hello"'. +!!! error TS2345: Argument of type 'boolean' is not assignable to parameter of type '"Hello" | "World"'. +!!! error TS2345: Type 'boolean' is not assignable to type '"World"'. b = takeReturnHelloWorld(b); ~ -!!! error TS2345: Argument of type 'boolean' is not assignable to parameter of type '"Hello"'. +!!! error TS2345: Argument of type 'boolean' is not assignable to parameter of type '"Hello" | "World"'. +!!! error TS2345: Type 'boolean' is not assignable to type '"World"'. c = takeReturnHelloWorld(c); ~ -!!! error TS2345: Argument of type 'boolean' is not assignable to parameter of type '"Hello"'. +!!! error TS2345: Argument of type 'boolean' is not assignable to parameter of type '"Hello" | "World"'. +!!! error TS2345: Type 'boolean' is not assignable to type '"World"'. d = takeReturnHelloWorld(d); ~ -!!! error TS2345: Argument of type 'boolean' is not assignable to parameter of type '"Hello"'. +!!! error TS2345: Argument of type 'boolean' is not assignable to parameter of type '"Hello" | "World"'. +!!! error TS2345: Type 'boolean' is not assignable to type '"World"'. e = takeReturnHelloWorld(e); ~ -!!! error TS2345: Argument of type 'boolean' is not assignable to parameter of type '"Hello"'. +!!! error TS2345: Argument of type 'boolean' is not assignable to parameter of type '"Hello" | "World"'. +!!! error TS2345: Type 'boolean' is not assignable to type '"World"'. } @@ -309,17 +307,22 @@ tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes0 // Both should be valid. a = takeReturnHelloWorld(a); ~ -!!! error TS2345: Argument of type 'boolean' is not assignable to parameter of type '"Hello"'. +!!! error TS2345: Argument of type 'boolean' is not assignable to parameter of type '"Hello" | "World"'. +!!! error TS2345: Type 'boolean' is not assignable to type '"World"'. b = takeReturnHelloWorld(b); ~ -!!! error TS2345: Argument of type 'boolean' is not assignable to parameter of type '"Hello"'. +!!! error TS2345: Argument of type 'boolean' is not assignable to parameter of type '"Hello" | "World"'. +!!! error TS2345: Type 'boolean' is not assignable to type '"World"'. c = takeReturnHelloWorld(c); ~ -!!! error TS2345: Argument of type 'boolean' is not assignable to parameter of type '"Hello"'. +!!! error TS2345: Argument of type 'boolean' is not assignable to parameter of type '"Hello" | "World"'. +!!! error TS2345: Type 'boolean' is not assignable to type '"World"'. d = takeReturnHelloWorld(d); ~ -!!! error TS2345: Argument of type 'boolean' is not assignable to parameter of type '"Hello"'. +!!! error TS2345: Argument of type 'boolean' is not assignable to parameter of type '"Hello" | "World"'. +!!! error TS2345: Type 'boolean' is not assignable to type '"World"'. e = takeReturnHelloWorld(e); ~ -!!! error TS2345: Argument of type 'number' is not assignable to parameter of type '"Hello"'. +!!! error TS2345: Argument of type 'number' is not assignable to parameter of type '"Hello" | "World"'. +!!! error TS2345: Type 'number' is not assignable to type '"World"'. } \ No newline at end of file diff --git a/tests/baselines/reference/typeArgumentsWithStringLiteralTypes01.js b/tests/baselines/reference/typeArgumentsWithStringLiteralTypes01.js index 15c7cf5ef2d..e6e2b695a3b 100644 --- a/tests/baselines/reference/typeArgumentsWithStringLiteralTypes01.js +++ b/tests/baselines/reference/typeArgumentsWithStringLiteralTypes01.js @@ -113,8 +113,6 @@ namespace n3 { } //// [typeArgumentsWithStringLiteralTypes01.js] -"Hello"; -"Hello" | "World"; function fun1(x, y) { return randBool() ? x : y; } @@ -219,3 +217,34 @@ var n3; n3.d = takeReturnHelloWorld(n3.d); n3.e = takeReturnHelloWorld(n3.e); })(n3 || (n3 = {})); + + +//// [typeArgumentsWithStringLiteralTypes01.d.ts] +declare function randBool(): boolean; +declare function takeReturnString(str: string): string; +declare function takeReturnHello(str: "Hello"): "Hello"; +declare function takeReturnHelloWorld(str: "Hello" | "World"): "Hello" | "World"; +declare function fun1(x: T, y: T): T; +declare function fun2(x: T, y: U): T | U; +declare function fun3(...args: T[]): T; +declare namespace n1 { + let a: string; + let b: string; + let c: string; + let d: string; + let e: string; +} +declare namespace n2 { + let a: boolean; + let b: boolean; + let c: boolean; + let d: boolean; + let e: boolean; +} +declare namespace n3 { + let a: boolean; + let b: boolean; + let c: boolean; + let d: boolean; + let e: number; +} From dc0e368f824001d16bc7b22c7d0b8ac44305d924 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Thu, 1 Oct 2015 16:45:48 -0700 Subject: [PATCH 022/227] Make string literals valid types in type lists. --- src/compiler/parser.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 769415dd94b..a9d7f94715b 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -2387,6 +2387,7 @@ namespace ts { case SyntaxKind.OpenBracketToken: case SyntaxKind.LessThanToken: case SyntaxKind.NewKeyword: + case SyntaxKind.StringLiteral: return true; case SyntaxKind.OpenParenToken: // Only consider '(' the start of a type if followed by ')', '...', an identifier, a modifier, @@ -5446,6 +5447,7 @@ namespace ts { return parseTokenNode(); } + // TODO (drosen): Parse string literal types in JSDoc as well. return parseJSDocTypeReference(); } From 8891fba1498df42360b22faf5ac71753dcd4e0d2 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Thu, 1 Oct 2015 16:47:31 -0700 Subject: [PATCH 023/227] Accepted baselines. --- ...gumentsWithStringLiteralTypes01.errors.txt | 222 +++++------------- .../typeArgumentsWithStringLiteralTypes01.js | 46 ++-- .../typeParameterConstraints1.errors.txt | 5 +- 3 files changed, 74 insertions(+), 199 deletions(-) diff --git a/tests/baselines/reference/typeArgumentsWithStringLiteralTypes01.errors.txt b/tests/baselines/reference/typeArgumentsWithStringLiteralTypes01.errors.txt index f6421445ae1..413d2127003 100644 --- a/tests/baselines/reference/typeArgumentsWithStringLiteralTypes01.errors.txt +++ b/tests/baselines/reference/typeArgumentsWithStringLiteralTypes01.errors.txt @@ -14,69 +14,29 @@ tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes0 Type 'string' is not assignable to type '"World"'. tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(48,30): error TS2345: Argument of type 'string' is not assignable to parameter of type '"Hello" | "World"'. Type 'string' is not assignable to type '"World"'. -tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(54,20): error TS2365: Operator '<' cannot be applied to types '(x: T, y: T) => T' and 'string'. -tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(54,20): error TS2365: Operator '>' cannot be applied to types 'boolean' and 'string'. -tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(55,20): error TS2365: Operator '<' cannot be applied to types '(x: T, y: T) => T' and 'string'. -tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(55,20): error TS2365: Operator '>' cannot be applied to types 'boolean' and 'string'. -tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(56,20): error TS2365: Operator '<' cannot be applied to types '(x: T, y: U) => T | U' and 'string'. -tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(56,34): error TS1134: Variable declaration expected. -tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(57,20): error TS2365: Operator '<' cannot be applied to types '(x: T, y: U) => T | U' and 'string'. -tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(57,34): error TS1134: Variable declaration expected. -tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(58,20): error TS2365: Operator '<' cannot be applied to types '(...args: T[]) => T' and 'string'. -tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(58,20): error TS2365: Operator '>' cannot be applied to types 'boolean' and 'string'. -tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(61,26): error TS2345: Argument of type 'boolean' is not assignable to parameter of type 'string'. -tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(62,26): error TS2345: Argument of type 'boolean' is not assignable to parameter of type 'string'. -tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(63,26): error TS2345: Argument of type 'boolean' is not assignable to parameter of type 'string'. -tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(64,26): error TS2345: Argument of type 'boolean' is not assignable to parameter of type 'string'. -tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(65,26): error TS2345: Argument of type 'boolean' is not assignable to parameter of type 'string'. -tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(68,25): error TS2345: Argument of type 'boolean' is not assignable to parameter of type '"Hello"'. -tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(69,25): error TS2345: Argument of type 'boolean' is not assignable to parameter of type '"Hello"'. -tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(70,25): error TS2345: Argument of type 'boolean' is not assignable to parameter of type '"Hello"'. -tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(71,25): error TS2345: Argument of type 'boolean' is not assignable to parameter of type '"Hello"'. -tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(72,25): error TS2345: Argument of type 'boolean' is not assignable to parameter of type '"Hello"'. -tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(75,30): error TS2345: Argument of type 'boolean' is not assignable to parameter of type '"Hello" | "World"'. - Type 'boolean' is not assignable to type '"World"'. -tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(76,30): error TS2345: Argument of type 'boolean' is not assignable to parameter of type '"Hello" | "World"'. - Type 'boolean' is not assignable to type '"World"'. -tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(77,30): error TS2345: Argument of type 'boolean' is not assignable to parameter of type '"Hello" | "World"'. - Type 'boolean' is not assignable to type '"World"'. -tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(78,30): error TS2345: Argument of type 'boolean' is not assignable to parameter of type '"Hello" | "World"'. - Type 'boolean' is not assignable to type '"World"'. -tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(79,30): error TS2345: Argument of type 'boolean' is not assignable to parameter of type '"Hello" | "World"'. - Type 'boolean' is not assignable to type '"World"'. -tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(86,20): error TS2365: Operator '<' cannot be applied to types '(x: T, y: U) => T | U' and 'string'. -tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(86,34): error TS1134: Variable declaration expected. -tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(87,20): error TS2365: Operator '<' cannot be applied to types '(x: T, y: U) => T | U' and 'string'. -tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(87,34): error TS1134: Variable declaration expected. -tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(88,20): error TS2365: Operator '<' cannot be applied to types '(x: T, y: U) => T | U' and 'string'. -tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(88,34): error TS1134: Variable declaration expected. -tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(89,20): error TS2365: Operator '<' cannot be applied to types '(x: T, y: U) => T | U' and 'string'. -tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(89,34): error TS1134: Variable declaration expected. -tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(90,20): error TS2365: Operator '<' cannot be applied to types '(...args: T[]) => T' and 'string'. -tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(90,20): error TS2447: The '|' operator is not allowed for boolean types. Consider using '||' instead. -tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(93,26): error TS2345: Argument of type 'boolean' is not assignable to parameter of type 'string'. -tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(94,26): error TS2345: Argument of type 'boolean' is not assignable to parameter of type 'string'. -tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(95,26): error TS2345: Argument of type 'boolean' is not assignable to parameter of type 'string'. -tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(96,26): error TS2345: Argument of type 'boolean' is not assignable to parameter of type 'string'. -tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(97,26): error TS2345: Argument of type 'number' is not assignable to parameter of type 'string'. -tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(100,25): error TS2345: Argument of type 'boolean' is not assignable to parameter of type '"Hello"'. -tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(101,25): error TS2345: Argument of type 'boolean' is not assignable to parameter of type '"Hello"'. -tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(102,25): error TS2345: Argument of type 'boolean' is not assignable to parameter of type '"Hello"'. -tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(103,25): error TS2345: Argument of type 'boolean' is not assignable to parameter of type '"Hello"'. -tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(104,25): error TS2345: Argument of type 'number' is not assignable to parameter of type '"Hello"'. -tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(107,30): error TS2345: Argument of type 'boolean' is not assignable to parameter of type '"Hello" | "World"'. - Type 'boolean' is not assignable to type '"World"'. -tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(108,30): error TS2345: Argument of type 'boolean' is not assignable to parameter of type '"Hello" | "World"'. - Type 'boolean' is not assignable to type '"World"'. -tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(109,30): error TS2345: Argument of type 'boolean' is not assignable to parameter of type '"Hello" | "World"'. - Type 'boolean' is not assignable to type '"World"'. -tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(110,30): error TS2345: Argument of type 'boolean' is not assignable to parameter of type '"Hello" | "World"'. - Type 'boolean' is not assignable to type '"World"'. -tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(111,30): error TS2345: Argument of type 'number' is not assignable to parameter of type '"Hello" | "World"'. - Type 'number' is not assignable to type '"World"'. +tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(55,34): error TS2345: Argument of type 'string' is not assignable to parameter of type '"Hello"'. +tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(57,43): error TS2345: Argument of type 'string' is not assignable to parameter of type '"Hello"'. +tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(58,34): error TS2345: Argument of type 'string' is not assignable to parameter of type '"Hello"'. +tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(61,5): error TS2322: Type 'string' is not assignable to type '"Hello"'. +tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(63,5): error TS2322: Type 'string' is not assignable to type '"Hello"'. +tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(75,5): error TS2322: Type '"Hello" | "World"' is not assignable to type '"Hello"'. + Type '"World"' is not assignable to type '"Hello"'. +tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(77,5): error TS2322: Type '"Hello" | "World"' is not assignable to type '"Hello"'. + Type '"World"' is not assignable to type '"Hello"'. +tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(87,43): error TS2345: Argument of type 'string' is not assignable to parameter of type '"Hello"'. +tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(88,43): error TS2345: Argument of type 'string' is not assignable to parameter of type '"World"'. +tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(89,43): error TS2345: Argument of type 'string' is not assignable to parameter of type '"World"'. +tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(93,5): error TS2322: Type 'string' is not assignable to type '"Hello" | "World"'. + Type 'string' is not assignable to type '"World"'. +tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(97,5): error TS2322: Type 'string' is not assignable to type '"Hello" | "World"'. + Type 'string' is not assignable to type '"World"'. +tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(100,25): error TS2345: Argument of type '"Hello" | "World"' is not assignable to parameter of type '"Hello"'. + Type '"World"' is not assignable to type '"Hello"'. +tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(104,25): error TS2345: Argument of type '"Hello" | "World"' is not assignable to parameter of type '"Hello"'. + Type '"World"' is not assignable to type '"Hello"'. -==== tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts (61 errors) ==== +==== tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts (25 errors) ==== declare function randBool(): boolean; declare function takeReturnString(str: string): string; @@ -158,86 +118,47 @@ tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes0 // The following (regardless of errors) should come back typed // as "Hello" (or "Hello" | "Hello"). export let a = fun1<"Hello">("Hello", "Hello"); - ~~~~~~~~~~~~ -!!! error TS2365: Operator '<' cannot be applied to types '(x: T, y: T) => T' and 'string'. - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2365: Operator '>' cannot be applied to types 'boolean' and 'string'. export let b = fun1<"Hello">("Hello", "World"); - ~~~~~~~~~~~~ -!!! error TS2365: Operator '<' cannot be applied to types '(x: T, y: T) => T' and 'string'. - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2365: Operator '>' cannot be applied to types 'boolean' and 'string'. + ~~~~~~~ +!!! error TS2345: Argument of type 'string' is not assignable to parameter of type '"Hello"'. export let c = fun2<"Hello", "Hello">("Hello", "Hello"); - ~~~~~~~~~~~~ -!!! error TS2365: Operator '<' cannot be applied to types '(x: T, y: U) => T | U' and 'string'. - ~~~~~~~ -!!! error TS1134: Variable declaration expected. export let d = fun2<"Hello", "Hello">("Hello", "World"); - ~~~~~~~~~~~~ -!!! error TS2365: Operator '<' cannot be applied to types '(x: T, y: U) => T | U' and 'string'. - ~~~~~~~ -!!! error TS1134: Variable declaration expected. + ~~~~~~~ +!!! error TS2345: Argument of type 'string' is not assignable to parameter of type '"Hello"'. export let e = fun3<"Hello">("Hello", "World"); - ~~~~~~~~~~~~ -!!! error TS2365: Operator '<' cannot be applied to types '(...args: T[]) => T' and 'string'. - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2365: Operator '>' cannot be applied to types 'boolean' and 'string'. + ~~~~~~~ +!!! error TS2345: Argument of type 'string' is not assignable to parameter of type '"Hello"'. // Assignment from the returned value should cause an error. a = takeReturnString(a); - ~ -!!! error TS2345: Argument of type 'boolean' is not assignable to parameter of type 'string'. + ~ +!!! error TS2322: Type 'string' is not assignable to type '"Hello"'. b = takeReturnString(b); - ~ -!!! error TS2345: Argument of type 'boolean' is not assignable to parameter of type 'string'. c = takeReturnString(c); - ~ -!!! error TS2345: Argument of type 'boolean' is not assignable to parameter of type 'string'. + ~ +!!! error TS2322: Type 'string' is not assignable to type '"Hello"'. d = takeReturnString(d); - ~ -!!! error TS2345: Argument of type 'boolean' is not assignable to parameter of type 'string'. e = takeReturnString(e); - ~ -!!! error TS2345: Argument of type 'boolean' is not assignable to parameter of type 'string'. // Should be valid a = takeReturnHello(a); - ~ -!!! error TS2345: Argument of type 'boolean' is not assignable to parameter of type '"Hello"'. b = takeReturnHello(b); - ~ -!!! error TS2345: Argument of type 'boolean' is not assignable to parameter of type '"Hello"'. c = takeReturnHello(c); - ~ -!!! error TS2345: Argument of type 'boolean' is not assignable to parameter of type '"Hello"'. d = takeReturnHello(d); - ~ -!!! error TS2345: Argument of type 'boolean' is not assignable to parameter of type '"Hello"'. e = takeReturnHello(e); - ~ -!!! error TS2345: Argument of type 'boolean' is not assignable to parameter of type '"Hello"'. // Assignment from the returned value should cause an error. a = takeReturnHelloWorld(a); - ~ -!!! error TS2345: Argument of type 'boolean' is not assignable to parameter of type '"Hello" | "World"'. -!!! error TS2345: Type 'boolean' is not assignable to type '"World"'. + ~ +!!! error TS2322: Type '"Hello" | "World"' is not assignable to type '"Hello"'. +!!! error TS2322: Type '"World"' is not assignable to type '"Hello"'. b = takeReturnHelloWorld(b); - ~ -!!! error TS2345: Argument of type 'boolean' is not assignable to parameter of type '"Hello" | "World"'. -!!! error TS2345: Type 'boolean' is not assignable to type '"World"'. c = takeReturnHelloWorld(c); - ~ -!!! error TS2345: Argument of type 'boolean' is not assignable to parameter of type '"Hello" | "World"'. -!!! error TS2345: Type 'boolean' is not assignable to type '"World"'. + ~ +!!! error TS2322: Type '"Hello" | "World"' is not assignable to type '"Hello"'. +!!! error TS2322: Type '"World"' is not assignable to type '"Hello"'. d = takeReturnHelloWorld(d); - ~ -!!! error TS2345: Argument of type 'boolean' is not assignable to parameter of type '"Hello" | "World"'. -!!! error TS2345: Type 'boolean' is not assignable to type '"World"'. e = takeReturnHelloWorld(e); - ~ -!!! error TS2345: Argument of type 'boolean' is not assignable to parameter of type '"Hello" | "World"'. -!!! error TS2345: Type 'boolean' is not assignable to type '"World"'. } @@ -245,84 +166,47 @@ tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes0 // The following (regardless of errors) should come back typed // as "Hello" | "World" (or "World" | "Hello"). export let a = fun2<"Hello", "World">("Hello", "World"); - ~~~~~~~~~~~~ -!!! error TS2365: Operator '<' cannot be applied to types '(x: T, y: U) => T | U' and 'string'. - ~~~~~~~ -!!! error TS1134: Variable declaration expected. export let b = fun2<"Hello", "World">("World", "Hello"); - ~~~~~~~~~~~~ -!!! error TS2365: Operator '<' cannot be applied to types '(x: T, y: U) => T | U' and 'string'. - ~~~~~~~ -!!! error TS1134: Variable declaration expected. + ~~~~~~~ +!!! error TS2345: Argument of type 'string' is not assignable to parameter of type '"Hello"'. export let c = fun2<"World", "Hello">("Hello", "Hello"); - ~~~~~~~~~~~~ -!!! error TS2365: Operator '<' cannot be applied to types '(x: T, y: U) => T | U' and 'string'. - ~~~~~~~ -!!! error TS1134: Variable declaration expected. + ~~~~~~~ +!!! error TS2345: Argument of type 'string' is not assignable to parameter of type '"World"'. export let d = fun2<"World", "Hello">("World", "World"); - ~~~~~~~~~~~~ -!!! error TS2365: Operator '<' cannot be applied to types '(x: T, y: U) => T | U' and 'string'. - ~~~~~~~ -!!! error TS1134: Variable declaration expected. + ~~~~~~~ +!!! error TS2345: Argument of type 'string' is not assignable to parameter of type '"World"'. export let e = fun3<"Hello" | "World">("Hello", "World"); - ~~~~~~~~~~~~ -!!! error TS2365: Operator '<' cannot be applied to types '(...args: T[]) => T' and 'string'. - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2447: The '|' operator is not allowed for boolean types. Consider using '||' instead. // Assignment from the returned value should cause an error. a = takeReturnString(a); - ~ -!!! error TS2345: Argument of type 'boolean' is not assignable to parameter of type 'string'. + ~ +!!! error TS2322: Type 'string' is not assignable to type '"Hello" | "World"'. +!!! error TS2322: Type 'string' is not assignable to type '"World"'. b = takeReturnString(b); - ~ -!!! error TS2345: Argument of type 'boolean' is not assignable to parameter of type 'string'. c = takeReturnString(c); - ~ -!!! error TS2345: Argument of type 'boolean' is not assignable to parameter of type 'string'. d = takeReturnString(d); - ~ -!!! error TS2345: Argument of type 'boolean' is not assignable to parameter of type 'string'. e = takeReturnString(e); - ~ -!!! error TS2345: Argument of type 'number' is not assignable to parameter of type 'string'. + ~ +!!! error TS2322: Type 'string' is not assignable to type '"Hello" | "World"'. +!!! error TS2322: Type 'string' is not assignable to type '"World"'. // Passing these as arguments should cause an error. a = takeReturnHello(a); ~ -!!! error TS2345: Argument of type 'boolean' is not assignable to parameter of type '"Hello"'. +!!! error TS2345: Argument of type '"Hello" | "World"' is not assignable to parameter of type '"Hello"'. +!!! error TS2345: Type '"World"' is not assignable to type '"Hello"'. b = takeReturnHello(b); - ~ -!!! error TS2345: Argument of type 'boolean' is not assignable to parameter of type '"Hello"'. c = takeReturnHello(c); - ~ -!!! error TS2345: Argument of type 'boolean' is not assignable to parameter of type '"Hello"'. d = takeReturnHello(d); - ~ -!!! error TS2345: Argument of type 'boolean' is not assignable to parameter of type '"Hello"'. e = takeReturnHello(e); ~ -!!! error TS2345: Argument of type 'number' is not assignable to parameter of type '"Hello"'. +!!! error TS2345: Argument of type '"Hello" | "World"' is not assignable to parameter of type '"Hello"'. +!!! error TS2345: Type '"World"' is not assignable to type '"Hello"'. // Both should be valid. a = takeReturnHelloWorld(a); - ~ -!!! error TS2345: Argument of type 'boolean' is not assignable to parameter of type '"Hello" | "World"'. -!!! error TS2345: Type 'boolean' is not assignable to type '"World"'. b = takeReturnHelloWorld(b); - ~ -!!! error TS2345: Argument of type 'boolean' is not assignable to parameter of type '"Hello" | "World"'. -!!! error TS2345: Type 'boolean' is not assignable to type '"World"'. c = takeReturnHelloWorld(c); - ~ -!!! error TS2345: Argument of type 'boolean' is not assignable to parameter of type '"Hello" | "World"'. -!!! error TS2345: Type 'boolean' is not assignable to type '"World"'. d = takeReturnHelloWorld(d); - ~ -!!! error TS2345: Argument of type 'boolean' is not assignable to parameter of type '"Hello" | "World"'. -!!! error TS2345: Type 'boolean' is not assignable to type '"World"'. e = takeReturnHelloWorld(e); - ~ -!!! error TS2345: Argument of type 'number' is not assignable to parameter of type '"Hello" | "World"'. -!!! error TS2345: Type 'number' is not assignable to type '"World"'. } \ No newline at end of file diff --git a/tests/baselines/reference/typeArgumentsWithStringLiteralTypes01.js b/tests/baselines/reference/typeArgumentsWithStringLiteralTypes01.js index e6e2b695a3b..c07dd225396 100644 --- a/tests/baselines/reference/typeArgumentsWithStringLiteralTypes01.js +++ b/tests/baselines/reference/typeArgumentsWithStringLiteralTypes01.js @@ -159,13 +159,11 @@ var n2; (function (n2) { // The following (regardless of errors) should come back typed // as "Hello" (or "Hello" | "Hello"). - n2.a = fun1 < "Hello" > ("Hello", "Hello"); - n2.b = fun1 < "Hello" > ("Hello", "World"); - n2.c = fun2 < "Hello"; - "Hello" > ("Hello", "Hello"); - n2.d = fun2 < "Hello"; - "Hello" > ("Hello", "World"); - n2.e = fun3 < "Hello" > ("Hello", "World"); + n2.a = fun1("Hello", "Hello"); + n2.b = fun1("Hello", "World"); + n2.c = fun2("Hello", "Hello"); + n2.d = fun2("Hello", "World"); + n2.e = fun3("Hello", "World"); // Assignment from the returned value should cause an error. n2.a = takeReturnString(n2.a); n2.b = takeReturnString(n2.b); @@ -189,15 +187,11 @@ var n3; (function (n3) { // The following (regardless of errors) should come back typed // as "Hello" | "World" (or "World" | "Hello"). - n3.a = fun2 < "Hello"; - "World" > ("Hello", "World"); - n3.b = fun2 < "Hello"; - "World" > ("World", "Hello"); - n3.c = fun2 < "World"; - "Hello" > ("Hello", "Hello"); - n3.d = fun2 < "World"; - "Hello" > ("World", "World"); - n3.e = fun3 < "Hello" | "World" > ("Hello", "World"); + n3.a = fun2("Hello", "World"); + n3.b = fun2("World", "Hello"); + n3.c = fun2("Hello", "Hello"); + n3.d = fun2("World", "World"); + n3.e = fun3("Hello", "World"); // Assignment from the returned value should cause an error. n3.a = takeReturnString(n3.a); n3.b = takeReturnString(n3.b); @@ -235,16 +229,16 @@ declare namespace n1 { let e: string; } declare namespace n2 { - let a: boolean; - let b: boolean; - let c: boolean; - let d: boolean; - let e: boolean; + let a: "Hello"; + let b: any; + let c: "Hello"; + let d: any; + let e: any; } declare namespace n3 { - let a: boolean; - let b: boolean; - let c: boolean; - let d: boolean; - let e: number; + let a: "Hello" | "World"; + let b: any; + let c: any; + let d: any; + let e: "Hello" | "World"; } diff --git a/tests/baselines/reference/typeParameterConstraints1.errors.txt b/tests/baselines/reference/typeParameterConstraints1.errors.txt index f30fd4f6700..e837e19317d 100644 --- a/tests/baselines/reference/typeParameterConstraints1.errors.txt +++ b/tests/baselines/reference/typeParameterConstraints1.errors.txt @@ -1,12 +1,11 @@ tests/cases/compiler/typeParameterConstraints1.ts(6,25): error TS2304: Cannot find name 'hm'. -tests/cases/compiler/typeParameterConstraints1.ts(8,25): error TS1110: Type expected. tests/cases/compiler/typeParameterConstraints1.ts(9,25): error TS1110: Type expected. tests/cases/compiler/typeParameterConstraints1.ts(10,26): error TS1110: Type expected. tests/cases/compiler/typeParameterConstraints1.ts(11,26): error TS1110: Type expected. tests/cases/compiler/typeParameterConstraints1.ts(12,26): error TS2304: Cannot find name 'undefined'. -==== tests/cases/compiler/typeParameterConstraints1.ts (6 errors) ==== +==== tests/cases/compiler/typeParameterConstraints1.ts (5 errors) ==== function foo1(test: T) { } function foo2(test: T) { } function foo3(test: T) { } @@ -17,8 +16,6 @@ tests/cases/compiler/typeParameterConstraints1.ts(12,26): error TS2304: Cannot f !!! error TS2304: Cannot find name 'hm'. function foo7(test: T) { } // valid function foo8(test: T) { } - ~~ -!!! error TS1110: Type expected. function foo9 (test: T) { } ~ !!! error TS1110: Type expected. From 82545ce8544cf0e24b278fa11c8afc8116de1c3c Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Thu, 1 Oct 2015 16:58:03 -0700 Subject: [PATCH 024/227] Added test for string types in tuples. --- .../stringLiteralTypesAndTuples01.ts | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 tests/cases/conformance/types/stringLiteral/stringLiteralTypesAndTuples01.ts diff --git a/tests/cases/conformance/types/stringLiteral/stringLiteralTypesAndTuples01.ts b/tests/cases/conformance/types/stringLiteral/stringLiteralTypesAndTuples01.ts new file mode 100644 index 00000000000..7ac9aa3b427 --- /dev/null +++ b/tests/cases/conformance/types/stringLiteral/stringLiteralTypesAndTuples01.ts @@ -0,0 +1,20 @@ +// @declaration: true + +// Should all be strings. +let [hello, brave, newish, world] = ["Hello", "Brave", "New", "World"]; + +type RexOrRaptor = "t-rex" | "raptor" +let [im, a, dinosaur]: ["I'm", "a", Dinosaur] = ['I\'m', 'a', 't-rex']; + +rawr(dinosaur); + +function rawr(dino: RexOrRaptor) { + if (dino === "t-rex") { + return "ROAAAAR!"; + } + if (dino === "raptor") { + return "yip yip!"; + } + + throw "Unexpected " + dino; +} \ No newline at end of file From ed927d8cf642065806f28bdc715f44cfc704872e Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Thu, 1 Oct 2015 16:58:17 -0700 Subject: [PATCH 025/227] Accepted baselines. --- .../stringLiteralTypesAndTuples01.errors.txt | 32 ++++++++++++++ .../stringLiteralTypesAndTuples01.js | 42 +++++++++++++++++++ 2 files changed, 74 insertions(+) create mode 100644 tests/baselines/reference/stringLiteralTypesAndTuples01.errors.txt create mode 100644 tests/baselines/reference/stringLiteralTypesAndTuples01.js diff --git a/tests/baselines/reference/stringLiteralTypesAndTuples01.errors.txt b/tests/baselines/reference/stringLiteralTypesAndTuples01.errors.txt new file mode 100644 index 00000000000..849f4922e45 --- /dev/null +++ b/tests/baselines/reference/stringLiteralTypesAndTuples01.errors.txt @@ -0,0 +1,32 @@ +tests/cases/conformance/types/stringLiteral/stringLiteralTypesAndTuples01.ts(6,5): error TS2322: Type '[string, string, string]' is not assignable to type '["I'm", "a", any]'. + Types of property '0' are incompatible. + Type 'string' is not assignable to type '"I'm"'. +tests/cases/conformance/types/stringLiteral/stringLiteralTypesAndTuples01.ts(6,37): error TS2304: Cannot find name 'Dinosaur'. + + +==== tests/cases/conformance/types/stringLiteral/stringLiteralTypesAndTuples01.ts (2 errors) ==== + + // Should all be strings. + let [hello, brave, newish, world] = ["Hello", "Brave", "New", "World"]; + + type RexOrRaptor = "t-rex" | "raptor" + let [im, a, dinosaur]: ["I'm", "a", Dinosaur] = ['I\'m', 'a', 't-rex']; + ~~~~~~~~~~~~~~~~~ +!!! error TS2322: Type '[string, string, string]' is not assignable to type '["I'm", "a", any]'. +!!! error TS2322: Types of property '0' are incompatible. +!!! error TS2322: Type 'string' is not assignable to type '"I'm"'. + ~~~~~~~~ +!!! error TS2304: Cannot find name 'Dinosaur'. + + rawr(dinosaur); + + function rawr(dino: RexOrRaptor) { + if (dino === "t-rex") { + return "ROAAAAR!"; + } + if (dino === "raptor") { + return "yip yip!"; + } + + throw "Unexpected " + dino; + } \ No newline at end of file diff --git a/tests/baselines/reference/stringLiteralTypesAndTuples01.js b/tests/baselines/reference/stringLiteralTypesAndTuples01.js new file mode 100644 index 00000000000..66e57b1eea5 --- /dev/null +++ b/tests/baselines/reference/stringLiteralTypesAndTuples01.js @@ -0,0 +1,42 @@ +//// [stringLiteralTypesAndTuples01.ts] + +// Should all be strings. +let [hello, brave, newish, world] = ["Hello", "Brave", "New", "World"]; + +type RexOrRaptor = "t-rex" | "raptor" +let [im, a, dinosaur]: ["I'm", "a", Dinosaur] = ['I\'m', 'a', 't-rex']; + +rawr(dinosaur); + +function rawr(dino: RexOrRaptor) { + if (dino === "t-rex") { + return "ROAAAAR!"; + } + if (dino === "raptor") { + return "yip yip!"; + } + + throw "Unexpected " + dino; +} + +//// [stringLiteralTypesAndTuples01.js] +// Should all be strings. +var _a = ["Hello", "Brave", "New", "World"], hello = _a[0], brave = _a[1], newish = _a[2], world = _a[3]; +var _b = ['I\'m', 'a', 't-rex'], im = _b[0], a = _b[1], dinosaur = _b[2]; +rawr(dinosaur); +function rawr(dino) { + if (dino === "t-rex") { + return "ROAAAAR!"; + } + if (dino === "raptor") { + return "yip yip!"; + } + throw "Unexpected " + dino; +} + + +//// [stringLiteralTypesAndTuples01.d.ts] +declare let hello: string, brave: string, newish: string, world: string; +declare type RexOrRaptor = "t-rex" | "raptor"; +declare let im: "I'm", a: "a", dinosaur: any; +declare function rawr(dino: RexOrRaptor): string; From 122753b50a4f87981dccda3a0dc65d0dfb3250fb Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Thu, 1 Oct 2015 19:23:12 -0700 Subject: [PATCH 026/227] sourcemap correctness --- src/compiler/emitter.ts | 17 ++++++++++---- src/compiler/program.ts | 51 ++++++++++++++++++++++------------------- 2 files changed, 39 insertions(+), 29 deletions(-) diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index df2687768fc..3a4b9a4a3bf 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -473,12 +473,14 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi emitSourceFile(root); } else { - forEach(host.getSourceFiles(), emitEmitHelpers); + if (modulekind) { + forEach(host.getSourceFiles(), emitEmitHelpers); + } forEach(host.getSourceFiles(), sourceFile => { if (!isExternalModuleOrDeclarationFile(sourceFile)) { emitSourceFile(sourceFile); } - else if (isExternalModule(sourceFile)) { + else if (modulekind && isExternalModule(sourceFile)) { emitConcatenatedModule(sourceFile); } }); @@ -499,7 +501,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi exportFunctionForFile = undefined; let canonicalName = resolveToSemiabsolutePath(sourceFile.fileName); sourceFile.moduleName = sourceFile.moduleName || canonicalName; - bundleEmitDelegates[modulekind](sourceFile, 0, /*resolvePath*/true); + emit(sourceFile); } function resolveToSemiabsolutePath(path: string): string { @@ -7051,8 +7053,13 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi let startIndex = emitDirectivePrologues(node.statements, /*startWithNewLine*/ false); if (isExternalModule(node) || compilerOptions.isolatedModules) { - let emitModule = moduleEmitDelegates[modulekind] || moduleEmitDelegates[ModuleKind.CommonJS]; - emitModule(node, startIndex); + if (root) { + let emitModule = moduleEmitDelegates[modulekind] || moduleEmitDelegates[ModuleKind.CommonJS]; + emitModule(node, startIndex); + } + else { + bundleEmitDelegates[modulekind](node, startIndex, /*resolvePath*/true); + } } else { externalImports = undefined; diff --git a/src/compiler/program.ts b/src/compiler/program.ts index b595d48dc57..f54906d85ee 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -377,6 +377,29 @@ namespace ts { } } + // there has to be common source directory if user specified --outdir || --sourceRoot + // if user specified --mapRoot, there needs to be common source directory if there would be multiple files being emitted + if (options.outDir || // there is --outDir specified + options.sourceRoot || // there is --sourceRoot specified + options.mapRoot) { // there is --mapRoot specified + + if (options.rootDir && checkSourceFilesBelongToPath(files, options.rootDir)) { + // If a rootDir is specified and is valid use it as the commonSourceDirectory + commonSourceDirectory = getNormalizedAbsolutePath(options.rootDir, host.getCurrentDirectory()); + } + else { + // Compute the commonSourceDirectory from the input files + commonSourceDirectory = computeCommonSourceDirectory(files); + } + + if (commonSourceDirectory && commonSourceDirectory[commonSourceDirectory.length - 1] !== directorySeparator) { + // Make sure directory path ends with directory separator so this string can directly + // used to replace with "" to get the relative path of the source file and the relative path doesn't + // start with / making it rooted path + commonSourceDirectory += directorySeparator; + } + } + verifyCompilerOptions(); // unconditionally set oldProgram to undefined to prevent it from being captured in closure @@ -934,6 +957,10 @@ namespace ts { } }); + if (!commonPathComponents) { // Can happen when all input files are .d.ts files + return currentDirectory; + } + return getNormalizedPathFromPathComponents(commonPathComponents); } @@ -1036,30 +1063,6 @@ namespace ts { programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Cannot_compile_modules_into_es6_when_targeting_ES5_or_lower)); } - // there has to be common source directory if user specified --outdir || --sourceRoot - // if user specified --mapRoot, there needs to be common source directory if there would be multiple files being emitted - if (options.outDir || // there is --outDir specified - options.sourceRoot || // there is --sourceRoot specified - (options.mapRoot && // there is --mapRoot specified and there would be multiple js files generated - (!outFile || firstExternalModuleSourceFile !== undefined))) { - - if (options.rootDir && checkSourceFilesBelongToPath(files, options.rootDir)) { - // If a rootDir is specified and is valid use it as the commonSourceDirectory - commonSourceDirectory = getNormalizedAbsolutePath(options.rootDir, host.getCurrentDirectory()); - } - else { - // Compute the commonSourceDirectory from the input files - commonSourceDirectory = computeCommonSourceDirectory(files); - } - - if (commonSourceDirectory && commonSourceDirectory[commonSourceDirectory.length - 1] !== directorySeparator) { - // Make sure directory path ends with directory separator so this string can directly - // used to replace with "" to get the relative path of the source file and the relative path doesn't - // start with / making it rooted path - commonSourceDirectory += directorySeparator; - } - } - if (options.noEmit) { if (options.out) { programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_with_option_1, "noEmit", "out")); From ca0d580a14e019a05eac41bd7f21a36af0feafaa Mon Sep 17 00:00:00 2001 From: Vladimir Matveev Date: Thu, 1 Oct 2015 23:20:24 -0700 Subject: [PATCH 027/227] merge with master, fix linter issues --- src/compiler/binder.ts | 70 ++++++++++++++++++++--------------------- src/compiler/checker.ts | 2 +- src/compiler/types.ts | 10 +++--- 3 files changed, 41 insertions(+), 41 deletions(-) diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index 57e24faa6bf..8211509f580 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -9,14 +9,14 @@ namespace ts { Instantiated = 1, ConstEnumOnly = 2 } - + const enum Reachability { Unintialized = 1 << 0, Reachable = 1 << 1, Unreachable = 1 << 2, ReportedUnreachable = 1 << 3 } - + function or(state1: Reachability, state2: Reachability): Reachability { return (state1 | state2) & Reachability.Reachable ? Reachability.Reachable @@ -111,7 +111,7 @@ namespace ts { let labelStack: Reachability[]; let labelIndexMap: Map; let implicitLabels: number[]; - + // 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). @@ -365,18 +365,18 @@ namespace ts { parent = saveParent; blockScopeContainer = savedBlockScopeContainer; } - + function shouldSaveReachabilityState(n: Node): boolean { return n.kind === SyntaxKind.SourceFile || n.kind === SyntaxKind.ModuleBlock || isFunctionLike(n); } - + function bindWithReachabilityChecks(node: Node): void { let savedReachabilityState: Reachability; let savedLabelStack: Reachability[]; let savedLabels: Map; let savedImplicitLabels: number[]; let savedHasExplicitReturn: boolean; - + let saveState = shouldSaveReachabilityState(node); if (saveState) { savedReachabilityState = currentReachabilityState; @@ -384,7 +384,7 @@ namespace ts { savedLabels = labelIndexMap; savedImplicitLabels = implicitLabels; savedHasExplicitReturn = hasExplicitReturn; - + currentReachabilityState = Reachability.Reachable; hasExplicitReturn = false; labelStack = labelIndexMap = implicitLabels = undefined; @@ -393,7 +393,7 @@ namespace ts { if (!bindReachableStatement(node)) { forEachChild(node, bind); } - + if (currentReachabilityState === Reachability.Reachable && isFunctionLike(node) && nodeIsPresent((node).body)) { node.flags |= NodeFlags.HasImplicitReturn; if (hasExplicitReturn) { @@ -451,19 +451,19 @@ namespace ts { } function bindWhileStatement(n: WhileStatement): boolean { - const preWhileState = + const preWhileState = n.expression.kind === SyntaxKind.FalseKeyword ? Reachability.Unreachable : currentReachabilityState; - const postWhileState = + const postWhileState = n.expression.kind === SyntaxKind.TrueKeyword ? Reachability.Unreachable : currentReachabilityState; // bind expressions (don't affect reachability) bind(n.expression); - + currentReachabilityState = preWhileState; const postWhileLabel = pushImplicitLabel(); bind(n.statement); - popImplicitLabel(postWhileLabel, postWhileState) - + popImplicitLabel(postWhileLabel, postWhileState); + return true; } @@ -480,7 +480,7 @@ namespace ts { return true; } - + function bindForStatement(n: ForStatement): boolean { const preForState = currentReachabilityState; const postForLabel = pushImplicitLabel(); @@ -505,7 +505,7 @@ namespace ts { function bindForInOrForOfStatement(n: ForInStatement | ForOfStatement): boolean { const preStatementState = currentReachabilityState; const postStatementLabel = pushImplicitLabel(); - + // bind expressions (don't affect reachability) bind(n.initializer); bind(n.expression); @@ -566,7 +566,7 @@ namespace ts { currentReachabilityState = Reachability.Unreachable; return true; - } + } function bindTryStatement(n: TryStatement): boolean { // catch\finally blocks has the same reachability as try block @@ -597,7 +597,7 @@ namespace ts { bind(n.expression); bind(n.caseBlock); - + const hasDefault = forEach(n.caseBlock.clauses, c => c.kind === SyntaxKind.DefaultClause); // post switch state is unreachable if switch is exaustive (has a default case ) and does not have fallthrough from the last case @@ -1055,7 +1055,7 @@ namespace ts { if (!node) { return; } - + node.parent = parent; let savedInStrictMode = inStrictMode; @@ -1365,46 +1365,46 @@ namespace ts { function pushNamedLabel(name: Identifier): boolean { initializeReachabilityStateIfNecessary(); - + if (hasProperty(labelIndexMap, name.text)) { return false; } labelIndexMap[name.text] = labelStack.push(Reachability.Unintialized) - 1; return true; } - + function pushImplicitLabel(): number { initializeReachabilityStateIfNecessary(); - + let index = labelStack.push(Reachability.Unintialized) - 1; implicitLabels.push(index); return index; } - + function popNamedLabel(label: Identifier, outerState: Reachability): void { initializeReachabilityStateIfNecessary(); - + let index = labelIndexMap[label.text]; Debug.assert(index !== undefined); Debug.assert(labelStack.length == index + 1); - + labelIndexMap[label.text] = undefined; - + setCurrentStateAtLabel(labelStack.pop(), outerState, label); } - + function popImplicitLabel(implicitLabelIndex: number, outerState: Reachability): void { initializeReachabilityStateIfNecessary(); - + Debug.assert(labelStack.length === implicitLabelIndex + 1, `Label stack: ${labelStack.length}, index:${implicitLabelIndex}`); let i = implicitLabels.pop(); Debug.assert(implicitLabelIndex === i, `i: ${i}, index: ${implicitLabelIndex}`); setCurrentStateAtLabel(labelStack.pop(), outerState, /*name*/ undefined); } - + function setCurrentStateAtLabel(innerMergedState: Reachability, outerState: Reachability, label: Identifier): void { initializeReachabilityStateIfNecessary(); - + if (innerMergedState === Reachability.Unintialized) { if (label && options.noUnusedLabels) { file.bindDiagnostics.push(createDiagnosticForNode(label, Diagnostics.Unused_label)); @@ -1415,10 +1415,10 @@ namespace ts { currentReachabilityState = or(innerMergedState, outerState); } } - + function jumpToLabel(label: Identifier, outerState: Reachability): void { initializeReachabilityStateIfNecessary(); - + const index = label ? labelIndexMap[label.text] : lastOrUndefined(implicitLabels); if (index === undefined) { // reference to unknown label or @@ -1444,7 +1444,7 @@ namespace ts { if (reportError) { currentReachabilityState = Reachability.ReportedUnreachable; - + // 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 @@ -1453,15 +1453,15 @@ namespace ts { // - 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 = + // On the other side we do want to report errors on non-initialized 'lets' because of TDZ + const reportUnreachableCode = options.noUnreachableCode && !isInAmbientContext(node) && ( node.kind !== SyntaxKind.VariableStatement || getCombinedNodeFlags((node).declarationList) & NodeFlags.BlockScoped || forEach((node).declarationList.declarations, d => d.initializer) - ) + ); if (reportUnreachableCode) { file.bindDiagnostics.push(createDiagnosticForNode(node, Diagnostics.Unreachable_code_detected)); diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 01f240a80ca..f31beccf87d 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -9553,7 +9553,7 @@ namespace ts { if (nodeIsMissing(func.body) || func.body.kind !== SyntaxKind.Block || !(func.flags & NodeFlags.HasImplicitReturn)) { return; } - + if (func.flags & NodeFlags.HasExplicitReturn) { if (compilerOptions.noImplicitReturns) { error(func.type, Diagnostics.Not_all_code_paths_return_a_value); diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 24a6b11eef0..a93a4587c1b 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -2074,11 +2074,11 @@ namespace ts { experimentalDecorators?: boolean; experimentalAsyncFunctions?: boolean; emitDecoratorMetadata?: boolean; - moduleResolution?: ModuleResolutionKind, - noUnusedLabels?: boolean, - noImplicitReturns?: boolean, - noFallthroughCasesInSwitch?: boolean, - noUnreachableCode?: boolean, + moduleResolution?: ModuleResolutionKind; + noUnusedLabels?: boolean; + noImplicitReturns?: boolean; + noFallthroughCasesInSwitch?: boolean; + noUnreachableCode?: boolean; /* @internal */ stripInternal?: boolean; // Skip checking lib.d.ts to help speed up tests. From 8e409f34c71ef55b988bd3b68cbffe2ebc51fdd0 Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Fri, 2 Oct 2015 13:22:36 -0700 Subject: [PATCH 028/227] new baselines for sourcemaps tests (given that modules can now get emitted into single out) --- src/compiler/emitter.ts | 2 +- .../reference/getEmitOutputMapRoots.baseline | 4 +- .../amd/bin/test.d.ts | 13 - .../amd/bin/test.js | 23 - .../amd/bin/test.js.map | 2 +- ...edSubfolderSpecifyOutputFile.sourcemap.txt | 246 ++++++-- .../node/bin/test.d.ts | 13 - .../node/bin/test.js | 23 - .../node/bin/test.js.map | 2 +- ...edSubfolderSpecifyOutputFile.sourcemap.txt | 74 +-- .../amd/bin/outAndOutDirFile.d.ts | 13 - .../amd/bin/outAndOutDirFile.js | 23 - .../amd/bin/outAndOutDirFile.js.map | 2 +- ...OutputFileAndOutputDirectory.sourcemap.txt | 246 ++++++-- .../node/bin/outAndOutDirFile.d.ts | 13 - .../node/bin/outAndOutDirFile.js | 23 - .../node/bin/outAndOutDirFile.js.map | 2 +- ...OutputFileAndOutputDirectory.sourcemap.txt | 74 +-- .../amd/bin/test.d.ts | 0 .../amd/bin/test.js | 1 - .../amd/bin/test.js.map | 2 +- ...MultifolderSpecifyOutputFile.sourcemap.txt | 553 +++++++++++++++++- .../node/bin/test.d.ts | 0 .../node/bin/test.js | 1 - .../node/bin/test.js.map | 2 +- ...MultifolderSpecifyOutputFile.sourcemap.txt | 2 +- .../amd/bin/test.d.ts | 0 .../amd/bin/test.js | 1 - .../amd/bin/test.js.map | 2 +- ...oduleSimpleSpecifyOutputFile.sourcemap.txt | 361 +++++++++++- .../node/bin/test.d.ts | 0 .../node/bin/test.js | 1 - .../node/bin/test.js.map | 2 +- ...oduleSimpleSpecifyOutputFile.sourcemap.txt | 2 +- .../amd/bin/test.d.ts | 0 .../amd/bin/test.js | 1 - .../amd/bin/test.js.map | 2 +- ...leSubfolderSpecifyOutputFile.sourcemap.txt | 361 +++++++++++- .../node/bin/test.d.ts | 0 .../node/bin/test.js | 1 - .../node/bin/test.js.map | 2 +- ...leSubfolderSpecifyOutputFile.sourcemap.txt | 2 +- .../amd/bin/test.d.ts | 13 - .../amd/bin/test.js | 23 - .../amd/bin/test.js.map | 2 +- ...edSubfolderSpecifyOutputFile.sourcemap.txt | 246 ++++++-- .../node/bin/test.d.ts | 13 - .../node/bin/test.js | 23 - .../node/bin/test.js.map | 2 +- ...edSubfolderSpecifyOutputFile.sourcemap.txt | 74 +-- .../amd/bin/outAndOutDirFile.d.ts | 13 - .../amd/bin/outAndOutDirFile.js | 23 - .../amd/bin/outAndOutDirFile.js.map | 2 +- ...OutputFileAndOutputDirectory.sourcemap.txt | 246 ++++++-- .../node/bin/outAndOutDirFile.d.ts | 13 - .../node/bin/outAndOutDirFile.js | 23 - .../node/bin/outAndOutDirFile.js.map | 2 +- ...OutputFileAndOutputDirectory.sourcemap.txt | 74 +-- .../amd/bin/test.d.ts | 0 .../amd/bin/test.js | 1 - .../amd/bin/test.js.map | 2 +- ...MultifolderSpecifyOutputFile.sourcemap.txt | 553 +++++++++++++++++- .../node/bin/test.d.ts | 0 .../node/bin/test.js | 1 - .../node/bin/test.js.map | 2 +- ...MultifolderSpecifyOutputFile.sourcemap.txt | 2 +- .../amd/bin/test.d.ts | 0 .../amd/bin/test.js | 1 - .../amd/bin/test.js.map | 2 +- ...oduleSimpleSpecifyOutputFile.sourcemap.txt | 361 +++++++++++- .../node/bin/test.d.ts | 0 .../node/bin/test.js | 1 - .../node/bin/test.js.map | 2 +- ...oduleSimpleSpecifyOutputFile.sourcemap.txt | 2 +- .../amd/bin/test.d.ts | 0 .../amd/bin/test.js | 1 - .../amd/bin/test.js.map | 2 +- ...leSubfolderSpecifyOutputFile.sourcemap.txt | 361 +++++++++++- .../node/bin/test.d.ts | 0 .../node/bin/test.js | 1 - .../node/bin/test.js.map | 2 +- ...leSubfolderSpecifyOutputFile.sourcemap.txt | 2 +- .../amd/bin/test.d.ts | 18 - .../amd/bin/test.js | 33 -- .../amd/bin/test.js.map | 2 +- ...MultifolderSpecifyOutputFile.sourcemap.txt | 14 +- .../node/bin/test.d.ts | 18 - .../node/bin/test.js | 33 -- .../node/bin/test.js.map | 2 +- ...MultifolderSpecifyOutputFile.sourcemap.txt | 14 +- .../amd/bin/test.d.ts | 13 - .../amd/bin/test.js | 23 - .../amd/bin/test.js.map | 2 +- ...edSubfolderSpecifyOutputFile.sourcemap.txt | 246 ++++++-- .../node/bin/test.d.ts | 13 - .../node/bin/test.js | 23 - .../node/bin/test.js.map | 2 +- ...edSubfolderSpecifyOutputFile.sourcemap.txt | 74 +-- .../amd/bin/outAndOutDirFile.d.ts | 13 - .../amd/bin/outAndOutDirFile.js | 23 - .../amd/bin/outAndOutDirFile.js.map | 2 +- ...OutputFileAndOutputDirectory.sourcemap.txt | 246 ++++++-- .../node/bin/outAndOutDirFile.d.ts | 13 - .../node/bin/outAndOutDirFile.js | 23 - .../node/bin/outAndOutDirFile.js.map | 2 +- ...OutputFileAndOutputDirectory.sourcemap.txt | 74 +-- .../amd/bin/test.d.ts | 0 .../amd/bin/test.js | 1 - .../amd/bin/test.js.map | 2 +- ...MultifolderSpecifyOutputFile.sourcemap.txt | 553 +++++++++++++++++- .../node/bin/test.d.ts | 0 .../node/bin/test.js | 1 - .../node/bin/test.js.map | 2 +- ...MultifolderSpecifyOutputFile.sourcemap.txt | 2 +- .../amd/bin/test.d.ts | 0 .../amd/bin/test.js | 1 - .../amd/bin/test.js.map | 2 +- ...oduleSimpleSpecifyOutputFile.sourcemap.txt | 361 +++++++++++- .../node/bin/test.d.ts | 0 .../node/bin/test.js | 1 - .../node/bin/test.js.map | 2 +- ...oduleSimpleSpecifyOutputFile.sourcemap.txt | 2 +- .../amd/bin/test.d.ts | 0 .../amd/bin/test.js | 1 - .../amd/bin/test.js.map | 2 +- ...leSubfolderSpecifyOutputFile.sourcemap.txt | 361 +++++++++++- .../node/bin/test.d.ts | 0 .../node/bin/test.js | 1 - .../node/bin/test.js.map | 2 +- ...leSubfolderSpecifyOutputFile.sourcemap.txt | 2 +- .../amd/bin/test.d.ts | 13 - .../amd/bin/test.js | 23 - .../amd/bin/test.js.map | 2 +- ...edSubfolderSpecifyOutputFile.sourcemap.txt | 246 ++++++-- .../node/bin/test.d.ts | 13 - .../node/bin/test.js | 23 - .../node/bin/test.js.map | 2 +- ...edSubfolderSpecifyOutputFile.sourcemap.txt | 74 +-- .../amd/bin/outAndOutDirFile.d.ts | 13 - .../amd/bin/outAndOutDirFile.js | 23 - .../amd/bin/outAndOutDirFile.js.map | 2 +- ...OutputFileAndOutputDirectory.sourcemap.txt | 246 ++++++-- .../node/bin/outAndOutDirFile.d.ts | 13 - .../node/bin/outAndOutDirFile.js | 23 - .../node/bin/outAndOutDirFile.js.map | 2 +- ...OutputFileAndOutputDirectory.sourcemap.txt | 74 +-- .../amd/bin/test.d.ts | 0 .../amd/bin/test.js | 1 - .../amd/bin/test.js.map | 2 +- ...MultifolderSpecifyOutputFile.sourcemap.txt | 553 +++++++++++++++++- .../node/bin/test.d.ts | 0 .../node/bin/test.js | 1 - .../node/bin/test.js.map | 2 +- ...MultifolderSpecifyOutputFile.sourcemap.txt | 2 +- .../amd/bin/test.d.ts | 0 .../amd/bin/test.js | 1 - .../amd/bin/test.js.map | 2 +- ...oduleSimpleSpecifyOutputFile.sourcemap.txt | 361 +++++++++++- .../node/bin/test.d.ts | 0 .../node/bin/test.js | 1 - .../node/bin/test.js.map | 2 +- ...oduleSimpleSpecifyOutputFile.sourcemap.txt | 2 +- .../amd/bin/test.d.ts | 0 .../amd/bin/test.js | 1 - .../amd/bin/test.js.map | 2 +- ...leSubfolderSpecifyOutputFile.sourcemap.txt | 361 +++++++++++- .../node/bin/test.d.ts | 0 .../node/bin/test.js | 1 - .../node/bin/test.js.map | 2 +- ...leSubfolderSpecifyOutputFile.sourcemap.txt | 2 +- .../amd/bin/test.d.ts | 13 - .../amd/bin/test.js | 14 + .../amd/bin/outAndOutDirFile.d.ts | 13 - .../amd/bin/outAndOutDirFile.js | 14 + .../amd/bin/test.d.ts | 0 .../amd/bin/test.js | 44 ++ .../amd/bin/test.d.ts | 0 .../amd/bin/test.js | 29 + .../amd/bin/test.d.ts | 0 .../amd/bin/test.js | 29 + .../reference/project/prologueEmit/amd/out.js | 6 +- .../project/prologueEmit/node/out.js | 6 +- .../amd/bin/test.d.ts | 13 - .../amd/bin/test.js | 23 - .../amd/bin/test.js.map | 2 +- ...edSubfolderSpecifyOutputFile.sourcemap.txt | 246 ++++++-- .../node/bin/test.d.ts | 13 - .../node/bin/test.js | 23 - .../node/bin/test.js.map | 2 +- ...edSubfolderSpecifyOutputFile.sourcemap.txt | 74 +-- .../amd/bin/outAndOutDirFile.d.ts | 13 - .../amd/bin/outAndOutDirFile.js | 23 - .../amd/bin/outAndOutDirFile.js.map | 2 +- ...OutputFileAndOutputDirectory.sourcemap.txt | 246 ++++++-- .../node/bin/outAndOutDirFile.d.ts | 13 - .../node/bin/outAndOutDirFile.js | 23 - .../node/bin/outAndOutDirFile.js.map | 2 +- ...OutputFileAndOutputDirectory.sourcemap.txt | 74 +-- .../amd/bin/test.d.ts | 0 .../amd/bin/test.js | 1 - .../amd/bin/test.js.map | 2 +- ...MultifolderSpecifyOutputFile.sourcemap.txt | 553 +++++++++++++++++- .../node/bin/test.d.ts | 0 .../node/bin/test.js | 1 - .../node/bin/test.js.map | 2 +- ...MultifolderSpecifyOutputFile.sourcemap.txt | 2 +- .../amd/bin/test.d.ts | 0 .../amd/bin/test.js | 1 - .../amd/bin/test.js.map | 2 +- ...oduleSimpleSpecifyOutputFile.sourcemap.txt | 361 +++++++++++- .../node/bin/test.d.ts | 0 .../node/bin/test.js | 1 - .../node/bin/test.js.map | 2 +- ...oduleSimpleSpecifyOutputFile.sourcemap.txt | 2 +- .../amd/bin/test.d.ts | 0 .../amd/bin/test.js | 1 - .../amd/bin/test.js.map | 2 +- ...leSubfolderSpecifyOutputFile.sourcemap.txt | 361 +++++++++++- .../node/bin/test.d.ts | 0 .../node/bin/test.js | 1 - .../node/bin/test.js.map | 2 +- ...leSubfolderSpecifyOutputFile.sourcemap.txt | 2 +- .../amd/bin/test.d.ts | 13 - .../amd/bin/test.js | 23 - .../amd/bin/test.js.map | 2 +- ...edSubfolderSpecifyOutputFile.sourcemap.txt | 246 ++++++-- .../node/bin/test.d.ts | 13 - .../node/bin/test.js | 23 - .../node/bin/test.js.map | 2 +- ...edSubfolderSpecifyOutputFile.sourcemap.txt | 74 +-- .../amd/bin/outAndOutDirFile.d.ts | 13 - .../amd/bin/outAndOutDirFile.js | 23 - .../amd/bin/outAndOutDirFile.js.map | 2 +- ...OutputFileAndOutputDirectory.sourcemap.txt | 246 ++++++-- .../node/bin/outAndOutDirFile.d.ts | 13 - .../node/bin/outAndOutDirFile.js | 23 - .../node/bin/outAndOutDirFile.js.map | 2 +- ...OutputFileAndOutputDirectory.sourcemap.txt | 74 +-- .../amd/bin/test.d.ts | 0 .../amd/bin/test.js | 1 - .../amd/bin/test.js.map | 2 +- ...MultifolderSpecifyOutputFile.sourcemap.txt | 553 +++++++++++++++++- .../node/bin/test.d.ts | 0 .../node/bin/test.js | 1 - .../node/bin/test.js.map | 2 +- ...MultifolderSpecifyOutputFile.sourcemap.txt | 2 +- .../amd/bin/test.d.ts | 0 .../amd/bin/test.js | 1 - .../amd/bin/test.js.map | 2 +- ...oduleSimpleSpecifyOutputFile.sourcemap.txt | 361 +++++++++++- .../node/bin/test.d.ts | 0 .../node/bin/test.js | 1 - .../node/bin/test.js.map | 2 +- ...oduleSimpleSpecifyOutputFile.sourcemap.txt | 2 +- .../amd/bin/test.d.ts | 0 .../amd/bin/test.js | 1 - .../amd/bin/test.js.map | 2 +- ...leSubfolderSpecifyOutputFile.sourcemap.txt | 361 +++++++++++- .../node/bin/test.d.ts | 0 .../node/bin/test.js | 1 - .../node/bin/test.js.map | 2 +- ...leSubfolderSpecifyOutputFile.sourcemap.txt | 2 +- .../amd/bin/test.d.ts | 13 - .../amd/bin/test.js | 23 - .../amd/bin/test.js.map | 2 +- ...edSubfolderSpecifyOutputFile.sourcemap.txt | 246 ++++++-- .../node/bin/test.d.ts | 13 - .../node/bin/test.js | 23 - .../node/bin/test.js.map | 2 +- ...edSubfolderSpecifyOutputFile.sourcemap.txt | 74 +-- .../amd/bin/outAndOutDirFile.d.ts | 13 - .../amd/bin/outAndOutDirFile.js | 23 - .../amd/bin/outAndOutDirFile.js.map | 2 +- ...OutputFileAndOutputDirectory.sourcemap.txt | 246 ++++++-- .../node/bin/outAndOutDirFile.d.ts | 13 - .../node/bin/outAndOutDirFile.js | 23 - .../node/bin/outAndOutDirFile.js.map | 2 +- ...OutputFileAndOutputDirectory.sourcemap.txt | 74 +-- .../amd/bin/test.d.ts | 0 .../amd/bin/test.js | 1 - .../amd/bin/test.js.map | 2 +- ...MultifolderSpecifyOutputFile.sourcemap.txt | 553 +++++++++++++++++- .../node/bin/test.d.ts | 0 .../node/bin/test.js | 1 - .../node/bin/test.js.map | 2 +- ...MultifolderSpecifyOutputFile.sourcemap.txt | 2 +- .../amd/bin/test.d.ts | 0 .../amd/bin/test.js | 1 - .../amd/bin/test.js.map | 2 +- ...oduleSimpleSpecifyOutputFile.sourcemap.txt | 361 +++++++++++- .../node/bin/test.d.ts | 0 .../node/bin/test.js | 1 - .../node/bin/test.js.map | 2 +- ...oduleSimpleSpecifyOutputFile.sourcemap.txt | 2 +- .../amd/bin/test.d.ts | 0 .../amd/bin/test.js | 1 - .../amd/bin/test.js.map | 2 +- ...leSubfolderSpecifyOutputFile.sourcemap.txt | 361 +++++++++++- .../node/bin/test.d.ts | 0 .../node/bin/test.js | 1 - .../node/bin/test.js.map | 2 +- ...leSubfolderSpecifyOutputFile.sourcemap.txt | 2 +- .../amd/bin/test.d.ts | 13 - .../amd/bin/test.js | 23 - .../amd/bin/test.js.map | 2 +- ...edSubfolderSpecifyOutputFile.sourcemap.txt | 246 ++++++-- .../node/bin/test.d.ts | 13 - .../node/bin/test.js | 23 - .../node/bin/test.js.map | 2 +- ...edSubfolderSpecifyOutputFile.sourcemap.txt | 74 +-- .../amd/bin/outAndOutDirFile.d.ts | 13 - .../amd/bin/outAndOutDirFile.js | 23 - .../amd/bin/outAndOutDirFile.js.map | 2 +- ...OutputFileAndOutputDirectory.sourcemap.txt | 246 ++++++-- .../node/bin/outAndOutDirFile.d.ts | 13 - .../node/bin/outAndOutDirFile.js | 23 - .../node/bin/outAndOutDirFile.js.map | 2 +- ...OutputFileAndOutputDirectory.sourcemap.txt | 74 +-- .../amd/bin/test.d.ts | 0 .../amd/bin/test.js | 1 - .../amd/bin/test.js.map | 2 +- ...MultifolderSpecifyOutputFile.sourcemap.txt | 553 +++++++++++++++++- .../node/bin/test.d.ts | 0 .../node/bin/test.js | 1 - .../node/bin/test.js.map | 2 +- ...MultifolderSpecifyOutputFile.sourcemap.txt | 2 +- .../amd/bin/test.d.ts | 0 .../amd/bin/test.js | 1 - .../amd/bin/test.js.map | 2 +- ...oduleSimpleSpecifyOutputFile.sourcemap.txt | 361 +++++++++++- .../node/bin/test.d.ts | 0 .../node/bin/test.js | 1 - .../node/bin/test.js.map | 2 +- ...oduleSimpleSpecifyOutputFile.sourcemap.txt | 2 +- .../amd/bin/test.d.ts | 0 .../amd/bin/test.js | 1 - .../amd/bin/test.js.map | 2 +- ...leSubfolderSpecifyOutputFile.sourcemap.txt | 361 +++++++++++- .../node/bin/test.d.ts | 0 .../node/bin/test.js | 1 - .../node/bin/test.js.map | 2 +- ...leSubfolderSpecifyOutputFile.sourcemap.txt | 2 +- 342 files changed, 14323 insertions(+), 2713 deletions(-) delete mode 100644 tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFile/amd/bin/test.d.ts delete mode 100644 tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFile/amd/bin/test.js delete mode 100644 tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFile/node/bin/test.d.ts delete mode 100644 tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFile/node/bin/test.js delete mode 100644 tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.d.ts delete mode 100644 tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.js delete mode 100644 tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.d.ts delete mode 100644 tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.js delete mode 100644 tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderSpecifyOutputFile/amd/bin/test.d.ts delete mode 100644 tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderSpecifyOutputFile/amd/bin/test.js delete mode 100644 tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderSpecifyOutputFile/node/bin/test.d.ts delete mode 100644 tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderSpecifyOutputFile/node/bin/test.js delete mode 100644 tests/baselines/reference/project/mapRootAbsolutePathModuleSimpleSpecifyOutputFile/amd/bin/test.d.ts delete mode 100644 tests/baselines/reference/project/mapRootAbsolutePathModuleSimpleSpecifyOutputFile/amd/bin/test.js delete mode 100644 tests/baselines/reference/project/mapRootAbsolutePathModuleSimpleSpecifyOutputFile/node/bin/test.d.ts delete mode 100644 tests/baselines/reference/project/mapRootAbsolutePathModuleSimpleSpecifyOutputFile/node/bin/test.js delete mode 100644 tests/baselines/reference/project/mapRootAbsolutePathModuleSubfolderSpecifyOutputFile/amd/bin/test.d.ts delete mode 100644 tests/baselines/reference/project/mapRootAbsolutePathModuleSubfolderSpecifyOutputFile/amd/bin/test.js delete mode 100644 tests/baselines/reference/project/mapRootAbsolutePathModuleSubfolderSpecifyOutputFile/node/bin/test.d.ts delete mode 100644 tests/baselines/reference/project/mapRootAbsolutePathModuleSubfolderSpecifyOutputFile/node/bin/test.js delete mode 100644 tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFile/amd/bin/test.d.ts delete mode 100644 tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFile/amd/bin/test.js delete mode 100644 tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFile/node/bin/test.d.ts delete mode 100644 tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFile/node/bin/test.js delete mode 100644 tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.d.ts delete mode 100644 tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.js delete mode 100644 tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.d.ts delete mode 100644 tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.js delete mode 100644 tests/baselines/reference/project/mapRootRelativePathModuleMultifolderSpecifyOutputFile/amd/bin/test.d.ts delete mode 100644 tests/baselines/reference/project/mapRootRelativePathModuleMultifolderSpecifyOutputFile/amd/bin/test.js delete mode 100644 tests/baselines/reference/project/mapRootRelativePathModuleMultifolderSpecifyOutputFile/node/bin/test.d.ts delete mode 100644 tests/baselines/reference/project/mapRootRelativePathModuleMultifolderSpecifyOutputFile/node/bin/test.js delete mode 100644 tests/baselines/reference/project/mapRootRelativePathModuleSimpleSpecifyOutputFile/amd/bin/test.d.ts delete mode 100644 tests/baselines/reference/project/mapRootRelativePathModuleSimpleSpecifyOutputFile/amd/bin/test.js delete mode 100644 tests/baselines/reference/project/mapRootRelativePathModuleSimpleSpecifyOutputFile/node/bin/test.d.ts delete mode 100644 tests/baselines/reference/project/mapRootRelativePathModuleSimpleSpecifyOutputFile/node/bin/test.js delete mode 100644 tests/baselines/reference/project/mapRootRelativePathModuleSubfolderSpecifyOutputFile/amd/bin/test.d.ts delete mode 100644 tests/baselines/reference/project/mapRootRelativePathModuleSubfolderSpecifyOutputFile/amd/bin/test.js delete mode 100644 tests/baselines/reference/project/mapRootRelativePathModuleSubfolderSpecifyOutputFile/node/bin/test.d.ts delete mode 100644 tests/baselines/reference/project/mapRootRelativePathModuleSubfolderSpecifyOutputFile/node/bin/test.js delete mode 100644 tests/baselines/reference/project/mapRootRelativePathMultifolderSpecifyOutputFile/amd/bin/test.d.ts delete mode 100644 tests/baselines/reference/project/mapRootRelativePathMultifolderSpecifyOutputFile/amd/bin/test.js delete mode 100644 tests/baselines/reference/project/mapRootRelativePathMultifolderSpecifyOutputFile/node/bin/test.d.ts delete mode 100644 tests/baselines/reference/project/mapRootRelativePathMultifolderSpecifyOutputFile/node/bin/test.js delete mode 100644 tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFile/amd/bin/test.d.ts delete mode 100644 tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFile/amd/bin/test.js delete mode 100644 tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFile/node/bin/test.d.ts delete mode 100644 tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFile/node/bin/test.js delete mode 100644 tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.d.ts delete mode 100644 tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.js delete mode 100644 tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.d.ts delete mode 100644 tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.js delete mode 100644 tests/baselines/reference/project/maprootUrlModuleMultifolderSpecifyOutputFile/amd/bin/test.d.ts delete mode 100644 tests/baselines/reference/project/maprootUrlModuleMultifolderSpecifyOutputFile/amd/bin/test.js delete mode 100644 tests/baselines/reference/project/maprootUrlModuleMultifolderSpecifyOutputFile/node/bin/test.d.ts delete mode 100644 tests/baselines/reference/project/maprootUrlModuleMultifolderSpecifyOutputFile/node/bin/test.js delete mode 100644 tests/baselines/reference/project/maprootUrlModuleSimpleSpecifyOutputFile/amd/bin/test.d.ts delete mode 100644 tests/baselines/reference/project/maprootUrlModuleSimpleSpecifyOutputFile/amd/bin/test.js delete mode 100644 tests/baselines/reference/project/maprootUrlModuleSimpleSpecifyOutputFile/node/bin/test.d.ts delete mode 100644 tests/baselines/reference/project/maprootUrlModuleSimpleSpecifyOutputFile/node/bin/test.js delete mode 100644 tests/baselines/reference/project/maprootUrlModuleSubfolderSpecifyOutputFile/amd/bin/test.d.ts delete mode 100644 tests/baselines/reference/project/maprootUrlModuleSubfolderSpecifyOutputFile/amd/bin/test.js delete mode 100644 tests/baselines/reference/project/maprootUrlModuleSubfolderSpecifyOutputFile/node/bin/test.d.ts delete mode 100644 tests/baselines/reference/project/maprootUrlModuleSubfolderSpecifyOutputFile/node/bin/test.js delete mode 100644 tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFile/amd/bin/test.d.ts delete mode 100644 tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFile/amd/bin/test.js delete mode 100644 tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFile/node/bin/test.d.ts delete mode 100644 tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFile/node/bin/test.js delete mode 100644 tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.d.ts delete mode 100644 tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.js delete mode 100644 tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.d.ts delete mode 100644 tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.js delete mode 100644 tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputFile/amd/bin/test.d.ts delete mode 100644 tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputFile/amd/bin/test.js delete mode 100644 tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputFile/node/bin/test.d.ts delete mode 100644 tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputFile/node/bin/test.js delete mode 100644 tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSimpleSpecifyOutputFile/amd/bin/test.d.ts delete mode 100644 tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSimpleSpecifyOutputFile/amd/bin/test.js delete mode 100644 tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSimpleSpecifyOutputFile/node/bin/test.d.ts delete mode 100644 tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSimpleSpecifyOutputFile/node/bin/test.js delete mode 100644 tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSubfolderSpecifyOutputFile/amd/bin/test.d.ts delete mode 100644 tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSubfolderSpecifyOutputFile/amd/bin/test.js delete mode 100644 tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSubfolderSpecifyOutputFile/node/bin/test.d.ts delete mode 100644 tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSubfolderSpecifyOutputFile/node/bin/test.js delete mode 100644 tests/baselines/reference/project/outMixedSubfolderSpecifyOutputFile/amd/bin/test.d.ts delete mode 100644 tests/baselines/reference/project/outMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.d.ts delete mode 100644 tests/baselines/reference/project/outModuleMultifolderSpecifyOutputFile/amd/bin/test.d.ts delete mode 100644 tests/baselines/reference/project/outModuleSimpleSpecifyOutputFile/amd/bin/test.d.ts delete mode 100644 tests/baselines/reference/project/outModuleSubfolderSpecifyOutputFile/amd/bin/test.d.ts delete mode 100644 tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFile/amd/bin/test.d.ts delete mode 100644 tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFile/amd/bin/test.js delete mode 100644 tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFile/node/bin/test.d.ts delete mode 100644 tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFile/node/bin/test.js delete mode 100644 tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.d.ts delete mode 100644 tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.js delete mode 100644 tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.d.ts delete mode 100644 tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.js delete mode 100644 tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderSpecifyOutputFile/amd/bin/test.d.ts delete mode 100644 tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderSpecifyOutputFile/amd/bin/test.js delete mode 100644 tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderSpecifyOutputFile/node/bin/test.d.ts delete mode 100644 tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderSpecifyOutputFile/node/bin/test.js delete mode 100644 tests/baselines/reference/project/sourceRootAbsolutePathModuleSimpleSpecifyOutputFile/amd/bin/test.d.ts delete mode 100644 tests/baselines/reference/project/sourceRootAbsolutePathModuleSimpleSpecifyOutputFile/amd/bin/test.js delete mode 100644 tests/baselines/reference/project/sourceRootAbsolutePathModuleSimpleSpecifyOutputFile/node/bin/test.d.ts delete mode 100644 tests/baselines/reference/project/sourceRootAbsolutePathModuleSimpleSpecifyOutputFile/node/bin/test.js delete mode 100644 tests/baselines/reference/project/sourceRootAbsolutePathModuleSubfolderSpecifyOutputFile/amd/bin/test.d.ts delete mode 100644 tests/baselines/reference/project/sourceRootAbsolutePathModuleSubfolderSpecifyOutputFile/amd/bin/test.js delete mode 100644 tests/baselines/reference/project/sourceRootAbsolutePathModuleSubfolderSpecifyOutputFile/node/bin/test.d.ts delete mode 100644 tests/baselines/reference/project/sourceRootAbsolutePathModuleSubfolderSpecifyOutputFile/node/bin/test.js delete mode 100644 tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFile/amd/bin/test.d.ts delete mode 100644 tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFile/amd/bin/test.js delete mode 100644 tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFile/node/bin/test.d.ts delete mode 100644 tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFile/node/bin/test.js delete mode 100644 tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.d.ts delete mode 100644 tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.js delete mode 100644 tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.d.ts delete mode 100644 tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.js delete mode 100644 tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderSpecifyOutputFile/amd/bin/test.d.ts delete mode 100644 tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderSpecifyOutputFile/amd/bin/test.js delete mode 100644 tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderSpecifyOutputFile/node/bin/test.d.ts delete mode 100644 tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderSpecifyOutputFile/node/bin/test.js delete mode 100644 tests/baselines/reference/project/sourceRootRelativePathModuleSimpleSpecifyOutputFile/amd/bin/test.d.ts delete mode 100644 tests/baselines/reference/project/sourceRootRelativePathModuleSimpleSpecifyOutputFile/amd/bin/test.js delete mode 100644 tests/baselines/reference/project/sourceRootRelativePathModuleSimpleSpecifyOutputFile/node/bin/test.d.ts delete mode 100644 tests/baselines/reference/project/sourceRootRelativePathModuleSimpleSpecifyOutputFile/node/bin/test.js delete mode 100644 tests/baselines/reference/project/sourceRootRelativePathModuleSubfolderSpecifyOutputFile/amd/bin/test.d.ts delete mode 100644 tests/baselines/reference/project/sourceRootRelativePathModuleSubfolderSpecifyOutputFile/amd/bin/test.js delete mode 100644 tests/baselines/reference/project/sourceRootRelativePathModuleSubfolderSpecifyOutputFile/node/bin/test.d.ts delete mode 100644 tests/baselines/reference/project/sourceRootRelativePathModuleSubfolderSpecifyOutputFile/node/bin/test.js delete mode 100644 tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFile/amd/bin/test.d.ts delete mode 100644 tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFile/amd/bin/test.js delete mode 100644 tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFile/node/bin/test.d.ts delete mode 100644 tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFile/node/bin/test.js delete mode 100644 tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.d.ts delete mode 100644 tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.js delete mode 100644 tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.d.ts delete mode 100644 tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.js delete mode 100644 tests/baselines/reference/project/sourcemapModuleMultifolderSpecifyOutputFile/amd/bin/test.d.ts delete mode 100644 tests/baselines/reference/project/sourcemapModuleMultifolderSpecifyOutputFile/amd/bin/test.js delete mode 100644 tests/baselines/reference/project/sourcemapModuleMultifolderSpecifyOutputFile/node/bin/test.d.ts delete mode 100644 tests/baselines/reference/project/sourcemapModuleMultifolderSpecifyOutputFile/node/bin/test.js delete mode 100644 tests/baselines/reference/project/sourcemapModuleSimpleSpecifyOutputFile/amd/bin/test.d.ts delete mode 100644 tests/baselines/reference/project/sourcemapModuleSimpleSpecifyOutputFile/amd/bin/test.js delete mode 100644 tests/baselines/reference/project/sourcemapModuleSimpleSpecifyOutputFile/node/bin/test.d.ts delete mode 100644 tests/baselines/reference/project/sourcemapModuleSimpleSpecifyOutputFile/node/bin/test.js delete mode 100644 tests/baselines/reference/project/sourcemapModuleSubfolderSpecifyOutputFile/amd/bin/test.d.ts delete mode 100644 tests/baselines/reference/project/sourcemapModuleSubfolderSpecifyOutputFile/amd/bin/test.js delete mode 100644 tests/baselines/reference/project/sourcemapModuleSubfolderSpecifyOutputFile/node/bin/test.d.ts delete mode 100644 tests/baselines/reference/project/sourcemapModuleSubfolderSpecifyOutputFile/node/bin/test.js delete mode 100644 tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFile/amd/bin/test.d.ts delete mode 100644 tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFile/amd/bin/test.js delete mode 100644 tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFile/node/bin/test.d.ts delete mode 100644 tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFile/node/bin/test.js delete mode 100644 tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.d.ts delete mode 100644 tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.js delete mode 100644 tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.d.ts delete mode 100644 tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.js delete mode 100644 tests/baselines/reference/project/sourcerootUrlModuleMultifolderSpecifyOutputFile/amd/bin/test.d.ts delete mode 100644 tests/baselines/reference/project/sourcerootUrlModuleMultifolderSpecifyOutputFile/amd/bin/test.js delete mode 100644 tests/baselines/reference/project/sourcerootUrlModuleMultifolderSpecifyOutputFile/node/bin/test.d.ts delete mode 100644 tests/baselines/reference/project/sourcerootUrlModuleMultifolderSpecifyOutputFile/node/bin/test.js delete mode 100644 tests/baselines/reference/project/sourcerootUrlModuleSimpleSpecifyOutputFile/amd/bin/test.d.ts delete mode 100644 tests/baselines/reference/project/sourcerootUrlModuleSimpleSpecifyOutputFile/amd/bin/test.js delete mode 100644 tests/baselines/reference/project/sourcerootUrlModuleSimpleSpecifyOutputFile/node/bin/test.d.ts delete mode 100644 tests/baselines/reference/project/sourcerootUrlModuleSimpleSpecifyOutputFile/node/bin/test.js delete mode 100644 tests/baselines/reference/project/sourcerootUrlModuleSubfolderSpecifyOutputFile/amd/bin/test.d.ts delete mode 100644 tests/baselines/reference/project/sourcerootUrlModuleSubfolderSpecifyOutputFile/amd/bin/test.js delete mode 100644 tests/baselines/reference/project/sourcerootUrlModuleSubfolderSpecifyOutputFile/node/bin/test.d.ts delete mode 100644 tests/baselines/reference/project/sourcerootUrlModuleSubfolderSpecifyOutputFile/node/bin/test.js diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index 3a4b9a4a3bf..52b8760bbd1 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -7053,7 +7053,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi let startIndex = emitDirectivePrologues(node.statements, /*startWithNewLine*/ false); if (isExternalModule(node) || compilerOptions.isolatedModules) { - if (root) { + if (root || (!isExternalModule(node) && compilerOptions.isolatedModules)) { let emitModule = moduleEmitDelegates[modulekind] || moduleEmitDelegates[ModuleKind.CommonJS]; emitModule(node, startIndex); } diff --git a/tests/baselines/reference/getEmitOutputMapRoots.baseline b/tests/baselines/reference/getEmitOutputMapRoots.baseline index b4a4ace4d42..66130347d2d 100644 --- a/tests/baselines/reference/getEmitOutputMapRoots.baseline +++ b/tests/baselines/reference/getEmitOutputMapRoots.baseline @@ -1,6 +1,6 @@ EmitSkipped: false FileName : declSingleFile.js.map -{"version":3,"file":"declSingleFile.js","sourceRoot":"","sources":["../tests/cases/fourslash/inputFile.ts"],"names":["M","M.constructor"],"mappings":"AAAA,IAAI,CAAC,GAAG,GAAG,CAAC;AACZ,IAAI,GAAG,GAAG,aAAa,CAAC;AACxB;IAAAA;IAGAC,CAACA;IAADD,QAACA;AAADA,CAACA,AAHD,IAGC"}FileName : declSingleFile.js +{"version":3,"file":"declSingleFile.js","sourceRoot":"","sources":["../inputFile.ts"],"names":["M","M.constructor"],"mappings":"AAAA,IAAI,CAAC,GAAG,GAAG,CAAC;AACZ,IAAI,GAAG,GAAG,aAAa,CAAC;AACxB;IAAAA;IAGAC,CAACA;IAADD,QAACA;AAADA,CAACA,AAHD,IAGC"}FileName : declSingleFile.js var x = 109; var foo = "hello world"; var M = (function () { @@ -8,4 +8,4 @@ var M = (function () { } return M; })(); -//# sourceMappingURL=mapRootDir/declSingleFile.js.map +//# sourceMappingURL=tests/cases/fourslash/mapRootDir/declSingleFile.js.map diff --git a/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFile/amd/bin/test.d.ts b/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFile/amd/bin/test.d.ts deleted file mode 100644 index d61b4c3b876..00000000000 --- a/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFile/amd/bin/test.d.ts +++ /dev/null @@ -1,13 +0,0 @@ -/// -declare var m1_a1: number; -declare class m1_c1 { - m1_c1_p1: number; -} -declare var m1_instance1: m1_c1; -declare function m1_f1(): m1_c1; -declare var a1: number; -declare class c1 { - p1: number; -} -declare var instance1: c1; -declare function f1(): c1; diff --git a/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFile/amd/bin/test.js b/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFile/amd/bin/test.js deleted file mode 100644 index 7ef36232b8d..00000000000 --- a/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFile/amd/bin/test.js +++ /dev/null @@ -1,23 +0,0 @@ -var m1_a1 = 10; -var m1_c1 = (function () { - function m1_c1() { - } - return m1_c1; -})(); -var m1_instance1 = new m1_c1(); -function m1_f1() { - return m1_instance1; -} -/// -/// -var a1 = 10; -var c1 = (function () { - function c1() { - } - return c1; -})(); -var instance1 = new c1(); -function f1() { - return instance1; -} -//# sourceMappingURL=/tests/cases/projects/outputdir_mixed_subfolder/mapFiles/test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFile/amd/bin/test.js.map b/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFile/amd/bin/test.js.map index a1d591a0497..94371fe696d 100644 --- a/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFile/amd/bin/test.js.map +++ b/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFile/amd/bin/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"","sources":["../ref/m1.ts","../test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACRD,iCAAiC;AACjC,iCAAiC;AACjC,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"","sources":["../ref/m1.ts","../ref/m2.ts","../test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","m2_c1","m2_c1.constructor","m2_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;;ICRU,aAAK,GAAG,EAAE,CAAC;IACtB;QAAAC;QAEAC,CAACA;QAADD,YAACA;IAADA,CAACA,AAFD,IAEC;IAFY,aAAK,QAEjB,CAAA;IAEU,oBAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACIE,MAAMA,CAACA,oBAAYA,CAACA;IACxBA,CAACA;IAFe,aAAK,QAEpB,CAAA;;ACRD,iCAAiC;AACjC,iCAAiC;AACjC,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFile/amd/mapRootAbsolutePathMixedSubfolderSpecifyOutputFile.sourcemap.txt b/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFile/amd/mapRootAbsolutePathMixedSubfolderSpecifyOutputFile.sourcemap.txt index 133c266cc9e..ef882554ddb 100644 --- a/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFile/amd/mapRootAbsolutePathMixedSubfolderSpecifyOutputFile.sourcemap.txt +++ b/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFile/amd/mapRootAbsolutePathMixedSubfolderSpecifyOutputFile.sourcemap.txt @@ -174,7 +174,7 @@ sourceFile:../../ref/m2.ts JsFile: test.js mapUrl: /tests/cases/projects/outputdir_mixed_subfolder/mapFiles/test.js.map sourceRoot: -sources: ../ref/m1.ts,../test.ts +sources: ../ref/m1.ts,../ref/m2.ts,../test.ts =================================================================== ------------------------------------------------------------------- emittedFile:bin/test.js @@ -306,7 +306,7 @@ sourceFile:../ref/m1.ts >>>} 1 > 2 >^ -3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> 1 > > 2 >} @@ -315,16 +315,182 @@ sourceFile:../ref/m1.ts --- ------------------------------------------------------------------- emittedFile:bin/test.js +sourceFile:../ref/m2.ts +------------------------------------------------------------------- +>>>define("ref/m2", ["require", "exports"], function (require, exports) { +>>> exports.m2_a1 = 10; +1->^^^^ +2 > ^^^^^^^^^^^^^ +3 > ^^^ +4 > ^^ +5 > ^ +6 > ^^^^^^^^-> +1->export var +2 > m2_a1 +3 > = +4 > 10 +5 > ; +1->Emitted(12, 5) Source(1, 12) + SourceIndex(1) +2 >Emitted(12, 18) Source(1, 17) + SourceIndex(1) +3 >Emitted(12, 21) Source(1, 20) + SourceIndex(1) +4 >Emitted(12, 23) Source(1, 22) + SourceIndex(1) +5 >Emitted(12, 24) Source(1, 23) + SourceIndex(1) +--- +>>> var m2_c1 = (function () { +1->^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^^^^-> +1-> + > +1->Emitted(13, 5) Source(2, 1) + SourceIndex(1) +--- +>>> function m2_c1() { +1->^^^^^^^^ +2 > ^^-> +1-> +1->Emitted(14, 9) Source(2, 1) + SourceIndex(1) name (m2_c1) +--- +>>> } +1->^^^^^^^^ +2 > ^ +3 > ^^^^^^^^^^^^^-> +1->export class m2_c1 { + > public m2_c1_p1: number; + > +2 > } +1->Emitted(15, 9) Source(4, 1) + SourceIndex(1) name (m2_c1.constructor) +2 >Emitted(15, 10) Source(4, 2) + SourceIndex(1) name (m2_c1.constructor) +--- +>>> return m2_c1; +1->^^^^^^^^ +2 > ^^^^^^^^^^^^ +1-> +2 > } +1->Emitted(16, 9) Source(4, 1) + SourceIndex(1) name (m2_c1) +2 >Emitted(16, 21) Source(4, 2) + SourceIndex(1) name (m2_c1) +--- +>>> })(); +1 >^^^^ +2 > ^ +3 > +4 > ^^^^ +5 > ^^^^^^^^^^^^^^^^^^-> +1 > +2 > } +3 > +4 > export class m2_c1 { + > public m2_c1_p1: number; + > } +1 >Emitted(17, 5) Source(4, 1) + SourceIndex(1) name (m2_c1) +2 >Emitted(17, 6) Source(4, 2) + SourceIndex(1) name (m2_c1) +3 >Emitted(17, 6) Source(2, 1) + SourceIndex(1) +4 >Emitted(17, 10) Source(4, 2) + SourceIndex(1) +--- +>>> exports.m2_c1 = m2_c1; +1->^^^^ +2 > ^^^^^^^^^^^^^ +3 > ^^^^^^^^ +4 > ^ +5 > ^^^^^^^^^^^^^^-> +1-> +2 > m2_c1 +3 > { + > public m2_c1_p1: number; + > } +4 > +1->Emitted(18, 5) Source(2, 14) + SourceIndex(1) +2 >Emitted(18, 18) Source(2, 19) + SourceIndex(1) +3 >Emitted(18, 26) Source(4, 2) + SourceIndex(1) +4 >Emitted(18, 27) Source(4, 2) + SourceIndex(1) +--- +>>> exports.m2_instance1 = new m2_c1(); +1->^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^ +3 > ^^^ +4 > ^^^^ +5 > ^^^^^ +6 > ^^ +7 > ^ +1-> + > + >export var +2 > m2_instance1 +3 > = +4 > new +5 > m2_c1 +6 > () +7 > ; +1->Emitted(19, 5) Source(6, 12) + SourceIndex(1) +2 >Emitted(19, 25) Source(6, 24) + SourceIndex(1) +3 >Emitted(19, 28) Source(6, 27) + SourceIndex(1) +4 >Emitted(19, 32) Source(6, 31) + SourceIndex(1) +5 >Emitted(19, 37) Source(6, 36) + SourceIndex(1) +6 >Emitted(19, 39) Source(6, 38) + SourceIndex(1) +7 >Emitted(19, 40) Source(6, 39) + SourceIndex(1) +--- +>>> function m2_f1() { +1 >^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +1 > + > +1 >Emitted(20, 5) Source(7, 1) + SourceIndex(1) +--- +>>> return exports.m2_instance1; +1->^^^^^^^^ +2 > ^^^^^^ +3 > ^ +4 > ^^^^^^^^^^^^^^^^^^^^ +5 > ^ +1->export function m2_f1() { + > +2 > return +3 > +4 > m2_instance1 +5 > ; +1->Emitted(21, 9) Source(8, 5) + SourceIndex(1) name (m2_f1) +2 >Emitted(21, 15) Source(8, 11) + SourceIndex(1) name (m2_f1) +3 >Emitted(21, 16) Source(8, 12) + SourceIndex(1) name (m2_f1) +4 >Emitted(21, 36) Source(8, 24) + SourceIndex(1) name (m2_f1) +5 >Emitted(21, 37) Source(8, 25) + SourceIndex(1) name (m2_f1) +--- +>>> } +1 >^^^^ +2 > ^ +3 > ^^^^^^^^^^^^^^^^^^^^^^-> +1 > + > +2 > } +1 >Emitted(22, 5) Source(9, 1) + SourceIndex(1) name (m2_f1) +2 >Emitted(22, 6) Source(9, 2) + SourceIndex(1) name (m2_f1) +--- +>>> exports.m2_f1 = m2_f1; +1->^^^^ +2 > ^^^^^^^^^^^^^ +3 > ^^^^^^^^ +4 > ^ +1-> +2 > m2_f1 +3 > () { + > return m2_instance1; + > } +4 > +1->Emitted(23, 5) Source(7, 17) + SourceIndex(1) +2 >Emitted(23, 18) Source(7, 22) + SourceIndex(1) +3 >Emitted(23, 26) Source(9, 2) + SourceIndex(1) +4 >Emitted(23, 27) Source(9, 2) + SourceIndex(1) +--- +------------------------------------------------------------------- +emittedFile:bin/test.js sourceFile:../test.ts ------------------------------------------------------------------- +>>>}); >>>/// -1-> +1 > 2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 3 > ^-> -1-> +1 > 2 >/// -1->Emitted(11, 1) Source(1, 1) + SourceIndex(1) -2 >Emitted(11, 34) Source(1, 34) + SourceIndex(1) +1 >Emitted(25, 1) Source(1, 1) + SourceIndex(2) +2 >Emitted(25, 34) Source(1, 34) + SourceIndex(2) --- >>>/// 1-> @@ -332,8 +498,8 @@ sourceFile:../test.ts 1-> > 2 >/// -1->Emitted(12, 1) Source(2, 1) + SourceIndex(1) -2 >Emitted(12, 34) Source(2, 34) + SourceIndex(1) +1->Emitted(26, 1) Source(2, 1) + SourceIndex(2) +2 >Emitted(26, 34) Source(2, 34) + SourceIndex(2) --- >>>var a1 = 10; 1 > @@ -350,25 +516,25 @@ sourceFile:../test.ts 4 > = 5 > 10 6 > ; -1 >Emitted(13, 1) Source(3, 1) + SourceIndex(1) -2 >Emitted(13, 5) Source(3, 5) + SourceIndex(1) -3 >Emitted(13, 7) Source(3, 7) + SourceIndex(1) -4 >Emitted(13, 10) Source(3, 10) + SourceIndex(1) -5 >Emitted(13, 12) Source(3, 12) + SourceIndex(1) -6 >Emitted(13, 13) Source(3, 13) + SourceIndex(1) +1 >Emitted(27, 1) Source(3, 1) + SourceIndex(2) +2 >Emitted(27, 5) Source(3, 5) + SourceIndex(2) +3 >Emitted(27, 7) Source(3, 7) + SourceIndex(2) +4 >Emitted(27, 10) Source(3, 10) + SourceIndex(2) +5 >Emitted(27, 12) Source(3, 12) + SourceIndex(2) +6 >Emitted(27, 13) Source(3, 13) + SourceIndex(2) --- >>>var c1 = (function () { 1-> 2 >^^^^^^^^^^^^^^^^^^^^-> 1-> > -1->Emitted(14, 1) Source(4, 1) + SourceIndex(1) +1->Emitted(28, 1) Source(4, 1) + SourceIndex(2) --- >>> function c1() { 1->^^^^ 2 > ^^-> 1-> -1->Emitted(15, 5) Source(4, 1) + SourceIndex(1) name (c1) +1->Emitted(29, 5) Source(4, 1) + SourceIndex(2) name (c1) --- >>> } 1->^^^^ @@ -378,16 +544,16 @@ sourceFile:../test.ts > public p1: number; > 2 > } -1->Emitted(16, 5) Source(6, 1) + SourceIndex(1) name (c1.constructor) -2 >Emitted(16, 6) Source(6, 2) + SourceIndex(1) name (c1.constructor) +1->Emitted(30, 5) Source(6, 1) + SourceIndex(2) name (c1.constructor) +2 >Emitted(30, 6) Source(6, 2) + SourceIndex(2) name (c1.constructor) --- >>> return c1; 1->^^^^ 2 > ^^^^^^^^^ 1-> 2 > } -1->Emitted(17, 5) Source(6, 1) + SourceIndex(1) name (c1) -2 >Emitted(17, 14) Source(6, 2) + SourceIndex(1) name (c1) +1->Emitted(31, 5) Source(6, 1) + SourceIndex(2) name (c1) +2 >Emitted(31, 14) Source(6, 2) + SourceIndex(2) name (c1) --- >>>})(); 1 > @@ -401,10 +567,10 @@ sourceFile:../test.ts 4 > class c1 { > public p1: number; > } -1 >Emitted(18, 1) Source(6, 1) + SourceIndex(1) name (c1) -2 >Emitted(18, 2) Source(6, 2) + SourceIndex(1) name (c1) -3 >Emitted(18, 2) Source(4, 1) + SourceIndex(1) -4 >Emitted(18, 6) Source(6, 2) + SourceIndex(1) +1 >Emitted(32, 1) Source(6, 1) + SourceIndex(2) name (c1) +2 >Emitted(32, 2) Source(6, 2) + SourceIndex(2) name (c1) +3 >Emitted(32, 2) Source(4, 1) + SourceIndex(2) +4 >Emitted(32, 6) Source(6, 2) + SourceIndex(2) --- >>>var instance1 = new c1(); 1-> @@ -425,21 +591,21 @@ sourceFile:../test.ts 6 > c1 7 > () 8 > ; -1->Emitted(19, 1) Source(8, 1) + SourceIndex(1) -2 >Emitted(19, 5) Source(8, 5) + SourceIndex(1) -3 >Emitted(19, 14) Source(8, 14) + SourceIndex(1) -4 >Emitted(19, 17) Source(8, 17) + SourceIndex(1) -5 >Emitted(19, 21) Source(8, 21) + SourceIndex(1) -6 >Emitted(19, 23) Source(8, 23) + SourceIndex(1) -7 >Emitted(19, 25) Source(8, 25) + SourceIndex(1) -8 >Emitted(19, 26) Source(8, 26) + SourceIndex(1) +1->Emitted(33, 1) Source(8, 1) + SourceIndex(2) +2 >Emitted(33, 5) Source(8, 5) + SourceIndex(2) +3 >Emitted(33, 14) Source(8, 14) + SourceIndex(2) +4 >Emitted(33, 17) Source(8, 17) + SourceIndex(2) +5 >Emitted(33, 21) Source(8, 21) + SourceIndex(2) +6 >Emitted(33, 23) Source(8, 23) + SourceIndex(2) +7 >Emitted(33, 25) Source(8, 25) + SourceIndex(2) +8 >Emitted(33, 26) Source(8, 26) + SourceIndex(2) --- >>>function f1() { 1 > 2 >^^^^^^^^^^^^^^^^^^^^^^-> 1 > > -1 >Emitted(20, 1) Source(9, 1) + SourceIndex(1) +1 >Emitted(34, 1) Source(9, 1) + SourceIndex(2) --- >>> return instance1; 1->^^^^ @@ -453,11 +619,11 @@ sourceFile:../test.ts 3 > 4 > instance1 5 > ; -1->Emitted(21, 5) Source(10, 5) + SourceIndex(1) name (f1) -2 >Emitted(21, 11) Source(10, 11) + SourceIndex(1) name (f1) -3 >Emitted(21, 12) Source(10, 12) + SourceIndex(1) name (f1) -4 >Emitted(21, 21) Source(10, 21) + SourceIndex(1) name (f1) -5 >Emitted(21, 22) Source(10, 22) + SourceIndex(1) name (f1) +1->Emitted(35, 5) Source(10, 5) + SourceIndex(2) name (f1) +2 >Emitted(35, 11) Source(10, 11) + SourceIndex(2) name (f1) +3 >Emitted(35, 12) Source(10, 12) + SourceIndex(2) name (f1) +4 >Emitted(35, 21) Source(10, 21) + SourceIndex(2) name (f1) +5 >Emitted(35, 22) Source(10, 22) + SourceIndex(2) name (f1) --- >>>} 1 > @@ -466,7 +632,7 @@ sourceFile:../test.ts 1 > > 2 >} -1 >Emitted(22, 1) Source(11, 1) + SourceIndex(1) name (f1) -2 >Emitted(22, 2) Source(11, 2) + SourceIndex(1) name (f1) +1 >Emitted(36, 1) Source(11, 1) + SourceIndex(2) name (f1) +2 >Emitted(36, 2) Source(11, 2) + SourceIndex(2) name (f1) --- >>>//# sourceMappingURL=/tests/cases/projects/outputdir_mixed_subfolder/mapFiles/test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFile/node/bin/test.d.ts b/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFile/node/bin/test.d.ts deleted file mode 100644 index d61b4c3b876..00000000000 --- a/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFile/node/bin/test.d.ts +++ /dev/null @@ -1,13 +0,0 @@ -/// -declare var m1_a1: number; -declare class m1_c1 { - m1_c1_p1: number; -} -declare var m1_instance1: m1_c1; -declare function m1_f1(): m1_c1; -declare var a1: number; -declare class c1 { - p1: number; -} -declare var instance1: c1; -declare function f1(): c1; diff --git a/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFile/node/bin/test.js b/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFile/node/bin/test.js deleted file mode 100644 index 7ef36232b8d..00000000000 --- a/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFile/node/bin/test.js +++ /dev/null @@ -1,23 +0,0 @@ -var m1_a1 = 10; -var m1_c1 = (function () { - function m1_c1() { - } - return m1_c1; -})(); -var m1_instance1 = new m1_c1(); -function m1_f1() { - return m1_instance1; -} -/// -/// -var a1 = 10; -var c1 = (function () { - function c1() { - } - return c1; -})(); -var instance1 = new c1(); -function f1() { - return instance1; -} -//# sourceMappingURL=/tests/cases/projects/outputdir_mixed_subfolder/mapFiles/test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFile/node/bin/test.js.map b/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFile/node/bin/test.js.map index a1d591a0497..a580c050d07 100644 --- a/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFile/node/bin/test.js.map +++ b/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFile/node/bin/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"","sources":["../ref/m1.ts","../test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACRD,iCAAiC;AACjC,iCAAiC;AACjC,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"","sources":["../ref/m1.ts","../ref/m2.ts","../test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;AERD,iCAAiC;AACjC,iCAAiC;AACjC,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFile/node/mapRootAbsolutePathMixedSubfolderSpecifyOutputFile.sourcemap.txt b/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFile/node/mapRootAbsolutePathMixedSubfolderSpecifyOutputFile.sourcemap.txt index 0b573b627cf..c6aeabde516 100644 --- a/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFile/node/mapRootAbsolutePathMixedSubfolderSpecifyOutputFile.sourcemap.txt +++ b/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFile/node/mapRootAbsolutePathMixedSubfolderSpecifyOutputFile.sourcemap.txt @@ -173,7 +173,7 @@ sourceFile:../../ref/m2.ts JsFile: test.js mapUrl: /tests/cases/projects/outputdir_mixed_subfolder/mapFiles/test.js.map sourceRoot: -sources: ../ref/m1.ts,../test.ts +sources: ../ref/m1.ts,../ref/m2.ts,../test.ts =================================================================== ------------------------------------------------------------------- emittedFile:bin/test.js @@ -322,8 +322,8 @@ sourceFile:../test.ts 3 > ^-> 1-> 2 >/// -1->Emitted(11, 1) Source(1, 1) + SourceIndex(1) -2 >Emitted(11, 34) Source(1, 34) + SourceIndex(1) +1->Emitted(11, 1) Source(1, 1) + SourceIndex(2) +2 >Emitted(11, 34) Source(1, 34) + SourceIndex(2) --- >>>/// 1-> @@ -331,8 +331,8 @@ sourceFile:../test.ts 1-> > 2 >/// -1->Emitted(12, 1) Source(2, 1) + SourceIndex(1) -2 >Emitted(12, 34) Source(2, 34) + SourceIndex(1) +1->Emitted(12, 1) Source(2, 1) + SourceIndex(2) +2 >Emitted(12, 34) Source(2, 34) + SourceIndex(2) --- >>>var a1 = 10; 1 > @@ -349,25 +349,25 @@ sourceFile:../test.ts 4 > = 5 > 10 6 > ; -1 >Emitted(13, 1) Source(3, 1) + SourceIndex(1) -2 >Emitted(13, 5) Source(3, 5) + SourceIndex(1) -3 >Emitted(13, 7) Source(3, 7) + SourceIndex(1) -4 >Emitted(13, 10) Source(3, 10) + SourceIndex(1) -5 >Emitted(13, 12) Source(3, 12) + SourceIndex(1) -6 >Emitted(13, 13) Source(3, 13) + SourceIndex(1) +1 >Emitted(13, 1) Source(3, 1) + SourceIndex(2) +2 >Emitted(13, 5) Source(3, 5) + SourceIndex(2) +3 >Emitted(13, 7) Source(3, 7) + SourceIndex(2) +4 >Emitted(13, 10) Source(3, 10) + SourceIndex(2) +5 >Emitted(13, 12) Source(3, 12) + SourceIndex(2) +6 >Emitted(13, 13) Source(3, 13) + SourceIndex(2) --- >>>var c1 = (function () { 1-> 2 >^^^^^^^^^^^^^^^^^^^^-> 1-> > -1->Emitted(14, 1) Source(4, 1) + SourceIndex(1) +1->Emitted(14, 1) Source(4, 1) + SourceIndex(2) --- >>> function c1() { 1->^^^^ 2 > ^^-> 1-> -1->Emitted(15, 5) Source(4, 1) + SourceIndex(1) name (c1) +1->Emitted(15, 5) Source(4, 1) + SourceIndex(2) name (c1) --- >>> } 1->^^^^ @@ -377,16 +377,16 @@ sourceFile:../test.ts > public p1: number; > 2 > } -1->Emitted(16, 5) Source(6, 1) + SourceIndex(1) name (c1.constructor) -2 >Emitted(16, 6) Source(6, 2) + SourceIndex(1) name (c1.constructor) +1->Emitted(16, 5) Source(6, 1) + SourceIndex(2) name (c1.constructor) +2 >Emitted(16, 6) Source(6, 2) + SourceIndex(2) name (c1.constructor) --- >>> return c1; 1->^^^^ 2 > ^^^^^^^^^ 1-> 2 > } -1->Emitted(17, 5) Source(6, 1) + SourceIndex(1) name (c1) -2 >Emitted(17, 14) Source(6, 2) + SourceIndex(1) name (c1) +1->Emitted(17, 5) Source(6, 1) + SourceIndex(2) name (c1) +2 >Emitted(17, 14) Source(6, 2) + SourceIndex(2) name (c1) --- >>>})(); 1 > @@ -400,10 +400,10 @@ sourceFile:../test.ts 4 > class c1 { > public p1: number; > } -1 >Emitted(18, 1) Source(6, 1) + SourceIndex(1) name (c1) -2 >Emitted(18, 2) Source(6, 2) + SourceIndex(1) name (c1) -3 >Emitted(18, 2) Source(4, 1) + SourceIndex(1) -4 >Emitted(18, 6) Source(6, 2) + SourceIndex(1) +1 >Emitted(18, 1) Source(6, 1) + SourceIndex(2) name (c1) +2 >Emitted(18, 2) Source(6, 2) + SourceIndex(2) name (c1) +3 >Emitted(18, 2) Source(4, 1) + SourceIndex(2) +4 >Emitted(18, 6) Source(6, 2) + SourceIndex(2) --- >>>var instance1 = new c1(); 1-> @@ -424,21 +424,21 @@ sourceFile:../test.ts 6 > c1 7 > () 8 > ; -1->Emitted(19, 1) Source(8, 1) + SourceIndex(1) -2 >Emitted(19, 5) Source(8, 5) + SourceIndex(1) -3 >Emitted(19, 14) Source(8, 14) + SourceIndex(1) -4 >Emitted(19, 17) Source(8, 17) + SourceIndex(1) -5 >Emitted(19, 21) Source(8, 21) + SourceIndex(1) -6 >Emitted(19, 23) Source(8, 23) + SourceIndex(1) -7 >Emitted(19, 25) Source(8, 25) + SourceIndex(1) -8 >Emitted(19, 26) Source(8, 26) + SourceIndex(1) +1->Emitted(19, 1) Source(8, 1) + SourceIndex(2) +2 >Emitted(19, 5) Source(8, 5) + SourceIndex(2) +3 >Emitted(19, 14) Source(8, 14) + SourceIndex(2) +4 >Emitted(19, 17) Source(8, 17) + SourceIndex(2) +5 >Emitted(19, 21) Source(8, 21) + SourceIndex(2) +6 >Emitted(19, 23) Source(8, 23) + SourceIndex(2) +7 >Emitted(19, 25) Source(8, 25) + SourceIndex(2) +8 >Emitted(19, 26) Source(8, 26) + SourceIndex(2) --- >>>function f1() { 1 > 2 >^^^^^^^^^^^^^^^^^^^^^^-> 1 > > -1 >Emitted(20, 1) Source(9, 1) + SourceIndex(1) +1 >Emitted(20, 1) Source(9, 1) + SourceIndex(2) --- >>> return instance1; 1->^^^^ @@ -452,11 +452,11 @@ sourceFile:../test.ts 3 > 4 > instance1 5 > ; -1->Emitted(21, 5) Source(10, 5) + SourceIndex(1) name (f1) -2 >Emitted(21, 11) Source(10, 11) + SourceIndex(1) name (f1) -3 >Emitted(21, 12) Source(10, 12) + SourceIndex(1) name (f1) -4 >Emitted(21, 21) Source(10, 21) + SourceIndex(1) name (f1) -5 >Emitted(21, 22) Source(10, 22) + SourceIndex(1) name (f1) +1->Emitted(21, 5) Source(10, 5) + SourceIndex(2) name (f1) +2 >Emitted(21, 11) Source(10, 11) + SourceIndex(2) name (f1) +3 >Emitted(21, 12) Source(10, 12) + SourceIndex(2) name (f1) +4 >Emitted(21, 21) Source(10, 21) + SourceIndex(2) name (f1) +5 >Emitted(21, 22) Source(10, 22) + SourceIndex(2) name (f1) --- >>>} 1 > @@ -465,7 +465,7 @@ sourceFile:../test.ts 1 > > 2 >} -1 >Emitted(22, 1) Source(11, 1) + SourceIndex(1) name (f1) -2 >Emitted(22, 2) Source(11, 2) + SourceIndex(1) name (f1) +1 >Emitted(22, 1) Source(11, 1) + SourceIndex(2) name (f1) +2 >Emitted(22, 2) Source(11, 2) + SourceIndex(2) name (f1) --- >>>//# sourceMappingURL=/tests/cases/projects/outputdir_mixed_subfolder/mapFiles/test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.d.ts b/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.d.ts deleted file mode 100644 index 9b9cdd4a214..00000000000 --- a/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.d.ts +++ /dev/null @@ -1,13 +0,0 @@ -/// -declare var m1_a1: number; -declare class m1_c1 { - m1_c1_p1: number; -} -declare var m1_instance1: m1_c1; -declare function m1_f1(): m1_c1; -declare var a1: number; -declare class c1 { - p1: number; -} -declare var instance1: c1; -declare function f1(): c1; diff --git a/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.js b/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.js deleted file mode 100644 index fc53d59d7cb..00000000000 --- a/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.js +++ /dev/null @@ -1,23 +0,0 @@ -var m1_a1 = 10; -var m1_c1 = (function () { - function m1_c1() { - } - return m1_c1; -})(); -var m1_instance1 = new m1_c1(); -function m1_f1() { - return m1_instance1; -} -/// -/// -var a1 = 10; -var c1 = (function () { - function c1() { - } - return c1; -})(); -var instance1 = new c1(); -function f1() { - return instance1; -} -//# sourceMappingURL=/tests/cases/projects/outputdir_mixed_subfolder/mapFiles/outAndOutDirFile.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.js.map b/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.js.map index 4f87045fd25..22aaecafe2d 100644 --- a/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.js.map +++ b/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.js.map @@ -1 +1 @@ -{"version":3,"file":"outAndOutDirFile.js","sourceRoot":"","sources":["../ref/m1.ts","../test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACRD,iCAAiC;AACjC,iCAAiC;AACjC,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"outAndOutDirFile.js","sourceRoot":"","sources":["../ref/m1.ts","../ref/m2.ts","../test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","m2_c1","m2_c1.constructor","m2_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;;ICRU,aAAK,GAAG,EAAE,CAAC;IACtB;QAAAC;QAEAC,CAACA;QAADD,YAACA;IAADA,CAACA,AAFD,IAEC;IAFY,aAAK,QAEjB,CAAA;IAEU,oBAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACIE,MAAMA,CAACA,oBAAYA,CAACA;IACxBA,CAACA;IAFe,aAAK,QAEpB,CAAA;;ACRD,iCAAiC;AACjC,iCAAiC;AACjC,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/mapRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory.sourcemap.txt b/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/mapRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory.sourcemap.txt index a9e2e3f0e3c..68630d9e431 100644 --- a/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/mapRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory.sourcemap.txt +++ b/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/mapRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory.sourcemap.txt @@ -174,7 +174,7 @@ sourceFile:../../ref/m2.ts JsFile: outAndOutDirFile.js mapUrl: /tests/cases/projects/outputdir_mixed_subfolder/mapFiles/outAndOutDirFile.js.map sourceRoot: -sources: ../ref/m1.ts,../test.ts +sources: ../ref/m1.ts,../ref/m2.ts,../test.ts =================================================================== ------------------------------------------------------------------- emittedFile:bin/outAndOutDirFile.js @@ -306,7 +306,7 @@ sourceFile:../ref/m1.ts >>>} 1 > 2 >^ -3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> 1 > > 2 >} @@ -315,16 +315,182 @@ sourceFile:../ref/m1.ts --- ------------------------------------------------------------------- emittedFile:bin/outAndOutDirFile.js +sourceFile:../ref/m2.ts +------------------------------------------------------------------- +>>>define("ref/m2", ["require", "exports"], function (require, exports) { +>>> exports.m2_a1 = 10; +1->^^^^ +2 > ^^^^^^^^^^^^^ +3 > ^^^ +4 > ^^ +5 > ^ +6 > ^^^^^^^^-> +1->export var +2 > m2_a1 +3 > = +4 > 10 +5 > ; +1->Emitted(12, 5) Source(1, 12) + SourceIndex(1) +2 >Emitted(12, 18) Source(1, 17) + SourceIndex(1) +3 >Emitted(12, 21) Source(1, 20) + SourceIndex(1) +4 >Emitted(12, 23) Source(1, 22) + SourceIndex(1) +5 >Emitted(12, 24) Source(1, 23) + SourceIndex(1) +--- +>>> var m2_c1 = (function () { +1->^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^^^^-> +1-> + > +1->Emitted(13, 5) Source(2, 1) + SourceIndex(1) +--- +>>> function m2_c1() { +1->^^^^^^^^ +2 > ^^-> +1-> +1->Emitted(14, 9) Source(2, 1) + SourceIndex(1) name (m2_c1) +--- +>>> } +1->^^^^^^^^ +2 > ^ +3 > ^^^^^^^^^^^^^-> +1->export class m2_c1 { + > public m2_c1_p1: number; + > +2 > } +1->Emitted(15, 9) Source(4, 1) + SourceIndex(1) name (m2_c1.constructor) +2 >Emitted(15, 10) Source(4, 2) + SourceIndex(1) name (m2_c1.constructor) +--- +>>> return m2_c1; +1->^^^^^^^^ +2 > ^^^^^^^^^^^^ +1-> +2 > } +1->Emitted(16, 9) Source(4, 1) + SourceIndex(1) name (m2_c1) +2 >Emitted(16, 21) Source(4, 2) + SourceIndex(1) name (m2_c1) +--- +>>> })(); +1 >^^^^ +2 > ^ +3 > +4 > ^^^^ +5 > ^^^^^^^^^^^^^^^^^^-> +1 > +2 > } +3 > +4 > export class m2_c1 { + > public m2_c1_p1: number; + > } +1 >Emitted(17, 5) Source(4, 1) + SourceIndex(1) name (m2_c1) +2 >Emitted(17, 6) Source(4, 2) + SourceIndex(1) name (m2_c1) +3 >Emitted(17, 6) Source(2, 1) + SourceIndex(1) +4 >Emitted(17, 10) Source(4, 2) + SourceIndex(1) +--- +>>> exports.m2_c1 = m2_c1; +1->^^^^ +2 > ^^^^^^^^^^^^^ +3 > ^^^^^^^^ +4 > ^ +5 > ^^^^^^^^^^^^^^-> +1-> +2 > m2_c1 +3 > { + > public m2_c1_p1: number; + > } +4 > +1->Emitted(18, 5) Source(2, 14) + SourceIndex(1) +2 >Emitted(18, 18) Source(2, 19) + SourceIndex(1) +3 >Emitted(18, 26) Source(4, 2) + SourceIndex(1) +4 >Emitted(18, 27) Source(4, 2) + SourceIndex(1) +--- +>>> exports.m2_instance1 = new m2_c1(); +1->^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^ +3 > ^^^ +4 > ^^^^ +5 > ^^^^^ +6 > ^^ +7 > ^ +1-> + > + >export var +2 > m2_instance1 +3 > = +4 > new +5 > m2_c1 +6 > () +7 > ; +1->Emitted(19, 5) Source(6, 12) + SourceIndex(1) +2 >Emitted(19, 25) Source(6, 24) + SourceIndex(1) +3 >Emitted(19, 28) Source(6, 27) + SourceIndex(1) +4 >Emitted(19, 32) Source(6, 31) + SourceIndex(1) +5 >Emitted(19, 37) Source(6, 36) + SourceIndex(1) +6 >Emitted(19, 39) Source(6, 38) + SourceIndex(1) +7 >Emitted(19, 40) Source(6, 39) + SourceIndex(1) +--- +>>> function m2_f1() { +1 >^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +1 > + > +1 >Emitted(20, 5) Source(7, 1) + SourceIndex(1) +--- +>>> return exports.m2_instance1; +1->^^^^^^^^ +2 > ^^^^^^ +3 > ^ +4 > ^^^^^^^^^^^^^^^^^^^^ +5 > ^ +1->export function m2_f1() { + > +2 > return +3 > +4 > m2_instance1 +5 > ; +1->Emitted(21, 9) Source(8, 5) + SourceIndex(1) name (m2_f1) +2 >Emitted(21, 15) Source(8, 11) + SourceIndex(1) name (m2_f1) +3 >Emitted(21, 16) Source(8, 12) + SourceIndex(1) name (m2_f1) +4 >Emitted(21, 36) Source(8, 24) + SourceIndex(1) name (m2_f1) +5 >Emitted(21, 37) Source(8, 25) + SourceIndex(1) name (m2_f1) +--- +>>> } +1 >^^^^ +2 > ^ +3 > ^^^^^^^^^^^^^^^^^^^^^^-> +1 > + > +2 > } +1 >Emitted(22, 5) Source(9, 1) + SourceIndex(1) name (m2_f1) +2 >Emitted(22, 6) Source(9, 2) + SourceIndex(1) name (m2_f1) +--- +>>> exports.m2_f1 = m2_f1; +1->^^^^ +2 > ^^^^^^^^^^^^^ +3 > ^^^^^^^^ +4 > ^ +1-> +2 > m2_f1 +3 > () { + > return m2_instance1; + > } +4 > +1->Emitted(23, 5) Source(7, 17) + SourceIndex(1) +2 >Emitted(23, 18) Source(7, 22) + SourceIndex(1) +3 >Emitted(23, 26) Source(9, 2) + SourceIndex(1) +4 >Emitted(23, 27) Source(9, 2) + SourceIndex(1) +--- +------------------------------------------------------------------- +emittedFile:bin/outAndOutDirFile.js sourceFile:../test.ts ------------------------------------------------------------------- +>>>}); >>>/// -1-> +1 > 2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 3 > ^-> -1-> +1 > 2 >/// -1->Emitted(11, 1) Source(1, 1) + SourceIndex(1) -2 >Emitted(11, 34) Source(1, 34) + SourceIndex(1) +1 >Emitted(25, 1) Source(1, 1) + SourceIndex(2) +2 >Emitted(25, 34) Source(1, 34) + SourceIndex(2) --- >>>/// 1-> @@ -332,8 +498,8 @@ sourceFile:../test.ts 1-> > 2 >/// -1->Emitted(12, 1) Source(2, 1) + SourceIndex(1) -2 >Emitted(12, 34) Source(2, 34) + SourceIndex(1) +1->Emitted(26, 1) Source(2, 1) + SourceIndex(2) +2 >Emitted(26, 34) Source(2, 34) + SourceIndex(2) --- >>>var a1 = 10; 1 > @@ -350,25 +516,25 @@ sourceFile:../test.ts 4 > = 5 > 10 6 > ; -1 >Emitted(13, 1) Source(3, 1) + SourceIndex(1) -2 >Emitted(13, 5) Source(3, 5) + SourceIndex(1) -3 >Emitted(13, 7) Source(3, 7) + SourceIndex(1) -4 >Emitted(13, 10) Source(3, 10) + SourceIndex(1) -5 >Emitted(13, 12) Source(3, 12) + SourceIndex(1) -6 >Emitted(13, 13) Source(3, 13) + SourceIndex(1) +1 >Emitted(27, 1) Source(3, 1) + SourceIndex(2) +2 >Emitted(27, 5) Source(3, 5) + SourceIndex(2) +3 >Emitted(27, 7) Source(3, 7) + SourceIndex(2) +4 >Emitted(27, 10) Source(3, 10) + SourceIndex(2) +5 >Emitted(27, 12) Source(3, 12) + SourceIndex(2) +6 >Emitted(27, 13) Source(3, 13) + SourceIndex(2) --- >>>var c1 = (function () { 1-> 2 >^^^^^^^^^^^^^^^^^^^^-> 1-> > -1->Emitted(14, 1) Source(4, 1) + SourceIndex(1) +1->Emitted(28, 1) Source(4, 1) + SourceIndex(2) --- >>> function c1() { 1->^^^^ 2 > ^^-> 1-> -1->Emitted(15, 5) Source(4, 1) + SourceIndex(1) name (c1) +1->Emitted(29, 5) Source(4, 1) + SourceIndex(2) name (c1) --- >>> } 1->^^^^ @@ -378,16 +544,16 @@ sourceFile:../test.ts > public p1: number; > 2 > } -1->Emitted(16, 5) Source(6, 1) + SourceIndex(1) name (c1.constructor) -2 >Emitted(16, 6) Source(6, 2) + SourceIndex(1) name (c1.constructor) +1->Emitted(30, 5) Source(6, 1) + SourceIndex(2) name (c1.constructor) +2 >Emitted(30, 6) Source(6, 2) + SourceIndex(2) name (c1.constructor) --- >>> return c1; 1->^^^^ 2 > ^^^^^^^^^ 1-> 2 > } -1->Emitted(17, 5) Source(6, 1) + SourceIndex(1) name (c1) -2 >Emitted(17, 14) Source(6, 2) + SourceIndex(1) name (c1) +1->Emitted(31, 5) Source(6, 1) + SourceIndex(2) name (c1) +2 >Emitted(31, 14) Source(6, 2) + SourceIndex(2) name (c1) --- >>>})(); 1 > @@ -401,10 +567,10 @@ sourceFile:../test.ts 4 > class c1 { > public p1: number; > } -1 >Emitted(18, 1) Source(6, 1) + SourceIndex(1) name (c1) -2 >Emitted(18, 2) Source(6, 2) + SourceIndex(1) name (c1) -3 >Emitted(18, 2) Source(4, 1) + SourceIndex(1) -4 >Emitted(18, 6) Source(6, 2) + SourceIndex(1) +1 >Emitted(32, 1) Source(6, 1) + SourceIndex(2) name (c1) +2 >Emitted(32, 2) Source(6, 2) + SourceIndex(2) name (c1) +3 >Emitted(32, 2) Source(4, 1) + SourceIndex(2) +4 >Emitted(32, 6) Source(6, 2) + SourceIndex(2) --- >>>var instance1 = new c1(); 1-> @@ -425,21 +591,21 @@ sourceFile:../test.ts 6 > c1 7 > () 8 > ; -1->Emitted(19, 1) Source(8, 1) + SourceIndex(1) -2 >Emitted(19, 5) Source(8, 5) + SourceIndex(1) -3 >Emitted(19, 14) Source(8, 14) + SourceIndex(1) -4 >Emitted(19, 17) Source(8, 17) + SourceIndex(1) -5 >Emitted(19, 21) Source(8, 21) + SourceIndex(1) -6 >Emitted(19, 23) Source(8, 23) + SourceIndex(1) -7 >Emitted(19, 25) Source(8, 25) + SourceIndex(1) -8 >Emitted(19, 26) Source(8, 26) + SourceIndex(1) +1->Emitted(33, 1) Source(8, 1) + SourceIndex(2) +2 >Emitted(33, 5) Source(8, 5) + SourceIndex(2) +3 >Emitted(33, 14) Source(8, 14) + SourceIndex(2) +4 >Emitted(33, 17) Source(8, 17) + SourceIndex(2) +5 >Emitted(33, 21) Source(8, 21) + SourceIndex(2) +6 >Emitted(33, 23) Source(8, 23) + SourceIndex(2) +7 >Emitted(33, 25) Source(8, 25) + SourceIndex(2) +8 >Emitted(33, 26) Source(8, 26) + SourceIndex(2) --- >>>function f1() { 1 > 2 >^^^^^^^^^^^^^^^^^^^^^^-> 1 > > -1 >Emitted(20, 1) Source(9, 1) + SourceIndex(1) +1 >Emitted(34, 1) Source(9, 1) + SourceIndex(2) --- >>> return instance1; 1->^^^^ @@ -453,11 +619,11 @@ sourceFile:../test.ts 3 > 4 > instance1 5 > ; -1->Emitted(21, 5) Source(10, 5) + SourceIndex(1) name (f1) -2 >Emitted(21, 11) Source(10, 11) + SourceIndex(1) name (f1) -3 >Emitted(21, 12) Source(10, 12) + SourceIndex(1) name (f1) -4 >Emitted(21, 21) Source(10, 21) + SourceIndex(1) name (f1) -5 >Emitted(21, 22) Source(10, 22) + SourceIndex(1) name (f1) +1->Emitted(35, 5) Source(10, 5) + SourceIndex(2) name (f1) +2 >Emitted(35, 11) Source(10, 11) + SourceIndex(2) name (f1) +3 >Emitted(35, 12) Source(10, 12) + SourceIndex(2) name (f1) +4 >Emitted(35, 21) Source(10, 21) + SourceIndex(2) name (f1) +5 >Emitted(35, 22) Source(10, 22) + SourceIndex(2) name (f1) --- >>>} 1 > @@ -466,7 +632,7 @@ sourceFile:../test.ts 1 > > 2 >} -1 >Emitted(22, 1) Source(11, 1) + SourceIndex(1) name (f1) -2 >Emitted(22, 2) Source(11, 2) + SourceIndex(1) name (f1) +1 >Emitted(36, 1) Source(11, 1) + SourceIndex(2) name (f1) +2 >Emitted(36, 2) Source(11, 2) + SourceIndex(2) name (f1) --- >>>//# sourceMappingURL=/tests/cases/projects/outputdir_mixed_subfolder/mapFiles/outAndOutDirFile.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.d.ts b/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.d.ts deleted file mode 100644 index 9b9cdd4a214..00000000000 --- a/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.d.ts +++ /dev/null @@ -1,13 +0,0 @@ -/// -declare var m1_a1: number; -declare class m1_c1 { - m1_c1_p1: number; -} -declare var m1_instance1: m1_c1; -declare function m1_f1(): m1_c1; -declare var a1: number; -declare class c1 { - p1: number; -} -declare var instance1: c1; -declare function f1(): c1; diff --git a/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.js b/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.js deleted file mode 100644 index fc53d59d7cb..00000000000 --- a/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.js +++ /dev/null @@ -1,23 +0,0 @@ -var m1_a1 = 10; -var m1_c1 = (function () { - function m1_c1() { - } - return m1_c1; -})(); -var m1_instance1 = new m1_c1(); -function m1_f1() { - return m1_instance1; -} -/// -/// -var a1 = 10; -var c1 = (function () { - function c1() { - } - return c1; -})(); -var instance1 = new c1(); -function f1() { - return instance1; -} -//# sourceMappingURL=/tests/cases/projects/outputdir_mixed_subfolder/mapFiles/outAndOutDirFile.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.js.map b/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.js.map index 4f87045fd25..2eab0f87324 100644 --- a/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.js.map +++ b/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.js.map @@ -1 +1 @@ -{"version":3,"file":"outAndOutDirFile.js","sourceRoot":"","sources":["../ref/m1.ts","../test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACRD,iCAAiC;AACjC,iCAAiC;AACjC,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"outAndOutDirFile.js","sourceRoot":"","sources":["../ref/m1.ts","../ref/m2.ts","../test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;AERD,iCAAiC;AACjC,iCAAiC;AACjC,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/mapRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory.sourcemap.txt b/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/mapRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory.sourcemap.txt index c4c267ec395..8f645dc8a2d 100644 --- a/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/mapRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory.sourcemap.txt +++ b/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/mapRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory.sourcemap.txt @@ -173,7 +173,7 @@ sourceFile:../../ref/m2.ts JsFile: outAndOutDirFile.js mapUrl: /tests/cases/projects/outputdir_mixed_subfolder/mapFiles/outAndOutDirFile.js.map sourceRoot: -sources: ../ref/m1.ts,../test.ts +sources: ../ref/m1.ts,../ref/m2.ts,../test.ts =================================================================== ------------------------------------------------------------------- emittedFile:bin/outAndOutDirFile.js @@ -322,8 +322,8 @@ sourceFile:../test.ts 3 > ^-> 1-> 2 >/// -1->Emitted(11, 1) Source(1, 1) + SourceIndex(1) -2 >Emitted(11, 34) Source(1, 34) + SourceIndex(1) +1->Emitted(11, 1) Source(1, 1) + SourceIndex(2) +2 >Emitted(11, 34) Source(1, 34) + SourceIndex(2) --- >>>/// 1-> @@ -331,8 +331,8 @@ sourceFile:../test.ts 1-> > 2 >/// -1->Emitted(12, 1) Source(2, 1) + SourceIndex(1) -2 >Emitted(12, 34) Source(2, 34) + SourceIndex(1) +1->Emitted(12, 1) Source(2, 1) + SourceIndex(2) +2 >Emitted(12, 34) Source(2, 34) + SourceIndex(2) --- >>>var a1 = 10; 1 > @@ -349,25 +349,25 @@ sourceFile:../test.ts 4 > = 5 > 10 6 > ; -1 >Emitted(13, 1) Source(3, 1) + SourceIndex(1) -2 >Emitted(13, 5) Source(3, 5) + SourceIndex(1) -3 >Emitted(13, 7) Source(3, 7) + SourceIndex(1) -4 >Emitted(13, 10) Source(3, 10) + SourceIndex(1) -5 >Emitted(13, 12) Source(3, 12) + SourceIndex(1) -6 >Emitted(13, 13) Source(3, 13) + SourceIndex(1) +1 >Emitted(13, 1) Source(3, 1) + SourceIndex(2) +2 >Emitted(13, 5) Source(3, 5) + SourceIndex(2) +3 >Emitted(13, 7) Source(3, 7) + SourceIndex(2) +4 >Emitted(13, 10) Source(3, 10) + SourceIndex(2) +5 >Emitted(13, 12) Source(3, 12) + SourceIndex(2) +6 >Emitted(13, 13) Source(3, 13) + SourceIndex(2) --- >>>var c1 = (function () { 1-> 2 >^^^^^^^^^^^^^^^^^^^^-> 1-> > -1->Emitted(14, 1) Source(4, 1) + SourceIndex(1) +1->Emitted(14, 1) Source(4, 1) + SourceIndex(2) --- >>> function c1() { 1->^^^^ 2 > ^^-> 1-> -1->Emitted(15, 5) Source(4, 1) + SourceIndex(1) name (c1) +1->Emitted(15, 5) Source(4, 1) + SourceIndex(2) name (c1) --- >>> } 1->^^^^ @@ -377,16 +377,16 @@ sourceFile:../test.ts > public p1: number; > 2 > } -1->Emitted(16, 5) Source(6, 1) + SourceIndex(1) name (c1.constructor) -2 >Emitted(16, 6) Source(6, 2) + SourceIndex(1) name (c1.constructor) +1->Emitted(16, 5) Source(6, 1) + SourceIndex(2) name (c1.constructor) +2 >Emitted(16, 6) Source(6, 2) + SourceIndex(2) name (c1.constructor) --- >>> return c1; 1->^^^^ 2 > ^^^^^^^^^ 1-> 2 > } -1->Emitted(17, 5) Source(6, 1) + SourceIndex(1) name (c1) -2 >Emitted(17, 14) Source(6, 2) + SourceIndex(1) name (c1) +1->Emitted(17, 5) Source(6, 1) + SourceIndex(2) name (c1) +2 >Emitted(17, 14) Source(6, 2) + SourceIndex(2) name (c1) --- >>>})(); 1 > @@ -400,10 +400,10 @@ sourceFile:../test.ts 4 > class c1 { > public p1: number; > } -1 >Emitted(18, 1) Source(6, 1) + SourceIndex(1) name (c1) -2 >Emitted(18, 2) Source(6, 2) + SourceIndex(1) name (c1) -3 >Emitted(18, 2) Source(4, 1) + SourceIndex(1) -4 >Emitted(18, 6) Source(6, 2) + SourceIndex(1) +1 >Emitted(18, 1) Source(6, 1) + SourceIndex(2) name (c1) +2 >Emitted(18, 2) Source(6, 2) + SourceIndex(2) name (c1) +3 >Emitted(18, 2) Source(4, 1) + SourceIndex(2) +4 >Emitted(18, 6) Source(6, 2) + SourceIndex(2) --- >>>var instance1 = new c1(); 1-> @@ -424,21 +424,21 @@ sourceFile:../test.ts 6 > c1 7 > () 8 > ; -1->Emitted(19, 1) Source(8, 1) + SourceIndex(1) -2 >Emitted(19, 5) Source(8, 5) + SourceIndex(1) -3 >Emitted(19, 14) Source(8, 14) + SourceIndex(1) -4 >Emitted(19, 17) Source(8, 17) + SourceIndex(1) -5 >Emitted(19, 21) Source(8, 21) + SourceIndex(1) -6 >Emitted(19, 23) Source(8, 23) + SourceIndex(1) -7 >Emitted(19, 25) Source(8, 25) + SourceIndex(1) -8 >Emitted(19, 26) Source(8, 26) + SourceIndex(1) +1->Emitted(19, 1) Source(8, 1) + SourceIndex(2) +2 >Emitted(19, 5) Source(8, 5) + SourceIndex(2) +3 >Emitted(19, 14) Source(8, 14) + SourceIndex(2) +4 >Emitted(19, 17) Source(8, 17) + SourceIndex(2) +5 >Emitted(19, 21) Source(8, 21) + SourceIndex(2) +6 >Emitted(19, 23) Source(8, 23) + SourceIndex(2) +7 >Emitted(19, 25) Source(8, 25) + SourceIndex(2) +8 >Emitted(19, 26) Source(8, 26) + SourceIndex(2) --- >>>function f1() { 1 > 2 >^^^^^^^^^^^^^^^^^^^^^^-> 1 > > -1 >Emitted(20, 1) Source(9, 1) + SourceIndex(1) +1 >Emitted(20, 1) Source(9, 1) + SourceIndex(2) --- >>> return instance1; 1->^^^^ @@ -452,11 +452,11 @@ sourceFile:../test.ts 3 > 4 > instance1 5 > ; -1->Emitted(21, 5) Source(10, 5) + SourceIndex(1) name (f1) -2 >Emitted(21, 11) Source(10, 11) + SourceIndex(1) name (f1) -3 >Emitted(21, 12) Source(10, 12) + SourceIndex(1) name (f1) -4 >Emitted(21, 21) Source(10, 21) + SourceIndex(1) name (f1) -5 >Emitted(21, 22) Source(10, 22) + SourceIndex(1) name (f1) +1->Emitted(21, 5) Source(10, 5) + SourceIndex(2) name (f1) +2 >Emitted(21, 11) Source(10, 11) + SourceIndex(2) name (f1) +3 >Emitted(21, 12) Source(10, 12) + SourceIndex(2) name (f1) +4 >Emitted(21, 21) Source(10, 21) + SourceIndex(2) name (f1) +5 >Emitted(21, 22) Source(10, 22) + SourceIndex(2) name (f1) --- >>>} 1 > @@ -465,7 +465,7 @@ sourceFile:../test.ts 1 > > 2 >} -1 >Emitted(22, 1) Source(11, 1) + SourceIndex(1) name (f1) -2 >Emitted(22, 2) Source(11, 2) + SourceIndex(1) name (f1) +1 >Emitted(22, 1) Source(11, 1) + SourceIndex(2) name (f1) +2 >Emitted(22, 2) Source(11, 2) + SourceIndex(2) name (f1) --- >>>//# sourceMappingURL=/tests/cases/projects/outputdir_mixed_subfolder/mapFiles/outAndOutDirFile.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderSpecifyOutputFile/amd/bin/test.d.ts b/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderSpecifyOutputFile/amd/bin/test.d.ts deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderSpecifyOutputFile/amd/bin/test.js b/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderSpecifyOutputFile/amd/bin/test.js deleted file mode 100644 index 18e06e5bc50..00000000000 --- a/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderSpecifyOutputFile/amd/bin/test.js +++ /dev/null @@ -1 +0,0 @@ -//# sourceMappingURL=/tests/cases/projects/outputdir_module_multifolder/mapFiles/test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderSpecifyOutputFile/amd/bin/test.js.map b/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderSpecifyOutputFile/amd/bin/test.js.map index c1e0281a2ab..c532c3846d9 100644 --- a/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderSpecifyOutputFile/amd/bin/test.js.map +++ b/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderSpecifyOutputFile/amd/bin/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"","sources":[],"names":[],"mappings":""} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"","sources":["../ref/m1.ts","../../outputdir_module_multifolder_ref/m2.ts","../test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","m2_c1","m2_c1.constructor","m2_f1","c1","c1.constructor","f1"],"mappings":";IAAW,aAAK,GAAG,EAAE,CAAC;IACtB;QAAAA;QAEAC,CAACA;QAADD,YAACA;IAADA,CAACA,AAFD,IAEC;IAFY,aAAK,QAEjB,CAAA;IAEU,oBAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACIE,MAAMA,CAACA,oBAAYA,CAACA;IACxBA,CAACA;IAFe,aAAK,QAEpB,CAAA;;;ICRU,aAAK,GAAG,EAAE,CAAC;IACtB;QAAAC;QAEAC,CAACA;QAADD,YAACA;IAADA,CAACA,AAFD,IAEC;IAFY,aAAK,QAEjB,CAAA;IAEU,oBAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACIE,MAAMA,CAACA,oBAAYA,CAACA;IACxBA,CAACA;IAFe,aAAK,QAEpB,CAAA;;;ICNU,UAAE,GAAG,EAAE,CAAC;IACnB;QAAAC;QAEAC,CAACA;QAADD,SAACA;IAADA,CAACA,AAFD,IAEC;IAFY,UAAE,KAEd,CAAA;IAEU,iBAAS,GAAG,IAAI,EAAE,EAAE,CAAC;IAChC;QACIE,MAAMA,CAACA,iBAASA,CAACA;IACrBA,CAACA;IAFe,UAAE,KAEjB,CAAA;IAEU,UAAE,GAAG,EAAE,CAAC,KAAK,CAAC;IACd,UAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderSpecifyOutputFile/amd/mapRootAbsolutePathModuleMultifolderSpecifyOutputFile.sourcemap.txt b/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderSpecifyOutputFile/amd/mapRootAbsolutePathModuleMultifolderSpecifyOutputFile.sourcemap.txt index da94013dea3..9384228ece5 100644 --- a/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderSpecifyOutputFile/amd/mapRootAbsolutePathModuleMultifolderSpecifyOutputFile.sourcemap.txt +++ b/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderSpecifyOutputFile/amd/mapRootAbsolutePathModuleMultifolderSpecifyOutputFile.sourcemap.txt @@ -571,6 +571,557 @@ sourceFile:../../test.ts JsFile: test.js mapUrl: /tests/cases/projects/outputdir_module_multifolder/mapFiles/test.js.map sourceRoot: -sources: +sources: ../ref/m1.ts,../../outputdir_module_multifolder_ref/m2.ts,../test.ts =================================================================== +------------------------------------------------------------------- +emittedFile:bin/test.js +sourceFile:../ref/m1.ts +------------------------------------------------------------------- +>>>define("ref/m1", ["require", "exports"], function (require, exports) { +>>> exports.m1_a1 = 10; +1 >^^^^ +2 > ^^^^^^^^^^^^^ +3 > ^^^ +4 > ^^ +5 > ^ +6 > ^^^^^^^^-> +1 >export var +2 > m1_a1 +3 > = +4 > 10 +5 > ; +1 >Emitted(2, 5) Source(1, 12) + SourceIndex(0) +2 >Emitted(2, 18) Source(1, 17) + SourceIndex(0) +3 >Emitted(2, 21) Source(1, 20) + SourceIndex(0) +4 >Emitted(2, 23) Source(1, 22) + SourceIndex(0) +5 >Emitted(2, 24) Source(1, 23) + SourceIndex(0) +--- +>>> var m1_c1 = (function () { +1->^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^^^^-> +1-> + > +1->Emitted(3, 5) Source(2, 1) + SourceIndex(0) +--- +>>> function m1_c1() { +1->^^^^^^^^ +2 > ^^-> +1-> +1->Emitted(4, 9) Source(2, 1) + SourceIndex(0) name (m1_c1) +--- +>>> } +1->^^^^^^^^ +2 > ^ +3 > ^^^^^^^^^^^^^-> +1->export class m1_c1 { + > public m1_c1_p1: number; + > +2 > } +1->Emitted(5, 9) Source(4, 1) + SourceIndex(0) name (m1_c1.constructor) +2 >Emitted(5, 10) Source(4, 2) + SourceIndex(0) name (m1_c1.constructor) +--- +>>> return m1_c1; +1->^^^^^^^^ +2 > ^^^^^^^^^^^^ +1-> +2 > } +1->Emitted(6, 9) Source(4, 1) + SourceIndex(0) name (m1_c1) +2 >Emitted(6, 21) Source(4, 2) + SourceIndex(0) name (m1_c1) +--- +>>> })(); +1 >^^^^ +2 > ^ +3 > +4 > ^^^^ +5 > ^^^^^^^^^^^^^^^^^^-> +1 > +2 > } +3 > +4 > export class m1_c1 { + > public m1_c1_p1: number; + > } +1 >Emitted(7, 5) Source(4, 1) + SourceIndex(0) name (m1_c1) +2 >Emitted(7, 6) Source(4, 2) + SourceIndex(0) name (m1_c1) +3 >Emitted(7, 6) Source(2, 1) + SourceIndex(0) +4 >Emitted(7, 10) Source(4, 2) + SourceIndex(0) +--- +>>> exports.m1_c1 = m1_c1; +1->^^^^ +2 > ^^^^^^^^^^^^^ +3 > ^^^^^^^^ +4 > ^ +5 > ^^^^^^^^^^^^^^-> +1-> +2 > m1_c1 +3 > { + > public m1_c1_p1: number; + > } +4 > +1->Emitted(8, 5) Source(2, 14) + SourceIndex(0) +2 >Emitted(8, 18) Source(2, 19) + SourceIndex(0) +3 >Emitted(8, 26) Source(4, 2) + SourceIndex(0) +4 >Emitted(8, 27) Source(4, 2) + SourceIndex(0) +--- +>>> exports.m1_instance1 = new m1_c1(); +1->^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^ +3 > ^^^ +4 > ^^^^ +5 > ^^^^^ +6 > ^^ +7 > ^ +1-> + > + >export var +2 > m1_instance1 +3 > = +4 > new +5 > m1_c1 +6 > () +7 > ; +1->Emitted(9, 5) Source(6, 12) + SourceIndex(0) +2 >Emitted(9, 25) Source(6, 24) + SourceIndex(0) +3 >Emitted(9, 28) Source(6, 27) + SourceIndex(0) +4 >Emitted(9, 32) Source(6, 31) + SourceIndex(0) +5 >Emitted(9, 37) Source(6, 36) + SourceIndex(0) +6 >Emitted(9, 39) Source(6, 38) + SourceIndex(0) +7 >Emitted(9, 40) Source(6, 39) + SourceIndex(0) +--- +>>> function m1_f1() { +1 >^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +1 > + > +1 >Emitted(10, 5) Source(7, 1) + SourceIndex(0) +--- +>>> return exports.m1_instance1; +1->^^^^^^^^ +2 > ^^^^^^ +3 > ^ +4 > ^^^^^^^^^^^^^^^^^^^^ +5 > ^ +1->export function m1_f1() { + > +2 > return +3 > +4 > m1_instance1 +5 > ; +1->Emitted(11, 9) Source(8, 5) + SourceIndex(0) name (m1_f1) +2 >Emitted(11, 15) Source(8, 11) + SourceIndex(0) name (m1_f1) +3 >Emitted(11, 16) Source(8, 12) + SourceIndex(0) name (m1_f1) +4 >Emitted(11, 36) Source(8, 24) + SourceIndex(0) name (m1_f1) +5 >Emitted(11, 37) Source(8, 25) + SourceIndex(0) name (m1_f1) +--- +>>> } +1 >^^^^ +2 > ^ +3 > ^^^^^^^^^^^^^^^^^^^^^^-> +1 > + > +2 > } +1 >Emitted(12, 5) Source(9, 1) + SourceIndex(0) name (m1_f1) +2 >Emitted(12, 6) Source(9, 2) + SourceIndex(0) name (m1_f1) +--- +>>> exports.m1_f1 = m1_f1; +1->^^^^ +2 > ^^^^^^^^^^^^^ +3 > ^^^^^^^^ +4 > ^ +1-> +2 > m1_f1 +3 > () { + > return m1_instance1; + > } +4 > +1->Emitted(13, 5) Source(7, 17) + SourceIndex(0) +2 >Emitted(13, 18) Source(7, 22) + SourceIndex(0) +3 >Emitted(13, 26) Source(9, 2) + SourceIndex(0) +4 >Emitted(13, 27) Source(9, 2) + SourceIndex(0) +--- +------------------------------------------------------------------- +emittedFile:bin/test.js +sourceFile:../../outputdir_module_multifolder_ref/m2.ts +------------------------------------------------------------------- +>>>}); +>>>define("../outputdir_module_multifolder_ref/m2", ["require", "exports"], function (require, exports) { +>>> exports.m2_a1 = 10; +1 >^^^^ +2 > ^^^^^^^^^^^^^ +3 > ^^^ +4 > ^^ +5 > ^ +6 > ^^^^^^^^-> +1 >export var +2 > m2_a1 +3 > = +4 > 10 +5 > ; +1 >Emitted(16, 5) Source(1, 12) + SourceIndex(1) +2 >Emitted(16, 18) Source(1, 17) + SourceIndex(1) +3 >Emitted(16, 21) Source(1, 20) + SourceIndex(1) +4 >Emitted(16, 23) Source(1, 22) + SourceIndex(1) +5 >Emitted(16, 24) Source(1, 23) + SourceIndex(1) +--- +>>> var m2_c1 = (function () { +1->^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^^^^-> +1-> + > +1->Emitted(17, 5) Source(2, 1) + SourceIndex(1) +--- +>>> function m2_c1() { +1->^^^^^^^^ +2 > ^^-> +1-> +1->Emitted(18, 9) Source(2, 1) + SourceIndex(1) name (m2_c1) +--- +>>> } +1->^^^^^^^^ +2 > ^ +3 > ^^^^^^^^^^^^^-> +1->export class m2_c1 { + > public m2_c1_p1: number; + > +2 > } +1->Emitted(19, 9) Source(4, 1) + SourceIndex(1) name (m2_c1.constructor) +2 >Emitted(19, 10) Source(4, 2) + SourceIndex(1) name (m2_c1.constructor) +--- +>>> return m2_c1; +1->^^^^^^^^ +2 > ^^^^^^^^^^^^ +1-> +2 > } +1->Emitted(20, 9) Source(4, 1) + SourceIndex(1) name (m2_c1) +2 >Emitted(20, 21) Source(4, 2) + SourceIndex(1) name (m2_c1) +--- +>>> })(); +1 >^^^^ +2 > ^ +3 > +4 > ^^^^ +5 > ^^^^^^^^^^^^^^^^^^-> +1 > +2 > } +3 > +4 > export class m2_c1 { + > public m2_c1_p1: number; + > } +1 >Emitted(21, 5) Source(4, 1) + SourceIndex(1) name (m2_c1) +2 >Emitted(21, 6) Source(4, 2) + SourceIndex(1) name (m2_c1) +3 >Emitted(21, 6) Source(2, 1) + SourceIndex(1) +4 >Emitted(21, 10) Source(4, 2) + SourceIndex(1) +--- +>>> exports.m2_c1 = m2_c1; +1->^^^^ +2 > ^^^^^^^^^^^^^ +3 > ^^^^^^^^ +4 > ^ +5 > ^^^^^^^^^^^^^^-> +1-> +2 > m2_c1 +3 > { + > public m2_c1_p1: number; + > } +4 > +1->Emitted(22, 5) Source(2, 14) + SourceIndex(1) +2 >Emitted(22, 18) Source(2, 19) + SourceIndex(1) +3 >Emitted(22, 26) Source(4, 2) + SourceIndex(1) +4 >Emitted(22, 27) Source(4, 2) + SourceIndex(1) +--- +>>> exports.m2_instance1 = new m2_c1(); +1->^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^ +3 > ^^^ +4 > ^^^^ +5 > ^^^^^ +6 > ^^ +7 > ^ +1-> + > + >export var +2 > m2_instance1 +3 > = +4 > new +5 > m2_c1 +6 > () +7 > ; +1->Emitted(23, 5) Source(6, 12) + SourceIndex(1) +2 >Emitted(23, 25) Source(6, 24) + SourceIndex(1) +3 >Emitted(23, 28) Source(6, 27) + SourceIndex(1) +4 >Emitted(23, 32) Source(6, 31) + SourceIndex(1) +5 >Emitted(23, 37) Source(6, 36) + SourceIndex(1) +6 >Emitted(23, 39) Source(6, 38) + SourceIndex(1) +7 >Emitted(23, 40) Source(6, 39) + SourceIndex(1) +--- +>>> function m2_f1() { +1 >^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +1 > + > +1 >Emitted(24, 5) Source(7, 1) + SourceIndex(1) +--- +>>> return exports.m2_instance1; +1->^^^^^^^^ +2 > ^^^^^^ +3 > ^ +4 > ^^^^^^^^^^^^^^^^^^^^ +5 > ^ +1->export function m2_f1() { + > +2 > return +3 > +4 > m2_instance1 +5 > ; +1->Emitted(25, 9) Source(8, 5) + SourceIndex(1) name (m2_f1) +2 >Emitted(25, 15) Source(8, 11) + SourceIndex(1) name (m2_f1) +3 >Emitted(25, 16) Source(8, 12) + SourceIndex(1) name (m2_f1) +4 >Emitted(25, 36) Source(8, 24) + SourceIndex(1) name (m2_f1) +5 >Emitted(25, 37) Source(8, 25) + SourceIndex(1) name (m2_f1) +--- +>>> } +1 >^^^^ +2 > ^ +3 > ^^^^^^^^^^^^^^^^^^^^^^-> +1 > + > +2 > } +1 >Emitted(26, 5) Source(9, 1) + SourceIndex(1) name (m2_f1) +2 >Emitted(26, 6) Source(9, 2) + SourceIndex(1) name (m2_f1) +--- +>>> exports.m2_f1 = m2_f1; +1->^^^^ +2 > ^^^^^^^^^^^^^ +3 > ^^^^^^^^ +4 > ^ +1-> +2 > m2_f1 +3 > () { + > return m2_instance1; + > } +4 > +1->Emitted(27, 5) Source(7, 17) + SourceIndex(1) +2 >Emitted(27, 18) Source(7, 22) + SourceIndex(1) +3 >Emitted(27, 26) Source(9, 2) + SourceIndex(1) +4 >Emitted(27, 27) Source(9, 2) + SourceIndex(1) +--- +------------------------------------------------------------------- +emittedFile:bin/test.js +sourceFile:../test.ts +------------------------------------------------------------------- +>>>}); +>>>define("test", ["require", "exports", "ref/m1", "../outputdir_module_multifolder_ref/m2"], function (require, exports, m1, m2) { +>>> exports.a1 = 10; +1 >^^^^ +2 > ^^^^^^^^^^ +3 > ^^^ +4 > ^^ +5 > ^ +6 > ^^^^^^^^-> +1 >import m1 = require("ref/m1"); + >import m2 = require("../outputdir_module_multifolder_ref/m2"); + >export var +2 > a1 +3 > = +4 > 10 +5 > ; +1 >Emitted(30, 5) Source(3, 12) + SourceIndex(2) +2 >Emitted(30, 15) Source(3, 14) + SourceIndex(2) +3 >Emitted(30, 18) Source(3, 17) + SourceIndex(2) +4 >Emitted(30, 20) Source(3, 19) + SourceIndex(2) +5 >Emitted(30, 21) Source(3, 20) + SourceIndex(2) +--- +>>> var c1 = (function () { +1->^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^-> +1-> + > +1->Emitted(31, 5) Source(4, 1) + SourceIndex(2) +--- +>>> function c1() { +1->^^^^^^^^ +2 > ^^-> +1-> +1->Emitted(32, 9) Source(4, 1) + SourceIndex(2) name (c1) +--- +>>> } +1->^^^^^^^^ +2 > ^ +3 > ^^^^^^^^^^-> +1->export class c1 { + > public p1: number; + > +2 > } +1->Emitted(33, 9) Source(6, 1) + SourceIndex(2) name (c1.constructor) +2 >Emitted(33, 10) Source(6, 2) + SourceIndex(2) name (c1.constructor) +--- +>>> return c1; +1->^^^^^^^^ +2 > ^^^^^^^^^ +1-> +2 > } +1->Emitted(34, 9) Source(6, 1) + SourceIndex(2) name (c1) +2 >Emitted(34, 18) Source(6, 2) + SourceIndex(2) name (c1) +--- +>>> })(); +1 >^^^^ +2 > ^ +3 > +4 > ^^^^ +5 > ^^^^^^^^^^^^-> +1 > +2 > } +3 > +4 > export class c1 { + > public p1: number; + > } +1 >Emitted(35, 5) Source(6, 1) + SourceIndex(2) name (c1) +2 >Emitted(35, 6) Source(6, 2) + SourceIndex(2) name (c1) +3 >Emitted(35, 6) Source(4, 1) + SourceIndex(2) +4 >Emitted(35, 10) Source(6, 2) + SourceIndex(2) +--- +>>> exports.c1 = c1; +1->^^^^ +2 > ^^^^^^^^^^ +3 > ^^^^^ +4 > ^ +5 > ^^^^^^^^^^^^^^-> +1-> +2 > c1 +3 > { + > public p1: number; + > } +4 > +1->Emitted(36, 5) Source(4, 14) + SourceIndex(2) +2 >Emitted(36, 15) Source(4, 16) + SourceIndex(2) +3 >Emitted(36, 20) Source(6, 2) + SourceIndex(2) +4 >Emitted(36, 21) Source(6, 2) + SourceIndex(2) +--- +>>> exports.instance1 = new c1(); +1->^^^^ +2 > ^^^^^^^^^^^^^^^^^ +3 > ^^^ +4 > ^^^^ +5 > ^^ +6 > ^^ +7 > ^ +1-> + > + >export var +2 > instance1 +3 > = +4 > new +5 > c1 +6 > () +7 > ; +1->Emitted(37, 5) Source(8, 12) + SourceIndex(2) +2 >Emitted(37, 22) Source(8, 21) + SourceIndex(2) +3 >Emitted(37, 25) Source(8, 24) + SourceIndex(2) +4 >Emitted(37, 29) Source(8, 28) + SourceIndex(2) +5 >Emitted(37, 31) Source(8, 30) + SourceIndex(2) +6 >Emitted(37, 33) Source(8, 32) + SourceIndex(2) +7 >Emitted(37, 34) Source(8, 33) + SourceIndex(2) +--- +>>> function f1() { +1 >^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +1 > + > +1 >Emitted(38, 5) Source(9, 1) + SourceIndex(2) +--- +>>> return exports.instance1; +1->^^^^^^^^ +2 > ^^^^^^ +3 > ^ +4 > ^^^^^^^^^^^^^^^^^ +5 > ^ +1->export function f1() { + > +2 > return +3 > +4 > instance1 +5 > ; +1->Emitted(39, 9) Source(10, 5) + SourceIndex(2) name (f1) +2 >Emitted(39, 15) Source(10, 11) + SourceIndex(2) name (f1) +3 >Emitted(39, 16) Source(10, 12) + SourceIndex(2) name (f1) +4 >Emitted(39, 33) Source(10, 21) + SourceIndex(2) name (f1) +5 >Emitted(39, 34) Source(10, 22) + SourceIndex(2) name (f1) +--- +>>> } +1 >^^^^ +2 > ^ +3 > ^^^^^^^^^^^^^^^^-> +1 > + > +2 > } +1 >Emitted(40, 5) Source(11, 1) + SourceIndex(2) name (f1) +2 >Emitted(40, 6) Source(11, 2) + SourceIndex(2) name (f1) +--- +>>> exports.f1 = f1; +1->^^^^ +2 > ^^^^^^^^^^ +3 > ^^^^^ +4 > ^ +5 > ^^^^^^^-> +1-> +2 > f1 +3 > () { + > return instance1; + > } +4 > +1->Emitted(41, 5) Source(9, 17) + SourceIndex(2) +2 >Emitted(41, 15) Source(9, 19) + SourceIndex(2) +3 >Emitted(41, 20) Source(11, 2) + SourceIndex(2) +4 >Emitted(41, 21) Source(11, 2) + SourceIndex(2) +--- +>>> exports.a2 = m1.m1_c1; +1->^^^^ +2 > ^^^^^^^^^^ +3 > ^^^ +4 > ^^ +5 > ^ +6 > ^^^^^ +7 > ^ +8 > ^-> +1-> + > + >export var +2 > a2 +3 > = +4 > m1 +5 > . +6 > m1_c1 +7 > ; +1->Emitted(42, 5) Source(13, 12) + SourceIndex(2) +2 >Emitted(42, 15) Source(13, 14) + SourceIndex(2) +3 >Emitted(42, 18) Source(13, 17) + SourceIndex(2) +4 >Emitted(42, 20) Source(13, 19) + SourceIndex(2) +5 >Emitted(42, 21) Source(13, 20) + SourceIndex(2) +6 >Emitted(42, 26) Source(13, 25) + SourceIndex(2) +7 >Emitted(42, 27) Source(13, 26) + SourceIndex(2) +--- +>>> exports.a3 = m2.m2_c1; +1->^^^^ +2 > ^^^^^^^^^^ +3 > ^^^ +4 > ^^ +5 > ^ +6 > ^^^^^ +7 > ^ +1-> + >export var +2 > a3 +3 > = +4 > m2 +5 > . +6 > m2_c1 +7 > ; +1->Emitted(43, 5) Source(14, 12) + SourceIndex(2) +2 >Emitted(43, 15) Source(14, 14) + SourceIndex(2) +3 >Emitted(43, 18) Source(14, 17) + SourceIndex(2) +4 >Emitted(43, 20) Source(14, 19) + SourceIndex(2) +5 >Emitted(43, 21) Source(14, 20) + SourceIndex(2) +6 >Emitted(43, 26) Source(14, 25) + SourceIndex(2) +7 >Emitted(43, 27) Source(14, 26) + SourceIndex(2) +--- +>>>}); >>>//# sourceMappingURL=/tests/cases/projects/outputdir_module_multifolder/mapFiles/test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderSpecifyOutputFile/node/bin/test.d.ts b/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderSpecifyOutputFile/node/bin/test.d.ts deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderSpecifyOutputFile/node/bin/test.js b/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderSpecifyOutputFile/node/bin/test.js deleted file mode 100644 index 18e06e5bc50..00000000000 --- a/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderSpecifyOutputFile/node/bin/test.js +++ /dev/null @@ -1 +0,0 @@ -//# sourceMappingURL=/tests/cases/projects/outputdir_module_multifolder/mapFiles/test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderSpecifyOutputFile/node/bin/test.js.map b/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderSpecifyOutputFile/node/bin/test.js.map index c1e0281a2ab..2974abdc1cc 100644 --- a/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderSpecifyOutputFile/node/bin/test.js.map +++ b/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderSpecifyOutputFile/node/bin/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"","sources":[],"names":[],"mappings":""} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"","sources":["../ref/m1.ts","../../outputdir_module_multifolder_ref/m2.ts","../test.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderSpecifyOutputFile/node/mapRootAbsolutePathModuleMultifolderSpecifyOutputFile.sourcemap.txt b/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderSpecifyOutputFile/node/mapRootAbsolutePathModuleMultifolderSpecifyOutputFile.sourcemap.txt index f348cfad93c..47e6fcc66ef 100644 --- a/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderSpecifyOutputFile/node/mapRootAbsolutePathModuleMultifolderSpecifyOutputFile.sourcemap.txt +++ b/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderSpecifyOutputFile/node/mapRootAbsolutePathModuleMultifolderSpecifyOutputFile.sourcemap.txt @@ -615,6 +615,6 @@ sourceFile:../../test.ts JsFile: test.js mapUrl: /tests/cases/projects/outputdir_module_multifolder/mapFiles/test.js.map sourceRoot: -sources: +sources: ../ref/m1.ts,../../outputdir_module_multifolder_ref/m2.ts,../test.ts =================================================================== >>>//# sourceMappingURL=/tests/cases/projects/outputdir_module_multifolder/mapFiles/test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootAbsolutePathModuleSimpleSpecifyOutputFile/amd/bin/test.d.ts b/tests/baselines/reference/project/mapRootAbsolutePathModuleSimpleSpecifyOutputFile/amd/bin/test.d.ts deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/tests/baselines/reference/project/mapRootAbsolutePathModuleSimpleSpecifyOutputFile/amd/bin/test.js b/tests/baselines/reference/project/mapRootAbsolutePathModuleSimpleSpecifyOutputFile/amd/bin/test.js deleted file mode 100644 index f6e3eb542f4..00000000000 --- a/tests/baselines/reference/project/mapRootAbsolutePathModuleSimpleSpecifyOutputFile/amd/bin/test.js +++ /dev/null @@ -1 +0,0 @@ -//# sourceMappingURL=/tests/cases/projects/outputdir_module_simple/mapFiles/test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootAbsolutePathModuleSimpleSpecifyOutputFile/amd/bin/test.js.map b/tests/baselines/reference/project/mapRootAbsolutePathModuleSimpleSpecifyOutputFile/amd/bin/test.js.map index c1e0281a2ab..6377a26395e 100644 --- a/tests/baselines/reference/project/mapRootAbsolutePathModuleSimpleSpecifyOutputFile/amd/bin/test.js.map +++ b/tests/baselines/reference/project/mapRootAbsolutePathModuleSimpleSpecifyOutputFile/amd/bin/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"","sources":[],"names":[],"mappings":""} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"","sources":["../m1.ts","../test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","c1","c1.constructor","f1"],"mappings":";IAAW,aAAK,GAAG,EAAE,CAAC;IACtB;QAAAA;QAEAC,CAACA;QAADD,YAACA;IAADA,CAACA,AAFD,IAEC;IAFY,aAAK,QAEjB,CAAA;IAEU,oBAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACIE,MAAMA,CAACA,oBAAYA,CAACA;IACxBA,CAACA;IAFe,aAAK,QAEpB,CAAA;;;ICPU,UAAE,GAAG,EAAE,CAAC;IACnB;QAAAC;QAEAC,CAACA;QAADD,SAACA;IAADA,CAACA,AAFD,IAEC;IAFY,UAAE,KAEd,CAAA;IAEU,iBAAS,GAAG,IAAI,EAAE,EAAE,CAAC;IAChC;QACIE,MAAMA,CAACA,iBAASA,CAACA;IACrBA,CAACA;IAFe,UAAE,KAEjB,CAAA;IAEU,UAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootAbsolutePathModuleSimpleSpecifyOutputFile/amd/mapRootAbsolutePathModuleSimpleSpecifyOutputFile.sourcemap.txt b/tests/baselines/reference/project/mapRootAbsolutePathModuleSimpleSpecifyOutputFile/amd/mapRootAbsolutePathModuleSimpleSpecifyOutputFile.sourcemap.txt index 759b9dab302..ef240e21383 100644 --- a/tests/baselines/reference/project/mapRootAbsolutePathModuleSimpleSpecifyOutputFile/amd/mapRootAbsolutePathModuleSimpleSpecifyOutputFile.sourcemap.txt +++ b/tests/baselines/reference/project/mapRootAbsolutePathModuleSimpleSpecifyOutputFile/amd/mapRootAbsolutePathModuleSimpleSpecifyOutputFile.sourcemap.txt @@ -373,6 +373,365 @@ sourceFile:../test.ts JsFile: test.js mapUrl: /tests/cases/projects/outputdir_module_simple/mapFiles/test.js.map sourceRoot: -sources: +sources: ../m1.ts,../test.ts =================================================================== +------------------------------------------------------------------- +emittedFile:bin/test.js +sourceFile:../m1.ts +------------------------------------------------------------------- +>>>define("m1", ["require", "exports"], function (require, exports) { +>>> exports.m1_a1 = 10; +1 >^^^^ +2 > ^^^^^^^^^^^^^ +3 > ^^^ +4 > ^^ +5 > ^ +6 > ^^^^^^^^-> +1 >export var +2 > m1_a1 +3 > = +4 > 10 +5 > ; +1 >Emitted(2, 5) Source(1, 12) + SourceIndex(0) +2 >Emitted(2, 18) Source(1, 17) + SourceIndex(0) +3 >Emitted(2, 21) Source(1, 20) + SourceIndex(0) +4 >Emitted(2, 23) Source(1, 22) + SourceIndex(0) +5 >Emitted(2, 24) Source(1, 23) + SourceIndex(0) +--- +>>> var m1_c1 = (function () { +1->^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^^^^-> +1-> + > +1->Emitted(3, 5) Source(2, 1) + SourceIndex(0) +--- +>>> function m1_c1() { +1->^^^^^^^^ +2 > ^^-> +1-> +1->Emitted(4, 9) Source(2, 1) + SourceIndex(0) name (m1_c1) +--- +>>> } +1->^^^^^^^^ +2 > ^ +3 > ^^^^^^^^^^^^^-> +1->export class m1_c1 { + > public m1_c1_p1: number; + > +2 > } +1->Emitted(5, 9) Source(4, 1) + SourceIndex(0) name (m1_c1.constructor) +2 >Emitted(5, 10) Source(4, 2) + SourceIndex(0) name (m1_c1.constructor) +--- +>>> return m1_c1; +1->^^^^^^^^ +2 > ^^^^^^^^^^^^ +1-> +2 > } +1->Emitted(6, 9) Source(4, 1) + SourceIndex(0) name (m1_c1) +2 >Emitted(6, 21) Source(4, 2) + SourceIndex(0) name (m1_c1) +--- +>>> })(); +1 >^^^^ +2 > ^ +3 > +4 > ^^^^ +5 > ^^^^^^^^^^^^^^^^^^-> +1 > +2 > } +3 > +4 > export class m1_c1 { + > public m1_c1_p1: number; + > } +1 >Emitted(7, 5) Source(4, 1) + SourceIndex(0) name (m1_c1) +2 >Emitted(7, 6) Source(4, 2) + SourceIndex(0) name (m1_c1) +3 >Emitted(7, 6) Source(2, 1) + SourceIndex(0) +4 >Emitted(7, 10) Source(4, 2) + SourceIndex(0) +--- +>>> exports.m1_c1 = m1_c1; +1->^^^^ +2 > ^^^^^^^^^^^^^ +3 > ^^^^^^^^ +4 > ^ +5 > ^^^^^^^^^^^^^^-> +1-> +2 > m1_c1 +3 > { + > public m1_c1_p1: number; + > } +4 > +1->Emitted(8, 5) Source(2, 14) + SourceIndex(0) +2 >Emitted(8, 18) Source(2, 19) + SourceIndex(0) +3 >Emitted(8, 26) Source(4, 2) + SourceIndex(0) +4 >Emitted(8, 27) Source(4, 2) + SourceIndex(0) +--- +>>> exports.m1_instance1 = new m1_c1(); +1->^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^ +3 > ^^^ +4 > ^^^^ +5 > ^^^^^ +6 > ^^ +7 > ^ +1-> + > + >export var +2 > m1_instance1 +3 > = +4 > new +5 > m1_c1 +6 > () +7 > ; +1->Emitted(9, 5) Source(6, 12) + SourceIndex(0) +2 >Emitted(9, 25) Source(6, 24) + SourceIndex(0) +3 >Emitted(9, 28) Source(6, 27) + SourceIndex(0) +4 >Emitted(9, 32) Source(6, 31) + SourceIndex(0) +5 >Emitted(9, 37) Source(6, 36) + SourceIndex(0) +6 >Emitted(9, 39) Source(6, 38) + SourceIndex(0) +7 >Emitted(9, 40) Source(6, 39) + SourceIndex(0) +--- +>>> function m1_f1() { +1 >^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +1 > + > +1 >Emitted(10, 5) Source(7, 1) + SourceIndex(0) +--- +>>> return exports.m1_instance1; +1->^^^^^^^^ +2 > ^^^^^^ +3 > ^ +4 > ^^^^^^^^^^^^^^^^^^^^ +5 > ^ +1->export function m1_f1() { + > +2 > return +3 > +4 > m1_instance1 +5 > ; +1->Emitted(11, 9) Source(8, 5) + SourceIndex(0) name (m1_f1) +2 >Emitted(11, 15) Source(8, 11) + SourceIndex(0) name (m1_f1) +3 >Emitted(11, 16) Source(8, 12) + SourceIndex(0) name (m1_f1) +4 >Emitted(11, 36) Source(8, 24) + SourceIndex(0) name (m1_f1) +5 >Emitted(11, 37) Source(8, 25) + SourceIndex(0) name (m1_f1) +--- +>>> } +1 >^^^^ +2 > ^ +3 > ^^^^^^^^^^^^^^^^^^^^^^-> +1 > + > +2 > } +1 >Emitted(12, 5) Source(9, 1) + SourceIndex(0) name (m1_f1) +2 >Emitted(12, 6) Source(9, 2) + SourceIndex(0) name (m1_f1) +--- +>>> exports.m1_f1 = m1_f1; +1->^^^^ +2 > ^^^^^^^^^^^^^ +3 > ^^^^^^^^ +4 > ^ +1-> +2 > m1_f1 +3 > () { + > return m1_instance1; + > } +4 > +1->Emitted(13, 5) Source(7, 17) + SourceIndex(0) +2 >Emitted(13, 18) Source(7, 22) + SourceIndex(0) +3 >Emitted(13, 26) Source(9, 2) + SourceIndex(0) +4 >Emitted(13, 27) Source(9, 2) + SourceIndex(0) +--- +------------------------------------------------------------------- +emittedFile:bin/test.js +sourceFile:../test.ts +------------------------------------------------------------------- +>>>}); +>>>define("test", ["require", "exports", "m1"], function (require, exports, m1) { +>>> exports.a1 = 10; +1 >^^^^ +2 > ^^^^^^^^^^ +3 > ^^^ +4 > ^^ +5 > ^ +6 > ^^^^^^^^-> +1 >import m1 = require("m1"); + >export var +2 > a1 +3 > = +4 > 10 +5 > ; +1 >Emitted(16, 5) Source(2, 12) + SourceIndex(1) +2 >Emitted(16, 15) Source(2, 14) + SourceIndex(1) +3 >Emitted(16, 18) Source(2, 17) + SourceIndex(1) +4 >Emitted(16, 20) Source(2, 19) + SourceIndex(1) +5 >Emitted(16, 21) Source(2, 20) + SourceIndex(1) +--- +>>> var c1 = (function () { +1->^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^-> +1-> + > +1->Emitted(17, 5) Source(3, 1) + SourceIndex(1) +--- +>>> function c1() { +1->^^^^^^^^ +2 > ^^-> +1-> +1->Emitted(18, 9) Source(3, 1) + SourceIndex(1) name (c1) +--- +>>> } +1->^^^^^^^^ +2 > ^ +3 > ^^^^^^^^^^-> +1->export class c1 { + > public p1: number; + > +2 > } +1->Emitted(19, 9) Source(5, 1) + SourceIndex(1) name (c1.constructor) +2 >Emitted(19, 10) Source(5, 2) + SourceIndex(1) name (c1.constructor) +--- +>>> return c1; +1->^^^^^^^^ +2 > ^^^^^^^^^ +1-> +2 > } +1->Emitted(20, 9) Source(5, 1) + SourceIndex(1) name (c1) +2 >Emitted(20, 18) Source(5, 2) + SourceIndex(1) name (c1) +--- +>>> })(); +1 >^^^^ +2 > ^ +3 > +4 > ^^^^ +5 > ^^^^^^^^^^^^-> +1 > +2 > } +3 > +4 > export class c1 { + > public p1: number; + > } +1 >Emitted(21, 5) Source(5, 1) + SourceIndex(1) name (c1) +2 >Emitted(21, 6) Source(5, 2) + SourceIndex(1) name (c1) +3 >Emitted(21, 6) Source(3, 1) + SourceIndex(1) +4 >Emitted(21, 10) Source(5, 2) + SourceIndex(1) +--- +>>> exports.c1 = c1; +1->^^^^ +2 > ^^^^^^^^^^ +3 > ^^^^^ +4 > ^ +5 > ^^^^^^^^^^^^^^-> +1-> +2 > c1 +3 > { + > public p1: number; + > } +4 > +1->Emitted(22, 5) Source(3, 14) + SourceIndex(1) +2 >Emitted(22, 15) Source(3, 16) + SourceIndex(1) +3 >Emitted(22, 20) Source(5, 2) + SourceIndex(1) +4 >Emitted(22, 21) Source(5, 2) + SourceIndex(1) +--- +>>> exports.instance1 = new c1(); +1->^^^^ +2 > ^^^^^^^^^^^^^^^^^ +3 > ^^^ +4 > ^^^^ +5 > ^^ +6 > ^^ +7 > ^ +1-> + > + >export var +2 > instance1 +3 > = +4 > new +5 > c1 +6 > () +7 > ; +1->Emitted(23, 5) Source(7, 12) + SourceIndex(1) +2 >Emitted(23, 22) Source(7, 21) + SourceIndex(1) +3 >Emitted(23, 25) Source(7, 24) + SourceIndex(1) +4 >Emitted(23, 29) Source(7, 28) + SourceIndex(1) +5 >Emitted(23, 31) Source(7, 30) + SourceIndex(1) +6 >Emitted(23, 33) Source(7, 32) + SourceIndex(1) +7 >Emitted(23, 34) Source(7, 33) + SourceIndex(1) +--- +>>> function f1() { +1 >^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +1 > + > +1 >Emitted(24, 5) Source(8, 1) + SourceIndex(1) +--- +>>> return exports.instance1; +1->^^^^^^^^ +2 > ^^^^^^ +3 > ^ +4 > ^^^^^^^^^^^^^^^^^ +5 > ^ +1->export function f1() { + > +2 > return +3 > +4 > instance1 +5 > ; +1->Emitted(25, 9) Source(9, 5) + SourceIndex(1) name (f1) +2 >Emitted(25, 15) Source(9, 11) + SourceIndex(1) name (f1) +3 >Emitted(25, 16) Source(9, 12) + SourceIndex(1) name (f1) +4 >Emitted(25, 33) Source(9, 21) + SourceIndex(1) name (f1) +5 >Emitted(25, 34) Source(9, 22) + SourceIndex(1) name (f1) +--- +>>> } +1 >^^^^ +2 > ^ +3 > ^^^^^^^^^^^^^^^^-> +1 > + > +2 > } +1 >Emitted(26, 5) Source(10, 1) + SourceIndex(1) name (f1) +2 >Emitted(26, 6) Source(10, 2) + SourceIndex(1) name (f1) +--- +>>> exports.f1 = f1; +1->^^^^ +2 > ^^^^^^^^^^ +3 > ^^^^^ +4 > ^ +5 > ^^^^^^^-> +1-> +2 > f1 +3 > () { + > return instance1; + > } +4 > +1->Emitted(27, 5) Source(8, 17) + SourceIndex(1) +2 >Emitted(27, 15) Source(8, 19) + SourceIndex(1) +3 >Emitted(27, 20) Source(10, 2) + SourceIndex(1) +4 >Emitted(27, 21) Source(10, 2) + SourceIndex(1) +--- +>>> exports.a2 = m1.m1_c1; +1->^^^^ +2 > ^^^^^^^^^^ +3 > ^^^ +4 > ^^ +5 > ^ +6 > ^^^^^ +7 > ^ +1-> + > + >export var +2 > a2 +3 > = +4 > m1 +5 > . +6 > m1_c1 +7 > ; +1->Emitted(28, 5) Source(12, 12) + SourceIndex(1) +2 >Emitted(28, 15) Source(12, 14) + SourceIndex(1) +3 >Emitted(28, 18) Source(12, 17) + SourceIndex(1) +4 >Emitted(28, 20) Source(12, 19) + SourceIndex(1) +5 >Emitted(28, 21) Source(12, 20) + SourceIndex(1) +6 >Emitted(28, 26) Source(12, 25) + SourceIndex(1) +7 >Emitted(28, 27) Source(12, 26) + SourceIndex(1) +--- +>>>}); >>>//# sourceMappingURL=/tests/cases/projects/outputdir_module_simple/mapFiles/test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootAbsolutePathModuleSimpleSpecifyOutputFile/node/bin/test.d.ts b/tests/baselines/reference/project/mapRootAbsolutePathModuleSimpleSpecifyOutputFile/node/bin/test.d.ts deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/tests/baselines/reference/project/mapRootAbsolutePathModuleSimpleSpecifyOutputFile/node/bin/test.js b/tests/baselines/reference/project/mapRootAbsolutePathModuleSimpleSpecifyOutputFile/node/bin/test.js deleted file mode 100644 index f6e3eb542f4..00000000000 --- a/tests/baselines/reference/project/mapRootAbsolutePathModuleSimpleSpecifyOutputFile/node/bin/test.js +++ /dev/null @@ -1 +0,0 @@ -//# sourceMappingURL=/tests/cases/projects/outputdir_module_simple/mapFiles/test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootAbsolutePathModuleSimpleSpecifyOutputFile/node/bin/test.js.map b/tests/baselines/reference/project/mapRootAbsolutePathModuleSimpleSpecifyOutputFile/node/bin/test.js.map index c1e0281a2ab..f491a9ec373 100644 --- a/tests/baselines/reference/project/mapRootAbsolutePathModuleSimpleSpecifyOutputFile/node/bin/test.js.map +++ b/tests/baselines/reference/project/mapRootAbsolutePathModuleSimpleSpecifyOutputFile/node/bin/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"","sources":[],"names":[],"mappings":""} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"","sources":["../m1.ts","../test.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootAbsolutePathModuleSimpleSpecifyOutputFile/node/mapRootAbsolutePathModuleSimpleSpecifyOutputFile.sourcemap.txt b/tests/baselines/reference/project/mapRootAbsolutePathModuleSimpleSpecifyOutputFile/node/mapRootAbsolutePathModuleSimpleSpecifyOutputFile.sourcemap.txt index 75228e5ea64..aa64e62c809 100644 --- a/tests/baselines/reference/project/mapRootAbsolutePathModuleSimpleSpecifyOutputFile/node/mapRootAbsolutePathModuleSimpleSpecifyOutputFile.sourcemap.txt +++ b/tests/baselines/reference/project/mapRootAbsolutePathModuleSimpleSpecifyOutputFile/node/mapRootAbsolutePathModuleSimpleSpecifyOutputFile.sourcemap.txt @@ -394,6 +394,6 @@ sourceFile:../test.ts JsFile: test.js mapUrl: /tests/cases/projects/outputdir_module_simple/mapFiles/test.js.map sourceRoot: -sources: +sources: ../m1.ts,../test.ts =================================================================== >>>//# sourceMappingURL=/tests/cases/projects/outputdir_module_simple/mapFiles/test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootAbsolutePathModuleSubfolderSpecifyOutputFile/amd/bin/test.d.ts b/tests/baselines/reference/project/mapRootAbsolutePathModuleSubfolderSpecifyOutputFile/amd/bin/test.d.ts deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/tests/baselines/reference/project/mapRootAbsolutePathModuleSubfolderSpecifyOutputFile/amd/bin/test.js b/tests/baselines/reference/project/mapRootAbsolutePathModuleSubfolderSpecifyOutputFile/amd/bin/test.js deleted file mode 100644 index 7ff280253f1..00000000000 --- a/tests/baselines/reference/project/mapRootAbsolutePathModuleSubfolderSpecifyOutputFile/amd/bin/test.js +++ /dev/null @@ -1 +0,0 @@ -//# sourceMappingURL=/tests/cases/projects/outputdir_module_subfolder/mapFiles/test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootAbsolutePathModuleSubfolderSpecifyOutputFile/amd/bin/test.js.map b/tests/baselines/reference/project/mapRootAbsolutePathModuleSubfolderSpecifyOutputFile/amd/bin/test.js.map index c1e0281a2ab..f77c1351b15 100644 --- a/tests/baselines/reference/project/mapRootAbsolutePathModuleSubfolderSpecifyOutputFile/amd/bin/test.js.map +++ b/tests/baselines/reference/project/mapRootAbsolutePathModuleSubfolderSpecifyOutputFile/amd/bin/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"","sources":[],"names":[],"mappings":""} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"","sources":["../ref/m1.ts","../test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","c1","c1.constructor","f1"],"mappings":";IAAW,aAAK,GAAG,EAAE,CAAC;IACtB;QAAAA;QAEAC,CAACA;QAADD,YAACA;IAADA,CAACA,AAFD,IAEC;IAFY,aAAK,QAEjB,CAAA;IAEU,oBAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACIE,MAAMA,CAACA,oBAAYA,CAACA;IACxBA,CAACA;IAFe,aAAK,QAEpB,CAAA;;;ICPU,UAAE,GAAG,EAAE,CAAC;IACnB;QAAAC;QAEAC,CAACA;QAADD,SAACA;IAADA,CAACA,AAFD,IAEC;IAFY,UAAE,KAEd,CAAA;IAEU,iBAAS,GAAG,IAAI,EAAE,EAAE,CAAC;IAChC;QACIE,MAAMA,CAACA,iBAASA,CAACA;IACrBA,CAACA;IAFe,UAAE,KAEjB,CAAA;IAEU,UAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootAbsolutePathModuleSubfolderSpecifyOutputFile/amd/mapRootAbsolutePathModuleSubfolderSpecifyOutputFile.sourcemap.txt b/tests/baselines/reference/project/mapRootAbsolutePathModuleSubfolderSpecifyOutputFile/amd/mapRootAbsolutePathModuleSubfolderSpecifyOutputFile.sourcemap.txt index 18b397608e4..d6a44398f8e 100644 --- a/tests/baselines/reference/project/mapRootAbsolutePathModuleSubfolderSpecifyOutputFile/amd/mapRootAbsolutePathModuleSubfolderSpecifyOutputFile.sourcemap.txt +++ b/tests/baselines/reference/project/mapRootAbsolutePathModuleSubfolderSpecifyOutputFile/amd/mapRootAbsolutePathModuleSubfolderSpecifyOutputFile.sourcemap.txt @@ -373,6 +373,365 @@ sourceFile:../test.ts JsFile: test.js mapUrl: /tests/cases/projects/outputdir_module_subfolder/mapFiles/test.js.map sourceRoot: -sources: +sources: ../ref/m1.ts,../test.ts =================================================================== +------------------------------------------------------------------- +emittedFile:bin/test.js +sourceFile:../ref/m1.ts +------------------------------------------------------------------- +>>>define("ref/m1", ["require", "exports"], function (require, exports) { +>>> exports.m1_a1 = 10; +1 >^^^^ +2 > ^^^^^^^^^^^^^ +3 > ^^^ +4 > ^^ +5 > ^ +6 > ^^^^^^^^-> +1 >export var +2 > m1_a1 +3 > = +4 > 10 +5 > ; +1 >Emitted(2, 5) Source(1, 12) + SourceIndex(0) +2 >Emitted(2, 18) Source(1, 17) + SourceIndex(0) +3 >Emitted(2, 21) Source(1, 20) + SourceIndex(0) +4 >Emitted(2, 23) Source(1, 22) + SourceIndex(0) +5 >Emitted(2, 24) Source(1, 23) + SourceIndex(0) +--- +>>> var m1_c1 = (function () { +1->^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^^^^-> +1-> + > +1->Emitted(3, 5) Source(2, 1) + SourceIndex(0) +--- +>>> function m1_c1() { +1->^^^^^^^^ +2 > ^^-> +1-> +1->Emitted(4, 9) Source(2, 1) + SourceIndex(0) name (m1_c1) +--- +>>> } +1->^^^^^^^^ +2 > ^ +3 > ^^^^^^^^^^^^^-> +1->export class m1_c1 { + > public m1_c1_p1: number; + > +2 > } +1->Emitted(5, 9) Source(4, 1) + SourceIndex(0) name (m1_c1.constructor) +2 >Emitted(5, 10) Source(4, 2) + SourceIndex(0) name (m1_c1.constructor) +--- +>>> return m1_c1; +1->^^^^^^^^ +2 > ^^^^^^^^^^^^ +1-> +2 > } +1->Emitted(6, 9) Source(4, 1) + SourceIndex(0) name (m1_c1) +2 >Emitted(6, 21) Source(4, 2) + SourceIndex(0) name (m1_c1) +--- +>>> })(); +1 >^^^^ +2 > ^ +3 > +4 > ^^^^ +5 > ^^^^^^^^^^^^^^^^^^-> +1 > +2 > } +3 > +4 > export class m1_c1 { + > public m1_c1_p1: number; + > } +1 >Emitted(7, 5) Source(4, 1) + SourceIndex(0) name (m1_c1) +2 >Emitted(7, 6) Source(4, 2) + SourceIndex(0) name (m1_c1) +3 >Emitted(7, 6) Source(2, 1) + SourceIndex(0) +4 >Emitted(7, 10) Source(4, 2) + SourceIndex(0) +--- +>>> exports.m1_c1 = m1_c1; +1->^^^^ +2 > ^^^^^^^^^^^^^ +3 > ^^^^^^^^ +4 > ^ +5 > ^^^^^^^^^^^^^^-> +1-> +2 > m1_c1 +3 > { + > public m1_c1_p1: number; + > } +4 > +1->Emitted(8, 5) Source(2, 14) + SourceIndex(0) +2 >Emitted(8, 18) Source(2, 19) + SourceIndex(0) +3 >Emitted(8, 26) Source(4, 2) + SourceIndex(0) +4 >Emitted(8, 27) Source(4, 2) + SourceIndex(0) +--- +>>> exports.m1_instance1 = new m1_c1(); +1->^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^ +3 > ^^^ +4 > ^^^^ +5 > ^^^^^ +6 > ^^ +7 > ^ +1-> + > + >export var +2 > m1_instance1 +3 > = +4 > new +5 > m1_c1 +6 > () +7 > ; +1->Emitted(9, 5) Source(6, 12) + SourceIndex(0) +2 >Emitted(9, 25) Source(6, 24) + SourceIndex(0) +3 >Emitted(9, 28) Source(6, 27) + SourceIndex(0) +4 >Emitted(9, 32) Source(6, 31) + SourceIndex(0) +5 >Emitted(9, 37) Source(6, 36) + SourceIndex(0) +6 >Emitted(9, 39) Source(6, 38) + SourceIndex(0) +7 >Emitted(9, 40) Source(6, 39) + SourceIndex(0) +--- +>>> function m1_f1() { +1 >^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +1 > + > +1 >Emitted(10, 5) Source(7, 1) + SourceIndex(0) +--- +>>> return exports.m1_instance1; +1->^^^^^^^^ +2 > ^^^^^^ +3 > ^ +4 > ^^^^^^^^^^^^^^^^^^^^ +5 > ^ +1->export function m1_f1() { + > +2 > return +3 > +4 > m1_instance1 +5 > ; +1->Emitted(11, 9) Source(8, 5) + SourceIndex(0) name (m1_f1) +2 >Emitted(11, 15) Source(8, 11) + SourceIndex(0) name (m1_f1) +3 >Emitted(11, 16) Source(8, 12) + SourceIndex(0) name (m1_f1) +4 >Emitted(11, 36) Source(8, 24) + SourceIndex(0) name (m1_f1) +5 >Emitted(11, 37) Source(8, 25) + SourceIndex(0) name (m1_f1) +--- +>>> } +1 >^^^^ +2 > ^ +3 > ^^^^^^^^^^^^^^^^^^^^^^-> +1 > + > +2 > } +1 >Emitted(12, 5) Source(9, 1) + SourceIndex(0) name (m1_f1) +2 >Emitted(12, 6) Source(9, 2) + SourceIndex(0) name (m1_f1) +--- +>>> exports.m1_f1 = m1_f1; +1->^^^^ +2 > ^^^^^^^^^^^^^ +3 > ^^^^^^^^ +4 > ^ +1-> +2 > m1_f1 +3 > () { + > return m1_instance1; + > } +4 > +1->Emitted(13, 5) Source(7, 17) + SourceIndex(0) +2 >Emitted(13, 18) Source(7, 22) + SourceIndex(0) +3 >Emitted(13, 26) Source(9, 2) + SourceIndex(0) +4 >Emitted(13, 27) Source(9, 2) + SourceIndex(0) +--- +------------------------------------------------------------------- +emittedFile:bin/test.js +sourceFile:../test.ts +------------------------------------------------------------------- +>>>}); +>>>define("test", ["require", "exports", "ref/m1"], function (require, exports, m1) { +>>> exports.a1 = 10; +1 >^^^^ +2 > ^^^^^^^^^^ +3 > ^^^ +4 > ^^ +5 > ^ +6 > ^^^^^^^^-> +1 >import m1 = require("ref/m1"); + >export var +2 > a1 +3 > = +4 > 10 +5 > ; +1 >Emitted(16, 5) Source(2, 12) + SourceIndex(1) +2 >Emitted(16, 15) Source(2, 14) + SourceIndex(1) +3 >Emitted(16, 18) Source(2, 17) + SourceIndex(1) +4 >Emitted(16, 20) Source(2, 19) + SourceIndex(1) +5 >Emitted(16, 21) Source(2, 20) + SourceIndex(1) +--- +>>> var c1 = (function () { +1->^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^-> +1-> + > +1->Emitted(17, 5) Source(3, 1) + SourceIndex(1) +--- +>>> function c1() { +1->^^^^^^^^ +2 > ^^-> +1-> +1->Emitted(18, 9) Source(3, 1) + SourceIndex(1) name (c1) +--- +>>> } +1->^^^^^^^^ +2 > ^ +3 > ^^^^^^^^^^-> +1->export class c1 { + > public p1: number; + > +2 > } +1->Emitted(19, 9) Source(5, 1) + SourceIndex(1) name (c1.constructor) +2 >Emitted(19, 10) Source(5, 2) + SourceIndex(1) name (c1.constructor) +--- +>>> return c1; +1->^^^^^^^^ +2 > ^^^^^^^^^ +1-> +2 > } +1->Emitted(20, 9) Source(5, 1) + SourceIndex(1) name (c1) +2 >Emitted(20, 18) Source(5, 2) + SourceIndex(1) name (c1) +--- +>>> })(); +1 >^^^^ +2 > ^ +3 > +4 > ^^^^ +5 > ^^^^^^^^^^^^-> +1 > +2 > } +3 > +4 > export class c1 { + > public p1: number; + > } +1 >Emitted(21, 5) Source(5, 1) + SourceIndex(1) name (c1) +2 >Emitted(21, 6) Source(5, 2) + SourceIndex(1) name (c1) +3 >Emitted(21, 6) Source(3, 1) + SourceIndex(1) +4 >Emitted(21, 10) Source(5, 2) + SourceIndex(1) +--- +>>> exports.c1 = c1; +1->^^^^ +2 > ^^^^^^^^^^ +3 > ^^^^^ +4 > ^ +5 > ^^^^^^^^^^^^^^-> +1-> +2 > c1 +3 > { + > public p1: number; + > } +4 > +1->Emitted(22, 5) Source(3, 14) + SourceIndex(1) +2 >Emitted(22, 15) Source(3, 16) + SourceIndex(1) +3 >Emitted(22, 20) Source(5, 2) + SourceIndex(1) +4 >Emitted(22, 21) Source(5, 2) + SourceIndex(1) +--- +>>> exports.instance1 = new c1(); +1->^^^^ +2 > ^^^^^^^^^^^^^^^^^ +3 > ^^^ +4 > ^^^^ +5 > ^^ +6 > ^^ +7 > ^ +1-> + > + >export var +2 > instance1 +3 > = +4 > new +5 > c1 +6 > () +7 > ; +1->Emitted(23, 5) Source(7, 12) + SourceIndex(1) +2 >Emitted(23, 22) Source(7, 21) + SourceIndex(1) +3 >Emitted(23, 25) Source(7, 24) + SourceIndex(1) +4 >Emitted(23, 29) Source(7, 28) + SourceIndex(1) +5 >Emitted(23, 31) Source(7, 30) + SourceIndex(1) +6 >Emitted(23, 33) Source(7, 32) + SourceIndex(1) +7 >Emitted(23, 34) Source(7, 33) + SourceIndex(1) +--- +>>> function f1() { +1 >^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +1 > + > +1 >Emitted(24, 5) Source(8, 1) + SourceIndex(1) +--- +>>> return exports.instance1; +1->^^^^^^^^ +2 > ^^^^^^ +3 > ^ +4 > ^^^^^^^^^^^^^^^^^ +5 > ^ +1->export function f1() { + > +2 > return +3 > +4 > instance1 +5 > ; +1->Emitted(25, 9) Source(9, 5) + SourceIndex(1) name (f1) +2 >Emitted(25, 15) Source(9, 11) + SourceIndex(1) name (f1) +3 >Emitted(25, 16) Source(9, 12) + SourceIndex(1) name (f1) +4 >Emitted(25, 33) Source(9, 21) + SourceIndex(1) name (f1) +5 >Emitted(25, 34) Source(9, 22) + SourceIndex(1) name (f1) +--- +>>> } +1 >^^^^ +2 > ^ +3 > ^^^^^^^^^^^^^^^^-> +1 > + > +2 > } +1 >Emitted(26, 5) Source(10, 1) + SourceIndex(1) name (f1) +2 >Emitted(26, 6) Source(10, 2) + SourceIndex(1) name (f1) +--- +>>> exports.f1 = f1; +1->^^^^ +2 > ^^^^^^^^^^ +3 > ^^^^^ +4 > ^ +5 > ^^^^^^^-> +1-> +2 > f1 +3 > () { + > return instance1; + > } +4 > +1->Emitted(27, 5) Source(8, 17) + SourceIndex(1) +2 >Emitted(27, 15) Source(8, 19) + SourceIndex(1) +3 >Emitted(27, 20) Source(10, 2) + SourceIndex(1) +4 >Emitted(27, 21) Source(10, 2) + SourceIndex(1) +--- +>>> exports.a2 = m1.m1_c1; +1->^^^^ +2 > ^^^^^^^^^^ +3 > ^^^ +4 > ^^ +5 > ^ +6 > ^^^^^ +7 > ^ +1-> + > + >export var +2 > a2 +3 > = +4 > m1 +5 > . +6 > m1_c1 +7 > ; +1->Emitted(28, 5) Source(12, 12) + SourceIndex(1) +2 >Emitted(28, 15) Source(12, 14) + SourceIndex(1) +3 >Emitted(28, 18) Source(12, 17) + SourceIndex(1) +4 >Emitted(28, 20) Source(12, 19) + SourceIndex(1) +5 >Emitted(28, 21) Source(12, 20) + SourceIndex(1) +6 >Emitted(28, 26) Source(12, 25) + SourceIndex(1) +7 >Emitted(28, 27) Source(12, 26) + SourceIndex(1) +--- +>>>}); >>>//# sourceMappingURL=/tests/cases/projects/outputdir_module_subfolder/mapFiles/test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootAbsolutePathModuleSubfolderSpecifyOutputFile/node/bin/test.d.ts b/tests/baselines/reference/project/mapRootAbsolutePathModuleSubfolderSpecifyOutputFile/node/bin/test.d.ts deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/tests/baselines/reference/project/mapRootAbsolutePathModuleSubfolderSpecifyOutputFile/node/bin/test.js b/tests/baselines/reference/project/mapRootAbsolutePathModuleSubfolderSpecifyOutputFile/node/bin/test.js deleted file mode 100644 index 7ff280253f1..00000000000 --- a/tests/baselines/reference/project/mapRootAbsolutePathModuleSubfolderSpecifyOutputFile/node/bin/test.js +++ /dev/null @@ -1 +0,0 @@ -//# sourceMappingURL=/tests/cases/projects/outputdir_module_subfolder/mapFiles/test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootAbsolutePathModuleSubfolderSpecifyOutputFile/node/bin/test.js.map b/tests/baselines/reference/project/mapRootAbsolutePathModuleSubfolderSpecifyOutputFile/node/bin/test.js.map index c1e0281a2ab..bfdacf69428 100644 --- a/tests/baselines/reference/project/mapRootAbsolutePathModuleSubfolderSpecifyOutputFile/node/bin/test.js.map +++ b/tests/baselines/reference/project/mapRootAbsolutePathModuleSubfolderSpecifyOutputFile/node/bin/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"","sources":[],"names":[],"mappings":""} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"","sources":["../ref/m1.ts","../test.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootAbsolutePathModuleSubfolderSpecifyOutputFile/node/mapRootAbsolutePathModuleSubfolderSpecifyOutputFile.sourcemap.txt b/tests/baselines/reference/project/mapRootAbsolutePathModuleSubfolderSpecifyOutputFile/node/mapRootAbsolutePathModuleSubfolderSpecifyOutputFile.sourcemap.txt index 97c6b8a85e4..55f448a9c2f 100644 --- a/tests/baselines/reference/project/mapRootAbsolutePathModuleSubfolderSpecifyOutputFile/node/mapRootAbsolutePathModuleSubfolderSpecifyOutputFile.sourcemap.txt +++ b/tests/baselines/reference/project/mapRootAbsolutePathModuleSubfolderSpecifyOutputFile/node/mapRootAbsolutePathModuleSubfolderSpecifyOutputFile.sourcemap.txt @@ -394,6 +394,6 @@ sourceFile:../test.ts JsFile: test.js mapUrl: /tests/cases/projects/outputdir_module_subfolder/mapFiles/test.js.map sourceRoot: -sources: +sources: ../ref/m1.ts,../test.ts =================================================================== >>>//# sourceMappingURL=/tests/cases/projects/outputdir_module_subfolder/mapFiles/test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFile/amd/bin/test.d.ts b/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFile/amd/bin/test.d.ts deleted file mode 100644 index d61b4c3b876..00000000000 --- a/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFile/amd/bin/test.d.ts +++ /dev/null @@ -1,13 +0,0 @@ -/// -declare var m1_a1: number; -declare class m1_c1 { - m1_c1_p1: number; -} -declare var m1_instance1: m1_c1; -declare function m1_f1(): m1_c1; -declare var a1: number; -declare class c1 { - p1: number; -} -declare var instance1: c1; -declare function f1(): c1; diff --git a/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFile/amd/bin/test.js b/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFile/amd/bin/test.js deleted file mode 100644 index c4c79e0454b..00000000000 --- a/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFile/amd/bin/test.js +++ /dev/null @@ -1,23 +0,0 @@ -var m1_a1 = 10; -var m1_c1 = (function () { - function m1_c1() { - } - return m1_c1; -})(); -var m1_instance1 = new m1_c1(); -function m1_f1() { - return m1_instance1; -} -/// -/// -var a1 = 10; -var c1 = (function () { - function c1() { - } - return c1; -})(); -var instance1 = new c1(); -function f1() { - return instance1; -} -//# sourceMappingURL=../../mapFiles/test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFile/amd/bin/test.js.map b/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFile/amd/bin/test.js.map index b63911a2bc8..ca8dd0934b5 100644 --- a/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFile/amd/bin/test.js.map +++ b/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFile/amd/bin/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"","sources":["../outputdir_mixed_subfolder/ref/m1.ts","../outputdir_mixed_subfolder/test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACRD,iCAAiC;AACjC,iCAAiC;AACjC,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"","sources":["../outputdir_mixed_subfolder/ref/m1.ts","../outputdir_mixed_subfolder/ref/m2.ts","../outputdir_mixed_subfolder/test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","m2_c1","m2_c1.constructor","m2_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;;ICRU,aAAK,GAAG,EAAE,CAAC;IACtB;QAAAC;QAEAC,CAACA;QAADD,YAACA;IAADA,CAACA,AAFD,IAEC;IAFY,aAAK,QAEjB,CAAA;IAEU,oBAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACIE,MAAMA,CAACA,oBAAYA,CAACA;IACxBA,CAACA;IAFe,aAAK,QAEpB,CAAA;;ACRD,iCAAiC;AACjC,iCAAiC;AACjC,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFile/amd/mapRootRelativePathMixedSubfolderSpecifyOutputFile.sourcemap.txt b/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFile/amd/mapRootRelativePathMixedSubfolderSpecifyOutputFile.sourcemap.txt index f1cc6df9de8..33ebe5aaafb 100644 --- a/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFile/amd/mapRootRelativePathMixedSubfolderSpecifyOutputFile.sourcemap.txt +++ b/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFile/amd/mapRootRelativePathMixedSubfolderSpecifyOutputFile.sourcemap.txt @@ -174,7 +174,7 @@ sourceFile:../../outputdir_mixed_subfolder/ref/m2.ts JsFile: test.js mapUrl: ../../mapFiles/test.js.map sourceRoot: -sources: ../outputdir_mixed_subfolder/ref/m1.ts,../outputdir_mixed_subfolder/test.ts +sources: ../outputdir_mixed_subfolder/ref/m1.ts,../outputdir_mixed_subfolder/ref/m2.ts,../outputdir_mixed_subfolder/test.ts =================================================================== ------------------------------------------------------------------- emittedFile:bin/test.js @@ -306,7 +306,7 @@ sourceFile:../outputdir_mixed_subfolder/ref/m1.ts >>>} 1 > 2 >^ -3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> 1 > > 2 >} @@ -315,16 +315,182 @@ sourceFile:../outputdir_mixed_subfolder/ref/m1.ts --- ------------------------------------------------------------------- emittedFile:bin/test.js +sourceFile:../outputdir_mixed_subfolder/ref/m2.ts +------------------------------------------------------------------- +>>>define("ref/m2", ["require", "exports"], function (require, exports) { +>>> exports.m2_a1 = 10; +1->^^^^ +2 > ^^^^^^^^^^^^^ +3 > ^^^ +4 > ^^ +5 > ^ +6 > ^^^^^^^^-> +1->export var +2 > m2_a1 +3 > = +4 > 10 +5 > ; +1->Emitted(12, 5) Source(1, 12) + SourceIndex(1) +2 >Emitted(12, 18) Source(1, 17) + SourceIndex(1) +3 >Emitted(12, 21) Source(1, 20) + SourceIndex(1) +4 >Emitted(12, 23) Source(1, 22) + SourceIndex(1) +5 >Emitted(12, 24) Source(1, 23) + SourceIndex(1) +--- +>>> var m2_c1 = (function () { +1->^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^^^^-> +1-> + > +1->Emitted(13, 5) Source(2, 1) + SourceIndex(1) +--- +>>> function m2_c1() { +1->^^^^^^^^ +2 > ^^-> +1-> +1->Emitted(14, 9) Source(2, 1) + SourceIndex(1) name (m2_c1) +--- +>>> } +1->^^^^^^^^ +2 > ^ +3 > ^^^^^^^^^^^^^-> +1->export class m2_c1 { + > public m2_c1_p1: number; + > +2 > } +1->Emitted(15, 9) Source(4, 1) + SourceIndex(1) name (m2_c1.constructor) +2 >Emitted(15, 10) Source(4, 2) + SourceIndex(1) name (m2_c1.constructor) +--- +>>> return m2_c1; +1->^^^^^^^^ +2 > ^^^^^^^^^^^^ +1-> +2 > } +1->Emitted(16, 9) Source(4, 1) + SourceIndex(1) name (m2_c1) +2 >Emitted(16, 21) Source(4, 2) + SourceIndex(1) name (m2_c1) +--- +>>> })(); +1 >^^^^ +2 > ^ +3 > +4 > ^^^^ +5 > ^^^^^^^^^^^^^^^^^^-> +1 > +2 > } +3 > +4 > export class m2_c1 { + > public m2_c1_p1: number; + > } +1 >Emitted(17, 5) Source(4, 1) + SourceIndex(1) name (m2_c1) +2 >Emitted(17, 6) Source(4, 2) + SourceIndex(1) name (m2_c1) +3 >Emitted(17, 6) Source(2, 1) + SourceIndex(1) +4 >Emitted(17, 10) Source(4, 2) + SourceIndex(1) +--- +>>> exports.m2_c1 = m2_c1; +1->^^^^ +2 > ^^^^^^^^^^^^^ +3 > ^^^^^^^^ +4 > ^ +5 > ^^^^^^^^^^^^^^-> +1-> +2 > m2_c1 +3 > { + > public m2_c1_p1: number; + > } +4 > +1->Emitted(18, 5) Source(2, 14) + SourceIndex(1) +2 >Emitted(18, 18) Source(2, 19) + SourceIndex(1) +3 >Emitted(18, 26) Source(4, 2) + SourceIndex(1) +4 >Emitted(18, 27) Source(4, 2) + SourceIndex(1) +--- +>>> exports.m2_instance1 = new m2_c1(); +1->^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^ +3 > ^^^ +4 > ^^^^ +5 > ^^^^^ +6 > ^^ +7 > ^ +1-> + > + >export var +2 > m2_instance1 +3 > = +4 > new +5 > m2_c1 +6 > () +7 > ; +1->Emitted(19, 5) Source(6, 12) + SourceIndex(1) +2 >Emitted(19, 25) Source(6, 24) + SourceIndex(1) +3 >Emitted(19, 28) Source(6, 27) + SourceIndex(1) +4 >Emitted(19, 32) Source(6, 31) + SourceIndex(1) +5 >Emitted(19, 37) Source(6, 36) + SourceIndex(1) +6 >Emitted(19, 39) Source(6, 38) + SourceIndex(1) +7 >Emitted(19, 40) Source(6, 39) + SourceIndex(1) +--- +>>> function m2_f1() { +1 >^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +1 > + > +1 >Emitted(20, 5) Source(7, 1) + SourceIndex(1) +--- +>>> return exports.m2_instance1; +1->^^^^^^^^ +2 > ^^^^^^ +3 > ^ +4 > ^^^^^^^^^^^^^^^^^^^^ +5 > ^ +1->export function m2_f1() { + > +2 > return +3 > +4 > m2_instance1 +5 > ; +1->Emitted(21, 9) Source(8, 5) + SourceIndex(1) name (m2_f1) +2 >Emitted(21, 15) Source(8, 11) + SourceIndex(1) name (m2_f1) +3 >Emitted(21, 16) Source(8, 12) + SourceIndex(1) name (m2_f1) +4 >Emitted(21, 36) Source(8, 24) + SourceIndex(1) name (m2_f1) +5 >Emitted(21, 37) Source(8, 25) + SourceIndex(1) name (m2_f1) +--- +>>> } +1 >^^^^ +2 > ^ +3 > ^^^^^^^^^^^^^^^^^^^^^^-> +1 > + > +2 > } +1 >Emitted(22, 5) Source(9, 1) + SourceIndex(1) name (m2_f1) +2 >Emitted(22, 6) Source(9, 2) + SourceIndex(1) name (m2_f1) +--- +>>> exports.m2_f1 = m2_f1; +1->^^^^ +2 > ^^^^^^^^^^^^^ +3 > ^^^^^^^^ +4 > ^ +1-> +2 > m2_f1 +3 > () { + > return m2_instance1; + > } +4 > +1->Emitted(23, 5) Source(7, 17) + SourceIndex(1) +2 >Emitted(23, 18) Source(7, 22) + SourceIndex(1) +3 >Emitted(23, 26) Source(9, 2) + SourceIndex(1) +4 >Emitted(23, 27) Source(9, 2) + SourceIndex(1) +--- +------------------------------------------------------------------- +emittedFile:bin/test.js sourceFile:../outputdir_mixed_subfolder/test.ts ------------------------------------------------------------------- +>>>}); >>>/// -1-> +1 > 2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 3 > ^-> -1-> +1 > 2 >/// -1->Emitted(11, 1) Source(1, 1) + SourceIndex(1) -2 >Emitted(11, 34) Source(1, 34) + SourceIndex(1) +1 >Emitted(25, 1) Source(1, 1) + SourceIndex(2) +2 >Emitted(25, 34) Source(1, 34) + SourceIndex(2) --- >>>/// 1-> @@ -332,8 +498,8 @@ sourceFile:../outputdir_mixed_subfolder/test.ts 1-> > 2 >/// -1->Emitted(12, 1) Source(2, 1) + SourceIndex(1) -2 >Emitted(12, 34) Source(2, 34) + SourceIndex(1) +1->Emitted(26, 1) Source(2, 1) + SourceIndex(2) +2 >Emitted(26, 34) Source(2, 34) + SourceIndex(2) --- >>>var a1 = 10; 1 > @@ -350,25 +516,25 @@ sourceFile:../outputdir_mixed_subfolder/test.ts 4 > = 5 > 10 6 > ; -1 >Emitted(13, 1) Source(3, 1) + SourceIndex(1) -2 >Emitted(13, 5) Source(3, 5) + SourceIndex(1) -3 >Emitted(13, 7) Source(3, 7) + SourceIndex(1) -4 >Emitted(13, 10) Source(3, 10) + SourceIndex(1) -5 >Emitted(13, 12) Source(3, 12) + SourceIndex(1) -6 >Emitted(13, 13) Source(3, 13) + SourceIndex(1) +1 >Emitted(27, 1) Source(3, 1) + SourceIndex(2) +2 >Emitted(27, 5) Source(3, 5) + SourceIndex(2) +3 >Emitted(27, 7) Source(3, 7) + SourceIndex(2) +4 >Emitted(27, 10) Source(3, 10) + SourceIndex(2) +5 >Emitted(27, 12) Source(3, 12) + SourceIndex(2) +6 >Emitted(27, 13) Source(3, 13) + SourceIndex(2) --- >>>var c1 = (function () { 1-> 2 >^^^^^^^^^^^^^^^^^^^^-> 1-> > -1->Emitted(14, 1) Source(4, 1) + SourceIndex(1) +1->Emitted(28, 1) Source(4, 1) + SourceIndex(2) --- >>> function c1() { 1->^^^^ 2 > ^^-> 1-> -1->Emitted(15, 5) Source(4, 1) + SourceIndex(1) name (c1) +1->Emitted(29, 5) Source(4, 1) + SourceIndex(2) name (c1) --- >>> } 1->^^^^ @@ -378,16 +544,16 @@ sourceFile:../outputdir_mixed_subfolder/test.ts > public p1: number; > 2 > } -1->Emitted(16, 5) Source(6, 1) + SourceIndex(1) name (c1.constructor) -2 >Emitted(16, 6) Source(6, 2) + SourceIndex(1) name (c1.constructor) +1->Emitted(30, 5) Source(6, 1) + SourceIndex(2) name (c1.constructor) +2 >Emitted(30, 6) Source(6, 2) + SourceIndex(2) name (c1.constructor) --- >>> return c1; 1->^^^^ 2 > ^^^^^^^^^ 1-> 2 > } -1->Emitted(17, 5) Source(6, 1) + SourceIndex(1) name (c1) -2 >Emitted(17, 14) Source(6, 2) + SourceIndex(1) name (c1) +1->Emitted(31, 5) Source(6, 1) + SourceIndex(2) name (c1) +2 >Emitted(31, 14) Source(6, 2) + SourceIndex(2) name (c1) --- >>>})(); 1 > @@ -401,10 +567,10 @@ sourceFile:../outputdir_mixed_subfolder/test.ts 4 > class c1 { > public p1: number; > } -1 >Emitted(18, 1) Source(6, 1) + SourceIndex(1) name (c1) -2 >Emitted(18, 2) Source(6, 2) + SourceIndex(1) name (c1) -3 >Emitted(18, 2) Source(4, 1) + SourceIndex(1) -4 >Emitted(18, 6) Source(6, 2) + SourceIndex(1) +1 >Emitted(32, 1) Source(6, 1) + SourceIndex(2) name (c1) +2 >Emitted(32, 2) Source(6, 2) + SourceIndex(2) name (c1) +3 >Emitted(32, 2) Source(4, 1) + SourceIndex(2) +4 >Emitted(32, 6) Source(6, 2) + SourceIndex(2) --- >>>var instance1 = new c1(); 1-> @@ -425,21 +591,21 @@ sourceFile:../outputdir_mixed_subfolder/test.ts 6 > c1 7 > () 8 > ; -1->Emitted(19, 1) Source(8, 1) + SourceIndex(1) -2 >Emitted(19, 5) Source(8, 5) + SourceIndex(1) -3 >Emitted(19, 14) Source(8, 14) + SourceIndex(1) -4 >Emitted(19, 17) Source(8, 17) + SourceIndex(1) -5 >Emitted(19, 21) Source(8, 21) + SourceIndex(1) -6 >Emitted(19, 23) Source(8, 23) + SourceIndex(1) -7 >Emitted(19, 25) Source(8, 25) + SourceIndex(1) -8 >Emitted(19, 26) Source(8, 26) + SourceIndex(1) +1->Emitted(33, 1) Source(8, 1) + SourceIndex(2) +2 >Emitted(33, 5) Source(8, 5) + SourceIndex(2) +3 >Emitted(33, 14) Source(8, 14) + SourceIndex(2) +4 >Emitted(33, 17) Source(8, 17) + SourceIndex(2) +5 >Emitted(33, 21) Source(8, 21) + SourceIndex(2) +6 >Emitted(33, 23) Source(8, 23) + SourceIndex(2) +7 >Emitted(33, 25) Source(8, 25) + SourceIndex(2) +8 >Emitted(33, 26) Source(8, 26) + SourceIndex(2) --- >>>function f1() { 1 > 2 >^^^^^^^^^^^^^^^^^^^^^^-> 1 > > -1 >Emitted(20, 1) Source(9, 1) + SourceIndex(1) +1 >Emitted(34, 1) Source(9, 1) + SourceIndex(2) --- >>> return instance1; 1->^^^^ @@ -453,11 +619,11 @@ sourceFile:../outputdir_mixed_subfolder/test.ts 3 > 4 > instance1 5 > ; -1->Emitted(21, 5) Source(10, 5) + SourceIndex(1) name (f1) -2 >Emitted(21, 11) Source(10, 11) + SourceIndex(1) name (f1) -3 >Emitted(21, 12) Source(10, 12) + SourceIndex(1) name (f1) -4 >Emitted(21, 21) Source(10, 21) + SourceIndex(1) name (f1) -5 >Emitted(21, 22) Source(10, 22) + SourceIndex(1) name (f1) +1->Emitted(35, 5) Source(10, 5) + SourceIndex(2) name (f1) +2 >Emitted(35, 11) Source(10, 11) + SourceIndex(2) name (f1) +3 >Emitted(35, 12) Source(10, 12) + SourceIndex(2) name (f1) +4 >Emitted(35, 21) Source(10, 21) + SourceIndex(2) name (f1) +5 >Emitted(35, 22) Source(10, 22) + SourceIndex(2) name (f1) --- >>>} 1 > @@ -466,7 +632,7 @@ sourceFile:../outputdir_mixed_subfolder/test.ts 1 > > 2 >} -1 >Emitted(22, 1) Source(11, 1) + SourceIndex(1) name (f1) -2 >Emitted(22, 2) Source(11, 2) + SourceIndex(1) name (f1) +1 >Emitted(36, 1) Source(11, 1) + SourceIndex(2) name (f1) +2 >Emitted(36, 2) Source(11, 2) + SourceIndex(2) name (f1) --- >>>//# sourceMappingURL=../../mapFiles/test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFile/node/bin/test.d.ts b/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFile/node/bin/test.d.ts deleted file mode 100644 index d61b4c3b876..00000000000 --- a/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFile/node/bin/test.d.ts +++ /dev/null @@ -1,13 +0,0 @@ -/// -declare var m1_a1: number; -declare class m1_c1 { - m1_c1_p1: number; -} -declare var m1_instance1: m1_c1; -declare function m1_f1(): m1_c1; -declare var a1: number; -declare class c1 { - p1: number; -} -declare var instance1: c1; -declare function f1(): c1; diff --git a/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFile/node/bin/test.js b/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFile/node/bin/test.js deleted file mode 100644 index c4c79e0454b..00000000000 --- a/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFile/node/bin/test.js +++ /dev/null @@ -1,23 +0,0 @@ -var m1_a1 = 10; -var m1_c1 = (function () { - function m1_c1() { - } - return m1_c1; -})(); -var m1_instance1 = new m1_c1(); -function m1_f1() { - return m1_instance1; -} -/// -/// -var a1 = 10; -var c1 = (function () { - function c1() { - } - return c1; -})(); -var instance1 = new c1(); -function f1() { - return instance1; -} -//# sourceMappingURL=../../mapFiles/test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFile/node/bin/test.js.map b/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFile/node/bin/test.js.map index b63911a2bc8..02be1ec09fb 100644 --- a/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFile/node/bin/test.js.map +++ b/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFile/node/bin/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"","sources":["../outputdir_mixed_subfolder/ref/m1.ts","../outputdir_mixed_subfolder/test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACRD,iCAAiC;AACjC,iCAAiC;AACjC,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"","sources":["../outputdir_mixed_subfolder/ref/m1.ts","../outputdir_mixed_subfolder/ref/m2.ts","../outputdir_mixed_subfolder/test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;AERD,iCAAiC;AACjC,iCAAiC;AACjC,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFile/node/mapRootRelativePathMixedSubfolderSpecifyOutputFile.sourcemap.txt b/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFile/node/mapRootRelativePathMixedSubfolderSpecifyOutputFile.sourcemap.txt index 0a373a20359..d55115b85f2 100644 --- a/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFile/node/mapRootRelativePathMixedSubfolderSpecifyOutputFile.sourcemap.txt +++ b/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFile/node/mapRootRelativePathMixedSubfolderSpecifyOutputFile.sourcemap.txt @@ -173,7 +173,7 @@ sourceFile:../../outputdir_mixed_subfolder/ref/m2.ts JsFile: test.js mapUrl: ../../mapFiles/test.js.map sourceRoot: -sources: ../outputdir_mixed_subfolder/ref/m1.ts,../outputdir_mixed_subfolder/test.ts +sources: ../outputdir_mixed_subfolder/ref/m1.ts,../outputdir_mixed_subfolder/ref/m2.ts,../outputdir_mixed_subfolder/test.ts =================================================================== ------------------------------------------------------------------- emittedFile:bin/test.js @@ -322,8 +322,8 @@ sourceFile:../outputdir_mixed_subfolder/test.ts 3 > ^-> 1-> 2 >/// -1->Emitted(11, 1) Source(1, 1) + SourceIndex(1) -2 >Emitted(11, 34) Source(1, 34) + SourceIndex(1) +1->Emitted(11, 1) Source(1, 1) + SourceIndex(2) +2 >Emitted(11, 34) Source(1, 34) + SourceIndex(2) --- >>>/// 1-> @@ -331,8 +331,8 @@ sourceFile:../outputdir_mixed_subfolder/test.ts 1-> > 2 >/// -1->Emitted(12, 1) Source(2, 1) + SourceIndex(1) -2 >Emitted(12, 34) Source(2, 34) + SourceIndex(1) +1->Emitted(12, 1) Source(2, 1) + SourceIndex(2) +2 >Emitted(12, 34) Source(2, 34) + SourceIndex(2) --- >>>var a1 = 10; 1 > @@ -349,25 +349,25 @@ sourceFile:../outputdir_mixed_subfolder/test.ts 4 > = 5 > 10 6 > ; -1 >Emitted(13, 1) Source(3, 1) + SourceIndex(1) -2 >Emitted(13, 5) Source(3, 5) + SourceIndex(1) -3 >Emitted(13, 7) Source(3, 7) + SourceIndex(1) -4 >Emitted(13, 10) Source(3, 10) + SourceIndex(1) -5 >Emitted(13, 12) Source(3, 12) + SourceIndex(1) -6 >Emitted(13, 13) Source(3, 13) + SourceIndex(1) +1 >Emitted(13, 1) Source(3, 1) + SourceIndex(2) +2 >Emitted(13, 5) Source(3, 5) + SourceIndex(2) +3 >Emitted(13, 7) Source(3, 7) + SourceIndex(2) +4 >Emitted(13, 10) Source(3, 10) + SourceIndex(2) +5 >Emitted(13, 12) Source(3, 12) + SourceIndex(2) +6 >Emitted(13, 13) Source(3, 13) + SourceIndex(2) --- >>>var c1 = (function () { 1-> 2 >^^^^^^^^^^^^^^^^^^^^-> 1-> > -1->Emitted(14, 1) Source(4, 1) + SourceIndex(1) +1->Emitted(14, 1) Source(4, 1) + SourceIndex(2) --- >>> function c1() { 1->^^^^ 2 > ^^-> 1-> -1->Emitted(15, 5) Source(4, 1) + SourceIndex(1) name (c1) +1->Emitted(15, 5) Source(4, 1) + SourceIndex(2) name (c1) --- >>> } 1->^^^^ @@ -377,16 +377,16 @@ sourceFile:../outputdir_mixed_subfolder/test.ts > public p1: number; > 2 > } -1->Emitted(16, 5) Source(6, 1) + SourceIndex(1) name (c1.constructor) -2 >Emitted(16, 6) Source(6, 2) + SourceIndex(1) name (c1.constructor) +1->Emitted(16, 5) Source(6, 1) + SourceIndex(2) name (c1.constructor) +2 >Emitted(16, 6) Source(6, 2) + SourceIndex(2) name (c1.constructor) --- >>> return c1; 1->^^^^ 2 > ^^^^^^^^^ 1-> 2 > } -1->Emitted(17, 5) Source(6, 1) + SourceIndex(1) name (c1) -2 >Emitted(17, 14) Source(6, 2) + SourceIndex(1) name (c1) +1->Emitted(17, 5) Source(6, 1) + SourceIndex(2) name (c1) +2 >Emitted(17, 14) Source(6, 2) + SourceIndex(2) name (c1) --- >>>})(); 1 > @@ -400,10 +400,10 @@ sourceFile:../outputdir_mixed_subfolder/test.ts 4 > class c1 { > public p1: number; > } -1 >Emitted(18, 1) Source(6, 1) + SourceIndex(1) name (c1) -2 >Emitted(18, 2) Source(6, 2) + SourceIndex(1) name (c1) -3 >Emitted(18, 2) Source(4, 1) + SourceIndex(1) -4 >Emitted(18, 6) Source(6, 2) + SourceIndex(1) +1 >Emitted(18, 1) Source(6, 1) + SourceIndex(2) name (c1) +2 >Emitted(18, 2) Source(6, 2) + SourceIndex(2) name (c1) +3 >Emitted(18, 2) Source(4, 1) + SourceIndex(2) +4 >Emitted(18, 6) Source(6, 2) + SourceIndex(2) --- >>>var instance1 = new c1(); 1-> @@ -424,21 +424,21 @@ sourceFile:../outputdir_mixed_subfolder/test.ts 6 > c1 7 > () 8 > ; -1->Emitted(19, 1) Source(8, 1) + SourceIndex(1) -2 >Emitted(19, 5) Source(8, 5) + SourceIndex(1) -3 >Emitted(19, 14) Source(8, 14) + SourceIndex(1) -4 >Emitted(19, 17) Source(8, 17) + SourceIndex(1) -5 >Emitted(19, 21) Source(8, 21) + SourceIndex(1) -6 >Emitted(19, 23) Source(8, 23) + SourceIndex(1) -7 >Emitted(19, 25) Source(8, 25) + SourceIndex(1) -8 >Emitted(19, 26) Source(8, 26) + SourceIndex(1) +1->Emitted(19, 1) Source(8, 1) + SourceIndex(2) +2 >Emitted(19, 5) Source(8, 5) + SourceIndex(2) +3 >Emitted(19, 14) Source(8, 14) + SourceIndex(2) +4 >Emitted(19, 17) Source(8, 17) + SourceIndex(2) +5 >Emitted(19, 21) Source(8, 21) + SourceIndex(2) +6 >Emitted(19, 23) Source(8, 23) + SourceIndex(2) +7 >Emitted(19, 25) Source(8, 25) + SourceIndex(2) +8 >Emitted(19, 26) Source(8, 26) + SourceIndex(2) --- >>>function f1() { 1 > 2 >^^^^^^^^^^^^^^^^^^^^^^-> 1 > > -1 >Emitted(20, 1) Source(9, 1) + SourceIndex(1) +1 >Emitted(20, 1) Source(9, 1) + SourceIndex(2) --- >>> return instance1; 1->^^^^ @@ -452,11 +452,11 @@ sourceFile:../outputdir_mixed_subfolder/test.ts 3 > 4 > instance1 5 > ; -1->Emitted(21, 5) Source(10, 5) + SourceIndex(1) name (f1) -2 >Emitted(21, 11) Source(10, 11) + SourceIndex(1) name (f1) -3 >Emitted(21, 12) Source(10, 12) + SourceIndex(1) name (f1) -4 >Emitted(21, 21) Source(10, 21) + SourceIndex(1) name (f1) -5 >Emitted(21, 22) Source(10, 22) + SourceIndex(1) name (f1) +1->Emitted(21, 5) Source(10, 5) + SourceIndex(2) name (f1) +2 >Emitted(21, 11) Source(10, 11) + SourceIndex(2) name (f1) +3 >Emitted(21, 12) Source(10, 12) + SourceIndex(2) name (f1) +4 >Emitted(21, 21) Source(10, 21) + SourceIndex(2) name (f1) +5 >Emitted(21, 22) Source(10, 22) + SourceIndex(2) name (f1) --- >>>} 1 > @@ -465,7 +465,7 @@ sourceFile:../outputdir_mixed_subfolder/test.ts 1 > > 2 >} -1 >Emitted(22, 1) Source(11, 1) + SourceIndex(1) name (f1) -2 >Emitted(22, 2) Source(11, 2) + SourceIndex(1) name (f1) +1 >Emitted(22, 1) Source(11, 1) + SourceIndex(2) name (f1) +2 >Emitted(22, 2) Source(11, 2) + SourceIndex(2) name (f1) --- >>>//# sourceMappingURL=../../mapFiles/test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.d.ts b/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.d.ts deleted file mode 100644 index 9b9cdd4a214..00000000000 --- a/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.d.ts +++ /dev/null @@ -1,13 +0,0 @@ -/// -declare var m1_a1: number; -declare class m1_c1 { - m1_c1_p1: number; -} -declare var m1_instance1: m1_c1; -declare function m1_f1(): m1_c1; -declare var a1: number; -declare class c1 { - p1: number; -} -declare var instance1: c1; -declare function f1(): c1; diff --git a/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.js b/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.js deleted file mode 100644 index c0138423cae..00000000000 --- a/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.js +++ /dev/null @@ -1,23 +0,0 @@ -var m1_a1 = 10; -var m1_c1 = (function () { - function m1_c1() { - } - return m1_c1; -})(); -var m1_instance1 = new m1_c1(); -function m1_f1() { - return m1_instance1; -} -/// -/// -var a1 = 10; -var c1 = (function () { - function c1() { - } - return c1; -})(); -var instance1 = new c1(); -function f1() { - return instance1; -} -//# sourceMappingURL=../../mapFiles/outAndOutDirFile.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.js.map b/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.js.map index 630508cb9f8..794d2a58176 100644 --- a/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.js.map +++ b/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.js.map @@ -1 +1 @@ -{"version":3,"file":"outAndOutDirFile.js","sourceRoot":"","sources":["../outputdir_mixed_subfolder/ref/m1.ts","../outputdir_mixed_subfolder/test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACRD,iCAAiC;AACjC,iCAAiC;AACjC,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"outAndOutDirFile.js","sourceRoot":"","sources":["../outputdir_mixed_subfolder/ref/m1.ts","../outputdir_mixed_subfolder/ref/m2.ts","../outputdir_mixed_subfolder/test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","m2_c1","m2_c1.constructor","m2_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;;ICRU,aAAK,GAAG,EAAE,CAAC;IACtB;QAAAC;QAEAC,CAACA;QAADD,YAACA;IAADA,CAACA,AAFD,IAEC;IAFY,aAAK,QAEjB,CAAA;IAEU,oBAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACIE,MAAMA,CAACA,oBAAYA,CAACA;IACxBA,CAACA;IAFe,aAAK,QAEpB,CAAA;;ACRD,iCAAiC;AACjC,iCAAiC;AACjC,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/mapRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory.sourcemap.txt b/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/mapRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory.sourcemap.txt index fd08e128cfe..9932fdda3e9 100644 --- a/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/mapRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory.sourcemap.txt +++ b/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/mapRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory.sourcemap.txt @@ -174,7 +174,7 @@ sourceFile:../../outputdir_mixed_subfolder/ref/m2.ts JsFile: outAndOutDirFile.js mapUrl: ../../mapFiles/outAndOutDirFile.js.map sourceRoot: -sources: ../outputdir_mixed_subfolder/ref/m1.ts,../outputdir_mixed_subfolder/test.ts +sources: ../outputdir_mixed_subfolder/ref/m1.ts,../outputdir_mixed_subfolder/ref/m2.ts,../outputdir_mixed_subfolder/test.ts =================================================================== ------------------------------------------------------------------- emittedFile:bin/outAndOutDirFile.js @@ -306,7 +306,7 @@ sourceFile:../outputdir_mixed_subfolder/ref/m1.ts >>>} 1 > 2 >^ -3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> 1 > > 2 >} @@ -315,16 +315,182 @@ sourceFile:../outputdir_mixed_subfolder/ref/m1.ts --- ------------------------------------------------------------------- emittedFile:bin/outAndOutDirFile.js +sourceFile:../outputdir_mixed_subfolder/ref/m2.ts +------------------------------------------------------------------- +>>>define("ref/m2", ["require", "exports"], function (require, exports) { +>>> exports.m2_a1 = 10; +1->^^^^ +2 > ^^^^^^^^^^^^^ +3 > ^^^ +4 > ^^ +5 > ^ +6 > ^^^^^^^^-> +1->export var +2 > m2_a1 +3 > = +4 > 10 +5 > ; +1->Emitted(12, 5) Source(1, 12) + SourceIndex(1) +2 >Emitted(12, 18) Source(1, 17) + SourceIndex(1) +3 >Emitted(12, 21) Source(1, 20) + SourceIndex(1) +4 >Emitted(12, 23) Source(1, 22) + SourceIndex(1) +5 >Emitted(12, 24) Source(1, 23) + SourceIndex(1) +--- +>>> var m2_c1 = (function () { +1->^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^^^^-> +1-> + > +1->Emitted(13, 5) Source(2, 1) + SourceIndex(1) +--- +>>> function m2_c1() { +1->^^^^^^^^ +2 > ^^-> +1-> +1->Emitted(14, 9) Source(2, 1) + SourceIndex(1) name (m2_c1) +--- +>>> } +1->^^^^^^^^ +2 > ^ +3 > ^^^^^^^^^^^^^-> +1->export class m2_c1 { + > public m2_c1_p1: number; + > +2 > } +1->Emitted(15, 9) Source(4, 1) + SourceIndex(1) name (m2_c1.constructor) +2 >Emitted(15, 10) Source(4, 2) + SourceIndex(1) name (m2_c1.constructor) +--- +>>> return m2_c1; +1->^^^^^^^^ +2 > ^^^^^^^^^^^^ +1-> +2 > } +1->Emitted(16, 9) Source(4, 1) + SourceIndex(1) name (m2_c1) +2 >Emitted(16, 21) Source(4, 2) + SourceIndex(1) name (m2_c1) +--- +>>> })(); +1 >^^^^ +2 > ^ +3 > +4 > ^^^^ +5 > ^^^^^^^^^^^^^^^^^^-> +1 > +2 > } +3 > +4 > export class m2_c1 { + > public m2_c1_p1: number; + > } +1 >Emitted(17, 5) Source(4, 1) + SourceIndex(1) name (m2_c1) +2 >Emitted(17, 6) Source(4, 2) + SourceIndex(1) name (m2_c1) +3 >Emitted(17, 6) Source(2, 1) + SourceIndex(1) +4 >Emitted(17, 10) Source(4, 2) + SourceIndex(1) +--- +>>> exports.m2_c1 = m2_c1; +1->^^^^ +2 > ^^^^^^^^^^^^^ +3 > ^^^^^^^^ +4 > ^ +5 > ^^^^^^^^^^^^^^-> +1-> +2 > m2_c1 +3 > { + > public m2_c1_p1: number; + > } +4 > +1->Emitted(18, 5) Source(2, 14) + SourceIndex(1) +2 >Emitted(18, 18) Source(2, 19) + SourceIndex(1) +3 >Emitted(18, 26) Source(4, 2) + SourceIndex(1) +4 >Emitted(18, 27) Source(4, 2) + SourceIndex(1) +--- +>>> exports.m2_instance1 = new m2_c1(); +1->^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^ +3 > ^^^ +4 > ^^^^ +5 > ^^^^^ +6 > ^^ +7 > ^ +1-> + > + >export var +2 > m2_instance1 +3 > = +4 > new +5 > m2_c1 +6 > () +7 > ; +1->Emitted(19, 5) Source(6, 12) + SourceIndex(1) +2 >Emitted(19, 25) Source(6, 24) + SourceIndex(1) +3 >Emitted(19, 28) Source(6, 27) + SourceIndex(1) +4 >Emitted(19, 32) Source(6, 31) + SourceIndex(1) +5 >Emitted(19, 37) Source(6, 36) + SourceIndex(1) +6 >Emitted(19, 39) Source(6, 38) + SourceIndex(1) +7 >Emitted(19, 40) Source(6, 39) + SourceIndex(1) +--- +>>> function m2_f1() { +1 >^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +1 > + > +1 >Emitted(20, 5) Source(7, 1) + SourceIndex(1) +--- +>>> return exports.m2_instance1; +1->^^^^^^^^ +2 > ^^^^^^ +3 > ^ +4 > ^^^^^^^^^^^^^^^^^^^^ +5 > ^ +1->export function m2_f1() { + > +2 > return +3 > +4 > m2_instance1 +5 > ; +1->Emitted(21, 9) Source(8, 5) + SourceIndex(1) name (m2_f1) +2 >Emitted(21, 15) Source(8, 11) + SourceIndex(1) name (m2_f1) +3 >Emitted(21, 16) Source(8, 12) + SourceIndex(1) name (m2_f1) +4 >Emitted(21, 36) Source(8, 24) + SourceIndex(1) name (m2_f1) +5 >Emitted(21, 37) Source(8, 25) + SourceIndex(1) name (m2_f1) +--- +>>> } +1 >^^^^ +2 > ^ +3 > ^^^^^^^^^^^^^^^^^^^^^^-> +1 > + > +2 > } +1 >Emitted(22, 5) Source(9, 1) + SourceIndex(1) name (m2_f1) +2 >Emitted(22, 6) Source(9, 2) + SourceIndex(1) name (m2_f1) +--- +>>> exports.m2_f1 = m2_f1; +1->^^^^ +2 > ^^^^^^^^^^^^^ +3 > ^^^^^^^^ +4 > ^ +1-> +2 > m2_f1 +3 > () { + > return m2_instance1; + > } +4 > +1->Emitted(23, 5) Source(7, 17) + SourceIndex(1) +2 >Emitted(23, 18) Source(7, 22) + SourceIndex(1) +3 >Emitted(23, 26) Source(9, 2) + SourceIndex(1) +4 >Emitted(23, 27) Source(9, 2) + SourceIndex(1) +--- +------------------------------------------------------------------- +emittedFile:bin/outAndOutDirFile.js sourceFile:../outputdir_mixed_subfolder/test.ts ------------------------------------------------------------------- +>>>}); >>>/// -1-> +1 > 2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 3 > ^-> -1-> +1 > 2 >/// -1->Emitted(11, 1) Source(1, 1) + SourceIndex(1) -2 >Emitted(11, 34) Source(1, 34) + SourceIndex(1) +1 >Emitted(25, 1) Source(1, 1) + SourceIndex(2) +2 >Emitted(25, 34) Source(1, 34) + SourceIndex(2) --- >>>/// 1-> @@ -332,8 +498,8 @@ sourceFile:../outputdir_mixed_subfolder/test.ts 1-> > 2 >/// -1->Emitted(12, 1) Source(2, 1) + SourceIndex(1) -2 >Emitted(12, 34) Source(2, 34) + SourceIndex(1) +1->Emitted(26, 1) Source(2, 1) + SourceIndex(2) +2 >Emitted(26, 34) Source(2, 34) + SourceIndex(2) --- >>>var a1 = 10; 1 > @@ -350,25 +516,25 @@ sourceFile:../outputdir_mixed_subfolder/test.ts 4 > = 5 > 10 6 > ; -1 >Emitted(13, 1) Source(3, 1) + SourceIndex(1) -2 >Emitted(13, 5) Source(3, 5) + SourceIndex(1) -3 >Emitted(13, 7) Source(3, 7) + SourceIndex(1) -4 >Emitted(13, 10) Source(3, 10) + SourceIndex(1) -5 >Emitted(13, 12) Source(3, 12) + SourceIndex(1) -6 >Emitted(13, 13) Source(3, 13) + SourceIndex(1) +1 >Emitted(27, 1) Source(3, 1) + SourceIndex(2) +2 >Emitted(27, 5) Source(3, 5) + SourceIndex(2) +3 >Emitted(27, 7) Source(3, 7) + SourceIndex(2) +4 >Emitted(27, 10) Source(3, 10) + SourceIndex(2) +5 >Emitted(27, 12) Source(3, 12) + SourceIndex(2) +6 >Emitted(27, 13) Source(3, 13) + SourceIndex(2) --- >>>var c1 = (function () { 1-> 2 >^^^^^^^^^^^^^^^^^^^^-> 1-> > -1->Emitted(14, 1) Source(4, 1) + SourceIndex(1) +1->Emitted(28, 1) Source(4, 1) + SourceIndex(2) --- >>> function c1() { 1->^^^^ 2 > ^^-> 1-> -1->Emitted(15, 5) Source(4, 1) + SourceIndex(1) name (c1) +1->Emitted(29, 5) Source(4, 1) + SourceIndex(2) name (c1) --- >>> } 1->^^^^ @@ -378,16 +544,16 @@ sourceFile:../outputdir_mixed_subfolder/test.ts > public p1: number; > 2 > } -1->Emitted(16, 5) Source(6, 1) + SourceIndex(1) name (c1.constructor) -2 >Emitted(16, 6) Source(6, 2) + SourceIndex(1) name (c1.constructor) +1->Emitted(30, 5) Source(6, 1) + SourceIndex(2) name (c1.constructor) +2 >Emitted(30, 6) Source(6, 2) + SourceIndex(2) name (c1.constructor) --- >>> return c1; 1->^^^^ 2 > ^^^^^^^^^ 1-> 2 > } -1->Emitted(17, 5) Source(6, 1) + SourceIndex(1) name (c1) -2 >Emitted(17, 14) Source(6, 2) + SourceIndex(1) name (c1) +1->Emitted(31, 5) Source(6, 1) + SourceIndex(2) name (c1) +2 >Emitted(31, 14) Source(6, 2) + SourceIndex(2) name (c1) --- >>>})(); 1 > @@ -401,10 +567,10 @@ sourceFile:../outputdir_mixed_subfolder/test.ts 4 > class c1 { > public p1: number; > } -1 >Emitted(18, 1) Source(6, 1) + SourceIndex(1) name (c1) -2 >Emitted(18, 2) Source(6, 2) + SourceIndex(1) name (c1) -3 >Emitted(18, 2) Source(4, 1) + SourceIndex(1) -4 >Emitted(18, 6) Source(6, 2) + SourceIndex(1) +1 >Emitted(32, 1) Source(6, 1) + SourceIndex(2) name (c1) +2 >Emitted(32, 2) Source(6, 2) + SourceIndex(2) name (c1) +3 >Emitted(32, 2) Source(4, 1) + SourceIndex(2) +4 >Emitted(32, 6) Source(6, 2) + SourceIndex(2) --- >>>var instance1 = new c1(); 1-> @@ -425,21 +591,21 @@ sourceFile:../outputdir_mixed_subfolder/test.ts 6 > c1 7 > () 8 > ; -1->Emitted(19, 1) Source(8, 1) + SourceIndex(1) -2 >Emitted(19, 5) Source(8, 5) + SourceIndex(1) -3 >Emitted(19, 14) Source(8, 14) + SourceIndex(1) -4 >Emitted(19, 17) Source(8, 17) + SourceIndex(1) -5 >Emitted(19, 21) Source(8, 21) + SourceIndex(1) -6 >Emitted(19, 23) Source(8, 23) + SourceIndex(1) -7 >Emitted(19, 25) Source(8, 25) + SourceIndex(1) -8 >Emitted(19, 26) Source(8, 26) + SourceIndex(1) +1->Emitted(33, 1) Source(8, 1) + SourceIndex(2) +2 >Emitted(33, 5) Source(8, 5) + SourceIndex(2) +3 >Emitted(33, 14) Source(8, 14) + SourceIndex(2) +4 >Emitted(33, 17) Source(8, 17) + SourceIndex(2) +5 >Emitted(33, 21) Source(8, 21) + SourceIndex(2) +6 >Emitted(33, 23) Source(8, 23) + SourceIndex(2) +7 >Emitted(33, 25) Source(8, 25) + SourceIndex(2) +8 >Emitted(33, 26) Source(8, 26) + SourceIndex(2) --- >>>function f1() { 1 > 2 >^^^^^^^^^^^^^^^^^^^^^^-> 1 > > -1 >Emitted(20, 1) Source(9, 1) + SourceIndex(1) +1 >Emitted(34, 1) Source(9, 1) + SourceIndex(2) --- >>> return instance1; 1->^^^^ @@ -453,11 +619,11 @@ sourceFile:../outputdir_mixed_subfolder/test.ts 3 > 4 > instance1 5 > ; -1->Emitted(21, 5) Source(10, 5) + SourceIndex(1) name (f1) -2 >Emitted(21, 11) Source(10, 11) + SourceIndex(1) name (f1) -3 >Emitted(21, 12) Source(10, 12) + SourceIndex(1) name (f1) -4 >Emitted(21, 21) Source(10, 21) + SourceIndex(1) name (f1) -5 >Emitted(21, 22) Source(10, 22) + SourceIndex(1) name (f1) +1->Emitted(35, 5) Source(10, 5) + SourceIndex(2) name (f1) +2 >Emitted(35, 11) Source(10, 11) + SourceIndex(2) name (f1) +3 >Emitted(35, 12) Source(10, 12) + SourceIndex(2) name (f1) +4 >Emitted(35, 21) Source(10, 21) + SourceIndex(2) name (f1) +5 >Emitted(35, 22) Source(10, 22) + SourceIndex(2) name (f1) --- >>>} 1 > @@ -466,7 +632,7 @@ sourceFile:../outputdir_mixed_subfolder/test.ts 1 > > 2 >} -1 >Emitted(22, 1) Source(11, 1) + SourceIndex(1) name (f1) -2 >Emitted(22, 2) Source(11, 2) + SourceIndex(1) name (f1) +1 >Emitted(36, 1) Source(11, 1) + SourceIndex(2) name (f1) +2 >Emitted(36, 2) Source(11, 2) + SourceIndex(2) name (f1) --- >>>//# sourceMappingURL=../../mapFiles/outAndOutDirFile.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.d.ts b/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.d.ts deleted file mode 100644 index 9b9cdd4a214..00000000000 --- a/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.d.ts +++ /dev/null @@ -1,13 +0,0 @@ -/// -declare var m1_a1: number; -declare class m1_c1 { - m1_c1_p1: number; -} -declare var m1_instance1: m1_c1; -declare function m1_f1(): m1_c1; -declare var a1: number; -declare class c1 { - p1: number; -} -declare var instance1: c1; -declare function f1(): c1; diff --git a/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.js b/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.js deleted file mode 100644 index c0138423cae..00000000000 --- a/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.js +++ /dev/null @@ -1,23 +0,0 @@ -var m1_a1 = 10; -var m1_c1 = (function () { - function m1_c1() { - } - return m1_c1; -})(); -var m1_instance1 = new m1_c1(); -function m1_f1() { - return m1_instance1; -} -/// -/// -var a1 = 10; -var c1 = (function () { - function c1() { - } - return c1; -})(); -var instance1 = new c1(); -function f1() { - return instance1; -} -//# sourceMappingURL=../../mapFiles/outAndOutDirFile.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.js.map b/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.js.map index 630508cb9f8..43710b5f061 100644 --- a/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.js.map +++ b/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.js.map @@ -1 +1 @@ -{"version":3,"file":"outAndOutDirFile.js","sourceRoot":"","sources":["../outputdir_mixed_subfolder/ref/m1.ts","../outputdir_mixed_subfolder/test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACRD,iCAAiC;AACjC,iCAAiC;AACjC,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"outAndOutDirFile.js","sourceRoot":"","sources":["../outputdir_mixed_subfolder/ref/m1.ts","../outputdir_mixed_subfolder/ref/m2.ts","../outputdir_mixed_subfolder/test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;AERD,iCAAiC;AACjC,iCAAiC;AACjC,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/mapRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory.sourcemap.txt b/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/mapRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory.sourcemap.txt index eb9ad2993b2..89fba663c60 100644 --- a/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/mapRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory.sourcemap.txt +++ b/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/mapRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory.sourcemap.txt @@ -173,7 +173,7 @@ sourceFile:../../outputdir_mixed_subfolder/ref/m2.ts JsFile: outAndOutDirFile.js mapUrl: ../../mapFiles/outAndOutDirFile.js.map sourceRoot: -sources: ../outputdir_mixed_subfolder/ref/m1.ts,../outputdir_mixed_subfolder/test.ts +sources: ../outputdir_mixed_subfolder/ref/m1.ts,../outputdir_mixed_subfolder/ref/m2.ts,../outputdir_mixed_subfolder/test.ts =================================================================== ------------------------------------------------------------------- emittedFile:bin/outAndOutDirFile.js @@ -322,8 +322,8 @@ sourceFile:../outputdir_mixed_subfolder/test.ts 3 > ^-> 1-> 2 >/// -1->Emitted(11, 1) Source(1, 1) + SourceIndex(1) -2 >Emitted(11, 34) Source(1, 34) + SourceIndex(1) +1->Emitted(11, 1) Source(1, 1) + SourceIndex(2) +2 >Emitted(11, 34) Source(1, 34) + SourceIndex(2) --- >>>/// 1-> @@ -331,8 +331,8 @@ sourceFile:../outputdir_mixed_subfolder/test.ts 1-> > 2 >/// -1->Emitted(12, 1) Source(2, 1) + SourceIndex(1) -2 >Emitted(12, 34) Source(2, 34) + SourceIndex(1) +1->Emitted(12, 1) Source(2, 1) + SourceIndex(2) +2 >Emitted(12, 34) Source(2, 34) + SourceIndex(2) --- >>>var a1 = 10; 1 > @@ -349,25 +349,25 @@ sourceFile:../outputdir_mixed_subfolder/test.ts 4 > = 5 > 10 6 > ; -1 >Emitted(13, 1) Source(3, 1) + SourceIndex(1) -2 >Emitted(13, 5) Source(3, 5) + SourceIndex(1) -3 >Emitted(13, 7) Source(3, 7) + SourceIndex(1) -4 >Emitted(13, 10) Source(3, 10) + SourceIndex(1) -5 >Emitted(13, 12) Source(3, 12) + SourceIndex(1) -6 >Emitted(13, 13) Source(3, 13) + SourceIndex(1) +1 >Emitted(13, 1) Source(3, 1) + SourceIndex(2) +2 >Emitted(13, 5) Source(3, 5) + SourceIndex(2) +3 >Emitted(13, 7) Source(3, 7) + SourceIndex(2) +4 >Emitted(13, 10) Source(3, 10) + SourceIndex(2) +5 >Emitted(13, 12) Source(3, 12) + SourceIndex(2) +6 >Emitted(13, 13) Source(3, 13) + SourceIndex(2) --- >>>var c1 = (function () { 1-> 2 >^^^^^^^^^^^^^^^^^^^^-> 1-> > -1->Emitted(14, 1) Source(4, 1) + SourceIndex(1) +1->Emitted(14, 1) Source(4, 1) + SourceIndex(2) --- >>> function c1() { 1->^^^^ 2 > ^^-> 1-> -1->Emitted(15, 5) Source(4, 1) + SourceIndex(1) name (c1) +1->Emitted(15, 5) Source(4, 1) + SourceIndex(2) name (c1) --- >>> } 1->^^^^ @@ -377,16 +377,16 @@ sourceFile:../outputdir_mixed_subfolder/test.ts > public p1: number; > 2 > } -1->Emitted(16, 5) Source(6, 1) + SourceIndex(1) name (c1.constructor) -2 >Emitted(16, 6) Source(6, 2) + SourceIndex(1) name (c1.constructor) +1->Emitted(16, 5) Source(6, 1) + SourceIndex(2) name (c1.constructor) +2 >Emitted(16, 6) Source(6, 2) + SourceIndex(2) name (c1.constructor) --- >>> return c1; 1->^^^^ 2 > ^^^^^^^^^ 1-> 2 > } -1->Emitted(17, 5) Source(6, 1) + SourceIndex(1) name (c1) -2 >Emitted(17, 14) Source(6, 2) + SourceIndex(1) name (c1) +1->Emitted(17, 5) Source(6, 1) + SourceIndex(2) name (c1) +2 >Emitted(17, 14) Source(6, 2) + SourceIndex(2) name (c1) --- >>>})(); 1 > @@ -400,10 +400,10 @@ sourceFile:../outputdir_mixed_subfolder/test.ts 4 > class c1 { > public p1: number; > } -1 >Emitted(18, 1) Source(6, 1) + SourceIndex(1) name (c1) -2 >Emitted(18, 2) Source(6, 2) + SourceIndex(1) name (c1) -3 >Emitted(18, 2) Source(4, 1) + SourceIndex(1) -4 >Emitted(18, 6) Source(6, 2) + SourceIndex(1) +1 >Emitted(18, 1) Source(6, 1) + SourceIndex(2) name (c1) +2 >Emitted(18, 2) Source(6, 2) + SourceIndex(2) name (c1) +3 >Emitted(18, 2) Source(4, 1) + SourceIndex(2) +4 >Emitted(18, 6) Source(6, 2) + SourceIndex(2) --- >>>var instance1 = new c1(); 1-> @@ -424,21 +424,21 @@ sourceFile:../outputdir_mixed_subfolder/test.ts 6 > c1 7 > () 8 > ; -1->Emitted(19, 1) Source(8, 1) + SourceIndex(1) -2 >Emitted(19, 5) Source(8, 5) + SourceIndex(1) -3 >Emitted(19, 14) Source(8, 14) + SourceIndex(1) -4 >Emitted(19, 17) Source(8, 17) + SourceIndex(1) -5 >Emitted(19, 21) Source(8, 21) + SourceIndex(1) -6 >Emitted(19, 23) Source(8, 23) + SourceIndex(1) -7 >Emitted(19, 25) Source(8, 25) + SourceIndex(1) -8 >Emitted(19, 26) Source(8, 26) + SourceIndex(1) +1->Emitted(19, 1) Source(8, 1) + SourceIndex(2) +2 >Emitted(19, 5) Source(8, 5) + SourceIndex(2) +3 >Emitted(19, 14) Source(8, 14) + SourceIndex(2) +4 >Emitted(19, 17) Source(8, 17) + SourceIndex(2) +5 >Emitted(19, 21) Source(8, 21) + SourceIndex(2) +6 >Emitted(19, 23) Source(8, 23) + SourceIndex(2) +7 >Emitted(19, 25) Source(8, 25) + SourceIndex(2) +8 >Emitted(19, 26) Source(8, 26) + SourceIndex(2) --- >>>function f1() { 1 > 2 >^^^^^^^^^^^^^^^^^^^^^^-> 1 > > -1 >Emitted(20, 1) Source(9, 1) + SourceIndex(1) +1 >Emitted(20, 1) Source(9, 1) + SourceIndex(2) --- >>> return instance1; 1->^^^^ @@ -452,11 +452,11 @@ sourceFile:../outputdir_mixed_subfolder/test.ts 3 > 4 > instance1 5 > ; -1->Emitted(21, 5) Source(10, 5) + SourceIndex(1) name (f1) -2 >Emitted(21, 11) Source(10, 11) + SourceIndex(1) name (f1) -3 >Emitted(21, 12) Source(10, 12) + SourceIndex(1) name (f1) -4 >Emitted(21, 21) Source(10, 21) + SourceIndex(1) name (f1) -5 >Emitted(21, 22) Source(10, 22) + SourceIndex(1) name (f1) +1->Emitted(21, 5) Source(10, 5) + SourceIndex(2) name (f1) +2 >Emitted(21, 11) Source(10, 11) + SourceIndex(2) name (f1) +3 >Emitted(21, 12) Source(10, 12) + SourceIndex(2) name (f1) +4 >Emitted(21, 21) Source(10, 21) + SourceIndex(2) name (f1) +5 >Emitted(21, 22) Source(10, 22) + SourceIndex(2) name (f1) --- >>>} 1 > @@ -465,7 +465,7 @@ sourceFile:../outputdir_mixed_subfolder/test.ts 1 > > 2 >} -1 >Emitted(22, 1) Source(11, 1) + SourceIndex(1) name (f1) -2 >Emitted(22, 2) Source(11, 2) + SourceIndex(1) name (f1) +1 >Emitted(22, 1) Source(11, 1) + SourceIndex(2) name (f1) +2 >Emitted(22, 2) Source(11, 2) + SourceIndex(2) name (f1) --- >>>//# sourceMappingURL=../../mapFiles/outAndOutDirFile.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderSpecifyOutputFile/amd/bin/test.d.ts b/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderSpecifyOutputFile/amd/bin/test.d.ts deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderSpecifyOutputFile/amd/bin/test.js b/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderSpecifyOutputFile/amd/bin/test.js deleted file mode 100644 index f359cef4be2..00000000000 --- a/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderSpecifyOutputFile/amd/bin/test.js +++ /dev/null @@ -1 +0,0 @@ -//# sourceMappingURL=../../../mapFiles/test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderSpecifyOutputFile/amd/bin/test.js.map b/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderSpecifyOutputFile/amd/bin/test.js.map index c1e0281a2ab..a7235c6c2b3 100644 --- a/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderSpecifyOutputFile/amd/bin/test.js.map +++ b/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderSpecifyOutputFile/amd/bin/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"","sources":[],"names":[],"mappings":""} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"","sources":["../projects/outputdir_module_multifolder/ref/m1.ts","../projects/outputdir_module_multifolder_ref/m2.ts","../projects/outputdir_module_multifolder/test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","m2_c1","m2_c1.constructor","m2_f1","c1","c1.constructor","f1"],"mappings":";IAAW,aAAK,GAAG,EAAE,CAAC;IACtB;QAAAA;QAEAC,CAACA;QAADD,YAACA;IAADA,CAACA,AAFD,IAEC;IAFY,aAAK,QAEjB,CAAA;IAEU,oBAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACIE,MAAMA,CAACA,oBAAYA,CAACA;IACxBA,CAACA;IAFe,aAAK,QAEpB,CAAA;;;ICRU,aAAK,GAAG,EAAE,CAAC;IACtB;QAAAC;QAEAC,CAACA;QAADD,YAACA;IAADA,CAACA,AAFD,IAEC;IAFY,aAAK,QAEjB,CAAA;IAEU,oBAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACIE,MAAMA,CAACA,oBAAYA,CAACA;IACxBA,CAACA;IAFe,aAAK,QAEpB,CAAA;;;ICNU,UAAE,GAAG,EAAE,CAAC;IACnB;QAAAC;QAEAC,CAACA;QAADD,SAACA;IAADA,CAACA,AAFD,IAEC;IAFY,UAAE,KAEd,CAAA;IAEU,iBAAS,GAAG,IAAI,EAAE,EAAE,CAAC;IAChC;QACIE,MAAMA,CAACA,iBAASA,CAACA;IACrBA,CAACA;IAFe,UAAE,KAEjB,CAAA;IAEU,UAAE,GAAG,EAAE,CAAC,KAAK,CAAC;IACd,UAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderSpecifyOutputFile/amd/mapRootRelativePathModuleMultifolderSpecifyOutputFile.sourcemap.txt b/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderSpecifyOutputFile/amd/mapRootRelativePathModuleMultifolderSpecifyOutputFile.sourcemap.txt index c2eacec3bdc..2cbcfa7b2ce 100644 --- a/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderSpecifyOutputFile/amd/mapRootRelativePathModuleMultifolderSpecifyOutputFile.sourcemap.txt +++ b/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderSpecifyOutputFile/amd/mapRootRelativePathModuleMultifolderSpecifyOutputFile.sourcemap.txt @@ -571,6 +571,557 @@ sourceFile:../../projects/outputdir_module_multifolder/test.ts JsFile: test.js mapUrl: ../../../mapFiles/test.js.map sourceRoot: -sources: +sources: ../projects/outputdir_module_multifolder/ref/m1.ts,../projects/outputdir_module_multifolder_ref/m2.ts,../projects/outputdir_module_multifolder/test.ts =================================================================== +------------------------------------------------------------------- +emittedFile:bin/test.js +sourceFile:../projects/outputdir_module_multifolder/ref/m1.ts +------------------------------------------------------------------- +>>>define("ref/m1", ["require", "exports"], function (require, exports) { +>>> exports.m1_a1 = 10; +1 >^^^^ +2 > ^^^^^^^^^^^^^ +3 > ^^^ +4 > ^^ +5 > ^ +6 > ^^^^^^^^-> +1 >export var +2 > m1_a1 +3 > = +4 > 10 +5 > ; +1 >Emitted(2, 5) Source(1, 12) + SourceIndex(0) +2 >Emitted(2, 18) Source(1, 17) + SourceIndex(0) +3 >Emitted(2, 21) Source(1, 20) + SourceIndex(0) +4 >Emitted(2, 23) Source(1, 22) + SourceIndex(0) +5 >Emitted(2, 24) Source(1, 23) + SourceIndex(0) +--- +>>> var m1_c1 = (function () { +1->^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^^^^-> +1-> + > +1->Emitted(3, 5) Source(2, 1) + SourceIndex(0) +--- +>>> function m1_c1() { +1->^^^^^^^^ +2 > ^^-> +1-> +1->Emitted(4, 9) Source(2, 1) + SourceIndex(0) name (m1_c1) +--- +>>> } +1->^^^^^^^^ +2 > ^ +3 > ^^^^^^^^^^^^^-> +1->export class m1_c1 { + > public m1_c1_p1: number; + > +2 > } +1->Emitted(5, 9) Source(4, 1) + SourceIndex(0) name (m1_c1.constructor) +2 >Emitted(5, 10) Source(4, 2) + SourceIndex(0) name (m1_c1.constructor) +--- +>>> return m1_c1; +1->^^^^^^^^ +2 > ^^^^^^^^^^^^ +1-> +2 > } +1->Emitted(6, 9) Source(4, 1) + SourceIndex(0) name (m1_c1) +2 >Emitted(6, 21) Source(4, 2) + SourceIndex(0) name (m1_c1) +--- +>>> })(); +1 >^^^^ +2 > ^ +3 > +4 > ^^^^ +5 > ^^^^^^^^^^^^^^^^^^-> +1 > +2 > } +3 > +4 > export class m1_c1 { + > public m1_c1_p1: number; + > } +1 >Emitted(7, 5) Source(4, 1) + SourceIndex(0) name (m1_c1) +2 >Emitted(7, 6) Source(4, 2) + SourceIndex(0) name (m1_c1) +3 >Emitted(7, 6) Source(2, 1) + SourceIndex(0) +4 >Emitted(7, 10) Source(4, 2) + SourceIndex(0) +--- +>>> exports.m1_c1 = m1_c1; +1->^^^^ +2 > ^^^^^^^^^^^^^ +3 > ^^^^^^^^ +4 > ^ +5 > ^^^^^^^^^^^^^^-> +1-> +2 > m1_c1 +3 > { + > public m1_c1_p1: number; + > } +4 > +1->Emitted(8, 5) Source(2, 14) + SourceIndex(0) +2 >Emitted(8, 18) Source(2, 19) + SourceIndex(0) +3 >Emitted(8, 26) Source(4, 2) + SourceIndex(0) +4 >Emitted(8, 27) Source(4, 2) + SourceIndex(0) +--- +>>> exports.m1_instance1 = new m1_c1(); +1->^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^ +3 > ^^^ +4 > ^^^^ +5 > ^^^^^ +6 > ^^ +7 > ^ +1-> + > + >export var +2 > m1_instance1 +3 > = +4 > new +5 > m1_c1 +6 > () +7 > ; +1->Emitted(9, 5) Source(6, 12) + SourceIndex(0) +2 >Emitted(9, 25) Source(6, 24) + SourceIndex(0) +3 >Emitted(9, 28) Source(6, 27) + SourceIndex(0) +4 >Emitted(9, 32) Source(6, 31) + SourceIndex(0) +5 >Emitted(9, 37) Source(6, 36) + SourceIndex(0) +6 >Emitted(9, 39) Source(6, 38) + SourceIndex(0) +7 >Emitted(9, 40) Source(6, 39) + SourceIndex(0) +--- +>>> function m1_f1() { +1 >^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +1 > + > +1 >Emitted(10, 5) Source(7, 1) + SourceIndex(0) +--- +>>> return exports.m1_instance1; +1->^^^^^^^^ +2 > ^^^^^^ +3 > ^ +4 > ^^^^^^^^^^^^^^^^^^^^ +5 > ^ +1->export function m1_f1() { + > +2 > return +3 > +4 > m1_instance1 +5 > ; +1->Emitted(11, 9) Source(8, 5) + SourceIndex(0) name (m1_f1) +2 >Emitted(11, 15) Source(8, 11) + SourceIndex(0) name (m1_f1) +3 >Emitted(11, 16) Source(8, 12) + SourceIndex(0) name (m1_f1) +4 >Emitted(11, 36) Source(8, 24) + SourceIndex(0) name (m1_f1) +5 >Emitted(11, 37) Source(8, 25) + SourceIndex(0) name (m1_f1) +--- +>>> } +1 >^^^^ +2 > ^ +3 > ^^^^^^^^^^^^^^^^^^^^^^-> +1 > + > +2 > } +1 >Emitted(12, 5) Source(9, 1) + SourceIndex(0) name (m1_f1) +2 >Emitted(12, 6) Source(9, 2) + SourceIndex(0) name (m1_f1) +--- +>>> exports.m1_f1 = m1_f1; +1->^^^^ +2 > ^^^^^^^^^^^^^ +3 > ^^^^^^^^ +4 > ^ +1-> +2 > m1_f1 +3 > () { + > return m1_instance1; + > } +4 > +1->Emitted(13, 5) Source(7, 17) + SourceIndex(0) +2 >Emitted(13, 18) Source(7, 22) + SourceIndex(0) +3 >Emitted(13, 26) Source(9, 2) + SourceIndex(0) +4 >Emitted(13, 27) Source(9, 2) + SourceIndex(0) +--- +------------------------------------------------------------------- +emittedFile:bin/test.js +sourceFile:../projects/outputdir_module_multifolder_ref/m2.ts +------------------------------------------------------------------- +>>>}); +>>>define("../outputdir_module_multifolder_ref/m2", ["require", "exports"], function (require, exports) { +>>> exports.m2_a1 = 10; +1 >^^^^ +2 > ^^^^^^^^^^^^^ +3 > ^^^ +4 > ^^ +5 > ^ +6 > ^^^^^^^^-> +1 >export var +2 > m2_a1 +3 > = +4 > 10 +5 > ; +1 >Emitted(16, 5) Source(1, 12) + SourceIndex(1) +2 >Emitted(16, 18) Source(1, 17) + SourceIndex(1) +3 >Emitted(16, 21) Source(1, 20) + SourceIndex(1) +4 >Emitted(16, 23) Source(1, 22) + SourceIndex(1) +5 >Emitted(16, 24) Source(1, 23) + SourceIndex(1) +--- +>>> var m2_c1 = (function () { +1->^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^^^^-> +1-> + > +1->Emitted(17, 5) Source(2, 1) + SourceIndex(1) +--- +>>> function m2_c1() { +1->^^^^^^^^ +2 > ^^-> +1-> +1->Emitted(18, 9) Source(2, 1) + SourceIndex(1) name (m2_c1) +--- +>>> } +1->^^^^^^^^ +2 > ^ +3 > ^^^^^^^^^^^^^-> +1->export class m2_c1 { + > public m2_c1_p1: number; + > +2 > } +1->Emitted(19, 9) Source(4, 1) + SourceIndex(1) name (m2_c1.constructor) +2 >Emitted(19, 10) Source(4, 2) + SourceIndex(1) name (m2_c1.constructor) +--- +>>> return m2_c1; +1->^^^^^^^^ +2 > ^^^^^^^^^^^^ +1-> +2 > } +1->Emitted(20, 9) Source(4, 1) + SourceIndex(1) name (m2_c1) +2 >Emitted(20, 21) Source(4, 2) + SourceIndex(1) name (m2_c1) +--- +>>> })(); +1 >^^^^ +2 > ^ +3 > +4 > ^^^^ +5 > ^^^^^^^^^^^^^^^^^^-> +1 > +2 > } +3 > +4 > export class m2_c1 { + > public m2_c1_p1: number; + > } +1 >Emitted(21, 5) Source(4, 1) + SourceIndex(1) name (m2_c1) +2 >Emitted(21, 6) Source(4, 2) + SourceIndex(1) name (m2_c1) +3 >Emitted(21, 6) Source(2, 1) + SourceIndex(1) +4 >Emitted(21, 10) Source(4, 2) + SourceIndex(1) +--- +>>> exports.m2_c1 = m2_c1; +1->^^^^ +2 > ^^^^^^^^^^^^^ +3 > ^^^^^^^^ +4 > ^ +5 > ^^^^^^^^^^^^^^-> +1-> +2 > m2_c1 +3 > { + > public m2_c1_p1: number; + > } +4 > +1->Emitted(22, 5) Source(2, 14) + SourceIndex(1) +2 >Emitted(22, 18) Source(2, 19) + SourceIndex(1) +3 >Emitted(22, 26) Source(4, 2) + SourceIndex(1) +4 >Emitted(22, 27) Source(4, 2) + SourceIndex(1) +--- +>>> exports.m2_instance1 = new m2_c1(); +1->^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^ +3 > ^^^ +4 > ^^^^ +5 > ^^^^^ +6 > ^^ +7 > ^ +1-> + > + >export var +2 > m2_instance1 +3 > = +4 > new +5 > m2_c1 +6 > () +7 > ; +1->Emitted(23, 5) Source(6, 12) + SourceIndex(1) +2 >Emitted(23, 25) Source(6, 24) + SourceIndex(1) +3 >Emitted(23, 28) Source(6, 27) + SourceIndex(1) +4 >Emitted(23, 32) Source(6, 31) + SourceIndex(1) +5 >Emitted(23, 37) Source(6, 36) + SourceIndex(1) +6 >Emitted(23, 39) Source(6, 38) + SourceIndex(1) +7 >Emitted(23, 40) Source(6, 39) + SourceIndex(1) +--- +>>> function m2_f1() { +1 >^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +1 > + > +1 >Emitted(24, 5) Source(7, 1) + SourceIndex(1) +--- +>>> return exports.m2_instance1; +1->^^^^^^^^ +2 > ^^^^^^ +3 > ^ +4 > ^^^^^^^^^^^^^^^^^^^^ +5 > ^ +1->export function m2_f1() { + > +2 > return +3 > +4 > m2_instance1 +5 > ; +1->Emitted(25, 9) Source(8, 5) + SourceIndex(1) name (m2_f1) +2 >Emitted(25, 15) Source(8, 11) + SourceIndex(1) name (m2_f1) +3 >Emitted(25, 16) Source(8, 12) + SourceIndex(1) name (m2_f1) +4 >Emitted(25, 36) Source(8, 24) + SourceIndex(1) name (m2_f1) +5 >Emitted(25, 37) Source(8, 25) + SourceIndex(1) name (m2_f1) +--- +>>> } +1 >^^^^ +2 > ^ +3 > ^^^^^^^^^^^^^^^^^^^^^^-> +1 > + > +2 > } +1 >Emitted(26, 5) Source(9, 1) + SourceIndex(1) name (m2_f1) +2 >Emitted(26, 6) Source(9, 2) + SourceIndex(1) name (m2_f1) +--- +>>> exports.m2_f1 = m2_f1; +1->^^^^ +2 > ^^^^^^^^^^^^^ +3 > ^^^^^^^^ +4 > ^ +1-> +2 > m2_f1 +3 > () { + > return m2_instance1; + > } +4 > +1->Emitted(27, 5) Source(7, 17) + SourceIndex(1) +2 >Emitted(27, 18) Source(7, 22) + SourceIndex(1) +3 >Emitted(27, 26) Source(9, 2) + SourceIndex(1) +4 >Emitted(27, 27) Source(9, 2) + SourceIndex(1) +--- +------------------------------------------------------------------- +emittedFile:bin/test.js +sourceFile:../projects/outputdir_module_multifolder/test.ts +------------------------------------------------------------------- +>>>}); +>>>define("test", ["require", "exports", "ref/m1", "../outputdir_module_multifolder_ref/m2"], function (require, exports, m1, m2) { +>>> exports.a1 = 10; +1 >^^^^ +2 > ^^^^^^^^^^ +3 > ^^^ +4 > ^^ +5 > ^ +6 > ^^^^^^^^-> +1 >import m1 = require("ref/m1"); + >import m2 = require("../outputdir_module_multifolder_ref/m2"); + >export var +2 > a1 +3 > = +4 > 10 +5 > ; +1 >Emitted(30, 5) Source(3, 12) + SourceIndex(2) +2 >Emitted(30, 15) Source(3, 14) + SourceIndex(2) +3 >Emitted(30, 18) Source(3, 17) + SourceIndex(2) +4 >Emitted(30, 20) Source(3, 19) + SourceIndex(2) +5 >Emitted(30, 21) Source(3, 20) + SourceIndex(2) +--- +>>> var c1 = (function () { +1->^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^-> +1-> + > +1->Emitted(31, 5) Source(4, 1) + SourceIndex(2) +--- +>>> function c1() { +1->^^^^^^^^ +2 > ^^-> +1-> +1->Emitted(32, 9) Source(4, 1) + SourceIndex(2) name (c1) +--- +>>> } +1->^^^^^^^^ +2 > ^ +3 > ^^^^^^^^^^-> +1->export class c1 { + > public p1: number; + > +2 > } +1->Emitted(33, 9) Source(6, 1) + SourceIndex(2) name (c1.constructor) +2 >Emitted(33, 10) Source(6, 2) + SourceIndex(2) name (c1.constructor) +--- +>>> return c1; +1->^^^^^^^^ +2 > ^^^^^^^^^ +1-> +2 > } +1->Emitted(34, 9) Source(6, 1) + SourceIndex(2) name (c1) +2 >Emitted(34, 18) Source(6, 2) + SourceIndex(2) name (c1) +--- +>>> })(); +1 >^^^^ +2 > ^ +3 > +4 > ^^^^ +5 > ^^^^^^^^^^^^-> +1 > +2 > } +3 > +4 > export class c1 { + > public p1: number; + > } +1 >Emitted(35, 5) Source(6, 1) + SourceIndex(2) name (c1) +2 >Emitted(35, 6) Source(6, 2) + SourceIndex(2) name (c1) +3 >Emitted(35, 6) Source(4, 1) + SourceIndex(2) +4 >Emitted(35, 10) Source(6, 2) + SourceIndex(2) +--- +>>> exports.c1 = c1; +1->^^^^ +2 > ^^^^^^^^^^ +3 > ^^^^^ +4 > ^ +5 > ^^^^^^^^^^^^^^-> +1-> +2 > c1 +3 > { + > public p1: number; + > } +4 > +1->Emitted(36, 5) Source(4, 14) + SourceIndex(2) +2 >Emitted(36, 15) Source(4, 16) + SourceIndex(2) +3 >Emitted(36, 20) Source(6, 2) + SourceIndex(2) +4 >Emitted(36, 21) Source(6, 2) + SourceIndex(2) +--- +>>> exports.instance1 = new c1(); +1->^^^^ +2 > ^^^^^^^^^^^^^^^^^ +3 > ^^^ +4 > ^^^^ +5 > ^^ +6 > ^^ +7 > ^ +1-> + > + >export var +2 > instance1 +3 > = +4 > new +5 > c1 +6 > () +7 > ; +1->Emitted(37, 5) Source(8, 12) + SourceIndex(2) +2 >Emitted(37, 22) Source(8, 21) + SourceIndex(2) +3 >Emitted(37, 25) Source(8, 24) + SourceIndex(2) +4 >Emitted(37, 29) Source(8, 28) + SourceIndex(2) +5 >Emitted(37, 31) Source(8, 30) + SourceIndex(2) +6 >Emitted(37, 33) Source(8, 32) + SourceIndex(2) +7 >Emitted(37, 34) Source(8, 33) + SourceIndex(2) +--- +>>> function f1() { +1 >^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +1 > + > +1 >Emitted(38, 5) Source(9, 1) + SourceIndex(2) +--- +>>> return exports.instance1; +1->^^^^^^^^ +2 > ^^^^^^ +3 > ^ +4 > ^^^^^^^^^^^^^^^^^ +5 > ^ +1->export function f1() { + > +2 > return +3 > +4 > instance1 +5 > ; +1->Emitted(39, 9) Source(10, 5) + SourceIndex(2) name (f1) +2 >Emitted(39, 15) Source(10, 11) + SourceIndex(2) name (f1) +3 >Emitted(39, 16) Source(10, 12) + SourceIndex(2) name (f1) +4 >Emitted(39, 33) Source(10, 21) + SourceIndex(2) name (f1) +5 >Emitted(39, 34) Source(10, 22) + SourceIndex(2) name (f1) +--- +>>> } +1 >^^^^ +2 > ^ +3 > ^^^^^^^^^^^^^^^^-> +1 > + > +2 > } +1 >Emitted(40, 5) Source(11, 1) + SourceIndex(2) name (f1) +2 >Emitted(40, 6) Source(11, 2) + SourceIndex(2) name (f1) +--- +>>> exports.f1 = f1; +1->^^^^ +2 > ^^^^^^^^^^ +3 > ^^^^^ +4 > ^ +5 > ^^^^^^^-> +1-> +2 > f1 +3 > () { + > return instance1; + > } +4 > +1->Emitted(41, 5) Source(9, 17) + SourceIndex(2) +2 >Emitted(41, 15) Source(9, 19) + SourceIndex(2) +3 >Emitted(41, 20) Source(11, 2) + SourceIndex(2) +4 >Emitted(41, 21) Source(11, 2) + SourceIndex(2) +--- +>>> exports.a2 = m1.m1_c1; +1->^^^^ +2 > ^^^^^^^^^^ +3 > ^^^ +4 > ^^ +5 > ^ +6 > ^^^^^ +7 > ^ +8 > ^-> +1-> + > + >export var +2 > a2 +3 > = +4 > m1 +5 > . +6 > m1_c1 +7 > ; +1->Emitted(42, 5) Source(13, 12) + SourceIndex(2) +2 >Emitted(42, 15) Source(13, 14) + SourceIndex(2) +3 >Emitted(42, 18) Source(13, 17) + SourceIndex(2) +4 >Emitted(42, 20) Source(13, 19) + SourceIndex(2) +5 >Emitted(42, 21) Source(13, 20) + SourceIndex(2) +6 >Emitted(42, 26) Source(13, 25) + SourceIndex(2) +7 >Emitted(42, 27) Source(13, 26) + SourceIndex(2) +--- +>>> exports.a3 = m2.m2_c1; +1->^^^^ +2 > ^^^^^^^^^^ +3 > ^^^ +4 > ^^ +5 > ^ +6 > ^^^^^ +7 > ^ +1-> + >export var +2 > a3 +3 > = +4 > m2 +5 > . +6 > m2_c1 +7 > ; +1->Emitted(43, 5) Source(14, 12) + SourceIndex(2) +2 >Emitted(43, 15) Source(14, 14) + SourceIndex(2) +3 >Emitted(43, 18) Source(14, 17) + SourceIndex(2) +4 >Emitted(43, 20) Source(14, 19) + SourceIndex(2) +5 >Emitted(43, 21) Source(14, 20) + SourceIndex(2) +6 >Emitted(43, 26) Source(14, 25) + SourceIndex(2) +7 >Emitted(43, 27) Source(14, 26) + SourceIndex(2) +--- +>>>}); >>>//# sourceMappingURL=../../../mapFiles/test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderSpecifyOutputFile/node/bin/test.d.ts b/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderSpecifyOutputFile/node/bin/test.d.ts deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderSpecifyOutputFile/node/bin/test.js b/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderSpecifyOutputFile/node/bin/test.js deleted file mode 100644 index f359cef4be2..00000000000 --- a/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderSpecifyOutputFile/node/bin/test.js +++ /dev/null @@ -1 +0,0 @@ -//# sourceMappingURL=../../../mapFiles/test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderSpecifyOutputFile/node/bin/test.js.map b/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderSpecifyOutputFile/node/bin/test.js.map index c1e0281a2ab..ca280b23052 100644 --- a/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderSpecifyOutputFile/node/bin/test.js.map +++ b/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderSpecifyOutputFile/node/bin/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"","sources":[],"names":[],"mappings":""} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"","sources":["../projects/outputdir_module_multifolder/ref/m1.ts","../projects/outputdir_module_multifolder_ref/m2.ts","../projects/outputdir_module_multifolder/test.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderSpecifyOutputFile/node/mapRootRelativePathModuleMultifolderSpecifyOutputFile.sourcemap.txt b/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderSpecifyOutputFile/node/mapRootRelativePathModuleMultifolderSpecifyOutputFile.sourcemap.txt index 1d6a282976d..e020f2716f7 100644 --- a/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderSpecifyOutputFile/node/mapRootRelativePathModuleMultifolderSpecifyOutputFile.sourcemap.txt +++ b/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderSpecifyOutputFile/node/mapRootRelativePathModuleMultifolderSpecifyOutputFile.sourcemap.txt @@ -615,6 +615,6 @@ sourceFile:../../projects/outputdir_module_multifolder/test.ts JsFile: test.js mapUrl: ../../../mapFiles/test.js.map sourceRoot: -sources: +sources: ../projects/outputdir_module_multifolder/ref/m1.ts,../projects/outputdir_module_multifolder_ref/m2.ts,../projects/outputdir_module_multifolder/test.ts =================================================================== >>>//# sourceMappingURL=../../../mapFiles/test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootRelativePathModuleSimpleSpecifyOutputFile/amd/bin/test.d.ts b/tests/baselines/reference/project/mapRootRelativePathModuleSimpleSpecifyOutputFile/amd/bin/test.d.ts deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/tests/baselines/reference/project/mapRootRelativePathModuleSimpleSpecifyOutputFile/amd/bin/test.js b/tests/baselines/reference/project/mapRootRelativePathModuleSimpleSpecifyOutputFile/amd/bin/test.js deleted file mode 100644 index 58e831a041d..00000000000 --- a/tests/baselines/reference/project/mapRootRelativePathModuleSimpleSpecifyOutputFile/amd/bin/test.js +++ /dev/null @@ -1 +0,0 @@ -//# sourceMappingURL=../../mapFiles/test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootRelativePathModuleSimpleSpecifyOutputFile/amd/bin/test.js.map b/tests/baselines/reference/project/mapRootRelativePathModuleSimpleSpecifyOutputFile/amd/bin/test.js.map index c1e0281a2ab..b94a5ff18e5 100644 --- a/tests/baselines/reference/project/mapRootRelativePathModuleSimpleSpecifyOutputFile/amd/bin/test.js.map +++ b/tests/baselines/reference/project/mapRootRelativePathModuleSimpleSpecifyOutputFile/amd/bin/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"","sources":[],"names":[],"mappings":""} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"","sources":["../outputdir_module_simple/m1.ts","../outputdir_module_simple/test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","c1","c1.constructor","f1"],"mappings":";IAAW,aAAK,GAAG,EAAE,CAAC;IACtB;QAAAA;QAEAC,CAACA;QAADD,YAACA;IAADA,CAACA,AAFD,IAEC;IAFY,aAAK,QAEjB,CAAA;IAEU,oBAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACIE,MAAMA,CAACA,oBAAYA,CAACA;IACxBA,CAACA;IAFe,aAAK,QAEpB,CAAA;;;ICPU,UAAE,GAAG,EAAE,CAAC;IACnB;QAAAC;QAEAC,CAACA;QAADD,SAACA;IAADA,CAACA,AAFD,IAEC;IAFY,UAAE,KAEd,CAAA;IAEU,iBAAS,GAAG,IAAI,EAAE,EAAE,CAAC;IAChC;QACIE,MAAMA,CAACA,iBAASA,CAACA;IACrBA,CAACA;IAFe,UAAE,KAEjB,CAAA;IAEU,UAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootRelativePathModuleSimpleSpecifyOutputFile/amd/mapRootRelativePathModuleSimpleSpecifyOutputFile.sourcemap.txt b/tests/baselines/reference/project/mapRootRelativePathModuleSimpleSpecifyOutputFile/amd/mapRootRelativePathModuleSimpleSpecifyOutputFile.sourcemap.txt index 410dc94963f..8a95e1100a5 100644 --- a/tests/baselines/reference/project/mapRootRelativePathModuleSimpleSpecifyOutputFile/amd/mapRootRelativePathModuleSimpleSpecifyOutputFile.sourcemap.txt +++ b/tests/baselines/reference/project/mapRootRelativePathModuleSimpleSpecifyOutputFile/amd/mapRootRelativePathModuleSimpleSpecifyOutputFile.sourcemap.txt @@ -373,6 +373,365 @@ sourceFile:../outputdir_module_simple/test.ts JsFile: test.js mapUrl: ../../mapFiles/test.js.map sourceRoot: -sources: +sources: ../outputdir_module_simple/m1.ts,../outputdir_module_simple/test.ts =================================================================== +------------------------------------------------------------------- +emittedFile:bin/test.js +sourceFile:../outputdir_module_simple/m1.ts +------------------------------------------------------------------- +>>>define("m1", ["require", "exports"], function (require, exports) { +>>> exports.m1_a1 = 10; +1 >^^^^ +2 > ^^^^^^^^^^^^^ +3 > ^^^ +4 > ^^ +5 > ^ +6 > ^^^^^^^^-> +1 >export var +2 > m1_a1 +3 > = +4 > 10 +5 > ; +1 >Emitted(2, 5) Source(1, 12) + SourceIndex(0) +2 >Emitted(2, 18) Source(1, 17) + SourceIndex(0) +3 >Emitted(2, 21) Source(1, 20) + SourceIndex(0) +4 >Emitted(2, 23) Source(1, 22) + SourceIndex(0) +5 >Emitted(2, 24) Source(1, 23) + SourceIndex(0) +--- +>>> var m1_c1 = (function () { +1->^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^^^^-> +1-> + > +1->Emitted(3, 5) Source(2, 1) + SourceIndex(0) +--- +>>> function m1_c1() { +1->^^^^^^^^ +2 > ^^-> +1-> +1->Emitted(4, 9) Source(2, 1) + SourceIndex(0) name (m1_c1) +--- +>>> } +1->^^^^^^^^ +2 > ^ +3 > ^^^^^^^^^^^^^-> +1->export class m1_c1 { + > public m1_c1_p1: number; + > +2 > } +1->Emitted(5, 9) Source(4, 1) + SourceIndex(0) name (m1_c1.constructor) +2 >Emitted(5, 10) Source(4, 2) + SourceIndex(0) name (m1_c1.constructor) +--- +>>> return m1_c1; +1->^^^^^^^^ +2 > ^^^^^^^^^^^^ +1-> +2 > } +1->Emitted(6, 9) Source(4, 1) + SourceIndex(0) name (m1_c1) +2 >Emitted(6, 21) Source(4, 2) + SourceIndex(0) name (m1_c1) +--- +>>> })(); +1 >^^^^ +2 > ^ +3 > +4 > ^^^^ +5 > ^^^^^^^^^^^^^^^^^^-> +1 > +2 > } +3 > +4 > export class m1_c1 { + > public m1_c1_p1: number; + > } +1 >Emitted(7, 5) Source(4, 1) + SourceIndex(0) name (m1_c1) +2 >Emitted(7, 6) Source(4, 2) + SourceIndex(0) name (m1_c1) +3 >Emitted(7, 6) Source(2, 1) + SourceIndex(0) +4 >Emitted(7, 10) Source(4, 2) + SourceIndex(0) +--- +>>> exports.m1_c1 = m1_c1; +1->^^^^ +2 > ^^^^^^^^^^^^^ +3 > ^^^^^^^^ +4 > ^ +5 > ^^^^^^^^^^^^^^-> +1-> +2 > m1_c1 +3 > { + > public m1_c1_p1: number; + > } +4 > +1->Emitted(8, 5) Source(2, 14) + SourceIndex(0) +2 >Emitted(8, 18) Source(2, 19) + SourceIndex(0) +3 >Emitted(8, 26) Source(4, 2) + SourceIndex(0) +4 >Emitted(8, 27) Source(4, 2) + SourceIndex(0) +--- +>>> exports.m1_instance1 = new m1_c1(); +1->^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^ +3 > ^^^ +4 > ^^^^ +5 > ^^^^^ +6 > ^^ +7 > ^ +1-> + > + >export var +2 > m1_instance1 +3 > = +4 > new +5 > m1_c1 +6 > () +7 > ; +1->Emitted(9, 5) Source(6, 12) + SourceIndex(0) +2 >Emitted(9, 25) Source(6, 24) + SourceIndex(0) +3 >Emitted(9, 28) Source(6, 27) + SourceIndex(0) +4 >Emitted(9, 32) Source(6, 31) + SourceIndex(0) +5 >Emitted(9, 37) Source(6, 36) + SourceIndex(0) +6 >Emitted(9, 39) Source(6, 38) + SourceIndex(0) +7 >Emitted(9, 40) Source(6, 39) + SourceIndex(0) +--- +>>> function m1_f1() { +1 >^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +1 > + > +1 >Emitted(10, 5) Source(7, 1) + SourceIndex(0) +--- +>>> return exports.m1_instance1; +1->^^^^^^^^ +2 > ^^^^^^ +3 > ^ +4 > ^^^^^^^^^^^^^^^^^^^^ +5 > ^ +1->export function m1_f1() { + > +2 > return +3 > +4 > m1_instance1 +5 > ; +1->Emitted(11, 9) Source(8, 5) + SourceIndex(0) name (m1_f1) +2 >Emitted(11, 15) Source(8, 11) + SourceIndex(0) name (m1_f1) +3 >Emitted(11, 16) Source(8, 12) + SourceIndex(0) name (m1_f1) +4 >Emitted(11, 36) Source(8, 24) + SourceIndex(0) name (m1_f1) +5 >Emitted(11, 37) Source(8, 25) + SourceIndex(0) name (m1_f1) +--- +>>> } +1 >^^^^ +2 > ^ +3 > ^^^^^^^^^^^^^^^^^^^^^^-> +1 > + > +2 > } +1 >Emitted(12, 5) Source(9, 1) + SourceIndex(0) name (m1_f1) +2 >Emitted(12, 6) Source(9, 2) + SourceIndex(0) name (m1_f1) +--- +>>> exports.m1_f1 = m1_f1; +1->^^^^ +2 > ^^^^^^^^^^^^^ +3 > ^^^^^^^^ +4 > ^ +1-> +2 > m1_f1 +3 > () { + > return m1_instance1; + > } +4 > +1->Emitted(13, 5) Source(7, 17) + SourceIndex(0) +2 >Emitted(13, 18) Source(7, 22) + SourceIndex(0) +3 >Emitted(13, 26) Source(9, 2) + SourceIndex(0) +4 >Emitted(13, 27) Source(9, 2) + SourceIndex(0) +--- +------------------------------------------------------------------- +emittedFile:bin/test.js +sourceFile:../outputdir_module_simple/test.ts +------------------------------------------------------------------- +>>>}); +>>>define("test", ["require", "exports", "m1"], function (require, exports, m1) { +>>> exports.a1 = 10; +1 >^^^^ +2 > ^^^^^^^^^^ +3 > ^^^ +4 > ^^ +5 > ^ +6 > ^^^^^^^^-> +1 >import m1 = require("m1"); + >export var +2 > a1 +3 > = +4 > 10 +5 > ; +1 >Emitted(16, 5) Source(2, 12) + SourceIndex(1) +2 >Emitted(16, 15) Source(2, 14) + SourceIndex(1) +3 >Emitted(16, 18) Source(2, 17) + SourceIndex(1) +4 >Emitted(16, 20) Source(2, 19) + SourceIndex(1) +5 >Emitted(16, 21) Source(2, 20) + SourceIndex(1) +--- +>>> var c1 = (function () { +1->^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^-> +1-> + > +1->Emitted(17, 5) Source(3, 1) + SourceIndex(1) +--- +>>> function c1() { +1->^^^^^^^^ +2 > ^^-> +1-> +1->Emitted(18, 9) Source(3, 1) + SourceIndex(1) name (c1) +--- +>>> } +1->^^^^^^^^ +2 > ^ +3 > ^^^^^^^^^^-> +1->export class c1 { + > public p1: number; + > +2 > } +1->Emitted(19, 9) Source(5, 1) + SourceIndex(1) name (c1.constructor) +2 >Emitted(19, 10) Source(5, 2) + SourceIndex(1) name (c1.constructor) +--- +>>> return c1; +1->^^^^^^^^ +2 > ^^^^^^^^^ +1-> +2 > } +1->Emitted(20, 9) Source(5, 1) + SourceIndex(1) name (c1) +2 >Emitted(20, 18) Source(5, 2) + SourceIndex(1) name (c1) +--- +>>> })(); +1 >^^^^ +2 > ^ +3 > +4 > ^^^^ +5 > ^^^^^^^^^^^^-> +1 > +2 > } +3 > +4 > export class c1 { + > public p1: number; + > } +1 >Emitted(21, 5) Source(5, 1) + SourceIndex(1) name (c1) +2 >Emitted(21, 6) Source(5, 2) + SourceIndex(1) name (c1) +3 >Emitted(21, 6) Source(3, 1) + SourceIndex(1) +4 >Emitted(21, 10) Source(5, 2) + SourceIndex(1) +--- +>>> exports.c1 = c1; +1->^^^^ +2 > ^^^^^^^^^^ +3 > ^^^^^ +4 > ^ +5 > ^^^^^^^^^^^^^^-> +1-> +2 > c1 +3 > { + > public p1: number; + > } +4 > +1->Emitted(22, 5) Source(3, 14) + SourceIndex(1) +2 >Emitted(22, 15) Source(3, 16) + SourceIndex(1) +3 >Emitted(22, 20) Source(5, 2) + SourceIndex(1) +4 >Emitted(22, 21) Source(5, 2) + SourceIndex(1) +--- +>>> exports.instance1 = new c1(); +1->^^^^ +2 > ^^^^^^^^^^^^^^^^^ +3 > ^^^ +4 > ^^^^ +5 > ^^ +6 > ^^ +7 > ^ +1-> + > + >export var +2 > instance1 +3 > = +4 > new +5 > c1 +6 > () +7 > ; +1->Emitted(23, 5) Source(7, 12) + SourceIndex(1) +2 >Emitted(23, 22) Source(7, 21) + SourceIndex(1) +3 >Emitted(23, 25) Source(7, 24) + SourceIndex(1) +4 >Emitted(23, 29) Source(7, 28) + SourceIndex(1) +5 >Emitted(23, 31) Source(7, 30) + SourceIndex(1) +6 >Emitted(23, 33) Source(7, 32) + SourceIndex(1) +7 >Emitted(23, 34) Source(7, 33) + SourceIndex(1) +--- +>>> function f1() { +1 >^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +1 > + > +1 >Emitted(24, 5) Source(8, 1) + SourceIndex(1) +--- +>>> return exports.instance1; +1->^^^^^^^^ +2 > ^^^^^^ +3 > ^ +4 > ^^^^^^^^^^^^^^^^^ +5 > ^ +1->export function f1() { + > +2 > return +3 > +4 > instance1 +5 > ; +1->Emitted(25, 9) Source(9, 5) + SourceIndex(1) name (f1) +2 >Emitted(25, 15) Source(9, 11) + SourceIndex(1) name (f1) +3 >Emitted(25, 16) Source(9, 12) + SourceIndex(1) name (f1) +4 >Emitted(25, 33) Source(9, 21) + SourceIndex(1) name (f1) +5 >Emitted(25, 34) Source(9, 22) + SourceIndex(1) name (f1) +--- +>>> } +1 >^^^^ +2 > ^ +3 > ^^^^^^^^^^^^^^^^-> +1 > + > +2 > } +1 >Emitted(26, 5) Source(10, 1) + SourceIndex(1) name (f1) +2 >Emitted(26, 6) Source(10, 2) + SourceIndex(1) name (f1) +--- +>>> exports.f1 = f1; +1->^^^^ +2 > ^^^^^^^^^^ +3 > ^^^^^ +4 > ^ +5 > ^^^^^^^-> +1-> +2 > f1 +3 > () { + > return instance1; + > } +4 > +1->Emitted(27, 5) Source(8, 17) + SourceIndex(1) +2 >Emitted(27, 15) Source(8, 19) + SourceIndex(1) +3 >Emitted(27, 20) Source(10, 2) + SourceIndex(1) +4 >Emitted(27, 21) Source(10, 2) + SourceIndex(1) +--- +>>> exports.a2 = m1.m1_c1; +1->^^^^ +2 > ^^^^^^^^^^ +3 > ^^^ +4 > ^^ +5 > ^ +6 > ^^^^^ +7 > ^ +1-> + > + >export var +2 > a2 +3 > = +4 > m1 +5 > . +6 > m1_c1 +7 > ; +1->Emitted(28, 5) Source(12, 12) + SourceIndex(1) +2 >Emitted(28, 15) Source(12, 14) + SourceIndex(1) +3 >Emitted(28, 18) Source(12, 17) + SourceIndex(1) +4 >Emitted(28, 20) Source(12, 19) + SourceIndex(1) +5 >Emitted(28, 21) Source(12, 20) + SourceIndex(1) +6 >Emitted(28, 26) Source(12, 25) + SourceIndex(1) +7 >Emitted(28, 27) Source(12, 26) + SourceIndex(1) +--- +>>>}); >>>//# sourceMappingURL=../../mapFiles/test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootRelativePathModuleSimpleSpecifyOutputFile/node/bin/test.d.ts b/tests/baselines/reference/project/mapRootRelativePathModuleSimpleSpecifyOutputFile/node/bin/test.d.ts deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/tests/baselines/reference/project/mapRootRelativePathModuleSimpleSpecifyOutputFile/node/bin/test.js b/tests/baselines/reference/project/mapRootRelativePathModuleSimpleSpecifyOutputFile/node/bin/test.js deleted file mode 100644 index 58e831a041d..00000000000 --- a/tests/baselines/reference/project/mapRootRelativePathModuleSimpleSpecifyOutputFile/node/bin/test.js +++ /dev/null @@ -1 +0,0 @@ -//# sourceMappingURL=../../mapFiles/test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootRelativePathModuleSimpleSpecifyOutputFile/node/bin/test.js.map b/tests/baselines/reference/project/mapRootRelativePathModuleSimpleSpecifyOutputFile/node/bin/test.js.map index c1e0281a2ab..847236565f8 100644 --- a/tests/baselines/reference/project/mapRootRelativePathModuleSimpleSpecifyOutputFile/node/bin/test.js.map +++ b/tests/baselines/reference/project/mapRootRelativePathModuleSimpleSpecifyOutputFile/node/bin/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"","sources":[],"names":[],"mappings":""} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"","sources":["../outputdir_module_simple/m1.ts","../outputdir_module_simple/test.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootRelativePathModuleSimpleSpecifyOutputFile/node/mapRootRelativePathModuleSimpleSpecifyOutputFile.sourcemap.txt b/tests/baselines/reference/project/mapRootRelativePathModuleSimpleSpecifyOutputFile/node/mapRootRelativePathModuleSimpleSpecifyOutputFile.sourcemap.txt index 0af20dc5ef9..ffc11c547d2 100644 --- a/tests/baselines/reference/project/mapRootRelativePathModuleSimpleSpecifyOutputFile/node/mapRootRelativePathModuleSimpleSpecifyOutputFile.sourcemap.txt +++ b/tests/baselines/reference/project/mapRootRelativePathModuleSimpleSpecifyOutputFile/node/mapRootRelativePathModuleSimpleSpecifyOutputFile.sourcemap.txt @@ -394,6 +394,6 @@ sourceFile:../outputdir_module_simple/test.ts JsFile: test.js mapUrl: ../../mapFiles/test.js.map sourceRoot: -sources: +sources: ../outputdir_module_simple/m1.ts,../outputdir_module_simple/test.ts =================================================================== >>>//# sourceMappingURL=../../mapFiles/test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootRelativePathModuleSubfolderSpecifyOutputFile/amd/bin/test.d.ts b/tests/baselines/reference/project/mapRootRelativePathModuleSubfolderSpecifyOutputFile/amd/bin/test.d.ts deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/tests/baselines/reference/project/mapRootRelativePathModuleSubfolderSpecifyOutputFile/amd/bin/test.js b/tests/baselines/reference/project/mapRootRelativePathModuleSubfolderSpecifyOutputFile/amd/bin/test.js deleted file mode 100644 index 58e831a041d..00000000000 --- a/tests/baselines/reference/project/mapRootRelativePathModuleSubfolderSpecifyOutputFile/amd/bin/test.js +++ /dev/null @@ -1 +0,0 @@ -//# sourceMappingURL=../../mapFiles/test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootRelativePathModuleSubfolderSpecifyOutputFile/amd/bin/test.js.map b/tests/baselines/reference/project/mapRootRelativePathModuleSubfolderSpecifyOutputFile/amd/bin/test.js.map index c1e0281a2ab..ae6d9b42221 100644 --- a/tests/baselines/reference/project/mapRootRelativePathModuleSubfolderSpecifyOutputFile/amd/bin/test.js.map +++ b/tests/baselines/reference/project/mapRootRelativePathModuleSubfolderSpecifyOutputFile/amd/bin/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"","sources":[],"names":[],"mappings":""} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"","sources":["../outputdir_module_subfolder/ref/m1.ts","../outputdir_module_subfolder/test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","c1","c1.constructor","f1"],"mappings":";IAAW,aAAK,GAAG,EAAE,CAAC;IACtB;QAAAA;QAEAC,CAACA;QAADD,YAACA;IAADA,CAACA,AAFD,IAEC;IAFY,aAAK,QAEjB,CAAA;IAEU,oBAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACIE,MAAMA,CAACA,oBAAYA,CAACA;IACxBA,CAACA;IAFe,aAAK,QAEpB,CAAA;;;ICPU,UAAE,GAAG,EAAE,CAAC;IACnB;QAAAC;QAEAC,CAACA;QAADD,SAACA;IAADA,CAACA,AAFD,IAEC;IAFY,UAAE,KAEd,CAAA;IAEU,iBAAS,GAAG,IAAI,EAAE,EAAE,CAAC;IAChC;QACIE,MAAMA,CAACA,iBAASA,CAACA;IACrBA,CAACA;IAFe,UAAE,KAEjB,CAAA;IAEU,UAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootRelativePathModuleSubfolderSpecifyOutputFile/amd/mapRootRelativePathModuleSubfolderSpecifyOutputFile.sourcemap.txt b/tests/baselines/reference/project/mapRootRelativePathModuleSubfolderSpecifyOutputFile/amd/mapRootRelativePathModuleSubfolderSpecifyOutputFile.sourcemap.txt index fe747e98d9c..25e76457d53 100644 --- a/tests/baselines/reference/project/mapRootRelativePathModuleSubfolderSpecifyOutputFile/amd/mapRootRelativePathModuleSubfolderSpecifyOutputFile.sourcemap.txt +++ b/tests/baselines/reference/project/mapRootRelativePathModuleSubfolderSpecifyOutputFile/amd/mapRootRelativePathModuleSubfolderSpecifyOutputFile.sourcemap.txt @@ -373,6 +373,365 @@ sourceFile:../outputdir_module_subfolder/test.ts JsFile: test.js mapUrl: ../../mapFiles/test.js.map sourceRoot: -sources: +sources: ../outputdir_module_subfolder/ref/m1.ts,../outputdir_module_subfolder/test.ts =================================================================== +------------------------------------------------------------------- +emittedFile:bin/test.js +sourceFile:../outputdir_module_subfolder/ref/m1.ts +------------------------------------------------------------------- +>>>define("ref/m1", ["require", "exports"], function (require, exports) { +>>> exports.m1_a1 = 10; +1 >^^^^ +2 > ^^^^^^^^^^^^^ +3 > ^^^ +4 > ^^ +5 > ^ +6 > ^^^^^^^^-> +1 >export var +2 > m1_a1 +3 > = +4 > 10 +5 > ; +1 >Emitted(2, 5) Source(1, 12) + SourceIndex(0) +2 >Emitted(2, 18) Source(1, 17) + SourceIndex(0) +3 >Emitted(2, 21) Source(1, 20) + SourceIndex(0) +4 >Emitted(2, 23) Source(1, 22) + SourceIndex(0) +5 >Emitted(2, 24) Source(1, 23) + SourceIndex(0) +--- +>>> var m1_c1 = (function () { +1->^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^^^^-> +1-> + > +1->Emitted(3, 5) Source(2, 1) + SourceIndex(0) +--- +>>> function m1_c1() { +1->^^^^^^^^ +2 > ^^-> +1-> +1->Emitted(4, 9) Source(2, 1) + SourceIndex(0) name (m1_c1) +--- +>>> } +1->^^^^^^^^ +2 > ^ +3 > ^^^^^^^^^^^^^-> +1->export class m1_c1 { + > public m1_c1_p1: number; + > +2 > } +1->Emitted(5, 9) Source(4, 1) + SourceIndex(0) name (m1_c1.constructor) +2 >Emitted(5, 10) Source(4, 2) + SourceIndex(0) name (m1_c1.constructor) +--- +>>> return m1_c1; +1->^^^^^^^^ +2 > ^^^^^^^^^^^^ +1-> +2 > } +1->Emitted(6, 9) Source(4, 1) + SourceIndex(0) name (m1_c1) +2 >Emitted(6, 21) Source(4, 2) + SourceIndex(0) name (m1_c1) +--- +>>> })(); +1 >^^^^ +2 > ^ +3 > +4 > ^^^^ +5 > ^^^^^^^^^^^^^^^^^^-> +1 > +2 > } +3 > +4 > export class m1_c1 { + > public m1_c1_p1: number; + > } +1 >Emitted(7, 5) Source(4, 1) + SourceIndex(0) name (m1_c1) +2 >Emitted(7, 6) Source(4, 2) + SourceIndex(0) name (m1_c1) +3 >Emitted(7, 6) Source(2, 1) + SourceIndex(0) +4 >Emitted(7, 10) Source(4, 2) + SourceIndex(0) +--- +>>> exports.m1_c1 = m1_c1; +1->^^^^ +2 > ^^^^^^^^^^^^^ +3 > ^^^^^^^^ +4 > ^ +5 > ^^^^^^^^^^^^^^-> +1-> +2 > m1_c1 +3 > { + > public m1_c1_p1: number; + > } +4 > +1->Emitted(8, 5) Source(2, 14) + SourceIndex(0) +2 >Emitted(8, 18) Source(2, 19) + SourceIndex(0) +3 >Emitted(8, 26) Source(4, 2) + SourceIndex(0) +4 >Emitted(8, 27) Source(4, 2) + SourceIndex(0) +--- +>>> exports.m1_instance1 = new m1_c1(); +1->^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^ +3 > ^^^ +4 > ^^^^ +5 > ^^^^^ +6 > ^^ +7 > ^ +1-> + > + >export var +2 > m1_instance1 +3 > = +4 > new +5 > m1_c1 +6 > () +7 > ; +1->Emitted(9, 5) Source(6, 12) + SourceIndex(0) +2 >Emitted(9, 25) Source(6, 24) + SourceIndex(0) +3 >Emitted(9, 28) Source(6, 27) + SourceIndex(0) +4 >Emitted(9, 32) Source(6, 31) + SourceIndex(0) +5 >Emitted(9, 37) Source(6, 36) + SourceIndex(0) +6 >Emitted(9, 39) Source(6, 38) + SourceIndex(0) +7 >Emitted(9, 40) Source(6, 39) + SourceIndex(0) +--- +>>> function m1_f1() { +1 >^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +1 > + > +1 >Emitted(10, 5) Source(7, 1) + SourceIndex(0) +--- +>>> return exports.m1_instance1; +1->^^^^^^^^ +2 > ^^^^^^ +3 > ^ +4 > ^^^^^^^^^^^^^^^^^^^^ +5 > ^ +1->export function m1_f1() { + > +2 > return +3 > +4 > m1_instance1 +5 > ; +1->Emitted(11, 9) Source(8, 5) + SourceIndex(0) name (m1_f1) +2 >Emitted(11, 15) Source(8, 11) + SourceIndex(0) name (m1_f1) +3 >Emitted(11, 16) Source(8, 12) + SourceIndex(0) name (m1_f1) +4 >Emitted(11, 36) Source(8, 24) + SourceIndex(0) name (m1_f1) +5 >Emitted(11, 37) Source(8, 25) + SourceIndex(0) name (m1_f1) +--- +>>> } +1 >^^^^ +2 > ^ +3 > ^^^^^^^^^^^^^^^^^^^^^^-> +1 > + > +2 > } +1 >Emitted(12, 5) Source(9, 1) + SourceIndex(0) name (m1_f1) +2 >Emitted(12, 6) Source(9, 2) + SourceIndex(0) name (m1_f1) +--- +>>> exports.m1_f1 = m1_f1; +1->^^^^ +2 > ^^^^^^^^^^^^^ +3 > ^^^^^^^^ +4 > ^ +1-> +2 > m1_f1 +3 > () { + > return m1_instance1; + > } +4 > +1->Emitted(13, 5) Source(7, 17) + SourceIndex(0) +2 >Emitted(13, 18) Source(7, 22) + SourceIndex(0) +3 >Emitted(13, 26) Source(9, 2) + SourceIndex(0) +4 >Emitted(13, 27) Source(9, 2) + SourceIndex(0) +--- +------------------------------------------------------------------- +emittedFile:bin/test.js +sourceFile:../outputdir_module_subfolder/test.ts +------------------------------------------------------------------- +>>>}); +>>>define("test", ["require", "exports", "ref/m1"], function (require, exports, m1) { +>>> exports.a1 = 10; +1 >^^^^ +2 > ^^^^^^^^^^ +3 > ^^^ +4 > ^^ +5 > ^ +6 > ^^^^^^^^-> +1 >import m1 = require("ref/m1"); + >export var +2 > a1 +3 > = +4 > 10 +5 > ; +1 >Emitted(16, 5) Source(2, 12) + SourceIndex(1) +2 >Emitted(16, 15) Source(2, 14) + SourceIndex(1) +3 >Emitted(16, 18) Source(2, 17) + SourceIndex(1) +4 >Emitted(16, 20) Source(2, 19) + SourceIndex(1) +5 >Emitted(16, 21) Source(2, 20) + SourceIndex(1) +--- +>>> var c1 = (function () { +1->^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^-> +1-> + > +1->Emitted(17, 5) Source(3, 1) + SourceIndex(1) +--- +>>> function c1() { +1->^^^^^^^^ +2 > ^^-> +1-> +1->Emitted(18, 9) Source(3, 1) + SourceIndex(1) name (c1) +--- +>>> } +1->^^^^^^^^ +2 > ^ +3 > ^^^^^^^^^^-> +1->export class c1 { + > public p1: number; + > +2 > } +1->Emitted(19, 9) Source(5, 1) + SourceIndex(1) name (c1.constructor) +2 >Emitted(19, 10) Source(5, 2) + SourceIndex(1) name (c1.constructor) +--- +>>> return c1; +1->^^^^^^^^ +2 > ^^^^^^^^^ +1-> +2 > } +1->Emitted(20, 9) Source(5, 1) + SourceIndex(1) name (c1) +2 >Emitted(20, 18) Source(5, 2) + SourceIndex(1) name (c1) +--- +>>> })(); +1 >^^^^ +2 > ^ +3 > +4 > ^^^^ +5 > ^^^^^^^^^^^^-> +1 > +2 > } +3 > +4 > export class c1 { + > public p1: number; + > } +1 >Emitted(21, 5) Source(5, 1) + SourceIndex(1) name (c1) +2 >Emitted(21, 6) Source(5, 2) + SourceIndex(1) name (c1) +3 >Emitted(21, 6) Source(3, 1) + SourceIndex(1) +4 >Emitted(21, 10) Source(5, 2) + SourceIndex(1) +--- +>>> exports.c1 = c1; +1->^^^^ +2 > ^^^^^^^^^^ +3 > ^^^^^ +4 > ^ +5 > ^^^^^^^^^^^^^^-> +1-> +2 > c1 +3 > { + > public p1: number; + > } +4 > +1->Emitted(22, 5) Source(3, 14) + SourceIndex(1) +2 >Emitted(22, 15) Source(3, 16) + SourceIndex(1) +3 >Emitted(22, 20) Source(5, 2) + SourceIndex(1) +4 >Emitted(22, 21) Source(5, 2) + SourceIndex(1) +--- +>>> exports.instance1 = new c1(); +1->^^^^ +2 > ^^^^^^^^^^^^^^^^^ +3 > ^^^ +4 > ^^^^ +5 > ^^ +6 > ^^ +7 > ^ +1-> + > + >export var +2 > instance1 +3 > = +4 > new +5 > c1 +6 > () +7 > ; +1->Emitted(23, 5) Source(7, 12) + SourceIndex(1) +2 >Emitted(23, 22) Source(7, 21) + SourceIndex(1) +3 >Emitted(23, 25) Source(7, 24) + SourceIndex(1) +4 >Emitted(23, 29) Source(7, 28) + SourceIndex(1) +5 >Emitted(23, 31) Source(7, 30) + SourceIndex(1) +6 >Emitted(23, 33) Source(7, 32) + SourceIndex(1) +7 >Emitted(23, 34) Source(7, 33) + SourceIndex(1) +--- +>>> function f1() { +1 >^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +1 > + > +1 >Emitted(24, 5) Source(8, 1) + SourceIndex(1) +--- +>>> return exports.instance1; +1->^^^^^^^^ +2 > ^^^^^^ +3 > ^ +4 > ^^^^^^^^^^^^^^^^^ +5 > ^ +1->export function f1() { + > +2 > return +3 > +4 > instance1 +5 > ; +1->Emitted(25, 9) Source(9, 5) + SourceIndex(1) name (f1) +2 >Emitted(25, 15) Source(9, 11) + SourceIndex(1) name (f1) +3 >Emitted(25, 16) Source(9, 12) + SourceIndex(1) name (f1) +4 >Emitted(25, 33) Source(9, 21) + SourceIndex(1) name (f1) +5 >Emitted(25, 34) Source(9, 22) + SourceIndex(1) name (f1) +--- +>>> } +1 >^^^^ +2 > ^ +3 > ^^^^^^^^^^^^^^^^-> +1 > + > +2 > } +1 >Emitted(26, 5) Source(10, 1) + SourceIndex(1) name (f1) +2 >Emitted(26, 6) Source(10, 2) + SourceIndex(1) name (f1) +--- +>>> exports.f1 = f1; +1->^^^^ +2 > ^^^^^^^^^^ +3 > ^^^^^ +4 > ^ +5 > ^^^^^^^-> +1-> +2 > f1 +3 > () { + > return instance1; + > } +4 > +1->Emitted(27, 5) Source(8, 17) + SourceIndex(1) +2 >Emitted(27, 15) Source(8, 19) + SourceIndex(1) +3 >Emitted(27, 20) Source(10, 2) + SourceIndex(1) +4 >Emitted(27, 21) Source(10, 2) + SourceIndex(1) +--- +>>> exports.a2 = m1.m1_c1; +1->^^^^ +2 > ^^^^^^^^^^ +3 > ^^^ +4 > ^^ +5 > ^ +6 > ^^^^^ +7 > ^ +1-> + > + >export var +2 > a2 +3 > = +4 > m1 +5 > . +6 > m1_c1 +7 > ; +1->Emitted(28, 5) Source(12, 12) + SourceIndex(1) +2 >Emitted(28, 15) Source(12, 14) + SourceIndex(1) +3 >Emitted(28, 18) Source(12, 17) + SourceIndex(1) +4 >Emitted(28, 20) Source(12, 19) + SourceIndex(1) +5 >Emitted(28, 21) Source(12, 20) + SourceIndex(1) +6 >Emitted(28, 26) Source(12, 25) + SourceIndex(1) +7 >Emitted(28, 27) Source(12, 26) + SourceIndex(1) +--- +>>>}); >>>//# sourceMappingURL=../../mapFiles/test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootRelativePathModuleSubfolderSpecifyOutputFile/node/bin/test.d.ts b/tests/baselines/reference/project/mapRootRelativePathModuleSubfolderSpecifyOutputFile/node/bin/test.d.ts deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/tests/baselines/reference/project/mapRootRelativePathModuleSubfolderSpecifyOutputFile/node/bin/test.js b/tests/baselines/reference/project/mapRootRelativePathModuleSubfolderSpecifyOutputFile/node/bin/test.js deleted file mode 100644 index 58e831a041d..00000000000 --- a/tests/baselines/reference/project/mapRootRelativePathModuleSubfolderSpecifyOutputFile/node/bin/test.js +++ /dev/null @@ -1 +0,0 @@ -//# sourceMappingURL=../../mapFiles/test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootRelativePathModuleSubfolderSpecifyOutputFile/node/bin/test.js.map b/tests/baselines/reference/project/mapRootRelativePathModuleSubfolderSpecifyOutputFile/node/bin/test.js.map index c1e0281a2ab..b8c7cced3ae 100644 --- a/tests/baselines/reference/project/mapRootRelativePathModuleSubfolderSpecifyOutputFile/node/bin/test.js.map +++ b/tests/baselines/reference/project/mapRootRelativePathModuleSubfolderSpecifyOutputFile/node/bin/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"","sources":[],"names":[],"mappings":""} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"","sources":["../outputdir_module_subfolder/ref/m1.ts","../outputdir_module_subfolder/test.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootRelativePathModuleSubfolderSpecifyOutputFile/node/mapRootRelativePathModuleSubfolderSpecifyOutputFile.sourcemap.txt b/tests/baselines/reference/project/mapRootRelativePathModuleSubfolderSpecifyOutputFile/node/mapRootRelativePathModuleSubfolderSpecifyOutputFile.sourcemap.txt index 8f609cc28d9..4a7d5c7d49f 100644 --- a/tests/baselines/reference/project/mapRootRelativePathModuleSubfolderSpecifyOutputFile/node/mapRootRelativePathModuleSubfolderSpecifyOutputFile.sourcemap.txt +++ b/tests/baselines/reference/project/mapRootRelativePathModuleSubfolderSpecifyOutputFile/node/mapRootRelativePathModuleSubfolderSpecifyOutputFile.sourcemap.txt @@ -394,6 +394,6 @@ sourceFile:../outputdir_module_subfolder/test.ts JsFile: test.js mapUrl: ../../mapFiles/test.js.map sourceRoot: -sources: +sources: ../outputdir_module_subfolder/ref/m1.ts,../outputdir_module_subfolder/test.ts =================================================================== >>>//# sourceMappingURL=../../mapFiles/test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootRelativePathMultifolderSpecifyOutputFile/amd/bin/test.d.ts b/tests/baselines/reference/project/mapRootRelativePathMultifolderSpecifyOutputFile/amd/bin/test.d.ts deleted file mode 100644 index d75277ac607..00000000000 --- a/tests/baselines/reference/project/mapRootRelativePathMultifolderSpecifyOutputFile/amd/bin/test.d.ts +++ /dev/null @@ -1,18 +0,0 @@ -declare var m1_a1: number; -declare class m1_c1 { - m1_c1_p1: number; -} -declare var m1_instance1: m1_c1; -declare function m1_f1(): m1_c1; -declare var m2_a1: number; -declare class m2_c1 { - m2_c1_p1: number; -} -declare var m2_instance1: m2_c1; -declare function m2_f1(): m2_c1; -declare var a1: number; -declare class c1 { - p1: number; -} -declare var instance1: c1; -declare function f1(): c1; diff --git a/tests/baselines/reference/project/mapRootRelativePathMultifolderSpecifyOutputFile/amd/bin/test.js b/tests/baselines/reference/project/mapRootRelativePathMultifolderSpecifyOutputFile/amd/bin/test.js deleted file mode 100644 index 8fafee438e6..00000000000 --- a/tests/baselines/reference/project/mapRootRelativePathMultifolderSpecifyOutputFile/amd/bin/test.js +++ /dev/null @@ -1,33 +0,0 @@ -var m1_a1 = 10; -var m1_c1 = (function () { - function m1_c1() { - } - return m1_c1; -})(); -var m1_instance1 = new m1_c1(); -function m1_f1() { - return m1_instance1; -} -var m2_a1 = 10; -var m2_c1 = (function () { - function m2_c1() { - } - return m2_c1; -})(); -var m2_instance1 = new m2_c1(); -function m2_f1() { - return m2_instance1; -} -/// -/// -var a1 = 10; -var c1 = (function () { - function c1() { - } - return c1; -})(); -var instance1 = new c1(); -function f1() { - return instance1; -} -//# sourceMappingURL=../../mapFiles/test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootRelativePathMultifolderSpecifyOutputFile/amd/bin/test.js.map b/tests/baselines/reference/project/mapRootRelativePathMultifolderSpecifyOutputFile/amd/bin/test.js.map index 03cefb2f8d3..fc3b27ea65c 100644 --- a/tests/baselines/reference/project/mapRootRelativePathMultifolderSpecifyOutputFile/amd/bin/test.js.map +++ b/tests/baselines/reference/project/mapRootRelativePathMultifolderSpecifyOutputFile/amd/bin/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"","sources":["../outputdir_multifolder/ref/m1.ts","../outputdir_multifolder_ref/m2.ts","../outputdir_multifolder/test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","m2_c1","m2_c1.constructor","m2_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACRD,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAC;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACRD,iCAAiC;AACjC,0DAA0D;AAC1D,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"","sources":["../projects/outputdir_multifolder/ref/m1.ts","../projects/outputdir_multifolder_ref/m2.ts","../projects/outputdir_multifolder/test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","m2_c1","m2_c1.constructor","m2_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACRD,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAC;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACRD,iCAAiC;AACjC,0DAA0D;AAC1D,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootRelativePathMultifolderSpecifyOutputFile/amd/mapRootRelativePathMultifolderSpecifyOutputFile.sourcemap.txt b/tests/baselines/reference/project/mapRootRelativePathMultifolderSpecifyOutputFile/amd/mapRootRelativePathMultifolderSpecifyOutputFile.sourcemap.txt index d173bd36fb2..534e9184f7b 100644 --- a/tests/baselines/reference/project/mapRootRelativePathMultifolderSpecifyOutputFile/amd/mapRootRelativePathMultifolderSpecifyOutputFile.sourcemap.txt +++ b/tests/baselines/reference/project/mapRootRelativePathMultifolderSpecifyOutputFile/amd/mapRootRelativePathMultifolderSpecifyOutputFile.sourcemap.txt @@ -1,12 +1,12 @@ =================================================================== JsFile: test.js -mapUrl: ../../mapFiles/test.js.map +mapUrl: ../../../mapFiles/test.js.map sourceRoot: -sources: ../outputdir_multifolder/ref/m1.ts,../outputdir_multifolder_ref/m2.ts,../outputdir_multifolder/test.ts +sources: ../projects/outputdir_multifolder/ref/m1.ts,../projects/outputdir_multifolder_ref/m2.ts,../projects/outputdir_multifolder/test.ts =================================================================== ------------------------------------------------------------------- emittedFile:bin/test.js -sourceFile:../outputdir_multifolder/ref/m1.ts +sourceFile:../projects/outputdir_multifolder/ref/m1.ts ------------------------------------------------------------------- >>>var m1_a1 = 10; 1 > @@ -143,7 +143,7 @@ sourceFile:../outputdir_multifolder/ref/m1.ts --- ------------------------------------------------------------------- emittedFile:bin/test.js -sourceFile:../outputdir_multifolder_ref/m2.ts +sourceFile:../projects/outputdir_multifolder_ref/m2.ts ------------------------------------------------------------------- >>>var m2_a1 = 10; 1-> @@ -280,7 +280,7 @@ sourceFile:../outputdir_multifolder_ref/m2.ts --- ------------------------------------------------------------------- emittedFile:bin/test.js -sourceFile:../outputdir_multifolder/test.ts +sourceFile:../projects/outputdir_multifolder/test.ts ------------------------------------------------------------------- >>>/// 1-> @@ -427,11 +427,11 @@ sourceFile:../outputdir_multifolder/test.ts >>>} 1 > 2 >^ -3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> 1 > > 2 >} 1 >Emitted(32, 1) Source(11, 1) + SourceIndex(2) name (f1) 2 >Emitted(32, 2) Source(11, 2) + SourceIndex(2) name (f1) --- ->>>//# sourceMappingURL=../../mapFiles/test.js.map \ No newline at end of file +>>>//# sourceMappingURL=../../../mapFiles/test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootRelativePathMultifolderSpecifyOutputFile/node/bin/test.d.ts b/tests/baselines/reference/project/mapRootRelativePathMultifolderSpecifyOutputFile/node/bin/test.d.ts deleted file mode 100644 index d75277ac607..00000000000 --- a/tests/baselines/reference/project/mapRootRelativePathMultifolderSpecifyOutputFile/node/bin/test.d.ts +++ /dev/null @@ -1,18 +0,0 @@ -declare var m1_a1: number; -declare class m1_c1 { - m1_c1_p1: number; -} -declare var m1_instance1: m1_c1; -declare function m1_f1(): m1_c1; -declare var m2_a1: number; -declare class m2_c1 { - m2_c1_p1: number; -} -declare var m2_instance1: m2_c1; -declare function m2_f1(): m2_c1; -declare var a1: number; -declare class c1 { - p1: number; -} -declare var instance1: c1; -declare function f1(): c1; diff --git a/tests/baselines/reference/project/mapRootRelativePathMultifolderSpecifyOutputFile/node/bin/test.js b/tests/baselines/reference/project/mapRootRelativePathMultifolderSpecifyOutputFile/node/bin/test.js deleted file mode 100644 index 8fafee438e6..00000000000 --- a/tests/baselines/reference/project/mapRootRelativePathMultifolderSpecifyOutputFile/node/bin/test.js +++ /dev/null @@ -1,33 +0,0 @@ -var m1_a1 = 10; -var m1_c1 = (function () { - function m1_c1() { - } - return m1_c1; -})(); -var m1_instance1 = new m1_c1(); -function m1_f1() { - return m1_instance1; -} -var m2_a1 = 10; -var m2_c1 = (function () { - function m2_c1() { - } - return m2_c1; -})(); -var m2_instance1 = new m2_c1(); -function m2_f1() { - return m2_instance1; -} -/// -/// -var a1 = 10; -var c1 = (function () { - function c1() { - } - return c1; -})(); -var instance1 = new c1(); -function f1() { - return instance1; -} -//# sourceMappingURL=../../mapFiles/test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootRelativePathMultifolderSpecifyOutputFile/node/bin/test.js.map b/tests/baselines/reference/project/mapRootRelativePathMultifolderSpecifyOutputFile/node/bin/test.js.map index 03cefb2f8d3..fc3b27ea65c 100644 --- a/tests/baselines/reference/project/mapRootRelativePathMultifolderSpecifyOutputFile/node/bin/test.js.map +++ b/tests/baselines/reference/project/mapRootRelativePathMultifolderSpecifyOutputFile/node/bin/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"","sources":["../outputdir_multifolder/ref/m1.ts","../outputdir_multifolder_ref/m2.ts","../outputdir_multifolder/test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","m2_c1","m2_c1.constructor","m2_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACRD,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAC;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACRD,iCAAiC;AACjC,0DAA0D;AAC1D,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"","sources":["../projects/outputdir_multifolder/ref/m1.ts","../projects/outputdir_multifolder_ref/m2.ts","../projects/outputdir_multifolder/test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","m2_c1","m2_c1.constructor","m2_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACRD,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAC;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACRD,iCAAiC;AACjC,0DAA0D;AAC1D,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootRelativePathMultifolderSpecifyOutputFile/node/mapRootRelativePathMultifolderSpecifyOutputFile.sourcemap.txt b/tests/baselines/reference/project/mapRootRelativePathMultifolderSpecifyOutputFile/node/mapRootRelativePathMultifolderSpecifyOutputFile.sourcemap.txt index d173bd36fb2..534e9184f7b 100644 --- a/tests/baselines/reference/project/mapRootRelativePathMultifolderSpecifyOutputFile/node/mapRootRelativePathMultifolderSpecifyOutputFile.sourcemap.txt +++ b/tests/baselines/reference/project/mapRootRelativePathMultifolderSpecifyOutputFile/node/mapRootRelativePathMultifolderSpecifyOutputFile.sourcemap.txt @@ -1,12 +1,12 @@ =================================================================== JsFile: test.js -mapUrl: ../../mapFiles/test.js.map +mapUrl: ../../../mapFiles/test.js.map sourceRoot: -sources: ../outputdir_multifolder/ref/m1.ts,../outputdir_multifolder_ref/m2.ts,../outputdir_multifolder/test.ts +sources: ../projects/outputdir_multifolder/ref/m1.ts,../projects/outputdir_multifolder_ref/m2.ts,../projects/outputdir_multifolder/test.ts =================================================================== ------------------------------------------------------------------- emittedFile:bin/test.js -sourceFile:../outputdir_multifolder/ref/m1.ts +sourceFile:../projects/outputdir_multifolder/ref/m1.ts ------------------------------------------------------------------- >>>var m1_a1 = 10; 1 > @@ -143,7 +143,7 @@ sourceFile:../outputdir_multifolder/ref/m1.ts --- ------------------------------------------------------------------- emittedFile:bin/test.js -sourceFile:../outputdir_multifolder_ref/m2.ts +sourceFile:../projects/outputdir_multifolder_ref/m2.ts ------------------------------------------------------------------- >>>var m2_a1 = 10; 1-> @@ -280,7 +280,7 @@ sourceFile:../outputdir_multifolder_ref/m2.ts --- ------------------------------------------------------------------- emittedFile:bin/test.js -sourceFile:../outputdir_multifolder/test.ts +sourceFile:../projects/outputdir_multifolder/test.ts ------------------------------------------------------------------- >>>/// 1-> @@ -427,11 +427,11 @@ sourceFile:../outputdir_multifolder/test.ts >>>} 1 > 2 >^ -3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> 1 > > 2 >} 1 >Emitted(32, 1) Source(11, 1) + SourceIndex(2) name (f1) 2 >Emitted(32, 2) Source(11, 2) + SourceIndex(2) name (f1) --- ->>>//# sourceMappingURL=../../mapFiles/test.js.map \ No newline at end of file +>>>//# sourceMappingURL=../../../mapFiles/test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFile/amd/bin/test.d.ts b/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFile/amd/bin/test.d.ts deleted file mode 100644 index d61b4c3b876..00000000000 --- a/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFile/amd/bin/test.d.ts +++ /dev/null @@ -1,13 +0,0 @@ -/// -declare var m1_a1: number; -declare class m1_c1 { - m1_c1_p1: number; -} -declare var m1_instance1: m1_c1; -declare function m1_f1(): m1_c1; -declare var a1: number; -declare class c1 { - p1: number; -} -declare var instance1: c1; -declare function f1(): c1; diff --git a/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFile/amd/bin/test.js b/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFile/amd/bin/test.js deleted file mode 100644 index af0071d7e46..00000000000 --- a/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFile/amd/bin/test.js +++ /dev/null @@ -1,23 +0,0 @@ -var m1_a1 = 10; -var m1_c1 = (function () { - function m1_c1() { - } - return m1_c1; -})(); -var m1_instance1 = new m1_c1(); -function m1_f1() { - return m1_instance1; -} -/// -/// -var a1 = 10; -var c1 = (function () { - function c1() { - } - return c1; -})(); -var instance1 = new c1(); -function f1() { - return instance1; -} -//# sourceMappingURL=http://www.typescriptlang.org/test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFile/amd/bin/test.js.map b/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFile/amd/bin/test.js.map index df57785d945..c6996bb53b9 100644 --- a/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFile/amd/bin/test.js.map +++ b/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFile/amd/bin/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"","sources":["file:///tests/cases/projects/outputdir_mixed_subfolder/ref/m1.ts","file:///tests/cases/projects/outputdir_mixed_subfolder/test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACRD,iCAAiC;AACjC,iCAAiC;AACjC,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"","sources":["file:///tests/cases/projects/outputdir_mixed_subfolder/ref/m1.ts","file:///tests/cases/projects/outputdir_mixed_subfolder/ref/m2.ts","file:///tests/cases/projects/outputdir_mixed_subfolder/test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","m2_c1","m2_c1.constructor","m2_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;;ICRU,aAAK,GAAG,EAAE,CAAC;IACtB;QAAAC;QAEAC,CAACA;QAADD,YAACA;IAADA,CAACA,AAFD,IAEC;IAFY,aAAK,QAEjB,CAAA;IAEU,oBAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACIE,MAAMA,CAACA,oBAAYA,CAACA;IACxBA,CAACA;IAFe,aAAK,QAEpB,CAAA;;ACRD,iCAAiC;AACjC,iCAAiC;AACjC,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFile/amd/maprootUrlMixedSubfolderSpecifyOutputFile.sourcemap.txt b/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFile/amd/maprootUrlMixedSubfolderSpecifyOutputFile.sourcemap.txt index 0c806666ef0..bd84417baa2 100644 --- a/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFile/amd/maprootUrlMixedSubfolderSpecifyOutputFile.sourcemap.txt +++ b/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFile/amd/maprootUrlMixedSubfolderSpecifyOutputFile.sourcemap.txt @@ -174,7 +174,7 @@ sourceFile:file:///tests/cases/projects/outputdir_mixed_subfolder/ref/m2.ts JsFile: test.js mapUrl: http://www.typescriptlang.org/test.js.map sourceRoot: -sources: file:///tests/cases/projects/outputdir_mixed_subfolder/ref/m1.ts,file:///tests/cases/projects/outputdir_mixed_subfolder/test.ts +sources: file:///tests/cases/projects/outputdir_mixed_subfolder/ref/m1.ts,file:///tests/cases/projects/outputdir_mixed_subfolder/ref/m2.ts,file:///tests/cases/projects/outputdir_mixed_subfolder/test.ts =================================================================== ------------------------------------------------------------------- emittedFile:bin/test.js @@ -306,7 +306,7 @@ sourceFile:file:///tests/cases/projects/outputdir_mixed_subfolder/ref/m1.ts >>>} 1 > 2 >^ -3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> 1 > > 2 >} @@ -315,16 +315,182 @@ sourceFile:file:///tests/cases/projects/outputdir_mixed_subfolder/ref/m1.ts --- ------------------------------------------------------------------- emittedFile:bin/test.js +sourceFile:file:///tests/cases/projects/outputdir_mixed_subfolder/ref/m2.ts +------------------------------------------------------------------- +>>>define("ref/m2", ["require", "exports"], function (require, exports) { +>>> exports.m2_a1 = 10; +1->^^^^ +2 > ^^^^^^^^^^^^^ +3 > ^^^ +4 > ^^ +5 > ^ +6 > ^^^^^^^^-> +1->export var +2 > m2_a1 +3 > = +4 > 10 +5 > ; +1->Emitted(12, 5) Source(1, 12) + SourceIndex(1) +2 >Emitted(12, 18) Source(1, 17) + SourceIndex(1) +3 >Emitted(12, 21) Source(1, 20) + SourceIndex(1) +4 >Emitted(12, 23) Source(1, 22) + SourceIndex(1) +5 >Emitted(12, 24) Source(1, 23) + SourceIndex(1) +--- +>>> var m2_c1 = (function () { +1->^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^^^^-> +1-> + > +1->Emitted(13, 5) Source(2, 1) + SourceIndex(1) +--- +>>> function m2_c1() { +1->^^^^^^^^ +2 > ^^-> +1-> +1->Emitted(14, 9) Source(2, 1) + SourceIndex(1) name (m2_c1) +--- +>>> } +1->^^^^^^^^ +2 > ^ +3 > ^^^^^^^^^^^^^-> +1->export class m2_c1 { + > public m2_c1_p1: number; + > +2 > } +1->Emitted(15, 9) Source(4, 1) + SourceIndex(1) name (m2_c1.constructor) +2 >Emitted(15, 10) Source(4, 2) + SourceIndex(1) name (m2_c1.constructor) +--- +>>> return m2_c1; +1->^^^^^^^^ +2 > ^^^^^^^^^^^^ +1-> +2 > } +1->Emitted(16, 9) Source(4, 1) + SourceIndex(1) name (m2_c1) +2 >Emitted(16, 21) Source(4, 2) + SourceIndex(1) name (m2_c1) +--- +>>> })(); +1 >^^^^ +2 > ^ +3 > +4 > ^^^^ +5 > ^^^^^^^^^^^^^^^^^^-> +1 > +2 > } +3 > +4 > export class m2_c1 { + > public m2_c1_p1: number; + > } +1 >Emitted(17, 5) Source(4, 1) + SourceIndex(1) name (m2_c1) +2 >Emitted(17, 6) Source(4, 2) + SourceIndex(1) name (m2_c1) +3 >Emitted(17, 6) Source(2, 1) + SourceIndex(1) +4 >Emitted(17, 10) Source(4, 2) + SourceIndex(1) +--- +>>> exports.m2_c1 = m2_c1; +1->^^^^ +2 > ^^^^^^^^^^^^^ +3 > ^^^^^^^^ +4 > ^ +5 > ^^^^^^^^^^^^^^-> +1-> +2 > m2_c1 +3 > { + > public m2_c1_p1: number; + > } +4 > +1->Emitted(18, 5) Source(2, 14) + SourceIndex(1) +2 >Emitted(18, 18) Source(2, 19) + SourceIndex(1) +3 >Emitted(18, 26) Source(4, 2) + SourceIndex(1) +4 >Emitted(18, 27) Source(4, 2) + SourceIndex(1) +--- +>>> exports.m2_instance1 = new m2_c1(); +1->^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^ +3 > ^^^ +4 > ^^^^ +5 > ^^^^^ +6 > ^^ +7 > ^ +1-> + > + >export var +2 > m2_instance1 +3 > = +4 > new +5 > m2_c1 +6 > () +7 > ; +1->Emitted(19, 5) Source(6, 12) + SourceIndex(1) +2 >Emitted(19, 25) Source(6, 24) + SourceIndex(1) +3 >Emitted(19, 28) Source(6, 27) + SourceIndex(1) +4 >Emitted(19, 32) Source(6, 31) + SourceIndex(1) +5 >Emitted(19, 37) Source(6, 36) + SourceIndex(1) +6 >Emitted(19, 39) Source(6, 38) + SourceIndex(1) +7 >Emitted(19, 40) Source(6, 39) + SourceIndex(1) +--- +>>> function m2_f1() { +1 >^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +1 > + > +1 >Emitted(20, 5) Source(7, 1) + SourceIndex(1) +--- +>>> return exports.m2_instance1; +1->^^^^^^^^ +2 > ^^^^^^ +3 > ^ +4 > ^^^^^^^^^^^^^^^^^^^^ +5 > ^ +1->export function m2_f1() { + > +2 > return +3 > +4 > m2_instance1 +5 > ; +1->Emitted(21, 9) Source(8, 5) + SourceIndex(1) name (m2_f1) +2 >Emitted(21, 15) Source(8, 11) + SourceIndex(1) name (m2_f1) +3 >Emitted(21, 16) Source(8, 12) + SourceIndex(1) name (m2_f1) +4 >Emitted(21, 36) Source(8, 24) + SourceIndex(1) name (m2_f1) +5 >Emitted(21, 37) Source(8, 25) + SourceIndex(1) name (m2_f1) +--- +>>> } +1 >^^^^ +2 > ^ +3 > ^^^^^^^^^^^^^^^^^^^^^^-> +1 > + > +2 > } +1 >Emitted(22, 5) Source(9, 1) + SourceIndex(1) name (m2_f1) +2 >Emitted(22, 6) Source(9, 2) + SourceIndex(1) name (m2_f1) +--- +>>> exports.m2_f1 = m2_f1; +1->^^^^ +2 > ^^^^^^^^^^^^^ +3 > ^^^^^^^^ +4 > ^ +1-> +2 > m2_f1 +3 > () { + > return m2_instance1; + > } +4 > +1->Emitted(23, 5) Source(7, 17) + SourceIndex(1) +2 >Emitted(23, 18) Source(7, 22) + SourceIndex(1) +3 >Emitted(23, 26) Source(9, 2) + SourceIndex(1) +4 >Emitted(23, 27) Source(9, 2) + SourceIndex(1) +--- +------------------------------------------------------------------- +emittedFile:bin/test.js sourceFile:file:///tests/cases/projects/outputdir_mixed_subfolder/test.ts ------------------------------------------------------------------- +>>>}); >>>/// -1-> +1 > 2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 3 > ^-> -1-> +1 > 2 >/// -1->Emitted(11, 1) Source(1, 1) + SourceIndex(1) -2 >Emitted(11, 34) Source(1, 34) + SourceIndex(1) +1 >Emitted(25, 1) Source(1, 1) + SourceIndex(2) +2 >Emitted(25, 34) Source(1, 34) + SourceIndex(2) --- >>>/// 1-> @@ -332,8 +498,8 @@ sourceFile:file:///tests/cases/projects/outputdir_mixed_subfolder/test.ts 1-> > 2 >/// -1->Emitted(12, 1) Source(2, 1) + SourceIndex(1) -2 >Emitted(12, 34) Source(2, 34) + SourceIndex(1) +1->Emitted(26, 1) Source(2, 1) + SourceIndex(2) +2 >Emitted(26, 34) Source(2, 34) + SourceIndex(2) --- >>>var a1 = 10; 1 > @@ -350,25 +516,25 @@ sourceFile:file:///tests/cases/projects/outputdir_mixed_subfolder/test.ts 4 > = 5 > 10 6 > ; -1 >Emitted(13, 1) Source(3, 1) + SourceIndex(1) -2 >Emitted(13, 5) Source(3, 5) + SourceIndex(1) -3 >Emitted(13, 7) Source(3, 7) + SourceIndex(1) -4 >Emitted(13, 10) Source(3, 10) + SourceIndex(1) -5 >Emitted(13, 12) Source(3, 12) + SourceIndex(1) -6 >Emitted(13, 13) Source(3, 13) + SourceIndex(1) +1 >Emitted(27, 1) Source(3, 1) + SourceIndex(2) +2 >Emitted(27, 5) Source(3, 5) + SourceIndex(2) +3 >Emitted(27, 7) Source(3, 7) + SourceIndex(2) +4 >Emitted(27, 10) Source(3, 10) + SourceIndex(2) +5 >Emitted(27, 12) Source(3, 12) + SourceIndex(2) +6 >Emitted(27, 13) Source(3, 13) + SourceIndex(2) --- >>>var c1 = (function () { 1-> 2 >^^^^^^^^^^^^^^^^^^^^-> 1-> > -1->Emitted(14, 1) Source(4, 1) + SourceIndex(1) +1->Emitted(28, 1) Source(4, 1) + SourceIndex(2) --- >>> function c1() { 1->^^^^ 2 > ^^-> 1-> -1->Emitted(15, 5) Source(4, 1) + SourceIndex(1) name (c1) +1->Emitted(29, 5) Source(4, 1) + SourceIndex(2) name (c1) --- >>> } 1->^^^^ @@ -378,16 +544,16 @@ sourceFile:file:///tests/cases/projects/outputdir_mixed_subfolder/test.ts > public p1: number; > 2 > } -1->Emitted(16, 5) Source(6, 1) + SourceIndex(1) name (c1.constructor) -2 >Emitted(16, 6) Source(6, 2) + SourceIndex(1) name (c1.constructor) +1->Emitted(30, 5) Source(6, 1) + SourceIndex(2) name (c1.constructor) +2 >Emitted(30, 6) Source(6, 2) + SourceIndex(2) name (c1.constructor) --- >>> return c1; 1->^^^^ 2 > ^^^^^^^^^ 1-> 2 > } -1->Emitted(17, 5) Source(6, 1) + SourceIndex(1) name (c1) -2 >Emitted(17, 14) Source(6, 2) + SourceIndex(1) name (c1) +1->Emitted(31, 5) Source(6, 1) + SourceIndex(2) name (c1) +2 >Emitted(31, 14) Source(6, 2) + SourceIndex(2) name (c1) --- >>>})(); 1 > @@ -401,10 +567,10 @@ sourceFile:file:///tests/cases/projects/outputdir_mixed_subfolder/test.ts 4 > class c1 { > public p1: number; > } -1 >Emitted(18, 1) Source(6, 1) + SourceIndex(1) name (c1) -2 >Emitted(18, 2) Source(6, 2) + SourceIndex(1) name (c1) -3 >Emitted(18, 2) Source(4, 1) + SourceIndex(1) -4 >Emitted(18, 6) Source(6, 2) + SourceIndex(1) +1 >Emitted(32, 1) Source(6, 1) + SourceIndex(2) name (c1) +2 >Emitted(32, 2) Source(6, 2) + SourceIndex(2) name (c1) +3 >Emitted(32, 2) Source(4, 1) + SourceIndex(2) +4 >Emitted(32, 6) Source(6, 2) + SourceIndex(2) --- >>>var instance1 = new c1(); 1-> @@ -425,21 +591,21 @@ sourceFile:file:///tests/cases/projects/outputdir_mixed_subfolder/test.ts 6 > c1 7 > () 8 > ; -1->Emitted(19, 1) Source(8, 1) + SourceIndex(1) -2 >Emitted(19, 5) Source(8, 5) + SourceIndex(1) -3 >Emitted(19, 14) Source(8, 14) + SourceIndex(1) -4 >Emitted(19, 17) Source(8, 17) + SourceIndex(1) -5 >Emitted(19, 21) Source(8, 21) + SourceIndex(1) -6 >Emitted(19, 23) Source(8, 23) + SourceIndex(1) -7 >Emitted(19, 25) Source(8, 25) + SourceIndex(1) -8 >Emitted(19, 26) Source(8, 26) + SourceIndex(1) +1->Emitted(33, 1) Source(8, 1) + SourceIndex(2) +2 >Emitted(33, 5) Source(8, 5) + SourceIndex(2) +3 >Emitted(33, 14) Source(8, 14) + SourceIndex(2) +4 >Emitted(33, 17) Source(8, 17) + SourceIndex(2) +5 >Emitted(33, 21) Source(8, 21) + SourceIndex(2) +6 >Emitted(33, 23) Source(8, 23) + SourceIndex(2) +7 >Emitted(33, 25) Source(8, 25) + SourceIndex(2) +8 >Emitted(33, 26) Source(8, 26) + SourceIndex(2) --- >>>function f1() { 1 > 2 >^^^^^^^^^^^^^^^^^^^^^^-> 1 > > -1 >Emitted(20, 1) Source(9, 1) + SourceIndex(1) +1 >Emitted(34, 1) Source(9, 1) + SourceIndex(2) --- >>> return instance1; 1->^^^^ @@ -453,11 +619,11 @@ sourceFile:file:///tests/cases/projects/outputdir_mixed_subfolder/test.ts 3 > 4 > instance1 5 > ; -1->Emitted(21, 5) Source(10, 5) + SourceIndex(1) name (f1) -2 >Emitted(21, 11) Source(10, 11) + SourceIndex(1) name (f1) -3 >Emitted(21, 12) Source(10, 12) + SourceIndex(1) name (f1) -4 >Emitted(21, 21) Source(10, 21) + SourceIndex(1) name (f1) -5 >Emitted(21, 22) Source(10, 22) + SourceIndex(1) name (f1) +1->Emitted(35, 5) Source(10, 5) + SourceIndex(2) name (f1) +2 >Emitted(35, 11) Source(10, 11) + SourceIndex(2) name (f1) +3 >Emitted(35, 12) Source(10, 12) + SourceIndex(2) name (f1) +4 >Emitted(35, 21) Source(10, 21) + SourceIndex(2) name (f1) +5 >Emitted(35, 22) Source(10, 22) + SourceIndex(2) name (f1) --- >>>} 1 > @@ -466,7 +632,7 @@ sourceFile:file:///tests/cases/projects/outputdir_mixed_subfolder/test.ts 1 > > 2 >} -1 >Emitted(22, 1) Source(11, 1) + SourceIndex(1) name (f1) -2 >Emitted(22, 2) Source(11, 2) + SourceIndex(1) name (f1) +1 >Emitted(36, 1) Source(11, 1) + SourceIndex(2) name (f1) +2 >Emitted(36, 2) Source(11, 2) + SourceIndex(2) name (f1) --- >>>//# sourceMappingURL=http://www.typescriptlang.org/test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFile/node/bin/test.d.ts b/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFile/node/bin/test.d.ts deleted file mode 100644 index d61b4c3b876..00000000000 --- a/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFile/node/bin/test.d.ts +++ /dev/null @@ -1,13 +0,0 @@ -/// -declare var m1_a1: number; -declare class m1_c1 { - m1_c1_p1: number; -} -declare var m1_instance1: m1_c1; -declare function m1_f1(): m1_c1; -declare var a1: number; -declare class c1 { - p1: number; -} -declare var instance1: c1; -declare function f1(): c1; diff --git a/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFile/node/bin/test.js b/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFile/node/bin/test.js deleted file mode 100644 index af0071d7e46..00000000000 --- a/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFile/node/bin/test.js +++ /dev/null @@ -1,23 +0,0 @@ -var m1_a1 = 10; -var m1_c1 = (function () { - function m1_c1() { - } - return m1_c1; -})(); -var m1_instance1 = new m1_c1(); -function m1_f1() { - return m1_instance1; -} -/// -/// -var a1 = 10; -var c1 = (function () { - function c1() { - } - return c1; -})(); -var instance1 = new c1(); -function f1() { - return instance1; -} -//# sourceMappingURL=http://www.typescriptlang.org/test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFile/node/bin/test.js.map b/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFile/node/bin/test.js.map index df57785d945..0b202d40b8c 100644 --- a/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFile/node/bin/test.js.map +++ b/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFile/node/bin/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"","sources":["file:///tests/cases/projects/outputdir_mixed_subfolder/ref/m1.ts","file:///tests/cases/projects/outputdir_mixed_subfolder/test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACRD,iCAAiC;AACjC,iCAAiC;AACjC,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"","sources":["file:///tests/cases/projects/outputdir_mixed_subfolder/ref/m1.ts","file:///tests/cases/projects/outputdir_mixed_subfolder/ref/m2.ts","file:///tests/cases/projects/outputdir_mixed_subfolder/test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;AERD,iCAAiC;AACjC,iCAAiC;AACjC,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFile/node/maprootUrlMixedSubfolderSpecifyOutputFile.sourcemap.txt b/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFile/node/maprootUrlMixedSubfolderSpecifyOutputFile.sourcemap.txt index aede30c6f73..7a04c10d333 100644 --- a/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFile/node/maprootUrlMixedSubfolderSpecifyOutputFile.sourcemap.txt +++ b/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFile/node/maprootUrlMixedSubfolderSpecifyOutputFile.sourcemap.txt @@ -173,7 +173,7 @@ sourceFile:file:///tests/cases/projects/outputdir_mixed_subfolder/ref/m2.ts JsFile: test.js mapUrl: http://www.typescriptlang.org/test.js.map sourceRoot: -sources: file:///tests/cases/projects/outputdir_mixed_subfolder/ref/m1.ts,file:///tests/cases/projects/outputdir_mixed_subfolder/test.ts +sources: file:///tests/cases/projects/outputdir_mixed_subfolder/ref/m1.ts,file:///tests/cases/projects/outputdir_mixed_subfolder/ref/m2.ts,file:///tests/cases/projects/outputdir_mixed_subfolder/test.ts =================================================================== ------------------------------------------------------------------- emittedFile:bin/test.js @@ -322,8 +322,8 @@ sourceFile:file:///tests/cases/projects/outputdir_mixed_subfolder/test.ts 3 > ^-> 1-> 2 >/// -1->Emitted(11, 1) Source(1, 1) + SourceIndex(1) -2 >Emitted(11, 34) Source(1, 34) + SourceIndex(1) +1->Emitted(11, 1) Source(1, 1) + SourceIndex(2) +2 >Emitted(11, 34) Source(1, 34) + SourceIndex(2) --- >>>/// 1-> @@ -331,8 +331,8 @@ sourceFile:file:///tests/cases/projects/outputdir_mixed_subfolder/test.ts 1-> > 2 >/// -1->Emitted(12, 1) Source(2, 1) + SourceIndex(1) -2 >Emitted(12, 34) Source(2, 34) + SourceIndex(1) +1->Emitted(12, 1) Source(2, 1) + SourceIndex(2) +2 >Emitted(12, 34) Source(2, 34) + SourceIndex(2) --- >>>var a1 = 10; 1 > @@ -349,25 +349,25 @@ sourceFile:file:///tests/cases/projects/outputdir_mixed_subfolder/test.ts 4 > = 5 > 10 6 > ; -1 >Emitted(13, 1) Source(3, 1) + SourceIndex(1) -2 >Emitted(13, 5) Source(3, 5) + SourceIndex(1) -3 >Emitted(13, 7) Source(3, 7) + SourceIndex(1) -4 >Emitted(13, 10) Source(3, 10) + SourceIndex(1) -5 >Emitted(13, 12) Source(3, 12) + SourceIndex(1) -6 >Emitted(13, 13) Source(3, 13) + SourceIndex(1) +1 >Emitted(13, 1) Source(3, 1) + SourceIndex(2) +2 >Emitted(13, 5) Source(3, 5) + SourceIndex(2) +3 >Emitted(13, 7) Source(3, 7) + SourceIndex(2) +4 >Emitted(13, 10) Source(3, 10) + SourceIndex(2) +5 >Emitted(13, 12) Source(3, 12) + SourceIndex(2) +6 >Emitted(13, 13) Source(3, 13) + SourceIndex(2) --- >>>var c1 = (function () { 1-> 2 >^^^^^^^^^^^^^^^^^^^^-> 1-> > -1->Emitted(14, 1) Source(4, 1) + SourceIndex(1) +1->Emitted(14, 1) Source(4, 1) + SourceIndex(2) --- >>> function c1() { 1->^^^^ 2 > ^^-> 1-> -1->Emitted(15, 5) Source(4, 1) + SourceIndex(1) name (c1) +1->Emitted(15, 5) Source(4, 1) + SourceIndex(2) name (c1) --- >>> } 1->^^^^ @@ -377,16 +377,16 @@ sourceFile:file:///tests/cases/projects/outputdir_mixed_subfolder/test.ts > public p1: number; > 2 > } -1->Emitted(16, 5) Source(6, 1) + SourceIndex(1) name (c1.constructor) -2 >Emitted(16, 6) Source(6, 2) + SourceIndex(1) name (c1.constructor) +1->Emitted(16, 5) Source(6, 1) + SourceIndex(2) name (c1.constructor) +2 >Emitted(16, 6) Source(6, 2) + SourceIndex(2) name (c1.constructor) --- >>> return c1; 1->^^^^ 2 > ^^^^^^^^^ 1-> 2 > } -1->Emitted(17, 5) Source(6, 1) + SourceIndex(1) name (c1) -2 >Emitted(17, 14) Source(6, 2) + SourceIndex(1) name (c1) +1->Emitted(17, 5) Source(6, 1) + SourceIndex(2) name (c1) +2 >Emitted(17, 14) Source(6, 2) + SourceIndex(2) name (c1) --- >>>})(); 1 > @@ -400,10 +400,10 @@ sourceFile:file:///tests/cases/projects/outputdir_mixed_subfolder/test.ts 4 > class c1 { > public p1: number; > } -1 >Emitted(18, 1) Source(6, 1) + SourceIndex(1) name (c1) -2 >Emitted(18, 2) Source(6, 2) + SourceIndex(1) name (c1) -3 >Emitted(18, 2) Source(4, 1) + SourceIndex(1) -4 >Emitted(18, 6) Source(6, 2) + SourceIndex(1) +1 >Emitted(18, 1) Source(6, 1) + SourceIndex(2) name (c1) +2 >Emitted(18, 2) Source(6, 2) + SourceIndex(2) name (c1) +3 >Emitted(18, 2) Source(4, 1) + SourceIndex(2) +4 >Emitted(18, 6) Source(6, 2) + SourceIndex(2) --- >>>var instance1 = new c1(); 1-> @@ -424,21 +424,21 @@ sourceFile:file:///tests/cases/projects/outputdir_mixed_subfolder/test.ts 6 > c1 7 > () 8 > ; -1->Emitted(19, 1) Source(8, 1) + SourceIndex(1) -2 >Emitted(19, 5) Source(8, 5) + SourceIndex(1) -3 >Emitted(19, 14) Source(8, 14) + SourceIndex(1) -4 >Emitted(19, 17) Source(8, 17) + SourceIndex(1) -5 >Emitted(19, 21) Source(8, 21) + SourceIndex(1) -6 >Emitted(19, 23) Source(8, 23) + SourceIndex(1) -7 >Emitted(19, 25) Source(8, 25) + SourceIndex(1) -8 >Emitted(19, 26) Source(8, 26) + SourceIndex(1) +1->Emitted(19, 1) Source(8, 1) + SourceIndex(2) +2 >Emitted(19, 5) Source(8, 5) + SourceIndex(2) +3 >Emitted(19, 14) Source(8, 14) + SourceIndex(2) +4 >Emitted(19, 17) Source(8, 17) + SourceIndex(2) +5 >Emitted(19, 21) Source(8, 21) + SourceIndex(2) +6 >Emitted(19, 23) Source(8, 23) + SourceIndex(2) +7 >Emitted(19, 25) Source(8, 25) + SourceIndex(2) +8 >Emitted(19, 26) Source(8, 26) + SourceIndex(2) --- >>>function f1() { 1 > 2 >^^^^^^^^^^^^^^^^^^^^^^-> 1 > > -1 >Emitted(20, 1) Source(9, 1) + SourceIndex(1) +1 >Emitted(20, 1) Source(9, 1) + SourceIndex(2) --- >>> return instance1; 1->^^^^ @@ -452,11 +452,11 @@ sourceFile:file:///tests/cases/projects/outputdir_mixed_subfolder/test.ts 3 > 4 > instance1 5 > ; -1->Emitted(21, 5) Source(10, 5) + SourceIndex(1) name (f1) -2 >Emitted(21, 11) Source(10, 11) + SourceIndex(1) name (f1) -3 >Emitted(21, 12) Source(10, 12) + SourceIndex(1) name (f1) -4 >Emitted(21, 21) Source(10, 21) + SourceIndex(1) name (f1) -5 >Emitted(21, 22) Source(10, 22) + SourceIndex(1) name (f1) +1->Emitted(21, 5) Source(10, 5) + SourceIndex(2) name (f1) +2 >Emitted(21, 11) Source(10, 11) + SourceIndex(2) name (f1) +3 >Emitted(21, 12) Source(10, 12) + SourceIndex(2) name (f1) +4 >Emitted(21, 21) Source(10, 21) + SourceIndex(2) name (f1) +5 >Emitted(21, 22) Source(10, 22) + SourceIndex(2) name (f1) --- >>>} 1 > @@ -465,7 +465,7 @@ sourceFile:file:///tests/cases/projects/outputdir_mixed_subfolder/test.ts 1 > > 2 >} -1 >Emitted(22, 1) Source(11, 1) + SourceIndex(1) name (f1) -2 >Emitted(22, 2) Source(11, 2) + SourceIndex(1) name (f1) +1 >Emitted(22, 1) Source(11, 1) + SourceIndex(2) name (f1) +2 >Emitted(22, 2) Source(11, 2) + SourceIndex(2) name (f1) --- >>>//# sourceMappingURL=http://www.typescriptlang.org/test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.d.ts b/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.d.ts deleted file mode 100644 index 9b9cdd4a214..00000000000 --- a/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.d.ts +++ /dev/null @@ -1,13 +0,0 @@ -/// -declare var m1_a1: number; -declare class m1_c1 { - m1_c1_p1: number; -} -declare var m1_instance1: m1_c1; -declare function m1_f1(): m1_c1; -declare var a1: number; -declare class c1 { - p1: number; -} -declare var instance1: c1; -declare function f1(): c1; diff --git a/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.js b/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.js deleted file mode 100644 index 2ebe138ffda..00000000000 --- a/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.js +++ /dev/null @@ -1,23 +0,0 @@ -var m1_a1 = 10; -var m1_c1 = (function () { - function m1_c1() { - } - return m1_c1; -})(); -var m1_instance1 = new m1_c1(); -function m1_f1() { - return m1_instance1; -} -/// -/// -var a1 = 10; -var c1 = (function () { - function c1() { - } - return c1; -})(); -var instance1 = new c1(); -function f1() { - return instance1; -} -//# sourceMappingURL=http://www.typescriptlang.org/outAndOutDirFile.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.js.map b/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.js.map index e7042dca90a..d78e3b4607a 100644 --- a/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.js.map +++ b/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.js.map @@ -1 +1 @@ -{"version":3,"file":"outAndOutDirFile.js","sourceRoot":"","sources":["file:///tests/cases/projects/outputdir_mixed_subfolder/ref/m1.ts","file:///tests/cases/projects/outputdir_mixed_subfolder/test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACRD,iCAAiC;AACjC,iCAAiC;AACjC,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"outAndOutDirFile.js","sourceRoot":"","sources":["file:///tests/cases/projects/outputdir_mixed_subfolder/ref/m1.ts","file:///tests/cases/projects/outputdir_mixed_subfolder/ref/m2.ts","file:///tests/cases/projects/outputdir_mixed_subfolder/test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","m2_c1","m2_c1.constructor","m2_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;;ICRU,aAAK,GAAG,EAAE,CAAC;IACtB;QAAAC;QAEAC,CAACA;QAADD,YAACA;IAADA,CAACA,AAFD,IAEC;IAFY,aAAK,QAEjB,CAAA;IAEU,oBAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACIE,MAAMA,CAACA,oBAAYA,CAACA;IACxBA,CAACA;IAFe,aAAK,QAEpB,CAAA;;ACRD,iCAAiC;AACjC,iCAAiC;AACjC,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/maprootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory.sourcemap.txt b/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/maprootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory.sourcemap.txt index 5637274312d..bdeabb5ae19 100644 --- a/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/maprootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory.sourcemap.txt +++ b/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/maprootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory.sourcemap.txt @@ -174,7 +174,7 @@ sourceFile:file:///tests/cases/projects/outputdir_mixed_subfolder/ref/m2.ts JsFile: outAndOutDirFile.js mapUrl: http://www.typescriptlang.org/outAndOutDirFile.js.map sourceRoot: -sources: file:///tests/cases/projects/outputdir_mixed_subfolder/ref/m1.ts,file:///tests/cases/projects/outputdir_mixed_subfolder/test.ts +sources: file:///tests/cases/projects/outputdir_mixed_subfolder/ref/m1.ts,file:///tests/cases/projects/outputdir_mixed_subfolder/ref/m2.ts,file:///tests/cases/projects/outputdir_mixed_subfolder/test.ts =================================================================== ------------------------------------------------------------------- emittedFile:bin/outAndOutDirFile.js @@ -306,7 +306,7 @@ sourceFile:file:///tests/cases/projects/outputdir_mixed_subfolder/ref/m1.ts >>>} 1 > 2 >^ -3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> 1 > > 2 >} @@ -315,16 +315,182 @@ sourceFile:file:///tests/cases/projects/outputdir_mixed_subfolder/ref/m1.ts --- ------------------------------------------------------------------- emittedFile:bin/outAndOutDirFile.js +sourceFile:file:///tests/cases/projects/outputdir_mixed_subfolder/ref/m2.ts +------------------------------------------------------------------- +>>>define("ref/m2", ["require", "exports"], function (require, exports) { +>>> exports.m2_a1 = 10; +1->^^^^ +2 > ^^^^^^^^^^^^^ +3 > ^^^ +4 > ^^ +5 > ^ +6 > ^^^^^^^^-> +1->export var +2 > m2_a1 +3 > = +4 > 10 +5 > ; +1->Emitted(12, 5) Source(1, 12) + SourceIndex(1) +2 >Emitted(12, 18) Source(1, 17) + SourceIndex(1) +3 >Emitted(12, 21) Source(1, 20) + SourceIndex(1) +4 >Emitted(12, 23) Source(1, 22) + SourceIndex(1) +5 >Emitted(12, 24) Source(1, 23) + SourceIndex(1) +--- +>>> var m2_c1 = (function () { +1->^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^^^^-> +1-> + > +1->Emitted(13, 5) Source(2, 1) + SourceIndex(1) +--- +>>> function m2_c1() { +1->^^^^^^^^ +2 > ^^-> +1-> +1->Emitted(14, 9) Source(2, 1) + SourceIndex(1) name (m2_c1) +--- +>>> } +1->^^^^^^^^ +2 > ^ +3 > ^^^^^^^^^^^^^-> +1->export class m2_c1 { + > public m2_c1_p1: number; + > +2 > } +1->Emitted(15, 9) Source(4, 1) + SourceIndex(1) name (m2_c1.constructor) +2 >Emitted(15, 10) Source(4, 2) + SourceIndex(1) name (m2_c1.constructor) +--- +>>> return m2_c1; +1->^^^^^^^^ +2 > ^^^^^^^^^^^^ +1-> +2 > } +1->Emitted(16, 9) Source(4, 1) + SourceIndex(1) name (m2_c1) +2 >Emitted(16, 21) Source(4, 2) + SourceIndex(1) name (m2_c1) +--- +>>> })(); +1 >^^^^ +2 > ^ +3 > +4 > ^^^^ +5 > ^^^^^^^^^^^^^^^^^^-> +1 > +2 > } +3 > +4 > export class m2_c1 { + > public m2_c1_p1: number; + > } +1 >Emitted(17, 5) Source(4, 1) + SourceIndex(1) name (m2_c1) +2 >Emitted(17, 6) Source(4, 2) + SourceIndex(1) name (m2_c1) +3 >Emitted(17, 6) Source(2, 1) + SourceIndex(1) +4 >Emitted(17, 10) Source(4, 2) + SourceIndex(1) +--- +>>> exports.m2_c1 = m2_c1; +1->^^^^ +2 > ^^^^^^^^^^^^^ +3 > ^^^^^^^^ +4 > ^ +5 > ^^^^^^^^^^^^^^-> +1-> +2 > m2_c1 +3 > { + > public m2_c1_p1: number; + > } +4 > +1->Emitted(18, 5) Source(2, 14) + SourceIndex(1) +2 >Emitted(18, 18) Source(2, 19) + SourceIndex(1) +3 >Emitted(18, 26) Source(4, 2) + SourceIndex(1) +4 >Emitted(18, 27) Source(4, 2) + SourceIndex(1) +--- +>>> exports.m2_instance1 = new m2_c1(); +1->^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^ +3 > ^^^ +4 > ^^^^ +5 > ^^^^^ +6 > ^^ +7 > ^ +1-> + > + >export var +2 > m2_instance1 +3 > = +4 > new +5 > m2_c1 +6 > () +7 > ; +1->Emitted(19, 5) Source(6, 12) + SourceIndex(1) +2 >Emitted(19, 25) Source(6, 24) + SourceIndex(1) +3 >Emitted(19, 28) Source(6, 27) + SourceIndex(1) +4 >Emitted(19, 32) Source(6, 31) + SourceIndex(1) +5 >Emitted(19, 37) Source(6, 36) + SourceIndex(1) +6 >Emitted(19, 39) Source(6, 38) + SourceIndex(1) +7 >Emitted(19, 40) Source(6, 39) + SourceIndex(1) +--- +>>> function m2_f1() { +1 >^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +1 > + > +1 >Emitted(20, 5) Source(7, 1) + SourceIndex(1) +--- +>>> return exports.m2_instance1; +1->^^^^^^^^ +2 > ^^^^^^ +3 > ^ +4 > ^^^^^^^^^^^^^^^^^^^^ +5 > ^ +1->export function m2_f1() { + > +2 > return +3 > +4 > m2_instance1 +5 > ; +1->Emitted(21, 9) Source(8, 5) + SourceIndex(1) name (m2_f1) +2 >Emitted(21, 15) Source(8, 11) + SourceIndex(1) name (m2_f1) +3 >Emitted(21, 16) Source(8, 12) + SourceIndex(1) name (m2_f1) +4 >Emitted(21, 36) Source(8, 24) + SourceIndex(1) name (m2_f1) +5 >Emitted(21, 37) Source(8, 25) + SourceIndex(1) name (m2_f1) +--- +>>> } +1 >^^^^ +2 > ^ +3 > ^^^^^^^^^^^^^^^^^^^^^^-> +1 > + > +2 > } +1 >Emitted(22, 5) Source(9, 1) + SourceIndex(1) name (m2_f1) +2 >Emitted(22, 6) Source(9, 2) + SourceIndex(1) name (m2_f1) +--- +>>> exports.m2_f1 = m2_f1; +1->^^^^ +2 > ^^^^^^^^^^^^^ +3 > ^^^^^^^^ +4 > ^ +1-> +2 > m2_f1 +3 > () { + > return m2_instance1; + > } +4 > +1->Emitted(23, 5) Source(7, 17) + SourceIndex(1) +2 >Emitted(23, 18) Source(7, 22) + SourceIndex(1) +3 >Emitted(23, 26) Source(9, 2) + SourceIndex(1) +4 >Emitted(23, 27) Source(9, 2) + SourceIndex(1) +--- +------------------------------------------------------------------- +emittedFile:bin/outAndOutDirFile.js sourceFile:file:///tests/cases/projects/outputdir_mixed_subfolder/test.ts ------------------------------------------------------------------- +>>>}); >>>/// -1-> +1 > 2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 3 > ^-> -1-> +1 > 2 >/// -1->Emitted(11, 1) Source(1, 1) + SourceIndex(1) -2 >Emitted(11, 34) Source(1, 34) + SourceIndex(1) +1 >Emitted(25, 1) Source(1, 1) + SourceIndex(2) +2 >Emitted(25, 34) Source(1, 34) + SourceIndex(2) --- >>>/// 1-> @@ -332,8 +498,8 @@ sourceFile:file:///tests/cases/projects/outputdir_mixed_subfolder/test.ts 1-> > 2 >/// -1->Emitted(12, 1) Source(2, 1) + SourceIndex(1) -2 >Emitted(12, 34) Source(2, 34) + SourceIndex(1) +1->Emitted(26, 1) Source(2, 1) + SourceIndex(2) +2 >Emitted(26, 34) Source(2, 34) + SourceIndex(2) --- >>>var a1 = 10; 1 > @@ -350,25 +516,25 @@ sourceFile:file:///tests/cases/projects/outputdir_mixed_subfolder/test.ts 4 > = 5 > 10 6 > ; -1 >Emitted(13, 1) Source(3, 1) + SourceIndex(1) -2 >Emitted(13, 5) Source(3, 5) + SourceIndex(1) -3 >Emitted(13, 7) Source(3, 7) + SourceIndex(1) -4 >Emitted(13, 10) Source(3, 10) + SourceIndex(1) -5 >Emitted(13, 12) Source(3, 12) + SourceIndex(1) -6 >Emitted(13, 13) Source(3, 13) + SourceIndex(1) +1 >Emitted(27, 1) Source(3, 1) + SourceIndex(2) +2 >Emitted(27, 5) Source(3, 5) + SourceIndex(2) +3 >Emitted(27, 7) Source(3, 7) + SourceIndex(2) +4 >Emitted(27, 10) Source(3, 10) + SourceIndex(2) +5 >Emitted(27, 12) Source(3, 12) + SourceIndex(2) +6 >Emitted(27, 13) Source(3, 13) + SourceIndex(2) --- >>>var c1 = (function () { 1-> 2 >^^^^^^^^^^^^^^^^^^^^-> 1-> > -1->Emitted(14, 1) Source(4, 1) + SourceIndex(1) +1->Emitted(28, 1) Source(4, 1) + SourceIndex(2) --- >>> function c1() { 1->^^^^ 2 > ^^-> 1-> -1->Emitted(15, 5) Source(4, 1) + SourceIndex(1) name (c1) +1->Emitted(29, 5) Source(4, 1) + SourceIndex(2) name (c1) --- >>> } 1->^^^^ @@ -378,16 +544,16 @@ sourceFile:file:///tests/cases/projects/outputdir_mixed_subfolder/test.ts > public p1: number; > 2 > } -1->Emitted(16, 5) Source(6, 1) + SourceIndex(1) name (c1.constructor) -2 >Emitted(16, 6) Source(6, 2) + SourceIndex(1) name (c1.constructor) +1->Emitted(30, 5) Source(6, 1) + SourceIndex(2) name (c1.constructor) +2 >Emitted(30, 6) Source(6, 2) + SourceIndex(2) name (c1.constructor) --- >>> return c1; 1->^^^^ 2 > ^^^^^^^^^ 1-> 2 > } -1->Emitted(17, 5) Source(6, 1) + SourceIndex(1) name (c1) -2 >Emitted(17, 14) Source(6, 2) + SourceIndex(1) name (c1) +1->Emitted(31, 5) Source(6, 1) + SourceIndex(2) name (c1) +2 >Emitted(31, 14) Source(6, 2) + SourceIndex(2) name (c1) --- >>>})(); 1 > @@ -401,10 +567,10 @@ sourceFile:file:///tests/cases/projects/outputdir_mixed_subfolder/test.ts 4 > class c1 { > public p1: number; > } -1 >Emitted(18, 1) Source(6, 1) + SourceIndex(1) name (c1) -2 >Emitted(18, 2) Source(6, 2) + SourceIndex(1) name (c1) -3 >Emitted(18, 2) Source(4, 1) + SourceIndex(1) -4 >Emitted(18, 6) Source(6, 2) + SourceIndex(1) +1 >Emitted(32, 1) Source(6, 1) + SourceIndex(2) name (c1) +2 >Emitted(32, 2) Source(6, 2) + SourceIndex(2) name (c1) +3 >Emitted(32, 2) Source(4, 1) + SourceIndex(2) +4 >Emitted(32, 6) Source(6, 2) + SourceIndex(2) --- >>>var instance1 = new c1(); 1-> @@ -425,21 +591,21 @@ sourceFile:file:///tests/cases/projects/outputdir_mixed_subfolder/test.ts 6 > c1 7 > () 8 > ; -1->Emitted(19, 1) Source(8, 1) + SourceIndex(1) -2 >Emitted(19, 5) Source(8, 5) + SourceIndex(1) -3 >Emitted(19, 14) Source(8, 14) + SourceIndex(1) -4 >Emitted(19, 17) Source(8, 17) + SourceIndex(1) -5 >Emitted(19, 21) Source(8, 21) + SourceIndex(1) -6 >Emitted(19, 23) Source(8, 23) + SourceIndex(1) -7 >Emitted(19, 25) Source(8, 25) + SourceIndex(1) -8 >Emitted(19, 26) Source(8, 26) + SourceIndex(1) +1->Emitted(33, 1) Source(8, 1) + SourceIndex(2) +2 >Emitted(33, 5) Source(8, 5) + SourceIndex(2) +3 >Emitted(33, 14) Source(8, 14) + SourceIndex(2) +4 >Emitted(33, 17) Source(8, 17) + SourceIndex(2) +5 >Emitted(33, 21) Source(8, 21) + SourceIndex(2) +6 >Emitted(33, 23) Source(8, 23) + SourceIndex(2) +7 >Emitted(33, 25) Source(8, 25) + SourceIndex(2) +8 >Emitted(33, 26) Source(8, 26) + SourceIndex(2) --- >>>function f1() { 1 > 2 >^^^^^^^^^^^^^^^^^^^^^^-> 1 > > -1 >Emitted(20, 1) Source(9, 1) + SourceIndex(1) +1 >Emitted(34, 1) Source(9, 1) + SourceIndex(2) --- >>> return instance1; 1->^^^^ @@ -453,11 +619,11 @@ sourceFile:file:///tests/cases/projects/outputdir_mixed_subfolder/test.ts 3 > 4 > instance1 5 > ; -1->Emitted(21, 5) Source(10, 5) + SourceIndex(1) name (f1) -2 >Emitted(21, 11) Source(10, 11) + SourceIndex(1) name (f1) -3 >Emitted(21, 12) Source(10, 12) + SourceIndex(1) name (f1) -4 >Emitted(21, 21) Source(10, 21) + SourceIndex(1) name (f1) -5 >Emitted(21, 22) Source(10, 22) + SourceIndex(1) name (f1) +1->Emitted(35, 5) Source(10, 5) + SourceIndex(2) name (f1) +2 >Emitted(35, 11) Source(10, 11) + SourceIndex(2) name (f1) +3 >Emitted(35, 12) Source(10, 12) + SourceIndex(2) name (f1) +4 >Emitted(35, 21) Source(10, 21) + SourceIndex(2) name (f1) +5 >Emitted(35, 22) Source(10, 22) + SourceIndex(2) name (f1) --- >>>} 1 > @@ -466,7 +632,7 @@ sourceFile:file:///tests/cases/projects/outputdir_mixed_subfolder/test.ts 1 > > 2 >} -1 >Emitted(22, 1) Source(11, 1) + SourceIndex(1) name (f1) -2 >Emitted(22, 2) Source(11, 2) + SourceIndex(1) name (f1) +1 >Emitted(36, 1) Source(11, 1) + SourceIndex(2) name (f1) +2 >Emitted(36, 2) Source(11, 2) + SourceIndex(2) name (f1) --- >>>//# sourceMappingURL=http://www.typescriptlang.org/outAndOutDirFile.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.d.ts b/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.d.ts deleted file mode 100644 index 9b9cdd4a214..00000000000 --- a/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.d.ts +++ /dev/null @@ -1,13 +0,0 @@ -/// -declare var m1_a1: number; -declare class m1_c1 { - m1_c1_p1: number; -} -declare var m1_instance1: m1_c1; -declare function m1_f1(): m1_c1; -declare var a1: number; -declare class c1 { - p1: number; -} -declare var instance1: c1; -declare function f1(): c1; diff --git a/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.js b/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.js deleted file mode 100644 index 2ebe138ffda..00000000000 --- a/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.js +++ /dev/null @@ -1,23 +0,0 @@ -var m1_a1 = 10; -var m1_c1 = (function () { - function m1_c1() { - } - return m1_c1; -})(); -var m1_instance1 = new m1_c1(); -function m1_f1() { - return m1_instance1; -} -/// -/// -var a1 = 10; -var c1 = (function () { - function c1() { - } - return c1; -})(); -var instance1 = new c1(); -function f1() { - return instance1; -} -//# sourceMappingURL=http://www.typescriptlang.org/outAndOutDirFile.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.js.map b/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.js.map index e7042dca90a..363ef3c21bf 100644 --- a/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.js.map +++ b/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.js.map @@ -1 +1 @@ -{"version":3,"file":"outAndOutDirFile.js","sourceRoot":"","sources":["file:///tests/cases/projects/outputdir_mixed_subfolder/ref/m1.ts","file:///tests/cases/projects/outputdir_mixed_subfolder/test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACRD,iCAAiC;AACjC,iCAAiC;AACjC,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"outAndOutDirFile.js","sourceRoot":"","sources":["file:///tests/cases/projects/outputdir_mixed_subfolder/ref/m1.ts","file:///tests/cases/projects/outputdir_mixed_subfolder/ref/m2.ts","file:///tests/cases/projects/outputdir_mixed_subfolder/test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;AERD,iCAAiC;AACjC,iCAAiC;AACjC,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/maprootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory.sourcemap.txt b/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/maprootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory.sourcemap.txt index fa3d5513061..33ade6d5e9d 100644 --- a/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/maprootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory.sourcemap.txt +++ b/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/maprootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory.sourcemap.txt @@ -173,7 +173,7 @@ sourceFile:file:///tests/cases/projects/outputdir_mixed_subfolder/ref/m2.ts JsFile: outAndOutDirFile.js mapUrl: http://www.typescriptlang.org/outAndOutDirFile.js.map sourceRoot: -sources: file:///tests/cases/projects/outputdir_mixed_subfolder/ref/m1.ts,file:///tests/cases/projects/outputdir_mixed_subfolder/test.ts +sources: file:///tests/cases/projects/outputdir_mixed_subfolder/ref/m1.ts,file:///tests/cases/projects/outputdir_mixed_subfolder/ref/m2.ts,file:///tests/cases/projects/outputdir_mixed_subfolder/test.ts =================================================================== ------------------------------------------------------------------- emittedFile:bin/outAndOutDirFile.js @@ -322,8 +322,8 @@ sourceFile:file:///tests/cases/projects/outputdir_mixed_subfolder/test.ts 3 > ^-> 1-> 2 >/// -1->Emitted(11, 1) Source(1, 1) + SourceIndex(1) -2 >Emitted(11, 34) Source(1, 34) + SourceIndex(1) +1->Emitted(11, 1) Source(1, 1) + SourceIndex(2) +2 >Emitted(11, 34) Source(1, 34) + SourceIndex(2) --- >>>/// 1-> @@ -331,8 +331,8 @@ sourceFile:file:///tests/cases/projects/outputdir_mixed_subfolder/test.ts 1-> > 2 >/// -1->Emitted(12, 1) Source(2, 1) + SourceIndex(1) -2 >Emitted(12, 34) Source(2, 34) + SourceIndex(1) +1->Emitted(12, 1) Source(2, 1) + SourceIndex(2) +2 >Emitted(12, 34) Source(2, 34) + SourceIndex(2) --- >>>var a1 = 10; 1 > @@ -349,25 +349,25 @@ sourceFile:file:///tests/cases/projects/outputdir_mixed_subfolder/test.ts 4 > = 5 > 10 6 > ; -1 >Emitted(13, 1) Source(3, 1) + SourceIndex(1) -2 >Emitted(13, 5) Source(3, 5) + SourceIndex(1) -3 >Emitted(13, 7) Source(3, 7) + SourceIndex(1) -4 >Emitted(13, 10) Source(3, 10) + SourceIndex(1) -5 >Emitted(13, 12) Source(3, 12) + SourceIndex(1) -6 >Emitted(13, 13) Source(3, 13) + SourceIndex(1) +1 >Emitted(13, 1) Source(3, 1) + SourceIndex(2) +2 >Emitted(13, 5) Source(3, 5) + SourceIndex(2) +3 >Emitted(13, 7) Source(3, 7) + SourceIndex(2) +4 >Emitted(13, 10) Source(3, 10) + SourceIndex(2) +5 >Emitted(13, 12) Source(3, 12) + SourceIndex(2) +6 >Emitted(13, 13) Source(3, 13) + SourceIndex(2) --- >>>var c1 = (function () { 1-> 2 >^^^^^^^^^^^^^^^^^^^^-> 1-> > -1->Emitted(14, 1) Source(4, 1) + SourceIndex(1) +1->Emitted(14, 1) Source(4, 1) + SourceIndex(2) --- >>> function c1() { 1->^^^^ 2 > ^^-> 1-> -1->Emitted(15, 5) Source(4, 1) + SourceIndex(1) name (c1) +1->Emitted(15, 5) Source(4, 1) + SourceIndex(2) name (c1) --- >>> } 1->^^^^ @@ -377,16 +377,16 @@ sourceFile:file:///tests/cases/projects/outputdir_mixed_subfolder/test.ts > public p1: number; > 2 > } -1->Emitted(16, 5) Source(6, 1) + SourceIndex(1) name (c1.constructor) -2 >Emitted(16, 6) Source(6, 2) + SourceIndex(1) name (c1.constructor) +1->Emitted(16, 5) Source(6, 1) + SourceIndex(2) name (c1.constructor) +2 >Emitted(16, 6) Source(6, 2) + SourceIndex(2) name (c1.constructor) --- >>> return c1; 1->^^^^ 2 > ^^^^^^^^^ 1-> 2 > } -1->Emitted(17, 5) Source(6, 1) + SourceIndex(1) name (c1) -2 >Emitted(17, 14) Source(6, 2) + SourceIndex(1) name (c1) +1->Emitted(17, 5) Source(6, 1) + SourceIndex(2) name (c1) +2 >Emitted(17, 14) Source(6, 2) + SourceIndex(2) name (c1) --- >>>})(); 1 > @@ -400,10 +400,10 @@ sourceFile:file:///tests/cases/projects/outputdir_mixed_subfolder/test.ts 4 > class c1 { > public p1: number; > } -1 >Emitted(18, 1) Source(6, 1) + SourceIndex(1) name (c1) -2 >Emitted(18, 2) Source(6, 2) + SourceIndex(1) name (c1) -3 >Emitted(18, 2) Source(4, 1) + SourceIndex(1) -4 >Emitted(18, 6) Source(6, 2) + SourceIndex(1) +1 >Emitted(18, 1) Source(6, 1) + SourceIndex(2) name (c1) +2 >Emitted(18, 2) Source(6, 2) + SourceIndex(2) name (c1) +3 >Emitted(18, 2) Source(4, 1) + SourceIndex(2) +4 >Emitted(18, 6) Source(6, 2) + SourceIndex(2) --- >>>var instance1 = new c1(); 1-> @@ -424,21 +424,21 @@ sourceFile:file:///tests/cases/projects/outputdir_mixed_subfolder/test.ts 6 > c1 7 > () 8 > ; -1->Emitted(19, 1) Source(8, 1) + SourceIndex(1) -2 >Emitted(19, 5) Source(8, 5) + SourceIndex(1) -3 >Emitted(19, 14) Source(8, 14) + SourceIndex(1) -4 >Emitted(19, 17) Source(8, 17) + SourceIndex(1) -5 >Emitted(19, 21) Source(8, 21) + SourceIndex(1) -6 >Emitted(19, 23) Source(8, 23) + SourceIndex(1) -7 >Emitted(19, 25) Source(8, 25) + SourceIndex(1) -8 >Emitted(19, 26) Source(8, 26) + SourceIndex(1) +1->Emitted(19, 1) Source(8, 1) + SourceIndex(2) +2 >Emitted(19, 5) Source(8, 5) + SourceIndex(2) +3 >Emitted(19, 14) Source(8, 14) + SourceIndex(2) +4 >Emitted(19, 17) Source(8, 17) + SourceIndex(2) +5 >Emitted(19, 21) Source(8, 21) + SourceIndex(2) +6 >Emitted(19, 23) Source(8, 23) + SourceIndex(2) +7 >Emitted(19, 25) Source(8, 25) + SourceIndex(2) +8 >Emitted(19, 26) Source(8, 26) + SourceIndex(2) --- >>>function f1() { 1 > 2 >^^^^^^^^^^^^^^^^^^^^^^-> 1 > > -1 >Emitted(20, 1) Source(9, 1) + SourceIndex(1) +1 >Emitted(20, 1) Source(9, 1) + SourceIndex(2) --- >>> return instance1; 1->^^^^ @@ -452,11 +452,11 @@ sourceFile:file:///tests/cases/projects/outputdir_mixed_subfolder/test.ts 3 > 4 > instance1 5 > ; -1->Emitted(21, 5) Source(10, 5) + SourceIndex(1) name (f1) -2 >Emitted(21, 11) Source(10, 11) + SourceIndex(1) name (f1) -3 >Emitted(21, 12) Source(10, 12) + SourceIndex(1) name (f1) -4 >Emitted(21, 21) Source(10, 21) + SourceIndex(1) name (f1) -5 >Emitted(21, 22) Source(10, 22) + SourceIndex(1) name (f1) +1->Emitted(21, 5) Source(10, 5) + SourceIndex(2) name (f1) +2 >Emitted(21, 11) Source(10, 11) + SourceIndex(2) name (f1) +3 >Emitted(21, 12) Source(10, 12) + SourceIndex(2) name (f1) +4 >Emitted(21, 21) Source(10, 21) + SourceIndex(2) name (f1) +5 >Emitted(21, 22) Source(10, 22) + SourceIndex(2) name (f1) --- >>>} 1 > @@ -465,7 +465,7 @@ sourceFile:file:///tests/cases/projects/outputdir_mixed_subfolder/test.ts 1 > > 2 >} -1 >Emitted(22, 1) Source(11, 1) + SourceIndex(1) name (f1) -2 >Emitted(22, 2) Source(11, 2) + SourceIndex(1) name (f1) +1 >Emitted(22, 1) Source(11, 1) + SourceIndex(2) name (f1) +2 >Emitted(22, 2) Source(11, 2) + SourceIndex(2) name (f1) --- >>>//# sourceMappingURL=http://www.typescriptlang.org/outAndOutDirFile.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlModuleMultifolderSpecifyOutputFile/amd/bin/test.d.ts b/tests/baselines/reference/project/maprootUrlModuleMultifolderSpecifyOutputFile/amd/bin/test.d.ts deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/tests/baselines/reference/project/maprootUrlModuleMultifolderSpecifyOutputFile/amd/bin/test.js b/tests/baselines/reference/project/maprootUrlModuleMultifolderSpecifyOutputFile/amd/bin/test.js deleted file mode 100644 index 52f1b822100..00000000000 --- a/tests/baselines/reference/project/maprootUrlModuleMultifolderSpecifyOutputFile/amd/bin/test.js +++ /dev/null @@ -1 +0,0 @@ -//# sourceMappingURL=http://www.typescriptlang.org/test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlModuleMultifolderSpecifyOutputFile/amd/bin/test.js.map b/tests/baselines/reference/project/maprootUrlModuleMultifolderSpecifyOutputFile/amd/bin/test.js.map index c1e0281a2ab..211bf71cbed 100644 --- a/tests/baselines/reference/project/maprootUrlModuleMultifolderSpecifyOutputFile/amd/bin/test.js.map +++ b/tests/baselines/reference/project/maprootUrlModuleMultifolderSpecifyOutputFile/amd/bin/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"","sources":[],"names":[],"mappings":""} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"","sources":["file:///tests/cases/projects/outputdir_module_multifolder/ref/m1.ts","file:///tests/cases/projects/outputdir_module_multifolder_ref/m2.ts","file:///tests/cases/projects/outputdir_module_multifolder/test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","m2_c1","m2_c1.constructor","m2_f1","c1","c1.constructor","f1"],"mappings":";IAAW,aAAK,GAAG,EAAE,CAAC;IACtB;QAAAA;QAEAC,CAACA;QAADD,YAACA;IAADA,CAACA,AAFD,IAEC;IAFY,aAAK,QAEjB,CAAA;IAEU,oBAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACIE,MAAMA,CAACA,oBAAYA,CAACA;IACxBA,CAACA;IAFe,aAAK,QAEpB,CAAA;;;ICRU,aAAK,GAAG,EAAE,CAAC;IACtB;QAAAC;QAEAC,CAACA;QAADD,YAACA;IAADA,CAACA,AAFD,IAEC;IAFY,aAAK,QAEjB,CAAA;IAEU,oBAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACIE,MAAMA,CAACA,oBAAYA,CAACA;IACxBA,CAACA;IAFe,aAAK,QAEpB,CAAA;;;ICNU,UAAE,GAAG,EAAE,CAAC;IACnB;QAAAC;QAEAC,CAACA;QAADD,SAACA;IAADA,CAACA,AAFD,IAEC;IAFY,UAAE,KAEd,CAAA;IAEU,iBAAS,GAAG,IAAI,EAAE,EAAE,CAAC;IAChC;QACIE,MAAMA,CAACA,iBAASA,CAACA;IACrBA,CAACA;IAFe,UAAE,KAEjB,CAAA;IAEU,UAAE,GAAG,EAAE,CAAC,KAAK,CAAC;IACd,UAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlModuleMultifolderSpecifyOutputFile/amd/maprootUrlModuleMultifolderSpecifyOutputFile.sourcemap.txt b/tests/baselines/reference/project/maprootUrlModuleMultifolderSpecifyOutputFile/amd/maprootUrlModuleMultifolderSpecifyOutputFile.sourcemap.txt index 1fce6af3084..b45d5fdd6ef 100644 --- a/tests/baselines/reference/project/maprootUrlModuleMultifolderSpecifyOutputFile/amd/maprootUrlModuleMultifolderSpecifyOutputFile.sourcemap.txt +++ b/tests/baselines/reference/project/maprootUrlModuleMultifolderSpecifyOutputFile/amd/maprootUrlModuleMultifolderSpecifyOutputFile.sourcemap.txt @@ -571,6 +571,557 @@ sourceFile:file:///tests/cases/projects/outputdir_module_multifolder/test.ts JsFile: test.js mapUrl: http://www.typescriptlang.org/test.js.map sourceRoot: -sources: +sources: file:///tests/cases/projects/outputdir_module_multifolder/ref/m1.ts,file:///tests/cases/projects/outputdir_module_multifolder_ref/m2.ts,file:///tests/cases/projects/outputdir_module_multifolder/test.ts =================================================================== +------------------------------------------------------------------- +emittedFile:bin/test.js +sourceFile:file:///tests/cases/projects/outputdir_module_multifolder/ref/m1.ts +------------------------------------------------------------------- +>>>define("ref/m1", ["require", "exports"], function (require, exports) { +>>> exports.m1_a1 = 10; +1 >^^^^ +2 > ^^^^^^^^^^^^^ +3 > ^^^ +4 > ^^ +5 > ^ +6 > ^^^^^^^^-> +1 >export var +2 > m1_a1 +3 > = +4 > 10 +5 > ; +1 >Emitted(2, 5) Source(1, 12) + SourceIndex(0) +2 >Emitted(2, 18) Source(1, 17) + SourceIndex(0) +3 >Emitted(2, 21) Source(1, 20) + SourceIndex(0) +4 >Emitted(2, 23) Source(1, 22) + SourceIndex(0) +5 >Emitted(2, 24) Source(1, 23) + SourceIndex(0) +--- +>>> var m1_c1 = (function () { +1->^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^^^^-> +1-> + > +1->Emitted(3, 5) Source(2, 1) + SourceIndex(0) +--- +>>> function m1_c1() { +1->^^^^^^^^ +2 > ^^-> +1-> +1->Emitted(4, 9) Source(2, 1) + SourceIndex(0) name (m1_c1) +--- +>>> } +1->^^^^^^^^ +2 > ^ +3 > ^^^^^^^^^^^^^-> +1->export class m1_c1 { + > public m1_c1_p1: number; + > +2 > } +1->Emitted(5, 9) Source(4, 1) + SourceIndex(0) name (m1_c1.constructor) +2 >Emitted(5, 10) Source(4, 2) + SourceIndex(0) name (m1_c1.constructor) +--- +>>> return m1_c1; +1->^^^^^^^^ +2 > ^^^^^^^^^^^^ +1-> +2 > } +1->Emitted(6, 9) Source(4, 1) + SourceIndex(0) name (m1_c1) +2 >Emitted(6, 21) Source(4, 2) + SourceIndex(0) name (m1_c1) +--- +>>> })(); +1 >^^^^ +2 > ^ +3 > +4 > ^^^^ +5 > ^^^^^^^^^^^^^^^^^^-> +1 > +2 > } +3 > +4 > export class m1_c1 { + > public m1_c1_p1: number; + > } +1 >Emitted(7, 5) Source(4, 1) + SourceIndex(0) name (m1_c1) +2 >Emitted(7, 6) Source(4, 2) + SourceIndex(0) name (m1_c1) +3 >Emitted(7, 6) Source(2, 1) + SourceIndex(0) +4 >Emitted(7, 10) Source(4, 2) + SourceIndex(0) +--- +>>> exports.m1_c1 = m1_c1; +1->^^^^ +2 > ^^^^^^^^^^^^^ +3 > ^^^^^^^^ +4 > ^ +5 > ^^^^^^^^^^^^^^-> +1-> +2 > m1_c1 +3 > { + > public m1_c1_p1: number; + > } +4 > +1->Emitted(8, 5) Source(2, 14) + SourceIndex(0) +2 >Emitted(8, 18) Source(2, 19) + SourceIndex(0) +3 >Emitted(8, 26) Source(4, 2) + SourceIndex(0) +4 >Emitted(8, 27) Source(4, 2) + SourceIndex(0) +--- +>>> exports.m1_instance1 = new m1_c1(); +1->^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^ +3 > ^^^ +4 > ^^^^ +5 > ^^^^^ +6 > ^^ +7 > ^ +1-> + > + >export var +2 > m1_instance1 +3 > = +4 > new +5 > m1_c1 +6 > () +7 > ; +1->Emitted(9, 5) Source(6, 12) + SourceIndex(0) +2 >Emitted(9, 25) Source(6, 24) + SourceIndex(0) +3 >Emitted(9, 28) Source(6, 27) + SourceIndex(0) +4 >Emitted(9, 32) Source(6, 31) + SourceIndex(0) +5 >Emitted(9, 37) Source(6, 36) + SourceIndex(0) +6 >Emitted(9, 39) Source(6, 38) + SourceIndex(0) +7 >Emitted(9, 40) Source(6, 39) + SourceIndex(0) +--- +>>> function m1_f1() { +1 >^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +1 > + > +1 >Emitted(10, 5) Source(7, 1) + SourceIndex(0) +--- +>>> return exports.m1_instance1; +1->^^^^^^^^ +2 > ^^^^^^ +3 > ^ +4 > ^^^^^^^^^^^^^^^^^^^^ +5 > ^ +1->export function m1_f1() { + > +2 > return +3 > +4 > m1_instance1 +5 > ; +1->Emitted(11, 9) Source(8, 5) + SourceIndex(0) name (m1_f1) +2 >Emitted(11, 15) Source(8, 11) + SourceIndex(0) name (m1_f1) +3 >Emitted(11, 16) Source(8, 12) + SourceIndex(0) name (m1_f1) +4 >Emitted(11, 36) Source(8, 24) + SourceIndex(0) name (m1_f1) +5 >Emitted(11, 37) Source(8, 25) + SourceIndex(0) name (m1_f1) +--- +>>> } +1 >^^^^ +2 > ^ +3 > ^^^^^^^^^^^^^^^^^^^^^^-> +1 > + > +2 > } +1 >Emitted(12, 5) Source(9, 1) + SourceIndex(0) name (m1_f1) +2 >Emitted(12, 6) Source(9, 2) + SourceIndex(0) name (m1_f1) +--- +>>> exports.m1_f1 = m1_f1; +1->^^^^ +2 > ^^^^^^^^^^^^^ +3 > ^^^^^^^^ +4 > ^ +1-> +2 > m1_f1 +3 > () { + > return m1_instance1; + > } +4 > +1->Emitted(13, 5) Source(7, 17) + SourceIndex(0) +2 >Emitted(13, 18) Source(7, 22) + SourceIndex(0) +3 >Emitted(13, 26) Source(9, 2) + SourceIndex(0) +4 >Emitted(13, 27) Source(9, 2) + SourceIndex(0) +--- +------------------------------------------------------------------- +emittedFile:bin/test.js +sourceFile:file:///tests/cases/projects/outputdir_module_multifolder_ref/m2.ts +------------------------------------------------------------------- +>>>}); +>>>define("../outputdir_module_multifolder_ref/m2", ["require", "exports"], function (require, exports) { +>>> exports.m2_a1 = 10; +1 >^^^^ +2 > ^^^^^^^^^^^^^ +3 > ^^^ +4 > ^^ +5 > ^ +6 > ^^^^^^^^-> +1 >export var +2 > m2_a1 +3 > = +4 > 10 +5 > ; +1 >Emitted(16, 5) Source(1, 12) + SourceIndex(1) +2 >Emitted(16, 18) Source(1, 17) + SourceIndex(1) +3 >Emitted(16, 21) Source(1, 20) + SourceIndex(1) +4 >Emitted(16, 23) Source(1, 22) + SourceIndex(1) +5 >Emitted(16, 24) Source(1, 23) + SourceIndex(1) +--- +>>> var m2_c1 = (function () { +1->^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^^^^-> +1-> + > +1->Emitted(17, 5) Source(2, 1) + SourceIndex(1) +--- +>>> function m2_c1() { +1->^^^^^^^^ +2 > ^^-> +1-> +1->Emitted(18, 9) Source(2, 1) + SourceIndex(1) name (m2_c1) +--- +>>> } +1->^^^^^^^^ +2 > ^ +3 > ^^^^^^^^^^^^^-> +1->export class m2_c1 { + > public m2_c1_p1: number; + > +2 > } +1->Emitted(19, 9) Source(4, 1) + SourceIndex(1) name (m2_c1.constructor) +2 >Emitted(19, 10) Source(4, 2) + SourceIndex(1) name (m2_c1.constructor) +--- +>>> return m2_c1; +1->^^^^^^^^ +2 > ^^^^^^^^^^^^ +1-> +2 > } +1->Emitted(20, 9) Source(4, 1) + SourceIndex(1) name (m2_c1) +2 >Emitted(20, 21) Source(4, 2) + SourceIndex(1) name (m2_c1) +--- +>>> })(); +1 >^^^^ +2 > ^ +3 > +4 > ^^^^ +5 > ^^^^^^^^^^^^^^^^^^-> +1 > +2 > } +3 > +4 > export class m2_c1 { + > public m2_c1_p1: number; + > } +1 >Emitted(21, 5) Source(4, 1) + SourceIndex(1) name (m2_c1) +2 >Emitted(21, 6) Source(4, 2) + SourceIndex(1) name (m2_c1) +3 >Emitted(21, 6) Source(2, 1) + SourceIndex(1) +4 >Emitted(21, 10) Source(4, 2) + SourceIndex(1) +--- +>>> exports.m2_c1 = m2_c1; +1->^^^^ +2 > ^^^^^^^^^^^^^ +3 > ^^^^^^^^ +4 > ^ +5 > ^^^^^^^^^^^^^^-> +1-> +2 > m2_c1 +3 > { + > public m2_c1_p1: number; + > } +4 > +1->Emitted(22, 5) Source(2, 14) + SourceIndex(1) +2 >Emitted(22, 18) Source(2, 19) + SourceIndex(1) +3 >Emitted(22, 26) Source(4, 2) + SourceIndex(1) +4 >Emitted(22, 27) Source(4, 2) + SourceIndex(1) +--- +>>> exports.m2_instance1 = new m2_c1(); +1->^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^ +3 > ^^^ +4 > ^^^^ +5 > ^^^^^ +6 > ^^ +7 > ^ +1-> + > + >export var +2 > m2_instance1 +3 > = +4 > new +5 > m2_c1 +6 > () +7 > ; +1->Emitted(23, 5) Source(6, 12) + SourceIndex(1) +2 >Emitted(23, 25) Source(6, 24) + SourceIndex(1) +3 >Emitted(23, 28) Source(6, 27) + SourceIndex(1) +4 >Emitted(23, 32) Source(6, 31) + SourceIndex(1) +5 >Emitted(23, 37) Source(6, 36) + SourceIndex(1) +6 >Emitted(23, 39) Source(6, 38) + SourceIndex(1) +7 >Emitted(23, 40) Source(6, 39) + SourceIndex(1) +--- +>>> function m2_f1() { +1 >^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +1 > + > +1 >Emitted(24, 5) Source(7, 1) + SourceIndex(1) +--- +>>> return exports.m2_instance1; +1->^^^^^^^^ +2 > ^^^^^^ +3 > ^ +4 > ^^^^^^^^^^^^^^^^^^^^ +5 > ^ +1->export function m2_f1() { + > +2 > return +3 > +4 > m2_instance1 +5 > ; +1->Emitted(25, 9) Source(8, 5) + SourceIndex(1) name (m2_f1) +2 >Emitted(25, 15) Source(8, 11) + SourceIndex(1) name (m2_f1) +3 >Emitted(25, 16) Source(8, 12) + SourceIndex(1) name (m2_f1) +4 >Emitted(25, 36) Source(8, 24) + SourceIndex(1) name (m2_f1) +5 >Emitted(25, 37) Source(8, 25) + SourceIndex(1) name (m2_f1) +--- +>>> } +1 >^^^^ +2 > ^ +3 > ^^^^^^^^^^^^^^^^^^^^^^-> +1 > + > +2 > } +1 >Emitted(26, 5) Source(9, 1) + SourceIndex(1) name (m2_f1) +2 >Emitted(26, 6) Source(9, 2) + SourceIndex(1) name (m2_f1) +--- +>>> exports.m2_f1 = m2_f1; +1->^^^^ +2 > ^^^^^^^^^^^^^ +3 > ^^^^^^^^ +4 > ^ +1-> +2 > m2_f1 +3 > () { + > return m2_instance1; + > } +4 > +1->Emitted(27, 5) Source(7, 17) + SourceIndex(1) +2 >Emitted(27, 18) Source(7, 22) + SourceIndex(1) +3 >Emitted(27, 26) Source(9, 2) + SourceIndex(1) +4 >Emitted(27, 27) Source(9, 2) + SourceIndex(1) +--- +------------------------------------------------------------------- +emittedFile:bin/test.js +sourceFile:file:///tests/cases/projects/outputdir_module_multifolder/test.ts +------------------------------------------------------------------- +>>>}); +>>>define("test", ["require", "exports", "ref/m1", "../outputdir_module_multifolder_ref/m2"], function (require, exports, m1, m2) { +>>> exports.a1 = 10; +1 >^^^^ +2 > ^^^^^^^^^^ +3 > ^^^ +4 > ^^ +5 > ^ +6 > ^^^^^^^^-> +1 >import m1 = require("ref/m1"); + >import m2 = require("../outputdir_module_multifolder_ref/m2"); + >export var +2 > a1 +3 > = +4 > 10 +5 > ; +1 >Emitted(30, 5) Source(3, 12) + SourceIndex(2) +2 >Emitted(30, 15) Source(3, 14) + SourceIndex(2) +3 >Emitted(30, 18) Source(3, 17) + SourceIndex(2) +4 >Emitted(30, 20) Source(3, 19) + SourceIndex(2) +5 >Emitted(30, 21) Source(3, 20) + SourceIndex(2) +--- +>>> var c1 = (function () { +1->^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^-> +1-> + > +1->Emitted(31, 5) Source(4, 1) + SourceIndex(2) +--- +>>> function c1() { +1->^^^^^^^^ +2 > ^^-> +1-> +1->Emitted(32, 9) Source(4, 1) + SourceIndex(2) name (c1) +--- +>>> } +1->^^^^^^^^ +2 > ^ +3 > ^^^^^^^^^^-> +1->export class c1 { + > public p1: number; + > +2 > } +1->Emitted(33, 9) Source(6, 1) + SourceIndex(2) name (c1.constructor) +2 >Emitted(33, 10) Source(6, 2) + SourceIndex(2) name (c1.constructor) +--- +>>> return c1; +1->^^^^^^^^ +2 > ^^^^^^^^^ +1-> +2 > } +1->Emitted(34, 9) Source(6, 1) + SourceIndex(2) name (c1) +2 >Emitted(34, 18) Source(6, 2) + SourceIndex(2) name (c1) +--- +>>> })(); +1 >^^^^ +2 > ^ +3 > +4 > ^^^^ +5 > ^^^^^^^^^^^^-> +1 > +2 > } +3 > +4 > export class c1 { + > public p1: number; + > } +1 >Emitted(35, 5) Source(6, 1) + SourceIndex(2) name (c1) +2 >Emitted(35, 6) Source(6, 2) + SourceIndex(2) name (c1) +3 >Emitted(35, 6) Source(4, 1) + SourceIndex(2) +4 >Emitted(35, 10) Source(6, 2) + SourceIndex(2) +--- +>>> exports.c1 = c1; +1->^^^^ +2 > ^^^^^^^^^^ +3 > ^^^^^ +4 > ^ +5 > ^^^^^^^^^^^^^^-> +1-> +2 > c1 +3 > { + > public p1: number; + > } +4 > +1->Emitted(36, 5) Source(4, 14) + SourceIndex(2) +2 >Emitted(36, 15) Source(4, 16) + SourceIndex(2) +3 >Emitted(36, 20) Source(6, 2) + SourceIndex(2) +4 >Emitted(36, 21) Source(6, 2) + SourceIndex(2) +--- +>>> exports.instance1 = new c1(); +1->^^^^ +2 > ^^^^^^^^^^^^^^^^^ +3 > ^^^ +4 > ^^^^ +5 > ^^ +6 > ^^ +7 > ^ +1-> + > + >export var +2 > instance1 +3 > = +4 > new +5 > c1 +6 > () +7 > ; +1->Emitted(37, 5) Source(8, 12) + SourceIndex(2) +2 >Emitted(37, 22) Source(8, 21) + SourceIndex(2) +3 >Emitted(37, 25) Source(8, 24) + SourceIndex(2) +4 >Emitted(37, 29) Source(8, 28) + SourceIndex(2) +5 >Emitted(37, 31) Source(8, 30) + SourceIndex(2) +6 >Emitted(37, 33) Source(8, 32) + SourceIndex(2) +7 >Emitted(37, 34) Source(8, 33) + SourceIndex(2) +--- +>>> function f1() { +1 >^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +1 > + > +1 >Emitted(38, 5) Source(9, 1) + SourceIndex(2) +--- +>>> return exports.instance1; +1->^^^^^^^^ +2 > ^^^^^^ +3 > ^ +4 > ^^^^^^^^^^^^^^^^^ +5 > ^ +1->export function f1() { + > +2 > return +3 > +4 > instance1 +5 > ; +1->Emitted(39, 9) Source(10, 5) + SourceIndex(2) name (f1) +2 >Emitted(39, 15) Source(10, 11) + SourceIndex(2) name (f1) +3 >Emitted(39, 16) Source(10, 12) + SourceIndex(2) name (f1) +4 >Emitted(39, 33) Source(10, 21) + SourceIndex(2) name (f1) +5 >Emitted(39, 34) Source(10, 22) + SourceIndex(2) name (f1) +--- +>>> } +1 >^^^^ +2 > ^ +3 > ^^^^^^^^^^^^^^^^-> +1 > + > +2 > } +1 >Emitted(40, 5) Source(11, 1) + SourceIndex(2) name (f1) +2 >Emitted(40, 6) Source(11, 2) + SourceIndex(2) name (f1) +--- +>>> exports.f1 = f1; +1->^^^^ +2 > ^^^^^^^^^^ +3 > ^^^^^ +4 > ^ +5 > ^^^^^^^-> +1-> +2 > f1 +3 > () { + > return instance1; + > } +4 > +1->Emitted(41, 5) Source(9, 17) + SourceIndex(2) +2 >Emitted(41, 15) Source(9, 19) + SourceIndex(2) +3 >Emitted(41, 20) Source(11, 2) + SourceIndex(2) +4 >Emitted(41, 21) Source(11, 2) + SourceIndex(2) +--- +>>> exports.a2 = m1.m1_c1; +1->^^^^ +2 > ^^^^^^^^^^ +3 > ^^^ +4 > ^^ +5 > ^ +6 > ^^^^^ +7 > ^ +8 > ^-> +1-> + > + >export var +2 > a2 +3 > = +4 > m1 +5 > . +6 > m1_c1 +7 > ; +1->Emitted(42, 5) Source(13, 12) + SourceIndex(2) +2 >Emitted(42, 15) Source(13, 14) + SourceIndex(2) +3 >Emitted(42, 18) Source(13, 17) + SourceIndex(2) +4 >Emitted(42, 20) Source(13, 19) + SourceIndex(2) +5 >Emitted(42, 21) Source(13, 20) + SourceIndex(2) +6 >Emitted(42, 26) Source(13, 25) + SourceIndex(2) +7 >Emitted(42, 27) Source(13, 26) + SourceIndex(2) +--- +>>> exports.a3 = m2.m2_c1; +1->^^^^ +2 > ^^^^^^^^^^ +3 > ^^^ +4 > ^^ +5 > ^ +6 > ^^^^^ +7 > ^ +1-> + >export var +2 > a3 +3 > = +4 > m2 +5 > . +6 > m2_c1 +7 > ; +1->Emitted(43, 5) Source(14, 12) + SourceIndex(2) +2 >Emitted(43, 15) Source(14, 14) + SourceIndex(2) +3 >Emitted(43, 18) Source(14, 17) + SourceIndex(2) +4 >Emitted(43, 20) Source(14, 19) + SourceIndex(2) +5 >Emitted(43, 21) Source(14, 20) + SourceIndex(2) +6 >Emitted(43, 26) Source(14, 25) + SourceIndex(2) +7 >Emitted(43, 27) Source(14, 26) + SourceIndex(2) +--- +>>>}); >>>//# sourceMappingURL=http://www.typescriptlang.org/test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlModuleMultifolderSpecifyOutputFile/node/bin/test.d.ts b/tests/baselines/reference/project/maprootUrlModuleMultifolderSpecifyOutputFile/node/bin/test.d.ts deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/tests/baselines/reference/project/maprootUrlModuleMultifolderSpecifyOutputFile/node/bin/test.js b/tests/baselines/reference/project/maprootUrlModuleMultifolderSpecifyOutputFile/node/bin/test.js deleted file mode 100644 index 52f1b822100..00000000000 --- a/tests/baselines/reference/project/maprootUrlModuleMultifolderSpecifyOutputFile/node/bin/test.js +++ /dev/null @@ -1 +0,0 @@ -//# sourceMappingURL=http://www.typescriptlang.org/test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlModuleMultifolderSpecifyOutputFile/node/bin/test.js.map b/tests/baselines/reference/project/maprootUrlModuleMultifolderSpecifyOutputFile/node/bin/test.js.map index c1e0281a2ab..1c42486b782 100644 --- a/tests/baselines/reference/project/maprootUrlModuleMultifolderSpecifyOutputFile/node/bin/test.js.map +++ b/tests/baselines/reference/project/maprootUrlModuleMultifolderSpecifyOutputFile/node/bin/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"","sources":[],"names":[],"mappings":""} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"","sources":["file:///tests/cases/projects/outputdir_module_multifolder/ref/m1.ts","file:///tests/cases/projects/outputdir_module_multifolder_ref/m2.ts","file:///tests/cases/projects/outputdir_module_multifolder/test.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlModuleMultifolderSpecifyOutputFile/node/maprootUrlModuleMultifolderSpecifyOutputFile.sourcemap.txt b/tests/baselines/reference/project/maprootUrlModuleMultifolderSpecifyOutputFile/node/maprootUrlModuleMultifolderSpecifyOutputFile.sourcemap.txt index aaf57c9d055..4dfb2e5d394 100644 --- a/tests/baselines/reference/project/maprootUrlModuleMultifolderSpecifyOutputFile/node/maprootUrlModuleMultifolderSpecifyOutputFile.sourcemap.txt +++ b/tests/baselines/reference/project/maprootUrlModuleMultifolderSpecifyOutputFile/node/maprootUrlModuleMultifolderSpecifyOutputFile.sourcemap.txt @@ -615,6 +615,6 @@ sourceFile:file:///tests/cases/projects/outputdir_module_multifolder/test.ts JsFile: test.js mapUrl: http://www.typescriptlang.org/test.js.map sourceRoot: -sources: +sources: file:///tests/cases/projects/outputdir_module_multifolder/ref/m1.ts,file:///tests/cases/projects/outputdir_module_multifolder_ref/m2.ts,file:///tests/cases/projects/outputdir_module_multifolder/test.ts =================================================================== >>>//# sourceMappingURL=http://www.typescriptlang.org/test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlModuleSimpleSpecifyOutputFile/amd/bin/test.d.ts b/tests/baselines/reference/project/maprootUrlModuleSimpleSpecifyOutputFile/amd/bin/test.d.ts deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/tests/baselines/reference/project/maprootUrlModuleSimpleSpecifyOutputFile/amd/bin/test.js b/tests/baselines/reference/project/maprootUrlModuleSimpleSpecifyOutputFile/amd/bin/test.js deleted file mode 100644 index 52f1b822100..00000000000 --- a/tests/baselines/reference/project/maprootUrlModuleSimpleSpecifyOutputFile/amd/bin/test.js +++ /dev/null @@ -1 +0,0 @@ -//# sourceMappingURL=http://www.typescriptlang.org/test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlModuleSimpleSpecifyOutputFile/amd/bin/test.js.map b/tests/baselines/reference/project/maprootUrlModuleSimpleSpecifyOutputFile/amd/bin/test.js.map index c1e0281a2ab..445268f27c1 100644 --- a/tests/baselines/reference/project/maprootUrlModuleSimpleSpecifyOutputFile/amd/bin/test.js.map +++ b/tests/baselines/reference/project/maprootUrlModuleSimpleSpecifyOutputFile/amd/bin/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"","sources":[],"names":[],"mappings":""} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"","sources":["file:///tests/cases/projects/outputdir_module_simple/m1.ts","file:///tests/cases/projects/outputdir_module_simple/test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","c1","c1.constructor","f1"],"mappings":";IAAW,aAAK,GAAG,EAAE,CAAC;IACtB;QAAAA;QAEAC,CAACA;QAADD,YAACA;IAADA,CAACA,AAFD,IAEC;IAFY,aAAK,QAEjB,CAAA;IAEU,oBAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACIE,MAAMA,CAACA,oBAAYA,CAACA;IACxBA,CAACA;IAFe,aAAK,QAEpB,CAAA;;;ICPU,UAAE,GAAG,EAAE,CAAC;IACnB;QAAAC;QAEAC,CAACA;QAADD,SAACA;IAADA,CAACA,AAFD,IAEC;IAFY,UAAE,KAEd,CAAA;IAEU,iBAAS,GAAG,IAAI,EAAE,EAAE,CAAC;IAChC;QACIE,MAAMA,CAACA,iBAASA,CAACA;IACrBA,CAACA;IAFe,UAAE,KAEjB,CAAA;IAEU,UAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlModuleSimpleSpecifyOutputFile/amd/maprootUrlModuleSimpleSpecifyOutputFile.sourcemap.txt b/tests/baselines/reference/project/maprootUrlModuleSimpleSpecifyOutputFile/amd/maprootUrlModuleSimpleSpecifyOutputFile.sourcemap.txt index 7c3fae48716..2268138862a 100644 --- a/tests/baselines/reference/project/maprootUrlModuleSimpleSpecifyOutputFile/amd/maprootUrlModuleSimpleSpecifyOutputFile.sourcemap.txt +++ b/tests/baselines/reference/project/maprootUrlModuleSimpleSpecifyOutputFile/amd/maprootUrlModuleSimpleSpecifyOutputFile.sourcemap.txt @@ -373,6 +373,365 @@ sourceFile:file:///tests/cases/projects/outputdir_module_simple/test.ts JsFile: test.js mapUrl: http://www.typescriptlang.org/test.js.map sourceRoot: -sources: +sources: file:///tests/cases/projects/outputdir_module_simple/m1.ts,file:///tests/cases/projects/outputdir_module_simple/test.ts =================================================================== +------------------------------------------------------------------- +emittedFile:bin/test.js +sourceFile:file:///tests/cases/projects/outputdir_module_simple/m1.ts +------------------------------------------------------------------- +>>>define("m1", ["require", "exports"], function (require, exports) { +>>> exports.m1_a1 = 10; +1 >^^^^ +2 > ^^^^^^^^^^^^^ +3 > ^^^ +4 > ^^ +5 > ^ +6 > ^^^^^^^^-> +1 >export var +2 > m1_a1 +3 > = +4 > 10 +5 > ; +1 >Emitted(2, 5) Source(1, 12) + SourceIndex(0) +2 >Emitted(2, 18) Source(1, 17) + SourceIndex(0) +3 >Emitted(2, 21) Source(1, 20) + SourceIndex(0) +4 >Emitted(2, 23) Source(1, 22) + SourceIndex(0) +5 >Emitted(2, 24) Source(1, 23) + SourceIndex(0) +--- +>>> var m1_c1 = (function () { +1->^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^^^^-> +1-> + > +1->Emitted(3, 5) Source(2, 1) + SourceIndex(0) +--- +>>> function m1_c1() { +1->^^^^^^^^ +2 > ^^-> +1-> +1->Emitted(4, 9) Source(2, 1) + SourceIndex(0) name (m1_c1) +--- +>>> } +1->^^^^^^^^ +2 > ^ +3 > ^^^^^^^^^^^^^-> +1->export class m1_c1 { + > public m1_c1_p1: number; + > +2 > } +1->Emitted(5, 9) Source(4, 1) + SourceIndex(0) name (m1_c1.constructor) +2 >Emitted(5, 10) Source(4, 2) + SourceIndex(0) name (m1_c1.constructor) +--- +>>> return m1_c1; +1->^^^^^^^^ +2 > ^^^^^^^^^^^^ +1-> +2 > } +1->Emitted(6, 9) Source(4, 1) + SourceIndex(0) name (m1_c1) +2 >Emitted(6, 21) Source(4, 2) + SourceIndex(0) name (m1_c1) +--- +>>> })(); +1 >^^^^ +2 > ^ +3 > +4 > ^^^^ +5 > ^^^^^^^^^^^^^^^^^^-> +1 > +2 > } +3 > +4 > export class m1_c1 { + > public m1_c1_p1: number; + > } +1 >Emitted(7, 5) Source(4, 1) + SourceIndex(0) name (m1_c1) +2 >Emitted(7, 6) Source(4, 2) + SourceIndex(0) name (m1_c1) +3 >Emitted(7, 6) Source(2, 1) + SourceIndex(0) +4 >Emitted(7, 10) Source(4, 2) + SourceIndex(0) +--- +>>> exports.m1_c1 = m1_c1; +1->^^^^ +2 > ^^^^^^^^^^^^^ +3 > ^^^^^^^^ +4 > ^ +5 > ^^^^^^^^^^^^^^-> +1-> +2 > m1_c1 +3 > { + > public m1_c1_p1: number; + > } +4 > +1->Emitted(8, 5) Source(2, 14) + SourceIndex(0) +2 >Emitted(8, 18) Source(2, 19) + SourceIndex(0) +3 >Emitted(8, 26) Source(4, 2) + SourceIndex(0) +4 >Emitted(8, 27) Source(4, 2) + SourceIndex(0) +--- +>>> exports.m1_instance1 = new m1_c1(); +1->^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^ +3 > ^^^ +4 > ^^^^ +5 > ^^^^^ +6 > ^^ +7 > ^ +1-> + > + >export var +2 > m1_instance1 +3 > = +4 > new +5 > m1_c1 +6 > () +7 > ; +1->Emitted(9, 5) Source(6, 12) + SourceIndex(0) +2 >Emitted(9, 25) Source(6, 24) + SourceIndex(0) +3 >Emitted(9, 28) Source(6, 27) + SourceIndex(0) +4 >Emitted(9, 32) Source(6, 31) + SourceIndex(0) +5 >Emitted(9, 37) Source(6, 36) + SourceIndex(0) +6 >Emitted(9, 39) Source(6, 38) + SourceIndex(0) +7 >Emitted(9, 40) Source(6, 39) + SourceIndex(0) +--- +>>> function m1_f1() { +1 >^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +1 > + > +1 >Emitted(10, 5) Source(7, 1) + SourceIndex(0) +--- +>>> return exports.m1_instance1; +1->^^^^^^^^ +2 > ^^^^^^ +3 > ^ +4 > ^^^^^^^^^^^^^^^^^^^^ +5 > ^ +1->export function m1_f1() { + > +2 > return +3 > +4 > m1_instance1 +5 > ; +1->Emitted(11, 9) Source(8, 5) + SourceIndex(0) name (m1_f1) +2 >Emitted(11, 15) Source(8, 11) + SourceIndex(0) name (m1_f1) +3 >Emitted(11, 16) Source(8, 12) + SourceIndex(0) name (m1_f1) +4 >Emitted(11, 36) Source(8, 24) + SourceIndex(0) name (m1_f1) +5 >Emitted(11, 37) Source(8, 25) + SourceIndex(0) name (m1_f1) +--- +>>> } +1 >^^^^ +2 > ^ +3 > ^^^^^^^^^^^^^^^^^^^^^^-> +1 > + > +2 > } +1 >Emitted(12, 5) Source(9, 1) + SourceIndex(0) name (m1_f1) +2 >Emitted(12, 6) Source(9, 2) + SourceIndex(0) name (m1_f1) +--- +>>> exports.m1_f1 = m1_f1; +1->^^^^ +2 > ^^^^^^^^^^^^^ +3 > ^^^^^^^^ +4 > ^ +1-> +2 > m1_f1 +3 > () { + > return m1_instance1; + > } +4 > +1->Emitted(13, 5) Source(7, 17) + SourceIndex(0) +2 >Emitted(13, 18) Source(7, 22) + SourceIndex(0) +3 >Emitted(13, 26) Source(9, 2) + SourceIndex(0) +4 >Emitted(13, 27) Source(9, 2) + SourceIndex(0) +--- +------------------------------------------------------------------- +emittedFile:bin/test.js +sourceFile:file:///tests/cases/projects/outputdir_module_simple/test.ts +------------------------------------------------------------------- +>>>}); +>>>define("test", ["require", "exports", "m1"], function (require, exports, m1) { +>>> exports.a1 = 10; +1 >^^^^ +2 > ^^^^^^^^^^ +3 > ^^^ +4 > ^^ +5 > ^ +6 > ^^^^^^^^-> +1 >import m1 = require("m1"); + >export var +2 > a1 +3 > = +4 > 10 +5 > ; +1 >Emitted(16, 5) Source(2, 12) + SourceIndex(1) +2 >Emitted(16, 15) Source(2, 14) + SourceIndex(1) +3 >Emitted(16, 18) Source(2, 17) + SourceIndex(1) +4 >Emitted(16, 20) Source(2, 19) + SourceIndex(1) +5 >Emitted(16, 21) Source(2, 20) + SourceIndex(1) +--- +>>> var c1 = (function () { +1->^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^-> +1-> + > +1->Emitted(17, 5) Source(3, 1) + SourceIndex(1) +--- +>>> function c1() { +1->^^^^^^^^ +2 > ^^-> +1-> +1->Emitted(18, 9) Source(3, 1) + SourceIndex(1) name (c1) +--- +>>> } +1->^^^^^^^^ +2 > ^ +3 > ^^^^^^^^^^-> +1->export class c1 { + > public p1: number; + > +2 > } +1->Emitted(19, 9) Source(5, 1) + SourceIndex(1) name (c1.constructor) +2 >Emitted(19, 10) Source(5, 2) + SourceIndex(1) name (c1.constructor) +--- +>>> return c1; +1->^^^^^^^^ +2 > ^^^^^^^^^ +1-> +2 > } +1->Emitted(20, 9) Source(5, 1) + SourceIndex(1) name (c1) +2 >Emitted(20, 18) Source(5, 2) + SourceIndex(1) name (c1) +--- +>>> })(); +1 >^^^^ +2 > ^ +3 > +4 > ^^^^ +5 > ^^^^^^^^^^^^-> +1 > +2 > } +3 > +4 > export class c1 { + > public p1: number; + > } +1 >Emitted(21, 5) Source(5, 1) + SourceIndex(1) name (c1) +2 >Emitted(21, 6) Source(5, 2) + SourceIndex(1) name (c1) +3 >Emitted(21, 6) Source(3, 1) + SourceIndex(1) +4 >Emitted(21, 10) Source(5, 2) + SourceIndex(1) +--- +>>> exports.c1 = c1; +1->^^^^ +2 > ^^^^^^^^^^ +3 > ^^^^^ +4 > ^ +5 > ^^^^^^^^^^^^^^-> +1-> +2 > c1 +3 > { + > public p1: number; + > } +4 > +1->Emitted(22, 5) Source(3, 14) + SourceIndex(1) +2 >Emitted(22, 15) Source(3, 16) + SourceIndex(1) +3 >Emitted(22, 20) Source(5, 2) + SourceIndex(1) +4 >Emitted(22, 21) Source(5, 2) + SourceIndex(1) +--- +>>> exports.instance1 = new c1(); +1->^^^^ +2 > ^^^^^^^^^^^^^^^^^ +3 > ^^^ +4 > ^^^^ +5 > ^^ +6 > ^^ +7 > ^ +1-> + > + >export var +2 > instance1 +3 > = +4 > new +5 > c1 +6 > () +7 > ; +1->Emitted(23, 5) Source(7, 12) + SourceIndex(1) +2 >Emitted(23, 22) Source(7, 21) + SourceIndex(1) +3 >Emitted(23, 25) Source(7, 24) + SourceIndex(1) +4 >Emitted(23, 29) Source(7, 28) + SourceIndex(1) +5 >Emitted(23, 31) Source(7, 30) + SourceIndex(1) +6 >Emitted(23, 33) Source(7, 32) + SourceIndex(1) +7 >Emitted(23, 34) Source(7, 33) + SourceIndex(1) +--- +>>> function f1() { +1 >^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +1 > + > +1 >Emitted(24, 5) Source(8, 1) + SourceIndex(1) +--- +>>> return exports.instance1; +1->^^^^^^^^ +2 > ^^^^^^ +3 > ^ +4 > ^^^^^^^^^^^^^^^^^ +5 > ^ +1->export function f1() { + > +2 > return +3 > +4 > instance1 +5 > ; +1->Emitted(25, 9) Source(9, 5) + SourceIndex(1) name (f1) +2 >Emitted(25, 15) Source(9, 11) + SourceIndex(1) name (f1) +3 >Emitted(25, 16) Source(9, 12) + SourceIndex(1) name (f1) +4 >Emitted(25, 33) Source(9, 21) + SourceIndex(1) name (f1) +5 >Emitted(25, 34) Source(9, 22) + SourceIndex(1) name (f1) +--- +>>> } +1 >^^^^ +2 > ^ +3 > ^^^^^^^^^^^^^^^^-> +1 > + > +2 > } +1 >Emitted(26, 5) Source(10, 1) + SourceIndex(1) name (f1) +2 >Emitted(26, 6) Source(10, 2) + SourceIndex(1) name (f1) +--- +>>> exports.f1 = f1; +1->^^^^ +2 > ^^^^^^^^^^ +3 > ^^^^^ +4 > ^ +5 > ^^^^^^^-> +1-> +2 > f1 +3 > () { + > return instance1; + > } +4 > +1->Emitted(27, 5) Source(8, 17) + SourceIndex(1) +2 >Emitted(27, 15) Source(8, 19) + SourceIndex(1) +3 >Emitted(27, 20) Source(10, 2) + SourceIndex(1) +4 >Emitted(27, 21) Source(10, 2) + SourceIndex(1) +--- +>>> exports.a2 = m1.m1_c1; +1->^^^^ +2 > ^^^^^^^^^^ +3 > ^^^ +4 > ^^ +5 > ^ +6 > ^^^^^ +7 > ^ +1-> + > + >export var +2 > a2 +3 > = +4 > m1 +5 > . +6 > m1_c1 +7 > ; +1->Emitted(28, 5) Source(12, 12) + SourceIndex(1) +2 >Emitted(28, 15) Source(12, 14) + SourceIndex(1) +3 >Emitted(28, 18) Source(12, 17) + SourceIndex(1) +4 >Emitted(28, 20) Source(12, 19) + SourceIndex(1) +5 >Emitted(28, 21) Source(12, 20) + SourceIndex(1) +6 >Emitted(28, 26) Source(12, 25) + SourceIndex(1) +7 >Emitted(28, 27) Source(12, 26) + SourceIndex(1) +--- +>>>}); >>>//# sourceMappingURL=http://www.typescriptlang.org/test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlModuleSimpleSpecifyOutputFile/node/bin/test.d.ts b/tests/baselines/reference/project/maprootUrlModuleSimpleSpecifyOutputFile/node/bin/test.d.ts deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/tests/baselines/reference/project/maprootUrlModuleSimpleSpecifyOutputFile/node/bin/test.js b/tests/baselines/reference/project/maprootUrlModuleSimpleSpecifyOutputFile/node/bin/test.js deleted file mode 100644 index 52f1b822100..00000000000 --- a/tests/baselines/reference/project/maprootUrlModuleSimpleSpecifyOutputFile/node/bin/test.js +++ /dev/null @@ -1 +0,0 @@ -//# sourceMappingURL=http://www.typescriptlang.org/test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlModuleSimpleSpecifyOutputFile/node/bin/test.js.map b/tests/baselines/reference/project/maprootUrlModuleSimpleSpecifyOutputFile/node/bin/test.js.map index c1e0281a2ab..a7424e92122 100644 --- a/tests/baselines/reference/project/maprootUrlModuleSimpleSpecifyOutputFile/node/bin/test.js.map +++ b/tests/baselines/reference/project/maprootUrlModuleSimpleSpecifyOutputFile/node/bin/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"","sources":[],"names":[],"mappings":""} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"","sources":["file:///tests/cases/projects/outputdir_module_simple/m1.ts","file:///tests/cases/projects/outputdir_module_simple/test.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlModuleSimpleSpecifyOutputFile/node/maprootUrlModuleSimpleSpecifyOutputFile.sourcemap.txt b/tests/baselines/reference/project/maprootUrlModuleSimpleSpecifyOutputFile/node/maprootUrlModuleSimpleSpecifyOutputFile.sourcemap.txt index 804e4408446..889ac03323b 100644 --- a/tests/baselines/reference/project/maprootUrlModuleSimpleSpecifyOutputFile/node/maprootUrlModuleSimpleSpecifyOutputFile.sourcemap.txt +++ b/tests/baselines/reference/project/maprootUrlModuleSimpleSpecifyOutputFile/node/maprootUrlModuleSimpleSpecifyOutputFile.sourcemap.txt @@ -394,6 +394,6 @@ sourceFile:file:///tests/cases/projects/outputdir_module_simple/test.ts JsFile: test.js mapUrl: http://www.typescriptlang.org/test.js.map sourceRoot: -sources: +sources: file:///tests/cases/projects/outputdir_module_simple/m1.ts,file:///tests/cases/projects/outputdir_module_simple/test.ts =================================================================== >>>//# sourceMappingURL=http://www.typescriptlang.org/test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlModuleSubfolderSpecifyOutputFile/amd/bin/test.d.ts b/tests/baselines/reference/project/maprootUrlModuleSubfolderSpecifyOutputFile/amd/bin/test.d.ts deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/tests/baselines/reference/project/maprootUrlModuleSubfolderSpecifyOutputFile/amd/bin/test.js b/tests/baselines/reference/project/maprootUrlModuleSubfolderSpecifyOutputFile/amd/bin/test.js deleted file mode 100644 index 52f1b822100..00000000000 --- a/tests/baselines/reference/project/maprootUrlModuleSubfolderSpecifyOutputFile/amd/bin/test.js +++ /dev/null @@ -1 +0,0 @@ -//# sourceMappingURL=http://www.typescriptlang.org/test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlModuleSubfolderSpecifyOutputFile/amd/bin/test.js.map b/tests/baselines/reference/project/maprootUrlModuleSubfolderSpecifyOutputFile/amd/bin/test.js.map index c1e0281a2ab..439677f8aba 100644 --- a/tests/baselines/reference/project/maprootUrlModuleSubfolderSpecifyOutputFile/amd/bin/test.js.map +++ b/tests/baselines/reference/project/maprootUrlModuleSubfolderSpecifyOutputFile/amd/bin/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"","sources":[],"names":[],"mappings":""} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"","sources":["file:///tests/cases/projects/outputdir_module_subfolder/ref/m1.ts","file:///tests/cases/projects/outputdir_module_subfolder/test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","c1","c1.constructor","f1"],"mappings":";IAAW,aAAK,GAAG,EAAE,CAAC;IACtB;QAAAA;QAEAC,CAACA;QAADD,YAACA;IAADA,CAACA,AAFD,IAEC;IAFY,aAAK,QAEjB,CAAA;IAEU,oBAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACIE,MAAMA,CAACA,oBAAYA,CAACA;IACxBA,CAACA;IAFe,aAAK,QAEpB,CAAA;;;ICPU,UAAE,GAAG,EAAE,CAAC;IACnB;QAAAC;QAEAC,CAACA;QAADD,SAACA;IAADA,CAACA,AAFD,IAEC;IAFY,UAAE,KAEd,CAAA;IAEU,iBAAS,GAAG,IAAI,EAAE,EAAE,CAAC;IAChC;QACIE,MAAMA,CAACA,iBAASA,CAACA;IACrBA,CAACA;IAFe,UAAE,KAEjB,CAAA;IAEU,UAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlModuleSubfolderSpecifyOutputFile/amd/maprootUrlModuleSubfolderSpecifyOutputFile.sourcemap.txt b/tests/baselines/reference/project/maprootUrlModuleSubfolderSpecifyOutputFile/amd/maprootUrlModuleSubfolderSpecifyOutputFile.sourcemap.txt index 894bcf6cef4..b547512c50d 100644 --- a/tests/baselines/reference/project/maprootUrlModuleSubfolderSpecifyOutputFile/amd/maprootUrlModuleSubfolderSpecifyOutputFile.sourcemap.txt +++ b/tests/baselines/reference/project/maprootUrlModuleSubfolderSpecifyOutputFile/amd/maprootUrlModuleSubfolderSpecifyOutputFile.sourcemap.txt @@ -373,6 +373,365 @@ sourceFile:file:///tests/cases/projects/outputdir_module_subfolder/test.ts JsFile: test.js mapUrl: http://www.typescriptlang.org/test.js.map sourceRoot: -sources: +sources: file:///tests/cases/projects/outputdir_module_subfolder/ref/m1.ts,file:///tests/cases/projects/outputdir_module_subfolder/test.ts =================================================================== +------------------------------------------------------------------- +emittedFile:bin/test.js +sourceFile:file:///tests/cases/projects/outputdir_module_subfolder/ref/m1.ts +------------------------------------------------------------------- +>>>define("ref/m1", ["require", "exports"], function (require, exports) { +>>> exports.m1_a1 = 10; +1 >^^^^ +2 > ^^^^^^^^^^^^^ +3 > ^^^ +4 > ^^ +5 > ^ +6 > ^^^^^^^^-> +1 >export var +2 > m1_a1 +3 > = +4 > 10 +5 > ; +1 >Emitted(2, 5) Source(1, 12) + SourceIndex(0) +2 >Emitted(2, 18) Source(1, 17) + SourceIndex(0) +3 >Emitted(2, 21) Source(1, 20) + SourceIndex(0) +4 >Emitted(2, 23) Source(1, 22) + SourceIndex(0) +5 >Emitted(2, 24) Source(1, 23) + SourceIndex(0) +--- +>>> var m1_c1 = (function () { +1->^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^^^^-> +1-> + > +1->Emitted(3, 5) Source(2, 1) + SourceIndex(0) +--- +>>> function m1_c1() { +1->^^^^^^^^ +2 > ^^-> +1-> +1->Emitted(4, 9) Source(2, 1) + SourceIndex(0) name (m1_c1) +--- +>>> } +1->^^^^^^^^ +2 > ^ +3 > ^^^^^^^^^^^^^-> +1->export class m1_c1 { + > public m1_c1_p1: number; + > +2 > } +1->Emitted(5, 9) Source(4, 1) + SourceIndex(0) name (m1_c1.constructor) +2 >Emitted(5, 10) Source(4, 2) + SourceIndex(0) name (m1_c1.constructor) +--- +>>> return m1_c1; +1->^^^^^^^^ +2 > ^^^^^^^^^^^^ +1-> +2 > } +1->Emitted(6, 9) Source(4, 1) + SourceIndex(0) name (m1_c1) +2 >Emitted(6, 21) Source(4, 2) + SourceIndex(0) name (m1_c1) +--- +>>> })(); +1 >^^^^ +2 > ^ +3 > +4 > ^^^^ +5 > ^^^^^^^^^^^^^^^^^^-> +1 > +2 > } +3 > +4 > export class m1_c1 { + > public m1_c1_p1: number; + > } +1 >Emitted(7, 5) Source(4, 1) + SourceIndex(0) name (m1_c1) +2 >Emitted(7, 6) Source(4, 2) + SourceIndex(0) name (m1_c1) +3 >Emitted(7, 6) Source(2, 1) + SourceIndex(0) +4 >Emitted(7, 10) Source(4, 2) + SourceIndex(0) +--- +>>> exports.m1_c1 = m1_c1; +1->^^^^ +2 > ^^^^^^^^^^^^^ +3 > ^^^^^^^^ +4 > ^ +5 > ^^^^^^^^^^^^^^-> +1-> +2 > m1_c1 +3 > { + > public m1_c1_p1: number; + > } +4 > +1->Emitted(8, 5) Source(2, 14) + SourceIndex(0) +2 >Emitted(8, 18) Source(2, 19) + SourceIndex(0) +3 >Emitted(8, 26) Source(4, 2) + SourceIndex(0) +4 >Emitted(8, 27) Source(4, 2) + SourceIndex(0) +--- +>>> exports.m1_instance1 = new m1_c1(); +1->^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^ +3 > ^^^ +4 > ^^^^ +5 > ^^^^^ +6 > ^^ +7 > ^ +1-> + > + >export var +2 > m1_instance1 +3 > = +4 > new +5 > m1_c1 +6 > () +7 > ; +1->Emitted(9, 5) Source(6, 12) + SourceIndex(0) +2 >Emitted(9, 25) Source(6, 24) + SourceIndex(0) +3 >Emitted(9, 28) Source(6, 27) + SourceIndex(0) +4 >Emitted(9, 32) Source(6, 31) + SourceIndex(0) +5 >Emitted(9, 37) Source(6, 36) + SourceIndex(0) +6 >Emitted(9, 39) Source(6, 38) + SourceIndex(0) +7 >Emitted(9, 40) Source(6, 39) + SourceIndex(0) +--- +>>> function m1_f1() { +1 >^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +1 > + > +1 >Emitted(10, 5) Source(7, 1) + SourceIndex(0) +--- +>>> return exports.m1_instance1; +1->^^^^^^^^ +2 > ^^^^^^ +3 > ^ +4 > ^^^^^^^^^^^^^^^^^^^^ +5 > ^ +1->export function m1_f1() { + > +2 > return +3 > +4 > m1_instance1 +5 > ; +1->Emitted(11, 9) Source(8, 5) + SourceIndex(0) name (m1_f1) +2 >Emitted(11, 15) Source(8, 11) + SourceIndex(0) name (m1_f1) +3 >Emitted(11, 16) Source(8, 12) + SourceIndex(0) name (m1_f1) +4 >Emitted(11, 36) Source(8, 24) + SourceIndex(0) name (m1_f1) +5 >Emitted(11, 37) Source(8, 25) + SourceIndex(0) name (m1_f1) +--- +>>> } +1 >^^^^ +2 > ^ +3 > ^^^^^^^^^^^^^^^^^^^^^^-> +1 > + > +2 > } +1 >Emitted(12, 5) Source(9, 1) + SourceIndex(0) name (m1_f1) +2 >Emitted(12, 6) Source(9, 2) + SourceIndex(0) name (m1_f1) +--- +>>> exports.m1_f1 = m1_f1; +1->^^^^ +2 > ^^^^^^^^^^^^^ +3 > ^^^^^^^^ +4 > ^ +1-> +2 > m1_f1 +3 > () { + > return m1_instance1; + > } +4 > +1->Emitted(13, 5) Source(7, 17) + SourceIndex(0) +2 >Emitted(13, 18) Source(7, 22) + SourceIndex(0) +3 >Emitted(13, 26) Source(9, 2) + SourceIndex(0) +4 >Emitted(13, 27) Source(9, 2) + SourceIndex(0) +--- +------------------------------------------------------------------- +emittedFile:bin/test.js +sourceFile:file:///tests/cases/projects/outputdir_module_subfolder/test.ts +------------------------------------------------------------------- +>>>}); +>>>define("test", ["require", "exports", "ref/m1"], function (require, exports, m1) { +>>> exports.a1 = 10; +1 >^^^^ +2 > ^^^^^^^^^^ +3 > ^^^ +4 > ^^ +5 > ^ +6 > ^^^^^^^^-> +1 >import m1 = require("ref/m1"); + >export var +2 > a1 +3 > = +4 > 10 +5 > ; +1 >Emitted(16, 5) Source(2, 12) + SourceIndex(1) +2 >Emitted(16, 15) Source(2, 14) + SourceIndex(1) +3 >Emitted(16, 18) Source(2, 17) + SourceIndex(1) +4 >Emitted(16, 20) Source(2, 19) + SourceIndex(1) +5 >Emitted(16, 21) Source(2, 20) + SourceIndex(1) +--- +>>> var c1 = (function () { +1->^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^-> +1-> + > +1->Emitted(17, 5) Source(3, 1) + SourceIndex(1) +--- +>>> function c1() { +1->^^^^^^^^ +2 > ^^-> +1-> +1->Emitted(18, 9) Source(3, 1) + SourceIndex(1) name (c1) +--- +>>> } +1->^^^^^^^^ +2 > ^ +3 > ^^^^^^^^^^-> +1->export class c1 { + > public p1: number; + > +2 > } +1->Emitted(19, 9) Source(5, 1) + SourceIndex(1) name (c1.constructor) +2 >Emitted(19, 10) Source(5, 2) + SourceIndex(1) name (c1.constructor) +--- +>>> return c1; +1->^^^^^^^^ +2 > ^^^^^^^^^ +1-> +2 > } +1->Emitted(20, 9) Source(5, 1) + SourceIndex(1) name (c1) +2 >Emitted(20, 18) Source(5, 2) + SourceIndex(1) name (c1) +--- +>>> })(); +1 >^^^^ +2 > ^ +3 > +4 > ^^^^ +5 > ^^^^^^^^^^^^-> +1 > +2 > } +3 > +4 > export class c1 { + > public p1: number; + > } +1 >Emitted(21, 5) Source(5, 1) + SourceIndex(1) name (c1) +2 >Emitted(21, 6) Source(5, 2) + SourceIndex(1) name (c1) +3 >Emitted(21, 6) Source(3, 1) + SourceIndex(1) +4 >Emitted(21, 10) Source(5, 2) + SourceIndex(1) +--- +>>> exports.c1 = c1; +1->^^^^ +2 > ^^^^^^^^^^ +3 > ^^^^^ +4 > ^ +5 > ^^^^^^^^^^^^^^-> +1-> +2 > c1 +3 > { + > public p1: number; + > } +4 > +1->Emitted(22, 5) Source(3, 14) + SourceIndex(1) +2 >Emitted(22, 15) Source(3, 16) + SourceIndex(1) +3 >Emitted(22, 20) Source(5, 2) + SourceIndex(1) +4 >Emitted(22, 21) Source(5, 2) + SourceIndex(1) +--- +>>> exports.instance1 = new c1(); +1->^^^^ +2 > ^^^^^^^^^^^^^^^^^ +3 > ^^^ +4 > ^^^^ +5 > ^^ +6 > ^^ +7 > ^ +1-> + > + >export var +2 > instance1 +3 > = +4 > new +5 > c1 +6 > () +7 > ; +1->Emitted(23, 5) Source(7, 12) + SourceIndex(1) +2 >Emitted(23, 22) Source(7, 21) + SourceIndex(1) +3 >Emitted(23, 25) Source(7, 24) + SourceIndex(1) +4 >Emitted(23, 29) Source(7, 28) + SourceIndex(1) +5 >Emitted(23, 31) Source(7, 30) + SourceIndex(1) +6 >Emitted(23, 33) Source(7, 32) + SourceIndex(1) +7 >Emitted(23, 34) Source(7, 33) + SourceIndex(1) +--- +>>> function f1() { +1 >^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +1 > + > +1 >Emitted(24, 5) Source(8, 1) + SourceIndex(1) +--- +>>> return exports.instance1; +1->^^^^^^^^ +2 > ^^^^^^ +3 > ^ +4 > ^^^^^^^^^^^^^^^^^ +5 > ^ +1->export function f1() { + > +2 > return +3 > +4 > instance1 +5 > ; +1->Emitted(25, 9) Source(9, 5) + SourceIndex(1) name (f1) +2 >Emitted(25, 15) Source(9, 11) + SourceIndex(1) name (f1) +3 >Emitted(25, 16) Source(9, 12) + SourceIndex(1) name (f1) +4 >Emitted(25, 33) Source(9, 21) + SourceIndex(1) name (f1) +5 >Emitted(25, 34) Source(9, 22) + SourceIndex(1) name (f1) +--- +>>> } +1 >^^^^ +2 > ^ +3 > ^^^^^^^^^^^^^^^^-> +1 > + > +2 > } +1 >Emitted(26, 5) Source(10, 1) + SourceIndex(1) name (f1) +2 >Emitted(26, 6) Source(10, 2) + SourceIndex(1) name (f1) +--- +>>> exports.f1 = f1; +1->^^^^ +2 > ^^^^^^^^^^ +3 > ^^^^^ +4 > ^ +5 > ^^^^^^^-> +1-> +2 > f1 +3 > () { + > return instance1; + > } +4 > +1->Emitted(27, 5) Source(8, 17) + SourceIndex(1) +2 >Emitted(27, 15) Source(8, 19) + SourceIndex(1) +3 >Emitted(27, 20) Source(10, 2) + SourceIndex(1) +4 >Emitted(27, 21) Source(10, 2) + SourceIndex(1) +--- +>>> exports.a2 = m1.m1_c1; +1->^^^^ +2 > ^^^^^^^^^^ +3 > ^^^ +4 > ^^ +5 > ^ +6 > ^^^^^ +7 > ^ +1-> + > + >export var +2 > a2 +3 > = +4 > m1 +5 > . +6 > m1_c1 +7 > ; +1->Emitted(28, 5) Source(12, 12) + SourceIndex(1) +2 >Emitted(28, 15) Source(12, 14) + SourceIndex(1) +3 >Emitted(28, 18) Source(12, 17) + SourceIndex(1) +4 >Emitted(28, 20) Source(12, 19) + SourceIndex(1) +5 >Emitted(28, 21) Source(12, 20) + SourceIndex(1) +6 >Emitted(28, 26) Source(12, 25) + SourceIndex(1) +7 >Emitted(28, 27) Source(12, 26) + SourceIndex(1) +--- +>>>}); >>>//# sourceMappingURL=http://www.typescriptlang.org/test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlModuleSubfolderSpecifyOutputFile/node/bin/test.d.ts b/tests/baselines/reference/project/maprootUrlModuleSubfolderSpecifyOutputFile/node/bin/test.d.ts deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/tests/baselines/reference/project/maprootUrlModuleSubfolderSpecifyOutputFile/node/bin/test.js b/tests/baselines/reference/project/maprootUrlModuleSubfolderSpecifyOutputFile/node/bin/test.js deleted file mode 100644 index 52f1b822100..00000000000 --- a/tests/baselines/reference/project/maprootUrlModuleSubfolderSpecifyOutputFile/node/bin/test.js +++ /dev/null @@ -1 +0,0 @@ -//# sourceMappingURL=http://www.typescriptlang.org/test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlModuleSubfolderSpecifyOutputFile/node/bin/test.js.map b/tests/baselines/reference/project/maprootUrlModuleSubfolderSpecifyOutputFile/node/bin/test.js.map index c1e0281a2ab..44276925bda 100644 --- a/tests/baselines/reference/project/maprootUrlModuleSubfolderSpecifyOutputFile/node/bin/test.js.map +++ b/tests/baselines/reference/project/maprootUrlModuleSubfolderSpecifyOutputFile/node/bin/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"","sources":[],"names":[],"mappings":""} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"","sources":["file:///tests/cases/projects/outputdir_module_subfolder/ref/m1.ts","file:///tests/cases/projects/outputdir_module_subfolder/test.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlModuleSubfolderSpecifyOutputFile/node/maprootUrlModuleSubfolderSpecifyOutputFile.sourcemap.txt b/tests/baselines/reference/project/maprootUrlModuleSubfolderSpecifyOutputFile/node/maprootUrlModuleSubfolderSpecifyOutputFile.sourcemap.txt index 9a7f754c534..3bb1f02d820 100644 --- a/tests/baselines/reference/project/maprootUrlModuleSubfolderSpecifyOutputFile/node/maprootUrlModuleSubfolderSpecifyOutputFile.sourcemap.txt +++ b/tests/baselines/reference/project/maprootUrlModuleSubfolderSpecifyOutputFile/node/maprootUrlModuleSubfolderSpecifyOutputFile.sourcemap.txt @@ -394,6 +394,6 @@ sourceFile:file:///tests/cases/projects/outputdir_module_subfolder/test.ts JsFile: test.js mapUrl: http://www.typescriptlang.org/test.js.map sourceRoot: -sources: +sources: file:///tests/cases/projects/outputdir_module_subfolder/ref/m1.ts,file:///tests/cases/projects/outputdir_module_subfolder/test.ts =================================================================== >>>//# sourceMappingURL=http://www.typescriptlang.org/test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFile/amd/bin/test.d.ts b/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFile/amd/bin/test.d.ts deleted file mode 100644 index d61b4c3b876..00000000000 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFile/amd/bin/test.d.ts +++ /dev/null @@ -1,13 +0,0 @@ -/// -declare var m1_a1: number; -declare class m1_c1 { - m1_c1_p1: number; -} -declare var m1_instance1: m1_c1; -declare function m1_f1(): m1_c1; -declare var a1: number; -declare class c1 { - p1: number; -} -declare var instance1: c1; -declare function f1(): c1; diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFile/amd/bin/test.js b/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFile/amd/bin/test.js deleted file mode 100644 index af0071d7e46..00000000000 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFile/amd/bin/test.js +++ /dev/null @@ -1,23 +0,0 @@ -var m1_a1 = 10; -var m1_c1 = (function () { - function m1_c1() { - } - return m1_c1; -})(); -var m1_instance1 = new m1_c1(); -function m1_f1() { - return m1_instance1; -} -/// -/// -var a1 = 10; -var c1 = (function () { - function c1() { - } - return c1; -})(); -var instance1 = new c1(); -function f1() { - return instance1; -} -//# sourceMappingURL=http://www.typescriptlang.org/test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFile/amd/bin/test.js.map b/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFile/amd/bin/test.js.map index 7a70d18105c..37bb9be8a95 100644 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFile/amd/bin/test.js.map +++ b/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFile/amd/bin/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"http://typescript.codeplex.com/","sources":["ref/m1.ts","test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACRD,iCAAiC;AACjC,iCAAiC;AACjC,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"http://typescript.codeplex.com/","sources":["ref/m1.ts","ref/m2.ts","test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","m2_c1","m2_c1.constructor","m2_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;;ICRU,aAAK,GAAG,EAAE,CAAC;IACtB;QAAAC;QAEAC,CAACA;QAADD,YAACA;IAADA,CAACA,AAFD,IAEC;IAFY,aAAK,QAEjB,CAAA;IAEU,oBAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACIE,MAAMA,CAACA,oBAAYA,CAACA;IACxBA,CAACA;IAFe,aAAK,QAEpB,CAAA;;ACRD,iCAAiC;AACjC,iCAAiC;AACjC,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFile/amd/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFile.sourcemap.txt b/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFile/amd/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFile.sourcemap.txt index 49c44cde80e..65ffacd46fc 100644 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFile/amd/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFile.sourcemap.txt +++ b/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFile/amd/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFile.sourcemap.txt @@ -174,7 +174,7 @@ sourceFile:ref/m2.ts JsFile: test.js mapUrl: http://www.typescriptlang.org/test.js.map sourceRoot: http://typescript.codeplex.com/ -sources: ref/m1.ts,test.ts +sources: ref/m1.ts,ref/m2.ts,test.ts =================================================================== ------------------------------------------------------------------- emittedFile:bin/test.js @@ -306,7 +306,7 @@ sourceFile:ref/m1.ts >>>} 1 > 2 >^ -3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> 1 > > 2 >} @@ -315,16 +315,182 @@ sourceFile:ref/m1.ts --- ------------------------------------------------------------------- emittedFile:bin/test.js +sourceFile:ref/m2.ts +------------------------------------------------------------------- +>>>define("ref/m2", ["require", "exports"], function (require, exports) { +>>> exports.m2_a1 = 10; +1->^^^^ +2 > ^^^^^^^^^^^^^ +3 > ^^^ +4 > ^^ +5 > ^ +6 > ^^^^^^^^-> +1->export var +2 > m2_a1 +3 > = +4 > 10 +5 > ; +1->Emitted(12, 5) Source(1, 12) + SourceIndex(1) +2 >Emitted(12, 18) Source(1, 17) + SourceIndex(1) +3 >Emitted(12, 21) Source(1, 20) + SourceIndex(1) +4 >Emitted(12, 23) Source(1, 22) + SourceIndex(1) +5 >Emitted(12, 24) Source(1, 23) + SourceIndex(1) +--- +>>> var m2_c1 = (function () { +1->^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^^^^-> +1-> + > +1->Emitted(13, 5) Source(2, 1) + SourceIndex(1) +--- +>>> function m2_c1() { +1->^^^^^^^^ +2 > ^^-> +1-> +1->Emitted(14, 9) Source(2, 1) + SourceIndex(1) name (m2_c1) +--- +>>> } +1->^^^^^^^^ +2 > ^ +3 > ^^^^^^^^^^^^^-> +1->export class m2_c1 { + > public m2_c1_p1: number; + > +2 > } +1->Emitted(15, 9) Source(4, 1) + SourceIndex(1) name (m2_c1.constructor) +2 >Emitted(15, 10) Source(4, 2) + SourceIndex(1) name (m2_c1.constructor) +--- +>>> return m2_c1; +1->^^^^^^^^ +2 > ^^^^^^^^^^^^ +1-> +2 > } +1->Emitted(16, 9) Source(4, 1) + SourceIndex(1) name (m2_c1) +2 >Emitted(16, 21) Source(4, 2) + SourceIndex(1) name (m2_c1) +--- +>>> })(); +1 >^^^^ +2 > ^ +3 > +4 > ^^^^ +5 > ^^^^^^^^^^^^^^^^^^-> +1 > +2 > } +3 > +4 > export class m2_c1 { + > public m2_c1_p1: number; + > } +1 >Emitted(17, 5) Source(4, 1) + SourceIndex(1) name (m2_c1) +2 >Emitted(17, 6) Source(4, 2) + SourceIndex(1) name (m2_c1) +3 >Emitted(17, 6) Source(2, 1) + SourceIndex(1) +4 >Emitted(17, 10) Source(4, 2) + SourceIndex(1) +--- +>>> exports.m2_c1 = m2_c1; +1->^^^^ +2 > ^^^^^^^^^^^^^ +3 > ^^^^^^^^ +4 > ^ +5 > ^^^^^^^^^^^^^^-> +1-> +2 > m2_c1 +3 > { + > public m2_c1_p1: number; + > } +4 > +1->Emitted(18, 5) Source(2, 14) + SourceIndex(1) +2 >Emitted(18, 18) Source(2, 19) + SourceIndex(1) +3 >Emitted(18, 26) Source(4, 2) + SourceIndex(1) +4 >Emitted(18, 27) Source(4, 2) + SourceIndex(1) +--- +>>> exports.m2_instance1 = new m2_c1(); +1->^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^ +3 > ^^^ +4 > ^^^^ +5 > ^^^^^ +6 > ^^ +7 > ^ +1-> + > + >export var +2 > m2_instance1 +3 > = +4 > new +5 > m2_c1 +6 > () +7 > ; +1->Emitted(19, 5) Source(6, 12) + SourceIndex(1) +2 >Emitted(19, 25) Source(6, 24) + SourceIndex(1) +3 >Emitted(19, 28) Source(6, 27) + SourceIndex(1) +4 >Emitted(19, 32) Source(6, 31) + SourceIndex(1) +5 >Emitted(19, 37) Source(6, 36) + SourceIndex(1) +6 >Emitted(19, 39) Source(6, 38) + SourceIndex(1) +7 >Emitted(19, 40) Source(6, 39) + SourceIndex(1) +--- +>>> function m2_f1() { +1 >^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +1 > + > +1 >Emitted(20, 5) Source(7, 1) + SourceIndex(1) +--- +>>> return exports.m2_instance1; +1->^^^^^^^^ +2 > ^^^^^^ +3 > ^ +4 > ^^^^^^^^^^^^^^^^^^^^ +5 > ^ +1->export function m2_f1() { + > +2 > return +3 > +4 > m2_instance1 +5 > ; +1->Emitted(21, 9) Source(8, 5) + SourceIndex(1) name (m2_f1) +2 >Emitted(21, 15) Source(8, 11) + SourceIndex(1) name (m2_f1) +3 >Emitted(21, 16) Source(8, 12) + SourceIndex(1) name (m2_f1) +4 >Emitted(21, 36) Source(8, 24) + SourceIndex(1) name (m2_f1) +5 >Emitted(21, 37) Source(8, 25) + SourceIndex(1) name (m2_f1) +--- +>>> } +1 >^^^^ +2 > ^ +3 > ^^^^^^^^^^^^^^^^^^^^^^-> +1 > + > +2 > } +1 >Emitted(22, 5) Source(9, 1) + SourceIndex(1) name (m2_f1) +2 >Emitted(22, 6) Source(9, 2) + SourceIndex(1) name (m2_f1) +--- +>>> exports.m2_f1 = m2_f1; +1->^^^^ +2 > ^^^^^^^^^^^^^ +3 > ^^^^^^^^ +4 > ^ +1-> +2 > m2_f1 +3 > () { + > return m2_instance1; + > } +4 > +1->Emitted(23, 5) Source(7, 17) + SourceIndex(1) +2 >Emitted(23, 18) Source(7, 22) + SourceIndex(1) +3 >Emitted(23, 26) Source(9, 2) + SourceIndex(1) +4 >Emitted(23, 27) Source(9, 2) + SourceIndex(1) +--- +------------------------------------------------------------------- +emittedFile:bin/test.js sourceFile:test.ts ------------------------------------------------------------------- +>>>}); >>>/// -1-> +1 > 2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 3 > ^-> -1-> +1 > 2 >/// -1->Emitted(11, 1) Source(1, 1) + SourceIndex(1) -2 >Emitted(11, 34) Source(1, 34) + SourceIndex(1) +1 >Emitted(25, 1) Source(1, 1) + SourceIndex(2) +2 >Emitted(25, 34) Source(1, 34) + SourceIndex(2) --- >>>/// 1-> @@ -332,8 +498,8 @@ sourceFile:test.ts 1-> > 2 >/// -1->Emitted(12, 1) Source(2, 1) + SourceIndex(1) -2 >Emitted(12, 34) Source(2, 34) + SourceIndex(1) +1->Emitted(26, 1) Source(2, 1) + SourceIndex(2) +2 >Emitted(26, 34) Source(2, 34) + SourceIndex(2) --- >>>var a1 = 10; 1 > @@ -350,25 +516,25 @@ sourceFile:test.ts 4 > = 5 > 10 6 > ; -1 >Emitted(13, 1) Source(3, 1) + SourceIndex(1) -2 >Emitted(13, 5) Source(3, 5) + SourceIndex(1) -3 >Emitted(13, 7) Source(3, 7) + SourceIndex(1) -4 >Emitted(13, 10) Source(3, 10) + SourceIndex(1) -5 >Emitted(13, 12) Source(3, 12) + SourceIndex(1) -6 >Emitted(13, 13) Source(3, 13) + SourceIndex(1) +1 >Emitted(27, 1) Source(3, 1) + SourceIndex(2) +2 >Emitted(27, 5) Source(3, 5) + SourceIndex(2) +3 >Emitted(27, 7) Source(3, 7) + SourceIndex(2) +4 >Emitted(27, 10) Source(3, 10) + SourceIndex(2) +5 >Emitted(27, 12) Source(3, 12) + SourceIndex(2) +6 >Emitted(27, 13) Source(3, 13) + SourceIndex(2) --- >>>var c1 = (function () { 1-> 2 >^^^^^^^^^^^^^^^^^^^^-> 1-> > -1->Emitted(14, 1) Source(4, 1) + SourceIndex(1) +1->Emitted(28, 1) Source(4, 1) + SourceIndex(2) --- >>> function c1() { 1->^^^^ 2 > ^^-> 1-> -1->Emitted(15, 5) Source(4, 1) + SourceIndex(1) name (c1) +1->Emitted(29, 5) Source(4, 1) + SourceIndex(2) name (c1) --- >>> } 1->^^^^ @@ -378,16 +544,16 @@ sourceFile:test.ts > public p1: number; > 2 > } -1->Emitted(16, 5) Source(6, 1) + SourceIndex(1) name (c1.constructor) -2 >Emitted(16, 6) Source(6, 2) + SourceIndex(1) name (c1.constructor) +1->Emitted(30, 5) Source(6, 1) + SourceIndex(2) name (c1.constructor) +2 >Emitted(30, 6) Source(6, 2) + SourceIndex(2) name (c1.constructor) --- >>> return c1; 1->^^^^ 2 > ^^^^^^^^^ 1-> 2 > } -1->Emitted(17, 5) Source(6, 1) + SourceIndex(1) name (c1) -2 >Emitted(17, 14) Source(6, 2) + SourceIndex(1) name (c1) +1->Emitted(31, 5) Source(6, 1) + SourceIndex(2) name (c1) +2 >Emitted(31, 14) Source(6, 2) + SourceIndex(2) name (c1) --- >>>})(); 1 > @@ -401,10 +567,10 @@ sourceFile:test.ts 4 > class c1 { > public p1: number; > } -1 >Emitted(18, 1) Source(6, 1) + SourceIndex(1) name (c1) -2 >Emitted(18, 2) Source(6, 2) + SourceIndex(1) name (c1) -3 >Emitted(18, 2) Source(4, 1) + SourceIndex(1) -4 >Emitted(18, 6) Source(6, 2) + SourceIndex(1) +1 >Emitted(32, 1) Source(6, 1) + SourceIndex(2) name (c1) +2 >Emitted(32, 2) Source(6, 2) + SourceIndex(2) name (c1) +3 >Emitted(32, 2) Source(4, 1) + SourceIndex(2) +4 >Emitted(32, 6) Source(6, 2) + SourceIndex(2) --- >>>var instance1 = new c1(); 1-> @@ -425,21 +591,21 @@ sourceFile:test.ts 6 > c1 7 > () 8 > ; -1->Emitted(19, 1) Source(8, 1) + SourceIndex(1) -2 >Emitted(19, 5) Source(8, 5) + SourceIndex(1) -3 >Emitted(19, 14) Source(8, 14) + SourceIndex(1) -4 >Emitted(19, 17) Source(8, 17) + SourceIndex(1) -5 >Emitted(19, 21) Source(8, 21) + SourceIndex(1) -6 >Emitted(19, 23) Source(8, 23) + SourceIndex(1) -7 >Emitted(19, 25) Source(8, 25) + SourceIndex(1) -8 >Emitted(19, 26) Source(8, 26) + SourceIndex(1) +1->Emitted(33, 1) Source(8, 1) + SourceIndex(2) +2 >Emitted(33, 5) Source(8, 5) + SourceIndex(2) +3 >Emitted(33, 14) Source(8, 14) + SourceIndex(2) +4 >Emitted(33, 17) Source(8, 17) + SourceIndex(2) +5 >Emitted(33, 21) Source(8, 21) + SourceIndex(2) +6 >Emitted(33, 23) Source(8, 23) + SourceIndex(2) +7 >Emitted(33, 25) Source(8, 25) + SourceIndex(2) +8 >Emitted(33, 26) Source(8, 26) + SourceIndex(2) --- >>>function f1() { 1 > 2 >^^^^^^^^^^^^^^^^^^^^^^-> 1 > > -1 >Emitted(20, 1) Source(9, 1) + SourceIndex(1) +1 >Emitted(34, 1) Source(9, 1) + SourceIndex(2) --- >>> return instance1; 1->^^^^ @@ -453,11 +619,11 @@ sourceFile:test.ts 3 > 4 > instance1 5 > ; -1->Emitted(21, 5) Source(10, 5) + SourceIndex(1) name (f1) -2 >Emitted(21, 11) Source(10, 11) + SourceIndex(1) name (f1) -3 >Emitted(21, 12) Source(10, 12) + SourceIndex(1) name (f1) -4 >Emitted(21, 21) Source(10, 21) + SourceIndex(1) name (f1) -5 >Emitted(21, 22) Source(10, 22) + SourceIndex(1) name (f1) +1->Emitted(35, 5) Source(10, 5) + SourceIndex(2) name (f1) +2 >Emitted(35, 11) Source(10, 11) + SourceIndex(2) name (f1) +3 >Emitted(35, 12) Source(10, 12) + SourceIndex(2) name (f1) +4 >Emitted(35, 21) Source(10, 21) + SourceIndex(2) name (f1) +5 >Emitted(35, 22) Source(10, 22) + SourceIndex(2) name (f1) --- >>>} 1 > @@ -466,7 +632,7 @@ sourceFile:test.ts 1 > > 2 >} -1 >Emitted(22, 1) Source(11, 1) + SourceIndex(1) name (f1) -2 >Emitted(22, 2) Source(11, 2) + SourceIndex(1) name (f1) +1 >Emitted(36, 1) Source(11, 1) + SourceIndex(2) name (f1) +2 >Emitted(36, 2) Source(11, 2) + SourceIndex(2) name (f1) --- >>>//# sourceMappingURL=http://www.typescriptlang.org/test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFile/node/bin/test.d.ts b/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFile/node/bin/test.d.ts deleted file mode 100644 index d61b4c3b876..00000000000 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFile/node/bin/test.d.ts +++ /dev/null @@ -1,13 +0,0 @@ -/// -declare var m1_a1: number; -declare class m1_c1 { - m1_c1_p1: number; -} -declare var m1_instance1: m1_c1; -declare function m1_f1(): m1_c1; -declare var a1: number; -declare class c1 { - p1: number; -} -declare var instance1: c1; -declare function f1(): c1; diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFile/node/bin/test.js b/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFile/node/bin/test.js deleted file mode 100644 index af0071d7e46..00000000000 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFile/node/bin/test.js +++ /dev/null @@ -1,23 +0,0 @@ -var m1_a1 = 10; -var m1_c1 = (function () { - function m1_c1() { - } - return m1_c1; -})(); -var m1_instance1 = new m1_c1(); -function m1_f1() { - return m1_instance1; -} -/// -/// -var a1 = 10; -var c1 = (function () { - function c1() { - } - return c1; -})(); -var instance1 = new c1(); -function f1() { - return instance1; -} -//# sourceMappingURL=http://www.typescriptlang.org/test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFile/node/bin/test.js.map b/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFile/node/bin/test.js.map index 7a70d18105c..a6626039aa2 100644 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFile/node/bin/test.js.map +++ b/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFile/node/bin/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"http://typescript.codeplex.com/","sources":["ref/m1.ts","test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACRD,iCAAiC;AACjC,iCAAiC;AACjC,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"http://typescript.codeplex.com/","sources":["ref/m1.ts","ref/m2.ts","test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;AERD,iCAAiC;AACjC,iCAAiC;AACjC,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFile/node/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFile.sourcemap.txt b/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFile/node/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFile.sourcemap.txt index d54d4d6245e..714864e506f 100644 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFile/node/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFile.sourcemap.txt +++ b/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFile/node/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFile.sourcemap.txt @@ -173,7 +173,7 @@ sourceFile:ref/m2.ts JsFile: test.js mapUrl: http://www.typescriptlang.org/test.js.map sourceRoot: http://typescript.codeplex.com/ -sources: ref/m1.ts,test.ts +sources: ref/m1.ts,ref/m2.ts,test.ts =================================================================== ------------------------------------------------------------------- emittedFile:bin/test.js @@ -322,8 +322,8 @@ sourceFile:test.ts 3 > ^-> 1-> 2 >/// -1->Emitted(11, 1) Source(1, 1) + SourceIndex(1) -2 >Emitted(11, 34) Source(1, 34) + SourceIndex(1) +1->Emitted(11, 1) Source(1, 1) + SourceIndex(2) +2 >Emitted(11, 34) Source(1, 34) + SourceIndex(2) --- >>>/// 1-> @@ -331,8 +331,8 @@ sourceFile:test.ts 1-> > 2 >/// -1->Emitted(12, 1) Source(2, 1) + SourceIndex(1) -2 >Emitted(12, 34) Source(2, 34) + SourceIndex(1) +1->Emitted(12, 1) Source(2, 1) + SourceIndex(2) +2 >Emitted(12, 34) Source(2, 34) + SourceIndex(2) --- >>>var a1 = 10; 1 > @@ -349,25 +349,25 @@ sourceFile:test.ts 4 > = 5 > 10 6 > ; -1 >Emitted(13, 1) Source(3, 1) + SourceIndex(1) -2 >Emitted(13, 5) Source(3, 5) + SourceIndex(1) -3 >Emitted(13, 7) Source(3, 7) + SourceIndex(1) -4 >Emitted(13, 10) Source(3, 10) + SourceIndex(1) -5 >Emitted(13, 12) Source(3, 12) + SourceIndex(1) -6 >Emitted(13, 13) Source(3, 13) + SourceIndex(1) +1 >Emitted(13, 1) Source(3, 1) + SourceIndex(2) +2 >Emitted(13, 5) Source(3, 5) + SourceIndex(2) +3 >Emitted(13, 7) Source(3, 7) + SourceIndex(2) +4 >Emitted(13, 10) Source(3, 10) + SourceIndex(2) +5 >Emitted(13, 12) Source(3, 12) + SourceIndex(2) +6 >Emitted(13, 13) Source(3, 13) + SourceIndex(2) --- >>>var c1 = (function () { 1-> 2 >^^^^^^^^^^^^^^^^^^^^-> 1-> > -1->Emitted(14, 1) Source(4, 1) + SourceIndex(1) +1->Emitted(14, 1) Source(4, 1) + SourceIndex(2) --- >>> function c1() { 1->^^^^ 2 > ^^-> 1-> -1->Emitted(15, 5) Source(4, 1) + SourceIndex(1) name (c1) +1->Emitted(15, 5) Source(4, 1) + SourceIndex(2) name (c1) --- >>> } 1->^^^^ @@ -377,16 +377,16 @@ sourceFile:test.ts > public p1: number; > 2 > } -1->Emitted(16, 5) Source(6, 1) + SourceIndex(1) name (c1.constructor) -2 >Emitted(16, 6) Source(6, 2) + SourceIndex(1) name (c1.constructor) +1->Emitted(16, 5) Source(6, 1) + SourceIndex(2) name (c1.constructor) +2 >Emitted(16, 6) Source(6, 2) + SourceIndex(2) name (c1.constructor) --- >>> return c1; 1->^^^^ 2 > ^^^^^^^^^ 1-> 2 > } -1->Emitted(17, 5) Source(6, 1) + SourceIndex(1) name (c1) -2 >Emitted(17, 14) Source(6, 2) + SourceIndex(1) name (c1) +1->Emitted(17, 5) Source(6, 1) + SourceIndex(2) name (c1) +2 >Emitted(17, 14) Source(6, 2) + SourceIndex(2) name (c1) --- >>>})(); 1 > @@ -400,10 +400,10 @@ sourceFile:test.ts 4 > class c1 { > public p1: number; > } -1 >Emitted(18, 1) Source(6, 1) + SourceIndex(1) name (c1) -2 >Emitted(18, 2) Source(6, 2) + SourceIndex(1) name (c1) -3 >Emitted(18, 2) Source(4, 1) + SourceIndex(1) -4 >Emitted(18, 6) Source(6, 2) + SourceIndex(1) +1 >Emitted(18, 1) Source(6, 1) + SourceIndex(2) name (c1) +2 >Emitted(18, 2) Source(6, 2) + SourceIndex(2) name (c1) +3 >Emitted(18, 2) Source(4, 1) + SourceIndex(2) +4 >Emitted(18, 6) Source(6, 2) + SourceIndex(2) --- >>>var instance1 = new c1(); 1-> @@ -424,21 +424,21 @@ sourceFile:test.ts 6 > c1 7 > () 8 > ; -1->Emitted(19, 1) Source(8, 1) + SourceIndex(1) -2 >Emitted(19, 5) Source(8, 5) + SourceIndex(1) -3 >Emitted(19, 14) Source(8, 14) + SourceIndex(1) -4 >Emitted(19, 17) Source(8, 17) + SourceIndex(1) -5 >Emitted(19, 21) Source(8, 21) + SourceIndex(1) -6 >Emitted(19, 23) Source(8, 23) + SourceIndex(1) -7 >Emitted(19, 25) Source(8, 25) + SourceIndex(1) -8 >Emitted(19, 26) Source(8, 26) + SourceIndex(1) +1->Emitted(19, 1) Source(8, 1) + SourceIndex(2) +2 >Emitted(19, 5) Source(8, 5) + SourceIndex(2) +3 >Emitted(19, 14) Source(8, 14) + SourceIndex(2) +4 >Emitted(19, 17) Source(8, 17) + SourceIndex(2) +5 >Emitted(19, 21) Source(8, 21) + SourceIndex(2) +6 >Emitted(19, 23) Source(8, 23) + SourceIndex(2) +7 >Emitted(19, 25) Source(8, 25) + SourceIndex(2) +8 >Emitted(19, 26) Source(8, 26) + SourceIndex(2) --- >>>function f1() { 1 > 2 >^^^^^^^^^^^^^^^^^^^^^^-> 1 > > -1 >Emitted(20, 1) Source(9, 1) + SourceIndex(1) +1 >Emitted(20, 1) Source(9, 1) + SourceIndex(2) --- >>> return instance1; 1->^^^^ @@ -452,11 +452,11 @@ sourceFile:test.ts 3 > 4 > instance1 5 > ; -1->Emitted(21, 5) Source(10, 5) + SourceIndex(1) name (f1) -2 >Emitted(21, 11) Source(10, 11) + SourceIndex(1) name (f1) -3 >Emitted(21, 12) Source(10, 12) + SourceIndex(1) name (f1) -4 >Emitted(21, 21) Source(10, 21) + SourceIndex(1) name (f1) -5 >Emitted(21, 22) Source(10, 22) + SourceIndex(1) name (f1) +1->Emitted(21, 5) Source(10, 5) + SourceIndex(2) name (f1) +2 >Emitted(21, 11) Source(10, 11) + SourceIndex(2) name (f1) +3 >Emitted(21, 12) Source(10, 12) + SourceIndex(2) name (f1) +4 >Emitted(21, 21) Source(10, 21) + SourceIndex(2) name (f1) +5 >Emitted(21, 22) Source(10, 22) + SourceIndex(2) name (f1) --- >>>} 1 > @@ -465,7 +465,7 @@ sourceFile:test.ts 1 > > 2 >} -1 >Emitted(22, 1) Source(11, 1) + SourceIndex(1) name (f1) -2 >Emitted(22, 2) Source(11, 2) + SourceIndex(1) name (f1) +1 >Emitted(22, 1) Source(11, 1) + SourceIndex(2) name (f1) +2 >Emitted(22, 2) Source(11, 2) + SourceIndex(2) name (f1) --- >>>//# sourceMappingURL=http://www.typescriptlang.org/test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.d.ts b/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.d.ts deleted file mode 100644 index 9b9cdd4a214..00000000000 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.d.ts +++ /dev/null @@ -1,13 +0,0 @@ -/// -declare var m1_a1: number; -declare class m1_c1 { - m1_c1_p1: number; -} -declare var m1_instance1: m1_c1; -declare function m1_f1(): m1_c1; -declare var a1: number; -declare class c1 { - p1: number; -} -declare var instance1: c1; -declare function f1(): c1; diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.js b/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.js deleted file mode 100644 index 2ebe138ffda..00000000000 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.js +++ /dev/null @@ -1,23 +0,0 @@ -var m1_a1 = 10; -var m1_c1 = (function () { - function m1_c1() { - } - return m1_c1; -})(); -var m1_instance1 = new m1_c1(); -function m1_f1() { - return m1_instance1; -} -/// -/// -var a1 = 10; -var c1 = (function () { - function c1() { - } - return c1; -})(); -var instance1 = new c1(); -function f1() { - return instance1; -} -//# sourceMappingURL=http://www.typescriptlang.org/outAndOutDirFile.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.js.map b/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.js.map index 53e31e30260..f3058d9f878 100644 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.js.map +++ b/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.js.map @@ -1 +1 @@ -{"version":3,"file":"outAndOutDirFile.js","sourceRoot":"http://typescript.codeplex.com/","sources":["ref/m1.ts","test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACRD,iCAAiC;AACjC,iCAAiC;AACjC,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"outAndOutDirFile.js","sourceRoot":"http://typescript.codeplex.com/","sources":["ref/m1.ts","ref/m2.ts","test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","m2_c1","m2_c1.constructor","m2_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;;ICRU,aAAK,GAAG,EAAE,CAAC;IACtB;QAAAC;QAEAC,CAACA;QAADD,YAACA;IAADA,CAACA,AAFD,IAEC;IAFY,aAAK,QAEjB,CAAA;IAEU,oBAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACIE,MAAMA,CAACA,oBAAYA,CAACA;IACxBA,CAACA;IAFe,aAAK,QAEpB,CAAA;;ACRD,iCAAiC;AACjC,iCAAiC;AACjC,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory.sourcemap.txt b/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory.sourcemap.txt index 7793026dd6e..72dd27c642f 100644 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory.sourcemap.txt +++ b/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory.sourcemap.txt @@ -174,7 +174,7 @@ sourceFile:ref/m2.ts JsFile: outAndOutDirFile.js mapUrl: http://www.typescriptlang.org/outAndOutDirFile.js.map sourceRoot: http://typescript.codeplex.com/ -sources: ref/m1.ts,test.ts +sources: ref/m1.ts,ref/m2.ts,test.ts =================================================================== ------------------------------------------------------------------- emittedFile:bin/outAndOutDirFile.js @@ -306,7 +306,7 @@ sourceFile:ref/m1.ts >>>} 1 > 2 >^ -3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> 1 > > 2 >} @@ -315,16 +315,182 @@ sourceFile:ref/m1.ts --- ------------------------------------------------------------------- emittedFile:bin/outAndOutDirFile.js +sourceFile:ref/m2.ts +------------------------------------------------------------------- +>>>define("ref/m2", ["require", "exports"], function (require, exports) { +>>> exports.m2_a1 = 10; +1->^^^^ +2 > ^^^^^^^^^^^^^ +3 > ^^^ +4 > ^^ +5 > ^ +6 > ^^^^^^^^-> +1->export var +2 > m2_a1 +3 > = +4 > 10 +5 > ; +1->Emitted(12, 5) Source(1, 12) + SourceIndex(1) +2 >Emitted(12, 18) Source(1, 17) + SourceIndex(1) +3 >Emitted(12, 21) Source(1, 20) + SourceIndex(1) +4 >Emitted(12, 23) Source(1, 22) + SourceIndex(1) +5 >Emitted(12, 24) Source(1, 23) + SourceIndex(1) +--- +>>> var m2_c1 = (function () { +1->^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^^^^-> +1-> + > +1->Emitted(13, 5) Source(2, 1) + SourceIndex(1) +--- +>>> function m2_c1() { +1->^^^^^^^^ +2 > ^^-> +1-> +1->Emitted(14, 9) Source(2, 1) + SourceIndex(1) name (m2_c1) +--- +>>> } +1->^^^^^^^^ +2 > ^ +3 > ^^^^^^^^^^^^^-> +1->export class m2_c1 { + > public m2_c1_p1: number; + > +2 > } +1->Emitted(15, 9) Source(4, 1) + SourceIndex(1) name (m2_c1.constructor) +2 >Emitted(15, 10) Source(4, 2) + SourceIndex(1) name (m2_c1.constructor) +--- +>>> return m2_c1; +1->^^^^^^^^ +2 > ^^^^^^^^^^^^ +1-> +2 > } +1->Emitted(16, 9) Source(4, 1) + SourceIndex(1) name (m2_c1) +2 >Emitted(16, 21) Source(4, 2) + SourceIndex(1) name (m2_c1) +--- +>>> })(); +1 >^^^^ +2 > ^ +3 > +4 > ^^^^ +5 > ^^^^^^^^^^^^^^^^^^-> +1 > +2 > } +3 > +4 > export class m2_c1 { + > public m2_c1_p1: number; + > } +1 >Emitted(17, 5) Source(4, 1) + SourceIndex(1) name (m2_c1) +2 >Emitted(17, 6) Source(4, 2) + SourceIndex(1) name (m2_c1) +3 >Emitted(17, 6) Source(2, 1) + SourceIndex(1) +4 >Emitted(17, 10) Source(4, 2) + SourceIndex(1) +--- +>>> exports.m2_c1 = m2_c1; +1->^^^^ +2 > ^^^^^^^^^^^^^ +3 > ^^^^^^^^ +4 > ^ +5 > ^^^^^^^^^^^^^^-> +1-> +2 > m2_c1 +3 > { + > public m2_c1_p1: number; + > } +4 > +1->Emitted(18, 5) Source(2, 14) + SourceIndex(1) +2 >Emitted(18, 18) Source(2, 19) + SourceIndex(1) +3 >Emitted(18, 26) Source(4, 2) + SourceIndex(1) +4 >Emitted(18, 27) Source(4, 2) + SourceIndex(1) +--- +>>> exports.m2_instance1 = new m2_c1(); +1->^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^ +3 > ^^^ +4 > ^^^^ +5 > ^^^^^ +6 > ^^ +7 > ^ +1-> + > + >export var +2 > m2_instance1 +3 > = +4 > new +5 > m2_c1 +6 > () +7 > ; +1->Emitted(19, 5) Source(6, 12) + SourceIndex(1) +2 >Emitted(19, 25) Source(6, 24) + SourceIndex(1) +3 >Emitted(19, 28) Source(6, 27) + SourceIndex(1) +4 >Emitted(19, 32) Source(6, 31) + SourceIndex(1) +5 >Emitted(19, 37) Source(6, 36) + SourceIndex(1) +6 >Emitted(19, 39) Source(6, 38) + SourceIndex(1) +7 >Emitted(19, 40) Source(6, 39) + SourceIndex(1) +--- +>>> function m2_f1() { +1 >^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +1 > + > +1 >Emitted(20, 5) Source(7, 1) + SourceIndex(1) +--- +>>> return exports.m2_instance1; +1->^^^^^^^^ +2 > ^^^^^^ +3 > ^ +4 > ^^^^^^^^^^^^^^^^^^^^ +5 > ^ +1->export function m2_f1() { + > +2 > return +3 > +4 > m2_instance1 +5 > ; +1->Emitted(21, 9) Source(8, 5) + SourceIndex(1) name (m2_f1) +2 >Emitted(21, 15) Source(8, 11) + SourceIndex(1) name (m2_f1) +3 >Emitted(21, 16) Source(8, 12) + SourceIndex(1) name (m2_f1) +4 >Emitted(21, 36) Source(8, 24) + SourceIndex(1) name (m2_f1) +5 >Emitted(21, 37) Source(8, 25) + SourceIndex(1) name (m2_f1) +--- +>>> } +1 >^^^^ +2 > ^ +3 > ^^^^^^^^^^^^^^^^^^^^^^-> +1 > + > +2 > } +1 >Emitted(22, 5) Source(9, 1) + SourceIndex(1) name (m2_f1) +2 >Emitted(22, 6) Source(9, 2) + SourceIndex(1) name (m2_f1) +--- +>>> exports.m2_f1 = m2_f1; +1->^^^^ +2 > ^^^^^^^^^^^^^ +3 > ^^^^^^^^ +4 > ^ +1-> +2 > m2_f1 +3 > () { + > return m2_instance1; + > } +4 > +1->Emitted(23, 5) Source(7, 17) + SourceIndex(1) +2 >Emitted(23, 18) Source(7, 22) + SourceIndex(1) +3 >Emitted(23, 26) Source(9, 2) + SourceIndex(1) +4 >Emitted(23, 27) Source(9, 2) + SourceIndex(1) +--- +------------------------------------------------------------------- +emittedFile:bin/outAndOutDirFile.js sourceFile:test.ts ------------------------------------------------------------------- +>>>}); >>>/// -1-> +1 > 2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 3 > ^-> -1-> +1 > 2 >/// -1->Emitted(11, 1) Source(1, 1) + SourceIndex(1) -2 >Emitted(11, 34) Source(1, 34) + SourceIndex(1) +1 >Emitted(25, 1) Source(1, 1) + SourceIndex(2) +2 >Emitted(25, 34) Source(1, 34) + SourceIndex(2) --- >>>/// 1-> @@ -332,8 +498,8 @@ sourceFile:test.ts 1-> > 2 >/// -1->Emitted(12, 1) Source(2, 1) + SourceIndex(1) -2 >Emitted(12, 34) Source(2, 34) + SourceIndex(1) +1->Emitted(26, 1) Source(2, 1) + SourceIndex(2) +2 >Emitted(26, 34) Source(2, 34) + SourceIndex(2) --- >>>var a1 = 10; 1 > @@ -350,25 +516,25 @@ sourceFile:test.ts 4 > = 5 > 10 6 > ; -1 >Emitted(13, 1) Source(3, 1) + SourceIndex(1) -2 >Emitted(13, 5) Source(3, 5) + SourceIndex(1) -3 >Emitted(13, 7) Source(3, 7) + SourceIndex(1) -4 >Emitted(13, 10) Source(3, 10) + SourceIndex(1) -5 >Emitted(13, 12) Source(3, 12) + SourceIndex(1) -6 >Emitted(13, 13) Source(3, 13) + SourceIndex(1) +1 >Emitted(27, 1) Source(3, 1) + SourceIndex(2) +2 >Emitted(27, 5) Source(3, 5) + SourceIndex(2) +3 >Emitted(27, 7) Source(3, 7) + SourceIndex(2) +4 >Emitted(27, 10) Source(3, 10) + SourceIndex(2) +5 >Emitted(27, 12) Source(3, 12) + SourceIndex(2) +6 >Emitted(27, 13) Source(3, 13) + SourceIndex(2) --- >>>var c1 = (function () { 1-> 2 >^^^^^^^^^^^^^^^^^^^^-> 1-> > -1->Emitted(14, 1) Source(4, 1) + SourceIndex(1) +1->Emitted(28, 1) Source(4, 1) + SourceIndex(2) --- >>> function c1() { 1->^^^^ 2 > ^^-> 1-> -1->Emitted(15, 5) Source(4, 1) + SourceIndex(1) name (c1) +1->Emitted(29, 5) Source(4, 1) + SourceIndex(2) name (c1) --- >>> } 1->^^^^ @@ -378,16 +544,16 @@ sourceFile:test.ts > public p1: number; > 2 > } -1->Emitted(16, 5) Source(6, 1) + SourceIndex(1) name (c1.constructor) -2 >Emitted(16, 6) Source(6, 2) + SourceIndex(1) name (c1.constructor) +1->Emitted(30, 5) Source(6, 1) + SourceIndex(2) name (c1.constructor) +2 >Emitted(30, 6) Source(6, 2) + SourceIndex(2) name (c1.constructor) --- >>> return c1; 1->^^^^ 2 > ^^^^^^^^^ 1-> 2 > } -1->Emitted(17, 5) Source(6, 1) + SourceIndex(1) name (c1) -2 >Emitted(17, 14) Source(6, 2) + SourceIndex(1) name (c1) +1->Emitted(31, 5) Source(6, 1) + SourceIndex(2) name (c1) +2 >Emitted(31, 14) Source(6, 2) + SourceIndex(2) name (c1) --- >>>})(); 1 > @@ -401,10 +567,10 @@ sourceFile:test.ts 4 > class c1 { > public p1: number; > } -1 >Emitted(18, 1) Source(6, 1) + SourceIndex(1) name (c1) -2 >Emitted(18, 2) Source(6, 2) + SourceIndex(1) name (c1) -3 >Emitted(18, 2) Source(4, 1) + SourceIndex(1) -4 >Emitted(18, 6) Source(6, 2) + SourceIndex(1) +1 >Emitted(32, 1) Source(6, 1) + SourceIndex(2) name (c1) +2 >Emitted(32, 2) Source(6, 2) + SourceIndex(2) name (c1) +3 >Emitted(32, 2) Source(4, 1) + SourceIndex(2) +4 >Emitted(32, 6) Source(6, 2) + SourceIndex(2) --- >>>var instance1 = new c1(); 1-> @@ -425,21 +591,21 @@ sourceFile:test.ts 6 > c1 7 > () 8 > ; -1->Emitted(19, 1) Source(8, 1) + SourceIndex(1) -2 >Emitted(19, 5) Source(8, 5) + SourceIndex(1) -3 >Emitted(19, 14) Source(8, 14) + SourceIndex(1) -4 >Emitted(19, 17) Source(8, 17) + SourceIndex(1) -5 >Emitted(19, 21) Source(8, 21) + SourceIndex(1) -6 >Emitted(19, 23) Source(8, 23) + SourceIndex(1) -7 >Emitted(19, 25) Source(8, 25) + SourceIndex(1) -8 >Emitted(19, 26) Source(8, 26) + SourceIndex(1) +1->Emitted(33, 1) Source(8, 1) + SourceIndex(2) +2 >Emitted(33, 5) Source(8, 5) + SourceIndex(2) +3 >Emitted(33, 14) Source(8, 14) + SourceIndex(2) +4 >Emitted(33, 17) Source(8, 17) + SourceIndex(2) +5 >Emitted(33, 21) Source(8, 21) + SourceIndex(2) +6 >Emitted(33, 23) Source(8, 23) + SourceIndex(2) +7 >Emitted(33, 25) Source(8, 25) + SourceIndex(2) +8 >Emitted(33, 26) Source(8, 26) + SourceIndex(2) --- >>>function f1() { 1 > 2 >^^^^^^^^^^^^^^^^^^^^^^-> 1 > > -1 >Emitted(20, 1) Source(9, 1) + SourceIndex(1) +1 >Emitted(34, 1) Source(9, 1) + SourceIndex(2) --- >>> return instance1; 1->^^^^ @@ -453,11 +619,11 @@ sourceFile:test.ts 3 > 4 > instance1 5 > ; -1->Emitted(21, 5) Source(10, 5) + SourceIndex(1) name (f1) -2 >Emitted(21, 11) Source(10, 11) + SourceIndex(1) name (f1) -3 >Emitted(21, 12) Source(10, 12) + SourceIndex(1) name (f1) -4 >Emitted(21, 21) Source(10, 21) + SourceIndex(1) name (f1) -5 >Emitted(21, 22) Source(10, 22) + SourceIndex(1) name (f1) +1->Emitted(35, 5) Source(10, 5) + SourceIndex(2) name (f1) +2 >Emitted(35, 11) Source(10, 11) + SourceIndex(2) name (f1) +3 >Emitted(35, 12) Source(10, 12) + SourceIndex(2) name (f1) +4 >Emitted(35, 21) Source(10, 21) + SourceIndex(2) name (f1) +5 >Emitted(35, 22) Source(10, 22) + SourceIndex(2) name (f1) --- >>>} 1 > @@ -466,7 +632,7 @@ sourceFile:test.ts 1 > > 2 >} -1 >Emitted(22, 1) Source(11, 1) + SourceIndex(1) name (f1) -2 >Emitted(22, 2) Source(11, 2) + SourceIndex(1) name (f1) +1 >Emitted(36, 1) Source(11, 1) + SourceIndex(2) name (f1) +2 >Emitted(36, 2) Source(11, 2) + SourceIndex(2) name (f1) --- >>>//# sourceMappingURL=http://www.typescriptlang.org/outAndOutDirFile.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.d.ts b/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.d.ts deleted file mode 100644 index 9b9cdd4a214..00000000000 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.d.ts +++ /dev/null @@ -1,13 +0,0 @@ -/// -declare var m1_a1: number; -declare class m1_c1 { - m1_c1_p1: number; -} -declare var m1_instance1: m1_c1; -declare function m1_f1(): m1_c1; -declare var a1: number; -declare class c1 { - p1: number; -} -declare var instance1: c1; -declare function f1(): c1; diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.js b/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.js deleted file mode 100644 index 2ebe138ffda..00000000000 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.js +++ /dev/null @@ -1,23 +0,0 @@ -var m1_a1 = 10; -var m1_c1 = (function () { - function m1_c1() { - } - return m1_c1; -})(); -var m1_instance1 = new m1_c1(); -function m1_f1() { - return m1_instance1; -} -/// -/// -var a1 = 10; -var c1 = (function () { - function c1() { - } - return c1; -})(); -var instance1 = new c1(); -function f1() { - return instance1; -} -//# sourceMappingURL=http://www.typescriptlang.org/outAndOutDirFile.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.js.map b/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.js.map index 53e31e30260..ba9f4ee590c 100644 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.js.map +++ b/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.js.map @@ -1 +1 @@ -{"version":3,"file":"outAndOutDirFile.js","sourceRoot":"http://typescript.codeplex.com/","sources":["ref/m1.ts","test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACRD,iCAAiC;AACjC,iCAAiC;AACjC,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"outAndOutDirFile.js","sourceRoot":"http://typescript.codeplex.com/","sources":["ref/m1.ts","ref/m2.ts","test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;AERD,iCAAiC;AACjC,iCAAiC;AACjC,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory.sourcemap.txt b/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory.sourcemap.txt index a6deca12207..8284d795792 100644 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory.sourcemap.txt +++ b/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory.sourcemap.txt @@ -173,7 +173,7 @@ sourceFile:ref/m2.ts JsFile: outAndOutDirFile.js mapUrl: http://www.typescriptlang.org/outAndOutDirFile.js.map sourceRoot: http://typescript.codeplex.com/ -sources: ref/m1.ts,test.ts +sources: ref/m1.ts,ref/m2.ts,test.ts =================================================================== ------------------------------------------------------------------- emittedFile:bin/outAndOutDirFile.js @@ -322,8 +322,8 @@ sourceFile:test.ts 3 > ^-> 1-> 2 >/// -1->Emitted(11, 1) Source(1, 1) + SourceIndex(1) -2 >Emitted(11, 34) Source(1, 34) + SourceIndex(1) +1->Emitted(11, 1) Source(1, 1) + SourceIndex(2) +2 >Emitted(11, 34) Source(1, 34) + SourceIndex(2) --- >>>/// 1-> @@ -331,8 +331,8 @@ sourceFile:test.ts 1-> > 2 >/// -1->Emitted(12, 1) Source(2, 1) + SourceIndex(1) -2 >Emitted(12, 34) Source(2, 34) + SourceIndex(1) +1->Emitted(12, 1) Source(2, 1) + SourceIndex(2) +2 >Emitted(12, 34) Source(2, 34) + SourceIndex(2) --- >>>var a1 = 10; 1 > @@ -349,25 +349,25 @@ sourceFile:test.ts 4 > = 5 > 10 6 > ; -1 >Emitted(13, 1) Source(3, 1) + SourceIndex(1) -2 >Emitted(13, 5) Source(3, 5) + SourceIndex(1) -3 >Emitted(13, 7) Source(3, 7) + SourceIndex(1) -4 >Emitted(13, 10) Source(3, 10) + SourceIndex(1) -5 >Emitted(13, 12) Source(3, 12) + SourceIndex(1) -6 >Emitted(13, 13) Source(3, 13) + SourceIndex(1) +1 >Emitted(13, 1) Source(3, 1) + SourceIndex(2) +2 >Emitted(13, 5) Source(3, 5) + SourceIndex(2) +3 >Emitted(13, 7) Source(3, 7) + SourceIndex(2) +4 >Emitted(13, 10) Source(3, 10) + SourceIndex(2) +5 >Emitted(13, 12) Source(3, 12) + SourceIndex(2) +6 >Emitted(13, 13) Source(3, 13) + SourceIndex(2) --- >>>var c1 = (function () { 1-> 2 >^^^^^^^^^^^^^^^^^^^^-> 1-> > -1->Emitted(14, 1) Source(4, 1) + SourceIndex(1) +1->Emitted(14, 1) Source(4, 1) + SourceIndex(2) --- >>> function c1() { 1->^^^^ 2 > ^^-> 1-> -1->Emitted(15, 5) Source(4, 1) + SourceIndex(1) name (c1) +1->Emitted(15, 5) Source(4, 1) + SourceIndex(2) name (c1) --- >>> } 1->^^^^ @@ -377,16 +377,16 @@ sourceFile:test.ts > public p1: number; > 2 > } -1->Emitted(16, 5) Source(6, 1) + SourceIndex(1) name (c1.constructor) -2 >Emitted(16, 6) Source(6, 2) + SourceIndex(1) name (c1.constructor) +1->Emitted(16, 5) Source(6, 1) + SourceIndex(2) name (c1.constructor) +2 >Emitted(16, 6) Source(6, 2) + SourceIndex(2) name (c1.constructor) --- >>> return c1; 1->^^^^ 2 > ^^^^^^^^^ 1-> 2 > } -1->Emitted(17, 5) Source(6, 1) + SourceIndex(1) name (c1) -2 >Emitted(17, 14) Source(6, 2) + SourceIndex(1) name (c1) +1->Emitted(17, 5) Source(6, 1) + SourceIndex(2) name (c1) +2 >Emitted(17, 14) Source(6, 2) + SourceIndex(2) name (c1) --- >>>})(); 1 > @@ -400,10 +400,10 @@ sourceFile:test.ts 4 > class c1 { > public p1: number; > } -1 >Emitted(18, 1) Source(6, 1) + SourceIndex(1) name (c1) -2 >Emitted(18, 2) Source(6, 2) + SourceIndex(1) name (c1) -3 >Emitted(18, 2) Source(4, 1) + SourceIndex(1) -4 >Emitted(18, 6) Source(6, 2) + SourceIndex(1) +1 >Emitted(18, 1) Source(6, 1) + SourceIndex(2) name (c1) +2 >Emitted(18, 2) Source(6, 2) + SourceIndex(2) name (c1) +3 >Emitted(18, 2) Source(4, 1) + SourceIndex(2) +4 >Emitted(18, 6) Source(6, 2) + SourceIndex(2) --- >>>var instance1 = new c1(); 1-> @@ -424,21 +424,21 @@ sourceFile:test.ts 6 > c1 7 > () 8 > ; -1->Emitted(19, 1) Source(8, 1) + SourceIndex(1) -2 >Emitted(19, 5) Source(8, 5) + SourceIndex(1) -3 >Emitted(19, 14) Source(8, 14) + SourceIndex(1) -4 >Emitted(19, 17) Source(8, 17) + SourceIndex(1) -5 >Emitted(19, 21) Source(8, 21) + SourceIndex(1) -6 >Emitted(19, 23) Source(8, 23) + SourceIndex(1) -7 >Emitted(19, 25) Source(8, 25) + SourceIndex(1) -8 >Emitted(19, 26) Source(8, 26) + SourceIndex(1) +1->Emitted(19, 1) Source(8, 1) + SourceIndex(2) +2 >Emitted(19, 5) Source(8, 5) + SourceIndex(2) +3 >Emitted(19, 14) Source(8, 14) + SourceIndex(2) +4 >Emitted(19, 17) Source(8, 17) + SourceIndex(2) +5 >Emitted(19, 21) Source(8, 21) + SourceIndex(2) +6 >Emitted(19, 23) Source(8, 23) + SourceIndex(2) +7 >Emitted(19, 25) Source(8, 25) + SourceIndex(2) +8 >Emitted(19, 26) Source(8, 26) + SourceIndex(2) --- >>>function f1() { 1 > 2 >^^^^^^^^^^^^^^^^^^^^^^-> 1 > > -1 >Emitted(20, 1) Source(9, 1) + SourceIndex(1) +1 >Emitted(20, 1) Source(9, 1) + SourceIndex(2) --- >>> return instance1; 1->^^^^ @@ -452,11 +452,11 @@ sourceFile:test.ts 3 > 4 > instance1 5 > ; -1->Emitted(21, 5) Source(10, 5) + SourceIndex(1) name (f1) -2 >Emitted(21, 11) Source(10, 11) + SourceIndex(1) name (f1) -3 >Emitted(21, 12) Source(10, 12) + SourceIndex(1) name (f1) -4 >Emitted(21, 21) Source(10, 21) + SourceIndex(1) name (f1) -5 >Emitted(21, 22) Source(10, 22) + SourceIndex(1) name (f1) +1->Emitted(21, 5) Source(10, 5) + SourceIndex(2) name (f1) +2 >Emitted(21, 11) Source(10, 11) + SourceIndex(2) name (f1) +3 >Emitted(21, 12) Source(10, 12) + SourceIndex(2) name (f1) +4 >Emitted(21, 21) Source(10, 21) + SourceIndex(2) name (f1) +5 >Emitted(21, 22) Source(10, 22) + SourceIndex(2) name (f1) --- >>>} 1 > @@ -465,7 +465,7 @@ sourceFile:test.ts 1 > > 2 >} -1 >Emitted(22, 1) Source(11, 1) + SourceIndex(1) name (f1) -2 >Emitted(22, 2) Source(11, 2) + SourceIndex(1) name (f1) +1 >Emitted(22, 1) Source(11, 1) + SourceIndex(2) name (f1) +2 >Emitted(22, 2) Source(11, 2) + SourceIndex(2) name (f1) --- >>>//# sourceMappingURL=http://www.typescriptlang.org/outAndOutDirFile.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputFile/amd/bin/test.d.ts b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputFile/amd/bin/test.d.ts deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputFile/amd/bin/test.js b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputFile/amd/bin/test.js deleted file mode 100644 index 52f1b822100..00000000000 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputFile/amd/bin/test.js +++ /dev/null @@ -1 +0,0 @@ -//# sourceMappingURL=http://www.typescriptlang.org/test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputFile/amd/bin/test.js.map b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputFile/amd/bin/test.js.map index d3e851981ec..85e465474d3 100644 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputFile/amd/bin/test.js.map +++ b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputFile/amd/bin/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"http://typescript.codeplex.com/","sources":[],"names":[],"mappings":""} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"http://typescript.codeplex.com/","sources":["outputdir_module_multifolder/ref/m1.ts","outputdir_module_multifolder_ref/m2.ts","outputdir_module_multifolder/test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","m2_c1","m2_c1.constructor","m2_f1","c1","c1.constructor","f1"],"mappings":";IAAW,aAAK,GAAG,EAAE,CAAC;IACtB;QAAAA;QAEAC,CAACA;QAADD,YAACA;IAADA,CAACA,AAFD,IAEC;IAFY,aAAK,QAEjB,CAAA;IAEU,oBAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACIE,MAAMA,CAACA,oBAAYA,CAACA;IACxBA,CAACA;IAFe,aAAK,QAEpB,CAAA;;;ICRU,aAAK,GAAG,EAAE,CAAC;IACtB;QAAAC;QAEAC,CAACA;QAADD,YAACA;IAADA,CAACA,AAFD,IAEC;IAFY,aAAK,QAEjB,CAAA;IAEU,oBAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACIE,MAAMA,CAACA,oBAAYA,CAACA;IACxBA,CAACA;IAFe,aAAK,QAEpB,CAAA;;;ICNU,UAAE,GAAG,EAAE,CAAC;IACnB;QAAAC;QAEAC,CAACA;QAADD,SAACA;IAADA,CAACA,AAFD,IAEC;IAFY,UAAE,KAEd,CAAA;IAEU,iBAAS,GAAG,IAAI,EAAE,EAAE,CAAC;IAChC;QACIE,MAAMA,CAACA,iBAASA,CAACA;IACrBA,CAACA;IAFe,UAAE,KAEjB,CAAA;IAEU,UAAE,GAAG,EAAE,CAAC,KAAK,CAAC;IACd,UAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputFile/amd/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputFile.sourcemap.txt b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputFile/amd/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputFile.sourcemap.txt index deb74d2ae36..4eb71f2bf29 100644 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputFile/amd/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputFile.sourcemap.txt +++ b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputFile/amd/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputFile.sourcemap.txt @@ -571,6 +571,557 @@ sourceFile:outputdir_module_multifolder/test.ts JsFile: test.js mapUrl: http://www.typescriptlang.org/test.js.map sourceRoot: http://typescript.codeplex.com/ -sources: +sources: outputdir_module_multifolder/ref/m1.ts,outputdir_module_multifolder_ref/m2.ts,outputdir_module_multifolder/test.ts =================================================================== +------------------------------------------------------------------- +emittedFile:bin/test.js +sourceFile:outputdir_module_multifolder/ref/m1.ts +------------------------------------------------------------------- +>>>define("ref/m1", ["require", "exports"], function (require, exports) { +>>> exports.m1_a1 = 10; +1 >^^^^ +2 > ^^^^^^^^^^^^^ +3 > ^^^ +4 > ^^ +5 > ^ +6 > ^^^^^^^^-> +1 >export var +2 > m1_a1 +3 > = +4 > 10 +5 > ; +1 >Emitted(2, 5) Source(1, 12) + SourceIndex(0) +2 >Emitted(2, 18) Source(1, 17) + SourceIndex(0) +3 >Emitted(2, 21) Source(1, 20) + SourceIndex(0) +4 >Emitted(2, 23) Source(1, 22) + SourceIndex(0) +5 >Emitted(2, 24) Source(1, 23) + SourceIndex(0) +--- +>>> var m1_c1 = (function () { +1->^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^^^^-> +1-> + > +1->Emitted(3, 5) Source(2, 1) + SourceIndex(0) +--- +>>> function m1_c1() { +1->^^^^^^^^ +2 > ^^-> +1-> +1->Emitted(4, 9) Source(2, 1) + SourceIndex(0) name (m1_c1) +--- +>>> } +1->^^^^^^^^ +2 > ^ +3 > ^^^^^^^^^^^^^-> +1->export class m1_c1 { + > public m1_c1_p1: number; + > +2 > } +1->Emitted(5, 9) Source(4, 1) + SourceIndex(0) name (m1_c1.constructor) +2 >Emitted(5, 10) Source(4, 2) + SourceIndex(0) name (m1_c1.constructor) +--- +>>> return m1_c1; +1->^^^^^^^^ +2 > ^^^^^^^^^^^^ +1-> +2 > } +1->Emitted(6, 9) Source(4, 1) + SourceIndex(0) name (m1_c1) +2 >Emitted(6, 21) Source(4, 2) + SourceIndex(0) name (m1_c1) +--- +>>> })(); +1 >^^^^ +2 > ^ +3 > +4 > ^^^^ +5 > ^^^^^^^^^^^^^^^^^^-> +1 > +2 > } +3 > +4 > export class m1_c1 { + > public m1_c1_p1: number; + > } +1 >Emitted(7, 5) Source(4, 1) + SourceIndex(0) name (m1_c1) +2 >Emitted(7, 6) Source(4, 2) + SourceIndex(0) name (m1_c1) +3 >Emitted(7, 6) Source(2, 1) + SourceIndex(0) +4 >Emitted(7, 10) Source(4, 2) + SourceIndex(0) +--- +>>> exports.m1_c1 = m1_c1; +1->^^^^ +2 > ^^^^^^^^^^^^^ +3 > ^^^^^^^^ +4 > ^ +5 > ^^^^^^^^^^^^^^-> +1-> +2 > m1_c1 +3 > { + > public m1_c1_p1: number; + > } +4 > +1->Emitted(8, 5) Source(2, 14) + SourceIndex(0) +2 >Emitted(8, 18) Source(2, 19) + SourceIndex(0) +3 >Emitted(8, 26) Source(4, 2) + SourceIndex(0) +4 >Emitted(8, 27) Source(4, 2) + SourceIndex(0) +--- +>>> exports.m1_instance1 = new m1_c1(); +1->^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^ +3 > ^^^ +4 > ^^^^ +5 > ^^^^^ +6 > ^^ +7 > ^ +1-> + > + >export var +2 > m1_instance1 +3 > = +4 > new +5 > m1_c1 +6 > () +7 > ; +1->Emitted(9, 5) Source(6, 12) + SourceIndex(0) +2 >Emitted(9, 25) Source(6, 24) + SourceIndex(0) +3 >Emitted(9, 28) Source(6, 27) + SourceIndex(0) +4 >Emitted(9, 32) Source(6, 31) + SourceIndex(0) +5 >Emitted(9, 37) Source(6, 36) + SourceIndex(0) +6 >Emitted(9, 39) Source(6, 38) + SourceIndex(0) +7 >Emitted(9, 40) Source(6, 39) + SourceIndex(0) +--- +>>> function m1_f1() { +1 >^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +1 > + > +1 >Emitted(10, 5) Source(7, 1) + SourceIndex(0) +--- +>>> return exports.m1_instance1; +1->^^^^^^^^ +2 > ^^^^^^ +3 > ^ +4 > ^^^^^^^^^^^^^^^^^^^^ +5 > ^ +1->export function m1_f1() { + > +2 > return +3 > +4 > m1_instance1 +5 > ; +1->Emitted(11, 9) Source(8, 5) + SourceIndex(0) name (m1_f1) +2 >Emitted(11, 15) Source(8, 11) + SourceIndex(0) name (m1_f1) +3 >Emitted(11, 16) Source(8, 12) + SourceIndex(0) name (m1_f1) +4 >Emitted(11, 36) Source(8, 24) + SourceIndex(0) name (m1_f1) +5 >Emitted(11, 37) Source(8, 25) + SourceIndex(0) name (m1_f1) +--- +>>> } +1 >^^^^ +2 > ^ +3 > ^^^^^^^^^^^^^^^^^^^^^^-> +1 > + > +2 > } +1 >Emitted(12, 5) Source(9, 1) + SourceIndex(0) name (m1_f1) +2 >Emitted(12, 6) Source(9, 2) + SourceIndex(0) name (m1_f1) +--- +>>> exports.m1_f1 = m1_f1; +1->^^^^ +2 > ^^^^^^^^^^^^^ +3 > ^^^^^^^^ +4 > ^ +1-> +2 > m1_f1 +3 > () { + > return m1_instance1; + > } +4 > +1->Emitted(13, 5) Source(7, 17) + SourceIndex(0) +2 >Emitted(13, 18) Source(7, 22) + SourceIndex(0) +3 >Emitted(13, 26) Source(9, 2) + SourceIndex(0) +4 >Emitted(13, 27) Source(9, 2) + SourceIndex(0) +--- +------------------------------------------------------------------- +emittedFile:bin/test.js +sourceFile:outputdir_module_multifolder_ref/m2.ts +------------------------------------------------------------------- +>>>}); +>>>define("../outputdir_module_multifolder_ref/m2", ["require", "exports"], function (require, exports) { +>>> exports.m2_a1 = 10; +1 >^^^^ +2 > ^^^^^^^^^^^^^ +3 > ^^^ +4 > ^^ +5 > ^ +6 > ^^^^^^^^-> +1 >export var +2 > m2_a1 +3 > = +4 > 10 +5 > ; +1 >Emitted(16, 5) Source(1, 12) + SourceIndex(1) +2 >Emitted(16, 18) Source(1, 17) + SourceIndex(1) +3 >Emitted(16, 21) Source(1, 20) + SourceIndex(1) +4 >Emitted(16, 23) Source(1, 22) + SourceIndex(1) +5 >Emitted(16, 24) Source(1, 23) + SourceIndex(1) +--- +>>> var m2_c1 = (function () { +1->^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^^^^-> +1-> + > +1->Emitted(17, 5) Source(2, 1) + SourceIndex(1) +--- +>>> function m2_c1() { +1->^^^^^^^^ +2 > ^^-> +1-> +1->Emitted(18, 9) Source(2, 1) + SourceIndex(1) name (m2_c1) +--- +>>> } +1->^^^^^^^^ +2 > ^ +3 > ^^^^^^^^^^^^^-> +1->export class m2_c1 { + > public m2_c1_p1: number; + > +2 > } +1->Emitted(19, 9) Source(4, 1) + SourceIndex(1) name (m2_c1.constructor) +2 >Emitted(19, 10) Source(4, 2) + SourceIndex(1) name (m2_c1.constructor) +--- +>>> return m2_c1; +1->^^^^^^^^ +2 > ^^^^^^^^^^^^ +1-> +2 > } +1->Emitted(20, 9) Source(4, 1) + SourceIndex(1) name (m2_c1) +2 >Emitted(20, 21) Source(4, 2) + SourceIndex(1) name (m2_c1) +--- +>>> })(); +1 >^^^^ +2 > ^ +3 > +4 > ^^^^ +5 > ^^^^^^^^^^^^^^^^^^-> +1 > +2 > } +3 > +4 > export class m2_c1 { + > public m2_c1_p1: number; + > } +1 >Emitted(21, 5) Source(4, 1) + SourceIndex(1) name (m2_c1) +2 >Emitted(21, 6) Source(4, 2) + SourceIndex(1) name (m2_c1) +3 >Emitted(21, 6) Source(2, 1) + SourceIndex(1) +4 >Emitted(21, 10) Source(4, 2) + SourceIndex(1) +--- +>>> exports.m2_c1 = m2_c1; +1->^^^^ +2 > ^^^^^^^^^^^^^ +3 > ^^^^^^^^ +4 > ^ +5 > ^^^^^^^^^^^^^^-> +1-> +2 > m2_c1 +3 > { + > public m2_c1_p1: number; + > } +4 > +1->Emitted(22, 5) Source(2, 14) + SourceIndex(1) +2 >Emitted(22, 18) Source(2, 19) + SourceIndex(1) +3 >Emitted(22, 26) Source(4, 2) + SourceIndex(1) +4 >Emitted(22, 27) Source(4, 2) + SourceIndex(1) +--- +>>> exports.m2_instance1 = new m2_c1(); +1->^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^ +3 > ^^^ +4 > ^^^^ +5 > ^^^^^ +6 > ^^ +7 > ^ +1-> + > + >export var +2 > m2_instance1 +3 > = +4 > new +5 > m2_c1 +6 > () +7 > ; +1->Emitted(23, 5) Source(6, 12) + SourceIndex(1) +2 >Emitted(23, 25) Source(6, 24) + SourceIndex(1) +3 >Emitted(23, 28) Source(6, 27) + SourceIndex(1) +4 >Emitted(23, 32) Source(6, 31) + SourceIndex(1) +5 >Emitted(23, 37) Source(6, 36) + SourceIndex(1) +6 >Emitted(23, 39) Source(6, 38) + SourceIndex(1) +7 >Emitted(23, 40) Source(6, 39) + SourceIndex(1) +--- +>>> function m2_f1() { +1 >^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +1 > + > +1 >Emitted(24, 5) Source(7, 1) + SourceIndex(1) +--- +>>> return exports.m2_instance1; +1->^^^^^^^^ +2 > ^^^^^^ +3 > ^ +4 > ^^^^^^^^^^^^^^^^^^^^ +5 > ^ +1->export function m2_f1() { + > +2 > return +3 > +4 > m2_instance1 +5 > ; +1->Emitted(25, 9) Source(8, 5) + SourceIndex(1) name (m2_f1) +2 >Emitted(25, 15) Source(8, 11) + SourceIndex(1) name (m2_f1) +3 >Emitted(25, 16) Source(8, 12) + SourceIndex(1) name (m2_f1) +4 >Emitted(25, 36) Source(8, 24) + SourceIndex(1) name (m2_f1) +5 >Emitted(25, 37) Source(8, 25) + SourceIndex(1) name (m2_f1) +--- +>>> } +1 >^^^^ +2 > ^ +3 > ^^^^^^^^^^^^^^^^^^^^^^-> +1 > + > +2 > } +1 >Emitted(26, 5) Source(9, 1) + SourceIndex(1) name (m2_f1) +2 >Emitted(26, 6) Source(9, 2) + SourceIndex(1) name (m2_f1) +--- +>>> exports.m2_f1 = m2_f1; +1->^^^^ +2 > ^^^^^^^^^^^^^ +3 > ^^^^^^^^ +4 > ^ +1-> +2 > m2_f1 +3 > () { + > return m2_instance1; + > } +4 > +1->Emitted(27, 5) Source(7, 17) + SourceIndex(1) +2 >Emitted(27, 18) Source(7, 22) + SourceIndex(1) +3 >Emitted(27, 26) Source(9, 2) + SourceIndex(1) +4 >Emitted(27, 27) Source(9, 2) + SourceIndex(1) +--- +------------------------------------------------------------------- +emittedFile:bin/test.js +sourceFile:outputdir_module_multifolder/test.ts +------------------------------------------------------------------- +>>>}); +>>>define("test", ["require", "exports", "ref/m1", "../outputdir_module_multifolder_ref/m2"], function (require, exports, m1, m2) { +>>> exports.a1 = 10; +1 >^^^^ +2 > ^^^^^^^^^^ +3 > ^^^ +4 > ^^ +5 > ^ +6 > ^^^^^^^^-> +1 >import m1 = require("ref/m1"); + >import m2 = require("../outputdir_module_multifolder_ref/m2"); + >export var +2 > a1 +3 > = +4 > 10 +5 > ; +1 >Emitted(30, 5) Source(3, 12) + SourceIndex(2) +2 >Emitted(30, 15) Source(3, 14) + SourceIndex(2) +3 >Emitted(30, 18) Source(3, 17) + SourceIndex(2) +4 >Emitted(30, 20) Source(3, 19) + SourceIndex(2) +5 >Emitted(30, 21) Source(3, 20) + SourceIndex(2) +--- +>>> var c1 = (function () { +1->^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^-> +1-> + > +1->Emitted(31, 5) Source(4, 1) + SourceIndex(2) +--- +>>> function c1() { +1->^^^^^^^^ +2 > ^^-> +1-> +1->Emitted(32, 9) Source(4, 1) + SourceIndex(2) name (c1) +--- +>>> } +1->^^^^^^^^ +2 > ^ +3 > ^^^^^^^^^^-> +1->export class c1 { + > public p1: number; + > +2 > } +1->Emitted(33, 9) Source(6, 1) + SourceIndex(2) name (c1.constructor) +2 >Emitted(33, 10) Source(6, 2) + SourceIndex(2) name (c1.constructor) +--- +>>> return c1; +1->^^^^^^^^ +2 > ^^^^^^^^^ +1-> +2 > } +1->Emitted(34, 9) Source(6, 1) + SourceIndex(2) name (c1) +2 >Emitted(34, 18) Source(6, 2) + SourceIndex(2) name (c1) +--- +>>> })(); +1 >^^^^ +2 > ^ +3 > +4 > ^^^^ +5 > ^^^^^^^^^^^^-> +1 > +2 > } +3 > +4 > export class c1 { + > public p1: number; + > } +1 >Emitted(35, 5) Source(6, 1) + SourceIndex(2) name (c1) +2 >Emitted(35, 6) Source(6, 2) + SourceIndex(2) name (c1) +3 >Emitted(35, 6) Source(4, 1) + SourceIndex(2) +4 >Emitted(35, 10) Source(6, 2) + SourceIndex(2) +--- +>>> exports.c1 = c1; +1->^^^^ +2 > ^^^^^^^^^^ +3 > ^^^^^ +4 > ^ +5 > ^^^^^^^^^^^^^^-> +1-> +2 > c1 +3 > { + > public p1: number; + > } +4 > +1->Emitted(36, 5) Source(4, 14) + SourceIndex(2) +2 >Emitted(36, 15) Source(4, 16) + SourceIndex(2) +3 >Emitted(36, 20) Source(6, 2) + SourceIndex(2) +4 >Emitted(36, 21) Source(6, 2) + SourceIndex(2) +--- +>>> exports.instance1 = new c1(); +1->^^^^ +2 > ^^^^^^^^^^^^^^^^^ +3 > ^^^ +4 > ^^^^ +5 > ^^ +6 > ^^ +7 > ^ +1-> + > + >export var +2 > instance1 +3 > = +4 > new +5 > c1 +6 > () +7 > ; +1->Emitted(37, 5) Source(8, 12) + SourceIndex(2) +2 >Emitted(37, 22) Source(8, 21) + SourceIndex(2) +3 >Emitted(37, 25) Source(8, 24) + SourceIndex(2) +4 >Emitted(37, 29) Source(8, 28) + SourceIndex(2) +5 >Emitted(37, 31) Source(8, 30) + SourceIndex(2) +6 >Emitted(37, 33) Source(8, 32) + SourceIndex(2) +7 >Emitted(37, 34) Source(8, 33) + SourceIndex(2) +--- +>>> function f1() { +1 >^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +1 > + > +1 >Emitted(38, 5) Source(9, 1) + SourceIndex(2) +--- +>>> return exports.instance1; +1->^^^^^^^^ +2 > ^^^^^^ +3 > ^ +4 > ^^^^^^^^^^^^^^^^^ +5 > ^ +1->export function f1() { + > +2 > return +3 > +4 > instance1 +5 > ; +1->Emitted(39, 9) Source(10, 5) + SourceIndex(2) name (f1) +2 >Emitted(39, 15) Source(10, 11) + SourceIndex(2) name (f1) +3 >Emitted(39, 16) Source(10, 12) + SourceIndex(2) name (f1) +4 >Emitted(39, 33) Source(10, 21) + SourceIndex(2) name (f1) +5 >Emitted(39, 34) Source(10, 22) + SourceIndex(2) name (f1) +--- +>>> } +1 >^^^^ +2 > ^ +3 > ^^^^^^^^^^^^^^^^-> +1 > + > +2 > } +1 >Emitted(40, 5) Source(11, 1) + SourceIndex(2) name (f1) +2 >Emitted(40, 6) Source(11, 2) + SourceIndex(2) name (f1) +--- +>>> exports.f1 = f1; +1->^^^^ +2 > ^^^^^^^^^^ +3 > ^^^^^ +4 > ^ +5 > ^^^^^^^-> +1-> +2 > f1 +3 > () { + > return instance1; + > } +4 > +1->Emitted(41, 5) Source(9, 17) + SourceIndex(2) +2 >Emitted(41, 15) Source(9, 19) + SourceIndex(2) +3 >Emitted(41, 20) Source(11, 2) + SourceIndex(2) +4 >Emitted(41, 21) Source(11, 2) + SourceIndex(2) +--- +>>> exports.a2 = m1.m1_c1; +1->^^^^ +2 > ^^^^^^^^^^ +3 > ^^^ +4 > ^^ +5 > ^ +6 > ^^^^^ +7 > ^ +8 > ^-> +1-> + > + >export var +2 > a2 +3 > = +4 > m1 +5 > . +6 > m1_c1 +7 > ; +1->Emitted(42, 5) Source(13, 12) + SourceIndex(2) +2 >Emitted(42, 15) Source(13, 14) + SourceIndex(2) +3 >Emitted(42, 18) Source(13, 17) + SourceIndex(2) +4 >Emitted(42, 20) Source(13, 19) + SourceIndex(2) +5 >Emitted(42, 21) Source(13, 20) + SourceIndex(2) +6 >Emitted(42, 26) Source(13, 25) + SourceIndex(2) +7 >Emitted(42, 27) Source(13, 26) + SourceIndex(2) +--- +>>> exports.a3 = m2.m2_c1; +1->^^^^ +2 > ^^^^^^^^^^ +3 > ^^^ +4 > ^^ +5 > ^ +6 > ^^^^^ +7 > ^ +1-> + >export var +2 > a3 +3 > = +4 > m2 +5 > . +6 > m2_c1 +7 > ; +1->Emitted(43, 5) Source(14, 12) + SourceIndex(2) +2 >Emitted(43, 15) Source(14, 14) + SourceIndex(2) +3 >Emitted(43, 18) Source(14, 17) + SourceIndex(2) +4 >Emitted(43, 20) Source(14, 19) + SourceIndex(2) +5 >Emitted(43, 21) Source(14, 20) + SourceIndex(2) +6 >Emitted(43, 26) Source(14, 25) + SourceIndex(2) +7 >Emitted(43, 27) Source(14, 26) + SourceIndex(2) +--- +>>>}); >>>//# sourceMappingURL=http://www.typescriptlang.org/test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputFile/node/bin/test.d.ts b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputFile/node/bin/test.d.ts deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputFile/node/bin/test.js b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputFile/node/bin/test.js deleted file mode 100644 index 52f1b822100..00000000000 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputFile/node/bin/test.js +++ /dev/null @@ -1 +0,0 @@ -//# sourceMappingURL=http://www.typescriptlang.org/test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputFile/node/bin/test.js.map b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputFile/node/bin/test.js.map index d3e851981ec..f84040526ba 100644 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputFile/node/bin/test.js.map +++ b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputFile/node/bin/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"http://typescript.codeplex.com/","sources":[],"names":[],"mappings":""} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"http://typescript.codeplex.com/","sources":["outputdir_module_multifolder/ref/m1.ts","outputdir_module_multifolder_ref/m2.ts","outputdir_module_multifolder/test.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputFile/node/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputFile.sourcemap.txt b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputFile/node/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputFile.sourcemap.txt index 5f476cfb8ed..77c5e460779 100644 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputFile/node/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputFile.sourcemap.txt +++ b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputFile/node/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputFile.sourcemap.txt @@ -615,6 +615,6 @@ sourceFile:outputdir_module_multifolder/test.ts JsFile: test.js mapUrl: http://www.typescriptlang.org/test.js.map sourceRoot: http://typescript.codeplex.com/ -sources: +sources: outputdir_module_multifolder/ref/m1.ts,outputdir_module_multifolder_ref/m2.ts,outputdir_module_multifolder/test.ts =================================================================== >>>//# sourceMappingURL=http://www.typescriptlang.org/test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSimpleSpecifyOutputFile/amd/bin/test.d.ts b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSimpleSpecifyOutputFile/amd/bin/test.d.ts deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSimpleSpecifyOutputFile/amd/bin/test.js b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSimpleSpecifyOutputFile/amd/bin/test.js deleted file mode 100644 index 52f1b822100..00000000000 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSimpleSpecifyOutputFile/amd/bin/test.js +++ /dev/null @@ -1 +0,0 @@ -//# sourceMappingURL=http://www.typescriptlang.org/test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSimpleSpecifyOutputFile/amd/bin/test.js.map b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSimpleSpecifyOutputFile/amd/bin/test.js.map index d3e851981ec..2ace469f902 100644 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSimpleSpecifyOutputFile/amd/bin/test.js.map +++ b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSimpleSpecifyOutputFile/amd/bin/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"http://typescript.codeplex.com/","sources":[],"names":[],"mappings":""} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"http://typescript.codeplex.com/","sources":["m1.ts","test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","c1","c1.constructor","f1"],"mappings":";IAAW,aAAK,GAAG,EAAE,CAAC;IACtB;QAAAA;QAEAC,CAACA;QAADD,YAACA;IAADA,CAACA,AAFD,IAEC;IAFY,aAAK,QAEjB,CAAA;IAEU,oBAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACIE,MAAMA,CAACA,oBAAYA,CAACA;IACxBA,CAACA;IAFe,aAAK,QAEpB,CAAA;;;ICPU,UAAE,GAAG,EAAE,CAAC;IACnB;QAAAC;QAEAC,CAACA;QAADD,SAACA;IAADA,CAACA,AAFD,IAEC;IAFY,UAAE,KAEd,CAAA;IAEU,iBAAS,GAAG,IAAI,EAAE,EAAE,CAAC;IAChC;QACIE,MAAMA,CAACA,iBAASA,CAACA;IACrBA,CAACA;IAFe,UAAE,KAEjB,CAAA;IAEU,UAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSimpleSpecifyOutputFile/amd/maprootUrlsourcerootUrlModuleSimpleSpecifyOutputFile.sourcemap.txt b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSimpleSpecifyOutputFile/amd/maprootUrlsourcerootUrlModuleSimpleSpecifyOutputFile.sourcemap.txt index 8b526ff5859..6e3a046bb27 100644 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSimpleSpecifyOutputFile/amd/maprootUrlsourcerootUrlModuleSimpleSpecifyOutputFile.sourcemap.txt +++ b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSimpleSpecifyOutputFile/amd/maprootUrlsourcerootUrlModuleSimpleSpecifyOutputFile.sourcemap.txt @@ -373,6 +373,365 @@ sourceFile:test.ts JsFile: test.js mapUrl: http://www.typescriptlang.org/test.js.map sourceRoot: http://typescript.codeplex.com/ -sources: +sources: m1.ts,test.ts =================================================================== +------------------------------------------------------------------- +emittedFile:bin/test.js +sourceFile:m1.ts +------------------------------------------------------------------- +>>>define("m1", ["require", "exports"], function (require, exports) { +>>> exports.m1_a1 = 10; +1 >^^^^ +2 > ^^^^^^^^^^^^^ +3 > ^^^ +4 > ^^ +5 > ^ +6 > ^^^^^^^^-> +1 >export var +2 > m1_a1 +3 > = +4 > 10 +5 > ; +1 >Emitted(2, 5) Source(1, 12) + SourceIndex(0) +2 >Emitted(2, 18) Source(1, 17) + SourceIndex(0) +3 >Emitted(2, 21) Source(1, 20) + SourceIndex(0) +4 >Emitted(2, 23) Source(1, 22) + SourceIndex(0) +5 >Emitted(2, 24) Source(1, 23) + SourceIndex(0) +--- +>>> var m1_c1 = (function () { +1->^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^^^^-> +1-> + > +1->Emitted(3, 5) Source(2, 1) + SourceIndex(0) +--- +>>> function m1_c1() { +1->^^^^^^^^ +2 > ^^-> +1-> +1->Emitted(4, 9) Source(2, 1) + SourceIndex(0) name (m1_c1) +--- +>>> } +1->^^^^^^^^ +2 > ^ +3 > ^^^^^^^^^^^^^-> +1->export class m1_c1 { + > public m1_c1_p1: number; + > +2 > } +1->Emitted(5, 9) Source(4, 1) + SourceIndex(0) name (m1_c1.constructor) +2 >Emitted(5, 10) Source(4, 2) + SourceIndex(0) name (m1_c1.constructor) +--- +>>> return m1_c1; +1->^^^^^^^^ +2 > ^^^^^^^^^^^^ +1-> +2 > } +1->Emitted(6, 9) Source(4, 1) + SourceIndex(0) name (m1_c1) +2 >Emitted(6, 21) Source(4, 2) + SourceIndex(0) name (m1_c1) +--- +>>> })(); +1 >^^^^ +2 > ^ +3 > +4 > ^^^^ +5 > ^^^^^^^^^^^^^^^^^^-> +1 > +2 > } +3 > +4 > export class m1_c1 { + > public m1_c1_p1: number; + > } +1 >Emitted(7, 5) Source(4, 1) + SourceIndex(0) name (m1_c1) +2 >Emitted(7, 6) Source(4, 2) + SourceIndex(0) name (m1_c1) +3 >Emitted(7, 6) Source(2, 1) + SourceIndex(0) +4 >Emitted(7, 10) Source(4, 2) + SourceIndex(0) +--- +>>> exports.m1_c1 = m1_c1; +1->^^^^ +2 > ^^^^^^^^^^^^^ +3 > ^^^^^^^^ +4 > ^ +5 > ^^^^^^^^^^^^^^-> +1-> +2 > m1_c1 +3 > { + > public m1_c1_p1: number; + > } +4 > +1->Emitted(8, 5) Source(2, 14) + SourceIndex(0) +2 >Emitted(8, 18) Source(2, 19) + SourceIndex(0) +3 >Emitted(8, 26) Source(4, 2) + SourceIndex(0) +4 >Emitted(8, 27) Source(4, 2) + SourceIndex(0) +--- +>>> exports.m1_instance1 = new m1_c1(); +1->^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^ +3 > ^^^ +4 > ^^^^ +5 > ^^^^^ +6 > ^^ +7 > ^ +1-> + > + >export var +2 > m1_instance1 +3 > = +4 > new +5 > m1_c1 +6 > () +7 > ; +1->Emitted(9, 5) Source(6, 12) + SourceIndex(0) +2 >Emitted(9, 25) Source(6, 24) + SourceIndex(0) +3 >Emitted(9, 28) Source(6, 27) + SourceIndex(0) +4 >Emitted(9, 32) Source(6, 31) + SourceIndex(0) +5 >Emitted(9, 37) Source(6, 36) + SourceIndex(0) +6 >Emitted(9, 39) Source(6, 38) + SourceIndex(0) +7 >Emitted(9, 40) Source(6, 39) + SourceIndex(0) +--- +>>> function m1_f1() { +1 >^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +1 > + > +1 >Emitted(10, 5) Source(7, 1) + SourceIndex(0) +--- +>>> return exports.m1_instance1; +1->^^^^^^^^ +2 > ^^^^^^ +3 > ^ +4 > ^^^^^^^^^^^^^^^^^^^^ +5 > ^ +1->export function m1_f1() { + > +2 > return +3 > +4 > m1_instance1 +5 > ; +1->Emitted(11, 9) Source(8, 5) + SourceIndex(0) name (m1_f1) +2 >Emitted(11, 15) Source(8, 11) + SourceIndex(0) name (m1_f1) +3 >Emitted(11, 16) Source(8, 12) + SourceIndex(0) name (m1_f1) +4 >Emitted(11, 36) Source(8, 24) + SourceIndex(0) name (m1_f1) +5 >Emitted(11, 37) Source(8, 25) + SourceIndex(0) name (m1_f1) +--- +>>> } +1 >^^^^ +2 > ^ +3 > ^^^^^^^^^^^^^^^^^^^^^^-> +1 > + > +2 > } +1 >Emitted(12, 5) Source(9, 1) + SourceIndex(0) name (m1_f1) +2 >Emitted(12, 6) Source(9, 2) + SourceIndex(0) name (m1_f1) +--- +>>> exports.m1_f1 = m1_f1; +1->^^^^ +2 > ^^^^^^^^^^^^^ +3 > ^^^^^^^^ +4 > ^ +1-> +2 > m1_f1 +3 > () { + > return m1_instance1; + > } +4 > +1->Emitted(13, 5) Source(7, 17) + SourceIndex(0) +2 >Emitted(13, 18) Source(7, 22) + SourceIndex(0) +3 >Emitted(13, 26) Source(9, 2) + SourceIndex(0) +4 >Emitted(13, 27) Source(9, 2) + SourceIndex(0) +--- +------------------------------------------------------------------- +emittedFile:bin/test.js +sourceFile:test.ts +------------------------------------------------------------------- +>>>}); +>>>define("test", ["require", "exports", "m1"], function (require, exports, m1) { +>>> exports.a1 = 10; +1 >^^^^ +2 > ^^^^^^^^^^ +3 > ^^^ +4 > ^^ +5 > ^ +6 > ^^^^^^^^-> +1 >import m1 = require("m1"); + >export var +2 > a1 +3 > = +4 > 10 +5 > ; +1 >Emitted(16, 5) Source(2, 12) + SourceIndex(1) +2 >Emitted(16, 15) Source(2, 14) + SourceIndex(1) +3 >Emitted(16, 18) Source(2, 17) + SourceIndex(1) +4 >Emitted(16, 20) Source(2, 19) + SourceIndex(1) +5 >Emitted(16, 21) Source(2, 20) + SourceIndex(1) +--- +>>> var c1 = (function () { +1->^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^-> +1-> + > +1->Emitted(17, 5) Source(3, 1) + SourceIndex(1) +--- +>>> function c1() { +1->^^^^^^^^ +2 > ^^-> +1-> +1->Emitted(18, 9) Source(3, 1) + SourceIndex(1) name (c1) +--- +>>> } +1->^^^^^^^^ +2 > ^ +3 > ^^^^^^^^^^-> +1->export class c1 { + > public p1: number; + > +2 > } +1->Emitted(19, 9) Source(5, 1) + SourceIndex(1) name (c1.constructor) +2 >Emitted(19, 10) Source(5, 2) + SourceIndex(1) name (c1.constructor) +--- +>>> return c1; +1->^^^^^^^^ +2 > ^^^^^^^^^ +1-> +2 > } +1->Emitted(20, 9) Source(5, 1) + SourceIndex(1) name (c1) +2 >Emitted(20, 18) Source(5, 2) + SourceIndex(1) name (c1) +--- +>>> })(); +1 >^^^^ +2 > ^ +3 > +4 > ^^^^ +5 > ^^^^^^^^^^^^-> +1 > +2 > } +3 > +4 > export class c1 { + > public p1: number; + > } +1 >Emitted(21, 5) Source(5, 1) + SourceIndex(1) name (c1) +2 >Emitted(21, 6) Source(5, 2) + SourceIndex(1) name (c1) +3 >Emitted(21, 6) Source(3, 1) + SourceIndex(1) +4 >Emitted(21, 10) Source(5, 2) + SourceIndex(1) +--- +>>> exports.c1 = c1; +1->^^^^ +2 > ^^^^^^^^^^ +3 > ^^^^^ +4 > ^ +5 > ^^^^^^^^^^^^^^-> +1-> +2 > c1 +3 > { + > public p1: number; + > } +4 > +1->Emitted(22, 5) Source(3, 14) + SourceIndex(1) +2 >Emitted(22, 15) Source(3, 16) + SourceIndex(1) +3 >Emitted(22, 20) Source(5, 2) + SourceIndex(1) +4 >Emitted(22, 21) Source(5, 2) + SourceIndex(1) +--- +>>> exports.instance1 = new c1(); +1->^^^^ +2 > ^^^^^^^^^^^^^^^^^ +3 > ^^^ +4 > ^^^^ +5 > ^^ +6 > ^^ +7 > ^ +1-> + > + >export var +2 > instance1 +3 > = +4 > new +5 > c1 +6 > () +7 > ; +1->Emitted(23, 5) Source(7, 12) + SourceIndex(1) +2 >Emitted(23, 22) Source(7, 21) + SourceIndex(1) +3 >Emitted(23, 25) Source(7, 24) + SourceIndex(1) +4 >Emitted(23, 29) Source(7, 28) + SourceIndex(1) +5 >Emitted(23, 31) Source(7, 30) + SourceIndex(1) +6 >Emitted(23, 33) Source(7, 32) + SourceIndex(1) +7 >Emitted(23, 34) Source(7, 33) + SourceIndex(1) +--- +>>> function f1() { +1 >^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +1 > + > +1 >Emitted(24, 5) Source(8, 1) + SourceIndex(1) +--- +>>> return exports.instance1; +1->^^^^^^^^ +2 > ^^^^^^ +3 > ^ +4 > ^^^^^^^^^^^^^^^^^ +5 > ^ +1->export function f1() { + > +2 > return +3 > +4 > instance1 +5 > ; +1->Emitted(25, 9) Source(9, 5) + SourceIndex(1) name (f1) +2 >Emitted(25, 15) Source(9, 11) + SourceIndex(1) name (f1) +3 >Emitted(25, 16) Source(9, 12) + SourceIndex(1) name (f1) +4 >Emitted(25, 33) Source(9, 21) + SourceIndex(1) name (f1) +5 >Emitted(25, 34) Source(9, 22) + SourceIndex(1) name (f1) +--- +>>> } +1 >^^^^ +2 > ^ +3 > ^^^^^^^^^^^^^^^^-> +1 > + > +2 > } +1 >Emitted(26, 5) Source(10, 1) + SourceIndex(1) name (f1) +2 >Emitted(26, 6) Source(10, 2) + SourceIndex(1) name (f1) +--- +>>> exports.f1 = f1; +1->^^^^ +2 > ^^^^^^^^^^ +3 > ^^^^^ +4 > ^ +5 > ^^^^^^^-> +1-> +2 > f1 +3 > () { + > return instance1; + > } +4 > +1->Emitted(27, 5) Source(8, 17) + SourceIndex(1) +2 >Emitted(27, 15) Source(8, 19) + SourceIndex(1) +3 >Emitted(27, 20) Source(10, 2) + SourceIndex(1) +4 >Emitted(27, 21) Source(10, 2) + SourceIndex(1) +--- +>>> exports.a2 = m1.m1_c1; +1->^^^^ +2 > ^^^^^^^^^^ +3 > ^^^ +4 > ^^ +5 > ^ +6 > ^^^^^ +7 > ^ +1-> + > + >export var +2 > a2 +3 > = +4 > m1 +5 > . +6 > m1_c1 +7 > ; +1->Emitted(28, 5) Source(12, 12) + SourceIndex(1) +2 >Emitted(28, 15) Source(12, 14) + SourceIndex(1) +3 >Emitted(28, 18) Source(12, 17) + SourceIndex(1) +4 >Emitted(28, 20) Source(12, 19) + SourceIndex(1) +5 >Emitted(28, 21) Source(12, 20) + SourceIndex(1) +6 >Emitted(28, 26) Source(12, 25) + SourceIndex(1) +7 >Emitted(28, 27) Source(12, 26) + SourceIndex(1) +--- +>>>}); >>>//# sourceMappingURL=http://www.typescriptlang.org/test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSimpleSpecifyOutputFile/node/bin/test.d.ts b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSimpleSpecifyOutputFile/node/bin/test.d.ts deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSimpleSpecifyOutputFile/node/bin/test.js b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSimpleSpecifyOutputFile/node/bin/test.js deleted file mode 100644 index 52f1b822100..00000000000 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSimpleSpecifyOutputFile/node/bin/test.js +++ /dev/null @@ -1 +0,0 @@ -//# sourceMappingURL=http://www.typescriptlang.org/test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSimpleSpecifyOutputFile/node/bin/test.js.map b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSimpleSpecifyOutputFile/node/bin/test.js.map index d3e851981ec..3b75f2878c9 100644 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSimpleSpecifyOutputFile/node/bin/test.js.map +++ b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSimpleSpecifyOutputFile/node/bin/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"http://typescript.codeplex.com/","sources":[],"names":[],"mappings":""} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"http://typescript.codeplex.com/","sources":["m1.ts","test.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSimpleSpecifyOutputFile/node/maprootUrlsourcerootUrlModuleSimpleSpecifyOutputFile.sourcemap.txt b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSimpleSpecifyOutputFile/node/maprootUrlsourcerootUrlModuleSimpleSpecifyOutputFile.sourcemap.txt index ff984bf74ee..d52a70d4dac 100644 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSimpleSpecifyOutputFile/node/maprootUrlsourcerootUrlModuleSimpleSpecifyOutputFile.sourcemap.txt +++ b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSimpleSpecifyOutputFile/node/maprootUrlsourcerootUrlModuleSimpleSpecifyOutputFile.sourcemap.txt @@ -394,6 +394,6 @@ sourceFile:test.ts JsFile: test.js mapUrl: http://www.typescriptlang.org/test.js.map sourceRoot: http://typescript.codeplex.com/ -sources: +sources: m1.ts,test.ts =================================================================== >>>//# sourceMappingURL=http://www.typescriptlang.org/test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSubfolderSpecifyOutputFile/amd/bin/test.d.ts b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSubfolderSpecifyOutputFile/amd/bin/test.d.ts deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSubfolderSpecifyOutputFile/amd/bin/test.js b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSubfolderSpecifyOutputFile/amd/bin/test.js deleted file mode 100644 index 52f1b822100..00000000000 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSubfolderSpecifyOutputFile/amd/bin/test.js +++ /dev/null @@ -1 +0,0 @@ -//# sourceMappingURL=http://www.typescriptlang.org/test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSubfolderSpecifyOutputFile/amd/bin/test.js.map b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSubfolderSpecifyOutputFile/amd/bin/test.js.map index d3e851981ec..29e01bc0bc6 100644 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSubfolderSpecifyOutputFile/amd/bin/test.js.map +++ b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSubfolderSpecifyOutputFile/amd/bin/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"http://typescript.codeplex.com/","sources":[],"names":[],"mappings":""} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"http://typescript.codeplex.com/","sources":["ref/m1.ts","test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","c1","c1.constructor","f1"],"mappings":";IAAW,aAAK,GAAG,EAAE,CAAC;IACtB;QAAAA;QAEAC,CAACA;QAADD,YAACA;IAADA,CAACA,AAFD,IAEC;IAFY,aAAK,QAEjB,CAAA;IAEU,oBAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACIE,MAAMA,CAACA,oBAAYA,CAACA;IACxBA,CAACA;IAFe,aAAK,QAEpB,CAAA;;;ICPU,UAAE,GAAG,EAAE,CAAC;IACnB;QAAAC;QAEAC,CAACA;QAADD,SAACA;IAADA,CAACA,AAFD,IAEC;IAFY,UAAE,KAEd,CAAA;IAEU,iBAAS,GAAG,IAAI,EAAE,EAAE,CAAC;IAChC;QACIE,MAAMA,CAACA,iBAASA,CAACA;IACrBA,CAACA;IAFe,UAAE,KAEjB,CAAA;IAEU,UAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSubfolderSpecifyOutputFile/amd/maprootUrlsourcerootUrlModuleSubfolderSpecifyOutputFile.sourcemap.txt b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSubfolderSpecifyOutputFile/amd/maprootUrlsourcerootUrlModuleSubfolderSpecifyOutputFile.sourcemap.txt index 67e50350919..93d4a677676 100644 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSubfolderSpecifyOutputFile/amd/maprootUrlsourcerootUrlModuleSubfolderSpecifyOutputFile.sourcemap.txt +++ b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSubfolderSpecifyOutputFile/amd/maprootUrlsourcerootUrlModuleSubfolderSpecifyOutputFile.sourcemap.txt @@ -373,6 +373,365 @@ sourceFile:test.ts JsFile: test.js mapUrl: http://www.typescriptlang.org/test.js.map sourceRoot: http://typescript.codeplex.com/ -sources: +sources: ref/m1.ts,test.ts =================================================================== +------------------------------------------------------------------- +emittedFile:bin/test.js +sourceFile:ref/m1.ts +------------------------------------------------------------------- +>>>define("ref/m1", ["require", "exports"], function (require, exports) { +>>> exports.m1_a1 = 10; +1 >^^^^ +2 > ^^^^^^^^^^^^^ +3 > ^^^ +4 > ^^ +5 > ^ +6 > ^^^^^^^^-> +1 >export var +2 > m1_a1 +3 > = +4 > 10 +5 > ; +1 >Emitted(2, 5) Source(1, 12) + SourceIndex(0) +2 >Emitted(2, 18) Source(1, 17) + SourceIndex(0) +3 >Emitted(2, 21) Source(1, 20) + SourceIndex(0) +4 >Emitted(2, 23) Source(1, 22) + SourceIndex(0) +5 >Emitted(2, 24) Source(1, 23) + SourceIndex(0) +--- +>>> var m1_c1 = (function () { +1->^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^^^^-> +1-> + > +1->Emitted(3, 5) Source(2, 1) + SourceIndex(0) +--- +>>> function m1_c1() { +1->^^^^^^^^ +2 > ^^-> +1-> +1->Emitted(4, 9) Source(2, 1) + SourceIndex(0) name (m1_c1) +--- +>>> } +1->^^^^^^^^ +2 > ^ +3 > ^^^^^^^^^^^^^-> +1->export class m1_c1 { + > public m1_c1_p1: number; + > +2 > } +1->Emitted(5, 9) Source(4, 1) + SourceIndex(0) name (m1_c1.constructor) +2 >Emitted(5, 10) Source(4, 2) + SourceIndex(0) name (m1_c1.constructor) +--- +>>> return m1_c1; +1->^^^^^^^^ +2 > ^^^^^^^^^^^^ +1-> +2 > } +1->Emitted(6, 9) Source(4, 1) + SourceIndex(0) name (m1_c1) +2 >Emitted(6, 21) Source(4, 2) + SourceIndex(0) name (m1_c1) +--- +>>> })(); +1 >^^^^ +2 > ^ +3 > +4 > ^^^^ +5 > ^^^^^^^^^^^^^^^^^^-> +1 > +2 > } +3 > +4 > export class m1_c1 { + > public m1_c1_p1: number; + > } +1 >Emitted(7, 5) Source(4, 1) + SourceIndex(0) name (m1_c1) +2 >Emitted(7, 6) Source(4, 2) + SourceIndex(0) name (m1_c1) +3 >Emitted(7, 6) Source(2, 1) + SourceIndex(0) +4 >Emitted(7, 10) Source(4, 2) + SourceIndex(0) +--- +>>> exports.m1_c1 = m1_c1; +1->^^^^ +2 > ^^^^^^^^^^^^^ +3 > ^^^^^^^^ +4 > ^ +5 > ^^^^^^^^^^^^^^-> +1-> +2 > m1_c1 +3 > { + > public m1_c1_p1: number; + > } +4 > +1->Emitted(8, 5) Source(2, 14) + SourceIndex(0) +2 >Emitted(8, 18) Source(2, 19) + SourceIndex(0) +3 >Emitted(8, 26) Source(4, 2) + SourceIndex(0) +4 >Emitted(8, 27) Source(4, 2) + SourceIndex(0) +--- +>>> exports.m1_instance1 = new m1_c1(); +1->^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^ +3 > ^^^ +4 > ^^^^ +5 > ^^^^^ +6 > ^^ +7 > ^ +1-> + > + >export var +2 > m1_instance1 +3 > = +4 > new +5 > m1_c1 +6 > () +7 > ; +1->Emitted(9, 5) Source(6, 12) + SourceIndex(0) +2 >Emitted(9, 25) Source(6, 24) + SourceIndex(0) +3 >Emitted(9, 28) Source(6, 27) + SourceIndex(0) +4 >Emitted(9, 32) Source(6, 31) + SourceIndex(0) +5 >Emitted(9, 37) Source(6, 36) + SourceIndex(0) +6 >Emitted(9, 39) Source(6, 38) + SourceIndex(0) +7 >Emitted(9, 40) Source(6, 39) + SourceIndex(0) +--- +>>> function m1_f1() { +1 >^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +1 > + > +1 >Emitted(10, 5) Source(7, 1) + SourceIndex(0) +--- +>>> return exports.m1_instance1; +1->^^^^^^^^ +2 > ^^^^^^ +3 > ^ +4 > ^^^^^^^^^^^^^^^^^^^^ +5 > ^ +1->export function m1_f1() { + > +2 > return +3 > +4 > m1_instance1 +5 > ; +1->Emitted(11, 9) Source(8, 5) + SourceIndex(0) name (m1_f1) +2 >Emitted(11, 15) Source(8, 11) + SourceIndex(0) name (m1_f1) +3 >Emitted(11, 16) Source(8, 12) + SourceIndex(0) name (m1_f1) +4 >Emitted(11, 36) Source(8, 24) + SourceIndex(0) name (m1_f1) +5 >Emitted(11, 37) Source(8, 25) + SourceIndex(0) name (m1_f1) +--- +>>> } +1 >^^^^ +2 > ^ +3 > ^^^^^^^^^^^^^^^^^^^^^^-> +1 > + > +2 > } +1 >Emitted(12, 5) Source(9, 1) + SourceIndex(0) name (m1_f1) +2 >Emitted(12, 6) Source(9, 2) + SourceIndex(0) name (m1_f1) +--- +>>> exports.m1_f1 = m1_f1; +1->^^^^ +2 > ^^^^^^^^^^^^^ +3 > ^^^^^^^^ +4 > ^ +1-> +2 > m1_f1 +3 > () { + > return m1_instance1; + > } +4 > +1->Emitted(13, 5) Source(7, 17) + SourceIndex(0) +2 >Emitted(13, 18) Source(7, 22) + SourceIndex(0) +3 >Emitted(13, 26) Source(9, 2) + SourceIndex(0) +4 >Emitted(13, 27) Source(9, 2) + SourceIndex(0) +--- +------------------------------------------------------------------- +emittedFile:bin/test.js +sourceFile:test.ts +------------------------------------------------------------------- +>>>}); +>>>define("test", ["require", "exports", "ref/m1"], function (require, exports, m1) { +>>> exports.a1 = 10; +1 >^^^^ +2 > ^^^^^^^^^^ +3 > ^^^ +4 > ^^ +5 > ^ +6 > ^^^^^^^^-> +1 >import m1 = require("ref/m1"); + >export var +2 > a1 +3 > = +4 > 10 +5 > ; +1 >Emitted(16, 5) Source(2, 12) + SourceIndex(1) +2 >Emitted(16, 15) Source(2, 14) + SourceIndex(1) +3 >Emitted(16, 18) Source(2, 17) + SourceIndex(1) +4 >Emitted(16, 20) Source(2, 19) + SourceIndex(1) +5 >Emitted(16, 21) Source(2, 20) + SourceIndex(1) +--- +>>> var c1 = (function () { +1->^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^-> +1-> + > +1->Emitted(17, 5) Source(3, 1) + SourceIndex(1) +--- +>>> function c1() { +1->^^^^^^^^ +2 > ^^-> +1-> +1->Emitted(18, 9) Source(3, 1) + SourceIndex(1) name (c1) +--- +>>> } +1->^^^^^^^^ +2 > ^ +3 > ^^^^^^^^^^-> +1->export class c1 { + > public p1: number; + > +2 > } +1->Emitted(19, 9) Source(5, 1) + SourceIndex(1) name (c1.constructor) +2 >Emitted(19, 10) Source(5, 2) + SourceIndex(1) name (c1.constructor) +--- +>>> return c1; +1->^^^^^^^^ +2 > ^^^^^^^^^ +1-> +2 > } +1->Emitted(20, 9) Source(5, 1) + SourceIndex(1) name (c1) +2 >Emitted(20, 18) Source(5, 2) + SourceIndex(1) name (c1) +--- +>>> })(); +1 >^^^^ +2 > ^ +3 > +4 > ^^^^ +5 > ^^^^^^^^^^^^-> +1 > +2 > } +3 > +4 > export class c1 { + > public p1: number; + > } +1 >Emitted(21, 5) Source(5, 1) + SourceIndex(1) name (c1) +2 >Emitted(21, 6) Source(5, 2) + SourceIndex(1) name (c1) +3 >Emitted(21, 6) Source(3, 1) + SourceIndex(1) +4 >Emitted(21, 10) Source(5, 2) + SourceIndex(1) +--- +>>> exports.c1 = c1; +1->^^^^ +2 > ^^^^^^^^^^ +3 > ^^^^^ +4 > ^ +5 > ^^^^^^^^^^^^^^-> +1-> +2 > c1 +3 > { + > public p1: number; + > } +4 > +1->Emitted(22, 5) Source(3, 14) + SourceIndex(1) +2 >Emitted(22, 15) Source(3, 16) + SourceIndex(1) +3 >Emitted(22, 20) Source(5, 2) + SourceIndex(1) +4 >Emitted(22, 21) Source(5, 2) + SourceIndex(1) +--- +>>> exports.instance1 = new c1(); +1->^^^^ +2 > ^^^^^^^^^^^^^^^^^ +3 > ^^^ +4 > ^^^^ +5 > ^^ +6 > ^^ +7 > ^ +1-> + > + >export var +2 > instance1 +3 > = +4 > new +5 > c1 +6 > () +7 > ; +1->Emitted(23, 5) Source(7, 12) + SourceIndex(1) +2 >Emitted(23, 22) Source(7, 21) + SourceIndex(1) +3 >Emitted(23, 25) Source(7, 24) + SourceIndex(1) +4 >Emitted(23, 29) Source(7, 28) + SourceIndex(1) +5 >Emitted(23, 31) Source(7, 30) + SourceIndex(1) +6 >Emitted(23, 33) Source(7, 32) + SourceIndex(1) +7 >Emitted(23, 34) Source(7, 33) + SourceIndex(1) +--- +>>> function f1() { +1 >^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +1 > + > +1 >Emitted(24, 5) Source(8, 1) + SourceIndex(1) +--- +>>> return exports.instance1; +1->^^^^^^^^ +2 > ^^^^^^ +3 > ^ +4 > ^^^^^^^^^^^^^^^^^ +5 > ^ +1->export function f1() { + > +2 > return +3 > +4 > instance1 +5 > ; +1->Emitted(25, 9) Source(9, 5) + SourceIndex(1) name (f1) +2 >Emitted(25, 15) Source(9, 11) + SourceIndex(1) name (f1) +3 >Emitted(25, 16) Source(9, 12) + SourceIndex(1) name (f1) +4 >Emitted(25, 33) Source(9, 21) + SourceIndex(1) name (f1) +5 >Emitted(25, 34) Source(9, 22) + SourceIndex(1) name (f1) +--- +>>> } +1 >^^^^ +2 > ^ +3 > ^^^^^^^^^^^^^^^^-> +1 > + > +2 > } +1 >Emitted(26, 5) Source(10, 1) + SourceIndex(1) name (f1) +2 >Emitted(26, 6) Source(10, 2) + SourceIndex(1) name (f1) +--- +>>> exports.f1 = f1; +1->^^^^ +2 > ^^^^^^^^^^ +3 > ^^^^^ +4 > ^ +5 > ^^^^^^^-> +1-> +2 > f1 +3 > () { + > return instance1; + > } +4 > +1->Emitted(27, 5) Source(8, 17) + SourceIndex(1) +2 >Emitted(27, 15) Source(8, 19) + SourceIndex(1) +3 >Emitted(27, 20) Source(10, 2) + SourceIndex(1) +4 >Emitted(27, 21) Source(10, 2) + SourceIndex(1) +--- +>>> exports.a2 = m1.m1_c1; +1->^^^^ +2 > ^^^^^^^^^^ +3 > ^^^ +4 > ^^ +5 > ^ +6 > ^^^^^ +7 > ^ +1-> + > + >export var +2 > a2 +3 > = +4 > m1 +5 > . +6 > m1_c1 +7 > ; +1->Emitted(28, 5) Source(12, 12) + SourceIndex(1) +2 >Emitted(28, 15) Source(12, 14) + SourceIndex(1) +3 >Emitted(28, 18) Source(12, 17) + SourceIndex(1) +4 >Emitted(28, 20) Source(12, 19) + SourceIndex(1) +5 >Emitted(28, 21) Source(12, 20) + SourceIndex(1) +6 >Emitted(28, 26) Source(12, 25) + SourceIndex(1) +7 >Emitted(28, 27) Source(12, 26) + SourceIndex(1) +--- +>>>}); >>>//# sourceMappingURL=http://www.typescriptlang.org/test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSubfolderSpecifyOutputFile/node/bin/test.d.ts b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSubfolderSpecifyOutputFile/node/bin/test.d.ts deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSubfolderSpecifyOutputFile/node/bin/test.js b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSubfolderSpecifyOutputFile/node/bin/test.js deleted file mode 100644 index 52f1b822100..00000000000 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSubfolderSpecifyOutputFile/node/bin/test.js +++ /dev/null @@ -1 +0,0 @@ -//# sourceMappingURL=http://www.typescriptlang.org/test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSubfolderSpecifyOutputFile/node/bin/test.js.map b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSubfolderSpecifyOutputFile/node/bin/test.js.map index d3e851981ec..4409af8d0a7 100644 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSubfolderSpecifyOutputFile/node/bin/test.js.map +++ b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSubfolderSpecifyOutputFile/node/bin/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"http://typescript.codeplex.com/","sources":[],"names":[],"mappings":""} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"http://typescript.codeplex.com/","sources":["ref/m1.ts","test.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSubfolderSpecifyOutputFile/node/maprootUrlsourcerootUrlModuleSubfolderSpecifyOutputFile.sourcemap.txt b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSubfolderSpecifyOutputFile/node/maprootUrlsourcerootUrlModuleSubfolderSpecifyOutputFile.sourcemap.txt index c5bce1a19d5..abdc3af24ca 100644 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSubfolderSpecifyOutputFile/node/maprootUrlsourcerootUrlModuleSubfolderSpecifyOutputFile.sourcemap.txt +++ b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSubfolderSpecifyOutputFile/node/maprootUrlsourcerootUrlModuleSubfolderSpecifyOutputFile.sourcemap.txt @@ -394,6 +394,6 @@ sourceFile:test.ts JsFile: test.js mapUrl: http://www.typescriptlang.org/test.js.map sourceRoot: http://typescript.codeplex.com/ -sources: +sources: ref/m1.ts,test.ts =================================================================== >>>//# sourceMappingURL=http://www.typescriptlang.org/test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/outMixedSubfolderSpecifyOutputFile/amd/bin/test.d.ts b/tests/baselines/reference/project/outMixedSubfolderSpecifyOutputFile/amd/bin/test.d.ts deleted file mode 100644 index d61b4c3b876..00000000000 --- a/tests/baselines/reference/project/outMixedSubfolderSpecifyOutputFile/amd/bin/test.d.ts +++ /dev/null @@ -1,13 +0,0 @@ -/// -declare var m1_a1: number; -declare class m1_c1 { - m1_c1_p1: number; -} -declare var m1_instance1: m1_c1; -declare function m1_f1(): m1_c1; -declare var a1: number; -declare class c1 { - p1: number; -} -declare var instance1: c1; -declare function f1(): c1; diff --git a/tests/baselines/reference/project/outMixedSubfolderSpecifyOutputFile/amd/bin/test.js b/tests/baselines/reference/project/outMixedSubfolderSpecifyOutputFile/amd/bin/test.js index ad3b4896eec..40bdaa24fc9 100644 --- a/tests/baselines/reference/project/outMixedSubfolderSpecifyOutputFile/amd/bin/test.js +++ b/tests/baselines/reference/project/outMixedSubfolderSpecifyOutputFile/amd/bin/test.js @@ -8,6 +8,20 @@ var m1_instance1 = new m1_c1(); function m1_f1() { return m1_instance1; } +define("ref/m2", ["require", "exports"], function (require, exports) { + exports.m2_a1 = 10; + var m2_c1 = (function () { + function m2_c1() { + } + return m2_c1; + })(); + exports.m2_c1 = m2_c1; + exports.m2_instance1 = new m2_c1(); + function m2_f1() { + return exports.m2_instance1; + } + exports.m2_f1 = m2_f1; +}); /// /// var a1 = 10; diff --git a/tests/baselines/reference/project/outMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.d.ts b/tests/baselines/reference/project/outMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.d.ts deleted file mode 100644 index 9b9cdd4a214..00000000000 --- a/tests/baselines/reference/project/outMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.d.ts +++ /dev/null @@ -1,13 +0,0 @@ -/// -declare var m1_a1: number; -declare class m1_c1 { - m1_c1_p1: number; -} -declare var m1_instance1: m1_c1; -declare function m1_f1(): m1_c1; -declare var a1: number; -declare class c1 { - p1: number; -} -declare var instance1: c1; -declare function f1(): c1; diff --git a/tests/baselines/reference/project/outMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.js b/tests/baselines/reference/project/outMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.js index ad3b4896eec..40bdaa24fc9 100644 --- a/tests/baselines/reference/project/outMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.js +++ b/tests/baselines/reference/project/outMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.js @@ -8,6 +8,20 @@ var m1_instance1 = new m1_c1(); function m1_f1() { return m1_instance1; } +define("ref/m2", ["require", "exports"], function (require, exports) { + exports.m2_a1 = 10; + var m2_c1 = (function () { + function m2_c1() { + } + return m2_c1; + })(); + exports.m2_c1 = m2_c1; + exports.m2_instance1 = new m2_c1(); + function m2_f1() { + return exports.m2_instance1; + } + exports.m2_f1 = m2_f1; +}); /// /// var a1 = 10; diff --git a/tests/baselines/reference/project/outModuleMultifolderSpecifyOutputFile/amd/bin/test.d.ts b/tests/baselines/reference/project/outModuleMultifolderSpecifyOutputFile/amd/bin/test.d.ts deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/tests/baselines/reference/project/outModuleMultifolderSpecifyOutputFile/amd/bin/test.js b/tests/baselines/reference/project/outModuleMultifolderSpecifyOutputFile/amd/bin/test.js index e69de29bb2d..0814424ca39 100644 --- a/tests/baselines/reference/project/outModuleMultifolderSpecifyOutputFile/amd/bin/test.js +++ b/tests/baselines/reference/project/outModuleMultifolderSpecifyOutputFile/amd/bin/test.js @@ -0,0 +1,44 @@ +define("ref/m1", ["require", "exports"], function (require, exports) { + exports.m1_a1 = 10; + var m1_c1 = (function () { + function m1_c1() { + } + return m1_c1; + })(); + exports.m1_c1 = m1_c1; + exports.m1_instance1 = new m1_c1(); + function m1_f1() { + return exports.m1_instance1; + } + exports.m1_f1 = m1_f1; +}); +define("../outputdir_module_multifolder_ref/m2", ["require", "exports"], function (require, exports) { + exports.m2_a1 = 10; + var m2_c1 = (function () { + function m2_c1() { + } + return m2_c1; + })(); + exports.m2_c1 = m2_c1; + exports.m2_instance1 = new m2_c1(); + function m2_f1() { + return exports.m2_instance1; + } + exports.m2_f1 = m2_f1; +}); +define("test", ["require", "exports", "ref/m1", "../outputdir_module_multifolder_ref/m2"], function (require, exports, m1, m2) { + exports.a1 = 10; + var c1 = (function () { + function c1() { + } + return c1; + })(); + exports.c1 = c1; + exports.instance1 = new c1(); + function f1() { + return exports.instance1; + } + exports.f1 = f1; + exports.a2 = m1.m1_c1; + exports.a3 = m2.m2_c1; +}); diff --git a/tests/baselines/reference/project/outModuleSimpleSpecifyOutputFile/amd/bin/test.d.ts b/tests/baselines/reference/project/outModuleSimpleSpecifyOutputFile/amd/bin/test.d.ts deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/tests/baselines/reference/project/outModuleSimpleSpecifyOutputFile/amd/bin/test.js b/tests/baselines/reference/project/outModuleSimpleSpecifyOutputFile/amd/bin/test.js index e69de29bb2d..d07eebbd726 100644 --- a/tests/baselines/reference/project/outModuleSimpleSpecifyOutputFile/amd/bin/test.js +++ b/tests/baselines/reference/project/outModuleSimpleSpecifyOutputFile/amd/bin/test.js @@ -0,0 +1,29 @@ +define("m1", ["require", "exports"], function (require, exports) { + exports.m1_a1 = 10; + var m1_c1 = (function () { + function m1_c1() { + } + return m1_c1; + })(); + exports.m1_c1 = m1_c1; + exports.m1_instance1 = new m1_c1(); + function m1_f1() { + return exports.m1_instance1; + } + exports.m1_f1 = m1_f1; +}); +define("test", ["require", "exports", "m1"], function (require, exports, m1) { + exports.a1 = 10; + var c1 = (function () { + function c1() { + } + return c1; + })(); + exports.c1 = c1; + exports.instance1 = new c1(); + function f1() { + return exports.instance1; + } + exports.f1 = f1; + exports.a2 = m1.m1_c1; +}); diff --git a/tests/baselines/reference/project/outModuleSubfolderSpecifyOutputFile/amd/bin/test.d.ts b/tests/baselines/reference/project/outModuleSubfolderSpecifyOutputFile/amd/bin/test.d.ts deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/tests/baselines/reference/project/outModuleSubfolderSpecifyOutputFile/amd/bin/test.js b/tests/baselines/reference/project/outModuleSubfolderSpecifyOutputFile/amd/bin/test.js index e69de29bb2d..a1bb15d7b35 100644 --- a/tests/baselines/reference/project/outModuleSubfolderSpecifyOutputFile/amd/bin/test.js +++ b/tests/baselines/reference/project/outModuleSubfolderSpecifyOutputFile/amd/bin/test.js @@ -0,0 +1,29 @@ +define("ref/m1", ["require", "exports"], function (require, exports) { + exports.m1_a1 = 10; + var m1_c1 = (function () { + function m1_c1() { + } + return m1_c1; + })(); + exports.m1_c1 = m1_c1; + exports.m1_instance1 = new m1_c1(); + function m1_f1() { + return exports.m1_instance1; + } + exports.m1_f1 = m1_f1; +}); +define("test", ["require", "exports", "ref/m1"], function (require, exports, m1) { + exports.a1 = 10; + var c1 = (function () { + function c1() { + } + return c1; + })(); + exports.c1 = c1; + exports.instance1 = new c1(); + function f1() { + return exports.instance1; + } + exports.f1 = f1; + exports.a2 = m1.m1_c1; +}); diff --git a/tests/baselines/reference/project/prologueEmit/amd/out.js b/tests/baselines/reference/project/prologueEmit/amd/out.js index fb0ca5dfac0..42313b7ce64 100644 --- a/tests/baselines/reference/project/prologueEmit/amd/out.js +++ b/tests/baselines/reference/project/prologueEmit/amd/out.js @@ -1,11 +1,11 @@ -var _this = this; -// Add a lambda to ensure global 'this' capture is triggered -(function () { return _this.window; }); 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 _this = this; +// Add a lambda to ensure global 'this' capture is triggered +(function () { return _this.window; }); // class inheritance to ensure __extends is emitted var m; (function (m) { diff --git a/tests/baselines/reference/project/prologueEmit/node/out.js b/tests/baselines/reference/project/prologueEmit/node/out.js index fb0ca5dfac0..42313b7ce64 100644 --- a/tests/baselines/reference/project/prologueEmit/node/out.js +++ b/tests/baselines/reference/project/prologueEmit/node/out.js @@ -1,11 +1,11 @@ -var _this = this; -// Add a lambda to ensure global 'this' capture is triggered -(function () { return _this.window; }); 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 _this = this; +// Add a lambda to ensure global 'this' capture is triggered +(function () { return _this.window; }); // class inheritance to ensure __extends is emitted var m; (function (m) { diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFile/amd/bin/test.d.ts b/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFile/amd/bin/test.d.ts deleted file mode 100644 index d61b4c3b876..00000000000 --- a/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFile/amd/bin/test.d.ts +++ /dev/null @@ -1,13 +0,0 @@ -/// -declare var m1_a1: number; -declare class m1_c1 { - m1_c1_p1: number; -} -declare var m1_instance1: m1_c1; -declare function m1_f1(): m1_c1; -declare var a1: number; -declare class c1 { - p1: number; -} -declare var instance1: c1; -declare function f1(): c1; diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFile/amd/bin/test.js b/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFile/amd/bin/test.js deleted file mode 100644 index 5af28cf8560..00000000000 --- a/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFile/amd/bin/test.js +++ /dev/null @@ -1,23 +0,0 @@ -var m1_a1 = 10; -var m1_c1 = (function () { - function m1_c1() { - } - return m1_c1; -})(); -var m1_instance1 = new m1_c1(); -function m1_f1() { - return m1_instance1; -} -/// -/// -var a1 = 10; -var c1 = (function () { - function c1() { - } - return c1; -})(); -var instance1 = new c1(); -function f1() { - return instance1; -} -//# sourceMappingURL=test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFile/amd/bin/test.js.map b/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFile/amd/bin/test.js.map index 65bbb0e67c2..3aa34b0f833 100644 --- a/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFile/amd/bin/test.js.map +++ b/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFile/amd/bin/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"/tests/cases/projects/outputdir_mixed_subfolder/src/","sources":["ref/m1.ts","test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACRD,iCAAiC;AACjC,iCAAiC;AACjC,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"/tests/cases/projects/outputdir_mixed_subfolder/src/","sources":["ref/m1.ts","ref/m2.ts","test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","m2_c1","m2_c1.constructor","m2_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;;ICRU,aAAK,GAAG,EAAE,CAAC;IACtB;QAAAC;QAEAC,CAACA;QAADD,YAACA;IAADA,CAACA,AAFD,IAEC;IAFY,aAAK,QAEjB,CAAA;IAEU,oBAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACIE,MAAMA,CAACA,oBAAYA,CAACA;IACxBA,CAACA;IAFe,aAAK,QAEpB,CAAA;;ACRD,iCAAiC;AACjC,iCAAiC;AACjC,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFile/amd/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFile.sourcemap.txt b/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFile/amd/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFile.sourcemap.txt index bbad2c102f9..06d778caf3a 100644 --- a/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFile/amd/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFile.sourcemap.txt +++ b/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFile/amd/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFile.sourcemap.txt @@ -174,7 +174,7 @@ sourceFile:ref/m2.ts JsFile: test.js mapUrl: test.js.map sourceRoot: /tests/cases/projects/outputdir_mixed_subfolder/src/ -sources: ref/m1.ts,test.ts +sources: ref/m1.ts,ref/m2.ts,test.ts =================================================================== ------------------------------------------------------------------- emittedFile:bin/test.js @@ -306,7 +306,7 @@ sourceFile:ref/m1.ts >>>} 1 > 2 >^ -3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> 1 > > 2 >} @@ -315,16 +315,182 @@ sourceFile:ref/m1.ts --- ------------------------------------------------------------------- emittedFile:bin/test.js +sourceFile:ref/m2.ts +------------------------------------------------------------------- +>>>define("ref/m2", ["require", "exports"], function (require, exports) { +>>> exports.m2_a1 = 10; +1->^^^^ +2 > ^^^^^^^^^^^^^ +3 > ^^^ +4 > ^^ +5 > ^ +6 > ^^^^^^^^-> +1->export var +2 > m2_a1 +3 > = +4 > 10 +5 > ; +1->Emitted(12, 5) Source(1, 12) + SourceIndex(1) +2 >Emitted(12, 18) Source(1, 17) + SourceIndex(1) +3 >Emitted(12, 21) Source(1, 20) + SourceIndex(1) +4 >Emitted(12, 23) Source(1, 22) + SourceIndex(1) +5 >Emitted(12, 24) Source(1, 23) + SourceIndex(1) +--- +>>> var m2_c1 = (function () { +1->^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^^^^-> +1-> + > +1->Emitted(13, 5) Source(2, 1) + SourceIndex(1) +--- +>>> function m2_c1() { +1->^^^^^^^^ +2 > ^^-> +1-> +1->Emitted(14, 9) Source(2, 1) + SourceIndex(1) name (m2_c1) +--- +>>> } +1->^^^^^^^^ +2 > ^ +3 > ^^^^^^^^^^^^^-> +1->export class m2_c1 { + > public m2_c1_p1: number; + > +2 > } +1->Emitted(15, 9) Source(4, 1) + SourceIndex(1) name (m2_c1.constructor) +2 >Emitted(15, 10) Source(4, 2) + SourceIndex(1) name (m2_c1.constructor) +--- +>>> return m2_c1; +1->^^^^^^^^ +2 > ^^^^^^^^^^^^ +1-> +2 > } +1->Emitted(16, 9) Source(4, 1) + SourceIndex(1) name (m2_c1) +2 >Emitted(16, 21) Source(4, 2) + SourceIndex(1) name (m2_c1) +--- +>>> })(); +1 >^^^^ +2 > ^ +3 > +4 > ^^^^ +5 > ^^^^^^^^^^^^^^^^^^-> +1 > +2 > } +3 > +4 > export class m2_c1 { + > public m2_c1_p1: number; + > } +1 >Emitted(17, 5) Source(4, 1) + SourceIndex(1) name (m2_c1) +2 >Emitted(17, 6) Source(4, 2) + SourceIndex(1) name (m2_c1) +3 >Emitted(17, 6) Source(2, 1) + SourceIndex(1) +4 >Emitted(17, 10) Source(4, 2) + SourceIndex(1) +--- +>>> exports.m2_c1 = m2_c1; +1->^^^^ +2 > ^^^^^^^^^^^^^ +3 > ^^^^^^^^ +4 > ^ +5 > ^^^^^^^^^^^^^^-> +1-> +2 > m2_c1 +3 > { + > public m2_c1_p1: number; + > } +4 > +1->Emitted(18, 5) Source(2, 14) + SourceIndex(1) +2 >Emitted(18, 18) Source(2, 19) + SourceIndex(1) +3 >Emitted(18, 26) Source(4, 2) + SourceIndex(1) +4 >Emitted(18, 27) Source(4, 2) + SourceIndex(1) +--- +>>> exports.m2_instance1 = new m2_c1(); +1->^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^ +3 > ^^^ +4 > ^^^^ +5 > ^^^^^ +6 > ^^ +7 > ^ +1-> + > + >export var +2 > m2_instance1 +3 > = +4 > new +5 > m2_c1 +6 > () +7 > ; +1->Emitted(19, 5) Source(6, 12) + SourceIndex(1) +2 >Emitted(19, 25) Source(6, 24) + SourceIndex(1) +3 >Emitted(19, 28) Source(6, 27) + SourceIndex(1) +4 >Emitted(19, 32) Source(6, 31) + SourceIndex(1) +5 >Emitted(19, 37) Source(6, 36) + SourceIndex(1) +6 >Emitted(19, 39) Source(6, 38) + SourceIndex(1) +7 >Emitted(19, 40) Source(6, 39) + SourceIndex(1) +--- +>>> function m2_f1() { +1 >^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +1 > + > +1 >Emitted(20, 5) Source(7, 1) + SourceIndex(1) +--- +>>> return exports.m2_instance1; +1->^^^^^^^^ +2 > ^^^^^^ +3 > ^ +4 > ^^^^^^^^^^^^^^^^^^^^ +5 > ^ +1->export function m2_f1() { + > +2 > return +3 > +4 > m2_instance1 +5 > ; +1->Emitted(21, 9) Source(8, 5) + SourceIndex(1) name (m2_f1) +2 >Emitted(21, 15) Source(8, 11) + SourceIndex(1) name (m2_f1) +3 >Emitted(21, 16) Source(8, 12) + SourceIndex(1) name (m2_f1) +4 >Emitted(21, 36) Source(8, 24) + SourceIndex(1) name (m2_f1) +5 >Emitted(21, 37) Source(8, 25) + SourceIndex(1) name (m2_f1) +--- +>>> } +1 >^^^^ +2 > ^ +3 > ^^^^^^^^^^^^^^^^^^^^^^-> +1 > + > +2 > } +1 >Emitted(22, 5) Source(9, 1) + SourceIndex(1) name (m2_f1) +2 >Emitted(22, 6) Source(9, 2) + SourceIndex(1) name (m2_f1) +--- +>>> exports.m2_f1 = m2_f1; +1->^^^^ +2 > ^^^^^^^^^^^^^ +3 > ^^^^^^^^ +4 > ^ +1-> +2 > m2_f1 +3 > () { + > return m2_instance1; + > } +4 > +1->Emitted(23, 5) Source(7, 17) + SourceIndex(1) +2 >Emitted(23, 18) Source(7, 22) + SourceIndex(1) +3 >Emitted(23, 26) Source(9, 2) + SourceIndex(1) +4 >Emitted(23, 27) Source(9, 2) + SourceIndex(1) +--- +------------------------------------------------------------------- +emittedFile:bin/test.js sourceFile:test.ts ------------------------------------------------------------------- +>>>}); >>>/// -1-> +1 > 2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 3 > ^-> -1-> +1 > 2 >/// -1->Emitted(11, 1) Source(1, 1) + SourceIndex(1) -2 >Emitted(11, 34) Source(1, 34) + SourceIndex(1) +1 >Emitted(25, 1) Source(1, 1) + SourceIndex(2) +2 >Emitted(25, 34) Source(1, 34) + SourceIndex(2) --- >>>/// 1-> @@ -332,8 +498,8 @@ sourceFile:test.ts 1-> > 2 >/// -1->Emitted(12, 1) Source(2, 1) + SourceIndex(1) -2 >Emitted(12, 34) Source(2, 34) + SourceIndex(1) +1->Emitted(26, 1) Source(2, 1) + SourceIndex(2) +2 >Emitted(26, 34) Source(2, 34) + SourceIndex(2) --- >>>var a1 = 10; 1 > @@ -350,25 +516,25 @@ sourceFile:test.ts 4 > = 5 > 10 6 > ; -1 >Emitted(13, 1) Source(3, 1) + SourceIndex(1) -2 >Emitted(13, 5) Source(3, 5) + SourceIndex(1) -3 >Emitted(13, 7) Source(3, 7) + SourceIndex(1) -4 >Emitted(13, 10) Source(3, 10) + SourceIndex(1) -5 >Emitted(13, 12) Source(3, 12) + SourceIndex(1) -6 >Emitted(13, 13) Source(3, 13) + SourceIndex(1) +1 >Emitted(27, 1) Source(3, 1) + SourceIndex(2) +2 >Emitted(27, 5) Source(3, 5) + SourceIndex(2) +3 >Emitted(27, 7) Source(3, 7) + SourceIndex(2) +4 >Emitted(27, 10) Source(3, 10) + SourceIndex(2) +5 >Emitted(27, 12) Source(3, 12) + SourceIndex(2) +6 >Emitted(27, 13) Source(3, 13) + SourceIndex(2) --- >>>var c1 = (function () { 1-> 2 >^^^^^^^^^^^^^^^^^^^^-> 1-> > -1->Emitted(14, 1) Source(4, 1) + SourceIndex(1) +1->Emitted(28, 1) Source(4, 1) + SourceIndex(2) --- >>> function c1() { 1->^^^^ 2 > ^^-> 1-> -1->Emitted(15, 5) Source(4, 1) + SourceIndex(1) name (c1) +1->Emitted(29, 5) Source(4, 1) + SourceIndex(2) name (c1) --- >>> } 1->^^^^ @@ -378,16 +544,16 @@ sourceFile:test.ts > public p1: number; > 2 > } -1->Emitted(16, 5) Source(6, 1) + SourceIndex(1) name (c1.constructor) -2 >Emitted(16, 6) Source(6, 2) + SourceIndex(1) name (c1.constructor) +1->Emitted(30, 5) Source(6, 1) + SourceIndex(2) name (c1.constructor) +2 >Emitted(30, 6) Source(6, 2) + SourceIndex(2) name (c1.constructor) --- >>> return c1; 1->^^^^ 2 > ^^^^^^^^^ 1-> 2 > } -1->Emitted(17, 5) Source(6, 1) + SourceIndex(1) name (c1) -2 >Emitted(17, 14) Source(6, 2) + SourceIndex(1) name (c1) +1->Emitted(31, 5) Source(6, 1) + SourceIndex(2) name (c1) +2 >Emitted(31, 14) Source(6, 2) + SourceIndex(2) name (c1) --- >>>})(); 1 > @@ -401,10 +567,10 @@ sourceFile:test.ts 4 > class c1 { > public p1: number; > } -1 >Emitted(18, 1) Source(6, 1) + SourceIndex(1) name (c1) -2 >Emitted(18, 2) Source(6, 2) + SourceIndex(1) name (c1) -3 >Emitted(18, 2) Source(4, 1) + SourceIndex(1) -4 >Emitted(18, 6) Source(6, 2) + SourceIndex(1) +1 >Emitted(32, 1) Source(6, 1) + SourceIndex(2) name (c1) +2 >Emitted(32, 2) Source(6, 2) + SourceIndex(2) name (c1) +3 >Emitted(32, 2) Source(4, 1) + SourceIndex(2) +4 >Emitted(32, 6) Source(6, 2) + SourceIndex(2) --- >>>var instance1 = new c1(); 1-> @@ -425,21 +591,21 @@ sourceFile:test.ts 6 > c1 7 > () 8 > ; -1->Emitted(19, 1) Source(8, 1) + SourceIndex(1) -2 >Emitted(19, 5) Source(8, 5) + SourceIndex(1) -3 >Emitted(19, 14) Source(8, 14) + SourceIndex(1) -4 >Emitted(19, 17) Source(8, 17) + SourceIndex(1) -5 >Emitted(19, 21) Source(8, 21) + SourceIndex(1) -6 >Emitted(19, 23) Source(8, 23) + SourceIndex(1) -7 >Emitted(19, 25) Source(8, 25) + SourceIndex(1) -8 >Emitted(19, 26) Source(8, 26) + SourceIndex(1) +1->Emitted(33, 1) Source(8, 1) + SourceIndex(2) +2 >Emitted(33, 5) Source(8, 5) + SourceIndex(2) +3 >Emitted(33, 14) Source(8, 14) + SourceIndex(2) +4 >Emitted(33, 17) Source(8, 17) + SourceIndex(2) +5 >Emitted(33, 21) Source(8, 21) + SourceIndex(2) +6 >Emitted(33, 23) Source(8, 23) + SourceIndex(2) +7 >Emitted(33, 25) Source(8, 25) + SourceIndex(2) +8 >Emitted(33, 26) Source(8, 26) + SourceIndex(2) --- >>>function f1() { 1 > 2 >^^^^^^^^^^^^^^^^^^^^^^-> 1 > > -1 >Emitted(20, 1) Source(9, 1) + SourceIndex(1) +1 >Emitted(34, 1) Source(9, 1) + SourceIndex(2) --- >>> return instance1; 1->^^^^ @@ -453,11 +619,11 @@ sourceFile:test.ts 3 > 4 > instance1 5 > ; -1->Emitted(21, 5) Source(10, 5) + SourceIndex(1) name (f1) -2 >Emitted(21, 11) Source(10, 11) + SourceIndex(1) name (f1) -3 >Emitted(21, 12) Source(10, 12) + SourceIndex(1) name (f1) -4 >Emitted(21, 21) Source(10, 21) + SourceIndex(1) name (f1) -5 >Emitted(21, 22) Source(10, 22) + SourceIndex(1) name (f1) +1->Emitted(35, 5) Source(10, 5) + SourceIndex(2) name (f1) +2 >Emitted(35, 11) Source(10, 11) + SourceIndex(2) name (f1) +3 >Emitted(35, 12) Source(10, 12) + SourceIndex(2) name (f1) +4 >Emitted(35, 21) Source(10, 21) + SourceIndex(2) name (f1) +5 >Emitted(35, 22) Source(10, 22) + SourceIndex(2) name (f1) --- >>>} 1 > @@ -466,7 +632,7 @@ sourceFile:test.ts 1 > > 2 >} -1 >Emitted(22, 1) Source(11, 1) + SourceIndex(1) name (f1) -2 >Emitted(22, 2) Source(11, 2) + SourceIndex(1) name (f1) +1 >Emitted(36, 1) Source(11, 1) + SourceIndex(2) name (f1) +2 >Emitted(36, 2) Source(11, 2) + SourceIndex(2) name (f1) --- >>>//# sourceMappingURL=test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFile/node/bin/test.d.ts b/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFile/node/bin/test.d.ts deleted file mode 100644 index d61b4c3b876..00000000000 --- a/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFile/node/bin/test.d.ts +++ /dev/null @@ -1,13 +0,0 @@ -/// -declare var m1_a1: number; -declare class m1_c1 { - m1_c1_p1: number; -} -declare var m1_instance1: m1_c1; -declare function m1_f1(): m1_c1; -declare var a1: number; -declare class c1 { - p1: number; -} -declare var instance1: c1; -declare function f1(): c1; diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFile/node/bin/test.js b/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFile/node/bin/test.js deleted file mode 100644 index 5af28cf8560..00000000000 --- a/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFile/node/bin/test.js +++ /dev/null @@ -1,23 +0,0 @@ -var m1_a1 = 10; -var m1_c1 = (function () { - function m1_c1() { - } - return m1_c1; -})(); -var m1_instance1 = new m1_c1(); -function m1_f1() { - return m1_instance1; -} -/// -/// -var a1 = 10; -var c1 = (function () { - function c1() { - } - return c1; -})(); -var instance1 = new c1(); -function f1() { - return instance1; -} -//# sourceMappingURL=test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFile/node/bin/test.js.map b/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFile/node/bin/test.js.map index 65bbb0e67c2..cf4a14ae9e9 100644 --- a/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFile/node/bin/test.js.map +++ b/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFile/node/bin/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"/tests/cases/projects/outputdir_mixed_subfolder/src/","sources":["ref/m1.ts","test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACRD,iCAAiC;AACjC,iCAAiC;AACjC,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"/tests/cases/projects/outputdir_mixed_subfolder/src/","sources":["ref/m1.ts","ref/m2.ts","test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;AERD,iCAAiC;AACjC,iCAAiC;AACjC,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFile/node/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFile.sourcemap.txt b/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFile/node/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFile.sourcemap.txt index c409dc99f14..631ec5abf3d 100644 --- a/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFile/node/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFile.sourcemap.txt +++ b/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFile/node/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFile.sourcemap.txt @@ -173,7 +173,7 @@ sourceFile:ref/m2.ts JsFile: test.js mapUrl: test.js.map sourceRoot: /tests/cases/projects/outputdir_mixed_subfolder/src/ -sources: ref/m1.ts,test.ts +sources: ref/m1.ts,ref/m2.ts,test.ts =================================================================== ------------------------------------------------------------------- emittedFile:bin/test.js @@ -322,8 +322,8 @@ sourceFile:test.ts 3 > ^-> 1-> 2 >/// -1->Emitted(11, 1) Source(1, 1) + SourceIndex(1) -2 >Emitted(11, 34) Source(1, 34) + SourceIndex(1) +1->Emitted(11, 1) Source(1, 1) + SourceIndex(2) +2 >Emitted(11, 34) Source(1, 34) + SourceIndex(2) --- >>>/// 1-> @@ -331,8 +331,8 @@ sourceFile:test.ts 1-> > 2 >/// -1->Emitted(12, 1) Source(2, 1) + SourceIndex(1) -2 >Emitted(12, 34) Source(2, 34) + SourceIndex(1) +1->Emitted(12, 1) Source(2, 1) + SourceIndex(2) +2 >Emitted(12, 34) Source(2, 34) + SourceIndex(2) --- >>>var a1 = 10; 1 > @@ -349,25 +349,25 @@ sourceFile:test.ts 4 > = 5 > 10 6 > ; -1 >Emitted(13, 1) Source(3, 1) + SourceIndex(1) -2 >Emitted(13, 5) Source(3, 5) + SourceIndex(1) -3 >Emitted(13, 7) Source(3, 7) + SourceIndex(1) -4 >Emitted(13, 10) Source(3, 10) + SourceIndex(1) -5 >Emitted(13, 12) Source(3, 12) + SourceIndex(1) -6 >Emitted(13, 13) Source(3, 13) + SourceIndex(1) +1 >Emitted(13, 1) Source(3, 1) + SourceIndex(2) +2 >Emitted(13, 5) Source(3, 5) + SourceIndex(2) +3 >Emitted(13, 7) Source(3, 7) + SourceIndex(2) +4 >Emitted(13, 10) Source(3, 10) + SourceIndex(2) +5 >Emitted(13, 12) Source(3, 12) + SourceIndex(2) +6 >Emitted(13, 13) Source(3, 13) + SourceIndex(2) --- >>>var c1 = (function () { 1-> 2 >^^^^^^^^^^^^^^^^^^^^-> 1-> > -1->Emitted(14, 1) Source(4, 1) + SourceIndex(1) +1->Emitted(14, 1) Source(4, 1) + SourceIndex(2) --- >>> function c1() { 1->^^^^ 2 > ^^-> 1-> -1->Emitted(15, 5) Source(4, 1) + SourceIndex(1) name (c1) +1->Emitted(15, 5) Source(4, 1) + SourceIndex(2) name (c1) --- >>> } 1->^^^^ @@ -377,16 +377,16 @@ sourceFile:test.ts > public p1: number; > 2 > } -1->Emitted(16, 5) Source(6, 1) + SourceIndex(1) name (c1.constructor) -2 >Emitted(16, 6) Source(6, 2) + SourceIndex(1) name (c1.constructor) +1->Emitted(16, 5) Source(6, 1) + SourceIndex(2) name (c1.constructor) +2 >Emitted(16, 6) Source(6, 2) + SourceIndex(2) name (c1.constructor) --- >>> return c1; 1->^^^^ 2 > ^^^^^^^^^ 1-> 2 > } -1->Emitted(17, 5) Source(6, 1) + SourceIndex(1) name (c1) -2 >Emitted(17, 14) Source(6, 2) + SourceIndex(1) name (c1) +1->Emitted(17, 5) Source(6, 1) + SourceIndex(2) name (c1) +2 >Emitted(17, 14) Source(6, 2) + SourceIndex(2) name (c1) --- >>>})(); 1 > @@ -400,10 +400,10 @@ sourceFile:test.ts 4 > class c1 { > public p1: number; > } -1 >Emitted(18, 1) Source(6, 1) + SourceIndex(1) name (c1) -2 >Emitted(18, 2) Source(6, 2) + SourceIndex(1) name (c1) -3 >Emitted(18, 2) Source(4, 1) + SourceIndex(1) -4 >Emitted(18, 6) Source(6, 2) + SourceIndex(1) +1 >Emitted(18, 1) Source(6, 1) + SourceIndex(2) name (c1) +2 >Emitted(18, 2) Source(6, 2) + SourceIndex(2) name (c1) +3 >Emitted(18, 2) Source(4, 1) + SourceIndex(2) +4 >Emitted(18, 6) Source(6, 2) + SourceIndex(2) --- >>>var instance1 = new c1(); 1-> @@ -424,21 +424,21 @@ sourceFile:test.ts 6 > c1 7 > () 8 > ; -1->Emitted(19, 1) Source(8, 1) + SourceIndex(1) -2 >Emitted(19, 5) Source(8, 5) + SourceIndex(1) -3 >Emitted(19, 14) Source(8, 14) + SourceIndex(1) -4 >Emitted(19, 17) Source(8, 17) + SourceIndex(1) -5 >Emitted(19, 21) Source(8, 21) + SourceIndex(1) -6 >Emitted(19, 23) Source(8, 23) + SourceIndex(1) -7 >Emitted(19, 25) Source(8, 25) + SourceIndex(1) -8 >Emitted(19, 26) Source(8, 26) + SourceIndex(1) +1->Emitted(19, 1) Source(8, 1) + SourceIndex(2) +2 >Emitted(19, 5) Source(8, 5) + SourceIndex(2) +3 >Emitted(19, 14) Source(8, 14) + SourceIndex(2) +4 >Emitted(19, 17) Source(8, 17) + SourceIndex(2) +5 >Emitted(19, 21) Source(8, 21) + SourceIndex(2) +6 >Emitted(19, 23) Source(8, 23) + SourceIndex(2) +7 >Emitted(19, 25) Source(8, 25) + SourceIndex(2) +8 >Emitted(19, 26) Source(8, 26) + SourceIndex(2) --- >>>function f1() { 1 > 2 >^^^^^^^^^^^^^^^^^^^^^^-> 1 > > -1 >Emitted(20, 1) Source(9, 1) + SourceIndex(1) +1 >Emitted(20, 1) Source(9, 1) + SourceIndex(2) --- >>> return instance1; 1->^^^^ @@ -452,11 +452,11 @@ sourceFile:test.ts 3 > 4 > instance1 5 > ; -1->Emitted(21, 5) Source(10, 5) + SourceIndex(1) name (f1) -2 >Emitted(21, 11) Source(10, 11) + SourceIndex(1) name (f1) -3 >Emitted(21, 12) Source(10, 12) + SourceIndex(1) name (f1) -4 >Emitted(21, 21) Source(10, 21) + SourceIndex(1) name (f1) -5 >Emitted(21, 22) Source(10, 22) + SourceIndex(1) name (f1) +1->Emitted(21, 5) Source(10, 5) + SourceIndex(2) name (f1) +2 >Emitted(21, 11) Source(10, 11) + SourceIndex(2) name (f1) +3 >Emitted(21, 12) Source(10, 12) + SourceIndex(2) name (f1) +4 >Emitted(21, 21) Source(10, 21) + SourceIndex(2) name (f1) +5 >Emitted(21, 22) Source(10, 22) + SourceIndex(2) name (f1) --- >>>} 1 > @@ -465,7 +465,7 @@ sourceFile:test.ts 1 > > 2 >} -1 >Emitted(22, 1) Source(11, 1) + SourceIndex(1) name (f1) -2 >Emitted(22, 2) Source(11, 2) + SourceIndex(1) name (f1) +1 >Emitted(22, 1) Source(11, 1) + SourceIndex(2) name (f1) +2 >Emitted(22, 2) Source(11, 2) + SourceIndex(2) name (f1) --- >>>//# sourceMappingURL=test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.d.ts b/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.d.ts deleted file mode 100644 index 9b9cdd4a214..00000000000 --- a/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.d.ts +++ /dev/null @@ -1,13 +0,0 @@ -/// -declare var m1_a1: number; -declare class m1_c1 { - m1_c1_p1: number; -} -declare var m1_instance1: m1_c1; -declare function m1_f1(): m1_c1; -declare var a1: number; -declare class c1 { - p1: number; -} -declare var instance1: c1; -declare function f1(): c1; diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.js b/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.js deleted file mode 100644 index 1750a5975ae..00000000000 --- a/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.js +++ /dev/null @@ -1,23 +0,0 @@ -var m1_a1 = 10; -var m1_c1 = (function () { - function m1_c1() { - } - return m1_c1; -})(); -var m1_instance1 = new m1_c1(); -function m1_f1() { - return m1_instance1; -} -/// -/// -var a1 = 10; -var c1 = (function () { - function c1() { - } - return c1; -})(); -var instance1 = new c1(); -function f1() { - return instance1; -} -//# sourceMappingURL=outAndOutDirFile.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.js.map b/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.js.map index 820efe6d9d1..454bdf3acb0 100644 --- a/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.js.map +++ b/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.js.map @@ -1 +1 @@ -{"version":3,"file":"outAndOutDirFile.js","sourceRoot":"/tests/cases/projects/outputdir_mixed_subfolder/src/","sources":["ref/m1.ts","test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACRD,iCAAiC;AACjC,iCAAiC;AACjC,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"outAndOutDirFile.js","sourceRoot":"/tests/cases/projects/outputdir_mixed_subfolder/src/","sources":["ref/m1.ts","ref/m2.ts","test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","m2_c1","m2_c1.constructor","m2_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;;ICRU,aAAK,GAAG,EAAE,CAAC;IACtB;QAAAC;QAEAC,CAACA;QAADD,YAACA;IAADA,CAACA,AAFD,IAEC;IAFY,aAAK,QAEjB,CAAA;IAEU,oBAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACIE,MAAMA,CAACA,oBAAYA,CAACA;IACxBA,CAACA;IAFe,aAAK,QAEpB,CAAA;;ACRD,iCAAiC;AACjC,iCAAiC;AACjC,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory.sourcemap.txt b/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory.sourcemap.txt index 8536097d111..bda16ffe4e1 100644 --- a/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory.sourcemap.txt +++ b/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory.sourcemap.txt @@ -174,7 +174,7 @@ sourceFile:ref/m2.ts JsFile: outAndOutDirFile.js mapUrl: outAndOutDirFile.js.map sourceRoot: /tests/cases/projects/outputdir_mixed_subfolder/src/ -sources: ref/m1.ts,test.ts +sources: ref/m1.ts,ref/m2.ts,test.ts =================================================================== ------------------------------------------------------------------- emittedFile:bin/outAndOutDirFile.js @@ -306,7 +306,7 @@ sourceFile:ref/m1.ts >>>} 1 > 2 >^ -3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> 1 > > 2 >} @@ -315,16 +315,182 @@ sourceFile:ref/m1.ts --- ------------------------------------------------------------------- emittedFile:bin/outAndOutDirFile.js +sourceFile:ref/m2.ts +------------------------------------------------------------------- +>>>define("ref/m2", ["require", "exports"], function (require, exports) { +>>> exports.m2_a1 = 10; +1->^^^^ +2 > ^^^^^^^^^^^^^ +3 > ^^^ +4 > ^^ +5 > ^ +6 > ^^^^^^^^-> +1->export var +2 > m2_a1 +3 > = +4 > 10 +5 > ; +1->Emitted(12, 5) Source(1, 12) + SourceIndex(1) +2 >Emitted(12, 18) Source(1, 17) + SourceIndex(1) +3 >Emitted(12, 21) Source(1, 20) + SourceIndex(1) +4 >Emitted(12, 23) Source(1, 22) + SourceIndex(1) +5 >Emitted(12, 24) Source(1, 23) + SourceIndex(1) +--- +>>> var m2_c1 = (function () { +1->^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^^^^-> +1-> + > +1->Emitted(13, 5) Source(2, 1) + SourceIndex(1) +--- +>>> function m2_c1() { +1->^^^^^^^^ +2 > ^^-> +1-> +1->Emitted(14, 9) Source(2, 1) + SourceIndex(1) name (m2_c1) +--- +>>> } +1->^^^^^^^^ +2 > ^ +3 > ^^^^^^^^^^^^^-> +1->export class m2_c1 { + > public m2_c1_p1: number; + > +2 > } +1->Emitted(15, 9) Source(4, 1) + SourceIndex(1) name (m2_c1.constructor) +2 >Emitted(15, 10) Source(4, 2) + SourceIndex(1) name (m2_c1.constructor) +--- +>>> return m2_c1; +1->^^^^^^^^ +2 > ^^^^^^^^^^^^ +1-> +2 > } +1->Emitted(16, 9) Source(4, 1) + SourceIndex(1) name (m2_c1) +2 >Emitted(16, 21) Source(4, 2) + SourceIndex(1) name (m2_c1) +--- +>>> })(); +1 >^^^^ +2 > ^ +3 > +4 > ^^^^ +5 > ^^^^^^^^^^^^^^^^^^-> +1 > +2 > } +3 > +4 > export class m2_c1 { + > public m2_c1_p1: number; + > } +1 >Emitted(17, 5) Source(4, 1) + SourceIndex(1) name (m2_c1) +2 >Emitted(17, 6) Source(4, 2) + SourceIndex(1) name (m2_c1) +3 >Emitted(17, 6) Source(2, 1) + SourceIndex(1) +4 >Emitted(17, 10) Source(4, 2) + SourceIndex(1) +--- +>>> exports.m2_c1 = m2_c1; +1->^^^^ +2 > ^^^^^^^^^^^^^ +3 > ^^^^^^^^ +4 > ^ +5 > ^^^^^^^^^^^^^^-> +1-> +2 > m2_c1 +3 > { + > public m2_c1_p1: number; + > } +4 > +1->Emitted(18, 5) Source(2, 14) + SourceIndex(1) +2 >Emitted(18, 18) Source(2, 19) + SourceIndex(1) +3 >Emitted(18, 26) Source(4, 2) + SourceIndex(1) +4 >Emitted(18, 27) Source(4, 2) + SourceIndex(1) +--- +>>> exports.m2_instance1 = new m2_c1(); +1->^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^ +3 > ^^^ +4 > ^^^^ +5 > ^^^^^ +6 > ^^ +7 > ^ +1-> + > + >export var +2 > m2_instance1 +3 > = +4 > new +5 > m2_c1 +6 > () +7 > ; +1->Emitted(19, 5) Source(6, 12) + SourceIndex(1) +2 >Emitted(19, 25) Source(6, 24) + SourceIndex(1) +3 >Emitted(19, 28) Source(6, 27) + SourceIndex(1) +4 >Emitted(19, 32) Source(6, 31) + SourceIndex(1) +5 >Emitted(19, 37) Source(6, 36) + SourceIndex(1) +6 >Emitted(19, 39) Source(6, 38) + SourceIndex(1) +7 >Emitted(19, 40) Source(6, 39) + SourceIndex(1) +--- +>>> function m2_f1() { +1 >^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +1 > + > +1 >Emitted(20, 5) Source(7, 1) + SourceIndex(1) +--- +>>> return exports.m2_instance1; +1->^^^^^^^^ +2 > ^^^^^^ +3 > ^ +4 > ^^^^^^^^^^^^^^^^^^^^ +5 > ^ +1->export function m2_f1() { + > +2 > return +3 > +4 > m2_instance1 +5 > ; +1->Emitted(21, 9) Source(8, 5) + SourceIndex(1) name (m2_f1) +2 >Emitted(21, 15) Source(8, 11) + SourceIndex(1) name (m2_f1) +3 >Emitted(21, 16) Source(8, 12) + SourceIndex(1) name (m2_f1) +4 >Emitted(21, 36) Source(8, 24) + SourceIndex(1) name (m2_f1) +5 >Emitted(21, 37) Source(8, 25) + SourceIndex(1) name (m2_f1) +--- +>>> } +1 >^^^^ +2 > ^ +3 > ^^^^^^^^^^^^^^^^^^^^^^-> +1 > + > +2 > } +1 >Emitted(22, 5) Source(9, 1) + SourceIndex(1) name (m2_f1) +2 >Emitted(22, 6) Source(9, 2) + SourceIndex(1) name (m2_f1) +--- +>>> exports.m2_f1 = m2_f1; +1->^^^^ +2 > ^^^^^^^^^^^^^ +3 > ^^^^^^^^ +4 > ^ +1-> +2 > m2_f1 +3 > () { + > return m2_instance1; + > } +4 > +1->Emitted(23, 5) Source(7, 17) + SourceIndex(1) +2 >Emitted(23, 18) Source(7, 22) + SourceIndex(1) +3 >Emitted(23, 26) Source(9, 2) + SourceIndex(1) +4 >Emitted(23, 27) Source(9, 2) + SourceIndex(1) +--- +------------------------------------------------------------------- +emittedFile:bin/outAndOutDirFile.js sourceFile:test.ts ------------------------------------------------------------------- +>>>}); >>>/// -1-> +1 > 2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 3 > ^-> -1-> +1 > 2 >/// -1->Emitted(11, 1) Source(1, 1) + SourceIndex(1) -2 >Emitted(11, 34) Source(1, 34) + SourceIndex(1) +1 >Emitted(25, 1) Source(1, 1) + SourceIndex(2) +2 >Emitted(25, 34) Source(1, 34) + SourceIndex(2) --- >>>/// 1-> @@ -332,8 +498,8 @@ sourceFile:test.ts 1-> > 2 >/// -1->Emitted(12, 1) Source(2, 1) + SourceIndex(1) -2 >Emitted(12, 34) Source(2, 34) + SourceIndex(1) +1->Emitted(26, 1) Source(2, 1) + SourceIndex(2) +2 >Emitted(26, 34) Source(2, 34) + SourceIndex(2) --- >>>var a1 = 10; 1 > @@ -350,25 +516,25 @@ sourceFile:test.ts 4 > = 5 > 10 6 > ; -1 >Emitted(13, 1) Source(3, 1) + SourceIndex(1) -2 >Emitted(13, 5) Source(3, 5) + SourceIndex(1) -3 >Emitted(13, 7) Source(3, 7) + SourceIndex(1) -4 >Emitted(13, 10) Source(3, 10) + SourceIndex(1) -5 >Emitted(13, 12) Source(3, 12) + SourceIndex(1) -6 >Emitted(13, 13) Source(3, 13) + SourceIndex(1) +1 >Emitted(27, 1) Source(3, 1) + SourceIndex(2) +2 >Emitted(27, 5) Source(3, 5) + SourceIndex(2) +3 >Emitted(27, 7) Source(3, 7) + SourceIndex(2) +4 >Emitted(27, 10) Source(3, 10) + SourceIndex(2) +5 >Emitted(27, 12) Source(3, 12) + SourceIndex(2) +6 >Emitted(27, 13) Source(3, 13) + SourceIndex(2) --- >>>var c1 = (function () { 1-> 2 >^^^^^^^^^^^^^^^^^^^^-> 1-> > -1->Emitted(14, 1) Source(4, 1) + SourceIndex(1) +1->Emitted(28, 1) Source(4, 1) + SourceIndex(2) --- >>> function c1() { 1->^^^^ 2 > ^^-> 1-> -1->Emitted(15, 5) Source(4, 1) + SourceIndex(1) name (c1) +1->Emitted(29, 5) Source(4, 1) + SourceIndex(2) name (c1) --- >>> } 1->^^^^ @@ -378,16 +544,16 @@ sourceFile:test.ts > public p1: number; > 2 > } -1->Emitted(16, 5) Source(6, 1) + SourceIndex(1) name (c1.constructor) -2 >Emitted(16, 6) Source(6, 2) + SourceIndex(1) name (c1.constructor) +1->Emitted(30, 5) Source(6, 1) + SourceIndex(2) name (c1.constructor) +2 >Emitted(30, 6) Source(6, 2) + SourceIndex(2) name (c1.constructor) --- >>> return c1; 1->^^^^ 2 > ^^^^^^^^^ 1-> 2 > } -1->Emitted(17, 5) Source(6, 1) + SourceIndex(1) name (c1) -2 >Emitted(17, 14) Source(6, 2) + SourceIndex(1) name (c1) +1->Emitted(31, 5) Source(6, 1) + SourceIndex(2) name (c1) +2 >Emitted(31, 14) Source(6, 2) + SourceIndex(2) name (c1) --- >>>})(); 1 > @@ -401,10 +567,10 @@ sourceFile:test.ts 4 > class c1 { > public p1: number; > } -1 >Emitted(18, 1) Source(6, 1) + SourceIndex(1) name (c1) -2 >Emitted(18, 2) Source(6, 2) + SourceIndex(1) name (c1) -3 >Emitted(18, 2) Source(4, 1) + SourceIndex(1) -4 >Emitted(18, 6) Source(6, 2) + SourceIndex(1) +1 >Emitted(32, 1) Source(6, 1) + SourceIndex(2) name (c1) +2 >Emitted(32, 2) Source(6, 2) + SourceIndex(2) name (c1) +3 >Emitted(32, 2) Source(4, 1) + SourceIndex(2) +4 >Emitted(32, 6) Source(6, 2) + SourceIndex(2) --- >>>var instance1 = new c1(); 1-> @@ -425,21 +591,21 @@ sourceFile:test.ts 6 > c1 7 > () 8 > ; -1->Emitted(19, 1) Source(8, 1) + SourceIndex(1) -2 >Emitted(19, 5) Source(8, 5) + SourceIndex(1) -3 >Emitted(19, 14) Source(8, 14) + SourceIndex(1) -4 >Emitted(19, 17) Source(8, 17) + SourceIndex(1) -5 >Emitted(19, 21) Source(8, 21) + SourceIndex(1) -6 >Emitted(19, 23) Source(8, 23) + SourceIndex(1) -7 >Emitted(19, 25) Source(8, 25) + SourceIndex(1) -8 >Emitted(19, 26) Source(8, 26) + SourceIndex(1) +1->Emitted(33, 1) Source(8, 1) + SourceIndex(2) +2 >Emitted(33, 5) Source(8, 5) + SourceIndex(2) +3 >Emitted(33, 14) Source(8, 14) + SourceIndex(2) +4 >Emitted(33, 17) Source(8, 17) + SourceIndex(2) +5 >Emitted(33, 21) Source(8, 21) + SourceIndex(2) +6 >Emitted(33, 23) Source(8, 23) + SourceIndex(2) +7 >Emitted(33, 25) Source(8, 25) + SourceIndex(2) +8 >Emitted(33, 26) Source(8, 26) + SourceIndex(2) --- >>>function f1() { 1 > 2 >^^^^^^^^^^^^^^^^^^^^^^-> 1 > > -1 >Emitted(20, 1) Source(9, 1) + SourceIndex(1) +1 >Emitted(34, 1) Source(9, 1) + SourceIndex(2) --- >>> return instance1; 1->^^^^ @@ -453,11 +619,11 @@ sourceFile:test.ts 3 > 4 > instance1 5 > ; -1->Emitted(21, 5) Source(10, 5) + SourceIndex(1) name (f1) -2 >Emitted(21, 11) Source(10, 11) + SourceIndex(1) name (f1) -3 >Emitted(21, 12) Source(10, 12) + SourceIndex(1) name (f1) -4 >Emitted(21, 21) Source(10, 21) + SourceIndex(1) name (f1) -5 >Emitted(21, 22) Source(10, 22) + SourceIndex(1) name (f1) +1->Emitted(35, 5) Source(10, 5) + SourceIndex(2) name (f1) +2 >Emitted(35, 11) Source(10, 11) + SourceIndex(2) name (f1) +3 >Emitted(35, 12) Source(10, 12) + SourceIndex(2) name (f1) +4 >Emitted(35, 21) Source(10, 21) + SourceIndex(2) name (f1) +5 >Emitted(35, 22) Source(10, 22) + SourceIndex(2) name (f1) --- >>>} 1 > @@ -466,7 +632,7 @@ sourceFile:test.ts 1 > > 2 >} -1 >Emitted(22, 1) Source(11, 1) + SourceIndex(1) name (f1) -2 >Emitted(22, 2) Source(11, 2) + SourceIndex(1) name (f1) +1 >Emitted(36, 1) Source(11, 1) + SourceIndex(2) name (f1) +2 >Emitted(36, 2) Source(11, 2) + SourceIndex(2) name (f1) --- >>>//# sourceMappingURL=outAndOutDirFile.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.d.ts b/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.d.ts deleted file mode 100644 index 9b9cdd4a214..00000000000 --- a/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.d.ts +++ /dev/null @@ -1,13 +0,0 @@ -/// -declare var m1_a1: number; -declare class m1_c1 { - m1_c1_p1: number; -} -declare var m1_instance1: m1_c1; -declare function m1_f1(): m1_c1; -declare var a1: number; -declare class c1 { - p1: number; -} -declare var instance1: c1; -declare function f1(): c1; diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.js b/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.js deleted file mode 100644 index 1750a5975ae..00000000000 --- a/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.js +++ /dev/null @@ -1,23 +0,0 @@ -var m1_a1 = 10; -var m1_c1 = (function () { - function m1_c1() { - } - return m1_c1; -})(); -var m1_instance1 = new m1_c1(); -function m1_f1() { - return m1_instance1; -} -/// -/// -var a1 = 10; -var c1 = (function () { - function c1() { - } - return c1; -})(); -var instance1 = new c1(); -function f1() { - return instance1; -} -//# sourceMappingURL=outAndOutDirFile.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.js.map b/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.js.map index 820efe6d9d1..f7d00d1aff9 100644 --- a/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.js.map +++ b/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.js.map @@ -1 +1 @@ -{"version":3,"file":"outAndOutDirFile.js","sourceRoot":"/tests/cases/projects/outputdir_mixed_subfolder/src/","sources":["ref/m1.ts","test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACRD,iCAAiC;AACjC,iCAAiC;AACjC,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"outAndOutDirFile.js","sourceRoot":"/tests/cases/projects/outputdir_mixed_subfolder/src/","sources":["ref/m1.ts","ref/m2.ts","test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;AERD,iCAAiC;AACjC,iCAAiC;AACjC,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory.sourcemap.txt b/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory.sourcemap.txt index 47e9f1da73a..d46f8d557ed 100644 --- a/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory.sourcemap.txt +++ b/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory.sourcemap.txt @@ -173,7 +173,7 @@ sourceFile:ref/m2.ts JsFile: outAndOutDirFile.js mapUrl: outAndOutDirFile.js.map sourceRoot: /tests/cases/projects/outputdir_mixed_subfolder/src/ -sources: ref/m1.ts,test.ts +sources: ref/m1.ts,ref/m2.ts,test.ts =================================================================== ------------------------------------------------------------------- emittedFile:bin/outAndOutDirFile.js @@ -322,8 +322,8 @@ sourceFile:test.ts 3 > ^-> 1-> 2 >/// -1->Emitted(11, 1) Source(1, 1) + SourceIndex(1) -2 >Emitted(11, 34) Source(1, 34) + SourceIndex(1) +1->Emitted(11, 1) Source(1, 1) + SourceIndex(2) +2 >Emitted(11, 34) Source(1, 34) + SourceIndex(2) --- >>>/// 1-> @@ -331,8 +331,8 @@ sourceFile:test.ts 1-> > 2 >/// -1->Emitted(12, 1) Source(2, 1) + SourceIndex(1) -2 >Emitted(12, 34) Source(2, 34) + SourceIndex(1) +1->Emitted(12, 1) Source(2, 1) + SourceIndex(2) +2 >Emitted(12, 34) Source(2, 34) + SourceIndex(2) --- >>>var a1 = 10; 1 > @@ -349,25 +349,25 @@ sourceFile:test.ts 4 > = 5 > 10 6 > ; -1 >Emitted(13, 1) Source(3, 1) + SourceIndex(1) -2 >Emitted(13, 5) Source(3, 5) + SourceIndex(1) -3 >Emitted(13, 7) Source(3, 7) + SourceIndex(1) -4 >Emitted(13, 10) Source(3, 10) + SourceIndex(1) -5 >Emitted(13, 12) Source(3, 12) + SourceIndex(1) -6 >Emitted(13, 13) Source(3, 13) + SourceIndex(1) +1 >Emitted(13, 1) Source(3, 1) + SourceIndex(2) +2 >Emitted(13, 5) Source(3, 5) + SourceIndex(2) +3 >Emitted(13, 7) Source(3, 7) + SourceIndex(2) +4 >Emitted(13, 10) Source(3, 10) + SourceIndex(2) +5 >Emitted(13, 12) Source(3, 12) + SourceIndex(2) +6 >Emitted(13, 13) Source(3, 13) + SourceIndex(2) --- >>>var c1 = (function () { 1-> 2 >^^^^^^^^^^^^^^^^^^^^-> 1-> > -1->Emitted(14, 1) Source(4, 1) + SourceIndex(1) +1->Emitted(14, 1) Source(4, 1) + SourceIndex(2) --- >>> function c1() { 1->^^^^ 2 > ^^-> 1-> -1->Emitted(15, 5) Source(4, 1) + SourceIndex(1) name (c1) +1->Emitted(15, 5) Source(4, 1) + SourceIndex(2) name (c1) --- >>> } 1->^^^^ @@ -377,16 +377,16 @@ sourceFile:test.ts > public p1: number; > 2 > } -1->Emitted(16, 5) Source(6, 1) + SourceIndex(1) name (c1.constructor) -2 >Emitted(16, 6) Source(6, 2) + SourceIndex(1) name (c1.constructor) +1->Emitted(16, 5) Source(6, 1) + SourceIndex(2) name (c1.constructor) +2 >Emitted(16, 6) Source(6, 2) + SourceIndex(2) name (c1.constructor) --- >>> return c1; 1->^^^^ 2 > ^^^^^^^^^ 1-> 2 > } -1->Emitted(17, 5) Source(6, 1) + SourceIndex(1) name (c1) -2 >Emitted(17, 14) Source(6, 2) + SourceIndex(1) name (c1) +1->Emitted(17, 5) Source(6, 1) + SourceIndex(2) name (c1) +2 >Emitted(17, 14) Source(6, 2) + SourceIndex(2) name (c1) --- >>>})(); 1 > @@ -400,10 +400,10 @@ sourceFile:test.ts 4 > class c1 { > public p1: number; > } -1 >Emitted(18, 1) Source(6, 1) + SourceIndex(1) name (c1) -2 >Emitted(18, 2) Source(6, 2) + SourceIndex(1) name (c1) -3 >Emitted(18, 2) Source(4, 1) + SourceIndex(1) -4 >Emitted(18, 6) Source(6, 2) + SourceIndex(1) +1 >Emitted(18, 1) Source(6, 1) + SourceIndex(2) name (c1) +2 >Emitted(18, 2) Source(6, 2) + SourceIndex(2) name (c1) +3 >Emitted(18, 2) Source(4, 1) + SourceIndex(2) +4 >Emitted(18, 6) Source(6, 2) + SourceIndex(2) --- >>>var instance1 = new c1(); 1-> @@ -424,21 +424,21 @@ sourceFile:test.ts 6 > c1 7 > () 8 > ; -1->Emitted(19, 1) Source(8, 1) + SourceIndex(1) -2 >Emitted(19, 5) Source(8, 5) + SourceIndex(1) -3 >Emitted(19, 14) Source(8, 14) + SourceIndex(1) -4 >Emitted(19, 17) Source(8, 17) + SourceIndex(1) -5 >Emitted(19, 21) Source(8, 21) + SourceIndex(1) -6 >Emitted(19, 23) Source(8, 23) + SourceIndex(1) -7 >Emitted(19, 25) Source(8, 25) + SourceIndex(1) -8 >Emitted(19, 26) Source(8, 26) + SourceIndex(1) +1->Emitted(19, 1) Source(8, 1) + SourceIndex(2) +2 >Emitted(19, 5) Source(8, 5) + SourceIndex(2) +3 >Emitted(19, 14) Source(8, 14) + SourceIndex(2) +4 >Emitted(19, 17) Source(8, 17) + SourceIndex(2) +5 >Emitted(19, 21) Source(8, 21) + SourceIndex(2) +6 >Emitted(19, 23) Source(8, 23) + SourceIndex(2) +7 >Emitted(19, 25) Source(8, 25) + SourceIndex(2) +8 >Emitted(19, 26) Source(8, 26) + SourceIndex(2) --- >>>function f1() { 1 > 2 >^^^^^^^^^^^^^^^^^^^^^^-> 1 > > -1 >Emitted(20, 1) Source(9, 1) + SourceIndex(1) +1 >Emitted(20, 1) Source(9, 1) + SourceIndex(2) --- >>> return instance1; 1->^^^^ @@ -452,11 +452,11 @@ sourceFile:test.ts 3 > 4 > instance1 5 > ; -1->Emitted(21, 5) Source(10, 5) + SourceIndex(1) name (f1) -2 >Emitted(21, 11) Source(10, 11) + SourceIndex(1) name (f1) -3 >Emitted(21, 12) Source(10, 12) + SourceIndex(1) name (f1) -4 >Emitted(21, 21) Source(10, 21) + SourceIndex(1) name (f1) -5 >Emitted(21, 22) Source(10, 22) + SourceIndex(1) name (f1) +1->Emitted(21, 5) Source(10, 5) + SourceIndex(2) name (f1) +2 >Emitted(21, 11) Source(10, 11) + SourceIndex(2) name (f1) +3 >Emitted(21, 12) Source(10, 12) + SourceIndex(2) name (f1) +4 >Emitted(21, 21) Source(10, 21) + SourceIndex(2) name (f1) +5 >Emitted(21, 22) Source(10, 22) + SourceIndex(2) name (f1) --- >>>} 1 > @@ -465,7 +465,7 @@ sourceFile:test.ts 1 > > 2 >} -1 >Emitted(22, 1) Source(11, 1) + SourceIndex(1) name (f1) -2 >Emitted(22, 2) Source(11, 2) + SourceIndex(1) name (f1) +1 >Emitted(22, 1) Source(11, 1) + SourceIndex(2) name (f1) +2 >Emitted(22, 2) Source(11, 2) + SourceIndex(2) name (f1) --- >>>//# sourceMappingURL=outAndOutDirFile.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderSpecifyOutputFile/amd/bin/test.d.ts b/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderSpecifyOutputFile/amd/bin/test.d.ts deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderSpecifyOutputFile/amd/bin/test.js b/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderSpecifyOutputFile/amd/bin/test.js deleted file mode 100644 index 6f3fefb9498..00000000000 --- a/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderSpecifyOutputFile/amd/bin/test.js +++ /dev/null @@ -1 +0,0 @@ -//# sourceMappingURL=test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderSpecifyOutputFile/amd/bin/test.js.map b/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderSpecifyOutputFile/amd/bin/test.js.map index e53f2e0a755..0fd0b2def0c 100644 --- a/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderSpecifyOutputFile/amd/bin/test.js.map +++ b/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderSpecifyOutputFile/amd/bin/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"/tests/cases/projects/outputdir_module_multifolder/src/","sources":[],"names":[],"mappings":""} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"/tests/cases/projects/outputdir_module_multifolder/src/","sources":["outputdir_module_multifolder/ref/m1.ts","outputdir_module_multifolder_ref/m2.ts","outputdir_module_multifolder/test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","m2_c1","m2_c1.constructor","m2_f1","c1","c1.constructor","f1"],"mappings":";IAAW,aAAK,GAAG,EAAE,CAAC;IACtB;QAAAA;QAEAC,CAACA;QAADD,YAACA;IAADA,CAACA,AAFD,IAEC;IAFY,aAAK,QAEjB,CAAA;IAEU,oBAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACIE,MAAMA,CAACA,oBAAYA,CAACA;IACxBA,CAACA;IAFe,aAAK,QAEpB,CAAA;;;ICRU,aAAK,GAAG,EAAE,CAAC;IACtB;QAAAC;QAEAC,CAACA;QAADD,YAACA;IAADA,CAACA,AAFD,IAEC;IAFY,aAAK,QAEjB,CAAA;IAEU,oBAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACIE,MAAMA,CAACA,oBAAYA,CAACA;IACxBA,CAACA;IAFe,aAAK,QAEpB,CAAA;;;ICNU,UAAE,GAAG,EAAE,CAAC;IACnB;QAAAC;QAEAC,CAACA;QAADD,SAACA;IAADA,CAACA,AAFD,IAEC;IAFY,UAAE,KAEd,CAAA;IAEU,iBAAS,GAAG,IAAI,EAAE,EAAE,CAAC;IAChC;QACIE,MAAMA,CAACA,iBAASA,CAACA;IACrBA,CAACA;IAFe,UAAE,KAEjB,CAAA;IAEU,UAAE,GAAG,EAAE,CAAC,KAAK,CAAC;IACd,UAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderSpecifyOutputFile/amd/sourceRootAbsolutePathModuleMultifolderSpecifyOutputFile.sourcemap.txt b/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderSpecifyOutputFile/amd/sourceRootAbsolutePathModuleMultifolderSpecifyOutputFile.sourcemap.txt index e1bca270ba0..3937e0acb04 100644 --- a/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderSpecifyOutputFile/amd/sourceRootAbsolutePathModuleMultifolderSpecifyOutputFile.sourcemap.txt +++ b/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderSpecifyOutputFile/amd/sourceRootAbsolutePathModuleMultifolderSpecifyOutputFile.sourcemap.txt @@ -571,6 +571,557 @@ sourceFile:outputdir_module_multifolder/test.ts JsFile: test.js mapUrl: test.js.map sourceRoot: /tests/cases/projects/outputdir_module_multifolder/src/ -sources: +sources: outputdir_module_multifolder/ref/m1.ts,outputdir_module_multifolder_ref/m2.ts,outputdir_module_multifolder/test.ts =================================================================== +------------------------------------------------------------------- +emittedFile:bin/test.js +sourceFile:outputdir_module_multifolder/ref/m1.ts +------------------------------------------------------------------- +>>>define("ref/m1", ["require", "exports"], function (require, exports) { +>>> exports.m1_a1 = 10; +1 >^^^^ +2 > ^^^^^^^^^^^^^ +3 > ^^^ +4 > ^^ +5 > ^ +6 > ^^^^^^^^-> +1 >export var +2 > m1_a1 +3 > = +4 > 10 +5 > ; +1 >Emitted(2, 5) Source(1, 12) + SourceIndex(0) +2 >Emitted(2, 18) Source(1, 17) + SourceIndex(0) +3 >Emitted(2, 21) Source(1, 20) + SourceIndex(0) +4 >Emitted(2, 23) Source(1, 22) + SourceIndex(0) +5 >Emitted(2, 24) Source(1, 23) + SourceIndex(0) +--- +>>> var m1_c1 = (function () { +1->^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^^^^-> +1-> + > +1->Emitted(3, 5) Source(2, 1) + SourceIndex(0) +--- +>>> function m1_c1() { +1->^^^^^^^^ +2 > ^^-> +1-> +1->Emitted(4, 9) Source(2, 1) + SourceIndex(0) name (m1_c1) +--- +>>> } +1->^^^^^^^^ +2 > ^ +3 > ^^^^^^^^^^^^^-> +1->export class m1_c1 { + > public m1_c1_p1: number; + > +2 > } +1->Emitted(5, 9) Source(4, 1) + SourceIndex(0) name (m1_c1.constructor) +2 >Emitted(5, 10) Source(4, 2) + SourceIndex(0) name (m1_c1.constructor) +--- +>>> return m1_c1; +1->^^^^^^^^ +2 > ^^^^^^^^^^^^ +1-> +2 > } +1->Emitted(6, 9) Source(4, 1) + SourceIndex(0) name (m1_c1) +2 >Emitted(6, 21) Source(4, 2) + SourceIndex(0) name (m1_c1) +--- +>>> })(); +1 >^^^^ +2 > ^ +3 > +4 > ^^^^ +5 > ^^^^^^^^^^^^^^^^^^-> +1 > +2 > } +3 > +4 > export class m1_c1 { + > public m1_c1_p1: number; + > } +1 >Emitted(7, 5) Source(4, 1) + SourceIndex(0) name (m1_c1) +2 >Emitted(7, 6) Source(4, 2) + SourceIndex(0) name (m1_c1) +3 >Emitted(7, 6) Source(2, 1) + SourceIndex(0) +4 >Emitted(7, 10) Source(4, 2) + SourceIndex(0) +--- +>>> exports.m1_c1 = m1_c1; +1->^^^^ +2 > ^^^^^^^^^^^^^ +3 > ^^^^^^^^ +4 > ^ +5 > ^^^^^^^^^^^^^^-> +1-> +2 > m1_c1 +3 > { + > public m1_c1_p1: number; + > } +4 > +1->Emitted(8, 5) Source(2, 14) + SourceIndex(0) +2 >Emitted(8, 18) Source(2, 19) + SourceIndex(0) +3 >Emitted(8, 26) Source(4, 2) + SourceIndex(0) +4 >Emitted(8, 27) Source(4, 2) + SourceIndex(0) +--- +>>> exports.m1_instance1 = new m1_c1(); +1->^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^ +3 > ^^^ +4 > ^^^^ +5 > ^^^^^ +6 > ^^ +7 > ^ +1-> + > + >export var +2 > m1_instance1 +3 > = +4 > new +5 > m1_c1 +6 > () +7 > ; +1->Emitted(9, 5) Source(6, 12) + SourceIndex(0) +2 >Emitted(9, 25) Source(6, 24) + SourceIndex(0) +3 >Emitted(9, 28) Source(6, 27) + SourceIndex(0) +4 >Emitted(9, 32) Source(6, 31) + SourceIndex(0) +5 >Emitted(9, 37) Source(6, 36) + SourceIndex(0) +6 >Emitted(9, 39) Source(6, 38) + SourceIndex(0) +7 >Emitted(9, 40) Source(6, 39) + SourceIndex(0) +--- +>>> function m1_f1() { +1 >^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +1 > + > +1 >Emitted(10, 5) Source(7, 1) + SourceIndex(0) +--- +>>> return exports.m1_instance1; +1->^^^^^^^^ +2 > ^^^^^^ +3 > ^ +4 > ^^^^^^^^^^^^^^^^^^^^ +5 > ^ +1->export function m1_f1() { + > +2 > return +3 > +4 > m1_instance1 +5 > ; +1->Emitted(11, 9) Source(8, 5) + SourceIndex(0) name (m1_f1) +2 >Emitted(11, 15) Source(8, 11) + SourceIndex(0) name (m1_f1) +3 >Emitted(11, 16) Source(8, 12) + SourceIndex(0) name (m1_f1) +4 >Emitted(11, 36) Source(8, 24) + SourceIndex(0) name (m1_f1) +5 >Emitted(11, 37) Source(8, 25) + SourceIndex(0) name (m1_f1) +--- +>>> } +1 >^^^^ +2 > ^ +3 > ^^^^^^^^^^^^^^^^^^^^^^-> +1 > + > +2 > } +1 >Emitted(12, 5) Source(9, 1) + SourceIndex(0) name (m1_f1) +2 >Emitted(12, 6) Source(9, 2) + SourceIndex(0) name (m1_f1) +--- +>>> exports.m1_f1 = m1_f1; +1->^^^^ +2 > ^^^^^^^^^^^^^ +3 > ^^^^^^^^ +4 > ^ +1-> +2 > m1_f1 +3 > () { + > return m1_instance1; + > } +4 > +1->Emitted(13, 5) Source(7, 17) + SourceIndex(0) +2 >Emitted(13, 18) Source(7, 22) + SourceIndex(0) +3 >Emitted(13, 26) Source(9, 2) + SourceIndex(0) +4 >Emitted(13, 27) Source(9, 2) + SourceIndex(0) +--- +------------------------------------------------------------------- +emittedFile:bin/test.js +sourceFile:outputdir_module_multifolder_ref/m2.ts +------------------------------------------------------------------- +>>>}); +>>>define("../outputdir_module_multifolder_ref/m2", ["require", "exports"], function (require, exports) { +>>> exports.m2_a1 = 10; +1 >^^^^ +2 > ^^^^^^^^^^^^^ +3 > ^^^ +4 > ^^ +5 > ^ +6 > ^^^^^^^^-> +1 >export var +2 > m2_a1 +3 > = +4 > 10 +5 > ; +1 >Emitted(16, 5) Source(1, 12) + SourceIndex(1) +2 >Emitted(16, 18) Source(1, 17) + SourceIndex(1) +3 >Emitted(16, 21) Source(1, 20) + SourceIndex(1) +4 >Emitted(16, 23) Source(1, 22) + SourceIndex(1) +5 >Emitted(16, 24) Source(1, 23) + SourceIndex(1) +--- +>>> var m2_c1 = (function () { +1->^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^^^^-> +1-> + > +1->Emitted(17, 5) Source(2, 1) + SourceIndex(1) +--- +>>> function m2_c1() { +1->^^^^^^^^ +2 > ^^-> +1-> +1->Emitted(18, 9) Source(2, 1) + SourceIndex(1) name (m2_c1) +--- +>>> } +1->^^^^^^^^ +2 > ^ +3 > ^^^^^^^^^^^^^-> +1->export class m2_c1 { + > public m2_c1_p1: number; + > +2 > } +1->Emitted(19, 9) Source(4, 1) + SourceIndex(1) name (m2_c1.constructor) +2 >Emitted(19, 10) Source(4, 2) + SourceIndex(1) name (m2_c1.constructor) +--- +>>> return m2_c1; +1->^^^^^^^^ +2 > ^^^^^^^^^^^^ +1-> +2 > } +1->Emitted(20, 9) Source(4, 1) + SourceIndex(1) name (m2_c1) +2 >Emitted(20, 21) Source(4, 2) + SourceIndex(1) name (m2_c1) +--- +>>> })(); +1 >^^^^ +2 > ^ +3 > +4 > ^^^^ +5 > ^^^^^^^^^^^^^^^^^^-> +1 > +2 > } +3 > +4 > export class m2_c1 { + > public m2_c1_p1: number; + > } +1 >Emitted(21, 5) Source(4, 1) + SourceIndex(1) name (m2_c1) +2 >Emitted(21, 6) Source(4, 2) + SourceIndex(1) name (m2_c1) +3 >Emitted(21, 6) Source(2, 1) + SourceIndex(1) +4 >Emitted(21, 10) Source(4, 2) + SourceIndex(1) +--- +>>> exports.m2_c1 = m2_c1; +1->^^^^ +2 > ^^^^^^^^^^^^^ +3 > ^^^^^^^^ +4 > ^ +5 > ^^^^^^^^^^^^^^-> +1-> +2 > m2_c1 +3 > { + > public m2_c1_p1: number; + > } +4 > +1->Emitted(22, 5) Source(2, 14) + SourceIndex(1) +2 >Emitted(22, 18) Source(2, 19) + SourceIndex(1) +3 >Emitted(22, 26) Source(4, 2) + SourceIndex(1) +4 >Emitted(22, 27) Source(4, 2) + SourceIndex(1) +--- +>>> exports.m2_instance1 = new m2_c1(); +1->^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^ +3 > ^^^ +4 > ^^^^ +5 > ^^^^^ +6 > ^^ +7 > ^ +1-> + > + >export var +2 > m2_instance1 +3 > = +4 > new +5 > m2_c1 +6 > () +7 > ; +1->Emitted(23, 5) Source(6, 12) + SourceIndex(1) +2 >Emitted(23, 25) Source(6, 24) + SourceIndex(1) +3 >Emitted(23, 28) Source(6, 27) + SourceIndex(1) +4 >Emitted(23, 32) Source(6, 31) + SourceIndex(1) +5 >Emitted(23, 37) Source(6, 36) + SourceIndex(1) +6 >Emitted(23, 39) Source(6, 38) + SourceIndex(1) +7 >Emitted(23, 40) Source(6, 39) + SourceIndex(1) +--- +>>> function m2_f1() { +1 >^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +1 > + > +1 >Emitted(24, 5) Source(7, 1) + SourceIndex(1) +--- +>>> return exports.m2_instance1; +1->^^^^^^^^ +2 > ^^^^^^ +3 > ^ +4 > ^^^^^^^^^^^^^^^^^^^^ +5 > ^ +1->export function m2_f1() { + > +2 > return +3 > +4 > m2_instance1 +5 > ; +1->Emitted(25, 9) Source(8, 5) + SourceIndex(1) name (m2_f1) +2 >Emitted(25, 15) Source(8, 11) + SourceIndex(1) name (m2_f1) +3 >Emitted(25, 16) Source(8, 12) + SourceIndex(1) name (m2_f1) +4 >Emitted(25, 36) Source(8, 24) + SourceIndex(1) name (m2_f1) +5 >Emitted(25, 37) Source(8, 25) + SourceIndex(1) name (m2_f1) +--- +>>> } +1 >^^^^ +2 > ^ +3 > ^^^^^^^^^^^^^^^^^^^^^^-> +1 > + > +2 > } +1 >Emitted(26, 5) Source(9, 1) + SourceIndex(1) name (m2_f1) +2 >Emitted(26, 6) Source(9, 2) + SourceIndex(1) name (m2_f1) +--- +>>> exports.m2_f1 = m2_f1; +1->^^^^ +2 > ^^^^^^^^^^^^^ +3 > ^^^^^^^^ +4 > ^ +1-> +2 > m2_f1 +3 > () { + > return m2_instance1; + > } +4 > +1->Emitted(27, 5) Source(7, 17) + SourceIndex(1) +2 >Emitted(27, 18) Source(7, 22) + SourceIndex(1) +3 >Emitted(27, 26) Source(9, 2) + SourceIndex(1) +4 >Emitted(27, 27) Source(9, 2) + SourceIndex(1) +--- +------------------------------------------------------------------- +emittedFile:bin/test.js +sourceFile:outputdir_module_multifolder/test.ts +------------------------------------------------------------------- +>>>}); +>>>define("test", ["require", "exports", "ref/m1", "../outputdir_module_multifolder_ref/m2"], function (require, exports, m1, m2) { +>>> exports.a1 = 10; +1 >^^^^ +2 > ^^^^^^^^^^ +3 > ^^^ +4 > ^^ +5 > ^ +6 > ^^^^^^^^-> +1 >import m1 = require("ref/m1"); + >import m2 = require("../outputdir_module_multifolder_ref/m2"); + >export var +2 > a1 +3 > = +4 > 10 +5 > ; +1 >Emitted(30, 5) Source(3, 12) + SourceIndex(2) +2 >Emitted(30, 15) Source(3, 14) + SourceIndex(2) +3 >Emitted(30, 18) Source(3, 17) + SourceIndex(2) +4 >Emitted(30, 20) Source(3, 19) + SourceIndex(2) +5 >Emitted(30, 21) Source(3, 20) + SourceIndex(2) +--- +>>> var c1 = (function () { +1->^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^-> +1-> + > +1->Emitted(31, 5) Source(4, 1) + SourceIndex(2) +--- +>>> function c1() { +1->^^^^^^^^ +2 > ^^-> +1-> +1->Emitted(32, 9) Source(4, 1) + SourceIndex(2) name (c1) +--- +>>> } +1->^^^^^^^^ +2 > ^ +3 > ^^^^^^^^^^-> +1->export class c1 { + > public p1: number; + > +2 > } +1->Emitted(33, 9) Source(6, 1) + SourceIndex(2) name (c1.constructor) +2 >Emitted(33, 10) Source(6, 2) + SourceIndex(2) name (c1.constructor) +--- +>>> return c1; +1->^^^^^^^^ +2 > ^^^^^^^^^ +1-> +2 > } +1->Emitted(34, 9) Source(6, 1) + SourceIndex(2) name (c1) +2 >Emitted(34, 18) Source(6, 2) + SourceIndex(2) name (c1) +--- +>>> })(); +1 >^^^^ +2 > ^ +3 > +4 > ^^^^ +5 > ^^^^^^^^^^^^-> +1 > +2 > } +3 > +4 > export class c1 { + > public p1: number; + > } +1 >Emitted(35, 5) Source(6, 1) + SourceIndex(2) name (c1) +2 >Emitted(35, 6) Source(6, 2) + SourceIndex(2) name (c1) +3 >Emitted(35, 6) Source(4, 1) + SourceIndex(2) +4 >Emitted(35, 10) Source(6, 2) + SourceIndex(2) +--- +>>> exports.c1 = c1; +1->^^^^ +2 > ^^^^^^^^^^ +3 > ^^^^^ +4 > ^ +5 > ^^^^^^^^^^^^^^-> +1-> +2 > c1 +3 > { + > public p1: number; + > } +4 > +1->Emitted(36, 5) Source(4, 14) + SourceIndex(2) +2 >Emitted(36, 15) Source(4, 16) + SourceIndex(2) +3 >Emitted(36, 20) Source(6, 2) + SourceIndex(2) +4 >Emitted(36, 21) Source(6, 2) + SourceIndex(2) +--- +>>> exports.instance1 = new c1(); +1->^^^^ +2 > ^^^^^^^^^^^^^^^^^ +3 > ^^^ +4 > ^^^^ +5 > ^^ +6 > ^^ +7 > ^ +1-> + > + >export var +2 > instance1 +3 > = +4 > new +5 > c1 +6 > () +7 > ; +1->Emitted(37, 5) Source(8, 12) + SourceIndex(2) +2 >Emitted(37, 22) Source(8, 21) + SourceIndex(2) +3 >Emitted(37, 25) Source(8, 24) + SourceIndex(2) +4 >Emitted(37, 29) Source(8, 28) + SourceIndex(2) +5 >Emitted(37, 31) Source(8, 30) + SourceIndex(2) +6 >Emitted(37, 33) Source(8, 32) + SourceIndex(2) +7 >Emitted(37, 34) Source(8, 33) + SourceIndex(2) +--- +>>> function f1() { +1 >^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +1 > + > +1 >Emitted(38, 5) Source(9, 1) + SourceIndex(2) +--- +>>> return exports.instance1; +1->^^^^^^^^ +2 > ^^^^^^ +3 > ^ +4 > ^^^^^^^^^^^^^^^^^ +5 > ^ +1->export function f1() { + > +2 > return +3 > +4 > instance1 +5 > ; +1->Emitted(39, 9) Source(10, 5) + SourceIndex(2) name (f1) +2 >Emitted(39, 15) Source(10, 11) + SourceIndex(2) name (f1) +3 >Emitted(39, 16) Source(10, 12) + SourceIndex(2) name (f1) +4 >Emitted(39, 33) Source(10, 21) + SourceIndex(2) name (f1) +5 >Emitted(39, 34) Source(10, 22) + SourceIndex(2) name (f1) +--- +>>> } +1 >^^^^ +2 > ^ +3 > ^^^^^^^^^^^^^^^^-> +1 > + > +2 > } +1 >Emitted(40, 5) Source(11, 1) + SourceIndex(2) name (f1) +2 >Emitted(40, 6) Source(11, 2) + SourceIndex(2) name (f1) +--- +>>> exports.f1 = f1; +1->^^^^ +2 > ^^^^^^^^^^ +3 > ^^^^^ +4 > ^ +5 > ^^^^^^^-> +1-> +2 > f1 +3 > () { + > return instance1; + > } +4 > +1->Emitted(41, 5) Source(9, 17) + SourceIndex(2) +2 >Emitted(41, 15) Source(9, 19) + SourceIndex(2) +3 >Emitted(41, 20) Source(11, 2) + SourceIndex(2) +4 >Emitted(41, 21) Source(11, 2) + SourceIndex(2) +--- +>>> exports.a2 = m1.m1_c1; +1->^^^^ +2 > ^^^^^^^^^^ +3 > ^^^ +4 > ^^ +5 > ^ +6 > ^^^^^ +7 > ^ +8 > ^-> +1-> + > + >export var +2 > a2 +3 > = +4 > m1 +5 > . +6 > m1_c1 +7 > ; +1->Emitted(42, 5) Source(13, 12) + SourceIndex(2) +2 >Emitted(42, 15) Source(13, 14) + SourceIndex(2) +3 >Emitted(42, 18) Source(13, 17) + SourceIndex(2) +4 >Emitted(42, 20) Source(13, 19) + SourceIndex(2) +5 >Emitted(42, 21) Source(13, 20) + SourceIndex(2) +6 >Emitted(42, 26) Source(13, 25) + SourceIndex(2) +7 >Emitted(42, 27) Source(13, 26) + SourceIndex(2) +--- +>>> exports.a3 = m2.m2_c1; +1->^^^^ +2 > ^^^^^^^^^^ +3 > ^^^ +4 > ^^ +5 > ^ +6 > ^^^^^ +7 > ^ +1-> + >export var +2 > a3 +3 > = +4 > m2 +5 > . +6 > m2_c1 +7 > ; +1->Emitted(43, 5) Source(14, 12) + SourceIndex(2) +2 >Emitted(43, 15) Source(14, 14) + SourceIndex(2) +3 >Emitted(43, 18) Source(14, 17) + SourceIndex(2) +4 >Emitted(43, 20) Source(14, 19) + SourceIndex(2) +5 >Emitted(43, 21) Source(14, 20) + SourceIndex(2) +6 >Emitted(43, 26) Source(14, 25) + SourceIndex(2) +7 >Emitted(43, 27) Source(14, 26) + SourceIndex(2) +--- +>>>}); >>>//# sourceMappingURL=test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderSpecifyOutputFile/node/bin/test.d.ts b/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderSpecifyOutputFile/node/bin/test.d.ts deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderSpecifyOutputFile/node/bin/test.js b/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderSpecifyOutputFile/node/bin/test.js deleted file mode 100644 index 6f3fefb9498..00000000000 --- a/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderSpecifyOutputFile/node/bin/test.js +++ /dev/null @@ -1 +0,0 @@ -//# sourceMappingURL=test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderSpecifyOutputFile/node/bin/test.js.map b/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderSpecifyOutputFile/node/bin/test.js.map index e53f2e0a755..027f9569ebc 100644 --- a/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderSpecifyOutputFile/node/bin/test.js.map +++ b/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderSpecifyOutputFile/node/bin/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"/tests/cases/projects/outputdir_module_multifolder/src/","sources":[],"names":[],"mappings":""} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"/tests/cases/projects/outputdir_module_multifolder/src/","sources":["outputdir_module_multifolder/ref/m1.ts","outputdir_module_multifolder_ref/m2.ts","outputdir_module_multifolder/test.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderSpecifyOutputFile/node/sourceRootAbsolutePathModuleMultifolderSpecifyOutputFile.sourcemap.txt b/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderSpecifyOutputFile/node/sourceRootAbsolutePathModuleMultifolderSpecifyOutputFile.sourcemap.txt index 63e22ab64ba..1c069ce2390 100644 --- a/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderSpecifyOutputFile/node/sourceRootAbsolutePathModuleMultifolderSpecifyOutputFile.sourcemap.txt +++ b/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderSpecifyOutputFile/node/sourceRootAbsolutePathModuleMultifolderSpecifyOutputFile.sourcemap.txt @@ -615,6 +615,6 @@ sourceFile:outputdir_module_multifolder/test.ts JsFile: test.js mapUrl: test.js.map sourceRoot: /tests/cases/projects/outputdir_module_multifolder/src/ -sources: +sources: outputdir_module_multifolder/ref/m1.ts,outputdir_module_multifolder_ref/m2.ts,outputdir_module_multifolder/test.ts =================================================================== >>>//# sourceMappingURL=test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathModuleSimpleSpecifyOutputFile/amd/bin/test.d.ts b/tests/baselines/reference/project/sourceRootAbsolutePathModuleSimpleSpecifyOutputFile/amd/bin/test.d.ts deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathModuleSimpleSpecifyOutputFile/amd/bin/test.js b/tests/baselines/reference/project/sourceRootAbsolutePathModuleSimpleSpecifyOutputFile/amd/bin/test.js deleted file mode 100644 index 6f3fefb9498..00000000000 --- a/tests/baselines/reference/project/sourceRootAbsolutePathModuleSimpleSpecifyOutputFile/amd/bin/test.js +++ /dev/null @@ -1 +0,0 @@ -//# sourceMappingURL=test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathModuleSimpleSpecifyOutputFile/amd/bin/test.js.map b/tests/baselines/reference/project/sourceRootAbsolutePathModuleSimpleSpecifyOutputFile/amd/bin/test.js.map index 42e5a82e74b..a910369c3e4 100644 --- a/tests/baselines/reference/project/sourceRootAbsolutePathModuleSimpleSpecifyOutputFile/amd/bin/test.js.map +++ b/tests/baselines/reference/project/sourceRootAbsolutePathModuleSimpleSpecifyOutputFile/amd/bin/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"/tests/cases/projects/outputdir_module_simple/src/","sources":[],"names":[],"mappings":""} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"/tests/cases/projects/outputdir_module_simple/src/","sources":["m1.ts","test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","c1","c1.constructor","f1"],"mappings":";IAAW,aAAK,GAAG,EAAE,CAAC;IACtB;QAAAA;QAEAC,CAACA;QAADD,YAACA;IAADA,CAACA,AAFD,IAEC;IAFY,aAAK,QAEjB,CAAA;IAEU,oBAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACIE,MAAMA,CAACA,oBAAYA,CAACA;IACxBA,CAACA;IAFe,aAAK,QAEpB,CAAA;;;ICPU,UAAE,GAAG,EAAE,CAAC;IACnB;QAAAC;QAEAC,CAACA;QAADD,SAACA;IAADA,CAACA,AAFD,IAEC;IAFY,UAAE,KAEd,CAAA;IAEU,iBAAS,GAAG,IAAI,EAAE,EAAE,CAAC;IAChC;QACIE,MAAMA,CAACA,iBAASA,CAACA;IACrBA,CAACA;IAFe,UAAE,KAEjB,CAAA;IAEU,UAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathModuleSimpleSpecifyOutputFile/amd/sourceRootAbsolutePathModuleSimpleSpecifyOutputFile.sourcemap.txt b/tests/baselines/reference/project/sourceRootAbsolutePathModuleSimpleSpecifyOutputFile/amd/sourceRootAbsolutePathModuleSimpleSpecifyOutputFile.sourcemap.txt index 0fc6cd6eb2a..fab0c65ae8e 100644 --- a/tests/baselines/reference/project/sourceRootAbsolutePathModuleSimpleSpecifyOutputFile/amd/sourceRootAbsolutePathModuleSimpleSpecifyOutputFile.sourcemap.txt +++ b/tests/baselines/reference/project/sourceRootAbsolutePathModuleSimpleSpecifyOutputFile/amd/sourceRootAbsolutePathModuleSimpleSpecifyOutputFile.sourcemap.txt @@ -373,6 +373,365 @@ sourceFile:test.ts JsFile: test.js mapUrl: test.js.map sourceRoot: /tests/cases/projects/outputdir_module_simple/src/ -sources: +sources: m1.ts,test.ts =================================================================== +------------------------------------------------------------------- +emittedFile:bin/test.js +sourceFile:m1.ts +------------------------------------------------------------------- +>>>define("m1", ["require", "exports"], function (require, exports) { +>>> exports.m1_a1 = 10; +1 >^^^^ +2 > ^^^^^^^^^^^^^ +3 > ^^^ +4 > ^^ +5 > ^ +6 > ^^^^^^^^-> +1 >export var +2 > m1_a1 +3 > = +4 > 10 +5 > ; +1 >Emitted(2, 5) Source(1, 12) + SourceIndex(0) +2 >Emitted(2, 18) Source(1, 17) + SourceIndex(0) +3 >Emitted(2, 21) Source(1, 20) + SourceIndex(0) +4 >Emitted(2, 23) Source(1, 22) + SourceIndex(0) +5 >Emitted(2, 24) Source(1, 23) + SourceIndex(0) +--- +>>> var m1_c1 = (function () { +1->^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^^^^-> +1-> + > +1->Emitted(3, 5) Source(2, 1) + SourceIndex(0) +--- +>>> function m1_c1() { +1->^^^^^^^^ +2 > ^^-> +1-> +1->Emitted(4, 9) Source(2, 1) + SourceIndex(0) name (m1_c1) +--- +>>> } +1->^^^^^^^^ +2 > ^ +3 > ^^^^^^^^^^^^^-> +1->export class m1_c1 { + > public m1_c1_p1: number; + > +2 > } +1->Emitted(5, 9) Source(4, 1) + SourceIndex(0) name (m1_c1.constructor) +2 >Emitted(5, 10) Source(4, 2) + SourceIndex(0) name (m1_c1.constructor) +--- +>>> return m1_c1; +1->^^^^^^^^ +2 > ^^^^^^^^^^^^ +1-> +2 > } +1->Emitted(6, 9) Source(4, 1) + SourceIndex(0) name (m1_c1) +2 >Emitted(6, 21) Source(4, 2) + SourceIndex(0) name (m1_c1) +--- +>>> })(); +1 >^^^^ +2 > ^ +3 > +4 > ^^^^ +5 > ^^^^^^^^^^^^^^^^^^-> +1 > +2 > } +3 > +4 > export class m1_c1 { + > public m1_c1_p1: number; + > } +1 >Emitted(7, 5) Source(4, 1) + SourceIndex(0) name (m1_c1) +2 >Emitted(7, 6) Source(4, 2) + SourceIndex(0) name (m1_c1) +3 >Emitted(7, 6) Source(2, 1) + SourceIndex(0) +4 >Emitted(7, 10) Source(4, 2) + SourceIndex(0) +--- +>>> exports.m1_c1 = m1_c1; +1->^^^^ +2 > ^^^^^^^^^^^^^ +3 > ^^^^^^^^ +4 > ^ +5 > ^^^^^^^^^^^^^^-> +1-> +2 > m1_c1 +3 > { + > public m1_c1_p1: number; + > } +4 > +1->Emitted(8, 5) Source(2, 14) + SourceIndex(0) +2 >Emitted(8, 18) Source(2, 19) + SourceIndex(0) +3 >Emitted(8, 26) Source(4, 2) + SourceIndex(0) +4 >Emitted(8, 27) Source(4, 2) + SourceIndex(0) +--- +>>> exports.m1_instance1 = new m1_c1(); +1->^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^ +3 > ^^^ +4 > ^^^^ +5 > ^^^^^ +6 > ^^ +7 > ^ +1-> + > + >export var +2 > m1_instance1 +3 > = +4 > new +5 > m1_c1 +6 > () +7 > ; +1->Emitted(9, 5) Source(6, 12) + SourceIndex(0) +2 >Emitted(9, 25) Source(6, 24) + SourceIndex(0) +3 >Emitted(9, 28) Source(6, 27) + SourceIndex(0) +4 >Emitted(9, 32) Source(6, 31) + SourceIndex(0) +5 >Emitted(9, 37) Source(6, 36) + SourceIndex(0) +6 >Emitted(9, 39) Source(6, 38) + SourceIndex(0) +7 >Emitted(9, 40) Source(6, 39) + SourceIndex(0) +--- +>>> function m1_f1() { +1 >^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +1 > + > +1 >Emitted(10, 5) Source(7, 1) + SourceIndex(0) +--- +>>> return exports.m1_instance1; +1->^^^^^^^^ +2 > ^^^^^^ +3 > ^ +4 > ^^^^^^^^^^^^^^^^^^^^ +5 > ^ +1->export function m1_f1() { + > +2 > return +3 > +4 > m1_instance1 +5 > ; +1->Emitted(11, 9) Source(8, 5) + SourceIndex(0) name (m1_f1) +2 >Emitted(11, 15) Source(8, 11) + SourceIndex(0) name (m1_f1) +3 >Emitted(11, 16) Source(8, 12) + SourceIndex(0) name (m1_f1) +4 >Emitted(11, 36) Source(8, 24) + SourceIndex(0) name (m1_f1) +5 >Emitted(11, 37) Source(8, 25) + SourceIndex(0) name (m1_f1) +--- +>>> } +1 >^^^^ +2 > ^ +3 > ^^^^^^^^^^^^^^^^^^^^^^-> +1 > + > +2 > } +1 >Emitted(12, 5) Source(9, 1) + SourceIndex(0) name (m1_f1) +2 >Emitted(12, 6) Source(9, 2) + SourceIndex(0) name (m1_f1) +--- +>>> exports.m1_f1 = m1_f1; +1->^^^^ +2 > ^^^^^^^^^^^^^ +3 > ^^^^^^^^ +4 > ^ +1-> +2 > m1_f1 +3 > () { + > return m1_instance1; + > } +4 > +1->Emitted(13, 5) Source(7, 17) + SourceIndex(0) +2 >Emitted(13, 18) Source(7, 22) + SourceIndex(0) +3 >Emitted(13, 26) Source(9, 2) + SourceIndex(0) +4 >Emitted(13, 27) Source(9, 2) + SourceIndex(0) +--- +------------------------------------------------------------------- +emittedFile:bin/test.js +sourceFile:test.ts +------------------------------------------------------------------- +>>>}); +>>>define("test", ["require", "exports", "m1"], function (require, exports, m1) { +>>> exports.a1 = 10; +1 >^^^^ +2 > ^^^^^^^^^^ +3 > ^^^ +4 > ^^ +5 > ^ +6 > ^^^^^^^^-> +1 >import m1 = require("m1"); + >export var +2 > a1 +3 > = +4 > 10 +5 > ; +1 >Emitted(16, 5) Source(2, 12) + SourceIndex(1) +2 >Emitted(16, 15) Source(2, 14) + SourceIndex(1) +3 >Emitted(16, 18) Source(2, 17) + SourceIndex(1) +4 >Emitted(16, 20) Source(2, 19) + SourceIndex(1) +5 >Emitted(16, 21) Source(2, 20) + SourceIndex(1) +--- +>>> var c1 = (function () { +1->^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^-> +1-> + > +1->Emitted(17, 5) Source(3, 1) + SourceIndex(1) +--- +>>> function c1() { +1->^^^^^^^^ +2 > ^^-> +1-> +1->Emitted(18, 9) Source(3, 1) + SourceIndex(1) name (c1) +--- +>>> } +1->^^^^^^^^ +2 > ^ +3 > ^^^^^^^^^^-> +1->export class c1 { + > public p1: number; + > +2 > } +1->Emitted(19, 9) Source(5, 1) + SourceIndex(1) name (c1.constructor) +2 >Emitted(19, 10) Source(5, 2) + SourceIndex(1) name (c1.constructor) +--- +>>> return c1; +1->^^^^^^^^ +2 > ^^^^^^^^^ +1-> +2 > } +1->Emitted(20, 9) Source(5, 1) + SourceIndex(1) name (c1) +2 >Emitted(20, 18) Source(5, 2) + SourceIndex(1) name (c1) +--- +>>> })(); +1 >^^^^ +2 > ^ +3 > +4 > ^^^^ +5 > ^^^^^^^^^^^^-> +1 > +2 > } +3 > +4 > export class c1 { + > public p1: number; + > } +1 >Emitted(21, 5) Source(5, 1) + SourceIndex(1) name (c1) +2 >Emitted(21, 6) Source(5, 2) + SourceIndex(1) name (c1) +3 >Emitted(21, 6) Source(3, 1) + SourceIndex(1) +4 >Emitted(21, 10) Source(5, 2) + SourceIndex(1) +--- +>>> exports.c1 = c1; +1->^^^^ +2 > ^^^^^^^^^^ +3 > ^^^^^ +4 > ^ +5 > ^^^^^^^^^^^^^^-> +1-> +2 > c1 +3 > { + > public p1: number; + > } +4 > +1->Emitted(22, 5) Source(3, 14) + SourceIndex(1) +2 >Emitted(22, 15) Source(3, 16) + SourceIndex(1) +3 >Emitted(22, 20) Source(5, 2) + SourceIndex(1) +4 >Emitted(22, 21) Source(5, 2) + SourceIndex(1) +--- +>>> exports.instance1 = new c1(); +1->^^^^ +2 > ^^^^^^^^^^^^^^^^^ +3 > ^^^ +4 > ^^^^ +5 > ^^ +6 > ^^ +7 > ^ +1-> + > + >export var +2 > instance1 +3 > = +4 > new +5 > c1 +6 > () +7 > ; +1->Emitted(23, 5) Source(7, 12) + SourceIndex(1) +2 >Emitted(23, 22) Source(7, 21) + SourceIndex(1) +3 >Emitted(23, 25) Source(7, 24) + SourceIndex(1) +4 >Emitted(23, 29) Source(7, 28) + SourceIndex(1) +5 >Emitted(23, 31) Source(7, 30) + SourceIndex(1) +6 >Emitted(23, 33) Source(7, 32) + SourceIndex(1) +7 >Emitted(23, 34) Source(7, 33) + SourceIndex(1) +--- +>>> function f1() { +1 >^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +1 > + > +1 >Emitted(24, 5) Source(8, 1) + SourceIndex(1) +--- +>>> return exports.instance1; +1->^^^^^^^^ +2 > ^^^^^^ +3 > ^ +4 > ^^^^^^^^^^^^^^^^^ +5 > ^ +1->export function f1() { + > +2 > return +3 > +4 > instance1 +5 > ; +1->Emitted(25, 9) Source(9, 5) + SourceIndex(1) name (f1) +2 >Emitted(25, 15) Source(9, 11) + SourceIndex(1) name (f1) +3 >Emitted(25, 16) Source(9, 12) + SourceIndex(1) name (f1) +4 >Emitted(25, 33) Source(9, 21) + SourceIndex(1) name (f1) +5 >Emitted(25, 34) Source(9, 22) + SourceIndex(1) name (f1) +--- +>>> } +1 >^^^^ +2 > ^ +3 > ^^^^^^^^^^^^^^^^-> +1 > + > +2 > } +1 >Emitted(26, 5) Source(10, 1) + SourceIndex(1) name (f1) +2 >Emitted(26, 6) Source(10, 2) + SourceIndex(1) name (f1) +--- +>>> exports.f1 = f1; +1->^^^^ +2 > ^^^^^^^^^^ +3 > ^^^^^ +4 > ^ +5 > ^^^^^^^-> +1-> +2 > f1 +3 > () { + > return instance1; + > } +4 > +1->Emitted(27, 5) Source(8, 17) + SourceIndex(1) +2 >Emitted(27, 15) Source(8, 19) + SourceIndex(1) +3 >Emitted(27, 20) Source(10, 2) + SourceIndex(1) +4 >Emitted(27, 21) Source(10, 2) + SourceIndex(1) +--- +>>> exports.a2 = m1.m1_c1; +1->^^^^ +2 > ^^^^^^^^^^ +3 > ^^^ +4 > ^^ +5 > ^ +6 > ^^^^^ +7 > ^ +1-> + > + >export var +2 > a2 +3 > = +4 > m1 +5 > . +6 > m1_c1 +7 > ; +1->Emitted(28, 5) Source(12, 12) + SourceIndex(1) +2 >Emitted(28, 15) Source(12, 14) + SourceIndex(1) +3 >Emitted(28, 18) Source(12, 17) + SourceIndex(1) +4 >Emitted(28, 20) Source(12, 19) + SourceIndex(1) +5 >Emitted(28, 21) Source(12, 20) + SourceIndex(1) +6 >Emitted(28, 26) Source(12, 25) + SourceIndex(1) +7 >Emitted(28, 27) Source(12, 26) + SourceIndex(1) +--- +>>>}); >>>//# sourceMappingURL=test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathModuleSimpleSpecifyOutputFile/node/bin/test.d.ts b/tests/baselines/reference/project/sourceRootAbsolutePathModuleSimpleSpecifyOutputFile/node/bin/test.d.ts deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathModuleSimpleSpecifyOutputFile/node/bin/test.js b/tests/baselines/reference/project/sourceRootAbsolutePathModuleSimpleSpecifyOutputFile/node/bin/test.js deleted file mode 100644 index 6f3fefb9498..00000000000 --- a/tests/baselines/reference/project/sourceRootAbsolutePathModuleSimpleSpecifyOutputFile/node/bin/test.js +++ /dev/null @@ -1 +0,0 @@ -//# sourceMappingURL=test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathModuleSimpleSpecifyOutputFile/node/bin/test.js.map b/tests/baselines/reference/project/sourceRootAbsolutePathModuleSimpleSpecifyOutputFile/node/bin/test.js.map index 42e5a82e74b..487d57bd2ae 100644 --- a/tests/baselines/reference/project/sourceRootAbsolutePathModuleSimpleSpecifyOutputFile/node/bin/test.js.map +++ b/tests/baselines/reference/project/sourceRootAbsolutePathModuleSimpleSpecifyOutputFile/node/bin/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"/tests/cases/projects/outputdir_module_simple/src/","sources":[],"names":[],"mappings":""} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"/tests/cases/projects/outputdir_module_simple/src/","sources":["m1.ts","test.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathModuleSimpleSpecifyOutputFile/node/sourceRootAbsolutePathModuleSimpleSpecifyOutputFile.sourcemap.txt b/tests/baselines/reference/project/sourceRootAbsolutePathModuleSimpleSpecifyOutputFile/node/sourceRootAbsolutePathModuleSimpleSpecifyOutputFile.sourcemap.txt index 08491d50151..2da5935b483 100644 --- a/tests/baselines/reference/project/sourceRootAbsolutePathModuleSimpleSpecifyOutputFile/node/sourceRootAbsolutePathModuleSimpleSpecifyOutputFile.sourcemap.txt +++ b/tests/baselines/reference/project/sourceRootAbsolutePathModuleSimpleSpecifyOutputFile/node/sourceRootAbsolutePathModuleSimpleSpecifyOutputFile.sourcemap.txt @@ -394,6 +394,6 @@ sourceFile:test.ts JsFile: test.js mapUrl: test.js.map sourceRoot: /tests/cases/projects/outputdir_module_simple/src/ -sources: +sources: m1.ts,test.ts =================================================================== >>>//# sourceMappingURL=test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathModuleSubfolderSpecifyOutputFile/amd/bin/test.d.ts b/tests/baselines/reference/project/sourceRootAbsolutePathModuleSubfolderSpecifyOutputFile/amd/bin/test.d.ts deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathModuleSubfolderSpecifyOutputFile/amd/bin/test.js b/tests/baselines/reference/project/sourceRootAbsolutePathModuleSubfolderSpecifyOutputFile/amd/bin/test.js deleted file mode 100644 index 6f3fefb9498..00000000000 --- a/tests/baselines/reference/project/sourceRootAbsolutePathModuleSubfolderSpecifyOutputFile/amd/bin/test.js +++ /dev/null @@ -1 +0,0 @@ -//# sourceMappingURL=test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathModuleSubfolderSpecifyOutputFile/amd/bin/test.js.map b/tests/baselines/reference/project/sourceRootAbsolutePathModuleSubfolderSpecifyOutputFile/amd/bin/test.js.map index 279042a1a0f..30bac946d14 100644 --- a/tests/baselines/reference/project/sourceRootAbsolutePathModuleSubfolderSpecifyOutputFile/amd/bin/test.js.map +++ b/tests/baselines/reference/project/sourceRootAbsolutePathModuleSubfolderSpecifyOutputFile/amd/bin/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"/tests/cases/projects/outputdir_module_subfolder/src/","sources":[],"names":[],"mappings":""} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"/tests/cases/projects/outputdir_module_subfolder/src/","sources":["ref/m1.ts","test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","c1","c1.constructor","f1"],"mappings":";IAAW,aAAK,GAAG,EAAE,CAAC;IACtB;QAAAA;QAEAC,CAACA;QAADD,YAACA;IAADA,CAACA,AAFD,IAEC;IAFY,aAAK,QAEjB,CAAA;IAEU,oBAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACIE,MAAMA,CAACA,oBAAYA,CAACA;IACxBA,CAACA;IAFe,aAAK,QAEpB,CAAA;;;ICPU,UAAE,GAAG,EAAE,CAAC;IACnB;QAAAC;QAEAC,CAACA;QAADD,SAACA;IAADA,CAACA,AAFD,IAEC;IAFY,UAAE,KAEd,CAAA;IAEU,iBAAS,GAAG,IAAI,EAAE,EAAE,CAAC;IAChC;QACIE,MAAMA,CAACA,iBAASA,CAACA;IACrBA,CAACA;IAFe,UAAE,KAEjB,CAAA;IAEU,UAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathModuleSubfolderSpecifyOutputFile/amd/sourceRootAbsolutePathModuleSubfolderSpecifyOutputFile.sourcemap.txt b/tests/baselines/reference/project/sourceRootAbsolutePathModuleSubfolderSpecifyOutputFile/amd/sourceRootAbsolutePathModuleSubfolderSpecifyOutputFile.sourcemap.txt index 5e87f2ef555..15269d7fb80 100644 --- a/tests/baselines/reference/project/sourceRootAbsolutePathModuleSubfolderSpecifyOutputFile/amd/sourceRootAbsolutePathModuleSubfolderSpecifyOutputFile.sourcemap.txt +++ b/tests/baselines/reference/project/sourceRootAbsolutePathModuleSubfolderSpecifyOutputFile/amd/sourceRootAbsolutePathModuleSubfolderSpecifyOutputFile.sourcemap.txt @@ -373,6 +373,365 @@ sourceFile:test.ts JsFile: test.js mapUrl: test.js.map sourceRoot: /tests/cases/projects/outputdir_module_subfolder/src/ -sources: +sources: ref/m1.ts,test.ts =================================================================== +------------------------------------------------------------------- +emittedFile:bin/test.js +sourceFile:ref/m1.ts +------------------------------------------------------------------- +>>>define("ref/m1", ["require", "exports"], function (require, exports) { +>>> exports.m1_a1 = 10; +1 >^^^^ +2 > ^^^^^^^^^^^^^ +3 > ^^^ +4 > ^^ +5 > ^ +6 > ^^^^^^^^-> +1 >export var +2 > m1_a1 +3 > = +4 > 10 +5 > ; +1 >Emitted(2, 5) Source(1, 12) + SourceIndex(0) +2 >Emitted(2, 18) Source(1, 17) + SourceIndex(0) +3 >Emitted(2, 21) Source(1, 20) + SourceIndex(0) +4 >Emitted(2, 23) Source(1, 22) + SourceIndex(0) +5 >Emitted(2, 24) Source(1, 23) + SourceIndex(0) +--- +>>> var m1_c1 = (function () { +1->^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^^^^-> +1-> + > +1->Emitted(3, 5) Source(2, 1) + SourceIndex(0) +--- +>>> function m1_c1() { +1->^^^^^^^^ +2 > ^^-> +1-> +1->Emitted(4, 9) Source(2, 1) + SourceIndex(0) name (m1_c1) +--- +>>> } +1->^^^^^^^^ +2 > ^ +3 > ^^^^^^^^^^^^^-> +1->export class m1_c1 { + > public m1_c1_p1: number; + > +2 > } +1->Emitted(5, 9) Source(4, 1) + SourceIndex(0) name (m1_c1.constructor) +2 >Emitted(5, 10) Source(4, 2) + SourceIndex(0) name (m1_c1.constructor) +--- +>>> return m1_c1; +1->^^^^^^^^ +2 > ^^^^^^^^^^^^ +1-> +2 > } +1->Emitted(6, 9) Source(4, 1) + SourceIndex(0) name (m1_c1) +2 >Emitted(6, 21) Source(4, 2) + SourceIndex(0) name (m1_c1) +--- +>>> })(); +1 >^^^^ +2 > ^ +3 > +4 > ^^^^ +5 > ^^^^^^^^^^^^^^^^^^-> +1 > +2 > } +3 > +4 > export class m1_c1 { + > public m1_c1_p1: number; + > } +1 >Emitted(7, 5) Source(4, 1) + SourceIndex(0) name (m1_c1) +2 >Emitted(7, 6) Source(4, 2) + SourceIndex(0) name (m1_c1) +3 >Emitted(7, 6) Source(2, 1) + SourceIndex(0) +4 >Emitted(7, 10) Source(4, 2) + SourceIndex(0) +--- +>>> exports.m1_c1 = m1_c1; +1->^^^^ +2 > ^^^^^^^^^^^^^ +3 > ^^^^^^^^ +4 > ^ +5 > ^^^^^^^^^^^^^^-> +1-> +2 > m1_c1 +3 > { + > public m1_c1_p1: number; + > } +4 > +1->Emitted(8, 5) Source(2, 14) + SourceIndex(0) +2 >Emitted(8, 18) Source(2, 19) + SourceIndex(0) +3 >Emitted(8, 26) Source(4, 2) + SourceIndex(0) +4 >Emitted(8, 27) Source(4, 2) + SourceIndex(0) +--- +>>> exports.m1_instance1 = new m1_c1(); +1->^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^ +3 > ^^^ +4 > ^^^^ +5 > ^^^^^ +6 > ^^ +7 > ^ +1-> + > + >export var +2 > m1_instance1 +3 > = +4 > new +5 > m1_c1 +6 > () +7 > ; +1->Emitted(9, 5) Source(6, 12) + SourceIndex(0) +2 >Emitted(9, 25) Source(6, 24) + SourceIndex(0) +3 >Emitted(9, 28) Source(6, 27) + SourceIndex(0) +4 >Emitted(9, 32) Source(6, 31) + SourceIndex(0) +5 >Emitted(9, 37) Source(6, 36) + SourceIndex(0) +6 >Emitted(9, 39) Source(6, 38) + SourceIndex(0) +7 >Emitted(9, 40) Source(6, 39) + SourceIndex(0) +--- +>>> function m1_f1() { +1 >^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +1 > + > +1 >Emitted(10, 5) Source(7, 1) + SourceIndex(0) +--- +>>> return exports.m1_instance1; +1->^^^^^^^^ +2 > ^^^^^^ +3 > ^ +4 > ^^^^^^^^^^^^^^^^^^^^ +5 > ^ +1->export function m1_f1() { + > +2 > return +3 > +4 > m1_instance1 +5 > ; +1->Emitted(11, 9) Source(8, 5) + SourceIndex(0) name (m1_f1) +2 >Emitted(11, 15) Source(8, 11) + SourceIndex(0) name (m1_f1) +3 >Emitted(11, 16) Source(8, 12) + SourceIndex(0) name (m1_f1) +4 >Emitted(11, 36) Source(8, 24) + SourceIndex(0) name (m1_f1) +5 >Emitted(11, 37) Source(8, 25) + SourceIndex(0) name (m1_f1) +--- +>>> } +1 >^^^^ +2 > ^ +3 > ^^^^^^^^^^^^^^^^^^^^^^-> +1 > + > +2 > } +1 >Emitted(12, 5) Source(9, 1) + SourceIndex(0) name (m1_f1) +2 >Emitted(12, 6) Source(9, 2) + SourceIndex(0) name (m1_f1) +--- +>>> exports.m1_f1 = m1_f1; +1->^^^^ +2 > ^^^^^^^^^^^^^ +3 > ^^^^^^^^ +4 > ^ +1-> +2 > m1_f1 +3 > () { + > return m1_instance1; + > } +4 > +1->Emitted(13, 5) Source(7, 17) + SourceIndex(0) +2 >Emitted(13, 18) Source(7, 22) + SourceIndex(0) +3 >Emitted(13, 26) Source(9, 2) + SourceIndex(0) +4 >Emitted(13, 27) Source(9, 2) + SourceIndex(0) +--- +------------------------------------------------------------------- +emittedFile:bin/test.js +sourceFile:test.ts +------------------------------------------------------------------- +>>>}); +>>>define("test", ["require", "exports", "ref/m1"], function (require, exports, m1) { +>>> exports.a1 = 10; +1 >^^^^ +2 > ^^^^^^^^^^ +3 > ^^^ +4 > ^^ +5 > ^ +6 > ^^^^^^^^-> +1 >import m1 = require("ref/m1"); + >export var +2 > a1 +3 > = +4 > 10 +5 > ; +1 >Emitted(16, 5) Source(2, 12) + SourceIndex(1) +2 >Emitted(16, 15) Source(2, 14) + SourceIndex(1) +3 >Emitted(16, 18) Source(2, 17) + SourceIndex(1) +4 >Emitted(16, 20) Source(2, 19) + SourceIndex(1) +5 >Emitted(16, 21) Source(2, 20) + SourceIndex(1) +--- +>>> var c1 = (function () { +1->^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^-> +1-> + > +1->Emitted(17, 5) Source(3, 1) + SourceIndex(1) +--- +>>> function c1() { +1->^^^^^^^^ +2 > ^^-> +1-> +1->Emitted(18, 9) Source(3, 1) + SourceIndex(1) name (c1) +--- +>>> } +1->^^^^^^^^ +2 > ^ +3 > ^^^^^^^^^^-> +1->export class c1 { + > public p1: number; + > +2 > } +1->Emitted(19, 9) Source(5, 1) + SourceIndex(1) name (c1.constructor) +2 >Emitted(19, 10) Source(5, 2) + SourceIndex(1) name (c1.constructor) +--- +>>> return c1; +1->^^^^^^^^ +2 > ^^^^^^^^^ +1-> +2 > } +1->Emitted(20, 9) Source(5, 1) + SourceIndex(1) name (c1) +2 >Emitted(20, 18) Source(5, 2) + SourceIndex(1) name (c1) +--- +>>> })(); +1 >^^^^ +2 > ^ +3 > +4 > ^^^^ +5 > ^^^^^^^^^^^^-> +1 > +2 > } +3 > +4 > export class c1 { + > public p1: number; + > } +1 >Emitted(21, 5) Source(5, 1) + SourceIndex(1) name (c1) +2 >Emitted(21, 6) Source(5, 2) + SourceIndex(1) name (c1) +3 >Emitted(21, 6) Source(3, 1) + SourceIndex(1) +4 >Emitted(21, 10) Source(5, 2) + SourceIndex(1) +--- +>>> exports.c1 = c1; +1->^^^^ +2 > ^^^^^^^^^^ +3 > ^^^^^ +4 > ^ +5 > ^^^^^^^^^^^^^^-> +1-> +2 > c1 +3 > { + > public p1: number; + > } +4 > +1->Emitted(22, 5) Source(3, 14) + SourceIndex(1) +2 >Emitted(22, 15) Source(3, 16) + SourceIndex(1) +3 >Emitted(22, 20) Source(5, 2) + SourceIndex(1) +4 >Emitted(22, 21) Source(5, 2) + SourceIndex(1) +--- +>>> exports.instance1 = new c1(); +1->^^^^ +2 > ^^^^^^^^^^^^^^^^^ +3 > ^^^ +4 > ^^^^ +5 > ^^ +6 > ^^ +7 > ^ +1-> + > + >export var +2 > instance1 +3 > = +4 > new +5 > c1 +6 > () +7 > ; +1->Emitted(23, 5) Source(7, 12) + SourceIndex(1) +2 >Emitted(23, 22) Source(7, 21) + SourceIndex(1) +3 >Emitted(23, 25) Source(7, 24) + SourceIndex(1) +4 >Emitted(23, 29) Source(7, 28) + SourceIndex(1) +5 >Emitted(23, 31) Source(7, 30) + SourceIndex(1) +6 >Emitted(23, 33) Source(7, 32) + SourceIndex(1) +7 >Emitted(23, 34) Source(7, 33) + SourceIndex(1) +--- +>>> function f1() { +1 >^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +1 > + > +1 >Emitted(24, 5) Source(8, 1) + SourceIndex(1) +--- +>>> return exports.instance1; +1->^^^^^^^^ +2 > ^^^^^^ +3 > ^ +4 > ^^^^^^^^^^^^^^^^^ +5 > ^ +1->export function f1() { + > +2 > return +3 > +4 > instance1 +5 > ; +1->Emitted(25, 9) Source(9, 5) + SourceIndex(1) name (f1) +2 >Emitted(25, 15) Source(9, 11) + SourceIndex(1) name (f1) +3 >Emitted(25, 16) Source(9, 12) + SourceIndex(1) name (f1) +4 >Emitted(25, 33) Source(9, 21) + SourceIndex(1) name (f1) +5 >Emitted(25, 34) Source(9, 22) + SourceIndex(1) name (f1) +--- +>>> } +1 >^^^^ +2 > ^ +3 > ^^^^^^^^^^^^^^^^-> +1 > + > +2 > } +1 >Emitted(26, 5) Source(10, 1) + SourceIndex(1) name (f1) +2 >Emitted(26, 6) Source(10, 2) + SourceIndex(1) name (f1) +--- +>>> exports.f1 = f1; +1->^^^^ +2 > ^^^^^^^^^^ +3 > ^^^^^ +4 > ^ +5 > ^^^^^^^-> +1-> +2 > f1 +3 > () { + > return instance1; + > } +4 > +1->Emitted(27, 5) Source(8, 17) + SourceIndex(1) +2 >Emitted(27, 15) Source(8, 19) + SourceIndex(1) +3 >Emitted(27, 20) Source(10, 2) + SourceIndex(1) +4 >Emitted(27, 21) Source(10, 2) + SourceIndex(1) +--- +>>> exports.a2 = m1.m1_c1; +1->^^^^ +2 > ^^^^^^^^^^ +3 > ^^^ +4 > ^^ +5 > ^ +6 > ^^^^^ +7 > ^ +1-> + > + >export var +2 > a2 +3 > = +4 > m1 +5 > . +6 > m1_c1 +7 > ; +1->Emitted(28, 5) Source(12, 12) + SourceIndex(1) +2 >Emitted(28, 15) Source(12, 14) + SourceIndex(1) +3 >Emitted(28, 18) Source(12, 17) + SourceIndex(1) +4 >Emitted(28, 20) Source(12, 19) + SourceIndex(1) +5 >Emitted(28, 21) Source(12, 20) + SourceIndex(1) +6 >Emitted(28, 26) Source(12, 25) + SourceIndex(1) +7 >Emitted(28, 27) Source(12, 26) + SourceIndex(1) +--- +>>>}); >>>//# sourceMappingURL=test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathModuleSubfolderSpecifyOutputFile/node/bin/test.d.ts b/tests/baselines/reference/project/sourceRootAbsolutePathModuleSubfolderSpecifyOutputFile/node/bin/test.d.ts deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathModuleSubfolderSpecifyOutputFile/node/bin/test.js b/tests/baselines/reference/project/sourceRootAbsolutePathModuleSubfolderSpecifyOutputFile/node/bin/test.js deleted file mode 100644 index 6f3fefb9498..00000000000 --- a/tests/baselines/reference/project/sourceRootAbsolutePathModuleSubfolderSpecifyOutputFile/node/bin/test.js +++ /dev/null @@ -1 +0,0 @@ -//# sourceMappingURL=test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathModuleSubfolderSpecifyOutputFile/node/bin/test.js.map b/tests/baselines/reference/project/sourceRootAbsolutePathModuleSubfolderSpecifyOutputFile/node/bin/test.js.map index 279042a1a0f..622f2c91c95 100644 --- a/tests/baselines/reference/project/sourceRootAbsolutePathModuleSubfolderSpecifyOutputFile/node/bin/test.js.map +++ b/tests/baselines/reference/project/sourceRootAbsolutePathModuleSubfolderSpecifyOutputFile/node/bin/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"/tests/cases/projects/outputdir_module_subfolder/src/","sources":[],"names":[],"mappings":""} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"/tests/cases/projects/outputdir_module_subfolder/src/","sources":["ref/m1.ts","test.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathModuleSubfolderSpecifyOutputFile/node/sourceRootAbsolutePathModuleSubfolderSpecifyOutputFile.sourcemap.txt b/tests/baselines/reference/project/sourceRootAbsolutePathModuleSubfolderSpecifyOutputFile/node/sourceRootAbsolutePathModuleSubfolderSpecifyOutputFile.sourcemap.txt index 67fc9030f41..9bcf1436d51 100644 --- a/tests/baselines/reference/project/sourceRootAbsolutePathModuleSubfolderSpecifyOutputFile/node/sourceRootAbsolutePathModuleSubfolderSpecifyOutputFile.sourcemap.txt +++ b/tests/baselines/reference/project/sourceRootAbsolutePathModuleSubfolderSpecifyOutputFile/node/sourceRootAbsolutePathModuleSubfolderSpecifyOutputFile.sourcemap.txt @@ -394,6 +394,6 @@ sourceFile:test.ts JsFile: test.js mapUrl: test.js.map sourceRoot: /tests/cases/projects/outputdir_module_subfolder/src/ -sources: +sources: ref/m1.ts,test.ts =================================================================== >>>//# sourceMappingURL=test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFile/amd/bin/test.d.ts b/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFile/amd/bin/test.d.ts deleted file mode 100644 index d61b4c3b876..00000000000 --- a/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFile/amd/bin/test.d.ts +++ /dev/null @@ -1,13 +0,0 @@ -/// -declare var m1_a1: number; -declare class m1_c1 { - m1_c1_p1: number; -} -declare var m1_instance1: m1_c1; -declare function m1_f1(): m1_c1; -declare var a1: number; -declare class c1 { - p1: number; -} -declare var instance1: c1; -declare function f1(): c1; diff --git a/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFile/amd/bin/test.js b/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFile/amd/bin/test.js deleted file mode 100644 index 5af28cf8560..00000000000 --- a/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFile/amd/bin/test.js +++ /dev/null @@ -1,23 +0,0 @@ -var m1_a1 = 10; -var m1_c1 = (function () { - function m1_c1() { - } - return m1_c1; -})(); -var m1_instance1 = new m1_c1(); -function m1_f1() { - return m1_instance1; -} -/// -/// -var a1 = 10; -var c1 = (function () { - function c1() { - } - return c1; -})(); -var instance1 = new c1(); -function f1() { - return instance1; -} -//# sourceMappingURL=test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFile/amd/bin/test.js.map b/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFile/amd/bin/test.js.map index 86afcf32e25..62f932a571e 100644 --- a/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFile/amd/bin/test.js.map +++ b/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFile/amd/bin/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"../src/","sources":["ref/m1.ts","test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACRD,iCAAiC;AACjC,iCAAiC;AACjC,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"../src/","sources":["ref/m1.ts","ref/m2.ts","test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","m2_c1","m2_c1.constructor","m2_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;;ICRU,aAAK,GAAG,EAAE,CAAC;IACtB;QAAAC;QAEAC,CAACA;QAADD,YAACA;IAADA,CAACA,AAFD,IAEC;IAFY,aAAK,QAEjB,CAAA;IAEU,oBAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACIE,MAAMA,CAACA,oBAAYA,CAACA;IACxBA,CAACA;IAFe,aAAK,QAEpB,CAAA;;ACRD,iCAAiC;AACjC,iCAAiC;AACjC,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFile/amd/sourceRootRelativePathMixedSubfolderSpecifyOutputFile.sourcemap.txt b/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFile/amd/sourceRootRelativePathMixedSubfolderSpecifyOutputFile.sourcemap.txt index 94b86ffdde1..cbab02333cb 100644 --- a/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFile/amd/sourceRootRelativePathMixedSubfolderSpecifyOutputFile.sourcemap.txt +++ b/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFile/amd/sourceRootRelativePathMixedSubfolderSpecifyOutputFile.sourcemap.txt @@ -174,7 +174,7 @@ sourceFile:ref/m2.ts JsFile: test.js mapUrl: test.js.map sourceRoot: ../src/ -sources: ref/m1.ts,test.ts +sources: ref/m1.ts,ref/m2.ts,test.ts =================================================================== ------------------------------------------------------------------- emittedFile:bin/test.js @@ -306,7 +306,7 @@ sourceFile:ref/m1.ts >>>} 1 > 2 >^ -3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> 1 > > 2 >} @@ -315,16 +315,182 @@ sourceFile:ref/m1.ts --- ------------------------------------------------------------------- emittedFile:bin/test.js +sourceFile:ref/m2.ts +------------------------------------------------------------------- +>>>define("ref/m2", ["require", "exports"], function (require, exports) { +>>> exports.m2_a1 = 10; +1->^^^^ +2 > ^^^^^^^^^^^^^ +3 > ^^^ +4 > ^^ +5 > ^ +6 > ^^^^^^^^-> +1->export var +2 > m2_a1 +3 > = +4 > 10 +5 > ; +1->Emitted(12, 5) Source(1, 12) + SourceIndex(1) +2 >Emitted(12, 18) Source(1, 17) + SourceIndex(1) +3 >Emitted(12, 21) Source(1, 20) + SourceIndex(1) +4 >Emitted(12, 23) Source(1, 22) + SourceIndex(1) +5 >Emitted(12, 24) Source(1, 23) + SourceIndex(1) +--- +>>> var m2_c1 = (function () { +1->^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^^^^-> +1-> + > +1->Emitted(13, 5) Source(2, 1) + SourceIndex(1) +--- +>>> function m2_c1() { +1->^^^^^^^^ +2 > ^^-> +1-> +1->Emitted(14, 9) Source(2, 1) + SourceIndex(1) name (m2_c1) +--- +>>> } +1->^^^^^^^^ +2 > ^ +3 > ^^^^^^^^^^^^^-> +1->export class m2_c1 { + > public m2_c1_p1: number; + > +2 > } +1->Emitted(15, 9) Source(4, 1) + SourceIndex(1) name (m2_c1.constructor) +2 >Emitted(15, 10) Source(4, 2) + SourceIndex(1) name (m2_c1.constructor) +--- +>>> return m2_c1; +1->^^^^^^^^ +2 > ^^^^^^^^^^^^ +1-> +2 > } +1->Emitted(16, 9) Source(4, 1) + SourceIndex(1) name (m2_c1) +2 >Emitted(16, 21) Source(4, 2) + SourceIndex(1) name (m2_c1) +--- +>>> })(); +1 >^^^^ +2 > ^ +3 > +4 > ^^^^ +5 > ^^^^^^^^^^^^^^^^^^-> +1 > +2 > } +3 > +4 > export class m2_c1 { + > public m2_c1_p1: number; + > } +1 >Emitted(17, 5) Source(4, 1) + SourceIndex(1) name (m2_c1) +2 >Emitted(17, 6) Source(4, 2) + SourceIndex(1) name (m2_c1) +3 >Emitted(17, 6) Source(2, 1) + SourceIndex(1) +4 >Emitted(17, 10) Source(4, 2) + SourceIndex(1) +--- +>>> exports.m2_c1 = m2_c1; +1->^^^^ +2 > ^^^^^^^^^^^^^ +3 > ^^^^^^^^ +4 > ^ +5 > ^^^^^^^^^^^^^^-> +1-> +2 > m2_c1 +3 > { + > public m2_c1_p1: number; + > } +4 > +1->Emitted(18, 5) Source(2, 14) + SourceIndex(1) +2 >Emitted(18, 18) Source(2, 19) + SourceIndex(1) +3 >Emitted(18, 26) Source(4, 2) + SourceIndex(1) +4 >Emitted(18, 27) Source(4, 2) + SourceIndex(1) +--- +>>> exports.m2_instance1 = new m2_c1(); +1->^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^ +3 > ^^^ +4 > ^^^^ +5 > ^^^^^ +6 > ^^ +7 > ^ +1-> + > + >export var +2 > m2_instance1 +3 > = +4 > new +5 > m2_c1 +6 > () +7 > ; +1->Emitted(19, 5) Source(6, 12) + SourceIndex(1) +2 >Emitted(19, 25) Source(6, 24) + SourceIndex(1) +3 >Emitted(19, 28) Source(6, 27) + SourceIndex(1) +4 >Emitted(19, 32) Source(6, 31) + SourceIndex(1) +5 >Emitted(19, 37) Source(6, 36) + SourceIndex(1) +6 >Emitted(19, 39) Source(6, 38) + SourceIndex(1) +7 >Emitted(19, 40) Source(6, 39) + SourceIndex(1) +--- +>>> function m2_f1() { +1 >^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +1 > + > +1 >Emitted(20, 5) Source(7, 1) + SourceIndex(1) +--- +>>> return exports.m2_instance1; +1->^^^^^^^^ +2 > ^^^^^^ +3 > ^ +4 > ^^^^^^^^^^^^^^^^^^^^ +5 > ^ +1->export function m2_f1() { + > +2 > return +3 > +4 > m2_instance1 +5 > ; +1->Emitted(21, 9) Source(8, 5) + SourceIndex(1) name (m2_f1) +2 >Emitted(21, 15) Source(8, 11) + SourceIndex(1) name (m2_f1) +3 >Emitted(21, 16) Source(8, 12) + SourceIndex(1) name (m2_f1) +4 >Emitted(21, 36) Source(8, 24) + SourceIndex(1) name (m2_f1) +5 >Emitted(21, 37) Source(8, 25) + SourceIndex(1) name (m2_f1) +--- +>>> } +1 >^^^^ +2 > ^ +3 > ^^^^^^^^^^^^^^^^^^^^^^-> +1 > + > +2 > } +1 >Emitted(22, 5) Source(9, 1) + SourceIndex(1) name (m2_f1) +2 >Emitted(22, 6) Source(9, 2) + SourceIndex(1) name (m2_f1) +--- +>>> exports.m2_f1 = m2_f1; +1->^^^^ +2 > ^^^^^^^^^^^^^ +3 > ^^^^^^^^ +4 > ^ +1-> +2 > m2_f1 +3 > () { + > return m2_instance1; + > } +4 > +1->Emitted(23, 5) Source(7, 17) + SourceIndex(1) +2 >Emitted(23, 18) Source(7, 22) + SourceIndex(1) +3 >Emitted(23, 26) Source(9, 2) + SourceIndex(1) +4 >Emitted(23, 27) Source(9, 2) + SourceIndex(1) +--- +------------------------------------------------------------------- +emittedFile:bin/test.js sourceFile:test.ts ------------------------------------------------------------------- +>>>}); >>>/// -1-> +1 > 2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 3 > ^-> -1-> +1 > 2 >/// -1->Emitted(11, 1) Source(1, 1) + SourceIndex(1) -2 >Emitted(11, 34) Source(1, 34) + SourceIndex(1) +1 >Emitted(25, 1) Source(1, 1) + SourceIndex(2) +2 >Emitted(25, 34) Source(1, 34) + SourceIndex(2) --- >>>/// 1-> @@ -332,8 +498,8 @@ sourceFile:test.ts 1-> > 2 >/// -1->Emitted(12, 1) Source(2, 1) + SourceIndex(1) -2 >Emitted(12, 34) Source(2, 34) + SourceIndex(1) +1->Emitted(26, 1) Source(2, 1) + SourceIndex(2) +2 >Emitted(26, 34) Source(2, 34) + SourceIndex(2) --- >>>var a1 = 10; 1 > @@ -350,25 +516,25 @@ sourceFile:test.ts 4 > = 5 > 10 6 > ; -1 >Emitted(13, 1) Source(3, 1) + SourceIndex(1) -2 >Emitted(13, 5) Source(3, 5) + SourceIndex(1) -3 >Emitted(13, 7) Source(3, 7) + SourceIndex(1) -4 >Emitted(13, 10) Source(3, 10) + SourceIndex(1) -5 >Emitted(13, 12) Source(3, 12) + SourceIndex(1) -6 >Emitted(13, 13) Source(3, 13) + SourceIndex(1) +1 >Emitted(27, 1) Source(3, 1) + SourceIndex(2) +2 >Emitted(27, 5) Source(3, 5) + SourceIndex(2) +3 >Emitted(27, 7) Source(3, 7) + SourceIndex(2) +4 >Emitted(27, 10) Source(3, 10) + SourceIndex(2) +5 >Emitted(27, 12) Source(3, 12) + SourceIndex(2) +6 >Emitted(27, 13) Source(3, 13) + SourceIndex(2) --- >>>var c1 = (function () { 1-> 2 >^^^^^^^^^^^^^^^^^^^^-> 1-> > -1->Emitted(14, 1) Source(4, 1) + SourceIndex(1) +1->Emitted(28, 1) Source(4, 1) + SourceIndex(2) --- >>> function c1() { 1->^^^^ 2 > ^^-> 1-> -1->Emitted(15, 5) Source(4, 1) + SourceIndex(1) name (c1) +1->Emitted(29, 5) Source(4, 1) + SourceIndex(2) name (c1) --- >>> } 1->^^^^ @@ -378,16 +544,16 @@ sourceFile:test.ts > public p1: number; > 2 > } -1->Emitted(16, 5) Source(6, 1) + SourceIndex(1) name (c1.constructor) -2 >Emitted(16, 6) Source(6, 2) + SourceIndex(1) name (c1.constructor) +1->Emitted(30, 5) Source(6, 1) + SourceIndex(2) name (c1.constructor) +2 >Emitted(30, 6) Source(6, 2) + SourceIndex(2) name (c1.constructor) --- >>> return c1; 1->^^^^ 2 > ^^^^^^^^^ 1-> 2 > } -1->Emitted(17, 5) Source(6, 1) + SourceIndex(1) name (c1) -2 >Emitted(17, 14) Source(6, 2) + SourceIndex(1) name (c1) +1->Emitted(31, 5) Source(6, 1) + SourceIndex(2) name (c1) +2 >Emitted(31, 14) Source(6, 2) + SourceIndex(2) name (c1) --- >>>})(); 1 > @@ -401,10 +567,10 @@ sourceFile:test.ts 4 > class c1 { > public p1: number; > } -1 >Emitted(18, 1) Source(6, 1) + SourceIndex(1) name (c1) -2 >Emitted(18, 2) Source(6, 2) + SourceIndex(1) name (c1) -3 >Emitted(18, 2) Source(4, 1) + SourceIndex(1) -4 >Emitted(18, 6) Source(6, 2) + SourceIndex(1) +1 >Emitted(32, 1) Source(6, 1) + SourceIndex(2) name (c1) +2 >Emitted(32, 2) Source(6, 2) + SourceIndex(2) name (c1) +3 >Emitted(32, 2) Source(4, 1) + SourceIndex(2) +4 >Emitted(32, 6) Source(6, 2) + SourceIndex(2) --- >>>var instance1 = new c1(); 1-> @@ -425,21 +591,21 @@ sourceFile:test.ts 6 > c1 7 > () 8 > ; -1->Emitted(19, 1) Source(8, 1) + SourceIndex(1) -2 >Emitted(19, 5) Source(8, 5) + SourceIndex(1) -3 >Emitted(19, 14) Source(8, 14) + SourceIndex(1) -4 >Emitted(19, 17) Source(8, 17) + SourceIndex(1) -5 >Emitted(19, 21) Source(8, 21) + SourceIndex(1) -6 >Emitted(19, 23) Source(8, 23) + SourceIndex(1) -7 >Emitted(19, 25) Source(8, 25) + SourceIndex(1) -8 >Emitted(19, 26) Source(8, 26) + SourceIndex(1) +1->Emitted(33, 1) Source(8, 1) + SourceIndex(2) +2 >Emitted(33, 5) Source(8, 5) + SourceIndex(2) +3 >Emitted(33, 14) Source(8, 14) + SourceIndex(2) +4 >Emitted(33, 17) Source(8, 17) + SourceIndex(2) +5 >Emitted(33, 21) Source(8, 21) + SourceIndex(2) +6 >Emitted(33, 23) Source(8, 23) + SourceIndex(2) +7 >Emitted(33, 25) Source(8, 25) + SourceIndex(2) +8 >Emitted(33, 26) Source(8, 26) + SourceIndex(2) --- >>>function f1() { 1 > 2 >^^^^^^^^^^^^^^^^^^^^^^-> 1 > > -1 >Emitted(20, 1) Source(9, 1) + SourceIndex(1) +1 >Emitted(34, 1) Source(9, 1) + SourceIndex(2) --- >>> return instance1; 1->^^^^ @@ -453,11 +619,11 @@ sourceFile:test.ts 3 > 4 > instance1 5 > ; -1->Emitted(21, 5) Source(10, 5) + SourceIndex(1) name (f1) -2 >Emitted(21, 11) Source(10, 11) + SourceIndex(1) name (f1) -3 >Emitted(21, 12) Source(10, 12) + SourceIndex(1) name (f1) -4 >Emitted(21, 21) Source(10, 21) + SourceIndex(1) name (f1) -5 >Emitted(21, 22) Source(10, 22) + SourceIndex(1) name (f1) +1->Emitted(35, 5) Source(10, 5) + SourceIndex(2) name (f1) +2 >Emitted(35, 11) Source(10, 11) + SourceIndex(2) name (f1) +3 >Emitted(35, 12) Source(10, 12) + SourceIndex(2) name (f1) +4 >Emitted(35, 21) Source(10, 21) + SourceIndex(2) name (f1) +5 >Emitted(35, 22) Source(10, 22) + SourceIndex(2) name (f1) --- >>>} 1 > @@ -466,7 +632,7 @@ sourceFile:test.ts 1 > > 2 >} -1 >Emitted(22, 1) Source(11, 1) + SourceIndex(1) name (f1) -2 >Emitted(22, 2) Source(11, 2) + SourceIndex(1) name (f1) +1 >Emitted(36, 1) Source(11, 1) + SourceIndex(2) name (f1) +2 >Emitted(36, 2) Source(11, 2) + SourceIndex(2) name (f1) --- >>>//# sourceMappingURL=test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFile/node/bin/test.d.ts b/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFile/node/bin/test.d.ts deleted file mode 100644 index d61b4c3b876..00000000000 --- a/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFile/node/bin/test.d.ts +++ /dev/null @@ -1,13 +0,0 @@ -/// -declare var m1_a1: number; -declare class m1_c1 { - m1_c1_p1: number; -} -declare var m1_instance1: m1_c1; -declare function m1_f1(): m1_c1; -declare var a1: number; -declare class c1 { - p1: number; -} -declare var instance1: c1; -declare function f1(): c1; diff --git a/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFile/node/bin/test.js b/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFile/node/bin/test.js deleted file mode 100644 index 5af28cf8560..00000000000 --- a/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFile/node/bin/test.js +++ /dev/null @@ -1,23 +0,0 @@ -var m1_a1 = 10; -var m1_c1 = (function () { - function m1_c1() { - } - return m1_c1; -})(); -var m1_instance1 = new m1_c1(); -function m1_f1() { - return m1_instance1; -} -/// -/// -var a1 = 10; -var c1 = (function () { - function c1() { - } - return c1; -})(); -var instance1 = new c1(); -function f1() { - return instance1; -} -//# sourceMappingURL=test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFile/node/bin/test.js.map b/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFile/node/bin/test.js.map index 86afcf32e25..03976e6a8d6 100644 --- a/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFile/node/bin/test.js.map +++ b/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFile/node/bin/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"../src/","sources":["ref/m1.ts","test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACRD,iCAAiC;AACjC,iCAAiC;AACjC,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"../src/","sources":["ref/m1.ts","ref/m2.ts","test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;AERD,iCAAiC;AACjC,iCAAiC;AACjC,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFile/node/sourceRootRelativePathMixedSubfolderSpecifyOutputFile.sourcemap.txt b/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFile/node/sourceRootRelativePathMixedSubfolderSpecifyOutputFile.sourcemap.txt index 12a6fdbc6dd..e064f005473 100644 --- a/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFile/node/sourceRootRelativePathMixedSubfolderSpecifyOutputFile.sourcemap.txt +++ b/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFile/node/sourceRootRelativePathMixedSubfolderSpecifyOutputFile.sourcemap.txt @@ -173,7 +173,7 @@ sourceFile:ref/m2.ts JsFile: test.js mapUrl: test.js.map sourceRoot: ../src/ -sources: ref/m1.ts,test.ts +sources: ref/m1.ts,ref/m2.ts,test.ts =================================================================== ------------------------------------------------------------------- emittedFile:bin/test.js @@ -322,8 +322,8 @@ sourceFile:test.ts 3 > ^-> 1-> 2 >/// -1->Emitted(11, 1) Source(1, 1) + SourceIndex(1) -2 >Emitted(11, 34) Source(1, 34) + SourceIndex(1) +1->Emitted(11, 1) Source(1, 1) + SourceIndex(2) +2 >Emitted(11, 34) Source(1, 34) + SourceIndex(2) --- >>>/// 1-> @@ -331,8 +331,8 @@ sourceFile:test.ts 1-> > 2 >/// -1->Emitted(12, 1) Source(2, 1) + SourceIndex(1) -2 >Emitted(12, 34) Source(2, 34) + SourceIndex(1) +1->Emitted(12, 1) Source(2, 1) + SourceIndex(2) +2 >Emitted(12, 34) Source(2, 34) + SourceIndex(2) --- >>>var a1 = 10; 1 > @@ -349,25 +349,25 @@ sourceFile:test.ts 4 > = 5 > 10 6 > ; -1 >Emitted(13, 1) Source(3, 1) + SourceIndex(1) -2 >Emitted(13, 5) Source(3, 5) + SourceIndex(1) -3 >Emitted(13, 7) Source(3, 7) + SourceIndex(1) -4 >Emitted(13, 10) Source(3, 10) + SourceIndex(1) -5 >Emitted(13, 12) Source(3, 12) + SourceIndex(1) -6 >Emitted(13, 13) Source(3, 13) + SourceIndex(1) +1 >Emitted(13, 1) Source(3, 1) + SourceIndex(2) +2 >Emitted(13, 5) Source(3, 5) + SourceIndex(2) +3 >Emitted(13, 7) Source(3, 7) + SourceIndex(2) +4 >Emitted(13, 10) Source(3, 10) + SourceIndex(2) +5 >Emitted(13, 12) Source(3, 12) + SourceIndex(2) +6 >Emitted(13, 13) Source(3, 13) + SourceIndex(2) --- >>>var c1 = (function () { 1-> 2 >^^^^^^^^^^^^^^^^^^^^-> 1-> > -1->Emitted(14, 1) Source(4, 1) + SourceIndex(1) +1->Emitted(14, 1) Source(4, 1) + SourceIndex(2) --- >>> function c1() { 1->^^^^ 2 > ^^-> 1-> -1->Emitted(15, 5) Source(4, 1) + SourceIndex(1) name (c1) +1->Emitted(15, 5) Source(4, 1) + SourceIndex(2) name (c1) --- >>> } 1->^^^^ @@ -377,16 +377,16 @@ sourceFile:test.ts > public p1: number; > 2 > } -1->Emitted(16, 5) Source(6, 1) + SourceIndex(1) name (c1.constructor) -2 >Emitted(16, 6) Source(6, 2) + SourceIndex(1) name (c1.constructor) +1->Emitted(16, 5) Source(6, 1) + SourceIndex(2) name (c1.constructor) +2 >Emitted(16, 6) Source(6, 2) + SourceIndex(2) name (c1.constructor) --- >>> return c1; 1->^^^^ 2 > ^^^^^^^^^ 1-> 2 > } -1->Emitted(17, 5) Source(6, 1) + SourceIndex(1) name (c1) -2 >Emitted(17, 14) Source(6, 2) + SourceIndex(1) name (c1) +1->Emitted(17, 5) Source(6, 1) + SourceIndex(2) name (c1) +2 >Emitted(17, 14) Source(6, 2) + SourceIndex(2) name (c1) --- >>>})(); 1 > @@ -400,10 +400,10 @@ sourceFile:test.ts 4 > class c1 { > public p1: number; > } -1 >Emitted(18, 1) Source(6, 1) + SourceIndex(1) name (c1) -2 >Emitted(18, 2) Source(6, 2) + SourceIndex(1) name (c1) -3 >Emitted(18, 2) Source(4, 1) + SourceIndex(1) -4 >Emitted(18, 6) Source(6, 2) + SourceIndex(1) +1 >Emitted(18, 1) Source(6, 1) + SourceIndex(2) name (c1) +2 >Emitted(18, 2) Source(6, 2) + SourceIndex(2) name (c1) +3 >Emitted(18, 2) Source(4, 1) + SourceIndex(2) +4 >Emitted(18, 6) Source(6, 2) + SourceIndex(2) --- >>>var instance1 = new c1(); 1-> @@ -424,21 +424,21 @@ sourceFile:test.ts 6 > c1 7 > () 8 > ; -1->Emitted(19, 1) Source(8, 1) + SourceIndex(1) -2 >Emitted(19, 5) Source(8, 5) + SourceIndex(1) -3 >Emitted(19, 14) Source(8, 14) + SourceIndex(1) -4 >Emitted(19, 17) Source(8, 17) + SourceIndex(1) -5 >Emitted(19, 21) Source(8, 21) + SourceIndex(1) -6 >Emitted(19, 23) Source(8, 23) + SourceIndex(1) -7 >Emitted(19, 25) Source(8, 25) + SourceIndex(1) -8 >Emitted(19, 26) Source(8, 26) + SourceIndex(1) +1->Emitted(19, 1) Source(8, 1) + SourceIndex(2) +2 >Emitted(19, 5) Source(8, 5) + SourceIndex(2) +3 >Emitted(19, 14) Source(8, 14) + SourceIndex(2) +4 >Emitted(19, 17) Source(8, 17) + SourceIndex(2) +5 >Emitted(19, 21) Source(8, 21) + SourceIndex(2) +6 >Emitted(19, 23) Source(8, 23) + SourceIndex(2) +7 >Emitted(19, 25) Source(8, 25) + SourceIndex(2) +8 >Emitted(19, 26) Source(8, 26) + SourceIndex(2) --- >>>function f1() { 1 > 2 >^^^^^^^^^^^^^^^^^^^^^^-> 1 > > -1 >Emitted(20, 1) Source(9, 1) + SourceIndex(1) +1 >Emitted(20, 1) Source(9, 1) + SourceIndex(2) --- >>> return instance1; 1->^^^^ @@ -452,11 +452,11 @@ sourceFile:test.ts 3 > 4 > instance1 5 > ; -1->Emitted(21, 5) Source(10, 5) + SourceIndex(1) name (f1) -2 >Emitted(21, 11) Source(10, 11) + SourceIndex(1) name (f1) -3 >Emitted(21, 12) Source(10, 12) + SourceIndex(1) name (f1) -4 >Emitted(21, 21) Source(10, 21) + SourceIndex(1) name (f1) -5 >Emitted(21, 22) Source(10, 22) + SourceIndex(1) name (f1) +1->Emitted(21, 5) Source(10, 5) + SourceIndex(2) name (f1) +2 >Emitted(21, 11) Source(10, 11) + SourceIndex(2) name (f1) +3 >Emitted(21, 12) Source(10, 12) + SourceIndex(2) name (f1) +4 >Emitted(21, 21) Source(10, 21) + SourceIndex(2) name (f1) +5 >Emitted(21, 22) Source(10, 22) + SourceIndex(2) name (f1) --- >>>} 1 > @@ -465,7 +465,7 @@ sourceFile:test.ts 1 > > 2 >} -1 >Emitted(22, 1) Source(11, 1) + SourceIndex(1) name (f1) -2 >Emitted(22, 2) Source(11, 2) + SourceIndex(1) name (f1) +1 >Emitted(22, 1) Source(11, 1) + SourceIndex(2) name (f1) +2 >Emitted(22, 2) Source(11, 2) + SourceIndex(2) name (f1) --- >>>//# sourceMappingURL=test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.d.ts b/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.d.ts deleted file mode 100644 index 9b9cdd4a214..00000000000 --- a/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.d.ts +++ /dev/null @@ -1,13 +0,0 @@ -/// -declare var m1_a1: number; -declare class m1_c1 { - m1_c1_p1: number; -} -declare var m1_instance1: m1_c1; -declare function m1_f1(): m1_c1; -declare var a1: number; -declare class c1 { - p1: number; -} -declare var instance1: c1; -declare function f1(): c1; diff --git a/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.js b/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.js deleted file mode 100644 index 1750a5975ae..00000000000 --- a/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.js +++ /dev/null @@ -1,23 +0,0 @@ -var m1_a1 = 10; -var m1_c1 = (function () { - function m1_c1() { - } - return m1_c1; -})(); -var m1_instance1 = new m1_c1(); -function m1_f1() { - return m1_instance1; -} -/// -/// -var a1 = 10; -var c1 = (function () { - function c1() { - } - return c1; -})(); -var instance1 = new c1(); -function f1() { - return instance1; -} -//# sourceMappingURL=outAndOutDirFile.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.js.map b/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.js.map index 13b958b1025..a9529891ffd 100644 --- a/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.js.map +++ b/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.js.map @@ -1 +1 @@ -{"version":3,"file":"outAndOutDirFile.js","sourceRoot":"../src/","sources":["ref/m1.ts","test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACRD,iCAAiC;AACjC,iCAAiC;AACjC,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"outAndOutDirFile.js","sourceRoot":"../src/","sources":["ref/m1.ts","ref/m2.ts","test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","m2_c1","m2_c1.constructor","m2_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;;ICRU,aAAK,GAAG,EAAE,CAAC;IACtB;QAAAC;QAEAC,CAACA;QAADD,YAACA;IAADA,CAACA,AAFD,IAEC;IAFY,aAAK,QAEjB,CAAA;IAEU,oBAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACIE,MAAMA,CAACA,oBAAYA,CAACA;IACxBA,CAACA;IAFe,aAAK,QAEpB,CAAA;;ACRD,iCAAiC;AACjC,iCAAiC;AACjC,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/sourceRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory.sourcemap.txt b/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/sourceRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory.sourcemap.txt index 11e34ee5a2e..f2fc29c157e 100644 --- a/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/sourceRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory.sourcemap.txt +++ b/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/sourceRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory.sourcemap.txt @@ -174,7 +174,7 @@ sourceFile:ref/m2.ts JsFile: outAndOutDirFile.js mapUrl: outAndOutDirFile.js.map sourceRoot: ../src/ -sources: ref/m1.ts,test.ts +sources: ref/m1.ts,ref/m2.ts,test.ts =================================================================== ------------------------------------------------------------------- emittedFile:bin/outAndOutDirFile.js @@ -306,7 +306,7 @@ sourceFile:ref/m1.ts >>>} 1 > 2 >^ -3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> 1 > > 2 >} @@ -315,16 +315,182 @@ sourceFile:ref/m1.ts --- ------------------------------------------------------------------- emittedFile:bin/outAndOutDirFile.js +sourceFile:ref/m2.ts +------------------------------------------------------------------- +>>>define("ref/m2", ["require", "exports"], function (require, exports) { +>>> exports.m2_a1 = 10; +1->^^^^ +2 > ^^^^^^^^^^^^^ +3 > ^^^ +4 > ^^ +5 > ^ +6 > ^^^^^^^^-> +1->export var +2 > m2_a1 +3 > = +4 > 10 +5 > ; +1->Emitted(12, 5) Source(1, 12) + SourceIndex(1) +2 >Emitted(12, 18) Source(1, 17) + SourceIndex(1) +3 >Emitted(12, 21) Source(1, 20) + SourceIndex(1) +4 >Emitted(12, 23) Source(1, 22) + SourceIndex(1) +5 >Emitted(12, 24) Source(1, 23) + SourceIndex(1) +--- +>>> var m2_c1 = (function () { +1->^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^^^^-> +1-> + > +1->Emitted(13, 5) Source(2, 1) + SourceIndex(1) +--- +>>> function m2_c1() { +1->^^^^^^^^ +2 > ^^-> +1-> +1->Emitted(14, 9) Source(2, 1) + SourceIndex(1) name (m2_c1) +--- +>>> } +1->^^^^^^^^ +2 > ^ +3 > ^^^^^^^^^^^^^-> +1->export class m2_c1 { + > public m2_c1_p1: number; + > +2 > } +1->Emitted(15, 9) Source(4, 1) + SourceIndex(1) name (m2_c1.constructor) +2 >Emitted(15, 10) Source(4, 2) + SourceIndex(1) name (m2_c1.constructor) +--- +>>> return m2_c1; +1->^^^^^^^^ +2 > ^^^^^^^^^^^^ +1-> +2 > } +1->Emitted(16, 9) Source(4, 1) + SourceIndex(1) name (m2_c1) +2 >Emitted(16, 21) Source(4, 2) + SourceIndex(1) name (m2_c1) +--- +>>> })(); +1 >^^^^ +2 > ^ +3 > +4 > ^^^^ +5 > ^^^^^^^^^^^^^^^^^^-> +1 > +2 > } +3 > +4 > export class m2_c1 { + > public m2_c1_p1: number; + > } +1 >Emitted(17, 5) Source(4, 1) + SourceIndex(1) name (m2_c1) +2 >Emitted(17, 6) Source(4, 2) + SourceIndex(1) name (m2_c1) +3 >Emitted(17, 6) Source(2, 1) + SourceIndex(1) +4 >Emitted(17, 10) Source(4, 2) + SourceIndex(1) +--- +>>> exports.m2_c1 = m2_c1; +1->^^^^ +2 > ^^^^^^^^^^^^^ +3 > ^^^^^^^^ +4 > ^ +5 > ^^^^^^^^^^^^^^-> +1-> +2 > m2_c1 +3 > { + > public m2_c1_p1: number; + > } +4 > +1->Emitted(18, 5) Source(2, 14) + SourceIndex(1) +2 >Emitted(18, 18) Source(2, 19) + SourceIndex(1) +3 >Emitted(18, 26) Source(4, 2) + SourceIndex(1) +4 >Emitted(18, 27) Source(4, 2) + SourceIndex(1) +--- +>>> exports.m2_instance1 = new m2_c1(); +1->^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^ +3 > ^^^ +4 > ^^^^ +5 > ^^^^^ +6 > ^^ +7 > ^ +1-> + > + >export var +2 > m2_instance1 +3 > = +4 > new +5 > m2_c1 +6 > () +7 > ; +1->Emitted(19, 5) Source(6, 12) + SourceIndex(1) +2 >Emitted(19, 25) Source(6, 24) + SourceIndex(1) +3 >Emitted(19, 28) Source(6, 27) + SourceIndex(1) +4 >Emitted(19, 32) Source(6, 31) + SourceIndex(1) +5 >Emitted(19, 37) Source(6, 36) + SourceIndex(1) +6 >Emitted(19, 39) Source(6, 38) + SourceIndex(1) +7 >Emitted(19, 40) Source(6, 39) + SourceIndex(1) +--- +>>> function m2_f1() { +1 >^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +1 > + > +1 >Emitted(20, 5) Source(7, 1) + SourceIndex(1) +--- +>>> return exports.m2_instance1; +1->^^^^^^^^ +2 > ^^^^^^ +3 > ^ +4 > ^^^^^^^^^^^^^^^^^^^^ +5 > ^ +1->export function m2_f1() { + > +2 > return +3 > +4 > m2_instance1 +5 > ; +1->Emitted(21, 9) Source(8, 5) + SourceIndex(1) name (m2_f1) +2 >Emitted(21, 15) Source(8, 11) + SourceIndex(1) name (m2_f1) +3 >Emitted(21, 16) Source(8, 12) + SourceIndex(1) name (m2_f1) +4 >Emitted(21, 36) Source(8, 24) + SourceIndex(1) name (m2_f1) +5 >Emitted(21, 37) Source(8, 25) + SourceIndex(1) name (m2_f1) +--- +>>> } +1 >^^^^ +2 > ^ +3 > ^^^^^^^^^^^^^^^^^^^^^^-> +1 > + > +2 > } +1 >Emitted(22, 5) Source(9, 1) + SourceIndex(1) name (m2_f1) +2 >Emitted(22, 6) Source(9, 2) + SourceIndex(1) name (m2_f1) +--- +>>> exports.m2_f1 = m2_f1; +1->^^^^ +2 > ^^^^^^^^^^^^^ +3 > ^^^^^^^^ +4 > ^ +1-> +2 > m2_f1 +3 > () { + > return m2_instance1; + > } +4 > +1->Emitted(23, 5) Source(7, 17) + SourceIndex(1) +2 >Emitted(23, 18) Source(7, 22) + SourceIndex(1) +3 >Emitted(23, 26) Source(9, 2) + SourceIndex(1) +4 >Emitted(23, 27) Source(9, 2) + SourceIndex(1) +--- +------------------------------------------------------------------- +emittedFile:bin/outAndOutDirFile.js sourceFile:test.ts ------------------------------------------------------------------- +>>>}); >>>/// -1-> +1 > 2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 3 > ^-> -1-> +1 > 2 >/// -1->Emitted(11, 1) Source(1, 1) + SourceIndex(1) -2 >Emitted(11, 34) Source(1, 34) + SourceIndex(1) +1 >Emitted(25, 1) Source(1, 1) + SourceIndex(2) +2 >Emitted(25, 34) Source(1, 34) + SourceIndex(2) --- >>>/// 1-> @@ -332,8 +498,8 @@ sourceFile:test.ts 1-> > 2 >/// -1->Emitted(12, 1) Source(2, 1) + SourceIndex(1) -2 >Emitted(12, 34) Source(2, 34) + SourceIndex(1) +1->Emitted(26, 1) Source(2, 1) + SourceIndex(2) +2 >Emitted(26, 34) Source(2, 34) + SourceIndex(2) --- >>>var a1 = 10; 1 > @@ -350,25 +516,25 @@ sourceFile:test.ts 4 > = 5 > 10 6 > ; -1 >Emitted(13, 1) Source(3, 1) + SourceIndex(1) -2 >Emitted(13, 5) Source(3, 5) + SourceIndex(1) -3 >Emitted(13, 7) Source(3, 7) + SourceIndex(1) -4 >Emitted(13, 10) Source(3, 10) + SourceIndex(1) -5 >Emitted(13, 12) Source(3, 12) + SourceIndex(1) -6 >Emitted(13, 13) Source(3, 13) + SourceIndex(1) +1 >Emitted(27, 1) Source(3, 1) + SourceIndex(2) +2 >Emitted(27, 5) Source(3, 5) + SourceIndex(2) +3 >Emitted(27, 7) Source(3, 7) + SourceIndex(2) +4 >Emitted(27, 10) Source(3, 10) + SourceIndex(2) +5 >Emitted(27, 12) Source(3, 12) + SourceIndex(2) +6 >Emitted(27, 13) Source(3, 13) + SourceIndex(2) --- >>>var c1 = (function () { 1-> 2 >^^^^^^^^^^^^^^^^^^^^-> 1-> > -1->Emitted(14, 1) Source(4, 1) + SourceIndex(1) +1->Emitted(28, 1) Source(4, 1) + SourceIndex(2) --- >>> function c1() { 1->^^^^ 2 > ^^-> 1-> -1->Emitted(15, 5) Source(4, 1) + SourceIndex(1) name (c1) +1->Emitted(29, 5) Source(4, 1) + SourceIndex(2) name (c1) --- >>> } 1->^^^^ @@ -378,16 +544,16 @@ sourceFile:test.ts > public p1: number; > 2 > } -1->Emitted(16, 5) Source(6, 1) + SourceIndex(1) name (c1.constructor) -2 >Emitted(16, 6) Source(6, 2) + SourceIndex(1) name (c1.constructor) +1->Emitted(30, 5) Source(6, 1) + SourceIndex(2) name (c1.constructor) +2 >Emitted(30, 6) Source(6, 2) + SourceIndex(2) name (c1.constructor) --- >>> return c1; 1->^^^^ 2 > ^^^^^^^^^ 1-> 2 > } -1->Emitted(17, 5) Source(6, 1) + SourceIndex(1) name (c1) -2 >Emitted(17, 14) Source(6, 2) + SourceIndex(1) name (c1) +1->Emitted(31, 5) Source(6, 1) + SourceIndex(2) name (c1) +2 >Emitted(31, 14) Source(6, 2) + SourceIndex(2) name (c1) --- >>>})(); 1 > @@ -401,10 +567,10 @@ sourceFile:test.ts 4 > class c1 { > public p1: number; > } -1 >Emitted(18, 1) Source(6, 1) + SourceIndex(1) name (c1) -2 >Emitted(18, 2) Source(6, 2) + SourceIndex(1) name (c1) -3 >Emitted(18, 2) Source(4, 1) + SourceIndex(1) -4 >Emitted(18, 6) Source(6, 2) + SourceIndex(1) +1 >Emitted(32, 1) Source(6, 1) + SourceIndex(2) name (c1) +2 >Emitted(32, 2) Source(6, 2) + SourceIndex(2) name (c1) +3 >Emitted(32, 2) Source(4, 1) + SourceIndex(2) +4 >Emitted(32, 6) Source(6, 2) + SourceIndex(2) --- >>>var instance1 = new c1(); 1-> @@ -425,21 +591,21 @@ sourceFile:test.ts 6 > c1 7 > () 8 > ; -1->Emitted(19, 1) Source(8, 1) + SourceIndex(1) -2 >Emitted(19, 5) Source(8, 5) + SourceIndex(1) -3 >Emitted(19, 14) Source(8, 14) + SourceIndex(1) -4 >Emitted(19, 17) Source(8, 17) + SourceIndex(1) -5 >Emitted(19, 21) Source(8, 21) + SourceIndex(1) -6 >Emitted(19, 23) Source(8, 23) + SourceIndex(1) -7 >Emitted(19, 25) Source(8, 25) + SourceIndex(1) -8 >Emitted(19, 26) Source(8, 26) + SourceIndex(1) +1->Emitted(33, 1) Source(8, 1) + SourceIndex(2) +2 >Emitted(33, 5) Source(8, 5) + SourceIndex(2) +3 >Emitted(33, 14) Source(8, 14) + SourceIndex(2) +4 >Emitted(33, 17) Source(8, 17) + SourceIndex(2) +5 >Emitted(33, 21) Source(8, 21) + SourceIndex(2) +6 >Emitted(33, 23) Source(8, 23) + SourceIndex(2) +7 >Emitted(33, 25) Source(8, 25) + SourceIndex(2) +8 >Emitted(33, 26) Source(8, 26) + SourceIndex(2) --- >>>function f1() { 1 > 2 >^^^^^^^^^^^^^^^^^^^^^^-> 1 > > -1 >Emitted(20, 1) Source(9, 1) + SourceIndex(1) +1 >Emitted(34, 1) Source(9, 1) + SourceIndex(2) --- >>> return instance1; 1->^^^^ @@ -453,11 +619,11 @@ sourceFile:test.ts 3 > 4 > instance1 5 > ; -1->Emitted(21, 5) Source(10, 5) + SourceIndex(1) name (f1) -2 >Emitted(21, 11) Source(10, 11) + SourceIndex(1) name (f1) -3 >Emitted(21, 12) Source(10, 12) + SourceIndex(1) name (f1) -4 >Emitted(21, 21) Source(10, 21) + SourceIndex(1) name (f1) -5 >Emitted(21, 22) Source(10, 22) + SourceIndex(1) name (f1) +1->Emitted(35, 5) Source(10, 5) + SourceIndex(2) name (f1) +2 >Emitted(35, 11) Source(10, 11) + SourceIndex(2) name (f1) +3 >Emitted(35, 12) Source(10, 12) + SourceIndex(2) name (f1) +4 >Emitted(35, 21) Source(10, 21) + SourceIndex(2) name (f1) +5 >Emitted(35, 22) Source(10, 22) + SourceIndex(2) name (f1) --- >>>} 1 > @@ -466,7 +632,7 @@ sourceFile:test.ts 1 > > 2 >} -1 >Emitted(22, 1) Source(11, 1) + SourceIndex(1) name (f1) -2 >Emitted(22, 2) Source(11, 2) + SourceIndex(1) name (f1) +1 >Emitted(36, 1) Source(11, 1) + SourceIndex(2) name (f1) +2 >Emitted(36, 2) Source(11, 2) + SourceIndex(2) name (f1) --- >>>//# sourceMappingURL=outAndOutDirFile.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.d.ts b/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.d.ts deleted file mode 100644 index 9b9cdd4a214..00000000000 --- a/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.d.ts +++ /dev/null @@ -1,13 +0,0 @@ -/// -declare var m1_a1: number; -declare class m1_c1 { - m1_c1_p1: number; -} -declare var m1_instance1: m1_c1; -declare function m1_f1(): m1_c1; -declare var a1: number; -declare class c1 { - p1: number; -} -declare var instance1: c1; -declare function f1(): c1; diff --git a/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.js b/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.js deleted file mode 100644 index 1750a5975ae..00000000000 --- a/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.js +++ /dev/null @@ -1,23 +0,0 @@ -var m1_a1 = 10; -var m1_c1 = (function () { - function m1_c1() { - } - return m1_c1; -})(); -var m1_instance1 = new m1_c1(); -function m1_f1() { - return m1_instance1; -} -/// -/// -var a1 = 10; -var c1 = (function () { - function c1() { - } - return c1; -})(); -var instance1 = new c1(); -function f1() { - return instance1; -} -//# sourceMappingURL=outAndOutDirFile.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.js.map b/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.js.map index 13b958b1025..23957761470 100644 --- a/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.js.map +++ b/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.js.map @@ -1 +1 @@ -{"version":3,"file":"outAndOutDirFile.js","sourceRoot":"../src/","sources":["ref/m1.ts","test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACRD,iCAAiC;AACjC,iCAAiC;AACjC,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"outAndOutDirFile.js","sourceRoot":"../src/","sources":["ref/m1.ts","ref/m2.ts","test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;AERD,iCAAiC;AACjC,iCAAiC;AACjC,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/sourceRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory.sourcemap.txt b/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/sourceRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory.sourcemap.txt index 5b9ec51c270..5690deb27df 100644 --- a/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/sourceRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory.sourcemap.txt +++ b/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/sourceRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory.sourcemap.txt @@ -173,7 +173,7 @@ sourceFile:ref/m2.ts JsFile: outAndOutDirFile.js mapUrl: outAndOutDirFile.js.map sourceRoot: ../src/ -sources: ref/m1.ts,test.ts +sources: ref/m1.ts,ref/m2.ts,test.ts =================================================================== ------------------------------------------------------------------- emittedFile:bin/outAndOutDirFile.js @@ -322,8 +322,8 @@ sourceFile:test.ts 3 > ^-> 1-> 2 >/// -1->Emitted(11, 1) Source(1, 1) + SourceIndex(1) -2 >Emitted(11, 34) Source(1, 34) + SourceIndex(1) +1->Emitted(11, 1) Source(1, 1) + SourceIndex(2) +2 >Emitted(11, 34) Source(1, 34) + SourceIndex(2) --- >>>/// 1-> @@ -331,8 +331,8 @@ sourceFile:test.ts 1-> > 2 >/// -1->Emitted(12, 1) Source(2, 1) + SourceIndex(1) -2 >Emitted(12, 34) Source(2, 34) + SourceIndex(1) +1->Emitted(12, 1) Source(2, 1) + SourceIndex(2) +2 >Emitted(12, 34) Source(2, 34) + SourceIndex(2) --- >>>var a1 = 10; 1 > @@ -349,25 +349,25 @@ sourceFile:test.ts 4 > = 5 > 10 6 > ; -1 >Emitted(13, 1) Source(3, 1) + SourceIndex(1) -2 >Emitted(13, 5) Source(3, 5) + SourceIndex(1) -3 >Emitted(13, 7) Source(3, 7) + SourceIndex(1) -4 >Emitted(13, 10) Source(3, 10) + SourceIndex(1) -5 >Emitted(13, 12) Source(3, 12) + SourceIndex(1) -6 >Emitted(13, 13) Source(3, 13) + SourceIndex(1) +1 >Emitted(13, 1) Source(3, 1) + SourceIndex(2) +2 >Emitted(13, 5) Source(3, 5) + SourceIndex(2) +3 >Emitted(13, 7) Source(3, 7) + SourceIndex(2) +4 >Emitted(13, 10) Source(3, 10) + SourceIndex(2) +5 >Emitted(13, 12) Source(3, 12) + SourceIndex(2) +6 >Emitted(13, 13) Source(3, 13) + SourceIndex(2) --- >>>var c1 = (function () { 1-> 2 >^^^^^^^^^^^^^^^^^^^^-> 1-> > -1->Emitted(14, 1) Source(4, 1) + SourceIndex(1) +1->Emitted(14, 1) Source(4, 1) + SourceIndex(2) --- >>> function c1() { 1->^^^^ 2 > ^^-> 1-> -1->Emitted(15, 5) Source(4, 1) + SourceIndex(1) name (c1) +1->Emitted(15, 5) Source(4, 1) + SourceIndex(2) name (c1) --- >>> } 1->^^^^ @@ -377,16 +377,16 @@ sourceFile:test.ts > public p1: number; > 2 > } -1->Emitted(16, 5) Source(6, 1) + SourceIndex(1) name (c1.constructor) -2 >Emitted(16, 6) Source(6, 2) + SourceIndex(1) name (c1.constructor) +1->Emitted(16, 5) Source(6, 1) + SourceIndex(2) name (c1.constructor) +2 >Emitted(16, 6) Source(6, 2) + SourceIndex(2) name (c1.constructor) --- >>> return c1; 1->^^^^ 2 > ^^^^^^^^^ 1-> 2 > } -1->Emitted(17, 5) Source(6, 1) + SourceIndex(1) name (c1) -2 >Emitted(17, 14) Source(6, 2) + SourceIndex(1) name (c1) +1->Emitted(17, 5) Source(6, 1) + SourceIndex(2) name (c1) +2 >Emitted(17, 14) Source(6, 2) + SourceIndex(2) name (c1) --- >>>})(); 1 > @@ -400,10 +400,10 @@ sourceFile:test.ts 4 > class c1 { > public p1: number; > } -1 >Emitted(18, 1) Source(6, 1) + SourceIndex(1) name (c1) -2 >Emitted(18, 2) Source(6, 2) + SourceIndex(1) name (c1) -3 >Emitted(18, 2) Source(4, 1) + SourceIndex(1) -4 >Emitted(18, 6) Source(6, 2) + SourceIndex(1) +1 >Emitted(18, 1) Source(6, 1) + SourceIndex(2) name (c1) +2 >Emitted(18, 2) Source(6, 2) + SourceIndex(2) name (c1) +3 >Emitted(18, 2) Source(4, 1) + SourceIndex(2) +4 >Emitted(18, 6) Source(6, 2) + SourceIndex(2) --- >>>var instance1 = new c1(); 1-> @@ -424,21 +424,21 @@ sourceFile:test.ts 6 > c1 7 > () 8 > ; -1->Emitted(19, 1) Source(8, 1) + SourceIndex(1) -2 >Emitted(19, 5) Source(8, 5) + SourceIndex(1) -3 >Emitted(19, 14) Source(8, 14) + SourceIndex(1) -4 >Emitted(19, 17) Source(8, 17) + SourceIndex(1) -5 >Emitted(19, 21) Source(8, 21) + SourceIndex(1) -6 >Emitted(19, 23) Source(8, 23) + SourceIndex(1) -7 >Emitted(19, 25) Source(8, 25) + SourceIndex(1) -8 >Emitted(19, 26) Source(8, 26) + SourceIndex(1) +1->Emitted(19, 1) Source(8, 1) + SourceIndex(2) +2 >Emitted(19, 5) Source(8, 5) + SourceIndex(2) +3 >Emitted(19, 14) Source(8, 14) + SourceIndex(2) +4 >Emitted(19, 17) Source(8, 17) + SourceIndex(2) +5 >Emitted(19, 21) Source(8, 21) + SourceIndex(2) +6 >Emitted(19, 23) Source(8, 23) + SourceIndex(2) +7 >Emitted(19, 25) Source(8, 25) + SourceIndex(2) +8 >Emitted(19, 26) Source(8, 26) + SourceIndex(2) --- >>>function f1() { 1 > 2 >^^^^^^^^^^^^^^^^^^^^^^-> 1 > > -1 >Emitted(20, 1) Source(9, 1) + SourceIndex(1) +1 >Emitted(20, 1) Source(9, 1) + SourceIndex(2) --- >>> return instance1; 1->^^^^ @@ -452,11 +452,11 @@ sourceFile:test.ts 3 > 4 > instance1 5 > ; -1->Emitted(21, 5) Source(10, 5) + SourceIndex(1) name (f1) -2 >Emitted(21, 11) Source(10, 11) + SourceIndex(1) name (f1) -3 >Emitted(21, 12) Source(10, 12) + SourceIndex(1) name (f1) -4 >Emitted(21, 21) Source(10, 21) + SourceIndex(1) name (f1) -5 >Emitted(21, 22) Source(10, 22) + SourceIndex(1) name (f1) +1->Emitted(21, 5) Source(10, 5) + SourceIndex(2) name (f1) +2 >Emitted(21, 11) Source(10, 11) + SourceIndex(2) name (f1) +3 >Emitted(21, 12) Source(10, 12) + SourceIndex(2) name (f1) +4 >Emitted(21, 21) Source(10, 21) + SourceIndex(2) name (f1) +5 >Emitted(21, 22) Source(10, 22) + SourceIndex(2) name (f1) --- >>>} 1 > @@ -465,7 +465,7 @@ sourceFile:test.ts 1 > > 2 >} -1 >Emitted(22, 1) Source(11, 1) + SourceIndex(1) name (f1) -2 >Emitted(22, 2) Source(11, 2) + SourceIndex(1) name (f1) +1 >Emitted(22, 1) Source(11, 1) + SourceIndex(2) name (f1) +2 >Emitted(22, 2) Source(11, 2) + SourceIndex(2) name (f1) --- >>>//# sourceMappingURL=outAndOutDirFile.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderSpecifyOutputFile/amd/bin/test.d.ts b/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderSpecifyOutputFile/amd/bin/test.d.ts deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderSpecifyOutputFile/amd/bin/test.js b/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderSpecifyOutputFile/amd/bin/test.js deleted file mode 100644 index 6f3fefb9498..00000000000 --- a/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderSpecifyOutputFile/amd/bin/test.js +++ /dev/null @@ -1 +0,0 @@ -//# sourceMappingURL=test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderSpecifyOutputFile/amd/bin/test.js.map b/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderSpecifyOutputFile/amd/bin/test.js.map index 512eba0e11a..39dcc66e06b 100644 --- a/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderSpecifyOutputFile/amd/bin/test.js.map +++ b/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderSpecifyOutputFile/amd/bin/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"../src/","sources":[],"names":[],"mappings":""} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"../src/","sources":["outputdir_module_multifolder/ref/m1.ts","outputdir_module_multifolder_ref/m2.ts","outputdir_module_multifolder/test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","m2_c1","m2_c1.constructor","m2_f1","c1","c1.constructor","f1"],"mappings":";IAAW,aAAK,GAAG,EAAE,CAAC;IACtB;QAAAA;QAEAC,CAACA;QAADD,YAACA;IAADA,CAACA,AAFD,IAEC;IAFY,aAAK,QAEjB,CAAA;IAEU,oBAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACIE,MAAMA,CAACA,oBAAYA,CAACA;IACxBA,CAACA;IAFe,aAAK,QAEpB,CAAA;;;ICRU,aAAK,GAAG,EAAE,CAAC;IACtB;QAAAC;QAEAC,CAACA;QAADD,YAACA;IAADA,CAACA,AAFD,IAEC;IAFY,aAAK,QAEjB,CAAA;IAEU,oBAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACIE,MAAMA,CAACA,oBAAYA,CAACA;IACxBA,CAACA;IAFe,aAAK,QAEpB,CAAA;;;ICNU,UAAE,GAAG,EAAE,CAAC;IACnB;QAAAC;QAEAC,CAACA;QAADD,SAACA;IAADA,CAACA,AAFD,IAEC;IAFY,UAAE,KAEd,CAAA;IAEU,iBAAS,GAAG,IAAI,EAAE,EAAE,CAAC;IAChC;QACIE,MAAMA,CAACA,iBAASA,CAACA;IACrBA,CAACA;IAFe,UAAE,KAEjB,CAAA;IAEU,UAAE,GAAG,EAAE,CAAC,KAAK,CAAC;IACd,UAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderSpecifyOutputFile/amd/sourceRootRelativePathModuleMultifolderSpecifyOutputFile.sourcemap.txt b/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderSpecifyOutputFile/amd/sourceRootRelativePathModuleMultifolderSpecifyOutputFile.sourcemap.txt index 9c817da60e9..b2923025e73 100644 --- a/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderSpecifyOutputFile/amd/sourceRootRelativePathModuleMultifolderSpecifyOutputFile.sourcemap.txt +++ b/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderSpecifyOutputFile/amd/sourceRootRelativePathModuleMultifolderSpecifyOutputFile.sourcemap.txt @@ -571,6 +571,557 @@ sourceFile:outputdir_module_multifolder/test.ts JsFile: test.js mapUrl: test.js.map sourceRoot: ../src/ -sources: +sources: outputdir_module_multifolder/ref/m1.ts,outputdir_module_multifolder_ref/m2.ts,outputdir_module_multifolder/test.ts =================================================================== +------------------------------------------------------------------- +emittedFile:bin/test.js +sourceFile:outputdir_module_multifolder/ref/m1.ts +------------------------------------------------------------------- +>>>define("ref/m1", ["require", "exports"], function (require, exports) { +>>> exports.m1_a1 = 10; +1 >^^^^ +2 > ^^^^^^^^^^^^^ +3 > ^^^ +4 > ^^ +5 > ^ +6 > ^^^^^^^^-> +1 >export var +2 > m1_a1 +3 > = +4 > 10 +5 > ; +1 >Emitted(2, 5) Source(1, 12) + SourceIndex(0) +2 >Emitted(2, 18) Source(1, 17) + SourceIndex(0) +3 >Emitted(2, 21) Source(1, 20) + SourceIndex(0) +4 >Emitted(2, 23) Source(1, 22) + SourceIndex(0) +5 >Emitted(2, 24) Source(1, 23) + SourceIndex(0) +--- +>>> var m1_c1 = (function () { +1->^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^^^^-> +1-> + > +1->Emitted(3, 5) Source(2, 1) + SourceIndex(0) +--- +>>> function m1_c1() { +1->^^^^^^^^ +2 > ^^-> +1-> +1->Emitted(4, 9) Source(2, 1) + SourceIndex(0) name (m1_c1) +--- +>>> } +1->^^^^^^^^ +2 > ^ +3 > ^^^^^^^^^^^^^-> +1->export class m1_c1 { + > public m1_c1_p1: number; + > +2 > } +1->Emitted(5, 9) Source(4, 1) + SourceIndex(0) name (m1_c1.constructor) +2 >Emitted(5, 10) Source(4, 2) + SourceIndex(0) name (m1_c1.constructor) +--- +>>> return m1_c1; +1->^^^^^^^^ +2 > ^^^^^^^^^^^^ +1-> +2 > } +1->Emitted(6, 9) Source(4, 1) + SourceIndex(0) name (m1_c1) +2 >Emitted(6, 21) Source(4, 2) + SourceIndex(0) name (m1_c1) +--- +>>> })(); +1 >^^^^ +2 > ^ +3 > +4 > ^^^^ +5 > ^^^^^^^^^^^^^^^^^^-> +1 > +2 > } +3 > +4 > export class m1_c1 { + > public m1_c1_p1: number; + > } +1 >Emitted(7, 5) Source(4, 1) + SourceIndex(0) name (m1_c1) +2 >Emitted(7, 6) Source(4, 2) + SourceIndex(0) name (m1_c1) +3 >Emitted(7, 6) Source(2, 1) + SourceIndex(0) +4 >Emitted(7, 10) Source(4, 2) + SourceIndex(0) +--- +>>> exports.m1_c1 = m1_c1; +1->^^^^ +2 > ^^^^^^^^^^^^^ +3 > ^^^^^^^^ +4 > ^ +5 > ^^^^^^^^^^^^^^-> +1-> +2 > m1_c1 +3 > { + > public m1_c1_p1: number; + > } +4 > +1->Emitted(8, 5) Source(2, 14) + SourceIndex(0) +2 >Emitted(8, 18) Source(2, 19) + SourceIndex(0) +3 >Emitted(8, 26) Source(4, 2) + SourceIndex(0) +4 >Emitted(8, 27) Source(4, 2) + SourceIndex(0) +--- +>>> exports.m1_instance1 = new m1_c1(); +1->^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^ +3 > ^^^ +4 > ^^^^ +5 > ^^^^^ +6 > ^^ +7 > ^ +1-> + > + >export var +2 > m1_instance1 +3 > = +4 > new +5 > m1_c1 +6 > () +7 > ; +1->Emitted(9, 5) Source(6, 12) + SourceIndex(0) +2 >Emitted(9, 25) Source(6, 24) + SourceIndex(0) +3 >Emitted(9, 28) Source(6, 27) + SourceIndex(0) +4 >Emitted(9, 32) Source(6, 31) + SourceIndex(0) +5 >Emitted(9, 37) Source(6, 36) + SourceIndex(0) +6 >Emitted(9, 39) Source(6, 38) + SourceIndex(0) +7 >Emitted(9, 40) Source(6, 39) + SourceIndex(0) +--- +>>> function m1_f1() { +1 >^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +1 > + > +1 >Emitted(10, 5) Source(7, 1) + SourceIndex(0) +--- +>>> return exports.m1_instance1; +1->^^^^^^^^ +2 > ^^^^^^ +3 > ^ +4 > ^^^^^^^^^^^^^^^^^^^^ +5 > ^ +1->export function m1_f1() { + > +2 > return +3 > +4 > m1_instance1 +5 > ; +1->Emitted(11, 9) Source(8, 5) + SourceIndex(0) name (m1_f1) +2 >Emitted(11, 15) Source(8, 11) + SourceIndex(0) name (m1_f1) +3 >Emitted(11, 16) Source(8, 12) + SourceIndex(0) name (m1_f1) +4 >Emitted(11, 36) Source(8, 24) + SourceIndex(0) name (m1_f1) +5 >Emitted(11, 37) Source(8, 25) + SourceIndex(0) name (m1_f1) +--- +>>> } +1 >^^^^ +2 > ^ +3 > ^^^^^^^^^^^^^^^^^^^^^^-> +1 > + > +2 > } +1 >Emitted(12, 5) Source(9, 1) + SourceIndex(0) name (m1_f1) +2 >Emitted(12, 6) Source(9, 2) + SourceIndex(0) name (m1_f1) +--- +>>> exports.m1_f1 = m1_f1; +1->^^^^ +2 > ^^^^^^^^^^^^^ +3 > ^^^^^^^^ +4 > ^ +1-> +2 > m1_f1 +3 > () { + > return m1_instance1; + > } +4 > +1->Emitted(13, 5) Source(7, 17) + SourceIndex(0) +2 >Emitted(13, 18) Source(7, 22) + SourceIndex(0) +3 >Emitted(13, 26) Source(9, 2) + SourceIndex(0) +4 >Emitted(13, 27) Source(9, 2) + SourceIndex(0) +--- +------------------------------------------------------------------- +emittedFile:bin/test.js +sourceFile:outputdir_module_multifolder_ref/m2.ts +------------------------------------------------------------------- +>>>}); +>>>define("../outputdir_module_multifolder_ref/m2", ["require", "exports"], function (require, exports) { +>>> exports.m2_a1 = 10; +1 >^^^^ +2 > ^^^^^^^^^^^^^ +3 > ^^^ +4 > ^^ +5 > ^ +6 > ^^^^^^^^-> +1 >export var +2 > m2_a1 +3 > = +4 > 10 +5 > ; +1 >Emitted(16, 5) Source(1, 12) + SourceIndex(1) +2 >Emitted(16, 18) Source(1, 17) + SourceIndex(1) +3 >Emitted(16, 21) Source(1, 20) + SourceIndex(1) +4 >Emitted(16, 23) Source(1, 22) + SourceIndex(1) +5 >Emitted(16, 24) Source(1, 23) + SourceIndex(1) +--- +>>> var m2_c1 = (function () { +1->^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^^^^-> +1-> + > +1->Emitted(17, 5) Source(2, 1) + SourceIndex(1) +--- +>>> function m2_c1() { +1->^^^^^^^^ +2 > ^^-> +1-> +1->Emitted(18, 9) Source(2, 1) + SourceIndex(1) name (m2_c1) +--- +>>> } +1->^^^^^^^^ +2 > ^ +3 > ^^^^^^^^^^^^^-> +1->export class m2_c1 { + > public m2_c1_p1: number; + > +2 > } +1->Emitted(19, 9) Source(4, 1) + SourceIndex(1) name (m2_c1.constructor) +2 >Emitted(19, 10) Source(4, 2) + SourceIndex(1) name (m2_c1.constructor) +--- +>>> return m2_c1; +1->^^^^^^^^ +2 > ^^^^^^^^^^^^ +1-> +2 > } +1->Emitted(20, 9) Source(4, 1) + SourceIndex(1) name (m2_c1) +2 >Emitted(20, 21) Source(4, 2) + SourceIndex(1) name (m2_c1) +--- +>>> })(); +1 >^^^^ +2 > ^ +3 > +4 > ^^^^ +5 > ^^^^^^^^^^^^^^^^^^-> +1 > +2 > } +3 > +4 > export class m2_c1 { + > public m2_c1_p1: number; + > } +1 >Emitted(21, 5) Source(4, 1) + SourceIndex(1) name (m2_c1) +2 >Emitted(21, 6) Source(4, 2) + SourceIndex(1) name (m2_c1) +3 >Emitted(21, 6) Source(2, 1) + SourceIndex(1) +4 >Emitted(21, 10) Source(4, 2) + SourceIndex(1) +--- +>>> exports.m2_c1 = m2_c1; +1->^^^^ +2 > ^^^^^^^^^^^^^ +3 > ^^^^^^^^ +4 > ^ +5 > ^^^^^^^^^^^^^^-> +1-> +2 > m2_c1 +3 > { + > public m2_c1_p1: number; + > } +4 > +1->Emitted(22, 5) Source(2, 14) + SourceIndex(1) +2 >Emitted(22, 18) Source(2, 19) + SourceIndex(1) +3 >Emitted(22, 26) Source(4, 2) + SourceIndex(1) +4 >Emitted(22, 27) Source(4, 2) + SourceIndex(1) +--- +>>> exports.m2_instance1 = new m2_c1(); +1->^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^ +3 > ^^^ +4 > ^^^^ +5 > ^^^^^ +6 > ^^ +7 > ^ +1-> + > + >export var +2 > m2_instance1 +3 > = +4 > new +5 > m2_c1 +6 > () +7 > ; +1->Emitted(23, 5) Source(6, 12) + SourceIndex(1) +2 >Emitted(23, 25) Source(6, 24) + SourceIndex(1) +3 >Emitted(23, 28) Source(6, 27) + SourceIndex(1) +4 >Emitted(23, 32) Source(6, 31) + SourceIndex(1) +5 >Emitted(23, 37) Source(6, 36) + SourceIndex(1) +6 >Emitted(23, 39) Source(6, 38) + SourceIndex(1) +7 >Emitted(23, 40) Source(6, 39) + SourceIndex(1) +--- +>>> function m2_f1() { +1 >^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +1 > + > +1 >Emitted(24, 5) Source(7, 1) + SourceIndex(1) +--- +>>> return exports.m2_instance1; +1->^^^^^^^^ +2 > ^^^^^^ +3 > ^ +4 > ^^^^^^^^^^^^^^^^^^^^ +5 > ^ +1->export function m2_f1() { + > +2 > return +3 > +4 > m2_instance1 +5 > ; +1->Emitted(25, 9) Source(8, 5) + SourceIndex(1) name (m2_f1) +2 >Emitted(25, 15) Source(8, 11) + SourceIndex(1) name (m2_f1) +3 >Emitted(25, 16) Source(8, 12) + SourceIndex(1) name (m2_f1) +4 >Emitted(25, 36) Source(8, 24) + SourceIndex(1) name (m2_f1) +5 >Emitted(25, 37) Source(8, 25) + SourceIndex(1) name (m2_f1) +--- +>>> } +1 >^^^^ +2 > ^ +3 > ^^^^^^^^^^^^^^^^^^^^^^-> +1 > + > +2 > } +1 >Emitted(26, 5) Source(9, 1) + SourceIndex(1) name (m2_f1) +2 >Emitted(26, 6) Source(9, 2) + SourceIndex(1) name (m2_f1) +--- +>>> exports.m2_f1 = m2_f1; +1->^^^^ +2 > ^^^^^^^^^^^^^ +3 > ^^^^^^^^ +4 > ^ +1-> +2 > m2_f1 +3 > () { + > return m2_instance1; + > } +4 > +1->Emitted(27, 5) Source(7, 17) + SourceIndex(1) +2 >Emitted(27, 18) Source(7, 22) + SourceIndex(1) +3 >Emitted(27, 26) Source(9, 2) + SourceIndex(1) +4 >Emitted(27, 27) Source(9, 2) + SourceIndex(1) +--- +------------------------------------------------------------------- +emittedFile:bin/test.js +sourceFile:outputdir_module_multifolder/test.ts +------------------------------------------------------------------- +>>>}); +>>>define("test", ["require", "exports", "ref/m1", "../outputdir_module_multifolder_ref/m2"], function (require, exports, m1, m2) { +>>> exports.a1 = 10; +1 >^^^^ +2 > ^^^^^^^^^^ +3 > ^^^ +4 > ^^ +5 > ^ +6 > ^^^^^^^^-> +1 >import m1 = require("ref/m1"); + >import m2 = require("../outputdir_module_multifolder_ref/m2"); + >export var +2 > a1 +3 > = +4 > 10 +5 > ; +1 >Emitted(30, 5) Source(3, 12) + SourceIndex(2) +2 >Emitted(30, 15) Source(3, 14) + SourceIndex(2) +3 >Emitted(30, 18) Source(3, 17) + SourceIndex(2) +4 >Emitted(30, 20) Source(3, 19) + SourceIndex(2) +5 >Emitted(30, 21) Source(3, 20) + SourceIndex(2) +--- +>>> var c1 = (function () { +1->^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^-> +1-> + > +1->Emitted(31, 5) Source(4, 1) + SourceIndex(2) +--- +>>> function c1() { +1->^^^^^^^^ +2 > ^^-> +1-> +1->Emitted(32, 9) Source(4, 1) + SourceIndex(2) name (c1) +--- +>>> } +1->^^^^^^^^ +2 > ^ +3 > ^^^^^^^^^^-> +1->export class c1 { + > public p1: number; + > +2 > } +1->Emitted(33, 9) Source(6, 1) + SourceIndex(2) name (c1.constructor) +2 >Emitted(33, 10) Source(6, 2) + SourceIndex(2) name (c1.constructor) +--- +>>> return c1; +1->^^^^^^^^ +2 > ^^^^^^^^^ +1-> +2 > } +1->Emitted(34, 9) Source(6, 1) + SourceIndex(2) name (c1) +2 >Emitted(34, 18) Source(6, 2) + SourceIndex(2) name (c1) +--- +>>> })(); +1 >^^^^ +2 > ^ +3 > +4 > ^^^^ +5 > ^^^^^^^^^^^^-> +1 > +2 > } +3 > +4 > export class c1 { + > public p1: number; + > } +1 >Emitted(35, 5) Source(6, 1) + SourceIndex(2) name (c1) +2 >Emitted(35, 6) Source(6, 2) + SourceIndex(2) name (c1) +3 >Emitted(35, 6) Source(4, 1) + SourceIndex(2) +4 >Emitted(35, 10) Source(6, 2) + SourceIndex(2) +--- +>>> exports.c1 = c1; +1->^^^^ +2 > ^^^^^^^^^^ +3 > ^^^^^ +4 > ^ +5 > ^^^^^^^^^^^^^^-> +1-> +2 > c1 +3 > { + > public p1: number; + > } +4 > +1->Emitted(36, 5) Source(4, 14) + SourceIndex(2) +2 >Emitted(36, 15) Source(4, 16) + SourceIndex(2) +3 >Emitted(36, 20) Source(6, 2) + SourceIndex(2) +4 >Emitted(36, 21) Source(6, 2) + SourceIndex(2) +--- +>>> exports.instance1 = new c1(); +1->^^^^ +2 > ^^^^^^^^^^^^^^^^^ +3 > ^^^ +4 > ^^^^ +5 > ^^ +6 > ^^ +7 > ^ +1-> + > + >export var +2 > instance1 +3 > = +4 > new +5 > c1 +6 > () +7 > ; +1->Emitted(37, 5) Source(8, 12) + SourceIndex(2) +2 >Emitted(37, 22) Source(8, 21) + SourceIndex(2) +3 >Emitted(37, 25) Source(8, 24) + SourceIndex(2) +4 >Emitted(37, 29) Source(8, 28) + SourceIndex(2) +5 >Emitted(37, 31) Source(8, 30) + SourceIndex(2) +6 >Emitted(37, 33) Source(8, 32) + SourceIndex(2) +7 >Emitted(37, 34) Source(8, 33) + SourceIndex(2) +--- +>>> function f1() { +1 >^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +1 > + > +1 >Emitted(38, 5) Source(9, 1) + SourceIndex(2) +--- +>>> return exports.instance1; +1->^^^^^^^^ +2 > ^^^^^^ +3 > ^ +4 > ^^^^^^^^^^^^^^^^^ +5 > ^ +1->export function f1() { + > +2 > return +3 > +4 > instance1 +5 > ; +1->Emitted(39, 9) Source(10, 5) + SourceIndex(2) name (f1) +2 >Emitted(39, 15) Source(10, 11) + SourceIndex(2) name (f1) +3 >Emitted(39, 16) Source(10, 12) + SourceIndex(2) name (f1) +4 >Emitted(39, 33) Source(10, 21) + SourceIndex(2) name (f1) +5 >Emitted(39, 34) Source(10, 22) + SourceIndex(2) name (f1) +--- +>>> } +1 >^^^^ +2 > ^ +3 > ^^^^^^^^^^^^^^^^-> +1 > + > +2 > } +1 >Emitted(40, 5) Source(11, 1) + SourceIndex(2) name (f1) +2 >Emitted(40, 6) Source(11, 2) + SourceIndex(2) name (f1) +--- +>>> exports.f1 = f1; +1->^^^^ +2 > ^^^^^^^^^^ +3 > ^^^^^ +4 > ^ +5 > ^^^^^^^-> +1-> +2 > f1 +3 > () { + > return instance1; + > } +4 > +1->Emitted(41, 5) Source(9, 17) + SourceIndex(2) +2 >Emitted(41, 15) Source(9, 19) + SourceIndex(2) +3 >Emitted(41, 20) Source(11, 2) + SourceIndex(2) +4 >Emitted(41, 21) Source(11, 2) + SourceIndex(2) +--- +>>> exports.a2 = m1.m1_c1; +1->^^^^ +2 > ^^^^^^^^^^ +3 > ^^^ +4 > ^^ +5 > ^ +6 > ^^^^^ +7 > ^ +8 > ^-> +1-> + > + >export var +2 > a2 +3 > = +4 > m1 +5 > . +6 > m1_c1 +7 > ; +1->Emitted(42, 5) Source(13, 12) + SourceIndex(2) +2 >Emitted(42, 15) Source(13, 14) + SourceIndex(2) +3 >Emitted(42, 18) Source(13, 17) + SourceIndex(2) +4 >Emitted(42, 20) Source(13, 19) + SourceIndex(2) +5 >Emitted(42, 21) Source(13, 20) + SourceIndex(2) +6 >Emitted(42, 26) Source(13, 25) + SourceIndex(2) +7 >Emitted(42, 27) Source(13, 26) + SourceIndex(2) +--- +>>> exports.a3 = m2.m2_c1; +1->^^^^ +2 > ^^^^^^^^^^ +3 > ^^^ +4 > ^^ +5 > ^ +6 > ^^^^^ +7 > ^ +1-> + >export var +2 > a3 +3 > = +4 > m2 +5 > . +6 > m2_c1 +7 > ; +1->Emitted(43, 5) Source(14, 12) + SourceIndex(2) +2 >Emitted(43, 15) Source(14, 14) + SourceIndex(2) +3 >Emitted(43, 18) Source(14, 17) + SourceIndex(2) +4 >Emitted(43, 20) Source(14, 19) + SourceIndex(2) +5 >Emitted(43, 21) Source(14, 20) + SourceIndex(2) +6 >Emitted(43, 26) Source(14, 25) + SourceIndex(2) +7 >Emitted(43, 27) Source(14, 26) + SourceIndex(2) +--- +>>>}); >>>//# sourceMappingURL=test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderSpecifyOutputFile/node/bin/test.d.ts b/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderSpecifyOutputFile/node/bin/test.d.ts deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderSpecifyOutputFile/node/bin/test.js b/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderSpecifyOutputFile/node/bin/test.js deleted file mode 100644 index 6f3fefb9498..00000000000 --- a/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderSpecifyOutputFile/node/bin/test.js +++ /dev/null @@ -1 +0,0 @@ -//# sourceMappingURL=test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderSpecifyOutputFile/node/bin/test.js.map b/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderSpecifyOutputFile/node/bin/test.js.map index 512eba0e11a..a3ab2ebecdb 100644 --- a/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderSpecifyOutputFile/node/bin/test.js.map +++ b/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderSpecifyOutputFile/node/bin/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"../src/","sources":[],"names":[],"mappings":""} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"../src/","sources":["outputdir_module_multifolder/ref/m1.ts","outputdir_module_multifolder_ref/m2.ts","outputdir_module_multifolder/test.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderSpecifyOutputFile/node/sourceRootRelativePathModuleMultifolderSpecifyOutputFile.sourcemap.txt b/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderSpecifyOutputFile/node/sourceRootRelativePathModuleMultifolderSpecifyOutputFile.sourcemap.txt index e34bffc6f61..c0077fe3214 100644 --- a/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderSpecifyOutputFile/node/sourceRootRelativePathModuleMultifolderSpecifyOutputFile.sourcemap.txt +++ b/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderSpecifyOutputFile/node/sourceRootRelativePathModuleMultifolderSpecifyOutputFile.sourcemap.txt @@ -615,6 +615,6 @@ sourceFile:outputdir_module_multifolder/test.ts JsFile: test.js mapUrl: test.js.map sourceRoot: ../src/ -sources: +sources: outputdir_module_multifolder/ref/m1.ts,outputdir_module_multifolder_ref/m2.ts,outputdir_module_multifolder/test.ts =================================================================== >>>//# sourceMappingURL=test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootRelativePathModuleSimpleSpecifyOutputFile/amd/bin/test.d.ts b/tests/baselines/reference/project/sourceRootRelativePathModuleSimpleSpecifyOutputFile/amd/bin/test.d.ts deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/tests/baselines/reference/project/sourceRootRelativePathModuleSimpleSpecifyOutputFile/amd/bin/test.js b/tests/baselines/reference/project/sourceRootRelativePathModuleSimpleSpecifyOutputFile/amd/bin/test.js deleted file mode 100644 index 6f3fefb9498..00000000000 --- a/tests/baselines/reference/project/sourceRootRelativePathModuleSimpleSpecifyOutputFile/amd/bin/test.js +++ /dev/null @@ -1 +0,0 @@ -//# sourceMappingURL=test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootRelativePathModuleSimpleSpecifyOutputFile/amd/bin/test.js.map b/tests/baselines/reference/project/sourceRootRelativePathModuleSimpleSpecifyOutputFile/amd/bin/test.js.map index 512eba0e11a..262e5cdc1f3 100644 --- a/tests/baselines/reference/project/sourceRootRelativePathModuleSimpleSpecifyOutputFile/amd/bin/test.js.map +++ b/tests/baselines/reference/project/sourceRootRelativePathModuleSimpleSpecifyOutputFile/amd/bin/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"../src/","sources":[],"names":[],"mappings":""} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"../src/","sources":["m1.ts","test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","c1","c1.constructor","f1"],"mappings":";IAAW,aAAK,GAAG,EAAE,CAAC;IACtB;QAAAA;QAEAC,CAACA;QAADD,YAACA;IAADA,CAACA,AAFD,IAEC;IAFY,aAAK,QAEjB,CAAA;IAEU,oBAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACIE,MAAMA,CAACA,oBAAYA,CAACA;IACxBA,CAACA;IAFe,aAAK,QAEpB,CAAA;;;ICPU,UAAE,GAAG,EAAE,CAAC;IACnB;QAAAC;QAEAC,CAACA;QAADD,SAACA;IAADA,CAACA,AAFD,IAEC;IAFY,UAAE,KAEd,CAAA;IAEU,iBAAS,GAAG,IAAI,EAAE,EAAE,CAAC;IAChC;QACIE,MAAMA,CAACA,iBAASA,CAACA;IACrBA,CAACA;IAFe,UAAE,KAEjB,CAAA;IAEU,UAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootRelativePathModuleSimpleSpecifyOutputFile/amd/sourceRootRelativePathModuleSimpleSpecifyOutputFile.sourcemap.txt b/tests/baselines/reference/project/sourceRootRelativePathModuleSimpleSpecifyOutputFile/amd/sourceRootRelativePathModuleSimpleSpecifyOutputFile.sourcemap.txt index c259bb45210..97323d5d307 100644 --- a/tests/baselines/reference/project/sourceRootRelativePathModuleSimpleSpecifyOutputFile/amd/sourceRootRelativePathModuleSimpleSpecifyOutputFile.sourcemap.txt +++ b/tests/baselines/reference/project/sourceRootRelativePathModuleSimpleSpecifyOutputFile/amd/sourceRootRelativePathModuleSimpleSpecifyOutputFile.sourcemap.txt @@ -373,6 +373,365 @@ sourceFile:test.ts JsFile: test.js mapUrl: test.js.map sourceRoot: ../src/ -sources: +sources: m1.ts,test.ts =================================================================== +------------------------------------------------------------------- +emittedFile:bin/test.js +sourceFile:m1.ts +------------------------------------------------------------------- +>>>define("m1", ["require", "exports"], function (require, exports) { +>>> exports.m1_a1 = 10; +1 >^^^^ +2 > ^^^^^^^^^^^^^ +3 > ^^^ +4 > ^^ +5 > ^ +6 > ^^^^^^^^-> +1 >export var +2 > m1_a1 +3 > = +4 > 10 +5 > ; +1 >Emitted(2, 5) Source(1, 12) + SourceIndex(0) +2 >Emitted(2, 18) Source(1, 17) + SourceIndex(0) +3 >Emitted(2, 21) Source(1, 20) + SourceIndex(0) +4 >Emitted(2, 23) Source(1, 22) + SourceIndex(0) +5 >Emitted(2, 24) Source(1, 23) + SourceIndex(0) +--- +>>> var m1_c1 = (function () { +1->^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^^^^-> +1-> + > +1->Emitted(3, 5) Source(2, 1) + SourceIndex(0) +--- +>>> function m1_c1() { +1->^^^^^^^^ +2 > ^^-> +1-> +1->Emitted(4, 9) Source(2, 1) + SourceIndex(0) name (m1_c1) +--- +>>> } +1->^^^^^^^^ +2 > ^ +3 > ^^^^^^^^^^^^^-> +1->export class m1_c1 { + > public m1_c1_p1: number; + > +2 > } +1->Emitted(5, 9) Source(4, 1) + SourceIndex(0) name (m1_c1.constructor) +2 >Emitted(5, 10) Source(4, 2) + SourceIndex(0) name (m1_c1.constructor) +--- +>>> return m1_c1; +1->^^^^^^^^ +2 > ^^^^^^^^^^^^ +1-> +2 > } +1->Emitted(6, 9) Source(4, 1) + SourceIndex(0) name (m1_c1) +2 >Emitted(6, 21) Source(4, 2) + SourceIndex(0) name (m1_c1) +--- +>>> })(); +1 >^^^^ +2 > ^ +3 > +4 > ^^^^ +5 > ^^^^^^^^^^^^^^^^^^-> +1 > +2 > } +3 > +4 > export class m1_c1 { + > public m1_c1_p1: number; + > } +1 >Emitted(7, 5) Source(4, 1) + SourceIndex(0) name (m1_c1) +2 >Emitted(7, 6) Source(4, 2) + SourceIndex(0) name (m1_c1) +3 >Emitted(7, 6) Source(2, 1) + SourceIndex(0) +4 >Emitted(7, 10) Source(4, 2) + SourceIndex(0) +--- +>>> exports.m1_c1 = m1_c1; +1->^^^^ +2 > ^^^^^^^^^^^^^ +3 > ^^^^^^^^ +4 > ^ +5 > ^^^^^^^^^^^^^^-> +1-> +2 > m1_c1 +3 > { + > public m1_c1_p1: number; + > } +4 > +1->Emitted(8, 5) Source(2, 14) + SourceIndex(0) +2 >Emitted(8, 18) Source(2, 19) + SourceIndex(0) +3 >Emitted(8, 26) Source(4, 2) + SourceIndex(0) +4 >Emitted(8, 27) Source(4, 2) + SourceIndex(0) +--- +>>> exports.m1_instance1 = new m1_c1(); +1->^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^ +3 > ^^^ +4 > ^^^^ +5 > ^^^^^ +6 > ^^ +7 > ^ +1-> + > + >export var +2 > m1_instance1 +3 > = +4 > new +5 > m1_c1 +6 > () +7 > ; +1->Emitted(9, 5) Source(6, 12) + SourceIndex(0) +2 >Emitted(9, 25) Source(6, 24) + SourceIndex(0) +3 >Emitted(9, 28) Source(6, 27) + SourceIndex(0) +4 >Emitted(9, 32) Source(6, 31) + SourceIndex(0) +5 >Emitted(9, 37) Source(6, 36) + SourceIndex(0) +6 >Emitted(9, 39) Source(6, 38) + SourceIndex(0) +7 >Emitted(9, 40) Source(6, 39) + SourceIndex(0) +--- +>>> function m1_f1() { +1 >^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +1 > + > +1 >Emitted(10, 5) Source(7, 1) + SourceIndex(0) +--- +>>> return exports.m1_instance1; +1->^^^^^^^^ +2 > ^^^^^^ +3 > ^ +4 > ^^^^^^^^^^^^^^^^^^^^ +5 > ^ +1->export function m1_f1() { + > +2 > return +3 > +4 > m1_instance1 +5 > ; +1->Emitted(11, 9) Source(8, 5) + SourceIndex(0) name (m1_f1) +2 >Emitted(11, 15) Source(8, 11) + SourceIndex(0) name (m1_f1) +3 >Emitted(11, 16) Source(8, 12) + SourceIndex(0) name (m1_f1) +4 >Emitted(11, 36) Source(8, 24) + SourceIndex(0) name (m1_f1) +5 >Emitted(11, 37) Source(8, 25) + SourceIndex(0) name (m1_f1) +--- +>>> } +1 >^^^^ +2 > ^ +3 > ^^^^^^^^^^^^^^^^^^^^^^-> +1 > + > +2 > } +1 >Emitted(12, 5) Source(9, 1) + SourceIndex(0) name (m1_f1) +2 >Emitted(12, 6) Source(9, 2) + SourceIndex(0) name (m1_f1) +--- +>>> exports.m1_f1 = m1_f1; +1->^^^^ +2 > ^^^^^^^^^^^^^ +3 > ^^^^^^^^ +4 > ^ +1-> +2 > m1_f1 +3 > () { + > return m1_instance1; + > } +4 > +1->Emitted(13, 5) Source(7, 17) + SourceIndex(0) +2 >Emitted(13, 18) Source(7, 22) + SourceIndex(0) +3 >Emitted(13, 26) Source(9, 2) + SourceIndex(0) +4 >Emitted(13, 27) Source(9, 2) + SourceIndex(0) +--- +------------------------------------------------------------------- +emittedFile:bin/test.js +sourceFile:test.ts +------------------------------------------------------------------- +>>>}); +>>>define("test", ["require", "exports", "m1"], function (require, exports, m1) { +>>> exports.a1 = 10; +1 >^^^^ +2 > ^^^^^^^^^^ +3 > ^^^ +4 > ^^ +5 > ^ +6 > ^^^^^^^^-> +1 >import m1 = require("m1"); + >export var +2 > a1 +3 > = +4 > 10 +5 > ; +1 >Emitted(16, 5) Source(2, 12) + SourceIndex(1) +2 >Emitted(16, 15) Source(2, 14) + SourceIndex(1) +3 >Emitted(16, 18) Source(2, 17) + SourceIndex(1) +4 >Emitted(16, 20) Source(2, 19) + SourceIndex(1) +5 >Emitted(16, 21) Source(2, 20) + SourceIndex(1) +--- +>>> var c1 = (function () { +1->^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^-> +1-> + > +1->Emitted(17, 5) Source(3, 1) + SourceIndex(1) +--- +>>> function c1() { +1->^^^^^^^^ +2 > ^^-> +1-> +1->Emitted(18, 9) Source(3, 1) + SourceIndex(1) name (c1) +--- +>>> } +1->^^^^^^^^ +2 > ^ +3 > ^^^^^^^^^^-> +1->export class c1 { + > public p1: number; + > +2 > } +1->Emitted(19, 9) Source(5, 1) + SourceIndex(1) name (c1.constructor) +2 >Emitted(19, 10) Source(5, 2) + SourceIndex(1) name (c1.constructor) +--- +>>> return c1; +1->^^^^^^^^ +2 > ^^^^^^^^^ +1-> +2 > } +1->Emitted(20, 9) Source(5, 1) + SourceIndex(1) name (c1) +2 >Emitted(20, 18) Source(5, 2) + SourceIndex(1) name (c1) +--- +>>> })(); +1 >^^^^ +2 > ^ +3 > +4 > ^^^^ +5 > ^^^^^^^^^^^^-> +1 > +2 > } +3 > +4 > export class c1 { + > public p1: number; + > } +1 >Emitted(21, 5) Source(5, 1) + SourceIndex(1) name (c1) +2 >Emitted(21, 6) Source(5, 2) + SourceIndex(1) name (c1) +3 >Emitted(21, 6) Source(3, 1) + SourceIndex(1) +4 >Emitted(21, 10) Source(5, 2) + SourceIndex(1) +--- +>>> exports.c1 = c1; +1->^^^^ +2 > ^^^^^^^^^^ +3 > ^^^^^ +4 > ^ +5 > ^^^^^^^^^^^^^^-> +1-> +2 > c1 +3 > { + > public p1: number; + > } +4 > +1->Emitted(22, 5) Source(3, 14) + SourceIndex(1) +2 >Emitted(22, 15) Source(3, 16) + SourceIndex(1) +3 >Emitted(22, 20) Source(5, 2) + SourceIndex(1) +4 >Emitted(22, 21) Source(5, 2) + SourceIndex(1) +--- +>>> exports.instance1 = new c1(); +1->^^^^ +2 > ^^^^^^^^^^^^^^^^^ +3 > ^^^ +4 > ^^^^ +5 > ^^ +6 > ^^ +7 > ^ +1-> + > + >export var +2 > instance1 +3 > = +4 > new +5 > c1 +6 > () +7 > ; +1->Emitted(23, 5) Source(7, 12) + SourceIndex(1) +2 >Emitted(23, 22) Source(7, 21) + SourceIndex(1) +3 >Emitted(23, 25) Source(7, 24) + SourceIndex(1) +4 >Emitted(23, 29) Source(7, 28) + SourceIndex(1) +5 >Emitted(23, 31) Source(7, 30) + SourceIndex(1) +6 >Emitted(23, 33) Source(7, 32) + SourceIndex(1) +7 >Emitted(23, 34) Source(7, 33) + SourceIndex(1) +--- +>>> function f1() { +1 >^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +1 > + > +1 >Emitted(24, 5) Source(8, 1) + SourceIndex(1) +--- +>>> return exports.instance1; +1->^^^^^^^^ +2 > ^^^^^^ +3 > ^ +4 > ^^^^^^^^^^^^^^^^^ +5 > ^ +1->export function f1() { + > +2 > return +3 > +4 > instance1 +5 > ; +1->Emitted(25, 9) Source(9, 5) + SourceIndex(1) name (f1) +2 >Emitted(25, 15) Source(9, 11) + SourceIndex(1) name (f1) +3 >Emitted(25, 16) Source(9, 12) + SourceIndex(1) name (f1) +4 >Emitted(25, 33) Source(9, 21) + SourceIndex(1) name (f1) +5 >Emitted(25, 34) Source(9, 22) + SourceIndex(1) name (f1) +--- +>>> } +1 >^^^^ +2 > ^ +3 > ^^^^^^^^^^^^^^^^-> +1 > + > +2 > } +1 >Emitted(26, 5) Source(10, 1) + SourceIndex(1) name (f1) +2 >Emitted(26, 6) Source(10, 2) + SourceIndex(1) name (f1) +--- +>>> exports.f1 = f1; +1->^^^^ +2 > ^^^^^^^^^^ +3 > ^^^^^ +4 > ^ +5 > ^^^^^^^-> +1-> +2 > f1 +3 > () { + > return instance1; + > } +4 > +1->Emitted(27, 5) Source(8, 17) + SourceIndex(1) +2 >Emitted(27, 15) Source(8, 19) + SourceIndex(1) +3 >Emitted(27, 20) Source(10, 2) + SourceIndex(1) +4 >Emitted(27, 21) Source(10, 2) + SourceIndex(1) +--- +>>> exports.a2 = m1.m1_c1; +1->^^^^ +2 > ^^^^^^^^^^ +3 > ^^^ +4 > ^^ +5 > ^ +6 > ^^^^^ +7 > ^ +1-> + > + >export var +2 > a2 +3 > = +4 > m1 +5 > . +6 > m1_c1 +7 > ; +1->Emitted(28, 5) Source(12, 12) + SourceIndex(1) +2 >Emitted(28, 15) Source(12, 14) + SourceIndex(1) +3 >Emitted(28, 18) Source(12, 17) + SourceIndex(1) +4 >Emitted(28, 20) Source(12, 19) + SourceIndex(1) +5 >Emitted(28, 21) Source(12, 20) + SourceIndex(1) +6 >Emitted(28, 26) Source(12, 25) + SourceIndex(1) +7 >Emitted(28, 27) Source(12, 26) + SourceIndex(1) +--- +>>>}); >>>//# sourceMappingURL=test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootRelativePathModuleSimpleSpecifyOutputFile/node/bin/test.d.ts b/tests/baselines/reference/project/sourceRootRelativePathModuleSimpleSpecifyOutputFile/node/bin/test.d.ts deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/tests/baselines/reference/project/sourceRootRelativePathModuleSimpleSpecifyOutputFile/node/bin/test.js b/tests/baselines/reference/project/sourceRootRelativePathModuleSimpleSpecifyOutputFile/node/bin/test.js deleted file mode 100644 index 6f3fefb9498..00000000000 --- a/tests/baselines/reference/project/sourceRootRelativePathModuleSimpleSpecifyOutputFile/node/bin/test.js +++ /dev/null @@ -1 +0,0 @@ -//# sourceMappingURL=test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootRelativePathModuleSimpleSpecifyOutputFile/node/bin/test.js.map b/tests/baselines/reference/project/sourceRootRelativePathModuleSimpleSpecifyOutputFile/node/bin/test.js.map index 512eba0e11a..f55a72e7977 100644 --- a/tests/baselines/reference/project/sourceRootRelativePathModuleSimpleSpecifyOutputFile/node/bin/test.js.map +++ b/tests/baselines/reference/project/sourceRootRelativePathModuleSimpleSpecifyOutputFile/node/bin/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"../src/","sources":[],"names":[],"mappings":""} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"../src/","sources":["m1.ts","test.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootRelativePathModuleSimpleSpecifyOutputFile/node/sourceRootRelativePathModuleSimpleSpecifyOutputFile.sourcemap.txt b/tests/baselines/reference/project/sourceRootRelativePathModuleSimpleSpecifyOutputFile/node/sourceRootRelativePathModuleSimpleSpecifyOutputFile.sourcemap.txt index 65bea50d84f..b38468c878d 100644 --- a/tests/baselines/reference/project/sourceRootRelativePathModuleSimpleSpecifyOutputFile/node/sourceRootRelativePathModuleSimpleSpecifyOutputFile.sourcemap.txt +++ b/tests/baselines/reference/project/sourceRootRelativePathModuleSimpleSpecifyOutputFile/node/sourceRootRelativePathModuleSimpleSpecifyOutputFile.sourcemap.txt @@ -394,6 +394,6 @@ sourceFile:test.ts JsFile: test.js mapUrl: test.js.map sourceRoot: ../src/ -sources: +sources: m1.ts,test.ts =================================================================== >>>//# sourceMappingURL=test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootRelativePathModuleSubfolderSpecifyOutputFile/amd/bin/test.d.ts b/tests/baselines/reference/project/sourceRootRelativePathModuleSubfolderSpecifyOutputFile/amd/bin/test.d.ts deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/tests/baselines/reference/project/sourceRootRelativePathModuleSubfolderSpecifyOutputFile/amd/bin/test.js b/tests/baselines/reference/project/sourceRootRelativePathModuleSubfolderSpecifyOutputFile/amd/bin/test.js deleted file mode 100644 index 6f3fefb9498..00000000000 --- a/tests/baselines/reference/project/sourceRootRelativePathModuleSubfolderSpecifyOutputFile/amd/bin/test.js +++ /dev/null @@ -1 +0,0 @@ -//# sourceMappingURL=test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootRelativePathModuleSubfolderSpecifyOutputFile/amd/bin/test.js.map b/tests/baselines/reference/project/sourceRootRelativePathModuleSubfolderSpecifyOutputFile/amd/bin/test.js.map index 512eba0e11a..dc294ebd160 100644 --- a/tests/baselines/reference/project/sourceRootRelativePathModuleSubfolderSpecifyOutputFile/amd/bin/test.js.map +++ b/tests/baselines/reference/project/sourceRootRelativePathModuleSubfolderSpecifyOutputFile/amd/bin/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"../src/","sources":[],"names":[],"mappings":""} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"../src/","sources":["ref/m1.ts","test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","c1","c1.constructor","f1"],"mappings":";IAAW,aAAK,GAAG,EAAE,CAAC;IACtB;QAAAA;QAEAC,CAACA;QAADD,YAACA;IAADA,CAACA,AAFD,IAEC;IAFY,aAAK,QAEjB,CAAA;IAEU,oBAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACIE,MAAMA,CAACA,oBAAYA,CAACA;IACxBA,CAACA;IAFe,aAAK,QAEpB,CAAA;;;ICPU,UAAE,GAAG,EAAE,CAAC;IACnB;QAAAC;QAEAC,CAACA;QAADD,SAACA;IAADA,CAACA,AAFD,IAEC;IAFY,UAAE,KAEd,CAAA;IAEU,iBAAS,GAAG,IAAI,EAAE,EAAE,CAAC;IAChC;QACIE,MAAMA,CAACA,iBAASA,CAACA;IACrBA,CAACA;IAFe,UAAE,KAEjB,CAAA;IAEU,UAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootRelativePathModuleSubfolderSpecifyOutputFile/amd/sourceRootRelativePathModuleSubfolderSpecifyOutputFile.sourcemap.txt b/tests/baselines/reference/project/sourceRootRelativePathModuleSubfolderSpecifyOutputFile/amd/sourceRootRelativePathModuleSubfolderSpecifyOutputFile.sourcemap.txt index 7be1fe1fb8f..e754942b588 100644 --- a/tests/baselines/reference/project/sourceRootRelativePathModuleSubfolderSpecifyOutputFile/amd/sourceRootRelativePathModuleSubfolderSpecifyOutputFile.sourcemap.txt +++ b/tests/baselines/reference/project/sourceRootRelativePathModuleSubfolderSpecifyOutputFile/amd/sourceRootRelativePathModuleSubfolderSpecifyOutputFile.sourcemap.txt @@ -373,6 +373,365 @@ sourceFile:test.ts JsFile: test.js mapUrl: test.js.map sourceRoot: ../src/ -sources: +sources: ref/m1.ts,test.ts =================================================================== +------------------------------------------------------------------- +emittedFile:bin/test.js +sourceFile:ref/m1.ts +------------------------------------------------------------------- +>>>define("ref/m1", ["require", "exports"], function (require, exports) { +>>> exports.m1_a1 = 10; +1 >^^^^ +2 > ^^^^^^^^^^^^^ +3 > ^^^ +4 > ^^ +5 > ^ +6 > ^^^^^^^^-> +1 >export var +2 > m1_a1 +3 > = +4 > 10 +5 > ; +1 >Emitted(2, 5) Source(1, 12) + SourceIndex(0) +2 >Emitted(2, 18) Source(1, 17) + SourceIndex(0) +3 >Emitted(2, 21) Source(1, 20) + SourceIndex(0) +4 >Emitted(2, 23) Source(1, 22) + SourceIndex(0) +5 >Emitted(2, 24) Source(1, 23) + SourceIndex(0) +--- +>>> var m1_c1 = (function () { +1->^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^^^^-> +1-> + > +1->Emitted(3, 5) Source(2, 1) + SourceIndex(0) +--- +>>> function m1_c1() { +1->^^^^^^^^ +2 > ^^-> +1-> +1->Emitted(4, 9) Source(2, 1) + SourceIndex(0) name (m1_c1) +--- +>>> } +1->^^^^^^^^ +2 > ^ +3 > ^^^^^^^^^^^^^-> +1->export class m1_c1 { + > public m1_c1_p1: number; + > +2 > } +1->Emitted(5, 9) Source(4, 1) + SourceIndex(0) name (m1_c1.constructor) +2 >Emitted(5, 10) Source(4, 2) + SourceIndex(0) name (m1_c1.constructor) +--- +>>> return m1_c1; +1->^^^^^^^^ +2 > ^^^^^^^^^^^^ +1-> +2 > } +1->Emitted(6, 9) Source(4, 1) + SourceIndex(0) name (m1_c1) +2 >Emitted(6, 21) Source(4, 2) + SourceIndex(0) name (m1_c1) +--- +>>> })(); +1 >^^^^ +2 > ^ +3 > +4 > ^^^^ +5 > ^^^^^^^^^^^^^^^^^^-> +1 > +2 > } +3 > +4 > export class m1_c1 { + > public m1_c1_p1: number; + > } +1 >Emitted(7, 5) Source(4, 1) + SourceIndex(0) name (m1_c1) +2 >Emitted(7, 6) Source(4, 2) + SourceIndex(0) name (m1_c1) +3 >Emitted(7, 6) Source(2, 1) + SourceIndex(0) +4 >Emitted(7, 10) Source(4, 2) + SourceIndex(0) +--- +>>> exports.m1_c1 = m1_c1; +1->^^^^ +2 > ^^^^^^^^^^^^^ +3 > ^^^^^^^^ +4 > ^ +5 > ^^^^^^^^^^^^^^-> +1-> +2 > m1_c1 +3 > { + > public m1_c1_p1: number; + > } +4 > +1->Emitted(8, 5) Source(2, 14) + SourceIndex(0) +2 >Emitted(8, 18) Source(2, 19) + SourceIndex(0) +3 >Emitted(8, 26) Source(4, 2) + SourceIndex(0) +4 >Emitted(8, 27) Source(4, 2) + SourceIndex(0) +--- +>>> exports.m1_instance1 = new m1_c1(); +1->^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^ +3 > ^^^ +4 > ^^^^ +5 > ^^^^^ +6 > ^^ +7 > ^ +1-> + > + >export var +2 > m1_instance1 +3 > = +4 > new +5 > m1_c1 +6 > () +7 > ; +1->Emitted(9, 5) Source(6, 12) + SourceIndex(0) +2 >Emitted(9, 25) Source(6, 24) + SourceIndex(0) +3 >Emitted(9, 28) Source(6, 27) + SourceIndex(0) +4 >Emitted(9, 32) Source(6, 31) + SourceIndex(0) +5 >Emitted(9, 37) Source(6, 36) + SourceIndex(0) +6 >Emitted(9, 39) Source(6, 38) + SourceIndex(0) +7 >Emitted(9, 40) Source(6, 39) + SourceIndex(0) +--- +>>> function m1_f1() { +1 >^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +1 > + > +1 >Emitted(10, 5) Source(7, 1) + SourceIndex(0) +--- +>>> return exports.m1_instance1; +1->^^^^^^^^ +2 > ^^^^^^ +3 > ^ +4 > ^^^^^^^^^^^^^^^^^^^^ +5 > ^ +1->export function m1_f1() { + > +2 > return +3 > +4 > m1_instance1 +5 > ; +1->Emitted(11, 9) Source(8, 5) + SourceIndex(0) name (m1_f1) +2 >Emitted(11, 15) Source(8, 11) + SourceIndex(0) name (m1_f1) +3 >Emitted(11, 16) Source(8, 12) + SourceIndex(0) name (m1_f1) +4 >Emitted(11, 36) Source(8, 24) + SourceIndex(0) name (m1_f1) +5 >Emitted(11, 37) Source(8, 25) + SourceIndex(0) name (m1_f1) +--- +>>> } +1 >^^^^ +2 > ^ +3 > ^^^^^^^^^^^^^^^^^^^^^^-> +1 > + > +2 > } +1 >Emitted(12, 5) Source(9, 1) + SourceIndex(0) name (m1_f1) +2 >Emitted(12, 6) Source(9, 2) + SourceIndex(0) name (m1_f1) +--- +>>> exports.m1_f1 = m1_f1; +1->^^^^ +2 > ^^^^^^^^^^^^^ +3 > ^^^^^^^^ +4 > ^ +1-> +2 > m1_f1 +3 > () { + > return m1_instance1; + > } +4 > +1->Emitted(13, 5) Source(7, 17) + SourceIndex(0) +2 >Emitted(13, 18) Source(7, 22) + SourceIndex(0) +3 >Emitted(13, 26) Source(9, 2) + SourceIndex(0) +4 >Emitted(13, 27) Source(9, 2) + SourceIndex(0) +--- +------------------------------------------------------------------- +emittedFile:bin/test.js +sourceFile:test.ts +------------------------------------------------------------------- +>>>}); +>>>define("test", ["require", "exports", "ref/m1"], function (require, exports, m1) { +>>> exports.a1 = 10; +1 >^^^^ +2 > ^^^^^^^^^^ +3 > ^^^ +4 > ^^ +5 > ^ +6 > ^^^^^^^^-> +1 >import m1 = require("ref/m1"); + >export var +2 > a1 +3 > = +4 > 10 +5 > ; +1 >Emitted(16, 5) Source(2, 12) + SourceIndex(1) +2 >Emitted(16, 15) Source(2, 14) + SourceIndex(1) +3 >Emitted(16, 18) Source(2, 17) + SourceIndex(1) +4 >Emitted(16, 20) Source(2, 19) + SourceIndex(1) +5 >Emitted(16, 21) Source(2, 20) + SourceIndex(1) +--- +>>> var c1 = (function () { +1->^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^-> +1-> + > +1->Emitted(17, 5) Source(3, 1) + SourceIndex(1) +--- +>>> function c1() { +1->^^^^^^^^ +2 > ^^-> +1-> +1->Emitted(18, 9) Source(3, 1) + SourceIndex(1) name (c1) +--- +>>> } +1->^^^^^^^^ +2 > ^ +3 > ^^^^^^^^^^-> +1->export class c1 { + > public p1: number; + > +2 > } +1->Emitted(19, 9) Source(5, 1) + SourceIndex(1) name (c1.constructor) +2 >Emitted(19, 10) Source(5, 2) + SourceIndex(1) name (c1.constructor) +--- +>>> return c1; +1->^^^^^^^^ +2 > ^^^^^^^^^ +1-> +2 > } +1->Emitted(20, 9) Source(5, 1) + SourceIndex(1) name (c1) +2 >Emitted(20, 18) Source(5, 2) + SourceIndex(1) name (c1) +--- +>>> })(); +1 >^^^^ +2 > ^ +3 > +4 > ^^^^ +5 > ^^^^^^^^^^^^-> +1 > +2 > } +3 > +4 > export class c1 { + > public p1: number; + > } +1 >Emitted(21, 5) Source(5, 1) + SourceIndex(1) name (c1) +2 >Emitted(21, 6) Source(5, 2) + SourceIndex(1) name (c1) +3 >Emitted(21, 6) Source(3, 1) + SourceIndex(1) +4 >Emitted(21, 10) Source(5, 2) + SourceIndex(1) +--- +>>> exports.c1 = c1; +1->^^^^ +2 > ^^^^^^^^^^ +3 > ^^^^^ +4 > ^ +5 > ^^^^^^^^^^^^^^-> +1-> +2 > c1 +3 > { + > public p1: number; + > } +4 > +1->Emitted(22, 5) Source(3, 14) + SourceIndex(1) +2 >Emitted(22, 15) Source(3, 16) + SourceIndex(1) +3 >Emitted(22, 20) Source(5, 2) + SourceIndex(1) +4 >Emitted(22, 21) Source(5, 2) + SourceIndex(1) +--- +>>> exports.instance1 = new c1(); +1->^^^^ +2 > ^^^^^^^^^^^^^^^^^ +3 > ^^^ +4 > ^^^^ +5 > ^^ +6 > ^^ +7 > ^ +1-> + > + >export var +2 > instance1 +3 > = +4 > new +5 > c1 +6 > () +7 > ; +1->Emitted(23, 5) Source(7, 12) + SourceIndex(1) +2 >Emitted(23, 22) Source(7, 21) + SourceIndex(1) +3 >Emitted(23, 25) Source(7, 24) + SourceIndex(1) +4 >Emitted(23, 29) Source(7, 28) + SourceIndex(1) +5 >Emitted(23, 31) Source(7, 30) + SourceIndex(1) +6 >Emitted(23, 33) Source(7, 32) + SourceIndex(1) +7 >Emitted(23, 34) Source(7, 33) + SourceIndex(1) +--- +>>> function f1() { +1 >^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +1 > + > +1 >Emitted(24, 5) Source(8, 1) + SourceIndex(1) +--- +>>> return exports.instance1; +1->^^^^^^^^ +2 > ^^^^^^ +3 > ^ +4 > ^^^^^^^^^^^^^^^^^ +5 > ^ +1->export function f1() { + > +2 > return +3 > +4 > instance1 +5 > ; +1->Emitted(25, 9) Source(9, 5) + SourceIndex(1) name (f1) +2 >Emitted(25, 15) Source(9, 11) + SourceIndex(1) name (f1) +3 >Emitted(25, 16) Source(9, 12) + SourceIndex(1) name (f1) +4 >Emitted(25, 33) Source(9, 21) + SourceIndex(1) name (f1) +5 >Emitted(25, 34) Source(9, 22) + SourceIndex(1) name (f1) +--- +>>> } +1 >^^^^ +2 > ^ +3 > ^^^^^^^^^^^^^^^^-> +1 > + > +2 > } +1 >Emitted(26, 5) Source(10, 1) + SourceIndex(1) name (f1) +2 >Emitted(26, 6) Source(10, 2) + SourceIndex(1) name (f1) +--- +>>> exports.f1 = f1; +1->^^^^ +2 > ^^^^^^^^^^ +3 > ^^^^^ +4 > ^ +5 > ^^^^^^^-> +1-> +2 > f1 +3 > () { + > return instance1; + > } +4 > +1->Emitted(27, 5) Source(8, 17) + SourceIndex(1) +2 >Emitted(27, 15) Source(8, 19) + SourceIndex(1) +3 >Emitted(27, 20) Source(10, 2) + SourceIndex(1) +4 >Emitted(27, 21) Source(10, 2) + SourceIndex(1) +--- +>>> exports.a2 = m1.m1_c1; +1->^^^^ +2 > ^^^^^^^^^^ +3 > ^^^ +4 > ^^ +5 > ^ +6 > ^^^^^ +7 > ^ +1-> + > + >export var +2 > a2 +3 > = +4 > m1 +5 > . +6 > m1_c1 +7 > ; +1->Emitted(28, 5) Source(12, 12) + SourceIndex(1) +2 >Emitted(28, 15) Source(12, 14) + SourceIndex(1) +3 >Emitted(28, 18) Source(12, 17) + SourceIndex(1) +4 >Emitted(28, 20) Source(12, 19) + SourceIndex(1) +5 >Emitted(28, 21) Source(12, 20) + SourceIndex(1) +6 >Emitted(28, 26) Source(12, 25) + SourceIndex(1) +7 >Emitted(28, 27) Source(12, 26) + SourceIndex(1) +--- +>>>}); >>>//# sourceMappingURL=test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootRelativePathModuleSubfolderSpecifyOutputFile/node/bin/test.d.ts b/tests/baselines/reference/project/sourceRootRelativePathModuleSubfolderSpecifyOutputFile/node/bin/test.d.ts deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/tests/baselines/reference/project/sourceRootRelativePathModuleSubfolderSpecifyOutputFile/node/bin/test.js b/tests/baselines/reference/project/sourceRootRelativePathModuleSubfolderSpecifyOutputFile/node/bin/test.js deleted file mode 100644 index 6f3fefb9498..00000000000 --- a/tests/baselines/reference/project/sourceRootRelativePathModuleSubfolderSpecifyOutputFile/node/bin/test.js +++ /dev/null @@ -1 +0,0 @@ -//# sourceMappingURL=test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootRelativePathModuleSubfolderSpecifyOutputFile/node/bin/test.js.map b/tests/baselines/reference/project/sourceRootRelativePathModuleSubfolderSpecifyOutputFile/node/bin/test.js.map index 512eba0e11a..f803a29f3bf 100644 --- a/tests/baselines/reference/project/sourceRootRelativePathModuleSubfolderSpecifyOutputFile/node/bin/test.js.map +++ b/tests/baselines/reference/project/sourceRootRelativePathModuleSubfolderSpecifyOutputFile/node/bin/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"../src/","sources":[],"names":[],"mappings":""} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"../src/","sources":["ref/m1.ts","test.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootRelativePathModuleSubfolderSpecifyOutputFile/node/sourceRootRelativePathModuleSubfolderSpecifyOutputFile.sourcemap.txt b/tests/baselines/reference/project/sourceRootRelativePathModuleSubfolderSpecifyOutputFile/node/sourceRootRelativePathModuleSubfolderSpecifyOutputFile.sourcemap.txt index 5a3d45c1960..7e4dd146e52 100644 --- a/tests/baselines/reference/project/sourceRootRelativePathModuleSubfolderSpecifyOutputFile/node/sourceRootRelativePathModuleSubfolderSpecifyOutputFile.sourcemap.txt +++ b/tests/baselines/reference/project/sourceRootRelativePathModuleSubfolderSpecifyOutputFile/node/sourceRootRelativePathModuleSubfolderSpecifyOutputFile.sourcemap.txt @@ -394,6 +394,6 @@ sourceFile:test.ts JsFile: test.js mapUrl: test.js.map sourceRoot: ../src/ -sources: +sources: ref/m1.ts,test.ts =================================================================== >>>//# sourceMappingURL=test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFile/amd/bin/test.d.ts b/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFile/amd/bin/test.d.ts deleted file mode 100644 index d61b4c3b876..00000000000 --- a/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFile/amd/bin/test.d.ts +++ /dev/null @@ -1,13 +0,0 @@ -/// -declare var m1_a1: number; -declare class m1_c1 { - m1_c1_p1: number; -} -declare var m1_instance1: m1_c1; -declare function m1_f1(): m1_c1; -declare var a1: number; -declare class c1 { - p1: number; -} -declare var instance1: c1; -declare function f1(): c1; diff --git a/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFile/amd/bin/test.js b/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFile/amd/bin/test.js deleted file mode 100644 index 5af28cf8560..00000000000 --- a/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFile/amd/bin/test.js +++ /dev/null @@ -1,23 +0,0 @@ -var m1_a1 = 10; -var m1_c1 = (function () { - function m1_c1() { - } - return m1_c1; -})(); -var m1_instance1 = new m1_c1(); -function m1_f1() { - return m1_instance1; -} -/// -/// -var a1 = 10; -var c1 = (function () { - function c1() { - } - return c1; -})(); -var instance1 = new c1(); -function f1() { - return instance1; -} -//# sourceMappingURL=test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFile/amd/bin/test.js.map b/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFile/amd/bin/test.js.map index a1d591a0497..94371fe696d 100644 --- a/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFile/amd/bin/test.js.map +++ b/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFile/amd/bin/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"","sources":["../ref/m1.ts","../test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACRD,iCAAiC;AACjC,iCAAiC;AACjC,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"","sources":["../ref/m1.ts","../ref/m2.ts","../test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","m2_c1","m2_c1.constructor","m2_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;;ICRU,aAAK,GAAG,EAAE,CAAC;IACtB;QAAAC;QAEAC,CAACA;QAADD,YAACA;IAADA,CAACA,AAFD,IAEC;IAFY,aAAK,QAEjB,CAAA;IAEU,oBAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACIE,MAAMA,CAACA,oBAAYA,CAACA;IACxBA,CAACA;IAFe,aAAK,QAEpB,CAAA;;ACRD,iCAAiC;AACjC,iCAAiC;AACjC,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFile/amd/sourcemapMixedSubfolderSpecifyOutputFile.sourcemap.txt b/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFile/amd/sourcemapMixedSubfolderSpecifyOutputFile.sourcemap.txt index b1d3f293b7e..23f10a2cf62 100644 --- a/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFile/amd/sourcemapMixedSubfolderSpecifyOutputFile.sourcemap.txt +++ b/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFile/amd/sourcemapMixedSubfolderSpecifyOutputFile.sourcemap.txt @@ -174,7 +174,7 @@ sourceFile:m2.ts JsFile: test.js mapUrl: test.js.map sourceRoot: -sources: ../ref/m1.ts,../test.ts +sources: ../ref/m1.ts,../ref/m2.ts,../test.ts =================================================================== ------------------------------------------------------------------- emittedFile:bin/test.js @@ -306,7 +306,7 @@ sourceFile:../ref/m1.ts >>>} 1 > 2 >^ -3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> 1 > > 2 >} @@ -315,16 +315,182 @@ sourceFile:../ref/m1.ts --- ------------------------------------------------------------------- emittedFile:bin/test.js +sourceFile:../ref/m2.ts +------------------------------------------------------------------- +>>>define("ref/m2", ["require", "exports"], function (require, exports) { +>>> exports.m2_a1 = 10; +1->^^^^ +2 > ^^^^^^^^^^^^^ +3 > ^^^ +4 > ^^ +5 > ^ +6 > ^^^^^^^^-> +1->export var +2 > m2_a1 +3 > = +4 > 10 +5 > ; +1->Emitted(12, 5) Source(1, 12) + SourceIndex(1) +2 >Emitted(12, 18) Source(1, 17) + SourceIndex(1) +3 >Emitted(12, 21) Source(1, 20) + SourceIndex(1) +4 >Emitted(12, 23) Source(1, 22) + SourceIndex(1) +5 >Emitted(12, 24) Source(1, 23) + SourceIndex(1) +--- +>>> var m2_c1 = (function () { +1->^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^^^^-> +1-> + > +1->Emitted(13, 5) Source(2, 1) + SourceIndex(1) +--- +>>> function m2_c1() { +1->^^^^^^^^ +2 > ^^-> +1-> +1->Emitted(14, 9) Source(2, 1) + SourceIndex(1) name (m2_c1) +--- +>>> } +1->^^^^^^^^ +2 > ^ +3 > ^^^^^^^^^^^^^-> +1->export class m2_c1 { + > public m2_c1_p1: number; + > +2 > } +1->Emitted(15, 9) Source(4, 1) + SourceIndex(1) name (m2_c1.constructor) +2 >Emitted(15, 10) Source(4, 2) + SourceIndex(1) name (m2_c1.constructor) +--- +>>> return m2_c1; +1->^^^^^^^^ +2 > ^^^^^^^^^^^^ +1-> +2 > } +1->Emitted(16, 9) Source(4, 1) + SourceIndex(1) name (m2_c1) +2 >Emitted(16, 21) Source(4, 2) + SourceIndex(1) name (m2_c1) +--- +>>> })(); +1 >^^^^ +2 > ^ +3 > +4 > ^^^^ +5 > ^^^^^^^^^^^^^^^^^^-> +1 > +2 > } +3 > +4 > export class m2_c1 { + > public m2_c1_p1: number; + > } +1 >Emitted(17, 5) Source(4, 1) + SourceIndex(1) name (m2_c1) +2 >Emitted(17, 6) Source(4, 2) + SourceIndex(1) name (m2_c1) +3 >Emitted(17, 6) Source(2, 1) + SourceIndex(1) +4 >Emitted(17, 10) Source(4, 2) + SourceIndex(1) +--- +>>> exports.m2_c1 = m2_c1; +1->^^^^ +2 > ^^^^^^^^^^^^^ +3 > ^^^^^^^^ +4 > ^ +5 > ^^^^^^^^^^^^^^-> +1-> +2 > m2_c1 +3 > { + > public m2_c1_p1: number; + > } +4 > +1->Emitted(18, 5) Source(2, 14) + SourceIndex(1) +2 >Emitted(18, 18) Source(2, 19) + SourceIndex(1) +3 >Emitted(18, 26) Source(4, 2) + SourceIndex(1) +4 >Emitted(18, 27) Source(4, 2) + SourceIndex(1) +--- +>>> exports.m2_instance1 = new m2_c1(); +1->^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^ +3 > ^^^ +4 > ^^^^ +5 > ^^^^^ +6 > ^^ +7 > ^ +1-> + > + >export var +2 > m2_instance1 +3 > = +4 > new +5 > m2_c1 +6 > () +7 > ; +1->Emitted(19, 5) Source(6, 12) + SourceIndex(1) +2 >Emitted(19, 25) Source(6, 24) + SourceIndex(1) +3 >Emitted(19, 28) Source(6, 27) + SourceIndex(1) +4 >Emitted(19, 32) Source(6, 31) + SourceIndex(1) +5 >Emitted(19, 37) Source(6, 36) + SourceIndex(1) +6 >Emitted(19, 39) Source(6, 38) + SourceIndex(1) +7 >Emitted(19, 40) Source(6, 39) + SourceIndex(1) +--- +>>> function m2_f1() { +1 >^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +1 > + > +1 >Emitted(20, 5) Source(7, 1) + SourceIndex(1) +--- +>>> return exports.m2_instance1; +1->^^^^^^^^ +2 > ^^^^^^ +3 > ^ +4 > ^^^^^^^^^^^^^^^^^^^^ +5 > ^ +1->export function m2_f1() { + > +2 > return +3 > +4 > m2_instance1 +5 > ; +1->Emitted(21, 9) Source(8, 5) + SourceIndex(1) name (m2_f1) +2 >Emitted(21, 15) Source(8, 11) + SourceIndex(1) name (m2_f1) +3 >Emitted(21, 16) Source(8, 12) + SourceIndex(1) name (m2_f1) +4 >Emitted(21, 36) Source(8, 24) + SourceIndex(1) name (m2_f1) +5 >Emitted(21, 37) Source(8, 25) + SourceIndex(1) name (m2_f1) +--- +>>> } +1 >^^^^ +2 > ^ +3 > ^^^^^^^^^^^^^^^^^^^^^^-> +1 > + > +2 > } +1 >Emitted(22, 5) Source(9, 1) + SourceIndex(1) name (m2_f1) +2 >Emitted(22, 6) Source(9, 2) + SourceIndex(1) name (m2_f1) +--- +>>> exports.m2_f1 = m2_f1; +1->^^^^ +2 > ^^^^^^^^^^^^^ +3 > ^^^^^^^^ +4 > ^ +1-> +2 > m2_f1 +3 > () { + > return m2_instance1; + > } +4 > +1->Emitted(23, 5) Source(7, 17) + SourceIndex(1) +2 >Emitted(23, 18) Source(7, 22) + SourceIndex(1) +3 >Emitted(23, 26) Source(9, 2) + SourceIndex(1) +4 >Emitted(23, 27) Source(9, 2) + SourceIndex(1) +--- +------------------------------------------------------------------- +emittedFile:bin/test.js sourceFile:../test.ts ------------------------------------------------------------------- +>>>}); >>>/// -1-> +1 > 2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 3 > ^-> -1-> +1 > 2 >/// -1->Emitted(11, 1) Source(1, 1) + SourceIndex(1) -2 >Emitted(11, 34) Source(1, 34) + SourceIndex(1) +1 >Emitted(25, 1) Source(1, 1) + SourceIndex(2) +2 >Emitted(25, 34) Source(1, 34) + SourceIndex(2) --- >>>/// 1-> @@ -332,8 +498,8 @@ sourceFile:../test.ts 1-> > 2 >/// -1->Emitted(12, 1) Source(2, 1) + SourceIndex(1) -2 >Emitted(12, 34) Source(2, 34) + SourceIndex(1) +1->Emitted(26, 1) Source(2, 1) + SourceIndex(2) +2 >Emitted(26, 34) Source(2, 34) + SourceIndex(2) --- >>>var a1 = 10; 1 > @@ -350,25 +516,25 @@ sourceFile:../test.ts 4 > = 5 > 10 6 > ; -1 >Emitted(13, 1) Source(3, 1) + SourceIndex(1) -2 >Emitted(13, 5) Source(3, 5) + SourceIndex(1) -3 >Emitted(13, 7) Source(3, 7) + SourceIndex(1) -4 >Emitted(13, 10) Source(3, 10) + SourceIndex(1) -5 >Emitted(13, 12) Source(3, 12) + SourceIndex(1) -6 >Emitted(13, 13) Source(3, 13) + SourceIndex(1) +1 >Emitted(27, 1) Source(3, 1) + SourceIndex(2) +2 >Emitted(27, 5) Source(3, 5) + SourceIndex(2) +3 >Emitted(27, 7) Source(3, 7) + SourceIndex(2) +4 >Emitted(27, 10) Source(3, 10) + SourceIndex(2) +5 >Emitted(27, 12) Source(3, 12) + SourceIndex(2) +6 >Emitted(27, 13) Source(3, 13) + SourceIndex(2) --- >>>var c1 = (function () { 1-> 2 >^^^^^^^^^^^^^^^^^^^^-> 1-> > -1->Emitted(14, 1) Source(4, 1) + SourceIndex(1) +1->Emitted(28, 1) Source(4, 1) + SourceIndex(2) --- >>> function c1() { 1->^^^^ 2 > ^^-> 1-> -1->Emitted(15, 5) Source(4, 1) + SourceIndex(1) name (c1) +1->Emitted(29, 5) Source(4, 1) + SourceIndex(2) name (c1) --- >>> } 1->^^^^ @@ -378,16 +544,16 @@ sourceFile:../test.ts > public p1: number; > 2 > } -1->Emitted(16, 5) Source(6, 1) + SourceIndex(1) name (c1.constructor) -2 >Emitted(16, 6) Source(6, 2) + SourceIndex(1) name (c1.constructor) +1->Emitted(30, 5) Source(6, 1) + SourceIndex(2) name (c1.constructor) +2 >Emitted(30, 6) Source(6, 2) + SourceIndex(2) name (c1.constructor) --- >>> return c1; 1->^^^^ 2 > ^^^^^^^^^ 1-> 2 > } -1->Emitted(17, 5) Source(6, 1) + SourceIndex(1) name (c1) -2 >Emitted(17, 14) Source(6, 2) + SourceIndex(1) name (c1) +1->Emitted(31, 5) Source(6, 1) + SourceIndex(2) name (c1) +2 >Emitted(31, 14) Source(6, 2) + SourceIndex(2) name (c1) --- >>>})(); 1 > @@ -401,10 +567,10 @@ sourceFile:../test.ts 4 > class c1 { > public p1: number; > } -1 >Emitted(18, 1) Source(6, 1) + SourceIndex(1) name (c1) -2 >Emitted(18, 2) Source(6, 2) + SourceIndex(1) name (c1) -3 >Emitted(18, 2) Source(4, 1) + SourceIndex(1) -4 >Emitted(18, 6) Source(6, 2) + SourceIndex(1) +1 >Emitted(32, 1) Source(6, 1) + SourceIndex(2) name (c1) +2 >Emitted(32, 2) Source(6, 2) + SourceIndex(2) name (c1) +3 >Emitted(32, 2) Source(4, 1) + SourceIndex(2) +4 >Emitted(32, 6) Source(6, 2) + SourceIndex(2) --- >>>var instance1 = new c1(); 1-> @@ -425,21 +591,21 @@ sourceFile:../test.ts 6 > c1 7 > () 8 > ; -1->Emitted(19, 1) Source(8, 1) + SourceIndex(1) -2 >Emitted(19, 5) Source(8, 5) + SourceIndex(1) -3 >Emitted(19, 14) Source(8, 14) + SourceIndex(1) -4 >Emitted(19, 17) Source(8, 17) + SourceIndex(1) -5 >Emitted(19, 21) Source(8, 21) + SourceIndex(1) -6 >Emitted(19, 23) Source(8, 23) + SourceIndex(1) -7 >Emitted(19, 25) Source(8, 25) + SourceIndex(1) -8 >Emitted(19, 26) Source(8, 26) + SourceIndex(1) +1->Emitted(33, 1) Source(8, 1) + SourceIndex(2) +2 >Emitted(33, 5) Source(8, 5) + SourceIndex(2) +3 >Emitted(33, 14) Source(8, 14) + SourceIndex(2) +4 >Emitted(33, 17) Source(8, 17) + SourceIndex(2) +5 >Emitted(33, 21) Source(8, 21) + SourceIndex(2) +6 >Emitted(33, 23) Source(8, 23) + SourceIndex(2) +7 >Emitted(33, 25) Source(8, 25) + SourceIndex(2) +8 >Emitted(33, 26) Source(8, 26) + SourceIndex(2) --- >>>function f1() { 1 > 2 >^^^^^^^^^^^^^^^^^^^^^^-> 1 > > -1 >Emitted(20, 1) Source(9, 1) + SourceIndex(1) +1 >Emitted(34, 1) Source(9, 1) + SourceIndex(2) --- >>> return instance1; 1->^^^^ @@ -453,11 +619,11 @@ sourceFile:../test.ts 3 > 4 > instance1 5 > ; -1->Emitted(21, 5) Source(10, 5) + SourceIndex(1) name (f1) -2 >Emitted(21, 11) Source(10, 11) + SourceIndex(1) name (f1) -3 >Emitted(21, 12) Source(10, 12) + SourceIndex(1) name (f1) -4 >Emitted(21, 21) Source(10, 21) + SourceIndex(1) name (f1) -5 >Emitted(21, 22) Source(10, 22) + SourceIndex(1) name (f1) +1->Emitted(35, 5) Source(10, 5) + SourceIndex(2) name (f1) +2 >Emitted(35, 11) Source(10, 11) + SourceIndex(2) name (f1) +3 >Emitted(35, 12) Source(10, 12) + SourceIndex(2) name (f1) +4 >Emitted(35, 21) Source(10, 21) + SourceIndex(2) name (f1) +5 >Emitted(35, 22) Source(10, 22) + SourceIndex(2) name (f1) --- >>>} 1 > @@ -466,7 +632,7 @@ sourceFile:../test.ts 1 > > 2 >} -1 >Emitted(22, 1) Source(11, 1) + SourceIndex(1) name (f1) -2 >Emitted(22, 2) Source(11, 2) + SourceIndex(1) name (f1) +1 >Emitted(36, 1) Source(11, 1) + SourceIndex(2) name (f1) +2 >Emitted(36, 2) Source(11, 2) + SourceIndex(2) name (f1) --- >>>//# sourceMappingURL=test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFile/node/bin/test.d.ts b/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFile/node/bin/test.d.ts deleted file mode 100644 index d61b4c3b876..00000000000 --- a/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFile/node/bin/test.d.ts +++ /dev/null @@ -1,13 +0,0 @@ -/// -declare var m1_a1: number; -declare class m1_c1 { - m1_c1_p1: number; -} -declare var m1_instance1: m1_c1; -declare function m1_f1(): m1_c1; -declare var a1: number; -declare class c1 { - p1: number; -} -declare var instance1: c1; -declare function f1(): c1; diff --git a/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFile/node/bin/test.js b/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFile/node/bin/test.js deleted file mode 100644 index 5af28cf8560..00000000000 --- a/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFile/node/bin/test.js +++ /dev/null @@ -1,23 +0,0 @@ -var m1_a1 = 10; -var m1_c1 = (function () { - function m1_c1() { - } - return m1_c1; -})(); -var m1_instance1 = new m1_c1(); -function m1_f1() { - return m1_instance1; -} -/// -/// -var a1 = 10; -var c1 = (function () { - function c1() { - } - return c1; -})(); -var instance1 = new c1(); -function f1() { - return instance1; -} -//# sourceMappingURL=test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFile/node/bin/test.js.map b/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFile/node/bin/test.js.map index a1d591a0497..a580c050d07 100644 --- a/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFile/node/bin/test.js.map +++ b/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFile/node/bin/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"","sources":["../ref/m1.ts","../test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACRD,iCAAiC;AACjC,iCAAiC;AACjC,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"","sources":["../ref/m1.ts","../ref/m2.ts","../test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;AERD,iCAAiC;AACjC,iCAAiC;AACjC,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFile/node/sourcemapMixedSubfolderSpecifyOutputFile.sourcemap.txt b/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFile/node/sourcemapMixedSubfolderSpecifyOutputFile.sourcemap.txt index 676e8f264ec..4bc6731c326 100644 --- a/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFile/node/sourcemapMixedSubfolderSpecifyOutputFile.sourcemap.txt +++ b/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFile/node/sourcemapMixedSubfolderSpecifyOutputFile.sourcemap.txt @@ -173,7 +173,7 @@ sourceFile:m2.ts JsFile: test.js mapUrl: test.js.map sourceRoot: -sources: ../ref/m1.ts,../test.ts +sources: ../ref/m1.ts,../ref/m2.ts,../test.ts =================================================================== ------------------------------------------------------------------- emittedFile:bin/test.js @@ -322,8 +322,8 @@ sourceFile:../test.ts 3 > ^-> 1-> 2 >/// -1->Emitted(11, 1) Source(1, 1) + SourceIndex(1) -2 >Emitted(11, 34) Source(1, 34) + SourceIndex(1) +1->Emitted(11, 1) Source(1, 1) + SourceIndex(2) +2 >Emitted(11, 34) Source(1, 34) + SourceIndex(2) --- >>>/// 1-> @@ -331,8 +331,8 @@ sourceFile:../test.ts 1-> > 2 >/// -1->Emitted(12, 1) Source(2, 1) + SourceIndex(1) -2 >Emitted(12, 34) Source(2, 34) + SourceIndex(1) +1->Emitted(12, 1) Source(2, 1) + SourceIndex(2) +2 >Emitted(12, 34) Source(2, 34) + SourceIndex(2) --- >>>var a1 = 10; 1 > @@ -349,25 +349,25 @@ sourceFile:../test.ts 4 > = 5 > 10 6 > ; -1 >Emitted(13, 1) Source(3, 1) + SourceIndex(1) -2 >Emitted(13, 5) Source(3, 5) + SourceIndex(1) -3 >Emitted(13, 7) Source(3, 7) + SourceIndex(1) -4 >Emitted(13, 10) Source(3, 10) + SourceIndex(1) -5 >Emitted(13, 12) Source(3, 12) + SourceIndex(1) -6 >Emitted(13, 13) Source(3, 13) + SourceIndex(1) +1 >Emitted(13, 1) Source(3, 1) + SourceIndex(2) +2 >Emitted(13, 5) Source(3, 5) + SourceIndex(2) +3 >Emitted(13, 7) Source(3, 7) + SourceIndex(2) +4 >Emitted(13, 10) Source(3, 10) + SourceIndex(2) +5 >Emitted(13, 12) Source(3, 12) + SourceIndex(2) +6 >Emitted(13, 13) Source(3, 13) + SourceIndex(2) --- >>>var c1 = (function () { 1-> 2 >^^^^^^^^^^^^^^^^^^^^-> 1-> > -1->Emitted(14, 1) Source(4, 1) + SourceIndex(1) +1->Emitted(14, 1) Source(4, 1) + SourceIndex(2) --- >>> function c1() { 1->^^^^ 2 > ^^-> 1-> -1->Emitted(15, 5) Source(4, 1) + SourceIndex(1) name (c1) +1->Emitted(15, 5) Source(4, 1) + SourceIndex(2) name (c1) --- >>> } 1->^^^^ @@ -377,16 +377,16 @@ sourceFile:../test.ts > public p1: number; > 2 > } -1->Emitted(16, 5) Source(6, 1) + SourceIndex(1) name (c1.constructor) -2 >Emitted(16, 6) Source(6, 2) + SourceIndex(1) name (c1.constructor) +1->Emitted(16, 5) Source(6, 1) + SourceIndex(2) name (c1.constructor) +2 >Emitted(16, 6) Source(6, 2) + SourceIndex(2) name (c1.constructor) --- >>> return c1; 1->^^^^ 2 > ^^^^^^^^^ 1-> 2 > } -1->Emitted(17, 5) Source(6, 1) + SourceIndex(1) name (c1) -2 >Emitted(17, 14) Source(6, 2) + SourceIndex(1) name (c1) +1->Emitted(17, 5) Source(6, 1) + SourceIndex(2) name (c1) +2 >Emitted(17, 14) Source(6, 2) + SourceIndex(2) name (c1) --- >>>})(); 1 > @@ -400,10 +400,10 @@ sourceFile:../test.ts 4 > class c1 { > public p1: number; > } -1 >Emitted(18, 1) Source(6, 1) + SourceIndex(1) name (c1) -2 >Emitted(18, 2) Source(6, 2) + SourceIndex(1) name (c1) -3 >Emitted(18, 2) Source(4, 1) + SourceIndex(1) -4 >Emitted(18, 6) Source(6, 2) + SourceIndex(1) +1 >Emitted(18, 1) Source(6, 1) + SourceIndex(2) name (c1) +2 >Emitted(18, 2) Source(6, 2) + SourceIndex(2) name (c1) +3 >Emitted(18, 2) Source(4, 1) + SourceIndex(2) +4 >Emitted(18, 6) Source(6, 2) + SourceIndex(2) --- >>>var instance1 = new c1(); 1-> @@ -424,21 +424,21 @@ sourceFile:../test.ts 6 > c1 7 > () 8 > ; -1->Emitted(19, 1) Source(8, 1) + SourceIndex(1) -2 >Emitted(19, 5) Source(8, 5) + SourceIndex(1) -3 >Emitted(19, 14) Source(8, 14) + SourceIndex(1) -4 >Emitted(19, 17) Source(8, 17) + SourceIndex(1) -5 >Emitted(19, 21) Source(8, 21) + SourceIndex(1) -6 >Emitted(19, 23) Source(8, 23) + SourceIndex(1) -7 >Emitted(19, 25) Source(8, 25) + SourceIndex(1) -8 >Emitted(19, 26) Source(8, 26) + SourceIndex(1) +1->Emitted(19, 1) Source(8, 1) + SourceIndex(2) +2 >Emitted(19, 5) Source(8, 5) + SourceIndex(2) +3 >Emitted(19, 14) Source(8, 14) + SourceIndex(2) +4 >Emitted(19, 17) Source(8, 17) + SourceIndex(2) +5 >Emitted(19, 21) Source(8, 21) + SourceIndex(2) +6 >Emitted(19, 23) Source(8, 23) + SourceIndex(2) +7 >Emitted(19, 25) Source(8, 25) + SourceIndex(2) +8 >Emitted(19, 26) Source(8, 26) + SourceIndex(2) --- >>>function f1() { 1 > 2 >^^^^^^^^^^^^^^^^^^^^^^-> 1 > > -1 >Emitted(20, 1) Source(9, 1) + SourceIndex(1) +1 >Emitted(20, 1) Source(9, 1) + SourceIndex(2) --- >>> return instance1; 1->^^^^ @@ -452,11 +452,11 @@ sourceFile:../test.ts 3 > 4 > instance1 5 > ; -1->Emitted(21, 5) Source(10, 5) + SourceIndex(1) name (f1) -2 >Emitted(21, 11) Source(10, 11) + SourceIndex(1) name (f1) -3 >Emitted(21, 12) Source(10, 12) + SourceIndex(1) name (f1) -4 >Emitted(21, 21) Source(10, 21) + SourceIndex(1) name (f1) -5 >Emitted(21, 22) Source(10, 22) + SourceIndex(1) name (f1) +1->Emitted(21, 5) Source(10, 5) + SourceIndex(2) name (f1) +2 >Emitted(21, 11) Source(10, 11) + SourceIndex(2) name (f1) +3 >Emitted(21, 12) Source(10, 12) + SourceIndex(2) name (f1) +4 >Emitted(21, 21) Source(10, 21) + SourceIndex(2) name (f1) +5 >Emitted(21, 22) Source(10, 22) + SourceIndex(2) name (f1) --- >>>} 1 > @@ -465,7 +465,7 @@ sourceFile:../test.ts 1 > > 2 >} -1 >Emitted(22, 1) Source(11, 1) + SourceIndex(1) name (f1) -2 >Emitted(22, 2) Source(11, 2) + SourceIndex(1) name (f1) +1 >Emitted(22, 1) Source(11, 1) + SourceIndex(2) name (f1) +2 >Emitted(22, 2) Source(11, 2) + SourceIndex(2) name (f1) --- >>>//# sourceMappingURL=test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.d.ts b/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.d.ts deleted file mode 100644 index 9b9cdd4a214..00000000000 --- a/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.d.ts +++ /dev/null @@ -1,13 +0,0 @@ -/// -declare var m1_a1: number; -declare class m1_c1 { - m1_c1_p1: number; -} -declare var m1_instance1: m1_c1; -declare function m1_f1(): m1_c1; -declare var a1: number; -declare class c1 { - p1: number; -} -declare var instance1: c1; -declare function f1(): c1; diff --git a/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.js b/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.js deleted file mode 100644 index 1750a5975ae..00000000000 --- a/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.js +++ /dev/null @@ -1,23 +0,0 @@ -var m1_a1 = 10; -var m1_c1 = (function () { - function m1_c1() { - } - return m1_c1; -})(); -var m1_instance1 = new m1_c1(); -function m1_f1() { - return m1_instance1; -} -/// -/// -var a1 = 10; -var c1 = (function () { - function c1() { - } - return c1; -})(); -var instance1 = new c1(); -function f1() { - return instance1; -} -//# sourceMappingURL=outAndOutDirFile.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.js.map b/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.js.map index 4f87045fd25..22aaecafe2d 100644 --- a/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.js.map +++ b/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.js.map @@ -1 +1 @@ -{"version":3,"file":"outAndOutDirFile.js","sourceRoot":"","sources":["../ref/m1.ts","../test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACRD,iCAAiC;AACjC,iCAAiC;AACjC,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"outAndOutDirFile.js","sourceRoot":"","sources":["../ref/m1.ts","../ref/m2.ts","../test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","m2_c1","m2_c1.constructor","m2_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;;ICRU,aAAK,GAAG,EAAE,CAAC;IACtB;QAAAC;QAEAC,CAACA;QAADD,YAACA;IAADA,CAACA,AAFD,IAEC;IAFY,aAAK,QAEjB,CAAA;IAEU,oBAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACIE,MAAMA,CAACA,oBAAYA,CAACA;IACxBA,CAACA;IAFe,aAAK,QAEpB,CAAA;;ACRD,iCAAiC;AACjC,iCAAiC;AACjC,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/sourcemapMixedSubfolderSpecifyOutputFileAndOutputDirectory.sourcemap.txt b/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/sourcemapMixedSubfolderSpecifyOutputFileAndOutputDirectory.sourcemap.txt index a73c3b0852a..5a223fb7109 100644 --- a/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/sourcemapMixedSubfolderSpecifyOutputFileAndOutputDirectory.sourcemap.txt +++ b/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/sourcemapMixedSubfolderSpecifyOutputFileAndOutputDirectory.sourcemap.txt @@ -174,7 +174,7 @@ sourceFile:../../../ref/m2.ts JsFile: outAndOutDirFile.js mapUrl: outAndOutDirFile.js.map sourceRoot: -sources: ../ref/m1.ts,../test.ts +sources: ../ref/m1.ts,../ref/m2.ts,../test.ts =================================================================== ------------------------------------------------------------------- emittedFile:bin/outAndOutDirFile.js @@ -306,7 +306,7 @@ sourceFile:../ref/m1.ts >>>} 1 > 2 >^ -3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> 1 > > 2 >} @@ -315,16 +315,182 @@ sourceFile:../ref/m1.ts --- ------------------------------------------------------------------- emittedFile:bin/outAndOutDirFile.js +sourceFile:../ref/m2.ts +------------------------------------------------------------------- +>>>define("ref/m2", ["require", "exports"], function (require, exports) { +>>> exports.m2_a1 = 10; +1->^^^^ +2 > ^^^^^^^^^^^^^ +3 > ^^^ +4 > ^^ +5 > ^ +6 > ^^^^^^^^-> +1->export var +2 > m2_a1 +3 > = +4 > 10 +5 > ; +1->Emitted(12, 5) Source(1, 12) + SourceIndex(1) +2 >Emitted(12, 18) Source(1, 17) + SourceIndex(1) +3 >Emitted(12, 21) Source(1, 20) + SourceIndex(1) +4 >Emitted(12, 23) Source(1, 22) + SourceIndex(1) +5 >Emitted(12, 24) Source(1, 23) + SourceIndex(1) +--- +>>> var m2_c1 = (function () { +1->^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^^^^-> +1-> + > +1->Emitted(13, 5) Source(2, 1) + SourceIndex(1) +--- +>>> function m2_c1() { +1->^^^^^^^^ +2 > ^^-> +1-> +1->Emitted(14, 9) Source(2, 1) + SourceIndex(1) name (m2_c1) +--- +>>> } +1->^^^^^^^^ +2 > ^ +3 > ^^^^^^^^^^^^^-> +1->export class m2_c1 { + > public m2_c1_p1: number; + > +2 > } +1->Emitted(15, 9) Source(4, 1) + SourceIndex(1) name (m2_c1.constructor) +2 >Emitted(15, 10) Source(4, 2) + SourceIndex(1) name (m2_c1.constructor) +--- +>>> return m2_c1; +1->^^^^^^^^ +2 > ^^^^^^^^^^^^ +1-> +2 > } +1->Emitted(16, 9) Source(4, 1) + SourceIndex(1) name (m2_c1) +2 >Emitted(16, 21) Source(4, 2) + SourceIndex(1) name (m2_c1) +--- +>>> })(); +1 >^^^^ +2 > ^ +3 > +4 > ^^^^ +5 > ^^^^^^^^^^^^^^^^^^-> +1 > +2 > } +3 > +4 > export class m2_c1 { + > public m2_c1_p1: number; + > } +1 >Emitted(17, 5) Source(4, 1) + SourceIndex(1) name (m2_c1) +2 >Emitted(17, 6) Source(4, 2) + SourceIndex(1) name (m2_c1) +3 >Emitted(17, 6) Source(2, 1) + SourceIndex(1) +4 >Emitted(17, 10) Source(4, 2) + SourceIndex(1) +--- +>>> exports.m2_c1 = m2_c1; +1->^^^^ +2 > ^^^^^^^^^^^^^ +3 > ^^^^^^^^ +4 > ^ +5 > ^^^^^^^^^^^^^^-> +1-> +2 > m2_c1 +3 > { + > public m2_c1_p1: number; + > } +4 > +1->Emitted(18, 5) Source(2, 14) + SourceIndex(1) +2 >Emitted(18, 18) Source(2, 19) + SourceIndex(1) +3 >Emitted(18, 26) Source(4, 2) + SourceIndex(1) +4 >Emitted(18, 27) Source(4, 2) + SourceIndex(1) +--- +>>> exports.m2_instance1 = new m2_c1(); +1->^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^ +3 > ^^^ +4 > ^^^^ +5 > ^^^^^ +6 > ^^ +7 > ^ +1-> + > + >export var +2 > m2_instance1 +3 > = +4 > new +5 > m2_c1 +6 > () +7 > ; +1->Emitted(19, 5) Source(6, 12) + SourceIndex(1) +2 >Emitted(19, 25) Source(6, 24) + SourceIndex(1) +3 >Emitted(19, 28) Source(6, 27) + SourceIndex(1) +4 >Emitted(19, 32) Source(6, 31) + SourceIndex(1) +5 >Emitted(19, 37) Source(6, 36) + SourceIndex(1) +6 >Emitted(19, 39) Source(6, 38) + SourceIndex(1) +7 >Emitted(19, 40) Source(6, 39) + SourceIndex(1) +--- +>>> function m2_f1() { +1 >^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +1 > + > +1 >Emitted(20, 5) Source(7, 1) + SourceIndex(1) +--- +>>> return exports.m2_instance1; +1->^^^^^^^^ +2 > ^^^^^^ +3 > ^ +4 > ^^^^^^^^^^^^^^^^^^^^ +5 > ^ +1->export function m2_f1() { + > +2 > return +3 > +4 > m2_instance1 +5 > ; +1->Emitted(21, 9) Source(8, 5) + SourceIndex(1) name (m2_f1) +2 >Emitted(21, 15) Source(8, 11) + SourceIndex(1) name (m2_f1) +3 >Emitted(21, 16) Source(8, 12) + SourceIndex(1) name (m2_f1) +4 >Emitted(21, 36) Source(8, 24) + SourceIndex(1) name (m2_f1) +5 >Emitted(21, 37) Source(8, 25) + SourceIndex(1) name (m2_f1) +--- +>>> } +1 >^^^^ +2 > ^ +3 > ^^^^^^^^^^^^^^^^^^^^^^-> +1 > + > +2 > } +1 >Emitted(22, 5) Source(9, 1) + SourceIndex(1) name (m2_f1) +2 >Emitted(22, 6) Source(9, 2) + SourceIndex(1) name (m2_f1) +--- +>>> exports.m2_f1 = m2_f1; +1->^^^^ +2 > ^^^^^^^^^^^^^ +3 > ^^^^^^^^ +4 > ^ +1-> +2 > m2_f1 +3 > () { + > return m2_instance1; + > } +4 > +1->Emitted(23, 5) Source(7, 17) + SourceIndex(1) +2 >Emitted(23, 18) Source(7, 22) + SourceIndex(1) +3 >Emitted(23, 26) Source(9, 2) + SourceIndex(1) +4 >Emitted(23, 27) Source(9, 2) + SourceIndex(1) +--- +------------------------------------------------------------------- +emittedFile:bin/outAndOutDirFile.js sourceFile:../test.ts ------------------------------------------------------------------- +>>>}); >>>/// -1-> +1 > 2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 3 > ^-> -1-> +1 > 2 >/// -1->Emitted(11, 1) Source(1, 1) + SourceIndex(1) -2 >Emitted(11, 34) Source(1, 34) + SourceIndex(1) +1 >Emitted(25, 1) Source(1, 1) + SourceIndex(2) +2 >Emitted(25, 34) Source(1, 34) + SourceIndex(2) --- >>>/// 1-> @@ -332,8 +498,8 @@ sourceFile:../test.ts 1-> > 2 >/// -1->Emitted(12, 1) Source(2, 1) + SourceIndex(1) -2 >Emitted(12, 34) Source(2, 34) + SourceIndex(1) +1->Emitted(26, 1) Source(2, 1) + SourceIndex(2) +2 >Emitted(26, 34) Source(2, 34) + SourceIndex(2) --- >>>var a1 = 10; 1 > @@ -350,25 +516,25 @@ sourceFile:../test.ts 4 > = 5 > 10 6 > ; -1 >Emitted(13, 1) Source(3, 1) + SourceIndex(1) -2 >Emitted(13, 5) Source(3, 5) + SourceIndex(1) -3 >Emitted(13, 7) Source(3, 7) + SourceIndex(1) -4 >Emitted(13, 10) Source(3, 10) + SourceIndex(1) -5 >Emitted(13, 12) Source(3, 12) + SourceIndex(1) -6 >Emitted(13, 13) Source(3, 13) + SourceIndex(1) +1 >Emitted(27, 1) Source(3, 1) + SourceIndex(2) +2 >Emitted(27, 5) Source(3, 5) + SourceIndex(2) +3 >Emitted(27, 7) Source(3, 7) + SourceIndex(2) +4 >Emitted(27, 10) Source(3, 10) + SourceIndex(2) +5 >Emitted(27, 12) Source(3, 12) + SourceIndex(2) +6 >Emitted(27, 13) Source(3, 13) + SourceIndex(2) --- >>>var c1 = (function () { 1-> 2 >^^^^^^^^^^^^^^^^^^^^-> 1-> > -1->Emitted(14, 1) Source(4, 1) + SourceIndex(1) +1->Emitted(28, 1) Source(4, 1) + SourceIndex(2) --- >>> function c1() { 1->^^^^ 2 > ^^-> 1-> -1->Emitted(15, 5) Source(4, 1) + SourceIndex(1) name (c1) +1->Emitted(29, 5) Source(4, 1) + SourceIndex(2) name (c1) --- >>> } 1->^^^^ @@ -378,16 +544,16 @@ sourceFile:../test.ts > public p1: number; > 2 > } -1->Emitted(16, 5) Source(6, 1) + SourceIndex(1) name (c1.constructor) -2 >Emitted(16, 6) Source(6, 2) + SourceIndex(1) name (c1.constructor) +1->Emitted(30, 5) Source(6, 1) + SourceIndex(2) name (c1.constructor) +2 >Emitted(30, 6) Source(6, 2) + SourceIndex(2) name (c1.constructor) --- >>> return c1; 1->^^^^ 2 > ^^^^^^^^^ 1-> 2 > } -1->Emitted(17, 5) Source(6, 1) + SourceIndex(1) name (c1) -2 >Emitted(17, 14) Source(6, 2) + SourceIndex(1) name (c1) +1->Emitted(31, 5) Source(6, 1) + SourceIndex(2) name (c1) +2 >Emitted(31, 14) Source(6, 2) + SourceIndex(2) name (c1) --- >>>})(); 1 > @@ -401,10 +567,10 @@ sourceFile:../test.ts 4 > class c1 { > public p1: number; > } -1 >Emitted(18, 1) Source(6, 1) + SourceIndex(1) name (c1) -2 >Emitted(18, 2) Source(6, 2) + SourceIndex(1) name (c1) -3 >Emitted(18, 2) Source(4, 1) + SourceIndex(1) -4 >Emitted(18, 6) Source(6, 2) + SourceIndex(1) +1 >Emitted(32, 1) Source(6, 1) + SourceIndex(2) name (c1) +2 >Emitted(32, 2) Source(6, 2) + SourceIndex(2) name (c1) +3 >Emitted(32, 2) Source(4, 1) + SourceIndex(2) +4 >Emitted(32, 6) Source(6, 2) + SourceIndex(2) --- >>>var instance1 = new c1(); 1-> @@ -425,21 +591,21 @@ sourceFile:../test.ts 6 > c1 7 > () 8 > ; -1->Emitted(19, 1) Source(8, 1) + SourceIndex(1) -2 >Emitted(19, 5) Source(8, 5) + SourceIndex(1) -3 >Emitted(19, 14) Source(8, 14) + SourceIndex(1) -4 >Emitted(19, 17) Source(8, 17) + SourceIndex(1) -5 >Emitted(19, 21) Source(8, 21) + SourceIndex(1) -6 >Emitted(19, 23) Source(8, 23) + SourceIndex(1) -7 >Emitted(19, 25) Source(8, 25) + SourceIndex(1) -8 >Emitted(19, 26) Source(8, 26) + SourceIndex(1) +1->Emitted(33, 1) Source(8, 1) + SourceIndex(2) +2 >Emitted(33, 5) Source(8, 5) + SourceIndex(2) +3 >Emitted(33, 14) Source(8, 14) + SourceIndex(2) +4 >Emitted(33, 17) Source(8, 17) + SourceIndex(2) +5 >Emitted(33, 21) Source(8, 21) + SourceIndex(2) +6 >Emitted(33, 23) Source(8, 23) + SourceIndex(2) +7 >Emitted(33, 25) Source(8, 25) + SourceIndex(2) +8 >Emitted(33, 26) Source(8, 26) + SourceIndex(2) --- >>>function f1() { 1 > 2 >^^^^^^^^^^^^^^^^^^^^^^-> 1 > > -1 >Emitted(20, 1) Source(9, 1) + SourceIndex(1) +1 >Emitted(34, 1) Source(9, 1) + SourceIndex(2) --- >>> return instance1; 1->^^^^ @@ -453,11 +619,11 @@ sourceFile:../test.ts 3 > 4 > instance1 5 > ; -1->Emitted(21, 5) Source(10, 5) + SourceIndex(1) name (f1) -2 >Emitted(21, 11) Source(10, 11) + SourceIndex(1) name (f1) -3 >Emitted(21, 12) Source(10, 12) + SourceIndex(1) name (f1) -4 >Emitted(21, 21) Source(10, 21) + SourceIndex(1) name (f1) -5 >Emitted(21, 22) Source(10, 22) + SourceIndex(1) name (f1) +1->Emitted(35, 5) Source(10, 5) + SourceIndex(2) name (f1) +2 >Emitted(35, 11) Source(10, 11) + SourceIndex(2) name (f1) +3 >Emitted(35, 12) Source(10, 12) + SourceIndex(2) name (f1) +4 >Emitted(35, 21) Source(10, 21) + SourceIndex(2) name (f1) +5 >Emitted(35, 22) Source(10, 22) + SourceIndex(2) name (f1) --- >>>} 1 > @@ -466,7 +632,7 @@ sourceFile:../test.ts 1 > > 2 >} -1 >Emitted(22, 1) Source(11, 1) + SourceIndex(1) name (f1) -2 >Emitted(22, 2) Source(11, 2) + SourceIndex(1) name (f1) +1 >Emitted(36, 1) Source(11, 1) + SourceIndex(2) name (f1) +2 >Emitted(36, 2) Source(11, 2) + SourceIndex(2) name (f1) --- >>>//# sourceMappingURL=outAndOutDirFile.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.d.ts b/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.d.ts deleted file mode 100644 index 9b9cdd4a214..00000000000 --- a/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.d.ts +++ /dev/null @@ -1,13 +0,0 @@ -/// -declare var m1_a1: number; -declare class m1_c1 { - m1_c1_p1: number; -} -declare var m1_instance1: m1_c1; -declare function m1_f1(): m1_c1; -declare var a1: number; -declare class c1 { - p1: number; -} -declare var instance1: c1; -declare function f1(): c1; diff --git a/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.js b/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.js deleted file mode 100644 index 1750a5975ae..00000000000 --- a/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.js +++ /dev/null @@ -1,23 +0,0 @@ -var m1_a1 = 10; -var m1_c1 = (function () { - function m1_c1() { - } - return m1_c1; -})(); -var m1_instance1 = new m1_c1(); -function m1_f1() { - return m1_instance1; -} -/// -/// -var a1 = 10; -var c1 = (function () { - function c1() { - } - return c1; -})(); -var instance1 = new c1(); -function f1() { - return instance1; -} -//# sourceMappingURL=outAndOutDirFile.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.js.map b/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.js.map index 4f87045fd25..2eab0f87324 100644 --- a/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.js.map +++ b/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.js.map @@ -1 +1 @@ -{"version":3,"file":"outAndOutDirFile.js","sourceRoot":"","sources":["../ref/m1.ts","../test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACRD,iCAAiC;AACjC,iCAAiC;AACjC,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"outAndOutDirFile.js","sourceRoot":"","sources":["../ref/m1.ts","../ref/m2.ts","../test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;AERD,iCAAiC;AACjC,iCAAiC;AACjC,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/sourcemapMixedSubfolderSpecifyOutputFileAndOutputDirectory.sourcemap.txt b/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/sourcemapMixedSubfolderSpecifyOutputFileAndOutputDirectory.sourcemap.txt index 77ff10492be..b36bfbd8c56 100644 --- a/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/sourcemapMixedSubfolderSpecifyOutputFileAndOutputDirectory.sourcemap.txt +++ b/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/sourcemapMixedSubfolderSpecifyOutputFileAndOutputDirectory.sourcemap.txt @@ -173,7 +173,7 @@ sourceFile:../../../ref/m2.ts JsFile: outAndOutDirFile.js mapUrl: outAndOutDirFile.js.map sourceRoot: -sources: ../ref/m1.ts,../test.ts +sources: ../ref/m1.ts,../ref/m2.ts,../test.ts =================================================================== ------------------------------------------------------------------- emittedFile:bin/outAndOutDirFile.js @@ -322,8 +322,8 @@ sourceFile:../test.ts 3 > ^-> 1-> 2 >/// -1->Emitted(11, 1) Source(1, 1) + SourceIndex(1) -2 >Emitted(11, 34) Source(1, 34) + SourceIndex(1) +1->Emitted(11, 1) Source(1, 1) + SourceIndex(2) +2 >Emitted(11, 34) Source(1, 34) + SourceIndex(2) --- >>>/// 1-> @@ -331,8 +331,8 @@ sourceFile:../test.ts 1-> > 2 >/// -1->Emitted(12, 1) Source(2, 1) + SourceIndex(1) -2 >Emitted(12, 34) Source(2, 34) + SourceIndex(1) +1->Emitted(12, 1) Source(2, 1) + SourceIndex(2) +2 >Emitted(12, 34) Source(2, 34) + SourceIndex(2) --- >>>var a1 = 10; 1 > @@ -349,25 +349,25 @@ sourceFile:../test.ts 4 > = 5 > 10 6 > ; -1 >Emitted(13, 1) Source(3, 1) + SourceIndex(1) -2 >Emitted(13, 5) Source(3, 5) + SourceIndex(1) -3 >Emitted(13, 7) Source(3, 7) + SourceIndex(1) -4 >Emitted(13, 10) Source(3, 10) + SourceIndex(1) -5 >Emitted(13, 12) Source(3, 12) + SourceIndex(1) -6 >Emitted(13, 13) Source(3, 13) + SourceIndex(1) +1 >Emitted(13, 1) Source(3, 1) + SourceIndex(2) +2 >Emitted(13, 5) Source(3, 5) + SourceIndex(2) +3 >Emitted(13, 7) Source(3, 7) + SourceIndex(2) +4 >Emitted(13, 10) Source(3, 10) + SourceIndex(2) +5 >Emitted(13, 12) Source(3, 12) + SourceIndex(2) +6 >Emitted(13, 13) Source(3, 13) + SourceIndex(2) --- >>>var c1 = (function () { 1-> 2 >^^^^^^^^^^^^^^^^^^^^-> 1-> > -1->Emitted(14, 1) Source(4, 1) + SourceIndex(1) +1->Emitted(14, 1) Source(4, 1) + SourceIndex(2) --- >>> function c1() { 1->^^^^ 2 > ^^-> 1-> -1->Emitted(15, 5) Source(4, 1) + SourceIndex(1) name (c1) +1->Emitted(15, 5) Source(4, 1) + SourceIndex(2) name (c1) --- >>> } 1->^^^^ @@ -377,16 +377,16 @@ sourceFile:../test.ts > public p1: number; > 2 > } -1->Emitted(16, 5) Source(6, 1) + SourceIndex(1) name (c1.constructor) -2 >Emitted(16, 6) Source(6, 2) + SourceIndex(1) name (c1.constructor) +1->Emitted(16, 5) Source(6, 1) + SourceIndex(2) name (c1.constructor) +2 >Emitted(16, 6) Source(6, 2) + SourceIndex(2) name (c1.constructor) --- >>> return c1; 1->^^^^ 2 > ^^^^^^^^^ 1-> 2 > } -1->Emitted(17, 5) Source(6, 1) + SourceIndex(1) name (c1) -2 >Emitted(17, 14) Source(6, 2) + SourceIndex(1) name (c1) +1->Emitted(17, 5) Source(6, 1) + SourceIndex(2) name (c1) +2 >Emitted(17, 14) Source(6, 2) + SourceIndex(2) name (c1) --- >>>})(); 1 > @@ -400,10 +400,10 @@ sourceFile:../test.ts 4 > class c1 { > public p1: number; > } -1 >Emitted(18, 1) Source(6, 1) + SourceIndex(1) name (c1) -2 >Emitted(18, 2) Source(6, 2) + SourceIndex(1) name (c1) -3 >Emitted(18, 2) Source(4, 1) + SourceIndex(1) -4 >Emitted(18, 6) Source(6, 2) + SourceIndex(1) +1 >Emitted(18, 1) Source(6, 1) + SourceIndex(2) name (c1) +2 >Emitted(18, 2) Source(6, 2) + SourceIndex(2) name (c1) +3 >Emitted(18, 2) Source(4, 1) + SourceIndex(2) +4 >Emitted(18, 6) Source(6, 2) + SourceIndex(2) --- >>>var instance1 = new c1(); 1-> @@ -424,21 +424,21 @@ sourceFile:../test.ts 6 > c1 7 > () 8 > ; -1->Emitted(19, 1) Source(8, 1) + SourceIndex(1) -2 >Emitted(19, 5) Source(8, 5) + SourceIndex(1) -3 >Emitted(19, 14) Source(8, 14) + SourceIndex(1) -4 >Emitted(19, 17) Source(8, 17) + SourceIndex(1) -5 >Emitted(19, 21) Source(8, 21) + SourceIndex(1) -6 >Emitted(19, 23) Source(8, 23) + SourceIndex(1) -7 >Emitted(19, 25) Source(8, 25) + SourceIndex(1) -8 >Emitted(19, 26) Source(8, 26) + SourceIndex(1) +1->Emitted(19, 1) Source(8, 1) + SourceIndex(2) +2 >Emitted(19, 5) Source(8, 5) + SourceIndex(2) +3 >Emitted(19, 14) Source(8, 14) + SourceIndex(2) +4 >Emitted(19, 17) Source(8, 17) + SourceIndex(2) +5 >Emitted(19, 21) Source(8, 21) + SourceIndex(2) +6 >Emitted(19, 23) Source(8, 23) + SourceIndex(2) +7 >Emitted(19, 25) Source(8, 25) + SourceIndex(2) +8 >Emitted(19, 26) Source(8, 26) + SourceIndex(2) --- >>>function f1() { 1 > 2 >^^^^^^^^^^^^^^^^^^^^^^-> 1 > > -1 >Emitted(20, 1) Source(9, 1) + SourceIndex(1) +1 >Emitted(20, 1) Source(9, 1) + SourceIndex(2) --- >>> return instance1; 1->^^^^ @@ -452,11 +452,11 @@ sourceFile:../test.ts 3 > 4 > instance1 5 > ; -1->Emitted(21, 5) Source(10, 5) + SourceIndex(1) name (f1) -2 >Emitted(21, 11) Source(10, 11) + SourceIndex(1) name (f1) -3 >Emitted(21, 12) Source(10, 12) + SourceIndex(1) name (f1) -4 >Emitted(21, 21) Source(10, 21) + SourceIndex(1) name (f1) -5 >Emitted(21, 22) Source(10, 22) + SourceIndex(1) name (f1) +1->Emitted(21, 5) Source(10, 5) + SourceIndex(2) name (f1) +2 >Emitted(21, 11) Source(10, 11) + SourceIndex(2) name (f1) +3 >Emitted(21, 12) Source(10, 12) + SourceIndex(2) name (f1) +4 >Emitted(21, 21) Source(10, 21) + SourceIndex(2) name (f1) +5 >Emitted(21, 22) Source(10, 22) + SourceIndex(2) name (f1) --- >>>} 1 > @@ -465,7 +465,7 @@ sourceFile:../test.ts 1 > > 2 >} -1 >Emitted(22, 1) Source(11, 1) + SourceIndex(1) name (f1) -2 >Emitted(22, 2) Source(11, 2) + SourceIndex(1) name (f1) +1 >Emitted(22, 1) Source(11, 1) + SourceIndex(2) name (f1) +2 >Emitted(22, 2) Source(11, 2) + SourceIndex(2) name (f1) --- >>>//# sourceMappingURL=outAndOutDirFile.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcemapModuleMultifolderSpecifyOutputFile/amd/bin/test.d.ts b/tests/baselines/reference/project/sourcemapModuleMultifolderSpecifyOutputFile/amd/bin/test.d.ts deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/tests/baselines/reference/project/sourcemapModuleMultifolderSpecifyOutputFile/amd/bin/test.js b/tests/baselines/reference/project/sourcemapModuleMultifolderSpecifyOutputFile/amd/bin/test.js deleted file mode 100644 index 6f3fefb9498..00000000000 --- a/tests/baselines/reference/project/sourcemapModuleMultifolderSpecifyOutputFile/amd/bin/test.js +++ /dev/null @@ -1 +0,0 @@ -//# sourceMappingURL=test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcemapModuleMultifolderSpecifyOutputFile/amd/bin/test.js.map b/tests/baselines/reference/project/sourcemapModuleMultifolderSpecifyOutputFile/amd/bin/test.js.map index c1e0281a2ab..c532c3846d9 100644 --- a/tests/baselines/reference/project/sourcemapModuleMultifolderSpecifyOutputFile/amd/bin/test.js.map +++ b/tests/baselines/reference/project/sourcemapModuleMultifolderSpecifyOutputFile/amd/bin/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"","sources":[],"names":[],"mappings":""} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"","sources":["../ref/m1.ts","../../outputdir_module_multifolder_ref/m2.ts","../test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","m2_c1","m2_c1.constructor","m2_f1","c1","c1.constructor","f1"],"mappings":";IAAW,aAAK,GAAG,EAAE,CAAC;IACtB;QAAAA;QAEAC,CAACA;QAADD,YAACA;IAADA,CAACA,AAFD,IAEC;IAFY,aAAK,QAEjB,CAAA;IAEU,oBAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACIE,MAAMA,CAACA,oBAAYA,CAACA;IACxBA,CAACA;IAFe,aAAK,QAEpB,CAAA;;;ICRU,aAAK,GAAG,EAAE,CAAC;IACtB;QAAAC;QAEAC,CAACA;QAADD,YAACA;IAADA,CAACA,AAFD,IAEC;IAFY,aAAK,QAEjB,CAAA;IAEU,oBAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACIE,MAAMA,CAACA,oBAAYA,CAACA;IACxBA,CAACA;IAFe,aAAK,QAEpB,CAAA;;;ICNU,UAAE,GAAG,EAAE,CAAC;IACnB;QAAAC;QAEAC,CAACA;QAADD,SAACA;IAADA,CAACA,AAFD,IAEC;IAFY,UAAE,KAEd,CAAA;IAEU,iBAAS,GAAG,IAAI,EAAE,EAAE,CAAC;IAChC;QACIE,MAAMA,CAACA,iBAASA,CAACA;IACrBA,CAACA;IAFe,UAAE,KAEjB,CAAA;IAEU,UAAE,GAAG,EAAE,CAAC,KAAK,CAAC;IACd,UAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcemapModuleMultifolderSpecifyOutputFile/amd/sourcemapModuleMultifolderSpecifyOutputFile.sourcemap.txt b/tests/baselines/reference/project/sourcemapModuleMultifolderSpecifyOutputFile/amd/sourcemapModuleMultifolderSpecifyOutputFile.sourcemap.txt index 74ecef44103..3fa1bc7e057 100644 --- a/tests/baselines/reference/project/sourcemapModuleMultifolderSpecifyOutputFile/amd/sourcemapModuleMultifolderSpecifyOutputFile.sourcemap.txt +++ b/tests/baselines/reference/project/sourcemapModuleMultifolderSpecifyOutputFile/amd/sourcemapModuleMultifolderSpecifyOutputFile.sourcemap.txt @@ -571,6 +571,557 @@ sourceFile:test.ts JsFile: test.js mapUrl: test.js.map sourceRoot: -sources: +sources: ../ref/m1.ts,../../outputdir_module_multifolder_ref/m2.ts,../test.ts =================================================================== +------------------------------------------------------------------- +emittedFile:bin/test.js +sourceFile:../ref/m1.ts +------------------------------------------------------------------- +>>>define("ref/m1", ["require", "exports"], function (require, exports) { +>>> exports.m1_a1 = 10; +1 >^^^^ +2 > ^^^^^^^^^^^^^ +3 > ^^^ +4 > ^^ +5 > ^ +6 > ^^^^^^^^-> +1 >export var +2 > m1_a1 +3 > = +4 > 10 +5 > ; +1 >Emitted(2, 5) Source(1, 12) + SourceIndex(0) +2 >Emitted(2, 18) Source(1, 17) + SourceIndex(0) +3 >Emitted(2, 21) Source(1, 20) + SourceIndex(0) +4 >Emitted(2, 23) Source(1, 22) + SourceIndex(0) +5 >Emitted(2, 24) Source(1, 23) + SourceIndex(0) +--- +>>> var m1_c1 = (function () { +1->^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^^^^-> +1-> + > +1->Emitted(3, 5) Source(2, 1) + SourceIndex(0) +--- +>>> function m1_c1() { +1->^^^^^^^^ +2 > ^^-> +1-> +1->Emitted(4, 9) Source(2, 1) + SourceIndex(0) name (m1_c1) +--- +>>> } +1->^^^^^^^^ +2 > ^ +3 > ^^^^^^^^^^^^^-> +1->export class m1_c1 { + > public m1_c1_p1: number; + > +2 > } +1->Emitted(5, 9) Source(4, 1) + SourceIndex(0) name (m1_c1.constructor) +2 >Emitted(5, 10) Source(4, 2) + SourceIndex(0) name (m1_c1.constructor) +--- +>>> return m1_c1; +1->^^^^^^^^ +2 > ^^^^^^^^^^^^ +1-> +2 > } +1->Emitted(6, 9) Source(4, 1) + SourceIndex(0) name (m1_c1) +2 >Emitted(6, 21) Source(4, 2) + SourceIndex(0) name (m1_c1) +--- +>>> })(); +1 >^^^^ +2 > ^ +3 > +4 > ^^^^ +5 > ^^^^^^^^^^^^^^^^^^-> +1 > +2 > } +3 > +4 > export class m1_c1 { + > public m1_c1_p1: number; + > } +1 >Emitted(7, 5) Source(4, 1) + SourceIndex(0) name (m1_c1) +2 >Emitted(7, 6) Source(4, 2) + SourceIndex(0) name (m1_c1) +3 >Emitted(7, 6) Source(2, 1) + SourceIndex(0) +4 >Emitted(7, 10) Source(4, 2) + SourceIndex(0) +--- +>>> exports.m1_c1 = m1_c1; +1->^^^^ +2 > ^^^^^^^^^^^^^ +3 > ^^^^^^^^ +4 > ^ +5 > ^^^^^^^^^^^^^^-> +1-> +2 > m1_c1 +3 > { + > public m1_c1_p1: number; + > } +4 > +1->Emitted(8, 5) Source(2, 14) + SourceIndex(0) +2 >Emitted(8, 18) Source(2, 19) + SourceIndex(0) +3 >Emitted(8, 26) Source(4, 2) + SourceIndex(0) +4 >Emitted(8, 27) Source(4, 2) + SourceIndex(0) +--- +>>> exports.m1_instance1 = new m1_c1(); +1->^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^ +3 > ^^^ +4 > ^^^^ +5 > ^^^^^ +6 > ^^ +7 > ^ +1-> + > + >export var +2 > m1_instance1 +3 > = +4 > new +5 > m1_c1 +6 > () +7 > ; +1->Emitted(9, 5) Source(6, 12) + SourceIndex(0) +2 >Emitted(9, 25) Source(6, 24) + SourceIndex(0) +3 >Emitted(9, 28) Source(6, 27) + SourceIndex(0) +4 >Emitted(9, 32) Source(6, 31) + SourceIndex(0) +5 >Emitted(9, 37) Source(6, 36) + SourceIndex(0) +6 >Emitted(9, 39) Source(6, 38) + SourceIndex(0) +7 >Emitted(9, 40) Source(6, 39) + SourceIndex(0) +--- +>>> function m1_f1() { +1 >^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +1 > + > +1 >Emitted(10, 5) Source(7, 1) + SourceIndex(0) +--- +>>> return exports.m1_instance1; +1->^^^^^^^^ +2 > ^^^^^^ +3 > ^ +4 > ^^^^^^^^^^^^^^^^^^^^ +5 > ^ +1->export function m1_f1() { + > +2 > return +3 > +4 > m1_instance1 +5 > ; +1->Emitted(11, 9) Source(8, 5) + SourceIndex(0) name (m1_f1) +2 >Emitted(11, 15) Source(8, 11) + SourceIndex(0) name (m1_f1) +3 >Emitted(11, 16) Source(8, 12) + SourceIndex(0) name (m1_f1) +4 >Emitted(11, 36) Source(8, 24) + SourceIndex(0) name (m1_f1) +5 >Emitted(11, 37) Source(8, 25) + SourceIndex(0) name (m1_f1) +--- +>>> } +1 >^^^^ +2 > ^ +3 > ^^^^^^^^^^^^^^^^^^^^^^-> +1 > + > +2 > } +1 >Emitted(12, 5) Source(9, 1) + SourceIndex(0) name (m1_f1) +2 >Emitted(12, 6) Source(9, 2) + SourceIndex(0) name (m1_f1) +--- +>>> exports.m1_f1 = m1_f1; +1->^^^^ +2 > ^^^^^^^^^^^^^ +3 > ^^^^^^^^ +4 > ^ +1-> +2 > m1_f1 +3 > () { + > return m1_instance1; + > } +4 > +1->Emitted(13, 5) Source(7, 17) + SourceIndex(0) +2 >Emitted(13, 18) Source(7, 22) + SourceIndex(0) +3 >Emitted(13, 26) Source(9, 2) + SourceIndex(0) +4 >Emitted(13, 27) Source(9, 2) + SourceIndex(0) +--- +------------------------------------------------------------------- +emittedFile:bin/test.js +sourceFile:../../outputdir_module_multifolder_ref/m2.ts +------------------------------------------------------------------- +>>>}); +>>>define("../outputdir_module_multifolder_ref/m2", ["require", "exports"], function (require, exports) { +>>> exports.m2_a1 = 10; +1 >^^^^ +2 > ^^^^^^^^^^^^^ +3 > ^^^ +4 > ^^ +5 > ^ +6 > ^^^^^^^^-> +1 >export var +2 > m2_a1 +3 > = +4 > 10 +5 > ; +1 >Emitted(16, 5) Source(1, 12) + SourceIndex(1) +2 >Emitted(16, 18) Source(1, 17) + SourceIndex(1) +3 >Emitted(16, 21) Source(1, 20) + SourceIndex(1) +4 >Emitted(16, 23) Source(1, 22) + SourceIndex(1) +5 >Emitted(16, 24) Source(1, 23) + SourceIndex(1) +--- +>>> var m2_c1 = (function () { +1->^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^^^^-> +1-> + > +1->Emitted(17, 5) Source(2, 1) + SourceIndex(1) +--- +>>> function m2_c1() { +1->^^^^^^^^ +2 > ^^-> +1-> +1->Emitted(18, 9) Source(2, 1) + SourceIndex(1) name (m2_c1) +--- +>>> } +1->^^^^^^^^ +2 > ^ +3 > ^^^^^^^^^^^^^-> +1->export class m2_c1 { + > public m2_c1_p1: number; + > +2 > } +1->Emitted(19, 9) Source(4, 1) + SourceIndex(1) name (m2_c1.constructor) +2 >Emitted(19, 10) Source(4, 2) + SourceIndex(1) name (m2_c1.constructor) +--- +>>> return m2_c1; +1->^^^^^^^^ +2 > ^^^^^^^^^^^^ +1-> +2 > } +1->Emitted(20, 9) Source(4, 1) + SourceIndex(1) name (m2_c1) +2 >Emitted(20, 21) Source(4, 2) + SourceIndex(1) name (m2_c1) +--- +>>> })(); +1 >^^^^ +2 > ^ +3 > +4 > ^^^^ +5 > ^^^^^^^^^^^^^^^^^^-> +1 > +2 > } +3 > +4 > export class m2_c1 { + > public m2_c1_p1: number; + > } +1 >Emitted(21, 5) Source(4, 1) + SourceIndex(1) name (m2_c1) +2 >Emitted(21, 6) Source(4, 2) + SourceIndex(1) name (m2_c1) +3 >Emitted(21, 6) Source(2, 1) + SourceIndex(1) +4 >Emitted(21, 10) Source(4, 2) + SourceIndex(1) +--- +>>> exports.m2_c1 = m2_c1; +1->^^^^ +2 > ^^^^^^^^^^^^^ +3 > ^^^^^^^^ +4 > ^ +5 > ^^^^^^^^^^^^^^-> +1-> +2 > m2_c1 +3 > { + > public m2_c1_p1: number; + > } +4 > +1->Emitted(22, 5) Source(2, 14) + SourceIndex(1) +2 >Emitted(22, 18) Source(2, 19) + SourceIndex(1) +3 >Emitted(22, 26) Source(4, 2) + SourceIndex(1) +4 >Emitted(22, 27) Source(4, 2) + SourceIndex(1) +--- +>>> exports.m2_instance1 = new m2_c1(); +1->^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^ +3 > ^^^ +4 > ^^^^ +5 > ^^^^^ +6 > ^^ +7 > ^ +1-> + > + >export var +2 > m2_instance1 +3 > = +4 > new +5 > m2_c1 +6 > () +7 > ; +1->Emitted(23, 5) Source(6, 12) + SourceIndex(1) +2 >Emitted(23, 25) Source(6, 24) + SourceIndex(1) +3 >Emitted(23, 28) Source(6, 27) + SourceIndex(1) +4 >Emitted(23, 32) Source(6, 31) + SourceIndex(1) +5 >Emitted(23, 37) Source(6, 36) + SourceIndex(1) +6 >Emitted(23, 39) Source(6, 38) + SourceIndex(1) +7 >Emitted(23, 40) Source(6, 39) + SourceIndex(1) +--- +>>> function m2_f1() { +1 >^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +1 > + > +1 >Emitted(24, 5) Source(7, 1) + SourceIndex(1) +--- +>>> return exports.m2_instance1; +1->^^^^^^^^ +2 > ^^^^^^ +3 > ^ +4 > ^^^^^^^^^^^^^^^^^^^^ +5 > ^ +1->export function m2_f1() { + > +2 > return +3 > +4 > m2_instance1 +5 > ; +1->Emitted(25, 9) Source(8, 5) + SourceIndex(1) name (m2_f1) +2 >Emitted(25, 15) Source(8, 11) + SourceIndex(1) name (m2_f1) +3 >Emitted(25, 16) Source(8, 12) + SourceIndex(1) name (m2_f1) +4 >Emitted(25, 36) Source(8, 24) + SourceIndex(1) name (m2_f1) +5 >Emitted(25, 37) Source(8, 25) + SourceIndex(1) name (m2_f1) +--- +>>> } +1 >^^^^ +2 > ^ +3 > ^^^^^^^^^^^^^^^^^^^^^^-> +1 > + > +2 > } +1 >Emitted(26, 5) Source(9, 1) + SourceIndex(1) name (m2_f1) +2 >Emitted(26, 6) Source(9, 2) + SourceIndex(1) name (m2_f1) +--- +>>> exports.m2_f1 = m2_f1; +1->^^^^ +2 > ^^^^^^^^^^^^^ +3 > ^^^^^^^^ +4 > ^ +1-> +2 > m2_f1 +3 > () { + > return m2_instance1; + > } +4 > +1->Emitted(27, 5) Source(7, 17) + SourceIndex(1) +2 >Emitted(27, 18) Source(7, 22) + SourceIndex(1) +3 >Emitted(27, 26) Source(9, 2) + SourceIndex(1) +4 >Emitted(27, 27) Source(9, 2) + SourceIndex(1) +--- +------------------------------------------------------------------- +emittedFile:bin/test.js +sourceFile:../test.ts +------------------------------------------------------------------- +>>>}); +>>>define("test", ["require", "exports", "ref/m1", "../outputdir_module_multifolder_ref/m2"], function (require, exports, m1, m2) { +>>> exports.a1 = 10; +1 >^^^^ +2 > ^^^^^^^^^^ +3 > ^^^ +4 > ^^ +5 > ^ +6 > ^^^^^^^^-> +1 >import m1 = require("ref/m1"); + >import m2 = require("../outputdir_module_multifolder_ref/m2"); + >export var +2 > a1 +3 > = +4 > 10 +5 > ; +1 >Emitted(30, 5) Source(3, 12) + SourceIndex(2) +2 >Emitted(30, 15) Source(3, 14) + SourceIndex(2) +3 >Emitted(30, 18) Source(3, 17) + SourceIndex(2) +4 >Emitted(30, 20) Source(3, 19) + SourceIndex(2) +5 >Emitted(30, 21) Source(3, 20) + SourceIndex(2) +--- +>>> var c1 = (function () { +1->^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^-> +1-> + > +1->Emitted(31, 5) Source(4, 1) + SourceIndex(2) +--- +>>> function c1() { +1->^^^^^^^^ +2 > ^^-> +1-> +1->Emitted(32, 9) Source(4, 1) + SourceIndex(2) name (c1) +--- +>>> } +1->^^^^^^^^ +2 > ^ +3 > ^^^^^^^^^^-> +1->export class c1 { + > public p1: number; + > +2 > } +1->Emitted(33, 9) Source(6, 1) + SourceIndex(2) name (c1.constructor) +2 >Emitted(33, 10) Source(6, 2) + SourceIndex(2) name (c1.constructor) +--- +>>> return c1; +1->^^^^^^^^ +2 > ^^^^^^^^^ +1-> +2 > } +1->Emitted(34, 9) Source(6, 1) + SourceIndex(2) name (c1) +2 >Emitted(34, 18) Source(6, 2) + SourceIndex(2) name (c1) +--- +>>> })(); +1 >^^^^ +2 > ^ +3 > +4 > ^^^^ +5 > ^^^^^^^^^^^^-> +1 > +2 > } +3 > +4 > export class c1 { + > public p1: number; + > } +1 >Emitted(35, 5) Source(6, 1) + SourceIndex(2) name (c1) +2 >Emitted(35, 6) Source(6, 2) + SourceIndex(2) name (c1) +3 >Emitted(35, 6) Source(4, 1) + SourceIndex(2) +4 >Emitted(35, 10) Source(6, 2) + SourceIndex(2) +--- +>>> exports.c1 = c1; +1->^^^^ +2 > ^^^^^^^^^^ +3 > ^^^^^ +4 > ^ +5 > ^^^^^^^^^^^^^^-> +1-> +2 > c1 +3 > { + > public p1: number; + > } +4 > +1->Emitted(36, 5) Source(4, 14) + SourceIndex(2) +2 >Emitted(36, 15) Source(4, 16) + SourceIndex(2) +3 >Emitted(36, 20) Source(6, 2) + SourceIndex(2) +4 >Emitted(36, 21) Source(6, 2) + SourceIndex(2) +--- +>>> exports.instance1 = new c1(); +1->^^^^ +2 > ^^^^^^^^^^^^^^^^^ +3 > ^^^ +4 > ^^^^ +5 > ^^ +6 > ^^ +7 > ^ +1-> + > + >export var +2 > instance1 +3 > = +4 > new +5 > c1 +6 > () +7 > ; +1->Emitted(37, 5) Source(8, 12) + SourceIndex(2) +2 >Emitted(37, 22) Source(8, 21) + SourceIndex(2) +3 >Emitted(37, 25) Source(8, 24) + SourceIndex(2) +4 >Emitted(37, 29) Source(8, 28) + SourceIndex(2) +5 >Emitted(37, 31) Source(8, 30) + SourceIndex(2) +6 >Emitted(37, 33) Source(8, 32) + SourceIndex(2) +7 >Emitted(37, 34) Source(8, 33) + SourceIndex(2) +--- +>>> function f1() { +1 >^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +1 > + > +1 >Emitted(38, 5) Source(9, 1) + SourceIndex(2) +--- +>>> return exports.instance1; +1->^^^^^^^^ +2 > ^^^^^^ +3 > ^ +4 > ^^^^^^^^^^^^^^^^^ +5 > ^ +1->export function f1() { + > +2 > return +3 > +4 > instance1 +5 > ; +1->Emitted(39, 9) Source(10, 5) + SourceIndex(2) name (f1) +2 >Emitted(39, 15) Source(10, 11) + SourceIndex(2) name (f1) +3 >Emitted(39, 16) Source(10, 12) + SourceIndex(2) name (f1) +4 >Emitted(39, 33) Source(10, 21) + SourceIndex(2) name (f1) +5 >Emitted(39, 34) Source(10, 22) + SourceIndex(2) name (f1) +--- +>>> } +1 >^^^^ +2 > ^ +3 > ^^^^^^^^^^^^^^^^-> +1 > + > +2 > } +1 >Emitted(40, 5) Source(11, 1) + SourceIndex(2) name (f1) +2 >Emitted(40, 6) Source(11, 2) + SourceIndex(2) name (f1) +--- +>>> exports.f1 = f1; +1->^^^^ +2 > ^^^^^^^^^^ +3 > ^^^^^ +4 > ^ +5 > ^^^^^^^-> +1-> +2 > f1 +3 > () { + > return instance1; + > } +4 > +1->Emitted(41, 5) Source(9, 17) + SourceIndex(2) +2 >Emitted(41, 15) Source(9, 19) + SourceIndex(2) +3 >Emitted(41, 20) Source(11, 2) + SourceIndex(2) +4 >Emitted(41, 21) Source(11, 2) + SourceIndex(2) +--- +>>> exports.a2 = m1.m1_c1; +1->^^^^ +2 > ^^^^^^^^^^ +3 > ^^^ +4 > ^^ +5 > ^ +6 > ^^^^^ +7 > ^ +8 > ^-> +1-> + > + >export var +2 > a2 +3 > = +4 > m1 +5 > . +6 > m1_c1 +7 > ; +1->Emitted(42, 5) Source(13, 12) + SourceIndex(2) +2 >Emitted(42, 15) Source(13, 14) + SourceIndex(2) +3 >Emitted(42, 18) Source(13, 17) + SourceIndex(2) +4 >Emitted(42, 20) Source(13, 19) + SourceIndex(2) +5 >Emitted(42, 21) Source(13, 20) + SourceIndex(2) +6 >Emitted(42, 26) Source(13, 25) + SourceIndex(2) +7 >Emitted(42, 27) Source(13, 26) + SourceIndex(2) +--- +>>> exports.a3 = m2.m2_c1; +1->^^^^ +2 > ^^^^^^^^^^ +3 > ^^^ +4 > ^^ +5 > ^ +6 > ^^^^^ +7 > ^ +1-> + >export var +2 > a3 +3 > = +4 > m2 +5 > . +6 > m2_c1 +7 > ; +1->Emitted(43, 5) Source(14, 12) + SourceIndex(2) +2 >Emitted(43, 15) Source(14, 14) + SourceIndex(2) +3 >Emitted(43, 18) Source(14, 17) + SourceIndex(2) +4 >Emitted(43, 20) Source(14, 19) + SourceIndex(2) +5 >Emitted(43, 21) Source(14, 20) + SourceIndex(2) +6 >Emitted(43, 26) Source(14, 25) + SourceIndex(2) +7 >Emitted(43, 27) Source(14, 26) + SourceIndex(2) +--- +>>>}); >>>//# sourceMappingURL=test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcemapModuleMultifolderSpecifyOutputFile/node/bin/test.d.ts b/tests/baselines/reference/project/sourcemapModuleMultifolderSpecifyOutputFile/node/bin/test.d.ts deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/tests/baselines/reference/project/sourcemapModuleMultifolderSpecifyOutputFile/node/bin/test.js b/tests/baselines/reference/project/sourcemapModuleMultifolderSpecifyOutputFile/node/bin/test.js deleted file mode 100644 index 6f3fefb9498..00000000000 --- a/tests/baselines/reference/project/sourcemapModuleMultifolderSpecifyOutputFile/node/bin/test.js +++ /dev/null @@ -1 +0,0 @@ -//# sourceMappingURL=test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcemapModuleMultifolderSpecifyOutputFile/node/bin/test.js.map b/tests/baselines/reference/project/sourcemapModuleMultifolderSpecifyOutputFile/node/bin/test.js.map index c1e0281a2ab..2974abdc1cc 100644 --- a/tests/baselines/reference/project/sourcemapModuleMultifolderSpecifyOutputFile/node/bin/test.js.map +++ b/tests/baselines/reference/project/sourcemapModuleMultifolderSpecifyOutputFile/node/bin/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"","sources":[],"names":[],"mappings":""} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"","sources":["../ref/m1.ts","../../outputdir_module_multifolder_ref/m2.ts","../test.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcemapModuleMultifolderSpecifyOutputFile/node/sourcemapModuleMultifolderSpecifyOutputFile.sourcemap.txt b/tests/baselines/reference/project/sourcemapModuleMultifolderSpecifyOutputFile/node/sourcemapModuleMultifolderSpecifyOutputFile.sourcemap.txt index f8d10678ca0..d36064b989c 100644 --- a/tests/baselines/reference/project/sourcemapModuleMultifolderSpecifyOutputFile/node/sourcemapModuleMultifolderSpecifyOutputFile.sourcemap.txt +++ b/tests/baselines/reference/project/sourcemapModuleMultifolderSpecifyOutputFile/node/sourcemapModuleMultifolderSpecifyOutputFile.sourcemap.txt @@ -615,6 +615,6 @@ sourceFile:test.ts JsFile: test.js mapUrl: test.js.map sourceRoot: -sources: +sources: ../ref/m1.ts,../../outputdir_module_multifolder_ref/m2.ts,../test.ts =================================================================== >>>//# sourceMappingURL=test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcemapModuleSimpleSpecifyOutputFile/amd/bin/test.d.ts b/tests/baselines/reference/project/sourcemapModuleSimpleSpecifyOutputFile/amd/bin/test.d.ts deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/tests/baselines/reference/project/sourcemapModuleSimpleSpecifyOutputFile/amd/bin/test.js b/tests/baselines/reference/project/sourcemapModuleSimpleSpecifyOutputFile/amd/bin/test.js deleted file mode 100644 index 6f3fefb9498..00000000000 --- a/tests/baselines/reference/project/sourcemapModuleSimpleSpecifyOutputFile/amd/bin/test.js +++ /dev/null @@ -1 +0,0 @@ -//# sourceMappingURL=test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcemapModuleSimpleSpecifyOutputFile/amd/bin/test.js.map b/tests/baselines/reference/project/sourcemapModuleSimpleSpecifyOutputFile/amd/bin/test.js.map index c1e0281a2ab..6377a26395e 100644 --- a/tests/baselines/reference/project/sourcemapModuleSimpleSpecifyOutputFile/amd/bin/test.js.map +++ b/tests/baselines/reference/project/sourcemapModuleSimpleSpecifyOutputFile/amd/bin/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"","sources":[],"names":[],"mappings":""} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"","sources":["../m1.ts","../test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","c1","c1.constructor","f1"],"mappings":";IAAW,aAAK,GAAG,EAAE,CAAC;IACtB;QAAAA;QAEAC,CAACA;QAADD,YAACA;IAADA,CAACA,AAFD,IAEC;IAFY,aAAK,QAEjB,CAAA;IAEU,oBAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACIE,MAAMA,CAACA,oBAAYA,CAACA;IACxBA,CAACA;IAFe,aAAK,QAEpB,CAAA;;;ICPU,UAAE,GAAG,EAAE,CAAC;IACnB;QAAAC;QAEAC,CAACA;QAADD,SAACA;IAADA,CAACA,AAFD,IAEC;IAFY,UAAE,KAEd,CAAA;IAEU,iBAAS,GAAG,IAAI,EAAE,EAAE,CAAC;IAChC;QACIE,MAAMA,CAACA,iBAASA,CAACA;IACrBA,CAACA;IAFe,UAAE,KAEjB,CAAA;IAEU,UAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcemapModuleSimpleSpecifyOutputFile/amd/sourcemapModuleSimpleSpecifyOutputFile.sourcemap.txt b/tests/baselines/reference/project/sourcemapModuleSimpleSpecifyOutputFile/amd/sourcemapModuleSimpleSpecifyOutputFile.sourcemap.txt index a1646bc14e5..2d6e3052871 100644 --- a/tests/baselines/reference/project/sourcemapModuleSimpleSpecifyOutputFile/amd/sourcemapModuleSimpleSpecifyOutputFile.sourcemap.txt +++ b/tests/baselines/reference/project/sourcemapModuleSimpleSpecifyOutputFile/amd/sourcemapModuleSimpleSpecifyOutputFile.sourcemap.txt @@ -373,6 +373,365 @@ sourceFile:test.ts JsFile: test.js mapUrl: test.js.map sourceRoot: -sources: +sources: ../m1.ts,../test.ts =================================================================== +------------------------------------------------------------------- +emittedFile:bin/test.js +sourceFile:../m1.ts +------------------------------------------------------------------- +>>>define("m1", ["require", "exports"], function (require, exports) { +>>> exports.m1_a1 = 10; +1 >^^^^ +2 > ^^^^^^^^^^^^^ +3 > ^^^ +4 > ^^ +5 > ^ +6 > ^^^^^^^^-> +1 >export var +2 > m1_a1 +3 > = +4 > 10 +5 > ; +1 >Emitted(2, 5) Source(1, 12) + SourceIndex(0) +2 >Emitted(2, 18) Source(1, 17) + SourceIndex(0) +3 >Emitted(2, 21) Source(1, 20) + SourceIndex(0) +4 >Emitted(2, 23) Source(1, 22) + SourceIndex(0) +5 >Emitted(2, 24) Source(1, 23) + SourceIndex(0) +--- +>>> var m1_c1 = (function () { +1->^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^^^^-> +1-> + > +1->Emitted(3, 5) Source(2, 1) + SourceIndex(0) +--- +>>> function m1_c1() { +1->^^^^^^^^ +2 > ^^-> +1-> +1->Emitted(4, 9) Source(2, 1) + SourceIndex(0) name (m1_c1) +--- +>>> } +1->^^^^^^^^ +2 > ^ +3 > ^^^^^^^^^^^^^-> +1->export class m1_c1 { + > public m1_c1_p1: number; + > +2 > } +1->Emitted(5, 9) Source(4, 1) + SourceIndex(0) name (m1_c1.constructor) +2 >Emitted(5, 10) Source(4, 2) + SourceIndex(0) name (m1_c1.constructor) +--- +>>> return m1_c1; +1->^^^^^^^^ +2 > ^^^^^^^^^^^^ +1-> +2 > } +1->Emitted(6, 9) Source(4, 1) + SourceIndex(0) name (m1_c1) +2 >Emitted(6, 21) Source(4, 2) + SourceIndex(0) name (m1_c1) +--- +>>> })(); +1 >^^^^ +2 > ^ +3 > +4 > ^^^^ +5 > ^^^^^^^^^^^^^^^^^^-> +1 > +2 > } +3 > +4 > export class m1_c1 { + > public m1_c1_p1: number; + > } +1 >Emitted(7, 5) Source(4, 1) + SourceIndex(0) name (m1_c1) +2 >Emitted(7, 6) Source(4, 2) + SourceIndex(0) name (m1_c1) +3 >Emitted(7, 6) Source(2, 1) + SourceIndex(0) +4 >Emitted(7, 10) Source(4, 2) + SourceIndex(0) +--- +>>> exports.m1_c1 = m1_c1; +1->^^^^ +2 > ^^^^^^^^^^^^^ +3 > ^^^^^^^^ +4 > ^ +5 > ^^^^^^^^^^^^^^-> +1-> +2 > m1_c1 +3 > { + > public m1_c1_p1: number; + > } +4 > +1->Emitted(8, 5) Source(2, 14) + SourceIndex(0) +2 >Emitted(8, 18) Source(2, 19) + SourceIndex(0) +3 >Emitted(8, 26) Source(4, 2) + SourceIndex(0) +4 >Emitted(8, 27) Source(4, 2) + SourceIndex(0) +--- +>>> exports.m1_instance1 = new m1_c1(); +1->^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^ +3 > ^^^ +4 > ^^^^ +5 > ^^^^^ +6 > ^^ +7 > ^ +1-> + > + >export var +2 > m1_instance1 +3 > = +4 > new +5 > m1_c1 +6 > () +7 > ; +1->Emitted(9, 5) Source(6, 12) + SourceIndex(0) +2 >Emitted(9, 25) Source(6, 24) + SourceIndex(0) +3 >Emitted(9, 28) Source(6, 27) + SourceIndex(0) +4 >Emitted(9, 32) Source(6, 31) + SourceIndex(0) +5 >Emitted(9, 37) Source(6, 36) + SourceIndex(0) +6 >Emitted(9, 39) Source(6, 38) + SourceIndex(0) +7 >Emitted(9, 40) Source(6, 39) + SourceIndex(0) +--- +>>> function m1_f1() { +1 >^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +1 > + > +1 >Emitted(10, 5) Source(7, 1) + SourceIndex(0) +--- +>>> return exports.m1_instance1; +1->^^^^^^^^ +2 > ^^^^^^ +3 > ^ +4 > ^^^^^^^^^^^^^^^^^^^^ +5 > ^ +1->export function m1_f1() { + > +2 > return +3 > +4 > m1_instance1 +5 > ; +1->Emitted(11, 9) Source(8, 5) + SourceIndex(0) name (m1_f1) +2 >Emitted(11, 15) Source(8, 11) + SourceIndex(0) name (m1_f1) +3 >Emitted(11, 16) Source(8, 12) + SourceIndex(0) name (m1_f1) +4 >Emitted(11, 36) Source(8, 24) + SourceIndex(0) name (m1_f1) +5 >Emitted(11, 37) Source(8, 25) + SourceIndex(0) name (m1_f1) +--- +>>> } +1 >^^^^ +2 > ^ +3 > ^^^^^^^^^^^^^^^^^^^^^^-> +1 > + > +2 > } +1 >Emitted(12, 5) Source(9, 1) + SourceIndex(0) name (m1_f1) +2 >Emitted(12, 6) Source(9, 2) + SourceIndex(0) name (m1_f1) +--- +>>> exports.m1_f1 = m1_f1; +1->^^^^ +2 > ^^^^^^^^^^^^^ +3 > ^^^^^^^^ +4 > ^ +1-> +2 > m1_f1 +3 > () { + > return m1_instance1; + > } +4 > +1->Emitted(13, 5) Source(7, 17) + SourceIndex(0) +2 >Emitted(13, 18) Source(7, 22) + SourceIndex(0) +3 >Emitted(13, 26) Source(9, 2) + SourceIndex(0) +4 >Emitted(13, 27) Source(9, 2) + SourceIndex(0) +--- +------------------------------------------------------------------- +emittedFile:bin/test.js +sourceFile:../test.ts +------------------------------------------------------------------- +>>>}); +>>>define("test", ["require", "exports", "m1"], function (require, exports, m1) { +>>> exports.a1 = 10; +1 >^^^^ +2 > ^^^^^^^^^^ +3 > ^^^ +4 > ^^ +5 > ^ +6 > ^^^^^^^^-> +1 >import m1 = require("m1"); + >export var +2 > a1 +3 > = +4 > 10 +5 > ; +1 >Emitted(16, 5) Source(2, 12) + SourceIndex(1) +2 >Emitted(16, 15) Source(2, 14) + SourceIndex(1) +3 >Emitted(16, 18) Source(2, 17) + SourceIndex(1) +4 >Emitted(16, 20) Source(2, 19) + SourceIndex(1) +5 >Emitted(16, 21) Source(2, 20) + SourceIndex(1) +--- +>>> var c1 = (function () { +1->^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^-> +1-> + > +1->Emitted(17, 5) Source(3, 1) + SourceIndex(1) +--- +>>> function c1() { +1->^^^^^^^^ +2 > ^^-> +1-> +1->Emitted(18, 9) Source(3, 1) + SourceIndex(1) name (c1) +--- +>>> } +1->^^^^^^^^ +2 > ^ +3 > ^^^^^^^^^^-> +1->export class c1 { + > public p1: number; + > +2 > } +1->Emitted(19, 9) Source(5, 1) + SourceIndex(1) name (c1.constructor) +2 >Emitted(19, 10) Source(5, 2) + SourceIndex(1) name (c1.constructor) +--- +>>> return c1; +1->^^^^^^^^ +2 > ^^^^^^^^^ +1-> +2 > } +1->Emitted(20, 9) Source(5, 1) + SourceIndex(1) name (c1) +2 >Emitted(20, 18) Source(5, 2) + SourceIndex(1) name (c1) +--- +>>> })(); +1 >^^^^ +2 > ^ +3 > +4 > ^^^^ +5 > ^^^^^^^^^^^^-> +1 > +2 > } +3 > +4 > export class c1 { + > public p1: number; + > } +1 >Emitted(21, 5) Source(5, 1) + SourceIndex(1) name (c1) +2 >Emitted(21, 6) Source(5, 2) + SourceIndex(1) name (c1) +3 >Emitted(21, 6) Source(3, 1) + SourceIndex(1) +4 >Emitted(21, 10) Source(5, 2) + SourceIndex(1) +--- +>>> exports.c1 = c1; +1->^^^^ +2 > ^^^^^^^^^^ +3 > ^^^^^ +4 > ^ +5 > ^^^^^^^^^^^^^^-> +1-> +2 > c1 +3 > { + > public p1: number; + > } +4 > +1->Emitted(22, 5) Source(3, 14) + SourceIndex(1) +2 >Emitted(22, 15) Source(3, 16) + SourceIndex(1) +3 >Emitted(22, 20) Source(5, 2) + SourceIndex(1) +4 >Emitted(22, 21) Source(5, 2) + SourceIndex(1) +--- +>>> exports.instance1 = new c1(); +1->^^^^ +2 > ^^^^^^^^^^^^^^^^^ +3 > ^^^ +4 > ^^^^ +5 > ^^ +6 > ^^ +7 > ^ +1-> + > + >export var +2 > instance1 +3 > = +4 > new +5 > c1 +6 > () +7 > ; +1->Emitted(23, 5) Source(7, 12) + SourceIndex(1) +2 >Emitted(23, 22) Source(7, 21) + SourceIndex(1) +3 >Emitted(23, 25) Source(7, 24) + SourceIndex(1) +4 >Emitted(23, 29) Source(7, 28) + SourceIndex(1) +5 >Emitted(23, 31) Source(7, 30) + SourceIndex(1) +6 >Emitted(23, 33) Source(7, 32) + SourceIndex(1) +7 >Emitted(23, 34) Source(7, 33) + SourceIndex(1) +--- +>>> function f1() { +1 >^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +1 > + > +1 >Emitted(24, 5) Source(8, 1) + SourceIndex(1) +--- +>>> return exports.instance1; +1->^^^^^^^^ +2 > ^^^^^^ +3 > ^ +4 > ^^^^^^^^^^^^^^^^^ +5 > ^ +1->export function f1() { + > +2 > return +3 > +4 > instance1 +5 > ; +1->Emitted(25, 9) Source(9, 5) + SourceIndex(1) name (f1) +2 >Emitted(25, 15) Source(9, 11) + SourceIndex(1) name (f1) +3 >Emitted(25, 16) Source(9, 12) + SourceIndex(1) name (f1) +4 >Emitted(25, 33) Source(9, 21) + SourceIndex(1) name (f1) +5 >Emitted(25, 34) Source(9, 22) + SourceIndex(1) name (f1) +--- +>>> } +1 >^^^^ +2 > ^ +3 > ^^^^^^^^^^^^^^^^-> +1 > + > +2 > } +1 >Emitted(26, 5) Source(10, 1) + SourceIndex(1) name (f1) +2 >Emitted(26, 6) Source(10, 2) + SourceIndex(1) name (f1) +--- +>>> exports.f1 = f1; +1->^^^^ +2 > ^^^^^^^^^^ +3 > ^^^^^ +4 > ^ +5 > ^^^^^^^-> +1-> +2 > f1 +3 > () { + > return instance1; + > } +4 > +1->Emitted(27, 5) Source(8, 17) + SourceIndex(1) +2 >Emitted(27, 15) Source(8, 19) + SourceIndex(1) +3 >Emitted(27, 20) Source(10, 2) + SourceIndex(1) +4 >Emitted(27, 21) Source(10, 2) + SourceIndex(1) +--- +>>> exports.a2 = m1.m1_c1; +1->^^^^ +2 > ^^^^^^^^^^ +3 > ^^^ +4 > ^^ +5 > ^ +6 > ^^^^^ +7 > ^ +1-> + > + >export var +2 > a2 +3 > = +4 > m1 +5 > . +6 > m1_c1 +7 > ; +1->Emitted(28, 5) Source(12, 12) + SourceIndex(1) +2 >Emitted(28, 15) Source(12, 14) + SourceIndex(1) +3 >Emitted(28, 18) Source(12, 17) + SourceIndex(1) +4 >Emitted(28, 20) Source(12, 19) + SourceIndex(1) +5 >Emitted(28, 21) Source(12, 20) + SourceIndex(1) +6 >Emitted(28, 26) Source(12, 25) + SourceIndex(1) +7 >Emitted(28, 27) Source(12, 26) + SourceIndex(1) +--- +>>>}); >>>//# sourceMappingURL=test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcemapModuleSimpleSpecifyOutputFile/node/bin/test.d.ts b/tests/baselines/reference/project/sourcemapModuleSimpleSpecifyOutputFile/node/bin/test.d.ts deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/tests/baselines/reference/project/sourcemapModuleSimpleSpecifyOutputFile/node/bin/test.js b/tests/baselines/reference/project/sourcemapModuleSimpleSpecifyOutputFile/node/bin/test.js deleted file mode 100644 index 6f3fefb9498..00000000000 --- a/tests/baselines/reference/project/sourcemapModuleSimpleSpecifyOutputFile/node/bin/test.js +++ /dev/null @@ -1 +0,0 @@ -//# sourceMappingURL=test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcemapModuleSimpleSpecifyOutputFile/node/bin/test.js.map b/tests/baselines/reference/project/sourcemapModuleSimpleSpecifyOutputFile/node/bin/test.js.map index c1e0281a2ab..f491a9ec373 100644 --- a/tests/baselines/reference/project/sourcemapModuleSimpleSpecifyOutputFile/node/bin/test.js.map +++ b/tests/baselines/reference/project/sourcemapModuleSimpleSpecifyOutputFile/node/bin/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"","sources":[],"names":[],"mappings":""} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"","sources":["../m1.ts","../test.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcemapModuleSimpleSpecifyOutputFile/node/sourcemapModuleSimpleSpecifyOutputFile.sourcemap.txt b/tests/baselines/reference/project/sourcemapModuleSimpleSpecifyOutputFile/node/sourcemapModuleSimpleSpecifyOutputFile.sourcemap.txt index 4ff8b4fa8c7..c1334bd15ae 100644 --- a/tests/baselines/reference/project/sourcemapModuleSimpleSpecifyOutputFile/node/sourcemapModuleSimpleSpecifyOutputFile.sourcemap.txt +++ b/tests/baselines/reference/project/sourcemapModuleSimpleSpecifyOutputFile/node/sourcemapModuleSimpleSpecifyOutputFile.sourcemap.txt @@ -394,6 +394,6 @@ sourceFile:test.ts JsFile: test.js mapUrl: test.js.map sourceRoot: -sources: +sources: ../m1.ts,../test.ts =================================================================== >>>//# sourceMappingURL=test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcemapModuleSubfolderSpecifyOutputFile/amd/bin/test.d.ts b/tests/baselines/reference/project/sourcemapModuleSubfolderSpecifyOutputFile/amd/bin/test.d.ts deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/tests/baselines/reference/project/sourcemapModuleSubfolderSpecifyOutputFile/amd/bin/test.js b/tests/baselines/reference/project/sourcemapModuleSubfolderSpecifyOutputFile/amd/bin/test.js deleted file mode 100644 index 6f3fefb9498..00000000000 --- a/tests/baselines/reference/project/sourcemapModuleSubfolderSpecifyOutputFile/amd/bin/test.js +++ /dev/null @@ -1 +0,0 @@ -//# sourceMappingURL=test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcemapModuleSubfolderSpecifyOutputFile/amd/bin/test.js.map b/tests/baselines/reference/project/sourcemapModuleSubfolderSpecifyOutputFile/amd/bin/test.js.map index c1e0281a2ab..f77c1351b15 100644 --- a/tests/baselines/reference/project/sourcemapModuleSubfolderSpecifyOutputFile/amd/bin/test.js.map +++ b/tests/baselines/reference/project/sourcemapModuleSubfolderSpecifyOutputFile/amd/bin/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"","sources":[],"names":[],"mappings":""} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"","sources":["../ref/m1.ts","../test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","c1","c1.constructor","f1"],"mappings":";IAAW,aAAK,GAAG,EAAE,CAAC;IACtB;QAAAA;QAEAC,CAACA;QAADD,YAACA;IAADA,CAACA,AAFD,IAEC;IAFY,aAAK,QAEjB,CAAA;IAEU,oBAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACIE,MAAMA,CAACA,oBAAYA,CAACA;IACxBA,CAACA;IAFe,aAAK,QAEpB,CAAA;;;ICPU,UAAE,GAAG,EAAE,CAAC;IACnB;QAAAC;QAEAC,CAACA;QAADD,SAACA;IAADA,CAACA,AAFD,IAEC;IAFY,UAAE,KAEd,CAAA;IAEU,iBAAS,GAAG,IAAI,EAAE,EAAE,CAAC;IAChC;QACIE,MAAMA,CAACA,iBAASA,CAACA;IACrBA,CAACA;IAFe,UAAE,KAEjB,CAAA;IAEU,UAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcemapModuleSubfolderSpecifyOutputFile/amd/sourcemapModuleSubfolderSpecifyOutputFile.sourcemap.txt b/tests/baselines/reference/project/sourcemapModuleSubfolderSpecifyOutputFile/amd/sourcemapModuleSubfolderSpecifyOutputFile.sourcemap.txt index d0abf20190f..c72d3084670 100644 --- a/tests/baselines/reference/project/sourcemapModuleSubfolderSpecifyOutputFile/amd/sourcemapModuleSubfolderSpecifyOutputFile.sourcemap.txt +++ b/tests/baselines/reference/project/sourcemapModuleSubfolderSpecifyOutputFile/amd/sourcemapModuleSubfolderSpecifyOutputFile.sourcemap.txt @@ -373,6 +373,365 @@ sourceFile:test.ts JsFile: test.js mapUrl: test.js.map sourceRoot: -sources: +sources: ../ref/m1.ts,../test.ts =================================================================== +------------------------------------------------------------------- +emittedFile:bin/test.js +sourceFile:../ref/m1.ts +------------------------------------------------------------------- +>>>define("ref/m1", ["require", "exports"], function (require, exports) { +>>> exports.m1_a1 = 10; +1 >^^^^ +2 > ^^^^^^^^^^^^^ +3 > ^^^ +4 > ^^ +5 > ^ +6 > ^^^^^^^^-> +1 >export var +2 > m1_a1 +3 > = +4 > 10 +5 > ; +1 >Emitted(2, 5) Source(1, 12) + SourceIndex(0) +2 >Emitted(2, 18) Source(1, 17) + SourceIndex(0) +3 >Emitted(2, 21) Source(1, 20) + SourceIndex(0) +4 >Emitted(2, 23) Source(1, 22) + SourceIndex(0) +5 >Emitted(2, 24) Source(1, 23) + SourceIndex(0) +--- +>>> var m1_c1 = (function () { +1->^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^^^^-> +1-> + > +1->Emitted(3, 5) Source(2, 1) + SourceIndex(0) +--- +>>> function m1_c1() { +1->^^^^^^^^ +2 > ^^-> +1-> +1->Emitted(4, 9) Source(2, 1) + SourceIndex(0) name (m1_c1) +--- +>>> } +1->^^^^^^^^ +2 > ^ +3 > ^^^^^^^^^^^^^-> +1->export class m1_c1 { + > public m1_c1_p1: number; + > +2 > } +1->Emitted(5, 9) Source(4, 1) + SourceIndex(0) name (m1_c1.constructor) +2 >Emitted(5, 10) Source(4, 2) + SourceIndex(0) name (m1_c1.constructor) +--- +>>> return m1_c1; +1->^^^^^^^^ +2 > ^^^^^^^^^^^^ +1-> +2 > } +1->Emitted(6, 9) Source(4, 1) + SourceIndex(0) name (m1_c1) +2 >Emitted(6, 21) Source(4, 2) + SourceIndex(0) name (m1_c1) +--- +>>> })(); +1 >^^^^ +2 > ^ +3 > +4 > ^^^^ +5 > ^^^^^^^^^^^^^^^^^^-> +1 > +2 > } +3 > +4 > export class m1_c1 { + > public m1_c1_p1: number; + > } +1 >Emitted(7, 5) Source(4, 1) + SourceIndex(0) name (m1_c1) +2 >Emitted(7, 6) Source(4, 2) + SourceIndex(0) name (m1_c1) +3 >Emitted(7, 6) Source(2, 1) + SourceIndex(0) +4 >Emitted(7, 10) Source(4, 2) + SourceIndex(0) +--- +>>> exports.m1_c1 = m1_c1; +1->^^^^ +2 > ^^^^^^^^^^^^^ +3 > ^^^^^^^^ +4 > ^ +5 > ^^^^^^^^^^^^^^-> +1-> +2 > m1_c1 +3 > { + > public m1_c1_p1: number; + > } +4 > +1->Emitted(8, 5) Source(2, 14) + SourceIndex(0) +2 >Emitted(8, 18) Source(2, 19) + SourceIndex(0) +3 >Emitted(8, 26) Source(4, 2) + SourceIndex(0) +4 >Emitted(8, 27) Source(4, 2) + SourceIndex(0) +--- +>>> exports.m1_instance1 = new m1_c1(); +1->^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^ +3 > ^^^ +4 > ^^^^ +5 > ^^^^^ +6 > ^^ +7 > ^ +1-> + > + >export var +2 > m1_instance1 +3 > = +4 > new +5 > m1_c1 +6 > () +7 > ; +1->Emitted(9, 5) Source(6, 12) + SourceIndex(0) +2 >Emitted(9, 25) Source(6, 24) + SourceIndex(0) +3 >Emitted(9, 28) Source(6, 27) + SourceIndex(0) +4 >Emitted(9, 32) Source(6, 31) + SourceIndex(0) +5 >Emitted(9, 37) Source(6, 36) + SourceIndex(0) +6 >Emitted(9, 39) Source(6, 38) + SourceIndex(0) +7 >Emitted(9, 40) Source(6, 39) + SourceIndex(0) +--- +>>> function m1_f1() { +1 >^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +1 > + > +1 >Emitted(10, 5) Source(7, 1) + SourceIndex(0) +--- +>>> return exports.m1_instance1; +1->^^^^^^^^ +2 > ^^^^^^ +3 > ^ +4 > ^^^^^^^^^^^^^^^^^^^^ +5 > ^ +1->export function m1_f1() { + > +2 > return +3 > +4 > m1_instance1 +5 > ; +1->Emitted(11, 9) Source(8, 5) + SourceIndex(0) name (m1_f1) +2 >Emitted(11, 15) Source(8, 11) + SourceIndex(0) name (m1_f1) +3 >Emitted(11, 16) Source(8, 12) + SourceIndex(0) name (m1_f1) +4 >Emitted(11, 36) Source(8, 24) + SourceIndex(0) name (m1_f1) +5 >Emitted(11, 37) Source(8, 25) + SourceIndex(0) name (m1_f1) +--- +>>> } +1 >^^^^ +2 > ^ +3 > ^^^^^^^^^^^^^^^^^^^^^^-> +1 > + > +2 > } +1 >Emitted(12, 5) Source(9, 1) + SourceIndex(0) name (m1_f1) +2 >Emitted(12, 6) Source(9, 2) + SourceIndex(0) name (m1_f1) +--- +>>> exports.m1_f1 = m1_f1; +1->^^^^ +2 > ^^^^^^^^^^^^^ +3 > ^^^^^^^^ +4 > ^ +1-> +2 > m1_f1 +3 > () { + > return m1_instance1; + > } +4 > +1->Emitted(13, 5) Source(7, 17) + SourceIndex(0) +2 >Emitted(13, 18) Source(7, 22) + SourceIndex(0) +3 >Emitted(13, 26) Source(9, 2) + SourceIndex(0) +4 >Emitted(13, 27) Source(9, 2) + SourceIndex(0) +--- +------------------------------------------------------------------- +emittedFile:bin/test.js +sourceFile:../test.ts +------------------------------------------------------------------- +>>>}); +>>>define("test", ["require", "exports", "ref/m1"], function (require, exports, m1) { +>>> exports.a1 = 10; +1 >^^^^ +2 > ^^^^^^^^^^ +3 > ^^^ +4 > ^^ +5 > ^ +6 > ^^^^^^^^-> +1 >import m1 = require("ref/m1"); + >export var +2 > a1 +3 > = +4 > 10 +5 > ; +1 >Emitted(16, 5) Source(2, 12) + SourceIndex(1) +2 >Emitted(16, 15) Source(2, 14) + SourceIndex(1) +3 >Emitted(16, 18) Source(2, 17) + SourceIndex(1) +4 >Emitted(16, 20) Source(2, 19) + SourceIndex(1) +5 >Emitted(16, 21) Source(2, 20) + SourceIndex(1) +--- +>>> var c1 = (function () { +1->^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^-> +1-> + > +1->Emitted(17, 5) Source(3, 1) + SourceIndex(1) +--- +>>> function c1() { +1->^^^^^^^^ +2 > ^^-> +1-> +1->Emitted(18, 9) Source(3, 1) + SourceIndex(1) name (c1) +--- +>>> } +1->^^^^^^^^ +2 > ^ +3 > ^^^^^^^^^^-> +1->export class c1 { + > public p1: number; + > +2 > } +1->Emitted(19, 9) Source(5, 1) + SourceIndex(1) name (c1.constructor) +2 >Emitted(19, 10) Source(5, 2) + SourceIndex(1) name (c1.constructor) +--- +>>> return c1; +1->^^^^^^^^ +2 > ^^^^^^^^^ +1-> +2 > } +1->Emitted(20, 9) Source(5, 1) + SourceIndex(1) name (c1) +2 >Emitted(20, 18) Source(5, 2) + SourceIndex(1) name (c1) +--- +>>> })(); +1 >^^^^ +2 > ^ +3 > +4 > ^^^^ +5 > ^^^^^^^^^^^^-> +1 > +2 > } +3 > +4 > export class c1 { + > public p1: number; + > } +1 >Emitted(21, 5) Source(5, 1) + SourceIndex(1) name (c1) +2 >Emitted(21, 6) Source(5, 2) + SourceIndex(1) name (c1) +3 >Emitted(21, 6) Source(3, 1) + SourceIndex(1) +4 >Emitted(21, 10) Source(5, 2) + SourceIndex(1) +--- +>>> exports.c1 = c1; +1->^^^^ +2 > ^^^^^^^^^^ +3 > ^^^^^ +4 > ^ +5 > ^^^^^^^^^^^^^^-> +1-> +2 > c1 +3 > { + > public p1: number; + > } +4 > +1->Emitted(22, 5) Source(3, 14) + SourceIndex(1) +2 >Emitted(22, 15) Source(3, 16) + SourceIndex(1) +3 >Emitted(22, 20) Source(5, 2) + SourceIndex(1) +4 >Emitted(22, 21) Source(5, 2) + SourceIndex(1) +--- +>>> exports.instance1 = new c1(); +1->^^^^ +2 > ^^^^^^^^^^^^^^^^^ +3 > ^^^ +4 > ^^^^ +5 > ^^ +6 > ^^ +7 > ^ +1-> + > + >export var +2 > instance1 +3 > = +4 > new +5 > c1 +6 > () +7 > ; +1->Emitted(23, 5) Source(7, 12) + SourceIndex(1) +2 >Emitted(23, 22) Source(7, 21) + SourceIndex(1) +3 >Emitted(23, 25) Source(7, 24) + SourceIndex(1) +4 >Emitted(23, 29) Source(7, 28) + SourceIndex(1) +5 >Emitted(23, 31) Source(7, 30) + SourceIndex(1) +6 >Emitted(23, 33) Source(7, 32) + SourceIndex(1) +7 >Emitted(23, 34) Source(7, 33) + SourceIndex(1) +--- +>>> function f1() { +1 >^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +1 > + > +1 >Emitted(24, 5) Source(8, 1) + SourceIndex(1) +--- +>>> return exports.instance1; +1->^^^^^^^^ +2 > ^^^^^^ +3 > ^ +4 > ^^^^^^^^^^^^^^^^^ +5 > ^ +1->export function f1() { + > +2 > return +3 > +4 > instance1 +5 > ; +1->Emitted(25, 9) Source(9, 5) + SourceIndex(1) name (f1) +2 >Emitted(25, 15) Source(9, 11) + SourceIndex(1) name (f1) +3 >Emitted(25, 16) Source(9, 12) + SourceIndex(1) name (f1) +4 >Emitted(25, 33) Source(9, 21) + SourceIndex(1) name (f1) +5 >Emitted(25, 34) Source(9, 22) + SourceIndex(1) name (f1) +--- +>>> } +1 >^^^^ +2 > ^ +3 > ^^^^^^^^^^^^^^^^-> +1 > + > +2 > } +1 >Emitted(26, 5) Source(10, 1) + SourceIndex(1) name (f1) +2 >Emitted(26, 6) Source(10, 2) + SourceIndex(1) name (f1) +--- +>>> exports.f1 = f1; +1->^^^^ +2 > ^^^^^^^^^^ +3 > ^^^^^ +4 > ^ +5 > ^^^^^^^-> +1-> +2 > f1 +3 > () { + > return instance1; + > } +4 > +1->Emitted(27, 5) Source(8, 17) + SourceIndex(1) +2 >Emitted(27, 15) Source(8, 19) + SourceIndex(1) +3 >Emitted(27, 20) Source(10, 2) + SourceIndex(1) +4 >Emitted(27, 21) Source(10, 2) + SourceIndex(1) +--- +>>> exports.a2 = m1.m1_c1; +1->^^^^ +2 > ^^^^^^^^^^ +3 > ^^^ +4 > ^^ +5 > ^ +6 > ^^^^^ +7 > ^ +1-> + > + >export var +2 > a2 +3 > = +4 > m1 +5 > . +6 > m1_c1 +7 > ; +1->Emitted(28, 5) Source(12, 12) + SourceIndex(1) +2 >Emitted(28, 15) Source(12, 14) + SourceIndex(1) +3 >Emitted(28, 18) Source(12, 17) + SourceIndex(1) +4 >Emitted(28, 20) Source(12, 19) + SourceIndex(1) +5 >Emitted(28, 21) Source(12, 20) + SourceIndex(1) +6 >Emitted(28, 26) Source(12, 25) + SourceIndex(1) +7 >Emitted(28, 27) Source(12, 26) + SourceIndex(1) +--- +>>>}); >>>//# sourceMappingURL=test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcemapModuleSubfolderSpecifyOutputFile/node/bin/test.d.ts b/tests/baselines/reference/project/sourcemapModuleSubfolderSpecifyOutputFile/node/bin/test.d.ts deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/tests/baselines/reference/project/sourcemapModuleSubfolderSpecifyOutputFile/node/bin/test.js b/tests/baselines/reference/project/sourcemapModuleSubfolderSpecifyOutputFile/node/bin/test.js deleted file mode 100644 index 6f3fefb9498..00000000000 --- a/tests/baselines/reference/project/sourcemapModuleSubfolderSpecifyOutputFile/node/bin/test.js +++ /dev/null @@ -1 +0,0 @@ -//# sourceMappingURL=test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcemapModuleSubfolderSpecifyOutputFile/node/bin/test.js.map b/tests/baselines/reference/project/sourcemapModuleSubfolderSpecifyOutputFile/node/bin/test.js.map index c1e0281a2ab..bfdacf69428 100644 --- a/tests/baselines/reference/project/sourcemapModuleSubfolderSpecifyOutputFile/node/bin/test.js.map +++ b/tests/baselines/reference/project/sourcemapModuleSubfolderSpecifyOutputFile/node/bin/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"","sources":[],"names":[],"mappings":""} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"","sources":["../ref/m1.ts","../test.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcemapModuleSubfolderSpecifyOutputFile/node/sourcemapModuleSubfolderSpecifyOutputFile.sourcemap.txt b/tests/baselines/reference/project/sourcemapModuleSubfolderSpecifyOutputFile/node/sourcemapModuleSubfolderSpecifyOutputFile.sourcemap.txt index 205f70497ad..9011abbae05 100644 --- a/tests/baselines/reference/project/sourcemapModuleSubfolderSpecifyOutputFile/node/sourcemapModuleSubfolderSpecifyOutputFile.sourcemap.txt +++ b/tests/baselines/reference/project/sourcemapModuleSubfolderSpecifyOutputFile/node/sourcemapModuleSubfolderSpecifyOutputFile.sourcemap.txt @@ -394,6 +394,6 @@ sourceFile:test.ts JsFile: test.js mapUrl: test.js.map sourceRoot: -sources: +sources: ../ref/m1.ts,../test.ts =================================================================== >>>//# sourceMappingURL=test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFile/amd/bin/test.d.ts b/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFile/amd/bin/test.d.ts deleted file mode 100644 index d61b4c3b876..00000000000 --- a/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFile/amd/bin/test.d.ts +++ /dev/null @@ -1,13 +0,0 @@ -/// -declare var m1_a1: number; -declare class m1_c1 { - m1_c1_p1: number; -} -declare var m1_instance1: m1_c1; -declare function m1_f1(): m1_c1; -declare var a1: number; -declare class c1 { - p1: number; -} -declare var instance1: c1; -declare function f1(): c1; diff --git a/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFile/amd/bin/test.js b/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFile/amd/bin/test.js deleted file mode 100644 index 5af28cf8560..00000000000 --- a/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFile/amd/bin/test.js +++ /dev/null @@ -1,23 +0,0 @@ -var m1_a1 = 10; -var m1_c1 = (function () { - function m1_c1() { - } - return m1_c1; -})(); -var m1_instance1 = new m1_c1(); -function m1_f1() { - return m1_instance1; -} -/// -/// -var a1 = 10; -var c1 = (function () { - function c1() { - } - return c1; -})(); -var instance1 = new c1(); -function f1() { - return instance1; -} -//# sourceMappingURL=test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFile/amd/bin/test.js.map b/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFile/amd/bin/test.js.map index 7a70d18105c..37bb9be8a95 100644 --- a/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFile/amd/bin/test.js.map +++ b/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFile/amd/bin/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"http://typescript.codeplex.com/","sources":["ref/m1.ts","test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACRD,iCAAiC;AACjC,iCAAiC;AACjC,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"http://typescript.codeplex.com/","sources":["ref/m1.ts","ref/m2.ts","test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","m2_c1","m2_c1.constructor","m2_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;;ICRU,aAAK,GAAG,EAAE,CAAC;IACtB;QAAAC;QAEAC,CAACA;QAADD,YAACA;IAADA,CAACA,AAFD,IAEC;IAFY,aAAK,QAEjB,CAAA;IAEU,oBAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACIE,MAAMA,CAACA,oBAAYA,CAACA;IACxBA,CAACA;IAFe,aAAK,QAEpB,CAAA;;ACRD,iCAAiC;AACjC,iCAAiC;AACjC,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFile/amd/sourcerootUrlMixedSubfolderSpecifyOutputFile.sourcemap.txt b/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFile/amd/sourcerootUrlMixedSubfolderSpecifyOutputFile.sourcemap.txt index d4cac643490..d88a0d7585b 100644 --- a/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFile/amd/sourcerootUrlMixedSubfolderSpecifyOutputFile.sourcemap.txt +++ b/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFile/amd/sourcerootUrlMixedSubfolderSpecifyOutputFile.sourcemap.txt @@ -174,7 +174,7 @@ sourceFile:ref/m2.ts JsFile: test.js mapUrl: test.js.map sourceRoot: http://typescript.codeplex.com/ -sources: ref/m1.ts,test.ts +sources: ref/m1.ts,ref/m2.ts,test.ts =================================================================== ------------------------------------------------------------------- emittedFile:bin/test.js @@ -306,7 +306,7 @@ sourceFile:ref/m1.ts >>>} 1 > 2 >^ -3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> 1 > > 2 >} @@ -315,16 +315,182 @@ sourceFile:ref/m1.ts --- ------------------------------------------------------------------- emittedFile:bin/test.js +sourceFile:ref/m2.ts +------------------------------------------------------------------- +>>>define("ref/m2", ["require", "exports"], function (require, exports) { +>>> exports.m2_a1 = 10; +1->^^^^ +2 > ^^^^^^^^^^^^^ +3 > ^^^ +4 > ^^ +5 > ^ +6 > ^^^^^^^^-> +1->export var +2 > m2_a1 +3 > = +4 > 10 +5 > ; +1->Emitted(12, 5) Source(1, 12) + SourceIndex(1) +2 >Emitted(12, 18) Source(1, 17) + SourceIndex(1) +3 >Emitted(12, 21) Source(1, 20) + SourceIndex(1) +4 >Emitted(12, 23) Source(1, 22) + SourceIndex(1) +5 >Emitted(12, 24) Source(1, 23) + SourceIndex(1) +--- +>>> var m2_c1 = (function () { +1->^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^^^^-> +1-> + > +1->Emitted(13, 5) Source(2, 1) + SourceIndex(1) +--- +>>> function m2_c1() { +1->^^^^^^^^ +2 > ^^-> +1-> +1->Emitted(14, 9) Source(2, 1) + SourceIndex(1) name (m2_c1) +--- +>>> } +1->^^^^^^^^ +2 > ^ +3 > ^^^^^^^^^^^^^-> +1->export class m2_c1 { + > public m2_c1_p1: number; + > +2 > } +1->Emitted(15, 9) Source(4, 1) + SourceIndex(1) name (m2_c1.constructor) +2 >Emitted(15, 10) Source(4, 2) + SourceIndex(1) name (m2_c1.constructor) +--- +>>> return m2_c1; +1->^^^^^^^^ +2 > ^^^^^^^^^^^^ +1-> +2 > } +1->Emitted(16, 9) Source(4, 1) + SourceIndex(1) name (m2_c1) +2 >Emitted(16, 21) Source(4, 2) + SourceIndex(1) name (m2_c1) +--- +>>> })(); +1 >^^^^ +2 > ^ +3 > +4 > ^^^^ +5 > ^^^^^^^^^^^^^^^^^^-> +1 > +2 > } +3 > +4 > export class m2_c1 { + > public m2_c1_p1: number; + > } +1 >Emitted(17, 5) Source(4, 1) + SourceIndex(1) name (m2_c1) +2 >Emitted(17, 6) Source(4, 2) + SourceIndex(1) name (m2_c1) +3 >Emitted(17, 6) Source(2, 1) + SourceIndex(1) +4 >Emitted(17, 10) Source(4, 2) + SourceIndex(1) +--- +>>> exports.m2_c1 = m2_c1; +1->^^^^ +2 > ^^^^^^^^^^^^^ +3 > ^^^^^^^^ +4 > ^ +5 > ^^^^^^^^^^^^^^-> +1-> +2 > m2_c1 +3 > { + > public m2_c1_p1: number; + > } +4 > +1->Emitted(18, 5) Source(2, 14) + SourceIndex(1) +2 >Emitted(18, 18) Source(2, 19) + SourceIndex(1) +3 >Emitted(18, 26) Source(4, 2) + SourceIndex(1) +4 >Emitted(18, 27) Source(4, 2) + SourceIndex(1) +--- +>>> exports.m2_instance1 = new m2_c1(); +1->^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^ +3 > ^^^ +4 > ^^^^ +5 > ^^^^^ +6 > ^^ +7 > ^ +1-> + > + >export var +2 > m2_instance1 +3 > = +4 > new +5 > m2_c1 +6 > () +7 > ; +1->Emitted(19, 5) Source(6, 12) + SourceIndex(1) +2 >Emitted(19, 25) Source(6, 24) + SourceIndex(1) +3 >Emitted(19, 28) Source(6, 27) + SourceIndex(1) +4 >Emitted(19, 32) Source(6, 31) + SourceIndex(1) +5 >Emitted(19, 37) Source(6, 36) + SourceIndex(1) +6 >Emitted(19, 39) Source(6, 38) + SourceIndex(1) +7 >Emitted(19, 40) Source(6, 39) + SourceIndex(1) +--- +>>> function m2_f1() { +1 >^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +1 > + > +1 >Emitted(20, 5) Source(7, 1) + SourceIndex(1) +--- +>>> return exports.m2_instance1; +1->^^^^^^^^ +2 > ^^^^^^ +3 > ^ +4 > ^^^^^^^^^^^^^^^^^^^^ +5 > ^ +1->export function m2_f1() { + > +2 > return +3 > +4 > m2_instance1 +5 > ; +1->Emitted(21, 9) Source(8, 5) + SourceIndex(1) name (m2_f1) +2 >Emitted(21, 15) Source(8, 11) + SourceIndex(1) name (m2_f1) +3 >Emitted(21, 16) Source(8, 12) + SourceIndex(1) name (m2_f1) +4 >Emitted(21, 36) Source(8, 24) + SourceIndex(1) name (m2_f1) +5 >Emitted(21, 37) Source(8, 25) + SourceIndex(1) name (m2_f1) +--- +>>> } +1 >^^^^ +2 > ^ +3 > ^^^^^^^^^^^^^^^^^^^^^^-> +1 > + > +2 > } +1 >Emitted(22, 5) Source(9, 1) + SourceIndex(1) name (m2_f1) +2 >Emitted(22, 6) Source(9, 2) + SourceIndex(1) name (m2_f1) +--- +>>> exports.m2_f1 = m2_f1; +1->^^^^ +2 > ^^^^^^^^^^^^^ +3 > ^^^^^^^^ +4 > ^ +1-> +2 > m2_f1 +3 > () { + > return m2_instance1; + > } +4 > +1->Emitted(23, 5) Source(7, 17) + SourceIndex(1) +2 >Emitted(23, 18) Source(7, 22) + SourceIndex(1) +3 >Emitted(23, 26) Source(9, 2) + SourceIndex(1) +4 >Emitted(23, 27) Source(9, 2) + SourceIndex(1) +--- +------------------------------------------------------------------- +emittedFile:bin/test.js sourceFile:test.ts ------------------------------------------------------------------- +>>>}); >>>/// -1-> +1 > 2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 3 > ^-> -1-> +1 > 2 >/// -1->Emitted(11, 1) Source(1, 1) + SourceIndex(1) -2 >Emitted(11, 34) Source(1, 34) + SourceIndex(1) +1 >Emitted(25, 1) Source(1, 1) + SourceIndex(2) +2 >Emitted(25, 34) Source(1, 34) + SourceIndex(2) --- >>>/// 1-> @@ -332,8 +498,8 @@ sourceFile:test.ts 1-> > 2 >/// -1->Emitted(12, 1) Source(2, 1) + SourceIndex(1) -2 >Emitted(12, 34) Source(2, 34) + SourceIndex(1) +1->Emitted(26, 1) Source(2, 1) + SourceIndex(2) +2 >Emitted(26, 34) Source(2, 34) + SourceIndex(2) --- >>>var a1 = 10; 1 > @@ -350,25 +516,25 @@ sourceFile:test.ts 4 > = 5 > 10 6 > ; -1 >Emitted(13, 1) Source(3, 1) + SourceIndex(1) -2 >Emitted(13, 5) Source(3, 5) + SourceIndex(1) -3 >Emitted(13, 7) Source(3, 7) + SourceIndex(1) -4 >Emitted(13, 10) Source(3, 10) + SourceIndex(1) -5 >Emitted(13, 12) Source(3, 12) + SourceIndex(1) -6 >Emitted(13, 13) Source(3, 13) + SourceIndex(1) +1 >Emitted(27, 1) Source(3, 1) + SourceIndex(2) +2 >Emitted(27, 5) Source(3, 5) + SourceIndex(2) +3 >Emitted(27, 7) Source(3, 7) + SourceIndex(2) +4 >Emitted(27, 10) Source(3, 10) + SourceIndex(2) +5 >Emitted(27, 12) Source(3, 12) + SourceIndex(2) +6 >Emitted(27, 13) Source(3, 13) + SourceIndex(2) --- >>>var c1 = (function () { 1-> 2 >^^^^^^^^^^^^^^^^^^^^-> 1-> > -1->Emitted(14, 1) Source(4, 1) + SourceIndex(1) +1->Emitted(28, 1) Source(4, 1) + SourceIndex(2) --- >>> function c1() { 1->^^^^ 2 > ^^-> 1-> -1->Emitted(15, 5) Source(4, 1) + SourceIndex(1) name (c1) +1->Emitted(29, 5) Source(4, 1) + SourceIndex(2) name (c1) --- >>> } 1->^^^^ @@ -378,16 +544,16 @@ sourceFile:test.ts > public p1: number; > 2 > } -1->Emitted(16, 5) Source(6, 1) + SourceIndex(1) name (c1.constructor) -2 >Emitted(16, 6) Source(6, 2) + SourceIndex(1) name (c1.constructor) +1->Emitted(30, 5) Source(6, 1) + SourceIndex(2) name (c1.constructor) +2 >Emitted(30, 6) Source(6, 2) + SourceIndex(2) name (c1.constructor) --- >>> return c1; 1->^^^^ 2 > ^^^^^^^^^ 1-> 2 > } -1->Emitted(17, 5) Source(6, 1) + SourceIndex(1) name (c1) -2 >Emitted(17, 14) Source(6, 2) + SourceIndex(1) name (c1) +1->Emitted(31, 5) Source(6, 1) + SourceIndex(2) name (c1) +2 >Emitted(31, 14) Source(6, 2) + SourceIndex(2) name (c1) --- >>>})(); 1 > @@ -401,10 +567,10 @@ sourceFile:test.ts 4 > class c1 { > public p1: number; > } -1 >Emitted(18, 1) Source(6, 1) + SourceIndex(1) name (c1) -2 >Emitted(18, 2) Source(6, 2) + SourceIndex(1) name (c1) -3 >Emitted(18, 2) Source(4, 1) + SourceIndex(1) -4 >Emitted(18, 6) Source(6, 2) + SourceIndex(1) +1 >Emitted(32, 1) Source(6, 1) + SourceIndex(2) name (c1) +2 >Emitted(32, 2) Source(6, 2) + SourceIndex(2) name (c1) +3 >Emitted(32, 2) Source(4, 1) + SourceIndex(2) +4 >Emitted(32, 6) Source(6, 2) + SourceIndex(2) --- >>>var instance1 = new c1(); 1-> @@ -425,21 +591,21 @@ sourceFile:test.ts 6 > c1 7 > () 8 > ; -1->Emitted(19, 1) Source(8, 1) + SourceIndex(1) -2 >Emitted(19, 5) Source(8, 5) + SourceIndex(1) -3 >Emitted(19, 14) Source(8, 14) + SourceIndex(1) -4 >Emitted(19, 17) Source(8, 17) + SourceIndex(1) -5 >Emitted(19, 21) Source(8, 21) + SourceIndex(1) -6 >Emitted(19, 23) Source(8, 23) + SourceIndex(1) -7 >Emitted(19, 25) Source(8, 25) + SourceIndex(1) -8 >Emitted(19, 26) Source(8, 26) + SourceIndex(1) +1->Emitted(33, 1) Source(8, 1) + SourceIndex(2) +2 >Emitted(33, 5) Source(8, 5) + SourceIndex(2) +3 >Emitted(33, 14) Source(8, 14) + SourceIndex(2) +4 >Emitted(33, 17) Source(8, 17) + SourceIndex(2) +5 >Emitted(33, 21) Source(8, 21) + SourceIndex(2) +6 >Emitted(33, 23) Source(8, 23) + SourceIndex(2) +7 >Emitted(33, 25) Source(8, 25) + SourceIndex(2) +8 >Emitted(33, 26) Source(8, 26) + SourceIndex(2) --- >>>function f1() { 1 > 2 >^^^^^^^^^^^^^^^^^^^^^^-> 1 > > -1 >Emitted(20, 1) Source(9, 1) + SourceIndex(1) +1 >Emitted(34, 1) Source(9, 1) + SourceIndex(2) --- >>> return instance1; 1->^^^^ @@ -453,11 +619,11 @@ sourceFile:test.ts 3 > 4 > instance1 5 > ; -1->Emitted(21, 5) Source(10, 5) + SourceIndex(1) name (f1) -2 >Emitted(21, 11) Source(10, 11) + SourceIndex(1) name (f1) -3 >Emitted(21, 12) Source(10, 12) + SourceIndex(1) name (f1) -4 >Emitted(21, 21) Source(10, 21) + SourceIndex(1) name (f1) -5 >Emitted(21, 22) Source(10, 22) + SourceIndex(1) name (f1) +1->Emitted(35, 5) Source(10, 5) + SourceIndex(2) name (f1) +2 >Emitted(35, 11) Source(10, 11) + SourceIndex(2) name (f1) +3 >Emitted(35, 12) Source(10, 12) + SourceIndex(2) name (f1) +4 >Emitted(35, 21) Source(10, 21) + SourceIndex(2) name (f1) +5 >Emitted(35, 22) Source(10, 22) + SourceIndex(2) name (f1) --- >>>} 1 > @@ -466,7 +632,7 @@ sourceFile:test.ts 1 > > 2 >} -1 >Emitted(22, 1) Source(11, 1) + SourceIndex(1) name (f1) -2 >Emitted(22, 2) Source(11, 2) + SourceIndex(1) name (f1) +1 >Emitted(36, 1) Source(11, 1) + SourceIndex(2) name (f1) +2 >Emitted(36, 2) Source(11, 2) + SourceIndex(2) name (f1) --- >>>//# sourceMappingURL=test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFile/node/bin/test.d.ts b/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFile/node/bin/test.d.ts deleted file mode 100644 index d61b4c3b876..00000000000 --- a/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFile/node/bin/test.d.ts +++ /dev/null @@ -1,13 +0,0 @@ -/// -declare var m1_a1: number; -declare class m1_c1 { - m1_c1_p1: number; -} -declare var m1_instance1: m1_c1; -declare function m1_f1(): m1_c1; -declare var a1: number; -declare class c1 { - p1: number; -} -declare var instance1: c1; -declare function f1(): c1; diff --git a/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFile/node/bin/test.js b/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFile/node/bin/test.js deleted file mode 100644 index 5af28cf8560..00000000000 --- a/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFile/node/bin/test.js +++ /dev/null @@ -1,23 +0,0 @@ -var m1_a1 = 10; -var m1_c1 = (function () { - function m1_c1() { - } - return m1_c1; -})(); -var m1_instance1 = new m1_c1(); -function m1_f1() { - return m1_instance1; -} -/// -/// -var a1 = 10; -var c1 = (function () { - function c1() { - } - return c1; -})(); -var instance1 = new c1(); -function f1() { - return instance1; -} -//# sourceMappingURL=test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFile/node/bin/test.js.map b/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFile/node/bin/test.js.map index 7a70d18105c..a6626039aa2 100644 --- a/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFile/node/bin/test.js.map +++ b/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFile/node/bin/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"http://typescript.codeplex.com/","sources":["ref/m1.ts","test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACRD,iCAAiC;AACjC,iCAAiC;AACjC,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"http://typescript.codeplex.com/","sources":["ref/m1.ts","ref/m2.ts","test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;AERD,iCAAiC;AACjC,iCAAiC;AACjC,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFile/node/sourcerootUrlMixedSubfolderSpecifyOutputFile.sourcemap.txt b/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFile/node/sourcerootUrlMixedSubfolderSpecifyOutputFile.sourcemap.txt index cb96dcbf7d7..244cd8fafdf 100644 --- a/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFile/node/sourcerootUrlMixedSubfolderSpecifyOutputFile.sourcemap.txt +++ b/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFile/node/sourcerootUrlMixedSubfolderSpecifyOutputFile.sourcemap.txt @@ -173,7 +173,7 @@ sourceFile:ref/m2.ts JsFile: test.js mapUrl: test.js.map sourceRoot: http://typescript.codeplex.com/ -sources: ref/m1.ts,test.ts +sources: ref/m1.ts,ref/m2.ts,test.ts =================================================================== ------------------------------------------------------------------- emittedFile:bin/test.js @@ -322,8 +322,8 @@ sourceFile:test.ts 3 > ^-> 1-> 2 >/// -1->Emitted(11, 1) Source(1, 1) + SourceIndex(1) -2 >Emitted(11, 34) Source(1, 34) + SourceIndex(1) +1->Emitted(11, 1) Source(1, 1) + SourceIndex(2) +2 >Emitted(11, 34) Source(1, 34) + SourceIndex(2) --- >>>/// 1-> @@ -331,8 +331,8 @@ sourceFile:test.ts 1-> > 2 >/// -1->Emitted(12, 1) Source(2, 1) + SourceIndex(1) -2 >Emitted(12, 34) Source(2, 34) + SourceIndex(1) +1->Emitted(12, 1) Source(2, 1) + SourceIndex(2) +2 >Emitted(12, 34) Source(2, 34) + SourceIndex(2) --- >>>var a1 = 10; 1 > @@ -349,25 +349,25 @@ sourceFile:test.ts 4 > = 5 > 10 6 > ; -1 >Emitted(13, 1) Source(3, 1) + SourceIndex(1) -2 >Emitted(13, 5) Source(3, 5) + SourceIndex(1) -3 >Emitted(13, 7) Source(3, 7) + SourceIndex(1) -4 >Emitted(13, 10) Source(3, 10) + SourceIndex(1) -5 >Emitted(13, 12) Source(3, 12) + SourceIndex(1) -6 >Emitted(13, 13) Source(3, 13) + SourceIndex(1) +1 >Emitted(13, 1) Source(3, 1) + SourceIndex(2) +2 >Emitted(13, 5) Source(3, 5) + SourceIndex(2) +3 >Emitted(13, 7) Source(3, 7) + SourceIndex(2) +4 >Emitted(13, 10) Source(3, 10) + SourceIndex(2) +5 >Emitted(13, 12) Source(3, 12) + SourceIndex(2) +6 >Emitted(13, 13) Source(3, 13) + SourceIndex(2) --- >>>var c1 = (function () { 1-> 2 >^^^^^^^^^^^^^^^^^^^^-> 1-> > -1->Emitted(14, 1) Source(4, 1) + SourceIndex(1) +1->Emitted(14, 1) Source(4, 1) + SourceIndex(2) --- >>> function c1() { 1->^^^^ 2 > ^^-> 1-> -1->Emitted(15, 5) Source(4, 1) + SourceIndex(1) name (c1) +1->Emitted(15, 5) Source(4, 1) + SourceIndex(2) name (c1) --- >>> } 1->^^^^ @@ -377,16 +377,16 @@ sourceFile:test.ts > public p1: number; > 2 > } -1->Emitted(16, 5) Source(6, 1) + SourceIndex(1) name (c1.constructor) -2 >Emitted(16, 6) Source(6, 2) + SourceIndex(1) name (c1.constructor) +1->Emitted(16, 5) Source(6, 1) + SourceIndex(2) name (c1.constructor) +2 >Emitted(16, 6) Source(6, 2) + SourceIndex(2) name (c1.constructor) --- >>> return c1; 1->^^^^ 2 > ^^^^^^^^^ 1-> 2 > } -1->Emitted(17, 5) Source(6, 1) + SourceIndex(1) name (c1) -2 >Emitted(17, 14) Source(6, 2) + SourceIndex(1) name (c1) +1->Emitted(17, 5) Source(6, 1) + SourceIndex(2) name (c1) +2 >Emitted(17, 14) Source(6, 2) + SourceIndex(2) name (c1) --- >>>})(); 1 > @@ -400,10 +400,10 @@ sourceFile:test.ts 4 > class c1 { > public p1: number; > } -1 >Emitted(18, 1) Source(6, 1) + SourceIndex(1) name (c1) -2 >Emitted(18, 2) Source(6, 2) + SourceIndex(1) name (c1) -3 >Emitted(18, 2) Source(4, 1) + SourceIndex(1) -4 >Emitted(18, 6) Source(6, 2) + SourceIndex(1) +1 >Emitted(18, 1) Source(6, 1) + SourceIndex(2) name (c1) +2 >Emitted(18, 2) Source(6, 2) + SourceIndex(2) name (c1) +3 >Emitted(18, 2) Source(4, 1) + SourceIndex(2) +4 >Emitted(18, 6) Source(6, 2) + SourceIndex(2) --- >>>var instance1 = new c1(); 1-> @@ -424,21 +424,21 @@ sourceFile:test.ts 6 > c1 7 > () 8 > ; -1->Emitted(19, 1) Source(8, 1) + SourceIndex(1) -2 >Emitted(19, 5) Source(8, 5) + SourceIndex(1) -3 >Emitted(19, 14) Source(8, 14) + SourceIndex(1) -4 >Emitted(19, 17) Source(8, 17) + SourceIndex(1) -5 >Emitted(19, 21) Source(8, 21) + SourceIndex(1) -6 >Emitted(19, 23) Source(8, 23) + SourceIndex(1) -7 >Emitted(19, 25) Source(8, 25) + SourceIndex(1) -8 >Emitted(19, 26) Source(8, 26) + SourceIndex(1) +1->Emitted(19, 1) Source(8, 1) + SourceIndex(2) +2 >Emitted(19, 5) Source(8, 5) + SourceIndex(2) +3 >Emitted(19, 14) Source(8, 14) + SourceIndex(2) +4 >Emitted(19, 17) Source(8, 17) + SourceIndex(2) +5 >Emitted(19, 21) Source(8, 21) + SourceIndex(2) +6 >Emitted(19, 23) Source(8, 23) + SourceIndex(2) +7 >Emitted(19, 25) Source(8, 25) + SourceIndex(2) +8 >Emitted(19, 26) Source(8, 26) + SourceIndex(2) --- >>>function f1() { 1 > 2 >^^^^^^^^^^^^^^^^^^^^^^-> 1 > > -1 >Emitted(20, 1) Source(9, 1) + SourceIndex(1) +1 >Emitted(20, 1) Source(9, 1) + SourceIndex(2) --- >>> return instance1; 1->^^^^ @@ -452,11 +452,11 @@ sourceFile:test.ts 3 > 4 > instance1 5 > ; -1->Emitted(21, 5) Source(10, 5) + SourceIndex(1) name (f1) -2 >Emitted(21, 11) Source(10, 11) + SourceIndex(1) name (f1) -3 >Emitted(21, 12) Source(10, 12) + SourceIndex(1) name (f1) -4 >Emitted(21, 21) Source(10, 21) + SourceIndex(1) name (f1) -5 >Emitted(21, 22) Source(10, 22) + SourceIndex(1) name (f1) +1->Emitted(21, 5) Source(10, 5) + SourceIndex(2) name (f1) +2 >Emitted(21, 11) Source(10, 11) + SourceIndex(2) name (f1) +3 >Emitted(21, 12) Source(10, 12) + SourceIndex(2) name (f1) +4 >Emitted(21, 21) Source(10, 21) + SourceIndex(2) name (f1) +5 >Emitted(21, 22) Source(10, 22) + SourceIndex(2) name (f1) --- >>>} 1 > @@ -465,7 +465,7 @@ sourceFile:test.ts 1 > > 2 >} -1 >Emitted(22, 1) Source(11, 1) + SourceIndex(1) name (f1) -2 >Emitted(22, 2) Source(11, 2) + SourceIndex(1) name (f1) +1 >Emitted(22, 1) Source(11, 1) + SourceIndex(2) name (f1) +2 >Emitted(22, 2) Source(11, 2) + SourceIndex(2) name (f1) --- >>>//# sourceMappingURL=test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.d.ts b/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.d.ts deleted file mode 100644 index 9b9cdd4a214..00000000000 --- a/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.d.ts +++ /dev/null @@ -1,13 +0,0 @@ -/// -declare var m1_a1: number; -declare class m1_c1 { - m1_c1_p1: number; -} -declare var m1_instance1: m1_c1; -declare function m1_f1(): m1_c1; -declare var a1: number; -declare class c1 { - p1: number; -} -declare var instance1: c1; -declare function f1(): c1; diff --git a/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.js b/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.js deleted file mode 100644 index 1750a5975ae..00000000000 --- a/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.js +++ /dev/null @@ -1,23 +0,0 @@ -var m1_a1 = 10; -var m1_c1 = (function () { - function m1_c1() { - } - return m1_c1; -})(); -var m1_instance1 = new m1_c1(); -function m1_f1() { - return m1_instance1; -} -/// -/// -var a1 = 10; -var c1 = (function () { - function c1() { - } - return c1; -})(); -var instance1 = new c1(); -function f1() { - return instance1; -} -//# sourceMappingURL=outAndOutDirFile.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.js.map b/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.js.map index 53e31e30260..f3058d9f878 100644 --- a/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.js.map +++ b/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.js.map @@ -1 +1 @@ -{"version":3,"file":"outAndOutDirFile.js","sourceRoot":"http://typescript.codeplex.com/","sources":["ref/m1.ts","test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACRD,iCAAiC;AACjC,iCAAiC;AACjC,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"outAndOutDirFile.js","sourceRoot":"http://typescript.codeplex.com/","sources":["ref/m1.ts","ref/m2.ts","test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","m2_c1","m2_c1.constructor","m2_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;;ICRU,aAAK,GAAG,EAAE,CAAC;IACtB;QAAAC;QAEAC,CAACA;QAADD,YAACA;IAADA,CAACA,AAFD,IAEC;IAFY,aAAK,QAEjB,CAAA;IAEU,oBAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACIE,MAAMA,CAACA,oBAAYA,CAACA;IACxBA,CAACA;IAFe,aAAK,QAEpB,CAAA;;ACRD,iCAAiC;AACjC,iCAAiC;AACjC,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/sourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory.sourcemap.txt b/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/sourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory.sourcemap.txt index d54fa316273..5744420ab71 100644 --- a/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/sourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory.sourcemap.txt +++ b/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/sourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory.sourcemap.txt @@ -174,7 +174,7 @@ sourceFile:ref/m2.ts JsFile: outAndOutDirFile.js mapUrl: outAndOutDirFile.js.map sourceRoot: http://typescript.codeplex.com/ -sources: ref/m1.ts,test.ts +sources: ref/m1.ts,ref/m2.ts,test.ts =================================================================== ------------------------------------------------------------------- emittedFile:bin/outAndOutDirFile.js @@ -306,7 +306,7 @@ sourceFile:ref/m1.ts >>>} 1 > 2 >^ -3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> 1 > > 2 >} @@ -315,16 +315,182 @@ sourceFile:ref/m1.ts --- ------------------------------------------------------------------- emittedFile:bin/outAndOutDirFile.js +sourceFile:ref/m2.ts +------------------------------------------------------------------- +>>>define("ref/m2", ["require", "exports"], function (require, exports) { +>>> exports.m2_a1 = 10; +1->^^^^ +2 > ^^^^^^^^^^^^^ +3 > ^^^ +4 > ^^ +5 > ^ +6 > ^^^^^^^^-> +1->export var +2 > m2_a1 +3 > = +4 > 10 +5 > ; +1->Emitted(12, 5) Source(1, 12) + SourceIndex(1) +2 >Emitted(12, 18) Source(1, 17) + SourceIndex(1) +3 >Emitted(12, 21) Source(1, 20) + SourceIndex(1) +4 >Emitted(12, 23) Source(1, 22) + SourceIndex(1) +5 >Emitted(12, 24) Source(1, 23) + SourceIndex(1) +--- +>>> var m2_c1 = (function () { +1->^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^^^^-> +1-> + > +1->Emitted(13, 5) Source(2, 1) + SourceIndex(1) +--- +>>> function m2_c1() { +1->^^^^^^^^ +2 > ^^-> +1-> +1->Emitted(14, 9) Source(2, 1) + SourceIndex(1) name (m2_c1) +--- +>>> } +1->^^^^^^^^ +2 > ^ +3 > ^^^^^^^^^^^^^-> +1->export class m2_c1 { + > public m2_c1_p1: number; + > +2 > } +1->Emitted(15, 9) Source(4, 1) + SourceIndex(1) name (m2_c1.constructor) +2 >Emitted(15, 10) Source(4, 2) + SourceIndex(1) name (m2_c1.constructor) +--- +>>> return m2_c1; +1->^^^^^^^^ +2 > ^^^^^^^^^^^^ +1-> +2 > } +1->Emitted(16, 9) Source(4, 1) + SourceIndex(1) name (m2_c1) +2 >Emitted(16, 21) Source(4, 2) + SourceIndex(1) name (m2_c1) +--- +>>> })(); +1 >^^^^ +2 > ^ +3 > +4 > ^^^^ +5 > ^^^^^^^^^^^^^^^^^^-> +1 > +2 > } +3 > +4 > export class m2_c1 { + > public m2_c1_p1: number; + > } +1 >Emitted(17, 5) Source(4, 1) + SourceIndex(1) name (m2_c1) +2 >Emitted(17, 6) Source(4, 2) + SourceIndex(1) name (m2_c1) +3 >Emitted(17, 6) Source(2, 1) + SourceIndex(1) +4 >Emitted(17, 10) Source(4, 2) + SourceIndex(1) +--- +>>> exports.m2_c1 = m2_c1; +1->^^^^ +2 > ^^^^^^^^^^^^^ +3 > ^^^^^^^^ +4 > ^ +5 > ^^^^^^^^^^^^^^-> +1-> +2 > m2_c1 +3 > { + > public m2_c1_p1: number; + > } +4 > +1->Emitted(18, 5) Source(2, 14) + SourceIndex(1) +2 >Emitted(18, 18) Source(2, 19) + SourceIndex(1) +3 >Emitted(18, 26) Source(4, 2) + SourceIndex(1) +4 >Emitted(18, 27) Source(4, 2) + SourceIndex(1) +--- +>>> exports.m2_instance1 = new m2_c1(); +1->^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^ +3 > ^^^ +4 > ^^^^ +5 > ^^^^^ +6 > ^^ +7 > ^ +1-> + > + >export var +2 > m2_instance1 +3 > = +4 > new +5 > m2_c1 +6 > () +7 > ; +1->Emitted(19, 5) Source(6, 12) + SourceIndex(1) +2 >Emitted(19, 25) Source(6, 24) + SourceIndex(1) +3 >Emitted(19, 28) Source(6, 27) + SourceIndex(1) +4 >Emitted(19, 32) Source(6, 31) + SourceIndex(1) +5 >Emitted(19, 37) Source(6, 36) + SourceIndex(1) +6 >Emitted(19, 39) Source(6, 38) + SourceIndex(1) +7 >Emitted(19, 40) Source(6, 39) + SourceIndex(1) +--- +>>> function m2_f1() { +1 >^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +1 > + > +1 >Emitted(20, 5) Source(7, 1) + SourceIndex(1) +--- +>>> return exports.m2_instance1; +1->^^^^^^^^ +2 > ^^^^^^ +3 > ^ +4 > ^^^^^^^^^^^^^^^^^^^^ +5 > ^ +1->export function m2_f1() { + > +2 > return +3 > +4 > m2_instance1 +5 > ; +1->Emitted(21, 9) Source(8, 5) + SourceIndex(1) name (m2_f1) +2 >Emitted(21, 15) Source(8, 11) + SourceIndex(1) name (m2_f1) +3 >Emitted(21, 16) Source(8, 12) + SourceIndex(1) name (m2_f1) +4 >Emitted(21, 36) Source(8, 24) + SourceIndex(1) name (m2_f1) +5 >Emitted(21, 37) Source(8, 25) + SourceIndex(1) name (m2_f1) +--- +>>> } +1 >^^^^ +2 > ^ +3 > ^^^^^^^^^^^^^^^^^^^^^^-> +1 > + > +2 > } +1 >Emitted(22, 5) Source(9, 1) + SourceIndex(1) name (m2_f1) +2 >Emitted(22, 6) Source(9, 2) + SourceIndex(1) name (m2_f1) +--- +>>> exports.m2_f1 = m2_f1; +1->^^^^ +2 > ^^^^^^^^^^^^^ +3 > ^^^^^^^^ +4 > ^ +1-> +2 > m2_f1 +3 > () { + > return m2_instance1; + > } +4 > +1->Emitted(23, 5) Source(7, 17) + SourceIndex(1) +2 >Emitted(23, 18) Source(7, 22) + SourceIndex(1) +3 >Emitted(23, 26) Source(9, 2) + SourceIndex(1) +4 >Emitted(23, 27) Source(9, 2) + SourceIndex(1) +--- +------------------------------------------------------------------- +emittedFile:bin/outAndOutDirFile.js sourceFile:test.ts ------------------------------------------------------------------- +>>>}); >>>/// -1-> +1 > 2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 3 > ^-> -1-> +1 > 2 >/// -1->Emitted(11, 1) Source(1, 1) + SourceIndex(1) -2 >Emitted(11, 34) Source(1, 34) + SourceIndex(1) +1 >Emitted(25, 1) Source(1, 1) + SourceIndex(2) +2 >Emitted(25, 34) Source(1, 34) + SourceIndex(2) --- >>>/// 1-> @@ -332,8 +498,8 @@ sourceFile:test.ts 1-> > 2 >/// -1->Emitted(12, 1) Source(2, 1) + SourceIndex(1) -2 >Emitted(12, 34) Source(2, 34) + SourceIndex(1) +1->Emitted(26, 1) Source(2, 1) + SourceIndex(2) +2 >Emitted(26, 34) Source(2, 34) + SourceIndex(2) --- >>>var a1 = 10; 1 > @@ -350,25 +516,25 @@ sourceFile:test.ts 4 > = 5 > 10 6 > ; -1 >Emitted(13, 1) Source(3, 1) + SourceIndex(1) -2 >Emitted(13, 5) Source(3, 5) + SourceIndex(1) -3 >Emitted(13, 7) Source(3, 7) + SourceIndex(1) -4 >Emitted(13, 10) Source(3, 10) + SourceIndex(1) -5 >Emitted(13, 12) Source(3, 12) + SourceIndex(1) -6 >Emitted(13, 13) Source(3, 13) + SourceIndex(1) +1 >Emitted(27, 1) Source(3, 1) + SourceIndex(2) +2 >Emitted(27, 5) Source(3, 5) + SourceIndex(2) +3 >Emitted(27, 7) Source(3, 7) + SourceIndex(2) +4 >Emitted(27, 10) Source(3, 10) + SourceIndex(2) +5 >Emitted(27, 12) Source(3, 12) + SourceIndex(2) +6 >Emitted(27, 13) Source(3, 13) + SourceIndex(2) --- >>>var c1 = (function () { 1-> 2 >^^^^^^^^^^^^^^^^^^^^-> 1-> > -1->Emitted(14, 1) Source(4, 1) + SourceIndex(1) +1->Emitted(28, 1) Source(4, 1) + SourceIndex(2) --- >>> function c1() { 1->^^^^ 2 > ^^-> 1-> -1->Emitted(15, 5) Source(4, 1) + SourceIndex(1) name (c1) +1->Emitted(29, 5) Source(4, 1) + SourceIndex(2) name (c1) --- >>> } 1->^^^^ @@ -378,16 +544,16 @@ sourceFile:test.ts > public p1: number; > 2 > } -1->Emitted(16, 5) Source(6, 1) + SourceIndex(1) name (c1.constructor) -2 >Emitted(16, 6) Source(6, 2) + SourceIndex(1) name (c1.constructor) +1->Emitted(30, 5) Source(6, 1) + SourceIndex(2) name (c1.constructor) +2 >Emitted(30, 6) Source(6, 2) + SourceIndex(2) name (c1.constructor) --- >>> return c1; 1->^^^^ 2 > ^^^^^^^^^ 1-> 2 > } -1->Emitted(17, 5) Source(6, 1) + SourceIndex(1) name (c1) -2 >Emitted(17, 14) Source(6, 2) + SourceIndex(1) name (c1) +1->Emitted(31, 5) Source(6, 1) + SourceIndex(2) name (c1) +2 >Emitted(31, 14) Source(6, 2) + SourceIndex(2) name (c1) --- >>>})(); 1 > @@ -401,10 +567,10 @@ sourceFile:test.ts 4 > class c1 { > public p1: number; > } -1 >Emitted(18, 1) Source(6, 1) + SourceIndex(1) name (c1) -2 >Emitted(18, 2) Source(6, 2) + SourceIndex(1) name (c1) -3 >Emitted(18, 2) Source(4, 1) + SourceIndex(1) -4 >Emitted(18, 6) Source(6, 2) + SourceIndex(1) +1 >Emitted(32, 1) Source(6, 1) + SourceIndex(2) name (c1) +2 >Emitted(32, 2) Source(6, 2) + SourceIndex(2) name (c1) +3 >Emitted(32, 2) Source(4, 1) + SourceIndex(2) +4 >Emitted(32, 6) Source(6, 2) + SourceIndex(2) --- >>>var instance1 = new c1(); 1-> @@ -425,21 +591,21 @@ sourceFile:test.ts 6 > c1 7 > () 8 > ; -1->Emitted(19, 1) Source(8, 1) + SourceIndex(1) -2 >Emitted(19, 5) Source(8, 5) + SourceIndex(1) -3 >Emitted(19, 14) Source(8, 14) + SourceIndex(1) -4 >Emitted(19, 17) Source(8, 17) + SourceIndex(1) -5 >Emitted(19, 21) Source(8, 21) + SourceIndex(1) -6 >Emitted(19, 23) Source(8, 23) + SourceIndex(1) -7 >Emitted(19, 25) Source(8, 25) + SourceIndex(1) -8 >Emitted(19, 26) Source(8, 26) + SourceIndex(1) +1->Emitted(33, 1) Source(8, 1) + SourceIndex(2) +2 >Emitted(33, 5) Source(8, 5) + SourceIndex(2) +3 >Emitted(33, 14) Source(8, 14) + SourceIndex(2) +4 >Emitted(33, 17) Source(8, 17) + SourceIndex(2) +5 >Emitted(33, 21) Source(8, 21) + SourceIndex(2) +6 >Emitted(33, 23) Source(8, 23) + SourceIndex(2) +7 >Emitted(33, 25) Source(8, 25) + SourceIndex(2) +8 >Emitted(33, 26) Source(8, 26) + SourceIndex(2) --- >>>function f1() { 1 > 2 >^^^^^^^^^^^^^^^^^^^^^^-> 1 > > -1 >Emitted(20, 1) Source(9, 1) + SourceIndex(1) +1 >Emitted(34, 1) Source(9, 1) + SourceIndex(2) --- >>> return instance1; 1->^^^^ @@ -453,11 +619,11 @@ sourceFile:test.ts 3 > 4 > instance1 5 > ; -1->Emitted(21, 5) Source(10, 5) + SourceIndex(1) name (f1) -2 >Emitted(21, 11) Source(10, 11) + SourceIndex(1) name (f1) -3 >Emitted(21, 12) Source(10, 12) + SourceIndex(1) name (f1) -4 >Emitted(21, 21) Source(10, 21) + SourceIndex(1) name (f1) -5 >Emitted(21, 22) Source(10, 22) + SourceIndex(1) name (f1) +1->Emitted(35, 5) Source(10, 5) + SourceIndex(2) name (f1) +2 >Emitted(35, 11) Source(10, 11) + SourceIndex(2) name (f1) +3 >Emitted(35, 12) Source(10, 12) + SourceIndex(2) name (f1) +4 >Emitted(35, 21) Source(10, 21) + SourceIndex(2) name (f1) +5 >Emitted(35, 22) Source(10, 22) + SourceIndex(2) name (f1) --- >>>} 1 > @@ -466,7 +632,7 @@ sourceFile:test.ts 1 > > 2 >} -1 >Emitted(22, 1) Source(11, 1) + SourceIndex(1) name (f1) -2 >Emitted(22, 2) Source(11, 2) + SourceIndex(1) name (f1) +1 >Emitted(36, 1) Source(11, 1) + SourceIndex(2) name (f1) +2 >Emitted(36, 2) Source(11, 2) + SourceIndex(2) name (f1) --- >>>//# sourceMappingURL=outAndOutDirFile.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.d.ts b/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.d.ts deleted file mode 100644 index 9b9cdd4a214..00000000000 --- a/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.d.ts +++ /dev/null @@ -1,13 +0,0 @@ -/// -declare var m1_a1: number; -declare class m1_c1 { - m1_c1_p1: number; -} -declare var m1_instance1: m1_c1; -declare function m1_f1(): m1_c1; -declare var a1: number; -declare class c1 { - p1: number; -} -declare var instance1: c1; -declare function f1(): c1; diff --git a/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.js b/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.js deleted file mode 100644 index 1750a5975ae..00000000000 --- a/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.js +++ /dev/null @@ -1,23 +0,0 @@ -var m1_a1 = 10; -var m1_c1 = (function () { - function m1_c1() { - } - return m1_c1; -})(); -var m1_instance1 = new m1_c1(); -function m1_f1() { - return m1_instance1; -} -/// -/// -var a1 = 10; -var c1 = (function () { - function c1() { - } - return c1; -})(); -var instance1 = new c1(); -function f1() { - return instance1; -} -//# sourceMappingURL=outAndOutDirFile.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.js.map b/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.js.map index 53e31e30260..ba9f4ee590c 100644 --- a/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.js.map +++ b/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.js.map @@ -1 +1 @@ -{"version":3,"file":"outAndOutDirFile.js","sourceRoot":"http://typescript.codeplex.com/","sources":["ref/m1.ts","test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACRD,iCAAiC;AACjC,iCAAiC;AACjC,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"outAndOutDirFile.js","sourceRoot":"http://typescript.codeplex.com/","sources":["ref/m1.ts","ref/m2.ts","test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;AERD,iCAAiC;AACjC,iCAAiC;AACjC,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/sourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory.sourcemap.txt b/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/sourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory.sourcemap.txt index 8bd8c2ac035..568c310918f 100644 --- a/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/sourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory.sourcemap.txt +++ b/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/sourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory.sourcemap.txt @@ -173,7 +173,7 @@ sourceFile:ref/m2.ts JsFile: outAndOutDirFile.js mapUrl: outAndOutDirFile.js.map sourceRoot: http://typescript.codeplex.com/ -sources: ref/m1.ts,test.ts +sources: ref/m1.ts,ref/m2.ts,test.ts =================================================================== ------------------------------------------------------------------- emittedFile:bin/outAndOutDirFile.js @@ -322,8 +322,8 @@ sourceFile:test.ts 3 > ^-> 1-> 2 >/// -1->Emitted(11, 1) Source(1, 1) + SourceIndex(1) -2 >Emitted(11, 34) Source(1, 34) + SourceIndex(1) +1->Emitted(11, 1) Source(1, 1) + SourceIndex(2) +2 >Emitted(11, 34) Source(1, 34) + SourceIndex(2) --- >>>/// 1-> @@ -331,8 +331,8 @@ sourceFile:test.ts 1-> > 2 >/// -1->Emitted(12, 1) Source(2, 1) + SourceIndex(1) -2 >Emitted(12, 34) Source(2, 34) + SourceIndex(1) +1->Emitted(12, 1) Source(2, 1) + SourceIndex(2) +2 >Emitted(12, 34) Source(2, 34) + SourceIndex(2) --- >>>var a1 = 10; 1 > @@ -349,25 +349,25 @@ sourceFile:test.ts 4 > = 5 > 10 6 > ; -1 >Emitted(13, 1) Source(3, 1) + SourceIndex(1) -2 >Emitted(13, 5) Source(3, 5) + SourceIndex(1) -3 >Emitted(13, 7) Source(3, 7) + SourceIndex(1) -4 >Emitted(13, 10) Source(3, 10) + SourceIndex(1) -5 >Emitted(13, 12) Source(3, 12) + SourceIndex(1) -6 >Emitted(13, 13) Source(3, 13) + SourceIndex(1) +1 >Emitted(13, 1) Source(3, 1) + SourceIndex(2) +2 >Emitted(13, 5) Source(3, 5) + SourceIndex(2) +3 >Emitted(13, 7) Source(3, 7) + SourceIndex(2) +4 >Emitted(13, 10) Source(3, 10) + SourceIndex(2) +5 >Emitted(13, 12) Source(3, 12) + SourceIndex(2) +6 >Emitted(13, 13) Source(3, 13) + SourceIndex(2) --- >>>var c1 = (function () { 1-> 2 >^^^^^^^^^^^^^^^^^^^^-> 1-> > -1->Emitted(14, 1) Source(4, 1) + SourceIndex(1) +1->Emitted(14, 1) Source(4, 1) + SourceIndex(2) --- >>> function c1() { 1->^^^^ 2 > ^^-> 1-> -1->Emitted(15, 5) Source(4, 1) + SourceIndex(1) name (c1) +1->Emitted(15, 5) Source(4, 1) + SourceIndex(2) name (c1) --- >>> } 1->^^^^ @@ -377,16 +377,16 @@ sourceFile:test.ts > public p1: number; > 2 > } -1->Emitted(16, 5) Source(6, 1) + SourceIndex(1) name (c1.constructor) -2 >Emitted(16, 6) Source(6, 2) + SourceIndex(1) name (c1.constructor) +1->Emitted(16, 5) Source(6, 1) + SourceIndex(2) name (c1.constructor) +2 >Emitted(16, 6) Source(6, 2) + SourceIndex(2) name (c1.constructor) --- >>> return c1; 1->^^^^ 2 > ^^^^^^^^^ 1-> 2 > } -1->Emitted(17, 5) Source(6, 1) + SourceIndex(1) name (c1) -2 >Emitted(17, 14) Source(6, 2) + SourceIndex(1) name (c1) +1->Emitted(17, 5) Source(6, 1) + SourceIndex(2) name (c1) +2 >Emitted(17, 14) Source(6, 2) + SourceIndex(2) name (c1) --- >>>})(); 1 > @@ -400,10 +400,10 @@ sourceFile:test.ts 4 > class c1 { > public p1: number; > } -1 >Emitted(18, 1) Source(6, 1) + SourceIndex(1) name (c1) -2 >Emitted(18, 2) Source(6, 2) + SourceIndex(1) name (c1) -3 >Emitted(18, 2) Source(4, 1) + SourceIndex(1) -4 >Emitted(18, 6) Source(6, 2) + SourceIndex(1) +1 >Emitted(18, 1) Source(6, 1) + SourceIndex(2) name (c1) +2 >Emitted(18, 2) Source(6, 2) + SourceIndex(2) name (c1) +3 >Emitted(18, 2) Source(4, 1) + SourceIndex(2) +4 >Emitted(18, 6) Source(6, 2) + SourceIndex(2) --- >>>var instance1 = new c1(); 1-> @@ -424,21 +424,21 @@ sourceFile:test.ts 6 > c1 7 > () 8 > ; -1->Emitted(19, 1) Source(8, 1) + SourceIndex(1) -2 >Emitted(19, 5) Source(8, 5) + SourceIndex(1) -3 >Emitted(19, 14) Source(8, 14) + SourceIndex(1) -4 >Emitted(19, 17) Source(8, 17) + SourceIndex(1) -5 >Emitted(19, 21) Source(8, 21) + SourceIndex(1) -6 >Emitted(19, 23) Source(8, 23) + SourceIndex(1) -7 >Emitted(19, 25) Source(8, 25) + SourceIndex(1) -8 >Emitted(19, 26) Source(8, 26) + SourceIndex(1) +1->Emitted(19, 1) Source(8, 1) + SourceIndex(2) +2 >Emitted(19, 5) Source(8, 5) + SourceIndex(2) +3 >Emitted(19, 14) Source(8, 14) + SourceIndex(2) +4 >Emitted(19, 17) Source(8, 17) + SourceIndex(2) +5 >Emitted(19, 21) Source(8, 21) + SourceIndex(2) +6 >Emitted(19, 23) Source(8, 23) + SourceIndex(2) +7 >Emitted(19, 25) Source(8, 25) + SourceIndex(2) +8 >Emitted(19, 26) Source(8, 26) + SourceIndex(2) --- >>>function f1() { 1 > 2 >^^^^^^^^^^^^^^^^^^^^^^-> 1 > > -1 >Emitted(20, 1) Source(9, 1) + SourceIndex(1) +1 >Emitted(20, 1) Source(9, 1) + SourceIndex(2) --- >>> return instance1; 1->^^^^ @@ -452,11 +452,11 @@ sourceFile:test.ts 3 > 4 > instance1 5 > ; -1->Emitted(21, 5) Source(10, 5) + SourceIndex(1) name (f1) -2 >Emitted(21, 11) Source(10, 11) + SourceIndex(1) name (f1) -3 >Emitted(21, 12) Source(10, 12) + SourceIndex(1) name (f1) -4 >Emitted(21, 21) Source(10, 21) + SourceIndex(1) name (f1) -5 >Emitted(21, 22) Source(10, 22) + SourceIndex(1) name (f1) +1->Emitted(21, 5) Source(10, 5) + SourceIndex(2) name (f1) +2 >Emitted(21, 11) Source(10, 11) + SourceIndex(2) name (f1) +3 >Emitted(21, 12) Source(10, 12) + SourceIndex(2) name (f1) +4 >Emitted(21, 21) Source(10, 21) + SourceIndex(2) name (f1) +5 >Emitted(21, 22) Source(10, 22) + SourceIndex(2) name (f1) --- >>>} 1 > @@ -465,7 +465,7 @@ sourceFile:test.ts 1 > > 2 >} -1 >Emitted(22, 1) Source(11, 1) + SourceIndex(1) name (f1) -2 >Emitted(22, 2) Source(11, 2) + SourceIndex(1) name (f1) +1 >Emitted(22, 1) Source(11, 1) + SourceIndex(2) name (f1) +2 >Emitted(22, 2) Source(11, 2) + SourceIndex(2) name (f1) --- >>>//# sourceMappingURL=outAndOutDirFile.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcerootUrlModuleMultifolderSpecifyOutputFile/amd/bin/test.d.ts b/tests/baselines/reference/project/sourcerootUrlModuleMultifolderSpecifyOutputFile/amd/bin/test.d.ts deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/tests/baselines/reference/project/sourcerootUrlModuleMultifolderSpecifyOutputFile/amd/bin/test.js b/tests/baselines/reference/project/sourcerootUrlModuleMultifolderSpecifyOutputFile/amd/bin/test.js deleted file mode 100644 index 6f3fefb9498..00000000000 --- a/tests/baselines/reference/project/sourcerootUrlModuleMultifolderSpecifyOutputFile/amd/bin/test.js +++ /dev/null @@ -1 +0,0 @@ -//# sourceMappingURL=test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcerootUrlModuleMultifolderSpecifyOutputFile/amd/bin/test.js.map b/tests/baselines/reference/project/sourcerootUrlModuleMultifolderSpecifyOutputFile/amd/bin/test.js.map index d3e851981ec..85e465474d3 100644 --- a/tests/baselines/reference/project/sourcerootUrlModuleMultifolderSpecifyOutputFile/amd/bin/test.js.map +++ b/tests/baselines/reference/project/sourcerootUrlModuleMultifolderSpecifyOutputFile/amd/bin/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"http://typescript.codeplex.com/","sources":[],"names":[],"mappings":""} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"http://typescript.codeplex.com/","sources":["outputdir_module_multifolder/ref/m1.ts","outputdir_module_multifolder_ref/m2.ts","outputdir_module_multifolder/test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","m2_c1","m2_c1.constructor","m2_f1","c1","c1.constructor","f1"],"mappings":";IAAW,aAAK,GAAG,EAAE,CAAC;IACtB;QAAAA;QAEAC,CAACA;QAADD,YAACA;IAADA,CAACA,AAFD,IAEC;IAFY,aAAK,QAEjB,CAAA;IAEU,oBAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACIE,MAAMA,CAACA,oBAAYA,CAACA;IACxBA,CAACA;IAFe,aAAK,QAEpB,CAAA;;;ICRU,aAAK,GAAG,EAAE,CAAC;IACtB;QAAAC;QAEAC,CAACA;QAADD,YAACA;IAADA,CAACA,AAFD,IAEC;IAFY,aAAK,QAEjB,CAAA;IAEU,oBAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACIE,MAAMA,CAACA,oBAAYA,CAACA;IACxBA,CAACA;IAFe,aAAK,QAEpB,CAAA;;;ICNU,UAAE,GAAG,EAAE,CAAC;IACnB;QAAAC;QAEAC,CAACA;QAADD,SAACA;IAADA,CAACA,AAFD,IAEC;IAFY,UAAE,KAEd,CAAA;IAEU,iBAAS,GAAG,IAAI,EAAE,EAAE,CAAC;IAChC;QACIE,MAAMA,CAACA,iBAASA,CAACA;IACrBA,CAACA;IAFe,UAAE,KAEjB,CAAA;IAEU,UAAE,GAAG,EAAE,CAAC,KAAK,CAAC;IACd,UAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcerootUrlModuleMultifolderSpecifyOutputFile/amd/sourcerootUrlModuleMultifolderSpecifyOutputFile.sourcemap.txt b/tests/baselines/reference/project/sourcerootUrlModuleMultifolderSpecifyOutputFile/amd/sourcerootUrlModuleMultifolderSpecifyOutputFile.sourcemap.txt index 86764c6d57a..088f581289a 100644 --- a/tests/baselines/reference/project/sourcerootUrlModuleMultifolderSpecifyOutputFile/amd/sourcerootUrlModuleMultifolderSpecifyOutputFile.sourcemap.txt +++ b/tests/baselines/reference/project/sourcerootUrlModuleMultifolderSpecifyOutputFile/amd/sourcerootUrlModuleMultifolderSpecifyOutputFile.sourcemap.txt @@ -571,6 +571,557 @@ sourceFile:outputdir_module_multifolder/test.ts JsFile: test.js mapUrl: test.js.map sourceRoot: http://typescript.codeplex.com/ -sources: +sources: outputdir_module_multifolder/ref/m1.ts,outputdir_module_multifolder_ref/m2.ts,outputdir_module_multifolder/test.ts =================================================================== +------------------------------------------------------------------- +emittedFile:bin/test.js +sourceFile:outputdir_module_multifolder/ref/m1.ts +------------------------------------------------------------------- +>>>define("ref/m1", ["require", "exports"], function (require, exports) { +>>> exports.m1_a1 = 10; +1 >^^^^ +2 > ^^^^^^^^^^^^^ +3 > ^^^ +4 > ^^ +5 > ^ +6 > ^^^^^^^^-> +1 >export var +2 > m1_a1 +3 > = +4 > 10 +5 > ; +1 >Emitted(2, 5) Source(1, 12) + SourceIndex(0) +2 >Emitted(2, 18) Source(1, 17) + SourceIndex(0) +3 >Emitted(2, 21) Source(1, 20) + SourceIndex(0) +4 >Emitted(2, 23) Source(1, 22) + SourceIndex(0) +5 >Emitted(2, 24) Source(1, 23) + SourceIndex(0) +--- +>>> var m1_c1 = (function () { +1->^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^^^^-> +1-> + > +1->Emitted(3, 5) Source(2, 1) + SourceIndex(0) +--- +>>> function m1_c1() { +1->^^^^^^^^ +2 > ^^-> +1-> +1->Emitted(4, 9) Source(2, 1) + SourceIndex(0) name (m1_c1) +--- +>>> } +1->^^^^^^^^ +2 > ^ +3 > ^^^^^^^^^^^^^-> +1->export class m1_c1 { + > public m1_c1_p1: number; + > +2 > } +1->Emitted(5, 9) Source(4, 1) + SourceIndex(0) name (m1_c1.constructor) +2 >Emitted(5, 10) Source(4, 2) + SourceIndex(0) name (m1_c1.constructor) +--- +>>> return m1_c1; +1->^^^^^^^^ +2 > ^^^^^^^^^^^^ +1-> +2 > } +1->Emitted(6, 9) Source(4, 1) + SourceIndex(0) name (m1_c1) +2 >Emitted(6, 21) Source(4, 2) + SourceIndex(0) name (m1_c1) +--- +>>> })(); +1 >^^^^ +2 > ^ +3 > +4 > ^^^^ +5 > ^^^^^^^^^^^^^^^^^^-> +1 > +2 > } +3 > +4 > export class m1_c1 { + > public m1_c1_p1: number; + > } +1 >Emitted(7, 5) Source(4, 1) + SourceIndex(0) name (m1_c1) +2 >Emitted(7, 6) Source(4, 2) + SourceIndex(0) name (m1_c1) +3 >Emitted(7, 6) Source(2, 1) + SourceIndex(0) +4 >Emitted(7, 10) Source(4, 2) + SourceIndex(0) +--- +>>> exports.m1_c1 = m1_c1; +1->^^^^ +2 > ^^^^^^^^^^^^^ +3 > ^^^^^^^^ +4 > ^ +5 > ^^^^^^^^^^^^^^-> +1-> +2 > m1_c1 +3 > { + > public m1_c1_p1: number; + > } +4 > +1->Emitted(8, 5) Source(2, 14) + SourceIndex(0) +2 >Emitted(8, 18) Source(2, 19) + SourceIndex(0) +3 >Emitted(8, 26) Source(4, 2) + SourceIndex(0) +4 >Emitted(8, 27) Source(4, 2) + SourceIndex(0) +--- +>>> exports.m1_instance1 = new m1_c1(); +1->^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^ +3 > ^^^ +4 > ^^^^ +5 > ^^^^^ +6 > ^^ +7 > ^ +1-> + > + >export var +2 > m1_instance1 +3 > = +4 > new +5 > m1_c1 +6 > () +7 > ; +1->Emitted(9, 5) Source(6, 12) + SourceIndex(0) +2 >Emitted(9, 25) Source(6, 24) + SourceIndex(0) +3 >Emitted(9, 28) Source(6, 27) + SourceIndex(0) +4 >Emitted(9, 32) Source(6, 31) + SourceIndex(0) +5 >Emitted(9, 37) Source(6, 36) + SourceIndex(0) +6 >Emitted(9, 39) Source(6, 38) + SourceIndex(0) +7 >Emitted(9, 40) Source(6, 39) + SourceIndex(0) +--- +>>> function m1_f1() { +1 >^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +1 > + > +1 >Emitted(10, 5) Source(7, 1) + SourceIndex(0) +--- +>>> return exports.m1_instance1; +1->^^^^^^^^ +2 > ^^^^^^ +3 > ^ +4 > ^^^^^^^^^^^^^^^^^^^^ +5 > ^ +1->export function m1_f1() { + > +2 > return +3 > +4 > m1_instance1 +5 > ; +1->Emitted(11, 9) Source(8, 5) + SourceIndex(0) name (m1_f1) +2 >Emitted(11, 15) Source(8, 11) + SourceIndex(0) name (m1_f1) +3 >Emitted(11, 16) Source(8, 12) + SourceIndex(0) name (m1_f1) +4 >Emitted(11, 36) Source(8, 24) + SourceIndex(0) name (m1_f1) +5 >Emitted(11, 37) Source(8, 25) + SourceIndex(0) name (m1_f1) +--- +>>> } +1 >^^^^ +2 > ^ +3 > ^^^^^^^^^^^^^^^^^^^^^^-> +1 > + > +2 > } +1 >Emitted(12, 5) Source(9, 1) + SourceIndex(0) name (m1_f1) +2 >Emitted(12, 6) Source(9, 2) + SourceIndex(0) name (m1_f1) +--- +>>> exports.m1_f1 = m1_f1; +1->^^^^ +2 > ^^^^^^^^^^^^^ +3 > ^^^^^^^^ +4 > ^ +1-> +2 > m1_f1 +3 > () { + > return m1_instance1; + > } +4 > +1->Emitted(13, 5) Source(7, 17) + SourceIndex(0) +2 >Emitted(13, 18) Source(7, 22) + SourceIndex(0) +3 >Emitted(13, 26) Source(9, 2) + SourceIndex(0) +4 >Emitted(13, 27) Source(9, 2) + SourceIndex(0) +--- +------------------------------------------------------------------- +emittedFile:bin/test.js +sourceFile:outputdir_module_multifolder_ref/m2.ts +------------------------------------------------------------------- +>>>}); +>>>define("../outputdir_module_multifolder_ref/m2", ["require", "exports"], function (require, exports) { +>>> exports.m2_a1 = 10; +1 >^^^^ +2 > ^^^^^^^^^^^^^ +3 > ^^^ +4 > ^^ +5 > ^ +6 > ^^^^^^^^-> +1 >export var +2 > m2_a1 +3 > = +4 > 10 +5 > ; +1 >Emitted(16, 5) Source(1, 12) + SourceIndex(1) +2 >Emitted(16, 18) Source(1, 17) + SourceIndex(1) +3 >Emitted(16, 21) Source(1, 20) + SourceIndex(1) +4 >Emitted(16, 23) Source(1, 22) + SourceIndex(1) +5 >Emitted(16, 24) Source(1, 23) + SourceIndex(1) +--- +>>> var m2_c1 = (function () { +1->^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^^^^-> +1-> + > +1->Emitted(17, 5) Source(2, 1) + SourceIndex(1) +--- +>>> function m2_c1() { +1->^^^^^^^^ +2 > ^^-> +1-> +1->Emitted(18, 9) Source(2, 1) + SourceIndex(1) name (m2_c1) +--- +>>> } +1->^^^^^^^^ +2 > ^ +3 > ^^^^^^^^^^^^^-> +1->export class m2_c1 { + > public m2_c1_p1: number; + > +2 > } +1->Emitted(19, 9) Source(4, 1) + SourceIndex(1) name (m2_c1.constructor) +2 >Emitted(19, 10) Source(4, 2) + SourceIndex(1) name (m2_c1.constructor) +--- +>>> return m2_c1; +1->^^^^^^^^ +2 > ^^^^^^^^^^^^ +1-> +2 > } +1->Emitted(20, 9) Source(4, 1) + SourceIndex(1) name (m2_c1) +2 >Emitted(20, 21) Source(4, 2) + SourceIndex(1) name (m2_c1) +--- +>>> })(); +1 >^^^^ +2 > ^ +3 > +4 > ^^^^ +5 > ^^^^^^^^^^^^^^^^^^-> +1 > +2 > } +3 > +4 > export class m2_c1 { + > public m2_c1_p1: number; + > } +1 >Emitted(21, 5) Source(4, 1) + SourceIndex(1) name (m2_c1) +2 >Emitted(21, 6) Source(4, 2) + SourceIndex(1) name (m2_c1) +3 >Emitted(21, 6) Source(2, 1) + SourceIndex(1) +4 >Emitted(21, 10) Source(4, 2) + SourceIndex(1) +--- +>>> exports.m2_c1 = m2_c1; +1->^^^^ +2 > ^^^^^^^^^^^^^ +3 > ^^^^^^^^ +4 > ^ +5 > ^^^^^^^^^^^^^^-> +1-> +2 > m2_c1 +3 > { + > public m2_c1_p1: number; + > } +4 > +1->Emitted(22, 5) Source(2, 14) + SourceIndex(1) +2 >Emitted(22, 18) Source(2, 19) + SourceIndex(1) +3 >Emitted(22, 26) Source(4, 2) + SourceIndex(1) +4 >Emitted(22, 27) Source(4, 2) + SourceIndex(1) +--- +>>> exports.m2_instance1 = new m2_c1(); +1->^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^ +3 > ^^^ +4 > ^^^^ +5 > ^^^^^ +6 > ^^ +7 > ^ +1-> + > + >export var +2 > m2_instance1 +3 > = +4 > new +5 > m2_c1 +6 > () +7 > ; +1->Emitted(23, 5) Source(6, 12) + SourceIndex(1) +2 >Emitted(23, 25) Source(6, 24) + SourceIndex(1) +3 >Emitted(23, 28) Source(6, 27) + SourceIndex(1) +4 >Emitted(23, 32) Source(6, 31) + SourceIndex(1) +5 >Emitted(23, 37) Source(6, 36) + SourceIndex(1) +6 >Emitted(23, 39) Source(6, 38) + SourceIndex(1) +7 >Emitted(23, 40) Source(6, 39) + SourceIndex(1) +--- +>>> function m2_f1() { +1 >^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +1 > + > +1 >Emitted(24, 5) Source(7, 1) + SourceIndex(1) +--- +>>> return exports.m2_instance1; +1->^^^^^^^^ +2 > ^^^^^^ +3 > ^ +4 > ^^^^^^^^^^^^^^^^^^^^ +5 > ^ +1->export function m2_f1() { + > +2 > return +3 > +4 > m2_instance1 +5 > ; +1->Emitted(25, 9) Source(8, 5) + SourceIndex(1) name (m2_f1) +2 >Emitted(25, 15) Source(8, 11) + SourceIndex(1) name (m2_f1) +3 >Emitted(25, 16) Source(8, 12) + SourceIndex(1) name (m2_f1) +4 >Emitted(25, 36) Source(8, 24) + SourceIndex(1) name (m2_f1) +5 >Emitted(25, 37) Source(8, 25) + SourceIndex(1) name (m2_f1) +--- +>>> } +1 >^^^^ +2 > ^ +3 > ^^^^^^^^^^^^^^^^^^^^^^-> +1 > + > +2 > } +1 >Emitted(26, 5) Source(9, 1) + SourceIndex(1) name (m2_f1) +2 >Emitted(26, 6) Source(9, 2) + SourceIndex(1) name (m2_f1) +--- +>>> exports.m2_f1 = m2_f1; +1->^^^^ +2 > ^^^^^^^^^^^^^ +3 > ^^^^^^^^ +4 > ^ +1-> +2 > m2_f1 +3 > () { + > return m2_instance1; + > } +4 > +1->Emitted(27, 5) Source(7, 17) + SourceIndex(1) +2 >Emitted(27, 18) Source(7, 22) + SourceIndex(1) +3 >Emitted(27, 26) Source(9, 2) + SourceIndex(1) +4 >Emitted(27, 27) Source(9, 2) + SourceIndex(1) +--- +------------------------------------------------------------------- +emittedFile:bin/test.js +sourceFile:outputdir_module_multifolder/test.ts +------------------------------------------------------------------- +>>>}); +>>>define("test", ["require", "exports", "ref/m1", "../outputdir_module_multifolder_ref/m2"], function (require, exports, m1, m2) { +>>> exports.a1 = 10; +1 >^^^^ +2 > ^^^^^^^^^^ +3 > ^^^ +4 > ^^ +5 > ^ +6 > ^^^^^^^^-> +1 >import m1 = require("ref/m1"); + >import m2 = require("../outputdir_module_multifolder_ref/m2"); + >export var +2 > a1 +3 > = +4 > 10 +5 > ; +1 >Emitted(30, 5) Source(3, 12) + SourceIndex(2) +2 >Emitted(30, 15) Source(3, 14) + SourceIndex(2) +3 >Emitted(30, 18) Source(3, 17) + SourceIndex(2) +4 >Emitted(30, 20) Source(3, 19) + SourceIndex(2) +5 >Emitted(30, 21) Source(3, 20) + SourceIndex(2) +--- +>>> var c1 = (function () { +1->^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^-> +1-> + > +1->Emitted(31, 5) Source(4, 1) + SourceIndex(2) +--- +>>> function c1() { +1->^^^^^^^^ +2 > ^^-> +1-> +1->Emitted(32, 9) Source(4, 1) + SourceIndex(2) name (c1) +--- +>>> } +1->^^^^^^^^ +2 > ^ +3 > ^^^^^^^^^^-> +1->export class c1 { + > public p1: number; + > +2 > } +1->Emitted(33, 9) Source(6, 1) + SourceIndex(2) name (c1.constructor) +2 >Emitted(33, 10) Source(6, 2) + SourceIndex(2) name (c1.constructor) +--- +>>> return c1; +1->^^^^^^^^ +2 > ^^^^^^^^^ +1-> +2 > } +1->Emitted(34, 9) Source(6, 1) + SourceIndex(2) name (c1) +2 >Emitted(34, 18) Source(6, 2) + SourceIndex(2) name (c1) +--- +>>> })(); +1 >^^^^ +2 > ^ +3 > +4 > ^^^^ +5 > ^^^^^^^^^^^^-> +1 > +2 > } +3 > +4 > export class c1 { + > public p1: number; + > } +1 >Emitted(35, 5) Source(6, 1) + SourceIndex(2) name (c1) +2 >Emitted(35, 6) Source(6, 2) + SourceIndex(2) name (c1) +3 >Emitted(35, 6) Source(4, 1) + SourceIndex(2) +4 >Emitted(35, 10) Source(6, 2) + SourceIndex(2) +--- +>>> exports.c1 = c1; +1->^^^^ +2 > ^^^^^^^^^^ +3 > ^^^^^ +4 > ^ +5 > ^^^^^^^^^^^^^^-> +1-> +2 > c1 +3 > { + > public p1: number; + > } +4 > +1->Emitted(36, 5) Source(4, 14) + SourceIndex(2) +2 >Emitted(36, 15) Source(4, 16) + SourceIndex(2) +3 >Emitted(36, 20) Source(6, 2) + SourceIndex(2) +4 >Emitted(36, 21) Source(6, 2) + SourceIndex(2) +--- +>>> exports.instance1 = new c1(); +1->^^^^ +2 > ^^^^^^^^^^^^^^^^^ +3 > ^^^ +4 > ^^^^ +5 > ^^ +6 > ^^ +7 > ^ +1-> + > + >export var +2 > instance1 +3 > = +4 > new +5 > c1 +6 > () +7 > ; +1->Emitted(37, 5) Source(8, 12) + SourceIndex(2) +2 >Emitted(37, 22) Source(8, 21) + SourceIndex(2) +3 >Emitted(37, 25) Source(8, 24) + SourceIndex(2) +4 >Emitted(37, 29) Source(8, 28) + SourceIndex(2) +5 >Emitted(37, 31) Source(8, 30) + SourceIndex(2) +6 >Emitted(37, 33) Source(8, 32) + SourceIndex(2) +7 >Emitted(37, 34) Source(8, 33) + SourceIndex(2) +--- +>>> function f1() { +1 >^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +1 > + > +1 >Emitted(38, 5) Source(9, 1) + SourceIndex(2) +--- +>>> return exports.instance1; +1->^^^^^^^^ +2 > ^^^^^^ +3 > ^ +4 > ^^^^^^^^^^^^^^^^^ +5 > ^ +1->export function f1() { + > +2 > return +3 > +4 > instance1 +5 > ; +1->Emitted(39, 9) Source(10, 5) + SourceIndex(2) name (f1) +2 >Emitted(39, 15) Source(10, 11) + SourceIndex(2) name (f1) +3 >Emitted(39, 16) Source(10, 12) + SourceIndex(2) name (f1) +4 >Emitted(39, 33) Source(10, 21) + SourceIndex(2) name (f1) +5 >Emitted(39, 34) Source(10, 22) + SourceIndex(2) name (f1) +--- +>>> } +1 >^^^^ +2 > ^ +3 > ^^^^^^^^^^^^^^^^-> +1 > + > +2 > } +1 >Emitted(40, 5) Source(11, 1) + SourceIndex(2) name (f1) +2 >Emitted(40, 6) Source(11, 2) + SourceIndex(2) name (f1) +--- +>>> exports.f1 = f1; +1->^^^^ +2 > ^^^^^^^^^^ +3 > ^^^^^ +4 > ^ +5 > ^^^^^^^-> +1-> +2 > f1 +3 > () { + > return instance1; + > } +4 > +1->Emitted(41, 5) Source(9, 17) + SourceIndex(2) +2 >Emitted(41, 15) Source(9, 19) + SourceIndex(2) +3 >Emitted(41, 20) Source(11, 2) + SourceIndex(2) +4 >Emitted(41, 21) Source(11, 2) + SourceIndex(2) +--- +>>> exports.a2 = m1.m1_c1; +1->^^^^ +2 > ^^^^^^^^^^ +3 > ^^^ +4 > ^^ +5 > ^ +6 > ^^^^^ +7 > ^ +8 > ^-> +1-> + > + >export var +2 > a2 +3 > = +4 > m1 +5 > . +6 > m1_c1 +7 > ; +1->Emitted(42, 5) Source(13, 12) + SourceIndex(2) +2 >Emitted(42, 15) Source(13, 14) + SourceIndex(2) +3 >Emitted(42, 18) Source(13, 17) + SourceIndex(2) +4 >Emitted(42, 20) Source(13, 19) + SourceIndex(2) +5 >Emitted(42, 21) Source(13, 20) + SourceIndex(2) +6 >Emitted(42, 26) Source(13, 25) + SourceIndex(2) +7 >Emitted(42, 27) Source(13, 26) + SourceIndex(2) +--- +>>> exports.a3 = m2.m2_c1; +1->^^^^ +2 > ^^^^^^^^^^ +3 > ^^^ +4 > ^^ +5 > ^ +6 > ^^^^^ +7 > ^ +1-> + >export var +2 > a3 +3 > = +4 > m2 +5 > . +6 > m2_c1 +7 > ; +1->Emitted(43, 5) Source(14, 12) + SourceIndex(2) +2 >Emitted(43, 15) Source(14, 14) + SourceIndex(2) +3 >Emitted(43, 18) Source(14, 17) + SourceIndex(2) +4 >Emitted(43, 20) Source(14, 19) + SourceIndex(2) +5 >Emitted(43, 21) Source(14, 20) + SourceIndex(2) +6 >Emitted(43, 26) Source(14, 25) + SourceIndex(2) +7 >Emitted(43, 27) Source(14, 26) + SourceIndex(2) +--- +>>>}); >>>//# sourceMappingURL=test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcerootUrlModuleMultifolderSpecifyOutputFile/node/bin/test.d.ts b/tests/baselines/reference/project/sourcerootUrlModuleMultifolderSpecifyOutputFile/node/bin/test.d.ts deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/tests/baselines/reference/project/sourcerootUrlModuleMultifolderSpecifyOutputFile/node/bin/test.js b/tests/baselines/reference/project/sourcerootUrlModuleMultifolderSpecifyOutputFile/node/bin/test.js deleted file mode 100644 index 6f3fefb9498..00000000000 --- a/tests/baselines/reference/project/sourcerootUrlModuleMultifolderSpecifyOutputFile/node/bin/test.js +++ /dev/null @@ -1 +0,0 @@ -//# sourceMappingURL=test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcerootUrlModuleMultifolderSpecifyOutputFile/node/bin/test.js.map b/tests/baselines/reference/project/sourcerootUrlModuleMultifolderSpecifyOutputFile/node/bin/test.js.map index d3e851981ec..f84040526ba 100644 --- a/tests/baselines/reference/project/sourcerootUrlModuleMultifolderSpecifyOutputFile/node/bin/test.js.map +++ b/tests/baselines/reference/project/sourcerootUrlModuleMultifolderSpecifyOutputFile/node/bin/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"http://typescript.codeplex.com/","sources":[],"names":[],"mappings":""} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"http://typescript.codeplex.com/","sources":["outputdir_module_multifolder/ref/m1.ts","outputdir_module_multifolder_ref/m2.ts","outputdir_module_multifolder/test.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcerootUrlModuleMultifolderSpecifyOutputFile/node/sourcerootUrlModuleMultifolderSpecifyOutputFile.sourcemap.txt b/tests/baselines/reference/project/sourcerootUrlModuleMultifolderSpecifyOutputFile/node/sourcerootUrlModuleMultifolderSpecifyOutputFile.sourcemap.txt index eb2dff17042..a116b6b4d78 100644 --- a/tests/baselines/reference/project/sourcerootUrlModuleMultifolderSpecifyOutputFile/node/sourcerootUrlModuleMultifolderSpecifyOutputFile.sourcemap.txt +++ b/tests/baselines/reference/project/sourcerootUrlModuleMultifolderSpecifyOutputFile/node/sourcerootUrlModuleMultifolderSpecifyOutputFile.sourcemap.txt @@ -615,6 +615,6 @@ sourceFile:outputdir_module_multifolder/test.ts JsFile: test.js mapUrl: test.js.map sourceRoot: http://typescript.codeplex.com/ -sources: +sources: outputdir_module_multifolder/ref/m1.ts,outputdir_module_multifolder_ref/m2.ts,outputdir_module_multifolder/test.ts =================================================================== >>>//# sourceMappingURL=test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcerootUrlModuleSimpleSpecifyOutputFile/amd/bin/test.d.ts b/tests/baselines/reference/project/sourcerootUrlModuleSimpleSpecifyOutputFile/amd/bin/test.d.ts deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/tests/baselines/reference/project/sourcerootUrlModuleSimpleSpecifyOutputFile/amd/bin/test.js b/tests/baselines/reference/project/sourcerootUrlModuleSimpleSpecifyOutputFile/amd/bin/test.js deleted file mode 100644 index 6f3fefb9498..00000000000 --- a/tests/baselines/reference/project/sourcerootUrlModuleSimpleSpecifyOutputFile/amd/bin/test.js +++ /dev/null @@ -1 +0,0 @@ -//# sourceMappingURL=test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcerootUrlModuleSimpleSpecifyOutputFile/amd/bin/test.js.map b/tests/baselines/reference/project/sourcerootUrlModuleSimpleSpecifyOutputFile/amd/bin/test.js.map index d3e851981ec..2ace469f902 100644 --- a/tests/baselines/reference/project/sourcerootUrlModuleSimpleSpecifyOutputFile/amd/bin/test.js.map +++ b/tests/baselines/reference/project/sourcerootUrlModuleSimpleSpecifyOutputFile/amd/bin/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"http://typescript.codeplex.com/","sources":[],"names":[],"mappings":""} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"http://typescript.codeplex.com/","sources":["m1.ts","test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","c1","c1.constructor","f1"],"mappings":";IAAW,aAAK,GAAG,EAAE,CAAC;IACtB;QAAAA;QAEAC,CAACA;QAADD,YAACA;IAADA,CAACA,AAFD,IAEC;IAFY,aAAK,QAEjB,CAAA;IAEU,oBAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACIE,MAAMA,CAACA,oBAAYA,CAACA;IACxBA,CAACA;IAFe,aAAK,QAEpB,CAAA;;;ICPU,UAAE,GAAG,EAAE,CAAC;IACnB;QAAAC;QAEAC,CAACA;QAADD,SAACA;IAADA,CAACA,AAFD,IAEC;IAFY,UAAE,KAEd,CAAA;IAEU,iBAAS,GAAG,IAAI,EAAE,EAAE,CAAC;IAChC;QACIE,MAAMA,CAACA,iBAASA,CAACA;IACrBA,CAACA;IAFe,UAAE,KAEjB,CAAA;IAEU,UAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcerootUrlModuleSimpleSpecifyOutputFile/amd/sourcerootUrlModuleSimpleSpecifyOutputFile.sourcemap.txt b/tests/baselines/reference/project/sourcerootUrlModuleSimpleSpecifyOutputFile/amd/sourcerootUrlModuleSimpleSpecifyOutputFile.sourcemap.txt index 3e447368494..906ba3a07ac 100644 --- a/tests/baselines/reference/project/sourcerootUrlModuleSimpleSpecifyOutputFile/amd/sourcerootUrlModuleSimpleSpecifyOutputFile.sourcemap.txt +++ b/tests/baselines/reference/project/sourcerootUrlModuleSimpleSpecifyOutputFile/amd/sourcerootUrlModuleSimpleSpecifyOutputFile.sourcemap.txt @@ -373,6 +373,365 @@ sourceFile:test.ts JsFile: test.js mapUrl: test.js.map sourceRoot: http://typescript.codeplex.com/ -sources: +sources: m1.ts,test.ts =================================================================== +------------------------------------------------------------------- +emittedFile:bin/test.js +sourceFile:m1.ts +------------------------------------------------------------------- +>>>define("m1", ["require", "exports"], function (require, exports) { +>>> exports.m1_a1 = 10; +1 >^^^^ +2 > ^^^^^^^^^^^^^ +3 > ^^^ +4 > ^^ +5 > ^ +6 > ^^^^^^^^-> +1 >export var +2 > m1_a1 +3 > = +4 > 10 +5 > ; +1 >Emitted(2, 5) Source(1, 12) + SourceIndex(0) +2 >Emitted(2, 18) Source(1, 17) + SourceIndex(0) +3 >Emitted(2, 21) Source(1, 20) + SourceIndex(0) +4 >Emitted(2, 23) Source(1, 22) + SourceIndex(0) +5 >Emitted(2, 24) Source(1, 23) + SourceIndex(0) +--- +>>> var m1_c1 = (function () { +1->^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^^^^-> +1-> + > +1->Emitted(3, 5) Source(2, 1) + SourceIndex(0) +--- +>>> function m1_c1() { +1->^^^^^^^^ +2 > ^^-> +1-> +1->Emitted(4, 9) Source(2, 1) + SourceIndex(0) name (m1_c1) +--- +>>> } +1->^^^^^^^^ +2 > ^ +3 > ^^^^^^^^^^^^^-> +1->export class m1_c1 { + > public m1_c1_p1: number; + > +2 > } +1->Emitted(5, 9) Source(4, 1) + SourceIndex(0) name (m1_c1.constructor) +2 >Emitted(5, 10) Source(4, 2) + SourceIndex(0) name (m1_c1.constructor) +--- +>>> return m1_c1; +1->^^^^^^^^ +2 > ^^^^^^^^^^^^ +1-> +2 > } +1->Emitted(6, 9) Source(4, 1) + SourceIndex(0) name (m1_c1) +2 >Emitted(6, 21) Source(4, 2) + SourceIndex(0) name (m1_c1) +--- +>>> })(); +1 >^^^^ +2 > ^ +3 > +4 > ^^^^ +5 > ^^^^^^^^^^^^^^^^^^-> +1 > +2 > } +3 > +4 > export class m1_c1 { + > public m1_c1_p1: number; + > } +1 >Emitted(7, 5) Source(4, 1) + SourceIndex(0) name (m1_c1) +2 >Emitted(7, 6) Source(4, 2) + SourceIndex(0) name (m1_c1) +3 >Emitted(7, 6) Source(2, 1) + SourceIndex(0) +4 >Emitted(7, 10) Source(4, 2) + SourceIndex(0) +--- +>>> exports.m1_c1 = m1_c1; +1->^^^^ +2 > ^^^^^^^^^^^^^ +3 > ^^^^^^^^ +4 > ^ +5 > ^^^^^^^^^^^^^^-> +1-> +2 > m1_c1 +3 > { + > public m1_c1_p1: number; + > } +4 > +1->Emitted(8, 5) Source(2, 14) + SourceIndex(0) +2 >Emitted(8, 18) Source(2, 19) + SourceIndex(0) +3 >Emitted(8, 26) Source(4, 2) + SourceIndex(0) +4 >Emitted(8, 27) Source(4, 2) + SourceIndex(0) +--- +>>> exports.m1_instance1 = new m1_c1(); +1->^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^ +3 > ^^^ +4 > ^^^^ +5 > ^^^^^ +6 > ^^ +7 > ^ +1-> + > + >export var +2 > m1_instance1 +3 > = +4 > new +5 > m1_c1 +6 > () +7 > ; +1->Emitted(9, 5) Source(6, 12) + SourceIndex(0) +2 >Emitted(9, 25) Source(6, 24) + SourceIndex(0) +3 >Emitted(9, 28) Source(6, 27) + SourceIndex(0) +4 >Emitted(9, 32) Source(6, 31) + SourceIndex(0) +5 >Emitted(9, 37) Source(6, 36) + SourceIndex(0) +6 >Emitted(9, 39) Source(6, 38) + SourceIndex(0) +7 >Emitted(9, 40) Source(6, 39) + SourceIndex(0) +--- +>>> function m1_f1() { +1 >^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +1 > + > +1 >Emitted(10, 5) Source(7, 1) + SourceIndex(0) +--- +>>> return exports.m1_instance1; +1->^^^^^^^^ +2 > ^^^^^^ +3 > ^ +4 > ^^^^^^^^^^^^^^^^^^^^ +5 > ^ +1->export function m1_f1() { + > +2 > return +3 > +4 > m1_instance1 +5 > ; +1->Emitted(11, 9) Source(8, 5) + SourceIndex(0) name (m1_f1) +2 >Emitted(11, 15) Source(8, 11) + SourceIndex(0) name (m1_f1) +3 >Emitted(11, 16) Source(8, 12) + SourceIndex(0) name (m1_f1) +4 >Emitted(11, 36) Source(8, 24) + SourceIndex(0) name (m1_f1) +5 >Emitted(11, 37) Source(8, 25) + SourceIndex(0) name (m1_f1) +--- +>>> } +1 >^^^^ +2 > ^ +3 > ^^^^^^^^^^^^^^^^^^^^^^-> +1 > + > +2 > } +1 >Emitted(12, 5) Source(9, 1) + SourceIndex(0) name (m1_f1) +2 >Emitted(12, 6) Source(9, 2) + SourceIndex(0) name (m1_f1) +--- +>>> exports.m1_f1 = m1_f1; +1->^^^^ +2 > ^^^^^^^^^^^^^ +3 > ^^^^^^^^ +4 > ^ +1-> +2 > m1_f1 +3 > () { + > return m1_instance1; + > } +4 > +1->Emitted(13, 5) Source(7, 17) + SourceIndex(0) +2 >Emitted(13, 18) Source(7, 22) + SourceIndex(0) +3 >Emitted(13, 26) Source(9, 2) + SourceIndex(0) +4 >Emitted(13, 27) Source(9, 2) + SourceIndex(0) +--- +------------------------------------------------------------------- +emittedFile:bin/test.js +sourceFile:test.ts +------------------------------------------------------------------- +>>>}); +>>>define("test", ["require", "exports", "m1"], function (require, exports, m1) { +>>> exports.a1 = 10; +1 >^^^^ +2 > ^^^^^^^^^^ +3 > ^^^ +4 > ^^ +5 > ^ +6 > ^^^^^^^^-> +1 >import m1 = require("m1"); + >export var +2 > a1 +3 > = +4 > 10 +5 > ; +1 >Emitted(16, 5) Source(2, 12) + SourceIndex(1) +2 >Emitted(16, 15) Source(2, 14) + SourceIndex(1) +3 >Emitted(16, 18) Source(2, 17) + SourceIndex(1) +4 >Emitted(16, 20) Source(2, 19) + SourceIndex(1) +5 >Emitted(16, 21) Source(2, 20) + SourceIndex(1) +--- +>>> var c1 = (function () { +1->^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^-> +1-> + > +1->Emitted(17, 5) Source(3, 1) + SourceIndex(1) +--- +>>> function c1() { +1->^^^^^^^^ +2 > ^^-> +1-> +1->Emitted(18, 9) Source(3, 1) + SourceIndex(1) name (c1) +--- +>>> } +1->^^^^^^^^ +2 > ^ +3 > ^^^^^^^^^^-> +1->export class c1 { + > public p1: number; + > +2 > } +1->Emitted(19, 9) Source(5, 1) + SourceIndex(1) name (c1.constructor) +2 >Emitted(19, 10) Source(5, 2) + SourceIndex(1) name (c1.constructor) +--- +>>> return c1; +1->^^^^^^^^ +2 > ^^^^^^^^^ +1-> +2 > } +1->Emitted(20, 9) Source(5, 1) + SourceIndex(1) name (c1) +2 >Emitted(20, 18) Source(5, 2) + SourceIndex(1) name (c1) +--- +>>> })(); +1 >^^^^ +2 > ^ +3 > +4 > ^^^^ +5 > ^^^^^^^^^^^^-> +1 > +2 > } +3 > +4 > export class c1 { + > public p1: number; + > } +1 >Emitted(21, 5) Source(5, 1) + SourceIndex(1) name (c1) +2 >Emitted(21, 6) Source(5, 2) + SourceIndex(1) name (c1) +3 >Emitted(21, 6) Source(3, 1) + SourceIndex(1) +4 >Emitted(21, 10) Source(5, 2) + SourceIndex(1) +--- +>>> exports.c1 = c1; +1->^^^^ +2 > ^^^^^^^^^^ +3 > ^^^^^ +4 > ^ +5 > ^^^^^^^^^^^^^^-> +1-> +2 > c1 +3 > { + > public p1: number; + > } +4 > +1->Emitted(22, 5) Source(3, 14) + SourceIndex(1) +2 >Emitted(22, 15) Source(3, 16) + SourceIndex(1) +3 >Emitted(22, 20) Source(5, 2) + SourceIndex(1) +4 >Emitted(22, 21) Source(5, 2) + SourceIndex(1) +--- +>>> exports.instance1 = new c1(); +1->^^^^ +2 > ^^^^^^^^^^^^^^^^^ +3 > ^^^ +4 > ^^^^ +5 > ^^ +6 > ^^ +7 > ^ +1-> + > + >export var +2 > instance1 +3 > = +4 > new +5 > c1 +6 > () +7 > ; +1->Emitted(23, 5) Source(7, 12) + SourceIndex(1) +2 >Emitted(23, 22) Source(7, 21) + SourceIndex(1) +3 >Emitted(23, 25) Source(7, 24) + SourceIndex(1) +4 >Emitted(23, 29) Source(7, 28) + SourceIndex(1) +5 >Emitted(23, 31) Source(7, 30) + SourceIndex(1) +6 >Emitted(23, 33) Source(7, 32) + SourceIndex(1) +7 >Emitted(23, 34) Source(7, 33) + SourceIndex(1) +--- +>>> function f1() { +1 >^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +1 > + > +1 >Emitted(24, 5) Source(8, 1) + SourceIndex(1) +--- +>>> return exports.instance1; +1->^^^^^^^^ +2 > ^^^^^^ +3 > ^ +4 > ^^^^^^^^^^^^^^^^^ +5 > ^ +1->export function f1() { + > +2 > return +3 > +4 > instance1 +5 > ; +1->Emitted(25, 9) Source(9, 5) + SourceIndex(1) name (f1) +2 >Emitted(25, 15) Source(9, 11) + SourceIndex(1) name (f1) +3 >Emitted(25, 16) Source(9, 12) + SourceIndex(1) name (f1) +4 >Emitted(25, 33) Source(9, 21) + SourceIndex(1) name (f1) +5 >Emitted(25, 34) Source(9, 22) + SourceIndex(1) name (f1) +--- +>>> } +1 >^^^^ +2 > ^ +3 > ^^^^^^^^^^^^^^^^-> +1 > + > +2 > } +1 >Emitted(26, 5) Source(10, 1) + SourceIndex(1) name (f1) +2 >Emitted(26, 6) Source(10, 2) + SourceIndex(1) name (f1) +--- +>>> exports.f1 = f1; +1->^^^^ +2 > ^^^^^^^^^^ +3 > ^^^^^ +4 > ^ +5 > ^^^^^^^-> +1-> +2 > f1 +3 > () { + > return instance1; + > } +4 > +1->Emitted(27, 5) Source(8, 17) + SourceIndex(1) +2 >Emitted(27, 15) Source(8, 19) + SourceIndex(1) +3 >Emitted(27, 20) Source(10, 2) + SourceIndex(1) +4 >Emitted(27, 21) Source(10, 2) + SourceIndex(1) +--- +>>> exports.a2 = m1.m1_c1; +1->^^^^ +2 > ^^^^^^^^^^ +3 > ^^^ +4 > ^^ +5 > ^ +6 > ^^^^^ +7 > ^ +1-> + > + >export var +2 > a2 +3 > = +4 > m1 +5 > . +6 > m1_c1 +7 > ; +1->Emitted(28, 5) Source(12, 12) + SourceIndex(1) +2 >Emitted(28, 15) Source(12, 14) + SourceIndex(1) +3 >Emitted(28, 18) Source(12, 17) + SourceIndex(1) +4 >Emitted(28, 20) Source(12, 19) + SourceIndex(1) +5 >Emitted(28, 21) Source(12, 20) + SourceIndex(1) +6 >Emitted(28, 26) Source(12, 25) + SourceIndex(1) +7 >Emitted(28, 27) Source(12, 26) + SourceIndex(1) +--- +>>>}); >>>//# sourceMappingURL=test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcerootUrlModuleSimpleSpecifyOutputFile/node/bin/test.d.ts b/tests/baselines/reference/project/sourcerootUrlModuleSimpleSpecifyOutputFile/node/bin/test.d.ts deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/tests/baselines/reference/project/sourcerootUrlModuleSimpleSpecifyOutputFile/node/bin/test.js b/tests/baselines/reference/project/sourcerootUrlModuleSimpleSpecifyOutputFile/node/bin/test.js deleted file mode 100644 index 6f3fefb9498..00000000000 --- a/tests/baselines/reference/project/sourcerootUrlModuleSimpleSpecifyOutputFile/node/bin/test.js +++ /dev/null @@ -1 +0,0 @@ -//# sourceMappingURL=test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcerootUrlModuleSimpleSpecifyOutputFile/node/bin/test.js.map b/tests/baselines/reference/project/sourcerootUrlModuleSimpleSpecifyOutputFile/node/bin/test.js.map index d3e851981ec..3b75f2878c9 100644 --- a/tests/baselines/reference/project/sourcerootUrlModuleSimpleSpecifyOutputFile/node/bin/test.js.map +++ b/tests/baselines/reference/project/sourcerootUrlModuleSimpleSpecifyOutputFile/node/bin/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"http://typescript.codeplex.com/","sources":[],"names":[],"mappings":""} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"http://typescript.codeplex.com/","sources":["m1.ts","test.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcerootUrlModuleSimpleSpecifyOutputFile/node/sourcerootUrlModuleSimpleSpecifyOutputFile.sourcemap.txt b/tests/baselines/reference/project/sourcerootUrlModuleSimpleSpecifyOutputFile/node/sourcerootUrlModuleSimpleSpecifyOutputFile.sourcemap.txt index 4d3c5799e27..432e0b90c49 100644 --- a/tests/baselines/reference/project/sourcerootUrlModuleSimpleSpecifyOutputFile/node/sourcerootUrlModuleSimpleSpecifyOutputFile.sourcemap.txt +++ b/tests/baselines/reference/project/sourcerootUrlModuleSimpleSpecifyOutputFile/node/sourcerootUrlModuleSimpleSpecifyOutputFile.sourcemap.txt @@ -394,6 +394,6 @@ sourceFile:test.ts JsFile: test.js mapUrl: test.js.map sourceRoot: http://typescript.codeplex.com/ -sources: +sources: m1.ts,test.ts =================================================================== >>>//# sourceMappingURL=test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcerootUrlModuleSubfolderSpecifyOutputFile/amd/bin/test.d.ts b/tests/baselines/reference/project/sourcerootUrlModuleSubfolderSpecifyOutputFile/amd/bin/test.d.ts deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/tests/baselines/reference/project/sourcerootUrlModuleSubfolderSpecifyOutputFile/amd/bin/test.js b/tests/baselines/reference/project/sourcerootUrlModuleSubfolderSpecifyOutputFile/amd/bin/test.js deleted file mode 100644 index 6f3fefb9498..00000000000 --- a/tests/baselines/reference/project/sourcerootUrlModuleSubfolderSpecifyOutputFile/amd/bin/test.js +++ /dev/null @@ -1 +0,0 @@ -//# sourceMappingURL=test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcerootUrlModuleSubfolderSpecifyOutputFile/amd/bin/test.js.map b/tests/baselines/reference/project/sourcerootUrlModuleSubfolderSpecifyOutputFile/amd/bin/test.js.map index d3e851981ec..29e01bc0bc6 100644 --- a/tests/baselines/reference/project/sourcerootUrlModuleSubfolderSpecifyOutputFile/amd/bin/test.js.map +++ b/tests/baselines/reference/project/sourcerootUrlModuleSubfolderSpecifyOutputFile/amd/bin/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"http://typescript.codeplex.com/","sources":[],"names":[],"mappings":""} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"http://typescript.codeplex.com/","sources":["ref/m1.ts","test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","c1","c1.constructor","f1"],"mappings":";IAAW,aAAK,GAAG,EAAE,CAAC;IACtB;QAAAA;QAEAC,CAACA;QAADD,YAACA;IAADA,CAACA,AAFD,IAEC;IAFY,aAAK,QAEjB,CAAA;IAEU,oBAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACIE,MAAMA,CAACA,oBAAYA,CAACA;IACxBA,CAACA;IAFe,aAAK,QAEpB,CAAA;;;ICPU,UAAE,GAAG,EAAE,CAAC;IACnB;QAAAC;QAEAC,CAACA;QAADD,SAACA;IAADA,CAACA,AAFD,IAEC;IAFY,UAAE,KAEd,CAAA;IAEU,iBAAS,GAAG,IAAI,EAAE,EAAE,CAAC;IAChC;QACIE,MAAMA,CAACA,iBAASA,CAACA;IACrBA,CAACA;IAFe,UAAE,KAEjB,CAAA;IAEU,UAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcerootUrlModuleSubfolderSpecifyOutputFile/amd/sourcerootUrlModuleSubfolderSpecifyOutputFile.sourcemap.txt b/tests/baselines/reference/project/sourcerootUrlModuleSubfolderSpecifyOutputFile/amd/sourcerootUrlModuleSubfolderSpecifyOutputFile.sourcemap.txt index 54c26748c78..a5d445804bf 100644 --- a/tests/baselines/reference/project/sourcerootUrlModuleSubfolderSpecifyOutputFile/amd/sourcerootUrlModuleSubfolderSpecifyOutputFile.sourcemap.txt +++ b/tests/baselines/reference/project/sourcerootUrlModuleSubfolderSpecifyOutputFile/amd/sourcerootUrlModuleSubfolderSpecifyOutputFile.sourcemap.txt @@ -373,6 +373,365 @@ sourceFile:test.ts JsFile: test.js mapUrl: test.js.map sourceRoot: http://typescript.codeplex.com/ -sources: +sources: ref/m1.ts,test.ts =================================================================== +------------------------------------------------------------------- +emittedFile:bin/test.js +sourceFile:ref/m1.ts +------------------------------------------------------------------- +>>>define("ref/m1", ["require", "exports"], function (require, exports) { +>>> exports.m1_a1 = 10; +1 >^^^^ +2 > ^^^^^^^^^^^^^ +3 > ^^^ +4 > ^^ +5 > ^ +6 > ^^^^^^^^-> +1 >export var +2 > m1_a1 +3 > = +4 > 10 +5 > ; +1 >Emitted(2, 5) Source(1, 12) + SourceIndex(0) +2 >Emitted(2, 18) Source(1, 17) + SourceIndex(0) +3 >Emitted(2, 21) Source(1, 20) + SourceIndex(0) +4 >Emitted(2, 23) Source(1, 22) + SourceIndex(0) +5 >Emitted(2, 24) Source(1, 23) + SourceIndex(0) +--- +>>> var m1_c1 = (function () { +1->^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^^^^-> +1-> + > +1->Emitted(3, 5) Source(2, 1) + SourceIndex(0) +--- +>>> function m1_c1() { +1->^^^^^^^^ +2 > ^^-> +1-> +1->Emitted(4, 9) Source(2, 1) + SourceIndex(0) name (m1_c1) +--- +>>> } +1->^^^^^^^^ +2 > ^ +3 > ^^^^^^^^^^^^^-> +1->export class m1_c1 { + > public m1_c1_p1: number; + > +2 > } +1->Emitted(5, 9) Source(4, 1) + SourceIndex(0) name (m1_c1.constructor) +2 >Emitted(5, 10) Source(4, 2) + SourceIndex(0) name (m1_c1.constructor) +--- +>>> return m1_c1; +1->^^^^^^^^ +2 > ^^^^^^^^^^^^ +1-> +2 > } +1->Emitted(6, 9) Source(4, 1) + SourceIndex(0) name (m1_c1) +2 >Emitted(6, 21) Source(4, 2) + SourceIndex(0) name (m1_c1) +--- +>>> })(); +1 >^^^^ +2 > ^ +3 > +4 > ^^^^ +5 > ^^^^^^^^^^^^^^^^^^-> +1 > +2 > } +3 > +4 > export class m1_c1 { + > public m1_c1_p1: number; + > } +1 >Emitted(7, 5) Source(4, 1) + SourceIndex(0) name (m1_c1) +2 >Emitted(7, 6) Source(4, 2) + SourceIndex(0) name (m1_c1) +3 >Emitted(7, 6) Source(2, 1) + SourceIndex(0) +4 >Emitted(7, 10) Source(4, 2) + SourceIndex(0) +--- +>>> exports.m1_c1 = m1_c1; +1->^^^^ +2 > ^^^^^^^^^^^^^ +3 > ^^^^^^^^ +4 > ^ +5 > ^^^^^^^^^^^^^^-> +1-> +2 > m1_c1 +3 > { + > public m1_c1_p1: number; + > } +4 > +1->Emitted(8, 5) Source(2, 14) + SourceIndex(0) +2 >Emitted(8, 18) Source(2, 19) + SourceIndex(0) +3 >Emitted(8, 26) Source(4, 2) + SourceIndex(0) +4 >Emitted(8, 27) Source(4, 2) + SourceIndex(0) +--- +>>> exports.m1_instance1 = new m1_c1(); +1->^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^ +3 > ^^^ +4 > ^^^^ +5 > ^^^^^ +6 > ^^ +7 > ^ +1-> + > + >export var +2 > m1_instance1 +3 > = +4 > new +5 > m1_c1 +6 > () +7 > ; +1->Emitted(9, 5) Source(6, 12) + SourceIndex(0) +2 >Emitted(9, 25) Source(6, 24) + SourceIndex(0) +3 >Emitted(9, 28) Source(6, 27) + SourceIndex(0) +4 >Emitted(9, 32) Source(6, 31) + SourceIndex(0) +5 >Emitted(9, 37) Source(6, 36) + SourceIndex(0) +6 >Emitted(9, 39) Source(6, 38) + SourceIndex(0) +7 >Emitted(9, 40) Source(6, 39) + SourceIndex(0) +--- +>>> function m1_f1() { +1 >^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +1 > + > +1 >Emitted(10, 5) Source(7, 1) + SourceIndex(0) +--- +>>> return exports.m1_instance1; +1->^^^^^^^^ +2 > ^^^^^^ +3 > ^ +4 > ^^^^^^^^^^^^^^^^^^^^ +5 > ^ +1->export function m1_f1() { + > +2 > return +3 > +4 > m1_instance1 +5 > ; +1->Emitted(11, 9) Source(8, 5) + SourceIndex(0) name (m1_f1) +2 >Emitted(11, 15) Source(8, 11) + SourceIndex(0) name (m1_f1) +3 >Emitted(11, 16) Source(8, 12) + SourceIndex(0) name (m1_f1) +4 >Emitted(11, 36) Source(8, 24) + SourceIndex(0) name (m1_f1) +5 >Emitted(11, 37) Source(8, 25) + SourceIndex(0) name (m1_f1) +--- +>>> } +1 >^^^^ +2 > ^ +3 > ^^^^^^^^^^^^^^^^^^^^^^-> +1 > + > +2 > } +1 >Emitted(12, 5) Source(9, 1) + SourceIndex(0) name (m1_f1) +2 >Emitted(12, 6) Source(9, 2) + SourceIndex(0) name (m1_f1) +--- +>>> exports.m1_f1 = m1_f1; +1->^^^^ +2 > ^^^^^^^^^^^^^ +3 > ^^^^^^^^ +4 > ^ +1-> +2 > m1_f1 +3 > () { + > return m1_instance1; + > } +4 > +1->Emitted(13, 5) Source(7, 17) + SourceIndex(0) +2 >Emitted(13, 18) Source(7, 22) + SourceIndex(0) +3 >Emitted(13, 26) Source(9, 2) + SourceIndex(0) +4 >Emitted(13, 27) Source(9, 2) + SourceIndex(0) +--- +------------------------------------------------------------------- +emittedFile:bin/test.js +sourceFile:test.ts +------------------------------------------------------------------- +>>>}); +>>>define("test", ["require", "exports", "ref/m1"], function (require, exports, m1) { +>>> exports.a1 = 10; +1 >^^^^ +2 > ^^^^^^^^^^ +3 > ^^^ +4 > ^^ +5 > ^ +6 > ^^^^^^^^-> +1 >import m1 = require("ref/m1"); + >export var +2 > a1 +3 > = +4 > 10 +5 > ; +1 >Emitted(16, 5) Source(2, 12) + SourceIndex(1) +2 >Emitted(16, 15) Source(2, 14) + SourceIndex(1) +3 >Emitted(16, 18) Source(2, 17) + SourceIndex(1) +4 >Emitted(16, 20) Source(2, 19) + SourceIndex(1) +5 >Emitted(16, 21) Source(2, 20) + SourceIndex(1) +--- +>>> var c1 = (function () { +1->^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^-> +1-> + > +1->Emitted(17, 5) Source(3, 1) + SourceIndex(1) +--- +>>> function c1() { +1->^^^^^^^^ +2 > ^^-> +1-> +1->Emitted(18, 9) Source(3, 1) + SourceIndex(1) name (c1) +--- +>>> } +1->^^^^^^^^ +2 > ^ +3 > ^^^^^^^^^^-> +1->export class c1 { + > public p1: number; + > +2 > } +1->Emitted(19, 9) Source(5, 1) + SourceIndex(1) name (c1.constructor) +2 >Emitted(19, 10) Source(5, 2) + SourceIndex(1) name (c1.constructor) +--- +>>> return c1; +1->^^^^^^^^ +2 > ^^^^^^^^^ +1-> +2 > } +1->Emitted(20, 9) Source(5, 1) + SourceIndex(1) name (c1) +2 >Emitted(20, 18) Source(5, 2) + SourceIndex(1) name (c1) +--- +>>> })(); +1 >^^^^ +2 > ^ +3 > +4 > ^^^^ +5 > ^^^^^^^^^^^^-> +1 > +2 > } +3 > +4 > export class c1 { + > public p1: number; + > } +1 >Emitted(21, 5) Source(5, 1) + SourceIndex(1) name (c1) +2 >Emitted(21, 6) Source(5, 2) + SourceIndex(1) name (c1) +3 >Emitted(21, 6) Source(3, 1) + SourceIndex(1) +4 >Emitted(21, 10) Source(5, 2) + SourceIndex(1) +--- +>>> exports.c1 = c1; +1->^^^^ +2 > ^^^^^^^^^^ +3 > ^^^^^ +4 > ^ +5 > ^^^^^^^^^^^^^^-> +1-> +2 > c1 +3 > { + > public p1: number; + > } +4 > +1->Emitted(22, 5) Source(3, 14) + SourceIndex(1) +2 >Emitted(22, 15) Source(3, 16) + SourceIndex(1) +3 >Emitted(22, 20) Source(5, 2) + SourceIndex(1) +4 >Emitted(22, 21) Source(5, 2) + SourceIndex(1) +--- +>>> exports.instance1 = new c1(); +1->^^^^ +2 > ^^^^^^^^^^^^^^^^^ +3 > ^^^ +4 > ^^^^ +5 > ^^ +6 > ^^ +7 > ^ +1-> + > + >export var +2 > instance1 +3 > = +4 > new +5 > c1 +6 > () +7 > ; +1->Emitted(23, 5) Source(7, 12) + SourceIndex(1) +2 >Emitted(23, 22) Source(7, 21) + SourceIndex(1) +3 >Emitted(23, 25) Source(7, 24) + SourceIndex(1) +4 >Emitted(23, 29) Source(7, 28) + SourceIndex(1) +5 >Emitted(23, 31) Source(7, 30) + SourceIndex(1) +6 >Emitted(23, 33) Source(7, 32) + SourceIndex(1) +7 >Emitted(23, 34) Source(7, 33) + SourceIndex(1) +--- +>>> function f1() { +1 >^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +1 > + > +1 >Emitted(24, 5) Source(8, 1) + SourceIndex(1) +--- +>>> return exports.instance1; +1->^^^^^^^^ +2 > ^^^^^^ +3 > ^ +4 > ^^^^^^^^^^^^^^^^^ +5 > ^ +1->export function f1() { + > +2 > return +3 > +4 > instance1 +5 > ; +1->Emitted(25, 9) Source(9, 5) + SourceIndex(1) name (f1) +2 >Emitted(25, 15) Source(9, 11) + SourceIndex(1) name (f1) +3 >Emitted(25, 16) Source(9, 12) + SourceIndex(1) name (f1) +4 >Emitted(25, 33) Source(9, 21) + SourceIndex(1) name (f1) +5 >Emitted(25, 34) Source(9, 22) + SourceIndex(1) name (f1) +--- +>>> } +1 >^^^^ +2 > ^ +3 > ^^^^^^^^^^^^^^^^-> +1 > + > +2 > } +1 >Emitted(26, 5) Source(10, 1) + SourceIndex(1) name (f1) +2 >Emitted(26, 6) Source(10, 2) + SourceIndex(1) name (f1) +--- +>>> exports.f1 = f1; +1->^^^^ +2 > ^^^^^^^^^^ +3 > ^^^^^ +4 > ^ +5 > ^^^^^^^-> +1-> +2 > f1 +3 > () { + > return instance1; + > } +4 > +1->Emitted(27, 5) Source(8, 17) + SourceIndex(1) +2 >Emitted(27, 15) Source(8, 19) + SourceIndex(1) +3 >Emitted(27, 20) Source(10, 2) + SourceIndex(1) +4 >Emitted(27, 21) Source(10, 2) + SourceIndex(1) +--- +>>> exports.a2 = m1.m1_c1; +1->^^^^ +2 > ^^^^^^^^^^ +3 > ^^^ +4 > ^^ +5 > ^ +6 > ^^^^^ +7 > ^ +1-> + > + >export var +2 > a2 +3 > = +4 > m1 +5 > . +6 > m1_c1 +7 > ; +1->Emitted(28, 5) Source(12, 12) + SourceIndex(1) +2 >Emitted(28, 15) Source(12, 14) + SourceIndex(1) +3 >Emitted(28, 18) Source(12, 17) + SourceIndex(1) +4 >Emitted(28, 20) Source(12, 19) + SourceIndex(1) +5 >Emitted(28, 21) Source(12, 20) + SourceIndex(1) +6 >Emitted(28, 26) Source(12, 25) + SourceIndex(1) +7 >Emitted(28, 27) Source(12, 26) + SourceIndex(1) +--- +>>>}); >>>//# sourceMappingURL=test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcerootUrlModuleSubfolderSpecifyOutputFile/node/bin/test.d.ts b/tests/baselines/reference/project/sourcerootUrlModuleSubfolderSpecifyOutputFile/node/bin/test.d.ts deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/tests/baselines/reference/project/sourcerootUrlModuleSubfolderSpecifyOutputFile/node/bin/test.js b/tests/baselines/reference/project/sourcerootUrlModuleSubfolderSpecifyOutputFile/node/bin/test.js deleted file mode 100644 index 6f3fefb9498..00000000000 --- a/tests/baselines/reference/project/sourcerootUrlModuleSubfolderSpecifyOutputFile/node/bin/test.js +++ /dev/null @@ -1 +0,0 @@ -//# sourceMappingURL=test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcerootUrlModuleSubfolderSpecifyOutputFile/node/bin/test.js.map b/tests/baselines/reference/project/sourcerootUrlModuleSubfolderSpecifyOutputFile/node/bin/test.js.map index d3e851981ec..4409af8d0a7 100644 --- a/tests/baselines/reference/project/sourcerootUrlModuleSubfolderSpecifyOutputFile/node/bin/test.js.map +++ b/tests/baselines/reference/project/sourcerootUrlModuleSubfolderSpecifyOutputFile/node/bin/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"http://typescript.codeplex.com/","sources":[],"names":[],"mappings":""} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"http://typescript.codeplex.com/","sources":["ref/m1.ts","test.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcerootUrlModuleSubfolderSpecifyOutputFile/node/sourcerootUrlModuleSubfolderSpecifyOutputFile.sourcemap.txt b/tests/baselines/reference/project/sourcerootUrlModuleSubfolderSpecifyOutputFile/node/sourcerootUrlModuleSubfolderSpecifyOutputFile.sourcemap.txt index cf41966a818..3f2ad9829b3 100644 --- a/tests/baselines/reference/project/sourcerootUrlModuleSubfolderSpecifyOutputFile/node/sourcerootUrlModuleSubfolderSpecifyOutputFile.sourcemap.txt +++ b/tests/baselines/reference/project/sourcerootUrlModuleSubfolderSpecifyOutputFile/node/sourcerootUrlModuleSubfolderSpecifyOutputFile.sourcemap.txt @@ -394,6 +394,6 @@ sourceFile:test.ts JsFile: test.js mapUrl: test.js.map sourceRoot: http://typescript.codeplex.com/ -sources: +sources: ref/m1.ts,test.ts =================================================================== >>>//# sourceMappingURL=test.js.map \ No newline at end of file From a3e7ccb108b8897f969499941403e5803cef4e75 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Fri, 2 Oct 2015 15:00:46 -0700 Subject: [PATCH 029/227] Use normalized text for text on string literal types. --- 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 9f1bf504a0e..c062398c1a9 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -1620,7 +1620,7 @@ namespace ts { writeAnonymousType(type, flags); } else if (type.flags & TypeFlags.StringLiteral) { - writer.writeStringLiteral((type).text); + writer.writeStringLiteral(`"${escapeString((type).text)}"`); } else { // Should never get here @@ -4213,12 +4213,13 @@ namespace ts { } function getStringLiteralType(node: StringLiteral): StringLiteralType { - if (hasProperty(stringLiteralTypes, node.text)) { - return stringLiteralTypes[node.text]; + const text = node.text; + if (hasProperty(stringLiteralTypes, text)) { + return stringLiteralTypes[text]; } - let type = stringLiteralTypes[node.text] = createType(TypeFlags.StringLiteral); - type.text = getTextOfNode(node); + let type = stringLiteralTypes[text] = createType(TypeFlags.StringLiteral); + type.text = text; return type; } From 20c2c4e5e53ce5c19667caf087d303530df1e432 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Fri, 2 Oct 2015 15:22:35 -0700 Subject: [PATCH 030/227] Amended fourslash tests to expect double quotes. --- .../fourslash/overloadOnConstCallSignature.ts | 2 +- .../fourslash/quickInfoForOverloadOnConst1.ts | 16 ++++++++-------- .../fourslash/signatureHelpOnOverloadOnConst.ts | 4 ++-- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/tests/cases/fourslash/overloadOnConstCallSignature.ts b/tests/cases/fourslash/overloadOnConstCallSignature.ts index d729fd4da6f..101d7750e04 100644 --- a/tests/cases/fourslash/overloadOnConstCallSignature.ts +++ b/tests/cases/fourslash/overloadOnConstCallSignature.ts @@ -11,7 +11,7 @@ goTo.marker('1'); verify.signatureHelpCountIs(4); -verify.currentSignatureHelpIs('foo(name: \'order\'): string'); +verify.currentSignatureHelpIs('foo(name: "order"): string'); edit.insert('"hi"'); goTo.marker('2'); diff --git a/tests/cases/fourslash/quickInfoForOverloadOnConst1.ts b/tests/cases/fourslash/quickInfoForOverloadOnConst1.ts index f2ee37aa675..948c2fde999 100644 --- a/tests/cases/fourslash/quickInfoForOverloadOnConst1.ts +++ b/tests/cases/fourslash/quickInfoForOverloadOnConst1.ts @@ -20,22 +20,22 @@ ////c.x1(1, (x/*10*/x) => { return 1; } ); goTo.marker('1'); -verify.quickInfoIs("(method) I.x1(a: number, callback: (x: 'hi') => number): any"); +verify.quickInfoIs("(method) I.x1(a: number, callback: (x: \"hi\") => number): any"); goTo.marker('2'); -verify.quickInfoIs("(method) C.x1(a: number, callback: (x: 'hi') => number): any"); +verify.quickInfoIs("(method) C.x1(a: number, callback: (x: \"hi\") => number): any"); goTo.marker('3'); -verify.quickInfoIs("(parameter) callback: (x: 'hi') => number"); +verify.quickInfoIs("(parameter) callback: (x: \"hi\") => number"); goTo.marker('4'); -verify.quickInfoIs("(method) C.x1(a: number, callback: (x: 'hi') => number): any"); +verify.quickInfoIs("(method) C.x1(a: number, callback: (x: \"hi\") => number): any"); goTo.marker('5'); verify.quickInfoIs('(parameter) callback: (x: string) => number'); goTo.marker('6'); verify.quickInfoIs('(parameter) callback: (x: string) => number'); goTo.marker('7'); -verify.quickInfoIs("(method) C.x1(a: number, callback: (x: 'hi') => number): any"); +verify.quickInfoIs("(method) C.x1(a: number, callback: (x: \"hi\") => number): any"); goTo.marker('8'); -verify.quickInfoIs("(parameter) xx: 'hi'"); +verify.quickInfoIs("(parameter) xx: \"hi\""); goTo.marker('9'); -verify.quickInfoIs("(parameter) xx: 'bye'"); +verify.quickInfoIs("(parameter) xx: \"bye\""); goTo.marker('10'); -verify.quickInfoIs("(parameter) xx: 'hi'"); \ No newline at end of file +verify.quickInfoIs("(parameter) xx: \"hi\""); \ No newline at end of file diff --git a/tests/cases/fourslash/signatureHelpOnOverloadOnConst.ts b/tests/cases/fourslash/signatureHelpOnOverloadOnConst.ts index 8edd0617d70..e312b71aebe 100644 --- a/tests/cases/fourslash/signatureHelpOnOverloadOnConst.ts +++ b/tests/cases/fourslash/signatureHelpOnOverloadOnConst.ts @@ -18,9 +18,9 @@ verify.currentParameterSpanIs("z: string"); goTo.marker('2'); verify.signatureHelpCountIs(3); verify.currentParameterHelpArgumentNameIs("x"); -verify.currentParameterSpanIs("x: 'hi'"); +verify.currentParameterSpanIs("x: \"hi\""); goTo.marker('3'); verify.signatureHelpCountIs(3); verify.currentParameterHelpArgumentNameIs("y"); -verify.currentParameterSpanIs("y: 'bye'"); +verify.currentParameterSpanIs("y: \"bye\""); From 87f2957e4d510637f5fcab4151561a60548944d0 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Fri, 2 Oct 2015 15:23:53 -0700 Subject: [PATCH 031/227] Accepted baselines. --- .../callSignatureFunctionOverload.types | 16 +-- .../reference/constantOverloadFunction.types | 16 +-- ...ritedOverloadedSpecializedSignatures.types | 16 +-- ...pecializedCallAndConstructSignatures.types | 4 +- .../memberFunctionsWithPublicOverloads.types | 40 +++---- .../overloadOnConstConstraintChecks1.types | 30 +++--- .../overloadOnConstConstraintChecks2.types | 12 +-- .../overloadOnConstConstraintChecks3.types | 12 +-- .../overloadOnConstInheritance1.types | 12 +-- .../overloadOnConstInheritance2.errors.txt | 4 +- .../overloadOnConstInheritance3.errors.txt | 4 +- .../reference/primtiveTypesAreIdentical.types | 12 +-- .../specializedSignatureInInterface.types | 4 +- ...reIsSubtypeOfNonSpecializedSignature.types | 102 +++++++++--------- .../reference/stringLiteralType.types | 10 +- .../stringLiteralTypesOverloads01.errors.txt | 4 +- .../stringLiteralTypesOverloads01.js | 6 +- ...aturesWithSpecializedSignatures.errors.txt | 4 +- ...aturesWithSpecializedSignatures.errors.txt | 4 +- .../typesWithSpecializedCallSignatures.types | 58 +++++----- ...esWithSpecializedConstructSignatures.types | 26 ++--- 21 files changed, 198 insertions(+), 198 deletions(-) diff --git a/tests/baselines/reference/callSignatureFunctionOverload.types b/tests/baselines/reference/callSignatureFunctionOverload.types index b9788e5b143..d5897c01494 100644 --- a/tests/baselines/reference/callSignatureFunctionOverload.types +++ b/tests/baselines/reference/callSignatureFunctionOverload.types @@ -1,33 +1,33 @@ === tests/cases/compiler/callSignatureFunctionOverload.ts === var foo: { ->foo : { (name: string): string; (name: 'order'): string; (name: 'content'): string; (name: 'done'): string; } +>foo : { (name: string): string; (name: "order"): string; (name: "content"): string; (name: "done"): string; } (name: string): string; >name : string (name: 'order'): string; ->name : 'order' +>name : "order" (name: 'content'): string; ->name : 'content' +>name : "content" (name: 'done'): string; ->name : 'done' +>name : "done" } var foo2: { ->foo2 : { (name: string): string; (name: 'order'): string; (name: 'order'): string; (name: 'done'): string; } +>foo2 : { (name: string): string; (name: "order"): string; (name: "order"): string; (name: "done"): string; } (name: string): string; >name : string (name: 'order'): string; ->name : 'order' +>name : "order" (name: 'order'): string; ->name : 'order' +>name : "order" (name: 'done'): string; ->name : 'done' +>name : "done" } diff --git a/tests/baselines/reference/constantOverloadFunction.types b/tests/baselines/reference/constantOverloadFunction.types index d643d3a726d..d7deaaae46d 100644 --- a/tests/baselines/reference/constantOverloadFunction.types +++ b/tests/baselines/reference/constantOverloadFunction.types @@ -19,27 +19,27 @@ class Derived3 extends Base { biz() { } } >biz : () => void function foo(tagName: 'canvas'): Derived1; ->foo : { (tagName: 'canvas'): Derived1; (tagName: 'div'): Derived2; (tagName: 'span'): Derived3; (tagName: string): Base; } ->tagName : 'canvas' +>foo : { (tagName: "canvas"): Derived1; (tagName: "div"): Derived2; (tagName: "span"): Derived3; (tagName: string): Base; } +>tagName : "canvas" >Derived1 : Derived1 function foo(tagName: 'div'): Derived2; ->foo : { (tagName: 'canvas'): Derived1; (tagName: 'div'): Derived2; (tagName: 'span'): Derived3; (tagName: string): Base; } ->tagName : 'div' +>foo : { (tagName: "canvas"): Derived1; (tagName: "div"): Derived2; (tagName: "span"): Derived3; (tagName: string): Base; } +>tagName : "div" >Derived2 : Derived2 function foo(tagName: 'span'): Derived3; ->foo : { (tagName: 'canvas'): Derived1; (tagName: 'div'): Derived2; (tagName: 'span'): Derived3; (tagName: string): Base; } ->tagName : 'span' +>foo : { (tagName: "canvas"): Derived1; (tagName: "div"): Derived2; (tagName: "span"): Derived3; (tagName: string): Base; } +>tagName : "span" >Derived3 : Derived3 function foo(tagName: string): Base; ->foo : { (tagName: 'canvas'): Derived1; (tagName: 'div'): Derived2; (tagName: 'span'): Derived3; (tagName: string): Base; } +>foo : { (tagName: "canvas"): Derived1; (tagName: "div"): Derived2; (tagName: "span"): Derived3; (tagName: string): Base; } >tagName : string >Base : Base function foo(tagName: any): Base { ->foo : { (tagName: 'canvas'): Derived1; (tagName: 'div'): Derived2; (tagName: 'span'): Derived3; (tagName: string): Base; } +>foo : { (tagName: "canvas"): Derived1; (tagName: "div"): Derived2; (tagName: "span"): Derived3; (tagName: string): Base; } >tagName : any >Base : Base diff --git a/tests/baselines/reference/inheritedOverloadedSpecializedSignatures.types b/tests/baselines/reference/inheritedOverloadedSpecializedSignatures.types index dc8b9b465d8..0ec428bb159 100644 --- a/tests/baselines/reference/inheritedOverloadedSpecializedSignatures.types +++ b/tests/baselines/reference/inheritedOverloadedSpecializedSignatures.types @@ -11,7 +11,7 @@ interface B extends A { >A : A (key:'foo'):string; ->key : 'foo' +>key : "foo" } var b:B; @@ -32,7 +32,7 @@ interface A { >A : A (x: 'A1'): string; ->x : 'A1' +>x : "A1" (x: string): void; >x : string @@ -43,21 +43,21 @@ interface B extends A { >A : A (x: 'B1'): number; ->x : 'B1' +>x : "B1" } interface A { >A : A (x: 'A2'): boolean; ->x : 'A2' +>x : "A2" } interface B { >B : B (x: 'B2'): string[]; ->x : 'B2' +>x : "B2" } interface C1 extends B { @@ -65,7 +65,7 @@ interface C1 extends B { >B : B (x: 'C1'): number[]; ->x : 'C1' +>x : "C1" } interface C2 extends B { @@ -73,7 +73,7 @@ interface C2 extends B { >B : B (x: 'C2'): boolean[]; ->x : 'C2' +>x : "C2" } interface C extends C1, C2 { @@ -82,7 +82,7 @@ interface C extends C1, C2 { >C2 : C2 (x: 'C'): string; ->x : 'C' +>x : "C" } var c: C; diff --git a/tests/baselines/reference/interfaceWithSpecializedCallAndConstructSignatures.types b/tests/baselines/reference/interfaceWithSpecializedCallAndConstructSignatures.types index 971b5e56907..7b19fd5889b 100644 --- a/tests/baselines/reference/interfaceWithSpecializedCallAndConstructSignatures.types +++ b/tests/baselines/reference/interfaceWithSpecializedCallAndConstructSignatures.types @@ -3,13 +3,13 @@ interface Foo { >Foo : Foo (x: 'a'): number; ->x : 'a' +>x : "a" (x: string): any; >x : string new (x: 'a'): any; ->x : 'a' +>x : "a" new (x: string): Object; >x : string diff --git a/tests/baselines/reference/memberFunctionsWithPublicOverloads.types b/tests/baselines/reference/memberFunctionsWithPublicOverloads.types index 7cbc2aca1ff..bcd937e9cfc 100644 --- a/tests/baselines/reference/memberFunctionsWithPublicOverloads.types +++ b/tests/baselines/reference/memberFunctionsWithPublicOverloads.types @@ -17,20 +17,20 @@ class C { >y : any public bar(x: 'hi'); ->bar : { (x: 'hi'): any; (x: string): any; (x: number, y: string): any; } ->x : 'hi' +>bar : { (x: "hi"): any; (x: string): any; (x: number, y: string): any; } +>x : "hi" public bar(x: string); ->bar : { (x: 'hi'): any; (x: string): any; (x: number, y: string): any; } +>bar : { (x: "hi"): any; (x: string): any; (x: number, y: string): any; } >x : string public bar(x: number, y: string); ->bar : { (x: 'hi'): any; (x: string): any; (x: number, y: string): any; } +>bar : { (x: "hi"): any; (x: string): any; (x: number, y: string): any; } >x : number >y : string public bar(x: any, y?: any) { } ->bar : { (x: 'hi'): any; (x: string): any; (x: number, y: string): any; } +>bar : { (x: "hi"): any; (x: string): any; (x: number, y: string): any; } >x : any >y : any @@ -49,20 +49,20 @@ class C { >y : any public static bar(x: 'hi'); ->bar : { (x: 'hi'): any; (x: string): any; (x: number, y: string): any; } ->x : 'hi' +>bar : { (x: "hi"): any; (x: string): any; (x: number, y: string): any; } +>x : "hi" public static bar(x: string); ->bar : { (x: 'hi'): any; (x: string): any; (x: number, y: string): any; } +>bar : { (x: "hi"): any; (x: string): any; (x: number, y: string): any; } >x : string public static bar(x: number, y: string); ->bar : { (x: 'hi'): any; (x: string): any; (x: number, y: string): any; } +>bar : { (x: "hi"): any; (x: string): any; (x: number, y: string): any; } >x : number >y : string public static bar(x: any, y?: any) { } ->bar : { (x: 'hi'): any; (x: string): any; (x: number, y: string): any; } +>bar : { (x: "hi"): any; (x: string): any; (x: number, y: string): any; } >x : any >y : any } @@ -88,22 +88,22 @@ class D { >y : any public bar(x: 'hi'); ->bar : { (x: 'hi'): any; (x: string): any; (x: T, y: T): any; } ->x : 'hi' +>bar : { (x: "hi"): any; (x: string): any; (x: T, y: T): any; } +>x : "hi" public bar(x: string); ->bar : { (x: 'hi'): any; (x: string): any; (x: T, y: T): any; } +>bar : { (x: "hi"): any; (x: string): any; (x: T, y: T): any; } >x : string public bar(x: T, y: T); ->bar : { (x: 'hi'): any; (x: string): any; (x: T, y: T): any; } +>bar : { (x: "hi"): any; (x: string): any; (x: T, y: T): any; } >x : T >T : T >y : T >T : T public bar(x: any, y?: any) { } ->bar : { (x: 'hi'): any; (x: string): any; (x: T, y: T): any; } +>bar : { (x: "hi"): any; (x: string): any; (x: T, y: T): any; } >x : any >y : any @@ -122,20 +122,20 @@ class D { >y : any public static bar(x: 'hi'); ->bar : { (x: 'hi'): any; (x: string): any; (x: number, y: string): any; } ->x : 'hi' +>bar : { (x: "hi"): any; (x: string): any; (x: number, y: string): any; } +>x : "hi" public static bar(x: string); ->bar : { (x: 'hi'): any; (x: string): any; (x: number, y: string): any; } +>bar : { (x: "hi"): any; (x: string): any; (x: number, y: string): any; } >x : string public static bar(x: number, y: string); ->bar : { (x: 'hi'): any; (x: string): any; (x: number, y: string): any; } +>bar : { (x: "hi"): any; (x: string): any; (x: number, y: string): any; } >x : number >y : string public static bar(x: any, y?: any) { } ->bar : { (x: 'hi'): any; (x: string): any; (x: number, y: string): any; } +>bar : { (x: "hi"): any; (x: string): any; (x: number, y: string): any; } >x : any >y : any diff --git a/tests/baselines/reference/overloadOnConstConstraintChecks1.types b/tests/baselines/reference/overloadOnConstConstraintChecks1.types index cc561eb6e21..012774b3cc9 100644 --- a/tests/baselines/reference/overloadOnConstConstraintChecks1.types +++ b/tests/baselines/reference/overloadOnConstConstraintChecks1.types @@ -22,23 +22,23 @@ interface MyDoc { // Document >MyDoc : MyDoc createElement(tagName: string): Base; ->createElement : { (tagName: string): Base; (tagName: 'canvas'): Derived1; (tagName: 'div'): Derived2; (tagName: 'span'): Derived3; } +>createElement : { (tagName: string): Base; (tagName: "canvas"): Derived1; (tagName: "div"): Derived2; (tagName: "span"): Derived3; } >tagName : string >Base : Base createElement(tagName: 'canvas'): Derived1; ->createElement : { (tagName: string): Base; (tagName: 'canvas'): Derived1; (tagName: 'div'): Derived2; (tagName: 'span'): Derived3; } ->tagName : 'canvas' +>createElement : { (tagName: string): Base; (tagName: "canvas"): Derived1; (tagName: "div"): Derived2; (tagName: "span"): Derived3; } +>tagName : "canvas" >Derived1 : Derived1 createElement(tagName: 'div'): Derived2; ->createElement : { (tagName: string): Base; (tagName: 'canvas'): Derived1; (tagName: 'div'): Derived2; (tagName: 'span'): Derived3; } ->tagName : 'div' +>createElement : { (tagName: string): Base; (tagName: "canvas"): Derived1; (tagName: "div"): Derived2; (tagName: "span"): Derived3; } +>tagName : "div" >Derived2 : Derived2 createElement(tagName: 'span'): Derived3; ->createElement : { (tagName: string): Base; (tagName: 'canvas'): Derived1; (tagName: 'div'): Derived2; (tagName: 'span'): Derived3; } ->tagName : 'span' +>createElement : { (tagName: string): Base; (tagName: "canvas"): Derived1; (tagName: "div"): Derived2; (tagName: "span"): Derived3; } +>tagName : "span" >Derived3 : Derived3 // + 100 more @@ -49,27 +49,27 @@ class D implements MyDoc { >MyDoc : MyDoc createElement(tagName:string): Base; ->createElement : { (tagName: string): Base; (tagName: 'canvas'): Derived1; (tagName: 'div'): Derived2; (tagName: 'span'): Derived3; } +>createElement : { (tagName: string): Base; (tagName: "canvas"): Derived1; (tagName: "div"): Derived2; (tagName: "span"): Derived3; } >tagName : string >Base : Base createElement(tagName: 'canvas'): Derived1; ->createElement : { (tagName: string): Base; (tagName: 'canvas'): Derived1; (tagName: 'div'): Derived2; (tagName: 'span'): Derived3; } ->tagName : 'canvas' +>createElement : { (tagName: string): Base; (tagName: "canvas"): Derived1; (tagName: "div"): Derived2; (tagName: "span"): Derived3; } +>tagName : "canvas" >Derived1 : Derived1 createElement(tagName: 'div'): Derived2; ->createElement : { (tagName: string): Base; (tagName: 'canvas'): Derived1; (tagName: 'div'): Derived2; (tagName: 'span'): Derived3; } ->tagName : 'div' +>createElement : { (tagName: string): Base; (tagName: "canvas"): Derived1; (tagName: "div"): Derived2; (tagName: "span"): Derived3; } +>tagName : "div" >Derived2 : Derived2 createElement(tagName: 'span'): Derived3; ->createElement : { (tagName: string): Base; (tagName: 'canvas'): Derived1; (tagName: 'div'): Derived2; (tagName: 'span'): Derived3; } ->tagName : 'span' +>createElement : { (tagName: string): Base; (tagName: "canvas"): Derived1; (tagName: "div"): Derived2; (tagName: "span"): Derived3; } +>tagName : "span" >Derived3 : Derived3 createElement(tagName:any): Base { ->createElement : { (tagName: string): Base; (tagName: 'canvas'): Derived1; (tagName: 'div'): Derived2; (tagName: 'span'): Derived3; } +>createElement : { (tagName: string): Base; (tagName: "canvas"): Derived1; (tagName: "div"): Derived2; (tagName: "span"): Derived3; } >tagName : any >Base : Base diff --git a/tests/baselines/reference/overloadOnConstConstraintChecks2.types b/tests/baselines/reference/overloadOnConstConstraintChecks2.types index 36fa89dec4a..6102c282a60 100644 --- a/tests/baselines/reference/overloadOnConstConstraintChecks2.types +++ b/tests/baselines/reference/overloadOnConstConstraintChecks2.types @@ -14,22 +14,22 @@ class C extends A { >foo : () => void } function foo(name: 'hi'): B; ->foo : { (name: 'hi'): B; (name: 'bye'): C; (name: string): A; } ->name : 'hi' +>foo : { (name: "hi"): B; (name: "bye"): C; (name: string): A; } +>name : "hi" >B : B function foo(name: 'bye'): C; ->foo : { (name: 'hi'): B; (name: 'bye'): C; (name: string): A; } ->name : 'bye' +>foo : { (name: "hi"): B; (name: "bye"): C; (name: string): A; } +>name : "bye" >C : C function foo(name: string): A; ->foo : { (name: 'hi'): B; (name: 'bye'): C; (name: string): A; } +>foo : { (name: "hi"): B; (name: "bye"): C; (name: string): A; } >name : string >A : A function foo(name: any): A { ->foo : { (name: 'hi'): B; (name: 'bye'): C; (name: string): A; } +>foo : { (name: "hi"): B; (name: "bye"): C; (name: string): A; } >name : any >A : A diff --git a/tests/baselines/reference/overloadOnConstConstraintChecks3.types b/tests/baselines/reference/overloadOnConstConstraintChecks3.types index 94a03bb7680..0348d3d4b79 100644 --- a/tests/baselines/reference/overloadOnConstConstraintChecks3.types +++ b/tests/baselines/reference/overloadOnConstConstraintChecks3.types @@ -16,22 +16,22 @@ class C extends A { >foo : () => void } function foo(name: 'hi'): B; ->foo : { (name: 'hi'): B; (name: 'bye'): C; (name: string): A; } ->name : 'hi' +>foo : { (name: "hi"): B; (name: "bye"): C; (name: string): A; } +>name : "hi" >B : B function foo(name: 'bye'): C; ->foo : { (name: 'hi'): B; (name: 'bye'): C; (name: string): A; } ->name : 'bye' +>foo : { (name: "hi"): B; (name: "bye"): C; (name: string): A; } +>name : "bye" >C : C function foo(name: string): A; ->foo : { (name: 'hi'): B; (name: 'bye'): C; (name: string): A; } +>foo : { (name: "hi"): B; (name: "bye"): C; (name: string): A; } >name : string >A : A function foo(name: any): A { ->foo : { (name: 'hi'): B; (name: 'bye'): C; (name: string): A; } +>foo : { (name: "hi"): B; (name: "bye"): C; (name: string): A; } >name : any >A : A diff --git a/tests/baselines/reference/overloadOnConstInheritance1.types b/tests/baselines/reference/overloadOnConstInheritance1.types index 96f8df3dffd..4721c18e55c 100644 --- a/tests/baselines/reference/overloadOnConstInheritance1.types +++ b/tests/baselines/reference/overloadOnConstInheritance1.types @@ -3,23 +3,23 @@ interface Base { >Base : Base addEventListener(x: string): any; ->addEventListener : { (x: string): any; (x: 'foo'): string; } +>addEventListener : { (x: string): any; (x: "foo"): string; } >x : string addEventListener(x: 'foo'): string; ->addEventListener : { (x: string): any; (x: 'foo'): string; } ->x : 'foo' +>addEventListener : { (x: string): any; (x: "foo"): string; } +>x : "foo" } interface Deriver extends Base { >Deriver : Deriver >Base : Base addEventListener(x: string): any; ->addEventListener : { (x: string): any; (x: 'bar'): string; } +>addEventListener : { (x: string): any; (x: "bar"): string; } >x : string addEventListener(x: 'bar'): string; ->addEventListener : { (x: string): any; (x: 'bar'): string; } ->x : 'bar' +>addEventListener : { (x: string): any; (x: "bar"): string; } +>x : "bar" } diff --git a/tests/baselines/reference/overloadOnConstInheritance2.errors.txt b/tests/baselines/reference/overloadOnConstInheritance2.errors.txt index 159af64a13a..4870106f474 100644 --- a/tests/baselines/reference/overloadOnConstInheritance2.errors.txt +++ b/tests/baselines/reference/overloadOnConstInheritance2.errors.txt @@ -1,6 +1,6 @@ tests/cases/compiler/overloadOnConstInheritance2.ts(5,11): error TS2430: Interface 'Deriver' incorrectly extends interface 'Base'. Types of property 'addEventListener' are incompatible. - Type '(x: 'bar') => string' is not assignable to type '{ (x: string): any; (x: 'foo'): string; }'. + Type '(x: "bar") => string' is not assignable to type '{ (x: string): any; (x: "foo"): string; }'. tests/cases/compiler/overloadOnConstInheritance2.ts(6,5): error TS2382: Specialized overload signature is not assignable to any non-specialized signature. @@ -13,7 +13,7 @@ tests/cases/compiler/overloadOnConstInheritance2.ts(6,5): error TS2382: Speciali ~~~~~~~ !!! error TS2430: Interface 'Deriver' incorrectly extends interface 'Base'. !!! error TS2430: Types of property 'addEventListener' are incompatible. -!!! error TS2430: Type '(x: 'bar') => string' is not assignable to type '{ (x: string): any; (x: 'foo'): string; }'. +!!! error TS2430: Type '(x: "bar") => string' is not assignable to type '{ (x: string): any; (x: "foo"): string; }'. addEventListener(x: 'bar'): string; // shouldn't need to redeclare the string overload ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS2382: Specialized overload signature is not assignable to any non-specialized signature. diff --git a/tests/baselines/reference/overloadOnConstInheritance3.errors.txt b/tests/baselines/reference/overloadOnConstInheritance3.errors.txt index e0fff7b1ec7..b338f9795d7 100644 --- a/tests/baselines/reference/overloadOnConstInheritance3.errors.txt +++ b/tests/baselines/reference/overloadOnConstInheritance3.errors.txt @@ -1,6 +1,6 @@ tests/cases/compiler/overloadOnConstInheritance3.ts(4,11): error TS2430: Interface 'Deriver' incorrectly extends interface 'Base'. Types of property 'addEventListener' are incompatible. - Type '{ (x: 'bar'): string; (x: 'foo'): string; }' is not assignable to type '(x: string) => any'. + Type '{ (x: "bar"): string; (x: "foo"): string; }' is not assignable to type '(x: string) => any'. tests/cases/compiler/overloadOnConstInheritance3.ts(6,5): error TS2382: Specialized overload signature is not assignable to any non-specialized signature. tests/cases/compiler/overloadOnConstInheritance3.ts(7,5): error TS2382: Specialized overload signature is not assignable to any non-specialized signature. @@ -13,7 +13,7 @@ tests/cases/compiler/overloadOnConstInheritance3.ts(7,5): error TS2382: Speciali ~~~~~~~ !!! error TS2430: Interface 'Deriver' incorrectly extends interface 'Base'. !!! error TS2430: Types of property 'addEventListener' are incompatible. -!!! error TS2430: Type '{ (x: 'bar'): string; (x: 'foo'): string; }' is not assignable to type '(x: string) => any'. +!!! error TS2430: Type '{ (x: "bar"): string; (x: "foo"): string; }' is not assignable to type '(x: string) => any'. // shouldn't need to redeclare the string overload addEventListener(x: 'bar'): string; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/tests/baselines/reference/primtiveTypesAreIdentical.types b/tests/baselines/reference/primtiveTypesAreIdentical.types index bbff4623f0b..0b8e7dadf7d 100644 --- a/tests/baselines/reference/primtiveTypesAreIdentical.types +++ b/tests/baselines/reference/primtiveTypesAreIdentical.types @@ -50,19 +50,19 @@ function foo4(x: any) { } >x : any function foo5(x: 'a'); ->foo5 : { (x: 'a'): any; (x: 'a'): any; (x: string): any; } ->x : 'a' +>foo5 : { (x: "a"): any; (x: "a"): any; (x: string): any; } +>x : "a" function foo5(x: 'a'); ->foo5 : { (x: 'a'): any; (x: 'a'): any; (x: string): any; } ->x : 'a' +>foo5 : { (x: "a"): any; (x: "a"): any; (x: string): any; } +>x : "a" function foo5(x: string); ->foo5 : { (x: 'a'): any; (x: 'a'): any; (x: string): any; } +>foo5 : { (x: "a"): any; (x: "a"): any; (x: string): any; } >x : string function foo5(x: any) { } ->foo5 : { (x: 'a'): any; (x: 'a'): any; (x: string): any; } +>foo5 : { (x: "a"): any; (x: "a"): any; (x: string): any; } >x : any enum E { A } diff --git a/tests/baselines/reference/specializedSignatureInInterface.types b/tests/baselines/reference/specializedSignatureInInterface.types index c8f76f4cb9b..b9621af7b8b 100644 --- a/tests/baselines/reference/specializedSignatureInInterface.types +++ b/tests/baselines/reference/specializedSignatureInInterface.types @@ -11,8 +11,8 @@ interface B extends A { >A : A (key:'foo'):string; ->key : 'foo' +>key : "foo" (key:'bar'):string; ->key : 'bar' +>key : "bar" } diff --git a/tests/baselines/reference/specializedSignatureIsSubtypeOfNonSpecializedSignature.types b/tests/baselines/reference/specializedSignatureIsSubtypeOfNonSpecializedSignature.types index cb86966d65a..b27a935ced6 100644 --- a/tests/baselines/reference/specializedSignatureIsSubtypeOfNonSpecializedSignature.types +++ b/tests/baselines/reference/specializedSignatureIsSubtypeOfNonSpecializedSignature.types @@ -3,30 +3,30 @@ // All the below should not be errors function foo(x: 'a'); ->foo : { (x: 'a'): any; (x: string): any; } ->x : 'a' +>foo : { (x: "a"): any; (x: string): any; } +>x : "a" function foo(x: string); ->foo : { (x: 'a'): any; (x: string): any; } +>foo : { (x: "a"): any; (x: string): any; } >x : string function foo(x: any) { } ->foo : { (x: 'a'): any; (x: string): any; } +>foo : { (x: "a"): any; (x: string): any; } >x : any class C { >C : C foo(x: 'a'); ->foo : { (x: 'a'): any; (x: string): any; } ->x : 'a' +>foo : { (x: "a"): any; (x: string): any; } +>x : "a" foo(x: string); ->foo : { (x: 'a'): any; (x: string): any; } +>foo : { (x: "a"): any; (x: string): any; } >x : string foo(x: any) { } ->foo : { (x: 'a'): any; (x: string): any; } +>foo : { (x: "a"): any; (x: string): any; } >x : any } @@ -35,20 +35,20 @@ class C2 { >T : T foo(x: 'a'); ->foo : { (x: 'a'): any; (x: string): any; (x: T): any; } ->x : 'a' +>foo : { (x: "a"): any; (x: string): any; (x: T): any; } +>x : "a" foo(x: string); ->foo : { (x: 'a'): any; (x: string): any; (x: T): any; } +>foo : { (x: "a"): any; (x: string): any; (x: T): any; } >x : string foo(x: T); ->foo : { (x: 'a'): any; (x: string): any; (x: T): any; } +>foo : { (x: "a"): any; (x: string): any; (x: T): any; } >x : T >T : T foo(x: any) { } ->foo : { (x: 'a'): any; (x: string): any; (x: T): any; } +>foo : { (x: "a"): any; (x: string): any; (x: T): any; } >x : any } @@ -58,20 +58,20 @@ class C3 { >String : String foo(x: 'a'); ->foo : { (x: 'a'): any; (x: string): any; (x: T): any; } ->x : 'a' +>foo : { (x: "a"): any; (x: string): any; (x: T): any; } +>x : "a" foo(x: string); ->foo : { (x: 'a'): any; (x: string): any; (x: T): any; } +>foo : { (x: "a"): any; (x: string): any; (x: T): any; } >x : string foo(x: T); ->foo : { (x: 'a'): any; (x: string): any; (x: T): any; } +>foo : { (x: "a"): any; (x: string): any; (x: T): any; } >x : T >T : T foo(x: any) { } ->foo : { (x: 'a'): any; (x: string): any; (x: T): any; } +>foo : { (x: "a"): any; (x: string): any; (x: T): any; } >x : any } @@ -79,7 +79,7 @@ interface I { >I : I (x: 'a'); ->x : 'a' +>x : "a" (x: number); >x : number @@ -88,15 +88,15 @@ interface I { >x : string foo(x: 'a'); ->foo : { (x: 'a'): any; (x: string): any; (x: number): any; } ->x : 'a' +>foo : { (x: "a"): any; (x: string): any; (x: number): any; } +>x : "a" foo(x: string); ->foo : { (x: 'a'): any; (x: string): any; (x: number): any; } +>foo : { (x: "a"): any; (x: string): any; (x: number): any; } >x : string foo(x: number); ->foo : { (x: 'a'): any; (x: string): any; (x: number): any; } +>foo : { (x: "a"): any; (x: string): any; (x: number): any; } >x : number } @@ -105,7 +105,7 @@ interface I2 { >T : T (x: 'a'); ->x : 'a' +>x : "a" (x: T); >x : T @@ -115,15 +115,15 @@ interface I2 { >x : string foo(x: 'a'); ->foo : { (x: 'a'): any; (x: string): any; (x: T): any; } ->x : 'a' +>foo : { (x: "a"): any; (x: string): any; (x: T): any; } +>x : "a" foo(x: string); ->foo : { (x: 'a'): any; (x: string): any; (x: T): any; } +>foo : { (x: "a"): any; (x: string): any; (x: T): any; } >x : string foo(x: T); ->foo : { (x: 'a'): any; (x: string): any; (x: T): any; } +>foo : { (x: "a"): any; (x: string): any; (x: T): any; } >x : T >T : T } @@ -134,7 +134,7 @@ interface I3 { >String : String (x: 'a'); ->x : 'a' +>x : "a" (x: string); >x : string @@ -144,49 +144,49 @@ interface I3 { >T : T foo(x: 'a'); ->foo : { (x: 'a'): any; (x: string): any; (x: T): any; } ->x : 'a' +>foo : { (x: "a"): any; (x: string): any; (x: T): any; } +>x : "a" foo(x: string); ->foo : { (x: 'a'): any; (x: string): any; (x: T): any; } +>foo : { (x: "a"): any; (x: string): any; (x: T): any; } >x : string foo(x: T); ->foo : { (x: 'a'): any; (x: string): any; (x: T): any; } +>foo : { (x: "a"): any; (x: string): any; (x: T): any; } >x : T >T : T } var a: { ->a : { (x: string): any; (x: 'a'): any; (x: number): any; foo(x: string): any; foo(x: 'a'): any; foo(x: number): any; } +>a : { (x: string): any; (x: "a"): any; (x: number): any; foo(x: string): any; foo(x: "a"): any; foo(x: number): any; } (x: string); >x : string (x: 'a'); ->x : 'a' +>x : "a" (x: number); >x : number foo(x: string); ->foo : { (x: string): any; (x: 'a'): any; (x: number): any; } +>foo : { (x: string): any; (x: "a"): any; (x: number): any; } >x : string foo(x: 'a'); ->foo : { (x: string): any; (x: 'a'): any; (x: number): any; } ->x : 'a' +>foo : { (x: string): any; (x: "a"): any; (x: number): any; } +>x : "a" foo(x: number); ->foo : { (x: string): any; (x: 'a'): any; (x: number): any; } +>foo : { (x: string): any; (x: "a"): any; (x: number): any; } >x : number } var a2: { ->a2 : { (x: 'a'): any; (x: string): any; (x: T): any; foo(x: string): any; foo(x: 'a'): any; foo(x: T): any; } +>a2 : { (x: "a"): any; (x: string): any; (x: T): any; foo(x: string): any; foo(x: "a"): any; foo(x: T): any; } (x: 'a'); ->x : 'a' +>x : "a" (x: string); >x : string @@ -197,25 +197,25 @@ var a2: { >T : T foo(x: string); ->foo : { (x: string): any; (x: 'a'): any; (x: T): any; } +>foo : { (x: string): any; (x: "a"): any; (x: T): any; } >x : string foo(x: 'a'); ->foo : { (x: string): any; (x: 'a'): any; (x: T): any; } ->x : 'a' +>foo : { (x: string): any; (x: "a"): any; (x: T): any; } +>x : "a" foo(x: T); ->foo : { (x: string): any; (x: 'a'): any; (x: T): any; } +>foo : { (x: string): any; (x: "a"): any; (x: T): any; } >T : T >x : T >T : T } var a3: { ->a3 : { (x: 'a'): any; (x: T): any; (x: string): any; foo(x: string): any; foo(x: 'a'): any; foo(x: T): any; } +>a3 : { (x: "a"): any; (x: T): any; (x: string): any; foo(x: string): any; foo(x: "a"): any; foo(x: T): any; } (x: 'a'); ->x : 'a' +>x : "a" (x: T); >T : T @@ -226,15 +226,15 @@ var a3: { >x : string foo(x: string); ->foo : { (x: string): any; (x: 'a'): any; (x: T): any; } +>foo : { (x: string): any; (x: "a"): any; (x: T): any; } >x : string foo(x: 'a'); ->foo : { (x: string): any; (x: 'a'): any; (x: T): any; } ->x : 'a' +>foo : { (x: string): any; (x: "a"): any; (x: T): any; } +>x : "a" foo(x: T); ->foo : { (x: string): any; (x: 'a'): any; (x: T): any; } +>foo : { (x: string): any; (x: "a"): any; (x: T): any; } >T : T >String : String >x : T diff --git a/tests/baselines/reference/stringLiteralType.types b/tests/baselines/reference/stringLiteralType.types index 5d2e13c4ba5..affa995c2f3 100644 --- a/tests/baselines/reference/stringLiteralType.types +++ b/tests/baselines/reference/stringLiteralType.types @@ -1,16 +1,16 @@ === tests/cases/conformance/types/primitives/stringLiteral/stringLiteralType.ts === var x: 'hi'; ->x : 'hi' +>x : "hi" function f(x: 'hi'); ->f : { (x: 'hi'): any; (x: string): any; } ->x : 'hi' +>f : { (x: "hi"): any; (x: string): any; } +>x : "hi" function f(x: string); ->f : { (x: 'hi'): any; (x: string): any; } +>f : { (x: "hi"): any; (x: string): any; } >x : string function f(x: any) { ->f : { (x: 'hi'): any; (x: string): any; } +>f : { (x: "hi"): any; (x: string): any; } >x : any } diff --git a/tests/baselines/reference/stringLiteralTypesOverloads01.errors.txt b/tests/baselines/reference/stringLiteralTypesOverloads01.errors.txt index 378857dc277..6e0fd982638 100644 --- a/tests/baselines/reference/stringLiteralTypesOverloads01.errors.txt +++ b/tests/baselines/reference/stringLiteralTypesOverloads01.errors.txt @@ -1,6 +1,6 @@ tests/cases/conformance/types/stringLiteral/stringLiteralTypesOverloads01.ts(11,10): error TS2354: No best common type exists among return expressions. tests/cases/conformance/types/stringLiteral/stringLiteralTypesOverloads01.ts(32,7): error TS2322: Type 'string' is not assignable to type '"string"'. -tests/cases/conformance/types/stringLiteral/stringLiteralTypesOverloads01.ts(33,7): error TS2322: Type 'string' is not assignable to type ''number''. +tests/cases/conformance/types/stringLiteral/stringLiteralTypesOverloads01.ts(33,7): error TS2322: Type 'string' is not assignable to type '"number"'. tests/cases/conformance/types/stringLiteral/stringLiteralTypesOverloads01.ts(34,7): error TS2322: Type 'string' is not assignable to type '"boolean"'. @@ -43,7 +43,7 @@ tests/cases/conformance/types/stringLiteral/stringLiteralTypesOverloads01.ts(34, !!! error TS2322: Type 'string' is not assignable to type '"string"'. const number: "number" = "number" ~~~~~~ -!!! error TS2322: Type 'string' is not assignable to type ''number''. +!!! error TS2322: Type 'string' is not assignable to type '"number"'. const boolean: "boolean" = "boolean" ~~~~~~~ !!! error TS2322: Type 'string' is not assignable to type '"boolean"'. diff --git a/tests/baselines/reference/stringLiteralTypesOverloads01.js b/tests/baselines/reference/stringLiteralTypesOverloads01.js index 23483776a9b..73dabd26fab 100644 --- a/tests/baselines/reference/stringLiteralTypesOverloads01.js +++ b/tests/baselines/reference/stringLiteralTypesOverloads01.js @@ -106,9 +106,9 @@ declare namespace Consts1 { declare const string: "string"; declare const number: "number"; declare const boolean: "boolean"; -declare const stringOrNumber: "string" | 'number'; +declare const stringOrNumber: "string" | "number"; declare const stringOrBoolean: "string" | "boolean"; -declare const booleanOrNumber: 'number' | "boolean"; -declare const stringOrBooleanOrNumber: "string" | "boolean" | 'number'; +declare const booleanOrNumber: "number" | "boolean"; +declare const stringOrBooleanOrNumber: "string" | "boolean" | "number"; declare namespace Consts2 { } diff --git a/tests/baselines/reference/subtypingWithCallSignaturesWithSpecializedSignatures.errors.txt b/tests/baselines/reference/subtypingWithCallSignaturesWithSpecializedSignatures.errors.txt index d3c399477d6..da742fcd69c 100644 --- a/tests/baselines/reference/subtypingWithCallSignaturesWithSpecializedSignatures.errors.txt +++ b/tests/baselines/reference/subtypingWithCallSignaturesWithSpecializedSignatures.errors.txt @@ -1,6 +1,6 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithCallSignaturesWithSpecializedSignatures.ts(70,15): error TS2430: Interface 'I2' incorrectly extends interface 'Base2'. Types of property 'a' are incompatible. - Type '(x: string) => string' is not assignable to type '{ (x: 'a'): number; (x: string): number; }'. + Type '(x: string) => string' is not assignable to type '{ (x: "a"): number; (x: string): number; }'. Type 'string' is not assignable to type 'number'. @@ -78,7 +78,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW ~~ !!! error TS2430: Interface 'I2' incorrectly extends interface 'Base2'. !!! error TS2430: Types of property 'a' are incompatible. -!!! error TS2430: Type '(x: string) => string' is not assignable to type '{ (x: 'a'): number; (x: string): number; }'. +!!! error TS2430: Type '(x: string) => string' is not assignable to type '{ (x: "a"): number; (x: string): number; }'. !!! error TS2430: Type 'string' is not assignable to type 'number'. // N's a: (x: string) => string; // error because base returns non-void; diff --git a/tests/baselines/reference/subtypingWithConstructSignaturesWithSpecializedSignatures.errors.txt b/tests/baselines/reference/subtypingWithConstructSignaturesWithSpecializedSignatures.errors.txt index 03cc6de0ca4..8a885a2455f 100644 --- a/tests/baselines/reference/subtypingWithConstructSignaturesWithSpecializedSignatures.errors.txt +++ b/tests/baselines/reference/subtypingWithConstructSignaturesWithSpecializedSignatures.errors.txt @@ -1,6 +1,6 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithConstructSignaturesWithSpecializedSignatures.ts(70,15): error TS2430: Interface 'I2' incorrectly extends interface 'Base2'. Types of property 'a' are incompatible. - Type 'new (x: string) => string' is not assignable to type '{ new (x: 'a'): number; new (x: string): number; }'. + Type 'new (x: string) => string' is not assignable to type '{ new (x: "a"): number; new (x: string): number; }'. Type 'string' is not assignable to type 'number'. @@ -78,7 +78,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW ~~ !!! error TS2430: Interface 'I2' incorrectly extends interface 'Base2'. !!! error TS2430: Types of property 'a' are incompatible. -!!! error TS2430: Type 'new (x: string) => string' is not assignable to type '{ new (x: 'a'): number; new (x: string): number; }'. +!!! error TS2430: Type 'new (x: string) => string' is not assignable to type '{ new (x: "a"): number; new (x: string): number; }'. !!! error TS2430: Type 'string' is not assignable to type 'number'. // N's a: new (x: string) => string; // error because base returns non-void; diff --git a/tests/baselines/reference/typesWithSpecializedCallSignatures.types b/tests/baselines/reference/typesWithSpecializedCallSignatures.types index fa3ac7a4ba4..113e24456f9 100644 --- a/tests/baselines/reference/typesWithSpecializedCallSignatures.types +++ b/tests/baselines/reference/typesWithSpecializedCallSignatures.types @@ -19,22 +19,22 @@ class C { >C : C foo(x: 'hi'): Derived1; ->foo : { (x: 'hi'): Derived1; (x: 'bye'): Derived2; (x: string): Base; } ->x : 'hi' +>foo : { (x: "hi"): Derived1; (x: "bye"): Derived2; (x: string): Base; } +>x : "hi" >Derived1 : Derived1 foo(x: 'bye'): Derived2; ->foo : { (x: 'hi'): Derived1; (x: 'bye'): Derived2; (x: string): Base; } ->x : 'bye' +>foo : { (x: "hi"): Derived1; (x: "bye"): Derived2; (x: string): Base; } +>x : "bye" >Derived2 : Derived2 foo(x: string): Base; ->foo : { (x: 'hi'): Derived1; (x: 'bye'): Derived2; (x: string): Base; } +>foo : { (x: "hi"): Derived1; (x: "bye"): Derived2; (x: string): Base; } >x : string >Base : Base foo(x) { ->foo : { (x: 'hi'): Derived1; (x: 'bye'): Derived2; (x: string): Base; } +>foo : { (x: "hi"): Derived1; (x: "bye"): Derived2; (x: string): Base; } >x : any return x; @@ -50,17 +50,17 @@ interface I { >I : I foo(x: 'hi'): Derived1; ->foo : { (x: 'hi'): Derived1; (x: 'bye'): Derived2; (x: string): Base; } ->x : 'hi' +>foo : { (x: "hi"): Derived1; (x: "bye"): Derived2; (x: string): Base; } +>x : "hi" >Derived1 : Derived1 foo(x: 'bye'): Derived2; ->foo : { (x: 'hi'): Derived1; (x: 'bye'): Derived2; (x: string): Base; } ->x : 'bye' +>foo : { (x: "hi"): Derived1; (x: "bye"): Derived2; (x: string): Base; } +>x : "bye" >Derived2 : Derived2 foo(x: string): Base; ->foo : { (x: 'hi'): Derived1; (x: 'bye'): Derived2; (x: string): Base; } +>foo : { (x: "hi"): Derived1; (x: "bye"): Derived2; (x: string): Base; } >x : string >Base : Base } @@ -69,20 +69,20 @@ var i: I; >I : I var a: { ->a : { foo(x: 'hi'): Derived1; foo(x: 'bye'): Derived2; foo(x: string): Base; } +>a : { foo(x: "hi"): Derived1; foo(x: "bye"): Derived2; foo(x: string): Base; } foo(x: 'hi'): Derived1; ->foo : { (x: 'hi'): Derived1; (x: 'bye'): Derived2; (x: string): Base; } ->x : 'hi' +>foo : { (x: "hi"): Derived1; (x: "bye"): Derived2; (x: string): Base; } +>x : "hi" >Derived1 : Derived1 foo(x: 'bye'): Derived2; ->foo : { (x: 'hi'): Derived1; (x: 'bye'): Derived2; (x: string): Base; } ->x : 'bye' +>foo : { (x: "hi"): Derived1; (x: "bye"): Derived2; (x: string): Base; } +>x : "bye" >Derived2 : Derived2 foo(x: string): Base; ->foo : { (x: 'hi'): Derived1; (x: 'bye'): Derived2; (x: string): Base; } +>foo : { (x: "hi"): Derived1; (x: "bye"): Derived2; (x: string): Base; } >x : string >Base : Base @@ -94,9 +94,9 @@ c = i; >i : I c = a; ->c = a : { foo(x: 'hi'): Derived1; foo(x: 'bye'): Derived2; foo(x: string): Base; } +>c = a : { foo(x: "hi"): Derived1; foo(x: "bye"): Derived2; foo(x: string): Base; } >c : C ->a : { foo(x: 'hi'): Derived1; foo(x: 'bye'): Derived2; foo(x: string): Base; } +>a : { foo(x: "hi"): Derived1; foo(x: "bye"): Derived2; foo(x: string): Base; } i = c; >i = c : C @@ -104,44 +104,44 @@ i = c; >c : C i = a; ->i = a : { foo(x: 'hi'): Derived1; foo(x: 'bye'): Derived2; foo(x: string): Base; } +>i = a : { foo(x: "hi"): Derived1; foo(x: "bye"): Derived2; foo(x: string): Base; } >i : I ->a : { foo(x: 'hi'): Derived1; foo(x: 'bye'): Derived2; foo(x: string): Base; } +>a : { foo(x: "hi"): Derived1; foo(x: "bye"): Derived2; foo(x: string): Base; } a = c; >a = c : C ->a : { foo(x: 'hi'): Derived1; foo(x: 'bye'): Derived2; foo(x: string): Base; } +>a : { foo(x: "hi"): Derived1; foo(x: "bye"): Derived2; foo(x: string): Base; } >c : C a = i; >a = i : I ->a : { foo(x: 'hi'): Derived1; foo(x: 'bye'): Derived2; foo(x: string): Base; } +>a : { foo(x: "hi"): Derived1; foo(x: "bye"): Derived2; foo(x: string): Base; } >i : I var r1: Derived1 = c.foo('hi'); >r1 : Derived1 >Derived1 : Derived1 >c.foo('hi') : Derived1 ->c.foo : { (x: 'hi'): Derived1; (x: 'bye'): Derived2; (x: string): Base; } +>c.foo : { (x: "hi"): Derived1; (x: "bye"): Derived2; (x: string): Base; } >c : C ->foo : { (x: 'hi'): Derived1; (x: 'bye'): Derived2; (x: string): Base; } +>foo : { (x: "hi"): Derived1; (x: "bye"): Derived2; (x: string): Base; } >'hi' : string var r2: Derived2 = c.foo('bye'); >r2 : Derived2 >Derived2 : Derived2 >c.foo('bye') : Derived2 ->c.foo : { (x: 'hi'): Derived1; (x: 'bye'): Derived2; (x: string): Base; } +>c.foo : { (x: "hi"): Derived1; (x: "bye"): Derived2; (x: string): Base; } >c : C ->foo : { (x: 'hi'): Derived1; (x: 'bye'): Derived2; (x: string): Base; } +>foo : { (x: "hi"): Derived1; (x: "bye"): Derived2; (x: string): Base; } >'bye' : string var r3: Base = c.foo('hm'); >r3 : Base >Base : Base >c.foo('hm') : Base ->c.foo : { (x: 'hi'): Derived1; (x: 'bye'): Derived2; (x: string): Base; } +>c.foo : { (x: "hi"): Derived1; (x: "bye"): Derived2; (x: string): Base; } >c : C ->foo : { (x: 'hi'): Derived1; (x: 'bye'): Derived2; (x: string): Base; } +>foo : { (x: "hi"): Derived1; (x: "bye"): Derived2; (x: string): Base; } >'hm' : string diff --git a/tests/baselines/reference/typesWithSpecializedConstructSignatures.types b/tests/baselines/reference/typesWithSpecializedConstructSignatures.types index 66e274d917a..2698439c527 100644 --- a/tests/baselines/reference/typesWithSpecializedConstructSignatures.types +++ b/tests/baselines/reference/typesWithSpecializedConstructSignatures.types @@ -19,10 +19,10 @@ class C { >C : C constructor(x: 'hi'); ->x : 'hi' +>x : "hi" constructor(x: 'bye'); ->x : 'bye' +>x : "bye" constructor(x: string); >x : string @@ -44,11 +44,11 @@ interface I { >I : I new(x: 'hi'): Derived1; ->x : 'hi' +>x : "hi" >Derived1 : Derived1 new(x: 'bye'): Derived2; ->x : 'bye' +>x : "bye" >Derived2 : Derived2 new(x: string): Base; @@ -60,14 +60,14 @@ var i: I; >I : I var a: { ->a : { new (x: 'hi'): Derived1; new (x: 'bye'): Derived2; new (x: string): Base; } +>a : { new (x: "hi"): Derived1; new (x: "bye"): Derived2; new (x: string): Base; } new(x: 'hi'): Derived1; ->x : 'hi' +>x : "hi" >Derived1 : Derived1 new(x: 'bye'): Derived2; ->x : 'bye' +>x : "bye" >Derived2 : Derived2 new(x: string): Base; @@ -82,18 +82,18 @@ c = i; >i : I c = a; ->c = a : { new (x: 'hi'): Derived1; new (x: 'bye'): Derived2; new (x: string): Base; } +>c = a : { new (x: "hi"): Derived1; new (x: "bye"): Derived2; new (x: string): Base; } >c : C ->a : { new (x: 'hi'): Derived1; new (x: 'bye'): Derived2; new (x: string): Base; } +>a : { new (x: "hi"): Derived1; new (x: "bye"): Derived2; new (x: string): Base; } i = a; ->i = a : { new (x: 'hi'): Derived1; new (x: 'bye'): Derived2; new (x: string): Base; } +>i = a : { new (x: "hi"): Derived1; new (x: "bye"): Derived2; new (x: string): Base; } >i : I ->a : { new (x: 'hi'): Derived1; new (x: 'bye'): Derived2; new (x: string): Base; } +>a : { new (x: "hi"): Derived1; new (x: "bye"): Derived2; new (x: string): Base; } a = i; >a = i : I ->a : { new (x: 'hi'): Derived1; new (x: 'bye'): Derived2; new (x: string): Base; } +>a : { new (x: "hi"): Derived1; new (x: "bye"): Derived2; new (x: string): Base; } >i : I var r1 = new C('hi'); @@ -113,6 +113,6 @@ var r3: Base = new a('hm'); >r3 : Base >Base : Base >new a('hm') : Base ->a : { new (x: 'hi'): Derived1; new (x: 'bye'): Derived2; new (x: string): Base; } +>a : { new (x: "hi"): Derived1; new (x: "bye"): Derived2; new (x: string): Base; } >'hm' : string From f721971063f210389dc3cd4c0d0a6b3e4562d4e8 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Fri, 2 Oct 2015 15:41:12 -0700 Subject: [PATCH 032/227] Capture compatible contextual types for unions containing string literals. --- src/compiler/checker.ts | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index c062398c1a9..dd6c3a63df9 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -10103,6 +10103,28 @@ namespace ts { return getUnionType([type1, type2]); } + function checkStringLiteralExpression(node: LiteralExpression) { + // TODO (drosen): Do we want to apply the same approach to no-sub template literals? + + let contextualType = getContextualType(node); + if (contextualType) { + if (contextualType.flags & TypeFlags.Union) { + for (const type of (contextualType).types) { + if (type.flags & TypeFlags.StringLiteral && (type).text === node.text) { + return contextualType; + } + } + } + else if (contextualType.flags & TypeFlags.StringLiteral && (contextualType).text === node.text) { + // NOTE: This doesn't work because the contextual type of a string literal + // always gets its apparent type. + // Thus you'll always end up with 'String' instead of the literal. + return contextualType; + } + } + return stringType; + } + function checkTemplateExpression(node: TemplateExpression): Type { // We just want to check each expressions, but we are unconcerned with // the type of each expression, as any value may be coerced into a string. @@ -10233,8 +10255,9 @@ namespace ts { case SyntaxKind.TemplateExpression: return checkTemplateExpression(node); case SyntaxKind.StringLiteral: + return checkStringLiteralExpression(node); case SyntaxKind.NoSubstitutionTemplateLiteral: - return stringType; + return stringType case SyntaxKind.RegularExpressionLiteral: return globalRegExpType; case SyntaxKind.ArrayLiteralExpression: From 7b4e94dbd57aef497a6cda2d6b440d35dd6e9d19 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Fri, 2 Oct 2015 15:42:16 -0700 Subject: [PATCH 033/227] Accepted baselines. --- ...tringLiteralTypesInUnionTypes01.errors.txt | 33 ------- .../stringLiteralTypesInUnionTypes01.symbols | 52 +++++++++++ .../stringLiteralTypesInUnionTypes01.types | 62 +++++++++++++ .../stringLiteralTypesInUnionTypes02.types | 4 +- ...tringLiteralTypesInUnionTypes03.errors.txt | 7 +- ...tringLiteralTypesInUnionTypes04.errors.txt | 50 ---------- .../stringLiteralTypesInUnionTypes04.symbols | 76 +++++++++++++++ .../stringLiteralTypesInUnionTypes04.types | 92 +++++++++++++++++++ ...ingLiteralTypesTypePredicates01.errors.txt | 7 +- 9 files changed, 286 insertions(+), 97 deletions(-) delete mode 100644 tests/baselines/reference/stringLiteralTypesInUnionTypes01.errors.txt create mode 100644 tests/baselines/reference/stringLiteralTypesInUnionTypes01.symbols create mode 100644 tests/baselines/reference/stringLiteralTypesInUnionTypes01.types delete mode 100644 tests/baselines/reference/stringLiteralTypesInUnionTypes04.errors.txt create mode 100644 tests/baselines/reference/stringLiteralTypesInUnionTypes04.symbols create mode 100644 tests/baselines/reference/stringLiteralTypesInUnionTypes04.types diff --git a/tests/baselines/reference/stringLiteralTypesInUnionTypes01.errors.txt b/tests/baselines/reference/stringLiteralTypesInUnionTypes01.errors.txt deleted file mode 100644 index 14d0a892f55..00000000000 --- a/tests/baselines/reference/stringLiteralTypesInUnionTypes01.errors.txt +++ /dev/null @@ -1,33 +0,0 @@ -tests/cases/conformance/types/stringLiteral/stringLiteralTypesInUnionTypes01.ts(4,5): error TS2322: Type 'string' is not assignable to type '"foo" | "bar" | "baz"'. - Type 'string' is not assignable to type '"baz"'. -tests/cases/conformance/types/stringLiteral/stringLiteralTypesInUnionTypes01.ts(5,5): error TS2322: Type 'string' is not assignable to type '"foo" | "bar" | "baz"'. - Type 'string' is not assignable to type '"baz"'. - - -==== tests/cases/conformance/types/stringLiteral/stringLiteralTypesInUnionTypes01.ts (2 errors) ==== - - type T = "foo" | "bar" | "baz"; - - var x: "foo" | "bar" | "baz" = "foo"; - ~ -!!! error TS2322: Type 'string' is not assignable to type '"foo" | "bar" | "baz"'. -!!! error TS2322: Type 'string' is not assignable to type '"baz"'. - var y: T = "bar"; - ~ -!!! error TS2322: Type 'string' is not assignable to type '"foo" | "bar" | "baz"'. -!!! error TS2322: Type 'string' is not assignable to type '"baz"'. - - if (x === "foo") { - let a = x; - } - else if (x !== "bar") { - let b = x || y; - } - else { - let c = x; - let d = y; - let e: (typeof x) | (typeof y) = c || d; - } - - x = y; - y = x; \ No newline at end of file diff --git a/tests/baselines/reference/stringLiteralTypesInUnionTypes01.symbols b/tests/baselines/reference/stringLiteralTypesInUnionTypes01.symbols new file mode 100644 index 00000000000..c608929383e --- /dev/null +++ b/tests/baselines/reference/stringLiteralTypesInUnionTypes01.symbols @@ -0,0 +1,52 @@ +=== tests/cases/conformance/types/stringLiteral/stringLiteralTypesInUnionTypes01.ts === + +type T = "foo" | "bar" | "baz"; +>T : Symbol(T, Decl(stringLiteralTypesInUnionTypes01.ts, 0, 0)) + +var x: "foo" | "bar" | "baz" = "foo"; +>x : Symbol(x, Decl(stringLiteralTypesInUnionTypes01.ts, 3, 3)) + +var y: T = "bar"; +>y : Symbol(y, Decl(stringLiteralTypesInUnionTypes01.ts, 4, 3)) +>T : Symbol(T, Decl(stringLiteralTypesInUnionTypes01.ts, 0, 0)) + +if (x === "foo") { +>x : Symbol(x, Decl(stringLiteralTypesInUnionTypes01.ts, 3, 3)) + + let a = x; +>a : Symbol(a, Decl(stringLiteralTypesInUnionTypes01.ts, 7, 7)) +>x : Symbol(x, Decl(stringLiteralTypesInUnionTypes01.ts, 3, 3)) +} +else if (x !== "bar") { +>x : Symbol(x, Decl(stringLiteralTypesInUnionTypes01.ts, 3, 3)) + + let b = x || y; +>b : Symbol(b, Decl(stringLiteralTypesInUnionTypes01.ts, 10, 7)) +>x : Symbol(x, Decl(stringLiteralTypesInUnionTypes01.ts, 3, 3)) +>y : Symbol(y, Decl(stringLiteralTypesInUnionTypes01.ts, 4, 3)) +} +else { + let c = x; +>c : Symbol(c, Decl(stringLiteralTypesInUnionTypes01.ts, 13, 7)) +>x : Symbol(x, Decl(stringLiteralTypesInUnionTypes01.ts, 3, 3)) + + let d = y; +>d : Symbol(d, Decl(stringLiteralTypesInUnionTypes01.ts, 14, 7)) +>y : Symbol(y, Decl(stringLiteralTypesInUnionTypes01.ts, 4, 3)) + + let e: (typeof x) | (typeof y) = c || d; +>e : Symbol(e, Decl(stringLiteralTypesInUnionTypes01.ts, 15, 7)) +>x : Symbol(x, Decl(stringLiteralTypesInUnionTypes01.ts, 3, 3)) +>y : Symbol(y, Decl(stringLiteralTypesInUnionTypes01.ts, 4, 3)) +>c : Symbol(c, Decl(stringLiteralTypesInUnionTypes01.ts, 13, 7)) +>d : Symbol(d, Decl(stringLiteralTypesInUnionTypes01.ts, 14, 7)) +} + +x = y; +>x : Symbol(x, Decl(stringLiteralTypesInUnionTypes01.ts, 3, 3)) +>y : Symbol(y, Decl(stringLiteralTypesInUnionTypes01.ts, 4, 3)) + +y = x; +>y : Symbol(y, Decl(stringLiteralTypesInUnionTypes01.ts, 4, 3)) +>x : Symbol(x, Decl(stringLiteralTypesInUnionTypes01.ts, 3, 3)) + diff --git a/tests/baselines/reference/stringLiteralTypesInUnionTypes01.types b/tests/baselines/reference/stringLiteralTypesInUnionTypes01.types new file mode 100644 index 00000000000..b5a2d876bcc --- /dev/null +++ b/tests/baselines/reference/stringLiteralTypesInUnionTypes01.types @@ -0,0 +1,62 @@ +=== tests/cases/conformance/types/stringLiteral/stringLiteralTypesInUnionTypes01.ts === + +type T = "foo" | "bar" | "baz"; +>T : "foo" | "bar" | "baz" + +var x: "foo" | "bar" | "baz" = "foo"; +>x : "foo" | "bar" | "baz" +>"foo" : "foo" | "bar" | "baz" + +var y: T = "bar"; +>y : "foo" | "bar" | "baz" +>T : "foo" | "bar" | "baz" +>"bar" : "foo" | "bar" | "baz" + +if (x === "foo") { +>x === "foo" : boolean +>x : "foo" | "bar" | "baz" +>"foo" : string + + let a = x; +>a : "foo" | "bar" | "baz" +>x : "foo" | "bar" | "baz" +} +else if (x !== "bar") { +>x !== "bar" : boolean +>x : "foo" | "bar" | "baz" +>"bar" : string + + let b = x || y; +>b : "foo" | "bar" | "baz" +>x || y : "foo" | "bar" | "baz" +>x : "foo" | "bar" | "baz" +>y : "foo" | "bar" | "baz" +} +else { + let c = x; +>c : "foo" | "bar" | "baz" +>x : "foo" | "bar" | "baz" + + let d = y; +>d : "foo" | "bar" | "baz" +>y : "foo" | "bar" | "baz" + + let e: (typeof x) | (typeof y) = c || d; +>e : "foo" | "bar" | "baz" +>x : "foo" | "bar" | "baz" +>y : "foo" | "bar" | "baz" +>c || d : "foo" | "bar" | "baz" +>c : "foo" | "bar" | "baz" +>d : "foo" | "bar" | "baz" +} + +x = y; +>x = y : "foo" | "bar" | "baz" +>x : "foo" | "bar" | "baz" +>y : "foo" | "bar" | "baz" + +y = x; +>y = x : "foo" | "bar" | "baz" +>y : "foo" | "bar" | "baz" +>x : "foo" | "bar" | "baz" + diff --git a/tests/baselines/reference/stringLiteralTypesInUnionTypes02.types b/tests/baselines/reference/stringLiteralTypesInUnionTypes02.types index 569edc77815..e3ac5ba4817 100644 --- a/tests/baselines/reference/stringLiteralTypesInUnionTypes02.types +++ b/tests/baselines/reference/stringLiteralTypesInUnionTypes02.types @@ -5,12 +5,12 @@ type T = string | "foo" | "bar" | "baz"; var x: "foo" | "bar" | "baz" | string = "foo"; >x : "foo" | "bar" | "baz" | string ->"foo" : string +>"foo" : "foo" | "bar" | "baz" | string var y: T = "bar"; >y : string | "foo" | "bar" | "baz" >T : string | "foo" | "bar" | "baz" ->"bar" : string +>"bar" : string | "foo" | "bar" | "baz" if (x === "foo") { >x === "foo" : boolean diff --git a/tests/baselines/reference/stringLiteralTypesInUnionTypes03.errors.txt b/tests/baselines/reference/stringLiteralTypesInUnionTypes03.errors.txt index 8ff377b2e72..74249b178d6 100644 --- a/tests/baselines/reference/stringLiteralTypesInUnionTypes03.errors.txt +++ b/tests/baselines/reference/stringLiteralTypesInUnionTypes03.errors.txt @@ -1,18 +1,13 @@ -tests/cases/conformance/types/stringLiteral/stringLiteralTypesInUnionTypes03.ts(5,5): error TS2322: Type 'string' is not assignable to type 'number | "foo" | "bar"'. - Type 'string' is not assignable to type '"bar"'. tests/cases/conformance/types/stringLiteral/stringLiteralTypesInUnionTypes03.ts(7,5): error TS2365: Operator '===' cannot be applied to types '"foo" | "bar" | number' and 'string'. tests/cases/conformance/types/stringLiteral/stringLiteralTypesInUnionTypes03.ts(10,10): error TS2365: Operator '!==' cannot be applied to types '"foo" | "bar" | number' and 'string'. -==== tests/cases/conformance/types/stringLiteral/stringLiteralTypesInUnionTypes03.ts (3 errors) ==== +==== tests/cases/conformance/types/stringLiteral/stringLiteralTypesInUnionTypes03.ts (2 errors) ==== type T = number | "foo" | "bar"; var x: "foo" | "bar" | number; var y: T = "bar"; - ~ -!!! error TS2322: Type 'string' is not assignable to type 'number | "foo" | "bar"'. -!!! error TS2322: Type 'string' is not assignable to type '"bar"'. if (x === "foo") { ~~~~~~~~~~~ diff --git a/tests/baselines/reference/stringLiteralTypesInUnionTypes04.errors.txt b/tests/baselines/reference/stringLiteralTypesInUnionTypes04.errors.txt deleted file mode 100644 index 77cb9c09531..00000000000 --- a/tests/baselines/reference/stringLiteralTypesInUnionTypes04.errors.txt +++ /dev/null @@ -1,50 +0,0 @@ -tests/cases/conformance/types/stringLiteral/stringLiteralTypesInUnionTypes04.ts(4,5): error TS2322: Type 'string' is not assignable to type '"" | "foo"'. - Type 'string' is not assignable to type '"foo"'. -tests/cases/conformance/types/stringLiteral/stringLiteralTypesInUnionTypes04.ts(5,5): error TS2322: Type 'string' is not assignable to type '"" | "foo"'. - Type 'string' is not assignable to type '"foo"'. - - -==== tests/cases/conformance/types/stringLiteral/stringLiteralTypesInUnionTypes04.ts (2 errors) ==== - - type T = "" | "foo"; - - let x: T = ""; - ~ -!!! error TS2322: Type 'string' is not assignable to type '"" | "foo"'. -!!! error TS2322: Type 'string' is not assignable to type '"foo"'. - let y: T = "foo"; - ~ -!!! error TS2322: Type 'string' is not assignable to type '"" | "foo"'. -!!! error TS2322: Type 'string' is not assignable to type '"foo"'. - - if (x === "") { - let a = x; - } - - if (x !== "") { - let b = x; - } - - if (x == "") { - let c = x; - } - - if (x != "") { - let d = x; - } - - if (x) { - let e = x; - } - - if (!x) { - let f = x; - } - - if (!!x) { - let g = x; - } - - if (!!!x) { - let h = x; - } \ No newline at end of file diff --git a/tests/baselines/reference/stringLiteralTypesInUnionTypes04.symbols b/tests/baselines/reference/stringLiteralTypesInUnionTypes04.symbols new file mode 100644 index 00000000000..ced93fcefc9 --- /dev/null +++ b/tests/baselines/reference/stringLiteralTypesInUnionTypes04.symbols @@ -0,0 +1,76 @@ +=== tests/cases/conformance/types/stringLiteral/stringLiteralTypesInUnionTypes04.ts === + +type T = "" | "foo"; +>T : Symbol(T, Decl(stringLiteralTypesInUnionTypes04.ts, 0, 0)) + +let x: T = ""; +>x : Symbol(x, Decl(stringLiteralTypesInUnionTypes04.ts, 3, 3)) +>T : Symbol(T, Decl(stringLiteralTypesInUnionTypes04.ts, 0, 0)) + +let y: T = "foo"; +>y : Symbol(y, Decl(stringLiteralTypesInUnionTypes04.ts, 4, 3)) +>T : Symbol(T, Decl(stringLiteralTypesInUnionTypes04.ts, 0, 0)) + +if (x === "") { +>x : Symbol(x, Decl(stringLiteralTypesInUnionTypes04.ts, 3, 3)) + + let a = x; +>a : Symbol(a, Decl(stringLiteralTypesInUnionTypes04.ts, 7, 7)) +>x : Symbol(x, Decl(stringLiteralTypesInUnionTypes04.ts, 3, 3)) +} + +if (x !== "") { +>x : Symbol(x, Decl(stringLiteralTypesInUnionTypes04.ts, 3, 3)) + + let b = x; +>b : Symbol(b, Decl(stringLiteralTypesInUnionTypes04.ts, 11, 7)) +>x : Symbol(x, Decl(stringLiteralTypesInUnionTypes04.ts, 3, 3)) +} + +if (x == "") { +>x : Symbol(x, Decl(stringLiteralTypesInUnionTypes04.ts, 3, 3)) + + let c = x; +>c : Symbol(c, Decl(stringLiteralTypesInUnionTypes04.ts, 15, 7)) +>x : Symbol(x, Decl(stringLiteralTypesInUnionTypes04.ts, 3, 3)) +} + +if (x != "") { +>x : Symbol(x, Decl(stringLiteralTypesInUnionTypes04.ts, 3, 3)) + + let d = x; +>d : Symbol(d, Decl(stringLiteralTypesInUnionTypes04.ts, 19, 7)) +>x : Symbol(x, Decl(stringLiteralTypesInUnionTypes04.ts, 3, 3)) +} + +if (x) { +>x : Symbol(x, Decl(stringLiteralTypesInUnionTypes04.ts, 3, 3)) + + let e = x; +>e : Symbol(e, Decl(stringLiteralTypesInUnionTypes04.ts, 23, 7)) +>x : Symbol(x, Decl(stringLiteralTypesInUnionTypes04.ts, 3, 3)) +} + +if (!x) { +>x : Symbol(x, Decl(stringLiteralTypesInUnionTypes04.ts, 3, 3)) + + let f = x; +>f : Symbol(f, Decl(stringLiteralTypesInUnionTypes04.ts, 27, 7)) +>x : Symbol(x, Decl(stringLiteralTypesInUnionTypes04.ts, 3, 3)) +} + +if (!!x) { +>x : Symbol(x, Decl(stringLiteralTypesInUnionTypes04.ts, 3, 3)) + + let g = x; +>g : Symbol(g, Decl(stringLiteralTypesInUnionTypes04.ts, 31, 7)) +>x : Symbol(x, Decl(stringLiteralTypesInUnionTypes04.ts, 3, 3)) +} + +if (!!!x) { +>x : Symbol(x, Decl(stringLiteralTypesInUnionTypes04.ts, 3, 3)) + + let h = x; +>h : Symbol(h, Decl(stringLiteralTypesInUnionTypes04.ts, 35, 7)) +>x : Symbol(x, Decl(stringLiteralTypesInUnionTypes04.ts, 3, 3)) +} diff --git a/tests/baselines/reference/stringLiteralTypesInUnionTypes04.types b/tests/baselines/reference/stringLiteralTypesInUnionTypes04.types new file mode 100644 index 00000000000..9a010b490cc --- /dev/null +++ b/tests/baselines/reference/stringLiteralTypesInUnionTypes04.types @@ -0,0 +1,92 @@ +=== tests/cases/conformance/types/stringLiteral/stringLiteralTypesInUnionTypes04.ts === + +type T = "" | "foo"; +>T : "" | "foo" + +let x: T = ""; +>x : "" | "foo" +>T : "" | "foo" +>"" : "" | "foo" + +let y: T = "foo"; +>y : "" | "foo" +>T : "" | "foo" +>"foo" : "" | "foo" + +if (x === "") { +>x === "" : boolean +>x : "" | "foo" +>"" : string + + let a = x; +>a : "" | "foo" +>x : "" | "foo" +} + +if (x !== "") { +>x !== "" : boolean +>x : "" | "foo" +>"" : string + + let b = x; +>b : "" | "foo" +>x : "" | "foo" +} + +if (x == "") { +>x == "" : boolean +>x : "" | "foo" +>"" : string + + let c = x; +>c : "" | "foo" +>x : "" | "foo" +} + +if (x != "") { +>x != "" : boolean +>x : "" | "foo" +>"" : string + + let d = x; +>d : "" | "foo" +>x : "" | "foo" +} + +if (x) { +>x : "" | "foo" + + let e = x; +>e : "" | "foo" +>x : "" | "foo" +} + +if (!x) { +>!x : boolean +>x : "" | "foo" + + let f = x; +>f : "" | "foo" +>x : "" | "foo" +} + +if (!!x) { +>!!x : boolean +>!x : boolean +>x : "" | "foo" + + let g = x; +>g : "" | "foo" +>x : "" | "foo" +} + +if (!!!x) { +>!!!x : boolean +>!!x : boolean +>!x : boolean +>x : "" | "foo" + + let h = x; +>h : "" | "foo" +>x : "" | "foo" +} diff --git a/tests/baselines/reference/stringLiteralTypesTypePredicates01.errors.txt b/tests/baselines/reference/stringLiteralTypesTypePredicates01.errors.txt index 3e412a6c770..b888c3ca77e 100644 --- a/tests/baselines/reference/stringLiteralTypesTypePredicates01.errors.txt +++ b/tests/baselines/reference/stringLiteralTypesTypePredicates01.errors.txt @@ -1,10 +1,8 @@ tests/cases/conformance/types/stringLiteral/stringLiteralTypesTypePredicates01.ts(4,10): error TS2382: Specialized overload signature is not assignable to any non-specialized signature. tests/cases/conformance/types/stringLiteral/stringLiteralTypesTypePredicates01.ts(5,10): error TS2382: Specialized overload signature is not assignable to any non-specialized signature. -tests/cases/conformance/types/stringLiteral/stringLiteralTypesTypePredicates01.ts(10,5): error TS2322: Type 'string' is not assignable to type '"A" | "B"'. - Type 'string' is not assignable to type '"B"'. -==== tests/cases/conformance/types/stringLiteral/stringLiteralTypesTypePredicates01.ts (3 errors) ==== +==== tests/cases/conformance/types/stringLiteral/stringLiteralTypesTypePredicates01.ts (2 errors) ==== type Kind = "A" | "B" @@ -19,9 +17,6 @@ tests/cases/conformance/types/stringLiteral/stringLiteralTypesTypePredicates01.t } var x: Kind = "A"; - ~ -!!! error TS2322: Type 'string' is not assignable to type '"A" | "B"'. -!!! error TS2322: Type 'string' is not assignable to type '"B"'. if (kindIs(x, "A")) { let a = x; From d8d72aabae439e17d18e35887981165413b71556 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Fri, 2 Oct 2015 16:00:45 -0700 Subject: [PATCH 034/227] Separated the concept of apparent types from contextual types for string literal types. In most cases, expressions are interested in the apparent type of the contextual type. For instance: var x = { hasOwnProperty(prop) { /* ... */ }; In the above, 'prop' should be contextually typed as 'string' from the signature of 'hasOwnProperty' in the global 'Object' type. However, in the case of string literal types, we don't want to get the apparent type after fetching the contextual type. This is because the apparent type of the '"onload"' string literal type is the global 'String' type. This has adverse effects in simple assignments like the following: let x: "onload" = "onload"; In this example, the right-hand side of the assignment will grab the type of 'x'. After figuring out the type is "onload", we then get the apparent type which is 'String'. This is problematic because when we then check the assignment itself, 'String's are not assignable to '"onload"'s. So in this case, we grab the contextual type *without* getting its apparent type. --- src/compiler/checker.ts | 39 +++++++++++++++++++++++---------------- 1 file changed, 23 insertions(+), 16 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index dd6c3a63df9..2dcded72ad4 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -80,7 +80,7 @@ namespace ts { symbolToString, getAugmentedPropertiesOfType, getRootSymbols, - getContextualType, + getContextualType: getApparentTypeOfContextualType, getFullyQualifiedName, getResolvedSignature, getConstantValue, @@ -6716,7 +6716,7 @@ namespace ts { else if (operator === SyntaxKind.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. - let type = getContextualType(binaryExpression); + let type = getApparentTypeOfContextualType(binaryExpression); if (!type && node === binaryExpression.right) { type = checkExpression(binaryExpression.left); } @@ -6788,7 +6788,7 @@ namespace ts { function getContextualTypeForObjectLiteralElement(element: ObjectLiteralElement) { let objectLiteral = element.parent; - let type = getContextualType(objectLiteral); + let type = getApparentTypeOfContextualType(objectLiteral); if (type) { if (!hasDynamicName(element)) { // For a (non-symbol) computed property, there is no reason to look up the name @@ -6814,7 +6814,7 @@ namespace ts { // type of T. function getContextualTypeForElementExpression(node: Expression): Type { let arrayLiteral = node.parent; - let type = getContextualType(arrayLiteral); + let type = getApparentTypeOfContextualType(arrayLiteral); if (type) { let index = indexOf(arrayLiteral.elements, node); return getTypeOfPropertyOfContextualType(type, "" + index) @@ -6827,7 +6827,7 @@ namespace ts { // In a contextually typed conditional expression, the true/false expressions are contextually typed by the same type. function getContextualTypeForConditionalOperand(node: Expression): Type { let conditional = node.parent; - return node === conditional.whenTrue || node === conditional.whenFalse ? getContextualType(conditional) : undefined; + return node === conditional.whenTrue || node === conditional.whenFalse ? getApparentTypeOfContextualType(conditional) : undefined; } function getContextualTypeForJsxExpression(expr: JsxExpression|JsxSpreadAttribute): Type { @@ -6852,12 +6852,22 @@ namespace ts { // Return the contextual type for a given expression node. During overload resolution, a contextual type may temporarily // be "pushed" onto a node using the contextualType property. - function getContextualType(node: Expression): Type { - let type = getContextualTypeWorker(node); + function getApparentTypeOfContextualType(node: Expression): Type { + let type = getContextualType(node); return type && getApparentType(type); } - function getContextualTypeWorker(node: Expression): Type { + /** + * Woah! Do you really want to use this function? + * + * Unless you're trying to get the *non-apparent* type for a value-literal type, + * you probably meant to use 'getApparentTypeOfContextualType'. + * Otherwise this is slightly less useful. + * + * @param node the expression whose contextual type will be returned. + * @returns the contextual type of an expression. + */ + function getContextualType(node: Expression): Type { if (isInsideWithStatementBody(node)) { // We cannot answer semantic questions within a with block, do not proceed any further return undefined; @@ -6896,7 +6906,7 @@ namespace ts { Debug.assert(parent.parent.kind === SyntaxKind.TemplateExpression); return getContextualTypeForSubstitutionExpression(parent.parent, node); case SyntaxKind.ParenthesizedExpression: - return getContextualType(parent); + return getApparentTypeOfContextualType(parent); case SyntaxKind.JsxExpression: case SyntaxKind.JsxSpreadAttribute: return getContextualTypeForJsxExpression(parent); @@ -6936,7 +6946,7 @@ namespace ts { Debug.assert(node.kind !== SyntaxKind.MethodDeclaration || isObjectLiteralMethod(node)); let type = isObjectLiteralMethod(node) ? getContextualTypeForObjectLiteralMethod(node) - : getContextualType(node); + : getApparentTypeOfContextualType(node); if (!type) { return undefined; } @@ -7066,7 +7076,7 @@ namespace ts { type.pattern = node; return type; } - let contextualType = getContextualType(node); + let contextualType = getApparentTypeOfContextualType(node); if (contextualType && contextualTypeIsTupleLikeType(contextualType)) { let pattern = contextualType.pattern; // If array literal is contextually typed by a binding pattern or an assignment pattern, pad the resulting @@ -7157,7 +7167,7 @@ namespace ts { let propertiesTable: SymbolTable = {}; let propertiesArray: Symbol[] = []; - let contextualType = getContextualType(node); + let contextualType = getApparentTypeOfContextualType(node); let contextualTypeHasPattern = contextualType && contextualType.pattern && (contextualType.pattern.kind === SyntaxKind.ObjectBindingPattern || contextualType.pattern.kind === SyntaxKind.ObjectLiteralExpression); let inDestructuringPattern = isAssignmentTarget(node); @@ -10116,9 +10126,6 @@ namespace ts { } } else if (contextualType.flags & TypeFlags.StringLiteral && (contextualType).text === node.text) { - // NOTE: This doesn't work because the contextual type of a string literal - // always gets its apparent type. - // Thus you'll always end up with 'String' instead of the literal. return contextualType; } } @@ -10184,7 +10191,7 @@ namespace ts { if (isInferentialContext(contextualMapper)) { let signature = getSingleCallSignature(type); if (signature && signature.typeParameters) { - let contextualType = getContextualType(node); + let contextualType = getApparentTypeOfContextualType(node); if (contextualType) { let contextualSignature = getSingleCallSignature(contextualType); if (contextualSignature && !contextualSignature.typeParameters) { From 315b06dc99b6bcf6079e31f535d9ab3171d1d9ad Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Fri, 2 Oct 2015 16:09:57 -0700 Subject: [PATCH 035/227] Accepted baselines. --- ...ritedOverloadedSpecializedSignatures.types | 16 ++++----- ...pecializedCallAndConstructSignatures.types | 4 +-- .../stringLiteralTypesAndTuples01.errors.txt | 9 +---- .../stringLiteralTypesAsTags01.errors.txt | 9 +---- ...alTypesInVariableDeclarations01.errors.txt | 34 ++----------------- .../stringLiteralTypesOverloads01.errors.txt | 11 +----- .../stringLiteralTypesOverloads02.errors.txt | 11 +----- .../reference/symbolProperty41.types | 2 +- ...gumentsWithStringLiteralTypes01.errors.txt | 18 +++++----- .../typesWithSpecializedCallSignatures.types | 4 +-- ...esWithSpecializedConstructSignatures.types | 4 +-- 11 files changed, 30 insertions(+), 92 deletions(-) diff --git a/tests/baselines/reference/inheritedOverloadedSpecializedSignatures.types b/tests/baselines/reference/inheritedOverloadedSpecializedSignatures.types index 0ec428bb159..563cb58a755 100644 --- a/tests/baselines/reference/inheritedOverloadedSpecializedSignatures.types +++ b/tests/baselines/reference/inheritedOverloadedSpecializedSignatures.types @@ -24,7 +24,7 @@ b('foo').charAt(0); >b('foo').charAt : (pos: number) => string >b('foo') : string >b : B ->'foo' : string +>'foo' : "foo" >charAt : (pos: number) => string >0 : number @@ -94,25 +94,25 @@ var x1: string[] = c('B2'); >x1 : string[] >c('B2') : string[] >c : C ->'B2' : string +>'B2' : "B2" var x2: number = c('B1'); >x2 : number >c('B1') : number >c : C ->'B1' : string +>'B1' : "B1" var x3: boolean = c('A2'); >x3 : boolean >c('A2') : boolean >c : C ->'A2' : string +>'A2' : "A2" var x4: string = c('A1'); >x4 : string >c('A1') : string >c : C ->'A1' : string +>'A1' : "A1" var x5: void = c('A0'); >x5 : void @@ -124,19 +124,19 @@ var x6: number[] = c('C1'); >x6 : number[] >c('C1') : number[] >c : C ->'C1' : string +>'C1' : "C1" var x7: boolean[] = c('C2'); >x7 : boolean[] >c('C2') : boolean[] >c : C ->'C2' : string +>'C2' : "C2" var x8: string = c('C'); >x8 : string >c('C') : string >c : C ->'C' : string +>'C' : "C" var x9: void = c('generic'); >x9 : void diff --git a/tests/baselines/reference/interfaceWithSpecializedCallAndConstructSignatures.types b/tests/baselines/reference/interfaceWithSpecializedCallAndConstructSignatures.types index 7b19fd5889b..5288d9f15a4 100644 --- a/tests/baselines/reference/interfaceWithSpecializedCallAndConstructSignatures.types +++ b/tests/baselines/reference/interfaceWithSpecializedCallAndConstructSignatures.types @@ -24,7 +24,7 @@ var r = f('a'); >r : number >f('a') : number >f : Foo ->'a' : string +>'a' : "a" var r2 = f('A'); >r2 : any @@ -36,7 +36,7 @@ var r3 = new f('a'); >r3 : any >new f('a') : any >f : Foo ->'a' : string +>'a' : "a" var r4 = new f('A'); >r4 : Object diff --git a/tests/baselines/reference/stringLiteralTypesAndTuples01.errors.txt b/tests/baselines/reference/stringLiteralTypesAndTuples01.errors.txt index 849f4922e45..6a8704ce554 100644 --- a/tests/baselines/reference/stringLiteralTypesAndTuples01.errors.txt +++ b/tests/baselines/reference/stringLiteralTypesAndTuples01.errors.txt @@ -1,20 +1,13 @@ -tests/cases/conformance/types/stringLiteral/stringLiteralTypesAndTuples01.ts(6,5): error TS2322: Type '[string, string, string]' is not assignable to type '["I'm", "a", any]'. - Types of property '0' are incompatible. - Type 'string' is not assignable to type '"I'm"'. tests/cases/conformance/types/stringLiteral/stringLiteralTypesAndTuples01.ts(6,37): error TS2304: Cannot find name 'Dinosaur'. -==== tests/cases/conformance/types/stringLiteral/stringLiteralTypesAndTuples01.ts (2 errors) ==== +==== tests/cases/conformance/types/stringLiteral/stringLiteralTypesAndTuples01.ts (1 errors) ==== // Should all be strings. let [hello, brave, newish, world] = ["Hello", "Brave", "New", "World"]; type RexOrRaptor = "t-rex" | "raptor" let [im, a, dinosaur]: ["I'm", "a", Dinosaur] = ['I\'m', 'a', 't-rex']; - ~~~~~~~~~~~~~~~~~ -!!! error TS2322: Type '[string, string, string]' is not assignable to type '["I'm", "a", any]'. -!!! error TS2322: Types of property '0' are incompatible. -!!! error TS2322: Type 'string' is not assignable to type '"I'm"'. ~~~~~~~~ !!! error TS2304: Cannot find name 'Dinosaur'. diff --git a/tests/baselines/reference/stringLiteralTypesAsTags01.errors.txt b/tests/baselines/reference/stringLiteralTypesAsTags01.errors.txt index df05e25304f..6e4f8943fb6 100644 --- a/tests/baselines/reference/stringLiteralTypesAsTags01.errors.txt +++ b/tests/baselines/reference/stringLiteralTypesAsTags01.errors.txt @@ -2,12 +2,9 @@ tests/cases/conformance/types/stringLiteral/stringLiteralTypesAsTags01.ts(18,10) tests/cases/conformance/types/stringLiteral/stringLiteralTypesAsTags01.ts(19,10): error TS2382: Specialized overload signature is not assignable to any non-specialized signature. tests/cases/conformance/types/stringLiteral/stringLiteralTypesAsTags01.ts(20,10): error TS2394: Overload signature is not compatible with function implementation. tests/cases/conformance/types/stringLiteral/stringLiteralTypesAsTags01.ts(22,21): error TS2304: Cannot find name 'is'. -tests/cases/conformance/types/stringLiteral/stringLiteralTypesAsTags01.ts(25,5): error TS2322: Type '{ kind: string; a: number; }' is not assignable to type 'A'. - Types of property 'kind' are incompatible. - Type 'string' is not assignable to type '"A"'. -==== tests/cases/conformance/types/stringLiteral/stringLiteralTypesAsTags01.ts (5 errors) ==== +==== tests/cases/conformance/types/stringLiteral/stringLiteralTypesAsTags01.ts (4 errors) ==== type Kind = "A" | "B" @@ -41,10 +38,6 @@ tests/cases/conformance/types/stringLiteral/stringLiteralTypesAsTags01.ts(25,5): } let x: A = { - ~ -!!! error TS2322: Type '{ kind: string; a: number; }' is not assignable to type 'A'. -!!! error TS2322: Types of property 'kind' are incompatible. -!!! error TS2322: Type 'string' is not assignable to type '"A"'. kind: "A", a: 100, } diff --git a/tests/baselines/reference/stringLiteralTypesInVariableDeclarations01.errors.txt b/tests/baselines/reference/stringLiteralTypesInVariableDeclarations01.errors.txt index 3dd2adbbce0..1a639a1c222 100644 --- a/tests/baselines/reference/stringLiteralTypesInVariableDeclarations01.errors.txt +++ b/tests/baselines/reference/stringLiteralTypesInVariableDeclarations01.errors.txt @@ -1,17 +1,7 @@ tests/cases/conformance/types/stringLiteral/stringLiteralTypesInVariableDeclarations01.ts(5,7): error TS1155: 'const' declarations must be initialized -tests/cases/conformance/types/stringLiteral/stringLiteralTypesInVariableDeclarations01.ts(7,1): error TS2322: Type 'string' is not assignable to type '""'. -tests/cases/conformance/types/stringLiteral/stringLiteralTypesInVariableDeclarations01.ts(8,1): error TS2322: Type 'string' is not assignable to type '"foo"'. -tests/cases/conformance/types/stringLiteral/stringLiteralTypesInVariableDeclarations01.ts(9,1): error TS2322: Type 'string' is not assignable to type '"bar"'. -tests/cases/conformance/types/stringLiteral/stringLiteralTypesInVariableDeclarations01.ts(11,5): error TS2322: Type 'string' is not assignable to type '""'. -tests/cases/conformance/types/stringLiteral/stringLiteralTypesInVariableDeclarations01.ts(12,5): error TS2322: Type 'string' is not assignable to type '"foo"'. -tests/cases/conformance/types/stringLiteral/stringLiteralTypesInVariableDeclarations01.ts(13,5): error TS2322: Type 'string' is not assignable to type '"bar"'. -tests/cases/conformance/types/stringLiteral/stringLiteralTypesInVariableDeclarations01.ts(14,7): error TS2322: Type 'string' is not assignable to type '"baz"'. -tests/cases/conformance/types/stringLiteral/stringLiteralTypesInVariableDeclarations01.ts(16,1): error TS2322: Type 'string' is not assignable to type '""'. -tests/cases/conformance/types/stringLiteral/stringLiteralTypesInVariableDeclarations01.ts(17,1): error TS2322: Type 'string' is not assignable to type '"foo"'. -tests/cases/conformance/types/stringLiteral/stringLiteralTypesInVariableDeclarations01.ts(18,1): error TS2322: Type 'string' is not assignable to type '"bar"'. -==== tests/cases/conformance/types/stringLiteral/stringLiteralTypesInVariableDeclarations01.ts (11 errors) ==== +==== tests/cases/conformance/types/stringLiteral/stringLiteralTypesInVariableDeclarations01.ts (1 errors) ==== let a: ""; var b: "foo"; @@ -21,34 +11,14 @@ tests/cases/conformance/types/stringLiteral/stringLiteralTypesInVariableDeclarat !!! error TS1155: 'const' declarations must be initialized a = ""; - ~ -!!! error TS2322: Type 'string' is not assignable to type '""'. b = "foo"; - ~ -!!! error TS2322: Type 'string' is not assignable to type '"foo"'. c = "bar"; - ~ -!!! error TS2322: Type 'string' is not assignable to type '"bar"'. let e: "" = ""; - ~ -!!! error TS2322: Type 'string' is not assignable to type '""'. var f: "foo" = "foo"; - ~ -!!! error TS2322: Type 'string' is not assignable to type '"foo"'. let g: "bar" = "bar"; - ~ -!!! error TS2322: Type 'string' is not assignable to type '"bar"'. const h: "baz" = "baz"; - ~ -!!! error TS2322: Type 'string' is not assignable to type '"baz"'. e = ""; - ~ -!!! error TS2322: Type 'string' is not assignable to type '""'. f = "foo"; - ~ -!!! error TS2322: Type 'string' is not assignable to type '"foo"'. - g = "bar"; - ~ -!!! error TS2322: Type 'string' is not assignable to type '"bar"'. \ No newline at end of file + g = "bar"; \ No newline at end of file diff --git a/tests/baselines/reference/stringLiteralTypesOverloads01.errors.txt b/tests/baselines/reference/stringLiteralTypesOverloads01.errors.txt index 6e0fd982638..1592427208b 100644 --- a/tests/baselines/reference/stringLiteralTypesOverloads01.errors.txt +++ b/tests/baselines/reference/stringLiteralTypesOverloads01.errors.txt @@ -1,10 +1,7 @@ tests/cases/conformance/types/stringLiteral/stringLiteralTypesOverloads01.ts(11,10): error TS2354: No best common type exists among return expressions. -tests/cases/conformance/types/stringLiteral/stringLiteralTypesOverloads01.ts(32,7): error TS2322: Type 'string' is not assignable to type '"string"'. -tests/cases/conformance/types/stringLiteral/stringLiteralTypesOverloads01.ts(33,7): error TS2322: Type 'string' is not assignable to type '"number"'. -tests/cases/conformance/types/stringLiteral/stringLiteralTypesOverloads01.ts(34,7): error TS2322: Type 'string' is not assignable to type '"boolean"'. -==== tests/cases/conformance/types/stringLiteral/stringLiteralTypesOverloads01.ts (4 errors) ==== +==== tests/cases/conformance/types/stringLiteral/stringLiteralTypesOverloads01.ts (1 errors) ==== type PrimitiveName = 'string' | 'number' | 'boolean'; @@ -39,14 +36,8 @@ tests/cases/conformance/types/stringLiteral/stringLiteralTypesOverloads01.ts(34, } const string: "string" = "string" - ~~~~~~ -!!! error TS2322: Type 'string' is not assignable to type '"string"'. const number: "number" = "number" - ~~~~~~ -!!! error TS2322: Type 'string' is not assignable to type '"number"'. const boolean: "boolean" = "boolean" - ~~~~~~~ -!!! error TS2322: Type 'string' is not assignable to type '"boolean"'. const stringOrNumber = string || number; const stringOrBoolean = string || boolean; diff --git a/tests/baselines/reference/stringLiteralTypesOverloads02.errors.txt b/tests/baselines/reference/stringLiteralTypesOverloads02.errors.txt index ae9fb9ce4f6..995cf687b70 100644 --- a/tests/baselines/reference/stringLiteralTypesOverloads02.errors.txt +++ b/tests/baselines/reference/stringLiteralTypesOverloads02.errors.txt @@ -1,10 +1,7 @@ tests/cases/conformance/types/stringLiteral/stringLiteralTypesOverloads02.ts(9,10): error TS2354: No best common type exists among return expressions. -tests/cases/conformance/types/stringLiteral/stringLiteralTypesOverloads02.ts(30,7): error TS2322: Type 'string' is not assignable to type '"string"'. -tests/cases/conformance/types/stringLiteral/stringLiteralTypesOverloads02.ts(31,7): error TS2322: Type 'string' is not assignable to type '"number"'. -tests/cases/conformance/types/stringLiteral/stringLiteralTypesOverloads02.ts(32,7): error TS2322: Type 'string' is not assignable to type '"boolean"'. -==== tests/cases/conformance/types/stringLiteral/stringLiteralTypesOverloads02.ts (4 errors) ==== +==== tests/cases/conformance/types/stringLiteral/stringLiteralTypesOverloads02.ts (1 errors) ==== function getFalsyPrimitive(x: "string"): string; function getFalsyPrimitive(x: "number"): number; @@ -37,14 +34,8 @@ tests/cases/conformance/types/stringLiteral/stringLiteralTypesOverloads02.ts(32, } const string: "string" = "string" - ~~~~~~ -!!! error TS2322: Type 'string' is not assignable to type '"string"'. const number: "number" = "number" - ~~~~~~ -!!! error TS2322: Type 'string' is not assignable to type '"number"'. const boolean: "boolean" = "boolean" - ~~~~~~~ -!!! error TS2322: Type 'string' is not assignable to type '"boolean"'. const stringOrNumber = string || number; const stringOrBoolean = string || boolean; diff --git a/tests/baselines/reference/symbolProperty41.types b/tests/baselines/reference/symbolProperty41.types index 61b71dfe246..f312481ac04 100644 --- a/tests/baselines/reference/symbolProperty41.types +++ b/tests/baselines/reference/symbolProperty41.types @@ -49,5 +49,5 @@ c[Symbol.iterator]("hello"); >Symbol.iterator : symbol >Symbol : SymbolConstructor >iterator : symbol ->"hello" : string +>"hello" : "hello" diff --git a/tests/baselines/reference/typeArgumentsWithStringLiteralTypes01.errors.txt b/tests/baselines/reference/typeArgumentsWithStringLiteralTypes01.errors.txt index 413d2127003..69f8d6581a1 100644 --- a/tests/baselines/reference/typeArgumentsWithStringLiteralTypes01.errors.txt +++ b/tests/baselines/reference/typeArgumentsWithStringLiteralTypes01.errors.txt @@ -14,9 +14,9 @@ tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes0 Type 'string' is not assignable to type '"World"'. tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(48,30): error TS2345: Argument of type 'string' is not assignable to parameter of type '"Hello" | "World"'. Type 'string' is not assignable to type '"World"'. -tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(55,34): error TS2345: Argument of type 'string' is not assignable to parameter of type '"Hello"'. -tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(57,43): error TS2345: Argument of type 'string' is not assignable to parameter of type '"Hello"'. -tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(58,34): error TS2345: Argument of type 'string' is not assignable to parameter of type '"Hello"'. +tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(55,43): error TS2345: Argument of type 'string' is not assignable to parameter of type '"Hello"'. +tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(57,52): error TS2345: Argument of type 'string' is not assignable to parameter of type '"Hello"'. +tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(58,43): error TS2345: Argument of type 'string' is not assignable to parameter of type '"Hello"'. tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(61,5): error TS2322: Type 'string' is not assignable to type '"Hello"'. tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(63,5): error TS2322: Type 'string' is not assignable to type '"Hello"'. tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(75,5): error TS2322: Type '"Hello" | "World"' is not assignable to type '"Hello"'. @@ -25,7 +25,7 @@ tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes0 Type '"World"' is not assignable to type '"Hello"'. tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(87,43): error TS2345: Argument of type 'string' is not assignable to parameter of type '"Hello"'. tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(88,43): error TS2345: Argument of type 'string' is not assignable to parameter of type '"World"'. -tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(89,43): error TS2345: Argument of type 'string' is not assignable to parameter of type '"World"'. +tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(89,52): error TS2345: Argument of type 'string' is not assignable to parameter of type '"Hello"'. tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(93,5): error TS2322: Type 'string' is not assignable to type '"Hello" | "World"'. Type 'string' is not assignable to type '"World"'. tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(97,5): error TS2322: Type 'string' is not assignable to type '"Hello" | "World"'. @@ -119,14 +119,14 @@ tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes0 // as "Hello" (or "Hello" | "Hello"). export let a = fun1<"Hello">("Hello", "Hello"); export let b = fun1<"Hello">("Hello", "World"); - ~~~~~~~ + ~~~~~~~ !!! error TS2345: Argument of type 'string' is not assignable to parameter of type '"Hello"'. export let c = fun2<"Hello", "Hello">("Hello", "Hello"); export let d = fun2<"Hello", "Hello">("Hello", "World"); - ~~~~~~~ + ~~~~~~~ !!! error TS2345: Argument of type 'string' is not assignable to parameter of type '"Hello"'. export let e = fun3<"Hello">("Hello", "World"); - ~~~~~~~ + ~~~~~~~ !!! error TS2345: Argument of type 'string' is not assignable to parameter of type '"Hello"'. // Assignment from the returned value should cause an error. @@ -173,8 +173,8 @@ tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes0 ~~~~~~~ !!! error TS2345: Argument of type 'string' is not assignable to parameter of type '"World"'. export let d = fun2<"World", "Hello">("World", "World"); - ~~~~~~~ -!!! error TS2345: Argument of type 'string' is not assignable to parameter of type '"World"'. + ~~~~~~~ +!!! error TS2345: Argument of type 'string' is not assignable to parameter of type '"Hello"'. export let e = fun3<"Hello" | "World">("Hello", "World"); // Assignment from the returned value should cause an error. diff --git a/tests/baselines/reference/typesWithSpecializedCallSignatures.types b/tests/baselines/reference/typesWithSpecializedCallSignatures.types index 113e24456f9..b587ee7840e 100644 --- a/tests/baselines/reference/typesWithSpecializedCallSignatures.types +++ b/tests/baselines/reference/typesWithSpecializedCallSignatures.types @@ -125,7 +125,7 @@ var r1: Derived1 = c.foo('hi'); >c.foo : { (x: "hi"): Derived1; (x: "bye"): Derived2; (x: string): Base; } >c : C >foo : { (x: "hi"): Derived1; (x: "bye"): Derived2; (x: string): Base; } ->'hi' : string +>'hi' : "hi" var r2: Derived2 = c.foo('bye'); >r2 : Derived2 @@ -134,7 +134,7 @@ var r2: Derived2 = c.foo('bye'); >c.foo : { (x: "hi"): Derived1; (x: "bye"): Derived2; (x: string): Base; } >c : C >foo : { (x: "hi"): Derived1; (x: "bye"): Derived2; (x: string): Base; } ->'bye' : string +>'bye' : "bye" var r3: Base = c.foo('hm'); >r3 : Base diff --git a/tests/baselines/reference/typesWithSpecializedConstructSignatures.types b/tests/baselines/reference/typesWithSpecializedConstructSignatures.types index 2698439c527..3036c0cea71 100644 --- a/tests/baselines/reference/typesWithSpecializedConstructSignatures.types +++ b/tests/baselines/reference/typesWithSpecializedConstructSignatures.types @@ -100,14 +100,14 @@ var r1 = new C('hi'); >r1 : C >new C('hi') : C >C : typeof C ->'hi' : string +>'hi' : "hi" var r2: Derived2 = new i('bye'); >r2 : Derived2 >Derived2 : Derived2 >new i('bye') : Derived2 >i : I ->'bye' : string +>'bye' : "bye" var r3: Base = new a('hm'); >r3 : Base From 4b736da23172030a4a7970e06fa20cb094167535 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Fri, 2 Oct 2015 16:30:22 -0700 Subject: [PATCH 036/227] Fixed issue in test. --- .../types/stringLiteral/stringLiteralTypesAndTuples01.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/cases/conformance/types/stringLiteral/stringLiteralTypesAndTuples01.ts b/tests/cases/conformance/types/stringLiteral/stringLiteralTypesAndTuples01.ts index 7ac9aa3b427..388f4567ed7 100644 --- a/tests/cases/conformance/types/stringLiteral/stringLiteralTypesAndTuples01.ts +++ b/tests/cases/conformance/types/stringLiteral/stringLiteralTypesAndTuples01.ts @@ -4,7 +4,7 @@ let [hello, brave, newish, world] = ["Hello", "Brave", "New", "World"]; type RexOrRaptor = "t-rex" | "raptor" -let [im, a, dinosaur]: ["I'm", "a", Dinosaur] = ['I\'m', 'a', 't-rex']; +let [im, a, dinosaur]: ["I'm", "a", RexOrRaptor] = ['I\'m', 'a', 't-rex']; rawr(dinosaur); From fd5dec4ff12aceb9be710624a5dc6d871e576e58 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Fri, 2 Oct 2015 16:34:15 -0700 Subject: [PATCH 037/227] Accepted baselines. --- .../stringLiteralTypesAndTuples01.errors.txt | 25 -------- .../stringLiteralTypesAndTuples01.js | 4 +- .../stringLiteralTypesAndTuples01.symbols | 41 +++++++++++++ .../stringLiteralTypesAndTuples01.types | 59 +++++++++++++++++++ 4 files changed, 102 insertions(+), 27 deletions(-) delete mode 100644 tests/baselines/reference/stringLiteralTypesAndTuples01.errors.txt create mode 100644 tests/baselines/reference/stringLiteralTypesAndTuples01.symbols create mode 100644 tests/baselines/reference/stringLiteralTypesAndTuples01.types diff --git a/tests/baselines/reference/stringLiteralTypesAndTuples01.errors.txt b/tests/baselines/reference/stringLiteralTypesAndTuples01.errors.txt deleted file mode 100644 index 6a8704ce554..00000000000 --- a/tests/baselines/reference/stringLiteralTypesAndTuples01.errors.txt +++ /dev/null @@ -1,25 +0,0 @@ -tests/cases/conformance/types/stringLiteral/stringLiteralTypesAndTuples01.ts(6,37): error TS2304: Cannot find name 'Dinosaur'. - - -==== tests/cases/conformance/types/stringLiteral/stringLiteralTypesAndTuples01.ts (1 errors) ==== - - // Should all be strings. - let [hello, brave, newish, world] = ["Hello", "Brave", "New", "World"]; - - type RexOrRaptor = "t-rex" | "raptor" - let [im, a, dinosaur]: ["I'm", "a", Dinosaur] = ['I\'m', 'a', 't-rex']; - ~~~~~~~~ -!!! error TS2304: Cannot find name 'Dinosaur'. - - rawr(dinosaur); - - function rawr(dino: RexOrRaptor) { - if (dino === "t-rex") { - return "ROAAAAR!"; - } - if (dino === "raptor") { - return "yip yip!"; - } - - throw "Unexpected " + dino; - } \ No newline at end of file diff --git a/tests/baselines/reference/stringLiteralTypesAndTuples01.js b/tests/baselines/reference/stringLiteralTypesAndTuples01.js index 66e57b1eea5..ae02d12429a 100644 --- a/tests/baselines/reference/stringLiteralTypesAndTuples01.js +++ b/tests/baselines/reference/stringLiteralTypesAndTuples01.js @@ -4,7 +4,7 @@ let [hello, brave, newish, world] = ["Hello", "Brave", "New", "World"]; type RexOrRaptor = "t-rex" | "raptor" -let [im, a, dinosaur]: ["I'm", "a", Dinosaur] = ['I\'m', 'a', 't-rex']; +let [im, a, dinosaur]: ["I'm", "a", RexOrRaptor] = ['I\'m', 'a', 't-rex']; rawr(dinosaur); @@ -38,5 +38,5 @@ function rawr(dino) { //// [stringLiteralTypesAndTuples01.d.ts] declare let hello: string, brave: string, newish: string, world: string; declare type RexOrRaptor = "t-rex" | "raptor"; -declare let im: "I'm", a: "a", dinosaur: any; +declare let im: "I'm", a: "a", dinosaur: "t-rex" | "raptor"; declare function rawr(dino: RexOrRaptor): string; diff --git a/tests/baselines/reference/stringLiteralTypesAndTuples01.symbols b/tests/baselines/reference/stringLiteralTypesAndTuples01.symbols new file mode 100644 index 00000000000..b7ca53517ca --- /dev/null +++ b/tests/baselines/reference/stringLiteralTypesAndTuples01.symbols @@ -0,0 +1,41 @@ +=== tests/cases/conformance/types/stringLiteral/stringLiteralTypesAndTuples01.ts === + +// Should all be strings. +let [hello, brave, newish, world] = ["Hello", "Brave", "New", "World"]; +>hello : Symbol(hello, Decl(stringLiteralTypesAndTuples01.ts, 2, 5)) +>brave : Symbol(brave, Decl(stringLiteralTypesAndTuples01.ts, 2, 11)) +>newish : Symbol(newish, Decl(stringLiteralTypesAndTuples01.ts, 2, 18)) +>world : Symbol(world, Decl(stringLiteralTypesAndTuples01.ts, 2, 26)) + +type RexOrRaptor = "t-rex" | "raptor" +>RexOrRaptor : Symbol(RexOrRaptor, Decl(stringLiteralTypesAndTuples01.ts, 2, 71)) + +let [im, a, dinosaur]: ["I'm", "a", RexOrRaptor] = ['I\'m', 'a', 't-rex']; +>im : Symbol(im, Decl(stringLiteralTypesAndTuples01.ts, 5, 5)) +>a : Symbol(a, Decl(stringLiteralTypesAndTuples01.ts, 5, 8)) +>dinosaur : Symbol(dinosaur, Decl(stringLiteralTypesAndTuples01.ts, 5, 11)) +>RexOrRaptor : Symbol(RexOrRaptor, Decl(stringLiteralTypesAndTuples01.ts, 2, 71)) + +rawr(dinosaur); +>rawr : Symbol(rawr, Decl(stringLiteralTypesAndTuples01.ts, 7, 15)) +>dinosaur : Symbol(dinosaur, Decl(stringLiteralTypesAndTuples01.ts, 5, 11)) + +function rawr(dino: RexOrRaptor) { +>rawr : Symbol(rawr, Decl(stringLiteralTypesAndTuples01.ts, 7, 15)) +>dino : Symbol(dino, Decl(stringLiteralTypesAndTuples01.ts, 9, 14)) +>RexOrRaptor : Symbol(RexOrRaptor, Decl(stringLiteralTypesAndTuples01.ts, 2, 71)) + + if (dino === "t-rex") { +>dino : Symbol(dino, Decl(stringLiteralTypesAndTuples01.ts, 9, 14)) + + return "ROAAAAR!"; + } + if (dino === "raptor") { +>dino : Symbol(dino, Decl(stringLiteralTypesAndTuples01.ts, 9, 14)) + + return "yip yip!"; + } + + throw "Unexpected " + dino; +>dino : Symbol(dino, Decl(stringLiteralTypesAndTuples01.ts, 9, 14)) +} diff --git a/tests/baselines/reference/stringLiteralTypesAndTuples01.types b/tests/baselines/reference/stringLiteralTypesAndTuples01.types new file mode 100644 index 00000000000..740cf237412 --- /dev/null +++ b/tests/baselines/reference/stringLiteralTypesAndTuples01.types @@ -0,0 +1,59 @@ +=== tests/cases/conformance/types/stringLiteral/stringLiteralTypesAndTuples01.ts === + +// Should all be strings. +let [hello, brave, newish, world] = ["Hello", "Brave", "New", "World"]; +>hello : string +>brave : string +>newish : string +>world : string +>["Hello", "Brave", "New", "World"] : [string, string, string, string] +>"Hello" : string +>"Brave" : string +>"New" : string +>"World" : string + +type RexOrRaptor = "t-rex" | "raptor" +>RexOrRaptor : "t-rex" | "raptor" + +let [im, a, dinosaur]: ["I'm", "a", RexOrRaptor] = ['I\'m', 'a', 't-rex']; +>im : "I'm" +>a : "a" +>dinosaur : "t-rex" | "raptor" +>RexOrRaptor : "t-rex" | "raptor" +>['I\'m', 'a', 't-rex'] : ["I'm", "a", "t-rex" | "raptor"] +>'I\'m' : "I'm" +>'a' : "a" +>'t-rex' : "t-rex" | "raptor" + +rawr(dinosaur); +>rawr(dinosaur) : string +>rawr : (dino: "t-rex" | "raptor") => string +>dinosaur : "t-rex" | "raptor" + +function rawr(dino: RexOrRaptor) { +>rawr : (dino: "t-rex" | "raptor") => string +>dino : "t-rex" | "raptor" +>RexOrRaptor : "t-rex" | "raptor" + + if (dino === "t-rex") { +>dino === "t-rex" : boolean +>dino : "t-rex" | "raptor" +>"t-rex" : string + + return "ROAAAAR!"; +>"ROAAAAR!" : string + } + if (dino === "raptor") { +>dino === "raptor" : boolean +>dino : "t-rex" | "raptor" +>"raptor" : string + + return "yip yip!"; +>"yip yip!" : string + } + + throw "Unexpected " + dino; +>"Unexpected " + dino : string +>"Unexpected " : string +>dino : "t-rex" | "raptor" +} From 4c4087c6566becf9f7e8d9f38daafc0c07540ab8 Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Fri, 2 Oct 2015 17:03:29 -0700 Subject: [PATCH 038/227] Add compiler error for incompatible module formats --- Jakefile.js | 2 +- src/compiler/diagnosticMessages.json | 20 ++++++++++++-------- src/compiler/emitter.ts | 4 ++-- src/compiler/program.ts | 5 +++++ 4 files changed, 20 insertions(+), 11 deletions(-) diff --git a/Jakefile.js b/Jakefile.js index 943f2eff5ec..84f2d527857 100644 --- a/Jakefile.js +++ b/Jakefile.js @@ -225,7 +225,7 @@ var builtLocalCompiler = path.join(builtLocalDirectory, compilerFilename); function compileFile(outFile, sources, prereqs, prefixes, useBuiltCompiler, noOutFile, generateDeclarations, outDir, preserveConstEnums, keepComments, noResolve, stripInternal, callback) { file(outFile, prereqs, function() { var compilerPath = useBuiltCompiler ? builtLocalCompiler : LKGCompiler; - var options = "--module commonjs --noImplicitAny --noEmitOnError"; + var options = "--noImplicitAny --noEmitOnError"; // Keep comments when specifically requested // or when in debug mode. diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 6986d7ff5fb..0685eb44304 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -2262,14 +2262,6 @@ "code": 6063 }, - "Specify JSX code generation: 'preserve' or 'react'": { - "category": "Message", - "code": 6080 - }, - "Argument for '--jsx' must be 'preserve' or 'react'.": { - "category": "Message", - "code": 6081 - }, "Enables experimental support for ES7 decorators.": { "category": "Message", "code": 6065 @@ -2302,6 +2294,18 @@ "category": "Message", "code": 6072 }, + "Specify JSX code generation: 'preserve' or 'react'": { + "category": "Message", + "code": 6080 + }, + "Argument for '--jsx' must be 'preserve' or 'react'.": { + "category": "Message", + "code": 6081 + }, + "Only 'amd', 'umd', and 'system' modules are supported alongside --{0}.": { + "category": "Error", + "code": 6082 + }, "Variable '{0}' implicitly has an '{1}' type.": { "category": "Error", diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index 52b8760bbd1..7e4a1714d51 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -457,11 +457,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi }; let bundleEmitDelegates: Map<(node: SourceFile, startIndex: number, resolvePath?: boolean) => void> = { - [ModuleKind.ES6]: () => {}, + [ModuleKind.ES6]() { }, [ModuleKind.AMD]: emitAMDModule, [ModuleKind.System]: emitSystemModule, [ModuleKind.UMD]: emitUMDModule, - [ModuleKind.CommonJS]: () => {}, + [ModuleKind.CommonJS]() { }, }; if (compilerOptions.sourceMap || compilerOptions.inlineSourceMap) { diff --git a/src/compiler/program.ts b/src/compiler/program.ts index f54906d85ee..163ddfa36c1 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -1063,6 +1063,11 @@ namespace ts { programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Cannot_compile_modules_into_es6_when_targeting_ES5_or_lower)); } + // Cannot specify module gen that isn't amd, umd, or system with --out + if (outFile && options.module && options.module !== ModuleKind.AMD && options.module !== ModuleKind.UMD && options.module !== ModuleKind.System) { + programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Only_amd_umd_and_system_modules_are_supported_alongside_0, options.out ? "out" : "outFile")); + } + if (options.noEmit) { if (options.out) { programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_with_option_1, "noEmit", "out")); From 145fa0cdf6b8351b2f3fd6d666bb3ec815d87e0e Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Fri, 2 Oct 2015 17:11:03 -0700 Subject: [PATCH 039/227] Accept baselines --- .../baselines/reference/out-flag2.errors.txt | 10 +++++ tests/baselines/reference/out-flag2.symbols | 9 ---- tests/baselines/reference/out-flag2.types | 9 ---- .../baselines/reference/out-flag3.errors.txt | 2 + .../amd/bin/test.js | 37 +++++++++++++++ .../node/bin/test.js | 23 ++++++++++ ...MixedSubfolderSpecifyOutputFile.errors.txt | 36 +++++++++++++++ .../amd/bin/outAndOutDirFile.js | 37 +++++++++++++++ .../node/bin/outAndOutDirFile.js | 23 ++++++++++ ...ifyOutputFileAndOutputDirectory.errors.txt | 36 +++++++++++++++ .../amd/bin/test.js | 45 +++++++++++++++++++ .../node/bin/test.js | 1 + ...uleMultifolderSpecifyOutputFile.errors.txt | 39 ++++++++++++++++ .../amd/bin/test.js | 30 +++++++++++++ .../node/bin/test.js | 1 + ...thModuleSimpleSpecifyOutputFile.errors.txt | 27 +++++++++++ .../amd/bin/test.js | 30 +++++++++++++ .../node/bin/test.js | 1 + ...oduleSubfolderSpecifyOutputFile.errors.txt | 27 +++++++++++ ...athMultifolderSpecifyOutputFile.errors.txt | 36 +++++++++++++++ ...lutePathSimpleSpecifyOutputFile.errors.txt | 25 +++++++++++ ...PathSingleFileSpecifyOutputFile.errors.txt | 14 ++++++ ...ePathSubfolderSpecifyOutputFile.errors.txt | 25 +++++++++++ .../amd/bin/test.js | 37 +++++++++++++++ .../node/bin/test.js | 23 ++++++++++ ...MixedSubfolderSpecifyOutputFile.errors.txt | 36 +++++++++++++++ .../amd/bin/outAndOutDirFile.js | 37 +++++++++++++++ .../node/bin/outAndOutDirFile.js | 23 ++++++++++ ...ifyOutputFileAndOutputDirectory.errors.txt | 36 +++++++++++++++ .../amd/bin/test.js | 45 +++++++++++++++++++ .../node/bin/test.js | 1 + ...uleMultifolderSpecifyOutputFile.errors.txt | 39 ++++++++++++++++ .../amd/bin/test.js | 30 +++++++++++++ .../node/bin/test.js | 1 + ...thModuleSimpleSpecifyOutputFile.errors.txt | 27 +++++++++++ .../amd/bin/test.js | 30 +++++++++++++ .../node/bin/test.js | 1 + ...oduleSubfolderSpecifyOutputFile.errors.txt | 27 +++++++++++ .../amd/bin/test.js | 33 ++++++++++++++ .../node/bin/test.js | 33 ++++++++++++++ ...athMultifolderSpecifyOutputFile.errors.txt | 36 +++++++++++++++ ...tivePathSimpleSpecifyOutputFile.errors.txt | 25 +++++++++++ ...PathSingleFileSpecifyOutputFile.errors.txt | 14 ++++++ ...ePathSubfolderSpecifyOutputFile.errors.txt | 25 +++++++++++ .../amd/bin/test.js | 37 +++++++++++++++ .../node/bin/test.js | 23 ++++++++++ ...MixedSubfolderSpecifyOutputFile.errors.txt | 36 +++++++++++++++ .../amd/bin/outAndOutDirFile.js | 37 +++++++++++++++ .../node/bin/outAndOutDirFile.js | 23 ++++++++++ ...ifyOutputFileAndOutputDirectory.errors.txt | 36 +++++++++++++++ .../amd/bin/test.js | 45 +++++++++++++++++++ .../node/bin/test.js | 1 + ...uleMultifolderSpecifyOutputFile.errors.txt | 39 ++++++++++++++++ .../amd/bin/test.js | 30 +++++++++++++ .../node/bin/test.js | 1 + ...rlModuleSimpleSpecifyOutputFile.errors.txt | 27 +++++++++++ .../amd/bin/test.js | 30 +++++++++++++ .../node/bin/test.js | 1 + ...oduleSubfolderSpecifyOutputFile.errors.txt | 27 +++++++++++ ...UrlMultifolderSpecifyOutputFile.errors.txt | 36 +++++++++++++++ ...prootUrlSimpleSpecifyOutputFile.errors.txt | 25 +++++++++++ ...tUrlSingleFileSpecifyOutputFile.errors.txt | 14 ++++++ ...otUrlSubfolderSpecifyOutputFile.errors.txt | 25 +++++++++++ .../amd/bin/test.js | 37 +++++++++++++++ .../node/bin/test.js | 23 ++++++++++ ...MixedSubfolderSpecifyOutputFile.errors.txt | 36 +++++++++++++++ .../amd/bin/outAndOutDirFile.js | 37 +++++++++++++++ .../node/bin/outAndOutDirFile.js | 23 ++++++++++ ...ifyOutputFileAndOutputDirectory.errors.txt | 36 +++++++++++++++ .../amd/bin/test.js | 45 +++++++++++++++++++ .../node/bin/test.js | 1 + ...uleMultifolderSpecifyOutputFile.errors.txt | 39 ++++++++++++++++ .../amd/bin/test.js | 30 +++++++++++++ .../node/bin/test.js | 1 + ...rlModuleSimpleSpecifyOutputFile.errors.txt | 27 +++++++++++ .../amd/bin/test.js | 30 +++++++++++++ .../node/bin/test.js | 1 + ...oduleSubfolderSpecifyOutputFile.errors.txt | 27 +++++++++++ ...UrlMultifolderSpecifyOutputFile.errors.txt | 36 +++++++++++++++ ...erootUrlSimpleSpecifyOutputFile.errors.txt | 25 +++++++++++ ...tUrlSingleFileSpecifyOutputFile.errors.txt | 14 ++++++ ...otUrlSubfolderSpecifyOutputFile.errors.txt | 25 +++++++++++ .../amd/bin/test.d.ts | 13 ++++++ ...MixedSubfolderSpecifyOutputFile.errors.txt | 36 +++++++++++++++ .../amd/bin/outAndOutDirFile.d.ts | 13 ++++++ ...ifyOutputFileAndOutputDirectory.errors.txt | 36 +++++++++++++++ .../amd/bin/test.d.ts | 0 ...uleMultifolderSpecifyOutputFile.errors.txt | 39 ++++++++++++++++ .../amd/bin/test.d.ts | 0 ...utModuleSimpleSpecifyOutputFile.errors.txt | 27 +++++++++++ .../amd/bin/test.d.ts | 0 ...oduleSubfolderSpecifyOutputFile.errors.txt | 27 +++++++++++ ...outMultifolderSpecifyOutputFile.errors.txt | 36 +++++++++++++++ .../outSimpleSpecifyOutputFile.errors.txt | 25 +++++++++++ .../outSingleFileSpecifyOutputFile.errors.txt | 14 ++++++ .../outSubfolderSpecifyOutputFile.errors.txt | 25 +++++++++++ .../prologueEmit/node/prologueEmit.errors.txt | 14 ++++++ .../amd/bin/test.js | 37 +++++++++++++++ .../node/bin/test.js | 23 ++++++++++ ...MixedSubfolderSpecifyOutputFile.errors.txt | 36 +++++++++++++++ .../amd/bin/outAndOutDirFile.js | 37 +++++++++++++++ .../node/bin/outAndOutDirFile.js | 23 ++++++++++ ...ifyOutputFileAndOutputDirectory.errors.txt | 36 +++++++++++++++ .../amd/bin/test.js | 45 +++++++++++++++++++ .../node/bin/test.js | 1 + ...uleMultifolderSpecifyOutputFile.errors.txt | 39 ++++++++++++++++ .../amd/bin/test.js | 30 +++++++++++++ .../node/bin/test.js | 1 + ...thModuleSimpleSpecifyOutputFile.errors.txt | 27 +++++++++++ .../amd/bin/test.js | 30 +++++++++++++ .../node/bin/test.js | 1 + ...oduleSubfolderSpecifyOutputFile.errors.txt | 27 +++++++++++ ...athMultifolderSpecifyOutputFile.errors.txt | 36 +++++++++++++++ ...lutePathSimpleSpecifyOutputFile.errors.txt | 25 +++++++++++ ...PathSingleFileSpecifyOutputFile.errors.txt | 14 ++++++ ...ePathSubfolderSpecifyOutputFile.errors.txt | 25 +++++++++++ .../amd/bin/test.js | 37 +++++++++++++++ .../node/bin/test.js | 23 ++++++++++ ...MixedSubfolderSpecifyOutputFile.errors.txt | 36 +++++++++++++++ .../amd/bin/outAndOutDirFile.js | 37 +++++++++++++++ .../node/bin/outAndOutDirFile.js | 23 ++++++++++ ...ifyOutputFileAndOutputDirectory.errors.txt | 36 +++++++++++++++ .../amd/bin/test.js | 45 +++++++++++++++++++ .../node/bin/test.js | 1 + ...uleMultifolderSpecifyOutputFile.errors.txt | 39 ++++++++++++++++ .../amd/bin/test.js | 30 +++++++++++++ .../node/bin/test.js | 1 + ...thModuleSimpleSpecifyOutputFile.errors.txt | 27 +++++++++++ .../amd/bin/test.js | 30 +++++++++++++ .../node/bin/test.js | 1 + ...oduleSubfolderSpecifyOutputFile.errors.txt | 27 +++++++++++ ...athMultifolderSpecifyOutputFile.errors.txt | 36 +++++++++++++++ ...tivePathSimpleSpecifyOutputFile.errors.txt | 25 +++++++++++ ...PathSingleFileSpecifyOutputFile.errors.txt | 14 ++++++ ...ePathSubfolderSpecifyOutputFile.errors.txt | 25 +++++++++++ .../amd/bin/test.js | 37 +++++++++++++++ .../node/bin/test.js | 23 ++++++++++ ...MixedSubfolderSpecifyOutputFile.errors.txt | 36 +++++++++++++++ .../amd/bin/outAndOutDirFile.js | 37 +++++++++++++++ .../node/bin/outAndOutDirFile.js | 23 ++++++++++ ...ifyOutputFileAndOutputDirectory.errors.txt | 36 +++++++++++++++ .../amd/bin/test.js | 45 +++++++++++++++++++ .../node/bin/test.js | 1 + ...uleMultifolderSpecifyOutputFile.errors.txt | 39 ++++++++++++++++ .../amd/bin/test.js | 30 +++++++++++++ .../node/bin/test.js | 1 + ...apModuleSimpleSpecifyOutputFile.errors.txt | 27 +++++++++++ .../amd/bin/test.js | 30 +++++++++++++ .../node/bin/test.js | 1 + ...oduleSubfolderSpecifyOutputFile.errors.txt | 27 +++++++++++ ...mapMultifolderSpecifyOutputFile.errors.txt | 36 +++++++++++++++ ...ourcemapSimpleSpecifyOutputFile.errors.txt | 25 +++++++++++ ...emapSingleFileSpecifyOutputFile.errors.txt | 14 ++++++ ...cemapSubfolderSpecifyOutputFile.errors.txt | 25 +++++++++++ .../amd/bin/test.js | 37 +++++++++++++++ .../node/bin/test.js | 23 ++++++++++ ...MixedSubfolderSpecifyOutputFile.errors.txt | 36 +++++++++++++++ .../amd/bin/outAndOutDirFile.js | 37 +++++++++++++++ .../node/bin/outAndOutDirFile.js | 23 ++++++++++ ...ifyOutputFileAndOutputDirectory.errors.txt | 36 +++++++++++++++ .../amd/bin/test.js | 45 +++++++++++++++++++ .../node/bin/test.js | 1 + ...uleMultifolderSpecifyOutputFile.errors.txt | 39 ++++++++++++++++ .../amd/bin/test.js | 30 +++++++++++++ .../node/bin/test.js | 1 + ...rlModuleSimpleSpecifyOutputFile.errors.txt | 27 +++++++++++ .../amd/bin/test.js | 30 +++++++++++++ .../node/bin/test.js | 1 + ...oduleSubfolderSpecifyOutputFile.errors.txt | 27 +++++++++++ ...UrlMultifolderSpecifyOutputFile.errors.txt | 36 +++++++++++++++ ...erootUrlSimpleSpecifyOutputFile.errors.txt | 25 +++++++++++ ...tUrlSingleFileSpecifyOutputFile.errors.txt | 14 ++++++ ...otUrlSubfolderSpecifyOutputFile.errors.txt | 25 +++++++++++ 173 files changed, 4327 insertions(+), 18 deletions(-) create mode 100644 tests/baselines/reference/out-flag2.errors.txt delete mode 100644 tests/baselines/reference/out-flag2.symbols delete mode 100644 tests/baselines/reference/out-flag2.types create mode 100644 tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFile/amd/bin/test.js create mode 100644 tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFile/node/bin/test.js create mode 100644 tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFile/node/mapRootAbsolutePathMixedSubfolderSpecifyOutputFile.errors.txt create mode 100644 tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.js create mode 100644 tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.js create mode 100644 tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/mapRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory.errors.txt create mode 100644 tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderSpecifyOutputFile/amd/bin/test.js create mode 100644 tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderSpecifyOutputFile/node/bin/test.js create mode 100644 tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderSpecifyOutputFile/node/mapRootAbsolutePathModuleMultifolderSpecifyOutputFile.errors.txt create mode 100644 tests/baselines/reference/project/mapRootAbsolutePathModuleSimpleSpecifyOutputFile/amd/bin/test.js create mode 100644 tests/baselines/reference/project/mapRootAbsolutePathModuleSimpleSpecifyOutputFile/node/bin/test.js create mode 100644 tests/baselines/reference/project/mapRootAbsolutePathModuleSimpleSpecifyOutputFile/node/mapRootAbsolutePathModuleSimpleSpecifyOutputFile.errors.txt create mode 100644 tests/baselines/reference/project/mapRootAbsolutePathModuleSubfolderSpecifyOutputFile/amd/bin/test.js create mode 100644 tests/baselines/reference/project/mapRootAbsolutePathModuleSubfolderSpecifyOutputFile/node/bin/test.js create mode 100644 tests/baselines/reference/project/mapRootAbsolutePathModuleSubfolderSpecifyOutputFile/node/mapRootAbsolutePathModuleSubfolderSpecifyOutputFile.errors.txt create mode 100644 tests/baselines/reference/project/mapRootAbsolutePathMultifolderSpecifyOutputFile/node/mapRootAbsolutePathMultifolderSpecifyOutputFile.errors.txt create mode 100644 tests/baselines/reference/project/mapRootAbsolutePathSimpleSpecifyOutputFile/node/mapRootAbsolutePathSimpleSpecifyOutputFile.errors.txt create mode 100644 tests/baselines/reference/project/mapRootAbsolutePathSingleFileSpecifyOutputFile/node/mapRootAbsolutePathSingleFileSpecifyOutputFile.errors.txt create mode 100644 tests/baselines/reference/project/mapRootAbsolutePathSubfolderSpecifyOutputFile/node/mapRootAbsolutePathSubfolderSpecifyOutputFile.errors.txt create mode 100644 tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFile/amd/bin/test.js create mode 100644 tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFile/node/bin/test.js create mode 100644 tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFile/node/mapRootRelativePathMixedSubfolderSpecifyOutputFile.errors.txt create mode 100644 tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.js create mode 100644 tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.js create mode 100644 tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/mapRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory.errors.txt create mode 100644 tests/baselines/reference/project/mapRootRelativePathModuleMultifolderSpecifyOutputFile/amd/bin/test.js create mode 100644 tests/baselines/reference/project/mapRootRelativePathModuleMultifolderSpecifyOutputFile/node/bin/test.js create mode 100644 tests/baselines/reference/project/mapRootRelativePathModuleMultifolderSpecifyOutputFile/node/mapRootRelativePathModuleMultifolderSpecifyOutputFile.errors.txt create mode 100644 tests/baselines/reference/project/mapRootRelativePathModuleSimpleSpecifyOutputFile/amd/bin/test.js create mode 100644 tests/baselines/reference/project/mapRootRelativePathModuleSimpleSpecifyOutputFile/node/bin/test.js create mode 100644 tests/baselines/reference/project/mapRootRelativePathModuleSimpleSpecifyOutputFile/node/mapRootRelativePathModuleSimpleSpecifyOutputFile.errors.txt create mode 100644 tests/baselines/reference/project/mapRootRelativePathModuleSubfolderSpecifyOutputFile/amd/bin/test.js create mode 100644 tests/baselines/reference/project/mapRootRelativePathModuleSubfolderSpecifyOutputFile/node/bin/test.js create mode 100644 tests/baselines/reference/project/mapRootRelativePathModuleSubfolderSpecifyOutputFile/node/mapRootRelativePathModuleSubfolderSpecifyOutputFile.errors.txt create mode 100644 tests/baselines/reference/project/mapRootRelativePathMultifolderSpecifyOutputFile/amd/bin/test.js create mode 100644 tests/baselines/reference/project/mapRootRelativePathMultifolderSpecifyOutputFile/node/bin/test.js create mode 100644 tests/baselines/reference/project/mapRootRelativePathMultifolderSpecifyOutputFile/node/mapRootRelativePathMultifolderSpecifyOutputFile.errors.txt create mode 100644 tests/baselines/reference/project/mapRootRelativePathSimpleSpecifyOutputFile/node/mapRootRelativePathSimpleSpecifyOutputFile.errors.txt create mode 100644 tests/baselines/reference/project/mapRootRelativePathSingleFileSpecifyOutputFile/node/mapRootRelativePathSingleFileSpecifyOutputFile.errors.txt create mode 100644 tests/baselines/reference/project/mapRootRelativePathSubfolderSpecifyOutputFile/node/mapRootRelativePathSubfolderSpecifyOutputFile.errors.txt create mode 100644 tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFile/amd/bin/test.js create mode 100644 tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFile/node/bin/test.js create mode 100644 tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFile/node/maprootUrlMixedSubfolderSpecifyOutputFile.errors.txt create mode 100644 tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.js create mode 100644 tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.js create mode 100644 tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/maprootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory.errors.txt create mode 100644 tests/baselines/reference/project/maprootUrlModuleMultifolderSpecifyOutputFile/amd/bin/test.js create mode 100644 tests/baselines/reference/project/maprootUrlModuleMultifolderSpecifyOutputFile/node/bin/test.js create mode 100644 tests/baselines/reference/project/maprootUrlModuleMultifolderSpecifyOutputFile/node/maprootUrlModuleMultifolderSpecifyOutputFile.errors.txt create mode 100644 tests/baselines/reference/project/maprootUrlModuleSimpleSpecifyOutputFile/amd/bin/test.js create mode 100644 tests/baselines/reference/project/maprootUrlModuleSimpleSpecifyOutputFile/node/bin/test.js create mode 100644 tests/baselines/reference/project/maprootUrlModuleSimpleSpecifyOutputFile/node/maprootUrlModuleSimpleSpecifyOutputFile.errors.txt create mode 100644 tests/baselines/reference/project/maprootUrlModuleSubfolderSpecifyOutputFile/amd/bin/test.js create mode 100644 tests/baselines/reference/project/maprootUrlModuleSubfolderSpecifyOutputFile/node/bin/test.js create mode 100644 tests/baselines/reference/project/maprootUrlModuleSubfolderSpecifyOutputFile/node/maprootUrlModuleSubfolderSpecifyOutputFile.errors.txt create mode 100644 tests/baselines/reference/project/maprootUrlMultifolderSpecifyOutputFile/node/maprootUrlMultifolderSpecifyOutputFile.errors.txt create mode 100644 tests/baselines/reference/project/maprootUrlSimpleSpecifyOutputFile/node/maprootUrlSimpleSpecifyOutputFile.errors.txt create mode 100644 tests/baselines/reference/project/maprootUrlSingleFileSpecifyOutputFile/node/maprootUrlSingleFileSpecifyOutputFile.errors.txt create mode 100644 tests/baselines/reference/project/maprootUrlSubfolderSpecifyOutputFile/node/maprootUrlSubfolderSpecifyOutputFile.errors.txt create mode 100644 tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFile/amd/bin/test.js create mode 100644 tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFile/node/bin/test.js create mode 100644 tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFile/node/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFile.errors.txt create mode 100644 tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.js create mode 100644 tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.js create mode 100644 tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory.errors.txt create mode 100644 tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputFile/amd/bin/test.js create mode 100644 tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputFile/node/bin/test.js create mode 100644 tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputFile/node/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputFile.errors.txt create mode 100644 tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSimpleSpecifyOutputFile/amd/bin/test.js create mode 100644 tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSimpleSpecifyOutputFile/node/bin/test.js create mode 100644 tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSimpleSpecifyOutputFile/node/maprootUrlsourcerootUrlModuleSimpleSpecifyOutputFile.errors.txt create mode 100644 tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSubfolderSpecifyOutputFile/amd/bin/test.js create mode 100644 tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSubfolderSpecifyOutputFile/node/bin/test.js create mode 100644 tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSubfolderSpecifyOutputFile/node/maprootUrlsourcerootUrlModuleSubfolderSpecifyOutputFile.errors.txt create mode 100644 tests/baselines/reference/project/maprootUrlsourcerootUrlMultifolderSpecifyOutputFile/node/maprootUrlsourcerootUrlMultifolderSpecifyOutputFile.errors.txt create mode 100644 tests/baselines/reference/project/maprootUrlsourcerootUrlSimpleSpecifyOutputFile/node/maprootUrlsourcerootUrlSimpleSpecifyOutputFile.errors.txt create mode 100644 tests/baselines/reference/project/maprootUrlsourcerootUrlSingleFileSpecifyOutputFile/node/maprootUrlsourcerootUrlSingleFileSpecifyOutputFile.errors.txt create mode 100644 tests/baselines/reference/project/maprootUrlsourcerootUrlSubfolderSpecifyOutputFile/node/maprootUrlsourcerootUrlSubfolderSpecifyOutputFile.errors.txt create mode 100644 tests/baselines/reference/project/outMixedSubfolderSpecifyOutputFile/amd/bin/test.d.ts create mode 100644 tests/baselines/reference/project/outMixedSubfolderSpecifyOutputFile/node/outMixedSubfolderSpecifyOutputFile.errors.txt create mode 100644 tests/baselines/reference/project/outMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.d.ts create mode 100644 tests/baselines/reference/project/outMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/outMixedSubfolderSpecifyOutputFileAndOutputDirectory.errors.txt create mode 100644 tests/baselines/reference/project/outModuleMultifolderSpecifyOutputFile/amd/bin/test.d.ts create mode 100644 tests/baselines/reference/project/outModuleMultifolderSpecifyOutputFile/node/outModuleMultifolderSpecifyOutputFile.errors.txt create mode 100644 tests/baselines/reference/project/outModuleSimpleSpecifyOutputFile/amd/bin/test.d.ts create mode 100644 tests/baselines/reference/project/outModuleSimpleSpecifyOutputFile/node/outModuleSimpleSpecifyOutputFile.errors.txt create mode 100644 tests/baselines/reference/project/outModuleSubfolderSpecifyOutputFile/amd/bin/test.d.ts create mode 100644 tests/baselines/reference/project/outModuleSubfolderSpecifyOutputFile/node/outModuleSubfolderSpecifyOutputFile.errors.txt create mode 100644 tests/baselines/reference/project/outMultifolderSpecifyOutputFile/node/outMultifolderSpecifyOutputFile.errors.txt create mode 100644 tests/baselines/reference/project/outSimpleSpecifyOutputFile/node/outSimpleSpecifyOutputFile.errors.txt create mode 100644 tests/baselines/reference/project/outSingleFileSpecifyOutputFile/node/outSingleFileSpecifyOutputFile.errors.txt create mode 100644 tests/baselines/reference/project/outSubfolderSpecifyOutputFile/node/outSubfolderSpecifyOutputFile.errors.txt create mode 100644 tests/baselines/reference/project/prologueEmit/node/prologueEmit.errors.txt create mode 100644 tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFile/amd/bin/test.js create mode 100644 tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFile/node/bin/test.js create mode 100644 tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFile/node/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFile.errors.txt create mode 100644 tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.js create mode 100644 tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.js create mode 100644 tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory.errors.txt create mode 100644 tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderSpecifyOutputFile/amd/bin/test.js create mode 100644 tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderSpecifyOutputFile/node/bin/test.js create mode 100644 tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderSpecifyOutputFile/node/sourceRootAbsolutePathModuleMultifolderSpecifyOutputFile.errors.txt create mode 100644 tests/baselines/reference/project/sourceRootAbsolutePathModuleSimpleSpecifyOutputFile/amd/bin/test.js create mode 100644 tests/baselines/reference/project/sourceRootAbsolutePathModuleSimpleSpecifyOutputFile/node/bin/test.js create mode 100644 tests/baselines/reference/project/sourceRootAbsolutePathModuleSimpleSpecifyOutputFile/node/sourceRootAbsolutePathModuleSimpleSpecifyOutputFile.errors.txt create mode 100644 tests/baselines/reference/project/sourceRootAbsolutePathModuleSubfolderSpecifyOutputFile/amd/bin/test.js create mode 100644 tests/baselines/reference/project/sourceRootAbsolutePathModuleSubfolderSpecifyOutputFile/node/bin/test.js create mode 100644 tests/baselines/reference/project/sourceRootAbsolutePathModuleSubfolderSpecifyOutputFile/node/sourceRootAbsolutePathModuleSubfolderSpecifyOutputFile.errors.txt create mode 100644 tests/baselines/reference/project/sourceRootAbsolutePathMultifolderSpecifyOutputFile/node/sourceRootAbsolutePathMultifolderSpecifyOutputFile.errors.txt create mode 100644 tests/baselines/reference/project/sourceRootAbsolutePathSimpleSpecifyOutputFile/node/sourceRootAbsolutePathSimpleSpecifyOutputFile.errors.txt create mode 100644 tests/baselines/reference/project/sourceRootAbsolutePathSingleFileSpecifyOutputFile/node/sourceRootAbsolutePathSingleFileSpecifyOutputFile.errors.txt create mode 100644 tests/baselines/reference/project/sourceRootAbsolutePathSubfolderSpecifyOutputFile/node/sourceRootAbsolutePathSubfolderSpecifyOutputFile.errors.txt create mode 100644 tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFile/amd/bin/test.js create mode 100644 tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFile/node/bin/test.js create mode 100644 tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFile/node/sourceRootRelativePathMixedSubfolderSpecifyOutputFile.errors.txt create mode 100644 tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.js create mode 100644 tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.js create mode 100644 tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/sourceRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory.errors.txt create mode 100644 tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderSpecifyOutputFile/amd/bin/test.js create mode 100644 tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderSpecifyOutputFile/node/bin/test.js create mode 100644 tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderSpecifyOutputFile/node/sourceRootRelativePathModuleMultifolderSpecifyOutputFile.errors.txt create mode 100644 tests/baselines/reference/project/sourceRootRelativePathModuleSimpleSpecifyOutputFile/amd/bin/test.js create mode 100644 tests/baselines/reference/project/sourceRootRelativePathModuleSimpleSpecifyOutputFile/node/bin/test.js create mode 100644 tests/baselines/reference/project/sourceRootRelativePathModuleSimpleSpecifyOutputFile/node/sourceRootRelativePathModuleSimpleSpecifyOutputFile.errors.txt create mode 100644 tests/baselines/reference/project/sourceRootRelativePathModuleSubfolderSpecifyOutputFile/amd/bin/test.js create mode 100644 tests/baselines/reference/project/sourceRootRelativePathModuleSubfolderSpecifyOutputFile/node/bin/test.js create mode 100644 tests/baselines/reference/project/sourceRootRelativePathModuleSubfolderSpecifyOutputFile/node/sourceRootRelativePathModuleSubfolderSpecifyOutputFile.errors.txt create mode 100644 tests/baselines/reference/project/sourceRootRelativePathMultifolderSpecifyOutputFile/node/sourceRootRelativePathMultifolderSpecifyOutputFile.errors.txt create mode 100644 tests/baselines/reference/project/sourceRootRelativePathSimpleSpecifyOutputFile/node/sourceRootRelativePathSimpleSpecifyOutputFile.errors.txt create mode 100644 tests/baselines/reference/project/sourceRootRelativePathSingleFileSpecifyOutputFile/node/sourceRootRelativePathSingleFileSpecifyOutputFile.errors.txt create mode 100644 tests/baselines/reference/project/sourceRootRelativePathSubfolderSpecifyOutputFile/node/sourceRootRelativePathSubfolderSpecifyOutputFile.errors.txt create mode 100644 tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFile/amd/bin/test.js create mode 100644 tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFile/node/bin/test.js create mode 100644 tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFile/node/sourcemapMixedSubfolderSpecifyOutputFile.errors.txt create mode 100644 tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.js create mode 100644 tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.js create mode 100644 tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/sourcemapMixedSubfolderSpecifyOutputFileAndOutputDirectory.errors.txt create mode 100644 tests/baselines/reference/project/sourcemapModuleMultifolderSpecifyOutputFile/amd/bin/test.js create mode 100644 tests/baselines/reference/project/sourcemapModuleMultifolderSpecifyOutputFile/node/bin/test.js create mode 100644 tests/baselines/reference/project/sourcemapModuleMultifolderSpecifyOutputFile/node/sourcemapModuleMultifolderSpecifyOutputFile.errors.txt create mode 100644 tests/baselines/reference/project/sourcemapModuleSimpleSpecifyOutputFile/amd/bin/test.js create mode 100644 tests/baselines/reference/project/sourcemapModuleSimpleSpecifyOutputFile/node/bin/test.js create mode 100644 tests/baselines/reference/project/sourcemapModuleSimpleSpecifyOutputFile/node/sourcemapModuleSimpleSpecifyOutputFile.errors.txt create mode 100644 tests/baselines/reference/project/sourcemapModuleSubfolderSpecifyOutputFile/amd/bin/test.js create mode 100644 tests/baselines/reference/project/sourcemapModuleSubfolderSpecifyOutputFile/node/bin/test.js create mode 100644 tests/baselines/reference/project/sourcemapModuleSubfolderSpecifyOutputFile/node/sourcemapModuleSubfolderSpecifyOutputFile.errors.txt create mode 100644 tests/baselines/reference/project/sourcemapMultifolderSpecifyOutputFile/node/sourcemapMultifolderSpecifyOutputFile.errors.txt create mode 100644 tests/baselines/reference/project/sourcemapSimpleSpecifyOutputFile/node/sourcemapSimpleSpecifyOutputFile.errors.txt create mode 100644 tests/baselines/reference/project/sourcemapSingleFileSpecifyOutputFile/node/sourcemapSingleFileSpecifyOutputFile.errors.txt create mode 100644 tests/baselines/reference/project/sourcemapSubfolderSpecifyOutputFile/node/sourcemapSubfolderSpecifyOutputFile.errors.txt create mode 100644 tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFile/amd/bin/test.js create mode 100644 tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFile/node/bin/test.js create mode 100644 tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFile/node/sourcerootUrlMixedSubfolderSpecifyOutputFile.errors.txt create mode 100644 tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.js create mode 100644 tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.js create mode 100644 tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/sourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory.errors.txt create mode 100644 tests/baselines/reference/project/sourcerootUrlModuleMultifolderSpecifyOutputFile/amd/bin/test.js create mode 100644 tests/baselines/reference/project/sourcerootUrlModuleMultifolderSpecifyOutputFile/node/bin/test.js create mode 100644 tests/baselines/reference/project/sourcerootUrlModuleMultifolderSpecifyOutputFile/node/sourcerootUrlModuleMultifolderSpecifyOutputFile.errors.txt create mode 100644 tests/baselines/reference/project/sourcerootUrlModuleSimpleSpecifyOutputFile/amd/bin/test.js create mode 100644 tests/baselines/reference/project/sourcerootUrlModuleSimpleSpecifyOutputFile/node/bin/test.js create mode 100644 tests/baselines/reference/project/sourcerootUrlModuleSimpleSpecifyOutputFile/node/sourcerootUrlModuleSimpleSpecifyOutputFile.errors.txt create mode 100644 tests/baselines/reference/project/sourcerootUrlModuleSubfolderSpecifyOutputFile/amd/bin/test.js create mode 100644 tests/baselines/reference/project/sourcerootUrlModuleSubfolderSpecifyOutputFile/node/bin/test.js create mode 100644 tests/baselines/reference/project/sourcerootUrlModuleSubfolderSpecifyOutputFile/node/sourcerootUrlModuleSubfolderSpecifyOutputFile.errors.txt create mode 100644 tests/baselines/reference/project/sourcerootUrlMultifolderSpecifyOutputFile/node/sourcerootUrlMultifolderSpecifyOutputFile.errors.txt create mode 100644 tests/baselines/reference/project/sourcerootUrlSimpleSpecifyOutputFile/node/sourcerootUrlSimpleSpecifyOutputFile.errors.txt create mode 100644 tests/baselines/reference/project/sourcerootUrlSingleFileSpecifyOutputFile/node/sourcerootUrlSingleFileSpecifyOutputFile.errors.txt create mode 100644 tests/baselines/reference/project/sourcerootUrlSubfolderSpecifyOutputFile/node/sourcerootUrlSubfolderSpecifyOutputFile.errors.txt diff --git a/tests/baselines/reference/out-flag2.errors.txt b/tests/baselines/reference/out-flag2.errors.txt new file mode 100644 index 00000000000..755019b52b0 --- /dev/null +++ b/tests/baselines/reference/out-flag2.errors.txt @@ -0,0 +1,10 @@ +error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. + + +!!! error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +==== tests/cases/compiler/a.ts (0 errors) ==== + + class A { } + +==== tests/cases/compiler/b.ts (0 errors) ==== + class B { } \ No newline at end of file diff --git a/tests/baselines/reference/out-flag2.symbols b/tests/baselines/reference/out-flag2.symbols deleted file mode 100644 index 1bca057c580..00000000000 --- a/tests/baselines/reference/out-flag2.symbols +++ /dev/null @@ -1,9 +0,0 @@ -=== tests/cases/compiler/a.ts === - -class A { } ->A : Symbol(A, Decl(a.ts, 0, 0)) - -=== tests/cases/compiler/b.ts === -class B { } ->B : Symbol(B, Decl(b.ts, 0, 0)) - diff --git a/tests/baselines/reference/out-flag2.types b/tests/baselines/reference/out-flag2.types deleted file mode 100644 index 5a13642f99f..00000000000 --- a/tests/baselines/reference/out-flag2.types +++ /dev/null @@ -1,9 +0,0 @@ -=== tests/cases/compiler/a.ts === - -class A { } ->A : A - -=== tests/cases/compiler/b.ts === -class B { } ->B : B - diff --git a/tests/baselines/reference/out-flag3.errors.txt b/tests/baselines/reference/out-flag3.errors.txt index 6b7dda7c962..ab44f4e94fd 100644 --- a/tests/baselines/reference/out-flag3.errors.txt +++ b/tests/baselines/reference/out-flag3.errors.txt @@ -1,7 +1,9 @@ error TS5053: Option 'out' cannot be specified with option 'outFile'. +error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --out. !!! error TS5053: Option 'out' cannot be specified with option 'outFile'. +!!! error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --out. ==== tests/cases/compiler/a.ts (0 errors) ==== // --out and --outFile error diff --git a/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFile/amd/bin/test.js b/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFile/amd/bin/test.js new file mode 100644 index 00000000000..af837fd2031 --- /dev/null +++ b/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFile/amd/bin/test.js @@ -0,0 +1,37 @@ +var m1_a1 = 10; +var m1_c1 = (function () { + function m1_c1() { + } + return m1_c1; +})(); +var m1_instance1 = new m1_c1(); +function m1_f1() { + return m1_instance1; +} +define("ref/m2", ["require", "exports"], function (require, exports) { + exports.m2_a1 = 10; + var m2_c1 = (function () { + function m2_c1() { + } + return m2_c1; + })(); + exports.m2_c1 = m2_c1; + exports.m2_instance1 = new m2_c1(); + function m2_f1() { + return exports.m2_instance1; + } + exports.m2_f1 = m2_f1; +}); +/// +/// +var a1 = 10; +var c1 = (function () { + function c1() { + } + return c1; +})(); +var instance1 = new c1(); +function f1() { + return instance1; +} +//# sourceMappingURL=/tests/cases/projects/outputdir_mixed_subfolder/mapFiles/test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFile/node/bin/test.js b/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFile/node/bin/test.js new file mode 100644 index 00000000000..7ef36232b8d --- /dev/null +++ b/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFile/node/bin/test.js @@ -0,0 +1,23 @@ +var m1_a1 = 10; +var m1_c1 = (function () { + function m1_c1() { + } + return m1_c1; +})(); +var m1_instance1 = new m1_c1(); +function m1_f1() { + return m1_instance1; +} +/// +/// +var a1 = 10; +var c1 = (function () { + function c1() { + } + return c1; +})(); +var instance1 = new c1(); +function f1() { + return instance1; +} +//# sourceMappingURL=/tests/cases/projects/outputdir_mixed_subfolder/mapFiles/test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFile/node/mapRootAbsolutePathMixedSubfolderSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFile/node/mapRootAbsolutePathMixedSubfolderSpecifyOutputFile.errors.txt new file mode 100644 index 00000000000..9674c11863f --- /dev/null +++ b/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFile/node/mapRootAbsolutePathMixedSubfolderSpecifyOutputFile.errors.txt @@ -0,0 +1,36 @@ +error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. + + +!!! error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +==== ref/m1.ts (0 errors) ==== + var m1_a1 = 10; + class m1_c1 { + public m1_c1_p1: number; + } + + var m1_instance1 = new m1_c1(); + function m1_f1() { + return m1_instance1; + } +==== ref/m2.ts (0 errors) ==== + export var m2_a1 = 10; + export class m2_c1 { + public m2_c1_p1: number; + } + + export var m2_instance1 = new m2_c1(); + export function m2_f1() { + return m2_instance1; + } +==== test.ts (0 errors) ==== + /// + /// + var a1 = 10; + class c1 { + public p1: number; + } + + var instance1 = new c1(); + function f1() { + return instance1; + } \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.js b/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.js new file mode 100644 index 00000000000..de704afeedb --- /dev/null +++ b/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.js @@ -0,0 +1,37 @@ +var m1_a1 = 10; +var m1_c1 = (function () { + function m1_c1() { + } + return m1_c1; +})(); +var m1_instance1 = new m1_c1(); +function m1_f1() { + return m1_instance1; +} +define("ref/m2", ["require", "exports"], function (require, exports) { + exports.m2_a1 = 10; + var m2_c1 = (function () { + function m2_c1() { + } + return m2_c1; + })(); + exports.m2_c1 = m2_c1; + exports.m2_instance1 = new m2_c1(); + function m2_f1() { + return exports.m2_instance1; + } + exports.m2_f1 = m2_f1; +}); +/// +/// +var a1 = 10; +var c1 = (function () { + function c1() { + } + return c1; +})(); +var instance1 = new c1(); +function f1() { + return instance1; +} +//# sourceMappingURL=/tests/cases/projects/outputdir_mixed_subfolder/mapFiles/outAndOutDirFile.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.js b/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.js new file mode 100644 index 00000000000..fc53d59d7cb --- /dev/null +++ b/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.js @@ -0,0 +1,23 @@ +var m1_a1 = 10; +var m1_c1 = (function () { + function m1_c1() { + } + return m1_c1; +})(); +var m1_instance1 = new m1_c1(); +function m1_f1() { + return m1_instance1; +} +/// +/// +var a1 = 10; +var c1 = (function () { + function c1() { + } + return c1; +})(); +var instance1 = new c1(); +function f1() { + return instance1; +} +//# sourceMappingURL=/tests/cases/projects/outputdir_mixed_subfolder/mapFiles/outAndOutDirFile.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/mapRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory.errors.txt b/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/mapRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory.errors.txt new file mode 100644 index 00000000000..9674c11863f --- /dev/null +++ b/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/mapRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory.errors.txt @@ -0,0 +1,36 @@ +error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. + + +!!! error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +==== ref/m1.ts (0 errors) ==== + var m1_a1 = 10; + class m1_c1 { + public m1_c1_p1: number; + } + + var m1_instance1 = new m1_c1(); + function m1_f1() { + return m1_instance1; + } +==== ref/m2.ts (0 errors) ==== + export var m2_a1 = 10; + export class m2_c1 { + public m2_c1_p1: number; + } + + export var m2_instance1 = new m2_c1(); + export function m2_f1() { + return m2_instance1; + } +==== test.ts (0 errors) ==== + /// + /// + var a1 = 10; + class c1 { + public p1: number; + } + + var instance1 = new c1(); + function f1() { + return instance1; + } \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderSpecifyOutputFile/amd/bin/test.js b/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderSpecifyOutputFile/amd/bin/test.js new file mode 100644 index 00000000000..25cd156c4ab --- /dev/null +++ b/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderSpecifyOutputFile/amd/bin/test.js @@ -0,0 +1,45 @@ +define("ref/m1", ["require", "exports"], function (require, exports) { + exports.m1_a1 = 10; + var m1_c1 = (function () { + function m1_c1() { + } + return m1_c1; + })(); + exports.m1_c1 = m1_c1; + exports.m1_instance1 = new m1_c1(); + function m1_f1() { + return exports.m1_instance1; + } + exports.m1_f1 = m1_f1; +}); +define("../outputdir_module_multifolder_ref/m2", ["require", "exports"], function (require, exports) { + exports.m2_a1 = 10; + var m2_c1 = (function () { + function m2_c1() { + } + return m2_c1; + })(); + exports.m2_c1 = m2_c1; + exports.m2_instance1 = new m2_c1(); + function m2_f1() { + return exports.m2_instance1; + } + exports.m2_f1 = m2_f1; +}); +define("test", ["require", "exports", "ref/m1", "../outputdir_module_multifolder_ref/m2"], function (require, exports, m1, m2) { + exports.a1 = 10; + var c1 = (function () { + function c1() { + } + return c1; + })(); + exports.c1 = c1; + exports.instance1 = new c1(); + function f1() { + return exports.instance1; + } + exports.f1 = f1; + exports.a2 = m1.m1_c1; + exports.a3 = m2.m2_c1; +}); +//# sourceMappingURL=/tests/cases/projects/outputdir_module_multifolder/mapFiles/test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderSpecifyOutputFile/node/bin/test.js b/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderSpecifyOutputFile/node/bin/test.js new file mode 100644 index 00000000000..18e06e5bc50 --- /dev/null +++ b/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderSpecifyOutputFile/node/bin/test.js @@ -0,0 +1 @@ +//# sourceMappingURL=/tests/cases/projects/outputdir_module_multifolder/mapFiles/test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderSpecifyOutputFile/node/mapRootAbsolutePathModuleMultifolderSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderSpecifyOutputFile/node/mapRootAbsolutePathModuleMultifolderSpecifyOutputFile.errors.txt new file mode 100644 index 00000000000..ea8c2e58ae5 --- /dev/null +++ b/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderSpecifyOutputFile/node/mapRootAbsolutePathModuleMultifolderSpecifyOutputFile.errors.txt @@ -0,0 +1,39 @@ +error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. + + +!!! error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +==== ref/m1.ts (0 errors) ==== + export var m1_a1 = 10; + export class m1_c1 { + public m1_c1_p1: number; + } + + export var m1_instance1 = new m1_c1(); + export function m1_f1() { + return m1_instance1; + } +==== ../outputdir_module_multifolder_ref/m2.ts (0 errors) ==== + export var m2_a1 = 10; + export class m2_c1 { + public m2_c1_p1: number; + } + + export var m2_instance1 = new m2_c1(); + export function m2_f1() { + return m2_instance1; + } +==== test.ts (0 errors) ==== + import m1 = require("ref/m1"); + import m2 = require("../outputdir_module_multifolder_ref/m2"); + export var a1 = 10; + export class c1 { + public p1: number; + } + + export var instance1 = new c1(); + export function f1() { + return instance1; + } + + export var a2 = m1.m1_c1; + export var a3 = m2.m2_c1; \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootAbsolutePathModuleSimpleSpecifyOutputFile/amd/bin/test.js b/tests/baselines/reference/project/mapRootAbsolutePathModuleSimpleSpecifyOutputFile/amd/bin/test.js new file mode 100644 index 00000000000..d3d9bd9dc85 --- /dev/null +++ b/tests/baselines/reference/project/mapRootAbsolutePathModuleSimpleSpecifyOutputFile/amd/bin/test.js @@ -0,0 +1,30 @@ +define("m1", ["require", "exports"], function (require, exports) { + exports.m1_a1 = 10; + var m1_c1 = (function () { + function m1_c1() { + } + return m1_c1; + })(); + exports.m1_c1 = m1_c1; + exports.m1_instance1 = new m1_c1(); + function m1_f1() { + return exports.m1_instance1; + } + exports.m1_f1 = m1_f1; +}); +define("test", ["require", "exports", "m1"], function (require, exports, m1) { + exports.a1 = 10; + var c1 = (function () { + function c1() { + } + return c1; + })(); + exports.c1 = c1; + exports.instance1 = new c1(); + function f1() { + return exports.instance1; + } + exports.f1 = f1; + exports.a2 = m1.m1_c1; +}); +//# sourceMappingURL=/tests/cases/projects/outputdir_module_simple/mapFiles/test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootAbsolutePathModuleSimpleSpecifyOutputFile/node/bin/test.js b/tests/baselines/reference/project/mapRootAbsolutePathModuleSimpleSpecifyOutputFile/node/bin/test.js new file mode 100644 index 00000000000..f6e3eb542f4 --- /dev/null +++ b/tests/baselines/reference/project/mapRootAbsolutePathModuleSimpleSpecifyOutputFile/node/bin/test.js @@ -0,0 +1 @@ +//# sourceMappingURL=/tests/cases/projects/outputdir_module_simple/mapFiles/test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootAbsolutePathModuleSimpleSpecifyOutputFile/node/mapRootAbsolutePathModuleSimpleSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/mapRootAbsolutePathModuleSimpleSpecifyOutputFile/node/mapRootAbsolutePathModuleSimpleSpecifyOutputFile.errors.txt new file mode 100644 index 00000000000..0d918d5b2a0 --- /dev/null +++ b/tests/baselines/reference/project/mapRootAbsolutePathModuleSimpleSpecifyOutputFile/node/mapRootAbsolutePathModuleSimpleSpecifyOutputFile.errors.txt @@ -0,0 +1,27 @@ +error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. + + +!!! error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +==== m1.ts (0 errors) ==== + export var m1_a1 = 10; + export class m1_c1 { + public m1_c1_p1: number; + } + + export var m1_instance1 = new m1_c1(); + export function m1_f1() { + return m1_instance1; + } +==== test.ts (0 errors) ==== + import m1 = require("m1"); + export var a1 = 10; + export class c1 { + public p1: number; + } + + export var instance1 = new c1(); + export function f1() { + return instance1; + } + + export var a2 = m1.m1_c1; \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootAbsolutePathModuleSubfolderSpecifyOutputFile/amd/bin/test.js b/tests/baselines/reference/project/mapRootAbsolutePathModuleSubfolderSpecifyOutputFile/amd/bin/test.js new file mode 100644 index 00000000000..176c3f78407 --- /dev/null +++ b/tests/baselines/reference/project/mapRootAbsolutePathModuleSubfolderSpecifyOutputFile/amd/bin/test.js @@ -0,0 +1,30 @@ +define("ref/m1", ["require", "exports"], function (require, exports) { + exports.m1_a1 = 10; + var m1_c1 = (function () { + function m1_c1() { + } + return m1_c1; + })(); + exports.m1_c1 = m1_c1; + exports.m1_instance1 = new m1_c1(); + function m1_f1() { + return exports.m1_instance1; + } + exports.m1_f1 = m1_f1; +}); +define("test", ["require", "exports", "ref/m1"], function (require, exports, m1) { + exports.a1 = 10; + var c1 = (function () { + function c1() { + } + return c1; + })(); + exports.c1 = c1; + exports.instance1 = new c1(); + function f1() { + return exports.instance1; + } + exports.f1 = f1; + exports.a2 = m1.m1_c1; +}); +//# sourceMappingURL=/tests/cases/projects/outputdir_module_subfolder/mapFiles/test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootAbsolutePathModuleSubfolderSpecifyOutputFile/node/bin/test.js b/tests/baselines/reference/project/mapRootAbsolutePathModuleSubfolderSpecifyOutputFile/node/bin/test.js new file mode 100644 index 00000000000..7ff280253f1 --- /dev/null +++ b/tests/baselines/reference/project/mapRootAbsolutePathModuleSubfolderSpecifyOutputFile/node/bin/test.js @@ -0,0 +1 @@ +//# sourceMappingURL=/tests/cases/projects/outputdir_module_subfolder/mapFiles/test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootAbsolutePathModuleSubfolderSpecifyOutputFile/node/mapRootAbsolutePathModuleSubfolderSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/mapRootAbsolutePathModuleSubfolderSpecifyOutputFile/node/mapRootAbsolutePathModuleSubfolderSpecifyOutputFile.errors.txt new file mode 100644 index 00000000000..2468ab068e2 --- /dev/null +++ b/tests/baselines/reference/project/mapRootAbsolutePathModuleSubfolderSpecifyOutputFile/node/mapRootAbsolutePathModuleSubfolderSpecifyOutputFile.errors.txt @@ -0,0 +1,27 @@ +error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. + + +!!! error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +==== ref/m1.ts (0 errors) ==== + export var m1_a1 = 10; + export class m1_c1 { + public m1_c1_p1: number; + } + + export var m1_instance1 = new m1_c1(); + export function m1_f1() { + return m1_instance1; + } +==== test.ts (0 errors) ==== + import m1 = require("ref/m1"); + export var a1 = 10; + export class c1 { + public p1: number; + } + + export var instance1 = new c1(); + export function f1() { + return instance1; + } + + export var a2 = m1.m1_c1; \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootAbsolutePathMultifolderSpecifyOutputFile/node/mapRootAbsolutePathMultifolderSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/mapRootAbsolutePathMultifolderSpecifyOutputFile/node/mapRootAbsolutePathMultifolderSpecifyOutputFile.errors.txt new file mode 100644 index 00000000000..8deca814d80 --- /dev/null +++ b/tests/baselines/reference/project/mapRootAbsolutePathMultifolderSpecifyOutputFile/node/mapRootAbsolutePathMultifolderSpecifyOutputFile.errors.txt @@ -0,0 +1,36 @@ +error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. + + +!!! error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +==== ref/m1.ts (0 errors) ==== + var m1_a1 = 10; + class m1_c1 { + public m1_c1_p1: number; + } + + var m1_instance1 = new m1_c1(); + function m1_f1() { + return m1_instance1; + } +==== ../outputdir_multifolder_ref/m2.ts (0 errors) ==== + var m2_a1 = 10; + class m2_c1 { + public m2_c1_p1: number; + } + + var m2_instance1 = new m2_c1(); + function m2_f1() { + return m2_instance1; + } +==== test.ts (0 errors) ==== + /// + /// + var a1 = 10; + class c1 { + public p1: number; + } + + var instance1 = new c1(); + function f1() { + return instance1; + } \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootAbsolutePathSimpleSpecifyOutputFile/node/mapRootAbsolutePathSimpleSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/mapRootAbsolutePathSimpleSpecifyOutputFile/node/mapRootAbsolutePathSimpleSpecifyOutputFile.errors.txt new file mode 100644 index 00000000000..edf8d0637e2 --- /dev/null +++ b/tests/baselines/reference/project/mapRootAbsolutePathSimpleSpecifyOutputFile/node/mapRootAbsolutePathSimpleSpecifyOutputFile.errors.txt @@ -0,0 +1,25 @@ +error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. + + +!!! error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +==== m1.ts (0 errors) ==== + var m1_a1 = 10; + class m1_c1 { + public m1_c1_p1: number; + } + + var m1_instance1 = new m1_c1(); + function m1_f1() { + return m1_instance1; + } +==== test.ts (0 errors) ==== + /// + var a1 = 10; + class c1 { + public p1: number; + } + + var instance1 = new c1(); + function f1() { + return instance1; + } \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootAbsolutePathSingleFileSpecifyOutputFile/node/mapRootAbsolutePathSingleFileSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/mapRootAbsolutePathSingleFileSpecifyOutputFile/node/mapRootAbsolutePathSingleFileSpecifyOutputFile.errors.txt new file mode 100644 index 00000000000..3413d4675e7 --- /dev/null +++ b/tests/baselines/reference/project/mapRootAbsolutePathSingleFileSpecifyOutputFile/node/mapRootAbsolutePathSingleFileSpecifyOutputFile.errors.txt @@ -0,0 +1,14 @@ +error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. + + +!!! error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +==== test.ts (0 errors) ==== + var a1 = 10; + class c1 { + public p1: number; + } + + var instance1 = new c1(); + function f1() { + return instance1; + } \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootAbsolutePathSubfolderSpecifyOutputFile/node/mapRootAbsolutePathSubfolderSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/mapRootAbsolutePathSubfolderSpecifyOutputFile/node/mapRootAbsolutePathSubfolderSpecifyOutputFile.errors.txt new file mode 100644 index 00000000000..3a508fede30 --- /dev/null +++ b/tests/baselines/reference/project/mapRootAbsolutePathSubfolderSpecifyOutputFile/node/mapRootAbsolutePathSubfolderSpecifyOutputFile.errors.txt @@ -0,0 +1,25 @@ +error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. + + +!!! error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +==== ref/m1.ts (0 errors) ==== + var m1_a1 = 10; + class m1_c1 { + public m1_c1_p1: number; + } + + var m1_instance1 = new m1_c1(); + function m1_f1() { + return m1_instance1; + } +==== test.ts (0 errors) ==== + /// + var a1 = 10; + class c1 { + public p1: number; + } + + var instance1 = new c1(); + function f1() { + return instance1; + } \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFile/amd/bin/test.js b/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFile/amd/bin/test.js new file mode 100644 index 00000000000..bd14cd07502 --- /dev/null +++ b/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFile/amd/bin/test.js @@ -0,0 +1,37 @@ +var m1_a1 = 10; +var m1_c1 = (function () { + function m1_c1() { + } + return m1_c1; +})(); +var m1_instance1 = new m1_c1(); +function m1_f1() { + return m1_instance1; +} +define("ref/m2", ["require", "exports"], function (require, exports) { + exports.m2_a1 = 10; + var m2_c1 = (function () { + function m2_c1() { + } + return m2_c1; + })(); + exports.m2_c1 = m2_c1; + exports.m2_instance1 = new m2_c1(); + function m2_f1() { + return exports.m2_instance1; + } + exports.m2_f1 = m2_f1; +}); +/// +/// +var a1 = 10; +var c1 = (function () { + function c1() { + } + return c1; +})(); +var instance1 = new c1(); +function f1() { + return instance1; +} +//# sourceMappingURL=../../mapFiles/test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFile/node/bin/test.js b/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFile/node/bin/test.js new file mode 100644 index 00000000000..c4c79e0454b --- /dev/null +++ b/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFile/node/bin/test.js @@ -0,0 +1,23 @@ +var m1_a1 = 10; +var m1_c1 = (function () { + function m1_c1() { + } + return m1_c1; +})(); +var m1_instance1 = new m1_c1(); +function m1_f1() { + return m1_instance1; +} +/// +/// +var a1 = 10; +var c1 = (function () { + function c1() { + } + return c1; +})(); +var instance1 = new c1(); +function f1() { + return instance1; +} +//# sourceMappingURL=../../mapFiles/test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFile/node/mapRootRelativePathMixedSubfolderSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFile/node/mapRootRelativePathMixedSubfolderSpecifyOutputFile.errors.txt new file mode 100644 index 00000000000..9674c11863f --- /dev/null +++ b/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFile/node/mapRootRelativePathMixedSubfolderSpecifyOutputFile.errors.txt @@ -0,0 +1,36 @@ +error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. + + +!!! error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +==== ref/m1.ts (0 errors) ==== + var m1_a1 = 10; + class m1_c1 { + public m1_c1_p1: number; + } + + var m1_instance1 = new m1_c1(); + function m1_f1() { + return m1_instance1; + } +==== ref/m2.ts (0 errors) ==== + export var m2_a1 = 10; + export class m2_c1 { + public m2_c1_p1: number; + } + + export var m2_instance1 = new m2_c1(); + export function m2_f1() { + return m2_instance1; + } +==== test.ts (0 errors) ==== + /// + /// + var a1 = 10; + class c1 { + public p1: number; + } + + var instance1 = new c1(); + function f1() { + return instance1; + } \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.js b/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.js new file mode 100644 index 00000000000..59405bccb9c --- /dev/null +++ b/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.js @@ -0,0 +1,37 @@ +var m1_a1 = 10; +var m1_c1 = (function () { + function m1_c1() { + } + return m1_c1; +})(); +var m1_instance1 = new m1_c1(); +function m1_f1() { + return m1_instance1; +} +define("ref/m2", ["require", "exports"], function (require, exports) { + exports.m2_a1 = 10; + var m2_c1 = (function () { + function m2_c1() { + } + return m2_c1; + })(); + exports.m2_c1 = m2_c1; + exports.m2_instance1 = new m2_c1(); + function m2_f1() { + return exports.m2_instance1; + } + exports.m2_f1 = m2_f1; +}); +/// +/// +var a1 = 10; +var c1 = (function () { + function c1() { + } + return c1; +})(); +var instance1 = new c1(); +function f1() { + return instance1; +} +//# sourceMappingURL=../../mapFiles/outAndOutDirFile.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.js b/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.js new file mode 100644 index 00000000000..c0138423cae --- /dev/null +++ b/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.js @@ -0,0 +1,23 @@ +var m1_a1 = 10; +var m1_c1 = (function () { + function m1_c1() { + } + return m1_c1; +})(); +var m1_instance1 = new m1_c1(); +function m1_f1() { + return m1_instance1; +} +/// +/// +var a1 = 10; +var c1 = (function () { + function c1() { + } + return c1; +})(); +var instance1 = new c1(); +function f1() { + return instance1; +} +//# sourceMappingURL=../../mapFiles/outAndOutDirFile.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/mapRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory.errors.txt b/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/mapRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory.errors.txt new file mode 100644 index 00000000000..9674c11863f --- /dev/null +++ b/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/mapRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory.errors.txt @@ -0,0 +1,36 @@ +error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. + + +!!! error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +==== ref/m1.ts (0 errors) ==== + var m1_a1 = 10; + class m1_c1 { + public m1_c1_p1: number; + } + + var m1_instance1 = new m1_c1(); + function m1_f1() { + return m1_instance1; + } +==== ref/m2.ts (0 errors) ==== + export var m2_a1 = 10; + export class m2_c1 { + public m2_c1_p1: number; + } + + export var m2_instance1 = new m2_c1(); + export function m2_f1() { + return m2_instance1; + } +==== test.ts (0 errors) ==== + /// + /// + var a1 = 10; + class c1 { + public p1: number; + } + + var instance1 = new c1(); + function f1() { + return instance1; + } \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderSpecifyOutputFile/amd/bin/test.js b/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderSpecifyOutputFile/amd/bin/test.js new file mode 100644 index 00000000000..8b109433561 --- /dev/null +++ b/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderSpecifyOutputFile/amd/bin/test.js @@ -0,0 +1,45 @@ +define("ref/m1", ["require", "exports"], function (require, exports) { + exports.m1_a1 = 10; + var m1_c1 = (function () { + function m1_c1() { + } + return m1_c1; + })(); + exports.m1_c1 = m1_c1; + exports.m1_instance1 = new m1_c1(); + function m1_f1() { + return exports.m1_instance1; + } + exports.m1_f1 = m1_f1; +}); +define("../outputdir_module_multifolder_ref/m2", ["require", "exports"], function (require, exports) { + exports.m2_a1 = 10; + var m2_c1 = (function () { + function m2_c1() { + } + return m2_c1; + })(); + exports.m2_c1 = m2_c1; + exports.m2_instance1 = new m2_c1(); + function m2_f1() { + return exports.m2_instance1; + } + exports.m2_f1 = m2_f1; +}); +define("test", ["require", "exports", "ref/m1", "../outputdir_module_multifolder_ref/m2"], function (require, exports, m1, m2) { + exports.a1 = 10; + var c1 = (function () { + function c1() { + } + return c1; + })(); + exports.c1 = c1; + exports.instance1 = new c1(); + function f1() { + return exports.instance1; + } + exports.f1 = f1; + exports.a2 = m1.m1_c1; + exports.a3 = m2.m2_c1; +}); +//# sourceMappingURL=../../../mapFiles/test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderSpecifyOutputFile/node/bin/test.js b/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderSpecifyOutputFile/node/bin/test.js new file mode 100644 index 00000000000..f359cef4be2 --- /dev/null +++ b/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderSpecifyOutputFile/node/bin/test.js @@ -0,0 +1 @@ +//# sourceMappingURL=../../../mapFiles/test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderSpecifyOutputFile/node/mapRootRelativePathModuleMultifolderSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderSpecifyOutputFile/node/mapRootRelativePathModuleMultifolderSpecifyOutputFile.errors.txt new file mode 100644 index 00000000000..ea8c2e58ae5 --- /dev/null +++ b/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderSpecifyOutputFile/node/mapRootRelativePathModuleMultifolderSpecifyOutputFile.errors.txt @@ -0,0 +1,39 @@ +error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. + + +!!! error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +==== ref/m1.ts (0 errors) ==== + export var m1_a1 = 10; + export class m1_c1 { + public m1_c1_p1: number; + } + + export var m1_instance1 = new m1_c1(); + export function m1_f1() { + return m1_instance1; + } +==== ../outputdir_module_multifolder_ref/m2.ts (0 errors) ==== + export var m2_a1 = 10; + export class m2_c1 { + public m2_c1_p1: number; + } + + export var m2_instance1 = new m2_c1(); + export function m2_f1() { + return m2_instance1; + } +==== test.ts (0 errors) ==== + import m1 = require("ref/m1"); + import m2 = require("../outputdir_module_multifolder_ref/m2"); + export var a1 = 10; + export class c1 { + public p1: number; + } + + export var instance1 = new c1(); + export function f1() { + return instance1; + } + + export var a2 = m1.m1_c1; + export var a3 = m2.m2_c1; \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootRelativePathModuleSimpleSpecifyOutputFile/amd/bin/test.js b/tests/baselines/reference/project/mapRootRelativePathModuleSimpleSpecifyOutputFile/amd/bin/test.js new file mode 100644 index 00000000000..8ff2bbdb75b --- /dev/null +++ b/tests/baselines/reference/project/mapRootRelativePathModuleSimpleSpecifyOutputFile/amd/bin/test.js @@ -0,0 +1,30 @@ +define("m1", ["require", "exports"], function (require, exports) { + exports.m1_a1 = 10; + var m1_c1 = (function () { + function m1_c1() { + } + return m1_c1; + })(); + exports.m1_c1 = m1_c1; + exports.m1_instance1 = new m1_c1(); + function m1_f1() { + return exports.m1_instance1; + } + exports.m1_f1 = m1_f1; +}); +define("test", ["require", "exports", "m1"], function (require, exports, m1) { + exports.a1 = 10; + var c1 = (function () { + function c1() { + } + return c1; + })(); + exports.c1 = c1; + exports.instance1 = new c1(); + function f1() { + return exports.instance1; + } + exports.f1 = f1; + exports.a2 = m1.m1_c1; +}); +//# sourceMappingURL=../../mapFiles/test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootRelativePathModuleSimpleSpecifyOutputFile/node/bin/test.js b/tests/baselines/reference/project/mapRootRelativePathModuleSimpleSpecifyOutputFile/node/bin/test.js new file mode 100644 index 00000000000..58e831a041d --- /dev/null +++ b/tests/baselines/reference/project/mapRootRelativePathModuleSimpleSpecifyOutputFile/node/bin/test.js @@ -0,0 +1 @@ +//# sourceMappingURL=../../mapFiles/test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootRelativePathModuleSimpleSpecifyOutputFile/node/mapRootRelativePathModuleSimpleSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/mapRootRelativePathModuleSimpleSpecifyOutputFile/node/mapRootRelativePathModuleSimpleSpecifyOutputFile.errors.txt new file mode 100644 index 00000000000..0d918d5b2a0 --- /dev/null +++ b/tests/baselines/reference/project/mapRootRelativePathModuleSimpleSpecifyOutputFile/node/mapRootRelativePathModuleSimpleSpecifyOutputFile.errors.txt @@ -0,0 +1,27 @@ +error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. + + +!!! error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +==== m1.ts (0 errors) ==== + export var m1_a1 = 10; + export class m1_c1 { + public m1_c1_p1: number; + } + + export var m1_instance1 = new m1_c1(); + export function m1_f1() { + return m1_instance1; + } +==== test.ts (0 errors) ==== + import m1 = require("m1"); + export var a1 = 10; + export class c1 { + public p1: number; + } + + export var instance1 = new c1(); + export function f1() { + return instance1; + } + + export var a2 = m1.m1_c1; \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootRelativePathModuleSubfolderSpecifyOutputFile/amd/bin/test.js b/tests/baselines/reference/project/mapRootRelativePathModuleSubfolderSpecifyOutputFile/amd/bin/test.js new file mode 100644 index 00000000000..ccc0a7b503b --- /dev/null +++ b/tests/baselines/reference/project/mapRootRelativePathModuleSubfolderSpecifyOutputFile/amd/bin/test.js @@ -0,0 +1,30 @@ +define("ref/m1", ["require", "exports"], function (require, exports) { + exports.m1_a1 = 10; + var m1_c1 = (function () { + function m1_c1() { + } + return m1_c1; + })(); + exports.m1_c1 = m1_c1; + exports.m1_instance1 = new m1_c1(); + function m1_f1() { + return exports.m1_instance1; + } + exports.m1_f1 = m1_f1; +}); +define("test", ["require", "exports", "ref/m1"], function (require, exports, m1) { + exports.a1 = 10; + var c1 = (function () { + function c1() { + } + return c1; + })(); + exports.c1 = c1; + exports.instance1 = new c1(); + function f1() { + return exports.instance1; + } + exports.f1 = f1; + exports.a2 = m1.m1_c1; +}); +//# sourceMappingURL=../../mapFiles/test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootRelativePathModuleSubfolderSpecifyOutputFile/node/bin/test.js b/tests/baselines/reference/project/mapRootRelativePathModuleSubfolderSpecifyOutputFile/node/bin/test.js new file mode 100644 index 00000000000..58e831a041d --- /dev/null +++ b/tests/baselines/reference/project/mapRootRelativePathModuleSubfolderSpecifyOutputFile/node/bin/test.js @@ -0,0 +1 @@ +//# sourceMappingURL=../../mapFiles/test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootRelativePathModuleSubfolderSpecifyOutputFile/node/mapRootRelativePathModuleSubfolderSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/mapRootRelativePathModuleSubfolderSpecifyOutputFile/node/mapRootRelativePathModuleSubfolderSpecifyOutputFile.errors.txt new file mode 100644 index 00000000000..2468ab068e2 --- /dev/null +++ b/tests/baselines/reference/project/mapRootRelativePathModuleSubfolderSpecifyOutputFile/node/mapRootRelativePathModuleSubfolderSpecifyOutputFile.errors.txt @@ -0,0 +1,27 @@ +error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. + + +!!! error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +==== ref/m1.ts (0 errors) ==== + export var m1_a1 = 10; + export class m1_c1 { + public m1_c1_p1: number; + } + + export var m1_instance1 = new m1_c1(); + export function m1_f1() { + return m1_instance1; + } +==== test.ts (0 errors) ==== + import m1 = require("ref/m1"); + export var a1 = 10; + export class c1 { + public p1: number; + } + + export var instance1 = new c1(); + export function f1() { + return instance1; + } + + export var a2 = m1.m1_c1; \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootRelativePathMultifolderSpecifyOutputFile/amd/bin/test.js b/tests/baselines/reference/project/mapRootRelativePathMultifolderSpecifyOutputFile/amd/bin/test.js new file mode 100644 index 00000000000..acd2d113c02 --- /dev/null +++ b/tests/baselines/reference/project/mapRootRelativePathMultifolderSpecifyOutputFile/amd/bin/test.js @@ -0,0 +1,33 @@ +var m1_a1 = 10; +var m1_c1 = (function () { + function m1_c1() { + } + return m1_c1; +})(); +var m1_instance1 = new m1_c1(); +function m1_f1() { + return m1_instance1; +} +var m2_a1 = 10; +var m2_c1 = (function () { + function m2_c1() { + } + return m2_c1; +})(); +var m2_instance1 = new m2_c1(); +function m2_f1() { + return m2_instance1; +} +/// +/// +var a1 = 10; +var c1 = (function () { + function c1() { + } + return c1; +})(); +var instance1 = new c1(); +function f1() { + return instance1; +} +//# sourceMappingURL=../../../mapFiles/test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootRelativePathMultifolderSpecifyOutputFile/node/bin/test.js b/tests/baselines/reference/project/mapRootRelativePathMultifolderSpecifyOutputFile/node/bin/test.js new file mode 100644 index 00000000000..acd2d113c02 --- /dev/null +++ b/tests/baselines/reference/project/mapRootRelativePathMultifolderSpecifyOutputFile/node/bin/test.js @@ -0,0 +1,33 @@ +var m1_a1 = 10; +var m1_c1 = (function () { + function m1_c1() { + } + return m1_c1; +})(); +var m1_instance1 = new m1_c1(); +function m1_f1() { + return m1_instance1; +} +var m2_a1 = 10; +var m2_c1 = (function () { + function m2_c1() { + } + return m2_c1; +})(); +var m2_instance1 = new m2_c1(); +function m2_f1() { + return m2_instance1; +} +/// +/// +var a1 = 10; +var c1 = (function () { + function c1() { + } + return c1; +})(); +var instance1 = new c1(); +function f1() { + return instance1; +} +//# sourceMappingURL=../../../mapFiles/test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootRelativePathMultifolderSpecifyOutputFile/node/mapRootRelativePathMultifolderSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/mapRootRelativePathMultifolderSpecifyOutputFile/node/mapRootRelativePathMultifolderSpecifyOutputFile.errors.txt new file mode 100644 index 00000000000..8deca814d80 --- /dev/null +++ b/tests/baselines/reference/project/mapRootRelativePathMultifolderSpecifyOutputFile/node/mapRootRelativePathMultifolderSpecifyOutputFile.errors.txt @@ -0,0 +1,36 @@ +error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. + + +!!! error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +==== ref/m1.ts (0 errors) ==== + var m1_a1 = 10; + class m1_c1 { + public m1_c1_p1: number; + } + + var m1_instance1 = new m1_c1(); + function m1_f1() { + return m1_instance1; + } +==== ../outputdir_multifolder_ref/m2.ts (0 errors) ==== + var m2_a1 = 10; + class m2_c1 { + public m2_c1_p1: number; + } + + var m2_instance1 = new m2_c1(); + function m2_f1() { + return m2_instance1; + } +==== test.ts (0 errors) ==== + /// + /// + var a1 = 10; + class c1 { + public p1: number; + } + + var instance1 = new c1(); + function f1() { + return instance1; + } \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootRelativePathSimpleSpecifyOutputFile/node/mapRootRelativePathSimpleSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/mapRootRelativePathSimpleSpecifyOutputFile/node/mapRootRelativePathSimpleSpecifyOutputFile.errors.txt new file mode 100644 index 00000000000..edf8d0637e2 --- /dev/null +++ b/tests/baselines/reference/project/mapRootRelativePathSimpleSpecifyOutputFile/node/mapRootRelativePathSimpleSpecifyOutputFile.errors.txt @@ -0,0 +1,25 @@ +error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. + + +!!! error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +==== m1.ts (0 errors) ==== + var m1_a1 = 10; + class m1_c1 { + public m1_c1_p1: number; + } + + var m1_instance1 = new m1_c1(); + function m1_f1() { + return m1_instance1; + } +==== test.ts (0 errors) ==== + /// + var a1 = 10; + class c1 { + public p1: number; + } + + var instance1 = new c1(); + function f1() { + return instance1; + } \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootRelativePathSingleFileSpecifyOutputFile/node/mapRootRelativePathSingleFileSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/mapRootRelativePathSingleFileSpecifyOutputFile/node/mapRootRelativePathSingleFileSpecifyOutputFile.errors.txt new file mode 100644 index 00000000000..3413d4675e7 --- /dev/null +++ b/tests/baselines/reference/project/mapRootRelativePathSingleFileSpecifyOutputFile/node/mapRootRelativePathSingleFileSpecifyOutputFile.errors.txt @@ -0,0 +1,14 @@ +error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. + + +!!! error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +==== test.ts (0 errors) ==== + var a1 = 10; + class c1 { + public p1: number; + } + + var instance1 = new c1(); + function f1() { + return instance1; + } \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootRelativePathSubfolderSpecifyOutputFile/node/mapRootRelativePathSubfolderSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/mapRootRelativePathSubfolderSpecifyOutputFile/node/mapRootRelativePathSubfolderSpecifyOutputFile.errors.txt new file mode 100644 index 00000000000..3a508fede30 --- /dev/null +++ b/tests/baselines/reference/project/mapRootRelativePathSubfolderSpecifyOutputFile/node/mapRootRelativePathSubfolderSpecifyOutputFile.errors.txt @@ -0,0 +1,25 @@ +error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. + + +!!! error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +==== ref/m1.ts (0 errors) ==== + var m1_a1 = 10; + class m1_c1 { + public m1_c1_p1: number; + } + + var m1_instance1 = new m1_c1(); + function m1_f1() { + return m1_instance1; + } +==== test.ts (0 errors) ==== + /// + var a1 = 10; + class c1 { + public p1: number; + } + + var instance1 = new c1(); + function f1() { + return instance1; + } \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFile/amd/bin/test.js b/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFile/amd/bin/test.js new file mode 100644 index 00000000000..6fbac81a12d --- /dev/null +++ b/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFile/amd/bin/test.js @@ -0,0 +1,37 @@ +var m1_a1 = 10; +var m1_c1 = (function () { + function m1_c1() { + } + return m1_c1; +})(); +var m1_instance1 = new m1_c1(); +function m1_f1() { + return m1_instance1; +} +define("ref/m2", ["require", "exports"], function (require, exports) { + exports.m2_a1 = 10; + var m2_c1 = (function () { + function m2_c1() { + } + return m2_c1; + })(); + exports.m2_c1 = m2_c1; + exports.m2_instance1 = new m2_c1(); + function m2_f1() { + return exports.m2_instance1; + } + exports.m2_f1 = m2_f1; +}); +/// +/// +var a1 = 10; +var c1 = (function () { + function c1() { + } + return c1; +})(); +var instance1 = new c1(); +function f1() { + return instance1; +} +//# sourceMappingURL=http://www.typescriptlang.org/test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFile/node/bin/test.js b/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFile/node/bin/test.js new file mode 100644 index 00000000000..af0071d7e46 --- /dev/null +++ b/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFile/node/bin/test.js @@ -0,0 +1,23 @@ +var m1_a1 = 10; +var m1_c1 = (function () { + function m1_c1() { + } + return m1_c1; +})(); +var m1_instance1 = new m1_c1(); +function m1_f1() { + return m1_instance1; +} +/// +/// +var a1 = 10; +var c1 = (function () { + function c1() { + } + return c1; +})(); +var instance1 = new c1(); +function f1() { + return instance1; +} +//# sourceMappingURL=http://www.typescriptlang.org/test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFile/node/maprootUrlMixedSubfolderSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFile/node/maprootUrlMixedSubfolderSpecifyOutputFile.errors.txt new file mode 100644 index 00000000000..9674c11863f --- /dev/null +++ b/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFile/node/maprootUrlMixedSubfolderSpecifyOutputFile.errors.txt @@ -0,0 +1,36 @@ +error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. + + +!!! error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +==== ref/m1.ts (0 errors) ==== + var m1_a1 = 10; + class m1_c1 { + public m1_c1_p1: number; + } + + var m1_instance1 = new m1_c1(); + function m1_f1() { + return m1_instance1; + } +==== ref/m2.ts (0 errors) ==== + export var m2_a1 = 10; + export class m2_c1 { + public m2_c1_p1: number; + } + + export var m2_instance1 = new m2_c1(); + export function m2_f1() { + return m2_instance1; + } +==== test.ts (0 errors) ==== + /// + /// + var a1 = 10; + class c1 { + public p1: number; + } + + var instance1 = new c1(); + function f1() { + return instance1; + } \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.js b/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.js new file mode 100644 index 00000000000..8c16871c4a7 --- /dev/null +++ b/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.js @@ -0,0 +1,37 @@ +var m1_a1 = 10; +var m1_c1 = (function () { + function m1_c1() { + } + return m1_c1; +})(); +var m1_instance1 = new m1_c1(); +function m1_f1() { + return m1_instance1; +} +define("ref/m2", ["require", "exports"], function (require, exports) { + exports.m2_a1 = 10; + var m2_c1 = (function () { + function m2_c1() { + } + return m2_c1; + })(); + exports.m2_c1 = m2_c1; + exports.m2_instance1 = new m2_c1(); + function m2_f1() { + return exports.m2_instance1; + } + exports.m2_f1 = m2_f1; +}); +/// +/// +var a1 = 10; +var c1 = (function () { + function c1() { + } + return c1; +})(); +var instance1 = new c1(); +function f1() { + return instance1; +} +//# sourceMappingURL=http://www.typescriptlang.org/outAndOutDirFile.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.js b/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.js new file mode 100644 index 00000000000..2ebe138ffda --- /dev/null +++ b/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.js @@ -0,0 +1,23 @@ +var m1_a1 = 10; +var m1_c1 = (function () { + function m1_c1() { + } + return m1_c1; +})(); +var m1_instance1 = new m1_c1(); +function m1_f1() { + return m1_instance1; +} +/// +/// +var a1 = 10; +var c1 = (function () { + function c1() { + } + return c1; +})(); +var instance1 = new c1(); +function f1() { + return instance1; +} +//# sourceMappingURL=http://www.typescriptlang.org/outAndOutDirFile.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/maprootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory.errors.txt b/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/maprootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory.errors.txt new file mode 100644 index 00000000000..9674c11863f --- /dev/null +++ b/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/maprootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory.errors.txt @@ -0,0 +1,36 @@ +error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. + + +!!! error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +==== ref/m1.ts (0 errors) ==== + var m1_a1 = 10; + class m1_c1 { + public m1_c1_p1: number; + } + + var m1_instance1 = new m1_c1(); + function m1_f1() { + return m1_instance1; + } +==== ref/m2.ts (0 errors) ==== + export var m2_a1 = 10; + export class m2_c1 { + public m2_c1_p1: number; + } + + export var m2_instance1 = new m2_c1(); + export function m2_f1() { + return m2_instance1; + } +==== test.ts (0 errors) ==== + /// + /// + var a1 = 10; + class c1 { + public p1: number; + } + + var instance1 = new c1(); + function f1() { + return instance1; + } \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlModuleMultifolderSpecifyOutputFile/amd/bin/test.js b/tests/baselines/reference/project/maprootUrlModuleMultifolderSpecifyOutputFile/amd/bin/test.js new file mode 100644 index 00000000000..0734d350e11 --- /dev/null +++ b/tests/baselines/reference/project/maprootUrlModuleMultifolderSpecifyOutputFile/amd/bin/test.js @@ -0,0 +1,45 @@ +define("ref/m1", ["require", "exports"], function (require, exports) { + exports.m1_a1 = 10; + var m1_c1 = (function () { + function m1_c1() { + } + return m1_c1; + })(); + exports.m1_c1 = m1_c1; + exports.m1_instance1 = new m1_c1(); + function m1_f1() { + return exports.m1_instance1; + } + exports.m1_f1 = m1_f1; +}); +define("../outputdir_module_multifolder_ref/m2", ["require", "exports"], function (require, exports) { + exports.m2_a1 = 10; + var m2_c1 = (function () { + function m2_c1() { + } + return m2_c1; + })(); + exports.m2_c1 = m2_c1; + exports.m2_instance1 = new m2_c1(); + function m2_f1() { + return exports.m2_instance1; + } + exports.m2_f1 = m2_f1; +}); +define("test", ["require", "exports", "ref/m1", "../outputdir_module_multifolder_ref/m2"], function (require, exports, m1, m2) { + exports.a1 = 10; + var c1 = (function () { + function c1() { + } + return c1; + })(); + exports.c1 = c1; + exports.instance1 = new c1(); + function f1() { + return exports.instance1; + } + exports.f1 = f1; + exports.a2 = m1.m1_c1; + exports.a3 = m2.m2_c1; +}); +//# sourceMappingURL=http://www.typescriptlang.org/test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlModuleMultifolderSpecifyOutputFile/node/bin/test.js b/tests/baselines/reference/project/maprootUrlModuleMultifolderSpecifyOutputFile/node/bin/test.js new file mode 100644 index 00000000000..52f1b822100 --- /dev/null +++ b/tests/baselines/reference/project/maprootUrlModuleMultifolderSpecifyOutputFile/node/bin/test.js @@ -0,0 +1 @@ +//# sourceMappingURL=http://www.typescriptlang.org/test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlModuleMultifolderSpecifyOutputFile/node/maprootUrlModuleMultifolderSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/maprootUrlModuleMultifolderSpecifyOutputFile/node/maprootUrlModuleMultifolderSpecifyOutputFile.errors.txt new file mode 100644 index 00000000000..ea8c2e58ae5 --- /dev/null +++ b/tests/baselines/reference/project/maprootUrlModuleMultifolderSpecifyOutputFile/node/maprootUrlModuleMultifolderSpecifyOutputFile.errors.txt @@ -0,0 +1,39 @@ +error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. + + +!!! error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +==== ref/m1.ts (0 errors) ==== + export var m1_a1 = 10; + export class m1_c1 { + public m1_c1_p1: number; + } + + export var m1_instance1 = new m1_c1(); + export function m1_f1() { + return m1_instance1; + } +==== ../outputdir_module_multifolder_ref/m2.ts (0 errors) ==== + export var m2_a1 = 10; + export class m2_c1 { + public m2_c1_p1: number; + } + + export var m2_instance1 = new m2_c1(); + export function m2_f1() { + return m2_instance1; + } +==== test.ts (0 errors) ==== + import m1 = require("ref/m1"); + import m2 = require("../outputdir_module_multifolder_ref/m2"); + export var a1 = 10; + export class c1 { + public p1: number; + } + + export var instance1 = new c1(); + export function f1() { + return instance1; + } + + export var a2 = m1.m1_c1; + export var a3 = m2.m2_c1; \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlModuleSimpleSpecifyOutputFile/amd/bin/test.js b/tests/baselines/reference/project/maprootUrlModuleSimpleSpecifyOutputFile/amd/bin/test.js new file mode 100644 index 00000000000..77db9e80a53 --- /dev/null +++ b/tests/baselines/reference/project/maprootUrlModuleSimpleSpecifyOutputFile/amd/bin/test.js @@ -0,0 +1,30 @@ +define("m1", ["require", "exports"], function (require, exports) { + exports.m1_a1 = 10; + var m1_c1 = (function () { + function m1_c1() { + } + return m1_c1; + })(); + exports.m1_c1 = m1_c1; + exports.m1_instance1 = new m1_c1(); + function m1_f1() { + return exports.m1_instance1; + } + exports.m1_f1 = m1_f1; +}); +define("test", ["require", "exports", "m1"], function (require, exports, m1) { + exports.a1 = 10; + var c1 = (function () { + function c1() { + } + return c1; + })(); + exports.c1 = c1; + exports.instance1 = new c1(); + function f1() { + return exports.instance1; + } + exports.f1 = f1; + exports.a2 = m1.m1_c1; +}); +//# sourceMappingURL=http://www.typescriptlang.org/test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlModuleSimpleSpecifyOutputFile/node/bin/test.js b/tests/baselines/reference/project/maprootUrlModuleSimpleSpecifyOutputFile/node/bin/test.js new file mode 100644 index 00000000000..52f1b822100 --- /dev/null +++ b/tests/baselines/reference/project/maprootUrlModuleSimpleSpecifyOutputFile/node/bin/test.js @@ -0,0 +1 @@ +//# sourceMappingURL=http://www.typescriptlang.org/test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlModuleSimpleSpecifyOutputFile/node/maprootUrlModuleSimpleSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/maprootUrlModuleSimpleSpecifyOutputFile/node/maprootUrlModuleSimpleSpecifyOutputFile.errors.txt new file mode 100644 index 00000000000..0d918d5b2a0 --- /dev/null +++ b/tests/baselines/reference/project/maprootUrlModuleSimpleSpecifyOutputFile/node/maprootUrlModuleSimpleSpecifyOutputFile.errors.txt @@ -0,0 +1,27 @@ +error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. + + +!!! error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +==== m1.ts (0 errors) ==== + export var m1_a1 = 10; + export class m1_c1 { + public m1_c1_p1: number; + } + + export var m1_instance1 = new m1_c1(); + export function m1_f1() { + return m1_instance1; + } +==== test.ts (0 errors) ==== + import m1 = require("m1"); + export var a1 = 10; + export class c1 { + public p1: number; + } + + export var instance1 = new c1(); + export function f1() { + return instance1; + } + + export var a2 = m1.m1_c1; \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlModuleSubfolderSpecifyOutputFile/amd/bin/test.js b/tests/baselines/reference/project/maprootUrlModuleSubfolderSpecifyOutputFile/amd/bin/test.js new file mode 100644 index 00000000000..10c38a74411 --- /dev/null +++ b/tests/baselines/reference/project/maprootUrlModuleSubfolderSpecifyOutputFile/amd/bin/test.js @@ -0,0 +1,30 @@ +define("ref/m1", ["require", "exports"], function (require, exports) { + exports.m1_a1 = 10; + var m1_c1 = (function () { + function m1_c1() { + } + return m1_c1; + })(); + exports.m1_c1 = m1_c1; + exports.m1_instance1 = new m1_c1(); + function m1_f1() { + return exports.m1_instance1; + } + exports.m1_f1 = m1_f1; +}); +define("test", ["require", "exports", "ref/m1"], function (require, exports, m1) { + exports.a1 = 10; + var c1 = (function () { + function c1() { + } + return c1; + })(); + exports.c1 = c1; + exports.instance1 = new c1(); + function f1() { + return exports.instance1; + } + exports.f1 = f1; + exports.a2 = m1.m1_c1; +}); +//# sourceMappingURL=http://www.typescriptlang.org/test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlModuleSubfolderSpecifyOutputFile/node/bin/test.js b/tests/baselines/reference/project/maprootUrlModuleSubfolderSpecifyOutputFile/node/bin/test.js new file mode 100644 index 00000000000..52f1b822100 --- /dev/null +++ b/tests/baselines/reference/project/maprootUrlModuleSubfolderSpecifyOutputFile/node/bin/test.js @@ -0,0 +1 @@ +//# sourceMappingURL=http://www.typescriptlang.org/test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlModuleSubfolderSpecifyOutputFile/node/maprootUrlModuleSubfolderSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/maprootUrlModuleSubfolderSpecifyOutputFile/node/maprootUrlModuleSubfolderSpecifyOutputFile.errors.txt new file mode 100644 index 00000000000..2468ab068e2 --- /dev/null +++ b/tests/baselines/reference/project/maprootUrlModuleSubfolderSpecifyOutputFile/node/maprootUrlModuleSubfolderSpecifyOutputFile.errors.txt @@ -0,0 +1,27 @@ +error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. + + +!!! error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +==== ref/m1.ts (0 errors) ==== + export var m1_a1 = 10; + export class m1_c1 { + public m1_c1_p1: number; + } + + export var m1_instance1 = new m1_c1(); + export function m1_f1() { + return m1_instance1; + } +==== test.ts (0 errors) ==== + import m1 = require("ref/m1"); + export var a1 = 10; + export class c1 { + public p1: number; + } + + export var instance1 = new c1(); + export function f1() { + return instance1; + } + + export var a2 = m1.m1_c1; \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlMultifolderSpecifyOutputFile/node/maprootUrlMultifolderSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/maprootUrlMultifolderSpecifyOutputFile/node/maprootUrlMultifolderSpecifyOutputFile.errors.txt new file mode 100644 index 00000000000..8deca814d80 --- /dev/null +++ b/tests/baselines/reference/project/maprootUrlMultifolderSpecifyOutputFile/node/maprootUrlMultifolderSpecifyOutputFile.errors.txt @@ -0,0 +1,36 @@ +error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. + + +!!! error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +==== ref/m1.ts (0 errors) ==== + var m1_a1 = 10; + class m1_c1 { + public m1_c1_p1: number; + } + + var m1_instance1 = new m1_c1(); + function m1_f1() { + return m1_instance1; + } +==== ../outputdir_multifolder_ref/m2.ts (0 errors) ==== + var m2_a1 = 10; + class m2_c1 { + public m2_c1_p1: number; + } + + var m2_instance1 = new m2_c1(); + function m2_f1() { + return m2_instance1; + } +==== test.ts (0 errors) ==== + /// + /// + var a1 = 10; + class c1 { + public p1: number; + } + + var instance1 = new c1(); + function f1() { + return instance1; + } \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlSimpleSpecifyOutputFile/node/maprootUrlSimpleSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/maprootUrlSimpleSpecifyOutputFile/node/maprootUrlSimpleSpecifyOutputFile.errors.txt new file mode 100644 index 00000000000..edf8d0637e2 --- /dev/null +++ b/tests/baselines/reference/project/maprootUrlSimpleSpecifyOutputFile/node/maprootUrlSimpleSpecifyOutputFile.errors.txt @@ -0,0 +1,25 @@ +error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. + + +!!! error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +==== m1.ts (0 errors) ==== + var m1_a1 = 10; + class m1_c1 { + public m1_c1_p1: number; + } + + var m1_instance1 = new m1_c1(); + function m1_f1() { + return m1_instance1; + } +==== test.ts (0 errors) ==== + /// + var a1 = 10; + class c1 { + public p1: number; + } + + var instance1 = new c1(); + function f1() { + return instance1; + } \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlSingleFileSpecifyOutputFile/node/maprootUrlSingleFileSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/maprootUrlSingleFileSpecifyOutputFile/node/maprootUrlSingleFileSpecifyOutputFile.errors.txt new file mode 100644 index 00000000000..3413d4675e7 --- /dev/null +++ b/tests/baselines/reference/project/maprootUrlSingleFileSpecifyOutputFile/node/maprootUrlSingleFileSpecifyOutputFile.errors.txt @@ -0,0 +1,14 @@ +error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. + + +!!! error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +==== test.ts (0 errors) ==== + var a1 = 10; + class c1 { + public p1: number; + } + + var instance1 = new c1(); + function f1() { + return instance1; + } \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlSubfolderSpecifyOutputFile/node/maprootUrlSubfolderSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/maprootUrlSubfolderSpecifyOutputFile/node/maprootUrlSubfolderSpecifyOutputFile.errors.txt new file mode 100644 index 00000000000..3a508fede30 --- /dev/null +++ b/tests/baselines/reference/project/maprootUrlSubfolderSpecifyOutputFile/node/maprootUrlSubfolderSpecifyOutputFile.errors.txt @@ -0,0 +1,25 @@ +error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. + + +!!! error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +==== ref/m1.ts (0 errors) ==== + var m1_a1 = 10; + class m1_c1 { + public m1_c1_p1: number; + } + + var m1_instance1 = new m1_c1(); + function m1_f1() { + return m1_instance1; + } +==== test.ts (0 errors) ==== + /// + var a1 = 10; + class c1 { + public p1: number; + } + + var instance1 = new c1(); + function f1() { + return instance1; + } \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFile/amd/bin/test.js b/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFile/amd/bin/test.js new file mode 100644 index 00000000000..6fbac81a12d --- /dev/null +++ b/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFile/amd/bin/test.js @@ -0,0 +1,37 @@ +var m1_a1 = 10; +var m1_c1 = (function () { + function m1_c1() { + } + return m1_c1; +})(); +var m1_instance1 = new m1_c1(); +function m1_f1() { + return m1_instance1; +} +define("ref/m2", ["require", "exports"], function (require, exports) { + exports.m2_a1 = 10; + var m2_c1 = (function () { + function m2_c1() { + } + return m2_c1; + })(); + exports.m2_c1 = m2_c1; + exports.m2_instance1 = new m2_c1(); + function m2_f1() { + return exports.m2_instance1; + } + exports.m2_f1 = m2_f1; +}); +/// +/// +var a1 = 10; +var c1 = (function () { + function c1() { + } + return c1; +})(); +var instance1 = new c1(); +function f1() { + return instance1; +} +//# sourceMappingURL=http://www.typescriptlang.org/test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFile/node/bin/test.js b/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFile/node/bin/test.js new file mode 100644 index 00000000000..af0071d7e46 --- /dev/null +++ b/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFile/node/bin/test.js @@ -0,0 +1,23 @@ +var m1_a1 = 10; +var m1_c1 = (function () { + function m1_c1() { + } + return m1_c1; +})(); +var m1_instance1 = new m1_c1(); +function m1_f1() { + return m1_instance1; +} +/// +/// +var a1 = 10; +var c1 = (function () { + function c1() { + } + return c1; +})(); +var instance1 = new c1(); +function f1() { + return instance1; +} +//# sourceMappingURL=http://www.typescriptlang.org/test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFile/node/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFile/node/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFile.errors.txt new file mode 100644 index 00000000000..9674c11863f --- /dev/null +++ b/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFile/node/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFile.errors.txt @@ -0,0 +1,36 @@ +error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. + + +!!! error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +==== ref/m1.ts (0 errors) ==== + var m1_a1 = 10; + class m1_c1 { + public m1_c1_p1: number; + } + + var m1_instance1 = new m1_c1(); + function m1_f1() { + return m1_instance1; + } +==== ref/m2.ts (0 errors) ==== + export var m2_a1 = 10; + export class m2_c1 { + public m2_c1_p1: number; + } + + export var m2_instance1 = new m2_c1(); + export function m2_f1() { + return m2_instance1; + } +==== test.ts (0 errors) ==== + /// + /// + var a1 = 10; + class c1 { + public p1: number; + } + + var instance1 = new c1(); + function f1() { + return instance1; + } \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.js b/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.js new file mode 100644 index 00000000000..8c16871c4a7 --- /dev/null +++ b/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.js @@ -0,0 +1,37 @@ +var m1_a1 = 10; +var m1_c1 = (function () { + function m1_c1() { + } + return m1_c1; +})(); +var m1_instance1 = new m1_c1(); +function m1_f1() { + return m1_instance1; +} +define("ref/m2", ["require", "exports"], function (require, exports) { + exports.m2_a1 = 10; + var m2_c1 = (function () { + function m2_c1() { + } + return m2_c1; + })(); + exports.m2_c1 = m2_c1; + exports.m2_instance1 = new m2_c1(); + function m2_f1() { + return exports.m2_instance1; + } + exports.m2_f1 = m2_f1; +}); +/// +/// +var a1 = 10; +var c1 = (function () { + function c1() { + } + return c1; +})(); +var instance1 = new c1(); +function f1() { + return instance1; +} +//# sourceMappingURL=http://www.typescriptlang.org/outAndOutDirFile.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.js b/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.js new file mode 100644 index 00000000000..2ebe138ffda --- /dev/null +++ b/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.js @@ -0,0 +1,23 @@ +var m1_a1 = 10; +var m1_c1 = (function () { + function m1_c1() { + } + return m1_c1; +})(); +var m1_instance1 = new m1_c1(); +function m1_f1() { + return m1_instance1; +} +/// +/// +var a1 = 10; +var c1 = (function () { + function c1() { + } + return c1; +})(); +var instance1 = new c1(); +function f1() { + return instance1; +} +//# sourceMappingURL=http://www.typescriptlang.org/outAndOutDirFile.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory.errors.txt b/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory.errors.txt new file mode 100644 index 00000000000..9674c11863f --- /dev/null +++ b/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory.errors.txt @@ -0,0 +1,36 @@ +error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. + + +!!! error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +==== ref/m1.ts (0 errors) ==== + var m1_a1 = 10; + class m1_c1 { + public m1_c1_p1: number; + } + + var m1_instance1 = new m1_c1(); + function m1_f1() { + return m1_instance1; + } +==== ref/m2.ts (0 errors) ==== + export var m2_a1 = 10; + export class m2_c1 { + public m2_c1_p1: number; + } + + export var m2_instance1 = new m2_c1(); + export function m2_f1() { + return m2_instance1; + } +==== test.ts (0 errors) ==== + /// + /// + var a1 = 10; + class c1 { + public p1: number; + } + + var instance1 = new c1(); + function f1() { + return instance1; + } \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputFile/amd/bin/test.js b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputFile/amd/bin/test.js new file mode 100644 index 00000000000..0734d350e11 --- /dev/null +++ b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputFile/amd/bin/test.js @@ -0,0 +1,45 @@ +define("ref/m1", ["require", "exports"], function (require, exports) { + exports.m1_a1 = 10; + var m1_c1 = (function () { + function m1_c1() { + } + return m1_c1; + })(); + exports.m1_c1 = m1_c1; + exports.m1_instance1 = new m1_c1(); + function m1_f1() { + return exports.m1_instance1; + } + exports.m1_f1 = m1_f1; +}); +define("../outputdir_module_multifolder_ref/m2", ["require", "exports"], function (require, exports) { + exports.m2_a1 = 10; + var m2_c1 = (function () { + function m2_c1() { + } + return m2_c1; + })(); + exports.m2_c1 = m2_c1; + exports.m2_instance1 = new m2_c1(); + function m2_f1() { + return exports.m2_instance1; + } + exports.m2_f1 = m2_f1; +}); +define("test", ["require", "exports", "ref/m1", "../outputdir_module_multifolder_ref/m2"], function (require, exports, m1, m2) { + exports.a1 = 10; + var c1 = (function () { + function c1() { + } + return c1; + })(); + exports.c1 = c1; + exports.instance1 = new c1(); + function f1() { + return exports.instance1; + } + exports.f1 = f1; + exports.a2 = m1.m1_c1; + exports.a3 = m2.m2_c1; +}); +//# sourceMappingURL=http://www.typescriptlang.org/test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputFile/node/bin/test.js b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputFile/node/bin/test.js new file mode 100644 index 00000000000..52f1b822100 --- /dev/null +++ b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputFile/node/bin/test.js @@ -0,0 +1 @@ +//# sourceMappingURL=http://www.typescriptlang.org/test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputFile/node/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputFile/node/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputFile.errors.txt new file mode 100644 index 00000000000..ea8c2e58ae5 --- /dev/null +++ b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputFile/node/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputFile.errors.txt @@ -0,0 +1,39 @@ +error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. + + +!!! error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +==== ref/m1.ts (0 errors) ==== + export var m1_a1 = 10; + export class m1_c1 { + public m1_c1_p1: number; + } + + export var m1_instance1 = new m1_c1(); + export function m1_f1() { + return m1_instance1; + } +==== ../outputdir_module_multifolder_ref/m2.ts (0 errors) ==== + export var m2_a1 = 10; + export class m2_c1 { + public m2_c1_p1: number; + } + + export var m2_instance1 = new m2_c1(); + export function m2_f1() { + return m2_instance1; + } +==== test.ts (0 errors) ==== + import m1 = require("ref/m1"); + import m2 = require("../outputdir_module_multifolder_ref/m2"); + export var a1 = 10; + export class c1 { + public p1: number; + } + + export var instance1 = new c1(); + export function f1() { + return instance1; + } + + export var a2 = m1.m1_c1; + export var a3 = m2.m2_c1; \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSimpleSpecifyOutputFile/amd/bin/test.js b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSimpleSpecifyOutputFile/amd/bin/test.js new file mode 100644 index 00000000000..77db9e80a53 --- /dev/null +++ b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSimpleSpecifyOutputFile/amd/bin/test.js @@ -0,0 +1,30 @@ +define("m1", ["require", "exports"], function (require, exports) { + exports.m1_a1 = 10; + var m1_c1 = (function () { + function m1_c1() { + } + return m1_c1; + })(); + exports.m1_c1 = m1_c1; + exports.m1_instance1 = new m1_c1(); + function m1_f1() { + return exports.m1_instance1; + } + exports.m1_f1 = m1_f1; +}); +define("test", ["require", "exports", "m1"], function (require, exports, m1) { + exports.a1 = 10; + var c1 = (function () { + function c1() { + } + return c1; + })(); + exports.c1 = c1; + exports.instance1 = new c1(); + function f1() { + return exports.instance1; + } + exports.f1 = f1; + exports.a2 = m1.m1_c1; +}); +//# sourceMappingURL=http://www.typescriptlang.org/test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSimpleSpecifyOutputFile/node/bin/test.js b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSimpleSpecifyOutputFile/node/bin/test.js new file mode 100644 index 00000000000..52f1b822100 --- /dev/null +++ b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSimpleSpecifyOutputFile/node/bin/test.js @@ -0,0 +1 @@ +//# sourceMappingURL=http://www.typescriptlang.org/test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSimpleSpecifyOutputFile/node/maprootUrlsourcerootUrlModuleSimpleSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSimpleSpecifyOutputFile/node/maprootUrlsourcerootUrlModuleSimpleSpecifyOutputFile.errors.txt new file mode 100644 index 00000000000..0d918d5b2a0 --- /dev/null +++ b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSimpleSpecifyOutputFile/node/maprootUrlsourcerootUrlModuleSimpleSpecifyOutputFile.errors.txt @@ -0,0 +1,27 @@ +error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. + + +!!! error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +==== m1.ts (0 errors) ==== + export var m1_a1 = 10; + export class m1_c1 { + public m1_c1_p1: number; + } + + export var m1_instance1 = new m1_c1(); + export function m1_f1() { + return m1_instance1; + } +==== test.ts (0 errors) ==== + import m1 = require("m1"); + export var a1 = 10; + export class c1 { + public p1: number; + } + + export var instance1 = new c1(); + export function f1() { + return instance1; + } + + export var a2 = m1.m1_c1; \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSubfolderSpecifyOutputFile/amd/bin/test.js b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSubfolderSpecifyOutputFile/amd/bin/test.js new file mode 100644 index 00000000000..10c38a74411 --- /dev/null +++ b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSubfolderSpecifyOutputFile/amd/bin/test.js @@ -0,0 +1,30 @@ +define("ref/m1", ["require", "exports"], function (require, exports) { + exports.m1_a1 = 10; + var m1_c1 = (function () { + function m1_c1() { + } + return m1_c1; + })(); + exports.m1_c1 = m1_c1; + exports.m1_instance1 = new m1_c1(); + function m1_f1() { + return exports.m1_instance1; + } + exports.m1_f1 = m1_f1; +}); +define("test", ["require", "exports", "ref/m1"], function (require, exports, m1) { + exports.a1 = 10; + var c1 = (function () { + function c1() { + } + return c1; + })(); + exports.c1 = c1; + exports.instance1 = new c1(); + function f1() { + return exports.instance1; + } + exports.f1 = f1; + exports.a2 = m1.m1_c1; +}); +//# sourceMappingURL=http://www.typescriptlang.org/test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSubfolderSpecifyOutputFile/node/bin/test.js b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSubfolderSpecifyOutputFile/node/bin/test.js new file mode 100644 index 00000000000..52f1b822100 --- /dev/null +++ b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSubfolderSpecifyOutputFile/node/bin/test.js @@ -0,0 +1 @@ +//# sourceMappingURL=http://www.typescriptlang.org/test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSubfolderSpecifyOutputFile/node/maprootUrlsourcerootUrlModuleSubfolderSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSubfolderSpecifyOutputFile/node/maprootUrlsourcerootUrlModuleSubfolderSpecifyOutputFile.errors.txt new file mode 100644 index 00000000000..2468ab068e2 --- /dev/null +++ b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSubfolderSpecifyOutputFile/node/maprootUrlsourcerootUrlModuleSubfolderSpecifyOutputFile.errors.txt @@ -0,0 +1,27 @@ +error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. + + +!!! error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +==== ref/m1.ts (0 errors) ==== + export var m1_a1 = 10; + export class m1_c1 { + public m1_c1_p1: number; + } + + export var m1_instance1 = new m1_c1(); + export function m1_f1() { + return m1_instance1; + } +==== test.ts (0 errors) ==== + import m1 = require("ref/m1"); + export var a1 = 10; + export class c1 { + public p1: number; + } + + export var instance1 = new c1(); + export function f1() { + return instance1; + } + + export var a2 = m1.m1_c1; \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlMultifolderSpecifyOutputFile/node/maprootUrlsourcerootUrlMultifolderSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/maprootUrlsourcerootUrlMultifolderSpecifyOutputFile/node/maprootUrlsourcerootUrlMultifolderSpecifyOutputFile.errors.txt new file mode 100644 index 00000000000..8deca814d80 --- /dev/null +++ b/tests/baselines/reference/project/maprootUrlsourcerootUrlMultifolderSpecifyOutputFile/node/maprootUrlsourcerootUrlMultifolderSpecifyOutputFile.errors.txt @@ -0,0 +1,36 @@ +error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. + + +!!! error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +==== ref/m1.ts (0 errors) ==== + var m1_a1 = 10; + class m1_c1 { + public m1_c1_p1: number; + } + + var m1_instance1 = new m1_c1(); + function m1_f1() { + return m1_instance1; + } +==== ../outputdir_multifolder_ref/m2.ts (0 errors) ==== + var m2_a1 = 10; + class m2_c1 { + public m2_c1_p1: number; + } + + var m2_instance1 = new m2_c1(); + function m2_f1() { + return m2_instance1; + } +==== test.ts (0 errors) ==== + /// + /// + var a1 = 10; + class c1 { + public p1: number; + } + + var instance1 = new c1(); + function f1() { + return instance1; + } \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlSimpleSpecifyOutputFile/node/maprootUrlsourcerootUrlSimpleSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/maprootUrlsourcerootUrlSimpleSpecifyOutputFile/node/maprootUrlsourcerootUrlSimpleSpecifyOutputFile.errors.txt new file mode 100644 index 00000000000..edf8d0637e2 --- /dev/null +++ b/tests/baselines/reference/project/maprootUrlsourcerootUrlSimpleSpecifyOutputFile/node/maprootUrlsourcerootUrlSimpleSpecifyOutputFile.errors.txt @@ -0,0 +1,25 @@ +error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. + + +!!! error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +==== m1.ts (0 errors) ==== + var m1_a1 = 10; + class m1_c1 { + public m1_c1_p1: number; + } + + var m1_instance1 = new m1_c1(); + function m1_f1() { + return m1_instance1; + } +==== test.ts (0 errors) ==== + /// + var a1 = 10; + class c1 { + public p1: number; + } + + var instance1 = new c1(); + function f1() { + return instance1; + } \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlSingleFileSpecifyOutputFile/node/maprootUrlsourcerootUrlSingleFileSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/maprootUrlsourcerootUrlSingleFileSpecifyOutputFile/node/maprootUrlsourcerootUrlSingleFileSpecifyOutputFile.errors.txt new file mode 100644 index 00000000000..3413d4675e7 --- /dev/null +++ b/tests/baselines/reference/project/maprootUrlsourcerootUrlSingleFileSpecifyOutputFile/node/maprootUrlsourcerootUrlSingleFileSpecifyOutputFile.errors.txt @@ -0,0 +1,14 @@ +error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. + + +!!! error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +==== test.ts (0 errors) ==== + var a1 = 10; + class c1 { + public p1: number; + } + + var instance1 = new c1(); + function f1() { + return instance1; + } \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlSubfolderSpecifyOutputFile/node/maprootUrlsourcerootUrlSubfolderSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/maprootUrlsourcerootUrlSubfolderSpecifyOutputFile/node/maprootUrlsourcerootUrlSubfolderSpecifyOutputFile.errors.txt new file mode 100644 index 00000000000..3a508fede30 --- /dev/null +++ b/tests/baselines/reference/project/maprootUrlsourcerootUrlSubfolderSpecifyOutputFile/node/maprootUrlsourcerootUrlSubfolderSpecifyOutputFile.errors.txt @@ -0,0 +1,25 @@ +error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. + + +!!! error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +==== ref/m1.ts (0 errors) ==== + var m1_a1 = 10; + class m1_c1 { + public m1_c1_p1: number; + } + + var m1_instance1 = new m1_c1(); + function m1_f1() { + return m1_instance1; + } +==== test.ts (0 errors) ==== + /// + var a1 = 10; + class c1 { + public p1: number; + } + + var instance1 = new c1(); + function f1() { + return instance1; + } \ No newline at end of file diff --git a/tests/baselines/reference/project/outMixedSubfolderSpecifyOutputFile/amd/bin/test.d.ts b/tests/baselines/reference/project/outMixedSubfolderSpecifyOutputFile/amd/bin/test.d.ts new file mode 100644 index 00000000000..d61b4c3b876 --- /dev/null +++ b/tests/baselines/reference/project/outMixedSubfolderSpecifyOutputFile/amd/bin/test.d.ts @@ -0,0 +1,13 @@ +/// +declare var m1_a1: number; +declare class m1_c1 { + m1_c1_p1: number; +} +declare var m1_instance1: m1_c1; +declare function m1_f1(): m1_c1; +declare var a1: number; +declare class c1 { + p1: number; +} +declare var instance1: c1; +declare function f1(): c1; diff --git a/tests/baselines/reference/project/outMixedSubfolderSpecifyOutputFile/node/outMixedSubfolderSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/outMixedSubfolderSpecifyOutputFile/node/outMixedSubfolderSpecifyOutputFile.errors.txt new file mode 100644 index 00000000000..9674c11863f --- /dev/null +++ b/tests/baselines/reference/project/outMixedSubfolderSpecifyOutputFile/node/outMixedSubfolderSpecifyOutputFile.errors.txt @@ -0,0 +1,36 @@ +error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. + + +!!! error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +==== ref/m1.ts (0 errors) ==== + var m1_a1 = 10; + class m1_c1 { + public m1_c1_p1: number; + } + + var m1_instance1 = new m1_c1(); + function m1_f1() { + return m1_instance1; + } +==== ref/m2.ts (0 errors) ==== + export var m2_a1 = 10; + export class m2_c1 { + public m2_c1_p1: number; + } + + export var m2_instance1 = new m2_c1(); + export function m2_f1() { + return m2_instance1; + } +==== test.ts (0 errors) ==== + /// + /// + var a1 = 10; + class c1 { + public p1: number; + } + + var instance1 = new c1(); + function f1() { + return instance1; + } \ No newline at end of file diff --git a/tests/baselines/reference/project/outMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.d.ts b/tests/baselines/reference/project/outMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.d.ts new file mode 100644 index 00000000000..9b9cdd4a214 --- /dev/null +++ b/tests/baselines/reference/project/outMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.d.ts @@ -0,0 +1,13 @@ +/// +declare var m1_a1: number; +declare class m1_c1 { + m1_c1_p1: number; +} +declare var m1_instance1: m1_c1; +declare function m1_f1(): m1_c1; +declare var a1: number; +declare class c1 { + p1: number; +} +declare var instance1: c1; +declare function f1(): c1; diff --git a/tests/baselines/reference/project/outMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/outMixedSubfolderSpecifyOutputFileAndOutputDirectory.errors.txt b/tests/baselines/reference/project/outMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/outMixedSubfolderSpecifyOutputFileAndOutputDirectory.errors.txt new file mode 100644 index 00000000000..9674c11863f --- /dev/null +++ b/tests/baselines/reference/project/outMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/outMixedSubfolderSpecifyOutputFileAndOutputDirectory.errors.txt @@ -0,0 +1,36 @@ +error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. + + +!!! error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +==== ref/m1.ts (0 errors) ==== + var m1_a1 = 10; + class m1_c1 { + public m1_c1_p1: number; + } + + var m1_instance1 = new m1_c1(); + function m1_f1() { + return m1_instance1; + } +==== ref/m2.ts (0 errors) ==== + export var m2_a1 = 10; + export class m2_c1 { + public m2_c1_p1: number; + } + + export var m2_instance1 = new m2_c1(); + export function m2_f1() { + return m2_instance1; + } +==== test.ts (0 errors) ==== + /// + /// + var a1 = 10; + class c1 { + public p1: number; + } + + var instance1 = new c1(); + function f1() { + return instance1; + } \ No newline at end of file diff --git a/tests/baselines/reference/project/outModuleMultifolderSpecifyOutputFile/amd/bin/test.d.ts b/tests/baselines/reference/project/outModuleMultifolderSpecifyOutputFile/amd/bin/test.d.ts new file mode 100644 index 00000000000..e69de29bb2d diff --git a/tests/baselines/reference/project/outModuleMultifolderSpecifyOutputFile/node/outModuleMultifolderSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/outModuleMultifolderSpecifyOutputFile/node/outModuleMultifolderSpecifyOutputFile.errors.txt new file mode 100644 index 00000000000..ea8c2e58ae5 --- /dev/null +++ b/tests/baselines/reference/project/outModuleMultifolderSpecifyOutputFile/node/outModuleMultifolderSpecifyOutputFile.errors.txt @@ -0,0 +1,39 @@ +error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. + + +!!! error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +==== ref/m1.ts (0 errors) ==== + export var m1_a1 = 10; + export class m1_c1 { + public m1_c1_p1: number; + } + + export var m1_instance1 = new m1_c1(); + export function m1_f1() { + return m1_instance1; + } +==== ../outputdir_module_multifolder_ref/m2.ts (0 errors) ==== + export var m2_a1 = 10; + export class m2_c1 { + public m2_c1_p1: number; + } + + export var m2_instance1 = new m2_c1(); + export function m2_f1() { + return m2_instance1; + } +==== test.ts (0 errors) ==== + import m1 = require("ref/m1"); + import m2 = require("../outputdir_module_multifolder_ref/m2"); + export var a1 = 10; + export class c1 { + public p1: number; + } + + export var instance1 = new c1(); + export function f1() { + return instance1; + } + + export var a2 = m1.m1_c1; + export var a3 = m2.m2_c1; \ No newline at end of file diff --git a/tests/baselines/reference/project/outModuleSimpleSpecifyOutputFile/amd/bin/test.d.ts b/tests/baselines/reference/project/outModuleSimpleSpecifyOutputFile/amd/bin/test.d.ts new file mode 100644 index 00000000000..e69de29bb2d diff --git a/tests/baselines/reference/project/outModuleSimpleSpecifyOutputFile/node/outModuleSimpleSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/outModuleSimpleSpecifyOutputFile/node/outModuleSimpleSpecifyOutputFile.errors.txt new file mode 100644 index 00000000000..0d918d5b2a0 --- /dev/null +++ b/tests/baselines/reference/project/outModuleSimpleSpecifyOutputFile/node/outModuleSimpleSpecifyOutputFile.errors.txt @@ -0,0 +1,27 @@ +error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. + + +!!! error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +==== m1.ts (0 errors) ==== + export var m1_a1 = 10; + export class m1_c1 { + public m1_c1_p1: number; + } + + export var m1_instance1 = new m1_c1(); + export function m1_f1() { + return m1_instance1; + } +==== test.ts (0 errors) ==== + import m1 = require("m1"); + export var a1 = 10; + export class c1 { + public p1: number; + } + + export var instance1 = new c1(); + export function f1() { + return instance1; + } + + export var a2 = m1.m1_c1; \ No newline at end of file diff --git a/tests/baselines/reference/project/outModuleSubfolderSpecifyOutputFile/amd/bin/test.d.ts b/tests/baselines/reference/project/outModuleSubfolderSpecifyOutputFile/amd/bin/test.d.ts new file mode 100644 index 00000000000..e69de29bb2d diff --git a/tests/baselines/reference/project/outModuleSubfolderSpecifyOutputFile/node/outModuleSubfolderSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/outModuleSubfolderSpecifyOutputFile/node/outModuleSubfolderSpecifyOutputFile.errors.txt new file mode 100644 index 00000000000..2468ab068e2 --- /dev/null +++ b/tests/baselines/reference/project/outModuleSubfolderSpecifyOutputFile/node/outModuleSubfolderSpecifyOutputFile.errors.txt @@ -0,0 +1,27 @@ +error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. + + +!!! error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +==== ref/m1.ts (0 errors) ==== + export var m1_a1 = 10; + export class m1_c1 { + public m1_c1_p1: number; + } + + export var m1_instance1 = new m1_c1(); + export function m1_f1() { + return m1_instance1; + } +==== test.ts (0 errors) ==== + import m1 = require("ref/m1"); + export var a1 = 10; + export class c1 { + public p1: number; + } + + export var instance1 = new c1(); + export function f1() { + return instance1; + } + + export var a2 = m1.m1_c1; \ No newline at end of file diff --git a/tests/baselines/reference/project/outMultifolderSpecifyOutputFile/node/outMultifolderSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/outMultifolderSpecifyOutputFile/node/outMultifolderSpecifyOutputFile.errors.txt new file mode 100644 index 00000000000..8deca814d80 --- /dev/null +++ b/tests/baselines/reference/project/outMultifolderSpecifyOutputFile/node/outMultifolderSpecifyOutputFile.errors.txt @@ -0,0 +1,36 @@ +error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. + + +!!! error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +==== ref/m1.ts (0 errors) ==== + var m1_a1 = 10; + class m1_c1 { + public m1_c1_p1: number; + } + + var m1_instance1 = new m1_c1(); + function m1_f1() { + return m1_instance1; + } +==== ../outputdir_multifolder_ref/m2.ts (0 errors) ==== + var m2_a1 = 10; + class m2_c1 { + public m2_c1_p1: number; + } + + var m2_instance1 = new m2_c1(); + function m2_f1() { + return m2_instance1; + } +==== test.ts (0 errors) ==== + /// + /// + var a1 = 10; + class c1 { + public p1: number; + } + + var instance1 = new c1(); + function f1() { + return instance1; + } \ No newline at end of file diff --git a/tests/baselines/reference/project/outSimpleSpecifyOutputFile/node/outSimpleSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/outSimpleSpecifyOutputFile/node/outSimpleSpecifyOutputFile.errors.txt new file mode 100644 index 00000000000..edf8d0637e2 --- /dev/null +++ b/tests/baselines/reference/project/outSimpleSpecifyOutputFile/node/outSimpleSpecifyOutputFile.errors.txt @@ -0,0 +1,25 @@ +error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. + + +!!! error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +==== m1.ts (0 errors) ==== + var m1_a1 = 10; + class m1_c1 { + public m1_c1_p1: number; + } + + var m1_instance1 = new m1_c1(); + function m1_f1() { + return m1_instance1; + } +==== test.ts (0 errors) ==== + /// + var a1 = 10; + class c1 { + public p1: number; + } + + var instance1 = new c1(); + function f1() { + return instance1; + } \ No newline at end of file diff --git a/tests/baselines/reference/project/outSingleFileSpecifyOutputFile/node/outSingleFileSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/outSingleFileSpecifyOutputFile/node/outSingleFileSpecifyOutputFile.errors.txt new file mode 100644 index 00000000000..3413d4675e7 --- /dev/null +++ b/tests/baselines/reference/project/outSingleFileSpecifyOutputFile/node/outSingleFileSpecifyOutputFile.errors.txt @@ -0,0 +1,14 @@ +error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. + + +!!! error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +==== test.ts (0 errors) ==== + var a1 = 10; + class c1 { + public p1: number; + } + + var instance1 = new c1(); + function f1() { + return instance1; + } \ No newline at end of file diff --git a/tests/baselines/reference/project/outSubfolderSpecifyOutputFile/node/outSubfolderSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/outSubfolderSpecifyOutputFile/node/outSubfolderSpecifyOutputFile.errors.txt new file mode 100644 index 00000000000..3a508fede30 --- /dev/null +++ b/tests/baselines/reference/project/outSubfolderSpecifyOutputFile/node/outSubfolderSpecifyOutputFile.errors.txt @@ -0,0 +1,25 @@ +error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. + + +!!! error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +==== ref/m1.ts (0 errors) ==== + var m1_a1 = 10; + class m1_c1 { + public m1_c1_p1: number; + } + + var m1_instance1 = new m1_c1(); + function m1_f1() { + return m1_instance1; + } +==== test.ts (0 errors) ==== + /// + var a1 = 10; + class c1 { + public p1: number; + } + + var instance1 = new c1(); + function f1() { + return instance1; + } \ No newline at end of file diff --git a/tests/baselines/reference/project/prologueEmit/node/prologueEmit.errors.txt b/tests/baselines/reference/project/prologueEmit/node/prologueEmit.errors.txt new file mode 100644 index 00000000000..5225c47ee97 --- /dev/null +++ b/tests/baselines/reference/project/prologueEmit/node/prologueEmit.errors.txt @@ -0,0 +1,14 @@ +error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. + + +!!! error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +==== globalThisCapture.ts (0 errors) ==== + // Add a lambda to ensure global 'this' capture is triggered + (()=>this.window); + +==== __extends.ts (0 errors) ==== + // class inheritance to ensure __extends is emitted + module m { + export class base {} + export class child extends base {} + } \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFile/amd/bin/test.js b/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFile/amd/bin/test.js new file mode 100644 index 00000000000..13e9de8f87f --- /dev/null +++ b/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFile/amd/bin/test.js @@ -0,0 +1,37 @@ +var m1_a1 = 10; +var m1_c1 = (function () { + function m1_c1() { + } + return m1_c1; +})(); +var m1_instance1 = new m1_c1(); +function m1_f1() { + return m1_instance1; +} +define("ref/m2", ["require", "exports"], function (require, exports) { + exports.m2_a1 = 10; + var m2_c1 = (function () { + function m2_c1() { + } + return m2_c1; + })(); + exports.m2_c1 = m2_c1; + exports.m2_instance1 = new m2_c1(); + function m2_f1() { + return exports.m2_instance1; + } + exports.m2_f1 = m2_f1; +}); +/// +/// +var a1 = 10; +var c1 = (function () { + function c1() { + } + return c1; +})(); +var instance1 = new c1(); +function f1() { + return instance1; +} +//# sourceMappingURL=test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFile/node/bin/test.js b/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFile/node/bin/test.js new file mode 100644 index 00000000000..5af28cf8560 --- /dev/null +++ b/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFile/node/bin/test.js @@ -0,0 +1,23 @@ +var m1_a1 = 10; +var m1_c1 = (function () { + function m1_c1() { + } + return m1_c1; +})(); +var m1_instance1 = new m1_c1(); +function m1_f1() { + return m1_instance1; +} +/// +/// +var a1 = 10; +var c1 = (function () { + function c1() { + } + return c1; +})(); +var instance1 = new c1(); +function f1() { + return instance1; +} +//# sourceMappingURL=test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFile/node/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFile/node/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFile.errors.txt new file mode 100644 index 00000000000..9674c11863f --- /dev/null +++ b/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFile/node/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFile.errors.txt @@ -0,0 +1,36 @@ +error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. + + +!!! error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +==== ref/m1.ts (0 errors) ==== + var m1_a1 = 10; + class m1_c1 { + public m1_c1_p1: number; + } + + var m1_instance1 = new m1_c1(); + function m1_f1() { + return m1_instance1; + } +==== ref/m2.ts (0 errors) ==== + export var m2_a1 = 10; + export class m2_c1 { + public m2_c1_p1: number; + } + + export var m2_instance1 = new m2_c1(); + export function m2_f1() { + return m2_instance1; + } +==== test.ts (0 errors) ==== + /// + /// + var a1 = 10; + class c1 { + public p1: number; + } + + var instance1 = new c1(); + function f1() { + return instance1; + } \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.js b/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.js new file mode 100644 index 00000000000..81bb710c580 --- /dev/null +++ b/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.js @@ -0,0 +1,37 @@ +var m1_a1 = 10; +var m1_c1 = (function () { + function m1_c1() { + } + return m1_c1; +})(); +var m1_instance1 = new m1_c1(); +function m1_f1() { + return m1_instance1; +} +define("ref/m2", ["require", "exports"], function (require, exports) { + exports.m2_a1 = 10; + var m2_c1 = (function () { + function m2_c1() { + } + return m2_c1; + })(); + exports.m2_c1 = m2_c1; + exports.m2_instance1 = new m2_c1(); + function m2_f1() { + return exports.m2_instance1; + } + exports.m2_f1 = m2_f1; +}); +/// +/// +var a1 = 10; +var c1 = (function () { + function c1() { + } + return c1; +})(); +var instance1 = new c1(); +function f1() { + return instance1; +} +//# sourceMappingURL=outAndOutDirFile.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.js b/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.js new file mode 100644 index 00000000000..1750a5975ae --- /dev/null +++ b/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.js @@ -0,0 +1,23 @@ +var m1_a1 = 10; +var m1_c1 = (function () { + function m1_c1() { + } + return m1_c1; +})(); +var m1_instance1 = new m1_c1(); +function m1_f1() { + return m1_instance1; +} +/// +/// +var a1 = 10; +var c1 = (function () { + function c1() { + } + return c1; +})(); +var instance1 = new c1(); +function f1() { + return instance1; +} +//# sourceMappingURL=outAndOutDirFile.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory.errors.txt b/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory.errors.txt new file mode 100644 index 00000000000..9674c11863f --- /dev/null +++ b/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory.errors.txt @@ -0,0 +1,36 @@ +error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. + + +!!! error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +==== ref/m1.ts (0 errors) ==== + var m1_a1 = 10; + class m1_c1 { + public m1_c1_p1: number; + } + + var m1_instance1 = new m1_c1(); + function m1_f1() { + return m1_instance1; + } +==== ref/m2.ts (0 errors) ==== + export var m2_a1 = 10; + export class m2_c1 { + public m2_c1_p1: number; + } + + export var m2_instance1 = new m2_c1(); + export function m2_f1() { + return m2_instance1; + } +==== test.ts (0 errors) ==== + /// + /// + var a1 = 10; + class c1 { + public p1: number; + } + + var instance1 = new c1(); + function f1() { + return instance1; + } \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderSpecifyOutputFile/amd/bin/test.js b/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderSpecifyOutputFile/amd/bin/test.js new file mode 100644 index 00000000000..994e21ca032 --- /dev/null +++ b/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderSpecifyOutputFile/amd/bin/test.js @@ -0,0 +1,45 @@ +define("ref/m1", ["require", "exports"], function (require, exports) { + exports.m1_a1 = 10; + var m1_c1 = (function () { + function m1_c1() { + } + return m1_c1; + })(); + exports.m1_c1 = m1_c1; + exports.m1_instance1 = new m1_c1(); + function m1_f1() { + return exports.m1_instance1; + } + exports.m1_f1 = m1_f1; +}); +define("../outputdir_module_multifolder_ref/m2", ["require", "exports"], function (require, exports) { + exports.m2_a1 = 10; + var m2_c1 = (function () { + function m2_c1() { + } + return m2_c1; + })(); + exports.m2_c1 = m2_c1; + exports.m2_instance1 = new m2_c1(); + function m2_f1() { + return exports.m2_instance1; + } + exports.m2_f1 = m2_f1; +}); +define("test", ["require", "exports", "ref/m1", "../outputdir_module_multifolder_ref/m2"], function (require, exports, m1, m2) { + exports.a1 = 10; + var c1 = (function () { + function c1() { + } + return c1; + })(); + exports.c1 = c1; + exports.instance1 = new c1(); + function f1() { + return exports.instance1; + } + exports.f1 = f1; + exports.a2 = m1.m1_c1; + exports.a3 = m2.m2_c1; +}); +//# sourceMappingURL=test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderSpecifyOutputFile/node/bin/test.js b/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderSpecifyOutputFile/node/bin/test.js new file mode 100644 index 00000000000..6f3fefb9498 --- /dev/null +++ b/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderSpecifyOutputFile/node/bin/test.js @@ -0,0 +1 @@ +//# sourceMappingURL=test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderSpecifyOutputFile/node/sourceRootAbsolutePathModuleMultifolderSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderSpecifyOutputFile/node/sourceRootAbsolutePathModuleMultifolderSpecifyOutputFile.errors.txt new file mode 100644 index 00000000000..ea8c2e58ae5 --- /dev/null +++ b/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderSpecifyOutputFile/node/sourceRootAbsolutePathModuleMultifolderSpecifyOutputFile.errors.txt @@ -0,0 +1,39 @@ +error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. + + +!!! error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +==== ref/m1.ts (0 errors) ==== + export var m1_a1 = 10; + export class m1_c1 { + public m1_c1_p1: number; + } + + export var m1_instance1 = new m1_c1(); + export function m1_f1() { + return m1_instance1; + } +==== ../outputdir_module_multifolder_ref/m2.ts (0 errors) ==== + export var m2_a1 = 10; + export class m2_c1 { + public m2_c1_p1: number; + } + + export var m2_instance1 = new m2_c1(); + export function m2_f1() { + return m2_instance1; + } +==== test.ts (0 errors) ==== + import m1 = require("ref/m1"); + import m2 = require("../outputdir_module_multifolder_ref/m2"); + export var a1 = 10; + export class c1 { + public p1: number; + } + + export var instance1 = new c1(); + export function f1() { + return instance1; + } + + export var a2 = m1.m1_c1; + export var a3 = m2.m2_c1; \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathModuleSimpleSpecifyOutputFile/amd/bin/test.js b/tests/baselines/reference/project/sourceRootAbsolutePathModuleSimpleSpecifyOutputFile/amd/bin/test.js new file mode 100644 index 00000000000..f385e49ecd1 --- /dev/null +++ b/tests/baselines/reference/project/sourceRootAbsolutePathModuleSimpleSpecifyOutputFile/amd/bin/test.js @@ -0,0 +1,30 @@ +define("m1", ["require", "exports"], function (require, exports) { + exports.m1_a1 = 10; + var m1_c1 = (function () { + function m1_c1() { + } + return m1_c1; + })(); + exports.m1_c1 = m1_c1; + exports.m1_instance1 = new m1_c1(); + function m1_f1() { + return exports.m1_instance1; + } + exports.m1_f1 = m1_f1; +}); +define("test", ["require", "exports", "m1"], function (require, exports, m1) { + exports.a1 = 10; + var c1 = (function () { + function c1() { + } + return c1; + })(); + exports.c1 = c1; + exports.instance1 = new c1(); + function f1() { + return exports.instance1; + } + exports.f1 = f1; + exports.a2 = m1.m1_c1; +}); +//# sourceMappingURL=test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathModuleSimpleSpecifyOutputFile/node/bin/test.js b/tests/baselines/reference/project/sourceRootAbsolutePathModuleSimpleSpecifyOutputFile/node/bin/test.js new file mode 100644 index 00000000000..6f3fefb9498 --- /dev/null +++ b/tests/baselines/reference/project/sourceRootAbsolutePathModuleSimpleSpecifyOutputFile/node/bin/test.js @@ -0,0 +1 @@ +//# sourceMappingURL=test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathModuleSimpleSpecifyOutputFile/node/sourceRootAbsolutePathModuleSimpleSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/sourceRootAbsolutePathModuleSimpleSpecifyOutputFile/node/sourceRootAbsolutePathModuleSimpleSpecifyOutputFile.errors.txt new file mode 100644 index 00000000000..0d918d5b2a0 --- /dev/null +++ b/tests/baselines/reference/project/sourceRootAbsolutePathModuleSimpleSpecifyOutputFile/node/sourceRootAbsolutePathModuleSimpleSpecifyOutputFile.errors.txt @@ -0,0 +1,27 @@ +error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. + + +!!! error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +==== m1.ts (0 errors) ==== + export var m1_a1 = 10; + export class m1_c1 { + public m1_c1_p1: number; + } + + export var m1_instance1 = new m1_c1(); + export function m1_f1() { + return m1_instance1; + } +==== test.ts (0 errors) ==== + import m1 = require("m1"); + export var a1 = 10; + export class c1 { + public p1: number; + } + + export var instance1 = new c1(); + export function f1() { + return instance1; + } + + export var a2 = m1.m1_c1; \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathModuleSubfolderSpecifyOutputFile/amd/bin/test.js b/tests/baselines/reference/project/sourceRootAbsolutePathModuleSubfolderSpecifyOutputFile/amd/bin/test.js new file mode 100644 index 00000000000..18d212c7e69 --- /dev/null +++ b/tests/baselines/reference/project/sourceRootAbsolutePathModuleSubfolderSpecifyOutputFile/amd/bin/test.js @@ -0,0 +1,30 @@ +define("ref/m1", ["require", "exports"], function (require, exports) { + exports.m1_a1 = 10; + var m1_c1 = (function () { + function m1_c1() { + } + return m1_c1; + })(); + exports.m1_c1 = m1_c1; + exports.m1_instance1 = new m1_c1(); + function m1_f1() { + return exports.m1_instance1; + } + exports.m1_f1 = m1_f1; +}); +define("test", ["require", "exports", "ref/m1"], function (require, exports, m1) { + exports.a1 = 10; + var c1 = (function () { + function c1() { + } + return c1; + })(); + exports.c1 = c1; + exports.instance1 = new c1(); + function f1() { + return exports.instance1; + } + exports.f1 = f1; + exports.a2 = m1.m1_c1; +}); +//# sourceMappingURL=test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathModuleSubfolderSpecifyOutputFile/node/bin/test.js b/tests/baselines/reference/project/sourceRootAbsolutePathModuleSubfolderSpecifyOutputFile/node/bin/test.js new file mode 100644 index 00000000000..6f3fefb9498 --- /dev/null +++ b/tests/baselines/reference/project/sourceRootAbsolutePathModuleSubfolderSpecifyOutputFile/node/bin/test.js @@ -0,0 +1 @@ +//# sourceMappingURL=test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathModuleSubfolderSpecifyOutputFile/node/sourceRootAbsolutePathModuleSubfolderSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/sourceRootAbsolutePathModuleSubfolderSpecifyOutputFile/node/sourceRootAbsolutePathModuleSubfolderSpecifyOutputFile.errors.txt new file mode 100644 index 00000000000..2468ab068e2 --- /dev/null +++ b/tests/baselines/reference/project/sourceRootAbsolutePathModuleSubfolderSpecifyOutputFile/node/sourceRootAbsolutePathModuleSubfolderSpecifyOutputFile.errors.txt @@ -0,0 +1,27 @@ +error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. + + +!!! error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +==== ref/m1.ts (0 errors) ==== + export var m1_a1 = 10; + export class m1_c1 { + public m1_c1_p1: number; + } + + export var m1_instance1 = new m1_c1(); + export function m1_f1() { + return m1_instance1; + } +==== test.ts (0 errors) ==== + import m1 = require("ref/m1"); + export var a1 = 10; + export class c1 { + public p1: number; + } + + export var instance1 = new c1(); + export function f1() { + return instance1; + } + + export var a2 = m1.m1_c1; \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathMultifolderSpecifyOutputFile/node/sourceRootAbsolutePathMultifolderSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/sourceRootAbsolutePathMultifolderSpecifyOutputFile/node/sourceRootAbsolutePathMultifolderSpecifyOutputFile.errors.txt new file mode 100644 index 00000000000..8deca814d80 --- /dev/null +++ b/tests/baselines/reference/project/sourceRootAbsolutePathMultifolderSpecifyOutputFile/node/sourceRootAbsolutePathMultifolderSpecifyOutputFile.errors.txt @@ -0,0 +1,36 @@ +error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. + + +!!! error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +==== ref/m1.ts (0 errors) ==== + var m1_a1 = 10; + class m1_c1 { + public m1_c1_p1: number; + } + + var m1_instance1 = new m1_c1(); + function m1_f1() { + return m1_instance1; + } +==== ../outputdir_multifolder_ref/m2.ts (0 errors) ==== + var m2_a1 = 10; + class m2_c1 { + public m2_c1_p1: number; + } + + var m2_instance1 = new m2_c1(); + function m2_f1() { + return m2_instance1; + } +==== test.ts (0 errors) ==== + /// + /// + var a1 = 10; + class c1 { + public p1: number; + } + + var instance1 = new c1(); + function f1() { + return instance1; + } \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathSimpleSpecifyOutputFile/node/sourceRootAbsolutePathSimpleSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/sourceRootAbsolutePathSimpleSpecifyOutputFile/node/sourceRootAbsolutePathSimpleSpecifyOutputFile.errors.txt new file mode 100644 index 00000000000..edf8d0637e2 --- /dev/null +++ b/tests/baselines/reference/project/sourceRootAbsolutePathSimpleSpecifyOutputFile/node/sourceRootAbsolutePathSimpleSpecifyOutputFile.errors.txt @@ -0,0 +1,25 @@ +error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. + + +!!! error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +==== m1.ts (0 errors) ==== + var m1_a1 = 10; + class m1_c1 { + public m1_c1_p1: number; + } + + var m1_instance1 = new m1_c1(); + function m1_f1() { + return m1_instance1; + } +==== test.ts (0 errors) ==== + /// + var a1 = 10; + class c1 { + public p1: number; + } + + var instance1 = new c1(); + function f1() { + return instance1; + } \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathSingleFileSpecifyOutputFile/node/sourceRootAbsolutePathSingleFileSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/sourceRootAbsolutePathSingleFileSpecifyOutputFile/node/sourceRootAbsolutePathSingleFileSpecifyOutputFile.errors.txt new file mode 100644 index 00000000000..3413d4675e7 --- /dev/null +++ b/tests/baselines/reference/project/sourceRootAbsolutePathSingleFileSpecifyOutputFile/node/sourceRootAbsolutePathSingleFileSpecifyOutputFile.errors.txt @@ -0,0 +1,14 @@ +error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. + + +!!! error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +==== test.ts (0 errors) ==== + var a1 = 10; + class c1 { + public p1: number; + } + + var instance1 = new c1(); + function f1() { + return instance1; + } \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathSubfolderSpecifyOutputFile/node/sourceRootAbsolutePathSubfolderSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/sourceRootAbsolutePathSubfolderSpecifyOutputFile/node/sourceRootAbsolutePathSubfolderSpecifyOutputFile.errors.txt new file mode 100644 index 00000000000..3a508fede30 --- /dev/null +++ b/tests/baselines/reference/project/sourceRootAbsolutePathSubfolderSpecifyOutputFile/node/sourceRootAbsolutePathSubfolderSpecifyOutputFile.errors.txt @@ -0,0 +1,25 @@ +error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. + + +!!! error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +==== ref/m1.ts (0 errors) ==== + var m1_a1 = 10; + class m1_c1 { + public m1_c1_p1: number; + } + + var m1_instance1 = new m1_c1(); + function m1_f1() { + return m1_instance1; + } +==== test.ts (0 errors) ==== + /// + var a1 = 10; + class c1 { + public p1: number; + } + + var instance1 = new c1(); + function f1() { + return instance1; + } \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFile/amd/bin/test.js b/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFile/amd/bin/test.js new file mode 100644 index 00000000000..13e9de8f87f --- /dev/null +++ b/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFile/amd/bin/test.js @@ -0,0 +1,37 @@ +var m1_a1 = 10; +var m1_c1 = (function () { + function m1_c1() { + } + return m1_c1; +})(); +var m1_instance1 = new m1_c1(); +function m1_f1() { + return m1_instance1; +} +define("ref/m2", ["require", "exports"], function (require, exports) { + exports.m2_a1 = 10; + var m2_c1 = (function () { + function m2_c1() { + } + return m2_c1; + })(); + exports.m2_c1 = m2_c1; + exports.m2_instance1 = new m2_c1(); + function m2_f1() { + return exports.m2_instance1; + } + exports.m2_f1 = m2_f1; +}); +/// +/// +var a1 = 10; +var c1 = (function () { + function c1() { + } + return c1; +})(); +var instance1 = new c1(); +function f1() { + return instance1; +} +//# sourceMappingURL=test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFile/node/bin/test.js b/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFile/node/bin/test.js new file mode 100644 index 00000000000..5af28cf8560 --- /dev/null +++ b/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFile/node/bin/test.js @@ -0,0 +1,23 @@ +var m1_a1 = 10; +var m1_c1 = (function () { + function m1_c1() { + } + return m1_c1; +})(); +var m1_instance1 = new m1_c1(); +function m1_f1() { + return m1_instance1; +} +/// +/// +var a1 = 10; +var c1 = (function () { + function c1() { + } + return c1; +})(); +var instance1 = new c1(); +function f1() { + return instance1; +} +//# sourceMappingURL=test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFile/node/sourceRootRelativePathMixedSubfolderSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFile/node/sourceRootRelativePathMixedSubfolderSpecifyOutputFile.errors.txt new file mode 100644 index 00000000000..9674c11863f --- /dev/null +++ b/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFile/node/sourceRootRelativePathMixedSubfolderSpecifyOutputFile.errors.txt @@ -0,0 +1,36 @@ +error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. + + +!!! error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +==== ref/m1.ts (0 errors) ==== + var m1_a1 = 10; + class m1_c1 { + public m1_c1_p1: number; + } + + var m1_instance1 = new m1_c1(); + function m1_f1() { + return m1_instance1; + } +==== ref/m2.ts (0 errors) ==== + export var m2_a1 = 10; + export class m2_c1 { + public m2_c1_p1: number; + } + + export var m2_instance1 = new m2_c1(); + export function m2_f1() { + return m2_instance1; + } +==== test.ts (0 errors) ==== + /// + /// + var a1 = 10; + class c1 { + public p1: number; + } + + var instance1 = new c1(); + function f1() { + return instance1; + } \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.js b/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.js new file mode 100644 index 00000000000..81bb710c580 --- /dev/null +++ b/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.js @@ -0,0 +1,37 @@ +var m1_a1 = 10; +var m1_c1 = (function () { + function m1_c1() { + } + return m1_c1; +})(); +var m1_instance1 = new m1_c1(); +function m1_f1() { + return m1_instance1; +} +define("ref/m2", ["require", "exports"], function (require, exports) { + exports.m2_a1 = 10; + var m2_c1 = (function () { + function m2_c1() { + } + return m2_c1; + })(); + exports.m2_c1 = m2_c1; + exports.m2_instance1 = new m2_c1(); + function m2_f1() { + return exports.m2_instance1; + } + exports.m2_f1 = m2_f1; +}); +/// +/// +var a1 = 10; +var c1 = (function () { + function c1() { + } + return c1; +})(); +var instance1 = new c1(); +function f1() { + return instance1; +} +//# sourceMappingURL=outAndOutDirFile.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.js b/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.js new file mode 100644 index 00000000000..1750a5975ae --- /dev/null +++ b/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.js @@ -0,0 +1,23 @@ +var m1_a1 = 10; +var m1_c1 = (function () { + function m1_c1() { + } + return m1_c1; +})(); +var m1_instance1 = new m1_c1(); +function m1_f1() { + return m1_instance1; +} +/// +/// +var a1 = 10; +var c1 = (function () { + function c1() { + } + return c1; +})(); +var instance1 = new c1(); +function f1() { + return instance1; +} +//# sourceMappingURL=outAndOutDirFile.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/sourceRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory.errors.txt b/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/sourceRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory.errors.txt new file mode 100644 index 00000000000..9674c11863f --- /dev/null +++ b/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/sourceRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory.errors.txt @@ -0,0 +1,36 @@ +error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. + + +!!! error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +==== ref/m1.ts (0 errors) ==== + var m1_a1 = 10; + class m1_c1 { + public m1_c1_p1: number; + } + + var m1_instance1 = new m1_c1(); + function m1_f1() { + return m1_instance1; + } +==== ref/m2.ts (0 errors) ==== + export var m2_a1 = 10; + export class m2_c1 { + public m2_c1_p1: number; + } + + export var m2_instance1 = new m2_c1(); + export function m2_f1() { + return m2_instance1; + } +==== test.ts (0 errors) ==== + /// + /// + var a1 = 10; + class c1 { + public p1: number; + } + + var instance1 = new c1(); + function f1() { + return instance1; + } \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderSpecifyOutputFile/amd/bin/test.js b/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderSpecifyOutputFile/amd/bin/test.js new file mode 100644 index 00000000000..994e21ca032 --- /dev/null +++ b/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderSpecifyOutputFile/amd/bin/test.js @@ -0,0 +1,45 @@ +define("ref/m1", ["require", "exports"], function (require, exports) { + exports.m1_a1 = 10; + var m1_c1 = (function () { + function m1_c1() { + } + return m1_c1; + })(); + exports.m1_c1 = m1_c1; + exports.m1_instance1 = new m1_c1(); + function m1_f1() { + return exports.m1_instance1; + } + exports.m1_f1 = m1_f1; +}); +define("../outputdir_module_multifolder_ref/m2", ["require", "exports"], function (require, exports) { + exports.m2_a1 = 10; + var m2_c1 = (function () { + function m2_c1() { + } + return m2_c1; + })(); + exports.m2_c1 = m2_c1; + exports.m2_instance1 = new m2_c1(); + function m2_f1() { + return exports.m2_instance1; + } + exports.m2_f1 = m2_f1; +}); +define("test", ["require", "exports", "ref/m1", "../outputdir_module_multifolder_ref/m2"], function (require, exports, m1, m2) { + exports.a1 = 10; + var c1 = (function () { + function c1() { + } + return c1; + })(); + exports.c1 = c1; + exports.instance1 = new c1(); + function f1() { + return exports.instance1; + } + exports.f1 = f1; + exports.a2 = m1.m1_c1; + exports.a3 = m2.m2_c1; +}); +//# sourceMappingURL=test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderSpecifyOutputFile/node/bin/test.js b/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderSpecifyOutputFile/node/bin/test.js new file mode 100644 index 00000000000..6f3fefb9498 --- /dev/null +++ b/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderSpecifyOutputFile/node/bin/test.js @@ -0,0 +1 @@ +//# sourceMappingURL=test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderSpecifyOutputFile/node/sourceRootRelativePathModuleMultifolderSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderSpecifyOutputFile/node/sourceRootRelativePathModuleMultifolderSpecifyOutputFile.errors.txt new file mode 100644 index 00000000000..ea8c2e58ae5 --- /dev/null +++ b/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderSpecifyOutputFile/node/sourceRootRelativePathModuleMultifolderSpecifyOutputFile.errors.txt @@ -0,0 +1,39 @@ +error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. + + +!!! error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +==== ref/m1.ts (0 errors) ==== + export var m1_a1 = 10; + export class m1_c1 { + public m1_c1_p1: number; + } + + export var m1_instance1 = new m1_c1(); + export function m1_f1() { + return m1_instance1; + } +==== ../outputdir_module_multifolder_ref/m2.ts (0 errors) ==== + export var m2_a1 = 10; + export class m2_c1 { + public m2_c1_p1: number; + } + + export var m2_instance1 = new m2_c1(); + export function m2_f1() { + return m2_instance1; + } +==== test.ts (0 errors) ==== + import m1 = require("ref/m1"); + import m2 = require("../outputdir_module_multifolder_ref/m2"); + export var a1 = 10; + export class c1 { + public p1: number; + } + + export var instance1 = new c1(); + export function f1() { + return instance1; + } + + export var a2 = m1.m1_c1; + export var a3 = m2.m2_c1; \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootRelativePathModuleSimpleSpecifyOutputFile/amd/bin/test.js b/tests/baselines/reference/project/sourceRootRelativePathModuleSimpleSpecifyOutputFile/amd/bin/test.js new file mode 100644 index 00000000000..f385e49ecd1 --- /dev/null +++ b/tests/baselines/reference/project/sourceRootRelativePathModuleSimpleSpecifyOutputFile/amd/bin/test.js @@ -0,0 +1,30 @@ +define("m1", ["require", "exports"], function (require, exports) { + exports.m1_a1 = 10; + var m1_c1 = (function () { + function m1_c1() { + } + return m1_c1; + })(); + exports.m1_c1 = m1_c1; + exports.m1_instance1 = new m1_c1(); + function m1_f1() { + return exports.m1_instance1; + } + exports.m1_f1 = m1_f1; +}); +define("test", ["require", "exports", "m1"], function (require, exports, m1) { + exports.a1 = 10; + var c1 = (function () { + function c1() { + } + return c1; + })(); + exports.c1 = c1; + exports.instance1 = new c1(); + function f1() { + return exports.instance1; + } + exports.f1 = f1; + exports.a2 = m1.m1_c1; +}); +//# sourceMappingURL=test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootRelativePathModuleSimpleSpecifyOutputFile/node/bin/test.js b/tests/baselines/reference/project/sourceRootRelativePathModuleSimpleSpecifyOutputFile/node/bin/test.js new file mode 100644 index 00000000000..6f3fefb9498 --- /dev/null +++ b/tests/baselines/reference/project/sourceRootRelativePathModuleSimpleSpecifyOutputFile/node/bin/test.js @@ -0,0 +1 @@ +//# sourceMappingURL=test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootRelativePathModuleSimpleSpecifyOutputFile/node/sourceRootRelativePathModuleSimpleSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/sourceRootRelativePathModuleSimpleSpecifyOutputFile/node/sourceRootRelativePathModuleSimpleSpecifyOutputFile.errors.txt new file mode 100644 index 00000000000..0d918d5b2a0 --- /dev/null +++ b/tests/baselines/reference/project/sourceRootRelativePathModuleSimpleSpecifyOutputFile/node/sourceRootRelativePathModuleSimpleSpecifyOutputFile.errors.txt @@ -0,0 +1,27 @@ +error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. + + +!!! error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +==== m1.ts (0 errors) ==== + export var m1_a1 = 10; + export class m1_c1 { + public m1_c1_p1: number; + } + + export var m1_instance1 = new m1_c1(); + export function m1_f1() { + return m1_instance1; + } +==== test.ts (0 errors) ==== + import m1 = require("m1"); + export var a1 = 10; + export class c1 { + public p1: number; + } + + export var instance1 = new c1(); + export function f1() { + return instance1; + } + + export var a2 = m1.m1_c1; \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootRelativePathModuleSubfolderSpecifyOutputFile/amd/bin/test.js b/tests/baselines/reference/project/sourceRootRelativePathModuleSubfolderSpecifyOutputFile/amd/bin/test.js new file mode 100644 index 00000000000..18d212c7e69 --- /dev/null +++ b/tests/baselines/reference/project/sourceRootRelativePathModuleSubfolderSpecifyOutputFile/amd/bin/test.js @@ -0,0 +1,30 @@ +define("ref/m1", ["require", "exports"], function (require, exports) { + exports.m1_a1 = 10; + var m1_c1 = (function () { + function m1_c1() { + } + return m1_c1; + })(); + exports.m1_c1 = m1_c1; + exports.m1_instance1 = new m1_c1(); + function m1_f1() { + return exports.m1_instance1; + } + exports.m1_f1 = m1_f1; +}); +define("test", ["require", "exports", "ref/m1"], function (require, exports, m1) { + exports.a1 = 10; + var c1 = (function () { + function c1() { + } + return c1; + })(); + exports.c1 = c1; + exports.instance1 = new c1(); + function f1() { + return exports.instance1; + } + exports.f1 = f1; + exports.a2 = m1.m1_c1; +}); +//# sourceMappingURL=test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootRelativePathModuleSubfolderSpecifyOutputFile/node/bin/test.js b/tests/baselines/reference/project/sourceRootRelativePathModuleSubfolderSpecifyOutputFile/node/bin/test.js new file mode 100644 index 00000000000..6f3fefb9498 --- /dev/null +++ b/tests/baselines/reference/project/sourceRootRelativePathModuleSubfolderSpecifyOutputFile/node/bin/test.js @@ -0,0 +1 @@ +//# sourceMappingURL=test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootRelativePathModuleSubfolderSpecifyOutputFile/node/sourceRootRelativePathModuleSubfolderSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/sourceRootRelativePathModuleSubfolderSpecifyOutputFile/node/sourceRootRelativePathModuleSubfolderSpecifyOutputFile.errors.txt new file mode 100644 index 00000000000..2468ab068e2 --- /dev/null +++ b/tests/baselines/reference/project/sourceRootRelativePathModuleSubfolderSpecifyOutputFile/node/sourceRootRelativePathModuleSubfolderSpecifyOutputFile.errors.txt @@ -0,0 +1,27 @@ +error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. + + +!!! error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +==== ref/m1.ts (0 errors) ==== + export var m1_a1 = 10; + export class m1_c1 { + public m1_c1_p1: number; + } + + export var m1_instance1 = new m1_c1(); + export function m1_f1() { + return m1_instance1; + } +==== test.ts (0 errors) ==== + import m1 = require("ref/m1"); + export var a1 = 10; + export class c1 { + public p1: number; + } + + export var instance1 = new c1(); + export function f1() { + return instance1; + } + + export var a2 = m1.m1_c1; \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootRelativePathMultifolderSpecifyOutputFile/node/sourceRootRelativePathMultifolderSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/sourceRootRelativePathMultifolderSpecifyOutputFile/node/sourceRootRelativePathMultifolderSpecifyOutputFile.errors.txt new file mode 100644 index 00000000000..8deca814d80 --- /dev/null +++ b/tests/baselines/reference/project/sourceRootRelativePathMultifolderSpecifyOutputFile/node/sourceRootRelativePathMultifolderSpecifyOutputFile.errors.txt @@ -0,0 +1,36 @@ +error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. + + +!!! error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +==== ref/m1.ts (0 errors) ==== + var m1_a1 = 10; + class m1_c1 { + public m1_c1_p1: number; + } + + var m1_instance1 = new m1_c1(); + function m1_f1() { + return m1_instance1; + } +==== ../outputdir_multifolder_ref/m2.ts (0 errors) ==== + var m2_a1 = 10; + class m2_c1 { + public m2_c1_p1: number; + } + + var m2_instance1 = new m2_c1(); + function m2_f1() { + return m2_instance1; + } +==== test.ts (0 errors) ==== + /// + /// + var a1 = 10; + class c1 { + public p1: number; + } + + var instance1 = new c1(); + function f1() { + return instance1; + } \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootRelativePathSimpleSpecifyOutputFile/node/sourceRootRelativePathSimpleSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/sourceRootRelativePathSimpleSpecifyOutputFile/node/sourceRootRelativePathSimpleSpecifyOutputFile.errors.txt new file mode 100644 index 00000000000..edf8d0637e2 --- /dev/null +++ b/tests/baselines/reference/project/sourceRootRelativePathSimpleSpecifyOutputFile/node/sourceRootRelativePathSimpleSpecifyOutputFile.errors.txt @@ -0,0 +1,25 @@ +error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. + + +!!! error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +==== m1.ts (0 errors) ==== + var m1_a1 = 10; + class m1_c1 { + public m1_c1_p1: number; + } + + var m1_instance1 = new m1_c1(); + function m1_f1() { + return m1_instance1; + } +==== test.ts (0 errors) ==== + /// + var a1 = 10; + class c1 { + public p1: number; + } + + var instance1 = new c1(); + function f1() { + return instance1; + } \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootRelativePathSingleFileSpecifyOutputFile/node/sourceRootRelativePathSingleFileSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/sourceRootRelativePathSingleFileSpecifyOutputFile/node/sourceRootRelativePathSingleFileSpecifyOutputFile.errors.txt new file mode 100644 index 00000000000..3413d4675e7 --- /dev/null +++ b/tests/baselines/reference/project/sourceRootRelativePathSingleFileSpecifyOutputFile/node/sourceRootRelativePathSingleFileSpecifyOutputFile.errors.txt @@ -0,0 +1,14 @@ +error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. + + +!!! error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +==== test.ts (0 errors) ==== + var a1 = 10; + class c1 { + public p1: number; + } + + var instance1 = new c1(); + function f1() { + return instance1; + } \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootRelativePathSubfolderSpecifyOutputFile/node/sourceRootRelativePathSubfolderSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/sourceRootRelativePathSubfolderSpecifyOutputFile/node/sourceRootRelativePathSubfolderSpecifyOutputFile.errors.txt new file mode 100644 index 00000000000..3a508fede30 --- /dev/null +++ b/tests/baselines/reference/project/sourceRootRelativePathSubfolderSpecifyOutputFile/node/sourceRootRelativePathSubfolderSpecifyOutputFile.errors.txt @@ -0,0 +1,25 @@ +error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. + + +!!! error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +==== ref/m1.ts (0 errors) ==== + var m1_a1 = 10; + class m1_c1 { + public m1_c1_p1: number; + } + + var m1_instance1 = new m1_c1(); + function m1_f1() { + return m1_instance1; + } +==== test.ts (0 errors) ==== + /// + var a1 = 10; + class c1 { + public p1: number; + } + + var instance1 = new c1(); + function f1() { + return instance1; + } \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFile/amd/bin/test.js b/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFile/amd/bin/test.js new file mode 100644 index 00000000000..13e9de8f87f --- /dev/null +++ b/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFile/amd/bin/test.js @@ -0,0 +1,37 @@ +var m1_a1 = 10; +var m1_c1 = (function () { + function m1_c1() { + } + return m1_c1; +})(); +var m1_instance1 = new m1_c1(); +function m1_f1() { + return m1_instance1; +} +define("ref/m2", ["require", "exports"], function (require, exports) { + exports.m2_a1 = 10; + var m2_c1 = (function () { + function m2_c1() { + } + return m2_c1; + })(); + exports.m2_c1 = m2_c1; + exports.m2_instance1 = new m2_c1(); + function m2_f1() { + return exports.m2_instance1; + } + exports.m2_f1 = m2_f1; +}); +/// +/// +var a1 = 10; +var c1 = (function () { + function c1() { + } + return c1; +})(); +var instance1 = new c1(); +function f1() { + return instance1; +} +//# sourceMappingURL=test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFile/node/bin/test.js b/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFile/node/bin/test.js new file mode 100644 index 00000000000..5af28cf8560 --- /dev/null +++ b/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFile/node/bin/test.js @@ -0,0 +1,23 @@ +var m1_a1 = 10; +var m1_c1 = (function () { + function m1_c1() { + } + return m1_c1; +})(); +var m1_instance1 = new m1_c1(); +function m1_f1() { + return m1_instance1; +} +/// +/// +var a1 = 10; +var c1 = (function () { + function c1() { + } + return c1; +})(); +var instance1 = new c1(); +function f1() { + return instance1; +} +//# sourceMappingURL=test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFile/node/sourcemapMixedSubfolderSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFile/node/sourcemapMixedSubfolderSpecifyOutputFile.errors.txt new file mode 100644 index 00000000000..9674c11863f --- /dev/null +++ b/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFile/node/sourcemapMixedSubfolderSpecifyOutputFile.errors.txt @@ -0,0 +1,36 @@ +error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. + + +!!! error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +==== ref/m1.ts (0 errors) ==== + var m1_a1 = 10; + class m1_c1 { + public m1_c1_p1: number; + } + + var m1_instance1 = new m1_c1(); + function m1_f1() { + return m1_instance1; + } +==== ref/m2.ts (0 errors) ==== + export var m2_a1 = 10; + export class m2_c1 { + public m2_c1_p1: number; + } + + export var m2_instance1 = new m2_c1(); + export function m2_f1() { + return m2_instance1; + } +==== test.ts (0 errors) ==== + /// + /// + var a1 = 10; + class c1 { + public p1: number; + } + + var instance1 = new c1(); + function f1() { + return instance1; + } \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.js b/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.js new file mode 100644 index 00000000000..81bb710c580 --- /dev/null +++ b/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.js @@ -0,0 +1,37 @@ +var m1_a1 = 10; +var m1_c1 = (function () { + function m1_c1() { + } + return m1_c1; +})(); +var m1_instance1 = new m1_c1(); +function m1_f1() { + return m1_instance1; +} +define("ref/m2", ["require", "exports"], function (require, exports) { + exports.m2_a1 = 10; + var m2_c1 = (function () { + function m2_c1() { + } + return m2_c1; + })(); + exports.m2_c1 = m2_c1; + exports.m2_instance1 = new m2_c1(); + function m2_f1() { + return exports.m2_instance1; + } + exports.m2_f1 = m2_f1; +}); +/// +/// +var a1 = 10; +var c1 = (function () { + function c1() { + } + return c1; +})(); +var instance1 = new c1(); +function f1() { + return instance1; +} +//# sourceMappingURL=outAndOutDirFile.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.js b/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.js new file mode 100644 index 00000000000..1750a5975ae --- /dev/null +++ b/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.js @@ -0,0 +1,23 @@ +var m1_a1 = 10; +var m1_c1 = (function () { + function m1_c1() { + } + return m1_c1; +})(); +var m1_instance1 = new m1_c1(); +function m1_f1() { + return m1_instance1; +} +/// +/// +var a1 = 10; +var c1 = (function () { + function c1() { + } + return c1; +})(); +var instance1 = new c1(); +function f1() { + return instance1; +} +//# sourceMappingURL=outAndOutDirFile.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/sourcemapMixedSubfolderSpecifyOutputFileAndOutputDirectory.errors.txt b/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/sourcemapMixedSubfolderSpecifyOutputFileAndOutputDirectory.errors.txt new file mode 100644 index 00000000000..9674c11863f --- /dev/null +++ b/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/sourcemapMixedSubfolderSpecifyOutputFileAndOutputDirectory.errors.txt @@ -0,0 +1,36 @@ +error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. + + +!!! error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +==== ref/m1.ts (0 errors) ==== + var m1_a1 = 10; + class m1_c1 { + public m1_c1_p1: number; + } + + var m1_instance1 = new m1_c1(); + function m1_f1() { + return m1_instance1; + } +==== ref/m2.ts (0 errors) ==== + export var m2_a1 = 10; + export class m2_c1 { + public m2_c1_p1: number; + } + + export var m2_instance1 = new m2_c1(); + export function m2_f1() { + return m2_instance1; + } +==== test.ts (0 errors) ==== + /// + /// + var a1 = 10; + class c1 { + public p1: number; + } + + var instance1 = new c1(); + function f1() { + return instance1; + } \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcemapModuleMultifolderSpecifyOutputFile/amd/bin/test.js b/tests/baselines/reference/project/sourcemapModuleMultifolderSpecifyOutputFile/amd/bin/test.js new file mode 100644 index 00000000000..994e21ca032 --- /dev/null +++ b/tests/baselines/reference/project/sourcemapModuleMultifolderSpecifyOutputFile/amd/bin/test.js @@ -0,0 +1,45 @@ +define("ref/m1", ["require", "exports"], function (require, exports) { + exports.m1_a1 = 10; + var m1_c1 = (function () { + function m1_c1() { + } + return m1_c1; + })(); + exports.m1_c1 = m1_c1; + exports.m1_instance1 = new m1_c1(); + function m1_f1() { + return exports.m1_instance1; + } + exports.m1_f1 = m1_f1; +}); +define("../outputdir_module_multifolder_ref/m2", ["require", "exports"], function (require, exports) { + exports.m2_a1 = 10; + var m2_c1 = (function () { + function m2_c1() { + } + return m2_c1; + })(); + exports.m2_c1 = m2_c1; + exports.m2_instance1 = new m2_c1(); + function m2_f1() { + return exports.m2_instance1; + } + exports.m2_f1 = m2_f1; +}); +define("test", ["require", "exports", "ref/m1", "../outputdir_module_multifolder_ref/m2"], function (require, exports, m1, m2) { + exports.a1 = 10; + var c1 = (function () { + function c1() { + } + return c1; + })(); + exports.c1 = c1; + exports.instance1 = new c1(); + function f1() { + return exports.instance1; + } + exports.f1 = f1; + exports.a2 = m1.m1_c1; + exports.a3 = m2.m2_c1; +}); +//# sourceMappingURL=test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcemapModuleMultifolderSpecifyOutputFile/node/bin/test.js b/tests/baselines/reference/project/sourcemapModuleMultifolderSpecifyOutputFile/node/bin/test.js new file mode 100644 index 00000000000..6f3fefb9498 --- /dev/null +++ b/tests/baselines/reference/project/sourcemapModuleMultifolderSpecifyOutputFile/node/bin/test.js @@ -0,0 +1 @@ +//# sourceMappingURL=test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcemapModuleMultifolderSpecifyOutputFile/node/sourcemapModuleMultifolderSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/sourcemapModuleMultifolderSpecifyOutputFile/node/sourcemapModuleMultifolderSpecifyOutputFile.errors.txt new file mode 100644 index 00000000000..ea8c2e58ae5 --- /dev/null +++ b/tests/baselines/reference/project/sourcemapModuleMultifolderSpecifyOutputFile/node/sourcemapModuleMultifolderSpecifyOutputFile.errors.txt @@ -0,0 +1,39 @@ +error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. + + +!!! error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +==== ref/m1.ts (0 errors) ==== + export var m1_a1 = 10; + export class m1_c1 { + public m1_c1_p1: number; + } + + export var m1_instance1 = new m1_c1(); + export function m1_f1() { + return m1_instance1; + } +==== ../outputdir_module_multifolder_ref/m2.ts (0 errors) ==== + export var m2_a1 = 10; + export class m2_c1 { + public m2_c1_p1: number; + } + + export var m2_instance1 = new m2_c1(); + export function m2_f1() { + return m2_instance1; + } +==== test.ts (0 errors) ==== + import m1 = require("ref/m1"); + import m2 = require("../outputdir_module_multifolder_ref/m2"); + export var a1 = 10; + export class c1 { + public p1: number; + } + + export var instance1 = new c1(); + export function f1() { + return instance1; + } + + export var a2 = m1.m1_c1; + export var a3 = m2.m2_c1; \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcemapModuleSimpleSpecifyOutputFile/amd/bin/test.js b/tests/baselines/reference/project/sourcemapModuleSimpleSpecifyOutputFile/amd/bin/test.js new file mode 100644 index 00000000000..f385e49ecd1 --- /dev/null +++ b/tests/baselines/reference/project/sourcemapModuleSimpleSpecifyOutputFile/amd/bin/test.js @@ -0,0 +1,30 @@ +define("m1", ["require", "exports"], function (require, exports) { + exports.m1_a1 = 10; + var m1_c1 = (function () { + function m1_c1() { + } + return m1_c1; + })(); + exports.m1_c1 = m1_c1; + exports.m1_instance1 = new m1_c1(); + function m1_f1() { + return exports.m1_instance1; + } + exports.m1_f1 = m1_f1; +}); +define("test", ["require", "exports", "m1"], function (require, exports, m1) { + exports.a1 = 10; + var c1 = (function () { + function c1() { + } + return c1; + })(); + exports.c1 = c1; + exports.instance1 = new c1(); + function f1() { + return exports.instance1; + } + exports.f1 = f1; + exports.a2 = m1.m1_c1; +}); +//# sourceMappingURL=test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcemapModuleSimpleSpecifyOutputFile/node/bin/test.js b/tests/baselines/reference/project/sourcemapModuleSimpleSpecifyOutputFile/node/bin/test.js new file mode 100644 index 00000000000..6f3fefb9498 --- /dev/null +++ b/tests/baselines/reference/project/sourcemapModuleSimpleSpecifyOutputFile/node/bin/test.js @@ -0,0 +1 @@ +//# sourceMappingURL=test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcemapModuleSimpleSpecifyOutputFile/node/sourcemapModuleSimpleSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/sourcemapModuleSimpleSpecifyOutputFile/node/sourcemapModuleSimpleSpecifyOutputFile.errors.txt new file mode 100644 index 00000000000..0d918d5b2a0 --- /dev/null +++ b/tests/baselines/reference/project/sourcemapModuleSimpleSpecifyOutputFile/node/sourcemapModuleSimpleSpecifyOutputFile.errors.txt @@ -0,0 +1,27 @@ +error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. + + +!!! error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +==== m1.ts (0 errors) ==== + export var m1_a1 = 10; + export class m1_c1 { + public m1_c1_p1: number; + } + + export var m1_instance1 = new m1_c1(); + export function m1_f1() { + return m1_instance1; + } +==== test.ts (0 errors) ==== + import m1 = require("m1"); + export var a1 = 10; + export class c1 { + public p1: number; + } + + export var instance1 = new c1(); + export function f1() { + return instance1; + } + + export var a2 = m1.m1_c1; \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcemapModuleSubfolderSpecifyOutputFile/amd/bin/test.js b/tests/baselines/reference/project/sourcemapModuleSubfolderSpecifyOutputFile/amd/bin/test.js new file mode 100644 index 00000000000..18d212c7e69 --- /dev/null +++ b/tests/baselines/reference/project/sourcemapModuleSubfolderSpecifyOutputFile/amd/bin/test.js @@ -0,0 +1,30 @@ +define("ref/m1", ["require", "exports"], function (require, exports) { + exports.m1_a1 = 10; + var m1_c1 = (function () { + function m1_c1() { + } + return m1_c1; + })(); + exports.m1_c1 = m1_c1; + exports.m1_instance1 = new m1_c1(); + function m1_f1() { + return exports.m1_instance1; + } + exports.m1_f1 = m1_f1; +}); +define("test", ["require", "exports", "ref/m1"], function (require, exports, m1) { + exports.a1 = 10; + var c1 = (function () { + function c1() { + } + return c1; + })(); + exports.c1 = c1; + exports.instance1 = new c1(); + function f1() { + return exports.instance1; + } + exports.f1 = f1; + exports.a2 = m1.m1_c1; +}); +//# sourceMappingURL=test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcemapModuleSubfolderSpecifyOutputFile/node/bin/test.js b/tests/baselines/reference/project/sourcemapModuleSubfolderSpecifyOutputFile/node/bin/test.js new file mode 100644 index 00000000000..6f3fefb9498 --- /dev/null +++ b/tests/baselines/reference/project/sourcemapModuleSubfolderSpecifyOutputFile/node/bin/test.js @@ -0,0 +1 @@ +//# sourceMappingURL=test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcemapModuleSubfolderSpecifyOutputFile/node/sourcemapModuleSubfolderSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/sourcemapModuleSubfolderSpecifyOutputFile/node/sourcemapModuleSubfolderSpecifyOutputFile.errors.txt new file mode 100644 index 00000000000..2468ab068e2 --- /dev/null +++ b/tests/baselines/reference/project/sourcemapModuleSubfolderSpecifyOutputFile/node/sourcemapModuleSubfolderSpecifyOutputFile.errors.txt @@ -0,0 +1,27 @@ +error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. + + +!!! error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +==== ref/m1.ts (0 errors) ==== + export var m1_a1 = 10; + export class m1_c1 { + public m1_c1_p1: number; + } + + export var m1_instance1 = new m1_c1(); + export function m1_f1() { + return m1_instance1; + } +==== test.ts (0 errors) ==== + import m1 = require("ref/m1"); + export var a1 = 10; + export class c1 { + public p1: number; + } + + export var instance1 = new c1(); + export function f1() { + return instance1; + } + + export var a2 = m1.m1_c1; \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcemapMultifolderSpecifyOutputFile/node/sourcemapMultifolderSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/sourcemapMultifolderSpecifyOutputFile/node/sourcemapMultifolderSpecifyOutputFile.errors.txt new file mode 100644 index 00000000000..8deca814d80 --- /dev/null +++ b/tests/baselines/reference/project/sourcemapMultifolderSpecifyOutputFile/node/sourcemapMultifolderSpecifyOutputFile.errors.txt @@ -0,0 +1,36 @@ +error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. + + +!!! error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +==== ref/m1.ts (0 errors) ==== + var m1_a1 = 10; + class m1_c1 { + public m1_c1_p1: number; + } + + var m1_instance1 = new m1_c1(); + function m1_f1() { + return m1_instance1; + } +==== ../outputdir_multifolder_ref/m2.ts (0 errors) ==== + var m2_a1 = 10; + class m2_c1 { + public m2_c1_p1: number; + } + + var m2_instance1 = new m2_c1(); + function m2_f1() { + return m2_instance1; + } +==== test.ts (0 errors) ==== + /// + /// + var a1 = 10; + class c1 { + public p1: number; + } + + var instance1 = new c1(); + function f1() { + return instance1; + } \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcemapSimpleSpecifyOutputFile/node/sourcemapSimpleSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/sourcemapSimpleSpecifyOutputFile/node/sourcemapSimpleSpecifyOutputFile.errors.txt new file mode 100644 index 00000000000..edf8d0637e2 --- /dev/null +++ b/tests/baselines/reference/project/sourcemapSimpleSpecifyOutputFile/node/sourcemapSimpleSpecifyOutputFile.errors.txt @@ -0,0 +1,25 @@ +error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. + + +!!! error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +==== m1.ts (0 errors) ==== + var m1_a1 = 10; + class m1_c1 { + public m1_c1_p1: number; + } + + var m1_instance1 = new m1_c1(); + function m1_f1() { + return m1_instance1; + } +==== test.ts (0 errors) ==== + /// + var a1 = 10; + class c1 { + public p1: number; + } + + var instance1 = new c1(); + function f1() { + return instance1; + } \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcemapSingleFileSpecifyOutputFile/node/sourcemapSingleFileSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/sourcemapSingleFileSpecifyOutputFile/node/sourcemapSingleFileSpecifyOutputFile.errors.txt new file mode 100644 index 00000000000..3413d4675e7 --- /dev/null +++ b/tests/baselines/reference/project/sourcemapSingleFileSpecifyOutputFile/node/sourcemapSingleFileSpecifyOutputFile.errors.txt @@ -0,0 +1,14 @@ +error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. + + +!!! error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +==== test.ts (0 errors) ==== + var a1 = 10; + class c1 { + public p1: number; + } + + var instance1 = new c1(); + function f1() { + return instance1; + } \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcemapSubfolderSpecifyOutputFile/node/sourcemapSubfolderSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/sourcemapSubfolderSpecifyOutputFile/node/sourcemapSubfolderSpecifyOutputFile.errors.txt new file mode 100644 index 00000000000..3a508fede30 --- /dev/null +++ b/tests/baselines/reference/project/sourcemapSubfolderSpecifyOutputFile/node/sourcemapSubfolderSpecifyOutputFile.errors.txt @@ -0,0 +1,25 @@ +error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. + + +!!! error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +==== ref/m1.ts (0 errors) ==== + var m1_a1 = 10; + class m1_c1 { + public m1_c1_p1: number; + } + + var m1_instance1 = new m1_c1(); + function m1_f1() { + return m1_instance1; + } +==== test.ts (0 errors) ==== + /// + var a1 = 10; + class c1 { + public p1: number; + } + + var instance1 = new c1(); + function f1() { + return instance1; + } \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFile/amd/bin/test.js b/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFile/amd/bin/test.js new file mode 100644 index 00000000000..13e9de8f87f --- /dev/null +++ b/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFile/amd/bin/test.js @@ -0,0 +1,37 @@ +var m1_a1 = 10; +var m1_c1 = (function () { + function m1_c1() { + } + return m1_c1; +})(); +var m1_instance1 = new m1_c1(); +function m1_f1() { + return m1_instance1; +} +define("ref/m2", ["require", "exports"], function (require, exports) { + exports.m2_a1 = 10; + var m2_c1 = (function () { + function m2_c1() { + } + return m2_c1; + })(); + exports.m2_c1 = m2_c1; + exports.m2_instance1 = new m2_c1(); + function m2_f1() { + return exports.m2_instance1; + } + exports.m2_f1 = m2_f1; +}); +/// +/// +var a1 = 10; +var c1 = (function () { + function c1() { + } + return c1; +})(); +var instance1 = new c1(); +function f1() { + return instance1; +} +//# sourceMappingURL=test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFile/node/bin/test.js b/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFile/node/bin/test.js new file mode 100644 index 00000000000..5af28cf8560 --- /dev/null +++ b/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFile/node/bin/test.js @@ -0,0 +1,23 @@ +var m1_a1 = 10; +var m1_c1 = (function () { + function m1_c1() { + } + return m1_c1; +})(); +var m1_instance1 = new m1_c1(); +function m1_f1() { + return m1_instance1; +} +/// +/// +var a1 = 10; +var c1 = (function () { + function c1() { + } + return c1; +})(); +var instance1 = new c1(); +function f1() { + return instance1; +} +//# sourceMappingURL=test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFile/node/sourcerootUrlMixedSubfolderSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFile/node/sourcerootUrlMixedSubfolderSpecifyOutputFile.errors.txt new file mode 100644 index 00000000000..9674c11863f --- /dev/null +++ b/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFile/node/sourcerootUrlMixedSubfolderSpecifyOutputFile.errors.txt @@ -0,0 +1,36 @@ +error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. + + +!!! error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +==== ref/m1.ts (0 errors) ==== + var m1_a1 = 10; + class m1_c1 { + public m1_c1_p1: number; + } + + var m1_instance1 = new m1_c1(); + function m1_f1() { + return m1_instance1; + } +==== ref/m2.ts (0 errors) ==== + export var m2_a1 = 10; + export class m2_c1 { + public m2_c1_p1: number; + } + + export var m2_instance1 = new m2_c1(); + export function m2_f1() { + return m2_instance1; + } +==== test.ts (0 errors) ==== + /// + /// + var a1 = 10; + class c1 { + public p1: number; + } + + var instance1 = new c1(); + function f1() { + return instance1; + } \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.js b/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.js new file mode 100644 index 00000000000..81bb710c580 --- /dev/null +++ b/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.js @@ -0,0 +1,37 @@ +var m1_a1 = 10; +var m1_c1 = (function () { + function m1_c1() { + } + return m1_c1; +})(); +var m1_instance1 = new m1_c1(); +function m1_f1() { + return m1_instance1; +} +define("ref/m2", ["require", "exports"], function (require, exports) { + exports.m2_a1 = 10; + var m2_c1 = (function () { + function m2_c1() { + } + return m2_c1; + })(); + exports.m2_c1 = m2_c1; + exports.m2_instance1 = new m2_c1(); + function m2_f1() { + return exports.m2_instance1; + } + exports.m2_f1 = m2_f1; +}); +/// +/// +var a1 = 10; +var c1 = (function () { + function c1() { + } + return c1; +})(); +var instance1 = new c1(); +function f1() { + return instance1; +} +//# sourceMappingURL=outAndOutDirFile.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.js b/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.js new file mode 100644 index 00000000000..1750a5975ae --- /dev/null +++ b/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.js @@ -0,0 +1,23 @@ +var m1_a1 = 10; +var m1_c1 = (function () { + function m1_c1() { + } + return m1_c1; +})(); +var m1_instance1 = new m1_c1(); +function m1_f1() { + return m1_instance1; +} +/// +/// +var a1 = 10; +var c1 = (function () { + function c1() { + } + return c1; +})(); +var instance1 = new c1(); +function f1() { + return instance1; +} +//# sourceMappingURL=outAndOutDirFile.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/sourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory.errors.txt b/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/sourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory.errors.txt new file mode 100644 index 00000000000..9674c11863f --- /dev/null +++ b/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/sourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory.errors.txt @@ -0,0 +1,36 @@ +error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. + + +!!! error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +==== ref/m1.ts (0 errors) ==== + var m1_a1 = 10; + class m1_c1 { + public m1_c1_p1: number; + } + + var m1_instance1 = new m1_c1(); + function m1_f1() { + return m1_instance1; + } +==== ref/m2.ts (0 errors) ==== + export var m2_a1 = 10; + export class m2_c1 { + public m2_c1_p1: number; + } + + export var m2_instance1 = new m2_c1(); + export function m2_f1() { + return m2_instance1; + } +==== test.ts (0 errors) ==== + /// + /// + var a1 = 10; + class c1 { + public p1: number; + } + + var instance1 = new c1(); + function f1() { + return instance1; + } \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcerootUrlModuleMultifolderSpecifyOutputFile/amd/bin/test.js b/tests/baselines/reference/project/sourcerootUrlModuleMultifolderSpecifyOutputFile/amd/bin/test.js new file mode 100644 index 00000000000..994e21ca032 --- /dev/null +++ b/tests/baselines/reference/project/sourcerootUrlModuleMultifolderSpecifyOutputFile/amd/bin/test.js @@ -0,0 +1,45 @@ +define("ref/m1", ["require", "exports"], function (require, exports) { + exports.m1_a1 = 10; + var m1_c1 = (function () { + function m1_c1() { + } + return m1_c1; + })(); + exports.m1_c1 = m1_c1; + exports.m1_instance1 = new m1_c1(); + function m1_f1() { + return exports.m1_instance1; + } + exports.m1_f1 = m1_f1; +}); +define("../outputdir_module_multifolder_ref/m2", ["require", "exports"], function (require, exports) { + exports.m2_a1 = 10; + var m2_c1 = (function () { + function m2_c1() { + } + return m2_c1; + })(); + exports.m2_c1 = m2_c1; + exports.m2_instance1 = new m2_c1(); + function m2_f1() { + return exports.m2_instance1; + } + exports.m2_f1 = m2_f1; +}); +define("test", ["require", "exports", "ref/m1", "../outputdir_module_multifolder_ref/m2"], function (require, exports, m1, m2) { + exports.a1 = 10; + var c1 = (function () { + function c1() { + } + return c1; + })(); + exports.c1 = c1; + exports.instance1 = new c1(); + function f1() { + return exports.instance1; + } + exports.f1 = f1; + exports.a2 = m1.m1_c1; + exports.a3 = m2.m2_c1; +}); +//# sourceMappingURL=test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcerootUrlModuleMultifolderSpecifyOutputFile/node/bin/test.js b/tests/baselines/reference/project/sourcerootUrlModuleMultifolderSpecifyOutputFile/node/bin/test.js new file mode 100644 index 00000000000..6f3fefb9498 --- /dev/null +++ b/tests/baselines/reference/project/sourcerootUrlModuleMultifolderSpecifyOutputFile/node/bin/test.js @@ -0,0 +1 @@ +//# sourceMappingURL=test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcerootUrlModuleMultifolderSpecifyOutputFile/node/sourcerootUrlModuleMultifolderSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/sourcerootUrlModuleMultifolderSpecifyOutputFile/node/sourcerootUrlModuleMultifolderSpecifyOutputFile.errors.txt new file mode 100644 index 00000000000..ea8c2e58ae5 --- /dev/null +++ b/tests/baselines/reference/project/sourcerootUrlModuleMultifolderSpecifyOutputFile/node/sourcerootUrlModuleMultifolderSpecifyOutputFile.errors.txt @@ -0,0 +1,39 @@ +error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. + + +!!! error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +==== ref/m1.ts (0 errors) ==== + export var m1_a1 = 10; + export class m1_c1 { + public m1_c1_p1: number; + } + + export var m1_instance1 = new m1_c1(); + export function m1_f1() { + return m1_instance1; + } +==== ../outputdir_module_multifolder_ref/m2.ts (0 errors) ==== + export var m2_a1 = 10; + export class m2_c1 { + public m2_c1_p1: number; + } + + export var m2_instance1 = new m2_c1(); + export function m2_f1() { + return m2_instance1; + } +==== test.ts (0 errors) ==== + import m1 = require("ref/m1"); + import m2 = require("../outputdir_module_multifolder_ref/m2"); + export var a1 = 10; + export class c1 { + public p1: number; + } + + export var instance1 = new c1(); + export function f1() { + return instance1; + } + + export var a2 = m1.m1_c1; + export var a3 = m2.m2_c1; \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcerootUrlModuleSimpleSpecifyOutputFile/amd/bin/test.js b/tests/baselines/reference/project/sourcerootUrlModuleSimpleSpecifyOutputFile/amd/bin/test.js new file mode 100644 index 00000000000..f385e49ecd1 --- /dev/null +++ b/tests/baselines/reference/project/sourcerootUrlModuleSimpleSpecifyOutputFile/amd/bin/test.js @@ -0,0 +1,30 @@ +define("m1", ["require", "exports"], function (require, exports) { + exports.m1_a1 = 10; + var m1_c1 = (function () { + function m1_c1() { + } + return m1_c1; + })(); + exports.m1_c1 = m1_c1; + exports.m1_instance1 = new m1_c1(); + function m1_f1() { + return exports.m1_instance1; + } + exports.m1_f1 = m1_f1; +}); +define("test", ["require", "exports", "m1"], function (require, exports, m1) { + exports.a1 = 10; + var c1 = (function () { + function c1() { + } + return c1; + })(); + exports.c1 = c1; + exports.instance1 = new c1(); + function f1() { + return exports.instance1; + } + exports.f1 = f1; + exports.a2 = m1.m1_c1; +}); +//# sourceMappingURL=test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcerootUrlModuleSimpleSpecifyOutputFile/node/bin/test.js b/tests/baselines/reference/project/sourcerootUrlModuleSimpleSpecifyOutputFile/node/bin/test.js new file mode 100644 index 00000000000..6f3fefb9498 --- /dev/null +++ b/tests/baselines/reference/project/sourcerootUrlModuleSimpleSpecifyOutputFile/node/bin/test.js @@ -0,0 +1 @@ +//# sourceMappingURL=test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcerootUrlModuleSimpleSpecifyOutputFile/node/sourcerootUrlModuleSimpleSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/sourcerootUrlModuleSimpleSpecifyOutputFile/node/sourcerootUrlModuleSimpleSpecifyOutputFile.errors.txt new file mode 100644 index 00000000000..0d918d5b2a0 --- /dev/null +++ b/tests/baselines/reference/project/sourcerootUrlModuleSimpleSpecifyOutputFile/node/sourcerootUrlModuleSimpleSpecifyOutputFile.errors.txt @@ -0,0 +1,27 @@ +error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. + + +!!! error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +==== m1.ts (0 errors) ==== + export var m1_a1 = 10; + export class m1_c1 { + public m1_c1_p1: number; + } + + export var m1_instance1 = new m1_c1(); + export function m1_f1() { + return m1_instance1; + } +==== test.ts (0 errors) ==== + import m1 = require("m1"); + export var a1 = 10; + export class c1 { + public p1: number; + } + + export var instance1 = new c1(); + export function f1() { + return instance1; + } + + export var a2 = m1.m1_c1; \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcerootUrlModuleSubfolderSpecifyOutputFile/amd/bin/test.js b/tests/baselines/reference/project/sourcerootUrlModuleSubfolderSpecifyOutputFile/amd/bin/test.js new file mode 100644 index 00000000000..18d212c7e69 --- /dev/null +++ b/tests/baselines/reference/project/sourcerootUrlModuleSubfolderSpecifyOutputFile/amd/bin/test.js @@ -0,0 +1,30 @@ +define("ref/m1", ["require", "exports"], function (require, exports) { + exports.m1_a1 = 10; + var m1_c1 = (function () { + function m1_c1() { + } + return m1_c1; + })(); + exports.m1_c1 = m1_c1; + exports.m1_instance1 = new m1_c1(); + function m1_f1() { + return exports.m1_instance1; + } + exports.m1_f1 = m1_f1; +}); +define("test", ["require", "exports", "ref/m1"], function (require, exports, m1) { + exports.a1 = 10; + var c1 = (function () { + function c1() { + } + return c1; + })(); + exports.c1 = c1; + exports.instance1 = new c1(); + function f1() { + return exports.instance1; + } + exports.f1 = f1; + exports.a2 = m1.m1_c1; +}); +//# sourceMappingURL=test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcerootUrlModuleSubfolderSpecifyOutputFile/node/bin/test.js b/tests/baselines/reference/project/sourcerootUrlModuleSubfolderSpecifyOutputFile/node/bin/test.js new file mode 100644 index 00000000000..6f3fefb9498 --- /dev/null +++ b/tests/baselines/reference/project/sourcerootUrlModuleSubfolderSpecifyOutputFile/node/bin/test.js @@ -0,0 +1 @@ +//# sourceMappingURL=test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcerootUrlModuleSubfolderSpecifyOutputFile/node/sourcerootUrlModuleSubfolderSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/sourcerootUrlModuleSubfolderSpecifyOutputFile/node/sourcerootUrlModuleSubfolderSpecifyOutputFile.errors.txt new file mode 100644 index 00000000000..2468ab068e2 --- /dev/null +++ b/tests/baselines/reference/project/sourcerootUrlModuleSubfolderSpecifyOutputFile/node/sourcerootUrlModuleSubfolderSpecifyOutputFile.errors.txt @@ -0,0 +1,27 @@ +error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. + + +!!! error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +==== ref/m1.ts (0 errors) ==== + export var m1_a1 = 10; + export class m1_c1 { + public m1_c1_p1: number; + } + + export var m1_instance1 = new m1_c1(); + export function m1_f1() { + return m1_instance1; + } +==== test.ts (0 errors) ==== + import m1 = require("ref/m1"); + export var a1 = 10; + export class c1 { + public p1: number; + } + + export var instance1 = new c1(); + export function f1() { + return instance1; + } + + export var a2 = m1.m1_c1; \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcerootUrlMultifolderSpecifyOutputFile/node/sourcerootUrlMultifolderSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/sourcerootUrlMultifolderSpecifyOutputFile/node/sourcerootUrlMultifolderSpecifyOutputFile.errors.txt new file mode 100644 index 00000000000..8deca814d80 --- /dev/null +++ b/tests/baselines/reference/project/sourcerootUrlMultifolderSpecifyOutputFile/node/sourcerootUrlMultifolderSpecifyOutputFile.errors.txt @@ -0,0 +1,36 @@ +error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. + + +!!! error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +==== ref/m1.ts (0 errors) ==== + var m1_a1 = 10; + class m1_c1 { + public m1_c1_p1: number; + } + + var m1_instance1 = new m1_c1(); + function m1_f1() { + return m1_instance1; + } +==== ../outputdir_multifolder_ref/m2.ts (0 errors) ==== + var m2_a1 = 10; + class m2_c1 { + public m2_c1_p1: number; + } + + var m2_instance1 = new m2_c1(); + function m2_f1() { + return m2_instance1; + } +==== test.ts (0 errors) ==== + /// + /// + var a1 = 10; + class c1 { + public p1: number; + } + + var instance1 = new c1(); + function f1() { + return instance1; + } \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcerootUrlSimpleSpecifyOutputFile/node/sourcerootUrlSimpleSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/sourcerootUrlSimpleSpecifyOutputFile/node/sourcerootUrlSimpleSpecifyOutputFile.errors.txt new file mode 100644 index 00000000000..edf8d0637e2 --- /dev/null +++ b/tests/baselines/reference/project/sourcerootUrlSimpleSpecifyOutputFile/node/sourcerootUrlSimpleSpecifyOutputFile.errors.txt @@ -0,0 +1,25 @@ +error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. + + +!!! error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +==== m1.ts (0 errors) ==== + var m1_a1 = 10; + class m1_c1 { + public m1_c1_p1: number; + } + + var m1_instance1 = new m1_c1(); + function m1_f1() { + return m1_instance1; + } +==== test.ts (0 errors) ==== + /// + var a1 = 10; + class c1 { + public p1: number; + } + + var instance1 = new c1(); + function f1() { + return instance1; + } \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcerootUrlSingleFileSpecifyOutputFile/node/sourcerootUrlSingleFileSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/sourcerootUrlSingleFileSpecifyOutputFile/node/sourcerootUrlSingleFileSpecifyOutputFile.errors.txt new file mode 100644 index 00000000000..3413d4675e7 --- /dev/null +++ b/tests/baselines/reference/project/sourcerootUrlSingleFileSpecifyOutputFile/node/sourcerootUrlSingleFileSpecifyOutputFile.errors.txt @@ -0,0 +1,14 @@ +error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. + + +!!! error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +==== test.ts (0 errors) ==== + var a1 = 10; + class c1 { + public p1: number; + } + + var instance1 = new c1(); + function f1() { + return instance1; + } \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcerootUrlSubfolderSpecifyOutputFile/node/sourcerootUrlSubfolderSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/sourcerootUrlSubfolderSpecifyOutputFile/node/sourcerootUrlSubfolderSpecifyOutputFile.errors.txt new file mode 100644 index 00000000000..3a508fede30 --- /dev/null +++ b/tests/baselines/reference/project/sourcerootUrlSubfolderSpecifyOutputFile/node/sourcerootUrlSubfolderSpecifyOutputFile.errors.txt @@ -0,0 +1,25 @@ +error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. + + +!!! error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +==== ref/m1.ts (0 errors) ==== + var m1_a1 = 10; + class m1_c1 { + public m1_c1_p1: number; + } + + var m1_instance1 = new m1_c1(); + function m1_f1() { + return m1_instance1; + } +==== test.ts (0 errors) ==== + /// + var a1 = 10; + class c1 { + public p1: number; + } + + var instance1 = new c1(); + function f1() { + return instance1; + } \ No newline at end of file From 03256e7c8627e1af66f9704ecfa3a89956e42f2a Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Fri, 2 Oct 2015 17:43:58 -0700 Subject: [PATCH 040/227] cusotm tests, forbid umd --- src/compiler/diagnosticMessages.json | 2 +- src/compiler/emitter.ts | 10 +++++----- src/compiler/program.ts | 4 ++-- tests/cases/compiler/outModuleConcatAmd.ts | 12 ++++++++++++ tests/cases/compiler/outModuleConcatCommonjs.ts | 14 ++++++++++++++ tests/cases/compiler/outModuleConcatES6.ts | 14 ++++++++++++++ tests/cases/compiler/outModuleConcatSystem.ts | 12 ++++++++++++ tests/cases/compiler/outModuleConcatUmd.ts | 14 ++++++++++++++ 8 files changed, 74 insertions(+), 8 deletions(-) create mode 100644 tests/cases/compiler/outModuleConcatAmd.ts create mode 100644 tests/cases/compiler/outModuleConcatCommonjs.ts create mode 100644 tests/cases/compiler/outModuleConcatES6.ts create mode 100644 tests/cases/compiler/outModuleConcatSystem.ts create mode 100644 tests/cases/compiler/outModuleConcatUmd.ts diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 0685eb44304..a222aa6a344 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -2302,7 +2302,7 @@ "category": "Message", "code": 6081 }, - "Only 'amd', 'umd', and 'system' modules are supported alongside --{0}.": { + "Only 'amd' and 'system' modules are supported alongside --{0}.": { "category": "Error", "code": 6082 }, diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index 7e4a1714d51..4ce0a39eb07 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -457,11 +457,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi }; let bundleEmitDelegates: Map<(node: SourceFile, startIndex: number, resolvePath?: boolean) => void> = { - [ModuleKind.ES6]() { }, + [ModuleKind.ES6]() {}, [ModuleKind.AMD]: emitAMDModule, [ModuleKind.System]: emitSystemModule, - [ModuleKind.UMD]: emitUMDModule, - [ModuleKind.CommonJS]() { }, + [ModuleKind.UMD]() {}, + [ModuleKind.CommonJS]() {}, }; if (compilerOptions.sourceMap || compilerOptions.inlineSourceMap) { @@ -6827,11 +6827,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi emitExportEquals(/*emitAsReturn*/ false); } - function emitUMDModule(node: SourceFile, startIndex: number, resolvePath?: boolean) { + function emitUMDModule(node: SourceFile, startIndex: number) { emitEmitHelpers(node); collectExternalModuleInfo(node); - let dependencyNames = getAMDDependencyNames(node, /*includeNonAmdDependencies*/ false, resolvePath); + let dependencyNames = getAMDDependencyNames(node, /*includeNonAmdDependencies*/ false); // Module is detected first to support Browserify users that load into a browser with an AMD loader writeLines(`(function (factory) { diff --git a/src/compiler/program.ts b/src/compiler/program.ts index 163ddfa36c1..0cdcddbb0ed 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -1064,8 +1064,8 @@ namespace ts { } // Cannot specify module gen that isn't amd, umd, or system with --out - if (outFile && options.module && options.module !== ModuleKind.AMD && options.module !== ModuleKind.UMD && options.module !== ModuleKind.System) { - programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Only_amd_umd_and_system_modules_are_supported_alongside_0, options.out ? "out" : "outFile")); + if (outFile && options.module && options.module !== ModuleKind.AMD && options.module !== ModuleKind.System) { + programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Only_amd_and_system_modules_are_supported_alongside_0, options.out ? "out" : "outFile")); } if (options.noEmit) { diff --git a/tests/cases/compiler/outModuleConcatAmd.ts b/tests/cases/compiler/outModuleConcatAmd.ts new file mode 100644 index 00000000000..411a13e72a2 --- /dev/null +++ b/tests/cases/compiler/outModuleConcatAmd.ts @@ -0,0 +1,12 @@ +// @target: ES5 +// @sourcemap: true +// @declaration: true +// @module: amd +// @outFile: all.js + +// @Filename: ref/a.ts +export class A { } + +// @Filename: b.ts +import {A} from "./ref/a"; +export class B extends A { } \ No newline at end of file diff --git a/tests/cases/compiler/outModuleConcatCommonjs.ts b/tests/cases/compiler/outModuleConcatCommonjs.ts new file mode 100644 index 00000000000..0cb57bd11e7 --- /dev/null +++ b/tests/cases/compiler/outModuleConcatCommonjs.ts @@ -0,0 +1,14 @@ +// @target: ES5 +// @sourcemap: true +// @declaration: true +// @module: commonjs +// @outFile: all.js + +// This should be an error + +// @Filename: ref/a.ts +export class A { } + +// @Filename: b.ts +import {A} from "./ref/a"; +export class B extends A { } \ No newline at end of file diff --git a/tests/cases/compiler/outModuleConcatES6.ts b/tests/cases/compiler/outModuleConcatES6.ts new file mode 100644 index 00000000000..e98514e9adc --- /dev/null +++ b/tests/cases/compiler/outModuleConcatES6.ts @@ -0,0 +1,14 @@ +// @target: ES6 +// @sourcemap: true +// @declaration: true +// @module: es6 +// @outFile: all.js + +// This should be an error + +// @Filename: ref/a.ts +export class A { } + +// @Filename: b.ts +import {A} from "./ref/a"; +export class B extends A { } \ No newline at end of file diff --git a/tests/cases/compiler/outModuleConcatSystem.ts b/tests/cases/compiler/outModuleConcatSystem.ts new file mode 100644 index 00000000000..c8d9b4e9737 --- /dev/null +++ b/tests/cases/compiler/outModuleConcatSystem.ts @@ -0,0 +1,12 @@ +// @target: ES5 +// @sourcemap: true +// @declaration: true +// @module: system +// @outFile: all.js + +// @Filename: ref/a.ts +export class A { } + +// @Filename: b.ts +import {A} from "./ref/a"; +export class B extends A { } \ No newline at end of file diff --git a/tests/cases/compiler/outModuleConcatUmd.ts b/tests/cases/compiler/outModuleConcatUmd.ts new file mode 100644 index 00000000000..fa4a4a519c6 --- /dev/null +++ b/tests/cases/compiler/outModuleConcatUmd.ts @@ -0,0 +1,14 @@ +// @target: ES5 +// @sourcemap: true +// @declaration: true +// @module: umd +// @outFile: all.js + +// This should error + +// @Filename: ref/a.ts +export class A { } + +// @Filename: b.ts +import {A} from "./ref/a"; +export class B extends A { } \ No newline at end of file From 3c73a66ba70baa710cf0de15ca0fa8ced6e09f26 Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Fri, 2 Oct 2015 17:51:59 -0700 Subject: [PATCH 041/227] removed umd as allowed, accepted new baselines --- .../baselines/reference/out-flag2.errors.txt | 4 +- .../baselines/reference/out-flag3.errors.txt | 4 +- .../baselines/reference/outModuleConcatAmd.js | 69 ++++ .../reference/outModuleConcatAmd.js.map | 4 + .../outModuleConcatAmd.sourcemap.txt | 333 +++++++++++++++++ .../reference/outModuleConcatAmd.symbols | 13 + .../reference/outModuleConcatAmd.types | 13 + .../outModuleConcatCommonjs.errors.txt | 13 + .../reference/outModuleConcatCommonjs.js | 52 +++ .../reference/outModuleConcatCommonjs.js.map | 4 + .../outModuleConcatCommonjs.sourcemap.txt | 220 +++++++++++ .../reference/outModuleConcatES6.errors.txt | 13 + .../baselines/reference/outModuleConcatES6.js | 32 ++ .../reference/outModuleConcatES6.js.map | 4 + .../outModuleConcatES6.sourcemap.txt | 118 ++++++ .../reference/outModuleConcatSystem.js | 101 +++++ .../reference/outModuleConcatSystem.js.map | 4 + .../outModuleConcatSystem.sourcemap.txt | 353 ++++++++++++++++++ .../reference/outModuleConcatSystem.symbols | 13 + .../reference/outModuleConcatSystem.types | 13 + .../reference/outModuleConcatUmd.errors.txt | 13 + .../baselines/reference/outModuleConcatUmd.js | 70 ++++ .../reference/outModuleConcatUmd.js.map | 4 + .../outModuleConcatUmd.sourcemap.txt | 237 ++++++++++++ .../amd/bin/test.d.ts | 13 + .../node/bin/test.d.ts | 13 + ...MixedSubfolderSpecifyOutputFile.errors.txt | 4 +- .../amd/bin/outAndOutDirFile.d.ts | 13 + .../node/bin/outAndOutDirFile.d.ts | 13 + ...ifyOutputFileAndOutputDirectory.errors.txt | 4 +- .../amd/bin/test.d.ts | 0 .../node/bin/test.d.ts | 0 ...uleMultifolderSpecifyOutputFile.errors.txt | 4 +- .../amd/bin/test.d.ts | 0 .../node/bin/test.d.ts | 0 ...thModuleSimpleSpecifyOutputFile.errors.txt | 4 +- .../amd/bin/test.d.ts | 0 .../node/bin/test.d.ts | 0 ...oduleSubfolderSpecifyOutputFile.errors.txt | 4 +- ...athMultifolderSpecifyOutputFile.errors.txt | 4 +- ...lutePathSimpleSpecifyOutputFile.errors.txt | 4 +- ...PathSingleFileSpecifyOutputFile.errors.txt | 4 +- ...ePathSubfolderSpecifyOutputFile.errors.txt | 4 +- .../amd/bin/test.d.ts | 13 + .../node/bin/test.d.ts | 13 + ...MixedSubfolderSpecifyOutputFile.errors.txt | 4 +- .../amd/bin/outAndOutDirFile.d.ts | 13 + .../node/bin/outAndOutDirFile.d.ts | 13 + ...ifyOutputFileAndOutputDirectory.errors.txt | 4 +- .../amd/bin/test.d.ts | 0 .../node/bin/test.d.ts | 0 ...uleMultifolderSpecifyOutputFile.errors.txt | 4 +- .../amd/bin/test.d.ts | 0 .../node/bin/test.d.ts | 0 ...thModuleSimpleSpecifyOutputFile.errors.txt | 4 +- .../amd/bin/test.d.ts | 0 .../node/bin/test.d.ts | 0 ...oduleSubfolderSpecifyOutputFile.errors.txt | 4 +- .../amd/bin/test.d.ts | 18 + .../node/bin/test.d.ts | 18 + ...athMultifolderSpecifyOutputFile.errors.txt | 4 +- ...tivePathSimpleSpecifyOutputFile.errors.txt | 4 +- ...PathSingleFileSpecifyOutputFile.errors.txt | 4 +- ...ePathSubfolderSpecifyOutputFile.errors.txt | 4 +- .../amd/bin/test.d.ts | 13 + .../node/bin/test.d.ts | 13 + ...MixedSubfolderSpecifyOutputFile.errors.txt | 4 +- .../amd/bin/outAndOutDirFile.d.ts | 13 + .../node/bin/outAndOutDirFile.d.ts | 13 + ...ifyOutputFileAndOutputDirectory.errors.txt | 4 +- .../amd/bin/test.d.ts | 0 .../node/bin/test.d.ts | 0 ...uleMultifolderSpecifyOutputFile.errors.txt | 4 +- .../amd/bin/test.d.ts | 0 .../node/bin/test.d.ts | 0 ...rlModuleSimpleSpecifyOutputFile.errors.txt | 4 +- .../amd/bin/test.d.ts | 0 .../node/bin/test.d.ts | 0 ...oduleSubfolderSpecifyOutputFile.errors.txt | 4 +- ...UrlMultifolderSpecifyOutputFile.errors.txt | 4 +- ...prootUrlSimpleSpecifyOutputFile.errors.txt | 4 +- ...tUrlSingleFileSpecifyOutputFile.errors.txt | 4 +- ...otUrlSubfolderSpecifyOutputFile.errors.txt | 4 +- .../amd/bin/test.d.ts | 13 + .../node/bin/test.d.ts | 13 + ...MixedSubfolderSpecifyOutputFile.errors.txt | 4 +- .../amd/bin/outAndOutDirFile.d.ts | 13 + .../node/bin/outAndOutDirFile.d.ts | 13 + ...ifyOutputFileAndOutputDirectory.errors.txt | 4 +- .../amd/bin/test.d.ts | 0 .../node/bin/test.d.ts | 0 ...uleMultifolderSpecifyOutputFile.errors.txt | 4 +- .../amd/bin/test.d.ts | 0 .../node/bin/test.d.ts | 0 ...rlModuleSimpleSpecifyOutputFile.errors.txt | 4 +- .../amd/bin/test.d.ts | 0 .../node/bin/test.d.ts | 0 ...oduleSubfolderSpecifyOutputFile.errors.txt | 4 +- ...UrlMultifolderSpecifyOutputFile.errors.txt | 4 +- ...erootUrlSimpleSpecifyOutputFile.errors.txt | 4 +- ...tUrlSingleFileSpecifyOutputFile.errors.txt | 4 +- ...otUrlSubfolderSpecifyOutputFile.errors.txt | 4 +- ...MixedSubfolderSpecifyOutputFile.errors.txt | 4 +- ...ifyOutputFileAndOutputDirectory.errors.txt | 4 +- ...uleMultifolderSpecifyOutputFile.errors.txt | 4 +- ...utModuleSimpleSpecifyOutputFile.errors.txt | 4 +- ...oduleSubfolderSpecifyOutputFile.errors.txt | 4 +- ...outMultifolderSpecifyOutputFile.errors.txt | 4 +- .../outSimpleSpecifyOutputFile.errors.txt | 4 +- .../outSingleFileSpecifyOutputFile.errors.txt | 4 +- .../outSubfolderSpecifyOutputFile.errors.txt | 4 +- .../prologueEmit/node/prologueEmit.errors.txt | 4 +- .../amd/bin/test.d.ts | 13 + .../node/bin/test.d.ts | 13 + ...MixedSubfolderSpecifyOutputFile.errors.txt | 4 +- .../amd/bin/outAndOutDirFile.d.ts | 13 + .../node/bin/outAndOutDirFile.d.ts | 13 + ...ifyOutputFileAndOutputDirectory.errors.txt | 4 +- .../amd/bin/test.d.ts | 0 .../node/bin/test.d.ts | 0 ...uleMultifolderSpecifyOutputFile.errors.txt | 4 +- .../amd/bin/test.d.ts | 0 .../node/bin/test.d.ts | 0 ...thModuleSimpleSpecifyOutputFile.errors.txt | 4 +- .../amd/bin/test.d.ts | 0 .../node/bin/test.d.ts | 0 ...oduleSubfolderSpecifyOutputFile.errors.txt | 4 +- ...athMultifolderSpecifyOutputFile.errors.txt | 4 +- ...lutePathSimpleSpecifyOutputFile.errors.txt | 4 +- ...PathSingleFileSpecifyOutputFile.errors.txt | 4 +- ...ePathSubfolderSpecifyOutputFile.errors.txt | 4 +- .../amd/bin/test.d.ts | 13 + .../node/bin/test.d.ts | 13 + ...MixedSubfolderSpecifyOutputFile.errors.txt | 4 +- .../amd/bin/outAndOutDirFile.d.ts | 13 + .../node/bin/outAndOutDirFile.d.ts | 13 + ...ifyOutputFileAndOutputDirectory.errors.txt | 4 +- .../amd/bin/test.d.ts | 0 .../node/bin/test.d.ts | 0 ...uleMultifolderSpecifyOutputFile.errors.txt | 4 +- .../amd/bin/test.d.ts | 0 .../node/bin/test.d.ts | 0 ...thModuleSimpleSpecifyOutputFile.errors.txt | 4 +- .../amd/bin/test.d.ts | 0 .../node/bin/test.d.ts | 0 ...oduleSubfolderSpecifyOutputFile.errors.txt | 4 +- ...athMultifolderSpecifyOutputFile.errors.txt | 4 +- ...tivePathSimpleSpecifyOutputFile.errors.txt | 4 +- ...PathSingleFileSpecifyOutputFile.errors.txt | 4 +- ...ePathSubfolderSpecifyOutputFile.errors.txt | 4 +- .../amd/bin/test.d.ts | 13 + .../node/bin/test.d.ts | 13 + ...MixedSubfolderSpecifyOutputFile.errors.txt | 4 +- .../amd/bin/outAndOutDirFile.d.ts | 13 + .../node/bin/outAndOutDirFile.d.ts | 13 + ...ifyOutputFileAndOutputDirectory.errors.txt | 4 +- .../amd/bin/test.d.ts | 0 .../node/bin/test.d.ts | 0 ...uleMultifolderSpecifyOutputFile.errors.txt | 4 +- .../amd/bin/test.d.ts | 0 .../node/bin/test.d.ts | 0 ...apModuleSimpleSpecifyOutputFile.errors.txt | 4 +- .../amd/bin/test.d.ts | 0 .../node/bin/test.d.ts | 0 ...oduleSubfolderSpecifyOutputFile.errors.txt | 4 +- ...mapMultifolderSpecifyOutputFile.errors.txt | 4 +- ...ourcemapSimpleSpecifyOutputFile.errors.txt | 4 +- ...emapSingleFileSpecifyOutputFile.errors.txt | 4 +- ...cemapSubfolderSpecifyOutputFile.errors.txt | 4 +- .../amd/bin/test.d.ts | 13 + .../node/bin/test.d.ts | 13 + ...MixedSubfolderSpecifyOutputFile.errors.txt | 4 +- .../amd/bin/outAndOutDirFile.d.ts | 13 + .../node/bin/outAndOutDirFile.d.ts | 13 + ...ifyOutputFileAndOutputDirectory.errors.txt | 4 +- .../amd/bin/test.d.ts | 0 .../node/bin/test.d.ts | 0 ...uleMultifolderSpecifyOutputFile.errors.txt | 4 +- .../amd/bin/test.d.ts | 0 .../node/bin/test.d.ts | 0 ...rlModuleSimpleSpecifyOutputFile.errors.txt | 4 +- .../amd/bin/test.d.ts | 0 .../node/bin/test.d.ts | 0 ...oduleSubfolderSpecifyOutputFile.errors.txt | 4 +- ...UrlMultifolderSpecifyOutputFile.errors.txt | 4 +- ...erootUrlSimpleSpecifyOutputFile.errors.txt | 4 +- ...tUrlSingleFileSpecifyOutputFile.errors.txt | 4 +- ...otUrlSubfolderSpecifyOutputFile.errors.txt | 4 +- 188 files changed, 2316 insertions(+), 168 deletions(-) create mode 100644 tests/baselines/reference/outModuleConcatAmd.js create mode 100644 tests/baselines/reference/outModuleConcatAmd.js.map create mode 100644 tests/baselines/reference/outModuleConcatAmd.sourcemap.txt create mode 100644 tests/baselines/reference/outModuleConcatAmd.symbols create mode 100644 tests/baselines/reference/outModuleConcatAmd.types create mode 100644 tests/baselines/reference/outModuleConcatCommonjs.errors.txt create mode 100644 tests/baselines/reference/outModuleConcatCommonjs.js create mode 100644 tests/baselines/reference/outModuleConcatCommonjs.js.map create mode 100644 tests/baselines/reference/outModuleConcatCommonjs.sourcemap.txt create mode 100644 tests/baselines/reference/outModuleConcatES6.errors.txt create mode 100644 tests/baselines/reference/outModuleConcatES6.js create mode 100644 tests/baselines/reference/outModuleConcatES6.js.map create mode 100644 tests/baselines/reference/outModuleConcatES6.sourcemap.txt create mode 100644 tests/baselines/reference/outModuleConcatSystem.js create mode 100644 tests/baselines/reference/outModuleConcatSystem.js.map create mode 100644 tests/baselines/reference/outModuleConcatSystem.sourcemap.txt create mode 100644 tests/baselines/reference/outModuleConcatSystem.symbols create mode 100644 tests/baselines/reference/outModuleConcatSystem.types create mode 100644 tests/baselines/reference/outModuleConcatUmd.errors.txt create mode 100644 tests/baselines/reference/outModuleConcatUmd.js create mode 100644 tests/baselines/reference/outModuleConcatUmd.js.map create mode 100644 tests/baselines/reference/outModuleConcatUmd.sourcemap.txt create mode 100644 tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFile/amd/bin/test.d.ts create mode 100644 tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFile/node/bin/test.d.ts create mode 100644 tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.d.ts create mode 100644 tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.d.ts create mode 100644 tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderSpecifyOutputFile/amd/bin/test.d.ts create mode 100644 tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderSpecifyOutputFile/node/bin/test.d.ts create mode 100644 tests/baselines/reference/project/mapRootAbsolutePathModuleSimpleSpecifyOutputFile/amd/bin/test.d.ts create mode 100644 tests/baselines/reference/project/mapRootAbsolutePathModuleSimpleSpecifyOutputFile/node/bin/test.d.ts create mode 100644 tests/baselines/reference/project/mapRootAbsolutePathModuleSubfolderSpecifyOutputFile/amd/bin/test.d.ts create mode 100644 tests/baselines/reference/project/mapRootAbsolutePathModuleSubfolderSpecifyOutputFile/node/bin/test.d.ts create mode 100644 tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFile/amd/bin/test.d.ts create mode 100644 tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFile/node/bin/test.d.ts create mode 100644 tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.d.ts create mode 100644 tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.d.ts create mode 100644 tests/baselines/reference/project/mapRootRelativePathModuleMultifolderSpecifyOutputFile/amd/bin/test.d.ts create mode 100644 tests/baselines/reference/project/mapRootRelativePathModuleMultifolderSpecifyOutputFile/node/bin/test.d.ts create mode 100644 tests/baselines/reference/project/mapRootRelativePathModuleSimpleSpecifyOutputFile/amd/bin/test.d.ts create mode 100644 tests/baselines/reference/project/mapRootRelativePathModuleSimpleSpecifyOutputFile/node/bin/test.d.ts create mode 100644 tests/baselines/reference/project/mapRootRelativePathModuleSubfolderSpecifyOutputFile/amd/bin/test.d.ts create mode 100644 tests/baselines/reference/project/mapRootRelativePathModuleSubfolderSpecifyOutputFile/node/bin/test.d.ts create mode 100644 tests/baselines/reference/project/mapRootRelativePathMultifolderSpecifyOutputFile/amd/bin/test.d.ts create mode 100644 tests/baselines/reference/project/mapRootRelativePathMultifolderSpecifyOutputFile/node/bin/test.d.ts create mode 100644 tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFile/amd/bin/test.d.ts create mode 100644 tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFile/node/bin/test.d.ts create mode 100644 tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.d.ts create mode 100644 tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.d.ts create mode 100644 tests/baselines/reference/project/maprootUrlModuleMultifolderSpecifyOutputFile/amd/bin/test.d.ts create mode 100644 tests/baselines/reference/project/maprootUrlModuleMultifolderSpecifyOutputFile/node/bin/test.d.ts create mode 100644 tests/baselines/reference/project/maprootUrlModuleSimpleSpecifyOutputFile/amd/bin/test.d.ts create mode 100644 tests/baselines/reference/project/maprootUrlModuleSimpleSpecifyOutputFile/node/bin/test.d.ts create mode 100644 tests/baselines/reference/project/maprootUrlModuleSubfolderSpecifyOutputFile/amd/bin/test.d.ts create mode 100644 tests/baselines/reference/project/maprootUrlModuleSubfolderSpecifyOutputFile/node/bin/test.d.ts create mode 100644 tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFile/amd/bin/test.d.ts create mode 100644 tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFile/node/bin/test.d.ts create mode 100644 tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.d.ts create mode 100644 tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.d.ts create mode 100644 tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputFile/amd/bin/test.d.ts create mode 100644 tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputFile/node/bin/test.d.ts create mode 100644 tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSimpleSpecifyOutputFile/amd/bin/test.d.ts create mode 100644 tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSimpleSpecifyOutputFile/node/bin/test.d.ts create mode 100644 tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSubfolderSpecifyOutputFile/amd/bin/test.d.ts create mode 100644 tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSubfolderSpecifyOutputFile/node/bin/test.d.ts create mode 100644 tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFile/amd/bin/test.d.ts create mode 100644 tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFile/node/bin/test.d.ts create mode 100644 tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.d.ts create mode 100644 tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.d.ts create mode 100644 tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderSpecifyOutputFile/amd/bin/test.d.ts create mode 100644 tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderSpecifyOutputFile/node/bin/test.d.ts create mode 100644 tests/baselines/reference/project/sourceRootAbsolutePathModuleSimpleSpecifyOutputFile/amd/bin/test.d.ts create mode 100644 tests/baselines/reference/project/sourceRootAbsolutePathModuleSimpleSpecifyOutputFile/node/bin/test.d.ts create mode 100644 tests/baselines/reference/project/sourceRootAbsolutePathModuleSubfolderSpecifyOutputFile/amd/bin/test.d.ts create mode 100644 tests/baselines/reference/project/sourceRootAbsolutePathModuleSubfolderSpecifyOutputFile/node/bin/test.d.ts create mode 100644 tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFile/amd/bin/test.d.ts create mode 100644 tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFile/node/bin/test.d.ts create mode 100644 tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.d.ts create mode 100644 tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.d.ts create mode 100644 tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderSpecifyOutputFile/amd/bin/test.d.ts create mode 100644 tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderSpecifyOutputFile/node/bin/test.d.ts create mode 100644 tests/baselines/reference/project/sourceRootRelativePathModuleSimpleSpecifyOutputFile/amd/bin/test.d.ts create mode 100644 tests/baselines/reference/project/sourceRootRelativePathModuleSimpleSpecifyOutputFile/node/bin/test.d.ts create mode 100644 tests/baselines/reference/project/sourceRootRelativePathModuleSubfolderSpecifyOutputFile/amd/bin/test.d.ts create mode 100644 tests/baselines/reference/project/sourceRootRelativePathModuleSubfolderSpecifyOutputFile/node/bin/test.d.ts create mode 100644 tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFile/amd/bin/test.d.ts create mode 100644 tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFile/node/bin/test.d.ts create mode 100644 tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.d.ts create mode 100644 tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.d.ts create mode 100644 tests/baselines/reference/project/sourcemapModuleMultifolderSpecifyOutputFile/amd/bin/test.d.ts create mode 100644 tests/baselines/reference/project/sourcemapModuleMultifolderSpecifyOutputFile/node/bin/test.d.ts create mode 100644 tests/baselines/reference/project/sourcemapModuleSimpleSpecifyOutputFile/amd/bin/test.d.ts create mode 100644 tests/baselines/reference/project/sourcemapModuleSimpleSpecifyOutputFile/node/bin/test.d.ts create mode 100644 tests/baselines/reference/project/sourcemapModuleSubfolderSpecifyOutputFile/amd/bin/test.d.ts create mode 100644 tests/baselines/reference/project/sourcemapModuleSubfolderSpecifyOutputFile/node/bin/test.d.ts create mode 100644 tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFile/amd/bin/test.d.ts create mode 100644 tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFile/node/bin/test.d.ts create mode 100644 tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.d.ts create mode 100644 tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.d.ts create mode 100644 tests/baselines/reference/project/sourcerootUrlModuleMultifolderSpecifyOutputFile/amd/bin/test.d.ts create mode 100644 tests/baselines/reference/project/sourcerootUrlModuleMultifolderSpecifyOutputFile/node/bin/test.d.ts create mode 100644 tests/baselines/reference/project/sourcerootUrlModuleSimpleSpecifyOutputFile/amd/bin/test.d.ts create mode 100644 tests/baselines/reference/project/sourcerootUrlModuleSimpleSpecifyOutputFile/node/bin/test.d.ts create mode 100644 tests/baselines/reference/project/sourcerootUrlModuleSubfolderSpecifyOutputFile/amd/bin/test.d.ts create mode 100644 tests/baselines/reference/project/sourcerootUrlModuleSubfolderSpecifyOutputFile/node/bin/test.d.ts diff --git a/tests/baselines/reference/out-flag2.errors.txt b/tests/baselines/reference/out-flag2.errors.txt index 755019b52b0..ea6fed45bd0 100644 --- a/tests/baselines/reference/out-flag2.errors.txt +++ b/tests/baselines/reference/out-flag2.errors.txt @@ -1,7 +1,7 @@ -error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. -!!! error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +!!! error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. ==== tests/cases/compiler/a.ts (0 errors) ==== class A { } diff --git a/tests/baselines/reference/out-flag3.errors.txt b/tests/baselines/reference/out-flag3.errors.txt index ab44f4e94fd..c01cef151f3 100644 --- a/tests/baselines/reference/out-flag3.errors.txt +++ b/tests/baselines/reference/out-flag3.errors.txt @@ -1,9 +1,9 @@ error TS5053: Option 'out' cannot be specified with option 'outFile'. -error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --out. +error TS6082: Only 'amd' and 'system' modules are supported alongside --out. !!! error TS5053: Option 'out' cannot be specified with option 'outFile'. -!!! error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --out. +!!! error TS6082: Only 'amd' and 'system' modules are supported alongside --out. ==== tests/cases/compiler/a.ts (0 errors) ==== // --out and --outFile error diff --git a/tests/baselines/reference/outModuleConcatAmd.js b/tests/baselines/reference/outModuleConcatAmd.js new file mode 100644 index 00000000000..f6af61005e9 --- /dev/null +++ b/tests/baselines/reference/outModuleConcatAmd.js @@ -0,0 +1,69 @@ +//// [tests/cases/compiler/outModuleConcatAmd.ts] //// + +//// [a.ts] + +export class A { } + +//// [b.ts] +import {A} from "./ref/a"; +export class B extends A { } + +//// [a.js] +define(["require", "exports"], function (require, exports) { + var A = (function () { + function A() { + } + return A; + })(); + exports.A = A; +}); +//# sourceMappingURL=a.js.map//// [b.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 __()); +}; +define(["require", "exports", "./ref/a"], function (require, exports, a_1) { + var B = (function (_super) { + __extends(B, _super); + function B() { + _super.apply(this, arguments); + } + return B; + })(a_1.A); + exports.B = B; +}); +//# sourceMappingURL=b.js.map//// [all.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 __()); +}; +define("tests/cases/compiler/ref/a", ["require", "exports"], function (require, exports) { + var A = (function () { + function A() { + } + return A; + })(); + exports.A = A; +}); +define("tests/cases/compiler/b", ["require", "exports", "tests/cases/compiler/ref/a"], function (require, exports, a_1) { + var B = (function (_super) { + __extends(B, _super); + function B() { + _super.apply(this, arguments); + } + return B; + })(a_1.A); + exports.B = B; +}); +//# sourceMappingURL=all.js.map + +//// [a.d.ts] +export declare class A { +} +//// [b.d.ts] +import { A } from "./ref/a"; +export declare class B extends A { +} +//// [all.d.ts] diff --git a/tests/baselines/reference/outModuleConcatAmd.js.map b/tests/baselines/reference/outModuleConcatAmd.js.map new file mode 100644 index 00000000000..88e6fa81885 --- /dev/null +++ b/tests/baselines/reference/outModuleConcatAmd.js.map @@ -0,0 +1,4 @@ +//// [a.js.map] +{"version":3,"file":"a.js","sourceRoot":"","sources":["a.ts"],"names":["A","A.constructor"],"mappings":";IACA;QAAAA;QAAiBC,CAACA;QAADD,QAACA;IAADA,CAACA,AAAlB,IAAkB;IAAL,SAAC,IAAI,CAAA"}//// [b.js.map] +{"version":3,"file":"b.js","sourceRoot":"","sources":["b.ts"],"names":["B","B.constructor"],"mappings":";;;;;;IACA;QAAuBA,qBAACA;QAAxBA;YAAuBC,8BAACA;QAAGA,CAACA;QAADD,QAACA;IAADA,CAACA,AAA5B,EAAuB,KAAC,EAAI;IAAf,SAAC,IAAc,CAAA"}//// [all.js.map] +{"version":3,"file":"all.js","sourceRoot":"","sources":["tests/cases/compiler/ref/a.ts","tests/cases/compiler/b.ts"],"names":["A","A.constructor","B","B.constructor"],"mappings":";;;;;;IACA;QAAAA;QAAiBC,CAACA;QAADD,QAACA;IAADA,CAACA,AAAlB,IAAkB;IAAL,SAAC,IAAI,CAAA;;;ICAlB;QAAuBE,qBAACA;QAAxBA;YAAuBC,8BAACA;QAAGA,CAACA;QAADD,QAACA;IAADA,CAACA,AAA5B,EAAuB,KAAC,EAAI;IAAf,SAAC,IAAc,CAAA"} \ No newline at end of file diff --git a/tests/baselines/reference/outModuleConcatAmd.sourcemap.txt b/tests/baselines/reference/outModuleConcatAmd.sourcemap.txt new file mode 100644 index 00000000000..4ec8e34e8e1 --- /dev/null +++ b/tests/baselines/reference/outModuleConcatAmd.sourcemap.txt @@ -0,0 +1,333 @@ +=================================================================== +JsFile: a.js +mapUrl: a.js.map +sourceRoot: +sources: a.ts +=================================================================== +------------------------------------------------------------------- +emittedFile:tests/cases/compiler/ref/a.js +sourceFile:a.ts +------------------------------------------------------------------- +>>>define(["require", "exports"], function (require, exports) { +>>> var A = (function () { +1 >^^^^ +2 > ^^^^^^^^^^^^^^^^^^^-> +1 > + > +1 >Emitted(2, 5) Source(2, 1) + SourceIndex(0) +--- +>>> function A() { +1->^^^^^^^^ +2 > ^^-> +1-> +1->Emitted(3, 9) Source(2, 1) + SourceIndex(0) name (A) +--- +>>> } +1->^^^^^^^^ +2 > ^ +3 > ^^^^^^^^^-> +1->export class A { +2 > } +1->Emitted(4, 9) Source(2, 18) + SourceIndex(0) name (A.constructor) +2 >Emitted(4, 10) Source(2, 19) + SourceIndex(0) name (A.constructor) +--- +>>> return A; +1->^^^^^^^^ +2 > ^^^^^^^^ +1-> +2 > } +1->Emitted(5, 9) Source(2, 18) + SourceIndex(0) name (A) +2 >Emitted(5, 17) Source(2, 19) + SourceIndex(0) name (A) +--- +>>> })(); +1 >^^^^ +2 > ^ +3 > +4 > ^^^^ +5 > ^^^^^^^^^^-> +1 > +2 > } +3 > +4 > export class A { } +1 >Emitted(6, 5) Source(2, 18) + SourceIndex(0) name (A) +2 >Emitted(6, 6) Source(2, 19) + SourceIndex(0) name (A) +3 >Emitted(6, 6) Source(2, 1) + SourceIndex(0) +4 >Emitted(6, 10) Source(2, 19) + SourceIndex(0) +--- +>>> exports.A = A; +1->^^^^ +2 > ^^^^^^^^^ +3 > ^^^^ +4 > ^ +1-> +2 > A +3 > { } +4 > +1->Emitted(7, 5) Source(2, 14) + SourceIndex(0) +2 >Emitted(7, 14) Source(2, 15) + SourceIndex(0) +3 >Emitted(7, 18) Source(2, 19) + SourceIndex(0) +4 >Emitted(7, 19) Source(2, 19) + SourceIndex(0) +--- +>>>}); +>>>//# sourceMappingURL=a.js.map=================================================================== +JsFile: b.js +mapUrl: b.js.map +sourceRoot: +sources: b.ts +=================================================================== +------------------------------------------------------------------- +emittedFile:tests/cases/compiler/b.js +sourceFile:b.ts +------------------------------------------------------------------- +>>>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 __()); +>>>}; +>>>define(["require", "exports", "./ref/a"], function (require, exports, a_1) { +>>> var B = (function (_super) { +1 >^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^-> +1 >import {A} from "./ref/a"; + > +1 >Emitted(7, 5) Source(2, 1) + SourceIndex(0) +--- +>>> __extends(B, _super); +1->^^^^^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^^ +1->export class B extends +2 > A +1->Emitted(8, 9) Source(2, 24) + SourceIndex(0) name (B) +2 >Emitted(8, 30) Source(2, 25) + SourceIndex(0) name (B) +--- +>>> function B() { +1 >^^^^^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +1 > +1 >Emitted(9, 9) Source(2, 1) + SourceIndex(0) name (B) +--- +>>> _super.apply(this, arguments); +1->^^^^^^^^^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +1->export class B extends +2 > A +1->Emitted(10, 13) Source(2, 24) + SourceIndex(0) name (B.constructor) +2 >Emitted(10, 43) Source(2, 25) + SourceIndex(0) name (B.constructor) +--- +>>> } +1 >^^^^^^^^ +2 > ^ +3 > ^^^^^^^^^-> +1 > { +2 > } +1 >Emitted(11, 9) Source(2, 28) + SourceIndex(0) name (B.constructor) +2 >Emitted(11, 10) Source(2, 29) + SourceIndex(0) name (B.constructor) +--- +>>> return B; +1->^^^^^^^^ +2 > ^^^^^^^^ +1-> +2 > } +1->Emitted(12, 9) Source(2, 28) + SourceIndex(0) name (B) +2 >Emitted(12, 17) Source(2, 29) + SourceIndex(0) name (B) +--- +>>> })(a_1.A); +1 >^^^^ +2 > ^ +3 > +4 > ^^ +5 > ^^^^^ +6 > ^^ +7 > ^^^^^-> +1 > +2 > } +3 > +4 > export class B extends +5 > A +6 > { } +1 >Emitted(13, 5) Source(2, 28) + SourceIndex(0) name (B) +2 >Emitted(13, 6) Source(2, 29) + SourceIndex(0) name (B) +3 >Emitted(13, 6) Source(2, 1) + SourceIndex(0) +4 >Emitted(13, 8) Source(2, 24) + SourceIndex(0) +5 >Emitted(13, 13) Source(2, 25) + SourceIndex(0) +6 >Emitted(13, 15) Source(2, 29) + SourceIndex(0) +--- +>>> exports.B = B; +1->^^^^ +2 > ^^^^^^^^^ +3 > ^^^^ +4 > ^ +1-> +2 > B +3 > extends A { } +4 > +1->Emitted(14, 5) Source(2, 14) + SourceIndex(0) +2 >Emitted(14, 14) Source(2, 15) + SourceIndex(0) +3 >Emitted(14, 18) Source(2, 29) + SourceIndex(0) +4 >Emitted(14, 19) Source(2, 29) + SourceIndex(0) +--- +>>>}); +>>>//# sourceMappingURL=b.js.map=================================================================== +JsFile: all.js +mapUrl: all.js.map +sourceRoot: +sources: tests/cases/compiler/ref/a.ts,tests/cases/compiler/b.ts +=================================================================== +------------------------------------------------------------------- +emittedFile:all.js +sourceFile:tests/cases/compiler/ref/a.ts +------------------------------------------------------------------- +>>>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 __()); +>>>}; +>>>define("tests/cases/compiler/ref/a", ["require", "exports"], function (require, exports) { +>>> var A = (function () { +1 >^^^^ +2 > ^^^^^^^^^^^^^^^^^^^-> +1 > + > +1 >Emitted(7, 5) Source(2, 1) + SourceIndex(0) +--- +>>> function A() { +1->^^^^^^^^ +2 > ^^-> +1-> +1->Emitted(8, 9) Source(2, 1) + SourceIndex(0) name (A) +--- +>>> } +1->^^^^^^^^ +2 > ^ +3 > ^^^^^^^^^-> +1->export class A { +2 > } +1->Emitted(9, 9) Source(2, 18) + SourceIndex(0) name (A.constructor) +2 >Emitted(9, 10) Source(2, 19) + SourceIndex(0) name (A.constructor) +--- +>>> return A; +1->^^^^^^^^ +2 > ^^^^^^^^ +1-> +2 > } +1->Emitted(10, 9) Source(2, 18) + SourceIndex(0) name (A) +2 >Emitted(10, 17) Source(2, 19) + SourceIndex(0) name (A) +--- +>>> })(); +1 >^^^^ +2 > ^ +3 > +4 > ^^^^ +5 > ^^^^^^^^^^-> +1 > +2 > } +3 > +4 > export class A { } +1 >Emitted(11, 5) Source(2, 18) + SourceIndex(0) name (A) +2 >Emitted(11, 6) Source(2, 19) + SourceIndex(0) name (A) +3 >Emitted(11, 6) Source(2, 1) + SourceIndex(0) +4 >Emitted(11, 10) Source(2, 19) + SourceIndex(0) +--- +>>> exports.A = A; +1->^^^^ +2 > ^^^^^^^^^ +3 > ^^^^ +4 > ^ +1-> +2 > A +3 > { } +4 > +1->Emitted(12, 5) Source(2, 14) + SourceIndex(0) +2 >Emitted(12, 14) Source(2, 15) + SourceIndex(0) +3 >Emitted(12, 18) Source(2, 19) + SourceIndex(0) +4 >Emitted(12, 19) Source(2, 19) + SourceIndex(0) +--- +------------------------------------------------------------------- +emittedFile:all.js +sourceFile:tests/cases/compiler/b.ts +------------------------------------------------------------------- +>>>}); +>>>define("tests/cases/compiler/b", ["require", "exports", "tests/cases/compiler/ref/a"], function (require, exports, a_1) { +>>> var B = (function (_super) { +1 >^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^-> +1 >import {A} from "./ref/a"; + > +1 >Emitted(15, 5) Source(2, 1) + SourceIndex(1) +--- +>>> __extends(B, _super); +1->^^^^^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^^ +1->export class B extends +2 > A +1->Emitted(16, 9) Source(2, 24) + SourceIndex(1) name (B) +2 >Emitted(16, 30) Source(2, 25) + SourceIndex(1) name (B) +--- +>>> function B() { +1 >^^^^^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +1 > +1 >Emitted(17, 9) Source(2, 1) + SourceIndex(1) name (B) +--- +>>> _super.apply(this, arguments); +1->^^^^^^^^^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +1->export class B extends +2 > A +1->Emitted(18, 13) Source(2, 24) + SourceIndex(1) name (B.constructor) +2 >Emitted(18, 43) Source(2, 25) + SourceIndex(1) name (B.constructor) +--- +>>> } +1 >^^^^^^^^ +2 > ^ +3 > ^^^^^^^^^-> +1 > { +2 > } +1 >Emitted(19, 9) Source(2, 28) + SourceIndex(1) name (B.constructor) +2 >Emitted(19, 10) Source(2, 29) + SourceIndex(1) name (B.constructor) +--- +>>> return B; +1->^^^^^^^^ +2 > ^^^^^^^^ +1-> +2 > } +1->Emitted(20, 9) Source(2, 28) + SourceIndex(1) name (B) +2 >Emitted(20, 17) Source(2, 29) + SourceIndex(1) name (B) +--- +>>> })(a_1.A); +1 >^^^^ +2 > ^ +3 > +4 > ^^ +5 > ^^^^^ +6 > ^^ +7 > ^^^^^-> +1 > +2 > } +3 > +4 > export class B extends +5 > A +6 > { } +1 >Emitted(21, 5) Source(2, 28) + SourceIndex(1) name (B) +2 >Emitted(21, 6) Source(2, 29) + SourceIndex(1) name (B) +3 >Emitted(21, 6) Source(2, 1) + SourceIndex(1) +4 >Emitted(21, 8) Source(2, 24) + SourceIndex(1) +5 >Emitted(21, 13) Source(2, 25) + SourceIndex(1) +6 >Emitted(21, 15) Source(2, 29) + SourceIndex(1) +--- +>>> exports.B = B; +1->^^^^ +2 > ^^^^^^^^^ +3 > ^^^^ +4 > ^ +1-> +2 > B +3 > extends A { } +4 > +1->Emitted(22, 5) Source(2, 14) + SourceIndex(1) +2 >Emitted(22, 14) Source(2, 15) + SourceIndex(1) +3 >Emitted(22, 18) Source(2, 29) + SourceIndex(1) +4 >Emitted(22, 19) Source(2, 29) + SourceIndex(1) +--- +>>>}); +>>>//# sourceMappingURL=all.js.map \ No newline at end of file diff --git a/tests/baselines/reference/outModuleConcatAmd.symbols b/tests/baselines/reference/outModuleConcatAmd.symbols new file mode 100644 index 00000000000..349de40815a --- /dev/null +++ b/tests/baselines/reference/outModuleConcatAmd.symbols @@ -0,0 +1,13 @@ +=== tests/cases/compiler/ref/a.ts === + +export class A { } +>A : Symbol(A, Decl(a.ts, 0, 0)) + +=== tests/cases/compiler/b.ts === +import {A} from "./ref/a"; +>A : Symbol(A, Decl(b.ts, 0, 8)) + +export class B extends A { } +>B : Symbol(B, Decl(b.ts, 0, 26)) +>A : Symbol(A, Decl(b.ts, 0, 8)) + diff --git a/tests/baselines/reference/outModuleConcatAmd.types b/tests/baselines/reference/outModuleConcatAmd.types new file mode 100644 index 00000000000..6e0d9398853 --- /dev/null +++ b/tests/baselines/reference/outModuleConcatAmd.types @@ -0,0 +1,13 @@ +=== tests/cases/compiler/ref/a.ts === + +export class A { } +>A : A + +=== tests/cases/compiler/b.ts === +import {A} from "./ref/a"; +>A : typeof A + +export class B extends A { } +>B : B +>A : A + diff --git a/tests/baselines/reference/outModuleConcatCommonjs.errors.txt b/tests/baselines/reference/outModuleConcatCommonjs.errors.txt new file mode 100644 index 00000000000..d1a2adbc93f --- /dev/null +++ b/tests/baselines/reference/outModuleConcatCommonjs.errors.txt @@ -0,0 +1,13 @@ +error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. + + +!!! error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. +==== tests/cases/compiler/ref/a.ts (0 errors) ==== + + // This should be an error + + export class A { } + +==== tests/cases/compiler/b.ts (0 errors) ==== + import {A} from "./ref/a"; + export class B extends A { } \ No newline at end of file diff --git a/tests/baselines/reference/outModuleConcatCommonjs.js b/tests/baselines/reference/outModuleConcatCommonjs.js new file mode 100644 index 00000000000..ed19f93f702 --- /dev/null +++ b/tests/baselines/reference/outModuleConcatCommonjs.js @@ -0,0 +1,52 @@ +//// [tests/cases/compiler/outModuleConcatCommonjs.ts] //// + +//// [a.ts] + +// This should be an error + +export class A { } + +//// [b.ts] +import {A} from "./ref/a"; +export class B extends A { } + +//// [a.js] +// This should be an error +var A = (function () { + function A() { + } + return A; +})(); +exports.A = A; +//# sourceMappingURL=a.js.map//// [b.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 a_1 = require("./ref/a"); +var B = (function (_super) { + __extends(B, _super); + function B() { + _super.apply(this, arguments); + } + return B; +})(a_1.A); +exports.B = B; +//# sourceMappingURL=b.js.map//// [all.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 __()); +}; +// This should be an error +//# sourceMappingURL=all.js.map + +//// [a.d.ts] +export declare class A { +} +//// [b.d.ts] +import { A } from "./ref/a"; +export declare class B extends A { +} +//// [all.d.ts] diff --git a/tests/baselines/reference/outModuleConcatCommonjs.js.map b/tests/baselines/reference/outModuleConcatCommonjs.js.map new file mode 100644 index 00000000000..babde662bc1 --- /dev/null +++ b/tests/baselines/reference/outModuleConcatCommonjs.js.map @@ -0,0 +1,4 @@ +//// [a.js.map] +{"version":3,"file":"a.js","sourceRoot":"","sources":["a.ts"],"names":["A","A.constructor"],"mappings":"AACA,0BAA0B;AAE1B;IAAAA;IAAiBC,CAACA;IAADD,QAACA;AAADA,CAACA,AAAlB,IAAkB;AAAL,SAAC,IAAI,CAAA"}//// [b.js.map] +{"version":3,"file":"b.js","sourceRoot":"","sources":["b.ts"],"names":["B","B.constructor"],"mappings":";;;;;AAAA,kBAAgB,SAAS,CAAC,CAAA;AAC1B;IAAuBA,qBAACA;IAAxBA;QAAuBC,8BAACA;IAAGA,CAACA;IAADD,QAACA;AAADA,CAACA,AAA5B,EAAuB,KAAC,EAAI;AAAf,SAAC,IAAc,CAAA"}//// [all.js.map] +{"version":3,"file":"all.js","sourceRoot":"","sources":["tests/cases/compiler/ref/a.ts","tests/cases/compiler/b.ts"],"names":[],"mappings":";;;;;AACA,0BAA0B"} \ No newline at end of file diff --git a/tests/baselines/reference/outModuleConcatCommonjs.sourcemap.txt b/tests/baselines/reference/outModuleConcatCommonjs.sourcemap.txt new file mode 100644 index 00000000000..22dda7ae4bf --- /dev/null +++ b/tests/baselines/reference/outModuleConcatCommonjs.sourcemap.txt @@ -0,0 +1,220 @@ +=================================================================== +JsFile: a.js +mapUrl: a.js.map +sourceRoot: +sources: a.ts +=================================================================== +------------------------------------------------------------------- +emittedFile:tests/cases/compiler/ref/a.js +sourceFile:a.ts +------------------------------------------------------------------- +>>>// This should be an error +1 > +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^ +1 > + > +2 >// This should be an error +1 >Emitted(1, 1) Source(2, 1) + SourceIndex(0) +2 >Emitted(1, 27) Source(2, 27) + SourceIndex(0) +--- +>>>var A = (function () { +1 > +2 >^^^^^^^^^^^^^^^^^^^-> +1 > + > + > +1 >Emitted(2, 1) Source(4, 1) + SourceIndex(0) +--- +>>> function A() { +1->^^^^ +2 > ^^-> +1-> +1->Emitted(3, 5) Source(4, 1) + SourceIndex(0) name (A) +--- +>>> } +1->^^^^ +2 > ^ +3 > ^^^^^^^^^-> +1->export class A { +2 > } +1->Emitted(4, 5) Source(4, 18) + SourceIndex(0) name (A.constructor) +2 >Emitted(4, 6) Source(4, 19) + SourceIndex(0) name (A.constructor) +--- +>>> return A; +1->^^^^ +2 > ^^^^^^^^ +1-> +2 > } +1->Emitted(5, 5) Source(4, 18) + SourceIndex(0) name (A) +2 >Emitted(5, 13) Source(4, 19) + SourceIndex(0) name (A) +--- +>>>})(); +1 > +2 >^ +3 > +4 > ^^^^ +5 > ^^^^^^^^^^-> +1 > +2 >} +3 > +4 > export class A { } +1 >Emitted(6, 1) Source(4, 18) + SourceIndex(0) name (A) +2 >Emitted(6, 2) Source(4, 19) + SourceIndex(0) name (A) +3 >Emitted(6, 2) Source(4, 1) + SourceIndex(0) +4 >Emitted(6, 6) Source(4, 19) + SourceIndex(0) +--- +>>>exports.A = A; +1-> +2 >^^^^^^^^^ +3 > ^^^^ +4 > ^ +5 > ^^^^^^^^^^^^^^-> +1-> +2 >A +3 > { } +4 > +1->Emitted(7, 1) Source(4, 14) + SourceIndex(0) +2 >Emitted(7, 10) Source(4, 15) + SourceIndex(0) +3 >Emitted(7, 14) Source(4, 19) + SourceIndex(0) +4 >Emitted(7, 15) Source(4, 19) + SourceIndex(0) +--- +>>>//# sourceMappingURL=a.js.map=================================================================== +JsFile: b.js +mapUrl: b.js.map +sourceRoot: +sources: b.ts +=================================================================== +------------------------------------------------------------------- +emittedFile:tests/cases/compiler/b.js +sourceFile:b.ts +------------------------------------------------------------------- +>>>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 a_1 = require("./ref/a"); +1 > +2 >^^^^^^^^^^^^^^^^^^ +3 > ^^^^^^^^^ +4 > ^ +5 > ^ +1 > +2 >import {A} from +3 > "./ref/a" +4 > ; +5 > +1 >Emitted(6, 1) Source(1, 1) + SourceIndex(0) +2 >Emitted(6, 19) Source(1, 17) + SourceIndex(0) +3 >Emitted(6, 28) Source(1, 26) + SourceIndex(0) +4 >Emitted(6, 29) Source(1, 27) + SourceIndex(0) +5 >Emitted(6, 30) Source(1, 27) + SourceIndex(0) +--- +>>>var B = (function (_super) { +1 > +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^-> +1 > + > +1 >Emitted(7, 1) Source(2, 1) + SourceIndex(0) +--- +>>> __extends(B, _super); +1->^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^^ +1->export class B extends +2 > A +1->Emitted(8, 5) Source(2, 24) + SourceIndex(0) name (B) +2 >Emitted(8, 26) Source(2, 25) + SourceIndex(0) name (B) +--- +>>> function B() { +1 >^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +1 > +1 >Emitted(9, 5) Source(2, 1) + SourceIndex(0) name (B) +--- +>>> _super.apply(this, arguments); +1->^^^^^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +1->export class B extends +2 > A +1->Emitted(10, 9) Source(2, 24) + SourceIndex(0) name (B.constructor) +2 >Emitted(10, 39) Source(2, 25) + SourceIndex(0) name (B.constructor) +--- +>>> } +1 >^^^^ +2 > ^ +3 > ^^^^^^^^^-> +1 > { +2 > } +1 >Emitted(11, 5) Source(2, 28) + SourceIndex(0) name (B.constructor) +2 >Emitted(11, 6) Source(2, 29) + SourceIndex(0) name (B.constructor) +--- +>>> return B; +1->^^^^ +2 > ^^^^^^^^ +1-> +2 > } +1->Emitted(12, 5) Source(2, 28) + SourceIndex(0) name (B) +2 >Emitted(12, 13) Source(2, 29) + SourceIndex(0) name (B) +--- +>>>})(a_1.A); +1 > +2 >^ +3 > +4 > ^^ +5 > ^^^^^ +6 > ^^ +7 > ^^^^^-> +1 > +2 >} +3 > +4 > export class B extends +5 > A +6 > { } +1 >Emitted(13, 1) Source(2, 28) + SourceIndex(0) name (B) +2 >Emitted(13, 2) Source(2, 29) + SourceIndex(0) name (B) +3 >Emitted(13, 2) Source(2, 1) + SourceIndex(0) +4 >Emitted(13, 4) Source(2, 24) + SourceIndex(0) +5 >Emitted(13, 9) Source(2, 25) + SourceIndex(0) +6 >Emitted(13, 11) Source(2, 29) + SourceIndex(0) +--- +>>>exports.B = B; +1-> +2 >^^^^^^^^^ +3 > ^^^^ +4 > ^ +5 > ^^^^^^^^^^^^^^-> +1-> +2 >B +3 > extends A { } +4 > +1->Emitted(14, 1) Source(2, 14) + SourceIndex(0) +2 >Emitted(14, 10) Source(2, 15) + SourceIndex(0) +3 >Emitted(14, 14) Source(2, 29) + SourceIndex(0) +4 >Emitted(14, 15) Source(2, 29) + SourceIndex(0) +--- +>>>//# sourceMappingURL=b.js.map=================================================================== +JsFile: all.js +mapUrl: all.js.map +sourceRoot: +sources: tests/cases/compiler/ref/a.ts,tests/cases/compiler/b.ts +=================================================================== +------------------------------------------------------------------- +emittedFile:all.js +sourceFile:tests/cases/compiler/ref/a.ts +------------------------------------------------------------------- +>>>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 __()); +>>>}; +>>>// This should be an error +1 > +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^ +3 > ^^^^-> +1 > + > +2 >// This should be an error +1 >Emitted(6, 1) Source(2, 1) + SourceIndex(0) +2 >Emitted(6, 27) Source(2, 27) + SourceIndex(0) +--- +>>>//# sourceMappingURL=all.js.map \ No newline at end of file diff --git a/tests/baselines/reference/outModuleConcatES6.errors.txt b/tests/baselines/reference/outModuleConcatES6.errors.txt new file mode 100644 index 00000000000..d1a2adbc93f --- /dev/null +++ b/tests/baselines/reference/outModuleConcatES6.errors.txt @@ -0,0 +1,13 @@ +error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. + + +!!! error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. +==== tests/cases/compiler/ref/a.ts (0 errors) ==== + + // This should be an error + + export class A { } + +==== tests/cases/compiler/b.ts (0 errors) ==== + import {A} from "./ref/a"; + export class B extends A { } \ No newline at end of file diff --git a/tests/baselines/reference/outModuleConcatES6.js b/tests/baselines/reference/outModuleConcatES6.js new file mode 100644 index 00000000000..91aa1bb90e4 --- /dev/null +++ b/tests/baselines/reference/outModuleConcatES6.js @@ -0,0 +1,32 @@ +//// [tests/cases/compiler/outModuleConcatES6.ts] //// + +//// [a.ts] + +// This should be an error + +export class A { } + +//// [b.ts] +import {A} from "./ref/a"; +export class B extends A { } + +//// [a.js] +// This should be an error +export class A { +} +//# sourceMappingURL=a.js.map//// [b.js] +import { A } from "./ref/a"; +export class B extends A { +} +//# sourceMappingURL=b.js.map//// [all.js] +// This should be an error +//# sourceMappingURL=all.js.map + +//// [a.d.ts] +export declare class A { +} +//// [b.d.ts] +import { A } from "./ref/a"; +export declare class B extends A { +} +//// [all.d.ts] diff --git a/tests/baselines/reference/outModuleConcatES6.js.map b/tests/baselines/reference/outModuleConcatES6.js.map new file mode 100644 index 00000000000..347b15b38f3 --- /dev/null +++ b/tests/baselines/reference/outModuleConcatES6.js.map @@ -0,0 +1,4 @@ +//// [a.js.map] +{"version":3,"file":"a.js","sourceRoot":"","sources":["a.ts"],"names":["A"],"mappings":"AACA,0BAA0B;AAE1B;AAAiBA,CAACA;AAAA"}//// [b.js.map] +{"version":3,"file":"b.js","sourceRoot":"","sources":["b.ts"],"names":["B"],"mappings":"OAAO,EAAC,CAAC,EAAC,MAAM,SAAS;AACzB,uBAAuB,CAAC;AAAGA,CAACA;AAAA"}//// [all.js.map] +{"version":3,"file":"all.js","sourceRoot":"","sources":["tests/cases/compiler/ref/a.ts","tests/cases/compiler/b.ts"],"names":[],"mappings":"AACA,0BAA0B"} \ No newline at end of file diff --git a/tests/baselines/reference/outModuleConcatES6.sourcemap.txt b/tests/baselines/reference/outModuleConcatES6.sourcemap.txt new file mode 100644 index 00000000000..239dff14456 --- /dev/null +++ b/tests/baselines/reference/outModuleConcatES6.sourcemap.txt @@ -0,0 +1,118 @@ +=================================================================== +JsFile: a.js +mapUrl: a.js.map +sourceRoot: +sources: a.ts +=================================================================== +------------------------------------------------------------------- +emittedFile:tests/cases/compiler/ref/a.js +sourceFile:a.ts +------------------------------------------------------------------- +>>>// This should be an error +1 > +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^ +1 > + > +2 >// This should be an error +1 >Emitted(1, 1) Source(2, 1) + SourceIndex(0) +2 >Emitted(1, 27) Source(2, 27) + SourceIndex(0) +--- +>>>export class A { +1 > +2 >^^-> +1 > + > + > +1 >Emitted(2, 1) Source(4, 1) + SourceIndex(0) +--- +>>>} +1-> +2 >^ +3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +1->export class A { +2 >} +1->Emitted(3, 1) Source(4, 18) + SourceIndex(0) name (A) +2 >Emitted(3, 2) Source(4, 19) + SourceIndex(0) name (A) +--- +>>>//# sourceMappingURL=a.js.map1-> +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +1-> +1->Emitted(4, 1) Source(4, 19) + SourceIndex(0) +--- +=================================================================== +JsFile: b.js +mapUrl: b.js.map +sourceRoot: +sources: b.ts +=================================================================== +------------------------------------------------------------------- +emittedFile:tests/cases/compiler/b.js +sourceFile:b.ts +------------------------------------------------------------------- +>>>import { A } from "./ref/a"; +1 >^^^^^^^ +2 > ^^ +3 > ^ +4 > ^^ +5 > ^^^^^^ +6 > ^^^^^^^^^ +1 >import +2 > { +3 > A +4 > } +5 > from +6 > "./ref/a" +1 >Emitted(1, 8) Source(1, 8) + SourceIndex(0) +2 >Emitted(1, 10) Source(1, 9) + SourceIndex(0) +3 >Emitted(1, 11) Source(1, 10) + SourceIndex(0) +4 >Emitted(1, 13) Source(1, 11) + SourceIndex(0) +5 >Emitted(1, 19) Source(1, 17) + SourceIndex(0) +6 >Emitted(1, 28) Source(1, 26) + SourceIndex(0) +--- +>>>export class B extends A { +1 > +2 >^^^^^^^^^^^^^^^^^^^^^^^ +3 > ^ +1 >; + > +2 >export class B extends +3 > A +1 >Emitted(2, 1) Source(2, 1) + SourceIndex(0) +2 >Emitted(2, 24) Source(2, 24) + SourceIndex(0) +3 >Emitted(2, 25) Source(2, 25) + SourceIndex(0) +--- +>>>} +1 > +2 >^ +3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +1 > { +2 >} +1 >Emitted(3, 1) Source(2, 28) + SourceIndex(0) name (B) +2 >Emitted(3, 2) Source(2, 29) + SourceIndex(0) name (B) +--- +>>>//# sourceMappingURL=b.js.map1-> +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +1-> +1->Emitted(4, 1) Source(2, 29) + SourceIndex(0) +--- +=================================================================== +JsFile: all.js +mapUrl: all.js.map +sourceRoot: +sources: tests/cases/compiler/ref/a.ts,tests/cases/compiler/b.ts +=================================================================== +------------------------------------------------------------------- +emittedFile:all.js +sourceFile:tests/cases/compiler/ref/a.ts +------------------------------------------------------------------- +>>>// This should be an error +1 > +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^ +3 > ^^^^-> +1 > + > +2 >// This should be an error +1 >Emitted(1, 1) Source(2, 1) + SourceIndex(0) +2 >Emitted(1, 27) Source(2, 27) + SourceIndex(0) +--- +>>>//# sourceMappingURL=all.js.map \ No newline at end of file diff --git a/tests/baselines/reference/outModuleConcatSystem.js b/tests/baselines/reference/outModuleConcatSystem.js new file mode 100644 index 00000000000..92c8772378f --- /dev/null +++ b/tests/baselines/reference/outModuleConcatSystem.js @@ -0,0 +1,101 @@ +//// [tests/cases/compiler/outModuleConcatSystem.ts] //// + +//// [a.ts] + +export class A { } + +//// [b.ts] +import {A} from "./ref/a"; +export class B extends A { } + +//// [a.js] +System.register([], function(exports_1) { + var A; + return { + setters:[], + execute: function() { + A = (function () { + function A() { + } + return A; + })(); + exports_1("A", A); + } + } +}); +//# sourceMappingURL=a.js.map//// [b.js] +System.register(["./ref/a"], function(exports_1) { + 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 a_1; + var B; + return { + setters:[ + function (a_1_1) { + a_1 = a_1_1; + }], + execute: function() { + B = (function (_super) { + __extends(B, _super); + function B() { + _super.apply(this, arguments); + } + return B; + })(a_1.A); + exports_1("B", B); + } + } +}); +//# sourceMappingURL=b.js.map//// [all.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 __()); +}; +System.register("tests/cases/compiler/ref/a", [], function(exports_1) { + var A; + return { + setters:[], + execute: function() { + A = (function () { + function A() { + } + return A; + })(); + exports_1("A", A); + } + } +}); +System.register("tests/cases/compiler/b", ["tests/cases/compiler/ref/a"], function(exports_2) { + var a_1; + var B; + return { + setters:[ + function (a_1_1) { + a_1 = a_1_1; + }], + execute: function() { + B = (function (_super) { + __extends(B, _super); + function B() { + _super.apply(this, arguments); + } + return B; + })(a_1.A); + exports_2("B", B); + } + } +}); +//# sourceMappingURL=all.js.map + +//// [a.d.ts] +export declare class A { +} +//// [b.d.ts] +import { A } from "./ref/a"; +export declare class B extends A { +} +//// [all.d.ts] diff --git a/tests/baselines/reference/outModuleConcatSystem.js.map b/tests/baselines/reference/outModuleConcatSystem.js.map new file mode 100644 index 00000000000..a74b131da99 --- /dev/null +++ b/tests/baselines/reference/outModuleConcatSystem.js.map @@ -0,0 +1,4 @@ +//// [a.js.map] +{"version":3,"file":"a.js","sourceRoot":"","sources":["a.ts"],"names":["A","A.constructor"],"mappings":";;;;;YACA;gBAAAA;gBAAiBC,CAACA;gBAADD,QAACA;YAADA,CAACA,AAAlB,IAAkB;YAAlB,iBAAkB,CAAA"}//// [b.js.map] +{"version":3,"file":"b.js","sourceRoot":"","sources":["b.ts"],"names":["B","B.constructor"],"mappings":";;;;;;;;;;;;;;YACA;gBAAuBA,qBAACA;gBAAxBA;oBAAuBC,8BAACA;gBAAGA,CAACA;gBAADD,QAACA;YAADA,CAACA,AAA5B,EAAuB,KAAC,EAAI;YAA5B,iBAA4B,CAAA"}//// [all.js.map] +{"version":3,"file":"all.js","sourceRoot":"","sources":["tests/cases/compiler/ref/a.ts","tests/cases/compiler/b.ts"],"names":["A","A.constructor","B","B.constructor"],"mappings":";;;;;;;;;;YACA;gBAAAA;gBAAiBC,CAACA;gBAADD,QAACA;YAADA,CAACA,AAAlB,IAAkB;YAAlB,iBAAkB,CAAA;;;;;;;;;;;;;YCAlB;gBAAuBE,qBAACA;gBAAxBA;oBAAuBC,8BAACA;gBAAGA,CAACA;gBAADD,QAACA;YAADA,CAACA,AAA5B,EAAuB,KAAC,EAAI;YAA5B,iBAA4B,CAAA"} \ No newline at end of file diff --git a/tests/baselines/reference/outModuleConcatSystem.sourcemap.txt b/tests/baselines/reference/outModuleConcatSystem.sourcemap.txt new file mode 100644 index 00000000000..e717c3f677b --- /dev/null +++ b/tests/baselines/reference/outModuleConcatSystem.sourcemap.txt @@ -0,0 +1,353 @@ +=================================================================== +JsFile: a.js +mapUrl: a.js.map +sourceRoot: +sources: a.ts +=================================================================== +------------------------------------------------------------------- +emittedFile:tests/cases/compiler/ref/a.js +sourceFile:a.ts +------------------------------------------------------------------- +>>>System.register([], function(exports_1) { +>>> var A; +>>> return { +>>> setters:[], +>>> execute: function() { +>>> A = (function () { +1 >^^^^^^^^^^^^ +2 > ^^^^^^^^^^^^^^^^^^^-> +1 > + > +1 >Emitted(6, 13) Source(2, 1) + SourceIndex(0) +--- +>>> function A() { +1->^^^^^^^^^^^^^^^^ +2 > ^^-> +1-> +1->Emitted(7, 17) Source(2, 1) + SourceIndex(0) name (A) +--- +>>> } +1->^^^^^^^^^^^^^^^^ +2 > ^ +3 > ^^^^^^^^^-> +1->export class A { +2 > } +1->Emitted(8, 17) Source(2, 18) + SourceIndex(0) name (A.constructor) +2 >Emitted(8, 18) Source(2, 19) + SourceIndex(0) name (A.constructor) +--- +>>> return A; +1->^^^^^^^^^^^^^^^^ +2 > ^^^^^^^^ +1-> +2 > } +1->Emitted(9, 17) Source(2, 18) + SourceIndex(0) name (A) +2 >Emitted(9, 25) Source(2, 19) + SourceIndex(0) name (A) +--- +>>> })(); +1 >^^^^^^^^^^^^ +2 > ^ +3 > +4 > ^^^^ +5 > ^^^^^^^^^^^^^^-> +1 > +2 > } +3 > +4 > export class A { } +1 >Emitted(10, 13) Source(2, 18) + SourceIndex(0) name (A) +2 >Emitted(10, 14) Source(2, 19) + SourceIndex(0) name (A) +3 >Emitted(10, 14) Source(2, 1) + SourceIndex(0) +4 >Emitted(10, 18) Source(2, 19) + SourceIndex(0) +--- +>>> exports_1("A", A); +1->^^^^^^^^^^^^ +2 > ^^^^^^^^^^^^^^^^^ +3 > ^ +1-> +2 > export class A { } +3 > +1->Emitted(11, 13) Source(2, 1) + SourceIndex(0) +2 >Emitted(11, 30) Source(2, 19) + SourceIndex(0) +3 >Emitted(11, 31) Source(2, 19) + SourceIndex(0) +--- +>>> } +>>> } +>>>}); +>>>//# sourceMappingURL=a.js.map=================================================================== +JsFile: b.js +mapUrl: b.js.map +sourceRoot: +sources: b.ts +=================================================================== +------------------------------------------------------------------- +emittedFile:tests/cases/compiler/b.js +sourceFile:b.ts +------------------------------------------------------------------- +>>>System.register(["./ref/a"], function(exports_1) { +>>> 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 a_1; +>>> var B; +>>> return { +>>> setters:[ +>>> function (a_1_1) { +>>> a_1 = a_1_1; +>>> }], +>>> execute: function() { +>>> B = (function (_super) { +1 >^^^^^^^^^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^-> +1 >import {A} from "./ref/a"; + > +1 >Emitted(15, 13) Source(2, 1) + SourceIndex(0) +--- +>>> __extends(B, _super); +1->^^^^^^^^^^^^^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^^ +1->export class B extends +2 > A +1->Emitted(16, 17) Source(2, 24) + SourceIndex(0) name (B) +2 >Emitted(16, 38) Source(2, 25) + SourceIndex(0) name (B) +--- +>>> function B() { +1 >^^^^^^^^^^^^^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +1 > +1 >Emitted(17, 17) Source(2, 1) + SourceIndex(0) name (B) +--- +>>> _super.apply(this, arguments); +1->^^^^^^^^^^^^^^^^^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +1->export class B extends +2 > A +1->Emitted(18, 21) Source(2, 24) + SourceIndex(0) name (B.constructor) +2 >Emitted(18, 51) Source(2, 25) + SourceIndex(0) name (B.constructor) +--- +>>> } +1 >^^^^^^^^^^^^^^^^ +2 > ^ +3 > ^^^^^^^^^-> +1 > { +2 > } +1 >Emitted(19, 17) Source(2, 28) + SourceIndex(0) name (B.constructor) +2 >Emitted(19, 18) Source(2, 29) + SourceIndex(0) name (B.constructor) +--- +>>> return B; +1->^^^^^^^^^^^^^^^^ +2 > ^^^^^^^^ +1-> +2 > } +1->Emitted(20, 17) Source(2, 28) + SourceIndex(0) name (B) +2 >Emitted(20, 25) Source(2, 29) + SourceIndex(0) name (B) +--- +>>> })(a_1.A); +1 >^^^^^^^^^^^^ +2 > ^ +3 > +4 > ^^ +5 > ^^^^^ +6 > ^^ +7 > ^^^^^^^^^-> +1 > +2 > } +3 > +4 > export class B extends +5 > A +6 > { } +1 >Emitted(21, 13) Source(2, 28) + SourceIndex(0) name (B) +2 >Emitted(21, 14) Source(2, 29) + SourceIndex(0) name (B) +3 >Emitted(21, 14) Source(2, 1) + SourceIndex(0) +4 >Emitted(21, 16) Source(2, 24) + SourceIndex(0) +5 >Emitted(21, 21) Source(2, 25) + SourceIndex(0) +6 >Emitted(21, 23) Source(2, 29) + SourceIndex(0) +--- +>>> exports_1("B", B); +1->^^^^^^^^^^^^ +2 > ^^^^^^^^^^^^^^^^^ +3 > ^ +1-> +2 > export class B extends A { } +3 > +1->Emitted(22, 13) Source(2, 1) + SourceIndex(0) +2 >Emitted(22, 30) Source(2, 29) + SourceIndex(0) +3 >Emitted(22, 31) Source(2, 29) + SourceIndex(0) +--- +>>> } +>>> } +>>>}); +>>>//# sourceMappingURL=b.js.map=================================================================== +JsFile: all.js +mapUrl: all.js.map +sourceRoot: +sources: tests/cases/compiler/ref/a.ts,tests/cases/compiler/b.ts +=================================================================== +------------------------------------------------------------------- +emittedFile:all.js +sourceFile:tests/cases/compiler/ref/a.ts +------------------------------------------------------------------- +>>>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 __()); +>>>}; +>>>System.register("tests/cases/compiler/ref/a", [], function(exports_1) { +>>> var A; +>>> return { +>>> setters:[], +>>> execute: function() { +>>> A = (function () { +1 >^^^^^^^^^^^^ +2 > ^^^^^^^^^^^^^^^^^^^-> +1 > + > +1 >Emitted(11, 13) Source(2, 1) + SourceIndex(0) +--- +>>> function A() { +1->^^^^^^^^^^^^^^^^ +2 > ^^-> +1-> +1->Emitted(12, 17) Source(2, 1) + SourceIndex(0) name (A) +--- +>>> } +1->^^^^^^^^^^^^^^^^ +2 > ^ +3 > ^^^^^^^^^-> +1->export class A { +2 > } +1->Emitted(13, 17) Source(2, 18) + SourceIndex(0) name (A.constructor) +2 >Emitted(13, 18) Source(2, 19) + SourceIndex(0) name (A.constructor) +--- +>>> return A; +1->^^^^^^^^^^^^^^^^ +2 > ^^^^^^^^ +1-> +2 > } +1->Emitted(14, 17) Source(2, 18) + SourceIndex(0) name (A) +2 >Emitted(14, 25) Source(2, 19) + SourceIndex(0) name (A) +--- +>>> })(); +1 >^^^^^^^^^^^^ +2 > ^ +3 > +4 > ^^^^ +5 > ^^^^^^^^^^^^^^-> +1 > +2 > } +3 > +4 > export class A { } +1 >Emitted(15, 13) Source(2, 18) + SourceIndex(0) name (A) +2 >Emitted(15, 14) Source(2, 19) + SourceIndex(0) name (A) +3 >Emitted(15, 14) Source(2, 1) + SourceIndex(0) +4 >Emitted(15, 18) Source(2, 19) + SourceIndex(0) +--- +>>> exports_1("A", A); +1->^^^^^^^^^^^^ +2 > ^^^^^^^^^^^^^^^^^ +3 > ^ +1-> +2 > export class A { } +3 > +1->Emitted(16, 13) Source(2, 1) + SourceIndex(0) +2 >Emitted(16, 30) Source(2, 19) + SourceIndex(0) +3 >Emitted(16, 31) Source(2, 19) + SourceIndex(0) +--- +------------------------------------------------------------------- +emittedFile:all.js +sourceFile:tests/cases/compiler/b.ts +------------------------------------------------------------------- +>>> } +>>> } +>>>}); +>>>System.register("tests/cases/compiler/b", ["tests/cases/compiler/ref/a"], function(exports_2) { +>>> var a_1; +>>> var B; +>>> return { +>>> setters:[ +>>> function (a_1_1) { +>>> a_1 = a_1_1; +>>> }], +>>> execute: function() { +>>> B = (function (_super) { +1 >^^^^^^^^^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^-> +1 >import {A} from "./ref/a"; + > +1 >Emitted(29, 13) Source(2, 1) + SourceIndex(1) +--- +>>> __extends(B, _super); +1->^^^^^^^^^^^^^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^^ +1->export class B extends +2 > A +1->Emitted(30, 17) Source(2, 24) + SourceIndex(1) name (B) +2 >Emitted(30, 38) Source(2, 25) + SourceIndex(1) name (B) +--- +>>> function B() { +1 >^^^^^^^^^^^^^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +1 > +1 >Emitted(31, 17) Source(2, 1) + SourceIndex(1) name (B) +--- +>>> _super.apply(this, arguments); +1->^^^^^^^^^^^^^^^^^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +1->export class B extends +2 > A +1->Emitted(32, 21) Source(2, 24) + SourceIndex(1) name (B.constructor) +2 >Emitted(32, 51) Source(2, 25) + SourceIndex(1) name (B.constructor) +--- +>>> } +1 >^^^^^^^^^^^^^^^^ +2 > ^ +3 > ^^^^^^^^^-> +1 > { +2 > } +1 >Emitted(33, 17) Source(2, 28) + SourceIndex(1) name (B.constructor) +2 >Emitted(33, 18) Source(2, 29) + SourceIndex(1) name (B.constructor) +--- +>>> return B; +1->^^^^^^^^^^^^^^^^ +2 > ^^^^^^^^ +1-> +2 > } +1->Emitted(34, 17) Source(2, 28) + SourceIndex(1) name (B) +2 >Emitted(34, 25) Source(2, 29) + SourceIndex(1) name (B) +--- +>>> })(a_1.A); +1 >^^^^^^^^^^^^ +2 > ^ +3 > +4 > ^^ +5 > ^^^^^ +6 > ^^ +7 > ^^^^^^^^^-> +1 > +2 > } +3 > +4 > export class B extends +5 > A +6 > { } +1 >Emitted(35, 13) Source(2, 28) + SourceIndex(1) name (B) +2 >Emitted(35, 14) Source(2, 29) + SourceIndex(1) name (B) +3 >Emitted(35, 14) Source(2, 1) + SourceIndex(1) +4 >Emitted(35, 16) Source(2, 24) + SourceIndex(1) +5 >Emitted(35, 21) Source(2, 25) + SourceIndex(1) +6 >Emitted(35, 23) Source(2, 29) + SourceIndex(1) +--- +>>> exports_2("B", B); +1->^^^^^^^^^^^^ +2 > ^^^^^^^^^^^^^^^^^ +3 > ^ +1-> +2 > export class B extends A { } +3 > +1->Emitted(36, 13) Source(2, 1) + SourceIndex(1) +2 >Emitted(36, 30) Source(2, 29) + SourceIndex(1) +3 >Emitted(36, 31) Source(2, 29) + SourceIndex(1) +--- +>>> } +>>> } +>>>}); +>>>//# sourceMappingURL=all.js.map \ No newline at end of file diff --git a/tests/baselines/reference/outModuleConcatSystem.symbols b/tests/baselines/reference/outModuleConcatSystem.symbols new file mode 100644 index 00000000000..349de40815a --- /dev/null +++ b/tests/baselines/reference/outModuleConcatSystem.symbols @@ -0,0 +1,13 @@ +=== tests/cases/compiler/ref/a.ts === + +export class A { } +>A : Symbol(A, Decl(a.ts, 0, 0)) + +=== tests/cases/compiler/b.ts === +import {A} from "./ref/a"; +>A : Symbol(A, Decl(b.ts, 0, 8)) + +export class B extends A { } +>B : Symbol(B, Decl(b.ts, 0, 26)) +>A : Symbol(A, Decl(b.ts, 0, 8)) + diff --git a/tests/baselines/reference/outModuleConcatSystem.types b/tests/baselines/reference/outModuleConcatSystem.types new file mode 100644 index 00000000000..6e0d9398853 --- /dev/null +++ b/tests/baselines/reference/outModuleConcatSystem.types @@ -0,0 +1,13 @@ +=== tests/cases/compiler/ref/a.ts === + +export class A { } +>A : A + +=== tests/cases/compiler/b.ts === +import {A} from "./ref/a"; +>A : typeof A + +export class B extends A { } +>B : B +>A : A + diff --git a/tests/baselines/reference/outModuleConcatUmd.errors.txt b/tests/baselines/reference/outModuleConcatUmd.errors.txt new file mode 100644 index 00000000000..8695199c7eb --- /dev/null +++ b/tests/baselines/reference/outModuleConcatUmd.errors.txt @@ -0,0 +1,13 @@ +error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. + + +!!! error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. +==== tests/cases/compiler/ref/a.ts (0 errors) ==== + + // This should error + + export class A { } + +==== tests/cases/compiler/b.ts (0 errors) ==== + import {A} from "./ref/a"; + export class B extends A { } \ No newline at end of file diff --git a/tests/baselines/reference/outModuleConcatUmd.js b/tests/baselines/reference/outModuleConcatUmd.js new file mode 100644 index 00000000000..6ff5e848aa2 --- /dev/null +++ b/tests/baselines/reference/outModuleConcatUmd.js @@ -0,0 +1,70 @@ +//// [tests/cases/compiler/outModuleConcatUmd.ts] //// + +//// [a.ts] + +// This should error + +export class A { } + +//// [b.ts] +import {A} from "./ref/a"; +export class B extends A { } + +//// [a.js] +// This should error +(function (factory) { + if (typeof module === 'object' && typeof module.exports === 'object') { + var v = factory(require, exports); if (v !== undefined) module.exports = v; + } + else if (typeof define === 'function' && define.amd) { + define(["require", "exports"], factory); + } +})(function (require, exports) { + var A = (function () { + function A() { + } + return A; + })(); + exports.A = A; +}); +//# sourceMappingURL=a.js.map//// [b.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 __()); +}; +(function (factory) { + if (typeof module === 'object' && typeof module.exports === 'object') { + var v = factory(require, exports); if (v !== undefined) module.exports = v; + } + else if (typeof define === 'function' && define.amd) { + define(["require", "exports", "./ref/a"], factory); + } +})(function (require, exports) { + var a_1 = require("./ref/a"); + var B = (function (_super) { + __extends(B, _super); + function B() { + _super.apply(this, arguments); + } + return B; + })(a_1.A); + exports.B = B; +}); +//# sourceMappingURL=b.js.map//// [all.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 __()); +}; +// This should error +//# sourceMappingURL=all.js.map + +//// [a.d.ts] +export declare class A { +} +//// [b.d.ts] +import { A } from "./ref/a"; +export declare class B extends A { +} +//// [all.d.ts] diff --git a/tests/baselines/reference/outModuleConcatUmd.js.map b/tests/baselines/reference/outModuleConcatUmd.js.map new file mode 100644 index 00000000000..b00a2c1c187 --- /dev/null +++ b/tests/baselines/reference/outModuleConcatUmd.js.map @@ -0,0 +1,4 @@ +//// [a.js.map] +{"version":3,"file":"a.js","sourceRoot":"","sources":["a.ts"],"names":["A","A.constructor"],"mappings":"AACA,oBAAoB;;;;;;;;;IAEpB;QAAAA;QAAiBC,CAACA;QAADD,QAACA;IAADA,CAACA,AAAlB,IAAkB;IAAL,SAAC,IAAI,CAAA"}//// [b.js.map] +{"version":3,"file":"b.js","sourceRoot":"","sources":["b.ts"],"names":["B","B.constructor"],"mappings":";;;;;;;;;;;;;IAAA,kBAAgB,SAAS,CAAC,CAAA;IAC1B;QAAuBA,qBAACA;QAAxBA;YAAuBC,8BAACA;QAAGA,CAACA;QAADD,QAACA;IAADA,CAACA,AAA5B,EAAuB,KAAC,EAAI;IAAf,SAAC,IAAc,CAAA"}//// [all.js.map] +{"version":3,"file":"all.js","sourceRoot":"","sources":["tests/cases/compiler/ref/a.ts","tests/cases/compiler/b.ts"],"names":[],"mappings":";;;;;AACA,oBAAoB"} \ No newline at end of file diff --git a/tests/baselines/reference/outModuleConcatUmd.sourcemap.txt b/tests/baselines/reference/outModuleConcatUmd.sourcemap.txt new file mode 100644 index 00000000000..9749e38cc40 --- /dev/null +++ b/tests/baselines/reference/outModuleConcatUmd.sourcemap.txt @@ -0,0 +1,237 @@ +=================================================================== +JsFile: a.js +mapUrl: a.js.map +sourceRoot: +sources: a.ts +=================================================================== +------------------------------------------------------------------- +emittedFile:tests/cases/compiler/ref/a.js +sourceFile:a.ts +------------------------------------------------------------------- +>>>// This should error +1 > +2 >^^^^^^^^^^^^^^^^^^^^ +3 > ^^-> +1 > + > +2 >// This should error +1 >Emitted(1, 1) Source(2, 1) + SourceIndex(0) +2 >Emitted(1, 21) Source(2, 21) + SourceIndex(0) +--- +>>>(function (factory) { +>>> if (typeof module === 'object' && typeof module.exports === 'object') { +>>> var v = factory(require, exports); if (v !== undefined) module.exports = v; +>>> } +>>> else if (typeof define === 'function' && define.amd) { +>>> define(["require", "exports"], factory); +>>> } +>>>})(function (require, exports) { +>>> var A = (function () { +1->^^^^ +2 > ^^^^^^^^^^^^^^^^^^^-> +1-> + > + > +1->Emitted(10, 5) Source(4, 1) + SourceIndex(0) +--- +>>> function A() { +1->^^^^^^^^ +2 > ^^-> +1-> +1->Emitted(11, 9) Source(4, 1) + SourceIndex(0) name (A) +--- +>>> } +1->^^^^^^^^ +2 > ^ +3 > ^^^^^^^^^-> +1->export class A { +2 > } +1->Emitted(12, 9) Source(4, 18) + SourceIndex(0) name (A.constructor) +2 >Emitted(12, 10) Source(4, 19) + SourceIndex(0) name (A.constructor) +--- +>>> return A; +1->^^^^^^^^ +2 > ^^^^^^^^ +1-> +2 > } +1->Emitted(13, 9) Source(4, 18) + SourceIndex(0) name (A) +2 >Emitted(13, 17) Source(4, 19) + SourceIndex(0) name (A) +--- +>>> })(); +1 >^^^^ +2 > ^ +3 > +4 > ^^^^ +5 > ^^^^^^^^^^-> +1 > +2 > } +3 > +4 > export class A { } +1 >Emitted(14, 5) Source(4, 18) + SourceIndex(0) name (A) +2 >Emitted(14, 6) Source(4, 19) + SourceIndex(0) name (A) +3 >Emitted(14, 6) Source(4, 1) + SourceIndex(0) +4 >Emitted(14, 10) Source(4, 19) + SourceIndex(0) +--- +>>> exports.A = A; +1->^^^^ +2 > ^^^^^^^^^ +3 > ^^^^ +4 > ^ +1-> +2 > A +3 > { } +4 > +1->Emitted(15, 5) Source(4, 14) + SourceIndex(0) +2 >Emitted(15, 14) Source(4, 15) + SourceIndex(0) +3 >Emitted(15, 18) Source(4, 19) + SourceIndex(0) +4 >Emitted(15, 19) Source(4, 19) + SourceIndex(0) +--- +>>>}); +>>>//# sourceMappingURL=a.js.map=================================================================== +JsFile: b.js +mapUrl: b.js.map +sourceRoot: +sources: b.ts +=================================================================== +------------------------------------------------------------------- +emittedFile:tests/cases/compiler/b.js +sourceFile:b.ts +------------------------------------------------------------------- +>>>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 __()); +>>>}; +>>>(function (factory) { +>>> if (typeof module === 'object' && typeof module.exports === 'object') { +>>> var v = factory(require, exports); if (v !== undefined) module.exports = v; +>>> } +>>> else if (typeof define === 'function' && define.amd) { +>>> define(["require", "exports", "./ref/a"], factory); +>>> } +>>>})(function (require, exports) { +>>> var a_1 = require("./ref/a"); +1 >^^^^ +2 > ^^^^^^^^^^^^^^^^^^ +3 > ^^^^^^^^^ +4 > ^ +5 > ^ +1 > +2 > import {A} from +3 > "./ref/a" +4 > ; +5 > +1 >Emitted(14, 5) Source(1, 1) + SourceIndex(0) +2 >Emitted(14, 23) Source(1, 17) + SourceIndex(0) +3 >Emitted(14, 32) Source(1, 26) + SourceIndex(0) +4 >Emitted(14, 33) Source(1, 27) + SourceIndex(0) +5 >Emitted(14, 34) Source(1, 27) + SourceIndex(0) +--- +>>> var B = (function (_super) { +1 >^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^-> +1 > + > +1 >Emitted(15, 5) Source(2, 1) + SourceIndex(0) +--- +>>> __extends(B, _super); +1->^^^^^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^^ +1->export class B extends +2 > A +1->Emitted(16, 9) Source(2, 24) + SourceIndex(0) name (B) +2 >Emitted(16, 30) Source(2, 25) + SourceIndex(0) name (B) +--- +>>> function B() { +1 >^^^^^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +1 > +1 >Emitted(17, 9) Source(2, 1) + SourceIndex(0) name (B) +--- +>>> _super.apply(this, arguments); +1->^^^^^^^^^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +1->export class B extends +2 > A +1->Emitted(18, 13) Source(2, 24) + SourceIndex(0) name (B.constructor) +2 >Emitted(18, 43) Source(2, 25) + SourceIndex(0) name (B.constructor) +--- +>>> } +1 >^^^^^^^^ +2 > ^ +3 > ^^^^^^^^^-> +1 > { +2 > } +1 >Emitted(19, 9) Source(2, 28) + SourceIndex(0) name (B.constructor) +2 >Emitted(19, 10) Source(2, 29) + SourceIndex(0) name (B.constructor) +--- +>>> return B; +1->^^^^^^^^ +2 > ^^^^^^^^ +1-> +2 > } +1->Emitted(20, 9) Source(2, 28) + SourceIndex(0) name (B) +2 >Emitted(20, 17) Source(2, 29) + SourceIndex(0) name (B) +--- +>>> })(a_1.A); +1 >^^^^ +2 > ^ +3 > +4 > ^^ +5 > ^^^^^ +6 > ^^ +7 > ^^^^^-> +1 > +2 > } +3 > +4 > export class B extends +5 > A +6 > { } +1 >Emitted(21, 5) Source(2, 28) + SourceIndex(0) name (B) +2 >Emitted(21, 6) Source(2, 29) + SourceIndex(0) name (B) +3 >Emitted(21, 6) Source(2, 1) + SourceIndex(0) +4 >Emitted(21, 8) Source(2, 24) + SourceIndex(0) +5 >Emitted(21, 13) Source(2, 25) + SourceIndex(0) +6 >Emitted(21, 15) Source(2, 29) + SourceIndex(0) +--- +>>> exports.B = B; +1->^^^^ +2 > ^^^^^^^^^ +3 > ^^^^ +4 > ^ +1-> +2 > B +3 > extends A { } +4 > +1->Emitted(22, 5) Source(2, 14) + SourceIndex(0) +2 >Emitted(22, 14) Source(2, 15) + SourceIndex(0) +3 >Emitted(22, 18) Source(2, 29) + SourceIndex(0) +4 >Emitted(22, 19) Source(2, 29) + SourceIndex(0) +--- +>>>}); +>>>//# sourceMappingURL=b.js.map=================================================================== +JsFile: all.js +mapUrl: all.js.map +sourceRoot: +sources: tests/cases/compiler/ref/a.ts,tests/cases/compiler/b.ts +=================================================================== +------------------------------------------------------------------- +emittedFile:all.js +sourceFile:tests/cases/compiler/ref/a.ts +------------------------------------------------------------------- +>>>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 __()); +>>>}; +>>>// This should error +1 > +2 >^^^^^^^^^^^^^^^^^^^^ +3 > ^^^^^^^^^^-> +1 > + > +2 >// This should error +1 >Emitted(6, 1) Source(2, 1) + SourceIndex(0) +2 >Emitted(6, 21) Source(2, 21) + SourceIndex(0) +--- +>>>//# sourceMappingURL=all.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFile/amd/bin/test.d.ts b/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFile/amd/bin/test.d.ts new file mode 100644 index 00000000000..d61b4c3b876 --- /dev/null +++ b/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFile/amd/bin/test.d.ts @@ -0,0 +1,13 @@ +/// +declare var m1_a1: number; +declare class m1_c1 { + m1_c1_p1: number; +} +declare var m1_instance1: m1_c1; +declare function m1_f1(): m1_c1; +declare var a1: number; +declare class c1 { + p1: number; +} +declare var instance1: c1; +declare function f1(): c1; diff --git a/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFile/node/bin/test.d.ts b/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFile/node/bin/test.d.ts new file mode 100644 index 00000000000..d61b4c3b876 --- /dev/null +++ b/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFile/node/bin/test.d.ts @@ -0,0 +1,13 @@ +/// +declare var m1_a1: number; +declare class m1_c1 { + m1_c1_p1: number; +} +declare var m1_instance1: m1_c1; +declare function m1_f1(): m1_c1; +declare var a1: number; +declare class c1 { + p1: number; +} +declare var instance1: c1; +declare function f1(): c1; diff --git a/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFile/node/mapRootAbsolutePathMixedSubfolderSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFile/node/mapRootAbsolutePathMixedSubfolderSpecifyOutputFile.errors.txt index 9674c11863f..51edf2991ad 100644 --- a/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFile/node/mapRootAbsolutePathMixedSubfolderSpecifyOutputFile.errors.txt +++ b/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFile/node/mapRootAbsolutePathMixedSubfolderSpecifyOutputFile.errors.txt @@ -1,7 +1,7 @@ -error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. -!!! error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +!!! error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. ==== ref/m1.ts (0 errors) ==== var m1_a1 = 10; class m1_c1 { diff --git a/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.d.ts b/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.d.ts new file mode 100644 index 00000000000..9b9cdd4a214 --- /dev/null +++ b/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.d.ts @@ -0,0 +1,13 @@ +/// +declare var m1_a1: number; +declare class m1_c1 { + m1_c1_p1: number; +} +declare var m1_instance1: m1_c1; +declare function m1_f1(): m1_c1; +declare var a1: number; +declare class c1 { + p1: number; +} +declare var instance1: c1; +declare function f1(): c1; diff --git a/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.d.ts b/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.d.ts new file mode 100644 index 00000000000..9b9cdd4a214 --- /dev/null +++ b/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.d.ts @@ -0,0 +1,13 @@ +/// +declare var m1_a1: number; +declare class m1_c1 { + m1_c1_p1: number; +} +declare var m1_instance1: m1_c1; +declare function m1_f1(): m1_c1; +declare var a1: number; +declare class c1 { + p1: number; +} +declare var instance1: c1; +declare function f1(): c1; diff --git a/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/mapRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory.errors.txt b/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/mapRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory.errors.txt index 9674c11863f..51edf2991ad 100644 --- a/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/mapRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory.errors.txt +++ b/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/mapRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory.errors.txt @@ -1,7 +1,7 @@ -error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. -!!! error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +!!! error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. ==== ref/m1.ts (0 errors) ==== var m1_a1 = 10; class m1_c1 { diff --git a/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderSpecifyOutputFile/amd/bin/test.d.ts b/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderSpecifyOutputFile/amd/bin/test.d.ts new file mode 100644 index 00000000000..e69de29bb2d diff --git a/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderSpecifyOutputFile/node/bin/test.d.ts b/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderSpecifyOutputFile/node/bin/test.d.ts new file mode 100644 index 00000000000..e69de29bb2d diff --git a/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderSpecifyOutputFile/node/mapRootAbsolutePathModuleMultifolderSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderSpecifyOutputFile/node/mapRootAbsolutePathModuleMultifolderSpecifyOutputFile.errors.txt index ea8c2e58ae5..20fc9c39de5 100644 --- a/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderSpecifyOutputFile/node/mapRootAbsolutePathModuleMultifolderSpecifyOutputFile.errors.txt +++ b/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderSpecifyOutputFile/node/mapRootAbsolutePathModuleMultifolderSpecifyOutputFile.errors.txt @@ -1,7 +1,7 @@ -error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. -!!! error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +!!! error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. ==== ref/m1.ts (0 errors) ==== export var m1_a1 = 10; export class m1_c1 { diff --git a/tests/baselines/reference/project/mapRootAbsolutePathModuleSimpleSpecifyOutputFile/amd/bin/test.d.ts b/tests/baselines/reference/project/mapRootAbsolutePathModuleSimpleSpecifyOutputFile/amd/bin/test.d.ts new file mode 100644 index 00000000000..e69de29bb2d diff --git a/tests/baselines/reference/project/mapRootAbsolutePathModuleSimpleSpecifyOutputFile/node/bin/test.d.ts b/tests/baselines/reference/project/mapRootAbsolutePathModuleSimpleSpecifyOutputFile/node/bin/test.d.ts new file mode 100644 index 00000000000..e69de29bb2d diff --git a/tests/baselines/reference/project/mapRootAbsolutePathModuleSimpleSpecifyOutputFile/node/mapRootAbsolutePathModuleSimpleSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/mapRootAbsolutePathModuleSimpleSpecifyOutputFile/node/mapRootAbsolutePathModuleSimpleSpecifyOutputFile.errors.txt index 0d918d5b2a0..12592331fb5 100644 --- a/tests/baselines/reference/project/mapRootAbsolutePathModuleSimpleSpecifyOutputFile/node/mapRootAbsolutePathModuleSimpleSpecifyOutputFile.errors.txt +++ b/tests/baselines/reference/project/mapRootAbsolutePathModuleSimpleSpecifyOutputFile/node/mapRootAbsolutePathModuleSimpleSpecifyOutputFile.errors.txt @@ -1,7 +1,7 @@ -error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. -!!! error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +!!! error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. ==== m1.ts (0 errors) ==== export var m1_a1 = 10; export class m1_c1 { diff --git a/tests/baselines/reference/project/mapRootAbsolutePathModuleSubfolderSpecifyOutputFile/amd/bin/test.d.ts b/tests/baselines/reference/project/mapRootAbsolutePathModuleSubfolderSpecifyOutputFile/amd/bin/test.d.ts new file mode 100644 index 00000000000..e69de29bb2d diff --git a/tests/baselines/reference/project/mapRootAbsolutePathModuleSubfolderSpecifyOutputFile/node/bin/test.d.ts b/tests/baselines/reference/project/mapRootAbsolutePathModuleSubfolderSpecifyOutputFile/node/bin/test.d.ts new file mode 100644 index 00000000000..e69de29bb2d diff --git a/tests/baselines/reference/project/mapRootAbsolutePathModuleSubfolderSpecifyOutputFile/node/mapRootAbsolutePathModuleSubfolderSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/mapRootAbsolutePathModuleSubfolderSpecifyOutputFile/node/mapRootAbsolutePathModuleSubfolderSpecifyOutputFile.errors.txt index 2468ab068e2..bbe6b1772ae 100644 --- a/tests/baselines/reference/project/mapRootAbsolutePathModuleSubfolderSpecifyOutputFile/node/mapRootAbsolutePathModuleSubfolderSpecifyOutputFile.errors.txt +++ b/tests/baselines/reference/project/mapRootAbsolutePathModuleSubfolderSpecifyOutputFile/node/mapRootAbsolutePathModuleSubfolderSpecifyOutputFile.errors.txt @@ -1,7 +1,7 @@ -error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. -!!! error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +!!! error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. ==== ref/m1.ts (0 errors) ==== export var m1_a1 = 10; export class m1_c1 { diff --git a/tests/baselines/reference/project/mapRootAbsolutePathMultifolderSpecifyOutputFile/node/mapRootAbsolutePathMultifolderSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/mapRootAbsolutePathMultifolderSpecifyOutputFile/node/mapRootAbsolutePathMultifolderSpecifyOutputFile.errors.txt index 8deca814d80..664beb97bc2 100644 --- a/tests/baselines/reference/project/mapRootAbsolutePathMultifolderSpecifyOutputFile/node/mapRootAbsolutePathMultifolderSpecifyOutputFile.errors.txt +++ b/tests/baselines/reference/project/mapRootAbsolutePathMultifolderSpecifyOutputFile/node/mapRootAbsolutePathMultifolderSpecifyOutputFile.errors.txt @@ -1,7 +1,7 @@ -error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. -!!! error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +!!! error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. ==== ref/m1.ts (0 errors) ==== var m1_a1 = 10; class m1_c1 { diff --git a/tests/baselines/reference/project/mapRootAbsolutePathSimpleSpecifyOutputFile/node/mapRootAbsolutePathSimpleSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/mapRootAbsolutePathSimpleSpecifyOutputFile/node/mapRootAbsolutePathSimpleSpecifyOutputFile.errors.txt index edf8d0637e2..53fc18f86c7 100644 --- a/tests/baselines/reference/project/mapRootAbsolutePathSimpleSpecifyOutputFile/node/mapRootAbsolutePathSimpleSpecifyOutputFile.errors.txt +++ b/tests/baselines/reference/project/mapRootAbsolutePathSimpleSpecifyOutputFile/node/mapRootAbsolutePathSimpleSpecifyOutputFile.errors.txt @@ -1,7 +1,7 @@ -error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. -!!! error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +!!! error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. ==== m1.ts (0 errors) ==== var m1_a1 = 10; class m1_c1 { diff --git a/tests/baselines/reference/project/mapRootAbsolutePathSingleFileSpecifyOutputFile/node/mapRootAbsolutePathSingleFileSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/mapRootAbsolutePathSingleFileSpecifyOutputFile/node/mapRootAbsolutePathSingleFileSpecifyOutputFile.errors.txt index 3413d4675e7..eb358c3b79d 100644 --- a/tests/baselines/reference/project/mapRootAbsolutePathSingleFileSpecifyOutputFile/node/mapRootAbsolutePathSingleFileSpecifyOutputFile.errors.txt +++ b/tests/baselines/reference/project/mapRootAbsolutePathSingleFileSpecifyOutputFile/node/mapRootAbsolutePathSingleFileSpecifyOutputFile.errors.txt @@ -1,7 +1,7 @@ -error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. -!!! error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +!!! error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. ==== test.ts (0 errors) ==== var a1 = 10; class c1 { diff --git a/tests/baselines/reference/project/mapRootAbsolutePathSubfolderSpecifyOutputFile/node/mapRootAbsolutePathSubfolderSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/mapRootAbsolutePathSubfolderSpecifyOutputFile/node/mapRootAbsolutePathSubfolderSpecifyOutputFile.errors.txt index 3a508fede30..110e3849820 100644 --- a/tests/baselines/reference/project/mapRootAbsolutePathSubfolderSpecifyOutputFile/node/mapRootAbsolutePathSubfolderSpecifyOutputFile.errors.txt +++ b/tests/baselines/reference/project/mapRootAbsolutePathSubfolderSpecifyOutputFile/node/mapRootAbsolutePathSubfolderSpecifyOutputFile.errors.txt @@ -1,7 +1,7 @@ -error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. -!!! error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +!!! error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. ==== ref/m1.ts (0 errors) ==== var m1_a1 = 10; class m1_c1 { diff --git a/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFile/amd/bin/test.d.ts b/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFile/amd/bin/test.d.ts new file mode 100644 index 00000000000..d61b4c3b876 --- /dev/null +++ b/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFile/amd/bin/test.d.ts @@ -0,0 +1,13 @@ +/// +declare var m1_a1: number; +declare class m1_c1 { + m1_c1_p1: number; +} +declare var m1_instance1: m1_c1; +declare function m1_f1(): m1_c1; +declare var a1: number; +declare class c1 { + p1: number; +} +declare var instance1: c1; +declare function f1(): c1; diff --git a/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFile/node/bin/test.d.ts b/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFile/node/bin/test.d.ts new file mode 100644 index 00000000000..d61b4c3b876 --- /dev/null +++ b/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFile/node/bin/test.d.ts @@ -0,0 +1,13 @@ +/// +declare var m1_a1: number; +declare class m1_c1 { + m1_c1_p1: number; +} +declare var m1_instance1: m1_c1; +declare function m1_f1(): m1_c1; +declare var a1: number; +declare class c1 { + p1: number; +} +declare var instance1: c1; +declare function f1(): c1; diff --git a/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFile/node/mapRootRelativePathMixedSubfolderSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFile/node/mapRootRelativePathMixedSubfolderSpecifyOutputFile.errors.txt index 9674c11863f..51edf2991ad 100644 --- a/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFile/node/mapRootRelativePathMixedSubfolderSpecifyOutputFile.errors.txt +++ b/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFile/node/mapRootRelativePathMixedSubfolderSpecifyOutputFile.errors.txt @@ -1,7 +1,7 @@ -error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. -!!! error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +!!! error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. ==== ref/m1.ts (0 errors) ==== var m1_a1 = 10; class m1_c1 { diff --git a/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.d.ts b/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.d.ts new file mode 100644 index 00000000000..9b9cdd4a214 --- /dev/null +++ b/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.d.ts @@ -0,0 +1,13 @@ +/// +declare var m1_a1: number; +declare class m1_c1 { + m1_c1_p1: number; +} +declare var m1_instance1: m1_c1; +declare function m1_f1(): m1_c1; +declare var a1: number; +declare class c1 { + p1: number; +} +declare var instance1: c1; +declare function f1(): c1; diff --git a/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.d.ts b/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.d.ts new file mode 100644 index 00000000000..9b9cdd4a214 --- /dev/null +++ b/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.d.ts @@ -0,0 +1,13 @@ +/// +declare var m1_a1: number; +declare class m1_c1 { + m1_c1_p1: number; +} +declare var m1_instance1: m1_c1; +declare function m1_f1(): m1_c1; +declare var a1: number; +declare class c1 { + p1: number; +} +declare var instance1: c1; +declare function f1(): c1; diff --git a/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/mapRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory.errors.txt b/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/mapRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory.errors.txt index 9674c11863f..51edf2991ad 100644 --- a/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/mapRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory.errors.txt +++ b/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/mapRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory.errors.txt @@ -1,7 +1,7 @@ -error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. -!!! error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +!!! error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. ==== ref/m1.ts (0 errors) ==== var m1_a1 = 10; class m1_c1 { diff --git a/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderSpecifyOutputFile/amd/bin/test.d.ts b/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderSpecifyOutputFile/amd/bin/test.d.ts new file mode 100644 index 00000000000..e69de29bb2d diff --git a/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderSpecifyOutputFile/node/bin/test.d.ts b/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderSpecifyOutputFile/node/bin/test.d.ts new file mode 100644 index 00000000000..e69de29bb2d diff --git a/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderSpecifyOutputFile/node/mapRootRelativePathModuleMultifolderSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderSpecifyOutputFile/node/mapRootRelativePathModuleMultifolderSpecifyOutputFile.errors.txt index ea8c2e58ae5..20fc9c39de5 100644 --- a/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderSpecifyOutputFile/node/mapRootRelativePathModuleMultifolderSpecifyOutputFile.errors.txt +++ b/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderSpecifyOutputFile/node/mapRootRelativePathModuleMultifolderSpecifyOutputFile.errors.txt @@ -1,7 +1,7 @@ -error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. -!!! error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +!!! error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. ==== ref/m1.ts (0 errors) ==== export var m1_a1 = 10; export class m1_c1 { diff --git a/tests/baselines/reference/project/mapRootRelativePathModuleSimpleSpecifyOutputFile/amd/bin/test.d.ts b/tests/baselines/reference/project/mapRootRelativePathModuleSimpleSpecifyOutputFile/amd/bin/test.d.ts new file mode 100644 index 00000000000..e69de29bb2d diff --git a/tests/baselines/reference/project/mapRootRelativePathModuleSimpleSpecifyOutputFile/node/bin/test.d.ts b/tests/baselines/reference/project/mapRootRelativePathModuleSimpleSpecifyOutputFile/node/bin/test.d.ts new file mode 100644 index 00000000000..e69de29bb2d diff --git a/tests/baselines/reference/project/mapRootRelativePathModuleSimpleSpecifyOutputFile/node/mapRootRelativePathModuleSimpleSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/mapRootRelativePathModuleSimpleSpecifyOutputFile/node/mapRootRelativePathModuleSimpleSpecifyOutputFile.errors.txt index 0d918d5b2a0..12592331fb5 100644 --- a/tests/baselines/reference/project/mapRootRelativePathModuleSimpleSpecifyOutputFile/node/mapRootRelativePathModuleSimpleSpecifyOutputFile.errors.txt +++ b/tests/baselines/reference/project/mapRootRelativePathModuleSimpleSpecifyOutputFile/node/mapRootRelativePathModuleSimpleSpecifyOutputFile.errors.txt @@ -1,7 +1,7 @@ -error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. -!!! error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +!!! error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. ==== m1.ts (0 errors) ==== export var m1_a1 = 10; export class m1_c1 { diff --git a/tests/baselines/reference/project/mapRootRelativePathModuleSubfolderSpecifyOutputFile/amd/bin/test.d.ts b/tests/baselines/reference/project/mapRootRelativePathModuleSubfolderSpecifyOutputFile/amd/bin/test.d.ts new file mode 100644 index 00000000000..e69de29bb2d diff --git a/tests/baselines/reference/project/mapRootRelativePathModuleSubfolderSpecifyOutputFile/node/bin/test.d.ts b/tests/baselines/reference/project/mapRootRelativePathModuleSubfolderSpecifyOutputFile/node/bin/test.d.ts new file mode 100644 index 00000000000..e69de29bb2d diff --git a/tests/baselines/reference/project/mapRootRelativePathModuleSubfolderSpecifyOutputFile/node/mapRootRelativePathModuleSubfolderSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/mapRootRelativePathModuleSubfolderSpecifyOutputFile/node/mapRootRelativePathModuleSubfolderSpecifyOutputFile.errors.txt index 2468ab068e2..bbe6b1772ae 100644 --- a/tests/baselines/reference/project/mapRootRelativePathModuleSubfolderSpecifyOutputFile/node/mapRootRelativePathModuleSubfolderSpecifyOutputFile.errors.txt +++ b/tests/baselines/reference/project/mapRootRelativePathModuleSubfolderSpecifyOutputFile/node/mapRootRelativePathModuleSubfolderSpecifyOutputFile.errors.txt @@ -1,7 +1,7 @@ -error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. -!!! error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +!!! error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. ==== ref/m1.ts (0 errors) ==== export var m1_a1 = 10; export class m1_c1 { diff --git a/tests/baselines/reference/project/mapRootRelativePathMultifolderSpecifyOutputFile/amd/bin/test.d.ts b/tests/baselines/reference/project/mapRootRelativePathMultifolderSpecifyOutputFile/amd/bin/test.d.ts new file mode 100644 index 00000000000..d75277ac607 --- /dev/null +++ b/tests/baselines/reference/project/mapRootRelativePathMultifolderSpecifyOutputFile/amd/bin/test.d.ts @@ -0,0 +1,18 @@ +declare var m1_a1: number; +declare class m1_c1 { + m1_c1_p1: number; +} +declare var m1_instance1: m1_c1; +declare function m1_f1(): m1_c1; +declare var m2_a1: number; +declare class m2_c1 { + m2_c1_p1: number; +} +declare var m2_instance1: m2_c1; +declare function m2_f1(): m2_c1; +declare var a1: number; +declare class c1 { + p1: number; +} +declare var instance1: c1; +declare function f1(): c1; diff --git a/tests/baselines/reference/project/mapRootRelativePathMultifolderSpecifyOutputFile/node/bin/test.d.ts b/tests/baselines/reference/project/mapRootRelativePathMultifolderSpecifyOutputFile/node/bin/test.d.ts new file mode 100644 index 00000000000..d75277ac607 --- /dev/null +++ b/tests/baselines/reference/project/mapRootRelativePathMultifolderSpecifyOutputFile/node/bin/test.d.ts @@ -0,0 +1,18 @@ +declare var m1_a1: number; +declare class m1_c1 { + m1_c1_p1: number; +} +declare var m1_instance1: m1_c1; +declare function m1_f1(): m1_c1; +declare var m2_a1: number; +declare class m2_c1 { + m2_c1_p1: number; +} +declare var m2_instance1: m2_c1; +declare function m2_f1(): m2_c1; +declare var a1: number; +declare class c1 { + p1: number; +} +declare var instance1: c1; +declare function f1(): c1; diff --git a/tests/baselines/reference/project/mapRootRelativePathMultifolderSpecifyOutputFile/node/mapRootRelativePathMultifolderSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/mapRootRelativePathMultifolderSpecifyOutputFile/node/mapRootRelativePathMultifolderSpecifyOutputFile.errors.txt index 8deca814d80..664beb97bc2 100644 --- a/tests/baselines/reference/project/mapRootRelativePathMultifolderSpecifyOutputFile/node/mapRootRelativePathMultifolderSpecifyOutputFile.errors.txt +++ b/tests/baselines/reference/project/mapRootRelativePathMultifolderSpecifyOutputFile/node/mapRootRelativePathMultifolderSpecifyOutputFile.errors.txt @@ -1,7 +1,7 @@ -error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. -!!! error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +!!! error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. ==== ref/m1.ts (0 errors) ==== var m1_a1 = 10; class m1_c1 { diff --git a/tests/baselines/reference/project/mapRootRelativePathSimpleSpecifyOutputFile/node/mapRootRelativePathSimpleSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/mapRootRelativePathSimpleSpecifyOutputFile/node/mapRootRelativePathSimpleSpecifyOutputFile.errors.txt index edf8d0637e2..53fc18f86c7 100644 --- a/tests/baselines/reference/project/mapRootRelativePathSimpleSpecifyOutputFile/node/mapRootRelativePathSimpleSpecifyOutputFile.errors.txt +++ b/tests/baselines/reference/project/mapRootRelativePathSimpleSpecifyOutputFile/node/mapRootRelativePathSimpleSpecifyOutputFile.errors.txt @@ -1,7 +1,7 @@ -error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. -!!! error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +!!! error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. ==== m1.ts (0 errors) ==== var m1_a1 = 10; class m1_c1 { diff --git a/tests/baselines/reference/project/mapRootRelativePathSingleFileSpecifyOutputFile/node/mapRootRelativePathSingleFileSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/mapRootRelativePathSingleFileSpecifyOutputFile/node/mapRootRelativePathSingleFileSpecifyOutputFile.errors.txt index 3413d4675e7..eb358c3b79d 100644 --- a/tests/baselines/reference/project/mapRootRelativePathSingleFileSpecifyOutputFile/node/mapRootRelativePathSingleFileSpecifyOutputFile.errors.txt +++ b/tests/baselines/reference/project/mapRootRelativePathSingleFileSpecifyOutputFile/node/mapRootRelativePathSingleFileSpecifyOutputFile.errors.txt @@ -1,7 +1,7 @@ -error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. -!!! error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +!!! error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. ==== test.ts (0 errors) ==== var a1 = 10; class c1 { diff --git a/tests/baselines/reference/project/mapRootRelativePathSubfolderSpecifyOutputFile/node/mapRootRelativePathSubfolderSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/mapRootRelativePathSubfolderSpecifyOutputFile/node/mapRootRelativePathSubfolderSpecifyOutputFile.errors.txt index 3a508fede30..110e3849820 100644 --- a/tests/baselines/reference/project/mapRootRelativePathSubfolderSpecifyOutputFile/node/mapRootRelativePathSubfolderSpecifyOutputFile.errors.txt +++ b/tests/baselines/reference/project/mapRootRelativePathSubfolderSpecifyOutputFile/node/mapRootRelativePathSubfolderSpecifyOutputFile.errors.txt @@ -1,7 +1,7 @@ -error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. -!!! error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +!!! error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. ==== ref/m1.ts (0 errors) ==== var m1_a1 = 10; class m1_c1 { diff --git a/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFile/amd/bin/test.d.ts b/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFile/amd/bin/test.d.ts new file mode 100644 index 00000000000..d61b4c3b876 --- /dev/null +++ b/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFile/amd/bin/test.d.ts @@ -0,0 +1,13 @@ +/// +declare var m1_a1: number; +declare class m1_c1 { + m1_c1_p1: number; +} +declare var m1_instance1: m1_c1; +declare function m1_f1(): m1_c1; +declare var a1: number; +declare class c1 { + p1: number; +} +declare var instance1: c1; +declare function f1(): c1; diff --git a/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFile/node/bin/test.d.ts b/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFile/node/bin/test.d.ts new file mode 100644 index 00000000000..d61b4c3b876 --- /dev/null +++ b/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFile/node/bin/test.d.ts @@ -0,0 +1,13 @@ +/// +declare var m1_a1: number; +declare class m1_c1 { + m1_c1_p1: number; +} +declare var m1_instance1: m1_c1; +declare function m1_f1(): m1_c1; +declare var a1: number; +declare class c1 { + p1: number; +} +declare var instance1: c1; +declare function f1(): c1; diff --git a/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFile/node/maprootUrlMixedSubfolderSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFile/node/maprootUrlMixedSubfolderSpecifyOutputFile.errors.txt index 9674c11863f..51edf2991ad 100644 --- a/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFile/node/maprootUrlMixedSubfolderSpecifyOutputFile.errors.txt +++ b/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFile/node/maprootUrlMixedSubfolderSpecifyOutputFile.errors.txt @@ -1,7 +1,7 @@ -error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. -!!! error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +!!! error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. ==== ref/m1.ts (0 errors) ==== var m1_a1 = 10; class m1_c1 { diff --git a/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.d.ts b/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.d.ts new file mode 100644 index 00000000000..9b9cdd4a214 --- /dev/null +++ b/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.d.ts @@ -0,0 +1,13 @@ +/// +declare var m1_a1: number; +declare class m1_c1 { + m1_c1_p1: number; +} +declare var m1_instance1: m1_c1; +declare function m1_f1(): m1_c1; +declare var a1: number; +declare class c1 { + p1: number; +} +declare var instance1: c1; +declare function f1(): c1; diff --git a/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.d.ts b/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.d.ts new file mode 100644 index 00000000000..9b9cdd4a214 --- /dev/null +++ b/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.d.ts @@ -0,0 +1,13 @@ +/// +declare var m1_a1: number; +declare class m1_c1 { + m1_c1_p1: number; +} +declare var m1_instance1: m1_c1; +declare function m1_f1(): m1_c1; +declare var a1: number; +declare class c1 { + p1: number; +} +declare var instance1: c1; +declare function f1(): c1; diff --git a/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/maprootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory.errors.txt b/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/maprootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory.errors.txt index 9674c11863f..51edf2991ad 100644 --- a/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/maprootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory.errors.txt +++ b/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/maprootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory.errors.txt @@ -1,7 +1,7 @@ -error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. -!!! error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +!!! error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. ==== ref/m1.ts (0 errors) ==== var m1_a1 = 10; class m1_c1 { diff --git a/tests/baselines/reference/project/maprootUrlModuleMultifolderSpecifyOutputFile/amd/bin/test.d.ts b/tests/baselines/reference/project/maprootUrlModuleMultifolderSpecifyOutputFile/amd/bin/test.d.ts new file mode 100644 index 00000000000..e69de29bb2d diff --git a/tests/baselines/reference/project/maprootUrlModuleMultifolderSpecifyOutputFile/node/bin/test.d.ts b/tests/baselines/reference/project/maprootUrlModuleMultifolderSpecifyOutputFile/node/bin/test.d.ts new file mode 100644 index 00000000000..e69de29bb2d diff --git a/tests/baselines/reference/project/maprootUrlModuleMultifolderSpecifyOutputFile/node/maprootUrlModuleMultifolderSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/maprootUrlModuleMultifolderSpecifyOutputFile/node/maprootUrlModuleMultifolderSpecifyOutputFile.errors.txt index ea8c2e58ae5..20fc9c39de5 100644 --- a/tests/baselines/reference/project/maprootUrlModuleMultifolderSpecifyOutputFile/node/maprootUrlModuleMultifolderSpecifyOutputFile.errors.txt +++ b/tests/baselines/reference/project/maprootUrlModuleMultifolderSpecifyOutputFile/node/maprootUrlModuleMultifolderSpecifyOutputFile.errors.txt @@ -1,7 +1,7 @@ -error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. -!!! error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +!!! error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. ==== ref/m1.ts (0 errors) ==== export var m1_a1 = 10; export class m1_c1 { diff --git a/tests/baselines/reference/project/maprootUrlModuleSimpleSpecifyOutputFile/amd/bin/test.d.ts b/tests/baselines/reference/project/maprootUrlModuleSimpleSpecifyOutputFile/amd/bin/test.d.ts new file mode 100644 index 00000000000..e69de29bb2d diff --git a/tests/baselines/reference/project/maprootUrlModuleSimpleSpecifyOutputFile/node/bin/test.d.ts b/tests/baselines/reference/project/maprootUrlModuleSimpleSpecifyOutputFile/node/bin/test.d.ts new file mode 100644 index 00000000000..e69de29bb2d diff --git a/tests/baselines/reference/project/maprootUrlModuleSimpleSpecifyOutputFile/node/maprootUrlModuleSimpleSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/maprootUrlModuleSimpleSpecifyOutputFile/node/maprootUrlModuleSimpleSpecifyOutputFile.errors.txt index 0d918d5b2a0..12592331fb5 100644 --- a/tests/baselines/reference/project/maprootUrlModuleSimpleSpecifyOutputFile/node/maprootUrlModuleSimpleSpecifyOutputFile.errors.txt +++ b/tests/baselines/reference/project/maprootUrlModuleSimpleSpecifyOutputFile/node/maprootUrlModuleSimpleSpecifyOutputFile.errors.txt @@ -1,7 +1,7 @@ -error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. -!!! error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +!!! error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. ==== m1.ts (0 errors) ==== export var m1_a1 = 10; export class m1_c1 { diff --git a/tests/baselines/reference/project/maprootUrlModuleSubfolderSpecifyOutputFile/amd/bin/test.d.ts b/tests/baselines/reference/project/maprootUrlModuleSubfolderSpecifyOutputFile/amd/bin/test.d.ts new file mode 100644 index 00000000000..e69de29bb2d diff --git a/tests/baselines/reference/project/maprootUrlModuleSubfolderSpecifyOutputFile/node/bin/test.d.ts b/tests/baselines/reference/project/maprootUrlModuleSubfolderSpecifyOutputFile/node/bin/test.d.ts new file mode 100644 index 00000000000..e69de29bb2d diff --git a/tests/baselines/reference/project/maprootUrlModuleSubfolderSpecifyOutputFile/node/maprootUrlModuleSubfolderSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/maprootUrlModuleSubfolderSpecifyOutputFile/node/maprootUrlModuleSubfolderSpecifyOutputFile.errors.txt index 2468ab068e2..bbe6b1772ae 100644 --- a/tests/baselines/reference/project/maprootUrlModuleSubfolderSpecifyOutputFile/node/maprootUrlModuleSubfolderSpecifyOutputFile.errors.txt +++ b/tests/baselines/reference/project/maprootUrlModuleSubfolderSpecifyOutputFile/node/maprootUrlModuleSubfolderSpecifyOutputFile.errors.txt @@ -1,7 +1,7 @@ -error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. -!!! error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +!!! error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. ==== ref/m1.ts (0 errors) ==== export var m1_a1 = 10; export class m1_c1 { diff --git a/tests/baselines/reference/project/maprootUrlMultifolderSpecifyOutputFile/node/maprootUrlMultifolderSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/maprootUrlMultifolderSpecifyOutputFile/node/maprootUrlMultifolderSpecifyOutputFile.errors.txt index 8deca814d80..664beb97bc2 100644 --- a/tests/baselines/reference/project/maprootUrlMultifolderSpecifyOutputFile/node/maprootUrlMultifolderSpecifyOutputFile.errors.txt +++ b/tests/baselines/reference/project/maprootUrlMultifolderSpecifyOutputFile/node/maprootUrlMultifolderSpecifyOutputFile.errors.txt @@ -1,7 +1,7 @@ -error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. -!!! error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +!!! error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. ==== ref/m1.ts (0 errors) ==== var m1_a1 = 10; class m1_c1 { diff --git a/tests/baselines/reference/project/maprootUrlSimpleSpecifyOutputFile/node/maprootUrlSimpleSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/maprootUrlSimpleSpecifyOutputFile/node/maprootUrlSimpleSpecifyOutputFile.errors.txt index edf8d0637e2..53fc18f86c7 100644 --- a/tests/baselines/reference/project/maprootUrlSimpleSpecifyOutputFile/node/maprootUrlSimpleSpecifyOutputFile.errors.txt +++ b/tests/baselines/reference/project/maprootUrlSimpleSpecifyOutputFile/node/maprootUrlSimpleSpecifyOutputFile.errors.txt @@ -1,7 +1,7 @@ -error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. -!!! error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +!!! error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. ==== m1.ts (0 errors) ==== var m1_a1 = 10; class m1_c1 { diff --git a/tests/baselines/reference/project/maprootUrlSingleFileSpecifyOutputFile/node/maprootUrlSingleFileSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/maprootUrlSingleFileSpecifyOutputFile/node/maprootUrlSingleFileSpecifyOutputFile.errors.txt index 3413d4675e7..eb358c3b79d 100644 --- a/tests/baselines/reference/project/maprootUrlSingleFileSpecifyOutputFile/node/maprootUrlSingleFileSpecifyOutputFile.errors.txt +++ b/tests/baselines/reference/project/maprootUrlSingleFileSpecifyOutputFile/node/maprootUrlSingleFileSpecifyOutputFile.errors.txt @@ -1,7 +1,7 @@ -error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. -!!! error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +!!! error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. ==== test.ts (0 errors) ==== var a1 = 10; class c1 { diff --git a/tests/baselines/reference/project/maprootUrlSubfolderSpecifyOutputFile/node/maprootUrlSubfolderSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/maprootUrlSubfolderSpecifyOutputFile/node/maprootUrlSubfolderSpecifyOutputFile.errors.txt index 3a508fede30..110e3849820 100644 --- a/tests/baselines/reference/project/maprootUrlSubfolderSpecifyOutputFile/node/maprootUrlSubfolderSpecifyOutputFile.errors.txt +++ b/tests/baselines/reference/project/maprootUrlSubfolderSpecifyOutputFile/node/maprootUrlSubfolderSpecifyOutputFile.errors.txt @@ -1,7 +1,7 @@ -error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. -!!! error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +!!! error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. ==== ref/m1.ts (0 errors) ==== var m1_a1 = 10; class m1_c1 { diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFile/amd/bin/test.d.ts b/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFile/amd/bin/test.d.ts new file mode 100644 index 00000000000..d61b4c3b876 --- /dev/null +++ b/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFile/amd/bin/test.d.ts @@ -0,0 +1,13 @@ +/// +declare var m1_a1: number; +declare class m1_c1 { + m1_c1_p1: number; +} +declare var m1_instance1: m1_c1; +declare function m1_f1(): m1_c1; +declare var a1: number; +declare class c1 { + p1: number; +} +declare var instance1: c1; +declare function f1(): c1; diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFile/node/bin/test.d.ts b/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFile/node/bin/test.d.ts new file mode 100644 index 00000000000..d61b4c3b876 --- /dev/null +++ b/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFile/node/bin/test.d.ts @@ -0,0 +1,13 @@ +/// +declare var m1_a1: number; +declare class m1_c1 { + m1_c1_p1: number; +} +declare var m1_instance1: m1_c1; +declare function m1_f1(): m1_c1; +declare var a1: number; +declare class c1 { + p1: number; +} +declare var instance1: c1; +declare function f1(): c1; diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFile/node/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFile/node/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFile.errors.txt index 9674c11863f..51edf2991ad 100644 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFile/node/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFile.errors.txt +++ b/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFile/node/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFile.errors.txt @@ -1,7 +1,7 @@ -error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. -!!! error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +!!! error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. ==== ref/m1.ts (0 errors) ==== var m1_a1 = 10; class m1_c1 { diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.d.ts b/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.d.ts new file mode 100644 index 00000000000..9b9cdd4a214 --- /dev/null +++ b/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.d.ts @@ -0,0 +1,13 @@ +/// +declare var m1_a1: number; +declare class m1_c1 { + m1_c1_p1: number; +} +declare var m1_instance1: m1_c1; +declare function m1_f1(): m1_c1; +declare var a1: number; +declare class c1 { + p1: number; +} +declare var instance1: c1; +declare function f1(): c1; diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.d.ts b/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.d.ts new file mode 100644 index 00000000000..9b9cdd4a214 --- /dev/null +++ b/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.d.ts @@ -0,0 +1,13 @@ +/// +declare var m1_a1: number; +declare class m1_c1 { + m1_c1_p1: number; +} +declare var m1_instance1: m1_c1; +declare function m1_f1(): m1_c1; +declare var a1: number; +declare class c1 { + p1: number; +} +declare var instance1: c1; +declare function f1(): c1; diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory.errors.txt b/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory.errors.txt index 9674c11863f..51edf2991ad 100644 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory.errors.txt +++ b/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory.errors.txt @@ -1,7 +1,7 @@ -error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. -!!! error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +!!! error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. ==== ref/m1.ts (0 errors) ==== var m1_a1 = 10; class m1_c1 { diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputFile/amd/bin/test.d.ts b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputFile/amd/bin/test.d.ts new file mode 100644 index 00000000000..e69de29bb2d diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputFile/node/bin/test.d.ts b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputFile/node/bin/test.d.ts new file mode 100644 index 00000000000..e69de29bb2d diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputFile/node/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputFile/node/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputFile.errors.txt index ea8c2e58ae5..20fc9c39de5 100644 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputFile/node/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputFile.errors.txt +++ b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputFile/node/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputFile.errors.txt @@ -1,7 +1,7 @@ -error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. -!!! error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +!!! error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. ==== ref/m1.ts (0 errors) ==== export var m1_a1 = 10; export class m1_c1 { diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSimpleSpecifyOutputFile/amd/bin/test.d.ts b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSimpleSpecifyOutputFile/amd/bin/test.d.ts new file mode 100644 index 00000000000..e69de29bb2d diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSimpleSpecifyOutputFile/node/bin/test.d.ts b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSimpleSpecifyOutputFile/node/bin/test.d.ts new file mode 100644 index 00000000000..e69de29bb2d diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSimpleSpecifyOutputFile/node/maprootUrlsourcerootUrlModuleSimpleSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSimpleSpecifyOutputFile/node/maprootUrlsourcerootUrlModuleSimpleSpecifyOutputFile.errors.txt index 0d918d5b2a0..12592331fb5 100644 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSimpleSpecifyOutputFile/node/maprootUrlsourcerootUrlModuleSimpleSpecifyOutputFile.errors.txt +++ b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSimpleSpecifyOutputFile/node/maprootUrlsourcerootUrlModuleSimpleSpecifyOutputFile.errors.txt @@ -1,7 +1,7 @@ -error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. -!!! error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +!!! error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. ==== m1.ts (0 errors) ==== export var m1_a1 = 10; export class m1_c1 { diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSubfolderSpecifyOutputFile/amd/bin/test.d.ts b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSubfolderSpecifyOutputFile/amd/bin/test.d.ts new file mode 100644 index 00000000000..e69de29bb2d diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSubfolderSpecifyOutputFile/node/bin/test.d.ts b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSubfolderSpecifyOutputFile/node/bin/test.d.ts new file mode 100644 index 00000000000..e69de29bb2d diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSubfolderSpecifyOutputFile/node/maprootUrlsourcerootUrlModuleSubfolderSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSubfolderSpecifyOutputFile/node/maprootUrlsourcerootUrlModuleSubfolderSpecifyOutputFile.errors.txt index 2468ab068e2..bbe6b1772ae 100644 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSubfolderSpecifyOutputFile/node/maprootUrlsourcerootUrlModuleSubfolderSpecifyOutputFile.errors.txt +++ b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSubfolderSpecifyOutputFile/node/maprootUrlsourcerootUrlModuleSubfolderSpecifyOutputFile.errors.txt @@ -1,7 +1,7 @@ -error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. -!!! error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +!!! error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. ==== ref/m1.ts (0 errors) ==== export var m1_a1 = 10; export class m1_c1 { diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlMultifolderSpecifyOutputFile/node/maprootUrlsourcerootUrlMultifolderSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/maprootUrlsourcerootUrlMultifolderSpecifyOutputFile/node/maprootUrlsourcerootUrlMultifolderSpecifyOutputFile.errors.txt index 8deca814d80..664beb97bc2 100644 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlMultifolderSpecifyOutputFile/node/maprootUrlsourcerootUrlMultifolderSpecifyOutputFile.errors.txt +++ b/tests/baselines/reference/project/maprootUrlsourcerootUrlMultifolderSpecifyOutputFile/node/maprootUrlsourcerootUrlMultifolderSpecifyOutputFile.errors.txt @@ -1,7 +1,7 @@ -error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. -!!! error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +!!! error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. ==== ref/m1.ts (0 errors) ==== var m1_a1 = 10; class m1_c1 { diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlSimpleSpecifyOutputFile/node/maprootUrlsourcerootUrlSimpleSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/maprootUrlsourcerootUrlSimpleSpecifyOutputFile/node/maprootUrlsourcerootUrlSimpleSpecifyOutputFile.errors.txt index edf8d0637e2..53fc18f86c7 100644 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlSimpleSpecifyOutputFile/node/maprootUrlsourcerootUrlSimpleSpecifyOutputFile.errors.txt +++ b/tests/baselines/reference/project/maprootUrlsourcerootUrlSimpleSpecifyOutputFile/node/maprootUrlsourcerootUrlSimpleSpecifyOutputFile.errors.txt @@ -1,7 +1,7 @@ -error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. -!!! error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +!!! error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. ==== m1.ts (0 errors) ==== var m1_a1 = 10; class m1_c1 { diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlSingleFileSpecifyOutputFile/node/maprootUrlsourcerootUrlSingleFileSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/maprootUrlsourcerootUrlSingleFileSpecifyOutputFile/node/maprootUrlsourcerootUrlSingleFileSpecifyOutputFile.errors.txt index 3413d4675e7..eb358c3b79d 100644 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlSingleFileSpecifyOutputFile/node/maprootUrlsourcerootUrlSingleFileSpecifyOutputFile.errors.txt +++ b/tests/baselines/reference/project/maprootUrlsourcerootUrlSingleFileSpecifyOutputFile/node/maprootUrlsourcerootUrlSingleFileSpecifyOutputFile.errors.txt @@ -1,7 +1,7 @@ -error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. -!!! error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +!!! error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. ==== test.ts (0 errors) ==== var a1 = 10; class c1 { diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlSubfolderSpecifyOutputFile/node/maprootUrlsourcerootUrlSubfolderSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/maprootUrlsourcerootUrlSubfolderSpecifyOutputFile/node/maprootUrlsourcerootUrlSubfolderSpecifyOutputFile.errors.txt index 3a508fede30..110e3849820 100644 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlSubfolderSpecifyOutputFile/node/maprootUrlsourcerootUrlSubfolderSpecifyOutputFile.errors.txt +++ b/tests/baselines/reference/project/maprootUrlsourcerootUrlSubfolderSpecifyOutputFile/node/maprootUrlsourcerootUrlSubfolderSpecifyOutputFile.errors.txt @@ -1,7 +1,7 @@ -error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. -!!! error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +!!! error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. ==== ref/m1.ts (0 errors) ==== var m1_a1 = 10; class m1_c1 { diff --git a/tests/baselines/reference/project/outMixedSubfolderSpecifyOutputFile/node/outMixedSubfolderSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/outMixedSubfolderSpecifyOutputFile/node/outMixedSubfolderSpecifyOutputFile.errors.txt index 9674c11863f..51edf2991ad 100644 --- a/tests/baselines/reference/project/outMixedSubfolderSpecifyOutputFile/node/outMixedSubfolderSpecifyOutputFile.errors.txt +++ b/tests/baselines/reference/project/outMixedSubfolderSpecifyOutputFile/node/outMixedSubfolderSpecifyOutputFile.errors.txt @@ -1,7 +1,7 @@ -error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. -!!! error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +!!! error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. ==== ref/m1.ts (0 errors) ==== var m1_a1 = 10; class m1_c1 { diff --git a/tests/baselines/reference/project/outMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/outMixedSubfolderSpecifyOutputFileAndOutputDirectory.errors.txt b/tests/baselines/reference/project/outMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/outMixedSubfolderSpecifyOutputFileAndOutputDirectory.errors.txt index 9674c11863f..51edf2991ad 100644 --- a/tests/baselines/reference/project/outMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/outMixedSubfolderSpecifyOutputFileAndOutputDirectory.errors.txt +++ b/tests/baselines/reference/project/outMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/outMixedSubfolderSpecifyOutputFileAndOutputDirectory.errors.txt @@ -1,7 +1,7 @@ -error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. -!!! error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +!!! error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. ==== ref/m1.ts (0 errors) ==== var m1_a1 = 10; class m1_c1 { diff --git a/tests/baselines/reference/project/outModuleMultifolderSpecifyOutputFile/node/outModuleMultifolderSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/outModuleMultifolderSpecifyOutputFile/node/outModuleMultifolderSpecifyOutputFile.errors.txt index ea8c2e58ae5..20fc9c39de5 100644 --- a/tests/baselines/reference/project/outModuleMultifolderSpecifyOutputFile/node/outModuleMultifolderSpecifyOutputFile.errors.txt +++ b/tests/baselines/reference/project/outModuleMultifolderSpecifyOutputFile/node/outModuleMultifolderSpecifyOutputFile.errors.txt @@ -1,7 +1,7 @@ -error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. -!!! error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +!!! error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. ==== ref/m1.ts (0 errors) ==== export var m1_a1 = 10; export class m1_c1 { diff --git a/tests/baselines/reference/project/outModuleSimpleSpecifyOutputFile/node/outModuleSimpleSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/outModuleSimpleSpecifyOutputFile/node/outModuleSimpleSpecifyOutputFile.errors.txt index 0d918d5b2a0..12592331fb5 100644 --- a/tests/baselines/reference/project/outModuleSimpleSpecifyOutputFile/node/outModuleSimpleSpecifyOutputFile.errors.txt +++ b/tests/baselines/reference/project/outModuleSimpleSpecifyOutputFile/node/outModuleSimpleSpecifyOutputFile.errors.txt @@ -1,7 +1,7 @@ -error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. -!!! error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +!!! error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. ==== m1.ts (0 errors) ==== export var m1_a1 = 10; export class m1_c1 { diff --git a/tests/baselines/reference/project/outModuleSubfolderSpecifyOutputFile/node/outModuleSubfolderSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/outModuleSubfolderSpecifyOutputFile/node/outModuleSubfolderSpecifyOutputFile.errors.txt index 2468ab068e2..bbe6b1772ae 100644 --- a/tests/baselines/reference/project/outModuleSubfolderSpecifyOutputFile/node/outModuleSubfolderSpecifyOutputFile.errors.txt +++ b/tests/baselines/reference/project/outModuleSubfolderSpecifyOutputFile/node/outModuleSubfolderSpecifyOutputFile.errors.txt @@ -1,7 +1,7 @@ -error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. -!!! error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +!!! error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. ==== ref/m1.ts (0 errors) ==== export var m1_a1 = 10; export class m1_c1 { diff --git a/tests/baselines/reference/project/outMultifolderSpecifyOutputFile/node/outMultifolderSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/outMultifolderSpecifyOutputFile/node/outMultifolderSpecifyOutputFile.errors.txt index 8deca814d80..664beb97bc2 100644 --- a/tests/baselines/reference/project/outMultifolderSpecifyOutputFile/node/outMultifolderSpecifyOutputFile.errors.txt +++ b/tests/baselines/reference/project/outMultifolderSpecifyOutputFile/node/outMultifolderSpecifyOutputFile.errors.txt @@ -1,7 +1,7 @@ -error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. -!!! error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +!!! error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. ==== ref/m1.ts (0 errors) ==== var m1_a1 = 10; class m1_c1 { diff --git a/tests/baselines/reference/project/outSimpleSpecifyOutputFile/node/outSimpleSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/outSimpleSpecifyOutputFile/node/outSimpleSpecifyOutputFile.errors.txt index edf8d0637e2..53fc18f86c7 100644 --- a/tests/baselines/reference/project/outSimpleSpecifyOutputFile/node/outSimpleSpecifyOutputFile.errors.txt +++ b/tests/baselines/reference/project/outSimpleSpecifyOutputFile/node/outSimpleSpecifyOutputFile.errors.txt @@ -1,7 +1,7 @@ -error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. -!!! error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +!!! error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. ==== m1.ts (0 errors) ==== var m1_a1 = 10; class m1_c1 { diff --git a/tests/baselines/reference/project/outSingleFileSpecifyOutputFile/node/outSingleFileSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/outSingleFileSpecifyOutputFile/node/outSingleFileSpecifyOutputFile.errors.txt index 3413d4675e7..eb358c3b79d 100644 --- a/tests/baselines/reference/project/outSingleFileSpecifyOutputFile/node/outSingleFileSpecifyOutputFile.errors.txt +++ b/tests/baselines/reference/project/outSingleFileSpecifyOutputFile/node/outSingleFileSpecifyOutputFile.errors.txt @@ -1,7 +1,7 @@ -error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. -!!! error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +!!! error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. ==== test.ts (0 errors) ==== var a1 = 10; class c1 { diff --git a/tests/baselines/reference/project/outSubfolderSpecifyOutputFile/node/outSubfolderSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/outSubfolderSpecifyOutputFile/node/outSubfolderSpecifyOutputFile.errors.txt index 3a508fede30..110e3849820 100644 --- a/tests/baselines/reference/project/outSubfolderSpecifyOutputFile/node/outSubfolderSpecifyOutputFile.errors.txt +++ b/tests/baselines/reference/project/outSubfolderSpecifyOutputFile/node/outSubfolderSpecifyOutputFile.errors.txt @@ -1,7 +1,7 @@ -error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. -!!! error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +!!! error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. ==== ref/m1.ts (0 errors) ==== var m1_a1 = 10; class m1_c1 { diff --git a/tests/baselines/reference/project/prologueEmit/node/prologueEmit.errors.txt b/tests/baselines/reference/project/prologueEmit/node/prologueEmit.errors.txt index 5225c47ee97..ef77af7372e 100644 --- a/tests/baselines/reference/project/prologueEmit/node/prologueEmit.errors.txt +++ b/tests/baselines/reference/project/prologueEmit/node/prologueEmit.errors.txt @@ -1,7 +1,7 @@ -error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. -!!! error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +!!! error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. ==== globalThisCapture.ts (0 errors) ==== // Add a lambda to ensure global 'this' capture is triggered (()=>this.window); diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFile/amd/bin/test.d.ts b/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFile/amd/bin/test.d.ts new file mode 100644 index 00000000000..d61b4c3b876 --- /dev/null +++ b/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFile/amd/bin/test.d.ts @@ -0,0 +1,13 @@ +/// +declare var m1_a1: number; +declare class m1_c1 { + m1_c1_p1: number; +} +declare var m1_instance1: m1_c1; +declare function m1_f1(): m1_c1; +declare var a1: number; +declare class c1 { + p1: number; +} +declare var instance1: c1; +declare function f1(): c1; diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFile/node/bin/test.d.ts b/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFile/node/bin/test.d.ts new file mode 100644 index 00000000000..d61b4c3b876 --- /dev/null +++ b/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFile/node/bin/test.d.ts @@ -0,0 +1,13 @@ +/// +declare var m1_a1: number; +declare class m1_c1 { + m1_c1_p1: number; +} +declare var m1_instance1: m1_c1; +declare function m1_f1(): m1_c1; +declare var a1: number; +declare class c1 { + p1: number; +} +declare var instance1: c1; +declare function f1(): c1; diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFile/node/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFile/node/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFile.errors.txt index 9674c11863f..51edf2991ad 100644 --- a/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFile/node/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFile.errors.txt +++ b/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFile/node/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFile.errors.txt @@ -1,7 +1,7 @@ -error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. -!!! error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +!!! error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. ==== ref/m1.ts (0 errors) ==== var m1_a1 = 10; class m1_c1 { diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.d.ts b/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.d.ts new file mode 100644 index 00000000000..9b9cdd4a214 --- /dev/null +++ b/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.d.ts @@ -0,0 +1,13 @@ +/// +declare var m1_a1: number; +declare class m1_c1 { + m1_c1_p1: number; +} +declare var m1_instance1: m1_c1; +declare function m1_f1(): m1_c1; +declare var a1: number; +declare class c1 { + p1: number; +} +declare var instance1: c1; +declare function f1(): c1; diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.d.ts b/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.d.ts new file mode 100644 index 00000000000..9b9cdd4a214 --- /dev/null +++ b/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.d.ts @@ -0,0 +1,13 @@ +/// +declare var m1_a1: number; +declare class m1_c1 { + m1_c1_p1: number; +} +declare var m1_instance1: m1_c1; +declare function m1_f1(): m1_c1; +declare var a1: number; +declare class c1 { + p1: number; +} +declare var instance1: c1; +declare function f1(): c1; diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory.errors.txt b/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory.errors.txt index 9674c11863f..51edf2991ad 100644 --- a/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory.errors.txt +++ b/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory.errors.txt @@ -1,7 +1,7 @@ -error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. -!!! error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +!!! error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. ==== ref/m1.ts (0 errors) ==== var m1_a1 = 10; class m1_c1 { diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderSpecifyOutputFile/amd/bin/test.d.ts b/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderSpecifyOutputFile/amd/bin/test.d.ts new file mode 100644 index 00000000000..e69de29bb2d diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderSpecifyOutputFile/node/bin/test.d.ts b/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderSpecifyOutputFile/node/bin/test.d.ts new file mode 100644 index 00000000000..e69de29bb2d diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderSpecifyOutputFile/node/sourceRootAbsolutePathModuleMultifolderSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderSpecifyOutputFile/node/sourceRootAbsolutePathModuleMultifolderSpecifyOutputFile.errors.txt index ea8c2e58ae5..20fc9c39de5 100644 --- a/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderSpecifyOutputFile/node/sourceRootAbsolutePathModuleMultifolderSpecifyOutputFile.errors.txt +++ b/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderSpecifyOutputFile/node/sourceRootAbsolutePathModuleMultifolderSpecifyOutputFile.errors.txt @@ -1,7 +1,7 @@ -error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. -!!! error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +!!! error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. ==== ref/m1.ts (0 errors) ==== export var m1_a1 = 10; export class m1_c1 { diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathModuleSimpleSpecifyOutputFile/amd/bin/test.d.ts b/tests/baselines/reference/project/sourceRootAbsolutePathModuleSimpleSpecifyOutputFile/amd/bin/test.d.ts new file mode 100644 index 00000000000..e69de29bb2d diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathModuleSimpleSpecifyOutputFile/node/bin/test.d.ts b/tests/baselines/reference/project/sourceRootAbsolutePathModuleSimpleSpecifyOutputFile/node/bin/test.d.ts new file mode 100644 index 00000000000..e69de29bb2d diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathModuleSimpleSpecifyOutputFile/node/sourceRootAbsolutePathModuleSimpleSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/sourceRootAbsolutePathModuleSimpleSpecifyOutputFile/node/sourceRootAbsolutePathModuleSimpleSpecifyOutputFile.errors.txt index 0d918d5b2a0..12592331fb5 100644 --- a/tests/baselines/reference/project/sourceRootAbsolutePathModuleSimpleSpecifyOutputFile/node/sourceRootAbsolutePathModuleSimpleSpecifyOutputFile.errors.txt +++ b/tests/baselines/reference/project/sourceRootAbsolutePathModuleSimpleSpecifyOutputFile/node/sourceRootAbsolutePathModuleSimpleSpecifyOutputFile.errors.txt @@ -1,7 +1,7 @@ -error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. -!!! error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +!!! error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. ==== m1.ts (0 errors) ==== export var m1_a1 = 10; export class m1_c1 { diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathModuleSubfolderSpecifyOutputFile/amd/bin/test.d.ts b/tests/baselines/reference/project/sourceRootAbsolutePathModuleSubfolderSpecifyOutputFile/amd/bin/test.d.ts new file mode 100644 index 00000000000..e69de29bb2d diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathModuleSubfolderSpecifyOutputFile/node/bin/test.d.ts b/tests/baselines/reference/project/sourceRootAbsolutePathModuleSubfolderSpecifyOutputFile/node/bin/test.d.ts new file mode 100644 index 00000000000..e69de29bb2d diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathModuleSubfolderSpecifyOutputFile/node/sourceRootAbsolutePathModuleSubfolderSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/sourceRootAbsolutePathModuleSubfolderSpecifyOutputFile/node/sourceRootAbsolutePathModuleSubfolderSpecifyOutputFile.errors.txt index 2468ab068e2..bbe6b1772ae 100644 --- a/tests/baselines/reference/project/sourceRootAbsolutePathModuleSubfolderSpecifyOutputFile/node/sourceRootAbsolutePathModuleSubfolderSpecifyOutputFile.errors.txt +++ b/tests/baselines/reference/project/sourceRootAbsolutePathModuleSubfolderSpecifyOutputFile/node/sourceRootAbsolutePathModuleSubfolderSpecifyOutputFile.errors.txt @@ -1,7 +1,7 @@ -error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. -!!! error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +!!! error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. ==== ref/m1.ts (0 errors) ==== export var m1_a1 = 10; export class m1_c1 { diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathMultifolderSpecifyOutputFile/node/sourceRootAbsolutePathMultifolderSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/sourceRootAbsolutePathMultifolderSpecifyOutputFile/node/sourceRootAbsolutePathMultifolderSpecifyOutputFile.errors.txt index 8deca814d80..664beb97bc2 100644 --- a/tests/baselines/reference/project/sourceRootAbsolutePathMultifolderSpecifyOutputFile/node/sourceRootAbsolutePathMultifolderSpecifyOutputFile.errors.txt +++ b/tests/baselines/reference/project/sourceRootAbsolutePathMultifolderSpecifyOutputFile/node/sourceRootAbsolutePathMultifolderSpecifyOutputFile.errors.txt @@ -1,7 +1,7 @@ -error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. -!!! error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +!!! error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. ==== ref/m1.ts (0 errors) ==== var m1_a1 = 10; class m1_c1 { diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathSimpleSpecifyOutputFile/node/sourceRootAbsolutePathSimpleSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/sourceRootAbsolutePathSimpleSpecifyOutputFile/node/sourceRootAbsolutePathSimpleSpecifyOutputFile.errors.txt index edf8d0637e2..53fc18f86c7 100644 --- a/tests/baselines/reference/project/sourceRootAbsolutePathSimpleSpecifyOutputFile/node/sourceRootAbsolutePathSimpleSpecifyOutputFile.errors.txt +++ b/tests/baselines/reference/project/sourceRootAbsolutePathSimpleSpecifyOutputFile/node/sourceRootAbsolutePathSimpleSpecifyOutputFile.errors.txt @@ -1,7 +1,7 @@ -error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. -!!! error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +!!! error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. ==== m1.ts (0 errors) ==== var m1_a1 = 10; class m1_c1 { diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathSingleFileSpecifyOutputFile/node/sourceRootAbsolutePathSingleFileSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/sourceRootAbsolutePathSingleFileSpecifyOutputFile/node/sourceRootAbsolutePathSingleFileSpecifyOutputFile.errors.txt index 3413d4675e7..eb358c3b79d 100644 --- a/tests/baselines/reference/project/sourceRootAbsolutePathSingleFileSpecifyOutputFile/node/sourceRootAbsolutePathSingleFileSpecifyOutputFile.errors.txt +++ b/tests/baselines/reference/project/sourceRootAbsolutePathSingleFileSpecifyOutputFile/node/sourceRootAbsolutePathSingleFileSpecifyOutputFile.errors.txt @@ -1,7 +1,7 @@ -error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. -!!! error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +!!! error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. ==== test.ts (0 errors) ==== var a1 = 10; class c1 { diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathSubfolderSpecifyOutputFile/node/sourceRootAbsolutePathSubfolderSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/sourceRootAbsolutePathSubfolderSpecifyOutputFile/node/sourceRootAbsolutePathSubfolderSpecifyOutputFile.errors.txt index 3a508fede30..110e3849820 100644 --- a/tests/baselines/reference/project/sourceRootAbsolutePathSubfolderSpecifyOutputFile/node/sourceRootAbsolutePathSubfolderSpecifyOutputFile.errors.txt +++ b/tests/baselines/reference/project/sourceRootAbsolutePathSubfolderSpecifyOutputFile/node/sourceRootAbsolutePathSubfolderSpecifyOutputFile.errors.txt @@ -1,7 +1,7 @@ -error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. -!!! error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +!!! error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. ==== ref/m1.ts (0 errors) ==== var m1_a1 = 10; class m1_c1 { diff --git a/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFile/amd/bin/test.d.ts b/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFile/amd/bin/test.d.ts new file mode 100644 index 00000000000..d61b4c3b876 --- /dev/null +++ b/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFile/amd/bin/test.d.ts @@ -0,0 +1,13 @@ +/// +declare var m1_a1: number; +declare class m1_c1 { + m1_c1_p1: number; +} +declare var m1_instance1: m1_c1; +declare function m1_f1(): m1_c1; +declare var a1: number; +declare class c1 { + p1: number; +} +declare var instance1: c1; +declare function f1(): c1; diff --git a/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFile/node/bin/test.d.ts b/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFile/node/bin/test.d.ts new file mode 100644 index 00000000000..d61b4c3b876 --- /dev/null +++ b/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFile/node/bin/test.d.ts @@ -0,0 +1,13 @@ +/// +declare var m1_a1: number; +declare class m1_c1 { + m1_c1_p1: number; +} +declare var m1_instance1: m1_c1; +declare function m1_f1(): m1_c1; +declare var a1: number; +declare class c1 { + p1: number; +} +declare var instance1: c1; +declare function f1(): c1; diff --git a/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFile/node/sourceRootRelativePathMixedSubfolderSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFile/node/sourceRootRelativePathMixedSubfolderSpecifyOutputFile.errors.txt index 9674c11863f..51edf2991ad 100644 --- a/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFile/node/sourceRootRelativePathMixedSubfolderSpecifyOutputFile.errors.txt +++ b/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFile/node/sourceRootRelativePathMixedSubfolderSpecifyOutputFile.errors.txt @@ -1,7 +1,7 @@ -error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. -!!! error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +!!! error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. ==== ref/m1.ts (0 errors) ==== var m1_a1 = 10; class m1_c1 { diff --git a/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.d.ts b/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.d.ts new file mode 100644 index 00000000000..9b9cdd4a214 --- /dev/null +++ b/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.d.ts @@ -0,0 +1,13 @@ +/// +declare var m1_a1: number; +declare class m1_c1 { + m1_c1_p1: number; +} +declare var m1_instance1: m1_c1; +declare function m1_f1(): m1_c1; +declare var a1: number; +declare class c1 { + p1: number; +} +declare var instance1: c1; +declare function f1(): c1; diff --git a/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.d.ts b/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.d.ts new file mode 100644 index 00000000000..9b9cdd4a214 --- /dev/null +++ b/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.d.ts @@ -0,0 +1,13 @@ +/// +declare var m1_a1: number; +declare class m1_c1 { + m1_c1_p1: number; +} +declare var m1_instance1: m1_c1; +declare function m1_f1(): m1_c1; +declare var a1: number; +declare class c1 { + p1: number; +} +declare var instance1: c1; +declare function f1(): c1; diff --git a/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/sourceRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory.errors.txt b/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/sourceRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory.errors.txt index 9674c11863f..51edf2991ad 100644 --- a/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/sourceRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory.errors.txt +++ b/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/sourceRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory.errors.txt @@ -1,7 +1,7 @@ -error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. -!!! error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +!!! error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. ==== ref/m1.ts (0 errors) ==== var m1_a1 = 10; class m1_c1 { diff --git a/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderSpecifyOutputFile/amd/bin/test.d.ts b/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderSpecifyOutputFile/amd/bin/test.d.ts new file mode 100644 index 00000000000..e69de29bb2d diff --git a/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderSpecifyOutputFile/node/bin/test.d.ts b/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderSpecifyOutputFile/node/bin/test.d.ts new file mode 100644 index 00000000000..e69de29bb2d diff --git a/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderSpecifyOutputFile/node/sourceRootRelativePathModuleMultifolderSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderSpecifyOutputFile/node/sourceRootRelativePathModuleMultifolderSpecifyOutputFile.errors.txt index ea8c2e58ae5..20fc9c39de5 100644 --- a/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderSpecifyOutputFile/node/sourceRootRelativePathModuleMultifolderSpecifyOutputFile.errors.txt +++ b/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderSpecifyOutputFile/node/sourceRootRelativePathModuleMultifolderSpecifyOutputFile.errors.txt @@ -1,7 +1,7 @@ -error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. -!!! error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +!!! error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. ==== ref/m1.ts (0 errors) ==== export var m1_a1 = 10; export class m1_c1 { diff --git a/tests/baselines/reference/project/sourceRootRelativePathModuleSimpleSpecifyOutputFile/amd/bin/test.d.ts b/tests/baselines/reference/project/sourceRootRelativePathModuleSimpleSpecifyOutputFile/amd/bin/test.d.ts new file mode 100644 index 00000000000..e69de29bb2d diff --git a/tests/baselines/reference/project/sourceRootRelativePathModuleSimpleSpecifyOutputFile/node/bin/test.d.ts b/tests/baselines/reference/project/sourceRootRelativePathModuleSimpleSpecifyOutputFile/node/bin/test.d.ts new file mode 100644 index 00000000000..e69de29bb2d diff --git a/tests/baselines/reference/project/sourceRootRelativePathModuleSimpleSpecifyOutputFile/node/sourceRootRelativePathModuleSimpleSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/sourceRootRelativePathModuleSimpleSpecifyOutputFile/node/sourceRootRelativePathModuleSimpleSpecifyOutputFile.errors.txt index 0d918d5b2a0..12592331fb5 100644 --- a/tests/baselines/reference/project/sourceRootRelativePathModuleSimpleSpecifyOutputFile/node/sourceRootRelativePathModuleSimpleSpecifyOutputFile.errors.txt +++ b/tests/baselines/reference/project/sourceRootRelativePathModuleSimpleSpecifyOutputFile/node/sourceRootRelativePathModuleSimpleSpecifyOutputFile.errors.txt @@ -1,7 +1,7 @@ -error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. -!!! error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +!!! error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. ==== m1.ts (0 errors) ==== export var m1_a1 = 10; export class m1_c1 { diff --git a/tests/baselines/reference/project/sourceRootRelativePathModuleSubfolderSpecifyOutputFile/amd/bin/test.d.ts b/tests/baselines/reference/project/sourceRootRelativePathModuleSubfolderSpecifyOutputFile/amd/bin/test.d.ts new file mode 100644 index 00000000000..e69de29bb2d diff --git a/tests/baselines/reference/project/sourceRootRelativePathModuleSubfolderSpecifyOutputFile/node/bin/test.d.ts b/tests/baselines/reference/project/sourceRootRelativePathModuleSubfolderSpecifyOutputFile/node/bin/test.d.ts new file mode 100644 index 00000000000..e69de29bb2d diff --git a/tests/baselines/reference/project/sourceRootRelativePathModuleSubfolderSpecifyOutputFile/node/sourceRootRelativePathModuleSubfolderSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/sourceRootRelativePathModuleSubfolderSpecifyOutputFile/node/sourceRootRelativePathModuleSubfolderSpecifyOutputFile.errors.txt index 2468ab068e2..bbe6b1772ae 100644 --- a/tests/baselines/reference/project/sourceRootRelativePathModuleSubfolderSpecifyOutputFile/node/sourceRootRelativePathModuleSubfolderSpecifyOutputFile.errors.txt +++ b/tests/baselines/reference/project/sourceRootRelativePathModuleSubfolderSpecifyOutputFile/node/sourceRootRelativePathModuleSubfolderSpecifyOutputFile.errors.txt @@ -1,7 +1,7 @@ -error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. -!!! error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +!!! error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. ==== ref/m1.ts (0 errors) ==== export var m1_a1 = 10; export class m1_c1 { diff --git a/tests/baselines/reference/project/sourceRootRelativePathMultifolderSpecifyOutputFile/node/sourceRootRelativePathMultifolderSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/sourceRootRelativePathMultifolderSpecifyOutputFile/node/sourceRootRelativePathMultifolderSpecifyOutputFile.errors.txt index 8deca814d80..664beb97bc2 100644 --- a/tests/baselines/reference/project/sourceRootRelativePathMultifolderSpecifyOutputFile/node/sourceRootRelativePathMultifolderSpecifyOutputFile.errors.txt +++ b/tests/baselines/reference/project/sourceRootRelativePathMultifolderSpecifyOutputFile/node/sourceRootRelativePathMultifolderSpecifyOutputFile.errors.txt @@ -1,7 +1,7 @@ -error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. -!!! error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +!!! error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. ==== ref/m1.ts (0 errors) ==== var m1_a1 = 10; class m1_c1 { diff --git a/tests/baselines/reference/project/sourceRootRelativePathSimpleSpecifyOutputFile/node/sourceRootRelativePathSimpleSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/sourceRootRelativePathSimpleSpecifyOutputFile/node/sourceRootRelativePathSimpleSpecifyOutputFile.errors.txt index edf8d0637e2..53fc18f86c7 100644 --- a/tests/baselines/reference/project/sourceRootRelativePathSimpleSpecifyOutputFile/node/sourceRootRelativePathSimpleSpecifyOutputFile.errors.txt +++ b/tests/baselines/reference/project/sourceRootRelativePathSimpleSpecifyOutputFile/node/sourceRootRelativePathSimpleSpecifyOutputFile.errors.txt @@ -1,7 +1,7 @@ -error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. -!!! error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +!!! error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. ==== m1.ts (0 errors) ==== var m1_a1 = 10; class m1_c1 { diff --git a/tests/baselines/reference/project/sourceRootRelativePathSingleFileSpecifyOutputFile/node/sourceRootRelativePathSingleFileSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/sourceRootRelativePathSingleFileSpecifyOutputFile/node/sourceRootRelativePathSingleFileSpecifyOutputFile.errors.txt index 3413d4675e7..eb358c3b79d 100644 --- a/tests/baselines/reference/project/sourceRootRelativePathSingleFileSpecifyOutputFile/node/sourceRootRelativePathSingleFileSpecifyOutputFile.errors.txt +++ b/tests/baselines/reference/project/sourceRootRelativePathSingleFileSpecifyOutputFile/node/sourceRootRelativePathSingleFileSpecifyOutputFile.errors.txt @@ -1,7 +1,7 @@ -error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. -!!! error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +!!! error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. ==== test.ts (0 errors) ==== var a1 = 10; class c1 { diff --git a/tests/baselines/reference/project/sourceRootRelativePathSubfolderSpecifyOutputFile/node/sourceRootRelativePathSubfolderSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/sourceRootRelativePathSubfolderSpecifyOutputFile/node/sourceRootRelativePathSubfolderSpecifyOutputFile.errors.txt index 3a508fede30..110e3849820 100644 --- a/tests/baselines/reference/project/sourceRootRelativePathSubfolderSpecifyOutputFile/node/sourceRootRelativePathSubfolderSpecifyOutputFile.errors.txt +++ b/tests/baselines/reference/project/sourceRootRelativePathSubfolderSpecifyOutputFile/node/sourceRootRelativePathSubfolderSpecifyOutputFile.errors.txt @@ -1,7 +1,7 @@ -error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. -!!! error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +!!! error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. ==== ref/m1.ts (0 errors) ==== var m1_a1 = 10; class m1_c1 { diff --git a/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFile/amd/bin/test.d.ts b/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFile/amd/bin/test.d.ts new file mode 100644 index 00000000000..d61b4c3b876 --- /dev/null +++ b/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFile/amd/bin/test.d.ts @@ -0,0 +1,13 @@ +/// +declare var m1_a1: number; +declare class m1_c1 { + m1_c1_p1: number; +} +declare var m1_instance1: m1_c1; +declare function m1_f1(): m1_c1; +declare var a1: number; +declare class c1 { + p1: number; +} +declare var instance1: c1; +declare function f1(): c1; diff --git a/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFile/node/bin/test.d.ts b/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFile/node/bin/test.d.ts new file mode 100644 index 00000000000..d61b4c3b876 --- /dev/null +++ b/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFile/node/bin/test.d.ts @@ -0,0 +1,13 @@ +/// +declare var m1_a1: number; +declare class m1_c1 { + m1_c1_p1: number; +} +declare var m1_instance1: m1_c1; +declare function m1_f1(): m1_c1; +declare var a1: number; +declare class c1 { + p1: number; +} +declare var instance1: c1; +declare function f1(): c1; diff --git a/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFile/node/sourcemapMixedSubfolderSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFile/node/sourcemapMixedSubfolderSpecifyOutputFile.errors.txt index 9674c11863f..51edf2991ad 100644 --- a/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFile/node/sourcemapMixedSubfolderSpecifyOutputFile.errors.txt +++ b/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFile/node/sourcemapMixedSubfolderSpecifyOutputFile.errors.txt @@ -1,7 +1,7 @@ -error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. -!!! error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +!!! error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. ==== ref/m1.ts (0 errors) ==== var m1_a1 = 10; class m1_c1 { diff --git a/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.d.ts b/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.d.ts new file mode 100644 index 00000000000..9b9cdd4a214 --- /dev/null +++ b/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.d.ts @@ -0,0 +1,13 @@ +/// +declare var m1_a1: number; +declare class m1_c1 { + m1_c1_p1: number; +} +declare var m1_instance1: m1_c1; +declare function m1_f1(): m1_c1; +declare var a1: number; +declare class c1 { + p1: number; +} +declare var instance1: c1; +declare function f1(): c1; diff --git a/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.d.ts b/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.d.ts new file mode 100644 index 00000000000..9b9cdd4a214 --- /dev/null +++ b/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.d.ts @@ -0,0 +1,13 @@ +/// +declare var m1_a1: number; +declare class m1_c1 { + m1_c1_p1: number; +} +declare var m1_instance1: m1_c1; +declare function m1_f1(): m1_c1; +declare var a1: number; +declare class c1 { + p1: number; +} +declare var instance1: c1; +declare function f1(): c1; diff --git a/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/sourcemapMixedSubfolderSpecifyOutputFileAndOutputDirectory.errors.txt b/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/sourcemapMixedSubfolderSpecifyOutputFileAndOutputDirectory.errors.txt index 9674c11863f..51edf2991ad 100644 --- a/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/sourcemapMixedSubfolderSpecifyOutputFileAndOutputDirectory.errors.txt +++ b/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/sourcemapMixedSubfolderSpecifyOutputFileAndOutputDirectory.errors.txt @@ -1,7 +1,7 @@ -error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. -!!! error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +!!! error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. ==== ref/m1.ts (0 errors) ==== var m1_a1 = 10; class m1_c1 { diff --git a/tests/baselines/reference/project/sourcemapModuleMultifolderSpecifyOutputFile/amd/bin/test.d.ts b/tests/baselines/reference/project/sourcemapModuleMultifolderSpecifyOutputFile/amd/bin/test.d.ts new file mode 100644 index 00000000000..e69de29bb2d diff --git a/tests/baselines/reference/project/sourcemapModuleMultifolderSpecifyOutputFile/node/bin/test.d.ts b/tests/baselines/reference/project/sourcemapModuleMultifolderSpecifyOutputFile/node/bin/test.d.ts new file mode 100644 index 00000000000..e69de29bb2d diff --git a/tests/baselines/reference/project/sourcemapModuleMultifolderSpecifyOutputFile/node/sourcemapModuleMultifolderSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/sourcemapModuleMultifolderSpecifyOutputFile/node/sourcemapModuleMultifolderSpecifyOutputFile.errors.txt index ea8c2e58ae5..20fc9c39de5 100644 --- a/tests/baselines/reference/project/sourcemapModuleMultifolderSpecifyOutputFile/node/sourcemapModuleMultifolderSpecifyOutputFile.errors.txt +++ b/tests/baselines/reference/project/sourcemapModuleMultifolderSpecifyOutputFile/node/sourcemapModuleMultifolderSpecifyOutputFile.errors.txt @@ -1,7 +1,7 @@ -error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. -!!! error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +!!! error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. ==== ref/m1.ts (0 errors) ==== export var m1_a1 = 10; export class m1_c1 { diff --git a/tests/baselines/reference/project/sourcemapModuleSimpleSpecifyOutputFile/amd/bin/test.d.ts b/tests/baselines/reference/project/sourcemapModuleSimpleSpecifyOutputFile/amd/bin/test.d.ts new file mode 100644 index 00000000000..e69de29bb2d diff --git a/tests/baselines/reference/project/sourcemapModuleSimpleSpecifyOutputFile/node/bin/test.d.ts b/tests/baselines/reference/project/sourcemapModuleSimpleSpecifyOutputFile/node/bin/test.d.ts new file mode 100644 index 00000000000..e69de29bb2d diff --git a/tests/baselines/reference/project/sourcemapModuleSimpleSpecifyOutputFile/node/sourcemapModuleSimpleSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/sourcemapModuleSimpleSpecifyOutputFile/node/sourcemapModuleSimpleSpecifyOutputFile.errors.txt index 0d918d5b2a0..12592331fb5 100644 --- a/tests/baselines/reference/project/sourcemapModuleSimpleSpecifyOutputFile/node/sourcemapModuleSimpleSpecifyOutputFile.errors.txt +++ b/tests/baselines/reference/project/sourcemapModuleSimpleSpecifyOutputFile/node/sourcemapModuleSimpleSpecifyOutputFile.errors.txt @@ -1,7 +1,7 @@ -error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. -!!! error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +!!! error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. ==== m1.ts (0 errors) ==== export var m1_a1 = 10; export class m1_c1 { diff --git a/tests/baselines/reference/project/sourcemapModuleSubfolderSpecifyOutputFile/amd/bin/test.d.ts b/tests/baselines/reference/project/sourcemapModuleSubfolderSpecifyOutputFile/amd/bin/test.d.ts new file mode 100644 index 00000000000..e69de29bb2d diff --git a/tests/baselines/reference/project/sourcemapModuleSubfolderSpecifyOutputFile/node/bin/test.d.ts b/tests/baselines/reference/project/sourcemapModuleSubfolderSpecifyOutputFile/node/bin/test.d.ts new file mode 100644 index 00000000000..e69de29bb2d diff --git a/tests/baselines/reference/project/sourcemapModuleSubfolderSpecifyOutputFile/node/sourcemapModuleSubfolderSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/sourcemapModuleSubfolderSpecifyOutputFile/node/sourcemapModuleSubfolderSpecifyOutputFile.errors.txt index 2468ab068e2..bbe6b1772ae 100644 --- a/tests/baselines/reference/project/sourcemapModuleSubfolderSpecifyOutputFile/node/sourcemapModuleSubfolderSpecifyOutputFile.errors.txt +++ b/tests/baselines/reference/project/sourcemapModuleSubfolderSpecifyOutputFile/node/sourcemapModuleSubfolderSpecifyOutputFile.errors.txt @@ -1,7 +1,7 @@ -error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. -!!! error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +!!! error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. ==== ref/m1.ts (0 errors) ==== export var m1_a1 = 10; export class m1_c1 { diff --git a/tests/baselines/reference/project/sourcemapMultifolderSpecifyOutputFile/node/sourcemapMultifolderSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/sourcemapMultifolderSpecifyOutputFile/node/sourcemapMultifolderSpecifyOutputFile.errors.txt index 8deca814d80..664beb97bc2 100644 --- a/tests/baselines/reference/project/sourcemapMultifolderSpecifyOutputFile/node/sourcemapMultifolderSpecifyOutputFile.errors.txt +++ b/tests/baselines/reference/project/sourcemapMultifolderSpecifyOutputFile/node/sourcemapMultifolderSpecifyOutputFile.errors.txt @@ -1,7 +1,7 @@ -error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. -!!! error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +!!! error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. ==== ref/m1.ts (0 errors) ==== var m1_a1 = 10; class m1_c1 { diff --git a/tests/baselines/reference/project/sourcemapSimpleSpecifyOutputFile/node/sourcemapSimpleSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/sourcemapSimpleSpecifyOutputFile/node/sourcemapSimpleSpecifyOutputFile.errors.txt index edf8d0637e2..53fc18f86c7 100644 --- a/tests/baselines/reference/project/sourcemapSimpleSpecifyOutputFile/node/sourcemapSimpleSpecifyOutputFile.errors.txt +++ b/tests/baselines/reference/project/sourcemapSimpleSpecifyOutputFile/node/sourcemapSimpleSpecifyOutputFile.errors.txt @@ -1,7 +1,7 @@ -error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. -!!! error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +!!! error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. ==== m1.ts (0 errors) ==== var m1_a1 = 10; class m1_c1 { diff --git a/tests/baselines/reference/project/sourcemapSingleFileSpecifyOutputFile/node/sourcemapSingleFileSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/sourcemapSingleFileSpecifyOutputFile/node/sourcemapSingleFileSpecifyOutputFile.errors.txt index 3413d4675e7..eb358c3b79d 100644 --- a/tests/baselines/reference/project/sourcemapSingleFileSpecifyOutputFile/node/sourcemapSingleFileSpecifyOutputFile.errors.txt +++ b/tests/baselines/reference/project/sourcemapSingleFileSpecifyOutputFile/node/sourcemapSingleFileSpecifyOutputFile.errors.txt @@ -1,7 +1,7 @@ -error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. -!!! error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +!!! error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. ==== test.ts (0 errors) ==== var a1 = 10; class c1 { diff --git a/tests/baselines/reference/project/sourcemapSubfolderSpecifyOutputFile/node/sourcemapSubfolderSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/sourcemapSubfolderSpecifyOutputFile/node/sourcemapSubfolderSpecifyOutputFile.errors.txt index 3a508fede30..110e3849820 100644 --- a/tests/baselines/reference/project/sourcemapSubfolderSpecifyOutputFile/node/sourcemapSubfolderSpecifyOutputFile.errors.txt +++ b/tests/baselines/reference/project/sourcemapSubfolderSpecifyOutputFile/node/sourcemapSubfolderSpecifyOutputFile.errors.txt @@ -1,7 +1,7 @@ -error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. -!!! error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +!!! error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. ==== ref/m1.ts (0 errors) ==== var m1_a1 = 10; class m1_c1 { diff --git a/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFile/amd/bin/test.d.ts b/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFile/amd/bin/test.d.ts new file mode 100644 index 00000000000..d61b4c3b876 --- /dev/null +++ b/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFile/amd/bin/test.d.ts @@ -0,0 +1,13 @@ +/// +declare var m1_a1: number; +declare class m1_c1 { + m1_c1_p1: number; +} +declare var m1_instance1: m1_c1; +declare function m1_f1(): m1_c1; +declare var a1: number; +declare class c1 { + p1: number; +} +declare var instance1: c1; +declare function f1(): c1; diff --git a/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFile/node/bin/test.d.ts b/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFile/node/bin/test.d.ts new file mode 100644 index 00000000000..d61b4c3b876 --- /dev/null +++ b/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFile/node/bin/test.d.ts @@ -0,0 +1,13 @@ +/// +declare var m1_a1: number; +declare class m1_c1 { + m1_c1_p1: number; +} +declare var m1_instance1: m1_c1; +declare function m1_f1(): m1_c1; +declare var a1: number; +declare class c1 { + p1: number; +} +declare var instance1: c1; +declare function f1(): c1; diff --git a/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFile/node/sourcerootUrlMixedSubfolderSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFile/node/sourcerootUrlMixedSubfolderSpecifyOutputFile.errors.txt index 9674c11863f..51edf2991ad 100644 --- a/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFile/node/sourcerootUrlMixedSubfolderSpecifyOutputFile.errors.txt +++ b/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFile/node/sourcerootUrlMixedSubfolderSpecifyOutputFile.errors.txt @@ -1,7 +1,7 @@ -error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. -!!! error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +!!! error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. ==== ref/m1.ts (0 errors) ==== var m1_a1 = 10; class m1_c1 { diff --git a/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.d.ts b/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.d.ts new file mode 100644 index 00000000000..9b9cdd4a214 --- /dev/null +++ b/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.d.ts @@ -0,0 +1,13 @@ +/// +declare var m1_a1: number; +declare class m1_c1 { + m1_c1_p1: number; +} +declare var m1_instance1: m1_c1; +declare function m1_f1(): m1_c1; +declare var a1: number; +declare class c1 { + p1: number; +} +declare var instance1: c1; +declare function f1(): c1; diff --git a/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.d.ts b/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.d.ts new file mode 100644 index 00000000000..9b9cdd4a214 --- /dev/null +++ b/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.d.ts @@ -0,0 +1,13 @@ +/// +declare var m1_a1: number; +declare class m1_c1 { + m1_c1_p1: number; +} +declare var m1_instance1: m1_c1; +declare function m1_f1(): m1_c1; +declare var a1: number; +declare class c1 { + p1: number; +} +declare var instance1: c1; +declare function f1(): c1; diff --git a/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/sourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory.errors.txt b/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/sourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory.errors.txt index 9674c11863f..51edf2991ad 100644 --- a/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/sourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory.errors.txt +++ b/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/sourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory.errors.txt @@ -1,7 +1,7 @@ -error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. -!!! error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +!!! error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. ==== ref/m1.ts (0 errors) ==== var m1_a1 = 10; class m1_c1 { diff --git a/tests/baselines/reference/project/sourcerootUrlModuleMultifolderSpecifyOutputFile/amd/bin/test.d.ts b/tests/baselines/reference/project/sourcerootUrlModuleMultifolderSpecifyOutputFile/amd/bin/test.d.ts new file mode 100644 index 00000000000..e69de29bb2d diff --git a/tests/baselines/reference/project/sourcerootUrlModuleMultifolderSpecifyOutputFile/node/bin/test.d.ts b/tests/baselines/reference/project/sourcerootUrlModuleMultifolderSpecifyOutputFile/node/bin/test.d.ts new file mode 100644 index 00000000000..e69de29bb2d diff --git a/tests/baselines/reference/project/sourcerootUrlModuleMultifolderSpecifyOutputFile/node/sourcerootUrlModuleMultifolderSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/sourcerootUrlModuleMultifolderSpecifyOutputFile/node/sourcerootUrlModuleMultifolderSpecifyOutputFile.errors.txt index ea8c2e58ae5..20fc9c39de5 100644 --- a/tests/baselines/reference/project/sourcerootUrlModuleMultifolderSpecifyOutputFile/node/sourcerootUrlModuleMultifolderSpecifyOutputFile.errors.txt +++ b/tests/baselines/reference/project/sourcerootUrlModuleMultifolderSpecifyOutputFile/node/sourcerootUrlModuleMultifolderSpecifyOutputFile.errors.txt @@ -1,7 +1,7 @@ -error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. -!!! error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +!!! error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. ==== ref/m1.ts (0 errors) ==== export var m1_a1 = 10; export class m1_c1 { diff --git a/tests/baselines/reference/project/sourcerootUrlModuleSimpleSpecifyOutputFile/amd/bin/test.d.ts b/tests/baselines/reference/project/sourcerootUrlModuleSimpleSpecifyOutputFile/amd/bin/test.d.ts new file mode 100644 index 00000000000..e69de29bb2d diff --git a/tests/baselines/reference/project/sourcerootUrlModuleSimpleSpecifyOutputFile/node/bin/test.d.ts b/tests/baselines/reference/project/sourcerootUrlModuleSimpleSpecifyOutputFile/node/bin/test.d.ts new file mode 100644 index 00000000000..e69de29bb2d diff --git a/tests/baselines/reference/project/sourcerootUrlModuleSimpleSpecifyOutputFile/node/sourcerootUrlModuleSimpleSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/sourcerootUrlModuleSimpleSpecifyOutputFile/node/sourcerootUrlModuleSimpleSpecifyOutputFile.errors.txt index 0d918d5b2a0..12592331fb5 100644 --- a/tests/baselines/reference/project/sourcerootUrlModuleSimpleSpecifyOutputFile/node/sourcerootUrlModuleSimpleSpecifyOutputFile.errors.txt +++ b/tests/baselines/reference/project/sourcerootUrlModuleSimpleSpecifyOutputFile/node/sourcerootUrlModuleSimpleSpecifyOutputFile.errors.txt @@ -1,7 +1,7 @@ -error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. -!!! error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +!!! error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. ==== m1.ts (0 errors) ==== export var m1_a1 = 10; export class m1_c1 { diff --git a/tests/baselines/reference/project/sourcerootUrlModuleSubfolderSpecifyOutputFile/amd/bin/test.d.ts b/tests/baselines/reference/project/sourcerootUrlModuleSubfolderSpecifyOutputFile/amd/bin/test.d.ts new file mode 100644 index 00000000000..e69de29bb2d diff --git a/tests/baselines/reference/project/sourcerootUrlModuleSubfolderSpecifyOutputFile/node/bin/test.d.ts b/tests/baselines/reference/project/sourcerootUrlModuleSubfolderSpecifyOutputFile/node/bin/test.d.ts new file mode 100644 index 00000000000..e69de29bb2d diff --git a/tests/baselines/reference/project/sourcerootUrlModuleSubfolderSpecifyOutputFile/node/sourcerootUrlModuleSubfolderSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/sourcerootUrlModuleSubfolderSpecifyOutputFile/node/sourcerootUrlModuleSubfolderSpecifyOutputFile.errors.txt index 2468ab068e2..bbe6b1772ae 100644 --- a/tests/baselines/reference/project/sourcerootUrlModuleSubfolderSpecifyOutputFile/node/sourcerootUrlModuleSubfolderSpecifyOutputFile.errors.txt +++ b/tests/baselines/reference/project/sourcerootUrlModuleSubfolderSpecifyOutputFile/node/sourcerootUrlModuleSubfolderSpecifyOutputFile.errors.txt @@ -1,7 +1,7 @@ -error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. -!!! error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +!!! error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. ==== ref/m1.ts (0 errors) ==== export var m1_a1 = 10; export class m1_c1 { diff --git a/tests/baselines/reference/project/sourcerootUrlMultifolderSpecifyOutputFile/node/sourcerootUrlMultifolderSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/sourcerootUrlMultifolderSpecifyOutputFile/node/sourcerootUrlMultifolderSpecifyOutputFile.errors.txt index 8deca814d80..664beb97bc2 100644 --- a/tests/baselines/reference/project/sourcerootUrlMultifolderSpecifyOutputFile/node/sourcerootUrlMultifolderSpecifyOutputFile.errors.txt +++ b/tests/baselines/reference/project/sourcerootUrlMultifolderSpecifyOutputFile/node/sourcerootUrlMultifolderSpecifyOutputFile.errors.txt @@ -1,7 +1,7 @@ -error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. -!!! error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +!!! error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. ==== ref/m1.ts (0 errors) ==== var m1_a1 = 10; class m1_c1 { diff --git a/tests/baselines/reference/project/sourcerootUrlSimpleSpecifyOutputFile/node/sourcerootUrlSimpleSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/sourcerootUrlSimpleSpecifyOutputFile/node/sourcerootUrlSimpleSpecifyOutputFile.errors.txt index edf8d0637e2..53fc18f86c7 100644 --- a/tests/baselines/reference/project/sourcerootUrlSimpleSpecifyOutputFile/node/sourcerootUrlSimpleSpecifyOutputFile.errors.txt +++ b/tests/baselines/reference/project/sourcerootUrlSimpleSpecifyOutputFile/node/sourcerootUrlSimpleSpecifyOutputFile.errors.txt @@ -1,7 +1,7 @@ -error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. -!!! error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +!!! error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. ==== m1.ts (0 errors) ==== var m1_a1 = 10; class m1_c1 { diff --git a/tests/baselines/reference/project/sourcerootUrlSingleFileSpecifyOutputFile/node/sourcerootUrlSingleFileSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/sourcerootUrlSingleFileSpecifyOutputFile/node/sourcerootUrlSingleFileSpecifyOutputFile.errors.txt index 3413d4675e7..eb358c3b79d 100644 --- a/tests/baselines/reference/project/sourcerootUrlSingleFileSpecifyOutputFile/node/sourcerootUrlSingleFileSpecifyOutputFile.errors.txt +++ b/tests/baselines/reference/project/sourcerootUrlSingleFileSpecifyOutputFile/node/sourcerootUrlSingleFileSpecifyOutputFile.errors.txt @@ -1,7 +1,7 @@ -error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. -!!! error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +!!! error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. ==== test.ts (0 errors) ==== var a1 = 10; class c1 { diff --git a/tests/baselines/reference/project/sourcerootUrlSubfolderSpecifyOutputFile/node/sourcerootUrlSubfolderSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/sourcerootUrlSubfolderSpecifyOutputFile/node/sourcerootUrlSubfolderSpecifyOutputFile.errors.txt index 3a508fede30..110e3849820 100644 --- a/tests/baselines/reference/project/sourcerootUrlSubfolderSpecifyOutputFile/node/sourcerootUrlSubfolderSpecifyOutputFile.errors.txt +++ b/tests/baselines/reference/project/sourcerootUrlSubfolderSpecifyOutputFile/node/sourcerootUrlSubfolderSpecifyOutputFile.errors.txt @@ -1,7 +1,7 @@ -error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. -!!! error TS6082: Only 'amd', 'umd', and 'system' modules are supported alongside --outFile. +!!! error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. ==== ref/m1.ts (0 errors) ==== var m1_a1 = 10; class m1_c1 { From f0f5a0d71ee9f7966f10459ddf10468b3e4887f9 Mon Sep 17 00:00:00 2001 From: Vladimir Matveev Date: Sat, 3 Oct 2015 00:20:15 -0700 Subject: [PATCH 042/227] updated command line options, accepted baselines --- src/compiler/binder.ts | 22 +- src/compiler/commandLineParser.ts | 8 +- src/compiler/diagnosticMessages.json | 4 +- src/compiler/types.ts | 4 +- src/compiler/utilities.ts | 2 +- .../reference/assignmentLHSIsValue.errors.txt | 5 +- .../bestCommonTypeReturnStatement.errors.txt | 18 + .../bestCommonTypeReturnStatement.symbols | 34 - .../bestCommonTypeReturnStatement.types | 39 - .../reference/breakTarget3.errors.txt | 11 + .../baselines/reference/breakTarget3.symbols | 7 - tests/baselines/reference/breakTarget3.types | 13 - .../reference/breakTarget4.errors.txt | 11 + .../baselines/reference/breakTarget4.symbols | 7 - tests/baselines/reference/breakTarget4.types | 13 - .../reference/breakTarget5.errors.txt | 5 +- ...utReturnTypeAnnotationInference.errors.txt | 126 + ...thoutReturnTypeAnnotationInference.symbols | 255 -- ...WithoutReturnTypeAnnotationInference.types | 296 -- tests/baselines/reference/cf.errors.txt | 72 + tests/baselines/reference/cf.symbols | 111 - tests/baselines/reference/cf.types | 169 - .../reference/commentsAtEndOfFile1.errors.txt | 10 + .../reference/commentsAtEndOfFile1.symbols | 6 - .../reference/commentsAtEndOfFile1.types | 7 - .../compoundAssignmentLHSIsValue.errors.txt | 5 +- .../conditionalExpressions2.errors.txt | 15 + .../reference/conditionalExpressions2.symbols | 33 - .../reference/conditionalExpressions2.types | 68 - ...nstDeclarations-invalidContexts.errors.txt | 8 +- .../constDeclarations-scopes.errors.txt | 8 +- ...constDeclarations-validContexts.errors.txt | 8 +- ...torWithIncompleteTypeAnnotation.errors.txt | 8 +- ...ontinueNotInIterationStatement4.errors.txt | 5 +- .../reference/continueTarget3.errors.txt | 11 + .../reference/continueTarget3.symbols | 7 - .../baselines/reference/continueTarget3.types | 13 - .../reference/continueTarget4.errors.txt | 11 + .../reference/continueTarget4.symbols | 7 - .../baselines/reference/continueTarget4.types | 13 - .../reference/continueTarget5.errors.txt | 5 +- .../doWhileBreakStatements.errors.txt | 50 + .../reference/doWhileBreakStatements.symbols | 41 - .../reference/doWhileBreakStatements.types | 80 - .../doWhileContinueStatements.errors.txt | 44 + .../doWhileContinueStatements.symbols | 41 - .../reference/doWhileContinueStatements.types | 80 - .../reference/downlevelLetConst16.errors.txt | 8 +- .../reference/downlevelLetConst17.errors.txt | 73 + .../reference/downlevelLetConst17.symbols | 134 - .../reference/downlevelLetConst17.types | 169 - .../reference/downlevelLetConst18.errors.txt | 5 +- .../reference/duplicateLabel1.errors.txt | 5 +- .../reference/duplicateLabel2.errors.txt | 5 +- .../reference/duplicateLabel3.errors.txt | 17 + .../reference/duplicateLabel3.symbols | 11 - .../baselines/reference/duplicateLabel3.types | 18 - .../reference/duplicateLabel4.errors.txt | 16 + .../reference/duplicateLabel4.symbols | 9 - .../baselines/reference/duplicateLabel4.types | 14 - .../duplicateLocalVariable1.errors.txt | 8 +- .../duplicateVariablesByScope.errors.txt | 37 + .../duplicateVariablesByScope.symbols | 56 - .../reference/duplicateVariablesByScope.types | 72 - .../es6ClassSuperCodegenBug.errors.txt | 19 + .../reference/es6ClassSuperCodegenBug.symbols | 24 - .../reference/es6ClassSuperCodegenBug.types | 32 - .../reference/escapedIdentifiers.errors.txt | 146 + .../reference/escapedIdentifiers.symbols | 260 -- .../reference/escapedIdentifiers.types | 351 -- tests/baselines/reference/for.errors.txt | 5 +- .../reference/forBreakStatements.errors.txt | 49 + .../reference/forBreakStatements.symbols | 40 - .../reference/forBreakStatements.types | 63 - .../forContinueStatements.errors.txt | 43 + .../reference/forContinueStatements.symbols | 40 - .../reference/forContinueStatements.types | 63 - .../reference/forInBreakStatements.errors.txt | 46 + .../reference/forInBreakStatements.symbols | 58 - .../reference/forInBreakStatements.types | 92 - .../forInContinueStatements.errors.txt | 46 + .../reference/forInContinueStatements.symbols | 58 - .../reference/forInContinueStatements.types | 92 - .../reference/forStatements.errors.txt | 52 + .../baselines/reference/forStatements.symbols | 145 - tests/baselines/reference/forStatements.types | 164 - ...orStatementsMultipleInvalidDecl.errors.txt | 5 +- .../forStatementsMultipleValidDecl.errors.txt | 39 + .../forStatementsMultipleValidDecl.symbols | 110 - .../forStatementsMultipleValidDecl.types | 140 - .../functionImplementationErrors.errors.txt | 35 +- .../functionImplementations.errors.txt | 183 + .../reference/functionImplementations.symbols | 344 -- .../reference/functionImplementations.types | 416 -- .../reference/functionOverloads12.errors.txt | 10 + .../reference/functionOverloads12.symbols | 10 - .../reference/functionOverloads12.types | 13 - .../reference/functionReturn.errors.txt | 23 + .../reference/functionReturn.symbols | 30 - .../baselines/reference/functionReturn.types | 35 - ...ionWithMultipleReturnStatements.errors.txt | 17 +- ...onWithMultipleReturnStatements2.errors.txt | 26 +- .../functionWithNoBestCommonType1.errors.txt | 5 +- .../functionWithNoBestCommonType2.errors.txt | 5 +- ...gReturnStatementsAndExpressions.errors.txt | 11 +- .../generatedContextualTyping.errors.txt | 393 ++ .../generatedContextualTyping.symbols | 2831 ------------- .../reference/generatedContextualTyping.types | 3768 ----------------- .../reference/ifDoWhileStatements.errors.txt | 168 + .../reference/ifDoWhileStatements.symbols | 336 -- .../reference/ifDoWhileStatements.types | 433 -- .../ifElseWithStatements1.errors.txt | 8 +- ...edFunctionReturnTypeIsEmptyType.errors.txt | 5 +- ...taticPropertyOverridingAccessor.errors.txt | 5 +- .../interfaceExtendingClass2.errors.txt | 5 +- .../interfaceWithPrivateMember.errors.txt | 5 +- .../invalidDoWhileBreakStatements.errors.txt | 8 +- ...nvalidDoWhileContinueStatements.errors.txt | 8 +- .../invalidForBreakStatements.errors.txt | 8 +- .../invalidForContinueStatements.errors.txt | 8 +- .../invalidForInBreakStatements.errors.txt | 17 +- .../invalidForInContinueStatements.errors.txt | 17 +- .../invalidThrowStatement.errors.txt | 5 +- .../invalidWhileBreakStatements.errors.txt | 8 +- .../invalidWhileContinueStatements.errors.txt | 8 +- .../letAndVarRedeclaration.errors.txt | 5 +- ...letDeclarations-invalidContexts.errors.txt | 8 +- .../letDeclarations-scopes.errors.txt | 11 +- .../letDeclarations-validContexts.errors.txt | 20 +- .../reference/localTypes4.errors.txt | 5 +- tests/baselines/reference/null.errors.txt | 30 + tests/baselines/reference/null.symbols | 44 - tests/baselines/reference/null.types | 59 - ...overloadOnConstAsTypeAnnotation.errors.txt | 7 +- .../reference/parser10.1.1-8gs.errors.txt | 5 +- .../reference/parser768531.errors.txt | 8 + .../baselines/reference/parser768531.symbols | 4 - tests/baselines/reference/parser768531.types | 8 - ...serErrorRecovery_ModuleElement1.errors.txt | 5 +- .../parserLabeledStatement1.d.errors.txt | 5 +- .../reference/parser_breakTarget3.errors.txt | 11 + .../reference/parser_breakTarget3.symbols | 7 - .../reference/parser_breakTarget3.types | 13 - .../reference/parser_breakTarget4.errors.txt | 11 + .../reference/parser_breakTarget4.symbols | 7 - .../reference/parser_breakTarget4.types | 13 - .../reference/parser_breakTarget5.errors.txt | 5 +- ...ontinueNotInIterationStatement4.errors.txt | 5 +- .../parser_continueTarget3.errors.txt | 11 + .../reference/parser_continueTarget3.symbols | 7 - .../reference/parser_continueTarget3.types | 13 - .../parser_continueTarget4.errors.txt | 11 + .../reference/parser_continueTarget4.symbols | 7 - .../reference/parser_continueTarget4.types | 13 - .../parser_continueTarget5.errors.txt | 5 +- .../parser_duplicateLabel1.errors.txt | 5 +- .../parser_duplicateLabel2.errors.txt | 5 +- .../parser_duplicateLabel3.errors.txt | 17 + .../reference/parser_duplicateLabel3.symbols | 11 - .../reference/parser_duplicateLabel3.types | 18 - .../parser_duplicateLabel4.errors.txt | 16 + .../reference/parser_duplicateLabel4.symbols | 9 - .../reference/parser_duplicateLabel4.types | 14 - ...ionCannotNameReturnTypeDeclFile.errors.txt | 38 +- .../reference/reachabilityChecks1.errors.txt | 24 +- .../reference/reachabilityChecks2.errors.txt | 4 +- .../reference/reachabilityChecks3.errors.txt | 15 +- .../reference/reachabilityChecks3.js | 11 +- .../reference/reachabilityChecks5.errors.txt | 4 +- .../reference/recursiveLetConst.errors.txt | 5 +- .../reference/recursiveMods.errors.txt | 29 + .../baselines/reference/recursiveMods.symbols | 47 - tests/baselines/reference/recursiveMods.types | 53 - .../recursiveNamedLambdaCall.errors.txt | 5 +- .../reference/reservedWords2.errors.txt | 5 +- .../reference/returnStatement1.errors.txt | 12 + .../reference/returnStatement1.symbols | 14 - .../reference/returnStatement1.types | 17 - .../reference/scanner10.1.1-8gs.errors.txt | 5 +- .../reference/setterWithReturn.errors.txt | 5 +- .../sourceMapValidationFor.errors.txt | 5 +- .../sourceMapValidationLabeled.errors.txt | 8 + .../sourceMapValidationLabeled.symbols | 5 - .../sourceMapValidationLabeled.types | 8 - .../switchBreakStatements.errors.txt | 67 + .../reference/switchBreakStatements.symbols | 58 - .../reference/switchBreakStatements.types | 126 - .../reference/systemModule8.errors.txt | 36 + .../baselines/reference/systemModule8.symbols | 92 - tests/baselines/reference/systemModule8.types | 143 - .../throwInEnclosingStatements.errors.txt | 52 + .../throwInEnclosingStatements.symbols | 93 - .../throwInEnclosingStatements.types | 109 - .../reference/throwStatements.errors.txt | 91 + .../reference/throwStatements.symbols | 215 - .../baselines/reference/throwStatements.types | 266 -- .../reference/throwWithoutNewLine2.errors.txt | 7 +- .../typeGuardFunctionErrors.errors.txt | 5 +- .../typeofOperatorWithAnyOtherType.errors.txt | 11 +- .../typeofOperatorWithBooleanType.errors.txt | 59 + .../typeofOperatorWithBooleanType.symbols | 130 - .../typeofOperatorWithBooleanType.types | 176 - .../typeofOperatorWithEnumType.errors.txt | 33 + .../typeofOperatorWithEnumType.symbols | 69 - .../typeofOperatorWithEnumType.types | 98 - .../typeofOperatorWithNumberType.errors.txt | 69 + .../typeofOperatorWithNumberType.symbols | 168 - .../typeofOperatorWithNumberType.types | 233 - .../typeofOperatorWithStringType.errors.txt | 69 + .../typeofOperatorWithStringType.symbols | 167 - .../typeofOperatorWithStringType.types | 233 - .../reference/undeclaredVarEmit.errors.txt | 5 +- ...lidMultipleVariableDeclarations.errors.txt | 45 + .../validMultipleVariableDeclarations.symbols | 118 - .../validMultipleVariableDeclarations.types | 152 - .../reference/whileBreakStatements.errors.txt | 54 + .../reference/whileBreakStatements.symbols | 45 - .../reference/whileBreakStatements.types | 89 - .../whileContinueStatements.errors.txt | 59 + .../reference/whileContinueStatements.symbols | 56 - .../reference/whileContinueStatements.types | 110 - tests/cases/compiler/reachabilityChecks1.ts | 2 +- tests/cases/compiler/reachabilityChecks2.ts | 2 +- tests/cases/compiler/reachabilityChecks3.ts | 9 +- tests/cases/compiler/reachabilityChecks5.ts | 2 +- .../unclosedFunctionErrorRecovery3.ts | 1 + tests/webTestServer.ts | 1 - 227 files changed, 3047 insertions(+), 15217 deletions(-) create mode 100644 tests/baselines/reference/bestCommonTypeReturnStatement.errors.txt delete mode 100644 tests/baselines/reference/bestCommonTypeReturnStatement.symbols delete mode 100644 tests/baselines/reference/bestCommonTypeReturnStatement.types create mode 100644 tests/baselines/reference/breakTarget3.errors.txt delete mode 100644 tests/baselines/reference/breakTarget3.symbols delete mode 100644 tests/baselines/reference/breakTarget3.types create mode 100644 tests/baselines/reference/breakTarget4.errors.txt delete mode 100644 tests/baselines/reference/breakTarget4.symbols delete mode 100644 tests/baselines/reference/breakTarget4.types create mode 100644 tests/baselines/reference/callSignatureWithoutReturnTypeAnnotationInference.errors.txt delete mode 100644 tests/baselines/reference/callSignatureWithoutReturnTypeAnnotationInference.symbols delete mode 100644 tests/baselines/reference/callSignatureWithoutReturnTypeAnnotationInference.types create mode 100644 tests/baselines/reference/cf.errors.txt delete mode 100644 tests/baselines/reference/cf.symbols delete mode 100644 tests/baselines/reference/cf.types create mode 100644 tests/baselines/reference/commentsAtEndOfFile1.errors.txt delete mode 100644 tests/baselines/reference/commentsAtEndOfFile1.symbols delete mode 100644 tests/baselines/reference/commentsAtEndOfFile1.types create mode 100644 tests/baselines/reference/conditionalExpressions2.errors.txt delete mode 100644 tests/baselines/reference/conditionalExpressions2.symbols delete mode 100644 tests/baselines/reference/conditionalExpressions2.types create mode 100644 tests/baselines/reference/continueTarget3.errors.txt delete mode 100644 tests/baselines/reference/continueTarget3.symbols delete mode 100644 tests/baselines/reference/continueTarget3.types create mode 100644 tests/baselines/reference/continueTarget4.errors.txt delete mode 100644 tests/baselines/reference/continueTarget4.symbols delete mode 100644 tests/baselines/reference/continueTarget4.types create mode 100644 tests/baselines/reference/doWhileBreakStatements.errors.txt delete mode 100644 tests/baselines/reference/doWhileBreakStatements.symbols delete mode 100644 tests/baselines/reference/doWhileBreakStatements.types create mode 100644 tests/baselines/reference/doWhileContinueStatements.errors.txt delete mode 100644 tests/baselines/reference/doWhileContinueStatements.symbols delete mode 100644 tests/baselines/reference/doWhileContinueStatements.types create mode 100644 tests/baselines/reference/downlevelLetConst17.errors.txt delete mode 100644 tests/baselines/reference/downlevelLetConst17.symbols delete mode 100644 tests/baselines/reference/downlevelLetConst17.types create mode 100644 tests/baselines/reference/duplicateLabel3.errors.txt delete mode 100644 tests/baselines/reference/duplicateLabel3.symbols delete mode 100644 tests/baselines/reference/duplicateLabel3.types create mode 100644 tests/baselines/reference/duplicateLabel4.errors.txt delete mode 100644 tests/baselines/reference/duplicateLabel4.symbols delete mode 100644 tests/baselines/reference/duplicateLabel4.types create mode 100644 tests/baselines/reference/duplicateVariablesByScope.errors.txt delete mode 100644 tests/baselines/reference/duplicateVariablesByScope.symbols delete mode 100644 tests/baselines/reference/duplicateVariablesByScope.types create mode 100644 tests/baselines/reference/es6ClassSuperCodegenBug.errors.txt delete mode 100644 tests/baselines/reference/es6ClassSuperCodegenBug.symbols delete mode 100644 tests/baselines/reference/es6ClassSuperCodegenBug.types create mode 100644 tests/baselines/reference/escapedIdentifiers.errors.txt delete mode 100644 tests/baselines/reference/escapedIdentifiers.symbols delete mode 100644 tests/baselines/reference/escapedIdentifiers.types create mode 100644 tests/baselines/reference/forBreakStatements.errors.txt delete mode 100644 tests/baselines/reference/forBreakStatements.symbols delete mode 100644 tests/baselines/reference/forBreakStatements.types create mode 100644 tests/baselines/reference/forContinueStatements.errors.txt delete mode 100644 tests/baselines/reference/forContinueStatements.symbols delete mode 100644 tests/baselines/reference/forContinueStatements.types create mode 100644 tests/baselines/reference/forInBreakStatements.errors.txt delete mode 100644 tests/baselines/reference/forInBreakStatements.symbols delete mode 100644 tests/baselines/reference/forInBreakStatements.types create mode 100644 tests/baselines/reference/forInContinueStatements.errors.txt delete mode 100644 tests/baselines/reference/forInContinueStatements.symbols delete mode 100644 tests/baselines/reference/forInContinueStatements.types create mode 100644 tests/baselines/reference/forStatements.errors.txt delete mode 100644 tests/baselines/reference/forStatements.symbols delete mode 100644 tests/baselines/reference/forStatements.types create mode 100644 tests/baselines/reference/forStatementsMultipleValidDecl.errors.txt delete mode 100644 tests/baselines/reference/forStatementsMultipleValidDecl.symbols delete mode 100644 tests/baselines/reference/forStatementsMultipleValidDecl.types create mode 100644 tests/baselines/reference/functionImplementations.errors.txt delete mode 100644 tests/baselines/reference/functionImplementations.symbols delete mode 100644 tests/baselines/reference/functionImplementations.types create mode 100644 tests/baselines/reference/functionOverloads12.errors.txt delete mode 100644 tests/baselines/reference/functionOverloads12.symbols delete mode 100644 tests/baselines/reference/functionOverloads12.types create mode 100644 tests/baselines/reference/functionReturn.errors.txt delete mode 100644 tests/baselines/reference/functionReturn.symbols delete mode 100644 tests/baselines/reference/functionReturn.types create mode 100644 tests/baselines/reference/generatedContextualTyping.errors.txt delete mode 100644 tests/baselines/reference/generatedContextualTyping.symbols delete mode 100644 tests/baselines/reference/generatedContextualTyping.types create mode 100644 tests/baselines/reference/ifDoWhileStatements.errors.txt delete mode 100644 tests/baselines/reference/ifDoWhileStatements.symbols delete mode 100644 tests/baselines/reference/ifDoWhileStatements.types create mode 100644 tests/baselines/reference/null.errors.txt delete mode 100644 tests/baselines/reference/null.symbols delete mode 100644 tests/baselines/reference/null.types create mode 100644 tests/baselines/reference/parser768531.errors.txt delete mode 100644 tests/baselines/reference/parser768531.symbols delete mode 100644 tests/baselines/reference/parser768531.types create mode 100644 tests/baselines/reference/parser_breakTarget3.errors.txt delete mode 100644 tests/baselines/reference/parser_breakTarget3.symbols delete mode 100644 tests/baselines/reference/parser_breakTarget3.types create mode 100644 tests/baselines/reference/parser_breakTarget4.errors.txt delete mode 100644 tests/baselines/reference/parser_breakTarget4.symbols delete mode 100644 tests/baselines/reference/parser_breakTarget4.types create mode 100644 tests/baselines/reference/parser_continueTarget3.errors.txt delete mode 100644 tests/baselines/reference/parser_continueTarget3.symbols delete mode 100644 tests/baselines/reference/parser_continueTarget3.types create mode 100644 tests/baselines/reference/parser_continueTarget4.errors.txt delete mode 100644 tests/baselines/reference/parser_continueTarget4.symbols delete mode 100644 tests/baselines/reference/parser_continueTarget4.types create mode 100644 tests/baselines/reference/parser_duplicateLabel3.errors.txt delete mode 100644 tests/baselines/reference/parser_duplicateLabel3.symbols delete mode 100644 tests/baselines/reference/parser_duplicateLabel3.types create mode 100644 tests/baselines/reference/parser_duplicateLabel4.errors.txt delete mode 100644 tests/baselines/reference/parser_duplicateLabel4.symbols delete mode 100644 tests/baselines/reference/parser_duplicateLabel4.types create mode 100644 tests/baselines/reference/recursiveMods.errors.txt delete mode 100644 tests/baselines/reference/recursiveMods.symbols delete mode 100644 tests/baselines/reference/recursiveMods.types create mode 100644 tests/baselines/reference/returnStatement1.errors.txt delete mode 100644 tests/baselines/reference/returnStatement1.symbols delete mode 100644 tests/baselines/reference/returnStatement1.types create mode 100644 tests/baselines/reference/sourceMapValidationLabeled.errors.txt delete mode 100644 tests/baselines/reference/sourceMapValidationLabeled.symbols delete mode 100644 tests/baselines/reference/sourceMapValidationLabeled.types create mode 100644 tests/baselines/reference/switchBreakStatements.errors.txt delete mode 100644 tests/baselines/reference/switchBreakStatements.symbols delete mode 100644 tests/baselines/reference/switchBreakStatements.types create mode 100644 tests/baselines/reference/systemModule8.errors.txt delete mode 100644 tests/baselines/reference/systemModule8.symbols delete mode 100644 tests/baselines/reference/systemModule8.types create mode 100644 tests/baselines/reference/throwInEnclosingStatements.errors.txt delete mode 100644 tests/baselines/reference/throwInEnclosingStatements.symbols delete mode 100644 tests/baselines/reference/throwInEnclosingStatements.types create mode 100644 tests/baselines/reference/throwStatements.errors.txt delete mode 100644 tests/baselines/reference/throwStatements.symbols delete mode 100644 tests/baselines/reference/throwStatements.types create mode 100644 tests/baselines/reference/typeofOperatorWithBooleanType.errors.txt delete mode 100644 tests/baselines/reference/typeofOperatorWithBooleanType.symbols delete mode 100644 tests/baselines/reference/typeofOperatorWithBooleanType.types create mode 100644 tests/baselines/reference/typeofOperatorWithEnumType.errors.txt delete mode 100644 tests/baselines/reference/typeofOperatorWithEnumType.symbols delete mode 100644 tests/baselines/reference/typeofOperatorWithEnumType.types create mode 100644 tests/baselines/reference/typeofOperatorWithNumberType.errors.txt delete mode 100644 tests/baselines/reference/typeofOperatorWithNumberType.symbols delete mode 100644 tests/baselines/reference/typeofOperatorWithNumberType.types create mode 100644 tests/baselines/reference/typeofOperatorWithStringType.errors.txt delete mode 100644 tests/baselines/reference/typeofOperatorWithStringType.symbols delete mode 100644 tests/baselines/reference/typeofOperatorWithStringType.types create mode 100644 tests/baselines/reference/validMultipleVariableDeclarations.errors.txt delete mode 100644 tests/baselines/reference/validMultipleVariableDeclarations.symbols delete mode 100644 tests/baselines/reference/validMultipleVariableDeclarations.types create mode 100644 tests/baselines/reference/whileBreakStatements.errors.txt delete mode 100644 tests/baselines/reference/whileBreakStatements.symbols delete mode 100644 tests/baselines/reference/whileBreakStatements.types create mode 100644 tests/baselines/reference/whileContinueStatements.errors.txt delete mode 100644 tests/baselines/reference/whileContinueStatements.symbols delete mode 100644 tests/baselines/reference/whileContinueStatements.types diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index 8211509f580..9414b93de3f 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -557,14 +557,11 @@ namespace ts { function bindBreakOrContinueStatement(n: BreakOrContinueStatement): boolean { // call bind on label (don't affect reachability) bind(n.label); - if (n.kind === SyntaxKind.BreakStatement) { - jumpToLabel(n.label, currentReachabilityState); + // for continue case touch label so it will be marked a used + const isValidJump = jumpToLabel(n.label, n.kind === SyntaxKind.BreakStatement ? currentReachabilityState : Reachability.Unreachable); + if (isValidJump) { + currentReachabilityState = Reachability.Unreachable; } - else { - jumpToLabel(n.label, Reachability.Unreachable); // touch label so it will be marked a used - } - currentReachabilityState = Reachability.Unreachable; - return true; } @@ -1406,7 +1403,7 @@ namespace ts { initializeReachabilityStateIfNecessary(); if (innerMergedState === Reachability.Unintialized) { - if (label && options.noUnusedLabels) { + if (label && !options.allowUnusedLabels) { file.bindDiagnostics.push(createDiagnosticForNode(label, Diagnostics.Unused_label)); } currentReachabilityState = outerState; @@ -1416,17 +1413,18 @@ namespace ts { } } - function jumpToLabel(label: Identifier, outerState: Reachability): void { + function jumpToLabel(label: Identifier, outerState: Reachability): boolean { initializeReachabilityStateIfNecessary(); const index = label ? labelIndexMap[label.text] : lastOrUndefined(implicitLabels); if (index === undefined) { // reference to unknown label or // break/continue used outside of loops - return; + return false; } const stateAtLabel = labelStack[index]; labelStack[index] = stateAtLabel === Reachability.Unintialized ? outerState : or(stateAtLabel, outerState); + return true; } function checkUnreachable(node: Node): boolean { @@ -1455,7 +1453,7 @@ namespace ts { // 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.noUnreachableCode && + !options.allowUnreachableCode && !isInAmbientContext(node) && ( node.kind !== SyntaxKind.VariableStatement || @@ -1464,7 +1462,7 @@ namespace ts { ); if (reportUnreachableCode) { - file.bindDiagnostics.push(createDiagnosticForNode(node, Diagnostics.Unreachable_code_detected)); + errorOnFirstToken(node, Diagnostics.Unreachable_code_detected); } } case Reachability.ReportedUnreachable: diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index a159604c099..e9919d31008 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -248,9 +248,9 @@ namespace ts { error: Diagnostics.Argument_for_moduleResolution_option_must_be_node_or_classic, }, { - name: "noUnusedLabels", + name: "allowUnusedLabels", type: "boolean", - description: Diagnostics.Report_error_on_unused_labels + description: Diagnostics.Do_not_report_errors_on_unused_labels }, { name: "noImplicitReturns", @@ -263,9 +263,9 @@ namespace ts { description: Diagnostics.Report_errors_for_fallthrough_cases_in_switch_statement }, { - name: "noUnreachableCode", + name: "allowUnreachableCode", type: "boolean", - description: Diagnostics.Report_errors_on_unreachable_code + description: Diagnostics.Do_not_report_errors_on_unreachable_code } ]; diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 2917d333138..3552fec1226 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -2302,7 +2302,7 @@ "category": "Message", "code": 6072 }, - "Report error on unused labels.": { + "Do not report errors on unused labels.": { "category": "Message", "code": 6073 }, @@ -2314,7 +2314,7 @@ "category": "Message", "code": 6075 }, - "Report errors on unreachable code.": { + "Do not report errors on unreachable code.": { "category": "Message", "code": 6076 }, diff --git a/src/compiler/types.ts b/src/compiler/types.ts index a93a4587c1b..efc510d2f14 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -2075,10 +2075,10 @@ namespace ts { experimentalAsyncFunctions?: boolean; emitDecoratorMetadata?: boolean; moduleResolution?: ModuleResolutionKind; - noUnusedLabels?: boolean; + allowUnusedLabels?: boolean; + allowUnreachableCode?: boolean; noImplicitReturns?: boolean; noFallthroughCasesInSwitch?: boolean; - noUnreachableCode?: boolean; /* @internal */ stripInternal?: boolean; // Skip checking lib.d.ts to help speed up tests. diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 452f59f0f03..06f71177447 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -1203,7 +1203,7 @@ namespace ts { case SyntaxKind.LabeledStatement: case SyntaxKind.ReturnStatement: case SyntaxKind.SwitchStatement: - case SyntaxKind.ThrowKeyword: + case SyntaxKind.ThrowStatement: case SyntaxKind.TryStatement: case SyntaxKind.VariableStatement: case SyntaxKind.WhileStatement: diff --git a/tests/baselines/reference/assignmentLHSIsValue.errors.txt b/tests/baselines/reference/assignmentLHSIsValue.errors.txt index cf747b44b3e..bf253df5e70 100644 --- a/tests/baselines/reference/assignmentLHSIsValue.errors.txt +++ b/tests/baselines/reference/assignmentLHSIsValue.errors.txt @@ -13,6 +13,7 @@ tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(2 tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(30,1): error TS2364: Invalid left-hand side of assignment expression. tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(31,1): error TS2364: Invalid left-hand side of assignment expression. tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(32,1): error TS2364: Invalid left-hand side of assignment expression. +tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(35,3): error TS7028: Unused label. tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(35,9): error TS1128: Declaration or statement expected. tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(38,2): error TS2364: Invalid left-hand side of assignment expression. tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(38,6): error TS2364: Invalid left-hand side of assignment expression. @@ -38,7 +39,7 @@ tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(6 tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(70,1): error TS2364: Invalid left-hand side of assignment expression. -==== tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts (38 errors) ==== +==== tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts (39 errors) ==== // expected error for all the LHS of assignments var value; @@ -104,6 +105,8 @@ tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(7 // object literals { a: 0} = value; + ~ +!!! error TS7028: Unused label. ~ !!! error TS1128: Declaration or statement expected. diff --git a/tests/baselines/reference/bestCommonTypeReturnStatement.errors.txt b/tests/baselines/reference/bestCommonTypeReturnStatement.errors.txt new file mode 100644 index 00000000000..af83d53a722 --- /dev/null +++ b/tests/baselines/reference/bestCommonTypeReturnStatement.errors.txt @@ -0,0 +1,18 @@ +tests/cases/compiler/bestCommonTypeReturnStatement.ts(7,5): error TS7027: Unreachable code detected. + + +==== tests/cases/compiler/bestCommonTypeReturnStatement.ts (1 errors) ==== + interface IPromise { + then(successCallback: (promiseValue: T) => any, errorCallback?: (reason: any) => any): IPromise; + } + + function f() { + if (true) return b(); + return d(); + ~~~~~~ +!!! error TS7027: Unreachable code detected. + } + + + function b(): IPromise { return null; } + function d(): IPromise { return null; } \ No newline at end of file diff --git a/tests/baselines/reference/bestCommonTypeReturnStatement.symbols b/tests/baselines/reference/bestCommonTypeReturnStatement.symbols deleted file mode 100644 index 43e04ef037d..00000000000 --- a/tests/baselines/reference/bestCommonTypeReturnStatement.symbols +++ /dev/null @@ -1,34 +0,0 @@ -=== tests/cases/compiler/bestCommonTypeReturnStatement.ts === -interface IPromise { ->IPromise : Symbol(IPromise, Decl(bestCommonTypeReturnStatement.ts, 0, 0)) ->T : Symbol(T, Decl(bestCommonTypeReturnStatement.ts, 0, 19)) - - then(successCallback: (promiseValue: T) => any, errorCallback?: (reason: any) => any): IPromise; ->then : Symbol(then, Decl(bestCommonTypeReturnStatement.ts, 0, 23)) ->successCallback : Symbol(successCallback, Decl(bestCommonTypeReturnStatement.ts, 1, 9)) ->promiseValue : Symbol(promiseValue, Decl(bestCommonTypeReturnStatement.ts, 1, 27)) ->T : Symbol(T, Decl(bestCommonTypeReturnStatement.ts, 0, 19)) ->errorCallback : Symbol(errorCallback, Decl(bestCommonTypeReturnStatement.ts, 1, 51)) ->reason : Symbol(reason, Decl(bestCommonTypeReturnStatement.ts, 1, 69)) ->IPromise : Symbol(IPromise, Decl(bestCommonTypeReturnStatement.ts, 0, 0)) -} - -function f() { ->f : Symbol(f, Decl(bestCommonTypeReturnStatement.ts, 2, 1)) - - if (true) return b(); ->b : Symbol(b, Decl(bestCommonTypeReturnStatement.ts, 7, 1)) - - return d(); ->d : Symbol(d, Decl(bestCommonTypeReturnStatement.ts, 10, 45)) -} - - -function b(): IPromise { return null; } ->b : Symbol(b, Decl(bestCommonTypeReturnStatement.ts, 7, 1)) ->IPromise : Symbol(IPromise, Decl(bestCommonTypeReturnStatement.ts, 0, 0)) - -function d(): IPromise { return null; } ->d : Symbol(d, Decl(bestCommonTypeReturnStatement.ts, 10, 45)) ->IPromise : Symbol(IPromise, Decl(bestCommonTypeReturnStatement.ts, 0, 0)) - diff --git a/tests/baselines/reference/bestCommonTypeReturnStatement.types b/tests/baselines/reference/bestCommonTypeReturnStatement.types deleted file mode 100644 index 28974f064a5..00000000000 --- a/tests/baselines/reference/bestCommonTypeReturnStatement.types +++ /dev/null @@ -1,39 +0,0 @@ -=== tests/cases/compiler/bestCommonTypeReturnStatement.ts === -interface IPromise { ->IPromise : IPromise ->T : T - - then(successCallback: (promiseValue: T) => any, errorCallback?: (reason: any) => any): IPromise; ->then : (successCallback: (promiseValue: T) => any, errorCallback?: (reason: any) => any) => IPromise ->successCallback : (promiseValue: T) => any ->promiseValue : T ->T : T ->errorCallback : (reason: any) => any ->reason : any ->IPromise : IPromise -} - -function f() { ->f : () => IPromise - - if (true) return b(); ->true : boolean ->b() : IPromise ->b : () => IPromise - - return d(); ->d() : IPromise ->d : () => IPromise -} - - -function b(): IPromise { return null; } ->b : () => IPromise ->IPromise : IPromise ->null : null - -function d(): IPromise { return null; } ->d : () => IPromise ->IPromise : IPromise ->null : null - diff --git a/tests/baselines/reference/breakTarget3.errors.txt b/tests/baselines/reference/breakTarget3.errors.txt new file mode 100644 index 00000000000..aff8887c15e --- /dev/null +++ b/tests/baselines/reference/breakTarget3.errors.txt @@ -0,0 +1,11 @@ +tests/cases/compiler/breakTarget3.ts(2,1): error TS7028: Unused label. + + +==== tests/cases/compiler/breakTarget3.ts (1 errors) ==== + target1: + target2: + ~~~~~~~ +!!! error TS7028: Unused label. + while (true) { + break target1; + } \ No newline at end of file diff --git a/tests/baselines/reference/breakTarget3.symbols b/tests/baselines/reference/breakTarget3.symbols deleted file mode 100644 index 580706bbd4a..00000000000 --- a/tests/baselines/reference/breakTarget3.symbols +++ /dev/null @@ -1,7 +0,0 @@ -=== tests/cases/compiler/breakTarget3.ts === -target1: -No type information for this code.target2: -No type information for this code.while (true) { -No type information for this code. break target1; -No type information for this code.} -No type information for this code. \ No newline at end of file diff --git a/tests/baselines/reference/breakTarget3.types b/tests/baselines/reference/breakTarget3.types deleted file mode 100644 index 785bf00ef6e..00000000000 --- a/tests/baselines/reference/breakTarget3.types +++ /dev/null @@ -1,13 +0,0 @@ -=== tests/cases/compiler/breakTarget3.ts === -target1: ->target1 : any - -target2: ->target2 : any - -while (true) { ->true : boolean - - break target1; ->target1 : any -} diff --git a/tests/baselines/reference/breakTarget4.errors.txt b/tests/baselines/reference/breakTarget4.errors.txt new file mode 100644 index 00000000000..d1283de2fa0 --- /dev/null +++ b/tests/baselines/reference/breakTarget4.errors.txt @@ -0,0 +1,11 @@ +tests/cases/compiler/breakTarget4.ts(1,1): error TS7028: Unused label. + + +==== tests/cases/compiler/breakTarget4.ts (1 errors) ==== + target1: + ~~~~~~~ +!!! error TS7028: Unused label. + target2: + while (true) { + break target2; + } \ No newline at end of file diff --git a/tests/baselines/reference/breakTarget4.symbols b/tests/baselines/reference/breakTarget4.symbols deleted file mode 100644 index aba35ddcfdf..00000000000 --- a/tests/baselines/reference/breakTarget4.symbols +++ /dev/null @@ -1,7 +0,0 @@ -=== tests/cases/compiler/breakTarget4.ts === -target1: -No type information for this code.target2: -No type information for this code.while (true) { -No type information for this code. break target2; -No type information for this code.} -No type information for this code. \ No newline at end of file diff --git a/tests/baselines/reference/breakTarget4.types b/tests/baselines/reference/breakTarget4.types deleted file mode 100644 index eb4c14f6386..00000000000 --- a/tests/baselines/reference/breakTarget4.types +++ /dev/null @@ -1,13 +0,0 @@ -=== tests/cases/compiler/breakTarget4.ts === -target1: ->target1 : any - -target2: ->target2 : any - -while (true) { ->true : boolean - - break target2; ->target2 : any -} diff --git a/tests/baselines/reference/breakTarget5.errors.txt b/tests/baselines/reference/breakTarget5.errors.txt index a54a415b990..55a454ee68b 100644 --- a/tests/baselines/reference/breakTarget5.errors.txt +++ b/tests/baselines/reference/breakTarget5.errors.txt @@ -1,8 +1,11 @@ +tests/cases/compiler/breakTarget5.ts(1,1): error TS7028: Unused label. tests/cases/compiler/breakTarget5.ts(5,7): error TS1107: Jump target cannot cross function boundary. -==== tests/cases/compiler/breakTarget5.ts (1 errors) ==== +==== tests/cases/compiler/breakTarget5.ts (2 errors) ==== target: + ~~~~~~ +!!! error TS7028: Unused label. while (true) { function f() { while (true) { diff --git a/tests/baselines/reference/callSignatureWithoutReturnTypeAnnotationInference.errors.txt b/tests/baselines/reference/callSignatureWithoutReturnTypeAnnotationInference.errors.txt new file mode 100644 index 00000000000..06eca28b512 --- /dev/null +++ b/tests/baselines/reference/callSignatureWithoutReturnTypeAnnotationInference.errors.txt @@ -0,0 +1,126 @@ +tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignatureWithoutReturnTypeAnnotationInference.ts(28,9): error TS7027: Unreachable code detected. + + +==== tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignatureWithoutReturnTypeAnnotationInference.ts (1 errors) ==== + // Call signatures without a return type should infer one from the function body (if present) + + // Simple types + function foo(x) { + return 1; + } + var r = foo(1); + + function foo2(x) { + return foo(x); + } + var r2 = foo2(1); + + function foo3() { + return foo3(); + } + var r3 = foo3(); + + function foo4(x: T) { + return x; + } + var r4 = foo4(1); + + function foo5(x) { + if (true) { + return 1; + } else { + return 2; + ~~~~~~ +!!! error TS7027: Unreachable code detected. + } + } + var r5 = foo5(1); + + function foo6(x) { + try { + } + catch (e) { + return []; + } + finally { + return []; + } + } + var r6 = foo6(1); + + function foo7(x) { + return typeof x; + } + var r7 = foo7(1); + + // object types + function foo8(x: number) { + return { x: x }; + } + var r8 = foo8(1); + + interface I { + foo: string; + } + function foo9(x: number) { + var i: I; + return i; + } + var r9 = foo9(1); + + class C { + foo: string; + } + function foo10(x: number) { + var c: C; + return c; + } + var r10 = foo10(1); + + module M { + export var x = 1; + export class C { foo: string } + } + function foo11() { + return M; + } + var r11 = foo11(); + + // merged declarations + interface I2 { + x: number; + } + interface I2 { + y: number; + } + function foo12() { + var i2: I2; + return i2; + } + var r12 = foo12(); + + function m1() { return 1; } + module m1 { export var y = 2; } + function foo13() { + return m1; + } + var r13 = foo13(); + + class c1 { + foo: string; + constructor(x) { } + } + module c1 { + export var x = 1; + } + function foo14() { + return c1; + } + var r14 = foo14(); + + enum e1 { A } + module e1 { export var y = 1; } + function foo15() { + return e1; + } + var r15 = foo15(); \ No newline at end of file diff --git a/tests/baselines/reference/callSignatureWithoutReturnTypeAnnotationInference.symbols b/tests/baselines/reference/callSignatureWithoutReturnTypeAnnotationInference.symbols deleted file mode 100644 index 1c5a6786ab7..00000000000 --- a/tests/baselines/reference/callSignatureWithoutReturnTypeAnnotationInference.symbols +++ /dev/null @@ -1,255 +0,0 @@ -=== tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignatureWithoutReturnTypeAnnotationInference.ts === -// Call signatures without a return type should infer one from the function body (if present) - -// Simple types -function foo(x) { ->foo : Symbol(foo, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 0, 0)) ->x : Symbol(x, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 3, 13)) - - return 1; -} -var r = foo(1); ->r : Symbol(r, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 6, 3)) ->foo : Symbol(foo, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 0, 0)) - -function foo2(x) { ->foo2 : Symbol(foo2, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 6, 15)) ->x : Symbol(x, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 8, 14)) - - return foo(x); ->foo : Symbol(foo, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 0, 0)) ->x : Symbol(x, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 8, 14)) -} -var r2 = foo2(1); ->r2 : Symbol(r2, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 11, 3)) ->foo2 : Symbol(foo2, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 6, 15)) - -function foo3() { ->foo3 : Symbol(foo3, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 11, 17)) - - return foo3(); ->foo3 : Symbol(foo3, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 11, 17)) -} -var r3 = foo3(); ->r3 : Symbol(r3, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 16, 3)) ->foo3 : Symbol(foo3, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 11, 17)) - -function foo4(x: T) { ->foo4 : Symbol(foo4, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 16, 16)) ->T : Symbol(T, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 18, 14)) ->x : Symbol(x, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 18, 17)) ->T : Symbol(T, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 18, 14)) - - return x; ->x : Symbol(x, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 18, 17)) -} -var r4 = foo4(1); ->r4 : Symbol(r4, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 21, 3)) ->foo4 : Symbol(foo4, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 16, 16)) - -function foo5(x) { ->foo5 : Symbol(foo5, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 21, 17)) ->x : Symbol(x, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 23, 14)) - - if (true) { - return 1; - } else { - return 2; - } -} -var r5 = foo5(1); ->r5 : Symbol(r5, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 30, 3)) ->foo5 : Symbol(foo5, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 21, 17)) - -function foo6(x) { ->foo6 : Symbol(foo6, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 30, 17)) ->x : Symbol(x, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 32, 14)) - - try { - } - catch (e) { ->e : Symbol(e, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 35, 11)) - - return []; - } - finally { - return []; - } -} -var r6 = foo6(1); ->r6 : Symbol(r6, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 42, 3)) ->foo6 : Symbol(foo6, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 30, 17)) - -function foo7(x) { ->foo7 : Symbol(foo7, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 42, 17)) ->x : Symbol(x, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 44, 14)) - - return typeof x; ->x : Symbol(x, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 44, 14)) -} -var r7 = foo7(1); ->r7 : Symbol(r7, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 47, 3)) ->foo7 : Symbol(foo7, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 42, 17)) - -// object types -function foo8(x: number) { ->foo8 : Symbol(foo8, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 47, 17)) ->x : Symbol(x, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 50, 14)) - - return { x: x }; ->x : Symbol(x, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 51, 12)) ->x : Symbol(x, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 50, 14)) -} -var r8 = foo8(1); ->r8 : Symbol(r8, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 53, 3)) ->foo8 : Symbol(foo8, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 47, 17)) - -interface I { ->I : Symbol(I, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 53, 17)) - - foo: string; ->foo : Symbol(foo, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 55, 13)) -} -function foo9(x: number) { ->foo9 : Symbol(foo9, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 57, 1)) ->x : Symbol(x, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 58, 14)) - - var i: I; ->i : Symbol(i, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 59, 7)) ->I : Symbol(I, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 53, 17)) - - return i; ->i : Symbol(i, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 59, 7)) -} -var r9 = foo9(1); ->r9 : Symbol(r9, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 62, 3)) ->foo9 : Symbol(foo9, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 57, 1)) - -class C { ->C : Symbol(C, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 62, 17)) - - foo: string; ->foo : Symbol(foo, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 64, 9)) -} -function foo10(x: number) { ->foo10 : Symbol(foo10, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 66, 1)) ->x : Symbol(x, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 67, 15)) - - var c: C; ->c : Symbol(c, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 68, 7)) ->C : Symbol(C, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 62, 17)) - - return c; ->c : Symbol(c, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 68, 7)) -} -var r10 = foo10(1); ->r10 : Symbol(r10, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 71, 3)) ->foo10 : Symbol(foo10, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 66, 1)) - -module M { ->M : Symbol(M, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 71, 19)) - - export var x = 1; ->x : Symbol(x, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 74, 14)) - - export class C { foo: string } ->C : Symbol(C, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 74, 21)) ->foo : Symbol(foo, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 75, 20)) -} -function foo11() { ->foo11 : Symbol(foo11, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 76, 1)) - - return M; ->M : Symbol(M, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 71, 19)) -} -var r11 = foo11(); ->r11 : Symbol(r11, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 80, 3)) ->foo11 : Symbol(foo11, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 76, 1)) - -// merged declarations -interface I2 { ->I2 : Symbol(I2, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 80, 18), Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 85, 1)) - - x: number; ->x : Symbol(x, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 83, 14)) -} -interface I2 { ->I2 : Symbol(I2, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 80, 18), Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 85, 1)) - - y: number; ->y : Symbol(y, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 86, 14)) -} -function foo12() { ->foo12 : Symbol(foo12, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 88, 1)) - - var i2: I2; ->i2 : Symbol(i2, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 90, 7)) ->I2 : Symbol(I2, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 80, 18), Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 85, 1)) - - return i2; ->i2 : Symbol(i2, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 90, 7)) -} -var r12 = foo12(); ->r12 : Symbol(r12, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 93, 3)) ->foo12 : Symbol(foo12, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 88, 1)) - -function m1() { return 1; } ->m1 : Symbol(m1, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 93, 18), Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 95, 27)) - -module m1 { export var y = 2; } ->m1 : Symbol(m1, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 93, 18), Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 95, 27)) ->y : Symbol(y, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 96, 22)) - -function foo13() { ->foo13 : Symbol(foo13, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 96, 31)) - - return m1; ->m1 : Symbol(m1, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 93, 18), Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 95, 27)) -} -var r13 = foo13(); ->r13 : Symbol(r13, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 100, 3)) ->foo13 : Symbol(foo13, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 96, 31)) - -class c1 { ->c1 : Symbol(c1, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 100, 18), Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 105, 1)) - - foo: string; ->foo : Symbol(foo, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 102, 10)) - - constructor(x) { } ->x : Symbol(x, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 104, 16)) -} -module c1 { ->c1 : Symbol(c1, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 100, 18), Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 105, 1)) - - export var x = 1; ->x : Symbol(x, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 107, 14)) -} -function foo14() { ->foo14 : Symbol(foo14, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 108, 1)) - - return c1; ->c1 : Symbol(c1, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 100, 18), Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 105, 1)) -} -var r14 = foo14(); ->r14 : Symbol(r14, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 112, 3)) ->foo14 : Symbol(foo14, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 108, 1)) - -enum e1 { A } ->e1 : Symbol(e1, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 112, 18), Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 114, 13)) ->A : Symbol(e1.A, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 114, 9)) - -module e1 { export var y = 1; } ->e1 : Symbol(e1, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 112, 18), Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 114, 13)) ->y : Symbol(y, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 115, 22)) - -function foo15() { ->foo15 : Symbol(foo15, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 115, 31)) - - return e1; ->e1 : Symbol(e1, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 112, 18), Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 114, 13)) -} -var r15 = foo15(); ->r15 : Symbol(r15, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 119, 3)) ->foo15 : Symbol(foo15, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 115, 31)) - diff --git a/tests/baselines/reference/callSignatureWithoutReturnTypeAnnotationInference.types b/tests/baselines/reference/callSignatureWithoutReturnTypeAnnotationInference.types deleted file mode 100644 index 760451eb9c1..00000000000 --- a/tests/baselines/reference/callSignatureWithoutReturnTypeAnnotationInference.types +++ /dev/null @@ -1,296 +0,0 @@ -=== tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignatureWithoutReturnTypeAnnotationInference.ts === -// Call signatures without a return type should infer one from the function body (if present) - -// Simple types -function foo(x) { ->foo : (x: any) => number ->x : any - - return 1; ->1 : number -} -var r = foo(1); ->r : number ->foo(1) : number ->foo : (x: any) => number ->1 : number - -function foo2(x) { ->foo2 : (x: any) => number ->x : any - - return foo(x); ->foo(x) : number ->foo : (x: any) => number ->x : any -} -var r2 = foo2(1); ->r2 : number ->foo2(1) : number ->foo2 : (x: any) => number ->1 : number - -function foo3() { ->foo3 : () => any - - return foo3(); ->foo3() : any ->foo3 : () => any -} -var r3 = foo3(); ->r3 : any ->foo3() : any ->foo3 : () => any - -function foo4(x: T) { ->foo4 : (x: T) => T ->T : T ->x : T ->T : T - - return x; ->x : T -} -var r4 = foo4(1); ->r4 : number ->foo4(1) : number ->foo4 : (x: T) => T ->1 : number - -function foo5(x) { ->foo5 : (x: any) => number ->x : any - - if (true) { ->true : boolean - - return 1; ->1 : number - - } else { - return 2; ->2 : number - } -} -var r5 = foo5(1); ->r5 : number ->foo5(1) : number ->foo5 : (x: any) => number ->1 : number - -function foo6(x) { ->foo6 : (x: any) => any[] ->x : any - - try { - } - catch (e) { ->e : any - - return []; ->[] : undefined[] - } - finally { - return []; ->[] : undefined[] - } -} -var r6 = foo6(1); ->r6 : any[] ->foo6(1) : any[] ->foo6 : (x: any) => any[] ->1 : number - -function foo7(x) { ->foo7 : (x: any) => string ->x : any - - return typeof x; ->typeof x : string ->x : any -} -var r7 = foo7(1); ->r7 : string ->foo7(1) : string ->foo7 : (x: any) => string ->1 : number - -// object types -function foo8(x: number) { ->foo8 : (x: number) => { x: number; } ->x : number - - return { x: x }; ->{ x: x } : { x: number; } ->x : number ->x : number -} -var r8 = foo8(1); ->r8 : { x: number; } ->foo8(1) : { x: number; } ->foo8 : (x: number) => { x: number; } ->1 : number - -interface I { ->I : I - - foo: string; ->foo : string -} -function foo9(x: number) { ->foo9 : (x: number) => I ->x : number - - var i: I; ->i : I ->I : I - - return i; ->i : I -} -var r9 = foo9(1); ->r9 : I ->foo9(1) : I ->foo9 : (x: number) => I ->1 : number - -class C { ->C : C - - foo: string; ->foo : string -} -function foo10(x: number) { ->foo10 : (x: number) => C ->x : number - - var c: C; ->c : C ->C : C - - return c; ->c : C -} -var r10 = foo10(1); ->r10 : C ->foo10(1) : C ->foo10 : (x: number) => C ->1 : number - -module M { ->M : typeof M - - export var x = 1; ->x : number ->1 : number - - export class C { foo: string } ->C : C ->foo : string -} -function foo11() { ->foo11 : () => typeof M - - return M; ->M : typeof M -} -var r11 = foo11(); ->r11 : typeof M ->foo11() : typeof M ->foo11 : () => typeof M - -// merged declarations -interface I2 { ->I2 : I2 - - x: number; ->x : number -} -interface I2 { ->I2 : I2 - - y: number; ->y : number -} -function foo12() { ->foo12 : () => I2 - - var i2: I2; ->i2 : I2 ->I2 : I2 - - return i2; ->i2 : I2 -} -var r12 = foo12(); ->r12 : I2 ->foo12() : I2 ->foo12 : () => I2 - -function m1() { return 1; } ->m1 : typeof m1 ->1 : number - -module m1 { export var y = 2; } ->m1 : typeof m1 ->y : number ->2 : number - -function foo13() { ->foo13 : () => typeof m1 - - return m1; ->m1 : typeof m1 -} -var r13 = foo13(); ->r13 : typeof m1 ->foo13() : typeof m1 ->foo13 : () => typeof m1 - -class c1 { ->c1 : c1 - - foo: string; ->foo : string - - constructor(x) { } ->x : any -} -module c1 { ->c1 : typeof c1 - - export var x = 1; ->x : number ->1 : number -} -function foo14() { ->foo14 : () => typeof c1 - - return c1; ->c1 : typeof c1 -} -var r14 = foo14(); ->r14 : typeof c1 ->foo14() : typeof c1 ->foo14 : () => typeof c1 - -enum e1 { A } ->e1 : e1 ->A : e1 - -module e1 { export var y = 1; } ->e1 : typeof e1 ->y : number ->1 : number - -function foo15() { ->foo15 : () => typeof e1 - - return e1; ->e1 : typeof e1 -} -var r15 = foo15(); ->r15 : typeof e1 ->foo15() : typeof e1 ->foo15 : () => typeof e1 - diff --git a/tests/baselines/reference/cf.errors.txt b/tests/baselines/reference/cf.errors.txt new file mode 100644 index 00000000000..75b285c37c6 --- /dev/null +++ b/tests/baselines/reference/cf.errors.txt @@ -0,0 +1,72 @@ +tests/cases/compiler/cf.ts(9,13): error TS7027: Unreachable code detected. +tests/cases/compiler/cf.ts(21,17): error TS7027: Unreachable code detected. +tests/cases/compiler/cf.ts(32,13): error TS7027: Unreachable code detected. +tests/cases/compiler/cf.ts(36,13): error TS7027: Unreachable code detected. + + +==== tests/cases/compiler/cf.ts (4 errors) ==== + function f() { + var z; + var x=10; + var y=3; + + L1: for (var i=0;i<19;i++) { + if (y==7) { + continue L1; + x=11; + ~ +!!! error TS7027: Unreachable code detected. + } + if (y==3) { + y++; + } + else { + y--; + } + do { + y+=2; + if (y==20) { + break; + x=12; + ~ +!!! error TS7027: Unreachable code detected. + } + } while (y<41); + y++; + } + while (y>2) { + y=y>>1; + } + L2: try { + L3: if (xf : Symbol(f, Decl(cf.ts, 0, 0)) - - var z; ->z : Symbol(z, Decl(cf.ts, 1, 7)) - - var x=10; ->x : Symbol(x, Decl(cf.ts, 2, 7)) - - var y=3; ->y : Symbol(y, Decl(cf.ts, 3, 7)) - - L1: for (var i=0;i<19;i++) { ->i : Symbol(i, Decl(cf.ts, 5, 16)) ->i : Symbol(i, Decl(cf.ts, 5, 16)) ->i : Symbol(i, Decl(cf.ts, 5, 16)) - - if (y==7) { ->y : Symbol(y, Decl(cf.ts, 3, 7)) - - continue L1; - x=11; ->x : Symbol(x, Decl(cf.ts, 2, 7)) - } - if (y==3) { ->y : Symbol(y, Decl(cf.ts, 3, 7)) - - y++; ->y : Symbol(y, Decl(cf.ts, 3, 7)) - } - else { - y--; ->y : Symbol(y, Decl(cf.ts, 3, 7)) - } - do { - y+=2; ->y : Symbol(y, Decl(cf.ts, 3, 7)) - - if (y==20) { ->y : Symbol(y, Decl(cf.ts, 3, 7)) - - break; - x=12; ->x : Symbol(x, Decl(cf.ts, 2, 7)) - } - } while (y<41); ->y : Symbol(y, Decl(cf.ts, 3, 7)) - - y++; ->y : Symbol(y, Decl(cf.ts, 3, 7)) - } - while (y>2) { ->y : Symbol(y, Decl(cf.ts, 3, 7)) - - y=y>>1; ->y : Symbol(y, Decl(cf.ts, 3, 7)) ->y : Symbol(y, Decl(cf.ts, 3, 7)) - } - L2: try { - L3: if (xx : Symbol(x, Decl(cf.ts, 2, 7)) ->y : Symbol(y, Decl(cf.ts, 3, 7)) - - break L2; - x=13; ->x : Symbol(x, Decl(cf.ts, 2, 7)) - } - else { - break L3; - x=14; ->x : Symbol(x, Decl(cf.ts, 2, 7)) - } - } - catch (e) { ->e : Symbol(e, Decl(cf.ts, 38, 11)) - - x++; ->x : Symbol(x, Decl(cf.ts, 2, 7)) - } - finally { - x+=3; ->x : Symbol(x, Decl(cf.ts, 2, 7)) - } - y++; ->y : Symbol(y, Decl(cf.ts, 3, 7)) - - for (var k=0;k<10;k++) { ->k : Symbol(k, Decl(cf.ts, 45, 12)) ->k : Symbol(k, Decl(cf.ts, 45, 12)) ->k : Symbol(k, Decl(cf.ts, 45, 12)) - - z; ->z : Symbol(z, Decl(cf.ts, 1, 7)) - - break; - } - for (k=0;k<10;k++) { ->k : Symbol(k, Decl(cf.ts, 45, 12)) ->k : Symbol(k, Decl(cf.ts, 45, 12)) ->k : Symbol(k, Decl(cf.ts, 45, 12)) - - if (k==6) { ->k : Symbol(k, Decl(cf.ts, 45, 12)) - - continue; - } - break; - } -} - diff --git a/tests/baselines/reference/cf.types b/tests/baselines/reference/cf.types deleted file mode 100644 index 397e3469ece..00000000000 --- a/tests/baselines/reference/cf.types +++ /dev/null @@ -1,169 +0,0 @@ -=== tests/cases/compiler/cf.ts === -function f() { ->f : () => void - - var z; ->z : any - - var x=10; ->x : number ->10 : number - - var y=3; ->y : number ->3 : number - - L1: for (var i=0;i<19;i++) { ->L1 : any ->i : number ->0 : number ->i<19 : boolean ->i : number ->19 : number ->i++ : number ->i : number - - if (y==7) { ->y==7 : boolean ->y : number ->7 : number - - continue L1; ->L1 : any - - x=11; ->x=11 : number ->x : number ->11 : number - } - if (y==3) { ->y==3 : boolean ->y : number ->3 : number - - y++; ->y++ : number ->y : number - } - else { - y--; ->y-- : number ->y : number - } - do { - y+=2; ->y+=2 : number ->y : number ->2 : number - - if (y==20) { ->y==20 : boolean ->y : number ->20 : number - - break; - x=12; ->x=12 : number ->x : number ->12 : number - } - } while (y<41); ->y<41 : boolean ->y : number ->41 : number - - y++; ->y++ : number ->y : number - } - while (y>2) { ->y>2 : boolean ->y : number ->2 : number - - y=y>>1; ->y=y>>1 : number ->y : number ->y>>1 : number ->y : number ->1 : number - } - L2: try { ->L2 : any - - L3: if (xL3 : any ->xx : number ->y : number - - break L2; ->L2 : any - - x=13; ->x=13 : number ->x : number ->13 : number - } - else { - break L3; ->L3 : any - - x=14; ->x=14 : number ->x : number ->14 : number - } - } - catch (e) { ->e : any - - x++; ->x++ : number ->x : number - } - finally { - x+=3; ->x+=3 : number ->x : number ->3 : number - } - y++; ->y++ : number ->y : number - - for (var k=0;k<10;k++) { ->k : number ->0 : number ->k<10 : boolean ->k : number ->10 : number ->k++ : number ->k : number - - z; ->z : any - - break; - } - for (k=0;k<10;k++) { ->k=0 : number ->k : number ->0 : number ->k<10 : boolean ->k : number ->10 : number ->k++ : number ->k : number - - if (k==6) { ->k==6 : boolean ->k : number ->6 : number - - continue; - } - break; - } -} - diff --git a/tests/baselines/reference/commentsAtEndOfFile1.errors.txt b/tests/baselines/reference/commentsAtEndOfFile1.errors.txt new file mode 100644 index 00000000000..dd689841659 --- /dev/null +++ b/tests/baselines/reference/commentsAtEndOfFile1.errors.txt @@ -0,0 +1,10 @@ +tests/cases/compiler/commentsAtEndOfFile1.ts(1,1): error TS7028: Unused label. + + +==== tests/cases/compiler/commentsAtEndOfFile1.ts (1 errors) ==== + Input: + ~~~~~ +!!! error TS7028: Unused label. + ; + //Testing two + \ No newline at end of file diff --git a/tests/baselines/reference/commentsAtEndOfFile1.symbols b/tests/baselines/reference/commentsAtEndOfFile1.symbols deleted file mode 100644 index c09a435f1a7..00000000000 --- a/tests/baselines/reference/commentsAtEndOfFile1.symbols +++ /dev/null @@ -1,6 +0,0 @@ -=== tests/cases/compiler/commentsAtEndOfFile1.ts === -Input: -No type information for this code.; -No type information for this code.//Testing two -No type information for this code. -No type information for this code. \ No newline at end of file diff --git a/tests/baselines/reference/commentsAtEndOfFile1.types b/tests/baselines/reference/commentsAtEndOfFile1.types deleted file mode 100644 index 6bac6757061..00000000000 --- a/tests/baselines/reference/commentsAtEndOfFile1.types +++ /dev/null @@ -1,7 +0,0 @@ -=== tests/cases/compiler/commentsAtEndOfFile1.ts === -Input: ->Input : any - -; -//Testing two - diff --git a/tests/baselines/reference/compoundAssignmentLHSIsValue.errors.txt b/tests/baselines/reference/compoundAssignmentLHSIsValue.errors.txt index 7b26fc4bf9e..645e34bcfa7 100644 --- a/tests/baselines/reference/compoundAssignmentLHSIsValue.errors.txt +++ b/tests/baselines/reference/compoundAssignmentLHSIsValue.errors.txt @@ -28,6 +28,7 @@ tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsVa tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(53,1): error TS2364: Invalid left-hand side of assignment expression. tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(54,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(55,1): error TS2364: Invalid left-hand side of assignment expression. +tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(58,3): error TS7028: Unused label. tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(58,9): error TS1128: Declaration or statement expected. tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(59,9): error TS1128: Declaration or statement expected. tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(62,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. @@ -74,7 +75,7 @@ tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsVa tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(122,1): error TS2364: Invalid left-hand side of assignment expression. -==== tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts (74 errors) ==== +==== tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts (75 errors) ==== // expected error for all the LHS of compound assignments (arithmetic and addition) var value; @@ -193,6 +194,8 @@ tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsVa // object literals { a: 0} *= value; + ~ +!!! error TS7028: Unused label. ~~ !!! error TS1128: Declaration or statement expected. { a: 0} += value; diff --git a/tests/baselines/reference/conditionalExpressions2.errors.txt b/tests/baselines/reference/conditionalExpressions2.errors.txt new file mode 100644 index 00000000000..3fb44a840b3 --- /dev/null +++ b/tests/baselines/reference/conditionalExpressions2.errors.txt @@ -0,0 +1,15 @@ +tests/cases/compiler/conditionalExpressions2.ts(9,54): error TS7027: Unreachable code detected. + + +==== tests/cases/compiler/conditionalExpressions2.ts (1 errors) ==== + var a = false ? 1 : null; + var b = false ? undefined : 0; + var c = false ? 1 : 0; + var d = false ? false : true; + var e = false ? "foo" : "bar"; + var f = false ? null : undefined; + var g = true ? {g:5} : null; + var h = [{h:5}, null]; + function i() { if (true) { return { x: 5 }; } else { return null; } } + ~~~~~~ +!!! error TS7027: Unreachable code detected. \ No newline at end of file diff --git a/tests/baselines/reference/conditionalExpressions2.symbols b/tests/baselines/reference/conditionalExpressions2.symbols deleted file mode 100644 index 63c8b417477..00000000000 --- a/tests/baselines/reference/conditionalExpressions2.symbols +++ /dev/null @@ -1,33 +0,0 @@ -=== tests/cases/compiler/conditionalExpressions2.ts === -var a = false ? 1 : null; ->a : Symbol(a, Decl(conditionalExpressions2.ts, 0, 3)) - -var b = false ? undefined : 0; ->b : Symbol(b, Decl(conditionalExpressions2.ts, 1, 3)) ->undefined : Symbol(undefined) - -var c = false ? 1 : 0; ->c : Symbol(c, Decl(conditionalExpressions2.ts, 2, 3)) - -var d = false ? false : true; ->d : Symbol(d, Decl(conditionalExpressions2.ts, 3, 3)) - -var e = false ? "foo" : "bar"; ->e : Symbol(e, Decl(conditionalExpressions2.ts, 4, 3)) - -var f = false ? null : undefined; ->f : Symbol(f, Decl(conditionalExpressions2.ts, 5, 3)) ->undefined : Symbol(undefined) - -var g = true ? {g:5} : null; ->g : Symbol(g, Decl(conditionalExpressions2.ts, 6, 3)) ->g : Symbol(g, Decl(conditionalExpressions2.ts, 6, 16)) - -var h = [{h:5}, null]; ->h : Symbol(h, Decl(conditionalExpressions2.ts, 7, 3)) ->h : Symbol(h, Decl(conditionalExpressions2.ts, 7, 10)) - -function i() { if (true) { return { x: 5 }; } else { return null; } } ->i : Symbol(i, Decl(conditionalExpressions2.ts, 7, 22)) ->x : Symbol(x, Decl(conditionalExpressions2.ts, 8, 35)) - diff --git a/tests/baselines/reference/conditionalExpressions2.types b/tests/baselines/reference/conditionalExpressions2.types deleted file mode 100644 index 5f49410b1e4..00000000000 --- a/tests/baselines/reference/conditionalExpressions2.types +++ /dev/null @@ -1,68 +0,0 @@ -=== tests/cases/compiler/conditionalExpressions2.ts === -var a = false ? 1 : null; ->a : number ->false ? 1 : null : number ->false : boolean ->1 : number ->null : null - -var b = false ? undefined : 0; ->b : number ->false ? undefined : 0 : number ->false : boolean ->undefined : undefined ->0 : number - -var c = false ? 1 : 0; ->c : number ->false ? 1 : 0 : number ->false : boolean ->1 : number ->0 : number - -var d = false ? false : true; ->d : boolean ->false ? false : true : boolean ->false : boolean ->false : boolean ->true : boolean - -var e = false ? "foo" : "bar"; ->e : string ->false ? "foo" : "bar" : string ->false : boolean ->"foo" : string ->"bar" : string - -var f = false ? null : undefined; ->f : any ->false ? null : undefined : null ->false : boolean ->null : null ->undefined : undefined - -var g = true ? {g:5} : null; ->g : { g: number; } ->true ? {g:5} : null : { g: number; } ->true : boolean ->{g:5} : { g: number; } ->g : number ->5 : number ->null : null - -var h = [{h:5}, null]; ->h : { h: number; }[] ->[{h:5}, null] : { h: number; }[] ->{h:5} : { h: number; } ->h : number ->5 : number ->null : null - -function i() { if (true) { return { x: 5 }; } else { return null; } } ->i : () => { x: number; } ->true : boolean ->{ x: 5 } : { x: number; } ->x : number ->5 : number ->null : null - diff --git a/tests/baselines/reference/constDeclarations-invalidContexts.errors.txt b/tests/baselines/reference/constDeclarations-invalidContexts.errors.txt index 20ec5b0c25b..56273924ac1 100644 --- a/tests/baselines/reference/constDeclarations-invalidContexts.errors.txt +++ b/tests/baselines/reference/constDeclarations-invalidContexts.errors.txt @@ -1,6 +1,8 @@ tests/cases/compiler/constDeclarations-invalidContexts.ts(4,5): error TS1156: 'const' declarations can only be declared inside a block. +tests/cases/compiler/constDeclarations-invalidContexts.ts(6,5): error TS7027: Unreachable code detected. tests/cases/compiler/constDeclarations-invalidContexts.ts(6,5): error TS1156: 'const' declarations can only be declared inside a block. tests/cases/compiler/constDeclarations-invalidContexts.ts(9,5): error TS1156: 'const' declarations can only be declared inside a block. +tests/cases/compiler/constDeclarations-invalidContexts.ts(11,1): error TS7027: Unreachable code detected. tests/cases/compiler/constDeclarations-invalidContexts.ts(12,5): error TS1156: 'const' declarations can only be declared inside a block. tests/cases/compiler/constDeclarations-invalidContexts.ts(16,7): error TS2410: All symbols within a 'with' block will be resolved to 'any'. tests/cases/compiler/constDeclarations-invalidContexts.ts(20,5): error TS1156: 'const' declarations can only be declared inside a block. @@ -9,7 +11,7 @@ tests/cases/compiler/constDeclarations-invalidContexts.ts(26,12): error TS1156: tests/cases/compiler/constDeclarations-invalidContexts.ts(29,29): error TS1156: 'const' declarations can only be declared inside a block. -==== tests/cases/compiler/constDeclarations-invalidContexts.ts (9 errors) ==== +==== tests/cases/compiler/constDeclarations-invalidContexts.ts (11 errors) ==== // Errors, const must be defined inside a block if (true) @@ -18,6 +20,8 @@ tests/cases/compiler/constDeclarations-invalidContexts.ts(29,29): error TS1156: !!! error TS1156: 'const' declarations can only be declared inside a block. else const c2 = 0; + ~~~~~ +!!! error TS7027: Unreachable code detected. ~~~~~~~~~~~~~ !!! error TS1156: 'const' declarations can only be declared inside a block. @@ -27,6 +31,8 @@ tests/cases/compiler/constDeclarations-invalidContexts.ts(29,29): error TS1156: !!! error TS1156: 'const' declarations can only be declared inside a block. do + ~~ +!!! error TS7027: Unreachable code detected. const c4 = 0; ~~~~~~~~~~~~~ !!! error TS1156: 'const' declarations can only be declared inside a block. diff --git a/tests/baselines/reference/constDeclarations-scopes.errors.txt b/tests/baselines/reference/constDeclarations-scopes.errors.txt index 138acd9b16d..4c9f7ce5163 100644 --- a/tests/baselines/reference/constDeclarations-scopes.errors.txt +++ b/tests/baselines/reference/constDeclarations-scopes.errors.txt @@ -1,7 +1,9 @@ +tests/cases/compiler/constDeclarations-scopes.ts(13,5): error TS7027: Unreachable code detected. +tests/cases/compiler/constDeclarations-scopes.ts(22,1): error TS7027: Unreachable code detected. tests/cases/compiler/constDeclarations-scopes.ts(28,7): error TS2410: All symbols within a 'with' block will be resolved to 'any'. -==== tests/cases/compiler/constDeclarations-scopes.ts (1 errors) ==== +==== tests/cases/compiler/constDeclarations-scopes.ts (3 errors) ==== // global const c = "string"; @@ -15,6 +17,8 @@ tests/cases/compiler/constDeclarations-scopes.ts(28,7): error TS2410: All symbol } else { const c = 0; + ~~~~~ +!!! error TS7027: Unreachable code detected. n = c; } @@ -24,6 +28,8 @@ tests/cases/compiler/constDeclarations-scopes.ts(28,7): error TS2410: All symbol } do { + ~~ +!!! error TS7027: Unreachable code detected. const c = 0; n = c; } while (true); diff --git a/tests/baselines/reference/constDeclarations-validContexts.errors.txt b/tests/baselines/reference/constDeclarations-validContexts.errors.txt index 7af16a53cbe..e55e5f578ba 100644 --- a/tests/baselines/reference/constDeclarations-validContexts.errors.txt +++ b/tests/baselines/reference/constDeclarations-validContexts.errors.txt @@ -1,7 +1,9 @@ +tests/cases/compiler/constDeclarations-validContexts.ts(8,5): error TS7027: Unreachable code detected. +tests/cases/compiler/constDeclarations-validContexts.ts(15,1): error TS7027: Unreachable code detected. tests/cases/compiler/constDeclarations-validContexts.ts(20,7): error TS2410: All symbols within a 'with' block will be resolved to 'any'. -==== tests/cases/compiler/constDeclarations-validContexts.ts (1 errors) ==== +==== tests/cases/compiler/constDeclarations-validContexts.ts (3 errors) ==== // Control flow statements with blocks @@ -10,6 +12,8 @@ tests/cases/compiler/constDeclarations-validContexts.ts(20,7): error TS2410: All } else { const c2 = 0; + ~~~~~ +!!! error TS7027: Unreachable code detected. } while (true) { @@ -17,6 +21,8 @@ tests/cases/compiler/constDeclarations-validContexts.ts(20,7): error TS2410: All } do { + ~~ +!!! error TS7027: Unreachable code detected. const c4 = 0; } while (true); diff --git a/tests/baselines/reference/constructorWithIncompleteTypeAnnotation.errors.txt b/tests/baselines/reference/constructorWithIncompleteTypeAnnotation.errors.txt index 12f397ff06c..56213610b83 100644 --- a/tests/baselines/reference/constructorWithIncompleteTypeAnnotation.errors.txt +++ b/tests/baselines/reference/constructorWithIncompleteTypeAnnotation.errors.txt @@ -9,6 +9,7 @@ tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(27,18): error TS tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(27,26): error TS2304: Cannot find name 'bfs'. tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(28,30): error TS1005: '=' expected. tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(31,18): error TS1109: Expression expected. +tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(31,18): error TS7027: Unreachable code detected. tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(34,17): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(34,26): error TS1005: ';' expected. tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(34,28): error TS2304: Cannot find name 'bfs'. @@ -52,6 +53,7 @@ tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(235,28): error T tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(235,36): error TS1005: ';' expected. tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(238,9): error TS1128: Declaration or statement expected. tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(238,16): error TS2304: Cannot find name 'method2'. +tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(238,16): error TS7027: Unreachable code detected. tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(238,26): error TS1005: ';' expected. tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(241,5): error TS1128: Declaration or statement expected. tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(246,25): error TS2339: Property 'method1' does not exist on type 'B'. @@ -83,7 +85,7 @@ tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(259,55): error T tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(261,1): error TS1128: Declaration or statement expected. -==== tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts (83 errors) ==== +==== tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts (85 errors) ==== declare module "fs" { export class File { constructor(filename: string); @@ -140,6 +142,8 @@ tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(261,1): error TS ^ ~ !!! error TS1109: Expression expected. + ~ +!!! error TS7027: Unreachable code detected. retValue = bfs.TYPES(); @@ -433,6 +437,8 @@ tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(261,1): error TS !!! error TS1128: Declaration or statement expected. ~~~~~~~ !!! error TS2304: Cannot find name 'method2'. + ~~~~~~~ +!!! error TS7027: Unreachable code detected. ~ !!! error TS1005: ';' expected. return 2 * this.method1(2); diff --git a/tests/baselines/reference/continueNotInIterationStatement4.errors.txt b/tests/baselines/reference/continueNotInIterationStatement4.errors.txt index 1c80f7057b8..3f0d57ac45d 100644 --- a/tests/baselines/reference/continueNotInIterationStatement4.errors.txt +++ b/tests/baselines/reference/continueNotInIterationStatement4.errors.txt @@ -1,8 +1,11 @@ +tests/cases/compiler/continueNotInIterationStatement4.ts(1,1): error TS7028: Unused label. tests/cases/compiler/continueNotInIterationStatement4.ts(4,5): error TS1107: Jump target cannot cross function boundary. -==== tests/cases/compiler/continueNotInIterationStatement4.ts (1 errors) ==== +==== tests/cases/compiler/continueNotInIterationStatement4.ts (2 errors) ==== TWO: + ~~~ +!!! error TS7028: Unused label. while (true){ var x = () => { continue TWO; diff --git a/tests/baselines/reference/continueTarget3.errors.txt b/tests/baselines/reference/continueTarget3.errors.txt new file mode 100644 index 00000000000..a3f6b64e7c6 --- /dev/null +++ b/tests/baselines/reference/continueTarget3.errors.txt @@ -0,0 +1,11 @@ +tests/cases/compiler/continueTarget3.ts(2,1): error TS7028: Unused label. + + +==== tests/cases/compiler/continueTarget3.ts (1 errors) ==== + target1: + target2: + ~~~~~~~ +!!! error TS7028: Unused label. + while (true) { + continue target1; + } \ No newline at end of file diff --git a/tests/baselines/reference/continueTarget3.symbols b/tests/baselines/reference/continueTarget3.symbols deleted file mode 100644 index a1b930f2f5a..00000000000 --- a/tests/baselines/reference/continueTarget3.symbols +++ /dev/null @@ -1,7 +0,0 @@ -=== tests/cases/compiler/continueTarget3.ts === -target1: -No type information for this code.target2: -No type information for this code.while (true) { -No type information for this code. continue target1; -No type information for this code.} -No type information for this code. \ No newline at end of file diff --git a/tests/baselines/reference/continueTarget3.types b/tests/baselines/reference/continueTarget3.types deleted file mode 100644 index 3336b47772c..00000000000 --- a/tests/baselines/reference/continueTarget3.types +++ /dev/null @@ -1,13 +0,0 @@ -=== tests/cases/compiler/continueTarget3.ts === -target1: ->target1 : any - -target2: ->target2 : any - -while (true) { ->true : boolean - - continue target1; ->target1 : any -} diff --git a/tests/baselines/reference/continueTarget4.errors.txt b/tests/baselines/reference/continueTarget4.errors.txt new file mode 100644 index 00000000000..d8f3cc12892 --- /dev/null +++ b/tests/baselines/reference/continueTarget4.errors.txt @@ -0,0 +1,11 @@ +tests/cases/compiler/continueTarget4.ts(1,1): error TS7028: Unused label. + + +==== tests/cases/compiler/continueTarget4.ts (1 errors) ==== + target1: + ~~~~~~~ +!!! error TS7028: Unused label. + target2: + while (true) { + continue target2; + } \ No newline at end of file diff --git a/tests/baselines/reference/continueTarget4.symbols b/tests/baselines/reference/continueTarget4.symbols deleted file mode 100644 index ea1989a3e4d..00000000000 --- a/tests/baselines/reference/continueTarget4.symbols +++ /dev/null @@ -1,7 +0,0 @@ -=== tests/cases/compiler/continueTarget4.ts === -target1: -No type information for this code.target2: -No type information for this code.while (true) { -No type information for this code. continue target2; -No type information for this code.} -No type information for this code. \ No newline at end of file diff --git a/tests/baselines/reference/continueTarget4.types b/tests/baselines/reference/continueTarget4.types deleted file mode 100644 index 5d2b7c29bbe..00000000000 --- a/tests/baselines/reference/continueTarget4.types +++ /dev/null @@ -1,13 +0,0 @@ -=== tests/cases/compiler/continueTarget4.ts === -target1: ->target1 : any - -target2: ->target2 : any - -while (true) { ->true : boolean - - continue target2; ->target2 : any -} diff --git a/tests/baselines/reference/continueTarget5.errors.txt b/tests/baselines/reference/continueTarget5.errors.txt index 401c5874ee0..6f0d3a2f6bf 100644 --- a/tests/baselines/reference/continueTarget5.errors.txt +++ b/tests/baselines/reference/continueTarget5.errors.txt @@ -1,8 +1,11 @@ +tests/cases/compiler/continueTarget5.ts(1,1): error TS7028: Unused label. tests/cases/compiler/continueTarget5.ts(5,7): error TS1107: Jump target cannot cross function boundary. -==== tests/cases/compiler/continueTarget5.ts (1 errors) ==== +==== tests/cases/compiler/continueTarget5.ts (2 errors) ==== target: + ~~~~~~ +!!! error TS7028: Unused label. while (true) { function f() { while (true) { diff --git a/tests/baselines/reference/doWhileBreakStatements.errors.txt b/tests/baselines/reference/doWhileBreakStatements.errors.txt new file mode 100644 index 00000000000..e31109858cf --- /dev/null +++ b/tests/baselines/reference/doWhileBreakStatements.errors.txt @@ -0,0 +1,50 @@ +tests/cases/conformance/statements/breakStatements/doWhileBreakStatements.ts(11,1): error TS7028: Unused label. +tests/cases/conformance/statements/breakStatements/doWhileBreakStatements.ts(19,5): error TS7028: Unused label. +tests/cases/conformance/statements/breakStatements/doWhileBreakStatements.ts(30,1): error TS7027: Unreachable code detected. + + +==== tests/cases/conformance/statements/breakStatements/doWhileBreakStatements.ts (3 errors) ==== + do { + break; + } while(true) + + ONE: + do { + break ONE; + } + while (true) + + TWO: + ~~~ +!!! error TS7028: Unused label. + THREE: + do { + break THREE; + }while (true) + + FOUR: + do { + FIVE: + ~~~~ +!!! error TS7028: Unused label. + do { + break FOUR; + }while (true) + }while (true) + + do { + SIX: + do break SIX; while(true) + }while (true) + + SEVEN: + ~~~~~ +!!! error TS7027: Unreachable code detected. + do do do break SEVEN; while (true) while (true) while (true) + + EIGHT: + do{ + var fn = function () { } + break EIGHT; + }while(true) + \ No newline at end of file diff --git a/tests/baselines/reference/doWhileBreakStatements.symbols b/tests/baselines/reference/doWhileBreakStatements.symbols deleted file mode 100644 index 7d9db9a5ebb..00000000000 --- a/tests/baselines/reference/doWhileBreakStatements.symbols +++ /dev/null @@ -1,41 +0,0 @@ -=== tests/cases/conformance/statements/breakStatements/doWhileBreakStatements.ts === -do { - break; -} while(true) - -ONE: -do { - break ONE; -} -while (true) - -TWO: -THREE: -do { - break THREE; -}while (true) - -FOUR: -do { - FIVE: - do { - break FOUR; - }while (true) -}while (true) - -do { - SIX: - do break SIX; while(true) -}while (true) - -SEVEN: -do do do break SEVEN; while (true) while (true) while (true) - -EIGHT: -do{ - var fn = function () { } ->fn : Symbol(fn, Decl(doWhileBreakStatements.ts, 34, 7)) - - break EIGHT; -}while(true) - diff --git a/tests/baselines/reference/doWhileBreakStatements.types b/tests/baselines/reference/doWhileBreakStatements.types deleted file mode 100644 index c3ca932910a..00000000000 --- a/tests/baselines/reference/doWhileBreakStatements.types +++ /dev/null @@ -1,80 +0,0 @@ -=== tests/cases/conformance/statements/breakStatements/doWhileBreakStatements.ts === -do { - break; -} while(true) ->true : boolean - -ONE: ->ONE : any - -do { - break ONE; ->ONE : any -} -while (true) ->true : boolean - -TWO: ->TWO : any - -THREE: ->THREE : any - -do { - break THREE; ->THREE : any - -}while (true) ->true : boolean - -FOUR: ->FOUR : any - -do { - FIVE: ->FIVE : any - - do { - break FOUR; ->FOUR : any - - }while (true) ->true : boolean - -}while (true) ->true : boolean - -do { - SIX: ->SIX : any - - do break SIX; while(true) ->SIX : any ->true : boolean - -}while (true) ->true : boolean - -SEVEN: ->SEVEN : any - -do do do break SEVEN; while (true) while (true) while (true) ->SEVEN : any ->true : boolean ->true : boolean ->true : boolean - -EIGHT: ->EIGHT : any - -do{ - var fn = function () { } ->fn : () => void ->function () { } : () => void - - break EIGHT; ->EIGHT : any - -}while(true) ->true : boolean - diff --git a/tests/baselines/reference/doWhileContinueStatements.errors.txt b/tests/baselines/reference/doWhileContinueStatements.errors.txt new file mode 100644 index 00000000000..491e1242e2f --- /dev/null +++ b/tests/baselines/reference/doWhileContinueStatements.errors.txt @@ -0,0 +1,44 @@ +tests/cases/conformance/statements/continueStatements/doWhileContinueStatements.ts(5,1): error TS7027: Unreachable code detected. + + +==== tests/cases/conformance/statements/continueStatements/doWhileContinueStatements.ts (1 errors) ==== + do { + continue; + } while(true) + + ONE: + ~~~ +!!! error TS7027: Unreachable code detected. + do { + continue ONE; + } + while (true) + + TWO: + THREE: + do { + continue THREE; + }while (true) + + FOUR: + do { + FIVE: + do { + continue FOUR; + }while (true) + }while (true) + + do { + SIX: + do continue SIX; while(true) + }while (true) + + SEVEN: + do do do continue SEVEN; while (true) while (true) while (true) + + EIGHT: + do{ + var fn = function () { } + continue EIGHT; + }while(true) + \ No newline at end of file diff --git a/tests/baselines/reference/doWhileContinueStatements.symbols b/tests/baselines/reference/doWhileContinueStatements.symbols deleted file mode 100644 index e4c6d577d5a..00000000000 --- a/tests/baselines/reference/doWhileContinueStatements.symbols +++ /dev/null @@ -1,41 +0,0 @@ -=== tests/cases/conformance/statements/continueStatements/doWhileContinueStatements.ts === -do { - continue; -} while(true) - -ONE: -do { - continue ONE; -} -while (true) - -TWO: -THREE: -do { - continue THREE; -}while (true) - -FOUR: -do { - FIVE: - do { - continue FOUR; - }while (true) -}while (true) - -do { - SIX: - do continue SIX; while(true) -}while (true) - -SEVEN: -do do do continue SEVEN; while (true) while (true) while (true) - -EIGHT: -do{ - var fn = function () { } ->fn : Symbol(fn, Decl(doWhileContinueStatements.ts, 34, 7)) - - continue EIGHT; -}while(true) - diff --git a/tests/baselines/reference/doWhileContinueStatements.types b/tests/baselines/reference/doWhileContinueStatements.types deleted file mode 100644 index 90c9f59842a..00000000000 --- a/tests/baselines/reference/doWhileContinueStatements.types +++ /dev/null @@ -1,80 +0,0 @@ -=== tests/cases/conformance/statements/continueStatements/doWhileContinueStatements.ts === -do { - continue; -} while(true) ->true : boolean - -ONE: ->ONE : any - -do { - continue ONE; ->ONE : any -} -while (true) ->true : boolean - -TWO: ->TWO : any - -THREE: ->THREE : any - -do { - continue THREE; ->THREE : any - -}while (true) ->true : boolean - -FOUR: ->FOUR : any - -do { - FIVE: ->FIVE : any - - do { - continue FOUR; ->FOUR : any - - }while (true) ->true : boolean - -}while (true) ->true : boolean - -do { - SIX: ->SIX : any - - do continue SIX; while(true) ->SIX : any ->true : boolean - -}while (true) ->true : boolean - -SEVEN: ->SEVEN : any - -do do do continue SEVEN; while (true) while (true) while (true) ->SEVEN : any ->true : boolean ->true : boolean ->true : boolean - -EIGHT: ->EIGHT : any - -do{ - var fn = function () { } ->fn : () => void ->function () { } : () => void - - continue EIGHT; ->EIGHT : any - -}while(true) ->true : boolean - diff --git a/tests/baselines/reference/downlevelLetConst16.errors.txt b/tests/baselines/reference/downlevelLetConst16.errors.txt index 905d1a607e8..a6651574b9e 100644 --- a/tests/baselines/reference/downlevelLetConst16.errors.txt +++ b/tests/baselines/reference/downlevelLetConst16.errors.txt @@ -1,4 +1,6 @@ +tests/cases/compiler/downlevelLetConst16.ts(151,5): error TS7027: Unreachable code detected. tests/cases/compiler/downlevelLetConst16.ts(151,15): error TS2525: Initializer provides no value for this binding element and the binding element has no default value. +tests/cases/compiler/downlevelLetConst16.ts(164,5): error TS7027: Unreachable code detected. tests/cases/compiler/downlevelLetConst16.ts(164,17): error TS2525: Initializer provides no value for this binding element and the binding element has no default value. tests/cases/compiler/downlevelLetConst16.ts(195,14): error TS2461: Type 'undefined' is not an array type. tests/cases/compiler/downlevelLetConst16.ts(202,15): error TS2459: Type 'undefined' has no property 'a' and no string index signature. @@ -6,7 +8,7 @@ tests/cases/compiler/downlevelLetConst16.ts(216,16): error TS2461: Type 'undefin tests/cases/compiler/downlevelLetConst16.ts(223,17): error TS2459: Type 'undefined' has no property 'a' and no string index signature. -==== tests/cases/compiler/downlevelLetConst16.ts (6 errors) ==== +==== tests/cases/compiler/downlevelLetConst16.ts (8 errors) ==== 'use strict' declare function use(a: any); @@ -158,6 +160,8 @@ tests/cases/compiler/downlevelLetConst16.ts(223,17): error TS2459: Type 'undefin use(x); } for (let [y] = []; ;) { + ~~~ +!!! error TS7027: Unreachable code detected. ~ !!! error TS2525: Initializer provides no value for this binding element and the binding element has no default value. use(y); @@ -173,6 +177,8 @@ tests/cases/compiler/downlevelLetConst16.ts(223,17): error TS2459: Type 'undefin use(x); } for (const [y] = []; ;) { + ~~~ +!!! error TS7027: Unreachable code detected. ~ !!! error TS2525: Initializer provides no value for this binding element and the binding element has no default value. use(y); diff --git a/tests/baselines/reference/downlevelLetConst17.errors.txt b/tests/baselines/reference/downlevelLetConst17.errors.txt new file mode 100644 index 00000000000..0365b638449 --- /dev/null +++ b/tests/baselines/reference/downlevelLetConst17.errors.txt @@ -0,0 +1,73 @@ +tests/cases/compiler/downlevelLetConst17.ts(9,1): error TS7027: Unreachable code detected. + + +==== tests/cases/compiler/downlevelLetConst17.ts (1 errors) ==== + 'use strict' + + declare function use(a: any); + + var x; + for (let x = 10; ;) { + use(x); + } + use(x); + ~~~ +!!! error TS7027: Unreachable code detected. + + for (const x = 10; ;) { + use(x); + } + + for (; ;) { + let x = 10; + use(x); + x = 1; + } + + for (; ;) { + const x = 10; + use(x); + } + + for (let x; ;) { + use(x); + x = 1; + } + + for (; ;) { + let x; + use(x); + x = 1; + } + + while (true) { + let x; + use(x); + } + + while (true) { + const x = true; + use(x); + } + + do { + let x; + use(x); + } while (true); + + do { + let x; + use(x); + } while (true); + + for (let x in []) { + use(x); + } + + for (const x in []) { + use(x); + } + + for (const x of []) { + use(x); + } \ No newline at end of file diff --git a/tests/baselines/reference/downlevelLetConst17.symbols b/tests/baselines/reference/downlevelLetConst17.symbols deleted file mode 100644 index 809a835774c..00000000000 --- a/tests/baselines/reference/downlevelLetConst17.symbols +++ /dev/null @@ -1,134 +0,0 @@ -=== tests/cases/compiler/downlevelLetConst17.ts === -'use strict' - -declare function use(a: any); ->use : Symbol(use, Decl(downlevelLetConst17.ts, 0, 12)) ->a : Symbol(a, Decl(downlevelLetConst17.ts, 2, 21)) - -var x; ->x : Symbol(x, Decl(downlevelLetConst17.ts, 4, 3)) - -for (let x = 10; ;) { ->x : Symbol(x, Decl(downlevelLetConst17.ts, 5, 8)) - - use(x); ->use : Symbol(use, Decl(downlevelLetConst17.ts, 0, 12)) ->x : Symbol(x, Decl(downlevelLetConst17.ts, 5, 8)) -} -use(x); ->use : Symbol(use, Decl(downlevelLetConst17.ts, 0, 12)) ->x : Symbol(x, Decl(downlevelLetConst17.ts, 4, 3)) - -for (const x = 10; ;) { ->x : Symbol(x, Decl(downlevelLetConst17.ts, 10, 10)) - - use(x); ->use : Symbol(use, Decl(downlevelLetConst17.ts, 0, 12)) ->x : Symbol(x, Decl(downlevelLetConst17.ts, 10, 10)) -} - -for (; ;) { - let x = 10; ->x : Symbol(x, Decl(downlevelLetConst17.ts, 15, 7)) - - use(x); ->use : Symbol(use, Decl(downlevelLetConst17.ts, 0, 12)) ->x : Symbol(x, Decl(downlevelLetConst17.ts, 15, 7)) - - x = 1; ->x : Symbol(x, Decl(downlevelLetConst17.ts, 15, 7)) -} - -for (; ;) { - const x = 10; ->x : Symbol(x, Decl(downlevelLetConst17.ts, 21, 9)) - - use(x); ->use : Symbol(use, Decl(downlevelLetConst17.ts, 0, 12)) ->x : Symbol(x, Decl(downlevelLetConst17.ts, 21, 9)) -} - -for (let x; ;) { ->x : Symbol(x, Decl(downlevelLetConst17.ts, 25, 8)) - - use(x); ->use : Symbol(use, Decl(downlevelLetConst17.ts, 0, 12)) ->x : Symbol(x, Decl(downlevelLetConst17.ts, 25, 8)) - - x = 1; ->x : Symbol(x, Decl(downlevelLetConst17.ts, 25, 8)) -} - -for (; ;) { - let x; ->x : Symbol(x, Decl(downlevelLetConst17.ts, 31, 7)) - - use(x); ->use : Symbol(use, Decl(downlevelLetConst17.ts, 0, 12)) ->x : Symbol(x, Decl(downlevelLetConst17.ts, 31, 7)) - - x = 1; ->x : Symbol(x, Decl(downlevelLetConst17.ts, 31, 7)) -} - -while (true) { - let x; ->x : Symbol(x, Decl(downlevelLetConst17.ts, 37, 7)) - - use(x); ->use : Symbol(use, Decl(downlevelLetConst17.ts, 0, 12)) ->x : Symbol(x, Decl(downlevelLetConst17.ts, 37, 7)) -} - -while (true) { - const x = true; ->x : Symbol(x, Decl(downlevelLetConst17.ts, 42, 9)) - - use(x); ->use : Symbol(use, Decl(downlevelLetConst17.ts, 0, 12)) ->x : Symbol(x, Decl(downlevelLetConst17.ts, 42, 9)) -} - -do { - let x; ->x : Symbol(x, Decl(downlevelLetConst17.ts, 47, 7)) - - use(x); ->use : Symbol(use, Decl(downlevelLetConst17.ts, 0, 12)) ->x : Symbol(x, Decl(downlevelLetConst17.ts, 47, 7)) - -} while (true); - -do { - let x; ->x : Symbol(x, Decl(downlevelLetConst17.ts, 52, 7)) - - use(x); ->use : Symbol(use, Decl(downlevelLetConst17.ts, 0, 12)) ->x : Symbol(x, Decl(downlevelLetConst17.ts, 52, 7)) - -} while (true); - -for (let x in []) { ->x : Symbol(x, Decl(downlevelLetConst17.ts, 56, 8)) - - use(x); ->use : Symbol(use, Decl(downlevelLetConst17.ts, 0, 12)) ->x : Symbol(x, Decl(downlevelLetConst17.ts, 56, 8)) -} - -for (const x in []) { ->x : Symbol(x, Decl(downlevelLetConst17.ts, 60, 10)) - - use(x); ->use : Symbol(use, Decl(downlevelLetConst17.ts, 0, 12)) ->x : Symbol(x, Decl(downlevelLetConst17.ts, 60, 10)) -} - -for (const x of []) { ->x : Symbol(x, Decl(downlevelLetConst17.ts, 64, 10)) - - use(x); ->use : Symbol(use, Decl(downlevelLetConst17.ts, 0, 12)) ->x : Symbol(x, Decl(downlevelLetConst17.ts, 64, 10)) -} diff --git a/tests/baselines/reference/downlevelLetConst17.types b/tests/baselines/reference/downlevelLetConst17.types deleted file mode 100644 index 824abcc76be..00000000000 --- a/tests/baselines/reference/downlevelLetConst17.types +++ /dev/null @@ -1,169 +0,0 @@ -=== tests/cases/compiler/downlevelLetConst17.ts === -'use strict' ->'use strict' : string - -declare function use(a: any); ->use : (a: any) => any ->a : any - -var x; ->x : any - -for (let x = 10; ;) { ->x : number ->10 : number - - use(x); ->use(x) : any ->use : (a: any) => any ->x : number -} -use(x); ->use(x) : any ->use : (a: any) => any ->x : any - -for (const x = 10; ;) { ->x : number ->10 : number - - use(x); ->use(x) : any ->use : (a: any) => any ->x : number -} - -for (; ;) { - let x = 10; ->x : number ->10 : number - - use(x); ->use(x) : any ->use : (a: any) => any ->x : number - - x = 1; ->x = 1 : number ->x : number ->1 : number -} - -for (; ;) { - const x = 10; ->x : number ->10 : number - - use(x); ->use(x) : any ->use : (a: any) => any ->x : number -} - -for (let x; ;) { ->x : any - - use(x); ->use(x) : any ->use : (a: any) => any ->x : any - - x = 1; ->x = 1 : number ->x : any ->1 : number -} - -for (; ;) { - let x; ->x : any - - use(x); ->use(x) : any ->use : (a: any) => any ->x : any - - x = 1; ->x = 1 : number ->x : any ->1 : number -} - -while (true) { ->true : boolean - - let x; ->x : any - - use(x); ->use(x) : any ->use : (a: any) => any ->x : any -} - -while (true) { ->true : boolean - - const x = true; ->x : boolean ->true : boolean - - use(x); ->use(x) : any ->use : (a: any) => any ->x : boolean -} - -do { - let x; ->x : any - - use(x); ->use(x) : any ->use : (a: any) => any ->x : any - -} while (true); ->true : boolean - -do { - let x; ->x : any - - use(x); ->use(x) : any ->use : (a: any) => any ->x : any - -} while (true); ->true : boolean - -for (let x in []) { ->x : any ->[] : undefined[] - - use(x); ->use(x) : any ->use : (a: any) => any ->x : any -} - -for (const x in []) { ->x : any ->[] : undefined[] - - use(x); ->use(x) : any ->use : (a: any) => any ->x : any -} - -for (const x of []) { ->x : any ->[] : undefined[] - - use(x); ->use(x) : any ->use : (a: any) => any ->x : any -} diff --git a/tests/baselines/reference/downlevelLetConst18.errors.txt b/tests/baselines/reference/downlevelLetConst18.errors.txt index 8f30b0f802a..5d9d24a4d6d 100644 --- a/tests/baselines/reference/downlevelLetConst18.errors.txt +++ b/tests/baselines/reference/downlevelLetConst18.errors.txt @@ -1,6 +1,7 @@ tests/cases/compiler/downlevelLetConst18.ts(3,1): error TS4091: Loop contains block-scoped variable 'x' referenced by a function in the loop. This is only supported in ECMAScript 6 or higher. tests/cases/compiler/downlevelLetConst18.ts(4,14): error TS2393: Duplicate function implementation. tests/cases/compiler/downlevelLetConst18.ts(7,1): error TS4091: Loop contains block-scoped variable 'x' referenced by a function in the loop. This is only supported in ECMAScript 6 or higher. +tests/cases/compiler/downlevelLetConst18.ts(7,1): error TS7027: Unreachable code detected. tests/cases/compiler/downlevelLetConst18.ts(8,14): error TS2393: Duplicate function implementation. tests/cases/compiler/downlevelLetConst18.ts(11,1): error TS4091: Loop contains block-scoped variable 'x' referenced by a function in the loop. This is only supported in ECMAScript 6 or higher. tests/cases/compiler/downlevelLetConst18.ts(15,1): error TS4091: Loop contains block-scoped variable 'x' referenced by a function in the loop. This is only supported in ECMAScript 6 or higher. @@ -9,7 +10,7 @@ tests/cases/compiler/downlevelLetConst18.ts(23,1): error TS4091: Loop contains b tests/cases/compiler/downlevelLetConst18.ts(27,1): error TS4091: Loop contains block-scoped variable 'x' referenced by a function in the loop. This is only supported in ECMAScript 6 or higher. -==== tests/cases/compiler/downlevelLetConst18.ts (9 errors) ==== +==== tests/cases/compiler/downlevelLetConst18.ts (10 errors) ==== 'use strict' for (let x; ;) { @@ -23,6 +24,8 @@ tests/cases/compiler/downlevelLetConst18.ts(27,1): error TS4091: Loop contains b for (let x; ;) { ~~~ !!! error TS4091: Loop contains block-scoped variable 'x' referenced by a function in the loop. This is only supported in ECMAScript 6 or higher. + ~~~ +!!! error TS7027: Unreachable code detected. function foo() { x }; ~~~ !!! error TS2393: Duplicate function implementation. diff --git a/tests/baselines/reference/duplicateLabel1.errors.txt b/tests/baselines/reference/duplicateLabel1.errors.txt index b34f1f771e0..2f89b400e21 100644 --- a/tests/baselines/reference/duplicateLabel1.errors.txt +++ b/tests/baselines/reference/duplicateLabel1.errors.txt @@ -1,8 +1,11 @@ +tests/cases/compiler/duplicateLabel1.ts(1,1): error TS7028: Unused label. tests/cases/compiler/duplicateLabel1.ts(2,1): error TS1114: Duplicate label 'target' -==== tests/cases/compiler/duplicateLabel1.ts (1 errors) ==== +==== tests/cases/compiler/duplicateLabel1.ts (2 errors) ==== target: + ~~~~~~ +!!! error TS7028: Unused label. target: ~~~~~~ !!! error TS1114: Duplicate label 'target' diff --git a/tests/baselines/reference/duplicateLabel2.errors.txt b/tests/baselines/reference/duplicateLabel2.errors.txt index 307596cf4e8..f150879c010 100644 --- a/tests/baselines/reference/duplicateLabel2.errors.txt +++ b/tests/baselines/reference/duplicateLabel2.errors.txt @@ -1,8 +1,11 @@ +tests/cases/compiler/duplicateLabel2.ts(1,1): error TS7028: Unused label. tests/cases/compiler/duplicateLabel2.ts(3,3): error TS1114: Duplicate label 'target' -==== tests/cases/compiler/duplicateLabel2.ts (1 errors) ==== +==== tests/cases/compiler/duplicateLabel2.ts (2 errors) ==== target: + ~~~~~~ +!!! error TS7028: Unused label. while (true) { target: ~~~~~~ diff --git a/tests/baselines/reference/duplicateLabel3.errors.txt b/tests/baselines/reference/duplicateLabel3.errors.txt new file mode 100644 index 00000000000..f256176f1e0 --- /dev/null +++ b/tests/baselines/reference/duplicateLabel3.errors.txt @@ -0,0 +1,17 @@ +tests/cases/compiler/duplicateLabel3.ts(1,1): error TS7028: Unused label. +tests/cases/compiler/duplicateLabel3.ts(4,5): error TS7028: Unused label. + + +==== tests/cases/compiler/duplicateLabel3.ts (2 errors) ==== + target: + ~~~~~~ +!!! error TS7028: Unused label. + while (true) { + function f() { + target: + ~~~~~~ +!!! error TS7028: Unused label. + while (true) { + } + } + } \ No newline at end of file diff --git a/tests/baselines/reference/duplicateLabel3.symbols b/tests/baselines/reference/duplicateLabel3.symbols deleted file mode 100644 index 07d0ded2923..00000000000 --- a/tests/baselines/reference/duplicateLabel3.symbols +++ /dev/null @@ -1,11 +0,0 @@ -=== tests/cases/compiler/duplicateLabel3.ts === -target: -while (true) { - function f() { ->f : Symbol(f, Decl(duplicateLabel3.ts, 1, 14)) - - target: - while (true) { - } - } -} diff --git a/tests/baselines/reference/duplicateLabel3.types b/tests/baselines/reference/duplicateLabel3.types deleted file mode 100644 index 8d75b08c768..00000000000 --- a/tests/baselines/reference/duplicateLabel3.types +++ /dev/null @@ -1,18 +0,0 @@ -=== tests/cases/compiler/duplicateLabel3.ts === -target: ->target : any - -while (true) { ->true : boolean - - function f() { ->f : () => void - - target: ->target : any - - while (true) { ->true : boolean - } - } -} diff --git a/tests/baselines/reference/duplicateLabel4.errors.txt b/tests/baselines/reference/duplicateLabel4.errors.txt new file mode 100644 index 00000000000..516a4b2324b --- /dev/null +++ b/tests/baselines/reference/duplicateLabel4.errors.txt @@ -0,0 +1,16 @@ +tests/cases/compiler/duplicateLabel4.ts(1,1): error TS7028: Unused label. +tests/cases/compiler/duplicateLabel4.ts(5,1): error TS7027: Unreachable code detected. + + +==== tests/cases/compiler/duplicateLabel4.ts (2 errors) ==== + target: + ~~~~~~ +!!! error TS7028: Unused label. + while (true) { + } + + target: + ~~~~~~ +!!! error TS7027: Unreachable code detected. + while (true) { + } \ No newline at end of file diff --git a/tests/baselines/reference/duplicateLabel4.symbols b/tests/baselines/reference/duplicateLabel4.symbols deleted file mode 100644 index c671abcef35..00000000000 --- a/tests/baselines/reference/duplicateLabel4.symbols +++ /dev/null @@ -1,9 +0,0 @@ -=== tests/cases/compiler/duplicateLabel4.ts === -target: -No type information for this code.while (true) { -No type information for this code.} -No type information for this code. -No type information for this code.target: -No type information for this code.while (true) { -No type information for this code.} -No type information for this code. \ No newline at end of file diff --git a/tests/baselines/reference/duplicateLabel4.types b/tests/baselines/reference/duplicateLabel4.types deleted file mode 100644 index 9238986b582..00000000000 --- a/tests/baselines/reference/duplicateLabel4.types +++ /dev/null @@ -1,14 +0,0 @@ -=== tests/cases/compiler/duplicateLabel4.ts === -target: ->target : any - -while (true) { ->true : boolean -} - -target: ->target : any - -while (true) { ->true : boolean -} diff --git a/tests/baselines/reference/duplicateLocalVariable1.errors.txt b/tests/baselines/reference/duplicateLocalVariable1.errors.txt index e4217d4d411..890470f6c11 100644 --- a/tests/baselines/reference/duplicateLocalVariable1.errors.txt +++ b/tests/baselines/reference/duplicateLocalVariable1.errors.txt @@ -1,7 +1,9 @@ +tests/cases/compiler/duplicateLocalVariable1.ts(64,92): error TS7027: Unreachable code detected. +tests/cases/compiler/duplicateLocalVariable1.ts(65,122): error TS7027: Unreachable code detected. tests/cases/compiler/duplicateLocalVariable1.ts(185,22): error TS2403: Subsequent variable declarations must have the same type. Variable 'i' must be of type 'any', but here has type 'number'. -==== tests/cases/compiler/duplicateLocalVariable1.ts (1 errors) ==== +==== tests/cases/compiler/duplicateLocalVariable1.ts (3 errors) ==== //import FileManager = require('filemanager'); //import App = require('app'); @@ -66,7 +68,11 @@ tests/cases/compiler/duplicateLocalVariable1.ts(185,22): error TS2403: Subsequen // First 3 are for simple harness validation testRunner.addTest(new TestCase("Basic test", function () { return true; })); testRunner.addTest(new TestCase("Test for any error", function () { throw new Error(); return false; }, "")); + ~~~~~~ +!!! error TS7027: Unreachable code detected. testRunner.addTest(new TestCase("Test RegEx error message match", function () { throw new Error("Should also pass"); return false; }, "Should [also]+ pass")); + ~~~~~~ +!!! error TS7027: Unreachable code detected. testRunner.addTest(new TestCase("Test array compare true", function () { return TestRunner.arrayCompare([1, 2, 3], [1, 2, 3]); })); testRunner.addTest(new TestCase("Test array compare false", function () { return !TestRunner.arrayCompare([3, 2, 3], [1, 2, 3]); })); diff --git a/tests/baselines/reference/duplicateVariablesByScope.errors.txt b/tests/baselines/reference/duplicateVariablesByScope.errors.txt new file mode 100644 index 00000000000..e101b2b0e0d --- /dev/null +++ b/tests/baselines/reference/duplicateVariablesByScope.errors.txt @@ -0,0 +1,37 @@ +tests/cases/compiler/duplicateVariablesByScope.ts(18,9): error TS7027: Unreachable code detected. + + +==== tests/cases/compiler/duplicateVariablesByScope.ts (1 errors) ==== + // duplicate local variables are only reported at global scope + + module M { + for (var j = 0; j < 10; j++) { + } + + for (var j = 0; j < 10; j++) { + } + } + + function foo() { + var x = 2; + var x = 1; + if (true) { + var result = 1; + } + else { + var result = 2; + ~~~ +!!! error TS7027: Unreachable code detected. + } + } + + class C { + foo() { + try { + var x = 1; + } + catch (e) { + var x = 2; + } + } + } \ No newline at end of file diff --git a/tests/baselines/reference/duplicateVariablesByScope.symbols b/tests/baselines/reference/duplicateVariablesByScope.symbols deleted file mode 100644 index bc94dc9b807..00000000000 --- a/tests/baselines/reference/duplicateVariablesByScope.symbols +++ /dev/null @@ -1,56 +0,0 @@ -=== tests/cases/compiler/duplicateVariablesByScope.ts === -// duplicate local variables are only reported at global scope - -module M { ->M : Symbol(M, Decl(duplicateVariablesByScope.ts, 0, 0)) - - for (var j = 0; j < 10; j++) { ->j : Symbol(j, Decl(duplicateVariablesByScope.ts, 3, 12), Decl(duplicateVariablesByScope.ts, 6, 12)) ->j : Symbol(j, Decl(duplicateVariablesByScope.ts, 3, 12), Decl(duplicateVariablesByScope.ts, 6, 12)) ->j : Symbol(j, Decl(duplicateVariablesByScope.ts, 3, 12), Decl(duplicateVariablesByScope.ts, 6, 12)) - } - - for (var j = 0; j < 10; j++) { ->j : Symbol(j, Decl(duplicateVariablesByScope.ts, 3, 12), Decl(duplicateVariablesByScope.ts, 6, 12)) ->j : Symbol(j, Decl(duplicateVariablesByScope.ts, 3, 12), Decl(duplicateVariablesByScope.ts, 6, 12)) ->j : Symbol(j, Decl(duplicateVariablesByScope.ts, 3, 12), Decl(duplicateVariablesByScope.ts, 6, 12)) - } -} - -function foo() { ->foo : Symbol(foo, Decl(duplicateVariablesByScope.ts, 8, 1)) - - var x = 2; ->x : Symbol(x, Decl(duplicateVariablesByScope.ts, 11, 7), Decl(duplicateVariablesByScope.ts, 12, 7)) - - var x = 1; ->x : Symbol(x, Decl(duplicateVariablesByScope.ts, 11, 7), Decl(duplicateVariablesByScope.ts, 12, 7)) - - if (true) { - var result = 1; ->result : Symbol(result, Decl(duplicateVariablesByScope.ts, 14, 11), Decl(duplicateVariablesByScope.ts, 17, 11)) - } - else { - var result = 2; ->result : Symbol(result, Decl(duplicateVariablesByScope.ts, 14, 11), Decl(duplicateVariablesByScope.ts, 17, 11)) - } -} - -class C { ->C : Symbol(C, Decl(duplicateVariablesByScope.ts, 19, 1)) - - foo() { ->foo : Symbol(foo, Decl(duplicateVariablesByScope.ts, 21, 9)) - - try { - var x = 1; ->x : Symbol(x, Decl(duplicateVariablesByScope.ts, 24, 15), Decl(duplicateVariablesByScope.ts, 27, 15)) - } - catch (e) { ->e : Symbol(e, Decl(duplicateVariablesByScope.ts, 26, 15)) - - var x = 2; ->x : Symbol(x, Decl(duplicateVariablesByScope.ts, 24, 15), Decl(duplicateVariablesByScope.ts, 27, 15)) - } - } -} diff --git a/tests/baselines/reference/duplicateVariablesByScope.types b/tests/baselines/reference/duplicateVariablesByScope.types deleted file mode 100644 index 42d8cae2a3c..00000000000 --- a/tests/baselines/reference/duplicateVariablesByScope.types +++ /dev/null @@ -1,72 +0,0 @@ -=== tests/cases/compiler/duplicateVariablesByScope.ts === -// duplicate local variables are only reported at global scope - -module M { ->M : typeof M - - for (var j = 0; j < 10; j++) { ->j : number ->0 : number ->j < 10 : boolean ->j : number ->10 : number ->j++ : number ->j : number - } - - for (var j = 0; j < 10; j++) { ->j : number ->0 : number ->j < 10 : boolean ->j : number ->10 : number ->j++ : number ->j : number - } -} - -function foo() { ->foo : () => void - - var x = 2; ->x : number ->2 : number - - var x = 1; ->x : number ->1 : number - - if (true) { ->true : boolean - - var result = 1; ->result : number ->1 : number - } - else { - var result = 2; ->result : number ->2 : number - } -} - -class C { ->C : C - - foo() { ->foo : () => void - - try { - var x = 1; ->x : number ->1 : number - } - catch (e) { ->e : any - - var x = 2; ->x : number ->2 : number - } - } -} diff --git a/tests/baselines/reference/es6ClassSuperCodegenBug.errors.txt b/tests/baselines/reference/es6ClassSuperCodegenBug.errors.txt new file mode 100644 index 00000000000..f30719a2792 --- /dev/null +++ b/tests/baselines/reference/es6ClassSuperCodegenBug.errors.txt @@ -0,0 +1,19 @@ +tests/cases/compiler/es6ClassSuperCodegenBug.ts(9,10): error TS7027: Unreachable code detected. + + +==== tests/cases/compiler/es6ClassSuperCodegenBug.ts (1 errors) ==== + class A { + constructor(str1:string, str2:string) {} + } + class B extends A { + constructor() { + if (true) { + super('a1', 'b1'); + } else { + super('a2', 'b2'); + ~~~~~ +!!! error TS7027: Unreachable code detected. + } + } + } + \ No newline at end of file diff --git a/tests/baselines/reference/es6ClassSuperCodegenBug.symbols b/tests/baselines/reference/es6ClassSuperCodegenBug.symbols deleted file mode 100644 index d520ec3ceb1..00000000000 --- a/tests/baselines/reference/es6ClassSuperCodegenBug.symbols +++ /dev/null @@ -1,24 +0,0 @@ -=== tests/cases/compiler/es6ClassSuperCodegenBug.ts === -class A { ->A : Symbol(A, Decl(es6ClassSuperCodegenBug.ts, 0, 0)) - - constructor(str1:string, str2:string) {} ->str1 : Symbol(str1, Decl(es6ClassSuperCodegenBug.ts, 1, 13)) ->str2 : Symbol(str2, Decl(es6ClassSuperCodegenBug.ts, 1, 25)) -} -class B extends A { ->B : Symbol(B, Decl(es6ClassSuperCodegenBug.ts, 2, 1)) ->A : Symbol(A, Decl(es6ClassSuperCodegenBug.ts, 0, 0)) - - constructor() { - if (true) { - super('a1', 'b1'); ->super : Symbol(A, Decl(es6ClassSuperCodegenBug.ts, 0, 0)) - - } else { - super('a2', 'b2'); ->super : Symbol(A, Decl(es6ClassSuperCodegenBug.ts, 0, 0)) - } - } -} - diff --git a/tests/baselines/reference/es6ClassSuperCodegenBug.types b/tests/baselines/reference/es6ClassSuperCodegenBug.types deleted file mode 100644 index bdf8ebde8f2..00000000000 --- a/tests/baselines/reference/es6ClassSuperCodegenBug.types +++ /dev/null @@ -1,32 +0,0 @@ -=== tests/cases/compiler/es6ClassSuperCodegenBug.ts === -class A { ->A : A - - constructor(str1:string, str2:string) {} ->str1 : string ->str2 : string -} -class B extends A { ->B : B ->A : A - - constructor() { - if (true) { ->true : boolean - - super('a1', 'b1'); ->super('a1', 'b1') : void ->super : typeof A ->'a1' : string ->'b1' : string - - } else { - super('a2', 'b2'); ->super('a2', 'b2') : void ->super : typeof A ->'a2' : string ->'b2' : string - } - } -} - diff --git a/tests/baselines/reference/escapedIdentifiers.errors.txt b/tests/baselines/reference/escapedIdentifiers.errors.txt new file mode 100644 index 00000000000..8f7d735ceed --- /dev/null +++ b/tests/baselines/reference/escapedIdentifiers.errors.txt @@ -0,0 +1,146 @@ +tests/cases/compiler/escapedIdentifiers.ts(93,1): error TS7028: Unused label. +tests/cases/compiler/escapedIdentifiers.ts(96,8): error TS7027: Unreachable code detected. +tests/cases/compiler/escapedIdentifiers.ts(100,1): error TS7028: Unused label. +tests/cases/compiler/escapedIdentifiers.ts(103,8): error TS7027: Unreachable code detected. +tests/cases/compiler/escapedIdentifiers.ts(107,1): error TS7028: Unused label. +tests/cases/compiler/escapedIdentifiers.ts(110,8): error TS7027: Unreachable code detected. +tests/cases/compiler/escapedIdentifiers.ts(114,1): error TS7028: Unused label. +tests/cases/compiler/escapedIdentifiers.ts(117,8): error TS7027: Unreachable code detected. + + +==== tests/cases/compiler/escapedIdentifiers.ts (8 errors) ==== + /* + 0 .. \u0030 + 9 .. \u0039 + + A .. \u0041 + Z .. \u005a + + a .. \u0061 + z .. \u00za + */ + + // var decl + var \u0061 = 1; + a ++; + \u0061 ++; + + var b = 1; + b ++; + \u0062 ++; + + // modules + module moduleType1 { + export var baz1: number; + } + module moduleType\u0032 { + export var baz2: number; + } + + moduleType1.baz1 = 3; + moduleType\u0031.baz1 = 3; + moduleType2.baz2 = 3; + moduleType\u0032.baz2 = 3; + + // classes + + class classType1 { + public foo1: number; + } + class classType\u0032 { + public foo2: number; + } + + var classType1Object1 = new classType1(); + classType1Object1.foo1 = 2; + var classType1Object2 = new classType\u0031(); + classType1Object2.foo1 = 2; + var classType2Object1 = new classType2(); + classType2Object1.foo2 = 2; + var classType2Object2 = new classType\u0032(); + classType2Object2.foo2 = 2; + + // interfaces + interface interfaceType1 { + bar1: number; + } + interface interfaceType\u0032 { + bar2: number; + } + + var interfaceType1Object1 = { bar1: 0 }; + interfaceType1Object1.bar1 = 2; + var interfaceType1Object2 = { bar1: 0 }; + interfaceType1Object2.bar1 = 2; + var interfaceType2Object1 = { bar2: 0 }; + interfaceType2Object1.bar2 = 2; + var interfaceType2Object2 = { bar2: 0 }; + interfaceType2Object2.bar2 = 2; + + + // arguments + class testClass { + public func(arg1: number, arg\u0032: string, arg\u0033: boolean, arg4: number) { + arg\u0031 = 1; + arg2 = 'string'; + arg\u0033 = true; + arg4 = 2; + } + } + + // constructors + class constructorTestClass { + constructor (public arg1: number,public arg\u0032: string,public arg\u0033: boolean,public arg4: number) { + } + } + var constructorTestObject = new constructorTestClass(1, 'string', true, 2); + constructorTestObject.arg\u0031 = 1; + constructorTestObject.arg2 = 'string'; + constructorTestObject.arg\u0033 = true; + constructorTestObject.arg4 = 2; + + // Lables + + l\u0061bel1: + ~~~~~~~~~~~ +!!! error TS7028: Unused label. + while (false) + { + while(false) + ~~~~~ +!!! error TS7027: Unreachable code detected. + continue label1; // it will go to next iteration of outer loop + } + + label2: + ~~~~~~ +!!! error TS7028: Unused label. + while (false) + { + while(false) + ~~~~~ +!!! error TS7027: Unreachable code detected. + continue l\u0061bel2; // it will go to next iteration of outer loop + } + + label3: + ~~~~~~ +!!! error TS7028: Unused label. + while (false) + { + while(false) + ~~~~~ +!!! error TS7027: Unreachable code detected. + continue label3; // it will go to next iteration of outer loop + } + + l\u0061bel4: + ~~~~~~~~~~~ +!!! error TS7028: Unused label. + while (false) + { + while(false) + ~~~~~ +!!! error TS7027: Unreachable code detected. + continue l\u0061bel4; // it will go to next iteration of outer loop + } \ No newline at end of file diff --git a/tests/baselines/reference/escapedIdentifiers.symbols b/tests/baselines/reference/escapedIdentifiers.symbols deleted file mode 100644 index 6c84b25647f..00000000000 --- a/tests/baselines/reference/escapedIdentifiers.symbols +++ /dev/null @@ -1,260 +0,0 @@ -=== tests/cases/compiler/escapedIdentifiers.ts === -/* - 0 .. \u0030 - 9 .. \u0039 - - A .. \u0041 - Z .. \u005a - - a .. \u0061 - z .. \u00za -*/ - -// var decl -var \u0061 = 1; ->\u0061 : Symbol(\u0061, Decl(escapedIdentifiers.ts, 12, 3)) - -a ++; ->a : Symbol(\u0061, Decl(escapedIdentifiers.ts, 12, 3)) - -\u0061 ++; ->\u0061 : Symbol(\u0061, Decl(escapedIdentifiers.ts, 12, 3)) - -var b = 1; ->b : Symbol(b, Decl(escapedIdentifiers.ts, 16, 3)) - -b ++; ->b : Symbol(b, Decl(escapedIdentifiers.ts, 16, 3)) - -\u0062 ++; ->\u0062 : Symbol(b, Decl(escapedIdentifiers.ts, 16, 3)) - -// modules -module moduleType1 { ->moduleType1 : Symbol(moduleType1, Decl(escapedIdentifiers.ts, 18, 10)) - - export var baz1: number; ->baz1 : Symbol(baz1, Decl(escapedIdentifiers.ts, 22, 14)) -} -module moduleType\u0032 { ->moduleType\u0032 : Symbol(moduleType\u0032, Decl(escapedIdentifiers.ts, 23, 1)) - - export var baz2: number; ->baz2 : Symbol(baz2, Decl(escapedIdentifiers.ts, 25, 14)) -} - -moduleType1.baz1 = 3; ->moduleType1.baz1 : Symbol(moduleType1.baz1, Decl(escapedIdentifiers.ts, 22, 14)) ->moduleType1 : Symbol(moduleType1, Decl(escapedIdentifiers.ts, 18, 10)) ->baz1 : Symbol(moduleType1.baz1, Decl(escapedIdentifiers.ts, 22, 14)) - -moduleType\u0031.baz1 = 3; ->moduleType\u0031.baz1 : Symbol(moduleType1.baz1, Decl(escapedIdentifiers.ts, 22, 14)) ->moduleType\u0031 : Symbol(moduleType1, Decl(escapedIdentifiers.ts, 18, 10)) ->baz1 : Symbol(moduleType1.baz1, Decl(escapedIdentifiers.ts, 22, 14)) - -moduleType2.baz2 = 3; ->moduleType2.baz2 : Symbol(moduleType\u0032.baz2, Decl(escapedIdentifiers.ts, 25, 14)) ->moduleType2 : Symbol(moduleType\u0032, Decl(escapedIdentifiers.ts, 23, 1)) ->baz2 : Symbol(moduleType\u0032.baz2, Decl(escapedIdentifiers.ts, 25, 14)) - -moduleType\u0032.baz2 = 3; ->moduleType\u0032.baz2 : Symbol(moduleType\u0032.baz2, Decl(escapedIdentifiers.ts, 25, 14)) ->moduleType\u0032 : Symbol(moduleType\u0032, Decl(escapedIdentifiers.ts, 23, 1)) ->baz2 : Symbol(moduleType\u0032.baz2, Decl(escapedIdentifiers.ts, 25, 14)) - -// classes - -class classType1 { ->classType1 : Symbol(classType1, Decl(escapedIdentifiers.ts, 31, 26)) - - public foo1: number; ->foo1 : Symbol(foo1, Decl(escapedIdentifiers.ts, 35, 18)) -} -class classType\u0032 { ->classType\u0032 : Symbol(classType\u0032, Decl(escapedIdentifiers.ts, 37, 1)) - - public foo2: number; ->foo2 : Symbol(foo2, Decl(escapedIdentifiers.ts, 38, 23)) -} - -var classType1Object1 = new classType1(); ->classType1Object1 : Symbol(classType1Object1, Decl(escapedIdentifiers.ts, 42, 3)) ->classType1 : Symbol(classType1, Decl(escapedIdentifiers.ts, 31, 26)) - -classType1Object1.foo1 = 2; ->classType1Object1.foo1 : Symbol(classType1.foo1, Decl(escapedIdentifiers.ts, 35, 18)) ->classType1Object1 : Symbol(classType1Object1, Decl(escapedIdentifiers.ts, 42, 3)) ->foo1 : Symbol(classType1.foo1, Decl(escapedIdentifiers.ts, 35, 18)) - -var classType1Object2 = new classType\u0031(); ->classType1Object2 : Symbol(classType1Object2, Decl(escapedIdentifiers.ts, 44, 3)) ->classType\u0031 : Symbol(classType1, Decl(escapedIdentifiers.ts, 31, 26)) - -classType1Object2.foo1 = 2; ->classType1Object2.foo1 : Symbol(classType1.foo1, Decl(escapedIdentifiers.ts, 35, 18)) ->classType1Object2 : Symbol(classType1Object2, Decl(escapedIdentifiers.ts, 44, 3)) ->foo1 : Symbol(classType1.foo1, Decl(escapedIdentifiers.ts, 35, 18)) - -var classType2Object1 = new classType2(); ->classType2Object1 : Symbol(classType2Object1, Decl(escapedIdentifiers.ts, 46, 3)) ->classType2 : Symbol(classType\u0032, Decl(escapedIdentifiers.ts, 37, 1)) - -classType2Object1.foo2 = 2; ->classType2Object1.foo2 : Symbol(classType\u0032.foo2, Decl(escapedIdentifiers.ts, 38, 23)) ->classType2Object1 : Symbol(classType2Object1, Decl(escapedIdentifiers.ts, 46, 3)) ->foo2 : Symbol(classType\u0032.foo2, Decl(escapedIdentifiers.ts, 38, 23)) - -var classType2Object2 = new classType\u0032(); ->classType2Object2 : Symbol(classType2Object2, Decl(escapedIdentifiers.ts, 48, 3)) ->classType\u0032 : Symbol(classType\u0032, Decl(escapedIdentifiers.ts, 37, 1)) - -classType2Object2.foo2 = 2; ->classType2Object2.foo2 : Symbol(classType\u0032.foo2, Decl(escapedIdentifiers.ts, 38, 23)) ->classType2Object2 : Symbol(classType2Object2, Decl(escapedIdentifiers.ts, 48, 3)) ->foo2 : Symbol(classType\u0032.foo2, Decl(escapedIdentifiers.ts, 38, 23)) - -// interfaces -interface interfaceType1 { ->interfaceType1 : Symbol(interfaceType1, Decl(escapedIdentifiers.ts, 49, 27)) - - bar1: number; ->bar1 : Symbol(bar1, Decl(escapedIdentifiers.ts, 52, 26)) -} -interface interfaceType\u0032 { ->interfaceType\u0032 : Symbol(interfaceType\u0032, Decl(escapedIdentifiers.ts, 54, 1)) - - bar2: number; ->bar2 : Symbol(bar2, Decl(escapedIdentifiers.ts, 55, 31)) -} - -var interfaceType1Object1 = { bar1: 0 }; ->interfaceType1Object1 : Symbol(interfaceType1Object1, Decl(escapedIdentifiers.ts, 59, 3)) ->interfaceType1 : Symbol(interfaceType1, Decl(escapedIdentifiers.ts, 49, 27)) ->bar1 : Symbol(bar1, Decl(escapedIdentifiers.ts, 59, 45)) - -interfaceType1Object1.bar1 = 2; ->interfaceType1Object1.bar1 : Symbol(interfaceType1.bar1, Decl(escapedIdentifiers.ts, 52, 26)) ->interfaceType1Object1 : Symbol(interfaceType1Object1, Decl(escapedIdentifiers.ts, 59, 3)) ->bar1 : Symbol(interfaceType1.bar1, Decl(escapedIdentifiers.ts, 52, 26)) - -var interfaceType1Object2 = { bar1: 0 }; ->interfaceType1Object2 : Symbol(interfaceType1Object2, Decl(escapedIdentifiers.ts, 61, 3)) ->interfaceType\u0031 : Symbol(interfaceType1, Decl(escapedIdentifiers.ts, 49, 27)) ->bar1 : Symbol(bar1, Decl(escapedIdentifiers.ts, 61, 50)) - -interfaceType1Object2.bar1 = 2; ->interfaceType1Object2.bar1 : Symbol(interfaceType1.bar1, Decl(escapedIdentifiers.ts, 52, 26)) ->interfaceType1Object2 : Symbol(interfaceType1Object2, Decl(escapedIdentifiers.ts, 61, 3)) ->bar1 : Symbol(interfaceType1.bar1, Decl(escapedIdentifiers.ts, 52, 26)) - -var interfaceType2Object1 = { bar2: 0 }; ->interfaceType2Object1 : Symbol(interfaceType2Object1, Decl(escapedIdentifiers.ts, 63, 3)) ->interfaceType2 : Symbol(interfaceType\u0032, Decl(escapedIdentifiers.ts, 54, 1)) ->bar2 : Symbol(bar2, Decl(escapedIdentifiers.ts, 63, 45)) - -interfaceType2Object1.bar2 = 2; ->interfaceType2Object1.bar2 : Symbol(interfaceType\u0032.bar2, Decl(escapedIdentifiers.ts, 55, 31)) ->interfaceType2Object1 : Symbol(interfaceType2Object1, Decl(escapedIdentifiers.ts, 63, 3)) ->bar2 : Symbol(interfaceType\u0032.bar2, Decl(escapedIdentifiers.ts, 55, 31)) - -var interfaceType2Object2 = { bar2: 0 }; ->interfaceType2Object2 : Symbol(interfaceType2Object2, Decl(escapedIdentifiers.ts, 65, 3)) ->interfaceType\u0032 : Symbol(interfaceType\u0032, Decl(escapedIdentifiers.ts, 54, 1)) ->bar2 : Symbol(bar2, Decl(escapedIdentifiers.ts, 65, 50)) - -interfaceType2Object2.bar2 = 2; ->interfaceType2Object2.bar2 : Symbol(interfaceType\u0032.bar2, Decl(escapedIdentifiers.ts, 55, 31)) ->interfaceType2Object2 : Symbol(interfaceType2Object2, Decl(escapedIdentifiers.ts, 65, 3)) ->bar2 : Symbol(interfaceType\u0032.bar2, Decl(escapedIdentifiers.ts, 55, 31)) - - -// arguments -class testClass { ->testClass : Symbol(testClass, Decl(escapedIdentifiers.ts, 66, 31)) - - public func(arg1: number, arg\u0032: string, arg\u0033: boolean, arg4: number) { ->func : Symbol(func, Decl(escapedIdentifiers.ts, 70, 17)) ->arg1 : Symbol(arg1, Decl(escapedIdentifiers.ts, 71, 16)) ->arg\u0032 : Symbol(arg\u0032, Decl(escapedIdentifiers.ts, 71, 29)) ->arg\u0033 : Symbol(arg\u0033, Decl(escapedIdentifiers.ts, 71, 48)) ->arg4 : Symbol(arg4, Decl(escapedIdentifiers.ts, 71, 68)) - - arg\u0031 = 1; ->arg\u0031 : Symbol(arg1, Decl(escapedIdentifiers.ts, 71, 16)) - - arg2 = 'string'; ->arg2 : Symbol(arg\u0032, Decl(escapedIdentifiers.ts, 71, 29)) - - arg\u0033 = true; ->arg\u0033 : Symbol(arg\u0033, Decl(escapedIdentifiers.ts, 71, 48)) - - arg4 = 2; ->arg4 : Symbol(arg4, Decl(escapedIdentifiers.ts, 71, 68)) - } -} - -// constructors -class constructorTestClass { ->constructorTestClass : Symbol(constructorTestClass, Decl(escapedIdentifiers.ts, 77, 1)) - - constructor (public arg1: number,public arg\u0032: string,public arg\u0033: boolean,public arg4: number) { ->arg1 : Symbol(arg1, Decl(escapedIdentifiers.ts, 81, 17)) ->arg\u0032 : Symbol(arg\u0032, Decl(escapedIdentifiers.ts, 81, 37)) ->arg\u0033 : Symbol(arg\u0033, Decl(escapedIdentifiers.ts, 81, 62)) ->arg4 : Symbol(arg4, Decl(escapedIdentifiers.ts, 81, 88)) - } -} -var constructorTestObject = new constructorTestClass(1, 'string', true, 2); ->constructorTestObject : Symbol(constructorTestObject, Decl(escapedIdentifiers.ts, 84, 3)) ->constructorTestClass : Symbol(constructorTestClass, Decl(escapedIdentifiers.ts, 77, 1)) - -constructorTestObject.arg\u0031 = 1; ->constructorTestObject.arg\u0031 : Symbol(constructorTestClass.arg1, Decl(escapedIdentifiers.ts, 81, 17)) ->constructorTestObject : Symbol(constructorTestObject, Decl(escapedIdentifiers.ts, 84, 3)) ->arg\u0031 : Symbol(constructorTestClass.arg1, Decl(escapedIdentifiers.ts, 81, 17)) - -constructorTestObject.arg2 = 'string'; ->constructorTestObject.arg2 : Symbol(constructorTestClass.arg\u0032, Decl(escapedIdentifiers.ts, 81, 37)) ->constructorTestObject : Symbol(constructorTestObject, Decl(escapedIdentifiers.ts, 84, 3)) ->arg2 : Symbol(constructorTestClass.arg\u0032, Decl(escapedIdentifiers.ts, 81, 37)) - -constructorTestObject.arg\u0033 = true; ->constructorTestObject.arg\u0033 : Symbol(constructorTestClass.arg\u0033, Decl(escapedIdentifiers.ts, 81, 62)) ->constructorTestObject : Symbol(constructorTestObject, Decl(escapedIdentifiers.ts, 84, 3)) ->arg\u0033 : Symbol(constructorTestClass.arg\u0033, Decl(escapedIdentifiers.ts, 81, 62)) - -constructorTestObject.arg4 = 2; ->constructorTestObject.arg4 : Symbol(constructorTestClass.arg4, Decl(escapedIdentifiers.ts, 81, 88)) ->constructorTestObject : Symbol(constructorTestObject, Decl(escapedIdentifiers.ts, 84, 3)) ->arg4 : Symbol(constructorTestClass.arg4, Decl(escapedIdentifiers.ts, 81, 88)) - -// Lables - -l\u0061bel1: - while (false) - { - while(false) - continue label1; // it will go to next iteration of outer loop - } - -label2: - while (false) - { - while(false) - continue l\u0061bel2; // it will go to next iteration of outer loop - } - -label3: - while (false) - { - while(false) - continue label3; // it will go to next iteration of outer loop - } - -l\u0061bel4: - while (false) - { - while(false) - continue l\u0061bel4; // it will go to next iteration of outer loop - } diff --git a/tests/baselines/reference/escapedIdentifiers.types b/tests/baselines/reference/escapedIdentifiers.types deleted file mode 100644 index b32d21a48cb..00000000000 --- a/tests/baselines/reference/escapedIdentifiers.types +++ /dev/null @@ -1,351 +0,0 @@ -=== tests/cases/compiler/escapedIdentifiers.ts === -/* - 0 .. \u0030 - 9 .. \u0039 - - A .. \u0041 - Z .. \u005a - - a .. \u0061 - z .. \u00za -*/ - -// var decl -var \u0061 = 1; ->\u0061 : number ->1 : number - -a ++; ->a ++ : number ->a : number - -\u0061 ++; ->\u0061 ++ : number ->\u0061 : number - -var b = 1; ->b : number ->1 : number - -b ++; ->b ++ : number ->b : number - -\u0062 ++; ->\u0062 ++ : number ->\u0062 : number - -// modules -module moduleType1 { ->moduleType1 : typeof moduleType1 - - export var baz1: number; ->baz1 : number -} -module moduleType\u0032 { ->moduleType\u0032 : typeof moduleType\u0032 - - export var baz2: number; ->baz2 : number -} - -moduleType1.baz1 = 3; ->moduleType1.baz1 = 3 : number ->moduleType1.baz1 : number ->moduleType1 : typeof moduleType1 ->baz1 : number ->3 : number - -moduleType\u0031.baz1 = 3; ->moduleType\u0031.baz1 = 3 : number ->moduleType\u0031.baz1 : number ->moduleType\u0031 : typeof moduleType1 ->baz1 : number ->3 : number - -moduleType2.baz2 = 3; ->moduleType2.baz2 = 3 : number ->moduleType2.baz2 : number ->moduleType2 : typeof moduleType\u0032 ->baz2 : number ->3 : number - -moduleType\u0032.baz2 = 3; ->moduleType\u0032.baz2 = 3 : number ->moduleType\u0032.baz2 : number ->moduleType\u0032 : typeof moduleType\u0032 ->baz2 : number ->3 : number - -// classes - -class classType1 { ->classType1 : classType1 - - public foo1: number; ->foo1 : number -} -class classType\u0032 { ->classType\u0032 : classType\u0032 - - public foo2: number; ->foo2 : number -} - -var classType1Object1 = new classType1(); ->classType1Object1 : classType1 ->new classType1() : classType1 ->classType1 : typeof classType1 - -classType1Object1.foo1 = 2; ->classType1Object1.foo1 = 2 : number ->classType1Object1.foo1 : number ->classType1Object1 : classType1 ->foo1 : number ->2 : number - -var classType1Object2 = new classType\u0031(); ->classType1Object2 : classType1 ->new classType\u0031() : classType1 ->classType\u0031 : typeof classType1 - -classType1Object2.foo1 = 2; ->classType1Object2.foo1 = 2 : number ->classType1Object2.foo1 : number ->classType1Object2 : classType1 ->foo1 : number ->2 : number - -var classType2Object1 = new classType2(); ->classType2Object1 : classType\u0032 ->new classType2() : classType\u0032 ->classType2 : typeof classType\u0032 - -classType2Object1.foo2 = 2; ->classType2Object1.foo2 = 2 : number ->classType2Object1.foo2 : number ->classType2Object1 : classType\u0032 ->foo2 : number ->2 : number - -var classType2Object2 = new classType\u0032(); ->classType2Object2 : classType\u0032 ->new classType\u0032() : classType\u0032 ->classType\u0032 : typeof classType\u0032 - -classType2Object2.foo2 = 2; ->classType2Object2.foo2 = 2 : number ->classType2Object2.foo2 : number ->classType2Object2 : classType\u0032 ->foo2 : number ->2 : number - -// interfaces -interface interfaceType1 { ->interfaceType1 : interfaceType1 - - bar1: number; ->bar1 : number -} -interface interfaceType\u0032 { ->interfaceType\u0032 : interfaceType\u0032 - - bar2: number; ->bar2 : number -} - -var interfaceType1Object1 = { bar1: 0 }; ->interfaceType1Object1 : interfaceType1 ->{ bar1: 0 } : interfaceType1 ->interfaceType1 : interfaceType1 ->{ bar1: 0 } : { bar1: number; } ->bar1 : number ->0 : number - -interfaceType1Object1.bar1 = 2; ->interfaceType1Object1.bar1 = 2 : number ->interfaceType1Object1.bar1 : number ->interfaceType1Object1 : interfaceType1 ->bar1 : number ->2 : number - -var interfaceType1Object2 = { bar1: 0 }; ->interfaceType1Object2 : interfaceType1 ->{ bar1: 0 } : interfaceType1 ->interfaceType\u0031 : interfaceType1 ->{ bar1: 0 } : { bar1: number; } ->bar1 : number ->0 : number - -interfaceType1Object2.bar1 = 2; ->interfaceType1Object2.bar1 = 2 : number ->interfaceType1Object2.bar1 : number ->interfaceType1Object2 : interfaceType1 ->bar1 : number ->2 : number - -var interfaceType2Object1 = { bar2: 0 }; ->interfaceType2Object1 : interfaceType\u0032 ->{ bar2: 0 } : interfaceType\u0032 ->interfaceType2 : interfaceType\u0032 ->{ bar2: 0 } : { bar2: number; } ->bar2 : number ->0 : number - -interfaceType2Object1.bar2 = 2; ->interfaceType2Object1.bar2 = 2 : number ->interfaceType2Object1.bar2 : number ->interfaceType2Object1 : interfaceType\u0032 ->bar2 : number ->2 : number - -var interfaceType2Object2 = { bar2: 0 }; ->interfaceType2Object2 : interfaceType\u0032 ->{ bar2: 0 } : interfaceType\u0032 ->interfaceType\u0032 : interfaceType\u0032 ->{ bar2: 0 } : { bar2: number; } ->bar2 : number ->0 : number - -interfaceType2Object2.bar2 = 2; ->interfaceType2Object2.bar2 = 2 : number ->interfaceType2Object2.bar2 : number ->interfaceType2Object2 : interfaceType\u0032 ->bar2 : number ->2 : number - - -// arguments -class testClass { ->testClass : testClass - - public func(arg1: number, arg\u0032: string, arg\u0033: boolean, arg4: number) { ->func : (arg1: number, arg\u0032: string, arg\u0033: boolean, arg4: number) => void ->arg1 : number ->arg\u0032 : string ->arg\u0033 : boolean ->arg4 : number - - arg\u0031 = 1; ->arg\u0031 = 1 : number ->arg\u0031 : number ->1 : number - - arg2 = 'string'; ->arg2 = 'string' : string ->arg2 : string ->'string' : string - - arg\u0033 = true; ->arg\u0033 = true : boolean ->arg\u0033 : boolean ->true : boolean - - arg4 = 2; ->arg4 = 2 : number ->arg4 : number ->2 : number - } -} - -// constructors -class constructorTestClass { ->constructorTestClass : constructorTestClass - - constructor (public arg1: number,public arg\u0032: string,public arg\u0033: boolean,public arg4: number) { ->arg1 : number ->arg\u0032 : string ->arg\u0033 : boolean ->arg4 : number - } -} -var constructorTestObject = new constructorTestClass(1, 'string', true, 2); ->constructorTestObject : constructorTestClass ->new constructorTestClass(1, 'string', true, 2) : constructorTestClass ->constructorTestClass : typeof constructorTestClass ->1 : number ->'string' : string ->true : boolean ->2 : number - -constructorTestObject.arg\u0031 = 1; ->constructorTestObject.arg\u0031 = 1 : number ->constructorTestObject.arg\u0031 : number ->constructorTestObject : constructorTestClass ->arg\u0031 : number ->1 : number - -constructorTestObject.arg2 = 'string'; ->constructorTestObject.arg2 = 'string' : string ->constructorTestObject.arg2 : string ->constructorTestObject : constructorTestClass ->arg2 : string ->'string' : string - -constructorTestObject.arg\u0033 = true; ->constructorTestObject.arg\u0033 = true : boolean ->constructorTestObject.arg\u0033 : boolean ->constructorTestObject : constructorTestClass ->arg\u0033 : boolean ->true : boolean - -constructorTestObject.arg4 = 2; ->constructorTestObject.arg4 = 2 : number ->constructorTestObject.arg4 : number ->constructorTestObject : constructorTestClass ->arg4 : number ->2 : number - -// Lables - -l\u0061bel1: ->l\u0061bel1 : any - - while (false) ->false : boolean - { - while(false) ->false : boolean - - continue label1; // it will go to next iteration of outer loop ->label1 : any - } - -label2: ->label2 : any - - while (false) ->false : boolean - { - while(false) ->false : boolean - - continue l\u0061bel2; // it will go to next iteration of outer loop ->l\u0061bel2 : any - } - -label3: ->label3 : any - - while (false) ->false : boolean - { - while(false) ->false : boolean - - continue label3; // it will go to next iteration of outer loop ->label3 : any - } - -l\u0061bel4: ->l\u0061bel4 : any - - while (false) ->false : boolean - { - while(false) ->false : boolean - - continue l\u0061bel4; // it will go to next iteration of outer loop ->l\u0061bel4 : any - } diff --git a/tests/baselines/reference/for.errors.txt b/tests/baselines/reference/for.errors.txt index 41ed5765c9a..34de6a4b114 100644 --- a/tests/baselines/reference/for.errors.txt +++ b/tests/baselines/reference/for.errors.txt @@ -1,7 +1,8 @@ +tests/cases/compiler/for.ts(29,1): error TS7027: Unreachable code detected. tests/cases/compiler/for.ts(29,6): error TS1109: Expression expected. -==== tests/cases/compiler/for.ts (1 errors) ==== +==== tests/cases/compiler/for.ts (2 errors) ==== for (var i = 0; i < 10; i++) { // ok var x1 = i; } @@ -31,6 +32,8 @@ tests/cases/compiler/for.ts(29,6): error TS1109: Expression expected. } for () { // error + ~~~ +!!! error TS7027: Unreachable code detected. ~ !!! error TS1109: Expression expected. } \ No newline at end of file diff --git a/tests/baselines/reference/forBreakStatements.errors.txt b/tests/baselines/reference/forBreakStatements.errors.txt new file mode 100644 index 00000000000..2b42afc9be2 --- /dev/null +++ b/tests/baselines/reference/forBreakStatements.errors.txt @@ -0,0 +1,49 @@ +tests/cases/conformance/statements/breakStatements/forBreakStatements.ts(10,1): error TS7028: Unused label. +tests/cases/conformance/statements/breakStatements/forBreakStatements.ts(18,5): error TS7028: Unused label. +tests/cases/conformance/statements/breakStatements/forBreakStatements.ts(29,1): error TS7027: Unreachable code detected. + + +==== tests/cases/conformance/statements/breakStatements/forBreakStatements.ts (3 errors) ==== + for (; ;) { + break; + } + + ONE: + for (; ;) { + break ONE; + } + + TWO: + ~~~ +!!! error TS7028: Unused label. + THREE: + for (; ;) { + break THREE; + } + + FOUR: + for (; ;) { + FIVE: + ~~~~ +!!! error TS7028: Unused label. + for (; ;) { + break FOUR; + } + } + + for (; ;) { + SIX: + for (; ;) break SIX; + } + + SEVEN: + ~~~~~ +!!! error TS7027: Unreachable code detected. + for (; ;) for (; ;) for (; ;) break SEVEN; + + EIGHT: + for (; ;) { + var fn = function () { } + break EIGHT; + } + \ No newline at end of file diff --git a/tests/baselines/reference/forBreakStatements.symbols b/tests/baselines/reference/forBreakStatements.symbols deleted file mode 100644 index 76db9309a39..00000000000 --- a/tests/baselines/reference/forBreakStatements.symbols +++ /dev/null @@ -1,40 +0,0 @@ -=== tests/cases/conformance/statements/breakStatements/forBreakStatements.ts === -for (; ;) { - break; -} - -ONE: -for (; ;) { - break ONE; -} - -TWO: -THREE: -for (; ;) { - break THREE; -} - -FOUR: -for (; ;) { - FIVE: - for (; ;) { - break FOUR; - } -} - -for (; ;) { - SIX: - for (; ;) break SIX; -} - -SEVEN: -for (; ;) for (; ;) for (; ;) break SEVEN; - -EIGHT: -for (; ;) { - var fn = function () { } ->fn : Symbol(fn, Decl(forBreakStatements.ts, 33, 7)) - - break EIGHT; -} - diff --git a/tests/baselines/reference/forBreakStatements.types b/tests/baselines/reference/forBreakStatements.types deleted file mode 100644 index 8469a85bd19..00000000000 --- a/tests/baselines/reference/forBreakStatements.types +++ /dev/null @@ -1,63 +0,0 @@ -=== tests/cases/conformance/statements/breakStatements/forBreakStatements.ts === -for (; ;) { - break; -} - -ONE: ->ONE : any - -for (; ;) { - break ONE; ->ONE : any -} - -TWO: ->TWO : any - -THREE: ->THREE : any - -for (; ;) { - break THREE; ->THREE : any -} - -FOUR: ->FOUR : any - -for (; ;) { - FIVE: ->FIVE : any - - for (; ;) { - break FOUR; ->FOUR : any - } -} - -for (; ;) { - SIX: ->SIX : any - - for (; ;) break SIX; ->SIX : any -} - -SEVEN: ->SEVEN : any - -for (; ;) for (; ;) for (; ;) break SEVEN; ->SEVEN : any - -EIGHT: ->EIGHT : any - -for (; ;) { - var fn = function () { } ->fn : () => void ->function () { } : () => void - - break EIGHT; ->EIGHT : any -} - diff --git a/tests/baselines/reference/forContinueStatements.errors.txt b/tests/baselines/reference/forContinueStatements.errors.txt new file mode 100644 index 00000000000..b7a4cc35546 --- /dev/null +++ b/tests/baselines/reference/forContinueStatements.errors.txt @@ -0,0 +1,43 @@ +tests/cases/conformance/statements/continueStatements/forContinueStatements.ts(5,1): error TS7027: Unreachable code detected. + + +==== tests/cases/conformance/statements/continueStatements/forContinueStatements.ts (1 errors) ==== + for (; ;) { + continue; + } + + ONE: + ~~~ +!!! error TS7027: Unreachable code detected. + for (; ;) { + continue ONE; + } + + TWO: + THREE: + for (; ;) { + continue THREE; + } + + FOUR: + for (; ;) { + FIVE: + for (; ;) { + continue FOUR; + } + } + + for (; ;) { + SIX: + for (; ;) continue SIX; + } + + SEVEN: + for (; ;) for (; ;) for (; ;) continue SEVEN; + + EIGHT: + for (; ;) { + var fn = function () { } + continue EIGHT; + } + \ No newline at end of file diff --git a/tests/baselines/reference/forContinueStatements.symbols b/tests/baselines/reference/forContinueStatements.symbols deleted file mode 100644 index e24eb2aaa92..00000000000 --- a/tests/baselines/reference/forContinueStatements.symbols +++ /dev/null @@ -1,40 +0,0 @@ -=== tests/cases/conformance/statements/continueStatements/forContinueStatements.ts === -for (; ;) { - continue; -} - -ONE: -for (; ;) { - continue ONE; -} - -TWO: -THREE: -for (; ;) { - continue THREE; -} - -FOUR: -for (; ;) { - FIVE: - for (; ;) { - continue FOUR; - } -} - -for (; ;) { - SIX: - for (; ;) continue SIX; -} - -SEVEN: -for (; ;) for (; ;) for (; ;) continue SEVEN; - -EIGHT: -for (; ;) { - var fn = function () { } ->fn : Symbol(fn, Decl(forContinueStatements.ts, 33, 7)) - - continue EIGHT; -} - diff --git a/tests/baselines/reference/forContinueStatements.types b/tests/baselines/reference/forContinueStatements.types deleted file mode 100644 index 79b78e83345..00000000000 --- a/tests/baselines/reference/forContinueStatements.types +++ /dev/null @@ -1,63 +0,0 @@ -=== tests/cases/conformance/statements/continueStatements/forContinueStatements.ts === -for (; ;) { - continue; -} - -ONE: ->ONE : any - -for (; ;) { - continue ONE; ->ONE : any -} - -TWO: ->TWO : any - -THREE: ->THREE : any - -for (; ;) { - continue THREE; ->THREE : any -} - -FOUR: ->FOUR : any - -for (; ;) { - FIVE: ->FIVE : any - - for (; ;) { - continue FOUR; ->FOUR : any - } -} - -for (; ;) { - SIX: ->SIX : any - - for (; ;) continue SIX; ->SIX : any -} - -SEVEN: ->SEVEN : any - -for (; ;) for (; ;) for (; ;) continue SEVEN; ->SEVEN : any - -EIGHT: ->EIGHT : any - -for (; ;) { - var fn = function () { } ->fn : () => void ->function () { } : () => void - - continue EIGHT; ->EIGHT : any -} - diff --git a/tests/baselines/reference/forInBreakStatements.errors.txt b/tests/baselines/reference/forInBreakStatements.errors.txt new file mode 100644 index 00000000000..8bbbf2d38ee --- /dev/null +++ b/tests/baselines/reference/forInBreakStatements.errors.txt @@ -0,0 +1,46 @@ +tests/cases/conformance/statements/breakStatements/forInBreakStatements.ts(10,1): error TS7028: Unused label. +tests/cases/conformance/statements/breakStatements/forInBreakStatements.ts(18,5): error TS7028: Unused label. + + +==== tests/cases/conformance/statements/breakStatements/forInBreakStatements.ts (2 errors) ==== + for(var x in {}) { + break; + } + + ONE: + for(var x in {}) { + break ONE; + } + + TWO: + ~~~ +!!! error TS7028: Unused label. + THREE: + for(var x in {}) { + break THREE; + } + + FOUR: + for(var x in {}) { + FIVE: + ~~~~ +!!! error TS7028: Unused label. + for(var x in {}) { + break FOUR; + } + } + + for(var x in {}) { + SIX: + for(var x in {}) break SIX; + } + + SEVEN: + for (var x in {}) for (var x in {}) for (var x in {}) break SEVEN; + + EIGHT: + for (var x in {}){ + var fn = function () { } + break EIGHT; + } + \ No newline at end of file diff --git a/tests/baselines/reference/forInBreakStatements.symbols b/tests/baselines/reference/forInBreakStatements.symbols deleted file mode 100644 index 7984edc3fd6..00000000000 --- a/tests/baselines/reference/forInBreakStatements.symbols +++ /dev/null @@ -1,58 +0,0 @@ -=== tests/cases/conformance/statements/breakStatements/forInBreakStatements.ts === -for(var x in {}) { ->x : Symbol(x, Decl(forInBreakStatements.ts, 0, 7), Decl(forInBreakStatements.ts, 5, 7), Decl(forInBreakStatements.ts, 11, 7), Decl(forInBreakStatements.ts, 16, 7), Decl(forInBreakStatements.ts, 18, 11), Decl(forInBreakStatements.ts, 23, 7), Decl(forInBreakStatements.ts, 25, 11), Decl(forInBreakStatements.ts, 29, 8), Decl(forInBreakStatements.ts, 29, 26), Decl(forInBreakStatements.ts, 29, 44), Decl(forInBreakStatements.ts, 32, 8)) - - break; -} - -ONE: -for(var x in {}) { ->x : Symbol(x, Decl(forInBreakStatements.ts, 0, 7), Decl(forInBreakStatements.ts, 5, 7), Decl(forInBreakStatements.ts, 11, 7), Decl(forInBreakStatements.ts, 16, 7), Decl(forInBreakStatements.ts, 18, 11), Decl(forInBreakStatements.ts, 23, 7), Decl(forInBreakStatements.ts, 25, 11), Decl(forInBreakStatements.ts, 29, 8), Decl(forInBreakStatements.ts, 29, 26), Decl(forInBreakStatements.ts, 29, 44), Decl(forInBreakStatements.ts, 32, 8)) - - break ONE; -} - -TWO: -THREE: -for(var x in {}) { ->x : Symbol(x, Decl(forInBreakStatements.ts, 0, 7), Decl(forInBreakStatements.ts, 5, 7), Decl(forInBreakStatements.ts, 11, 7), Decl(forInBreakStatements.ts, 16, 7), Decl(forInBreakStatements.ts, 18, 11), Decl(forInBreakStatements.ts, 23, 7), Decl(forInBreakStatements.ts, 25, 11), Decl(forInBreakStatements.ts, 29, 8), Decl(forInBreakStatements.ts, 29, 26), Decl(forInBreakStatements.ts, 29, 44), Decl(forInBreakStatements.ts, 32, 8)) - - break THREE; -} - -FOUR: -for(var x in {}) { ->x : Symbol(x, Decl(forInBreakStatements.ts, 0, 7), Decl(forInBreakStatements.ts, 5, 7), Decl(forInBreakStatements.ts, 11, 7), Decl(forInBreakStatements.ts, 16, 7), Decl(forInBreakStatements.ts, 18, 11), Decl(forInBreakStatements.ts, 23, 7), Decl(forInBreakStatements.ts, 25, 11), Decl(forInBreakStatements.ts, 29, 8), Decl(forInBreakStatements.ts, 29, 26), Decl(forInBreakStatements.ts, 29, 44), Decl(forInBreakStatements.ts, 32, 8)) - - FIVE: - for(var x in {}) { ->x : Symbol(x, Decl(forInBreakStatements.ts, 0, 7), Decl(forInBreakStatements.ts, 5, 7), Decl(forInBreakStatements.ts, 11, 7), Decl(forInBreakStatements.ts, 16, 7), Decl(forInBreakStatements.ts, 18, 11), Decl(forInBreakStatements.ts, 23, 7), Decl(forInBreakStatements.ts, 25, 11), Decl(forInBreakStatements.ts, 29, 8), Decl(forInBreakStatements.ts, 29, 26), Decl(forInBreakStatements.ts, 29, 44), Decl(forInBreakStatements.ts, 32, 8)) - - break FOUR; - } -} - -for(var x in {}) { ->x : Symbol(x, Decl(forInBreakStatements.ts, 0, 7), Decl(forInBreakStatements.ts, 5, 7), Decl(forInBreakStatements.ts, 11, 7), Decl(forInBreakStatements.ts, 16, 7), Decl(forInBreakStatements.ts, 18, 11), Decl(forInBreakStatements.ts, 23, 7), Decl(forInBreakStatements.ts, 25, 11), Decl(forInBreakStatements.ts, 29, 8), Decl(forInBreakStatements.ts, 29, 26), Decl(forInBreakStatements.ts, 29, 44), Decl(forInBreakStatements.ts, 32, 8)) - - SIX: - for(var x in {}) break SIX; ->x : Symbol(x, Decl(forInBreakStatements.ts, 0, 7), Decl(forInBreakStatements.ts, 5, 7), Decl(forInBreakStatements.ts, 11, 7), Decl(forInBreakStatements.ts, 16, 7), Decl(forInBreakStatements.ts, 18, 11), Decl(forInBreakStatements.ts, 23, 7), Decl(forInBreakStatements.ts, 25, 11), Decl(forInBreakStatements.ts, 29, 8), Decl(forInBreakStatements.ts, 29, 26), Decl(forInBreakStatements.ts, 29, 44), Decl(forInBreakStatements.ts, 32, 8)) -} - -SEVEN: -for (var x in {}) for (var x in {}) for (var x in {}) break SEVEN; ->x : Symbol(x, Decl(forInBreakStatements.ts, 0, 7), Decl(forInBreakStatements.ts, 5, 7), Decl(forInBreakStatements.ts, 11, 7), Decl(forInBreakStatements.ts, 16, 7), Decl(forInBreakStatements.ts, 18, 11), Decl(forInBreakStatements.ts, 23, 7), Decl(forInBreakStatements.ts, 25, 11), Decl(forInBreakStatements.ts, 29, 8), Decl(forInBreakStatements.ts, 29, 26), Decl(forInBreakStatements.ts, 29, 44), Decl(forInBreakStatements.ts, 32, 8)) ->x : Symbol(x, Decl(forInBreakStatements.ts, 0, 7), Decl(forInBreakStatements.ts, 5, 7), Decl(forInBreakStatements.ts, 11, 7), Decl(forInBreakStatements.ts, 16, 7), Decl(forInBreakStatements.ts, 18, 11), Decl(forInBreakStatements.ts, 23, 7), Decl(forInBreakStatements.ts, 25, 11), Decl(forInBreakStatements.ts, 29, 8), Decl(forInBreakStatements.ts, 29, 26), Decl(forInBreakStatements.ts, 29, 44), Decl(forInBreakStatements.ts, 32, 8)) ->x : Symbol(x, Decl(forInBreakStatements.ts, 0, 7), Decl(forInBreakStatements.ts, 5, 7), Decl(forInBreakStatements.ts, 11, 7), Decl(forInBreakStatements.ts, 16, 7), Decl(forInBreakStatements.ts, 18, 11), Decl(forInBreakStatements.ts, 23, 7), Decl(forInBreakStatements.ts, 25, 11), Decl(forInBreakStatements.ts, 29, 8), Decl(forInBreakStatements.ts, 29, 26), Decl(forInBreakStatements.ts, 29, 44), Decl(forInBreakStatements.ts, 32, 8)) - -EIGHT: -for (var x in {}){ ->x : Symbol(x, Decl(forInBreakStatements.ts, 0, 7), Decl(forInBreakStatements.ts, 5, 7), Decl(forInBreakStatements.ts, 11, 7), Decl(forInBreakStatements.ts, 16, 7), Decl(forInBreakStatements.ts, 18, 11), Decl(forInBreakStatements.ts, 23, 7), Decl(forInBreakStatements.ts, 25, 11), Decl(forInBreakStatements.ts, 29, 8), Decl(forInBreakStatements.ts, 29, 26), Decl(forInBreakStatements.ts, 29, 44), Decl(forInBreakStatements.ts, 32, 8)) - - var fn = function () { } ->fn : Symbol(fn, Decl(forInBreakStatements.ts, 33, 7)) - - break EIGHT; -} - diff --git a/tests/baselines/reference/forInBreakStatements.types b/tests/baselines/reference/forInBreakStatements.types deleted file mode 100644 index 05ea8e35feb..00000000000 --- a/tests/baselines/reference/forInBreakStatements.types +++ /dev/null @@ -1,92 +0,0 @@ -=== tests/cases/conformance/statements/breakStatements/forInBreakStatements.ts === -for(var x in {}) { ->x : any ->{} : {} - - break; -} - -ONE: ->ONE : any - -for(var x in {}) { ->x : any ->{} : {} - - break ONE; ->ONE : any -} - -TWO: ->TWO : any - -THREE: ->THREE : any - -for(var x in {}) { ->x : any ->{} : {} - - break THREE; ->THREE : any -} - -FOUR: ->FOUR : any - -for(var x in {}) { ->x : any ->{} : {} - - FIVE: ->FIVE : any - - for(var x in {}) { ->x : any ->{} : {} - - break FOUR; ->FOUR : any - } -} - -for(var x in {}) { ->x : any ->{} : {} - - SIX: ->SIX : any - - for(var x in {}) break SIX; ->x : any ->{} : {} ->SIX : any -} - -SEVEN: ->SEVEN : any - -for (var x in {}) for (var x in {}) for (var x in {}) break SEVEN; ->x : any ->{} : {} ->x : any ->{} : {} ->x : any ->{} : {} ->SEVEN : any - -EIGHT: ->EIGHT : any - -for (var x in {}){ ->x : any ->{} : {} - - var fn = function () { } ->fn : () => void ->function () { } : () => void - - break EIGHT; ->EIGHT : any -} - diff --git a/tests/baselines/reference/forInContinueStatements.errors.txt b/tests/baselines/reference/forInContinueStatements.errors.txt new file mode 100644 index 00000000000..7a3a74e5aee --- /dev/null +++ b/tests/baselines/reference/forInContinueStatements.errors.txt @@ -0,0 +1,46 @@ +tests/cases/conformance/statements/continueStatements/forInContinueStatements.ts(10,1): error TS7028: Unused label. +tests/cases/conformance/statements/continueStatements/forInContinueStatements.ts(18,5): error TS7028: Unused label. + + +==== tests/cases/conformance/statements/continueStatements/forInContinueStatements.ts (2 errors) ==== + for(var x in {}) { + continue; + } + + ONE: + for(var x in {}) { + continue ONE; + } + + TWO: + ~~~ +!!! error TS7028: Unused label. + THREE: + for(var x in {}) { + continue THREE; + } + + FOUR: + for(var x in {}) { + FIVE: + ~~~~ +!!! error TS7028: Unused label. + for(var x in {}) { + continue FOUR; + } + } + + for(var x in {}) { + SIX: + for(var x in {}) continue SIX; + } + + SEVEN: + for (var x in {}) for (var x in {}) for (var x in {}) continue SEVEN; + + EIGHT: + for (var x in {}){ + var fn = function () { } + continue EIGHT; + } + \ No newline at end of file diff --git a/tests/baselines/reference/forInContinueStatements.symbols b/tests/baselines/reference/forInContinueStatements.symbols deleted file mode 100644 index 88129a50d21..00000000000 --- a/tests/baselines/reference/forInContinueStatements.symbols +++ /dev/null @@ -1,58 +0,0 @@ -=== tests/cases/conformance/statements/continueStatements/forInContinueStatements.ts === -for(var x in {}) { ->x : Symbol(x, Decl(forInContinueStatements.ts, 0, 7), Decl(forInContinueStatements.ts, 5, 7), Decl(forInContinueStatements.ts, 11, 7), Decl(forInContinueStatements.ts, 16, 7), Decl(forInContinueStatements.ts, 18, 11), Decl(forInContinueStatements.ts, 23, 7), Decl(forInContinueStatements.ts, 25, 11), Decl(forInContinueStatements.ts, 29, 8), Decl(forInContinueStatements.ts, 29, 26), Decl(forInContinueStatements.ts, 29, 44), Decl(forInContinueStatements.ts, 32, 8)) - - continue; -} - -ONE: -for(var x in {}) { ->x : Symbol(x, Decl(forInContinueStatements.ts, 0, 7), Decl(forInContinueStatements.ts, 5, 7), Decl(forInContinueStatements.ts, 11, 7), Decl(forInContinueStatements.ts, 16, 7), Decl(forInContinueStatements.ts, 18, 11), Decl(forInContinueStatements.ts, 23, 7), Decl(forInContinueStatements.ts, 25, 11), Decl(forInContinueStatements.ts, 29, 8), Decl(forInContinueStatements.ts, 29, 26), Decl(forInContinueStatements.ts, 29, 44), Decl(forInContinueStatements.ts, 32, 8)) - - continue ONE; -} - -TWO: -THREE: -for(var x in {}) { ->x : Symbol(x, Decl(forInContinueStatements.ts, 0, 7), Decl(forInContinueStatements.ts, 5, 7), Decl(forInContinueStatements.ts, 11, 7), Decl(forInContinueStatements.ts, 16, 7), Decl(forInContinueStatements.ts, 18, 11), Decl(forInContinueStatements.ts, 23, 7), Decl(forInContinueStatements.ts, 25, 11), Decl(forInContinueStatements.ts, 29, 8), Decl(forInContinueStatements.ts, 29, 26), Decl(forInContinueStatements.ts, 29, 44), Decl(forInContinueStatements.ts, 32, 8)) - - continue THREE; -} - -FOUR: -for(var x in {}) { ->x : Symbol(x, Decl(forInContinueStatements.ts, 0, 7), Decl(forInContinueStatements.ts, 5, 7), Decl(forInContinueStatements.ts, 11, 7), Decl(forInContinueStatements.ts, 16, 7), Decl(forInContinueStatements.ts, 18, 11), Decl(forInContinueStatements.ts, 23, 7), Decl(forInContinueStatements.ts, 25, 11), Decl(forInContinueStatements.ts, 29, 8), Decl(forInContinueStatements.ts, 29, 26), Decl(forInContinueStatements.ts, 29, 44), Decl(forInContinueStatements.ts, 32, 8)) - - FIVE: - for(var x in {}) { ->x : Symbol(x, Decl(forInContinueStatements.ts, 0, 7), Decl(forInContinueStatements.ts, 5, 7), Decl(forInContinueStatements.ts, 11, 7), Decl(forInContinueStatements.ts, 16, 7), Decl(forInContinueStatements.ts, 18, 11), Decl(forInContinueStatements.ts, 23, 7), Decl(forInContinueStatements.ts, 25, 11), Decl(forInContinueStatements.ts, 29, 8), Decl(forInContinueStatements.ts, 29, 26), Decl(forInContinueStatements.ts, 29, 44), Decl(forInContinueStatements.ts, 32, 8)) - - continue FOUR; - } -} - -for(var x in {}) { ->x : Symbol(x, Decl(forInContinueStatements.ts, 0, 7), Decl(forInContinueStatements.ts, 5, 7), Decl(forInContinueStatements.ts, 11, 7), Decl(forInContinueStatements.ts, 16, 7), Decl(forInContinueStatements.ts, 18, 11), Decl(forInContinueStatements.ts, 23, 7), Decl(forInContinueStatements.ts, 25, 11), Decl(forInContinueStatements.ts, 29, 8), Decl(forInContinueStatements.ts, 29, 26), Decl(forInContinueStatements.ts, 29, 44), Decl(forInContinueStatements.ts, 32, 8)) - - SIX: - for(var x in {}) continue SIX; ->x : Symbol(x, Decl(forInContinueStatements.ts, 0, 7), Decl(forInContinueStatements.ts, 5, 7), Decl(forInContinueStatements.ts, 11, 7), Decl(forInContinueStatements.ts, 16, 7), Decl(forInContinueStatements.ts, 18, 11), Decl(forInContinueStatements.ts, 23, 7), Decl(forInContinueStatements.ts, 25, 11), Decl(forInContinueStatements.ts, 29, 8), Decl(forInContinueStatements.ts, 29, 26), Decl(forInContinueStatements.ts, 29, 44), Decl(forInContinueStatements.ts, 32, 8)) -} - -SEVEN: -for (var x in {}) for (var x in {}) for (var x in {}) continue SEVEN; ->x : Symbol(x, Decl(forInContinueStatements.ts, 0, 7), Decl(forInContinueStatements.ts, 5, 7), Decl(forInContinueStatements.ts, 11, 7), Decl(forInContinueStatements.ts, 16, 7), Decl(forInContinueStatements.ts, 18, 11), Decl(forInContinueStatements.ts, 23, 7), Decl(forInContinueStatements.ts, 25, 11), Decl(forInContinueStatements.ts, 29, 8), Decl(forInContinueStatements.ts, 29, 26), Decl(forInContinueStatements.ts, 29, 44), Decl(forInContinueStatements.ts, 32, 8)) ->x : Symbol(x, Decl(forInContinueStatements.ts, 0, 7), Decl(forInContinueStatements.ts, 5, 7), Decl(forInContinueStatements.ts, 11, 7), Decl(forInContinueStatements.ts, 16, 7), Decl(forInContinueStatements.ts, 18, 11), Decl(forInContinueStatements.ts, 23, 7), Decl(forInContinueStatements.ts, 25, 11), Decl(forInContinueStatements.ts, 29, 8), Decl(forInContinueStatements.ts, 29, 26), Decl(forInContinueStatements.ts, 29, 44), Decl(forInContinueStatements.ts, 32, 8)) ->x : Symbol(x, Decl(forInContinueStatements.ts, 0, 7), Decl(forInContinueStatements.ts, 5, 7), Decl(forInContinueStatements.ts, 11, 7), Decl(forInContinueStatements.ts, 16, 7), Decl(forInContinueStatements.ts, 18, 11), Decl(forInContinueStatements.ts, 23, 7), Decl(forInContinueStatements.ts, 25, 11), Decl(forInContinueStatements.ts, 29, 8), Decl(forInContinueStatements.ts, 29, 26), Decl(forInContinueStatements.ts, 29, 44), Decl(forInContinueStatements.ts, 32, 8)) - -EIGHT: -for (var x in {}){ ->x : Symbol(x, Decl(forInContinueStatements.ts, 0, 7), Decl(forInContinueStatements.ts, 5, 7), Decl(forInContinueStatements.ts, 11, 7), Decl(forInContinueStatements.ts, 16, 7), Decl(forInContinueStatements.ts, 18, 11), Decl(forInContinueStatements.ts, 23, 7), Decl(forInContinueStatements.ts, 25, 11), Decl(forInContinueStatements.ts, 29, 8), Decl(forInContinueStatements.ts, 29, 26), Decl(forInContinueStatements.ts, 29, 44), Decl(forInContinueStatements.ts, 32, 8)) - - var fn = function () { } ->fn : Symbol(fn, Decl(forInContinueStatements.ts, 33, 7)) - - continue EIGHT; -} - diff --git a/tests/baselines/reference/forInContinueStatements.types b/tests/baselines/reference/forInContinueStatements.types deleted file mode 100644 index 95637345fa6..00000000000 --- a/tests/baselines/reference/forInContinueStatements.types +++ /dev/null @@ -1,92 +0,0 @@ -=== tests/cases/conformance/statements/continueStatements/forInContinueStatements.ts === -for(var x in {}) { ->x : any ->{} : {} - - continue; -} - -ONE: ->ONE : any - -for(var x in {}) { ->x : any ->{} : {} - - continue ONE; ->ONE : any -} - -TWO: ->TWO : any - -THREE: ->THREE : any - -for(var x in {}) { ->x : any ->{} : {} - - continue THREE; ->THREE : any -} - -FOUR: ->FOUR : any - -for(var x in {}) { ->x : any ->{} : {} - - FIVE: ->FIVE : any - - for(var x in {}) { ->x : any ->{} : {} - - continue FOUR; ->FOUR : any - } -} - -for(var x in {}) { ->x : any ->{} : {} - - SIX: ->SIX : any - - for(var x in {}) continue SIX; ->x : any ->{} : {} ->SIX : any -} - -SEVEN: ->SEVEN : any - -for (var x in {}) for (var x in {}) for (var x in {}) continue SEVEN; ->x : any ->{} : {} ->x : any ->{} : {} ->x : any ->{} : {} ->SEVEN : any - -EIGHT: ->EIGHT : any - -for (var x in {}){ ->x : any ->{} : {} - - var fn = function () { } ->fn : () => void ->function () { } : () => void - - continue EIGHT; ->EIGHT : any -} - diff --git a/tests/baselines/reference/forStatements.errors.txt b/tests/baselines/reference/forStatements.errors.txt new file mode 100644 index 00000000000..5f1e6f10c79 --- /dev/null +++ b/tests/baselines/reference/forStatements.errors.txt @@ -0,0 +1,52 @@ +tests/cases/conformance/statements/forStatements/forStatements.ts(26,1): error TS7027: Unreachable code detected. + + +==== tests/cases/conformance/statements/forStatements/forStatements.ts (1 errors) ==== + interface I { + id: number; + } + + class C implements I { + id: number; + } + + class D{ + source: T; + recurse: D; + wrapped: D> + } + + function F(x: string): number { return 42; } + + module M { + export class A { + name: string; + } + + export function F2(x: number): string { return x.toString(); } + } + + for(var aNumber: number = 9.9;;){} + for(var aString: string = 'this is a string';;){} + ~~~ +!!! error TS7027: Unreachable code detected. + for(var aDate: Date = new Date(12);;){} + for(var anObject: Object = new Object();;){} + + for(var anAny: any = null;;){} + for(var aSecondAny: any = undefined;;){} + for(var aVoid: void = undefined;;){} + + for(var anInterface: I = new C();;){} + for(var aClass: C = new C();;){} + for(var aGenericClass: D = new D();;){} + for(var anObjectLiteral: I = { id: 12 };;){} + for(var anOtherObjectLiteral: { id: number } = new C();;){} + + for(var aFunction: typeof F = F;;){} + for(var anOtherFunction: (x: string) => number = F;;){} + for(var aLambda: typeof F = (x) => 2;;){} + + for(var aModule: typeof M = M;;){} + for(var aClassInModule: M.A = new M.A();;){} + for(var aFunctionInModule: typeof M.F2 = (x) => 'this is a string';;){} \ No newline at end of file diff --git a/tests/baselines/reference/forStatements.symbols b/tests/baselines/reference/forStatements.symbols deleted file mode 100644 index 6f7c6d6cdbe..00000000000 --- a/tests/baselines/reference/forStatements.symbols +++ /dev/null @@ -1,145 +0,0 @@ -=== tests/cases/conformance/statements/forStatements/forStatements.ts === -interface I { ->I : Symbol(I, Decl(forStatements.ts, 0, 0)) - - id: number; ->id : Symbol(id, Decl(forStatements.ts, 0, 13)) -} - -class C implements I { ->C : Symbol(C, Decl(forStatements.ts, 2, 1)) ->I : Symbol(I, Decl(forStatements.ts, 0, 0)) - - id: number; ->id : Symbol(id, Decl(forStatements.ts, 4, 22)) -} - -class D{ ->D : Symbol(D, Decl(forStatements.ts, 6, 1)) ->T : Symbol(T, Decl(forStatements.ts, 8, 8)) - - source: T; ->source : Symbol(source, Decl(forStatements.ts, 8, 11)) ->T : Symbol(T, Decl(forStatements.ts, 8, 8)) - - recurse: D; ->recurse : Symbol(recurse, Decl(forStatements.ts, 9, 14)) ->D : Symbol(D, Decl(forStatements.ts, 6, 1)) ->T : Symbol(T, Decl(forStatements.ts, 8, 8)) - - wrapped: D> ->wrapped : Symbol(wrapped, Decl(forStatements.ts, 10, 18)) ->D : Symbol(D, Decl(forStatements.ts, 6, 1)) ->D : Symbol(D, Decl(forStatements.ts, 6, 1)) ->T : Symbol(T, Decl(forStatements.ts, 8, 8)) -} - -function F(x: string): number { return 42; } ->F : Symbol(F, Decl(forStatements.ts, 12, 1)) ->x : Symbol(x, Decl(forStatements.ts, 14, 11)) - -module M { ->M : Symbol(M, Decl(forStatements.ts, 14, 44)) - - export class A { ->A : Symbol(A, Decl(forStatements.ts, 16, 10)) - - name: string; ->name : Symbol(name, Decl(forStatements.ts, 17, 20)) - } - - export function F2(x: number): string { return x.toString(); } ->F2 : Symbol(F2, Decl(forStatements.ts, 19, 5)) ->x : Symbol(x, Decl(forStatements.ts, 21, 23)) ->x.toString : Symbol(Number.toString, Decl(lib.d.ts, 458, 18)) ->x : Symbol(x, Decl(forStatements.ts, 21, 23)) ->toString : Symbol(Number.toString, Decl(lib.d.ts, 458, 18)) -} - -for(var aNumber: number = 9.9;;){} ->aNumber : Symbol(aNumber, Decl(forStatements.ts, 24, 7)) - -for(var aString: string = 'this is a string';;){} ->aString : Symbol(aString, Decl(forStatements.ts, 25, 7)) - -for(var aDate: Date = new Date(12);;){} ->aDate : Symbol(aDate, Decl(forStatements.ts, 26, 7)) ->Date : Symbol(Date, Decl(lib.d.ts, 633, 23), Decl(lib.d.ts, 815, 11)) ->Date : Symbol(Date, Decl(lib.d.ts, 633, 23), Decl(lib.d.ts, 815, 11)) - -for(var anObject: Object = new Object();;){} ->anObject : Symbol(anObject, Decl(forStatements.ts, 27, 7)) ->Object : Symbol(Object, Decl(lib.d.ts, 92, 1), Decl(lib.d.ts, 223, 11)) ->Object : Symbol(Object, Decl(lib.d.ts, 92, 1), Decl(lib.d.ts, 223, 11)) - -for(var anAny: any = null;;){} ->anAny : Symbol(anAny, Decl(forStatements.ts, 29, 7)) - -for(var aSecondAny: any = undefined;;){} ->aSecondAny : Symbol(aSecondAny, Decl(forStatements.ts, 30, 7)) ->undefined : Symbol(undefined) - -for(var aVoid: void = undefined;;){} ->aVoid : Symbol(aVoid, Decl(forStatements.ts, 31, 7)) ->undefined : Symbol(undefined) - -for(var anInterface: I = new C();;){} ->anInterface : Symbol(anInterface, Decl(forStatements.ts, 33, 7)) ->I : Symbol(I, Decl(forStatements.ts, 0, 0)) ->C : Symbol(C, Decl(forStatements.ts, 2, 1)) - -for(var aClass: C = new C();;){} ->aClass : Symbol(aClass, Decl(forStatements.ts, 34, 7)) ->C : Symbol(C, Decl(forStatements.ts, 2, 1)) ->C : Symbol(C, Decl(forStatements.ts, 2, 1)) - -for(var aGenericClass: D = new D();;){} ->aGenericClass : Symbol(aGenericClass, Decl(forStatements.ts, 35, 7)) ->D : Symbol(D, Decl(forStatements.ts, 6, 1)) ->D : Symbol(D, Decl(forStatements.ts, 6, 1)) - -for(var anObjectLiteral: I = { id: 12 };;){} ->anObjectLiteral : Symbol(anObjectLiteral, Decl(forStatements.ts, 36, 7)) ->I : Symbol(I, Decl(forStatements.ts, 0, 0)) ->id : Symbol(id, Decl(forStatements.ts, 36, 30)) - -for(var anOtherObjectLiteral: { id: number } = new C();;){} ->anOtherObjectLiteral : Symbol(anOtherObjectLiteral, Decl(forStatements.ts, 37, 7)) ->id : Symbol(id, Decl(forStatements.ts, 37, 31)) ->C : Symbol(C, Decl(forStatements.ts, 2, 1)) - -for(var aFunction: typeof F = F;;){} ->aFunction : Symbol(aFunction, Decl(forStatements.ts, 39, 7)) ->F : Symbol(F, Decl(forStatements.ts, 12, 1)) ->F : Symbol(F, Decl(forStatements.ts, 12, 1)) - -for(var anOtherFunction: (x: string) => number = F;;){} ->anOtherFunction : Symbol(anOtherFunction, Decl(forStatements.ts, 40, 7)) ->x : Symbol(x, Decl(forStatements.ts, 40, 26)) ->F : Symbol(F, Decl(forStatements.ts, 12, 1)) - -for(var aLambda: typeof F = (x) => 2;;){} ->aLambda : Symbol(aLambda, Decl(forStatements.ts, 41, 7)) ->F : Symbol(F, Decl(forStatements.ts, 12, 1)) ->x : Symbol(x, Decl(forStatements.ts, 41, 29)) - -for(var aModule: typeof M = M;;){} ->aModule : Symbol(aModule, Decl(forStatements.ts, 43, 7)) ->M : Symbol(M, Decl(forStatements.ts, 14, 44)) ->M : Symbol(M, Decl(forStatements.ts, 14, 44)) - -for(var aClassInModule: M.A = new M.A();;){} ->aClassInModule : Symbol(aClassInModule, Decl(forStatements.ts, 44, 7)) ->M : Symbol(M, Decl(forStatements.ts, 14, 44)) ->A : Symbol(M.A, Decl(forStatements.ts, 16, 10)) ->M.A : Symbol(M.A, Decl(forStatements.ts, 16, 10)) ->M : Symbol(M, Decl(forStatements.ts, 14, 44)) ->A : Symbol(M.A, Decl(forStatements.ts, 16, 10)) - -for(var aFunctionInModule: typeof M.F2 = (x) => 'this is a string';;){} ->aFunctionInModule : Symbol(aFunctionInModule, Decl(forStatements.ts, 45, 7)) ->M.F2 : Symbol(M.F2, Decl(forStatements.ts, 19, 5)) ->M : Symbol(M, Decl(forStatements.ts, 14, 44)) ->F2 : Symbol(M.F2, Decl(forStatements.ts, 19, 5)) ->x : Symbol(x, Decl(forStatements.ts, 45, 42)) - diff --git a/tests/baselines/reference/forStatements.types b/tests/baselines/reference/forStatements.types deleted file mode 100644 index 3fbcf2dbfb2..00000000000 --- a/tests/baselines/reference/forStatements.types +++ /dev/null @@ -1,164 +0,0 @@ -=== tests/cases/conformance/statements/forStatements/forStatements.ts === -interface I { ->I : I - - id: number; ->id : number -} - -class C implements I { ->C : C ->I : I - - id: number; ->id : number -} - -class D{ ->D : D ->T : T - - source: T; ->source : T ->T : T - - recurse: D; ->recurse : D ->D : D ->T : T - - wrapped: D> ->wrapped : D> ->D : D ->D : D ->T : T -} - -function F(x: string): number { return 42; } ->F : (x: string) => number ->x : string ->42 : number - -module M { ->M : typeof M - - export class A { ->A : A - - name: string; ->name : string - } - - export function F2(x: number): string { return x.toString(); } ->F2 : (x: number) => string ->x : number ->x.toString() : string ->x.toString : (radix?: number) => string ->x : number ->toString : (radix?: number) => string -} - -for(var aNumber: number = 9.9;;){} ->aNumber : number ->9.9 : number - -for(var aString: string = 'this is a string';;){} ->aString : string ->'this is a string' : string - -for(var aDate: Date = new Date(12);;){} ->aDate : Date ->Date : Date ->new Date(12) : Date ->Date : DateConstructor ->12 : number - -for(var anObject: Object = new Object();;){} ->anObject : Object ->Object : Object ->new Object() : Object ->Object : ObjectConstructor - -for(var anAny: any = null;;){} ->anAny : any ->null : null - -for(var aSecondAny: any = undefined;;){} ->aSecondAny : any ->undefined : undefined - -for(var aVoid: void = undefined;;){} ->aVoid : void ->undefined : undefined - -for(var anInterface: I = new C();;){} ->anInterface : I ->I : I ->new C() : C ->C : typeof C - -for(var aClass: C = new C();;){} ->aClass : C ->C : C ->new C() : C ->C : typeof C - -for(var aGenericClass: D = new D();;){} ->aGenericClass : D ->D : D ->new D() : D ->D : typeof D - -for(var anObjectLiteral: I = { id: 12 };;){} ->anObjectLiteral : I ->I : I ->{ id: 12 } : { id: number; } ->id : number ->12 : number - -for(var anOtherObjectLiteral: { id: number } = new C();;){} ->anOtherObjectLiteral : { id: number; } ->id : number ->new C() : C ->C : typeof C - -for(var aFunction: typeof F = F;;){} ->aFunction : (x: string) => number ->F : (x: string) => number ->F : (x: string) => number - -for(var anOtherFunction: (x: string) => number = F;;){} ->anOtherFunction : (x: string) => number ->x : string ->F : (x: string) => number - -for(var aLambda: typeof F = (x) => 2;;){} ->aLambda : (x: string) => number ->F : (x: string) => number ->(x) => 2 : (x: string) => number ->x : string ->2 : number - -for(var aModule: typeof M = M;;){} ->aModule : typeof M ->M : typeof M ->M : typeof M - -for(var aClassInModule: M.A = new M.A();;){} ->aClassInModule : M.A ->M : any ->A : M.A ->new M.A() : M.A ->M.A : typeof M.A ->M : typeof M ->A : typeof M.A - -for(var aFunctionInModule: typeof M.F2 = (x) => 'this is a string';;){} ->aFunctionInModule : (x: number) => string ->M.F2 : (x: number) => string ->M : typeof M ->F2 : (x: number) => string ->(x) => 'this is a string' : (x: number) => string ->x : number ->'this is a string' : string - diff --git a/tests/baselines/reference/forStatementsMultipleInvalidDecl.errors.txt b/tests/baselines/reference/forStatementsMultipleInvalidDecl.errors.txt index 53ecb88363d..fa1c87824d7 100644 --- a/tests/baselines/reference/forStatementsMultipleInvalidDecl.errors.txt +++ b/tests/baselines/reference/forStatementsMultipleInvalidDecl.errors.txt @@ -1,3 +1,4 @@ +tests/cases/conformance/statements/forStatements/forStatementsMultipleInvalidDecl.ts(32,1): error TS7027: Unreachable code detected. tests/cases/conformance/statements/forStatements/forStatementsMultipleInvalidDecl.ts(32,10): error TS2403: Subsequent variable declarations must have the same type. Variable 'a' must be of type 'any', but here has type 'number'. tests/cases/conformance/statements/forStatements/forStatementsMultipleInvalidDecl.ts(33,10): error TS2403: Subsequent variable declarations must have the same type. Variable 'a' must be of type 'any', but here has type 'string'. tests/cases/conformance/statements/forStatements/forStatementsMultipleInvalidDecl.ts(34,10): error TS2403: Subsequent variable declarations must have the same type. Variable 'a' must be of type 'any', but here has type 'C'. @@ -12,7 +13,7 @@ tests/cases/conformance/statements/forStatements/forStatementsMultipleInvalidDec tests/cases/conformance/statements/forStatements/forStatementsMultipleInvalidDecl.ts(53,10): error TS2403: Subsequent variable declarations must have the same type. Variable 'm' must be of type 'typeof M', but here has type 'typeof A'. -==== tests/cases/conformance/statements/forStatements/forStatementsMultipleInvalidDecl.ts (12 errors) ==== +==== tests/cases/conformance/statements/forStatements/forStatementsMultipleInvalidDecl.ts (13 errors) ==== interface I { id: number; } @@ -45,6 +46,8 @@ tests/cases/conformance/statements/forStatements/forStatementsMultipleInvalidDec // all of these are errors for( var a: any;;){} for( var a = 1;;){} + ~~~ +!!! error TS7027: Unreachable code detected. ~ !!! error TS2403: Subsequent variable declarations must have the same type. Variable 'a' must be of type 'any', but here has type 'number'. for( var a = 'a string';;){} diff --git a/tests/baselines/reference/forStatementsMultipleValidDecl.errors.txt b/tests/baselines/reference/forStatementsMultipleValidDecl.errors.txt new file mode 100644 index 00000000000..eb871af31c0 --- /dev/null +++ b/tests/baselines/reference/forStatementsMultipleValidDecl.errors.txt @@ -0,0 +1,39 @@ +tests/cases/conformance/statements/forStatements/forStatementsMultipleValidDecl.ts(4,1): error TS7027: Unreachable code detected. + + +==== tests/cases/conformance/statements/forStatements/forStatementsMultipleValidDecl.ts (1 errors) ==== + // all expected to be valid + + for (var x: number; ;) { } + for (var x = 2; ;) { } + ~~~ +!!! error TS7027: Unreachable code detected. + + for (var x = undefined; ;) { } + // new declaration space, making redeclaring x as a string valid + function declSpace() { + for (var x = 'this is a string'; ;) { } + } + interface Point { x: number; y: number; } + + for (var p: Point; ;) { } + for (var p = { x: 1, y: 2 }; ;) { } + for (var p: Point = { x: 0, y: undefined }; ;) { } + for (var p = { x: 1, y: undefined }; ;) { } + for (var p: { x: number; y: number; } = { x: 1, y: 2 }; ;) { } + for (var p = <{ x: number; y: number; }>{ x: 0, y: undefined }; ;) { } + for (var p: typeof p; ;) { } + + for (var fn = function (s: string) { return 42; }; ;) { } + for (var fn = (s: string) => 3; ;) { } + for (var fn: (s: string) => number; ;) { } + for (var fn: { (s: string): number }; ;) { } + for (var fn = <(s: string) => number> null; ;) { } + for (var fn: typeof fn; ;) { } + + for (var a: string[]; ;) { } + for (var a = ['a', 'b']; ;) { } + for (var a = []; ;) { } + for (var a: string[] = []; ;) { } + for (var a = new Array(); ;) { } + for (var a: typeof a; ;) { } \ No newline at end of file diff --git a/tests/baselines/reference/forStatementsMultipleValidDecl.symbols b/tests/baselines/reference/forStatementsMultipleValidDecl.symbols deleted file mode 100644 index 6a98fbf133e..00000000000 --- a/tests/baselines/reference/forStatementsMultipleValidDecl.symbols +++ /dev/null @@ -1,110 +0,0 @@ -=== tests/cases/conformance/statements/forStatements/forStatementsMultipleValidDecl.ts === -// all expected to be valid - -for (var x: number; ;) { } ->x : Symbol(x, Decl(forStatementsMultipleValidDecl.ts, 2, 8), Decl(forStatementsMultipleValidDecl.ts, 3, 8), Decl(forStatementsMultipleValidDecl.ts, 5, 8)) - -for (var x = 2; ;) { } ->x : Symbol(x, Decl(forStatementsMultipleValidDecl.ts, 2, 8), Decl(forStatementsMultipleValidDecl.ts, 3, 8), Decl(forStatementsMultipleValidDecl.ts, 5, 8)) - -for (var x = undefined; ;) { } ->x : Symbol(x, Decl(forStatementsMultipleValidDecl.ts, 2, 8), Decl(forStatementsMultipleValidDecl.ts, 3, 8), Decl(forStatementsMultipleValidDecl.ts, 5, 8)) ->undefined : Symbol(undefined) - -// new declaration space, making redeclaring x as a string valid -function declSpace() { ->declSpace : Symbol(declSpace, Decl(forStatementsMultipleValidDecl.ts, 5, 38)) - - for (var x = 'this is a string'; ;) { } ->x : Symbol(x, Decl(forStatementsMultipleValidDecl.ts, 8, 12)) -} -interface Point { x: number; y: number; } ->Point : Symbol(Point, Decl(forStatementsMultipleValidDecl.ts, 9, 1)) ->x : Symbol(x, Decl(forStatementsMultipleValidDecl.ts, 10, 17)) ->y : Symbol(y, Decl(forStatementsMultipleValidDecl.ts, 10, 28)) - -for (var p: Point; ;) { } ->p : Symbol(p, Decl(forStatementsMultipleValidDecl.ts, 12, 8), Decl(forStatementsMultipleValidDecl.ts, 13, 8), Decl(forStatementsMultipleValidDecl.ts, 14, 8), Decl(forStatementsMultipleValidDecl.ts, 15, 8), Decl(forStatementsMultipleValidDecl.ts, 16, 8), Decl(forStatementsMultipleValidDecl.ts, 17, 8), Decl(forStatementsMultipleValidDecl.ts, 18, 8)) ->Point : Symbol(Point, Decl(forStatementsMultipleValidDecl.ts, 9, 1)) - -for (var p = { x: 1, y: 2 }; ;) { } ->p : Symbol(p, Decl(forStatementsMultipleValidDecl.ts, 12, 8), Decl(forStatementsMultipleValidDecl.ts, 13, 8), Decl(forStatementsMultipleValidDecl.ts, 14, 8), Decl(forStatementsMultipleValidDecl.ts, 15, 8), Decl(forStatementsMultipleValidDecl.ts, 16, 8), Decl(forStatementsMultipleValidDecl.ts, 17, 8), Decl(forStatementsMultipleValidDecl.ts, 18, 8)) ->x : Symbol(x, Decl(forStatementsMultipleValidDecl.ts, 13, 14)) ->y : Symbol(y, Decl(forStatementsMultipleValidDecl.ts, 13, 20)) - -for (var p: Point = { x: 0, y: undefined }; ;) { } ->p : Symbol(p, Decl(forStatementsMultipleValidDecl.ts, 12, 8), Decl(forStatementsMultipleValidDecl.ts, 13, 8), Decl(forStatementsMultipleValidDecl.ts, 14, 8), Decl(forStatementsMultipleValidDecl.ts, 15, 8), Decl(forStatementsMultipleValidDecl.ts, 16, 8), Decl(forStatementsMultipleValidDecl.ts, 17, 8), Decl(forStatementsMultipleValidDecl.ts, 18, 8)) ->Point : Symbol(Point, Decl(forStatementsMultipleValidDecl.ts, 9, 1)) ->x : Symbol(x, Decl(forStatementsMultipleValidDecl.ts, 14, 21)) ->y : Symbol(y, Decl(forStatementsMultipleValidDecl.ts, 14, 27)) ->undefined : Symbol(undefined) - -for (var p = { x: 1, y: undefined }; ;) { } ->p : Symbol(p, Decl(forStatementsMultipleValidDecl.ts, 12, 8), Decl(forStatementsMultipleValidDecl.ts, 13, 8), Decl(forStatementsMultipleValidDecl.ts, 14, 8), Decl(forStatementsMultipleValidDecl.ts, 15, 8), Decl(forStatementsMultipleValidDecl.ts, 16, 8), Decl(forStatementsMultipleValidDecl.ts, 17, 8), Decl(forStatementsMultipleValidDecl.ts, 18, 8)) ->x : Symbol(x, Decl(forStatementsMultipleValidDecl.ts, 15, 14)) ->y : Symbol(y, Decl(forStatementsMultipleValidDecl.ts, 15, 20)) ->undefined : Symbol(undefined) - -for (var p: { x: number; y: number; } = { x: 1, y: 2 }; ;) { } ->p : Symbol(p, Decl(forStatementsMultipleValidDecl.ts, 12, 8), Decl(forStatementsMultipleValidDecl.ts, 13, 8), Decl(forStatementsMultipleValidDecl.ts, 14, 8), Decl(forStatementsMultipleValidDecl.ts, 15, 8), Decl(forStatementsMultipleValidDecl.ts, 16, 8), Decl(forStatementsMultipleValidDecl.ts, 17, 8), Decl(forStatementsMultipleValidDecl.ts, 18, 8)) ->x : Symbol(x, Decl(forStatementsMultipleValidDecl.ts, 16, 13)) ->y : Symbol(y, Decl(forStatementsMultipleValidDecl.ts, 16, 24)) ->x : Symbol(x, Decl(forStatementsMultipleValidDecl.ts, 16, 41)) ->y : Symbol(y, Decl(forStatementsMultipleValidDecl.ts, 16, 47)) - -for (var p = <{ x: number; y: number; }>{ x: 0, y: undefined }; ;) { } ->p : Symbol(p, Decl(forStatementsMultipleValidDecl.ts, 12, 8), Decl(forStatementsMultipleValidDecl.ts, 13, 8), Decl(forStatementsMultipleValidDecl.ts, 14, 8), Decl(forStatementsMultipleValidDecl.ts, 15, 8), Decl(forStatementsMultipleValidDecl.ts, 16, 8), Decl(forStatementsMultipleValidDecl.ts, 17, 8), Decl(forStatementsMultipleValidDecl.ts, 18, 8)) ->x : Symbol(x, Decl(forStatementsMultipleValidDecl.ts, 17, 15)) ->y : Symbol(y, Decl(forStatementsMultipleValidDecl.ts, 17, 26)) ->x : Symbol(x, Decl(forStatementsMultipleValidDecl.ts, 17, 41)) ->y : Symbol(y, Decl(forStatementsMultipleValidDecl.ts, 17, 47)) ->undefined : Symbol(undefined) - -for (var p: typeof p; ;) { } ->p : Symbol(p, Decl(forStatementsMultipleValidDecl.ts, 12, 8), Decl(forStatementsMultipleValidDecl.ts, 13, 8), Decl(forStatementsMultipleValidDecl.ts, 14, 8), Decl(forStatementsMultipleValidDecl.ts, 15, 8), Decl(forStatementsMultipleValidDecl.ts, 16, 8), Decl(forStatementsMultipleValidDecl.ts, 17, 8), Decl(forStatementsMultipleValidDecl.ts, 18, 8)) ->p : Symbol(p, Decl(forStatementsMultipleValidDecl.ts, 12, 8), Decl(forStatementsMultipleValidDecl.ts, 13, 8), Decl(forStatementsMultipleValidDecl.ts, 14, 8), Decl(forStatementsMultipleValidDecl.ts, 15, 8), Decl(forStatementsMultipleValidDecl.ts, 16, 8), Decl(forStatementsMultipleValidDecl.ts, 17, 8), Decl(forStatementsMultipleValidDecl.ts, 18, 8)) - -for (var fn = function (s: string) { return 42; }; ;) { } ->fn : Symbol(fn, Decl(forStatementsMultipleValidDecl.ts, 20, 8), Decl(forStatementsMultipleValidDecl.ts, 21, 8), Decl(forStatementsMultipleValidDecl.ts, 22, 8), Decl(forStatementsMultipleValidDecl.ts, 23, 8), Decl(forStatementsMultipleValidDecl.ts, 24, 8), Decl(forStatementsMultipleValidDecl.ts, 25, 8)) ->s : Symbol(s, Decl(forStatementsMultipleValidDecl.ts, 20, 24)) - -for (var fn = (s: string) => 3; ;) { } ->fn : Symbol(fn, Decl(forStatementsMultipleValidDecl.ts, 20, 8), Decl(forStatementsMultipleValidDecl.ts, 21, 8), Decl(forStatementsMultipleValidDecl.ts, 22, 8), Decl(forStatementsMultipleValidDecl.ts, 23, 8), Decl(forStatementsMultipleValidDecl.ts, 24, 8), Decl(forStatementsMultipleValidDecl.ts, 25, 8)) ->s : Symbol(s, Decl(forStatementsMultipleValidDecl.ts, 21, 15)) - -for (var fn: (s: string) => number; ;) { } ->fn : Symbol(fn, Decl(forStatementsMultipleValidDecl.ts, 20, 8), Decl(forStatementsMultipleValidDecl.ts, 21, 8), Decl(forStatementsMultipleValidDecl.ts, 22, 8), Decl(forStatementsMultipleValidDecl.ts, 23, 8), Decl(forStatementsMultipleValidDecl.ts, 24, 8), Decl(forStatementsMultipleValidDecl.ts, 25, 8)) ->s : Symbol(s, Decl(forStatementsMultipleValidDecl.ts, 22, 14)) - -for (var fn: { (s: string): number }; ;) { } ->fn : Symbol(fn, Decl(forStatementsMultipleValidDecl.ts, 20, 8), Decl(forStatementsMultipleValidDecl.ts, 21, 8), Decl(forStatementsMultipleValidDecl.ts, 22, 8), Decl(forStatementsMultipleValidDecl.ts, 23, 8), Decl(forStatementsMultipleValidDecl.ts, 24, 8), Decl(forStatementsMultipleValidDecl.ts, 25, 8)) ->s : Symbol(s, Decl(forStatementsMultipleValidDecl.ts, 23, 16)) - -for (var fn = <(s: string) => number> null; ;) { } ->fn : Symbol(fn, Decl(forStatementsMultipleValidDecl.ts, 20, 8), Decl(forStatementsMultipleValidDecl.ts, 21, 8), Decl(forStatementsMultipleValidDecl.ts, 22, 8), Decl(forStatementsMultipleValidDecl.ts, 23, 8), Decl(forStatementsMultipleValidDecl.ts, 24, 8), Decl(forStatementsMultipleValidDecl.ts, 25, 8)) ->s : Symbol(s, Decl(forStatementsMultipleValidDecl.ts, 24, 16)) - -for (var fn: typeof fn; ;) { } ->fn : Symbol(fn, Decl(forStatementsMultipleValidDecl.ts, 20, 8), Decl(forStatementsMultipleValidDecl.ts, 21, 8), Decl(forStatementsMultipleValidDecl.ts, 22, 8), Decl(forStatementsMultipleValidDecl.ts, 23, 8), Decl(forStatementsMultipleValidDecl.ts, 24, 8), Decl(forStatementsMultipleValidDecl.ts, 25, 8)) ->fn : Symbol(fn, Decl(forStatementsMultipleValidDecl.ts, 20, 8), Decl(forStatementsMultipleValidDecl.ts, 21, 8), Decl(forStatementsMultipleValidDecl.ts, 22, 8), Decl(forStatementsMultipleValidDecl.ts, 23, 8), Decl(forStatementsMultipleValidDecl.ts, 24, 8), Decl(forStatementsMultipleValidDecl.ts, 25, 8)) - -for (var a: string[]; ;) { } ->a : Symbol(a, Decl(forStatementsMultipleValidDecl.ts, 27, 8), Decl(forStatementsMultipleValidDecl.ts, 28, 8), Decl(forStatementsMultipleValidDecl.ts, 29, 8), Decl(forStatementsMultipleValidDecl.ts, 30, 8), Decl(forStatementsMultipleValidDecl.ts, 31, 8), Decl(forStatementsMultipleValidDecl.ts, 32, 8)) - -for (var a = ['a', 'b']; ;) { } ->a : Symbol(a, Decl(forStatementsMultipleValidDecl.ts, 27, 8), Decl(forStatementsMultipleValidDecl.ts, 28, 8), Decl(forStatementsMultipleValidDecl.ts, 29, 8), Decl(forStatementsMultipleValidDecl.ts, 30, 8), Decl(forStatementsMultipleValidDecl.ts, 31, 8), Decl(forStatementsMultipleValidDecl.ts, 32, 8)) - -for (var a = []; ;) { } ->a : Symbol(a, Decl(forStatementsMultipleValidDecl.ts, 27, 8), Decl(forStatementsMultipleValidDecl.ts, 28, 8), Decl(forStatementsMultipleValidDecl.ts, 29, 8), Decl(forStatementsMultipleValidDecl.ts, 30, 8), Decl(forStatementsMultipleValidDecl.ts, 31, 8), Decl(forStatementsMultipleValidDecl.ts, 32, 8)) - -for (var a: string[] = []; ;) { } ->a : Symbol(a, Decl(forStatementsMultipleValidDecl.ts, 27, 8), Decl(forStatementsMultipleValidDecl.ts, 28, 8), Decl(forStatementsMultipleValidDecl.ts, 29, 8), Decl(forStatementsMultipleValidDecl.ts, 30, 8), Decl(forStatementsMultipleValidDecl.ts, 31, 8), Decl(forStatementsMultipleValidDecl.ts, 32, 8)) - -for (var a = new Array(); ;) { } ->a : Symbol(a, Decl(forStatementsMultipleValidDecl.ts, 27, 8), Decl(forStatementsMultipleValidDecl.ts, 28, 8), Decl(forStatementsMultipleValidDecl.ts, 29, 8), Decl(forStatementsMultipleValidDecl.ts, 30, 8), Decl(forStatementsMultipleValidDecl.ts, 31, 8), Decl(forStatementsMultipleValidDecl.ts, 32, 8)) ->Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11)) - -for (var a: typeof a; ;) { } ->a : Symbol(a, Decl(forStatementsMultipleValidDecl.ts, 27, 8), Decl(forStatementsMultipleValidDecl.ts, 28, 8), Decl(forStatementsMultipleValidDecl.ts, 29, 8), Decl(forStatementsMultipleValidDecl.ts, 30, 8), Decl(forStatementsMultipleValidDecl.ts, 31, 8), Decl(forStatementsMultipleValidDecl.ts, 32, 8)) ->a : Symbol(a, Decl(forStatementsMultipleValidDecl.ts, 27, 8), Decl(forStatementsMultipleValidDecl.ts, 28, 8), Decl(forStatementsMultipleValidDecl.ts, 29, 8), Decl(forStatementsMultipleValidDecl.ts, 30, 8), Decl(forStatementsMultipleValidDecl.ts, 31, 8), Decl(forStatementsMultipleValidDecl.ts, 32, 8)) - diff --git a/tests/baselines/reference/forStatementsMultipleValidDecl.types b/tests/baselines/reference/forStatementsMultipleValidDecl.types deleted file mode 100644 index 9b9af5b850e..00000000000 --- a/tests/baselines/reference/forStatementsMultipleValidDecl.types +++ /dev/null @@ -1,140 +0,0 @@ -=== tests/cases/conformance/statements/forStatements/forStatementsMultipleValidDecl.ts === -// all expected to be valid - -for (var x: number; ;) { } ->x : number - -for (var x = 2; ;) { } ->x : number ->2 : number - -for (var x = undefined; ;) { } ->x : number ->undefined : number ->undefined : undefined - -// new declaration space, making redeclaring x as a string valid -function declSpace() { ->declSpace : () => void - - for (var x = 'this is a string'; ;) { } ->x : string ->'this is a string' : string -} -interface Point { x: number; y: number; } ->Point : Point ->x : number ->y : number - -for (var p: Point; ;) { } ->p : Point ->Point : Point - -for (var p = { x: 1, y: 2 }; ;) { } ->p : Point ->{ x: 1, y: 2 } : { x: number; y: number; } ->x : number ->1 : number ->y : number ->2 : number - -for (var p: Point = { x: 0, y: undefined }; ;) { } ->p : Point ->Point : Point ->{ x: 0, y: undefined } : { x: number; y: undefined; } ->x : number ->0 : number ->y : undefined ->undefined : undefined - -for (var p = { x: 1, y: undefined }; ;) { } ->p : Point ->{ x: 1, y: undefined } : { x: number; y: number; } ->x : number ->1 : number ->y : number ->undefined : number ->undefined : undefined - -for (var p: { x: number; y: number; } = { x: 1, y: 2 }; ;) { } ->p : Point ->x : number ->y : number ->{ x: 1, y: 2 } : { x: number; y: number; } ->x : number ->1 : number ->y : number ->2 : number - -for (var p = <{ x: number; y: number; }>{ x: 0, y: undefined }; ;) { } ->p : Point -><{ x: number; y: number; }>{ x: 0, y: undefined } : { x: number; y: number; } ->x : number ->y : number ->{ x: 0, y: undefined } : { x: number; y: undefined; } ->x : number ->0 : number ->y : undefined ->undefined : undefined - -for (var p: typeof p; ;) { } ->p : Point ->p : Point - -for (var fn = function (s: string) { return 42; }; ;) { } ->fn : (s: string) => number ->function (s: string) { return 42; } : (s: string) => number ->s : string ->42 : number - -for (var fn = (s: string) => 3; ;) { } ->fn : (s: string) => number ->(s: string) => 3 : (s: string) => number ->s : string ->3 : number - -for (var fn: (s: string) => number; ;) { } ->fn : (s: string) => number ->s : string - -for (var fn: { (s: string): number }; ;) { } ->fn : (s: string) => number ->s : string - -for (var fn = <(s: string) => number> null; ;) { } ->fn : (s: string) => number -><(s: string) => number> null : (s: string) => number ->s : string ->null : null - -for (var fn: typeof fn; ;) { } ->fn : (s: string) => number ->fn : (s: string) => number - -for (var a: string[]; ;) { } ->a : string[] - -for (var a = ['a', 'b']; ;) { } ->a : string[] ->['a', 'b'] : string[] ->'a' : string ->'b' : string - -for (var a = []; ;) { } ->a : string[] ->[] : string[] ->[] : undefined[] - -for (var a: string[] = []; ;) { } ->a : string[] ->[] : undefined[] - -for (var a = new Array(); ;) { } ->a : string[] ->new Array() : string[] ->Array : ArrayConstructor - -for (var a: typeof a; ;) { } ->a : string[] ->a : string[] - diff --git a/tests/baselines/reference/functionImplementationErrors.errors.txt b/tests/baselines/reference/functionImplementationErrors.errors.txt index 1ab438e340b..bde939a1578 100644 --- a/tests/baselines/reference/functionImplementationErrors.errors.txt +++ b/tests/baselines/reference/functionImplementationErrors.errors.txt @@ -1,31 +1,46 @@ tests/cases/conformance/functions/functionImplementationErrors.ts(2,10): error TS2354: No best common type exists among return expressions. +tests/cases/conformance/functions/functionImplementationErrors.ts(4,5): error TS7027: Unreachable code detected. tests/cases/conformance/functions/functionImplementationErrors.ts(6,19): error TS2354: No best common type exists among return expressions. +tests/cases/conformance/functions/functionImplementationErrors.ts(8,5): error TS7027: Unreachable code detected. tests/cases/conformance/functions/functionImplementationErrors.ts(10,10): error TS2354: No best common type exists among return expressions. +tests/cases/conformance/functions/functionImplementationErrors.ts(12,5): error TS7027: Unreachable code detected. tests/cases/conformance/functions/functionImplementationErrors.ts(16,10): error TS2354: No best common type exists among return expressions. +tests/cases/conformance/functions/functionImplementationErrors.ts(20,9): error TS7027: Unreachable code detected. tests/cases/conformance/functions/functionImplementationErrors.ts(25,16): error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. tests/cases/conformance/functions/functionImplementationErrors.ts(30,17): error TS2373: Initializer of parameter 'n' cannot reference identifier 'm' declared after it. tests/cases/conformance/functions/functionImplementationErrors.ts(35,17): error TS2373: Initializer of parameter 'n' cannot reference identifier 'm' declared after it. +tests/cases/conformance/functions/functionImplementationErrors.ts(42,5): error TS7027: Unreachable code detected. tests/cases/conformance/functions/functionImplementationErrors.ts(49,10): error TS2354: No best common type exists among return expressions. +tests/cases/conformance/functions/functionImplementationErrors.ts(51,5): error TS7027: Unreachable code detected. tests/cases/conformance/functions/functionImplementationErrors.ts(53,10): error TS2354: No best common type exists among return expressions. +tests/cases/conformance/functions/functionImplementationErrors.ts(55,5): error TS7027: Unreachable code detected. tests/cases/conformance/functions/functionImplementationErrors.ts(57,11): error TS2354: No best common type exists among return expressions. +tests/cases/conformance/functions/functionImplementationErrors.ts(59,5): error TS7027: Unreachable code detected. tests/cases/conformance/functions/functionImplementationErrors.ts(61,10): error TS2354: No best common type exists among return expressions. +tests/cases/conformance/functions/functionImplementationErrors.ts(63,5): error TS7027: Unreachable code detected. tests/cases/conformance/functions/functionImplementationErrors.ts(65,11): error TS2354: No best common type exists among return expressions. +tests/cases/conformance/functions/functionImplementationErrors.ts(67,5): error TS7027: Unreachable code detected. tests/cases/conformance/functions/functionImplementationErrors.ts(69,11): error TS2354: No best common type exists among return expressions. +tests/cases/conformance/functions/functionImplementationErrors.ts(71,5): error TS7027: Unreachable code detected. -==== tests/cases/conformance/functions/functionImplementationErrors.ts (13 errors) ==== +==== tests/cases/conformance/functions/functionImplementationErrors.ts (24 errors) ==== // FunctionExpression with no return type annotation with multiple return statements with unrelated types var f1 = function () { ~~~~~~~~ !!! error TS2354: No best common type exists among return expressions. return ''; return 3; + ~~~~~~ +!!! error TS7027: Unreachable code detected. }; var f2 = function x() { ~ !!! error TS2354: No best common type exists among return expressions. return ''; return 3; + ~~~~~~ +!!! error TS7027: Unreachable code detected. }; var f3 = () => { ~~~~~~~ @@ -33,6 +48,8 @@ tests/cases/conformance/functions/functionImplementationErrors.ts(69,11): error ~~~~~~~~~~~~~~ return 3; ~~~~~~~~~~~~~ + ~~~~~~ +!!! error TS7027: Unreachable code detected. }; ~ !!! error TS2354: No best common type exists among return expressions. @@ -45,6 +62,8 @@ tests/cases/conformance/functions/functionImplementationErrors.ts(69,11): error return ['']; } else { return [1]; + ~~~~~~ +!!! error TS7027: Unreachable code detected. } } @@ -73,6 +92,8 @@ tests/cases/conformance/functions/functionImplementationErrors.ts(69,11): error undefined === function (): number { throw undefined; var x = 4; + ~~~ +!!! error TS7027: Unreachable code detected. }; class Base { private x; } @@ -84,12 +105,16 @@ tests/cases/conformance/functions/functionImplementationErrors.ts(69,11): error !!! error TS2354: No best common type exists among return expressions. return new Derived1(); return new Derived2(); + ~~~~~~ +!!! error TS7027: Unreachable code detected. } var f9 = function () { ~~~~~~~~ !!! error TS2354: No best common type exists among return expressions. return new Derived1(); return new Derived2(); + ~~~~~~ +!!! error TS7027: Unreachable code detected. }; var f10 = () => { ~~~~~~~ @@ -97,6 +122,8 @@ tests/cases/conformance/functions/functionImplementationErrors.ts(69,11): error ~~~~~~~~~~~~~~~~~~~~~~~~~~ return new Derived2(); ~~~~~~~~~~~~~~~~~~~~~~~~~~ + ~~~~~~ +!!! error TS7027: Unreachable code detected. }; ~ !!! error TS2354: No best common type exists among return expressions. @@ -105,12 +132,16 @@ tests/cases/conformance/functions/functionImplementationErrors.ts(69,11): error !!! error TS2354: No best common type exists among return expressions. return new Base(); return new AnotherClass(); + ~~~~~~ +!!! error TS7027: Unreachable code detected. } var f12 = function () { ~~~~~~~~ !!! error TS2354: No best common type exists among return expressions. return new Base(); return new AnotherClass(); + ~~~~~~ +!!! error TS7027: Unreachable code detected. }; var f13 = () => { ~~~~~~~ @@ -118,6 +149,8 @@ tests/cases/conformance/functions/functionImplementationErrors.ts(69,11): error ~~~~~~~~~~~~~~~~~~~~~~ return new AnotherClass(); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + ~~~~~~ +!!! error TS7027: Unreachable code detected. }; ~ !!! error TS2354: No best common type exists among return expressions. diff --git a/tests/baselines/reference/functionImplementations.errors.txt b/tests/baselines/reference/functionImplementations.errors.txt new file mode 100644 index 00000000000..f3e4d6404c6 --- /dev/null +++ b/tests/baselines/reference/functionImplementations.errors.txt @@ -0,0 +1,183 @@ +tests/cases/conformance/functions/functionImplementations.ts(69,5): error TS7027: Unreachable code detected. +tests/cases/conformance/functions/functionImplementations.ts(81,24): error TS7027: Unreachable code detected. +tests/cases/conformance/functions/functionImplementations.ts(86,24): error TS7027: Unreachable code detected. +tests/cases/conformance/functions/functionImplementations.ts(137,5): error TS7027: Unreachable code detected. +tests/cases/conformance/functions/functionImplementations.ts(141,5): error TS7027: Unreachable code detected. +tests/cases/conformance/functions/functionImplementations.ts(146,5): error TS7027: Unreachable code detected. +tests/cases/conformance/functions/functionImplementations.ts(150,5): error TS7027: Unreachable code detected. +tests/cases/conformance/functions/functionImplementations.ts(154,5): error TS7027: Unreachable code detected. + + +==== tests/cases/conformance/functions/functionImplementations.ts (8 errors) ==== + // FunctionExpression with no return type annotation and no return statement returns void + var v: void = function () { } (); + + // FunctionExpression f with no return type annotation and directly references f in its body returns any + var a: any = function f() { + return f; + }; + var a: any = function f() { + return f(); + }; + + // FunctionExpression f with no return type annotation and indirectly references f in its body returns any + var a: any = function f() { + var x = f; + return x; + }; + + // Two mutually recursive function implementations with no return type annotations + function rec1() { + return rec2(); + } + function rec2() { + return rec1(); + } + var a = rec1(); + var a = rec2(); + + // Two mutually recursive function implementations with return type annotation in one + function rec3(): number { + return rec4(); + } + function rec4() { + return rec3(); + } + var n: number; + var n = rec3(); + var n = rec4(); + + // FunctionExpression with no return type annotation and returns a number + var n = function () { + return 3; + } (); + + // FunctionExpression with no return type annotation and returns null + var nu = null; + var nu = function () { + return null; + } (); + + // FunctionExpression with no return type annotation and returns undefined + var un = undefined; + var un = function () { + return undefined; + } (); + + // FunctionExpression with no return type annotation and returns a type parameter type + var n = function (x: T) { + return x; + } (4); + + // FunctionExpression with no return type annotation and returns a constrained type parameter type + var n = function (x: T) { + return x; + } (4); + + // FunctionExpression with no return type annotation with multiple return statements with identical types + var n = function () { + return 3; + return 5; + ~~~~~~ +!!! error TS7027: Unreachable code detected. + }(); + + // Otherwise, the inferred return type is the first of the types of the return statement expressions + // in the function body that is a supertype of each of the others, + // ignoring return statements with no expressions. + // A compile - time error occurs if no return statement expression has a type that is a supertype of each of the others. + // FunctionExpression with no return type annotation with multiple return statements with subtype relation between returns + class Base { private m; } + class Derived extends Base { private q; } + var b: Base; + var b = function () { + return new Base(); return new Derived(); + ~~~~~~ +!!! error TS7027: Unreachable code detected. + } (); + + // FunctionExpression with no return type annotation with multiple return statements with one a recursive call + var a = function f() { + return new Base(); return new Derived(); return f(); // ? + ~~~~~~ +!!! error TS7027: Unreachable code detected. + } (); + + // FunctionExpression with non -void return type annotation with a single throw statement + undefined === function (): number { + throw undefined; + }; + + // Type of 'this' in function implementation is 'any' + function thisFunc() { + var x = this; + var x: any; + } + + // Function signature with optional parameter, no type annotation and initializer has initializer's type + function opt1(n = 4) { + var m = n; + var m: number; + } + + // Function signature with optional parameter, no type annotation and initializer has initializer's widened type + function opt2(n = { x: null, y: undefined }) { + var m = n; + var m: { x: any; y: any }; + } + + // Function signature with initializer referencing other parameter to the left + function opt3(n: number, m = n) { + var y = m; + var y: number; + } + + // Function signature with optional parameter has correct codegen + // (tested above) + + // FunctionExpression with non -void return type annotation return with no expression + function f6(): number { + return; + } + + class Derived2 extends Base { private r: string; } + class AnotherClass { private x } + // if f is a contextually typed function expression, the inferred return type is the union type + // of the types of the return statement expressions in the function body, + // ignoring return statements with no expressions. + var f7: (x: number) => string | number = x => { // should be (x: number) => number | string + if (x < 0) { return x; } + return x.toString(); + } + var f8: (x: number) => any = x => { // should be (x: number) => Base + return new Base(); + return new Derived2(); + ~~~~~~ +!!! error TS7027: Unreachable code detected. + } + var f9: (x: number) => any = x => { // should be (x: number) => Base + return new Base(); + return new Derived(); + ~~~~~~ +!!! error TS7027: Unreachable code detected. + return new Derived2(); + } + var f10: (x: number) => any = x => { // should be (x: number) => Derived | Derived1 + return new Derived(); + return new Derived2(); + ~~~~~~ +!!! error TS7027: Unreachable code detected. + } + var f11: (x: number) => any = x => { // should be (x: number) => Base | AnotherClass + return new Base(); + return new AnotherClass(); + ~~~~~~ +!!! error TS7027: Unreachable code detected. + } + var f12: (x: number) => any = x => { // should be (x: number) => Base | AnotherClass + return new Base(); + return; // should be ignored + ~~~~~~ +!!! error TS7027: Unreachable code detected. + return new AnotherClass(); + } \ No newline at end of file diff --git a/tests/baselines/reference/functionImplementations.symbols b/tests/baselines/reference/functionImplementations.symbols deleted file mode 100644 index f9205f37650..00000000000 --- a/tests/baselines/reference/functionImplementations.symbols +++ /dev/null @@ -1,344 +0,0 @@ -=== tests/cases/conformance/functions/functionImplementations.ts === -// FunctionExpression with no return type annotation and no return statement returns void -var v: void = function () { } (); ->v : Symbol(v, Decl(functionImplementations.ts, 1, 3)) - -// FunctionExpression f with no return type annotation and directly references f in its body returns any -var a: any = function f() { ->a : Symbol(a, Decl(functionImplementations.ts, 4, 3), Decl(functionImplementations.ts, 7, 3), Decl(functionImplementations.ts, 12, 3), Decl(functionImplementations.ts, 24, 3), Decl(functionImplementations.ts, 25, 3), Decl(functionImplementations.ts, 84, 3)) ->f : Symbol(f, Decl(functionImplementations.ts, 4, 12)) - - return f; ->f : Symbol(f, Decl(functionImplementations.ts, 4, 12)) - -}; -var a: any = function f() { ->a : Symbol(a, Decl(functionImplementations.ts, 4, 3), Decl(functionImplementations.ts, 7, 3), Decl(functionImplementations.ts, 12, 3), Decl(functionImplementations.ts, 24, 3), Decl(functionImplementations.ts, 25, 3), Decl(functionImplementations.ts, 84, 3)) ->f : Symbol(f, Decl(functionImplementations.ts, 7, 12)) - - return f(); ->f : Symbol(f, Decl(functionImplementations.ts, 7, 12)) - -}; - -// FunctionExpression f with no return type annotation and indirectly references f in its body returns any -var a: any = function f() { ->a : Symbol(a, Decl(functionImplementations.ts, 4, 3), Decl(functionImplementations.ts, 7, 3), Decl(functionImplementations.ts, 12, 3), Decl(functionImplementations.ts, 24, 3), Decl(functionImplementations.ts, 25, 3), Decl(functionImplementations.ts, 84, 3)) ->f : Symbol(f, Decl(functionImplementations.ts, 12, 12)) - - var x = f; ->x : Symbol(x, Decl(functionImplementations.ts, 13, 7)) ->f : Symbol(f, Decl(functionImplementations.ts, 12, 12)) - - return x; ->x : Symbol(x, Decl(functionImplementations.ts, 13, 7)) - -}; - -// Two mutually recursive function implementations with no return type annotations -function rec1() { ->rec1 : Symbol(rec1, Decl(functionImplementations.ts, 15, 2)) - - return rec2(); ->rec2 : Symbol(rec2, Decl(functionImplementations.ts, 20, 1)) -} -function rec2() { ->rec2 : Symbol(rec2, Decl(functionImplementations.ts, 20, 1)) - - return rec1(); ->rec1 : Symbol(rec1, Decl(functionImplementations.ts, 15, 2)) -} -var a = rec1(); ->a : Symbol(a, Decl(functionImplementations.ts, 4, 3), Decl(functionImplementations.ts, 7, 3), Decl(functionImplementations.ts, 12, 3), Decl(functionImplementations.ts, 24, 3), Decl(functionImplementations.ts, 25, 3), Decl(functionImplementations.ts, 84, 3)) ->rec1 : Symbol(rec1, Decl(functionImplementations.ts, 15, 2)) - -var a = rec2(); ->a : Symbol(a, Decl(functionImplementations.ts, 4, 3), Decl(functionImplementations.ts, 7, 3), Decl(functionImplementations.ts, 12, 3), Decl(functionImplementations.ts, 24, 3), Decl(functionImplementations.ts, 25, 3), Decl(functionImplementations.ts, 84, 3)) ->rec2 : Symbol(rec2, Decl(functionImplementations.ts, 20, 1)) - -// Two mutually recursive function implementations with return type annotation in one -function rec3(): number { ->rec3 : Symbol(rec3, Decl(functionImplementations.ts, 25, 15)) - - return rec4(); ->rec4 : Symbol(rec4, Decl(functionImplementations.ts, 30, 1)) -} -function rec4() { ->rec4 : Symbol(rec4, Decl(functionImplementations.ts, 30, 1)) - - return rec3(); ->rec3 : Symbol(rec3, Decl(functionImplementations.ts, 25, 15)) -} -var n: number; ->n : Symbol(n, Decl(functionImplementations.ts, 34, 3), Decl(functionImplementations.ts, 35, 3), Decl(functionImplementations.ts, 36, 3), Decl(functionImplementations.ts, 39, 3), Decl(functionImplementations.ts, 56, 3), Decl(functionImplementations.ts, 61, 3), Decl(functionImplementations.ts, 66, 3)) - -var n = rec3(); ->n : Symbol(n, Decl(functionImplementations.ts, 34, 3), Decl(functionImplementations.ts, 35, 3), Decl(functionImplementations.ts, 36, 3), Decl(functionImplementations.ts, 39, 3), Decl(functionImplementations.ts, 56, 3), Decl(functionImplementations.ts, 61, 3), Decl(functionImplementations.ts, 66, 3)) ->rec3 : Symbol(rec3, Decl(functionImplementations.ts, 25, 15)) - -var n = rec4(); ->n : Symbol(n, Decl(functionImplementations.ts, 34, 3), Decl(functionImplementations.ts, 35, 3), Decl(functionImplementations.ts, 36, 3), Decl(functionImplementations.ts, 39, 3), Decl(functionImplementations.ts, 56, 3), Decl(functionImplementations.ts, 61, 3), Decl(functionImplementations.ts, 66, 3)) ->rec4 : Symbol(rec4, Decl(functionImplementations.ts, 30, 1)) - -// FunctionExpression with no return type annotation and returns a number -var n = function () { ->n : Symbol(n, Decl(functionImplementations.ts, 34, 3), Decl(functionImplementations.ts, 35, 3), Decl(functionImplementations.ts, 36, 3), Decl(functionImplementations.ts, 39, 3), Decl(functionImplementations.ts, 56, 3), Decl(functionImplementations.ts, 61, 3), Decl(functionImplementations.ts, 66, 3)) - - return 3; -} (); - -// FunctionExpression with no return type annotation and returns null -var nu = null; ->nu : Symbol(nu, Decl(functionImplementations.ts, 44, 3), Decl(functionImplementations.ts, 45, 3)) - -var nu = function () { ->nu : Symbol(nu, Decl(functionImplementations.ts, 44, 3), Decl(functionImplementations.ts, 45, 3)) - - return null; -} (); - -// FunctionExpression with no return type annotation and returns undefined -var un = undefined; ->un : Symbol(un, Decl(functionImplementations.ts, 50, 3), Decl(functionImplementations.ts, 51, 3)) ->undefined : Symbol(undefined) - -var un = function () { ->un : Symbol(un, Decl(functionImplementations.ts, 50, 3), Decl(functionImplementations.ts, 51, 3)) - - return undefined; ->undefined : Symbol(undefined) - -} (); - -// FunctionExpression with no return type annotation and returns a type parameter type -var n = function (x: T) { ->n : Symbol(n, Decl(functionImplementations.ts, 34, 3), Decl(functionImplementations.ts, 35, 3), Decl(functionImplementations.ts, 36, 3), Decl(functionImplementations.ts, 39, 3), Decl(functionImplementations.ts, 56, 3), Decl(functionImplementations.ts, 61, 3), Decl(functionImplementations.ts, 66, 3)) ->T : Symbol(T, Decl(functionImplementations.ts, 56, 18)) ->x : Symbol(x, Decl(functionImplementations.ts, 56, 21)) ->T : Symbol(T, Decl(functionImplementations.ts, 56, 18)) - - return x; ->x : Symbol(x, Decl(functionImplementations.ts, 56, 21)) - -} (4); - -// FunctionExpression with no return type annotation and returns a constrained type parameter type -var n = function (x: T) { ->n : Symbol(n, Decl(functionImplementations.ts, 34, 3), Decl(functionImplementations.ts, 35, 3), Decl(functionImplementations.ts, 36, 3), Decl(functionImplementations.ts, 39, 3), Decl(functionImplementations.ts, 56, 3), Decl(functionImplementations.ts, 61, 3), Decl(functionImplementations.ts, 66, 3)) ->T : Symbol(T, Decl(functionImplementations.ts, 61, 18)) ->x : Symbol(x, Decl(functionImplementations.ts, 61, 32)) ->T : Symbol(T, Decl(functionImplementations.ts, 61, 18)) - - return x; ->x : Symbol(x, Decl(functionImplementations.ts, 61, 32)) - -} (4); - -// FunctionExpression with no return type annotation with multiple return statements with identical types -var n = function () { ->n : Symbol(n, Decl(functionImplementations.ts, 34, 3), Decl(functionImplementations.ts, 35, 3), Decl(functionImplementations.ts, 36, 3), Decl(functionImplementations.ts, 39, 3), Decl(functionImplementations.ts, 56, 3), Decl(functionImplementations.ts, 61, 3), Decl(functionImplementations.ts, 66, 3)) - - return 3; - return 5; -}(); - -// Otherwise, the inferred return type is the first of the types of the return statement expressions -// in the function body that is a supertype of each of the others, -// ignoring return statements with no expressions. -// A compile - time error occurs if no return statement expression has a type that is a supertype of each of the others. -// FunctionExpression with no return type annotation with multiple return statements with subtype relation between returns -class Base { private m; } ->Base : Symbol(Base, Decl(functionImplementations.ts, 69, 4)) ->m : Symbol(m, Decl(functionImplementations.ts, 76, 12)) - -class Derived extends Base { private q; } ->Derived : Symbol(Derived, Decl(functionImplementations.ts, 76, 25)) ->Base : Symbol(Base, Decl(functionImplementations.ts, 69, 4)) ->q : Symbol(q, Decl(functionImplementations.ts, 77, 28)) - -var b: Base; ->b : Symbol(b, Decl(functionImplementations.ts, 78, 3), Decl(functionImplementations.ts, 79, 3)) ->Base : Symbol(Base, Decl(functionImplementations.ts, 69, 4)) - -var b = function () { ->b : Symbol(b, Decl(functionImplementations.ts, 78, 3), Decl(functionImplementations.ts, 79, 3)) - - return new Base(); return new Derived(); ->Base : Symbol(Base, Decl(functionImplementations.ts, 69, 4)) ->Derived : Symbol(Derived, Decl(functionImplementations.ts, 76, 25)) - -} (); - -// FunctionExpression with no return type annotation with multiple return statements with one a recursive call -var a = function f() { ->a : Symbol(a, Decl(functionImplementations.ts, 4, 3), Decl(functionImplementations.ts, 7, 3), Decl(functionImplementations.ts, 12, 3), Decl(functionImplementations.ts, 24, 3), Decl(functionImplementations.ts, 25, 3), Decl(functionImplementations.ts, 84, 3)) ->f : Symbol(f, Decl(functionImplementations.ts, 84, 7)) - - return new Base(); return new Derived(); return f(); // ? ->Base : Symbol(Base, Decl(functionImplementations.ts, 69, 4)) ->Derived : Symbol(Derived, Decl(functionImplementations.ts, 76, 25)) ->f : Symbol(f, Decl(functionImplementations.ts, 84, 7)) - -} (); - -// FunctionExpression with non -void return type annotation with a single throw statement -undefined === function (): number { ->undefined : Symbol(undefined) - - throw undefined; ->undefined : Symbol(undefined) - -}; - -// Type of 'this' in function implementation is 'any' -function thisFunc() { ->thisFunc : Symbol(thisFunc, Decl(functionImplementations.ts, 91, 2)) - - var x = this; ->x : Symbol(x, Decl(functionImplementations.ts, 95, 7), Decl(functionImplementations.ts, 96, 7)) - - var x: any; ->x : Symbol(x, Decl(functionImplementations.ts, 95, 7), Decl(functionImplementations.ts, 96, 7)) -} - -// Function signature with optional parameter, no type annotation and initializer has initializer's type -function opt1(n = 4) { ->opt1 : Symbol(opt1, Decl(functionImplementations.ts, 97, 1)) ->n : Symbol(n, Decl(functionImplementations.ts, 100, 14)) - - var m = n; ->m : Symbol(m, Decl(functionImplementations.ts, 101, 7), Decl(functionImplementations.ts, 102, 7)) ->n : Symbol(n, Decl(functionImplementations.ts, 100, 14)) - - var m: number; ->m : Symbol(m, Decl(functionImplementations.ts, 101, 7), Decl(functionImplementations.ts, 102, 7)) -} - -// Function signature with optional parameter, no type annotation and initializer has initializer's widened type -function opt2(n = { x: null, y: undefined }) { ->opt2 : Symbol(opt2, Decl(functionImplementations.ts, 103, 1)) ->n : Symbol(n, Decl(functionImplementations.ts, 106, 14)) ->x : Symbol(x, Decl(functionImplementations.ts, 106, 19)) ->y : Symbol(y, Decl(functionImplementations.ts, 106, 28)) ->undefined : Symbol(undefined) - - var m = n; ->m : Symbol(m, Decl(functionImplementations.ts, 107, 7), Decl(functionImplementations.ts, 108, 7)) ->n : Symbol(n, Decl(functionImplementations.ts, 106, 14)) - - var m: { x: any; y: any }; ->m : Symbol(m, Decl(functionImplementations.ts, 107, 7), Decl(functionImplementations.ts, 108, 7)) ->x : Symbol(x, Decl(functionImplementations.ts, 108, 12)) ->y : Symbol(y, Decl(functionImplementations.ts, 108, 20)) -} - -// Function signature with initializer referencing other parameter to the left -function opt3(n: number, m = n) { ->opt3 : Symbol(opt3, Decl(functionImplementations.ts, 109, 1)) ->n : Symbol(n, Decl(functionImplementations.ts, 112, 14)) ->m : Symbol(m, Decl(functionImplementations.ts, 112, 24)) ->n : Symbol(n, Decl(functionImplementations.ts, 112, 14)) - - var y = m; ->y : Symbol(y, Decl(functionImplementations.ts, 113, 7), Decl(functionImplementations.ts, 114, 7)) ->m : Symbol(m, Decl(functionImplementations.ts, 112, 24)) - - var y: number; ->y : Symbol(y, Decl(functionImplementations.ts, 113, 7), Decl(functionImplementations.ts, 114, 7)) -} - -// Function signature with optional parameter has correct codegen -// (tested above) - -// FunctionExpression with non -void return type annotation return with no expression -function f6(): number { ->f6 : Symbol(f6, Decl(functionImplementations.ts, 115, 1)) - - return; -} - -class Derived2 extends Base { private r: string; } ->Derived2 : Symbol(Derived2, Decl(functionImplementations.ts, 123, 1)) ->Base : Symbol(Base, Decl(functionImplementations.ts, 69, 4)) ->r : Symbol(r, Decl(functionImplementations.ts, 125, 29)) - -class AnotherClass { private x } ->AnotherClass : Symbol(AnotherClass, Decl(functionImplementations.ts, 125, 50)) ->x : Symbol(x, Decl(functionImplementations.ts, 126, 20)) - -// if f is a contextually typed function expression, the inferred return type is the union type -// of the types of the return statement expressions in the function body, -// ignoring return statements with no expressions. -var f7: (x: number) => string | number = x => { // should be (x: number) => number | string ->f7 : Symbol(f7, Decl(functionImplementations.ts, 130, 3)) ->x : Symbol(x, Decl(functionImplementations.ts, 130, 9)) ->x : Symbol(x, Decl(functionImplementations.ts, 130, 40)) - - if (x < 0) { return x; } ->x : Symbol(x, Decl(functionImplementations.ts, 130, 40)) ->x : Symbol(x, Decl(functionImplementations.ts, 130, 40)) - - return x.toString(); ->x.toString : Symbol(Number.toString, Decl(lib.d.ts, 458, 18)) ->x : Symbol(x, Decl(functionImplementations.ts, 130, 40)) ->toString : Symbol(Number.toString, Decl(lib.d.ts, 458, 18)) -} -var f8: (x: number) => any = x => { // should be (x: number) => Base ->f8 : Symbol(f8, Decl(functionImplementations.ts, 134, 3)) ->x : Symbol(x, Decl(functionImplementations.ts, 134, 9)) ->x : Symbol(x, Decl(functionImplementations.ts, 134, 28)) - - return new Base(); ->Base : Symbol(Base, Decl(functionImplementations.ts, 69, 4)) - - return new Derived2(); ->Derived2 : Symbol(Derived2, Decl(functionImplementations.ts, 123, 1)) -} -var f9: (x: number) => any = x => { // should be (x: number) => Base ->f9 : Symbol(f9, Decl(functionImplementations.ts, 138, 3)) ->x : Symbol(x, Decl(functionImplementations.ts, 138, 9)) ->x : Symbol(x, Decl(functionImplementations.ts, 138, 28)) - - return new Base(); ->Base : Symbol(Base, Decl(functionImplementations.ts, 69, 4)) - - return new Derived(); ->Derived : Symbol(Derived, Decl(functionImplementations.ts, 76, 25)) - - return new Derived2(); ->Derived2 : Symbol(Derived2, Decl(functionImplementations.ts, 123, 1)) -} -var f10: (x: number) => any = x => { // should be (x: number) => Derived | Derived1 ->f10 : Symbol(f10, Decl(functionImplementations.ts, 143, 3)) ->x : Symbol(x, Decl(functionImplementations.ts, 143, 10)) ->x : Symbol(x, Decl(functionImplementations.ts, 143, 29)) - - return new Derived(); ->Derived : Symbol(Derived, Decl(functionImplementations.ts, 76, 25)) - - return new Derived2(); ->Derived2 : Symbol(Derived2, Decl(functionImplementations.ts, 123, 1)) -} -var f11: (x: number) => any = x => { // should be (x: number) => Base | AnotherClass ->f11 : Symbol(f11, Decl(functionImplementations.ts, 147, 3)) ->x : Symbol(x, Decl(functionImplementations.ts, 147, 10)) ->x : Symbol(x, Decl(functionImplementations.ts, 147, 29)) - - return new Base(); ->Base : Symbol(Base, Decl(functionImplementations.ts, 69, 4)) - - return new AnotherClass(); ->AnotherClass : Symbol(AnotherClass, Decl(functionImplementations.ts, 125, 50)) -} -var f12: (x: number) => any = x => { // should be (x: number) => Base | AnotherClass ->f12 : Symbol(f12, Decl(functionImplementations.ts, 151, 3)) ->x : Symbol(x, Decl(functionImplementations.ts, 151, 10)) ->x : Symbol(x, Decl(functionImplementations.ts, 151, 29)) - - return new Base(); ->Base : Symbol(Base, Decl(functionImplementations.ts, 69, 4)) - - return; // should be ignored - return new AnotherClass(); ->AnotherClass : Symbol(AnotherClass, Decl(functionImplementations.ts, 125, 50)) -} diff --git a/tests/baselines/reference/functionImplementations.types b/tests/baselines/reference/functionImplementations.types deleted file mode 100644 index 1398e2974f0..00000000000 --- a/tests/baselines/reference/functionImplementations.types +++ /dev/null @@ -1,416 +0,0 @@ -=== tests/cases/conformance/functions/functionImplementations.ts === -// FunctionExpression with no return type annotation and no return statement returns void -var v: void = function () { } (); ->v : void ->function () { } () : void ->function () { } : () => void - -// FunctionExpression f with no return type annotation and directly references f in its body returns any -var a: any = function f() { ->a : any ->function f() { return f;} : () => any ->f : () => any - - return f; ->f : () => any - -}; -var a: any = function f() { ->a : any ->function f() { return f();} : () => any ->f : () => any - - return f(); ->f() : any ->f : () => any - -}; - -// FunctionExpression f with no return type annotation and indirectly references f in its body returns any -var a: any = function f() { ->a : any ->function f() { var x = f; return x;} : () => any ->f : () => any - - var x = f; ->x : () => any ->f : () => any - - return x; ->x : () => any - -}; - -// Two mutually recursive function implementations with no return type annotations -function rec1() { ->rec1 : () => any - - return rec2(); ->rec2() : any ->rec2 : () => any -} -function rec2() { ->rec2 : () => any - - return rec1(); ->rec1() : any ->rec1 : () => any -} -var a = rec1(); ->a : any ->rec1() : any ->rec1 : () => any - -var a = rec2(); ->a : any ->rec2() : any ->rec2 : () => any - -// Two mutually recursive function implementations with return type annotation in one -function rec3(): number { ->rec3 : () => number - - return rec4(); ->rec4() : number ->rec4 : () => number -} -function rec4() { ->rec4 : () => number - - return rec3(); ->rec3() : number ->rec3 : () => number -} -var n: number; ->n : number - -var n = rec3(); ->n : number ->rec3() : number ->rec3 : () => number - -var n = rec4(); ->n : number ->rec4() : number ->rec4 : () => number - -// FunctionExpression with no return type annotation and returns a number -var n = function () { ->n : number ->function () { return 3;} () : number ->function () { return 3;} : () => number - - return 3; ->3 : number - -} (); - -// FunctionExpression with no return type annotation and returns null -var nu = null; ->nu : any ->null : null - -var nu = function () { ->nu : any ->function () { return null;} () : any ->function () { return null;} : () => any - - return null; ->null : null - -} (); - -// FunctionExpression with no return type annotation and returns undefined -var un = undefined; ->un : any ->undefined : undefined - -var un = function () { ->un : any ->function () { return undefined;} () : any ->function () { return undefined;} : () => any - - return undefined; ->undefined : undefined - -} (); - -// FunctionExpression with no return type annotation and returns a type parameter type -var n = function (x: T) { ->n : number ->function (x: T) { return x;} (4) : number ->function (x: T) { return x;} : (x: T) => T ->T : T ->x : T ->T : T - - return x; ->x : T - -} (4); ->4 : number - -// FunctionExpression with no return type annotation and returns a constrained type parameter type -var n = function (x: T) { ->n : number ->function (x: T) { return x;} (4) : number ->function (x: T) { return x;} : (x: T) => T ->T : T ->x : T ->T : T - - return x; ->x : T - -} (4); ->4 : number - -// FunctionExpression with no return type annotation with multiple return statements with identical types -var n = function () { ->n : number ->function () { return 3; return 5;}() : number ->function () { return 3; return 5;} : () => number - - return 3; ->3 : number - - return 5; ->5 : number - -}(); - -// Otherwise, the inferred return type is the first of the types of the return statement expressions -// in the function body that is a supertype of each of the others, -// ignoring return statements with no expressions. -// A compile - time error occurs if no return statement expression has a type that is a supertype of each of the others. -// FunctionExpression with no return type annotation with multiple return statements with subtype relation between returns -class Base { private m; } ->Base : Base ->m : any - -class Derived extends Base { private q; } ->Derived : Derived ->Base : Base ->q : any - -var b: Base; ->b : Base ->Base : Base - -var b = function () { ->b : Base ->function () { return new Base(); return new Derived();} () : Base ->function () { return new Base(); return new Derived();} : () => Base - - return new Base(); return new Derived(); ->new Base() : Base ->Base : typeof Base ->new Derived() : Derived ->Derived : typeof Derived - -} (); - -// FunctionExpression with no return type annotation with multiple return statements with one a recursive call -var a = function f() { ->a : any ->function f() { return new Base(); return new Derived(); return f(); // ?} () : any ->function f() { return new Base(); return new Derived(); return f(); // ?} : () => any ->f : () => any - - return new Base(); return new Derived(); return f(); // ? ->new Base() : Base ->Base : typeof Base ->new Derived() : Derived ->Derived : typeof Derived ->f() : any ->f : () => any - -} (); - -// FunctionExpression with non -void return type annotation with a single throw statement -undefined === function (): number { ->undefined === function (): number { throw undefined;} : boolean ->undefined : undefined ->function (): number { throw undefined;} : () => number - - throw undefined; ->undefined : undefined - -}; - -// Type of 'this' in function implementation is 'any' -function thisFunc() { ->thisFunc : () => void - - var x = this; ->x : any ->this : any - - var x: any; ->x : any -} - -// Function signature with optional parameter, no type annotation and initializer has initializer's type -function opt1(n = 4) { ->opt1 : (n?: number) => void ->n : number ->4 : number - - var m = n; ->m : number ->n : number - - var m: number; ->m : number -} - -// Function signature with optional parameter, no type annotation and initializer has initializer's widened type -function opt2(n = { x: null, y: undefined }) { ->opt2 : (n?: { x: any; y: any; }) => void ->n : { x: any; y: any; } ->{ x: null, y: undefined } : { x: null; y: undefined; } ->x : null ->null : null ->y : undefined ->undefined : undefined - - var m = n; ->m : { x: any; y: any; } ->n : { x: any; y: any; } - - var m: { x: any; y: any }; ->m : { x: any; y: any; } ->x : any ->y : any -} - -// Function signature with initializer referencing other parameter to the left -function opt3(n: number, m = n) { ->opt3 : (n: number, m?: number) => void ->n : number ->m : number ->n : number - - var y = m; ->y : number ->m : number - - var y: number; ->y : number -} - -// Function signature with optional parameter has correct codegen -// (tested above) - -// FunctionExpression with non -void return type annotation return with no expression -function f6(): number { ->f6 : () => number - - return; -} - -class Derived2 extends Base { private r: string; } ->Derived2 : Derived2 ->Base : Base ->r : string - -class AnotherClass { private x } ->AnotherClass : AnotherClass ->x : any - -// if f is a contextually typed function expression, the inferred return type is the union type -// of the types of the return statement expressions in the function body, -// ignoring return statements with no expressions. -var f7: (x: number) => string | number = x => { // should be (x: number) => number | string ->f7 : (x: number) => string | number ->x : number ->x => { // should be (x: number) => number | string if (x < 0) { return x; } return x.toString();} : (x: number) => number | string ->x : number - - if (x < 0) { return x; } ->x < 0 : boolean ->x : number ->0 : number ->x : number - - return x.toString(); ->x.toString() : string ->x.toString : (radix?: number) => string ->x : number ->toString : (radix?: number) => string -} -var f8: (x: number) => any = x => { // should be (x: number) => Base ->f8 : (x: number) => any ->x : number ->x => { // should be (x: number) => Base return new Base(); return new Derived2();} : (x: number) => Base ->x : number - - return new Base(); ->new Base() : Base ->Base : typeof Base - - return new Derived2(); ->new Derived2() : Derived2 ->Derived2 : typeof Derived2 -} -var f9: (x: number) => any = x => { // should be (x: number) => Base ->f9 : (x: number) => any ->x : number ->x => { // should be (x: number) => Base return new Base(); return new Derived(); return new Derived2();} : (x: number) => Base ->x : number - - return new Base(); ->new Base() : Base ->Base : typeof Base - - return new Derived(); ->new Derived() : Derived ->Derived : typeof Derived - - return new Derived2(); ->new Derived2() : Derived2 ->Derived2 : typeof Derived2 -} -var f10: (x: number) => any = x => { // should be (x: number) => Derived | Derived1 ->f10 : (x: number) => any ->x : number ->x => { // should be (x: number) => Derived | Derived1 return new Derived(); return new Derived2();} : (x: number) => Derived | Derived2 ->x : number - - return new Derived(); ->new Derived() : Derived ->Derived : typeof Derived - - return new Derived2(); ->new Derived2() : Derived2 ->Derived2 : typeof Derived2 -} -var f11: (x: number) => any = x => { // should be (x: number) => Base | AnotherClass ->f11 : (x: number) => any ->x : number ->x => { // should be (x: number) => Base | AnotherClass return new Base(); return new AnotherClass();} : (x: number) => Base | AnotherClass ->x : number - - return new Base(); ->new Base() : Base ->Base : typeof Base - - return new AnotherClass(); ->new AnotherClass() : AnotherClass ->AnotherClass : typeof AnotherClass -} -var f12: (x: number) => any = x => { // should be (x: number) => Base | AnotherClass ->f12 : (x: number) => any ->x : number ->x => { // should be (x: number) => Base | AnotherClass return new Base(); return; // should be ignored return new AnotherClass();} : (x: number) => Base | AnotherClass ->x : number - - return new Base(); ->new Base() : Base ->Base : typeof Base - - return; // should be ignored - return new AnotherClass(); ->new AnotherClass() : AnotherClass ->AnotherClass : typeof AnotherClass -} diff --git a/tests/baselines/reference/functionOverloads12.errors.txt b/tests/baselines/reference/functionOverloads12.errors.txt new file mode 100644 index 00000000000..fac5cd71afe --- /dev/null +++ b/tests/baselines/reference/functionOverloads12.errors.txt @@ -0,0 +1,10 @@ +tests/cases/compiler/functionOverloads12.ts(3,48): error TS7027: Unreachable code detected. + + +==== tests/cases/compiler/functionOverloads12.ts (1 errors) ==== + function foo():string; + function foo():number; + function foo():any { if (true) return ""; else return 0;} + ~~~~~~ +!!! error TS7027: Unreachable code detected. + \ No newline at end of file diff --git a/tests/baselines/reference/functionOverloads12.symbols b/tests/baselines/reference/functionOverloads12.symbols deleted file mode 100644 index 583e7f5c045..00000000000 --- a/tests/baselines/reference/functionOverloads12.symbols +++ /dev/null @@ -1,10 +0,0 @@ -=== tests/cases/compiler/functionOverloads12.ts === -function foo():string; ->foo : Symbol(foo, Decl(functionOverloads12.ts, 0, 0), Decl(functionOverloads12.ts, 0, 22), Decl(functionOverloads12.ts, 1, 22)) - -function foo():number; ->foo : Symbol(foo, Decl(functionOverloads12.ts, 0, 0), Decl(functionOverloads12.ts, 0, 22), Decl(functionOverloads12.ts, 1, 22)) - -function foo():any { if (true) return ""; else return 0;} ->foo : Symbol(foo, Decl(functionOverloads12.ts, 0, 0), Decl(functionOverloads12.ts, 0, 22), Decl(functionOverloads12.ts, 1, 22)) - diff --git a/tests/baselines/reference/functionOverloads12.types b/tests/baselines/reference/functionOverloads12.types deleted file mode 100644 index 20f5ee5d556..00000000000 --- a/tests/baselines/reference/functionOverloads12.types +++ /dev/null @@ -1,13 +0,0 @@ -=== tests/cases/compiler/functionOverloads12.ts === -function foo():string; ->foo : { (): string; (): number; } - -function foo():number; ->foo : { (): string; (): number; } - -function foo():any { if (true) return ""; else return 0;} ->foo : { (): string; (): number; } ->true : boolean ->"" : string ->0 : number - diff --git a/tests/baselines/reference/functionReturn.errors.txt b/tests/baselines/reference/functionReturn.errors.txt new file mode 100644 index 00000000000..d5f78b2534d --- /dev/null +++ b/tests/baselines/reference/functionReturn.errors.txt @@ -0,0 +1,23 @@ +tests/cases/compiler/functionReturn.ts(9,5): error TS7027: Unreachable code detected. +tests/cases/compiler/functionReturn.ts(13,5): error TS7027: Unreachable code detected. + + +==== tests/cases/compiler/functionReturn.ts (2 errors) ==== + function f0(): void { } + function f1() { + var n: any = f0(); + } + function f2(): any { } + function f3(): string { return; } + function f4(): string { + return ''; + return; + ~~~~~~ +!!! error TS7027: Unreachable code detected. + } + function f5(): string { + return ''; + return undefined; + ~~~~~~ +!!! error TS7027: Unreachable code detected. + } \ No newline at end of file diff --git a/tests/baselines/reference/functionReturn.symbols b/tests/baselines/reference/functionReturn.symbols deleted file mode 100644 index 9c6b794b3d0..00000000000 --- a/tests/baselines/reference/functionReturn.symbols +++ /dev/null @@ -1,30 +0,0 @@ -=== tests/cases/compiler/functionReturn.ts === -function f0(): void { } ->f0 : Symbol(f0, Decl(functionReturn.ts, 0, 0)) - -function f1() { ->f1 : Symbol(f1, Decl(functionReturn.ts, 0, 23)) - - var n: any = f0(); ->n : Symbol(n, Decl(functionReturn.ts, 2, 7)) ->f0 : Symbol(f0, Decl(functionReturn.ts, 0, 0)) -} -function f2(): any { } ->f2 : Symbol(f2, Decl(functionReturn.ts, 3, 1)) - -function f3(): string { return; } ->f3 : Symbol(f3, Decl(functionReturn.ts, 4, 22)) - -function f4(): string { ->f4 : Symbol(f4, Decl(functionReturn.ts, 5, 33)) - - return ''; - return; -} -function f5(): string { ->f5 : Symbol(f5, Decl(functionReturn.ts, 9, 1)) - - return ''; - return undefined; ->undefined : Symbol(undefined) -} diff --git a/tests/baselines/reference/functionReturn.types b/tests/baselines/reference/functionReturn.types deleted file mode 100644 index 6fc9d680db9..00000000000 --- a/tests/baselines/reference/functionReturn.types +++ /dev/null @@ -1,35 +0,0 @@ -=== tests/cases/compiler/functionReturn.ts === -function f0(): void { } ->f0 : () => void - -function f1() { ->f1 : () => void - - var n: any = f0(); ->n : any ->f0() : void ->f0 : () => void -} -function f2(): any { } ->f2 : () => any - -function f3(): string { return; } ->f3 : () => string - -function f4(): string { ->f4 : () => string - - return ''; ->'' : string - - return; -} -function f5(): string { ->f5 : () => string - - return ''; ->'' : string - - return undefined; ->undefined : undefined -} diff --git a/tests/baselines/reference/functionWithMultipleReturnStatements.errors.txt b/tests/baselines/reference/functionWithMultipleReturnStatements.errors.txt index 8a57d8e08e6..4c21fc6814c 100644 --- a/tests/baselines/reference/functionWithMultipleReturnStatements.errors.txt +++ b/tests/baselines/reference/functionWithMultipleReturnStatements.errors.txt @@ -1,15 +1,20 @@ tests/cases/conformance/types/typeRelationships/bestCommonType/functionWithMultipleReturnStatements.ts(4,10): error TS2354: No best common type exists among return expressions. +tests/cases/conformance/types/typeRelationships/bestCommonType/functionWithMultipleReturnStatements.ts(8,9): error TS7027: Unreachable code detected. tests/cases/conformance/types/typeRelationships/bestCommonType/functionWithMultipleReturnStatements.ts(12,10): error TS2354: No best common type exists among return expressions. +tests/cases/conformance/types/typeRelationships/bestCommonType/functionWithMultipleReturnStatements.ts(15,12): error TS7027: Unreachable code detected. tests/cases/conformance/types/typeRelationships/bestCommonType/functionWithMultipleReturnStatements.ts(22,10): error TS2354: No best common type exists among return expressions. tests/cases/conformance/types/typeRelationships/bestCommonType/functionWithMultipleReturnStatements.ts(31,10): error TS2354: No best common type exists among return expressions. tests/cases/conformance/types/typeRelationships/bestCommonType/functionWithMultipleReturnStatements.ts(43,10): error TS2354: No best common type exists among return expressions. +tests/cases/conformance/types/typeRelationships/bestCommonType/functionWithMultipleReturnStatements.ts(45,5): error TS7027: Unreachable code detected. tests/cases/conformance/types/typeRelationships/bestCommonType/functionWithMultipleReturnStatements.ts(48,10): error TS2354: No best common type exists among return expressions. +tests/cases/conformance/types/typeRelationships/bestCommonType/functionWithMultipleReturnStatements.ts(52,9): error TS7027: Unreachable code detected. tests/cases/conformance/types/typeRelationships/bestCommonType/functionWithMultipleReturnStatements.ts(56,10): error TS2354: No best common type exists among return expressions. tests/cases/conformance/types/typeRelationships/bestCommonType/functionWithMultipleReturnStatements.ts(56,13): error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list. tests/cases/conformance/types/typeRelationships/bestCommonType/functionWithMultipleReturnStatements.ts(56,26): error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list. +tests/cases/conformance/types/typeRelationships/bestCommonType/functionWithMultipleReturnStatements.ts(60,9): error TS7027: Unreachable code detected. -==== tests/cases/conformance/types/typeRelationships/bestCommonType/functionWithMultipleReturnStatements.ts (9 errors) ==== +==== tests/cases/conformance/types/typeRelationships/bestCommonType/functionWithMultipleReturnStatements.ts (14 errors) ==== // return type of a function with multiple returns is the BCT of each return statement // it is an error if there is no single BCT, these are error cases @@ -20,6 +25,8 @@ tests/cases/conformance/types/typeRelationships/bestCommonType/functionWithMulti return 1; } else { return ''; + ~~~~~~ +!!! error TS7027: Unreachable code detected. } } @@ -29,6 +36,8 @@ tests/cases/conformance/types/typeRelationships/bestCommonType/functionWithMulti if (true) { return 1; } else if (false) { + ~~ +!!! error TS7027: Unreachable code detected. return 2; } else { return ''; @@ -65,6 +74,8 @@ tests/cases/conformance/types/typeRelationships/bestCommonType/functionWithMulti !!! error TS2354: No best common type exists among return expressions. return 1; return ''; + ~~~~~~ +!!! error TS7027: Unreachable code detected. } function f6(x: T, y:U) { @@ -74,6 +85,8 @@ tests/cases/conformance/types/typeRelationships/bestCommonType/functionWithMulti return x; } else { return y; + ~~~~~~ +!!! error TS7027: Unreachable code detected. } } @@ -88,6 +101,8 @@ tests/cases/conformance/types/typeRelationships/bestCommonType/functionWithMulti return x; } else { return y; + ~~~~~~ +!!! error TS7027: Unreachable code detected. } } \ No newline at end of file diff --git a/tests/baselines/reference/functionWithMultipleReturnStatements2.errors.txt b/tests/baselines/reference/functionWithMultipleReturnStatements2.errors.txt index bbaa5a85578..a965a1a9a99 100644 --- a/tests/baselines/reference/functionWithMultipleReturnStatements2.errors.txt +++ b/tests/baselines/reference/functionWithMultipleReturnStatements2.errors.txt @@ -1,8 +1,16 @@ +tests/cases/conformance/types/typeRelationships/bestCommonType/functionWithMultipleReturnStatements2.ts(8,9): error TS7027: Unreachable code detected. +tests/cases/conformance/types/typeRelationships/bestCommonType/functionWithMultipleReturnStatements2.ts(15,12): error TS7027: Unreachable code detected. +tests/cases/conformance/types/typeRelationships/bestCommonType/functionWithMultipleReturnStatements2.ts(36,5): error TS7027: Unreachable code detected. +tests/cases/conformance/types/typeRelationships/bestCommonType/functionWithMultipleReturnStatements2.ts(43,9): error TS7027: Unreachable code detected. tests/cases/conformance/types/typeRelationships/bestCommonType/functionWithMultipleReturnStatements2.ts(58,10): error TS2354: No best common type exists among return expressions. +tests/cases/conformance/types/typeRelationships/bestCommonType/functionWithMultipleReturnStatements2.ts(62,9): error TS7027: Unreachable code detected. tests/cases/conformance/types/typeRelationships/bestCommonType/functionWithMultipleReturnStatements2.ts(67,10): error TS2354: No best common type exists among return expressions. +tests/cases/conformance/types/typeRelationships/bestCommonType/functionWithMultipleReturnStatements2.ts(71,9): error TS7027: Unreachable code detected. +tests/cases/conformance/types/typeRelationships/bestCommonType/functionWithMultipleReturnStatements2.ts(80,9): error TS7027: Unreachable code detected. +tests/cases/conformance/types/typeRelationships/bestCommonType/functionWithMultipleReturnStatements2.ts(89,9): error TS7027: Unreachable code detected. -==== tests/cases/conformance/types/typeRelationships/bestCommonType/functionWithMultipleReturnStatements2.ts (2 errors) ==== +==== tests/cases/conformance/types/typeRelationships/bestCommonType/functionWithMultipleReturnStatements2.ts (10 errors) ==== // return type of a function with multiple returns is the BCT of each return statement // no errors expected here @@ -11,6 +19,8 @@ tests/cases/conformance/types/typeRelationships/bestCommonType/functionWithMulti return 1; } else { return null; + ~~~~~~ +!!! error TS7027: Unreachable code detected. } } @@ -18,6 +28,8 @@ tests/cases/conformance/types/typeRelationships/bestCommonType/functionWithMulti if (true) { return 1; } else if (false) { + ~~ +!!! error TS7027: Unreachable code detected. return null; } else { return 2; @@ -39,6 +51,8 @@ tests/cases/conformance/types/typeRelationships/bestCommonType/functionWithMulti function f5() { return 1; return new Object(); + ~~~~~~ +!!! error TS7027: Unreachable code detected. } function f6(x: T) { @@ -46,6 +60,8 @@ tests/cases/conformance/types/typeRelationships/bestCommonType/functionWithMulti return x; } else { return null; + ~~~~~~ +!!! error TS7027: Unreachable code detected. } } @@ -67,6 +83,8 @@ tests/cases/conformance/types/typeRelationships/bestCommonType/functionWithMulti return a; } else { return b; + ~~~~~~ +!!! error TS7027: Unreachable code detected. } } @@ -78,6 +96,8 @@ tests/cases/conformance/types/typeRelationships/bestCommonType/functionWithMulti return b; } else { return a; + ~~~~~~ +!!! error TS7027: Unreachable code detected. } } @@ -87,6 +107,8 @@ tests/cases/conformance/types/typeRelationships/bestCommonType/functionWithMulti return (x: number) => { } } else { return (x: Object) => { } + ~~~~~~ +!!! error TS7027: Unreachable code detected. } } @@ -96,5 +118,7 @@ tests/cases/conformance/types/typeRelationships/bestCommonType/functionWithMulti return (x: Object) => { } } else { return (x: number) => { } + ~~~~~~ +!!! error TS7027: Unreachable code detected. } } \ No newline at end of file diff --git a/tests/baselines/reference/functionWithNoBestCommonType1.errors.txt b/tests/baselines/reference/functionWithNoBestCommonType1.errors.txt index 3c8fef3eb49..4cc440ee397 100644 --- a/tests/baselines/reference/functionWithNoBestCommonType1.errors.txt +++ b/tests/baselines/reference/functionWithNoBestCommonType1.errors.txt @@ -1,12 +1,15 @@ tests/cases/compiler/functionWithNoBestCommonType1.ts(1,10): error TS2354: No best common type exists among return expressions. +tests/cases/compiler/functionWithNoBestCommonType1.ts(3,5): error TS7027: Unreachable code detected. -==== tests/cases/compiler/functionWithNoBestCommonType1.ts (1 errors) ==== +==== tests/cases/compiler/functionWithNoBestCommonType1.ts (2 errors) ==== function foo() { ~~~ !!! error TS2354: No best common type exists among return expressions. return true; return bar(); + ~~~~~~ +!!! error TS7027: Unreachable code detected. } function bar(): void { diff --git a/tests/baselines/reference/functionWithNoBestCommonType2.errors.txt b/tests/baselines/reference/functionWithNoBestCommonType2.errors.txt index 981e330d9b5..a93161b27b8 100644 --- a/tests/baselines/reference/functionWithNoBestCommonType2.errors.txt +++ b/tests/baselines/reference/functionWithNoBestCommonType2.errors.txt @@ -1,12 +1,15 @@ tests/cases/compiler/functionWithNoBestCommonType2.ts(1,9): error TS2354: No best common type exists among return expressions. +tests/cases/compiler/functionWithNoBestCommonType2.ts(3,4): error TS7027: Unreachable code detected. -==== tests/cases/compiler/functionWithNoBestCommonType2.ts (1 errors) ==== +==== tests/cases/compiler/functionWithNoBestCommonType2.ts (2 errors) ==== var v = function () { ~~~~~~~~ !!! error TS2354: No best common type exists among return expressions. return true; return bar(); + ~~~~~~ +!!! error TS7027: Unreachable code detected. }; function bar(): void { diff --git a/tests/baselines/reference/functionsMissingReturnStatementsAndExpressions.errors.txt b/tests/baselines/reference/functionsMissingReturnStatementsAndExpressions.errors.txt index 88b0c8d5e14..3a128de4cee 100644 --- a/tests/baselines/reference/functionsMissingReturnStatementsAndExpressions.errors.txt +++ b/tests/baselines/reference/functionsMissingReturnStatementsAndExpressions.errors.txt @@ -1,9 +1,12 @@ tests/cases/compiler/functionsMissingReturnStatementsAndExpressions.ts(2,16): error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. +tests/cases/compiler/functionsMissingReturnStatementsAndExpressions.ts(68,5): error TS7027: Unreachable code detected. +tests/cases/compiler/functionsMissingReturnStatementsAndExpressions.ts(74,5): error TS7027: Unreachable code detected. tests/cases/compiler/functionsMissingReturnStatementsAndExpressions.ts(94,16): error TS2378: A 'get' accessor must return a value. +tests/cases/compiler/functionsMissingReturnStatementsAndExpressions.ts(116,9): error TS7027: Unreachable code detected. tests/cases/compiler/functionsMissingReturnStatementsAndExpressions.ts(117,5): error TS1003: Identifier expected. -==== tests/cases/compiler/functionsMissingReturnStatementsAndExpressions.ts (3 errors) ==== +==== tests/cases/compiler/functionsMissingReturnStatementsAndExpressions.ts (6 errors) ==== function f1(): string { ~~~~~~ @@ -74,12 +77,16 @@ tests/cases/compiler/functionsMissingReturnStatementsAndExpressions.ts(117,5): e // if no return statements are present but we are annotated. throw undefined; throw null; + ~~~~~ +!!! error TS7027: Unreachable code detected. } function f15(): number { // Fine, since we have a return statement somewhere. throw undefined; throw null; + ~~~~~ +!!! error TS7027: Unreachable code detected. return; } @@ -124,6 +131,8 @@ tests/cases/compiler/functionsMissingReturnStatementsAndExpressions.ts(117,5): e // if no return statements are present but we are a get accessor. throw null; throw undefined. + ~~~~~ +!!! error TS7027: Unreachable code detected. } ~ !!! error TS1003: Identifier expected. diff --git a/tests/baselines/reference/generatedContextualTyping.errors.txt b/tests/baselines/reference/generatedContextualTyping.errors.txt new file mode 100644 index 00000000000..a2f95cdcb23 --- /dev/null +++ b/tests/baselines/reference/generatedContextualTyping.errors.txt @@ -0,0 +1,393 @@ +tests/cases/conformance/expressions/contextualTyping/generatedContextualTyping.ts(150,56): error TS7027: Unreachable code detected. +tests/cases/conformance/expressions/contextualTyping/generatedContextualTyping.ts(151,72): error TS7027: Unreachable code detected. +tests/cases/conformance/expressions/contextualTyping/generatedContextualTyping.ts(152,78): error TS7027: Unreachable code detected. +tests/cases/conformance/expressions/contextualTyping/generatedContextualTyping.ts(153,59): error TS7027: Unreachable code detected. +tests/cases/conformance/expressions/contextualTyping/generatedContextualTyping.ts(154,75): error TS7027: Unreachable code detected. +tests/cases/conformance/expressions/contextualTyping/generatedContextualTyping.ts(155,81): error TS7027: Unreachable code detected. +tests/cases/conformance/expressions/contextualTyping/generatedContextualTyping.ts(156,44): error TS7027: Unreachable code detected. +tests/cases/conformance/expressions/contextualTyping/generatedContextualTyping.ts(157,49): error TS7027: Unreachable code detected. +tests/cases/conformance/expressions/contextualTyping/generatedContextualTyping.ts(158,60): error TS7027: Unreachable code detected. +tests/cases/conformance/expressions/contextualTyping/generatedContextualTyping.ts(159,59): error TS7027: Unreachable code detected. +tests/cases/conformance/expressions/contextualTyping/generatedContextualTyping.ts(160,84): error TS7027: Unreachable code detected. +tests/cases/conformance/expressions/contextualTyping/generatedContextualTyping.ts(161,77): error TS7027: Unreachable code detected. + + +==== tests/cases/conformance/expressions/contextualTyping/generatedContextualTyping.ts (12 errors) ==== + class Base { private p; } + class Derived1 extends Base { private m; } + class Derived2 extends Base { private n; } + interface Genric { func(n: T[]); } + var b = new Base(), d1 = new Derived1(), d2 = new Derived2(); + var x1: () => Base[] = () => [d1, d2]; + var x2: () => Base[] = function() { return [d1, d2] }; + var x3: () => Base[] = function named() { return [d1, d2] }; + var x4: { (): Base[]; } = () => [d1, d2]; + var x5: { (): Base[]; } = function() { return [d1, d2] }; + var x6: { (): Base[]; } = function named() { return [d1, d2] }; + var x7: Base[] = [d1, d2]; + var x8: Array = [d1, d2]; + var x9: { [n: number]: Base; } = [d1, d2]; + var x10: {n: Base[]; } = { n: [d1, d2] }; + var x11: (s: Base[]) => any = n => { var n: Base[]; return null; }; + var x12: Genric = { func: n => { return [d1, d2]; } }; + class x13 { member: () => Base[] = () => [d1, d2] } + class x14 { member: () => Base[] = function() { return [d1, d2] } } + class x15 { member: () => Base[] = function named() { return [d1, d2] } } + class x16 { member: { (): Base[]; } = () => [d1, d2] } + class x17 { member: { (): Base[]; } = function() { return [d1, d2] } } + class x18 { member: { (): Base[]; } = function named() { return [d1, d2] } } + class x19 { member: Base[] = [d1, d2] } + class x20 { member: Array = [d1, d2] } + class x21 { member: { [n: number]: Base; } = [d1, d2] } + class x22 { member: {n: Base[]; } = { n: [d1, d2] } } + class x23 { member: (s: Base[]) => any = n => { var n: Base[]; return null; } } + class x24 { member: Genric = { func: n => { return [d1, d2]; } } } + class x25 { private member: () => Base[] = () => [d1, d2] } + class x26 { private member: () => Base[] = function() { return [d1, d2] } } + class x27 { private member: () => Base[] = function named() { return [d1, d2] } } + class x28 { private member: { (): Base[]; } = () => [d1, d2] } + class x29 { private member: { (): Base[]; } = function() { return [d1, d2] } } + class x30 { private member: { (): Base[]; } = function named() { return [d1, d2] } } + class x31 { private member: Base[] = [d1, d2] } + class x32 { private member: Array = [d1, d2] } + class x33 { private member: { [n: number]: Base; } = [d1, d2] } + class x34 { private member: {n: Base[]; } = { n: [d1, d2] } } + class x35 { private member: (s: Base[]) => any = n => { var n: Base[]; return null; } } + class x36 { private member: Genric = { func: n => { return [d1, d2]; } } } + class x37 { public member: () => Base[] = () => [d1, d2] } + class x38 { public member: () => Base[] = function() { return [d1, d2] } } + class x39 { public member: () => Base[] = function named() { return [d1, d2] } } + class x40 { public member: { (): Base[]; } = () => [d1, d2] } + class x41 { public member: { (): Base[]; } = function() { return [d1, d2] } } + class x42 { public member: { (): Base[]; } = function named() { return [d1, d2] } } + class x43 { public member: Base[] = [d1, d2] } + class x44 { public member: Array = [d1, d2] } + class x45 { public member: { [n: number]: Base; } = [d1, d2] } + class x46 { public member: {n: Base[]; } = { n: [d1, d2] } } + class x47 { public member: (s: Base[]) => any = n => { var n: Base[]; return null; } } + class x48 { public member: Genric = { func: n => { return [d1, d2]; } } } + class x49 { static member: () => Base[] = () => [d1, d2] } + class x50 { static member: () => Base[] = function() { return [d1, d2] } } + class x51 { static member: () => Base[] = function named() { return [d1, d2] } } + class x52 { static member: { (): Base[]; } = () => [d1, d2] } + class x53 { static member: { (): Base[]; } = function() { return [d1, d2] } } + class x54 { static member: { (): Base[]; } = function named() { return [d1, d2] } } + class x55 { static member: Base[] = [d1, d2] } + class x56 { static member: Array = [d1, d2] } + class x57 { static member: { [n: number]: Base; } = [d1, d2] } + class x58 { static member: {n: Base[]; } = { n: [d1, d2] } } + class x59 { static member: (s: Base[]) => any = n => { var n: Base[]; return null; } } + class x60 { static member: Genric = { func: n => { return [d1, d2]; } } } + class x61 { private static member: () => Base[] = () => [d1, d2] } + class x62 { private static member: () => Base[] = function() { return [d1, d2] } } + class x63 { private static member: () => Base[] = function named() { return [d1, d2] } } + class x64 { private static member: { (): Base[]; } = () => [d1, d2] } + class x65 { private static member: { (): Base[]; } = function() { return [d1, d2] } } + class x66 { private static member: { (): Base[]; } = function named() { return [d1, d2] } } + class x67 { private static member: Base[] = [d1, d2] } + class x68 { private static member: Array = [d1, d2] } + class x69 { private static member: { [n: number]: Base; } = [d1, d2] } + class x70 { private static member: {n: Base[]; } = { n: [d1, d2] } } + class x71 { private static member: (s: Base[]) => any = n => { var n: Base[]; return null; } } + class x72 { private static member: Genric = { func: n => { return [d1, d2]; } } } + class x73 { public static member: () => Base[] = () => [d1, d2] } + class x74 { public static member: () => Base[] = function() { return [d1, d2] } } + class x75 { public static member: () => Base[] = function named() { return [d1, d2] } } + class x76 { public static member: { (): Base[]; } = () => [d1, d2] } + class x77 { public static member: { (): Base[]; } = function() { return [d1, d2] } } + class x78 { public static member: { (): Base[]; } = function named() { return [d1, d2] } } + class x79 { public static member: Base[] = [d1, d2] } + class x80 { public static member: Array = [d1, d2] } + class x81 { public static member: { [n: number]: Base; } = [d1, d2] } + class x82 { public static member: {n: Base[]; } = { n: [d1, d2] } } + class x83 { public static member: (s: Base[]) => any = n => { var n: Base[]; return null; } } + class x84 { public static member: Genric = { func: n => { return [d1, d2]; } } } + class x85 { constructor(parm: () => Base[] = () => [d1, d2]) { } } + class x86 { constructor(parm: () => Base[] = function() { return [d1, d2] }) { } } + class x87 { constructor(parm: () => Base[] = function named() { return [d1, d2] }) { } } + class x88 { constructor(parm: { (): Base[]; } = () => [d1, d2]) { } } + class x89 { constructor(parm: { (): Base[]; } = function() { return [d1, d2] }) { } } + class x90 { constructor(parm: { (): Base[]; } = function named() { return [d1, d2] }) { } } + class x91 { constructor(parm: Base[] = [d1, d2]) { } } + class x92 { constructor(parm: Array = [d1, d2]) { } } + class x93 { constructor(parm: { [n: number]: Base; } = [d1, d2]) { } } + class x94 { constructor(parm: {n: Base[]; } = { n: [d1, d2] }) { } } + class x95 { constructor(parm: (s: Base[]) => any = n => { var n: Base[]; return null; }) { } } + class x96 { constructor(parm: Genric = { func: n => { return [d1, d2]; } }) { } } + class x97 { constructor(public parm: () => Base[] = () => [d1, d2]) { } } + class x98 { constructor(public parm: () => Base[] = function() { return [d1, d2] }) { } } + class x99 { constructor(public parm: () => Base[] = function named() { return [d1, d2] }) { } } + class x100 { constructor(public parm: { (): Base[]; } = () => [d1, d2]) { } } + class x101 { constructor(public parm: { (): Base[]; } = function() { return [d1, d2] }) { } } + class x102 { constructor(public parm: { (): Base[]; } = function named() { return [d1, d2] }) { } } + class x103 { constructor(public parm: Base[] = [d1, d2]) { } } + class x104 { constructor(public parm: Array = [d1, d2]) { } } + class x105 { constructor(public parm: { [n: number]: Base; } = [d1, d2]) { } } + class x106 { constructor(public parm: {n: Base[]; } = { n: [d1, d2] }) { } } + class x107 { constructor(public parm: (s: Base[]) => any = n => { var n: Base[]; return null; }) { } } + class x108 { constructor(public parm: Genric = { func: n => { return [d1, d2]; } }) { } } + class x109 { constructor(private parm: () => Base[] = () => [d1, d2]) { } } + class x110 { constructor(private parm: () => Base[] = function() { return [d1, d2] }) { } } + class x111 { constructor(private parm: () => Base[] = function named() { return [d1, d2] }) { } } + class x112 { constructor(private parm: { (): Base[]; } = () => [d1, d2]) { } } + class x113 { constructor(private parm: { (): Base[]; } = function() { return [d1, d2] }) { } } + class x114 { constructor(private parm: { (): Base[]; } = function named() { return [d1, d2] }) { } } + class x115 { constructor(private parm: Base[] = [d1, d2]) { } } + class x116 { constructor(private parm: Array = [d1, d2]) { } } + class x117 { constructor(private parm: { [n: number]: Base; } = [d1, d2]) { } } + class x118 { constructor(private parm: {n: Base[]; } = { n: [d1, d2] }) { } } + class x119 { constructor(private parm: (s: Base[]) => any = n => { var n: Base[]; return null; }) { } } + class x120 { constructor(private parm: Genric = { func: n => { return [d1, d2]; } }) { } } + function x121(parm: () => Base[] = () => [d1, d2]) { } + function x122(parm: () => Base[] = function() { return [d1, d2] }) { } + function x123(parm: () => Base[] = function named() { return [d1, d2] }) { } + function x124(parm: { (): Base[]; } = () => [d1, d2]) { } + function x125(parm: { (): Base[]; } = function() { return [d1, d2] }) { } + function x126(parm: { (): Base[]; } = function named() { return [d1, d2] }) { } + function x127(parm: Base[] = [d1, d2]) { } + function x128(parm: Array = [d1, d2]) { } + function x129(parm: { [n: number]: Base; } = [d1, d2]) { } + function x130(parm: {n: Base[]; } = { n: [d1, d2] }) { } + function x131(parm: (s: Base[]) => any = n => { var n: Base[]; return null; }) { } + function x132(parm: Genric = { func: n => { return [d1, d2]; } }) { } + function x133(): () => Base[] { return () => [d1, d2]; } + function x134(): () => Base[] { return function() { return [d1, d2] }; } + function x135(): () => Base[] { return function named() { return [d1, d2] }; } + function x136(): { (): Base[]; } { return () => [d1, d2]; } + function x137(): { (): Base[]; } { return function() { return [d1, d2] }; } + function x138(): { (): Base[]; } { return function named() { return [d1, d2] }; } + function x139(): Base[] { return [d1, d2]; } + function x140(): Array { return [d1, d2]; } + function x141(): { [n: number]: Base; } { return [d1, d2]; } + function x142(): {n: Base[]; } { return { n: [d1, d2] }; } + function x143(): (s: Base[]) => any { return n => { var n: Base[]; return null; }; } + function x144(): Genric { return { func: n => { return [d1, d2]; } }; } + function x145(): () => Base[] { return () => [d1, d2]; return () => [d1, d2]; } + ~~~~~~ +!!! error TS7027: Unreachable code detected. + function x146(): () => Base[] { return function() { return [d1, d2] }; return function() { return [d1, d2] }; } + ~~~~~~ +!!! error TS7027: Unreachable code detected. + function x147(): () => Base[] { return function named() { return [d1, d2] }; return function named() { return [d1, d2] }; } + ~~~~~~ +!!! error TS7027: Unreachable code detected. + function x148(): { (): Base[]; } { return () => [d1, d2]; return () => [d1, d2]; } + ~~~~~~ +!!! error TS7027: Unreachable code detected. + function x149(): { (): Base[]; } { return function() { return [d1, d2] }; return function() { return [d1, d2] }; } + ~~~~~~ +!!! error TS7027: Unreachable code detected. + function x150(): { (): Base[]; } { return function named() { return [d1, d2] }; return function named() { return [d1, d2] }; } + ~~~~~~ +!!! error TS7027: Unreachable code detected. + function x151(): Base[] { return [d1, d2]; return [d1, d2]; } + ~~~~~~ +!!! error TS7027: Unreachable code detected. + function x152(): Array { return [d1, d2]; return [d1, d2]; } + ~~~~~~ +!!! error TS7027: Unreachable code detected. + function x153(): { [n: number]: Base; } { return [d1, d2]; return [d1, d2]; } + ~~~~~~ +!!! error TS7027: Unreachable code detected. + function x154(): {n: Base[]; } { return { n: [d1, d2] }; return { n: [d1, d2] }; } + ~~~~~~ +!!! error TS7027: Unreachable code detected. + function x155(): (s: Base[]) => any { return n => { var n: Base[]; return null; }; return n => { var n: Base[]; return null; }; } + ~~~~~~ +!!! error TS7027: Unreachable code detected. + function x156(): Genric { return { func: n => { return [d1, d2]; } }; return { func: n => { return [d1, d2]; } }; } + ~~~~~~ +!!! error TS7027: Unreachable code detected. + var x157: () => () => Base[] = () => { return () => [d1, d2]; }; + var x158: () => () => Base[] = () => { return function() { return [d1, d2] }; }; + var x159: () => () => Base[] = () => { return function named() { return [d1, d2] }; }; + var x160: () => { (): Base[]; } = () => { return () => [d1, d2]; }; + var x161: () => { (): Base[]; } = () => { return function() { return [d1, d2] }; }; + var x162: () => { (): Base[]; } = () => { return function named() { return [d1, d2] }; }; + var x163: () => Base[] = () => { return [d1, d2]; }; + var x164: () => Array = () => { return [d1, d2]; }; + var x165: () => { [n: number]: Base; } = () => { return [d1, d2]; }; + var x166: () => {n: Base[]; } = () => { return { n: [d1, d2] }; }; + var x167: () => (s: Base[]) => any = () => { return n => { var n: Base[]; return null; }; }; + var x168: () => Genric = () => { return { func: n => { return [d1, d2]; } }; }; + var x169: () => () => Base[] = function() { return () => [d1, d2]; }; + var x170: () => () => Base[] = function() { return function() { return [d1, d2] }; }; + var x171: () => () => Base[] = function() { return function named() { return [d1, d2] }; }; + var x172: () => { (): Base[]; } = function() { return () => [d1, d2]; }; + var x173: () => { (): Base[]; } = function() { return function() { return [d1, d2] }; }; + var x174: () => { (): Base[]; } = function() { return function named() { return [d1, d2] }; }; + var x175: () => Base[] = function() { return [d1, d2]; }; + var x176: () => Array = function() { return [d1, d2]; }; + var x177: () => { [n: number]: Base; } = function() { return [d1, d2]; }; + var x178: () => {n: Base[]; } = function() { return { n: [d1, d2] }; }; + var x179: () => (s: Base[]) => any = function() { return n => { var n: Base[]; return null; }; }; + var x180: () => Genric = function() { return { func: n => { return [d1, d2]; } }; }; + module x181 { var t: () => Base[] = () => [d1, d2]; } + module x182 { var t: () => Base[] = function() { return [d1, d2] }; } + module x183 { var t: () => Base[] = function named() { return [d1, d2] }; } + module x184 { var t: { (): Base[]; } = () => [d1, d2]; } + module x185 { var t: { (): Base[]; } = function() { return [d1, d2] }; } + module x186 { var t: { (): Base[]; } = function named() { return [d1, d2] }; } + module x187 { var t: Base[] = [d1, d2]; } + module x188 { var t: Array = [d1, d2]; } + module x189 { var t: { [n: number]: Base; } = [d1, d2]; } + module x190 { var t: {n: Base[]; } = { n: [d1, d2] }; } + module x191 { var t: (s: Base[]) => any = n => { var n: Base[]; return null; }; } + module x192 { var t: Genric = { func: n => { return [d1, d2]; } }; } + module x193 { export var t: () => Base[] = () => [d1, d2]; } + module x194 { export var t: () => Base[] = function() { return [d1, d2] }; } + module x195 { export var t: () => Base[] = function named() { return [d1, d2] }; } + module x196 { export var t: { (): Base[]; } = () => [d1, d2]; } + module x197 { export var t: { (): Base[]; } = function() { return [d1, d2] }; } + module x198 { export var t: { (): Base[]; } = function named() { return [d1, d2] }; } + module x199 { export var t: Base[] = [d1, d2]; } + module x200 { export var t: Array = [d1, d2]; } + module x201 { export var t: { [n: number]: Base; } = [d1, d2]; } + module x202 { export var t: {n: Base[]; } = { n: [d1, d2] }; } + module x203 { export var t: (s: Base[]) => any = n => { var n: Base[]; return null; }; } + module x204 { export var t: Genric = { func: n => { return [d1, d2]; } }; } + var x206 = <() => Base[]>function() { return [d1, d2] }; + var x207 = <() => Base[]>function named() { return [d1, d2] }; + var x209 = <{ (): Base[]; }>function() { return [d1, d2] }; + var x210 = <{ (): Base[]; }>function named() { return [d1, d2] }; + var x211 = [d1, d2]; + var x212 = >[d1, d2]; + var x213 = <{ [n: number]: Base; }>[d1, d2]; + var x214 = <{n: Base[]; } >{ n: [d1, d2] }; + var x216 = >{ func: n => { return [d1, d2]; } }; + var x217 = (<() => Base[]>undefined) || function() { return [d1, d2] }; + var x218 = (<() => Base[]>undefined) || function named() { return [d1, d2] }; + var x219 = (<{ (): Base[]; }>undefined) || function() { return [d1, d2] }; + var x220 = (<{ (): Base[]; }>undefined) || function named() { return [d1, d2] }; + var x221 = (undefined) || [d1, d2]; + var x222 = (>undefined) || [d1, d2]; + var x223 = (<{ [n: number]: Base; }>undefined) || [d1, d2]; + var x224 = (<{n: Base[]; } >undefined) || { n: [d1, d2] }; + var x225: () => Base[]; x225 = () => [d1, d2]; + var x226: () => Base[]; x226 = function() { return [d1, d2] }; + var x227: () => Base[]; x227 = function named() { return [d1, d2] }; + var x228: { (): Base[]; }; x228 = () => [d1, d2]; + var x229: { (): Base[]; }; x229 = function() { return [d1, d2] }; + var x230: { (): Base[]; }; x230 = function named() { return [d1, d2] }; + var x231: Base[]; x231 = [d1, d2]; + var x232: Array; x232 = [d1, d2]; + var x233: { [n: number]: Base; }; x233 = [d1, d2]; + var x234: {n: Base[]; } ; x234 = { n: [d1, d2] }; + var x235: (s: Base[]) => any; x235 = n => { var n: Base[]; return null; }; + var x236: Genric; x236 = { func: n => { return [d1, d2]; } }; + var x237: { n: () => Base[]; } = { n: () => [d1, d2] }; + var x238: { n: () => Base[]; } = { n: function() { return [d1, d2] } }; + var x239: { n: () => Base[]; } = { n: function named() { return [d1, d2] } }; + var x240: { n: { (): Base[]; }; } = { n: () => [d1, d2] }; + var x241: { n: { (): Base[]; }; } = { n: function() { return [d1, d2] } }; + var x242: { n: { (): Base[]; }; } = { n: function named() { return [d1, d2] } }; + var x243: { n: Base[]; } = { n: [d1, d2] }; + var x244: { n: Array; } = { n: [d1, d2] }; + var x245: { n: { [n: number]: Base; }; } = { n: [d1, d2] }; + var x246: { n: {n: Base[]; } ; } = { n: { n: [d1, d2] } }; + var x247: { n: (s: Base[]) => any; } = { n: n => { var n: Base[]; return null; } }; + var x248: { n: Genric; } = { n: { func: n => { return [d1, d2]; } } }; + var x252: { (): Base[]; }[] = [() => [d1, d2]]; + var x253: { (): Base[]; }[] = [function() { return [d1, d2] }]; + var x254: { (): Base[]; }[] = [function named() { return [d1, d2] }]; + var x255: Base[][] = [[d1, d2]]; + var x256: Array[] = [[d1, d2]]; + var x257: { [n: number]: Base; }[] = [[d1, d2]]; + var x258: {n: Base[]; } [] = [{ n: [d1, d2] }]; + var x260: Genric[] = [{ func: n => { return [d1, d2]; } }]; + var x261: () => Base[] = function() { return [d1, d2] } || undefined; + var x262: () => Base[] = function named() { return [d1, d2] } || undefined; + var x263: { (): Base[]; } = function() { return [d1, d2] } || undefined; + var x264: { (): Base[]; } = function named() { return [d1, d2] } || undefined; + var x265: Base[] = [d1, d2] || undefined; + var x266: Array = [d1, d2] || undefined; + var x267: { [n: number]: Base; } = [d1, d2] || undefined; + var x268: {n: Base[]; } = { n: [d1, d2] } || undefined; + var x269: () => Base[] = undefined || function() { return [d1, d2] }; + var x270: () => Base[] = undefined || function named() { return [d1, d2] }; + var x271: { (): Base[]; } = undefined || function() { return [d1, d2] }; + var x272: { (): Base[]; } = undefined || function named() { return [d1, d2] }; + var x273: Base[] = undefined || [d1, d2]; + var x274: Array = undefined || [d1, d2]; + var x275: { [n: number]: Base; } = undefined || [d1, d2]; + var x276: {n: Base[]; } = undefined || { n: [d1, d2] }; + var x277: () => Base[] = function() { return [d1, d2] } || function() { return [d1, d2] }; + var x278: () => Base[] = function named() { return [d1, d2] } || function named() { return [d1, d2] }; + var x279: { (): Base[]; } = function() { return [d1, d2] } || function() { return [d1, d2] }; + var x280: { (): Base[]; } = function named() { return [d1, d2] } || function named() { return [d1, d2] }; + var x281: Base[] = [d1, d2] || [d1, d2]; + var x282: Array = [d1, d2] || [d1, d2]; + var x283: { [n: number]: Base; } = [d1, d2] || [d1, d2]; + var x284: {n: Base[]; } = { n: [d1, d2] } || { n: [d1, d2] }; + var x285: () => Base[] = true ? () => [d1, d2] : () => [d1, d2]; + var x286: () => Base[] = true ? function() { return [d1, d2] } : function() { return [d1, d2] }; + var x287: () => Base[] = true ? function named() { return [d1, d2] } : function named() { return [d1, d2] }; + var x288: { (): Base[]; } = true ? () => [d1, d2] : () => [d1, d2]; + var x289: { (): Base[]; } = true ? function() { return [d1, d2] } : function() { return [d1, d2] }; + var x290: { (): Base[]; } = true ? function named() { return [d1, d2] } : function named() { return [d1, d2] }; + var x291: Base[] = true ? [d1, d2] : [d1, d2]; + var x292: Array = true ? [d1, d2] : [d1, d2]; + var x293: { [n: number]: Base; } = true ? [d1, d2] : [d1, d2]; + var x294: {n: Base[]; } = true ? { n: [d1, d2] } : { n: [d1, d2] }; + var x295: (s: Base[]) => any = true ? n => { var n: Base[]; return null; } : n => { var n: Base[]; return null; }; + var x296: Genric = true ? { func: n => { return [d1, d2]; } } : { func: n => { return [d1, d2]; } }; + var x297: () => Base[] = true ? undefined : () => [d1, d2]; + var x298: () => Base[] = true ? undefined : function() { return [d1, d2] }; + var x299: () => Base[] = true ? undefined : function named() { return [d1, d2] }; + var x300: { (): Base[]; } = true ? undefined : () => [d1, d2]; + var x301: { (): Base[]; } = true ? undefined : function() { return [d1, d2] }; + var x302: { (): Base[]; } = true ? undefined : function named() { return [d1, d2] }; + var x303: Base[] = true ? undefined : [d1, d2]; + var x304: Array = true ? undefined : [d1, d2]; + var x305: { [n: number]: Base; } = true ? undefined : [d1, d2]; + var x306: {n: Base[]; } = true ? undefined : { n: [d1, d2] }; + var x307: (s: Base[]) => any = true ? undefined : n => { var n: Base[]; return null; }; + var x308: Genric = true ? undefined : { func: n => { return [d1, d2]; } }; + var x309: () => Base[] = true ? () => [d1, d2] : undefined; + var x310: () => Base[] = true ? function() { return [d1, d2] } : undefined; + var x311: () => Base[] = true ? function named() { return [d1, d2] } : undefined; + var x312: { (): Base[]; } = true ? () => [d1, d2] : undefined; + var x313: { (): Base[]; } = true ? function() { return [d1, d2] } : undefined; + var x314: { (): Base[]; } = true ? function named() { return [d1, d2] } : undefined; + var x315: Base[] = true ? [d1, d2] : undefined; + var x316: Array = true ? [d1, d2] : undefined; + var x317: { [n: number]: Base; } = true ? [d1, d2] : undefined; + var x318: {n: Base[]; } = true ? { n: [d1, d2] } : undefined; + var x319: (s: Base[]) => any = true ? n => { var n: Base[]; return null; } : undefined; + var x320: Genric = true ? { func: n => { return [d1, d2]; } } : undefined; + function x321(n: () => Base[]) { }; x321(() => [d1, d2]); + function x322(n: () => Base[]) { }; x322(function() { return [d1, d2] }); + function x323(n: () => Base[]) { }; x323(function named() { return [d1, d2] }); + function x324(n: { (): Base[]; }) { }; x324(() => [d1, d2]); + function x325(n: { (): Base[]; }) { }; x325(function() { return [d1, d2] }); + function x326(n: { (): Base[]; }) { }; x326(function named() { return [d1, d2] }); + function x327(n: Base[]) { }; x327([d1, d2]); + function x328(n: Array) { }; x328([d1, d2]); + function x329(n: { [n: number]: Base; }) { }; x329([d1, d2]); + function x330(n: {n: Base[]; } ) { }; x330({ n: [d1, d2] }); + function x331(n: (s: Base[]) => any) { }; x331(n => { var n: Base[]; return null; }); + function x332(n: Genric) { }; x332({ func: n => { return [d1, d2]; } }); + var x333 = (n: () => Base[]) => n; x333(() => [d1, d2]); + var x334 = (n: () => Base[]) => n; x334(function() { return [d1, d2] }); + var x335 = (n: () => Base[]) => n; x335(function named() { return [d1, d2] }); + var x336 = (n: { (): Base[]; }) => n; x336(() => [d1, d2]); + var x337 = (n: { (): Base[]; }) => n; x337(function() { return [d1, d2] }); + var x338 = (n: { (): Base[]; }) => n; x338(function named() { return [d1, d2] }); + var x339 = (n: Base[]) => n; x339([d1, d2]); + var x340 = (n: Array) => n; x340([d1, d2]); + var x341 = (n: { [n: number]: Base; }) => n; x341([d1, d2]); + var x342 = (n: {n: Base[]; } ) => n; x342({ n: [d1, d2] }); + var x343 = (n: (s: Base[]) => any) => n; x343(n => { var n: Base[]; return null; }); + var x344 = (n: Genric) => n; x344({ func: n => { return [d1, d2]; } }); + var x345 = function(n: () => Base[]) { }; x345(() => [d1, d2]); + var x346 = function(n: () => Base[]) { }; x346(function() { return [d1, d2] }); + var x347 = function(n: () => Base[]) { }; x347(function named() { return [d1, d2] }); + var x348 = function(n: { (): Base[]; }) { }; x348(() => [d1, d2]); + var x349 = function(n: { (): Base[]; }) { }; x349(function() { return [d1, d2] }); + var x350 = function(n: { (): Base[]; }) { }; x350(function named() { return [d1, d2] }); + var x351 = function(n: Base[]) { }; x351([d1, d2]); + var x352 = function(n: Array) { }; x352([d1, d2]); + var x353 = function(n: { [n: number]: Base; }) { }; x353([d1, d2]); + var x354 = function(n: {n: Base[]; } ) { }; x354({ n: [d1, d2] }); + var x355 = function(n: (s: Base[]) => any) { }; x355(n => { var n: Base[]; return null; }); + var x356 = function(n: Genric) { }; x356({ func: n => { return [d1, d2]; } }); \ No newline at end of file diff --git a/tests/baselines/reference/generatedContextualTyping.symbols b/tests/baselines/reference/generatedContextualTyping.symbols deleted file mode 100644 index 287b7be66d0..00000000000 --- a/tests/baselines/reference/generatedContextualTyping.symbols +++ /dev/null @@ -1,2831 +0,0 @@ -=== tests/cases/conformance/expressions/contextualTyping/generatedContextualTyping.ts === -class Base { private p; } ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->p : Symbol(p, Decl(generatedContextualTyping.ts, 0, 12)) - -class Derived1 extends Base { private m; } ->Derived1 : Symbol(Derived1, Decl(generatedContextualTyping.ts, 0, 25)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->m : Symbol(m, Decl(generatedContextualTyping.ts, 1, 29)) - -class Derived2 extends Base { private n; } ->Derived2 : Symbol(Derived2, Decl(generatedContextualTyping.ts, 1, 42)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 2, 29)) - -interface Genric { func(n: T[]); } ->Genric : Symbol(Genric, Decl(generatedContextualTyping.ts, 2, 42)) ->T : Symbol(T, Decl(generatedContextualTyping.ts, 3, 17)) ->func : Symbol(func, Decl(generatedContextualTyping.ts, 3, 21)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 3, 27)) ->T : Symbol(T, Decl(generatedContextualTyping.ts, 3, 17)) - -var b = new Base(), d1 = new Derived1(), d2 = new Derived2(); ->b : Symbol(b, Decl(generatedContextualTyping.ts, 4, 3)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->Derived1 : Symbol(Derived1, Decl(generatedContextualTyping.ts, 0, 25)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) ->Derived2 : Symbol(Derived2, Decl(generatedContextualTyping.ts, 1, 42)) - -var x1: () => Base[] = () => [d1, d2]; ->x1 : Symbol(x1, Decl(generatedContextualTyping.ts, 5, 3)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -var x2: () => Base[] = function() { return [d1, d2] }; ->x2 : Symbol(x2, Decl(generatedContextualTyping.ts, 6, 3)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -var x3: () => Base[] = function named() { return [d1, d2] }; ->x3 : Symbol(x3, Decl(generatedContextualTyping.ts, 7, 3)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->named : Symbol(named, Decl(generatedContextualTyping.ts, 7, 22)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -var x4: { (): Base[]; } = () => [d1, d2]; ->x4 : Symbol(x4, Decl(generatedContextualTyping.ts, 8, 3)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -var x5: { (): Base[]; } = function() { return [d1, d2] }; ->x5 : Symbol(x5, Decl(generatedContextualTyping.ts, 9, 3)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -var x6: { (): Base[]; } = function named() { return [d1, d2] }; ->x6 : Symbol(x6, Decl(generatedContextualTyping.ts, 10, 3)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->named : Symbol(named, Decl(generatedContextualTyping.ts, 10, 25)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -var x7: Base[] = [d1, d2]; ->x7 : Symbol(x7, Decl(generatedContextualTyping.ts, 11, 3)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -var x8: Array = [d1, d2]; ->x8 : Symbol(x8, Decl(generatedContextualTyping.ts, 12, 3)) ->Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -var x9: { [n: number]: Base; } = [d1, d2]; ->x9 : Symbol(x9, Decl(generatedContextualTyping.ts, 13, 3)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 13, 11)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -var x10: {n: Base[]; } = { n: [d1, d2] }; ->x10 : Symbol(x10, Decl(generatedContextualTyping.ts, 14, 3)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 14, 10)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 14, 27)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -var x11: (s: Base[]) => any = n => { var n: Base[]; return null; }; ->x11 : Symbol(x11, Decl(generatedContextualTyping.ts, 15, 3)) ->s : Symbol(s, Decl(generatedContextualTyping.ts, 15, 10)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 15, 29), Decl(generatedContextualTyping.ts, 15, 40)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 15, 29), Decl(generatedContextualTyping.ts, 15, 40)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) - -var x12: Genric = { func: n => { return [d1, d2]; } }; ->x12 : Symbol(x12, Decl(generatedContextualTyping.ts, 16, 3)) ->Genric : Symbol(Genric, Decl(generatedContextualTyping.ts, 2, 42)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->func : Symbol(func, Decl(generatedContextualTyping.ts, 16, 25)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 16, 31)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -class x13 { member: () => Base[] = () => [d1, d2] } ->x13 : Symbol(x13, Decl(generatedContextualTyping.ts, 16, 60)) ->member : Symbol(member, Decl(generatedContextualTyping.ts, 17, 11)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -class x14 { member: () => Base[] = function() { return [d1, d2] } } ->x14 : Symbol(x14, Decl(generatedContextualTyping.ts, 17, 51)) ->member : Symbol(member, Decl(generatedContextualTyping.ts, 18, 11)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -class x15 { member: () => Base[] = function named() { return [d1, d2] } } ->x15 : Symbol(x15, Decl(generatedContextualTyping.ts, 18, 67)) ->member : Symbol(member, Decl(generatedContextualTyping.ts, 19, 11)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->named : Symbol(named, Decl(generatedContextualTyping.ts, 19, 34)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -class x16 { member: { (): Base[]; } = () => [d1, d2] } ->x16 : Symbol(x16, Decl(generatedContextualTyping.ts, 19, 73)) ->member : Symbol(member, Decl(generatedContextualTyping.ts, 20, 11)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -class x17 { member: { (): Base[]; } = function() { return [d1, d2] } } ->x17 : Symbol(x17, Decl(generatedContextualTyping.ts, 20, 54)) ->member : Symbol(member, Decl(generatedContextualTyping.ts, 21, 11)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -class x18 { member: { (): Base[]; } = function named() { return [d1, d2] } } ->x18 : Symbol(x18, Decl(generatedContextualTyping.ts, 21, 70)) ->member : Symbol(member, Decl(generatedContextualTyping.ts, 22, 11)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->named : Symbol(named, Decl(generatedContextualTyping.ts, 22, 37)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -class x19 { member: Base[] = [d1, d2] } ->x19 : Symbol(x19, Decl(generatedContextualTyping.ts, 22, 76)) ->member : Symbol(member, Decl(generatedContextualTyping.ts, 23, 11)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -class x20 { member: Array = [d1, d2] } ->x20 : Symbol(x20, Decl(generatedContextualTyping.ts, 23, 39)) ->member : Symbol(member, Decl(generatedContextualTyping.ts, 24, 11)) ->Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -class x21 { member: { [n: number]: Base; } = [d1, d2] } ->x21 : Symbol(x21, Decl(generatedContextualTyping.ts, 24, 44)) ->member : Symbol(member, Decl(generatedContextualTyping.ts, 25, 11)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 25, 23)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -class x22 { member: {n: Base[]; } = { n: [d1, d2] } } ->x22 : Symbol(x22, Decl(generatedContextualTyping.ts, 25, 55)) ->member : Symbol(member, Decl(generatedContextualTyping.ts, 26, 11)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 26, 21)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 26, 38)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -class x23 { member: (s: Base[]) => any = n => { var n: Base[]; return null; } } ->x23 : Symbol(x23, Decl(generatedContextualTyping.ts, 26, 54)) ->member : Symbol(member, Decl(generatedContextualTyping.ts, 27, 11)) ->s : Symbol(s, Decl(generatedContextualTyping.ts, 27, 21)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 27, 40), Decl(generatedContextualTyping.ts, 27, 51)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 27, 40), Decl(generatedContextualTyping.ts, 27, 51)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) - -class x24 { member: Genric = { func: n => { return [d1, d2]; } } } ->x24 : Symbol(x24, Decl(generatedContextualTyping.ts, 27, 79)) ->member : Symbol(member, Decl(generatedContextualTyping.ts, 28, 11)) ->Genric : Symbol(Genric, Decl(generatedContextualTyping.ts, 2, 42)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->func : Symbol(func, Decl(generatedContextualTyping.ts, 28, 36)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 28, 42)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -class x25 { private member: () => Base[] = () => [d1, d2] } ->x25 : Symbol(x25, Decl(generatedContextualTyping.ts, 28, 72)) ->member : Symbol(member, Decl(generatedContextualTyping.ts, 29, 11)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -class x26 { private member: () => Base[] = function() { return [d1, d2] } } ->x26 : Symbol(x26, Decl(generatedContextualTyping.ts, 29, 59)) ->member : Symbol(member, Decl(generatedContextualTyping.ts, 30, 11)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -class x27 { private member: () => Base[] = function named() { return [d1, d2] } } ->x27 : Symbol(x27, Decl(generatedContextualTyping.ts, 30, 75)) ->member : Symbol(member, Decl(generatedContextualTyping.ts, 31, 11)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->named : Symbol(named, Decl(generatedContextualTyping.ts, 31, 42)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -class x28 { private member: { (): Base[]; } = () => [d1, d2] } ->x28 : Symbol(x28, Decl(generatedContextualTyping.ts, 31, 81)) ->member : Symbol(member, Decl(generatedContextualTyping.ts, 32, 11)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -class x29 { private member: { (): Base[]; } = function() { return [d1, d2] } } ->x29 : Symbol(x29, Decl(generatedContextualTyping.ts, 32, 62)) ->member : Symbol(member, Decl(generatedContextualTyping.ts, 33, 11)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -class x30 { private member: { (): Base[]; } = function named() { return [d1, d2] } } ->x30 : Symbol(x30, Decl(generatedContextualTyping.ts, 33, 78)) ->member : Symbol(member, Decl(generatedContextualTyping.ts, 34, 11)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->named : Symbol(named, Decl(generatedContextualTyping.ts, 34, 45)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -class x31 { private member: Base[] = [d1, d2] } ->x31 : Symbol(x31, Decl(generatedContextualTyping.ts, 34, 84)) ->member : Symbol(member, Decl(generatedContextualTyping.ts, 35, 11)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -class x32 { private member: Array = [d1, d2] } ->x32 : Symbol(x32, Decl(generatedContextualTyping.ts, 35, 47)) ->member : Symbol(member, Decl(generatedContextualTyping.ts, 36, 11)) ->Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -class x33 { private member: { [n: number]: Base; } = [d1, d2] } ->x33 : Symbol(x33, Decl(generatedContextualTyping.ts, 36, 52)) ->member : Symbol(member, Decl(generatedContextualTyping.ts, 37, 11)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 37, 31)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -class x34 { private member: {n: Base[]; } = { n: [d1, d2] } } ->x34 : Symbol(x34, Decl(generatedContextualTyping.ts, 37, 63)) ->member : Symbol(member, Decl(generatedContextualTyping.ts, 38, 11)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 38, 29)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 38, 46)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -class x35 { private member: (s: Base[]) => any = n => { var n: Base[]; return null; } } ->x35 : Symbol(x35, Decl(generatedContextualTyping.ts, 38, 62)) ->member : Symbol(member, Decl(generatedContextualTyping.ts, 39, 11)) ->s : Symbol(s, Decl(generatedContextualTyping.ts, 39, 29)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 39, 48), Decl(generatedContextualTyping.ts, 39, 59)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 39, 48), Decl(generatedContextualTyping.ts, 39, 59)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) - -class x36 { private member: Genric = { func: n => { return [d1, d2]; } } } ->x36 : Symbol(x36, Decl(generatedContextualTyping.ts, 39, 87)) ->member : Symbol(member, Decl(generatedContextualTyping.ts, 40, 11)) ->Genric : Symbol(Genric, Decl(generatedContextualTyping.ts, 2, 42)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->func : Symbol(func, Decl(generatedContextualTyping.ts, 40, 44)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 40, 50)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -class x37 { public member: () => Base[] = () => [d1, d2] } ->x37 : Symbol(x37, Decl(generatedContextualTyping.ts, 40, 80)) ->member : Symbol(member, Decl(generatedContextualTyping.ts, 41, 11)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -class x38 { public member: () => Base[] = function() { return [d1, d2] } } ->x38 : Symbol(x38, Decl(generatedContextualTyping.ts, 41, 58)) ->member : Symbol(member, Decl(generatedContextualTyping.ts, 42, 11)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -class x39 { public member: () => Base[] = function named() { return [d1, d2] } } ->x39 : Symbol(x39, Decl(generatedContextualTyping.ts, 42, 74)) ->member : Symbol(member, Decl(generatedContextualTyping.ts, 43, 11)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->named : Symbol(named, Decl(generatedContextualTyping.ts, 43, 41)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -class x40 { public member: { (): Base[]; } = () => [d1, d2] } ->x40 : Symbol(x40, Decl(generatedContextualTyping.ts, 43, 80)) ->member : Symbol(member, Decl(generatedContextualTyping.ts, 44, 11)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -class x41 { public member: { (): Base[]; } = function() { return [d1, d2] } } ->x41 : Symbol(x41, Decl(generatedContextualTyping.ts, 44, 61)) ->member : Symbol(member, Decl(generatedContextualTyping.ts, 45, 11)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -class x42 { public member: { (): Base[]; } = function named() { return [d1, d2] } } ->x42 : Symbol(x42, Decl(generatedContextualTyping.ts, 45, 77)) ->member : Symbol(member, Decl(generatedContextualTyping.ts, 46, 11)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->named : Symbol(named, Decl(generatedContextualTyping.ts, 46, 44)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -class x43 { public member: Base[] = [d1, d2] } ->x43 : Symbol(x43, Decl(generatedContextualTyping.ts, 46, 83)) ->member : Symbol(member, Decl(generatedContextualTyping.ts, 47, 11)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -class x44 { public member: Array = [d1, d2] } ->x44 : Symbol(x44, Decl(generatedContextualTyping.ts, 47, 46)) ->member : Symbol(member, Decl(generatedContextualTyping.ts, 48, 11)) ->Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -class x45 { public member: { [n: number]: Base; } = [d1, d2] } ->x45 : Symbol(x45, Decl(generatedContextualTyping.ts, 48, 51)) ->member : Symbol(member, Decl(generatedContextualTyping.ts, 49, 11)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 49, 30)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -class x46 { public member: {n: Base[]; } = { n: [d1, d2] } } ->x46 : Symbol(x46, Decl(generatedContextualTyping.ts, 49, 62)) ->member : Symbol(member, Decl(generatedContextualTyping.ts, 50, 11)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 50, 28)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 50, 45)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -class x47 { public member: (s: Base[]) => any = n => { var n: Base[]; return null; } } ->x47 : Symbol(x47, Decl(generatedContextualTyping.ts, 50, 61)) ->member : Symbol(member, Decl(generatedContextualTyping.ts, 51, 11)) ->s : Symbol(s, Decl(generatedContextualTyping.ts, 51, 28)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 51, 47), Decl(generatedContextualTyping.ts, 51, 58)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 51, 47), Decl(generatedContextualTyping.ts, 51, 58)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) - -class x48 { public member: Genric = { func: n => { return [d1, d2]; } } } ->x48 : Symbol(x48, Decl(generatedContextualTyping.ts, 51, 86)) ->member : Symbol(member, Decl(generatedContextualTyping.ts, 52, 11)) ->Genric : Symbol(Genric, Decl(generatedContextualTyping.ts, 2, 42)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->func : Symbol(func, Decl(generatedContextualTyping.ts, 52, 43)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 52, 49)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -class x49 { static member: () => Base[] = () => [d1, d2] } ->x49 : Symbol(x49, Decl(generatedContextualTyping.ts, 52, 79)) ->member : Symbol(x49.member, Decl(generatedContextualTyping.ts, 53, 11)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -class x50 { static member: () => Base[] = function() { return [d1, d2] } } ->x50 : Symbol(x50, Decl(generatedContextualTyping.ts, 53, 58)) ->member : Symbol(x50.member, Decl(generatedContextualTyping.ts, 54, 11)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -class x51 { static member: () => Base[] = function named() { return [d1, d2] } } ->x51 : Symbol(x51, Decl(generatedContextualTyping.ts, 54, 74)) ->member : Symbol(x51.member, Decl(generatedContextualTyping.ts, 55, 11)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->named : Symbol(named, Decl(generatedContextualTyping.ts, 55, 41)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -class x52 { static member: { (): Base[]; } = () => [d1, d2] } ->x52 : Symbol(x52, Decl(generatedContextualTyping.ts, 55, 80)) ->member : Symbol(x52.member, Decl(generatedContextualTyping.ts, 56, 11)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -class x53 { static member: { (): Base[]; } = function() { return [d1, d2] } } ->x53 : Symbol(x53, Decl(generatedContextualTyping.ts, 56, 61)) ->member : Symbol(x53.member, Decl(generatedContextualTyping.ts, 57, 11)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -class x54 { static member: { (): Base[]; } = function named() { return [d1, d2] } } ->x54 : Symbol(x54, Decl(generatedContextualTyping.ts, 57, 77)) ->member : Symbol(x54.member, Decl(generatedContextualTyping.ts, 58, 11)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->named : Symbol(named, Decl(generatedContextualTyping.ts, 58, 44)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -class x55 { static member: Base[] = [d1, d2] } ->x55 : Symbol(x55, Decl(generatedContextualTyping.ts, 58, 83)) ->member : Symbol(x55.member, Decl(generatedContextualTyping.ts, 59, 11)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -class x56 { static member: Array = [d1, d2] } ->x56 : Symbol(x56, Decl(generatedContextualTyping.ts, 59, 46)) ->member : Symbol(x56.member, Decl(generatedContextualTyping.ts, 60, 11)) ->Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -class x57 { static member: { [n: number]: Base; } = [d1, d2] } ->x57 : Symbol(x57, Decl(generatedContextualTyping.ts, 60, 51)) ->member : Symbol(x57.member, Decl(generatedContextualTyping.ts, 61, 11)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 61, 30)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -class x58 { static member: {n: Base[]; } = { n: [d1, d2] } } ->x58 : Symbol(x58, Decl(generatedContextualTyping.ts, 61, 62)) ->member : Symbol(x58.member, Decl(generatedContextualTyping.ts, 62, 11)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 62, 28)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 62, 45)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -class x59 { static member: (s: Base[]) => any = n => { var n: Base[]; return null; } } ->x59 : Symbol(x59, Decl(generatedContextualTyping.ts, 62, 61)) ->member : Symbol(x59.member, Decl(generatedContextualTyping.ts, 63, 11)) ->s : Symbol(s, Decl(generatedContextualTyping.ts, 63, 28)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 63, 47), Decl(generatedContextualTyping.ts, 63, 58)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 63, 47), Decl(generatedContextualTyping.ts, 63, 58)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) - -class x60 { static member: Genric = { func: n => { return [d1, d2]; } } } ->x60 : Symbol(x60, Decl(generatedContextualTyping.ts, 63, 86)) ->member : Symbol(x60.member, Decl(generatedContextualTyping.ts, 64, 11)) ->Genric : Symbol(Genric, Decl(generatedContextualTyping.ts, 2, 42)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->func : Symbol(func, Decl(generatedContextualTyping.ts, 64, 43)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 64, 49)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -class x61 { private static member: () => Base[] = () => [d1, d2] } ->x61 : Symbol(x61, Decl(generatedContextualTyping.ts, 64, 79)) ->member : Symbol(x61.member, Decl(generatedContextualTyping.ts, 65, 11)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -class x62 { private static member: () => Base[] = function() { return [d1, d2] } } ->x62 : Symbol(x62, Decl(generatedContextualTyping.ts, 65, 66)) ->member : Symbol(x62.member, Decl(generatedContextualTyping.ts, 66, 11)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -class x63 { private static member: () => Base[] = function named() { return [d1, d2] } } ->x63 : Symbol(x63, Decl(generatedContextualTyping.ts, 66, 82)) ->member : Symbol(x63.member, Decl(generatedContextualTyping.ts, 67, 11)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->named : Symbol(named, Decl(generatedContextualTyping.ts, 67, 49)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -class x64 { private static member: { (): Base[]; } = () => [d1, d2] } ->x64 : Symbol(x64, Decl(generatedContextualTyping.ts, 67, 88)) ->member : Symbol(x64.member, Decl(generatedContextualTyping.ts, 68, 11)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -class x65 { private static member: { (): Base[]; } = function() { return [d1, d2] } } ->x65 : Symbol(x65, Decl(generatedContextualTyping.ts, 68, 69)) ->member : Symbol(x65.member, Decl(generatedContextualTyping.ts, 69, 11)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -class x66 { private static member: { (): Base[]; } = function named() { return [d1, d2] } } ->x66 : Symbol(x66, Decl(generatedContextualTyping.ts, 69, 85)) ->member : Symbol(x66.member, Decl(generatedContextualTyping.ts, 70, 11)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->named : Symbol(named, Decl(generatedContextualTyping.ts, 70, 52)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -class x67 { private static member: Base[] = [d1, d2] } ->x67 : Symbol(x67, Decl(generatedContextualTyping.ts, 70, 91)) ->member : Symbol(x67.member, Decl(generatedContextualTyping.ts, 71, 11)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -class x68 { private static member: Array = [d1, d2] } ->x68 : Symbol(x68, Decl(generatedContextualTyping.ts, 71, 54)) ->member : Symbol(x68.member, Decl(generatedContextualTyping.ts, 72, 11)) ->Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -class x69 { private static member: { [n: number]: Base; } = [d1, d2] } ->x69 : Symbol(x69, Decl(generatedContextualTyping.ts, 72, 59)) ->member : Symbol(x69.member, Decl(generatedContextualTyping.ts, 73, 11)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 73, 38)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -class x70 { private static member: {n: Base[]; } = { n: [d1, d2] } } ->x70 : Symbol(x70, Decl(generatedContextualTyping.ts, 73, 70)) ->member : Symbol(x70.member, Decl(generatedContextualTyping.ts, 74, 11)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 74, 36)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 74, 53)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -class x71 { private static member: (s: Base[]) => any = n => { var n: Base[]; return null; } } ->x71 : Symbol(x71, Decl(generatedContextualTyping.ts, 74, 69)) ->member : Symbol(x71.member, Decl(generatedContextualTyping.ts, 75, 11)) ->s : Symbol(s, Decl(generatedContextualTyping.ts, 75, 36)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 75, 55), Decl(generatedContextualTyping.ts, 75, 66)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 75, 55), Decl(generatedContextualTyping.ts, 75, 66)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) - -class x72 { private static member: Genric = { func: n => { return [d1, d2]; } } } ->x72 : Symbol(x72, Decl(generatedContextualTyping.ts, 75, 94)) ->member : Symbol(x72.member, Decl(generatedContextualTyping.ts, 76, 11)) ->Genric : Symbol(Genric, Decl(generatedContextualTyping.ts, 2, 42)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->func : Symbol(func, Decl(generatedContextualTyping.ts, 76, 51)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 76, 57)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -class x73 { public static member: () => Base[] = () => [d1, d2] } ->x73 : Symbol(x73, Decl(generatedContextualTyping.ts, 76, 87)) ->member : Symbol(x73.member, Decl(generatedContextualTyping.ts, 77, 11)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -class x74 { public static member: () => Base[] = function() { return [d1, d2] } } ->x74 : Symbol(x74, Decl(generatedContextualTyping.ts, 77, 65)) ->member : Symbol(x74.member, Decl(generatedContextualTyping.ts, 78, 11)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -class x75 { public static member: () => Base[] = function named() { return [d1, d2] } } ->x75 : Symbol(x75, Decl(generatedContextualTyping.ts, 78, 81)) ->member : Symbol(x75.member, Decl(generatedContextualTyping.ts, 79, 11)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->named : Symbol(named, Decl(generatedContextualTyping.ts, 79, 48)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -class x76 { public static member: { (): Base[]; } = () => [d1, d2] } ->x76 : Symbol(x76, Decl(generatedContextualTyping.ts, 79, 87)) ->member : Symbol(x76.member, Decl(generatedContextualTyping.ts, 80, 11)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -class x77 { public static member: { (): Base[]; } = function() { return [d1, d2] } } ->x77 : Symbol(x77, Decl(generatedContextualTyping.ts, 80, 68)) ->member : Symbol(x77.member, Decl(generatedContextualTyping.ts, 81, 11)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -class x78 { public static member: { (): Base[]; } = function named() { return [d1, d2] } } ->x78 : Symbol(x78, Decl(generatedContextualTyping.ts, 81, 84)) ->member : Symbol(x78.member, Decl(generatedContextualTyping.ts, 82, 11)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->named : Symbol(named, Decl(generatedContextualTyping.ts, 82, 51)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -class x79 { public static member: Base[] = [d1, d2] } ->x79 : Symbol(x79, Decl(generatedContextualTyping.ts, 82, 90)) ->member : Symbol(x79.member, Decl(generatedContextualTyping.ts, 83, 11)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -class x80 { public static member: Array = [d1, d2] } ->x80 : Symbol(x80, Decl(generatedContextualTyping.ts, 83, 53)) ->member : Symbol(x80.member, Decl(generatedContextualTyping.ts, 84, 11)) ->Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -class x81 { public static member: { [n: number]: Base; } = [d1, d2] } ->x81 : Symbol(x81, Decl(generatedContextualTyping.ts, 84, 58)) ->member : Symbol(x81.member, Decl(generatedContextualTyping.ts, 85, 11)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 85, 37)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -class x82 { public static member: {n: Base[]; } = { n: [d1, d2] } } ->x82 : Symbol(x82, Decl(generatedContextualTyping.ts, 85, 69)) ->member : Symbol(x82.member, Decl(generatedContextualTyping.ts, 86, 11)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 86, 35)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 86, 52)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -class x83 { public static member: (s: Base[]) => any = n => { var n: Base[]; return null; } } ->x83 : Symbol(x83, Decl(generatedContextualTyping.ts, 86, 68)) ->member : Symbol(x83.member, Decl(generatedContextualTyping.ts, 87, 11)) ->s : Symbol(s, Decl(generatedContextualTyping.ts, 87, 35)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 87, 54), Decl(generatedContextualTyping.ts, 87, 65)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 87, 54), Decl(generatedContextualTyping.ts, 87, 65)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) - -class x84 { public static member: Genric = { func: n => { return [d1, d2]; } } } ->x84 : Symbol(x84, Decl(generatedContextualTyping.ts, 87, 93)) ->member : Symbol(x84.member, Decl(generatedContextualTyping.ts, 88, 11)) ->Genric : Symbol(Genric, Decl(generatedContextualTyping.ts, 2, 42)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->func : Symbol(func, Decl(generatedContextualTyping.ts, 88, 50)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 88, 56)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -class x85 { constructor(parm: () => Base[] = () => [d1, d2]) { } } ->x85 : Symbol(x85, Decl(generatedContextualTyping.ts, 88, 86)) ->parm : Symbol(parm, Decl(generatedContextualTyping.ts, 89, 24)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -class x86 { constructor(parm: () => Base[] = function() { return [d1, d2] }) { } } ->x86 : Symbol(x86, Decl(generatedContextualTyping.ts, 89, 66)) ->parm : Symbol(parm, Decl(generatedContextualTyping.ts, 90, 24)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -class x87 { constructor(parm: () => Base[] = function named() { return [d1, d2] }) { } } ->x87 : Symbol(x87, Decl(generatedContextualTyping.ts, 90, 82)) ->parm : Symbol(parm, Decl(generatedContextualTyping.ts, 91, 24)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->named : Symbol(named, Decl(generatedContextualTyping.ts, 91, 44)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -class x88 { constructor(parm: { (): Base[]; } = () => [d1, d2]) { } } ->x88 : Symbol(x88, Decl(generatedContextualTyping.ts, 91, 88)) ->parm : Symbol(parm, Decl(generatedContextualTyping.ts, 92, 24)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -class x89 { constructor(parm: { (): Base[]; } = function() { return [d1, d2] }) { } } ->x89 : Symbol(x89, Decl(generatedContextualTyping.ts, 92, 69)) ->parm : Symbol(parm, Decl(generatedContextualTyping.ts, 93, 24)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -class x90 { constructor(parm: { (): Base[]; } = function named() { return [d1, d2] }) { } } ->x90 : Symbol(x90, Decl(generatedContextualTyping.ts, 93, 85)) ->parm : Symbol(parm, Decl(generatedContextualTyping.ts, 94, 24)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->named : Symbol(named, Decl(generatedContextualTyping.ts, 94, 47)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -class x91 { constructor(parm: Base[] = [d1, d2]) { } } ->x91 : Symbol(x91, Decl(generatedContextualTyping.ts, 94, 91)) ->parm : Symbol(parm, Decl(generatedContextualTyping.ts, 95, 24)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -class x92 { constructor(parm: Array = [d1, d2]) { } } ->x92 : Symbol(x92, Decl(generatedContextualTyping.ts, 95, 54)) ->parm : Symbol(parm, Decl(generatedContextualTyping.ts, 96, 24)) ->Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -class x93 { constructor(parm: { [n: number]: Base; } = [d1, d2]) { } } ->x93 : Symbol(x93, Decl(generatedContextualTyping.ts, 96, 59)) ->parm : Symbol(parm, Decl(generatedContextualTyping.ts, 97, 24)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 97, 33)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -class x94 { constructor(parm: {n: Base[]; } = { n: [d1, d2] }) { } } ->x94 : Symbol(x94, Decl(generatedContextualTyping.ts, 97, 70)) ->parm : Symbol(parm, Decl(generatedContextualTyping.ts, 98, 24)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 98, 31)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 98, 48)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -class x95 { constructor(parm: (s: Base[]) => any = n => { var n: Base[]; return null; }) { } } ->x95 : Symbol(x95, Decl(generatedContextualTyping.ts, 98, 69)) ->parm : Symbol(parm, Decl(generatedContextualTyping.ts, 99, 24)) ->s : Symbol(s, Decl(generatedContextualTyping.ts, 99, 31)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 99, 50), Decl(generatedContextualTyping.ts, 99, 61)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 99, 50), Decl(generatedContextualTyping.ts, 99, 61)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) - -class x96 { constructor(parm: Genric = { func: n => { return [d1, d2]; } }) { } } ->x96 : Symbol(x96, Decl(generatedContextualTyping.ts, 99, 94)) ->parm : Symbol(parm, Decl(generatedContextualTyping.ts, 100, 24)) ->Genric : Symbol(Genric, Decl(generatedContextualTyping.ts, 2, 42)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->func : Symbol(func, Decl(generatedContextualTyping.ts, 100, 46)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 100, 52)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -class x97 { constructor(public parm: () => Base[] = () => [d1, d2]) { } } ->x97 : Symbol(x97, Decl(generatedContextualTyping.ts, 100, 87)) ->parm : Symbol(parm, Decl(generatedContextualTyping.ts, 101, 24)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -class x98 { constructor(public parm: () => Base[] = function() { return [d1, d2] }) { } } ->x98 : Symbol(x98, Decl(generatedContextualTyping.ts, 101, 73)) ->parm : Symbol(parm, Decl(generatedContextualTyping.ts, 102, 24)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -class x99 { constructor(public parm: () => Base[] = function named() { return [d1, d2] }) { } } ->x99 : Symbol(x99, Decl(generatedContextualTyping.ts, 102, 89)) ->parm : Symbol(parm, Decl(generatedContextualTyping.ts, 103, 24)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->named : Symbol(named, Decl(generatedContextualTyping.ts, 103, 51)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -class x100 { constructor(public parm: { (): Base[]; } = () => [d1, d2]) { } } ->x100 : Symbol(x100, Decl(generatedContextualTyping.ts, 103, 95)) ->parm : Symbol(parm, Decl(generatedContextualTyping.ts, 104, 25)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -class x101 { constructor(public parm: { (): Base[]; } = function() { return [d1, d2] }) { } } ->x101 : Symbol(x101, Decl(generatedContextualTyping.ts, 104, 77)) ->parm : Symbol(parm, Decl(generatedContextualTyping.ts, 105, 25)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -class x102 { constructor(public parm: { (): Base[]; } = function named() { return [d1, d2] }) { } } ->x102 : Symbol(x102, Decl(generatedContextualTyping.ts, 105, 93)) ->parm : Symbol(parm, Decl(generatedContextualTyping.ts, 106, 25)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->named : Symbol(named, Decl(generatedContextualTyping.ts, 106, 55)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -class x103 { constructor(public parm: Base[] = [d1, d2]) { } } ->x103 : Symbol(x103, Decl(generatedContextualTyping.ts, 106, 99)) ->parm : Symbol(parm, Decl(generatedContextualTyping.ts, 107, 25)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -class x104 { constructor(public parm: Array = [d1, d2]) { } } ->x104 : Symbol(x104, Decl(generatedContextualTyping.ts, 107, 62)) ->parm : Symbol(parm, Decl(generatedContextualTyping.ts, 108, 25)) ->Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -class x105 { constructor(public parm: { [n: number]: Base; } = [d1, d2]) { } } ->x105 : Symbol(x105, Decl(generatedContextualTyping.ts, 108, 67)) ->parm : Symbol(parm, Decl(generatedContextualTyping.ts, 109, 25)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 109, 41)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -class x106 { constructor(public parm: {n: Base[]; } = { n: [d1, d2] }) { } } ->x106 : Symbol(x106, Decl(generatedContextualTyping.ts, 109, 78)) ->parm : Symbol(parm, Decl(generatedContextualTyping.ts, 110, 25)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 110, 39)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 110, 56)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -class x107 { constructor(public parm: (s: Base[]) => any = n => { var n: Base[]; return null; }) { } } ->x107 : Symbol(x107, Decl(generatedContextualTyping.ts, 110, 77)) ->parm : Symbol(parm, Decl(generatedContextualTyping.ts, 111, 25)) ->s : Symbol(s, Decl(generatedContextualTyping.ts, 111, 39)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 111, 58), Decl(generatedContextualTyping.ts, 111, 69)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 111, 58), Decl(generatedContextualTyping.ts, 111, 69)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) - -class x108 { constructor(public parm: Genric = { func: n => { return [d1, d2]; } }) { } } ->x108 : Symbol(x108, Decl(generatedContextualTyping.ts, 111, 102)) ->parm : Symbol(parm, Decl(generatedContextualTyping.ts, 112, 25)) ->Genric : Symbol(Genric, Decl(generatedContextualTyping.ts, 2, 42)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->func : Symbol(func, Decl(generatedContextualTyping.ts, 112, 54)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 112, 60)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -class x109 { constructor(private parm: () => Base[] = () => [d1, d2]) { } } ->x109 : Symbol(x109, Decl(generatedContextualTyping.ts, 112, 95)) ->parm : Symbol(parm, Decl(generatedContextualTyping.ts, 113, 25)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -class x110 { constructor(private parm: () => Base[] = function() { return [d1, d2] }) { } } ->x110 : Symbol(x110, Decl(generatedContextualTyping.ts, 113, 75)) ->parm : Symbol(parm, Decl(generatedContextualTyping.ts, 114, 25)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -class x111 { constructor(private parm: () => Base[] = function named() { return [d1, d2] }) { } } ->x111 : Symbol(x111, Decl(generatedContextualTyping.ts, 114, 91)) ->parm : Symbol(parm, Decl(generatedContextualTyping.ts, 115, 25)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->named : Symbol(named, Decl(generatedContextualTyping.ts, 115, 53)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -class x112 { constructor(private parm: { (): Base[]; } = () => [d1, d2]) { } } ->x112 : Symbol(x112, Decl(generatedContextualTyping.ts, 115, 97)) ->parm : Symbol(parm, Decl(generatedContextualTyping.ts, 116, 25)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -class x113 { constructor(private parm: { (): Base[]; } = function() { return [d1, d2] }) { } } ->x113 : Symbol(x113, Decl(generatedContextualTyping.ts, 116, 78)) ->parm : Symbol(parm, Decl(generatedContextualTyping.ts, 117, 25)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -class x114 { constructor(private parm: { (): Base[]; } = function named() { return [d1, d2] }) { } } ->x114 : Symbol(x114, Decl(generatedContextualTyping.ts, 117, 94)) ->parm : Symbol(parm, Decl(generatedContextualTyping.ts, 118, 25)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->named : Symbol(named, Decl(generatedContextualTyping.ts, 118, 56)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -class x115 { constructor(private parm: Base[] = [d1, d2]) { } } ->x115 : Symbol(x115, Decl(generatedContextualTyping.ts, 118, 100)) ->parm : Symbol(parm, Decl(generatedContextualTyping.ts, 119, 25)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -class x116 { constructor(private parm: Array = [d1, d2]) { } } ->x116 : Symbol(x116, Decl(generatedContextualTyping.ts, 119, 63)) ->parm : Symbol(parm, Decl(generatedContextualTyping.ts, 120, 25)) ->Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -class x117 { constructor(private parm: { [n: number]: Base; } = [d1, d2]) { } } ->x117 : Symbol(x117, Decl(generatedContextualTyping.ts, 120, 68)) ->parm : Symbol(parm, Decl(generatedContextualTyping.ts, 121, 25)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 121, 42)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -class x118 { constructor(private parm: {n: Base[]; } = { n: [d1, d2] }) { } } ->x118 : Symbol(x118, Decl(generatedContextualTyping.ts, 121, 79)) ->parm : Symbol(parm, Decl(generatedContextualTyping.ts, 122, 25)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 122, 40)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 122, 57)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -class x119 { constructor(private parm: (s: Base[]) => any = n => { var n: Base[]; return null; }) { } } ->x119 : Symbol(x119, Decl(generatedContextualTyping.ts, 122, 78)) ->parm : Symbol(parm, Decl(generatedContextualTyping.ts, 123, 25)) ->s : Symbol(s, Decl(generatedContextualTyping.ts, 123, 40)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 123, 59), Decl(generatedContextualTyping.ts, 123, 70)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 123, 59), Decl(generatedContextualTyping.ts, 123, 70)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) - -class x120 { constructor(private parm: Genric = { func: n => { return [d1, d2]; } }) { } } ->x120 : Symbol(x120, Decl(generatedContextualTyping.ts, 123, 103)) ->parm : Symbol(parm, Decl(generatedContextualTyping.ts, 124, 25)) ->Genric : Symbol(Genric, Decl(generatedContextualTyping.ts, 2, 42)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->func : Symbol(func, Decl(generatedContextualTyping.ts, 124, 55)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 124, 61)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -function x121(parm: () => Base[] = () => [d1, d2]) { } ->x121 : Symbol(x121, Decl(generatedContextualTyping.ts, 124, 96)) ->parm : Symbol(parm, Decl(generatedContextualTyping.ts, 125, 14)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -function x122(parm: () => Base[] = function() { return [d1, d2] }) { } ->x122 : Symbol(x122, Decl(generatedContextualTyping.ts, 125, 54)) ->parm : Symbol(parm, Decl(generatedContextualTyping.ts, 126, 14)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -function x123(parm: () => Base[] = function named() { return [d1, d2] }) { } ->x123 : Symbol(x123, Decl(generatedContextualTyping.ts, 126, 70)) ->parm : Symbol(parm, Decl(generatedContextualTyping.ts, 127, 14)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->named : Symbol(named, Decl(generatedContextualTyping.ts, 127, 34)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -function x124(parm: { (): Base[]; } = () => [d1, d2]) { } ->x124 : Symbol(x124, Decl(generatedContextualTyping.ts, 127, 76)) ->parm : Symbol(parm, Decl(generatedContextualTyping.ts, 128, 14)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -function x125(parm: { (): Base[]; } = function() { return [d1, d2] }) { } ->x125 : Symbol(x125, Decl(generatedContextualTyping.ts, 128, 57)) ->parm : Symbol(parm, Decl(generatedContextualTyping.ts, 129, 14)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -function x126(parm: { (): Base[]; } = function named() { return [d1, d2] }) { } ->x126 : Symbol(x126, Decl(generatedContextualTyping.ts, 129, 73)) ->parm : Symbol(parm, Decl(generatedContextualTyping.ts, 130, 14)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->named : Symbol(named, Decl(generatedContextualTyping.ts, 130, 37)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -function x127(parm: Base[] = [d1, d2]) { } ->x127 : Symbol(x127, Decl(generatedContextualTyping.ts, 130, 79)) ->parm : Symbol(parm, Decl(generatedContextualTyping.ts, 131, 14)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -function x128(parm: Array = [d1, d2]) { } ->x128 : Symbol(x128, Decl(generatedContextualTyping.ts, 131, 42)) ->parm : Symbol(parm, Decl(generatedContextualTyping.ts, 132, 14)) ->Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -function x129(parm: { [n: number]: Base; } = [d1, d2]) { } ->x129 : Symbol(x129, Decl(generatedContextualTyping.ts, 132, 47)) ->parm : Symbol(parm, Decl(generatedContextualTyping.ts, 133, 14)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 133, 23)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -function x130(parm: {n: Base[]; } = { n: [d1, d2] }) { } ->x130 : Symbol(x130, Decl(generatedContextualTyping.ts, 133, 58)) ->parm : Symbol(parm, Decl(generatedContextualTyping.ts, 134, 14)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 134, 21)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 134, 38)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -function x131(parm: (s: Base[]) => any = n => { var n: Base[]; return null; }) { } ->x131 : Symbol(x131, Decl(generatedContextualTyping.ts, 134, 57)) ->parm : Symbol(parm, Decl(generatedContextualTyping.ts, 135, 14)) ->s : Symbol(s, Decl(generatedContextualTyping.ts, 135, 21)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 135, 40), Decl(generatedContextualTyping.ts, 135, 51)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 135, 40), Decl(generatedContextualTyping.ts, 135, 51)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) - -function x132(parm: Genric = { func: n => { return [d1, d2]; } }) { } ->x132 : Symbol(x132, Decl(generatedContextualTyping.ts, 135, 82)) ->parm : Symbol(parm, Decl(generatedContextualTyping.ts, 136, 14)) ->Genric : Symbol(Genric, Decl(generatedContextualTyping.ts, 2, 42)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->func : Symbol(func, Decl(generatedContextualTyping.ts, 136, 36)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 136, 42)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -function x133(): () => Base[] { return () => [d1, d2]; } ->x133 : Symbol(x133, Decl(generatedContextualTyping.ts, 136, 75)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -function x134(): () => Base[] { return function() { return [d1, d2] }; } ->x134 : Symbol(x134, Decl(generatedContextualTyping.ts, 137, 56)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -function x135(): () => Base[] { return function named() { return [d1, d2] }; } ->x135 : Symbol(x135, Decl(generatedContextualTyping.ts, 138, 72)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->named : Symbol(named, Decl(generatedContextualTyping.ts, 139, 38)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -function x136(): { (): Base[]; } { return () => [d1, d2]; } ->x136 : Symbol(x136, Decl(generatedContextualTyping.ts, 139, 78)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -function x137(): { (): Base[]; } { return function() { return [d1, d2] }; } ->x137 : Symbol(x137, Decl(generatedContextualTyping.ts, 140, 59)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -function x138(): { (): Base[]; } { return function named() { return [d1, d2] }; } ->x138 : Symbol(x138, Decl(generatedContextualTyping.ts, 141, 75)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->named : Symbol(named, Decl(generatedContextualTyping.ts, 142, 41)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -function x139(): Base[] { return [d1, d2]; } ->x139 : Symbol(x139, Decl(generatedContextualTyping.ts, 142, 81)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -function x140(): Array { return [d1, d2]; } ->x140 : Symbol(x140, Decl(generatedContextualTyping.ts, 143, 44)) ->Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -function x141(): { [n: number]: Base; } { return [d1, d2]; } ->x141 : Symbol(x141, Decl(generatedContextualTyping.ts, 144, 49)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 145, 20)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -function x142(): {n: Base[]; } { return { n: [d1, d2] }; } ->x142 : Symbol(x142, Decl(generatedContextualTyping.ts, 145, 60)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 146, 18)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 146, 42)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -function x143(): (s: Base[]) => any { return n => { var n: Base[]; return null; }; } ->x143 : Symbol(x143, Decl(generatedContextualTyping.ts, 146, 59)) ->s : Symbol(s, Decl(generatedContextualTyping.ts, 147, 18)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 147, 44), Decl(generatedContextualTyping.ts, 147, 55)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 147, 44), Decl(generatedContextualTyping.ts, 147, 55)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) - -function x144(): Genric { return { func: n => { return [d1, d2]; } }; } ->x144 : Symbol(x144, Decl(generatedContextualTyping.ts, 147, 84)) ->Genric : Symbol(Genric, Decl(generatedContextualTyping.ts, 2, 42)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->func : Symbol(func, Decl(generatedContextualTyping.ts, 148, 40)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 148, 46)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -function x145(): () => Base[] { return () => [d1, d2]; return () => [d1, d2]; } ->x145 : Symbol(x145, Decl(generatedContextualTyping.ts, 148, 77)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -function x146(): () => Base[] { return function() { return [d1, d2] }; return function() { return [d1, d2] }; } ->x146 : Symbol(x146, Decl(generatedContextualTyping.ts, 149, 79)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -function x147(): () => Base[] { return function named() { return [d1, d2] }; return function named() { return [d1, d2] }; } ->x147 : Symbol(x147, Decl(generatedContextualTyping.ts, 150, 111)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->named : Symbol(named, Decl(generatedContextualTyping.ts, 151, 38)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) ->named : Symbol(named, Decl(generatedContextualTyping.ts, 151, 83)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -function x148(): { (): Base[]; } { return () => [d1, d2]; return () => [d1, d2]; } ->x148 : Symbol(x148, Decl(generatedContextualTyping.ts, 151, 123)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -function x149(): { (): Base[]; } { return function() { return [d1, d2] }; return function() { return [d1, d2] }; } ->x149 : Symbol(x149, Decl(generatedContextualTyping.ts, 152, 82)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -function x150(): { (): Base[]; } { return function named() { return [d1, d2] }; return function named() { return [d1, d2] }; } ->x150 : Symbol(x150, Decl(generatedContextualTyping.ts, 153, 114)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->named : Symbol(named, Decl(generatedContextualTyping.ts, 154, 41)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) ->named : Symbol(named, Decl(generatedContextualTyping.ts, 154, 86)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -function x151(): Base[] { return [d1, d2]; return [d1, d2]; } ->x151 : Symbol(x151, Decl(generatedContextualTyping.ts, 154, 126)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -function x152(): Array { return [d1, d2]; return [d1, d2]; } ->x152 : Symbol(x152, Decl(generatedContextualTyping.ts, 155, 61)) ->Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -function x153(): { [n: number]: Base; } { return [d1, d2]; return [d1, d2]; } ->x153 : Symbol(x153, Decl(generatedContextualTyping.ts, 156, 66)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 157, 20)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -function x154(): {n: Base[]; } { return { n: [d1, d2] }; return { n: [d1, d2] }; } ->x154 : Symbol(x154, Decl(generatedContextualTyping.ts, 157, 77)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 158, 18)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 158, 42)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 158, 66)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -function x155(): (s: Base[]) => any { return n => { var n: Base[]; return null; }; return n => { var n: Base[]; return null; }; } ->x155 : Symbol(x155, Decl(generatedContextualTyping.ts, 158, 83)) ->s : Symbol(s, Decl(generatedContextualTyping.ts, 159, 18)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 159, 44), Decl(generatedContextualTyping.ts, 159, 55)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 159, 44), Decl(generatedContextualTyping.ts, 159, 55)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 159, 89), Decl(generatedContextualTyping.ts, 159, 100)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 159, 89), Decl(generatedContextualTyping.ts, 159, 100)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) - -function x156(): Genric { return { func: n => { return [d1, d2]; } }; return { func: n => { return [d1, d2]; } }; } ->x156 : Symbol(x156, Decl(generatedContextualTyping.ts, 159, 129)) ->Genric : Symbol(Genric, Decl(generatedContextualTyping.ts, 2, 42)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->func : Symbol(func, Decl(generatedContextualTyping.ts, 160, 40)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 160, 46)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) ->func : Symbol(func, Decl(generatedContextualTyping.ts, 160, 84)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 160, 90)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -var x157: () => () => Base[] = () => { return () => [d1, d2]; }; ->x157 : Symbol(x157, Decl(generatedContextualTyping.ts, 161, 3)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -var x158: () => () => Base[] = () => { return function() { return [d1, d2] }; }; ->x158 : Symbol(x158, Decl(generatedContextualTyping.ts, 162, 3)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -var x159: () => () => Base[] = () => { return function named() { return [d1, d2] }; }; ->x159 : Symbol(x159, Decl(generatedContextualTyping.ts, 163, 3)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->named : Symbol(named, Decl(generatedContextualTyping.ts, 163, 45)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -var x160: () => { (): Base[]; } = () => { return () => [d1, d2]; }; ->x160 : Symbol(x160, Decl(generatedContextualTyping.ts, 164, 3)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -var x161: () => { (): Base[]; } = () => { return function() { return [d1, d2] }; }; ->x161 : Symbol(x161, Decl(generatedContextualTyping.ts, 165, 3)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -var x162: () => { (): Base[]; } = () => { return function named() { return [d1, d2] }; }; ->x162 : Symbol(x162, Decl(generatedContextualTyping.ts, 166, 3)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->named : Symbol(named, Decl(generatedContextualTyping.ts, 166, 48)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -var x163: () => Base[] = () => { return [d1, d2]; }; ->x163 : Symbol(x163, Decl(generatedContextualTyping.ts, 167, 3)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -var x164: () => Array = () => { return [d1, d2]; }; ->x164 : Symbol(x164, Decl(generatedContextualTyping.ts, 168, 3)) ->Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -var x165: () => { [n: number]: Base; } = () => { return [d1, d2]; }; ->x165 : Symbol(x165, Decl(generatedContextualTyping.ts, 169, 3)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 169, 19)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -var x166: () => {n: Base[]; } = () => { return { n: [d1, d2] }; }; ->x166 : Symbol(x166, Decl(generatedContextualTyping.ts, 170, 3)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 170, 17)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 170, 49)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -var x167: () => (s: Base[]) => any = () => { return n => { var n: Base[]; return null; }; }; ->x167 : Symbol(x167, Decl(generatedContextualTyping.ts, 171, 3)) ->s : Symbol(s, Decl(generatedContextualTyping.ts, 171, 17)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 171, 51), Decl(generatedContextualTyping.ts, 171, 62)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 171, 51), Decl(generatedContextualTyping.ts, 171, 62)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) - -var x168: () => Genric = () => { return { func: n => { return [d1, d2]; } }; }; ->x168 : Symbol(x168, Decl(generatedContextualTyping.ts, 172, 3)) ->Genric : Symbol(Genric, Decl(generatedContextualTyping.ts, 2, 42)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->func : Symbol(func, Decl(generatedContextualTyping.ts, 172, 47)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 172, 53)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -var x169: () => () => Base[] = function() { return () => [d1, d2]; }; ->x169 : Symbol(x169, Decl(generatedContextualTyping.ts, 173, 3)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -var x170: () => () => Base[] = function() { return function() { return [d1, d2] }; }; ->x170 : Symbol(x170, Decl(generatedContextualTyping.ts, 174, 3)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -var x171: () => () => Base[] = function() { return function named() { return [d1, d2] }; }; ->x171 : Symbol(x171, Decl(generatedContextualTyping.ts, 175, 3)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->named : Symbol(named, Decl(generatedContextualTyping.ts, 175, 50)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -var x172: () => { (): Base[]; } = function() { return () => [d1, d2]; }; ->x172 : Symbol(x172, Decl(generatedContextualTyping.ts, 176, 3)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -var x173: () => { (): Base[]; } = function() { return function() { return [d1, d2] }; }; ->x173 : Symbol(x173, Decl(generatedContextualTyping.ts, 177, 3)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -var x174: () => { (): Base[]; } = function() { return function named() { return [d1, d2] }; }; ->x174 : Symbol(x174, Decl(generatedContextualTyping.ts, 178, 3)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->named : Symbol(named, Decl(generatedContextualTyping.ts, 178, 53)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -var x175: () => Base[] = function() { return [d1, d2]; }; ->x175 : Symbol(x175, Decl(generatedContextualTyping.ts, 179, 3)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -var x176: () => Array = function() { return [d1, d2]; }; ->x176 : Symbol(x176, Decl(generatedContextualTyping.ts, 180, 3)) ->Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -var x177: () => { [n: number]: Base; } = function() { return [d1, d2]; }; ->x177 : Symbol(x177, Decl(generatedContextualTyping.ts, 181, 3)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 181, 19)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -var x178: () => {n: Base[]; } = function() { return { n: [d1, d2] }; }; ->x178 : Symbol(x178, Decl(generatedContextualTyping.ts, 182, 3)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 182, 17)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 182, 54)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -var x179: () => (s: Base[]) => any = function() { return n => { var n: Base[]; return null; }; }; ->x179 : Symbol(x179, Decl(generatedContextualTyping.ts, 183, 3)) ->s : Symbol(s, Decl(generatedContextualTyping.ts, 183, 17)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 183, 56), Decl(generatedContextualTyping.ts, 183, 67)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 183, 56), Decl(generatedContextualTyping.ts, 183, 67)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) - -var x180: () => Genric = function() { return { func: n => { return [d1, d2]; } }; }; ->x180 : Symbol(x180, Decl(generatedContextualTyping.ts, 184, 3)) ->Genric : Symbol(Genric, Decl(generatedContextualTyping.ts, 2, 42)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->func : Symbol(func, Decl(generatedContextualTyping.ts, 184, 52)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 184, 58)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -module x181 { var t: () => Base[] = () => [d1, d2]; } ->x181 : Symbol(x181, Decl(generatedContextualTyping.ts, 184, 90)) ->t : Symbol(t, Decl(generatedContextualTyping.ts, 185, 17)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -module x182 { var t: () => Base[] = function() { return [d1, d2] }; } ->x182 : Symbol(x182, Decl(generatedContextualTyping.ts, 185, 53)) ->t : Symbol(t, Decl(generatedContextualTyping.ts, 186, 17)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -module x183 { var t: () => Base[] = function named() { return [d1, d2] }; } ->x183 : Symbol(x183, Decl(generatedContextualTyping.ts, 186, 69)) ->t : Symbol(t, Decl(generatedContextualTyping.ts, 187, 17)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->named : Symbol(named, Decl(generatedContextualTyping.ts, 187, 35)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -module x184 { var t: { (): Base[]; } = () => [d1, d2]; } ->x184 : Symbol(x184, Decl(generatedContextualTyping.ts, 187, 75)) ->t : Symbol(t, Decl(generatedContextualTyping.ts, 188, 17)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -module x185 { var t: { (): Base[]; } = function() { return [d1, d2] }; } ->x185 : Symbol(x185, Decl(generatedContextualTyping.ts, 188, 56)) ->t : Symbol(t, Decl(generatedContextualTyping.ts, 189, 17)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -module x186 { var t: { (): Base[]; } = function named() { return [d1, d2] }; } ->x186 : Symbol(x186, Decl(generatedContextualTyping.ts, 189, 72)) ->t : Symbol(t, Decl(generatedContextualTyping.ts, 190, 17)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->named : Symbol(named, Decl(generatedContextualTyping.ts, 190, 38)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -module x187 { var t: Base[] = [d1, d2]; } ->x187 : Symbol(x187, Decl(generatedContextualTyping.ts, 190, 78)) ->t : Symbol(t, Decl(generatedContextualTyping.ts, 191, 17)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -module x188 { var t: Array = [d1, d2]; } ->x188 : Symbol(x188, Decl(generatedContextualTyping.ts, 191, 41)) ->t : Symbol(t, Decl(generatedContextualTyping.ts, 192, 17)) ->Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -module x189 { var t: { [n: number]: Base; } = [d1, d2]; } ->x189 : Symbol(x189, Decl(generatedContextualTyping.ts, 192, 46)) ->t : Symbol(t, Decl(generatedContextualTyping.ts, 193, 17)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 193, 24)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -module x190 { var t: {n: Base[]; } = { n: [d1, d2] }; } ->x190 : Symbol(x190, Decl(generatedContextualTyping.ts, 193, 57)) ->t : Symbol(t, Decl(generatedContextualTyping.ts, 194, 17)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 194, 22)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 194, 39)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -module x191 { var t: (s: Base[]) => any = n => { var n: Base[]; return null; }; } ->x191 : Symbol(x191, Decl(generatedContextualTyping.ts, 194, 56)) ->t : Symbol(t, Decl(generatedContextualTyping.ts, 195, 17)) ->s : Symbol(s, Decl(generatedContextualTyping.ts, 195, 22)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 195, 41), Decl(generatedContextualTyping.ts, 195, 52)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 195, 41), Decl(generatedContextualTyping.ts, 195, 52)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) - -module x192 { var t: Genric = { func: n => { return [d1, d2]; } }; } ->x192 : Symbol(x192, Decl(generatedContextualTyping.ts, 195, 81)) ->t : Symbol(t, Decl(generatedContextualTyping.ts, 196, 17)) ->Genric : Symbol(Genric, Decl(generatedContextualTyping.ts, 2, 42)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->func : Symbol(func, Decl(generatedContextualTyping.ts, 196, 37)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 196, 43)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -module x193 { export var t: () => Base[] = () => [d1, d2]; } ->x193 : Symbol(x193, Decl(generatedContextualTyping.ts, 196, 74)) ->t : Symbol(t, Decl(generatedContextualTyping.ts, 197, 24)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -module x194 { export var t: () => Base[] = function() { return [d1, d2] }; } ->x194 : Symbol(x194, Decl(generatedContextualTyping.ts, 197, 60)) ->t : Symbol(t, Decl(generatedContextualTyping.ts, 198, 24)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -module x195 { export var t: () => Base[] = function named() { return [d1, d2] }; } ->x195 : Symbol(x195, Decl(generatedContextualTyping.ts, 198, 76)) ->t : Symbol(t, Decl(generatedContextualTyping.ts, 199, 24)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->named : Symbol(named, Decl(generatedContextualTyping.ts, 199, 42)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -module x196 { export var t: { (): Base[]; } = () => [d1, d2]; } ->x196 : Symbol(x196, Decl(generatedContextualTyping.ts, 199, 82)) ->t : Symbol(t, Decl(generatedContextualTyping.ts, 200, 24)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -module x197 { export var t: { (): Base[]; } = function() { return [d1, d2] }; } ->x197 : Symbol(x197, Decl(generatedContextualTyping.ts, 200, 63)) ->t : Symbol(t, Decl(generatedContextualTyping.ts, 201, 24)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -module x198 { export var t: { (): Base[]; } = function named() { return [d1, d2] }; } ->x198 : Symbol(x198, Decl(generatedContextualTyping.ts, 201, 79)) ->t : Symbol(t, Decl(generatedContextualTyping.ts, 202, 24)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->named : Symbol(named, Decl(generatedContextualTyping.ts, 202, 45)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -module x199 { export var t: Base[] = [d1, d2]; } ->x199 : Symbol(x199, Decl(generatedContextualTyping.ts, 202, 85)) ->t : Symbol(t, Decl(generatedContextualTyping.ts, 203, 24)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -module x200 { export var t: Array = [d1, d2]; } ->x200 : Symbol(x200, Decl(generatedContextualTyping.ts, 203, 48)) ->t : Symbol(t, Decl(generatedContextualTyping.ts, 204, 24)) ->Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -module x201 { export var t: { [n: number]: Base; } = [d1, d2]; } ->x201 : Symbol(x201, Decl(generatedContextualTyping.ts, 204, 53)) ->t : Symbol(t, Decl(generatedContextualTyping.ts, 205, 24)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 205, 31)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -module x202 { export var t: {n: Base[]; } = { n: [d1, d2] }; } ->x202 : Symbol(x202, Decl(generatedContextualTyping.ts, 205, 64)) ->t : Symbol(t, Decl(generatedContextualTyping.ts, 206, 24)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 206, 29)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 206, 46)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -module x203 { export var t: (s: Base[]) => any = n => { var n: Base[]; return null; }; } ->x203 : Symbol(x203, Decl(generatedContextualTyping.ts, 206, 63)) ->t : Symbol(t, Decl(generatedContextualTyping.ts, 207, 24)) ->s : Symbol(s, Decl(generatedContextualTyping.ts, 207, 29)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 207, 48), Decl(generatedContextualTyping.ts, 207, 59)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 207, 48), Decl(generatedContextualTyping.ts, 207, 59)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) - -module x204 { export var t: Genric = { func: n => { return [d1, d2]; } }; } ->x204 : Symbol(x204, Decl(generatedContextualTyping.ts, 207, 88)) ->t : Symbol(t, Decl(generatedContextualTyping.ts, 208, 24)) ->Genric : Symbol(Genric, Decl(generatedContextualTyping.ts, 2, 42)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->func : Symbol(func, Decl(generatedContextualTyping.ts, 208, 44)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 208, 50)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -var x206 = <() => Base[]>function() { return [d1, d2] }; ->x206 : Symbol(x206, Decl(generatedContextualTyping.ts, 209, 3)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -var x207 = <() => Base[]>function named() { return [d1, d2] }; ->x207 : Symbol(x207, Decl(generatedContextualTyping.ts, 210, 3)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->named : Symbol(named, Decl(generatedContextualTyping.ts, 210, 25)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -var x209 = <{ (): Base[]; }>function() { return [d1, d2] }; ->x209 : Symbol(x209, Decl(generatedContextualTyping.ts, 211, 3)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -var x210 = <{ (): Base[]; }>function named() { return [d1, d2] }; ->x210 : Symbol(x210, Decl(generatedContextualTyping.ts, 212, 3)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->named : Symbol(named, Decl(generatedContextualTyping.ts, 212, 28)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -var x211 = [d1, d2]; ->x211 : Symbol(x211, Decl(generatedContextualTyping.ts, 213, 3)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -var x212 = >[d1, d2]; ->x212 : Symbol(x212, Decl(generatedContextualTyping.ts, 214, 3)) ->Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -var x213 = <{ [n: number]: Base; }>[d1, d2]; ->x213 : Symbol(x213, Decl(generatedContextualTyping.ts, 215, 3)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 215, 15)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -var x214 = <{n: Base[]; } >{ n: [d1, d2] }; ->x214 : Symbol(x214, Decl(generatedContextualTyping.ts, 216, 3)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 216, 13)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 216, 28)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -var x216 = >{ func: n => { return [d1, d2]; } }; ->x216 : Symbol(x216, Decl(generatedContextualTyping.ts, 217, 3)) ->Genric : Symbol(Genric, Decl(generatedContextualTyping.ts, 2, 42)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->func : Symbol(func, Decl(generatedContextualTyping.ts, 217, 26)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 217, 32)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -var x217 = (<() => Base[]>undefined) || function() { return [d1, d2] }; ->x217 : Symbol(x217, Decl(generatedContextualTyping.ts, 218, 3)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->undefined : Symbol(undefined) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -var x218 = (<() => Base[]>undefined) || function named() { return [d1, d2] }; ->x218 : Symbol(x218, Decl(generatedContextualTyping.ts, 219, 3)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->undefined : Symbol(undefined) ->named : Symbol(named, Decl(generatedContextualTyping.ts, 219, 39)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -var x219 = (<{ (): Base[]; }>undefined) || function() { return [d1, d2] }; ->x219 : Symbol(x219, Decl(generatedContextualTyping.ts, 220, 3)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->undefined : Symbol(undefined) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -var x220 = (<{ (): Base[]; }>undefined) || function named() { return [d1, d2] }; ->x220 : Symbol(x220, Decl(generatedContextualTyping.ts, 221, 3)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->undefined : Symbol(undefined) ->named : Symbol(named, Decl(generatedContextualTyping.ts, 221, 42)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -var x221 = (undefined) || [d1, d2]; ->x221 : Symbol(x221, Decl(generatedContextualTyping.ts, 222, 3)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->undefined : Symbol(undefined) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -var x222 = (>undefined) || [d1, d2]; ->x222 : Symbol(x222, Decl(generatedContextualTyping.ts, 223, 3)) ->Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->undefined : Symbol(undefined) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -var x223 = (<{ [n: number]: Base; }>undefined) || [d1, d2]; ->x223 : Symbol(x223, Decl(generatedContextualTyping.ts, 224, 3)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 224, 16)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->undefined : Symbol(undefined) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -var x224 = (<{n: Base[]; } >undefined) || { n: [d1, d2] }; ->x224 : Symbol(x224, Decl(generatedContextualTyping.ts, 225, 3)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 225, 14)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->undefined : Symbol(undefined) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 225, 43)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -var x225: () => Base[]; x225 = () => [d1, d2]; ->x225 : Symbol(x225, Decl(generatedContextualTyping.ts, 226, 3)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->x225 : Symbol(x225, Decl(generatedContextualTyping.ts, 226, 3)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -var x226: () => Base[]; x226 = function() { return [d1, d2] }; ->x226 : Symbol(x226, Decl(generatedContextualTyping.ts, 227, 3)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->x226 : Symbol(x226, Decl(generatedContextualTyping.ts, 227, 3)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -var x227: () => Base[]; x227 = function named() { return [d1, d2] }; ->x227 : Symbol(x227, Decl(generatedContextualTyping.ts, 228, 3)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->x227 : Symbol(x227, Decl(generatedContextualTyping.ts, 228, 3)) ->named : Symbol(named, Decl(generatedContextualTyping.ts, 228, 30)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -var x228: { (): Base[]; }; x228 = () => [d1, d2]; ->x228 : Symbol(x228, Decl(generatedContextualTyping.ts, 229, 3)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->x228 : Symbol(x228, Decl(generatedContextualTyping.ts, 229, 3)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -var x229: { (): Base[]; }; x229 = function() { return [d1, d2] }; ->x229 : Symbol(x229, Decl(generatedContextualTyping.ts, 230, 3)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->x229 : Symbol(x229, Decl(generatedContextualTyping.ts, 230, 3)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -var x230: { (): Base[]; }; x230 = function named() { return [d1, d2] }; ->x230 : Symbol(x230, Decl(generatedContextualTyping.ts, 231, 3)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->x230 : Symbol(x230, Decl(generatedContextualTyping.ts, 231, 3)) ->named : Symbol(named, Decl(generatedContextualTyping.ts, 231, 33)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -var x231: Base[]; x231 = [d1, d2]; ->x231 : Symbol(x231, Decl(generatedContextualTyping.ts, 232, 3)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->x231 : Symbol(x231, Decl(generatedContextualTyping.ts, 232, 3)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -var x232: Array; x232 = [d1, d2]; ->x232 : Symbol(x232, Decl(generatedContextualTyping.ts, 233, 3)) ->Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->x232 : Symbol(x232, Decl(generatedContextualTyping.ts, 233, 3)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -var x233: { [n: number]: Base; }; x233 = [d1, d2]; ->x233 : Symbol(x233, Decl(generatedContextualTyping.ts, 234, 3)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 234, 13)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->x233 : Symbol(x233, Decl(generatedContextualTyping.ts, 234, 3)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -var x234: {n: Base[]; } ; x234 = { n: [d1, d2] }; ->x234 : Symbol(x234, Decl(generatedContextualTyping.ts, 235, 3)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 235, 11)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->x234 : Symbol(x234, Decl(generatedContextualTyping.ts, 235, 3)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 235, 34)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -var x235: (s: Base[]) => any; x235 = n => { var n: Base[]; return null; }; ->x235 : Symbol(x235, Decl(generatedContextualTyping.ts, 236, 3)) ->s : Symbol(s, Decl(generatedContextualTyping.ts, 236, 11)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->x235 : Symbol(x235, Decl(generatedContextualTyping.ts, 236, 3)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 236, 36), Decl(generatedContextualTyping.ts, 236, 47)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 236, 36), Decl(generatedContextualTyping.ts, 236, 47)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) - -var x236: Genric; x236 = { func: n => { return [d1, d2]; } }; ->x236 : Symbol(x236, Decl(generatedContextualTyping.ts, 237, 3)) ->Genric : Symbol(Genric, Decl(generatedContextualTyping.ts, 2, 42)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->x236 : Symbol(x236, Decl(generatedContextualTyping.ts, 237, 3)) ->func : Symbol(func, Decl(generatedContextualTyping.ts, 237, 32)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 237, 38)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -var x237: { n: () => Base[]; } = { n: () => [d1, d2] }; ->x237 : Symbol(x237, Decl(generatedContextualTyping.ts, 238, 3)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 238, 11)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 238, 34)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -var x238: { n: () => Base[]; } = { n: function() { return [d1, d2] } }; ->x238 : Symbol(x238, Decl(generatedContextualTyping.ts, 239, 3)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 239, 11)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 239, 34)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -var x239: { n: () => Base[]; } = { n: function named() { return [d1, d2] } }; ->x239 : Symbol(x239, Decl(generatedContextualTyping.ts, 240, 3)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 240, 11)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 240, 34)) ->named : Symbol(named, Decl(generatedContextualTyping.ts, 240, 37)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -var x240: { n: { (): Base[]; }; } = { n: () => [d1, d2] }; ->x240 : Symbol(x240, Decl(generatedContextualTyping.ts, 241, 3)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 241, 11)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 241, 37)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -var x241: { n: { (): Base[]; }; } = { n: function() { return [d1, d2] } }; ->x241 : Symbol(x241, Decl(generatedContextualTyping.ts, 242, 3)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 242, 11)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 242, 37)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -var x242: { n: { (): Base[]; }; } = { n: function named() { return [d1, d2] } }; ->x242 : Symbol(x242, Decl(generatedContextualTyping.ts, 243, 3)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 243, 11)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 243, 37)) ->named : Symbol(named, Decl(generatedContextualTyping.ts, 243, 40)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -var x243: { n: Base[]; } = { n: [d1, d2] }; ->x243 : Symbol(x243, Decl(generatedContextualTyping.ts, 244, 3)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 244, 11)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 244, 28)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -var x244: { n: Array; } = { n: [d1, d2] }; ->x244 : Symbol(x244, Decl(generatedContextualTyping.ts, 245, 3)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 245, 11)) ->Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 245, 33)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -var x245: { n: { [n: number]: Base; }; } = { n: [d1, d2] }; ->x245 : Symbol(x245, Decl(generatedContextualTyping.ts, 246, 3)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 246, 11)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 246, 18)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 246, 44)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -var x246: { n: {n: Base[]; } ; } = { n: { n: [d1, d2] } }; ->x246 : Symbol(x246, Decl(generatedContextualTyping.ts, 247, 3)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 247, 11)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 247, 16)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 247, 36)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 247, 41)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -var x247: { n: (s: Base[]) => any; } = { n: n => { var n: Base[]; return null; } }; ->x247 : Symbol(x247, Decl(generatedContextualTyping.ts, 248, 3)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 248, 11)) ->s : Symbol(s, Decl(generatedContextualTyping.ts, 248, 16)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 248, 40)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 248, 43), Decl(generatedContextualTyping.ts, 248, 54)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 248, 43), Decl(generatedContextualTyping.ts, 248, 54)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) - -var x248: { n: Genric; } = { n: { func: n => { return [d1, d2]; } } }; ->x248 : Symbol(x248, Decl(generatedContextualTyping.ts, 249, 3)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 249, 11)) ->Genric : Symbol(Genric, Decl(generatedContextualTyping.ts, 2, 42)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 249, 34)) ->func : Symbol(func, Decl(generatedContextualTyping.ts, 249, 39)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 249, 45)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -var x252: { (): Base[]; }[] = [() => [d1, d2]]; ->x252 : Symbol(x252, Decl(generatedContextualTyping.ts, 250, 3)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -var x253: { (): Base[]; }[] = [function() { return [d1, d2] }]; ->x253 : Symbol(x253, Decl(generatedContextualTyping.ts, 251, 3)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -var x254: { (): Base[]; }[] = [function named() { return [d1, d2] }]; ->x254 : Symbol(x254, Decl(generatedContextualTyping.ts, 252, 3)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->named : Symbol(named, Decl(generatedContextualTyping.ts, 252, 31)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -var x255: Base[][] = [[d1, d2]]; ->x255 : Symbol(x255, Decl(generatedContextualTyping.ts, 253, 3)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -var x256: Array[] = [[d1, d2]]; ->x256 : Symbol(x256, Decl(generatedContextualTyping.ts, 254, 3)) ->Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -var x257: { [n: number]: Base; }[] = [[d1, d2]]; ->x257 : Symbol(x257, Decl(generatedContextualTyping.ts, 255, 3)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 255, 13)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -var x258: {n: Base[]; } [] = [{ n: [d1, d2] }]; ->x258 : Symbol(x258, Decl(generatedContextualTyping.ts, 256, 3)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 256, 11)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 256, 31)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -var x260: Genric[] = [{ func: n => { return [d1, d2]; } }]; ->x260 : Symbol(x260, Decl(generatedContextualTyping.ts, 257, 3)) ->Genric : Symbol(Genric, Decl(generatedContextualTyping.ts, 2, 42)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->func : Symbol(func, Decl(generatedContextualTyping.ts, 257, 29)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 257, 35)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -var x261: () => Base[] = function() { return [d1, d2] } || undefined; ->x261 : Symbol(x261, Decl(generatedContextualTyping.ts, 258, 3)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) ->undefined : Symbol(undefined) - -var x262: () => Base[] = function named() { return [d1, d2] } || undefined; ->x262 : Symbol(x262, Decl(generatedContextualTyping.ts, 259, 3)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->named : Symbol(named, Decl(generatedContextualTyping.ts, 259, 24)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) ->undefined : Symbol(undefined) - -var x263: { (): Base[]; } = function() { return [d1, d2] } || undefined; ->x263 : Symbol(x263, Decl(generatedContextualTyping.ts, 260, 3)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) ->undefined : Symbol(undefined) - -var x264: { (): Base[]; } = function named() { return [d1, d2] } || undefined; ->x264 : Symbol(x264, Decl(generatedContextualTyping.ts, 261, 3)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->named : Symbol(named, Decl(generatedContextualTyping.ts, 261, 27)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) ->undefined : Symbol(undefined) - -var x265: Base[] = [d1, d2] || undefined; ->x265 : Symbol(x265, Decl(generatedContextualTyping.ts, 262, 3)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) ->undefined : Symbol(undefined) - -var x266: Array = [d1, d2] || undefined; ->x266 : Symbol(x266, Decl(generatedContextualTyping.ts, 263, 3)) ->Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) ->undefined : Symbol(undefined) - -var x267: { [n: number]: Base; } = [d1, d2] || undefined; ->x267 : Symbol(x267, Decl(generatedContextualTyping.ts, 264, 3)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 264, 13)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) ->undefined : Symbol(undefined) - -var x268: {n: Base[]; } = { n: [d1, d2] } || undefined; ->x268 : Symbol(x268, Decl(generatedContextualTyping.ts, 265, 3)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 265, 11)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 265, 28)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) ->undefined : Symbol(undefined) - -var x269: () => Base[] = undefined || function() { return [d1, d2] }; ->x269 : Symbol(x269, Decl(generatedContextualTyping.ts, 266, 3)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->undefined : Symbol(undefined) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -var x270: () => Base[] = undefined || function named() { return [d1, d2] }; ->x270 : Symbol(x270, Decl(generatedContextualTyping.ts, 267, 3)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->undefined : Symbol(undefined) ->named : Symbol(named, Decl(generatedContextualTyping.ts, 267, 37)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -var x271: { (): Base[]; } = undefined || function() { return [d1, d2] }; ->x271 : Symbol(x271, Decl(generatedContextualTyping.ts, 268, 3)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->undefined : Symbol(undefined) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -var x272: { (): Base[]; } = undefined || function named() { return [d1, d2] }; ->x272 : Symbol(x272, Decl(generatedContextualTyping.ts, 269, 3)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->undefined : Symbol(undefined) ->named : Symbol(named, Decl(generatedContextualTyping.ts, 269, 40)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -var x273: Base[] = undefined || [d1, d2]; ->x273 : Symbol(x273, Decl(generatedContextualTyping.ts, 270, 3)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->undefined : Symbol(undefined) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -var x274: Array = undefined || [d1, d2]; ->x274 : Symbol(x274, Decl(generatedContextualTyping.ts, 271, 3)) ->Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->undefined : Symbol(undefined) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -var x275: { [n: number]: Base; } = undefined || [d1, d2]; ->x275 : Symbol(x275, Decl(generatedContextualTyping.ts, 272, 3)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 272, 13)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->undefined : Symbol(undefined) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -var x276: {n: Base[]; } = undefined || { n: [d1, d2] }; ->x276 : Symbol(x276, Decl(generatedContextualTyping.ts, 273, 3)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 273, 11)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->undefined : Symbol(undefined) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 273, 41)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -var x277: () => Base[] = function() { return [d1, d2] } || function() { return [d1, d2] }; ->x277 : Symbol(x277, Decl(generatedContextualTyping.ts, 274, 3)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -var x278: () => Base[] = function named() { return [d1, d2] } || function named() { return [d1, d2] }; ->x278 : Symbol(x278, Decl(generatedContextualTyping.ts, 275, 3)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->named : Symbol(named, Decl(generatedContextualTyping.ts, 275, 24)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) ->named : Symbol(named, Decl(generatedContextualTyping.ts, 275, 64)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -var x279: { (): Base[]; } = function() { return [d1, d2] } || function() { return [d1, d2] }; ->x279 : Symbol(x279, Decl(generatedContextualTyping.ts, 276, 3)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -var x280: { (): Base[]; } = function named() { return [d1, d2] } || function named() { return [d1, d2] }; ->x280 : Symbol(x280, Decl(generatedContextualTyping.ts, 277, 3)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->named : Symbol(named, Decl(generatedContextualTyping.ts, 277, 27)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) ->named : Symbol(named, Decl(generatedContextualTyping.ts, 277, 67)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -var x281: Base[] = [d1, d2] || [d1, d2]; ->x281 : Symbol(x281, Decl(generatedContextualTyping.ts, 278, 3)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -var x282: Array = [d1, d2] || [d1, d2]; ->x282 : Symbol(x282, Decl(generatedContextualTyping.ts, 279, 3)) ->Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -var x283: { [n: number]: Base; } = [d1, d2] || [d1, d2]; ->x283 : Symbol(x283, Decl(generatedContextualTyping.ts, 280, 3)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 280, 13)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -var x284: {n: Base[]; } = { n: [d1, d2] } || { n: [d1, d2] }; ->x284 : Symbol(x284, Decl(generatedContextualTyping.ts, 281, 3)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 281, 11)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 281, 28)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 281, 47)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -var x285: () => Base[] = true ? () => [d1, d2] : () => [d1, d2]; ->x285 : Symbol(x285, Decl(generatedContextualTyping.ts, 282, 3)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -var x286: () => Base[] = true ? function() { return [d1, d2] } : function() { return [d1, d2] }; ->x286 : Symbol(x286, Decl(generatedContextualTyping.ts, 283, 3)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -var x287: () => Base[] = true ? function named() { return [d1, d2] } : function named() { return [d1, d2] }; ->x287 : Symbol(x287, Decl(generatedContextualTyping.ts, 284, 3)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->named : Symbol(named, Decl(generatedContextualTyping.ts, 284, 31)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) ->named : Symbol(named, Decl(generatedContextualTyping.ts, 284, 70)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -var x288: { (): Base[]; } = true ? () => [d1, d2] : () => [d1, d2]; ->x288 : Symbol(x288, Decl(generatedContextualTyping.ts, 285, 3)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -var x289: { (): Base[]; } = true ? function() { return [d1, d2] } : function() { return [d1, d2] }; ->x289 : Symbol(x289, Decl(generatedContextualTyping.ts, 286, 3)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -var x290: { (): Base[]; } = true ? function named() { return [d1, d2] } : function named() { return [d1, d2] }; ->x290 : Symbol(x290, Decl(generatedContextualTyping.ts, 287, 3)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->named : Symbol(named, Decl(generatedContextualTyping.ts, 287, 34)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) ->named : Symbol(named, Decl(generatedContextualTyping.ts, 287, 73)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -var x291: Base[] = true ? [d1, d2] : [d1, d2]; ->x291 : Symbol(x291, Decl(generatedContextualTyping.ts, 288, 3)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -var x292: Array = true ? [d1, d2] : [d1, d2]; ->x292 : Symbol(x292, Decl(generatedContextualTyping.ts, 289, 3)) ->Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -var x293: { [n: number]: Base; } = true ? [d1, d2] : [d1, d2]; ->x293 : Symbol(x293, Decl(generatedContextualTyping.ts, 290, 3)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 290, 13)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -var x294: {n: Base[]; } = true ? { n: [d1, d2] } : { n: [d1, d2] }; ->x294 : Symbol(x294, Decl(generatedContextualTyping.ts, 291, 3)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 291, 11)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 291, 35)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 291, 53)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -var x295: (s: Base[]) => any = true ? n => { var n: Base[]; return null; } : n => { var n: Base[]; return null; }; ->x295 : Symbol(x295, Decl(generatedContextualTyping.ts, 292, 3)) ->s : Symbol(s, Decl(generatedContextualTyping.ts, 292, 11)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 292, 37), Decl(generatedContextualTyping.ts, 292, 48)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 292, 37), Decl(generatedContextualTyping.ts, 292, 48)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 292, 76), Decl(generatedContextualTyping.ts, 292, 87)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 292, 76), Decl(generatedContextualTyping.ts, 292, 87)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) - -var x296: Genric = true ? { func: n => { return [d1, d2]; } } : { func: n => { return [d1, d2]; } }; ->x296 : Symbol(x296, Decl(generatedContextualTyping.ts, 293, 3)) ->Genric : Symbol(Genric, Decl(generatedContextualTyping.ts, 2, 42)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->func : Symbol(func, Decl(generatedContextualTyping.ts, 293, 33)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 293, 39)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) ->func : Symbol(func, Decl(generatedContextualTyping.ts, 293, 71)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 293, 77)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -var x297: () => Base[] = true ? undefined : () => [d1, d2]; ->x297 : Symbol(x297, Decl(generatedContextualTyping.ts, 294, 3)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->undefined : Symbol(undefined) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -var x298: () => Base[] = true ? undefined : function() { return [d1, d2] }; ->x298 : Symbol(x298, Decl(generatedContextualTyping.ts, 295, 3)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->undefined : Symbol(undefined) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -var x299: () => Base[] = true ? undefined : function named() { return [d1, d2] }; ->x299 : Symbol(x299, Decl(generatedContextualTyping.ts, 296, 3)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->undefined : Symbol(undefined) ->named : Symbol(named, Decl(generatedContextualTyping.ts, 296, 43)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -var x300: { (): Base[]; } = true ? undefined : () => [d1, d2]; ->x300 : Symbol(x300, Decl(generatedContextualTyping.ts, 297, 3)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->undefined : Symbol(undefined) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -var x301: { (): Base[]; } = true ? undefined : function() { return [d1, d2] }; ->x301 : Symbol(x301, Decl(generatedContextualTyping.ts, 298, 3)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->undefined : Symbol(undefined) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -var x302: { (): Base[]; } = true ? undefined : function named() { return [d1, d2] }; ->x302 : Symbol(x302, Decl(generatedContextualTyping.ts, 299, 3)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->undefined : Symbol(undefined) ->named : Symbol(named, Decl(generatedContextualTyping.ts, 299, 46)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -var x303: Base[] = true ? undefined : [d1, d2]; ->x303 : Symbol(x303, Decl(generatedContextualTyping.ts, 300, 3)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->undefined : Symbol(undefined) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -var x304: Array = true ? undefined : [d1, d2]; ->x304 : Symbol(x304, Decl(generatedContextualTyping.ts, 301, 3)) ->Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->undefined : Symbol(undefined) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -var x305: { [n: number]: Base; } = true ? undefined : [d1, d2]; ->x305 : Symbol(x305, Decl(generatedContextualTyping.ts, 302, 3)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 302, 13)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->undefined : Symbol(undefined) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -var x306: {n: Base[]; } = true ? undefined : { n: [d1, d2] }; ->x306 : Symbol(x306, Decl(generatedContextualTyping.ts, 303, 3)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 303, 11)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->undefined : Symbol(undefined) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 303, 47)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -var x307: (s: Base[]) => any = true ? undefined : n => { var n: Base[]; return null; }; ->x307 : Symbol(x307, Decl(generatedContextualTyping.ts, 304, 3)) ->s : Symbol(s, Decl(generatedContextualTyping.ts, 304, 11)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->undefined : Symbol(undefined) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 304, 49), Decl(generatedContextualTyping.ts, 304, 60)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 304, 49), Decl(generatedContextualTyping.ts, 304, 60)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) - -var x308: Genric = true ? undefined : { func: n => { return [d1, d2]; } }; ->x308 : Symbol(x308, Decl(generatedContextualTyping.ts, 305, 3)) ->Genric : Symbol(Genric, Decl(generatedContextualTyping.ts, 2, 42)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->undefined : Symbol(undefined) ->func : Symbol(func, Decl(generatedContextualTyping.ts, 305, 45)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 305, 51)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -var x309: () => Base[] = true ? () => [d1, d2] : undefined; ->x309 : Symbol(x309, Decl(generatedContextualTyping.ts, 306, 3)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) ->undefined : Symbol(undefined) - -var x310: () => Base[] = true ? function() { return [d1, d2] } : undefined; ->x310 : Symbol(x310, Decl(generatedContextualTyping.ts, 307, 3)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) ->undefined : Symbol(undefined) - -var x311: () => Base[] = true ? function named() { return [d1, d2] } : undefined; ->x311 : Symbol(x311, Decl(generatedContextualTyping.ts, 308, 3)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->named : Symbol(named, Decl(generatedContextualTyping.ts, 308, 31)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) ->undefined : Symbol(undefined) - -var x312: { (): Base[]; } = true ? () => [d1, d2] : undefined; ->x312 : Symbol(x312, Decl(generatedContextualTyping.ts, 309, 3)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) ->undefined : Symbol(undefined) - -var x313: { (): Base[]; } = true ? function() { return [d1, d2] } : undefined; ->x313 : Symbol(x313, Decl(generatedContextualTyping.ts, 310, 3)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) ->undefined : Symbol(undefined) - -var x314: { (): Base[]; } = true ? function named() { return [d1, d2] } : undefined; ->x314 : Symbol(x314, Decl(generatedContextualTyping.ts, 311, 3)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->named : Symbol(named, Decl(generatedContextualTyping.ts, 311, 34)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) ->undefined : Symbol(undefined) - -var x315: Base[] = true ? [d1, d2] : undefined; ->x315 : Symbol(x315, Decl(generatedContextualTyping.ts, 312, 3)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) ->undefined : Symbol(undefined) - -var x316: Array = true ? [d1, d2] : undefined; ->x316 : Symbol(x316, Decl(generatedContextualTyping.ts, 313, 3)) ->Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) ->undefined : Symbol(undefined) - -var x317: { [n: number]: Base; } = true ? [d1, d2] : undefined; ->x317 : Symbol(x317, Decl(generatedContextualTyping.ts, 314, 3)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 314, 13)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) ->undefined : Symbol(undefined) - -var x318: {n: Base[]; } = true ? { n: [d1, d2] } : undefined; ->x318 : Symbol(x318, Decl(generatedContextualTyping.ts, 315, 3)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 315, 11)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 315, 35)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) ->undefined : Symbol(undefined) - -var x319: (s: Base[]) => any = true ? n => { var n: Base[]; return null; } : undefined; ->x319 : Symbol(x319, Decl(generatedContextualTyping.ts, 316, 3)) ->s : Symbol(s, Decl(generatedContextualTyping.ts, 316, 11)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 316, 37), Decl(generatedContextualTyping.ts, 316, 48)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 316, 37), Decl(generatedContextualTyping.ts, 316, 48)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->undefined : Symbol(undefined) - -var x320: Genric = true ? { func: n => { return [d1, d2]; } } : undefined; ->x320 : Symbol(x320, Decl(generatedContextualTyping.ts, 317, 3)) ->Genric : Symbol(Genric, Decl(generatedContextualTyping.ts, 2, 42)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->func : Symbol(func, Decl(generatedContextualTyping.ts, 317, 33)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 317, 39)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) ->undefined : Symbol(undefined) - -function x321(n: () => Base[]) { }; x321(() => [d1, d2]); ->x321 : Symbol(x321, Decl(generatedContextualTyping.ts, 317, 80)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 318, 14)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->x321 : Symbol(x321, Decl(generatedContextualTyping.ts, 317, 80)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -function x322(n: () => Base[]) { }; x322(function() { return [d1, d2] }); ->x322 : Symbol(x322, Decl(generatedContextualTyping.ts, 318, 57)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 319, 14)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->x322 : Symbol(x322, Decl(generatedContextualTyping.ts, 318, 57)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -function x323(n: () => Base[]) { }; x323(function named() { return [d1, d2] }); ->x323 : Symbol(x323, Decl(generatedContextualTyping.ts, 319, 73)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 320, 14)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->x323 : Symbol(x323, Decl(generatedContextualTyping.ts, 319, 73)) ->named : Symbol(named, Decl(generatedContextualTyping.ts, 320, 41)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -function x324(n: { (): Base[]; }) { }; x324(() => [d1, d2]); ->x324 : Symbol(x324, Decl(generatedContextualTyping.ts, 320, 79)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 321, 14)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->x324 : Symbol(x324, Decl(generatedContextualTyping.ts, 320, 79)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -function x325(n: { (): Base[]; }) { }; x325(function() { return [d1, d2] }); ->x325 : Symbol(x325, Decl(generatedContextualTyping.ts, 321, 60)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 322, 14)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->x325 : Symbol(x325, Decl(generatedContextualTyping.ts, 321, 60)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -function x326(n: { (): Base[]; }) { }; x326(function named() { return [d1, d2] }); ->x326 : Symbol(x326, Decl(generatedContextualTyping.ts, 322, 76)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 323, 14)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->x326 : Symbol(x326, Decl(generatedContextualTyping.ts, 322, 76)) ->named : Symbol(named, Decl(generatedContextualTyping.ts, 323, 44)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -function x327(n: Base[]) { }; x327([d1, d2]); ->x327 : Symbol(x327, Decl(generatedContextualTyping.ts, 323, 82)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 324, 14)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->x327 : Symbol(x327, Decl(generatedContextualTyping.ts, 323, 82)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -function x328(n: Array) { }; x328([d1, d2]); ->x328 : Symbol(x328, Decl(generatedContextualTyping.ts, 324, 45)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 325, 14)) ->Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->x328 : Symbol(x328, Decl(generatedContextualTyping.ts, 324, 45)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -function x329(n: { [n: number]: Base; }) { }; x329([d1, d2]); ->x329 : Symbol(x329, Decl(generatedContextualTyping.ts, 325, 50)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 326, 14)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 326, 20)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->x329 : Symbol(x329, Decl(generatedContextualTyping.ts, 325, 50)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -function x330(n: {n: Base[]; } ) { }; x330({ n: [d1, d2] }); ->x330 : Symbol(x330, Decl(generatedContextualTyping.ts, 326, 61)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 327, 14)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 327, 18)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->x330 : Symbol(x330, Decl(generatedContextualTyping.ts, 326, 61)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 327, 44)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -function x331(n: (s: Base[]) => any) { }; x331(n => { var n: Base[]; return null; }); ->x331 : Symbol(x331, Decl(generatedContextualTyping.ts, 327, 60)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 328, 14)) ->s : Symbol(s, Decl(generatedContextualTyping.ts, 328, 18)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->x331 : Symbol(x331, Decl(generatedContextualTyping.ts, 327, 60)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 328, 47), Decl(generatedContextualTyping.ts, 328, 57)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 328, 47), Decl(generatedContextualTyping.ts, 328, 57)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) - -function x332(n: Genric) { }; x332({ func: n => { return [d1, d2]; } }); ->x332 : Symbol(x332, Decl(generatedContextualTyping.ts, 328, 85)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 329, 14)) ->Genric : Symbol(Genric, Decl(generatedContextualTyping.ts, 2, 42)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->x332 : Symbol(x332, Decl(generatedContextualTyping.ts, 328, 85)) ->func : Symbol(func, Decl(generatedContextualTyping.ts, 329, 42)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 329, 48)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -var x333 = (n: () => Base[]) => n; x333(() => [d1, d2]); ->x333 : Symbol(x333, Decl(generatedContextualTyping.ts, 330, 3)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 330, 12)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 330, 12)) ->x333 : Symbol(x333, Decl(generatedContextualTyping.ts, 330, 3)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -var x334 = (n: () => Base[]) => n; x334(function() { return [d1, d2] }); ->x334 : Symbol(x334, Decl(generatedContextualTyping.ts, 331, 3)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 331, 12)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 331, 12)) ->x334 : Symbol(x334, Decl(generatedContextualTyping.ts, 331, 3)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -var x335 = (n: () => Base[]) => n; x335(function named() { return [d1, d2] }); ->x335 : Symbol(x335, Decl(generatedContextualTyping.ts, 332, 3)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 332, 12)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 332, 12)) ->x335 : Symbol(x335, Decl(generatedContextualTyping.ts, 332, 3)) ->named : Symbol(named, Decl(generatedContextualTyping.ts, 332, 40)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -var x336 = (n: { (): Base[]; }) => n; x336(() => [d1, d2]); ->x336 : Symbol(x336, Decl(generatedContextualTyping.ts, 333, 3)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 333, 12)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 333, 12)) ->x336 : Symbol(x336, Decl(generatedContextualTyping.ts, 333, 3)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -var x337 = (n: { (): Base[]; }) => n; x337(function() { return [d1, d2] }); ->x337 : Symbol(x337, Decl(generatedContextualTyping.ts, 334, 3)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 334, 12)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 334, 12)) ->x337 : Symbol(x337, Decl(generatedContextualTyping.ts, 334, 3)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -var x338 = (n: { (): Base[]; }) => n; x338(function named() { return [d1, d2] }); ->x338 : Symbol(x338, Decl(generatedContextualTyping.ts, 335, 3)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 335, 12)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 335, 12)) ->x338 : Symbol(x338, Decl(generatedContextualTyping.ts, 335, 3)) ->named : Symbol(named, Decl(generatedContextualTyping.ts, 335, 43)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -var x339 = (n: Base[]) => n; x339([d1, d2]); ->x339 : Symbol(x339, Decl(generatedContextualTyping.ts, 336, 3)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 336, 12)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 336, 12)) ->x339 : Symbol(x339, Decl(generatedContextualTyping.ts, 336, 3)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -var x340 = (n: Array) => n; x340([d1, d2]); ->x340 : Symbol(x340, Decl(generatedContextualTyping.ts, 337, 3)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 337, 12)) ->Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 337, 12)) ->x340 : Symbol(x340, Decl(generatedContextualTyping.ts, 337, 3)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -var x341 = (n: { [n: number]: Base; }) => n; x341([d1, d2]); ->x341 : Symbol(x341, Decl(generatedContextualTyping.ts, 338, 3)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 338, 12)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 338, 18)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 338, 12)) ->x341 : Symbol(x341, Decl(generatedContextualTyping.ts, 338, 3)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -var x342 = (n: {n: Base[]; } ) => n; x342({ n: [d1, d2] }); ->x342 : Symbol(x342, Decl(generatedContextualTyping.ts, 339, 3)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 339, 12)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 339, 16)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 339, 12)) ->x342 : Symbol(x342, Decl(generatedContextualTyping.ts, 339, 3)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 339, 43)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -var x343 = (n: (s: Base[]) => any) => n; x343(n => { var n: Base[]; return null; }); ->x343 : Symbol(x343, Decl(generatedContextualTyping.ts, 340, 3)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 340, 12)) ->s : Symbol(s, Decl(generatedContextualTyping.ts, 340, 16)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 340, 12)) ->x343 : Symbol(x343, Decl(generatedContextualTyping.ts, 340, 3)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 340, 46), Decl(generatedContextualTyping.ts, 340, 56)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 340, 46), Decl(generatedContextualTyping.ts, 340, 56)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) - -var x344 = (n: Genric) => n; x344({ func: n => { return [d1, d2]; } }); ->x344 : Symbol(x344, Decl(generatedContextualTyping.ts, 341, 3)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 341, 12)) ->Genric : Symbol(Genric, Decl(generatedContextualTyping.ts, 2, 42)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 341, 12)) ->x344 : Symbol(x344, Decl(generatedContextualTyping.ts, 341, 3)) ->func : Symbol(func, Decl(generatedContextualTyping.ts, 341, 41)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 341, 47)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -var x345 = function(n: () => Base[]) { }; x345(() => [d1, d2]); ->x345 : Symbol(x345, Decl(generatedContextualTyping.ts, 342, 3)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 342, 20)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->x345 : Symbol(x345, Decl(generatedContextualTyping.ts, 342, 3)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -var x346 = function(n: () => Base[]) { }; x346(function() { return [d1, d2] }); ->x346 : Symbol(x346, Decl(generatedContextualTyping.ts, 343, 3)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 343, 20)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->x346 : Symbol(x346, Decl(generatedContextualTyping.ts, 343, 3)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -var x347 = function(n: () => Base[]) { }; x347(function named() { return [d1, d2] }); ->x347 : Symbol(x347, Decl(generatedContextualTyping.ts, 344, 3)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 344, 20)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->x347 : Symbol(x347, Decl(generatedContextualTyping.ts, 344, 3)) ->named : Symbol(named, Decl(generatedContextualTyping.ts, 344, 47)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -var x348 = function(n: { (): Base[]; }) { }; x348(() => [d1, d2]); ->x348 : Symbol(x348, Decl(generatedContextualTyping.ts, 345, 3)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 345, 20)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->x348 : Symbol(x348, Decl(generatedContextualTyping.ts, 345, 3)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -var x349 = function(n: { (): Base[]; }) { }; x349(function() { return [d1, d2] }); ->x349 : Symbol(x349, Decl(generatedContextualTyping.ts, 346, 3)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 346, 20)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->x349 : Symbol(x349, Decl(generatedContextualTyping.ts, 346, 3)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -var x350 = function(n: { (): Base[]; }) { }; x350(function named() { return [d1, d2] }); ->x350 : Symbol(x350, Decl(generatedContextualTyping.ts, 347, 3)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 347, 20)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->x350 : Symbol(x350, Decl(generatedContextualTyping.ts, 347, 3)) ->named : Symbol(named, Decl(generatedContextualTyping.ts, 347, 50)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -var x351 = function(n: Base[]) { }; x351([d1, d2]); ->x351 : Symbol(x351, Decl(generatedContextualTyping.ts, 348, 3)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 348, 20)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->x351 : Symbol(x351, Decl(generatedContextualTyping.ts, 348, 3)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -var x352 = function(n: Array) { }; x352([d1, d2]); ->x352 : Symbol(x352, Decl(generatedContextualTyping.ts, 349, 3)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 349, 20)) ->Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->x352 : Symbol(x352, Decl(generatedContextualTyping.ts, 349, 3)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -var x353 = function(n: { [n: number]: Base; }) { }; x353([d1, d2]); ->x353 : Symbol(x353, Decl(generatedContextualTyping.ts, 350, 3)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 350, 20)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 350, 26)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->x353 : Symbol(x353, Decl(generatedContextualTyping.ts, 350, 3)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -var x354 = function(n: {n: Base[]; } ) { }; x354({ n: [d1, d2] }); ->x354 : Symbol(x354, Decl(generatedContextualTyping.ts, 351, 3)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 351, 20)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 351, 24)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->x354 : Symbol(x354, Decl(generatedContextualTyping.ts, 351, 3)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 351, 50)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - -var x355 = function(n: (s: Base[]) => any) { }; x355(n => { var n: Base[]; return null; }); ->x355 : Symbol(x355, Decl(generatedContextualTyping.ts, 352, 3)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 352, 20)) ->s : Symbol(s, Decl(generatedContextualTyping.ts, 352, 24)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->x355 : Symbol(x355, Decl(generatedContextualTyping.ts, 352, 3)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 352, 53), Decl(generatedContextualTyping.ts, 352, 63)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 352, 53), Decl(generatedContextualTyping.ts, 352, 63)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) - -var x356 = function(n: Genric) { }; x356({ func: n => { return [d1, d2]; } }); ->x356 : Symbol(x356, Decl(generatedContextualTyping.ts, 353, 3)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 353, 20)) ->Genric : Symbol(Genric, Decl(generatedContextualTyping.ts, 2, 42)) ->Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) ->x356 : Symbol(x356, Decl(generatedContextualTyping.ts, 353, 3)) ->func : Symbol(func, Decl(generatedContextualTyping.ts, 353, 48)) ->n : Symbol(n, Decl(generatedContextualTyping.ts, 353, 54)) ->d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 4, 19)) ->d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 4, 40)) - diff --git a/tests/baselines/reference/generatedContextualTyping.types b/tests/baselines/reference/generatedContextualTyping.types deleted file mode 100644 index e8f434d31a8..00000000000 --- a/tests/baselines/reference/generatedContextualTyping.types +++ /dev/null @@ -1,3768 +0,0 @@ -=== tests/cases/conformance/expressions/contextualTyping/generatedContextualTyping.ts === -class Base { private p; } ->Base : Base ->p : any - -class Derived1 extends Base { private m; } ->Derived1 : Derived1 ->Base : Base ->m : any - -class Derived2 extends Base { private n; } ->Derived2 : Derived2 ->Base : Base ->n : any - -interface Genric { func(n: T[]); } ->Genric : Genric ->T : T ->func : (n: T[]) => any ->n : T[] ->T : T - -var b = new Base(), d1 = new Derived1(), d2 = new Derived2(); ->b : Base ->new Base() : Base ->Base : typeof Base ->d1 : Derived1 ->new Derived1() : Derived1 ->Derived1 : typeof Derived1 ->d2 : Derived2 ->new Derived2() : Derived2 ->Derived2 : typeof Derived2 - -var x1: () => Base[] = () => [d1, d2]; ->x1 : () => Base[] ->Base : Base ->() => [d1, d2] : () => (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -var x2: () => Base[] = function() { return [d1, d2] }; ->x2 : () => Base[] ->Base : Base ->function() { return [d1, d2] } : () => (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -var x3: () => Base[] = function named() { return [d1, d2] }; ->x3 : () => Base[] ->Base : Base ->function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] ->named : () => (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -var x4: { (): Base[]; } = () => [d1, d2]; ->x4 : () => Base[] ->Base : Base ->() => [d1, d2] : () => (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -var x5: { (): Base[]; } = function() { return [d1, d2] }; ->x5 : () => Base[] ->Base : Base ->function() { return [d1, d2] } : () => (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -var x6: { (): Base[]; } = function named() { return [d1, d2] }; ->x6 : () => Base[] ->Base : Base ->function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] ->named : () => (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -var x7: Base[] = [d1, d2]; ->x7 : Base[] ->Base : Base ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -var x8: Array = [d1, d2]; ->x8 : Base[] ->Array : T[] ->Base : Base ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -var x9: { [n: number]: Base; } = [d1, d2]; ->x9 : { [n: number]: Base; } ->n : number ->Base : Base ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -var x10: {n: Base[]; } = { n: [d1, d2] }; ->x10 : { n: Base[]; } ->n : Base[] ->Base : Base ->{ n: [d1, d2] } : { n: (Derived1 | Derived2)[]; } ->n : (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -var x11: (s: Base[]) => any = n => { var n: Base[]; return null; }; ->x11 : (s: Base[]) => any ->s : Base[] ->Base : Base ->n => { var n: Base[]; return null; } : (n: Base[]) => any ->n : Base[] ->n : Base[] ->Base : Base ->null : null - -var x12: Genric = { func: n => { return [d1, d2]; } }; ->x12 : Genric ->Genric : Genric ->Base : Base ->{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => (Derived1 | Derived2)[]; } ->func : (n: Base[]) => (Derived1 | Derived2)[] ->n => { return [d1, d2]; } : (n: Base[]) => (Derived1 | Derived2)[] ->n : Base[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -class x13 { member: () => Base[] = () => [d1, d2] } ->x13 : x13 ->member : () => Base[] ->Base : Base ->() => [d1, d2] : () => (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -class x14 { member: () => Base[] = function() { return [d1, d2] } } ->x14 : x14 ->member : () => Base[] ->Base : Base ->function() { return [d1, d2] } : () => (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -class x15 { member: () => Base[] = function named() { return [d1, d2] } } ->x15 : x15 ->member : () => Base[] ->Base : Base ->function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] ->named : () => (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -class x16 { member: { (): Base[]; } = () => [d1, d2] } ->x16 : x16 ->member : () => Base[] ->Base : Base ->() => [d1, d2] : () => (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -class x17 { member: { (): Base[]; } = function() { return [d1, d2] } } ->x17 : x17 ->member : () => Base[] ->Base : Base ->function() { return [d1, d2] } : () => (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -class x18 { member: { (): Base[]; } = function named() { return [d1, d2] } } ->x18 : x18 ->member : () => Base[] ->Base : Base ->function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] ->named : () => (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -class x19 { member: Base[] = [d1, d2] } ->x19 : x19 ->member : Base[] ->Base : Base ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -class x20 { member: Array = [d1, d2] } ->x20 : x20 ->member : Base[] ->Array : T[] ->Base : Base ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -class x21 { member: { [n: number]: Base; } = [d1, d2] } ->x21 : x21 ->member : { [n: number]: Base; } ->n : number ->Base : Base ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -class x22 { member: {n: Base[]; } = { n: [d1, d2] } } ->x22 : x22 ->member : { n: Base[]; } ->n : Base[] ->Base : Base ->{ n: [d1, d2] } : { n: (Derived1 | Derived2)[]; } ->n : (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -class x23 { member: (s: Base[]) => any = n => { var n: Base[]; return null; } } ->x23 : x23 ->member : (s: Base[]) => any ->s : Base[] ->Base : Base ->n => { var n: Base[]; return null; } : (n: Base[]) => any ->n : Base[] ->n : Base[] ->Base : Base ->null : null - -class x24 { member: Genric = { func: n => { return [d1, d2]; } } } ->x24 : x24 ->member : Genric ->Genric : Genric ->Base : Base ->{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => (Derived1 | Derived2)[]; } ->func : (n: Base[]) => (Derived1 | Derived2)[] ->n => { return [d1, d2]; } : (n: Base[]) => (Derived1 | Derived2)[] ->n : Base[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -class x25 { private member: () => Base[] = () => [d1, d2] } ->x25 : x25 ->member : () => Base[] ->Base : Base ->() => [d1, d2] : () => (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -class x26 { private member: () => Base[] = function() { return [d1, d2] } } ->x26 : x26 ->member : () => Base[] ->Base : Base ->function() { return [d1, d2] } : () => (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -class x27 { private member: () => Base[] = function named() { return [d1, d2] } } ->x27 : x27 ->member : () => Base[] ->Base : Base ->function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] ->named : () => (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -class x28 { private member: { (): Base[]; } = () => [d1, d2] } ->x28 : x28 ->member : () => Base[] ->Base : Base ->() => [d1, d2] : () => (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -class x29 { private member: { (): Base[]; } = function() { return [d1, d2] } } ->x29 : x29 ->member : () => Base[] ->Base : Base ->function() { return [d1, d2] } : () => (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -class x30 { private member: { (): Base[]; } = function named() { return [d1, d2] } } ->x30 : x30 ->member : () => Base[] ->Base : Base ->function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] ->named : () => (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -class x31 { private member: Base[] = [d1, d2] } ->x31 : x31 ->member : Base[] ->Base : Base ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -class x32 { private member: Array = [d1, d2] } ->x32 : x32 ->member : Base[] ->Array : T[] ->Base : Base ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -class x33 { private member: { [n: number]: Base; } = [d1, d2] } ->x33 : x33 ->member : { [n: number]: Base; } ->n : number ->Base : Base ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -class x34 { private member: {n: Base[]; } = { n: [d1, d2] } } ->x34 : x34 ->member : { n: Base[]; } ->n : Base[] ->Base : Base ->{ n: [d1, d2] } : { n: (Derived1 | Derived2)[]; } ->n : (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -class x35 { private member: (s: Base[]) => any = n => { var n: Base[]; return null; } } ->x35 : x35 ->member : (s: Base[]) => any ->s : Base[] ->Base : Base ->n => { var n: Base[]; return null; } : (n: Base[]) => any ->n : Base[] ->n : Base[] ->Base : Base ->null : null - -class x36 { private member: Genric = { func: n => { return [d1, d2]; } } } ->x36 : x36 ->member : Genric ->Genric : Genric ->Base : Base ->{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => (Derived1 | Derived2)[]; } ->func : (n: Base[]) => (Derived1 | Derived2)[] ->n => { return [d1, d2]; } : (n: Base[]) => (Derived1 | Derived2)[] ->n : Base[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -class x37 { public member: () => Base[] = () => [d1, d2] } ->x37 : x37 ->member : () => Base[] ->Base : Base ->() => [d1, d2] : () => (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -class x38 { public member: () => Base[] = function() { return [d1, d2] } } ->x38 : x38 ->member : () => Base[] ->Base : Base ->function() { return [d1, d2] } : () => (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -class x39 { public member: () => Base[] = function named() { return [d1, d2] } } ->x39 : x39 ->member : () => Base[] ->Base : Base ->function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] ->named : () => (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -class x40 { public member: { (): Base[]; } = () => [d1, d2] } ->x40 : x40 ->member : () => Base[] ->Base : Base ->() => [d1, d2] : () => (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -class x41 { public member: { (): Base[]; } = function() { return [d1, d2] } } ->x41 : x41 ->member : () => Base[] ->Base : Base ->function() { return [d1, d2] } : () => (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -class x42 { public member: { (): Base[]; } = function named() { return [d1, d2] } } ->x42 : x42 ->member : () => Base[] ->Base : Base ->function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] ->named : () => (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -class x43 { public member: Base[] = [d1, d2] } ->x43 : x43 ->member : Base[] ->Base : Base ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -class x44 { public member: Array = [d1, d2] } ->x44 : x44 ->member : Base[] ->Array : T[] ->Base : Base ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -class x45 { public member: { [n: number]: Base; } = [d1, d2] } ->x45 : x45 ->member : { [n: number]: Base; } ->n : number ->Base : Base ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -class x46 { public member: {n: Base[]; } = { n: [d1, d2] } } ->x46 : x46 ->member : { n: Base[]; } ->n : Base[] ->Base : Base ->{ n: [d1, d2] } : { n: (Derived1 | Derived2)[]; } ->n : (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -class x47 { public member: (s: Base[]) => any = n => { var n: Base[]; return null; } } ->x47 : x47 ->member : (s: Base[]) => any ->s : Base[] ->Base : Base ->n => { var n: Base[]; return null; } : (n: Base[]) => any ->n : Base[] ->n : Base[] ->Base : Base ->null : null - -class x48 { public member: Genric = { func: n => { return [d1, d2]; } } } ->x48 : x48 ->member : Genric ->Genric : Genric ->Base : Base ->{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => (Derived1 | Derived2)[]; } ->func : (n: Base[]) => (Derived1 | Derived2)[] ->n => { return [d1, d2]; } : (n: Base[]) => (Derived1 | Derived2)[] ->n : Base[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -class x49 { static member: () => Base[] = () => [d1, d2] } ->x49 : x49 ->member : () => Base[] ->Base : Base ->() => [d1, d2] : () => (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -class x50 { static member: () => Base[] = function() { return [d1, d2] } } ->x50 : x50 ->member : () => Base[] ->Base : Base ->function() { return [d1, d2] } : () => (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -class x51 { static member: () => Base[] = function named() { return [d1, d2] } } ->x51 : x51 ->member : () => Base[] ->Base : Base ->function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] ->named : () => (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -class x52 { static member: { (): Base[]; } = () => [d1, d2] } ->x52 : x52 ->member : () => Base[] ->Base : Base ->() => [d1, d2] : () => (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -class x53 { static member: { (): Base[]; } = function() { return [d1, d2] } } ->x53 : x53 ->member : () => Base[] ->Base : Base ->function() { return [d1, d2] } : () => (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -class x54 { static member: { (): Base[]; } = function named() { return [d1, d2] } } ->x54 : x54 ->member : () => Base[] ->Base : Base ->function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] ->named : () => (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -class x55 { static member: Base[] = [d1, d2] } ->x55 : x55 ->member : Base[] ->Base : Base ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -class x56 { static member: Array = [d1, d2] } ->x56 : x56 ->member : Base[] ->Array : T[] ->Base : Base ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -class x57 { static member: { [n: number]: Base; } = [d1, d2] } ->x57 : x57 ->member : { [n: number]: Base; } ->n : number ->Base : Base ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -class x58 { static member: {n: Base[]; } = { n: [d1, d2] } } ->x58 : x58 ->member : { n: Base[]; } ->n : Base[] ->Base : Base ->{ n: [d1, d2] } : { n: (Derived1 | Derived2)[]; } ->n : (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -class x59 { static member: (s: Base[]) => any = n => { var n: Base[]; return null; } } ->x59 : x59 ->member : (s: Base[]) => any ->s : Base[] ->Base : Base ->n => { var n: Base[]; return null; } : (n: Base[]) => any ->n : Base[] ->n : Base[] ->Base : Base ->null : null - -class x60 { static member: Genric = { func: n => { return [d1, d2]; } } } ->x60 : x60 ->member : Genric ->Genric : Genric ->Base : Base ->{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => (Derived1 | Derived2)[]; } ->func : (n: Base[]) => (Derived1 | Derived2)[] ->n => { return [d1, d2]; } : (n: Base[]) => (Derived1 | Derived2)[] ->n : Base[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -class x61 { private static member: () => Base[] = () => [d1, d2] } ->x61 : x61 ->member : () => Base[] ->Base : Base ->() => [d1, d2] : () => (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -class x62 { private static member: () => Base[] = function() { return [d1, d2] } } ->x62 : x62 ->member : () => Base[] ->Base : Base ->function() { return [d1, d2] } : () => (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -class x63 { private static member: () => Base[] = function named() { return [d1, d2] } } ->x63 : x63 ->member : () => Base[] ->Base : Base ->function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] ->named : () => (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -class x64 { private static member: { (): Base[]; } = () => [d1, d2] } ->x64 : x64 ->member : () => Base[] ->Base : Base ->() => [d1, d2] : () => (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -class x65 { private static member: { (): Base[]; } = function() { return [d1, d2] } } ->x65 : x65 ->member : () => Base[] ->Base : Base ->function() { return [d1, d2] } : () => (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -class x66 { private static member: { (): Base[]; } = function named() { return [d1, d2] } } ->x66 : x66 ->member : () => Base[] ->Base : Base ->function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] ->named : () => (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -class x67 { private static member: Base[] = [d1, d2] } ->x67 : x67 ->member : Base[] ->Base : Base ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -class x68 { private static member: Array = [d1, d2] } ->x68 : x68 ->member : Base[] ->Array : T[] ->Base : Base ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -class x69 { private static member: { [n: number]: Base; } = [d1, d2] } ->x69 : x69 ->member : { [n: number]: Base; } ->n : number ->Base : Base ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -class x70 { private static member: {n: Base[]; } = { n: [d1, d2] } } ->x70 : x70 ->member : { n: Base[]; } ->n : Base[] ->Base : Base ->{ n: [d1, d2] } : { n: (Derived1 | Derived2)[]; } ->n : (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -class x71 { private static member: (s: Base[]) => any = n => { var n: Base[]; return null; } } ->x71 : x71 ->member : (s: Base[]) => any ->s : Base[] ->Base : Base ->n => { var n: Base[]; return null; } : (n: Base[]) => any ->n : Base[] ->n : Base[] ->Base : Base ->null : null - -class x72 { private static member: Genric = { func: n => { return [d1, d2]; } } } ->x72 : x72 ->member : Genric ->Genric : Genric ->Base : Base ->{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => (Derived1 | Derived2)[]; } ->func : (n: Base[]) => (Derived1 | Derived2)[] ->n => { return [d1, d2]; } : (n: Base[]) => (Derived1 | Derived2)[] ->n : Base[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -class x73 { public static member: () => Base[] = () => [d1, d2] } ->x73 : x73 ->member : () => Base[] ->Base : Base ->() => [d1, d2] : () => (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -class x74 { public static member: () => Base[] = function() { return [d1, d2] } } ->x74 : x74 ->member : () => Base[] ->Base : Base ->function() { return [d1, d2] } : () => (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -class x75 { public static member: () => Base[] = function named() { return [d1, d2] } } ->x75 : x75 ->member : () => Base[] ->Base : Base ->function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] ->named : () => (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -class x76 { public static member: { (): Base[]; } = () => [d1, d2] } ->x76 : x76 ->member : () => Base[] ->Base : Base ->() => [d1, d2] : () => (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -class x77 { public static member: { (): Base[]; } = function() { return [d1, d2] } } ->x77 : x77 ->member : () => Base[] ->Base : Base ->function() { return [d1, d2] } : () => (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -class x78 { public static member: { (): Base[]; } = function named() { return [d1, d2] } } ->x78 : x78 ->member : () => Base[] ->Base : Base ->function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] ->named : () => (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -class x79 { public static member: Base[] = [d1, d2] } ->x79 : x79 ->member : Base[] ->Base : Base ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -class x80 { public static member: Array = [d1, d2] } ->x80 : x80 ->member : Base[] ->Array : T[] ->Base : Base ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -class x81 { public static member: { [n: number]: Base; } = [d1, d2] } ->x81 : x81 ->member : { [n: number]: Base; } ->n : number ->Base : Base ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -class x82 { public static member: {n: Base[]; } = { n: [d1, d2] } } ->x82 : x82 ->member : { n: Base[]; } ->n : Base[] ->Base : Base ->{ n: [d1, d2] } : { n: (Derived1 | Derived2)[]; } ->n : (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -class x83 { public static member: (s: Base[]) => any = n => { var n: Base[]; return null; } } ->x83 : x83 ->member : (s: Base[]) => any ->s : Base[] ->Base : Base ->n => { var n: Base[]; return null; } : (n: Base[]) => any ->n : Base[] ->n : Base[] ->Base : Base ->null : null - -class x84 { public static member: Genric = { func: n => { return [d1, d2]; } } } ->x84 : x84 ->member : Genric ->Genric : Genric ->Base : Base ->{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => (Derived1 | Derived2)[]; } ->func : (n: Base[]) => (Derived1 | Derived2)[] ->n => { return [d1, d2]; } : (n: Base[]) => (Derived1 | Derived2)[] ->n : Base[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -class x85 { constructor(parm: () => Base[] = () => [d1, d2]) { } } ->x85 : x85 ->parm : () => Base[] ->Base : Base ->() => [d1, d2] : () => (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -class x86 { constructor(parm: () => Base[] = function() { return [d1, d2] }) { } } ->x86 : x86 ->parm : () => Base[] ->Base : Base ->function() { return [d1, d2] } : () => (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -class x87 { constructor(parm: () => Base[] = function named() { return [d1, d2] }) { } } ->x87 : x87 ->parm : () => Base[] ->Base : Base ->function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] ->named : () => (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -class x88 { constructor(parm: { (): Base[]; } = () => [d1, d2]) { } } ->x88 : x88 ->parm : () => Base[] ->Base : Base ->() => [d1, d2] : () => (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -class x89 { constructor(parm: { (): Base[]; } = function() { return [d1, d2] }) { } } ->x89 : x89 ->parm : () => Base[] ->Base : Base ->function() { return [d1, d2] } : () => (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -class x90 { constructor(parm: { (): Base[]; } = function named() { return [d1, d2] }) { } } ->x90 : x90 ->parm : () => Base[] ->Base : Base ->function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] ->named : () => (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -class x91 { constructor(parm: Base[] = [d1, d2]) { } } ->x91 : x91 ->parm : Base[] ->Base : Base ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -class x92 { constructor(parm: Array = [d1, d2]) { } } ->x92 : x92 ->parm : Base[] ->Array : T[] ->Base : Base ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -class x93 { constructor(parm: { [n: number]: Base; } = [d1, d2]) { } } ->x93 : x93 ->parm : { [n: number]: Base; } ->n : number ->Base : Base ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -class x94 { constructor(parm: {n: Base[]; } = { n: [d1, d2] }) { } } ->x94 : x94 ->parm : { n: Base[]; } ->n : Base[] ->Base : Base ->{ n: [d1, d2] } : { n: (Derived1 | Derived2)[]; } ->n : (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -class x95 { constructor(parm: (s: Base[]) => any = n => { var n: Base[]; return null; }) { } } ->x95 : x95 ->parm : (s: Base[]) => any ->s : Base[] ->Base : Base ->n => { var n: Base[]; return null; } : (n: Base[]) => any ->n : Base[] ->n : Base[] ->Base : Base ->null : null - -class x96 { constructor(parm: Genric = { func: n => { return [d1, d2]; } }) { } } ->x96 : x96 ->parm : Genric ->Genric : Genric ->Base : Base ->{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => (Derived1 | Derived2)[]; } ->func : (n: Base[]) => (Derived1 | Derived2)[] ->n => { return [d1, d2]; } : (n: Base[]) => (Derived1 | Derived2)[] ->n : Base[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -class x97 { constructor(public parm: () => Base[] = () => [d1, d2]) { } } ->x97 : x97 ->parm : () => Base[] ->Base : Base ->() => [d1, d2] : () => (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -class x98 { constructor(public parm: () => Base[] = function() { return [d1, d2] }) { } } ->x98 : x98 ->parm : () => Base[] ->Base : Base ->function() { return [d1, d2] } : () => (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -class x99 { constructor(public parm: () => Base[] = function named() { return [d1, d2] }) { } } ->x99 : x99 ->parm : () => Base[] ->Base : Base ->function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] ->named : () => (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -class x100 { constructor(public parm: { (): Base[]; } = () => [d1, d2]) { } } ->x100 : x100 ->parm : () => Base[] ->Base : Base ->() => [d1, d2] : () => (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -class x101 { constructor(public parm: { (): Base[]; } = function() { return [d1, d2] }) { } } ->x101 : x101 ->parm : () => Base[] ->Base : Base ->function() { return [d1, d2] } : () => (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -class x102 { constructor(public parm: { (): Base[]; } = function named() { return [d1, d2] }) { } } ->x102 : x102 ->parm : () => Base[] ->Base : Base ->function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] ->named : () => (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -class x103 { constructor(public parm: Base[] = [d1, d2]) { } } ->x103 : x103 ->parm : Base[] ->Base : Base ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -class x104 { constructor(public parm: Array = [d1, d2]) { } } ->x104 : x104 ->parm : Base[] ->Array : T[] ->Base : Base ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -class x105 { constructor(public parm: { [n: number]: Base; } = [d1, d2]) { } } ->x105 : x105 ->parm : { [n: number]: Base; } ->n : number ->Base : Base ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -class x106 { constructor(public parm: {n: Base[]; } = { n: [d1, d2] }) { } } ->x106 : x106 ->parm : { n: Base[]; } ->n : Base[] ->Base : Base ->{ n: [d1, d2] } : { n: (Derived1 | Derived2)[]; } ->n : (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -class x107 { constructor(public parm: (s: Base[]) => any = n => { var n: Base[]; return null; }) { } } ->x107 : x107 ->parm : (s: Base[]) => any ->s : Base[] ->Base : Base ->n => { var n: Base[]; return null; } : (n: Base[]) => any ->n : Base[] ->n : Base[] ->Base : Base ->null : null - -class x108 { constructor(public parm: Genric = { func: n => { return [d1, d2]; } }) { } } ->x108 : x108 ->parm : Genric ->Genric : Genric ->Base : Base ->{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => (Derived1 | Derived2)[]; } ->func : (n: Base[]) => (Derived1 | Derived2)[] ->n => { return [d1, d2]; } : (n: Base[]) => (Derived1 | Derived2)[] ->n : Base[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -class x109 { constructor(private parm: () => Base[] = () => [d1, d2]) { } } ->x109 : x109 ->parm : () => Base[] ->Base : Base ->() => [d1, d2] : () => (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -class x110 { constructor(private parm: () => Base[] = function() { return [d1, d2] }) { } } ->x110 : x110 ->parm : () => Base[] ->Base : Base ->function() { return [d1, d2] } : () => (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -class x111 { constructor(private parm: () => Base[] = function named() { return [d1, d2] }) { } } ->x111 : x111 ->parm : () => Base[] ->Base : Base ->function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] ->named : () => (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -class x112 { constructor(private parm: { (): Base[]; } = () => [d1, d2]) { } } ->x112 : x112 ->parm : () => Base[] ->Base : Base ->() => [d1, d2] : () => (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -class x113 { constructor(private parm: { (): Base[]; } = function() { return [d1, d2] }) { } } ->x113 : x113 ->parm : () => Base[] ->Base : Base ->function() { return [d1, d2] } : () => (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -class x114 { constructor(private parm: { (): Base[]; } = function named() { return [d1, d2] }) { } } ->x114 : x114 ->parm : () => Base[] ->Base : Base ->function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] ->named : () => (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -class x115 { constructor(private parm: Base[] = [d1, d2]) { } } ->x115 : x115 ->parm : Base[] ->Base : Base ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -class x116 { constructor(private parm: Array = [d1, d2]) { } } ->x116 : x116 ->parm : Base[] ->Array : T[] ->Base : Base ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -class x117 { constructor(private parm: { [n: number]: Base; } = [d1, d2]) { } } ->x117 : x117 ->parm : { [n: number]: Base; } ->n : number ->Base : Base ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -class x118 { constructor(private parm: {n: Base[]; } = { n: [d1, d2] }) { } } ->x118 : x118 ->parm : { n: Base[]; } ->n : Base[] ->Base : Base ->{ n: [d1, d2] } : { n: (Derived1 | Derived2)[]; } ->n : (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -class x119 { constructor(private parm: (s: Base[]) => any = n => { var n: Base[]; return null; }) { } } ->x119 : x119 ->parm : (s: Base[]) => any ->s : Base[] ->Base : Base ->n => { var n: Base[]; return null; } : (n: Base[]) => any ->n : Base[] ->n : Base[] ->Base : Base ->null : null - -class x120 { constructor(private parm: Genric = { func: n => { return [d1, d2]; } }) { } } ->x120 : x120 ->parm : Genric ->Genric : Genric ->Base : Base ->{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => (Derived1 | Derived2)[]; } ->func : (n: Base[]) => (Derived1 | Derived2)[] ->n => { return [d1, d2]; } : (n: Base[]) => (Derived1 | Derived2)[] ->n : Base[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -function x121(parm: () => Base[] = () => [d1, d2]) { } ->x121 : (parm?: () => Base[]) => void ->parm : () => Base[] ->Base : Base ->() => [d1, d2] : () => (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -function x122(parm: () => Base[] = function() { return [d1, d2] }) { } ->x122 : (parm?: () => Base[]) => void ->parm : () => Base[] ->Base : Base ->function() { return [d1, d2] } : () => (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -function x123(parm: () => Base[] = function named() { return [d1, d2] }) { } ->x123 : (parm?: () => Base[]) => void ->parm : () => Base[] ->Base : Base ->function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] ->named : () => (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -function x124(parm: { (): Base[]; } = () => [d1, d2]) { } ->x124 : (parm?: () => Base[]) => void ->parm : () => Base[] ->Base : Base ->() => [d1, d2] : () => (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -function x125(parm: { (): Base[]; } = function() { return [d1, d2] }) { } ->x125 : (parm?: () => Base[]) => void ->parm : () => Base[] ->Base : Base ->function() { return [d1, d2] } : () => (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -function x126(parm: { (): Base[]; } = function named() { return [d1, d2] }) { } ->x126 : (parm?: () => Base[]) => void ->parm : () => Base[] ->Base : Base ->function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] ->named : () => (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -function x127(parm: Base[] = [d1, d2]) { } ->x127 : (parm?: Base[]) => void ->parm : Base[] ->Base : Base ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -function x128(parm: Array = [d1, d2]) { } ->x128 : (parm?: Base[]) => void ->parm : Base[] ->Array : T[] ->Base : Base ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -function x129(parm: { [n: number]: Base; } = [d1, d2]) { } ->x129 : (parm?: { [n: number]: Base; }) => void ->parm : { [n: number]: Base; } ->n : number ->Base : Base ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -function x130(parm: {n: Base[]; } = { n: [d1, d2] }) { } ->x130 : (parm?: { n: Base[]; }) => void ->parm : { n: Base[]; } ->n : Base[] ->Base : Base ->{ n: [d1, d2] } : { n: (Derived1 | Derived2)[]; } ->n : (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -function x131(parm: (s: Base[]) => any = n => { var n: Base[]; return null; }) { } ->x131 : (parm?: (s: Base[]) => any) => void ->parm : (s: Base[]) => any ->s : Base[] ->Base : Base ->n => { var n: Base[]; return null; } : (n: Base[]) => any ->n : Base[] ->n : Base[] ->Base : Base ->null : null - -function x132(parm: Genric = { func: n => { return [d1, d2]; } }) { } ->x132 : (parm?: Genric) => void ->parm : Genric ->Genric : Genric ->Base : Base ->{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => (Derived1 | Derived2)[]; } ->func : (n: Base[]) => (Derived1 | Derived2)[] ->n => { return [d1, d2]; } : (n: Base[]) => (Derived1 | Derived2)[] ->n : Base[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -function x133(): () => Base[] { return () => [d1, d2]; } ->x133 : () => () => Base[] ->Base : Base ->() => [d1, d2] : () => (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -function x134(): () => Base[] { return function() { return [d1, d2] }; } ->x134 : () => () => Base[] ->Base : Base ->function() { return [d1, d2] } : () => (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -function x135(): () => Base[] { return function named() { return [d1, d2] }; } ->x135 : () => () => Base[] ->Base : Base ->function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] ->named : () => (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -function x136(): { (): Base[]; } { return () => [d1, d2]; } ->x136 : () => () => Base[] ->Base : Base ->() => [d1, d2] : () => (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -function x137(): { (): Base[]; } { return function() { return [d1, d2] }; } ->x137 : () => () => Base[] ->Base : Base ->function() { return [d1, d2] } : () => (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -function x138(): { (): Base[]; } { return function named() { return [d1, d2] }; } ->x138 : () => () => Base[] ->Base : Base ->function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] ->named : () => (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -function x139(): Base[] { return [d1, d2]; } ->x139 : () => Base[] ->Base : Base ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -function x140(): Array { return [d1, d2]; } ->x140 : () => Base[] ->Array : T[] ->Base : Base ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -function x141(): { [n: number]: Base; } { return [d1, d2]; } ->x141 : () => { [n: number]: Base; } ->n : number ->Base : Base ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -function x142(): {n: Base[]; } { return { n: [d1, d2] }; } ->x142 : () => { n: Base[]; } ->n : Base[] ->Base : Base ->{ n: [d1, d2] } : { n: (Derived1 | Derived2)[]; } ->n : (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -function x143(): (s: Base[]) => any { return n => { var n: Base[]; return null; }; } ->x143 : () => (s: Base[]) => any ->s : Base[] ->Base : Base ->n => { var n: Base[]; return null; } : (n: Base[]) => any ->n : Base[] ->n : Base[] ->Base : Base ->null : null - -function x144(): Genric { return { func: n => { return [d1, d2]; } }; } ->x144 : () => Genric ->Genric : Genric ->Base : Base ->{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => (Derived1 | Derived2)[]; } ->func : (n: Base[]) => (Derived1 | Derived2)[] ->n => { return [d1, d2]; } : (n: Base[]) => (Derived1 | Derived2)[] ->n : Base[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -function x145(): () => Base[] { return () => [d1, d2]; return () => [d1, d2]; } ->x145 : () => () => Base[] ->Base : Base ->() => [d1, d2] : () => (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 ->() => [d1, d2] : () => (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -function x146(): () => Base[] { return function() { return [d1, d2] }; return function() { return [d1, d2] }; } ->x146 : () => () => Base[] ->Base : Base ->function() { return [d1, d2] } : () => (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 ->function() { return [d1, d2] } : () => (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -function x147(): () => Base[] { return function named() { return [d1, d2] }; return function named() { return [d1, d2] }; } ->x147 : () => () => Base[] ->Base : Base ->function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] ->named : () => (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 ->function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] ->named : () => (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -function x148(): { (): Base[]; } { return () => [d1, d2]; return () => [d1, d2]; } ->x148 : () => () => Base[] ->Base : Base ->() => [d1, d2] : () => (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 ->() => [d1, d2] : () => (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -function x149(): { (): Base[]; } { return function() { return [d1, d2] }; return function() { return [d1, d2] }; } ->x149 : () => () => Base[] ->Base : Base ->function() { return [d1, d2] } : () => (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 ->function() { return [d1, d2] } : () => (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -function x150(): { (): Base[]; } { return function named() { return [d1, d2] }; return function named() { return [d1, d2] }; } ->x150 : () => () => Base[] ->Base : Base ->function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] ->named : () => (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 ->function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] ->named : () => (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -function x151(): Base[] { return [d1, d2]; return [d1, d2]; } ->x151 : () => Base[] ->Base : Base ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -function x152(): Array { return [d1, d2]; return [d1, d2]; } ->x152 : () => Base[] ->Array : T[] ->Base : Base ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -function x153(): { [n: number]: Base; } { return [d1, d2]; return [d1, d2]; } ->x153 : () => { [n: number]: Base; } ->n : number ->Base : Base ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -function x154(): {n: Base[]; } { return { n: [d1, d2] }; return { n: [d1, d2] }; } ->x154 : () => { n: Base[]; } ->n : Base[] ->Base : Base ->{ n: [d1, d2] } : { n: (Derived1 | Derived2)[]; } ->n : (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 ->{ n: [d1, d2] } : { n: (Derived1 | Derived2)[]; } ->n : (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -function x155(): (s: Base[]) => any { return n => { var n: Base[]; return null; }; return n => { var n: Base[]; return null; }; } ->x155 : () => (s: Base[]) => any ->s : Base[] ->Base : Base ->n => { var n: Base[]; return null; } : (n: Base[]) => any ->n : Base[] ->n : Base[] ->Base : Base ->null : null ->n => { var n: Base[]; return null; } : (n: Base[]) => any ->n : Base[] ->n : Base[] ->Base : Base ->null : null - -function x156(): Genric { return { func: n => { return [d1, d2]; } }; return { func: n => { return [d1, d2]; } }; } ->x156 : () => Genric ->Genric : Genric ->Base : Base ->{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => (Derived1 | Derived2)[]; } ->func : (n: Base[]) => (Derived1 | Derived2)[] ->n => { return [d1, d2]; } : (n: Base[]) => (Derived1 | Derived2)[] ->n : Base[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 ->{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => (Derived1 | Derived2)[]; } ->func : (n: Base[]) => (Derived1 | Derived2)[] ->n => { return [d1, d2]; } : (n: Base[]) => (Derived1 | Derived2)[] ->n : Base[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -var x157: () => () => Base[] = () => { return () => [d1, d2]; }; ->x157 : () => () => Base[] ->Base : Base ->() => { return () => [d1, d2]; } : () => () => (Derived1 | Derived2)[] ->() => [d1, d2] : () => (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -var x158: () => () => Base[] = () => { return function() { return [d1, d2] }; }; ->x158 : () => () => Base[] ->Base : Base ->() => { return function() { return [d1, d2] }; } : () => () => (Derived1 | Derived2)[] ->function() { return [d1, d2] } : () => (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -var x159: () => () => Base[] = () => { return function named() { return [d1, d2] }; }; ->x159 : () => () => Base[] ->Base : Base ->() => { return function named() { return [d1, d2] }; } : () => () => (Derived1 | Derived2)[] ->function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] ->named : () => (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -var x160: () => { (): Base[]; } = () => { return () => [d1, d2]; }; ->x160 : () => () => Base[] ->Base : Base ->() => { return () => [d1, d2]; } : () => () => (Derived1 | Derived2)[] ->() => [d1, d2] : () => (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -var x161: () => { (): Base[]; } = () => { return function() { return [d1, d2] }; }; ->x161 : () => () => Base[] ->Base : Base ->() => { return function() { return [d1, d2] }; } : () => () => (Derived1 | Derived2)[] ->function() { return [d1, d2] } : () => (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -var x162: () => { (): Base[]; } = () => { return function named() { return [d1, d2] }; }; ->x162 : () => () => Base[] ->Base : Base ->() => { return function named() { return [d1, d2] }; } : () => () => (Derived1 | Derived2)[] ->function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] ->named : () => (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -var x163: () => Base[] = () => { return [d1, d2]; }; ->x163 : () => Base[] ->Base : Base ->() => { return [d1, d2]; } : () => (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -var x164: () => Array = () => { return [d1, d2]; }; ->x164 : () => Base[] ->Array : T[] ->Base : Base ->() => { return [d1, d2]; } : () => (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -var x165: () => { [n: number]: Base; } = () => { return [d1, d2]; }; ->x165 : () => { [n: number]: Base; } ->n : number ->Base : Base ->() => { return [d1, d2]; } : () => (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -var x166: () => {n: Base[]; } = () => { return { n: [d1, d2] }; }; ->x166 : () => { n: Base[]; } ->n : Base[] ->Base : Base ->() => { return { n: [d1, d2] }; } : () => { n: (Derived1 | Derived2)[]; } ->{ n: [d1, d2] } : { n: (Derived1 | Derived2)[]; } ->n : (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -var x167: () => (s: Base[]) => any = () => { return n => { var n: Base[]; return null; }; }; ->x167 : () => (s: Base[]) => any ->s : Base[] ->Base : Base ->() => { return n => { var n: Base[]; return null; }; } : () => (n: Base[]) => any ->n => { var n: Base[]; return null; } : (n: Base[]) => any ->n : Base[] ->n : Base[] ->Base : Base ->null : null - -var x168: () => Genric = () => { return { func: n => { return [d1, d2]; } }; }; ->x168 : () => Genric ->Genric : Genric ->Base : Base ->() => { return { func: n => { return [d1, d2]; } }; } : () => { func: (n: Base[]) => (Derived1 | Derived2)[]; } ->{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => (Derived1 | Derived2)[]; } ->func : (n: Base[]) => (Derived1 | Derived2)[] ->n => { return [d1, d2]; } : (n: Base[]) => (Derived1 | Derived2)[] ->n : Base[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -var x169: () => () => Base[] = function() { return () => [d1, d2]; }; ->x169 : () => () => Base[] ->Base : Base ->function() { return () => [d1, d2]; } : () => () => (Derived1 | Derived2)[] ->() => [d1, d2] : () => (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -var x170: () => () => Base[] = function() { return function() { return [d1, d2] }; }; ->x170 : () => () => Base[] ->Base : Base ->function() { return function() { return [d1, d2] }; } : () => () => (Derived1 | Derived2)[] ->function() { return [d1, d2] } : () => (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -var x171: () => () => Base[] = function() { return function named() { return [d1, d2] }; }; ->x171 : () => () => Base[] ->Base : Base ->function() { return function named() { return [d1, d2] }; } : () => () => (Derived1 | Derived2)[] ->function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] ->named : () => (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -var x172: () => { (): Base[]; } = function() { return () => [d1, d2]; }; ->x172 : () => () => Base[] ->Base : Base ->function() { return () => [d1, d2]; } : () => () => (Derived1 | Derived2)[] ->() => [d1, d2] : () => (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -var x173: () => { (): Base[]; } = function() { return function() { return [d1, d2] }; }; ->x173 : () => () => Base[] ->Base : Base ->function() { return function() { return [d1, d2] }; } : () => () => (Derived1 | Derived2)[] ->function() { return [d1, d2] } : () => (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -var x174: () => { (): Base[]; } = function() { return function named() { return [d1, d2] }; }; ->x174 : () => () => Base[] ->Base : Base ->function() { return function named() { return [d1, d2] }; } : () => () => (Derived1 | Derived2)[] ->function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] ->named : () => (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -var x175: () => Base[] = function() { return [d1, d2]; }; ->x175 : () => Base[] ->Base : Base ->function() { return [d1, d2]; } : () => (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -var x176: () => Array = function() { return [d1, d2]; }; ->x176 : () => Base[] ->Array : T[] ->Base : Base ->function() { return [d1, d2]; } : () => (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -var x177: () => { [n: number]: Base; } = function() { return [d1, d2]; }; ->x177 : () => { [n: number]: Base; } ->n : number ->Base : Base ->function() { return [d1, d2]; } : () => (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -var x178: () => {n: Base[]; } = function() { return { n: [d1, d2] }; }; ->x178 : () => { n: Base[]; } ->n : Base[] ->Base : Base ->function() { return { n: [d1, d2] }; } : () => { n: (Derived1 | Derived2)[]; } ->{ n: [d1, d2] } : { n: (Derived1 | Derived2)[]; } ->n : (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -var x179: () => (s: Base[]) => any = function() { return n => { var n: Base[]; return null; }; }; ->x179 : () => (s: Base[]) => any ->s : Base[] ->Base : Base ->function() { return n => { var n: Base[]; return null; }; } : () => (n: Base[]) => any ->n => { var n: Base[]; return null; } : (n: Base[]) => any ->n : Base[] ->n : Base[] ->Base : Base ->null : null - -var x180: () => Genric = function() { return { func: n => { return [d1, d2]; } }; }; ->x180 : () => Genric ->Genric : Genric ->Base : Base ->function() { return { func: n => { return [d1, d2]; } }; } : () => { func: (n: Base[]) => (Derived1 | Derived2)[]; } ->{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => (Derived1 | Derived2)[]; } ->func : (n: Base[]) => (Derived1 | Derived2)[] ->n => { return [d1, d2]; } : (n: Base[]) => (Derived1 | Derived2)[] ->n : Base[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -module x181 { var t: () => Base[] = () => [d1, d2]; } ->x181 : typeof x181 ->t : () => Base[] ->Base : Base ->() => [d1, d2] : () => (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -module x182 { var t: () => Base[] = function() { return [d1, d2] }; } ->x182 : typeof x182 ->t : () => Base[] ->Base : Base ->function() { return [d1, d2] } : () => (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -module x183 { var t: () => Base[] = function named() { return [d1, d2] }; } ->x183 : typeof x183 ->t : () => Base[] ->Base : Base ->function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] ->named : () => (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -module x184 { var t: { (): Base[]; } = () => [d1, d2]; } ->x184 : typeof x184 ->t : () => Base[] ->Base : Base ->() => [d1, d2] : () => (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -module x185 { var t: { (): Base[]; } = function() { return [d1, d2] }; } ->x185 : typeof x185 ->t : () => Base[] ->Base : Base ->function() { return [d1, d2] } : () => (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -module x186 { var t: { (): Base[]; } = function named() { return [d1, d2] }; } ->x186 : typeof x186 ->t : () => Base[] ->Base : Base ->function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] ->named : () => (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -module x187 { var t: Base[] = [d1, d2]; } ->x187 : typeof x187 ->t : Base[] ->Base : Base ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -module x188 { var t: Array = [d1, d2]; } ->x188 : typeof x188 ->t : Base[] ->Array : T[] ->Base : Base ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -module x189 { var t: { [n: number]: Base; } = [d1, d2]; } ->x189 : typeof x189 ->t : { [n: number]: Base; } ->n : number ->Base : Base ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -module x190 { var t: {n: Base[]; } = { n: [d1, d2] }; } ->x190 : typeof x190 ->t : { n: Base[]; } ->n : Base[] ->Base : Base ->{ n: [d1, d2] } : { n: (Derived1 | Derived2)[]; } ->n : (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -module x191 { var t: (s: Base[]) => any = n => { var n: Base[]; return null; }; } ->x191 : typeof x191 ->t : (s: Base[]) => any ->s : Base[] ->Base : Base ->n => { var n: Base[]; return null; } : (n: Base[]) => any ->n : Base[] ->n : Base[] ->Base : Base ->null : null - -module x192 { var t: Genric = { func: n => { return [d1, d2]; } }; } ->x192 : typeof x192 ->t : Genric ->Genric : Genric ->Base : Base ->{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => (Derived1 | Derived2)[]; } ->func : (n: Base[]) => (Derived1 | Derived2)[] ->n => { return [d1, d2]; } : (n: Base[]) => (Derived1 | Derived2)[] ->n : Base[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -module x193 { export var t: () => Base[] = () => [d1, d2]; } ->x193 : typeof x193 ->t : () => Base[] ->Base : Base ->() => [d1, d2] : () => (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -module x194 { export var t: () => Base[] = function() { return [d1, d2] }; } ->x194 : typeof x194 ->t : () => Base[] ->Base : Base ->function() { return [d1, d2] } : () => (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -module x195 { export var t: () => Base[] = function named() { return [d1, d2] }; } ->x195 : typeof x195 ->t : () => Base[] ->Base : Base ->function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] ->named : () => (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -module x196 { export var t: { (): Base[]; } = () => [d1, d2]; } ->x196 : typeof x196 ->t : () => Base[] ->Base : Base ->() => [d1, d2] : () => (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -module x197 { export var t: { (): Base[]; } = function() { return [d1, d2] }; } ->x197 : typeof x197 ->t : () => Base[] ->Base : Base ->function() { return [d1, d2] } : () => (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -module x198 { export var t: { (): Base[]; } = function named() { return [d1, d2] }; } ->x198 : typeof x198 ->t : () => Base[] ->Base : Base ->function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] ->named : () => (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -module x199 { export var t: Base[] = [d1, d2]; } ->x199 : typeof x199 ->t : Base[] ->Base : Base ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -module x200 { export var t: Array = [d1, d2]; } ->x200 : typeof x200 ->t : Base[] ->Array : T[] ->Base : Base ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -module x201 { export var t: { [n: number]: Base; } = [d1, d2]; } ->x201 : typeof x201 ->t : { [n: number]: Base; } ->n : number ->Base : Base ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -module x202 { export var t: {n: Base[]; } = { n: [d1, d2] }; } ->x202 : typeof x202 ->t : { n: Base[]; } ->n : Base[] ->Base : Base ->{ n: [d1, d2] } : { n: (Derived1 | Derived2)[]; } ->n : (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -module x203 { export var t: (s: Base[]) => any = n => { var n: Base[]; return null; }; } ->x203 : typeof x203 ->t : (s: Base[]) => any ->s : Base[] ->Base : Base ->n => { var n: Base[]; return null; } : (n: Base[]) => any ->n : Base[] ->n : Base[] ->Base : Base ->null : null - -module x204 { export var t: Genric = { func: n => { return [d1, d2]; } }; } ->x204 : typeof x204 ->t : Genric ->Genric : Genric ->Base : Base ->{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => (Derived1 | Derived2)[]; } ->func : (n: Base[]) => (Derived1 | Derived2)[] ->n => { return [d1, d2]; } : (n: Base[]) => (Derived1 | Derived2)[] ->n : Base[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -var x206 = <() => Base[]>function() { return [d1, d2] }; ->x206 : () => Base[] -><() => Base[]>function() { return [d1, d2] } : () => Base[] ->Base : Base ->function() { return [d1, d2] } : () => (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -var x207 = <() => Base[]>function named() { return [d1, d2] }; ->x207 : () => Base[] -><() => Base[]>function named() { return [d1, d2] } : () => Base[] ->Base : Base ->function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] ->named : () => (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -var x209 = <{ (): Base[]; }>function() { return [d1, d2] }; ->x209 : () => Base[] -><{ (): Base[]; }>function() { return [d1, d2] } : () => Base[] ->Base : Base ->function() { return [d1, d2] } : () => (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -var x210 = <{ (): Base[]; }>function named() { return [d1, d2] }; ->x210 : () => Base[] -><{ (): Base[]; }>function named() { return [d1, d2] } : () => Base[] ->Base : Base ->function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] ->named : () => (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -var x211 = [d1, d2]; ->x211 : Base[] ->[d1, d2] : Base[] ->Base : Base ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -var x212 = >[d1, d2]; ->x212 : Base[] ->>[d1, d2] : Base[] ->Array : T[] ->Base : Base ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -var x213 = <{ [n: number]: Base; }>[d1, d2]; ->x213 : { [n: number]: Base; } -><{ [n: number]: Base; }>[d1, d2] : { [n: number]: Base; } ->n : number ->Base : Base ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -var x214 = <{n: Base[]; } >{ n: [d1, d2] }; ->x214 : { n: Base[]; } -><{n: Base[]; } >{ n: [d1, d2] } : { n: Base[]; } ->n : Base[] ->Base : Base ->{ n: [d1, d2] } : { n: (Derived1 | Derived2)[]; } ->n : (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -var x216 = >{ func: n => { return [d1, d2]; } }; ->x216 : Genric ->>{ func: n => { return [d1, d2]; } } : Genric ->Genric : Genric ->Base : Base ->{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => (Derived1 | Derived2)[]; } ->func : (n: Base[]) => (Derived1 | Derived2)[] ->n => { return [d1, d2]; } : (n: Base[]) => (Derived1 | Derived2)[] ->n : Base[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -var x217 = (<() => Base[]>undefined) || function() { return [d1, d2] }; ->x217 : () => Base[] ->(<() => Base[]>undefined) || function() { return [d1, d2] } : () => Base[] ->(<() => Base[]>undefined) : () => Base[] -><() => Base[]>undefined : () => Base[] ->Base : Base ->undefined : undefined ->function() { return [d1, d2] } : () => (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -var x218 = (<() => Base[]>undefined) || function named() { return [d1, d2] }; ->x218 : () => Base[] ->(<() => Base[]>undefined) || function named() { return [d1, d2] } : () => Base[] ->(<() => Base[]>undefined) : () => Base[] -><() => Base[]>undefined : () => Base[] ->Base : Base ->undefined : undefined ->function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] ->named : () => (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -var x219 = (<{ (): Base[]; }>undefined) || function() { return [d1, d2] }; ->x219 : () => Base[] ->(<{ (): Base[]; }>undefined) || function() { return [d1, d2] } : () => Base[] ->(<{ (): Base[]; }>undefined) : () => Base[] -><{ (): Base[]; }>undefined : () => Base[] ->Base : Base ->undefined : undefined ->function() { return [d1, d2] } : () => (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -var x220 = (<{ (): Base[]; }>undefined) || function named() { return [d1, d2] }; ->x220 : () => Base[] ->(<{ (): Base[]; }>undefined) || function named() { return [d1, d2] } : () => Base[] ->(<{ (): Base[]; }>undefined) : () => Base[] -><{ (): Base[]; }>undefined : () => Base[] ->Base : Base ->undefined : undefined ->function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] ->named : () => (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -var x221 = (undefined) || [d1, d2]; ->x221 : Base[] ->(undefined) || [d1, d2] : Base[] ->(undefined) : Base[] ->undefined : Base[] ->Base : Base ->undefined : undefined ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -var x222 = (>undefined) || [d1, d2]; ->x222 : Base[] ->(>undefined) || [d1, d2] : Base[] ->(>undefined) : Base[] ->>undefined : Base[] ->Array : T[] ->Base : Base ->undefined : undefined ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -var x223 = (<{ [n: number]: Base; }>undefined) || [d1, d2]; ->x223 : { [n: number]: Base; } ->(<{ [n: number]: Base; }>undefined) || [d1, d2] : { [n: number]: Base; } ->(<{ [n: number]: Base; }>undefined) : { [n: number]: Base; } -><{ [n: number]: Base; }>undefined : { [n: number]: Base; } ->n : number ->Base : Base ->undefined : undefined ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -var x224 = (<{n: Base[]; } >undefined) || { n: [d1, d2] }; ->x224 : { n: Base[]; } ->(<{n: Base[]; } >undefined) || { n: [d1, d2] } : { n: Base[]; } ->(<{n: Base[]; } >undefined) : { n: Base[]; } -><{n: Base[]; } >undefined : { n: Base[]; } ->n : Base[] ->Base : Base ->undefined : undefined ->{ n: [d1, d2] } : { n: (Derived1 | Derived2)[]; } ->n : (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -var x225: () => Base[]; x225 = () => [d1, d2]; ->x225 : () => Base[] ->Base : Base ->x225 = () => [d1, d2] : () => (Derived1 | Derived2)[] ->x225 : () => Base[] ->() => [d1, d2] : () => (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -var x226: () => Base[]; x226 = function() { return [d1, d2] }; ->x226 : () => Base[] ->Base : Base ->x226 = function() { return [d1, d2] } : () => (Derived1 | Derived2)[] ->x226 : () => Base[] ->function() { return [d1, d2] } : () => (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -var x227: () => Base[]; x227 = function named() { return [d1, d2] }; ->x227 : () => Base[] ->Base : Base ->x227 = function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] ->x227 : () => Base[] ->function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] ->named : () => (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -var x228: { (): Base[]; }; x228 = () => [d1, d2]; ->x228 : () => Base[] ->Base : Base ->x228 = () => [d1, d2] : () => (Derived1 | Derived2)[] ->x228 : () => Base[] ->() => [d1, d2] : () => (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -var x229: { (): Base[]; }; x229 = function() { return [d1, d2] }; ->x229 : () => Base[] ->Base : Base ->x229 = function() { return [d1, d2] } : () => (Derived1 | Derived2)[] ->x229 : () => Base[] ->function() { return [d1, d2] } : () => (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -var x230: { (): Base[]; }; x230 = function named() { return [d1, d2] }; ->x230 : () => Base[] ->Base : Base ->x230 = function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] ->x230 : () => Base[] ->function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] ->named : () => (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -var x231: Base[]; x231 = [d1, d2]; ->x231 : Base[] ->Base : Base ->x231 = [d1, d2] : (Derived1 | Derived2)[] ->x231 : Base[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -var x232: Array; x232 = [d1, d2]; ->x232 : Base[] ->Array : T[] ->Base : Base ->x232 = [d1, d2] : (Derived1 | Derived2)[] ->x232 : Base[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -var x233: { [n: number]: Base; }; x233 = [d1, d2]; ->x233 : { [n: number]: Base; } ->n : number ->Base : Base ->x233 = [d1, d2] : (Derived1 | Derived2)[] ->x233 : { [n: number]: Base; } ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -var x234: {n: Base[]; } ; x234 = { n: [d1, d2] }; ->x234 : { n: Base[]; } ->n : Base[] ->Base : Base ->x234 = { n: [d1, d2] } : { n: (Derived1 | Derived2)[]; } ->x234 : { n: Base[]; } ->{ n: [d1, d2] } : { n: (Derived1 | Derived2)[]; } ->n : (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -var x235: (s: Base[]) => any; x235 = n => { var n: Base[]; return null; }; ->x235 : (s: Base[]) => any ->s : Base[] ->Base : Base ->x235 = n => { var n: Base[]; return null; } : (n: Base[]) => any ->x235 : (s: Base[]) => any ->n => { var n: Base[]; return null; } : (n: Base[]) => any ->n : Base[] ->n : Base[] ->Base : Base ->null : null - -var x236: Genric; x236 = { func: n => { return [d1, d2]; } }; ->x236 : Genric ->Genric : Genric ->Base : Base ->x236 = { func: n => { return [d1, d2]; } } : { func: (n: Base[]) => (Derived1 | Derived2)[]; } ->x236 : Genric ->{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => (Derived1 | Derived2)[]; } ->func : (n: Base[]) => (Derived1 | Derived2)[] ->n => { return [d1, d2]; } : (n: Base[]) => (Derived1 | Derived2)[] ->n : Base[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -var x237: { n: () => Base[]; } = { n: () => [d1, d2] }; ->x237 : { n: () => Base[]; } ->n : () => Base[] ->Base : Base ->{ n: () => [d1, d2] } : { n: () => (Derived1 | Derived2)[]; } ->n : () => (Derived1 | Derived2)[] ->() => [d1, d2] : () => (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -var x238: { n: () => Base[]; } = { n: function() { return [d1, d2] } }; ->x238 : { n: () => Base[]; } ->n : () => Base[] ->Base : Base ->{ n: function() { return [d1, d2] } } : { n: () => (Derived1 | Derived2)[]; } ->n : () => (Derived1 | Derived2)[] ->function() { return [d1, d2] } : () => (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -var x239: { n: () => Base[]; } = { n: function named() { return [d1, d2] } }; ->x239 : { n: () => Base[]; } ->n : () => Base[] ->Base : Base ->{ n: function named() { return [d1, d2] } } : { n: () => (Derived1 | Derived2)[]; } ->n : () => (Derived1 | Derived2)[] ->function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] ->named : () => (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -var x240: { n: { (): Base[]; }; } = { n: () => [d1, d2] }; ->x240 : { n: () => Base[]; } ->n : () => Base[] ->Base : Base ->{ n: () => [d1, d2] } : { n: () => (Derived1 | Derived2)[]; } ->n : () => (Derived1 | Derived2)[] ->() => [d1, d2] : () => (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -var x241: { n: { (): Base[]; }; } = { n: function() { return [d1, d2] } }; ->x241 : { n: () => Base[]; } ->n : () => Base[] ->Base : Base ->{ n: function() { return [d1, d2] } } : { n: () => (Derived1 | Derived2)[]; } ->n : () => (Derived1 | Derived2)[] ->function() { return [d1, d2] } : () => (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -var x242: { n: { (): Base[]; }; } = { n: function named() { return [d1, d2] } }; ->x242 : { n: () => Base[]; } ->n : () => Base[] ->Base : Base ->{ n: function named() { return [d1, d2] } } : { n: () => (Derived1 | Derived2)[]; } ->n : () => (Derived1 | Derived2)[] ->function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] ->named : () => (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -var x243: { n: Base[]; } = { n: [d1, d2] }; ->x243 : { n: Base[]; } ->n : Base[] ->Base : Base ->{ n: [d1, d2] } : { n: (Derived1 | Derived2)[]; } ->n : (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -var x244: { n: Array; } = { n: [d1, d2] }; ->x244 : { n: Base[]; } ->n : Base[] ->Array : T[] ->Base : Base ->{ n: [d1, d2] } : { n: (Derived1 | Derived2)[]; } ->n : (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -var x245: { n: { [n: number]: Base; }; } = { n: [d1, d2] }; ->x245 : { n: { [n: number]: Base; }; } ->n : { [n: number]: Base; } ->n : number ->Base : Base ->{ n: [d1, d2] } : { n: (Derived1 | Derived2)[]; } ->n : (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -var x246: { n: {n: Base[]; } ; } = { n: { n: [d1, d2] } }; ->x246 : { n: { n: Base[]; }; } ->n : { n: Base[]; } ->n : Base[] ->Base : Base ->{ n: { n: [d1, d2] } } : { n: { n: (Derived1 | Derived2)[]; }; } ->n : { n: (Derived1 | Derived2)[]; } ->{ n: [d1, d2] } : { n: (Derived1 | Derived2)[]; } ->n : (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -var x247: { n: (s: Base[]) => any; } = { n: n => { var n: Base[]; return null; } }; ->x247 : { n: (s: Base[]) => any; } ->n : (s: Base[]) => any ->s : Base[] ->Base : Base ->{ n: n => { var n: Base[]; return null; } } : { n: (n: Base[]) => any; } ->n : (n: Base[]) => any ->n => { var n: Base[]; return null; } : (n: Base[]) => any ->n : Base[] ->n : Base[] ->Base : Base ->null : null - -var x248: { n: Genric; } = { n: { func: n => { return [d1, d2]; } } }; ->x248 : { n: Genric; } ->n : Genric ->Genric : Genric ->Base : Base ->{ n: { func: n => { return [d1, d2]; } } } : { n: { func: (n: Base[]) => (Derived1 | Derived2)[]; }; } ->n : { func: (n: Base[]) => (Derived1 | Derived2)[]; } ->{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => (Derived1 | Derived2)[]; } ->func : (n: Base[]) => (Derived1 | Derived2)[] ->n => { return [d1, d2]; } : (n: Base[]) => (Derived1 | Derived2)[] ->n : Base[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -var x252: { (): Base[]; }[] = [() => [d1, d2]]; ->x252 : (() => Base[])[] ->Base : Base ->[() => [d1, d2]] : (() => (Derived1 | Derived2)[])[] ->() => [d1, d2] : () => (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -var x253: { (): Base[]; }[] = [function() { return [d1, d2] }]; ->x253 : (() => Base[])[] ->Base : Base ->[function() { return [d1, d2] }] : (() => (Derived1 | Derived2)[])[] ->function() { return [d1, d2] } : () => (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -var x254: { (): Base[]; }[] = [function named() { return [d1, d2] }]; ->x254 : (() => Base[])[] ->Base : Base ->[function named() { return [d1, d2] }] : (() => (Derived1 | Derived2)[])[] ->function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] ->named : () => (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -var x255: Base[][] = [[d1, d2]]; ->x255 : Base[][] ->Base : Base ->[[d1, d2]] : (Derived1 | Derived2)[][] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -var x256: Array[] = [[d1, d2]]; ->x256 : Base[][] ->Array : T[] ->Base : Base ->[[d1, d2]] : (Derived1 | Derived2)[][] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -var x257: { [n: number]: Base; }[] = [[d1, d2]]; ->x257 : { [n: number]: Base; }[] ->n : number ->Base : Base ->[[d1, d2]] : (Derived1 | Derived2)[][] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -var x258: {n: Base[]; } [] = [{ n: [d1, d2] }]; ->x258 : { n: Base[]; }[] ->n : Base[] ->Base : Base ->[{ n: [d1, d2] }] : { n: (Derived1 | Derived2)[]; }[] ->{ n: [d1, d2] } : { n: (Derived1 | Derived2)[]; } ->n : (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -var x260: Genric[] = [{ func: n => { return [d1, d2]; } }]; ->x260 : Genric[] ->Genric : Genric ->Base : Base ->[{ func: n => { return [d1, d2]; } }] : { func: (n: Base[]) => (Derived1 | Derived2)[]; }[] ->{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => (Derived1 | Derived2)[]; } ->func : (n: Base[]) => (Derived1 | Derived2)[] ->n => { return [d1, d2]; } : (n: Base[]) => (Derived1 | Derived2)[] ->n : Base[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -var x261: () => Base[] = function() { return [d1, d2] } || undefined; ->x261 : () => Base[] ->Base : Base ->function() { return [d1, d2] } || undefined : () => (Derived1 | Derived2)[] ->function() { return [d1, d2] } : () => (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 ->undefined : undefined - -var x262: () => Base[] = function named() { return [d1, d2] } || undefined; ->x262 : () => Base[] ->Base : Base ->function named() { return [d1, d2] } || undefined : () => (Derived1 | Derived2)[] ->function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] ->named : () => (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 ->undefined : undefined - -var x263: { (): Base[]; } = function() { return [d1, d2] } || undefined; ->x263 : () => Base[] ->Base : Base ->function() { return [d1, d2] } || undefined : () => (Derived1 | Derived2)[] ->function() { return [d1, d2] } : () => (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 ->undefined : undefined - -var x264: { (): Base[]; } = function named() { return [d1, d2] } || undefined; ->x264 : () => Base[] ->Base : Base ->function named() { return [d1, d2] } || undefined : () => (Derived1 | Derived2)[] ->function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] ->named : () => (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 ->undefined : undefined - -var x265: Base[] = [d1, d2] || undefined; ->x265 : Base[] ->Base : Base ->[d1, d2] || undefined : (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 ->undefined : undefined - -var x266: Array = [d1, d2] || undefined; ->x266 : Base[] ->Array : T[] ->Base : Base ->[d1, d2] || undefined : (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 ->undefined : undefined - -var x267: { [n: number]: Base; } = [d1, d2] || undefined; ->x267 : { [n: number]: Base; } ->n : number ->Base : Base ->[d1, d2] || undefined : (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 ->undefined : undefined - -var x268: {n: Base[]; } = { n: [d1, d2] } || undefined; ->x268 : { n: Base[]; } ->n : Base[] ->Base : Base ->{ n: [d1, d2] } || undefined : { n: (Derived1 | Derived2)[]; } ->{ n: [d1, d2] } : { n: (Derived1 | Derived2)[]; } ->n : (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 ->undefined : undefined - -var x269: () => Base[] = undefined || function() { return [d1, d2] }; ->x269 : () => Base[] ->Base : Base ->undefined || function() { return [d1, d2] } : () => (Derived1 | Derived2)[] ->undefined : undefined ->function() { return [d1, d2] } : () => (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -var x270: () => Base[] = undefined || function named() { return [d1, d2] }; ->x270 : () => Base[] ->Base : Base ->undefined || function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] ->undefined : undefined ->function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] ->named : () => (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -var x271: { (): Base[]; } = undefined || function() { return [d1, d2] }; ->x271 : () => Base[] ->Base : Base ->undefined || function() { return [d1, d2] } : () => (Derived1 | Derived2)[] ->undefined : undefined ->function() { return [d1, d2] } : () => (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -var x272: { (): Base[]; } = undefined || function named() { return [d1, d2] }; ->x272 : () => Base[] ->Base : Base ->undefined || function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] ->undefined : undefined ->function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] ->named : () => (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -var x273: Base[] = undefined || [d1, d2]; ->x273 : Base[] ->Base : Base ->undefined || [d1, d2] : (Derived1 | Derived2)[] ->undefined : undefined ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -var x274: Array = undefined || [d1, d2]; ->x274 : Base[] ->Array : T[] ->Base : Base ->undefined || [d1, d2] : (Derived1 | Derived2)[] ->undefined : undefined ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -var x275: { [n: number]: Base; } = undefined || [d1, d2]; ->x275 : { [n: number]: Base; } ->n : number ->Base : Base ->undefined || [d1, d2] : (Derived1 | Derived2)[] ->undefined : undefined ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -var x276: {n: Base[]; } = undefined || { n: [d1, d2] }; ->x276 : { n: Base[]; } ->n : Base[] ->Base : Base ->undefined || { n: [d1, d2] } : { n: (Derived1 | Derived2)[]; } ->undefined : undefined ->{ n: [d1, d2] } : { n: (Derived1 | Derived2)[]; } ->n : (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -var x277: () => Base[] = function() { return [d1, d2] } || function() { return [d1, d2] }; ->x277 : () => Base[] ->Base : Base ->function() { return [d1, d2] } || function() { return [d1, d2] } : () => (Derived1 | Derived2)[] ->function() { return [d1, d2] } : () => (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 ->function() { return [d1, d2] } : () => (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -var x278: () => Base[] = function named() { return [d1, d2] } || function named() { return [d1, d2] }; ->x278 : () => Base[] ->Base : Base ->function named() { return [d1, d2] } || function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] ->function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] ->named : () => (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 ->function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] ->named : () => (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -var x279: { (): Base[]; } = function() { return [d1, d2] } || function() { return [d1, d2] }; ->x279 : () => Base[] ->Base : Base ->function() { return [d1, d2] } || function() { return [d1, d2] } : () => (Derived1 | Derived2)[] ->function() { return [d1, d2] } : () => (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 ->function() { return [d1, d2] } : () => (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -var x280: { (): Base[]; } = function named() { return [d1, d2] } || function named() { return [d1, d2] }; ->x280 : () => Base[] ->Base : Base ->function named() { return [d1, d2] } || function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] ->function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] ->named : () => (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 ->function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] ->named : () => (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -var x281: Base[] = [d1, d2] || [d1, d2]; ->x281 : Base[] ->Base : Base ->[d1, d2] || [d1, d2] : (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -var x282: Array = [d1, d2] || [d1, d2]; ->x282 : Base[] ->Array : T[] ->Base : Base ->[d1, d2] || [d1, d2] : (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -var x283: { [n: number]: Base; } = [d1, d2] || [d1, d2]; ->x283 : { [n: number]: Base; } ->n : number ->Base : Base ->[d1, d2] || [d1, d2] : (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -var x284: {n: Base[]; } = { n: [d1, d2] } || { n: [d1, d2] }; ->x284 : { n: Base[]; } ->n : Base[] ->Base : Base ->{ n: [d1, d2] } || { n: [d1, d2] } : { n: (Derived1 | Derived2)[]; } ->{ n: [d1, d2] } : { n: (Derived1 | Derived2)[]; } ->n : (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 ->{ n: [d1, d2] } : { n: (Derived1 | Derived2)[]; } ->n : (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -var x285: () => Base[] = true ? () => [d1, d2] : () => [d1, d2]; ->x285 : () => Base[] ->Base : Base ->true ? () => [d1, d2] : () => [d1, d2] : () => (Derived1 | Derived2)[] ->true : boolean ->() => [d1, d2] : () => (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 ->() => [d1, d2] : () => (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -var x286: () => Base[] = true ? function() { return [d1, d2] } : function() { return [d1, d2] }; ->x286 : () => Base[] ->Base : Base ->true ? function() { return [d1, d2] } : function() { return [d1, d2] } : () => (Derived1 | Derived2)[] ->true : boolean ->function() { return [d1, d2] } : () => (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 ->function() { return [d1, d2] } : () => (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -var x287: () => Base[] = true ? function named() { return [d1, d2] } : function named() { return [d1, d2] }; ->x287 : () => Base[] ->Base : Base ->true ? function named() { return [d1, d2] } : function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] ->true : boolean ->function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] ->named : () => (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 ->function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] ->named : () => (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -var x288: { (): Base[]; } = true ? () => [d1, d2] : () => [d1, d2]; ->x288 : () => Base[] ->Base : Base ->true ? () => [d1, d2] : () => [d1, d2] : () => (Derived1 | Derived2)[] ->true : boolean ->() => [d1, d2] : () => (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 ->() => [d1, d2] : () => (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -var x289: { (): Base[]; } = true ? function() { return [d1, d2] } : function() { return [d1, d2] }; ->x289 : () => Base[] ->Base : Base ->true ? function() { return [d1, d2] } : function() { return [d1, d2] } : () => (Derived1 | Derived2)[] ->true : boolean ->function() { return [d1, d2] } : () => (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 ->function() { return [d1, d2] } : () => (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -var x290: { (): Base[]; } = true ? function named() { return [d1, d2] } : function named() { return [d1, d2] }; ->x290 : () => Base[] ->Base : Base ->true ? function named() { return [d1, d2] } : function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] ->true : boolean ->function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] ->named : () => (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 ->function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] ->named : () => (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -var x291: Base[] = true ? [d1, d2] : [d1, d2]; ->x291 : Base[] ->Base : Base ->true ? [d1, d2] : [d1, d2] : (Derived1 | Derived2)[] ->true : boolean ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -var x292: Array = true ? [d1, d2] : [d1, d2]; ->x292 : Base[] ->Array : T[] ->Base : Base ->true ? [d1, d2] : [d1, d2] : (Derived1 | Derived2)[] ->true : boolean ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -var x293: { [n: number]: Base; } = true ? [d1, d2] : [d1, d2]; ->x293 : { [n: number]: Base; } ->n : number ->Base : Base ->true ? [d1, d2] : [d1, d2] : (Derived1 | Derived2)[] ->true : boolean ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -var x294: {n: Base[]; } = true ? { n: [d1, d2] } : { n: [d1, d2] }; ->x294 : { n: Base[]; } ->n : Base[] ->Base : Base ->true ? { n: [d1, d2] } : { n: [d1, d2] } : { n: (Derived1 | Derived2)[]; } ->true : boolean ->{ n: [d1, d2] } : { n: (Derived1 | Derived2)[]; } ->n : (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 ->{ n: [d1, d2] } : { n: (Derived1 | Derived2)[]; } ->n : (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -var x295: (s: Base[]) => any = true ? n => { var n: Base[]; return null; } : n => { var n: Base[]; return null; }; ->x295 : (s: Base[]) => any ->s : Base[] ->Base : Base ->true ? n => { var n: Base[]; return null; } : n => { var n: Base[]; return null; } : (n: Base[]) => any ->true : boolean ->n => { var n: Base[]; return null; } : (n: Base[]) => any ->n : Base[] ->n : Base[] ->Base : Base ->null : null ->n => { var n: Base[]; return null; } : (n: Base[]) => any ->n : Base[] ->n : Base[] ->Base : Base ->null : null - -var x296: Genric = true ? { func: n => { return [d1, d2]; } } : { func: n => { return [d1, d2]; } }; ->x296 : Genric ->Genric : Genric ->Base : Base ->true ? { func: n => { return [d1, d2]; } } : { func: n => { return [d1, d2]; } } : { func: (n: Base[]) => (Derived1 | Derived2)[]; } ->true : boolean ->{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => (Derived1 | Derived2)[]; } ->func : (n: Base[]) => (Derived1 | Derived2)[] ->n => { return [d1, d2]; } : (n: Base[]) => (Derived1 | Derived2)[] ->n : Base[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 ->{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => (Derived1 | Derived2)[]; } ->func : (n: Base[]) => (Derived1 | Derived2)[] ->n => { return [d1, d2]; } : (n: Base[]) => (Derived1 | Derived2)[] ->n : Base[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -var x297: () => Base[] = true ? undefined : () => [d1, d2]; ->x297 : () => Base[] ->Base : Base ->true ? undefined : () => [d1, d2] : () => (Derived1 | Derived2)[] ->true : boolean ->undefined : undefined ->() => [d1, d2] : () => (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -var x298: () => Base[] = true ? undefined : function() { return [d1, d2] }; ->x298 : () => Base[] ->Base : Base ->true ? undefined : function() { return [d1, d2] } : () => (Derived1 | Derived2)[] ->true : boolean ->undefined : undefined ->function() { return [d1, d2] } : () => (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -var x299: () => Base[] = true ? undefined : function named() { return [d1, d2] }; ->x299 : () => Base[] ->Base : Base ->true ? undefined : function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] ->true : boolean ->undefined : undefined ->function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] ->named : () => (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -var x300: { (): Base[]; } = true ? undefined : () => [d1, d2]; ->x300 : () => Base[] ->Base : Base ->true ? undefined : () => [d1, d2] : () => (Derived1 | Derived2)[] ->true : boolean ->undefined : undefined ->() => [d1, d2] : () => (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -var x301: { (): Base[]; } = true ? undefined : function() { return [d1, d2] }; ->x301 : () => Base[] ->Base : Base ->true ? undefined : function() { return [d1, d2] } : () => (Derived1 | Derived2)[] ->true : boolean ->undefined : undefined ->function() { return [d1, d2] } : () => (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -var x302: { (): Base[]; } = true ? undefined : function named() { return [d1, d2] }; ->x302 : () => Base[] ->Base : Base ->true ? undefined : function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] ->true : boolean ->undefined : undefined ->function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] ->named : () => (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -var x303: Base[] = true ? undefined : [d1, d2]; ->x303 : Base[] ->Base : Base ->true ? undefined : [d1, d2] : (Derived1 | Derived2)[] ->true : boolean ->undefined : undefined ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -var x304: Array = true ? undefined : [d1, d2]; ->x304 : Base[] ->Array : T[] ->Base : Base ->true ? undefined : [d1, d2] : (Derived1 | Derived2)[] ->true : boolean ->undefined : undefined ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -var x305: { [n: number]: Base; } = true ? undefined : [d1, d2]; ->x305 : { [n: number]: Base; } ->n : number ->Base : Base ->true ? undefined : [d1, d2] : (Derived1 | Derived2)[] ->true : boolean ->undefined : undefined ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -var x306: {n: Base[]; } = true ? undefined : { n: [d1, d2] }; ->x306 : { n: Base[]; } ->n : Base[] ->Base : Base ->true ? undefined : { n: [d1, d2] } : { n: (Derived1 | Derived2)[]; } ->true : boolean ->undefined : undefined ->{ n: [d1, d2] } : { n: (Derived1 | Derived2)[]; } ->n : (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -var x307: (s: Base[]) => any = true ? undefined : n => { var n: Base[]; return null; }; ->x307 : (s: Base[]) => any ->s : Base[] ->Base : Base ->true ? undefined : n => { var n: Base[]; return null; } : (n: Base[]) => any ->true : boolean ->undefined : undefined ->n => { var n: Base[]; return null; } : (n: Base[]) => any ->n : Base[] ->n : Base[] ->Base : Base ->null : null - -var x308: Genric = true ? undefined : { func: n => { return [d1, d2]; } }; ->x308 : Genric ->Genric : Genric ->Base : Base ->true ? undefined : { func: n => { return [d1, d2]; } } : { func: (n: Base[]) => (Derived1 | Derived2)[]; } ->true : boolean ->undefined : undefined ->{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => (Derived1 | Derived2)[]; } ->func : (n: Base[]) => (Derived1 | Derived2)[] ->n => { return [d1, d2]; } : (n: Base[]) => (Derived1 | Derived2)[] ->n : Base[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -var x309: () => Base[] = true ? () => [d1, d2] : undefined; ->x309 : () => Base[] ->Base : Base ->true ? () => [d1, d2] : undefined : () => (Derived1 | Derived2)[] ->true : boolean ->() => [d1, d2] : () => (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 ->undefined : undefined - -var x310: () => Base[] = true ? function() { return [d1, d2] } : undefined; ->x310 : () => Base[] ->Base : Base ->true ? function() { return [d1, d2] } : undefined : () => (Derived1 | Derived2)[] ->true : boolean ->function() { return [d1, d2] } : () => (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 ->undefined : undefined - -var x311: () => Base[] = true ? function named() { return [d1, d2] } : undefined; ->x311 : () => Base[] ->Base : Base ->true ? function named() { return [d1, d2] } : undefined : () => (Derived1 | Derived2)[] ->true : boolean ->function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] ->named : () => (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 ->undefined : undefined - -var x312: { (): Base[]; } = true ? () => [d1, d2] : undefined; ->x312 : () => Base[] ->Base : Base ->true ? () => [d1, d2] : undefined : () => (Derived1 | Derived2)[] ->true : boolean ->() => [d1, d2] : () => (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 ->undefined : undefined - -var x313: { (): Base[]; } = true ? function() { return [d1, d2] } : undefined; ->x313 : () => Base[] ->Base : Base ->true ? function() { return [d1, d2] } : undefined : () => (Derived1 | Derived2)[] ->true : boolean ->function() { return [d1, d2] } : () => (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 ->undefined : undefined - -var x314: { (): Base[]; } = true ? function named() { return [d1, d2] } : undefined; ->x314 : () => Base[] ->Base : Base ->true ? function named() { return [d1, d2] } : undefined : () => (Derived1 | Derived2)[] ->true : boolean ->function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] ->named : () => (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 ->undefined : undefined - -var x315: Base[] = true ? [d1, d2] : undefined; ->x315 : Base[] ->Base : Base ->true ? [d1, d2] : undefined : (Derived1 | Derived2)[] ->true : boolean ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 ->undefined : undefined - -var x316: Array = true ? [d1, d2] : undefined; ->x316 : Base[] ->Array : T[] ->Base : Base ->true ? [d1, d2] : undefined : (Derived1 | Derived2)[] ->true : boolean ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 ->undefined : undefined - -var x317: { [n: number]: Base; } = true ? [d1, d2] : undefined; ->x317 : { [n: number]: Base; } ->n : number ->Base : Base ->true ? [d1, d2] : undefined : (Derived1 | Derived2)[] ->true : boolean ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 ->undefined : undefined - -var x318: {n: Base[]; } = true ? { n: [d1, d2] } : undefined; ->x318 : { n: Base[]; } ->n : Base[] ->Base : Base ->true ? { n: [d1, d2] } : undefined : { n: (Derived1 | Derived2)[]; } ->true : boolean ->{ n: [d1, d2] } : { n: (Derived1 | Derived2)[]; } ->n : (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 ->undefined : undefined - -var x319: (s: Base[]) => any = true ? n => { var n: Base[]; return null; } : undefined; ->x319 : (s: Base[]) => any ->s : Base[] ->Base : Base ->true ? n => { var n: Base[]; return null; } : undefined : (n: Base[]) => any ->true : boolean ->n => { var n: Base[]; return null; } : (n: Base[]) => any ->n : Base[] ->n : Base[] ->Base : Base ->null : null ->undefined : undefined - -var x320: Genric = true ? { func: n => { return [d1, d2]; } } : undefined; ->x320 : Genric ->Genric : Genric ->Base : Base ->true ? { func: n => { return [d1, d2]; } } : undefined : { func: (n: Base[]) => (Derived1 | Derived2)[]; } ->true : boolean ->{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => (Derived1 | Derived2)[]; } ->func : (n: Base[]) => (Derived1 | Derived2)[] ->n => { return [d1, d2]; } : (n: Base[]) => (Derived1 | Derived2)[] ->n : Base[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 ->undefined : undefined - -function x321(n: () => Base[]) { }; x321(() => [d1, d2]); ->x321 : (n: () => Base[]) => void ->n : () => Base[] ->Base : Base ->x321(() => [d1, d2]) : void ->x321 : (n: () => Base[]) => void ->() => [d1, d2] : () => (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -function x322(n: () => Base[]) { }; x322(function() { return [d1, d2] }); ->x322 : (n: () => Base[]) => void ->n : () => Base[] ->Base : Base ->x322(function() { return [d1, d2] }) : void ->x322 : (n: () => Base[]) => void ->function() { return [d1, d2] } : () => (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -function x323(n: () => Base[]) { }; x323(function named() { return [d1, d2] }); ->x323 : (n: () => Base[]) => void ->n : () => Base[] ->Base : Base ->x323(function named() { return [d1, d2] }) : void ->x323 : (n: () => Base[]) => void ->function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] ->named : () => (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -function x324(n: { (): Base[]; }) { }; x324(() => [d1, d2]); ->x324 : (n: () => Base[]) => void ->n : () => Base[] ->Base : Base ->x324(() => [d1, d2]) : void ->x324 : (n: () => Base[]) => void ->() => [d1, d2] : () => (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -function x325(n: { (): Base[]; }) { }; x325(function() { return [d1, d2] }); ->x325 : (n: () => Base[]) => void ->n : () => Base[] ->Base : Base ->x325(function() { return [d1, d2] }) : void ->x325 : (n: () => Base[]) => void ->function() { return [d1, d2] } : () => (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -function x326(n: { (): Base[]; }) { }; x326(function named() { return [d1, d2] }); ->x326 : (n: () => Base[]) => void ->n : () => Base[] ->Base : Base ->x326(function named() { return [d1, d2] }) : void ->x326 : (n: () => Base[]) => void ->function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] ->named : () => (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -function x327(n: Base[]) { }; x327([d1, d2]); ->x327 : (n: Base[]) => void ->n : Base[] ->Base : Base ->x327([d1, d2]) : void ->x327 : (n: Base[]) => void ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -function x328(n: Array) { }; x328([d1, d2]); ->x328 : (n: Base[]) => void ->n : Base[] ->Array : T[] ->Base : Base ->x328([d1, d2]) : void ->x328 : (n: Base[]) => void ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -function x329(n: { [n: number]: Base; }) { }; x329([d1, d2]); ->x329 : (n: { [n: number]: Base; }) => void ->n : { [n: number]: Base; } ->n : number ->Base : Base ->x329([d1, d2]) : void ->x329 : (n: { [n: number]: Base; }) => void ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -function x330(n: {n: Base[]; } ) { }; x330({ n: [d1, d2] }); ->x330 : (n: { n: Base[]; }) => void ->n : { n: Base[]; } ->n : Base[] ->Base : Base ->x330({ n: [d1, d2] }) : void ->x330 : (n: { n: Base[]; }) => void ->{ n: [d1, d2] } : { n: (Derived1 | Derived2)[]; } ->n : (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -function x331(n: (s: Base[]) => any) { }; x331(n => { var n: Base[]; return null; }); ->x331 : (n: (s: Base[]) => any) => void ->n : (s: Base[]) => any ->s : Base[] ->Base : Base ->x331(n => { var n: Base[]; return null; }) : void ->x331 : (n: (s: Base[]) => any) => void ->n => { var n: Base[]; return null; } : (n: Base[]) => any ->n : Base[] ->n : Base[] ->Base : Base ->null : null - -function x332(n: Genric) { }; x332({ func: n => { return [d1, d2]; } }); ->x332 : (n: Genric) => void ->n : Genric ->Genric : Genric ->Base : Base ->x332({ func: n => { return [d1, d2]; } }) : void ->x332 : (n: Genric) => void ->{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => (Derived1 | Derived2)[]; } ->func : (n: Base[]) => (Derived1 | Derived2)[] ->n => { return [d1, d2]; } : (n: Base[]) => (Derived1 | Derived2)[] ->n : Base[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -var x333 = (n: () => Base[]) => n; x333(() => [d1, d2]); ->x333 : (n: () => Base[]) => () => Base[] ->(n: () => Base[]) => n : (n: () => Base[]) => () => Base[] ->n : () => Base[] ->Base : Base ->n : () => Base[] ->x333(() => [d1, d2]) : () => Base[] ->x333 : (n: () => Base[]) => () => Base[] ->() => [d1, d2] : () => (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -var x334 = (n: () => Base[]) => n; x334(function() { return [d1, d2] }); ->x334 : (n: () => Base[]) => () => Base[] ->(n: () => Base[]) => n : (n: () => Base[]) => () => Base[] ->n : () => Base[] ->Base : Base ->n : () => Base[] ->x334(function() { return [d1, d2] }) : () => Base[] ->x334 : (n: () => Base[]) => () => Base[] ->function() { return [d1, d2] } : () => (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -var x335 = (n: () => Base[]) => n; x335(function named() { return [d1, d2] }); ->x335 : (n: () => Base[]) => () => Base[] ->(n: () => Base[]) => n : (n: () => Base[]) => () => Base[] ->n : () => Base[] ->Base : Base ->n : () => Base[] ->x335(function named() { return [d1, d2] }) : () => Base[] ->x335 : (n: () => Base[]) => () => Base[] ->function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] ->named : () => (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -var x336 = (n: { (): Base[]; }) => n; x336(() => [d1, d2]); ->x336 : (n: () => Base[]) => () => Base[] ->(n: { (): Base[]; }) => n : (n: () => Base[]) => () => Base[] ->n : () => Base[] ->Base : Base ->n : () => Base[] ->x336(() => [d1, d2]) : () => Base[] ->x336 : (n: () => Base[]) => () => Base[] ->() => [d1, d2] : () => (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -var x337 = (n: { (): Base[]; }) => n; x337(function() { return [d1, d2] }); ->x337 : (n: () => Base[]) => () => Base[] ->(n: { (): Base[]; }) => n : (n: () => Base[]) => () => Base[] ->n : () => Base[] ->Base : Base ->n : () => Base[] ->x337(function() { return [d1, d2] }) : () => Base[] ->x337 : (n: () => Base[]) => () => Base[] ->function() { return [d1, d2] } : () => (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -var x338 = (n: { (): Base[]; }) => n; x338(function named() { return [d1, d2] }); ->x338 : (n: () => Base[]) => () => Base[] ->(n: { (): Base[]; }) => n : (n: () => Base[]) => () => Base[] ->n : () => Base[] ->Base : Base ->n : () => Base[] ->x338(function named() { return [d1, d2] }) : () => Base[] ->x338 : (n: () => Base[]) => () => Base[] ->function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] ->named : () => (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -var x339 = (n: Base[]) => n; x339([d1, d2]); ->x339 : (n: Base[]) => Base[] ->(n: Base[]) => n : (n: Base[]) => Base[] ->n : Base[] ->Base : Base ->n : Base[] ->x339([d1, d2]) : Base[] ->x339 : (n: Base[]) => Base[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -var x340 = (n: Array) => n; x340([d1, d2]); ->x340 : (n: Base[]) => Base[] ->(n: Array) => n : (n: Base[]) => Base[] ->n : Base[] ->Array : T[] ->Base : Base ->n : Base[] ->x340([d1, d2]) : Base[] ->x340 : (n: Base[]) => Base[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -var x341 = (n: { [n: number]: Base; }) => n; x341([d1, d2]); ->x341 : (n: { [n: number]: Base; }) => { [n: number]: Base; } ->(n: { [n: number]: Base; }) => n : (n: { [n: number]: Base; }) => { [n: number]: Base; } ->n : { [n: number]: Base; } ->n : number ->Base : Base ->n : { [n: number]: Base; } ->x341([d1, d2]) : { [n: number]: Base; } ->x341 : (n: { [n: number]: Base; }) => { [n: number]: Base; } ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -var x342 = (n: {n: Base[]; } ) => n; x342({ n: [d1, d2] }); ->x342 : (n: { n: Base[]; }) => { n: Base[]; } ->(n: {n: Base[]; } ) => n : (n: { n: Base[]; }) => { n: Base[]; } ->n : { n: Base[]; } ->n : Base[] ->Base : Base ->n : { n: Base[]; } ->x342({ n: [d1, d2] }) : { n: Base[]; } ->x342 : (n: { n: Base[]; }) => { n: Base[]; } ->{ n: [d1, d2] } : { n: (Derived1 | Derived2)[]; } ->n : (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -var x343 = (n: (s: Base[]) => any) => n; x343(n => { var n: Base[]; return null; }); ->x343 : (n: (s: Base[]) => any) => (s: Base[]) => any ->(n: (s: Base[]) => any) => n : (n: (s: Base[]) => any) => (s: Base[]) => any ->n : (s: Base[]) => any ->s : Base[] ->Base : Base ->n : (s: Base[]) => any ->x343(n => { var n: Base[]; return null; }) : (s: Base[]) => any ->x343 : (n: (s: Base[]) => any) => (s: Base[]) => any ->n => { var n: Base[]; return null; } : (n: Base[]) => any ->n : Base[] ->n : Base[] ->Base : Base ->null : null - -var x344 = (n: Genric) => n; x344({ func: n => { return [d1, d2]; } }); ->x344 : (n: Genric) => Genric ->(n: Genric) => n : (n: Genric) => Genric ->n : Genric ->Genric : Genric ->Base : Base ->n : Genric ->x344({ func: n => { return [d1, d2]; } }) : Genric ->x344 : (n: Genric) => Genric ->{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => (Derived1 | Derived2)[]; } ->func : (n: Base[]) => (Derived1 | Derived2)[] ->n => { return [d1, d2]; } : (n: Base[]) => (Derived1 | Derived2)[] ->n : Base[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -var x345 = function(n: () => Base[]) { }; x345(() => [d1, d2]); ->x345 : (n: () => Base[]) => void ->function(n: () => Base[]) { } : (n: () => Base[]) => void ->n : () => Base[] ->Base : Base ->x345(() => [d1, d2]) : void ->x345 : (n: () => Base[]) => void ->() => [d1, d2] : () => (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -var x346 = function(n: () => Base[]) { }; x346(function() { return [d1, d2] }); ->x346 : (n: () => Base[]) => void ->function(n: () => Base[]) { } : (n: () => Base[]) => void ->n : () => Base[] ->Base : Base ->x346(function() { return [d1, d2] }) : void ->x346 : (n: () => Base[]) => void ->function() { return [d1, d2] } : () => (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -var x347 = function(n: () => Base[]) { }; x347(function named() { return [d1, d2] }); ->x347 : (n: () => Base[]) => void ->function(n: () => Base[]) { } : (n: () => Base[]) => void ->n : () => Base[] ->Base : Base ->x347(function named() { return [d1, d2] }) : void ->x347 : (n: () => Base[]) => void ->function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] ->named : () => (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -var x348 = function(n: { (): Base[]; }) { }; x348(() => [d1, d2]); ->x348 : (n: () => Base[]) => void ->function(n: { (): Base[]; }) { } : (n: () => Base[]) => void ->n : () => Base[] ->Base : Base ->x348(() => [d1, d2]) : void ->x348 : (n: () => Base[]) => void ->() => [d1, d2] : () => (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -var x349 = function(n: { (): Base[]; }) { }; x349(function() { return [d1, d2] }); ->x349 : (n: () => Base[]) => void ->function(n: { (): Base[]; }) { } : (n: () => Base[]) => void ->n : () => Base[] ->Base : Base ->x349(function() { return [d1, d2] }) : void ->x349 : (n: () => Base[]) => void ->function() { return [d1, d2] } : () => (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -var x350 = function(n: { (): Base[]; }) { }; x350(function named() { return [d1, d2] }); ->x350 : (n: () => Base[]) => void ->function(n: { (): Base[]; }) { } : (n: () => Base[]) => void ->n : () => Base[] ->Base : Base ->x350(function named() { return [d1, d2] }) : void ->x350 : (n: () => Base[]) => void ->function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] ->named : () => (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -var x351 = function(n: Base[]) { }; x351([d1, d2]); ->x351 : (n: Base[]) => void ->function(n: Base[]) { } : (n: Base[]) => void ->n : Base[] ->Base : Base ->x351([d1, d2]) : void ->x351 : (n: Base[]) => void ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -var x352 = function(n: Array) { }; x352([d1, d2]); ->x352 : (n: Base[]) => void ->function(n: Array) { } : (n: Base[]) => void ->n : Base[] ->Array : T[] ->Base : Base ->x352([d1, d2]) : void ->x352 : (n: Base[]) => void ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -var x353 = function(n: { [n: number]: Base; }) { }; x353([d1, d2]); ->x353 : (n: { [n: number]: Base; }) => void ->function(n: { [n: number]: Base; }) { } : (n: { [n: number]: Base; }) => void ->n : { [n: number]: Base; } ->n : number ->Base : Base ->x353([d1, d2]) : void ->x353 : (n: { [n: number]: Base; }) => void ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -var x354 = function(n: {n: Base[]; } ) { }; x354({ n: [d1, d2] }); ->x354 : (n: { n: Base[]; }) => void ->function(n: {n: Base[]; } ) { } : (n: { n: Base[]; }) => void ->n : { n: Base[]; } ->n : Base[] ->Base : Base ->x354({ n: [d1, d2] }) : void ->x354 : (n: { n: Base[]; }) => void ->{ n: [d1, d2] } : { n: (Derived1 | Derived2)[]; } ->n : (Derived1 | Derived2)[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - -var x355 = function(n: (s: Base[]) => any) { }; x355(n => { var n: Base[]; return null; }); ->x355 : (n: (s: Base[]) => any) => void ->function(n: (s: Base[]) => any) { } : (n: (s: Base[]) => any) => void ->n : (s: Base[]) => any ->s : Base[] ->Base : Base ->x355(n => { var n: Base[]; return null; }) : void ->x355 : (n: (s: Base[]) => any) => void ->n => { var n: Base[]; return null; } : (n: Base[]) => any ->n : Base[] ->n : Base[] ->Base : Base ->null : null - -var x356 = function(n: Genric) { }; x356({ func: n => { return [d1, d2]; } }); ->x356 : (n: Genric) => void ->function(n: Genric) { } : (n: Genric) => void ->n : Genric ->Genric : Genric ->Base : Base ->x356({ func: n => { return [d1, d2]; } }) : void ->x356 : (n: Genric) => void ->{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => (Derived1 | Derived2)[]; } ->func : (n: Base[]) => (Derived1 | Derived2)[] ->n => { return [d1, d2]; } : (n: Base[]) => (Derived1 | Derived2)[] ->n : Base[] ->[d1, d2] : (Derived1 | Derived2)[] ->d1 : Derived1 ->d2 : Derived2 - diff --git a/tests/baselines/reference/ifDoWhileStatements.errors.txt b/tests/baselines/reference/ifDoWhileStatements.errors.txt new file mode 100644 index 00000000000..fb8985e634b --- /dev/null +++ b/tests/baselines/reference/ifDoWhileStatements.errors.txt @@ -0,0 +1,168 @@ +tests/cases/conformance/statements/ifDoWhileStatements/ifDoWhileStatements.ts(42,1): error TS7027: Unreachable code detected. + + +==== tests/cases/conformance/statements/ifDoWhileStatements/ifDoWhileStatements.ts (1 errors) ==== + interface I { + id: number; + } + + class C implements I { + id: number; + name: string; + } + + class C2 extends C { + valid: boolean; + } + + class D{ + source: T; + recurse: D; + wrapped: D> + } + + function F(x: string): number { return 42; } + function F2(x: number): boolean { return x < 42; } + + module M { + export class A { + name: string; + } + + export function F2(x: number): string { return x.toString(); } + } + + module N { + export class A { + id: number; + } + + export function F2(x: number): string { return x.toString(); } + } + + // literals + if (true) { } + while (true) { } + do { }while(true) + ~~ +!!! error TS7027: Unreachable code detected. + + if (null) { } + while (null) { } + do { }while(null) + + if (undefined) { } + while (undefined) { } + do { }while(undefined) + + if (0.0) { } + while (0.0) { } + do { }while(0.0) + + if ('a string') { } + while ('a string') { } + do { }while('a string') + + if ('') { } + while ('') { } + do { }while('') + + if (/[a-z]/) { } + while (/[a-z]/) { } + do { }while(/[a-z]/) + + if ([]) { } + while ([]) { } + do { }while([]) + + if ([1, 2]) { } + while ([1, 2]) { } + do { }while([1, 2]) + + if ({}) { } + while ({}) { } + do { }while({}) + + if ({ x: 1, y: 'a' }) { } + while ({ x: 1, y: 'a' }) { } + do { }while({ x: 1, y: 'a' }) + + if (() => 43) { } + while (() => 43) { } + do { }while(() => 43) + + if (new C()) { } + while (new C()) { } + do { }while(new C()) + + if (new D()) { } + while (new D()) { } + do { }while(new D()) + + // references + var a = true; + if (a) { } + while (a) { } + do { }while(a) + + var b = null; + if (b) { } + while (b) { } + do { }while(b) + + var c = undefined; + if (c) { } + while (c) { } + do { }while(c) + + var d = 0.0; + if (d) { } + while (d) { } + do { }while(d) + + var e = 'a string'; + if (e) { } + while (e) { } + do { }while(e) + + var f = ''; + if (f) { } + while (f) { } + do { }while(f) + + var g = /[a-z]/ + if (g) { } + while (g) { } + do { }while(g) + + var h = []; + if (h) { } + while (h) { } + do { }while(h) + + var i = [1, 2]; + if (i) { } + while (i) { } + do { }while(i) + + var j = {}; + if (j) { } + while (j) { } + do { }while(j) + + var k = { x: 1, y: 'a' }; + if (k) { } + while (k) { } + do { }while(k) + + function fn(x?: string): I { return null; } + if (fn()) { } + while (fn()) { } + do { }while(fn()) + + if (fn) { } + while (fn) { } + do { }while(fn) + + + \ No newline at end of file diff --git a/tests/baselines/reference/ifDoWhileStatements.symbols b/tests/baselines/reference/ifDoWhileStatements.symbols deleted file mode 100644 index 36a990010ef..00000000000 --- a/tests/baselines/reference/ifDoWhileStatements.symbols +++ /dev/null @@ -1,336 +0,0 @@ -=== tests/cases/conformance/statements/ifDoWhileStatements/ifDoWhileStatements.ts === -interface I { ->I : Symbol(I, Decl(ifDoWhileStatements.ts, 0, 0)) - - id: number; ->id : Symbol(id, Decl(ifDoWhileStatements.ts, 0, 13)) -} - -class C implements I { ->C : Symbol(C, Decl(ifDoWhileStatements.ts, 2, 1)) ->I : Symbol(I, Decl(ifDoWhileStatements.ts, 0, 0)) - - id: number; ->id : Symbol(id, Decl(ifDoWhileStatements.ts, 4, 22)) - - name: string; ->name : Symbol(name, Decl(ifDoWhileStatements.ts, 5, 15)) -} - -class C2 extends C { ->C2 : Symbol(C2, Decl(ifDoWhileStatements.ts, 7, 1)) ->C : Symbol(C, Decl(ifDoWhileStatements.ts, 2, 1)) - - valid: boolean; ->valid : Symbol(valid, Decl(ifDoWhileStatements.ts, 9, 20)) -} - -class D{ ->D : Symbol(D, Decl(ifDoWhileStatements.ts, 11, 1)) ->T : Symbol(T, Decl(ifDoWhileStatements.ts, 13, 8)) - - source: T; ->source : Symbol(source, Decl(ifDoWhileStatements.ts, 13, 11)) ->T : Symbol(T, Decl(ifDoWhileStatements.ts, 13, 8)) - - recurse: D; ->recurse : Symbol(recurse, Decl(ifDoWhileStatements.ts, 14, 14)) ->D : Symbol(D, Decl(ifDoWhileStatements.ts, 11, 1)) ->T : Symbol(T, Decl(ifDoWhileStatements.ts, 13, 8)) - - wrapped: D> ->wrapped : Symbol(wrapped, Decl(ifDoWhileStatements.ts, 15, 18)) ->D : Symbol(D, Decl(ifDoWhileStatements.ts, 11, 1)) ->D : Symbol(D, Decl(ifDoWhileStatements.ts, 11, 1)) ->T : Symbol(T, Decl(ifDoWhileStatements.ts, 13, 8)) -} - -function F(x: string): number { return 42; } ->F : Symbol(F, Decl(ifDoWhileStatements.ts, 17, 1)) ->x : Symbol(x, Decl(ifDoWhileStatements.ts, 19, 11)) - -function F2(x: number): boolean { return x < 42; } ->F2 : Symbol(F2, Decl(ifDoWhileStatements.ts, 19, 44)) ->x : Symbol(x, Decl(ifDoWhileStatements.ts, 20, 12)) ->x : Symbol(x, Decl(ifDoWhileStatements.ts, 20, 12)) - -module M { ->M : Symbol(M, Decl(ifDoWhileStatements.ts, 20, 50)) - - export class A { ->A : Symbol(A, Decl(ifDoWhileStatements.ts, 22, 10)) - - name: string; ->name : Symbol(name, Decl(ifDoWhileStatements.ts, 23, 20)) - } - - export function F2(x: number): string { return x.toString(); } ->F2 : Symbol(F2, Decl(ifDoWhileStatements.ts, 25, 5)) ->x : Symbol(x, Decl(ifDoWhileStatements.ts, 27, 23)) ->x.toString : Symbol(Number.toString, Decl(lib.d.ts, 458, 18)) ->x : Symbol(x, Decl(ifDoWhileStatements.ts, 27, 23)) ->toString : Symbol(Number.toString, Decl(lib.d.ts, 458, 18)) -} - -module N { ->N : Symbol(N, Decl(ifDoWhileStatements.ts, 28, 1)) - - export class A { ->A : Symbol(A, Decl(ifDoWhileStatements.ts, 30, 10)) - - id: number; ->id : Symbol(id, Decl(ifDoWhileStatements.ts, 31, 20)) - } - - export function F2(x: number): string { return x.toString(); } ->F2 : Symbol(F2, Decl(ifDoWhileStatements.ts, 33, 5)) ->x : Symbol(x, Decl(ifDoWhileStatements.ts, 35, 23)) ->x.toString : Symbol(Number.toString, Decl(lib.d.ts, 458, 18)) ->x : Symbol(x, Decl(ifDoWhileStatements.ts, 35, 23)) ->toString : Symbol(Number.toString, Decl(lib.d.ts, 458, 18)) -} - -// literals -if (true) { } -while (true) { } -do { }while(true) - -if (null) { } -while (null) { } -do { }while(null) - -if (undefined) { } ->undefined : Symbol(undefined) - -while (undefined) { } ->undefined : Symbol(undefined) - -do { }while(undefined) ->undefined : Symbol(undefined) - -if (0.0) { } -while (0.0) { } -do { }while(0.0) - -if ('a string') { } -while ('a string') { } -do { }while('a string') - -if ('') { } -while ('') { } -do { }while('') - -if (/[a-z]/) { } -while (/[a-z]/) { } -do { }while(/[a-z]/) - -if ([]) { } -while ([]) { } -do { }while([]) - -if ([1, 2]) { } -while ([1, 2]) { } -do { }while([1, 2]) - -if ({}) { } -while ({}) { } -do { }while({}) - -if ({ x: 1, y: 'a' }) { } ->x : Symbol(x, Decl(ifDoWhileStatements.ts, 79, 5)) ->y : Symbol(y, Decl(ifDoWhileStatements.ts, 79, 11)) - -while ({ x: 1, y: 'a' }) { } ->x : Symbol(x, Decl(ifDoWhileStatements.ts, 80, 8)) ->y : Symbol(y, Decl(ifDoWhileStatements.ts, 80, 14)) - -do { }while({ x: 1, y: 'a' }) ->x : Symbol(x, Decl(ifDoWhileStatements.ts, 81, 13)) ->y : Symbol(y, Decl(ifDoWhileStatements.ts, 81, 19)) - -if (() => 43) { } -while (() => 43) { } -do { }while(() => 43) - -if (new C()) { } ->C : Symbol(C, Decl(ifDoWhileStatements.ts, 2, 1)) - -while (new C()) { } ->C : Symbol(C, Decl(ifDoWhileStatements.ts, 2, 1)) - -do { }while(new C()) ->C : Symbol(C, Decl(ifDoWhileStatements.ts, 2, 1)) - -if (new D()) { } ->D : Symbol(D, Decl(ifDoWhileStatements.ts, 11, 1)) ->C : Symbol(C, Decl(ifDoWhileStatements.ts, 2, 1)) - -while (new D()) { } ->D : Symbol(D, Decl(ifDoWhileStatements.ts, 11, 1)) ->C : Symbol(C, Decl(ifDoWhileStatements.ts, 2, 1)) - -do { }while(new D()) ->D : Symbol(D, Decl(ifDoWhileStatements.ts, 11, 1)) ->C : Symbol(C, Decl(ifDoWhileStatements.ts, 2, 1)) - -// references -var a = true; ->a : Symbol(a, Decl(ifDoWhileStatements.ts, 96, 3)) - -if (a) { } ->a : Symbol(a, Decl(ifDoWhileStatements.ts, 96, 3)) - -while (a) { } ->a : Symbol(a, Decl(ifDoWhileStatements.ts, 96, 3)) - -do { }while(a) ->a : Symbol(a, Decl(ifDoWhileStatements.ts, 96, 3)) - -var b = null; ->b : Symbol(b, Decl(ifDoWhileStatements.ts, 101, 3)) - -if (b) { } ->b : Symbol(b, Decl(ifDoWhileStatements.ts, 101, 3)) - -while (b) { } ->b : Symbol(b, Decl(ifDoWhileStatements.ts, 101, 3)) - -do { }while(b) ->b : Symbol(b, Decl(ifDoWhileStatements.ts, 101, 3)) - -var c = undefined; ->c : Symbol(c, Decl(ifDoWhileStatements.ts, 106, 3)) ->undefined : Symbol(undefined) - -if (c) { } ->c : Symbol(c, Decl(ifDoWhileStatements.ts, 106, 3)) - -while (c) { } ->c : Symbol(c, Decl(ifDoWhileStatements.ts, 106, 3)) - -do { }while(c) ->c : Symbol(c, Decl(ifDoWhileStatements.ts, 106, 3)) - -var d = 0.0; ->d : Symbol(d, Decl(ifDoWhileStatements.ts, 111, 3)) - -if (d) { } ->d : Symbol(d, Decl(ifDoWhileStatements.ts, 111, 3)) - -while (d) { } ->d : Symbol(d, Decl(ifDoWhileStatements.ts, 111, 3)) - -do { }while(d) ->d : Symbol(d, Decl(ifDoWhileStatements.ts, 111, 3)) - -var e = 'a string'; ->e : Symbol(e, Decl(ifDoWhileStatements.ts, 116, 3)) - -if (e) { } ->e : Symbol(e, Decl(ifDoWhileStatements.ts, 116, 3)) - -while (e) { } ->e : Symbol(e, Decl(ifDoWhileStatements.ts, 116, 3)) - -do { }while(e) ->e : Symbol(e, Decl(ifDoWhileStatements.ts, 116, 3)) - -var f = ''; ->f : Symbol(f, Decl(ifDoWhileStatements.ts, 121, 3)) - -if (f) { } ->f : Symbol(f, Decl(ifDoWhileStatements.ts, 121, 3)) - -while (f) { } ->f : Symbol(f, Decl(ifDoWhileStatements.ts, 121, 3)) - -do { }while(f) ->f : Symbol(f, Decl(ifDoWhileStatements.ts, 121, 3)) - -var g = /[a-z]/ ->g : Symbol(g, Decl(ifDoWhileStatements.ts, 126, 3)) - -if (g) { } ->g : Symbol(g, Decl(ifDoWhileStatements.ts, 126, 3)) - -while (g) { } ->g : Symbol(g, Decl(ifDoWhileStatements.ts, 126, 3)) - -do { }while(g) ->g : Symbol(g, Decl(ifDoWhileStatements.ts, 126, 3)) - -var h = []; ->h : Symbol(h, Decl(ifDoWhileStatements.ts, 131, 3)) - -if (h) { } ->h : Symbol(h, Decl(ifDoWhileStatements.ts, 131, 3)) - -while (h) { } ->h : Symbol(h, Decl(ifDoWhileStatements.ts, 131, 3)) - -do { }while(h) ->h : Symbol(h, Decl(ifDoWhileStatements.ts, 131, 3)) - -var i = [1, 2]; ->i : Symbol(i, Decl(ifDoWhileStatements.ts, 136, 3)) - -if (i) { } ->i : Symbol(i, Decl(ifDoWhileStatements.ts, 136, 3)) - -while (i) { } ->i : Symbol(i, Decl(ifDoWhileStatements.ts, 136, 3)) - -do { }while(i) ->i : Symbol(i, Decl(ifDoWhileStatements.ts, 136, 3)) - -var j = {}; ->j : Symbol(j, Decl(ifDoWhileStatements.ts, 141, 3)) - -if (j) { } ->j : Symbol(j, Decl(ifDoWhileStatements.ts, 141, 3)) - -while (j) { } ->j : Symbol(j, Decl(ifDoWhileStatements.ts, 141, 3)) - -do { }while(j) ->j : Symbol(j, Decl(ifDoWhileStatements.ts, 141, 3)) - -var k = { x: 1, y: 'a' }; ->k : Symbol(k, Decl(ifDoWhileStatements.ts, 146, 3)) ->x : Symbol(x, Decl(ifDoWhileStatements.ts, 146, 9)) ->y : Symbol(y, Decl(ifDoWhileStatements.ts, 146, 15)) - -if (k) { } ->k : Symbol(k, Decl(ifDoWhileStatements.ts, 146, 3)) - -while (k) { } ->k : Symbol(k, Decl(ifDoWhileStatements.ts, 146, 3)) - -do { }while(k) ->k : Symbol(k, Decl(ifDoWhileStatements.ts, 146, 3)) - -function fn(x?: string): I { return null; } ->fn : Symbol(fn, Decl(ifDoWhileStatements.ts, 149, 14)) ->x : Symbol(x, Decl(ifDoWhileStatements.ts, 151, 12)) ->I : Symbol(I, Decl(ifDoWhileStatements.ts, 0, 0)) - -if (fn()) { } ->fn : Symbol(fn, Decl(ifDoWhileStatements.ts, 149, 14)) - -while (fn()) { } ->fn : Symbol(fn, Decl(ifDoWhileStatements.ts, 149, 14)) - -do { }while(fn()) ->fn : Symbol(fn, Decl(ifDoWhileStatements.ts, 149, 14)) - -if (fn) { } ->fn : Symbol(fn, Decl(ifDoWhileStatements.ts, 149, 14)) - -while (fn) { } ->fn : Symbol(fn, Decl(ifDoWhileStatements.ts, 149, 14)) - -do { }while(fn) ->fn : Symbol(fn, Decl(ifDoWhileStatements.ts, 149, 14)) - - - diff --git a/tests/baselines/reference/ifDoWhileStatements.types b/tests/baselines/reference/ifDoWhileStatements.types deleted file mode 100644 index 92a9df6a4dd..00000000000 --- a/tests/baselines/reference/ifDoWhileStatements.types +++ /dev/null @@ -1,433 +0,0 @@ -=== tests/cases/conformance/statements/ifDoWhileStatements/ifDoWhileStatements.ts === -interface I { ->I : I - - id: number; ->id : number -} - -class C implements I { ->C : C ->I : I - - id: number; ->id : number - - name: string; ->name : string -} - -class C2 extends C { ->C2 : C2 ->C : C - - valid: boolean; ->valid : boolean -} - -class D{ ->D : D ->T : T - - source: T; ->source : T ->T : T - - recurse: D; ->recurse : D ->D : D ->T : T - - wrapped: D> ->wrapped : D> ->D : D ->D : D ->T : T -} - -function F(x: string): number { return 42; } ->F : (x: string) => number ->x : string ->42 : number - -function F2(x: number): boolean { return x < 42; } ->F2 : (x: number) => boolean ->x : number ->x < 42 : boolean ->x : number ->42 : number - -module M { ->M : typeof M - - export class A { ->A : A - - name: string; ->name : string - } - - export function F2(x: number): string { return x.toString(); } ->F2 : (x: number) => string ->x : number ->x.toString() : string ->x.toString : (radix?: number) => string ->x : number ->toString : (radix?: number) => string -} - -module N { ->N : typeof N - - export class A { ->A : A - - id: number; ->id : number - } - - export function F2(x: number): string { return x.toString(); } ->F2 : (x: number) => string ->x : number ->x.toString() : string ->x.toString : (radix?: number) => string ->x : number ->toString : (radix?: number) => string -} - -// literals -if (true) { } ->true : boolean - -while (true) { } ->true : boolean - -do { }while(true) ->true : boolean - -if (null) { } ->null : null - -while (null) { } ->null : null - -do { }while(null) ->null : null - -if (undefined) { } ->undefined : undefined - -while (undefined) { } ->undefined : undefined - -do { }while(undefined) ->undefined : undefined - -if (0.0) { } ->0.0 : number - -while (0.0) { } ->0.0 : number - -do { }while(0.0) ->0.0 : number - -if ('a string') { } ->'a string' : string - -while ('a string') { } ->'a string' : string - -do { }while('a string') ->'a string' : string - -if ('') { } ->'' : string - -while ('') { } ->'' : string - -do { }while('') ->'' : string - -if (/[a-z]/) { } ->/[a-z]/ : RegExp - -while (/[a-z]/) { } ->/[a-z]/ : RegExp - -do { }while(/[a-z]/) ->/[a-z]/ : RegExp - -if ([]) { } ->[] : undefined[] - -while ([]) { } ->[] : undefined[] - -do { }while([]) ->[] : undefined[] - -if ([1, 2]) { } ->[1, 2] : number[] ->1 : number ->2 : number - -while ([1, 2]) { } ->[1, 2] : number[] ->1 : number ->2 : number - -do { }while([1, 2]) ->[1, 2] : number[] ->1 : number ->2 : number - -if ({}) { } ->{} : {} - -while ({}) { } ->{} : {} - -do { }while({}) ->{} : {} - -if ({ x: 1, y: 'a' }) { } ->{ x: 1, y: 'a' } : { x: number; y: string; } ->x : number ->1 : number ->y : string ->'a' : string - -while ({ x: 1, y: 'a' }) { } ->{ x: 1, y: 'a' } : { x: number; y: string; } ->x : number ->1 : number ->y : string ->'a' : string - -do { }while({ x: 1, y: 'a' }) ->{ x: 1, y: 'a' } : { x: number; y: string; } ->x : number ->1 : number ->y : string ->'a' : string - -if (() => 43) { } ->() => 43 : () => number ->43 : number - -while (() => 43) { } ->() => 43 : () => number ->43 : number - -do { }while(() => 43) ->() => 43 : () => number ->43 : number - -if (new C()) { } ->new C() : C ->C : typeof C - -while (new C()) { } ->new C() : C ->C : typeof C - -do { }while(new C()) ->new C() : C ->C : typeof C - -if (new D()) { } ->new D() : D ->D : typeof D ->C : C - -while (new D()) { } ->new D() : D ->D : typeof D ->C : C - -do { }while(new D()) ->new D() : D ->D : typeof D ->C : C - -// references -var a = true; ->a : boolean ->true : boolean - -if (a) { } ->a : boolean - -while (a) { } ->a : boolean - -do { }while(a) ->a : boolean - -var b = null; ->b : any ->null : null - -if (b) { } ->b : any - -while (b) { } ->b : any - -do { }while(b) ->b : any - -var c = undefined; ->c : any ->undefined : undefined - -if (c) { } ->c : any - -while (c) { } ->c : any - -do { }while(c) ->c : any - -var d = 0.0; ->d : number ->0.0 : number - -if (d) { } ->d : number - -while (d) { } ->d : number - -do { }while(d) ->d : number - -var e = 'a string'; ->e : string ->'a string' : string - -if (e) { } ->e : string - -while (e) { } ->e : string - -do { }while(e) ->e : string - -var f = ''; ->f : string ->'' : string - -if (f) { } ->f : string - -while (f) { } ->f : string - -do { }while(f) ->f : string - -var g = /[a-z]/ ->g : RegExp ->/[a-z]/ : RegExp - -if (g) { } ->g : RegExp - -while (g) { } ->g : RegExp - -do { }while(g) ->g : RegExp - -var h = []; ->h : any[] ->[] : undefined[] - -if (h) { } ->h : any[] - -while (h) { } ->h : any[] - -do { }while(h) ->h : any[] - -var i = [1, 2]; ->i : number[] ->[1, 2] : number[] ->1 : number ->2 : number - -if (i) { } ->i : number[] - -while (i) { } ->i : number[] - -do { }while(i) ->i : number[] - -var j = {}; ->j : {} ->{} : {} - -if (j) { } ->j : {} - -while (j) { } ->j : {} - -do { }while(j) ->j : {} - -var k = { x: 1, y: 'a' }; ->k : { x: number; y: string; } ->{ x: 1, y: 'a' } : { x: number; y: string; } ->x : number ->1 : number ->y : string ->'a' : string - -if (k) { } ->k : { x: number; y: string; } - -while (k) { } ->k : { x: number; y: string; } - -do { }while(k) ->k : { x: number; y: string; } - -function fn(x?: string): I { return null; } ->fn : (x?: string) => I ->x : string ->I : I ->null : null - -if (fn()) { } ->fn() : I ->fn : (x?: string) => I - -while (fn()) { } ->fn() : I ->fn : (x?: string) => I - -do { }while(fn()) ->fn() : I ->fn : (x?: string) => I - -if (fn) { } ->fn : (x?: string) => I - -while (fn) { } ->fn : (x?: string) => I - -do { }while(fn) ->fn : (x?: string) => I - - - diff --git a/tests/baselines/reference/ifElseWithStatements1.errors.txt b/tests/baselines/reference/ifElseWithStatements1.errors.txt index 186cff59241..f9fcb33113a 100644 --- a/tests/baselines/reference/ifElseWithStatements1.errors.txt +++ b/tests/baselines/reference/ifElseWithStatements1.errors.txt @@ -1,8 +1,10 @@ tests/cases/compiler/ifElseWithStatements1.ts(2,5): error TS2304: Cannot find name 'f'. tests/cases/compiler/ifElseWithStatements1.ts(4,5): error TS2304: Cannot find name 'f'. +tests/cases/compiler/ifElseWithStatements1.ts(4,5): error TS7027: Unreachable code detected. +tests/cases/compiler/ifElseWithStatements1.ts(10,9): error TS7027: Unreachable code detected. -==== tests/cases/compiler/ifElseWithStatements1.ts (2 errors) ==== +==== tests/cases/compiler/ifElseWithStatements1.ts (4 errors) ==== if (true) f(); ~ @@ -11,11 +13,15 @@ tests/cases/compiler/ifElseWithStatements1.ts(4,5): error TS2304: Cannot find na f(); ~ !!! error TS2304: Cannot find name 'f'. + ~ +!!! error TS7027: Unreachable code detected. function foo(): boolean { if (true) return true; else return false; + ~~~~~~ +!!! error TS7027: Unreachable code detected. } \ No newline at end of file diff --git a/tests/baselines/reference/inferredFunctionReturnTypeIsEmptyType.errors.txt b/tests/baselines/reference/inferredFunctionReturnTypeIsEmptyType.errors.txt index 99819ecad2c..b1d4a1ba6ba 100644 --- a/tests/baselines/reference/inferredFunctionReturnTypeIsEmptyType.errors.txt +++ b/tests/baselines/reference/inferredFunctionReturnTypeIsEmptyType.errors.txt @@ -1,7 +1,8 @@ tests/cases/compiler/inferredFunctionReturnTypeIsEmptyType.ts(1,10): error TS2354: No best common type exists among return expressions. +tests/cases/compiler/inferredFunctionReturnTypeIsEmptyType.ts(6,9): error TS7027: Unreachable code detected. -==== tests/cases/compiler/inferredFunctionReturnTypeIsEmptyType.ts (1 errors) ==== +==== tests/cases/compiler/inferredFunctionReturnTypeIsEmptyType.ts (2 errors) ==== function foo() { ~~~ !!! error TS2354: No best common type exists among return expressions. @@ -10,6 +11,8 @@ tests/cases/compiler/inferredFunctionReturnTypeIsEmptyType.ts(1,10): error TS235 } else { return "42"; + ~~~~~~ +!!! error TS7027: Unreachable code detected. } }; \ No newline at end of file diff --git a/tests/baselines/reference/inheritanceStaticPropertyOverridingAccessor.errors.txt b/tests/baselines/reference/inheritanceStaticPropertyOverridingAccessor.errors.txt index 08aab5b1158..251938cc9c7 100644 --- a/tests/baselines/reference/inheritanceStaticPropertyOverridingAccessor.errors.txt +++ b/tests/baselines/reference/inheritanceStaticPropertyOverridingAccessor.errors.txt @@ -1,13 +1,16 @@ tests/cases/compiler/inheritanceStaticPropertyOverridingAccessor.ts(2,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. +tests/cases/compiler/inheritanceStaticPropertyOverridingAccessor.ts(3,21): error TS7027: Unreachable code detected. tests/cases/compiler/inheritanceStaticPropertyOverridingAccessor.ts(5,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -==== tests/cases/compiler/inheritanceStaticPropertyOverridingAccessor.ts (2 errors) ==== +==== tests/cases/compiler/inheritanceStaticPropertyOverridingAccessor.ts (3 errors) ==== class a { static get x(): () => string { ~ !!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. return null;; + ~ +!!! error TS7027: Unreachable code detected. } static set x(aValue: () => string) { ~ diff --git a/tests/baselines/reference/interfaceExtendingClass2.errors.txt b/tests/baselines/reference/interfaceExtendingClass2.errors.txt index 3b394d4922a..68bd5e845ac 100644 --- a/tests/baselines/reference/interfaceExtendingClass2.errors.txt +++ b/tests/baselines/reference/interfaceExtendingClass2.errors.txt @@ -1,10 +1,11 @@ tests/cases/conformance/interfaces/interfacesExtendingClasses/interfaceExtendingClass2.ts(11,5): error TS2411: Property 'a' of type '{ toString: () => {}; }' is not assignable to string index type 'Object'. tests/cases/conformance/interfaces/interfacesExtendingClasses/interfaceExtendingClass2.ts(13,13): error TS1131: Property or signature expected. tests/cases/conformance/interfaces/interfacesExtendingClasses/interfaceExtendingClass2.ts(14,9): error TS1128: Declaration or statement expected. +tests/cases/conformance/interfaces/interfacesExtendingClasses/interfaceExtendingClass2.ts(14,10): error TS7027: Unreachable code detected. tests/cases/conformance/interfaces/interfacesExtendingClasses/interfaceExtendingClass2.ts(15,5): error TS1128: Declaration or statement expected. -==== tests/cases/conformance/interfaces/interfacesExtendingClasses/interfaceExtendingClass2.ts (4 errors) ==== +==== tests/cases/conformance/interfaces/interfacesExtendingClasses/interfaceExtendingClass2.ts (5 errors) ==== class Foo { x: string; y() { } @@ -26,6 +27,8 @@ tests/cases/conformance/interfaces/interfacesExtendingClasses/interfaceExtending }; ~ !!! error TS1128: Declaration or statement expected. + ~ +!!! error TS7027: Unreachable code detected. } ~ !!! error TS1128: Declaration or statement expected. \ No newline at end of file diff --git a/tests/baselines/reference/interfaceWithPrivateMember.errors.txt b/tests/baselines/reference/interfaceWithPrivateMember.errors.txt index 7f2542b45a1..aa6dfdc1032 100644 --- a/tests/baselines/reference/interfaceWithPrivateMember.errors.txt +++ b/tests/baselines/reference/interfaceWithPrivateMember.errors.txt @@ -1,11 +1,12 @@ tests/cases/conformance/types/namedTypes/interfaceWithPrivateMember.ts(4,5): error TS1131: Property or signature expected. tests/cases/conformance/types/namedTypes/interfaceWithPrivateMember.ts(8,5): error TS1131: Property or signature expected. tests/cases/conformance/types/namedTypes/interfaceWithPrivateMember.ts(12,5): error TS1131: Property or signature expected. +tests/cases/conformance/types/namedTypes/interfaceWithPrivateMember.ts(12,13): error TS7028: Unused label. tests/cases/conformance/types/namedTypes/interfaceWithPrivateMember.ts(12,16): error TS2304: Cannot find name 'string'. tests/cases/conformance/types/namedTypes/interfaceWithPrivateMember.ts(13,1): error TS1128: Declaration or statement expected. -==== tests/cases/conformance/types/namedTypes/interfaceWithPrivateMember.ts (5 errors) ==== +==== tests/cases/conformance/types/namedTypes/interfaceWithPrivateMember.ts (6 errors) ==== // interfaces do not permit private members, these are errors interface I { @@ -24,6 +25,8 @@ tests/cases/conformance/types/namedTypes/interfaceWithPrivateMember.ts(13,1): er private y: string; ~~~~~~~ !!! error TS1131: Property or signature expected. + ~ +!!! error TS7028: Unused label. ~~~~~~ !!! error TS2304: Cannot find name 'string'. } diff --git a/tests/baselines/reference/invalidDoWhileBreakStatements.errors.txt b/tests/baselines/reference/invalidDoWhileBreakStatements.errors.txt index 65fd55b763b..2a26190534e 100644 --- a/tests/baselines/reference/invalidDoWhileBreakStatements.errors.txt +++ b/tests/baselines/reference/invalidDoWhileBreakStatements.errors.txt @@ -1,12 +1,14 @@ tests/cases/conformance/statements/breakStatements/invalidDoWhileBreakStatements.ts(4,1): error TS1105: A 'break' statement can only be used within an enclosing iteration or switch statement. +tests/cases/conformance/statements/breakStatements/invalidDoWhileBreakStatements.ts(7,1): error TS7028: Unused label. tests/cases/conformance/statements/breakStatements/invalidDoWhileBreakStatements.ts(8,4): error TS1116: A 'break' statement can only jump to a label of an enclosing statement. +tests/cases/conformance/statements/breakStatements/invalidDoWhileBreakStatements.ts(11,1): error TS7027: Unreachable code detected. tests/cases/conformance/statements/breakStatements/invalidDoWhileBreakStatements.ts(14,9): error TS1107: Jump target cannot cross function boundary. tests/cases/conformance/statements/breakStatements/invalidDoWhileBreakStatements.ts(21,9): error TS1107: Jump target cannot cross function boundary. tests/cases/conformance/statements/breakStatements/invalidDoWhileBreakStatements.ts(27,5): error TS1116: A 'break' statement can only jump to a label of an enclosing statement. tests/cases/conformance/statements/breakStatements/invalidDoWhileBreakStatements.ts(37,5): error TS1116: A 'break' statement can only jump to a label of an enclosing statement. -==== tests/cases/conformance/statements/breakStatements/invalidDoWhileBreakStatements.ts (6 errors) ==== +==== tests/cases/conformance/statements/breakStatements/invalidDoWhileBreakStatements.ts (8 errors) ==== // All errors // naked break not allowed @@ -16,12 +18,16 @@ tests/cases/conformance/statements/breakStatements/invalidDoWhileBreakStatements // non-existent label ONE: + ~~~ +!!! error TS7028: Unused label. do break TWO; while (true) ~~~~~~~~~~ !!! error TS1116: A 'break' statement can only jump to a label of an enclosing statement. // break from inside function TWO: + ~~~ +!!! error TS7027: Unreachable code detected. do { var x = () => { break TWO; diff --git a/tests/baselines/reference/invalidDoWhileContinueStatements.errors.txt b/tests/baselines/reference/invalidDoWhileContinueStatements.errors.txt index e9643394d12..b3938d9ba8b 100644 --- a/tests/baselines/reference/invalidDoWhileContinueStatements.errors.txt +++ b/tests/baselines/reference/invalidDoWhileContinueStatements.errors.txt @@ -1,12 +1,14 @@ tests/cases/conformance/statements/continueStatements/invalidDoWhileContinueStatements.ts(4,1): error TS1104: A 'continue' statement can only be used within an enclosing iteration statement. +tests/cases/conformance/statements/continueStatements/invalidDoWhileContinueStatements.ts(7,1): error TS7028: Unused label. tests/cases/conformance/statements/continueStatements/invalidDoWhileContinueStatements.ts(8,4): error TS1115: A 'continue' statement can only jump to a label of an enclosing iteration statement. +tests/cases/conformance/statements/continueStatements/invalidDoWhileContinueStatements.ts(11,1): error TS7027: Unreachable code detected. tests/cases/conformance/statements/continueStatements/invalidDoWhileContinueStatements.ts(14,9): error TS1107: Jump target cannot cross function boundary. tests/cases/conformance/statements/continueStatements/invalidDoWhileContinueStatements.ts(21,9): error TS1107: Jump target cannot cross function boundary. tests/cases/conformance/statements/continueStatements/invalidDoWhileContinueStatements.ts(27,5): error TS1115: A 'continue' statement can only jump to a label of an enclosing iteration statement. tests/cases/conformance/statements/continueStatements/invalidDoWhileContinueStatements.ts(37,5): error TS1115: A 'continue' statement can only jump to a label of an enclosing iteration statement. -==== tests/cases/conformance/statements/continueStatements/invalidDoWhileContinueStatements.ts (6 errors) ==== +==== tests/cases/conformance/statements/continueStatements/invalidDoWhileContinueStatements.ts (8 errors) ==== // All errors // naked continue not allowed @@ -16,12 +18,16 @@ tests/cases/conformance/statements/continueStatements/invalidDoWhileContinueStat // non-existent label ONE: + ~~~ +!!! error TS7028: Unused label. do continue TWO; while (true) ~~~~~~~~~~~~~ !!! error TS1115: A 'continue' statement can only jump to a label of an enclosing iteration statement. // continue from inside function TWO: + ~~~ +!!! error TS7027: Unreachable code detected. do { var x = () => { continue TWO; diff --git a/tests/baselines/reference/invalidForBreakStatements.errors.txt b/tests/baselines/reference/invalidForBreakStatements.errors.txt index 50e4013c0ea..f803cad08e1 100644 --- a/tests/baselines/reference/invalidForBreakStatements.errors.txt +++ b/tests/baselines/reference/invalidForBreakStatements.errors.txt @@ -1,12 +1,14 @@ tests/cases/conformance/statements/breakStatements/invalidForBreakStatements.ts(4,1): error TS1105: A 'break' statement can only be used within an enclosing iteration or switch statement. +tests/cases/conformance/statements/breakStatements/invalidForBreakStatements.ts(7,1): error TS7028: Unused label. tests/cases/conformance/statements/breakStatements/invalidForBreakStatements.ts(8,9): error TS1116: A 'break' statement can only jump to a label of an enclosing statement. +tests/cases/conformance/statements/breakStatements/invalidForBreakStatements.ts(11,1): error TS7027: Unreachable code detected. tests/cases/conformance/statements/breakStatements/invalidForBreakStatements.ts(14,9): error TS1107: Jump target cannot cross function boundary. tests/cases/conformance/statements/breakStatements/invalidForBreakStatements.ts(21,9): error TS1107: Jump target cannot cross function boundary. tests/cases/conformance/statements/breakStatements/invalidForBreakStatements.ts(27,5): error TS1116: A 'break' statement can only jump to a label of an enclosing statement. tests/cases/conformance/statements/breakStatements/invalidForBreakStatements.ts(36,5): error TS1116: A 'break' statement can only jump to a label of an enclosing statement. -==== tests/cases/conformance/statements/breakStatements/invalidForBreakStatements.ts (6 errors) ==== +==== tests/cases/conformance/statements/breakStatements/invalidForBreakStatements.ts (8 errors) ==== // All errors // naked break not allowed @@ -16,12 +18,16 @@ tests/cases/conformance/statements/breakStatements/invalidForBreakStatements.ts( // non-existent label ONE: + ~~~ +!!! error TS7028: Unused label. for(;;) break TWO; ~~~~~~~~~~ !!! error TS1116: A 'break' statement can only jump to a label of an enclosing statement. // break from inside function TWO: + ~~~ +!!! error TS7027: Unreachable code detected. for(;;) { var x = () => { break TWO; diff --git a/tests/baselines/reference/invalidForContinueStatements.errors.txt b/tests/baselines/reference/invalidForContinueStatements.errors.txt index 3af47370df1..9a252a2c572 100644 --- a/tests/baselines/reference/invalidForContinueStatements.errors.txt +++ b/tests/baselines/reference/invalidForContinueStatements.errors.txt @@ -1,12 +1,14 @@ tests/cases/conformance/statements/continueStatements/invalidForContinueStatements.ts(4,1): error TS1104: A 'continue' statement can only be used within an enclosing iteration statement. +tests/cases/conformance/statements/continueStatements/invalidForContinueStatements.ts(7,1): error TS7028: Unused label. tests/cases/conformance/statements/continueStatements/invalidForContinueStatements.ts(8,9): error TS1115: A 'continue' statement can only jump to a label of an enclosing iteration statement. +tests/cases/conformance/statements/continueStatements/invalidForContinueStatements.ts(11,1): error TS7027: Unreachable code detected. tests/cases/conformance/statements/continueStatements/invalidForContinueStatements.ts(14,9): error TS1107: Jump target cannot cross function boundary. tests/cases/conformance/statements/continueStatements/invalidForContinueStatements.ts(21,9): error TS1107: Jump target cannot cross function boundary. tests/cases/conformance/statements/continueStatements/invalidForContinueStatements.ts(27,5): error TS1115: A 'continue' statement can only jump to a label of an enclosing iteration statement. tests/cases/conformance/statements/continueStatements/invalidForContinueStatements.ts(36,5): error TS1115: A 'continue' statement can only jump to a label of an enclosing iteration statement. -==== tests/cases/conformance/statements/continueStatements/invalidForContinueStatements.ts (6 errors) ==== +==== tests/cases/conformance/statements/continueStatements/invalidForContinueStatements.ts (8 errors) ==== // All errors // naked continue not allowed @@ -16,12 +18,16 @@ tests/cases/conformance/statements/continueStatements/invalidForContinueStatemen // non-existent label ONE: + ~~~ +!!! error TS7028: Unused label. for(;;) continue TWO; ~~~~~~~~~~~~~ !!! error TS1115: A 'continue' statement can only jump to a label of an enclosing iteration statement. // continue from inside function TWO: + ~~~ +!!! error TS7027: Unreachable code detected. for(;;) { var x = () => { continue TWO; diff --git a/tests/baselines/reference/invalidForInBreakStatements.errors.txt b/tests/baselines/reference/invalidForInBreakStatements.errors.txt index d83304ab1c6..a575970ff88 100644 --- a/tests/baselines/reference/invalidForInBreakStatements.errors.txt +++ b/tests/baselines/reference/invalidForInBreakStatements.errors.txt @@ -1,12 +1,17 @@ tests/cases/conformance/statements/breakStatements/invalidForInBreakStatements.ts(4,1): error TS1105: A 'break' statement can only be used within an enclosing iteration or switch statement. +tests/cases/conformance/statements/breakStatements/invalidForInBreakStatements.ts(7,1): error TS7028: Unused label. tests/cases/conformance/statements/breakStatements/invalidForInBreakStatements.ts(8,19): error TS1116: A 'break' statement can only jump to a label of an enclosing statement. +tests/cases/conformance/statements/breakStatements/invalidForInBreakStatements.ts(11,1): error TS7028: Unused label. tests/cases/conformance/statements/breakStatements/invalidForInBreakStatements.ts(14,9): error TS1107: Jump target cannot cross function boundary. +tests/cases/conformance/statements/breakStatements/invalidForInBreakStatements.ts(18,1): error TS7028: Unused label. tests/cases/conformance/statements/breakStatements/invalidForInBreakStatements.ts(21,9): error TS1107: Jump target cannot cross function boundary. tests/cases/conformance/statements/breakStatements/invalidForInBreakStatements.ts(27,5): error TS1116: A 'break' statement can only jump to a label of an enclosing statement. +tests/cases/conformance/statements/breakStatements/invalidForInBreakStatements.ts(28,5): error TS7028: Unused label. +tests/cases/conformance/statements/breakStatements/invalidForInBreakStatements.ts(33,1): error TS7028: Unused label. tests/cases/conformance/statements/breakStatements/invalidForInBreakStatements.ts(37,5): error TS1116: A 'break' statement can only jump to a label of an enclosing statement. -==== tests/cases/conformance/statements/breakStatements/invalidForInBreakStatements.ts (6 errors) ==== +==== tests/cases/conformance/statements/breakStatements/invalidForInBreakStatements.ts (11 errors) ==== // All errors // naked break not allowed @@ -16,12 +21,16 @@ tests/cases/conformance/statements/breakStatements/invalidForInBreakStatements.t // non-existent label ONE: + ~~~ +!!! error TS7028: Unused label. for (var x in {}) break TWO; ~~~~~~~~~~ !!! error TS1116: A 'break' statement can only jump to a label of an enclosing statement. // break from inside function TWO: + ~~~ +!!! error TS7028: Unused label. for (var x in {}) { var fn = () => { break TWO; @@ -31,6 +40,8 @@ tests/cases/conformance/statements/breakStatements/invalidForInBreakStatements.t } THREE: + ~~~~~ +!!! error TS7028: Unused label. for (var x in {}) { var fn = function () { break THREE; @@ -45,11 +56,15 @@ tests/cases/conformance/statements/breakStatements/invalidForInBreakStatements.t ~~~~~~~~~~~ !!! error TS1116: A 'break' statement can only jump to a label of an enclosing statement. FIVE: + ~~~~ +!!! error TS7028: Unused label. for (var x in {}) { } } // label on non-loop statement NINE: + ~~~~ +!!! error TS7028: Unused label. var y = 12; for (var x in {}) { diff --git a/tests/baselines/reference/invalidForInContinueStatements.errors.txt b/tests/baselines/reference/invalidForInContinueStatements.errors.txt index 7353a22d9cd..15b515742a9 100644 --- a/tests/baselines/reference/invalidForInContinueStatements.errors.txt +++ b/tests/baselines/reference/invalidForInContinueStatements.errors.txt @@ -1,12 +1,17 @@ tests/cases/conformance/statements/continueStatements/invalidForInContinueStatements.ts(4,1): error TS1104: A 'continue' statement can only be used within an enclosing iteration statement. +tests/cases/conformance/statements/continueStatements/invalidForInContinueStatements.ts(7,1): error TS7028: Unused label. tests/cases/conformance/statements/continueStatements/invalidForInContinueStatements.ts(8,19): error TS1115: A 'continue' statement can only jump to a label of an enclosing iteration statement. +tests/cases/conformance/statements/continueStatements/invalidForInContinueStatements.ts(11,1): error TS7028: Unused label. tests/cases/conformance/statements/continueStatements/invalidForInContinueStatements.ts(14,9): error TS1107: Jump target cannot cross function boundary. +tests/cases/conformance/statements/continueStatements/invalidForInContinueStatements.ts(18,1): error TS7028: Unused label. tests/cases/conformance/statements/continueStatements/invalidForInContinueStatements.ts(21,9): error TS1107: Jump target cannot cross function boundary. tests/cases/conformance/statements/continueStatements/invalidForInContinueStatements.ts(27,5): error TS1115: A 'continue' statement can only jump to a label of an enclosing iteration statement. +tests/cases/conformance/statements/continueStatements/invalidForInContinueStatements.ts(28,5): error TS7028: Unused label. +tests/cases/conformance/statements/continueStatements/invalidForInContinueStatements.ts(33,1): error TS7028: Unused label. tests/cases/conformance/statements/continueStatements/invalidForInContinueStatements.ts(37,5): error TS1115: A 'continue' statement can only jump to a label of an enclosing iteration statement. -==== tests/cases/conformance/statements/continueStatements/invalidForInContinueStatements.ts (6 errors) ==== +==== tests/cases/conformance/statements/continueStatements/invalidForInContinueStatements.ts (11 errors) ==== // All errors // naked continue not allowed @@ -16,12 +21,16 @@ tests/cases/conformance/statements/continueStatements/invalidForInContinueStatem // non-existent label ONE: + ~~~ +!!! error TS7028: Unused label. for (var x in {}) continue TWO; ~~~~~~~~~~~~~ !!! error TS1115: A 'continue' statement can only jump to a label of an enclosing iteration statement. // continue from inside function TWO: + ~~~ +!!! error TS7028: Unused label. for (var x in {}) { var fn = () => { continue TWO; @@ -31,6 +40,8 @@ tests/cases/conformance/statements/continueStatements/invalidForInContinueStatem } THREE: + ~~~~~ +!!! error TS7028: Unused label. for (var x in {}) { var fn = function () { continue THREE; @@ -45,11 +56,15 @@ tests/cases/conformance/statements/continueStatements/invalidForInContinueStatem ~~~~~~~~~~~~~~ !!! error TS1115: A 'continue' statement can only jump to a label of an enclosing iteration statement. FIVE: + ~~~~ +!!! error TS7028: Unused label. for (var x in {}) { } } // label on non-loop statement NINE: + ~~~~ +!!! error TS7028: Unused label. var y = 12; for (var x in {}) { diff --git a/tests/baselines/reference/invalidThrowStatement.errors.txt b/tests/baselines/reference/invalidThrowStatement.errors.txt index b30549a217c..d72fd7e2acd 100644 --- a/tests/baselines/reference/invalidThrowStatement.errors.txt +++ b/tests/baselines/reference/invalidThrowStatement.errors.txt @@ -1,8 +1,9 @@ tests/cases/conformance/statements/throwStatements/invalidThrowStatement.ts(1,6): error TS1109: Expression expected. tests/cases/conformance/statements/throwStatements/invalidThrowStatement.ts(3,1): error TS1128: Declaration or statement expected. +tests/cases/conformance/statements/throwStatements/invalidThrowStatement.ts(3,8): error TS7027: Unreachable code detected. -==== tests/cases/conformance/statements/throwStatements/invalidThrowStatement.ts (2 errors) ==== +==== tests/cases/conformance/statements/throwStatements/invalidThrowStatement.ts (3 errors) ==== throw; ~ !!! error TS1109: Expression expected. @@ -10,4 +11,6 @@ tests/cases/conformance/statements/throwStatements/invalidThrowStatement.ts(3,1) export throw null; ~~~~~~ !!! error TS1128: Declaration or statement expected. + ~~~~~ +!!! error TS7027: Unreachable code detected. \ No newline at end of file diff --git a/tests/baselines/reference/invalidWhileBreakStatements.errors.txt b/tests/baselines/reference/invalidWhileBreakStatements.errors.txt index 54adc2856d7..7d4f86b3e9d 100644 --- a/tests/baselines/reference/invalidWhileBreakStatements.errors.txt +++ b/tests/baselines/reference/invalidWhileBreakStatements.errors.txt @@ -1,12 +1,14 @@ tests/cases/conformance/statements/breakStatements/invalidWhileBreakStatements.ts(4,1): error TS1105: A 'break' statement can only be used within an enclosing iteration or switch statement. +tests/cases/conformance/statements/breakStatements/invalidWhileBreakStatements.ts(7,1): error TS7028: Unused label. tests/cases/conformance/statements/breakStatements/invalidWhileBreakStatements.ts(8,14): error TS1116: A 'break' statement can only jump to a label of an enclosing statement. +tests/cases/conformance/statements/breakStatements/invalidWhileBreakStatements.ts(11,1): error TS7027: Unreachable code detected. tests/cases/conformance/statements/breakStatements/invalidWhileBreakStatements.ts(14,9): error TS1107: Jump target cannot cross function boundary. tests/cases/conformance/statements/breakStatements/invalidWhileBreakStatements.ts(21,9): error TS1107: Jump target cannot cross function boundary. tests/cases/conformance/statements/breakStatements/invalidWhileBreakStatements.ts(27,5): error TS1116: A 'break' statement can only jump to a label of an enclosing statement. tests/cases/conformance/statements/breakStatements/invalidWhileBreakStatements.ts(37,5): error TS1116: A 'break' statement can only jump to a label of an enclosing statement. -==== tests/cases/conformance/statements/breakStatements/invalidWhileBreakStatements.ts (6 errors) ==== +==== tests/cases/conformance/statements/breakStatements/invalidWhileBreakStatements.ts (8 errors) ==== // All errors // naked break not allowed @@ -16,12 +18,16 @@ tests/cases/conformance/statements/breakStatements/invalidWhileBreakStatements.t // non-existent label ONE: + ~~~ +!!! error TS7028: Unused label. while (true) break TWO; ~~~~~~~~~~ !!! error TS1116: A 'break' statement can only jump to a label of an enclosing statement. // break from inside function TWO: + ~~~ +!!! error TS7027: Unreachable code detected. while (true){ var x = () => { break TWO; diff --git a/tests/baselines/reference/invalidWhileContinueStatements.errors.txt b/tests/baselines/reference/invalidWhileContinueStatements.errors.txt index 462b244efd4..fdc84d84f2e 100644 --- a/tests/baselines/reference/invalidWhileContinueStatements.errors.txt +++ b/tests/baselines/reference/invalidWhileContinueStatements.errors.txt @@ -1,12 +1,14 @@ tests/cases/conformance/statements/continueStatements/invalidWhileContinueStatements.ts(4,1): error TS1104: A 'continue' statement can only be used within an enclosing iteration statement. +tests/cases/conformance/statements/continueStatements/invalidWhileContinueStatements.ts(7,1): error TS7028: Unused label. tests/cases/conformance/statements/continueStatements/invalidWhileContinueStatements.ts(8,14): error TS1115: A 'continue' statement can only jump to a label of an enclosing iteration statement. +tests/cases/conformance/statements/continueStatements/invalidWhileContinueStatements.ts(11,1): error TS7027: Unreachable code detected. tests/cases/conformance/statements/continueStatements/invalidWhileContinueStatements.ts(14,9): error TS1107: Jump target cannot cross function boundary. tests/cases/conformance/statements/continueStatements/invalidWhileContinueStatements.ts(21,9): error TS1107: Jump target cannot cross function boundary. tests/cases/conformance/statements/continueStatements/invalidWhileContinueStatements.ts(27,5): error TS1115: A 'continue' statement can only jump to a label of an enclosing iteration statement. tests/cases/conformance/statements/continueStatements/invalidWhileContinueStatements.ts(37,5): error TS1115: A 'continue' statement can only jump to a label of an enclosing iteration statement. -==== tests/cases/conformance/statements/continueStatements/invalidWhileContinueStatements.ts (6 errors) ==== +==== tests/cases/conformance/statements/continueStatements/invalidWhileContinueStatements.ts (8 errors) ==== // All errors // naked continue not allowed @@ -16,12 +18,16 @@ tests/cases/conformance/statements/continueStatements/invalidWhileContinueStatem // non-existent label ONE: + ~~~ +!!! error TS7028: Unused label. while (true) continue TWO; ~~~~~~~~~~~~~ !!! error TS1115: A 'continue' statement can only jump to a label of an enclosing iteration statement. // continue from inside function TWO: + ~~~ +!!! error TS7027: Unreachable code detected. while (true){ var x = () => { continue TWO; diff --git a/tests/baselines/reference/letAndVarRedeclaration.errors.txt b/tests/baselines/reference/letAndVarRedeclaration.errors.txt index 48704f61040..3c523154c3f 100644 --- a/tests/baselines/reference/letAndVarRedeclaration.errors.txt +++ b/tests/baselines/reference/letAndVarRedeclaration.errors.txt @@ -17,11 +17,12 @@ tests/cases/compiler/letAndVarRedeclaration.ts(38,5): error TS2451: Cannot redec tests/cases/compiler/letAndVarRedeclaration.ts(39,10): error TS2451: Cannot redeclare block-scoped variable 'x11'. tests/cases/compiler/letAndVarRedeclaration.ts(43,9): error TS2451: Cannot redeclare block-scoped variable 'x11'. tests/cases/compiler/letAndVarRedeclaration.ts(44,14): error TS2451: Cannot redeclare block-scoped variable 'x11'. +tests/cases/compiler/letAndVarRedeclaration.ts(48,1): error TS7027: Unreachable code detected. tests/cases/compiler/letAndVarRedeclaration.ts(49,9): error TS2451: Cannot redeclare block-scoped variable 'x11'. tests/cases/compiler/letAndVarRedeclaration.ts(50,14): error TS2451: Cannot redeclare block-scoped variable 'x11'. -==== tests/cases/compiler/letAndVarRedeclaration.ts (21 errors) ==== +==== tests/cases/compiler/letAndVarRedeclaration.ts (22 errors) ==== let e0 ~~ @@ -108,6 +109,8 @@ tests/cases/compiler/letAndVarRedeclaration.ts(50,14): error TS2451: Cannot rede } module M2 { + ~~~~~~ +!!! error TS7027: Unreachable code detected. let x11; ~~~ !!! error TS2451: Cannot redeclare block-scoped variable 'x11'. diff --git a/tests/baselines/reference/letDeclarations-invalidContexts.errors.txt b/tests/baselines/reference/letDeclarations-invalidContexts.errors.txt index 1ece1f31433..f3144b52500 100644 --- a/tests/baselines/reference/letDeclarations-invalidContexts.errors.txt +++ b/tests/baselines/reference/letDeclarations-invalidContexts.errors.txt @@ -1,6 +1,8 @@ tests/cases/compiler/letDeclarations-invalidContexts.ts(4,5): error TS1157: 'let' declarations can only be declared inside a block. +tests/cases/compiler/letDeclarations-invalidContexts.ts(6,5): error TS7027: Unreachable code detected. tests/cases/compiler/letDeclarations-invalidContexts.ts(6,5): error TS1157: 'let' declarations can only be declared inside a block. tests/cases/compiler/letDeclarations-invalidContexts.ts(9,5): error TS1157: 'let' declarations can only be declared inside a block. +tests/cases/compiler/letDeclarations-invalidContexts.ts(11,1): error TS7027: Unreachable code detected. tests/cases/compiler/letDeclarations-invalidContexts.ts(12,5): error TS1157: 'let' declarations can only be declared inside a block. tests/cases/compiler/letDeclarations-invalidContexts.ts(16,7): error TS2410: All symbols within a 'with' block will be resolved to 'any'. tests/cases/compiler/letDeclarations-invalidContexts.ts(20,5): error TS1157: 'let' declarations can only be declared inside a block. @@ -9,7 +11,7 @@ tests/cases/compiler/letDeclarations-invalidContexts.ts(26,12): error TS1157: 'l tests/cases/compiler/letDeclarations-invalidContexts.ts(29,29): error TS1157: 'let' declarations can only be declared inside a block. -==== tests/cases/compiler/letDeclarations-invalidContexts.ts (9 errors) ==== +==== tests/cases/compiler/letDeclarations-invalidContexts.ts (11 errors) ==== // Errors, let must be defined inside a block if (true) @@ -18,6 +20,8 @@ tests/cases/compiler/letDeclarations-invalidContexts.ts(29,29): error TS1157: 'l !!! error TS1157: 'let' declarations can only be declared inside a block. else let l2 = 0; + ~~~ +!!! error TS7027: Unreachable code detected. ~~~~~~~~~~~ !!! error TS1157: 'let' declarations can only be declared inside a block. @@ -27,6 +31,8 @@ tests/cases/compiler/letDeclarations-invalidContexts.ts(29,29): error TS1157: 'l !!! error TS1157: 'let' declarations can only be declared inside a block. do + ~~ +!!! error TS7027: Unreachable code detected. let l4 = 0; ~~~~~~~~~~~ !!! error TS1157: 'let' declarations can only be declared inside a block. diff --git a/tests/baselines/reference/letDeclarations-scopes.errors.txt b/tests/baselines/reference/letDeclarations-scopes.errors.txt index 5c89ea98049..49072f30e98 100644 --- a/tests/baselines/reference/letDeclarations-scopes.errors.txt +++ b/tests/baselines/reference/letDeclarations-scopes.errors.txt @@ -1,7 +1,10 @@ +tests/cases/compiler/letDeclarations-scopes.ts(13,5): error TS7027: Unreachable code detected. +tests/cases/compiler/letDeclarations-scopes.ts(22,1): error TS7027: Unreachable code detected. tests/cases/compiler/letDeclarations-scopes.ts(28,7): error TS2410: All symbols within a 'with' block will be resolved to 'any'. +tests/cases/compiler/letDeclarations-scopes.ts(120,5): error TS7028: Unused label. -==== tests/cases/compiler/letDeclarations-scopes.ts (1 errors) ==== +==== tests/cases/compiler/letDeclarations-scopes.ts (4 errors) ==== // global let l = "string"; @@ -15,6 +18,8 @@ tests/cases/compiler/letDeclarations-scopes.ts(28,7): error TS2410: All symbols } else { let l = 0; + ~~~ +!!! error TS7027: Unreachable code detected. n = l; } @@ -24,6 +29,8 @@ tests/cases/compiler/letDeclarations-scopes.ts(28,7): error TS2410: All symbols } do { + ~~ +!!! error TS7027: Unreachable code detected. let l = 0; n = l; } while (true); @@ -124,6 +131,8 @@ tests/cases/compiler/letDeclarations-scopes.ts(28,7): error TS2410: All symbols } lable: let l2 = 0; + ~~~~~ +!!! error TS7028: Unused label. } // methods diff --git a/tests/baselines/reference/letDeclarations-validContexts.errors.txt b/tests/baselines/reference/letDeclarations-validContexts.errors.txt index 3f3b7a2634f..f5e8022191b 100644 --- a/tests/baselines/reference/letDeclarations-validContexts.errors.txt +++ b/tests/baselines/reference/letDeclarations-validContexts.errors.txt @@ -1,7 +1,13 @@ +tests/cases/compiler/letDeclarations-validContexts.ts(8,5): error TS7027: Unreachable code detected. +tests/cases/compiler/letDeclarations-validContexts.ts(15,1): error TS7027: Unreachable code detected. tests/cases/compiler/letDeclarations-validContexts.ts(20,7): error TS2410: All symbols within a 'with' block will be resolved to 'any'. +tests/cases/compiler/letDeclarations-validContexts.ts(132,5): error TS7028: Unused label. +tests/cases/compiler/letDeclarations-validContexts.ts(134,9): error TS7028: Unused label. +tests/cases/compiler/letDeclarations-validContexts.ts(139,5): error TS7028: Unused label. +tests/cases/compiler/letDeclarations-validContexts.ts(141,9): error TS7028: Unused label. -==== tests/cases/compiler/letDeclarations-validContexts.ts (1 errors) ==== +==== tests/cases/compiler/letDeclarations-validContexts.ts (7 errors) ==== // Control flow statements with blocks @@ -10,6 +16,8 @@ tests/cases/compiler/letDeclarations-validContexts.ts(20,7): error TS2410: All s } else { let l2 = 0; + ~~~ +!!! error TS7027: Unreachable code detected. } while (true) { @@ -17,6 +25,8 @@ tests/cases/compiler/letDeclarations-validContexts.ts(20,7): error TS2410: All s } do { + ~~ +!!! error TS7027: Unreachable code detected. let l4 = 0; } while (true); @@ -136,14 +146,22 @@ tests/cases/compiler/letDeclarations-validContexts.ts(20,7): error TS2410: All s function f3() { label: let l32 = 0; + ~~~~~ +!!! error TS7028: Unused label. { label2: let l33 = 0; + ~~~~~~ +!!! error TS7028: Unused label. } } module m3 { label: let l34 = 0; + ~~~~~ +!!! error TS7028: Unused label. { label2: let l35 = 0; + ~~~~~~ +!!! error TS7028: Unused label. } } \ No newline at end of file diff --git a/tests/baselines/reference/localTypes4.errors.txt b/tests/baselines/reference/localTypes4.errors.txt index cad9d30c933..d6a3f0ce699 100644 --- a/tests/baselines/reference/localTypes4.errors.txt +++ b/tests/baselines/reference/localTypes4.errors.txt @@ -2,9 +2,10 @@ tests/cases/conformance/types/localTypes/localTypes4.ts(10,19): error TS2304: Ca tests/cases/conformance/types/localTypes/localTypes4.ts(10,23): error TS2304: Cannot find name 'T'. tests/cases/conformance/types/localTypes/localTypes4.ts(18,16): error TS2300: Duplicate identifier 'T'. tests/cases/conformance/types/localTypes/localTypes4.ts(19,19): error TS2300: Duplicate identifier 'T'. +tests/cases/conformance/types/localTypes/localTypes4.ts(35,9): error TS7027: Unreachable code detected. -==== tests/cases/conformance/types/localTypes/localTypes4.ts (4 errors) ==== +==== tests/cases/conformance/types/localTypes/localTypes4.ts (5 errors) ==== function f1() { // Type parameters are in scope in parameters and return types function f(x: T): T { @@ -48,6 +49,8 @@ tests/cases/conformance/types/localTypes/localTypes4.ts(19,19): error TS2300: Du } else { v.x = 20; + ~ +!!! error TS7027: Unreachable code detected. } } \ No newline at end of file diff --git a/tests/baselines/reference/null.errors.txt b/tests/baselines/reference/null.errors.txt new file mode 100644 index 00000000000..b516720b241 --- /dev/null +++ b/tests/baselines/reference/null.errors.txt @@ -0,0 +1,30 @@ +tests/cases/compiler/null.ts(8,5): error TS7027: Unreachable code detected. +tests/cases/compiler/null.ts(12,5): error TS7027: Unreachable code detected. + + +==== tests/cases/compiler/null.ts (2 errors) ==== + var x=null; + var y=3+x; + var z=3+null; + class C { + } + function f() { + return null; + return new C(); + ~~~~~~ +!!! error TS7027: Unreachable code detected. + } + function g() { + return null; + return 3; + ~~~~~~ +!!! error TS7027: Unreachable code detected. + } + interface I { + x:any; + y:number; + } + var w:I={x:null,y:3}; + + + \ No newline at end of file diff --git a/tests/baselines/reference/null.symbols b/tests/baselines/reference/null.symbols deleted file mode 100644 index 148cd1586b2..00000000000 --- a/tests/baselines/reference/null.symbols +++ /dev/null @@ -1,44 +0,0 @@ -=== tests/cases/compiler/null.ts === -var x=null; ->x : Symbol(x, Decl(null.ts, 0, 3)) - -var y=3+x; ->y : Symbol(y, Decl(null.ts, 1, 3)) ->x : Symbol(x, Decl(null.ts, 0, 3)) - -var z=3+null; ->z : Symbol(z, Decl(null.ts, 2, 3)) - -class C { ->C : Symbol(C, Decl(null.ts, 2, 13)) -} -function f() { ->f : Symbol(f, Decl(null.ts, 4, 1)) - - return null; - return new C(); ->C : Symbol(C, Decl(null.ts, 2, 13)) -} -function g() { ->g : Symbol(g, Decl(null.ts, 8, 1)) - - return null; - return 3; -} -interface I { ->I : Symbol(I, Decl(null.ts, 12, 1)) - - x:any; ->x : Symbol(x, Decl(null.ts, 13, 13)) - - y:number; ->y : Symbol(y, Decl(null.ts, 14, 10)) -} -var w:I={x:null,y:3}; ->w : Symbol(w, Decl(null.ts, 17, 3)) ->I : Symbol(I, Decl(null.ts, 12, 1)) ->x : Symbol(x, Decl(null.ts, 17, 9)) ->y : Symbol(y, Decl(null.ts, 17, 16)) - - - diff --git a/tests/baselines/reference/null.types b/tests/baselines/reference/null.types deleted file mode 100644 index 7df551b1bde..00000000000 --- a/tests/baselines/reference/null.types +++ /dev/null @@ -1,59 +0,0 @@ -=== tests/cases/compiler/null.ts === -var x=null; ->x : any ->null : null - -var y=3+x; ->y : any ->3+x : any ->3 : number ->x : any - -var z=3+null; ->z : number ->3+null : number ->3 : number ->null : null - -class C { ->C : C -} -function f() { ->f : () => C - - return null; ->null : null - - return new C(); ->new C() : C ->C : typeof C -} -function g() { ->g : () => number - - return null; ->null : null - - return 3; ->3 : number -} -interface I { ->I : I - - x:any; ->x : any - - y:number; ->y : number -} -var w:I={x:null,y:3}; ->w : I ->I : I ->{x:null,y:3} : { x: null; y: number; } ->x : null ->null : null ->y : number ->3 : number - - - diff --git a/tests/baselines/reference/overloadOnConstAsTypeAnnotation.errors.txt b/tests/baselines/reference/overloadOnConstAsTypeAnnotation.errors.txt index 079951880ab..48f1ce1bd13 100644 --- a/tests/baselines/reference/overloadOnConstAsTypeAnnotation.errors.txt +++ b/tests/baselines/reference/overloadOnConstAsTypeAnnotation.errors.txt @@ -1,10 +1,13 @@ tests/cases/compiler/overloadOnConstAsTypeAnnotation.ts(1,8): error TS2382: Specialized overload signature is not assignable to any non-specialized signature. tests/cases/compiler/overloadOnConstAsTypeAnnotation.ts(1,37): error TS1005: ';' expected. +tests/cases/compiler/overloadOnConstAsTypeAnnotation.ts(1,53): error TS7027: Unreachable code detected. -==== tests/cases/compiler/overloadOnConstAsTypeAnnotation.ts (2 errors) ==== +==== tests/cases/compiler/overloadOnConstAsTypeAnnotation.ts (3 errors) ==== var f: (x: 'hi') => number = ('hi') => { return 1; }; ~~~~~~~~~~~~~~~~~~~ !!! error TS2382: Specialized overload signature is not assignable to any non-specialized signature. ~~ -!!! error TS1005: ';' expected. \ No newline at end of file +!!! error TS1005: ';' expected. + ~ +!!! error TS7027: Unreachable code detected. \ No newline at end of file diff --git a/tests/baselines/reference/parser10.1.1-8gs.errors.txt b/tests/baselines/reference/parser10.1.1-8gs.errors.txt index 185665d23da..c321ca1fff8 100644 --- a/tests/baselines/reference/parser10.1.1-8gs.errors.txt +++ b/tests/baselines/reference/parser10.1.1-8gs.errors.txt @@ -1,8 +1,9 @@ tests/cases/conformance/parser/ecmascript5/parser10.1.1-8gs.ts(16,7): error TS2304: Cannot find name 'NotEarlyError'. +tests/cases/conformance/parser/ecmascript5/parser10.1.1-8gs.ts(17,1): error TS7027: Unreachable code detected. tests/cases/conformance/parser/ecmascript5/parser10.1.1-8gs.ts(17,5): error TS1212: Identifier expected. 'public' is a reserved word in strict mode -==== tests/cases/conformance/parser/ecmascript5/parser10.1.1-8gs.ts (2 errors) ==== +==== tests/cases/conformance/parser/ecmascript5/parser10.1.1-8gs.ts (3 errors) ==== /// Copyright (c) 2012 Ecma International. All rights reserved. /// Ecma International makes this code available under the terms and conditions set /// forth on http://hg.ecmascript.org/tests/test262/raw-file/tip/LICENSE (the @@ -22,6 +23,8 @@ tests/cases/conformance/parser/ecmascript5/parser10.1.1-8gs.ts(17,5): error TS12 ~~~~~~~~~~~~~ !!! error TS2304: Cannot find name 'NotEarlyError'. var public = 1; + ~~~ +!!! error TS7027: Unreachable code detected. ~~~~~~ !!! error TS1212: Identifier expected. 'public' is a reserved word in strict mode \ No newline at end of file diff --git a/tests/baselines/reference/parser768531.errors.txt b/tests/baselines/reference/parser768531.errors.txt new file mode 100644 index 00000000000..8298431e0e0 --- /dev/null +++ b/tests/baselines/reference/parser768531.errors.txt @@ -0,0 +1,8 @@ +tests/cases/conformance/parser/ecmascript5/Fuzz/parser768531.ts(1,2): error TS7028: Unused label. + + +==== tests/cases/conformance/parser/ecmascript5/Fuzz/parser768531.ts (1 errors) ==== + {a: 3} + ~ +!!! error TS7028: Unused label. + /x/ \ No newline at end of file diff --git a/tests/baselines/reference/parser768531.symbols b/tests/baselines/reference/parser768531.symbols deleted file mode 100644 index 2da2298c8e2..00000000000 --- a/tests/baselines/reference/parser768531.symbols +++ /dev/null @@ -1,4 +0,0 @@ -=== tests/cases/conformance/parser/ecmascript5/Fuzz/parser768531.ts === -{a: 3} -No type information for this code./x/ -No type information for this code. \ No newline at end of file diff --git a/tests/baselines/reference/parser768531.types b/tests/baselines/reference/parser768531.types deleted file mode 100644 index f1bcedefae9..00000000000 --- a/tests/baselines/reference/parser768531.types +++ /dev/null @@ -1,8 +0,0 @@ -=== tests/cases/conformance/parser/ecmascript5/Fuzz/parser768531.ts === -{a: 3} ->a : any ->3 : number - -/x/ ->/x/ : RegExp - diff --git a/tests/baselines/reference/parserErrorRecovery_ModuleElement1.errors.txt b/tests/baselines/reference/parserErrorRecovery_ModuleElement1.errors.txt index 4b8be3e17ad..05b31b7af8e 100644 --- a/tests/baselines/reference/parserErrorRecovery_ModuleElement1.errors.txt +++ b/tests/baselines/reference/parserErrorRecovery_ModuleElement1.errors.txt @@ -1,13 +1,16 @@ tests/cases/conformance/parser/ecmascript5/ErrorRecovery/ModuleElements/parserErrorRecovery_ModuleElement1.ts(2,1): error TS1128: Declaration or statement expected. +tests/cases/conformance/parser/ecmascript5/ErrorRecovery/ModuleElements/parserErrorRecovery_ModuleElement1.ts(3,1): error TS7027: Unreachable code detected. tests/cases/conformance/parser/ecmascript5/ErrorRecovery/ModuleElements/parserErrorRecovery_ModuleElement1.ts(4,1): error TS1128: Declaration or statement expected. -==== tests/cases/conformance/parser/ecmascript5/ErrorRecovery/ModuleElements/parserErrorRecovery_ModuleElement1.ts (2 errors) ==== +==== tests/cases/conformance/parser/ecmascript5/ErrorRecovery/ModuleElements/parserErrorRecovery_ModuleElement1.ts (3 errors) ==== return foo; } ~ !!! error TS1128: Declaration or statement expected. return bar; + ~~~~~~ +!!! error TS7027: Unreachable code detected. } ~ !!! error TS1128: Declaration or statement expected. \ No newline at end of file diff --git a/tests/baselines/reference/parserLabeledStatement1.d.errors.txt b/tests/baselines/reference/parserLabeledStatement1.d.errors.txt index 11de61548a3..2ce51b0bb4c 100644 --- a/tests/baselines/reference/parserLabeledStatement1.d.errors.txt +++ b/tests/baselines/reference/parserLabeledStatement1.d.errors.txt @@ -1,11 +1,14 @@ tests/cases/conformance/parser/ecmascript5/Statements/parserLabeledStatement1.d.ts(1,1): error TS1036: Statements are not allowed in ambient contexts. +tests/cases/conformance/parser/ecmascript5/Statements/parserLabeledStatement1.d.ts(1,1): error TS7028: Unused label. tests/cases/conformance/parser/ecmascript5/Statements/parserLabeledStatement1.d.ts(2,3): error TS2304: Cannot find name 'bar'. -==== tests/cases/conformance/parser/ecmascript5/Statements/parserLabeledStatement1.d.ts (2 errors) ==== +==== tests/cases/conformance/parser/ecmascript5/Statements/parserLabeledStatement1.d.ts (3 errors) ==== foo: ~~~ !!! error TS1036: Statements are not allowed in ambient contexts. + ~~~ +!!! error TS7028: Unused label. bar(); ~~~ !!! error TS2304: Cannot find name 'bar'. \ No newline at end of file diff --git a/tests/baselines/reference/parser_breakTarget3.errors.txt b/tests/baselines/reference/parser_breakTarget3.errors.txt new file mode 100644 index 00000000000..ad3123eda79 --- /dev/null +++ b/tests/baselines/reference/parser_breakTarget3.errors.txt @@ -0,0 +1,11 @@ +tests/cases/conformance/parser/ecmascript5/Statements/BreakStatements/parser_breakTarget3.ts(2,1): error TS7028: Unused label. + + +==== tests/cases/conformance/parser/ecmascript5/Statements/BreakStatements/parser_breakTarget3.ts (1 errors) ==== + target1: + target2: + ~~~~~~~ +!!! error TS7028: Unused label. + while (true) { + break target1; + } \ No newline at end of file diff --git a/tests/baselines/reference/parser_breakTarget3.symbols b/tests/baselines/reference/parser_breakTarget3.symbols deleted file mode 100644 index 99ec413987a..00000000000 --- a/tests/baselines/reference/parser_breakTarget3.symbols +++ /dev/null @@ -1,7 +0,0 @@ -=== tests/cases/conformance/parser/ecmascript5/Statements/BreakStatements/parser_breakTarget3.ts === -target1: -No type information for this code.target2: -No type information for this code.while (true) { -No type information for this code. break target1; -No type information for this code.} -No type information for this code. \ No newline at end of file diff --git a/tests/baselines/reference/parser_breakTarget3.types b/tests/baselines/reference/parser_breakTarget3.types deleted file mode 100644 index 7cdcb74d7da..00000000000 --- a/tests/baselines/reference/parser_breakTarget3.types +++ /dev/null @@ -1,13 +0,0 @@ -=== tests/cases/conformance/parser/ecmascript5/Statements/BreakStatements/parser_breakTarget3.ts === -target1: ->target1 : any - -target2: ->target2 : any - -while (true) { ->true : boolean - - break target1; ->target1 : any -} diff --git a/tests/baselines/reference/parser_breakTarget4.errors.txt b/tests/baselines/reference/parser_breakTarget4.errors.txt new file mode 100644 index 00000000000..8c61b20b0ed --- /dev/null +++ b/tests/baselines/reference/parser_breakTarget4.errors.txt @@ -0,0 +1,11 @@ +tests/cases/conformance/parser/ecmascript5/Statements/BreakStatements/parser_breakTarget4.ts(1,1): error TS7028: Unused label. + + +==== tests/cases/conformance/parser/ecmascript5/Statements/BreakStatements/parser_breakTarget4.ts (1 errors) ==== + target1: + ~~~~~~~ +!!! error TS7028: Unused label. + target2: + while (true) { + break target2; + } \ No newline at end of file diff --git a/tests/baselines/reference/parser_breakTarget4.symbols b/tests/baselines/reference/parser_breakTarget4.symbols deleted file mode 100644 index 042df67d9b2..00000000000 --- a/tests/baselines/reference/parser_breakTarget4.symbols +++ /dev/null @@ -1,7 +0,0 @@ -=== tests/cases/conformance/parser/ecmascript5/Statements/BreakStatements/parser_breakTarget4.ts === -target1: -No type information for this code.target2: -No type information for this code.while (true) { -No type information for this code. break target2; -No type information for this code.} -No type information for this code. \ No newline at end of file diff --git a/tests/baselines/reference/parser_breakTarget4.types b/tests/baselines/reference/parser_breakTarget4.types deleted file mode 100644 index 7315175800e..00000000000 --- a/tests/baselines/reference/parser_breakTarget4.types +++ /dev/null @@ -1,13 +0,0 @@ -=== tests/cases/conformance/parser/ecmascript5/Statements/BreakStatements/parser_breakTarget4.ts === -target1: ->target1 : any - -target2: ->target2 : any - -while (true) { ->true : boolean - - break target2; ->target2 : any -} diff --git a/tests/baselines/reference/parser_breakTarget5.errors.txt b/tests/baselines/reference/parser_breakTarget5.errors.txt index 8221cbebb4c..5943649c97b 100644 --- a/tests/baselines/reference/parser_breakTarget5.errors.txt +++ b/tests/baselines/reference/parser_breakTarget5.errors.txt @@ -1,8 +1,11 @@ +tests/cases/conformance/parser/ecmascript5/Statements/BreakStatements/parser_breakTarget5.ts(1,1): error TS7028: Unused label. tests/cases/conformance/parser/ecmascript5/Statements/BreakStatements/parser_breakTarget5.ts(5,7): error TS1107: Jump target cannot cross function boundary. -==== tests/cases/conformance/parser/ecmascript5/Statements/BreakStatements/parser_breakTarget5.ts (1 errors) ==== +==== tests/cases/conformance/parser/ecmascript5/Statements/BreakStatements/parser_breakTarget5.ts (2 errors) ==== target: + ~~~~~~ +!!! error TS7028: Unused label. while (true) { function f() { while (true) { diff --git a/tests/baselines/reference/parser_continueNotInIterationStatement4.errors.txt b/tests/baselines/reference/parser_continueNotInIterationStatement4.errors.txt index efade17a52a..94392259568 100644 --- a/tests/baselines/reference/parser_continueNotInIterationStatement4.errors.txt +++ b/tests/baselines/reference/parser_continueNotInIterationStatement4.errors.txt @@ -1,8 +1,11 @@ +tests/cases/conformance/parser/ecmascript5/Statements/ContinueStatements/parser_continueNotInIterationStatement4.ts(1,1): error TS7028: Unused label. tests/cases/conformance/parser/ecmascript5/Statements/ContinueStatements/parser_continueNotInIterationStatement4.ts(4,5): error TS1107: Jump target cannot cross function boundary. -==== tests/cases/conformance/parser/ecmascript5/Statements/ContinueStatements/parser_continueNotInIterationStatement4.ts (1 errors) ==== +==== tests/cases/conformance/parser/ecmascript5/Statements/ContinueStatements/parser_continueNotInIterationStatement4.ts (2 errors) ==== TWO: + ~~~ +!!! error TS7028: Unused label. while (true){ var x = () => { continue TWO; diff --git a/tests/baselines/reference/parser_continueTarget3.errors.txt b/tests/baselines/reference/parser_continueTarget3.errors.txt new file mode 100644 index 00000000000..4871cb275e7 --- /dev/null +++ b/tests/baselines/reference/parser_continueTarget3.errors.txt @@ -0,0 +1,11 @@ +tests/cases/conformance/parser/ecmascript5/Statements/ContinueStatements/parser_continueTarget3.ts(2,1): error TS7028: Unused label. + + +==== tests/cases/conformance/parser/ecmascript5/Statements/ContinueStatements/parser_continueTarget3.ts (1 errors) ==== + target1: + target2: + ~~~~~~~ +!!! error TS7028: Unused label. + while (true) { + continue target1; + } \ No newline at end of file diff --git a/tests/baselines/reference/parser_continueTarget3.symbols b/tests/baselines/reference/parser_continueTarget3.symbols deleted file mode 100644 index 2038671d215..00000000000 --- a/tests/baselines/reference/parser_continueTarget3.symbols +++ /dev/null @@ -1,7 +0,0 @@ -=== tests/cases/conformance/parser/ecmascript5/Statements/ContinueStatements/parser_continueTarget3.ts === -target1: -No type information for this code.target2: -No type information for this code.while (true) { -No type information for this code. continue target1; -No type information for this code.} -No type information for this code. \ No newline at end of file diff --git a/tests/baselines/reference/parser_continueTarget3.types b/tests/baselines/reference/parser_continueTarget3.types deleted file mode 100644 index 33c931c7959..00000000000 --- a/tests/baselines/reference/parser_continueTarget3.types +++ /dev/null @@ -1,13 +0,0 @@ -=== tests/cases/conformance/parser/ecmascript5/Statements/ContinueStatements/parser_continueTarget3.ts === -target1: ->target1 : any - -target2: ->target2 : any - -while (true) { ->true : boolean - - continue target1; ->target1 : any -} diff --git a/tests/baselines/reference/parser_continueTarget4.errors.txt b/tests/baselines/reference/parser_continueTarget4.errors.txt new file mode 100644 index 00000000000..6089ea60cf7 --- /dev/null +++ b/tests/baselines/reference/parser_continueTarget4.errors.txt @@ -0,0 +1,11 @@ +tests/cases/conformance/parser/ecmascript5/Statements/ContinueStatements/parser_continueTarget4.ts(1,1): error TS7028: Unused label. + + +==== tests/cases/conformance/parser/ecmascript5/Statements/ContinueStatements/parser_continueTarget4.ts (1 errors) ==== + target1: + ~~~~~~~ +!!! error TS7028: Unused label. + target2: + while (true) { + continue target2; + } \ No newline at end of file diff --git a/tests/baselines/reference/parser_continueTarget4.symbols b/tests/baselines/reference/parser_continueTarget4.symbols deleted file mode 100644 index 2b47099715e..00000000000 --- a/tests/baselines/reference/parser_continueTarget4.symbols +++ /dev/null @@ -1,7 +0,0 @@ -=== tests/cases/conformance/parser/ecmascript5/Statements/ContinueStatements/parser_continueTarget4.ts === -target1: -No type information for this code.target2: -No type information for this code.while (true) { -No type information for this code. continue target2; -No type information for this code.} -No type information for this code. \ No newline at end of file diff --git a/tests/baselines/reference/parser_continueTarget4.types b/tests/baselines/reference/parser_continueTarget4.types deleted file mode 100644 index cb0367283ce..00000000000 --- a/tests/baselines/reference/parser_continueTarget4.types +++ /dev/null @@ -1,13 +0,0 @@ -=== tests/cases/conformance/parser/ecmascript5/Statements/ContinueStatements/parser_continueTarget4.ts === -target1: ->target1 : any - -target2: ->target2 : any - -while (true) { ->true : boolean - - continue target2; ->target2 : any -} diff --git a/tests/baselines/reference/parser_continueTarget5.errors.txt b/tests/baselines/reference/parser_continueTarget5.errors.txt index ffeee7a07b3..b9b1f2edb94 100644 --- a/tests/baselines/reference/parser_continueTarget5.errors.txt +++ b/tests/baselines/reference/parser_continueTarget5.errors.txt @@ -1,8 +1,11 @@ +tests/cases/conformance/parser/ecmascript5/Statements/ContinueStatements/parser_continueTarget5.ts(1,1): error TS7028: Unused label. tests/cases/conformance/parser/ecmascript5/Statements/ContinueStatements/parser_continueTarget5.ts(5,7): error TS1107: Jump target cannot cross function boundary. -==== tests/cases/conformance/parser/ecmascript5/Statements/ContinueStatements/parser_continueTarget5.ts (1 errors) ==== +==== tests/cases/conformance/parser/ecmascript5/Statements/ContinueStatements/parser_continueTarget5.ts (2 errors) ==== target: + ~~~~~~ +!!! error TS7028: Unused label. while (true) { function f() { while (true) { diff --git a/tests/baselines/reference/parser_duplicateLabel1.errors.txt b/tests/baselines/reference/parser_duplicateLabel1.errors.txt index 4733a240e36..a4319aaa7b9 100644 --- a/tests/baselines/reference/parser_duplicateLabel1.errors.txt +++ b/tests/baselines/reference/parser_duplicateLabel1.errors.txt @@ -1,8 +1,11 @@ +tests/cases/conformance/parser/ecmascript5/Statements/LabeledStatements/parser_duplicateLabel1.ts(1,1): error TS7028: Unused label. tests/cases/conformance/parser/ecmascript5/Statements/LabeledStatements/parser_duplicateLabel1.ts(2,1): error TS1114: Duplicate label 'target' -==== tests/cases/conformance/parser/ecmascript5/Statements/LabeledStatements/parser_duplicateLabel1.ts (1 errors) ==== +==== tests/cases/conformance/parser/ecmascript5/Statements/LabeledStatements/parser_duplicateLabel1.ts (2 errors) ==== target: + ~~~~~~ +!!! error TS7028: Unused label. target: ~~~~~~ !!! error TS1114: Duplicate label 'target' diff --git a/tests/baselines/reference/parser_duplicateLabel2.errors.txt b/tests/baselines/reference/parser_duplicateLabel2.errors.txt index 92078593e47..123949fa5aa 100644 --- a/tests/baselines/reference/parser_duplicateLabel2.errors.txt +++ b/tests/baselines/reference/parser_duplicateLabel2.errors.txt @@ -1,8 +1,11 @@ +tests/cases/conformance/parser/ecmascript5/Statements/LabeledStatements/parser_duplicateLabel2.ts(1,1): error TS7028: Unused label. tests/cases/conformance/parser/ecmascript5/Statements/LabeledStatements/parser_duplicateLabel2.ts(3,3): error TS1114: Duplicate label 'target' -==== tests/cases/conformance/parser/ecmascript5/Statements/LabeledStatements/parser_duplicateLabel2.ts (1 errors) ==== +==== tests/cases/conformance/parser/ecmascript5/Statements/LabeledStatements/parser_duplicateLabel2.ts (2 errors) ==== target: + ~~~~~~ +!!! error TS7028: Unused label. while (true) { target: ~~~~~~ diff --git a/tests/baselines/reference/parser_duplicateLabel3.errors.txt b/tests/baselines/reference/parser_duplicateLabel3.errors.txt new file mode 100644 index 00000000000..a933588f538 --- /dev/null +++ b/tests/baselines/reference/parser_duplicateLabel3.errors.txt @@ -0,0 +1,17 @@ +tests/cases/conformance/parser/ecmascript5/Statements/LabeledStatements/parser_duplicateLabel3.ts(1,1): error TS7028: Unused label. +tests/cases/conformance/parser/ecmascript5/Statements/LabeledStatements/parser_duplicateLabel3.ts(4,5): error TS7028: Unused label. + + +==== tests/cases/conformance/parser/ecmascript5/Statements/LabeledStatements/parser_duplicateLabel3.ts (2 errors) ==== + target: + ~~~~~~ +!!! error TS7028: Unused label. + while (true) { + function f() { + target: + ~~~~~~ +!!! error TS7028: Unused label. + while (true) { + } + } + } \ No newline at end of file diff --git a/tests/baselines/reference/parser_duplicateLabel3.symbols b/tests/baselines/reference/parser_duplicateLabel3.symbols deleted file mode 100644 index 20627a0e2b8..00000000000 --- a/tests/baselines/reference/parser_duplicateLabel3.symbols +++ /dev/null @@ -1,11 +0,0 @@ -=== tests/cases/conformance/parser/ecmascript5/Statements/LabeledStatements/parser_duplicateLabel3.ts === -target: -while (true) { - function f() { ->f : Symbol(f, Decl(parser_duplicateLabel3.ts, 1, 14)) - - target: - while (true) { - } - } -} diff --git a/tests/baselines/reference/parser_duplicateLabel3.types b/tests/baselines/reference/parser_duplicateLabel3.types deleted file mode 100644 index 05cfe708161..00000000000 --- a/tests/baselines/reference/parser_duplicateLabel3.types +++ /dev/null @@ -1,18 +0,0 @@ -=== tests/cases/conformance/parser/ecmascript5/Statements/LabeledStatements/parser_duplicateLabel3.ts === -target: ->target : any - -while (true) { ->true : boolean - - function f() { ->f : () => void - - target: ->target : any - - while (true) { ->true : boolean - } - } -} diff --git a/tests/baselines/reference/parser_duplicateLabel4.errors.txt b/tests/baselines/reference/parser_duplicateLabel4.errors.txt new file mode 100644 index 00000000000..4a0108ebe06 --- /dev/null +++ b/tests/baselines/reference/parser_duplicateLabel4.errors.txt @@ -0,0 +1,16 @@ +tests/cases/conformance/parser/ecmascript5/Statements/LabeledStatements/parser_duplicateLabel4.ts(1,1): error TS7028: Unused label. +tests/cases/conformance/parser/ecmascript5/Statements/LabeledStatements/parser_duplicateLabel4.ts(5,1): error TS7027: Unreachable code detected. + + +==== tests/cases/conformance/parser/ecmascript5/Statements/LabeledStatements/parser_duplicateLabel4.ts (2 errors) ==== + target: + ~~~~~~ +!!! error TS7028: Unused label. + while (true) { + } + + target: + ~~~~~~ +!!! error TS7027: Unreachable code detected. + while (true) { + } \ No newline at end of file diff --git a/tests/baselines/reference/parser_duplicateLabel4.symbols b/tests/baselines/reference/parser_duplicateLabel4.symbols deleted file mode 100644 index 564531bf71b..00000000000 --- a/tests/baselines/reference/parser_duplicateLabel4.symbols +++ /dev/null @@ -1,9 +0,0 @@ -=== tests/cases/conformance/parser/ecmascript5/Statements/LabeledStatements/parser_duplicateLabel4.ts === -target: -No type information for this code.while (true) { -No type information for this code.} -No type information for this code. -No type information for this code.target: -No type information for this code.while (true) { -No type information for this code.} -No type information for this code. \ No newline at end of file diff --git a/tests/baselines/reference/parser_duplicateLabel4.types b/tests/baselines/reference/parser_duplicateLabel4.types deleted file mode 100644 index d09529301ca..00000000000 --- a/tests/baselines/reference/parser_duplicateLabel4.types +++ /dev/null @@ -1,14 +0,0 @@ -=== tests/cases/conformance/parser/ecmascript5/Statements/LabeledStatements/parser_duplicateLabel4.ts === -target: ->target : any - -while (true) { ->true : boolean -} - -target: ->target : any - -while (true) { ->true : boolean -} diff --git a/tests/baselines/reference/privacyFunctionCannotNameReturnTypeDeclFile.errors.txt b/tests/baselines/reference/privacyFunctionCannotNameReturnTypeDeclFile.errors.txt index bc6229815f5..0f148b6a20e 100644 --- a/tests/baselines/reference/privacyFunctionCannotNameReturnTypeDeclFile.errors.txt +++ b/tests/baselines/reference/privacyFunctionCannotNameReturnTypeDeclFile.errors.txt @@ -1,7 +1,19 @@ tests/cases/compiler/privacyFunctionReturnTypeDeclFile_consumer.ts(3,12): error TS4050: Return type of public static method from exported class has or is using name 'Widget1' from external module "tests/cases/compiler/privacyFunctionReturnTypeDeclFile_Widgets" but cannot be named. +tests/cases/compiler/privacyFunctionReturnTypeDeclFile_consumer.ts(7,49): error TS7027: Unreachable code detected. tests/cases/compiler/privacyFunctionReturnTypeDeclFile_consumer.ts(9,5): error TS4053: Return type of public method from exported class has or is using name 'Widget1' from external module "tests/cases/compiler/privacyFunctionReturnTypeDeclFile_Widgets" but cannot be named. +tests/cases/compiler/privacyFunctionReturnTypeDeclFile_consumer.ts(10,49): error TS7027: Unreachable code detected. +tests/cases/compiler/privacyFunctionReturnTypeDeclFile_consumer.ts(13,49): error TS7027: Unreachable code detected. tests/cases/compiler/privacyFunctionReturnTypeDeclFile_consumer.ts(15,12): error TS4050: Return type of public static method from exported class has or is using name 'Widget3' from external module "GlobalWidgets" but cannot be named. +tests/cases/compiler/privacyFunctionReturnTypeDeclFile_consumer.ts(19,49): error TS7027: Unreachable code detected. tests/cases/compiler/privacyFunctionReturnTypeDeclFile_consumer.ts(21,5): error TS4053: Return type of public method from exported class has or is using name 'Widget3' from external module "GlobalWidgets" but cannot be named. +tests/cases/compiler/privacyFunctionReturnTypeDeclFile_consumer.ts(22,49): error TS7027: Unreachable code detected. +tests/cases/compiler/privacyFunctionReturnTypeDeclFile_consumer.ts(25,49): error TS7027: Unreachable code detected. +tests/cases/compiler/privacyFunctionReturnTypeDeclFile_consumer.ts(34,49): error TS7027: Unreachable code detected. +tests/cases/compiler/privacyFunctionReturnTypeDeclFile_consumer.ts(37,49): error TS7027: Unreachable code detected. +tests/cases/compiler/privacyFunctionReturnTypeDeclFile_consumer.ts(40,49): error TS7027: Unreachable code detected. +tests/cases/compiler/privacyFunctionReturnTypeDeclFile_consumer.ts(46,49): error TS7027: Unreachable code detected. +tests/cases/compiler/privacyFunctionReturnTypeDeclFile_consumer.ts(49,49): error TS7027: Unreachable code detected. +tests/cases/compiler/privacyFunctionReturnTypeDeclFile_consumer.ts(52,49): error TS7027: Unreachable code detected. tests/cases/compiler/privacyFunctionReturnTypeDeclFile_consumer.ts(56,17): error TS4058: Return type of exported function has or is using name 'Widget1' from external module "tests/cases/compiler/privacyFunctionReturnTypeDeclFile_Widgets" but cannot be named. tests/cases/compiler/privacyFunctionReturnTypeDeclFile_consumer.ts(62,17): error TS4058: Return type of exported function has or is using name 'Widget3' from external module "GlobalWidgets" but cannot be named. tests/cases/compiler/privacyFunctionReturnTypeDeclFile_consumer.ts(70,12): error TS4050: Return type of public static method from exported class has or is using name 'SpecializedWidget.Widget2' from external module "tests/cases/compiler/privacyFunctionReturnTypeDeclFile_Widgets" but cannot be named. @@ -12,7 +24,7 @@ tests/cases/compiler/privacyFunctionReturnTypeDeclFile_consumer.ts(83,17): error tests/cases/compiler/privacyFunctionReturnTypeDeclFile_consumer.ts(86,17): error TS4058: Return type of exported function has or is using name 'SpecializedGlobalWidget.Widget4' from external module "GlobalWidgets" but cannot be named. -==== tests/cases/compiler/privacyFunctionReturnTypeDeclFile_consumer.ts (12 errors) ==== +==== tests/cases/compiler/privacyFunctionReturnTypeDeclFile_consumer.ts (24 errors) ==== import exporter = require("./privacyFunctionReturnTypeDeclFile_exporter"); export class publicClassWithWithPrivateParmeterTypes { static myPublicStaticMethod() { // Error @@ -22,14 +34,20 @@ tests/cases/compiler/privacyFunctionReturnTypeDeclFile_consumer.ts(86,17): error } private static myPrivateStaticMethod() { return exporter.createExportedWidget1();; + ~ +!!! error TS7027: Unreachable code detected. } myPublicMethod() { // Error ~~~~~~~~~~~~~~ !!! error TS4053: Return type of public method from exported class has or is using name 'Widget1' from external module "tests/cases/compiler/privacyFunctionReturnTypeDeclFile_Widgets" but cannot be named. return exporter.createExportedWidget1();; + ~ +!!! error TS7027: Unreachable code detected. } private myPrivateMethod() { return exporter.createExportedWidget1();; + ~ +!!! error TS7027: Unreachable code detected. } static myPublicStaticMethod1() { // Error ~~~~~~~~~~~~~~~~~~~~~ @@ -38,14 +56,20 @@ tests/cases/compiler/privacyFunctionReturnTypeDeclFile_consumer.ts(86,17): error } private static myPrivateStaticMethod1() { return exporter.createExportedWidget3();; + ~ +!!! error TS7027: Unreachable code detected. } myPublicMethod1() { // Error ~~~~~~~~~~~~~~~ !!! error TS4053: Return type of public method from exported class has or is using name 'Widget3' from external module "GlobalWidgets" but cannot be named. return exporter.createExportedWidget3();; + ~ +!!! error TS7027: Unreachable code detected. } private myPrivateMethod1() { return exporter.createExportedWidget3();; + ~ +!!! error TS7027: Unreachable code detected. } } @@ -55,24 +79,36 @@ tests/cases/compiler/privacyFunctionReturnTypeDeclFile_consumer.ts(86,17): error } private static myPrivateStaticMethod() { return exporter.createExportedWidget1();; + ~ +!!! error TS7027: Unreachable code detected. } myPublicMethod() { return exporter.createExportedWidget1();; + ~ +!!! error TS7027: Unreachable code detected. } private myPrivateMethod() { return exporter.createExportedWidget1();; + ~ +!!! error TS7027: Unreachable code detected. } static myPublicStaticMethod1() { return exporter.createExportedWidget3(); } private static myPrivateStaticMethod1() { return exporter.createExportedWidget3();; + ~ +!!! error TS7027: Unreachable code detected. } myPublicMethod1() { return exporter.createExportedWidget3();; + ~ +!!! error TS7027: Unreachable code detected. } private myPrivateMethod1() { return exporter.createExportedWidget3();; + ~ +!!! error TS7027: Unreachable code detected. } } diff --git a/tests/baselines/reference/reachabilityChecks1.errors.txt b/tests/baselines/reference/reachabilityChecks1.errors.txt index 7708867c26c..18a453969a1 100644 --- a/tests/baselines/reference/reachabilityChecks1.errors.txt +++ b/tests/baselines/reference/reachabilityChecks1.errors.txt @@ -1,23 +1,23 @@ tests/cases/compiler/reachabilityChecks1.ts(3,1): error TS7027: Unreachable code detected. tests/cases/compiler/reachabilityChecks1.ts(7,5): error TS7027: Unreachable code detected. -tests/cases/compiler/reachabilityChecks1.ts(19,12): error TS7027: Unreachable code detected. -tests/cases/compiler/reachabilityChecks1.ts(31,12): error TS7027: Unreachable code detected. -tests/cases/compiler/reachabilityChecks1.ts(48,11): error TS7027: Unreachable code detected. -tests/cases/compiler/reachabilityChecks1.ts(61,10): error TS7027: Unreachable code detected. -tests/cases/compiler/reachabilityChecks1.ts(70,16): error TS7027: Unreachable code detected. +tests/cases/compiler/reachabilityChecks1.ts(19,5): error TS7027: Unreachable code detected. +tests/cases/compiler/reachabilityChecks1.ts(31,5): error TS7027: Unreachable code detected. +tests/cases/compiler/reachabilityChecks1.ts(48,5): error TS7027: Unreachable code detected. +tests/cases/compiler/reachabilityChecks1.ts(61,5): error TS7027: Unreachable code detected. +tests/cases/compiler/reachabilityChecks1.ts(70,5): error TS7027: Unreachable code detected. ==== tests/cases/compiler/reachabilityChecks1.ts (7 errors) ==== while (true); var x = 1; - ~~~~~~~~~~ + ~~~ !!! error TS7027: Unreachable code detected. module A { while (true); let x; - ~~~~~~ + ~~~ !!! error TS7027: Unreachable code detected. } @@ -31,7 +31,7 @@ tests/cases/compiler/reachabilityChecks1.ts(70,16): error TS7027: Unreachable co module A2 { while (true); module A { - ~ + ~~~~~~ !!! error TS7027: Unreachable code detected. var x = 1; } @@ -45,7 +45,7 @@ tests/cases/compiler/reachabilityChecks1.ts(70,16): error TS7027: Unreachable co module A4 { while (true); module A { - ~ + ~~~~~~ !!! error TS7027: Unreachable code detected. const enum E { X } } @@ -64,7 +64,7 @@ tests/cases/compiler/reachabilityChecks1.ts(70,16): error TS7027: Unreachable co function f2() { return; class A { - ~ + ~~~~~ !!! error TS7027: Unreachable code detected. } } @@ -79,7 +79,7 @@ tests/cases/compiler/reachabilityChecks1.ts(70,16): error TS7027: Unreachable co do { } while (true); enum E { - ~ + ~~~~ !!! error TS7027: Unreachable code detected. X = 1 } @@ -90,7 +90,7 @@ tests/cases/compiler/reachabilityChecks1.ts(70,16): error TS7027: Unreachable co throw new Error(); } const enum E { - ~ + ~~~~~ !!! error TS7027: Unreachable code detected. X = 1 } diff --git a/tests/baselines/reference/reachabilityChecks2.errors.txt b/tests/baselines/reference/reachabilityChecks2.errors.txt index 3de7adc50a6..cd48f84f8e1 100644 --- a/tests/baselines/reference/reachabilityChecks2.errors.txt +++ b/tests/baselines/reference/reachabilityChecks2.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/reachabilityChecks2.ts(5,8): error TS7027: Unreachable code detected. +tests/cases/compiler/reachabilityChecks2.ts(5,1): error TS7027: Unreachable code detected. ==== tests/cases/compiler/reachabilityChecks2.ts (1 errors) ==== @@ -7,7 +7,7 @@ tests/cases/compiler/reachabilityChecks2.ts(5,8): error TS7027: Unreachable code const enum E { X } module A4 { - ~~ + ~~~~~~ !!! error TS7027: Unreachable code detected. while (true); module A { diff --git a/tests/baselines/reference/reachabilityChecks3.errors.txt b/tests/baselines/reference/reachabilityChecks3.errors.txt index 993ab571b2e..1114f245f44 100644 --- a/tests/baselines/reference/reachabilityChecks3.errors.txt +++ b/tests/baselines/reference/reachabilityChecks3.errors.txt @@ -1,7 +1,9 @@ tests/cases/compiler/reachabilityChecks3.ts(3,1): error TS7028: Unused label. +tests/cases/compiler/reachabilityChecks3.ts(12,5): error TS7028: Unused label. +tests/cases/compiler/reachabilityChecks3.ts(15,17): error TS7028: Unused label. -==== tests/cases/compiler/reachabilityChecks3.ts (1 errors) ==== +==== tests/cases/compiler/reachabilityChecks3.ts (3 errors) ==== let x = 1; loop: while (true) { @@ -13,4 +15,13 @@ tests/cases/compiler/reachabilityChecks3.ts(3,1): error TS7028: Unused label. else { x++; } - } \ No newline at end of file + } + { + x: 100 + ~ +!!! error TS7028: Unused label. + } + + var y = () => { f: 1 } + ~ +!!! error TS7028: Unused label. \ No newline at end of file diff --git a/tests/baselines/reference/reachabilityChecks3.js b/tests/baselines/reference/reachabilityChecks3.js index 4de316d1ddc..dd22453938d 100644 --- a/tests/baselines/reference/reachabilityChecks3.js +++ b/tests/baselines/reference/reachabilityChecks3.js @@ -8,7 +8,12 @@ loop: while (true) { else { x++; } -} +} +{ + x: 100 +} + +var y = () => { f: 1 } //// [reachabilityChecks3.js] var x = 1; @@ -20,3 +25,7 @@ loop: while (true) { x++; } } +{ + x: 100; +} +var y = function () { f: 1; }; diff --git a/tests/baselines/reference/reachabilityChecks5.errors.txt b/tests/baselines/reference/reachabilityChecks5.errors.txt index c30dfa71817..147dbe264a3 100644 --- a/tests/baselines/reference/reachabilityChecks5.errors.txt +++ b/tests/baselines/reference/reachabilityChecks5.errors.txt @@ -109,7 +109,7 @@ tests/cases/compiler/reachabilityChecks5.ts(123,13): error TS7027: Unreachable c } else { return 1; - ~~~~~~~~~ + ~~~~~~ !!! error TS7027: Unreachable code detected. } } @@ -152,7 +152,7 @@ tests/cases/compiler/reachabilityChecks5.ts(123,13): error TS7027: Unreachable c break test; } while (true); x++; - ~~~~ + ~ !!! error TS7027: Unreachable code detected. } while (true); } diff --git a/tests/baselines/reference/recursiveLetConst.errors.txt b/tests/baselines/reference/recursiveLetConst.errors.txt index b02d0819a3f..88ecb379e5e 100644 --- a/tests/baselines/reference/recursiveLetConst.errors.txt +++ b/tests/baselines/reference/recursiveLetConst.errors.txt @@ -3,6 +3,7 @@ tests/cases/compiler/recursiveLetConst.ts(3,12): error TS2448: Block-scoped vari tests/cases/compiler/recursiveLetConst.ts(4,11): error TS2448: Block-scoped variable 'y' used before its declaration. tests/cases/compiler/recursiveLetConst.ts(5,14): error TS2448: Block-scoped variable 'y1' used before its declaration. tests/cases/compiler/recursiveLetConst.ts(6,14): error TS2448: Block-scoped variable 'v' used before its declaration. +tests/cases/compiler/recursiveLetConst.ts(7,1): error TS7027: Unreachable code detected. tests/cases/compiler/recursiveLetConst.ts(7,16): error TS2448: Block-scoped variable 'v' used before its declaration. tests/cases/compiler/recursiveLetConst.ts(8,15): error TS2448: Block-scoped variable 'v' used before its declaration. tests/cases/compiler/recursiveLetConst.ts(9,15): error TS2448: Block-scoped variable 'v' used before its declaration. @@ -10,7 +11,7 @@ tests/cases/compiler/recursiveLetConst.ts(10,17): error TS2448: Block-scoped var tests/cases/compiler/recursiveLetConst.ts(11,11): error TS2448: Block-scoped variable 'x2' used before its declaration. -==== tests/cases/compiler/recursiveLetConst.ts (10 errors) ==== +==== tests/cases/compiler/recursiveLetConst.ts (11 errors) ==== 'use strict' let x = x + 1; ~ @@ -28,6 +29,8 @@ tests/cases/compiler/recursiveLetConst.ts(11,11): error TS2448: Block-scoped var ~ !!! error TS2448: Block-scoped variable 'v' used before its declaration. for (let [v] = v; ;) { } + ~~~ +!!! error TS7027: Unreachable code detected. ~ !!! error TS2448: Block-scoped variable 'v' used before its declaration. for (let v in v) { } diff --git a/tests/baselines/reference/recursiveMods.errors.txt b/tests/baselines/reference/recursiveMods.errors.txt new file mode 100644 index 00000000000..6adba78d004 --- /dev/null +++ b/tests/baselines/reference/recursiveMods.errors.txt @@ -0,0 +1,29 @@ +tests/cases/compiler/recursiveMods.ts(9,3): error TS7027: Unreachable code detected. + + +==== tests/cases/compiler/recursiveMods.ts (1 errors) ==== + export module Foo { + export class C {} + } + + export module Foo { + + function Bar() : C { + if (true) { return Bar();} + return new C(); + ~~~~~~ +!!! error TS7027: Unreachable code detected. + } + + function Baz() : C { + var c = Baz(); + return Bar(); + } + + function Gar() { + var c : C = Baz(); + return; + } + + } + \ No newline at end of file diff --git a/tests/baselines/reference/recursiveMods.symbols b/tests/baselines/reference/recursiveMods.symbols deleted file mode 100644 index 1e7e8fa1c84..00000000000 --- a/tests/baselines/reference/recursiveMods.symbols +++ /dev/null @@ -1,47 +0,0 @@ -=== tests/cases/compiler/recursiveMods.ts === -export module Foo { ->Foo : Symbol(Foo, Decl(recursiveMods.ts, 0, 0), Decl(recursiveMods.ts, 2, 1)) - - export class C {} ->C : Symbol(C, Decl(recursiveMods.ts, 0, 19)) -} - -export module Foo { ->Foo : Symbol(Foo, Decl(recursiveMods.ts, 0, 0), Decl(recursiveMods.ts, 2, 1)) - - function Bar() : C { ->Bar : Symbol(Bar, Decl(recursiveMods.ts, 4, 19)) ->C : Symbol(C, Decl(recursiveMods.ts, 0, 19)) - - if (true) { return Bar();} ->Bar : Symbol(Bar, Decl(recursiveMods.ts, 4, 19)) - - return new C(); ->C : Symbol(C, Decl(recursiveMods.ts, 0, 19)) - } - - function Baz() : C { ->Baz : Symbol(Baz, Decl(recursiveMods.ts, 9, 2)) ->C : Symbol(C, Decl(recursiveMods.ts, 0, 19)) - - var c = Baz(); ->c : Symbol(c, Decl(recursiveMods.ts, 12, 5)) ->Baz : Symbol(Baz, Decl(recursiveMods.ts, 9, 2)) - - return Bar(); ->Bar : Symbol(Bar, Decl(recursiveMods.ts, 4, 19)) - } - - function Gar() { ->Gar : Symbol(Gar, Decl(recursiveMods.ts, 14, 2)) - - var c : C = Baz(); ->c : Symbol(c, Decl(recursiveMods.ts, 17, 5)) ->C : Symbol(C, Decl(recursiveMods.ts, 0, 19)) ->Baz : Symbol(Baz, Decl(recursiveMods.ts, 9, 2)) - - return; - } - -} - diff --git a/tests/baselines/reference/recursiveMods.types b/tests/baselines/reference/recursiveMods.types deleted file mode 100644 index d7f28f84975..00000000000 --- a/tests/baselines/reference/recursiveMods.types +++ /dev/null @@ -1,53 +0,0 @@ -=== tests/cases/compiler/recursiveMods.ts === -export module Foo { ->Foo : typeof Foo - - export class C {} ->C : C -} - -export module Foo { ->Foo : typeof Foo - - function Bar() : C { ->Bar : () => C ->C : C - - if (true) { return Bar();} ->true : boolean ->Bar() : C ->Bar : () => C - - return new C(); ->new C() : C ->C : typeof C - } - - function Baz() : C { ->Baz : () => C ->C : C - - var c = Baz(); ->c : C ->Baz() : C ->Baz : () => C - - return Bar(); ->Bar() : C ->Bar : () => C - } - - function Gar() { ->Gar : () => void - - var c : C = Baz(); ->c : C ->C : C ->Baz() : C ->Baz : () => C - - return; - } - -} - diff --git a/tests/baselines/reference/recursiveNamedLambdaCall.errors.txt b/tests/baselines/reference/recursiveNamedLambdaCall.errors.txt index 7729d1e780f..04ddc371ac7 100644 --- a/tests/baselines/reference/recursiveNamedLambdaCall.errors.txt +++ b/tests/baselines/reference/recursiveNamedLambdaCall.errors.txt @@ -1,11 +1,12 @@ tests/cases/compiler/recursiveNamedLambdaCall.ts(3,8): error TS2304: Cannot find name 'top'. tests/cases/compiler/recursiveNamedLambdaCall.ts(3,15): error TS2304: Cannot find name 'top'. +tests/cases/compiler/recursiveNamedLambdaCall.ts(7,6): error TS7027: Unreachable code detected. tests/cases/compiler/recursiveNamedLambdaCall.ts(8,7): error TS2304: Cannot find name 'top'. tests/cases/compiler/recursiveNamedLambdaCall.ts(10,14): error TS2304: Cannot find name 'setTimeout'. tests/cases/compiler/recursiveNamedLambdaCall.ts(14,6): error TS2304: Cannot find name 'detach'. -==== tests/cases/compiler/recursiveNamedLambdaCall.ts (5 errors) ==== +==== tests/cases/compiler/recursiveNamedLambdaCall.ts (6 errors) ==== var promise = function( obj ) { if ( top && top.doScroll ) { @@ -17,6 +18,8 @@ tests/cases/compiler/recursiveNamedLambdaCall.ts(14,6): error TS2304: Cannot fin if ( false ) { try { + ~~~ +!!! error TS7027: Unreachable code detected. top.doScroll("left"); ~~~ !!! error TS2304: Cannot find name 'top'. diff --git a/tests/baselines/reference/reservedWords2.errors.txt b/tests/baselines/reference/reservedWords2.errors.txt index 090b2d0d43e..d6e2d04073d 100644 --- a/tests/baselines/reference/reservedWords2.errors.txt +++ b/tests/baselines/reference/reservedWords2.errors.txt @@ -14,6 +14,7 @@ tests/cases/compiler/reservedWords2.ts(5,9): error TS2300: Duplicate identifier tests/cases/compiler/reservedWords2.ts(5,10): error TS1003: Identifier expected. tests/cases/compiler/reservedWords2.ts(5,18): error TS1005: '=>' expected. tests/cases/compiler/reservedWords2.ts(6,1): error TS2304: Cannot find name 'module'. +tests/cases/compiler/reservedWords2.ts(6,1): error TS7027: Unreachable code detected. tests/cases/compiler/reservedWords2.ts(6,8): error TS1005: ';' expected. tests/cases/compiler/reservedWords2.ts(7,11): error TS2300: Duplicate identifier '(Missing)'. tests/cases/compiler/reservedWords2.ts(7,11): error TS1005: ':' expected. @@ -31,7 +32,7 @@ tests/cases/compiler/reservedWords2.ts(10,5): error TS2300: Duplicate identifier tests/cases/compiler/reservedWords2.ts(10,6): error TS1003: Identifier expected. -==== tests/cases/compiler/reservedWords2.ts (31 errors) ==== +==== tests/cases/compiler/reservedWords2.ts (32 errors) ==== import while = require("dfdf"); ~~~~~~ !!! error TS1148: Cannot compile modules unless the '--module' flag is provided. @@ -70,6 +71,8 @@ tests/cases/compiler/reservedWords2.ts(10,6): error TS1003: Identifier expected. module void {} ~~~~~~ !!! error TS2304: Cannot find name 'module'. + ~~~~~~ +!!! error TS7027: Unreachable code detected. ~~~~ !!! error TS1005: ';' expected. var {while, return} = { while: 1, return: 2 }; diff --git a/tests/baselines/reference/returnStatement1.errors.txt b/tests/baselines/reference/returnStatement1.errors.txt new file mode 100644 index 00000000000..af17564a874 --- /dev/null +++ b/tests/baselines/reference/returnStatement1.errors.txt @@ -0,0 +1,12 @@ +tests/cases/compiler/returnStatement1.ts(5,5): error TS7027: Unreachable code detected. + + +==== tests/cases/compiler/returnStatement1.ts (1 errors) ==== + function f() { + return function (s) { + var x = s; + }; + ("harmless extra line"); + ~ +!!! error TS7027: Unreachable code detected. + } \ No newline at end of file diff --git a/tests/baselines/reference/returnStatement1.symbols b/tests/baselines/reference/returnStatement1.symbols deleted file mode 100644 index acec9f76003..00000000000 --- a/tests/baselines/reference/returnStatement1.symbols +++ /dev/null @@ -1,14 +0,0 @@ -=== tests/cases/compiler/returnStatement1.ts === -function f() { ->f : Symbol(f, Decl(returnStatement1.ts, 0, 0)) - - return function (s) { ->s : Symbol(s, Decl(returnStatement1.ts, 1, 21)) - - var x = s; ->x : Symbol(x, Decl(returnStatement1.ts, 2, 11)) ->s : Symbol(s, Decl(returnStatement1.ts, 1, 21)) - - }; - ("harmless extra line"); -} diff --git a/tests/baselines/reference/returnStatement1.types b/tests/baselines/reference/returnStatement1.types deleted file mode 100644 index ff30148af5a..00000000000 --- a/tests/baselines/reference/returnStatement1.types +++ /dev/null @@ -1,17 +0,0 @@ -=== tests/cases/compiler/returnStatement1.ts === -function f() { ->f : () => (s: any) => void - - return function (s) { ->function (s) { var x = s; } : (s: any) => void ->s : any - - var x = s; ->x : any ->s : any - - }; - ("harmless extra line"); ->("harmless extra line") : string ->"harmless extra line" : string -} diff --git a/tests/baselines/reference/scanner10.1.1-8gs.errors.txt b/tests/baselines/reference/scanner10.1.1-8gs.errors.txt index 54cd92dc0ca..23d89cdf7ff 100644 --- a/tests/baselines/reference/scanner10.1.1-8gs.errors.txt +++ b/tests/baselines/reference/scanner10.1.1-8gs.errors.txt @@ -1,8 +1,9 @@ tests/cases/conformance/scanner/ecmascript5/scanner10.1.1-8gs.ts(16,7): error TS2304: Cannot find name 'NotEarlyError'. +tests/cases/conformance/scanner/ecmascript5/scanner10.1.1-8gs.ts(17,1): error TS7027: Unreachable code detected. tests/cases/conformance/scanner/ecmascript5/scanner10.1.1-8gs.ts(17,5): error TS1212: Identifier expected. 'public' is a reserved word in strict mode -==== tests/cases/conformance/scanner/ecmascript5/scanner10.1.1-8gs.ts (2 errors) ==== +==== tests/cases/conformance/scanner/ecmascript5/scanner10.1.1-8gs.ts (3 errors) ==== /// Copyright (c) 2012 Ecma International. All rights reserved. /// Ecma International makes this code available under the terms and conditions set /// forth on http://hg.ecmascript.org/tests/test262/raw-file/tip/LICENSE (the @@ -22,6 +23,8 @@ tests/cases/conformance/scanner/ecmascript5/scanner10.1.1-8gs.ts(17,5): error TS ~~~~~~~~~~~~~ !!! error TS2304: Cannot find name 'NotEarlyError'. var public = 1; + ~~~ +!!! error TS7027: Unreachable code detected. ~~~~~~ !!! error TS1212: Identifier expected. 'public' is a reserved word in strict mode \ No newline at end of file diff --git a/tests/baselines/reference/setterWithReturn.errors.txt b/tests/baselines/reference/setterWithReturn.errors.txt index 481116327b8..6aed49105b8 100644 --- a/tests/baselines/reference/setterWithReturn.errors.txt +++ b/tests/baselines/reference/setterWithReturn.errors.txt @@ -1,9 +1,10 @@ tests/cases/compiler/setterWithReturn.ts(2,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/setterWithReturn.ts(4,20): error TS2408: Setters cannot return a value. +tests/cases/compiler/setterWithReturn.ts(7,13): error TS7027: Unreachable code detected. tests/cases/compiler/setterWithReturn.ts(7,20): error TS2408: Setters cannot return a value. -==== tests/cases/compiler/setterWithReturn.ts (3 errors) ==== +==== tests/cases/compiler/setterWithReturn.ts (4 errors) ==== class C234 { public set p1(arg1) { ~~ @@ -15,6 +16,8 @@ tests/cases/compiler/setterWithReturn.ts(7,20): error TS2408: Setters cannot ret } else { return 0; + ~~~~~~ +!!! error TS7027: Unreachable code detected. ~ !!! error TS2408: Setters cannot return a value. } diff --git a/tests/baselines/reference/sourceMapValidationFor.errors.txt b/tests/baselines/reference/sourceMapValidationFor.errors.txt index 7fe75d640d2..6949d7545ed 100644 --- a/tests/baselines/reference/sourceMapValidationFor.errors.txt +++ b/tests/baselines/reference/sourceMapValidationFor.errors.txt @@ -1,8 +1,9 @@ tests/cases/compiler/sourceMapValidationFor.ts(2,5): error TS2304: Cannot find name 'WScript'. tests/cases/compiler/sourceMapValidationFor.ts(6,5): error TS2304: Cannot find name 'WScript'. +tests/cases/compiler/sourceMapValidationFor.ts(20,1): error TS7027: Unreachable code detected. -==== tests/cases/compiler/sourceMapValidationFor.ts (2 errors) ==== +==== tests/cases/compiler/sourceMapValidationFor.ts (3 errors) ==== for (var i = 0; i < 10; i++) { WScript.Echo("i: " + i); ~~~~~~~ @@ -27,6 +28,8 @@ tests/cases/compiler/sourceMapValidationFor.ts(6,5): error TS2304: Cannot find n for (var k = 0;; k++) { } for (k = 0;; k++) + ~~~ +!!! error TS7027: Unreachable code detected. { } for (; k < 10; k++) { diff --git a/tests/baselines/reference/sourceMapValidationLabeled.errors.txt b/tests/baselines/reference/sourceMapValidationLabeled.errors.txt new file mode 100644 index 00000000000..e9cf1fb3db8 --- /dev/null +++ b/tests/baselines/reference/sourceMapValidationLabeled.errors.txt @@ -0,0 +1,8 @@ +tests/cases/compiler/sourceMapValidationLabeled.ts(1,1): error TS7028: Unused label. + + +==== tests/cases/compiler/sourceMapValidationLabeled.ts (1 errors) ==== + x: + ~ +!!! error TS7028: Unused label. + var b = 10; \ No newline at end of file diff --git a/tests/baselines/reference/sourceMapValidationLabeled.symbols b/tests/baselines/reference/sourceMapValidationLabeled.symbols deleted file mode 100644 index 2a3c4f5606c..00000000000 --- a/tests/baselines/reference/sourceMapValidationLabeled.symbols +++ /dev/null @@ -1,5 +0,0 @@ -=== tests/cases/compiler/sourceMapValidationLabeled.ts === -x: -var b = 10; ->b : Symbol(b, Decl(sourceMapValidationLabeled.ts, 1, 3)) - diff --git a/tests/baselines/reference/sourceMapValidationLabeled.types b/tests/baselines/reference/sourceMapValidationLabeled.types deleted file mode 100644 index 3058869cb0b..00000000000 --- a/tests/baselines/reference/sourceMapValidationLabeled.types +++ /dev/null @@ -1,8 +0,0 @@ -=== tests/cases/compiler/sourceMapValidationLabeled.ts === -x: ->x : any - -var b = 10; ->b : number ->10 : number - diff --git a/tests/baselines/reference/switchBreakStatements.errors.txt b/tests/baselines/reference/switchBreakStatements.errors.txt new file mode 100644 index 00000000000..77577e485da --- /dev/null +++ b/tests/baselines/reference/switchBreakStatements.errors.txt @@ -0,0 +1,67 @@ +tests/cases/conformance/statements/breakStatements/switchBreakStatements.ts(12,1): error TS7028: Unused label. +tests/cases/conformance/statements/breakStatements/switchBreakStatements.ts(22,9): error TS7028: Unused label. +tests/cases/conformance/statements/breakStatements/switchBreakStatements.ts(46,25): error TS7027: Unreachable code detected. + + +==== tests/cases/conformance/statements/breakStatements/switchBreakStatements.ts (3 errors) ==== + switch ('') { + case 'a': + break; + } + + ONE: + switch ('') { + case 'a': + break ONE; + } + + TWO: + ~~~ +!!! error TS7028: Unused label. + THREE: + switch ('') { + case 'a': + break THREE; + } + + FOUR: + switch ('') { + case 'a': + FIVE: + ~~~~ +!!! error TS7028: Unused label. + switch ('') { + case 'a': + break FOUR; + } + } + + switch ('') { + case 'a': + SIX: + switch ('') { + case 'a': + break SIX; + } + } + + SEVEN: + switch ('') { + case 'a': + switch ('') { + case 'a': + switch ('') { + case 'a': + break SEVEN; + EIGHT: + ~~~~~ +!!! error TS7027: Unreachable code detected. + switch ('') { + case 'a': + var fn = function () { } + break EIGHT; + } + } + } + } + \ No newline at end of file diff --git a/tests/baselines/reference/switchBreakStatements.symbols b/tests/baselines/reference/switchBreakStatements.symbols deleted file mode 100644 index 22626241881..00000000000 --- a/tests/baselines/reference/switchBreakStatements.symbols +++ /dev/null @@ -1,58 +0,0 @@ -=== tests/cases/conformance/statements/breakStatements/switchBreakStatements.ts === -switch ('') { - case 'a': - break; -} - -ONE: -switch ('') { - case 'a': - break ONE; -} - -TWO: -THREE: -switch ('') { - case 'a': - break THREE; -} - -FOUR: -switch ('') { - case 'a': - FIVE: - switch ('') { - case 'a': - break FOUR; - } -} - -switch ('') { - case 'a': - SIX: - switch ('') { - case 'a': - break SIX; - } -} - -SEVEN: -switch ('') { - case 'a': - switch ('') { - case 'a': - switch ('') { - case 'a': - break SEVEN; - EIGHT: - switch ('') { - case 'a': - var fn = function () { } ->fn : Symbol(fn, Decl(switchBreakStatements.ts, 48, 35)) - - break EIGHT; - } - } - } -} - diff --git a/tests/baselines/reference/switchBreakStatements.types b/tests/baselines/reference/switchBreakStatements.types deleted file mode 100644 index c8847a5dc34..00000000000 --- a/tests/baselines/reference/switchBreakStatements.types +++ /dev/null @@ -1,126 +0,0 @@ -=== tests/cases/conformance/statements/breakStatements/switchBreakStatements.ts === -switch ('') { ->'' : string - - case 'a': ->'a' : string - - break; -} - -ONE: ->ONE : any - -switch ('') { ->'' : string - - case 'a': ->'a' : string - - break ONE; ->ONE : any -} - -TWO: ->TWO : any - -THREE: ->THREE : any - -switch ('') { ->'' : string - - case 'a': ->'a' : string - - break THREE; ->THREE : any -} - -FOUR: ->FOUR : any - -switch ('') { ->'' : string - - case 'a': ->'a' : string - - FIVE: ->FIVE : any - - switch ('') { ->'' : string - - case 'a': ->'a' : string - - break FOUR; ->FOUR : any - } -} - -switch ('') { ->'' : string - - case 'a': ->'a' : string - - SIX: ->SIX : any - - switch ('') { ->'' : string - - case 'a': ->'a' : string - - break SIX; ->SIX : any - } -} - -SEVEN: ->SEVEN : any - -switch ('') { ->'' : string - - case 'a': ->'a' : string - - switch ('') { ->'' : string - - case 'a': ->'a' : string - - switch ('') { ->'' : string - - case 'a': ->'a' : string - - break SEVEN; ->SEVEN : any - - EIGHT: ->EIGHT : any - - switch ('') { ->'' : string - - case 'a': ->'a' : string - - var fn = function () { } ->fn : () => void ->function () { } : () => void - - break EIGHT; ->EIGHT : any - } - } - } -} - diff --git a/tests/baselines/reference/systemModule8.errors.txt b/tests/baselines/reference/systemModule8.errors.txt new file mode 100644 index 00000000000..17a37e57d24 --- /dev/null +++ b/tests/baselines/reference/systemModule8.errors.txt @@ -0,0 +1,36 @@ +tests/cases/compiler/systemModule8.ts(19,1): error TS7027: Unreachable code detected. + + +==== tests/cases/compiler/systemModule8.ts (1 errors) ==== + + export var x; + x = 1; + x++; + x--; + ++x; + --x; + x += 1; + x -= 1; + x *= 1; + x /= 1; + x |= 1; + x &= 1; + x + 1; + x - 1; + x & 1; + x | 1; + for (x = 5;;x++) {} + for (x = 8;;x--) {} + ~~~ +!!! error TS7027: Unreachable code detected. + for (x = 15;;++x) {} + for (x = 18;;--x) {} + + for (let x = 50;;) {} + function foo() { + x = 100; + } + + export let [y] = [1]; + export const {a: z0, b: {c: z1}} = {a: true, b: {c: "123"}}; + for ([x] of [[1]]) {} \ No newline at end of file diff --git a/tests/baselines/reference/systemModule8.symbols b/tests/baselines/reference/systemModule8.symbols deleted file mode 100644 index 719d48e4592..00000000000 --- a/tests/baselines/reference/systemModule8.symbols +++ /dev/null @@ -1,92 +0,0 @@ -=== tests/cases/compiler/systemModule8.ts === - -export var x; ->x : Symbol(x, Decl(systemModule8.ts, 1, 10)) - -x = 1; ->x : Symbol(x, Decl(systemModule8.ts, 1, 10)) - -x++; ->x : Symbol(x, Decl(systemModule8.ts, 1, 10)) - -x--; ->x : Symbol(x, Decl(systemModule8.ts, 1, 10)) - -++x; ->x : Symbol(x, Decl(systemModule8.ts, 1, 10)) - ---x; ->x : Symbol(x, Decl(systemModule8.ts, 1, 10)) - -x += 1; ->x : Symbol(x, Decl(systemModule8.ts, 1, 10)) - -x -= 1; ->x : Symbol(x, Decl(systemModule8.ts, 1, 10)) - -x *= 1; ->x : Symbol(x, Decl(systemModule8.ts, 1, 10)) - -x /= 1; ->x : Symbol(x, Decl(systemModule8.ts, 1, 10)) - -x |= 1; ->x : Symbol(x, Decl(systemModule8.ts, 1, 10)) - -x &= 1; ->x : Symbol(x, Decl(systemModule8.ts, 1, 10)) - -x + 1; ->x : Symbol(x, Decl(systemModule8.ts, 1, 10)) - -x - 1; ->x : Symbol(x, Decl(systemModule8.ts, 1, 10)) - -x & 1; ->x : Symbol(x, Decl(systemModule8.ts, 1, 10)) - -x | 1; ->x : Symbol(x, Decl(systemModule8.ts, 1, 10)) - -for (x = 5;;x++) {} ->x : Symbol(x, Decl(systemModule8.ts, 1, 10)) ->x : Symbol(x, Decl(systemModule8.ts, 1, 10)) - -for (x = 8;;x--) {} ->x : Symbol(x, Decl(systemModule8.ts, 1, 10)) ->x : Symbol(x, Decl(systemModule8.ts, 1, 10)) - -for (x = 15;;++x) {} ->x : Symbol(x, Decl(systemModule8.ts, 1, 10)) ->x : Symbol(x, Decl(systemModule8.ts, 1, 10)) - -for (x = 18;;--x) {} ->x : Symbol(x, Decl(systemModule8.ts, 1, 10)) ->x : Symbol(x, Decl(systemModule8.ts, 1, 10)) - -for (let x = 50;;) {} ->x : Symbol(x, Decl(systemModule8.ts, 22, 8)) - -function foo() { ->foo : Symbol(foo, Decl(systemModule8.ts, 22, 21)) - - x = 100; ->x : Symbol(x, Decl(systemModule8.ts, 1, 10)) -} - -export let [y] = [1]; ->y : Symbol(y, Decl(systemModule8.ts, 27, 12)) - -export const {a: z0, b: {c: z1}} = {a: true, b: {c: "123"}}; ->a : Symbol(a, Decl(systemModule8.ts, 28, 36)) ->z0 : Symbol(z0, Decl(systemModule8.ts, 28, 14)) ->b : Symbol(b, Decl(systemModule8.ts, 28, 44)) ->c : Symbol(c, Decl(systemModule8.ts, 28, 49)) ->z1 : Symbol(z1, Decl(systemModule8.ts, 28, 25)) ->a : Symbol(a, Decl(systemModule8.ts, 28, 36)) ->b : Symbol(b, Decl(systemModule8.ts, 28, 44)) ->c : Symbol(c, Decl(systemModule8.ts, 28, 49)) - -for ([x] of [[1]]) {} ->x : Symbol(x, Decl(systemModule8.ts, 1, 10)) - diff --git a/tests/baselines/reference/systemModule8.types b/tests/baselines/reference/systemModule8.types deleted file mode 100644 index 2c3dd1e48bb..00000000000 --- a/tests/baselines/reference/systemModule8.types +++ /dev/null @@ -1,143 +0,0 @@ -=== tests/cases/compiler/systemModule8.ts === - -export var x; ->x : any - -x = 1; ->x = 1 : number ->x : any ->1 : number - -x++; ->x++ : number ->x : any - -x--; ->x-- : number ->x : any - -++x; ->++x : number ->x : any - ---x; ->--x : number ->x : any - -x += 1; ->x += 1 : any ->x : any ->1 : number - -x -= 1; ->x -= 1 : number ->x : any ->1 : number - -x *= 1; ->x *= 1 : number ->x : any ->1 : number - -x /= 1; ->x /= 1 : number ->x : any ->1 : number - -x |= 1; ->x |= 1 : number ->x : any ->1 : number - -x &= 1; ->x &= 1 : number ->x : any ->1 : number - -x + 1; ->x + 1 : any ->x : any ->1 : number - -x - 1; ->x - 1 : number ->x : any ->1 : number - -x & 1; ->x & 1 : number ->x : any ->1 : number - -x | 1; ->x | 1 : number ->x : any ->1 : number - -for (x = 5;;x++) {} ->x = 5 : number ->x : any ->5 : number ->x++ : number ->x : any - -for (x = 8;;x--) {} ->x = 8 : number ->x : any ->8 : number ->x-- : number ->x : any - -for (x = 15;;++x) {} ->x = 15 : number ->x : any ->15 : number ->++x : number ->x : any - -for (x = 18;;--x) {} ->x = 18 : number ->x : any ->18 : number ->--x : number ->x : any - -for (let x = 50;;) {} ->x : number ->50 : number - -function foo() { ->foo : () => void - - x = 100; ->x = 100 : number ->x : any ->100 : number -} - -export let [y] = [1]; ->y : number ->[1] : [number] ->1 : number - -export const {a: z0, b: {c: z1}} = {a: true, b: {c: "123"}}; ->a : any ->z0 : boolean ->b : any ->c : any ->z1 : string ->{a: true, b: {c: "123"}} : { a: boolean; b: { c: string; }; } ->a : boolean ->true : boolean ->b : { c: string; } ->{c: "123"} : { c: string; } ->c : string ->"123" : string - -for ([x] of [[1]]) {} ->[x] : any[] ->x : any ->[[1]] : number[][] ->[1] : number[] ->1 : number - diff --git a/tests/baselines/reference/throwInEnclosingStatements.errors.txt b/tests/baselines/reference/throwInEnclosingStatements.errors.txt new file mode 100644 index 00000000000..1d225a45fe8 --- /dev/null +++ b/tests/baselines/reference/throwInEnclosingStatements.errors.txt @@ -0,0 +1,52 @@ +tests/cases/conformance/statements/throwStatements/throwInEnclosingStatements.ts(15,1): error TS7027: Unreachable code detected. + + +==== tests/cases/conformance/statements/throwStatements/throwInEnclosingStatements.ts (1 errors) ==== + function fn(x) { + throw x; + } + + (x: T) => { throw x; } + + var y: string; + switch (y) { + case 'a': + throw y; + default: + throw y; + } + + var z = 0; + ~~~ +!!! error TS7027: Unreachable code detected. + while (z < 10) { + throw z; + } + + for (var i = 0; ;) { throw i; } + + for (var idx in {}) { throw idx; } + + do { throw null; }while(true) + + var j = 0; + while (j < 0) { throw j; } + + class C { + private value: T; + biz() { + throw this.value; + } + + constructor() { + throw this; + } + } + + var aa = { + id:12, + biz() { + throw this; + } + } + \ No newline at end of file diff --git a/tests/baselines/reference/throwInEnclosingStatements.symbols b/tests/baselines/reference/throwInEnclosingStatements.symbols deleted file mode 100644 index 007894047de..00000000000 --- a/tests/baselines/reference/throwInEnclosingStatements.symbols +++ /dev/null @@ -1,93 +0,0 @@ -=== tests/cases/conformance/statements/throwStatements/throwInEnclosingStatements.ts === -function fn(x) { ->fn : Symbol(fn, Decl(throwInEnclosingStatements.ts, 0, 0)) ->x : Symbol(x, Decl(throwInEnclosingStatements.ts, 0, 12)) - - throw x; ->x : Symbol(x, Decl(throwInEnclosingStatements.ts, 0, 12)) -} - -(x: T) => { throw x; } ->T : Symbol(T, Decl(throwInEnclosingStatements.ts, 4, 1)) ->x : Symbol(x, Decl(throwInEnclosingStatements.ts, 4, 4)) ->T : Symbol(T, Decl(throwInEnclosingStatements.ts, 4, 1)) ->x : Symbol(x, Decl(throwInEnclosingStatements.ts, 4, 4)) - -var y: string; ->y : Symbol(y, Decl(throwInEnclosingStatements.ts, 6, 3)) - -switch (y) { ->y : Symbol(y, Decl(throwInEnclosingStatements.ts, 6, 3)) - - case 'a': - throw y; ->y : Symbol(y, Decl(throwInEnclosingStatements.ts, 6, 3)) - - default: - throw y; ->y : Symbol(y, Decl(throwInEnclosingStatements.ts, 6, 3)) -} - -var z = 0; ->z : Symbol(z, Decl(throwInEnclosingStatements.ts, 14, 3)) - -while (z < 10) { ->z : Symbol(z, Decl(throwInEnclosingStatements.ts, 14, 3)) - - throw z; ->z : Symbol(z, Decl(throwInEnclosingStatements.ts, 14, 3)) -} - -for (var i = 0; ;) { throw i; } ->i : Symbol(i, Decl(throwInEnclosingStatements.ts, 19, 8)) ->i : Symbol(i, Decl(throwInEnclosingStatements.ts, 19, 8)) - -for (var idx in {}) { throw idx; } ->idx : Symbol(idx, Decl(throwInEnclosingStatements.ts, 21, 8)) ->idx : Symbol(idx, Decl(throwInEnclosingStatements.ts, 21, 8)) - -do { throw null; }while(true) - -var j = 0; ->j : Symbol(j, Decl(throwInEnclosingStatements.ts, 25, 3)) - -while (j < 0) { throw j; } ->j : Symbol(j, Decl(throwInEnclosingStatements.ts, 25, 3)) ->j : Symbol(j, Decl(throwInEnclosingStatements.ts, 25, 3)) - -class C { ->C : Symbol(C, Decl(throwInEnclosingStatements.ts, 26, 26)) ->T : Symbol(T, Decl(throwInEnclosingStatements.ts, 28, 8)) - - private value: T; ->value : Symbol(value, Decl(throwInEnclosingStatements.ts, 28, 12)) ->T : Symbol(T, Decl(throwInEnclosingStatements.ts, 28, 8)) - - biz() { ->biz : Symbol(biz, Decl(throwInEnclosingStatements.ts, 29, 21)) - - throw this.value; ->this.value : Symbol(value, Decl(throwInEnclosingStatements.ts, 28, 12)) ->this : Symbol(C, Decl(throwInEnclosingStatements.ts, 26, 26)) ->value : Symbol(value, Decl(throwInEnclosingStatements.ts, 28, 12)) - } - - constructor() { - throw this; ->this : Symbol(C, Decl(throwInEnclosingStatements.ts, 26, 26)) - } -} - -var aa = { ->aa : Symbol(aa, Decl(throwInEnclosingStatements.ts, 39, 3)) - - id:12, ->id : Symbol(id, Decl(throwInEnclosingStatements.ts, 39, 10)) - - biz() { ->biz : Symbol(biz, Decl(throwInEnclosingStatements.ts, 40, 10)) - - throw this; - } -} - diff --git a/tests/baselines/reference/throwInEnclosingStatements.types b/tests/baselines/reference/throwInEnclosingStatements.types deleted file mode 100644 index bcff8653d52..00000000000 --- a/tests/baselines/reference/throwInEnclosingStatements.types +++ /dev/null @@ -1,109 +0,0 @@ -=== tests/cases/conformance/statements/throwStatements/throwInEnclosingStatements.ts === -function fn(x) { ->fn : (x: any) => void ->x : any - - throw x; ->x : any -} - -(x: T) => { throw x; } ->(x: T) => { throw x; } : (x: T) => void ->T : T ->x : T ->T : T ->x : T - -var y: string; ->y : string - -switch (y) { ->y : string - - case 'a': ->'a' : string - - throw y; ->y : string - - default: - throw y; ->y : string -} - -var z = 0; ->z : number ->0 : number - -while (z < 10) { ->z < 10 : boolean ->z : number ->10 : number - - throw z; ->z : number -} - -for (var i = 0; ;) { throw i; } ->i : number ->0 : number ->i : number - -for (var idx in {}) { throw idx; } ->idx : any ->{} : {} ->idx : any - -do { throw null; }while(true) ->null : null ->true : boolean - -var j = 0; ->j : number ->0 : number - -while (j < 0) { throw j; } ->j < 0 : boolean ->j : number ->0 : number ->j : number - -class C { ->C : C ->T : T - - private value: T; ->value : T ->T : T - - biz() { ->biz : () => void - - throw this.value; ->this.value : T ->this : this ->value : T - } - - constructor() { - throw this; ->this : this - } -} - -var aa = { ->aa : { id: number; biz(): void; } ->{ id:12, biz() { throw this; }} : { id: number; biz(): void; } - - id:12, ->id : number ->12 : number - - biz() { ->biz : () => void - - throw this; ->this : any - } -} - diff --git a/tests/baselines/reference/throwStatements.errors.txt b/tests/baselines/reference/throwStatements.errors.txt new file mode 100644 index 00000000000..e2e15bd503a --- /dev/null +++ b/tests/baselines/reference/throwStatements.errors.txt @@ -0,0 +1,91 @@ +tests/cases/conformance/statements/throwStatements/throwStatements.ts(29,1): error TS7027: Unreachable code detected. + + +==== tests/cases/conformance/statements/throwStatements/throwStatements.ts (1 errors) ==== + // all legal + + interface I { + id: number; + } + + class C implements I { + id: number; + } + + class D{ + source: T; + recurse: D; + wrapped: D> + } + + function F(x: string): number { return 42; } + + module M { + export class A { + name: string; + } + + export function F2(x: number): string { return x.toString(); } + } + + var aNumber = 9.9; + throw aNumber; + var aString = 'this is a string'; + ~~~ +!!! error TS7027: Unreachable code detected. + throw aString; + var aDate = new Date(12); + throw aDate; + var anObject = new Object(); + throw anObject; + + var anAny = null; + throw anAny; + var anOtherAny = new C(); + throw anOtherAny; + var anUndefined = undefined; + throw anUndefined; + + var aClass = new C(); + throw aClass; + var aGenericClass = new D(); + throw aGenericClass; + var anObjectLiteral = { id: 12 }; + throw anObjectLiteral; + + var aFunction = F; + throw aFunction; + throw aFunction(''); + var aLambda = (x) => 2; + throw aLambda; + throw aLambda(1); + + var aModule = M; + throw aModule; + throw typeof M; + var aClassInModule = new M.A(); + throw aClassInModule; + var aFunctionInModule = M.F2; + throw aFunctionInModule; + + // no initializer or annotation, so this is an 'any' + var x; + throw x; + + // literals + throw 0.0; + throw false; + throw null; + throw undefined; + throw 'a string'; + throw function () { return 'a string' }; + throw (x:T) => 42; + throw { x: 12, y: 13 }; + throw []; + throw ['a', ['b']]; + throw /[a-z]/; + throw new Date(); + throw new C(); + throw new Object(); + throw new D(); + \ No newline at end of file diff --git a/tests/baselines/reference/throwStatements.symbols b/tests/baselines/reference/throwStatements.symbols deleted file mode 100644 index cb65755a145..00000000000 --- a/tests/baselines/reference/throwStatements.symbols +++ /dev/null @@ -1,215 +0,0 @@ -=== tests/cases/conformance/statements/throwStatements/throwStatements.ts === -// all legal - -interface I { ->I : Symbol(I, Decl(throwStatements.ts, 0, 0)) - - id: number; ->id : Symbol(id, Decl(throwStatements.ts, 2, 13)) -} - -class C implements I { ->C : Symbol(C, Decl(throwStatements.ts, 4, 1)) ->I : Symbol(I, Decl(throwStatements.ts, 0, 0)) - - id: number; ->id : Symbol(id, Decl(throwStatements.ts, 6, 22)) -} - -class D{ ->D : Symbol(D, Decl(throwStatements.ts, 8, 1)) ->T : Symbol(T, Decl(throwStatements.ts, 10, 8)) - - source: T; ->source : Symbol(source, Decl(throwStatements.ts, 10, 11)) ->T : Symbol(T, Decl(throwStatements.ts, 10, 8)) - - recurse: D; ->recurse : Symbol(recurse, Decl(throwStatements.ts, 11, 14)) ->D : Symbol(D, Decl(throwStatements.ts, 8, 1)) ->T : Symbol(T, Decl(throwStatements.ts, 10, 8)) - - wrapped: D> ->wrapped : Symbol(wrapped, Decl(throwStatements.ts, 12, 18)) ->D : Symbol(D, Decl(throwStatements.ts, 8, 1)) ->D : Symbol(D, Decl(throwStatements.ts, 8, 1)) ->T : Symbol(T, Decl(throwStatements.ts, 10, 8)) -} - -function F(x: string): number { return 42; } ->F : Symbol(F, Decl(throwStatements.ts, 14, 1)) ->x : Symbol(x, Decl(throwStatements.ts, 16, 11)) - -module M { ->M : Symbol(M, Decl(throwStatements.ts, 16, 44)) - - export class A { ->A : Symbol(A, Decl(throwStatements.ts, 18, 10)) - - name: string; ->name : Symbol(name, Decl(throwStatements.ts, 19, 20)) - } - - export function F2(x: number): string { return x.toString(); } ->F2 : Symbol(F2, Decl(throwStatements.ts, 21, 5)) ->x : Symbol(x, Decl(throwStatements.ts, 23, 23)) ->x.toString : Symbol(Number.toString, Decl(lib.d.ts, 458, 18)) ->x : Symbol(x, Decl(throwStatements.ts, 23, 23)) ->toString : Symbol(Number.toString, Decl(lib.d.ts, 458, 18)) -} - -var aNumber = 9.9; ->aNumber : Symbol(aNumber, Decl(throwStatements.ts, 26, 3)) - -throw aNumber; ->aNumber : Symbol(aNumber, Decl(throwStatements.ts, 26, 3)) - -var aString = 'this is a string'; ->aString : Symbol(aString, Decl(throwStatements.ts, 28, 3)) - -throw aString; ->aString : Symbol(aString, Decl(throwStatements.ts, 28, 3)) - -var aDate = new Date(12); ->aDate : Symbol(aDate, Decl(throwStatements.ts, 30, 3)) ->Date : Symbol(Date, Decl(lib.d.ts, 633, 23), Decl(lib.d.ts, 815, 11)) - -throw aDate; ->aDate : Symbol(aDate, Decl(throwStatements.ts, 30, 3)) - -var anObject = new Object(); ->anObject : Symbol(anObject, Decl(throwStatements.ts, 32, 3)) ->Object : Symbol(Object, Decl(lib.d.ts, 92, 1), Decl(lib.d.ts, 223, 11)) - -throw anObject; ->anObject : Symbol(anObject, Decl(throwStatements.ts, 32, 3)) - -var anAny = null; ->anAny : Symbol(anAny, Decl(throwStatements.ts, 35, 3)) - -throw anAny; ->anAny : Symbol(anAny, Decl(throwStatements.ts, 35, 3)) - -var anOtherAny = new C(); ->anOtherAny : Symbol(anOtherAny, Decl(throwStatements.ts, 37, 3)) ->C : Symbol(C, Decl(throwStatements.ts, 4, 1)) - -throw anOtherAny; ->anOtherAny : Symbol(anOtherAny, Decl(throwStatements.ts, 37, 3)) - -var anUndefined = undefined; ->anUndefined : Symbol(anUndefined, Decl(throwStatements.ts, 39, 3)) ->undefined : Symbol(undefined) - -throw anUndefined; ->anUndefined : Symbol(anUndefined, Decl(throwStatements.ts, 39, 3)) - -var aClass = new C(); ->aClass : Symbol(aClass, Decl(throwStatements.ts, 42, 3)) ->C : Symbol(C, Decl(throwStatements.ts, 4, 1)) - -throw aClass; ->aClass : Symbol(aClass, Decl(throwStatements.ts, 42, 3)) - -var aGenericClass = new D(); ->aGenericClass : Symbol(aGenericClass, Decl(throwStatements.ts, 44, 3)) ->D : Symbol(D, Decl(throwStatements.ts, 8, 1)) - -throw aGenericClass; ->aGenericClass : Symbol(aGenericClass, Decl(throwStatements.ts, 44, 3)) - -var anObjectLiteral = { id: 12 }; ->anObjectLiteral : Symbol(anObjectLiteral, Decl(throwStatements.ts, 46, 3)) ->id : Symbol(id, Decl(throwStatements.ts, 46, 23)) - -throw anObjectLiteral; ->anObjectLiteral : Symbol(anObjectLiteral, Decl(throwStatements.ts, 46, 3)) - -var aFunction = F; ->aFunction : Symbol(aFunction, Decl(throwStatements.ts, 49, 3)) ->F : Symbol(F, Decl(throwStatements.ts, 14, 1)) - -throw aFunction; ->aFunction : Symbol(aFunction, Decl(throwStatements.ts, 49, 3)) - -throw aFunction(''); ->aFunction : Symbol(aFunction, Decl(throwStatements.ts, 49, 3)) - -var aLambda = (x) => 2; ->aLambda : Symbol(aLambda, Decl(throwStatements.ts, 52, 3)) ->x : Symbol(x, Decl(throwStatements.ts, 52, 15)) - -throw aLambda; ->aLambda : Symbol(aLambda, Decl(throwStatements.ts, 52, 3)) - -throw aLambda(1); ->aLambda : Symbol(aLambda, Decl(throwStatements.ts, 52, 3)) - -var aModule = M; ->aModule : Symbol(aModule, Decl(throwStatements.ts, 56, 3)) ->M : Symbol(M, Decl(throwStatements.ts, 16, 44)) - -throw aModule; ->aModule : Symbol(aModule, Decl(throwStatements.ts, 56, 3)) - -throw typeof M; ->M : Symbol(M, Decl(throwStatements.ts, 16, 44)) - -var aClassInModule = new M.A(); ->aClassInModule : Symbol(aClassInModule, Decl(throwStatements.ts, 59, 3)) ->M.A : Symbol(M.A, Decl(throwStatements.ts, 18, 10)) ->M : Symbol(M, Decl(throwStatements.ts, 16, 44)) ->A : Symbol(M.A, Decl(throwStatements.ts, 18, 10)) - -throw aClassInModule; ->aClassInModule : Symbol(aClassInModule, Decl(throwStatements.ts, 59, 3)) - -var aFunctionInModule = M.F2; ->aFunctionInModule : Symbol(aFunctionInModule, Decl(throwStatements.ts, 61, 3)) ->M.F2 : Symbol(M.F2, Decl(throwStatements.ts, 21, 5)) ->M : Symbol(M, Decl(throwStatements.ts, 16, 44)) ->F2 : Symbol(M.F2, Decl(throwStatements.ts, 21, 5)) - -throw aFunctionInModule; ->aFunctionInModule : Symbol(aFunctionInModule, Decl(throwStatements.ts, 61, 3)) - -// no initializer or annotation, so this is an 'any' -var x; ->x : Symbol(x, Decl(throwStatements.ts, 65, 3)) - -throw x; ->x : Symbol(x, Decl(throwStatements.ts, 65, 3)) - -// literals -throw 0.0; -throw false; -throw null; -throw undefined; ->undefined : Symbol(undefined) - -throw 'a string'; -throw function () { return 'a string' }; -throw (x:T) => 42; ->T : Symbol(T, Decl(throwStatements.ts, 75, 7)) ->x : Symbol(x, Decl(throwStatements.ts, 75, 10)) ->T : Symbol(T, Decl(throwStatements.ts, 75, 7)) - -throw { x: 12, y: 13 }; ->x : Symbol(x, Decl(throwStatements.ts, 76, 7)) ->y : Symbol(y, Decl(throwStatements.ts, 76, 14)) - -throw []; -throw ['a', ['b']]; -throw /[a-z]/; -throw new Date(); ->Date : Symbol(Date, Decl(lib.d.ts, 633, 23), Decl(lib.d.ts, 815, 11)) - -throw new C(); ->C : Symbol(C, Decl(throwStatements.ts, 4, 1)) - -throw new Object(); ->Object : Symbol(Object, Decl(lib.d.ts, 92, 1), Decl(lib.d.ts, 223, 11)) - -throw new D(); ->D : Symbol(D, Decl(throwStatements.ts, 8, 1)) - diff --git a/tests/baselines/reference/throwStatements.types b/tests/baselines/reference/throwStatements.types deleted file mode 100644 index 3d365a1b65a..00000000000 --- a/tests/baselines/reference/throwStatements.types +++ /dev/null @@ -1,266 +0,0 @@ -=== tests/cases/conformance/statements/throwStatements/throwStatements.ts === -// all legal - -interface I { ->I : I - - id: number; ->id : number -} - -class C implements I { ->C : C ->I : I - - id: number; ->id : number -} - -class D{ ->D : D ->T : T - - source: T; ->source : T ->T : T - - recurse: D; ->recurse : D ->D : D ->T : T - - wrapped: D> ->wrapped : D> ->D : D ->D : D ->T : T -} - -function F(x: string): number { return 42; } ->F : (x: string) => number ->x : string ->42 : number - -module M { ->M : typeof M - - export class A { ->A : A - - name: string; ->name : string - } - - export function F2(x: number): string { return x.toString(); } ->F2 : (x: number) => string ->x : number ->x.toString() : string ->x.toString : (radix?: number) => string ->x : number ->toString : (radix?: number) => string -} - -var aNumber = 9.9; ->aNumber : number ->9.9 : number - -throw aNumber; ->aNumber : number - -var aString = 'this is a string'; ->aString : string ->'this is a string' : string - -throw aString; ->aString : string - -var aDate = new Date(12); ->aDate : Date ->new Date(12) : Date ->Date : DateConstructor ->12 : number - -throw aDate; ->aDate : Date - -var anObject = new Object(); ->anObject : Object ->new Object() : Object ->Object : ObjectConstructor - -throw anObject; ->anObject : Object - -var anAny = null; ->anAny : any ->null : null - -throw anAny; ->anAny : any - -var anOtherAny = new C(); ->anOtherAny : any -> new C() : any ->new C() : C ->C : typeof C - -throw anOtherAny; ->anOtherAny : any - -var anUndefined = undefined; ->anUndefined : any ->undefined : undefined - -throw anUndefined; ->anUndefined : any - -var aClass = new C(); ->aClass : C ->new C() : C ->C : typeof C - -throw aClass; ->aClass : C - -var aGenericClass = new D(); ->aGenericClass : D ->new D() : D ->D : typeof D - -throw aGenericClass; ->aGenericClass : D - -var anObjectLiteral = { id: 12 }; ->anObjectLiteral : { id: number; } ->{ id: 12 } : { id: number; } ->id : number ->12 : number - -throw anObjectLiteral; ->anObjectLiteral : { id: number; } - -var aFunction = F; ->aFunction : (x: string) => number ->F : (x: string) => number - -throw aFunction; ->aFunction : (x: string) => number - -throw aFunction(''); ->aFunction('') : number ->aFunction : (x: string) => number ->'' : string - -var aLambda = (x) => 2; ->aLambda : (x: any) => number ->(x) => 2 : (x: any) => number ->x : any ->2 : number - -throw aLambda; ->aLambda : (x: any) => number - -throw aLambda(1); ->aLambda(1) : number ->aLambda : (x: any) => number ->1 : number - -var aModule = M; ->aModule : typeof M ->M : typeof M - -throw aModule; ->aModule : typeof M - -throw typeof M; ->typeof M : string ->M : typeof M - -var aClassInModule = new M.A(); ->aClassInModule : M.A ->new M.A() : M.A ->M.A : typeof M.A ->M : typeof M ->A : typeof M.A - -throw aClassInModule; ->aClassInModule : M.A - -var aFunctionInModule = M.F2; ->aFunctionInModule : (x: number) => string ->M.F2 : (x: number) => string ->M : typeof M ->F2 : (x: number) => string - -throw aFunctionInModule; ->aFunctionInModule : (x: number) => string - -// no initializer or annotation, so this is an 'any' -var x; ->x : any - -throw x; ->x : any - -// literals -throw 0.0; ->0.0 : number - -throw false; ->false : boolean - -throw null; ->null : null - -throw undefined; ->undefined : undefined - -throw 'a string'; ->'a string' : string - -throw function () { return 'a string' }; ->function () { return 'a string' } : () => string ->'a string' : string - -throw (x:T) => 42; ->(x:T) => 42 : (x: T) => number ->T : T ->x : T ->T : T ->42 : number - -throw { x: 12, y: 13 }; ->{ x: 12, y: 13 } : { x: number; y: number; } ->x : number ->12 : number ->y : number ->13 : number - -throw []; ->[] : undefined[] - -throw ['a', ['b']]; ->['a', ['b']] : (string | string[])[] ->'a' : string ->['b'] : string[] ->'b' : string - -throw /[a-z]/; ->/[a-z]/ : RegExp - -throw new Date(); ->new Date() : Date ->Date : DateConstructor - -throw new C(); ->new C() : C ->C : typeof C - -throw new Object(); ->new Object() : Object ->Object : ObjectConstructor - -throw new D(); ->new D() : D ->D : typeof D - diff --git a/tests/baselines/reference/throwWithoutNewLine2.errors.txt b/tests/baselines/reference/throwWithoutNewLine2.errors.txt index 6930d240e7b..83f4e4cc246 100644 --- a/tests/baselines/reference/throwWithoutNewLine2.errors.txt +++ b/tests/baselines/reference/throwWithoutNewLine2.errors.txt @@ -1,11 +1,14 @@ tests/cases/compiler/throwWithoutNewLine2.ts(1,6): error TS1142: Line break not permitted here. tests/cases/compiler/throwWithoutNewLine2.ts(2,1): error TS2304: Cannot find name 'a'. +tests/cases/compiler/throwWithoutNewLine2.ts(2,1): error TS7027: Unreachable code detected. -==== tests/cases/compiler/throwWithoutNewLine2.ts (2 errors) ==== +==== tests/cases/compiler/throwWithoutNewLine2.ts (3 errors) ==== throw !!! error TS1142: Line break not permitted here. a; ~ -!!! error TS2304: Cannot find name 'a'. \ No newline at end of file +!!! error TS2304: Cannot find name 'a'. + ~ +!!! error TS7027: Unreachable code detected. \ No newline at end of file diff --git a/tests/baselines/reference/typeGuardFunctionErrors.errors.txt b/tests/baselines/reference/typeGuardFunctionErrors.errors.txt index b178b02c6b4..ca06e4f63a2 100644 --- a/tests/baselines/reference/typeGuardFunctionErrors.errors.txt +++ b/tests/baselines/reference/typeGuardFunctionErrors.errors.txt @@ -9,6 +9,7 @@ tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(38,51) Property 'propA' is missing in type 'B'. tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(42,56): error TS2322: Type 'number' is not assignable to type 'string'. tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(46,56): error TS2322: Type 'T[]' is not assignable to type 'string'. +tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(50,1): error TS7027: Unreachable code detected. tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(60,7): error TS2339: Property 'propB' does not exist on type 'A'. tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(65,7): error TS2339: Property 'propB' does not exist on type 'A'. tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(70,7): error TS2339: Property 'propB' does not exist on type 'A'. @@ -37,7 +38,7 @@ tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(133,34 tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(137,39): error TS1230: A type predicate cannot reference element 'p1' in a binding pattern. -==== tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts (31 errors) ==== +==== tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts (32 errors) ==== class A { propA: number; @@ -109,6 +110,8 @@ tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(137,39 } let a: A; + ~~~ +!!! error TS7027: Unreachable code detected. let b: B; declare function isB(p1): p1 is B; diff --git a/tests/baselines/reference/typeofOperatorWithAnyOtherType.errors.txt b/tests/baselines/reference/typeofOperatorWithAnyOtherType.errors.txt index 6112b61ceb6..0139c96b3f9 100644 --- a/tests/baselines/reference/typeofOperatorWithAnyOtherType.errors.txt +++ b/tests/baselines/reference/typeofOperatorWithAnyOtherType.errors.txt @@ -1,9 +1,12 @@ tests/cases/conformance/expressions/unaryOperators/typeofOperator/typeofOperatorWithAnyOtherType.ts(46,32): error TS2365: Operator '+' cannot be applied to types 'undefined' and 'undefined'. tests/cases/conformance/expressions/unaryOperators/typeofOperator/typeofOperatorWithAnyOtherType.ts(47,32): error TS2365: Operator '+' cannot be applied to types 'null' and 'null'. tests/cases/conformance/expressions/unaryOperators/typeofOperator/typeofOperatorWithAnyOtherType.ts(48,32): error TS2365: Operator '+' cannot be applied to types 'undefined' and 'undefined'. +tests/cases/conformance/expressions/unaryOperators/typeofOperator/typeofOperatorWithAnyOtherType.ts(68,1): error TS7028: Unused label. +tests/cases/conformance/expressions/unaryOperators/typeofOperator/typeofOperatorWithAnyOtherType.ts(69,1): error TS7028: Unused label. +tests/cases/conformance/expressions/unaryOperators/typeofOperator/typeofOperatorWithAnyOtherType.ts(70,1): error TS7028: Unused label. -==== tests/cases/conformance/expressions/unaryOperators/typeofOperator/typeofOperatorWithAnyOtherType.ts (3 errors) ==== +==== tests/cases/conformance/expressions/unaryOperators/typeofOperator/typeofOperatorWithAnyOtherType.ts (6 errors) ==== // typeof operator on any type var ANY: any; @@ -78,8 +81,14 @@ tests/cases/conformance/expressions/unaryOperators/typeofOperator/typeofOperator var x: any[]; var r: () => any; z: typeof ANY; + ~ +!!! error TS7028: Unused label. x: typeof ANY2; + ~ +!!! error TS7028: Unused label. r: typeof foo; + ~ +!!! error TS7028: Unused label. z: typeof objA.a; z: typeof A.foo; z: typeof M.n; diff --git a/tests/baselines/reference/typeofOperatorWithBooleanType.errors.txt b/tests/baselines/reference/typeofOperatorWithBooleanType.errors.txt new file mode 100644 index 00000000000..9c4e2495660 --- /dev/null +++ b/tests/baselines/reference/typeofOperatorWithBooleanType.errors.txt @@ -0,0 +1,59 @@ +tests/cases/conformance/expressions/unaryOperators/typeofOperator/typeofOperatorWithBooleanType.ts(44,1): error TS7028: Unused label. +tests/cases/conformance/expressions/unaryOperators/typeofOperator/typeofOperatorWithBooleanType.ts(45,1): error TS7028: Unused label. + + +==== tests/cases/conformance/expressions/unaryOperators/typeofOperator/typeofOperatorWithBooleanType.ts (2 errors) ==== + // typeof operator on boolean type + var BOOLEAN: boolean; + + function foo(): boolean { return true; } + + class A { + public a: boolean; + static foo() { return false; } + } + module M { + export var n: boolean; + } + + var objA = new A(); + + // boolean type var + var ResultIsString1 = typeof BOOLEAN; + + // boolean type literal + var ResultIsString2 = typeof true; + var ResultIsString3 = typeof { x: true, y: false }; + + // boolean type expressions + var ResultIsString4 = typeof objA.a; + var ResultIsString5 = typeof M.n; + var ResultIsString6 = typeof foo(); + var ResultIsString7 = typeof A.foo(); + + // multiple typeof operator + var ResultIsString8 = typeof typeof BOOLEAN; + + // miss assignment operators + typeof true; + typeof BOOLEAN; + typeof foo(); + typeof true, false; + typeof objA.a; + typeof M.n; + + // use typeof in type query + var z: boolean; + var x: boolean[]; + var r: () => boolean; + z: typeof BOOLEAN; + ~ +!!! error TS7028: Unused label. + r: typeof foo; + ~ +!!! error TS7028: Unused label. + var y = { a: true, b: false}; + z: typeof y.a; + z: typeof objA.a; + z: typeof A.foo; + z: typeof M.n; \ No newline at end of file diff --git a/tests/baselines/reference/typeofOperatorWithBooleanType.symbols b/tests/baselines/reference/typeofOperatorWithBooleanType.symbols deleted file mode 100644 index 39276e61625..00000000000 --- a/tests/baselines/reference/typeofOperatorWithBooleanType.symbols +++ /dev/null @@ -1,130 +0,0 @@ -=== tests/cases/conformance/expressions/unaryOperators/typeofOperator/typeofOperatorWithBooleanType.ts === -// typeof operator on boolean type -var BOOLEAN: boolean; ->BOOLEAN : Symbol(BOOLEAN, Decl(typeofOperatorWithBooleanType.ts, 1, 3)) - -function foo(): boolean { return true; } ->foo : Symbol(foo, Decl(typeofOperatorWithBooleanType.ts, 1, 21)) - -class A { ->A : Symbol(A, Decl(typeofOperatorWithBooleanType.ts, 3, 40)) - - public a: boolean; ->a : Symbol(a, Decl(typeofOperatorWithBooleanType.ts, 5, 9)) - - static foo() { return false; } ->foo : Symbol(A.foo, Decl(typeofOperatorWithBooleanType.ts, 6, 22)) -} -module M { ->M : Symbol(M, Decl(typeofOperatorWithBooleanType.ts, 8, 1)) - - export var n: boolean; ->n : Symbol(n, Decl(typeofOperatorWithBooleanType.ts, 10, 14)) -} - -var objA = new A(); ->objA : Symbol(objA, Decl(typeofOperatorWithBooleanType.ts, 13, 3)) ->A : Symbol(A, Decl(typeofOperatorWithBooleanType.ts, 3, 40)) - -// boolean type var -var ResultIsString1 = typeof BOOLEAN; ->ResultIsString1 : Symbol(ResultIsString1, Decl(typeofOperatorWithBooleanType.ts, 16, 3)) ->BOOLEAN : Symbol(BOOLEAN, Decl(typeofOperatorWithBooleanType.ts, 1, 3)) - -// boolean type literal -var ResultIsString2 = typeof true; ->ResultIsString2 : Symbol(ResultIsString2, Decl(typeofOperatorWithBooleanType.ts, 19, 3)) - -var ResultIsString3 = typeof { x: true, y: false }; ->ResultIsString3 : Symbol(ResultIsString3, Decl(typeofOperatorWithBooleanType.ts, 20, 3)) ->x : Symbol(x, Decl(typeofOperatorWithBooleanType.ts, 20, 30)) ->y : Symbol(y, Decl(typeofOperatorWithBooleanType.ts, 20, 39)) - -// boolean type expressions -var ResultIsString4 = typeof objA.a; ->ResultIsString4 : Symbol(ResultIsString4, Decl(typeofOperatorWithBooleanType.ts, 23, 3)) ->objA.a : Symbol(A.a, Decl(typeofOperatorWithBooleanType.ts, 5, 9)) ->objA : Symbol(objA, Decl(typeofOperatorWithBooleanType.ts, 13, 3)) ->a : Symbol(A.a, Decl(typeofOperatorWithBooleanType.ts, 5, 9)) - -var ResultIsString5 = typeof M.n; ->ResultIsString5 : Symbol(ResultIsString5, Decl(typeofOperatorWithBooleanType.ts, 24, 3)) ->M.n : Symbol(M.n, Decl(typeofOperatorWithBooleanType.ts, 10, 14)) ->M : Symbol(M, Decl(typeofOperatorWithBooleanType.ts, 8, 1)) ->n : Symbol(M.n, Decl(typeofOperatorWithBooleanType.ts, 10, 14)) - -var ResultIsString6 = typeof foo(); ->ResultIsString6 : Symbol(ResultIsString6, Decl(typeofOperatorWithBooleanType.ts, 25, 3)) ->foo : Symbol(foo, Decl(typeofOperatorWithBooleanType.ts, 1, 21)) - -var ResultIsString7 = typeof A.foo(); ->ResultIsString7 : Symbol(ResultIsString7, Decl(typeofOperatorWithBooleanType.ts, 26, 3)) ->A.foo : Symbol(A.foo, Decl(typeofOperatorWithBooleanType.ts, 6, 22)) ->A : Symbol(A, Decl(typeofOperatorWithBooleanType.ts, 3, 40)) ->foo : Symbol(A.foo, Decl(typeofOperatorWithBooleanType.ts, 6, 22)) - -// multiple typeof operator -var ResultIsString8 = typeof typeof BOOLEAN; ->ResultIsString8 : Symbol(ResultIsString8, Decl(typeofOperatorWithBooleanType.ts, 29, 3)) ->BOOLEAN : Symbol(BOOLEAN, Decl(typeofOperatorWithBooleanType.ts, 1, 3)) - -// miss assignment operators -typeof true; -typeof BOOLEAN; ->BOOLEAN : Symbol(BOOLEAN, Decl(typeofOperatorWithBooleanType.ts, 1, 3)) - -typeof foo(); ->foo : Symbol(foo, Decl(typeofOperatorWithBooleanType.ts, 1, 21)) - -typeof true, false; -typeof objA.a; ->objA.a : Symbol(A.a, Decl(typeofOperatorWithBooleanType.ts, 5, 9)) ->objA : Symbol(objA, Decl(typeofOperatorWithBooleanType.ts, 13, 3)) ->a : Symbol(A.a, Decl(typeofOperatorWithBooleanType.ts, 5, 9)) - -typeof M.n; ->M.n : Symbol(M.n, Decl(typeofOperatorWithBooleanType.ts, 10, 14)) ->M : Symbol(M, Decl(typeofOperatorWithBooleanType.ts, 8, 1)) ->n : Symbol(M.n, Decl(typeofOperatorWithBooleanType.ts, 10, 14)) - -// use typeof in type query -var z: boolean; ->z : Symbol(z, Decl(typeofOperatorWithBooleanType.ts, 40, 3)) - -var x: boolean[]; ->x : Symbol(x, Decl(typeofOperatorWithBooleanType.ts, 41, 3)) - -var r: () => boolean; ->r : Symbol(r, Decl(typeofOperatorWithBooleanType.ts, 42, 3)) - -z: typeof BOOLEAN; ->BOOLEAN : Symbol(BOOLEAN, Decl(typeofOperatorWithBooleanType.ts, 1, 3)) - -r: typeof foo; ->foo : Symbol(foo, Decl(typeofOperatorWithBooleanType.ts, 1, 21)) - -var y = { a: true, b: false}; ->y : Symbol(y, Decl(typeofOperatorWithBooleanType.ts, 45, 3)) ->a : Symbol(a, Decl(typeofOperatorWithBooleanType.ts, 45, 9)) ->b : Symbol(b, Decl(typeofOperatorWithBooleanType.ts, 45, 18)) - -z: typeof y.a; ->y.a : Symbol(a, Decl(typeofOperatorWithBooleanType.ts, 45, 9)) ->y : Symbol(y, Decl(typeofOperatorWithBooleanType.ts, 45, 3)) ->a : Symbol(a, Decl(typeofOperatorWithBooleanType.ts, 45, 9)) - -z: typeof objA.a; ->objA.a : Symbol(A.a, Decl(typeofOperatorWithBooleanType.ts, 5, 9)) ->objA : Symbol(objA, Decl(typeofOperatorWithBooleanType.ts, 13, 3)) ->a : Symbol(A.a, Decl(typeofOperatorWithBooleanType.ts, 5, 9)) - -z: typeof A.foo; ->A.foo : Symbol(A.foo, Decl(typeofOperatorWithBooleanType.ts, 6, 22)) ->A : Symbol(A, Decl(typeofOperatorWithBooleanType.ts, 3, 40)) ->foo : Symbol(A.foo, Decl(typeofOperatorWithBooleanType.ts, 6, 22)) - -z: typeof M.n; ->M.n : Symbol(M.n, Decl(typeofOperatorWithBooleanType.ts, 10, 14)) ->M : Symbol(M, Decl(typeofOperatorWithBooleanType.ts, 8, 1)) ->n : Symbol(M.n, Decl(typeofOperatorWithBooleanType.ts, 10, 14)) - diff --git a/tests/baselines/reference/typeofOperatorWithBooleanType.types b/tests/baselines/reference/typeofOperatorWithBooleanType.types deleted file mode 100644 index 06cd7466a18..00000000000 --- a/tests/baselines/reference/typeofOperatorWithBooleanType.types +++ /dev/null @@ -1,176 +0,0 @@ -=== tests/cases/conformance/expressions/unaryOperators/typeofOperator/typeofOperatorWithBooleanType.ts === -// typeof operator on boolean type -var BOOLEAN: boolean; ->BOOLEAN : boolean - -function foo(): boolean { return true; } ->foo : () => boolean ->true : boolean - -class A { ->A : A - - public a: boolean; ->a : boolean - - static foo() { return false; } ->foo : () => boolean ->false : boolean -} -module M { ->M : typeof M - - export var n: boolean; ->n : boolean -} - -var objA = new A(); ->objA : A ->new A() : A ->A : typeof A - -// boolean type var -var ResultIsString1 = typeof BOOLEAN; ->ResultIsString1 : string ->typeof BOOLEAN : string ->BOOLEAN : boolean - -// boolean type literal -var ResultIsString2 = typeof true; ->ResultIsString2 : string ->typeof true : string ->true : boolean - -var ResultIsString3 = typeof { x: true, y: false }; ->ResultIsString3 : string ->typeof { x: true, y: false } : string ->{ x: true, y: false } : { x: boolean; y: boolean; } ->x : boolean ->true : boolean ->y : boolean ->false : boolean - -// boolean type expressions -var ResultIsString4 = typeof objA.a; ->ResultIsString4 : string ->typeof objA.a : string ->objA.a : boolean ->objA : A ->a : boolean - -var ResultIsString5 = typeof M.n; ->ResultIsString5 : string ->typeof M.n : string ->M.n : boolean ->M : typeof M ->n : boolean - -var ResultIsString6 = typeof foo(); ->ResultIsString6 : string ->typeof foo() : string ->foo() : boolean ->foo : () => boolean - -var ResultIsString7 = typeof A.foo(); ->ResultIsString7 : string ->typeof A.foo() : string ->A.foo() : boolean ->A.foo : () => boolean ->A : typeof A ->foo : () => boolean - -// multiple typeof operator -var ResultIsString8 = typeof typeof BOOLEAN; ->ResultIsString8 : string ->typeof typeof BOOLEAN : string ->typeof BOOLEAN : string ->BOOLEAN : boolean - -// miss assignment operators -typeof true; ->typeof true : string ->true : boolean - -typeof BOOLEAN; ->typeof BOOLEAN : string ->BOOLEAN : boolean - -typeof foo(); ->typeof foo() : string ->foo() : boolean ->foo : () => boolean - -typeof true, false; ->typeof true, false : boolean ->typeof true : string ->true : boolean ->false : boolean - -typeof objA.a; ->typeof objA.a : string ->objA.a : boolean ->objA : A ->a : boolean - -typeof M.n; ->typeof M.n : string ->M.n : boolean ->M : typeof M ->n : boolean - -// use typeof in type query -var z: boolean; ->z : boolean - -var x: boolean[]; ->x : boolean[] - -var r: () => boolean; ->r : () => boolean - -z: typeof BOOLEAN; ->z : any ->typeof BOOLEAN : string ->BOOLEAN : boolean - -r: typeof foo; ->r : any ->typeof foo : string ->foo : () => boolean - -var y = { a: true, b: false}; ->y : { a: boolean; b: boolean; } ->{ a: true, b: false} : { a: boolean; b: boolean; } ->a : boolean ->true : boolean ->b : boolean ->false : boolean - -z: typeof y.a; ->z : any ->typeof y.a : string ->y.a : boolean ->y : { a: boolean; b: boolean; } ->a : boolean - -z: typeof objA.a; ->z : any ->typeof objA.a : string ->objA.a : boolean ->objA : A ->a : boolean - -z: typeof A.foo; ->z : any ->typeof A.foo : string ->A.foo : () => boolean ->A : typeof A ->foo : () => boolean - -z: typeof M.n; ->z : any ->typeof M.n : string ->M.n : boolean ->M : typeof M ->n : boolean - diff --git a/tests/baselines/reference/typeofOperatorWithEnumType.errors.txt b/tests/baselines/reference/typeofOperatorWithEnumType.errors.txt new file mode 100644 index 00000000000..6e473b7487d --- /dev/null +++ b/tests/baselines/reference/typeofOperatorWithEnumType.errors.txt @@ -0,0 +1,33 @@ +tests/cases/conformance/expressions/unaryOperators/typeofOperator/typeofOperatorWithEnumType.ts(26,1): error TS7028: Unused label. + + +==== tests/cases/conformance/expressions/unaryOperators/typeofOperator/typeofOperatorWithEnumType.ts (1 errors) ==== + // typeof operator on enum type + + enum ENUM { }; + enum ENUM1 { A, B, "" }; + + // enum type var + var ResultIsString1 = typeof ENUM; + var ResultIsString2 = typeof ENUM1; + + // enum type expressions + var ResultIsString3 = typeof ENUM1["A"]; + var ResultIsString4 = typeof (ENUM[0] + ENUM1["B"]); + + // multiple typeof operators + var ResultIsString5 = typeof typeof ENUM; + var ResultIsString6 = typeof typeof typeof (ENUM[0] + ENUM1.B); + + // miss assignment operators + typeof ENUM; + typeof ENUM1; + typeof ENUM1["B"]; + typeof ENUM, ENUM1; + + // use typeof in type query + enum z { }; + z: typeof ENUM; + ~ +!!! error TS7028: Unused label. + z: typeof ENUM1; \ No newline at end of file diff --git a/tests/baselines/reference/typeofOperatorWithEnumType.symbols b/tests/baselines/reference/typeofOperatorWithEnumType.symbols deleted file mode 100644 index 3ae150ece03..00000000000 --- a/tests/baselines/reference/typeofOperatorWithEnumType.symbols +++ /dev/null @@ -1,69 +0,0 @@ -=== tests/cases/conformance/expressions/unaryOperators/typeofOperator/typeofOperatorWithEnumType.ts === -// typeof operator on enum type - -enum ENUM { }; ->ENUM : Symbol(ENUM, Decl(typeofOperatorWithEnumType.ts, 0, 0)) - -enum ENUM1 { A, B, "" }; ->ENUM1 : Symbol(ENUM1, Decl(typeofOperatorWithEnumType.ts, 2, 14)) ->A : Symbol(ENUM1.A, Decl(typeofOperatorWithEnumType.ts, 3, 12)) ->B : Symbol(ENUM1.B, Decl(typeofOperatorWithEnumType.ts, 3, 15)) - -// enum type var -var ResultIsString1 = typeof ENUM; ->ResultIsString1 : Symbol(ResultIsString1, Decl(typeofOperatorWithEnumType.ts, 6, 3)) ->ENUM : Symbol(ENUM, Decl(typeofOperatorWithEnumType.ts, 0, 0)) - -var ResultIsString2 = typeof ENUM1; ->ResultIsString2 : Symbol(ResultIsString2, Decl(typeofOperatorWithEnumType.ts, 7, 3)) ->ENUM1 : Symbol(ENUM1, Decl(typeofOperatorWithEnumType.ts, 2, 14)) - -// enum type expressions -var ResultIsString3 = typeof ENUM1["A"]; ->ResultIsString3 : Symbol(ResultIsString3, Decl(typeofOperatorWithEnumType.ts, 10, 3)) ->ENUM1 : Symbol(ENUM1, Decl(typeofOperatorWithEnumType.ts, 2, 14)) ->"A" : Symbol(ENUM1.A, Decl(typeofOperatorWithEnumType.ts, 3, 12)) - -var ResultIsString4 = typeof (ENUM[0] + ENUM1["B"]); ->ResultIsString4 : Symbol(ResultIsString4, Decl(typeofOperatorWithEnumType.ts, 11, 3)) ->ENUM : Symbol(ENUM, Decl(typeofOperatorWithEnumType.ts, 0, 0)) ->ENUM1 : Symbol(ENUM1, Decl(typeofOperatorWithEnumType.ts, 2, 14)) ->"B" : Symbol(ENUM1.B, Decl(typeofOperatorWithEnumType.ts, 3, 15)) - -// multiple typeof operators -var ResultIsString5 = typeof typeof ENUM; ->ResultIsString5 : Symbol(ResultIsString5, Decl(typeofOperatorWithEnumType.ts, 14, 3)) ->ENUM : Symbol(ENUM, Decl(typeofOperatorWithEnumType.ts, 0, 0)) - -var ResultIsString6 = typeof typeof typeof (ENUM[0] + ENUM1.B); ->ResultIsString6 : Symbol(ResultIsString6, Decl(typeofOperatorWithEnumType.ts, 15, 3)) ->ENUM : Symbol(ENUM, Decl(typeofOperatorWithEnumType.ts, 0, 0)) ->ENUM1.B : Symbol(ENUM1.B, Decl(typeofOperatorWithEnumType.ts, 3, 15)) ->ENUM1 : Symbol(ENUM1, Decl(typeofOperatorWithEnumType.ts, 2, 14)) ->B : Symbol(ENUM1.B, Decl(typeofOperatorWithEnumType.ts, 3, 15)) - -// miss assignment operators -typeof ENUM; ->ENUM : Symbol(ENUM, Decl(typeofOperatorWithEnumType.ts, 0, 0)) - -typeof ENUM1; ->ENUM1 : Symbol(ENUM1, Decl(typeofOperatorWithEnumType.ts, 2, 14)) - -typeof ENUM1["B"]; ->ENUM1 : Symbol(ENUM1, Decl(typeofOperatorWithEnumType.ts, 2, 14)) ->"B" : Symbol(ENUM1.B, Decl(typeofOperatorWithEnumType.ts, 3, 15)) - -typeof ENUM, ENUM1; ->ENUM : Symbol(ENUM, Decl(typeofOperatorWithEnumType.ts, 0, 0)) ->ENUM1 : Symbol(ENUM1, Decl(typeofOperatorWithEnumType.ts, 2, 14)) - -// use typeof in type query -enum z { }; ->z : Symbol(z, Decl(typeofOperatorWithEnumType.ts, 21, 19)) - -z: typeof ENUM; ->ENUM : Symbol(ENUM, Decl(typeofOperatorWithEnumType.ts, 0, 0)) - -z: typeof ENUM1; ->ENUM1 : Symbol(ENUM1, Decl(typeofOperatorWithEnumType.ts, 2, 14)) - diff --git a/tests/baselines/reference/typeofOperatorWithEnumType.types b/tests/baselines/reference/typeofOperatorWithEnumType.types deleted file mode 100644 index 82bf699a22f..00000000000 --- a/tests/baselines/reference/typeofOperatorWithEnumType.types +++ /dev/null @@ -1,98 +0,0 @@ -=== tests/cases/conformance/expressions/unaryOperators/typeofOperator/typeofOperatorWithEnumType.ts === -// typeof operator on enum type - -enum ENUM { }; ->ENUM : ENUM - -enum ENUM1 { A, B, "" }; ->ENUM1 : ENUM1 ->A : ENUM1 ->B : ENUM1 - -// enum type var -var ResultIsString1 = typeof ENUM; ->ResultIsString1 : string ->typeof ENUM : string ->ENUM : typeof ENUM - -var ResultIsString2 = typeof ENUM1; ->ResultIsString2 : string ->typeof ENUM1 : string ->ENUM1 : typeof ENUM1 - -// enum type expressions -var ResultIsString3 = typeof ENUM1["A"]; ->ResultIsString3 : string ->typeof ENUM1["A"] : string ->ENUM1["A"] : ENUM1 ->ENUM1 : typeof ENUM1 ->"A" : string - -var ResultIsString4 = typeof (ENUM[0] + ENUM1["B"]); ->ResultIsString4 : string ->typeof (ENUM[0] + ENUM1["B"]) : string ->(ENUM[0] + ENUM1["B"]) : string ->ENUM[0] + ENUM1["B"] : string ->ENUM[0] : string ->ENUM : typeof ENUM ->0 : number ->ENUM1["B"] : ENUM1 ->ENUM1 : typeof ENUM1 ->"B" : string - -// multiple typeof operators -var ResultIsString5 = typeof typeof ENUM; ->ResultIsString5 : string ->typeof typeof ENUM : string ->typeof ENUM : string ->ENUM : typeof ENUM - -var ResultIsString6 = typeof typeof typeof (ENUM[0] + ENUM1.B); ->ResultIsString6 : string ->typeof typeof typeof (ENUM[0] + ENUM1.B) : string ->typeof typeof (ENUM[0] + ENUM1.B) : string ->typeof (ENUM[0] + ENUM1.B) : string ->(ENUM[0] + ENUM1.B) : string ->ENUM[0] + ENUM1.B : string ->ENUM[0] : string ->ENUM : typeof ENUM ->0 : number ->ENUM1.B : ENUM1 ->ENUM1 : typeof ENUM1 ->B : ENUM1 - -// miss assignment operators -typeof ENUM; ->typeof ENUM : string ->ENUM : typeof ENUM - -typeof ENUM1; ->typeof ENUM1 : string ->ENUM1 : typeof ENUM1 - -typeof ENUM1["B"]; ->typeof ENUM1["B"] : string ->ENUM1["B"] : ENUM1 ->ENUM1 : typeof ENUM1 ->"B" : string - -typeof ENUM, ENUM1; ->typeof ENUM, ENUM1 : typeof ENUM1 ->typeof ENUM : string ->ENUM : typeof ENUM ->ENUM1 : typeof ENUM1 - -// use typeof in type query -enum z { }; ->z : z - -z: typeof ENUM; ->z : any ->typeof ENUM : string ->ENUM : typeof ENUM - -z: typeof ENUM1; ->z : any ->typeof ENUM1 : string ->ENUM1 : typeof ENUM1 - diff --git a/tests/baselines/reference/typeofOperatorWithNumberType.errors.txt b/tests/baselines/reference/typeofOperatorWithNumberType.errors.txt new file mode 100644 index 00000000000..b84d3798ab0 --- /dev/null +++ b/tests/baselines/reference/typeofOperatorWithNumberType.errors.txt @@ -0,0 +1,69 @@ +tests/cases/conformance/expressions/unaryOperators/typeofOperator/typeofOperatorWithNumberType.ts(50,1): error TS7028: Unused label. +tests/cases/conformance/expressions/unaryOperators/typeofOperator/typeofOperatorWithNumberType.ts(51,1): error TS7028: Unused label. +tests/cases/conformance/expressions/unaryOperators/typeofOperator/typeofOperatorWithNumberType.ts(52,1): error TS7028: Unused label. + + +==== tests/cases/conformance/expressions/unaryOperators/typeofOperator/typeofOperatorWithNumberType.ts (3 errors) ==== + // typeof operator on number type + var NUMBER: number; + var NUMBER1: number[] = [1, 2]; + + function foo(): number { return 1; } + + class A { + public a: number; + static foo() { return 1; } + } + module M { + export var n: number; + } + + var objA = new A(); + + // number type var + var ResultIsString1 = typeof NUMBER; + var ResultIsString2 = typeof NUMBER1; + + // number type literal + var ResultIsString3 = typeof 1; + var ResultIsString4 = typeof { x: 1, y: 2}; + var ResultIsString5 = typeof { x: 1, y: (n: number) => { return n; } }; + + // number type expressions + var ResultIsString6 = typeof objA.a; + var ResultIsString7 = typeof M.n; + var ResultIsString8 = typeof NUMBER1[0]; + var ResultIsString9 = typeof foo(); + var ResultIsString10 = typeof A.foo(); + var ResultIsString11 = typeof (NUMBER + NUMBER); + + // multiple typeof operators + var ResultIsString12 = typeof typeof NUMBER; + var ResultIsString13 = typeof typeof typeof (NUMBER + NUMBER); + + // miss assignment operators + typeof 1; + typeof NUMBER; + typeof NUMBER1; + typeof foo(); + typeof objA.a; + typeof M.n; + typeof objA.a, M.n; + + // use typeof in type query + var z: number; + var x: number[]; + z: typeof NUMBER; + ~ +!!! error TS7028: Unused label. + x: typeof NUMBER1; + ~ +!!! error TS7028: Unused label. + r: typeof foo; + ~ +!!! error TS7028: Unused label. + var y = { a: 1, b: 2 }; + z: typeof y.a; + z: typeof objA.a; + z: typeof A.foo; + z: typeof M.n; \ No newline at end of file diff --git a/tests/baselines/reference/typeofOperatorWithNumberType.symbols b/tests/baselines/reference/typeofOperatorWithNumberType.symbols deleted file mode 100644 index df49b7dccb6..00000000000 --- a/tests/baselines/reference/typeofOperatorWithNumberType.symbols +++ /dev/null @@ -1,168 +0,0 @@ -=== tests/cases/conformance/expressions/unaryOperators/typeofOperator/typeofOperatorWithNumberType.ts === -// typeof operator on number type -var NUMBER: number; ->NUMBER : Symbol(NUMBER, Decl(typeofOperatorWithNumberType.ts, 1, 3)) - -var NUMBER1: number[] = [1, 2]; ->NUMBER1 : Symbol(NUMBER1, Decl(typeofOperatorWithNumberType.ts, 2, 3)) - -function foo(): number { return 1; } ->foo : Symbol(foo, Decl(typeofOperatorWithNumberType.ts, 2, 31)) - -class A { ->A : Symbol(A, Decl(typeofOperatorWithNumberType.ts, 4, 36)) - - public a: number; ->a : Symbol(a, Decl(typeofOperatorWithNumberType.ts, 6, 9)) - - static foo() { return 1; } ->foo : Symbol(A.foo, Decl(typeofOperatorWithNumberType.ts, 7, 21)) -} -module M { ->M : Symbol(M, Decl(typeofOperatorWithNumberType.ts, 9, 1)) - - export var n: number; ->n : Symbol(n, Decl(typeofOperatorWithNumberType.ts, 11, 14)) -} - -var objA = new A(); ->objA : Symbol(objA, Decl(typeofOperatorWithNumberType.ts, 14, 3)) ->A : Symbol(A, Decl(typeofOperatorWithNumberType.ts, 4, 36)) - -// number type var -var ResultIsString1 = typeof NUMBER; ->ResultIsString1 : Symbol(ResultIsString1, Decl(typeofOperatorWithNumberType.ts, 17, 3)) ->NUMBER : Symbol(NUMBER, Decl(typeofOperatorWithNumberType.ts, 1, 3)) - -var ResultIsString2 = typeof NUMBER1; ->ResultIsString2 : Symbol(ResultIsString2, Decl(typeofOperatorWithNumberType.ts, 18, 3)) ->NUMBER1 : Symbol(NUMBER1, Decl(typeofOperatorWithNumberType.ts, 2, 3)) - -// number type literal -var ResultIsString3 = typeof 1; ->ResultIsString3 : Symbol(ResultIsString3, Decl(typeofOperatorWithNumberType.ts, 21, 3)) - -var ResultIsString4 = typeof { x: 1, y: 2}; ->ResultIsString4 : Symbol(ResultIsString4, Decl(typeofOperatorWithNumberType.ts, 22, 3)) ->x : Symbol(x, Decl(typeofOperatorWithNumberType.ts, 22, 30)) ->y : Symbol(y, Decl(typeofOperatorWithNumberType.ts, 22, 36)) - -var ResultIsString5 = typeof { x: 1, y: (n: number) => { return n; } }; ->ResultIsString5 : Symbol(ResultIsString5, Decl(typeofOperatorWithNumberType.ts, 23, 3)) ->x : Symbol(x, Decl(typeofOperatorWithNumberType.ts, 23, 30)) ->y : Symbol(y, Decl(typeofOperatorWithNumberType.ts, 23, 36)) ->n : Symbol(n, Decl(typeofOperatorWithNumberType.ts, 23, 41)) ->n : Symbol(n, Decl(typeofOperatorWithNumberType.ts, 23, 41)) - -// number type expressions -var ResultIsString6 = typeof objA.a; ->ResultIsString6 : Symbol(ResultIsString6, Decl(typeofOperatorWithNumberType.ts, 26, 3)) ->objA.a : Symbol(A.a, Decl(typeofOperatorWithNumberType.ts, 6, 9)) ->objA : Symbol(objA, Decl(typeofOperatorWithNumberType.ts, 14, 3)) ->a : Symbol(A.a, Decl(typeofOperatorWithNumberType.ts, 6, 9)) - -var ResultIsString7 = typeof M.n; ->ResultIsString7 : Symbol(ResultIsString7, Decl(typeofOperatorWithNumberType.ts, 27, 3)) ->M.n : Symbol(M.n, Decl(typeofOperatorWithNumberType.ts, 11, 14)) ->M : Symbol(M, Decl(typeofOperatorWithNumberType.ts, 9, 1)) ->n : Symbol(M.n, Decl(typeofOperatorWithNumberType.ts, 11, 14)) - -var ResultIsString8 = typeof NUMBER1[0]; ->ResultIsString8 : Symbol(ResultIsString8, Decl(typeofOperatorWithNumberType.ts, 28, 3)) ->NUMBER1 : Symbol(NUMBER1, Decl(typeofOperatorWithNumberType.ts, 2, 3)) - -var ResultIsString9 = typeof foo(); ->ResultIsString9 : Symbol(ResultIsString9, Decl(typeofOperatorWithNumberType.ts, 29, 3)) ->foo : Symbol(foo, Decl(typeofOperatorWithNumberType.ts, 2, 31)) - -var ResultIsString10 = typeof A.foo(); ->ResultIsString10 : Symbol(ResultIsString10, Decl(typeofOperatorWithNumberType.ts, 30, 3)) ->A.foo : Symbol(A.foo, Decl(typeofOperatorWithNumberType.ts, 7, 21)) ->A : Symbol(A, Decl(typeofOperatorWithNumberType.ts, 4, 36)) ->foo : Symbol(A.foo, Decl(typeofOperatorWithNumberType.ts, 7, 21)) - -var ResultIsString11 = typeof (NUMBER + NUMBER); ->ResultIsString11 : Symbol(ResultIsString11, Decl(typeofOperatorWithNumberType.ts, 31, 3)) ->NUMBER : Symbol(NUMBER, Decl(typeofOperatorWithNumberType.ts, 1, 3)) ->NUMBER : Symbol(NUMBER, Decl(typeofOperatorWithNumberType.ts, 1, 3)) - -// multiple typeof operators -var ResultIsString12 = typeof typeof NUMBER; ->ResultIsString12 : Symbol(ResultIsString12, Decl(typeofOperatorWithNumberType.ts, 34, 3)) ->NUMBER : Symbol(NUMBER, Decl(typeofOperatorWithNumberType.ts, 1, 3)) - -var ResultIsString13 = typeof typeof typeof (NUMBER + NUMBER); ->ResultIsString13 : Symbol(ResultIsString13, Decl(typeofOperatorWithNumberType.ts, 35, 3)) ->NUMBER : Symbol(NUMBER, Decl(typeofOperatorWithNumberType.ts, 1, 3)) ->NUMBER : Symbol(NUMBER, Decl(typeofOperatorWithNumberType.ts, 1, 3)) - -// miss assignment operators -typeof 1; -typeof NUMBER; ->NUMBER : Symbol(NUMBER, Decl(typeofOperatorWithNumberType.ts, 1, 3)) - -typeof NUMBER1; ->NUMBER1 : Symbol(NUMBER1, Decl(typeofOperatorWithNumberType.ts, 2, 3)) - -typeof foo(); ->foo : Symbol(foo, Decl(typeofOperatorWithNumberType.ts, 2, 31)) - -typeof objA.a; ->objA.a : Symbol(A.a, Decl(typeofOperatorWithNumberType.ts, 6, 9)) ->objA : Symbol(objA, Decl(typeofOperatorWithNumberType.ts, 14, 3)) ->a : Symbol(A.a, Decl(typeofOperatorWithNumberType.ts, 6, 9)) - -typeof M.n; ->M.n : Symbol(M.n, Decl(typeofOperatorWithNumberType.ts, 11, 14)) ->M : Symbol(M, Decl(typeofOperatorWithNumberType.ts, 9, 1)) ->n : Symbol(M.n, Decl(typeofOperatorWithNumberType.ts, 11, 14)) - -typeof objA.a, M.n; ->objA.a : Symbol(A.a, Decl(typeofOperatorWithNumberType.ts, 6, 9)) ->objA : Symbol(objA, Decl(typeofOperatorWithNumberType.ts, 14, 3)) ->a : Symbol(A.a, Decl(typeofOperatorWithNumberType.ts, 6, 9)) ->M.n : Symbol(M.n, Decl(typeofOperatorWithNumberType.ts, 11, 14)) ->M : Symbol(M, Decl(typeofOperatorWithNumberType.ts, 9, 1)) ->n : Symbol(M.n, Decl(typeofOperatorWithNumberType.ts, 11, 14)) - -// use typeof in type query -var z: number; ->z : Symbol(z, Decl(typeofOperatorWithNumberType.ts, 47, 3)) - -var x: number[]; ->x : Symbol(x, Decl(typeofOperatorWithNumberType.ts, 48, 3)) - -z: typeof NUMBER; ->NUMBER : Symbol(NUMBER, Decl(typeofOperatorWithNumberType.ts, 1, 3)) - -x: typeof NUMBER1; ->NUMBER1 : Symbol(NUMBER1, Decl(typeofOperatorWithNumberType.ts, 2, 3)) - -r: typeof foo; ->foo : Symbol(foo, Decl(typeofOperatorWithNumberType.ts, 2, 31)) - -var y = { a: 1, b: 2 }; ->y : Symbol(y, Decl(typeofOperatorWithNumberType.ts, 52, 3)) ->a : Symbol(a, Decl(typeofOperatorWithNumberType.ts, 52, 9)) ->b : Symbol(b, Decl(typeofOperatorWithNumberType.ts, 52, 15)) - -z: typeof y.a; ->y.a : Symbol(a, Decl(typeofOperatorWithNumberType.ts, 52, 9)) ->y : Symbol(y, Decl(typeofOperatorWithNumberType.ts, 52, 3)) ->a : Symbol(a, Decl(typeofOperatorWithNumberType.ts, 52, 9)) - -z: typeof objA.a; ->objA.a : Symbol(A.a, Decl(typeofOperatorWithNumberType.ts, 6, 9)) ->objA : Symbol(objA, Decl(typeofOperatorWithNumberType.ts, 14, 3)) ->a : Symbol(A.a, Decl(typeofOperatorWithNumberType.ts, 6, 9)) - -z: typeof A.foo; ->A.foo : Symbol(A.foo, Decl(typeofOperatorWithNumberType.ts, 7, 21)) ->A : Symbol(A, Decl(typeofOperatorWithNumberType.ts, 4, 36)) ->foo : Symbol(A.foo, Decl(typeofOperatorWithNumberType.ts, 7, 21)) - -z: typeof M.n; ->M.n : Symbol(M.n, Decl(typeofOperatorWithNumberType.ts, 11, 14)) ->M : Symbol(M, Decl(typeofOperatorWithNumberType.ts, 9, 1)) ->n : Symbol(M.n, Decl(typeofOperatorWithNumberType.ts, 11, 14)) - diff --git a/tests/baselines/reference/typeofOperatorWithNumberType.types b/tests/baselines/reference/typeofOperatorWithNumberType.types deleted file mode 100644 index b80e6b1d4a8..00000000000 --- a/tests/baselines/reference/typeofOperatorWithNumberType.types +++ /dev/null @@ -1,233 +0,0 @@ -=== tests/cases/conformance/expressions/unaryOperators/typeofOperator/typeofOperatorWithNumberType.ts === -// typeof operator on number type -var NUMBER: number; ->NUMBER : number - -var NUMBER1: number[] = [1, 2]; ->NUMBER1 : number[] ->[1, 2] : number[] ->1 : number ->2 : number - -function foo(): number { return 1; } ->foo : () => number ->1 : number - -class A { ->A : A - - public a: number; ->a : number - - static foo() { return 1; } ->foo : () => number ->1 : number -} -module M { ->M : typeof M - - export var n: number; ->n : number -} - -var objA = new A(); ->objA : A ->new A() : A ->A : typeof A - -// number type var -var ResultIsString1 = typeof NUMBER; ->ResultIsString1 : string ->typeof NUMBER : string ->NUMBER : number - -var ResultIsString2 = typeof NUMBER1; ->ResultIsString2 : string ->typeof NUMBER1 : string ->NUMBER1 : number[] - -// number type literal -var ResultIsString3 = typeof 1; ->ResultIsString3 : string ->typeof 1 : string ->1 : number - -var ResultIsString4 = typeof { x: 1, y: 2}; ->ResultIsString4 : string ->typeof { x: 1, y: 2} : string ->{ x: 1, y: 2} : { x: number; y: number; } ->x : number ->1 : number ->y : number ->2 : number - -var ResultIsString5 = typeof { x: 1, y: (n: number) => { return n; } }; ->ResultIsString5 : string ->typeof { x: 1, y: (n: number) => { return n; } } : string ->{ x: 1, y: (n: number) => { return n; } } : { x: number; y: (n: number) => number; } ->x : number ->1 : number ->y : (n: number) => number ->(n: number) => { return n; } : (n: number) => number ->n : number ->n : number - -// number type expressions -var ResultIsString6 = typeof objA.a; ->ResultIsString6 : string ->typeof objA.a : string ->objA.a : number ->objA : A ->a : number - -var ResultIsString7 = typeof M.n; ->ResultIsString7 : string ->typeof M.n : string ->M.n : number ->M : typeof M ->n : number - -var ResultIsString8 = typeof NUMBER1[0]; ->ResultIsString8 : string ->typeof NUMBER1[0] : string ->NUMBER1[0] : number ->NUMBER1 : number[] ->0 : number - -var ResultIsString9 = typeof foo(); ->ResultIsString9 : string ->typeof foo() : string ->foo() : number ->foo : () => number - -var ResultIsString10 = typeof A.foo(); ->ResultIsString10 : string ->typeof A.foo() : string ->A.foo() : number ->A.foo : () => number ->A : typeof A ->foo : () => number - -var ResultIsString11 = typeof (NUMBER + NUMBER); ->ResultIsString11 : string ->typeof (NUMBER + NUMBER) : string ->(NUMBER + NUMBER) : number ->NUMBER + NUMBER : number ->NUMBER : number ->NUMBER : number - -// multiple typeof operators -var ResultIsString12 = typeof typeof NUMBER; ->ResultIsString12 : string ->typeof typeof NUMBER : string ->typeof NUMBER : string ->NUMBER : number - -var ResultIsString13 = typeof typeof typeof (NUMBER + NUMBER); ->ResultIsString13 : string ->typeof typeof typeof (NUMBER + NUMBER) : string ->typeof typeof (NUMBER + NUMBER) : string ->typeof (NUMBER + NUMBER) : string ->(NUMBER + NUMBER) : number ->NUMBER + NUMBER : number ->NUMBER : number ->NUMBER : number - -// miss assignment operators -typeof 1; ->typeof 1 : string ->1 : number - -typeof NUMBER; ->typeof NUMBER : string ->NUMBER : number - -typeof NUMBER1; ->typeof NUMBER1 : string ->NUMBER1 : number[] - -typeof foo(); ->typeof foo() : string ->foo() : number ->foo : () => number - -typeof objA.a; ->typeof objA.a : string ->objA.a : number ->objA : A ->a : number - -typeof M.n; ->typeof M.n : string ->M.n : number ->M : typeof M ->n : number - -typeof objA.a, M.n; ->typeof objA.a, M.n : number ->typeof objA.a : string ->objA.a : number ->objA : A ->a : number ->M.n : number ->M : typeof M ->n : number - -// use typeof in type query -var z: number; ->z : number - -var x: number[]; ->x : number[] - -z: typeof NUMBER; ->z : any ->typeof NUMBER : string ->NUMBER : number - -x: typeof NUMBER1; ->x : any ->typeof NUMBER1 : string ->NUMBER1 : number[] - -r: typeof foo; ->r : any ->typeof foo : string ->foo : () => number - -var y = { a: 1, b: 2 }; ->y : { a: number; b: number; } ->{ a: 1, b: 2 } : { a: number; b: number; } ->a : number ->1 : number ->b : number ->2 : number - -z: typeof y.a; ->z : any ->typeof y.a : string ->y.a : number ->y : { a: number; b: number; } ->a : number - -z: typeof objA.a; ->z : any ->typeof objA.a : string ->objA.a : number ->objA : A ->a : number - -z: typeof A.foo; ->z : any ->typeof A.foo : string ->A.foo : () => number ->A : typeof A ->foo : () => number - -z: typeof M.n; ->z : any ->typeof M.n : string ->M.n : number ->M : typeof M ->n : number - diff --git a/tests/baselines/reference/typeofOperatorWithStringType.errors.txt b/tests/baselines/reference/typeofOperatorWithStringType.errors.txt new file mode 100644 index 00000000000..37b2cafab37 --- /dev/null +++ b/tests/baselines/reference/typeofOperatorWithStringType.errors.txt @@ -0,0 +1,69 @@ +tests/cases/conformance/expressions/unaryOperators/typeofOperator/typeofOperatorWithStringType.ts(50,1): error TS7028: Unused label. +tests/cases/conformance/expressions/unaryOperators/typeofOperator/typeofOperatorWithStringType.ts(51,1): error TS7028: Unused label. +tests/cases/conformance/expressions/unaryOperators/typeofOperator/typeofOperatorWithStringType.ts(52,1): error TS7028: Unused label. + + +==== tests/cases/conformance/expressions/unaryOperators/typeofOperator/typeofOperatorWithStringType.ts (3 errors) ==== + // typeof operator on string type + var STRING: string; + var STRING1: string[] = ["", "abc"]; + + function foo(): string { return "abc"; } + + class A { + public a: string; + static foo() { return ""; } + } + module M { + export var n: string; + } + + var objA = new A(); + + // string type var + var ResultIsString1 = typeof STRING; + var ResultIsString2 = typeof STRING1; + + // string type literal + var ResultIsString3 = typeof ""; + var ResultIsString4 = typeof { x: "", y: "" }; + var ResultIsString5 = typeof { x: "", y: (s: string) => { return s; } }; + + // string type expressions + var ResultIsString6 = typeof objA.a; + var ResultIsString7 = typeof M.n; + var ResultIsString8 = typeof STRING1[0]; + var ResultIsString9 = typeof foo(); + var ResultIsString10 = typeof A.foo(); + var ResultIsString11 = typeof (STRING + STRING); + var ResultIsString12 = typeof STRING.charAt(0); + + // multiple typeof operators + var ResultIsString13 = typeof typeof STRING; + var ResultIsString14 = typeof typeof typeof (STRING + STRING); + + // miss assignment operators + typeof ""; + typeof STRING; + typeof STRING1; + typeof foo(); + typeof objA.a, M.n; + + // use typeof in type query + var z: string; + var x: string[]; + var r: () => string; + z: typeof STRING; + ~ +!!! error TS7028: Unused label. + x: typeof STRING1; + ~ +!!! error TS7028: Unused label. + r: typeof foo; + ~ +!!! error TS7028: Unused label. + var y = { a: "", b: "" }; + z: typeof y.a; + z: typeof objA.a; + z: typeof A.foo; + z: typeof M.n; \ No newline at end of file diff --git a/tests/baselines/reference/typeofOperatorWithStringType.symbols b/tests/baselines/reference/typeofOperatorWithStringType.symbols deleted file mode 100644 index 6da22469f83..00000000000 --- a/tests/baselines/reference/typeofOperatorWithStringType.symbols +++ /dev/null @@ -1,167 +0,0 @@ -=== tests/cases/conformance/expressions/unaryOperators/typeofOperator/typeofOperatorWithStringType.ts === -// typeof operator on string type -var STRING: string; ->STRING : Symbol(STRING, Decl(typeofOperatorWithStringType.ts, 1, 3)) - -var STRING1: string[] = ["", "abc"]; ->STRING1 : Symbol(STRING1, Decl(typeofOperatorWithStringType.ts, 2, 3)) - -function foo(): string { return "abc"; } ->foo : Symbol(foo, Decl(typeofOperatorWithStringType.ts, 2, 36)) - -class A { ->A : Symbol(A, Decl(typeofOperatorWithStringType.ts, 4, 40)) - - public a: string; ->a : Symbol(a, Decl(typeofOperatorWithStringType.ts, 6, 9)) - - static foo() { return ""; } ->foo : Symbol(A.foo, Decl(typeofOperatorWithStringType.ts, 7, 21)) -} -module M { ->M : Symbol(M, Decl(typeofOperatorWithStringType.ts, 9, 1)) - - export var n: string; ->n : Symbol(n, Decl(typeofOperatorWithStringType.ts, 11, 14)) -} - -var objA = new A(); ->objA : Symbol(objA, Decl(typeofOperatorWithStringType.ts, 14, 3)) ->A : Symbol(A, Decl(typeofOperatorWithStringType.ts, 4, 40)) - -// string type var -var ResultIsString1 = typeof STRING; ->ResultIsString1 : Symbol(ResultIsString1, Decl(typeofOperatorWithStringType.ts, 17, 3)) ->STRING : Symbol(STRING, Decl(typeofOperatorWithStringType.ts, 1, 3)) - -var ResultIsString2 = typeof STRING1; ->ResultIsString2 : Symbol(ResultIsString2, Decl(typeofOperatorWithStringType.ts, 18, 3)) ->STRING1 : Symbol(STRING1, Decl(typeofOperatorWithStringType.ts, 2, 3)) - -// string type literal -var ResultIsString3 = typeof ""; ->ResultIsString3 : Symbol(ResultIsString3, Decl(typeofOperatorWithStringType.ts, 21, 3)) - -var ResultIsString4 = typeof { x: "", y: "" }; ->ResultIsString4 : Symbol(ResultIsString4, Decl(typeofOperatorWithStringType.ts, 22, 3)) ->x : Symbol(x, Decl(typeofOperatorWithStringType.ts, 22, 30)) ->y : Symbol(y, Decl(typeofOperatorWithStringType.ts, 22, 37)) - -var ResultIsString5 = typeof { x: "", y: (s: string) => { return s; } }; ->ResultIsString5 : Symbol(ResultIsString5, Decl(typeofOperatorWithStringType.ts, 23, 3)) ->x : Symbol(x, Decl(typeofOperatorWithStringType.ts, 23, 30)) ->y : Symbol(y, Decl(typeofOperatorWithStringType.ts, 23, 37)) ->s : Symbol(s, Decl(typeofOperatorWithStringType.ts, 23, 42)) ->s : Symbol(s, Decl(typeofOperatorWithStringType.ts, 23, 42)) - -// string type expressions -var ResultIsString6 = typeof objA.a; ->ResultIsString6 : Symbol(ResultIsString6, Decl(typeofOperatorWithStringType.ts, 26, 3)) ->objA.a : Symbol(A.a, Decl(typeofOperatorWithStringType.ts, 6, 9)) ->objA : Symbol(objA, Decl(typeofOperatorWithStringType.ts, 14, 3)) ->a : Symbol(A.a, Decl(typeofOperatorWithStringType.ts, 6, 9)) - -var ResultIsString7 = typeof M.n; ->ResultIsString7 : Symbol(ResultIsString7, Decl(typeofOperatorWithStringType.ts, 27, 3)) ->M.n : Symbol(M.n, Decl(typeofOperatorWithStringType.ts, 11, 14)) ->M : Symbol(M, Decl(typeofOperatorWithStringType.ts, 9, 1)) ->n : Symbol(M.n, Decl(typeofOperatorWithStringType.ts, 11, 14)) - -var ResultIsString8 = typeof STRING1[0]; ->ResultIsString8 : Symbol(ResultIsString8, Decl(typeofOperatorWithStringType.ts, 28, 3)) ->STRING1 : Symbol(STRING1, Decl(typeofOperatorWithStringType.ts, 2, 3)) - -var ResultIsString9 = typeof foo(); ->ResultIsString9 : Symbol(ResultIsString9, Decl(typeofOperatorWithStringType.ts, 29, 3)) ->foo : Symbol(foo, Decl(typeofOperatorWithStringType.ts, 2, 36)) - -var ResultIsString10 = typeof A.foo(); ->ResultIsString10 : Symbol(ResultIsString10, Decl(typeofOperatorWithStringType.ts, 30, 3)) ->A.foo : Symbol(A.foo, Decl(typeofOperatorWithStringType.ts, 7, 21)) ->A : Symbol(A, Decl(typeofOperatorWithStringType.ts, 4, 40)) ->foo : Symbol(A.foo, Decl(typeofOperatorWithStringType.ts, 7, 21)) - -var ResultIsString11 = typeof (STRING + STRING); ->ResultIsString11 : Symbol(ResultIsString11, Decl(typeofOperatorWithStringType.ts, 31, 3)) ->STRING : Symbol(STRING, Decl(typeofOperatorWithStringType.ts, 1, 3)) ->STRING : Symbol(STRING, Decl(typeofOperatorWithStringType.ts, 1, 3)) - -var ResultIsString12 = typeof STRING.charAt(0); ->ResultIsString12 : Symbol(ResultIsString12, Decl(typeofOperatorWithStringType.ts, 32, 3)) ->STRING.charAt : Symbol(String.charAt, Decl(lib.d.ts, 279, 23)) ->STRING : Symbol(STRING, Decl(typeofOperatorWithStringType.ts, 1, 3)) ->charAt : Symbol(String.charAt, Decl(lib.d.ts, 279, 23)) - -// multiple typeof operators -var ResultIsString13 = typeof typeof STRING; ->ResultIsString13 : Symbol(ResultIsString13, Decl(typeofOperatorWithStringType.ts, 35, 3)) ->STRING : Symbol(STRING, Decl(typeofOperatorWithStringType.ts, 1, 3)) - -var ResultIsString14 = typeof typeof typeof (STRING + STRING); ->ResultIsString14 : Symbol(ResultIsString14, Decl(typeofOperatorWithStringType.ts, 36, 3)) ->STRING : Symbol(STRING, Decl(typeofOperatorWithStringType.ts, 1, 3)) ->STRING : Symbol(STRING, Decl(typeofOperatorWithStringType.ts, 1, 3)) - -// miss assignment operators -typeof ""; -typeof STRING; ->STRING : Symbol(STRING, Decl(typeofOperatorWithStringType.ts, 1, 3)) - -typeof STRING1; ->STRING1 : Symbol(STRING1, Decl(typeofOperatorWithStringType.ts, 2, 3)) - -typeof foo(); ->foo : Symbol(foo, Decl(typeofOperatorWithStringType.ts, 2, 36)) - -typeof objA.a, M.n; ->objA.a : Symbol(A.a, Decl(typeofOperatorWithStringType.ts, 6, 9)) ->objA : Symbol(objA, Decl(typeofOperatorWithStringType.ts, 14, 3)) ->a : Symbol(A.a, Decl(typeofOperatorWithStringType.ts, 6, 9)) ->M.n : Symbol(M.n, Decl(typeofOperatorWithStringType.ts, 11, 14)) ->M : Symbol(M, Decl(typeofOperatorWithStringType.ts, 9, 1)) ->n : Symbol(M.n, Decl(typeofOperatorWithStringType.ts, 11, 14)) - -// use typeof in type query -var z: string; ->z : Symbol(z, Decl(typeofOperatorWithStringType.ts, 46, 3)) - -var x: string[]; ->x : Symbol(x, Decl(typeofOperatorWithStringType.ts, 47, 3)) - -var r: () => string; ->r : Symbol(r, Decl(typeofOperatorWithStringType.ts, 48, 3)) - -z: typeof STRING; ->STRING : Symbol(STRING, Decl(typeofOperatorWithStringType.ts, 1, 3)) - -x: typeof STRING1; ->STRING1 : Symbol(STRING1, Decl(typeofOperatorWithStringType.ts, 2, 3)) - -r: typeof foo; ->foo : Symbol(foo, Decl(typeofOperatorWithStringType.ts, 2, 36)) - -var y = { a: "", b: "" }; ->y : Symbol(y, Decl(typeofOperatorWithStringType.ts, 52, 3)) ->a : Symbol(a, Decl(typeofOperatorWithStringType.ts, 52, 9)) ->b : Symbol(b, Decl(typeofOperatorWithStringType.ts, 52, 16)) - -z: typeof y.a; ->y.a : Symbol(a, Decl(typeofOperatorWithStringType.ts, 52, 9)) ->y : Symbol(y, Decl(typeofOperatorWithStringType.ts, 52, 3)) ->a : Symbol(a, Decl(typeofOperatorWithStringType.ts, 52, 9)) - -z: typeof objA.a; ->objA.a : Symbol(A.a, Decl(typeofOperatorWithStringType.ts, 6, 9)) ->objA : Symbol(objA, Decl(typeofOperatorWithStringType.ts, 14, 3)) ->a : Symbol(A.a, Decl(typeofOperatorWithStringType.ts, 6, 9)) - -z: typeof A.foo; ->A.foo : Symbol(A.foo, Decl(typeofOperatorWithStringType.ts, 7, 21)) ->A : Symbol(A, Decl(typeofOperatorWithStringType.ts, 4, 40)) ->foo : Symbol(A.foo, Decl(typeofOperatorWithStringType.ts, 7, 21)) - -z: typeof M.n; ->M.n : Symbol(M.n, Decl(typeofOperatorWithStringType.ts, 11, 14)) ->M : Symbol(M, Decl(typeofOperatorWithStringType.ts, 9, 1)) ->n : Symbol(M.n, Decl(typeofOperatorWithStringType.ts, 11, 14)) - diff --git a/tests/baselines/reference/typeofOperatorWithStringType.types b/tests/baselines/reference/typeofOperatorWithStringType.types deleted file mode 100644 index 3ae657a9951..00000000000 --- a/tests/baselines/reference/typeofOperatorWithStringType.types +++ /dev/null @@ -1,233 +0,0 @@ -=== tests/cases/conformance/expressions/unaryOperators/typeofOperator/typeofOperatorWithStringType.ts === -// typeof operator on string type -var STRING: string; ->STRING : string - -var STRING1: string[] = ["", "abc"]; ->STRING1 : string[] ->["", "abc"] : string[] ->"" : string ->"abc" : string - -function foo(): string { return "abc"; } ->foo : () => string ->"abc" : string - -class A { ->A : A - - public a: string; ->a : string - - static foo() { return ""; } ->foo : () => string ->"" : string -} -module M { ->M : typeof M - - export var n: string; ->n : string -} - -var objA = new A(); ->objA : A ->new A() : A ->A : typeof A - -// string type var -var ResultIsString1 = typeof STRING; ->ResultIsString1 : string ->typeof STRING : string ->STRING : string - -var ResultIsString2 = typeof STRING1; ->ResultIsString2 : string ->typeof STRING1 : string ->STRING1 : string[] - -// string type literal -var ResultIsString3 = typeof ""; ->ResultIsString3 : string ->typeof "" : string ->"" : string - -var ResultIsString4 = typeof { x: "", y: "" }; ->ResultIsString4 : string ->typeof { x: "", y: "" } : string ->{ x: "", y: "" } : { x: string; y: string; } ->x : string ->"" : string ->y : string ->"" : string - -var ResultIsString5 = typeof { x: "", y: (s: string) => { return s; } }; ->ResultIsString5 : string ->typeof { x: "", y: (s: string) => { return s; } } : string ->{ x: "", y: (s: string) => { return s; } } : { x: string; y: (s: string) => string; } ->x : string ->"" : string ->y : (s: string) => string ->(s: string) => { return s; } : (s: string) => string ->s : string ->s : string - -// string type expressions -var ResultIsString6 = typeof objA.a; ->ResultIsString6 : string ->typeof objA.a : string ->objA.a : string ->objA : A ->a : string - -var ResultIsString7 = typeof M.n; ->ResultIsString7 : string ->typeof M.n : string ->M.n : string ->M : typeof M ->n : string - -var ResultIsString8 = typeof STRING1[0]; ->ResultIsString8 : string ->typeof STRING1[0] : string ->STRING1[0] : string ->STRING1 : string[] ->0 : number - -var ResultIsString9 = typeof foo(); ->ResultIsString9 : string ->typeof foo() : string ->foo() : string ->foo : () => string - -var ResultIsString10 = typeof A.foo(); ->ResultIsString10 : string ->typeof A.foo() : string ->A.foo() : string ->A.foo : () => string ->A : typeof A ->foo : () => string - -var ResultIsString11 = typeof (STRING + STRING); ->ResultIsString11 : string ->typeof (STRING + STRING) : string ->(STRING + STRING) : string ->STRING + STRING : string ->STRING : string ->STRING : string - -var ResultIsString12 = typeof STRING.charAt(0); ->ResultIsString12 : string ->typeof STRING.charAt(0) : string ->STRING.charAt(0) : string ->STRING.charAt : (pos: number) => string ->STRING : string ->charAt : (pos: number) => string ->0 : number - -// multiple typeof operators -var ResultIsString13 = typeof typeof STRING; ->ResultIsString13 : string ->typeof typeof STRING : string ->typeof STRING : string ->STRING : string - -var ResultIsString14 = typeof typeof typeof (STRING + STRING); ->ResultIsString14 : string ->typeof typeof typeof (STRING + STRING) : string ->typeof typeof (STRING + STRING) : string ->typeof (STRING + STRING) : string ->(STRING + STRING) : string ->STRING + STRING : string ->STRING : string ->STRING : string - -// miss assignment operators -typeof ""; ->typeof "" : string ->"" : string - -typeof STRING; ->typeof STRING : string ->STRING : string - -typeof STRING1; ->typeof STRING1 : string ->STRING1 : string[] - -typeof foo(); ->typeof foo() : string ->foo() : string ->foo : () => string - -typeof objA.a, M.n; ->typeof objA.a, M.n : string ->typeof objA.a : string ->objA.a : string ->objA : A ->a : string ->M.n : string ->M : typeof M ->n : string - -// use typeof in type query -var z: string; ->z : string - -var x: string[]; ->x : string[] - -var r: () => string; ->r : () => string - -z: typeof STRING; ->z : any ->typeof STRING : string ->STRING : string - -x: typeof STRING1; ->x : any ->typeof STRING1 : string ->STRING1 : string[] - -r: typeof foo; ->r : any ->typeof foo : string ->foo : () => string - -var y = { a: "", b: "" }; ->y : { a: string; b: string; } ->{ a: "", b: "" } : { a: string; b: string; } ->a : string ->"" : string ->b : string ->"" : string - -z: typeof y.a; ->z : any ->typeof y.a : string ->y.a : string ->y : { a: string; b: string; } ->a : string - -z: typeof objA.a; ->z : any ->typeof objA.a : string ->objA.a : string ->objA : A ->a : string - -z: typeof A.foo; ->z : any ->typeof A.foo : string ->A.foo : () => string ->A : typeof A ->foo : () => string - -z: typeof M.n; ->z : any ->typeof M.n : string ->M.n : string ->M : typeof M ->n : string - diff --git a/tests/baselines/reference/undeclaredVarEmit.errors.txt b/tests/baselines/reference/undeclaredVarEmit.errors.txt index af6298b61d2..a95323aa362 100644 --- a/tests/baselines/reference/undeclaredVarEmit.errors.txt +++ b/tests/baselines/reference/undeclaredVarEmit.errors.txt @@ -1,7 +1,10 @@ +tests/cases/compiler/undeclaredVarEmit.ts(1,1): error TS7028: Unused label. tests/cases/compiler/undeclaredVarEmit.ts(1,4): error TS2304: Cannot find name 'number'. -==== tests/cases/compiler/undeclaredVarEmit.ts (1 errors) ==== +==== tests/cases/compiler/undeclaredVarEmit.ts (2 errors) ==== f: number; + ~ +!!! error TS7028: Unused label. ~~~~~~ !!! error TS2304: Cannot find name 'number'. \ No newline at end of file diff --git a/tests/baselines/reference/validMultipleVariableDeclarations.errors.txt b/tests/baselines/reference/validMultipleVariableDeclarations.errors.txt new file mode 100644 index 00000000000..8f751e9efee --- /dev/null +++ b/tests/baselines/reference/validMultipleVariableDeclarations.errors.txt @@ -0,0 +1,45 @@ +tests/cases/conformance/statements/VariableStatements/validMultipleVariableDeclarations.ts(9,1): error TS7027: Unreachable code detected. + + +==== tests/cases/conformance/statements/VariableStatements/validMultipleVariableDeclarations.ts (1 errors) ==== + // all expected to be valid + + var x: number; + var x = 2; + if (true) { + var x = 3; + for (var x = 0; ;) { } + } + var x = undefined; + ~~~ +!!! error TS7027: Unreachable code detected. + + // new declaration space, making redeclaring x as a string valid + function declSpace() { + var x = 'this is a string'; + } + + interface Point { x: number; y: number; } + + var p: Point; + var p = { x: 1, y: 2 }; + var p: Point = { x: 0, y: undefined }; + var p = { x: 1, y: undefined }; + var p: { x: number; y: number; } = { x: 1, y: 2 }; + var p = <{ x: number; y: number; }>{ x: 0, y: undefined }; + var p: typeof p; + + var fn = function (s: string) { return 42; } + var fn = (s: string) => 3; + var fn: (s: string) => number; + var fn: { (s: string): number }; + var fn = <(s: string) => number> null; + var fn: typeof fn; + + var a: string[]; + var a = ['a', 'b'] + var a = []; + var a: string[] = []; + var a = new Array(); + var a: typeof a; + \ No newline at end of file diff --git a/tests/baselines/reference/validMultipleVariableDeclarations.symbols b/tests/baselines/reference/validMultipleVariableDeclarations.symbols deleted file mode 100644 index 467c061c6fa..00000000000 --- a/tests/baselines/reference/validMultipleVariableDeclarations.symbols +++ /dev/null @@ -1,118 +0,0 @@ -=== tests/cases/conformance/statements/VariableStatements/validMultipleVariableDeclarations.ts === -// all expected to be valid - -var x: number; ->x : Symbol(x, Decl(validMultipleVariableDeclarations.ts, 2, 3), Decl(validMultipleVariableDeclarations.ts, 3, 3), Decl(validMultipleVariableDeclarations.ts, 5, 7), Decl(validMultipleVariableDeclarations.ts, 6, 12), Decl(validMultipleVariableDeclarations.ts, 8, 3)) - -var x = 2; ->x : Symbol(x, Decl(validMultipleVariableDeclarations.ts, 2, 3), Decl(validMultipleVariableDeclarations.ts, 3, 3), Decl(validMultipleVariableDeclarations.ts, 5, 7), Decl(validMultipleVariableDeclarations.ts, 6, 12), Decl(validMultipleVariableDeclarations.ts, 8, 3)) - -if (true) { - var x = 3; ->x : Symbol(x, Decl(validMultipleVariableDeclarations.ts, 2, 3), Decl(validMultipleVariableDeclarations.ts, 3, 3), Decl(validMultipleVariableDeclarations.ts, 5, 7), Decl(validMultipleVariableDeclarations.ts, 6, 12), Decl(validMultipleVariableDeclarations.ts, 8, 3)) - - for (var x = 0; ;) { } ->x : Symbol(x, Decl(validMultipleVariableDeclarations.ts, 2, 3), Decl(validMultipleVariableDeclarations.ts, 3, 3), Decl(validMultipleVariableDeclarations.ts, 5, 7), Decl(validMultipleVariableDeclarations.ts, 6, 12), Decl(validMultipleVariableDeclarations.ts, 8, 3)) -} -var x = undefined; ->x : Symbol(x, Decl(validMultipleVariableDeclarations.ts, 2, 3), Decl(validMultipleVariableDeclarations.ts, 3, 3), Decl(validMultipleVariableDeclarations.ts, 5, 7), Decl(validMultipleVariableDeclarations.ts, 6, 12), Decl(validMultipleVariableDeclarations.ts, 8, 3)) ->undefined : Symbol(undefined) - -// new declaration space, making redeclaring x as a string valid -function declSpace() { ->declSpace : Symbol(declSpace, Decl(validMultipleVariableDeclarations.ts, 8, 26)) - - var x = 'this is a string'; ->x : Symbol(x, Decl(validMultipleVariableDeclarations.ts, 12, 7)) -} - -interface Point { x: number; y: number; } ->Point : Symbol(Point, Decl(validMultipleVariableDeclarations.ts, 13, 1)) ->x : Symbol(x, Decl(validMultipleVariableDeclarations.ts, 15, 17)) ->y : Symbol(y, Decl(validMultipleVariableDeclarations.ts, 15, 28)) - -var p: Point; ->p : Symbol(p, Decl(validMultipleVariableDeclarations.ts, 17, 3), Decl(validMultipleVariableDeclarations.ts, 18, 3), Decl(validMultipleVariableDeclarations.ts, 19, 3), Decl(validMultipleVariableDeclarations.ts, 20, 3), Decl(validMultipleVariableDeclarations.ts, 21, 3), Decl(validMultipleVariableDeclarations.ts, 22, 3), Decl(validMultipleVariableDeclarations.ts, 23, 3)) ->Point : Symbol(Point, Decl(validMultipleVariableDeclarations.ts, 13, 1)) - -var p = { x: 1, y: 2 }; ->p : Symbol(p, Decl(validMultipleVariableDeclarations.ts, 17, 3), Decl(validMultipleVariableDeclarations.ts, 18, 3), Decl(validMultipleVariableDeclarations.ts, 19, 3), Decl(validMultipleVariableDeclarations.ts, 20, 3), Decl(validMultipleVariableDeclarations.ts, 21, 3), Decl(validMultipleVariableDeclarations.ts, 22, 3), Decl(validMultipleVariableDeclarations.ts, 23, 3)) ->x : Symbol(x, Decl(validMultipleVariableDeclarations.ts, 18, 9)) ->y : Symbol(y, Decl(validMultipleVariableDeclarations.ts, 18, 15)) - -var p: Point = { x: 0, y: undefined }; ->p : Symbol(p, Decl(validMultipleVariableDeclarations.ts, 17, 3), Decl(validMultipleVariableDeclarations.ts, 18, 3), Decl(validMultipleVariableDeclarations.ts, 19, 3), Decl(validMultipleVariableDeclarations.ts, 20, 3), Decl(validMultipleVariableDeclarations.ts, 21, 3), Decl(validMultipleVariableDeclarations.ts, 22, 3), Decl(validMultipleVariableDeclarations.ts, 23, 3)) ->Point : Symbol(Point, Decl(validMultipleVariableDeclarations.ts, 13, 1)) ->x : Symbol(x, Decl(validMultipleVariableDeclarations.ts, 19, 16)) ->y : Symbol(y, Decl(validMultipleVariableDeclarations.ts, 19, 22)) ->undefined : Symbol(undefined) - -var p = { x: 1, y: undefined }; ->p : Symbol(p, Decl(validMultipleVariableDeclarations.ts, 17, 3), Decl(validMultipleVariableDeclarations.ts, 18, 3), Decl(validMultipleVariableDeclarations.ts, 19, 3), Decl(validMultipleVariableDeclarations.ts, 20, 3), Decl(validMultipleVariableDeclarations.ts, 21, 3), Decl(validMultipleVariableDeclarations.ts, 22, 3), Decl(validMultipleVariableDeclarations.ts, 23, 3)) ->x : Symbol(x, Decl(validMultipleVariableDeclarations.ts, 20, 9)) ->y : Symbol(y, Decl(validMultipleVariableDeclarations.ts, 20, 15)) ->undefined : Symbol(undefined) - -var p: { x: number; y: number; } = { x: 1, y: 2 }; ->p : Symbol(p, Decl(validMultipleVariableDeclarations.ts, 17, 3), Decl(validMultipleVariableDeclarations.ts, 18, 3), Decl(validMultipleVariableDeclarations.ts, 19, 3), Decl(validMultipleVariableDeclarations.ts, 20, 3), Decl(validMultipleVariableDeclarations.ts, 21, 3), Decl(validMultipleVariableDeclarations.ts, 22, 3), Decl(validMultipleVariableDeclarations.ts, 23, 3)) ->x : Symbol(x, Decl(validMultipleVariableDeclarations.ts, 21, 8)) ->y : Symbol(y, Decl(validMultipleVariableDeclarations.ts, 21, 19)) ->x : Symbol(x, Decl(validMultipleVariableDeclarations.ts, 21, 36)) ->y : Symbol(y, Decl(validMultipleVariableDeclarations.ts, 21, 42)) - -var p = <{ x: number; y: number; }>{ x: 0, y: undefined }; ->p : Symbol(p, Decl(validMultipleVariableDeclarations.ts, 17, 3), Decl(validMultipleVariableDeclarations.ts, 18, 3), Decl(validMultipleVariableDeclarations.ts, 19, 3), Decl(validMultipleVariableDeclarations.ts, 20, 3), Decl(validMultipleVariableDeclarations.ts, 21, 3), Decl(validMultipleVariableDeclarations.ts, 22, 3), Decl(validMultipleVariableDeclarations.ts, 23, 3)) ->x : Symbol(x, Decl(validMultipleVariableDeclarations.ts, 22, 10)) ->y : Symbol(y, Decl(validMultipleVariableDeclarations.ts, 22, 21)) ->x : Symbol(x, Decl(validMultipleVariableDeclarations.ts, 22, 36)) ->y : Symbol(y, Decl(validMultipleVariableDeclarations.ts, 22, 42)) ->undefined : Symbol(undefined) - -var p: typeof p; ->p : Symbol(p, Decl(validMultipleVariableDeclarations.ts, 17, 3), Decl(validMultipleVariableDeclarations.ts, 18, 3), Decl(validMultipleVariableDeclarations.ts, 19, 3), Decl(validMultipleVariableDeclarations.ts, 20, 3), Decl(validMultipleVariableDeclarations.ts, 21, 3), Decl(validMultipleVariableDeclarations.ts, 22, 3), Decl(validMultipleVariableDeclarations.ts, 23, 3)) ->p : Symbol(p, Decl(validMultipleVariableDeclarations.ts, 17, 3), Decl(validMultipleVariableDeclarations.ts, 18, 3), Decl(validMultipleVariableDeclarations.ts, 19, 3), Decl(validMultipleVariableDeclarations.ts, 20, 3), Decl(validMultipleVariableDeclarations.ts, 21, 3), Decl(validMultipleVariableDeclarations.ts, 22, 3), Decl(validMultipleVariableDeclarations.ts, 23, 3)) - -var fn = function (s: string) { return 42; } ->fn : Symbol(fn, Decl(validMultipleVariableDeclarations.ts, 25, 3), Decl(validMultipleVariableDeclarations.ts, 26, 3), Decl(validMultipleVariableDeclarations.ts, 27, 3), Decl(validMultipleVariableDeclarations.ts, 28, 3), Decl(validMultipleVariableDeclarations.ts, 29, 3), Decl(validMultipleVariableDeclarations.ts, 30, 3)) ->s : Symbol(s, Decl(validMultipleVariableDeclarations.ts, 25, 19)) - -var fn = (s: string) => 3; ->fn : Symbol(fn, Decl(validMultipleVariableDeclarations.ts, 25, 3), Decl(validMultipleVariableDeclarations.ts, 26, 3), Decl(validMultipleVariableDeclarations.ts, 27, 3), Decl(validMultipleVariableDeclarations.ts, 28, 3), Decl(validMultipleVariableDeclarations.ts, 29, 3), Decl(validMultipleVariableDeclarations.ts, 30, 3)) ->s : Symbol(s, Decl(validMultipleVariableDeclarations.ts, 26, 10)) - -var fn: (s: string) => number; ->fn : Symbol(fn, Decl(validMultipleVariableDeclarations.ts, 25, 3), Decl(validMultipleVariableDeclarations.ts, 26, 3), Decl(validMultipleVariableDeclarations.ts, 27, 3), Decl(validMultipleVariableDeclarations.ts, 28, 3), Decl(validMultipleVariableDeclarations.ts, 29, 3), Decl(validMultipleVariableDeclarations.ts, 30, 3)) ->s : Symbol(s, Decl(validMultipleVariableDeclarations.ts, 27, 9)) - -var fn: { (s: string): number }; ->fn : Symbol(fn, Decl(validMultipleVariableDeclarations.ts, 25, 3), Decl(validMultipleVariableDeclarations.ts, 26, 3), Decl(validMultipleVariableDeclarations.ts, 27, 3), Decl(validMultipleVariableDeclarations.ts, 28, 3), Decl(validMultipleVariableDeclarations.ts, 29, 3), Decl(validMultipleVariableDeclarations.ts, 30, 3)) ->s : Symbol(s, Decl(validMultipleVariableDeclarations.ts, 28, 11)) - -var fn = <(s: string) => number> null; ->fn : Symbol(fn, Decl(validMultipleVariableDeclarations.ts, 25, 3), Decl(validMultipleVariableDeclarations.ts, 26, 3), Decl(validMultipleVariableDeclarations.ts, 27, 3), Decl(validMultipleVariableDeclarations.ts, 28, 3), Decl(validMultipleVariableDeclarations.ts, 29, 3), Decl(validMultipleVariableDeclarations.ts, 30, 3)) ->s : Symbol(s, Decl(validMultipleVariableDeclarations.ts, 29, 11)) - -var fn: typeof fn; ->fn : Symbol(fn, Decl(validMultipleVariableDeclarations.ts, 25, 3), Decl(validMultipleVariableDeclarations.ts, 26, 3), Decl(validMultipleVariableDeclarations.ts, 27, 3), Decl(validMultipleVariableDeclarations.ts, 28, 3), Decl(validMultipleVariableDeclarations.ts, 29, 3), Decl(validMultipleVariableDeclarations.ts, 30, 3)) ->fn : Symbol(fn, Decl(validMultipleVariableDeclarations.ts, 25, 3), Decl(validMultipleVariableDeclarations.ts, 26, 3), Decl(validMultipleVariableDeclarations.ts, 27, 3), Decl(validMultipleVariableDeclarations.ts, 28, 3), Decl(validMultipleVariableDeclarations.ts, 29, 3), Decl(validMultipleVariableDeclarations.ts, 30, 3)) - -var a: string[]; ->a : Symbol(a, Decl(validMultipleVariableDeclarations.ts, 32, 3), Decl(validMultipleVariableDeclarations.ts, 33, 3), Decl(validMultipleVariableDeclarations.ts, 34, 3), Decl(validMultipleVariableDeclarations.ts, 35, 3), Decl(validMultipleVariableDeclarations.ts, 36, 3), Decl(validMultipleVariableDeclarations.ts, 37, 3)) - -var a = ['a', 'b'] ->a : Symbol(a, Decl(validMultipleVariableDeclarations.ts, 32, 3), Decl(validMultipleVariableDeclarations.ts, 33, 3), Decl(validMultipleVariableDeclarations.ts, 34, 3), Decl(validMultipleVariableDeclarations.ts, 35, 3), Decl(validMultipleVariableDeclarations.ts, 36, 3), Decl(validMultipleVariableDeclarations.ts, 37, 3)) - -var a = []; ->a : Symbol(a, Decl(validMultipleVariableDeclarations.ts, 32, 3), Decl(validMultipleVariableDeclarations.ts, 33, 3), Decl(validMultipleVariableDeclarations.ts, 34, 3), Decl(validMultipleVariableDeclarations.ts, 35, 3), Decl(validMultipleVariableDeclarations.ts, 36, 3), Decl(validMultipleVariableDeclarations.ts, 37, 3)) - -var a: string[] = []; ->a : Symbol(a, Decl(validMultipleVariableDeclarations.ts, 32, 3), Decl(validMultipleVariableDeclarations.ts, 33, 3), Decl(validMultipleVariableDeclarations.ts, 34, 3), Decl(validMultipleVariableDeclarations.ts, 35, 3), Decl(validMultipleVariableDeclarations.ts, 36, 3), Decl(validMultipleVariableDeclarations.ts, 37, 3)) - -var a = new Array(); ->a : Symbol(a, Decl(validMultipleVariableDeclarations.ts, 32, 3), Decl(validMultipleVariableDeclarations.ts, 33, 3), Decl(validMultipleVariableDeclarations.ts, 34, 3), Decl(validMultipleVariableDeclarations.ts, 35, 3), Decl(validMultipleVariableDeclarations.ts, 36, 3), Decl(validMultipleVariableDeclarations.ts, 37, 3)) ->Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11)) - -var a: typeof a; ->a : Symbol(a, Decl(validMultipleVariableDeclarations.ts, 32, 3), Decl(validMultipleVariableDeclarations.ts, 33, 3), Decl(validMultipleVariableDeclarations.ts, 34, 3), Decl(validMultipleVariableDeclarations.ts, 35, 3), Decl(validMultipleVariableDeclarations.ts, 36, 3), Decl(validMultipleVariableDeclarations.ts, 37, 3)) ->a : Symbol(a, Decl(validMultipleVariableDeclarations.ts, 32, 3), Decl(validMultipleVariableDeclarations.ts, 33, 3), Decl(validMultipleVariableDeclarations.ts, 34, 3), Decl(validMultipleVariableDeclarations.ts, 35, 3), Decl(validMultipleVariableDeclarations.ts, 36, 3), Decl(validMultipleVariableDeclarations.ts, 37, 3)) - diff --git a/tests/baselines/reference/validMultipleVariableDeclarations.types b/tests/baselines/reference/validMultipleVariableDeclarations.types deleted file mode 100644 index 966128350b0..00000000000 --- a/tests/baselines/reference/validMultipleVariableDeclarations.types +++ /dev/null @@ -1,152 +0,0 @@ -=== tests/cases/conformance/statements/VariableStatements/validMultipleVariableDeclarations.ts === -// all expected to be valid - -var x: number; ->x : number - -var x = 2; ->x : number ->2 : number - -if (true) { ->true : boolean - - var x = 3; ->x : number ->3 : number - - for (var x = 0; ;) { } ->x : number ->0 : number -} -var x = undefined; ->x : number ->undefined : number ->undefined : undefined - -// new declaration space, making redeclaring x as a string valid -function declSpace() { ->declSpace : () => void - - var x = 'this is a string'; ->x : string ->'this is a string' : string -} - -interface Point { x: number; y: number; } ->Point : Point ->x : number ->y : number - -var p: Point; ->p : Point ->Point : Point - -var p = { x: 1, y: 2 }; ->p : Point ->{ x: 1, y: 2 } : { x: number; y: number; } ->x : number ->1 : number ->y : number ->2 : number - -var p: Point = { x: 0, y: undefined }; ->p : Point ->Point : Point ->{ x: 0, y: undefined } : { x: number; y: undefined; } ->x : number ->0 : number ->y : undefined ->undefined : undefined - -var p = { x: 1, y: undefined }; ->p : Point ->{ x: 1, y: undefined } : { x: number; y: number; } ->x : number ->1 : number ->y : number ->undefined : number ->undefined : undefined - -var p: { x: number; y: number; } = { x: 1, y: 2 }; ->p : Point ->x : number ->y : number ->{ x: 1, y: 2 } : { x: number; y: number; } ->x : number ->1 : number ->y : number ->2 : number - -var p = <{ x: number; y: number; }>{ x: 0, y: undefined }; ->p : Point -><{ x: number; y: number; }>{ x: 0, y: undefined } : { x: number; y: number; } ->x : number ->y : number ->{ x: 0, y: undefined } : { x: number; y: undefined; } ->x : number ->0 : number ->y : undefined ->undefined : undefined - -var p: typeof p; ->p : Point ->p : Point - -var fn = function (s: string) { return 42; } ->fn : (s: string) => number ->function (s: string) { return 42; } : (s: string) => number ->s : string ->42 : number - -var fn = (s: string) => 3; ->fn : (s: string) => number ->(s: string) => 3 : (s: string) => number ->s : string ->3 : number - -var fn: (s: string) => number; ->fn : (s: string) => number ->s : string - -var fn: { (s: string): number }; ->fn : (s: string) => number ->s : string - -var fn = <(s: string) => number> null; ->fn : (s: string) => number -><(s: string) => number> null : (s: string) => number ->s : string ->null : null - -var fn: typeof fn; ->fn : (s: string) => number ->fn : (s: string) => number - -var a: string[]; ->a : string[] - -var a = ['a', 'b'] ->a : string[] ->['a', 'b'] : string[] ->'a' : string ->'b' : string - -var a = []; ->a : string[] ->[] : string[] ->[] : undefined[] - -var a: string[] = []; ->a : string[] ->[] : undefined[] - -var a = new Array(); ->a : string[] ->new Array() : string[] ->Array : ArrayConstructor - -var a: typeof a; ->a : string[] ->a : string[] - diff --git a/tests/baselines/reference/whileBreakStatements.errors.txt b/tests/baselines/reference/whileBreakStatements.errors.txt new file mode 100644 index 00000000000..7c63dc59d3c --- /dev/null +++ b/tests/baselines/reference/whileBreakStatements.errors.txt @@ -0,0 +1,54 @@ +tests/cases/conformance/statements/breakStatements/whileBreakStatements.ts(11,1): error TS7028: Unused label. +tests/cases/conformance/statements/breakStatements/whileBreakStatements.ts(19,5): error TS7028: Unused label. +tests/cases/conformance/statements/breakStatements/whileBreakStatements.ts(31,1): error TS7027: Unreachable code detected. + + +==== tests/cases/conformance/statements/breakStatements/whileBreakStatements.ts (3 errors) ==== + while(true) { + break; + } + + ONE: + + while (true) { + break ONE; + } + + TWO: + ~~~ +!!! error TS7028: Unused label. + THREE: + while (true) { + break THREE; + } + + FOUR: + while (true) { + FIVE: + ~~~~ +!!! error TS7028: Unused label. + while (true) { + break FOUR; + } + } + + while (true) { + SIX: + while (true) + break SIX; + } + + SEVEN: + ~~~~~ +!!! error TS7027: Unreachable code detected. + while (true) + while (true) + while (true) + break SEVEN; + + EIGHT: + while (true) { + var fn = function () { } + break EIGHT; + } + \ No newline at end of file diff --git a/tests/baselines/reference/whileBreakStatements.symbols b/tests/baselines/reference/whileBreakStatements.symbols deleted file mode 100644 index 2ac7721621d..00000000000 --- a/tests/baselines/reference/whileBreakStatements.symbols +++ /dev/null @@ -1,45 +0,0 @@ -=== tests/cases/conformance/statements/breakStatements/whileBreakStatements.ts === -while(true) { - break; -} - -ONE: - -while (true) { - break ONE; -} - -TWO: -THREE: -while (true) { - break THREE; -} - -FOUR: -while (true) { - FIVE: - while (true) { - break FOUR; - } -} - -while (true) { - SIX: - while (true) - break SIX; -} - -SEVEN: -while (true) - while (true) - while (true) - break SEVEN; - -EIGHT: -while (true) { - var fn = function () { } ->fn : Symbol(fn, Decl(whileBreakStatements.ts, 38, 7)) - - break EIGHT; -} - diff --git a/tests/baselines/reference/whileBreakStatements.types b/tests/baselines/reference/whileBreakStatements.types deleted file mode 100644 index e7ca0a5322f..00000000000 --- a/tests/baselines/reference/whileBreakStatements.types +++ /dev/null @@ -1,89 +0,0 @@ -=== tests/cases/conformance/statements/breakStatements/whileBreakStatements.ts === -while(true) { ->true : boolean - - break; -} - -ONE: ->ONE : any - -while (true) { ->true : boolean - - break ONE; ->ONE : any -} - -TWO: ->TWO : any - -THREE: ->THREE : any - -while (true) { ->true : boolean - - break THREE; ->THREE : any -} - -FOUR: ->FOUR : any - -while (true) { ->true : boolean - - FIVE: ->FIVE : any - - while (true) { ->true : boolean - - break FOUR; ->FOUR : any - } -} - -while (true) { ->true : boolean - - SIX: ->SIX : any - - while (true) ->true : boolean - - break SIX; ->SIX : any -} - -SEVEN: ->SEVEN : any - -while (true) ->true : boolean - - while (true) ->true : boolean - - while (true) ->true : boolean - - break SEVEN; ->SEVEN : any - -EIGHT: ->EIGHT : any - -while (true) { ->true : boolean - - var fn = function () { } ->fn : () => void ->function () { } : () => void - - break EIGHT; ->EIGHT : any -} - diff --git a/tests/baselines/reference/whileContinueStatements.errors.txt b/tests/baselines/reference/whileContinueStatements.errors.txt new file mode 100644 index 00000000000..c2009b02600 --- /dev/null +++ b/tests/baselines/reference/whileContinueStatements.errors.txt @@ -0,0 +1,59 @@ +tests/cases/conformance/statements/continueStatements/whileContinueStatements.ts(5,1): error TS7027: Unreachable code detected. + + +==== tests/cases/conformance/statements/continueStatements/whileContinueStatements.ts (1 errors) ==== + while(true) { + continue; + } + + while (true) { + ~~~~~ +!!! error TS7027: Unreachable code detected. + if (true) { + continue; + } + } + + ONE: + + while (true) { + continue ONE; + } + + TWO: + THREE: + while (true) { + continue THREE; + } + + FOUR: + while (true) { + FIVE: + while (true) { + continue FOUR; + } + } + + while (true) { + SIX: + while (true) + continue SIX; + } + + SEVEN: + while (true) + while (true) + while (true) + continue SEVEN; + + EIGHT: + while (true) { + var fn = function () { } + continue EIGHT; + } + + NINE: + while (true) { + if (true) { continue NINE; } + } + \ No newline at end of file diff --git a/tests/baselines/reference/whileContinueStatements.symbols b/tests/baselines/reference/whileContinueStatements.symbols deleted file mode 100644 index 67508556f70..00000000000 --- a/tests/baselines/reference/whileContinueStatements.symbols +++ /dev/null @@ -1,56 +0,0 @@ -=== tests/cases/conformance/statements/continueStatements/whileContinueStatements.ts === -while(true) { - continue; -} - -while (true) { - if (true) { - continue; - } -} - -ONE: - -while (true) { - continue ONE; -} - -TWO: -THREE: -while (true) { - continue THREE; -} - -FOUR: -while (true) { - FIVE: - while (true) { - continue FOUR; - } -} - -while (true) { - SIX: - while (true) - continue SIX; -} - -SEVEN: -while (true) - while (true) - while (true) - continue SEVEN; - -EIGHT: -while (true) { - var fn = function () { } ->fn : Symbol(fn, Decl(whileContinueStatements.ts, 44, 7)) - - continue EIGHT; -} - -NINE: -while (true) { - if (true) { continue NINE; } -} - diff --git a/tests/baselines/reference/whileContinueStatements.types b/tests/baselines/reference/whileContinueStatements.types deleted file mode 100644 index 6bf371cde9e..00000000000 --- a/tests/baselines/reference/whileContinueStatements.types +++ /dev/null @@ -1,110 +0,0 @@ -=== tests/cases/conformance/statements/continueStatements/whileContinueStatements.ts === -while(true) { ->true : boolean - - continue; -} - -while (true) { ->true : boolean - - if (true) { ->true : boolean - - continue; - } -} - -ONE: ->ONE : any - -while (true) { ->true : boolean - - continue ONE; ->ONE : any -} - -TWO: ->TWO : any - -THREE: ->THREE : any - -while (true) { ->true : boolean - - continue THREE; ->THREE : any -} - -FOUR: ->FOUR : any - -while (true) { ->true : boolean - - FIVE: ->FIVE : any - - while (true) { ->true : boolean - - continue FOUR; ->FOUR : any - } -} - -while (true) { ->true : boolean - - SIX: ->SIX : any - - while (true) ->true : boolean - - continue SIX; ->SIX : any -} - -SEVEN: ->SEVEN : any - -while (true) ->true : boolean - - while (true) ->true : boolean - - while (true) ->true : boolean - - continue SEVEN; ->SEVEN : any - -EIGHT: ->EIGHT : any - -while (true) { ->true : boolean - - var fn = function () { } ->fn : () => void ->function () { } : () => void - - continue EIGHT; ->EIGHT : any -} - -NINE: ->NINE : any - -while (true) { ->true : boolean - - if (true) { continue NINE; } ->true : boolean ->NINE : any -} - diff --git a/tests/cases/compiler/reachabilityChecks1.ts b/tests/cases/compiler/reachabilityChecks1.ts index ce009e13456..6430556a203 100644 --- a/tests/cases/compiler/reachabilityChecks1.ts +++ b/tests/cases/compiler/reachabilityChecks1.ts @@ -1,4 +1,4 @@ -// @noUnreachableCode: true +// @allowUnreachableCode: false // @preserveConstEnums: true while (true); diff --git a/tests/cases/compiler/reachabilityChecks2.ts b/tests/cases/compiler/reachabilityChecks2.ts index 9a2b519ca4c..5a7a8aaab58 100644 --- a/tests/cases/compiler/reachabilityChecks2.ts +++ b/tests/cases/compiler/reachabilityChecks2.ts @@ -1,4 +1,4 @@ -// @noUnreachableCode: true +// @allowUnreachableCode: false // @preserveConstEnums: false while (true) { } diff --git a/tests/cases/compiler/reachabilityChecks3.ts b/tests/cases/compiler/reachabilityChecks3.ts index 362c64e1349..19f57e55b67 100644 --- a/tests/cases/compiler/reachabilityChecks3.ts +++ b/tests/cases/compiler/reachabilityChecks3.ts @@ -1,4 +1,4 @@ -// @noUnusedLabels: true +// @allowUnusedLabels: false let x = 1; loop: while (true) { @@ -8,4 +8,9 @@ loop: while (true) { else { x++; } -} \ No newline at end of file +} +{ + x: 100 +} + +var y = () => { f: 1 } \ No newline at end of file diff --git a/tests/cases/compiler/reachabilityChecks5.ts b/tests/cases/compiler/reachabilityChecks5.ts index 24134e238b9..97df11ccb79 100644 --- a/tests/cases/compiler/reachabilityChecks5.ts +++ b/tests/cases/compiler/reachabilityChecks5.ts @@ -1,4 +1,4 @@ -// @noUnreachableCode: true +// @allowUnreachableCode: false // @noImplicitReturns: true function f0(x): number { diff --git a/tests/cases/fourslash/unclosedFunctionErrorRecovery3.ts b/tests/cases/fourslash/unclosedFunctionErrorRecovery3.ts index bcb79811a62..7a52ddc2c32 100644 --- a/tests/cases/fourslash/unclosedFunctionErrorRecovery3.ts +++ b/tests/cases/fourslash/unclosedFunctionErrorRecovery3.ts @@ -1,4 +1,5 @@ /// +// @allowUnreachableCode: true //// class alpha { static beta() return 5; } } //// /**/ var gamma = alpha.beta() * 5; diff --git a/tests/webTestServer.ts b/tests/webTestServer.ts index 6d3144eeaec..aba6dd81982 100644 --- a/tests/webTestServer.ts +++ b/tests/webTestServer.ts @@ -191,7 +191,6 @@ function getRequestOperation(req: http.ServerRequest, filename: string) { } return RequestType.Unknown } - return RequestType.Unknown } function handleRequestOperation(req: http.ServerRequest, res: http.ServerResponse, operation: RequestType, reqPath: string) { From 613c51d6b50b8f5224700ae4715fe1c45ed24879 Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Mon, 5 Oct 2015 10:43:54 -0700 Subject: [PATCH 043/227] Fix jakefile rules build --- Jakefile.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Jakefile.js b/Jakefile.js index 84f2d527857..4c5287d6760 100644 --- a/Jakefile.js +++ b/Jakefile.js @@ -247,6 +247,8 @@ function compileFile(outFile, sources, prereqs, prefixes, useBuiltCompiler, noOu if (!noOutFile) { options += " --out " + outFile; + } else { + options += " --module commonjs" } if(noResolve) { From 05dc9daf7da3a33bece3c3b390f3e1af363d93f8 Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Mon, 5 Oct 2015 13:22:42 -0700 Subject: [PATCH 044/227] concatenated type emit --- src/compiler/declarationEmitter.ts | 54 ++++++++++++++++++++++++++++-- src/compiler/emitter.ts | 24 ++----------- src/compiler/utilities.ts | 18 ++++++++++ 3 files changed, 72 insertions(+), 24 deletions(-) diff --git a/src/compiler/declarationEmitter.ts b/src/compiler/declarationEmitter.ts index 00085f16086..d66c4110336 100644 --- a/src/compiler/declarationEmitter.ts +++ b/src/compiler/declarationEmitter.ts @@ -104,6 +104,7 @@ namespace ts { else { // Emit references corresponding to this file let emittedReferencedFiles: SourceFile[] = []; + let prevModuleElementDeclarationEmitInfo: ModuleElementDeclarationEmitInfo[] = []; forEach(host.getSourceFiles(), sourceFile => { if (!isExternalModuleOrDeclarationFile(sourceFile)) { // Check what references need to be added @@ -123,7 +124,42 @@ namespace ts { emitSourceFile(sourceFile); } + else if (isExternalModule(sourceFile)) { + currentSourceFile = sourceFile; + write(`declare module "${sourceFile.moduleName}"`); + + let prevEnclosingDeclaration = enclosingDeclaration; + enclosingDeclaration = sourceFile; + write(" {"); + writeLine(); + increaseIndent(); + emitLines(sourceFile.statements); + decreaseIndent(); + write("}"); + writeLine(); + enclosingDeclaration = prevEnclosingDeclaration; + + // create asynchronous output for the importDeclarations + if (moduleElementDeclarationEmitInfo.length) { + let oldWriter = writer; + forEach(moduleElementDeclarationEmitInfo, aliasEmitInfo => { + if (aliasEmitInfo.isVisible && !aliasEmitInfo.asynchronousOutput) { + Debug.assert(aliasEmitInfo.node.kind === SyntaxKind.ImportDeclaration); + createAndSetNewTextWriterWithSymbolWriter(); + Debug.assert(aliasEmitInfo.indent === 1); + increaseIndent(); + writeImportDeclaration(aliasEmitInfo.node); + aliasEmitInfo.asynchronousOutput = writer.getText(); + decreaseIndent(); + } + }); + setWriter(oldWriter); + } + prevModuleElementDeclarationEmitInfo = prevModuleElementDeclarationEmitInfo.concat(moduleElementDeclarationEmitInfo); + moduleElementDeclarationEmitInfo = []; + } }); + moduleElementDeclarationEmitInfo = moduleElementDeclarationEmitInfo.concat(prevModuleElementDeclarationEmitInfo); } return { @@ -601,7 +637,7 @@ namespace ts { if (node.flags & NodeFlags.Default) { write("default "); } - else if (node.kind !== SyntaxKind.InterfaceDeclaration) { + else if (node.kind !== SyntaxKind.InterfaceDeclaration && root) { write("declare "); } } @@ -696,7 +732,13 @@ namespace ts { } write(" from "); } - writeTextOfNode(currentSourceFile, node.moduleSpecifier); + let match: RegExpMatchArray; + if ((!root) && node.moduleSpecifier.kind === SyntaxKind.StringLiteral && (match = getTextOfNode(node.moduleSpecifier).match(/('|")(\.\/|\.\.\/)/))) { + write(makeModulePathSemiabsolute(host, currentSourceFile, getTextOfNode(node.moduleSpecifier))); + } + else { + writeTextOfNode(currentSourceFile, node.moduleSpecifier); + } write(";"); writer.writeLine(); } @@ -732,7 +774,13 @@ namespace ts { } if (node.moduleSpecifier) { write(" from "); - writeTextOfNode(currentSourceFile, node.moduleSpecifier); + let match: RegExpMatchArray; + if ((!root) && node.moduleSpecifier.kind === SyntaxKind.StringLiteral && (match = getTextOfNode(node.moduleSpecifier).match(/('|")(\.\/|\.\.\/)/))) { + write(makeModulePathSemiabsolute(host, currentSourceFile, getTextOfNode(node.moduleSpecifier))); + } + else { + writeTextOfNode(currentSourceFile, node.moduleSpecifier); + } } write(";"); writer.writeLine(); diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index 4ce0a39eb07..1b0492643bf 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -499,18 +499,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi function emitConcatenatedModule(sourceFile: SourceFile): void { currentSourceFile = sourceFile; exportFunctionForFile = undefined; - let canonicalName = resolveToSemiabsolutePath(sourceFile.fileName); + let canonicalName = resolveToSemiabsolutePath(host, sourceFile.fileName); sourceFile.moduleName = sourceFile.moduleName || canonicalName; emit(sourceFile); } - function resolveToSemiabsolutePath(path: string): string { - let dir = host.getCurrentDirectory(); - return removeFileExtension( - getRelativePathToDirectoryOrUrl(dir, path, dir, f => host.getCanonicalFileName(f), /*isAbsolutePathAnUrl*/false) - ); - } - function isUniqueName(name: string): boolean { return !resolver.hasGlobalName(name) && !hasProperty(currentSourceFile.identifiers, name) && @@ -6681,7 +6674,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi } if (resolvePath) { - text = makeModulePathSemiabsolute(text); + text = makeModulePathSemiabsolute(host, currentSourceFile, text); } write(text); } @@ -6702,17 +6695,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi importAliasNames: string[]; } - function makeModulePathSemiabsolute(externalModuleName: string): string { - let quotemark = externalModuleName.charAt(0); - let unquotedModuleName = externalModuleName.substring(1, externalModuleName.length - 1); - let resolvedFileName = host.resolveModuleName(unquotedModuleName, currentSourceFile.fileName); - if (resolvedFileName) { - let semiabsoluteName = resolveToSemiabsolutePath(resolvedFileName); - externalModuleName = quoteString(semiabsoluteName, quotemark); - } - return externalModuleName; - } - function getAMDDependencyNames(node: SourceFile, includeNonAmdDependencies: boolean, resolvePath?: boolean): AMDDependencyNames { // names of modules with corresponding parameter in the factory function let aliasedModuleNames: string[] = []; @@ -6738,7 +6720,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi let externalModuleName = getExternalModuleNameText(importNode); if (resolvePath) { - externalModuleName = makeModulePathSemiabsolute(externalModuleName); + externalModuleName = makeModulePathSemiabsolute(host, currentSourceFile, externalModuleName); } // Find the name of the module alias, if there is one diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 9ae65af046e..db30e4ca68e 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -1775,6 +1775,24 @@ namespace ts { }; } + export function makeModulePathSemiabsolute(host: EmitHost, currentSourceFile: SourceFile, externalModuleName: string): string { + let quotemark = externalModuleName.charAt(0); + let unquotedModuleName = externalModuleName.substring(1, externalModuleName.length - 1); + let resolvedFileName = host.resolveModuleName(unquotedModuleName, currentSourceFile.fileName); + if (resolvedFileName) { + let semiabsoluteName = resolveToSemiabsolutePath(host, resolvedFileName); + externalModuleName = quoteString(semiabsoluteName, quotemark); + } + return externalModuleName; + } + + export function resolveToSemiabsolutePath(host: EmitHost, path: string): string { + let dir = host.getCurrentDirectory(); + return removeFileExtension( + getRelativePathToDirectoryOrUrl(dir, path, dir, f => host.getCanonicalFileName(f), /*isAbsolutePathAnUrl*/false) + ); + } + export function getOwnEmitOutputFilePath(sourceFile: SourceFile, host: EmitHost, extension: string) { let compilerOptions = host.getCompilerOptions(); let emitOutputFilePathWithoutExtension: string; From d07e33dd9800b629d4e1e5335bb84fa08200ec06 Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Mon, 5 Oct 2015 14:06:34 -0700 Subject: [PATCH 045/227] Correct output, accept new baselines --- src/compiler/declarationEmitter.ts | 15 ++++------ .../baselines/reference/outModuleConcatAmd.js | 9 ++++++ .../reference/outModuleConcatCommonjs.js | 9 ++++++ .../baselines/reference/outModuleConcatES6.js | 9 ++++++ .../reference/outModuleConcatSystem.js | 9 ++++++ .../baselines/reference/outModuleConcatUmd.js | 9 ++++++ .../amd/bin/test.d.ts | 8 ++++++ .../node/bin/test.d.ts | 8 ++++++ .../amd/bin/outAndOutDirFile.d.ts | 8 ++++++ .../node/bin/outAndOutDirFile.d.ts | 8 ++++++ .../amd/bin/test.d.ts | 28 +++++++++++++++++++ .../node/bin/test.d.ts | 28 +++++++++++++++++++ .../amd/bin/test.d.ts | 18 ++++++++++++ .../node/bin/test.d.ts | 18 ++++++++++++ .../amd/bin/test.d.ts | 18 ++++++++++++ .../node/bin/test.d.ts | 18 ++++++++++++ .../amd/bin/test.d.ts | 8 ++++++ .../node/bin/test.d.ts | 8 ++++++ .../amd/bin/outAndOutDirFile.d.ts | 8 ++++++ .../node/bin/outAndOutDirFile.d.ts | 8 ++++++ .../amd/bin/test.d.ts | 28 +++++++++++++++++++ .../node/bin/test.d.ts | 28 +++++++++++++++++++ .../amd/bin/test.d.ts | 18 ++++++++++++ .../node/bin/test.d.ts | 18 ++++++++++++ .../amd/bin/test.d.ts | 18 ++++++++++++ .../node/bin/test.d.ts | 18 ++++++++++++ .../amd/bin/test.d.ts | 8 ++++++ .../node/bin/test.d.ts | 8 ++++++ .../amd/bin/outAndOutDirFile.d.ts | 8 ++++++ .../node/bin/outAndOutDirFile.d.ts | 8 ++++++ .../amd/bin/test.d.ts | 28 +++++++++++++++++++ .../node/bin/test.d.ts | 28 +++++++++++++++++++ .../amd/bin/test.d.ts | 18 ++++++++++++ .../node/bin/test.d.ts | 18 ++++++++++++ .../amd/bin/test.d.ts | 18 ++++++++++++ .../node/bin/test.d.ts | 18 ++++++++++++ .../amd/bin/test.d.ts | 8 ++++++ .../node/bin/test.d.ts | 8 ++++++ .../amd/bin/outAndOutDirFile.d.ts | 8 ++++++ .../node/bin/outAndOutDirFile.d.ts | 8 ++++++ .../amd/bin/test.d.ts | 28 +++++++++++++++++++ .../node/bin/test.d.ts | 28 +++++++++++++++++++ .../amd/bin/test.d.ts | 18 ++++++++++++ .../node/bin/test.d.ts | 18 ++++++++++++ .../amd/bin/test.d.ts | 18 ++++++++++++ .../node/bin/test.d.ts | 18 ++++++++++++ .../amd/bin/test.d.ts | 8 ++++++ .../node/bin/test.d.ts | 8 ++++++ .../amd/bin/outAndOutDirFile.d.ts | 8 ++++++ .../node/bin/outAndOutDirFile.d.ts | 8 ++++++ .../amd/bin/test.d.ts | 28 +++++++++++++++++++ .../node/bin/test.d.ts | 28 +++++++++++++++++++ .../amd/bin/test.d.ts | 18 ++++++++++++ .../node/bin/test.d.ts | 18 ++++++++++++ .../amd/bin/test.d.ts | 18 ++++++++++++ .../node/bin/test.d.ts | 18 ++++++++++++ .../amd/bin/test.d.ts | 8 ++++++ .../node/bin/test.d.ts | 8 ++++++ .../amd/bin/outAndOutDirFile.d.ts | 8 ++++++ .../node/bin/outAndOutDirFile.d.ts | 8 ++++++ .../amd/bin/test.d.ts | 28 +++++++++++++++++++ .../node/bin/test.d.ts | 28 +++++++++++++++++++ .../amd/bin/test.d.ts | 18 ++++++++++++ .../node/bin/test.d.ts | 18 ++++++++++++ .../amd/bin/test.d.ts | 18 ++++++++++++ .../node/bin/test.d.ts | 18 ++++++++++++ .../amd/bin/test.d.ts | 8 ++++++ .../node/bin/test.d.ts | 8 ++++++ .../amd/bin/outAndOutDirFile.d.ts | 8 ++++++ .../node/bin/outAndOutDirFile.d.ts | 8 ++++++ .../amd/bin/test.d.ts | 28 +++++++++++++++++++ .../node/bin/test.d.ts | 28 +++++++++++++++++++ .../amd/bin/test.d.ts | 18 ++++++++++++ .../node/bin/test.d.ts | 18 ++++++++++++ .../amd/bin/test.d.ts | 18 ++++++++++++ .../node/bin/test.d.ts | 18 ++++++++++++ .../amd/bin/test.d.ts | 8 ++++++ .../node/bin/test.d.ts | 8 ++++++ .../amd/bin/outAndOutDirFile.d.ts | 8 ++++++ .../node/bin/outAndOutDirFile.d.ts | 8 ++++++ .../amd/bin/test.d.ts | 28 +++++++++++++++++++ .../node/bin/test.d.ts | 28 +++++++++++++++++++ .../amd/bin/test.d.ts | 18 ++++++++++++ .../node/bin/test.d.ts | 18 ++++++++++++ .../amd/bin/test.d.ts | 18 ++++++++++++ .../node/bin/test.d.ts | 18 ++++++++++++ .../amd/bin/test.d.ts | 8 ++++++ .../node/bin/test.d.ts | 8 ++++++ .../amd/bin/outAndOutDirFile.d.ts | 8 ++++++ .../node/bin/outAndOutDirFile.d.ts | 8 ++++++ .../amd/bin/test.d.ts | 28 +++++++++++++++++++ .../node/bin/test.d.ts | 28 +++++++++++++++++++ .../amd/bin/test.d.ts | 18 ++++++++++++ .../node/bin/test.d.ts | 18 ++++++++++++ .../amd/bin/test.d.ts | 18 ++++++++++++ .../node/bin/test.d.ts | 18 ++++++++++++ 96 files changed, 1491 insertions(+), 9 deletions(-) diff --git a/src/compiler/declarationEmitter.ts b/src/compiler/declarationEmitter.ts index d66c4110336..277a1bf169a 100644 --- a/src/compiler/declarationEmitter.ts +++ b/src/compiler/declarationEmitter.ts @@ -55,6 +55,7 @@ namespace ts { let errorNameNode: DeclarationName; let emitJsDocComments = compilerOptions.removeComments ? function (declaration: Node) { } : writeJsDocComments; let emit = compilerOptions.stripInternal ? stripInternal : emitNode; + let noDeclare = !root; let moduleElementDeclarationEmitInfo: ModuleElementDeclarationEmitInfo[] = []; let asynchronousSubModuleDeclarationEmitInfo: ModuleElementDeclarationEmitInfo[]; @@ -107,6 +108,7 @@ namespace ts { let prevModuleElementDeclarationEmitInfo: ModuleElementDeclarationEmitInfo[] = []; forEach(host.getSourceFiles(), sourceFile => { if (!isExternalModuleOrDeclarationFile(sourceFile)) { + noDeclare = false; // Check what references need to be added if (!compilerOptions.noResolve) { forEach(sourceFile.referencedFiles, fileReference => { @@ -125,19 +127,14 @@ namespace ts { emitSourceFile(sourceFile); } else if (isExternalModule(sourceFile)) { - currentSourceFile = sourceFile; - write(`declare module "${sourceFile.moduleName}"`); - - let prevEnclosingDeclaration = enclosingDeclaration; - enclosingDeclaration = sourceFile; - write(" {"); + noDeclare = true; + write(`declare module "${sourceFile.moduleName}" {`); writeLine(); increaseIndent(); - emitLines(sourceFile.statements); + emitSourceFile(sourceFile) decreaseIndent(); write("}"); writeLine(); - enclosingDeclaration = prevEnclosingDeclaration; // create asynchronous output for the importDeclarations if (moduleElementDeclarationEmitInfo.length) { @@ -637,7 +634,7 @@ namespace ts { if (node.flags & NodeFlags.Default) { write("default "); } - else if (node.kind !== SyntaxKind.InterfaceDeclaration && root) { + else if (node.kind !== SyntaxKind.InterfaceDeclaration && !noDeclare) { write("declare "); } } diff --git a/tests/baselines/reference/outModuleConcatAmd.js b/tests/baselines/reference/outModuleConcatAmd.js index f6af61005e9..5d825757b71 100644 --- a/tests/baselines/reference/outModuleConcatAmd.js +++ b/tests/baselines/reference/outModuleConcatAmd.js @@ -67,3 +67,12 @@ import { A } from "./ref/a"; export declare class B extends A { } //// [all.d.ts] +declare module "tests/cases/compiler/ref/a" { + export class A { + } +} +declare module "tests/cases/compiler/b" { + import { A } from "tests/cases/compiler/ref/a"; + export class B extends A { + } +} diff --git a/tests/baselines/reference/outModuleConcatCommonjs.js b/tests/baselines/reference/outModuleConcatCommonjs.js index ed19f93f702..0f83b4fbe99 100644 --- a/tests/baselines/reference/outModuleConcatCommonjs.js +++ b/tests/baselines/reference/outModuleConcatCommonjs.js @@ -50,3 +50,12 @@ import { A } from "./ref/a"; export declare class B extends A { } //// [all.d.ts] +declare module "tests/cases/compiler/ref/a" { + export class A { + } +} +declare module "tests/cases/compiler/b" { + import { A } from "tests/cases/compiler/ref/a"; + export class B extends A { + } +} diff --git a/tests/baselines/reference/outModuleConcatES6.js b/tests/baselines/reference/outModuleConcatES6.js index 91aa1bb90e4..c8db9e083b6 100644 --- a/tests/baselines/reference/outModuleConcatES6.js +++ b/tests/baselines/reference/outModuleConcatES6.js @@ -30,3 +30,12 @@ import { A } from "./ref/a"; export declare class B extends A { } //// [all.d.ts] +declare module "tests/cases/compiler/ref/a" { + export class A { + } +} +declare module "tests/cases/compiler/b" { + import { A } from "tests/cases/compiler/ref/a"; + export class B extends A { + } +} diff --git a/tests/baselines/reference/outModuleConcatSystem.js b/tests/baselines/reference/outModuleConcatSystem.js index 92c8772378f..970ea4b3d6d 100644 --- a/tests/baselines/reference/outModuleConcatSystem.js +++ b/tests/baselines/reference/outModuleConcatSystem.js @@ -99,3 +99,12 @@ import { A } from "./ref/a"; export declare class B extends A { } //// [all.d.ts] +declare module "tests/cases/compiler/ref/a" { + export class A { + } +} +declare module "tests/cases/compiler/b" { + import { A } from "tests/cases/compiler/ref/a"; + export class B extends A { + } +} diff --git a/tests/baselines/reference/outModuleConcatUmd.js b/tests/baselines/reference/outModuleConcatUmd.js index 6ff5e848aa2..b94617a19d8 100644 --- a/tests/baselines/reference/outModuleConcatUmd.js +++ b/tests/baselines/reference/outModuleConcatUmd.js @@ -68,3 +68,12 @@ import { A } from "./ref/a"; export declare class B extends A { } //// [all.d.ts] +declare module "tests/cases/compiler/ref/a" { + export class A { + } +} +declare module "tests/cases/compiler/b" { + import { A } from "tests/cases/compiler/ref/a"; + export class B extends A { + } +} diff --git a/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFile/amd/bin/test.d.ts b/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFile/amd/bin/test.d.ts index d61b4c3b876..bc9ccf61daf 100644 --- a/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFile/amd/bin/test.d.ts +++ b/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFile/amd/bin/test.d.ts @@ -5,6 +5,14 @@ declare class m1_c1 { } declare var m1_instance1: m1_c1; declare function m1_f1(): m1_c1; +declare module "ref/m2" { + export var m2_a1: number; + export class m2_c1 { + m2_c1_p1: number; + } + export var m2_instance1: m2_c1; + export function m2_f1(): m2_c1; +} declare var a1: number; declare class c1 { p1: number; diff --git a/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFile/node/bin/test.d.ts b/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFile/node/bin/test.d.ts index d61b4c3b876..bc9ccf61daf 100644 --- a/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFile/node/bin/test.d.ts +++ b/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFile/node/bin/test.d.ts @@ -5,6 +5,14 @@ declare class m1_c1 { } declare var m1_instance1: m1_c1; declare function m1_f1(): m1_c1; +declare module "ref/m2" { + export var m2_a1: number; + export class m2_c1 { + m2_c1_p1: number; + } + export var m2_instance1: m2_c1; + export function m2_f1(): m2_c1; +} declare var a1: number; declare class c1 { p1: number; diff --git a/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.d.ts b/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.d.ts index 9b9cdd4a214..375869ffc94 100644 --- a/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.d.ts +++ b/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.d.ts @@ -5,6 +5,14 @@ declare class m1_c1 { } declare var m1_instance1: m1_c1; declare function m1_f1(): m1_c1; +declare module "ref/m2" { + export var m2_a1: number; + export class m2_c1 { + m2_c1_p1: number; + } + export var m2_instance1: m2_c1; + export function m2_f1(): m2_c1; +} declare var a1: number; declare class c1 { p1: number; diff --git a/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.d.ts b/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.d.ts index 9b9cdd4a214..375869ffc94 100644 --- a/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.d.ts +++ b/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.d.ts @@ -5,6 +5,14 @@ declare class m1_c1 { } declare var m1_instance1: m1_c1; declare function m1_f1(): m1_c1; +declare module "ref/m2" { + export var m2_a1: number; + export class m2_c1 { + m2_c1_p1: number; + } + export var m2_instance1: m2_c1; + export function m2_f1(): m2_c1; +} declare var a1: number; declare class c1 { p1: number; diff --git a/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderSpecifyOutputFile/amd/bin/test.d.ts b/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderSpecifyOutputFile/amd/bin/test.d.ts index e69de29bb2d..9b6af66589a 100644 --- a/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderSpecifyOutputFile/amd/bin/test.d.ts +++ b/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderSpecifyOutputFile/amd/bin/test.d.ts @@ -0,0 +1,28 @@ +declare module "ref/m1" { + export var m1_a1: number; + export class m1_c1 { + m1_c1_p1: number; + } + export var m1_instance1: m1_c1; + export function m1_f1(): m1_c1; +} +declare module "../outputdir_module_multifolder_ref/m2" { + export var m2_a1: number; + export class m2_c1 { + m2_c1_p1: number; + } + export var m2_instance1: m2_c1; + export function m2_f1(): m2_c1; +} +declare module "test" { + import m1 = require("ref/m1"); + import m2 = require("../outputdir_module_multifolder_ref/m2"); + export var a1: number; + export class c1 { + p1: number; + } + export var instance1: c1; + export function f1(): c1; + export var a2: typeof m1.m1_c1; + export var a3: typeof m2.m2_c1; +} diff --git a/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderSpecifyOutputFile/node/bin/test.d.ts b/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderSpecifyOutputFile/node/bin/test.d.ts index e69de29bb2d..9b6af66589a 100644 --- a/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderSpecifyOutputFile/node/bin/test.d.ts +++ b/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderSpecifyOutputFile/node/bin/test.d.ts @@ -0,0 +1,28 @@ +declare module "ref/m1" { + export var m1_a1: number; + export class m1_c1 { + m1_c1_p1: number; + } + export var m1_instance1: m1_c1; + export function m1_f1(): m1_c1; +} +declare module "../outputdir_module_multifolder_ref/m2" { + export var m2_a1: number; + export class m2_c1 { + m2_c1_p1: number; + } + export var m2_instance1: m2_c1; + export function m2_f1(): m2_c1; +} +declare module "test" { + import m1 = require("ref/m1"); + import m2 = require("../outputdir_module_multifolder_ref/m2"); + export var a1: number; + export class c1 { + p1: number; + } + export var instance1: c1; + export function f1(): c1; + export var a2: typeof m1.m1_c1; + export var a3: typeof m2.m2_c1; +} diff --git a/tests/baselines/reference/project/mapRootAbsolutePathModuleSimpleSpecifyOutputFile/amd/bin/test.d.ts b/tests/baselines/reference/project/mapRootAbsolutePathModuleSimpleSpecifyOutputFile/amd/bin/test.d.ts index e69de29bb2d..df062274b3e 100644 --- a/tests/baselines/reference/project/mapRootAbsolutePathModuleSimpleSpecifyOutputFile/amd/bin/test.d.ts +++ b/tests/baselines/reference/project/mapRootAbsolutePathModuleSimpleSpecifyOutputFile/amd/bin/test.d.ts @@ -0,0 +1,18 @@ +declare module "m1" { + export var m1_a1: number; + export class m1_c1 { + m1_c1_p1: number; + } + export var m1_instance1: m1_c1; + export function m1_f1(): m1_c1; +} +declare module "test" { + import m1 = require("m1"); + export var a1: number; + export class c1 { + p1: number; + } + export var instance1: c1; + export function f1(): c1; + export var a2: typeof m1.m1_c1; +} diff --git a/tests/baselines/reference/project/mapRootAbsolutePathModuleSimpleSpecifyOutputFile/node/bin/test.d.ts b/tests/baselines/reference/project/mapRootAbsolutePathModuleSimpleSpecifyOutputFile/node/bin/test.d.ts index e69de29bb2d..df062274b3e 100644 --- a/tests/baselines/reference/project/mapRootAbsolutePathModuleSimpleSpecifyOutputFile/node/bin/test.d.ts +++ b/tests/baselines/reference/project/mapRootAbsolutePathModuleSimpleSpecifyOutputFile/node/bin/test.d.ts @@ -0,0 +1,18 @@ +declare module "m1" { + export var m1_a1: number; + export class m1_c1 { + m1_c1_p1: number; + } + export var m1_instance1: m1_c1; + export function m1_f1(): m1_c1; +} +declare module "test" { + import m1 = require("m1"); + export var a1: number; + export class c1 { + p1: number; + } + export var instance1: c1; + export function f1(): c1; + export var a2: typeof m1.m1_c1; +} diff --git a/tests/baselines/reference/project/mapRootAbsolutePathModuleSubfolderSpecifyOutputFile/amd/bin/test.d.ts b/tests/baselines/reference/project/mapRootAbsolutePathModuleSubfolderSpecifyOutputFile/amd/bin/test.d.ts index e69de29bb2d..18eee0fd4df 100644 --- a/tests/baselines/reference/project/mapRootAbsolutePathModuleSubfolderSpecifyOutputFile/amd/bin/test.d.ts +++ b/tests/baselines/reference/project/mapRootAbsolutePathModuleSubfolderSpecifyOutputFile/amd/bin/test.d.ts @@ -0,0 +1,18 @@ +declare module "ref/m1" { + export var m1_a1: number; + export class m1_c1 { + m1_c1_p1: number; + } + export var m1_instance1: m1_c1; + export function m1_f1(): m1_c1; +} +declare module "test" { + import m1 = require("ref/m1"); + export var a1: number; + export class c1 { + p1: number; + } + export var instance1: c1; + export function f1(): c1; + export var a2: typeof m1.m1_c1; +} diff --git a/tests/baselines/reference/project/mapRootAbsolutePathModuleSubfolderSpecifyOutputFile/node/bin/test.d.ts b/tests/baselines/reference/project/mapRootAbsolutePathModuleSubfolderSpecifyOutputFile/node/bin/test.d.ts index e69de29bb2d..18eee0fd4df 100644 --- a/tests/baselines/reference/project/mapRootAbsolutePathModuleSubfolderSpecifyOutputFile/node/bin/test.d.ts +++ b/tests/baselines/reference/project/mapRootAbsolutePathModuleSubfolderSpecifyOutputFile/node/bin/test.d.ts @@ -0,0 +1,18 @@ +declare module "ref/m1" { + export var m1_a1: number; + export class m1_c1 { + m1_c1_p1: number; + } + export var m1_instance1: m1_c1; + export function m1_f1(): m1_c1; +} +declare module "test" { + import m1 = require("ref/m1"); + export var a1: number; + export class c1 { + p1: number; + } + export var instance1: c1; + export function f1(): c1; + export var a2: typeof m1.m1_c1; +} diff --git a/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFile/amd/bin/test.d.ts b/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFile/amd/bin/test.d.ts index d61b4c3b876..bc9ccf61daf 100644 --- a/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFile/amd/bin/test.d.ts +++ b/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFile/amd/bin/test.d.ts @@ -5,6 +5,14 @@ declare class m1_c1 { } declare var m1_instance1: m1_c1; declare function m1_f1(): m1_c1; +declare module "ref/m2" { + export var m2_a1: number; + export class m2_c1 { + m2_c1_p1: number; + } + export var m2_instance1: m2_c1; + export function m2_f1(): m2_c1; +} declare var a1: number; declare class c1 { p1: number; diff --git a/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFile/node/bin/test.d.ts b/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFile/node/bin/test.d.ts index d61b4c3b876..bc9ccf61daf 100644 --- a/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFile/node/bin/test.d.ts +++ b/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFile/node/bin/test.d.ts @@ -5,6 +5,14 @@ declare class m1_c1 { } declare var m1_instance1: m1_c1; declare function m1_f1(): m1_c1; +declare module "ref/m2" { + export var m2_a1: number; + export class m2_c1 { + m2_c1_p1: number; + } + export var m2_instance1: m2_c1; + export function m2_f1(): m2_c1; +} declare var a1: number; declare class c1 { p1: number; diff --git a/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.d.ts b/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.d.ts index 9b9cdd4a214..375869ffc94 100644 --- a/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.d.ts +++ b/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.d.ts @@ -5,6 +5,14 @@ declare class m1_c1 { } declare var m1_instance1: m1_c1; declare function m1_f1(): m1_c1; +declare module "ref/m2" { + export var m2_a1: number; + export class m2_c1 { + m2_c1_p1: number; + } + export var m2_instance1: m2_c1; + export function m2_f1(): m2_c1; +} declare var a1: number; declare class c1 { p1: number; diff --git a/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.d.ts b/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.d.ts index 9b9cdd4a214..375869ffc94 100644 --- a/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.d.ts +++ b/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.d.ts @@ -5,6 +5,14 @@ declare class m1_c1 { } declare var m1_instance1: m1_c1; declare function m1_f1(): m1_c1; +declare module "ref/m2" { + export var m2_a1: number; + export class m2_c1 { + m2_c1_p1: number; + } + export var m2_instance1: m2_c1; + export function m2_f1(): m2_c1; +} declare var a1: number; declare class c1 { p1: number; diff --git a/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderSpecifyOutputFile/amd/bin/test.d.ts b/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderSpecifyOutputFile/amd/bin/test.d.ts index e69de29bb2d..9b6af66589a 100644 --- a/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderSpecifyOutputFile/amd/bin/test.d.ts +++ b/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderSpecifyOutputFile/amd/bin/test.d.ts @@ -0,0 +1,28 @@ +declare module "ref/m1" { + export var m1_a1: number; + export class m1_c1 { + m1_c1_p1: number; + } + export var m1_instance1: m1_c1; + export function m1_f1(): m1_c1; +} +declare module "../outputdir_module_multifolder_ref/m2" { + export var m2_a1: number; + export class m2_c1 { + m2_c1_p1: number; + } + export var m2_instance1: m2_c1; + export function m2_f1(): m2_c1; +} +declare module "test" { + import m1 = require("ref/m1"); + import m2 = require("../outputdir_module_multifolder_ref/m2"); + export var a1: number; + export class c1 { + p1: number; + } + export var instance1: c1; + export function f1(): c1; + export var a2: typeof m1.m1_c1; + export var a3: typeof m2.m2_c1; +} diff --git a/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderSpecifyOutputFile/node/bin/test.d.ts b/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderSpecifyOutputFile/node/bin/test.d.ts index e69de29bb2d..9b6af66589a 100644 --- a/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderSpecifyOutputFile/node/bin/test.d.ts +++ b/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderSpecifyOutputFile/node/bin/test.d.ts @@ -0,0 +1,28 @@ +declare module "ref/m1" { + export var m1_a1: number; + export class m1_c1 { + m1_c1_p1: number; + } + export var m1_instance1: m1_c1; + export function m1_f1(): m1_c1; +} +declare module "../outputdir_module_multifolder_ref/m2" { + export var m2_a1: number; + export class m2_c1 { + m2_c1_p1: number; + } + export var m2_instance1: m2_c1; + export function m2_f1(): m2_c1; +} +declare module "test" { + import m1 = require("ref/m1"); + import m2 = require("../outputdir_module_multifolder_ref/m2"); + export var a1: number; + export class c1 { + p1: number; + } + export var instance1: c1; + export function f1(): c1; + export var a2: typeof m1.m1_c1; + export var a3: typeof m2.m2_c1; +} diff --git a/tests/baselines/reference/project/mapRootRelativePathModuleSimpleSpecifyOutputFile/amd/bin/test.d.ts b/tests/baselines/reference/project/mapRootRelativePathModuleSimpleSpecifyOutputFile/amd/bin/test.d.ts index e69de29bb2d..df062274b3e 100644 --- a/tests/baselines/reference/project/mapRootRelativePathModuleSimpleSpecifyOutputFile/amd/bin/test.d.ts +++ b/tests/baselines/reference/project/mapRootRelativePathModuleSimpleSpecifyOutputFile/amd/bin/test.d.ts @@ -0,0 +1,18 @@ +declare module "m1" { + export var m1_a1: number; + export class m1_c1 { + m1_c1_p1: number; + } + export var m1_instance1: m1_c1; + export function m1_f1(): m1_c1; +} +declare module "test" { + import m1 = require("m1"); + export var a1: number; + export class c1 { + p1: number; + } + export var instance1: c1; + export function f1(): c1; + export var a2: typeof m1.m1_c1; +} diff --git a/tests/baselines/reference/project/mapRootRelativePathModuleSimpleSpecifyOutputFile/node/bin/test.d.ts b/tests/baselines/reference/project/mapRootRelativePathModuleSimpleSpecifyOutputFile/node/bin/test.d.ts index e69de29bb2d..df062274b3e 100644 --- a/tests/baselines/reference/project/mapRootRelativePathModuleSimpleSpecifyOutputFile/node/bin/test.d.ts +++ b/tests/baselines/reference/project/mapRootRelativePathModuleSimpleSpecifyOutputFile/node/bin/test.d.ts @@ -0,0 +1,18 @@ +declare module "m1" { + export var m1_a1: number; + export class m1_c1 { + m1_c1_p1: number; + } + export var m1_instance1: m1_c1; + export function m1_f1(): m1_c1; +} +declare module "test" { + import m1 = require("m1"); + export var a1: number; + export class c1 { + p1: number; + } + export var instance1: c1; + export function f1(): c1; + export var a2: typeof m1.m1_c1; +} diff --git a/tests/baselines/reference/project/mapRootRelativePathModuleSubfolderSpecifyOutputFile/amd/bin/test.d.ts b/tests/baselines/reference/project/mapRootRelativePathModuleSubfolderSpecifyOutputFile/amd/bin/test.d.ts index e69de29bb2d..18eee0fd4df 100644 --- a/tests/baselines/reference/project/mapRootRelativePathModuleSubfolderSpecifyOutputFile/amd/bin/test.d.ts +++ b/tests/baselines/reference/project/mapRootRelativePathModuleSubfolderSpecifyOutputFile/amd/bin/test.d.ts @@ -0,0 +1,18 @@ +declare module "ref/m1" { + export var m1_a1: number; + export class m1_c1 { + m1_c1_p1: number; + } + export var m1_instance1: m1_c1; + export function m1_f1(): m1_c1; +} +declare module "test" { + import m1 = require("ref/m1"); + export var a1: number; + export class c1 { + p1: number; + } + export var instance1: c1; + export function f1(): c1; + export var a2: typeof m1.m1_c1; +} diff --git a/tests/baselines/reference/project/mapRootRelativePathModuleSubfolderSpecifyOutputFile/node/bin/test.d.ts b/tests/baselines/reference/project/mapRootRelativePathModuleSubfolderSpecifyOutputFile/node/bin/test.d.ts index e69de29bb2d..18eee0fd4df 100644 --- a/tests/baselines/reference/project/mapRootRelativePathModuleSubfolderSpecifyOutputFile/node/bin/test.d.ts +++ b/tests/baselines/reference/project/mapRootRelativePathModuleSubfolderSpecifyOutputFile/node/bin/test.d.ts @@ -0,0 +1,18 @@ +declare module "ref/m1" { + export var m1_a1: number; + export class m1_c1 { + m1_c1_p1: number; + } + export var m1_instance1: m1_c1; + export function m1_f1(): m1_c1; +} +declare module "test" { + import m1 = require("ref/m1"); + export var a1: number; + export class c1 { + p1: number; + } + export var instance1: c1; + export function f1(): c1; + export var a2: typeof m1.m1_c1; +} diff --git a/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFile/amd/bin/test.d.ts b/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFile/amd/bin/test.d.ts index d61b4c3b876..bc9ccf61daf 100644 --- a/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFile/amd/bin/test.d.ts +++ b/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFile/amd/bin/test.d.ts @@ -5,6 +5,14 @@ declare class m1_c1 { } declare var m1_instance1: m1_c1; declare function m1_f1(): m1_c1; +declare module "ref/m2" { + export var m2_a1: number; + export class m2_c1 { + m2_c1_p1: number; + } + export var m2_instance1: m2_c1; + export function m2_f1(): m2_c1; +} declare var a1: number; declare class c1 { p1: number; diff --git a/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFile/node/bin/test.d.ts b/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFile/node/bin/test.d.ts index d61b4c3b876..bc9ccf61daf 100644 --- a/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFile/node/bin/test.d.ts +++ b/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFile/node/bin/test.d.ts @@ -5,6 +5,14 @@ declare class m1_c1 { } declare var m1_instance1: m1_c1; declare function m1_f1(): m1_c1; +declare module "ref/m2" { + export var m2_a1: number; + export class m2_c1 { + m2_c1_p1: number; + } + export var m2_instance1: m2_c1; + export function m2_f1(): m2_c1; +} declare var a1: number; declare class c1 { p1: number; diff --git a/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.d.ts b/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.d.ts index 9b9cdd4a214..375869ffc94 100644 --- a/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.d.ts +++ b/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.d.ts @@ -5,6 +5,14 @@ declare class m1_c1 { } declare var m1_instance1: m1_c1; declare function m1_f1(): m1_c1; +declare module "ref/m2" { + export var m2_a1: number; + export class m2_c1 { + m2_c1_p1: number; + } + export var m2_instance1: m2_c1; + export function m2_f1(): m2_c1; +} declare var a1: number; declare class c1 { p1: number; diff --git a/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.d.ts b/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.d.ts index 9b9cdd4a214..375869ffc94 100644 --- a/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.d.ts +++ b/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.d.ts @@ -5,6 +5,14 @@ declare class m1_c1 { } declare var m1_instance1: m1_c1; declare function m1_f1(): m1_c1; +declare module "ref/m2" { + export var m2_a1: number; + export class m2_c1 { + m2_c1_p1: number; + } + export var m2_instance1: m2_c1; + export function m2_f1(): m2_c1; +} declare var a1: number; declare class c1 { p1: number; diff --git a/tests/baselines/reference/project/maprootUrlModuleMultifolderSpecifyOutputFile/amd/bin/test.d.ts b/tests/baselines/reference/project/maprootUrlModuleMultifolderSpecifyOutputFile/amd/bin/test.d.ts index e69de29bb2d..9b6af66589a 100644 --- a/tests/baselines/reference/project/maprootUrlModuleMultifolderSpecifyOutputFile/amd/bin/test.d.ts +++ b/tests/baselines/reference/project/maprootUrlModuleMultifolderSpecifyOutputFile/amd/bin/test.d.ts @@ -0,0 +1,28 @@ +declare module "ref/m1" { + export var m1_a1: number; + export class m1_c1 { + m1_c1_p1: number; + } + export var m1_instance1: m1_c1; + export function m1_f1(): m1_c1; +} +declare module "../outputdir_module_multifolder_ref/m2" { + export var m2_a1: number; + export class m2_c1 { + m2_c1_p1: number; + } + export var m2_instance1: m2_c1; + export function m2_f1(): m2_c1; +} +declare module "test" { + import m1 = require("ref/m1"); + import m2 = require("../outputdir_module_multifolder_ref/m2"); + export var a1: number; + export class c1 { + p1: number; + } + export var instance1: c1; + export function f1(): c1; + export var a2: typeof m1.m1_c1; + export var a3: typeof m2.m2_c1; +} diff --git a/tests/baselines/reference/project/maprootUrlModuleMultifolderSpecifyOutputFile/node/bin/test.d.ts b/tests/baselines/reference/project/maprootUrlModuleMultifolderSpecifyOutputFile/node/bin/test.d.ts index e69de29bb2d..9b6af66589a 100644 --- a/tests/baselines/reference/project/maprootUrlModuleMultifolderSpecifyOutputFile/node/bin/test.d.ts +++ b/tests/baselines/reference/project/maprootUrlModuleMultifolderSpecifyOutputFile/node/bin/test.d.ts @@ -0,0 +1,28 @@ +declare module "ref/m1" { + export var m1_a1: number; + export class m1_c1 { + m1_c1_p1: number; + } + export var m1_instance1: m1_c1; + export function m1_f1(): m1_c1; +} +declare module "../outputdir_module_multifolder_ref/m2" { + export var m2_a1: number; + export class m2_c1 { + m2_c1_p1: number; + } + export var m2_instance1: m2_c1; + export function m2_f1(): m2_c1; +} +declare module "test" { + import m1 = require("ref/m1"); + import m2 = require("../outputdir_module_multifolder_ref/m2"); + export var a1: number; + export class c1 { + p1: number; + } + export var instance1: c1; + export function f1(): c1; + export var a2: typeof m1.m1_c1; + export var a3: typeof m2.m2_c1; +} diff --git a/tests/baselines/reference/project/maprootUrlModuleSimpleSpecifyOutputFile/amd/bin/test.d.ts b/tests/baselines/reference/project/maprootUrlModuleSimpleSpecifyOutputFile/amd/bin/test.d.ts index e69de29bb2d..df062274b3e 100644 --- a/tests/baselines/reference/project/maprootUrlModuleSimpleSpecifyOutputFile/amd/bin/test.d.ts +++ b/tests/baselines/reference/project/maprootUrlModuleSimpleSpecifyOutputFile/amd/bin/test.d.ts @@ -0,0 +1,18 @@ +declare module "m1" { + export var m1_a1: number; + export class m1_c1 { + m1_c1_p1: number; + } + export var m1_instance1: m1_c1; + export function m1_f1(): m1_c1; +} +declare module "test" { + import m1 = require("m1"); + export var a1: number; + export class c1 { + p1: number; + } + export var instance1: c1; + export function f1(): c1; + export var a2: typeof m1.m1_c1; +} diff --git a/tests/baselines/reference/project/maprootUrlModuleSimpleSpecifyOutputFile/node/bin/test.d.ts b/tests/baselines/reference/project/maprootUrlModuleSimpleSpecifyOutputFile/node/bin/test.d.ts index e69de29bb2d..df062274b3e 100644 --- a/tests/baselines/reference/project/maprootUrlModuleSimpleSpecifyOutputFile/node/bin/test.d.ts +++ b/tests/baselines/reference/project/maprootUrlModuleSimpleSpecifyOutputFile/node/bin/test.d.ts @@ -0,0 +1,18 @@ +declare module "m1" { + export var m1_a1: number; + export class m1_c1 { + m1_c1_p1: number; + } + export var m1_instance1: m1_c1; + export function m1_f1(): m1_c1; +} +declare module "test" { + import m1 = require("m1"); + export var a1: number; + export class c1 { + p1: number; + } + export var instance1: c1; + export function f1(): c1; + export var a2: typeof m1.m1_c1; +} diff --git a/tests/baselines/reference/project/maprootUrlModuleSubfolderSpecifyOutputFile/amd/bin/test.d.ts b/tests/baselines/reference/project/maprootUrlModuleSubfolderSpecifyOutputFile/amd/bin/test.d.ts index e69de29bb2d..18eee0fd4df 100644 --- a/tests/baselines/reference/project/maprootUrlModuleSubfolderSpecifyOutputFile/amd/bin/test.d.ts +++ b/tests/baselines/reference/project/maprootUrlModuleSubfolderSpecifyOutputFile/amd/bin/test.d.ts @@ -0,0 +1,18 @@ +declare module "ref/m1" { + export var m1_a1: number; + export class m1_c1 { + m1_c1_p1: number; + } + export var m1_instance1: m1_c1; + export function m1_f1(): m1_c1; +} +declare module "test" { + import m1 = require("ref/m1"); + export var a1: number; + export class c1 { + p1: number; + } + export var instance1: c1; + export function f1(): c1; + export var a2: typeof m1.m1_c1; +} diff --git a/tests/baselines/reference/project/maprootUrlModuleSubfolderSpecifyOutputFile/node/bin/test.d.ts b/tests/baselines/reference/project/maprootUrlModuleSubfolderSpecifyOutputFile/node/bin/test.d.ts index e69de29bb2d..18eee0fd4df 100644 --- a/tests/baselines/reference/project/maprootUrlModuleSubfolderSpecifyOutputFile/node/bin/test.d.ts +++ b/tests/baselines/reference/project/maprootUrlModuleSubfolderSpecifyOutputFile/node/bin/test.d.ts @@ -0,0 +1,18 @@ +declare module "ref/m1" { + export var m1_a1: number; + export class m1_c1 { + m1_c1_p1: number; + } + export var m1_instance1: m1_c1; + export function m1_f1(): m1_c1; +} +declare module "test" { + import m1 = require("ref/m1"); + export var a1: number; + export class c1 { + p1: number; + } + export var instance1: c1; + export function f1(): c1; + export var a2: typeof m1.m1_c1; +} diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFile/amd/bin/test.d.ts b/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFile/amd/bin/test.d.ts index d61b4c3b876..bc9ccf61daf 100644 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFile/amd/bin/test.d.ts +++ b/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFile/amd/bin/test.d.ts @@ -5,6 +5,14 @@ declare class m1_c1 { } declare var m1_instance1: m1_c1; declare function m1_f1(): m1_c1; +declare module "ref/m2" { + export var m2_a1: number; + export class m2_c1 { + m2_c1_p1: number; + } + export var m2_instance1: m2_c1; + export function m2_f1(): m2_c1; +} declare var a1: number; declare class c1 { p1: number; diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFile/node/bin/test.d.ts b/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFile/node/bin/test.d.ts index d61b4c3b876..bc9ccf61daf 100644 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFile/node/bin/test.d.ts +++ b/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFile/node/bin/test.d.ts @@ -5,6 +5,14 @@ declare class m1_c1 { } declare var m1_instance1: m1_c1; declare function m1_f1(): m1_c1; +declare module "ref/m2" { + export var m2_a1: number; + export class m2_c1 { + m2_c1_p1: number; + } + export var m2_instance1: m2_c1; + export function m2_f1(): m2_c1; +} declare var a1: number; declare class c1 { p1: number; diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.d.ts b/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.d.ts index 9b9cdd4a214..375869ffc94 100644 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.d.ts +++ b/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.d.ts @@ -5,6 +5,14 @@ declare class m1_c1 { } declare var m1_instance1: m1_c1; declare function m1_f1(): m1_c1; +declare module "ref/m2" { + export var m2_a1: number; + export class m2_c1 { + m2_c1_p1: number; + } + export var m2_instance1: m2_c1; + export function m2_f1(): m2_c1; +} declare var a1: number; declare class c1 { p1: number; diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.d.ts b/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.d.ts index 9b9cdd4a214..375869ffc94 100644 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.d.ts +++ b/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.d.ts @@ -5,6 +5,14 @@ declare class m1_c1 { } declare var m1_instance1: m1_c1; declare function m1_f1(): m1_c1; +declare module "ref/m2" { + export var m2_a1: number; + export class m2_c1 { + m2_c1_p1: number; + } + export var m2_instance1: m2_c1; + export function m2_f1(): m2_c1; +} declare var a1: number; declare class c1 { p1: number; diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputFile/amd/bin/test.d.ts b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputFile/amd/bin/test.d.ts index e69de29bb2d..9b6af66589a 100644 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputFile/amd/bin/test.d.ts +++ b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputFile/amd/bin/test.d.ts @@ -0,0 +1,28 @@ +declare module "ref/m1" { + export var m1_a1: number; + export class m1_c1 { + m1_c1_p1: number; + } + export var m1_instance1: m1_c1; + export function m1_f1(): m1_c1; +} +declare module "../outputdir_module_multifolder_ref/m2" { + export var m2_a1: number; + export class m2_c1 { + m2_c1_p1: number; + } + export var m2_instance1: m2_c1; + export function m2_f1(): m2_c1; +} +declare module "test" { + import m1 = require("ref/m1"); + import m2 = require("../outputdir_module_multifolder_ref/m2"); + export var a1: number; + export class c1 { + p1: number; + } + export var instance1: c1; + export function f1(): c1; + export var a2: typeof m1.m1_c1; + export var a3: typeof m2.m2_c1; +} diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputFile/node/bin/test.d.ts b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputFile/node/bin/test.d.ts index e69de29bb2d..9b6af66589a 100644 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputFile/node/bin/test.d.ts +++ b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputFile/node/bin/test.d.ts @@ -0,0 +1,28 @@ +declare module "ref/m1" { + export var m1_a1: number; + export class m1_c1 { + m1_c1_p1: number; + } + export var m1_instance1: m1_c1; + export function m1_f1(): m1_c1; +} +declare module "../outputdir_module_multifolder_ref/m2" { + export var m2_a1: number; + export class m2_c1 { + m2_c1_p1: number; + } + export var m2_instance1: m2_c1; + export function m2_f1(): m2_c1; +} +declare module "test" { + import m1 = require("ref/m1"); + import m2 = require("../outputdir_module_multifolder_ref/m2"); + export var a1: number; + export class c1 { + p1: number; + } + export var instance1: c1; + export function f1(): c1; + export var a2: typeof m1.m1_c1; + export var a3: typeof m2.m2_c1; +} diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSimpleSpecifyOutputFile/amd/bin/test.d.ts b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSimpleSpecifyOutputFile/amd/bin/test.d.ts index e69de29bb2d..df062274b3e 100644 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSimpleSpecifyOutputFile/amd/bin/test.d.ts +++ b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSimpleSpecifyOutputFile/amd/bin/test.d.ts @@ -0,0 +1,18 @@ +declare module "m1" { + export var m1_a1: number; + export class m1_c1 { + m1_c1_p1: number; + } + export var m1_instance1: m1_c1; + export function m1_f1(): m1_c1; +} +declare module "test" { + import m1 = require("m1"); + export var a1: number; + export class c1 { + p1: number; + } + export var instance1: c1; + export function f1(): c1; + export var a2: typeof m1.m1_c1; +} diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSimpleSpecifyOutputFile/node/bin/test.d.ts b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSimpleSpecifyOutputFile/node/bin/test.d.ts index e69de29bb2d..df062274b3e 100644 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSimpleSpecifyOutputFile/node/bin/test.d.ts +++ b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSimpleSpecifyOutputFile/node/bin/test.d.ts @@ -0,0 +1,18 @@ +declare module "m1" { + export var m1_a1: number; + export class m1_c1 { + m1_c1_p1: number; + } + export var m1_instance1: m1_c1; + export function m1_f1(): m1_c1; +} +declare module "test" { + import m1 = require("m1"); + export var a1: number; + export class c1 { + p1: number; + } + export var instance1: c1; + export function f1(): c1; + export var a2: typeof m1.m1_c1; +} diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSubfolderSpecifyOutputFile/amd/bin/test.d.ts b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSubfolderSpecifyOutputFile/amd/bin/test.d.ts index e69de29bb2d..18eee0fd4df 100644 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSubfolderSpecifyOutputFile/amd/bin/test.d.ts +++ b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSubfolderSpecifyOutputFile/amd/bin/test.d.ts @@ -0,0 +1,18 @@ +declare module "ref/m1" { + export var m1_a1: number; + export class m1_c1 { + m1_c1_p1: number; + } + export var m1_instance1: m1_c1; + export function m1_f1(): m1_c1; +} +declare module "test" { + import m1 = require("ref/m1"); + export var a1: number; + export class c1 { + p1: number; + } + export var instance1: c1; + export function f1(): c1; + export var a2: typeof m1.m1_c1; +} diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSubfolderSpecifyOutputFile/node/bin/test.d.ts b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSubfolderSpecifyOutputFile/node/bin/test.d.ts index e69de29bb2d..18eee0fd4df 100644 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSubfolderSpecifyOutputFile/node/bin/test.d.ts +++ b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSubfolderSpecifyOutputFile/node/bin/test.d.ts @@ -0,0 +1,18 @@ +declare module "ref/m1" { + export var m1_a1: number; + export class m1_c1 { + m1_c1_p1: number; + } + export var m1_instance1: m1_c1; + export function m1_f1(): m1_c1; +} +declare module "test" { + import m1 = require("ref/m1"); + export var a1: number; + export class c1 { + p1: number; + } + export var instance1: c1; + export function f1(): c1; + export var a2: typeof m1.m1_c1; +} diff --git a/tests/baselines/reference/project/outMixedSubfolderSpecifyOutputFile/amd/bin/test.d.ts b/tests/baselines/reference/project/outMixedSubfolderSpecifyOutputFile/amd/bin/test.d.ts index d61b4c3b876..bc9ccf61daf 100644 --- a/tests/baselines/reference/project/outMixedSubfolderSpecifyOutputFile/amd/bin/test.d.ts +++ b/tests/baselines/reference/project/outMixedSubfolderSpecifyOutputFile/amd/bin/test.d.ts @@ -5,6 +5,14 @@ declare class m1_c1 { } declare var m1_instance1: m1_c1; declare function m1_f1(): m1_c1; +declare module "ref/m2" { + export var m2_a1: number; + export class m2_c1 { + m2_c1_p1: number; + } + export var m2_instance1: m2_c1; + export function m2_f1(): m2_c1; +} declare var a1: number; declare class c1 { p1: number; diff --git a/tests/baselines/reference/project/outMixedSubfolderSpecifyOutputFile/node/bin/test.d.ts b/tests/baselines/reference/project/outMixedSubfolderSpecifyOutputFile/node/bin/test.d.ts index d61b4c3b876..bc9ccf61daf 100644 --- a/tests/baselines/reference/project/outMixedSubfolderSpecifyOutputFile/node/bin/test.d.ts +++ b/tests/baselines/reference/project/outMixedSubfolderSpecifyOutputFile/node/bin/test.d.ts @@ -5,6 +5,14 @@ declare class m1_c1 { } declare var m1_instance1: m1_c1; declare function m1_f1(): m1_c1; +declare module "ref/m2" { + export var m2_a1: number; + export class m2_c1 { + m2_c1_p1: number; + } + export var m2_instance1: m2_c1; + export function m2_f1(): m2_c1; +} declare var a1: number; declare class c1 { p1: number; diff --git a/tests/baselines/reference/project/outMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.d.ts b/tests/baselines/reference/project/outMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.d.ts index 9b9cdd4a214..375869ffc94 100644 --- a/tests/baselines/reference/project/outMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.d.ts +++ b/tests/baselines/reference/project/outMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.d.ts @@ -5,6 +5,14 @@ declare class m1_c1 { } declare var m1_instance1: m1_c1; declare function m1_f1(): m1_c1; +declare module "ref/m2" { + export var m2_a1: number; + export class m2_c1 { + m2_c1_p1: number; + } + export var m2_instance1: m2_c1; + export function m2_f1(): m2_c1; +} declare var a1: number; declare class c1 { p1: number; diff --git a/tests/baselines/reference/project/outMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.d.ts b/tests/baselines/reference/project/outMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.d.ts index 9b9cdd4a214..375869ffc94 100644 --- a/tests/baselines/reference/project/outMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.d.ts +++ b/tests/baselines/reference/project/outMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.d.ts @@ -5,6 +5,14 @@ declare class m1_c1 { } declare var m1_instance1: m1_c1; declare function m1_f1(): m1_c1; +declare module "ref/m2" { + export var m2_a1: number; + export class m2_c1 { + m2_c1_p1: number; + } + export var m2_instance1: m2_c1; + export function m2_f1(): m2_c1; +} declare var a1: number; declare class c1 { p1: number; diff --git a/tests/baselines/reference/project/outModuleMultifolderSpecifyOutputFile/amd/bin/test.d.ts b/tests/baselines/reference/project/outModuleMultifolderSpecifyOutputFile/amd/bin/test.d.ts index e69de29bb2d..9b6af66589a 100644 --- a/tests/baselines/reference/project/outModuleMultifolderSpecifyOutputFile/amd/bin/test.d.ts +++ b/tests/baselines/reference/project/outModuleMultifolderSpecifyOutputFile/amd/bin/test.d.ts @@ -0,0 +1,28 @@ +declare module "ref/m1" { + export var m1_a1: number; + export class m1_c1 { + m1_c1_p1: number; + } + export var m1_instance1: m1_c1; + export function m1_f1(): m1_c1; +} +declare module "../outputdir_module_multifolder_ref/m2" { + export var m2_a1: number; + export class m2_c1 { + m2_c1_p1: number; + } + export var m2_instance1: m2_c1; + export function m2_f1(): m2_c1; +} +declare module "test" { + import m1 = require("ref/m1"); + import m2 = require("../outputdir_module_multifolder_ref/m2"); + export var a1: number; + export class c1 { + p1: number; + } + export var instance1: c1; + export function f1(): c1; + export var a2: typeof m1.m1_c1; + export var a3: typeof m2.m2_c1; +} diff --git a/tests/baselines/reference/project/outModuleMultifolderSpecifyOutputFile/node/bin/test.d.ts b/tests/baselines/reference/project/outModuleMultifolderSpecifyOutputFile/node/bin/test.d.ts index e69de29bb2d..9b6af66589a 100644 --- a/tests/baselines/reference/project/outModuleMultifolderSpecifyOutputFile/node/bin/test.d.ts +++ b/tests/baselines/reference/project/outModuleMultifolderSpecifyOutputFile/node/bin/test.d.ts @@ -0,0 +1,28 @@ +declare module "ref/m1" { + export var m1_a1: number; + export class m1_c1 { + m1_c1_p1: number; + } + export var m1_instance1: m1_c1; + export function m1_f1(): m1_c1; +} +declare module "../outputdir_module_multifolder_ref/m2" { + export var m2_a1: number; + export class m2_c1 { + m2_c1_p1: number; + } + export var m2_instance1: m2_c1; + export function m2_f1(): m2_c1; +} +declare module "test" { + import m1 = require("ref/m1"); + import m2 = require("../outputdir_module_multifolder_ref/m2"); + export var a1: number; + export class c1 { + p1: number; + } + export var instance1: c1; + export function f1(): c1; + export var a2: typeof m1.m1_c1; + export var a3: typeof m2.m2_c1; +} diff --git a/tests/baselines/reference/project/outModuleSimpleSpecifyOutputFile/amd/bin/test.d.ts b/tests/baselines/reference/project/outModuleSimpleSpecifyOutputFile/amd/bin/test.d.ts index e69de29bb2d..df062274b3e 100644 --- a/tests/baselines/reference/project/outModuleSimpleSpecifyOutputFile/amd/bin/test.d.ts +++ b/tests/baselines/reference/project/outModuleSimpleSpecifyOutputFile/amd/bin/test.d.ts @@ -0,0 +1,18 @@ +declare module "m1" { + export var m1_a1: number; + export class m1_c1 { + m1_c1_p1: number; + } + export var m1_instance1: m1_c1; + export function m1_f1(): m1_c1; +} +declare module "test" { + import m1 = require("m1"); + export var a1: number; + export class c1 { + p1: number; + } + export var instance1: c1; + export function f1(): c1; + export var a2: typeof m1.m1_c1; +} diff --git a/tests/baselines/reference/project/outModuleSimpleSpecifyOutputFile/node/bin/test.d.ts b/tests/baselines/reference/project/outModuleSimpleSpecifyOutputFile/node/bin/test.d.ts index e69de29bb2d..df062274b3e 100644 --- a/tests/baselines/reference/project/outModuleSimpleSpecifyOutputFile/node/bin/test.d.ts +++ b/tests/baselines/reference/project/outModuleSimpleSpecifyOutputFile/node/bin/test.d.ts @@ -0,0 +1,18 @@ +declare module "m1" { + export var m1_a1: number; + export class m1_c1 { + m1_c1_p1: number; + } + export var m1_instance1: m1_c1; + export function m1_f1(): m1_c1; +} +declare module "test" { + import m1 = require("m1"); + export var a1: number; + export class c1 { + p1: number; + } + export var instance1: c1; + export function f1(): c1; + export var a2: typeof m1.m1_c1; +} diff --git a/tests/baselines/reference/project/outModuleSubfolderSpecifyOutputFile/amd/bin/test.d.ts b/tests/baselines/reference/project/outModuleSubfolderSpecifyOutputFile/amd/bin/test.d.ts index e69de29bb2d..18eee0fd4df 100644 --- a/tests/baselines/reference/project/outModuleSubfolderSpecifyOutputFile/amd/bin/test.d.ts +++ b/tests/baselines/reference/project/outModuleSubfolderSpecifyOutputFile/amd/bin/test.d.ts @@ -0,0 +1,18 @@ +declare module "ref/m1" { + export var m1_a1: number; + export class m1_c1 { + m1_c1_p1: number; + } + export var m1_instance1: m1_c1; + export function m1_f1(): m1_c1; +} +declare module "test" { + import m1 = require("ref/m1"); + export var a1: number; + export class c1 { + p1: number; + } + export var instance1: c1; + export function f1(): c1; + export var a2: typeof m1.m1_c1; +} diff --git a/tests/baselines/reference/project/outModuleSubfolderSpecifyOutputFile/node/bin/test.d.ts b/tests/baselines/reference/project/outModuleSubfolderSpecifyOutputFile/node/bin/test.d.ts index e69de29bb2d..18eee0fd4df 100644 --- a/tests/baselines/reference/project/outModuleSubfolderSpecifyOutputFile/node/bin/test.d.ts +++ b/tests/baselines/reference/project/outModuleSubfolderSpecifyOutputFile/node/bin/test.d.ts @@ -0,0 +1,18 @@ +declare module "ref/m1" { + export var m1_a1: number; + export class m1_c1 { + m1_c1_p1: number; + } + export var m1_instance1: m1_c1; + export function m1_f1(): m1_c1; +} +declare module "test" { + import m1 = require("ref/m1"); + export var a1: number; + export class c1 { + p1: number; + } + export var instance1: c1; + export function f1(): c1; + export var a2: typeof m1.m1_c1; +} diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFile/amd/bin/test.d.ts b/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFile/amd/bin/test.d.ts index d61b4c3b876..bc9ccf61daf 100644 --- a/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFile/amd/bin/test.d.ts +++ b/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFile/amd/bin/test.d.ts @@ -5,6 +5,14 @@ declare class m1_c1 { } declare var m1_instance1: m1_c1; declare function m1_f1(): m1_c1; +declare module "ref/m2" { + export var m2_a1: number; + export class m2_c1 { + m2_c1_p1: number; + } + export var m2_instance1: m2_c1; + export function m2_f1(): m2_c1; +} declare var a1: number; declare class c1 { p1: number; diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFile/node/bin/test.d.ts b/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFile/node/bin/test.d.ts index d61b4c3b876..bc9ccf61daf 100644 --- a/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFile/node/bin/test.d.ts +++ b/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFile/node/bin/test.d.ts @@ -5,6 +5,14 @@ declare class m1_c1 { } declare var m1_instance1: m1_c1; declare function m1_f1(): m1_c1; +declare module "ref/m2" { + export var m2_a1: number; + export class m2_c1 { + m2_c1_p1: number; + } + export var m2_instance1: m2_c1; + export function m2_f1(): m2_c1; +} declare var a1: number; declare class c1 { p1: number; diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.d.ts b/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.d.ts index 9b9cdd4a214..375869ffc94 100644 --- a/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.d.ts +++ b/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.d.ts @@ -5,6 +5,14 @@ declare class m1_c1 { } declare var m1_instance1: m1_c1; declare function m1_f1(): m1_c1; +declare module "ref/m2" { + export var m2_a1: number; + export class m2_c1 { + m2_c1_p1: number; + } + export var m2_instance1: m2_c1; + export function m2_f1(): m2_c1; +} declare var a1: number; declare class c1 { p1: number; diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.d.ts b/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.d.ts index 9b9cdd4a214..375869ffc94 100644 --- a/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.d.ts +++ b/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.d.ts @@ -5,6 +5,14 @@ declare class m1_c1 { } declare var m1_instance1: m1_c1; declare function m1_f1(): m1_c1; +declare module "ref/m2" { + export var m2_a1: number; + export class m2_c1 { + m2_c1_p1: number; + } + export var m2_instance1: m2_c1; + export function m2_f1(): m2_c1; +} declare var a1: number; declare class c1 { p1: number; diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderSpecifyOutputFile/amd/bin/test.d.ts b/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderSpecifyOutputFile/amd/bin/test.d.ts index e69de29bb2d..9b6af66589a 100644 --- a/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderSpecifyOutputFile/amd/bin/test.d.ts +++ b/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderSpecifyOutputFile/amd/bin/test.d.ts @@ -0,0 +1,28 @@ +declare module "ref/m1" { + export var m1_a1: number; + export class m1_c1 { + m1_c1_p1: number; + } + export var m1_instance1: m1_c1; + export function m1_f1(): m1_c1; +} +declare module "../outputdir_module_multifolder_ref/m2" { + export var m2_a1: number; + export class m2_c1 { + m2_c1_p1: number; + } + export var m2_instance1: m2_c1; + export function m2_f1(): m2_c1; +} +declare module "test" { + import m1 = require("ref/m1"); + import m2 = require("../outputdir_module_multifolder_ref/m2"); + export var a1: number; + export class c1 { + p1: number; + } + export var instance1: c1; + export function f1(): c1; + export var a2: typeof m1.m1_c1; + export var a3: typeof m2.m2_c1; +} diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderSpecifyOutputFile/node/bin/test.d.ts b/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderSpecifyOutputFile/node/bin/test.d.ts index e69de29bb2d..9b6af66589a 100644 --- a/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderSpecifyOutputFile/node/bin/test.d.ts +++ b/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderSpecifyOutputFile/node/bin/test.d.ts @@ -0,0 +1,28 @@ +declare module "ref/m1" { + export var m1_a1: number; + export class m1_c1 { + m1_c1_p1: number; + } + export var m1_instance1: m1_c1; + export function m1_f1(): m1_c1; +} +declare module "../outputdir_module_multifolder_ref/m2" { + export var m2_a1: number; + export class m2_c1 { + m2_c1_p1: number; + } + export var m2_instance1: m2_c1; + export function m2_f1(): m2_c1; +} +declare module "test" { + import m1 = require("ref/m1"); + import m2 = require("../outputdir_module_multifolder_ref/m2"); + export var a1: number; + export class c1 { + p1: number; + } + export var instance1: c1; + export function f1(): c1; + export var a2: typeof m1.m1_c1; + export var a3: typeof m2.m2_c1; +} diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathModuleSimpleSpecifyOutputFile/amd/bin/test.d.ts b/tests/baselines/reference/project/sourceRootAbsolutePathModuleSimpleSpecifyOutputFile/amd/bin/test.d.ts index e69de29bb2d..df062274b3e 100644 --- a/tests/baselines/reference/project/sourceRootAbsolutePathModuleSimpleSpecifyOutputFile/amd/bin/test.d.ts +++ b/tests/baselines/reference/project/sourceRootAbsolutePathModuleSimpleSpecifyOutputFile/amd/bin/test.d.ts @@ -0,0 +1,18 @@ +declare module "m1" { + export var m1_a1: number; + export class m1_c1 { + m1_c1_p1: number; + } + export var m1_instance1: m1_c1; + export function m1_f1(): m1_c1; +} +declare module "test" { + import m1 = require("m1"); + export var a1: number; + export class c1 { + p1: number; + } + export var instance1: c1; + export function f1(): c1; + export var a2: typeof m1.m1_c1; +} diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathModuleSimpleSpecifyOutputFile/node/bin/test.d.ts b/tests/baselines/reference/project/sourceRootAbsolutePathModuleSimpleSpecifyOutputFile/node/bin/test.d.ts index e69de29bb2d..df062274b3e 100644 --- a/tests/baselines/reference/project/sourceRootAbsolutePathModuleSimpleSpecifyOutputFile/node/bin/test.d.ts +++ b/tests/baselines/reference/project/sourceRootAbsolutePathModuleSimpleSpecifyOutputFile/node/bin/test.d.ts @@ -0,0 +1,18 @@ +declare module "m1" { + export var m1_a1: number; + export class m1_c1 { + m1_c1_p1: number; + } + export var m1_instance1: m1_c1; + export function m1_f1(): m1_c1; +} +declare module "test" { + import m1 = require("m1"); + export var a1: number; + export class c1 { + p1: number; + } + export var instance1: c1; + export function f1(): c1; + export var a2: typeof m1.m1_c1; +} diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathModuleSubfolderSpecifyOutputFile/amd/bin/test.d.ts b/tests/baselines/reference/project/sourceRootAbsolutePathModuleSubfolderSpecifyOutputFile/amd/bin/test.d.ts index e69de29bb2d..18eee0fd4df 100644 --- a/tests/baselines/reference/project/sourceRootAbsolutePathModuleSubfolderSpecifyOutputFile/amd/bin/test.d.ts +++ b/tests/baselines/reference/project/sourceRootAbsolutePathModuleSubfolderSpecifyOutputFile/amd/bin/test.d.ts @@ -0,0 +1,18 @@ +declare module "ref/m1" { + export var m1_a1: number; + export class m1_c1 { + m1_c1_p1: number; + } + export var m1_instance1: m1_c1; + export function m1_f1(): m1_c1; +} +declare module "test" { + import m1 = require("ref/m1"); + export var a1: number; + export class c1 { + p1: number; + } + export var instance1: c1; + export function f1(): c1; + export var a2: typeof m1.m1_c1; +} diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathModuleSubfolderSpecifyOutputFile/node/bin/test.d.ts b/tests/baselines/reference/project/sourceRootAbsolutePathModuleSubfolderSpecifyOutputFile/node/bin/test.d.ts index e69de29bb2d..18eee0fd4df 100644 --- a/tests/baselines/reference/project/sourceRootAbsolutePathModuleSubfolderSpecifyOutputFile/node/bin/test.d.ts +++ b/tests/baselines/reference/project/sourceRootAbsolutePathModuleSubfolderSpecifyOutputFile/node/bin/test.d.ts @@ -0,0 +1,18 @@ +declare module "ref/m1" { + export var m1_a1: number; + export class m1_c1 { + m1_c1_p1: number; + } + export var m1_instance1: m1_c1; + export function m1_f1(): m1_c1; +} +declare module "test" { + import m1 = require("ref/m1"); + export var a1: number; + export class c1 { + p1: number; + } + export var instance1: c1; + export function f1(): c1; + export var a2: typeof m1.m1_c1; +} diff --git a/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFile/amd/bin/test.d.ts b/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFile/amd/bin/test.d.ts index d61b4c3b876..bc9ccf61daf 100644 --- a/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFile/amd/bin/test.d.ts +++ b/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFile/amd/bin/test.d.ts @@ -5,6 +5,14 @@ declare class m1_c1 { } declare var m1_instance1: m1_c1; declare function m1_f1(): m1_c1; +declare module "ref/m2" { + export var m2_a1: number; + export class m2_c1 { + m2_c1_p1: number; + } + export var m2_instance1: m2_c1; + export function m2_f1(): m2_c1; +} declare var a1: number; declare class c1 { p1: number; diff --git a/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFile/node/bin/test.d.ts b/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFile/node/bin/test.d.ts index d61b4c3b876..bc9ccf61daf 100644 --- a/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFile/node/bin/test.d.ts +++ b/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFile/node/bin/test.d.ts @@ -5,6 +5,14 @@ declare class m1_c1 { } declare var m1_instance1: m1_c1; declare function m1_f1(): m1_c1; +declare module "ref/m2" { + export var m2_a1: number; + export class m2_c1 { + m2_c1_p1: number; + } + export var m2_instance1: m2_c1; + export function m2_f1(): m2_c1; +} declare var a1: number; declare class c1 { p1: number; diff --git a/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.d.ts b/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.d.ts index 9b9cdd4a214..375869ffc94 100644 --- a/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.d.ts +++ b/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.d.ts @@ -5,6 +5,14 @@ declare class m1_c1 { } declare var m1_instance1: m1_c1; declare function m1_f1(): m1_c1; +declare module "ref/m2" { + export var m2_a1: number; + export class m2_c1 { + m2_c1_p1: number; + } + export var m2_instance1: m2_c1; + export function m2_f1(): m2_c1; +} declare var a1: number; declare class c1 { p1: number; diff --git a/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.d.ts b/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.d.ts index 9b9cdd4a214..375869ffc94 100644 --- a/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.d.ts +++ b/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.d.ts @@ -5,6 +5,14 @@ declare class m1_c1 { } declare var m1_instance1: m1_c1; declare function m1_f1(): m1_c1; +declare module "ref/m2" { + export var m2_a1: number; + export class m2_c1 { + m2_c1_p1: number; + } + export var m2_instance1: m2_c1; + export function m2_f1(): m2_c1; +} declare var a1: number; declare class c1 { p1: number; diff --git a/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderSpecifyOutputFile/amd/bin/test.d.ts b/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderSpecifyOutputFile/amd/bin/test.d.ts index e69de29bb2d..9b6af66589a 100644 --- a/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderSpecifyOutputFile/amd/bin/test.d.ts +++ b/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderSpecifyOutputFile/amd/bin/test.d.ts @@ -0,0 +1,28 @@ +declare module "ref/m1" { + export var m1_a1: number; + export class m1_c1 { + m1_c1_p1: number; + } + export var m1_instance1: m1_c1; + export function m1_f1(): m1_c1; +} +declare module "../outputdir_module_multifolder_ref/m2" { + export var m2_a1: number; + export class m2_c1 { + m2_c1_p1: number; + } + export var m2_instance1: m2_c1; + export function m2_f1(): m2_c1; +} +declare module "test" { + import m1 = require("ref/m1"); + import m2 = require("../outputdir_module_multifolder_ref/m2"); + export var a1: number; + export class c1 { + p1: number; + } + export var instance1: c1; + export function f1(): c1; + export var a2: typeof m1.m1_c1; + export var a3: typeof m2.m2_c1; +} diff --git a/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderSpecifyOutputFile/node/bin/test.d.ts b/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderSpecifyOutputFile/node/bin/test.d.ts index e69de29bb2d..9b6af66589a 100644 --- a/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderSpecifyOutputFile/node/bin/test.d.ts +++ b/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderSpecifyOutputFile/node/bin/test.d.ts @@ -0,0 +1,28 @@ +declare module "ref/m1" { + export var m1_a1: number; + export class m1_c1 { + m1_c1_p1: number; + } + export var m1_instance1: m1_c1; + export function m1_f1(): m1_c1; +} +declare module "../outputdir_module_multifolder_ref/m2" { + export var m2_a1: number; + export class m2_c1 { + m2_c1_p1: number; + } + export var m2_instance1: m2_c1; + export function m2_f1(): m2_c1; +} +declare module "test" { + import m1 = require("ref/m1"); + import m2 = require("../outputdir_module_multifolder_ref/m2"); + export var a1: number; + export class c1 { + p1: number; + } + export var instance1: c1; + export function f1(): c1; + export var a2: typeof m1.m1_c1; + export var a3: typeof m2.m2_c1; +} diff --git a/tests/baselines/reference/project/sourceRootRelativePathModuleSimpleSpecifyOutputFile/amd/bin/test.d.ts b/tests/baselines/reference/project/sourceRootRelativePathModuleSimpleSpecifyOutputFile/amd/bin/test.d.ts index e69de29bb2d..df062274b3e 100644 --- a/tests/baselines/reference/project/sourceRootRelativePathModuleSimpleSpecifyOutputFile/amd/bin/test.d.ts +++ b/tests/baselines/reference/project/sourceRootRelativePathModuleSimpleSpecifyOutputFile/amd/bin/test.d.ts @@ -0,0 +1,18 @@ +declare module "m1" { + export var m1_a1: number; + export class m1_c1 { + m1_c1_p1: number; + } + export var m1_instance1: m1_c1; + export function m1_f1(): m1_c1; +} +declare module "test" { + import m1 = require("m1"); + export var a1: number; + export class c1 { + p1: number; + } + export var instance1: c1; + export function f1(): c1; + export var a2: typeof m1.m1_c1; +} diff --git a/tests/baselines/reference/project/sourceRootRelativePathModuleSimpleSpecifyOutputFile/node/bin/test.d.ts b/tests/baselines/reference/project/sourceRootRelativePathModuleSimpleSpecifyOutputFile/node/bin/test.d.ts index e69de29bb2d..df062274b3e 100644 --- a/tests/baselines/reference/project/sourceRootRelativePathModuleSimpleSpecifyOutputFile/node/bin/test.d.ts +++ b/tests/baselines/reference/project/sourceRootRelativePathModuleSimpleSpecifyOutputFile/node/bin/test.d.ts @@ -0,0 +1,18 @@ +declare module "m1" { + export var m1_a1: number; + export class m1_c1 { + m1_c1_p1: number; + } + export var m1_instance1: m1_c1; + export function m1_f1(): m1_c1; +} +declare module "test" { + import m1 = require("m1"); + export var a1: number; + export class c1 { + p1: number; + } + export var instance1: c1; + export function f1(): c1; + export var a2: typeof m1.m1_c1; +} diff --git a/tests/baselines/reference/project/sourceRootRelativePathModuleSubfolderSpecifyOutputFile/amd/bin/test.d.ts b/tests/baselines/reference/project/sourceRootRelativePathModuleSubfolderSpecifyOutputFile/amd/bin/test.d.ts index e69de29bb2d..18eee0fd4df 100644 --- a/tests/baselines/reference/project/sourceRootRelativePathModuleSubfolderSpecifyOutputFile/amd/bin/test.d.ts +++ b/tests/baselines/reference/project/sourceRootRelativePathModuleSubfolderSpecifyOutputFile/amd/bin/test.d.ts @@ -0,0 +1,18 @@ +declare module "ref/m1" { + export var m1_a1: number; + export class m1_c1 { + m1_c1_p1: number; + } + export var m1_instance1: m1_c1; + export function m1_f1(): m1_c1; +} +declare module "test" { + import m1 = require("ref/m1"); + export var a1: number; + export class c1 { + p1: number; + } + export var instance1: c1; + export function f1(): c1; + export var a2: typeof m1.m1_c1; +} diff --git a/tests/baselines/reference/project/sourceRootRelativePathModuleSubfolderSpecifyOutputFile/node/bin/test.d.ts b/tests/baselines/reference/project/sourceRootRelativePathModuleSubfolderSpecifyOutputFile/node/bin/test.d.ts index e69de29bb2d..18eee0fd4df 100644 --- a/tests/baselines/reference/project/sourceRootRelativePathModuleSubfolderSpecifyOutputFile/node/bin/test.d.ts +++ b/tests/baselines/reference/project/sourceRootRelativePathModuleSubfolderSpecifyOutputFile/node/bin/test.d.ts @@ -0,0 +1,18 @@ +declare module "ref/m1" { + export var m1_a1: number; + export class m1_c1 { + m1_c1_p1: number; + } + export var m1_instance1: m1_c1; + export function m1_f1(): m1_c1; +} +declare module "test" { + import m1 = require("ref/m1"); + export var a1: number; + export class c1 { + p1: number; + } + export var instance1: c1; + export function f1(): c1; + export var a2: typeof m1.m1_c1; +} diff --git a/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFile/amd/bin/test.d.ts b/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFile/amd/bin/test.d.ts index d61b4c3b876..bc9ccf61daf 100644 --- a/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFile/amd/bin/test.d.ts +++ b/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFile/amd/bin/test.d.ts @@ -5,6 +5,14 @@ declare class m1_c1 { } declare var m1_instance1: m1_c1; declare function m1_f1(): m1_c1; +declare module "ref/m2" { + export var m2_a1: number; + export class m2_c1 { + m2_c1_p1: number; + } + export var m2_instance1: m2_c1; + export function m2_f1(): m2_c1; +} declare var a1: number; declare class c1 { p1: number; diff --git a/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFile/node/bin/test.d.ts b/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFile/node/bin/test.d.ts index d61b4c3b876..bc9ccf61daf 100644 --- a/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFile/node/bin/test.d.ts +++ b/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFile/node/bin/test.d.ts @@ -5,6 +5,14 @@ declare class m1_c1 { } declare var m1_instance1: m1_c1; declare function m1_f1(): m1_c1; +declare module "ref/m2" { + export var m2_a1: number; + export class m2_c1 { + m2_c1_p1: number; + } + export var m2_instance1: m2_c1; + export function m2_f1(): m2_c1; +} declare var a1: number; declare class c1 { p1: number; diff --git a/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.d.ts b/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.d.ts index 9b9cdd4a214..375869ffc94 100644 --- a/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.d.ts +++ b/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.d.ts @@ -5,6 +5,14 @@ declare class m1_c1 { } declare var m1_instance1: m1_c1; declare function m1_f1(): m1_c1; +declare module "ref/m2" { + export var m2_a1: number; + export class m2_c1 { + m2_c1_p1: number; + } + export var m2_instance1: m2_c1; + export function m2_f1(): m2_c1; +} declare var a1: number; declare class c1 { p1: number; diff --git a/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.d.ts b/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.d.ts index 9b9cdd4a214..375869ffc94 100644 --- a/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.d.ts +++ b/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.d.ts @@ -5,6 +5,14 @@ declare class m1_c1 { } declare var m1_instance1: m1_c1; declare function m1_f1(): m1_c1; +declare module "ref/m2" { + export var m2_a1: number; + export class m2_c1 { + m2_c1_p1: number; + } + export var m2_instance1: m2_c1; + export function m2_f1(): m2_c1; +} declare var a1: number; declare class c1 { p1: number; diff --git a/tests/baselines/reference/project/sourcemapModuleMultifolderSpecifyOutputFile/amd/bin/test.d.ts b/tests/baselines/reference/project/sourcemapModuleMultifolderSpecifyOutputFile/amd/bin/test.d.ts index e69de29bb2d..9b6af66589a 100644 --- a/tests/baselines/reference/project/sourcemapModuleMultifolderSpecifyOutputFile/amd/bin/test.d.ts +++ b/tests/baselines/reference/project/sourcemapModuleMultifolderSpecifyOutputFile/amd/bin/test.d.ts @@ -0,0 +1,28 @@ +declare module "ref/m1" { + export var m1_a1: number; + export class m1_c1 { + m1_c1_p1: number; + } + export var m1_instance1: m1_c1; + export function m1_f1(): m1_c1; +} +declare module "../outputdir_module_multifolder_ref/m2" { + export var m2_a1: number; + export class m2_c1 { + m2_c1_p1: number; + } + export var m2_instance1: m2_c1; + export function m2_f1(): m2_c1; +} +declare module "test" { + import m1 = require("ref/m1"); + import m2 = require("../outputdir_module_multifolder_ref/m2"); + export var a1: number; + export class c1 { + p1: number; + } + export var instance1: c1; + export function f1(): c1; + export var a2: typeof m1.m1_c1; + export var a3: typeof m2.m2_c1; +} diff --git a/tests/baselines/reference/project/sourcemapModuleMultifolderSpecifyOutputFile/node/bin/test.d.ts b/tests/baselines/reference/project/sourcemapModuleMultifolderSpecifyOutputFile/node/bin/test.d.ts index e69de29bb2d..9b6af66589a 100644 --- a/tests/baselines/reference/project/sourcemapModuleMultifolderSpecifyOutputFile/node/bin/test.d.ts +++ b/tests/baselines/reference/project/sourcemapModuleMultifolderSpecifyOutputFile/node/bin/test.d.ts @@ -0,0 +1,28 @@ +declare module "ref/m1" { + export var m1_a1: number; + export class m1_c1 { + m1_c1_p1: number; + } + export var m1_instance1: m1_c1; + export function m1_f1(): m1_c1; +} +declare module "../outputdir_module_multifolder_ref/m2" { + export var m2_a1: number; + export class m2_c1 { + m2_c1_p1: number; + } + export var m2_instance1: m2_c1; + export function m2_f1(): m2_c1; +} +declare module "test" { + import m1 = require("ref/m1"); + import m2 = require("../outputdir_module_multifolder_ref/m2"); + export var a1: number; + export class c1 { + p1: number; + } + export var instance1: c1; + export function f1(): c1; + export var a2: typeof m1.m1_c1; + export var a3: typeof m2.m2_c1; +} diff --git a/tests/baselines/reference/project/sourcemapModuleSimpleSpecifyOutputFile/amd/bin/test.d.ts b/tests/baselines/reference/project/sourcemapModuleSimpleSpecifyOutputFile/amd/bin/test.d.ts index e69de29bb2d..df062274b3e 100644 --- a/tests/baselines/reference/project/sourcemapModuleSimpleSpecifyOutputFile/amd/bin/test.d.ts +++ b/tests/baselines/reference/project/sourcemapModuleSimpleSpecifyOutputFile/amd/bin/test.d.ts @@ -0,0 +1,18 @@ +declare module "m1" { + export var m1_a1: number; + export class m1_c1 { + m1_c1_p1: number; + } + export var m1_instance1: m1_c1; + export function m1_f1(): m1_c1; +} +declare module "test" { + import m1 = require("m1"); + export var a1: number; + export class c1 { + p1: number; + } + export var instance1: c1; + export function f1(): c1; + export var a2: typeof m1.m1_c1; +} diff --git a/tests/baselines/reference/project/sourcemapModuleSimpleSpecifyOutputFile/node/bin/test.d.ts b/tests/baselines/reference/project/sourcemapModuleSimpleSpecifyOutputFile/node/bin/test.d.ts index e69de29bb2d..df062274b3e 100644 --- a/tests/baselines/reference/project/sourcemapModuleSimpleSpecifyOutputFile/node/bin/test.d.ts +++ b/tests/baselines/reference/project/sourcemapModuleSimpleSpecifyOutputFile/node/bin/test.d.ts @@ -0,0 +1,18 @@ +declare module "m1" { + export var m1_a1: number; + export class m1_c1 { + m1_c1_p1: number; + } + export var m1_instance1: m1_c1; + export function m1_f1(): m1_c1; +} +declare module "test" { + import m1 = require("m1"); + export var a1: number; + export class c1 { + p1: number; + } + export var instance1: c1; + export function f1(): c1; + export var a2: typeof m1.m1_c1; +} diff --git a/tests/baselines/reference/project/sourcemapModuleSubfolderSpecifyOutputFile/amd/bin/test.d.ts b/tests/baselines/reference/project/sourcemapModuleSubfolderSpecifyOutputFile/amd/bin/test.d.ts index e69de29bb2d..18eee0fd4df 100644 --- a/tests/baselines/reference/project/sourcemapModuleSubfolderSpecifyOutputFile/amd/bin/test.d.ts +++ b/tests/baselines/reference/project/sourcemapModuleSubfolderSpecifyOutputFile/amd/bin/test.d.ts @@ -0,0 +1,18 @@ +declare module "ref/m1" { + export var m1_a1: number; + export class m1_c1 { + m1_c1_p1: number; + } + export var m1_instance1: m1_c1; + export function m1_f1(): m1_c1; +} +declare module "test" { + import m1 = require("ref/m1"); + export var a1: number; + export class c1 { + p1: number; + } + export var instance1: c1; + export function f1(): c1; + export var a2: typeof m1.m1_c1; +} diff --git a/tests/baselines/reference/project/sourcemapModuleSubfolderSpecifyOutputFile/node/bin/test.d.ts b/tests/baselines/reference/project/sourcemapModuleSubfolderSpecifyOutputFile/node/bin/test.d.ts index e69de29bb2d..18eee0fd4df 100644 --- a/tests/baselines/reference/project/sourcemapModuleSubfolderSpecifyOutputFile/node/bin/test.d.ts +++ b/tests/baselines/reference/project/sourcemapModuleSubfolderSpecifyOutputFile/node/bin/test.d.ts @@ -0,0 +1,18 @@ +declare module "ref/m1" { + export var m1_a1: number; + export class m1_c1 { + m1_c1_p1: number; + } + export var m1_instance1: m1_c1; + export function m1_f1(): m1_c1; +} +declare module "test" { + import m1 = require("ref/m1"); + export var a1: number; + export class c1 { + p1: number; + } + export var instance1: c1; + export function f1(): c1; + export var a2: typeof m1.m1_c1; +} diff --git a/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFile/amd/bin/test.d.ts b/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFile/amd/bin/test.d.ts index d61b4c3b876..bc9ccf61daf 100644 --- a/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFile/amd/bin/test.d.ts +++ b/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFile/amd/bin/test.d.ts @@ -5,6 +5,14 @@ declare class m1_c1 { } declare var m1_instance1: m1_c1; declare function m1_f1(): m1_c1; +declare module "ref/m2" { + export var m2_a1: number; + export class m2_c1 { + m2_c1_p1: number; + } + export var m2_instance1: m2_c1; + export function m2_f1(): m2_c1; +} declare var a1: number; declare class c1 { p1: number; diff --git a/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFile/node/bin/test.d.ts b/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFile/node/bin/test.d.ts index d61b4c3b876..bc9ccf61daf 100644 --- a/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFile/node/bin/test.d.ts +++ b/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFile/node/bin/test.d.ts @@ -5,6 +5,14 @@ declare class m1_c1 { } declare var m1_instance1: m1_c1; declare function m1_f1(): m1_c1; +declare module "ref/m2" { + export var m2_a1: number; + export class m2_c1 { + m2_c1_p1: number; + } + export var m2_instance1: m2_c1; + export function m2_f1(): m2_c1; +} declare var a1: number; declare class c1 { p1: number; diff --git a/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.d.ts b/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.d.ts index 9b9cdd4a214..375869ffc94 100644 --- a/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.d.ts +++ b/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.d.ts @@ -5,6 +5,14 @@ declare class m1_c1 { } declare var m1_instance1: m1_c1; declare function m1_f1(): m1_c1; +declare module "ref/m2" { + export var m2_a1: number; + export class m2_c1 { + m2_c1_p1: number; + } + export var m2_instance1: m2_c1; + export function m2_f1(): m2_c1; +} declare var a1: number; declare class c1 { p1: number; diff --git a/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.d.ts b/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.d.ts index 9b9cdd4a214..375869ffc94 100644 --- a/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.d.ts +++ b/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.d.ts @@ -5,6 +5,14 @@ declare class m1_c1 { } declare var m1_instance1: m1_c1; declare function m1_f1(): m1_c1; +declare module "ref/m2" { + export var m2_a1: number; + export class m2_c1 { + m2_c1_p1: number; + } + export var m2_instance1: m2_c1; + export function m2_f1(): m2_c1; +} declare var a1: number; declare class c1 { p1: number; diff --git a/tests/baselines/reference/project/sourcerootUrlModuleMultifolderSpecifyOutputFile/amd/bin/test.d.ts b/tests/baselines/reference/project/sourcerootUrlModuleMultifolderSpecifyOutputFile/amd/bin/test.d.ts index e69de29bb2d..9b6af66589a 100644 --- a/tests/baselines/reference/project/sourcerootUrlModuleMultifolderSpecifyOutputFile/amd/bin/test.d.ts +++ b/tests/baselines/reference/project/sourcerootUrlModuleMultifolderSpecifyOutputFile/amd/bin/test.d.ts @@ -0,0 +1,28 @@ +declare module "ref/m1" { + export var m1_a1: number; + export class m1_c1 { + m1_c1_p1: number; + } + export var m1_instance1: m1_c1; + export function m1_f1(): m1_c1; +} +declare module "../outputdir_module_multifolder_ref/m2" { + export var m2_a1: number; + export class m2_c1 { + m2_c1_p1: number; + } + export var m2_instance1: m2_c1; + export function m2_f1(): m2_c1; +} +declare module "test" { + import m1 = require("ref/m1"); + import m2 = require("../outputdir_module_multifolder_ref/m2"); + export var a1: number; + export class c1 { + p1: number; + } + export var instance1: c1; + export function f1(): c1; + export var a2: typeof m1.m1_c1; + export var a3: typeof m2.m2_c1; +} diff --git a/tests/baselines/reference/project/sourcerootUrlModuleMultifolderSpecifyOutputFile/node/bin/test.d.ts b/tests/baselines/reference/project/sourcerootUrlModuleMultifolderSpecifyOutputFile/node/bin/test.d.ts index e69de29bb2d..9b6af66589a 100644 --- a/tests/baselines/reference/project/sourcerootUrlModuleMultifolderSpecifyOutputFile/node/bin/test.d.ts +++ b/tests/baselines/reference/project/sourcerootUrlModuleMultifolderSpecifyOutputFile/node/bin/test.d.ts @@ -0,0 +1,28 @@ +declare module "ref/m1" { + export var m1_a1: number; + export class m1_c1 { + m1_c1_p1: number; + } + export var m1_instance1: m1_c1; + export function m1_f1(): m1_c1; +} +declare module "../outputdir_module_multifolder_ref/m2" { + export var m2_a1: number; + export class m2_c1 { + m2_c1_p1: number; + } + export var m2_instance1: m2_c1; + export function m2_f1(): m2_c1; +} +declare module "test" { + import m1 = require("ref/m1"); + import m2 = require("../outputdir_module_multifolder_ref/m2"); + export var a1: number; + export class c1 { + p1: number; + } + export var instance1: c1; + export function f1(): c1; + export var a2: typeof m1.m1_c1; + export var a3: typeof m2.m2_c1; +} diff --git a/tests/baselines/reference/project/sourcerootUrlModuleSimpleSpecifyOutputFile/amd/bin/test.d.ts b/tests/baselines/reference/project/sourcerootUrlModuleSimpleSpecifyOutputFile/amd/bin/test.d.ts index e69de29bb2d..df062274b3e 100644 --- a/tests/baselines/reference/project/sourcerootUrlModuleSimpleSpecifyOutputFile/amd/bin/test.d.ts +++ b/tests/baselines/reference/project/sourcerootUrlModuleSimpleSpecifyOutputFile/amd/bin/test.d.ts @@ -0,0 +1,18 @@ +declare module "m1" { + export var m1_a1: number; + export class m1_c1 { + m1_c1_p1: number; + } + export var m1_instance1: m1_c1; + export function m1_f1(): m1_c1; +} +declare module "test" { + import m1 = require("m1"); + export var a1: number; + export class c1 { + p1: number; + } + export var instance1: c1; + export function f1(): c1; + export var a2: typeof m1.m1_c1; +} diff --git a/tests/baselines/reference/project/sourcerootUrlModuleSimpleSpecifyOutputFile/node/bin/test.d.ts b/tests/baselines/reference/project/sourcerootUrlModuleSimpleSpecifyOutputFile/node/bin/test.d.ts index e69de29bb2d..df062274b3e 100644 --- a/tests/baselines/reference/project/sourcerootUrlModuleSimpleSpecifyOutputFile/node/bin/test.d.ts +++ b/tests/baselines/reference/project/sourcerootUrlModuleSimpleSpecifyOutputFile/node/bin/test.d.ts @@ -0,0 +1,18 @@ +declare module "m1" { + export var m1_a1: number; + export class m1_c1 { + m1_c1_p1: number; + } + export var m1_instance1: m1_c1; + export function m1_f1(): m1_c1; +} +declare module "test" { + import m1 = require("m1"); + export var a1: number; + export class c1 { + p1: number; + } + export var instance1: c1; + export function f1(): c1; + export var a2: typeof m1.m1_c1; +} diff --git a/tests/baselines/reference/project/sourcerootUrlModuleSubfolderSpecifyOutputFile/amd/bin/test.d.ts b/tests/baselines/reference/project/sourcerootUrlModuleSubfolderSpecifyOutputFile/amd/bin/test.d.ts index e69de29bb2d..18eee0fd4df 100644 --- a/tests/baselines/reference/project/sourcerootUrlModuleSubfolderSpecifyOutputFile/amd/bin/test.d.ts +++ b/tests/baselines/reference/project/sourcerootUrlModuleSubfolderSpecifyOutputFile/amd/bin/test.d.ts @@ -0,0 +1,18 @@ +declare module "ref/m1" { + export var m1_a1: number; + export class m1_c1 { + m1_c1_p1: number; + } + export var m1_instance1: m1_c1; + export function m1_f1(): m1_c1; +} +declare module "test" { + import m1 = require("ref/m1"); + export var a1: number; + export class c1 { + p1: number; + } + export var instance1: c1; + export function f1(): c1; + export var a2: typeof m1.m1_c1; +} diff --git a/tests/baselines/reference/project/sourcerootUrlModuleSubfolderSpecifyOutputFile/node/bin/test.d.ts b/tests/baselines/reference/project/sourcerootUrlModuleSubfolderSpecifyOutputFile/node/bin/test.d.ts index e69de29bb2d..18eee0fd4df 100644 --- a/tests/baselines/reference/project/sourcerootUrlModuleSubfolderSpecifyOutputFile/node/bin/test.d.ts +++ b/tests/baselines/reference/project/sourcerootUrlModuleSubfolderSpecifyOutputFile/node/bin/test.d.ts @@ -0,0 +1,18 @@ +declare module "ref/m1" { + export var m1_a1: number; + export class m1_c1 { + m1_c1_p1: number; + } + export var m1_instance1: m1_c1; + export function m1_f1(): m1_c1; +} +declare module "test" { + import m1 = require("ref/m1"); + export var a1: number; + export class c1 { + p1: number; + } + export var instance1: c1; + export function f1(): c1; + export var a2: typeof m1.m1_c1; +} From 6c1f3effcbd7d18c4c55407100e9ee093dced763 Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Mon, 5 Oct 2015 14:14:00 -0700 Subject: [PATCH 046/227] m'lint --- src/compiler/declarationEmitter.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compiler/declarationEmitter.ts b/src/compiler/declarationEmitter.ts index 277a1bf169a..c3d611f131c 100644 --- a/src/compiler/declarationEmitter.ts +++ b/src/compiler/declarationEmitter.ts @@ -131,7 +131,7 @@ namespace ts { write(`declare module "${sourceFile.moduleName}" {`); writeLine(); increaseIndent(); - emitSourceFile(sourceFile) + emitSourceFile(sourceFile); decreaseIndent(); write("}"); writeLine(); From 732ec343fc0ad08c5615d9e496b9dd0549e2a65a Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Mon, 5 Oct 2015 14:25:48 -0700 Subject: [PATCH 047/227] update comment --- 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 0cdcddbb0ed..f8bb1e94da5 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -1063,7 +1063,7 @@ namespace ts { programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Cannot_compile_modules_into_es6_when_targeting_ES5_or_lower)); } - // Cannot specify module gen that isn't amd, umd, or system with --out + // Cannot specify module gen that isn't amd or system with --out if (outFile && options.module && options.module !== ModuleKind.AMD && options.module !== ModuleKind.System) { programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Only_amd_and_system_modules_are_supported_alongside_0, options.out ? "out" : "outFile")); } From ac5bed86b236da6d2746944819043cce54c9d9cc Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Fri, 18 Sep 2015 19:12:08 -0700 Subject: [PATCH 048/227] Added '--diagnosticStyle' compiler argument with options 'simple' and 'pretty'. --- src/compiler/commandLineParser.ts | 11 ++++++++ .../diagnosticInformationMap.generated.ts | 2 ++ src/compiler/diagnosticMessages.json | 9 ++++++ src/compiler/tsc.ts | 28 +++++++++++-------- src/compiler/types.ts | 6 ++++ 5 files changed, 45 insertions(+), 11 deletions(-) diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index 9a984b9a2f1..5d7c1bc1690 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -20,6 +20,17 @@ namespace ts { name: "diagnostics", type: "boolean", }, + { + name: "diagnosticStyle", + paramType: Diagnostics.KIND, + description: Diagnostics.Specify_diagnostic_printing_style_Colon_simple_default_or_pretty, + type: { + "simple": DiagnosticStyle.Simple, + "pretty": DiagnosticStyle.Pretty, + }, + error: Diagnostics.Argument_for_diagnosticStyle_must_be_simple_or_pretty, + experimental: true, + }, { name: "emitBOM", type: "boolean" diff --git a/src/compiler/diagnosticInformationMap.generated.ts b/src/compiler/diagnosticInformationMap.generated.ts index 5ccc0a0db9b..4fdb2221762 100644 --- a/src/compiler/diagnosticInformationMap.generated.ts +++ b/src/compiler/diagnosticInformationMap.generated.ts @@ -567,6 +567,8 @@ namespace ts { Specifies_the_end_of_line_sequence_to_be_used_when_emitting_files_Colon_CRLF_dos_or_LF_unix: { code: 6060, category: DiagnosticCategory.Message, key: "Specifies the end of line sequence to be used when emitting files: 'CRLF' (dos) or 'LF' (unix)." }, NEWLINE: { code: 6061, category: DiagnosticCategory.Message, key: "NEWLINE" }, Argument_for_newLine_option_must_be_CRLF_or_LF: { code: 6062, category: DiagnosticCategory.Error, key: "Argument for '--newLine' option must be 'CRLF' or 'LF'." }, + Specify_diagnostic_printing_style_Colon_simple_default_or_pretty: { code: 6063, category: DiagnosticCategory.Message, key: "Specify diagnostic printing style: 'simple' (default) or 'pretty'." }, + Argument_for_diagnosticStyle_must_be_simple_or_pretty: { code: 6064, category: DiagnosticCategory.Error, key: "Argument for '--diagnosticStyle' must be 'simple' or 'pretty'." }, Specify_JSX_code_generation_Colon_preserve_or_react: { code: 6080, category: DiagnosticCategory.Message, key: "Specify JSX code generation: 'preserve' or 'react'" }, Argument_for_jsx_must_be_preserve_or_react: { code: 6081, category: DiagnosticCategory.Message, key: "Argument for '--jsx' must be 'preserve' or 'react'." }, Option_experimentalDecorators_must_also_be_specified_when_option_emitDecoratorMetadata_is_specified: { code: 6064, category: DiagnosticCategory.Error, key: "Option 'experimentalDecorators' must also be specified when option 'emitDecoratorMetadata' is specified." }, diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index e138e2ddac4..4a7280f5fda 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -2258,6 +2258,15 @@ "category": "Error", "code": 6062 }, + "Specify diagnostic printing style: 'simple' (default) or 'pretty'.": { + "category": "Message", + "code": 6063 + }, + "Argument for '--diagnosticStyle' must be 'simple' or 'pretty'.": { + "category": "Error", + "code": 6064 + }, + "Specify JSX code generation: 'preserve' or 'react'": { "category": "Message", "code": 6080 diff --git a/src/compiler/tsc.ts b/src/compiler/tsc.ts index 10eddc41b7e..ae1a7cda220 100644 --- a/src/compiler/tsc.ts +++ b/src/compiler/tsc.ts @@ -6,9 +6,11 @@ namespace ts { fileWatcher?: FileWatcher; } - const reportDiagnostic = sys.writesToTty && sys.writesToTty() ? - reportDiagnosticWithColorAndContext : - reportDiagnosticSimply; + export interface CompilerOptions { + diagnosticStyle?: DiagnosticStyle; + } + + let reportDiagnostic = reportDiagnosticSimply; function reportDiagnostics(diagnostics: Diagnostic[]): void { for (let diagnostic of diagnostics) { @@ -221,7 +223,7 @@ namespace ts { if (commandLine.options.locale) { if (!isJSONSupported()) { - reportDiagnosticSimply(createCompilerDiagnostic(Diagnostics.The_current_host_does_not_support_the_0_option, "--locale")); + reportDiagnostic(createCompilerDiagnostic(Diagnostics.The_current_host_does_not_support_the_0_option, "--locale")); return sys.exit(ExitStatus.DiagnosticsPresent_OutputsSkipped); } validateLocaleAndSetLanguage(commandLine.options.locale, commandLine.errors); @@ -235,7 +237,7 @@ namespace ts { } if (commandLine.options.version) { - reportDiagnosticSimply(createCompilerDiagnostic(Diagnostics.Version_0, ts.version)); + reportDiagnostic(createCompilerDiagnostic(Diagnostics.Version_0, ts.version)); return sys.exit(ExitStatus.Success); } @@ -247,12 +249,12 @@ namespace ts { if (commandLine.options.project) { if (!isJSONSupported()) { - reportDiagnosticSimply(createCompilerDiagnostic(Diagnostics.The_current_host_does_not_support_the_0_option, "--project")); + reportDiagnostic(createCompilerDiagnostic(Diagnostics.The_current_host_does_not_support_the_0_option, "--project")); return sys.exit(ExitStatus.DiagnosticsPresent_OutputsSkipped); } configFileName = normalizePath(combinePaths(commandLine.options.project, "tsconfig.json")); if (commandLine.fileNames.length !== 0) { - reportDiagnosticSimply(createCompilerDiagnostic(Diagnostics.Option_project_cannot_be_mixed_with_source_files_on_a_command_line)); + reportDiagnostic(createCompilerDiagnostic(Diagnostics.Option_project_cannot_be_mixed_with_source_files_on_a_command_line)); return sys.exit(ExitStatus.DiagnosticsPresent_OutputsSkipped); } } @@ -270,7 +272,7 @@ namespace ts { // Firefox has Object.prototype.watch if (commandLine.options.watch && commandLine.options.hasOwnProperty("watch")) { if (!sys.watchFile) { - reportDiagnosticSimply(createCompilerDiagnostic(Diagnostics.The_current_host_does_not_support_the_0_option, "--watch")); + reportDiagnostic(createCompilerDiagnostic(Diagnostics.The_current_host_does_not_support_the_0_option, "--watch")); return sys.exit(ExitStatus.DiagnosticsPresent_OutputsSkipped); } if (configFileName) { @@ -288,7 +290,7 @@ namespace ts { let result = readConfigFile(configFileName); if (result.error) { - reportDiagnosticSimply(result.error); + reportDiagnostic(result.error); return sys.exit(ExitStatus.DiagnosticsPresent_OutputsSkipped); } @@ -310,6 +312,10 @@ namespace ts { compilerHost.getSourceFile = getSourceFile; } + if (compilerOptions.diagnosticStyle === DiagnosticStyle.Pretty) { + reportDiagnostic = reportDiagnosticWithColorAndContext; + } + let compileResult = compile(rootFileNames, compilerOptions, compilerHost); if (!compilerOptions.watch) { @@ -317,7 +323,7 @@ namespace ts { } setCachedProgram(compileResult.program); - reportDiagnosticSimply(createCompilerDiagnostic(Diagnostics.Compilation_complete_Watching_for_file_changes)); + reportDiagnostic(createCompilerDiagnostic(Diagnostics.Compilation_complete_Watching_for_file_changes)); } function getSourceFile(fileName: string, languageVersion: ScriptTarget, onError?: (message: string) => void) { @@ -379,7 +385,7 @@ namespace ts { function recompile() { timerHandle = undefined; - reportDiagnosticSimply(createCompilerDiagnostic(Diagnostics.File_change_detected_Starting_incremental_compilation)); + reportDiagnostic(createCompilerDiagnostic(Diagnostics.File_change_detected_Starting_incremental_compilation)); performCompilation(); } } diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 1338d19e1a7..01a791237ad 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -2094,6 +2094,12 @@ namespace ts { JSX } + /* @internal */ + export const enum DiagnosticStyle { + Simple, + Pretty, + } + export interface ParsedCommandLine { options: CompilerOptions; fileNames: string[]; From 2b4febee1c9eddaa8497a8dcfce0aedc49469db5 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Mon, 5 Oct 2015 23:10:04 -0700 Subject: [PATCH 049/227] Moved JSX diagnostics to a more sensical spot. --- src/compiler/diagnosticMessages.json | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 03d890bffa1..88805447985 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -2258,14 +2258,6 @@ "code": 6063 }, - "Specify JSX code generation: 'preserve' or 'react'": { - "category": "Message", - "code": 6080 - }, - "Argument for '--jsx' must be 'preserve' or 'react'.": { - "category": "Message", - "code": 6081 - }, "Enables experimental support for ES7 decorators.": { "category": "Message", "code": 6065 @@ -2307,6 +2299,15 @@ "code": 6074 }, + "Specify JSX code generation: 'preserve' or 'react'": { + "category": "Message", + "code": 6080 + }, + "Argument for '--jsx' must be 'preserve' or 'react'.": { + "category": "Message", + "code": 6081 + }, + "Variable '{0}' implicitly has an '{1}' type.": { "category": "Error", "code": 7005 From c3e00a24f3fccd5dfd126703fa3dbeb95e3261c9 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Mon, 5 Oct 2015 23:37:50 -0700 Subject: [PATCH 050/227] Only use colors if we are certain we are using a pseudoterminal. --- src/compiler/sys.ts | 2 +- src/compiler/tsc.ts | 19 +++++++++++-------- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/compiler/sys.ts b/src/compiler/sys.ts index c50291e60b8..fdf6d075cbf 100644 --- a/src/compiler/sys.ts +++ b/src/compiler/sys.ts @@ -272,7 +272,7 @@ namespace ts { args: process.argv.slice(2), newLine: _os.EOL, useCaseSensitiveFileNames: useCaseSensitiveFileNames, - write(s: string): void { + write(s: string): void { process.stdout.write(s); }, writesToTty: () => _tty.isatty(1), diff --git a/src/compiler/tsc.ts b/src/compiler/tsc.ts index 5222ca2fccf..d849425a885 100644 --- a/src/compiler/tsc.ts +++ b/src/compiler/tsc.ts @@ -108,9 +108,11 @@ namespace ts { sys.write(output); } - const redForegroundEscapeSequence = "\u001b[91m"; - const gutterStyleSequence = "\u001b[100;30m"; - const resetEscapeSequence = "\u001b[0m"; + const shouldUseColors = sys.writesToTty && sys.writesToTty(); + const redForegroundEscapeSequence = shouldUseColors ? "\u001b[91m" : ""; + const gutterStyleSequence = shouldUseColors ? "\u001b[100;30m" : ""; + const gutterSeparator = shouldUseColors ? " " : " | " + const resetEscapeSequence = shouldUseColors ? "\u001b[0m" : ""; function reportDiagnosticWithColorAndContext(diagnostic: Diagnostic): void { let output = ""; @@ -132,7 +134,7 @@ namespace ts { // If the error spans over 5 lines, we'll only show the first 2 and last 2 lines, // so we'll skip ahead to the second-to-last line. if (hasMoreThanFiveLines && firstLine + 1 < i && i < lastLine - 1) { - output += gutterStyleSequence + padLeft("...", gutterWidth) + resetEscapeSequence + " " + sys.newLine; + output += gutterStyleSequence + padLeft("...", gutterWidth) + resetEscapeSequence + gutterSeparator + sys.newLine; i = lastLine - 1; } @@ -142,11 +144,12 @@ namespace ts { lineContent = lineContent.replace(/\s+$/g, ""); // trim from end lineContent = lineContent.replace("\t", " "); // convert tabs to single spaces - // Output the actual contents of the line. - output += gutterStyleSequence + padLeft(i + 1 + "", gutterWidth) + resetEscapeSequence + " " + lineContent + sys.newLine; + // Output the gutter and the actual contents of the line. + output += gutterStyleSequence + padLeft(i + 1 + "", gutterWidth) + resetEscapeSequence + gutterSeparator; + output += lineContent + sys.newLine; - // Output the error span for the line using tildes. - output += gutterStyleSequence + padLeft("", gutterWidth) + resetEscapeSequence + " "; + // Output the gutter and the error span for the line using tildes. + output += gutterStyleSequence + padLeft("", gutterWidth) + resetEscapeSequence + gutterSeparator; output += redForegroundEscapeSequence; if (i === firstLine) { // If we're on the last line, then limit it to the last character of the last line. From 5c5fca64f03eff1eb9d1519d2181b5ddda429057 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Mon, 5 Oct 2015 23:41:44 -0700 Subject: [PATCH 051/227] Just make the compiler option internal. --- src/compiler/tsc.ts | 10 +++------- src/compiler/types.ts | 1 + 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/src/compiler/tsc.ts b/src/compiler/tsc.ts index d849425a885..b58f59e8a43 100644 --- a/src/compiler/tsc.ts +++ b/src/compiler/tsc.ts @@ -6,10 +6,6 @@ namespace ts { fileWatcher?: FileWatcher; } - export interface CompilerOptions { - diagnosticStyle?: DiagnosticStyle; - } - let reportDiagnostic = reportDiagnosticSimply; function reportDiagnostics(diagnostics: Diagnostic[]): void { @@ -95,7 +91,7 @@ namespace ts { function reportDiagnosticSimply(diagnostic: Diagnostic): void { let output = ""; - + if (diagnostic.file) { let { line, character } = getLineAndCharacterOfPosition(diagnostic.file, diagnostic.start); @@ -111,7 +107,7 @@ namespace ts { const shouldUseColors = sys.writesToTty && sys.writesToTty(); const redForegroundEscapeSequence = shouldUseColors ? "\u001b[91m" : ""; const gutterStyleSequence = shouldUseColors ? "\u001b[100;30m" : ""; - const gutterSeparator = shouldUseColors ? " " : " | " + const gutterSeparator = shouldUseColors ? " " : " | "; const resetEscapeSequence = shouldUseColors ? "\u001b[0m" : ""; function reportDiagnosticWithColorAndContext(diagnostic: Diagnostic): void { @@ -147,7 +143,7 @@ namespace ts { // Output the gutter and the actual contents of the line. output += gutterStyleSequence + padLeft(i + 1 + "", gutterWidth) + resetEscapeSequence + gutterSeparator; output += lineContent + sys.newLine; - + // Output the gutter and the error span for the line using tildes. output += gutterStyleSequence + padLeft("", gutterWidth) + resetEscapeSequence + gutterSeparator; output += redForegroundEscapeSequence; diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 48a31c417b7..d271f0d47ab 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -2043,6 +2043,7 @@ namespace ts { charset?: string; declaration?: boolean; diagnostics?: boolean; + /* @internal */diagnosticStyle?: DiagnosticStyle; emitBOM?: boolean; help?: boolean; init?: boolean; From 5bcd8b3afae3882feb35fa9257b720f266f770f5 Mon Sep 17 00:00:00 2001 From: Tingan Ho Date: Tue, 6 Oct 2015 19:03:01 +0800 Subject: [PATCH 052/227] Fixes instance of type exclusion in else clause --- 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 40db300d310..3dc9ee68d14 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -6362,9 +6362,10 @@ namespace ts { function narrowTypeByInstanceof(type: Type, expr: BinaryExpression, assumeTrue: boolean): Type { // Check that type is not any, assumed result is true, and we have variable symbol on the left - if (isTypeAny(type) || !assumeTrue || expr.left.kind !== SyntaxKind.Identifier || getResolvedSymbol(expr.left) !== symbol) { + if (isTypeAny(type) || expr.left.kind !== SyntaxKind.Identifier || getResolvedSymbol(expr.left) !== symbol) { return type; } + // Check that right operand is a function type with a prototype property let rightType = checkExpression(expr.right); if (!isTypeSubtypeOf(rightType, globalFunctionType)) { @@ -6396,6 +6397,13 @@ namespace ts { } if (targetType) { + if (!assumeTrue) { + if (type.flags & TypeFlags.Union) { + return getUnionType(filter((type).types, t => !isTypeSubtypeOf(t, targetType))); + } + return type; + } + return getNarrowedType(type, targetType); } From dd54b7a36f15da93748282eab3298071943f2969 Mon Sep 17 00:00:00 2001 From: Tingan Ho Date: Tue, 6 Oct 2015 19:03:11 +0800 Subject: [PATCH 053/227] Adds tests --- .../reference/narrowTypeByInstanceof.types | 2 +- .../reference/typeGuardOfFormInstanceOf.js | 112 +++++++-- .../typeGuardOfFormInstanceOf.symbols | 190 +++++++++++---- .../reference/typeGuardOfFormInstanceOf.types | 221 +++++++++++++----- .../typeGuards/typeGuardOfFormInstanceOf.ts | 57 ++++- 5 files changed, 447 insertions(+), 135 deletions(-) diff --git a/tests/baselines/reference/narrowTypeByInstanceof.types b/tests/baselines/reference/narrowTypeByInstanceof.types index e6a3466b88f..8bc13d12ca1 100644 --- a/tests/baselines/reference/narrowTypeByInstanceof.types +++ b/tests/baselines/reference/narrowTypeByInstanceof.types @@ -63,7 +63,7 @@ if (elementA instanceof FileMatch && elementB instanceof FileMatch) { } else if (elementA instanceof Match && elementB instanceof Match) { >elementA instanceof Match && elementB instanceof Match : boolean >elementA instanceof Match : boolean ->elementA : FileMatch | Match +>elementA : Match | FileMatch >Match : typeof Match >elementB instanceof Match : boolean >elementB : FileMatch | Match diff --git a/tests/baselines/reference/typeGuardOfFormInstanceOf.js b/tests/baselines/reference/typeGuardOfFormInstanceOf.js index cab04365c19..1431b4b9c60 100644 --- a/tests/baselines/reference/typeGuardOfFormInstanceOf.js +++ b/tests/baselines/reference/typeGuardOfFormInstanceOf.js @@ -14,21 +14,58 @@ class C2 { class D1 extends C1 { p3: number; } +class C3 { + p4: number; +} var str: string; var num: number; var strOrNum: string | number; -var c1Orc2: C1 | C2; -str = c1Orc2 instanceof C1 && c1Orc2.p1; // C1 -num = c1Orc2 instanceof C2 && c1Orc2.p2; // C2 -str = c1Orc2 instanceof D1 && c1Orc2.p1; // D1 -num = c1Orc2 instanceof D1 && c1Orc2.p3; // D1 +var ctor1: C1 | C2; +str = ctor1 instanceof C1 && ctor1.p1; // C1 +num = ctor1 instanceof C2 && ctor1.p2; // C2 +str = ctor1 instanceof D1 && ctor1.p1; // D1 +num = ctor1 instanceof D1 && ctor1.p3; // D1 -var c2Ord1: C2 | D1; -num = c2Ord1 instanceof C2 && c2Ord1.p2; // C2 -num = c2Ord1 instanceof D1 && c2Ord1.p3; // D1 -str = c2Ord1 instanceof D1 && c2Ord1.p1; // D1 -var r2: D1 | C2 = c2Ord1 instanceof C1 && c2Ord1; // C2 | D1 +var ctor2: C2 | D1; +num = ctor2 instanceof C2 && ctor2.p2; // C2 +num = ctor2 instanceof D1 && ctor2.p3; // D1 +str = ctor2 instanceof D1 && ctor2.p1; // D1 +var r2: D1 | C2 = ctor2 instanceof C1 && ctor2; // C2 | D1 + +var ctor3: C1 | C2; +if (ctor3 instanceof C1) { + ctor3.p1; // C1 +} +else { + ctor3.p2; // C2 +} + +var ctor4: C1 | C2 | C3; +if (ctor4 instanceof C1) { + ctor4.p1; // C1 +} +else if (ctor4 instanceof C2) { + ctor4.p2; // C2 +} +else { + ctor4.p4; // C3 +} + +var ctor5: C1 | D1 | C2; +if (ctor5 instanceof C1) { + ctor5.p1; // C1 +} +else { + ctor5.p2; // C2 +} + +var ctor6: C1 | C2 | C3; +if (ctor6 instanceof C1 || ctor6 instanceof C2) { +} +else { + ctor6.p4; // C3 +} //// [typeGuardOfFormInstanceOf.js] // A type guard of the form x instanceof C, where C is of a subtype of the global type 'Function' @@ -58,16 +95,51 @@ var D1 = (function (_super) { } return D1; })(C1); +var C3 = (function () { + function C3() { + } + return C3; +})(); var str; var num; var strOrNum; -var c1Orc2; -str = c1Orc2 instanceof C1 && c1Orc2.p1; // C1 -num = c1Orc2 instanceof C2 && c1Orc2.p2; // C2 -str = c1Orc2 instanceof D1 && c1Orc2.p1; // D1 -num = c1Orc2 instanceof D1 && c1Orc2.p3; // D1 -var c2Ord1; -num = c2Ord1 instanceof C2 && c2Ord1.p2; // C2 -num = c2Ord1 instanceof D1 && c2Ord1.p3; // D1 -str = c2Ord1 instanceof D1 && c2Ord1.p1; // D1 -var r2 = c2Ord1 instanceof C1 && c2Ord1; // C2 | D1 +var ctor1; +str = ctor1 instanceof C1 && ctor1.p1; // C1 +num = ctor1 instanceof C2 && ctor1.p2; // C2 +str = ctor1 instanceof D1 && ctor1.p1; // D1 +num = ctor1 instanceof D1 && ctor1.p3; // D1 +var ctor2; +num = ctor2 instanceof C2 && ctor2.p2; // C2 +num = ctor2 instanceof D1 && ctor2.p3; // D1 +str = ctor2 instanceof D1 && ctor2.p1; // D1 +var r2 = ctor2 instanceof C1 && ctor2; // C2 | D1 +var ctor3; +if (ctor3 instanceof C1) { + ctor3.p1; // C1 +} +else { + ctor3.p2; // C2 +} +var ctor4; +if (ctor4 instanceof C1) { + ctor4.p1; // C1 +} +else if (ctor4 instanceof C2) { + ctor4.p2; // C2 +} +else { + ctor4.p4; // C3 +} +var ctor5; +if (ctor5 instanceof C1) { + ctor5.p1; // C1 +} +else { + ctor5.p2; // C2 +} +var ctor6; +if (ctor6 instanceof C1 || ctor6 instanceof C2) { +} +else { + ctor6.p4; // C3 +} diff --git a/tests/baselines/reference/typeGuardOfFormInstanceOf.symbols b/tests/baselines/reference/typeGuardOfFormInstanceOf.symbols index 7a48d87e963..0dd2844f6ad 100644 --- a/tests/baselines/reference/typeGuardOfFormInstanceOf.symbols +++ b/tests/baselines/reference/typeGuardOfFormInstanceOf.symbols @@ -24,86 +24,184 @@ class D1 extends C1 { p3: number; >p3 : Symbol(p3, Decl(typeGuardOfFormInstanceOf.ts, 12, 21)) } +class C3 { +>C3 : Symbol(C3, Decl(typeGuardOfFormInstanceOf.ts, 14, 1)) + + p4: number; +>p4 : Symbol(p4, Decl(typeGuardOfFormInstanceOf.ts, 15, 10)) +} var str: string; ->str : Symbol(str, Decl(typeGuardOfFormInstanceOf.ts, 15, 3)) +>str : Symbol(str, Decl(typeGuardOfFormInstanceOf.ts, 18, 3)) var num: number; ->num : Symbol(num, Decl(typeGuardOfFormInstanceOf.ts, 16, 3)) +>num : Symbol(num, Decl(typeGuardOfFormInstanceOf.ts, 19, 3)) var strOrNum: string | number; ->strOrNum : Symbol(strOrNum, Decl(typeGuardOfFormInstanceOf.ts, 17, 3)) +>strOrNum : Symbol(strOrNum, Decl(typeGuardOfFormInstanceOf.ts, 20, 3)) -var c1Orc2: C1 | C2; ->c1Orc2 : Symbol(c1Orc2, Decl(typeGuardOfFormInstanceOf.ts, 19, 3)) +var ctor1: C1 | C2; +>ctor1 : Symbol(ctor1, Decl(typeGuardOfFormInstanceOf.ts, 22, 3)) >C1 : Symbol(C1, Decl(typeGuardOfFormInstanceOf.ts, 0, 0)) >C2 : Symbol(C2, Decl(typeGuardOfFormInstanceOf.ts, 8, 1)) -str = c1Orc2 instanceof C1 && c1Orc2.p1; // C1 ->str : Symbol(str, Decl(typeGuardOfFormInstanceOf.ts, 15, 3)) ->c1Orc2 : Symbol(c1Orc2, Decl(typeGuardOfFormInstanceOf.ts, 19, 3)) +str = ctor1 instanceof C1 && ctor1.p1; // C1 +>str : Symbol(str, Decl(typeGuardOfFormInstanceOf.ts, 18, 3)) +>ctor1 : Symbol(ctor1, Decl(typeGuardOfFormInstanceOf.ts, 22, 3)) >C1 : Symbol(C1, Decl(typeGuardOfFormInstanceOf.ts, 0, 0)) ->c1Orc2.p1 : Symbol(C1.p1, Decl(typeGuardOfFormInstanceOf.ts, 6, 10)) ->c1Orc2 : Symbol(c1Orc2, Decl(typeGuardOfFormInstanceOf.ts, 19, 3)) +>ctor1.p1 : Symbol(C1.p1, Decl(typeGuardOfFormInstanceOf.ts, 6, 10)) +>ctor1 : Symbol(ctor1, Decl(typeGuardOfFormInstanceOf.ts, 22, 3)) >p1 : Symbol(C1.p1, Decl(typeGuardOfFormInstanceOf.ts, 6, 10)) -num = c1Orc2 instanceof C2 && c1Orc2.p2; // C2 ->num : Symbol(num, Decl(typeGuardOfFormInstanceOf.ts, 16, 3)) ->c1Orc2 : Symbol(c1Orc2, Decl(typeGuardOfFormInstanceOf.ts, 19, 3)) +num = ctor1 instanceof C2 && ctor1.p2; // C2 +>num : Symbol(num, Decl(typeGuardOfFormInstanceOf.ts, 19, 3)) +>ctor1 : Symbol(ctor1, Decl(typeGuardOfFormInstanceOf.ts, 22, 3)) >C2 : Symbol(C2, Decl(typeGuardOfFormInstanceOf.ts, 8, 1)) ->c1Orc2.p2 : Symbol(C2.p2, Decl(typeGuardOfFormInstanceOf.ts, 9, 10)) ->c1Orc2 : Symbol(c1Orc2, Decl(typeGuardOfFormInstanceOf.ts, 19, 3)) +>ctor1.p2 : Symbol(C2.p2, Decl(typeGuardOfFormInstanceOf.ts, 9, 10)) +>ctor1 : Symbol(ctor1, Decl(typeGuardOfFormInstanceOf.ts, 22, 3)) >p2 : Symbol(C2.p2, Decl(typeGuardOfFormInstanceOf.ts, 9, 10)) -str = c1Orc2 instanceof D1 && c1Orc2.p1; // D1 ->str : Symbol(str, Decl(typeGuardOfFormInstanceOf.ts, 15, 3)) ->c1Orc2 : Symbol(c1Orc2, Decl(typeGuardOfFormInstanceOf.ts, 19, 3)) +str = ctor1 instanceof D1 && ctor1.p1; // D1 +>str : Symbol(str, Decl(typeGuardOfFormInstanceOf.ts, 18, 3)) +>ctor1 : Symbol(ctor1, Decl(typeGuardOfFormInstanceOf.ts, 22, 3)) >D1 : Symbol(D1, Decl(typeGuardOfFormInstanceOf.ts, 11, 1)) ->c1Orc2.p1 : Symbol(C1.p1, Decl(typeGuardOfFormInstanceOf.ts, 6, 10)) ->c1Orc2 : Symbol(c1Orc2, Decl(typeGuardOfFormInstanceOf.ts, 19, 3)) +>ctor1.p1 : Symbol(C1.p1, Decl(typeGuardOfFormInstanceOf.ts, 6, 10)) +>ctor1 : Symbol(ctor1, Decl(typeGuardOfFormInstanceOf.ts, 22, 3)) >p1 : Symbol(C1.p1, Decl(typeGuardOfFormInstanceOf.ts, 6, 10)) -num = c1Orc2 instanceof D1 && c1Orc2.p3; // D1 ->num : Symbol(num, Decl(typeGuardOfFormInstanceOf.ts, 16, 3)) ->c1Orc2 : Symbol(c1Orc2, Decl(typeGuardOfFormInstanceOf.ts, 19, 3)) +num = ctor1 instanceof D1 && ctor1.p3; // D1 +>num : Symbol(num, Decl(typeGuardOfFormInstanceOf.ts, 19, 3)) +>ctor1 : Symbol(ctor1, Decl(typeGuardOfFormInstanceOf.ts, 22, 3)) >D1 : Symbol(D1, Decl(typeGuardOfFormInstanceOf.ts, 11, 1)) ->c1Orc2.p3 : Symbol(D1.p3, Decl(typeGuardOfFormInstanceOf.ts, 12, 21)) ->c1Orc2 : Symbol(c1Orc2, Decl(typeGuardOfFormInstanceOf.ts, 19, 3)) +>ctor1.p3 : Symbol(D1.p3, Decl(typeGuardOfFormInstanceOf.ts, 12, 21)) +>ctor1 : Symbol(ctor1, Decl(typeGuardOfFormInstanceOf.ts, 22, 3)) >p3 : Symbol(D1.p3, Decl(typeGuardOfFormInstanceOf.ts, 12, 21)) -var c2Ord1: C2 | D1; ->c2Ord1 : Symbol(c2Ord1, Decl(typeGuardOfFormInstanceOf.ts, 25, 3)) +var ctor2: C2 | D1; +>ctor2 : Symbol(ctor2, Decl(typeGuardOfFormInstanceOf.ts, 28, 3)) >C2 : Symbol(C2, Decl(typeGuardOfFormInstanceOf.ts, 8, 1)) >D1 : Symbol(D1, Decl(typeGuardOfFormInstanceOf.ts, 11, 1)) -num = c2Ord1 instanceof C2 && c2Ord1.p2; // C2 ->num : Symbol(num, Decl(typeGuardOfFormInstanceOf.ts, 16, 3)) ->c2Ord1 : Symbol(c2Ord1, Decl(typeGuardOfFormInstanceOf.ts, 25, 3)) +num = ctor2 instanceof C2 && ctor2.p2; // C2 +>num : Symbol(num, Decl(typeGuardOfFormInstanceOf.ts, 19, 3)) +>ctor2 : Symbol(ctor2, Decl(typeGuardOfFormInstanceOf.ts, 28, 3)) >C2 : Symbol(C2, Decl(typeGuardOfFormInstanceOf.ts, 8, 1)) ->c2Ord1.p2 : Symbol(C2.p2, Decl(typeGuardOfFormInstanceOf.ts, 9, 10)) ->c2Ord1 : Symbol(c2Ord1, Decl(typeGuardOfFormInstanceOf.ts, 25, 3)) +>ctor2.p2 : Symbol(C2.p2, Decl(typeGuardOfFormInstanceOf.ts, 9, 10)) +>ctor2 : Symbol(ctor2, Decl(typeGuardOfFormInstanceOf.ts, 28, 3)) >p2 : Symbol(C2.p2, Decl(typeGuardOfFormInstanceOf.ts, 9, 10)) -num = c2Ord1 instanceof D1 && c2Ord1.p3; // D1 ->num : Symbol(num, Decl(typeGuardOfFormInstanceOf.ts, 16, 3)) ->c2Ord1 : Symbol(c2Ord1, Decl(typeGuardOfFormInstanceOf.ts, 25, 3)) +num = ctor2 instanceof D1 && ctor2.p3; // D1 +>num : Symbol(num, Decl(typeGuardOfFormInstanceOf.ts, 19, 3)) +>ctor2 : Symbol(ctor2, Decl(typeGuardOfFormInstanceOf.ts, 28, 3)) >D1 : Symbol(D1, Decl(typeGuardOfFormInstanceOf.ts, 11, 1)) ->c2Ord1.p3 : Symbol(D1.p3, Decl(typeGuardOfFormInstanceOf.ts, 12, 21)) ->c2Ord1 : Symbol(c2Ord1, Decl(typeGuardOfFormInstanceOf.ts, 25, 3)) +>ctor2.p3 : Symbol(D1.p3, Decl(typeGuardOfFormInstanceOf.ts, 12, 21)) +>ctor2 : Symbol(ctor2, Decl(typeGuardOfFormInstanceOf.ts, 28, 3)) >p3 : Symbol(D1.p3, Decl(typeGuardOfFormInstanceOf.ts, 12, 21)) -str = c2Ord1 instanceof D1 && c2Ord1.p1; // D1 ->str : Symbol(str, Decl(typeGuardOfFormInstanceOf.ts, 15, 3)) ->c2Ord1 : Symbol(c2Ord1, Decl(typeGuardOfFormInstanceOf.ts, 25, 3)) +str = ctor2 instanceof D1 && ctor2.p1; // D1 +>str : Symbol(str, Decl(typeGuardOfFormInstanceOf.ts, 18, 3)) +>ctor2 : Symbol(ctor2, Decl(typeGuardOfFormInstanceOf.ts, 28, 3)) >D1 : Symbol(D1, Decl(typeGuardOfFormInstanceOf.ts, 11, 1)) ->c2Ord1.p1 : Symbol(C1.p1, Decl(typeGuardOfFormInstanceOf.ts, 6, 10)) ->c2Ord1 : Symbol(c2Ord1, Decl(typeGuardOfFormInstanceOf.ts, 25, 3)) +>ctor2.p1 : Symbol(C1.p1, Decl(typeGuardOfFormInstanceOf.ts, 6, 10)) +>ctor2 : Symbol(ctor2, Decl(typeGuardOfFormInstanceOf.ts, 28, 3)) >p1 : Symbol(C1.p1, Decl(typeGuardOfFormInstanceOf.ts, 6, 10)) -var r2: D1 | C2 = c2Ord1 instanceof C1 && c2Ord1; // C2 | D1 ->r2 : Symbol(r2, Decl(typeGuardOfFormInstanceOf.ts, 29, 3)) +var r2: D1 | C2 = ctor2 instanceof C1 && ctor2; // C2 | D1 +>r2 : Symbol(r2, Decl(typeGuardOfFormInstanceOf.ts, 32, 3)) >D1 : Symbol(D1, Decl(typeGuardOfFormInstanceOf.ts, 11, 1)) >C2 : Symbol(C2, Decl(typeGuardOfFormInstanceOf.ts, 8, 1)) ->c2Ord1 : Symbol(c2Ord1, Decl(typeGuardOfFormInstanceOf.ts, 25, 3)) +>ctor2 : Symbol(ctor2, Decl(typeGuardOfFormInstanceOf.ts, 28, 3)) >C1 : Symbol(C1, Decl(typeGuardOfFormInstanceOf.ts, 0, 0)) ->c2Ord1 : Symbol(c2Ord1, Decl(typeGuardOfFormInstanceOf.ts, 25, 3)) +>ctor2 : Symbol(ctor2, Decl(typeGuardOfFormInstanceOf.ts, 28, 3)) +var ctor3: C1 | C2; +>ctor3 : Symbol(ctor3, Decl(typeGuardOfFormInstanceOf.ts, 34, 3)) +>C1 : Symbol(C1, Decl(typeGuardOfFormInstanceOf.ts, 0, 0)) +>C2 : Symbol(C2, Decl(typeGuardOfFormInstanceOf.ts, 8, 1)) + +if (ctor3 instanceof C1) { +>ctor3 : Symbol(ctor3, Decl(typeGuardOfFormInstanceOf.ts, 34, 3)) +>C1 : Symbol(C1, Decl(typeGuardOfFormInstanceOf.ts, 0, 0)) + + ctor3.p1; // C1 +>ctor3.p1 : Symbol(C1.p1, Decl(typeGuardOfFormInstanceOf.ts, 6, 10)) +>ctor3 : Symbol(ctor3, Decl(typeGuardOfFormInstanceOf.ts, 34, 3)) +>p1 : Symbol(C1.p1, Decl(typeGuardOfFormInstanceOf.ts, 6, 10)) +} +else { + ctor3.p2; // C2 +>ctor3.p2 : Symbol(C2.p2, Decl(typeGuardOfFormInstanceOf.ts, 9, 10)) +>ctor3 : Symbol(ctor3, Decl(typeGuardOfFormInstanceOf.ts, 34, 3)) +>p2 : Symbol(C2.p2, Decl(typeGuardOfFormInstanceOf.ts, 9, 10)) +} + +var ctor4: C1 | C2 | C3; +>ctor4 : Symbol(ctor4, Decl(typeGuardOfFormInstanceOf.ts, 42, 3)) +>C1 : Symbol(C1, Decl(typeGuardOfFormInstanceOf.ts, 0, 0)) +>C2 : Symbol(C2, Decl(typeGuardOfFormInstanceOf.ts, 8, 1)) +>C3 : Symbol(C3, Decl(typeGuardOfFormInstanceOf.ts, 14, 1)) + +if (ctor4 instanceof C1) { +>ctor4 : Symbol(ctor4, Decl(typeGuardOfFormInstanceOf.ts, 42, 3)) +>C1 : Symbol(C1, Decl(typeGuardOfFormInstanceOf.ts, 0, 0)) + + ctor4.p1; // C1 +>ctor4.p1 : Symbol(C1.p1, Decl(typeGuardOfFormInstanceOf.ts, 6, 10)) +>ctor4 : Symbol(ctor4, Decl(typeGuardOfFormInstanceOf.ts, 42, 3)) +>p1 : Symbol(C1.p1, Decl(typeGuardOfFormInstanceOf.ts, 6, 10)) +} +else if (ctor4 instanceof C2) { +>ctor4 : Symbol(ctor4, Decl(typeGuardOfFormInstanceOf.ts, 42, 3)) +>C2 : Symbol(C2, Decl(typeGuardOfFormInstanceOf.ts, 8, 1)) + + ctor4.p2; // C2 +>ctor4.p2 : Symbol(C2.p2, Decl(typeGuardOfFormInstanceOf.ts, 9, 10)) +>ctor4 : Symbol(ctor4, Decl(typeGuardOfFormInstanceOf.ts, 42, 3)) +>p2 : Symbol(C2.p2, Decl(typeGuardOfFormInstanceOf.ts, 9, 10)) +} +else { + ctor4.p4; // C3 +>ctor4.p4 : Symbol(C3.p4, Decl(typeGuardOfFormInstanceOf.ts, 15, 10)) +>ctor4 : Symbol(ctor4, Decl(typeGuardOfFormInstanceOf.ts, 42, 3)) +>p4 : Symbol(C3.p4, Decl(typeGuardOfFormInstanceOf.ts, 15, 10)) +} + +var ctor5: C1 | D1 | C2; +>ctor5 : Symbol(ctor5, Decl(typeGuardOfFormInstanceOf.ts, 53, 3)) +>C1 : Symbol(C1, Decl(typeGuardOfFormInstanceOf.ts, 0, 0)) +>D1 : Symbol(D1, Decl(typeGuardOfFormInstanceOf.ts, 11, 1)) +>C2 : Symbol(C2, Decl(typeGuardOfFormInstanceOf.ts, 8, 1)) + +if (ctor5 instanceof C1) { +>ctor5 : Symbol(ctor5, Decl(typeGuardOfFormInstanceOf.ts, 53, 3)) +>C1 : Symbol(C1, Decl(typeGuardOfFormInstanceOf.ts, 0, 0)) + + ctor5.p1; // C1 +>ctor5.p1 : Symbol(C1.p1, Decl(typeGuardOfFormInstanceOf.ts, 6, 10)) +>ctor5 : Symbol(ctor5, Decl(typeGuardOfFormInstanceOf.ts, 53, 3)) +>p1 : Symbol(C1.p1, Decl(typeGuardOfFormInstanceOf.ts, 6, 10)) +} +else { + ctor5.p2; // C2 +>ctor5.p2 : Symbol(C2.p2, Decl(typeGuardOfFormInstanceOf.ts, 9, 10)) +>ctor5 : Symbol(ctor5, Decl(typeGuardOfFormInstanceOf.ts, 53, 3)) +>p2 : Symbol(C2.p2, Decl(typeGuardOfFormInstanceOf.ts, 9, 10)) +} + +var ctor6: C1 | C2 | C3; +>ctor6 : Symbol(ctor6, Decl(typeGuardOfFormInstanceOf.ts, 61, 3)) +>C1 : Symbol(C1, Decl(typeGuardOfFormInstanceOf.ts, 0, 0)) +>C2 : Symbol(C2, Decl(typeGuardOfFormInstanceOf.ts, 8, 1)) +>C3 : Symbol(C3, Decl(typeGuardOfFormInstanceOf.ts, 14, 1)) + +if (ctor6 instanceof C1 || ctor6 instanceof C2) { +>ctor6 : Symbol(ctor6, Decl(typeGuardOfFormInstanceOf.ts, 61, 3)) +>C1 : Symbol(C1, Decl(typeGuardOfFormInstanceOf.ts, 0, 0)) +>ctor6 : Symbol(ctor6, Decl(typeGuardOfFormInstanceOf.ts, 61, 3)) +>C2 : Symbol(C2, Decl(typeGuardOfFormInstanceOf.ts, 8, 1)) +} +else { + ctor6.p4; // C3 +>ctor6.p4 : Symbol(C3.p4, Decl(typeGuardOfFormInstanceOf.ts, 15, 10)) +>ctor6 : Symbol(ctor6, Decl(typeGuardOfFormInstanceOf.ts, 61, 3)) +>p4 : Symbol(C3.p4, Decl(typeGuardOfFormInstanceOf.ts, 15, 10)) +} diff --git a/tests/baselines/reference/typeGuardOfFormInstanceOf.types b/tests/baselines/reference/typeGuardOfFormInstanceOf.types index c824e907733..6b83b57dcb5 100644 --- a/tests/baselines/reference/typeGuardOfFormInstanceOf.types +++ b/tests/baselines/reference/typeGuardOfFormInstanceOf.types @@ -24,6 +24,12 @@ class D1 extends C1 { p3: number; >p3 : number } +class C3 { +>C3 : C3 + + p4: number; +>p4 : number +} var str: string; >str : string @@ -33,100 +39,199 @@ var num: number; var strOrNum: string | number; >strOrNum : string | number -var c1Orc2: C1 | C2; ->c1Orc2 : C1 | C2 +var ctor1: C1 | C2; +>ctor1 : C1 | C2 >C1 : C1 >C2 : C2 -str = c1Orc2 instanceof C1 && c1Orc2.p1; // C1 ->str = c1Orc2 instanceof C1 && c1Orc2.p1 : string +str = ctor1 instanceof C1 && ctor1.p1; // C1 +>str = ctor1 instanceof C1 && ctor1.p1 : string >str : string ->c1Orc2 instanceof C1 && c1Orc2.p1 : string ->c1Orc2 instanceof C1 : boolean ->c1Orc2 : C1 | C2 +>ctor1 instanceof C1 && ctor1.p1 : string +>ctor1 instanceof C1 : boolean +>ctor1 : C1 | C2 >C1 : typeof C1 ->c1Orc2.p1 : string ->c1Orc2 : C1 +>ctor1.p1 : string +>ctor1 : C1 >p1 : string -num = c1Orc2 instanceof C2 && c1Orc2.p2; // C2 ->num = c1Orc2 instanceof C2 && c1Orc2.p2 : number +num = ctor1 instanceof C2 && ctor1.p2; // C2 +>num = ctor1 instanceof C2 && ctor1.p2 : number >num : number ->c1Orc2 instanceof C2 && c1Orc2.p2 : number ->c1Orc2 instanceof C2 : boolean ->c1Orc2 : C1 | C2 +>ctor1 instanceof C2 && ctor1.p2 : number +>ctor1 instanceof C2 : boolean +>ctor1 : C1 | C2 >C2 : typeof C2 ->c1Orc2.p2 : number ->c1Orc2 : C2 +>ctor1.p2 : number +>ctor1 : C2 >p2 : number -str = c1Orc2 instanceof D1 && c1Orc2.p1; // D1 ->str = c1Orc2 instanceof D1 && c1Orc2.p1 : string +str = ctor1 instanceof D1 && ctor1.p1; // D1 +>str = ctor1 instanceof D1 && ctor1.p1 : string >str : string ->c1Orc2 instanceof D1 && c1Orc2.p1 : string ->c1Orc2 instanceof D1 : boolean ->c1Orc2 : C1 | C2 +>ctor1 instanceof D1 && ctor1.p1 : string +>ctor1 instanceof D1 : boolean +>ctor1 : C1 | C2 >D1 : typeof D1 ->c1Orc2.p1 : string ->c1Orc2 : D1 +>ctor1.p1 : string +>ctor1 : D1 >p1 : string -num = c1Orc2 instanceof D1 && c1Orc2.p3; // D1 ->num = c1Orc2 instanceof D1 && c1Orc2.p3 : number +num = ctor1 instanceof D1 && ctor1.p3; // D1 +>num = ctor1 instanceof D1 && ctor1.p3 : number >num : number ->c1Orc2 instanceof D1 && c1Orc2.p3 : number ->c1Orc2 instanceof D1 : boolean ->c1Orc2 : C1 | C2 +>ctor1 instanceof D1 && ctor1.p3 : number +>ctor1 instanceof D1 : boolean +>ctor1 : C1 | C2 >D1 : typeof D1 ->c1Orc2.p3 : number ->c1Orc2 : D1 +>ctor1.p3 : number +>ctor1 : D1 >p3 : number -var c2Ord1: C2 | D1; ->c2Ord1 : C2 | D1 +var ctor2: C2 | D1; +>ctor2 : C2 | D1 >C2 : C2 >D1 : D1 -num = c2Ord1 instanceof C2 && c2Ord1.p2; // C2 ->num = c2Ord1 instanceof C2 && c2Ord1.p2 : number +num = ctor2 instanceof C2 && ctor2.p2; // C2 +>num = ctor2 instanceof C2 && ctor2.p2 : number >num : number ->c2Ord1 instanceof C2 && c2Ord1.p2 : number ->c2Ord1 instanceof C2 : boolean ->c2Ord1 : C2 | D1 +>ctor2 instanceof C2 && ctor2.p2 : number +>ctor2 instanceof C2 : boolean +>ctor2 : C2 | D1 >C2 : typeof C2 ->c2Ord1.p2 : number ->c2Ord1 : C2 +>ctor2.p2 : number +>ctor2 : C2 >p2 : number -num = c2Ord1 instanceof D1 && c2Ord1.p3; // D1 ->num = c2Ord1 instanceof D1 && c2Ord1.p3 : number +num = ctor2 instanceof D1 && ctor2.p3; // D1 +>num = ctor2 instanceof D1 && ctor2.p3 : number >num : number ->c2Ord1 instanceof D1 && c2Ord1.p3 : number ->c2Ord1 instanceof D1 : boolean ->c2Ord1 : C2 | D1 +>ctor2 instanceof D1 && ctor2.p3 : number +>ctor2 instanceof D1 : boolean +>ctor2 : C2 | D1 >D1 : typeof D1 ->c2Ord1.p3 : number ->c2Ord1 : D1 +>ctor2.p3 : number +>ctor2 : D1 >p3 : number -str = c2Ord1 instanceof D1 && c2Ord1.p1; // D1 ->str = c2Ord1 instanceof D1 && c2Ord1.p1 : string +str = ctor2 instanceof D1 && ctor2.p1; // D1 +>str = ctor2 instanceof D1 && ctor2.p1 : string >str : string ->c2Ord1 instanceof D1 && c2Ord1.p1 : string ->c2Ord1 instanceof D1 : boolean ->c2Ord1 : C2 | D1 +>ctor2 instanceof D1 && ctor2.p1 : string +>ctor2 instanceof D1 : boolean +>ctor2 : C2 | D1 >D1 : typeof D1 ->c2Ord1.p1 : string ->c2Ord1 : D1 +>ctor2.p1 : string +>ctor2 : D1 >p1 : string -var r2: D1 | C2 = c2Ord1 instanceof C1 && c2Ord1; // C2 | D1 +var r2: D1 | C2 = ctor2 instanceof C1 && ctor2; // C2 | D1 >r2 : D1 | C2 >D1 : D1 >C2 : C2 ->c2Ord1 instanceof C1 && c2Ord1 : D1 ->c2Ord1 instanceof C1 : boolean ->c2Ord1 : C2 | D1 +>ctor2 instanceof C1 && ctor2 : D1 +>ctor2 instanceof C1 : boolean +>ctor2 : C2 | D1 >C1 : typeof C1 ->c2Ord1 : D1 +>ctor2 : D1 +var ctor3: C1 | C2; +>ctor3 : C1 | C2 +>C1 : C1 +>C2 : C2 + +if (ctor3 instanceof C1) { +>ctor3 instanceof C1 : boolean +>ctor3 : C1 | C2 +>C1 : typeof C1 + + ctor3.p1; // C1 +>ctor3.p1 : string +>ctor3 : C1 +>p1 : string +} +else { + ctor3.p2; // C2 +>ctor3.p2 : number +>ctor3 : C2 +>p2 : number +} + +var ctor4: C1 | C2 | C3; +>ctor4 : C1 | C2 | C3 +>C1 : C1 +>C2 : C2 +>C3 : C3 + +if (ctor4 instanceof C1) { +>ctor4 instanceof C1 : boolean +>ctor4 : C1 | C2 | C3 +>C1 : typeof C1 + + ctor4.p1; // C1 +>ctor4.p1 : string +>ctor4 : C1 +>p1 : string +} +else if (ctor4 instanceof C2) { +>ctor4 instanceof C2 : boolean +>ctor4 : C2 | C3 +>C2 : typeof C2 + + ctor4.p2; // C2 +>ctor4.p2 : number +>ctor4 : C2 +>p2 : number +} +else { + ctor4.p4; // C3 +>ctor4.p4 : number +>ctor4 : C3 +>p4 : number +} + +var ctor5: C1 | D1 | C2; +>ctor5 : C1 | D1 | C2 +>C1 : C1 +>D1 : D1 +>C2 : C2 + +if (ctor5 instanceof C1) { +>ctor5 instanceof C1 : boolean +>ctor5 : C1 | D1 | C2 +>C1 : typeof C1 + + ctor5.p1; // C1 +>ctor5.p1 : string +>ctor5 : C1 +>p1 : string +} +else { + ctor5.p2; // C2 +>ctor5.p2 : number +>ctor5 : C2 +>p2 : number +} + +var ctor6: C1 | C2 | C3; +>ctor6 : C1 | C2 | C3 +>C1 : C1 +>C2 : C2 +>C3 : C3 + +if (ctor6 instanceof C1 || ctor6 instanceof C2) { +>ctor6 instanceof C1 || ctor6 instanceof C2 : boolean +>ctor6 instanceof C1 : boolean +>ctor6 : C1 | C2 | C3 +>C1 : typeof C1 +>ctor6 instanceof C2 : boolean +>ctor6 : C2 | C3 +>C2 : typeof C2 +} +else { + ctor6.p4; // C3 +>ctor6.p4 : number +>ctor6 : C3 +>p4 : number +} diff --git a/tests/cases/conformance/expressions/typeGuards/typeGuardOfFormInstanceOf.ts b/tests/cases/conformance/expressions/typeGuards/typeGuardOfFormInstanceOf.ts index 233909f44aa..31514fca749 100644 --- a/tests/cases/conformance/expressions/typeGuards/typeGuardOfFormInstanceOf.ts +++ b/tests/cases/conformance/expressions/typeGuards/typeGuardOfFormInstanceOf.ts @@ -13,18 +13,55 @@ class C2 { class D1 extends C1 { p3: number; } +class C3 { + p4: number; +} var str: string; var num: number; var strOrNum: string | number; -var c1Orc2: C1 | C2; -str = c1Orc2 instanceof C1 && c1Orc2.p1; // C1 -num = c1Orc2 instanceof C2 && c1Orc2.p2; // C2 -str = c1Orc2 instanceof D1 && c1Orc2.p1; // D1 -num = c1Orc2 instanceof D1 && c1Orc2.p3; // D1 +var ctor1: C1 | C2; +str = ctor1 instanceof C1 && ctor1.p1; // C1 +num = ctor1 instanceof C2 && ctor1.p2; // C2 +str = ctor1 instanceof D1 && ctor1.p1; // D1 +num = ctor1 instanceof D1 && ctor1.p3; // D1 + +var ctor2: C2 | D1; +num = ctor2 instanceof C2 && ctor2.p2; // C2 +num = ctor2 instanceof D1 && ctor2.p3; // D1 +str = ctor2 instanceof D1 && ctor2.p1; // D1 +var r2: D1 | C2 = ctor2 instanceof C1 && ctor2; // C2 | D1 -var c2Ord1: C2 | D1; -num = c2Ord1 instanceof C2 && c2Ord1.p2; // C2 -num = c2Ord1 instanceof D1 && c2Ord1.p3; // D1 -str = c2Ord1 instanceof D1 && c2Ord1.p1; // D1 -var r2: D1 | C2 = c2Ord1 instanceof C1 && c2Ord1; // C2 | D1 \ No newline at end of file +var ctor3: C1 | C2; +if (ctor3 instanceof C1) { + ctor3.p1; // C1 +} +else { + ctor3.p2; // C2 +} + +var ctor4: C1 | C2 | C3; +if (ctor4 instanceof C1) { + ctor4.p1; // C1 +} +else if (ctor4 instanceof C2) { + ctor4.p2; // C2 +} +else { + ctor4.p4; // C3 +} + +var ctor5: C1 | D1 | C2; +if (ctor5 instanceof C1) { + ctor5.p1; // C1 +} +else { + ctor5.p2; // C2 +} + +var ctor6: C1 | C2 | C3; +if (ctor6 instanceof C1 || ctor6 instanceof C2) { +} +else { + ctor6.p4; // C3 +} \ No newline at end of file From f7a6ac7e0c0a03a3fd2d32a759e38b204f8cc5a5 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Wed, 7 Oct 2015 15:38:24 -0700 Subject: [PATCH 054/227] Added more tests. --- .../stringLiteralTypesOverloads03.ts | 46 +++++++++++++++++++ ...tringLiteralTypesWithVariousOperators01.ts | 29 ++++++++++++ ...tringLiteralTypesWithVariousOperators02.ts | 19 ++++++++ 3 files changed, 94 insertions(+) create mode 100644 tests/cases/conformance/types/stringLiteral/stringLiteralTypesOverloads03.ts create mode 100644 tests/cases/conformance/types/stringLiteral/stringLiteralTypesWithVariousOperators01.ts create mode 100644 tests/cases/conformance/types/stringLiteral/stringLiteralTypesWithVariousOperators02.ts diff --git a/tests/cases/conformance/types/stringLiteral/stringLiteralTypesOverloads03.ts b/tests/cases/conformance/types/stringLiteral/stringLiteralTypesOverloads03.ts new file mode 100644 index 00000000000..a675c2c0eae --- /dev/null +++ b/tests/cases/conformance/types/stringLiteral/stringLiteralTypesOverloads03.ts @@ -0,0 +1,46 @@ +// @declaration: true + +interface Base { + x: string; + y: number; +} + +interface HelloOrWorld extends Base { + p1: boolean; +} + +interface JustHello extends Base { + p2: boolean; +} + +interface JustWorld extends Base { + p3: boolean; +} + +let hello: "hello"; +let world: "world"; +let helloOrWorld: "hello" | "world"; + +function f(p: "hello"): JustHello; +function f(p: "hello" | "world"): HelloOrWorld; +function f(p: "world"): JustWorld; +function f(p: string): Base; +function f(...args: any[]): any { + return undefined; +} + +let fResult1 = f(hello); +let fResult2 = f(world); +let fResult3 = f(helloOrWorld); + +function g(p: string): Base; +function g(p: "hello"): JustHello; +function g(p: "hello" | "world"): HelloOrWorld; +function g(p: "world"): JustWorld; +function g(...args: any[]): any { + return undefined; +} + +let gResult1 = g(hello); +let gResult2 = g(world); +let gResult3 = g(helloOrWorld); \ No newline at end of file diff --git a/tests/cases/conformance/types/stringLiteral/stringLiteralTypesWithVariousOperators01.ts b/tests/cases/conformance/types/stringLiteral/stringLiteralTypesWithVariousOperators01.ts new file mode 100644 index 00000000000..28c34d3c74a --- /dev/null +++ b/tests/cases/conformance/types/stringLiteral/stringLiteralTypesWithVariousOperators01.ts @@ -0,0 +1,29 @@ +// @declaration: true + +let abc: "ABC" = "ABC"; +let xyz: "XYZ" = "XYZ"; +let abcOrXyz: "ABC" | "XYZ" = abc || xyz; +let abcOrXyzOrNumber: "ABC" | "XYZ" | number = abcOrXyz || 100; + +let a = "" + abc; +let b = abc + ""; +let c = 10 + abc; +let d = abc + 10; +let e = xyz + abc; +let f = abc + xyz; +let g = true + abc; +let h = abc + true; +let i = abc + abcOrXyz + xyz; +let j = abcOrXyz + abcOrXyz; +let k = +abcOrXyz; +let l = -abcOrXyz; +let m = abcOrXyzOrNumber + ""; +let n = "" + abcOrXyzOrNumber; +let o = abcOrXyzOrNumber + abcOrXyz; +let p = abcOrXyz + abcOrXyzOrNumber; +let q = !abcOrXyzOrNumber; +let r = ~abcOrXyzOrNumber; +let s = abcOrXyzOrNumber < abcOrXyzOrNumber; +let t = abcOrXyzOrNumber >= abcOrXyz; +let u = abc === abcOrXyz; +let v = abcOrXyz === abcOrXyzOrNumber; \ No newline at end of file diff --git a/tests/cases/conformance/types/stringLiteral/stringLiteralTypesWithVariousOperators02.ts b/tests/cases/conformance/types/stringLiteral/stringLiteralTypesWithVariousOperators02.ts new file mode 100644 index 00000000000..cf66f66e47c --- /dev/null +++ b/tests/cases/conformance/types/stringLiteral/stringLiteralTypesWithVariousOperators02.ts @@ -0,0 +1,19 @@ +// @declaration: true + +let abc: "ABC" = "ABC"; +let xyz: "XYZ" = "XYZ"; +let abcOrXyz: "ABC" | "XYZ" = abc || xyz; +let abcOrXyzOrNumber: "ABC" | "XYZ" | number = abcOrXyz || 100; + +let a = abcOrXyzOrNumber + 100; +let b = 100 + abcOrXyzOrNumber; +let c = abcOrXyzOrNumber + abcOrXyzOrNumber; +let d = abcOrXyzOrNumber + true; +let e = false + abcOrXyzOrNumber; +let f = abcOrXyzOrNumber++; +let g = --abcOrXyzOrNumber; +let h = abcOrXyzOrNumber ^ 10; +let i = abcOrXyzOrNumber | 10; +let j = abc < xyz; +let k = abc === xyz; +let l = abc != xyz; \ No newline at end of file From a440f06cac2f5265f321cf06ea147310d759afb6 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Thu, 8 Oct 2015 14:10:15 -0700 Subject: [PATCH 055/227] Accepted baselines. --- .../stringLiteralTypesOverloads03.js | 104 ++++++++++++ .../stringLiteralTypesOverloads03.symbols | 131 +++++++++++++++ .../stringLiteralTypesOverloads03.types | 137 ++++++++++++++++ ...tringLiteralTypesWithVariousOperators01.js | 86 ++++++++++ ...LiteralTypesWithVariousOperators01.symbols | 116 +++++++++++++ ...ngLiteralTypesWithVariousOperators01.types | 152 ++++++++++++++++++ ...eralTypesWithVariousOperators02.errors.txt | 57 +++++++ ...tringLiteralTypesWithVariousOperators02.js | 56 +++++++ 8 files changed, 839 insertions(+) create mode 100644 tests/baselines/reference/stringLiteralTypesOverloads03.js create mode 100644 tests/baselines/reference/stringLiteralTypesOverloads03.symbols create mode 100644 tests/baselines/reference/stringLiteralTypesOverloads03.types create mode 100644 tests/baselines/reference/stringLiteralTypesWithVariousOperators01.js create mode 100644 tests/baselines/reference/stringLiteralTypesWithVariousOperators01.symbols create mode 100644 tests/baselines/reference/stringLiteralTypesWithVariousOperators01.types create mode 100644 tests/baselines/reference/stringLiteralTypesWithVariousOperators02.errors.txt create mode 100644 tests/baselines/reference/stringLiteralTypesWithVariousOperators02.js diff --git a/tests/baselines/reference/stringLiteralTypesOverloads03.js b/tests/baselines/reference/stringLiteralTypesOverloads03.js new file mode 100644 index 00000000000..c1e79160880 --- /dev/null +++ b/tests/baselines/reference/stringLiteralTypesOverloads03.js @@ -0,0 +1,104 @@ +//// [stringLiteralTypesOverloads03.ts] + +interface Base { + x: string; + y: number; +} + +interface HelloOrWorld extends Base { + p1: boolean; +} + +interface JustHello extends Base { + p2: boolean; +} + +interface JustWorld extends Base { + p3: boolean; +} + +let hello: "hello"; +let world: "world"; +let helloOrWorld: "hello" | "world"; + +function f(p: "hello"): JustHello; +function f(p: "hello" | "world"): HelloOrWorld; +function f(p: "world"): JustWorld; +function f(p: string): Base; +function f(...args: any[]): any { + return undefined; +} + +let fResult1 = f(hello); +let fResult2 = f(world); +let fResult3 = f(helloOrWorld); + +function g(p: string): Base; +function g(p: "hello"): JustHello; +function g(p: "hello" | "world"): HelloOrWorld; +function g(p: "world"): JustWorld; +function g(...args: any[]): any { + return undefined; +} + +let gResult1 = g(hello); +let gResult2 = g(world); +let gResult3 = g(helloOrWorld); + +//// [stringLiteralTypesOverloads03.js] +var hello; +var world; +var helloOrWorld; +function f() { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i - 0] = arguments[_i]; + } + return undefined; +} +var fResult1 = f(hello); +var fResult2 = f(world); +var fResult3 = f(helloOrWorld); +function g() { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i - 0] = arguments[_i]; + } + return undefined; +} +var gResult1 = g(hello); +var gResult2 = g(world); +var gResult3 = g(helloOrWorld); + + +//// [stringLiteralTypesOverloads03.d.ts] +interface Base { + x: string; + y: number; +} +interface HelloOrWorld extends Base { + p1: boolean; +} +interface JustHello extends Base { + p2: boolean; +} +interface JustWorld extends Base { + p3: boolean; +} +declare let hello: "hello"; +declare let world: "world"; +declare let helloOrWorld: "hello" | "world"; +declare function f(p: "hello"): JustHello; +declare function f(p: "hello" | "world"): HelloOrWorld; +declare function f(p: "world"): JustWorld; +declare function f(p: string): Base; +declare let fResult1: JustHello; +declare let fResult2: JustWorld; +declare let fResult3: HelloOrWorld; +declare function g(p: string): Base; +declare function g(p: "hello"): JustHello; +declare function g(p: "hello" | "world"): HelloOrWorld; +declare function g(p: "world"): JustWorld; +declare let gResult1: JustHello; +declare let gResult2: JustWorld; +declare let gResult3: Base; diff --git a/tests/baselines/reference/stringLiteralTypesOverloads03.symbols b/tests/baselines/reference/stringLiteralTypesOverloads03.symbols new file mode 100644 index 00000000000..a0a48de790f --- /dev/null +++ b/tests/baselines/reference/stringLiteralTypesOverloads03.symbols @@ -0,0 +1,131 @@ +=== tests/cases/conformance/types/stringLiteral/stringLiteralTypesOverloads03.ts === + +interface Base { +>Base : Symbol(Base, Decl(stringLiteralTypesOverloads03.ts, 0, 0)) + + x: string; +>x : Symbol(x, Decl(stringLiteralTypesOverloads03.ts, 1, 16)) + + y: number; +>y : Symbol(y, Decl(stringLiteralTypesOverloads03.ts, 2, 14)) +} + +interface HelloOrWorld extends Base { +>HelloOrWorld : Symbol(HelloOrWorld, Decl(stringLiteralTypesOverloads03.ts, 4, 1)) +>Base : Symbol(Base, Decl(stringLiteralTypesOverloads03.ts, 0, 0)) + + p1: boolean; +>p1 : Symbol(p1, Decl(stringLiteralTypesOverloads03.ts, 6, 37)) +} + +interface JustHello extends Base { +>JustHello : Symbol(JustHello, Decl(stringLiteralTypesOverloads03.ts, 8, 1)) +>Base : Symbol(Base, Decl(stringLiteralTypesOverloads03.ts, 0, 0)) + + p2: boolean; +>p2 : Symbol(p2, Decl(stringLiteralTypesOverloads03.ts, 10, 34)) +} + +interface JustWorld extends Base { +>JustWorld : Symbol(JustWorld, Decl(stringLiteralTypesOverloads03.ts, 12, 1)) +>Base : Symbol(Base, Decl(stringLiteralTypesOverloads03.ts, 0, 0)) + + p3: boolean; +>p3 : Symbol(p3, Decl(stringLiteralTypesOverloads03.ts, 14, 34)) +} + +let hello: "hello"; +>hello : Symbol(hello, Decl(stringLiteralTypesOverloads03.ts, 18, 3)) + +let world: "world"; +>world : Symbol(world, Decl(stringLiteralTypesOverloads03.ts, 19, 3)) + +let helloOrWorld: "hello" | "world"; +>helloOrWorld : Symbol(helloOrWorld, Decl(stringLiteralTypesOverloads03.ts, 20, 3)) + +function f(p: "hello"): JustHello; +>f : Symbol(f, Decl(stringLiteralTypesOverloads03.ts, 20, 36), Decl(stringLiteralTypesOverloads03.ts, 22, 34), Decl(stringLiteralTypesOverloads03.ts, 23, 47), Decl(stringLiteralTypesOverloads03.ts, 24, 34), Decl(stringLiteralTypesOverloads03.ts, 25, 28)) +>p : Symbol(p, Decl(stringLiteralTypesOverloads03.ts, 22, 11)) +>JustHello : Symbol(JustHello, Decl(stringLiteralTypesOverloads03.ts, 8, 1)) + +function f(p: "hello" | "world"): HelloOrWorld; +>f : Symbol(f, Decl(stringLiteralTypesOverloads03.ts, 20, 36), Decl(stringLiteralTypesOverloads03.ts, 22, 34), Decl(stringLiteralTypesOverloads03.ts, 23, 47), Decl(stringLiteralTypesOverloads03.ts, 24, 34), Decl(stringLiteralTypesOverloads03.ts, 25, 28)) +>p : Symbol(p, Decl(stringLiteralTypesOverloads03.ts, 23, 11)) +>HelloOrWorld : Symbol(HelloOrWorld, Decl(stringLiteralTypesOverloads03.ts, 4, 1)) + +function f(p: "world"): JustWorld; +>f : Symbol(f, Decl(stringLiteralTypesOverloads03.ts, 20, 36), Decl(stringLiteralTypesOverloads03.ts, 22, 34), Decl(stringLiteralTypesOverloads03.ts, 23, 47), Decl(stringLiteralTypesOverloads03.ts, 24, 34), Decl(stringLiteralTypesOverloads03.ts, 25, 28)) +>p : Symbol(p, Decl(stringLiteralTypesOverloads03.ts, 24, 11)) +>JustWorld : Symbol(JustWorld, Decl(stringLiteralTypesOverloads03.ts, 12, 1)) + +function f(p: string): Base; +>f : Symbol(f, Decl(stringLiteralTypesOverloads03.ts, 20, 36), Decl(stringLiteralTypesOverloads03.ts, 22, 34), Decl(stringLiteralTypesOverloads03.ts, 23, 47), Decl(stringLiteralTypesOverloads03.ts, 24, 34), Decl(stringLiteralTypesOverloads03.ts, 25, 28)) +>p : Symbol(p, Decl(stringLiteralTypesOverloads03.ts, 25, 11)) +>Base : Symbol(Base, Decl(stringLiteralTypesOverloads03.ts, 0, 0)) + +function f(...args: any[]): any { +>f : Symbol(f, Decl(stringLiteralTypesOverloads03.ts, 20, 36), Decl(stringLiteralTypesOverloads03.ts, 22, 34), Decl(stringLiteralTypesOverloads03.ts, 23, 47), Decl(stringLiteralTypesOverloads03.ts, 24, 34), Decl(stringLiteralTypesOverloads03.ts, 25, 28)) +>args : Symbol(args, Decl(stringLiteralTypesOverloads03.ts, 26, 11)) + + return undefined; +>undefined : Symbol(undefined) +} + +let fResult1 = f(hello); +>fResult1 : Symbol(fResult1, Decl(stringLiteralTypesOverloads03.ts, 30, 3)) +>f : Symbol(f, Decl(stringLiteralTypesOverloads03.ts, 20, 36), Decl(stringLiteralTypesOverloads03.ts, 22, 34), Decl(stringLiteralTypesOverloads03.ts, 23, 47), Decl(stringLiteralTypesOverloads03.ts, 24, 34), Decl(stringLiteralTypesOverloads03.ts, 25, 28)) +>hello : Symbol(hello, Decl(stringLiteralTypesOverloads03.ts, 18, 3)) + +let fResult2 = f(world); +>fResult2 : Symbol(fResult2, Decl(stringLiteralTypesOverloads03.ts, 31, 3)) +>f : Symbol(f, Decl(stringLiteralTypesOverloads03.ts, 20, 36), Decl(stringLiteralTypesOverloads03.ts, 22, 34), Decl(stringLiteralTypesOverloads03.ts, 23, 47), Decl(stringLiteralTypesOverloads03.ts, 24, 34), Decl(stringLiteralTypesOverloads03.ts, 25, 28)) +>world : Symbol(world, Decl(stringLiteralTypesOverloads03.ts, 19, 3)) + +let fResult3 = f(helloOrWorld); +>fResult3 : Symbol(fResult3, Decl(stringLiteralTypesOverloads03.ts, 32, 3)) +>f : Symbol(f, Decl(stringLiteralTypesOverloads03.ts, 20, 36), Decl(stringLiteralTypesOverloads03.ts, 22, 34), Decl(stringLiteralTypesOverloads03.ts, 23, 47), Decl(stringLiteralTypesOverloads03.ts, 24, 34), Decl(stringLiteralTypesOverloads03.ts, 25, 28)) +>helloOrWorld : Symbol(helloOrWorld, Decl(stringLiteralTypesOverloads03.ts, 20, 3)) + +function g(p: string): Base; +>g : Symbol(g, Decl(stringLiteralTypesOverloads03.ts, 32, 31), Decl(stringLiteralTypesOverloads03.ts, 34, 28), Decl(stringLiteralTypesOverloads03.ts, 35, 34), Decl(stringLiteralTypesOverloads03.ts, 36, 47), Decl(stringLiteralTypesOverloads03.ts, 37, 34)) +>p : Symbol(p, Decl(stringLiteralTypesOverloads03.ts, 34, 11)) +>Base : Symbol(Base, Decl(stringLiteralTypesOverloads03.ts, 0, 0)) + +function g(p: "hello"): JustHello; +>g : Symbol(g, Decl(stringLiteralTypesOverloads03.ts, 32, 31), Decl(stringLiteralTypesOverloads03.ts, 34, 28), Decl(stringLiteralTypesOverloads03.ts, 35, 34), Decl(stringLiteralTypesOverloads03.ts, 36, 47), Decl(stringLiteralTypesOverloads03.ts, 37, 34)) +>p : Symbol(p, Decl(stringLiteralTypesOverloads03.ts, 35, 11)) +>JustHello : Symbol(JustHello, Decl(stringLiteralTypesOverloads03.ts, 8, 1)) + +function g(p: "hello" | "world"): HelloOrWorld; +>g : Symbol(g, Decl(stringLiteralTypesOverloads03.ts, 32, 31), Decl(stringLiteralTypesOverloads03.ts, 34, 28), Decl(stringLiteralTypesOverloads03.ts, 35, 34), Decl(stringLiteralTypesOverloads03.ts, 36, 47), Decl(stringLiteralTypesOverloads03.ts, 37, 34)) +>p : Symbol(p, Decl(stringLiteralTypesOverloads03.ts, 36, 11)) +>HelloOrWorld : Symbol(HelloOrWorld, Decl(stringLiteralTypesOverloads03.ts, 4, 1)) + +function g(p: "world"): JustWorld; +>g : Symbol(g, Decl(stringLiteralTypesOverloads03.ts, 32, 31), Decl(stringLiteralTypesOverloads03.ts, 34, 28), Decl(stringLiteralTypesOverloads03.ts, 35, 34), Decl(stringLiteralTypesOverloads03.ts, 36, 47), Decl(stringLiteralTypesOverloads03.ts, 37, 34)) +>p : Symbol(p, Decl(stringLiteralTypesOverloads03.ts, 37, 11)) +>JustWorld : Symbol(JustWorld, Decl(stringLiteralTypesOverloads03.ts, 12, 1)) + +function g(...args: any[]): any { +>g : Symbol(g, Decl(stringLiteralTypesOverloads03.ts, 32, 31), Decl(stringLiteralTypesOverloads03.ts, 34, 28), Decl(stringLiteralTypesOverloads03.ts, 35, 34), Decl(stringLiteralTypesOverloads03.ts, 36, 47), Decl(stringLiteralTypesOverloads03.ts, 37, 34)) +>args : Symbol(args, Decl(stringLiteralTypesOverloads03.ts, 38, 11)) + + return undefined; +>undefined : Symbol(undefined) +} + +let gResult1 = g(hello); +>gResult1 : Symbol(gResult1, Decl(stringLiteralTypesOverloads03.ts, 42, 3)) +>g : Symbol(g, Decl(stringLiteralTypesOverloads03.ts, 32, 31), Decl(stringLiteralTypesOverloads03.ts, 34, 28), Decl(stringLiteralTypesOverloads03.ts, 35, 34), Decl(stringLiteralTypesOverloads03.ts, 36, 47), Decl(stringLiteralTypesOverloads03.ts, 37, 34)) +>hello : Symbol(hello, Decl(stringLiteralTypesOverloads03.ts, 18, 3)) + +let gResult2 = g(world); +>gResult2 : Symbol(gResult2, Decl(stringLiteralTypesOverloads03.ts, 43, 3)) +>g : Symbol(g, Decl(stringLiteralTypesOverloads03.ts, 32, 31), Decl(stringLiteralTypesOverloads03.ts, 34, 28), Decl(stringLiteralTypesOverloads03.ts, 35, 34), Decl(stringLiteralTypesOverloads03.ts, 36, 47), Decl(stringLiteralTypesOverloads03.ts, 37, 34)) +>world : Symbol(world, Decl(stringLiteralTypesOverloads03.ts, 19, 3)) + +let gResult3 = g(helloOrWorld); +>gResult3 : Symbol(gResult3, Decl(stringLiteralTypesOverloads03.ts, 44, 3)) +>g : Symbol(g, Decl(stringLiteralTypesOverloads03.ts, 32, 31), Decl(stringLiteralTypesOverloads03.ts, 34, 28), Decl(stringLiteralTypesOverloads03.ts, 35, 34), Decl(stringLiteralTypesOverloads03.ts, 36, 47), Decl(stringLiteralTypesOverloads03.ts, 37, 34)) +>helloOrWorld : Symbol(helloOrWorld, Decl(stringLiteralTypesOverloads03.ts, 20, 3)) + diff --git a/tests/baselines/reference/stringLiteralTypesOverloads03.types b/tests/baselines/reference/stringLiteralTypesOverloads03.types new file mode 100644 index 00000000000..643979ee987 --- /dev/null +++ b/tests/baselines/reference/stringLiteralTypesOverloads03.types @@ -0,0 +1,137 @@ +=== tests/cases/conformance/types/stringLiteral/stringLiteralTypesOverloads03.ts === + +interface Base { +>Base : Base + + x: string; +>x : string + + y: number; +>y : number +} + +interface HelloOrWorld extends Base { +>HelloOrWorld : HelloOrWorld +>Base : Base + + p1: boolean; +>p1 : boolean +} + +interface JustHello extends Base { +>JustHello : JustHello +>Base : Base + + p2: boolean; +>p2 : boolean +} + +interface JustWorld extends Base { +>JustWorld : JustWorld +>Base : Base + + p3: boolean; +>p3 : boolean +} + +let hello: "hello"; +>hello : "hello" + +let world: "world"; +>world : "world" + +let helloOrWorld: "hello" | "world"; +>helloOrWorld : "hello" | "world" + +function f(p: "hello"): JustHello; +>f : { (p: "hello"): JustHello; (p: "hello" | "world"): HelloOrWorld; (p: "world"): JustWorld; (p: string): Base; } +>p : "hello" +>JustHello : JustHello + +function f(p: "hello" | "world"): HelloOrWorld; +>f : { (p: "hello"): JustHello; (p: "hello" | "world"): HelloOrWorld; (p: "world"): JustWorld; (p: string): Base; } +>p : "hello" | "world" +>HelloOrWorld : HelloOrWorld + +function f(p: "world"): JustWorld; +>f : { (p: "hello"): JustHello; (p: "hello" | "world"): HelloOrWorld; (p: "world"): JustWorld; (p: string): Base; } +>p : "world" +>JustWorld : JustWorld + +function f(p: string): Base; +>f : { (p: "hello"): JustHello; (p: "hello" | "world"): HelloOrWorld; (p: "world"): JustWorld; (p: string): Base; } +>p : string +>Base : Base + +function f(...args: any[]): any { +>f : { (p: "hello"): JustHello; (p: "hello" | "world"): HelloOrWorld; (p: "world"): JustWorld; (p: string): Base; } +>args : any[] + + return undefined; +>undefined : undefined +} + +let fResult1 = f(hello); +>fResult1 : JustHello +>f(hello) : JustHello +>f : { (p: "hello"): JustHello; (p: "hello" | "world"): HelloOrWorld; (p: "world"): JustWorld; (p: string): Base; } +>hello : "hello" + +let fResult2 = f(world); +>fResult2 : JustWorld +>f(world) : JustWorld +>f : { (p: "hello"): JustHello; (p: "hello" | "world"): HelloOrWorld; (p: "world"): JustWorld; (p: string): Base; } +>world : "world" + +let fResult3 = f(helloOrWorld); +>fResult3 : HelloOrWorld +>f(helloOrWorld) : HelloOrWorld +>f : { (p: "hello"): JustHello; (p: "hello" | "world"): HelloOrWorld; (p: "world"): JustWorld; (p: string): Base; } +>helloOrWorld : "hello" | "world" + +function g(p: string): Base; +>g : { (p: string): Base; (p: "hello"): JustHello; (p: "hello" | "world"): HelloOrWorld; (p: "world"): JustWorld; } +>p : string +>Base : Base + +function g(p: "hello"): JustHello; +>g : { (p: string): Base; (p: "hello"): JustHello; (p: "hello" | "world"): HelloOrWorld; (p: "world"): JustWorld; } +>p : "hello" +>JustHello : JustHello + +function g(p: "hello" | "world"): HelloOrWorld; +>g : { (p: string): Base; (p: "hello"): JustHello; (p: "hello" | "world"): HelloOrWorld; (p: "world"): JustWorld; } +>p : "hello" | "world" +>HelloOrWorld : HelloOrWorld + +function g(p: "world"): JustWorld; +>g : { (p: string): Base; (p: "hello"): JustHello; (p: "hello" | "world"): HelloOrWorld; (p: "world"): JustWorld; } +>p : "world" +>JustWorld : JustWorld + +function g(...args: any[]): any { +>g : { (p: string): Base; (p: "hello"): JustHello; (p: "hello" | "world"): HelloOrWorld; (p: "world"): JustWorld; } +>args : any[] + + return undefined; +>undefined : undefined +} + +let gResult1 = g(hello); +>gResult1 : JustHello +>g(hello) : JustHello +>g : { (p: string): Base; (p: "hello"): JustHello; (p: "hello" | "world"): HelloOrWorld; (p: "world"): JustWorld; } +>hello : "hello" + +let gResult2 = g(world); +>gResult2 : JustWorld +>g(world) : JustWorld +>g : { (p: string): Base; (p: "hello"): JustHello; (p: "hello" | "world"): HelloOrWorld; (p: "world"): JustWorld; } +>world : "world" + +let gResult3 = g(helloOrWorld); +>gResult3 : Base +>g(helloOrWorld) : Base +>g : { (p: string): Base; (p: "hello"): JustHello; (p: "hello" | "world"): HelloOrWorld; (p: "world"): JustWorld; } +>helloOrWorld : "hello" | "world" + diff --git a/tests/baselines/reference/stringLiteralTypesWithVariousOperators01.js b/tests/baselines/reference/stringLiteralTypesWithVariousOperators01.js new file mode 100644 index 00000000000..1576540e244 --- /dev/null +++ b/tests/baselines/reference/stringLiteralTypesWithVariousOperators01.js @@ -0,0 +1,86 @@ +//// [stringLiteralTypesWithVariousOperators01.ts] + +let abc: "ABC" = "ABC"; +let xyz: "XYZ" = "XYZ"; +let abcOrXyz: "ABC" | "XYZ" = abc || xyz; +let abcOrXyzOrNumber: "ABC" | "XYZ" | number = abcOrXyz || 100; + +let a = "" + abc; +let b = abc + ""; +let c = 10 + abc; +let d = abc + 10; +let e = xyz + abc; +let f = abc + xyz; +let g = true + abc; +let h = abc + true; +let i = abc + abcOrXyz + xyz; +let j = abcOrXyz + abcOrXyz; +let k = +abcOrXyz; +let l = -abcOrXyz; +let m = abcOrXyzOrNumber + ""; +let n = "" + abcOrXyzOrNumber; +let o = abcOrXyzOrNumber + abcOrXyz; +let p = abcOrXyz + abcOrXyzOrNumber; +let q = !abcOrXyzOrNumber; +let r = ~abcOrXyzOrNumber; +let s = abcOrXyzOrNumber < abcOrXyzOrNumber; +let t = abcOrXyzOrNumber >= abcOrXyz; +let u = abc === abcOrXyz; +let v = abcOrXyz === abcOrXyzOrNumber; + +//// [stringLiteralTypesWithVariousOperators01.js] +var abc = "ABC"; +var xyz = "XYZ"; +var abcOrXyz = abc || xyz; +var abcOrXyzOrNumber = abcOrXyz || 100; +var a = "" + abc; +var b = abc + ""; +var c = 10 + abc; +var d = abc + 10; +var e = xyz + abc; +var f = abc + xyz; +var g = true + abc; +var h = abc + true; +var i = abc + abcOrXyz + xyz; +var j = abcOrXyz + abcOrXyz; +var k = +abcOrXyz; +var l = -abcOrXyz; +var m = abcOrXyzOrNumber + ""; +var n = "" + abcOrXyzOrNumber; +var o = abcOrXyzOrNumber + abcOrXyz; +var p = abcOrXyz + abcOrXyzOrNumber; +var q = !abcOrXyzOrNumber; +var r = ~abcOrXyzOrNumber; +var s = abcOrXyzOrNumber < abcOrXyzOrNumber; +var t = abcOrXyzOrNumber >= abcOrXyz; +var u = abc === abcOrXyz; +var v = abcOrXyz === abcOrXyzOrNumber; + + +//// [stringLiteralTypesWithVariousOperators01.d.ts] +declare let abc: "ABC"; +declare let xyz: "XYZ"; +declare let abcOrXyz: "ABC" | "XYZ"; +declare let abcOrXyzOrNumber: "ABC" | "XYZ" | number; +declare let a: string; +declare let b: string; +declare let c: string; +declare let d: string; +declare let e: string; +declare let f: string; +declare let g: string; +declare let h: string; +declare let i: string; +declare let j: string; +declare let k: number; +declare let l: number; +declare let m: string; +declare let n: string; +declare let o: string; +declare let p: string; +declare let q: boolean; +declare let r: number; +declare let s: boolean; +declare let t: boolean; +declare let u: boolean; +declare let v: boolean; diff --git a/tests/baselines/reference/stringLiteralTypesWithVariousOperators01.symbols b/tests/baselines/reference/stringLiteralTypesWithVariousOperators01.symbols new file mode 100644 index 00000000000..cc9c3aa842b --- /dev/null +++ b/tests/baselines/reference/stringLiteralTypesWithVariousOperators01.symbols @@ -0,0 +1,116 @@ +=== tests/cases/conformance/types/stringLiteral/stringLiteralTypesWithVariousOperators01.ts === + +let abc: "ABC" = "ABC"; +>abc : Symbol(abc, Decl(stringLiteralTypesWithVariousOperators01.ts, 1, 3)) + +let xyz: "XYZ" = "XYZ"; +>xyz : Symbol(xyz, Decl(stringLiteralTypesWithVariousOperators01.ts, 2, 3)) + +let abcOrXyz: "ABC" | "XYZ" = abc || xyz; +>abcOrXyz : Symbol(abcOrXyz, Decl(stringLiteralTypesWithVariousOperators01.ts, 3, 3)) +>abc : Symbol(abc, Decl(stringLiteralTypesWithVariousOperators01.ts, 1, 3)) +>xyz : Symbol(xyz, Decl(stringLiteralTypesWithVariousOperators01.ts, 2, 3)) + +let abcOrXyzOrNumber: "ABC" | "XYZ" | number = abcOrXyz || 100; +>abcOrXyzOrNumber : Symbol(abcOrXyzOrNumber, Decl(stringLiteralTypesWithVariousOperators01.ts, 4, 3)) +>abcOrXyz : Symbol(abcOrXyz, Decl(stringLiteralTypesWithVariousOperators01.ts, 3, 3)) + +let a = "" + abc; +>a : Symbol(a, Decl(stringLiteralTypesWithVariousOperators01.ts, 6, 3)) +>abc : Symbol(abc, Decl(stringLiteralTypesWithVariousOperators01.ts, 1, 3)) + +let b = abc + ""; +>b : Symbol(b, Decl(stringLiteralTypesWithVariousOperators01.ts, 7, 3)) +>abc : Symbol(abc, Decl(stringLiteralTypesWithVariousOperators01.ts, 1, 3)) + +let c = 10 + abc; +>c : Symbol(c, Decl(stringLiteralTypesWithVariousOperators01.ts, 8, 3)) +>abc : Symbol(abc, Decl(stringLiteralTypesWithVariousOperators01.ts, 1, 3)) + +let d = abc + 10; +>d : Symbol(d, Decl(stringLiteralTypesWithVariousOperators01.ts, 9, 3)) +>abc : Symbol(abc, Decl(stringLiteralTypesWithVariousOperators01.ts, 1, 3)) + +let e = xyz + abc; +>e : Symbol(e, Decl(stringLiteralTypesWithVariousOperators01.ts, 10, 3)) +>xyz : Symbol(xyz, Decl(stringLiteralTypesWithVariousOperators01.ts, 2, 3)) +>abc : Symbol(abc, Decl(stringLiteralTypesWithVariousOperators01.ts, 1, 3)) + +let f = abc + xyz; +>f : Symbol(f, Decl(stringLiteralTypesWithVariousOperators01.ts, 11, 3)) +>abc : Symbol(abc, Decl(stringLiteralTypesWithVariousOperators01.ts, 1, 3)) +>xyz : Symbol(xyz, Decl(stringLiteralTypesWithVariousOperators01.ts, 2, 3)) + +let g = true + abc; +>g : Symbol(g, Decl(stringLiteralTypesWithVariousOperators01.ts, 12, 3)) +>abc : Symbol(abc, Decl(stringLiteralTypesWithVariousOperators01.ts, 1, 3)) + +let h = abc + true; +>h : Symbol(h, Decl(stringLiteralTypesWithVariousOperators01.ts, 13, 3)) +>abc : Symbol(abc, Decl(stringLiteralTypesWithVariousOperators01.ts, 1, 3)) + +let i = abc + abcOrXyz + xyz; +>i : Symbol(i, Decl(stringLiteralTypesWithVariousOperators01.ts, 14, 3)) +>abc : Symbol(abc, Decl(stringLiteralTypesWithVariousOperators01.ts, 1, 3)) +>abcOrXyz : Symbol(abcOrXyz, Decl(stringLiteralTypesWithVariousOperators01.ts, 3, 3)) +>xyz : Symbol(xyz, Decl(stringLiteralTypesWithVariousOperators01.ts, 2, 3)) + +let j = abcOrXyz + abcOrXyz; +>j : Symbol(j, Decl(stringLiteralTypesWithVariousOperators01.ts, 15, 3)) +>abcOrXyz : Symbol(abcOrXyz, Decl(stringLiteralTypesWithVariousOperators01.ts, 3, 3)) +>abcOrXyz : Symbol(abcOrXyz, Decl(stringLiteralTypesWithVariousOperators01.ts, 3, 3)) + +let k = +abcOrXyz; +>k : Symbol(k, Decl(stringLiteralTypesWithVariousOperators01.ts, 16, 3)) +>abcOrXyz : Symbol(abcOrXyz, Decl(stringLiteralTypesWithVariousOperators01.ts, 3, 3)) + +let l = -abcOrXyz; +>l : Symbol(l, Decl(stringLiteralTypesWithVariousOperators01.ts, 17, 3)) +>abcOrXyz : Symbol(abcOrXyz, Decl(stringLiteralTypesWithVariousOperators01.ts, 3, 3)) + +let m = abcOrXyzOrNumber + ""; +>m : Symbol(m, Decl(stringLiteralTypesWithVariousOperators01.ts, 18, 3)) +>abcOrXyzOrNumber : Symbol(abcOrXyzOrNumber, Decl(stringLiteralTypesWithVariousOperators01.ts, 4, 3)) + +let n = "" + abcOrXyzOrNumber; +>n : Symbol(n, Decl(stringLiteralTypesWithVariousOperators01.ts, 19, 3)) +>abcOrXyzOrNumber : Symbol(abcOrXyzOrNumber, Decl(stringLiteralTypesWithVariousOperators01.ts, 4, 3)) + +let o = abcOrXyzOrNumber + abcOrXyz; +>o : Symbol(o, Decl(stringLiteralTypesWithVariousOperators01.ts, 20, 3)) +>abcOrXyzOrNumber : Symbol(abcOrXyzOrNumber, Decl(stringLiteralTypesWithVariousOperators01.ts, 4, 3)) +>abcOrXyz : Symbol(abcOrXyz, Decl(stringLiteralTypesWithVariousOperators01.ts, 3, 3)) + +let p = abcOrXyz + abcOrXyzOrNumber; +>p : Symbol(p, Decl(stringLiteralTypesWithVariousOperators01.ts, 21, 3)) +>abcOrXyz : Symbol(abcOrXyz, Decl(stringLiteralTypesWithVariousOperators01.ts, 3, 3)) +>abcOrXyzOrNumber : Symbol(abcOrXyzOrNumber, Decl(stringLiteralTypesWithVariousOperators01.ts, 4, 3)) + +let q = !abcOrXyzOrNumber; +>q : Symbol(q, Decl(stringLiteralTypesWithVariousOperators01.ts, 22, 3)) +>abcOrXyzOrNumber : Symbol(abcOrXyzOrNumber, Decl(stringLiteralTypesWithVariousOperators01.ts, 4, 3)) + +let r = ~abcOrXyzOrNumber; +>r : Symbol(r, Decl(stringLiteralTypesWithVariousOperators01.ts, 23, 3)) +>abcOrXyzOrNumber : Symbol(abcOrXyzOrNumber, Decl(stringLiteralTypesWithVariousOperators01.ts, 4, 3)) + +let s = abcOrXyzOrNumber < abcOrXyzOrNumber; +>s : Symbol(s, Decl(stringLiteralTypesWithVariousOperators01.ts, 24, 3)) +>abcOrXyzOrNumber : Symbol(abcOrXyzOrNumber, Decl(stringLiteralTypesWithVariousOperators01.ts, 4, 3)) +>abcOrXyzOrNumber : Symbol(abcOrXyzOrNumber, Decl(stringLiteralTypesWithVariousOperators01.ts, 4, 3)) + +let t = abcOrXyzOrNumber >= abcOrXyz; +>t : Symbol(t, Decl(stringLiteralTypesWithVariousOperators01.ts, 25, 3)) +>abcOrXyzOrNumber : Symbol(abcOrXyzOrNumber, Decl(stringLiteralTypesWithVariousOperators01.ts, 4, 3)) +>abcOrXyz : Symbol(abcOrXyz, Decl(stringLiteralTypesWithVariousOperators01.ts, 3, 3)) + +let u = abc === abcOrXyz; +>u : Symbol(u, Decl(stringLiteralTypesWithVariousOperators01.ts, 26, 3)) +>abc : Symbol(abc, Decl(stringLiteralTypesWithVariousOperators01.ts, 1, 3)) +>abcOrXyz : Symbol(abcOrXyz, Decl(stringLiteralTypesWithVariousOperators01.ts, 3, 3)) + +let v = abcOrXyz === abcOrXyzOrNumber; +>v : Symbol(v, Decl(stringLiteralTypesWithVariousOperators01.ts, 27, 3)) +>abcOrXyz : Symbol(abcOrXyz, Decl(stringLiteralTypesWithVariousOperators01.ts, 3, 3)) +>abcOrXyzOrNumber : Symbol(abcOrXyzOrNumber, Decl(stringLiteralTypesWithVariousOperators01.ts, 4, 3)) + diff --git a/tests/baselines/reference/stringLiteralTypesWithVariousOperators01.types b/tests/baselines/reference/stringLiteralTypesWithVariousOperators01.types new file mode 100644 index 00000000000..90cb538b800 --- /dev/null +++ b/tests/baselines/reference/stringLiteralTypesWithVariousOperators01.types @@ -0,0 +1,152 @@ +=== tests/cases/conformance/types/stringLiteral/stringLiteralTypesWithVariousOperators01.ts === + +let abc: "ABC" = "ABC"; +>abc : "ABC" +>"ABC" : "ABC" + +let xyz: "XYZ" = "XYZ"; +>xyz : "XYZ" +>"XYZ" : "XYZ" + +let abcOrXyz: "ABC" | "XYZ" = abc || xyz; +>abcOrXyz : "ABC" | "XYZ" +>abc || xyz : "ABC" | "XYZ" +>abc : "ABC" +>xyz : "XYZ" + +let abcOrXyzOrNumber: "ABC" | "XYZ" | number = abcOrXyz || 100; +>abcOrXyzOrNumber : "ABC" | "XYZ" | number +>abcOrXyz || 100 : "ABC" | "XYZ" | number +>abcOrXyz : "ABC" | "XYZ" +>100 : number + +let a = "" + abc; +>a : string +>"" + abc : string +>"" : string +>abc : "ABC" + +let b = abc + ""; +>b : string +>abc + "" : string +>abc : "ABC" +>"" : string + +let c = 10 + abc; +>c : string +>10 + abc : string +>10 : number +>abc : "ABC" + +let d = abc + 10; +>d : string +>abc + 10 : string +>abc : "ABC" +>10 : number + +let e = xyz + abc; +>e : string +>xyz + abc : string +>xyz : "XYZ" +>abc : "ABC" + +let f = abc + xyz; +>f : string +>abc + xyz : string +>abc : "ABC" +>xyz : "XYZ" + +let g = true + abc; +>g : string +>true + abc : string +>true : boolean +>abc : "ABC" + +let h = abc + true; +>h : string +>abc + true : string +>abc : "ABC" +>true : boolean + +let i = abc + abcOrXyz + xyz; +>i : string +>abc + abcOrXyz + xyz : string +>abc + abcOrXyz : string +>abc : "ABC" +>abcOrXyz : "ABC" | "XYZ" +>xyz : "XYZ" + +let j = abcOrXyz + abcOrXyz; +>j : string +>abcOrXyz + abcOrXyz : string +>abcOrXyz : "ABC" | "XYZ" +>abcOrXyz : "ABC" | "XYZ" + +let k = +abcOrXyz; +>k : number +>+abcOrXyz : number +>abcOrXyz : "ABC" | "XYZ" + +let l = -abcOrXyz; +>l : number +>-abcOrXyz : number +>abcOrXyz : "ABC" | "XYZ" + +let m = abcOrXyzOrNumber + ""; +>m : string +>abcOrXyzOrNumber + "" : string +>abcOrXyzOrNumber : "ABC" | "XYZ" | number +>"" : string + +let n = "" + abcOrXyzOrNumber; +>n : string +>"" + abcOrXyzOrNumber : string +>"" : string +>abcOrXyzOrNumber : "ABC" | "XYZ" | number + +let o = abcOrXyzOrNumber + abcOrXyz; +>o : string +>abcOrXyzOrNumber + abcOrXyz : string +>abcOrXyzOrNumber : "ABC" | "XYZ" | number +>abcOrXyz : "ABC" | "XYZ" + +let p = abcOrXyz + abcOrXyzOrNumber; +>p : string +>abcOrXyz + abcOrXyzOrNumber : string +>abcOrXyz : "ABC" | "XYZ" +>abcOrXyzOrNumber : "ABC" | "XYZ" | number + +let q = !abcOrXyzOrNumber; +>q : boolean +>!abcOrXyzOrNumber : boolean +>abcOrXyzOrNumber : "ABC" | "XYZ" | number + +let r = ~abcOrXyzOrNumber; +>r : number +>~abcOrXyzOrNumber : number +>abcOrXyzOrNumber : "ABC" | "XYZ" | number + +let s = abcOrXyzOrNumber < abcOrXyzOrNumber; +>s : boolean +>abcOrXyzOrNumber < abcOrXyzOrNumber : boolean +>abcOrXyzOrNumber : "ABC" | "XYZ" | number +>abcOrXyzOrNumber : "ABC" | "XYZ" | number + +let t = abcOrXyzOrNumber >= abcOrXyz; +>t : boolean +>abcOrXyzOrNumber >= abcOrXyz : boolean +>abcOrXyzOrNumber : "ABC" | "XYZ" | number +>abcOrXyz : "ABC" | "XYZ" + +let u = abc === abcOrXyz; +>u : boolean +>abc === abcOrXyz : boolean +>abc : "ABC" +>abcOrXyz : "ABC" | "XYZ" + +let v = abcOrXyz === abcOrXyzOrNumber; +>v : boolean +>abcOrXyz === abcOrXyzOrNumber : boolean +>abcOrXyz : "ABC" | "XYZ" +>abcOrXyzOrNumber : "ABC" | "XYZ" | number + diff --git a/tests/baselines/reference/stringLiteralTypesWithVariousOperators02.errors.txt b/tests/baselines/reference/stringLiteralTypesWithVariousOperators02.errors.txt new file mode 100644 index 00000000000..92afe67df0c --- /dev/null +++ b/tests/baselines/reference/stringLiteralTypesWithVariousOperators02.errors.txt @@ -0,0 +1,57 @@ +tests/cases/conformance/types/stringLiteral/stringLiteralTypesWithVariousOperators02.ts(7,9): error TS2365: Operator '+' cannot be applied to types '"ABC" | "XYZ" | number' and 'number'. +tests/cases/conformance/types/stringLiteral/stringLiteralTypesWithVariousOperators02.ts(8,9): error TS2365: Operator '+' cannot be applied to types 'number' and '"ABC" | "XYZ" | number'. +tests/cases/conformance/types/stringLiteral/stringLiteralTypesWithVariousOperators02.ts(9,9): error TS2365: Operator '+' cannot be applied to types '"ABC" | "XYZ" | number' and '"ABC" | "XYZ" | number'. +tests/cases/conformance/types/stringLiteral/stringLiteralTypesWithVariousOperators02.ts(10,9): error TS2365: Operator '+' cannot be applied to types '"ABC" | "XYZ" | number' and 'boolean'. +tests/cases/conformance/types/stringLiteral/stringLiteralTypesWithVariousOperators02.ts(11,9): error TS2365: Operator '+' cannot be applied to types 'boolean' and '"ABC" | "XYZ" | number'. +tests/cases/conformance/types/stringLiteral/stringLiteralTypesWithVariousOperators02.ts(12,9): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type. +tests/cases/conformance/types/stringLiteral/stringLiteralTypesWithVariousOperators02.ts(13,11): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type. +tests/cases/conformance/types/stringLiteral/stringLiteralTypesWithVariousOperators02.ts(14,9): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/types/stringLiteral/stringLiteralTypesWithVariousOperators02.ts(15,9): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/types/stringLiteral/stringLiteralTypesWithVariousOperators02.ts(16,9): error TS2365: Operator '<' cannot be applied to types '"ABC"' and '"XYZ"'. +tests/cases/conformance/types/stringLiteral/stringLiteralTypesWithVariousOperators02.ts(17,9): error TS2365: Operator '===' cannot be applied to types '"ABC"' and '"XYZ"'. +tests/cases/conformance/types/stringLiteral/stringLiteralTypesWithVariousOperators02.ts(18,9): error TS2365: Operator '!=' cannot be applied to types '"ABC"' and '"XYZ"'. + + +==== tests/cases/conformance/types/stringLiteral/stringLiteralTypesWithVariousOperators02.ts (12 errors) ==== + + let abc: "ABC" = "ABC"; + let xyz: "XYZ" = "XYZ"; + let abcOrXyz: "ABC" | "XYZ" = abc || xyz; + let abcOrXyzOrNumber: "ABC" | "XYZ" | number = abcOrXyz || 100; + + let a = abcOrXyzOrNumber + 100; + ~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2365: Operator '+' cannot be applied to types '"ABC" | "XYZ" | number' and 'number'. + let b = 100 + abcOrXyzOrNumber; + ~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2365: Operator '+' cannot be applied to types 'number' and '"ABC" | "XYZ" | number'. + let c = abcOrXyzOrNumber + abcOrXyzOrNumber; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2365: Operator '+' cannot be applied to types '"ABC" | "XYZ" | number' and '"ABC" | "XYZ" | number'. + let d = abcOrXyzOrNumber + true; + ~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2365: Operator '+' cannot be applied to types '"ABC" | "XYZ" | number' and 'boolean'. + let e = false + abcOrXyzOrNumber; + ~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2365: Operator '+' cannot be applied to types 'boolean' and '"ABC" | "XYZ" | number'. + let f = abcOrXyzOrNumber++; + ~~~~~~~~~~~~~~~~ +!!! error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type. + let g = --abcOrXyzOrNumber; + ~~~~~~~~~~~~~~~~ +!!! error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type. + let h = abcOrXyzOrNumber ^ 10; + ~~~~~~~~~~~~~~~~ +!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + let i = abcOrXyzOrNumber | 10; + ~~~~~~~~~~~~~~~~ +!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + let j = abc < xyz; + ~~~~~~~~~ +!!! error TS2365: Operator '<' cannot be applied to types '"ABC"' and '"XYZ"'. + let k = abc === xyz; + ~~~~~~~~~~~ +!!! error TS2365: Operator '===' cannot be applied to types '"ABC"' and '"XYZ"'. + let l = abc != xyz; + ~~~~~~~~~~ +!!! error TS2365: Operator '!=' cannot be applied to types '"ABC"' and '"XYZ"'. \ No newline at end of file diff --git a/tests/baselines/reference/stringLiteralTypesWithVariousOperators02.js b/tests/baselines/reference/stringLiteralTypesWithVariousOperators02.js new file mode 100644 index 00000000000..4914ecf3d17 --- /dev/null +++ b/tests/baselines/reference/stringLiteralTypesWithVariousOperators02.js @@ -0,0 +1,56 @@ +//// [stringLiteralTypesWithVariousOperators02.ts] + +let abc: "ABC" = "ABC"; +let xyz: "XYZ" = "XYZ"; +let abcOrXyz: "ABC" | "XYZ" = abc || xyz; +let abcOrXyzOrNumber: "ABC" | "XYZ" | number = abcOrXyz || 100; + +let a = abcOrXyzOrNumber + 100; +let b = 100 + abcOrXyzOrNumber; +let c = abcOrXyzOrNumber + abcOrXyzOrNumber; +let d = abcOrXyzOrNumber + true; +let e = false + abcOrXyzOrNumber; +let f = abcOrXyzOrNumber++; +let g = --abcOrXyzOrNumber; +let h = abcOrXyzOrNumber ^ 10; +let i = abcOrXyzOrNumber | 10; +let j = abc < xyz; +let k = abc === xyz; +let l = abc != xyz; + +//// [stringLiteralTypesWithVariousOperators02.js] +var abc = "ABC"; +var xyz = "XYZ"; +var abcOrXyz = abc || xyz; +var abcOrXyzOrNumber = abcOrXyz || 100; +var a = abcOrXyzOrNumber + 100; +var b = 100 + abcOrXyzOrNumber; +var c = abcOrXyzOrNumber + abcOrXyzOrNumber; +var d = abcOrXyzOrNumber + true; +var e = false + abcOrXyzOrNumber; +var f = abcOrXyzOrNumber++; +var g = --abcOrXyzOrNumber; +var h = abcOrXyzOrNumber ^ 10; +var i = abcOrXyzOrNumber | 10; +var j = abc < xyz; +var k = abc === xyz; +var l = abc != xyz; + + +//// [stringLiteralTypesWithVariousOperators02.d.ts] +declare let abc: "ABC"; +declare let xyz: "XYZ"; +declare let abcOrXyz: "ABC" | "XYZ"; +declare let abcOrXyzOrNumber: "ABC" | "XYZ" | number; +declare let a: any; +declare let b: any; +declare let c: any; +declare let d: any; +declare let e: any; +declare let f: number; +declare let g: number; +declare let h: number; +declare let i: number; +declare let j: boolean; +declare let k: boolean; +declare let l: boolean; From d2e2a55a9ed8e212c1c196a33c9163f8c8bf7da8 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Thu, 8 Oct 2015 14:36:36 -0700 Subject: [PATCH 056/227] Added fourslash test. --- ...ickInfoDisplayPartsVarWithStringTypes01.ts | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 tests/cases/fourslash/quickInfoDisplayPartsVarWithStringTypes01.ts diff --git a/tests/cases/fourslash/quickInfoDisplayPartsVarWithStringTypes01.ts b/tests/cases/fourslash/quickInfoDisplayPartsVarWithStringTypes01.ts new file mode 100644 index 00000000000..b48c7cfa3de --- /dev/null +++ b/tests/cases/fourslash/quickInfoDisplayPartsVarWithStringTypes01.ts @@ -0,0 +1,41 @@ +/// + +////let /*1*/hello: "hello" | 'hello' = "hello"; +////let /*2*/world: 'world' = "world"; +////let /*3*/helloOrWorld: "hello" | 'world'; + +goTo.marker("1"); +verify.verifyQuickInfoDisplayParts("let", "", { start: test.markerByName('1').position, length: "hello".length }, [ + { text: "let", kind: "keyword" }, + { text: " ", kind: "space" }, + { text: "hello", kind: "localName" }, + { text: ":", kind: "punctuation" }, + { text: " ", kind: "space" }, + { text: '"hello"', kind: "stringLiteral" }, ], + /*documentation*/ []); + +goTo.marker("2"); +verify.verifyQuickInfoDisplayParts("let", "", { start: test.markerByName('2').position, length: "world".length }, [ + { text: "let", kind: "keyword" }, + { text: " ", kind: "space" }, + { text: "world", kind: "localName" }, + { text: ":", kind: "punctuation" }, + { text: " ", kind: "space" }, + { text: '"world"', kind: "stringLiteral" }, + ], + /*documentation*/[]); + +goTo.marker("3"); +verify.verifyQuickInfoDisplayParts("let", "", { start: test.markerByName('3').position, length: "helloOrWorld".length }, [ + { text: "let", kind: "keyword" }, + { text: " ", kind: "space" }, + { text: "helloOrWorld", kind: "localName" }, + { text: ":", kind: "punctuation" }, + { text: " ", kind: "space" }, + { text: '"hello"', kind: "stringLiteral" }, + { text: " ", kind: "space" }, + { text: "|", kind: "punctuation" }, + { text: " ", kind: "space" }, + { text: '"world"', kind: "stringLiteral" }, + ], + /*documentation*/[]); \ No newline at end of file From 74ac57ddfcdca56e037ca7019f06b288560df43a Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Thu, 8 Oct 2015 15:26:00 -0700 Subject: [PATCH 057/227] Accepted post-merge baselines. --- .../parserErrorRecovery_IncompleteMemberVariable1.symbols | 6 +++--- .../parserErrorRecovery_IncompleteMemberVariable1.types | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/tests/baselines/reference/parserErrorRecovery_IncompleteMemberVariable1.symbols b/tests/baselines/reference/parserErrorRecovery_IncompleteMemberVariable1.symbols index db9cefbf642..7b8be05f923 100644 --- a/tests/baselines/reference/parserErrorRecovery_IncompleteMemberVariable1.symbols +++ b/tests/baselines/reference/parserErrorRecovery_IncompleteMemberVariable1.symbols @@ -27,9 +27,9 @@ module Shapes { // Instance member getDist() { return Math.sqrt(this.x * this.x + this.y * this.y); } >getDist : Symbol(getDist, Decl(parserErrorRecovery_IncompleteMemberVariable1.ts, 13, 60)) ->Math.sqrt : Symbol(Math.sqrt, Decl(lib.d.ts, 620, 27)) ->Math : Symbol(Math, Decl(lib.d.ts, 522, 1), Decl(lib.d.ts, 633, 11)) ->sqrt : Symbol(Math.sqrt, Decl(lib.d.ts, 620, 27)) +>Math.sqrt : Symbol(Math.sqrt, Decl(lib.d.ts, --, --)) +>Math : Symbol(Math, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>sqrt : Symbol(Math.sqrt, Decl(lib.d.ts, --, --)) >this.x : Symbol(x, Decl(parserErrorRecovery_IncompleteMemberVariable1.ts, 13, 21)) >this : Symbol(Point, Decl(parserErrorRecovery_IncompleteMemberVariable1.ts, 6, 15)) >x : Symbol(x, Decl(parserErrorRecovery_IncompleteMemberVariable1.ts, 13, 21)) diff --git a/tests/baselines/reference/parserErrorRecovery_IncompleteMemberVariable1.types b/tests/baselines/reference/parserErrorRecovery_IncompleteMemberVariable1.types index bb51151cfd7..b38bbbfe64d 100644 --- a/tests/baselines/reference/parserErrorRecovery_IncompleteMemberVariable1.types +++ b/tests/baselines/reference/parserErrorRecovery_IncompleteMemberVariable1.types @@ -34,17 +34,17 @@ module Shapes { >this.x * this.x + this.y * this.y : number >this.x * this.x : number >this.x : number ->this : Point +>this : this >x : number >this.x : number ->this : Point +>this : this >x : number >this.y * this.y : number >this.y : number ->this : Point +>this : this >y : number >this.y : number ->this : Point +>this : this >y : number // Static member From 61ece765c74f7cf48a7b61c9137405e206bd1766 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Thu, 8 Oct 2015 15:27:12 -0700 Subject: [PATCH 058/227] Return the string literal type itself instead of the union type. --- 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 bf8072bf2a5..3b43533e56b 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -10292,7 +10292,7 @@ namespace ts { if (contextualType.flags & TypeFlags.Union) { for (const type of (contextualType).types) { if (type.flags & TypeFlags.StringLiteral && (type).text === node.text) { - return contextualType; + return type; } } } From 84b64c4c670676b06cbf98891c85ab8c9f537182 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Thu, 8 Oct 2015 15:34:46 -0700 Subject: [PATCH 059/227] Accepted baselines. --- tests/baselines/reference/stringLiteralTypesAndTuples01.types | 4 ++-- .../reference/stringLiteralTypesInUnionTypes01.types | 4 ++-- .../reference/stringLiteralTypesInUnionTypes02.types | 4 ++-- .../reference/stringLiteralTypesInUnionTypes04.types | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/tests/baselines/reference/stringLiteralTypesAndTuples01.types b/tests/baselines/reference/stringLiteralTypesAndTuples01.types index 740cf237412..c874973e3e5 100644 --- a/tests/baselines/reference/stringLiteralTypesAndTuples01.types +++ b/tests/baselines/reference/stringLiteralTypesAndTuples01.types @@ -20,10 +20,10 @@ let [im, a, dinosaur]: ["I'm", "a", RexOrRaptor] = ['I\'m', 'a', 't-rex']; >a : "a" >dinosaur : "t-rex" | "raptor" >RexOrRaptor : "t-rex" | "raptor" ->['I\'m', 'a', 't-rex'] : ["I'm", "a", "t-rex" | "raptor"] +>['I\'m', 'a', 't-rex'] : ["I'm", "a", "t-rex"] >'I\'m' : "I'm" >'a' : "a" ->'t-rex' : "t-rex" | "raptor" +>'t-rex' : "t-rex" rawr(dinosaur); >rawr(dinosaur) : string diff --git a/tests/baselines/reference/stringLiteralTypesInUnionTypes01.types b/tests/baselines/reference/stringLiteralTypesInUnionTypes01.types index b5a2d876bcc..e5ff509822b 100644 --- a/tests/baselines/reference/stringLiteralTypesInUnionTypes01.types +++ b/tests/baselines/reference/stringLiteralTypesInUnionTypes01.types @@ -5,12 +5,12 @@ type T = "foo" | "bar" | "baz"; var x: "foo" | "bar" | "baz" = "foo"; >x : "foo" | "bar" | "baz" ->"foo" : "foo" | "bar" | "baz" +>"foo" : "foo" var y: T = "bar"; >y : "foo" | "bar" | "baz" >T : "foo" | "bar" | "baz" ->"bar" : "foo" | "bar" | "baz" +>"bar" : "bar" if (x === "foo") { >x === "foo" : boolean diff --git a/tests/baselines/reference/stringLiteralTypesInUnionTypes02.types b/tests/baselines/reference/stringLiteralTypesInUnionTypes02.types index e3ac5ba4817..b468c620376 100644 --- a/tests/baselines/reference/stringLiteralTypesInUnionTypes02.types +++ b/tests/baselines/reference/stringLiteralTypesInUnionTypes02.types @@ -5,12 +5,12 @@ type T = string | "foo" | "bar" | "baz"; var x: "foo" | "bar" | "baz" | string = "foo"; >x : "foo" | "bar" | "baz" | string ->"foo" : "foo" | "bar" | "baz" | string +>"foo" : "foo" var y: T = "bar"; >y : string | "foo" | "bar" | "baz" >T : string | "foo" | "bar" | "baz" ->"bar" : string | "foo" | "bar" | "baz" +>"bar" : "bar" if (x === "foo") { >x === "foo" : boolean diff --git a/tests/baselines/reference/stringLiteralTypesInUnionTypes04.types b/tests/baselines/reference/stringLiteralTypesInUnionTypes04.types index 9a010b490cc..ad92dc360d0 100644 --- a/tests/baselines/reference/stringLiteralTypesInUnionTypes04.types +++ b/tests/baselines/reference/stringLiteralTypesInUnionTypes04.types @@ -6,12 +6,12 @@ type T = "" | "foo"; let x: T = ""; >x : "" | "foo" >T : "" | "foo" ->"" : "" | "foo" +>"" : "" let y: T = "foo"; >y : "" | "foo" >T : "" | "foo" ->"foo" : "" | "foo" +>"foo" : "foo" if (x === "") { >x === "" : boolean From 3788254fdc23e51f90d00444e02062671d89871d Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Thu, 8 Oct 2015 15:49:32 -0700 Subject: [PATCH 060/227] Semicolon. --- src/compiler/parser.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 5726d260876..dcc924d29b4 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -2366,7 +2366,7 @@ namespace ts { let node = tryParse(parseKeywordAndNoDot); return node || parseTypeReferenceOrTypePredicate(); case SyntaxKind.StringLiteral: - return parseLiteralNode(/*internName*/ true) + return parseLiteralNode(/*internName*/ true); case SyntaxKind.VoidKeyword: case SyntaxKind.ThisKeyword: return parseTokenNode(); From ebc47d5e0213d31c7eee6111b7c9f09078c8f1ae Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Thu, 8 Oct 2015 16:04:09 -0700 Subject: [PATCH 061/227] Linting. --- src/compiler/checker.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 3b43533e56b..be8a486cf65 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -10286,7 +10286,7 @@ namespace ts { function checkStringLiteralExpression(node: LiteralExpression) { // TODO (drosen): Do we want to apply the same approach to no-sub template literals? - + let contextualType = getContextualType(node); if (contextualType) { if (contextualType.flags & TypeFlags.Union) { @@ -10435,7 +10435,7 @@ namespace ts { case SyntaxKind.StringLiteral: return checkStringLiteralExpression(node); case SyntaxKind.NoSubstitutionTemplateLiteral: - return stringType + return stringType; case SyntaxKind.RegularExpressionLiteral: return globalRegExpType; case SyntaxKind.ArrayLiteralExpression: From 17716fb54015a0672af3b4c0b897d35b1471ee6d Mon Sep 17 00:00:00 2001 From: Vladimir Matveev Date: Tue, 13 Oct 2015 09:06:58 -0700 Subject: [PATCH 062/227] accepted baselines --- .../compoundExponentiationAssignmentLHSIsValue.errors.txt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/baselines/reference/compoundExponentiationAssignmentLHSIsValue.errors.txt b/tests/baselines/reference/compoundExponentiationAssignmentLHSIsValue.errors.txt index bee6f75ff5c..23720468bb7 100644 --- a/tests/baselines/reference/compoundExponentiationAssignmentLHSIsValue.errors.txt +++ b/tests/baselines/reference/compoundExponentiationAssignmentLHSIsValue.errors.txt @@ -13,6 +13,7 @@ tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignm tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSIsValue.ts(38,1): error TS2364: Invalid left-hand side of assignment expression. tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSIsValue.ts(39,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSIsValue.ts(40,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSIsValue.ts(43,3): error TS7028: Unused label. tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSIsValue.ts(43,10): error TS1128: Declaration or statement expected. tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSIsValue.ts(46,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSIsValue.ts(52,15): error TS1034: 'super' must be followed by an argument list or member access. @@ -37,7 +38,7 @@ tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignm tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSIsValue.ts(85,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -==== tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSIsValue.ts (37 errors) ==== +==== tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSIsValue.ts (38 errors) ==== // expected error for all the LHS of compound assignments (arithmetic and addition) var value; @@ -111,6 +112,8 @@ tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignm // object literals { a: 0 } **= value; + ~ +!!! error TS7028: Unused label. ~~~ !!! error TS1128: Declaration or statement expected. From bc02341e9932411e01b36134f611d511f00d1cc8 Mon Sep 17 00:00:00 2001 From: Vladimir Matveev Date: Tue, 13 Oct 2015 10:15:39 -0700 Subject: [PATCH 063/227] addressed PR feedback, updated tests to suppress reachability errors where they are not needed --- src/compiler/binder.ts | 103 +- src/compiler/types.ts | 4 +- .../bestCommonTypeReturnStatement.errors.txt | 18 - .../bestCommonTypeReturnStatement.js | 1 + .../bestCommonTypeReturnStatement.symbols | 35 + .../bestCommonTypeReturnStatement.types | 40 + .../reference/breakTarget3.errors.txt | 11 - tests/baselines/reference/breakTarget3.js | 1 + .../baselines/reference/breakTarget3.symbols | 8 + tests/baselines/reference/breakTarget3.types | 14 + .../reference/breakTarget4.errors.txt | 11 - tests/baselines/reference/breakTarget4.js | 1 + .../baselines/reference/breakTarget4.symbols | 8 + tests/baselines/reference/breakTarget4.types | 14 + .../reference/breakTarget5.errors.txt | 8 +- tests/baselines/reference/breakTarget5.js | 1 + ...utReturnTypeAnnotationInference.errors.txt | 126 - ...ureWithoutReturnTypeAnnotationInference.js | 1 + ...thoutReturnTypeAnnotationInference.symbols | 256 ++ ...WithoutReturnTypeAnnotationInference.types | 297 ++ .../reference/commentEmitAtEndOfFile1.js | 1 + .../reference/commentEmitAtEndOfFile1.symbols | 9 +- .../reference/commentEmitAtEndOfFile1.types | 1 + .../compoundAssignmentLHSIsValue.errors.txt | 122 +- .../reference/compoundAssignmentLHSIsValue.js | 1 + .../conditionalExpressions2.errors.txt | 15 - .../reference/conditionalExpressions2.js | 1 + .../reference/conditionalExpressions2.symbols | 34 + .../reference/conditionalExpressions2.types | 69 + ...nstDeclarations-invalidContexts.errors.txt | 8 +- ...constDeclarations-validContexts.errors.txt | 8 +- ...torWithIncompleteTypeAnnotation.errors.txt | 171 +- ...constructorWithIncompleteTypeAnnotation.js | 1 + ...ontinueNotInIterationStatement4.errors.txt | 8 +- .../continueNotInIterationStatement4.js | 1 + .../reference/continueTarget3.errors.txt | 11 - tests/baselines/reference/continueTarget3.js | 1 + .../reference/continueTarget3.symbols | 8 + .../baselines/reference/continueTarget3.types | 14 + .../reference/continueTarget4.errors.txt | 11 - tests/baselines/reference/continueTarget4.js | 1 + .../reference/continueTarget4.symbols | 8 + .../baselines/reference/continueTarget4.types | 14 + .../reference/continueTarget5.errors.txt | 8 +- tests/baselines/reference/continueTarget5.js | 1 + .../doWhileBreakStatements.errors.txt | 50 - .../reference/doWhileBreakStatements.js | 1 + .../reference/doWhileBreakStatements.symbols | 42 + .../reference/doWhileBreakStatements.types | 81 + .../doWhileContinueStatements.errors.txt | 44 - .../reference/doWhileContinueStatements.js | 1 + .../doWhileContinueStatements.symbols | 42 + .../reference/doWhileContinueStatements.types | 81 + .../reference/downlevelLetConst16.errors.txt | 21 +- .../reference/downlevelLetConst16.js | 1 + .../reference/downlevelLetConst17.errors.txt | 73 - .../reference/downlevelLetConst17.symbols | 134 + .../reference/downlevelLetConst17.types | 169 + .../reference/downlevelLetConst18.errors.txt | 24 +- .../reference/downlevelLetConst18.js | 1 + .../reference/duplicateLabel1.errors.txt | 8 +- tests/baselines/reference/duplicateLabel1.js | 1 + .../reference/duplicateLabel2.errors.txt | 8 +- tests/baselines/reference/duplicateLabel2.js | 1 + .../reference/duplicateLabel3.errors.txt | 17 - tests/baselines/reference/duplicateLabel3.js | 1 + .../reference/duplicateLabel3.symbols | 12 + .../baselines/reference/duplicateLabel3.types | 19 + .../reference/duplicateLabel4.errors.txt | 16 - tests/baselines/reference/duplicateLabel4.js | 1 + .../reference/duplicateLabel4.symbols | 10 + .../baselines/reference/duplicateLabel4.types | 15 + .../duplicateLocalVariable1.errors.txt | 24 +- .../reference/duplicateLocalVariable1.js | 6 +- .../duplicateVariablesByScope.errors.txt | 37 - .../reference/duplicateVariablesByScope.js | 1 + .../duplicateVariablesByScope.symbols | 57 + .../reference/duplicateVariablesByScope.types | 73 + .../es6ClassSuperCodegenBug.errors.txt | 19 - .../reference/es6ClassSuperCodegenBug.js | 1 + .../reference/es6ClassSuperCodegenBug.symbols | 25 + .../reference/es6ClassSuperCodegenBug.types | 33 + .../reference/escapedIdentifiers.errors.txt | 146 - .../baselines/reference/escapedIdentifiers.js | 1 + .../reference/escapedIdentifiers.symbols | 261 ++ .../reference/escapedIdentifiers.types | 352 ++ tests/baselines/reference/for.errors.txt | 8 +- tests/baselines/reference/for.js | 1 + .../reference/forBreakStatements.errors.txt | 49 - .../baselines/reference/forBreakStatements.js | 1 + .../reference/forBreakStatements.symbols | 41 + .../reference/forBreakStatements.types | 64 + .../forContinueStatements.errors.txt | 43 - .../reference/forContinueStatements.js | 1 + .../reference/forContinueStatements.symbols | 41 + .../reference/forContinueStatements.types | 64 + .../reference/forInBreakStatements.errors.txt | 46 - .../reference/forInBreakStatements.js | 1 + .../reference/forInBreakStatements.symbols | 59 + .../reference/forInBreakStatements.types | 93 + .../forInContinueStatements.errors.txt | 46 - .../reference/forInContinueStatements.js | 1 + .../reference/forInContinueStatements.symbols | 59 + .../reference/forInContinueStatements.types | 93 + .../reference/forStatements.errors.txt | 52 - tests/baselines/reference/forStatements.js | 1 + .../baselines/reference/forStatements.symbols | 146 + tests/baselines/reference/forStatements.types | 165 + ...orStatementsMultipleInvalidDecl.errors.txt | 30 +- .../forStatementsMultipleInvalidDecl.js | 1 + .../forStatementsMultipleValidDecl.errors.txt | 39 - .../forStatementsMultipleValidDecl.js | 1 + .../forStatementsMultipleValidDecl.symbols | 111 + .../forStatementsMultipleValidDecl.types | 141 + .../functionImplementationErrors.errors.txt | 62 +- .../reference/functionImplementationErrors.js | 1 + .../functionImplementations.errors.txt | 183 - .../reference/functionImplementations.js | 1 + .../reference/functionImplementations.symbols | 345 ++ .../reference/functionImplementations.types | 417 ++ .../reference/functionOverloads12.errors.txt | 10 - .../reference/functionOverloads12.js | 1 + .../reference/functionOverloads12.symbols | 11 + .../reference/functionOverloads12.types | 14 + .../reference/functionReturn.errors.txt | 23 - tests/baselines/reference/functionReturn.js | 1 + .../reference/functionReturn.symbols | 31 + .../baselines/reference/functionReturn.types | 36 + ...ionWithMultipleReturnStatements.errors.txt | 36 +- .../functionWithMultipleReturnStatements.js | 1 + ...onWithMultipleReturnStatements2.errors.txt | 31 +- .../functionWithMultipleReturnStatements2.js | 1 + .../functionWithNoBestCommonType1.errors.txt | 8 +- .../functionWithNoBestCommonType1.js | 1 + .../functionWithNoBestCommonType2.errors.txt | 8 +- .../functionWithNoBestCommonType2.js | 1 + ...gReturnStatementsAndExpressions.errors.txt | 18 +- ...nsMissingReturnStatementsAndExpressions.js | 1 + .../generatedContextualTyping.errors.txt | 393 -- .../reference/generatedContextualTyping.js | 1 + .../generatedContextualTyping.symbols | 2832 +++++++++++++ .../reference/generatedContextualTyping.types | 3769 +++++++++++++++++ .../reference/ifDoWhileStatements.errors.txt | 168 - .../reference/ifDoWhileStatements.js | 1 + .../reference/ifDoWhileStatements.symbols | 337 ++ .../reference/ifDoWhileStatements.types | 434 ++ .../ifElseWithStatements1.errors.txt | 13 +- .../reference/ifElseWithStatements1.js | 1 + ...edFunctionReturnTypeIsEmptyType.errors.txt | 8 +- .../inferredFunctionReturnTypeIsEmptyType.js | 1 + ...taticPropertyOverridingAccessor.errors.txt | 10 +- ...ritanceStaticPropertyOverridingAccessor.js | 1 + .../interfaceExtendingClass2.errors.txt | 14 +- .../reference/interfaceExtendingClass2.js | 1 + .../interfaceWithPrivateMember.errors.txt | 16 +- .../reference/interfaceWithPrivateMember.js | 1 + .../invalidDoWhileBreakStatements.errors.txt | 21 +- .../invalidDoWhileBreakStatements.js | 1 + ...nvalidDoWhileContinueStatements.errors.txt | 21 +- .../invalidDoWhileContinueStatements.js | 1 + .../invalidForBreakStatements.errors.txt | 21 +- .../reference/invalidForBreakStatements.js | 1 + .../invalidForContinueStatements.errors.txt | 21 +- .../reference/invalidForContinueStatements.js | 1 + .../invalidForInBreakStatements.errors.txt | 30 +- .../reference/invalidForInBreakStatements.js | 1 + .../invalidForInContinueStatements.errors.txt | 30 +- .../invalidForInContinueStatements.js | 1 + .../invalidThrowStatement.errors.txt | 10 +- .../reference/invalidThrowStatement.js | 1 + .../invalidWhileContinueStatements.errors.txt | 21 +- .../invalidWhileContinueStatements.js | 1 + .../letAndVarRedeclaration.errors.txt | 42 +- .../reference/letAndVarRedeclaration.js | 1 + ...letDeclarations-invalidContexts.errors.txt | 27 +- .../letDeclarations-invalidContexts.js | 1 + .../letDeclarations-scopes.errors.txt | 14 +- .../reference/letDeclarations-scopes.js | 1 + .../letDeclarations-validContexts.errors.txt | 23 +- .../letDeclarations-validContexts.js | 1 + .../reference/localTypes4.errors.txt | 14 +- tests/baselines/reference/localTypes4.js | 1 + tests/baselines/reference/null.errors.txt | 30 - tests/baselines/reference/null.js | 1 + tests/baselines/reference/null.symbols | 45 + tests/baselines/reference/null.types | 60 + ...overloadOnConstAsTypeAnnotation.errors.txt | 12 +- .../overloadOnConstAsTypeAnnotation.js | 1 + .../reference/parser10.1.1-8gs.errors.txt | 10 +- tests/baselines/reference/parser10.1.1-8gs.js | 1 + .../reference/parser768531.errors.txt | 8 - tests/baselines/reference/parser768531.js | 1 + .../baselines/reference/parser768531.symbols | 5 + tests/baselines/reference/parser768531.types | 9 + .../reference/whileBreakStatements.errors.txt | 54 - .../reference/whileBreakStatements.js | 1 + .../reference/whileBreakStatements.symbols | 46 + .../reference/whileBreakStatements.types | 90 + .../compiler/bestCommonTypeReturnStatement.ts | 2 + tests/cases/compiler/breakTarget3.ts | 2 + tests/cases/compiler/breakTarget4.ts | 2 + tests/cases/compiler/breakTarget5.ts | 2 + .../cases/compiler/commentEmitAtEndOfFile1.ts | 2 + .../cases/compiler/conditionalExpressions2.ts | 2 + .../constDeclarations-invalidContexts.ts | 1 + .../constDeclarations-validContexts.ts | 1 + ...constructorWithIncompleteTypeAnnotation.ts | 2 + .../continueNotInIterationStatement4.ts | 2 + tests/cases/compiler/continueTarget3.ts | 2 + tests/cases/compiler/continueTarget4.ts | 2 + tests/cases/compiler/continueTarget5.ts | 2 + tests/cases/compiler/downlevelLetConst16.ts | 2 + tests/cases/compiler/downlevelLetConst17.ts | 1 + tests/cases/compiler/downlevelLetConst18.ts | 2 + tests/cases/compiler/duplicateLabel1.ts | 2 + tests/cases/compiler/duplicateLabel2.ts | 2 + tests/cases/compiler/duplicateLabel3.ts | 2 + tests/cases/compiler/duplicateLabel4.ts | 3 + .../cases/compiler/duplicateLocalVariable1.ts | 4 +- .../compiler/duplicateVariablesByScope.ts | 2 + .../cases/compiler/es6ClassSuperCodegenBug.ts | 2 + tests/cases/compiler/escapedIdentifiers.ts | 3 + tests/cases/compiler/for.ts | 2 + tests/cases/compiler/functionOverloads12.ts | 2 + tests/cases/compiler/functionReturn.ts | 2 + .../compiler/functionWithNoBestCommonType1.ts | 2 + .../compiler/functionWithNoBestCommonType2.ts | 2 + ...nsMissingReturnStatementsAndExpressions.ts | 2 + tests/cases/compiler/ifElseWithStatements1.ts | 2 + .../inferredFunctionReturnTypeIsEmptyType.ts | 2 + ...ritanceStaticPropertyOverridingAccessor.ts | 2 + .../cases/compiler/letAndVarRedeclaration.ts | 2 + .../letDeclarations-invalidContexts.ts | 2 + .../cases/compiler/letDeclarations-scopes.ts | 3 + .../compiler/letDeclarations-validContexts.ts | 3 + tests/cases/compiler/null.ts | 2 + .../overloadOnConstAsTypeAnnotation.ts | 2 + .../compoundAssignmentLHSIsValue.ts | 2 + .../generatedContextualTyping.ts | 2 + .../functions/functionImplementationErrors.ts | 2 + .../functions/functionImplementations.ts | 2 + .../interfaceExtendingClass2.ts | 2 + .../parser/ecmascript5/Fuzz/parser768531.ts | 2 + .../parser/ecmascript5/parser10.1.1-8gs.ts | 2 + .../breakStatements/doWhileBreakStatements.ts | 3 + .../breakStatements/forBreakStatements.ts | 3 + .../breakStatements/forInBreakStatements.ts | 2 + .../invalidDoWhileBreakStatements.ts | 3 + .../invalidForBreakStatements.ts | 3 + .../invalidForInBreakStatements.ts | 3 + .../breakStatements/whileBreakStatements.ts | 3 + .../doWhileContinueStatements.ts | 2 + .../forContinueStatements.ts | 2 + .../forInContinueStatements.ts | 2 + .../invalidDoWhileContinueStatements.ts | 3 + .../invalidForContinueStatements.ts | 3 + .../invalidForInContinueStatements.ts | 3 + .../invalidWhileContinueStatements.ts | 3 + .../statements/forStatements/forStatements.ts | 2 + .../forStatementsMultipleInvalidDecl.ts | 2 + .../forStatementsMultipleValidDecl.ts | 2 + .../ifDoWhileStatements.ts | 2 + .../throwStatements/invalidThrowStatement.ts | 2 + .../types/localTypes/localTypes4.ts | 2 + .../namedTypes/interfaceWithPrivateMember.ts | 2 + ...ureWithoutReturnTypeAnnotationInference.ts | 2 + .../functionWithMultipleReturnStatements.ts | 2 + .../functionWithMultipleReturnStatements2.ts | 2 + 268 files changed, 12446 insertions(+), 2425 deletions(-) delete mode 100644 tests/baselines/reference/bestCommonTypeReturnStatement.errors.txt create mode 100644 tests/baselines/reference/bestCommonTypeReturnStatement.symbols create mode 100644 tests/baselines/reference/bestCommonTypeReturnStatement.types delete mode 100644 tests/baselines/reference/breakTarget3.errors.txt create mode 100644 tests/baselines/reference/breakTarget3.symbols create mode 100644 tests/baselines/reference/breakTarget3.types delete mode 100644 tests/baselines/reference/breakTarget4.errors.txt create mode 100644 tests/baselines/reference/breakTarget4.symbols create mode 100644 tests/baselines/reference/breakTarget4.types delete mode 100644 tests/baselines/reference/callSignatureWithoutReturnTypeAnnotationInference.errors.txt create mode 100644 tests/baselines/reference/callSignatureWithoutReturnTypeAnnotationInference.symbols create mode 100644 tests/baselines/reference/callSignatureWithoutReturnTypeAnnotationInference.types delete mode 100644 tests/baselines/reference/conditionalExpressions2.errors.txt create mode 100644 tests/baselines/reference/conditionalExpressions2.symbols create mode 100644 tests/baselines/reference/conditionalExpressions2.types delete mode 100644 tests/baselines/reference/continueTarget3.errors.txt create mode 100644 tests/baselines/reference/continueTarget3.symbols create mode 100644 tests/baselines/reference/continueTarget3.types delete mode 100644 tests/baselines/reference/continueTarget4.errors.txt create mode 100644 tests/baselines/reference/continueTarget4.symbols create mode 100644 tests/baselines/reference/continueTarget4.types delete mode 100644 tests/baselines/reference/doWhileBreakStatements.errors.txt create mode 100644 tests/baselines/reference/doWhileBreakStatements.symbols create mode 100644 tests/baselines/reference/doWhileBreakStatements.types delete mode 100644 tests/baselines/reference/doWhileContinueStatements.errors.txt create mode 100644 tests/baselines/reference/doWhileContinueStatements.symbols create mode 100644 tests/baselines/reference/doWhileContinueStatements.types delete mode 100644 tests/baselines/reference/downlevelLetConst17.errors.txt create mode 100644 tests/baselines/reference/downlevelLetConst17.symbols create mode 100644 tests/baselines/reference/downlevelLetConst17.types delete mode 100644 tests/baselines/reference/duplicateLabel3.errors.txt create mode 100644 tests/baselines/reference/duplicateLabel3.symbols create mode 100644 tests/baselines/reference/duplicateLabel3.types delete mode 100644 tests/baselines/reference/duplicateLabel4.errors.txt create mode 100644 tests/baselines/reference/duplicateLabel4.symbols create mode 100644 tests/baselines/reference/duplicateLabel4.types delete mode 100644 tests/baselines/reference/duplicateVariablesByScope.errors.txt create mode 100644 tests/baselines/reference/duplicateVariablesByScope.symbols create mode 100644 tests/baselines/reference/duplicateVariablesByScope.types delete mode 100644 tests/baselines/reference/es6ClassSuperCodegenBug.errors.txt create mode 100644 tests/baselines/reference/es6ClassSuperCodegenBug.symbols create mode 100644 tests/baselines/reference/es6ClassSuperCodegenBug.types delete mode 100644 tests/baselines/reference/escapedIdentifiers.errors.txt create mode 100644 tests/baselines/reference/escapedIdentifiers.symbols create mode 100644 tests/baselines/reference/escapedIdentifiers.types delete mode 100644 tests/baselines/reference/forBreakStatements.errors.txt create mode 100644 tests/baselines/reference/forBreakStatements.symbols create mode 100644 tests/baselines/reference/forBreakStatements.types delete mode 100644 tests/baselines/reference/forContinueStatements.errors.txt create mode 100644 tests/baselines/reference/forContinueStatements.symbols create mode 100644 tests/baselines/reference/forContinueStatements.types delete mode 100644 tests/baselines/reference/forInBreakStatements.errors.txt create mode 100644 tests/baselines/reference/forInBreakStatements.symbols create mode 100644 tests/baselines/reference/forInBreakStatements.types delete mode 100644 tests/baselines/reference/forInContinueStatements.errors.txt create mode 100644 tests/baselines/reference/forInContinueStatements.symbols create mode 100644 tests/baselines/reference/forInContinueStatements.types delete mode 100644 tests/baselines/reference/forStatements.errors.txt create mode 100644 tests/baselines/reference/forStatements.symbols create mode 100644 tests/baselines/reference/forStatements.types delete mode 100644 tests/baselines/reference/forStatementsMultipleValidDecl.errors.txt create mode 100644 tests/baselines/reference/forStatementsMultipleValidDecl.symbols create mode 100644 tests/baselines/reference/forStatementsMultipleValidDecl.types delete mode 100644 tests/baselines/reference/functionImplementations.errors.txt create mode 100644 tests/baselines/reference/functionImplementations.symbols create mode 100644 tests/baselines/reference/functionImplementations.types delete mode 100644 tests/baselines/reference/functionOverloads12.errors.txt create mode 100644 tests/baselines/reference/functionOverloads12.symbols create mode 100644 tests/baselines/reference/functionOverloads12.types delete mode 100644 tests/baselines/reference/functionReturn.errors.txt create mode 100644 tests/baselines/reference/functionReturn.symbols create mode 100644 tests/baselines/reference/functionReturn.types delete mode 100644 tests/baselines/reference/generatedContextualTyping.errors.txt create mode 100644 tests/baselines/reference/generatedContextualTyping.symbols create mode 100644 tests/baselines/reference/generatedContextualTyping.types delete mode 100644 tests/baselines/reference/ifDoWhileStatements.errors.txt create mode 100644 tests/baselines/reference/ifDoWhileStatements.symbols create mode 100644 tests/baselines/reference/ifDoWhileStatements.types delete mode 100644 tests/baselines/reference/null.errors.txt create mode 100644 tests/baselines/reference/null.symbols create mode 100644 tests/baselines/reference/null.types delete mode 100644 tests/baselines/reference/parser768531.errors.txt create mode 100644 tests/baselines/reference/parser768531.symbols create mode 100644 tests/baselines/reference/parser768531.types delete mode 100644 tests/baselines/reference/whileBreakStatements.errors.txt create mode 100644 tests/baselines/reference/whileBreakStatements.symbols create mode 100644 tests/baselines/reference/whileBreakStatements.types diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index a520e3cd58a..8e764947ee8 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -374,10 +374,6 @@ namespace ts { blockScopeContainer = savedBlockScopeContainer; } - function shouldSaveReachabilityState(n: Node): boolean { - return n.kind === SyntaxKind.SourceFile || n.kind === SyntaxKind.ModuleBlock || isFunctionLike(n); - } - function bindWithReachabilityChecks(node: Node): void { let savedReachabilityState: Reachability; let savedLabelStack: Reachability[]; @@ -385,7 +381,10 @@ namespace ts { let savedImplicitLabels: number[]; let savedHasExplicitReturn: boolean; - let saveState = shouldSaveReachabilityState(node); + // reset all reachability check related flags on node (for incremental scenarios) + node.flags &= ~NodeFlags.ReachabilityCheckFlags; + + let saveState = node.kind === SyntaxKind.SourceFile || node.kind === SyntaxKind.ModuleBlock || isFunctionLike(node); if (saveState) { savedReachabilityState = currentReachabilityState; savedLabelStack = labelStack; @@ -398,9 +397,7 @@ namespace ts { labelStack = labelIndexMap = implicitLabels = undefined; } - if (!bindReachableStatement(node)) { - forEachChild(node, bind); - } + bindReachableStatement(node); if (currentReachabilityState === Reachability.Reachable && isFunctionLike(node) && nodeIsPresent((node).body)) { node.flags |= NodeFlags.HasImplicitReturn; @@ -422,43 +419,56 @@ namespace ts { * Returns true if node and its subnodes were successfully traversed. * Returning false means that node was not examined and caller needs to dive into the node himself. */ - function bindReachableStatement(node: Node): boolean { + function bindReachableStatement(node: Node): void { if (checkUnreachable(node)) { - return false; + forEachChild(node, bind); + return; } switch (node.kind) { case SyntaxKind.WhileStatement: - return bindWhileStatement(node); + bindWhileStatement(node); + break; case SyntaxKind.DoStatement: - return bindDoStatement(node); + bindDoStatement(node); + break; case SyntaxKind.ForStatement: - return bindForStatement(node); + bindForStatement(node); + break; case SyntaxKind.ForInStatement: case SyntaxKind.ForOfStatement: - return bindForInOrForOfStatement(node); + bindForInOrForOfStatement(node); + break; case SyntaxKind.IfStatement: - return bindIfStatement(node); + bindIfStatement(node); + break; case SyntaxKind.ReturnStatement: case SyntaxKind.ThrowStatement: - return bindReturnOrThrow(node); + bindReturnOrThrow(node); + break; case SyntaxKind.BreakStatement: case SyntaxKind.ContinueStatement: - return bindBreakOrContinueStatement(node); + bindBreakOrContinueStatement(node); + break; case SyntaxKind.TryStatement: - return bindTryStatement(node); + bindTryStatement(node); + break; case SyntaxKind.SwitchStatement: - return bindSwitchStatement(node); + bindSwitchStatement(node); + break; case SyntaxKind.CaseBlock: - return bindCaseBlock(node); + bindCaseBlock(node); + break; case SyntaxKind.LabeledStatement: - return bindLabeledStatement(node); + bindLabeledStatement(node); + break; default: - return false; + forEachChild(node, bind); + break; } } - function bindWhileStatement(n: WhileStatement): boolean { + function bindWhileStatement(n: WhileStatement): void { const preWhileState = n.expression.kind === SyntaxKind.FalseKeyword ? Reachability.Unreachable : currentReachabilityState; const postWhileState = @@ -471,11 +481,9 @@ namespace ts { const postWhileLabel = pushImplicitLabel(); bind(n.statement); popImplicitLabel(postWhileLabel, postWhileState); - - return true; } - function bindDoStatement(n: DoStatement): boolean { + function bindDoStatement(n: DoStatement): void { const preDoState = currentReachabilityState; const postDoLabel = pushImplicitLabel(); @@ -485,11 +493,9 @@ namespace ts { // bind expressions (don't affect reachability) bind(n.expression); - - return true; } - function bindForStatement(n: ForStatement): boolean { + function bindForStatement(n: ForStatement): void { const preForState = currentReachabilityState; const postForLabel = pushImplicitLabel(); @@ -506,11 +512,9 @@ namespace ts { const isInfiniteLoop = (!n.condition || n.condition.kind === SyntaxKind.TrueKeyword); const postForState = isInfiniteLoop ? Reachability.Unreachable : preForState; popImplicitLabel(postForLabel, postForState); - - return true; } - function bindForInOrForOfStatement(n: ForInStatement | ForOfStatement): boolean { + function bindForInOrForOfStatement(n: ForInStatement | ForOfStatement): void { const preStatementState = currentReachabilityState; const postStatementLabel = pushImplicitLabel(); @@ -520,11 +524,9 @@ namespace ts { bind(n.statement); popImplicitLabel(postStatementLabel, preStatementState); - - return true; } - function bindIfStatement(n: IfStatement): boolean { + function bindIfStatement(n: IfStatement): void { // denotes reachability state when entering 'thenStatement' part of the if statement: // i.e. if condition is false then thenStatement is unreachable const ifTrueState = n.expression.kind === SyntaxKind.FalseKeyword ? Reachability.Unreachable : currentReachabilityState; @@ -547,22 +549,18 @@ namespace ts { else { currentReachabilityState = or(currentReachabilityState, ifFalseState); } - - return true; } - function bindReturnOrThrow(n: ReturnStatement | ThrowStatement): boolean { + function bindReturnOrThrow(n: ReturnStatement | ThrowStatement): void { // bind expression (don't affect reachability) bind(n.expression); if (n.kind === SyntaxKind.ReturnStatement) { hasExplicitReturn = true; } currentReachabilityState = Reachability.Unreachable; - - return true; } - function bindBreakOrContinueStatement(n: BreakOrContinueStatement): boolean { + function bindBreakOrContinueStatement(n: BreakOrContinueStatement): void { // call bind on label (don't affect reachability) bind(n.label); // for continue case touch label so it will be marked a used @@ -570,10 +568,9 @@ namespace ts { if (isValidJump) { currentReachabilityState = Reachability.Unreachable; } - return true; } - function bindTryStatement(n: TryStatement): boolean { + function bindTryStatement(n: TryStatement): void { // catch\finally blocks has the same reachability as try block const preTryState = currentReachabilityState; bind(n.tryBlock); @@ -590,11 +587,9 @@ namespace ts { // - post try state is reachable - control flow can fall out of try block // - post catch state is reachable - control flow can fall out of catch block currentReachabilityState = or(postTryState, postCatchState); - - return true; } - function bindSwitchStatement(n: SwitchStatement): boolean { + function bindSwitchStatement(n: SwitchStatement): void { const preSwitchState = currentReachabilityState; const postSwitchLabel = pushImplicitLabel(); @@ -609,11 +604,9 @@ namespace ts { const postSwitchState = hasDefault && currentReachabilityState !== Reachability.Reachable ? Reachability.Unreachable : preSwitchState; popImplicitLabel(postSwitchLabel, postSwitchState); - - return true; } - function bindCaseBlock(n: CaseBlock): boolean { + function bindCaseBlock(n: CaseBlock): void { const startState = currentReachabilityState; for (let clause of n.clauses) { @@ -623,11 +616,9 @@ namespace ts { errorOnFirstToken(clause, Diagnostics.Fallthrough_case_in_switch); } } - - return true; } - function bindLabeledStatement(n: LabeledStatement): boolean { + function bindLabeledStatement(n: LabeledStatement): void { // call bind on label (don't affect reachability) bind(n.label); @@ -636,8 +627,6 @@ namespace ts { if (ok) { popNamedLabel(n.label, currentReachabilityState); } - - return true; } function getContainerFlags(node: Node): ContainerFlags { @@ -1387,8 +1376,6 @@ namespace ts { } function popNamedLabel(label: Identifier, outerState: Reachability): void { - initializeReachabilityStateIfNecessary(); - let index = labelIndexMap[label.text]; Debug.assert(index !== undefined); Debug.assert(labelStack.length == index + 1); @@ -1399,8 +1386,6 @@ namespace ts { } function popImplicitLabel(implicitLabelIndex: number, outerState: Reachability): void { - initializeReachabilityStateIfNecessary(); - Debug.assert(labelStack.length === implicitLabelIndex + 1, `Label stack: ${labelStack.length}, index:${implicitLabelIndex}`); let i = implicitLabels.pop(); Debug.assert(implicitLabelIndex === i, `i: ${i}, index: ${implicitLabelIndex}`); @@ -1408,8 +1393,6 @@ namespace ts { } function setCurrentStateAtLabel(innerMergedState: Reachability, outerState: Reachability, label: Identifier): void { - initializeReachabilityStateIfNecessary(); - if (innerMergedState === Reachability.Unintialized) { if (label && !options.allowUnusedLabels) { file.bindDiagnostics.push(createDiagnosticForNode(label, Diagnostics.Unused_label)); diff --git a/src/compiler/types.ts b/src/compiler/types.ts index c3afe56a2e9..fef3f071125 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -384,7 +384,9 @@ namespace ts { Modifier = Export | Ambient | Public | Private | Protected | Static | Abstract | Default | Async, AccessibilityModifier = Public | Private | Protected, - BlockScoped = Let | Const + BlockScoped = Let | Const, + + ReachabilityCheckFlags = HasImplicitReturn | HasExplicitReturn } /* @internal */ diff --git a/tests/baselines/reference/bestCommonTypeReturnStatement.errors.txt b/tests/baselines/reference/bestCommonTypeReturnStatement.errors.txt deleted file mode 100644 index af83d53a722..00000000000 --- a/tests/baselines/reference/bestCommonTypeReturnStatement.errors.txt +++ /dev/null @@ -1,18 +0,0 @@ -tests/cases/compiler/bestCommonTypeReturnStatement.ts(7,5): error TS7027: Unreachable code detected. - - -==== tests/cases/compiler/bestCommonTypeReturnStatement.ts (1 errors) ==== - interface IPromise { - then(successCallback: (promiseValue: T) => any, errorCallback?: (reason: any) => any): IPromise; - } - - function f() { - if (true) return b(); - return d(); - ~~~~~~ -!!! error TS7027: Unreachable code detected. - } - - - function b(): IPromise { return null; } - function d(): IPromise { return null; } \ No newline at end of file diff --git a/tests/baselines/reference/bestCommonTypeReturnStatement.js b/tests/baselines/reference/bestCommonTypeReturnStatement.js index f4ab98ed1c6..6d6f73bc0cf 100644 --- a/tests/baselines/reference/bestCommonTypeReturnStatement.js +++ b/tests/baselines/reference/bestCommonTypeReturnStatement.js @@ -1,4 +1,5 @@ //// [bestCommonTypeReturnStatement.ts] + interface IPromise { then(successCallback: (promiseValue: T) => any, errorCallback?: (reason: any) => any): IPromise; } diff --git a/tests/baselines/reference/bestCommonTypeReturnStatement.symbols b/tests/baselines/reference/bestCommonTypeReturnStatement.symbols new file mode 100644 index 00000000000..14e770ae255 --- /dev/null +++ b/tests/baselines/reference/bestCommonTypeReturnStatement.symbols @@ -0,0 +1,35 @@ +=== tests/cases/compiler/bestCommonTypeReturnStatement.ts === + +interface IPromise { +>IPromise : Symbol(IPromise, Decl(bestCommonTypeReturnStatement.ts, 0, 0)) +>T : Symbol(T, Decl(bestCommonTypeReturnStatement.ts, 1, 19)) + + then(successCallback: (promiseValue: T) => any, errorCallback?: (reason: any) => any): IPromise; +>then : Symbol(then, Decl(bestCommonTypeReturnStatement.ts, 1, 23)) +>successCallback : Symbol(successCallback, Decl(bestCommonTypeReturnStatement.ts, 2, 9)) +>promiseValue : Symbol(promiseValue, Decl(bestCommonTypeReturnStatement.ts, 2, 27)) +>T : Symbol(T, Decl(bestCommonTypeReturnStatement.ts, 1, 19)) +>errorCallback : Symbol(errorCallback, Decl(bestCommonTypeReturnStatement.ts, 2, 51)) +>reason : Symbol(reason, Decl(bestCommonTypeReturnStatement.ts, 2, 69)) +>IPromise : Symbol(IPromise, Decl(bestCommonTypeReturnStatement.ts, 0, 0)) +} + +function f() { +>f : Symbol(f, Decl(bestCommonTypeReturnStatement.ts, 3, 1)) + + if (true) return b(); +>b : Symbol(b, Decl(bestCommonTypeReturnStatement.ts, 8, 1)) + + return d(); +>d : Symbol(d, Decl(bestCommonTypeReturnStatement.ts, 11, 45)) +} + + +function b(): IPromise { return null; } +>b : Symbol(b, Decl(bestCommonTypeReturnStatement.ts, 8, 1)) +>IPromise : Symbol(IPromise, Decl(bestCommonTypeReturnStatement.ts, 0, 0)) + +function d(): IPromise { return null; } +>d : Symbol(d, Decl(bestCommonTypeReturnStatement.ts, 11, 45)) +>IPromise : Symbol(IPromise, Decl(bestCommonTypeReturnStatement.ts, 0, 0)) + diff --git a/tests/baselines/reference/bestCommonTypeReturnStatement.types b/tests/baselines/reference/bestCommonTypeReturnStatement.types new file mode 100644 index 00000000000..31f72ab93b4 --- /dev/null +++ b/tests/baselines/reference/bestCommonTypeReturnStatement.types @@ -0,0 +1,40 @@ +=== tests/cases/compiler/bestCommonTypeReturnStatement.ts === + +interface IPromise { +>IPromise : IPromise +>T : T + + then(successCallback: (promiseValue: T) => any, errorCallback?: (reason: any) => any): IPromise; +>then : (successCallback: (promiseValue: T) => any, errorCallback?: (reason: any) => any) => IPromise +>successCallback : (promiseValue: T) => any +>promiseValue : T +>T : T +>errorCallback : (reason: any) => any +>reason : any +>IPromise : IPromise +} + +function f() { +>f : () => IPromise + + if (true) return b(); +>true : boolean +>b() : IPromise +>b : () => IPromise + + return d(); +>d() : IPromise +>d : () => IPromise +} + + +function b(): IPromise { return null; } +>b : () => IPromise +>IPromise : IPromise +>null : null + +function d(): IPromise { return null; } +>d : () => IPromise +>IPromise : IPromise +>null : null + diff --git a/tests/baselines/reference/breakTarget3.errors.txt b/tests/baselines/reference/breakTarget3.errors.txt deleted file mode 100644 index aff8887c15e..00000000000 --- a/tests/baselines/reference/breakTarget3.errors.txt +++ /dev/null @@ -1,11 +0,0 @@ -tests/cases/compiler/breakTarget3.ts(2,1): error TS7028: Unused label. - - -==== tests/cases/compiler/breakTarget3.ts (1 errors) ==== - target1: - target2: - ~~~~~~~ -!!! error TS7028: Unused label. - while (true) { - break target1; - } \ No newline at end of file diff --git a/tests/baselines/reference/breakTarget3.js b/tests/baselines/reference/breakTarget3.js index 0fa6cd2d298..b36eeb3902b 100644 --- a/tests/baselines/reference/breakTarget3.js +++ b/tests/baselines/reference/breakTarget3.js @@ -1,4 +1,5 @@ //// [breakTarget3.ts] + target1: target2: while (true) { diff --git a/tests/baselines/reference/breakTarget3.symbols b/tests/baselines/reference/breakTarget3.symbols new file mode 100644 index 00000000000..a0b17435504 --- /dev/null +++ b/tests/baselines/reference/breakTarget3.symbols @@ -0,0 +1,8 @@ +=== tests/cases/compiler/breakTarget3.ts === + +No type information for this code.target1: +No type information for this code.target2: +No type information for this code.while (true) { +No type information for this code. break target1; +No type information for this code.} +No type information for this code. \ No newline at end of file diff --git a/tests/baselines/reference/breakTarget3.types b/tests/baselines/reference/breakTarget3.types new file mode 100644 index 00000000000..e4b5f8a1c61 --- /dev/null +++ b/tests/baselines/reference/breakTarget3.types @@ -0,0 +1,14 @@ +=== tests/cases/compiler/breakTarget3.ts === + +target1: +>target1 : any + +target2: +>target2 : any + +while (true) { +>true : boolean + + break target1; +>target1 : any +} diff --git a/tests/baselines/reference/breakTarget4.errors.txt b/tests/baselines/reference/breakTarget4.errors.txt deleted file mode 100644 index d1283de2fa0..00000000000 --- a/tests/baselines/reference/breakTarget4.errors.txt +++ /dev/null @@ -1,11 +0,0 @@ -tests/cases/compiler/breakTarget4.ts(1,1): error TS7028: Unused label. - - -==== tests/cases/compiler/breakTarget4.ts (1 errors) ==== - target1: - ~~~~~~~ -!!! error TS7028: Unused label. - target2: - while (true) { - break target2; - } \ No newline at end of file diff --git a/tests/baselines/reference/breakTarget4.js b/tests/baselines/reference/breakTarget4.js index 4586301d71b..0c91e44ecbd 100644 --- a/tests/baselines/reference/breakTarget4.js +++ b/tests/baselines/reference/breakTarget4.js @@ -1,4 +1,5 @@ //// [breakTarget4.ts] + target1: target2: while (true) { diff --git a/tests/baselines/reference/breakTarget4.symbols b/tests/baselines/reference/breakTarget4.symbols new file mode 100644 index 00000000000..d4edcb17e1a --- /dev/null +++ b/tests/baselines/reference/breakTarget4.symbols @@ -0,0 +1,8 @@ +=== tests/cases/compiler/breakTarget4.ts === + +No type information for this code.target1: +No type information for this code.target2: +No type information for this code.while (true) { +No type information for this code. break target2; +No type information for this code.} +No type information for this code. \ No newline at end of file diff --git a/tests/baselines/reference/breakTarget4.types b/tests/baselines/reference/breakTarget4.types new file mode 100644 index 00000000000..8b6ccf600ad --- /dev/null +++ b/tests/baselines/reference/breakTarget4.types @@ -0,0 +1,14 @@ +=== tests/cases/compiler/breakTarget4.ts === + +target1: +>target1 : any + +target2: +>target2 : any + +while (true) { +>true : boolean + + break target2; +>target2 : any +} diff --git a/tests/baselines/reference/breakTarget5.errors.txt b/tests/baselines/reference/breakTarget5.errors.txt index 55a454ee68b..d92f29d67ee 100644 --- a/tests/baselines/reference/breakTarget5.errors.txt +++ b/tests/baselines/reference/breakTarget5.errors.txt @@ -1,11 +1,9 @@ -tests/cases/compiler/breakTarget5.ts(1,1): error TS7028: Unused label. -tests/cases/compiler/breakTarget5.ts(5,7): error TS1107: Jump target cannot cross function boundary. +tests/cases/compiler/breakTarget5.ts(6,7): error TS1107: Jump target cannot cross function boundary. -==== tests/cases/compiler/breakTarget5.ts (2 errors) ==== +==== tests/cases/compiler/breakTarget5.ts (1 errors) ==== + target: - ~~~~~~ -!!! error TS7028: Unused label. while (true) { function f() { while (true) { diff --git a/tests/baselines/reference/breakTarget5.js b/tests/baselines/reference/breakTarget5.js index 197e4e147bd..9f6b063a8c4 100644 --- a/tests/baselines/reference/breakTarget5.js +++ b/tests/baselines/reference/breakTarget5.js @@ -1,4 +1,5 @@ //// [breakTarget5.ts] + target: while (true) { function f() { diff --git a/tests/baselines/reference/callSignatureWithoutReturnTypeAnnotationInference.errors.txt b/tests/baselines/reference/callSignatureWithoutReturnTypeAnnotationInference.errors.txt deleted file mode 100644 index 06eca28b512..00000000000 --- a/tests/baselines/reference/callSignatureWithoutReturnTypeAnnotationInference.errors.txt +++ /dev/null @@ -1,126 +0,0 @@ -tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignatureWithoutReturnTypeAnnotationInference.ts(28,9): error TS7027: Unreachable code detected. - - -==== tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignatureWithoutReturnTypeAnnotationInference.ts (1 errors) ==== - // Call signatures without a return type should infer one from the function body (if present) - - // Simple types - function foo(x) { - return 1; - } - var r = foo(1); - - function foo2(x) { - return foo(x); - } - var r2 = foo2(1); - - function foo3() { - return foo3(); - } - var r3 = foo3(); - - function foo4(x: T) { - return x; - } - var r4 = foo4(1); - - function foo5(x) { - if (true) { - return 1; - } else { - return 2; - ~~~~~~ -!!! error TS7027: Unreachable code detected. - } - } - var r5 = foo5(1); - - function foo6(x) { - try { - } - catch (e) { - return []; - } - finally { - return []; - } - } - var r6 = foo6(1); - - function foo7(x) { - return typeof x; - } - var r7 = foo7(1); - - // object types - function foo8(x: number) { - return { x: x }; - } - var r8 = foo8(1); - - interface I { - foo: string; - } - function foo9(x: number) { - var i: I; - return i; - } - var r9 = foo9(1); - - class C { - foo: string; - } - function foo10(x: number) { - var c: C; - return c; - } - var r10 = foo10(1); - - module M { - export var x = 1; - export class C { foo: string } - } - function foo11() { - return M; - } - var r11 = foo11(); - - // merged declarations - interface I2 { - x: number; - } - interface I2 { - y: number; - } - function foo12() { - var i2: I2; - return i2; - } - var r12 = foo12(); - - function m1() { return 1; } - module m1 { export var y = 2; } - function foo13() { - return m1; - } - var r13 = foo13(); - - class c1 { - foo: string; - constructor(x) { } - } - module c1 { - export var x = 1; - } - function foo14() { - return c1; - } - var r14 = foo14(); - - enum e1 { A } - module e1 { export var y = 1; } - function foo15() { - return e1; - } - var r15 = foo15(); \ No newline at end of file diff --git a/tests/baselines/reference/callSignatureWithoutReturnTypeAnnotationInference.js b/tests/baselines/reference/callSignatureWithoutReturnTypeAnnotationInference.js index 0e78aac2b1b..73270c240cb 100644 --- a/tests/baselines/reference/callSignatureWithoutReturnTypeAnnotationInference.js +++ b/tests/baselines/reference/callSignatureWithoutReturnTypeAnnotationInference.js @@ -1,4 +1,5 @@ //// [callSignatureWithoutReturnTypeAnnotationInference.ts] + // Call signatures without a return type should infer one from the function body (if present) // Simple types diff --git a/tests/baselines/reference/callSignatureWithoutReturnTypeAnnotationInference.symbols b/tests/baselines/reference/callSignatureWithoutReturnTypeAnnotationInference.symbols new file mode 100644 index 00000000000..faba4e427ec --- /dev/null +++ b/tests/baselines/reference/callSignatureWithoutReturnTypeAnnotationInference.symbols @@ -0,0 +1,256 @@ +=== tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignatureWithoutReturnTypeAnnotationInference.ts === + +// Call signatures without a return type should infer one from the function body (if present) + +// Simple types +function foo(x) { +>foo : Symbol(foo, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 0, 0)) +>x : Symbol(x, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 4, 13)) + + return 1; +} +var r = foo(1); +>r : Symbol(r, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 7, 3)) +>foo : Symbol(foo, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 0, 0)) + +function foo2(x) { +>foo2 : Symbol(foo2, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 7, 15)) +>x : Symbol(x, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 9, 14)) + + return foo(x); +>foo : Symbol(foo, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 0, 0)) +>x : Symbol(x, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 9, 14)) +} +var r2 = foo2(1); +>r2 : Symbol(r2, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 12, 3)) +>foo2 : Symbol(foo2, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 7, 15)) + +function foo3() { +>foo3 : Symbol(foo3, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 12, 17)) + + return foo3(); +>foo3 : Symbol(foo3, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 12, 17)) +} +var r3 = foo3(); +>r3 : Symbol(r3, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 17, 3)) +>foo3 : Symbol(foo3, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 12, 17)) + +function foo4(x: T) { +>foo4 : Symbol(foo4, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 17, 16)) +>T : Symbol(T, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 19, 14)) +>x : Symbol(x, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 19, 17)) +>T : Symbol(T, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 19, 14)) + + return x; +>x : Symbol(x, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 19, 17)) +} +var r4 = foo4(1); +>r4 : Symbol(r4, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 22, 3)) +>foo4 : Symbol(foo4, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 17, 16)) + +function foo5(x) { +>foo5 : Symbol(foo5, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 22, 17)) +>x : Symbol(x, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 24, 14)) + + if (true) { + return 1; + } else { + return 2; + } +} +var r5 = foo5(1); +>r5 : Symbol(r5, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 31, 3)) +>foo5 : Symbol(foo5, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 22, 17)) + +function foo6(x) { +>foo6 : Symbol(foo6, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 31, 17)) +>x : Symbol(x, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 33, 14)) + + try { + } + catch (e) { +>e : Symbol(e, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 36, 11)) + + return []; + } + finally { + return []; + } +} +var r6 = foo6(1); +>r6 : Symbol(r6, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 43, 3)) +>foo6 : Symbol(foo6, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 31, 17)) + +function foo7(x) { +>foo7 : Symbol(foo7, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 43, 17)) +>x : Symbol(x, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 45, 14)) + + return typeof x; +>x : Symbol(x, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 45, 14)) +} +var r7 = foo7(1); +>r7 : Symbol(r7, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 48, 3)) +>foo7 : Symbol(foo7, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 43, 17)) + +// object types +function foo8(x: number) { +>foo8 : Symbol(foo8, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 48, 17)) +>x : Symbol(x, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 51, 14)) + + return { x: x }; +>x : Symbol(x, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 52, 12)) +>x : Symbol(x, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 51, 14)) +} +var r8 = foo8(1); +>r8 : Symbol(r8, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 54, 3)) +>foo8 : Symbol(foo8, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 48, 17)) + +interface I { +>I : Symbol(I, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 54, 17)) + + foo: string; +>foo : Symbol(foo, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 56, 13)) +} +function foo9(x: number) { +>foo9 : Symbol(foo9, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 58, 1)) +>x : Symbol(x, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 59, 14)) + + var i: I; +>i : Symbol(i, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 60, 7)) +>I : Symbol(I, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 54, 17)) + + return i; +>i : Symbol(i, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 60, 7)) +} +var r9 = foo9(1); +>r9 : Symbol(r9, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 63, 3)) +>foo9 : Symbol(foo9, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 58, 1)) + +class C { +>C : Symbol(C, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 63, 17)) + + foo: string; +>foo : Symbol(foo, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 65, 9)) +} +function foo10(x: number) { +>foo10 : Symbol(foo10, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 67, 1)) +>x : Symbol(x, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 68, 15)) + + var c: C; +>c : Symbol(c, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 69, 7)) +>C : Symbol(C, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 63, 17)) + + return c; +>c : Symbol(c, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 69, 7)) +} +var r10 = foo10(1); +>r10 : Symbol(r10, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 72, 3)) +>foo10 : Symbol(foo10, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 67, 1)) + +module M { +>M : Symbol(M, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 72, 19)) + + export var x = 1; +>x : Symbol(x, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 75, 14)) + + export class C { foo: string } +>C : Symbol(C, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 75, 21)) +>foo : Symbol(foo, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 76, 20)) +} +function foo11() { +>foo11 : Symbol(foo11, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 77, 1)) + + return M; +>M : Symbol(M, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 72, 19)) +} +var r11 = foo11(); +>r11 : Symbol(r11, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 81, 3)) +>foo11 : Symbol(foo11, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 77, 1)) + +// merged declarations +interface I2 { +>I2 : Symbol(I2, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 81, 18), Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 86, 1)) + + x: number; +>x : Symbol(x, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 84, 14)) +} +interface I2 { +>I2 : Symbol(I2, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 81, 18), Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 86, 1)) + + y: number; +>y : Symbol(y, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 87, 14)) +} +function foo12() { +>foo12 : Symbol(foo12, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 89, 1)) + + var i2: I2; +>i2 : Symbol(i2, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 91, 7)) +>I2 : Symbol(I2, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 81, 18), Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 86, 1)) + + return i2; +>i2 : Symbol(i2, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 91, 7)) +} +var r12 = foo12(); +>r12 : Symbol(r12, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 94, 3)) +>foo12 : Symbol(foo12, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 89, 1)) + +function m1() { return 1; } +>m1 : Symbol(m1, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 94, 18), Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 96, 27)) + +module m1 { export var y = 2; } +>m1 : Symbol(m1, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 94, 18), Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 96, 27)) +>y : Symbol(y, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 97, 22)) + +function foo13() { +>foo13 : Symbol(foo13, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 97, 31)) + + return m1; +>m1 : Symbol(m1, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 94, 18), Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 96, 27)) +} +var r13 = foo13(); +>r13 : Symbol(r13, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 101, 3)) +>foo13 : Symbol(foo13, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 97, 31)) + +class c1 { +>c1 : Symbol(c1, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 101, 18), Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 106, 1)) + + foo: string; +>foo : Symbol(foo, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 103, 10)) + + constructor(x) { } +>x : Symbol(x, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 105, 16)) +} +module c1 { +>c1 : Symbol(c1, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 101, 18), Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 106, 1)) + + export var x = 1; +>x : Symbol(x, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 108, 14)) +} +function foo14() { +>foo14 : Symbol(foo14, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 109, 1)) + + return c1; +>c1 : Symbol(c1, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 101, 18), Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 106, 1)) +} +var r14 = foo14(); +>r14 : Symbol(r14, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 113, 3)) +>foo14 : Symbol(foo14, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 109, 1)) + +enum e1 { A } +>e1 : Symbol(e1, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 113, 18), Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 115, 13)) +>A : Symbol(e1.A, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 115, 9)) + +module e1 { export var y = 1; } +>e1 : Symbol(e1, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 113, 18), Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 115, 13)) +>y : Symbol(y, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 116, 22)) + +function foo15() { +>foo15 : Symbol(foo15, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 116, 31)) + + return e1; +>e1 : Symbol(e1, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 113, 18), Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 115, 13)) +} +var r15 = foo15(); +>r15 : Symbol(r15, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 120, 3)) +>foo15 : Symbol(foo15, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 116, 31)) + diff --git a/tests/baselines/reference/callSignatureWithoutReturnTypeAnnotationInference.types b/tests/baselines/reference/callSignatureWithoutReturnTypeAnnotationInference.types new file mode 100644 index 00000000000..689ac62c35b --- /dev/null +++ b/tests/baselines/reference/callSignatureWithoutReturnTypeAnnotationInference.types @@ -0,0 +1,297 @@ +=== tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignatureWithoutReturnTypeAnnotationInference.ts === + +// Call signatures without a return type should infer one from the function body (if present) + +// Simple types +function foo(x) { +>foo : (x: any) => number +>x : any + + return 1; +>1 : number +} +var r = foo(1); +>r : number +>foo(1) : number +>foo : (x: any) => number +>1 : number + +function foo2(x) { +>foo2 : (x: any) => number +>x : any + + return foo(x); +>foo(x) : number +>foo : (x: any) => number +>x : any +} +var r2 = foo2(1); +>r2 : number +>foo2(1) : number +>foo2 : (x: any) => number +>1 : number + +function foo3() { +>foo3 : () => any + + return foo3(); +>foo3() : any +>foo3 : () => any +} +var r3 = foo3(); +>r3 : any +>foo3() : any +>foo3 : () => any + +function foo4(x: T) { +>foo4 : (x: T) => T +>T : T +>x : T +>T : T + + return x; +>x : T +} +var r4 = foo4(1); +>r4 : number +>foo4(1) : number +>foo4 : (x: T) => T +>1 : number + +function foo5(x) { +>foo5 : (x: any) => number +>x : any + + if (true) { +>true : boolean + + return 1; +>1 : number + + } else { + return 2; +>2 : number + } +} +var r5 = foo5(1); +>r5 : number +>foo5(1) : number +>foo5 : (x: any) => number +>1 : number + +function foo6(x) { +>foo6 : (x: any) => any[] +>x : any + + try { + } + catch (e) { +>e : any + + return []; +>[] : undefined[] + } + finally { + return []; +>[] : undefined[] + } +} +var r6 = foo6(1); +>r6 : any[] +>foo6(1) : any[] +>foo6 : (x: any) => any[] +>1 : number + +function foo7(x) { +>foo7 : (x: any) => string +>x : any + + return typeof x; +>typeof x : string +>x : any +} +var r7 = foo7(1); +>r7 : string +>foo7(1) : string +>foo7 : (x: any) => string +>1 : number + +// object types +function foo8(x: number) { +>foo8 : (x: number) => { x: number; } +>x : number + + return { x: x }; +>{ x: x } : { x: number; } +>x : number +>x : number +} +var r8 = foo8(1); +>r8 : { x: number; } +>foo8(1) : { x: number; } +>foo8 : (x: number) => { x: number; } +>1 : number + +interface I { +>I : I + + foo: string; +>foo : string +} +function foo9(x: number) { +>foo9 : (x: number) => I +>x : number + + var i: I; +>i : I +>I : I + + return i; +>i : I +} +var r9 = foo9(1); +>r9 : I +>foo9(1) : I +>foo9 : (x: number) => I +>1 : number + +class C { +>C : C + + foo: string; +>foo : string +} +function foo10(x: number) { +>foo10 : (x: number) => C +>x : number + + var c: C; +>c : C +>C : C + + return c; +>c : C +} +var r10 = foo10(1); +>r10 : C +>foo10(1) : C +>foo10 : (x: number) => C +>1 : number + +module M { +>M : typeof M + + export var x = 1; +>x : number +>1 : number + + export class C { foo: string } +>C : C +>foo : string +} +function foo11() { +>foo11 : () => typeof M + + return M; +>M : typeof M +} +var r11 = foo11(); +>r11 : typeof M +>foo11() : typeof M +>foo11 : () => typeof M + +// merged declarations +interface I2 { +>I2 : I2 + + x: number; +>x : number +} +interface I2 { +>I2 : I2 + + y: number; +>y : number +} +function foo12() { +>foo12 : () => I2 + + var i2: I2; +>i2 : I2 +>I2 : I2 + + return i2; +>i2 : I2 +} +var r12 = foo12(); +>r12 : I2 +>foo12() : I2 +>foo12 : () => I2 + +function m1() { return 1; } +>m1 : typeof m1 +>1 : number + +module m1 { export var y = 2; } +>m1 : typeof m1 +>y : number +>2 : number + +function foo13() { +>foo13 : () => typeof m1 + + return m1; +>m1 : typeof m1 +} +var r13 = foo13(); +>r13 : typeof m1 +>foo13() : typeof m1 +>foo13 : () => typeof m1 + +class c1 { +>c1 : c1 + + foo: string; +>foo : string + + constructor(x) { } +>x : any +} +module c1 { +>c1 : typeof c1 + + export var x = 1; +>x : number +>1 : number +} +function foo14() { +>foo14 : () => typeof c1 + + return c1; +>c1 : typeof c1 +} +var r14 = foo14(); +>r14 : typeof c1 +>foo14() : typeof c1 +>foo14 : () => typeof c1 + +enum e1 { A } +>e1 : e1 +>A : e1 + +module e1 { export var y = 1; } +>e1 : typeof e1 +>y : number +>1 : number + +function foo15() { +>foo15 : () => typeof e1 + + return e1; +>e1 : typeof e1 +} +var r15 = foo15(); +>r15 : typeof e1 +>foo15() : typeof e1 +>foo15 : () => typeof e1 + diff --git a/tests/baselines/reference/commentEmitAtEndOfFile1.js b/tests/baselines/reference/commentEmitAtEndOfFile1.js index 1be031fa84a..cada7754002 100644 --- a/tests/baselines/reference/commentEmitAtEndOfFile1.js +++ b/tests/baselines/reference/commentEmitAtEndOfFile1.js @@ -1,4 +1,5 @@ //// [commentEmitAtEndOfFile1.ts] + // test var f = '' // test #2 diff --git a/tests/baselines/reference/commentEmitAtEndOfFile1.symbols b/tests/baselines/reference/commentEmitAtEndOfFile1.symbols index 1fc0ad09553..cb06d088307 100644 --- a/tests/baselines/reference/commentEmitAtEndOfFile1.symbols +++ b/tests/baselines/reference/commentEmitAtEndOfFile1.symbols @@ -1,17 +1,18 @@ === tests/cases/compiler/commentEmitAtEndOfFile1.ts === + // test var f = '' ->f : Symbol(f, Decl(commentEmitAtEndOfFile1.ts, 1, 3)) +>f : Symbol(f, Decl(commentEmitAtEndOfFile1.ts, 2, 3)) // test #2 module foo { ->foo : Symbol(foo, Decl(commentEmitAtEndOfFile1.ts, 1, 10)) +>foo : Symbol(foo, Decl(commentEmitAtEndOfFile1.ts, 2, 10)) function bar() { } ->bar : Symbol(bar, Decl(commentEmitAtEndOfFile1.ts, 3, 12)) +>bar : Symbol(bar, Decl(commentEmitAtEndOfFile1.ts, 4, 12)) } // test #3 module empty { ->empty : Symbol(empty, Decl(commentEmitAtEndOfFile1.ts, 5, 1)) +>empty : Symbol(empty, Decl(commentEmitAtEndOfFile1.ts, 6, 1)) } // test #4 diff --git a/tests/baselines/reference/commentEmitAtEndOfFile1.types b/tests/baselines/reference/commentEmitAtEndOfFile1.types index d88d7ffa5fc..f96a1069a06 100644 --- a/tests/baselines/reference/commentEmitAtEndOfFile1.types +++ b/tests/baselines/reference/commentEmitAtEndOfFile1.types @@ -1,4 +1,5 @@ === tests/cases/compiler/commentEmitAtEndOfFile1.ts === + // test var f = '' >f : string diff --git a/tests/baselines/reference/compoundAssignmentLHSIsValue.errors.txt b/tests/baselines/reference/compoundAssignmentLHSIsValue.errors.txt index 645e34bcfa7..392e1781dd5 100644 --- a/tests/baselines/reference/compoundAssignmentLHSIsValue.errors.txt +++ b/tests/baselines/reference/compoundAssignmentLHSIsValue.errors.txt @@ -1,81 +1,81 @@ -tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(7,9): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(8,9): error TS2364: Invalid left-hand side of assignment expression. -tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(11,9): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(12,9): error TS2364: Invalid left-hand side of assignment expression. -tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(15,9): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(16,9): error TS2364: Invalid left-hand side of assignment expression. -tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(21,5): error TS2364: Invalid left-hand side of assignment expression. +tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(8,9): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(9,9): error TS2364: Invalid left-hand side of assignment expression. +tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(12,9): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(13,9): error TS2364: Invalid left-hand side of assignment expression. +tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(16,9): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(17,9): error TS2364: Invalid left-hand side of assignment expression. tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(22,5): error TS2364: Invalid left-hand side of assignment expression. -tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(25,1): error TS2364: Invalid left-hand side of assignment expression. +tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(23,5): error TS2364: Invalid left-hand side of assignment expression. tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(26,1): error TS2364: Invalid left-hand side of assignment expression. -tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(30,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(31,1): error TS2364: Invalid left-hand side of assignment expression. -tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(33,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(34,1): error TS2364: Invalid left-hand side of assignment expression. -tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(37,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(38,1): error TS2364: Invalid left-hand side of assignment expression. -tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(40,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(41,1): error TS2364: Invalid left-hand side of assignment expression. -tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(44,1): error TS2364: Invalid left-hand side of assignment expression. +tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(27,1): error TS2364: Invalid left-hand side of assignment expression. +tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(31,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(32,1): error TS2364: Invalid left-hand side of assignment expression. +tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(34,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(35,1): error TS2364: Invalid left-hand side of assignment expression. +tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(38,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(39,1): error TS2364: Invalid left-hand side of assignment expression. +tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(41,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(42,1): error TS2364: Invalid left-hand side of assignment expression. tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(45,1): error TS2364: Invalid left-hand side of assignment expression. -tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(46,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(47,1): error TS2364: Invalid left-hand side of assignment expression. -tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(48,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(49,1): error TS2364: Invalid left-hand side of assignment expression. +tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(46,1): error TS2364: Invalid left-hand side of assignment expression. +tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(47,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(48,1): error TS2364: Invalid left-hand side of assignment expression. +tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(49,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(50,1): error TS2364: Invalid left-hand side of assignment expression. tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(51,1): error TS2364: Invalid left-hand side of assignment expression. -tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(52,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(53,1): error TS2364: Invalid left-hand side of assignment expression. -tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(54,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(55,1): error TS2364: Invalid left-hand side of assignment expression. -tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(58,3): error TS7028: Unused label. -tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(58,9): error TS1128: Declaration or statement expected. +tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(52,1): error TS2364: Invalid left-hand side of assignment expression. +tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(53,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(54,1): error TS2364: Invalid left-hand side of assignment expression. +tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(55,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(56,1): error TS2364: Invalid left-hand side of assignment expression. tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(59,9): error TS1128: Declaration or statement expected. -tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(62,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(63,1): error TS2364: Invalid left-hand side of assignment expression. -tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(69,15): error TS1034: 'super' must be followed by an argument list or member access. +tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(60,9): error TS1128: Declaration or statement expected. +tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(63,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(64,1): error TS2364: Invalid left-hand side of assignment expression. tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(70,15): error TS1034: 'super' must be followed by an argument list or member access. -tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(74,15): error TS1034: 'super' must be followed by an argument list or member access. +tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(71,15): error TS1034: 'super' must be followed by an argument list or member access. tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(75,15): error TS1034: 'super' must be followed by an argument list or member access. -tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(79,15): error TS1034: 'super' must be followed by an argument list or member access. +tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(76,15): error TS1034: 'super' must be followed by an argument list or member access. tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(80,15): error TS1034: 'super' must be followed by an argument list or member access. -tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(85,21): error TS1128: Declaration or statement expected. +tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(81,15): error TS1034: 'super' must be followed by an argument list or member access. tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(86,21): error TS1128: Declaration or statement expected. -tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(87,11): error TS1005: ';' expected. +tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(87,21): error TS1128: Declaration or statement expected. tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(88,11): error TS1005: ';' expected. -tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(91,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(92,1): error TS2364: Invalid left-hand side of assignment expression. -tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(95,1): error TS2364: Invalid left-hand side of assignment expression. +tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(89,11): error TS1005: ';' expected. +tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(92,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(93,1): error TS2364: Invalid left-hand side of assignment expression. tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(96,1): error TS2364: Invalid left-hand side of assignment expression. -tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(97,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(98,1): error TS2364: Invalid left-hand side of assignment expression. -tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(99,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(100,1): error TS2364: Invalid left-hand side of assignment expression. -tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(101,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(102,1): error TS2364: Invalid left-hand side of assignment expression. -tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(103,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(104,1): error TS2364: Invalid left-hand side of assignment expression. +tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(97,1): error TS2364: Invalid left-hand side of assignment expression. +tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(98,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(99,1): error TS2364: Invalid left-hand side of assignment expression. +tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(100,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(101,1): error TS2364: Invalid left-hand side of assignment expression. +tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(102,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(103,1): error TS2364: Invalid left-hand side of assignment expression. +tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(104,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(105,1): error TS2364: Invalid left-hand side of assignment expression. tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(106,1): error TS2364: Invalid left-hand side of assignment expression. -tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(107,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(108,1): error TS2364: Invalid left-hand side of assignment expression. +tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(107,1): error TS2364: Invalid left-hand side of assignment expression. +tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(108,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(109,1): error TS2364: Invalid left-hand side of assignment expression. tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(110,1): error TS2364: Invalid left-hand side of assignment expression. -tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(111,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(112,1): error TS2364: Invalid left-hand side of assignment expression. -tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(113,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(114,1): error TS2364: Invalid left-hand side of assignment expression. -tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(115,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(116,1): error TS2364: Invalid left-hand side of assignment expression. -tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(117,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(118,1): error TS2364: Invalid left-hand side of assignment expression. -tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(119,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(120,1): error TS2364: Invalid left-hand side of assignment expression. -tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(121,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(122,1): error TS2364: Invalid left-hand side of assignment expression. +tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(111,1): error TS2364: Invalid left-hand side of assignment expression. +tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(112,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(113,1): error TS2364: Invalid left-hand side of assignment expression. +tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(114,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(115,1): error TS2364: Invalid left-hand side of assignment expression. +tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(116,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(117,1): error TS2364: Invalid left-hand side of assignment expression. +tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(118,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(119,1): error TS2364: Invalid left-hand side of assignment expression. +tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(120,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(121,1): error TS2364: Invalid left-hand side of assignment expression. +tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(122,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(123,1): error TS2364: Invalid left-hand side of assignment expression. -==== tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts (75 errors) ==== +==== tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts (74 errors) ==== + // expected error for all the LHS of compound assignments (arithmetic and addition) var value; @@ -194,8 +194,6 @@ tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsVa // object literals { a: 0} *= value; - ~ -!!! error TS7028: Unused label. ~~ !!! error TS1128: Declaration or statement expected. { a: 0} += value; diff --git a/tests/baselines/reference/compoundAssignmentLHSIsValue.js b/tests/baselines/reference/compoundAssignmentLHSIsValue.js index 833c1e1ea7c..bf66183b70a 100644 --- a/tests/baselines/reference/compoundAssignmentLHSIsValue.js +++ b/tests/baselines/reference/compoundAssignmentLHSIsValue.js @@ -1,4 +1,5 @@ //// [compoundAssignmentLHSIsValue.ts] + // expected error for all the LHS of compound assignments (arithmetic and addition) var value; diff --git a/tests/baselines/reference/conditionalExpressions2.errors.txt b/tests/baselines/reference/conditionalExpressions2.errors.txt deleted file mode 100644 index 3fb44a840b3..00000000000 --- a/tests/baselines/reference/conditionalExpressions2.errors.txt +++ /dev/null @@ -1,15 +0,0 @@ -tests/cases/compiler/conditionalExpressions2.ts(9,54): error TS7027: Unreachable code detected. - - -==== tests/cases/compiler/conditionalExpressions2.ts (1 errors) ==== - var a = false ? 1 : null; - var b = false ? undefined : 0; - var c = false ? 1 : 0; - var d = false ? false : true; - var e = false ? "foo" : "bar"; - var f = false ? null : undefined; - var g = true ? {g:5} : null; - var h = [{h:5}, null]; - function i() { if (true) { return { x: 5 }; } else { return null; } } - ~~~~~~ -!!! error TS7027: Unreachable code detected. \ No newline at end of file diff --git a/tests/baselines/reference/conditionalExpressions2.js b/tests/baselines/reference/conditionalExpressions2.js index 6749a2c0ac0..8ac7df12cfa 100644 --- a/tests/baselines/reference/conditionalExpressions2.js +++ b/tests/baselines/reference/conditionalExpressions2.js @@ -1,4 +1,5 @@ //// [conditionalExpressions2.ts] + var a = false ? 1 : null; var b = false ? undefined : 0; var c = false ? 1 : 0; diff --git a/tests/baselines/reference/conditionalExpressions2.symbols b/tests/baselines/reference/conditionalExpressions2.symbols new file mode 100644 index 00000000000..e6edd635b40 --- /dev/null +++ b/tests/baselines/reference/conditionalExpressions2.symbols @@ -0,0 +1,34 @@ +=== tests/cases/compiler/conditionalExpressions2.ts === + +var a = false ? 1 : null; +>a : Symbol(a, Decl(conditionalExpressions2.ts, 1, 3)) + +var b = false ? undefined : 0; +>b : Symbol(b, Decl(conditionalExpressions2.ts, 2, 3)) +>undefined : Symbol(undefined) + +var c = false ? 1 : 0; +>c : Symbol(c, Decl(conditionalExpressions2.ts, 3, 3)) + +var d = false ? false : true; +>d : Symbol(d, Decl(conditionalExpressions2.ts, 4, 3)) + +var e = false ? "foo" : "bar"; +>e : Symbol(e, Decl(conditionalExpressions2.ts, 5, 3)) + +var f = false ? null : undefined; +>f : Symbol(f, Decl(conditionalExpressions2.ts, 6, 3)) +>undefined : Symbol(undefined) + +var g = true ? {g:5} : null; +>g : Symbol(g, Decl(conditionalExpressions2.ts, 7, 3)) +>g : Symbol(g, Decl(conditionalExpressions2.ts, 7, 16)) + +var h = [{h:5}, null]; +>h : Symbol(h, Decl(conditionalExpressions2.ts, 8, 3)) +>h : Symbol(h, Decl(conditionalExpressions2.ts, 8, 10)) + +function i() { if (true) { return { x: 5 }; } else { return null; } } +>i : Symbol(i, Decl(conditionalExpressions2.ts, 8, 22)) +>x : Symbol(x, Decl(conditionalExpressions2.ts, 9, 35)) + diff --git a/tests/baselines/reference/conditionalExpressions2.types b/tests/baselines/reference/conditionalExpressions2.types new file mode 100644 index 00000000000..77714e664fb --- /dev/null +++ b/tests/baselines/reference/conditionalExpressions2.types @@ -0,0 +1,69 @@ +=== tests/cases/compiler/conditionalExpressions2.ts === + +var a = false ? 1 : null; +>a : number +>false ? 1 : null : number +>false : boolean +>1 : number +>null : null + +var b = false ? undefined : 0; +>b : number +>false ? undefined : 0 : number +>false : boolean +>undefined : undefined +>0 : number + +var c = false ? 1 : 0; +>c : number +>false ? 1 : 0 : number +>false : boolean +>1 : number +>0 : number + +var d = false ? false : true; +>d : boolean +>false ? false : true : boolean +>false : boolean +>false : boolean +>true : boolean + +var e = false ? "foo" : "bar"; +>e : string +>false ? "foo" : "bar" : string +>false : boolean +>"foo" : string +>"bar" : string + +var f = false ? null : undefined; +>f : any +>false ? null : undefined : null +>false : boolean +>null : null +>undefined : undefined + +var g = true ? {g:5} : null; +>g : { g: number; } +>true ? {g:5} : null : { g: number; } +>true : boolean +>{g:5} : { g: number; } +>g : number +>5 : number +>null : null + +var h = [{h:5}, null]; +>h : { h: number; }[] +>[{h:5}, null] : { h: number; }[] +>{h:5} : { h: number; } +>h : number +>5 : number +>null : null + +function i() { if (true) { return { x: 5 }; } else { return null; } } +>i : () => { x: number; } +>true : boolean +>{ x: 5 } : { x: number; } +>x : number +>5 : number +>null : null + diff --git a/tests/baselines/reference/constDeclarations-invalidContexts.errors.txt b/tests/baselines/reference/constDeclarations-invalidContexts.errors.txt index 56273924ac1..20ec5b0c25b 100644 --- a/tests/baselines/reference/constDeclarations-invalidContexts.errors.txt +++ b/tests/baselines/reference/constDeclarations-invalidContexts.errors.txt @@ -1,8 +1,6 @@ tests/cases/compiler/constDeclarations-invalidContexts.ts(4,5): error TS1156: 'const' declarations can only be declared inside a block. -tests/cases/compiler/constDeclarations-invalidContexts.ts(6,5): error TS7027: Unreachable code detected. tests/cases/compiler/constDeclarations-invalidContexts.ts(6,5): error TS1156: 'const' declarations can only be declared inside a block. tests/cases/compiler/constDeclarations-invalidContexts.ts(9,5): error TS1156: 'const' declarations can only be declared inside a block. -tests/cases/compiler/constDeclarations-invalidContexts.ts(11,1): error TS7027: Unreachable code detected. tests/cases/compiler/constDeclarations-invalidContexts.ts(12,5): error TS1156: 'const' declarations can only be declared inside a block. tests/cases/compiler/constDeclarations-invalidContexts.ts(16,7): error TS2410: All symbols within a 'with' block will be resolved to 'any'. tests/cases/compiler/constDeclarations-invalidContexts.ts(20,5): error TS1156: 'const' declarations can only be declared inside a block. @@ -11,7 +9,7 @@ tests/cases/compiler/constDeclarations-invalidContexts.ts(26,12): error TS1156: tests/cases/compiler/constDeclarations-invalidContexts.ts(29,29): error TS1156: 'const' declarations can only be declared inside a block. -==== tests/cases/compiler/constDeclarations-invalidContexts.ts (11 errors) ==== +==== tests/cases/compiler/constDeclarations-invalidContexts.ts (9 errors) ==== // Errors, const must be defined inside a block if (true) @@ -20,8 +18,6 @@ tests/cases/compiler/constDeclarations-invalidContexts.ts(29,29): error TS1156: !!! error TS1156: 'const' declarations can only be declared inside a block. else const c2 = 0; - ~~~~~ -!!! error TS7027: Unreachable code detected. ~~~~~~~~~~~~~ !!! error TS1156: 'const' declarations can only be declared inside a block. @@ -31,8 +27,6 @@ tests/cases/compiler/constDeclarations-invalidContexts.ts(29,29): error TS1156: !!! error TS1156: 'const' declarations can only be declared inside a block. do - ~~ -!!! error TS7027: Unreachable code detected. const c4 = 0; ~~~~~~~~~~~~~ !!! error TS1156: 'const' declarations can only be declared inside a block. diff --git a/tests/baselines/reference/constDeclarations-validContexts.errors.txt b/tests/baselines/reference/constDeclarations-validContexts.errors.txt index e55e5f578ba..7af16a53cbe 100644 --- a/tests/baselines/reference/constDeclarations-validContexts.errors.txt +++ b/tests/baselines/reference/constDeclarations-validContexts.errors.txt @@ -1,9 +1,7 @@ -tests/cases/compiler/constDeclarations-validContexts.ts(8,5): error TS7027: Unreachable code detected. -tests/cases/compiler/constDeclarations-validContexts.ts(15,1): error TS7027: Unreachable code detected. tests/cases/compiler/constDeclarations-validContexts.ts(20,7): error TS2410: All symbols within a 'with' block will be resolved to 'any'. -==== tests/cases/compiler/constDeclarations-validContexts.ts (3 errors) ==== +==== tests/cases/compiler/constDeclarations-validContexts.ts (1 errors) ==== // Control flow statements with blocks @@ -12,8 +10,6 @@ tests/cases/compiler/constDeclarations-validContexts.ts(20,7): error TS2410: All } else { const c2 = 0; - ~~~~~ -!!! error TS7027: Unreachable code detected. } while (true) { @@ -21,8 +17,6 @@ tests/cases/compiler/constDeclarations-validContexts.ts(20,7): error TS2410: All } do { - ~~ -!!! error TS7027: Unreachable code detected. const c4 = 0; } while (true); diff --git a/tests/baselines/reference/constructorWithIncompleteTypeAnnotation.errors.txt b/tests/baselines/reference/constructorWithIncompleteTypeAnnotation.errors.txt index 56213610b83..b9804b1b6db 100644 --- a/tests/baselines/reference/constructorWithIncompleteTypeAnnotation.errors.txt +++ b/tests/baselines/reference/constructorWithIncompleteTypeAnnotation.errors.txt @@ -1,91 +1,90 @@ -tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(11,13): error TS2304: Cannot find name 'module'. -tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(11,13): error TS2503: Cannot find namespace 'module'. -tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(11,19): error TS1005: ';' expected. -tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(22,35): error TS1005: ')' expected. -tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(22,39): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(24,28): error TS1005: ':' expected. -tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(24,29): error TS1005: ',' expected. -tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(27,18): error TS1128: Declaration or statement expected. -tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(27,26): error TS2304: Cannot find name 'bfs'. -tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(28,30): error TS1005: '=' expected. -tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(31,18): error TS1109: Expression expected. -tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(31,18): error TS7027: Unreachable code detected. -tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(34,17): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(34,26): error TS1005: ';' expected. -tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(34,28): error TS2304: Cannot find name 'bfs'. -tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(35,21): error TS2365: Operator '!=' cannot be applied to types 'boolean' and 'number'. -tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(38,17): error TS1109: Expression expected. -tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(40,28): error TS2304: Cannot find name 'bfs'. -tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(40,41): error TS1005: ';' expected. -tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(40,45): error TS1002: Unterminated string literal. -tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(41,21): error TS2365: Operator '!=' cannot be applied to types 'boolean' and 'number'. -tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(47,17): error TS2304: Cannot find name 'console'. -tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(49,13): error TS1068: Unexpected token. A constructor, method, accessor, or property was expected. -tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(53,13): error TS2304: Cannot find name 'console'. -tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(58,5): error TS1128: Declaration or statement expected. -tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(69,13): error TS1109: Expression expected. -tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(72,37): error TS1127: Invalid character. -tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(81,13): error TS1109: Expression expected. -tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(89,23): error TS2364: Invalid left-hand side of assignment expression. -tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(90,13): error TS1109: Expression expected. -tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(105,29): error TS1109: Expression expected. -tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(106,13): error TS1109: Expression expected. -tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(108,24): error TS2365: Operator '+' cannot be applied to types 'number' and 'boolean'. -tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(138,13): error TS1109: Expression expected. -tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(141,32): error TS1005: '{' expected. -tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(143,13): error TS1005: 'try' expected. -tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(159,24): error TS1109: Expression expected. -tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(159,30): error TS1005: '(' expected. -tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(159,31): error TS2304: Cannot find name 'Property'. -tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(166,13): error TS2365: Operator '+=' cannot be applied to types 'number' and 'void'. -tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(180,40): error TS2447: The '^' operator is not allowed for boolean types. Consider using '!==' instead. -tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(205,28): error TS1109: Expression expected. -tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(213,16): error TS2304: Cannot find name 'bool'. -tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(218,10): error TS1068: Unexpected token. A constructor, method, accessor, or property was expected. -tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(223,23): error TS2304: Cannot find name 'bool'. -tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(227,13): error TS1109: Expression expected. -tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(234,14): error TS1005: '{' expected. -tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(235,9): error TS1128: Declaration or statement expected. -tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(235,16): error TS2304: Cannot find name 'method1'. -tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(235,24): error TS2304: Cannot find name 'val'. -tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(235,27): error TS1005: ',' expected. -tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(235,28): error TS2304: Cannot find name 'number'. -tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(235,36): error TS1005: ';' expected. -tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(238,9): error TS1128: Declaration or statement expected. -tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(238,16): error TS2304: Cannot find name 'method2'. -tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(238,16): error TS7027: Unreachable code detected. -tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(238,26): error TS1005: ';' expected. -tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(241,5): error TS1128: Declaration or statement expected. -tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(246,25): error TS2339: Property 'method1' does not exist on type 'B'. -tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(254,9): error TS2390: Constructor implementation is missing. -tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(254,21): error TS2369: A parameter property is only allowed in a constructor implementation. -tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(254,44): error TS2369: A parameter property is only allowed in a constructor implementation. -tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(254,69): error TS1110: Type expected. -tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(256,9): error TS1128: Declaration or statement expected. -tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(256,16): error TS2304: Cannot find name 'Overloads'. -tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(256,26): error TS2304: Cannot find name 'value'. -tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(256,31): error TS1005: ',' expected. -tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(256,33): error TS2304: Cannot find name 'string'. +tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(12,13): error TS2304: Cannot find name 'module'. +tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(12,13): error TS2503: Cannot find namespace 'module'. +tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(12,19): error TS1005: ';' expected. +tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(23,35): error TS1005: ')' expected. +tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(23,39): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(25,28): error TS1005: ':' expected. +tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(25,29): error TS1005: ',' expected. +tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(28,18): error TS1128: Declaration or statement expected. +tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(28,26): error TS2304: Cannot find name 'bfs'. +tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(29,30): error TS1005: '=' expected. +tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(32,18): error TS1109: Expression expected. +tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(35,17): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(35,26): error TS1005: ';' expected. +tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(35,28): error TS2304: Cannot find name 'bfs'. +tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(36,21): error TS2365: Operator '!=' cannot be applied to types 'boolean' and 'number'. +tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(39,17): error TS1109: Expression expected. +tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(41,28): error TS2304: Cannot find name 'bfs'. +tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(41,41): error TS1005: ';' expected. +tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(41,45): error TS1002: Unterminated string literal. +tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(42,21): error TS2365: Operator '!=' cannot be applied to types 'boolean' and 'number'. +tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(48,17): error TS2304: Cannot find name 'console'. +tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(50,13): error TS1068: Unexpected token. A constructor, method, accessor, or property was expected. +tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(54,13): error TS2304: Cannot find name 'console'. +tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(59,5): error TS1128: Declaration or statement expected. +tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(70,13): error TS1109: Expression expected. +tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(73,37): error TS1127: Invalid character. +tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(82,13): error TS1109: Expression expected. +tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(90,23): error TS2364: Invalid left-hand side of assignment expression. +tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(91,13): error TS1109: Expression expected. +tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(106,29): error TS1109: Expression expected. +tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(107,13): error TS1109: Expression expected. +tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(109,24): error TS2365: Operator '+' cannot be applied to types 'number' and 'boolean'. +tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(139,13): error TS1109: Expression expected. +tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(142,32): error TS1005: '{' expected. +tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(144,13): error TS1005: 'try' expected. +tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(160,24): error TS1109: Expression expected. +tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(160,30): error TS1005: '(' expected. +tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(160,31): error TS2304: Cannot find name 'Property'. +tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(167,13): error TS2365: Operator '+=' cannot be applied to types 'number' and 'void'. +tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(181,40): error TS2447: The '^' operator is not allowed for boolean types. Consider using '!==' instead. +tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(206,28): error TS1109: Expression expected. +tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(214,16): error TS2304: Cannot find name 'bool'. +tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(219,10): error TS1068: Unexpected token. A constructor, method, accessor, or property was expected. +tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(224,23): error TS2304: Cannot find name 'bool'. +tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(228,13): error TS1109: Expression expected. +tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(235,14): error TS1005: '{' expected. +tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(236,9): error TS1128: Declaration or statement expected. +tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(236,16): error TS2304: Cannot find name 'method1'. +tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(236,24): error TS2304: Cannot find name 'val'. +tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(236,27): error TS1005: ',' expected. +tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(236,28): error TS2304: Cannot find name 'number'. +tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(236,36): error TS1005: ';' expected. +tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(239,9): error TS1128: Declaration or statement expected. +tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(239,16): error TS2304: Cannot find name 'method2'. +tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(239,26): error TS1005: ';' expected. +tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(242,5): error TS1128: Declaration or statement expected. +tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(247,25): error TS2339: Property 'method1' does not exist on type 'B'. +tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(255,9): error TS2390: Constructor implementation is missing. +tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(255,21): error TS2369: A parameter property is only allowed in a constructor implementation. +tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(255,44): error TS2369: A parameter property is only allowed in a constructor implementation. +tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(255,69): error TS1110: Type expected. tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(257,9): error TS1128: Declaration or statement expected. tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(257,16): error TS2304: Cannot find name 'Overloads'. -tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(257,27): error TS1135: Argument expression expected. -tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(257,33): error TS1005: '(' expected. -tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(257,35): error TS2304: Cannot find name 'string'. -tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(257,43): error TS1109: Expression expected. -tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(257,52): error TS2304: Cannot find name 'string'. -tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(257,60): error TS1005: ';' expected. -tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(257,65): error TS1109: Expression expected. -tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(259,9): error TS2304: Cannot find name 'public'. -tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(259,16): error TS1005: ';' expected. -tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(259,16): error TS2304: Cannot find name 'DefaultValue'. -tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(259,29): error TS2304: Cannot find name 'value'. -tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(259,35): error TS1109: Expression expected. -tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(259,37): error TS2304: Cannot find name 'string'. -tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(259,55): error TS1005: ';' expected. -tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(261,1): error TS1128: Declaration or statement expected. +tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(257,26): error TS2304: Cannot find name 'value'. +tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(257,31): error TS1005: ',' expected. +tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(257,33): error TS2304: Cannot find name 'string'. +tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(258,9): error TS1128: Declaration or statement expected. +tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(258,16): error TS2304: Cannot find name 'Overloads'. +tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(258,27): error TS1135: Argument expression expected. +tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(258,33): error TS1005: '(' expected. +tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(258,35): error TS2304: Cannot find name 'string'. +tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(258,43): error TS1109: Expression expected. +tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(258,52): error TS2304: Cannot find name 'string'. +tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(258,60): error TS1005: ';' expected. +tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(258,65): error TS1109: Expression expected. +tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(260,9): error TS2304: Cannot find name 'public'. +tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(260,16): error TS1005: ';' expected. +tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(260,16): error TS2304: Cannot find name 'DefaultValue'. +tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(260,29): error TS2304: Cannot find name 'value'. +tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(260,35): error TS1109: Expression expected. +tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(260,37): error TS2304: Cannot find name 'string'. +tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(260,55): error TS1005: ';' expected. +tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(262,1): error TS1128: Declaration or statement expected. -==== tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts (85 errors) ==== +==== tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts (83 errors) ==== + declare module "fs" { export class File { constructor(filename: string); @@ -142,8 +141,6 @@ tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(261,1): error TS ^ ~ !!! error TS1109: Expression expected. - ~ -!!! error TS7027: Unreachable code detected. retValue = bfs.TYPES(); @@ -437,8 +434,6 @@ tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(261,1): error TS !!! error TS1128: Declaration or statement expected. ~~~~~~~ !!! error TS2304: Cannot find name 'method2'. - ~~~~~~~ -!!! error TS7027: Unreachable code detected. ~ !!! error TS1005: ';' expected. return 2 * this.method1(2); diff --git a/tests/baselines/reference/constructorWithIncompleteTypeAnnotation.js b/tests/baselines/reference/constructorWithIncompleteTypeAnnotation.js index 5a61d4d5d7e..4765d1de283 100644 --- a/tests/baselines/reference/constructorWithIncompleteTypeAnnotation.js +++ b/tests/baselines/reference/constructorWithIncompleteTypeAnnotation.js @@ -1,4 +1,5 @@ //// [constructorWithIncompleteTypeAnnotation.ts] + declare module "fs" { export class File { constructor(filename: string); diff --git a/tests/baselines/reference/continueNotInIterationStatement4.errors.txt b/tests/baselines/reference/continueNotInIterationStatement4.errors.txt index 3f0d57ac45d..dec899c7218 100644 --- a/tests/baselines/reference/continueNotInIterationStatement4.errors.txt +++ b/tests/baselines/reference/continueNotInIterationStatement4.errors.txt @@ -1,11 +1,9 @@ -tests/cases/compiler/continueNotInIterationStatement4.ts(1,1): error TS7028: Unused label. -tests/cases/compiler/continueNotInIterationStatement4.ts(4,5): error TS1107: Jump target cannot cross function boundary. +tests/cases/compiler/continueNotInIterationStatement4.ts(5,5): error TS1107: Jump target cannot cross function boundary. -==== tests/cases/compiler/continueNotInIterationStatement4.ts (2 errors) ==== +==== tests/cases/compiler/continueNotInIterationStatement4.ts (1 errors) ==== + TWO: - ~~~ -!!! error TS7028: Unused label. while (true){ var x = () => { continue TWO; diff --git a/tests/baselines/reference/continueNotInIterationStatement4.js b/tests/baselines/reference/continueNotInIterationStatement4.js index f3f52ecb48c..50261be23b1 100644 --- a/tests/baselines/reference/continueNotInIterationStatement4.js +++ b/tests/baselines/reference/continueNotInIterationStatement4.js @@ -1,4 +1,5 @@ //// [continueNotInIterationStatement4.ts] + TWO: while (true){ var x = () => { diff --git a/tests/baselines/reference/continueTarget3.errors.txt b/tests/baselines/reference/continueTarget3.errors.txt deleted file mode 100644 index a3f6b64e7c6..00000000000 --- a/tests/baselines/reference/continueTarget3.errors.txt +++ /dev/null @@ -1,11 +0,0 @@ -tests/cases/compiler/continueTarget3.ts(2,1): error TS7028: Unused label. - - -==== tests/cases/compiler/continueTarget3.ts (1 errors) ==== - target1: - target2: - ~~~~~~~ -!!! error TS7028: Unused label. - while (true) { - continue target1; - } \ No newline at end of file diff --git a/tests/baselines/reference/continueTarget3.js b/tests/baselines/reference/continueTarget3.js index 052b7b593c3..70c2d2590e5 100644 --- a/tests/baselines/reference/continueTarget3.js +++ b/tests/baselines/reference/continueTarget3.js @@ -1,4 +1,5 @@ //// [continueTarget3.ts] + target1: target2: while (true) { diff --git a/tests/baselines/reference/continueTarget3.symbols b/tests/baselines/reference/continueTarget3.symbols new file mode 100644 index 00000000000..a5decfe16d1 --- /dev/null +++ b/tests/baselines/reference/continueTarget3.symbols @@ -0,0 +1,8 @@ +=== tests/cases/compiler/continueTarget3.ts === + +No type information for this code.target1: +No type information for this code.target2: +No type information for this code.while (true) { +No type information for this code. continue target1; +No type information for this code.} +No type information for this code. \ No newline at end of file diff --git a/tests/baselines/reference/continueTarget3.types b/tests/baselines/reference/continueTarget3.types new file mode 100644 index 00000000000..d55f1c3f6d2 --- /dev/null +++ b/tests/baselines/reference/continueTarget3.types @@ -0,0 +1,14 @@ +=== tests/cases/compiler/continueTarget3.ts === + +target1: +>target1 : any + +target2: +>target2 : any + +while (true) { +>true : boolean + + continue target1; +>target1 : any +} diff --git a/tests/baselines/reference/continueTarget4.errors.txt b/tests/baselines/reference/continueTarget4.errors.txt deleted file mode 100644 index d8f3cc12892..00000000000 --- a/tests/baselines/reference/continueTarget4.errors.txt +++ /dev/null @@ -1,11 +0,0 @@ -tests/cases/compiler/continueTarget4.ts(1,1): error TS7028: Unused label. - - -==== tests/cases/compiler/continueTarget4.ts (1 errors) ==== - target1: - ~~~~~~~ -!!! error TS7028: Unused label. - target2: - while (true) { - continue target2; - } \ No newline at end of file diff --git a/tests/baselines/reference/continueTarget4.js b/tests/baselines/reference/continueTarget4.js index 0f6211f9202..23c20a03260 100644 --- a/tests/baselines/reference/continueTarget4.js +++ b/tests/baselines/reference/continueTarget4.js @@ -1,4 +1,5 @@ //// [continueTarget4.ts] + target1: target2: while (true) { diff --git a/tests/baselines/reference/continueTarget4.symbols b/tests/baselines/reference/continueTarget4.symbols new file mode 100644 index 00000000000..fc69a881a60 --- /dev/null +++ b/tests/baselines/reference/continueTarget4.symbols @@ -0,0 +1,8 @@ +=== tests/cases/compiler/continueTarget4.ts === + +No type information for this code.target1: +No type information for this code.target2: +No type information for this code.while (true) { +No type information for this code. continue target2; +No type information for this code.} +No type information for this code. \ No newline at end of file diff --git a/tests/baselines/reference/continueTarget4.types b/tests/baselines/reference/continueTarget4.types new file mode 100644 index 00000000000..e3e3ae82dfe --- /dev/null +++ b/tests/baselines/reference/continueTarget4.types @@ -0,0 +1,14 @@ +=== tests/cases/compiler/continueTarget4.ts === + +target1: +>target1 : any + +target2: +>target2 : any + +while (true) { +>true : boolean + + continue target2; +>target2 : any +} diff --git a/tests/baselines/reference/continueTarget5.errors.txt b/tests/baselines/reference/continueTarget5.errors.txt index 6f0d3a2f6bf..854f57017b6 100644 --- a/tests/baselines/reference/continueTarget5.errors.txt +++ b/tests/baselines/reference/continueTarget5.errors.txt @@ -1,11 +1,9 @@ -tests/cases/compiler/continueTarget5.ts(1,1): error TS7028: Unused label. -tests/cases/compiler/continueTarget5.ts(5,7): error TS1107: Jump target cannot cross function boundary. +tests/cases/compiler/continueTarget5.ts(6,7): error TS1107: Jump target cannot cross function boundary. -==== tests/cases/compiler/continueTarget5.ts (2 errors) ==== +==== tests/cases/compiler/continueTarget5.ts (1 errors) ==== + target: - ~~~~~~ -!!! error TS7028: Unused label. while (true) { function f() { while (true) { diff --git a/tests/baselines/reference/continueTarget5.js b/tests/baselines/reference/continueTarget5.js index 5bf309d2690..030a1c2589c 100644 --- a/tests/baselines/reference/continueTarget5.js +++ b/tests/baselines/reference/continueTarget5.js @@ -1,4 +1,5 @@ //// [continueTarget5.ts] + target: while (true) { function f() { diff --git a/tests/baselines/reference/doWhileBreakStatements.errors.txt b/tests/baselines/reference/doWhileBreakStatements.errors.txt deleted file mode 100644 index e31109858cf..00000000000 --- a/tests/baselines/reference/doWhileBreakStatements.errors.txt +++ /dev/null @@ -1,50 +0,0 @@ -tests/cases/conformance/statements/breakStatements/doWhileBreakStatements.ts(11,1): error TS7028: Unused label. -tests/cases/conformance/statements/breakStatements/doWhileBreakStatements.ts(19,5): error TS7028: Unused label. -tests/cases/conformance/statements/breakStatements/doWhileBreakStatements.ts(30,1): error TS7027: Unreachable code detected. - - -==== tests/cases/conformance/statements/breakStatements/doWhileBreakStatements.ts (3 errors) ==== - do { - break; - } while(true) - - ONE: - do { - break ONE; - } - while (true) - - TWO: - ~~~ -!!! error TS7028: Unused label. - THREE: - do { - break THREE; - }while (true) - - FOUR: - do { - FIVE: - ~~~~ -!!! error TS7028: Unused label. - do { - break FOUR; - }while (true) - }while (true) - - do { - SIX: - do break SIX; while(true) - }while (true) - - SEVEN: - ~~~~~ -!!! error TS7027: Unreachable code detected. - do do do break SEVEN; while (true) while (true) while (true) - - EIGHT: - do{ - var fn = function () { } - break EIGHT; - }while(true) - \ No newline at end of file diff --git a/tests/baselines/reference/doWhileBreakStatements.js b/tests/baselines/reference/doWhileBreakStatements.js index a2bc0d3c549..8e272ceed0a 100644 --- a/tests/baselines/reference/doWhileBreakStatements.js +++ b/tests/baselines/reference/doWhileBreakStatements.js @@ -1,4 +1,5 @@ //// [doWhileBreakStatements.ts] + do { break; } while(true) diff --git a/tests/baselines/reference/doWhileBreakStatements.symbols b/tests/baselines/reference/doWhileBreakStatements.symbols new file mode 100644 index 00000000000..14db540598d --- /dev/null +++ b/tests/baselines/reference/doWhileBreakStatements.symbols @@ -0,0 +1,42 @@ +=== tests/cases/conformance/statements/breakStatements/doWhileBreakStatements.ts === + +do { + break; +} while(true) + +ONE: +do { + break ONE; +} +while (true) + +TWO: +THREE: +do { + break THREE; +}while (true) + +FOUR: +do { + FIVE: + do { + break FOUR; + }while (true) +}while (true) + +do { + SIX: + do break SIX; while(true) +}while (true) + +SEVEN: +do do do break SEVEN; while (true) while (true) while (true) + +EIGHT: +do{ + var fn = function () { } +>fn : Symbol(fn, Decl(doWhileBreakStatements.ts, 35, 7)) + + break EIGHT; +}while(true) + diff --git a/tests/baselines/reference/doWhileBreakStatements.types b/tests/baselines/reference/doWhileBreakStatements.types new file mode 100644 index 00000000000..f143cb17d08 --- /dev/null +++ b/tests/baselines/reference/doWhileBreakStatements.types @@ -0,0 +1,81 @@ +=== tests/cases/conformance/statements/breakStatements/doWhileBreakStatements.ts === + +do { + break; +} while(true) +>true : boolean + +ONE: +>ONE : any + +do { + break ONE; +>ONE : any +} +while (true) +>true : boolean + +TWO: +>TWO : any + +THREE: +>THREE : any + +do { + break THREE; +>THREE : any + +}while (true) +>true : boolean + +FOUR: +>FOUR : any + +do { + FIVE: +>FIVE : any + + do { + break FOUR; +>FOUR : any + + }while (true) +>true : boolean + +}while (true) +>true : boolean + +do { + SIX: +>SIX : any + + do break SIX; while(true) +>SIX : any +>true : boolean + +}while (true) +>true : boolean + +SEVEN: +>SEVEN : any + +do do do break SEVEN; while (true) while (true) while (true) +>SEVEN : any +>true : boolean +>true : boolean +>true : boolean + +EIGHT: +>EIGHT : any + +do{ + var fn = function () { } +>fn : () => void +>function () { } : () => void + + break EIGHT; +>EIGHT : any + +}while(true) +>true : boolean + diff --git a/tests/baselines/reference/doWhileContinueStatements.errors.txt b/tests/baselines/reference/doWhileContinueStatements.errors.txt deleted file mode 100644 index 491e1242e2f..00000000000 --- a/tests/baselines/reference/doWhileContinueStatements.errors.txt +++ /dev/null @@ -1,44 +0,0 @@ -tests/cases/conformance/statements/continueStatements/doWhileContinueStatements.ts(5,1): error TS7027: Unreachable code detected. - - -==== tests/cases/conformance/statements/continueStatements/doWhileContinueStatements.ts (1 errors) ==== - do { - continue; - } while(true) - - ONE: - ~~~ -!!! error TS7027: Unreachable code detected. - do { - continue ONE; - } - while (true) - - TWO: - THREE: - do { - continue THREE; - }while (true) - - FOUR: - do { - FIVE: - do { - continue FOUR; - }while (true) - }while (true) - - do { - SIX: - do continue SIX; while(true) - }while (true) - - SEVEN: - do do do continue SEVEN; while (true) while (true) while (true) - - EIGHT: - do{ - var fn = function () { } - continue EIGHT; - }while(true) - \ No newline at end of file diff --git a/tests/baselines/reference/doWhileContinueStatements.js b/tests/baselines/reference/doWhileContinueStatements.js index 7f73157fd99..51bac3c4e09 100644 --- a/tests/baselines/reference/doWhileContinueStatements.js +++ b/tests/baselines/reference/doWhileContinueStatements.js @@ -1,4 +1,5 @@ //// [doWhileContinueStatements.ts] + do { continue; } while(true) diff --git a/tests/baselines/reference/doWhileContinueStatements.symbols b/tests/baselines/reference/doWhileContinueStatements.symbols new file mode 100644 index 00000000000..36ca2dde764 --- /dev/null +++ b/tests/baselines/reference/doWhileContinueStatements.symbols @@ -0,0 +1,42 @@ +=== tests/cases/conformance/statements/continueStatements/doWhileContinueStatements.ts === + +do { + continue; +} while(true) + +ONE: +do { + continue ONE; +} +while (true) + +TWO: +THREE: +do { + continue THREE; +}while (true) + +FOUR: +do { + FIVE: + do { + continue FOUR; + }while (true) +}while (true) + +do { + SIX: + do continue SIX; while(true) +}while (true) + +SEVEN: +do do do continue SEVEN; while (true) while (true) while (true) + +EIGHT: +do{ + var fn = function () { } +>fn : Symbol(fn, Decl(doWhileContinueStatements.ts, 35, 7)) + + continue EIGHT; +}while(true) + diff --git a/tests/baselines/reference/doWhileContinueStatements.types b/tests/baselines/reference/doWhileContinueStatements.types new file mode 100644 index 00000000000..e4d3191d040 --- /dev/null +++ b/tests/baselines/reference/doWhileContinueStatements.types @@ -0,0 +1,81 @@ +=== tests/cases/conformance/statements/continueStatements/doWhileContinueStatements.ts === + +do { + continue; +} while(true) +>true : boolean + +ONE: +>ONE : any + +do { + continue ONE; +>ONE : any +} +while (true) +>true : boolean + +TWO: +>TWO : any + +THREE: +>THREE : any + +do { + continue THREE; +>THREE : any + +}while (true) +>true : boolean + +FOUR: +>FOUR : any + +do { + FIVE: +>FIVE : any + + do { + continue FOUR; +>FOUR : any + + }while (true) +>true : boolean + +}while (true) +>true : boolean + +do { + SIX: +>SIX : any + + do continue SIX; while(true) +>SIX : any +>true : boolean + +}while (true) +>true : boolean + +SEVEN: +>SEVEN : any + +do do do continue SEVEN; while (true) while (true) while (true) +>SEVEN : any +>true : boolean +>true : boolean +>true : boolean + +EIGHT: +>EIGHT : any + +do{ + var fn = function () { } +>fn : () => void +>function () { } : () => void + + continue EIGHT; +>EIGHT : any + +}while(true) +>true : boolean + diff --git a/tests/baselines/reference/downlevelLetConst16.errors.txt b/tests/baselines/reference/downlevelLetConst16.errors.txt index a6651574b9e..a6ada633016 100644 --- a/tests/baselines/reference/downlevelLetConst16.errors.txt +++ b/tests/baselines/reference/downlevelLetConst16.errors.txt @@ -1,14 +1,13 @@ -tests/cases/compiler/downlevelLetConst16.ts(151,5): error TS7027: Unreachable code detected. -tests/cases/compiler/downlevelLetConst16.ts(151,15): error TS2525: Initializer provides no value for this binding element and the binding element has no default value. -tests/cases/compiler/downlevelLetConst16.ts(164,5): error TS7027: Unreachable code detected. -tests/cases/compiler/downlevelLetConst16.ts(164,17): error TS2525: Initializer provides no value for this binding element and the binding element has no default value. -tests/cases/compiler/downlevelLetConst16.ts(195,14): error TS2461: Type 'undefined' is not an array type. -tests/cases/compiler/downlevelLetConst16.ts(202,15): error TS2459: Type 'undefined' has no property 'a' and no string index signature. -tests/cases/compiler/downlevelLetConst16.ts(216,16): error TS2461: Type 'undefined' is not an array type. -tests/cases/compiler/downlevelLetConst16.ts(223,17): error TS2459: Type 'undefined' has no property 'a' and no string index signature. +tests/cases/compiler/downlevelLetConst16.ts(152,15): error TS2525: Initializer provides no value for this binding element and the binding element has no default value. +tests/cases/compiler/downlevelLetConst16.ts(165,17): error TS2525: Initializer provides no value for this binding element and the binding element has no default value. +tests/cases/compiler/downlevelLetConst16.ts(196,14): error TS2461: Type 'undefined' is not an array type. +tests/cases/compiler/downlevelLetConst16.ts(203,15): error TS2459: Type 'undefined' has no property 'a' and no string index signature. +tests/cases/compiler/downlevelLetConst16.ts(217,16): error TS2461: Type 'undefined' is not an array type. +tests/cases/compiler/downlevelLetConst16.ts(224,17): error TS2459: Type 'undefined' has no property 'a' and no string index signature. -==== tests/cases/compiler/downlevelLetConst16.ts (8 errors) ==== +==== tests/cases/compiler/downlevelLetConst16.ts (6 errors) ==== + 'use strict' declare function use(a: any); @@ -160,8 +159,6 @@ tests/cases/compiler/downlevelLetConst16.ts(223,17): error TS2459: Type 'undefin use(x); } for (let [y] = []; ;) { - ~~~ -!!! error TS7027: Unreachable code detected. ~ !!! error TS2525: Initializer provides no value for this binding element and the binding element has no default value. use(y); @@ -177,8 +174,6 @@ tests/cases/compiler/downlevelLetConst16.ts(223,17): error TS2459: Type 'undefin use(x); } for (const [y] = []; ;) { - ~~~ -!!! error TS7027: Unreachable code detected. ~ !!! error TS2525: Initializer provides no value for this binding element and the binding element has no default value. use(y); diff --git a/tests/baselines/reference/downlevelLetConst16.js b/tests/baselines/reference/downlevelLetConst16.js index 874fc121191..d6f05f7584a 100644 --- a/tests/baselines/reference/downlevelLetConst16.js +++ b/tests/baselines/reference/downlevelLetConst16.js @@ -1,4 +1,5 @@ //// [downlevelLetConst16.ts] + 'use strict' declare function use(a: any); diff --git a/tests/baselines/reference/downlevelLetConst17.errors.txt b/tests/baselines/reference/downlevelLetConst17.errors.txt deleted file mode 100644 index 0365b638449..00000000000 --- a/tests/baselines/reference/downlevelLetConst17.errors.txt +++ /dev/null @@ -1,73 +0,0 @@ -tests/cases/compiler/downlevelLetConst17.ts(9,1): error TS7027: Unreachable code detected. - - -==== tests/cases/compiler/downlevelLetConst17.ts (1 errors) ==== - 'use strict' - - declare function use(a: any); - - var x; - for (let x = 10; ;) { - use(x); - } - use(x); - ~~~ -!!! error TS7027: Unreachable code detected. - - for (const x = 10; ;) { - use(x); - } - - for (; ;) { - let x = 10; - use(x); - x = 1; - } - - for (; ;) { - const x = 10; - use(x); - } - - for (let x; ;) { - use(x); - x = 1; - } - - for (; ;) { - let x; - use(x); - x = 1; - } - - while (true) { - let x; - use(x); - } - - while (true) { - const x = true; - use(x); - } - - do { - let x; - use(x); - } while (true); - - do { - let x; - use(x); - } while (true); - - for (let x in []) { - use(x); - } - - for (const x in []) { - use(x); - } - - for (const x of []) { - use(x); - } \ No newline at end of file diff --git a/tests/baselines/reference/downlevelLetConst17.symbols b/tests/baselines/reference/downlevelLetConst17.symbols new file mode 100644 index 00000000000..809a835774c --- /dev/null +++ b/tests/baselines/reference/downlevelLetConst17.symbols @@ -0,0 +1,134 @@ +=== tests/cases/compiler/downlevelLetConst17.ts === +'use strict' + +declare function use(a: any); +>use : Symbol(use, Decl(downlevelLetConst17.ts, 0, 12)) +>a : Symbol(a, Decl(downlevelLetConst17.ts, 2, 21)) + +var x; +>x : Symbol(x, Decl(downlevelLetConst17.ts, 4, 3)) + +for (let x = 10; ;) { +>x : Symbol(x, Decl(downlevelLetConst17.ts, 5, 8)) + + use(x); +>use : Symbol(use, Decl(downlevelLetConst17.ts, 0, 12)) +>x : Symbol(x, Decl(downlevelLetConst17.ts, 5, 8)) +} +use(x); +>use : Symbol(use, Decl(downlevelLetConst17.ts, 0, 12)) +>x : Symbol(x, Decl(downlevelLetConst17.ts, 4, 3)) + +for (const x = 10; ;) { +>x : Symbol(x, Decl(downlevelLetConst17.ts, 10, 10)) + + use(x); +>use : Symbol(use, Decl(downlevelLetConst17.ts, 0, 12)) +>x : Symbol(x, Decl(downlevelLetConst17.ts, 10, 10)) +} + +for (; ;) { + let x = 10; +>x : Symbol(x, Decl(downlevelLetConst17.ts, 15, 7)) + + use(x); +>use : Symbol(use, Decl(downlevelLetConst17.ts, 0, 12)) +>x : Symbol(x, Decl(downlevelLetConst17.ts, 15, 7)) + + x = 1; +>x : Symbol(x, Decl(downlevelLetConst17.ts, 15, 7)) +} + +for (; ;) { + const x = 10; +>x : Symbol(x, Decl(downlevelLetConst17.ts, 21, 9)) + + use(x); +>use : Symbol(use, Decl(downlevelLetConst17.ts, 0, 12)) +>x : Symbol(x, Decl(downlevelLetConst17.ts, 21, 9)) +} + +for (let x; ;) { +>x : Symbol(x, Decl(downlevelLetConst17.ts, 25, 8)) + + use(x); +>use : Symbol(use, Decl(downlevelLetConst17.ts, 0, 12)) +>x : Symbol(x, Decl(downlevelLetConst17.ts, 25, 8)) + + x = 1; +>x : Symbol(x, Decl(downlevelLetConst17.ts, 25, 8)) +} + +for (; ;) { + let x; +>x : Symbol(x, Decl(downlevelLetConst17.ts, 31, 7)) + + use(x); +>use : Symbol(use, Decl(downlevelLetConst17.ts, 0, 12)) +>x : Symbol(x, Decl(downlevelLetConst17.ts, 31, 7)) + + x = 1; +>x : Symbol(x, Decl(downlevelLetConst17.ts, 31, 7)) +} + +while (true) { + let x; +>x : Symbol(x, Decl(downlevelLetConst17.ts, 37, 7)) + + use(x); +>use : Symbol(use, Decl(downlevelLetConst17.ts, 0, 12)) +>x : Symbol(x, Decl(downlevelLetConst17.ts, 37, 7)) +} + +while (true) { + const x = true; +>x : Symbol(x, Decl(downlevelLetConst17.ts, 42, 9)) + + use(x); +>use : Symbol(use, Decl(downlevelLetConst17.ts, 0, 12)) +>x : Symbol(x, Decl(downlevelLetConst17.ts, 42, 9)) +} + +do { + let x; +>x : Symbol(x, Decl(downlevelLetConst17.ts, 47, 7)) + + use(x); +>use : Symbol(use, Decl(downlevelLetConst17.ts, 0, 12)) +>x : Symbol(x, Decl(downlevelLetConst17.ts, 47, 7)) + +} while (true); + +do { + let x; +>x : Symbol(x, Decl(downlevelLetConst17.ts, 52, 7)) + + use(x); +>use : Symbol(use, Decl(downlevelLetConst17.ts, 0, 12)) +>x : Symbol(x, Decl(downlevelLetConst17.ts, 52, 7)) + +} while (true); + +for (let x in []) { +>x : Symbol(x, Decl(downlevelLetConst17.ts, 56, 8)) + + use(x); +>use : Symbol(use, Decl(downlevelLetConst17.ts, 0, 12)) +>x : Symbol(x, Decl(downlevelLetConst17.ts, 56, 8)) +} + +for (const x in []) { +>x : Symbol(x, Decl(downlevelLetConst17.ts, 60, 10)) + + use(x); +>use : Symbol(use, Decl(downlevelLetConst17.ts, 0, 12)) +>x : Symbol(x, Decl(downlevelLetConst17.ts, 60, 10)) +} + +for (const x of []) { +>x : Symbol(x, Decl(downlevelLetConst17.ts, 64, 10)) + + use(x); +>use : Symbol(use, Decl(downlevelLetConst17.ts, 0, 12)) +>x : Symbol(x, Decl(downlevelLetConst17.ts, 64, 10)) +} diff --git a/tests/baselines/reference/downlevelLetConst17.types b/tests/baselines/reference/downlevelLetConst17.types new file mode 100644 index 00000000000..824abcc76be --- /dev/null +++ b/tests/baselines/reference/downlevelLetConst17.types @@ -0,0 +1,169 @@ +=== tests/cases/compiler/downlevelLetConst17.ts === +'use strict' +>'use strict' : string + +declare function use(a: any); +>use : (a: any) => any +>a : any + +var x; +>x : any + +for (let x = 10; ;) { +>x : number +>10 : number + + use(x); +>use(x) : any +>use : (a: any) => any +>x : number +} +use(x); +>use(x) : any +>use : (a: any) => any +>x : any + +for (const x = 10; ;) { +>x : number +>10 : number + + use(x); +>use(x) : any +>use : (a: any) => any +>x : number +} + +for (; ;) { + let x = 10; +>x : number +>10 : number + + use(x); +>use(x) : any +>use : (a: any) => any +>x : number + + x = 1; +>x = 1 : number +>x : number +>1 : number +} + +for (; ;) { + const x = 10; +>x : number +>10 : number + + use(x); +>use(x) : any +>use : (a: any) => any +>x : number +} + +for (let x; ;) { +>x : any + + use(x); +>use(x) : any +>use : (a: any) => any +>x : any + + x = 1; +>x = 1 : number +>x : any +>1 : number +} + +for (; ;) { + let x; +>x : any + + use(x); +>use(x) : any +>use : (a: any) => any +>x : any + + x = 1; +>x = 1 : number +>x : any +>1 : number +} + +while (true) { +>true : boolean + + let x; +>x : any + + use(x); +>use(x) : any +>use : (a: any) => any +>x : any +} + +while (true) { +>true : boolean + + const x = true; +>x : boolean +>true : boolean + + use(x); +>use(x) : any +>use : (a: any) => any +>x : boolean +} + +do { + let x; +>x : any + + use(x); +>use(x) : any +>use : (a: any) => any +>x : any + +} while (true); +>true : boolean + +do { + let x; +>x : any + + use(x); +>use(x) : any +>use : (a: any) => any +>x : any + +} while (true); +>true : boolean + +for (let x in []) { +>x : any +>[] : undefined[] + + use(x); +>use(x) : any +>use : (a: any) => any +>x : any +} + +for (const x in []) { +>x : any +>[] : undefined[] + + use(x); +>use(x) : any +>use : (a: any) => any +>x : any +} + +for (const x of []) { +>x : any +>[] : undefined[] + + use(x); +>use(x) : any +>use : (a: any) => any +>x : any +} diff --git a/tests/baselines/reference/downlevelLetConst18.errors.txt b/tests/baselines/reference/downlevelLetConst18.errors.txt index 5d9d24a4d6d..9f9700dbb7e 100644 --- a/tests/baselines/reference/downlevelLetConst18.errors.txt +++ b/tests/baselines/reference/downlevelLetConst18.errors.txt @@ -1,16 +1,16 @@ -tests/cases/compiler/downlevelLetConst18.ts(3,1): error TS4091: Loop contains block-scoped variable 'x' referenced by a function in the loop. This is only supported in ECMAScript 6 or higher. -tests/cases/compiler/downlevelLetConst18.ts(4,14): error TS2393: Duplicate function implementation. -tests/cases/compiler/downlevelLetConst18.ts(7,1): error TS4091: Loop contains block-scoped variable 'x' referenced by a function in the loop. This is only supported in ECMAScript 6 or higher. -tests/cases/compiler/downlevelLetConst18.ts(7,1): error TS7027: Unreachable code detected. -tests/cases/compiler/downlevelLetConst18.ts(8,14): error TS2393: Duplicate function implementation. -tests/cases/compiler/downlevelLetConst18.ts(11,1): error TS4091: Loop contains block-scoped variable 'x' referenced by a function in the loop. This is only supported in ECMAScript 6 or higher. -tests/cases/compiler/downlevelLetConst18.ts(15,1): error TS4091: Loop contains block-scoped variable 'x' referenced by a function in the loop. This is only supported in ECMAScript 6 or higher. -tests/cases/compiler/downlevelLetConst18.ts(19,1): error TS4091: Loop contains block-scoped variable 'x' referenced by a function in the loop. This is only supported in ECMAScript 6 or higher. -tests/cases/compiler/downlevelLetConst18.ts(23,1): error TS4091: Loop contains block-scoped variable 'x' referenced by a function in the loop. This is only supported in ECMAScript 6 or higher. -tests/cases/compiler/downlevelLetConst18.ts(27,1): error TS4091: Loop contains block-scoped variable 'x' referenced by a function in the loop. This is only supported in ECMAScript 6 or higher. +tests/cases/compiler/downlevelLetConst18.ts(4,1): error TS4091: Loop contains block-scoped variable 'x' referenced by a function in the loop. This is only supported in ECMAScript 6 or higher. +tests/cases/compiler/downlevelLetConst18.ts(5,14): error TS2393: Duplicate function implementation. +tests/cases/compiler/downlevelLetConst18.ts(8,1): error TS4091: Loop contains block-scoped variable 'x' referenced by a function in the loop. This is only supported in ECMAScript 6 or higher. +tests/cases/compiler/downlevelLetConst18.ts(9,14): error TS2393: Duplicate function implementation. +tests/cases/compiler/downlevelLetConst18.ts(12,1): error TS4091: Loop contains block-scoped variable 'x' referenced by a function in the loop. This is only supported in ECMAScript 6 or higher. +tests/cases/compiler/downlevelLetConst18.ts(16,1): error TS4091: Loop contains block-scoped variable 'x' referenced by a function in the loop. This is only supported in ECMAScript 6 or higher. +tests/cases/compiler/downlevelLetConst18.ts(20,1): error TS4091: Loop contains block-scoped variable 'x' referenced by a function in the loop. This is only supported in ECMAScript 6 or higher. +tests/cases/compiler/downlevelLetConst18.ts(24,1): error TS4091: Loop contains block-scoped variable 'x' referenced by a function in the loop. This is only supported in ECMAScript 6 or higher. +tests/cases/compiler/downlevelLetConst18.ts(28,1): error TS4091: Loop contains block-scoped variable 'x' referenced by a function in the loop. This is only supported in ECMAScript 6 or higher. -==== tests/cases/compiler/downlevelLetConst18.ts (10 errors) ==== +==== tests/cases/compiler/downlevelLetConst18.ts (9 errors) ==== + 'use strict' for (let x; ;) { @@ -24,8 +24,6 @@ tests/cases/compiler/downlevelLetConst18.ts(27,1): error TS4091: Loop contains b for (let x; ;) { ~~~ !!! error TS4091: Loop contains block-scoped variable 'x' referenced by a function in the loop. This is only supported in ECMAScript 6 or higher. - ~~~ -!!! error TS7027: Unreachable code detected. function foo() { x }; ~~~ !!! error TS2393: Duplicate function implementation. diff --git a/tests/baselines/reference/downlevelLetConst18.js b/tests/baselines/reference/downlevelLetConst18.js index 70b8cb9e346..0674929d225 100644 --- a/tests/baselines/reference/downlevelLetConst18.js +++ b/tests/baselines/reference/downlevelLetConst18.js @@ -1,4 +1,5 @@ //// [downlevelLetConst18.ts] + 'use strict' for (let x; ;) { diff --git a/tests/baselines/reference/duplicateLabel1.errors.txt b/tests/baselines/reference/duplicateLabel1.errors.txt index 2f89b400e21..cf116f656fc 100644 --- a/tests/baselines/reference/duplicateLabel1.errors.txt +++ b/tests/baselines/reference/duplicateLabel1.errors.txt @@ -1,11 +1,9 @@ -tests/cases/compiler/duplicateLabel1.ts(1,1): error TS7028: Unused label. -tests/cases/compiler/duplicateLabel1.ts(2,1): error TS1114: Duplicate label 'target' +tests/cases/compiler/duplicateLabel1.ts(3,1): error TS1114: Duplicate label 'target' -==== tests/cases/compiler/duplicateLabel1.ts (2 errors) ==== +==== tests/cases/compiler/duplicateLabel1.ts (1 errors) ==== + target: - ~~~~~~ -!!! error TS7028: Unused label. target: ~~~~~~ !!! error TS1114: Duplicate label 'target' diff --git a/tests/baselines/reference/duplicateLabel1.js b/tests/baselines/reference/duplicateLabel1.js index e7976895c94..5251cec3e36 100644 --- a/tests/baselines/reference/duplicateLabel1.js +++ b/tests/baselines/reference/duplicateLabel1.js @@ -1,4 +1,5 @@ //// [duplicateLabel1.ts] + target: target: while (true) { diff --git a/tests/baselines/reference/duplicateLabel2.errors.txt b/tests/baselines/reference/duplicateLabel2.errors.txt index f150879c010..2a87ed96648 100644 --- a/tests/baselines/reference/duplicateLabel2.errors.txt +++ b/tests/baselines/reference/duplicateLabel2.errors.txt @@ -1,11 +1,9 @@ -tests/cases/compiler/duplicateLabel2.ts(1,1): error TS7028: Unused label. -tests/cases/compiler/duplicateLabel2.ts(3,3): error TS1114: Duplicate label 'target' +tests/cases/compiler/duplicateLabel2.ts(4,3): error TS1114: Duplicate label 'target' -==== tests/cases/compiler/duplicateLabel2.ts (2 errors) ==== +==== tests/cases/compiler/duplicateLabel2.ts (1 errors) ==== + target: - ~~~~~~ -!!! error TS7028: Unused label. while (true) { target: ~~~~~~ diff --git a/tests/baselines/reference/duplicateLabel2.js b/tests/baselines/reference/duplicateLabel2.js index 9ee9671d59d..40a5ee4595e 100644 --- a/tests/baselines/reference/duplicateLabel2.js +++ b/tests/baselines/reference/duplicateLabel2.js @@ -1,4 +1,5 @@ //// [duplicateLabel2.ts] + target: while (true) { target: diff --git a/tests/baselines/reference/duplicateLabel3.errors.txt b/tests/baselines/reference/duplicateLabel3.errors.txt deleted file mode 100644 index f256176f1e0..00000000000 --- a/tests/baselines/reference/duplicateLabel3.errors.txt +++ /dev/null @@ -1,17 +0,0 @@ -tests/cases/compiler/duplicateLabel3.ts(1,1): error TS7028: Unused label. -tests/cases/compiler/duplicateLabel3.ts(4,5): error TS7028: Unused label. - - -==== tests/cases/compiler/duplicateLabel3.ts (2 errors) ==== - target: - ~~~~~~ -!!! error TS7028: Unused label. - while (true) { - function f() { - target: - ~~~~~~ -!!! error TS7028: Unused label. - while (true) { - } - } - } \ No newline at end of file diff --git a/tests/baselines/reference/duplicateLabel3.js b/tests/baselines/reference/duplicateLabel3.js index 37e9619e8f6..a1d33e46fc1 100644 --- a/tests/baselines/reference/duplicateLabel3.js +++ b/tests/baselines/reference/duplicateLabel3.js @@ -1,4 +1,5 @@ //// [duplicateLabel3.ts] + target: while (true) { function f() { diff --git a/tests/baselines/reference/duplicateLabel3.symbols b/tests/baselines/reference/duplicateLabel3.symbols new file mode 100644 index 00000000000..89f2d5ee48a --- /dev/null +++ b/tests/baselines/reference/duplicateLabel3.symbols @@ -0,0 +1,12 @@ +=== tests/cases/compiler/duplicateLabel3.ts === + +target: +while (true) { + function f() { +>f : Symbol(f, Decl(duplicateLabel3.ts, 2, 14)) + + target: + while (true) { + } + } +} diff --git a/tests/baselines/reference/duplicateLabel3.types b/tests/baselines/reference/duplicateLabel3.types new file mode 100644 index 00000000000..920a077aa9e --- /dev/null +++ b/tests/baselines/reference/duplicateLabel3.types @@ -0,0 +1,19 @@ +=== tests/cases/compiler/duplicateLabel3.ts === + +target: +>target : any + +while (true) { +>true : boolean + + function f() { +>f : () => void + + target: +>target : any + + while (true) { +>true : boolean + } + } +} diff --git a/tests/baselines/reference/duplicateLabel4.errors.txt b/tests/baselines/reference/duplicateLabel4.errors.txt deleted file mode 100644 index 516a4b2324b..00000000000 --- a/tests/baselines/reference/duplicateLabel4.errors.txt +++ /dev/null @@ -1,16 +0,0 @@ -tests/cases/compiler/duplicateLabel4.ts(1,1): error TS7028: Unused label. -tests/cases/compiler/duplicateLabel4.ts(5,1): error TS7027: Unreachable code detected. - - -==== tests/cases/compiler/duplicateLabel4.ts (2 errors) ==== - target: - ~~~~~~ -!!! error TS7028: Unused label. - while (true) { - } - - target: - ~~~~~~ -!!! error TS7027: Unreachable code detected. - while (true) { - } \ No newline at end of file diff --git a/tests/baselines/reference/duplicateLabel4.js b/tests/baselines/reference/duplicateLabel4.js index 22d072d38d7..d5b81b1e5bb 100644 --- a/tests/baselines/reference/duplicateLabel4.js +++ b/tests/baselines/reference/duplicateLabel4.js @@ -1,4 +1,5 @@ //// [duplicateLabel4.ts] + target: while (true) { } diff --git a/tests/baselines/reference/duplicateLabel4.symbols b/tests/baselines/reference/duplicateLabel4.symbols new file mode 100644 index 00000000000..5660782e2ec --- /dev/null +++ b/tests/baselines/reference/duplicateLabel4.symbols @@ -0,0 +1,10 @@ +=== tests/cases/compiler/duplicateLabel4.ts === + +No type information for this code.target: +No type information for this code.while (true) { +No type information for this code.} +No type information for this code. +No type information for this code.target: +No type information for this code.while (true) { +No type information for this code.} +No type information for this code. \ No newline at end of file diff --git a/tests/baselines/reference/duplicateLabel4.types b/tests/baselines/reference/duplicateLabel4.types new file mode 100644 index 00000000000..a10a06fe7a2 --- /dev/null +++ b/tests/baselines/reference/duplicateLabel4.types @@ -0,0 +1,15 @@ +=== tests/cases/compiler/duplicateLabel4.ts === + +target: +>target : any + +while (true) { +>true : boolean +} + +target: +>target : any + +while (true) { +>true : boolean +} diff --git a/tests/baselines/reference/duplicateLocalVariable1.errors.txt b/tests/baselines/reference/duplicateLocalVariable1.errors.txt index 890470f6c11..bd6d535d88e 100644 --- a/tests/baselines/reference/duplicateLocalVariable1.errors.txt +++ b/tests/baselines/reference/duplicateLocalVariable1.errors.txt @@ -1,9 +1,19 @@ -tests/cases/compiler/duplicateLocalVariable1.ts(64,92): error TS7027: Unreachable code detected. -tests/cases/compiler/duplicateLocalVariable1.ts(65,122): error TS7027: Unreachable code detected. -tests/cases/compiler/duplicateLocalVariable1.ts(185,22): error TS2403: Subsequent variable declarations must have the same type. Variable 'i' must be of type 'any', but here has type 'number'. +tests/cases/compiler/duplicateLocalVariable1.ts(2,4): error TS1005: ';' expected. +tests/cases/compiler/duplicateLocalVariable1.ts(2,11): error TS1146: Declaration expected. +tests/cases/compiler/duplicateLocalVariable1.ts(2,13): error TS2304: Cannot find name 'commonjs'. +tests/cases/compiler/duplicateLocalVariable1.ts(12,14): error TS1148: Cannot compile modules unless the '--module' flag is provided. +tests/cases/compiler/duplicateLocalVariable1.ts(187,22): error TS2403: Subsequent variable declarations must have the same type. Variable 'i' must be of type 'any', but here has type 'number'. -==== tests/cases/compiler/duplicateLocalVariable1.ts (3 errors) ==== +==== tests/cases/compiler/duplicateLocalVariable1.ts (5 errors) ==== + + / /@module: commonjs + ~ +!!! error TS1005: ';' expected. + +!!! error TS1146: Declaration expected. + ~~~~~~~~ +!!! error TS2304: Cannot find name 'commonjs'. //import FileManager = require('filemanager'); //import App = require('app'); @@ -14,6 +24,8 @@ tests/cases/compiler/duplicateLocalVariable1.ts(185,22): error TS2403: Subsequen var TestFileDir = ".\\TempTestFiles"; export class TestCase { + ~~~~~~~~ +!!! error TS1148: Cannot compile modules unless the '--module' flag is provided. constructor (public name: string, public test: ()=>boolean, public errorMessageRegEx?: string) { } } @@ -68,11 +80,7 @@ tests/cases/compiler/duplicateLocalVariable1.ts(185,22): error TS2403: Subsequen // First 3 are for simple harness validation testRunner.addTest(new TestCase("Basic test", function () { return true; })); testRunner.addTest(new TestCase("Test for any error", function () { throw new Error(); return false; }, "")); - ~~~~~~ -!!! error TS7027: Unreachable code detected. testRunner.addTest(new TestCase("Test RegEx error message match", function () { throw new Error("Should also pass"); return false; }, "Should [also]+ pass")); - ~~~~~~ -!!! error TS7027: Unreachable code detected. testRunner.addTest(new TestCase("Test array compare true", function () { return TestRunner.arrayCompare([1, 2, 3], [1, 2, 3]); })); testRunner.addTest(new TestCase("Test array compare false", function () { return !TestRunner.arrayCompare([3, 2, 3], [1, 2, 3]); })); diff --git a/tests/baselines/reference/duplicateLocalVariable1.js b/tests/baselines/reference/duplicateLocalVariable1.js index 62e291f28c0..ecde1ff2407 100644 --- a/tests/baselines/reference/duplicateLocalVariable1.js +++ b/tests/baselines/reference/duplicateLocalVariable1.js @@ -1,5 +1,7 @@ //// [duplicateLocalVariable1.ts] +/ /@module: commonjs + //import FileManager = require('filemanager'); //import App = require('app'); @@ -344,8 +346,8 @@ export var tests: TestRunner = (function () { })(); //// [duplicateLocalVariable1.js] -//import FileManager = require('filemanager'); -//import App = require('app'); +/ /; +commonjs; var TestFileDir = ".\\TempTestFiles"; var TestCase = (function () { function TestCase(name, test, errorMessageRegEx) { diff --git a/tests/baselines/reference/duplicateVariablesByScope.errors.txt b/tests/baselines/reference/duplicateVariablesByScope.errors.txt deleted file mode 100644 index e101b2b0e0d..00000000000 --- a/tests/baselines/reference/duplicateVariablesByScope.errors.txt +++ /dev/null @@ -1,37 +0,0 @@ -tests/cases/compiler/duplicateVariablesByScope.ts(18,9): error TS7027: Unreachable code detected. - - -==== tests/cases/compiler/duplicateVariablesByScope.ts (1 errors) ==== - // duplicate local variables are only reported at global scope - - module M { - for (var j = 0; j < 10; j++) { - } - - for (var j = 0; j < 10; j++) { - } - } - - function foo() { - var x = 2; - var x = 1; - if (true) { - var result = 1; - } - else { - var result = 2; - ~~~ -!!! error TS7027: Unreachable code detected. - } - } - - class C { - foo() { - try { - var x = 1; - } - catch (e) { - var x = 2; - } - } - } \ No newline at end of file diff --git a/tests/baselines/reference/duplicateVariablesByScope.js b/tests/baselines/reference/duplicateVariablesByScope.js index d87fd966f32..43b6e89d412 100644 --- a/tests/baselines/reference/duplicateVariablesByScope.js +++ b/tests/baselines/reference/duplicateVariablesByScope.js @@ -1,4 +1,5 @@ //// [duplicateVariablesByScope.ts] + // duplicate local variables are only reported at global scope module M { diff --git a/tests/baselines/reference/duplicateVariablesByScope.symbols b/tests/baselines/reference/duplicateVariablesByScope.symbols new file mode 100644 index 00000000000..9dd280d2756 --- /dev/null +++ b/tests/baselines/reference/duplicateVariablesByScope.symbols @@ -0,0 +1,57 @@ +=== tests/cases/compiler/duplicateVariablesByScope.ts === + +// duplicate local variables are only reported at global scope + +module M { +>M : Symbol(M, Decl(duplicateVariablesByScope.ts, 0, 0)) + + for (var j = 0; j < 10; j++) { +>j : Symbol(j, Decl(duplicateVariablesByScope.ts, 4, 12), Decl(duplicateVariablesByScope.ts, 7, 12)) +>j : Symbol(j, Decl(duplicateVariablesByScope.ts, 4, 12), Decl(duplicateVariablesByScope.ts, 7, 12)) +>j : Symbol(j, Decl(duplicateVariablesByScope.ts, 4, 12), Decl(duplicateVariablesByScope.ts, 7, 12)) + } + + for (var j = 0; j < 10; j++) { +>j : Symbol(j, Decl(duplicateVariablesByScope.ts, 4, 12), Decl(duplicateVariablesByScope.ts, 7, 12)) +>j : Symbol(j, Decl(duplicateVariablesByScope.ts, 4, 12), Decl(duplicateVariablesByScope.ts, 7, 12)) +>j : Symbol(j, Decl(duplicateVariablesByScope.ts, 4, 12), Decl(duplicateVariablesByScope.ts, 7, 12)) + } +} + +function foo() { +>foo : Symbol(foo, Decl(duplicateVariablesByScope.ts, 9, 1)) + + var x = 2; +>x : Symbol(x, Decl(duplicateVariablesByScope.ts, 12, 7), Decl(duplicateVariablesByScope.ts, 13, 7)) + + var x = 1; +>x : Symbol(x, Decl(duplicateVariablesByScope.ts, 12, 7), Decl(duplicateVariablesByScope.ts, 13, 7)) + + if (true) { + var result = 1; +>result : Symbol(result, Decl(duplicateVariablesByScope.ts, 15, 11), Decl(duplicateVariablesByScope.ts, 18, 11)) + } + else { + var result = 2; +>result : Symbol(result, Decl(duplicateVariablesByScope.ts, 15, 11), Decl(duplicateVariablesByScope.ts, 18, 11)) + } +} + +class C { +>C : Symbol(C, Decl(duplicateVariablesByScope.ts, 20, 1)) + + foo() { +>foo : Symbol(foo, Decl(duplicateVariablesByScope.ts, 22, 9)) + + try { + var x = 1; +>x : Symbol(x, Decl(duplicateVariablesByScope.ts, 25, 15), Decl(duplicateVariablesByScope.ts, 28, 15)) + } + catch (e) { +>e : Symbol(e, Decl(duplicateVariablesByScope.ts, 27, 15)) + + var x = 2; +>x : Symbol(x, Decl(duplicateVariablesByScope.ts, 25, 15), Decl(duplicateVariablesByScope.ts, 28, 15)) + } + } +} diff --git a/tests/baselines/reference/duplicateVariablesByScope.types b/tests/baselines/reference/duplicateVariablesByScope.types new file mode 100644 index 00000000000..30e68d921ca --- /dev/null +++ b/tests/baselines/reference/duplicateVariablesByScope.types @@ -0,0 +1,73 @@ +=== tests/cases/compiler/duplicateVariablesByScope.ts === + +// duplicate local variables are only reported at global scope + +module M { +>M : typeof M + + for (var j = 0; j < 10; j++) { +>j : number +>0 : number +>j < 10 : boolean +>j : number +>10 : number +>j++ : number +>j : number + } + + for (var j = 0; j < 10; j++) { +>j : number +>0 : number +>j < 10 : boolean +>j : number +>10 : number +>j++ : number +>j : number + } +} + +function foo() { +>foo : () => void + + var x = 2; +>x : number +>2 : number + + var x = 1; +>x : number +>1 : number + + if (true) { +>true : boolean + + var result = 1; +>result : number +>1 : number + } + else { + var result = 2; +>result : number +>2 : number + } +} + +class C { +>C : C + + foo() { +>foo : () => void + + try { + var x = 1; +>x : number +>1 : number + } + catch (e) { +>e : any + + var x = 2; +>x : number +>2 : number + } + } +} diff --git a/tests/baselines/reference/es6ClassSuperCodegenBug.errors.txt b/tests/baselines/reference/es6ClassSuperCodegenBug.errors.txt deleted file mode 100644 index f30719a2792..00000000000 --- a/tests/baselines/reference/es6ClassSuperCodegenBug.errors.txt +++ /dev/null @@ -1,19 +0,0 @@ -tests/cases/compiler/es6ClassSuperCodegenBug.ts(9,10): error TS7027: Unreachable code detected. - - -==== tests/cases/compiler/es6ClassSuperCodegenBug.ts (1 errors) ==== - class A { - constructor(str1:string, str2:string) {} - } - class B extends A { - constructor() { - if (true) { - super('a1', 'b1'); - } else { - super('a2', 'b2'); - ~~~~~ -!!! error TS7027: Unreachable code detected. - } - } - } - \ No newline at end of file diff --git a/tests/baselines/reference/es6ClassSuperCodegenBug.js b/tests/baselines/reference/es6ClassSuperCodegenBug.js index 62c96f6260d..9f15af96be8 100644 --- a/tests/baselines/reference/es6ClassSuperCodegenBug.js +++ b/tests/baselines/reference/es6ClassSuperCodegenBug.js @@ -1,4 +1,5 @@ //// [es6ClassSuperCodegenBug.ts] + class A { constructor(str1:string, str2:string) {} } diff --git a/tests/baselines/reference/es6ClassSuperCodegenBug.symbols b/tests/baselines/reference/es6ClassSuperCodegenBug.symbols new file mode 100644 index 00000000000..bb500a1d2c2 --- /dev/null +++ b/tests/baselines/reference/es6ClassSuperCodegenBug.symbols @@ -0,0 +1,25 @@ +=== tests/cases/compiler/es6ClassSuperCodegenBug.ts === + +class A { +>A : Symbol(A, Decl(es6ClassSuperCodegenBug.ts, 0, 0)) + + constructor(str1:string, str2:string) {} +>str1 : Symbol(str1, Decl(es6ClassSuperCodegenBug.ts, 2, 13)) +>str2 : Symbol(str2, Decl(es6ClassSuperCodegenBug.ts, 2, 25)) +} +class B extends A { +>B : Symbol(B, Decl(es6ClassSuperCodegenBug.ts, 3, 1)) +>A : Symbol(A, Decl(es6ClassSuperCodegenBug.ts, 0, 0)) + + constructor() { + if (true) { + super('a1', 'b1'); +>super : Symbol(A, Decl(es6ClassSuperCodegenBug.ts, 0, 0)) + + } else { + super('a2', 'b2'); +>super : Symbol(A, Decl(es6ClassSuperCodegenBug.ts, 0, 0)) + } + } +} + diff --git a/tests/baselines/reference/es6ClassSuperCodegenBug.types b/tests/baselines/reference/es6ClassSuperCodegenBug.types new file mode 100644 index 00000000000..65269c99997 --- /dev/null +++ b/tests/baselines/reference/es6ClassSuperCodegenBug.types @@ -0,0 +1,33 @@ +=== tests/cases/compiler/es6ClassSuperCodegenBug.ts === + +class A { +>A : A + + constructor(str1:string, str2:string) {} +>str1 : string +>str2 : string +} +class B extends A { +>B : B +>A : A + + constructor() { + if (true) { +>true : boolean + + super('a1', 'b1'); +>super('a1', 'b1') : void +>super : typeof A +>'a1' : string +>'b1' : string + + } else { + super('a2', 'b2'); +>super('a2', 'b2') : void +>super : typeof A +>'a2' : string +>'b2' : string + } + } +} + diff --git a/tests/baselines/reference/escapedIdentifiers.errors.txt b/tests/baselines/reference/escapedIdentifiers.errors.txt deleted file mode 100644 index 8f7d735ceed..00000000000 --- a/tests/baselines/reference/escapedIdentifiers.errors.txt +++ /dev/null @@ -1,146 +0,0 @@ -tests/cases/compiler/escapedIdentifiers.ts(93,1): error TS7028: Unused label. -tests/cases/compiler/escapedIdentifiers.ts(96,8): error TS7027: Unreachable code detected. -tests/cases/compiler/escapedIdentifiers.ts(100,1): error TS7028: Unused label. -tests/cases/compiler/escapedIdentifiers.ts(103,8): error TS7027: Unreachable code detected. -tests/cases/compiler/escapedIdentifiers.ts(107,1): error TS7028: Unused label. -tests/cases/compiler/escapedIdentifiers.ts(110,8): error TS7027: Unreachable code detected. -tests/cases/compiler/escapedIdentifiers.ts(114,1): error TS7028: Unused label. -tests/cases/compiler/escapedIdentifiers.ts(117,8): error TS7027: Unreachable code detected. - - -==== tests/cases/compiler/escapedIdentifiers.ts (8 errors) ==== - /* - 0 .. \u0030 - 9 .. \u0039 - - A .. \u0041 - Z .. \u005a - - a .. \u0061 - z .. \u00za - */ - - // var decl - var \u0061 = 1; - a ++; - \u0061 ++; - - var b = 1; - b ++; - \u0062 ++; - - // modules - module moduleType1 { - export var baz1: number; - } - module moduleType\u0032 { - export var baz2: number; - } - - moduleType1.baz1 = 3; - moduleType\u0031.baz1 = 3; - moduleType2.baz2 = 3; - moduleType\u0032.baz2 = 3; - - // classes - - class classType1 { - public foo1: number; - } - class classType\u0032 { - public foo2: number; - } - - var classType1Object1 = new classType1(); - classType1Object1.foo1 = 2; - var classType1Object2 = new classType\u0031(); - classType1Object2.foo1 = 2; - var classType2Object1 = new classType2(); - classType2Object1.foo2 = 2; - var classType2Object2 = new classType\u0032(); - classType2Object2.foo2 = 2; - - // interfaces - interface interfaceType1 { - bar1: number; - } - interface interfaceType\u0032 { - bar2: number; - } - - var interfaceType1Object1 = { bar1: 0 }; - interfaceType1Object1.bar1 = 2; - var interfaceType1Object2 = { bar1: 0 }; - interfaceType1Object2.bar1 = 2; - var interfaceType2Object1 = { bar2: 0 }; - interfaceType2Object1.bar2 = 2; - var interfaceType2Object2 = { bar2: 0 }; - interfaceType2Object2.bar2 = 2; - - - // arguments - class testClass { - public func(arg1: number, arg\u0032: string, arg\u0033: boolean, arg4: number) { - arg\u0031 = 1; - arg2 = 'string'; - arg\u0033 = true; - arg4 = 2; - } - } - - // constructors - class constructorTestClass { - constructor (public arg1: number,public arg\u0032: string,public arg\u0033: boolean,public arg4: number) { - } - } - var constructorTestObject = new constructorTestClass(1, 'string', true, 2); - constructorTestObject.arg\u0031 = 1; - constructorTestObject.arg2 = 'string'; - constructorTestObject.arg\u0033 = true; - constructorTestObject.arg4 = 2; - - // Lables - - l\u0061bel1: - ~~~~~~~~~~~ -!!! error TS7028: Unused label. - while (false) - { - while(false) - ~~~~~ -!!! error TS7027: Unreachable code detected. - continue label1; // it will go to next iteration of outer loop - } - - label2: - ~~~~~~ -!!! error TS7028: Unused label. - while (false) - { - while(false) - ~~~~~ -!!! error TS7027: Unreachable code detected. - continue l\u0061bel2; // it will go to next iteration of outer loop - } - - label3: - ~~~~~~ -!!! error TS7028: Unused label. - while (false) - { - while(false) - ~~~~~ -!!! error TS7027: Unreachable code detected. - continue label3; // it will go to next iteration of outer loop - } - - l\u0061bel4: - ~~~~~~~~~~~ -!!! error TS7028: Unused label. - while (false) - { - while(false) - ~~~~~ -!!! error TS7027: Unreachable code detected. - continue l\u0061bel4; // it will go to next iteration of outer loop - } \ No newline at end of file diff --git a/tests/baselines/reference/escapedIdentifiers.js b/tests/baselines/reference/escapedIdentifiers.js index 5ab7dcc5a5a..64eaaa5784f 100644 --- a/tests/baselines/reference/escapedIdentifiers.js +++ b/tests/baselines/reference/escapedIdentifiers.js @@ -1,4 +1,5 @@ //// [escapedIdentifiers.ts] + /* 0 .. \u0030 9 .. \u0039 diff --git a/tests/baselines/reference/escapedIdentifiers.symbols b/tests/baselines/reference/escapedIdentifiers.symbols new file mode 100644 index 00000000000..a99e067b898 --- /dev/null +++ b/tests/baselines/reference/escapedIdentifiers.symbols @@ -0,0 +1,261 @@ +=== tests/cases/compiler/escapedIdentifiers.ts === + +/* + 0 .. \u0030 + 9 .. \u0039 + + A .. \u0041 + Z .. \u005a + + a .. \u0061 + z .. \u00za +*/ + +// var decl +var \u0061 = 1; +>\u0061 : Symbol(\u0061, Decl(escapedIdentifiers.ts, 13, 3)) + +a ++; +>a : Symbol(\u0061, Decl(escapedIdentifiers.ts, 13, 3)) + +\u0061 ++; +>\u0061 : Symbol(\u0061, Decl(escapedIdentifiers.ts, 13, 3)) + +var b = 1; +>b : Symbol(b, Decl(escapedIdentifiers.ts, 17, 3)) + +b ++; +>b : Symbol(b, Decl(escapedIdentifiers.ts, 17, 3)) + +\u0062 ++; +>\u0062 : Symbol(b, Decl(escapedIdentifiers.ts, 17, 3)) + +// modules +module moduleType1 { +>moduleType1 : Symbol(moduleType1, Decl(escapedIdentifiers.ts, 19, 10)) + + export var baz1: number; +>baz1 : Symbol(baz1, Decl(escapedIdentifiers.ts, 23, 14)) +} +module moduleType\u0032 { +>moduleType\u0032 : Symbol(moduleType\u0032, Decl(escapedIdentifiers.ts, 24, 1)) + + export var baz2: number; +>baz2 : Symbol(baz2, Decl(escapedIdentifiers.ts, 26, 14)) +} + +moduleType1.baz1 = 3; +>moduleType1.baz1 : Symbol(moduleType1.baz1, Decl(escapedIdentifiers.ts, 23, 14)) +>moduleType1 : Symbol(moduleType1, Decl(escapedIdentifiers.ts, 19, 10)) +>baz1 : Symbol(moduleType1.baz1, Decl(escapedIdentifiers.ts, 23, 14)) + +moduleType\u0031.baz1 = 3; +>moduleType\u0031.baz1 : Symbol(moduleType1.baz1, Decl(escapedIdentifiers.ts, 23, 14)) +>moduleType\u0031 : Symbol(moduleType1, Decl(escapedIdentifiers.ts, 19, 10)) +>baz1 : Symbol(moduleType1.baz1, Decl(escapedIdentifiers.ts, 23, 14)) + +moduleType2.baz2 = 3; +>moduleType2.baz2 : Symbol(moduleType\u0032.baz2, Decl(escapedIdentifiers.ts, 26, 14)) +>moduleType2 : Symbol(moduleType\u0032, Decl(escapedIdentifiers.ts, 24, 1)) +>baz2 : Symbol(moduleType\u0032.baz2, Decl(escapedIdentifiers.ts, 26, 14)) + +moduleType\u0032.baz2 = 3; +>moduleType\u0032.baz2 : Symbol(moduleType\u0032.baz2, Decl(escapedIdentifiers.ts, 26, 14)) +>moduleType\u0032 : Symbol(moduleType\u0032, Decl(escapedIdentifiers.ts, 24, 1)) +>baz2 : Symbol(moduleType\u0032.baz2, Decl(escapedIdentifiers.ts, 26, 14)) + +// classes + +class classType1 { +>classType1 : Symbol(classType1, Decl(escapedIdentifiers.ts, 32, 26)) + + public foo1: number; +>foo1 : Symbol(foo1, Decl(escapedIdentifiers.ts, 36, 18)) +} +class classType\u0032 { +>classType\u0032 : Symbol(classType\u0032, Decl(escapedIdentifiers.ts, 38, 1)) + + public foo2: number; +>foo2 : Symbol(foo2, Decl(escapedIdentifiers.ts, 39, 23)) +} + +var classType1Object1 = new classType1(); +>classType1Object1 : Symbol(classType1Object1, Decl(escapedIdentifiers.ts, 43, 3)) +>classType1 : Symbol(classType1, Decl(escapedIdentifiers.ts, 32, 26)) + +classType1Object1.foo1 = 2; +>classType1Object1.foo1 : Symbol(classType1.foo1, Decl(escapedIdentifiers.ts, 36, 18)) +>classType1Object1 : Symbol(classType1Object1, Decl(escapedIdentifiers.ts, 43, 3)) +>foo1 : Symbol(classType1.foo1, Decl(escapedIdentifiers.ts, 36, 18)) + +var classType1Object2 = new classType\u0031(); +>classType1Object2 : Symbol(classType1Object2, Decl(escapedIdentifiers.ts, 45, 3)) +>classType\u0031 : Symbol(classType1, Decl(escapedIdentifiers.ts, 32, 26)) + +classType1Object2.foo1 = 2; +>classType1Object2.foo1 : Symbol(classType1.foo1, Decl(escapedIdentifiers.ts, 36, 18)) +>classType1Object2 : Symbol(classType1Object2, Decl(escapedIdentifiers.ts, 45, 3)) +>foo1 : Symbol(classType1.foo1, Decl(escapedIdentifiers.ts, 36, 18)) + +var classType2Object1 = new classType2(); +>classType2Object1 : Symbol(classType2Object1, Decl(escapedIdentifiers.ts, 47, 3)) +>classType2 : Symbol(classType\u0032, Decl(escapedIdentifiers.ts, 38, 1)) + +classType2Object1.foo2 = 2; +>classType2Object1.foo2 : Symbol(classType\u0032.foo2, Decl(escapedIdentifiers.ts, 39, 23)) +>classType2Object1 : Symbol(classType2Object1, Decl(escapedIdentifiers.ts, 47, 3)) +>foo2 : Symbol(classType\u0032.foo2, Decl(escapedIdentifiers.ts, 39, 23)) + +var classType2Object2 = new classType\u0032(); +>classType2Object2 : Symbol(classType2Object2, Decl(escapedIdentifiers.ts, 49, 3)) +>classType\u0032 : Symbol(classType\u0032, Decl(escapedIdentifiers.ts, 38, 1)) + +classType2Object2.foo2 = 2; +>classType2Object2.foo2 : Symbol(classType\u0032.foo2, Decl(escapedIdentifiers.ts, 39, 23)) +>classType2Object2 : Symbol(classType2Object2, Decl(escapedIdentifiers.ts, 49, 3)) +>foo2 : Symbol(classType\u0032.foo2, Decl(escapedIdentifiers.ts, 39, 23)) + +// interfaces +interface interfaceType1 { +>interfaceType1 : Symbol(interfaceType1, Decl(escapedIdentifiers.ts, 50, 27)) + + bar1: number; +>bar1 : Symbol(bar1, Decl(escapedIdentifiers.ts, 53, 26)) +} +interface interfaceType\u0032 { +>interfaceType\u0032 : Symbol(interfaceType\u0032, Decl(escapedIdentifiers.ts, 55, 1)) + + bar2: number; +>bar2 : Symbol(bar2, Decl(escapedIdentifiers.ts, 56, 31)) +} + +var interfaceType1Object1 = { bar1: 0 }; +>interfaceType1Object1 : Symbol(interfaceType1Object1, Decl(escapedIdentifiers.ts, 60, 3)) +>interfaceType1 : Symbol(interfaceType1, Decl(escapedIdentifiers.ts, 50, 27)) +>bar1 : Symbol(bar1, Decl(escapedIdentifiers.ts, 60, 45)) + +interfaceType1Object1.bar1 = 2; +>interfaceType1Object1.bar1 : Symbol(interfaceType1.bar1, Decl(escapedIdentifiers.ts, 53, 26)) +>interfaceType1Object1 : Symbol(interfaceType1Object1, Decl(escapedIdentifiers.ts, 60, 3)) +>bar1 : Symbol(interfaceType1.bar1, Decl(escapedIdentifiers.ts, 53, 26)) + +var interfaceType1Object2 = { bar1: 0 }; +>interfaceType1Object2 : Symbol(interfaceType1Object2, Decl(escapedIdentifiers.ts, 62, 3)) +>interfaceType\u0031 : Symbol(interfaceType1, Decl(escapedIdentifiers.ts, 50, 27)) +>bar1 : Symbol(bar1, Decl(escapedIdentifiers.ts, 62, 50)) + +interfaceType1Object2.bar1 = 2; +>interfaceType1Object2.bar1 : Symbol(interfaceType1.bar1, Decl(escapedIdentifiers.ts, 53, 26)) +>interfaceType1Object2 : Symbol(interfaceType1Object2, Decl(escapedIdentifiers.ts, 62, 3)) +>bar1 : Symbol(interfaceType1.bar1, Decl(escapedIdentifiers.ts, 53, 26)) + +var interfaceType2Object1 = { bar2: 0 }; +>interfaceType2Object1 : Symbol(interfaceType2Object1, Decl(escapedIdentifiers.ts, 64, 3)) +>interfaceType2 : Symbol(interfaceType\u0032, Decl(escapedIdentifiers.ts, 55, 1)) +>bar2 : Symbol(bar2, Decl(escapedIdentifiers.ts, 64, 45)) + +interfaceType2Object1.bar2 = 2; +>interfaceType2Object1.bar2 : Symbol(interfaceType\u0032.bar2, Decl(escapedIdentifiers.ts, 56, 31)) +>interfaceType2Object1 : Symbol(interfaceType2Object1, Decl(escapedIdentifiers.ts, 64, 3)) +>bar2 : Symbol(interfaceType\u0032.bar2, Decl(escapedIdentifiers.ts, 56, 31)) + +var interfaceType2Object2 = { bar2: 0 }; +>interfaceType2Object2 : Symbol(interfaceType2Object2, Decl(escapedIdentifiers.ts, 66, 3)) +>interfaceType\u0032 : Symbol(interfaceType\u0032, Decl(escapedIdentifiers.ts, 55, 1)) +>bar2 : Symbol(bar2, Decl(escapedIdentifiers.ts, 66, 50)) + +interfaceType2Object2.bar2 = 2; +>interfaceType2Object2.bar2 : Symbol(interfaceType\u0032.bar2, Decl(escapedIdentifiers.ts, 56, 31)) +>interfaceType2Object2 : Symbol(interfaceType2Object2, Decl(escapedIdentifiers.ts, 66, 3)) +>bar2 : Symbol(interfaceType\u0032.bar2, Decl(escapedIdentifiers.ts, 56, 31)) + + +// arguments +class testClass { +>testClass : Symbol(testClass, Decl(escapedIdentifiers.ts, 67, 31)) + + public func(arg1: number, arg\u0032: string, arg\u0033: boolean, arg4: number) { +>func : Symbol(func, Decl(escapedIdentifiers.ts, 71, 17)) +>arg1 : Symbol(arg1, Decl(escapedIdentifiers.ts, 72, 16)) +>arg\u0032 : Symbol(arg\u0032, Decl(escapedIdentifiers.ts, 72, 29)) +>arg\u0033 : Symbol(arg\u0033, Decl(escapedIdentifiers.ts, 72, 48)) +>arg4 : Symbol(arg4, Decl(escapedIdentifiers.ts, 72, 68)) + + arg\u0031 = 1; +>arg\u0031 : Symbol(arg1, Decl(escapedIdentifiers.ts, 72, 16)) + + arg2 = 'string'; +>arg2 : Symbol(arg\u0032, Decl(escapedIdentifiers.ts, 72, 29)) + + arg\u0033 = true; +>arg\u0033 : Symbol(arg\u0033, Decl(escapedIdentifiers.ts, 72, 48)) + + arg4 = 2; +>arg4 : Symbol(arg4, Decl(escapedIdentifiers.ts, 72, 68)) + } +} + +// constructors +class constructorTestClass { +>constructorTestClass : Symbol(constructorTestClass, Decl(escapedIdentifiers.ts, 78, 1)) + + constructor (public arg1: number,public arg\u0032: string,public arg\u0033: boolean,public arg4: number) { +>arg1 : Symbol(arg1, Decl(escapedIdentifiers.ts, 82, 17)) +>arg\u0032 : Symbol(arg\u0032, Decl(escapedIdentifiers.ts, 82, 37)) +>arg\u0033 : Symbol(arg\u0033, Decl(escapedIdentifiers.ts, 82, 62)) +>arg4 : Symbol(arg4, Decl(escapedIdentifiers.ts, 82, 88)) + } +} +var constructorTestObject = new constructorTestClass(1, 'string', true, 2); +>constructorTestObject : Symbol(constructorTestObject, Decl(escapedIdentifiers.ts, 85, 3)) +>constructorTestClass : Symbol(constructorTestClass, Decl(escapedIdentifiers.ts, 78, 1)) + +constructorTestObject.arg\u0031 = 1; +>constructorTestObject.arg\u0031 : Symbol(constructorTestClass.arg1, Decl(escapedIdentifiers.ts, 82, 17)) +>constructorTestObject : Symbol(constructorTestObject, Decl(escapedIdentifiers.ts, 85, 3)) +>arg\u0031 : Symbol(constructorTestClass.arg1, Decl(escapedIdentifiers.ts, 82, 17)) + +constructorTestObject.arg2 = 'string'; +>constructorTestObject.arg2 : Symbol(constructorTestClass.arg\u0032, Decl(escapedIdentifiers.ts, 82, 37)) +>constructorTestObject : Symbol(constructorTestObject, Decl(escapedIdentifiers.ts, 85, 3)) +>arg2 : Symbol(constructorTestClass.arg\u0032, Decl(escapedIdentifiers.ts, 82, 37)) + +constructorTestObject.arg\u0033 = true; +>constructorTestObject.arg\u0033 : Symbol(constructorTestClass.arg\u0033, Decl(escapedIdentifiers.ts, 82, 62)) +>constructorTestObject : Symbol(constructorTestObject, Decl(escapedIdentifiers.ts, 85, 3)) +>arg\u0033 : Symbol(constructorTestClass.arg\u0033, Decl(escapedIdentifiers.ts, 82, 62)) + +constructorTestObject.arg4 = 2; +>constructorTestObject.arg4 : Symbol(constructorTestClass.arg4, Decl(escapedIdentifiers.ts, 82, 88)) +>constructorTestObject : Symbol(constructorTestObject, Decl(escapedIdentifiers.ts, 85, 3)) +>arg4 : Symbol(constructorTestClass.arg4, Decl(escapedIdentifiers.ts, 82, 88)) + +// Lables + +l\u0061bel1: + while (false) + { + while(false) + continue label1; // it will go to next iteration of outer loop + } + +label2: + while (false) + { + while(false) + continue l\u0061bel2; // it will go to next iteration of outer loop + } + +label3: + while (false) + { + while(false) + continue label3; // it will go to next iteration of outer loop + } + +l\u0061bel4: + while (false) + { + while(false) + continue l\u0061bel4; // it will go to next iteration of outer loop + } diff --git a/tests/baselines/reference/escapedIdentifiers.types b/tests/baselines/reference/escapedIdentifiers.types new file mode 100644 index 00000000000..67713976bd6 --- /dev/null +++ b/tests/baselines/reference/escapedIdentifiers.types @@ -0,0 +1,352 @@ +=== tests/cases/compiler/escapedIdentifiers.ts === + +/* + 0 .. \u0030 + 9 .. \u0039 + + A .. \u0041 + Z .. \u005a + + a .. \u0061 + z .. \u00za +*/ + +// var decl +var \u0061 = 1; +>\u0061 : number +>1 : number + +a ++; +>a ++ : number +>a : number + +\u0061 ++; +>\u0061 ++ : number +>\u0061 : number + +var b = 1; +>b : number +>1 : number + +b ++; +>b ++ : number +>b : number + +\u0062 ++; +>\u0062 ++ : number +>\u0062 : number + +// modules +module moduleType1 { +>moduleType1 : typeof moduleType1 + + export var baz1: number; +>baz1 : number +} +module moduleType\u0032 { +>moduleType\u0032 : typeof moduleType\u0032 + + export var baz2: number; +>baz2 : number +} + +moduleType1.baz1 = 3; +>moduleType1.baz1 = 3 : number +>moduleType1.baz1 : number +>moduleType1 : typeof moduleType1 +>baz1 : number +>3 : number + +moduleType\u0031.baz1 = 3; +>moduleType\u0031.baz1 = 3 : number +>moduleType\u0031.baz1 : number +>moduleType\u0031 : typeof moduleType1 +>baz1 : number +>3 : number + +moduleType2.baz2 = 3; +>moduleType2.baz2 = 3 : number +>moduleType2.baz2 : number +>moduleType2 : typeof moduleType\u0032 +>baz2 : number +>3 : number + +moduleType\u0032.baz2 = 3; +>moduleType\u0032.baz2 = 3 : number +>moduleType\u0032.baz2 : number +>moduleType\u0032 : typeof moduleType\u0032 +>baz2 : number +>3 : number + +// classes + +class classType1 { +>classType1 : classType1 + + public foo1: number; +>foo1 : number +} +class classType\u0032 { +>classType\u0032 : classType\u0032 + + public foo2: number; +>foo2 : number +} + +var classType1Object1 = new classType1(); +>classType1Object1 : classType1 +>new classType1() : classType1 +>classType1 : typeof classType1 + +classType1Object1.foo1 = 2; +>classType1Object1.foo1 = 2 : number +>classType1Object1.foo1 : number +>classType1Object1 : classType1 +>foo1 : number +>2 : number + +var classType1Object2 = new classType\u0031(); +>classType1Object2 : classType1 +>new classType\u0031() : classType1 +>classType\u0031 : typeof classType1 + +classType1Object2.foo1 = 2; +>classType1Object2.foo1 = 2 : number +>classType1Object2.foo1 : number +>classType1Object2 : classType1 +>foo1 : number +>2 : number + +var classType2Object1 = new classType2(); +>classType2Object1 : classType\u0032 +>new classType2() : classType\u0032 +>classType2 : typeof classType\u0032 + +classType2Object1.foo2 = 2; +>classType2Object1.foo2 = 2 : number +>classType2Object1.foo2 : number +>classType2Object1 : classType\u0032 +>foo2 : number +>2 : number + +var classType2Object2 = new classType\u0032(); +>classType2Object2 : classType\u0032 +>new classType\u0032() : classType\u0032 +>classType\u0032 : typeof classType\u0032 + +classType2Object2.foo2 = 2; +>classType2Object2.foo2 = 2 : number +>classType2Object2.foo2 : number +>classType2Object2 : classType\u0032 +>foo2 : number +>2 : number + +// interfaces +interface interfaceType1 { +>interfaceType1 : interfaceType1 + + bar1: number; +>bar1 : number +} +interface interfaceType\u0032 { +>interfaceType\u0032 : interfaceType\u0032 + + bar2: number; +>bar2 : number +} + +var interfaceType1Object1 = { bar1: 0 }; +>interfaceType1Object1 : interfaceType1 +>{ bar1: 0 } : interfaceType1 +>interfaceType1 : interfaceType1 +>{ bar1: 0 } : { bar1: number; } +>bar1 : number +>0 : number + +interfaceType1Object1.bar1 = 2; +>interfaceType1Object1.bar1 = 2 : number +>interfaceType1Object1.bar1 : number +>interfaceType1Object1 : interfaceType1 +>bar1 : number +>2 : number + +var interfaceType1Object2 = { bar1: 0 }; +>interfaceType1Object2 : interfaceType1 +>{ bar1: 0 } : interfaceType1 +>interfaceType\u0031 : interfaceType1 +>{ bar1: 0 } : { bar1: number; } +>bar1 : number +>0 : number + +interfaceType1Object2.bar1 = 2; +>interfaceType1Object2.bar1 = 2 : number +>interfaceType1Object2.bar1 : number +>interfaceType1Object2 : interfaceType1 +>bar1 : number +>2 : number + +var interfaceType2Object1 = { bar2: 0 }; +>interfaceType2Object1 : interfaceType\u0032 +>{ bar2: 0 } : interfaceType\u0032 +>interfaceType2 : interfaceType\u0032 +>{ bar2: 0 } : { bar2: number; } +>bar2 : number +>0 : number + +interfaceType2Object1.bar2 = 2; +>interfaceType2Object1.bar2 = 2 : number +>interfaceType2Object1.bar2 : number +>interfaceType2Object1 : interfaceType\u0032 +>bar2 : number +>2 : number + +var interfaceType2Object2 = { bar2: 0 }; +>interfaceType2Object2 : interfaceType\u0032 +>{ bar2: 0 } : interfaceType\u0032 +>interfaceType\u0032 : interfaceType\u0032 +>{ bar2: 0 } : { bar2: number; } +>bar2 : number +>0 : number + +interfaceType2Object2.bar2 = 2; +>interfaceType2Object2.bar2 = 2 : number +>interfaceType2Object2.bar2 : number +>interfaceType2Object2 : interfaceType\u0032 +>bar2 : number +>2 : number + + +// arguments +class testClass { +>testClass : testClass + + public func(arg1: number, arg\u0032: string, arg\u0033: boolean, arg4: number) { +>func : (arg1: number, arg\u0032: string, arg\u0033: boolean, arg4: number) => void +>arg1 : number +>arg\u0032 : string +>arg\u0033 : boolean +>arg4 : number + + arg\u0031 = 1; +>arg\u0031 = 1 : number +>arg\u0031 : number +>1 : number + + arg2 = 'string'; +>arg2 = 'string' : string +>arg2 : string +>'string' : string + + arg\u0033 = true; +>arg\u0033 = true : boolean +>arg\u0033 : boolean +>true : boolean + + arg4 = 2; +>arg4 = 2 : number +>arg4 : number +>2 : number + } +} + +// constructors +class constructorTestClass { +>constructorTestClass : constructorTestClass + + constructor (public arg1: number,public arg\u0032: string,public arg\u0033: boolean,public arg4: number) { +>arg1 : number +>arg\u0032 : string +>arg\u0033 : boolean +>arg4 : number + } +} +var constructorTestObject = new constructorTestClass(1, 'string', true, 2); +>constructorTestObject : constructorTestClass +>new constructorTestClass(1, 'string', true, 2) : constructorTestClass +>constructorTestClass : typeof constructorTestClass +>1 : number +>'string' : string +>true : boolean +>2 : number + +constructorTestObject.arg\u0031 = 1; +>constructorTestObject.arg\u0031 = 1 : number +>constructorTestObject.arg\u0031 : number +>constructorTestObject : constructorTestClass +>arg\u0031 : number +>1 : number + +constructorTestObject.arg2 = 'string'; +>constructorTestObject.arg2 = 'string' : string +>constructorTestObject.arg2 : string +>constructorTestObject : constructorTestClass +>arg2 : string +>'string' : string + +constructorTestObject.arg\u0033 = true; +>constructorTestObject.arg\u0033 = true : boolean +>constructorTestObject.arg\u0033 : boolean +>constructorTestObject : constructorTestClass +>arg\u0033 : boolean +>true : boolean + +constructorTestObject.arg4 = 2; +>constructorTestObject.arg4 = 2 : number +>constructorTestObject.arg4 : number +>constructorTestObject : constructorTestClass +>arg4 : number +>2 : number + +// Lables + +l\u0061bel1: +>l\u0061bel1 : any + + while (false) +>false : boolean + { + while(false) +>false : boolean + + continue label1; // it will go to next iteration of outer loop +>label1 : any + } + +label2: +>label2 : any + + while (false) +>false : boolean + { + while(false) +>false : boolean + + continue l\u0061bel2; // it will go to next iteration of outer loop +>l\u0061bel2 : any + } + +label3: +>label3 : any + + while (false) +>false : boolean + { + while(false) +>false : boolean + + continue label3; // it will go to next iteration of outer loop +>label3 : any + } + +l\u0061bel4: +>l\u0061bel4 : any + + while (false) +>false : boolean + { + while(false) +>false : boolean + + continue l\u0061bel4; // it will go to next iteration of outer loop +>l\u0061bel4 : any + } diff --git a/tests/baselines/reference/for.errors.txt b/tests/baselines/reference/for.errors.txt index 34de6a4b114..d2caefbcdae 100644 --- a/tests/baselines/reference/for.errors.txt +++ b/tests/baselines/reference/for.errors.txt @@ -1,8 +1,8 @@ -tests/cases/compiler/for.ts(29,1): error TS7027: Unreachable code detected. -tests/cases/compiler/for.ts(29,6): error TS1109: Expression expected. +tests/cases/compiler/for.ts(30,6): error TS1109: Expression expected. -==== tests/cases/compiler/for.ts (2 errors) ==== +==== tests/cases/compiler/for.ts (1 errors) ==== + for (var i = 0; i < 10; i++) { // ok var x1 = i; } @@ -32,8 +32,6 @@ tests/cases/compiler/for.ts(29,6): error TS1109: Expression expected. } for () { // error - ~~~ -!!! error TS7027: Unreachable code detected. ~ !!! error TS1109: Expression expected. } \ No newline at end of file diff --git a/tests/baselines/reference/for.js b/tests/baselines/reference/for.js index a77b68d8b6e..857d42bafdb 100644 --- a/tests/baselines/reference/for.js +++ b/tests/baselines/reference/for.js @@ -1,4 +1,5 @@ //// [for.ts] + for (var i = 0; i < 10; i++) { // ok var x1 = i; } diff --git a/tests/baselines/reference/forBreakStatements.errors.txt b/tests/baselines/reference/forBreakStatements.errors.txt deleted file mode 100644 index 2b42afc9be2..00000000000 --- a/tests/baselines/reference/forBreakStatements.errors.txt +++ /dev/null @@ -1,49 +0,0 @@ -tests/cases/conformance/statements/breakStatements/forBreakStatements.ts(10,1): error TS7028: Unused label. -tests/cases/conformance/statements/breakStatements/forBreakStatements.ts(18,5): error TS7028: Unused label. -tests/cases/conformance/statements/breakStatements/forBreakStatements.ts(29,1): error TS7027: Unreachable code detected. - - -==== tests/cases/conformance/statements/breakStatements/forBreakStatements.ts (3 errors) ==== - for (; ;) { - break; - } - - ONE: - for (; ;) { - break ONE; - } - - TWO: - ~~~ -!!! error TS7028: Unused label. - THREE: - for (; ;) { - break THREE; - } - - FOUR: - for (; ;) { - FIVE: - ~~~~ -!!! error TS7028: Unused label. - for (; ;) { - break FOUR; - } - } - - for (; ;) { - SIX: - for (; ;) break SIX; - } - - SEVEN: - ~~~~~ -!!! error TS7027: Unreachable code detected. - for (; ;) for (; ;) for (; ;) break SEVEN; - - EIGHT: - for (; ;) { - var fn = function () { } - break EIGHT; - } - \ No newline at end of file diff --git a/tests/baselines/reference/forBreakStatements.js b/tests/baselines/reference/forBreakStatements.js index 9ed65627c9c..da4fccdfd2a 100644 --- a/tests/baselines/reference/forBreakStatements.js +++ b/tests/baselines/reference/forBreakStatements.js @@ -1,4 +1,5 @@ //// [forBreakStatements.ts] + for (; ;) { break; } diff --git a/tests/baselines/reference/forBreakStatements.symbols b/tests/baselines/reference/forBreakStatements.symbols new file mode 100644 index 00000000000..6d869b45934 --- /dev/null +++ b/tests/baselines/reference/forBreakStatements.symbols @@ -0,0 +1,41 @@ +=== tests/cases/conformance/statements/breakStatements/forBreakStatements.ts === + +for (; ;) { + break; +} + +ONE: +for (; ;) { + break ONE; +} + +TWO: +THREE: +for (; ;) { + break THREE; +} + +FOUR: +for (; ;) { + FIVE: + for (; ;) { + break FOUR; + } +} + +for (; ;) { + SIX: + for (; ;) break SIX; +} + +SEVEN: +for (; ;) for (; ;) for (; ;) break SEVEN; + +EIGHT: +for (; ;) { + var fn = function () { } +>fn : Symbol(fn, Decl(forBreakStatements.ts, 34, 7)) + + break EIGHT; +} + diff --git a/tests/baselines/reference/forBreakStatements.types b/tests/baselines/reference/forBreakStatements.types new file mode 100644 index 00000000000..c494f6be30a --- /dev/null +++ b/tests/baselines/reference/forBreakStatements.types @@ -0,0 +1,64 @@ +=== tests/cases/conformance/statements/breakStatements/forBreakStatements.ts === + +for (; ;) { + break; +} + +ONE: +>ONE : any + +for (; ;) { + break ONE; +>ONE : any +} + +TWO: +>TWO : any + +THREE: +>THREE : any + +for (; ;) { + break THREE; +>THREE : any +} + +FOUR: +>FOUR : any + +for (; ;) { + FIVE: +>FIVE : any + + for (; ;) { + break FOUR; +>FOUR : any + } +} + +for (; ;) { + SIX: +>SIX : any + + for (; ;) break SIX; +>SIX : any +} + +SEVEN: +>SEVEN : any + +for (; ;) for (; ;) for (; ;) break SEVEN; +>SEVEN : any + +EIGHT: +>EIGHT : any + +for (; ;) { + var fn = function () { } +>fn : () => void +>function () { } : () => void + + break EIGHT; +>EIGHT : any +} + diff --git a/tests/baselines/reference/forContinueStatements.errors.txt b/tests/baselines/reference/forContinueStatements.errors.txt deleted file mode 100644 index b7a4cc35546..00000000000 --- a/tests/baselines/reference/forContinueStatements.errors.txt +++ /dev/null @@ -1,43 +0,0 @@ -tests/cases/conformance/statements/continueStatements/forContinueStatements.ts(5,1): error TS7027: Unreachable code detected. - - -==== tests/cases/conformance/statements/continueStatements/forContinueStatements.ts (1 errors) ==== - for (; ;) { - continue; - } - - ONE: - ~~~ -!!! error TS7027: Unreachable code detected. - for (; ;) { - continue ONE; - } - - TWO: - THREE: - for (; ;) { - continue THREE; - } - - FOUR: - for (; ;) { - FIVE: - for (; ;) { - continue FOUR; - } - } - - for (; ;) { - SIX: - for (; ;) continue SIX; - } - - SEVEN: - for (; ;) for (; ;) for (; ;) continue SEVEN; - - EIGHT: - for (; ;) { - var fn = function () { } - continue EIGHT; - } - \ No newline at end of file diff --git a/tests/baselines/reference/forContinueStatements.js b/tests/baselines/reference/forContinueStatements.js index 34f70bb1fc1..fc5aa0434b3 100644 --- a/tests/baselines/reference/forContinueStatements.js +++ b/tests/baselines/reference/forContinueStatements.js @@ -1,4 +1,5 @@ //// [forContinueStatements.ts] + for (; ;) { continue; } diff --git a/tests/baselines/reference/forContinueStatements.symbols b/tests/baselines/reference/forContinueStatements.symbols new file mode 100644 index 00000000000..9e0c396acfb --- /dev/null +++ b/tests/baselines/reference/forContinueStatements.symbols @@ -0,0 +1,41 @@ +=== tests/cases/conformance/statements/continueStatements/forContinueStatements.ts === + +for (; ;) { + continue; +} + +ONE: +for (; ;) { + continue ONE; +} + +TWO: +THREE: +for (; ;) { + continue THREE; +} + +FOUR: +for (; ;) { + FIVE: + for (; ;) { + continue FOUR; + } +} + +for (; ;) { + SIX: + for (; ;) continue SIX; +} + +SEVEN: +for (; ;) for (; ;) for (; ;) continue SEVEN; + +EIGHT: +for (; ;) { + var fn = function () { } +>fn : Symbol(fn, Decl(forContinueStatements.ts, 34, 7)) + + continue EIGHT; +} + diff --git a/tests/baselines/reference/forContinueStatements.types b/tests/baselines/reference/forContinueStatements.types new file mode 100644 index 00000000000..0b52bdd5d47 --- /dev/null +++ b/tests/baselines/reference/forContinueStatements.types @@ -0,0 +1,64 @@ +=== tests/cases/conformance/statements/continueStatements/forContinueStatements.ts === + +for (; ;) { + continue; +} + +ONE: +>ONE : any + +for (; ;) { + continue ONE; +>ONE : any +} + +TWO: +>TWO : any + +THREE: +>THREE : any + +for (; ;) { + continue THREE; +>THREE : any +} + +FOUR: +>FOUR : any + +for (; ;) { + FIVE: +>FIVE : any + + for (; ;) { + continue FOUR; +>FOUR : any + } +} + +for (; ;) { + SIX: +>SIX : any + + for (; ;) continue SIX; +>SIX : any +} + +SEVEN: +>SEVEN : any + +for (; ;) for (; ;) for (; ;) continue SEVEN; +>SEVEN : any + +EIGHT: +>EIGHT : any + +for (; ;) { + var fn = function () { } +>fn : () => void +>function () { } : () => void + + continue EIGHT; +>EIGHT : any +} + diff --git a/tests/baselines/reference/forInBreakStatements.errors.txt b/tests/baselines/reference/forInBreakStatements.errors.txt deleted file mode 100644 index 8bbbf2d38ee..00000000000 --- a/tests/baselines/reference/forInBreakStatements.errors.txt +++ /dev/null @@ -1,46 +0,0 @@ -tests/cases/conformance/statements/breakStatements/forInBreakStatements.ts(10,1): error TS7028: Unused label. -tests/cases/conformance/statements/breakStatements/forInBreakStatements.ts(18,5): error TS7028: Unused label. - - -==== tests/cases/conformance/statements/breakStatements/forInBreakStatements.ts (2 errors) ==== - for(var x in {}) { - break; - } - - ONE: - for(var x in {}) { - break ONE; - } - - TWO: - ~~~ -!!! error TS7028: Unused label. - THREE: - for(var x in {}) { - break THREE; - } - - FOUR: - for(var x in {}) { - FIVE: - ~~~~ -!!! error TS7028: Unused label. - for(var x in {}) { - break FOUR; - } - } - - for(var x in {}) { - SIX: - for(var x in {}) break SIX; - } - - SEVEN: - for (var x in {}) for (var x in {}) for (var x in {}) break SEVEN; - - EIGHT: - for (var x in {}){ - var fn = function () { } - break EIGHT; - } - \ No newline at end of file diff --git a/tests/baselines/reference/forInBreakStatements.js b/tests/baselines/reference/forInBreakStatements.js index 24b7cc57b8d..ebbadb31277 100644 --- a/tests/baselines/reference/forInBreakStatements.js +++ b/tests/baselines/reference/forInBreakStatements.js @@ -1,4 +1,5 @@ //// [forInBreakStatements.ts] + for(var x in {}) { break; } diff --git a/tests/baselines/reference/forInBreakStatements.symbols b/tests/baselines/reference/forInBreakStatements.symbols new file mode 100644 index 00000000000..5f48e110835 --- /dev/null +++ b/tests/baselines/reference/forInBreakStatements.symbols @@ -0,0 +1,59 @@ +=== tests/cases/conformance/statements/breakStatements/forInBreakStatements.ts === + +for(var x in {}) { +>x : Symbol(x, Decl(forInBreakStatements.ts, 1, 7), Decl(forInBreakStatements.ts, 6, 7), Decl(forInBreakStatements.ts, 12, 7), Decl(forInBreakStatements.ts, 17, 7), Decl(forInBreakStatements.ts, 19, 11), Decl(forInBreakStatements.ts, 24, 7), Decl(forInBreakStatements.ts, 26, 11), Decl(forInBreakStatements.ts, 30, 8), Decl(forInBreakStatements.ts, 30, 26), Decl(forInBreakStatements.ts, 30, 44), Decl(forInBreakStatements.ts, 33, 8)) + + break; +} + +ONE: +for(var x in {}) { +>x : Symbol(x, Decl(forInBreakStatements.ts, 1, 7), Decl(forInBreakStatements.ts, 6, 7), Decl(forInBreakStatements.ts, 12, 7), Decl(forInBreakStatements.ts, 17, 7), Decl(forInBreakStatements.ts, 19, 11), Decl(forInBreakStatements.ts, 24, 7), Decl(forInBreakStatements.ts, 26, 11), Decl(forInBreakStatements.ts, 30, 8), Decl(forInBreakStatements.ts, 30, 26), Decl(forInBreakStatements.ts, 30, 44), Decl(forInBreakStatements.ts, 33, 8)) + + break ONE; +} + +TWO: +THREE: +for(var x in {}) { +>x : Symbol(x, Decl(forInBreakStatements.ts, 1, 7), Decl(forInBreakStatements.ts, 6, 7), Decl(forInBreakStatements.ts, 12, 7), Decl(forInBreakStatements.ts, 17, 7), Decl(forInBreakStatements.ts, 19, 11), Decl(forInBreakStatements.ts, 24, 7), Decl(forInBreakStatements.ts, 26, 11), Decl(forInBreakStatements.ts, 30, 8), Decl(forInBreakStatements.ts, 30, 26), Decl(forInBreakStatements.ts, 30, 44), Decl(forInBreakStatements.ts, 33, 8)) + + break THREE; +} + +FOUR: +for(var x in {}) { +>x : Symbol(x, Decl(forInBreakStatements.ts, 1, 7), Decl(forInBreakStatements.ts, 6, 7), Decl(forInBreakStatements.ts, 12, 7), Decl(forInBreakStatements.ts, 17, 7), Decl(forInBreakStatements.ts, 19, 11), Decl(forInBreakStatements.ts, 24, 7), Decl(forInBreakStatements.ts, 26, 11), Decl(forInBreakStatements.ts, 30, 8), Decl(forInBreakStatements.ts, 30, 26), Decl(forInBreakStatements.ts, 30, 44), Decl(forInBreakStatements.ts, 33, 8)) + + FIVE: + for(var x in {}) { +>x : Symbol(x, Decl(forInBreakStatements.ts, 1, 7), Decl(forInBreakStatements.ts, 6, 7), Decl(forInBreakStatements.ts, 12, 7), Decl(forInBreakStatements.ts, 17, 7), Decl(forInBreakStatements.ts, 19, 11), Decl(forInBreakStatements.ts, 24, 7), Decl(forInBreakStatements.ts, 26, 11), Decl(forInBreakStatements.ts, 30, 8), Decl(forInBreakStatements.ts, 30, 26), Decl(forInBreakStatements.ts, 30, 44), Decl(forInBreakStatements.ts, 33, 8)) + + break FOUR; + } +} + +for(var x in {}) { +>x : Symbol(x, Decl(forInBreakStatements.ts, 1, 7), Decl(forInBreakStatements.ts, 6, 7), Decl(forInBreakStatements.ts, 12, 7), Decl(forInBreakStatements.ts, 17, 7), Decl(forInBreakStatements.ts, 19, 11), Decl(forInBreakStatements.ts, 24, 7), Decl(forInBreakStatements.ts, 26, 11), Decl(forInBreakStatements.ts, 30, 8), Decl(forInBreakStatements.ts, 30, 26), Decl(forInBreakStatements.ts, 30, 44), Decl(forInBreakStatements.ts, 33, 8)) + + SIX: + for(var x in {}) break SIX; +>x : Symbol(x, Decl(forInBreakStatements.ts, 1, 7), Decl(forInBreakStatements.ts, 6, 7), Decl(forInBreakStatements.ts, 12, 7), Decl(forInBreakStatements.ts, 17, 7), Decl(forInBreakStatements.ts, 19, 11), Decl(forInBreakStatements.ts, 24, 7), Decl(forInBreakStatements.ts, 26, 11), Decl(forInBreakStatements.ts, 30, 8), Decl(forInBreakStatements.ts, 30, 26), Decl(forInBreakStatements.ts, 30, 44), Decl(forInBreakStatements.ts, 33, 8)) +} + +SEVEN: +for (var x in {}) for (var x in {}) for (var x in {}) break SEVEN; +>x : Symbol(x, Decl(forInBreakStatements.ts, 1, 7), Decl(forInBreakStatements.ts, 6, 7), Decl(forInBreakStatements.ts, 12, 7), Decl(forInBreakStatements.ts, 17, 7), Decl(forInBreakStatements.ts, 19, 11), Decl(forInBreakStatements.ts, 24, 7), Decl(forInBreakStatements.ts, 26, 11), Decl(forInBreakStatements.ts, 30, 8), Decl(forInBreakStatements.ts, 30, 26), Decl(forInBreakStatements.ts, 30, 44), Decl(forInBreakStatements.ts, 33, 8)) +>x : Symbol(x, Decl(forInBreakStatements.ts, 1, 7), Decl(forInBreakStatements.ts, 6, 7), Decl(forInBreakStatements.ts, 12, 7), Decl(forInBreakStatements.ts, 17, 7), Decl(forInBreakStatements.ts, 19, 11), Decl(forInBreakStatements.ts, 24, 7), Decl(forInBreakStatements.ts, 26, 11), Decl(forInBreakStatements.ts, 30, 8), Decl(forInBreakStatements.ts, 30, 26), Decl(forInBreakStatements.ts, 30, 44), Decl(forInBreakStatements.ts, 33, 8)) +>x : Symbol(x, Decl(forInBreakStatements.ts, 1, 7), Decl(forInBreakStatements.ts, 6, 7), Decl(forInBreakStatements.ts, 12, 7), Decl(forInBreakStatements.ts, 17, 7), Decl(forInBreakStatements.ts, 19, 11), Decl(forInBreakStatements.ts, 24, 7), Decl(forInBreakStatements.ts, 26, 11), Decl(forInBreakStatements.ts, 30, 8), Decl(forInBreakStatements.ts, 30, 26), Decl(forInBreakStatements.ts, 30, 44), Decl(forInBreakStatements.ts, 33, 8)) + +EIGHT: +for (var x in {}){ +>x : Symbol(x, Decl(forInBreakStatements.ts, 1, 7), Decl(forInBreakStatements.ts, 6, 7), Decl(forInBreakStatements.ts, 12, 7), Decl(forInBreakStatements.ts, 17, 7), Decl(forInBreakStatements.ts, 19, 11), Decl(forInBreakStatements.ts, 24, 7), Decl(forInBreakStatements.ts, 26, 11), Decl(forInBreakStatements.ts, 30, 8), Decl(forInBreakStatements.ts, 30, 26), Decl(forInBreakStatements.ts, 30, 44), Decl(forInBreakStatements.ts, 33, 8)) + + var fn = function () { } +>fn : Symbol(fn, Decl(forInBreakStatements.ts, 34, 7)) + + break EIGHT; +} + diff --git a/tests/baselines/reference/forInBreakStatements.types b/tests/baselines/reference/forInBreakStatements.types new file mode 100644 index 00000000000..7714429e5af --- /dev/null +++ b/tests/baselines/reference/forInBreakStatements.types @@ -0,0 +1,93 @@ +=== tests/cases/conformance/statements/breakStatements/forInBreakStatements.ts === + +for(var x in {}) { +>x : any +>{} : {} + + break; +} + +ONE: +>ONE : any + +for(var x in {}) { +>x : any +>{} : {} + + break ONE; +>ONE : any +} + +TWO: +>TWO : any + +THREE: +>THREE : any + +for(var x in {}) { +>x : any +>{} : {} + + break THREE; +>THREE : any +} + +FOUR: +>FOUR : any + +for(var x in {}) { +>x : any +>{} : {} + + FIVE: +>FIVE : any + + for(var x in {}) { +>x : any +>{} : {} + + break FOUR; +>FOUR : any + } +} + +for(var x in {}) { +>x : any +>{} : {} + + SIX: +>SIX : any + + for(var x in {}) break SIX; +>x : any +>{} : {} +>SIX : any +} + +SEVEN: +>SEVEN : any + +for (var x in {}) for (var x in {}) for (var x in {}) break SEVEN; +>x : any +>{} : {} +>x : any +>{} : {} +>x : any +>{} : {} +>SEVEN : any + +EIGHT: +>EIGHT : any + +for (var x in {}){ +>x : any +>{} : {} + + var fn = function () { } +>fn : () => void +>function () { } : () => void + + break EIGHT; +>EIGHT : any +} + diff --git a/tests/baselines/reference/forInContinueStatements.errors.txt b/tests/baselines/reference/forInContinueStatements.errors.txt deleted file mode 100644 index 7a3a74e5aee..00000000000 --- a/tests/baselines/reference/forInContinueStatements.errors.txt +++ /dev/null @@ -1,46 +0,0 @@ -tests/cases/conformance/statements/continueStatements/forInContinueStatements.ts(10,1): error TS7028: Unused label. -tests/cases/conformance/statements/continueStatements/forInContinueStatements.ts(18,5): error TS7028: Unused label. - - -==== tests/cases/conformance/statements/continueStatements/forInContinueStatements.ts (2 errors) ==== - for(var x in {}) { - continue; - } - - ONE: - for(var x in {}) { - continue ONE; - } - - TWO: - ~~~ -!!! error TS7028: Unused label. - THREE: - for(var x in {}) { - continue THREE; - } - - FOUR: - for(var x in {}) { - FIVE: - ~~~~ -!!! error TS7028: Unused label. - for(var x in {}) { - continue FOUR; - } - } - - for(var x in {}) { - SIX: - for(var x in {}) continue SIX; - } - - SEVEN: - for (var x in {}) for (var x in {}) for (var x in {}) continue SEVEN; - - EIGHT: - for (var x in {}){ - var fn = function () { } - continue EIGHT; - } - \ No newline at end of file diff --git a/tests/baselines/reference/forInContinueStatements.js b/tests/baselines/reference/forInContinueStatements.js index 8b036c59721..ca530dd5d6c 100644 --- a/tests/baselines/reference/forInContinueStatements.js +++ b/tests/baselines/reference/forInContinueStatements.js @@ -1,4 +1,5 @@ //// [forInContinueStatements.ts] + for(var x in {}) { continue; } diff --git a/tests/baselines/reference/forInContinueStatements.symbols b/tests/baselines/reference/forInContinueStatements.symbols new file mode 100644 index 00000000000..a0edea53f3e --- /dev/null +++ b/tests/baselines/reference/forInContinueStatements.symbols @@ -0,0 +1,59 @@ +=== tests/cases/conformance/statements/continueStatements/forInContinueStatements.ts === + +for(var x in {}) { +>x : Symbol(x, Decl(forInContinueStatements.ts, 1, 7), Decl(forInContinueStatements.ts, 6, 7), Decl(forInContinueStatements.ts, 12, 7), Decl(forInContinueStatements.ts, 17, 7), Decl(forInContinueStatements.ts, 19, 11), Decl(forInContinueStatements.ts, 24, 7), Decl(forInContinueStatements.ts, 26, 11), Decl(forInContinueStatements.ts, 30, 8), Decl(forInContinueStatements.ts, 30, 26), Decl(forInContinueStatements.ts, 30, 44), Decl(forInContinueStatements.ts, 33, 8)) + + continue; +} + +ONE: +for(var x in {}) { +>x : Symbol(x, Decl(forInContinueStatements.ts, 1, 7), Decl(forInContinueStatements.ts, 6, 7), Decl(forInContinueStatements.ts, 12, 7), Decl(forInContinueStatements.ts, 17, 7), Decl(forInContinueStatements.ts, 19, 11), Decl(forInContinueStatements.ts, 24, 7), Decl(forInContinueStatements.ts, 26, 11), Decl(forInContinueStatements.ts, 30, 8), Decl(forInContinueStatements.ts, 30, 26), Decl(forInContinueStatements.ts, 30, 44), Decl(forInContinueStatements.ts, 33, 8)) + + continue ONE; +} + +TWO: +THREE: +for(var x in {}) { +>x : Symbol(x, Decl(forInContinueStatements.ts, 1, 7), Decl(forInContinueStatements.ts, 6, 7), Decl(forInContinueStatements.ts, 12, 7), Decl(forInContinueStatements.ts, 17, 7), Decl(forInContinueStatements.ts, 19, 11), Decl(forInContinueStatements.ts, 24, 7), Decl(forInContinueStatements.ts, 26, 11), Decl(forInContinueStatements.ts, 30, 8), Decl(forInContinueStatements.ts, 30, 26), Decl(forInContinueStatements.ts, 30, 44), Decl(forInContinueStatements.ts, 33, 8)) + + continue THREE; +} + +FOUR: +for(var x in {}) { +>x : Symbol(x, Decl(forInContinueStatements.ts, 1, 7), Decl(forInContinueStatements.ts, 6, 7), Decl(forInContinueStatements.ts, 12, 7), Decl(forInContinueStatements.ts, 17, 7), Decl(forInContinueStatements.ts, 19, 11), Decl(forInContinueStatements.ts, 24, 7), Decl(forInContinueStatements.ts, 26, 11), Decl(forInContinueStatements.ts, 30, 8), Decl(forInContinueStatements.ts, 30, 26), Decl(forInContinueStatements.ts, 30, 44), Decl(forInContinueStatements.ts, 33, 8)) + + FIVE: + for(var x in {}) { +>x : Symbol(x, Decl(forInContinueStatements.ts, 1, 7), Decl(forInContinueStatements.ts, 6, 7), Decl(forInContinueStatements.ts, 12, 7), Decl(forInContinueStatements.ts, 17, 7), Decl(forInContinueStatements.ts, 19, 11), Decl(forInContinueStatements.ts, 24, 7), Decl(forInContinueStatements.ts, 26, 11), Decl(forInContinueStatements.ts, 30, 8), Decl(forInContinueStatements.ts, 30, 26), Decl(forInContinueStatements.ts, 30, 44), Decl(forInContinueStatements.ts, 33, 8)) + + continue FOUR; + } +} + +for(var x in {}) { +>x : Symbol(x, Decl(forInContinueStatements.ts, 1, 7), Decl(forInContinueStatements.ts, 6, 7), Decl(forInContinueStatements.ts, 12, 7), Decl(forInContinueStatements.ts, 17, 7), Decl(forInContinueStatements.ts, 19, 11), Decl(forInContinueStatements.ts, 24, 7), Decl(forInContinueStatements.ts, 26, 11), Decl(forInContinueStatements.ts, 30, 8), Decl(forInContinueStatements.ts, 30, 26), Decl(forInContinueStatements.ts, 30, 44), Decl(forInContinueStatements.ts, 33, 8)) + + SIX: + for(var x in {}) continue SIX; +>x : Symbol(x, Decl(forInContinueStatements.ts, 1, 7), Decl(forInContinueStatements.ts, 6, 7), Decl(forInContinueStatements.ts, 12, 7), Decl(forInContinueStatements.ts, 17, 7), Decl(forInContinueStatements.ts, 19, 11), Decl(forInContinueStatements.ts, 24, 7), Decl(forInContinueStatements.ts, 26, 11), Decl(forInContinueStatements.ts, 30, 8), Decl(forInContinueStatements.ts, 30, 26), Decl(forInContinueStatements.ts, 30, 44), Decl(forInContinueStatements.ts, 33, 8)) +} + +SEVEN: +for (var x in {}) for (var x in {}) for (var x in {}) continue SEVEN; +>x : Symbol(x, Decl(forInContinueStatements.ts, 1, 7), Decl(forInContinueStatements.ts, 6, 7), Decl(forInContinueStatements.ts, 12, 7), Decl(forInContinueStatements.ts, 17, 7), Decl(forInContinueStatements.ts, 19, 11), Decl(forInContinueStatements.ts, 24, 7), Decl(forInContinueStatements.ts, 26, 11), Decl(forInContinueStatements.ts, 30, 8), Decl(forInContinueStatements.ts, 30, 26), Decl(forInContinueStatements.ts, 30, 44), Decl(forInContinueStatements.ts, 33, 8)) +>x : Symbol(x, Decl(forInContinueStatements.ts, 1, 7), Decl(forInContinueStatements.ts, 6, 7), Decl(forInContinueStatements.ts, 12, 7), Decl(forInContinueStatements.ts, 17, 7), Decl(forInContinueStatements.ts, 19, 11), Decl(forInContinueStatements.ts, 24, 7), Decl(forInContinueStatements.ts, 26, 11), Decl(forInContinueStatements.ts, 30, 8), Decl(forInContinueStatements.ts, 30, 26), Decl(forInContinueStatements.ts, 30, 44), Decl(forInContinueStatements.ts, 33, 8)) +>x : Symbol(x, Decl(forInContinueStatements.ts, 1, 7), Decl(forInContinueStatements.ts, 6, 7), Decl(forInContinueStatements.ts, 12, 7), Decl(forInContinueStatements.ts, 17, 7), Decl(forInContinueStatements.ts, 19, 11), Decl(forInContinueStatements.ts, 24, 7), Decl(forInContinueStatements.ts, 26, 11), Decl(forInContinueStatements.ts, 30, 8), Decl(forInContinueStatements.ts, 30, 26), Decl(forInContinueStatements.ts, 30, 44), Decl(forInContinueStatements.ts, 33, 8)) + +EIGHT: +for (var x in {}){ +>x : Symbol(x, Decl(forInContinueStatements.ts, 1, 7), Decl(forInContinueStatements.ts, 6, 7), Decl(forInContinueStatements.ts, 12, 7), Decl(forInContinueStatements.ts, 17, 7), Decl(forInContinueStatements.ts, 19, 11), Decl(forInContinueStatements.ts, 24, 7), Decl(forInContinueStatements.ts, 26, 11), Decl(forInContinueStatements.ts, 30, 8), Decl(forInContinueStatements.ts, 30, 26), Decl(forInContinueStatements.ts, 30, 44), Decl(forInContinueStatements.ts, 33, 8)) + + var fn = function () { } +>fn : Symbol(fn, Decl(forInContinueStatements.ts, 34, 7)) + + continue EIGHT; +} + diff --git a/tests/baselines/reference/forInContinueStatements.types b/tests/baselines/reference/forInContinueStatements.types new file mode 100644 index 00000000000..572fd16053d --- /dev/null +++ b/tests/baselines/reference/forInContinueStatements.types @@ -0,0 +1,93 @@ +=== tests/cases/conformance/statements/continueStatements/forInContinueStatements.ts === + +for(var x in {}) { +>x : any +>{} : {} + + continue; +} + +ONE: +>ONE : any + +for(var x in {}) { +>x : any +>{} : {} + + continue ONE; +>ONE : any +} + +TWO: +>TWO : any + +THREE: +>THREE : any + +for(var x in {}) { +>x : any +>{} : {} + + continue THREE; +>THREE : any +} + +FOUR: +>FOUR : any + +for(var x in {}) { +>x : any +>{} : {} + + FIVE: +>FIVE : any + + for(var x in {}) { +>x : any +>{} : {} + + continue FOUR; +>FOUR : any + } +} + +for(var x in {}) { +>x : any +>{} : {} + + SIX: +>SIX : any + + for(var x in {}) continue SIX; +>x : any +>{} : {} +>SIX : any +} + +SEVEN: +>SEVEN : any + +for (var x in {}) for (var x in {}) for (var x in {}) continue SEVEN; +>x : any +>{} : {} +>x : any +>{} : {} +>x : any +>{} : {} +>SEVEN : any + +EIGHT: +>EIGHT : any + +for (var x in {}){ +>x : any +>{} : {} + + var fn = function () { } +>fn : () => void +>function () { } : () => void + + continue EIGHT; +>EIGHT : any +} + diff --git a/tests/baselines/reference/forStatements.errors.txt b/tests/baselines/reference/forStatements.errors.txt deleted file mode 100644 index 5f1e6f10c79..00000000000 --- a/tests/baselines/reference/forStatements.errors.txt +++ /dev/null @@ -1,52 +0,0 @@ -tests/cases/conformance/statements/forStatements/forStatements.ts(26,1): error TS7027: Unreachable code detected. - - -==== tests/cases/conformance/statements/forStatements/forStatements.ts (1 errors) ==== - interface I { - id: number; - } - - class C implements I { - id: number; - } - - class D{ - source: T; - recurse: D; - wrapped: D> - } - - function F(x: string): number { return 42; } - - module M { - export class A { - name: string; - } - - export function F2(x: number): string { return x.toString(); } - } - - for(var aNumber: number = 9.9;;){} - for(var aString: string = 'this is a string';;){} - ~~~ -!!! error TS7027: Unreachable code detected. - for(var aDate: Date = new Date(12);;){} - for(var anObject: Object = new Object();;){} - - for(var anAny: any = null;;){} - for(var aSecondAny: any = undefined;;){} - for(var aVoid: void = undefined;;){} - - for(var anInterface: I = new C();;){} - for(var aClass: C = new C();;){} - for(var aGenericClass: D = new D();;){} - for(var anObjectLiteral: I = { id: 12 };;){} - for(var anOtherObjectLiteral: { id: number } = new C();;){} - - for(var aFunction: typeof F = F;;){} - for(var anOtherFunction: (x: string) => number = F;;){} - for(var aLambda: typeof F = (x) => 2;;){} - - for(var aModule: typeof M = M;;){} - for(var aClassInModule: M.A = new M.A();;){} - for(var aFunctionInModule: typeof M.F2 = (x) => 'this is a string';;){} \ No newline at end of file diff --git a/tests/baselines/reference/forStatements.js b/tests/baselines/reference/forStatements.js index 39fdb6c8871..253fafc81e8 100644 --- a/tests/baselines/reference/forStatements.js +++ b/tests/baselines/reference/forStatements.js @@ -1,4 +1,5 @@ //// [forStatements.ts] + interface I { id: number; } diff --git a/tests/baselines/reference/forStatements.symbols b/tests/baselines/reference/forStatements.symbols new file mode 100644 index 00000000000..2d5250217f9 --- /dev/null +++ b/tests/baselines/reference/forStatements.symbols @@ -0,0 +1,146 @@ +=== tests/cases/conformance/statements/forStatements/forStatements.ts === + +interface I { +>I : Symbol(I, Decl(forStatements.ts, 0, 0)) + + id: number; +>id : Symbol(id, Decl(forStatements.ts, 1, 13)) +} + +class C implements I { +>C : Symbol(C, Decl(forStatements.ts, 3, 1)) +>I : Symbol(I, Decl(forStatements.ts, 0, 0)) + + id: number; +>id : Symbol(id, Decl(forStatements.ts, 5, 22)) +} + +class D{ +>D : Symbol(D, Decl(forStatements.ts, 7, 1)) +>T : Symbol(T, Decl(forStatements.ts, 9, 8)) + + source: T; +>source : Symbol(source, Decl(forStatements.ts, 9, 11)) +>T : Symbol(T, Decl(forStatements.ts, 9, 8)) + + recurse: D; +>recurse : Symbol(recurse, Decl(forStatements.ts, 10, 14)) +>D : Symbol(D, Decl(forStatements.ts, 7, 1)) +>T : Symbol(T, Decl(forStatements.ts, 9, 8)) + + wrapped: D> +>wrapped : Symbol(wrapped, Decl(forStatements.ts, 11, 18)) +>D : Symbol(D, Decl(forStatements.ts, 7, 1)) +>D : Symbol(D, Decl(forStatements.ts, 7, 1)) +>T : Symbol(T, Decl(forStatements.ts, 9, 8)) +} + +function F(x: string): number { return 42; } +>F : Symbol(F, Decl(forStatements.ts, 13, 1)) +>x : Symbol(x, Decl(forStatements.ts, 15, 11)) + +module M { +>M : Symbol(M, Decl(forStatements.ts, 15, 44)) + + export class A { +>A : Symbol(A, Decl(forStatements.ts, 17, 10)) + + name: string; +>name : Symbol(name, Decl(forStatements.ts, 18, 20)) + } + + export function F2(x: number): string { return x.toString(); } +>F2 : Symbol(F2, Decl(forStatements.ts, 20, 5)) +>x : Symbol(x, Decl(forStatements.ts, 22, 23)) +>x.toString : Symbol(Number.toString, Decl(lib.d.ts, --, --)) +>x : Symbol(x, Decl(forStatements.ts, 22, 23)) +>toString : Symbol(Number.toString, Decl(lib.d.ts, --, --)) +} + +for(var aNumber: number = 9.9;;){} +>aNumber : Symbol(aNumber, Decl(forStatements.ts, 25, 7)) + +for(var aString: string = 'this is a string';;){} +>aString : Symbol(aString, Decl(forStatements.ts, 26, 7)) + +for(var aDate: Date = new Date(12);;){} +>aDate : Symbol(aDate, Decl(forStatements.ts, 27, 7)) +>Date : Symbol(Date, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>Date : Symbol(Date, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) + +for(var anObject: Object = new Object();;){} +>anObject : Symbol(anObject, Decl(forStatements.ts, 28, 7)) +>Object : Symbol(Object, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>Object : Symbol(Object, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) + +for(var anAny: any = null;;){} +>anAny : Symbol(anAny, Decl(forStatements.ts, 30, 7)) + +for(var aSecondAny: any = undefined;;){} +>aSecondAny : Symbol(aSecondAny, Decl(forStatements.ts, 31, 7)) +>undefined : Symbol(undefined) + +for(var aVoid: void = undefined;;){} +>aVoid : Symbol(aVoid, Decl(forStatements.ts, 32, 7)) +>undefined : Symbol(undefined) + +for(var anInterface: I = new C();;){} +>anInterface : Symbol(anInterface, Decl(forStatements.ts, 34, 7)) +>I : Symbol(I, Decl(forStatements.ts, 0, 0)) +>C : Symbol(C, Decl(forStatements.ts, 3, 1)) + +for(var aClass: C = new C();;){} +>aClass : Symbol(aClass, Decl(forStatements.ts, 35, 7)) +>C : Symbol(C, Decl(forStatements.ts, 3, 1)) +>C : Symbol(C, Decl(forStatements.ts, 3, 1)) + +for(var aGenericClass: D = new D();;){} +>aGenericClass : Symbol(aGenericClass, Decl(forStatements.ts, 36, 7)) +>D : Symbol(D, Decl(forStatements.ts, 7, 1)) +>D : Symbol(D, Decl(forStatements.ts, 7, 1)) + +for(var anObjectLiteral: I = { id: 12 };;){} +>anObjectLiteral : Symbol(anObjectLiteral, Decl(forStatements.ts, 37, 7)) +>I : Symbol(I, Decl(forStatements.ts, 0, 0)) +>id : Symbol(id, Decl(forStatements.ts, 37, 30)) + +for(var anOtherObjectLiteral: { id: number } = new C();;){} +>anOtherObjectLiteral : Symbol(anOtherObjectLiteral, Decl(forStatements.ts, 38, 7)) +>id : Symbol(id, Decl(forStatements.ts, 38, 31)) +>C : Symbol(C, Decl(forStatements.ts, 3, 1)) + +for(var aFunction: typeof F = F;;){} +>aFunction : Symbol(aFunction, Decl(forStatements.ts, 40, 7)) +>F : Symbol(F, Decl(forStatements.ts, 13, 1)) +>F : Symbol(F, Decl(forStatements.ts, 13, 1)) + +for(var anOtherFunction: (x: string) => number = F;;){} +>anOtherFunction : Symbol(anOtherFunction, Decl(forStatements.ts, 41, 7)) +>x : Symbol(x, Decl(forStatements.ts, 41, 26)) +>F : Symbol(F, Decl(forStatements.ts, 13, 1)) + +for(var aLambda: typeof F = (x) => 2;;){} +>aLambda : Symbol(aLambda, Decl(forStatements.ts, 42, 7)) +>F : Symbol(F, Decl(forStatements.ts, 13, 1)) +>x : Symbol(x, Decl(forStatements.ts, 42, 29)) + +for(var aModule: typeof M = M;;){} +>aModule : Symbol(aModule, Decl(forStatements.ts, 44, 7)) +>M : Symbol(M, Decl(forStatements.ts, 15, 44)) +>M : Symbol(M, Decl(forStatements.ts, 15, 44)) + +for(var aClassInModule: M.A = new M.A();;){} +>aClassInModule : Symbol(aClassInModule, Decl(forStatements.ts, 45, 7)) +>M : Symbol(M, Decl(forStatements.ts, 15, 44)) +>A : Symbol(M.A, Decl(forStatements.ts, 17, 10)) +>M.A : Symbol(M.A, Decl(forStatements.ts, 17, 10)) +>M : Symbol(M, Decl(forStatements.ts, 15, 44)) +>A : Symbol(M.A, Decl(forStatements.ts, 17, 10)) + +for(var aFunctionInModule: typeof M.F2 = (x) => 'this is a string';;){} +>aFunctionInModule : Symbol(aFunctionInModule, Decl(forStatements.ts, 46, 7)) +>M.F2 : Symbol(M.F2, Decl(forStatements.ts, 20, 5)) +>M : Symbol(M, Decl(forStatements.ts, 15, 44)) +>F2 : Symbol(M.F2, Decl(forStatements.ts, 20, 5)) +>x : Symbol(x, Decl(forStatements.ts, 46, 42)) + diff --git a/tests/baselines/reference/forStatements.types b/tests/baselines/reference/forStatements.types new file mode 100644 index 00000000000..95b198a7fec --- /dev/null +++ b/tests/baselines/reference/forStatements.types @@ -0,0 +1,165 @@ +=== tests/cases/conformance/statements/forStatements/forStatements.ts === + +interface I { +>I : I + + id: number; +>id : number +} + +class C implements I { +>C : C +>I : I + + id: number; +>id : number +} + +class D{ +>D : D +>T : T + + source: T; +>source : T +>T : T + + recurse: D; +>recurse : D +>D : D +>T : T + + wrapped: D> +>wrapped : D> +>D : D +>D : D +>T : T +} + +function F(x: string): number { return 42; } +>F : (x: string) => number +>x : string +>42 : number + +module M { +>M : typeof M + + export class A { +>A : A + + name: string; +>name : string + } + + export function F2(x: number): string { return x.toString(); } +>F2 : (x: number) => string +>x : number +>x.toString() : string +>x.toString : (radix?: number) => string +>x : number +>toString : (radix?: number) => string +} + +for(var aNumber: number = 9.9;;){} +>aNumber : number +>9.9 : number + +for(var aString: string = 'this is a string';;){} +>aString : string +>'this is a string' : string + +for(var aDate: Date = new Date(12);;){} +>aDate : Date +>Date : Date +>new Date(12) : Date +>Date : DateConstructor +>12 : number + +for(var anObject: Object = new Object();;){} +>anObject : Object +>Object : Object +>new Object() : Object +>Object : ObjectConstructor + +for(var anAny: any = null;;){} +>anAny : any +>null : null + +for(var aSecondAny: any = undefined;;){} +>aSecondAny : any +>undefined : undefined + +for(var aVoid: void = undefined;;){} +>aVoid : void +>undefined : undefined + +for(var anInterface: I = new C();;){} +>anInterface : I +>I : I +>new C() : C +>C : typeof C + +for(var aClass: C = new C();;){} +>aClass : C +>C : C +>new C() : C +>C : typeof C + +for(var aGenericClass: D = new D();;){} +>aGenericClass : D +>D : D +>new D() : D +>D : typeof D + +for(var anObjectLiteral: I = { id: 12 };;){} +>anObjectLiteral : I +>I : I +>{ id: 12 } : { id: number; } +>id : number +>12 : number + +for(var anOtherObjectLiteral: { id: number } = new C();;){} +>anOtherObjectLiteral : { id: number; } +>id : number +>new C() : C +>C : typeof C + +for(var aFunction: typeof F = F;;){} +>aFunction : (x: string) => number +>F : (x: string) => number +>F : (x: string) => number + +for(var anOtherFunction: (x: string) => number = F;;){} +>anOtherFunction : (x: string) => number +>x : string +>F : (x: string) => number + +for(var aLambda: typeof F = (x) => 2;;){} +>aLambda : (x: string) => number +>F : (x: string) => number +>(x) => 2 : (x: string) => number +>x : string +>2 : number + +for(var aModule: typeof M = M;;){} +>aModule : typeof M +>M : typeof M +>M : typeof M + +for(var aClassInModule: M.A = new M.A();;){} +>aClassInModule : M.A +>M : any +>A : M.A +>new M.A() : M.A +>M.A : typeof M.A +>M : typeof M +>A : typeof M.A + +for(var aFunctionInModule: typeof M.F2 = (x) => 'this is a string';;){} +>aFunctionInModule : (x: number) => string +>M.F2 : (x: number) => string +>M : typeof M +>F2 : (x: number) => string +>(x) => 'this is a string' : (x: number) => string +>x : number +>'this is a string' : string + diff --git a/tests/baselines/reference/forStatementsMultipleInvalidDecl.errors.txt b/tests/baselines/reference/forStatementsMultipleInvalidDecl.errors.txt index fa1c87824d7..f1869ae7fca 100644 --- a/tests/baselines/reference/forStatementsMultipleInvalidDecl.errors.txt +++ b/tests/baselines/reference/forStatementsMultipleInvalidDecl.errors.txt @@ -1,19 +1,19 @@ -tests/cases/conformance/statements/forStatements/forStatementsMultipleInvalidDecl.ts(32,1): error TS7027: Unreachable code detected. -tests/cases/conformance/statements/forStatements/forStatementsMultipleInvalidDecl.ts(32,10): error TS2403: Subsequent variable declarations must have the same type. Variable 'a' must be of type 'any', but here has type 'number'. -tests/cases/conformance/statements/forStatements/forStatementsMultipleInvalidDecl.ts(33,10): error TS2403: Subsequent variable declarations must have the same type. Variable 'a' must be of type 'any', but here has type 'string'. -tests/cases/conformance/statements/forStatements/forStatementsMultipleInvalidDecl.ts(34,10): error TS2403: Subsequent variable declarations must have the same type. Variable 'a' must be of type 'any', but here has type 'C'. -tests/cases/conformance/statements/forStatements/forStatementsMultipleInvalidDecl.ts(35,10): error TS2403: Subsequent variable declarations must have the same type. Variable 'a' must be of type 'any', but here has type 'D'. -tests/cases/conformance/statements/forStatements/forStatementsMultipleInvalidDecl.ts(36,10): error TS2403: Subsequent variable declarations must have the same type. Variable 'a' must be of type 'any', but here has type 'typeof M'. -tests/cases/conformance/statements/forStatements/forStatementsMultipleInvalidDecl.ts(39,10): error TS2403: Subsequent variable declarations must have the same type. Variable 'b' must be of type 'I', but here has type 'C'. -tests/cases/conformance/statements/forStatements/forStatementsMultipleInvalidDecl.ts(40,10): error TS2403: Subsequent variable declarations must have the same type. Variable 'b' must be of type 'I', but here has type 'C2'. -tests/cases/conformance/statements/forStatements/forStatementsMultipleInvalidDecl.ts(43,10): error TS2403: Subsequent variable declarations must have the same type. Variable 'f' must be of type '(x: string) => number', but here has type '(x: number) => string'. -tests/cases/conformance/statements/forStatements/forStatementsMultipleInvalidDecl.ts(46,10): error TS2403: Subsequent variable declarations must have the same type. Variable 'arr' must be of type 'string[]', but here has type 'number[]'. -tests/cases/conformance/statements/forStatements/forStatementsMultipleInvalidDecl.ts(47,10): error TS2403: Subsequent variable declarations must have the same type. Variable 'arr' must be of type 'string[]', but here has type '(C | D)[]'. -tests/cases/conformance/statements/forStatements/forStatementsMultipleInvalidDecl.ts(50,10): error TS2403: Subsequent variable declarations must have the same type. Variable 'arr2' must be of type 'D[]', but here has type 'D[]'. -tests/cases/conformance/statements/forStatements/forStatementsMultipleInvalidDecl.ts(53,10): error TS2403: Subsequent variable declarations must have the same type. Variable 'm' must be of type 'typeof M', but here has type 'typeof A'. +tests/cases/conformance/statements/forStatements/forStatementsMultipleInvalidDecl.ts(33,10): error TS2403: Subsequent variable declarations must have the same type. Variable 'a' must be of type 'any', but here has type 'number'. +tests/cases/conformance/statements/forStatements/forStatementsMultipleInvalidDecl.ts(34,10): error TS2403: Subsequent variable declarations must have the same type. Variable 'a' must be of type 'any', but here has type 'string'. +tests/cases/conformance/statements/forStatements/forStatementsMultipleInvalidDecl.ts(35,10): error TS2403: Subsequent variable declarations must have the same type. Variable 'a' must be of type 'any', but here has type 'C'. +tests/cases/conformance/statements/forStatements/forStatementsMultipleInvalidDecl.ts(36,10): error TS2403: Subsequent variable declarations must have the same type. Variable 'a' must be of type 'any', but here has type 'D'. +tests/cases/conformance/statements/forStatements/forStatementsMultipleInvalidDecl.ts(37,10): error TS2403: Subsequent variable declarations must have the same type. Variable 'a' must be of type 'any', but here has type 'typeof M'. +tests/cases/conformance/statements/forStatements/forStatementsMultipleInvalidDecl.ts(40,10): error TS2403: Subsequent variable declarations must have the same type. Variable 'b' must be of type 'I', but here has type 'C'. +tests/cases/conformance/statements/forStatements/forStatementsMultipleInvalidDecl.ts(41,10): error TS2403: Subsequent variable declarations must have the same type. Variable 'b' must be of type 'I', but here has type 'C2'. +tests/cases/conformance/statements/forStatements/forStatementsMultipleInvalidDecl.ts(44,10): error TS2403: Subsequent variable declarations must have the same type. Variable 'f' must be of type '(x: string) => number', but here has type '(x: number) => string'. +tests/cases/conformance/statements/forStatements/forStatementsMultipleInvalidDecl.ts(47,10): error TS2403: Subsequent variable declarations must have the same type. Variable 'arr' must be of type 'string[]', but here has type 'number[]'. +tests/cases/conformance/statements/forStatements/forStatementsMultipleInvalidDecl.ts(48,10): error TS2403: Subsequent variable declarations must have the same type. Variable 'arr' must be of type 'string[]', but here has type '(C | D)[]'. +tests/cases/conformance/statements/forStatements/forStatementsMultipleInvalidDecl.ts(51,10): error TS2403: Subsequent variable declarations must have the same type. Variable 'arr2' must be of type 'D[]', but here has type 'D[]'. +tests/cases/conformance/statements/forStatements/forStatementsMultipleInvalidDecl.ts(54,10): error TS2403: Subsequent variable declarations must have the same type. Variable 'm' must be of type 'typeof M', but here has type 'typeof A'. -==== tests/cases/conformance/statements/forStatements/forStatementsMultipleInvalidDecl.ts (13 errors) ==== +==== tests/cases/conformance/statements/forStatements/forStatementsMultipleInvalidDecl.ts (12 errors) ==== + interface I { id: number; } @@ -46,8 +46,6 @@ tests/cases/conformance/statements/forStatements/forStatementsMultipleInvalidDec // all of these are errors for( var a: any;;){} for( var a = 1;;){} - ~~~ -!!! error TS7027: Unreachable code detected. ~ !!! error TS2403: Subsequent variable declarations must have the same type. Variable 'a' must be of type 'any', but here has type 'number'. for( var a = 'a string';;){} diff --git a/tests/baselines/reference/forStatementsMultipleInvalidDecl.js b/tests/baselines/reference/forStatementsMultipleInvalidDecl.js index 1dde9981880..20639c687cb 100644 --- a/tests/baselines/reference/forStatementsMultipleInvalidDecl.js +++ b/tests/baselines/reference/forStatementsMultipleInvalidDecl.js @@ -1,4 +1,5 @@ //// [forStatementsMultipleInvalidDecl.ts] + interface I { id: number; } diff --git a/tests/baselines/reference/forStatementsMultipleValidDecl.errors.txt b/tests/baselines/reference/forStatementsMultipleValidDecl.errors.txt deleted file mode 100644 index eb871af31c0..00000000000 --- a/tests/baselines/reference/forStatementsMultipleValidDecl.errors.txt +++ /dev/null @@ -1,39 +0,0 @@ -tests/cases/conformance/statements/forStatements/forStatementsMultipleValidDecl.ts(4,1): error TS7027: Unreachable code detected. - - -==== tests/cases/conformance/statements/forStatements/forStatementsMultipleValidDecl.ts (1 errors) ==== - // all expected to be valid - - for (var x: number; ;) { } - for (var x = 2; ;) { } - ~~~ -!!! error TS7027: Unreachable code detected. - - for (var x = undefined; ;) { } - // new declaration space, making redeclaring x as a string valid - function declSpace() { - for (var x = 'this is a string'; ;) { } - } - interface Point { x: number; y: number; } - - for (var p: Point; ;) { } - for (var p = { x: 1, y: 2 }; ;) { } - for (var p: Point = { x: 0, y: undefined }; ;) { } - for (var p = { x: 1, y: undefined }; ;) { } - for (var p: { x: number; y: number; } = { x: 1, y: 2 }; ;) { } - for (var p = <{ x: number; y: number; }>{ x: 0, y: undefined }; ;) { } - for (var p: typeof p; ;) { } - - for (var fn = function (s: string) { return 42; }; ;) { } - for (var fn = (s: string) => 3; ;) { } - for (var fn: (s: string) => number; ;) { } - for (var fn: { (s: string): number }; ;) { } - for (var fn = <(s: string) => number> null; ;) { } - for (var fn: typeof fn; ;) { } - - for (var a: string[]; ;) { } - for (var a = ['a', 'b']; ;) { } - for (var a = []; ;) { } - for (var a: string[] = []; ;) { } - for (var a = new Array(); ;) { } - for (var a: typeof a; ;) { } \ No newline at end of file diff --git a/tests/baselines/reference/forStatementsMultipleValidDecl.js b/tests/baselines/reference/forStatementsMultipleValidDecl.js index e95e37d63ac..6913894a15f 100644 --- a/tests/baselines/reference/forStatementsMultipleValidDecl.js +++ b/tests/baselines/reference/forStatementsMultipleValidDecl.js @@ -1,4 +1,5 @@ //// [forStatementsMultipleValidDecl.ts] + // all expected to be valid for (var x: number; ;) { } diff --git a/tests/baselines/reference/forStatementsMultipleValidDecl.symbols b/tests/baselines/reference/forStatementsMultipleValidDecl.symbols new file mode 100644 index 00000000000..d2d8ac01003 --- /dev/null +++ b/tests/baselines/reference/forStatementsMultipleValidDecl.symbols @@ -0,0 +1,111 @@ +=== tests/cases/conformance/statements/forStatements/forStatementsMultipleValidDecl.ts === + +// all expected to be valid + +for (var x: number; ;) { } +>x : Symbol(x, Decl(forStatementsMultipleValidDecl.ts, 3, 8), Decl(forStatementsMultipleValidDecl.ts, 4, 8), Decl(forStatementsMultipleValidDecl.ts, 6, 8)) + +for (var x = 2; ;) { } +>x : Symbol(x, Decl(forStatementsMultipleValidDecl.ts, 3, 8), Decl(forStatementsMultipleValidDecl.ts, 4, 8), Decl(forStatementsMultipleValidDecl.ts, 6, 8)) + +for (var x = undefined; ;) { } +>x : Symbol(x, Decl(forStatementsMultipleValidDecl.ts, 3, 8), Decl(forStatementsMultipleValidDecl.ts, 4, 8), Decl(forStatementsMultipleValidDecl.ts, 6, 8)) +>undefined : Symbol(undefined) + +// new declaration space, making redeclaring x as a string valid +function declSpace() { +>declSpace : Symbol(declSpace, Decl(forStatementsMultipleValidDecl.ts, 6, 38)) + + for (var x = 'this is a string'; ;) { } +>x : Symbol(x, Decl(forStatementsMultipleValidDecl.ts, 9, 12)) +} +interface Point { x: number; y: number; } +>Point : Symbol(Point, Decl(forStatementsMultipleValidDecl.ts, 10, 1)) +>x : Symbol(x, Decl(forStatementsMultipleValidDecl.ts, 11, 17)) +>y : Symbol(y, Decl(forStatementsMultipleValidDecl.ts, 11, 28)) + +for (var p: Point; ;) { } +>p : Symbol(p, Decl(forStatementsMultipleValidDecl.ts, 13, 8), Decl(forStatementsMultipleValidDecl.ts, 14, 8), Decl(forStatementsMultipleValidDecl.ts, 15, 8), Decl(forStatementsMultipleValidDecl.ts, 16, 8), Decl(forStatementsMultipleValidDecl.ts, 17, 8), Decl(forStatementsMultipleValidDecl.ts, 18, 8), Decl(forStatementsMultipleValidDecl.ts, 19, 8)) +>Point : Symbol(Point, Decl(forStatementsMultipleValidDecl.ts, 10, 1)) + +for (var p = { x: 1, y: 2 }; ;) { } +>p : Symbol(p, Decl(forStatementsMultipleValidDecl.ts, 13, 8), Decl(forStatementsMultipleValidDecl.ts, 14, 8), Decl(forStatementsMultipleValidDecl.ts, 15, 8), Decl(forStatementsMultipleValidDecl.ts, 16, 8), Decl(forStatementsMultipleValidDecl.ts, 17, 8), Decl(forStatementsMultipleValidDecl.ts, 18, 8), Decl(forStatementsMultipleValidDecl.ts, 19, 8)) +>x : Symbol(x, Decl(forStatementsMultipleValidDecl.ts, 14, 14)) +>y : Symbol(y, Decl(forStatementsMultipleValidDecl.ts, 14, 20)) + +for (var p: Point = { x: 0, y: undefined }; ;) { } +>p : Symbol(p, Decl(forStatementsMultipleValidDecl.ts, 13, 8), Decl(forStatementsMultipleValidDecl.ts, 14, 8), Decl(forStatementsMultipleValidDecl.ts, 15, 8), Decl(forStatementsMultipleValidDecl.ts, 16, 8), Decl(forStatementsMultipleValidDecl.ts, 17, 8), Decl(forStatementsMultipleValidDecl.ts, 18, 8), Decl(forStatementsMultipleValidDecl.ts, 19, 8)) +>Point : Symbol(Point, Decl(forStatementsMultipleValidDecl.ts, 10, 1)) +>x : Symbol(x, Decl(forStatementsMultipleValidDecl.ts, 15, 21)) +>y : Symbol(y, Decl(forStatementsMultipleValidDecl.ts, 15, 27)) +>undefined : Symbol(undefined) + +for (var p = { x: 1, y: undefined }; ;) { } +>p : Symbol(p, Decl(forStatementsMultipleValidDecl.ts, 13, 8), Decl(forStatementsMultipleValidDecl.ts, 14, 8), Decl(forStatementsMultipleValidDecl.ts, 15, 8), Decl(forStatementsMultipleValidDecl.ts, 16, 8), Decl(forStatementsMultipleValidDecl.ts, 17, 8), Decl(forStatementsMultipleValidDecl.ts, 18, 8), Decl(forStatementsMultipleValidDecl.ts, 19, 8)) +>x : Symbol(x, Decl(forStatementsMultipleValidDecl.ts, 16, 14)) +>y : Symbol(y, Decl(forStatementsMultipleValidDecl.ts, 16, 20)) +>undefined : Symbol(undefined) + +for (var p: { x: number; y: number; } = { x: 1, y: 2 }; ;) { } +>p : Symbol(p, Decl(forStatementsMultipleValidDecl.ts, 13, 8), Decl(forStatementsMultipleValidDecl.ts, 14, 8), Decl(forStatementsMultipleValidDecl.ts, 15, 8), Decl(forStatementsMultipleValidDecl.ts, 16, 8), Decl(forStatementsMultipleValidDecl.ts, 17, 8), Decl(forStatementsMultipleValidDecl.ts, 18, 8), Decl(forStatementsMultipleValidDecl.ts, 19, 8)) +>x : Symbol(x, Decl(forStatementsMultipleValidDecl.ts, 17, 13)) +>y : Symbol(y, Decl(forStatementsMultipleValidDecl.ts, 17, 24)) +>x : Symbol(x, Decl(forStatementsMultipleValidDecl.ts, 17, 41)) +>y : Symbol(y, Decl(forStatementsMultipleValidDecl.ts, 17, 47)) + +for (var p = <{ x: number; y: number; }>{ x: 0, y: undefined }; ;) { } +>p : Symbol(p, Decl(forStatementsMultipleValidDecl.ts, 13, 8), Decl(forStatementsMultipleValidDecl.ts, 14, 8), Decl(forStatementsMultipleValidDecl.ts, 15, 8), Decl(forStatementsMultipleValidDecl.ts, 16, 8), Decl(forStatementsMultipleValidDecl.ts, 17, 8), Decl(forStatementsMultipleValidDecl.ts, 18, 8), Decl(forStatementsMultipleValidDecl.ts, 19, 8)) +>x : Symbol(x, Decl(forStatementsMultipleValidDecl.ts, 18, 15)) +>y : Symbol(y, Decl(forStatementsMultipleValidDecl.ts, 18, 26)) +>x : Symbol(x, Decl(forStatementsMultipleValidDecl.ts, 18, 41)) +>y : Symbol(y, Decl(forStatementsMultipleValidDecl.ts, 18, 47)) +>undefined : Symbol(undefined) + +for (var p: typeof p; ;) { } +>p : Symbol(p, Decl(forStatementsMultipleValidDecl.ts, 13, 8), Decl(forStatementsMultipleValidDecl.ts, 14, 8), Decl(forStatementsMultipleValidDecl.ts, 15, 8), Decl(forStatementsMultipleValidDecl.ts, 16, 8), Decl(forStatementsMultipleValidDecl.ts, 17, 8), Decl(forStatementsMultipleValidDecl.ts, 18, 8), Decl(forStatementsMultipleValidDecl.ts, 19, 8)) +>p : Symbol(p, Decl(forStatementsMultipleValidDecl.ts, 13, 8), Decl(forStatementsMultipleValidDecl.ts, 14, 8), Decl(forStatementsMultipleValidDecl.ts, 15, 8), Decl(forStatementsMultipleValidDecl.ts, 16, 8), Decl(forStatementsMultipleValidDecl.ts, 17, 8), Decl(forStatementsMultipleValidDecl.ts, 18, 8), Decl(forStatementsMultipleValidDecl.ts, 19, 8)) + +for (var fn = function (s: string) { return 42; }; ;) { } +>fn : Symbol(fn, Decl(forStatementsMultipleValidDecl.ts, 21, 8), Decl(forStatementsMultipleValidDecl.ts, 22, 8), Decl(forStatementsMultipleValidDecl.ts, 23, 8), Decl(forStatementsMultipleValidDecl.ts, 24, 8), Decl(forStatementsMultipleValidDecl.ts, 25, 8), Decl(forStatementsMultipleValidDecl.ts, 26, 8)) +>s : Symbol(s, Decl(forStatementsMultipleValidDecl.ts, 21, 24)) + +for (var fn = (s: string) => 3; ;) { } +>fn : Symbol(fn, Decl(forStatementsMultipleValidDecl.ts, 21, 8), Decl(forStatementsMultipleValidDecl.ts, 22, 8), Decl(forStatementsMultipleValidDecl.ts, 23, 8), Decl(forStatementsMultipleValidDecl.ts, 24, 8), Decl(forStatementsMultipleValidDecl.ts, 25, 8), Decl(forStatementsMultipleValidDecl.ts, 26, 8)) +>s : Symbol(s, Decl(forStatementsMultipleValidDecl.ts, 22, 15)) + +for (var fn: (s: string) => number; ;) { } +>fn : Symbol(fn, Decl(forStatementsMultipleValidDecl.ts, 21, 8), Decl(forStatementsMultipleValidDecl.ts, 22, 8), Decl(forStatementsMultipleValidDecl.ts, 23, 8), Decl(forStatementsMultipleValidDecl.ts, 24, 8), Decl(forStatementsMultipleValidDecl.ts, 25, 8), Decl(forStatementsMultipleValidDecl.ts, 26, 8)) +>s : Symbol(s, Decl(forStatementsMultipleValidDecl.ts, 23, 14)) + +for (var fn: { (s: string): number }; ;) { } +>fn : Symbol(fn, Decl(forStatementsMultipleValidDecl.ts, 21, 8), Decl(forStatementsMultipleValidDecl.ts, 22, 8), Decl(forStatementsMultipleValidDecl.ts, 23, 8), Decl(forStatementsMultipleValidDecl.ts, 24, 8), Decl(forStatementsMultipleValidDecl.ts, 25, 8), Decl(forStatementsMultipleValidDecl.ts, 26, 8)) +>s : Symbol(s, Decl(forStatementsMultipleValidDecl.ts, 24, 16)) + +for (var fn = <(s: string) => number> null; ;) { } +>fn : Symbol(fn, Decl(forStatementsMultipleValidDecl.ts, 21, 8), Decl(forStatementsMultipleValidDecl.ts, 22, 8), Decl(forStatementsMultipleValidDecl.ts, 23, 8), Decl(forStatementsMultipleValidDecl.ts, 24, 8), Decl(forStatementsMultipleValidDecl.ts, 25, 8), Decl(forStatementsMultipleValidDecl.ts, 26, 8)) +>s : Symbol(s, Decl(forStatementsMultipleValidDecl.ts, 25, 16)) + +for (var fn: typeof fn; ;) { } +>fn : Symbol(fn, Decl(forStatementsMultipleValidDecl.ts, 21, 8), Decl(forStatementsMultipleValidDecl.ts, 22, 8), Decl(forStatementsMultipleValidDecl.ts, 23, 8), Decl(forStatementsMultipleValidDecl.ts, 24, 8), Decl(forStatementsMultipleValidDecl.ts, 25, 8), Decl(forStatementsMultipleValidDecl.ts, 26, 8)) +>fn : Symbol(fn, Decl(forStatementsMultipleValidDecl.ts, 21, 8), Decl(forStatementsMultipleValidDecl.ts, 22, 8), Decl(forStatementsMultipleValidDecl.ts, 23, 8), Decl(forStatementsMultipleValidDecl.ts, 24, 8), Decl(forStatementsMultipleValidDecl.ts, 25, 8), Decl(forStatementsMultipleValidDecl.ts, 26, 8)) + +for (var a: string[]; ;) { } +>a : Symbol(a, Decl(forStatementsMultipleValidDecl.ts, 28, 8), Decl(forStatementsMultipleValidDecl.ts, 29, 8), Decl(forStatementsMultipleValidDecl.ts, 30, 8), Decl(forStatementsMultipleValidDecl.ts, 31, 8), Decl(forStatementsMultipleValidDecl.ts, 32, 8), Decl(forStatementsMultipleValidDecl.ts, 33, 8)) + +for (var a = ['a', 'b']; ;) { } +>a : Symbol(a, Decl(forStatementsMultipleValidDecl.ts, 28, 8), Decl(forStatementsMultipleValidDecl.ts, 29, 8), Decl(forStatementsMultipleValidDecl.ts, 30, 8), Decl(forStatementsMultipleValidDecl.ts, 31, 8), Decl(forStatementsMultipleValidDecl.ts, 32, 8), Decl(forStatementsMultipleValidDecl.ts, 33, 8)) + +for (var a = []; ;) { } +>a : Symbol(a, Decl(forStatementsMultipleValidDecl.ts, 28, 8), Decl(forStatementsMultipleValidDecl.ts, 29, 8), Decl(forStatementsMultipleValidDecl.ts, 30, 8), Decl(forStatementsMultipleValidDecl.ts, 31, 8), Decl(forStatementsMultipleValidDecl.ts, 32, 8), Decl(forStatementsMultipleValidDecl.ts, 33, 8)) + +for (var a: string[] = []; ;) { } +>a : Symbol(a, Decl(forStatementsMultipleValidDecl.ts, 28, 8), Decl(forStatementsMultipleValidDecl.ts, 29, 8), Decl(forStatementsMultipleValidDecl.ts, 30, 8), Decl(forStatementsMultipleValidDecl.ts, 31, 8), Decl(forStatementsMultipleValidDecl.ts, 32, 8), Decl(forStatementsMultipleValidDecl.ts, 33, 8)) + +for (var a = new Array(); ;) { } +>a : Symbol(a, Decl(forStatementsMultipleValidDecl.ts, 28, 8), Decl(forStatementsMultipleValidDecl.ts, 29, 8), Decl(forStatementsMultipleValidDecl.ts, 30, 8), Decl(forStatementsMultipleValidDecl.ts, 31, 8), Decl(forStatementsMultipleValidDecl.ts, 32, 8), Decl(forStatementsMultipleValidDecl.ts, 33, 8)) +>Array : Symbol(Array, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) + +for (var a: typeof a; ;) { } +>a : Symbol(a, Decl(forStatementsMultipleValidDecl.ts, 28, 8), Decl(forStatementsMultipleValidDecl.ts, 29, 8), Decl(forStatementsMultipleValidDecl.ts, 30, 8), Decl(forStatementsMultipleValidDecl.ts, 31, 8), Decl(forStatementsMultipleValidDecl.ts, 32, 8), Decl(forStatementsMultipleValidDecl.ts, 33, 8)) +>a : Symbol(a, Decl(forStatementsMultipleValidDecl.ts, 28, 8), Decl(forStatementsMultipleValidDecl.ts, 29, 8), Decl(forStatementsMultipleValidDecl.ts, 30, 8), Decl(forStatementsMultipleValidDecl.ts, 31, 8), Decl(forStatementsMultipleValidDecl.ts, 32, 8), Decl(forStatementsMultipleValidDecl.ts, 33, 8)) + diff --git a/tests/baselines/reference/forStatementsMultipleValidDecl.types b/tests/baselines/reference/forStatementsMultipleValidDecl.types new file mode 100644 index 00000000000..acb26f17312 --- /dev/null +++ b/tests/baselines/reference/forStatementsMultipleValidDecl.types @@ -0,0 +1,141 @@ +=== tests/cases/conformance/statements/forStatements/forStatementsMultipleValidDecl.ts === + +// all expected to be valid + +for (var x: number; ;) { } +>x : number + +for (var x = 2; ;) { } +>x : number +>2 : number + +for (var x = undefined; ;) { } +>x : number +>undefined : number +>undefined : undefined + +// new declaration space, making redeclaring x as a string valid +function declSpace() { +>declSpace : () => void + + for (var x = 'this is a string'; ;) { } +>x : string +>'this is a string' : string +} +interface Point { x: number; y: number; } +>Point : Point +>x : number +>y : number + +for (var p: Point; ;) { } +>p : Point +>Point : Point + +for (var p = { x: 1, y: 2 }; ;) { } +>p : Point +>{ x: 1, y: 2 } : { x: number; y: number; } +>x : number +>1 : number +>y : number +>2 : number + +for (var p: Point = { x: 0, y: undefined }; ;) { } +>p : Point +>Point : Point +>{ x: 0, y: undefined } : { x: number; y: undefined; } +>x : number +>0 : number +>y : undefined +>undefined : undefined + +for (var p = { x: 1, y: undefined }; ;) { } +>p : Point +>{ x: 1, y: undefined } : { x: number; y: number; } +>x : number +>1 : number +>y : number +>undefined : number +>undefined : undefined + +for (var p: { x: number; y: number; } = { x: 1, y: 2 }; ;) { } +>p : Point +>x : number +>y : number +>{ x: 1, y: 2 } : { x: number; y: number; } +>x : number +>1 : number +>y : number +>2 : number + +for (var p = <{ x: number; y: number; }>{ x: 0, y: undefined }; ;) { } +>p : Point +><{ x: number; y: number; }>{ x: 0, y: undefined } : { x: number; y: number; } +>x : number +>y : number +>{ x: 0, y: undefined } : { x: number; y: undefined; } +>x : number +>0 : number +>y : undefined +>undefined : undefined + +for (var p: typeof p; ;) { } +>p : Point +>p : Point + +for (var fn = function (s: string) { return 42; }; ;) { } +>fn : (s: string) => number +>function (s: string) { return 42; } : (s: string) => number +>s : string +>42 : number + +for (var fn = (s: string) => 3; ;) { } +>fn : (s: string) => number +>(s: string) => 3 : (s: string) => number +>s : string +>3 : number + +for (var fn: (s: string) => number; ;) { } +>fn : (s: string) => number +>s : string + +for (var fn: { (s: string): number }; ;) { } +>fn : (s: string) => number +>s : string + +for (var fn = <(s: string) => number> null; ;) { } +>fn : (s: string) => number +><(s: string) => number> null : (s: string) => number +>s : string +>null : null + +for (var fn: typeof fn; ;) { } +>fn : (s: string) => number +>fn : (s: string) => number + +for (var a: string[]; ;) { } +>a : string[] + +for (var a = ['a', 'b']; ;) { } +>a : string[] +>['a', 'b'] : string[] +>'a' : string +>'b' : string + +for (var a = []; ;) { } +>a : string[] +>[] : string[] +>[] : undefined[] + +for (var a: string[] = []; ;) { } +>a : string[] +>[] : undefined[] + +for (var a = new Array(); ;) { } +>a : string[] +>new Array() : string[] +>Array : ArrayConstructor + +for (var a: typeof a; ;) { } +>a : string[] +>a : string[] + diff --git a/tests/baselines/reference/functionImplementationErrors.errors.txt b/tests/baselines/reference/functionImplementationErrors.errors.txt index bde939a1578..86ecb6a6057 100644 --- a/tests/baselines/reference/functionImplementationErrors.errors.txt +++ b/tests/baselines/reference/functionImplementationErrors.errors.txt @@ -1,46 +1,32 @@ -tests/cases/conformance/functions/functionImplementationErrors.ts(2,10): error TS2354: No best common type exists among return expressions. -tests/cases/conformance/functions/functionImplementationErrors.ts(4,5): error TS7027: Unreachable code detected. -tests/cases/conformance/functions/functionImplementationErrors.ts(6,19): error TS2354: No best common type exists among return expressions. -tests/cases/conformance/functions/functionImplementationErrors.ts(8,5): error TS7027: Unreachable code detected. -tests/cases/conformance/functions/functionImplementationErrors.ts(10,10): error TS2354: No best common type exists among return expressions. -tests/cases/conformance/functions/functionImplementationErrors.ts(12,5): error TS7027: Unreachable code detected. -tests/cases/conformance/functions/functionImplementationErrors.ts(16,10): error TS2354: No best common type exists among return expressions. -tests/cases/conformance/functions/functionImplementationErrors.ts(20,9): error TS7027: Unreachable code detected. -tests/cases/conformance/functions/functionImplementationErrors.ts(25,16): error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. -tests/cases/conformance/functions/functionImplementationErrors.ts(30,17): error TS2373: Initializer of parameter 'n' cannot reference identifier 'm' declared after it. -tests/cases/conformance/functions/functionImplementationErrors.ts(35,17): error TS2373: Initializer of parameter 'n' cannot reference identifier 'm' declared after it. -tests/cases/conformance/functions/functionImplementationErrors.ts(42,5): error TS7027: Unreachable code detected. -tests/cases/conformance/functions/functionImplementationErrors.ts(49,10): error TS2354: No best common type exists among return expressions. -tests/cases/conformance/functions/functionImplementationErrors.ts(51,5): error TS7027: Unreachable code detected. -tests/cases/conformance/functions/functionImplementationErrors.ts(53,10): error TS2354: No best common type exists among return expressions. -tests/cases/conformance/functions/functionImplementationErrors.ts(55,5): error TS7027: Unreachable code detected. -tests/cases/conformance/functions/functionImplementationErrors.ts(57,11): error TS2354: No best common type exists among return expressions. -tests/cases/conformance/functions/functionImplementationErrors.ts(59,5): error TS7027: Unreachable code detected. -tests/cases/conformance/functions/functionImplementationErrors.ts(61,10): error TS2354: No best common type exists among return expressions. -tests/cases/conformance/functions/functionImplementationErrors.ts(63,5): error TS7027: Unreachable code detected. -tests/cases/conformance/functions/functionImplementationErrors.ts(65,11): error TS2354: No best common type exists among return expressions. -tests/cases/conformance/functions/functionImplementationErrors.ts(67,5): error TS7027: Unreachable code detected. -tests/cases/conformance/functions/functionImplementationErrors.ts(69,11): error TS2354: No best common type exists among return expressions. -tests/cases/conformance/functions/functionImplementationErrors.ts(71,5): error TS7027: Unreachable code detected. +tests/cases/conformance/functions/functionImplementationErrors.ts(3,10): error TS2354: No best common type exists among return expressions. +tests/cases/conformance/functions/functionImplementationErrors.ts(7,19): error TS2354: No best common type exists among return expressions. +tests/cases/conformance/functions/functionImplementationErrors.ts(11,10): error TS2354: No best common type exists among return expressions. +tests/cases/conformance/functions/functionImplementationErrors.ts(17,10): error TS2354: No best common type exists among return expressions. +tests/cases/conformance/functions/functionImplementationErrors.ts(26,16): error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. +tests/cases/conformance/functions/functionImplementationErrors.ts(31,17): error TS2373: Initializer of parameter 'n' cannot reference identifier 'm' declared after it. +tests/cases/conformance/functions/functionImplementationErrors.ts(36,17): error TS2373: Initializer of parameter 'n' cannot reference identifier 'm' declared after it. +tests/cases/conformance/functions/functionImplementationErrors.ts(50,10): error TS2354: No best common type exists among return expressions. +tests/cases/conformance/functions/functionImplementationErrors.ts(54,10): error TS2354: No best common type exists among return expressions. +tests/cases/conformance/functions/functionImplementationErrors.ts(58,11): error TS2354: No best common type exists among return expressions. +tests/cases/conformance/functions/functionImplementationErrors.ts(62,10): error TS2354: No best common type exists among return expressions. +tests/cases/conformance/functions/functionImplementationErrors.ts(66,11): error TS2354: No best common type exists among return expressions. +tests/cases/conformance/functions/functionImplementationErrors.ts(70,11): error TS2354: No best common type exists among return expressions. -==== tests/cases/conformance/functions/functionImplementationErrors.ts (24 errors) ==== +==== tests/cases/conformance/functions/functionImplementationErrors.ts (13 errors) ==== + // FunctionExpression with no return type annotation with multiple return statements with unrelated types var f1 = function () { ~~~~~~~~ !!! error TS2354: No best common type exists among return expressions. return ''; return 3; - ~~~~~~ -!!! error TS7027: Unreachable code detected. }; var f2 = function x() { ~ !!! error TS2354: No best common type exists among return expressions. return ''; return 3; - ~~~~~~ -!!! error TS7027: Unreachable code detected. }; var f3 = () => { ~~~~~~~ @@ -48,8 +34,6 @@ tests/cases/conformance/functions/functionImplementationErrors.ts(71,5): error T ~~~~~~~~~~~~~~ return 3; ~~~~~~~~~~~~~ - ~~~~~~ -!!! error TS7027: Unreachable code detected. }; ~ !!! error TS2354: No best common type exists among return expressions. @@ -62,8 +46,6 @@ tests/cases/conformance/functions/functionImplementationErrors.ts(71,5): error T return ['']; } else { return [1]; - ~~~~~~ -!!! error TS7027: Unreachable code detected. } } @@ -92,8 +74,6 @@ tests/cases/conformance/functions/functionImplementationErrors.ts(71,5): error T undefined === function (): number { throw undefined; var x = 4; - ~~~ -!!! error TS7027: Unreachable code detected. }; class Base { private x; } @@ -105,16 +85,12 @@ tests/cases/conformance/functions/functionImplementationErrors.ts(71,5): error T !!! error TS2354: No best common type exists among return expressions. return new Derived1(); return new Derived2(); - ~~~~~~ -!!! error TS7027: Unreachable code detected. } var f9 = function () { ~~~~~~~~ !!! error TS2354: No best common type exists among return expressions. return new Derived1(); return new Derived2(); - ~~~~~~ -!!! error TS7027: Unreachable code detected. }; var f10 = () => { ~~~~~~~ @@ -122,8 +98,6 @@ tests/cases/conformance/functions/functionImplementationErrors.ts(71,5): error T ~~~~~~~~~~~~~~~~~~~~~~~~~~ return new Derived2(); ~~~~~~~~~~~~~~~~~~~~~~~~~~ - ~~~~~~ -!!! error TS7027: Unreachable code detected. }; ~ !!! error TS2354: No best common type exists among return expressions. @@ -132,16 +106,12 @@ tests/cases/conformance/functions/functionImplementationErrors.ts(71,5): error T !!! error TS2354: No best common type exists among return expressions. return new Base(); return new AnotherClass(); - ~~~~~~ -!!! error TS7027: Unreachable code detected. } var f12 = function () { ~~~~~~~~ !!! error TS2354: No best common type exists among return expressions. return new Base(); return new AnotherClass(); - ~~~~~~ -!!! error TS7027: Unreachable code detected. }; var f13 = () => { ~~~~~~~ @@ -149,8 +119,6 @@ tests/cases/conformance/functions/functionImplementationErrors.ts(71,5): error T ~~~~~~~~~~~~~~~~~~~~~~ return new AnotherClass(); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - ~~~~~~ -!!! error TS7027: Unreachable code detected. }; ~ !!! error TS2354: No best common type exists among return expressions. diff --git a/tests/baselines/reference/functionImplementationErrors.js b/tests/baselines/reference/functionImplementationErrors.js index 42be5f21458..4436f1bc94f 100644 --- a/tests/baselines/reference/functionImplementationErrors.js +++ b/tests/baselines/reference/functionImplementationErrors.js @@ -1,4 +1,5 @@ //// [functionImplementationErrors.ts] + // FunctionExpression with no return type annotation with multiple return statements with unrelated types var f1 = function () { return ''; diff --git a/tests/baselines/reference/functionImplementations.errors.txt b/tests/baselines/reference/functionImplementations.errors.txt deleted file mode 100644 index f3e4d6404c6..00000000000 --- a/tests/baselines/reference/functionImplementations.errors.txt +++ /dev/null @@ -1,183 +0,0 @@ -tests/cases/conformance/functions/functionImplementations.ts(69,5): error TS7027: Unreachable code detected. -tests/cases/conformance/functions/functionImplementations.ts(81,24): error TS7027: Unreachable code detected. -tests/cases/conformance/functions/functionImplementations.ts(86,24): error TS7027: Unreachable code detected. -tests/cases/conformance/functions/functionImplementations.ts(137,5): error TS7027: Unreachable code detected. -tests/cases/conformance/functions/functionImplementations.ts(141,5): error TS7027: Unreachable code detected. -tests/cases/conformance/functions/functionImplementations.ts(146,5): error TS7027: Unreachable code detected. -tests/cases/conformance/functions/functionImplementations.ts(150,5): error TS7027: Unreachable code detected. -tests/cases/conformance/functions/functionImplementations.ts(154,5): error TS7027: Unreachable code detected. - - -==== tests/cases/conformance/functions/functionImplementations.ts (8 errors) ==== - // FunctionExpression with no return type annotation and no return statement returns void - var v: void = function () { } (); - - // FunctionExpression f with no return type annotation and directly references f in its body returns any - var a: any = function f() { - return f; - }; - var a: any = function f() { - return f(); - }; - - // FunctionExpression f with no return type annotation and indirectly references f in its body returns any - var a: any = function f() { - var x = f; - return x; - }; - - // Two mutually recursive function implementations with no return type annotations - function rec1() { - return rec2(); - } - function rec2() { - return rec1(); - } - var a = rec1(); - var a = rec2(); - - // Two mutually recursive function implementations with return type annotation in one - function rec3(): number { - return rec4(); - } - function rec4() { - return rec3(); - } - var n: number; - var n = rec3(); - var n = rec4(); - - // FunctionExpression with no return type annotation and returns a number - var n = function () { - return 3; - } (); - - // FunctionExpression with no return type annotation and returns null - var nu = null; - var nu = function () { - return null; - } (); - - // FunctionExpression with no return type annotation and returns undefined - var un = undefined; - var un = function () { - return undefined; - } (); - - // FunctionExpression with no return type annotation and returns a type parameter type - var n = function (x: T) { - return x; - } (4); - - // FunctionExpression with no return type annotation and returns a constrained type parameter type - var n = function (x: T) { - return x; - } (4); - - // FunctionExpression with no return type annotation with multiple return statements with identical types - var n = function () { - return 3; - return 5; - ~~~~~~ -!!! error TS7027: Unreachable code detected. - }(); - - // Otherwise, the inferred return type is the first of the types of the return statement expressions - // in the function body that is a supertype of each of the others, - // ignoring return statements with no expressions. - // A compile - time error occurs if no return statement expression has a type that is a supertype of each of the others. - // FunctionExpression with no return type annotation with multiple return statements with subtype relation between returns - class Base { private m; } - class Derived extends Base { private q; } - var b: Base; - var b = function () { - return new Base(); return new Derived(); - ~~~~~~ -!!! error TS7027: Unreachable code detected. - } (); - - // FunctionExpression with no return type annotation with multiple return statements with one a recursive call - var a = function f() { - return new Base(); return new Derived(); return f(); // ? - ~~~~~~ -!!! error TS7027: Unreachable code detected. - } (); - - // FunctionExpression with non -void return type annotation with a single throw statement - undefined === function (): number { - throw undefined; - }; - - // Type of 'this' in function implementation is 'any' - function thisFunc() { - var x = this; - var x: any; - } - - // Function signature with optional parameter, no type annotation and initializer has initializer's type - function opt1(n = 4) { - var m = n; - var m: number; - } - - // Function signature with optional parameter, no type annotation and initializer has initializer's widened type - function opt2(n = { x: null, y: undefined }) { - var m = n; - var m: { x: any; y: any }; - } - - // Function signature with initializer referencing other parameter to the left - function opt3(n: number, m = n) { - var y = m; - var y: number; - } - - // Function signature with optional parameter has correct codegen - // (tested above) - - // FunctionExpression with non -void return type annotation return with no expression - function f6(): number { - return; - } - - class Derived2 extends Base { private r: string; } - class AnotherClass { private x } - // if f is a contextually typed function expression, the inferred return type is the union type - // of the types of the return statement expressions in the function body, - // ignoring return statements with no expressions. - var f7: (x: number) => string | number = x => { // should be (x: number) => number | string - if (x < 0) { return x; } - return x.toString(); - } - var f8: (x: number) => any = x => { // should be (x: number) => Base - return new Base(); - return new Derived2(); - ~~~~~~ -!!! error TS7027: Unreachable code detected. - } - var f9: (x: number) => any = x => { // should be (x: number) => Base - return new Base(); - return new Derived(); - ~~~~~~ -!!! error TS7027: Unreachable code detected. - return new Derived2(); - } - var f10: (x: number) => any = x => { // should be (x: number) => Derived | Derived1 - return new Derived(); - return new Derived2(); - ~~~~~~ -!!! error TS7027: Unreachable code detected. - } - var f11: (x: number) => any = x => { // should be (x: number) => Base | AnotherClass - return new Base(); - return new AnotherClass(); - ~~~~~~ -!!! error TS7027: Unreachable code detected. - } - var f12: (x: number) => any = x => { // should be (x: number) => Base | AnotherClass - return new Base(); - return; // should be ignored - ~~~~~~ -!!! error TS7027: Unreachable code detected. - return new AnotherClass(); - } \ No newline at end of file diff --git a/tests/baselines/reference/functionImplementations.js b/tests/baselines/reference/functionImplementations.js index 3fc040650e4..512da960b78 100644 --- a/tests/baselines/reference/functionImplementations.js +++ b/tests/baselines/reference/functionImplementations.js @@ -1,4 +1,5 @@ //// [functionImplementations.ts] + // FunctionExpression with no return type annotation and no return statement returns void var v: void = function () { } (); diff --git a/tests/baselines/reference/functionImplementations.symbols b/tests/baselines/reference/functionImplementations.symbols new file mode 100644 index 00000000000..07945b5f765 --- /dev/null +++ b/tests/baselines/reference/functionImplementations.symbols @@ -0,0 +1,345 @@ +=== tests/cases/conformance/functions/functionImplementations.ts === + +// FunctionExpression with no return type annotation and no return statement returns void +var v: void = function () { } (); +>v : Symbol(v, Decl(functionImplementations.ts, 2, 3)) + +// FunctionExpression f with no return type annotation and directly references f in its body returns any +var a: any = function f() { +>a : Symbol(a, Decl(functionImplementations.ts, 5, 3), Decl(functionImplementations.ts, 8, 3), Decl(functionImplementations.ts, 13, 3), Decl(functionImplementations.ts, 25, 3), Decl(functionImplementations.ts, 26, 3), Decl(functionImplementations.ts, 85, 3)) +>f : Symbol(f, Decl(functionImplementations.ts, 5, 12)) + + return f; +>f : Symbol(f, Decl(functionImplementations.ts, 5, 12)) + +}; +var a: any = function f() { +>a : Symbol(a, Decl(functionImplementations.ts, 5, 3), Decl(functionImplementations.ts, 8, 3), Decl(functionImplementations.ts, 13, 3), Decl(functionImplementations.ts, 25, 3), Decl(functionImplementations.ts, 26, 3), Decl(functionImplementations.ts, 85, 3)) +>f : Symbol(f, Decl(functionImplementations.ts, 8, 12)) + + return f(); +>f : Symbol(f, Decl(functionImplementations.ts, 8, 12)) + +}; + +// FunctionExpression f with no return type annotation and indirectly references f in its body returns any +var a: any = function f() { +>a : Symbol(a, Decl(functionImplementations.ts, 5, 3), Decl(functionImplementations.ts, 8, 3), Decl(functionImplementations.ts, 13, 3), Decl(functionImplementations.ts, 25, 3), Decl(functionImplementations.ts, 26, 3), Decl(functionImplementations.ts, 85, 3)) +>f : Symbol(f, Decl(functionImplementations.ts, 13, 12)) + + var x = f; +>x : Symbol(x, Decl(functionImplementations.ts, 14, 7)) +>f : Symbol(f, Decl(functionImplementations.ts, 13, 12)) + + return x; +>x : Symbol(x, Decl(functionImplementations.ts, 14, 7)) + +}; + +// Two mutually recursive function implementations with no return type annotations +function rec1() { +>rec1 : Symbol(rec1, Decl(functionImplementations.ts, 16, 2)) + + return rec2(); +>rec2 : Symbol(rec2, Decl(functionImplementations.ts, 21, 1)) +} +function rec2() { +>rec2 : Symbol(rec2, Decl(functionImplementations.ts, 21, 1)) + + return rec1(); +>rec1 : Symbol(rec1, Decl(functionImplementations.ts, 16, 2)) +} +var a = rec1(); +>a : Symbol(a, Decl(functionImplementations.ts, 5, 3), Decl(functionImplementations.ts, 8, 3), Decl(functionImplementations.ts, 13, 3), Decl(functionImplementations.ts, 25, 3), Decl(functionImplementations.ts, 26, 3), Decl(functionImplementations.ts, 85, 3)) +>rec1 : Symbol(rec1, Decl(functionImplementations.ts, 16, 2)) + +var a = rec2(); +>a : Symbol(a, Decl(functionImplementations.ts, 5, 3), Decl(functionImplementations.ts, 8, 3), Decl(functionImplementations.ts, 13, 3), Decl(functionImplementations.ts, 25, 3), Decl(functionImplementations.ts, 26, 3), Decl(functionImplementations.ts, 85, 3)) +>rec2 : Symbol(rec2, Decl(functionImplementations.ts, 21, 1)) + +// Two mutually recursive function implementations with return type annotation in one +function rec3(): number { +>rec3 : Symbol(rec3, Decl(functionImplementations.ts, 26, 15)) + + return rec4(); +>rec4 : Symbol(rec4, Decl(functionImplementations.ts, 31, 1)) +} +function rec4() { +>rec4 : Symbol(rec4, Decl(functionImplementations.ts, 31, 1)) + + return rec3(); +>rec3 : Symbol(rec3, Decl(functionImplementations.ts, 26, 15)) +} +var n: number; +>n : Symbol(n, Decl(functionImplementations.ts, 35, 3), Decl(functionImplementations.ts, 36, 3), Decl(functionImplementations.ts, 37, 3), Decl(functionImplementations.ts, 40, 3), Decl(functionImplementations.ts, 57, 3), Decl(functionImplementations.ts, 62, 3), Decl(functionImplementations.ts, 67, 3)) + +var n = rec3(); +>n : Symbol(n, Decl(functionImplementations.ts, 35, 3), Decl(functionImplementations.ts, 36, 3), Decl(functionImplementations.ts, 37, 3), Decl(functionImplementations.ts, 40, 3), Decl(functionImplementations.ts, 57, 3), Decl(functionImplementations.ts, 62, 3), Decl(functionImplementations.ts, 67, 3)) +>rec3 : Symbol(rec3, Decl(functionImplementations.ts, 26, 15)) + +var n = rec4(); +>n : Symbol(n, Decl(functionImplementations.ts, 35, 3), Decl(functionImplementations.ts, 36, 3), Decl(functionImplementations.ts, 37, 3), Decl(functionImplementations.ts, 40, 3), Decl(functionImplementations.ts, 57, 3), Decl(functionImplementations.ts, 62, 3), Decl(functionImplementations.ts, 67, 3)) +>rec4 : Symbol(rec4, Decl(functionImplementations.ts, 31, 1)) + +// FunctionExpression with no return type annotation and returns a number +var n = function () { +>n : Symbol(n, Decl(functionImplementations.ts, 35, 3), Decl(functionImplementations.ts, 36, 3), Decl(functionImplementations.ts, 37, 3), Decl(functionImplementations.ts, 40, 3), Decl(functionImplementations.ts, 57, 3), Decl(functionImplementations.ts, 62, 3), Decl(functionImplementations.ts, 67, 3)) + + return 3; +} (); + +// FunctionExpression with no return type annotation and returns null +var nu = null; +>nu : Symbol(nu, Decl(functionImplementations.ts, 45, 3), Decl(functionImplementations.ts, 46, 3)) + +var nu = function () { +>nu : Symbol(nu, Decl(functionImplementations.ts, 45, 3), Decl(functionImplementations.ts, 46, 3)) + + return null; +} (); + +// FunctionExpression with no return type annotation and returns undefined +var un = undefined; +>un : Symbol(un, Decl(functionImplementations.ts, 51, 3), Decl(functionImplementations.ts, 52, 3)) +>undefined : Symbol(undefined) + +var un = function () { +>un : Symbol(un, Decl(functionImplementations.ts, 51, 3), Decl(functionImplementations.ts, 52, 3)) + + return undefined; +>undefined : Symbol(undefined) + +} (); + +// FunctionExpression with no return type annotation and returns a type parameter type +var n = function (x: T) { +>n : Symbol(n, Decl(functionImplementations.ts, 35, 3), Decl(functionImplementations.ts, 36, 3), Decl(functionImplementations.ts, 37, 3), Decl(functionImplementations.ts, 40, 3), Decl(functionImplementations.ts, 57, 3), Decl(functionImplementations.ts, 62, 3), Decl(functionImplementations.ts, 67, 3)) +>T : Symbol(T, Decl(functionImplementations.ts, 57, 18)) +>x : Symbol(x, Decl(functionImplementations.ts, 57, 21)) +>T : Symbol(T, Decl(functionImplementations.ts, 57, 18)) + + return x; +>x : Symbol(x, Decl(functionImplementations.ts, 57, 21)) + +} (4); + +// FunctionExpression with no return type annotation and returns a constrained type parameter type +var n = function (x: T) { +>n : Symbol(n, Decl(functionImplementations.ts, 35, 3), Decl(functionImplementations.ts, 36, 3), Decl(functionImplementations.ts, 37, 3), Decl(functionImplementations.ts, 40, 3), Decl(functionImplementations.ts, 57, 3), Decl(functionImplementations.ts, 62, 3), Decl(functionImplementations.ts, 67, 3)) +>T : Symbol(T, Decl(functionImplementations.ts, 62, 18)) +>x : Symbol(x, Decl(functionImplementations.ts, 62, 32)) +>T : Symbol(T, Decl(functionImplementations.ts, 62, 18)) + + return x; +>x : Symbol(x, Decl(functionImplementations.ts, 62, 32)) + +} (4); + +// FunctionExpression with no return type annotation with multiple return statements with identical types +var n = function () { +>n : Symbol(n, Decl(functionImplementations.ts, 35, 3), Decl(functionImplementations.ts, 36, 3), Decl(functionImplementations.ts, 37, 3), Decl(functionImplementations.ts, 40, 3), Decl(functionImplementations.ts, 57, 3), Decl(functionImplementations.ts, 62, 3), Decl(functionImplementations.ts, 67, 3)) + + return 3; + return 5; +}(); + +// Otherwise, the inferred return type is the first of the types of the return statement expressions +// in the function body that is a supertype of each of the others, +// ignoring return statements with no expressions. +// A compile - time error occurs if no return statement expression has a type that is a supertype of each of the others. +// FunctionExpression with no return type annotation with multiple return statements with subtype relation between returns +class Base { private m; } +>Base : Symbol(Base, Decl(functionImplementations.ts, 70, 4)) +>m : Symbol(m, Decl(functionImplementations.ts, 77, 12)) + +class Derived extends Base { private q; } +>Derived : Symbol(Derived, Decl(functionImplementations.ts, 77, 25)) +>Base : Symbol(Base, Decl(functionImplementations.ts, 70, 4)) +>q : Symbol(q, Decl(functionImplementations.ts, 78, 28)) + +var b: Base; +>b : Symbol(b, Decl(functionImplementations.ts, 79, 3), Decl(functionImplementations.ts, 80, 3)) +>Base : Symbol(Base, Decl(functionImplementations.ts, 70, 4)) + +var b = function () { +>b : Symbol(b, Decl(functionImplementations.ts, 79, 3), Decl(functionImplementations.ts, 80, 3)) + + return new Base(); return new Derived(); +>Base : Symbol(Base, Decl(functionImplementations.ts, 70, 4)) +>Derived : Symbol(Derived, Decl(functionImplementations.ts, 77, 25)) + +} (); + +// FunctionExpression with no return type annotation with multiple return statements with one a recursive call +var a = function f() { +>a : Symbol(a, Decl(functionImplementations.ts, 5, 3), Decl(functionImplementations.ts, 8, 3), Decl(functionImplementations.ts, 13, 3), Decl(functionImplementations.ts, 25, 3), Decl(functionImplementations.ts, 26, 3), Decl(functionImplementations.ts, 85, 3)) +>f : Symbol(f, Decl(functionImplementations.ts, 85, 7)) + + return new Base(); return new Derived(); return f(); // ? +>Base : Symbol(Base, Decl(functionImplementations.ts, 70, 4)) +>Derived : Symbol(Derived, Decl(functionImplementations.ts, 77, 25)) +>f : Symbol(f, Decl(functionImplementations.ts, 85, 7)) + +} (); + +// FunctionExpression with non -void return type annotation with a single throw statement +undefined === function (): number { +>undefined : Symbol(undefined) + + throw undefined; +>undefined : Symbol(undefined) + +}; + +// Type of 'this' in function implementation is 'any' +function thisFunc() { +>thisFunc : Symbol(thisFunc, Decl(functionImplementations.ts, 92, 2)) + + var x = this; +>x : Symbol(x, Decl(functionImplementations.ts, 96, 7), Decl(functionImplementations.ts, 97, 7)) + + var x: any; +>x : Symbol(x, Decl(functionImplementations.ts, 96, 7), Decl(functionImplementations.ts, 97, 7)) +} + +// Function signature with optional parameter, no type annotation and initializer has initializer's type +function opt1(n = 4) { +>opt1 : Symbol(opt1, Decl(functionImplementations.ts, 98, 1)) +>n : Symbol(n, Decl(functionImplementations.ts, 101, 14)) + + var m = n; +>m : Symbol(m, Decl(functionImplementations.ts, 102, 7), Decl(functionImplementations.ts, 103, 7)) +>n : Symbol(n, Decl(functionImplementations.ts, 101, 14)) + + var m: number; +>m : Symbol(m, Decl(functionImplementations.ts, 102, 7), Decl(functionImplementations.ts, 103, 7)) +} + +// Function signature with optional parameter, no type annotation and initializer has initializer's widened type +function opt2(n = { x: null, y: undefined }) { +>opt2 : Symbol(opt2, Decl(functionImplementations.ts, 104, 1)) +>n : Symbol(n, Decl(functionImplementations.ts, 107, 14)) +>x : Symbol(x, Decl(functionImplementations.ts, 107, 19)) +>y : Symbol(y, Decl(functionImplementations.ts, 107, 28)) +>undefined : Symbol(undefined) + + var m = n; +>m : Symbol(m, Decl(functionImplementations.ts, 108, 7), Decl(functionImplementations.ts, 109, 7)) +>n : Symbol(n, Decl(functionImplementations.ts, 107, 14)) + + var m: { x: any; y: any }; +>m : Symbol(m, Decl(functionImplementations.ts, 108, 7), Decl(functionImplementations.ts, 109, 7)) +>x : Symbol(x, Decl(functionImplementations.ts, 109, 12)) +>y : Symbol(y, Decl(functionImplementations.ts, 109, 20)) +} + +// Function signature with initializer referencing other parameter to the left +function opt3(n: number, m = n) { +>opt3 : Symbol(opt3, Decl(functionImplementations.ts, 110, 1)) +>n : Symbol(n, Decl(functionImplementations.ts, 113, 14)) +>m : Symbol(m, Decl(functionImplementations.ts, 113, 24)) +>n : Symbol(n, Decl(functionImplementations.ts, 113, 14)) + + var y = m; +>y : Symbol(y, Decl(functionImplementations.ts, 114, 7), Decl(functionImplementations.ts, 115, 7)) +>m : Symbol(m, Decl(functionImplementations.ts, 113, 24)) + + var y: number; +>y : Symbol(y, Decl(functionImplementations.ts, 114, 7), Decl(functionImplementations.ts, 115, 7)) +} + +// Function signature with optional parameter has correct codegen +// (tested above) + +// FunctionExpression with non -void return type annotation return with no expression +function f6(): number { +>f6 : Symbol(f6, Decl(functionImplementations.ts, 116, 1)) + + return; +} + +class Derived2 extends Base { private r: string; } +>Derived2 : Symbol(Derived2, Decl(functionImplementations.ts, 124, 1)) +>Base : Symbol(Base, Decl(functionImplementations.ts, 70, 4)) +>r : Symbol(r, Decl(functionImplementations.ts, 126, 29)) + +class AnotherClass { private x } +>AnotherClass : Symbol(AnotherClass, Decl(functionImplementations.ts, 126, 50)) +>x : Symbol(x, Decl(functionImplementations.ts, 127, 20)) + +// if f is a contextually typed function expression, the inferred return type is the union type +// of the types of the return statement expressions in the function body, +// ignoring return statements with no expressions. +var f7: (x: number) => string | number = x => { // should be (x: number) => number | string +>f7 : Symbol(f7, Decl(functionImplementations.ts, 131, 3)) +>x : Symbol(x, Decl(functionImplementations.ts, 131, 9)) +>x : Symbol(x, Decl(functionImplementations.ts, 131, 40)) + + if (x < 0) { return x; } +>x : Symbol(x, Decl(functionImplementations.ts, 131, 40)) +>x : Symbol(x, Decl(functionImplementations.ts, 131, 40)) + + return x.toString(); +>x.toString : Symbol(Number.toString, Decl(lib.d.ts, --, --)) +>x : Symbol(x, Decl(functionImplementations.ts, 131, 40)) +>toString : Symbol(Number.toString, Decl(lib.d.ts, --, --)) +} +var f8: (x: number) => any = x => { // should be (x: number) => Base +>f8 : Symbol(f8, Decl(functionImplementations.ts, 135, 3)) +>x : Symbol(x, Decl(functionImplementations.ts, 135, 9)) +>x : Symbol(x, Decl(functionImplementations.ts, 135, 28)) + + return new Base(); +>Base : Symbol(Base, Decl(functionImplementations.ts, 70, 4)) + + return new Derived2(); +>Derived2 : Symbol(Derived2, Decl(functionImplementations.ts, 124, 1)) +} +var f9: (x: number) => any = x => { // should be (x: number) => Base +>f9 : Symbol(f9, Decl(functionImplementations.ts, 139, 3)) +>x : Symbol(x, Decl(functionImplementations.ts, 139, 9)) +>x : Symbol(x, Decl(functionImplementations.ts, 139, 28)) + + return new Base(); +>Base : Symbol(Base, Decl(functionImplementations.ts, 70, 4)) + + return new Derived(); +>Derived : Symbol(Derived, Decl(functionImplementations.ts, 77, 25)) + + return new Derived2(); +>Derived2 : Symbol(Derived2, Decl(functionImplementations.ts, 124, 1)) +} +var f10: (x: number) => any = x => { // should be (x: number) => Derived | Derived1 +>f10 : Symbol(f10, Decl(functionImplementations.ts, 144, 3)) +>x : Symbol(x, Decl(functionImplementations.ts, 144, 10)) +>x : Symbol(x, Decl(functionImplementations.ts, 144, 29)) + + return new Derived(); +>Derived : Symbol(Derived, Decl(functionImplementations.ts, 77, 25)) + + return new Derived2(); +>Derived2 : Symbol(Derived2, Decl(functionImplementations.ts, 124, 1)) +} +var f11: (x: number) => any = x => { // should be (x: number) => Base | AnotherClass +>f11 : Symbol(f11, Decl(functionImplementations.ts, 148, 3)) +>x : Symbol(x, Decl(functionImplementations.ts, 148, 10)) +>x : Symbol(x, Decl(functionImplementations.ts, 148, 29)) + + return new Base(); +>Base : Symbol(Base, Decl(functionImplementations.ts, 70, 4)) + + return new AnotherClass(); +>AnotherClass : Symbol(AnotherClass, Decl(functionImplementations.ts, 126, 50)) +} +var f12: (x: number) => any = x => { // should be (x: number) => Base | AnotherClass +>f12 : Symbol(f12, Decl(functionImplementations.ts, 152, 3)) +>x : Symbol(x, Decl(functionImplementations.ts, 152, 10)) +>x : Symbol(x, Decl(functionImplementations.ts, 152, 29)) + + return new Base(); +>Base : Symbol(Base, Decl(functionImplementations.ts, 70, 4)) + + return; // should be ignored + return new AnotherClass(); +>AnotherClass : Symbol(AnotherClass, Decl(functionImplementations.ts, 126, 50)) +} diff --git a/tests/baselines/reference/functionImplementations.types b/tests/baselines/reference/functionImplementations.types new file mode 100644 index 00000000000..6690ca68c98 --- /dev/null +++ b/tests/baselines/reference/functionImplementations.types @@ -0,0 +1,417 @@ +=== tests/cases/conformance/functions/functionImplementations.ts === + +// FunctionExpression with no return type annotation and no return statement returns void +var v: void = function () { } (); +>v : void +>function () { } () : void +>function () { } : () => void + +// FunctionExpression f with no return type annotation and directly references f in its body returns any +var a: any = function f() { +>a : any +>function f() { return f;} : () => any +>f : () => any + + return f; +>f : () => any + +}; +var a: any = function f() { +>a : any +>function f() { return f();} : () => any +>f : () => any + + return f(); +>f() : any +>f : () => any + +}; + +// FunctionExpression f with no return type annotation and indirectly references f in its body returns any +var a: any = function f() { +>a : any +>function f() { var x = f; return x;} : () => any +>f : () => any + + var x = f; +>x : () => any +>f : () => any + + return x; +>x : () => any + +}; + +// Two mutually recursive function implementations with no return type annotations +function rec1() { +>rec1 : () => any + + return rec2(); +>rec2() : any +>rec2 : () => any +} +function rec2() { +>rec2 : () => any + + return rec1(); +>rec1() : any +>rec1 : () => any +} +var a = rec1(); +>a : any +>rec1() : any +>rec1 : () => any + +var a = rec2(); +>a : any +>rec2() : any +>rec2 : () => any + +// Two mutually recursive function implementations with return type annotation in one +function rec3(): number { +>rec3 : () => number + + return rec4(); +>rec4() : number +>rec4 : () => number +} +function rec4() { +>rec4 : () => number + + return rec3(); +>rec3() : number +>rec3 : () => number +} +var n: number; +>n : number + +var n = rec3(); +>n : number +>rec3() : number +>rec3 : () => number + +var n = rec4(); +>n : number +>rec4() : number +>rec4 : () => number + +// FunctionExpression with no return type annotation and returns a number +var n = function () { +>n : number +>function () { return 3;} () : number +>function () { return 3;} : () => number + + return 3; +>3 : number + +} (); + +// FunctionExpression with no return type annotation and returns null +var nu = null; +>nu : any +>null : null + +var nu = function () { +>nu : any +>function () { return null;} () : any +>function () { return null;} : () => any + + return null; +>null : null + +} (); + +// FunctionExpression with no return type annotation and returns undefined +var un = undefined; +>un : any +>undefined : undefined + +var un = function () { +>un : any +>function () { return undefined;} () : any +>function () { return undefined;} : () => any + + return undefined; +>undefined : undefined + +} (); + +// FunctionExpression with no return type annotation and returns a type parameter type +var n = function (x: T) { +>n : number +>function (x: T) { return x;} (4) : number +>function (x: T) { return x;} : (x: T) => T +>T : T +>x : T +>T : T + + return x; +>x : T + +} (4); +>4 : number + +// FunctionExpression with no return type annotation and returns a constrained type parameter type +var n = function (x: T) { +>n : number +>function (x: T) { return x;} (4) : number +>function (x: T) { return x;} : (x: T) => T +>T : T +>x : T +>T : T + + return x; +>x : T + +} (4); +>4 : number + +// FunctionExpression with no return type annotation with multiple return statements with identical types +var n = function () { +>n : number +>function () { return 3; return 5;}() : number +>function () { return 3; return 5;} : () => number + + return 3; +>3 : number + + return 5; +>5 : number + +}(); + +// Otherwise, the inferred return type is the first of the types of the return statement expressions +// in the function body that is a supertype of each of the others, +// ignoring return statements with no expressions. +// A compile - time error occurs if no return statement expression has a type that is a supertype of each of the others. +// FunctionExpression with no return type annotation with multiple return statements with subtype relation between returns +class Base { private m; } +>Base : Base +>m : any + +class Derived extends Base { private q; } +>Derived : Derived +>Base : Base +>q : any + +var b: Base; +>b : Base +>Base : Base + +var b = function () { +>b : Base +>function () { return new Base(); return new Derived();} () : Base +>function () { return new Base(); return new Derived();} : () => Base + + return new Base(); return new Derived(); +>new Base() : Base +>Base : typeof Base +>new Derived() : Derived +>Derived : typeof Derived + +} (); + +// FunctionExpression with no return type annotation with multiple return statements with one a recursive call +var a = function f() { +>a : any +>function f() { return new Base(); return new Derived(); return f(); // ?} () : any +>function f() { return new Base(); return new Derived(); return f(); // ?} : () => any +>f : () => any + + return new Base(); return new Derived(); return f(); // ? +>new Base() : Base +>Base : typeof Base +>new Derived() : Derived +>Derived : typeof Derived +>f() : any +>f : () => any + +} (); + +// FunctionExpression with non -void return type annotation with a single throw statement +undefined === function (): number { +>undefined === function (): number { throw undefined;} : boolean +>undefined : undefined +>function (): number { throw undefined;} : () => number + + throw undefined; +>undefined : undefined + +}; + +// Type of 'this' in function implementation is 'any' +function thisFunc() { +>thisFunc : () => void + + var x = this; +>x : any +>this : any + + var x: any; +>x : any +} + +// Function signature with optional parameter, no type annotation and initializer has initializer's type +function opt1(n = 4) { +>opt1 : (n?: number) => void +>n : number +>4 : number + + var m = n; +>m : number +>n : number + + var m: number; +>m : number +} + +// Function signature with optional parameter, no type annotation and initializer has initializer's widened type +function opt2(n = { x: null, y: undefined }) { +>opt2 : (n?: { x: any; y: any; }) => void +>n : { x: any; y: any; } +>{ x: null, y: undefined } : { x: null; y: undefined; } +>x : null +>null : null +>y : undefined +>undefined : undefined + + var m = n; +>m : { x: any; y: any; } +>n : { x: any; y: any; } + + var m: { x: any; y: any }; +>m : { x: any; y: any; } +>x : any +>y : any +} + +// Function signature with initializer referencing other parameter to the left +function opt3(n: number, m = n) { +>opt3 : (n: number, m?: number) => void +>n : number +>m : number +>n : number + + var y = m; +>y : number +>m : number + + var y: number; +>y : number +} + +// Function signature with optional parameter has correct codegen +// (tested above) + +// FunctionExpression with non -void return type annotation return with no expression +function f6(): number { +>f6 : () => number + + return; +} + +class Derived2 extends Base { private r: string; } +>Derived2 : Derived2 +>Base : Base +>r : string + +class AnotherClass { private x } +>AnotherClass : AnotherClass +>x : any + +// if f is a contextually typed function expression, the inferred return type is the union type +// of the types of the return statement expressions in the function body, +// ignoring return statements with no expressions. +var f7: (x: number) => string | number = x => { // should be (x: number) => number | string +>f7 : (x: number) => string | number +>x : number +>x => { // should be (x: number) => number | string if (x < 0) { return x; } return x.toString();} : (x: number) => number | string +>x : number + + if (x < 0) { return x; } +>x < 0 : boolean +>x : number +>0 : number +>x : number + + return x.toString(); +>x.toString() : string +>x.toString : (radix?: number) => string +>x : number +>toString : (radix?: number) => string +} +var f8: (x: number) => any = x => { // should be (x: number) => Base +>f8 : (x: number) => any +>x : number +>x => { // should be (x: number) => Base return new Base(); return new Derived2();} : (x: number) => Base +>x : number + + return new Base(); +>new Base() : Base +>Base : typeof Base + + return new Derived2(); +>new Derived2() : Derived2 +>Derived2 : typeof Derived2 +} +var f9: (x: number) => any = x => { // should be (x: number) => Base +>f9 : (x: number) => any +>x : number +>x => { // should be (x: number) => Base return new Base(); return new Derived(); return new Derived2();} : (x: number) => Base +>x : number + + return new Base(); +>new Base() : Base +>Base : typeof Base + + return new Derived(); +>new Derived() : Derived +>Derived : typeof Derived + + return new Derived2(); +>new Derived2() : Derived2 +>Derived2 : typeof Derived2 +} +var f10: (x: number) => any = x => { // should be (x: number) => Derived | Derived1 +>f10 : (x: number) => any +>x : number +>x => { // should be (x: number) => Derived | Derived1 return new Derived(); return new Derived2();} : (x: number) => Derived | Derived2 +>x : number + + return new Derived(); +>new Derived() : Derived +>Derived : typeof Derived + + return new Derived2(); +>new Derived2() : Derived2 +>Derived2 : typeof Derived2 +} +var f11: (x: number) => any = x => { // should be (x: number) => Base | AnotherClass +>f11 : (x: number) => any +>x : number +>x => { // should be (x: number) => Base | AnotherClass return new Base(); return new AnotherClass();} : (x: number) => Base | AnotherClass +>x : number + + return new Base(); +>new Base() : Base +>Base : typeof Base + + return new AnotherClass(); +>new AnotherClass() : AnotherClass +>AnotherClass : typeof AnotherClass +} +var f12: (x: number) => any = x => { // should be (x: number) => Base | AnotherClass +>f12 : (x: number) => any +>x : number +>x => { // should be (x: number) => Base | AnotherClass return new Base(); return; // should be ignored return new AnotherClass();} : (x: number) => Base | AnotherClass +>x : number + + return new Base(); +>new Base() : Base +>Base : typeof Base + + return; // should be ignored + return new AnotherClass(); +>new AnotherClass() : AnotherClass +>AnotherClass : typeof AnotherClass +} diff --git a/tests/baselines/reference/functionOverloads12.errors.txt b/tests/baselines/reference/functionOverloads12.errors.txt deleted file mode 100644 index fac5cd71afe..00000000000 --- a/tests/baselines/reference/functionOverloads12.errors.txt +++ /dev/null @@ -1,10 +0,0 @@ -tests/cases/compiler/functionOverloads12.ts(3,48): error TS7027: Unreachable code detected. - - -==== tests/cases/compiler/functionOverloads12.ts (1 errors) ==== - function foo():string; - function foo():number; - function foo():any { if (true) return ""; else return 0;} - ~~~~~~ -!!! error TS7027: Unreachable code detected. - \ No newline at end of file diff --git a/tests/baselines/reference/functionOverloads12.js b/tests/baselines/reference/functionOverloads12.js index 4681e43ee5b..8d834e8180f 100644 --- a/tests/baselines/reference/functionOverloads12.js +++ b/tests/baselines/reference/functionOverloads12.js @@ -1,4 +1,5 @@ //// [functionOverloads12.ts] + function foo():string; function foo():number; function foo():any { if (true) return ""; else return 0;} diff --git a/tests/baselines/reference/functionOverloads12.symbols b/tests/baselines/reference/functionOverloads12.symbols new file mode 100644 index 00000000000..4744f98c9f2 --- /dev/null +++ b/tests/baselines/reference/functionOverloads12.symbols @@ -0,0 +1,11 @@ +=== tests/cases/compiler/functionOverloads12.ts === + +function foo():string; +>foo : Symbol(foo, Decl(functionOverloads12.ts, 0, 0), Decl(functionOverloads12.ts, 1, 22), Decl(functionOverloads12.ts, 2, 22)) + +function foo():number; +>foo : Symbol(foo, Decl(functionOverloads12.ts, 0, 0), Decl(functionOverloads12.ts, 1, 22), Decl(functionOverloads12.ts, 2, 22)) + +function foo():any { if (true) return ""; else return 0;} +>foo : Symbol(foo, Decl(functionOverloads12.ts, 0, 0), Decl(functionOverloads12.ts, 1, 22), Decl(functionOverloads12.ts, 2, 22)) + diff --git a/tests/baselines/reference/functionOverloads12.types b/tests/baselines/reference/functionOverloads12.types new file mode 100644 index 00000000000..5db8ff68cd4 --- /dev/null +++ b/tests/baselines/reference/functionOverloads12.types @@ -0,0 +1,14 @@ +=== tests/cases/compiler/functionOverloads12.ts === + +function foo():string; +>foo : { (): string; (): number; } + +function foo():number; +>foo : { (): string; (): number; } + +function foo():any { if (true) return ""; else return 0;} +>foo : { (): string; (): number; } +>true : boolean +>"" : string +>0 : number + diff --git a/tests/baselines/reference/functionReturn.errors.txt b/tests/baselines/reference/functionReturn.errors.txt deleted file mode 100644 index d5f78b2534d..00000000000 --- a/tests/baselines/reference/functionReturn.errors.txt +++ /dev/null @@ -1,23 +0,0 @@ -tests/cases/compiler/functionReturn.ts(9,5): error TS7027: Unreachable code detected. -tests/cases/compiler/functionReturn.ts(13,5): error TS7027: Unreachable code detected. - - -==== tests/cases/compiler/functionReturn.ts (2 errors) ==== - function f0(): void { } - function f1() { - var n: any = f0(); - } - function f2(): any { } - function f3(): string { return; } - function f4(): string { - return ''; - return; - ~~~~~~ -!!! error TS7027: Unreachable code detected. - } - function f5(): string { - return ''; - return undefined; - ~~~~~~ -!!! error TS7027: Unreachable code detected. - } \ No newline at end of file diff --git a/tests/baselines/reference/functionReturn.js b/tests/baselines/reference/functionReturn.js index c433eec190d..42d0de5fd7c 100644 --- a/tests/baselines/reference/functionReturn.js +++ b/tests/baselines/reference/functionReturn.js @@ -1,4 +1,5 @@ //// [functionReturn.ts] + function f0(): void { } function f1() { var n: any = f0(); diff --git a/tests/baselines/reference/functionReturn.symbols b/tests/baselines/reference/functionReturn.symbols new file mode 100644 index 00000000000..630e435635b --- /dev/null +++ b/tests/baselines/reference/functionReturn.symbols @@ -0,0 +1,31 @@ +=== tests/cases/compiler/functionReturn.ts === + +function f0(): void { } +>f0 : Symbol(f0, Decl(functionReturn.ts, 0, 0)) + +function f1() { +>f1 : Symbol(f1, Decl(functionReturn.ts, 1, 23)) + + var n: any = f0(); +>n : Symbol(n, Decl(functionReturn.ts, 3, 7)) +>f0 : Symbol(f0, Decl(functionReturn.ts, 0, 0)) +} +function f2(): any { } +>f2 : Symbol(f2, Decl(functionReturn.ts, 4, 1)) + +function f3(): string { return; } +>f3 : Symbol(f3, Decl(functionReturn.ts, 5, 22)) + +function f4(): string { +>f4 : Symbol(f4, Decl(functionReturn.ts, 6, 33)) + + return ''; + return; +} +function f5(): string { +>f5 : Symbol(f5, Decl(functionReturn.ts, 10, 1)) + + return ''; + return undefined; +>undefined : Symbol(undefined) +} diff --git a/tests/baselines/reference/functionReturn.types b/tests/baselines/reference/functionReturn.types new file mode 100644 index 00000000000..f9c0b36fbc2 --- /dev/null +++ b/tests/baselines/reference/functionReturn.types @@ -0,0 +1,36 @@ +=== tests/cases/compiler/functionReturn.ts === + +function f0(): void { } +>f0 : () => void + +function f1() { +>f1 : () => void + + var n: any = f0(); +>n : any +>f0() : void +>f0 : () => void +} +function f2(): any { } +>f2 : () => any + +function f3(): string { return; } +>f3 : () => string + +function f4(): string { +>f4 : () => string + + return ''; +>'' : string + + return; +} +function f5(): string { +>f5 : () => string + + return ''; +>'' : string + + return undefined; +>undefined : undefined +} diff --git a/tests/baselines/reference/functionWithMultipleReturnStatements.errors.txt b/tests/baselines/reference/functionWithMultipleReturnStatements.errors.txt index 4c21fc6814c..a981d337093 100644 --- a/tests/baselines/reference/functionWithMultipleReturnStatements.errors.txt +++ b/tests/baselines/reference/functionWithMultipleReturnStatements.errors.txt @@ -1,20 +1,16 @@ -tests/cases/conformance/types/typeRelationships/bestCommonType/functionWithMultipleReturnStatements.ts(4,10): error TS2354: No best common type exists among return expressions. -tests/cases/conformance/types/typeRelationships/bestCommonType/functionWithMultipleReturnStatements.ts(8,9): error TS7027: Unreachable code detected. -tests/cases/conformance/types/typeRelationships/bestCommonType/functionWithMultipleReturnStatements.ts(12,10): error TS2354: No best common type exists among return expressions. -tests/cases/conformance/types/typeRelationships/bestCommonType/functionWithMultipleReturnStatements.ts(15,12): error TS7027: Unreachable code detected. -tests/cases/conformance/types/typeRelationships/bestCommonType/functionWithMultipleReturnStatements.ts(22,10): error TS2354: No best common type exists among return expressions. -tests/cases/conformance/types/typeRelationships/bestCommonType/functionWithMultipleReturnStatements.ts(31,10): error TS2354: No best common type exists among return expressions. -tests/cases/conformance/types/typeRelationships/bestCommonType/functionWithMultipleReturnStatements.ts(43,10): error TS2354: No best common type exists among return expressions. -tests/cases/conformance/types/typeRelationships/bestCommonType/functionWithMultipleReturnStatements.ts(45,5): error TS7027: Unreachable code detected. -tests/cases/conformance/types/typeRelationships/bestCommonType/functionWithMultipleReturnStatements.ts(48,10): error TS2354: No best common type exists among return expressions. -tests/cases/conformance/types/typeRelationships/bestCommonType/functionWithMultipleReturnStatements.ts(52,9): error TS7027: Unreachable code detected. -tests/cases/conformance/types/typeRelationships/bestCommonType/functionWithMultipleReturnStatements.ts(56,10): error TS2354: No best common type exists among return expressions. -tests/cases/conformance/types/typeRelationships/bestCommonType/functionWithMultipleReturnStatements.ts(56,13): error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list. -tests/cases/conformance/types/typeRelationships/bestCommonType/functionWithMultipleReturnStatements.ts(56,26): error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list. -tests/cases/conformance/types/typeRelationships/bestCommonType/functionWithMultipleReturnStatements.ts(60,9): error TS7027: Unreachable code detected. +tests/cases/conformance/types/typeRelationships/bestCommonType/functionWithMultipleReturnStatements.ts(5,10): error TS2354: No best common type exists among return expressions. +tests/cases/conformance/types/typeRelationships/bestCommonType/functionWithMultipleReturnStatements.ts(13,10): error TS2354: No best common type exists among return expressions. +tests/cases/conformance/types/typeRelationships/bestCommonType/functionWithMultipleReturnStatements.ts(23,10): error TS2354: No best common type exists among return expressions. +tests/cases/conformance/types/typeRelationships/bestCommonType/functionWithMultipleReturnStatements.ts(32,10): error TS2354: No best common type exists among return expressions. +tests/cases/conformance/types/typeRelationships/bestCommonType/functionWithMultipleReturnStatements.ts(44,10): error TS2354: No best common type exists among return expressions. +tests/cases/conformance/types/typeRelationships/bestCommonType/functionWithMultipleReturnStatements.ts(49,10): error TS2354: No best common type exists among return expressions. +tests/cases/conformance/types/typeRelationships/bestCommonType/functionWithMultipleReturnStatements.ts(57,10): error TS2354: No best common type exists among return expressions. +tests/cases/conformance/types/typeRelationships/bestCommonType/functionWithMultipleReturnStatements.ts(57,13): error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list. +tests/cases/conformance/types/typeRelationships/bestCommonType/functionWithMultipleReturnStatements.ts(57,26): error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list. -==== tests/cases/conformance/types/typeRelationships/bestCommonType/functionWithMultipleReturnStatements.ts (14 errors) ==== +==== tests/cases/conformance/types/typeRelationships/bestCommonType/functionWithMultipleReturnStatements.ts (9 errors) ==== + // return type of a function with multiple returns is the BCT of each return statement // it is an error if there is no single BCT, these are error cases @@ -25,8 +21,6 @@ tests/cases/conformance/types/typeRelationships/bestCommonType/functionWithMulti return 1; } else { return ''; - ~~~~~~ -!!! error TS7027: Unreachable code detected. } } @@ -36,8 +30,6 @@ tests/cases/conformance/types/typeRelationships/bestCommonType/functionWithMulti if (true) { return 1; } else if (false) { - ~~ -!!! error TS7027: Unreachable code detected. return 2; } else { return ''; @@ -74,8 +66,6 @@ tests/cases/conformance/types/typeRelationships/bestCommonType/functionWithMulti !!! error TS2354: No best common type exists among return expressions. return 1; return ''; - ~~~~~~ -!!! error TS7027: Unreachable code detected. } function f6(x: T, y:U) { @@ -85,8 +75,6 @@ tests/cases/conformance/types/typeRelationships/bestCommonType/functionWithMulti return x; } else { return y; - ~~~~~~ -!!! error TS7027: Unreachable code detected. } } @@ -101,8 +89,6 @@ tests/cases/conformance/types/typeRelationships/bestCommonType/functionWithMulti return x; } else { return y; - ~~~~~~ -!!! error TS7027: Unreachable code detected. } } \ No newline at end of file diff --git a/tests/baselines/reference/functionWithMultipleReturnStatements.js b/tests/baselines/reference/functionWithMultipleReturnStatements.js index 347a05d0f33..d44c37ebbf0 100644 --- a/tests/baselines/reference/functionWithMultipleReturnStatements.js +++ b/tests/baselines/reference/functionWithMultipleReturnStatements.js @@ -1,4 +1,5 @@ //// [functionWithMultipleReturnStatements.ts] + // return type of a function with multiple returns is the BCT of each return statement // it is an error if there is no single BCT, these are error cases diff --git a/tests/baselines/reference/functionWithMultipleReturnStatements2.errors.txt b/tests/baselines/reference/functionWithMultipleReturnStatements2.errors.txt index a965a1a9a99..0399c7a79a6 100644 --- a/tests/baselines/reference/functionWithMultipleReturnStatements2.errors.txt +++ b/tests/baselines/reference/functionWithMultipleReturnStatements2.errors.txt @@ -1,16 +1,9 @@ -tests/cases/conformance/types/typeRelationships/bestCommonType/functionWithMultipleReturnStatements2.ts(8,9): error TS7027: Unreachable code detected. -tests/cases/conformance/types/typeRelationships/bestCommonType/functionWithMultipleReturnStatements2.ts(15,12): error TS7027: Unreachable code detected. -tests/cases/conformance/types/typeRelationships/bestCommonType/functionWithMultipleReturnStatements2.ts(36,5): error TS7027: Unreachable code detected. -tests/cases/conformance/types/typeRelationships/bestCommonType/functionWithMultipleReturnStatements2.ts(43,9): error TS7027: Unreachable code detected. -tests/cases/conformance/types/typeRelationships/bestCommonType/functionWithMultipleReturnStatements2.ts(58,10): error TS2354: No best common type exists among return expressions. -tests/cases/conformance/types/typeRelationships/bestCommonType/functionWithMultipleReturnStatements2.ts(62,9): error TS7027: Unreachable code detected. -tests/cases/conformance/types/typeRelationships/bestCommonType/functionWithMultipleReturnStatements2.ts(67,10): error TS2354: No best common type exists among return expressions. -tests/cases/conformance/types/typeRelationships/bestCommonType/functionWithMultipleReturnStatements2.ts(71,9): error TS7027: Unreachable code detected. -tests/cases/conformance/types/typeRelationships/bestCommonType/functionWithMultipleReturnStatements2.ts(80,9): error TS7027: Unreachable code detected. -tests/cases/conformance/types/typeRelationships/bestCommonType/functionWithMultipleReturnStatements2.ts(89,9): error TS7027: Unreachable code detected. +tests/cases/conformance/types/typeRelationships/bestCommonType/functionWithMultipleReturnStatements2.ts(59,10): error TS2354: No best common type exists among return expressions. +tests/cases/conformance/types/typeRelationships/bestCommonType/functionWithMultipleReturnStatements2.ts(68,10): error TS2354: No best common type exists among return expressions. -==== tests/cases/conformance/types/typeRelationships/bestCommonType/functionWithMultipleReturnStatements2.ts (10 errors) ==== +==== tests/cases/conformance/types/typeRelationships/bestCommonType/functionWithMultipleReturnStatements2.ts (2 errors) ==== + // return type of a function with multiple returns is the BCT of each return statement // no errors expected here @@ -19,8 +12,6 @@ tests/cases/conformance/types/typeRelationships/bestCommonType/functionWithMulti return 1; } else { return null; - ~~~~~~ -!!! error TS7027: Unreachable code detected. } } @@ -28,8 +19,6 @@ tests/cases/conformance/types/typeRelationships/bestCommonType/functionWithMulti if (true) { return 1; } else if (false) { - ~~ -!!! error TS7027: Unreachable code detected. return null; } else { return 2; @@ -51,8 +40,6 @@ tests/cases/conformance/types/typeRelationships/bestCommonType/functionWithMulti function f5() { return 1; return new Object(); - ~~~~~~ -!!! error TS7027: Unreachable code detected. } function f6(x: T) { @@ -60,8 +47,6 @@ tests/cases/conformance/types/typeRelationships/bestCommonType/functionWithMulti return x; } else { return null; - ~~~~~~ -!!! error TS7027: Unreachable code detected. } } @@ -83,8 +68,6 @@ tests/cases/conformance/types/typeRelationships/bestCommonType/functionWithMulti return a; } else { return b; - ~~~~~~ -!!! error TS7027: Unreachable code detected. } } @@ -96,8 +79,6 @@ tests/cases/conformance/types/typeRelationships/bestCommonType/functionWithMulti return b; } else { return a; - ~~~~~~ -!!! error TS7027: Unreachable code detected. } } @@ -107,8 +88,6 @@ tests/cases/conformance/types/typeRelationships/bestCommonType/functionWithMulti return (x: number) => { } } else { return (x: Object) => { } - ~~~~~~ -!!! error TS7027: Unreachable code detected. } } @@ -118,7 +97,5 @@ tests/cases/conformance/types/typeRelationships/bestCommonType/functionWithMulti return (x: Object) => { } } else { return (x: number) => { } - ~~~~~~ -!!! error TS7027: Unreachable code detected. } } \ No newline at end of file diff --git a/tests/baselines/reference/functionWithMultipleReturnStatements2.js b/tests/baselines/reference/functionWithMultipleReturnStatements2.js index 4674c6db953..efee5816fb6 100644 --- a/tests/baselines/reference/functionWithMultipleReturnStatements2.js +++ b/tests/baselines/reference/functionWithMultipleReturnStatements2.js @@ -1,4 +1,5 @@ //// [functionWithMultipleReturnStatements2.ts] + // return type of a function with multiple returns is the BCT of each return statement // no errors expected here diff --git a/tests/baselines/reference/functionWithNoBestCommonType1.errors.txt b/tests/baselines/reference/functionWithNoBestCommonType1.errors.txt index 4cc440ee397..86234b7dd81 100644 --- a/tests/baselines/reference/functionWithNoBestCommonType1.errors.txt +++ b/tests/baselines/reference/functionWithNoBestCommonType1.errors.txt @@ -1,15 +1,13 @@ -tests/cases/compiler/functionWithNoBestCommonType1.ts(1,10): error TS2354: No best common type exists among return expressions. -tests/cases/compiler/functionWithNoBestCommonType1.ts(3,5): error TS7027: Unreachable code detected. +tests/cases/compiler/functionWithNoBestCommonType1.ts(2,10): error TS2354: No best common type exists among return expressions. -==== tests/cases/compiler/functionWithNoBestCommonType1.ts (2 errors) ==== +==== tests/cases/compiler/functionWithNoBestCommonType1.ts (1 errors) ==== + function foo() { ~~~ !!! error TS2354: No best common type exists among return expressions. return true; return bar(); - ~~~~~~ -!!! error TS7027: Unreachable code detected. } function bar(): void { diff --git a/tests/baselines/reference/functionWithNoBestCommonType1.js b/tests/baselines/reference/functionWithNoBestCommonType1.js index f7114fb40d8..4d197c24334 100644 --- a/tests/baselines/reference/functionWithNoBestCommonType1.js +++ b/tests/baselines/reference/functionWithNoBestCommonType1.js @@ -1,4 +1,5 @@ //// [functionWithNoBestCommonType1.ts] + function foo() { return true; return bar(); diff --git a/tests/baselines/reference/functionWithNoBestCommonType2.errors.txt b/tests/baselines/reference/functionWithNoBestCommonType2.errors.txt index a93161b27b8..6ce898e447c 100644 --- a/tests/baselines/reference/functionWithNoBestCommonType2.errors.txt +++ b/tests/baselines/reference/functionWithNoBestCommonType2.errors.txt @@ -1,15 +1,13 @@ -tests/cases/compiler/functionWithNoBestCommonType2.ts(1,9): error TS2354: No best common type exists among return expressions. -tests/cases/compiler/functionWithNoBestCommonType2.ts(3,4): error TS7027: Unreachable code detected. +tests/cases/compiler/functionWithNoBestCommonType2.ts(2,9): error TS2354: No best common type exists among return expressions. -==== tests/cases/compiler/functionWithNoBestCommonType2.ts (2 errors) ==== +==== tests/cases/compiler/functionWithNoBestCommonType2.ts (1 errors) ==== + var v = function () { ~~~~~~~~ !!! error TS2354: No best common type exists among return expressions. return true; return bar(); - ~~~~~~ -!!! error TS7027: Unreachable code detected. }; function bar(): void { diff --git a/tests/baselines/reference/functionWithNoBestCommonType2.js b/tests/baselines/reference/functionWithNoBestCommonType2.js index 8e903518ec0..06a133b2db8 100644 --- a/tests/baselines/reference/functionWithNoBestCommonType2.js +++ b/tests/baselines/reference/functionWithNoBestCommonType2.js @@ -1,4 +1,5 @@ //// [functionWithNoBestCommonType2.ts] + var v = function () { return true; return bar(); diff --git a/tests/baselines/reference/functionsMissingReturnStatementsAndExpressions.errors.txt b/tests/baselines/reference/functionsMissingReturnStatementsAndExpressions.errors.txt index 3a128de4cee..58ffd051d4d 100644 --- a/tests/baselines/reference/functionsMissingReturnStatementsAndExpressions.errors.txt +++ b/tests/baselines/reference/functionsMissingReturnStatementsAndExpressions.errors.txt @@ -1,12 +1,10 @@ -tests/cases/compiler/functionsMissingReturnStatementsAndExpressions.ts(2,16): error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. -tests/cases/compiler/functionsMissingReturnStatementsAndExpressions.ts(68,5): error TS7027: Unreachable code detected. -tests/cases/compiler/functionsMissingReturnStatementsAndExpressions.ts(74,5): error TS7027: Unreachable code detected. -tests/cases/compiler/functionsMissingReturnStatementsAndExpressions.ts(94,16): error TS2378: A 'get' accessor must return a value. -tests/cases/compiler/functionsMissingReturnStatementsAndExpressions.ts(116,9): error TS7027: Unreachable code detected. -tests/cases/compiler/functionsMissingReturnStatementsAndExpressions.ts(117,5): error TS1003: Identifier expected. +tests/cases/compiler/functionsMissingReturnStatementsAndExpressions.ts(3,16): error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. +tests/cases/compiler/functionsMissingReturnStatementsAndExpressions.ts(95,16): error TS2378: A 'get' accessor must return a value. +tests/cases/compiler/functionsMissingReturnStatementsAndExpressions.ts(118,5): error TS1003: Identifier expected. -==== tests/cases/compiler/functionsMissingReturnStatementsAndExpressions.ts (6 errors) ==== +==== tests/cases/compiler/functionsMissingReturnStatementsAndExpressions.ts (3 errors) ==== + function f1(): string { ~~~~~~ @@ -77,16 +75,12 @@ tests/cases/compiler/functionsMissingReturnStatementsAndExpressions.ts(117,5): e // if no return statements are present but we are annotated. throw undefined; throw null; - ~~~~~ -!!! error TS7027: Unreachable code detected. } function f15(): number { // Fine, since we have a return statement somewhere. throw undefined; throw null; - ~~~~~ -!!! error TS7027: Unreachable code detected. return; } @@ -131,8 +125,6 @@ tests/cases/compiler/functionsMissingReturnStatementsAndExpressions.ts(117,5): e // if no return statements are present but we are a get accessor. throw null; throw undefined. - ~~~~~ -!!! error TS7027: Unreachable code detected. } ~ !!! error TS1003: Identifier expected. diff --git a/tests/baselines/reference/functionsMissingReturnStatementsAndExpressions.js b/tests/baselines/reference/functionsMissingReturnStatementsAndExpressions.js index 592a03d7158..f76e5342aee 100644 --- a/tests/baselines/reference/functionsMissingReturnStatementsAndExpressions.js +++ b/tests/baselines/reference/functionsMissingReturnStatementsAndExpressions.js @@ -1,5 +1,6 @@ //// [functionsMissingReturnStatementsAndExpressions.ts] + function f1(): string { // errors because there are no return statements } diff --git a/tests/baselines/reference/generatedContextualTyping.errors.txt b/tests/baselines/reference/generatedContextualTyping.errors.txt deleted file mode 100644 index a2f95cdcb23..00000000000 --- a/tests/baselines/reference/generatedContextualTyping.errors.txt +++ /dev/null @@ -1,393 +0,0 @@ -tests/cases/conformance/expressions/contextualTyping/generatedContextualTyping.ts(150,56): error TS7027: Unreachable code detected. -tests/cases/conformance/expressions/contextualTyping/generatedContextualTyping.ts(151,72): error TS7027: Unreachable code detected. -tests/cases/conformance/expressions/contextualTyping/generatedContextualTyping.ts(152,78): error TS7027: Unreachable code detected. -tests/cases/conformance/expressions/contextualTyping/generatedContextualTyping.ts(153,59): error TS7027: Unreachable code detected. -tests/cases/conformance/expressions/contextualTyping/generatedContextualTyping.ts(154,75): error TS7027: Unreachable code detected. -tests/cases/conformance/expressions/contextualTyping/generatedContextualTyping.ts(155,81): error TS7027: Unreachable code detected. -tests/cases/conformance/expressions/contextualTyping/generatedContextualTyping.ts(156,44): error TS7027: Unreachable code detected. -tests/cases/conformance/expressions/contextualTyping/generatedContextualTyping.ts(157,49): error TS7027: Unreachable code detected. -tests/cases/conformance/expressions/contextualTyping/generatedContextualTyping.ts(158,60): error TS7027: Unreachable code detected. -tests/cases/conformance/expressions/contextualTyping/generatedContextualTyping.ts(159,59): error TS7027: Unreachable code detected. -tests/cases/conformance/expressions/contextualTyping/generatedContextualTyping.ts(160,84): error TS7027: Unreachable code detected. -tests/cases/conformance/expressions/contextualTyping/generatedContextualTyping.ts(161,77): error TS7027: Unreachable code detected. - - -==== tests/cases/conformance/expressions/contextualTyping/generatedContextualTyping.ts (12 errors) ==== - class Base { private p; } - class Derived1 extends Base { private m; } - class Derived2 extends Base { private n; } - interface Genric { func(n: T[]); } - var b = new Base(), d1 = new Derived1(), d2 = new Derived2(); - var x1: () => Base[] = () => [d1, d2]; - var x2: () => Base[] = function() { return [d1, d2] }; - var x3: () => Base[] = function named() { return [d1, d2] }; - var x4: { (): Base[]; } = () => [d1, d2]; - var x5: { (): Base[]; } = function() { return [d1, d2] }; - var x6: { (): Base[]; } = function named() { return [d1, d2] }; - var x7: Base[] = [d1, d2]; - var x8: Array = [d1, d2]; - var x9: { [n: number]: Base; } = [d1, d2]; - var x10: {n: Base[]; } = { n: [d1, d2] }; - var x11: (s: Base[]) => any = n => { var n: Base[]; return null; }; - var x12: Genric = { func: n => { return [d1, d2]; } }; - class x13 { member: () => Base[] = () => [d1, d2] } - class x14 { member: () => Base[] = function() { return [d1, d2] } } - class x15 { member: () => Base[] = function named() { return [d1, d2] } } - class x16 { member: { (): Base[]; } = () => [d1, d2] } - class x17 { member: { (): Base[]; } = function() { return [d1, d2] } } - class x18 { member: { (): Base[]; } = function named() { return [d1, d2] } } - class x19 { member: Base[] = [d1, d2] } - class x20 { member: Array = [d1, d2] } - class x21 { member: { [n: number]: Base; } = [d1, d2] } - class x22 { member: {n: Base[]; } = { n: [d1, d2] } } - class x23 { member: (s: Base[]) => any = n => { var n: Base[]; return null; } } - class x24 { member: Genric = { func: n => { return [d1, d2]; } } } - class x25 { private member: () => Base[] = () => [d1, d2] } - class x26 { private member: () => Base[] = function() { return [d1, d2] } } - class x27 { private member: () => Base[] = function named() { return [d1, d2] } } - class x28 { private member: { (): Base[]; } = () => [d1, d2] } - class x29 { private member: { (): Base[]; } = function() { return [d1, d2] } } - class x30 { private member: { (): Base[]; } = function named() { return [d1, d2] } } - class x31 { private member: Base[] = [d1, d2] } - class x32 { private member: Array = [d1, d2] } - class x33 { private member: { [n: number]: Base; } = [d1, d2] } - class x34 { private member: {n: Base[]; } = { n: [d1, d2] } } - class x35 { private member: (s: Base[]) => any = n => { var n: Base[]; return null; } } - class x36 { private member: Genric = { func: n => { return [d1, d2]; } } } - class x37 { public member: () => Base[] = () => [d1, d2] } - class x38 { public member: () => Base[] = function() { return [d1, d2] } } - class x39 { public member: () => Base[] = function named() { return [d1, d2] } } - class x40 { public member: { (): Base[]; } = () => [d1, d2] } - class x41 { public member: { (): Base[]; } = function() { return [d1, d2] } } - class x42 { public member: { (): Base[]; } = function named() { return [d1, d2] } } - class x43 { public member: Base[] = [d1, d2] } - class x44 { public member: Array = [d1, d2] } - class x45 { public member: { [n: number]: Base; } = [d1, d2] } - class x46 { public member: {n: Base[]; } = { n: [d1, d2] } } - class x47 { public member: (s: Base[]) => any = n => { var n: Base[]; return null; } } - class x48 { public member: Genric = { func: n => { return [d1, d2]; } } } - class x49 { static member: () => Base[] = () => [d1, d2] } - class x50 { static member: () => Base[] = function() { return [d1, d2] } } - class x51 { static member: () => Base[] = function named() { return [d1, d2] } } - class x52 { static member: { (): Base[]; } = () => [d1, d2] } - class x53 { static member: { (): Base[]; } = function() { return [d1, d2] } } - class x54 { static member: { (): Base[]; } = function named() { return [d1, d2] } } - class x55 { static member: Base[] = [d1, d2] } - class x56 { static member: Array = [d1, d2] } - class x57 { static member: { [n: number]: Base; } = [d1, d2] } - class x58 { static member: {n: Base[]; } = { n: [d1, d2] } } - class x59 { static member: (s: Base[]) => any = n => { var n: Base[]; return null; } } - class x60 { static member: Genric = { func: n => { return [d1, d2]; } } } - class x61 { private static member: () => Base[] = () => [d1, d2] } - class x62 { private static member: () => Base[] = function() { return [d1, d2] } } - class x63 { private static member: () => Base[] = function named() { return [d1, d2] } } - class x64 { private static member: { (): Base[]; } = () => [d1, d2] } - class x65 { private static member: { (): Base[]; } = function() { return [d1, d2] } } - class x66 { private static member: { (): Base[]; } = function named() { return [d1, d2] } } - class x67 { private static member: Base[] = [d1, d2] } - class x68 { private static member: Array = [d1, d2] } - class x69 { private static member: { [n: number]: Base; } = [d1, d2] } - class x70 { private static member: {n: Base[]; } = { n: [d1, d2] } } - class x71 { private static member: (s: Base[]) => any = n => { var n: Base[]; return null; } } - class x72 { private static member: Genric = { func: n => { return [d1, d2]; } } } - class x73 { public static member: () => Base[] = () => [d1, d2] } - class x74 { public static member: () => Base[] = function() { return [d1, d2] } } - class x75 { public static member: () => Base[] = function named() { return [d1, d2] } } - class x76 { public static member: { (): Base[]; } = () => [d1, d2] } - class x77 { public static member: { (): Base[]; } = function() { return [d1, d2] } } - class x78 { public static member: { (): Base[]; } = function named() { return [d1, d2] } } - class x79 { public static member: Base[] = [d1, d2] } - class x80 { public static member: Array = [d1, d2] } - class x81 { public static member: { [n: number]: Base; } = [d1, d2] } - class x82 { public static member: {n: Base[]; } = { n: [d1, d2] } } - class x83 { public static member: (s: Base[]) => any = n => { var n: Base[]; return null; } } - class x84 { public static member: Genric = { func: n => { return [d1, d2]; } } } - class x85 { constructor(parm: () => Base[] = () => [d1, d2]) { } } - class x86 { constructor(parm: () => Base[] = function() { return [d1, d2] }) { } } - class x87 { constructor(parm: () => Base[] = function named() { return [d1, d2] }) { } } - class x88 { constructor(parm: { (): Base[]; } = () => [d1, d2]) { } } - class x89 { constructor(parm: { (): Base[]; } = function() { return [d1, d2] }) { } } - class x90 { constructor(parm: { (): Base[]; } = function named() { return [d1, d2] }) { } } - class x91 { constructor(parm: Base[] = [d1, d2]) { } } - class x92 { constructor(parm: Array = [d1, d2]) { } } - class x93 { constructor(parm: { [n: number]: Base; } = [d1, d2]) { } } - class x94 { constructor(parm: {n: Base[]; } = { n: [d1, d2] }) { } } - class x95 { constructor(parm: (s: Base[]) => any = n => { var n: Base[]; return null; }) { } } - class x96 { constructor(parm: Genric = { func: n => { return [d1, d2]; } }) { } } - class x97 { constructor(public parm: () => Base[] = () => [d1, d2]) { } } - class x98 { constructor(public parm: () => Base[] = function() { return [d1, d2] }) { } } - class x99 { constructor(public parm: () => Base[] = function named() { return [d1, d2] }) { } } - class x100 { constructor(public parm: { (): Base[]; } = () => [d1, d2]) { } } - class x101 { constructor(public parm: { (): Base[]; } = function() { return [d1, d2] }) { } } - class x102 { constructor(public parm: { (): Base[]; } = function named() { return [d1, d2] }) { } } - class x103 { constructor(public parm: Base[] = [d1, d2]) { } } - class x104 { constructor(public parm: Array = [d1, d2]) { } } - class x105 { constructor(public parm: { [n: number]: Base; } = [d1, d2]) { } } - class x106 { constructor(public parm: {n: Base[]; } = { n: [d1, d2] }) { } } - class x107 { constructor(public parm: (s: Base[]) => any = n => { var n: Base[]; return null; }) { } } - class x108 { constructor(public parm: Genric = { func: n => { return [d1, d2]; } }) { } } - class x109 { constructor(private parm: () => Base[] = () => [d1, d2]) { } } - class x110 { constructor(private parm: () => Base[] = function() { return [d1, d2] }) { } } - class x111 { constructor(private parm: () => Base[] = function named() { return [d1, d2] }) { } } - class x112 { constructor(private parm: { (): Base[]; } = () => [d1, d2]) { } } - class x113 { constructor(private parm: { (): Base[]; } = function() { return [d1, d2] }) { } } - class x114 { constructor(private parm: { (): Base[]; } = function named() { return [d1, d2] }) { } } - class x115 { constructor(private parm: Base[] = [d1, d2]) { } } - class x116 { constructor(private parm: Array = [d1, d2]) { } } - class x117 { constructor(private parm: { [n: number]: Base; } = [d1, d2]) { } } - class x118 { constructor(private parm: {n: Base[]; } = { n: [d1, d2] }) { } } - class x119 { constructor(private parm: (s: Base[]) => any = n => { var n: Base[]; return null; }) { } } - class x120 { constructor(private parm: Genric = { func: n => { return [d1, d2]; } }) { } } - function x121(parm: () => Base[] = () => [d1, d2]) { } - function x122(parm: () => Base[] = function() { return [d1, d2] }) { } - function x123(parm: () => Base[] = function named() { return [d1, d2] }) { } - function x124(parm: { (): Base[]; } = () => [d1, d2]) { } - function x125(parm: { (): Base[]; } = function() { return [d1, d2] }) { } - function x126(parm: { (): Base[]; } = function named() { return [d1, d2] }) { } - function x127(parm: Base[] = [d1, d2]) { } - function x128(parm: Array = [d1, d2]) { } - function x129(parm: { [n: number]: Base; } = [d1, d2]) { } - function x130(parm: {n: Base[]; } = { n: [d1, d2] }) { } - function x131(parm: (s: Base[]) => any = n => { var n: Base[]; return null; }) { } - function x132(parm: Genric = { func: n => { return [d1, d2]; } }) { } - function x133(): () => Base[] { return () => [d1, d2]; } - function x134(): () => Base[] { return function() { return [d1, d2] }; } - function x135(): () => Base[] { return function named() { return [d1, d2] }; } - function x136(): { (): Base[]; } { return () => [d1, d2]; } - function x137(): { (): Base[]; } { return function() { return [d1, d2] }; } - function x138(): { (): Base[]; } { return function named() { return [d1, d2] }; } - function x139(): Base[] { return [d1, d2]; } - function x140(): Array { return [d1, d2]; } - function x141(): { [n: number]: Base; } { return [d1, d2]; } - function x142(): {n: Base[]; } { return { n: [d1, d2] }; } - function x143(): (s: Base[]) => any { return n => { var n: Base[]; return null; }; } - function x144(): Genric { return { func: n => { return [d1, d2]; } }; } - function x145(): () => Base[] { return () => [d1, d2]; return () => [d1, d2]; } - ~~~~~~ -!!! error TS7027: Unreachable code detected. - function x146(): () => Base[] { return function() { return [d1, d2] }; return function() { return [d1, d2] }; } - ~~~~~~ -!!! error TS7027: Unreachable code detected. - function x147(): () => Base[] { return function named() { return [d1, d2] }; return function named() { return [d1, d2] }; } - ~~~~~~ -!!! error TS7027: Unreachable code detected. - function x148(): { (): Base[]; } { return () => [d1, d2]; return () => [d1, d2]; } - ~~~~~~ -!!! error TS7027: Unreachable code detected. - function x149(): { (): Base[]; } { return function() { return [d1, d2] }; return function() { return [d1, d2] }; } - ~~~~~~ -!!! error TS7027: Unreachable code detected. - function x150(): { (): Base[]; } { return function named() { return [d1, d2] }; return function named() { return [d1, d2] }; } - ~~~~~~ -!!! error TS7027: Unreachable code detected. - function x151(): Base[] { return [d1, d2]; return [d1, d2]; } - ~~~~~~ -!!! error TS7027: Unreachable code detected. - function x152(): Array { return [d1, d2]; return [d1, d2]; } - ~~~~~~ -!!! error TS7027: Unreachable code detected. - function x153(): { [n: number]: Base; } { return [d1, d2]; return [d1, d2]; } - ~~~~~~ -!!! error TS7027: Unreachable code detected. - function x154(): {n: Base[]; } { return { n: [d1, d2] }; return { n: [d1, d2] }; } - ~~~~~~ -!!! error TS7027: Unreachable code detected. - function x155(): (s: Base[]) => any { return n => { var n: Base[]; return null; }; return n => { var n: Base[]; return null; }; } - ~~~~~~ -!!! error TS7027: Unreachable code detected. - function x156(): Genric { return { func: n => { return [d1, d2]; } }; return { func: n => { return [d1, d2]; } }; } - ~~~~~~ -!!! error TS7027: Unreachable code detected. - var x157: () => () => Base[] = () => { return () => [d1, d2]; }; - var x158: () => () => Base[] = () => { return function() { return [d1, d2] }; }; - var x159: () => () => Base[] = () => { return function named() { return [d1, d2] }; }; - var x160: () => { (): Base[]; } = () => { return () => [d1, d2]; }; - var x161: () => { (): Base[]; } = () => { return function() { return [d1, d2] }; }; - var x162: () => { (): Base[]; } = () => { return function named() { return [d1, d2] }; }; - var x163: () => Base[] = () => { return [d1, d2]; }; - var x164: () => Array = () => { return [d1, d2]; }; - var x165: () => { [n: number]: Base; } = () => { return [d1, d2]; }; - var x166: () => {n: Base[]; } = () => { return { n: [d1, d2] }; }; - var x167: () => (s: Base[]) => any = () => { return n => { var n: Base[]; return null; }; }; - var x168: () => Genric = () => { return { func: n => { return [d1, d2]; } }; }; - var x169: () => () => Base[] = function() { return () => [d1, d2]; }; - var x170: () => () => Base[] = function() { return function() { return [d1, d2] }; }; - var x171: () => () => Base[] = function() { return function named() { return [d1, d2] }; }; - var x172: () => { (): Base[]; } = function() { return () => [d1, d2]; }; - var x173: () => { (): Base[]; } = function() { return function() { return [d1, d2] }; }; - var x174: () => { (): Base[]; } = function() { return function named() { return [d1, d2] }; }; - var x175: () => Base[] = function() { return [d1, d2]; }; - var x176: () => Array = function() { return [d1, d2]; }; - var x177: () => { [n: number]: Base; } = function() { return [d1, d2]; }; - var x178: () => {n: Base[]; } = function() { return { n: [d1, d2] }; }; - var x179: () => (s: Base[]) => any = function() { return n => { var n: Base[]; return null; }; }; - var x180: () => Genric = function() { return { func: n => { return [d1, d2]; } }; }; - module x181 { var t: () => Base[] = () => [d1, d2]; } - module x182 { var t: () => Base[] = function() { return [d1, d2] }; } - module x183 { var t: () => Base[] = function named() { return [d1, d2] }; } - module x184 { var t: { (): Base[]; } = () => [d1, d2]; } - module x185 { var t: { (): Base[]; } = function() { return [d1, d2] }; } - module x186 { var t: { (): Base[]; } = function named() { return [d1, d2] }; } - module x187 { var t: Base[] = [d1, d2]; } - module x188 { var t: Array = [d1, d2]; } - module x189 { var t: { [n: number]: Base; } = [d1, d2]; } - module x190 { var t: {n: Base[]; } = { n: [d1, d2] }; } - module x191 { var t: (s: Base[]) => any = n => { var n: Base[]; return null; }; } - module x192 { var t: Genric = { func: n => { return [d1, d2]; } }; } - module x193 { export var t: () => Base[] = () => [d1, d2]; } - module x194 { export var t: () => Base[] = function() { return [d1, d2] }; } - module x195 { export var t: () => Base[] = function named() { return [d1, d2] }; } - module x196 { export var t: { (): Base[]; } = () => [d1, d2]; } - module x197 { export var t: { (): Base[]; } = function() { return [d1, d2] }; } - module x198 { export var t: { (): Base[]; } = function named() { return [d1, d2] }; } - module x199 { export var t: Base[] = [d1, d2]; } - module x200 { export var t: Array = [d1, d2]; } - module x201 { export var t: { [n: number]: Base; } = [d1, d2]; } - module x202 { export var t: {n: Base[]; } = { n: [d1, d2] }; } - module x203 { export var t: (s: Base[]) => any = n => { var n: Base[]; return null; }; } - module x204 { export var t: Genric = { func: n => { return [d1, d2]; } }; } - var x206 = <() => Base[]>function() { return [d1, d2] }; - var x207 = <() => Base[]>function named() { return [d1, d2] }; - var x209 = <{ (): Base[]; }>function() { return [d1, d2] }; - var x210 = <{ (): Base[]; }>function named() { return [d1, d2] }; - var x211 = [d1, d2]; - var x212 = >[d1, d2]; - var x213 = <{ [n: number]: Base; }>[d1, d2]; - var x214 = <{n: Base[]; } >{ n: [d1, d2] }; - var x216 = >{ func: n => { return [d1, d2]; } }; - var x217 = (<() => Base[]>undefined) || function() { return [d1, d2] }; - var x218 = (<() => Base[]>undefined) || function named() { return [d1, d2] }; - var x219 = (<{ (): Base[]; }>undefined) || function() { return [d1, d2] }; - var x220 = (<{ (): Base[]; }>undefined) || function named() { return [d1, d2] }; - var x221 = (undefined) || [d1, d2]; - var x222 = (>undefined) || [d1, d2]; - var x223 = (<{ [n: number]: Base; }>undefined) || [d1, d2]; - var x224 = (<{n: Base[]; } >undefined) || { n: [d1, d2] }; - var x225: () => Base[]; x225 = () => [d1, d2]; - var x226: () => Base[]; x226 = function() { return [d1, d2] }; - var x227: () => Base[]; x227 = function named() { return [d1, d2] }; - var x228: { (): Base[]; }; x228 = () => [d1, d2]; - var x229: { (): Base[]; }; x229 = function() { return [d1, d2] }; - var x230: { (): Base[]; }; x230 = function named() { return [d1, d2] }; - var x231: Base[]; x231 = [d1, d2]; - var x232: Array; x232 = [d1, d2]; - var x233: { [n: number]: Base; }; x233 = [d1, d2]; - var x234: {n: Base[]; } ; x234 = { n: [d1, d2] }; - var x235: (s: Base[]) => any; x235 = n => { var n: Base[]; return null; }; - var x236: Genric; x236 = { func: n => { return [d1, d2]; } }; - var x237: { n: () => Base[]; } = { n: () => [d1, d2] }; - var x238: { n: () => Base[]; } = { n: function() { return [d1, d2] } }; - var x239: { n: () => Base[]; } = { n: function named() { return [d1, d2] } }; - var x240: { n: { (): Base[]; }; } = { n: () => [d1, d2] }; - var x241: { n: { (): Base[]; }; } = { n: function() { return [d1, d2] } }; - var x242: { n: { (): Base[]; }; } = { n: function named() { return [d1, d2] } }; - var x243: { n: Base[]; } = { n: [d1, d2] }; - var x244: { n: Array; } = { n: [d1, d2] }; - var x245: { n: { [n: number]: Base; }; } = { n: [d1, d2] }; - var x246: { n: {n: Base[]; } ; } = { n: { n: [d1, d2] } }; - var x247: { n: (s: Base[]) => any; } = { n: n => { var n: Base[]; return null; } }; - var x248: { n: Genric; } = { n: { func: n => { return [d1, d2]; } } }; - var x252: { (): Base[]; }[] = [() => [d1, d2]]; - var x253: { (): Base[]; }[] = [function() { return [d1, d2] }]; - var x254: { (): Base[]; }[] = [function named() { return [d1, d2] }]; - var x255: Base[][] = [[d1, d2]]; - var x256: Array[] = [[d1, d2]]; - var x257: { [n: number]: Base; }[] = [[d1, d2]]; - var x258: {n: Base[]; } [] = [{ n: [d1, d2] }]; - var x260: Genric[] = [{ func: n => { return [d1, d2]; } }]; - var x261: () => Base[] = function() { return [d1, d2] } || undefined; - var x262: () => Base[] = function named() { return [d1, d2] } || undefined; - var x263: { (): Base[]; } = function() { return [d1, d2] } || undefined; - var x264: { (): Base[]; } = function named() { return [d1, d2] } || undefined; - var x265: Base[] = [d1, d2] || undefined; - var x266: Array = [d1, d2] || undefined; - var x267: { [n: number]: Base; } = [d1, d2] || undefined; - var x268: {n: Base[]; } = { n: [d1, d2] } || undefined; - var x269: () => Base[] = undefined || function() { return [d1, d2] }; - var x270: () => Base[] = undefined || function named() { return [d1, d2] }; - var x271: { (): Base[]; } = undefined || function() { return [d1, d2] }; - var x272: { (): Base[]; } = undefined || function named() { return [d1, d2] }; - var x273: Base[] = undefined || [d1, d2]; - var x274: Array = undefined || [d1, d2]; - var x275: { [n: number]: Base; } = undefined || [d1, d2]; - var x276: {n: Base[]; } = undefined || { n: [d1, d2] }; - var x277: () => Base[] = function() { return [d1, d2] } || function() { return [d1, d2] }; - var x278: () => Base[] = function named() { return [d1, d2] } || function named() { return [d1, d2] }; - var x279: { (): Base[]; } = function() { return [d1, d2] } || function() { return [d1, d2] }; - var x280: { (): Base[]; } = function named() { return [d1, d2] } || function named() { return [d1, d2] }; - var x281: Base[] = [d1, d2] || [d1, d2]; - var x282: Array = [d1, d2] || [d1, d2]; - var x283: { [n: number]: Base; } = [d1, d2] || [d1, d2]; - var x284: {n: Base[]; } = { n: [d1, d2] } || { n: [d1, d2] }; - var x285: () => Base[] = true ? () => [d1, d2] : () => [d1, d2]; - var x286: () => Base[] = true ? function() { return [d1, d2] } : function() { return [d1, d2] }; - var x287: () => Base[] = true ? function named() { return [d1, d2] } : function named() { return [d1, d2] }; - var x288: { (): Base[]; } = true ? () => [d1, d2] : () => [d1, d2]; - var x289: { (): Base[]; } = true ? function() { return [d1, d2] } : function() { return [d1, d2] }; - var x290: { (): Base[]; } = true ? function named() { return [d1, d2] } : function named() { return [d1, d2] }; - var x291: Base[] = true ? [d1, d2] : [d1, d2]; - var x292: Array = true ? [d1, d2] : [d1, d2]; - var x293: { [n: number]: Base; } = true ? [d1, d2] : [d1, d2]; - var x294: {n: Base[]; } = true ? { n: [d1, d2] } : { n: [d1, d2] }; - var x295: (s: Base[]) => any = true ? n => { var n: Base[]; return null; } : n => { var n: Base[]; return null; }; - var x296: Genric = true ? { func: n => { return [d1, d2]; } } : { func: n => { return [d1, d2]; } }; - var x297: () => Base[] = true ? undefined : () => [d1, d2]; - var x298: () => Base[] = true ? undefined : function() { return [d1, d2] }; - var x299: () => Base[] = true ? undefined : function named() { return [d1, d2] }; - var x300: { (): Base[]; } = true ? undefined : () => [d1, d2]; - var x301: { (): Base[]; } = true ? undefined : function() { return [d1, d2] }; - var x302: { (): Base[]; } = true ? undefined : function named() { return [d1, d2] }; - var x303: Base[] = true ? undefined : [d1, d2]; - var x304: Array = true ? undefined : [d1, d2]; - var x305: { [n: number]: Base; } = true ? undefined : [d1, d2]; - var x306: {n: Base[]; } = true ? undefined : { n: [d1, d2] }; - var x307: (s: Base[]) => any = true ? undefined : n => { var n: Base[]; return null; }; - var x308: Genric = true ? undefined : { func: n => { return [d1, d2]; } }; - var x309: () => Base[] = true ? () => [d1, d2] : undefined; - var x310: () => Base[] = true ? function() { return [d1, d2] } : undefined; - var x311: () => Base[] = true ? function named() { return [d1, d2] } : undefined; - var x312: { (): Base[]; } = true ? () => [d1, d2] : undefined; - var x313: { (): Base[]; } = true ? function() { return [d1, d2] } : undefined; - var x314: { (): Base[]; } = true ? function named() { return [d1, d2] } : undefined; - var x315: Base[] = true ? [d1, d2] : undefined; - var x316: Array = true ? [d1, d2] : undefined; - var x317: { [n: number]: Base; } = true ? [d1, d2] : undefined; - var x318: {n: Base[]; } = true ? { n: [d1, d2] } : undefined; - var x319: (s: Base[]) => any = true ? n => { var n: Base[]; return null; } : undefined; - var x320: Genric = true ? { func: n => { return [d1, d2]; } } : undefined; - function x321(n: () => Base[]) { }; x321(() => [d1, d2]); - function x322(n: () => Base[]) { }; x322(function() { return [d1, d2] }); - function x323(n: () => Base[]) { }; x323(function named() { return [d1, d2] }); - function x324(n: { (): Base[]; }) { }; x324(() => [d1, d2]); - function x325(n: { (): Base[]; }) { }; x325(function() { return [d1, d2] }); - function x326(n: { (): Base[]; }) { }; x326(function named() { return [d1, d2] }); - function x327(n: Base[]) { }; x327([d1, d2]); - function x328(n: Array) { }; x328([d1, d2]); - function x329(n: { [n: number]: Base; }) { }; x329([d1, d2]); - function x330(n: {n: Base[]; } ) { }; x330({ n: [d1, d2] }); - function x331(n: (s: Base[]) => any) { }; x331(n => { var n: Base[]; return null; }); - function x332(n: Genric) { }; x332({ func: n => { return [d1, d2]; } }); - var x333 = (n: () => Base[]) => n; x333(() => [d1, d2]); - var x334 = (n: () => Base[]) => n; x334(function() { return [d1, d2] }); - var x335 = (n: () => Base[]) => n; x335(function named() { return [d1, d2] }); - var x336 = (n: { (): Base[]; }) => n; x336(() => [d1, d2]); - var x337 = (n: { (): Base[]; }) => n; x337(function() { return [d1, d2] }); - var x338 = (n: { (): Base[]; }) => n; x338(function named() { return [d1, d2] }); - var x339 = (n: Base[]) => n; x339([d1, d2]); - var x340 = (n: Array) => n; x340([d1, d2]); - var x341 = (n: { [n: number]: Base; }) => n; x341([d1, d2]); - var x342 = (n: {n: Base[]; } ) => n; x342({ n: [d1, d2] }); - var x343 = (n: (s: Base[]) => any) => n; x343(n => { var n: Base[]; return null; }); - var x344 = (n: Genric) => n; x344({ func: n => { return [d1, d2]; } }); - var x345 = function(n: () => Base[]) { }; x345(() => [d1, d2]); - var x346 = function(n: () => Base[]) { }; x346(function() { return [d1, d2] }); - var x347 = function(n: () => Base[]) { }; x347(function named() { return [d1, d2] }); - var x348 = function(n: { (): Base[]; }) { }; x348(() => [d1, d2]); - var x349 = function(n: { (): Base[]; }) { }; x349(function() { return [d1, d2] }); - var x350 = function(n: { (): Base[]; }) { }; x350(function named() { return [d1, d2] }); - var x351 = function(n: Base[]) { }; x351([d1, d2]); - var x352 = function(n: Array) { }; x352([d1, d2]); - var x353 = function(n: { [n: number]: Base; }) { }; x353([d1, d2]); - var x354 = function(n: {n: Base[]; } ) { }; x354({ n: [d1, d2] }); - var x355 = function(n: (s: Base[]) => any) { }; x355(n => { var n: Base[]; return null; }); - var x356 = function(n: Genric) { }; x356({ func: n => { return [d1, d2]; } }); \ No newline at end of file diff --git a/tests/baselines/reference/generatedContextualTyping.js b/tests/baselines/reference/generatedContextualTyping.js index 1f7d2b8035f..a867d4b7629 100644 --- a/tests/baselines/reference/generatedContextualTyping.js +++ b/tests/baselines/reference/generatedContextualTyping.js @@ -1,4 +1,5 @@ //// [generatedContextualTyping.ts] + class Base { private p; } class Derived1 extends Base { private m; } class Derived2 extends Base { private n; } diff --git a/tests/baselines/reference/generatedContextualTyping.symbols b/tests/baselines/reference/generatedContextualTyping.symbols new file mode 100644 index 00000000000..bc50fcc25c6 --- /dev/null +++ b/tests/baselines/reference/generatedContextualTyping.symbols @@ -0,0 +1,2832 @@ +=== tests/cases/conformance/expressions/contextualTyping/generatedContextualTyping.ts === + +class Base { private p; } +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>p : Symbol(p, Decl(generatedContextualTyping.ts, 1, 12)) + +class Derived1 extends Base { private m; } +>Derived1 : Symbol(Derived1, Decl(generatedContextualTyping.ts, 1, 25)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>m : Symbol(m, Decl(generatedContextualTyping.ts, 2, 29)) + +class Derived2 extends Base { private n; } +>Derived2 : Symbol(Derived2, Decl(generatedContextualTyping.ts, 2, 42)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 3, 29)) + +interface Genric { func(n: T[]); } +>Genric : Symbol(Genric, Decl(generatedContextualTyping.ts, 3, 42)) +>T : Symbol(T, Decl(generatedContextualTyping.ts, 4, 17)) +>func : Symbol(func, Decl(generatedContextualTyping.ts, 4, 21)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 4, 27)) +>T : Symbol(T, Decl(generatedContextualTyping.ts, 4, 17)) + +var b = new Base(), d1 = new Derived1(), d2 = new Derived2(); +>b : Symbol(b, Decl(generatedContextualTyping.ts, 5, 3)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>Derived1 : Symbol(Derived1, Decl(generatedContextualTyping.ts, 1, 25)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) +>Derived2 : Symbol(Derived2, Decl(generatedContextualTyping.ts, 2, 42)) + +var x1: () => Base[] = () => [d1, d2]; +>x1 : Symbol(x1, Decl(generatedContextualTyping.ts, 6, 3)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +var x2: () => Base[] = function() { return [d1, d2] }; +>x2 : Symbol(x2, Decl(generatedContextualTyping.ts, 7, 3)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +var x3: () => Base[] = function named() { return [d1, d2] }; +>x3 : Symbol(x3, Decl(generatedContextualTyping.ts, 8, 3)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>named : Symbol(named, Decl(generatedContextualTyping.ts, 8, 22)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +var x4: { (): Base[]; } = () => [d1, d2]; +>x4 : Symbol(x4, Decl(generatedContextualTyping.ts, 9, 3)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +var x5: { (): Base[]; } = function() { return [d1, d2] }; +>x5 : Symbol(x5, Decl(generatedContextualTyping.ts, 10, 3)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +var x6: { (): Base[]; } = function named() { return [d1, d2] }; +>x6 : Symbol(x6, Decl(generatedContextualTyping.ts, 11, 3)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>named : Symbol(named, Decl(generatedContextualTyping.ts, 11, 25)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +var x7: Base[] = [d1, d2]; +>x7 : Symbol(x7, Decl(generatedContextualTyping.ts, 12, 3)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +var x8: Array = [d1, d2]; +>x8 : Symbol(x8, Decl(generatedContextualTyping.ts, 13, 3)) +>Array : Symbol(Array, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +var x9: { [n: number]: Base; } = [d1, d2]; +>x9 : Symbol(x9, Decl(generatedContextualTyping.ts, 14, 3)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 14, 11)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +var x10: {n: Base[]; } = { n: [d1, d2] }; +>x10 : Symbol(x10, Decl(generatedContextualTyping.ts, 15, 3)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 15, 10)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 15, 27)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +var x11: (s: Base[]) => any = n => { var n: Base[]; return null; }; +>x11 : Symbol(x11, Decl(generatedContextualTyping.ts, 16, 3)) +>s : Symbol(s, Decl(generatedContextualTyping.ts, 16, 10)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 16, 29), Decl(generatedContextualTyping.ts, 16, 40)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 16, 29), Decl(generatedContextualTyping.ts, 16, 40)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) + +var x12: Genric = { func: n => { return [d1, d2]; } }; +>x12 : Symbol(x12, Decl(generatedContextualTyping.ts, 17, 3)) +>Genric : Symbol(Genric, Decl(generatedContextualTyping.ts, 3, 42)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>func : Symbol(func, Decl(generatedContextualTyping.ts, 17, 25)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 17, 31)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +class x13 { member: () => Base[] = () => [d1, d2] } +>x13 : Symbol(x13, Decl(generatedContextualTyping.ts, 17, 60)) +>member : Symbol(member, Decl(generatedContextualTyping.ts, 18, 11)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +class x14 { member: () => Base[] = function() { return [d1, d2] } } +>x14 : Symbol(x14, Decl(generatedContextualTyping.ts, 18, 51)) +>member : Symbol(member, Decl(generatedContextualTyping.ts, 19, 11)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +class x15 { member: () => Base[] = function named() { return [d1, d2] } } +>x15 : Symbol(x15, Decl(generatedContextualTyping.ts, 19, 67)) +>member : Symbol(member, Decl(generatedContextualTyping.ts, 20, 11)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>named : Symbol(named, Decl(generatedContextualTyping.ts, 20, 34)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +class x16 { member: { (): Base[]; } = () => [d1, d2] } +>x16 : Symbol(x16, Decl(generatedContextualTyping.ts, 20, 73)) +>member : Symbol(member, Decl(generatedContextualTyping.ts, 21, 11)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +class x17 { member: { (): Base[]; } = function() { return [d1, d2] } } +>x17 : Symbol(x17, Decl(generatedContextualTyping.ts, 21, 54)) +>member : Symbol(member, Decl(generatedContextualTyping.ts, 22, 11)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +class x18 { member: { (): Base[]; } = function named() { return [d1, d2] } } +>x18 : Symbol(x18, Decl(generatedContextualTyping.ts, 22, 70)) +>member : Symbol(member, Decl(generatedContextualTyping.ts, 23, 11)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>named : Symbol(named, Decl(generatedContextualTyping.ts, 23, 37)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +class x19 { member: Base[] = [d1, d2] } +>x19 : Symbol(x19, Decl(generatedContextualTyping.ts, 23, 76)) +>member : Symbol(member, Decl(generatedContextualTyping.ts, 24, 11)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +class x20 { member: Array = [d1, d2] } +>x20 : Symbol(x20, Decl(generatedContextualTyping.ts, 24, 39)) +>member : Symbol(member, Decl(generatedContextualTyping.ts, 25, 11)) +>Array : Symbol(Array, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +class x21 { member: { [n: number]: Base; } = [d1, d2] } +>x21 : Symbol(x21, Decl(generatedContextualTyping.ts, 25, 44)) +>member : Symbol(member, Decl(generatedContextualTyping.ts, 26, 11)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 26, 23)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +class x22 { member: {n: Base[]; } = { n: [d1, d2] } } +>x22 : Symbol(x22, Decl(generatedContextualTyping.ts, 26, 55)) +>member : Symbol(member, Decl(generatedContextualTyping.ts, 27, 11)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 27, 21)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 27, 38)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +class x23 { member: (s: Base[]) => any = n => { var n: Base[]; return null; } } +>x23 : Symbol(x23, Decl(generatedContextualTyping.ts, 27, 54)) +>member : Symbol(member, Decl(generatedContextualTyping.ts, 28, 11)) +>s : Symbol(s, Decl(generatedContextualTyping.ts, 28, 21)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 28, 40), Decl(generatedContextualTyping.ts, 28, 51)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 28, 40), Decl(generatedContextualTyping.ts, 28, 51)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) + +class x24 { member: Genric = { func: n => { return [d1, d2]; } } } +>x24 : Symbol(x24, Decl(generatedContextualTyping.ts, 28, 79)) +>member : Symbol(member, Decl(generatedContextualTyping.ts, 29, 11)) +>Genric : Symbol(Genric, Decl(generatedContextualTyping.ts, 3, 42)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>func : Symbol(func, Decl(generatedContextualTyping.ts, 29, 36)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 29, 42)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +class x25 { private member: () => Base[] = () => [d1, d2] } +>x25 : Symbol(x25, Decl(generatedContextualTyping.ts, 29, 72)) +>member : Symbol(member, Decl(generatedContextualTyping.ts, 30, 11)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +class x26 { private member: () => Base[] = function() { return [d1, d2] } } +>x26 : Symbol(x26, Decl(generatedContextualTyping.ts, 30, 59)) +>member : Symbol(member, Decl(generatedContextualTyping.ts, 31, 11)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +class x27 { private member: () => Base[] = function named() { return [d1, d2] } } +>x27 : Symbol(x27, Decl(generatedContextualTyping.ts, 31, 75)) +>member : Symbol(member, Decl(generatedContextualTyping.ts, 32, 11)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>named : Symbol(named, Decl(generatedContextualTyping.ts, 32, 42)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +class x28 { private member: { (): Base[]; } = () => [d1, d2] } +>x28 : Symbol(x28, Decl(generatedContextualTyping.ts, 32, 81)) +>member : Symbol(member, Decl(generatedContextualTyping.ts, 33, 11)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +class x29 { private member: { (): Base[]; } = function() { return [d1, d2] } } +>x29 : Symbol(x29, Decl(generatedContextualTyping.ts, 33, 62)) +>member : Symbol(member, Decl(generatedContextualTyping.ts, 34, 11)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +class x30 { private member: { (): Base[]; } = function named() { return [d1, d2] } } +>x30 : Symbol(x30, Decl(generatedContextualTyping.ts, 34, 78)) +>member : Symbol(member, Decl(generatedContextualTyping.ts, 35, 11)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>named : Symbol(named, Decl(generatedContextualTyping.ts, 35, 45)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +class x31 { private member: Base[] = [d1, d2] } +>x31 : Symbol(x31, Decl(generatedContextualTyping.ts, 35, 84)) +>member : Symbol(member, Decl(generatedContextualTyping.ts, 36, 11)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +class x32 { private member: Array = [d1, d2] } +>x32 : Symbol(x32, Decl(generatedContextualTyping.ts, 36, 47)) +>member : Symbol(member, Decl(generatedContextualTyping.ts, 37, 11)) +>Array : Symbol(Array, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +class x33 { private member: { [n: number]: Base; } = [d1, d2] } +>x33 : Symbol(x33, Decl(generatedContextualTyping.ts, 37, 52)) +>member : Symbol(member, Decl(generatedContextualTyping.ts, 38, 11)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 38, 31)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +class x34 { private member: {n: Base[]; } = { n: [d1, d2] } } +>x34 : Symbol(x34, Decl(generatedContextualTyping.ts, 38, 63)) +>member : Symbol(member, Decl(generatedContextualTyping.ts, 39, 11)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 39, 29)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 39, 46)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +class x35 { private member: (s: Base[]) => any = n => { var n: Base[]; return null; } } +>x35 : Symbol(x35, Decl(generatedContextualTyping.ts, 39, 62)) +>member : Symbol(member, Decl(generatedContextualTyping.ts, 40, 11)) +>s : Symbol(s, Decl(generatedContextualTyping.ts, 40, 29)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 40, 48), Decl(generatedContextualTyping.ts, 40, 59)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 40, 48), Decl(generatedContextualTyping.ts, 40, 59)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) + +class x36 { private member: Genric = { func: n => { return [d1, d2]; } } } +>x36 : Symbol(x36, Decl(generatedContextualTyping.ts, 40, 87)) +>member : Symbol(member, Decl(generatedContextualTyping.ts, 41, 11)) +>Genric : Symbol(Genric, Decl(generatedContextualTyping.ts, 3, 42)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>func : Symbol(func, Decl(generatedContextualTyping.ts, 41, 44)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 41, 50)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +class x37 { public member: () => Base[] = () => [d1, d2] } +>x37 : Symbol(x37, Decl(generatedContextualTyping.ts, 41, 80)) +>member : Symbol(member, Decl(generatedContextualTyping.ts, 42, 11)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +class x38 { public member: () => Base[] = function() { return [d1, d2] } } +>x38 : Symbol(x38, Decl(generatedContextualTyping.ts, 42, 58)) +>member : Symbol(member, Decl(generatedContextualTyping.ts, 43, 11)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +class x39 { public member: () => Base[] = function named() { return [d1, d2] } } +>x39 : Symbol(x39, Decl(generatedContextualTyping.ts, 43, 74)) +>member : Symbol(member, Decl(generatedContextualTyping.ts, 44, 11)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>named : Symbol(named, Decl(generatedContextualTyping.ts, 44, 41)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +class x40 { public member: { (): Base[]; } = () => [d1, d2] } +>x40 : Symbol(x40, Decl(generatedContextualTyping.ts, 44, 80)) +>member : Symbol(member, Decl(generatedContextualTyping.ts, 45, 11)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +class x41 { public member: { (): Base[]; } = function() { return [d1, d2] } } +>x41 : Symbol(x41, Decl(generatedContextualTyping.ts, 45, 61)) +>member : Symbol(member, Decl(generatedContextualTyping.ts, 46, 11)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +class x42 { public member: { (): Base[]; } = function named() { return [d1, d2] } } +>x42 : Symbol(x42, Decl(generatedContextualTyping.ts, 46, 77)) +>member : Symbol(member, Decl(generatedContextualTyping.ts, 47, 11)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>named : Symbol(named, Decl(generatedContextualTyping.ts, 47, 44)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +class x43 { public member: Base[] = [d1, d2] } +>x43 : Symbol(x43, Decl(generatedContextualTyping.ts, 47, 83)) +>member : Symbol(member, Decl(generatedContextualTyping.ts, 48, 11)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +class x44 { public member: Array = [d1, d2] } +>x44 : Symbol(x44, Decl(generatedContextualTyping.ts, 48, 46)) +>member : Symbol(member, Decl(generatedContextualTyping.ts, 49, 11)) +>Array : Symbol(Array, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +class x45 { public member: { [n: number]: Base; } = [d1, d2] } +>x45 : Symbol(x45, Decl(generatedContextualTyping.ts, 49, 51)) +>member : Symbol(member, Decl(generatedContextualTyping.ts, 50, 11)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 50, 30)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +class x46 { public member: {n: Base[]; } = { n: [d1, d2] } } +>x46 : Symbol(x46, Decl(generatedContextualTyping.ts, 50, 62)) +>member : Symbol(member, Decl(generatedContextualTyping.ts, 51, 11)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 51, 28)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 51, 45)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +class x47 { public member: (s: Base[]) => any = n => { var n: Base[]; return null; } } +>x47 : Symbol(x47, Decl(generatedContextualTyping.ts, 51, 61)) +>member : Symbol(member, Decl(generatedContextualTyping.ts, 52, 11)) +>s : Symbol(s, Decl(generatedContextualTyping.ts, 52, 28)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 52, 47), Decl(generatedContextualTyping.ts, 52, 58)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 52, 47), Decl(generatedContextualTyping.ts, 52, 58)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) + +class x48 { public member: Genric = { func: n => { return [d1, d2]; } } } +>x48 : Symbol(x48, Decl(generatedContextualTyping.ts, 52, 86)) +>member : Symbol(member, Decl(generatedContextualTyping.ts, 53, 11)) +>Genric : Symbol(Genric, Decl(generatedContextualTyping.ts, 3, 42)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>func : Symbol(func, Decl(generatedContextualTyping.ts, 53, 43)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 53, 49)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +class x49 { static member: () => Base[] = () => [d1, d2] } +>x49 : Symbol(x49, Decl(generatedContextualTyping.ts, 53, 79)) +>member : Symbol(x49.member, Decl(generatedContextualTyping.ts, 54, 11)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +class x50 { static member: () => Base[] = function() { return [d1, d2] } } +>x50 : Symbol(x50, Decl(generatedContextualTyping.ts, 54, 58)) +>member : Symbol(x50.member, Decl(generatedContextualTyping.ts, 55, 11)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +class x51 { static member: () => Base[] = function named() { return [d1, d2] } } +>x51 : Symbol(x51, Decl(generatedContextualTyping.ts, 55, 74)) +>member : Symbol(x51.member, Decl(generatedContextualTyping.ts, 56, 11)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>named : Symbol(named, Decl(generatedContextualTyping.ts, 56, 41)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +class x52 { static member: { (): Base[]; } = () => [d1, d2] } +>x52 : Symbol(x52, Decl(generatedContextualTyping.ts, 56, 80)) +>member : Symbol(x52.member, Decl(generatedContextualTyping.ts, 57, 11)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +class x53 { static member: { (): Base[]; } = function() { return [d1, d2] } } +>x53 : Symbol(x53, Decl(generatedContextualTyping.ts, 57, 61)) +>member : Symbol(x53.member, Decl(generatedContextualTyping.ts, 58, 11)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +class x54 { static member: { (): Base[]; } = function named() { return [d1, d2] } } +>x54 : Symbol(x54, Decl(generatedContextualTyping.ts, 58, 77)) +>member : Symbol(x54.member, Decl(generatedContextualTyping.ts, 59, 11)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>named : Symbol(named, Decl(generatedContextualTyping.ts, 59, 44)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +class x55 { static member: Base[] = [d1, d2] } +>x55 : Symbol(x55, Decl(generatedContextualTyping.ts, 59, 83)) +>member : Symbol(x55.member, Decl(generatedContextualTyping.ts, 60, 11)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +class x56 { static member: Array = [d1, d2] } +>x56 : Symbol(x56, Decl(generatedContextualTyping.ts, 60, 46)) +>member : Symbol(x56.member, Decl(generatedContextualTyping.ts, 61, 11)) +>Array : Symbol(Array, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +class x57 { static member: { [n: number]: Base; } = [d1, d2] } +>x57 : Symbol(x57, Decl(generatedContextualTyping.ts, 61, 51)) +>member : Symbol(x57.member, Decl(generatedContextualTyping.ts, 62, 11)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 62, 30)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +class x58 { static member: {n: Base[]; } = { n: [d1, d2] } } +>x58 : Symbol(x58, Decl(generatedContextualTyping.ts, 62, 62)) +>member : Symbol(x58.member, Decl(generatedContextualTyping.ts, 63, 11)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 63, 28)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 63, 45)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +class x59 { static member: (s: Base[]) => any = n => { var n: Base[]; return null; } } +>x59 : Symbol(x59, Decl(generatedContextualTyping.ts, 63, 61)) +>member : Symbol(x59.member, Decl(generatedContextualTyping.ts, 64, 11)) +>s : Symbol(s, Decl(generatedContextualTyping.ts, 64, 28)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 64, 47), Decl(generatedContextualTyping.ts, 64, 58)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 64, 47), Decl(generatedContextualTyping.ts, 64, 58)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) + +class x60 { static member: Genric = { func: n => { return [d1, d2]; } } } +>x60 : Symbol(x60, Decl(generatedContextualTyping.ts, 64, 86)) +>member : Symbol(x60.member, Decl(generatedContextualTyping.ts, 65, 11)) +>Genric : Symbol(Genric, Decl(generatedContextualTyping.ts, 3, 42)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>func : Symbol(func, Decl(generatedContextualTyping.ts, 65, 43)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 65, 49)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +class x61 { private static member: () => Base[] = () => [d1, d2] } +>x61 : Symbol(x61, Decl(generatedContextualTyping.ts, 65, 79)) +>member : Symbol(x61.member, Decl(generatedContextualTyping.ts, 66, 11)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +class x62 { private static member: () => Base[] = function() { return [d1, d2] } } +>x62 : Symbol(x62, Decl(generatedContextualTyping.ts, 66, 66)) +>member : Symbol(x62.member, Decl(generatedContextualTyping.ts, 67, 11)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +class x63 { private static member: () => Base[] = function named() { return [d1, d2] } } +>x63 : Symbol(x63, Decl(generatedContextualTyping.ts, 67, 82)) +>member : Symbol(x63.member, Decl(generatedContextualTyping.ts, 68, 11)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>named : Symbol(named, Decl(generatedContextualTyping.ts, 68, 49)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +class x64 { private static member: { (): Base[]; } = () => [d1, d2] } +>x64 : Symbol(x64, Decl(generatedContextualTyping.ts, 68, 88)) +>member : Symbol(x64.member, Decl(generatedContextualTyping.ts, 69, 11)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +class x65 { private static member: { (): Base[]; } = function() { return [d1, d2] } } +>x65 : Symbol(x65, Decl(generatedContextualTyping.ts, 69, 69)) +>member : Symbol(x65.member, Decl(generatedContextualTyping.ts, 70, 11)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +class x66 { private static member: { (): Base[]; } = function named() { return [d1, d2] } } +>x66 : Symbol(x66, Decl(generatedContextualTyping.ts, 70, 85)) +>member : Symbol(x66.member, Decl(generatedContextualTyping.ts, 71, 11)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>named : Symbol(named, Decl(generatedContextualTyping.ts, 71, 52)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +class x67 { private static member: Base[] = [d1, d2] } +>x67 : Symbol(x67, Decl(generatedContextualTyping.ts, 71, 91)) +>member : Symbol(x67.member, Decl(generatedContextualTyping.ts, 72, 11)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +class x68 { private static member: Array = [d1, d2] } +>x68 : Symbol(x68, Decl(generatedContextualTyping.ts, 72, 54)) +>member : Symbol(x68.member, Decl(generatedContextualTyping.ts, 73, 11)) +>Array : Symbol(Array, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +class x69 { private static member: { [n: number]: Base; } = [d1, d2] } +>x69 : Symbol(x69, Decl(generatedContextualTyping.ts, 73, 59)) +>member : Symbol(x69.member, Decl(generatedContextualTyping.ts, 74, 11)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 74, 38)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +class x70 { private static member: {n: Base[]; } = { n: [d1, d2] } } +>x70 : Symbol(x70, Decl(generatedContextualTyping.ts, 74, 70)) +>member : Symbol(x70.member, Decl(generatedContextualTyping.ts, 75, 11)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 75, 36)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 75, 53)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +class x71 { private static member: (s: Base[]) => any = n => { var n: Base[]; return null; } } +>x71 : Symbol(x71, Decl(generatedContextualTyping.ts, 75, 69)) +>member : Symbol(x71.member, Decl(generatedContextualTyping.ts, 76, 11)) +>s : Symbol(s, Decl(generatedContextualTyping.ts, 76, 36)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 76, 55), Decl(generatedContextualTyping.ts, 76, 66)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 76, 55), Decl(generatedContextualTyping.ts, 76, 66)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) + +class x72 { private static member: Genric = { func: n => { return [d1, d2]; } } } +>x72 : Symbol(x72, Decl(generatedContextualTyping.ts, 76, 94)) +>member : Symbol(x72.member, Decl(generatedContextualTyping.ts, 77, 11)) +>Genric : Symbol(Genric, Decl(generatedContextualTyping.ts, 3, 42)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>func : Symbol(func, Decl(generatedContextualTyping.ts, 77, 51)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 77, 57)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +class x73 { public static member: () => Base[] = () => [d1, d2] } +>x73 : Symbol(x73, Decl(generatedContextualTyping.ts, 77, 87)) +>member : Symbol(x73.member, Decl(generatedContextualTyping.ts, 78, 11)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +class x74 { public static member: () => Base[] = function() { return [d1, d2] } } +>x74 : Symbol(x74, Decl(generatedContextualTyping.ts, 78, 65)) +>member : Symbol(x74.member, Decl(generatedContextualTyping.ts, 79, 11)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +class x75 { public static member: () => Base[] = function named() { return [d1, d2] } } +>x75 : Symbol(x75, Decl(generatedContextualTyping.ts, 79, 81)) +>member : Symbol(x75.member, Decl(generatedContextualTyping.ts, 80, 11)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>named : Symbol(named, Decl(generatedContextualTyping.ts, 80, 48)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +class x76 { public static member: { (): Base[]; } = () => [d1, d2] } +>x76 : Symbol(x76, Decl(generatedContextualTyping.ts, 80, 87)) +>member : Symbol(x76.member, Decl(generatedContextualTyping.ts, 81, 11)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +class x77 { public static member: { (): Base[]; } = function() { return [d1, d2] } } +>x77 : Symbol(x77, Decl(generatedContextualTyping.ts, 81, 68)) +>member : Symbol(x77.member, Decl(generatedContextualTyping.ts, 82, 11)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +class x78 { public static member: { (): Base[]; } = function named() { return [d1, d2] } } +>x78 : Symbol(x78, Decl(generatedContextualTyping.ts, 82, 84)) +>member : Symbol(x78.member, Decl(generatedContextualTyping.ts, 83, 11)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>named : Symbol(named, Decl(generatedContextualTyping.ts, 83, 51)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +class x79 { public static member: Base[] = [d1, d2] } +>x79 : Symbol(x79, Decl(generatedContextualTyping.ts, 83, 90)) +>member : Symbol(x79.member, Decl(generatedContextualTyping.ts, 84, 11)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +class x80 { public static member: Array = [d1, d2] } +>x80 : Symbol(x80, Decl(generatedContextualTyping.ts, 84, 53)) +>member : Symbol(x80.member, Decl(generatedContextualTyping.ts, 85, 11)) +>Array : Symbol(Array, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +class x81 { public static member: { [n: number]: Base; } = [d1, d2] } +>x81 : Symbol(x81, Decl(generatedContextualTyping.ts, 85, 58)) +>member : Symbol(x81.member, Decl(generatedContextualTyping.ts, 86, 11)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 86, 37)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +class x82 { public static member: {n: Base[]; } = { n: [d1, d2] } } +>x82 : Symbol(x82, Decl(generatedContextualTyping.ts, 86, 69)) +>member : Symbol(x82.member, Decl(generatedContextualTyping.ts, 87, 11)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 87, 35)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 87, 52)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +class x83 { public static member: (s: Base[]) => any = n => { var n: Base[]; return null; } } +>x83 : Symbol(x83, Decl(generatedContextualTyping.ts, 87, 68)) +>member : Symbol(x83.member, Decl(generatedContextualTyping.ts, 88, 11)) +>s : Symbol(s, Decl(generatedContextualTyping.ts, 88, 35)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 88, 54), Decl(generatedContextualTyping.ts, 88, 65)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 88, 54), Decl(generatedContextualTyping.ts, 88, 65)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) + +class x84 { public static member: Genric = { func: n => { return [d1, d2]; } } } +>x84 : Symbol(x84, Decl(generatedContextualTyping.ts, 88, 93)) +>member : Symbol(x84.member, Decl(generatedContextualTyping.ts, 89, 11)) +>Genric : Symbol(Genric, Decl(generatedContextualTyping.ts, 3, 42)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>func : Symbol(func, Decl(generatedContextualTyping.ts, 89, 50)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 89, 56)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +class x85 { constructor(parm: () => Base[] = () => [d1, d2]) { } } +>x85 : Symbol(x85, Decl(generatedContextualTyping.ts, 89, 86)) +>parm : Symbol(parm, Decl(generatedContextualTyping.ts, 90, 24)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +class x86 { constructor(parm: () => Base[] = function() { return [d1, d2] }) { } } +>x86 : Symbol(x86, Decl(generatedContextualTyping.ts, 90, 66)) +>parm : Symbol(parm, Decl(generatedContextualTyping.ts, 91, 24)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +class x87 { constructor(parm: () => Base[] = function named() { return [d1, d2] }) { } } +>x87 : Symbol(x87, Decl(generatedContextualTyping.ts, 91, 82)) +>parm : Symbol(parm, Decl(generatedContextualTyping.ts, 92, 24)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>named : Symbol(named, Decl(generatedContextualTyping.ts, 92, 44)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +class x88 { constructor(parm: { (): Base[]; } = () => [d1, d2]) { } } +>x88 : Symbol(x88, Decl(generatedContextualTyping.ts, 92, 88)) +>parm : Symbol(parm, Decl(generatedContextualTyping.ts, 93, 24)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +class x89 { constructor(parm: { (): Base[]; } = function() { return [d1, d2] }) { } } +>x89 : Symbol(x89, Decl(generatedContextualTyping.ts, 93, 69)) +>parm : Symbol(parm, Decl(generatedContextualTyping.ts, 94, 24)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +class x90 { constructor(parm: { (): Base[]; } = function named() { return [d1, d2] }) { } } +>x90 : Symbol(x90, Decl(generatedContextualTyping.ts, 94, 85)) +>parm : Symbol(parm, Decl(generatedContextualTyping.ts, 95, 24)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>named : Symbol(named, Decl(generatedContextualTyping.ts, 95, 47)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +class x91 { constructor(parm: Base[] = [d1, d2]) { } } +>x91 : Symbol(x91, Decl(generatedContextualTyping.ts, 95, 91)) +>parm : Symbol(parm, Decl(generatedContextualTyping.ts, 96, 24)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +class x92 { constructor(parm: Array = [d1, d2]) { } } +>x92 : Symbol(x92, Decl(generatedContextualTyping.ts, 96, 54)) +>parm : Symbol(parm, Decl(generatedContextualTyping.ts, 97, 24)) +>Array : Symbol(Array, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +class x93 { constructor(parm: { [n: number]: Base; } = [d1, d2]) { } } +>x93 : Symbol(x93, Decl(generatedContextualTyping.ts, 97, 59)) +>parm : Symbol(parm, Decl(generatedContextualTyping.ts, 98, 24)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 98, 33)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +class x94 { constructor(parm: {n: Base[]; } = { n: [d1, d2] }) { } } +>x94 : Symbol(x94, Decl(generatedContextualTyping.ts, 98, 70)) +>parm : Symbol(parm, Decl(generatedContextualTyping.ts, 99, 24)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 99, 31)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 99, 48)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +class x95 { constructor(parm: (s: Base[]) => any = n => { var n: Base[]; return null; }) { } } +>x95 : Symbol(x95, Decl(generatedContextualTyping.ts, 99, 69)) +>parm : Symbol(parm, Decl(generatedContextualTyping.ts, 100, 24)) +>s : Symbol(s, Decl(generatedContextualTyping.ts, 100, 31)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 100, 50), Decl(generatedContextualTyping.ts, 100, 61)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 100, 50), Decl(generatedContextualTyping.ts, 100, 61)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) + +class x96 { constructor(parm: Genric = { func: n => { return [d1, d2]; } }) { } } +>x96 : Symbol(x96, Decl(generatedContextualTyping.ts, 100, 94)) +>parm : Symbol(parm, Decl(generatedContextualTyping.ts, 101, 24)) +>Genric : Symbol(Genric, Decl(generatedContextualTyping.ts, 3, 42)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>func : Symbol(func, Decl(generatedContextualTyping.ts, 101, 46)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 101, 52)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +class x97 { constructor(public parm: () => Base[] = () => [d1, d2]) { } } +>x97 : Symbol(x97, Decl(generatedContextualTyping.ts, 101, 87)) +>parm : Symbol(parm, Decl(generatedContextualTyping.ts, 102, 24)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +class x98 { constructor(public parm: () => Base[] = function() { return [d1, d2] }) { } } +>x98 : Symbol(x98, Decl(generatedContextualTyping.ts, 102, 73)) +>parm : Symbol(parm, Decl(generatedContextualTyping.ts, 103, 24)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +class x99 { constructor(public parm: () => Base[] = function named() { return [d1, d2] }) { } } +>x99 : Symbol(x99, Decl(generatedContextualTyping.ts, 103, 89)) +>parm : Symbol(parm, Decl(generatedContextualTyping.ts, 104, 24)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>named : Symbol(named, Decl(generatedContextualTyping.ts, 104, 51)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +class x100 { constructor(public parm: { (): Base[]; } = () => [d1, d2]) { } } +>x100 : Symbol(x100, Decl(generatedContextualTyping.ts, 104, 95)) +>parm : Symbol(parm, Decl(generatedContextualTyping.ts, 105, 25)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +class x101 { constructor(public parm: { (): Base[]; } = function() { return [d1, d2] }) { } } +>x101 : Symbol(x101, Decl(generatedContextualTyping.ts, 105, 77)) +>parm : Symbol(parm, Decl(generatedContextualTyping.ts, 106, 25)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +class x102 { constructor(public parm: { (): Base[]; } = function named() { return [d1, d2] }) { } } +>x102 : Symbol(x102, Decl(generatedContextualTyping.ts, 106, 93)) +>parm : Symbol(parm, Decl(generatedContextualTyping.ts, 107, 25)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>named : Symbol(named, Decl(generatedContextualTyping.ts, 107, 55)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +class x103 { constructor(public parm: Base[] = [d1, d2]) { } } +>x103 : Symbol(x103, Decl(generatedContextualTyping.ts, 107, 99)) +>parm : Symbol(parm, Decl(generatedContextualTyping.ts, 108, 25)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +class x104 { constructor(public parm: Array = [d1, d2]) { } } +>x104 : Symbol(x104, Decl(generatedContextualTyping.ts, 108, 62)) +>parm : Symbol(parm, Decl(generatedContextualTyping.ts, 109, 25)) +>Array : Symbol(Array, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +class x105 { constructor(public parm: { [n: number]: Base; } = [d1, d2]) { } } +>x105 : Symbol(x105, Decl(generatedContextualTyping.ts, 109, 67)) +>parm : Symbol(parm, Decl(generatedContextualTyping.ts, 110, 25)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 110, 41)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +class x106 { constructor(public parm: {n: Base[]; } = { n: [d1, d2] }) { } } +>x106 : Symbol(x106, Decl(generatedContextualTyping.ts, 110, 78)) +>parm : Symbol(parm, Decl(generatedContextualTyping.ts, 111, 25)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 111, 39)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 111, 56)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +class x107 { constructor(public parm: (s: Base[]) => any = n => { var n: Base[]; return null; }) { } } +>x107 : Symbol(x107, Decl(generatedContextualTyping.ts, 111, 77)) +>parm : Symbol(parm, Decl(generatedContextualTyping.ts, 112, 25)) +>s : Symbol(s, Decl(generatedContextualTyping.ts, 112, 39)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 112, 58), Decl(generatedContextualTyping.ts, 112, 69)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 112, 58), Decl(generatedContextualTyping.ts, 112, 69)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) + +class x108 { constructor(public parm: Genric = { func: n => { return [d1, d2]; } }) { } } +>x108 : Symbol(x108, Decl(generatedContextualTyping.ts, 112, 102)) +>parm : Symbol(parm, Decl(generatedContextualTyping.ts, 113, 25)) +>Genric : Symbol(Genric, Decl(generatedContextualTyping.ts, 3, 42)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>func : Symbol(func, Decl(generatedContextualTyping.ts, 113, 54)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 113, 60)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +class x109 { constructor(private parm: () => Base[] = () => [d1, d2]) { } } +>x109 : Symbol(x109, Decl(generatedContextualTyping.ts, 113, 95)) +>parm : Symbol(parm, Decl(generatedContextualTyping.ts, 114, 25)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +class x110 { constructor(private parm: () => Base[] = function() { return [d1, d2] }) { } } +>x110 : Symbol(x110, Decl(generatedContextualTyping.ts, 114, 75)) +>parm : Symbol(parm, Decl(generatedContextualTyping.ts, 115, 25)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +class x111 { constructor(private parm: () => Base[] = function named() { return [d1, d2] }) { } } +>x111 : Symbol(x111, Decl(generatedContextualTyping.ts, 115, 91)) +>parm : Symbol(parm, Decl(generatedContextualTyping.ts, 116, 25)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>named : Symbol(named, Decl(generatedContextualTyping.ts, 116, 53)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +class x112 { constructor(private parm: { (): Base[]; } = () => [d1, d2]) { } } +>x112 : Symbol(x112, Decl(generatedContextualTyping.ts, 116, 97)) +>parm : Symbol(parm, Decl(generatedContextualTyping.ts, 117, 25)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +class x113 { constructor(private parm: { (): Base[]; } = function() { return [d1, d2] }) { } } +>x113 : Symbol(x113, Decl(generatedContextualTyping.ts, 117, 78)) +>parm : Symbol(parm, Decl(generatedContextualTyping.ts, 118, 25)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +class x114 { constructor(private parm: { (): Base[]; } = function named() { return [d1, d2] }) { } } +>x114 : Symbol(x114, Decl(generatedContextualTyping.ts, 118, 94)) +>parm : Symbol(parm, Decl(generatedContextualTyping.ts, 119, 25)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>named : Symbol(named, Decl(generatedContextualTyping.ts, 119, 56)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +class x115 { constructor(private parm: Base[] = [d1, d2]) { } } +>x115 : Symbol(x115, Decl(generatedContextualTyping.ts, 119, 100)) +>parm : Symbol(parm, Decl(generatedContextualTyping.ts, 120, 25)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +class x116 { constructor(private parm: Array = [d1, d2]) { } } +>x116 : Symbol(x116, Decl(generatedContextualTyping.ts, 120, 63)) +>parm : Symbol(parm, Decl(generatedContextualTyping.ts, 121, 25)) +>Array : Symbol(Array, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +class x117 { constructor(private parm: { [n: number]: Base; } = [d1, d2]) { } } +>x117 : Symbol(x117, Decl(generatedContextualTyping.ts, 121, 68)) +>parm : Symbol(parm, Decl(generatedContextualTyping.ts, 122, 25)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 122, 42)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +class x118 { constructor(private parm: {n: Base[]; } = { n: [d1, d2] }) { } } +>x118 : Symbol(x118, Decl(generatedContextualTyping.ts, 122, 79)) +>parm : Symbol(parm, Decl(generatedContextualTyping.ts, 123, 25)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 123, 40)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 123, 57)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +class x119 { constructor(private parm: (s: Base[]) => any = n => { var n: Base[]; return null; }) { } } +>x119 : Symbol(x119, Decl(generatedContextualTyping.ts, 123, 78)) +>parm : Symbol(parm, Decl(generatedContextualTyping.ts, 124, 25)) +>s : Symbol(s, Decl(generatedContextualTyping.ts, 124, 40)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 124, 59), Decl(generatedContextualTyping.ts, 124, 70)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 124, 59), Decl(generatedContextualTyping.ts, 124, 70)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) + +class x120 { constructor(private parm: Genric = { func: n => { return [d1, d2]; } }) { } } +>x120 : Symbol(x120, Decl(generatedContextualTyping.ts, 124, 103)) +>parm : Symbol(parm, Decl(generatedContextualTyping.ts, 125, 25)) +>Genric : Symbol(Genric, Decl(generatedContextualTyping.ts, 3, 42)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>func : Symbol(func, Decl(generatedContextualTyping.ts, 125, 55)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 125, 61)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +function x121(parm: () => Base[] = () => [d1, d2]) { } +>x121 : Symbol(x121, Decl(generatedContextualTyping.ts, 125, 96)) +>parm : Symbol(parm, Decl(generatedContextualTyping.ts, 126, 14)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +function x122(parm: () => Base[] = function() { return [d1, d2] }) { } +>x122 : Symbol(x122, Decl(generatedContextualTyping.ts, 126, 54)) +>parm : Symbol(parm, Decl(generatedContextualTyping.ts, 127, 14)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +function x123(parm: () => Base[] = function named() { return [d1, d2] }) { } +>x123 : Symbol(x123, Decl(generatedContextualTyping.ts, 127, 70)) +>parm : Symbol(parm, Decl(generatedContextualTyping.ts, 128, 14)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>named : Symbol(named, Decl(generatedContextualTyping.ts, 128, 34)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +function x124(parm: { (): Base[]; } = () => [d1, d2]) { } +>x124 : Symbol(x124, Decl(generatedContextualTyping.ts, 128, 76)) +>parm : Symbol(parm, Decl(generatedContextualTyping.ts, 129, 14)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +function x125(parm: { (): Base[]; } = function() { return [d1, d2] }) { } +>x125 : Symbol(x125, Decl(generatedContextualTyping.ts, 129, 57)) +>parm : Symbol(parm, Decl(generatedContextualTyping.ts, 130, 14)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +function x126(parm: { (): Base[]; } = function named() { return [d1, d2] }) { } +>x126 : Symbol(x126, Decl(generatedContextualTyping.ts, 130, 73)) +>parm : Symbol(parm, Decl(generatedContextualTyping.ts, 131, 14)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>named : Symbol(named, Decl(generatedContextualTyping.ts, 131, 37)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +function x127(parm: Base[] = [d1, d2]) { } +>x127 : Symbol(x127, Decl(generatedContextualTyping.ts, 131, 79)) +>parm : Symbol(parm, Decl(generatedContextualTyping.ts, 132, 14)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +function x128(parm: Array = [d1, d2]) { } +>x128 : Symbol(x128, Decl(generatedContextualTyping.ts, 132, 42)) +>parm : Symbol(parm, Decl(generatedContextualTyping.ts, 133, 14)) +>Array : Symbol(Array, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +function x129(parm: { [n: number]: Base; } = [d1, d2]) { } +>x129 : Symbol(x129, Decl(generatedContextualTyping.ts, 133, 47)) +>parm : Symbol(parm, Decl(generatedContextualTyping.ts, 134, 14)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 134, 23)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +function x130(parm: {n: Base[]; } = { n: [d1, d2] }) { } +>x130 : Symbol(x130, Decl(generatedContextualTyping.ts, 134, 58)) +>parm : Symbol(parm, Decl(generatedContextualTyping.ts, 135, 14)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 135, 21)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 135, 38)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +function x131(parm: (s: Base[]) => any = n => { var n: Base[]; return null; }) { } +>x131 : Symbol(x131, Decl(generatedContextualTyping.ts, 135, 57)) +>parm : Symbol(parm, Decl(generatedContextualTyping.ts, 136, 14)) +>s : Symbol(s, Decl(generatedContextualTyping.ts, 136, 21)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 136, 40), Decl(generatedContextualTyping.ts, 136, 51)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 136, 40), Decl(generatedContextualTyping.ts, 136, 51)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) + +function x132(parm: Genric = { func: n => { return [d1, d2]; } }) { } +>x132 : Symbol(x132, Decl(generatedContextualTyping.ts, 136, 82)) +>parm : Symbol(parm, Decl(generatedContextualTyping.ts, 137, 14)) +>Genric : Symbol(Genric, Decl(generatedContextualTyping.ts, 3, 42)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>func : Symbol(func, Decl(generatedContextualTyping.ts, 137, 36)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 137, 42)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +function x133(): () => Base[] { return () => [d1, d2]; } +>x133 : Symbol(x133, Decl(generatedContextualTyping.ts, 137, 75)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +function x134(): () => Base[] { return function() { return [d1, d2] }; } +>x134 : Symbol(x134, Decl(generatedContextualTyping.ts, 138, 56)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +function x135(): () => Base[] { return function named() { return [d1, d2] }; } +>x135 : Symbol(x135, Decl(generatedContextualTyping.ts, 139, 72)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>named : Symbol(named, Decl(generatedContextualTyping.ts, 140, 38)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +function x136(): { (): Base[]; } { return () => [d1, d2]; } +>x136 : Symbol(x136, Decl(generatedContextualTyping.ts, 140, 78)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +function x137(): { (): Base[]; } { return function() { return [d1, d2] }; } +>x137 : Symbol(x137, Decl(generatedContextualTyping.ts, 141, 59)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +function x138(): { (): Base[]; } { return function named() { return [d1, d2] }; } +>x138 : Symbol(x138, Decl(generatedContextualTyping.ts, 142, 75)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>named : Symbol(named, Decl(generatedContextualTyping.ts, 143, 41)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +function x139(): Base[] { return [d1, d2]; } +>x139 : Symbol(x139, Decl(generatedContextualTyping.ts, 143, 81)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +function x140(): Array { return [d1, d2]; } +>x140 : Symbol(x140, Decl(generatedContextualTyping.ts, 144, 44)) +>Array : Symbol(Array, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +function x141(): { [n: number]: Base; } { return [d1, d2]; } +>x141 : Symbol(x141, Decl(generatedContextualTyping.ts, 145, 49)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 146, 20)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +function x142(): {n: Base[]; } { return { n: [d1, d2] }; } +>x142 : Symbol(x142, Decl(generatedContextualTyping.ts, 146, 60)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 147, 18)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 147, 42)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +function x143(): (s: Base[]) => any { return n => { var n: Base[]; return null; }; } +>x143 : Symbol(x143, Decl(generatedContextualTyping.ts, 147, 59)) +>s : Symbol(s, Decl(generatedContextualTyping.ts, 148, 18)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 148, 44), Decl(generatedContextualTyping.ts, 148, 55)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 148, 44), Decl(generatedContextualTyping.ts, 148, 55)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) + +function x144(): Genric { return { func: n => { return [d1, d2]; } }; } +>x144 : Symbol(x144, Decl(generatedContextualTyping.ts, 148, 84)) +>Genric : Symbol(Genric, Decl(generatedContextualTyping.ts, 3, 42)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>func : Symbol(func, Decl(generatedContextualTyping.ts, 149, 40)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 149, 46)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +function x145(): () => Base[] { return () => [d1, d2]; return () => [d1, d2]; } +>x145 : Symbol(x145, Decl(generatedContextualTyping.ts, 149, 77)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +function x146(): () => Base[] { return function() { return [d1, d2] }; return function() { return [d1, d2] }; } +>x146 : Symbol(x146, Decl(generatedContextualTyping.ts, 150, 79)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +function x147(): () => Base[] { return function named() { return [d1, d2] }; return function named() { return [d1, d2] }; } +>x147 : Symbol(x147, Decl(generatedContextualTyping.ts, 151, 111)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>named : Symbol(named, Decl(generatedContextualTyping.ts, 152, 38)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) +>named : Symbol(named, Decl(generatedContextualTyping.ts, 152, 83)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +function x148(): { (): Base[]; } { return () => [d1, d2]; return () => [d1, d2]; } +>x148 : Symbol(x148, Decl(generatedContextualTyping.ts, 152, 123)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +function x149(): { (): Base[]; } { return function() { return [d1, d2] }; return function() { return [d1, d2] }; } +>x149 : Symbol(x149, Decl(generatedContextualTyping.ts, 153, 82)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +function x150(): { (): Base[]; } { return function named() { return [d1, d2] }; return function named() { return [d1, d2] }; } +>x150 : Symbol(x150, Decl(generatedContextualTyping.ts, 154, 114)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>named : Symbol(named, Decl(generatedContextualTyping.ts, 155, 41)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) +>named : Symbol(named, Decl(generatedContextualTyping.ts, 155, 86)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +function x151(): Base[] { return [d1, d2]; return [d1, d2]; } +>x151 : Symbol(x151, Decl(generatedContextualTyping.ts, 155, 126)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +function x152(): Array { return [d1, d2]; return [d1, d2]; } +>x152 : Symbol(x152, Decl(generatedContextualTyping.ts, 156, 61)) +>Array : Symbol(Array, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +function x153(): { [n: number]: Base; } { return [d1, d2]; return [d1, d2]; } +>x153 : Symbol(x153, Decl(generatedContextualTyping.ts, 157, 66)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 158, 20)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +function x154(): {n: Base[]; } { return { n: [d1, d2] }; return { n: [d1, d2] }; } +>x154 : Symbol(x154, Decl(generatedContextualTyping.ts, 158, 77)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 159, 18)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 159, 42)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 159, 66)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +function x155(): (s: Base[]) => any { return n => { var n: Base[]; return null; }; return n => { var n: Base[]; return null; }; } +>x155 : Symbol(x155, Decl(generatedContextualTyping.ts, 159, 83)) +>s : Symbol(s, Decl(generatedContextualTyping.ts, 160, 18)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 160, 44), Decl(generatedContextualTyping.ts, 160, 55)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 160, 44), Decl(generatedContextualTyping.ts, 160, 55)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 160, 89), Decl(generatedContextualTyping.ts, 160, 100)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 160, 89), Decl(generatedContextualTyping.ts, 160, 100)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) + +function x156(): Genric { return { func: n => { return [d1, d2]; } }; return { func: n => { return [d1, d2]; } }; } +>x156 : Symbol(x156, Decl(generatedContextualTyping.ts, 160, 129)) +>Genric : Symbol(Genric, Decl(generatedContextualTyping.ts, 3, 42)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>func : Symbol(func, Decl(generatedContextualTyping.ts, 161, 40)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 161, 46)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) +>func : Symbol(func, Decl(generatedContextualTyping.ts, 161, 84)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 161, 90)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +var x157: () => () => Base[] = () => { return () => [d1, d2]; }; +>x157 : Symbol(x157, Decl(generatedContextualTyping.ts, 162, 3)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +var x158: () => () => Base[] = () => { return function() { return [d1, d2] }; }; +>x158 : Symbol(x158, Decl(generatedContextualTyping.ts, 163, 3)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +var x159: () => () => Base[] = () => { return function named() { return [d1, d2] }; }; +>x159 : Symbol(x159, Decl(generatedContextualTyping.ts, 164, 3)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>named : Symbol(named, Decl(generatedContextualTyping.ts, 164, 45)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +var x160: () => { (): Base[]; } = () => { return () => [d1, d2]; }; +>x160 : Symbol(x160, Decl(generatedContextualTyping.ts, 165, 3)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +var x161: () => { (): Base[]; } = () => { return function() { return [d1, d2] }; }; +>x161 : Symbol(x161, Decl(generatedContextualTyping.ts, 166, 3)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +var x162: () => { (): Base[]; } = () => { return function named() { return [d1, d2] }; }; +>x162 : Symbol(x162, Decl(generatedContextualTyping.ts, 167, 3)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>named : Symbol(named, Decl(generatedContextualTyping.ts, 167, 48)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +var x163: () => Base[] = () => { return [d1, d2]; }; +>x163 : Symbol(x163, Decl(generatedContextualTyping.ts, 168, 3)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +var x164: () => Array = () => { return [d1, d2]; }; +>x164 : Symbol(x164, Decl(generatedContextualTyping.ts, 169, 3)) +>Array : Symbol(Array, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +var x165: () => { [n: number]: Base; } = () => { return [d1, d2]; }; +>x165 : Symbol(x165, Decl(generatedContextualTyping.ts, 170, 3)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 170, 19)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +var x166: () => {n: Base[]; } = () => { return { n: [d1, d2] }; }; +>x166 : Symbol(x166, Decl(generatedContextualTyping.ts, 171, 3)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 171, 17)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 171, 49)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +var x167: () => (s: Base[]) => any = () => { return n => { var n: Base[]; return null; }; }; +>x167 : Symbol(x167, Decl(generatedContextualTyping.ts, 172, 3)) +>s : Symbol(s, Decl(generatedContextualTyping.ts, 172, 17)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 172, 51), Decl(generatedContextualTyping.ts, 172, 62)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 172, 51), Decl(generatedContextualTyping.ts, 172, 62)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) + +var x168: () => Genric = () => { return { func: n => { return [d1, d2]; } }; }; +>x168 : Symbol(x168, Decl(generatedContextualTyping.ts, 173, 3)) +>Genric : Symbol(Genric, Decl(generatedContextualTyping.ts, 3, 42)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>func : Symbol(func, Decl(generatedContextualTyping.ts, 173, 47)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 173, 53)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +var x169: () => () => Base[] = function() { return () => [d1, d2]; }; +>x169 : Symbol(x169, Decl(generatedContextualTyping.ts, 174, 3)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +var x170: () => () => Base[] = function() { return function() { return [d1, d2] }; }; +>x170 : Symbol(x170, Decl(generatedContextualTyping.ts, 175, 3)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +var x171: () => () => Base[] = function() { return function named() { return [d1, d2] }; }; +>x171 : Symbol(x171, Decl(generatedContextualTyping.ts, 176, 3)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>named : Symbol(named, Decl(generatedContextualTyping.ts, 176, 50)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +var x172: () => { (): Base[]; } = function() { return () => [d1, d2]; }; +>x172 : Symbol(x172, Decl(generatedContextualTyping.ts, 177, 3)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +var x173: () => { (): Base[]; } = function() { return function() { return [d1, d2] }; }; +>x173 : Symbol(x173, Decl(generatedContextualTyping.ts, 178, 3)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +var x174: () => { (): Base[]; } = function() { return function named() { return [d1, d2] }; }; +>x174 : Symbol(x174, Decl(generatedContextualTyping.ts, 179, 3)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>named : Symbol(named, Decl(generatedContextualTyping.ts, 179, 53)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +var x175: () => Base[] = function() { return [d1, d2]; }; +>x175 : Symbol(x175, Decl(generatedContextualTyping.ts, 180, 3)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +var x176: () => Array = function() { return [d1, d2]; }; +>x176 : Symbol(x176, Decl(generatedContextualTyping.ts, 181, 3)) +>Array : Symbol(Array, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +var x177: () => { [n: number]: Base; } = function() { return [d1, d2]; }; +>x177 : Symbol(x177, Decl(generatedContextualTyping.ts, 182, 3)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 182, 19)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +var x178: () => {n: Base[]; } = function() { return { n: [d1, d2] }; }; +>x178 : Symbol(x178, Decl(generatedContextualTyping.ts, 183, 3)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 183, 17)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 183, 54)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +var x179: () => (s: Base[]) => any = function() { return n => { var n: Base[]; return null; }; }; +>x179 : Symbol(x179, Decl(generatedContextualTyping.ts, 184, 3)) +>s : Symbol(s, Decl(generatedContextualTyping.ts, 184, 17)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 184, 56), Decl(generatedContextualTyping.ts, 184, 67)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 184, 56), Decl(generatedContextualTyping.ts, 184, 67)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) + +var x180: () => Genric = function() { return { func: n => { return [d1, d2]; } }; }; +>x180 : Symbol(x180, Decl(generatedContextualTyping.ts, 185, 3)) +>Genric : Symbol(Genric, Decl(generatedContextualTyping.ts, 3, 42)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>func : Symbol(func, Decl(generatedContextualTyping.ts, 185, 52)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 185, 58)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +module x181 { var t: () => Base[] = () => [d1, d2]; } +>x181 : Symbol(x181, Decl(generatedContextualTyping.ts, 185, 90)) +>t : Symbol(t, Decl(generatedContextualTyping.ts, 186, 17)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +module x182 { var t: () => Base[] = function() { return [d1, d2] }; } +>x182 : Symbol(x182, Decl(generatedContextualTyping.ts, 186, 53)) +>t : Symbol(t, Decl(generatedContextualTyping.ts, 187, 17)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +module x183 { var t: () => Base[] = function named() { return [d1, d2] }; } +>x183 : Symbol(x183, Decl(generatedContextualTyping.ts, 187, 69)) +>t : Symbol(t, Decl(generatedContextualTyping.ts, 188, 17)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>named : Symbol(named, Decl(generatedContextualTyping.ts, 188, 35)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +module x184 { var t: { (): Base[]; } = () => [d1, d2]; } +>x184 : Symbol(x184, Decl(generatedContextualTyping.ts, 188, 75)) +>t : Symbol(t, Decl(generatedContextualTyping.ts, 189, 17)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +module x185 { var t: { (): Base[]; } = function() { return [d1, d2] }; } +>x185 : Symbol(x185, Decl(generatedContextualTyping.ts, 189, 56)) +>t : Symbol(t, Decl(generatedContextualTyping.ts, 190, 17)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +module x186 { var t: { (): Base[]; } = function named() { return [d1, d2] }; } +>x186 : Symbol(x186, Decl(generatedContextualTyping.ts, 190, 72)) +>t : Symbol(t, Decl(generatedContextualTyping.ts, 191, 17)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>named : Symbol(named, Decl(generatedContextualTyping.ts, 191, 38)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +module x187 { var t: Base[] = [d1, d2]; } +>x187 : Symbol(x187, Decl(generatedContextualTyping.ts, 191, 78)) +>t : Symbol(t, Decl(generatedContextualTyping.ts, 192, 17)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +module x188 { var t: Array = [d1, d2]; } +>x188 : Symbol(x188, Decl(generatedContextualTyping.ts, 192, 41)) +>t : Symbol(t, Decl(generatedContextualTyping.ts, 193, 17)) +>Array : Symbol(Array, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +module x189 { var t: { [n: number]: Base; } = [d1, d2]; } +>x189 : Symbol(x189, Decl(generatedContextualTyping.ts, 193, 46)) +>t : Symbol(t, Decl(generatedContextualTyping.ts, 194, 17)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 194, 24)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +module x190 { var t: {n: Base[]; } = { n: [d1, d2] }; } +>x190 : Symbol(x190, Decl(generatedContextualTyping.ts, 194, 57)) +>t : Symbol(t, Decl(generatedContextualTyping.ts, 195, 17)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 195, 22)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 195, 39)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +module x191 { var t: (s: Base[]) => any = n => { var n: Base[]; return null; }; } +>x191 : Symbol(x191, Decl(generatedContextualTyping.ts, 195, 56)) +>t : Symbol(t, Decl(generatedContextualTyping.ts, 196, 17)) +>s : Symbol(s, Decl(generatedContextualTyping.ts, 196, 22)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 196, 41), Decl(generatedContextualTyping.ts, 196, 52)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 196, 41), Decl(generatedContextualTyping.ts, 196, 52)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) + +module x192 { var t: Genric = { func: n => { return [d1, d2]; } }; } +>x192 : Symbol(x192, Decl(generatedContextualTyping.ts, 196, 81)) +>t : Symbol(t, Decl(generatedContextualTyping.ts, 197, 17)) +>Genric : Symbol(Genric, Decl(generatedContextualTyping.ts, 3, 42)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>func : Symbol(func, Decl(generatedContextualTyping.ts, 197, 37)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 197, 43)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +module x193 { export var t: () => Base[] = () => [d1, d2]; } +>x193 : Symbol(x193, Decl(generatedContextualTyping.ts, 197, 74)) +>t : Symbol(t, Decl(generatedContextualTyping.ts, 198, 24)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +module x194 { export var t: () => Base[] = function() { return [d1, d2] }; } +>x194 : Symbol(x194, Decl(generatedContextualTyping.ts, 198, 60)) +>t : Symbol(t, Decl(generatedContextualTyping.ts, 199, 24)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +module x195 { export var t: () => Base[] = function named() { return [d1, d2] }; } +>x195 : Symbol(x195, Decl(generatedContextualTyping.ts, 199, 76)) +>t : Symbol(t, Decl(generatedContextualTyping.ts, 200, 24)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>named : Symbol(named, Decl(generatedContextualTyping.ts, 200, 42)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +module x196 { export var t: { (): Base[]; } = () => [d1, d2]; } +>x196 : Symbol(x196, Decl(generatedContextualTyping.ts, 200, 82)) +>t : Symbol(t, Decl(generatedContextualTyping.ts, 201, 24)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +module x197 { export var t: { (): Base[]; } = function() { return [d1, d2] }; } +>x197 : Symbol(x197, Decl(generatedContextualTyping.ts, 201, 63)) +>t : Symbol(t, Decl(generatedContextualTyping.ts, 202, 24)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +module x198 { export var t: { (): Base[]; } = function named() { return [d1, d2] }; } +>x198 : Symbol(x198, Decl(generatedContextualTyping.ts, 202, 79)) +>t : Symbol(t, Decl(generatedContextualTyping.ts, 203, 24)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>named : Symbol(named, Decl(generatedContextualTyping.ts, 203, 45)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +module x199 { export var t: Base[] = [d1, d2]; } +>x199 : Symbol(x199, Decl(generatedContextualTyping.ts, 203, 85)) +>t : Symbol(t, Decl(generatedContextualTyping.ts, 204, 24)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +module x200 { export var t: Array = [d1, d2]; } +>x200 : Symbol(x200, Decl(generatedContextualTyping.ts, 204, 48)) +>t : Symbol(t, Decl(generatedContextualTyping.ts, 205, 24)) +>Array : Symbol(Array, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +module x201 { export var t: { [n: number]: Base; } = [d1, d2]; } +>x201 : Symbol(x201, Decl(generatedContextualTyping.ts, 205, 53)) +>t : Symbol(t, Decl(generatedContextualTyping.ts, 206, 24)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 206, 31)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +module x202 { export var t: {n: Base[]; } = { n: [d1, d2] }; } +>x202 : Symbol(x202, Decl(generatedContextualTyping.ts, 206, 64)) +>t : Symbol(t, Decl(generatedContextualTyping.ts, 207, 24)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 207, 29)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 207, 46)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +module x203 { export var t: (s: Base[]) => any = n => { var n: Base[]; return null; }; } +>x203 : Symbol(x203, Decl(generatedContextualTyping.ts, 207, 63)) +>t : Symbol(t, Decl(generatedContextualTyping.ts, 208, 24)) +>s : Symbol(s, Decl(generatedContextualTyping.ts, 208, 29)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 208, 48), Decl(generatedContextualTyping.ts, 208, 59)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 208, 48), Decl(generatedContextualTyping.ts, 208, 59)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) + +module x204 { export var t: Genric = { func: n => { return [d1, d2]; } }; } +>x204 : Symbol(x204, Decl(generatedContextualTyping.ts, 208, 88)) +>t : Symbol(t, Decl(generatedContextualTyping.ts, 209, 24)) +>Genric : Symbol(Genric, Decl(generatedContextualTyping.ts, 3, 42)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>func : Symbol(func, Decl(generatedContextualTyping.ts, 209, 44)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 209, 50)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +var x206 = <() => Base[]>function() { return [d1, d2] }; +>x206 : Symbol(x206, Decl(generatedContextualTyping.ts, 210, 3)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +var x207 = <() => Base[]>function named() { return [d1, d2] }; +>x207 : Symbol(x207, Decl(generatedContextualTyping.ts, 211, 3)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>named : Symbol(named, Decl(generatedContextualTyping.ts, 211, 25)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +var x209 = <{ (): Base[]; }>function() { return [d1, d2] }; +>x209 : Symbol(x209, Decl(generatedContextualTyping.ts, 212, 3)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +var x210 = <{ (): Base[]; }>function named() { return [d1, d2] }; +>x210 : Symbol(x210, Decl(generatedContextualTyping.ts, 213, 3)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>named : Symbol(named, Decl(generatedContextualTyping.ts, 213, 28)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +var x211 = [d1, d2]; +>x211 : Symbol(x211, Decl(generatedContextualTyping.ts, 214, 3)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +var x212 = >[d1, d2]; +>x212 : Symbol(x212, Decl(generatedContextualTyping.ts, 215, 3)) +>Array : Symbol(Array, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +var x213 = <{ [n: number]: Base; }>[d1, d2]; +>x213 : Symbol(x213, Decl(generatedContextualTyping.ts, 216, 3)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 216, 15)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +var x214 = <{n: Base[]; } >{ n: [d1, d2] }; +>x214 : Symbol(x214, Decl(generatedContextualTyping.ts, 217, 3)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 217, 13)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 217, 28)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +var x216 = >{ func: n => { return [d1, d2]; } }; +>x216 : Symbol(x216, Decl(generatedContextualTyping.ts, 218, 3)) +>Genric : Symbol(Genric, Decl(generatedContextualTyping.ts, 3, 42)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>func : Symbol(func, Decl(generatedContextualTyping.ts, 218, 26)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 218, 32)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +var x217 = (<() => Base[]>undefined) || function() { return [d1, d2] }; +>x217 : Symbol(x217, Decl(generatedContextualTyping.ts, 219, 3)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>undefined : Symbol(undefined) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +var x218 = (<() => Base[]>undefined) || function named() { return [d1, d2] }; +>x218 : Symbol(x218, Decl(generatedContextualTyping.ts, 220, 3)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>undefined : Symbol(undefined) +>named : Symbol(named, Decl(generatedContextualTyping.ts, 220, 39)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +var x219 = (<{ (): Base[]; }>undefined) || function() { return [d1, d2] }; +>x219 : Symbol(x219, Decl(generatedContextualTyping.ts, 221, 3)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>undefined : Symbol(undefined) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +var x220 = (<{ (): Base[]; }>undefined) || function named() { return [d1, d2] }; +>x220 : Symbol(x220, Decl(generatedContextualTyping.ts, 222, 3)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>undefined : Symbol(undefined) +>named : Symbol(named, Decl(generatedContextualTyping.ts, 222, 42)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +var x221 = (undefined) || [d1, d2]; +>x221 : Symbol(x221, Decl(generatedContextualTyping.ts, 223, 3)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>undefined : Symbol(undefined) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +var x222 = (>undefined) || [d1, d2]; +>x222 : Symbol(x222, Decl(generatedContextualTyping.ts, 224, 3)) +>Array : Symbol(Array, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>undefined : Symbol(undefined) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +var x223 = (<{ [n: number]: Base; }>undefined) || [d1, d2]; +>x223 : Symbol(x223, Decl(generatedContextualTyping.ts, 225, 3)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 225, 16)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>undefined : Symbol(undefined) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +var x224 = (<{n: Base[]; } >undefined) || { n: [d1, d2] }; +>x224 : Symbol(x224, Decl(generatedContextualTyping.ts, 226, 3)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 226, 14)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>undefined : Symbol(undefined) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 226, 43)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +var x225: () => Base[]; x225 = () => [d1, d2]; +>x225 : Symbol(x225, Decl(generatedContextualTyping.ts, 227, 3)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>x225 : Symbol(x225, Decl(generatedContextualTyping.ts, 227, 3)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +var x226: () => Base[]; x226 = function() { return [d1, d2] }; +>x226 : Symbol(x226, Decl(generatedContextualTyping.ts, 228, 3)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>x226 : Symbol(x226, Decl(generatedContextualTyping.ts, 228, 3)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +var x227: () => Base[]; x227 = function named() { return [d1, d2] }; +>x227 : Symbol(x227, Decl(generatedContextualTyping.ts, 229, 3)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>x227 : Symbol(x227, Decl(generatedContextualTyping.ts, 229, 3)) +>named : Symbol(named, Decl(generatedContextualTyping.ts, 229, 30)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +var x228: { (): Base[]; }; x228 = () => [d1, d2]; +>x228 : Symbol(x228, Decl(generatedContextualTyping.ts, 230, 3)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>x228 : Symbol(x228, Decl(generatedContextualTyping.ts, 230, 3)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +var x229: { (): Base[]; }; x229 = function() { return [d1, d2] }; +>x229 : Symbol(x229, Decl(generatedContextualTyping.ts, 231, 3)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>x229 : Symbol(x229, Decl(generatedContextualTyping.ts, 231, 3)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +var x230: { (): Base[]; }; x230 = function named() { return [d1, d2] }; +>x230 : Symbol(x230, Decl(generatedContextualTyping.ts, 232, 3)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>x230 : Symbol(x230, Decl(generatedContextualTyping.ts, 232, 3)) +>named : Symbol(named, Decl(generatedContextualTyping.ts, 232, 33)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +var x231: Base[]; x231 = [d1, d2]; +>x231 : Symbol(x231, Decl(generatedContextualTyping.ts, 233, 3)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>x231 : Symbol(x231, Decl(generatedContextualTyping.ts, 233, 3)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +var x232: Array; x232 = [d1, d2]; +>x232 : Symbol(x232, Decl(generatedContextualTyping.ts, 234, 3)) +>Array : Symbol(Array, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>x232 : Symbol(x232, Decl(generatedContextualTyping.ts, 234, 3)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +var x233: { [n: number]: Base; }; x233 = [d1, d2]; +>x233 : Symbol(x233, Decl(generatedContextualTyping.ts, 235, 3)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 235, 13)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>x233 : Symbol(x233, Decl(generatedContextualTyping.ts, 235, 3)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +var x234: {n: Base[]; } ; x234 = { n: [d1, d2] }; +>x234 : Symbol(x234, Decl(generatedContextualTyping.ts, 236, 3)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 236, 11)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>x234 : Symbol(x234, Decl(generatedContextualTyping.ts, 236, 3)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 236, 34)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +var x235: (s: Base[]) => any; x235 = n => { var n: Base[]; return null; }; +>x235 : Symbol(x235, Decl(generatedContextualTyping.ts, 237, 3)) +>s : Symbol(s, Decl(generatedContextualTyping.ts, 237, 11)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>x235 : Symbol(x235, Decl(generatedContextualTyping.ts, 237, 3)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 237, 36), Decl(generatedContextualTyping.ts, 237, 47)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 237, 36), Decl(generatedContextualTyping.ts, 237, 47)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) + +var x236: Genric; x236 = { func: n => { return [d1, d2]; } }; +>x236 : Symbol(x236, Decl(generatedContextualTyping.ts, 238, 3)) +>Genric : Symbol(Genric, Decl(generatedContextualTyping.ts, 3, 42)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>x236 : Symbol(x236, Decl(generatedContextualTyping.ts, 238, 3)) +>func : Symbol(func, Decl(generatedContextualTyping.ts, 238, 32)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 238, 38)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +var x237: { n: () => Base[]; } = { n: () => [d1, d2] }; +>x237 : Symbol(x237, Decl(generatedContextualTyping.ts, 239, 3)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 239, 11)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 239, 34)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +var x238: { n: () => Base[]; } = { n: function() { return [d1, d2] } }; +>x238 : Symbol(x238, Decl(generatedContextualTyping.ts, 240, 3)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 240, 11)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 240, 34)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +var x239: { n: () => Base[]; } = { n: function named() { return [d1, d2] } }; +>x239 : Symbol(x239, Decl(generatedContextualTyping.ts, 241, 3)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 241, 11)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 241, 34)) +>named : Symbol(named, Decl(generatedContextualTyping.ts, 241, 37)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +var x240: { n: { (): Base[]; }; } = { n: () => [d1, d2] }; +>x240 : Symbol(x240, Decl(generatedContextualTyping.ts, 242, 3)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 242, 11)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 242, 37)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +var x241: { n: { (): Base[]; }; } = { n: function() { return [d1, d2] } }; +>x241 : Symbol(x241, Decl(generatedContextualTyping.ts, 243, 3)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 243, 11)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 243, 37)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +var x242: { n: { (): Base[]; }; } = { n: function named() { return [d1, d2] } }; +>x242 : Symbol(x242, Decl(generatedContextualTyping.ts, 244, 3)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 244, 11)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 244, 37)) +>named : Symbol(named, Decl(generatedContextualTyping.ts, 244, 40)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +var x243: { n: Base[]; } = { n: [d1, d2] }; +>x243 : Symbol(x243, Decl(generatedContextualTyping.ts, 245, 3)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 245, 11)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 245, 28)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +var x244: { n: Array; } = { n: [d1, d2] }; +>x244 : Symbol(x244, Decl(generatedContextualTyping.ts, 246, 3)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 246, 11)) +>Array : Symbol(Array, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 246, 33)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +var x245: { n: { [n: number]: Base; }; } = { n: [d1, d2] }; +>x245 : Symbol(x245, Decl(generatedContextualTyping.ts, 247, 3)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 247, 11)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 247, 18)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 247, 44)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +var x246: { n: {n: Base[]; } ; } = { n: { n: [d1, d2] } }; +>x246 : Symbol(x246, Decl(generatedContextualTyping.ts, 248, 3)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 248, 11)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 248, 16)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 248, 36)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 248, 41)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +var x247: { n: (s: Base[]) => any; } = { n: n => { var n: Base[]; return null; } }; +>x247 : Symbol(x247, Decl(generatedContextualTyping.ts, 249, 3)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 249, 11)) +>s : Symbol(s, Decl(generatedContextualTyping.ts, 249, 16)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 249, 40)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 249, 43), Decl(generatedContextualTyping.ts, 249, 54)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 249, 43), Decl(generatedContextualTyping.ts, 249, 54)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) + +var x248: { n: Genric; } = { n: { func: n => { return [d1, d2]; } } }; +>x248 : Symbol(x248, Decl(generatedContextualTyping.ts, 250, 3)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 250, 11)) +>Genric : Symbol(Genric, Decl(generatedContextualTyping.ts, 3, 42)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 250, 34)) +>func : Symbol(func, Decl(generatedContextualTyping.ts, 250, 39)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 250, 45)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +var x252: { (): Base[]; }[] = [() => [d1, d2]]; +>x252 : Symbol(x252, Decl(generatedContextualTyping.ts, 251, 3)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +var x253: { (): Base[]; }[] = [function() { return [d1, d2] }]; +>x253 : Symbol(x253, Decl(generatedContextualTyping.ts, 252, 3)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +var x254: { (): Base[]; }[] = [function named() { return [d1, d2] }]; +>x254 : Symbol(x254, Decl(generatedContextualTyping.ts, 253, 3)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>named : Symbol(named, Decl(generatedContextualTyping.ts, 253, 31)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +var x255: Base[][] = [[d1, d2]]; +>x255 : Symbol(x255, Decl(generatedContextualTyping.ts, 254, 3)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +var x256: Array[] = [[d1, d2]]; +>x256 : Symbol(x256, Decl(generatedContextualTyping.ts, 255, 3)) +>Array : Symbol(Array, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +var x257: { [n: number]: Base; }[] = [[d1, d2]]; +>x257 : Symbol(x257, Decl(generatedContextualTyping.ts, 256, 3)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 256, 13)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +var x258: {n: Base[]; } [] = [{ n: [d1, d2] }]; +>x258 : Symbol(x258, Decl(generatedContextualTyping.ts, 257, 3)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 257, 11)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 257, 31)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +var x260: Genric[] = [{ func: n => { return [d1, d2]; } }]; +>x260 : Symbol(x260, Decl(generatedContextualTyping.ts, 258, 3)) +>Genric : Symbol(Genric, Decl(generatedContextualTyping.ts, 3, 42)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>func : Symbol(func, Decl(generatedContextualTyping.ts, 258, 29)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 258, 35)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +var x261: () => Base[] = function() { return [d1, d2] } || undefined; +>x261 : Symbol(x261, Decl(generatedContextualTyping.ts, 259, 3)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) +>undefined : Symbol(undefined) + +var x262: () => Base[] = function named() { return [d1, d2] } || undefined; +>x262 : Symbol(x262, Decl(generatedContextualTyping.ts, 260, 3)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>named : Symbol(named, Decl(generatedContextualTyping.ts, 260, 24)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) +>undefined : Symbol(undefined) + +var x263: { (): Base[]; } = function() { return [d1, d2] } || undefined; +>x263 : Symbol(x263, Decl(generatedContextualTyping.ts, 261, 3)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) +>undefined : Symbol(undefined) + +var x264: { (): Base[]; } = function named() { return [d1, d2] } || undefined; +>x264 : Symbol(x264, Decl(generatedContextualTyping.ts, 262, 3)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>named : Symbol(named, Decl(generatedContextualTyping.ts, 262, 27)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) +>undefined : Symbol(undefined) + +var x265: Base[] = [d1, d2] || undefined; +>x265 : Symbol(x265, Decl(generatedContextualTyping.ts, 263, 3)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) +>undefined : Symbol(undefined) + +var x266: Array = [d1, d2] || undefined; +>x266 : Symbol(x266, Decl(generatedContextualTyping.ts, 264, 3)) +>Array : Symbol(Array, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) +>undefined : Symbol(undefined) + +var x267: { [n: number]: Base; } = [d1, d2] || undefined; +>x267 : Symbol(x267, Decl(generatedContextualTyping.ts, 265, 3)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 265, 13)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) +>undefined : Symbol(undefined) + +var x268: {n: Base[]; } = { n: [d1, d2] } || undefined; +>x268 : Symbol(x268, Decl(generatedContextualTyping.ts, 266, 3)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 266, 11)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 266, 28)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) +>undefined : Symbol(undefined) + +var x269: () => Base[] = undefined || function() { return [d1, d2] }; +>x269 : Symbol(x269, Decl(generatedContextualTyping.ts, 267, 3)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>undefined : Symbol(undefined) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +var x270: () => Base[] = undefined || function named() { return [d1, d2] }; +>x270 : Symbol(x270, Decl(generatedContextualTyping.ts, 268, 3)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>undefined : Symbol(undefined) +>named : Symbol(named, Decl(generatedContextualTyping.ts, 268, 37)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +var x271: { (): Base[]; } = undefined || function() { return [d1, d2] }; +>x271 : Symbol(x271, Decl(generatedContextualTyping.ts, 269, 3)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>undefined : Symbol(undefined) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +var x272: { (): Base[]; } = undefined || function named() { return [d1, d2] }; +>x272 : Symbol(x272, Decl(generatedContextualTyping.ts, 270, 3)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>undefined : Symbol(undefined) +>named : Symbol(named, Decl(generatedContextualTyping.ts, 270, 40)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +var x273: Base[] = undefined || [d1, d2]; +>x273 : Symbol(x273, Decl(generatedContextualTyping.ts, 271, 3)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>undefined : Symbol(undefined) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +var x274: Array = undefined || [d1, d2]; +>x274 : Symbol(x274, Decl(generatedContextualTyping.ts, 272, 3)) +>Array : Symbol(Array, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>undefined : Symbol(undefined) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +var x275: { [n: number]: Base; } = undefined || [d1, d2]; +>x275 : Symbol(x275, Decl(generatedContextualTyping.ts, 273, 3)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 273, 13)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>undefined : Symbol(undefined) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +var x276: {n: Base[]; } = undefined || { n: [d1, d2] }; +>x276 : Symbol(x276, Decl(generatedContextualTyping.ts, 274, 3)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 274, 11)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>undefined : Symbol(undefined) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 274, 41)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +var x277: () => Base[] = function() { return [d1, d2] } || function() { return [d1, d2] }; +>x277 : Symbol(x277, Decl(generatedContextualTyping.ts, 275, 3)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +var x278: () => Base[] = function named() { return [d1, d2] } || function named() { return [d1, d2] }; +>x278 : Symbol(x278, Decl(generatedContextualTyping.ts, 276, 3)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>named : Symbol(named, Decl(generatedContextualTyping.ts, 276, 24)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) +>named : Symbol(named, Decl(generatedContextualTyping.ts, 276, 64)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +var x279: { (): Base[]; } = function() { return [d1, d2] } || function() { return [d1, d2] }; +>x279 : Symbol(x279, Decl(generatedContextualTyping.ts, 277, 3)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +var x280: { (): Base[]; } = function named() { return [d1, d2] } || function named() { return [d1, d2] }; +>x280 : Symbol(x280, Decl(generatedContextualTyping.ts, 278, 3)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>named : Symbol(named, Decl(generatedContextualTyping.ts, 278, 27)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) +>named : Symbol(named, Decl(generatedContextualTyping.ts, 278, 67)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +var x281: Base[] = [d1, d2] || [d1, d2]; +>x281 : Symbol(x281, Decl(generatedContextualTyping.ts, 279, 3)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +var x282: Array = [d1, d2] || [d1, d2]; +>x282 : Symbol(x282, Decl(generatedContextualTyping.ts, 280, 3)) +>Array : Symbol(Array, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +var x283: { [n: number]: Base; } = [d1, d2] || [d1, d2]; +>x283 : Symbol(x283, Decl(generatedContextualTyping.ts, 281, 3)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 281, 13)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +var x284: {n: Base[]; } = { n: [d1, d2] } || { n: [d1, d2] }; +>x284 : Symbol(x284, Decl(generatedContextualTyping.ts, 282, 3)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 282, 11)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 282, 28)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 282, 47)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +var x285: () => Base[] = true ? () => [d1, d2] : () => [d1, d2]; +>x285 : Symbol(x285, Decl(generatedContextualTyping.ts, 283, 3)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +var x286: () => Base[] = true ? function() { return [d1, d2] } : function() { return [d1, d2] }; +>x286 : Symbol(x286, Decl(generatedContextualTyping.ts, 284, 3)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +var x287: () => Base[] = true ? function named() { return [d1, d2] } : function named() { return [d1, d2] }; +>x287 : Symbol(x287, Decl(generatedContextualTyping.ts, 285, 3)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>named : Symbol(named, Decl(generatedContextualTyping.ts, 285, 31)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) +>named : Symbol(named, Decl(generatedContextualTyping.ts, 285, 70)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +var x288: { (): Base[]; } = true ? () => [d1, d2] : () => [d1, d2]; +>x288 : Symbol(x288, Decl(generatedContextualTyping.ts, 286, 3)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +var x289: { (): Base[]; } = true ? function() { return [d1, d2] } : function() { return [d1, d2] }; +>x289 : Symbol(x289, Decl(generatedContextualTyping.ts, 287, 3)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +var x290: { (): Base[]; } = true ? function named() { return [d1, d2] } : function named() { return [d1, d2] }; +>x290 : Symbol(x290, Decl(generatedContextualTyping.ts, 288, 3)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>named : Symbol(named, Decl(generatedContextualTyping.ts, 288, 34)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) +>named : Symbol(named, Decl(generatedContextualTyping.ts, 288, 73)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +var x291: Base[] = true ? [d1, d2] : [d1, d2]; +>x291 : Symbol(x291, Decl(generatedContextualTyping.ts, 289, 3)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +var x292: Array = true ? [d1, d2] : [d1, d2]; +>x292 : Symbol(x292, Decl(generatedContextualTyping.ts, 290, 3)) +>Array : Symbol(Array, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +var x293: { [n: number]: Base; } = true ? [d1, d2] : [d1, d2]; +>x293 : Symbol(x293, Decl(generatedContextualTyping.ts, 291, 3)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 291, 13)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +var x294: {n: Base[]; } = true ? { n: [d1, d2] } : { n: [d1, d2] }; +>x294 : Symbol(x294, Decl(generatedContextualTyping.ts, 292, 3)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 292, 11)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 292, 35)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 292, 53)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +var x295: (s: Base[]) => any = true ? n => { var n: Base[]; return null; } : n => { var n: Base[]; return null; }; +>x295 : Symbol(x295, Decl(generatedContextualTyping.ts, 293, 3)) +>s : Symbol(s, Decl(generatedContextualTyping.ts, 293, 11)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 293, 37), Decl(generatedContextualTyping.ts, 293, 48)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 293, 37), Decl(generatedContextualTyping.ts, 293, 48)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 293, 76), Decl(generatedContextualTyping.ts, 293, 87)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 293, 76), Decl(generatedContextualTyping.ts, 293, 87)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) + +var x296: Genric = true ? { func: n => { return [d1, d2]; } } : { func: n => { return [d1, d2]; } }; +>x296 : Symbol(x296, Decl(generatedContextualTyping.ts, 294, 3)) +>Genric : Symbol(Genric, Decl(generatedContextualTyping.ts, 3, 42)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>func : Symbol(func, Decl(generatedContextualTyping.ts, 294, 33)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 294, 39)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) +>func : Symbol(func, Decl(generatedContextualTyping.ts, 294, 71)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 294, 77)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +var x297: () => Base[] = true ? undefined : () => [d1, d2]; +>x297 : Symbol(x297, Decl(generatedContextualTyping.ts, 295, 3)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>undefined : Symbol(undefined) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +var x298: () => Base[] = true ? undefined : function() { return [d1, d2] }; +>x298 : Symbol(x298, Decl(generatedContextualTyping.ts, 296, 3)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>undefined : Symbol(undefined) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +var x299: () => Base[] = true ? undefined : function named() { return [d1, d2] }; +>x299 : Symbol(x299, Decl(generatedContextualTyping.ts, 297, 3)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>undefined : Symbol(undefined) +>named : Symbol(named, Decl(generatedContextualTyping.ts, 297, 43)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +var x300: { (): Base[]; } = true ? undefined : () => [d1, d2]; +>x300 : Symbol(x300, Decl(generatedContextualTyping.ts, 298, 3)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>undefined : Symbol(undefined) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +var x301: { (): Base[]; } = true ? undefined : function() { return [d1, d2] }; +>x301 : Symbol(x301, Decl(generatedContextualTyping.ts, 299, 3)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>undefined : Symbol(undefined) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +var x302: { (): Base[]; } = true ? undefined : function named() { return [d1, d2] }; +>x302 : Symbol(x302, Decl(generatedContextualTyping.ts, 300, 3)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>undefined : Symbol(undefined) +>named : Symbol(named, Decl(generatedContextualTyping.ts, 300, 46)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +var x303: Base[] = true ? undefined : [d1, d2]; +>x303 : Symbol(x303, Decl(generatedContextualTyping.ts, 301, 3)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>undefined : Symbol(undefined) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +var x304: Array = true ? undefined : [d1, d2]; +>x304 : Symbol(x304, Decl(generatedContextualTyping.ts, 302, 3)) +>Array : Symbol(Array, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>undefined : Symbol(undefined) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +var x305: { [n: number]: Base; } = true ? undefined : [d1, d2]; +>x305 : Symbol(x305, Decl(generatedContextualTyping.ts, 303, 3)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 303, 13)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>undefined : Symbol(undefined) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +var x306: {n: Base[]; } = true ? undefined : { n: [d1, d2] }; +>x306 : Symbol(x306, Decl(generatedContextualTyping.ts, 304, 3)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 304, 11)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>undefined : Symbol(undefined) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 304, 47)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +var x307: (s: Base[]) => any = true ? undefined : n => { var n: Base[]; return null; }; +>x307 : Symbol(x307, Decl(generatedContextualTyping.ts, 305, 3)) +>s : Symbol(s, Decl(generatedContextualTyping.ts, 305, 11)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>undefined : Symbol(undefined) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 305, 49), Decl(generatedContextualTyping.ts, 305, 60)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 305, 49), Decl(generatedContextualTyping.ts, 305, 60)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) + +var x308: Genric = true ? undefined : { func: n => { return [d1, d2]; } }; +>x308 : Symbol(x308, Decl(generatedContextualTyping.ts, 306, 3)) +>Genric : Symbol(Genric, Decl(generatedContextualTyping.ts, 3, 42)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>undefined : Symbol(undefined) +>func : Symbol(func, Decl(generatedContextualTyping.ts, 306, 45)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 306, 51)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +var x309: () => Base[] = true ? () => [d1, d2] : undefined; +>x309 : Symbol(x309, Decl(generatedContextualTyping.ts, 307, 3)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) +>undefined : Symbol(undefined) + +var x310: () => Base[] = true ? function() { return [d1, d2] } : undefined; +>x310 : Symbol(x310, Decl(generatedContextualTyping.ts, 308, 3)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) +>undefined : Symbol(undefined) + +var x311: () => Base[] = true ? function named() { return [d1, d2] } : undefined; +>x311 : Symbol(x311, Decl(generatedContextualTyping.ts, 309, 3)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>named : Symbol(named, Decl(generatedContextualTyping.ts, 309, 31)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) +>undefined : Symbol(undefined) + +var x312: { (): Base[]; } = true ? () => [d1, d2] : undefined; +>x312 : Symbol(x312, Decl(generatedContextualTyping.ts, 310, 3)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) +>undefined : Symbol(undefined) + +var x313: { (): Base[]; } = true ? function() { return [d1, d2] } : undefined; +>x313 : Symbol(x313, Decl(generatedContextualTyping.ts, 311, 3)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) +>undefined : Symbol(undefined) + +var x314: { (): Base[]; } = true ? function named() { return [d1, d2] } : undefined; +>x314 : Symbol(x314, Decl(generatedContextualTyping.ts, 312, 3)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>named : Symbol(named, Decl(generatedContextualTyping.ts, 312, 34)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) +>undefined : Symbol(undefined) + +var x315: Base[] = true ? [d1, d2] : undefined; +>x315 : Symbol(x315, Decl(generatedContextualTyping.ts, 313, 3)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) +>undefined : Symbol(undefined) + +var x316: Array = true ? [d1, d2] : undefined; +>x316 : Symbol(x316, Decl(generatedContextualTyping.ts, 314, 3)) +>Array : Symbol(Array, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) +>undefined : Symbol(undefined) + +var x317: { [n: number]: Base; } = true ? [d1, d2] : undefined; +>x317 : Symbol(x317, Decl(generatedContextualTyping.ts, 315, 3)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 315, 13)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) +>undefined : Symbol(undefined) + +var x318: {n: Base[]; } = true ? { n: [d1, d2] } : undefined; +>x318 : Symbol(x318, Decl(generatedContextualTyping.ts, 316, 3)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 316, 11)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 316, 35)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) +>undefined : Symbol(undefined) + +var x319: (s: Base[]) => any = true ? n => { var n: Base[]; return null; } : undefined; +>x319 : Symbol(x319, Decl(generatedContextualTyping.ts, 317, 3)) +>s : Symbol(s, Decl(generatedContextualTyping.ts, 317, 11)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 317, 37), Decl(generatedContextualTyping.ts, 317, 48)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 317, 37), Decl(generatedContextualTyping.ts, 317, 48)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>undefined : Symbol(undefined) + +var x320: Genric = true ? { func: n => { return [d1, d2]; } } : undefined; +>x320 : Symbol(x320, Decl(generatedContextualTyping.ts, 318, 3)) +>Genric : Symbol(Genric, Decl(generatedContextualTyping.ts, 3, 42)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>func : Symbol(func, Decl(generatedContextualTyping.ts, 318, 33)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 318, 39)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) +>undefined : Symbol(undefined) + +function x321(n: () => Base[]) { }; x321(() => [d1, d2]); +>x321 : Symbol(x321, Decl(generatedContextualTyping.ts, 318, 80)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 319, 14)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>x321 : Symbol(x321, Decl(generatedContextualTyping.ts, 318, 80)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +function x322(n: () => Base[]) { }; x322(function() { return [d1, d2] }); +>x322 : Symbol(x322, Decl(generatedContextualTyping.ts, 319, 57)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 320, 14)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>x322 : Symbol(x322, Decl(generatedContextualTyping.ts, 319, 57)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +function x323(n: () => Base[]) { }; x323(function named() { return [d1, d2] }); +>x323 : Symbol(x323, Decl(generatedContextualTyping.ts, 320, 73)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 321, 14)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>x323 : Symbol(x323, Decl(generatedContextualTyping.ts, 320, 73)) +>named : Symbol(named, Decl(generatedContextualTyping.ts, 321, 41)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +function x324(n: { (): Base[]; }) { }; x324(() => [d1, d2]); +>x324 : Symbol(x324, Decl(generatedContextualTyping.ts, 321, 79)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 322, 14)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>x324 : Symbol(x324, Decl(generatedContextualTyping.ts, 321, 79)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +function x325(n: { (): Base[]; }) { }; x325(function() { return [d1, d2] }); +>x325 : Symbol(x325, Decl(generatedContextualTyping.ts, 322, 60)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 323, 14)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>x325 : Symbol(x325, Decl(generatedContextualTyping.ts, 322, 60)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +function x326(n: { (): Base[]; }) { }; x326(function named() { return [d1, d2] }); +>x326 : Symbol(x326, Decl(generatedContextualTyping.ts, 323, 76)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 324, 14)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>x326 : Symbol(x326, Decl(generatedContextualTyping.ts, 323, 76)) +>named : Symbol(named, Decl(generatedContextualTyping.ts, 324, 44)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +function x327(n: Base[]) { }; x327([d1, d2]); +>x327 : Symbol(x327, Decl(generatedContextualTyping.ts, 324, 82)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 325, 14)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>x327 : Symbol(x327, Decl(generatedContextualTyping.ts, 324, 82)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +function x328(n: Array) { }; x328([d1, d2]); +>x328 : Symbol(x328, Decl(generatedContextualTyping.ts, 325, 45)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 326, 14)) +>Array : Symbol(Array, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>x328 : Symbol(x328, Decl(generatedContextualTyping.ts, 325, 45)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +function x329(n: { [n: number]: Base; }) { }; x329([d1, d2]); +>x329 : Symbol(x329, Decl(generatedContextualTyping.ts, 326, 50)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 327, 14)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 327, 20)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>x329 : Symbol(x329, Decl(generatedContextualTyping.ts, 326, 50)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +function x330(n: {n: Base[]; } ) { }; x330({ n: [d1, d2] }); +>x330 : Symbol(x330, Decl(generatedContextualTyping.ts, 327, 61)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 328, 14)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 328, 18)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>x330 : Symbol(x330, Decl(generatedContextualTyping.ts, 327, 61)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 328, 44)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +function x331(n: (s: Base[]) => any) { }; x331(n => { var n: Base[]; return null; }); +>x331 : Symbol(x331, Decl(generatedContextualTyping.ts, 328, 60)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 329, 14)) +>s : Symbol(s, Decl(generatedContextualTyping.ts, 329, 18)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>x331 : Symbol(x331, Decl(generatedContextualTyping.ts, 328, 60)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 329, 47), Decl(generatedContextualTyping.ts, 329, 57)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 329, 47), Decl(generatedContextualTyping.ts, 329, 57)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) + +function x332(n: Genric) { }; x332({ func: n => { return [d1, d2]; } }); +>x332 : Symbol(x332, Decl(generatedContextualTyping.ts, 329, 85)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 330, 14)) +>Genric : Symbol(Genric, Decl(generatedContextualTyping.ts, 3, 42)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>x332 : Symbol(x332, Decl(generatedContextualTyping.ts, 329, 85)) +>func : Symbol(func, Decl(generatedContextualTyping.ts, 330, 42)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 330, 48)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +var x333 = (n: () => Base[]) => n; x333(() => [d1, d2]); +>x333 : Symbol(x333, Decl(generatedContextualTyping.ts, 331, 3)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 331, 12)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 331, 12)) +>x333 : Symbol(x333, Decl(generatedContextualTyping.ts, 331, 3)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +var x334 = (n: () => Base[]) => n; x334(function() { return [d1, d2] }); +>x334 : Symbol(x334, Decl(generatedContextualTyping.ts, 332, 3)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 332, 12)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 332, 12)) +>x334 : Symbol(x334, Decl(generatedContextualTyping.ts, 332, 3)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +var x335 = (n: () => Base[]) => n; x335(function named() { return [d1, d2] }); +>x335 : Symbol(x335, Decl(generatedContextualTyping.ts, 333, 3)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 333, 12)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 333, 12)) +>x335 : Symbol(x335, Decl(generatedContextualTyping.ts, 333, 3)) +>named : Symbol(named, Decl(generatedContextualTyping.ts, 333, 40)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +var x336 = (n: { (): Base[]; }) => n; x336(() => [d1, d2]); +>x336 : Symbol(x336, Decl(generatedContextualTyping.ts, 334, 3)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 334, 12)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 334, 12)) +>x336 : Symbol(x336, Decl(generatedContextualTyping.ts, 334, 3)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +var x337 = (n: { (): Base[]; }) => n; x337(function() { return [d1, d2] }); +>x337 : Symbol(x337, Decl(generatedContextualTyping.ts, 335, 3)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 335, 12)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 335, 12)) +>x337 : Symbol(x337, Decl(generatedContextualTyping.ts, 335, 3)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +var x338 = (n: { (): Base[]; }) => n; x338(function named() { return [d1, d2] }); +>x338 : Symbol(x338, Decl(generatedContextualTyping.ts, 336, 3)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 336, 12)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 336, 12)) +>x338 : Symbol(x338, Decl(generatedContextualTyping.ts, 336, 3)) +>named : Symbol(named, Decl(generatedContextualTyping.ts, 336, 43)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +var x339 = (n: Base[]) => n; x339([d1, d2]); +>x339 : Symbol(x339, Decl(generatedContextualTyping.ts, 337, 3)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 337, 12)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 337, 12)) +>x339 : Symbol(x339, Decl(generatedContextualTyping.ts, 337, 3)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +var x340 = (n: Array) => n; x340([d1, d2]); +>x340 : Symbol(x340, Decl(generatedContextualTyping.ts, 338, 3)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 338, 12)) +>Array : Symbol(Array, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 338, 12)) +>x340 : Symbol(x340, Decl(generatedContextualTyping.ts, 338, 3)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +var x341 = (n: { [n: number]: Base; }) => n; x341([d1, d2]); +>x341 : Symbol(x341, Decl(generatedContextualTyping.ts, 339, 3)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 339, 12)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 339, 18)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 339, 12)) +>x341 : Symbol(x341, Decl(generatedContextualTyping.ts, 339, 3)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +var x342 = (n: {n: Base[]; } ) => n; x342({ n: [d1, d2] }); +>x342 : Symbol(x342, Decl(generatedContextualTyping.ts, 340, 3)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 340, 12)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 340, 16)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 340, 12)) +>x342 : Symbol(x342, Decl(generatedContextualTyping.ts, 340, 3)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 340, 43)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +var x343 = (n: (s: Base[]) => any) => n; x343(n => { var n: Base[]; return null; }); +>x343 : Symbol(x343, Decl(generatedContextualTyping.ts, 341, 3)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 341, 12)) +>s : Symbol(s, Decl(generatedContextualTyping.ts, 341, 16)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 341, 12)) +>x343 : Symbol(x343, Decl(generatedContextualTyping.ts, 341, 3)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 341, 46), Decl(generatedContextualTyping.ts, 341, 56)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 341, 46), Decl(generatedContextualTyping.ts, 341, 56)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) + +var x344 = (n: Genric) => n; x344({ func: n => { return [d1, d2]; } }); +>x344 : Symbol(x344, Decl(generatedContextualTyping.ts, 342, 3)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 342, 12)) +>Genric : Symbol(Genric, Decl(generatedContextualTyping.ts, 3, 42)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 342, 12)) +>x344 : Symbol(x344, Decl(generatedContextualTyping.ts, 342, 3)) +>func : Symbol(func, Decl(generatedContextualTyping.ts, 342, 41)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 342, 47)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +var x345 = function(n: () => Base[]) { }; x345(() => [d1, d2]); +>x345 : Symbol(x345, Decl(generatedContextualTyping.ts, 343, 3)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 343, 20)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>x345 : Symbol(x345, Decl(generatedContextualTyping.ts, 343, 3)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +var x346 = function(n: () => Base[]) { }; x346(function() { return [d1, d2] }); +>x346 : Symbol(x346, Decl(generatedContextualTyping.ts, 344, 3)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 344, 20)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>x346 : Symbol(x346, Decl(generatedContextualTyping.ts, 344, 3)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +var x347 = function(n: () => Base[]) { }; x347(function named() { return [d1, d2] }); +>x347 : Symbol(x347, Decl(generatedContextualTyping.ts, 345, 3)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 345, 20)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>x347 : Symbol(x347, Decl(generatedContextualTyping.ts, 345, 3)) +>named : Symbol(named, Decl(generatedContextualTyping.ts, 345, 47)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +var x348 = function(n: { (): Base[]; }) { }; x348(() => [d1, d2]); +>x348 : Symbol(x348, Decl(generatedContextualTyping.ts, 346, 3)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 346, 20)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>x348 : Symbol(x348, Decl(generatedContextualTyping.ts, 346, 3)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +var x349 = function(n: { (): Base[]; }) { }; x349(function() { return [d1, d2] }); +>x349 : Symbol(x349, Decl(generatedContextualTyping.ts, 347, 3)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 347, 20)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>x349 : Symbol(x349, Decl(generatedContextualTyping.ts, 347, 3)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +var x350 = function(n: { (): Base[]; }) { }; x350(function named() { return [d1, d2] }); +>x350 : Symbol(x350, Decl(generatedContextualTyping.ts, 348, 3)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 348, 20)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>x350 : Symbol(x350, Decl(generatedContextualTyping.ts, 348, 3)) +>named : Symbol(named, Decl(generatedContextualTyping.ts, 348, 50)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +var x351 = function(n: Base[]) { }; x351([d1, d2]); +>x351 : Symbol(x351, Decl(generatedContextualTyping.ts, 349, 3)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 349, 20)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>x351 : Symbol(x351, Decl(generatedContextualTyping.ts, 349, 3)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +var x352 = function(n: Array) { }; x352([d1, d2]); +>x352 : Symbol(x352, Decl(generatedContextualTyping.ts, 350, 3)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 350, 20)) +>Array : Symbol(Array, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>x352 : Symbol(x352, Decl(generatedContextualTyping.ts, 350, 3)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +var x353 = function(n: { [n: number]: Base; }) { }; x353([d1, d2]); +>x353 : Symbol(x353, Decl(generatedContextualTyping.ts, 351, 3)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 351, 20)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 351, 26)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>x353 : Symbol(x353, Decl(generatedContextualTyping.ts, 351, 3)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +var x354 = function(n: {n: Base[]; } ) { }; x354({ n: [d1, d2] }); +>x354 : Symbol(x354, Decl(generatedContextualTyping.ts, 352, 3)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 352, 20)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 352, 24)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>x354 : Symbol(x354, Decl(generatedContextualTyping.ts, 352, 3)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 352, 50)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + +var x355 = function(n: (s: Base[]) => any) { }; x355(n => { var n: Base[]; return null; }); +>x355 : Symbol(x355, Decl(generatedContextualTyping.ts, 353, 3)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 353, 20)) +>s : Symbol(s, Decl(generatedContextualTyping.ts, 353, 24)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>x355 : Symbol(x355, Decl(generatedContextualTyping.ts, 353, 3)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 353, 53), Decl(generatedContextualTyping.ts, 353, 63)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 353, 53), Decl(generatedContextualTyping.ts, 353, 63)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) + +var x356 = function(n: Genric) { }; x356({ func: n => { return [d1, d2]; } }); +>x356 : Symbol(x356, Decl(generatedContextualTyping.ts, 354, 3)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 354, 20)) +>Genric : Symbol(Genric, Decl(generatedContextualTyping.ts, 3, 42)) +>Base : Symbol(Base, Decl(generatedContextualTyping.ts, 0, 0)) +>x356 : Symbol(x356, Decl(generatedContextualTyping.ts, 354, 3)) +>func : Symbol(func, Decl(generatedContextualTyping.ts, 354, 48)) +>n : Symbol(n, Decl(generatedContextualTyping.ts, 354, 54)) +>d1 : Symbol(d1, Decl(generatedContextualTyping.ts, 5, 19)) +>d2 : Symbol(d2, Decl(generatedContextualTyping.ts, 5, 40)) + diff --git a/tests/baselines/reference/generatedContextualTyping.types b/tests/baselines/reference/generatedContextualTyping.types new file mode 100644 index 00000000000..2e9625cdb8b --- /dev/null +++ b/tests/baselines/reference/generatedContextualTyping.types @@ -0,0 +1,3769 @@ +=== tests/cases/conformance/expressions/contextualTyping/generatedContextualTyping.ts === + +class Base { private p; } +>Base : Base +>p : any + +class Derived1 extends Base { private m; } +>Derived1 : Derived1 +>Base : Base +>m : any + +class Derived2 extends Base { private n; } +>Derived2 : Derived2 +>Base : Base +>n : any + +interface Genric { func(n: T[]); } +>Genric : Genric +>T : T +>func : (n: T[]) => any +>n : T[] +>T : T + +var b = new Base(), d1 = new Derived1(), d2 = new Derived2(); +>b : Base +>new Base() : Base +>Base : typeof Base +>d1 : Derived1 +>new Derived1() : Derived1 +>Derived1 : typeof Derived1 +>d2 : Derived2 +>new Derived2() : Derived2 +>Derived2 : typeof Derived2 + +var x1: () => Base[] = () => [d1, d2]; +>x1 : () => Base[] +>Base : Base +>() => [d1, d2] : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +var x2: () => Base[] = function() { return [d1, d2] }; +>x2 : () => Base[] +>Base : Base +>function() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +var x3: () => Base[] = function named() { return [d1, d2] }; +>x3 : () => Base[] +>Base : Base +>function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>named : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +var x4: { (): Base[]; } = () => [d1, d2]; +>x4 : () => Base[] +>Base : Base +>() => [d1, d2] : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +var x5: { (): Base[]; } = function() { return [d1, d2] }; +>x5 : () => Base[] +>Base : Base +>function() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +var x6: { (): Base[]; } = function named() { return [d1, d2] }; +>x6 : () => Base[] +>Base : Base +>function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>named : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +var x7: Base[] = [d1, d2]; +>x7 : Base[] +>Base : Base +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +var x8: Array = [d1, d2]; +>x8 : Base[] +>Array : T[] +>Base : Base +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +var x9: { [n: number]: Base; } = [d1, d2]; +>x9 : { [n: number]: Base; } +>n : number +>Base : Base +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +var x10: {n: Base[]; } = { n: [d1, d2] }; +>x10 : { n: Base[]; } +>n : Base[] +>Base : Base +>{ n: [d1, d2] } : { n: (Derived1 | Derived2)[]; } +>n : (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +var x11: (s: Base[]) => any = n => { var n: Base[]; return null; }; +>x11 : (s: Base[]) => any +>s : Base[] +>Base : Base +>n => { var n: Base[]; return null; } : (n: Base[]) => any +>n : Base[] +>n : Base[] +>Base : Base +>null : null + +var x12: Genric = { func: n => { return [d1, d2]; } }; +>x12 : Genric +>Genric : Genric +>Base : Base +>{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => (Derived1 | Derived2)[]; } +>func : (n: Base[]) => (Derived1 | Derived2)[] +>n => { return [d1, d2]; } : (n: Base[]) => (Derived1 | Derived2)[] +>n : Base[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +class x13 { member: () => Base[] = () => [d1, d2] } +>x13 : x13 +>member : () => Base[] +>Base : Base +>() => [d1, d2] : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +class x14 { member: () => Base[] = function() { return [d1, d2] } } +>x14 : x14 +>member : () => Base[] +>Base : Base +>function() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +class x15 { member: () => Base[] = function named() { return [d1, d2] } } +>x15 : x15 +>member : () => Base[] +>Base : Base +>function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>named : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +class x16 { member: { (): Base[]; } = () => [d1, d2] } +>x16 : x16 +>member : () => Base[] +>Base : Base +>() => [d1, d2] : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +class x17 { member: { (): Base[]; } = function() { return [d1, d2] } } +>x17 : x17 +>member : () => Base[] +>Base : Base +>function() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +class x18 { member: { (): Base[]; } = function named() { return [d1, d2] } } +>x18 : x18 +>member : () => Base[] +>Base : Base +>function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>named : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +class x19 { member: Base[] = [d1, d2] } +>x19 : x19 +>member : Base[] +>Base : Base +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +class x20 { member: Array = [d1, d2] } +>x20 : x20 +>member : Base[] +>Array : T[] +>Base : Base +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +class x21 { member: { [n: number]: Base; } = [d1, d2] } +>x21 : x21 +>member : { [n: number]: Base; } +>n : number +>Base : Base +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +class x22 { member: {n: Base[]; } = { n: [d1, d2] } } +>x22 : x22 +>member : { n: Base[]; } +>n : Base[] +>Base : Base +>{ n: [d1, d2] } : { n: (Derived1 | Derived2)[]; } +>n : (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +class x23 { member: (s: Base[]) => any = n => { var n: Base[]; return null; } } +>x23 : x23 +>member : (s: Base[]) => any +>s : Base[] +>Base : Base +>n => { var n: Base[]; return null; } : (n: Base[]) => any +>n : Base[] +>n : Base[] +>Base : Base +>null : null + +class x24 { member: Genric = { func: n => { return [d1, d2]; } } } +>x24 : x24 +>member : Genric +>Genric : Genric +>Base : Base +>{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => (Derived1 | Derived2)[]; } +>func : (n: Base[]) => (Derived1 | Derived2)[] +>n => { return [d1, d2]; } : (n: Base[]) => (Derived1 | Derived2)[] +>n : Base[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +class x25 { private member: () => Base[] = () => [d1, d2] } +>x25 : x25 +>member : () => Base[] +>Base : Base +>() => [d1, d2] : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +class x26 { private member: () => Base[] = function() { return [d1, d2] } } +>x26 : x26 +>member : () => Base[] +>Base : Base +>function() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +class x27 { private member: () => Base[] = function named() { return [d1, d2] } } +>x27 : x27 +>member : () => Base[] +>Base : Base +>function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>named : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +class x28 { private member: { (): Base[]; } = () => [d1, d2] } +>x28 : x28 +>member : () => Base[] +>Base : Base +>() => [d1, d2] : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +class x29 { private member: { (): Base[]; } = function() { return [d1, d2] } } +>x29 : x29 +>member : () => Base[] +>Base : Base +>function() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +class x30 { private member: { (): Base[]; } = function named() { return [d1, d2] } } +>x30 : x30 +>member : () => Base[] +>Base : Base +>function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>named : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +class x31 { private member: Base[] = [d1, d2] } +>x31 : x31 +>member : Base[] +>Base : Base +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +class x32 { private member: Array = [d1, d2] } +>x32 : x32 +>member : Base[] +>Array : T[] +>Base : Base +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +class x33 { private member: { [n: number]: Base; } = [d1, d2] } +>x33 : x33 +>member : { [n: number]: Base; } +>n : number +>Base : Base +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +class x34 { private member: {n: Base[]; } = { n: [d1, d2] } } +>x34 : x34 +>member : { n: Base[]; } +>n : Base[] +>Base : Base +>{ n: [d1, d2] } : { n: (Derived1 | Derived2)[]; } +>n : (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +class x35 { private member: (s: Base[]) => any = n => { var n: Base[]; return null; } } +>x35 : x35 +>member : (s: Base[]) => any +>s : Base[] +>Base : Base +>n => { var n: Base[]; return null; } : (n: Base[]) => any +>n : Base[] +>n : Base[] +>Base : Base +>null : null + +class x36 { private member: Genric = { func: n => { return [d1, d2]; } } } +>x36 : x36 +>member : Genric +>Genric : Genric +>Base : Base +>{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => (Derived1 | Derived2)[]; } +>func : (n: Base[]) => (Derived1 | Derived2)[] +>n => { return [d1, d2]; } : (n: Base[]) => (Derived1 | Derived2)[] +>n : Base[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +class x37 { public member: () => Base[] = () => [d1, d2] } +>x37 : x37 +>member : () => Base[] +>Base : Base +>() => [d1, d2] : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +class x38 { public member: () => Base[] = function() { return [d1, d2] } } +>x38 : x38 +>member : () => Base[] +>Base : Base +>function() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +class x39 { public member: () => Base[] = function named() { return [d1, d2] } } +>x39 : x39 +>member : () => Base[] +>Base : Base +>function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>named : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +class x40 { public member: { (): Base[]; } = () => [d1, d2] } +>x40 : x40 +>member : () => Base[] +>Base : Base +>() => [d1, d2] : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +class x41 { public member: { (): Base[]; } = function() { return [d1, d2] } } +>x41 : x41 +>member : () => Base[] +>Base : Base +>function() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +class x42 { public member: { (): Base[]; } = function named() { return [d1, d2] } } +>x42 : x42 +>member : () => Base[] +>Base : Base +>function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>named : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +class x43 { public member: Base[] = [d1, d2] } +>x43 : x43 +>member : Base[] +>Base : Base +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +class x44 { public member: Array = [d1, d2] } +>x44 : x44 +>member : Base[] +>Array : T[] +>Base : Base +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +class x45 { public member: { [n: number]: Base; } = [d1, d2] } +>x45 : x45 +>member : { [n: number]: Base; } +>n : number +>Base : Base +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +class x46 { public member: {n: Base[]; } = { n: [d1, d2] } } +>x46 : x46 +>member : { n: Base[]; } +>n : Base[] +>Base : Base +>{ n: [d1, d2] } : { n: (Derived1 | Derived2)[]; } +>n : (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +class x47 { public member: (s: Base[]) => any = n => { var n: Base[]; return null; } } +>x47 : x47 +>member : (s: Base[]) => any +>s : Base[] +>Base : Base +>n => { var n: Base[]; return null; } : (n: Base[]) => any +>n : Base[] +>n : Base[] +>Base : Base +>null : null + +class x48 { public member: Genric = { func: n => { return [d1, d2]; } } } +>x48 : x48 +>member : Genric +>Genric : Genric +>Base : Base +>{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => (Derived1 | Derived2)[]; } +>func : (n: Base[]) => (Derived1 | Derived2)[] +>n => { return [d1, d2]; } : (n: Base[]) => (Derived1 | Derived2)[] +>n : Base[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +class x49 { static member: () => Base[] = () => [d1, d2] } +>x49 : x49 +>member : () => Base[] +>Base : Base +>() => [d1, d2] : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +class x50 { static member: () => Base[] = function() { return [d1, d2] } } +>x50 : x50 +>member : () => Base[] +>Base : Base +>function() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +class x51 { static member: () => Base[] = function named() { return [d1, d2] } } +>x51 : x51 +>member : () => Base[] +>Base : Base +>function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>named : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +class x52 { static member: { (): Base[]; } = () => [d1, d2] } +>x52 : x52 +>member : () => Base[] +>Base : Base +>() => [d1, d2] : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +class x53 { static member: { (): Base[]; } = function() { return [d1, d2] } } +>x53 : x53 +>member : () => Base[] +>Base : Base +>function() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +class x54 { static member: { (): Base[]; } = function named() { return [d1, d2] } } +>x54 : x54 +>member : () => Base[] +>Base : Base +>function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>named : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +class x55 { static member: Base[] = [d1, d2] } +>x55 : x55 +>member : Base[] +>Base : Base +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +class x56 { static member: Array = [d1, d2] } +>x56 : x56 +>member : Base[] +>Array : T[] +>Base : Base +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +class x57 { static member: { [n: number]: Base; } = [d1, d2] } +>x57 : x57 +>member : { [n: number]: Base; } +>n : number +>Base : Base +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +class x58 { static member: {n: Base[]; } = { n: [d1, d2] } } +>x58 : x58 +>member : { n: Base[]; } +>n : Base[] +>Base : Base +>{ n: [d1, d2] } : { n: (Derived1 | Derived2)[]; } +>n : (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +class x59 { static member: (s: Base[]) => any = n => { var n: Base[]; return null; } } +>x59 : x59 +>member : (s: Base[]) => any +>s : Base[] +>Base : Base +>n => { var n: Base[]; return null; } : (n: Base[]) => any +>n : Base[] +>n : Base[] +>Base : Base +>null : null + +class x60 { static member: Genric = { func: n => { return [d1, d2]; } } } +>x60 : x60 +>member : Genric +>Genric : Genric +>Base : Base +>{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => (Derived1 | Derived2)[]; } +>func : (n: Base[]) => (Derived1 | Derived2)[] +>n => { return [d1, d2]; } : (n: Base[]) => (Derived1 | Derived2)[] +>n : Base[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +class x61 { private static member: () => Base[] = () => [d1, d2] } +>x61 : x61 +>member : () => Base[] +>Base : Base +>() => [d1, d2] : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +class x62 { private static member: () => Base[] = function() { return [d1, d2] } } +>x62 : x62 +>member : () => Base[] +>Base : Base +>function() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +class x63 { private static member: () => Base[] = function named() { return [d1, d2] } } +>x63 : x63 +>member : () => Base[] +>Base : Base +>function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>named : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +class x64 { private static member: { (): Base[]; } = () => [d1, d2] } +>x64 : x64 +>member : () => Base[] +>Base : Base +>() => [d1, d2] : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +class x65 { private static member: { (): Base[]; } = function() { return [d1, d2] } } +>x65 : x65 +>member : () => Base[] +>Base : Base +>function() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +class x66 { private static member: { (): Base[]; } = function named() { return [d1, d2] } } +>x66 : x66 +>member : () => Base[] +>Base : Base +>function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>named : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +class x67 { private static member: Base[] = [d1, d2] } +>x67 : x67 +>member : Base[] +>Base : Base +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +class x68 { private static member: Array = [d1, d2] } +>x68 : x68 +>member : Base[] +>Array : T[] +>Base : Base +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +class x69 { private static member: { [n: number]: Base; } = [d1, d2] } +>x69 : x69 +>member : { [n: number]: Base; } +>n : number +>Base : Base +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +class x70 { private static member: {n: Base[]; } = { n: [d1, d2] } } +>x70 : x70 +>member : { n: Base[]; } +>n : Base[] +>Base : Base +>{ n: [d1, d2] } : { n: (Derived1 | Derived2)[]; } +>n : (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +class x71 { private static member: (s: Base[]) => any = n => { var n: Base[]; return null; } } +>x71 : x71 +>member : (s: Base[]) => any +>s : Base[] +>Base : Base +>n => { var n: Base[]; return null; } : (n: Base[]) => any +>n : Base[] +>n : Base[] +>Base : Base +>null : null + +class x72 { private static member: Genric = { func: n => { return [d1, d2]; } } } +>x72 : x72 +>member : Genric +>Genric : Genric +>Base : Base +>{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => (Derived1 | Derived2)[]; } +>func : (n: Base[]) => (Derived1 | Derived2)[] +>n => { return [d1, d2]; } : (n: Base[]) => (Derived1 | Derived2)[] +>n : Base[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +class x73 { public static member: () => Base[] = () => [d1, d2] } +>x73 : x73 +>member : () => Base[] +>Base : Base +>() => [d1, d2] : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +class x74 { public static member: () => Base[] = function() { return [d1, d2] } } +>x74 : x74 +>member : () => Base[] +>Base : Base +>function() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +class x75 { public static member: () => Base[] = function named() { return [d1, d2] } } +>x75 : x75 +>member : () => Base[] +>Base : Base +>function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>named : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +class x76 { public static member: { (): Base[]; } = () => [d1, d2] } +>x76 : x76 +>member : () => Base[] +>Base : Base +>() => [d1, d2] : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +class x77 { public static member: { (): Base[]; } = function() { return [d1, d2] } } +>x77 : x77 +>member : () => Base[] +>Base : Base +>function() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +class x78 { public static member: { (): Base[]; } = function named() { return [d1, d2] } } +>x78 : x78 +>member : () => Base[] +>Base : Base +>function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>named : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +class x79 { public static member: Base[] = [d1, d2] } +>x79 : x79 +>member : Base[] +>Base : Base +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +class x80 { public static member: Array = [d1, d2] } +>x80 : x80 +>member : Base[] +>Array : T[] +>Base : Base +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +class x81 { public static member: { [n: number]: Base; } = [d1, d2] } +>x81 : x81 +>member : { [n: number]: Base; } +>n : number +>Base : Base +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +class x82 { public static member: {n: Base[]; } = { n: [d1, d2] } } +>x82 : x82 +>member : { n: Base[]; } +>n : Base[] +>Base : Base +>{ n: [d1, d2] } : { n: (Derived1 | Derived2)[]; } +>n : (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +class x83 { public static member: (s: Base[]) => any = n => { var n: Base[]; return null; } } +>x83 : x83 +>member : (s: Base[]) => any +>s : Base[] +>Base : Base +>n => { var n: Base[]; return null; } : (n: Base[]) => any +>n : Base[] +>n : Base[] +>Base : Base +>null : null + +class x84 { public static member: Genric = { func: n => { return [d1, d2]; } } } +>x84 : x84 +>member : Genric +>Genric : Genric +>Base : Base +>{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => (Derived1 | Derived2)[]; } +>func : (n: Base[]) => (Derived1 | Derived2)[] +>n => { return [d1, d2]; } : (n: Base[]) => (Derived1 | Derived2)[] +>n : Base[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +class x85 { constructor(parm: () => Base[] = () => [d1, d2]) { } } +>x85 : x85 +>parm : () => Base[] +>Base : Base +>() => [d1, d2] : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +class x86 { constructor(parm: () => Base[] = function() { return [d1, d2] }) { } } +>x86 : x86 +>parm : () => Base[] +>Base : Base +>function() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +class x87 { constructor(parm: () => Base[] = function named() { return [d1, d2] }) { } } +>x87 : x87 +>parm : () => Base[] +>Base : Base +>function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>named : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +class x88 { constructor(parm: { (): Base[]; } = () => [d1, d2]) { } } +>x88 : x88 +>parm : () => Base[] +>Base : Base +>() => [d1, d2] : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +class x89 { constructor(parm: { (): Base[]; } = function() { return [d1, d2] }) { } } +>x89 : x89 +>parm : () => Base[] +>Base : Base +>function() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +class x90 { constructor(parm: { (): Base[]; } = function named() { return [d1, d2] }) { } } +>x90 : x90 +>parm : () => Base[] +>Base : Base +>function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>named : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +class x91 { constructor(parm: Base[] = [d1, d2]) { } } +>x91 : x91 +>parm : Base[] +>Base : Base +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +class x92 { constructor(parm: Array = [d1, d2]) { } } +>x92 : x92 +>parm : Base[] +>Array : T[] +>Base : Base +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +class x93 { constructor(parm: { [n: number]: Base; } = [d1, d2]) { } } +>x93 : x93 +>parm : { [n: number]: Base; } +>n : number +>Base : Base +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +class x94 { constructor(parm: {n: Base[]; } = { n: [d1, d2] }) { } } +>x94 : x94 +>parm : { n: Base[]; } +>n : Base[] +>Base : Base +>{ n: [d1, d2] } : { n: (Derived1 | Derived2)[]; } +>n : (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +class x95 { constructor(parm: (s: Base[]) => any = n => { var n: Base[]; return null; }) { } } +>x95 : x95 +>parm : (s: Base[]) => any +>s : Base[] +>Base : Base +>n => { var n: Base[]; return null; } : (n: Base[]) => any +>n : Base[] +>n : Base[] +>Base : Base +>null : null + +class x96 { constructor(parm: Genric = { func: n => { return [d1, d2]; } }) { } } +>x96 : x96 +>parm : Genric +>Genric : Genric +>Base : Base +>{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => (Derived1 | Derived2)[]; } +>func : (n: Base[]) => (Derived1 | Derived2)[] +>n => { return [d1, d2]; } : (n: Base[]) => (Derived1 | Derived2)[] +>n : Base[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +class x97 { constructor(public parm: () => Base[] = () => [d1, d2]) { } } +>x97 : x97 +>parm : () => Base[] +>Base : Base +>() => [d1, d2] : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +class x98 { constructor(public parm: () => Base[] = function() { return [d1, d2] }) { } } +>x98 : x98 +>parm : () => Base[] +>Base : Base +>function() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +class x99 { constructor(public parm: () => Base[] = function named() { return [d1, d2] }) { } } +>x99 : x99 +>parm : () => Base[] +>Base : Base +>function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>named : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +class x100 { constructor(public parm: { (): Base[]; } = () => [d1, d2]) { } } +>x100 : x100 +>parm : () => Base[] +>Base : Base +>() => [d1, d2] : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +class x101 { constructor(public parm: { (): Base[]; } = function() { return [d1, d2] }) { } } +>x101 : x101 +>parm : () => Base[] +>Base : Base +>function() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +class x102 { constructor(public parm: { (): Base[]; } = function named() { return [d1, d2] }) { } } +>x102 : x102 +>parm : () => Base[] +>Base : Base +>function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>named : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +class x103 { constructor(public parm: Base[] = [d1, d2]) { } } +>x103 : x103 +>parm : Base[] +>Base : Base +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +class x104 { constructor(public parm: Array = [d1, d2]) { } } +>x104 : x104 +>parm : Base[] +>Array : T[] +>Base : Base +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +class x105 { constructor(public parm: { [n: number]: Base; } = [d1, d2]) { } } +>x105 : x105 +>parm : { [n: number]: Base; } +>n : number +>Base : Base +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +class x106 { constructor(public parm: {n: Base[]; } = { n: [d1, d2] }) { } } +>x106 : x106 +>parm : { n: Base[]; } +>n : Base[] +>Base : Base +>{ n: [d1, d2] } : { n: (Derived1 | Derived2)[]; } +>n : (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +class x107 { constructor(public parm: (s: Base[]) => any = n => { var n: Base[]; return null; }) { } } +>x107 : x107 +>parm : (s: Base[]) => any +>s : Base[] +>Base : Base +>n => { var n: Base[]; return null; } : (n: Base[]) => any +>n : Base[] +>n : Base[] +>Base : Base +>null : null + +class x108 { constructor(public parm: Genric = { func: n => { return [d1, d2]; } }) { } } +>x108 : x108 +>parm : Genric +>Genric : Genric +>Base : Base +>{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => (Derived1 | Derived2)[]; } +>func : (n: Base[]) => (Derived1 | Derived2)[] +>n => { return [d1, d2]; } : (n: Base[]) => (Derived1 | Derived2)[] +>n : Base[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +class x109 { constructor(private parm: () => Base[] = () => [d1, d2]) { } } +>x109 : x109 +>parm : () => Base[] +>Base : Base +>() => [d1, d2] : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +class x110 { constructor(private parm: () => Base[] = function() { return [d1, d2] }) { } } +>x110 : x110 +>parm : () => Base[] +>Base : Base +>function() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +class x111 { constructor(private parm: () => Base[] = function named() { return [d1, d2] }) { } } +>x111 : x111 +>parm : () => Base[] +>Base : Base +>function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>named : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +class x112 { constructor(private parm: { (): Base[]; } = () => [d1, d2]) { } } +>x112 : x112 +>parm : () => Base[] +>Base : Base +>() => [d1, d2] : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +class x113 { constructor(private parm: { (): Base[]; } = function() { return [d1, d2] }) { } } +>x113 : x113 +>parm : () => Base[] +>Base : Base +>function() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +class x114 { constructor(private parm: { (): Base[]; } = function named() { return [d1, d2] }) { } } +>x114 : x114 +>parm : () => Base[] +>Base : Base +>function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>named : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +class x115 { constructor(private parm: Base[] = [d1, d2]) { } } +>x115 : x115 +>parm : Base[] +>Base : Base +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +class x116 { constructor(private parm: Array = [d1, d2]) { } } +>x116 : x116 +>parm : Base[] +>Array : T[] +>Base : Base +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +class x117 { constructor(private parm: { [n: number]: Base; } = [d1, d2]) { } } +>x117 : x117 +>parm : { [n: number]: Base; } +>n : number +>Base : Base +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +class x118 { constructor(private parm: {n: Base[]; } = { n: [d1, d2] }) { } } +>x118 : x118 +>parm : { n: Base[]; } +>n : Base[] +>Base : Base +>{ n: [d1, d2] } : { n: (Derived1 | Derived2)[]; } +>n : (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +class x119 { constructor(private parm: (s: Base[]) => any = n => { var n: Base[]; return null; }) { } } +>x119 : x119 +>parm : (s: Base[]) => any +>s : Base[] +>Base : Base +>n => { var n: Base[]; return null; } : (n: Base[]) => any +>n : Base[] +>n : Base[] +>Base : Base +>null : null + +class x120 { constructor(private parm: Genric = { func: n => { return [d1, d2]; } }) { } } +>x120 : x120 +>parm : Genric +>Genric : Genric +>Base : Base +>{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => (Derived1 | Derived2)[]; } +>func : (n: Base[]) => (Derived1 | Derived2)[] +>n => { return [d1, d2]; } : (n: Base[]) => (Derived1 | Derived2)[] +>n : Base[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +function x121(parm: () => Base[] = () => [d1, d2]) { } +>x121 : (parm?: () => Base[]) => void +>parm : () => Base[] +>Base : Base +>() => [d1, d2] : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +function x122(parm: () => Base[] = function() { return [d1, d2] }) { } +>x122 : (parm?: () => Base[]) => void +>parm : () => Base[] +>Base : Base +>function() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +function x123(parm: () => Base[] = function named() { return [d1, d2] }) { } +>x123 : (parm?: () => Base[]) => void +>parm : () => Base[] +>Base : Base +>function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>named : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +function x124(parm: { (): Base[]; } = () => [d1, d2]) { } +>x124 : (parm?: () => Base[]) => void +>parm : () => Base[] +>Base : Base +>() => [d1, d2] : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +function x125(parm: { (): Base[]; } = function() { return [d1, d2] }) { } +>x125 : (parm?: () => Base[]) => void +>parm : () => Base[] +>Base : Base +>function() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +function x126(parm: { (): Base[]; } = function named() { return [d1, d2] }) { } +>x126 : (parm?: () => Base[]) => void +>parm : () => Base[] +>Base : Base +>function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>named : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +function x127(parm: Base[] = [d1, d2]) { } +>x127 : (parm?: Base[]) => void +>parm : Base[] +>Base : Base +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +function x128(parm: Array = [d1, d2]) { } +>x128 : (parm?: Base[]) => void +>parm : Base[] +>Array : T[] +>Base : Base +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +function x129(parm: { [n: number]: Base; } = [d1, d2]) { } +>x129 : (parm?: { [n: number]: Base; }) => void +>parm : { [n: number]: Base; } +>n : number +>Base : Base +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +function x130(parm: {n: Base[]; } = { n: [d1, d2] }) { } +>x130 : (parm?: { n: Base[]; }) => void +>parm : { n: Base[]; } +>n : Base[] +>Base : Base +>{ n: [d1, d2] } : { n: (Derived1 | Derived2)[]; } +>n : (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +function x131(parm: (s: Base[]) => any = n => { var n: Base[]; return null; }) { } +>x131 : (parm?: (s: Base[]) => any) => void +>parm : (s: Base[]) => any +>s : Base[] +>Base : Base +>n => { var n: Base[]; return null; } : (n: Base[]) => any +>n : Base[] +>n : Base[] +>Base : Base +>null : null + +function x132(parm: Genric = { func: n => { return [d1, d2]; } }) { } +>x132 : (parm?: Genric) => void +>parm : Genric +>Genric : Genric +>Base : Base +>{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => (Derived1 | Derived2)[]; } +>func : (n: Base[]) => (Derived1 | Derived2)[] +>n => { return [d1, d2]; } : (n: Base[]) => (Derived1 | Derived2)[] +>n : Base[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +function x133(): () => Base[] { return () => [d1, d2]; } +>x133 : () => () => Base[] +>Base : Base +>() => [d1, d2] : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +function x134(): () => Base[] { return function() { return [d1, d2] }; } +>x134 : () => () => Base[] +>Base : Base +>function() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +function x135(): () => Base[] { return function named() { return [d1, d2] }; } +>x135 : () => () => Base[] +>Base : Base +>function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>named : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +function x136(): { (): Base[]; } { return () => [d1, d2]; } +>x136 : () => () => Base[] +>Base : Base +>() => [d1, d2] : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +function x137(): { (): Base[]; } { return function() { return [d1, d2] }; } +>x137 : () => () => Base[] +>Base : Base +>function() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +function x138(): { (): Base[]; } { return function named() { return [d1, d2] }; } +>x138 : () => () => Base[] +>Base : Base +>function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>named : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +function x139(): Base[] { return [d1, d2]; } +>x139 : () => Base[] +>Base : Base +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +function x140(): Array { return [d1, d2]; } +>x140 : () => Base[] +>Array : T[] +>Base : Base +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +function x141(): { [n: number]: Base; } { return [d1, d2]; } +>x141 : () => { [n: number]: Base; } +>n : number +>Base : Base +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +function x142(): {n: Base[]; } { return { n: [d1, d2] }; } +>x142 : () => { n: Base[]; } +>n : Base[] +>Base : Base +>{ n: [d1, d2] } : { n: (Derived1 | Derived2)[]; } +>n : (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +function x143(): (s: Base[]) => any { return n => { var n: Base[]; return null; }; } +>x143 : () => (s: Base[]) => any +>s : Base[] +>Base : Base +>n => { var n: Base[]; return null; } : (n: Base[]) => any +>n : Base[] +>n : Base[] +>Base : Base +>null : null + +function x144(): Genric { return { func: n => { return [d1, d2]; } }; } +>x144 : () => Genric +>Genric : Genric +>Base : Base +>{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => (Derived1 | Derived2)[]; } +>func : (n: Base[]) => (Derived1 | Derived2)[] +>n => { return [d1, d2]; } : (n: Base[]) => (Derived1 | Derived2)[] +>n : Base[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +function x145(): () => Base[] { return () => [d1, d2]; return () => [d1, d2]; } +>x145 : () => () => Base[] +>Base : Base +>() => [d1, d2] : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 +>() => [d1, d2] : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +function x146(): () => Base[] { return function() { return [d1, d2] }; return function() { return [d1, d2] }; } +>x146 : () => () => Base[] +>Base : Base +>function() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 +>function() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +function x147(): () => Base[] { return function named() { return [d1, d2] }; return function named() { return [d1, d2] }; } +>x147 : () => () => Base[] +>Base : Base +>function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>named : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 +>function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>named : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +function x148(): { (): Base[]; } { return () => [d1, d2]; return () => [d1, d2]; } +>x148 : () => () => Base[] +>Base : Base +>() => [d1, d2] : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 +>() => [d1, d2] : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +function x149(): { (): Base[]; } { return function() { return [d1, d2] }; return function() { return [d1, d2] }; } +>x149 : () => () => Base[] +>Base : Base +>function() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 +>function() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +function x150(): { (): Base[]; } { return function named() { return [d1, d2] }; return function named() { return [d1, d2] }; } +>x150 : () => () => Base[] +>Base : Base +>function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>named : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 +>function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>named : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +function x151(): Base[] { return [d1, d2]; return [d1, d2]; } +>x151 : () => Base[] +>Base : Base +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +function x152(): Array { return [d1, d2]; return [d1, d2]; } +>x152 : () => Base[] +>Array : T[] +>Base : Base +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +function x153(): { [n: number]: Base; } { return [d1, d2]; return [d1, d2]; } +>x153 : () => { [n: number]: Base; } +>n : number +>Base : Base +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +function x154(): {n: Base[]; } { return { n: [d1, d2] }; return { n: [d1, d2] }; } +>x154 : () => { n: Base[]; } +>n : Base[] +>Base : Base +>{ n: [d1, d2] } : { n: (Derived1 | Derived2)[]; } +>n : (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 +>{ n: [d1, d2] } : { n: (Derived1 | Derived2)[]; } +>n : (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +function x155(): (s: Base[]) => any { return n => { var n: Base[]; return null; }; return n => { var n: Base[]; return null; }; } +>x155 : () => (s: Base[]) => any +>s : Base[] +>Base : Base +>n => { var n: Base[]; return null; } : (n: Base[]) => any +>n : Base[] +>n : Base[] +>Base : Base +>null : null +>n => { var n: Base[]; return null; } : (n: Base[]) => any +>n : Base[] +>n : Base[] +>Base : Base +>null : null + +function x156(): Genric { return { func: n => { return [d1, d2]; } }; return { func: n => { return [d1, d2]; } }; } +>x156 : () => Genric +>Genric : Genric +>Base : Base +>{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => (Derived1 | Derived2)[]; } +>func : (n: Base[]) => (Derived1 | Derived2)[] +>n => { return [d1, d2]; } : (n: Base[]) => (Derived1 | Derived2)[] +>n : Base[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 +>{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => (Derived1 | Derived2)[]; } +>func : (n: Base[]) => (Derived1 | Derived2)[] +>n => { return [d1, d2]; } : (n: Base[]) => (Derived1 | Derived2)[] +>n : Base[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +var x157: () => () => Base[] = () => { return () => [d1, d2]; }; +>x157 : () => () => Base[] +>Base : Base +>() => { return () => [d1, d2]; } : () => () => (Derived1 | Derived2)[] +>() => [d1, d2] : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +var x158: () => () => Base[] = () => { return function() { return [d1, d2] }; }; +>x158 : () => () => Base[] +>Base : Base +>() => { return function() { return [d1, d2] }; } : () => () => (Derived1 | Derived2)[] +>function() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +var x159: () => () => Base[] = () => { return function named() { return [d1, d2] }; }; +>x159 : () => () => Base[] +>Base : Base +>() => { return function named() { return [d1, d2] }; } : () => () => (Derived1 | Derived2)[] +>function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>named : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +var x160: () => { (): Base[]; } = () => { return () => [d1, d2]; }; +>x160 : () => () => Base[] +>Base : Base +>() => { return () => [d1, d2]; } : () => () => (Derived1 | Derived2)[] +>() => [d1, d2] : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +var x161: () => { (): Base[]; } = () => { return function() { return [d1, d2] }; }; +>x161 : () => () => Base[] +>Base : Base +>() => { return function() { return [d1, d2] }; } : () => () => (Derived1 | Derived2)[] +>function() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +var x162: () => { (): Base[]; } = () => { return function named() { return [d1, d2] }; }; +>x162 : () => () => Base[] +>Base : Base +>() => { return function named() { return [d1, d2] }; } : () => () => (Derived1 | Derived2)[] +>function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>named : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +var x163: () => Base[] = () => { return [d1, d2]; }; +>x163 : () => Base[] +>Base : Base +>() => { return [d1, d2]; } : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +var x164: () => Array = () => { return [d1, d2]; }; +>x164 : () => Base[] +>Array : T[] +>Base : Base +>() => { return [d1, d2]; } : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +var x165: () => { [n: number]: Base; } = () => { return [d1, d2]; }; +>x165 : () => { [n: number]: Base; } +>n : number +>Base : Base +>() => { return [d1, d2]; } : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +var x166: () => {n: Base[]; } = () => { return { n: [d1, d2] }; }; +>x166 : () => { n: Base[]; } +>n : Base[] +>Base : Base +>() => { return { n: [d1, d2] }; } : () => { n: (Derived1 | Derived2)[]; } +>{ n: [d1, d2] } : { n: (Derived1 | Derived2)[]; } +>n : (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +var x167: () => (s: Base[]) => any = () => { return n => { var n: Base[]; return null; }; }; +>x167 : () => (s: Base[]) => any +>s : Base[] +>Base : Base +>() => { return n => { var n: Base[]; return null; }; } : () => (n: Base[]) => any +>n => { var n: Base[]; return null; } : (n: Base[]) => any +>n : Base[] +>n : Base[] +>Base : Base +>null : null + +var x168: () => Genric = () => { return { func: n => { return [d1, d2]; } }; }; +>x168 : () => Genric +>Genric : Genric +>Base : Base +>() => { return { func: n => { return [d1, d2]; } }; } : () => { func: (n: Base[]) => (Derived1 | Derived2)[]; } +>{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => (Derived1 | Derived2)[]; } +>func : (n: Base[]) => (Derived1 | Derived2)[] +>n => { return [d1, d2]; } : (n: Base[]) => (Derived1 | Derived2)[] +>n : Base[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +var x169: () => () => Base[] = function() { return () => [d1, d2]; }; +>x169 : () => () => Base[] +>Base : Base +>function() { return () => [d1, d2]; } : () => () => (Derived1 | Derived2)[] +>() => [d1, d2] : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +var x170: () => () => Base[] = function() { return function() { return [d1, d2] }; }; +>x170 : () => () => Base[] +>Base : Base +>function() { return function() { return [d1, d2] }; } : () => () => (Derived1 | Derived2)[] +>function() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +var x171: () => () => Base[] = function() { return function named() { return [d1, d2] }; }; +>x171 : () => () => Base[] +>Base : Base +>function() { return function named() { return [d1, d2] }; } : () => () => (Derived1 | Derived2)[] +>function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>named : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +var x172: () => { (): Base[]; } = function() { return () => [d1, d2]; }; +>x172 : () => () => Base[] +>Base : Base +>function() { return () => [d1, d2]; } : () => () => (Derived1 | Derived2)[] +>() => [d1, d2] : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +var x173: () => { (): Base[]; } = function() { return function() { return [d1, d2] }; }; +>x173 : () => () => Base[] +>Base : Base +>function() { return function() { return [d1, d2] }; } : () => () => (Derived1 | Derived2)[] +>function() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +var x174: () => { (): Base[]; } = function() { return function named() { return [d1, d2] }; }; +>x174 : () => () => Base[] +>Base : Base +>function() { return function named() { return [d1, d2] }; } : () => () => (Derived1 | Derived2)[] +>function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>named : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +var x175: () => Base[] = function() { return [d1, d2]; }; +>x175 : () => Base[] +>Base : Base +>function() { return [d1, d2]; } : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +var x176: () => Array = function() { return [d1, d2]; }; +>x176 : () => Base[] +>Array : T[] +>Base : Base +>function() { return [d1, d2]; } : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +var x177: () => { [n: number]: Base; } = function() { return [d1, d2]; }; +>x177 : () => { [n: number]: Base; } +>n : number +>Base : Base +>function() { return [d1, d2]; } : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +var x178: () => {n: Base[]; } = function() { return { n: [d1, d2] }; }; +>x178 : () => { n: Base[]; } +>n : Base[] +>Base : Base +>function() { return { n: [d1, d2] }; } : () => { n: (Derived1 | Derived2)[]; } +>{ n: [d1, d2] } : { n: (Derived1 | Derived2)[]; } +>n : (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +var x179: () => (s: Base[]) => any = function() { return n => { var n: Base[]; return null; }; }; +>x179 : () => (s: Base[]) => any +>s : Base[] +>Base : Base +>function() { return n => { var n: Base[]; return null; }; } : () => (n: Base[]) => any +>n => { var n: Base[]; return null; } : (n: Base[]) => any +>n : Base[] +>n : Base[] +>Base : Base +>null : null + +var x180: () => Genric = function() { return { func: n => { return [d1, d2]; } }; }; +>x180 : () => Genric +>Genric : Genric +>Base : Base +>function() { return { func: n => { return [d1, d2]; } }; } : () => { func: (n: Base[]) => (Derived1 | Derived2)[]; } +>{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => (Derived1 | Derived2)[]; } +>func : (n: Base[]) => (Derived1 | Derived2)[] +>n => { return [d1, d2]; } : (n: Base[]) => (Derived1 | Derived2)[] +>n : Base[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +module x181 { var t: () => Base[] = () => [d1, d2]; } +>x181 : typeof x181 +>t : () => Base[] +>Base : Base +>() => [d1, d2] : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +module x182 { var t: () => Base[] = function() { return [d1, d2] }; } +>x182 : typeof x182 +>t : () => Base[] +>Base : Base +>function() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +module x183 { var t: () => Base[] = function named() { return [d1, d2] }; } +>x183 : typeof x183 +>t : () => Base[] +>Base : Base +>function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>named : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +module x184 { var t: { (): Base[]; } = () => [d1, d2]; } +>x184 : typeof x184 +>t : () => Base[] +>Base : Base +>() => [d1, d2] : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +module x185 { var t: { (): Base[]; } = function() { return [d1, d2] }; } +>x185 : typeof x185 +>t : () => Base[] +>Base : Base +>function() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +module x186 { var t: { (): Base[]; } = function named() { return [d1, d2] }; } +>x186 : typeof x186 +>t : () => Base[] +>Base : Base +>function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>named : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +module x187 { var t: Base[] = [d1, d2]; } +>x187 : typeof x187 +>t : Base[] +>Base : Base +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +module x188 { var t: Array = [d1, d2]; } +>x188 : typeof x188 +>t : Base[] +>Array : T[] +>Base : Base +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +module x189 { var t: { [n: number]: Base; } = [d1, d2]; } +>x189 : typeof x189 +>t : { [n: number]: Base; } +>n : number +>Base : Base +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +module x190 { var t: {n: Base[]; } = { n: [d1, d2] }; } +>x190 : typeof x190 +>t : { n: Base[]; } +>n : Base[] +>Base : Base +>{ n: [d1, d2] } : { n: (Derived1 | Derived2)[]; } +>n : (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +module x191 { var t: (s: Base[]) => any = n => { var n: Base[]; return null; }; } +>x191 : typeof x191 +>t : (s: Base[]) => any +>s : Base[] +>Base : Base +>n => { var n: Base[]; return null; } : (n: Base[]) => any +>n : Base[] +>n : Base[] +>Base : Base +>null : null + +module x192 { var t: Genric = { func: n => { return [d1, d2]; } }; } +>x192 : typeof x192 +>t : Genric +>Genric : Genric +>Base : Base +>{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => (Derived1 | Derived2)[]; } +>func : (n: Base[]) => (Derived1 | Derived2)[] +>n => { return [d1, d2]; } : (n: Base[]) => (Derived1 | Derived2)[] +>n : Base[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +module x193 { export var t: () => Base[] = () => [d1, d2]; } +>x193 : typeof x193 +>t : () => Base[] +>Base : Base +>() => [d1, d2] : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +module x194 { export var t: () => Base[] = function() { return [d1, d2] }; } +>x194 : typeof x194 +>t : () => Base[] +>Base : Base +>function() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +module x195 { export var t: () => Base[] = function named() { return [d1, d2] }; } +>x195 : typeof x195 +>t : () => Base[] +>Base : Base +>function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>named : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +module x196 { export var t: { (): Base[]; } = () => [d1, d2]; } +>x196 : typeof x196 +>t : () => Base[] +>Base : Base +>() => [d1, d2] : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +module x197 { export var t: { (): Base[]; } = function() { return [d1, d2] }; } +>x197 : typeof x197 +>t : () => Base[] +>Base : Base +>function() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +module x198 { export var t: { (): Base[]; } = function named() { return [d1, d2] }; } +>x198 : typeof x198 +>t : () => Base[] +>Base : Base +>function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>named : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +module x199 { export var t: Base[] = [d1, d2]; } +>x199 : typeof x199 +>t : Base[] +>Base : Base +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +module x200 { export var t: Array = [d1, d2]; } +>x200 : typeof x200 +>t : Base[] +>Array : T[] +>Base : Base +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +module x201 { export var t: { [n: number]: Base; } = [d1, d2]; } +>x201 : typeof x201 +>t : { [n: number]: Base; } +>n : number +>Base : Base +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +module x202 { export var t: {n: Base[]; } = { n: [d1, d2] }; } +>x202 : typeof x202 +>t : { n: Base[]; } +>n : Base[] +>Base : Base +>{ n: [d1, d2] } : { n: (Derived1 | Derived2)[]; } +>n : (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +module x203 { export var t: (s: Base[]) => any = n => { var n: Base[]; return null; }; } +>x203 : typeof x203 +>t : (s: Base[]) => any +>s : Base[] +>Base : Base +>n => { var n: Base[]; return null; } : (n: Base[]) => any +>n : Base[] +>n : Base[] +>Base : Base +>null : null + +module x204 { export var t: Genric = { func: n => { return [d1, d2]; } }; } +>x204 : typeof x204 +>t : Genric +>Genric : Genric +>Base : Base +>{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => (Derived1 | Derived2)[]; } +>func : (n: Base[]) => (Derived1 | Derived2)[] +>n => { return [d1, d2]; } : (n: Base[]) => (Derived1 | Derived2)[] +>n : Base[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +var x206 = <() => Base[]>function() { return [d1, d2] }; +>x206 : () => Base[] +><() => Base[]>function() { return [d1, d2] } : () => Base[] +>Base : Base +>function() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +var x207 = <() => Base[]>function named() { return [d1, d2] }; +>x207 : () => Base[] +><() => Base[]>function named() { return [d1, d2] } : () => Base[] +>Base : Base +>function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>named : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +var x209 = <{ (): Base[]; }>function() { return [d1, d2] }; +>x209 : () => Base[] +><{ (): Base[]; }>function() { return [d1, d2] } : () => Base[] +>Base : Base +>function() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +var x210 = <{ (): Base[]; }>function named() { return [d1, d2] }; +>x210 : () => Base[] +><{ (): Base[]; }>function named() { return [d1, d2] } : () => Base[] +>Base : Base +>function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>named : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +var x211 = [d1, d2]; +>x211 : Base[] +>[d1, d2] : Base[] +>Base : Base +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +var x212 = >[d1, d2]; +>x212 : Base[] +>>[d1, d2] : Base[] +>Array : T[] +>Base : Base +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +var x213 = <{ [n: number]: Base; }>[d1, d2]; +>x213 : { [n: number]: Base; } +><{ [n: number]: Base; }>[d1, d2] : { [n: number]: Base; } +>n : number +>Base : Base +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +var x214 = <{n: Base[]; } >{ n: [d1, d2] }; +>x214 : { n: Base[]; } +><{n: Base[]; } >{ n: [d1, d2] } : { n: Base[]; } +>n : Base[] +>Base : Base +>{ n: [d1, d2] } : { n: (Derived1 | Derived2)[]; } +>n : (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +var x216 = >{ func: n => { return [d1, d2]; } }; +>x216 : Genric +>>{ func: n => { return [d1, d2]; } } : Genric +>Genric : Genric +>Base : Base +>{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => (Derived1 | Derived2)[]; } +>func : (n: Base[]) => (Derived1 | Derived2)[] +>n => { return [d1, d2]; } : (n: Base[]) => (Derived1 | Derived2)[] +>n : Base[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +var x217 = (<() => Base[]>undefined) || function() { return [d1, d2] }; +>x217 : () => Base[] +>(<() => Base[]>undefined) || function() { return [d1, d2] } : () => Base[] +>(<() => Base[]>undefined) : () => Base[] +><() => Base[]>undefined : () => Base[] +>Base : Base +>undefined : undefined +>function() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +var x218 = (<() => Base[]>undefined) || function named() { return [d1, d2] }; +>x218 : () => Base[] +>(<() => Base[]>undefined) || function named() { return [d1, d2] } : () => Base[] +>(<() => Base[]>undefined) : () => Base[] +><() => Base[]>undefined : () => Base[] +>Base : Base +>undefined : undefined +>function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>named : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +var x219 = (<{ (): Base[]; }>undefined) || function() { return [d1, d2] }; +>x219 : () => Base[] +>(<{ (): Base[]; }>undefined) || function() { return [d1, d2] } : () => Base[] +>(<{ (): Base[]; }>undefined) : () => Base[] +><{ (): Base[]; }>undefined : () => Base[] +>Base : Base +>undefined : undefined +>function() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +var x220 = (<{ (): Base[]; }>undefined) || function named() { return [d1, d2] }; +>x220 : () => Base[] +>(<{ (): Base[]; }>undefined) || function named() { return [d1, d2] } : () => Base[] +>(<{ (): Base[]; }>undefined) : () => Base[] +><{ (): Base[]; }>undefined : () => Base[] +>Base : Base +>undefined : undefined +>function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>named : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +var x221 = (undefined) || [d1, d2]; +>x221 : Base[] +>(undefined) || [d1, d2] : Base[] +>(undefined) : Base[] +>undefined : Base[] +>Base : Base +>undefined : undefined +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +var x222 = (>undefined) || [d1, d2]; +>x222 : Base[] +>(>undefined) || [d1, d2] : Base[] +>(>undefined) : Base[] +>>undefined : Base[] +>Array : T[] +>Base : Base +>undefined : undefined +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +var x223 = (<{ [n: number]: Base; }>undefined) || [d1, d2]; +>x223 : { [n: number]: Base; } +>(<{ [n: number]: Base; }>undefined) || [d1, d2] : { [n: number]: Base; } +>(<{ [n: number]: Base; }>undefined) : { [n: number]: Base; } +><{ [n: number]: Base; }>undefined : { [n: number]: Base; } +>n : number +>Base : Base +>undefined : undefined +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +var x224 = (<{n: Base[]; } >undefined) || { n: [d1, d2] }; +>x224 : { n: Base[]; } +>(<{n: Base[]; } >undefined) || { n: [d1, d2] } : { n: Base[]; } +>(<{n: Base[]; } >undefined) : { n: Base[]; } +><{n: Base[]; } >undefined : { n: Base[]; } +>n : Base[] +>Base : Base +>undefined : undefined +>{ n: [d1, d2] } : { n: (Derived1 | Derived2)[]; } +>n : (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +var x225: () => Base[]; x225 = () => [d1, d2]; +>x225 : () => Base[] +>Base : Base +>x225 = () => [d1, d2] : () => (Derived1 | Derived2)[] +>x225 : () => Base[] +>() => [d1, d2] : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +var x226: () => Base[]; x226 = function() { return [d1, d2] }; +>x226 : () => Base[] +>Base : Base +>x226 = function() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>x226 : () => Base[] +>function() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +var x227: () => Base[]; x227 = function named() { return [d1, d2] }; +>x227 : () => Base[] +>Base : Base +>x227 = function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>x227 : () => Base[] +>function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>named : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +var x228: { (): Base[]; }; x228 = () => [d1, d2]; +>x228 : () => Base[] +>Base : Base +>x228 = () => [d1, d2] : () => (Derived1 | Derived2)[] +>x228 : () => Base[] +>() => [d1, d2] : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +var x229: { (): Base[]; }; x229 = function() { return [d1, d2] }; +>x229 : () => Base[] +>Base : Base +>x229 = function() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>x229 : () => Base[] +>function() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +var x230: { (): Base[]; }; x230 = function named() { return [d1, d2] }; +>x230 : () => Base[] +>Base : Base +>x230 = function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>x230 : () => Base[] +>function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>named : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +var x231: Base[]; x231 = [d1, d2]; +>x231 : Base[] +>Base : Base +>x231 = [d1, d2] : (Derived1 | Derived2)[] +>x231 : Base[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +var x232: Array; x232 = [d1, d2]; +>x232 : Base[] +>Array : T[] +>Base : Base +>x232 = [d1, d2] : (Derived1 | Derived2)[] +>x232 : Base[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +var x233: { [n: number]: Base; }; x233 = [d1, d2]; +>x233 : { [n: number]: Base; } +>n : number +>Base : Base +>x233 = [d1, d2] : (Derived1 | Derived2)[] +>x233 : { [n: number]: Base; } +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +var x234: {n: Base[]; } ; x234 = { n: [d1, d2] }; +>x234 : { n: Base[]; } +>n : Base[] +>Base : Base +>x234 = { n: [d1, d2] } : { n: (Derived1 | Derived2)[]; } +>x234 : { n: Base[]; } +>{ n: [d1, d2] } : { n: (Derived1 | Derived2)[]; } +>n : (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +var x235: (s: Base[]) => any; x235 = n => { var n: Base[]; return null; }; +>x235 : (s: Base[]) => any +>s : Base[] +>Base : Base +>x235 = n => { var n: Base[]; return null; } : (n: Base[]) => any +>x235 : (s: Base[]) => any +>n => { var n: Base[]; return null; } : (n: Base[]) => any +>n : Base[] +>n : Base[] +>Base : Base +>null : null + +var x236: Genric; x236 = { func: n => { return [d1, d2]; } }; +>x236 : Genric +>Genric : Genric +>Base : Base +>x236 = { func: n => { return [d1, d2]; } } : { func: (n: Base[]) => (Derived1 | Derived2)[]; } +>x236 : Genric +>{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => (Derived1 | Derived2)[]; } +>func : (n: Base[]) => (Derived1 | Derived2)[] +>n => { return [d1, d2]; } : (n: Base[]) => (Derived1 | Derived2)[] +>n : Base[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +var x237: { n: () => Base[]; } = { n: () => [d1, d2] }; +>x237 : { n: () => Base[]; } +>n : () => Base[] +>Base : Base +>{ n: () => [d1, d2] } : { n: () => (Derived1 | Derived2)[]; } +>n : () => (Derived1 | Derived2)[] +>() => [d1, d2] : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +var x238: { n: () => Base[]; } = { n: function() { return [d1, d2] } }; +>x238 : { n: () => Base[]; } +>n : () => Base[] +>Base : Base +>{ n: function() { return [d1, d2] } } : { n: () => (Derived1 | Derived2)[]; } +>n : () => (Derived1 | Derived2)[] +>function() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +var x239: { n: () => Base[]; } = { n: function named() { return [d1, d2] } }; +>x239 : { n: () => Base[]; } +>n : () => Base[] +>Base : Base +>{ n: function named() { return [d1, d2] } } : { n: () => (Derived1 | Derived2)[]; } +>n : () => (Derived1 | Derived2)[] +>function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>named : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +var x240: { n: { (): Base[]; }; } = { n: () => [d1, d2] }; +>x240 : { n: () => Base[]; } +>n : () => Base[] +>Base : Base +>{ n: () => [d1, d2] } : { n: () => (Derived1 | Derived2)[]; } +>n : () => (Derived1 | Derived2)[] +>() => [d1, d2] : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +var x241: { n: { (): Base[]; }; } = { n: function() { return [d1, d2] } }; +>x241 : { n: () => Base[]; } +>n : () => Base[] +>Base : Base +>{ n: function() { return [d1, d2] } } : { n: () => (Derived1 | Derived2)[]; } +>n : () => (Derived1 | Derived2)[] +>function() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +var x242: { n: { (): Base[]; }; } = { n: function named() { return [d1, d2] } }; +>x242 : { n: () => Base[]; } +>n : () => Base[] +>Base : Base +>{ n: function named() { return [d1, d2] } } : { n: () => (Derived1 | Derived2)[]; } +>n : () => (Derived1 | Derived2)[] +>function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>named : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +var x243: { n: Base[]; } = { n: [d1, d2] }; +>x243 : { n: Base[]; } +>n : Base[] +>Base : Base +>{ n: [d1, d2] } : { n: (Derived1 | Derived2)[]; } +>n : (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +var x244: { n: Array; } = { n: [d1, d2] }; +>x244 : { n: Base[]; } +>n : Base[] +>Array : T[] +>Base : Base +>{ n: [d1, d2] } : { n: (Derived1 | Derived2)[]; } +>n : (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +var x245: { n: { [n: number]: Base; }; } = { n: [d1, d2] }; +>x245 : { n: { [n: number]: Base; }; } +>n : { [n: number]: Base; } +>n : number +>Base : Base +>{ n: [d1, d2] } : { n: (Derived1 | Derived2)[]; } +>n : (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +var x246: { n: {n: Base[]; } ; } = { n: { n: [d1, d2] } }; +>x246 : { n: { n: Base[]; }; } +>n : { n: Base[]; } +>n : Base[] +>Base : Base +>{ n: { n: [d1, d2] } } : { n: { n: (Derived1 | Derived2)[]; }; } +>n : { n: (Derived1 | Derived2)[]; } +>{ n: [d1, d2] } : { n: (Derived1 | Derived2)[]; } +>n : (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +var x247: { n: (s: Base[]) => any; } = { n: n => { var n: Base[]; return null; } }; +>x247 : { n: (s: Base[]) => any; } +>n : (s: Base[]) => any +>s : Base[] +>Base : Base +>{ n: n => { var n: Base[]; return null; } } : { n: (n: Base[]) => any; } +>n : (n: Base[]) => any +>n => { var n: Base[]; return null; } : (n: Base[]) => any +>n : Base[] +>n : Base[] +>Base : Base +>null : null + +var x248: { n: Genric; } = { n: { func: n => { return [d1, d2]; } } }; +>x248 : { n: Genric; } +>n : Genric +>Genric : Genric +>Base : Base +>{ n: { func: n => { return [d1, d2]; } } } : { n: { func: (n: Base[]) => (Derived1 | Derived2)[]; }; } +>n : { func: (n: Base[]) => (Derived1 | Derived2)[]; } +>{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => (Derived1 | Derived2)[]; } +>func : (n: Base[]) => (Derived1 | Derived2)[] +>n => { return [d1, d2]; } : (n: Base[]) => (Derived1 | Derived2)[] +>n : Base[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +var x252: { (): Base[]; }[] = [() => [d1, d2]]; +>x252 : (() => Base[])[] +>Base : Base +>[() => [d1, d2]] : (() => (Derived1 | Derived2)[])[] +>() => [d1, d2] : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +var x253: { (): Base[]; }[] = [function() { return [d1, d2] }]; +>x253 : (() => Base[])[] +>Base : Base +>[function() { return [d1, d2] }] : (() => (Derived1 | Derived2)[])[] +>function() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +var x254: { (): Base[]; }[] = [function named() { return [d1, d2] }]; +>x254 : (() => Base[])[] +>Base : Base +>[function named() { return [d1, d2] }] : (() => (Derived1 | Derived2)[])[] +>function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>named : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +var x255: Base[][] = [[d1, d2]]; +>x255 : Base[][] +>Base : Base +>[[d1, d2]] : (Derived1 | Derived2)[][] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +var x256: Array[] = [[d1, d2]]; +>x256 : Base[][] +>Array : T[] +>Base : Base +>[[d1, d2]] : (Derived1 | Derived2)[][] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +var x257: { [n: number]: Base; }[] = [[d1, d2]]; +>x257 : { [n: number]: Base; }[] +>n : number +>Base : Base +>[[d1, d2]] : (Derived1 | Derived2)[][] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +var x258: {n: Base[]; } [] = [{ n: [d1, d2] }]; +>x258 : { n: Base[]; }[] +>n : Base[] +>Base : Base +>[{ n: [d1, d2] }] : { n: (Derived1 | Derived2)[]; }[] +>{ n: [d1, d2] } : { n: (Derived1 | Derived2)[]; } +>n : (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +var x260: Genric[] = [{ func: n => { return [d1, d2]; } }]; +>x260 : Genric[] +>Genric : Genric +>Base : Base +>[{ func: n => { return [d1, d2]; } }] : { func: (n: Base[]) => (Derived1 | Derived2)[]; }[] +>{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => (Derived1 | Derived2)[]; } +>func : (n: Base[]) => (Derived1 | Derived2)[] +>n => { return [d1, d2]; } : (n: Base[]) => (Derived1 | Derived2)[] +>n : Base[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +var x261: () => Base[] = function() { return [d1, d2] } || undefined; +>x261 : () => Base[] +>Base : Base +>function() { return [d1, d2] } || undefined : () => (Derived1 | Derived2)[] +>function() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 +>undefined : undefined + +var x262: () => Base[] = function named() { return [d1, d2] } || undefined; +>x262 : () => Base[] +>Base : Base +>function named() { return [d1, d2] } || undefined : () => (Derived1 | Derived2)[] +>function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>named : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 +>undefined : undefined + +var x263: { (): Base[]; } = function() { return [d1, d2] } || undefined; +>x263 : () => Base[] +>Base : Base +>function() { return [d1, d2] } || undefined : () => (Derived1 | Derived2)[] +>function() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 +>undefined : undefined + +var x264: { (): Base[]; } = function named() { return [d1, d2] } || undefined; +>x264 : () => Base[] +>Base : Base +>function named() { return [d1, d2] } || undefined : () => (Derived1 | Derived2)[] +>function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>named : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 +>undefined : undefined + +var x265: Base[] = [d1, d2] || undefined; +>x265 : Base[] +>Base : Base +>[d1, d2] || undefined : (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 +>undefined : undefined + +var x266: Array = [d1, d2] || undefined; +>x266 : Base[] +>Array : T[] +>Base : Base +>[d1, d2] || undefined : (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 +>undefined : undefined + +var x267: { [n: number]: Base; } = [d1, d2] || undefined; +>x267 : { [n: number]: Base; } +>n : number +>Base : Base +>[d1, d2] || undefined : (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 +>undefined : undefined + +var x268: {n: Base[]; } = { n: [d1, d2] } || undefined; +>x268 : { n: Base[]; } +>n : Base[] +>Base : Base +>{ n: [d1, d2] } || undefined : { n: (Derived1 | Derived2)[]; } +>{ n: [d1, d2] } : { n: (Derived1 | Derived2)[]; } +>n : (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 +>undefined : undefined + +var x269: () => Base[] = undefined || function() { return [d1, d2] }; +>x269 : () => Base[] +>Base : Base +>undefined || function() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>undefined : undefined +>function() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +var x270: () => Base[] = undefined || function named() { return [d1, d2] }; +>x270 : () => Base[] +>Base : Base +>undefined || function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>undefined : undefined +>function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>named : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +var x271: { (): Base[]; } = undefined || function() { return [d1, d2] }; +>x271 : () => Base[] +>Base : Base +>undefined || function() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>undefined : undefined +>function() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +var x272: { (): Base[]; } = undefined || function named() { return [d1, d2] }; +>x272 : () => Base[] +>Base : Base +>undefined || function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>undefined : undefined +>function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>named : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +var x273: Base[] = undefined || [d1, d2]; +>x273 : Base[] +>Base : Base +>undefined || [d1, d2] : (Derived1 | Derived2)[] +>undefined : undefined +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +var x274: Array = undefined || [d1, d2]; +>x274 : Base[] +>Array : T[] +>Base : Base +>undefined || [d1, d2] : (Derived1 | Derived2)[] +>undefined : undefined +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +var x275: { [n: number]: Base; } = undefined || [d1, d2]; +>x275 : { [n: number]: Base; } +>n : number +>Base : Base +>undefined || [d1, d2] : (Derived1 | Derived2)[] +>undefined : undefined +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +var x276: {n: Base[]; } = undefined || { n: [d1, d2] }; +>x276 : { n: Base[]; } +>n : Base[] +>Base : Base +>undefined || { n: [d1, d2] } : { n: (Derived1 | Derived2)[]; } +>undefined : undefined +>{ n: [d1, d2] } : { n: (Derived1 | Derived2)[]; } +>n : (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +var x277: () => Base[] = function() { return [d1, d2] } || function() { return [d1, d2] }; +>x277 : () => Base[] +>Base : Base +>function() { return [d1, d2] } || function() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>function() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 +>function() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +var x278: () => Base[] = function named() { return [d1, d2] } || function named() { return [d1, d2] }; +>x278 : () => Base[] +>Base : Base +>function named() { return [d1, d2] } || function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>named : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 +>function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>named : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +var x279: { (): Base[]; } = function() { return [d1, d2] } || function() { return [d1, d2] }; +>x279 : () => Base[] +>Base : Base +>function() { return [d1, d2] } || function() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>function() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 +>function() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +var x280: { (): Base[]; } = function named() { return [d1, d2] } || function named() { return [d1, d2] }; +>x280 : () => Base[] +>Base : Base +>function named() { return [d1, d2] } || function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>named : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 +>function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>named : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +var x281: Base[] = [d1, d2] || [d1, d2]; +>x281 : Base[] +>Base : Base +>[d1, d2] || [d1, d2] : (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +var x282: Array = [d1, d2] || [d1, d2]; +>x282 : Base[] +>Array : T[] +>Base : Base +>[d1, d2] || [d1, d2] : (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +var x283: { [n: number]: Base; } = [d1, d2] || [d1, d2]; +>x283 : { [n: number]: Base; } +>n : number +>Base : Base +>[d1, d2] || [d1, d2] : (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +var x284: {n: Base[]; } = { n: [d1, d2] } || { n: [d1, d2] }; +>x284 : { n: Base[]; } +>n : Base[] +>Base : Base +>{ n: [d1, d2] } || { n: [d1, d2] } : { n: (Derived1 | Derived2)[]; } +>{ n: [d1, d2] } : { n: (Derived1 | Derived2)[]; } +>n : (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 +>{ n: [d1, d2] } : { n: (Derived1 | Derived2)[]; } +>n : (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +var x285: () => Base[] = true ? () => [d1, d2] : () => [d1, d2]; +>x285 : () => Base[] +>Base : Base +>true ? () => [d1, d2] : () => [d1, d2] : () => (Derived1 | Derived2)[] +>true : boolean +>() => [d1, d2] : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 +>() => [d1, d2] : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +var x286: () => Base[] = true ? function() { return [d1, d2] } : function() { return [d1, d2] }; +>x286 : () => Base[] +>Base : Base +>true ? function() { return [d1, d2] } : function() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>true : boolean +>function() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 +>function() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +var x287: () => Base[] = true ? function named() { return [d1, d2] } : function named() { return [d1, d2] }; +>x287 : () => Base[] +>Base : Base +>true ? function named() { return [d1, d2] } : function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>true : boolean +>function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>named : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 +>function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>named : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +var x288: { (): Base[]; } = true ? () => [d1, d2] : () => [d1, d2]; +>x288 : () => Base[] +>Base : Base +>true ? () => [d1, d2] : () => [d1, d2] : () => (Derived1 | Derived2)[] +>true : boolean +>() => [d1, d2] : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 +>() => [d1, d2] : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +var x289: { (): Base[]; } = true ? function() { return [d1, d2] } : function() { return [d1, d2] }; +>x289 : () => Base[] +>Base : Base +>true ? function() { return [d1, d2] } : function() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>true : boolean +>function() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 +>function() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +var x290: { (): Base[]; } = true ? function named() { return [d1, d2] } : function named() { return [d1, d2] }; +>x290 : () => Base[] +>Base : Base +>true ? function named() { return [d1, d2] } : function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>true : boolean +>function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>named : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 +>function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>named : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +var x291: Base[] = true ? [d1, d2] : [d1, d2]; +>x291 : Base[] +>Base : Base +>true ? [d1, d2] : [d1, d2] : (Derived1 | Derived2)[] +>true : boolean +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +var x292: Array = true ? [d1, d2] : [d1, d2]; +>x292 : Base[] +>Array : T[] +>Base : Base +>true ? [d1, d2] : [d1, d2] : (Derived1 | Derived2)[] +>true : boolean +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +var x293: { [n: number]: Base; } = true ? [d1, d2] : [d1, d2]; +>x293 : { [n: number]: Base; } +>n : number +>Base : Base +>true ? [d1, d2] : [d1, d2] : (Derived1 | Derived2)[] +>true : boolean +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +var x294: {n: Base[]; } = true ? { n: [d1, d2] } : { n: [d1, d2] }; +>x294 : { n: Base[]; } +>n : Base[] +>Base : Base +>true ? { n: [d1, d2] } : { n: [d1, d2] } : { n: (Derived1 | Derived2)[]; } +>true : boolean +>{ n: [d1, d2] } : { n: (Derived1 | Derived2)[]; } +>n : (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 +>{ n: [d1, d2] } : { n: (Derived1 | Derived2)[]; } +>n : (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +var x295: (s: Base[]) => any = true ? n => { var n: Base[]; return null; } : n => { var n: Base[]; return null; }; +>x295 : (s: Base[]) => any +>s : Base[] +>Base : Base +>true ? n => { var n: Base[]; return null; } : n => { var n: Base[]; return null; } : (n: Base[]) => any +>true : boolean +>n => { var n: Base[]; return null; } : (n: Base[]) => any +>n : Base[] +>n : Base[] +>Base : Base +>null : null +>n => { var n: Base[]; return null; } : (n: Base[]) => any +>n : Base[] +>n : Base[] +>Base : Base +>null : null + +var x296: Genric = true ? { func: n => { return [d1, d2]; } } : { func: n => { return [d1, d2]; } }; +>x296 : Genric +>Genric : Genric +>Base : Base +>true ? { func: n => { return [d1, d2]; } } : { func: n => { return [d1, d2]; } } : { func: (n: Base[]) => (Derived1 | Derived2)[]; } +>true : boolean +>{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => (Derived1 | Derived2)[]; } +>func : (n: Base[]) => (Derived1 | Derived2)[] +>n => { return [d1, d2]; } : (n: Base[]) => (Derived1 | Derived2)[] +>n : Base[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 +>{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => (Derived1 | Derived2)[]; } +>func : (n: Base[]) => (Derived1 | Derived2)[] +>n => { return [d1, d2]; } : (n: Base[]) => (Derived1 | Derived2)[] +>n : Base[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +var x297: () => Base[] = true ? undefined : () => [d1, d2]; +>x297 : () => Base[] +>Base : Base +>true ? undefined : () => [d1, d2] : () => (Derived1 | Derived2)[] +>true : boolean +>undefined : undefined +>() => [d1, d2] : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +var x298: () => Base[] = true ? undefined : function() { return [d1, d2] }; +>x298 : () => Base[] +>Base : Base +>true ? undefined : function() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>true : boolean +>undefined : undefined +>function() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +var x299: () => Base[] = true ? undefined : function named() { return [d1, d2] }; +>x299 : () => Base[] +>Base : Base +>true ? undefined : function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>true : boolean +>undefined : undefined +>function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>named : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +var x300: { (): Base[]; } = true ? undefined : () => [d1, d2]; +>x300 : () => Base[] +>Base : Base +>true ? undefined : () => [d1, d2] : () => (Derived1 | Derived2)[] +>true : boolean +>undefined : undefined +>() => [d1, d2] : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +var x301: { (): Base[]; } = true ? undefined : function() { return [d1, d2] }; +>x301 : () => Base[] +>Base : Base +>true ? undefined : function() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>true : boolean +>undefined : undefined +>function() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +var x302: { (): Base[]; } = true ? undefined : function named() { return [d1, d2] }; +>x302 : () => Base[] +>Base : Base +>true ? undefined : function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>true : boolean +>undefined : undefined +>function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>named : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +var x303: Base[] = true ? undefined : [d1, d2]; +>x303 : Base[] +>Base : Base +>true ? undefined : [d1, d2] : (Derived1 | Derived2)[] +>true : boolean +>undefined : undefined +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +var x304: Array = true ? undefined : [d1, d2]; +>x304 : Base[] +>Array : T[] +>Base : Base +>true ? undefined : [d1, d2] : (Derived1 | Derived2)[] +>true : boolean +>undefined : undefined +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +var x305: { [n: number]: Base; } = true ? undefined : [d1, d2]; +>x305 : { [n: number]: Base; } +>n : number +>Base : Base +>true ? undefined : [d1, d2] : (Derived1 | Derived2)[] +>true : boolean +>undefined : undefined +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +var x306: {n: Base[]; } = true ? undefined : { n: [d1, d2] }; +>x306 : { n: Base[]; } +>n : Base[] +>Base : Base +>true ? undefined : { n: [d1, d2] } : { n: (Derived1 | Derived2)[]; } +>true : boolean +>undefined : undefined +>{ n: [d1, d2] } : { n: (Derived1 | Derived2)[]; } +>n : (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +var x307: (s: Base[]) => any = true ? undefined : n => { var n: Base[]; return null; }; +>x307 : (s: Base[]) => any +>s : Base[] +>Base : Base +>true ? undefined : n => { var n: Base[]; return null; } : (n: Base[]) => any +>true : boolean +>undefined : undefined +>n => { var n: Base[]; return null; } : (n: Base[]) => any +>n : Base[] +>n : Base[] +>Base : Base +>null : null + +var x308: Genric = true ? undefined : { func: n => { return [d1, d2]; } }; +>x308 : Genric +>Genric : Genric +>Base : Base +>true ? undefined : { func: n => { return [d1, d2]; } } : { func: (n: Base[]) => (Derived1 | Derived2)[]; } +>true : boolean +>undefined : undefined +>{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => (Derived1 | Derived2)[]; } +>func : (n: Base[]) => (Derived1 | Derived2)[] +>n => { return [d1, d2]; } : (n: Base[]) => (Derived1 | Derived2)[] +>n : Base[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +var x309: () => Base[] = true ? () => [d1, d2] : undefined; +>x309 : () => Base[] +>Base : Base +>true ? () => [d1, d2] : undefined : () => (Derived1 | Derived2)[] +>true : boolean +>() => [d1, d2] : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 +>undefined : undefined + +var x310: () => Base[] = true ? function() { return [d1, d2] } : undefined; +>x310 : () => Base[] +>Base : Base +>true ? function() { return [d1, d2] } : undefined : () => (Derived1 | Derived2)[] +>true : boolean +>function() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 +>undefined : undefined + +var x311: () => Base[] = true ? function named() { return [d1, d2] } : undefined; +>x311 : () => Base[] +>Base : Base +>true ? function named() { return [d1, d2] } : undefined : () => (Derived1 | Derived2)[] +>true : boolean +>function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>named : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 +>undefined : undefined + +var x312: { (): Base[]; } = true ? () => [d1, d2] : undefined; +>x312 : () => Base[] +>Base : Base +>true ? () => [d1, d2] : undefined : () => (Derived1 | Derived2)[] +>true : boolean +>() => [d1, d2] : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 +>undefined : undefined + +var x313: { (): Base[]; } = true ? function() { return [d1, d2] } : undefined; +>x313 : () => Base[] +>Base : Base +>true ? function() { return [d1, d2] } : undefined : () => (Derived1 | Derived2)[] +>true : boolean +>function() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 +>undefined : undefined + +var x314: { (): Base[]; } = true ? function named() { return [d1, d2] } : undefined; +>x314 : () => Base[] +>Base : Base +>true ? function named() { return [d1, d2] } : undefined : () => (Derived1 | Derived2)[] +>true : boolean +>function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>named : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 +>undefined : undefined + +var x315: Base[] = true ? [d1, d2] : undefined; +>x315 : Base[] +>Base : Base +>true ? [d1, d2] : undefined : (Derived1 | Derived2)[] +>true : boolean +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 +>undefined : undefined + +var x316: Array = true ? [d1, d2] : undefined; +>x316 : Base[] +>Array : T[] +>Base : Base +>true ? [d1, d2] : undefined : (Derived1 | Derived2)[] +>true : boolean +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 +>undefined : undefined + +var x317: { [n: number]: Base; } = true ? [d1, d2] : undefined; +>x317 : { [n: number]: Base; } +>n : number +>Base : Base +>true ? [d1, d2] : undefined : (Derived1 | Derived2)[] +>true : boolean +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 +>undefined : undefined + +var x318: {n: Base[]; } = true ? { n: [d1, d2] } : undefined; +>x318 : { n: Base[]; } +>n : Base[] +>Base : Base +>true ? { n: [d1, d2] } : undefined : { n: (Derived1 | Derived2)[]; } +>true : boolean +>{ n: [d1, d2] } : { n: (Derived1 | Derived2)[]; } +>n : (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 +>undefined : undefined + +var x319: (s: Base[]) => any = true ? n => { var n: Base[]; return null; } : undefined; +>x319 : (s: Base[]) => any +>s : Base[] +>Base : Base +>true ? n => { var n: Base[]; return null; } : undefined : (n: Base[]) => any +>true : boolean +>n => { var n: Base[]; return null; } : (n: Base[]) => any +>n : Base[] +>n : Base[] +>Base : Base +>null : null +>undefined : undefined + +var x320: Genric = true ? { func: n => { return [d1, d2]; } } : undefined; +>x320 : Genric +>Genric : Genric +>Base : Base +>true ? { func: n => { return [d1, d2]; } } : undefined : { func: (n: Base[]) => (Derived1 | Derived2)[]; } +>true : boolean +>{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => (Derived1 | Derived2)[]; } +>func : (n: Base[]) => (Derived1 | Derived2)[] +>n => { return [d1, d2]; } : (n: Base[]) => (Derived1 | Derived2)[] +>n : Base[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 +>undefined : undefined + +function x321(n: () => Base[]) { }; x321(() => [d1, d2]); +>x321 : (n: () => Base[]) => void +>n : () => Base[] +>Base : Base +>x321(() => [d1, d2]) : void +>x321 : (n: () => Base[]) => void +>() => [d1, d2] : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +function x322(n: () => Base[]) { }; x322(function() { return [d1, d2] }); +>x322 : (n: () => Base[]) => void +>n : () => Base[] +>Base : Base +>x322(function() { return [d1, d2] }) : void +>x322 : (n: () => Base[]) => void +>function() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +function x323(n: () => Base[]) { }; x323(function named() { return [d1, d2] }); +>x323 : (n: () => Base[]) => void +>n : () => Base[] +>Base : Base +>x323(function named() { return [d1, d2] }) : void +>x323 : (n: () => Base[]) => void +>function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>named : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +function x324(n: { (): Base[]; }) { }; x324(() => [d1, d2]); +>x324 : (n: () => Base[]) => void +>n : () => Base[] +>Base : Base +>x324(() => [d1, d2]) : void +>x324 : (n: () => Base[]) => void +>() => [d1, d2] : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +function x325(n: { (): Base[]; }) { }; x325(function() { return [d1, d2] }); +>x325 : (n: () => Base[]) => void +>n : () => Base[] +>Base : Base +>x325(function() { return [d1, d2] }) : void +>x325 : (n: () => Base[]) => void +>function() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +function x326(n: { (): Base[]; }) { }; x326(function named() { return [d1, d2] }); +>x326 : (n: () => Base[]) => void +>n : () => Base[] +>Base : Base +>x326(function named() { return [d1, d2] }) : void +>x326 : (n: () => Base[]) => void +>function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>named : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +function x327(n: Base[]) { }; x327([d1, d2]); +>x327 : (n: Base[]) => void +>n : Base[] +>Base : Base +>x327([d1, d2]) : void +>x327 : (n: Base[]) => void +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +function x328(n: Array) { }; x328([d1, d2]); +>x328 : (n: Base[]) => void +>n : Base[] +>Array : T[] +>Base : Base +>x328([d1, d2]) : void +>x328 : (n: Base[]) => void +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +function x329(n: { [n: number]: Base; }) { }; x329([d1, d2]); +>x329 : (n: { [n: number]: Base; }) => void +>n : { [n: number]: Base; } +>n : number +>Base : Base +>x329([d1, d2]) : void +>x329 : (n: { [n: number]: Base; }) => void +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +function x330(n: {n: Base[]; } ) { }; x330({ n: [d1, d2] }); +>x330 : (n: { n: Base[]; }) => void +>n : { n: Base[]; } +>n : Base[] +>Base : Base +>x330({ n: [d1, d2] }) : void +>x330 : (n: { n: Base[]; }) => void +>{ n: [d1, d2] } : { n: (Derived1 | Derived2)[]; } +>n : (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +function x331(n: (s: Base[]) => any) { }; x331(n => { var n: Base[]; return null; }); +>x331 : (n: (s: Base[]) => any) => void +>n : (s: Base[]) => any +>s : Base[] +>Base : Base +>x331(n => { var n: Base[]; return null; }) : void +>x331 : (n: (s: Base[]) => any) => void +>n => { var n: Base[]; return null; } : (n: Base[]) => any +>n : Base[] +>n : Base[] +>Base : Base +>null : null + +function x332(n: Genric) { }; x332({ func: n => { return [d1, d2]; } }); +>x332 : (n: Genric) => void +>n : Genric +>Genric : Genric +>Base : Base +>x332({ func: n => { return [d1, d2]; } }) : void +>x332 : (n: Genric) => void +>{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => (Derived1 | Derived2)[]; } +>func : (n: Base[]) => (Derived1 | Derived2)[] +>n => { return [d1, d2]; } : (n: Base[]) => (Derived1 | Derived2)[] +>n : Base[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +var x333 = (n: () => Base[]) => n; x333(() => [d1, d2]); +>x333 : (n: () => Base[]) => () => Base[] +>(n: () => Base[]) => n : (n: () => Base[]) => () => Base[] +>n : () => Base[] +>Base : Base +>n : () => Base[] +>x333(() => [d1, d2]) : () => Base[] +>x333 : (n: () => Base[]) => () => Base[] +>() => [d1, d2] : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +var x334 = (n: () => Base[]) => n; x334(function() { return [d1, d2] }); +>x334 : (n: () => Base[]) => () => Base[] +>(n: () => Base[]) => n : (n: () => Base[]) => () => Base[] +>n : () => Base[] +>Base : Base +>n : () => Base[] +>x334(function() { return [d1, d2] }) : () => Base[] +>x334 : (n: () => Base[]) => () => Base[] +>function() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +var x335 = (n: () => Base[]) => n; x335(function named() { return [d1, d2] }); +>x335 : (n: () => Base[]) => () => Base[] +>(n: () => Base[]) => n : (n: () => Base[]) => () => Base[] +>n : () => Base[] +>Base : Base +>n : () => Base[] +>x335(function named() { return [d1, d2] }) : () => Base[] +>x335 : (n: () => Base[]) => () => Base[] +>function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>named : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +var x336 = (n: { (): Base[]; }) => n; x336(() => [d1, d2]); +>x336 : (n: () => Base[]) => () => Base[] +>(n: { (): Base[]; }) => n : (n: () => Base[]) => () => Base[] +>n : () => Base[] +>Base : Base +>n : () => Base[] +>x336(() => [d1, d2]) : () => Base[] +>x336 : (n: () => Base[]) => () => Base[] +>() => [d1, d2] : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +var x337 = (n: { (): Base[]; }) => n; x337(function() { return [d1, d2] }); +>x337 : (n: () => Base[]) => () => Base[] +>(n: { (): Base[]; }) => n : (n: () => Base[]) => () => Base[] +>n : () => Base[] +>Base : Base +>n : () => Base[] +>x337(function() { return [d1, d2] }) : () => Base[] +>x337 : (n: () => Base[]) => () => Base[] +>function() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +var x338 = (n: { (): Base[]; }) => n; x338(function named() { return [d1, d2] }); +>x338 : (n: () => Base[]) => () => Base[] +>(n: { (): Base[]; }) => n : (n: () => Base[]) => () => Base[] +>n : () => Base[] +>Base : Base +>n : () => Base[] +>x338(function named() { return [d1, d2] }) : () => Base[] +>x338 : (n: () => Base[]) => () => Base[] +>function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>named : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +var x339 = (n: Base[]) => n; x339([d1, d2]); +>x339 : (n: Base[]) => Base[] +>(n: Base[]) => n : (n: Base[]) => Base[] +>n : Base[] +>Base : Base +>n : Base[] +>x339([d1, d2]) : Base[] +>x339 : (n: Base[]) => Base[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +var x340 = (n: Array) => n; x340([d1, d2]); +>x340 : (n: Base[]) => Base[] +>(n: Array) => n : (n: Base[]) => Base[] +>n : Base[] +>Array : T[] +>Base : Base +>n : Base[] +>x340([d1, d2]) : Base[] +>x340 : (n: Base[]) => Base[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +var x341 = (n: { [n: number]: Base; }) => n; x341([d1, d2]); +>x341 : (n: { [n: number]: Base; }) => { [n: number]: Base; } +>(n: { [n: number]: Base; }) => n : (n: { [n: number]: Base; }) => { [n: number]: Base; } +>n : { [n: number]: Base; } +>n : number +>Base : Base +>n : { [n: number]: Base; } +>x341([d1, d2]) : { [n: number]: Base; } +>x341 : (n: { [n: number]: Base; }) => { [n: number]: Base; } +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +var x342 = (n: {n: Base[]; } ) => n; x342({ n: [d1, d2] }); +>x342 : (n: { n: Base[]; }) => { n: Base[]; } +>(n: {n: Base[]; } ) => n : (n: { n: Base[]; }) => { n: Base[]; } +>n : { n: Base[]; } +>n : Base[] +>Base : Base +>n : { n: Base[]; } +>x342({ n: [d1, d2] }) : { n: Base[]; } +>x342 : (n: { n: Base[]; }) => { n: Base[]; } +>{ n: [d1, d2] } : { n: (Derived1 | Derived2)[]; } +>n : (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +var x343 = (n: (s: Base[]) => any) => n; x343(n => { var n: Base[]; return null; }); +>x343 : (n: (s: Base[]) => any) => (s: Base[]) => any +>(n: (s: Base[]) => any) => n : (n: (s: Base[]) => any) => (s: Base[]) => any +>n : (s: Base[]) => any +>s : Base[] +>Base : Base +>n : (s: Base[]) => any +>x343(n => { var n: Base[]; return null; }) : (s: Base[]) => any +>x343 : (n: (s: Base[]) => any) => (s: Base[]) => any +>n => { var n: Base[]; return null; } : (n: Base[]) => any +>n : Base[] +>n : Base[] +>Base : Base +>null : null + +var x344 = (n: Genric) => n; x344({ func: n => { return [d1, d2]; } }); +>x344 : (n: Genric) => Genric +>(n: Genric) => n : (n: Genric) => Genric +>n : Genric +>Genric : Genric +>Base : Base +>n : Genric +>x344({ func: n => { return [d1, d2]; } }) : Genric +>x344 : (n: Genric) => Genric +>{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => (Derived1 | Derived2)[]; } +>func : (n: Base[]) => (Derived1 | Derived2)[] +>n => { return [d1, d2]; } : (n: Base[]) => (Derived1 | Derived2)[] +>n : Base[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +var x345 = function(n: () => Base[]) { }; x345(() => [d1, d2]); +>x345 : (n: () => Base[]) => void +>function(n: () => Base[]) { } : (n: () => Base[]) => void +>n : () => Base[] +>Base : Base +>x345(() => [d1, d2]) : void +>x345 : (n: () => Base[]) => void +>() => [d1, d2] : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +var x346 = function(n: () => Base[]) { }; x346(function() { return [d1, d2] }); +>x346 : (n: () => Base[]) => void +>function(n: () => Base[]) { } : (n: () => Base[]) => void +>n : () => Base[] +>Base : Base +>x346(function() { return [d1, d2] }) : void +>x346 : (n: () => Base[]) => void +>function() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +var x347 = function(n: () => Base[]) { }; x347(function named() { return [d1, d2] }); +>x347 : (n: () => Base[]) => void +>function(n: () => Base[]) { } : (n: () => Base[]) => void +>n : () => Base[] +>Base : Base +>x347(function named() { return [d1, d2] }) : void +>x347 : (n: () => Base[]) => void +>function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>named : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +var x348 = function(n: { (): Base[]; }) { }; x348(() => [d1, d2]); +>x348 : (n: () => Base[]) => void +>function(n: { (): Base[]; }) { } : (n: () => Base[]) => void +>n : () => Base[] +>Base : Base +>x348(() => [d1, d2]) : void +>x348 : (n: () => Base[]) => void +>() => [d1, d2] : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +var x349 = function(n: { (): Base[]; }) { }; x349(function() { return [d1, d2] }); +>x349 : (n: () => Base[]) => void +>function(n: { (): Base[]; }) { } : (n: () => Base[]) => void +>n : () => Base[] +>Base : Base +>x349(function() { return [d1, d2] }) : void +>x349 : (n: () => Base[]) => void +>function() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +var x350 = function(n: { (): Base[]; }) { }; x350(function named() { return [d1, d2] }); +>x350 : (n: () => Base[]) => void +>function(n: { (): Base[]; }) { } : (n: () => Base[]) => void +>n : () => Base[] +>Base : Base +>x350(function named() { return [d1, d2] }) : void +>x350 : (n: () => Base[]) => void +>function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] +>named : () => (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +var x351 = function(n: Base[]) { }; x351([d1, d2]); +>x351 : (n: Base[]) => void +>function(n: Base[]) { } : (n: Base[]) => void +>n : Base[] +>Base : Base +>x351([d1, d2]) : void +>x351 : (n: Base[]) => void +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +var x352 = function(n: Array) { }; x352([d1, d2]); +>x352 : (n: Base[]) => void +>function(n: Array) { } : (n: Base[]) => void +>n : Base[] +>Array : T[] +>Base : Base +>x352([d1, d2]) : void +>x352 : (n: Base[]) => void +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +var x353 = function(n: { [n: number]: Base; }) { }; x353([d1, d2]); +>x353 : (n: { [n: number]: Base; }) => void +>function(n: { [n: number]: Base; }) { } : (n: { [n: number]: Base; }) => void +>n : { [n: number]: Base; } +>n : number +>Base : Base +>x353([d1, d2]) : void +>x353 : (n: { [n: number]: Base; }) => void +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +var x354 = function(n: {n: Base[]; } ) { }; x354({ n: [d1, d2] }); +>x354 : (n: { n: Base[]; }) => void +>function(n: {n: Base[]; } ) { } : (n: { n: Base[]; }) => void +>n : { n: Base[]; } +>n : Base[] +>Base : Base +>x354({ n: [d1, d2] }) : void +>x354 : (n: { n: Base[]; }) => void +>{ n: [d1, d2] } : { n: (Derived1 | Derived2)[]; } +>n : (Derived1 | Derived2)[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + +var x355 = function(n: (s: Base[]) => any) { }; x355(n => { var n: Base[]; return null; }); +>x355 : (n: (s: Base[]) => any) => void +>function(n: (s: Base[]) => any) { } : (n: (s: Base[]) => any) => void +>n : (s: Base[]) => any +>s : Base[] +>Base : Base +>x355(n => { var n: Base[]; return null; }) : void +>x355 : (n: (s: Base[]) => any) => void +>n => { var n: Base[]; return null; } : (n: Base[]) => any +>n : Base[] +>n : Base[] +>Base : Base +>null : null + +var x356 = function(n: Genric) { }; x356({ func: n => { return [d1, d2]; } }); +>x356 : (n: Genric) => void +>function(n: Genric) { } : (n: Genric) => void +>n : Genric +>Genric : Genric +>Base : Base +>x356({ func: n => { return [d1, d2]; } }) : void +>x356 : (n: Genric) => void +>{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => (Derived1 | Derived2)[]; } +>func : (n: Base[]) => (Derived1 | Derived2)[] +>n => { return [d1, d2]; } : (n: Base[]) => (Derived1 | Derived2)[] +>n : Base[] +>[d1, d2] : (Derived1 | Derived2)[] +>d1 : Derived1 +>d2 : Derived2 + diff --git a/tests/baselines/reference/ifDoWhileStatements.errors.txt b/tests/baselines/reference/ifDoWhileStatements.errors.txt deleted file mode 100644 index fb8985e634b..00000000000 --- a/tests/baselines/reference/ifDoWhileStatements.errors.txt +++ /dev/null @@ -1,168 +0,0 @@ -tests/cases/conformance/statements/ifDoWhileStatements/ifDoWhileStatements.ts(42,1): error TS7027: Unreachable code detected. - - -==== tests/cases/conformance/statements/ifDoWhileStatements/ifDoWhileStatements.ts (1 errors) ==== - interface I { - id: number; - } - - class C implements I { - id: number; - name: string; - } - - class C2 extends C { - valid: boolean; - } - - class D{ - source: T; - recurse: D; - wrapped: D> - } - - function F(x: string): number { return 42; } - function F2(x: number): boolean { return x < 42; } - - module M { - export class A { - name: string; - } - - export function F2(x: number): string { return x.toString(); } - } - - module N { - export class A { - id: number; - } - - export function F2(x: number): string { return x.toString(); } - } - - // literals - if (true) { } - while (true) { } - do { }while(true) - ~~ -!!! error TS7027: Unreachable code detected. - - if (null) { } - while (null) { } - do { }while(null) - - if (undefined) { } - while (undefined) { } - do { }while(undefined) - - if (0.0) { } - while (0.0) { } - do { }while(0.0) - - if ('a string') { } - while ('a string') { } - do { }while('a string') - - if ('') { } - while ('') { } - do { }while('') - - if (/[a-z]/) { } - while (/[a-z]/) { } - do { }while(/[a-z]/) - - if ([]) { } - while ([]) { } - do { }while([]) - - if ([1, 2]) { } - while ([1, 2]) { } - do { }while([1, 2]) - - if ({}) { } - while ({}) { } - do { }while({}) - - if ({ x: 1, y: 'a' }) { } - while ({ x: 1, y: 'a' }) { } - do { }while({ x: 1, y: 'a' }) - - if (() => 43) { } - while (() => 43) { } - do { }while(() => 43) - - if (new C()) { } - while (new C()) { } - do { }while(new C()) - - if (new D()) { } - while (new D()) { } - do { }while(new D()) - - // references - var a = true; - if (a) { } - while (a) { } - do { }while(a) - - var b = null; - if (b) { } - while (b) { } - do { }while(b) - - var c = undefined; - if (c) { } - while (c) { } - do { }while(c) - - var d = 0.0; - if (d) { } - while (d) { } - do { }while(d) - - var e = 'a string'; - if (e) { } - while (e) { } - do { }while(e) - - var f = ''; - if (f) { } - while (f) { } - do { }while(f) - - var g = /[a-z]/ - if (g) { } - while (g) { } - do { }while(g) - - var h = []; - if (h) { } - while (h) { } - do { }while(h) - - var i = [1, 2]; - if (i) { } - while (i) { } - do { }while(i) - - var j = {}; - if (j) { } - while (j) { } - do { }while(j) - - var k = { x: 1, y: 'a' }; - if (k) { } - while (k) { } - do { }while(k) - - function fn(x?: string): I { return null; } - if (fn()) { } - while (fn()) { } - do { }while(fn()) - - if (fn) { } - while (fn) { } - do { }while(fn) - - - \ No newline at end of file diff --git a/tests/baselines/reference/ifDoWhileStatements.js b/tests/baselines/reference/ifDoWhileStatements.js index 020d3f053d1..a2553c674b0 100644 --- a/tests/baselines/reference/ifDoWhileStatements.js +++ b/tests/baselines/reference/ifDoWhileStatements.js @@ -1,4 +1,5 @@ //// [ifDoWhileStatements.ts] + interface I { id: number; } diff --git a/tests/baselines/reference/ifDoWhileStatements.symbols b/tests/baselines/reference/ifDoWhileStatements.symbols new file mode 100644 index 00000000000..80c8fc7f1d8 --- /dev/null +++ b/tests/baselines/reference/ifDoWhileStatements.symbols @@ -0,0 +1,337 @@ +=== tests/cases/conformance/statements/ifDoWhileStatements/ifDoWhileStatements.ts === + +interface I { +>I : Symbol(I, Decl(ifDoWhileStatements.ts, 0, 0)) + + id: number; +>id : Symbol(id, Decl(ifDoWhileStatements.ts, 1, 13)) +} + +class C implements I { +>C : Symbol(C, Decl(ifDoWhileStatements.ts, 3, 1)) +>I : Symbol(I, Decl(ifDoWhileStatements.ts, 0, 0)) + + id: number; +>id : Symbol(id, Decl(ifDoWhileStatements.ts, 5, 22)) + + name: string; +>name : Symbol(name, Decl(ifDoWhileStatements.ts, 6, 15)) +} + +class C2 extends C { +>C2 : Symbol(C2, Decl(ifDoWhileStatements.ts, 8, 1)) +>C : Symbol(C, Decl(ifDoWhileStatements.ts, 3, 1)) + + valid: boolean; +>valid : Symbol(valid, Decl(ifDoWhileStatements.ts, 10, 20)) +} + +class D{ +>D : Symbol(D, Decl(ifDoWhileStatements.ts, 12, 1)) +>T : Symbol(T, Decl(ifDoWhileStatements.ts, 14, 8)) + + source: T; +>source : Symbol(source, Decl(ifDoWhileStatements.ts, 14, 11)) +>T : Symbol(T, Decl(ifDoWhileStatements.ts, 14, 8)) + + recurse: D; +>recurse : Symbol(recurse, Decl(ifDoWhileStatements.ts, 15, 14)) +>D : Symbol(D, Decl(ifDoWhileStatements.ts, 12, 1)) +>T : Symbol(T, Decl(ifDoWhileStatements.ts, 14, 8)) + + wrapped: D> +>wrapped : Symbol(wrapped, Decl(ifDoWhileStatements.ts, 16, 18)) +>D : Symbol(D, Decl(ifDoWhileStatements.ts, 12, 1)) +>D : Symbol(D, Decl(ifDoWhileStatements.ts, 12, 1)) +>T : Symbol(T, Decl(ifDoWhileStatements.ts, 14, 8)) +} + +function F(x: string): number { return 42; } +>F : Symbol(F, Decl(ifDoWhileStatements.ts, 18, 1)) +>x : Symbol(x, Decl(ifDoWhileStatements.ts, 20, 11)) + +function F2(x: number): boolean { return x < 42; } +>F2 : Symbol(F2, Decl(ifDoWhileStatements.ts, 20, 44)) +>x : Symbol(x, Decl(ifDoWhileStatements.ts, 21, 12)) +>x : Symbol(x, Decl(ifDoWhileStatements.ts, 21, 12)) + +module M { +>M : Symbol(M, Decl(ifDoWhileStatements.ts, 21, 50)) + + export class A { +>A : Symbol(A, Decl(ifDoWhileStatements.ts, 23, 10)) + + name: string; +>name : Symbol(name, Decl(ifDoWhileStatements.ts, 24, 20)) + } + + export function F2(x: number): string { return x.toString(); } +>F2 : Symbol(F2, Decl(ifDoWhileStatements.ts, 26, 5)) +>x : Symbol(x, Decl(ifDoWhileStatements.ts, 28, 23)) +>x.toString : Symbol(Number.toString, Decl(lib.d.ts, --, --)) +>x : Symbol(x, Decl(ifDoWhileStatements.ts, 28, 23)) +>toString : Symbol(Number.toString, Decl(lib.d.ts, --, --)) +} + +module N { +>N : Symbol(N, Decl(ifDoWhileStatements.ts, 29, 1)) + + export class A { +>A : Symbol(A, Decl(ifDoWhileStatements.ts, 31, 10)) + + id: number; +>id : Symbol(id, Decl(ifDoWhileStatements.ts, 32, 20)) + } + + export function F2(x: number): string { return x.toString(); } +>F2 : Symbol(F2, Decl(ifDoWhileStatements.ts, 34, 5)) +>x : Symbol(x, Decl(ifDoWhileStatements.ts, 36, 23)) +>x.toString : Symbol(Number.toString, Decl(lib.d.ts, --, --)) +>x : Symbol(x, Decl(ifDoWhileStatements.ts, 36, 23)) +>toString : Symbol(Number.toString, Decl(lib.d.ts, --, --)) +} + +// literals +if (true) { } +while (true) { } +do { }while(true) + +if (null) { } +while (null) { } +do { }while(null) + +if (undefined) { } +>undefined : Symbol(undefined) + +while (undefined) { } +>undefined : Symbol(undefined) + +do { }while(undefined) +>undefined : Symbol(undefined) + +if (0.0) { } +while (0.0) { } +do { }while(0.0) + +if ('a string') { } +while ('a string') { } +do { }while('a string') + +if ('') { } +while ('') { } +do { }while('') + +if (/[a-z]/) { } +while (/[a-z]/) { } +do { }while(/[a-z]/) + +if ([]) { } +while ([]) { } +do { }while([]) + +if ([1, 2]) { } +while ([1, 2]) { } +do { }while([1, 2]) + +if ({}) { } +while ({}) { } +do { }while({}) + +if ({ x: 1, y: 'a' }) { } +>x : Symbol(x, Decl(ifDoWhileStatements.ts, 80, 5)) +>y : Symbol(y, Decl(ifDoWhileStatements.ts, 80, 11)) + +while ({ x: 1, y: 'a' }) { } +>x : Symbol(x, Decl(ifDoWhileStatements.ts, 81, 8)) +>y : Symbol(y, Decl(ifDoWhileStatements.ts, 81, 14)) + +do { }while({ x: 1, y: 'a' }) +>x : Symbol(x, Decl(ifDoWhileStatements.ts, 82, 13)) +>y : Symbol(y, Decl(ifDoWhileStatements.ts, 82, 19)) + +if (() => 43) { } +while (() => 43) { } +do { }while(() => 43) + +if (new C()) { } +>C : Symbol(C, Decl(ifDoWhileStatements.ts, 3, 1)) + +while (new C()) { } +>C : Symbol(C, Decl(ifDoWhileStatements.ts, 3, 1)) + +do { }while(new C()) +>C : Symbol(C, Decl(ifDoWhileStatements.ts, 3, 1)) + +if (new D()) { } +>D : Symbol(D, Decl(ifDoWhileStatements.ts, 12, 1)) +>C : Symbol(C, Decl(ifDoWhileStatements.ts, 3, 1)) + +while (new D()) { } +>D : Symbol(D, Decl(ifDoWhileStatements.ts, 12, 1)) +>C : Symbol(C, Decl(ifDoWhileStatements.ts, 3, 1)) + +do { }while(new D()) +>D : Symbol(D, Decl(ifDoWhileStatements.ts, 12, 1)) +>C : Symbol(C, Decl(ifDoWhileStatements.ts, 3, 1)) + +// references +var a = true; +>a : Symbol(a, Decl(ifDoWhileStatements.ts, 97, 3)) + +if (a) { } +>a : Symbol(a, Decl(ifDoWhileStatements.ts, 97, 3)) + +while (a) { } +>a : Symbol(a, Decl(ifDoWhileStatements.ts, 97, 3)) + +do { }while(a) +>a : Symbol(a, Decl(ifDoWhileStatements.ts, 97, 3)) + +var b = null; +>b : Symbol(b, Decl(ifDoWhileStatements.ts, 102, 3)) + +if (b) { } +>b : Symbol(b, Decl(ifDoWhileStatements.ts, 102, 3)) + +while (b) { } +>b : Symbol(b, Decl(ifDoWhileStatements.ts, 102, 3)) + +do { }while(b) +>b : Symbol(b, Decl(ifDoWhileStatements.ts, 102, 3)) + +var c = undefined; +>c : Symbol(c, Decl(ifDoWhileStatements.ts, 107, 3)) +>undefined : Symbol(undefined) + +if (c) { } +>c : Symbol(c, Decl(ifDoWhileStatements.ts, 107, 3)) + +while (c) { } +>c : Symbol(c, Decl(ifDoWhileStatements.ts, 107, 3)) + +do { }while(c) +>c : Symbol(c, Decl(ifDoWhileStatements.ts, 107, 3)) + +var d = 0.0; +>d : Symbol(d, Decl(ifDoWhileStatements.ts, 112, 3)) + +if (d) { } +>d : Symbol(d, Decl(ifDoWhileStatements.ts, 112, 3)) + +while (d) { } +>d : Symbol(d, Decl(ifDoWhileStatements.ts, 112, 3)) + +do { }while(d) +>d : Symbol(d, Decl(ifDoWhileStatements.ts, 112, 3)) + +var e = 'a string'; +>e : Symbol(e, Decl(ifDoWhileStatements.ts, 117, 3)) + +if (e) { } +>e : Symbol(e, Decl(ifDoWhileStatements.ts, 117, 3)) + +while (e) { } +>e : Symbol(e, Decl(ifDoWhileStatements.ts, 117, 3)) + +do { }while(e) +>e : Symbol(e, Decl(ifDoWhileStatements.ts, 117, 3)) + +var f = ''; +>f : Symbol(f, Decl(ifDoWhileStatements.ts, 122, 3)) + +if (f) { } +>f : Symbol(f, Decl(ifDoWhileStatements.ts, 122, 3)) + +while (f) { } +>f : Symbol(f, Decl(ifDoWhileStatements.ts, 122, 3)) + +do { }while(f) +>f : Symbol(f, Decl(ifDoWhileStatements.ts, 122, 3)) + +var g = /[a-z]/ +>g : Symbol(g, Decl(ifDoWhileStatements.ts, 127, 3)) + +if (g) { } +>g : Symbol(g, Decl(ifDoWhileStatements.ts, 127, 3)) + +while (g) { } +>g : Symbol(g, Decl(ifDoWhileStatements.ts, 127, 3)) + +do { }while(g) +>g : Symbol(g, Decl(ifDoWhileStatements.ts, 127, 3)) + +var h = []; +>h : Symbol(h, Decl(ifDoWhileStatements.ts, 132, 3)) + +if (h) { } +>h : Symbol(h, Decl(ifDoWhileStatements.ts, 132, 3)) + +while (h) { } +>h : Symbol(h, Decl(ifDoWhileStatements.ts, 132, 3)) + +do { }while(h) +>h : Symbol(h, Decl(ifDoWhileStatements.ts, 132, 3)) + +var i = [1, 2]; +>i : Symbol(i, Decl(ifDoWhileStatements.ts, 137, 3)) + +if (i) { } +>i : Symbol(i, Decl(ifDoWhileStatements.ts, 137, 3)) + +while (i) { } +>i : Symbol(i, Decl(ifDoWhileStatements.ts, 137, 3)) + +do { }while(i) +>i : Symbol(i, Decl(ifDoWhileStatements.ts, 137, 3)) + +var j = {}; +>j : Symbol(j, Decl(ifDoWhileStatements.ts, 142, 3)) + +if (j) { } +>j : Symbol(j, Decl(ifDoWhileStatements.ts, 142, 3)) + +while (j) { } +>j : Symbol(j, Decl(ifDoWhileStatements.ts, 142, 3)) + +do { }while(j) +>j : Symbol(j, Decl(ifDoWhileStatements.ts, 142, 3)) + +var k = { x: 1, y: 'a' }; +>k : Symbol(k, Decl(ifDoWhileStatements.ts, 147, 3)) +>x : Symbol(x, Decl(ifDoWhileStatements.ts, 147, 9)) +>y : Symbol(y, Decl(ifDoWhileStatements.ts, 147, 15)) + +if (k) { } +>k : Symbol(k, Decl(ifDoWhileStatements.ts, 147, 3)) + +while (k) { } +>k : Symbol(k, Decl(ifDoWhileStatements.ts, 147, 3)) + +do { }while(k) +>k : Symbol(k, Decl(ifDoWhileStatements.ts, 147, 3)) + +function fn(x?: string): I { return null; } +>fn : Symbol(fn, Decl(ifDoWhileStatements.ts, 150, 14)) +>x : Symbol(x, Decl(ifDoWhileStatements.ts, 152, 12)) +>I : Symbol(I, Decl(ifDoWhileStatements.ts, 0, 0)) + +if (fn()) { } +>fn : Symbol(fn, Decl(ifDoWhileStatements.ts, 150, 14)) + +while (fn()) { } +>fn : Symbol(fn, Decl(ifDoWhileStatements.ts, 150, 14)) + +do { }while(fn()) +>fn : Symbol(fn, Decl(ifDoWhileStatements.ts, 150, 14)) + +if (fn) { } +>fn : Symbol(fn, Decl(ifDoWhileStatements.ts, 150, 14)) + +while (fn) { } +>fn : Symbol(fn, Decl(ifDoWhileStatements.ts, 150, 14)) + +do { }while(fn) +>fn : Symbol(fn, Decl(ifDoWhileStatements.ts, 150, 14)) + + + diff --git a/tests/baselines/reference/ifDoWhileStatements.types b/tests/baselines/reference/ifDoWhileStatements.types new file mode 100644 index 00000000000..660eaa4fb63 --- /dev/null +++ b/tests/baselines/reference/ifDoWhileStatements.types @@ -0,0 +1,434 @@ +=== tests/cases/conformance/statements/ifDoWhileStatements/ifDoWhileStatements.ts === + +interface I { +>I : I + + id: number; +>id : number +} + +class C implements I { +>C : C +>I : I + + id: number; +>id : number + + name: string; +>name : string +} + +class C2 extends C { +>C2 : C2 +>C : C + + valid: boolean; +>valid : boolean +} + +class D{ +>D : D +>T : T + + source: T; +>source : T +>T : T + + recurse: D; +>recurse : D +>D : D +>T : T + + wrapped: D> +>wrapped : D> +>D : D +>D : D +>T : T +} + +function F(x: string): number { return 42; } +>F : (x: string) => number +>x : string +>42 : number + +function F2(x: number): boolean { return x < 42; } +>F2 : (x: number) => boolean +>x : number +>x < 42 : boolean +>x : number +>42 : number + +module M { +>M : typeof M + + export class A { +>A : A + + name: string; +>name : string + } + + export function F2(x: number): string { return x.toString(); } +>F2 : (x: number) => string +>x : number +>x.toString() : string +>x.toString : (radix?: number) => string +>x : number +>toString : (radix?: number) => string +} + +module N { +>N : typeof N + + export class A { +>A : A + + id: number; +>id : number + } + + export function F2(x: number): string { return x.toString(); } +>F2 : (x: number) => string +>x : number +>x.toString() : string +>x.toString : (radix?: number) => string +>x : number +>toString : (radix?: number) => string +} + +// literals +if (true) { } +>true : boolean + +while (true) { } +>true : boolean + +do { }while(true) +>true : boolean + +if (null) { } +>null : null + +while (null) { } +>null : null + +do { }while(null) +>null : null + +if (undefined) { } +>undefined : undefined + +while (undefined) { } +>undefined : undefined + +do { }while(undefined) +>undefined : undefined + +if (0.0) { } +>0.0 : number + +while (0.0) { } +>0.0 : number + +do { }while(0.0) +>0.0 : number + +if ('a string') { } +>'a string' : string + +while ('a string') { } +>'a string' : string + +do { }while('a string') +>'a string' : string + +if ('') { } +>'' : string + +while ('') { } +>'' : string + +do { }while('') +>'' : string + +if (/[a-z]/) { } +>/[a-z]/ : RegExp + +while (/[a-z]/) { } +>/[a-z]/ : RegExp + +do { }while(/[a-z]/) +>/[a-z]/ : RegExp + +if ([]) { } +>[] : undefined[] + +while ([]) { } +>[] : undefined[] + +do { }while([]) +>[] : undefined[] + +if ([1, 2]) { } +>[1, 2] : number[] +>1 : number +>2 : number + +while ([1, 2]) { } +>[1, 2] : number[] +>1 : number +>2 : number + +do { }while([1, 2]) +>[1, 2] : number[] +>1 : number +>2 : number + +if ({}) { } +>{} : {} + +while ({}) { } +>{} : {} + +do { }while({}) +>{} : {} + +if ({ x: 1, y: 'a' }) { } +>{ x: 1, y: 'a' } : { x: number; y: string; } +>x : number +>1 : number +>y : string +>'a' : string + +while ({ x: 1, y: 'a' }) { } +>{ x: 1, y: 'a' } : { x: number; y: string; } +>x : number +>1 : number +>y : string +>'a' : string + +do { }while({ x: 1, y: 'a' }) +>{ x: 1, y: 'a' } : { x: number; y: string; } +>x : number +>1 : number +>y : string +>'a' : string + +if (() => 43) { } +>() => 43 : () => number +>43 : number + +while (() => 43) { } +>() => 43 : () => number +>43 : number + +do { }while(() => 43) +>() => 43 : () => number +>43 : number + +if (new C()) { } +>new C() : C +>C : typeof C + +while (new C()) { } +>new C() : C +>C : typeof C + +do { }while(new C()) +>new C() : C +>C : typeof C + +if (new D()) { } +>new D() : D +>D : typeof D +>C : C + +while (new D()) { } +>new D() : D +>D : typeof D +>C : C + +do { }while(new D()) +>new D() : D +>D : typeof D +>C : C + +// references +var a = true; +>a : boolean +>true : boolean + +if (a) { } +>a : boolean + +while (a) { } +>a : boolean + +do { }while(a) +>a : boolean + +var b = null; +>b : any +>null : null + +if (b) { } +>b : any + +while (b) { } +>b : any + +do { }while(b) +>b : any + +var c = undefined; +>c : any +>undefined : undefined + +if (c) { } +>c : any + +while (c) { } +>c : any + +do { }while(c) +>c : any + +var d = 0.0; +>d : number +>0.0 : number + +if (d) { } +>d : number + +while (d) { } +>d : number + +do { }while(d) +>d : number + +var e = 'a string'; +>e : string +>'a string' : string + +if (e) { } +>e : string + +while (e) { } +>e : string + +do { }while(e) +>e : string + +var f = ''; +>f : string +>'' : string + +if (f) { } +>f : string + +while (f) { } +>f : string + +do { }while(f) +>f : string + +var g = /[a-z]/ +>g : RegExp +>/[a-z]/ : RegExp + +if (g) { } +>g : RegExp + +while (g) { } +>g : RegExp + +do { }while(g) +>g : RegExp + +var h = []; +>h : any[] +>[] : undefined[] + +if (h) { } +>h : any[] + +while (h) { } +>h : any[] + +do { }while(h) +>h : any[] + +var i = [1, 2]; +>i : number[] +>[1, 2] : number[] +>1 : number +>2 : number + +if (i) { } +>i : number[] + +while (i) { } +>i : number[] + +do { }while(i) +>i : number[] + +var j = {}; +>j : {} +>{} : {} + +if (j) { } +>j : {} + +while (j) { } +>j : {} + +do { }while(j) +>j : {} + +var k = { x: 1, y: 'a' }; +>k : { x: number; y: string; } +>{ x: 1, y: 'a' } : { x: number; y: string; } +>x : number +>1 : number +>y : string +>'a' : string + +if (k) { } +>k : { x: number; y: string; } + +while (k) { } +>k : { x: number; y: string; } + +do { }while(k) +>k : { x: number; y: string; } + +function fn(x?: string): I { return null; } +>fn : (x?: string) => I +>x : string +>I : I +>null : null + +if (fn()) { } +>fn() : I +>fn : (x?: string) => I + +while (fn()) { } +>fn() : I +>fn : (x?: string) => I + +do { }while(fn()) +>fn() : I +>fn : (x?: string) => I + +if (fn) { } +>fn : (x?: string) => I + +while (fn) { } +>fn : (x?: string) => I + +do { }while(fn) +>fn : (x?: string) => I + + + diff --git a/tests/baselines/reference/ifElseWithStatements1.errors.txt b/tests/baselines/reference/ifElseWithStatements1.errors.txt index f9fcb33113a..5dc4d9b0db5 100644 --- a/tests/baselines/reference/ifElseWithStatements1.errors.txt +++ b/tests/baselines/reference/ifElseWithStatements1.errors.txt @@ -1,10 +1,9 @@ -tests/cases/compiler/ifElseWithStatements1.ts(2,5): error TS2304: Cannot find name 'f'. -tests/cases/compiler/ifElseWithStatements1.ts(4,5): error TS2304: Cannot find name 'f'. -tests/cases/compiler/ifElseWithStatements1.ts(4,5): error TS7027: Unreachable code detected. -tests/cases/compiler/ifElseWithStatements1.ts(10,9): error TS7027: Unreachable code detected. +tests/cases/compiler/ifElseWithStatements1.ts(3,5): error TS2304: Cannot find name 'f'. +tests/cases/compiler/ifElseWithStatements1.ts(5,5): error TS2304: Cannot find name 'f'. -==== tests/cases/compiler/ifElseWithStatements1.ts (4 errors) ==== +==== tests/cases/compiler/ifElseWithStatements1.ts (2 errors) ==== + if (true) f(); ~ @@ -13,15 +12,11 @@ tests/cases/compiler/ifElseWithStatements1.ts(10,9): error TS7027: Unreachable c f(); ~ !!! error TS2304: Cannot find name 'f'. - ~ -!!! error TS7027: Unreachable code detected. function foo(): boolean { if (true) return true; else return false; - ~~~~~~ -!!! error TS7027: Unreachable code detected. } \ No newline at end of file diff --git a/tests/baselines/reference/ifElseWithStatements1.js b/tests/baselines/reference/ifElseWithStatements1.js index 506e7e6a330..47df08d46ba 100644 --- a/tests/baselines/reference/ifElseWithStatements1.js +++ b/tests/baselines/reference/ifElseWithStatements1.js @@ -1,4 +1,5 @@ //// [ifElseWithStatements1.ts] + if (true) f(); else diff --git a/tests/baselines/reference/inferredFunctionReturnTypeIsEmptyType.errors.txt b/tests/baselines/reference/inferredFunctionReturnTypeIsEmptyType.errors.txt index b1d4a1ba6ba..bab58d0e4cf 100644 --- a/tests/baselines/reference/inferredFunctionReturnTypeIsEmptyType.errors.txt +++ b/tests/baselines/reference/inferredFunctionReturnTypeIsEmptyType.errors.txt @@ -1,8 +1,8 @@ -tests/cases/compiler/inferredFunctionReturnTypeIsEmptyType.ts(1,10): error TS2354: No best common type exists among return expressions. -tests/cases/compiler/inferredFunctionReturnTypeIsEmptyType.ts(6,9): error TS7027: Unreachable code detected. +tests/cases/compiler/inferredFunctionReturnTypeIsEmptyType.ts(2,10): error TS2354: No best common type exists among return expressions. -==== tests/cases/compiler/inferredFunctionReturnTypeIsEmptyType.ts (2 errors) ==== +==== tests/cases/compiler/inferredFunctionReturnTypeIsEmptyType.ts (1 errors) ==== + function foo() { ~~~ !!! error TS2354: No best common type exists among return expressions. @@ -11,8 +11,6 @@ tests/cases/compiler/inferredFunctionReturnTypeIsEmptyType.ts(6,9): error TS7027 } else { return "42"; - ~~~~~~ -!!! error TS7027: Unreachable code detected. } }; \ No newline at end of file diff --git a/tests/baselines/reference/inferredFunctionReturnTypeIsEmptyType.js b/tests/baselines/reference/inferredFunctionReturnTypeIsEmptyType.js index ba528d4c133..2993a331fee 100644 --- a/tests/baselines/reference/inferredFunctionReturnTypeIsEmptyType.js +++ b/tests/baselines/reference/inferredFunctionReturnTypeIsEmptyType.js @@ -1,4 +1,5 @@ //// [inferredFunctionReturnTypeIsEmptyType.ts] + function foo() { if (true) { return 42; diff --git a/tests/baselines/reference/inheritanceStaticPropertyOverridingAccessor.errors.txt b/tests/baselines/reference/inheritanceStaticPropertyOverridingAccessor.errors.txt index 251938cc9c7..787b95f2297 100644 --- a/tests/baselines/reference/inheritanceStaticPropertyOverridingAccessor.errors.txt +++ b/tests/baselines/reference/inheritanceStaticPropertyOverridingAccessor.errors.txt @@ -1,16 +1,14 @@ -tests/cases/compiler/inheritanceStaticPropertyOverridingAccessor.ts(2,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/compiler/inheritanceStaticPropertyOverridingAccessor.ts(3,21): error TS7027: Unreachable code detected. -tests/cases/compiler/inheritanceStaticPropertyOverridingAccessor.ts(5,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. +tests/cases/compiler/inheritanceStaticPropertyOverridingAccessor.ts(3,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. +tests/cases/compiler/inheritanceStaticPropertyOverridingAccessor.ts(6,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -==== tests/cases/compiler/inheritanceStaticPropertyOverridingAccessor.ts (3 errors) ==== +==== tests/cases/compiler/inheritanceStaticPropertyOverridingAccessor.ts (2 errors) ==== + class a { static get x(): () => string { ~ !!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. return null;; - ~ -!!! error TS7027: Unreachable code detected. } static set x(aValue: () => string) { ~ diff --git a/tests/baselines/reference/inheritanceStaticPropertyOverridingAccessor.js b/tests/baselines/reference/inheritanceStaticPropertyOverridingAccessor.js index b81b6cd1d78..fa9c6e2a8b5 100644 --- a/tests/baselines/reference/inheritanceStaticPropertyOverridingAccessor.js +++ b/tests/baselines/reference/inheritanceStaticPropertyOverridingAccessor.js @@ -1,4 +1,5 @@ //// [inheritanceStaticPropertyOverridingAccessor.ts] + class a { static get x(): () => string { return null;; diff --git a/tests/baselines/reference/interfaceExtendingClass2.errors.txt b/tests/baselines/reference/interfaceExtendingClass2.errors.txt index 68bd5e845ac..859cb65410e 100644 --- a/tests/baselines/reference/interfaceExtendingClass2.errors.txt +++ b/tests/baselines/reference/interfaceExtendingClass2.errors.txt @@ -1,11 +1,11 @@ -tests/cases/conformance/interfaces/interfacesExtendingClasses/interfaceExtendingClass2.ts(11,5): error TS2411: Property 'a' of type '{ toString: () => {}; }' is not assignable to string index type 'Object'. -tests/cases/conformance/interfaces/interfacesExtendingClasses/interfaceExtendingClass2.ts(13,13): error TS1131: Property or signature expected. -tests/cases/conformance/interfaces/interfacesExtendingClasses/interfaceExtendingClass2.ts(14,9): error TS1128: Declaration or statement expected. -tests/cases/conformance/interfaces/interfacesExtendingClasses/interfaceExtendingClass2.ts(14,10): error TS7027: Unreachable code detected. -tests/cases/conformance/interfaces/interfacesExtendingClasses/interfaceExtendingClass2.ts(15,5): error TS1128: Declaration or statement expected. +tests/cases/conformance/interfaces/interfacesExtendingClasses/interfaceExtendingClass2.ts(12,5): error TS2411: Property 'a' of type '{ toString: () => {}; }' is not assignable to string index type 'Object'. +tests/cases/conformance/interfaces/interfacesExtendingClasses/interfaceExtendingClass2.ts(14,13): error TS1131: Property or signature expected. +tests/cases/conformance/interfaces/interfacesExtendingClasses/interfaceExtendingClass2.ts(15,9): error TS1128: Declaration or statement expected. +tests/cases/conformance/interfaces/interfacesExtendingClasses/interfaceExtendingClass2.ts(16,5): error TS1128: Declaration or statement expected. -==== tests/cases/conformance/interfaces/interfacesExtendingClasses/interfaceExtendingClass2.ts (5 errors) ==== +==== tests/cases/conformance/interfaces/interfacesExtendingClasses/interfaceExtendingClass2.ts (4 errors) ==== + class Foo { x: string; y() { } @@ -27,8 +27,6 @@ tests/cases/conformance/interfaces/interfacesExtendingClasses/interfaceExtending }; ~ !!! error TS1128: Declaration or statement expected. - ~ -!!! error TS7027: Unreachable code detected. } ~ !!! error TS1128: Declaration or statement expected. \ No newline at end of file diff --git a/tests/baselines/reference/interfaceExtendingClass2.js b/tests/baselines/reference/interfaceExtendingClass2.js index 6e6605e2459..c4143659125 100644 --- a/tests/baselines/reference/interfaceExtendingClass2.js +++ b/tests/baselines/reference/interfaceExtendingClass2.js @@ -1,4 +1,5 @@ //// [interfaceExtendingClass2.ts] + class Foo { x: string; y() { } diff --git a/tests/baselines/reference/interfaceWithPrivateMember.errors.txt b/tests/baselines/reference/interfaceWithPrivateMember.errors.txt index aa6dfdc1032..dc1cfeabed5 100644 --- a/tests/baselines/reference/interfaceWithPrivateMember.errors.txt +++ b/tests/baselines/reference/interfaceWithPrivateMember.errors.txt @@ -1,12 +1,12 @@ -tests/cases/conformance/types/namedTypes/interfaceWithPrivateMember.ts(4,5): error TS1131: Property or signature expected. -tests/cases/conformance/types/namedTypes/interfaceWithPrivateMember.ts(8,5): error TS1131: Property or signature expected. -tests/cases/conformance/types/namedTypes/interfaceWithPrivateMember.ts(12,5): error TS1131: Property or signature expected. -tests/cases/conformance/types/namedTypes/interfaceWithPrivateMember.ts(12,13): error TS7028: Unused label. -tests/cases/conformance/types/namedTypes/interfaceWithPrivateMember.ts(12,16): error TS2304: Cannot find name 'string'. -tests/cases/conformance/types/namedTypes/interfaceWithPrivateMember.ts(13,1): error TS1128: Declaration or statement expected. +tests/cases/conformance/types/namedTypes/interfaceWithPrivateMember.ts(5,5): error TS1131: Property or signature expected. +tests/cases/conformance/types/namedTypes/interfaceWithPrivateMember.ts(9,5): error TS1131: Property or signature expected. +tests/cases/conformance/types/namedTypes/interfaceWithPrivateMember.ts(13,5): error TS1131: Property or signature expected. +tests/cases/conformance/types/namedTypes/interfaceWithPrivateMember.ts(13,16): error TS2304: Cannot find name 'string'. +tests/cases/conformance/types/namedTypes/interfaceWithPrivateMember.ts(14,1): error TS1128: Declaration or statement expected. -==== tests/cases/conformance/types/namedTypes/interfaceWithPrivateMember.ts (6 errors) ==== +==== tests/cases/conformance/types/namedTypes/interfaceWithPrivateMember.ts (5 errors) ==== + // interfaces do not permit private members, these are errors interface I { @@ -25,8 +25,6 @@ tests/cases/conformance/types/namedTypes/interfaceWithPrivateMember.ts(13,1): er private y: string; ~~~~~~~ !!! error TS1131: Property or signature expected. - ~ -!!! error TS7028: Unused label. ~~~~~~ !!! error TS2304: Cannot find name 'string'. } diff --git a/tests/baselines/reference/interfaceWithPrivateMember.js b/tests/baselines/reference/interfaceWithPrivateMember.js index 24c2cf9ecf5..ceb388b1eae 100644 --- a/tests/baselines/reference/interfaceWithPrivateMember.js +++ b/tests/baselines/reference/interfaceWithPrivateMember.js @@ -1,4 +1,5 @@ //// [interfaceWithPrivateMember.ts] + // interfaces do not permit private members, these are errors interface I { diff --git a/tests/baselines/reference/invalidDoWhileBreakStatements.errors.txt b/tests/baselines/reference/invalidDoWhileBreakStatements.errors.txt index 2a26190534e..15983bd1fc4 100644 --- a/tests/baselines/reference/invalidDoWhileBreakStatements.errors.txt +++ b/tests/baselines/reference/invalidDoWhileBreakStatements.errors.txt @@ -1,14 +1,13 @@ -tests/cases/conformance/statements/breakStatements/invalidDoWhileBreakStatements.ts(4,1): error TS1105: A 'break' statement can only be used within an enclosing iteration or switch statement. -tests/cases/conformance/statements/breakStatements/invalidDoWhileBreakStatements.ts(7,1): error TS7028: Unused label. -tests/cases/conformance/statements/breakStatements/invalidDoWhileBreakStatements.ts(8,4): error TS1116: A 'break' statement can only jump to a label of an enclosing statement. -tests/cases/conformance/statements/breakStatements/invalidDoWhileBreakStatements.ts(11,1): error TS7027: Unreachable code detected. -tests/cases/conformance/statements/breakStatements/invalidDoWhileBreakStatements.ts(14,9): error TS1107: Jump target cannot cross function boundary. -tests/cases/conformance/statements/breakStatements/invalidDoWhileBreakStatements.ts(21,9): error TS1107: Jump target cannot cross function boundary. -tests/cases/conformance/statements/breakStatements/invalidDoWhileBreakStatements.ts(27,5): error TS1116: A 'break' statement can only jump to a label of an enclosing statement. -tests/cases/conformance/statements/breakStatements/invalidDoWhileBreakStatements.ts(37,5): error TS1116: A 'break' statement can only jump to a label of an enclosing statement. +tests/cases/conformance/statements/breakStatements/invalidDoWhileBreakStatements.ts(5,1): error TS1105: A 'break' statement can only be used within an enclosing iteration or switch statement. +tests/cases/conformance/statements/breakStatements/invalidDoWhileBreakStatements.ts(9,4): error TS1116: A 'break' statement can only jump to a label of an enclosing statement. +tests/cases/conformance/statements/breakStatements/invalidDoWhileBreakStatements.ts(15,9): error TS1107: Jump target cannot cross function boundary. +tests/cases/conformance/statements/breakStatements/invalidDoWhileBreakStatements.ts(22,9): error TS1107: Jump target cannot cross function boundary. +tests/cases/conformance/statements/breakStatements/invalidDoWhileBreakStatements.ts(28,5): error TS1116: A 'break' statement can only jump to a label of an enclosing statement. +tests/cases/conformance/statements/breakStatements/invalidDoWhileBreakStatements.ts(38,5): error TS1116: A 'break' statement can only jump to a label of an enclosing statement. -==== tests/cases/conformance/statements/breakStatements/invalidDoWhileBreakStatements.ts (8 errors) ==== +==== tests/cases/conformance/statements/breakStatements/invalidDoWhileBreakStatements.ts (6 errors) ==== + // All errors // naked break not allowed @@ -18,16 +17,12 @@ tests/cases/conformance/statements/breakStatements/invalidDoWhileBreakStatements // non-existent label ONE: - ~~~ -!!! error TS7028: Unused label. do break TWO; while (true) ~~~~~~~~~~ !!! error TS1116: A 'break' statement can only jump to a label of an enclosing statement. // break from inside function TWO: - ~~~ -!!! error TS7027: Unreachable code detected. do { var x = () => { break TWO; diff --git a/tests/baselines/reference/invalidDoWhileBreakStatements.js b/tests/baselines/reference/invalidDoWhileBreakStatements.js index 807d58a8fea..4f48a890aa6 100644 --- a/tests/baselines/reference/invalidDoWhileBreakStatements.js +++ b/tests/baselines/reference/invalidDoWhileBreakStatements.js @@ -1,4 +1,5 @@ //// [invalidDoWhileBreakStatements.ts] + // All errors // naked break not allowed diff --git a/tests/baselines/reference/invalidDoWhileContinueStatements.errors.txt b/tests/baselines/reference/invalidDoWhileContinueStatements.errors.txt index b3938d9ba8b..3a520209293 100644 --- a/tests/baselines/reference/invalidDoWhileContinueStatements.errors.txt +++ b/tests/baselines/reference/invalidDoWhileContinueStatements.errors.txt @@ -1,14 +1,13 @@ -tests/cases/conformance/statements/continueStatements/invalidDoWhileContinueStatements.ts(4,1): error TS1104: A 'continue' statement can only be used within an enclosing iteration statement. -tests/cases/conformance/statements/continueStatements/invalidDoWhileContinueStatements.ts(7,1): error TS7028: Unused label. -tests/cases/conformance/statements/continueStatements/invalidDoWhileContinueStatements.ts(8,4): error TS1115: A 'continue' statement can only jump to a label of an enclosing iteration statement. -tests/cases/conformance/statements/continueStatements/invalidDoWhileContinueStatements.ts(11,1): error TS7027: Unreachable code detected. -tests/cases/conformance/statements/continueStatements/invalidDoWhileContinueStatements.ts(14,9): error TS1107: Jump target cannot cross function boundary. -tests/cases/conformance/statements/continueStatements/invalidDoWhileContinueStatements.ts(21,9): error TS1107: Jump target cannot cross function boundary. -tests/cases/conformance/statements/continueStatements/invalidDoWhileContinueStatements.ts(27,5): error TS1115: A 'continue' statement can only jump to a label of an enclosing iteration statement. -tests/cases/conformance/statements/continueStatements/invalidDoWhileContinueStatements.ts(37,5): error TS1115: A 'continue' statement can only jump to a label of an enclosing iteration statement. +tests/cases/conformance/statements/continueStatements/invalidDoWhileContinueStatements.ts(5,1): error TS1104: A 'continue' statement can only be used within an enclosing iteration statement. +tests/cases/conformance/statements/continueStatements/invalidDoWhileContinueStatements.ts(9,4): error TS1115: A 'continue' statement can only jump to a label of an enclosing iteration statement. +tests/cases/conformance/statements/continueStatements/invalidDoWhileContinueStatements.ts(15,9): error TS1107: Jump target cannot cross function boundary. +tests/cases/conformance/statements/continueStatements/invalidDoWhileContinueStatements.ts(22,9): error TS1107: Jump target cannot cross function boundary. +tests/cases/conformance/statements/continueStatements/invalidDoWhileContinueStatements.ts(28,5): error TS1115: A 'continue' statement can only jump to a label of an enclosing iteration statement. +tests/cases/conformance/statements/continueStatements/invalidDoWhileContinueStatements.ts(38,5): error TS1115: A 'continue' statement can only jump to a label of an enclosing iteration statement. -==== tests/cases/conformance/statements/continueStatements/invalidDoWhileContinueStatements.ts (8 errors) ==== +==== tests/cases/conformance/statements/continueStatements/invalidDoWhileContinueStatements.ts (6 errors) ==== + // All errors // naked continue not allowed @@ -18,16 +17,12 @@ tests/cases/conformance/statements/continueStatements/invalidDoWhileContinueStat // non-existent label ONE: - ~~~ -!!! error TS7028: Unused label. do continue TWO; while (true) ~~~~~~~~~~~~~ !!! error TS1115: A 'continue' statement can only jump to a label of an enclosing iteration statement. // continue from inside function TWO: - ~~~ -!!! error TS7027: Unreachable code detected. do { var x = () => { continue TWO; diff --git a/tests/baselines/reference/invalidDoWhileContinueStatements.js b/tests/baselines/reference/invalidDoWhileContinueStatements.js index 21a10a3451b..b77259159a9 100644 --- a/tests/baselines/reference/invalidDoWhileContinueStatements.js +++ b/tests/baselines/reference/invalidDoWhileContinueStatements.js @@ -1,4 +1,5 @@ //// [invalidDoWhileContinueStatements.ts] + // All errors // naked continue not allowed diff --git a/tests/baselines/reference/invalidForBreakStatements.errors.txt b/tests/baselines/reference/invalidForBreakStatements.errors.txt index f803cad08e1..57ae1d32c8e 100644 --- a/tests/baselines/reference/invalidForBreakStatements.errors.txt +++ b/tests/baselines/reference/invalidForBreakStatements.errors.txt @@ -1,14 +1,13 @@ -tests/cases/conformance/statements/breakStatements/invalidForBreakStatements.ts(4,1): error TS1105: A 'break' statement can only be used within an enclosing iteration or switch statement. -tests/cases/conformance/statements/breakStatements/invalidForBreakStatements.ts(7,1): error TS7028: Unused label. -tests/cases/conformance/statements/breakStatements/invalidForBreakStatements.ts(8,9): error TS1116: A 'break' statement can only jump to a label of an enclosing statement. -tests/cases/conformance/statements/breakStatements/invalidForBreakStatements.ts(11,1): error TS7027: Unreachable code detected. -tests/cases/conformance/statements/breakStatements/invalidForBreakStatements.ts(14,9): error TS1107: Jump target cannot cross function boundary. -tests/cases/conformance/statements/breakStatements/invalidForBreakStatements.ts(21,9): error TS1107: Jump target cannot cross function boundary. -tests/cases/conformance/statements/breakStatements/invalidForBreakStatements.ts(27,5): error TS1116: A 'break' statement can only jump to a label of an enclosing statement. -tests/cases/conformance/statements/breakStatements/invalidForBreakStatements.ts(36,5): error TS1116: A 'break' statement can only jump to a label of an enclosing statement. +tests/cases/conformance/statements/breakStatements/invalidForBreakStatements.ts(5,1): error TS1105: A 'break' statement can only be used within an enclosing iteration or switch statement. +tests/cases/conformance/statements/breakStatements/invalidForBreakStatements.ts(9,9): error TS1116: A 'break' statement can only jump to a label of an enclosing statement. +tests/cases/conformance/statements/breakStatements/invalidForBreakStatements.ts(15,9): error TS1107: Jump target cannot cross function boundary. +tests/cases/conformance/statements/breakStatements/invalidForBreakStatements.ts(22,9): error TS1107: Jump target cannot cross function boundary. +tests/cases/conformance/statements/breakStatements/invalidForBreakStatements.ts(28,5): error TS1116: A 'break' statement can only jump to a label of an enclosing statement. +tests/cases/conformance/statements/breakStatements/invalidForBreakStatements.ts(37,5): error TS1116: A 'break' statement can only jump to a label of an enclosing statement. -==== tests/cases/conformance/statements/breakStatements/invalidForBreakStatements.ts (8 errors) ==== +==== tests/cases/conformance/statements/breakStatements/invalidForBreakStatements.ts (6 errors) ==== + // All errors // naked break not allowed @@ -18,16 +17,12 @@ tests/cases/conformance/statements/breakStatements/invalidForBreakStatements.ts( // non-existent label ONE: - ~~~ -!!! error TS7028: Unused label. for(;;) break TWO; ~~~~~~~~~~ !!! error TS1116: A 'break' statement can only jump to a label of an enclosing statement. // break from inside function TWO: - ~~~ -!!! error TS7027: Unreachable code detected. for(;;) { var x = () => { break TWO; diff --git a/tests/baselines/reference/invalidForBreakStatements.js b/tests/baselines/reference/invalidForBreakStatements.js index 5e3430ecb41..50096e16720 100644 --- a/tests/baselines/reference/invalidForBreakStatements.js +++ b/tests/baselines/reference/invalidForBreakStatements.js @@ -1,4 +1,5 @@ //// [invalidForBreakStatements.ts] + // All errors // naked break not allowed diff --git a/tests/baselines/reference/invalidForContinueStatements.errors.txt b/tests/baselines/reference/invalidForContinueStatements.errors.txt index 9a252a2c572..9ebfae57e9f 100644 --- a/tests/baselines/reference/invalidForContinueStatements.errors.txt +++ b/tests/baselines/reference/invalidForContinueStatements.errors.txt @@ -1,14 +1,13 @@ -tests/cases/conformance/statements/continueStatements/invalidForContinueStatements.ts(4,1): error TS1104: A 'continue' statement can only be used within an enclosing iteration statement. -tests/cases/conformance/statements/continueStatements/invalidForContinueStatements.ts(7,1): error TS7028: Unused label. -tests/cases/conformance/statements/continueStatements/invalidForContinueStatements.ts(8,9): error TS1115: A 'continue' statement can only jump to a label of an enclosing iteration statement. -tests/cases/conformance/statements/continueStatements/invalidForContinueStatements.ts(11,1): error TS7027: Unreachable code detected. -tests/cases/conformance/statements/continueStatements/invalidForContinueStatements.ts(14,9): error TS1107: Jump target cannot cross function boundary. -tests/cases/conformance/statements/continueStatements/invalidForContinueStatements.ts(21,9): error TS1107: Jump target cannot cross function boundary. -tests/cases/conformance/statements/continueStatements/invalidForContinueStatements.ts(27,5): error TS1115: A 'continue' statement can only jump to a label of an enclosing iteration statement. -tests/cases/conformance/statements/continueStatements/invalidForContinueStatements.ts(36,5): error TS1115: A 'continue' statement can only jump to a label of an enclosing iteration statement. +tests/cases/conformance/statements/continueStatements/invalidForContinueStatements.ts(5,1): error TS1104: A 'continue' statement can only be used within an enclosing iteration statement. +tests/cases/conformance/statements/continueStatements/invalidForContinueStatements.ts(9,9): error TS1115: A 'continue' statement can only jump to a label of an enclosing iteration statement. +tests/cases/conformance/statements/continueStatements/invalidForContinueStatements.ts(15,9): error TS1107: Jump target cannot cross function boundary. +tests/cases/conformance/statements/continueStatements/invalidForContinueStatements.ts(22,9): error TS1107: Jump target cannot cross function boundary. +tests/cases/conformance/statements/continueStatements/invalidForContinueStatements.ts(28,5): error TS1115: A 'continue' statement can only jump to a label of an enclosing iteration statement. +tests/cases/conformance/statements/continueStatements/invalidForContinueStatements.ts(37,5): error TS1115: A 'continue' statement can only jump to a label of an enclosing iteration statement. -==== tests/cases/conformance/statements/continueStatements/invalidForContinueStatements.ts (8 errors) ==== +==== tests/cases/conformance/statements/continueStatements/invalidForContinueStatements.ts (6 errors) ==== + // All errors // naked continue not allowed @@ -18,16 +17,12 @@ tests/cases/conformance/statements/continueStatements/invalidForContinueStatemen // non-existent label ONE: - ~~~ -!!! error TS7028: Unused label. for(;;) continue TWO; ~~~~~~~~~~~~~ !!! error TS1115: A 'continue' statement can only jump to a label of an enclosing iteration statement. // continue from inside function TWO: - ~~~ -!!! error TS7027: Unreachable code detected. for(;;) { var x = () => { continue TWO; diff --git a/tests/baselines/reference/invalidForContinueStatements.js b/tests/baselines/reference/invalidForContinueStatements.js index 2db1ce69ede..7a3513bb2a3 100644 --- a/tests/baselines/reference/invalidForContinueStatements.js +++ b/tests/baselines/reference/invalidForContinueStatements.js @@ -1,4 +1,5 @@ //// [invalidForContinueStatements.ts] + // All errors // naked continue not allowed diff --git a/tests/baselines/reference/invalidForInBreakStatements.errors.txt b/tests/baselines/reference/invalidForInBreakStatements.errors.txt index a575970ff88..b1f5d64f973 100644 --- a/tests/baselines/reference/invalidForInBreakStatements.errors.txt +++ b/tests/baselines/reference/invalidForInBreakStatements.errors.txt @@ -1,17 +1,13 @@ -tests/cases/conformance/statements/breakStatements/invalidForInBreakStatements.ts(4,1): error TS1105: A 'break' statement can only be used within an enclosing iteration or switch statement. -tests/cases/conformance/statements/breakStatements/invalidForInBreakStatements.ts(7,1): error TS7028: Unused label. -tests/cases/conformance/statements/breakStatements/invalidForInBreakStatements.ts(8,19): error TS1116: A 'break' statement can only jump to a label of an enclosing statement. -tests/cases/conformance/statements/breakStatements/invalidForInBreakStatements.ts(11,1): error TS7028: Unused label. -tests/cases/conformance/statements/breakStatements/invalidForInBreakStatements.ts(14,9): error TS1107: Jump target cannot cross function boundary. -tests/cases/conformance/statements/breakStatements/invalidForInBreakStatements.ts(18,1): error TS7028: Unused label. -tests/cases/conformance/statements/breakStatements/invalidForInBreakStatements.ts(21,9): error TS1107: Jump target cannot cross function boundary. -tests/cases/conformance/statements/breakStatements/invalidForInBreakStatements.ts(27,5): error TS1116: A 'break' statement can only jump to a label of an enclosing statement. -tests/cases/conformance/statements/breakStatements/invalidForInBreakStatements.ts(28,5): error TS7028: Unused label. -tests/cases/conformance/statements/breakStatements/invalidForInBreakStatements.ts(33,1): error TS7028: Unused label. -tests/cases/conformance/statements/breakStatements/invalidForInBreakStatements.ts(37,5): error TS1116: A 'break' statement can only jump to a label of an enclosing statement. +tests/cases/conformance/statements/breakStatements/invalidForInBreakStatements.ts(5,1): error TS1105: A 'break' statement can only be used within an enclosing iteration or switch statement. +tests/cases/conformance/statements/breakStatements/invalidForInBreakStatements.ts(9,19): error TS1116: A 'break' statement can only jump to a label of an enclosing statement. +tests/cases/conformance/statements/breakStatements/invalidForInBreakStatements.ts(15,9): error TS1107: Jump target cannot cross function boundary. +tests/cases/conformance/statements/breakStatements/invalidForInBreakStatements.ts(22,9): error TS1107: Jump target cannot cross function boundary. +tests/cases/conformance/statements/breakStatements/invalidForInBreakStatements.ts(28,5): error TS1116: A 'break' statement can only jump to a label of an enclosing statement. +tests/cases/conformance/statements/breakStatements/invalidForInBreakStatements.ts(38,5): error TS1116: A 'break' statement can only jump to a label of an enclosing statement. -==== tests/cases/conformance/statements/breakStatements/invalidForInBreakStatements.ts (11 errors) ==== +==== tests/cases/conformance/statements/breakStatements/invalidForInBreakStatements.ts (6 errors) ==== + // All errors // naked break not allowed @@ -21,16 +17,12 @@ tests/cases/conformance/statements/breakStatements/invalidForInBreakStatements.t // non-existent label ONE: - ~~~ -!!! error TS7028: Unused label. for (var x in {}) break TWO; ~~~~~~~~~~ !!! error TS1116: A 'break' statement can only jump to a label of an enclosing statement. // break from inside function TWO: - ~~~ -!!! error TS7028: Unused label. for (var x in {}) { var fn = () => { break TWO; @@ -40,8 +32,6 @@ tests/cases/conformance/statements/breakStatements/invalidForInBreakStatements.t } THREE: - ~~~~~ -!!! error TS7028: Unused label. for (var x in {}) { var fn = function () { break THREE; @@ -56,15 +46,11 @@ tests/cases/conformance/statements/breakStatements/invalidForInBreakStatements.t ~~~~~~~~~~~ !!! error TS1116: A 'break' statement can only jump to a label of an enclosing statement. FIVE: - ~~~~ -!!! error TS7028: Unused label. for (var x in {}) { } } // label on non-loop statement NINE: - ~~~~ -!!! error TS7028: Unused label. var y = 12; for (var x in {}) { diff --git a/tests/baselines/reference/invalidForInBreakStatements.js b/tests/baselines/reference/invalidForInBreakStatements.js index 1784b9a57a6..11517f2a020 100644 --- a/tests/baselines/reference/invalidForInBreakStatements.js +++ b/tests/baselines/reference/invalidForInBreakStatements.js @@ -1,4 +1,5 @@ //// [invalidForInBreakStatements.ts] + // All errors // naked break not allowed diff --git a/tests/baselines/reference/invalidForInContinueStatements.errors.txt b/tests/baselines/reference/invalidForInContinueStatements.errors.txt index 15b515742a9..f20d9c6e81c 100644 --- a/tests/baselines/reference/invalidForInContinueStatements.errors.txt +++ b/tests/baselines/reference/invalidForInContinueStatements.errors.txt @@ -1,17 +1,13 @@ -tests/cases/conformance/statements/continueStatements/invalidForInContinueStatements.ts(4,1): error TS1104: A 'continue' statement can only be used within an enclosing iteration statement. -tests/cases/conformance/statements/continueStatements/invalidForInContinueStatements.ts(7,1): error TS7028: Unused label. -tests/cases/conformance/statements/continueStatements/invalidForInContinueStatements.ts(8,19): error TS1115: A 'continue' statement can only jump to a label of an enclosing iteration statement. -tests/cases/conformance/statements/continueStatements/invalidForInContinueStatements.ts(11,1): error TS7028: Unused label. -tests/cases/conformance/statements/continueStatements/invalidForInContinueStatements.ts(14,9): error TS1107: Jump target cannot cross function boundary. -tests/cases/conformance/statements/continueStatements/invalidForInContinueStatements.ts(18,1): error TS7028: Unused label. -tests/cases/conformance/statements/continueStatements/invalidForInContinueStatements.ts(21,9): error TS1107: Jump target cannot cross function boundary. -tests/cases/conformance/statements/continueStatements/invalidForInContinueStatements.ts(27,5): error TS1115: A 'continue' statement can only jump to a label of an enclosing iteration statement. -tests/cases/conformance/statements/continueStatements/invalidForInContinueStatements.ts(28,5): error TS7028: Unused label. -tests/cases/conformance/statements/continueStatements/invalidForInContinueStatements.ts(33,1): error TS7028: Unused label. -tests/cases/conformance/statements/continueStatements/invalidForInContinueStatements.ts(37,5): error TS1115: A 'continue' statement can only jump to a label of an enclosing iteration statement. +tests/cases/conformance/statements/continueStatements/invalidForInContinueStatements.ts(5,1): error TS1104: A 'continue' statement can only be used within an enclosing iteration statement. +tests/cases/conformance/statements/continueStatements/invalidForInContinueStatements.ts(9,19): error TS1115: A 'continue' statement can only jump to a label of an enclosing iteration statement. +tests/cases/conformance/statements/continueStatements/invalidForInContinueStatements.ts(15,9): error TS1107: Jump target cannot cross function boundary. +tests/cases/conformance/statements/continueStatements/invalidForInContinueStatements.ts(22,9): error TS1107: Jump target cannot cross function boundary. +tests/cases/conformance/statements/continueStatements/invalidForInContinueStatements.ts(28,5): error TS1115: A 'continue' statement can only jump to a label of an enclosing iteration statement. +tests/cases/conformance/statements/continueStatements/invalidForInContinueStatements.ts(38,5): error TS1115: A 'continue' statement can only jump to a label of an enclosing iteration statement. -==== tests/cases/conformance/statements/continueStatements/invalidForInContinueStatements.ts (11 errors) ==== +==== tests/cases/conformance/statements/continueStatements/invalidForInContinueStatements.ts (6 errors) ==== + // All errors // naked continue not allowed @@ -21,16 +17,12 @@ tests/cases/conformance/statements/continueStatements/invalidForInContinueStatem // non-existent label ONE: - ~~~ -!!! error TS7028: Unused label. for (var x in {}) continue TWO; ~~~~~~~~~~~~~ !!! error TS1115: A 'continue' statement can only jump to a label of an enclosing iteration statement. // continue from inside function TWO: - ~~~ -!!! error TS7028: Unused label. for (var x in {}) { var fn = () => { continue TWO; @@ -40,8 +32,6 @@ tests/cases/conformance/statements/continueStatements/invalidForInContinueStatem } THREE: - ~~~~~ -!!! error TS7028: Unused label. for (var x in {}) { var fn = function () { continue THREE; @@ -56,15 +46,11 @@ tests/cases/conformance/statements/continueStatements/invalidForInContinueStatem ~~~~~~~~~~~~~~ !!! error TS1115: A 'continue' statement can only jump to a label of an enclosing iteration statement. FIVE: - ~~~~ -!!! error TS7028: Unused label. for (var x in {}) { } } // label on non-loop statement NINE: - ~~~~ -!!! error TS7028: Unused label. var y = 12; for (var x in {}) { diff --git a/tests/baselines/reference/invalidForInContinueStatements.js b/tests/baselines/reference/invalidForInContinueStatements.js index 94020d00f2b..5eb0e10bf53 100644 --- a/tests/baselines/reference/invalidForInContinueStatements.js +++ b/tests/baselines/reference/invalidForInContinueStatements.js @@ -1,4 +1,5 @@ //// [invalidForInContinueStatements.ts] + // All errors // naked continue not allowed diff --git a/tests/baselines/reference/invalidThrowStatement.errors.txt b/tests/baselines/reference/invalidThrowStatement.errors.txt index d72fd7e2acd..3002bce2f1f 100644 --- a/tests/baselines/reference/invalidThrowStatement.errors.txt +++ b/tests/baselines/reference/invalidThrowStatement.errors.txt @@ -1,9 +1,9 @@ -tests/cases/conformance/statements/throwStatements/invalidThrowStatement.ts(1,6): error TS1109: Expression expected. -tests/cases/conformance/statements/throwStatements/invalidThrowStatement.ts(3,1): error TS1128: Declaration or statement expected. -tests/cases/conformance/statements/throwStatements/invalidThrowStatement.ts(3,8): error TS7027: Unreachable code detected. +tests/cases/conformance/statements/throwStatements/invalidThrowStatement.ts(2,6): error TS1109: Expression expected. +tests/cases/conformance/statements/throwStatements/invalidThrowStatement.ts(4,1): error TS1128: Declaration or statement expected. -==== tests/cases/conformance/statements/throwStatements/invalidThrowStatement.ts (3 errors) ==== +==== tests/cases/conformance/statements/throwStatements/invalidThrowStatement.ts (2 errors) ==== + throw; ~ !!! error TS1109: Expression expected. @@ -11,6 +11,4 @@ tests/cases/conformance/statements/throwStatements/invalidThrowStatement.ts(3,8) export throw null; ~~~~~~ !!! error TS1128: Declaration or statement expected. - ~~~~~ -!!! error TS7027: Unreachable code detected. \ No newline at end of file diff --git a/tests/baselines/reference/invalidThrowStatement.js b/tests/baselines/reference/invalidThrowStatement.js index 4b794ab3d51..674dacf5c17 100644 --- a/tests/baselines/reference/invalidThrowStatement.js +++ b/tests/baselines/reference/invalidThrowStatement.js @@ -1,4 +1,5 @@ //// [invalidThrowStatement.ts] + throw; export throw null; diff --git a/tests/baselines/reference/invalidWhileContinueStatements.errors.txt b/tests/baselines/reference/invalidWhileContinueStatements.errors.txt index fdc84d84f2e..e7a9ed13c40 100644 --- a/tests/baselines/reference/invalidWhileContinueStatements.errors.txt +++ b/tests/baselines/reference/invalidWhileContinueStatements.errors.txt @@ -1,14 +1,13 @@ -tests/cases/conformance/statements/continueStatements/invalidWhileContinueStatements.ts(4,1): error TS1104: A 'continue' statement can only be used within an enclosing iteration statement. -tests/cases/conformance/statements/continueStatements/invalidWhileContinueStatements.ts(7,1): error TS7028: Unused label. -tests/cases/conformance/statements/continueStatements/invalidWhileContinueStatements.ts(8,14): error TS1115: A 'continue' statement can only jump to a label of an enclosing iteration statement. -tests/cases/conformance/statements/continueStatements/invalidWhileContinueStatements.ts(11,1): error TS7027: Unreachable code detected. -tests/cases/conformance/statements/continueStatements/invalidWhileContinueStatements.ts(14,9): error TS1107: Jump target cannot cross function boundary. -tests/cases/conformance/statements/continueStatements/invalidWhileContinueStatements.ts(21,9): error TS1107: Jump target cannot cross function boundary. -tests/cases/conformance/statements/continueStatements/invalidWhileContinueStatements.ts(27,5): error TS1115: A 'continue' statement can only jump to a label of an enclosing iteration statement. -tests/cases/conformance/statements/continueStatements/invalidWhileContinueStatements.ts(37,5): error TS1115: A 'continue' statement can only jump to a label of an enclosing iteration statement. +tests/cases/conformance/statements/continueStatements/invalidWhileContinueStatements.ts(5,1): error TS1104: A 'continue' statement can only be used within an enclosing iteration statement. +tests/cases/conformance/statements/continueStatements/invalidWhileContinueStatements.ts(9,14): error TS1115: A 'continue' statement can only jump to a label of an enclosing iteration statement. +tests/cases/conformance/statements/continueStatements/invalidWhileContinueStatements.ts(15,9): error TS1107: Jump target cannot cross function boundary. +tests/cases/conformance/statements/continueStatements/invalidWhileContinueStatements.ts(22,9): error TS1107: Jump target cannot cross function boundary. +tests/cases/conformance/statements/continueStatements/invalidWhileContinueStatements.ts(28,5): error TS1115: A 'continue' statement can only jump to a label of an enclosing iteration statement. +tests/cases/conformance/statements/continueStatements/invalidWhileContinueStatements.ts(38,5): error TS1115: A 'continue' statement can only jump to a label of an enclosing iteration statement. -==== tests/cases/conformance/statements/continueStatements/invalidWhileContinueStatements.ts (8 errors) ==== +==== tests/cases/conformance/statements/continueStatements/invalidWhileContinueStatements.ts (6 errors) ==== + // All errors // naked continue not allowed @@ -18,16 +17,12 @@ tests/cases/conformance/statements/continueStatements/invalidWhileContinueStatem // non-existent label ONE: - ~~~ -!!! error TS7028: Unused label. while (true) continue TWO; ~~~~~~~~~~~~~ !!! error TS1115: A 'continue' statement can only jump to a label of an enclosing iteration statement. // continue from inside function TWO: - ~~~ -!!! error TS7027: Unreachable code detected. while (true){ var x = () => { continue TWO; diff --git a/tests/baselines/reference/invalidWhileContinueStatements.js b/tests/baselines/reference/invalidWhileContinueStatements.js index b8234bf9604..16350e9b561 100644 --- a/tests/baselines/reference/invalidWhileContinueStatements.js +++ b/tests/baselines/reference/invalidWhileContinueStatements.js @@ -1,4 +1,5 @@ //// [invalidWhileContinueStatements.ts] + // All errors // naked continue not allowed diff --git a/tests/baselines/reference/letAndVarRedeclaration.errors.txt b/tests/baselines/reference/letAndVarRedeclaration.errors.txt index 3c523154c3f..50a916e8d90 100644 --- a/tests/baselines/reference/letAndVarRedeclaration.errors.txt +++ b/tests/baselines/reference/letAndVarRedeclaration.errors.txt @@ -1,28 +1,28 @@ -tests/cases/compiler/letAndVarRedeclaration.ts(2,5): error TS2451: Cannot redeclare block-scoped variable 'e0'. tests/cases/compiler/letAndVarRedeclaration.ts(3,5): error TS2451: Cannot redeclare block-scoped variable 'e0'. -tests/cases/compiler/letAndVarRedeclaration.ts(4,10): error TS2451: Cannot redeclare block-scoped variable 'e0'. -tests/cases/compiler/letAndVarRedeclaration.ts(7,9): error TS2451: Cannot redeclare block-scoped variable 'x1'. +tests/cases/compiler/letAndVarRedeclaration.ts(4,5): error TS2451: Cannot redeclare block-scoped variable 'e0'. +tests/cases/compiler/letAndVarRedeclaration.ts(5,10): error TS2451: Cannot redeclare block-scoped variable 'e0'. tests/cases/compiler/letAndVarRedeclaration.ts(8,9): error TS2451: Cannot redeclare block-scoped variable 'x1'. -tests/cases/compiler/letAndVarRedeclaration.ts(9,14): error TS2451: Cannot redeclare block-scoped variable 'x1'. -tests/cases/compiler/letAndVarRedeclaration.ts(13,9): error TS2451: Cannot redeclare block-scoped variable 'x'. -tests/cases/compiler/letAndVarRedeclaration.ts(15,13): error TS2451: Cannot redeclare block-scoped variable 'x'. -tests/cases/compiler/letAndVarRedeclaration.ts(18,18): error TS2451: Cannot redeclare block-scoped variable 'x'. -tests/cases/compiler/letAndVarRedeclaration.ts(23,9): error TS2451: Cannot redeclare block-scoped variable 'x2'. +tests/cases/compiler/letAndVarRedeclaration.ts(9,9): error TS2451: Cannot redeclare block-scoped variable 'x1'. +tests/cases/compiler/letAndVarRedeclaration.ts(10,14): error TS2451: Cannot redeclare block-scoped variable 'x1'. +tests/cases/compiler/letAndVarRedeclaration.ts(14,9): error TS2451: Cannot redeclare block-scoped variable 'x'. +tests/cases/compiler/letAndVarRedeclaration.ts(16,13): error TS2451: Cannot redeclare block-scoped variable 'x'. +tests/cases/compiler/letAndVarRedeclaration.ts(19,18): error TS2451: Cannot redeclare block-scoped variable 'x'. tests/cases/compiler/letAndVarRedeclaration.ts(24,9): error TS2451: Cannot redeclare block-scoped variable 'x2'. -tests/cases/compiler/letAndVarRedeclaration.ts(25,14): error TS2451: Cannot redeclare block-scoped variable 'x2'. -tests/cases/compiler/letAndVarRedeclaration.ts(29,9): error TS2451: Cannot redeclare block-scoped variable 'x2'. -tests/cases/compiler/letAndVarRedeclaration.ts(31,13): error TS2451: Cannot redeclare block-scoped variable 'x2'. -tests/cases/compiler/letAndVarRedeclaration.ts(34,18): error TS2451: Cannot redeclare block-scoped variable 'x2'. -tests/cases/compiler/letAndVarRedeclaration.ts(38,5): error TS2451: Cannot redeclare block-scoped variable 'x11'. -tests/cases/compiler/letAndVarRedeclaration.ts(39,10): error TS2451: Cannot redeclare block-scoped variable 'x11'. -tests/cases/compiler/letAndVarRedeclaration.ts(43,9): error TS2451: Cannot redeclare block-scoped variable 'x11'. -tests/cases/compiler/letAndVarRedeclaration.ts(44,14): error TS2451: Cannot redeclare block-scoped variable 'x11'. -tests/cases/compiler/letAndVarRedeclaration.ts(48,1): error TS7027: Unreachable code detected. -tests/cases/compiler/letAndVarRedeclaration.ts(49,9): error TS2451: Cannot redeclare block-scoped variable 'x11'. -tests/cases/compiler/letAndVarRedeclaration.ts(50,14): error TS2451: Cannot redeclare block-scoped variable 'x11'. +tests/cases/compiler/letAndVarRedeclaration.ts(25,9): error TS2451: Cannot redeclare block-scoped variable 'x2'. +tests/cases/compiler/letAndVarRedeclaration.ts(26,14): error TS2451: Cannot redeclare block-scoped variable 'x2'. +tests/cases/compiler/letAndVarRedeclaration.ts(30,9): error TS2451: Cannot redeclare block-scoped variable 'x2'. +tests/cases/compiler/letAndVarRedeclaration.ts(32,13): error TS2451: Cannot redeclare block-scoped variable 'x2'. +tests/cases/compiler/letAndVarRedeclaration.ts(35,18): error TS2451: Cannot redeclare block-scoped variable 'x2'. +tests/cases/compiler/letAndVarRedeclaration.ts(39,5): error TS2451: Cannot redeclare block-scoped variable 'x11'. +tests/cases/compiler/letAndVarRedeclaration.ts(40,10): error TS2451: Cannot redeclare block-scoped variable 'x11'. +tests/cases/compiler/letAndVarRedeclaration.ts(44,9): error TS2451: Cannot redeclare block-scoped variable 'x11'. +tests/cases/compiler/letAndVarRedeclaration.ts(45,14): error TS2451: Cannot redeclare block-scoped variable 'x11'. +tests/cases/compiler/letAndVarRedeclaration.ts(50,9): error TS2451: Cannot redeclare block-scoped variable 'x11'. +tests/cases/compiler/letAndVarRedeclaration.ts(51,14): error TS2451: Cannot redeclare block-scoped variable 'x11'. -==== tests/cases/compiler/letAndVarRedeclaration.ts (22 errors) ==== +==== tests/cases/compiler/letAndVarRedeclaration.ts (21 errors) ==== + let e0 ~~ @@ -109,8 +109,6 @@ tests/cases/compiler/letAndVarRedeclaration.ts(50,14): error TS2451: Cannot rede } module M2 { - ~~~~~~ -!!! error TS7027: Unreachable code detected. let x11; ~~~ !!! error TS2451: Cannot redeclare block-scoped variable 'x11'. diff --git a/tests/baselines/reference/letAndVarRedeclaration.js b/tests/baselines/reference/letAndVarRedeclaration.js index fd4bfe67cac..eb4dfc9c0e8 100644 --- a/tests/baselines/reference/letAndVarRedeclaration.js +++ b/tests/baselines/reference/letAndVarRedeclaration.js @@ -1,5 +1,6 @@ //// [letAndVarRedeclaration.ts] + let e0 var e0; function e0() { } diff --git a/tests/baselines/reference/letDeclarations-invalidContexts.errors.txt b/tests/baselines/reference/letDeclarations-invalidContexts.errors.txt index f3144b52500..e46554ec0e6 100644 --- a/tests/baselines/reference/letDeclarations-invalidContexts.errors.txt +++ b/tests/baselines/reference/letDeclarations-invalidContexts.errors.txt @@ -1,17 +1,16 @@ -tests/cases/compiler/letDeclarations-invalidContexts.ts(4,5): error TS1157: 'let' declarations can only be declared inside a block. -tests/cases/compiler/letDeclarations-invalidContexts.ts(6,5): error TS7027: Unreachable code detected. -tests/cases/compiler/letDeclarations-invalidContexts.ts(6,5): error TS1157: 'let' declarations can only be declared inside a block. -tests/cases/compiler/letDeclarations-invalidContexts.ts(9,5): error TS1157: 'let' declarations can only be declared inside a block. -tests/cases/compiler/letDeclarations-invalidContexts.ts(11,1): error TS7027: Unreachable code detected. -tests/cases/compiler/letDeclarations-invalidContexts.ts(12,5): error TS1157: 'let' declarations can only be declared inside a block. -tests/cases/compiler/letDeclarations-invalidContexts.ts(16,7): error TS2410: All symbols within a 'with' block will be resolved to 'any'. -tests/cases/compiler/letDeclarations-invalidContexts.ts(20,5): error TS1157: 'let' declarations can only be declared inside a block. -tests/cases/compiler/letDeclarations-invalidContexts.ts(23,5): error TS1157: 'let' declarations can only be declared inside a block. -tests/cases/compiler/letDeclarations-invalidContexts.ts(26,12): error TS1157: 'let' declarations can only be declared inside a block. -tests/cases/compiler/letDeclarations-invalidContexts.ts(29,29): error TS1157: 'let' declarations can only be declared inside a block. +tests/cases/compiler/letDeclarations-invalidContexts.ts(5,5): error TS1157: 'let' declarations can only be declared inside a block. +tests/cases/compiler/letDeclarations-invalidContexts.ts(7,5): error TS1157: 'let' declarations can only be declared inside a block. +tests/cases/compiler/letDeclarations-invalidContexts.ts(10,5): error TS1157: 'let' declarations can only be declared inside a block. +tests/cases/compiler/letDeclarations-invalidContexts.ts(13,5): error TS1157: 'let' declarations can only be declared inside a block. +tests/cases/compiler/letDeclarations-invalidContexts.ts(17,7): error TS2410: All symbols within a 'with' block will be resolved to 'any'. +tests/cases/compiler/letDeclarations-invalidContexts.ts(21,5): error TS1157: 'let' declarations can only be declared inside a block. +tests/cases/compiler/letDeclarations-invalidContexts.ts(24,5): error TS1157: 'let' declarations can only be declared inside a block. +tests/cases/compiler/letDeclarations-invalidContexts.ts(27,12): error TS1157: 'let' declarations can only be declared inside a block. +tests/cases/compiler/letDeclarations-invalidContexts.ts(30,29): error TS1157: 'let' declarations can only be declared inside a block. -==== tests/cases/compiler/letDeclarations-invalidContexts.ts (11 errors) ==== +==== tests/cases/compiler/letDeclarations-invalidContexts.ts (9 errors) ==== + // Errors, let must be defined inside a block if (true) @@ -20,8 +19,6 @@ tests/cases/compiler/letDeclarations-invalidContexts.ts(29,29): error TS1157: 'l !!! error TS1157: 'let' declarations can only be declared inside a block. else let l2 = 0; - ~~~ -!!! error TS7027: Unreachable code detected. ~~~~~~~~~~~ !!! error TS1157: 'let' declarations can only be declared inside a block. @@ -31,8 +28,6 @@ tests/cases/compiler/letDeclarations-invalidContexts.ts(29,29): error TS1157: 'l !!! error TS1157: 'let' declarations can only be declared inside a block. do - ~~ -!!! error TS7027: Unreachable code detected. let l4 = 0; ~~~~~~~~~~~ !!! error TS1157: 'let' declarations can only be declared inside a block. diff --git a/tests/baselines/reference/letDeclarations-invalidContexts.js b/tests/baselines/reference/letDeclarations-invalidContexts.js index f8c3bb04bdb..4c3be1faed8 100644 --- a/tests/baselines/reference/letDeclarations-invalidContexts.js +++ b/tests/baselines/reference/letDeclarations-invalidContexts.js @@ -1,5 +1,6 @@ //// [letDeclarations-invalidContexts.ts] + // Errors, let must be defined inside a block if (true) let l1 = 0; diff --git a/tests/baselines/reference/letDeclarations-scopes.errors.txt b/tests/baselines/reference/letDeclarations-scopes.errors.txt index 49072f30e98..1b10903af7c 100644 --- a/tests/baselines/reference/letDeclarations-scopes.errors.txt +++ b/tests/baselines/reference/letDeclarations-scopes.errors.txt @@ -1,10 +1,8 @@ -tests/cases/compiler/letDeclarations-scopes.ts(13,5): error TS7027: Unreachable code detected. -tests/cases/compiler/letDeclarations-scopes.ts(22,1): error TS7027: Unreachable code detected. -tests/cases/compiler/letDeclarations-scopes.ts(28,7): error TS2410: All symbols within a 'with' block will be resolved to 'any'. -tests/cases/compiler/letDeclarations-scopes.ts(120,5): error TS7028: Unused label. +tests/cases/compiler/letDeclarations-scopes.ts(29,7): error TS2410: All symbols within a 'with' block will be resolved to 'any'. -==== tests/cases/compiler/letDeclarations-scopes.ts (4 errors) ==== +==== tests/cases/compiler/letDeclarations-scopes.ts (1 errors) ==== + // global let l = "string"; @@ -18,8 +16,6 @@ tests/cases/compiler/letDeclarations-scopes.ts(120,5): error TS7028: Unused labe } else { let l = 0; - ~~~ -!!! error TS7027: Unreachable code detected. n = l; } @@ -29,8 +25,6 @@ tests/cases/compiler/letDeclarations-scopes.ts(120,5): error TS7028: Unused labe } do { - ~~ -!!! error TS7027: Unreachable code detected. let l = 0; n = l; } while (true); @@ -131,8 +125,6 @@ tests/cases/compiler/letDeclarations-scopes.ts(120,5): error TS7028: Unused labe } lable: let l2 = 0; - ~~~~~ -!!! error TS7028: Unused label. } // methods diff --git a/tests/baselines/reference/letDeclarations-scopes.js b/tests/baselines/reference/letDeclarations-scopes.js index d0489820d0b..3fc5976b4b7 100644 --- a/tests/baselines/reference/letDeclarations-scopes.js +++ b/tests/baselines/reference/letDeclarations-scopes.js @@ -1,5 +1,6 @@ //// [letDeclarations-scopes.ts] + // global let l = "string"; diff --git a/tests/baselines/reference/letDeclarations-validContexts.errors.txt b/tests/baselines/reference/letDeclarations-validContexts.errors.txt index f5e8022191b..acec026daf0 100644 --- a/tests/baselines/reference/letDeclarations-validContexts.errors.txt +++ b/tests/baselines/reference/letDeclarations-validContexts.errors.txt @@ -1,13 +1,8 @@ -tests/cases/compiler/letDeclarations-validContexts.ts(8,5): error TS7027: Unreachable code detected. -tests/cases/compiler/letDeclarations-validContexts.ts(15,1): error TS7027: Unreachable code detected. -tests/cases/compiler/letDeclarations-validContexts.ts(20,7): error TS2410: All symbols within a 'with' block will be resolved to 'any'. -tests/cases/compiler/letDeclarations-validContexts.ts(132,5): error TS7028: Unused label. -tests/cases/compiler/letDeclarations-validContexts.ts(134,9): error TS7028: Unused label. -tests/cases/compiler/letDeclarations-validContexts.ts(139,5): error TS7028: Unused label. -tests/cases/compiler/letDeclarations-validContexts.ts(141,9): error TS7028: Unused label. +tests/cases/compiler/letDeclarations-validContexts.ts(21,7): error TS2410: All symbols within a 'with' block will be resolved to 'any'. -==== tests/cases/compiler/letDeclarations-validContexts.ts (7 errors) ==== +==== tests/cases/compiler/letDeclarations-validContexts.ts (1 errors) ==== + // Control flow statements with blocks @@ -16,8 +11,6 @@ tests/cases/compiler/letDeclarations-validContexts.ts(141,9): error TS7028: Unus } else { let l2 = 0; - ~~~ -!!! error TS7027: Unreachable code detected. } while (true) { @@ -25,8 +18,6 @@ tests/cases/compiler/letDeclarations-validContexts.ts(141,9): error TS7028: Unus } do { - ~~ -!!! error TS7027: Unreachable code detected. let l4 = 0; } while (true); @@ -146,22 +137,14 @@ tests/cases/compiler/letDeclarations-validContexts.ts(141,9): error TS7028: Unus function f3() { label: let l32 = 0; - ~~~~~ -!!! error TS7028: Unused label. { label2: let l33 = 0; - ~~~~~~ -!!! error TS7028: Unused label. } } module m3 { label: let l34 = 0; - ~~~~~ -!!! error TS7028: Unused label. { label2: let l35 = 0; - ~~~~~~ -!!! error TS7028: Unused label. } } \ No newline at end of file diff --git a/tests/baselines/reference/letDeclarations-validContexts.js b/tests/baselines/reference/letDeclarations-validContexts.js index b11a1922383..1859a0215bb 100644 --- a/tests/baselines/reference/letDeclarations-validContexts.js +++ b/tests/baselines/reference/letDeclarations-validContexts.js @@ -1,6 +1,7 @@ //// [letDeclarations-validContexts.ts] + // Control flow statements with blocks if (true) { let l1 = 0; diff --git a/tests/baselines/reference/localTypes4.errors.txt b/tests/baselines/reference/localTypes4.errors.txt index d6a3f0ce699..4d08644ea89 100644 --- a/tests/baselines/reference/localTypes4.errors.txt +++ b/tests/baselines/reference/localTypes4.errors.txt @@ -1,11 +1,11 @@ -tests/cases/conformance/types/localTypes/localTypes4.ts(10,19): error TS2304: Cannot find name 'T'. -tests/cases/conformance/types/localTypes/localTypes4.ts(10,23): error TS2304: Cannot find name 'T'. -tests/cases/conformance/types/localTypes/localTypes4.ts(18,16): error TS2300: Duplicate identifier 'T'. -tests/cases/conformance/types/localTypes/localTypes4.ts(19,19): error TS2300: Duplicate identifier 'T'. -tests/cases/conformance/types/localTypes/localTypes4.ts(35,9): error TS7027: Unreachable code detected. +tests/cases/conformance/types/localTypes/localTypes4.ts(11,19): error TS2304: Cannot find name 'T'. +tests/cases/conformance/types/localTypes/localTypes4.ts(11,23): error TS2304: Cannot find name 'T'. +tests/cases/conformance/types/localTypes/localTypes4.ts(19,16): error TS2300: Duplicate identifier 'T'. +tests/cases/conformance/types/localTypes/localTypes4.ts(20,19): error TS2300: Duplicate identifier 'T'. -==== tests/cases/conformance/types/localTypes/localTypes4.ts (5 errors) ==== +==== tests/cases/conformance/types/localTypes/localTypes4.ts (4 errors) ==== + function f1() { // Type parameters are in scope in parameters and return types function f(x: T): T { @@ -49,8 +49,6 @@ tests/cases/conformance/types/localTypes/localTypes4.ts(35,9): error TS7027: Unr } else { v.x = 20; - ~ -!!! error TS7027: Unreachable code detected. } } \ No newline at end of file diff --git a/tests/baselines/reference/localTypes4.js b/tests/baselines/reference/localTypes4.js index 8f51761a65a..3b81175d2b6 100644 --- a/tests/baselines/reference/localTypes4.js +++ b/tests/baselines/reference/localTypes4.js @@ -1,4 +1,5 @@ //// [localTypes4.ts] + function f1() { // Type parameters are in scope in parameters and return types function f(x: T): T { diff --git a/tests/baselines/reference/null.errors.txt b/tests/baselines/reference/null.errors.txt deleted file mode 100644 index b516720b241..00000000000 --- a/tests/baselines/reference/null.errors.txt +++ /dev/null @@ -1,30 +0,0 @@ -tests/cases/compiler/null.ts(8,5): error TS7027: Unreachable code detected. -tests/cases/compiler/null.ts(12,5): error TS7027: Unreachable code detected. - - -==== tests/cases/compiler/null.ts (2 errors) ==== - var x=null; - var y=3+x; - var z=3+null; - class C { - } - function f() { - return null; - return new C(); - ~~~~~~ -!!! error TS7027: Unreachable code detected. - } - function g() { - return null; - return 3; - ~~~~~~ -!!! error TS7027: Unreachable code detected. - } - interface I { - x:any; - y:number; - } - var w:I={x:null,y:3}; - - - \ No newline at end of file diff --git a/tests/baselines/reference/null.js b/tests/baselines/reference/null.js index 499d6901847..ee897643fb1 100644 --- a/tests/baselines/reference/null.js +++ b/tests/baselines/reference/null.js @@ -1,4 +1,5 @@ //// [null.ts] + var x=null; var y=3+x; var z=3+null; diff --git a/tests/baselines/reference/null.symbols b/tests/baselines/reference/null.symbols new file mode 100644 index 00000000000..bd3d835995b --- /dev/null +++ b/tests/baselines/reference/null.symbols @@ -0,0 +1,45 @@ +=== tests/cases/compiler/null.ts === + +var x=null; +>x : Symbol(x, Decl(null.ts, 1, 3)) + +var y=3+x; +>y : Symbol(y, Decl(null.ts, 2, 3)) +>x : Symbol(x, Decl(null.ts, 1, 3)) + +var z=3+null; +>z : Symbol(z, Decl(null.ts, 3, 3)) + +class C { +>C : Symbol(C, Decl(null.ts, 3, 13)) +} +function f() { +>f : Symbol(f, Decl(null.ts, 5, 1)) + + return null; + return new C(); +>C : Symbol(C, Decl(null.ts, 3, 13)) +} +function g() { +>g : Symbol(g, Decl(null.ts, 9, 1)) + + return null; + return 3; +} +interface I { +>I : Symbol(I, Decl(null.ts, 13, 1)) + + x:any; +>x : Symbol(x, Decl(null.ts, 14, 13)) + + y:number; +>y : Symbol(y, Decl(null.ts, 15, 10)) +} +var w:I={x:null,y:3}; +>w : Symbol(w, Decl(null.ts, 18, 3)) +>I : Symbol(I, Decl(null.ts, 13, 1)) +>x : Symbol(x, Decl(null.ts, 18, 9)) +>y : Symbol(y, Decl(null.ts, 18, 16)) + + + diff --git a/tests/baselines/reference/null.types b/tests/baselines/reference/null.types new file mode 100644 index 00000000000..6fd8b423f13 --- /dev/null +++ b/tests/baselines/reference/null.types @@ -0,0 +1,60 @@ +=== tests/cases/compiler/null.ts === + +var x=null; +>x : any +>null : null + +var y=3+x; +>y : any +>3+x : any +>3 : number +>x : any + +var z=3+null; +>z : number +>3+null : number +>3 : number +>null : null + +class C { +>C : C +} +function f() { +>f : () => C + + return null; +>null : null + + return new C(); +>new C() : C +>C : typeof C +} +function g() { +>g : () => number + + return null; +>null : null + + return 3; +>3 : number +} +interface I { +>I : I + + x:any; +>x : any + + y:number; +>y : number +} +var w:I={x:null,y:3}; +>w : I +>I : I +>{x:null,y:3} : { x: null; y: number; } +>x : null +>null : null +>y : number +>3 : number + + + diff --git a/tests/baselines/reference/overloadOnConstAsTypeAnnotation.errors.txt b/tests/baselines/reference/overloadOnConstAsTypeAnnotation.errors.txt index 48f1ce1bd13..a78e0c8abcf 100644 --- a/tests/baselines/reference/overloadOnConstAsTypeAnnotation.errors.txt +++ b/tests/baselines/reference/overloadOnConstAsTypeAnnotation.errors.txt @@ -1,13 +1,11 @@ -tests/cases/compiler/overloadOnConstAsTypeAnnotation.ts(1,8): error TS2382: Specialized overload signature is not assignable to any non-specialized signature. -tests/cases/compiler/overloadOnConstAsTypeAnnotation.ts(1,37): error TS1005: ';' expected. -tests/cases/compiler/overloadOnConstAsTypeAnnotation.ts(1,53): error TS7027: Unreachable code detected. +tests/cases/compiler/overloadOnConstAsTypeAnnotation.ts(2,8): error TS2382: Specialized overload signature is not assignable to any non-specialized signature. +tests/cases/compiler/overloadOnConstAsTypeAnnotation.ts(2,37): error TS1005: ';' expected. -==== tests/cases/compiler/overloadOnConstAsTypeAnnotation.ts (3 errors) ==== +==== tests/cases/compiler/overloadOnConstAsTypeAnnotation.ts (2 errors) ==== + var f: (x: 'hi') => number = ('hi') => { return 1; }; ~~~~~~~~~~~~~~~~~~~ !!! error TS2382: Specialized overload signature is not assignable to any non-specialized signature. ~~ -!!! error TS1005: ';' expected. - ~ -!!! error TS7027: Unreachable code detected. \ No newline at end of file +!!! error TS1005: ';' expected. \ No newline at end of file diff --git a/tests/baselines/reference/overloadOnConstAsTypeAnnotation.js b/tests/baselines/reference/overloadOnConstAsTypeAnnotation.js index 48e52ba0967..aa5c8701f28 100644 --- a/tests/baselines/reference/overloadOnConstAsTypeAnnotation.js +++ b/tests/baselines/reference/overloadOnConstAsTypeAnnotation.js @@ -1,4 +1,5 @@ //// [overloadOnConstAsTypeAnnotation.ts] + var f: (x: 'hi') => number = ('hi') => { return 1; }; //// [overloadOnConstAsTypeAnnotation.js] diff --git a/tests/baselines/reference/parser10.1.1-8gs.errors.txt b/tests/baselines/reference/parser10.1.1-8gs.errors.txt index c321ca1fff8..3426ccab8da 100644 --- a/tests/baselines/reference/parser10.1.1-8gs.errors.txt +++ b/tests/baselines/reference/parser10.1.1-8gs.errors.txt @@ -1,9 +1,9 @@ -tests/cases/conformance/parser/ecmascript5/parser10.1.1-8gs.ts(16,7): error TS2304: Cannot find name 'NotEarlyError'. -tests/cases/conformance/parser/ecmascript5/parser10.1.1-8gs.ts(17,1): error TS7027: Unreachable code detected. -tests/cases/conformance/parser/ecmascript5/parser10.1.1-8gs.ts(17,5): error TS1212: Identifier expected. 'public' is a reserved word in strict mode +tests/cases/conformance/parser/ecmascript5/parser10.1.1-8gs.ts(17,7): error TS2304: Cannot find name 'NotEarlyError'. +tests/cases/conformance/parser/ecmascript5/parser10.1.1-8gs.ts(18,5): error TS1212: Identifier expected. 'public' is a reserved word in strict mode -==== tests/cases/conformance/parser/ecmascript5/parser10.1.1-8gs.ts (3 errors) ==== +==== tests/cases/conformance/parser/ecmascript5/parser10.1.1-8gs.ts (2 errors) ==== + /// Copyright (c) 2012 Ecma International. All rights reserved. /// Ecma International makes this code available under the terms and conditions set /// forth on http://hg.ecmascript.org/tests/test262/raw-file/tip/LICENSE (the @@ -23,8 +23,6 @@ tests/cases/conformance/parser/ecmascript5/parser10.1.1-8gs.ts(17,5): error TS12 ~~~~~~~~~~~~~ !!! error TS2304: Cannot find name 'NotEarlyError'. var public = 1; - ~~~ -!!! error TS7027: Unreachable code detected. ~~~~~~ !!! error TS1212: Identifier expected. 'public' is a reserved word in strict mode \ No newline at end of file diff --git a/tests/baselines/reference/parser10.1.1-8gs.js b/tests/baselines/reference/parser10.1.1-8gs.js index e7d342cf1f1..fb3b96f6baf 100644 --- a/tests/baselines/reference/parser10.1.1-8gs.js +++ b/tests/baselines/reference/parser10.1.1-8gs.js @@ -1,4 +1,5 @@ //// [parser10.1.1-8gs.ts] + /// Copyright (c) 2012 Ecma International. All rights reserved. /// Ecma International makes this code available under the terms and conditions set /// forth on http://hg.ecmascript.org/tests/test262/raw-file/tip/LICENSE (the diff --git a/tests/baselines/reference/parser768531.errors.txt b/tests/baselines/reference/parser768531.errors.txt deleted file mode 100644 index 8298431e0e0..00000000000 --- a/tests/baselines/reference/parser768531.errors.txt +++ /dev/null @@ -1,8 +0,0 @@ -tests/cases/conformance/parser/ecmascript5/Fuzz/parser768531.ts(1,2): error TS7028: Unused label. - - -==== tests/cases/conformance/parser/ecmascript5/Fuzz/parser768531.ts (1 errors) ==== - {a: 3} - ~ -!!! error TS7028: Unused label. - /x/ \ No newline at end of file diff --git a/tests/baselines/reference/parser768531.js b/tests/baselines/reference/parser768531.js index 26e22117717..462db3742b3 100644 --- a/tests/baselines/reference/parser768531.js +++ b/tests/baselines/reference/parser768531.js @@ -1,4 +1,5 @@ //// [parser768531.ts] + {a: 3} /x/ diff --git a/tests/baselines/reference/parser768531.symbols b/tests/baselines/reference/parser768531.symbols new file mode 100644 index 00000000000..f180922c7e0 --- /dev/null +++ b/tests/baselines/reference/parser768531.symbols @@ -0,0 +1,5 @@ +=== tests/cases/conformance/parser/ecmascript5/Fuzz/parser768531.ts === + +No type information for this code.{a: 3} +No type information for this code./x/ +No type information for this code. \ No newline at end of file diff --git a/tests/baselines/reference/parser768531.types b/tests/baselines/reference/parser768531.types new file mode 100644 index 00000000000..434535b5cc9 --- /dev/null +++ b/tests/baselines/reference/parser768531.types @@ -0,0 +1,9 @@ +=== tests/cases/conformance/parser/ecmascript5/Fuzz/parser768531.ts === + +{a: 3} +>a : any +>3 : number + +/x/ +>/x/ : RegExp + diff --git a/tests/baselines/reference/whileBreakStatements.errors.txt b/tests/baselines/reference/whileBreakStatements.errors.txt deleted file mode 100644 index 7c63dc59d3c..00000000000 --- a/tests/baselines/reference/whileBreakStatements.errors.txt +++ /dev/null @@ -1,54 +0,0 @@ -tests/cases/conformance/statements/breakStatements/whileBreakStatements.ts(11,1): error TS7028: Unused label. -tests/cases/conformance/statements/breakStatements/whileBreakStatements.ts(19,5): error TS7028: Unused label. -tests/cases/conformance/statements/breakStatements/whileBreakStatements.ts(31,1): error TS7027: Unreachable code detected. - - -==== tests/cases/conformance/statements/breakStatements/whileBreakStatements.ts (3 errors) ==== - while(true) { - break; - } - - ONE: - - while (true) { - break ONE; - } - - TWO: - ~~~ -!!! error TS7028: Unused label. - THREE: - while (true) { - break THREE; - } - - FOUR: - while (true) { - FIVE: - ~~~~ -!!! error TS7028: Unused label. - while (true) { - break FOUR; - } - } - - while (true) { - SIX: - while (true) - break SIX; - } - - SEVEN: - ~~~~~ -!!! error TS7027: Unreachable code detected. - while (true) - while (true) - while (true) - break SEVEN; - - EIGHT: - while (true) { - var fn = function () { } - break EIGHT; - } - \ No newline at end of file diff --git a/tests/baselines/reference/whileBreakStatements.js b/tests/baselines/reference/whileBreakStatements.js index 818be39a242..15dffe3e582 100644 --- a/tests/baselines/reference/whileBreakStatements.js +++ b/tests/baselines/reference/whileBreakStatements.js @@ -1,4 +1,5 @@ //// [whileBreakStatements.ts] + while(true) { break; } diff --git a/tests/baselines/reference/whileBreakStatements.symbols b/tests/baselines/reference/whileBreakStatements.symbols new file mode 100644 index 00000000000..022fe9a12a8 --- /dev/null +++ b/tests/baselines/reference/whileBreakStatements.symbols @@ -0,0 +1,46 @@ +=== tests/cases/conformance/statements/breakStatements/whileBreakStatements.ts === + +while(true) { + break; +} + +ONE: + +while (true) { + break ONE; +} + +TWO: +THREE: +while (true) { + break THREE; +} + +FOUR: +while (true) { + FIVE: + while (true) { + break FOUR; + } +} + +while (true) { + SIX: + while (true) + break SIX; +} + +SEVEN: +while (true) + while (true) + while (true) + break SEVEN; + +EIGHT: +while (true) { + var fn = function () { } +>fn : Symbol(fn, Decl(whileBreakStatements.ts, 39, 7)) + + break EIGHT; +} + diff --git a/tests/baselines/reference/whileBreakStatements.types b/tests/baselines/reference/whileBreakStatements.types new file mode 100644 index 00000000000..a31d1e9b40e --- /dev/null +++ b/tests/baselines/reference/whileBreakStatements.types @@ -0,0 +1,90 @@ +=== tests/cases/conformance/statements/breakStatements/whileBreakStatements.ts === + +while(true) { +>true : boolean + + break; +} + +ONE: +>ONE : any + +while (true) { +>true : boolean + + break ONE; +>ONE : any +} + +TWO: +>TWO : any + +THREE: +>THREE : any + +while (true) { +>true : boolean + + break THREE; +>THREE : any +} + +FOUR: +>FOUR : any + +while (true) { +>true : boolean + + FIVE: +>FIVE : any + + while (true) { +>true : boolean + + break FOUR; +>FOUR : any + } +} + +while (true) { +>true : boolean + + SIX: +>SIX : any + + while (true) +>true : boolean + + break SIX; +>SIX : any +} + +SEVEN: +>SEVEN : any + +while (true) +>true : boolean + + while (true) +>true : boolean + + while (true) +>true : boolean + + break SEVEN; +>SEVEN : any + +EIGHT: +>EIGHT : any + +while (true) { +>true : boolean + + var fn = function () { } +>fn : () => void +>function () { } : () => void + + break EIGHT; +>EIGHT : any +} + diff --git a/tests/cases/compiler/bestCommonTypeReturnStatement.ts b/tests/cases/compiler/bestCommonTypeReturnStatement.ts index aff173664f6..cb481147f9b 100644 --- a/tests/cases/compiler/bestCommonTypeReturnStatement.ts +++ b/tests/cases/compiler/bestCommonTypeReturnStatement.ts @@ -1,3 +1,5 @@ +// @allowUnreachableCode: true + interface IPromise { then(successCallback: (promiseValue: T) => any, errorCallback?: (reason: any) => any): IPromise; } diff --git a/tests/cases/compiler/breakTarget3.ts b/tests/cases/compiler/breakTarget3.ts index 9cef599692c..64a9357706f 100644 --- a/tests/cases/compiler/breakTarget3.ts +++ b/tests/cases/compiler/breakTarget3.ts @@ -1,3 +1,5 @@ +// @allowUnusedLabels: true + target1: target2: while (true) { diff --git a/tests/cases/compiler/breakTarget4.ts b/tests/cases/compiler/breakTarget4.ts index 2c3eadca7db..3e00bca659b 100644 --- a/tests/cases/compiler/breakTarget4.ts +++ b/tests/cases/compiler/breakTarget4.ts @@ -1,3 +1,5 @@ +// @allowUnusedLabels: true + target1: target2: while (true) { diff --git a/tests/cases/compiler/breakTarget5.ts b/tests/cases/compiler/breakTarget5.ts index a05ee1cf879..f0bceb5015f 100644 --- a/tests/cases/compiler/breakTarget5.ts +++ b/tests/cases/compiler/breakTarget5.ts @@ -1,3 +1,5 @@ +// @allowUnusedLabels: true + target: while (true) { function f() { diff --git a/tests/cases/compiler/commentEmitAtEndOfFile1.ts b/tests/cases/compiler/commentEmitAtEndOfFile1.ts index b1b863890d5..5713ef006e5 100644 --- a/tests/cases/compiler/commentEmitAtEndOfFile1.ts +++ b/tests/cases/compiler/commentEmitAtEndOfFile1.ts @@ -1,3 +1,5 @@ +// @allowUnusedLabels: true + // test var f = '' // test #2 diff --git a/tests/cases/compiler/conditionalExpressions2.ts b/tests/cases/compiler/conditionalExpressions2.ts index 6f2f097f6de..ece002d7778 100644 --- a/tests/cases/compiler/conditionalExpressions2.ts +++ b/tests/cases/compiler/conditionalExpressions2.ts @@ -1,3 +1,5 @@ +// @allowUnreachableCode: true + var a = false ? 1 : null; var b = false ? undefined : 0; var c = false ? 1 : 0; diff --git a/tests/cases/compiler/constDeclarations-invalidContexts.ts b/tests/cases/compiler/constDeclarations-invalidContexts.ts index b5093180990..6d21ee31ec2 100644 --- a/tests/cases/compiler/constDeclarations-invalidContexts.ts +++ b/tests/cases/compiler/constDeclarations-invalidContexts.ts @@ -1,3 +1,4 @@ +// @allowUnreachableCode: true // @target: ES6 // Errors, const must be defined inside a block diff --git a/tests/cases/compiler/constDeclarations-validContexts.ts b/tests/cases/compiler/constDeclarations-validContexts.ts index ffde8e45d6f..63af6d16959 100644 --- a/tests/cases/compiler/constDeclarations-validContexts.ts +++ b/tests/cases/compiler/constDeclarations-validContexts.ts @@ -1,3 +1,4 @@ +// @allowUnreachableCode: true // @target: ES6 diff --git a/tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts b/tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts index a93628e5494..63e0fc30141 100644 --- a/tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts +++ b/tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts @@ -1,3 +1,5 @@ +// @allowUnreachableCode: true + declare module "fs" { export class File { constructor(filename: string); diff --git a/tests/cases/compiler/continueNotInIterationStatement4.ts b/tests/cases/compiler/continueNotInIterationStatement4.ts index 5996eb4323a..218cb151df3 100644 --- a/tests/cases/compiler/continueNotInIterationStatement4.ts +++ b/tests/cases/compiler/continueNotInIterationStatement4.ts @@ -1,3 +1,5 @@ +// @allowUnusedLabels: true + TWO: while (true){ var x = () => { diff --git a/tests/cases/compiler/continueTarget3.ts b/tests/cases/compiler/continueTarget3.ts index 26bea241a7a..a7b47ff071b 100644 --- a/tests/cases/compiler/continueTarget3.ts +++ b/tests/cases/compiler/continueTarget3.ts @@ -1,3 +1,5 @@ +// @allowUnusedLabels: true + target1: target2: while (true) { diff --git a/tests/cases/compiler/continueTarget4.ts b/tests/cases/compiler/continueTarget4.ts index e00c222aa9c..5ba2bd69b11 100644 --- a/tests/cases/compiler/continueTarget4.ts +++ b/tests/cases/compiler/continueTarget4.ts @@ -1,3 +1,5 @@ +// @allowUnusedLabels: true + target1: target2: while (true) { diff --git a/tests/cases/compiler/continueTarget5.ts b/tests/cases/compiler/continueTarget5.ts index dd3a806ab2d..5f3d068282b 100644 --- a/tests/cases/compiler/continueTarget5.ts +++ b/tests/cases/compiler/continueTarget5.ts @@ -1,3 +1,5 @@ +// @allowUnusedLabels: true + target: while (true) { function f() { diff --git a/tests/cases/compiler/downlevelLetConst16.ts b/tests/cases/compiler/downlevelLetConst16.ts index 30a27ba61f4..b30f26b4b82 100644 --- a/tests/cases/compiler/downlevelLetConst16.ts +++ b/tests/cases/compiler/downlevelLetConst16.ts @@ -1,4 +1,6 @@ // @target:es5 +// @allowUnreachableCode: true + 'use strict' declare function use(a: any); diff --git a/tests/cases/compiler/downlevelLetConst17.ts b/tests/cases/compiler/downlevelLetConst17.ts index b581281f679..7cea2031ac5 100644 --- a/tests/cases/compiler/downlevelLetConst17.ts +++ b/tests/cases/compiler/downlevelLetConst17.ts @@ -1,4 +1,5 @@ // @target:es5 +// @allowUnreachableCode: true 'use strict' declare function use(a: any); diff --git a/tests/cases/compiler/downlevelLetConst18.ts b/tests/cases/compiler/downlevelLetConst18.ts index 59f2ee7a46e..d40f23e3a37 100644 --- a/tests/cases/compiler/downlevelLetConst18.ts +++ b/tests/cases/compiler/downlevelLetConst18.ts @@ -1,4 +1,6 @@ // @target:es5 +// @allowUnreachableCode: true + 'use strict' for (let x; ;) { diff --git a/tests/cases/compiler/duplicateLabel1.ts b/tests/cases/compiler/duplicateLabel1.ts index c588e7b8183..ff248c64548 100644 --- a/tests/cases/compiler/duplicateLabel1.ts +++ b/tests/cases/compiler/duplicateLabel1.ts @@ -1,3 +1,5 @@ +// @allowUnusedLabels: true + target: target: while (true) { diff --git a/tests/cases/compiler/duplicateLabel2.ts b/tests/cases/compiler/duplicateLabel2.ts index bdb0396a246..5ebf273c118 100644 --- a/tests/cases/compiler/duplicateLabel2.ts +++ b/tests/cases/compiler/duplicateLabel2.ts @@ -1,3 +1,5 @@ +// @allowUnusedLabels: true + target: while (true) { target: diff --git a/tests/cases/compiler/duplicateLabel3.ts b/tests/cases/compiler/duplicateLabel3.ts index d4db9399ed2..d6add980447 100644 --- a/tests/cases/compiler/duplicateLabel3.ts +++ b/tests/cases/compiler/duplicateLabel3.ts @@ -1,3 +1,5 @@ +// @allowUnusedLabels: true + target: while (true) { function f() { diff --git a/tests/cases/compiler/duplicateLabel4.ts b/tests/cases/compiler/duplicateLabel4.ts index 2c62180a2ab..bf7ea5c22c6 100644 --- a/tests/cases/compiler/duplicateLabel4.ts +++ b/tests/cases/compiler/duplicateLabel4.ts @@ -1,3 +1,6 @@ +// @allowUnusedLabels: true +// @allowUnreachableCode: true + target: while (true) { } diff --git a/tests/cases/compiler/duplicateLocalVariable1.ts b/tests/cases/compiler/duplicateLocalVariable1.ts index fc20a19c2d9..f6288cfc6ae 100644 --- a/tests/cases/compiler/duplicateLocalVariable1.ts +++ b/tests/cases/compiler/duplicateLocalVariable1.ts @@ -1,4 +1,6 @@ -//@module: commonjs + +// @allowUnreachableCode: true +/ /@module: commonjs //import FileManager = require('filemanager'); //import App = require('app'); diff --git a/tests/cases/compiler/duplicateVariablesByScope.ts b/tests/cases/compiler/duplicateVariablesByScope.ts index 481c1bb950e..dc811130d4f 100644 --- a/tests/cases/compiler/duplicateVariablesByScope.ts +++ b/tests/cases/compiler/duplicateVariablesByScope.ts @@ -1,3 +1,5 @@ +// @allowUnreachableCode: true + // duplicate local variables are only reported at global scope module M { diff --git a/tests/cases/compiler/es6ClassSuperCodegenBug.ts b/tests/cases/compiler/es6ClassSuperCodegenBug.ts index 7ab8344c815..2e3f306d5d6 100644 --- a/tests/cases/compiler/es6ClassSuperCodegenBug.ts +++ b/tests/cases/compiler/es6ClassSuperCodegenBug.ts @@ -1,3 +1,5 @@ +// @allowUnreachableCode: true + class A { constructor(str1:string, str2:string) {} } diff --git a/tests/cases/compiler/escapedIdentifiers.ts b/tests/cases/compiler/escapedIdentifiers.ts index 795aeca2481..c58c59d9b42 100644 --- a/tests/cases/compiler/escapedIdentifiers.ts +++ b/tests/cases/compiler/escapedIdentifiers.ts @@ -1,3 +1,6 @@ +// @allowUnusedLabels: true +// @allowUnreachableCode: true + /* 0 .. \u0030 9 .. \u0039 diff --git a/tests/cases/compiler/for.ts b/tests/cases/compiler/for.ts index e27dab7dbd2..636c7e4a5fc 100644 --- a/tests/cases/compiler/for.ts +++ b/tests/cases/compiler/for.ts @@ -1,3 +1,5 @@ +// @allowUnreachableCode: true + for (var i = 0; i < 10; i++) { // ok var x1 = i; } diff --git a/tests/cases/compiler/functionOverloads12.ts b/tests/cases/compiler/functionOverloads12.ts index 3e8a9882d08..48a8af06cc5 100644 --- a/tests/cases/compiler/functionOverloads12.ts +++ b/tests/cases/compiler/functionOverloads12.ts @@ -1,3 +1,5 @@ +// @allowUnreachableCode: true + function foo():string; function foo():number; function foo():any { if (true) return ""; else return 0;} diff --git a/tests/cases/compiler/functionReturn.ts b/tests/cases/compiler/functionReturn.ts index 8ea0cb8f5a1..897480c64d6 100644 --- a/tests/cases/compiler/functionReturn.ts +++ b/tests/cases/compiler/functionReturn.ts @@ -1,3 +1,5 @@ +// @allowUnreachableCode: true + function f0(): void { } function f1() { var n: any = f0(); diff --git a/tests/cases/compiler/functionWithNoBestCommonType1.ts b/tests/cases/compiler/functionWithNoBestCommonType1.ts index 11628812925..2d7a1191770 100644 --- a/tests/cases/compiler/functionWithNoBestCommonType1.ts +++ b/tests/cases/compiler/functionWithNoBestCommonType1.ts @@ -1,3 +1,5 @@ +// @allowUnreachableCode: true + function foo() { return true; return bar(); diff --git a/tests/cases/compiler/functionWithNoBestCommonType2.ts b/tests/cases/compiler/functionWithNoBestCommonType2.ts index 974ccdfe035..6bc3878d834 100644 --- a/tests/cases/compiler/functionWithNoBestCommonType2.ts +++ b/tests/cases/compiler/functionWithNoBestCommonType2.ts @@ -1,3 +1,5 @@ +// @allowUnreachableCode: true + var v = function () { return true; return bar(); diff --git a/tests/cases/compiler/functionsMissingReturnStatementsAndExpressions.ts b/tests/cases/compiler/functionsMissingReturnStatementsAndExpressions.ts index 81259fd7c0c..fde615af41d 100644 --- a/tests/cases/compiler/functionsMissingReturnStatementsAndExpressions.ts +++ b/tests/cases/compiler/functionsMissingReturnStatementsAndExpressions.ts @@ -1,3 +1,5 @@ +// @allowUnreachableCode: true + // @target: es5 function f1(): string { diff --git a/tests/cases/compiler/ifElseWithStatements1.ts b/tests/cases/compiler/ifElseWithStatements1.ts index a7f337068cb..5ed7f7dd7a3 100644 --- a/tests/cases/compiler/ifElseWithStatements1.ts +++ b/tests/cases/compiler/ifElseWithStatements1.ts @@ -1,3 +1,5 @@ +// @allowUnreachableCode: true + if (true) f(); else diff --git a/tests/cases/compiler/inferredFunctionReturnTypeIsEmptyType.ts b/tests/cases/compiler/inferredFunctionReturnTypeIsEmptyType.ts index d150fb1930a..6465e7f1200 100644 --- a/tests/cases/compiler/inferredFunctionReturnTypeIsEmptyType.ts +++ b/tests/cases/compiler/inferredFunctionReturnTypeIsEmptyType.ts @@ -1,3 +1,5 @@ +// @allowUnreachableCode: true + function foo() { if (true) { return 42; diff --git a/tests/cases/compiler/inheritanceStaticPropertyOverridingAccessor.ts b/tests/cases/compiler/inheritanceStaticPropertyOverridingAccessor.ts index 2620e7d88d4..e325ae4582a 100644 --- a/tests/cases/compiler/inheritanceStaticPropertyOverridingAccessor.ts +++ b/tests/cases/compiler/inheritanceStaticPropertyOverridingAccessor.ts @@ -1,3 +1,5 @@ +// @allowUnreachableCode: true + class a { static get x(): () => string { return null;; diff --git a/tests/cases/compiler/letAndVarRedeclaration.ts b/tests/cases/compiler/letAndVarRedeclaration.ts index 1f901ded520..aaf2ce1a68c 100644 --- a/tests/cases/compiler/letAndVarRedeclaration.ts +++ b/tests/cases/compiler/letAndVarRedeclaration.ts @@ -1,3 +1,5 @@ +// @allowUnreachableCode: true + // @target: es6 let e0 diff --git a/tests/cases/compiler/letDeclarations-invalidContexts.ts b/tests/cases/compiler/letDeclarations-invalidContexts.ts index 4d165ba2cda..cde6c2006bb 100644 --- a/tests/cases/compiler/letDeclarations-invalidContexts.ts +++ b/tests/cases/compiler/letDeclarations-invalidContexts.ts @@ -1,3 +1,5 @@ +// @allowUnreachableCode: true + // @target: ES6 // Errors, let must be defined inside a block diff --git a/tests/cases/compiler/letDeclarations-scopes.ts b/tests/cases/compiler/letDeclarations-scopes.ts index 93f4ce5b4ed..b050a5e9bd0 100644 --- a/tests/cases/compiler/letDeclarations-scopes.ts +++ b/tests/cases/compiler/letDeclarations-scopes.ts @@ -1,3 +1,6 @@ +// @allowUnusedLabels: true +// @allowUnreachableCode: true + // @target: ES6 // global diff --git a/tests/cases/compiler/letDeclarations-validContexts.ts b/tests/cases/compiler/letDeclarations-validContexts.ts index baedfa2644c..2a4022901c1 100644 --- a/tests/cases/compiler/letDeclarations-validContexts.ts +++ b/tests/cases/compiler/letDeclarations-validContexts.ts @@ -1,3 +1,6 @@ +// @allowUnusedLabels: true +// @allowUnreachableCode: true + // @target: ES6 diff --git a/tests/cases/compiler/null.ts b/tests/cases/compiler/null.ts index eb88d387bcc..e8fa9a5d687 100644 --- a/tests/cases/compiler/null.ts +++ b/tests/cases/compiler/null.ts @@ -1,3 +1,5 @@ +// @allowUnreachableCode: true + var x=null; var y=3+x; var z=3+null; diff --git a/tests/cases/compiler/overloadOnConstAsTypeAnnotation.ts b/tests/cases/compiler/overloadOnConstAsTypeAnnotation.ts index 21884031aec..12b99fb29ce 100644 --- a/tests/cases/compiler/overloadOnConstAsTypeAnnotation.ts +++ b/tests/cases/compiler/overloadOnConstAsTypeAnnotation.ts @@ -1 +1,3 @@ +// @allowUnreachableCode: true + var f: (x: 'hi') => number = ('hi') => { return 1; }; \ No newline at end of file diff --git a/tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts b/tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts index b36f423be21..62311ee75c9 100644 --- a/tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts +++ b/tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts @@ -1,3 +1,5 @@ +// @allowUnusedLabels: true + // expected error for all the LHS of compound assignments (arithmetic and addition) var value; diff --git a/tests/cases/conformance/expressions/contextualTyping/generatedContextualTyping.ts b/tests/cases/conformance/expressions/contextualTyping/generatedContextualTyping.ts index cd0fb64e0d2..d6bfd84fd9a 100644 --- a/tests/cases/conformance/expressions/contextualTyping/generatedContextualTyping.ts +++ b/tests/cases/conformance/expressions/contextualTyping/generatedContextualTyping.ts @@ -1,3 +1,5 @@ +// @allowUnreachableCode: true + class Base { private p; } class Derived1 extends Base { private m; } class Derived2 extends Base { private n; } diff --git a/tests/cases/conformance/functions/functionImplementationErrors.ts b/tests/cases/conformance/functions/functionImplementationErrors.ts index ddd3ba0a2c1..0a7c7812932 100644 --- a/tests/cases/conformance/functions/functionImplementationErrors.ts +++ b/tests/cases/conformance/functions/functionImplementationErrors.ts @@ -1,3 +1,5 @@ +// @allowUnreachableCode: true + // FunctionExpression with no return type annotation with multiple return statements with unrelated types var f1 = function () { return ''; diff --git a/tests/cases/conformance/functions/functionImplementations.ts b/tests/cases/conformance/functions/functionImplementations.ts index df36a0b4457..3c5adefd2e4 100644 --- a/tests/cases/conformance/functions/functionImplementations.ts +++ b/tests/cases/conformance/functions/functionImplementations.ts @@ -1,3 +1,5 @@ +// @allowUnreachableCode: true + // FunctionExpression with no return type annotation and no return statement returns void var v: void = function () { } (); diff --git a/tests/cases/conformance/interfaces/interfacesExtendingClasses/interfaceExtendingClass2.ts b/tests/cases/conformance/interfaces/interfacesExtendingClasses/interfaceExtendingClass2.ts index 31407b88590..d35002e2f65 100644 --- a/tests/cases/conformance/interfaces/interfacesExtendingClasses/interfaceExtendingClass2.ts +++ b/tests/cases/conformance/interfaces/interfacesExtendingClasses/interfaceExtendingClass2.ts @@ -1,3 +1,5 @@ +// @allowUnreachableCode: true + class Foo { x: string; y() { } diff --git a/tests/cases/conformance/parser/ecmascript5/Fuzz/parser768531.ts b/tests/cases/conformance/parser/ecmascript5/Fuzz/parser768531.ts index cad137cc88d..62c0153f224 100644 --- a/tests/cases/conformance/parser/ecmascript5/Fuzz/parser768531.ts +++ b/tests/cases/conformance/parser/ecmascript5/Fuzz/parser768531.ts @@ -1,2 +1,4 @@ +// @allowUnusedLabels: true + {a: 3} /x/ \ No newline at end of file diff --git a/tests/cases/conformance/parser/ecmascript5/parser10.1.1-8gs.ts b/tests/cases/conformance/parser/ecmascript5/parser10.1.1-8gs.ts index 88476ac4a78..b35204beb48 100644 --- a/tests/cases/conformance/parser/ecmascript5/parser10.1.1-8gs.ts +++ b/tests/cases/conformance/parser/ecmascript5/parser10.1.1-8gs.ts @@ -1,3 +1,5 @@ +// @allowUnreachableCode: true + /// Copyright (c) 2012 Ecma International. All rights reserved. /// Ecma International makes this code available under the terms and conditions set /// forth on http://hg.ecmascript.org/tests/test262/raw-file/tip/LICENSE (the diff --git a/tests/cases/conformance/statements/breakStatements/doWhileBreakStatements.ts b/tests/cases/conformance/statements/breakStatements/doWhileBreakStatements.ts index 49bfaaca13f..cca94947a5d 100644 --- a/tests/cases/conformance/statements/breakStatements/doWhileBreakStatements.ts +++ b/tests/cases/conformance/statements/breakStatements/doWhileBreakStatements.ts @@ -1,3 +1,6 @@ +// @allowUnusedLabels: true +// @allowUnreachableCode: true + do { break; } while(true) diff --git a/tests/cases/conformance/statements/breakStatements/forBreakStatements.ts b/tests/cases/conformance/statements/breakStatements/forBreakStatements.ts index 20a93db4418..9cf07e1eef7 100644 --- a/tests/cases/conformance/statements/breakStatements/forBreakStatements.ts +++ b/tests/cases/conformance/statements/breakStatements/forBreakStatements.ts @@ -1,3 +1,6 @@ +// @allowUnusedLabels: true +// @allowUnreachableCode: true + for (; ;) { break; } diff --git a/tests/cases/conformance/statements/breakStatements/forInBreakStatements.ts b/tests/cases/conformance/statements/breakStatements/forInBreakStatements.ts index 5810d522182..ffc99ee904b 100644 --- a/tests/cases/conformance/statements/breakStatements/forInBreakStatements.ts +++ b/tests/cases/conformance/statements/breakStatements/forInBreakStatements.ts @@ -1,3 +1,5 @@ +// @allowUnusedLabels: true + for(var x in {}) { break; } diff --git a/tests/cases/conformance/statements/breakStatements/invalidDoWhileBreakStatements.ts b/tests/cases/conformance/statements/breakStatements/invalidDoWhileBreakStatements.ts index 7c93553a726..d164691db68 100644 --- a/tests/cases/conformance/statements/breakStatements/invalidDoWhileBreakStatements.ts +++ b/tests/cases/conformance/statements/breakStatements/invalidDoWhileBreakStatements.ts @@ -1,3 +1,6 @@ +// @allowUnusedLabels: true +// @allowUnreachableCode: true + // All errors // naked break not allowed diff --git a/tests/cases/conformance/statements/breakStatements/invalidForBreakStatements.ts b/tests/cases/conformance/statements/breakStatements/invalidForBreakStatements.ts index cc21818b80f..142a8f8b3b5 100644 --- a/tests/cases/conformance/statements/breakStatements/invalidForBreakStatements.ts +++ b/tests/cases/conformance/statements/breakStatements/invalidForBreakStatements.ts @@ -1,3 +1,6 @@ +// @allowUnusedLabels: true +// @allowUnreachableCode: true + // All errors // naked break not allowed diff --git a/tests/cases/conformance/statements/breakStatements/invalidForInBreakStatements.ts b/tests/cases/conformance/statements/breakStatements/invalidForInBreakStatements.ts index 9cda003e6f5..db49a13c8f7 100644 --- a/tests/cases/conformance/statements/breakStatements/invalidForInBreakStatements.ts +++ b/tests/cases/conformance/statements/breakStatements/invalidForInBreakStatements.ts @@ -1,3 +1,6 @@ +// @allowUnusedLabels: true +// @allowUnreachableCode: true + // All errors // naked break not allowed diff --git a/tests/cases/conformance/statements/breakStatements/whileBreakStatements.ts b/tests/cases/conformance/statements/breakStatements/whileBreakStatements.ts index c471e6552b9..e2a836b62a3 100644 --- a/tests/cases/conformance/statements/breakStatements/whileBreakStatements.ts +++ b/tests/cases/conformance/statements/breakStatements/whileBreakStatements.ts @@ -1,3 +1,6 @@ +// @allowUnusedLabels: true +// @allowUnreachableCode: true + while(true) { break; } diff --git a/tests/cases/conformance/statements/continueStatements/doWhileContinueStatements.ts b/tests/cases/conformance/statements/continueStatements/doWhileContinueStatements.ts index d3d999ccb49..4685cc9f046 100644 --- a/tests/cases/conformance/statements/continueStatements/doWhileContinueStatements.ts +++ b/tests/cases/conformance/statements/continueStatements/doWhileContinueStatements.ts @@ -1,3 +1,5 @@ +// @allowUnreachableCode: true + do { continue; } while(true) diff --git a/tests/cases/conformance/statements/continueStatements/forContinueStatements.ts b/tests/cases/conformance/statements/continueStatements/forContinueStatements.ts index 1f8a3fc7b68..9b852df80c7 100644 --- a/tests/cases/conformance/statements/continueStatements/forContinueStatements.ts +++ b/tests/cases/conformance/statements/continueStatements/forContinueStatements.ts @@ -1,3 +1,5 @@ +// @allowUnreachableCode: true + for (; ;) { continue; } diff --git a/tests/cases/conformance/statements/continueStatements/forInContinueStatements.ts b/tests/cases/conformance/statements/continueStatements/forInContinueStatements.ts index 863caec2ccf..b5ccd8189ca 100644 --- a/tests/cases/conformance/statements/continueStatements/forInContinueStatements.ts +++ b/tests/cases/conformance/statements/continueStatements/forInContinueStatements.ts @@ -1,3 +1,5 @@ +// @allowUnusedLabels: true + for(var x in {}) { continue; } diff --git a/tests/cases/conformance/statements/continueStatements/invalidDoWhileContinueStatements.ts b/tests/cases/conformance/statements/continueStatements/invalidDoWhileContinueStatements.ts index 54192212ef7..dcf543ed7e3 100644 --- a/tests/cases/conformance/statements/continueStatements/invalidDoWhileContinueStatements.ts +++ b/tests/cases/conformance/statements/continueStatements/invalidDoWhileContinueStatements.ts @@ -1,3 +1,6 @@ +// @allowUnusedLabels: true +// @allowUnreachableCode: true + // All errors // naked continue not allowed diff --git a/tests/cases/conformance/statements/continueStatements/invalidForContinueStatements.ts b/tests/cases/conformance/statements/continueStatements/invalidForContinueStatements.ts index 751cd9477ad..ba367ef87b7 100644 --- a/tests/cases/conformance/statements/continueStatements/invalidForContinueStatements.ts +++ b/tests/cases/conformance/statements/continueStatements/invalidForContinueStatements.ts @@ -1,3 +1,6 @@ +// @allowUnusedLabels: true +// @allowUnreachableCode: true + // All errors // naked continue not allowed diff --git a/tests/cases/conformance/statements/continueStatements/invalidForInContinueStatements.ts b/tests/cases/conformance/statements/continueStatements/invalidForInContinueStatements.ts index be274005961..861d7e90629 100644 --- a/tests/cases/conformance/statements/continueStatements/invalidForInContinueStatements.ts +++ b/tests/cases/conformance/statements/continueStatements/invalidForInContinueStatements.ts @@ -1,3 +1,6 @@ +// @allowUnusedLabels: true +// @allowUnreachableCode: true + // All errors // naked continue not allowed diff --git a/tests/cases/conformance/statements/continueStatements/invalidWhileContinueStatements.ts b/tests/cases/conformance/statements/continueStatements/invalidWhileContinueStatements.ts index cf913671315..ef94466ffba 100644 --- a/tests/cases/conformance/statements/continueStatements/invalidWhileContinueStatements.ts +++ b/tests/cases/conformance/statements/continueStatements/invalidWhileContinueStatements.ts @@ -1,3 +1,6 @@ +// @allowUnusedLabels: true +// @allowUnreachableCode: true + // All errors // naked continue not allowed diff --git a/tests/cases/conformance/statements/forStatements/forStatements.ts b/tests/cases/conformance/statements/forStatements/forStatements.ts index 567c49c1098..1e65bdc2932 100644 --- a/tests/cases/conformance/statements/forStatements/forStatements.ts +++ b/tests/cases/conformance/statements/forStatements/forStatements.ts @@ -1,3 +1,5 @@ +// @allowUnreachableCode: true + interface I { id: number; } diff --git a/tests/cases/conformance/statements/forStatements/forStatementsMultipleInvalidDecl.ts b/tests/cases/conformance/statements/forStatements/forStatementsMultipleInvalidDecl.ts index 0c2bb3d40dc..64317b23336 100644 --- a/tests/cases/conformance/statements/forStatements/forStatementsMultipleInvalidDecl.ts +++ b/tests/cases/conformance/statements/forStatements/forStatementsMultipleInvalidDecl.ts @@ -1,3 +1,5 @@ +// @allowUnreachableCode: true + interface I { id: number; } diff --git a/tests/cases/conformance/statements/forStatements/forStatementsMultipleValidDecl.ts b/tests/cases/conformance/statements/forStatements/forStatementsMultipleValidDecl.ts index 9f5557e7756..af19fd404df 100644 --- a/tests/cases/conformance/statements/forStatements/forStatementsMultipleValidDecl.ts +++ b/tests/cases/conformance/statements/forStatements/forStatementsMultipleValidDecl.ts @@ -1,3 +1,5 @@ +// @allowUnreachableCode: true + // all expected to be valid for (var x: number; ;) { } diff --git a/tests/cases/conformance/statements/ifDoWhileStatements/ifDoWhileStatements.ts b/tests/cases/conformance/statements/ifDoWhileStatements/ifDoWhileStatements.ts index f2cd9aa43ee..03f042401d8 100644 --- a/tests/cases/conformance/statements/ifDoWhileStatements/ifDoWhileStatements.ts +++ b/tests/cases/conformance/statements/ifDoWhileStatements/ifDoWhileStatements.ts @@ -1,3 +1,5 @@ +// @allowUnreachableCode: true + interface I { id: number; } diff --git a/tests/cases/conformance/statements/throwStatements/invalidThrowStatement.ts b/tests/cases/conformance/statements/throwStatements/invalidThrowStatement.ts index aa382d4ec34..8cc294d01f7 100644 --- a/tests/cases/conformance/statements/throwStatements/invalidThrowStatement.ts +++ b/tests/cases/conformance/statements/throwStatements/invalidThrowStatement.ts @@ -1,3 +1,5 @@ +// @allowUnreachableCode: true + throw; export throw null; diff --git a/tests/cases/conformance/types/localTypes/localTypes4.ts b/tests/cases/conformance/types/localTypes/localTypes4.ts index bd31e76a80f..388d5efb637 100644 --- a/tests/cases/conformance/types/localTypes/localTypes4.ts +++ b/tests/cases/conformance/types/localTypes/localTypes4.ts @@ -1,3 +1,5 @@ +// @allowUnreachableCode: true + function f1() { // Type parameters are in scope in parameters and return types function f(x: T): T { diff --git a/tests/cases/conformance/types/namedTypes/interfaceWithPrivateMember.ts b/tests/cases/conformance/types/namedTypes/interfaceWithPrivateMember.ts index c249d2e5671..5cb52588644 100644 --- a/tests/cases/conformance/types/namedTypes/interfaceWithPrivateMember.ts +++ b/tests/cases/conformance/types/namedTypes/interfaceWithPrivateMember.ts @@ -1,3 +1,5 @@ +// @allowUnusedLabels: true + // interfaces do not permit private members, these are errors interface I { diff --git a/tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignatureWithoutReturnTypeAnnotationInference.ts b/tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignatureWithoutReturnTypeAnnotationInference.ts index 7ea4f414e15..1cc499c7d6e 100644 --- a/tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignatureWithoutReturnTypeAnnotationInference.ts +++ b/tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignatureWithoutReturnTypeAnnotationInference.ts @@ -1,3 +1,5 @@ +// @allowUnreachableCode: true + // Call signatures without a return type should infer one from the function body (if present) // Simple types diff --git a/tests/cases/conformance/types/typeRelationships/bestCommonType/functionWithMultipleReturnStatements.ts b/tests/cases/conformance/types/typeRelationships/bestCommonType/functionWithMultipleReturnStatements.ts index 9b12363ff08..9864ddab488 100644 --- a/tests/cases/conformance/types/typeRelationships/bestCommonType/functionWithMultipleReturnStatements.ts +++ b/tests/cases/conformance/types/typeRelationships/bestCommonType/functionWithMultipleReturnStatements.ts @@ -1,3 +1,5 @@ +// @allowUnreachableCode: true + // return type of a function with multiple returns is the BCT of each return statement // it is an error if there is no single BCT, these are error cases diff --git a/tests/cases/conformance/types/typeRelationships/bestCommonType/functionWithMultipleReturnStatements2.ts b/tests/cases/conformance/types/typeRelationships/bestCommonType/functionWithMultipleReturnStatements2.ts index 41d4fddfbeb..03021bfdd10 100644 --- a/tests/cases/conformance/types/typeRelationships/bestCommonType/functionWithMultipleReturnStatements2.ts +++ b/tests/cases/conformance/types/typeRelationships/bestCommonType/functionWithMultipleReturnStatements2.ts @@ -1,3 +1,5 @@ +// @allowUnreachableCode: true + // return type of a function with multiple returns is the BCT of each return statement // no errors expected here From 238e1c6f4bedfcd2dc0d64acdac58b33f665fef6 Mon Sep 17 00:00:00 2001 From: Vladimir Matveev Date: Tue, 13 Oct 2015 11:17:10 -0700 Subject: [PATCH 064/227] partially suppress reachability errors in tests --- .../reference/commentsAtEndOfFile1.errors.txt | 10 - .../reference/commentsAtEndOfFile1.js | 1 + .../reference/commentsAtEndOfFile1.symbols | 7 + .../reference/commentsAtEndOfFile1.types | 8 + .../reference/parser_breakTarget3.errors.txt | 11 - .../reference/parser_breakTarget3.js | 1 + .../reference/parser_breakTarget3.symbols | 8 + .../reference/parser_breakTarget3.types | 14 + .../reference/parser_breakTarget4.errors.txt | 11 - .../reference/parser_breakTarget4.js | 1 + .../reference/parser_breakTarget4.symbols | 8 + .../reference/parser_breakTarget4.types | 14 + .../parser_continueTarget3.errors.txt | 11 - .../reference/parser_continueTarget3.js | 1 + .../reference/parser_continueTarget3.symbols | 8 + .../reference/parser_continueTarget3.types | 14 + .../parser_continueTarget4.errors.txt | 11 - .../reference/parser_continueTarget4.js | 1 + .../reference/parser_continueTarget4.symbols | 8 + .../reference/parser_continueTarget4.types | 14 + .../parser_duplicateLabel3.errors.txt | 17 -- .../reference/parser_duplicateLabel3.js | 1 + .../reference/parser_duplicateLabel3.symbols | 12 + .../reference/parser_duplicateLabel3.types | 19 ++ .../parser_duplicateLabel4.errors.txt | 16 -- .../reference/parser_duplicateLabel4.js | 1 + .../reference/parser_duplicateLabel4.symbols | 10 + .../reference/parser_duplicateLabel4.types | 15 + .../reference/recursiveMods.errors.txt | 29 -- tests/baselines/reference/recursiveMods.js | 1 + .../baselines/reference/recursiveMods.symbols | 48 ++++ tests/baselines/reference/recursiveMods.types | 54 ++++ .../reference/returnStatement1.errors.txt | 12 - tests/baselines/reference/returnStatement1.js | 1 + .../reference/returnStatement1.symbols | 15 + .../reference/returnStatement1.types | 18 ++ .../sourceMapValidationLabeled.errors.txt | 8 - .../reference/sourceMapValidationLabeled.js | 1 + .../sourceMapValidationLabeled.js.map | 2 +- .../sourceMapValidationLabeled.sourcemap.txt | 19 +- .../sourceMapValidationLabeled.symbols | 6 + .../sourceMapValidationLabeled.types | 9 + .../switchBreakStatements.errors.txt | 67 ----- .../reference/switchBreakStatements.js | 1 + .../reference/switchBreakStatements.symbols | 59 ++++ .../reference/switchBreakStatements.types | 127 +++++++++ .../reference/systemModule8.errors.txt | 36 --- .../baselines/reference/systemModule8.symbols | 92 ++++++ tests/baselines/reference/systemModule8.types | 143 ++++++++++ .../throwInEnclosingStatements.errors.txt | 52 ---- .../reference/throwInEnclosingStatements.js | 1 + .../throwInEnclosingStatements.symbols | 94 ++++++ .../throwInEnclosingStatements.types | 110 ++++++++ .../reference/throwStatements.errors.txt | 91 ------ tests/baselines/reference/throwStatements.js | 1 + .../reference/throwStatements.symbols | 216 ++++++++++++++ .../baselines/reference/throwStatements.types | 267 ++++++++++++++++++ .../typeofOperatorWithBooleanType.errors.txt | 59 ---- .../typeofOperatorWithBooleanType.js | 1 + .../typeofOperatorWithBooleanType.symbols | 131 +++++++++ .../typeofOperatorWithBooleanType.types | 177 ++++++++++++ .../typeofOperatorWithEnumType.errors.txt | 33 --- .../reference/typeofOperatorWithEnumType.js | 1 + .../typeofOperatorWithEnumType.symbols | 70 +++++ .../typeofOperatorWithEnumType.types | 99 +++++++ tests/cases/compiler/commentsAtEndOfFile1.ts | 2 + tests/cases/compiler/recursiveMods.ts | 4 +- tests/cases/compiler/returnStatement1.ts | 2 + .../compiler/sourceMapValidationLabeled.ts | 2 + tests/cases/compiler/systemModule8.ts | 1 + .../typeofOperatorWithBooleanType.ts | 2 + .../typeofOperatorWithEnumType.ts | 2 + .../BreakStatements/parser_breakTarget3.ts | 2 + .../BreakStatements/parser_breakTarget4.ts | 2 + .../parser_continueTarget3.ts | 2 + .../parser_continueTarget4.ts | 2 + .../parser_duplicateLabel3.ts | 2 + .../parser_duplicateLabel4.ts | 3 + .../breakStatements/switchBreakStatements.ts | 3 + .../throwInEnclosingStatements.ts | 2 + .../throwStatements/throwStatements.ts | 2 + 81 files changed, 1954 insertions(+), 485 deletions(-) delete mode 100644 tests/baselines/reference/commentsAtEndOfFile1.errors.txt create mode 100644 tests/baselines/reference/commentsAtEndOfFile1.symbols create mode 100644 tests/baselines/reference/commentsAtEndOfFile1.types delete mode 100644 tests/baselines/reference/parser_breakTarget3.errors.txt create mode 100644 tests/baselines/reference/parser_breakTarget3.symbols create mode 100644 tests/baselines/reference/parser_breakTarget3.types delete mode 100644 tests/baselines/reference/parser_breakTarget4.errors.txt create mode 100644 tests/baselines/reference/parser_breakTarget4.symbols create mode 100644 tests/baselines/reference/parser_breakTarget4.types delete mode 100644 tests/baselines/reference/parser_continueTarget3.errors.txt create mode 100644 tests/baselines/reference/parser_continueTarget3.symbols create mode 100644 tests/baselines/reference/parser_continueTarget3.types delete mode 100644 tests/baselines/reference/parser_continueTarget4.errors.txt create mode 100644 tests/baselines/reference/parser_continueTarget4.symbols create mode 100644 tests/baselines/reference/parser_continueTarget4.types delete mode 100644 tests/baselines/reference/parser_duplicateLabel3.errors.txt create mode 100644 tests/baselines/reference/parser_duplicateLabel3.symbols create mode 100644 tests/baselines/reference/parser_duplicateLabel3.types delete mode 100644 tests/baselines/reference/parser_duplicateLabel4.errors.txt create mode 100644 tests/baselines/reference/parser_duplicateLabel4.symbols create mode 100644 tests/baselines/reference/parser_duplicateLabel4.types delete mode 100644 tests/baselines/reference/recursiveMods.errors.txt create mode 100644 tests/baselines/reference/recursiveMods.symbols create mode 100644 tests/baselines/reference/recursiveMods.types delete mode 100644 tests/baselines/reference/returnStatement1.errors.txt create mode 100644 tests/baselines/reference/returnStatement1.symbols create mode 100644 tests/baselines/reference/returnStatement1.types delete mode 100644 tests/baselines/reference/sourceMapValidationLabeled.errors.txt create mode 100644 tests/baselines/reference/sourceMapValidationLabeled.symbols create mode 100644 tests/baselines/reference/sourceMapValidationLabeled.types delete mode 100644 tests/baselines/reference/switchBreakStatements.errors.txt create mode 100644 tests/baselines/reference/switchBreakStatements.symbols create mode 100644 tests/baselines/reference/switchBreakStatements.types delete mode 100644 tests/baselines/reference/systemModule8.errors.txt create mode 100644 tests/baselines/reference/systemModule8.symbols create mode 100644 tests/baselines/reference/systemModule8.types delete mode 100644 tests/baselines/reference/throwInEnclosingStatements.errors.txt create mode 100644 tests/baselines/reference/throwInEnclosingStatements.symbols create mode 100644 tests/baselines/reference/throwInEnclosingStatements.types delete mode 100644 tests/baselines/reference/throwStatements.errors.txt create mode 100644 tests/baselines/reference/throwStatements.symbols create mode 100644 tests/baselines/reference/throwStatements.types delete mode 100644 tests/baselines/reference/typeofOperatorWithBooleanType.errors.txt create mode 100644 tests/baselines/reference/typeofOperatorWithBooleanType.symbols create mode 100644 tests/baselines/reference/typeofOperatorWithBooleanType.types delete mode 100644 tests/baselines/reference/typeofOperatorWithEnumType.errors.txt create mode 100644 tests/baselines/reference/typeofOperatorWithEnumType.symbols create mode 100644 tests/baselines/reference/typeofOperatorWithEnumType.types diff --git a/tests/baselines/reference/commentsAtEndOfFile1.errors.txt b/tests/baselines/reference/commentsAtEndOfFile1.errors.txt deleted file mode 100644 index dd689841659..00000000000 --- a/tests/baselines/reference/commentsAtEndOfFile1.errors.txt +++ /dev/null @@ -1,10 +0,0 @@ -tests/cases/compiler/commentsAtEndOfFile1.ts(1,1): error TS7028: Unused label. - - -==== tests/cases/compiler/commentsAtEndOfFile1.ts (1 errors) ==== - Input: - ~~~~~ -!!! error TS7028: Unused label. - ; - //Testing two - \ No newline at end of file diff --git a/tests/baselines/reference/commentsAtEndOfFile1.js b/tests/baselines/reference/commentsAtEndOfFile1.js index 2d4dae39e6b..d93dded59b0 100644 --- a/tests/baselines/reference/commentsAtEndOfFile1.js +++ b/tests/baselines/reference/commentsAtEndOfFile1.js @@ -1,4 +1,5 @@ //// [commentsAtEndOfFile1.ts] + Input: ; //Testing two diff --git a/tests/baselines/reference/commentsAtEndOfFile1.symbols b/tests/baselines/reference/commentsAtEndOfFile1.symbols new file mode 100644 index 00000000000..d35b4f251f6 --- /dev/null +++ b/tests/baselines/reference/commentsAtEndOfFile1.symbols @@ -0,0 +1,7 @@ +=== tests/cases/compiler/commentsAtEndOfFile1.ts === + +No type information for this code.Input: +No type information for this code.; +No type information for this code.//Testing two +No type information for this code. +No type information for this code. \ No newline at end of file diff --git a/tests/baselines/reference/commentsAtEndOfFile1.types b/tests/baselines/reference/commentsAtEndOfFile1.types new file mode 100644 index 00000000000..71eb367738b --- /dev/null +++ b/tests/baselines/reference/commentsAtEndOfFile1.types @@ -0,0 +1,8 @@ +=== tests/cases/compiler/commentsAtEndOfFile1.ts === + +Input: +>Input : any + +; +//Testing two + diff --git a/tests/baselines/reference/parser_breakTarget3.errors.txt b/tests/baselines/reference/parser_breakTarget3.errors.txt deleted file mode 100644 index ad3123eda79..00000000000 --- a/tests/baselines/reference/parser_breakTarget3.errors.txt +++ /dev/null @@ -1,11 +0,0 @@ -tests/cases/conformance/parser/ecmascript5/Statements/BreakStatements/parser_breakTarget3.ts(2,1): error TS7028: Unused label. - - -==== tests/cases/conformance/parser/ecmascript5/Statements/BreakStatements/parser_breakTarget3.ts (1 errors) ==== - target1: - target2: - ~~~~~~~ -!!! error TS7028: Unused label. - while (true) { - break target1; - } \ No newline at end of file diff --git a/tests/baselines/reference/parser_breakTarget3.js b/tests/baselines/reference/parser_breakTarget3.js index 0eceba87bf8..91ba9fb5993 100644 --- a/tests/baselines/reference/parser_breakTarget3.js +++ b/tests/baselines/reference/parser_breakTarget3.js @@ -1,4 +1,5 @@ //// [parser_breakTarget3.ts] + target1: target2: while (true) { diff --git a/tests/baselines/reference/parser_breakTarget3.symbols b/tests/baselines/reference/parser_breakTarget3.symbols new file mode 100644 index 00000000000..35184471d4d --- /dev/null +++ b/tests/baselines/reference/parser_breakTarget3.symbols @@ -0,0 +1,8 @@ +=== tests/cases/conformance/parser/ecmascript5/Statements/BreakStatements/parser_breakTarget3.ts === + +No type information for this code.target1: +No type information for this code.target2: +No type information for this code.while (true) { +No type information for this code. break target1; +No type information for this code.} +No type information for this code. \ No newline at end of file diff --git a/tests/baselines/reference/parser_breakTarget3.types b/tests/baselines/reference/parser_breakTarget3.types new file mode 100644 index 00000000000..b1ce9f8d94d --- /dev/null +++ b/tests/baselines/reference/parser_breakTarget3.types @@ -0,0 +1,14 @@ +=== tests/cases/conformance/parser/ecmascript5/Statements/BreakStatements/parser_breakTarget3.ts === + +target1: +>target1 : any + +target2: +>target2 : any + +while (true) { +>true : boolean + + break target1; +>target1 : any +} diff --git a/tests/baselines/reference/parser_breakTarget4.errors.txt b/tests/baselines/reference/parser_breakTarget4.errors.txt deleted file mode 100644 index 8c61b20b0ed..00000000000 --- a/tests/baselines/reference/parser_breakTarget4.errors.txt +++ /dev/null @@ -1,11 +0,0 @@ -tests/cases/conformance/parser/ecmascript5/Statements/BreakStatements/parser_breakTarget4.ts(1,1): error TS7028: Unused label. - - -==== tests/cases/conformance/parser/ecmascript5/Statements/BreakStatements/parser_breakTarget4.ts (1 errors) ==== - target1: - ~~~~~~~ -!!! error TS7028: Unused label. - target2: - while (true) { - break target2; - } \ No newline at end of file diff --git a/tests/baselines/reference/parser_breakTarget4.js b/tests/baselines/reference/parser_breakTarget4.js index c6cadb5efa1..4516cf3e8f9 100644 --- a/tests/baselines/reference/parser_breakTarget4.js +++ b/tests/baselines/reference/parser_breakTarget4.js @@ -1,4 +1,5 @@ //// [parser_breakTarget4.ts] + target1: target2: while (true) { diff --git a/tests/baselines/reference/parser_breakTarget4.symbols b/tests/baselines/reference/parser_breakTarget4.symbols new file mode 100644 index 00000000000..f4d4b2e4bff --- /dev/null +++ b/tests/baselines/reference/parser_breakTarget4.symbols @@ -0,0 +1,8 @@ +=== tests/cases/conformance/parser/ecmascript5/Statements/BreakStatements/parser_breakTarget4.ts === + +No type information for this code.target1: +No type information for this code.target2: +No type information for this code.while (true) { +No type information for this code. break target2; +No type information for this code.} +No type information for this code. \ No newline at end of file diff --git a/tests/baselines/reference/parser_breakTarget4.types b/tests/baselines/reference/parser_breakTarget4.types new file mode 100644 index 00000000000..04bb129c919 --- /dev/null +++ b/tests/baselines/reference/parser_breakTarget4.types @@ -0,0 +1,14 @@ +=== tests/cases/conformance/parser/ecmascript5/Statements/BreakStatements/parser_breakTarget4.ts === + +target1: +>target1 : any + +target2: +>target2 : any + +while (true) { +>true : boolean + + break target2; +>target2 : any +} diff --git a/tests/baselines/reference/parser_continueTarget3.errors.txt b/tests/baselines/reference/parser_continueTarget3.errors.txt deleted file mode 100644 index 4871cb275e7..00000000000 --- a/tests/baselines/reference/parser_continueTarget3.errors.txt +++ /dev/null @@ -1,11 +0,0 @@ -tests/cases/conformance/parser/ecmascript5/Statements/ContinueStatements/parser_continueTarget3.ts(2,1): error TS7028: Unused label. - - -==== tests/cases/conformance/parser/ecmascript5/Statements/ContinueStatements/parser_continueTarget3.ts (1 errors) ==== - target1: - target2: - ~~~~~~~ -!!! error TS7028: Unused label. - while (true) { - continue target1; - } \ No newline at end of file diff --git a/tests/baselines/reference/parser_continueTarget3.js b/tests/baselines/reference/parser_continueTarget3.js index 76a98a0e204..ea1559346de 100644 --- a/tests/baselines/reference/parser_continueTarget3.js +++ b/tests/baselines/reference/parser_continueTarget3.js @@ -1,4 +1,5 @@ //// [parser_continueTarget3.ts] + target1: target2: while (true) { diff --git a/tests/baselines/reference/parser_continueTarget3.symbols b/tests/baselines/reference/parser_continueTarget3.symbols new file mode 100644 index 00000000000..c522444ca1a --- /dev/null +++ b/tests/baselines/reference/parser_continueTarget3.symbols @@ -0,0 +1,8 @@ +=== tests/cases/conformance/parser/ecmascript5/Statements/ContinueStatements/parser_continueTarget3.ts === + +No type information for this code.target1: +No type information for this code.target2: +No type information for this code.while (true) { +No type information for this code. continue target1; +No type information for this code.} +No type information for this code. \ No newline at end of file diff --git a/tests/baselines/reference/parser_continueTarget3.types b/tests/baselines/reference/parser_continueTarget3.types new file mode 100644 index 00000000000..fd8aedc357f --- /dev/null +++ b/tests/baselines/reference/parser_continueTarget3.types @@ -0,0 +1,14 @@ +=== tests/cases/conformance/parser/ecmascript5/Statements/ContinueStatements/parser_continueTarget3.ts === + +target1: +>target1 : any + +target2: +>target2 : any + +while (true) { +>true : boolean + + continue target1; +>target1 : any +} diff --git a/tests/baselines/reference/parser_continueTarget4.errors.txt b/tests/baselines/reference/parser_continueTarget4.errors.txt deleted file mode 100644 index 6089ea60cf7..00000000000 --- a/tests/baselines/reference/parser_continueTarget4.errors.txt +++ /dev/null @@ -1,11 +0,0 @@ -tests/cases/conformance/parser/ecmascript5/Statements/ContinueStatements/parser_continueTarget4.ts(1,1): error TS7028: Unused label. - - -==== tests/cases/conformance/parser/ecmascript5/Statements/ContinueStatements/parser_continueTarget4.ts (1 errors) ==== - target1: - ~~~~~~~ -!!! error TS7028: Unused label. - target2: - while (true) { - continue target2; - } \ No newline at end of file diff --git a/tests/baselines/reference/parser_continueTarget4.js b/tests/baselines/reference/parser_continueTarget4.js index 795cab2e2ad..9ccaaac27e7 100644 --- a/tests/baselines/reference/parser_continueTarget4.js +++ b/tests/baselines/reference/parser_continueTarget4.js @@ -1,4 +1,5 @@ //// [parser_continueTarget4.ts] + target1: target2: while (true) { diff --git a/tests/baselines/reference/parser_continueTarget4.symbols b/tests/baselines/reference/parser_continueTarget4.symbols new file mode 100644 index 00000000000..b7e770f9bf9 --- /dev/null +++ b/tests/baselines/reference/parser_continueTarget4.symbols @@ -0,0 +1,8 @@ +=== tests/cases/conformance/parser/ecmascript5/Statements/ContinueStatements/parser_continueTarget4.ts === + +No type information for this code.target1: +No type information for this code.target2: +No type information for this code.while (true) { +No type information for this code. continue target2; +No type information for this code.} +No type information for this code. \ No newline at end of file diff --git a/tests/baselines/reference/parser_continueTarget4.types b/tests/baselines/reference/parser_continueTarget4.types new file mode 100644 index 00000000000..be1e5458f4b --- /dev/null +++ b/tests/baselines/reference/parser_continueTarget4.types @@ -0,0 +1,14 @@ +=== tests/cases/conformance/parser/ecmascript5/Statements/ContinueStatements/parser_continueTarget4.ts === + +target1: +>target1 : any + +target2: +>target2 : any + +while (true) { +>true : boolean + + continue target2; +>target2 : any +} diff --git a/tests/baselines/reference/parser_duplicateLabel3.errors.txt b/tests/baselines/reference/parser_duplicateLabel3.errors.txt deleted file mode 100644 index a933588f538..00000000000 --- a/tests/baselines/reference/parser_duplicateLabel3.errors.txt +++ /dev/null @@ -1,17 +0,0 @@ -tests/cases/conformance/parser/ecmascript5/Statements/LabeledStatements/parser_duplicateLabel3.ts(1,1): error TS7028: Unused label. -tests/cases/conformance/parser/ecmascript5/Statements/LabeledStatements/parser_duplicateLabel3.ts(4,5): error TS7028: Unused label. - - -==== tests/cases/conformance/parser/ecmascript5/Statements/LabeledStatements/parser_duplicateLabel3.ts (2 errors) ==== - target: - ~~~~~~ -!!! error TS7028: Unused label. - while (true) { - function f() { - target: - ~~~~~~ -!!! error TS7028: Unused label. - while (true) { - } - } - } \ No newline at end of file diff --git a/tests/baselines/reference/parser_duplicateLabel3.js b/tests/baselines/reference/parser_duplicateLabel3.js index 9bd6c56356a..c2ea2769f18 100644 --- a/tests/baselines/reference/parser_duplicateLabel3.js +++ b/tests/baselines/reference/parser_duplicateLabel3.js @@ -1,4 +1,5 @@ //// [parser_duplicateLabel3.ts] + target: while (true) { function f() { diff --git a/tests/baselines/reference/parser_duplicateLabel3.symbols b/tests/baselines/reference/parser_duplicateLabel3.symbols new file mode 100644 index 00000000000..7e238eb2916 --- /dev/null +++ b/tests/baselines/reference/parser_duplicateLabel3.symbols @@ -0,0 +1,12 @@ +=== tests/cases/conformance/parser/ecmascript5/Statements/LabeledStatements/parser_duplicateLabel3.ts === + +target: +while (true) { + function f() { +>f : Symbol(f, Decl(parser_duplicateLabel3.ts, 2, 14)) + + target: + while (true) { + } + } +} diff --git a/tests/baselines/reference/parser_duplicateLabel3.types b/tests/baselines/reference/parser_duplicateLabel3.types new file mode 100644 index 00000000000..88ea435bf3e --- /dev/null +++ b/tests/baselines/reference/parser_duplicateLabel3.types @@ -0,0 +1,19 @@ +=== tests/cases/conformance/parser/ecmascript5/Statements/LabeledStatements/parser_duplicateLabel3.ts === + +target: +>target : any + +while (true) { +>true : boolean + + function f() { +>f : () => void + + target: +>target : any + + while (true) { +>true : boolean + } + } +} diff --git a/tests/baselines/reference/parser_duplicateLabel4.errors.txt b/tests/baselines/reference/parser_duplicateLabel4.errors.txt deleted file mode 100644 index 4a0108ebe06..00000000000 --- a/tests/baselines/reference/parser_duplicateLabel4.errors.txt +++ /dev/null @@ -1,16 +0,0 @@ -tests/cases/conformance/parser/ecmascript5/Statements/LabeledStatements/parser_duplicateLabel4.ts(1,1): error TS7028: Unused label. -tests/cases/conformance/parser/ecmascript5/Statements/LabeledStatements/parser_duplicateLabel4.ts(5,1): error TS7027: Unreachable code detected. - - -==== tests/cases/conformance/parser/ecmascript5/Statements/LabeledStatements/parser_duplicateLabel4.ts (2 errors) ==== - target: - ~~~~~~ -!!! error TS7028: Unused label. - while (true) { - } - - target: - ~~~~~~ -!!! error TS7027: Unreachable code detected. - while (true) { - } \ No newline at end of file diff --git a/tests/baselines/reference/parser_duplicateLabel4.js b/tests/baselines/reference/parser_duplicateLabel4.js index 569a9bcd102..a9491314426 100644 --- a/tests/baselines/reference/parser_duplicateLabel4.js +++ b/tests/baselines/reference/parser_duplicateLabel4.js @@ -1,4 +1,5 @@ //// [parser_duplicateLabel4.ts] + target: while (true) { } diff --git a/tests/baselines/reference/parser_duplicateLabel4.symbols b/tests/baselines/reference/parser_duplicateLabel4.symbols new file mode 100644 index 00000000000..e7123de1600 --- /dev/null +++ b/tests/baselines/reference/parser_duplicateLabel4.symbols @@ -0,0 +1,10 @@ +=== tests/cases/conformance/parser/ecmascript5/Statements/LabeledStatements/parser_duplicateLabel4.ts === + +No type information for this code.target: +No type information for this code.while (true) { +No type information for this code.} +No type information for this code. +No type information for this code.target: +No type information for this code.while (true) { +No type information for this code.} +No type information for this code. \ No newline at end of file diff --git a/tests/baselines/reference/parser_duplicateLabel4.types b/tests/baselines/reference/parser_duplicateLabel4.types new file mode 100644 index 00000000000..b70dd12c695 --- /dev/null +++ b/tests/baselines/reference/parser_duplicateLabel4.types @@ -0,0 +1,15 @@ +=== tests/cases/conformance/parser/ecmascript5/Statements/LabeledStatements/parser_duplicateLabel4.ts === + +target: +>target : any + +while (true) { +>true : boolean +} + +target: +>target : any + +while (true) { +>true : boolean +} diff --git a/tests/baselines/reference/recursiveMods.errors.txt b/tests/baselines/reference/recursiveMods.errors.txt deleted file mode 100644 index 6adba78d004..00000000000 --- a/tests/baselines/reference/recursiveMods.errors.txt +++ /dev/null @@ -1,29 +0,0 @@ -tests/cases/compiler/recursiveMods.ts(9,3): error TS7027: Unreachable code detected. - - -==== tests/cases/compiler/recursiveMods.ts (1 errors) ==== - export module Foo { - export class C {} - } - - export module Foo { - - function Bar() : C { - if (true) { return Bar();} - return new C(); - ~~~~~~ -!!! error TS7027: Unreachable code detected. - } - - function Baz() : C { - var c = Baz(); - return Bar(); - } - - function Gar() { - var c : C = Baz(); - return; - } - - } - \ No newline at end of file diff --git a/tests/baselines/reference/recursiveMods.js b/tests/baselines/reference/recursiveMods.js index 36d2712e040..f913ddec012 100644 --- a/tests/baselines/reference/recursiveMods.js +++ b/tests/baselines/reference/recursiveMods.js @@ -1,4 +1,5 @@ //// [recursiveMods.ts] + export module Foo { export class C {} } diff --git a/tests/baselines/reference/recursiveMods.symbols b/tests/baselines/reference/recursiveMods.symbols new file mode 100644 index 00000000000..5f6d6f87721 --- /dev/null +++ b/tests/baselines/reference/recursiveMods.symbols @@ -0,0 +1,48 @@ +=== tests/cases/compiler/recursiveMods.ts === + +export module Foo { +>Foo : Symbol(Foo, Decl(recursiveMods.ts, 0, 0), Decl(recursiveMods.ts, 3, 1)) + + export class C {} +>C : Symbol(C, Decl(recursiveMods.ts, 1, 19)) +} + +export module Foo { +>Foo : Symbol(Foo, Decl(recursiveMods.ts, 0, 0), Decl(recursiveMods.ts, 3, 1)) + + function Bar() : C { +>Bar : Symbol(Bar, Decl(recursiveMods.ts, 5, 19)) +>C : Symbol(C, Decl(recursiveMods.ts, 1, 19)) + + if (true) { return Bar();} +>Bar : Symbol(Bar, Decl(recursiveMods.ts, 5, 19)) + + return new C(); +>C : Symbol(C, Decl(recursiveMods.ts, 1, 19)) + } + + function Baz() : C { +>Baz : Symbol(Baz, Decl(recursiveMods.ts, 10, 2)) +>C : Symbol(C, Decl(recursiveMods.ts, 1, 19)) + + var c = Baz(); +>c : Symbol(c, Decl(recursiveMods.ts, 13, 5)) +>Baz : Symbol(Baz, Decl(recursiveMods.ts, 10, 2)) + + return Bar(); +>Bar : Symbol(Bar, Decl(recursiveMods.ts, 5, 19)) + } + + function Gar() { +>Gar : Symbol(Gar, Decl(recursiveMods.ts, 15, 2)) + + var c : C = Baz(); +>c : Symbol(c, Decl(recursiveMods.ts, 18, 5)) +>C : Symbol(C, Decl(recursiveMods.ts, 1, 19)) +>Baz : Symbol(Baz, Decl(recursiveMods.ts, 10, 2)) + + return; + } + +} + diff --git a/tests/baselines/reference/recursiveMods.types b/tests/baselines/reference/recursiveMods.types new file mode 100644 index 00000000000..d4db816daf7 --- /dev/null +++ b/tests/baselines/reference/recursiveMods.types @@ -0,0 +1,54 @@ +=== tests/cases/compiler/recursiveMods.ts === + +export module Foo { +>Foo : typeof Foo + + export class C {} +>C : C +} + +export module Foo { +>Foo : typeof Foo + + function Bar() : C { +>Bar : () => C +>C : C + + if (true) { return Bar();} +>true : boolean +>Bar() : C +>Bar : () => C + + return new C(); +>new C() : C +>C : typeof C + } + + function Baz() : C { +>Baz : () => C +>C : C + + var c = Baz(); +>c : C +>Baz() : C +>Baz : () => C + + return Bar(); +>Bar() : C +>Bar : () => C + } + + function Gar() { +>Gar : () => void + + var c : C = Baz(); +>c : C +>C : C +>Baz() : C +>Baz : () => C + + return; + } + +} + diff --git a/tests/baselines/reference/returnStatement1.errors.txt b/tests/baselines/reference/returnStatement1.errors.txt deleted file mode 100644 index af17564a874..00000000000 --- a/tests/baselines/reference/returnStatement1.errors.txt +++ /dev/null @@ -1,12 +0,0 @@ -tests/cases/compiler/returnStatement1.ts(5,5): error TS7027: Unreachable code detected. - - -==== tests/cases/compiler/returnStatement1.ts (1 errors) ==== - function f() { - return function (s) { - var x = s; - }; - ("harmless extra line"); - ~ -!!! error TS7027: Unreachable code detected. - } \ No newline at end of file diff --git a/tests/baselines/reference/returnStatement1.js b/tests/baselines/reference/returnStatement1.js index c4ccc3cadde..3f5c5561b2a 100644 --- a/tests/baselines/reference/returnStatement1.js +++ b/tests/baselines/reference/returnStatement1.js @@ -1,4 +1,5 @@ //// [returnStatement1.ts] + function f() { return function (s) { var x = s; diff --git a/tests/baselines/reference/returnStatement1.symbols b/tests/baselines/reference/returnStatement1.symbols new file mode 100644 index 00000000000..6727cba0df5 --- /dev/null +++ b/tests/baselines/reference/returnStatement1.symbols @@ -0,0 +1,15 @@ +=== tests/cases/compiler/returnStatement1.ts === + +function f() { +>f : Symbol(f, Decl(returnStatement1.ts, 0, 0)) + + return function (s) { +>s : Symbol(s, Decl(returnStatement1.ts, 2, 21)) + + var x = s; +>x : Symbol(x, Decl(returnStatement1.ts, 3, 11)) +>s : Symbol(s, Decl(returnStatement1.ts, 2, 21)) + + }; + ("harmless extra line"); +} diff --git a/tests/baselines/reference/returnStatement1.types b/tests/baselines/reference/returnStatement1.types new file mode 100644 index 00000000000..b7e166ffa75 --- /dev/null +++ b/tests/baselines/reference/returnStatement1.types @@ -0,0 +1,18 @@ +=== tests/cases/compiler/returnStatement1.ts === + +function f() { +>f : () => (s: any) => void + + return function (s) { +>function (s) { var x = s; } : (s: any) => void +>s : any + + var x = s; +>x : any +>s : any + + }; + ("harmless extra line"); +>("harmless extra line") : string +>"harmless extra line" : string +} diff --git a/tests/baselines/reference/sourceMapValidationLabeled.errors.txt b/tests/baselines/reference/sourceMapValidationLabeled.errors.txt deleted file mode 100644 index e9cf1fb3db8..00000000000 --- a/tests/baselines/reference/sourceMapValidationLabeled.errors.txt +++ /dev/null @@ -1,8 +0,0 @@ -tests/cases/compiler/sourceMapValidationLabeled.ts(1,1): error TS7028: Unused label. - - -==== tests/cases/compiler/sourceMapValidationLabeled.ts (1 errors) ==== - x: - ~ -!!! error TS7028: Unused label. - var b = 10; \ No newline at end of file diff --git a/tests/baselines/reference/sourceMapValidationLabeled.js b/tests/baselines/reference/sourceMapValidationLabeled.js index 7aabc47ea4e..50669b870ab 100644 --- a/tests/baselines/reference/sourceMapValidationLabeled.js +++ b/tests/baselines/reference/sourceMapValidationLabeled.js @@ -1,4 +1,5 @@ //// [sourceMapValidationLabeled.ts] + x: var b = 10; diff --git a/tests/baselines/reference/sourceMapValidationLabeled.js.map b/tests/baselines/reference/sourceMapValidationLabeled.js.map index d1219f9896f..206ac95b951 100644 --- a/tests/baselines/reference/sourceMapValidationLabeled.js.map +++ b/tests/baselines/reference/sourceMapValidationLabeled.js.map @@ -1,2 +1,2 @@ //// [sourceMapValidationLabeled.js.map] -{"version":3,"file":"sourceMapValidationLabeled.js","sourceRoot":"","sources":["sourceMapValidationLabeled.ts"],"names":[],"mappings":"AAAA,CAAC,EACD,IAAI,CAAC,GAAG,EAAE,CAAC"} \ No newline at end of file +{"version":3,"file":"sourceMapValidationLabeled.js","sourceRoot":"","sources":["sourceMapValidationLabeled.ts"],"names":[],"mappings":"AACA,CAAC,EACD,IAAI,CAAC,GAAG,EAAE,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/sourceMapValidationLabeled.sourcemap.txt b/tests/baselines/reference/sourceMapValidationLabeled.sourcemap.txt index 007208c78f9..7cf1bf896ca 100644 --- a/tests/baselines/reference/sourceMapValidationLabeled.sourcemap.txt +++ b/tests/baselines/reference/sourceMapValidationLabeled.sourcemap.txt @@ -18,7 +18,8 @@ sourceFile:sourceMapValidationLabeled.ts 7 > ^^ 8 > ^ 9 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 > +1 > + > 2 >x 3 > : > @@ -27,13 +28,13 @@ sourceFile:sourceMapValidationLabeled.ts 6 > = 7 > 10 8 > ; -1 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) -2 >Emitted(1, 2) Source(1, 2) + SourceIndex(0) -3 >Emitted(1, 4) Source(2, 1) + SourceIndex(0) -4 >Emitted(1, 8) Source(2, 5) + SourceIndex(0) -5 >Emitted(1, 9) Source(2, 6) + SourceIndex(0) -6 >Emitted(1, 12) Source(2, 9) + SourceIndex(0) -7 >Emitted(1, 14) Source(2, 11) + SourceIndex(0) -8 >Emitted(1, 15) Source(2, 12) + SourceIndex(0) +1 >Emitted(1, 1) Source(2, 1) + SourceIndex(0) +2 >Emitted(1, 2) Source(2, 2) + SourceIndex(0) +3 >Emitted(1, 4) Source(3, 1) + SourceIndex(0) +4 >Emitted(1, 8) Source(3, 5) + SourceIndex(0) +5 >Emitted(1, 9) Source(3, 6) + SourceIndex(0) +6 >Emitted(1, 12) Source(3, 9) + SourceIndex(0) +7 >Emitted(1, 14) Source(3, 11) + SourceIndex(0) +8 >Emitted(1, 15) Source(3, 12) + SourceIndex(0) --- >>>//# sourceMappingURL=sourceMapValidationLabeled.js.map \ No newline at end of file diff --git a/tests/baselines/reference/sourceMapValidationLabeled.symbols b/tests/baselines/reference/sourceMapValidationLabeled.symbols new file mode 100644 index 00000000000..bf9abc593b3 --- /dev/null +++ b/tests/baselines/reference/sourceMapValidationLabeled.symbols @@ -0,0 +1,6 @@ +=== tests/cases/compiler/sourceMapValidationLabeled.ts === + +x: +var b = 10; +>b : Symbol(b, Decl(sourceMapValidationLabeled.ts, 2, 3)) + diff --git a/tests/baselines/reference/sourceMapValidationLabeled.types b/tests/baselines/reference/sourceMapValidationLabeled.types new file mode 100644 index 00000000000..7af624ac93b --- /dev/null +++ b/tests/baselines/reference/sourceMapValidationLabeled.types @@ -0,0 +1,9 @@ +=== tests/cases/compiler/sourceMapValidationLabeled.ts === + +x: +>x : any + +var b = 10; +>b : number +>10 : number + diff --git a/tests/baselines/reference/switchBreakStatements.errors.txt b/tests/baselines/reference/switchBreakStatements.errors.txt deleted file mode 100644 index 77577e485da..00000000000 --- a/tests/baselines/reference/switchBreakStatements.errors.txt +++ /dev/null @@ -1,67 +0,0 @@ -tests/cases/conformance/statements/breakStatements/switchBreakStatements.ts(12,1): error TS7028: Unused label. -tests/cases/conformance/statements/breakStatements/switchBreakStatements.ts(22,9): error TS7028: Unused label. -tests/cases/conformance/statements/breakStatements/switchBreakStatements.ts(46,25): error TS7027: Unreachable code detected. - - -==== tests/cases/conformance/statements/breakStatements/switchBreakStatements.ts (3 errors) ==== - switch ('') { - case 'a': - break; - } - - ONE: - switch ('') { - case 'a': - break ONE; - } - - TWO: - ~~~ -!!! error TS7028: Unused label. - THREE: - switch ('') { - case 'a': - break THREE; - } - - FOUR: - switch ('') { - case 'a': - FIVE: - ~~~~ -!!! error TS7028: Unused label. - switch ('') { - case 'a': - break FOUR; - } - } - - switch ('') { - case 'a': - SIX: - switch ('') { - case 'a': - break SIX; - } - } - - SEVEN: - switch ('') { - case 'a': - switch ('') { - case 'a': - switch ('') { - case 'a': - break SEVEN; - EIGHT: - ~~~~~ -!!! error TS7027: Unreachable code detected. - switch ('') { - case 'a': - var fn = function () { } - break EIGHT; - } - } - } - } - \ No newline at end of file diff --git a/tests/baselines/reference/switchBreakStatements.js b/tests/baselines/reference/switchBreakStatements.js index 534f025e2f5..d7fa279248c 100644 --- a/tests/baselines/reference/switchBreakStatements.js +++ b/tests/baselines/reference/switchBreakStatements.js @@ -1,4 +1,5 @@ //// [switchBreakStatements.ts] + switch ('') { case 'a': break; diff --git a/tests/baselines/reference/switchBreakStatements.symbols b/tests/baselines/reference/switchBreakStatements.symbols new file mode 100644 index 00000000000..dde7ca028cc --- /dev/null +++ b/tests/baselines/reference/switchBreakStatements.symbols @@ -0,0 +1,59 @@ +=== tests/cases/conformance/statements/breakStatements/switchBreakStatements.ts === + +switch ('') { + case 'a': + break; +} + +ONE: +switch ('') { + case 'a': + break ONE; +} + +TWO: +THREE: +switch ('') { + case 'a': + break THREE; +} + +FOUR: +switch ('') { + case 'a': + FIVE: + switch ('') { + case 'a': + break FOUR; + } +} + +switch ('') { + case 'a': + SIX: + switch ('') { + case 'a': + break SIX; + } +} + +SEVEN: +switch ('') { + case 'a': + switch ('') { + case 'a': + switch ('') { + case 'a': + break SEVEN; + EIGHT: + switch ('') { + case 'a': + var fn = function () { } +>fn : Symbol(fn, Decl(switchBreakStatements.ts, 49, 35)) + + break EIGHT; + } + } + } +} + diff --git a/tests/baselines/reference/switchBreakStatements.types b/tests/baselines/reference/switchBreakStatements.types new file mode 100644 index 00000000000..0364d878d5a --- /dev/null +++ b/tests/baselines/reference/switchBreakStatements.types @@ -0,0 +1,127 @@ +=== tests/cases/conformance/statements/breakStatements/switchBreakStatements.ts === + +switch ('') { +>'' : string + + case 'a': +>'a' : string + + break; +} + +ONE: +>ONE : any + +switch ('') { +>'' : string + + case 'a': +>'a' : string + + break ONE; +>ONE : any +} + +TWO: +>TWO : any + +THREE: +>THREE : any + +switch ('') { +>'' : string + + case 'a': +>'a' : string + + break THREE; +>THREE : any +} + +FOUR: +>FOUR : any + +switch ('') { +>'' : string + + case 'a': +>'a' : string + + FIVE: +>FIVE : any + + switch ('') { +>'' : string + + case 'a': +>'a' : string + + break FOUR; +>FOUR : any + } +} + +switch ('') { +>'' : string + + case 'a': +>'a' : string + + SIX: +>SIX : any + + switch ('') { +>'' : string + + case 'a': +>'a' : string + + break SIX; +>SIX : any + } +} + +SEVEN: +>SEVEN : any + +switch ('') { +>'' : string + + case 'a': +>'a' : string + + switch ('') { +>'' : string + + case 'a': +>'a' : string + + switch ('') { +>'' : string + + case 'a': +>'a' : string + + break SEVEN; +>SEVEN : any + + EIGHT: +>EIGHT : any + + switch ('') { +>'' : string + + case 'a': +>'a' : string + + var fn = function () { } +>fn : () => void +>function () { } : () => void + + break EIGHT; +>EIGHT : any + } + } + } +} + diff --git a/tests/baselines/reference/systemModule8.errors.txt b/tests/baselines/reference/systemModule8.errors.txt deleted file mode 100644 index 17a37e57d24..00000000000 --- a/tests/baselines/reference/systemModule8.errors.txt +++ /dev/null @@ -1,36 +0,0 @@ -tests/cases/compiler/systemModule8.ts(19,1): error TS7027: Unreachable code detected. - - -==== tests/cases/compiler/systemModule8.ts (1 errors) ==== - - export var x; - x = 1; - x++; - x--; - ++x; - --x; - x += 1; - x -= 1; - x *= 1; - x /= 1; - x |= 1; - x &= 1; - x + 1; - x - 1; - x & 1; - x | 1; - for (x = 5;;x++) {} - for (x = 8;;x--) {} - ~~~ -!!! error TS7027: Unreachable code detected. - for (x = 15;;++x) {} - for (x = 18;;--x) {} - - for (let x = 50;;) {} - function foo() { - x = 100; - } - - export let [y] = [1]; - export const {a: z0, b: {c: z1}} = {a: true, b: {c: "123"}}; - for ([x] of [[1]]) {} \ No newline at end of file diff --git a/tests/baselines/reference/systemModule8.symbols b/tests/baselines/reference/systemModule8.symbols new file mode 100644 index 00000000000..719d48e4592 --- /dev/null +++ b/tests/baselines/reference/systemModule8.symbols @@ -0,0 +1,92 @@ +=== tests/cases/compiler/systemModule8.ts === + +export var x; +>x : Symbol(x, Decl(systemModule8.ts, 1, 10)) + +x = 1; +>x : Symbol(x, Decl(systemModule8.ts, 1, 10)) + +x++; +>x : Symbol(x, Decl(systemModule8.ts, 1, 10)) + +x--; +>x : Symbol(x, Decl(systemModule8.ts, 1, 10)) + +++x; +>x : Symbol(x, Decl(systemModule8.ts, 1, 10)) + +--x; +>x : Symbol(x, Decl(systemModule8.ts, 1, 10)) + +x += 1; +>x : Symbol(x, Decl(systemModule8.ts, 1, 10)) + +x -= 1; +>x : Symbol(x, Decl(systemModule8.ts, 1, 10)) + +x *= 1; +>x : Symbol(x, Decl(systemModule8.ts, 1, 10)) + +x /= 1; +>x : Symbol(x, Decl(systemModule8.ts, 1, 10)) + +x |= 1; +>x : Symbol(x, Decl(systemModule8.ts, 1, 10)) + +x &= 1; +>x : Symbol(x, Decl(systemModule8.ts, 1, 10)) + +x + 1; +>x : Symbol(x, Decl(systemModule8.ts, 1, 10)) + +x - 1; +>x : Symbol(x, Decl(systemModule8.ts, 1, 10)) + +x & 1; +>x : Symbol(x, Decl(systemModule8.ts, 1, 10)) + +x | 1; +>x : Symbol(x, Decl(systemModule8.ts, 1, 10)) + +for (x = 5;;x++) {} +>x : Symbol(x, Decl(systemModule8.ts, 1, 10)) +>x : Symbol(x, Decl(systemModule8.ts, 1, 10)) + +for (x = 8;;x--) {} +>x : Symbol(x, Decl(systemModule8.ts, 1, 10)) +>x : Symbol(x, Decl(systemModule8.ts, 1, 10)) + +for (x = 15;;++x) {} +>x : Symbol(x, Decl(systemModule8.ts, 1, 10)) +>x : Symbol(x, Decl(systemModule8.ts, 1, 10)) + +for (x = 18;;--x) {} +>x : Symbol(x, Decl(systemModule8.ts, 1, 10)) +>x : Symbol(x, Decl(systemModule8.ts, 1, 10)) + +for (let x = 50;;) {} +>x : Symbol(x, Decl(systemModule8.ts, 22, 8)) + +function foo() { +>foo : Symbol(foo, Decl(systemModule8.ts, 22, 21)) + + x = 100; +>x : Symbol(x, Decl(systemModule8.ts, 1, 10)) +} + +export let [y] = [1]; +>y : Symbol(y, Decl(systemModule8.ts, 27, 12)) + +export const {a: z0, b: {c: z1}} = {a: true, b: {c: "123"}}; +>a : Symbol(a, Decl(systemModule8.ts, 28, 36)) +>z0 : Symbol(z0, Decl(systemModule8.ts, 28, 14)) +>b : Symbol(b, Decl(systemModule8.ts, 28, 44)) +>c : Symbol(c, Decl(systemModule8.ts, 28, 49)) +>z1 : Symbol(z1, Decl(systemModule8.ts, 28, 25)) +>a : Symbol(a, Decl(systemModule8.ts, 28, 36)) +>b : Symbol(b, Decl(systemModule8.ts, 28, 44)) +>c : Symbol(c, Decl(systemModule8.ts, 28, 49)) + +for ([x] of [[1]]) {} +>x : Symbol(x, Decl(systemModule8.ts, 1, 10)) + diff --git a/tests/baselines/reference/systemModule8.types b/tests/baselines/reference/systemModule8.types new file mode 100644 index 00000000000..2c3dd1e48bb --- /dev/null +++ b/tests/baselines/reference/systemModule8.types @@ -0,0 +1,143 @@ +=== tests/cases/compiler/systemModule8.ts === + +export var x; +>x : any + +x = 1; +>x = 1 : number +>x : any +>1 : number + +x++; +>x++ : number +>x : any + +x--; +>x-- : number +>x : any + +++x; +>++x : number +>x : any + +--x; +>--x : number +>x : any + +x += 1; +>x += 1 : any +>x : any +>1 : number + +x -= 1; +>x -= 1 : number +>x : any +>1 : number + +x *= 1; +>x *= 1 : number +>x : any +>1 : number + +x /= 1; +>x /= 1 : number +>x : any +>1 : number + +x |= 1; +>x |= 1 : number +>x : any +>1 : number + +x &= 1; +>x &= 1 : number +>x : any +>1 : number + +x + 1; +>x + 1 : any +>x : any +>1 : number + +x - 1; +>x - 1 : number +>x : any +>1 : number + +x & 1; +>x & 1 : number +>x : any +>1 : number + +x | 1; +>x | 1 : number +>x : any +>1 : number + +for (x = 5;;x++) {} +>x = 5 : number +>x : any +>5 : number +>x++ : number +>x : any + +for (x = 8;;x--) {} +>x = 8 : number +>x : any +>8 : number +>x-- : number +>x : any + +for (x = 15;;++x) {} +>x = 15 : number +>x : any +>15 : number +>++x : number +>x : any + +for (x = 18;;--x) {} +>x = 18 : number +>x : any +>18 : number +>--x : number +>x : any + +for (let x = 50;;) {} +>x : number +>50 : number + +function foo() { +>foo : () => void + + x = 100; +>x = 100 : number +>x : any +>100 : number +} + +export let [y] = [1]; +>y : number +>[1] : [number] +>1 : number + +export const {a: z0, b: {c: z1}} = {a: true, b: {c: "123"}}; +>a : any +>z0 : boolean +>b : any +>c : any +>z1 : string +>{a: true, b: {c: "123"}} : { a: boolean; b: { c: string; }; } +>a : boolean +>true : boolean +>b : { c: string; } +>{c: "123"} : { c: string; } +>c : string +>"123" : string + +for ([x] of [[1]]) {} +>[x] : any[] +>x : any +>[[1]] : number[][] +>[1] : number[] +>1 : number + diff --git a/tests/baselines/reference/throwInEnclosingStatements.errors.txt b/tests/baselines/reference/throwInEnclosingStatements.errors.txt deleted file mode 100644 index 1d225a45fe8..00000000000 --- a/tests/baselines/reference/throwInEnclosingStatements.errors.txt +++ /dev/null @@ -1,52 +0,0 @@ -tests/cases/conformance/statements/throwStatements/throwInEnclosingStatements.ts(15,1): error TS7027: Unreachable code detected. - - -==== tests/cases/conformance/statements/throwStatements/throwInEnclosingStatements.ts (1 errors) ==== - function fn(x) { - throw x; - } - - (x: T) => { throw x; } - - var y: string; - switch (y) { - case 'a': - throw y; - default: - throw y; - } - - var z = 0; - ~~~ -!!! error TS7027: Unreachable code detected. - while (z < 10) { - throw z; - } - - for (var i = 0; ;) { throw i; } - - for (var idx in {}) { throw idx; } - - do { throw null; }while(true) - - var j = 0; - while (j < 0) { throw j; } - - class C { - private value: T; - biz() { - throw this.value; - } - - constructor() { - throw this; - } - } - - var aa = { - id:12, - biz() { - throw this; - } - } - \ No newline at end of file diff --git a/tests/baselines/reference/throwInEnclosingStatements.js b/tests/baselines/reference/throwInEnclosingStatements.js index 0b072434f33..4d9200776e7 100644 --- a/tests/baselines/reference/throwInEnclosingStatements.js +++ b/tests/baselines/reference/throwInEnclosingStatements.js @@ -1,4 +1,5 @@ //// [throwInEnclosingStatements.ts] + function fn(x) { throw x; } diff --git a/tests/baselines/reference/throwInEnclosingStatements.symbols b/tests/baselines/reference/throwInEnclosingStatements.symbols new file mode 100644 index 00000000000..42053c60efa --- /dev/null +++ b/tests/baselines/reference/throwInEnclosingStatements.symbols @@ -0,0 +1,94 @@ +=== tests/cases/conformance/statements/throwStatements/throwInEnclosingStatements.ts === + +function fn(x) { +>fn : Symbol(fn, Decl(throwInEnclosingStatements.ts, 0, 0)) +>x : Symbol(x, Decl(throwInEnclosingStatements.ts, 1, 12)) + + throw x; +>x : Symbol(x, Decl(throwInEnclosingStatements.ts, 1, 12)) +} + +(x: T) => { throw x; } +>T : Symbol(T, Decl(throwInEnclosingStatements.ts, 5, 1)) +>x : Symbol(x, Decl(throwInEnclosingStatements.ts, 5, 4)) +>T : Symbol(T, Decl(throwInEnclosingStatements.ts, 5, 1)) +>x : Symbol(x, Decl(throwInEnclosingStatements.ts, 5, 4)) + +var y: string; +>y : Symbol(y, Decl(throwInEnclosingStatements.ts, 7, 3)) + +switch (y) { +>y : Symbol(y, Decl(throwInEnclosingStatements.ts, 7, 3)) + + case 'a': + throw y; +>y : Symbol(y, Decl(throwInEnclosingStatements.ts, 7, 3)) + + default: + throw y; +>y : Symbol(y, Decl(throwInEnclosingStatements.ts, 7, 3)) +} + +var z = 0; +>z : Symbol(z, Decl(throwInEnclosingStatements.ts, 15, 3)) + +while (z < 10) { +>z : Symbol(z, Decl(throwInEnclosingStatements.ts, 15, 3)) + + throw z; +>z : Symbol(z, Decl(throwInEnclosingStatements.ts, 15, 3)) +} + +for (var i = 0; ;) { throw i; } +>i : Symbol(i, Decl(throwInEnclosingStatements.ts, 20, 8)) +>i : Symbol(i, Decl(throwInEnclosingStatements.ts, 20, 8)) + +for (var idx in {}) { throw idx; } +>idx : Symbol(idx, Decl(throwInEnclosingStatements.ts, 22, 8)) +>idx : Symbol(idx, Decl(throwInEnclosingStatements.ts, 22, 8)) + +do { throw null; }while(true) + +var j = 0; +>j : Symbol(j, Decl(throwInEnclosingStatements.ts, 26, 3)) + +while (j < 0) { throw j; } +>j : Symbol(j, Decl(throwInEnclosingStatements.ts, 26, 3)) +>j : Symbol(j, Decl(throwInEnclosingStatements.ts, 26, 3)) + +class C { +>C : Symbol(C, Decl(throwInEnclosingStatements.ts, 27, 26)) +>T : Symbol(T, Decl(throwInEnclosingStatements.ts, 29, 8)) + + private value: T; +>value : Symbol(value, Decl(throwInEnclosingStatements.ts, 29, 12)) +>T : Symbol(T, Decl(throwInEnclosingStatements.ts, 29, 8)) + + biz() { +>biz : Symbol(biz, Decl(throwInEnclosingStatements.ts, 30, 21)) + + throw this.value; +>this.value : Symbol(value, Decl(throwInEnclosingStatements.ts, 29, 12)) +>this : Symbol(C, Decl(throwInEnclosingStatements.ts, 27, 26)) +>value : Symbol(value, Decl(throwInEnclosingStatements.ts, 29, 12)) + } + + constructor() { + throw this; +>this : Symbol(C, Decl(throwInEnclosingStatements.ts, 27, 26)) + } +} + +var aa = { +>aa : Symbol(aa, Decl(throwInEnclosingStatements.ts, 40, 3)) + + id:12, +>id : Symbol(id, Decl(throwInEnclosingStatements.ts, 40, 10)) + + biz() { +>biz : Symbol(biz, Decl(throwInEnclosingStatements.ts, 41, 10)) + + throw this; + } +} + diff --git a/tests/baselines/reference/throwInEnclosingStatements.types b/tests/baselines/reference/throwInEnclosingStatements.types new file mode 100644 index 00000000000..568fd800e35 --- /dev/null +++ b/tests/baselines/reference/throwInEnclosingStatements.types @@ -0,0 +1,110 @@ +=== tests/cases/conformance/statements/throwStatements/throwInEnclosingStatements.ts === + +function fn(x) { +>fn : (x: any) => void +>x : any + + throw x; +>x : any +} + +(x: T) => { throw x; } +>(x: T) => { throw x; } : (x: T) => void +>T : T +>x : T +>T : T +>x : T + +var y: string; +>y : string + +switch (y) { +>y : string + + case 'a': +>'a' : string + + throw y; +>y : string + + default: + throw y; +>y : string +} + +var z = 0; +>z : number +>0 : number + +while (z < 10) { +>z < 10 : boolean +>z : number +>10 : number + + throw z; +>z : number +} + +for (var i = 0; ;) { throw i; } +>i : number +>0 : number +>i : number + +for (var idx in {}) { throw idx; } +>idx : any +>{} : {} +>idx : any + +do { throw null; }while(true) +>null : null +>true : boolean + +var j = 0; +>j : number +>0 : number + +while (j < 0) { throw j; } +>j < 0 : boolean +>j : number +>0 : number +>j : number + +class C { +>C : C +>T : T + + private value: T; +>value : T +>T : T + + biz() { +>biz : () => void + + throw this.value; +>this.value : T +>this : this +>value : T + } + + constructor() { + throw this; +>this : this + } +} + +var aa = { +>aa : { id: number; biz(): void; } +>{ id:12, biz() { throw this; }} : { id: number; biz(): void; } + + id:12, +>id : number +>12 : number + + biz() { +>biz : () => void + + throw this; +>this : any + } +} + diff --git a/tests/baselines/reference/throwStatements.errors.txt b/tests/baselines/reference/throwStatements.errors.txt deleted file mode 100644 index e2e15bd503a..00000000000 --- a/tests/baselines/reference/throwStatements.errors.txt +++ /dev/null @@ -1,91 +0,0 @@ -tests/cases/conformance/statements/throwStatements/throwStatements.ts(29,1): error TS7027: Unreachable code detected. - - -==== tests/cases/conformance/statements/throwStatements/throwStatements.ts (1 errors) ==== - // all legal - - interface I { - id: number; - } - - class C implements I { - id: number; - } - - class D{ - source: T; - recurse: D; - wrapped: D> - } - - function F(x: string): number { return 42; } - - module M { - export class A { - name: string; - } - - export function F2(x: number): string { return x.toString(); } - } - - var aNumber = 9.9; - throw aNumber; - var aString = 'this is a string'; - ~~~ -!!! error TS7027: Unreachable code detected. - throw aString; - var aDate = new Date(12); - throw aDate; - var anObject = new Object(); - throw anObject; - - var anAny = null; - throw anAny; - var anOtherAny = new C(); - throw anOtherAny; - var anUndefined = undefined; - throw anUndefined; - - var aClass = new C(); - throw aClass; - var aGenericClass = new D(); - throw aGenericClass; - var anObjectLiteral = { id: 12 }; - throw anObjectLiteral; - - var aFunction = F; - throw aFunction; - throw aFunction(''); - var aLambda = (x) => 2; - throw aLambda; - throw aLambda(1); - - var aModule = M; - throw aModule; - throw typeof M; - var aClassInModule = new M.A(); - throw aClassInModule; - var aFunctionInModule = M.F2; - throw aFunctionInModule; - - // no initializer or annotation, so this is an 'any' - var x; - throw x; - - // literals - throw 0.0; - throw false; - throw null; - throw undefined; - throw 'a string'; - throw function () { return 'a string' }; - throw (x:T) => 42; - throw { x: 12, y: 13 }; - throw []; - throw ['a', ['b']]; - throw /[a-z]/; - throw new Date(); - throw new C(); - throw new Object(); - throw new D(); - \ No newline at end of file diff --git a/tests/baselines/reference/throwStatements.js b/tests/baselines/reference/throwStatements.js index 83663d08cc4..556ebc55e37 100644 --- a/tests/baselines/reference/throwStatements.js +++ b/tests/baselines/reference/throwStatements.js @@ -1,4 +1,5 @@ //// [throwStatements.ts] + // all legal interface I { diff --git a/tests/baselines/reference/throwStatements.symbols b/tests/baselines/reference/throwStatements.symbols new file mode 100644 index 00000000000..adf9cb461cf --- /dev/null +++ b/tests/baselines/reference/throwStatements.symbols @@ -0,0 +1,216 @@ +=== tests/cases/conformance/statements/throwStatements/throwStatements.ts === + +// all legal + +interface I { +>I : Symbol(I, Decl(throwStatements.ts, 0, 0)) + + id: number; +>id : Symbol(id, Decl(throwStatements.ts, 3, 13)) +} + +class C implements I { +>C : Symbol(C, Decl(throwStatements.ts, 5, 1)) +>I : Symbol(I, Decl(throwStatements.ts, 0, 0)) + + id: number; +>id : Symbol(id, Decl(throwStatements.ts, 7, 22)) +} + +class D{ +>D : Symbol(D, Decl(throwStatements.ts, 9, 1)) +>T : Symbol(T, Decl(throwStatements.ts, 11, 8)) + + source: T; +>source : Symbol(source, Decl(throwStatements.ts, 11, 11)) +>T : Symbol(T, Decl(throwStatements.ts, 11, 8)) + + recurse: D; +>recurse : Symbol(recurse, Decl(throwStatements.ts, 12, 14)) +>D : Symbol(D, Decl(throwStatements.ts, 9, 1)) +>T : Symbol(T, Decl(throwStatements.ts, 11, 8)) + + wrapped: D> +>wrapped : Symbol(wrapped, Decl(throwStatements.ts, 13, 18)) +>D : Symbol(D, Decl(throwStatements.ts, 9, 1)) +>D : Symbol(D, Decl(throwStatements.ts, 9, 1)) +>T : Symbol(T, Decl(throwStatements.ts, 11, 8)) +} + +function F(x: string): number { return 42; } +>F : Symbol(F, Decl(throwStatements.ts, 15, 1)) +>x : Symbol(x, Decl(throwStatements.ts, 17, 11)) + +module M { +>M : Symbol(M, Decl(throwStatements.ts, 17, 44)) + + export class A { +>A : Symbol(A, Decl(throwStatements.ts, 19, 10)) + + name: string; +>name : Symbol(name, Decl(throwStatements.ts, 20, 20)) + } + + export function F2(x: number): string { return x.toString(); } +>F2 : Symbol(F2, Decl(throwStatements.ts, 22, 5)) +>x : Symbol(x, Decl(throwStatements.ts, 24, 23)) +>x.toString : Symbol(Number.toString, Decl(lib.d.ts, --, --)) +>x : Symbol(x, Decl(throwStatements.ts, 24, 23)) +>toString : Symbol(Number.toString, Decl(lib.d.ts, --, --)) +} + +var aNumber = 9.9; +>aNumber : Symbol(aNumber, Decl(throwStatements.ts, 27, 3)) + +throw aNumber; +>aNumber : Symbol(aNumber, Decl(throwStatements.ts, 27, 3)) + +var aString = 'this is a string'; +>aString : Symbol(aString, Decl(throwStatements.ts, 29, 3)) + +throw aString; +>aString : Symbol(aString, Decl(throwStatements.ts, 29, 3)) + +var aDate = new Date(12); +>aDate : Symbol(aDate, Decl(throwStatements.ts, 31, 3)) +>Date : Symbol(Date, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) + +throw aDate; +>aDate : Symbol(aDate, Decl(throwStatements.ts, 31, 3)) + +var anObject = new Object(); +>anObject : Symbol(anObject, Decl(throwStatements.ts, 33, 3)) +>Object : Symbol(Object, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) + +throw anObject; +>anObject : Symbol(anObject, Decl(throwStatements.ts, 33, 3)) + +var anAny = null; +>anAny : Symbol(anAny, Decl(throwStatements.ts, 36, 3)) + +throw anAny; +>anAny : Symbol(anAny, Decl(throwStatements.ts, 36, 3)) + +var anOtherAny = new C(); +>anOtherAny : Symbol(anOtherAny, Decl(throwStatements.ts, 38, 3)) +>C : Symbol(C, Decl(throwStatements.ts, 5, 1)) + +throw anOtherAny; +>anOtherAny : Symbol(anOtherAny, Decl(throwStatements.ts, 38, 3)) + +var anUndefined = undefined; +>anUndefined : Symbol(anUndefined, Decl(throwStatements.ts, 40, 3)) +>undefined : Symbol(undefined) + +throw anUndefined; +>anUndefined : Symbol(anUndefined, Decl(throwStatements.ts, 40, 3)) + +var aClass = new C(); +>aClass : Symbol(aClass, Decl(throwStatements.ts, 43, 3)) +>C : Symbol(C, Decl(throwStatements.ts, 5, 1)) + +throw aClass; +>aClass : Symbol(aClass, Decl(throwStatements.ts, 43, 3)) + +var aGenericClass = new D(); +>aGenericClass : Symbol(aGenericClass, Decl(throwStatements.ts, 45, 3)) +>D : Symbol(D, Decl(throwStatements.ts, 9, 1)) + +throw aGenericClass; +>aGenericClass : Symbol(aGenericClass, Decl(throwStatements.ts, 45, 3)) + +var anObjectLiteral = { id: 12 }; +>anObjectLiteral : Symbol(anObjectLiteral, Decl(throwStatements.ts, 47, 3)) +>id : Symbol(id, Decl(throwStatements.ts, 47, 23)) + +throw anObjectLiteral; +>anObjectLiteral : Symbol(anObjectLiteral, Decl(throwStatements.ts, 47, 3)) + +var aFunction = F; +>aFunction : Symbol(aFunction, Decl(throwStatements.ts, 50, 3)) +>F : Symbol(F, Decl(throwStatements.ts, 15, 1)) + +throw aFunction; +>aFunction : Symbol(aFunction, Decl(throwStatements.ts, 50, 3)) + +throw aFunction(''); +>aFunction : Symbol(aFunction, Decl(throwStatements.ts, 50, 3)) + +var aLambda = (x) => 2; +>aLambda : Symbol(aLambda, Decl(throwStatements.ts, 53, 3)) +>x : Symbol(x, Decl(throwStatements.ts, 53, 15)) + +throw aLambda; +>aLambda : Symbol(aLambda, Decl(throwStatements.ts, 53, 3)) + +throw aLambda(1); +>aLambda : Symbol(aLambda, Decl(throwStatements.ts, 53, 3)) + +var aModule = M; +>aModule : Symbol(aModule, Decl(throwStatements.ts, 57, 3)) +>M : Symbol(M, Decl(throwStatements.ts, 17, 44)) + +throw aModule; +>aModule : Symbol(aModule, Decl(throwStatements.ts, 57, 3)) + +throw typeof M; +>M : Symbol(M, Decl(throwStatements.ts, 17, 44)) + +var aClassInModule = new M.A(); +>aClassInModule : Symbol(aClassInModule, Decl(throwStatements.ts, 60, 3)) +>M.A : Symbol(M.A, Decl(throwStatements.ts, 19, 10)) +>M : Symbol(M, Decl(throwStatements.ts, 17, 44)) +>A : Symbol(M.A, Decl(throwStatements.ts, 19, 10)) + +throw aClassInModule; +>aClassInModule : Symbol(aClassInModule, Decl(throwStatements.ts, 60, 3)) + +var aFunctionInModule = M.F2; +>aFunctionInModule : Symbol(aFunctionInModule, Decl(throwStatements.ts, 62, 3)) +>M.F2 : Symbol(M.F2, Decl(throwStatements.ts, 22, 5)) +>M : Symbol(M, Decl(throwStatements.ts, 17, 44)) +>F2 : Symbol(M.F2, Decl(throwStatements.ts, 22, 5)) + +throw aFunctionInModule; +>aFunctionInModule : Symbol(aFunctionInModule, Decl(throwStatements.ts, 62, 3)) + +// no initializer or annotation, so this is an 'any' +var x; +>x : Symbol(x, Decl(throwStatements.ts, 66, 3)) + +throw x; +>x : Symbol(x, Decl(throwStatements.ts, 66, 3)) + +// literals +throw 0.0; +throw false; +throw null; +throw undefined; +>undefined : Symbol(undefined) + +throw 'a string'; +throw function () { return 'a string' }; +throw (x:T) => 42; +>T : Symbol(T, Decl(throwStatements.ts, 76, 7)) +>x : Symbol(x, Decl(throwStatements.ts, 76, 10)) +>T : Symbol(T, Decl(throwStatements.ts, 76, 7)) + +throw { x: 12, y: 13 }; +>x : Symbol(x, Decl(throwStatements.ts, 77, 7)) +>y : Symbol(y, Decl(throwStatements.ts, 77, 14)) + +throw []; +throw ['a', ['b']]; +throw /[a-z]/; +throw new Date(); +>Date : Symbol(Date, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) + +throw new C(); +>C : Symbol(C, Decl(throwStatements.ts, 5, 1)) + +throw new Object(); +>Object : Symbol(Object, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) + +throw new D(); +>D : Symbol(D, Decl(throwStatements.ts, 9, 1)) + diff --git a/tests/baselines/reference/throwStatements.types b/tests/baselines/reference/throwStatements.types new file mode 100644 index 00000000000..5023513ee53 --- /dev/null +++ b/tests/baselines/reference/throwStatements.types @@ -0,0 +1,267 @@ +=== tests/cases/conformance/statements/throwStatements/throwStatements.ts === + +// all legal + +interface I { +>I : I + + id: number; +>id : number +} + +class C implements I { +>C : C +>I : I + + id: number; +>id : number +} + +class D{ +>D : D +>T : T + + source: T; +>source : T +>T : T + + recurse: D; +>recurse : D +>D : D +>T : T + + wrapped: D> +>wrapped : D> +>D : D +>D : D +>T : T +} + +function F(x: string): number { return 42; } +>F : (x: string) => number +>x : string +>42 : number + +module M { +>M : typeof M + + export class A { +>A : A + + name: string; +>name : string + } + + export function F2(x: number): string { return x.toString(); } +>F2 : (x: number) => string +>x : number +>x.toString() : string +>x.toString : (radix?: number) => string +>x : number +>toString : (radix?: number) => string +} + +var aNumber = 9.9; +>aNumber : number +>9.9 : number + +throw aNumber; +>aNumber : number + +var aString = 'this is a string'; +>aString : string +>'this is a string' : string + +throw aString; +>aString : string + +var aDate = new Date(12); +>aDate : Date +>new Date(12) : Date +>Date : DateConstructor +>12 : number + +throw aDate; +>aDate : Date + +var anObject = new Object(); +>anObject : Object +>new Object() : Object +>Object : ObjectConstructor + +throw anObject; +>anObject : Object + +var anAny = null; +>anAny : any +>null : null + +throw anAny; +>anAny : any + +var anOtherAny = new C(); +>anOtherAny : any +> new C() : any +>new C() : C +>C : typeof C + +throw anOtherAny; +>anOtherAny : any + +var anUndefined = undefined; +>anUndefined : any +>undefined : undefined + +throw anUndefined; +>anUndefined : any + +var aClass = new C(); +>aClass : C +>new C() : C +>C : typeof C + +throw aClass; +>aClass : C + +var aGenericClass = new D(); +>aGenericClass : D +>new D() : D +>D : typeof D + +throw aGenericClass; +>aGenericClass : D + +var anObjectLiteral = { id: 12 }; +>anObjectLiteral : { id: number; } +>{ id: 12 } : { id: number; } +>id : number +>12 : number + +throw anObjectLiteral; +>anObjectLiteral : { id: number; } + +var aFunction = F; +>aFunction : (x: string) => number +>F : (x: string) => number + +throw aFunction; +>aFunction : (x: string) => number + +throw aFunction(''); +>aFunction('') : number +>aFunction : (x: string) => number +>'' : string + +var aLambda = (x) => 2; +>aLambda : (x: any) => number +>(x) => 2 : (x: any) => number +>x : any +>2 : number + +throw aLambda; +>aLambda : (x: any) => number + +throw aLambda(1); +>aLambda(1) : number +>aLambda : (x: any) => number +>1 : number + +var aModule = M; +>aModule : typeof M +>M : typeof M + +throw aModule; +>aModule : typeof M + +throw typeof M; +>typeof M : string +>M : typeof M + +var aClassInModule = new M.A(); +>aClassInModule : M.A +>new M.A() : M.A +>M.A : typeof M.A +>M : typeof M +>A : typeof M.A + +throw aClassInModule; +>aClassInModule : M.A + +var aFunctionInModule = M.F2; +>aFunctionInModule : (x: number) => string +>M.F2 : (x: number) => string +>M : typeof M +>F2 : (x: number) => string + +throw aFunctionInModule; +>aFunctionInModule : (x: number) => string + +// no initializer or annotation, so this is an 'any' +var x; +>x : any + +throw x; +>x : any + +// literals +throw 0.0; +>0.0 : number + +throw false; +>false : boolean + +throw null; +>null : null + +throw undefined; +>undefined : undefined + +throw 'a string'; +>'a string' : string + +throw function () { return 'a string' }; +>function () { return 'a string' } : () => string +>'a string' : string + +throw (x:T) => 42; +>(x:T) => 42 : (x: T) => number +>T : T +>x : T +>T : T +>42 : number + +throw { x: 12, y: 13 }; +>{ x: 12, y: 13 } : { x: number; y: number; } +>x : number +>12 : number +>y : number +>13 : number + +throw []; +>[] : undefined[] + +throw ['a', ['b']]; +>['a', ['b']] : (string | string[])[] +>'a' : string +>['b'] : string[] +>'b' : string + +throw /[a-z]/; +>/[a-z]/ : RegExp + +throw new Date(); +>new Date() : Date +>Date : DateConstructor + +throw new C(); +>new C() : C +>C : typeof C + +throw new Object(); +>new Object() : Object +>Object : ObjectConstructor + +throw new D(); +>new D() : D +>D : typeof D + diff --git a/tests/baselines/reference/typeofOperatorWithBooleanType.errors.txt b/tests/baselines/reference/typeofOperatorWithBooleanType.errors.txt deleted file mode 100644 index 9c4e2495660..00000000000 --- a/tests/baselines/reference/typeofOperatorWithBooleanType.errors.txt +++ /dev/null @@ -1,59 +0,0 @@ -tests/cases/conformance/expressions/unaryOperators/typeofOperator/typeofOperatorWithBooleanType.ts(44,1): error TS7028: Unused label. -tests/cases/conformance/expressions/unaryOperators/typeofOperator/typeofOperatorWithBooleanType.ts(45,1): error TS7028: Unused label. - - -==== tests/cases/conformance/expressions/unaryOperators/typeofOperator/typeofOperatorWithBooleanType.ts (2 errors) ==== - // typeof operator on boolean type - var BOOLEAN: boolean; - - function foo(): boolean { return true; } - - class A { - public a: boolean; - static foo() { return false; } - } - module M { - export var n: boolean; - } - - var objA = new A(); - - // boolean type var - var ResultIsString1 = typeof BOOLEAN; - - // boolean type literal - var ResultIsString2 = typeof true; - var ResultIsString3 = typeof { x: true, y: false }; - - // boolean type expressions - var ResultIsString4 = typeof objA.a; - var ResultIsString5 = typeof M.n; - var ResultIsString6 = typeof foo(); - var ResultIsString7 = typeof A.foo(); - - // multiple typeof operator - var ResultIsString8 = typeof typeof BOOLEAN; - - // miss assignment operators - typeof true; - typeof BOOLEAN; - typeof foo(); - typeof true, false; - typeof objA.a; - typeof M.n; - - // use typeof in type query - var z: boolean; - var x: boolean[]; - var r: () => boolean; - z: typeof BOOLEAN; - ~ -!!! error TS7028: Unused label. - r: typeof foo; - ~ -!!! error TS7028: Unused label. - var y = { a: true, b: false}; - z: typeof y.a; - z: typeof objA.a; - z: typeof A.foo; - z: typeof M.n; \ No newline at end of file diff --git a/tests/baselines/reference/typeofOperatorWithBooleanType.js b/tests/baselines/reference/typeofOperatorWithBooleanType.js index c0538b78b14..b9db33b11a4 100644 --- a/tests/baselines/reference/typeofOperatorWithBooleanType.js +++ b/tests/baselines/reference/typeofOperatorWithBooleanType.js @@ -1,4 +1,5 @@ //// [typeofOperatorWithBooleanType.ts] + // typeof operator on boolean type var BOOLEAN: boolean; diff --git a/tests/baselines/reference/typeofOperatorWithBooleanType.symbols b/tests/baselines/reference/typeofOperatorWithBooleanType.symbols new file mode 100644 index 00000000000..0167a14ae03 --- /dev/null +++ b/tests/baselines/reference/typeofOperatorWithBooleanType.symbols @@ -0,0 +1,131 @@ +=== tests/cases/conformance/expressions/unaryOperators/typeofOperator/typeofOperatorWithBooleanType.ts === + +// typeof operator on boolean type +var BOOLEAN: boolean; +>BOOLEAN : Symbol(BOOLEAN, Decl(typeofOperatorWithBooleanType.ts, 2, 3)) + +function foo(): boolean { return true; } +>foo : Symbol(foo, Decl(typeofOperatorWithBooleanType.ts, 2, 21)) + +class A { +>A : Symbol(A, Decl(typeofOperatorWithBooleanType.ts, 4, 40)) + + public a: boolean; +>a : Symbol(a, Decl(typeofOperatorWithBooleanType.ts, 6, 9)) + + static foo() { return false; } +>foo : Symbol(A.foo, Decl(typeofOperatorWithBooleanType.ts, 7, 22)) +} +module M { +>M : Symbol(M, Decl(typeofOperatorWithBooleanType.ts, 9, 1)) + + export var n: boolean; +>n : Symbol(n, Decl(typeofOperatorWithBooleanType.ts, 11, 14)) +} + +var objA = new A(); +>objA : Symbol(objA, Decl(typeofOperatorWithBooleanType.ts, 14, 3)) +>A : Symbol(A, Decl(typeofOperatorWithBooleanType.ts, 4, 40)) + +// boolean type var +var ResultIsString1 = typeof BOOLEAN; +>ResultIsString1 : Symbol(ResultIsString1, Decl(typeofOperatorWithBooleanType.ts, 17, 3)) +>BOOLEAN : Symbol(BOOLEAN, Decl(typeofOperatorWithBooleanType.ts, 2, 3)) + +// boolean type literal +var ResultIsString2 = typeof true; +>ResultIsString2 : Symbol(ResultIsString2, Decl(typeofOperatorWithBooleanType.ts, 20, 3)) + +var ResultIsString3 = typeof { x: true, y: false }; +>ResultIsString3 : Symbol(ResultIsString3, Decl(typeofOperatorWithBooleanType.ts, 21, 3)) +>x : Symbol(x, Decl(typeofOperatorWithBooleanType.ts, 21, 30)) +>y : Symbol(y, Decl(typeofOperatorWithBooleanType.ts, 21, 39)) + +// boolean type expressions +var ResultIsString4 = typeof objA.a; +>ResultIsString4 : Symbol(ResultIsString4, Decl(typeofOperatorWithBooleanType.ts, 24, 3)) +>objA.a : Symbol(A.a, Decl(typeofOperatorWithBooleanType.ts, 6, 9)) +>objA : Symbol(objA, Decl(typeofOperatorWithBooleanType.ts, 14, 3)) +>a : Symbol(A.a, Decl(typeofOperatorWithBooleanType.ts, 6, 9)) + +var ResultIsString5 = typeof M.n; +>ResultIsString5 : Symbol(ResultIsString5, Decl(typeofOperatorWithBooleanType.ts, 25, 3)) +>M.n : Symbol(M.n, Decl(typeofOperatorWithBooleanType.ts, 11, 14)) +>M : Symbol(M, Decl(typeofOperatorWithBooleanType.ts, 9, 1)) +>n : Symbol(M.n, Decl(typeofOperatorWithBooleanType.ts, 11, 14)) + +var ResultIsString6 = typeof foo(); +>ResultIsString6 : Symbol(ResultIsString6, Decl(typeofOperatorWithBooleanType.ts, 26, 3)) +>foo : Symbol(foo, Decl(typeofOperatorWithBooleanType.ts, 2, 21)) + +var ResultIsString7 = typeof A.foo(); +>ResultIsString7 : Symbol(ResultIsString7, Decl(typeofOperatorWithBooleanType.ts, 27, 3)) +>A.foo : Symbol(A.foo, Decl(typeofOperatorWithBooleanType.ts, 7, 22)) +>A : Symbol(A, Decl(typeofOperatorWithBooleanType.ts, 4, 40)) +>foo : Symbol(A.foo, Decl(typeofOperatorWithBooleanType.ts, 7, 22)) + +// multiple typeof operator +var ResultIsString8 = typeof typeof BOOLEAN; +>ResultIsString8 : Symbol(ResultIsString8, Decl(typeofOperatorWithBooleanType.ts, 30, 3)) +>BOOLEAN : Symbol(BOOLEAN, Decl(typeofOperatorWithBooleanType.ts, 2, 3)) + +// miss assignment operators +typeof true; +typeof BOOLEAN; +>BOOLEAN : Symbol(BOOLEAN, Decl(typeofOperatorWithBooleanType.ts, 2, 3)) + +typeof foo(); +>foo : Symbol(foo, Decl(typeofOperatorWithBooleanType.ts, 2, 21)) + +typeof true, false; +typeof objA.a; +>objA.a : Symbol(A.a, Decl(typeofOperatorWithBooleanType.ts, 6, 9)) +>objA : Symbol(objA, Decl(typeofOperatorWithBooleanType.ts, 14, 3)) +>a : Symbol(A.a, Decl(typeofOperatorWithBooleanType.ts, 6, 9)) + +typeof M.n; +>M.n : Symbol(M.n, Decl(typeofOperatorWithBooleanType.ts, 11, 14)) +>M : Symbol(M, Decl(typeofOperatorWithBooleanType.ts, 9, 1)) +>n : Symbol(M.n, Decl(typeofOperatorWithBooleanType.ts, 11, 14)) + +// use typeof in type query +var z: boolean; +>z : Symbol(z, Decl(typeofOperatorWithBooleanType.ts, 41, 3)) + +var x: boolean[]; +>x : Symbol(x, Decl(typeofOperatorWithBooleanType.ts, 42, 3)) + +var r: () => boolean; +>r : Symbol(r, Decl(typeofOperatorWithBooleanType.ts, 43, 3)) + +z: typeof BOOLEAN; +>BOOLEAN : Symbol(BOOLEAN, Decl(typeofOperatorWithBooleanType.ts, 2, 3)) + +r: typeof foo; +>foo : Symbol(foo, Decl(typeofOperatorWithBooleanType.ts, 2, 21)) + +var y = { a: true, b: false}; +>y : Symbol(y, Decl(typeofOperatorWithBooleanType.ts, 46, 3)) +>a : Symbol(a, Decl(typeofOperatorWithBooleanType.ts, 46, 9)) +>b : Symbol(b, Decl(typeofOperatorWithBooleanType.ts, 46, 18)) + +z: typeof y.a; +>y.a : Symbol(a, Decl(typeofOperatorWithBooleanType.ts, 46, 9)) +>y : Symbol(y, Decl(typeofOperatorWithBooleanType.ts, 46, 3)) +>a : Symbol(a, Decl(typeofOperatorWithBooleanType.ts, 46, 9)) + +z: typeof objA.a; +>objA.a : Symbol(A.a, Decl(typeofOperatorWithBooleanType.ts, 6, 9)) +>objA : Symbol(objA, Decl(typeofOperatorWithBooleanType.ts, 14, 3)) +>a : Symbol(A.a, Decl(typeofOperatorWithBooleanType.ts, 6, 9)) + +z: typeof A.foo; +>A.foo : Symbol(A.foo, Decl(typeofOperatorWithBooleanType.ts, 7, 22)) +>A : Symbol(A, Decl(typeofOperatorWithBooleanType.ts, 4, 40)) +>foo : Symbol(A.foo, Decl(typeofOperatorWithBooleanType.ts, 7, 22)) + +z: typeof M.n; +>M.n : Symbol(M.n, Decl(typeofOperatorWithBooleanType.ts, 11, 14)) +>M : Symbol(M, Decl(typeofOperatorWithBooleanType.ts, 9, 1)) +>n : Symbol(M.n, Decl(typeofOperatorWithBooleanType.ts, 11, 14)) + diff --git a/tests/baselines/reference/typeofOperatorWithBooleanType.types b/tests/baselines/reference/typeofOperatorWithBooleanType.types new file mode 100644 index 00000000000..043307cfb00 --- /dev/null +++ b/tests/baselines/reference/typeofOperatorWithBooleanType.types @@ -0,0 +1,177 @@ +=== tests/cases/conformance/expressions/unaryOperators/typeofOperator/typeofOperatorWithBooleanType.ts === + +// typeof operator on boolean type +var BOOLEAN: boolean; +>BOOLEAN : boolean + +function foo(): boolean { return true; } +>foo : () => boolean +>true : boolean + +class A { +>A : A + + public a: boolean; +>a : boolean + + static foo() { return false; } +>foo : () => boolean +>false : boolean +} +module M { +>M : typeof M + + export var n: boolean; +>n : boolean +} + +var objA = new A(); +>objA : A +>new A() : A +>A : typeof A + +// boolean type var +var ResultIsString1 = typeof BOOLEAN; +>ResultIsString1 : string +>typeof BOOLEAN : string +>BOOLEAN : boolean + +// boolean type literal +var ResultIsString2 = typeof true; +>ResultIsString2 : string +>typeof true : string +>true : boolean + +var ResultIsString3 = typeof { x: true, y: false }; +>ResultIsString3 : string +>typeof { x: true, y: false } : string +>{ x: true, y: false } : { x: boolean; y: boolean; } +>x : boolean +>true : boolean +>y : boolean +>false : boolean + +// boolean type expressions +var ResultIsString4 = typeof objA.a; +>ResultIsString4 : string +>typeof objA.a : string +>objA.a : boolean +>objA : A +>a : boolean + +var ResultIsString5 = typeof M.n; +>ResultIsString5 : string +>typeof M.n : string +>M.n : boolean +>M : typeof M +>n : boolean + +var ResultIsString6 = typeof foo(); +>ResultIsString6 : string +>typeof foo() : string +>foo() : boolean +>foo : () => boolean + +var ResultIsString7 = typeof A.foo(); +>ResultIsString7 : string +>typeof A.foo() : string +>A.foo() : boolean +>A.foo : () => boolean +>A : typeof A +>foo : () => boolean + +// multiple typeof operator +var ResultIsString8 = typeof typeof BOOLEAN; +>ResultIsString8 : string +>typeof typeof BOOLEAN : string +>typeof BOOLEAN : string +>BOOLEAN : boolean + +// miss assignment operators +typeof true; +>typeof true : string +>true : boolean + +typeof BOOLEAN; +>typeof BOOLEAN : string +>BOOLEAN : boolean + +typeof foo(); +>typeof foo() : string +>foo() : boolean +>foo : () => boolean + +typeof true, false; +>typeof true, false : boolean +>typeof true : string +>true : boolean +>false : boolean + +typeof objA.a; +>typeof objA.a : string +>objA.a : boolean +>objA : A +>a : boolean + +typeof M.n; +>typeof M.n : string +>M.n : boolean +>M : typeof M +>n : boolean + +// use typeof in type query +var z: boolean; +>z : boolean + +var x: boolean[]; +>x : boolean[] + +var r: () => boolean; +>r : () => boolean + +z: typeof BOOLEAN; +>z : any +>typeof BOOLEAN : string +>BOOLEAN : boolean + +r: typeof foo; +>r : any +>typeof foo : string +>foo : () => boolean + +var y = { a: true, b: false}; +>y : { a: boolean; b: boolean; } +>{ a: true, b: false} : { a: boolean; b: boolean; } +>a : boolean +>true : boolean +>b : boolean +>false : boolean + +z: typeof y.a; +>z : any +>typeof y.a : string +>y.a : boolean +>y : { a: boolean; b: boolean; } +>a : boolean + +z: typeof objA.a; +>z : any +>typeof objA.a : string +>objA.a : boolean +>objA : A +>a : boolean + +z: typeof A.foo; +>z : any +>typeof A.foo : string +>A.foo : () => boolean +>A : typeof A +>foo : () => boolean + +z: typeof M.n; +>z : any +>typeof M.n : string +>M.n : boolean +>M : typeof M +>n : boolean + diff --git a/tests/baselines/reference/typeofOperatorWithEnumType.errors.txt b/tests/baselines/reference/typeofOperatorWithEnumType.errors.txt deleted file mode 100644 index 6e473b7487d..00000000000 --- a/tests/baselines/reference/typeofOperatorWithEnumType.errors.txt +++ /dev/null @@ -1,33 +0,0 @@ -tests/cases/conformance/expressions/unaryOperators/typeofOperator/typeofOperatorWithEnumType.ts(26,1): error TS7028: Unused label. - - -==== tests/cases/conformance/expressions/unaryOperators/typeofOperator/typeofOperatorWithEnumType.ts (1 errors) ==== - // typeof operator on enum type - - enum ENUM { }; - enum ENUM1 { A, B, "" }; - - // enum type var - var ResultIsString1 = typeof ENUM; - var ResultIsString2 = typeof ENUM1; - - // enum type expressions - var ResultIsString3 = typeof ENUM1["A"]; - var ResultIsString4 = typeof (ENUM[0] + ENUM1["B"]); - - // multiple typeof operators - var ResultIsString5 = typeof typeof ENUM; - var ResultIsString6 = typeof typeof typeof (ENUM[0] + ENUM1.B); - - // miss assignment operators - typeof ENUM; - typeof ENUM1; - typeof ENUM1["B"]; - typeof ENUM, ENUM1; - - // use typeof in type query - enum z { }; - z: typeof ENUM; - ~ -!!! error TS7028: Unused label. - z: typeof ENUM1; \ No newline at end of file diff --git a/tests/baselines/reference/typeofOperatorWithEnumType.js b/tests/baselines/reference/typeofOperatorWithEnumType.js index 2e2963b0955..2ce32668186 100644 --- a/tests/baselines/reference/typeofOperatorWithEnumType.js +++ b/tests/baselines/reference/typeofOperatorWithEnumType.js @@ -1,4 +1,5 @@ //// [typeofOperatorWithEnumType.ts] + // typeof operator on enum type enum ENUM { }; diff --git a/tests/baselines/reference/typeofOperatorWithEnumType.symbols b/tests/baselines/reference/typeofOperatorWithEnumType.symbols new file mode 100644 index 00000000000..a8e3d6d351f --- /dev/null +++ b/tests/baselines/reference/typeofOperatorWithEnumType.symbols @@ -0,0 +1,70 @@ +=== tests/cases/conformance/expressions/unaryOperators/typeofOperator/typeofOperatorWithEnumType.ts === + +// typeof operator on enum type + +enum ENUM { }; +>ENUM : Symbol(ENUM, Decl(typeofOperatorWithEnumType.ts, 0, 0)) + +enum ENUM1 { A, B, "" }; +>ENUM1 : Symbol(ENUM1, Decl(typeofOperatorWithEnumType.ts, 3, 14)) +>A : Symbol(ENUM1.A, Decl(typeofOperatorWithEnumType.ts, 4, 12)) +>B : Symbol(ENUM1.B, Decl(typeofOperatorWithEnumType.ts, 4, 15)) + +// enum type var +var ResultIsString1 = typeof ENUM; +>ResultIsString1 : Symbol(ResultIsString1, Decl(typeofOperatorWithEnumType.ts, 7, 3)) +>ENUM : Symbol(ENUM, Decl(typeofOperatorWithEnumType.ts, 0, 0)) + +var ResultIsString2 = typeof ENUM1; +>ResultIsString2 : Symbol(ResultIsString2, Decl(typeofOperatorWithEnumType.ts, 8, 3)) +>ENUM1 : Symbol(ENUM1, Decl(typeofOperatorWithEnumType.ts, 3, 14)) + +// enum type expressions +var ResultIsString3 = typeof ENUM1["A"]; +>ResultIsString3 : Symbol(ResultIsString3, Decl(typeofOperatorWithEnumType.ts, 11, 3)) +>ENUM1 : Symbol(ENUM1, Decl(typeofOperatorWithEnumType.ts, 3, 14)) +>"A" : Symbol(ENUM1.A, Decl(typeofOperatorWithEnumType.ts, 4, 12)) + +var ResultIsString4 = typeof (ENUM[0] + ENUM1["B"]); +>ResultIsString4 : Symbol(ResultIsString4, Decl(typeofOperatorWithEnumType.ts, 12, 3)) +>ENUM : Symbol(ENUM, Decl(typeofOperatorWithEnumType.ts, 0, 0)) +>ENUM1 : Symbol(ENUM1, Decl(typeofOperatorWithEnumType.ts, 3, 14)) +>"B" : Symbol(ENUM1.B, Decl(typeofOperatorWithEnumType.ts, 4, 15)) + +// multiple typeof operators +var ResultIsString5 = typeof typeof ENUM; +>ResultIsString5 : Symbol(ResultIsString5, Decl(typeofOperatorWithEnumType.ts, 15, 3)) +>ENUM : Symbol(ENUM, Decl(typeofOperatorWithEnumType.ts, 0, 0)) + +var ResultIsString6 = typeof typeof typeof (ENUM[0] + ENUM1.B); +>ResultIsString6 : Symbol(ResultIsString6, Decl(typeofOperatorWithEnumType.ts, 16, 3)) +>ENUM : Symbol(ENUM, Decl(typeofOperatorWithEnumType.ts, 0, 0)) +>ENUM1.B : Symbol(ENUM1.B, Decl(typeofOperatorWithEnumType.ts, 4, 15)) +>ENUM1 : Symbol(ENUM1, Decl(typeofOperatorWithEnumType.ts, 3, 14)) +>B : Symbol(ENUM1.B, Decl(typeofOperatorWithEnumType.ts, 4, 15)) + +// miss assignment operators +typeof ENUM; +>ENUM : Symbol(ENUM, Decl(typeofOperatorWithEnumType.ts, 0, 0)) + +typeof ENUM1; +>ENUM1 : Symbol(ENUM1, Decl(typeofOperatorWithEnumType.ts, 3, 14)) + +typeof ENUM1["B"]; +>ENUM1 : Symbol(ENUM1, Decl(typeofOperatorWithEnumType.ts, 3, 14)) +>"B" : Symbol(ENUM1.B, Decl(typeofOperatorWithEnumType.ts, 4, 15)) + +typeof ENUM, ENUM1; +>ENUM : Symbol(ENUM, Decl(typeofOperatorWithEnumType.ts, 0, 0)) +>ENUM1 : Symbol(ENUM1, Decl(typeofOperatorWithEnumType.ts, 3, 14)) + +// use typeof in type query +enum z { }; +>z : Symbol(z, Decl(typeofOperatorWithEnumType.ts, 22, 19)) + +z: typeof ENUM; +>ENUM : Symbol(ENUM, Decl(typeofOperatorWithEnumType.ts, 0, 0)) + +z: typeof ENUM1; +>ENUM1 : Symbol(ENUM1, Decl(typeofOperatorWithEnumType.ts, 3, 14)) + diff --git a/tests/baselines/reference/typeofOperatorWithEnumType.types b/tests/baselines/reference/typeofOperatorWithEnumType.types new file mode 100644 index 00000000000..f9224811393 --- /dev/null +++ b/tests/baselines/reference/typeofOperatorWithEnumType.types @@ -0,0 +1,99 @@ +=== tests/cases/conformance/expressions/unaryOperators/typeofOperator/typeofOperatorWithEnumType.ts === + +// typeof operator on enum type + +enum ENUM { }; +>ENUM : ENUM + +enum ENUM1 { A, B, "" }; +>ENUM1 : ENUM1 +>A : ENUM1 +>B : ENUM1 + +// enum type var +var ResultIsString1 = typeof ENUM; +>ResultIsString1 : string +>typeof ENUM : string +>ENUM : typeof ENUM + +var ResultIsString2 = typeof ENUM1; +>ResultIsString2 : string +>typeof ENUM1 : string +>ENUM1 : typeof ENUM1 + +// enum type expressions +var ResultIsString3 = typeof ENUM1["A"]; +>ResultIsString3 : string +>typeof ENUM1["A"] : string +>ENUM1["A"] : ENUM1 +>ENUM1 : typeof ENUM1 +>"A" : string + +var ResultIsString4 = typeof (ENUM[0] + ENUM1["B"]); +>ResultIsString4 : string +>typeof (ENUM[0] + ENUM1["B"]) : string +>(ENUM[0] + ENUM1["B"]) : string +>ENUM[0] + ENUM1["B"] : string +>ENUM[0] : string +>ENUM : typeof ENUM +>0 : number +>ENUM1["B"] : ENUM1 +>ENUM1 : typeof ENUM1 +>"B" : string + +// multiple typeof operators +var ResultIsString5 = typeof typeof ENUM; +>ResultIsString5 : string +>typeof typeof ENUM : string +>typeof ENUM : string +>ENUM : typeof ENUM + +var ResultIsString6 = typeof typeof typeof (ENUM[0] + ENUM1.B); +>ResultIsString6 : string +>typeof typeof typeof (ENUM[0] + ENUM1.B) : string +>typeof typeof (ENUM[0] + ENUM1.B) : string +>typeof (ENUM[0] + ENUM1.B) : string +>(ENUM[0] + ENUM1.B) : string +>ENUM[0] + ENUM1.B : string +>ENUM[0] : string +>ENUM : typeof ENUM +>0 : number +>ENUM1.B : ENUM1 +>ENUM1 : typeof ENUM1 +>B : ENUM1 + +// miss assignment operators +typeof ENUM; +>typeof ENUM : string +>ENUM : typeof ENUM + +typeof ENUM1; +>typeof ENUM1 : string +>ENUM1 : typeof ENUM1 + +typeof ENUM1["B"]; +>typeof ENUM1["B"] : string +>ENUM1["B"] : ENUM1 +>ENUM1 : typeof ENUM1 +>"B" : string + +typeof ENUM, ENUM1; +>typeof ENUM, ENUM1 : typeof ENUM1 +>typeof ENUM : string +>ENUM : typeof ENUM +>ENUM1 : typeof ENUM1 + +// use typeof in type query +enum z { }; +>z : z + +z: typeof ENUM; +>z : any +>typeof ENUM : string +>ENUM : typeof ENUM + +z: typeof ENUM1; +>z : any +>typeof ENUM1 : string +>ENUM1 : typeof ENUM1 + diff --git a/tests/cases/compiler/commentsAtEndOfFile1.ts b/tests/cases/compiler/commentsAtEndOfFile1.ts index 8e37b2361a5..04c90b3433a 100644 --- a/tests/cases/compiler/commentsAtEndOfFile1.ts +++ b/tests/cases/compiler/commentsAtEndOfFile1.ts @@ -1,3 +1,5 @@ +// @allowUnusedLabels: true + Input: ; //Testing two diff --git a/tests/cases/compiler/recursiveMods.ts b/tests/cases/compiler/recursiveMods.ts index fa07646ba72..84dbafff558 100644 --- a/tests/cases/compiler/recursiveMods.ts +++ b/tests/cases/compiler/recursiveMods.ts @@ -1,4 +1,6 @@ -//@module: commonjs +// @allowUnreachableCode: true +// @module: commonjs + export module Foo { export class C {} } diff --git a/tests/cases/compiler/returnStatement1.ts b/tests/cases/compiler/returnStatement1.ts index e87635b37d7..06d1bdb9569 100644 --- a/tests/cases/compiler/returnStatement1.ts +++ b/tests/cases/compiler/returnStatement1.ts @@ -1,3 +1,5 @@ +// @allowUnreachableCode: true + function f() { return function (s) { var x = s; diff --git a/tests/cases/compiler/sourceMapValidationLabeled.ts b/tests/cases/compiler/sourceMapValidationLabeled.ts index 5993e82aacc..e36bdd9a0b3 100644 --- a/tests/cases/compiler/sourceMapValidationLabeled.ts +++ b/tests/cases/compiler/sourceMapValidationLabeled.ts @@ -1,3 +1,5 @@ +// @allowUnusedLabels: true // @sourcemap: true + x: var b = 10; \ No newline at end of file diff --git a/tests/cases/compiler/systemModule8.ts b/tests/cases/compiler/systemModule8.ts index c3e0c7c7437..4490b2a8529 100644 --- a/tests/cases/compiler/systemModule8.ts +++ b/tests/cases/compiler/systemModule8.ts @@ -1,3 +1,4 @@ +// @allowUnreachableCode: true // @module: system export var x; diff --git a/tests/cases/conformance/expressions/unaryOperators/typeofOperator/typeofOperatorWithBooleanType.ts b/tests/cases/conformance/expressions/unaryOperators/typeofOperator/typeofOperatorWithBooleanType.ts index 00460181c2b..c22ed94087b 100644 --- a/tests/cases/conformance/expressions/unaryOperators/typeofOperator/typeofOperatorWithBooleanType.ts +++ b/tests/cases/conformance/expressions/unaryOperators/typeofOperator/typeofOperatorWithBooleanType.ts @@ -1,3 +1,5 @@ +// @allowUnusedLabels: true + // typeof operator on boolean type var BOOLEAN: boolean; diff --git a/tests/cases/conformance/expressions/unaryOperators/typeofOperator/typeofOperatorWithEnumType.ts b/tests/cases/conformance/expressions/unaryOperators/typeofOperator/typeofOperatorWithEnumType.ts index 9abb602db06..57b22e3646c 100644 --- a/tests/cases/conformance/expressions/unaryOperators/typeofOperator/typeofOperatorWithEnumType.ts +++ b/tests/cases/conformance/expressions/unaryOperators/typeofOperator/typeofOperatorWithEnumType.ts @@ -1,3 +1,5 @@ +// @allowUnusedLabels: true + // typeof operator on enum type enum ENUM { }; diff --git a/tests/cases/conformance/parser/ecmascript5/Statements/BreakStatements/parser_breakTarget3.ts b/tests/cases/conformance/parser/ecmascript5/Statements/BreakStatements/parser_breakTarget3.ts index 9cef599692c..64a9357706f 100644 --- a/tests/cases/conformance/parser/ecmascript5/Statements/BreakStatements/parser_breakTarget3.ts +++ b/tests/cases/conformance/parser/ecmascript5/Statements/BreakStatements/parser_breakTarget3.ts @@ -1,3 +1,5 @@ +// @allowUnusedLabels: true + target1: target2: while (true) { diff --git a/tests/cases/conformance/parser/ecmascript5/Statements/BreakStatements/parser_breakTarget4.ts b/tests/cases/conformance/parser/ecmascript5/Statements/BreakStatements/parser_breakTarget4.ts index 2c3eadca7db..3e00bca659b 100644 --- a/tests/cases/conformance/parser/ecmascript5/Statements/BreakStatements/parser_breakTarget4.ts +++ b/tests/cases/conformance/parser/ecmascript5/Statements/BreakStatements/parser_breakTarget4.ts @@ -1,3 +1,5 @@ +// @allowUnusedLabels: true + target1: target2: while (true) { diff --git a/tests/cases/conformance/parser/ecmascript5/Statements/ContinueStatements/parser_continueTarget3.ts b/tests/cases/conformance/parser/ecmascript5/Statements/ContinueStatements/parser_continueTarget3.ts index 26bea241a7a..a7b47ff071b 100644 --- a/tests/cases/conformance/parser/ecmascript5/Statements/ContinueStatements/parser_continueTarget3.ts +++ b/tests/cases/conformance/parser/ecmascript5/Statements/ContinueStatements/parser_continueTarget3.ts @@ -1,3 +1,5 @@ +// @allowUnusedLabels: true + target1: target2: while (true) { diff --git a/tests/cases/conformance/parser/ecmascript5/Statements/ContinueStatements/parser_continueTarget4.ts b/tests/cases/conformance/parser/ecmascript5/Statements/ContinueStatements/parser_continueTarget4.ts index e00c222aa9c..5ba2bd69b11 100644 --- a/tests/cases/conformance/parser/ecmascript5/Statements/ContinueStatements/parser_continueTarget4.ts +++ b/tests/cases/conformance/parser/ecmascript5/Statements/ContinueStatements/parser_continueTarget4.ts @@ -1,3 +1,5 @@ +// @allowUnusedLabels: true + target1: target2: while (true) { diff --git a/tests/cases/conformance/parser/ecmascript5/Statements/LabeledStatements/parser_duplicateLabel3.ts b/tests/cases/conformance/parser/ecmascript5/Statements/LabeledStatements/parser_duplicateLabel3.ts index d4db9399ed2..d6add980447 100644 --- a/tests/cases/conformance/parser/ecmascript5/Statements/LabeledStatements/parser_duplicateLabel3.ts +++ b/tests/cases/conformance/parser/ecmascript5/Statements/LabeledStatements/parser_duplicateLabel3.ts @@ -1,3 +1,5 @@ +// @allowUnusedLabels: true + target: while (true) { function f() { diff --git a/tests/cases/conformance/parser/ecmascript5/Statements/LabeledStatements/parser_duplicateLabel4.ts b/tests/cases/conformance/parser/ecmascript5/Statements/LabeledStatements/parser_duplicateLabel4.ts index 2c62180a2ab..bf7ea5c22c6 100644 --- a/tests/cases/conformance/parser/ecmascript5/Statements/LabeledStatements/parser_duplicateLabel4.ts +++ b/tests/cases/conformance/parser/ecmascript5/Statements/LabeledStatements/parser_duplicateLabel4.ts @@ -1,3 +1,6 @@ +// @allowUnusedLabels: true +// @allowUnreachableCode: true + target: while (true) { } diff --git a/tests/cases/conformance/statements/breakStatements/switchBreakStatements.ts b/tests/cases/conformance/statements/breakStatements/switchBreakStatements.ts index f5ce6ffa52f..3080a6b38a8 100644 --- a/tests/cases/conformance/statements/breakStatements/switchBreakStatements.ts +++ b/tests/cases/conformance/statements/breakStatements/switchBreakStatements.ts @@ -1,3 +1,6 @@ +// @allowUnusedLabels: true +// @allowUnreachableCode: true + switch ('') { case 'a': break; diff --git a/tests/cases/conformance/statements/throwStatements/throwInEnclosingStatements.ts b/tests/cases/conformance/statements/throwStatements/throwInEnclosingStatements.ts index 4b9675f9d63..c5875327b50 100644 --- a/tests/cases/conformance/statements/throwStatements/throwInEnclosingStatements.ts +++ b/tests/cases/conformance/statements/throwStatements/throwInEnclosingStatements.ts @@ -1,3 +1,5 @@ +// @allowUnreachableCode: true + function fn(x) { throw x; } diff --git a/tests/cases/conformance/statements/throwStatements/throwStatements.ts b/tests/cases/conformance/statements/throwStatements/throwStatements.ts index 8d155cbc8cf..07c09da93fc 100644 --- a/tests/cases/conformance/statements/throwStatements/throwStatements.ts +++ b/tests/cases/conformance/statements/throwStatements/throwStatements.ts @@ -1,3 +1,5 @@ +// @allowUnreachableCode: true + // all legal interface I { From 55327781c2920d474f36fd9a3edaf9301e252283 Mon Sep 17 00:00:00 2001 From: Vladimir Matveev Date: Tue, 13 Oct 2015 13:06:43 -0700 Subject: [PATCH 065/227] suppress reachability errors in remaining tests --- .../typeofOperatorWithNumberType.errors.txt | 69 ------ .../typeofOperatorWithNumberType.symbols | 168 +++++++++++++ .../typeofOperatorWithNumberType.types | 233 ++++++++++++++++++ .../typeofOperatorWithNumberType.ts | 1 + 4 files changed, 402 insertions(+), 69 deletions(-) delete mode 100644 tests/baselines/reference/typeofOperatorWithNumberType.errors.txt create mode 100644 tests/baselines/reference/typeofOperatorWithNumberType.symbols create mode 100644 tests/baselines/reference/typeofOperatorWithNumberType.types diff --git a/tests/baselines/reference/typeofOperatorWithNumberType.errors.txt b/tests/baselines/reference/typeofOperatorWithNumberType.errors.txt deleted file mode 100644 index b84d3798ab0..00000000000 --- a/tests/baselines/reference/typeofOperatorWithNumberType.errors.txt +++ /dev/null @@ -1,69 +0,0 @@ -tests/cases/conformance/expressions/unaryOperators/typeofOperator/typeofOperatorWithNumberType.ts(50,1): error TS7028: Unused label. -tests/cases/conformance/expressions/unaryOperators/typeofOperator/typeofOperatorWithNumberType.ts(51,1): error TS7028: Unused label. -tests/cases/conformance/expressions/unaryOperators/typeofOperator/typeofOperatorWithNumberType.ts(52,1): error TS7028: Unused label. - - -==== tests/cases/conformance/expressions/unaryOperators/typeofOperator/typeofOperatorWithNumberType.ts (3 errors) ==== - // typeof operator on number type - var NUMBER: number; - var NUMBER1: number[] = [1, 2]; - - function foo(): number { return 1; } - - class A { - public a: number; - static foo() { return 1; } - } - module M { - export var n: number; - } - - var objA = new A(); - - // number type var - var ResultIsString1 = typeof NUMBER; - var ResultIsString2 = typeof NUMBER1; - - // number type literal - var ResultIsString3 = typeof 1; - var ResultIsString4 = typeof { x: 1, y: 2}; - var ResultIsString5 = typeof { x: 1, y: (n: number) => { return n; } }; - - // number type expressions - var ResultIsString6 = typeof objA.a; - var ResultIsString7 = typeof M.n; - var ResultIsString8 = typeof NUMBER1[0]; - var ResultIsString9 = typeof foo(); - var ResultIsString10 = typeof A.foo(); - var ResultIsString11 = typeof (NUMBER + NUMBER); - - // multiple typeof operators - var ResultIsString12 = typeof typeof NUMBER; - var ResultIsString13 = typeof typeof typeof (NUMBER + NUMBER); - - // miss assignment operators - typeof 1; - typeof NUMBER; - typeof NUMBER1; - typeof foo(); - typeof objA.a; - typeof M.n; - typeof objA.a, M.n; - - // use typeof in type query - var z: number; - var x: number[]; - z: typeof NUMBER; - ~ -!!! error TS7028: Unused label. - x: typeof NUMBER1; - ~ -!!! error TS7028: Unused label. - r: typeof foo; - ~ -!!! error TS7028: Unused label. - var y = { a: 1, b: 2 }; - z: typeof y.a; - z: typeof objA.a; - z: typeof A.foo; - z: typeof M.n; \ No newline at end of file diff --git a/tests/baselines/reference/typeofOperatorWithNumberType.symbols b/tests/baselines/reference/typeofOperatorWithNumberType.symbols new file mode 100644 index 00000000000..df49b7dccb6 --- /dev/null +++ b/tests/baselines/reference/typeofOperatorWithNumberType.symbols @@ -0,0 +1,168 @@ +=== tests/cases/conformance/expressions/unaryOperators/typeofOperator/typeofOperatorWithNumberType.ts === +// typeof operator on number type +var NUMBER: number; +>NUMBER : Symbol(NUMBER, Decl(typeofOperatorWithNumberType.ts, 1, 3)) + +var NUMBER1: number[] = [1, 2]; +>NUMBER1 : Symbol(NUMBER1, Decl(typeofOperatorWithNumberType.ts, 2, 3)) + +function foo(): number { return 1; } +>foo : Symbol(foo, Decl(typeofOperatorWithNumberType.ts, 2, 31)) + +class A { +>A : Symbol(A, Decl(typeofOperatorWithNumberType.ts, 4, 36)) + + public a: number; +>a : Symbol(a, Decl(typeofOperatorWithNumberType.ts, 6, 9)) + + static foo() { return 1; } +>foo : Symbol(A.foo, Decl(typeofOperatorWithNumberType.ts, 7, 21)) +} +module M { +>M : Symbol(M, Decl(typeofOperatorWithNumberType.ts, 9, 1)) + + export var n: number; +>n : Symbol(n, Decl(typeofOperatorWithNumberType.ts, 11, 14)) +} + +var objA = new A(); +>objA : Symbol(objA, Decl(typeofOperatorWithNumberType.ts, 14, 3)) +>A : Symbol(A, Decl(typeofOperatorWithNumberType.ts, 4, 36)) + +// number type var +var ResultIsString1 = typeof NUMBER; +>ResultIsString1 : Symbol(ResultIsString1, Decl(typeofOperatorWithNumberType.ts, 17, 3)) +>NUMBER : Symbol(NUMBER, Decl(typeofOperatorWithNumberType.ts, 1, 3)) + +var ResultIsString2 = typeof NUMBER1; +>ResultIsString2 : Symbol(ResultIsString2, Decl(typeofOperatorWithNumberType.ts, 18, 3)) +>NUMBER1 : Symbol(NUMBER1, Decl(typeofOperatorWithNumberType.ts, 2, 3)) + +// number type literal +var ResultIsString3 = typeof 1; +>ResultIsString3 : Symbol(ResultIsString3, Decl(typeofOperatorWithNumberType.ts, 21, 3)) + +var ResultIsString4 = typeof { x: 1, y: 2}; +>ResultIsString4 : Symbol(ResultIsString4, Decl(typeofOperatorWithNumberType.ts, 22, 3)) +>x : Symbol(x, Decl(typeofOperatorWithNumberType.ts, 22, 30)) +>y : Symbol(y, Decl(typeofOperatorWithNumberType.ts, 22, 36)) + +var ResultIsString5 = typeof { x: 1, y: (n: number) => { return n; } }; +>ResultIsString5 : Symbol(ResultIsString5, Decl(typeofOperatorWithNumberType.ts, 23, 3)) +>x : Symbol(x, Decl(typeofOperatorWithNumberType.ts, 23, 30)) +>y : Symbol(y, Decl(typeofOperatorWithNumberType.ts, 23, 36)) +>n : Symbol(n, Decl(typeofOperatorWithNumberType.ts, 23, 41)) +>n : Symbol(n, Decl(typeofOperatorWithNumberType.ts, 23, 41)) + +// number type expressions +var ResultIsString6 = typeof objA.a; +>ResultIsString6 : Symbol(ResultIsString6, Decl(typeofOperatorWithNumberType.ts, 26, 3)) +>objA.a : Symbol(A.a, Decl(typeofOperatorWithNumberType.ts, 6, 9)) +>objA : Symbol(objA, Decl(typeofOperatorWithNumberType.ts, 14, 3)) +>a : Symbol(A.a, Decl(typeofOperatorWithNumberType.ts, 6, 9)) + +var ResultIsString7 = typeof M.n; +>ResultIsString7 : Symbol(ResultIsString7, Decl(typeofOperatorWithNumberType.ts, 27, 3)) +>M.n : Symbol(M.n, Decl(typeofOperatorWithNumberType.ts, 11, 14)) +>M : Symbol(M, Decl(typeofOperatorWithNumberType.ts, 9, 1)) +>n : Symbol(M.n, Decl(typeofOperatorWithNumberType.ts, 11, 14)) + +var ResultIsString8 = typeof NUMBER1[0]; +>ResultIsString8 : Symbol(ResultIsString8, Decl(typeofOperatorWithNumberType.ts, 28, 3)) +>NUMBER1 : Symbol(NUMBER1, Decl(typeofOperatorWithNumberType.ts, 2, 3)) + +var ResultIsString9 = typeof foo(); +>ResultIsString9 : Symbol(ResultIsString9, Decl(typeofOperatorWithNumberType.ts, 29, 3)) +>foo : Symbol(foo, Decl(typeofOperatorWithNumberType.ts, 2, 31)) + +var ResultIsString10 = typeof A.foo(); +>ResultIsString10 : Symbol(ResultIsString10, Decl(typeofOperatorWithNumberType.ts, 30, 3)) +>A.foo : Symbol(A.foo, Decl(typeofOperatorWithNumberType.ts, 7, 21)) +>A : Symbol(A, Decl(typeofOperatorWithNumberType.ts, 4, 36)) +>foo : Symbol(A.foo, Decl(typeofOperatorWithNumberType.ts, 7, 21)) + +var ResultIsString11 = typeof (NUMBER + NUMBER); +>ResultIsString11 : Symbol(ResultIsString11, Decl(typeofOperatorWithNumberType.ts, 31, 3)) +>NUMBER : Symbol(NUMBER, Decl(typeofOperatorWithNumberType.ts, 1, 3)) +>NUMBER : Symbol(NUMBER, Decl(typeofOperatorWithNumberType.ts, 1, 3)) + +// multiple typeof operators +var ResultIsString12 = typeof typeof NUMBER; +>ResultIsString12 : Symbol(ResultIsString12, Decl(typeofOperatorWithNumberType.ts, 34, 3)) +>NUMBER : Symbol(NUMBER, Decl(typeofOperatorWithNumberType.ts, 1, 3)) + +var ResultIsString13 = typeof typeof typeof (NUMBER + NUMBER); +>ResultIsString13 : Symbol(ResultIsString13, Decl(typeofOperatorWithNumberType.ts, 35, 3)) +>NUMBER : Symbol(NUMBER, Decl(typeofOperatorWithNumberType.ts, 1, 3)) +>NUMBER : Symbol(NUMBER, Decl(typeofOperatorWithNumberType.ts, 1, 3)) + +// miss assignment operators +typeof 1; +typeof NUMBER; +>NUMBER : Symbol(NUMBER, Decl(typeofOperatorWithNumberType.ts, 1, 3)) + +typeof NUMBER1; +>NUMBER1 : Symbol(NUMBER1, Decl(typeofOperatorWithNumberType.ts, 2, 3)) + +typeof foo(); +>foo : Symbol(foo, Decl(typeofOperatorWithNumberType.ts, 2, 31)) + +typeof objA.a; +>objA.a : Symbol(A.a, Decl(typeofOperatorWithNumberType.ts, 6, 9)) +>objA : Symbol(objA, Decl(typeofOperatorWithNumberType.ts, 14, 3)) +>a : Symbol(A.a, Decl(typeofOperatorWithNumberType.ts, 6, 9)) + +typeof M.n; +>M.n : Symbol(M.n, Decl(typeofOperatorWithNumberType.ts, 11, 14)) +>M : Symbol(M, Decl(typeofOperatorWithNumberType.ts, 9, 1)) +>n : Symbol(M.n, Decl(typeofOperatorWithNumberType.ts, 11, 14)) + +typeof objA.a, M.n; +>objA.a : Symbol(A.a, Decl(typeofOperatorWithNumberType.ts, 6, 9)) +>objA : Symbol(objA, Decl(typeofOperatorWithNumberType.ts, 14, 3)) +>a : Symbol(A.a, Decl(typeofOperatorWithNumberType.ts, 6, 9)) +>M.n : Symbol(M.n, Decl(typeofOperatorWithNumberType.ts, 11, 14)) +>M : Symbol(M, Decl(typeofOperatorWithNumberType.ts, 9, 1)) +>n : Symbol(M.n, Decl(typeofOperatorWithNumberType.ts, 11, 14)) + +// use typeof in type query +var z: number; +>z : Symbol(z, Decl(typeofOperatorWithNumberType.ts, 47, 3)) + +var x: number[]; +>x : Symbol(x, Decl(typeofOperatorWithNumberType.ts, 48, 3)) + +z: typeof NUMBER; +>NUMBER : Symbol(NUMBER, Decl(typeofOperatorWithNumberType.ts, 1, 3)) + +x: typeof NUMBER1; +>NUMBER1 : Symbol(NUMBER1, Decl(typeofOperatorWithNumberType.ts, 2, 3)) + +r: typeof foo; +>foo : Symbol(foo, Decl(typeofOperatorWithNumberType.ts, 2, 31)) + +var y = { a: 1, b: 2 }; +>y : Symbol(y, Decl(typeofOperatorWithNumberType.ts, 52, 3)) +>a : Symbol(a, Decl(typeofOperatorWithNumberType.ts, 52, 9)) +>b : Symbol(b, Decl(typeofOperatorWithNumberType.ts, 52, 15)) + +z: typeof y.a; +>y.a : Symbol(a, Decl(typeofOperatorWithNumberType.ts, 52, 9)) +>y : Symbol(y, Decl(typeofOperatorWithNumberType.ts, 52, 3)) +>a : Symbol(a, Decl(typeofOperatorWithNumberType.ts, 52, 9)) + +z: typeof objA.a; +>objA.a : Symbol(A.a, Decl(typeofOperatorWithNumberType.ts, 6, 9)) +>objA : Symbol(objA, Decl(typeofOperatorWithNumberType.ts, 14, 3)) +>a : Symbol(A.a, Decl(typeofOperatorWithNumberType.ts, 6, 9)) + +z: typeof A.foo; +>A.foo : Symbol(A.foo, Decl(typeofOperatorWithNumberType.ts, 7, 21)) +>A : Symbol(A, Decl(typeofOperatorWithNumberType.ts, 4, 36)) +>foo : Symbol(A.foo, Decl(typeofOperatorWithNumberType.ts, 7, 21)) + +z: typeof M.n; +>M.n : Symbol(M.n, Decl(typeofOperatorWithNumberType.ts, 11, 14)) +>M : Symbol(M, Decl(typeofOperatorWithNumberType.ts, 9, 1)) +>n : Symbol(M.n, Decl(typeofOperatorWithNumberType.ts, 11, 14)) + diff --git a/tests/baselines/reference/typeofOperatorWithNumberType.types b/tests/baselines/reference/typeofOperatorWithNumberType.types new file mode 100644 index 00000000000..b80e6b1d4a8 --- /dev/null +++ b/tests/baselines/reference/typeofOperatorWithNumberType.types @@ -0,0 +1,233 @@ +=== tests/cases/conformance/expressions/unaryOperators/typeofOperator/typeofOperatorWithNumberType.ts === +// typeof operator on number type +var NUMBER: number; +>NUMBER : number + +var NUMBER1: number[] = [1, 2]; +>NUMBER1 : number[] +>[1, 2] : number[] +>1 : number +>2 : number + +function foo(): number { return 1; } +>foo : () => number +>1 : number + +class A { +>A : A + + public a: number; +>a : number + + static foo() { return 1; } +>foo : () => number +>1 : number +} +module M { +>M : typeof M + + export var n: number; +>n : number +} + +var objA = new A(); +>objA : A +>new A() : A +>A : typeof A + +// number type var +var ResultIsString1 = typeof NUMBER; +>ResultIsString1 : string +>typeof NUMBER : string +>NUMBER : number + +var ResultIsString2 = typeof NUMBER1; +>ResultIsString2 : string +>typeof NUMBER1 : string +>NUMBER1 : number[] + +// number type literal +var ResultIsString3 = typeof 1; +>ResultIsString3 : string +>typeof 1 : string +>1 : number + +var ResultIsString4 = typeof { x: 1, y: 2}; +>ResultIsString4 : string +>typeof { x: 1, y: 2} : string +>{ x: 1, y: 2} : { x: number; y: number; } +>x : number +>1 : number +>y : number +>2 : number + +var ResultIsString5 = typeof { x: 1, y: (n: number) => { return n; } }; +>ResultIsString5 : string +>typeof { x: 1, y: (n: number) => { return n; } } : string +>{ x: 1, y: (n: number) => { return n; } } : { x: number; y: (n: number) => number; } +>x : number +>1 : number +>y : (n: number) => number +>(n: number) => { return n; } : (n: number) => number +>n : number +>n : number + +// number type expressions +var ResultIsString6 = typeof objA.a; +>ResultIsString6 : string +>typeof objA.a : string +>objA.a : number +>objA : A +>a : number + +var ResultIsString7 = typeof M.n; +>ResultIsString7 : string +>typeof M.n : string +>M.n : number +>M : typeof M +>n : number + +var ResultIsString8 = typeof NUMBER1[0]; +>ResultIsString8 : string +>typeof NUMBER1[0] : string +>NUMBER1[0] : number +>NUMBER1 : number[] +>0 : number + +var ResultIsString9 = typeof foo(); +>ResultIsString9 : string +>typeof foo() : string +>foo() : number +>foo : () => number + +var ResultIsString10 = typeof A.foo(); +>ResultIsString10 : string +>typeof A.foo() : string +>A.foo() : number +>A.foo : () => number +>A : typeof A +>foo : () => number + +var ResultIsString11 = typeof (NUMBER + NUMBER); +>ResultIsString11 : string +>typeof (NUMBER + NUMBER) : string +>(NUMBER + NUMBER) : number +>NUMBER + NUMBER : number +>NUMBER : number +>NUMBER : number + +// multiple typeof operators +var ResultIsString12 = typeof typeof NUMBER; +>ResultIsString12 : string +>typeof typeof NUMBER : string +>typeof NUMBER : string +>NUMBER : number + +var ResultIsString13 = typeof typeof typeof (NUMBER + NUMBER); +>ResultIsString13 : string +>typeof typeof typeof (NUMBER + NUMBER) : string +>typeof typeof (NUMBER + NUMBER) : string +>typeof (NUMBER + NUMBER) : string +>(NUMBER + NUMBER) : number +>NUMBER + NUMBER : number +>NUMBER : number +>NUMBER : number + +// miss assignment operators +typeof 1; +>typeof 1 : string +>1 : number + +typeof NUMBER; +>typeof NUMBER : string +>NUMBER : number + +typeof NUMBER1; +>typeof NUMBER1 : string +>NUMBER1 : number[] + +typeof foo(); +>typeof foo() : string +>foo() : number +>foo : () => number + +typeof objA.a; +>typeof objA.a : string +>objA.a : number +>objA : A +>a : number + +typeof M.n; +>typeof M.n : string +>M.n : number +>M : typeof M +>n : number + +typeof objA.a, M.n; +>typeof objA.a, M.n : number +>typeof objA.a : string +>objA.a : number +>objA : A +>a : number +>M.n : number +>M : typeof M +>n : number + +// use typeof in type query +var z: number; +>z : number + +var x: number[]; +>x : number[] + +z: typeof NUMBER; +>z : any +>typeof NUMBER : string +>NUMBER : number + +x: typeof NUMBER1; +>x : any +>typeof NUMBER1 : string +>NUMBER1 : number[] + +r: typeof foo; +>r : any +>typeof foo : string +>foo : () => number + +var y = { a: 1, b: 2 }; +>y : { a: number; b: number; } +>{ a: 1, b: 2 } : { a: number; b: number; } +>a : number +>1 : number +>b : number +>2 : number + +z: typeof y.a; +>z : any +>typeof y.a : string +>y.a : number +>y : { a: number; b: number; } +>a : number + +z: typeof objA.a; +>z : any +>typeof objA.a : string +>objA.a : number +>objA : A +>a : number + +z: typeof A.foo; +>z : any +>typeof A.foo : string +>A.foo : () => number +>A : typeof A +>foo : () => number + +z: typeof M.n; +>z : any +>typeof M.n : string +>M.n : number +>M : typeof M +>n : number + diff --git a/tests/cases/conformance/expressions/unaryOperators/typeofOperator/typeofOperatorWithNumberType.ts b/tests/cases/conformance/expressions/unaryOperators/typeofOperator/typeofOperatorWithNumberType.ts index 06ac3e29784..81687e4f860 100644 --- a/tests/cases/conformance/expressions/unaryOperators/typeofOperator/typeofOperatorWithNumberType.ts +++ b/tests/cases/conformance/expressions/unaryOperators/typeofOperator/typeofOperatorWithNumberType.ts @@ -1,3 +1,4 @@ +// @allowUnusedLabels: true // typeof operator on number type var NUMBER: number; var NUMBER1: number[] = [1, 2]; From 1a36fce4c2304d87a6f49ba3ec580819b15a2722 Mon Sep 17 00:00:00 2001 From: Ryan Cavanaugh Date: Wed, 14 Oct 2015 17:36:03 -0700 Subject: [PATCH 066/227] JavaScript LS scaffolding + JS module inference --- lib/lib.core.d.ts | 16 + lib/lib.core.es6.d.ts | 16 + lib/lib.d.ts | 16 + lib/lib.es6.d.ts | 16 + lib/tsc.js | 1 + src/compiler/binder.ts | 65 ++- src/compiler/checker.ts | 83 +++- src/compiler/core.ts | 7 +- src/compiler/parser.ts | 17 +- src/compiler/program.ts | 25 +- src/compiler/types.ts | 7 +- src/compiler/utilities.ts | 60 ++- src/harness/fourslash.ts | 32 +- src/harness/harness.ts | 2 +- src/harness/harnessLanguageService.ts | 2 +- src/lib/core.d.ts | 16 + src/server/editorServices.ts | 9 +- src/services/services.ts | 452 +++++++++++------- src/services/shims.ts | 3 +- src/services/signatureHelp.ts | 2 +- .../getJavaScriptSyntacticDiagnostics1.ts | 19 - tests/cases/fourslash/javaScriptModules12.ts | 57 +++ tests/cases/fourslash/javaScriptModules13.ts | 29 ++ tests/cases/fourslash/javaScriptModules14.ts | 28 ++ tests/cases/fourslash/javaScriptModules15.ts | 27 ++ tests/cases/fourslash/javaScriptModules16.ts | 22 + tests/cases/fourslash/javaScriptModules17.ts | 18 + tests/cases/fourslash/javaScriptModules18.ts | 14 + tests/cases/unittests/moduleResolution.ts | 28 +- .../unittests/services/preProcessFile.ts | 149 +++++- tests/webTestServer.ts | 15 +- 31 files changed, 993 insertions(+), 260 deletions(-) delete mode 100644 tests/cases/fourslash/getJavaScriptSyntacticDiagnostics1.ts create mode 100644 tests/cases/fourslash/javaScriptModules12.ts create mode 100644 tests/cases/fourslash/javaScriptModules13.ts create mode 100644 tests/cases/fourslash/javaScriptModules14.ts create mode 100644 tests/cases/fourslash/javaScriptModules15.ts create mode 100644 tests/cases/fourslash/javaScriptModules16.ts create mode 100644 tests/cases/fourslash/javaScriptModules17.ts create mode 100644 tests/cases/fourslash/javaScriptModules18.ts diff --git a/lib/lib.core.d.ts b/lib/lib.core.d.ts index b588c9fdb77..c1a71dd8d1d 100644 --- a/lib/lib.core.d.ts +++ b/lib/lib.core.d.ts @@ -1198,6 +1198,22 @@ interface PromiseLike { then(onfulfilled?: (value: T) => TResult | PromiseLike, onrejected?: (reason: any) => void): PromiseLike; } + +declare namespace CommonJS { + export var require: Require; + + export var exports: any; + + interface Exports { } + interface Module { + exports: Exports; + } + + interface Require { + (moduleName: string): any; + } +} + interface ArrayLike { length: number; [n: number]: T; diff --git a/lib/lib.core.es6.d.ts b/lib/lib.core.es6.d.ts index fd115497f8a..b0d4120b4b9 100644 --- a/lib/lib.core.es6.d.ts +++ b/lib/lib.core.es6.d.ts @@ -1198,6 +1198,22 @@ interface PromiseLike { then(onfulfilled?: (value: T) => TResult | PromiseLike, onrejected?: (reason: any) => void): PromiseLike; } + +declare namespace CommonJS { + export var require: Require; + + export var exports: any; + + interface Exports { } + interface Module { + exports: Exports; + } + + interface Require { + (moduleName: string): any; + } +} + interface ArrayLike { length: number; [n: number]: T; diff --git a/lib/lib.d.ts b/lib/lib.d.ts index a65fc96e43f..450f79b36e9 100644 --- a/lib/lib.d.ts +++ b/lib/lib.d.ts @@ -1198,6 +1198,22 @@ interface PromiseLike { then(onfulfilled?: (value: T) => TResult | PromiseLike, onrejected?: (reason: any) => void): PromiseLike; } + +declare namespace CommonJS { + export var require: Require; + + export var exports: any; + + interface Exports { } + interface Module { + exports: Exports; + } + + interface Require { + (moduleName: string): any; + } +} + interface ArrayLike { length: number; [n: number]: T; diff --git a/lib/lib.es6.d.ts b/lib/lib.es6.d.ts index 75ba647a128..63e6a101fbc 100644 --- a/lib/lib.es6.d.ts +++ b/lib/lib.es6.d.ts @@ -1198,6 +1198,22 @@ interface PromiseLike { then(onfulfilled?: (value: T) => TResult | PromiseLike, onrejected?: (reason: any) => void): PromiseLike; } + +declare namespace CommonJS { + export var require: Require; + + export var exports: any; + + interface Exports { } + interface Module { + exports: Exports; + } + + interface Require { + (moduleName: string): any; + } +} + interface ArrayLike { length: number; [n: number]: T; diff --git a/lib/tsc.js b/lib/tsc.js index 3d2b7f3956a..a4c2586f041 100644 --- a/lib/tsc.js +++ b/lib/tsc.js @@ -650,6 +650,7 @@ var ts; } ts.fileExtensionIs = fileExtensionIs; ts.supportedExtensions = [".ts", ".tsx", ".d.ts"]; + ts.supportedJsExtensions = ts.supportedExtensions.concat(".js", ".jsx"); var extensionsToRemove = [".d.ts", ".ts", ".js", ".tsx", ".jsx"]; function removeFileExtension(path) { for (var _i = 0; _i < extensionsToRemove.length; _i++) { diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index c12a9afad62..4e0d5225f58 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -6,8 +6,8 @@ namespace ts { export const enum ModuleInstanceState { NonInstantiated = 0, - Instantiated = 1, - ConstEnumOnly = 2 + Instantiated = 1, + ConstEnumOnly = 2 } export function getModuleInstanceState(node: Node): ModuleInstanceState { @@ -90,6 +90,8 @@ namespace ts { let lastContainer: Node; let seenThisKeyword: boolean; + let isJavaScriptFile = isSourceFileJavaScript(file); + // If this file is an external module, then it is automatically in strict-mode according to // ES6. If it is not an external module, then we'll determine if it is in strict mode or // not depending on if we see "use strict" in certain places (or if we hit a class/namespace). @@ -167,6 +169,10 @@ namespace ts { case SyntaxKind.FunctionDeclaration: case SyntaxKind.ClassDeclaration: return node.flags & NodeFlags.Default ? "default" : undefined; + + case SyntaxKind.BinaryExpression: + Debug.assert(isModuleExportsAssignment(node)); + return "__jsExports"; } } @@ -779,7 +785,7 @@ namespace ts { return "__" + indexOf((node.parent).parameters, node); } - function bind(node: Node) { + function bind(node: Node): void { node.parent = parent; let savedInStrictMode = inStrictMode; @@ -851,9 +857,18 @@ namespace ts { function bindWorker(node: Node) { switch (node.kind) { + /* Strict mode checks */ case SyntaxKind.Identifier: return checkStrictModeIdentifier(node); case SyntaxKind.BinaryExpression: + if (isJavaScriptFile) { + if (isExportsPropertyAssignment(node)) { + bindExportsPropertyAssignment(node); + } + else if (isModuleExportsAssignment(node)) { + bindModuleExportsAssignment(node); + } + } return checkStrictModeBinaryExpression(node); case SyntaxKind.CatchClause: return checkStrictModeCatchClause(node); @@ -919,6 +934,16 @@ namespace ts { checkStrictModeFunctionName(node); let bindingName = (node).name ? (node).name.text : "__function"; return bindAnonymousDeclaration(node, SymbolFlags.Function, bindingName); + + case SyntaxKind.CallExpression: + // We're only inspecting call expressions to detect CommonJS modules, so we can skip + // this check if we've already seen the module indicator + if (isJavaScriptFile && !file.commonJsModuleIndicator) { + bindCallExpression(node); + } + break; + + // Members of classes, interfaces, and modules case SyntaxKind.ClassExpression: case SyntaxKind.ClassDeclaration: return bindClassLikeDeclaration(node); @@ -930,6 +955,8 @@ namespace ts { return bindEnumDeclaration(node); case SyntaxKind.ModuleDeclaration: return bindModuleDeclaration(node); + + // Imports and exports case SyntaxKind.ImportEqualsDeclaration: case SyntaxKind.NamespaceImport: case SyntaxKind.ImportSpecifier: @@ -949,10 +976,14 @@ namespace ts { function bindSourceFileIfExternalModule() { setExportContextFlag(file); if (isExternalModule(file)) { - bindAnonymousDeclaration(file, SymbolFlags.ValueModule, `"${removeFileExtension(file.fileName)}"`); + bindSourceFileAsExternalModule(); } } + function bindSourceFileAsExternalModule() { + bindAnonymousDeclaration(file, SymbolFlags.ValueModule, `"${removeFileExtension(file.fileName) }"`); + } + function bindExportAssignment(node: ExportAssignment) { if (!container.symbol || !container.symbol.exports) { // Export assignment in some sort of block construct @@ -985,6 +1016,32 @@ namespace ts { } } + function setCommonJsModuleIndicator(node: Node) { + if (!file.commonJsModuleIndicator) { + file.commonJsModuleIndicator = node; + bindSourceFileAsExternalModule(); + } + } + + function bindExportsPropertyAssignment(node: BinaryExpression) { + // When we create a property via 'exports.foo = bar', the 'exports.foo' property access + // expression is the declaration + setCommonJsModuleIndicator(node); + declareSymbol(file.symbol.exports, file.symbol, node.left, SymbolFlags.Property | SymbolFlags.Export, SymbolFlags.None); + } + + function bindModuleExportsAssignment(node: BinaryExpression) { + // 'module.exports = expr' assignment + setCommonJsModuleIndicator(node); + declareSymbol(file.symbol.exports, file.symbol, node, SymbolFlags.None, SymbolFlags.None); + } + + function bindCallExpression(node: CallExpression) { + if (isRequireCall(node)) { + setCommonJsModuleIndicator(node); + } + } + function bindClassLikeDeclaration(node: ClassLikeDeclaration) { if (node.kind === SyntaxKind.ClassDeclaration) { bindBlockScopedDeclaration(node, SymbolFlags.Class, SymbolFlags.ClassExcludes); diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index b13520cee2d..7e15f0a3ad0 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -160,6 +160,8 @@ namespace ts { let getGlobalPromiseConstructorLikeType: () => ObjectType; let getGlobalThenableType: () => ObjectType; + let cjsRequireType: Type; + let tupleTypes: Map = {}; let unionTypes: Map = {}; let intersectionTypes: Map = {}; @@ -362,7 +364,7 @@ namespace ts { } function isGlobalSourceFile(node: Node) { - return node.kind === SyntaxKind.SourceFile && !isExternalModule(node); + return node.kind === SyntaxKind.SourceFile && !isExternalOrCommonJsModule(node); } function getSymbol(symbols: SymbolTable, name: string, meaning: SymbolFlags): Symbol { @@ -478,7 +480,7 @@ namespace ts { } switch (location.kind) { case SyntaxKind.SourceFile: - if (!isExternalModule(location)) break; + if (!isExternalOrCommonJsModule(location)) break; case SyntaxKind.ModuleDeclaration: let moduleExports = getSymbolOfNode(location).exports; if (location.kind === SyntaxKind.SourceFile || @@ -993,6 +995,11 @@ namespace ts { if (moduleName === undefined) { return; } + + if (moduleName.indexOf("!") >= 0) { + moduleName = moduleName.substr(0, moduleName.indexOf("!")); + } + let isRelative = isExternalModuleNameRelative(moduleName); if (!isRelative) { let symbol = getSymbol(globals, "\"" + moduleName + "\"", SymbolFlags.ValueModule); @@ -1080,6 +1087,20 @@ namespace ts { visit(resolveExternalModuleName(node, (node).moduleSpecifier)); } } + + // CommonJS 'module.exports = expr' assignments + let commonJsModuleExports = symbol.exports["__jsExports"]; + if (commonJsModuleExports) { + for (var i = 0; i < commonJsModuleExports.declarations.length; i++) { + let properties = getPropertiesOfType(checkExpression((commonJsModuleExports.declarations[i]).right)); + if (i === 0) { + result = createSymbolTable(properties); + } + else { + mergeSymbolTable(result, createSymbolTable(properties)); + } + } + } } } } @@ -1203,7 +1224,7 @@ namespace ts { } switch (location.kind) { case SyntaxKind.SourceFile: - if (!isExternalModule(location)) { + if (!isExternalOrCommonJsModule(location)) { break; } case SyntaxKind.ModuleDeclaration: @@ -1385,7 +1406,7 @@ namespace ts { function hasExternalModuleSymbol(declaration: Node) { return (declaration.kind === SyntaxKind.ModuleDeclaration && (declaration).name.kind === SyntaxKind.StringLiteral) || - (declaration.kind === SyntaxKind.SourceFile && isExternalModule(declaration)); + (declaration.kind === SyntaxKind.SourceFile && isExternalOrCommonJsModule(declaration)); } function hasVisibleDeclarations(symbol: Symbol): SymbolVisibilityResult { @@ -2059,7 +2080,7 @@ namespace ts { } } else if (node.kind === SyntaxKind.SourceFile) { - return isExternalModule(node) ? node : undefined; + return isExternalOrCommonJsModule(node) ? node : undefined; } } Debug.fail("getContainingModule cant reach here"); @@ -2180,7 +2201,7 @@ namespace ts { case SyntaxKind.SourceFile: return true; - // Export assignements do not create name bindings outside the module + // Export assignments do not create name bindings outside the module case SyntaxKind.ExportAssignment: return false; @@ -2565,6 +2586,10 @@ namespace ts { if (declaration.kind === SyntaxKind.ExportAssignment) { return links.type = checkExpression((declaration).expression); } + // Handle exports.p = expr + if (declaration.kind === SyntaxKind.PropertyAccessExpression && declaration.parent.kind === SyntaxKind.BinaryExpression) { + return checkExpressionCached((declaration.parent).right); + } // Handle variable, parameter or property if (!pushTypeResolution(symbol, TypeSystemPropertyName.Type)) { return unknownType; @@ -3811,6 +3836,18 @@ namespace ts { return result; } + function resolveExternalModuleTypeByLiteral(name: StringLiteral) { + let moduleSym = resolveExternalModuleName(name, name); + if (moduleSym) { + let moduleSymSym = resolveExternalModuleSymbol(moduleSym); + if (moduleSymSym) { + return getTypeOfSymbol(moduleSymSym); + } + } + + return anyType; + } + function getReturnTypeOfSignature(signature: Signature): Type { if (!signature.resolvedReturnType) { if (!pushTypeResolution(signature, TypeSystemPropertyName.ResolvedReturnType)) { @@ -4174,11 +4211,15 @@ namespace ts { * getExportedTypeFromNamespace('JSX', 'Element') returns the JSX.Element type */ function getExportedTypeFromNamespace(namespace: string, name: string): Type { - let namespaceSymbol = getGlobalSymbol(namespace, SymbolFlags.Namespace, /*diagnosticMessage*/ undefined); - let typeSymbol = namespaceSymbol && getSymbol(namespaceSymbol.exports, name, SymbolFlags.Type); + let typeSymbol = getExportedSymbolFromNamespace(namespace, name); return typeSymbol && getDeclaredTypeOfSymbol(typeSymbol); } + function getExportedSymbolFromNamespace(namespace: string, name: string): Symbol { + let namespaceSymbol = getGlobalSymbol(namespace, SymbolFlags.Namespace, /*diagnosticMessage*/ undefined); + return namespaceSymbol && getSymbol(namespaceSymbol.exports, name, SymbolFlags.Type | SymbolFlags.Value); + } + function getGlobalESSymbolConstructorSymbol() { return globalESSymbolConstructorSymbol || (globalESSymbolConstructorSymbol = getGlobalValueSymbol("Symbol")); } @@ -9345,6 +9386,14 @@ namespace ts { return anyType; } } + + let exprType = checkExpression(node.expression); + if (exprType === cjsRequireType) { + if (node.arguments.length === 1 && node.arguments[0].kind === SyntaxKind.StringLiteral) { + return resolveExternalModuleTypeByLiteral(node.arguments[0]); + } + } + return getReturnTypeOfSignature(signature); } @@ -11965,7 +12014,7 @@ namespace ts { // In case of variable declaration, node.parent is variable statement so look at the variable statement's parent let parent = getDeclarationContainer(node); - if (parent.kind === SyntaxKind.SourceFile && isExternalModule(parent)) { + if (parent.kind === SyntaxKind.SourceFile && isExternalOrCommonJsModule(parent)) { // If the declaration happens to be in external module, report error that require and exports are reserved keywords error(name, Diagnostics.Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module, declarationNameToString(name), declarationNameToString(name)); @@ -14047,7 +14096,7 @@ namespace ts { forEach(node.statements, checkSourceElement); checkFunctionAndClassExpressionBodies(node); - if (isExternalModule(node)) { + if (isExternalOrCommonJsModule(node)) { checkExternalModuleExports(node); } @@ -14150,7 +14199,7 @@ namespace ts { switch (location.kind) { case SyntaxKind.SourceFile: - if (!isExternalModule(location)) { + if (!isExternalOrCommonJsModule(location)) { break; } case SyntaxKind.ModuleDeclaration: @@ -14881,16 +14930,24 @@ namespace ts { // Initialize global symbol table forEach(host.getSourceFiles(), file => { - if (!isExternalModule(file)) { + if (!isExternalOrCommonJsModule(file)) { mergeSymbolTable(globals, file.locals); } }); // Initialize special symbols + if (compilerOptions.allowNonTsExtensions) { + let req = getExportedSymbolFromNamespace("CommonJS", "require"); + if (req) { + globals["require"] = req; + } + } + getSymbolLinks(undefinedSymbol).type = undefinedType; getSymbolLinks(argumentsSymbol).type = getGlobalType("IArguments"); getSymbolLinks(unknownSymbol).type = unknownType; globals[undefinedSymbol.name] = undefinedSymbol; + // Initialize special types globalArrayType = getGlobalType("Array", /*arity*/ 1); globalObjectType = getGlobalType("Object"); @@ -14913,6 +14970,8 @@ namespace ts { getGlobalPromiseConstructorLikeType = memoize(() => getGlobalType("PromiseConstructorLike")); getGlobalThenableType = memoize(createThenableType); + cjsRequireType = getExportedTypeFromNamespace("CommonJS", "Require"); + // If we're in ES6 mode, load the TemplateStringsArray. // Otherwise, default to 'unknown' for the purposes of type checking in LS scenarios. if (languageVersion >= ScriptTarget.ES6) { diff --git a/src/compiler/core.ts b/src/compiler/core.ts index 307a1ddd502..6f0aa363068 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -726,12 +726,7 @@ namespace ts { * List of supported extensions in order of file resolution precedence. */ export const supportedExtensions = [".ts", ".tsx", ".d.ts"]; - /** - * List of extensions that will be used to look for external modules. - * This list is kept separate from supportedExtensions to for cases when we'll allow to include .js files in compilation, - * but still would like to load only TypeScript files as modules - */ - export const moduleFileExtensions = supportedExtensions; + export const supportedJsExtensions = supportedExtensions.concat(".js", ".jsx"); const extensionsToRemove = [".d.ts", ".ts", ".js", ".tsx", ".jsx"]; export function removeFileExtension(path: string): string { diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 1551706a337..b477724475f 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -527,7 +527,8 @@ namespace ts { let parseErrorBeforeNextFinishedNode = false; export function parseSourceFile(fileName: string, _sourceText: string, languageVersion: ScriptTarget, _syntaxCursor: IncrementalParser.SyntaxCursor, setParentNodes?: boolean): SourceFile { - initializeState(fileName, _sourceText, languageVersion, _syntaxCursor); + const isJavaScriptFile = hasJavaScriptFileExtension(fileName) || _sourceText.lastIndexOf("// @language=javascript", 0) === 0; + initializeState(fileName, _sourceText, languageVersion, isJavaScriptFile, _syntaxCursor); let result = parseSourceFileWorker(fileName, languageVersion, setParentNodes); @@ -536,7 +537,7 @@ namespace ts { return result; } - function initializeState(fileName: string, _sourceText: string, languageVersion: ScriptTarget, _syntaxCursor: IncrementalParser.SyntaxCursor) { + function initializeState(fileName: string, _sourceText: string, languageVersion: ScriptTarget, isJavaScriptFile: boolean, _syntaxCursor: IncrementalParser.SyntaxCursor) { sourceText = _sourceText; syntaxCursor = _syntaxCursor; @@ -546,7 +547,7 @@ namespace ts { identifierCount = 0; nodeCount = 0; - contextFlags = isJavaScript(fileName) ? ParserContextFlags.JavaScriptFile : ParserContextFlags.None; + contextFlags = isJavaScriptFile ? ParserContextFlags.JavaScriptFile : ParserContextFlags.None; parseErrorBeforeNextFinishedNode = false; // Initialize and prime the scanner before parsing the source elements. @@ -572,6 +573,10 @@ namespace ts { function parseSourceFileWorker(fileName: string, languageVersion: ScriptTarget, setParentNodes: boolean): SourceFile { sourceFile = createSourceFile(fileName, languageVersion); + if (contextFlags & ParserContextFlags.JavaScriptFile) { + sourceFile.parserContextFlags = ParserContextFlags.JavaScriptFile; + } + // Prime the scanner. token = nextToken(); processReferenceComments(sourceFile); @@ -594,7 +599,7 @@ namespace ts { // If this is a javascript file, proactively see if we can get JSDoc comments for // relevant nodes in the file. We'll use these to provide typing informaion if they're // available. - if (isJavaScript(fileName)) { + if (isSourceFileJavaScript(sourceFile)) { addJSDocComments(); } @@ -5486,7 +5491,7 @@ namespace ts { } export function parseJSDocTypeExpressionForTests(content: string, start: number, length: number) { - initializeState("file.js", content, ScriptTarget.Latest, /*_syntaxCursor:*/ undefined); + initializeState("file.js", content, ScriptTarget.Latest, /*isJavaScriptFile*/ true, /*_syntaxCursor:*/ undefined); let jsDocTypeExpression = parseJSDocTypeExpression(start, length); let diagnostics = parseDiagnostics; clearState(); @@ -5806,7 +5811,7 @@ namespace ts { } export function parseIsolatedJSDocComment(content: string, start: number, length: number) { - initializeState("file.js", content, ScriptTarget.Latest, /*_syntaxCursor:*/ undefined); + initializeState("file.js", content, ScriptTarget.Latest, /*isJavaScriptFile*/ true, /*_syntaxCursor:*/ undefined); let jsDocComment = parseJSDocComment(/*parent:*/ undefined, start, length); let diagnostics = parseDiagnostics; clearState(); diff --git a/src/compiler/program.ts b/src/compiler/program.ts index 86719ff30b4..08fd94c60d3 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -70,7 +70,7 @@ namespace ts { } function loadNodeModuleFromFile(candidate: string, failedLookupLocation: string[], host: ModuleResolutionHost): string { - return forEach(moduleFileExtensions, tryLoad); + return forEach(supportedJsExtensions, tryLoad); function tryLoad(ext: string): string { let fileName = fileExtensionIs(candidate, ext) ? candidate : candidate + ext; @@ -162,9 +162,10 @@ namespace ts { let failedLookupLocations: string[] = []; let referencedSourceFile: string; + let extensions = compilerOptions.allowNonTsExtensions ? supportedJsExtensions : supportedExtensions; while (true) { searchName = normalizePath(combinePaths(searchPath, moduleName)); - referencedSourceFile = forEach(supportedExtensions, extension => { + referencedSourceFile = forEach(extensions, extension => { if (extension === ".tsx" && !compilerOptions.jsx) { // resolve .tsx files only if jsx support is enabled // 'logical not' handles both undefined and None cases @@ -684,6 +685,8 @@ namespace ts { return; } + let isJavaScriptFile = isSourceFileJavaScript(file); + let imports: LiteralExpression[]; for (let node of file.statements) { collect(node, /* allowRelativeModuleNames */ true); @@ -708,6 +711,20 @@ namespace ts { (imports || (imports = [])).push(moduleNameExpr); } break; + case SyntaxKind.CallExpression: + if (isJavaScriptFile && isRequireCall(node)) { + + let jsImports = (node).arguments; + if (jsImports) { + imports = (imports || []); + for (var i = 0; i < jsImports.length; i++) { + if (jsImports[i].kind === SyntaxKind.StringLiteral) { + imports.push(jsImports[i]); + } + } + } + } + break; case SyntaxKind.ModuleDeclaration: if ((node).name.kind === SyntaxKind.StringLiteral && (node.flags & NodeFlags.Ambient || isDeclarationFile(file))) { // TypeScript 1.0 spec (April 2014): 12.1.6 @@ -724,6 +741,10 @@ namespace ts { } break; } + + if (isSourceFileJavaScript(file)) { + forEachChild(node, node => collect(node, allowRelativeModuleNames)); + } } } diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 6e5528b8217..a1665d081ae 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -764,7 +764,8 @@ namespace ts { expression?: Expression; } - export interface BinaryExpression extends Expression { + // Binary expressions can be declarations if they are 'exports.foo = bar' expressions in JS files + export interface BinaryExpression extends Expression, Declaration { left: Expression; operatorToken: Node; right: Expression; @@ -825,7 +826,7 @@ namespace ts { properties: NodeArray; } - export interface PropertyAccessExpression extends MemberExpression { + export interface PropertyAccessExpression extends MemberExpression, Declaration { expression: LeftHandSideExpression; dotToken: Node; name: Identifier; @@ -1274,6 +1275,8 @@ namespace ts { // The first node that causes this file to be an external module /* @internal */ externalModuleIndicator: Node; + // The first node that causes this file to be a CommonJS module + /* @internal */ commonJsModuleIndicator: Node; /* @internal */ isDefaultLib: boolean; /* @internal */ identifiers: Map; diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 2a16c2c71fb..c5dfcf8947e 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -362,6 +362,10 @@ namespace ts { return file.externalModuleIndicator !== undefined; } + export function isExternalOrCommonJsModule(file: SourceFile): boolean { + return (file.externalModuleIndicator || file.commonJsModuleIndicator) !== undefined; + } + export function isDeclarationFile(file: SourceFile): boolean { return (file.flags & NodeFlags.DeclarationFile) !== 0; } @@ -1031,6 +1035,56 @@ namespace ts { return node.kind === SyntaxKind.ImportEqualsDeclaration && (node).moduleReference.kind !== SyntaxKind.ExternalModuleReference; } + export function isSourceFileJavaScript(file: SourceFile): boolean { + return isInJavaScriptFile(file); + } + + function isInJavaScriptFile(node: Node): boolean { + return node && !!(node.parserContextFlags & ParserContextFlags.JavaScriptFile); + } + + /** + * Returns true if the node is a CallExpression to the identifier 'require' with + * exactly one argument. + * This function does not test if the node is in a JavaScript file or not. + */ + export function isRequireCall(expression: Node): expression is CallExpression { + // of the form 'require("name")' + return expression.kind === SyntaxKind.CallExpression && + (expression).expression.kind === SyntaxKind.Identifier && + ((expression).expression).text === "require" && + (expression).arguments.length === 1; + } + + /** + * Returns true if the node is an assignment to a property on the identifier 'exports'. + * This function does not test if the node is in a JavaScript file or not. + */ + export function isExportsPropertyAssignment(expression: Node): boolean { + // of the form 'exports.name = expr' where 'name' and 'expr' are arbitrary + return isInJavaScriptFile(expression) && + (expression.kind === SyntaxKind.BinaryExpression) && + ((expression).operatorToken.kind === SyntaxKind.EqualsToken) && + ((expression).left.kind === SyntaxKind.PropertyAccessExpression) && + (((expression).left).expression.kind === SyntaxKind.Identifier) && + (((((expression).left).expression)).text === "exports"); + } + + /** + * Returns true if the node is an assignment to the property access expression 'module.exports'. + * This function does not test if the node is in a JavaScript file or not. + */ + export function isModuleExportsAssignment(expression: Node): boolean { + // of the form 'module.exports = expr' where 'expr' is arbitrary + return isInJavaScriptFile(expression) && + (expression.kind === SyntaxKind.BinaryExpression) && + ((expression).operatorToken.kind === SyntaxKind.EqualsToken) && + ((expression).left.kind === SyntaxKind.PropertyAccessExpression) && + (((expression).left).expression.kind === SyntaxKind.Identifier) && + (((((expression).left).expression)).text === "module") && + (((expression).left).name.text === "exports"); + } + export function getExternalModuleName(node: Node): Expression { if (node.kind === SyntaxKind.ImportDeclaration) { return (node).moduleSpecifier; @@ -2083,12 +2137,12 @@ namespace ts { return symbol && symbol.valueDeclaration && (symbol.valueDeclaration.flags & NodeFlags.Default) ? symbol.valueDeclaration.localSymbol : undefined; } - export function isJavaScript(fileName: string) { - return fileExtensionIs(fileName, ".js"); + export function hasJavaScriptFileExtension(fileName: string) { + return fileExtensionIs(fileName, ".js") || fileExtensionIs(fileName, ".jsx"); } export function isTsx(fileName: string) { - return fileExtensionIs(fileName, ".tsx"); + return fileExtensionIs(fileName, ".tsx") || fileExtensionIs(fileName, ".jsx"); } /** diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts index 457ece7e132..dd2dde6989c 100644 --- a/src/harness/fourslash.ts +++ b/src/harness/fourslash.ts @@ -223,10 +223,22 @@ namespace FourSlash { // Add input file which has matched file name with the given reference-file path. // This is necessary when resolveReference flag is specified - private addMatchedInputFile(referenceFilePath: string) { - let inputFile = this.inputFiles[referenceFilePath]; - if (inputFile && !Harness.isLibraryFile(referenceFilePath)) { - this.languageServiceAdapterHost.addScript(referenceFilePath, inputFile); + private addMatchedInputFile(referenceFilePath: string, extensions: string[]) { + let inputFiles = this.inputFiles; + let languageServiceAdapterHost = this.languageServiceAdapterHost; + if (!extensions) { + tryAdd(referenceFilePath); + } + else { + tryAdd(referenceFilePath) || ts.forEach(extensions, ext => tryAdd(referenceFilePath + ext)); + } + + function tryAdd(path: string) { + let inputFile = inputFiles[path]; + if (inputFile && !Harness.isLibraryFile(path)) { + languageServiceAdapterHost.addScript(path, inputFile); + return true; + } } } @@ -280,15 +292,15 @@ namespace FourSlash { ts.forEach(referencedFiles, referenceFile => { // Fourslash insert tests/cases/fourslash into inputFile.unitName so we will properly append the same base directory to refFile path let referenceFilePath = this.basePath + "/" + referenceFile.fileName; - this.addMatchedInputFile(referenceFilePath); + this.addMatchedInputFile(referenceFilePath, /* extensions */ undefined); }); // Add import files into language-service host ts.forEach(importedFiles, importedFile => { // Fourslash insert tests/cases/fourslash into inputFile.unitName and import statement doesn't require ".ts" // so convert them before making appropriate comparison - let importedFilePath = this.basePath + "/" + importedFile.fileName + ".ts"; - this.addMatchedInputFile(importedFilePath); + let importedFilePath = this.basePath + "/" + importedFile.fileName; + this.addMatchedInputFile(importedFilePath, compilationOptions.allowNonTsExtensions ? ts.supportedJsExtensions : ts.supportedExtensions); }); // Check if no-default-lib flag is false and if so add default library @@ -2257,15 +2269,15 @@ namespace FourSlash { let details = this.getCompletionEntryDetails(item.name); if (documentation !== undefined) { - assert.equal(ts.displayPartsToString(details.documentation), documentation, assertionMessage("completion item documentation")); + assert.equal(ts.displayPartsToString(details.documentation), documentation, assertionMessage("completion item documentation for " + name)); } if (text !== undefined) { - assert.equal(ts.displayPartsToString(details.displayParts), text, assertionMessage("completion item detail text")); + assert.equal(ts.displayPartsToString(details.displayParts), text, assertionMessage("completion item detail text for " + name)); } } if (kind !== undefined) { - assert.equal(item.kind, kind, assertionMessage("completion item kind")); + assert.equal(item.kind, kind, assertionMessage("completion item kind for " + name)); } return; diff --git a/src/harness/harness.ts b/src/harness/harness.ts index a37b647a124..91897493fd9 100644 --- a/src/harness/harness.ts +++ b/src/harness/harness.ts @@ -211,7 +211,7 @@ namespace Utils { return isNodeOrArray(v) ? serializeNode(v) : v; }, " "); - function getKindName(k: number | string): string { + function getKindName(k: number|string): string { if (typeof k === "string") { return k; } diff --git a/src/harness/harnessLanguageService.ts b/src/harness/harnessLanguageService.ts index dfde2bd1c08..688b7f0b906 100644 --- a/src/harness/harnessLanguageService.ts +++ b/src/harness/harnessLanguageService.ts @@ -197,7 +197,7 @@ namespace Harness.LanguageService { getHost() { return this.host; } getLanguageService(): ts.LanguageService { return ts.createLanguageService(this.host); } getClassifier(): ts.Classifier { return ts.createClassifier(); } - getPreProcessedFileInfo(fileName: string, fileContents: string): ts.PreProcessedFileInfo { return ts.preProcessFile(fileContents); } + getPreProcessedFileInfo(fileName: string, fileContents: string): ts.PreProcessedFileInfo { return ts.preProcessFile(fileContents, /* readImportFiles */ true, ts.hasJavaScriptFileExtension(fileName)); } } /// Shim adapter diff --git a/src/lib/core.d.ts b/src/lib/core.d.ts index 7259ff5081c..86dee00638d 100644 --- a/src/lib/core.d.ts +++ b/src/lib/core.d.ts @@ -1183,6 +1183,22 @@ interface PromiseLike { then(onfulfilled?: (value: T) => TResult | PromiseLike, onrejected?: (reason: any) => void): PromiseLike; } + +declare namespace CommonJS { + export var require: Require; + + export var exports: any; + + interface Exports { } + interface Module { + exports: Exports; + } + + interface Require { + (moduleName: string): any; + } +} + interface ArrayLike { length: number; [n: number]: T; diff --git a/src/server/editorServices.ts b/src/server/editorServices.ts index 436b97821cc..8ea216eefe6 100644 --- a/src/server/editorServices.ts +++ b/src/server/editorServices.ts @@ -361,6 +361,10 @@ namespace ts.server { openRefCount = 0; constructor(public projectService: ProjectService, public projectOptions?: ProjectOptions) { + if(projectOptions && projectOptions.files){ + // If files are listed explicitly, allow all extensions + projectOptions.compilerOptions.allowNonTsExtensions = true; + } this.compilerService = new CompilerService(this, projectOptions && projectOptions.compilerOptions); } @@ -449,6 +453,7 @@ namespace ts.server { setProjectOptions(projectOptions: ProjectOptions) { this.projectOptions = projectOptions; if (projectOptions.compilerOptions) { + projectOptions.compilerOptions.allowNonTsExtensions = true; this.compilerService.setCompilerOptions(projectOptions.compilerOptions); } } @@ -1156,7 +1161,9 @@ namespace ts.server { this.setCompilerOptions(opt); } else { - this.setCompilerOptions(ts.getDefaultCompilerOptions()); + var defaultOpts = ts.getDefaultCompilerOptions(); + defaultOpts.allowNonTsExtensions = true; + this.setCompilerOptions(defaultOpts); } this.languageService = ts.createLanguageService(this.host, this.documentRegistry); this.classifier = ts.createClassifier(); diff --git a/src/services/services.ts b/src/services/services.ts index 15c6e3df56f..a6611a3d39a 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -794,6 +794,7 @@ namespace ts { public isDefaultLib: boolean; public hasNoDefaultLib: boolean; public externalModuleIndicator: Node; // The first node that causes this file to be an external module + public commonJsModuleIndicator: Node; // The first node that causes this file to be a CommonJS module public nodeCount: number; public identifierCount: number; public symbolCount: number; @@ -2108,7 +2109,7 @@ namespace ts { }; } - export function preProcessFile(sourceText: string, readImportFiles = true): PreProcessedFileInfo { + export function preProcessFile(sourceText: string, readImportFiles = true, detectJavaScriptImports = false): PreProcessedFileInfo { let referencedFiles: FileReference[] = []; let importedFiles: FileReference[] = []; let ambientExternalModules: string[]; @@ -2146,9 +2147,239 @@ namespace ts { }); } - function processImport(): void { + /** + * Returns true if at least one token was consumed from the stream + */ + function tryConsumeDeclare(): boolean { + let token = scanner.getToken(); + if (token === SyntaxKind.DeclareKeyword) { + // declare module "mod" + token = scanner.scan(); + if (token === SyntaxKind.ModuleKeyword) { + token = scanner.scan(); + if (token === SyntaxKind.StringLiteral) { + recordAmbientExternalModule(); + } + } + return true; + } + + return false; + } + + /** + * Returns true if at least one token was consumed from the stream + */ + function tryConsumeImport(): boolean { + let token = scanner.getToken(); + if (token === SyntaxKind.ImportKeyword) { + token = scanner.scan(); + if (token === SyntaxKind.StringLiteral) { + // import "mod"; + recordModuleName(); + return true; + } + else { + if (token === SyntaxKind.Identifier || isKeyword(token)) { + token = scanner.scan(); + if (token === SyntaxKind.FromKeyword) { + token = scanner.scan(); + if (token === SyntaxKind.StringLiteral) { + // import d from "mod"; + recordModuleName(); + return true; + } + } + else if (token === SyntaxKind.EqualsToken) { + if (tryConsumeRequireCall(/* skipCurrentToken */ true)) { + return true; + } + } + else if (token === SyntaxKind.CommaToken) { + // consume comma and keep going + token = scanner.scan(); + } + else { + // unknown syntax + return true; + } + } + + if (token === SyntaxKind.OpenBraceToken) { + token = scanner.scan(); + // consume "{ a as B, c, d as D}" clauses + // make sure that it stops on EOF + while (token !== SyntaxKind.CloseBraceToken && token !== SyntaxKind.EndOfFileToken) { + token = scanner.scan(); + } + + if (token === SyntaxKind.CloseBraceToken) { + token = scanner.scan(); + if (token === SyntaxKind.FromKeyword) { + token = scanner.scan(); + if (token === SyntaxKind.StringLiteral) { + // import {a as A} from "mod"; + // import d, {a, b as B} from "mod" + recordModuleName(); + } + } + } + } + else if (token === SyntaxKind.AsteriskToken) { + token = scanner.scan(); + if (token === SyntaxKind.AsKeyword) { + token = scanner.scan(); + if (token === SyntaxKind.Identifier || isKeyword(token)) { + token = scanner.scan(); + if (token === SyntaxKind.FromKeyword) { + token = scanner.scan(); + if (token === SyntaxKind.StringLiteral) { + // import * as NS from "mod" + // import d, * as NS from "mod" + recordModuleName(); + } + } + } + } + } + } + + return true; + } + + return false; + } + + function tryConsumeExport(): boolean { + let token = scanner.getToken(); + if (token === SyntaxKind.ExportKeyword) { + token = scanner.scan(); + if (token === SyntaxKind.OpenBraceToken) { + token = scanner.scan(); + // consume "{ a as B, c, d as D}" clauses + // make sure it stops on EOF + while (token !== SyntaxKind.CloseBraceToken && token !== SyntaxKind.EndOfFileToken) { + token = scanner.scan(); + } + + if (token === SyntaxKind.CloseBraceToken) { + token = scanner.scan(); + if (token === SyntaxKind.FromKeyword) { + token = scanner.scan(); + if (token === SyntaxKind.StringLiteral) { + // export {a as A} from "mod"; + // export {a, b as B} from "mod" + recordModuleName(); + } + } + } + } + else if (token === SyntaxKind.AsteriskToken) { + token = scanner.scan(); + if (token === SyntaxKind.FromKeyword) { + token = scanner.scan(); + if (token === SyntaxKind.StringLiteral) { + // export * from "mod" + recordModuleName(); + } + } + } + else if (token === SyntaxKind.ImportKeyword) { + token = scanner.scan(); + if (token === SyntaxKind.Identifier || isKeyword(token)) { + token = scanner.scan(); + if (token === SyntaxKind.EqualsToken) { + if (tryConsumeRequireCall(/* skipCurrentToken */ true)) { + return true; + } + } + } + } + + return true; + } + + return false; + } + + function tryConsumeRequireCall(skipCurrentToken: boolean): boolean { + let token = skipCurrentToken ? scanner.scan() : scanner.getToken(); + if (token === SyntaxKind.RequireKeyword) { + token = scanner.scan(); + if (token === SyntaxKind.OpenParenToken) { + token = scanner.scan(); + if (token === SyntaxKind.StringLiteral) { + // require("mod"); + recordModuleName(); + } + } + return true; + } + return false; + } + + function tryConsumeDefine(): boolean { + let token = scanner.getToken(); + if (token === SyntaxKind.Identifier && scanner.getTokenValue() === "define") { + token = scanner.scan(); + if (token !== SyntaxKind.OpenParenToken) { + return true; + } + + token = scanner.scan(); + if (token === SyntaxKind.StringLiteral) { + // looks like define ("modname", ... - skip string literal and comma + token = scanner.scan(); + if (token === SyntaxKind.CommaToken) { + token = scanner.scan(); + } + else { + // unexpected token + return true; + } + } + + // should be start of dependency list + if (token !== SyntaxKind.OpenBracketToken) { + return true; + } + + // skip open bracket + token = scanner.scan(); + let i = 0; + // scan until ']' or EOF + while (token !== SyntaxKind.CloseBracketToken && token !== SyntaxKind.EndOfFileToken) { + // record string literals as module names + if (token === SyntaxKind.StringLiteral) { + const moduleName = scanner.getTokenValue(); + // record first item in the list only if its name is not "require" + // record second item in the list only if its name is not "exports" + // record third item in the list only if its name is not "module" + // record all other items in the list unconditionally + const shouldRecordName = + i === 0 + ? moduleName !== "require" + : i === 1 + ? moduleName !== "exports" + : i !== 2 || moduleName !== "module"; + + if (shouldRecordName) { + recordModuleName(); + } + i++; + } + + token = scanner.scan(); + } + return true; + + } + return false; + } + + function processImports(): void { scanner.setText(sourceText); - let token = scanner.scan(); + scanner.scan(); // Look for: // import "mod"; // import d from "mod" @@ -2160,157 +2391,30 @@ namespace ts { // export * from "mod" // export {a as b} from "mod" // export import i = require("mod") + // (for JavaScript files) require("mod") - while (token !== SyntaxKind.EndOfFileToken) { - if (token === SyntaxKind.DeclareKeyword) { - // declare module "mod" - token = scanner.scan(); - if (token === SyntaxKind.ModuleKeyword) { - token = scanner.scan(); - if (token === SyntaxKind.StringLiteral) { - recordAmbientExternalModule(); - continue; - } - } + while (true) { + if (scanner.getToken() === SyntaxKind.EndOfFileToken) { + break; } - else if (token === SyntaxKind.ImportKeyword) { - token = scanner.scan(); - if (token === SyntaxKind.StringLiteral) { - // import "mod"; - recordModuleName(); - continue; - } - else { - if (token === SyntaxKind.Identifier || isKeyword(token)) { - token = scanner.scan(); - if (token === SyntaxKind.FromKeyword) { - token = scanner.scan(); - if (token === SyntaxKind.StringLiteral) { - // import d from "mod"; - recordModuleName(); - continue - } - } - else if (token === SyntaxKind.EqualsToken) { - token = scanner.scan(); - if (token === SyntaxKind.RequireKeyword) { - token = scanner.scan(); - if (token === SyntaxKind.OpenParenToken) { - token = scanner.scan(); - if (token === SyntaxKind.StringLiteral) { - // import i = require("mod"); - recordModuleName(); - continue; - } - } - } - } - else if (token === SyntaxKind.CommaToken) { - // consume comma and keep going - token = scanner.scan(); - } - else { - // unknown syntax - continue; - } - } - if (token === SyntaxKind.OpenBraceToken) { - token = scanner.scan(); - // consume "{ a as B, c, d as D}" clauses - while (token !== SyntaxKind.CloseBraceToken) { - token = scanner.scan(); - } - - if (token === SyntaxKind.CloseBraceToken) { - token = scanner.scan(); - if (token === SyntaxKind.FromKeyword) { - token = scanner.scan(); - if (token === SyntaxKind.StringLiteral) { - // import {a as A} from "mod"; - // import d, {a, b as B} from "mod" - recordModuleName(); - } - } - } - } - else if (token === SyntaxKind.AsteriskToken) { - token = scanner.scan(); - if (token === SyntaxKind.AsKeyword) { - token = scanner.scan(); - if (token === SyntaxKind.Identifier || isKeyword(token)) { - token = scanner.scan(); - if (token === SyntaxKind.FromKeyword) { - token = scanner.scan(); - if (token === SyntaxKind.StringLiteral) { - // import * as NS from "mod" - // import d, * as NS from "mod" - recordModuleName(); - } - } - } - } - } - } + // check if at least one of alternative have moved scanner forward + if (tryConsumeDeclare() || + tryConsumeImport() || + tryConsumeExport() || + (detectJavaScriptImports && (tryConsumeRequireCall(/* skipCurrentToken */ false) || tryConsumeDefine()))) { + continue; } - else if (token === SyntaxKind.ExportKeyword) { - token = scanner.scan(); - if (token === SyntaxKind.OpenBraceToken) { - token = scanner.scan(); - // consume "{ a as B, c, d as D}" clauses - while (token !== SyntaxKind.CloseBraceToken) { - token = scanner.scan(); - } - - if (token === SyntaxKind.CloseBraceToken) { - token = scanner.scan(); - if (token === SyntaxKind.FromKeyword) { - token = scanner.scan(); - if (token === SyntaxKind.StringLiteral) { - // export {a as A} from "mod"; - // export {a, b as B} from "mod" - recordModuleName(); - } - } - } - } - else if (token === SyntaxKind.AsteriskToken) { - token = scanner.scan(); - if (token === SyntaxKind.FromKeyword) { - token = scanner.scan(); - if (token === SyntaxKind.StringLiteral) { - // export * from "mod" - recordModuleName(); - } - } - } - else if (token === SyntaxKind.ImportKeyword) { - token = scanner.scan(); - if (token === SyntaxKind.Identifier || isKeyword(token)) { - token = scanner.scan(); - if (token === SyntaxKind.EqualsToken) { - token = scanner.scan(); - if (token === SyntaxKind.RequireKeyword) { - token = scanner.scan(); - if (token === SyntaxKind.OpenParenToken) { - token = scanner.scan(); - if (token === SyntaxKind.StringLiteral) { - // export import i = require("mod"); - recordModuleName(); - } - } - } - } - } - } + else { + scanner.scan(); } - token = scanner.scan(); } + scanner.setText(undefined); } if (readImportFiles) { - processImport(); + processImports(); } processTripleSlashDirectives(); return { referencedFiles, importedFiles, isLibFile: isNoDefaultLib, ambientExternalModules }; @@ -2797,7 +2901,7 @@ namespace ts { // For JavaScript files, we don't want to report the normal typescript semantic errors. // Instead, we just report errors for using TypeScript-only constructs from within a // JavaScript file. - if (isJavaScript(fileName)) { + if (isSourceFileJavaScript(targetSourceFile)) { return getJavaScriptSemanticDiagnostics(targetSourceFile); } @@ -3036,7 +3140,7 @@ namespace ts { let typeChecker = program.getTypeChecker(); let syntacticStart = new Date().getTime(); let sourceFile = getValidSourceFile(fileName); - let isJavaScriptFile = isJavaScript(fileName); + let isJavaScriptFile = isSourceFileJavaScript(sourceFile); let isJsDocTagName = false; @@ -3857,22 +3961,25 @@ namespace ts { let { symbols, isMemberCompletion, isNewIdentifierLocation, location, isRightOfDot, isJsDocTagName } = completionData; - let entries: CompletionEntry[]; if (isJsDocTagName) { // If the current position is a jsDoc tag name, only tag names should be provided for completion return { isMemberCompletion: false, isNewIdentifierLocation: false, entries: getAllJsDocCompletionEntries() }; } - if (isRightOfDot && isJavaScript(fileName)) { - entries = getCompletionEntriesFromSymbols(symbols); - addRange(entries, getJavaScriptCompletionEntries()); + let sourceFile = getValidSourceFile(fileName); + + let entries: CompletionEntry[] = []; + + if (isRightOfDot && isSourceFileJavaScript(sourceFile)) { + const uniqueNames = getCompletionEntriesFromSymbols(symbols, entries); + addRange(entries, getJavaScriptCompletionEntries(sourceFile, uniqueNames)); } else { if (!symbols || symbols.length === 0) { return undefined; } - entries = getCompletionEntriesFromSymbols(symbols); + getCompletionEntriesFromSymbols(symbols, entries); } // Add keywords if this is not a member completion list @@ -3882,26 +3989,23 @@ namespace ts { return { isMemberCompletion, isNewIdentifierLocation, entries }; - function getJavaScriptCompletionEntries(): CompletionEntry[] { + function getJavaScriptCompletionEntries(sourceFile: SourceFile, uniqueNames: Map): CompletionEntry[] { let entries: CompletionEntry[] = []; - let allNames: Map = {}; let target = program.getCompilerOptions().target; - for (let sourceFile of program.getSourceFiles()) { - let nameTable = getNameTable(sourceFile); - for (let name in nameTable) { - if (!allNames[name]) { - allNames[name] = name; - let displayName = getCompletionEntryDisplayName(name, target, /*performCharacterChecks:*/ true); - if (displayName) { - let entry = { - name: displayName, - kind: ScriptElementKind.warning, - kindModifiers: "", - sortText: "1" - }; - entries.push(entry); - } + let nameTable = getNameTable(sourceFile); + for (let name in nameTable) { + if (!uniqueNames[name]) { + uniqueNames[name] = name; + let displayName = getCompletionEntryDisplayName(name, target, /*performCharacterChecks:*/ true); + if (displayName) { + let entry = { + name: displayName, + kind: ScriptElementKind.warning, + kindModifiers: "", + sortText: "1" + }; + entries.push(entry); } } } @@ -3945,26 +4049,24 @@ namespace ts { }; } - function getCompletionEntriesFromSymbols(symbols: Symbol[]): CompletionEntry[] { + function getCompletionEntriesFromSymbols(symbols: Symbol[], entries: CompletionEntry[]): Map { let start = new Date().getTime(); - let entries: CompletionEntry[] = []; - + let uniqueNames: Map = {}; if (symbols) { - let nameToSymbol: Map = {}; for (let symbol of symbols) { let entry = createCompletionEntry(symbol, location); if (entry) { let id = escapeIdentifier(entry.name); - if (!lookUp(nameToSymbol, id)) { + if (!lookUp(uniqueNames, id)) { entries.push(entry); - nameToSymbol[id] = symbol; + uniqueNames[id] = id; } } } } log("getCompletionsAtPosition: getCompletionEntriesFromSymbols: " + (new Date().getTime() - start)); - return entries; + return uniqueNames; } } diff --git a/src/services/shims.ts b/src/services/shims.ts index 351514a1499..686faf0e1bd 100644 --- a/src/services/shims.ts +++ b/src/services/shims.ts @@ -957,7 +957,8 @@ namespace ts { return this.forwardJSONCall( "getPreProcessedFileInfo('" + fileName + "')", () => { - var result = preProcessFile(sourceTextSnapshot.getText(0, sourceTextSnapshot.getLength())); + // for now treat files as JavaScript + var result = preProcessFile(sourceTextSnapshot.getText(0, sourceTextSnapshot.getLength()), /* readImportFiles */ true, /* detectJavaScriptImports */ true); var convertResult = { referencedFiles: [], importedFiles: [], diff --git a/src/services/signatureHelp.ts b/src/services/signatureHelp.ts index df321647e5c..02e36e185a5 100644 --- a/src/services/signatureHelp.ts +++ b/src/services/signatureHelp.ts @@ -204,7 +204,7 @@ namespace ts.SignatureHelp { if (!candidates.length) { // We didn't have any sig help items produced by the TS compiler. If this is a JS // file, then see if we can figure out anything better. - if (isJavaScript(sourceFile.fileName)) { + if (isSourceFileJavaScript(sourceFile)) { return createJavaScriptSignatureHelpItems(argumentInfo); } diff --git a/tests/cases/fourslash/getJavaScriptSyntacticDiagnostics1.ts b/tests/cases/fourslash/getJavaScriptSyntacticDiagnostics1.ts deleted file mode 100644 index e409029276b..00000000000 --- a/tests/cases/fourslash/getJavaScriptSyntacticDiagnostics1.ts +++ /dev/null @@ -1,19 +0,0 @@ -/// - -// @allowNonTsExtensions: true -// @Filename: a.js -//// /** -//// * @type {number} -//// * @type {string} -//// */ -//// var v; - -verify.getSyntacticDiagnostics(`[ - { - "message": "\'type\' tag already specified.", - "start": 26, - "length": 4, - "category": "error", - "code": 1223 - } -]`); \ No newline at end of file diff --git a/tests/cases/fourslash/javaScriptModules12.ts b/tests/cases/fourslash/javaScriptModules12.ts new file mode 100644 index 00000000000..c391f150963 --- /dev/null +++ b/tests/cases/fourslash/javaScriptModules12.ts @@ -0,0 +1,57 @@ +/// + +// Invocations of 'require' stop top-level variables from becoming global + +// @allowNonTsExtensions: true + +// @Filename: mod1.js +//// var x = require('fs'); +//// /*1*/ + +// @Filename: mod2.js +//// var y; +//// if(true) { +//// y = require('fs'); +//// } +//// /*2*/ + +// @Filename: glob1.js +//// var a = require; +//// /*3*/ + +// @Filename: glob2.js +//// var b = ''; +//// /*4*/ + +// @Filename: consumer.js +//// /*5*/ + +goTo.marker('1'); +verify.completionListContains('x'); +verify.not.completionListContains('y'); +verify.completionListContains('a'); +verify.completionListContains('b'); + +goTo.marker('2'); +verify.not.completionListContains('x'); +verify.completionListContains('y'); +verify.completionListContains('a'); +verify.completionListContains('b'); + +goTo.marker('3'); +verify.not.completionListContains('x'); +verify.not.completionListContains('y'); +verify.completionListContains('a'); +verify.completionListContains('b'); + +goTo.marker('4'); +verify.not.completionListContains('x'); +verify.not.completionListContains('y'); +verify.completionListContains('a'); +verify.completionListContains('b'); + +goTo.marker('5'); +verify.not.completionListContains('x'); +verify.not.completionListContains('y'); +verify.completionListContains('a'); +verify.completionListContains('b'); diff --git a/tests/cases/fourslash/javaScriptModules13.ts b/tests/cases/fourslash/javaScriptModules13.ts new file mode 100644 index 00000000000..215f47e9ad6 --- /dev/null +++ b/tests/cases/fourslash/javaScriptModules13.ts @@ -0,0 +1,29 @@ +/// + +// Assignments to 'module.exports' create an external module + +// @allowNonTsExtensions: true +// @Filename: myMod.js +//// if (true) { +//// module.exports = { a: 10 }; +//// } else { +//// module.exports = { b: 10 }; +//// } +//// var invisible = true; + +// @Filename: isGlobal.js +//// var y = 10; + +// @Filename: consumer.js +//// var x = require('myMod'); +//// /**/; + +goTo.file('consumer.js'); +goTo.marker(); + +verify.completionListContains('y'); +verify.not.completionListContains('invisible'); + +edit.insert('x.'); +verify.completionListContains('a'); +verify.completionListContains('b'); diff --git a/tests/cases/fourslash/javaScriptModules14.ts b/tests/cases/fourslash/javaScriptModules14.ts new file mode 100644 index 00000000000..5434f94cf8d --- /dev/null +++ b/tests/cases/fourslash/javaScriptModules14.ts @@ -0,0 +1,28 @@ +/// + +// Assignments to 'exports.p' stop global variables from being visible in other files + +// @allowNonTsExtensions: true +// @Filename: myMod.js +//// if (true) { +//// exports.b = true; +//// } else { +//// exports.n = 3; +//// } +//// function fn() { +//// exports.s = 'foo'; +//// } +//// var invisible = true; + +// @Filename: isGlobal.js +//// var y = 10; + +// @Filename: consumer.js +//// var x = require('myMod'); +//// /**/; + +goTo.file('consumer.js'); +goTo.marker(); + +verify.completionListContains('y'); +verify.not.completionListContains('invisible'); diff --git a/tests/cases/fourslash/javaScriptModules15.ts b/tests/cases/fourslash/javaScriptModules15.ts new file mode 100644 index 00000000000..ff888d99336 --- /dev/null +++ b/tests/cases/fourslash/javaScriptModules15.ts @@ -0,0 +1,27 @@ +/// + +// Assignments to 'exports.p' define a property 'p' even if they're not at top-level + +// @allowNonTsExtensions: true +// @Filename: myMod.js +//// if (true) { +//// exports.b = true; +//// } else { +//// exports.n = 3; +//// } +//// function fn() { +//// exports.s = 'foo'; +//// } + +// @Filename: consumer.js +//// var x = require('myMod'); +//// x/**/; + +goTo.file('consumer.js'); +goTo.marker(); +edit.insert('.'); +verify.completionListContains("n", /*displayText:*/ undefined, /*documentation*/ undefined, "property"); +verify.completionListContains("s", /*displayText:*/ undefined, /*documentation*/ undefined, "property"); +verify.completionListContains("b", /*displayText:*/ undefined, /*documentation*/ undefined, "property"); +edit.insert('n.'); +verify.completionListContains("toFixed", /*displayText:*/ undefined, /*documentation*/ undefined, "method"); diff --git a/tests/cases/fourslash/javaScriptModules16.ts b/tests/cases/fourslash/javaScriptModules16.ts new file mode 100644 index 00000000000..c556f288145 --- /dev/null +++ b/tests/cases/fourslash/javaScriptModules16.ts @@ -0,0 +1,22 @@ +/// + +// Assignments to 'exports.p' define a property 'p' + +// @allowNonTsExtensions: true +// @Filename: myMod.js +//// exports.n = 3; +//// exports.s = 'foo'; +//// exports.b = true; + +// @Filename: consumer.js +//// var x = require('myMod'); +//// x/**/; + +goTo.file('consumer.js'); +goTo.marker(); +edit.insert('.'); +verify.completionListContains("n", /*displayText:*/ undefined, /*documentation*/ undefined, "property"); +verify.completionListContains("s", /*displayText:*/ undefined, /*documentation*/ undefined, "property"); +verify.completionListContains("b", /*displayText:*/ undefined, /*documentation*/ undefined, "property"); +edit.insert('n.'); +verify.completionListContains("toFixed", /*displayText:*/ undefined, /*documentation*/ undefined, "method"); diff --git a/tests/cases/fourslash/javaScriptModules17.ts b/tests/cases/fourslash/javaScriptModules17.ts new file mode 100644 index 00000000000..8514ed0ee18 --- /dev/null +++ b/tests/cases/fourslash/javaScriptModules17.ts @@ -0,0 +1,18 @@ +/// + +// @allowNonTsExtensions: true +// @Filename: myMod.js +//// module.exports = { n: 3, s: 'foo', b: true }; + +// @Filename: consumer.js +//// var x = require('./myMod'); +//// x/**/; + +goTo.file('consumer.js'); +goTo.marker(); +edit.insert('.'); +verify.completionListContains("n", /*displayText:*/ undefined, /*documentation*/ undefined, "property"); +verify.completionListContains("s", /*displayText:*/ undefined, /*documentation*/ undefined, "property"); +verify.completionListContains("b", /*displayText:*/ undefined, /*documentation*/ undefined, "property"); +edit.insert('n.'); +verify.completionListContains("toFixed", /*displayText:*/ undefined, /*documentation*/ undefined, "method"); diff --git a/tests/cases/fourslash/javaScriptModules18.ts b/tests/cases/fourslash/javaScriptModules18.ts new file mode 100644 index 00000000000..d3117f86b3f --- /dev/null +++ b/tests/cases/fourslash/javaScriptModules18.ts @@ -0,0 +1,14 @@ +/// + +// CommonJS modules should not pollute the global namespace + +// @allowNonTsExtensions: true +// @Filename: myMod.js +//// var x = require('fs'); + +// @Filename: other.js +//// /**/; + +goTo.file('other.js'); + +verify.not.completionListContains('x'); diff --git a/tests/cases/unittests/moduleResolution.ts b/tests/cases/unittests/moduleResolution.ts index b5c2c70e491..7e363d80d6d 100644 --- a/tests/cases/unittests/moduleResolution.ts +++ b/tests/cases/unittests/moduleResolution.ts @@ -82,7 +82,7 @@ module ts { assert.equal(resolution.resolvedModule.resolvedFileName, moduleFile.name); assert.equal(!!resolution.resolvedModule.isExternalLibraryImport, false); // expect three failed lookup location - attempt to load module as file with all supported extensions - assert.equal(resolution.failedLookupLocations.length, 3); + assert.equal(resolution.failedLookupLocations.length, 5); } it("module name as directory - load from typings", () => { @@ -103,6 +103,8 @@ module ts { "/a/b/foo.ts", "/a/b/foo.tsx", "/a/b/foo.d.ts", + "/a/b/foo.js", + "/a/b/foo.jsx", "/a/b/foo/index.ts", "/a/b/foo/index.tsx", ]); @@ -119,17 +121,25 @@ module ts { "/a/b/c/d/node_modules/foo.ts", "/a/b/c/d/node_modules/foo.tsx", "/a/b/c/d/node_modules/foo.d.ts", + "/a/b/c/d/node_modules/foo.js", + "/a/b/c/d/node_modules/foo.jsx", "/a/b/c/d/node_modules/foo/package.json", "/a/b/c/d/node_modules/foo/index.ts", "/a/b/c/d/node_modules/foo/index.tsx", "/a/b/c/d/node_modules/foo/index.d.ts", + "/a/b/c/d/node_modules/foo/index.js", + "/a/b/c/d/node_modules/foo/index.jsx", "/a/b/c/node_modules/foo.ts", "/a/b/c/node_modules/foo.tsx", "/a/b/c/node_modules/foo.d.ts", + "/a/b/c/node_modules/foo.js", + "/a/b/c/node_modules/foo.jsx", "/a/b/c/node_modules/foo/package.json", "/a/b/c/node_modules/foo/index.ts", "/a/b/c/node_modules/foo/index.tsx", - "/a/b/c/node_modules/foo/index.d.ts" + "/a/b/c/node_modules/foo/index.d.ts", + "/a/b/c/node_modules/foo/index.js", + "/a/b/c/node_modules/foo/index.jsx" ]) }); @@ -151,27 +161,41 @@ module ts { "/a/node_modules/b/c/node_modules/d/node_modules/foo.ts", "/a/node_modules/b/c/node_modules/d/node_modules/foo.tsx", "/a/node_modules/b/c/node_modules/d/node_modules/foo.d.ts", + "/a/node_modules/b/c/node_modules/d/node_modules/foo.js", + "/a/node_modules/b/c/node_modules/d/node_modules/foo.jsx", "/a/node_modules/b/c/node_modules/d/node_modules/foo/package.json", "/a/node_modules/b/c/node_modules/d/node_modules/foo/index.ts", "/a/node_modules/b/c/node_modules/d/node_modules/foo/index.tsx", "/a/node_modules/b/c/node_modules/d/node_modules/foo/index.d.ts", + "/a/node_modules/b/c/node_modules/d/node_modules/foo/index.js", + "/a/node_modules/b/c/node_modules/d/node_modules/foo/index.jsx", "/a/node_modules/b/c/node_modules/foo.ts", "/a/node_modules/b/c/node_modules/foo.tsx", "/a/node_modules/b/c/node_modules/foo.d.ts", + "/a/node_modules/b/c/node_modules/foo.js", + "/a/node_modules/b/c/node_modules/foo.jsx", "/a/node_modules/b/c/node_modules/foo/package.json", "/a/node_modules/b/c/node_modules/foo/index.ts", "/a/node_modules/b/c/node_modules/foo/index.tsx", "/a/node_modules/b/c/node_modules/foo/index.d.ts", + "/a/node_modules/b/c/node_modules/foo/index.js", + "/a/node_modules/b/c/node_modules/foo/index.jsx", "/a/node_modules/b/node_modules/foo.ts", "/a/node_modules/b/node_modules/foo.tsx", "/a/node_modules/b/node_modules/foo.d.ts", + "/a/node_modules/b/node_modules/foo.js", + "/a/node_modules/b/node_modules/foo.jsx", "/a/node_modules/b/node_modules/foo/package.json", "/a/node_modules/b/node_modules/foo/index.ts", "/a/node_modules/b/node_modules/foo/index.tsx", "/a/node_modules/b/node_modules/foo/index.d.ts", + "/a/node_modules/b/node_modules/foo/index.js", + "/a/node_modules/b/node_modules/foo/index.jsx", "/a/node_modules/foo.ts", "/a/node_modules/foo.tsx", "/a/node_modules/foo.d.ts", + "/a/node_modules/foo.js", + "/a/node_modules/foo.jsx", "/a/node_modules/foo/package.json", "/a/node_modules/foo/index.ts", "/a/node_modules/foo/index.tsx" diff --git a/tests/cases/unittests/services/preProcessFile.ts b/tests/cases/unittests/services/preProcessFile.ts index a3f8db5528f..aba5ce15c03 100644 --- a/tests/cases/unittests/services/preProcessFile.ts +++ b/tests/cases/unittests/services/preProcessFile.ts @@ -2,8 +2,8 @@ /// describe('PreProcessFile:', function () { - function test(sourceText: string, readImportFile: boolean, expectedPreProcess: ts.PreProcessedFileInfo): void { - var resultPreProcess = ts.preProcessFile(sourceText, readImportFile); + function test(sourceText: string, readImportFile: boolean, detectJavaScriptImports: boolean, expectedPreProcess: ts.PreProcessedFileInfo): void { + var resultPreProcess = ts.preProcessFile(sourceText, readImportFile, detectJavaScriptImports); var resultIsLibFile = resultPreProcess.isLibFile; var resultImportedFiles = resultPreProcess.importedFiles; @@ -45,7 +45,9 @@ describe('PreProcessFile:', function () { } describe("Test preProcessFiles,", function () { it("Correctly return referenced files from triple slash", function () { - test("///" + "\n" + "///" + "\n" + "///" + "\n" + "///", true, + test("///" + "\n" + "///" + "\n" + "///" + "\n" + "///", + /* readImports */true, + /* detectJavaScriptImports */ false, { referencedFiles: [{ fileName: "refFile1.ts", pos: 0, end: 37 }, { fileName: "refFile2.ts", pos: 38, end: 73 }, { fileName: "refFile3.ts", pos: 74, end: 109 }, { fileName: "..\\refFile4d.ts", pos: 110, end: 150 }], @@ -56,7 +58,9 @@ describe('PreProcessFile:', function () { }), it("Do not return reference path because of invalid triple-slash syntax", function () { - test("///" + "\n" + "///" + "\n" + "///" + "\n" + "///", true, + test("///" + "\n" + "///" + "\n" + "///" + "\n" + "///", + /* readImports */true, + /* detectJavaScriptImports */ false, { referencedFiles: [], importedFiles: [], @@ -66,7 +70,9 @@ describe('PreProcessFile:', function () { }), it("Correctly return imported files", function () { - test("import i1 = require(\"r1.ts\"); import i2 =require(\"r2.ts\"); import i3= require(\"r3.ts\"); import i4=require(\"r4.ts\"); import i5 = require (\"r5.ts\");", true, + test("import i1 = require(\"r1.ts\"); import i2 =require(\"r2.ts\"); import i3= require(\"r3.ts\"); import i4=require(\"r4.ts\"); import i5 = require (\"r5.ts\");", + /* readImports */true, + /* detectJavaScriptImports */ false, { referencedFiles: [], importedFiles: [{ fileName: "r1.ts", pos: 20, end: 25 }, { fileName: "r2.ts", pos: 49, end: 54 }, { fileName: "r3.ts", pos: 78, end: 83 }, @@ -77,7 +83,9 @@ describe('PreProcessFile:', function () { }), it("Do not return imported files if readImportFiles argument is false", function () { - test("import i1 = require(\"r1.ts\"); import i2 =require(\"r2.ts\"); import i3= require(\"r3.ts\"); import i4=require(\"r4.ts\"); import i5 = require (\"r5.ts\");", false, + test("import i1 = require(\"r1.ts\"); import i2 =require(\"r2.ts\"); import i3= require(\"r3.ts\"); import i4=require(\"r4.ts\"); import i5 = require (\"r5.ts\");", + /* readImports */ false, + /* detectJavaScriptImports */ false, { referencedFiles: [], importedFiles: [], @@ -87,7 +95,9 @@ describe('PreProcessFile:', function () { }), it("Do not return import path because of invalid import syntax", function () { - test("import i1 require(\"r1.ts\"); import = require(\"r2.ts\") import i3= require(\"r3.ts\"); import i5", true, + test("import i1 require(\"r1.ts\"); import = require(\"r2.ts\") import i3= require(\"r3.ts\"); import i5", + /* readImports */true, + /* detectJavaScriptImports */ false, { referencedFiles: [], importedFiles: [{ fileName: "r3.ts", pos: 73, end: 78 }], @@ -97,7 +107,9 @@ describe('PreProcessFile:', function () { }), it("Correctly return referenced files and import files", function () { - test("///" + "\n" + "///" + "\n" + "import i1 = require(\"r1.ts\"); import i2 =require(\"r2.ts\");", true, + test("///" + "\n" + "///" + "\n" + "import i1 = require(\"r1.ts\"); import i2 =require(\"r2.ts\");", + /* readImports */true, + /* detectJavaScriptImports */ false, { referencedFiles: [{ fileName: "refFile1.ts", pos: 0, end: 35 }, { fileName: "refFile2.ts", pos: 36, end: 71 }], importedFiles: [{ fileName: "r1.ts", pos: 92, end: 97 }, { fileName: "r2.ts", pos: 121, end: 126 }], @@ -107,7 +119,9 @@ describe('PreProcessFile:', function () { }), it("Correctly return referenced files and import files even with some invalid syntax", function () { - test("///" + "\n" + "///" + "\n" + "import i1 = require(\"r1.ts\"); import = require(\"r2.ts\"); import i2 = require(\"r3.ts\");", true, + test("///" + "\n" + "///" + "\n" + "import i1 = require(\"r1.ts\"); import = require(\"r2.ts\"); import i2 = require(\"r3.ts\");", + /* readImports */true, + /* detectJavaScriptImports */ false, { referencedFiles: [{ fileName: "refFile1.ts", pos: 0, end: 35 }], importedFiles: [{ fileName: "r1.ts", pos: 91, end: 96 }, { fileName: "r3.ts", pos: 148, end: 153 }], @@ -124,7 +138,8 @@ describe('PreProcessFile:', function () { "import {a as A} from \"m5\";" + "\n" + "import {a as A, b, c as C} from \"m6\";" + "\n" + "import def , {a, b, c as C} from \"m7\";" + "\n", - true, + /* readImports */true, + /* detectJavaScriptImports */ false, { referencedFiles: [], importedFiles: [ @@ -146,7 +161,8 @@ describe('PreProcessFile:', function () { "export {a} from \"m2\";" + "\n" + "export {a as A} from \"m3\";" + "\n" + "export {a as A, b, c as C} from \"m4\";" + "\n", - true, + /* readImports */true, + /* detectJavaScriptImports */ false, { referencedFiles: [], importedFiles: [ @@ -166,7 +182,11 @@ describe('PreProcessFile:', function () { declare module "B" {} function foo() { } - `, false, { + `, + /* readImports */ false, + /* detectJavaScriptImports */ false, + + { referencedFiles: [], importedFiles: [], ambientExternalModules: ["B"], @@ -176,7 +196,8 @@ describe('PreProcessFile:', function () { it("Correctly handles export import declarations", function () { test("export import a = require(\"m1\");", - true, + /* readImports */true, + /* detectJavaScriptImports */ false, { referencedFiles: [], importedFiles: [ @@ -186,7 +207,109 @@ describe('PreProcessFile:', function () { isLibFile: false }) }); + it("Correctly handles export require calls in JavaScript files", function () { + test(` + export import a = require("m1"); + var x = require('m2'); + foo(require('m3')); + var z = { f: require('m4') } + `, + /* readImports */true, + /* detectJavaScriptImports */ true, + { + referencedFiles: [], + importedFiles: [ + { fileName: "m1", pos: 39, end: 41 }, + { fileName: "m2", pos: 74, end: 76 }, + { fileName: "m3", pos: 105, end: 107 }, + { fileName: "m4", pos: 146, end: 148 }, + ], + ambientExternalModules: undefined, + isLibFile: false + }) + }); + it("Correctly handles dependency lists in define([deplist]) calls in JavaScript files", function () { + test(` + define(["mod1", "mod2"], (m1, m2) => { + }); + `, + /* readImports */true, + /* detectJavaScriptImports */ true, + { + referencedFiles: [], + importedFiles: [ + { fileName: "mod1", pos: 21, end: 25 }, + { fileName: "mod2", pos: 29, end: 33 }, + ], + ambientExternalModules: undefined, + isLibFile: false + }) + }); + it("Correctly handles dependency lists in define(modName, [deplist]) calls in JavaScript files", function () { + test(` + define("mod", ["mod1", "mod2"], (m1, m2) => { + }); + `, + /* readImports */true, + /* detectJavaScriptImports */ true, + { + referencedFiles: [], + importedFiles: [ + { fileName: "mod1", pos: 28, end: 32 }, + { fileName: "mod2", pos: 36, end: 40 }, + ], + ambientExternalModules: undefined, + isLibFile: false + }) + }); + it("Excludes require/exports/module names from dependency lists in define(modName, [deplist]) calls in JavaScript files", function () { + test(` + define(["require", "exports", "module", "mod1", "mod2"], (m1, m2) => { + }); + `, + /* readImports */true, + /* detectJavaScriptImports */ true, + { + referencedFiles: [], + importedFiles: [ + { fileName: "mod1", pos: 53, end: 57 }, + { fileName: "mod2", pos: 61, end: 65 }, + ], + ambientExternalModules: undefined, + isLibFile: false + }); + test(` + define(["require", "exports", "mod1", "module"], (m1, m2) => { + }); + `, + /* readImports */true, + /* detectJavaScriptImports */ true, + { + referencedFiles: [], + importedFiles: [ + { fileName: "mod1", pos: 43, end: 47 }, + { fileName: "module", pos: 51, end: 57 }, + ], + ambientExternalModules: undefined, + isLibFile: false + }); + test(` + define(["require", "require", "exports"], (m1, m2) => { + }); + `, + /* readImports */true, + /* detectJavaScriptImports */ true, + { + referencedFiles: [], + importedFiles: [ + { fileName: "require", pos: 32, end: 39 }, + { fileName: "exports", pos: 43, end: 50 }, + ], + ambientExternalModules: undefined, + isLibFile: false + }); + }); }); }); diff --git a/tests/webTestServer.ts b/tests/webTestServer.ts index 6d3144eeaec..75d90dbeefe 100644 --- a/tests/webTestServer.ts +++ b/tests/webTestServer.ts @@ -5,6 +5,7 @@ import fs = require("fs"); import path = require("path"); import url = require("url"); import child_process = require("child_process"); +import os = require("os"); /// Command line processing /// @@ -263,7 +264,19 @@ http.createServer(function (req: http.ServerRequest, res: http.ServerResponse) { var browserPath: string; if ((browser && browser === 'chrome')) { - var defaultChromePath = "C:/Program Files (x86)/Google/Chrome/Application/chrome.exe"; + const platform = os.platform(); + let defaultChromePath: string; + switch(platform) { + case "win32": + defaultChromePath = "C:/Program Files (x86)/Google/Chrome/Application/chrome.exe"; + break; + case "linux": + defaultChromePath = "/opt/google/chrome/chrome"; + break; + default: + console.log(`Default Chrome location for platform ${platform} is unknown`); + break; + } if (fs.existsSync(defaultChromePath)) { browserPath = defaultChromePath; } else { From ec0d49a312171c408263c40ea777963b4d02963f Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Thu, 15 Oct 2015 14:26:27 -0700 Subject: [PATCH 067/227] Always use a string literal type if contextually typed by any string literal types. --- src/compiler/checker.ts | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 2980d8a7cad..3b7436f01e2 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -5691,6 +5691,10 @@ namespace ts { return !!getPropertyOfType(type, "0"); } + function isStringLiteralType(type: Type) { + return type.flags & TypeFlags.StringLiteral; + } + /** * Check if a Type was written as a tuple type literal. * Prefer using isTupleLikeType() unless the use of `elementTypes` is required. @@ -6953,6 +6957,10 @@ namespace ts { return applyToContextualType(type, t => getIndexTypeOfStructuredType(t, kind)); } + function contextualTypeIsStringLiteralType(type: Type): boolean { + return !!(type.flags & TypeFlags.Union ? forEach((type).types, isStringLiteralType) : isStringLiteralType(type)); + } + // Return true if the given contextual type is a tuple-like type function contextualTypeIsTupleLikeType(type: Type): boolean { return !!(type.flags & TypeFlags.Union ? forEach((type).types, isTupleLikeType) : isTupleLikeType(type)); @@ -10350,22 +10358,14 @@ namespace ts { return getUnionType([type1, type2]); } - function checkStringLiteralExpression(node: LiteralExpression) { + function checkStringLiteralExpression(node: StringLiteral): Type { // TODO (drosen): Do we want to apply the same approach to no-sub template literals? let contextualType = getContextualType(node); - if (contextualType) { - if (contextualType.flags & TypeFlags.Union) { - for (const type of (contextualType).types) { - if (type.flags & TypeFlags.StringLiteral && (type).text === node.text) { - return type; - } - } - } - else if (contextualType.flags & TypeFlags.StringLiteral && (contextualType).text === node.text) { - return contextualType; - } + if (contextualType && contextualTypeIsStringLiteralType(contextualType)) { + return getStringLiteralType(node); } + return stringType; } @@ -10499,7 +10499,7 @@ namespace ts { case SyntaxKind.TemplateExpression: return checkTemplateExpression(node); case SyntaxKind.StringLiteral: - return checkStringLiteralExpression(node); + return checkStringLiteralExpression(node); case SyntaxKind.NoSubstitutionTemplateLiteral: return stringType; case SyntaxKind.RegularExpressionLiteral: From 1dbd8d1dd8309456f76ce46e7645cb0d4a646cd5 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Thu, 15 Oct 2015 14:26:41 -0700 Subject: [PATCH 068/227] Accepted baselines. --- ...loadOnConstantsInvalidOverload1.errors.txt | 4 ++-- .../overloadingOnConstants2.errors.txt | 4 ++-- ...gumentsWithStringLiteralTypes01.errors.txt | 24 +++++++++---------- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/tests/baselines/reference/overloadOnConstantsInvalidOverload1.errors.txt b/tests/baselines/reference/overloadOnConstantsInvalidOverload1.errors.txt index 1676a2fb426..4fea7cc1227 100644 --- a/tests/baselines/reference/overloadOnConstantsInvalidOverload1.errors.txt +++ b/tests/baselines/reference/overloadOnConstantsInvalidOverload1.errors.txt @@ -1,6 +1,6 @@ tests/cases/compiler/overloadOnConstantsInvalidOverload1.ts(6,10): error TS2382: Specialized overload signature is not assignable to any non-specialized signature. tests/cases/compiler/overloadOnConstantsInvalidOverload1.ts(7,10): error TS2381: A signature with an implementation cannot use a string literal type. -tests/cases/compiler/overloadOnConstantsInvalidOverload1.ts(11,5): error TS2345: Argument of type 'string' is not assignable to parameter of type '"SPAN"'. +tests/cases/compiler/overloadOnConstantsInvalidOverload1.ts(11,5): error TS2345: Argument of type '"HI"' is not assignable to parameter of type '"SPAN"'. ==== tests/cases/compiler/overloadOnConstantsInvalidOverload1.ts (3 errors) ==== @@ -20,4 +20,4 @@ tests/cases/compiler/overloadOnConstantsInvalidOverload1.ts(11,5): error TS2345: foo("HI"); ~~~~ -!!! error TS2345: Argument of type 'string' is not assignable to parameter of type '"SPAN"'. \ No newline at end of file +!!! error TS2345: Argument of type '"HI"' is not assignable to parameter of type '"SPAN"'. \ No newline at end of file diff --git a/tests/baselines/reference/overloadingOnConstants2.errors.txt b/tests/baselines/reference/overloadingOnConstants2.errors.txt index c6d63523576..b448deaadc7 100644 --- a/tests/baselines/reference/overloadingOnConstants2.errors.txt +++ b/tests/baselines/reference/overloadingOnConstants2.errors.txt @@ -1,6 +1,6 @@ tests/cases/compiler/overloadingOnConstants2.ts(8,10): error TS2382: Specialized overload signature is not assignable to any non-specialized signature. tests/cases/compiler/overloadingOnConstants2.ts(9,10): error TS2382: Specialized overload signature is not assignable to any non-specialized signature. -tests/cases/compiler/overloadingOnConstants2.ts(15,13): error TS2345: Argument of type 'string' is not assignable to parameter of type '"bye"'. +tests/cases/compiler/overloadingOnConstants2.ts(15,13): error TS2345: Argument of type '"um"' is not assignable to parameter of type '"bye"'. tests/cases/compiler/overloadingOnConstants2.ts(19,10): error TS2382: Specialized overload signature is not assignable to any non-specialized signature. @@ -25,7 +25,7 @@ tests/cases/compiler/overloadingOnConstants2.ts(19,10): error TS2382: Specialize var b: E = foo("bye", []); // E var c = foo("um", []); // error ~~~~ -!!! error TS2345: Argument of type 'string' is not assignable to parameter of type '"bye"'. +!!! error TS2345: Argument of type '"um"' is not assignable to parameter of type '"bye"'. //function bar(x: "hi", items: string[]): D; diff --git a/tests/baselines/reference/typeArgumentsWithStringLiteralTypes01.errors.txt b/tests/baselines/reference/typeArgumentsWithStringLiteralTypes01.errors.txt index 69f8d6581a1..49f17e7891d 100644 --- a/tests/baselines/reference/typeArgumentsWithStringLiteralTypes01.errors.txt +++ b/tests/baselines/reference/typeArgumentsWithStringLiteralTypes01.errors.txt @@ -14,18 +14,18 @@ tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes0 Type 'string' is not assignable to type '"World"'. tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(48,30): error TS2345: Argument of type 'string' is not assignable to parameter of type '"Hello" | "World"'. Type 'string' is not assignable to type '"World"'. -tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(55,43): error TS2345: Argument of type 'string' is not assignable to parameter of type '"Hello"'. -tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(57,52): error TS2345: Argument of type 'string' is not assignable to parameter of type '"Hello"'. -tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(58,43): error TS2345: Argument of type 'string' is not assignable to parameter of type '"Hello"'. +tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(55,43): error TS2345: Argument of type '"World"' is not assignable to parameter of type '"Hello"'. +tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(57,52): error TS2345: Argument of type '"World"' is not assignable to parameter of type '"Hello"'. +tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(58,43): error TS2345: Argument of type '"World"' is not assignable to parameter of type '"Hello"'. tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(61,5): error TS2322: Type 'string' is not assignable to type '"Hello"'. tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(63,5): error TS2322: Type 'string' is not assignable to type '"Hello"'. tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(75,5): error TS2322: Type '"Hello" | "World"' is not assignable to type '"Hello"'. Type '"World"' is not assignable to type '"Hello"'. tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(77,5): error TS2322: Type '"Hello" | "World"' is not assignable to type '"Hello"'. Type '"World"' is not assignable to type '"Hello"'. -tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(87,43): error TS2345: Argument of type 'string' is not assignable to parameter of type '"Hello"'. -tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(88,43): error TS2345: Argument of type 'string' is not assignable to parameter of type '"World"'. -tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(89,52): error TS2345: Argument of type 'string' is not assignable to parameter of type '"Hello"'. +tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(87,43): error TS2345: Argument of type '"World"' is not assignable to parameter of type '"Hello"'. +tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(88,43): error TS2345: Argument of type '"Hello"' is not assignable to parameter of type '"World"'. +tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(89,52): error TS2345: Argument of type '"World"' is not assignable to parameter of type '"Hello"'. tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(93,5): error TS2322: Type 'string' is not assignable to type '"Hello" | "World"'. Type 'string' is not assignable to type '"World"'. tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(97,5): error TS2322: Type 'string' is not assignable to type '"Hello" | "World"'. @@ -120,14 +120,14 @@ tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes0 export let a = fun1<"Hello">("Hello", "Hello"); export let b = fun1<"Hello">("Hello", "World"); ~~~~~~~ -!!! error TS2345: Argument of type 'string' is not assignable to parameter of type '"Hello"'. +!!! error TS2345: Argument of type '"World"' is not assignable to parameter of type '"Hello"'. export let c = fun2<"Hello", "Hello">("Hello", "Hello"); export let d = fun2<"Hello", "Hello">("Hello", "World"); ~~~~~~~ -!!! error TS2345: Argument of type 'string' is not assignable to parameter of type '"Hello"'. +!!! error TS2345: Argument of type '"World"' is not assignable to parameter of type '"Hello"'. export let e = fun3<"Hello">("Hello", "World"); ~~~~~~~ -!!! error TS2345: Argument of type 'string' is not assignable to parameter of type '"Hello"'. +!!! error TS2345: Argument of type '"World"' is not assignable to parameter of type '"Hello"'. // Assignment from the returned value should cause an error. a = takeReturnString(a); @@ -168,13 +168,13 @@ tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes0 export let a = fun2<"Hello", "World">("Hello", "World"); export let b = fun2<"Hello", "World">("World", "Hello"); ~~~~~~~ -!!! error TS2345: Argument of type 'string' is not assignable to parameter of type '"Hello"'. +!!! error TS2345: Argument of type '"World"' is not assignable to parameter of type '"Hello"'. export let c = fun2<"World", "Hello">("Hello", "Hello"); ~~~~~~~ -!!! error TS2345: Argument of type 'string' is not assignable to parameter of type '"World"'. +!!! error TS2345: Argument of type '"Hello"' is not assignable to parameter of type '"World"'. export let d = fun2<"World", "Hello">("World", "World"); ~~~~~~~ -!!! error TS2345: Argument of type 'string' is not assignable to parameter of type '"Hello"'. +!!! error TS2345: Argument of type '"World"' is not assignable to parameter of type '"Hello"'. export let e = fun3<"Hello" | "World">("Hello", "World"); // Assignment from the returned value should cause an error. From b8a3564d284fb2344dcedcc603fcc23cd5a0f1f6 Mon Sep 17 00:00:00 2001 From: Vladimir Matveev Date: Thu, 15 Oct 2015 14:43:51 -0700 Subject: [PATCH 069/227] use absolute path as key to store files, correctly handle scenarios when file names differ only in casing --- src/compiler/commandLineParser.ts | 7 +- src/compiler/diagnosticMessages.json | 4 + src/compiler/program.ts | 122 ++++++------ src/compiler/types.ts | 1 + src/harness/harness.ts | 4 +- src/harness/projectsRunner.ts | 20 +- tests/cases/unittests/moduleResolution.ts | 219 +++++++++++++++------- 7 files changed, 249 insertions(+), 128 deletions(-) diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index acf0474b7bf..1d4ad8ae4df 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -247,7 +247,12 @@ namespace ts { }, description: Diagnostics.Specifies_module_resolution_strategy_Colon_node_Node_js_or_classic_TypeScript_pre_1_6, error: Diagnostics.Argument_for_moduleResolution_option_must_be_node_or_classic, - } + }, + { + name: "forceConsistentCasingInFileNames", + type: "boolean", + description: Diagnostics.Raise_error_if_two_file_names_in_program_differ_only_in_case + }, ]; /* @internal */ diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index a8ed6ac6127..7202713cbe1 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -2298,6 +2298,10 @@ "category": "Message", "code": 6072 }, + "Raise error if two file names in program differ only in case.": { + "category": "Message", + "code": 6073 + }, "Variable '{0}' implicitly has an '{1}' type.": { "category": "Error", diff --git a/src/compiler/program.ts b/src/compiler/program.ts index 86719ff30b4..d0785cdb16b 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -207,7 +207,6 @@ namespace ts { }; export function createCompilerHost(options: CompilerOptions, setParentNodes?: boolean): CompilerHost { - let currentDirectory: string; let existingDirectories: Map = {}; function getCanonicalFileName(fileName: string): string { @@ -277,7 +276,7 @@ namespace ts { getSourceFile, getDefaultLibFileName: options => combinePaths(getDirectoryPath(normalizePath(sys.getExecutingFilePath())), getDefaultLibFileName(options)), writeFile, - getCurrentDirectory: () => currentDirectory || (currentDirectory = sys.getCurrentDirectory()), + getCurrentDirectory: memoize(() => sys.getCurrentDirectory()), useCaseSensitiveFileNames: () => sys.useCaseSensitiveFileNames, getCanonicalFileName, getNewLine: () => newLine, @@ -342,11 +341,15 @@ namespace ts { host = host || createCompilerHost(options); + const currentDirectory = host.getCurrentDirectory(); const resolveModuleNamesWorker = host.resolveModuleNames ? ((moduleNames: string[], containingFile: string) => host.resolveModuleNames(moduleNames, containingFile)) : ((moduleNames: string[], containingFile: string) => map(moduleNames, moduleName => resolveModuleName(moduleName, containingFile, options, host).resolvedModule)); - let filesByName = createFileMap(fileName => host.getCanonicalFileName(fileName)); + let filesByName = createFileMap(getCanonicalFileName); + // stores 'filename -> file association' ignoring case + // used to track cases when two file names differ only in casing + let filesByNameIgnoreCase = host.useCaseSensitiveFileNames() ? createFileMap(fileName => fileName.toLowerCase()) : undefined; if (oldProgram) { // check properties that can affect structure of the program or module resolution strategy @@ -394,7 +397,7 @@ namespace ts { getDiagnosticsProducingTypeChecker, getCommonSourceDirectory: () => commonSourceDirectory, emit, - getCurrentDirectory: () => host.getCurrentDirectory(), + getCurrentDirectory: () => currentDirectory, getNodeCount: () => getDiagnosticsProducingTypeChecker().getNodeCount(), getIdentifierCount: () => getDiagnosticsProducingTypeChecker().getIdentifierCount(), getSymbolCount: () => getDiagnosticsProducingTypeChecker().getSymbolCount(), @@ -432,13 +435,18 @@ namespace ts { // check if program source files has changed in the way that can affect structure of the program let newSourceFiles: SourceFile[] = []; + let normalizedAbsoluteFileNames: string[] = []; let modifiedSourceFiles: SourceFile[] = []; + for (let oldSourceFile of oldProgram.getSourceFiles()) { let newSourceFile = host.getSourceFile(oldSourceFile.fileName, options.target); if (!newSourceFile) { return false; } + const normalizedAbsolutePath = getNormalizedAbsolutePath(newSourceFile.fileName, currentDirectory); + normalizedAbsoluteFileNames.push(normalizedAbsolutePath); + if (oldSourceFile !== newSourceFile) { if (oldSourceFile.hasNoDefaultLib !== newSourceFile.hasNoDefaultLib) { // value of no-default-lib has changed @@ -461,7 +469,7 @@ namespace ts { if (resolveModuleNamesWorker) { let moduleNames = map(newSourceFile.imports, name => name.text); - let resolutions = resolveModuleNamesWorker(moduleNames, newSourceFile.fileName); + let resolutions = resolveModuleNamesWorker(moduleNames, normalizedAbsolutePath); // ensure that module resolution results are still correct for (let i = 0; i < moduleNames.length; ++i) { let newResolution = resolutions[i]; @@ -491,8 +499,8 @@ namespace ts { } // update fileName -> file mapping - for (let file of newSourceFiles) { - filesByName.set(file.fileName, file); + for (let i = 0, len = newSourceFiles.length; i < len; ++i) { + filesByName.set(normalizedAbsoluteFileNames[i], newSourceFiles[i]); } files = newSourceFiles; @@ -508,10 +516,10 @@ namespace ts { function getEmitHost(writeFileCallback?: WriteFileCallback): EmitHost { return { - getCanonicalFileName: fileName => host.getCanonicalFileName(fileName), + getCanonicalFileName, getCommonSourceDirectory: program.getCommonSourceDirectory, getCompilerOptions: program.getCompilerOptions, - getCurrentDirectory: () => host.getCurrentDirectory(), + getCurrentDirectory: () => currentDirectory, getNewLine: () => host.getNewLine(), getSourceFile: program.getSourceFile, getSourceFiles: program.getSourceFiles, @@ -561,10 +569,8 @@ namespace ts { return emitResult; } - function getSourceFile(fileName: string) { - // first try to use file name as is to find file - // then try to convert relative file name to absolute and use it to retrieve source file - return filesByName.get(fileName) || filesByName.get(getNormalizedAbsolutePath(fileName, host.getCurrentDirectory())); + function getSourceFile(fileName: string): SourceFile { + return filesByName.get(getNormalizedAbsolutePath(fileName, currentDirectory)); } function getDiagnosticsHelper( @@ -735,7 +741,7 @@ namespace ts { diagnostic = Diagnostics.File_0_has_unsupported_extension_The_only_supported_extensions_are_1; diagnosticArgument = [fileName, "'" + supportedExtensions.join("', '") + "'"]; } - else if (!findSourceFile(fileName, isDefaultLib, refFile, refPos, refEnd)) { + else if (!findSourceFile(fileName, getNormalizedAbsolutePath(fileName, currentDirectory), isDefaultLib, refFile, refPos, refEnd)) { diagnostic = Diagnostics.File_0_not_found; diagnosticArgument = [fileName]; } @@ -745,13 +751,13 @@ namespace ts { } } else { - let nonTsFile: SourceFile = options.allowNonTsExtensions && findSourceFile(fileName, isDefaultLib, refFile, refPos, refEnd); + let nonTsFile: SourceFile = options.allowNonTsExtensions && findSourceFile(fileName, getNormalizedAbsolutePath(fileName, currentDirectory), 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, isDefaultLib, refFile, refPos, refEnd))) { + else if (!forEach(supportedExtensions, extension => findSourceFile(fileName + extension, getNormalizedAbsolutePath(fileName + extension, currentDirectory), isDefaultLib, refFile, refPos, refEnd))) { diagnostic = Diagnostics.File_0_not_found; fileName += ".ts"; diagnosticArgument = [fileName]; @@ -769,19 +775,26 @@ namespace ts { } } - // Get source file from normalized fileName - function findSourceFile(fileName: string, isDefaultLib: boolean, refFile?: SourceFile, refPos?: number, refEnd?: number): SourceFile { - if (filesByName.contains(fileName)) { - // We've already looked for this file, use cached result - return getSourceFileFromCache(fileName, /*useAbsolutePath*/ false); + function reportFileNamesDifferOnlyInCasingError(fileName: string, existingFileName: string, refFile: SourceFile, refPos: number, refEnd: number): void { + if (refFile !== undefined && refPos !== undefined && refEnd !== undefined) { + fileProcessingDiagnostics.add(createFileDiagnostic(refFile, refPos, refEnd - refPos, + Diagnostics.File_name_0_differs_from_already_included_file_name_1_only_in_casing, fileName, existingFileName)); } + else { + fileProcessingDiagnostics.add(createCompilerDiagnostic(Diagnostics.File_name_0_differs_from_already_included_file_name_1_only_in_casing, fileName, existingFileName)); + } + } - let normalizedAbsolutePath = getNormalizedAbsolutePath(fileName, host.getCurrentDirectory()); + // Get source file from normalized fileName + function findSourceFile(fileName: string, normalizedAbsolutePath: string, isDefaultLib: boolean, refFile?: SourceFile, refPos?: number, refEnd?: number): SourceFile { if (filesByName.contains(normalizedAbsolutePath)) { - const file = getSourceFileFromCache(normalizedAbsolutePath, /*useAbsolutePath*/ true); - // we don't have resolution for this relative file name but the match was found by absolute file name - // store resolution for relative name as well - filesByName.set(fileName, file); + const file = filesByName.get(normalizedAbsolutePath); + // try to check if we've already seen this file but with a different casing in path + // NOTE: this only makes sense for case-insensitive file systems + if (file && options.forceConsistentCasingInFileNames && getNormalizedAbsolutePath(file.fileName, currentDirectory) !== normalizedAbsolutePath) { + reportFileNamesDifferOnlyInCasingError(fileName, file.fileName, refFile, refPos, refEnd); + } + return file; } @@ -796,12 +809,20 @@ namespace ts { } }); - filesByName.set(fileName, file); + filesByName.set(normalizedAbsolutePath, file); if (file) { - skipDefaultLib = skipDefaultLib || file.hasNoDefaultLib; + if (host.useCaseSensitiveFileNames()) { + // for case-sensitive file systems check if we've already seen some file with similar filename ignoring case + const existingFile = filesByNameIgnoreCase.get(normalizedAbsolutePath); + if (existingFile) { + reportFileNamesDifferOnlyInCasingError(fileName, existingFile.fileName, refFile, refPos, refEnd); + } + else { + filesByNameIgnoreCase.set(normalizedAbsolutePath, file); + } + } - // Set the source file for normalized absolute path - filesByName.set(normalizedAbsolutePath, file); + skipDefaultLib = skipDefaultLib || file.hasNoDefaultLib; let basePath = getDirectoryPath(fileName); if (!options.noResolve) { @@ -821,23 +842,6 @@ namespace ts { } return file; - - function getSourceFileFromCache(fileName: string, useAbsolutePath: boolean): SourceFile { - let file = filesByName.get(fileName); - if (file && host.useCaseSensitiveFileNames()) { - let sourceFileName = useAbsolutePath ? getNormalizedAbsolutePath(file.fileName, host.getCurrentDirectory()) : file.fileName; - if (normalizeSlashes(fileName) !== normalizeSlashes(sourceFileName)) { - if (refFile !== undefined && refPos !== undefined && refEnd !== undefined) { - fileProcessingDiagnostics.add(createFileDiagnostic(refFile, refPos, refEnd - refPos, - Diagnostics.File_name_0_differs_from_already_included_file_name_1_only_in_casing, fileName, sourceFileName)); - } - else { - fileProcessingDiagnostics.add(createCompilerDiagnostic(Diagnostics.File_name_0_differs_from_already_included_file_name_1_only_in_casing, fileName, sourceFileName)); - } - } - } - return file; - } } function processReferencedFiles(file: SourceFile, basePath: string) { @@ -847,17 +851,29 @@ namespace ts { }); } + function getCanonicalFileName(fileName: string): string { + return host.getCanonicalFileName(fileName); + } + function processImportedModules(file: SourceFile, basePath: string) { collectExternalModuleReferences(file); if (file.imports.length) { file.resolvedModules = {}; let moduleNames = map(file.imports, name => name.text); - let resolutions = resolveModuleNamesWorker(moduleNames, file.fileName); + let resolutions = resolveModuleNamesWorker(moduleNames, getNormalizedAbsolutePath(file.fileName, currentDirectory)); for (let i = 0; i < file.imports.length; ++i) { let resolution = resolutions[i]; setResolvedModule(file, moduleNames[i], resolution); if (resolution && !options.noResolve) { - const importedFile = findModuleSourceFile(resolution.resolvedFileName, file.imports[i]); + const absoluteImportPath = isRootedDiskPath(resolution.resolvedFileName) + ? resolution.resolvedFileName + : getNormalizedAbsolutePath(resolution.resolvedFileName, currentDirectory); + + // convert an absolute import path to path that is relative to current directory + // this was host still can locate it but files names in user output will be shorter (and thus look nicer). + const relativePath = getRelativePathToDirectoryOrUrl(currentDirectory, absoluteImportPath, currentDirectory, getCanonicalFileName, false); + const importedFile = findSourceFile(relativePath, absoluteImportPath, /* isDefaultLib */ false, file, skipTrivia(file.text, file.imports[i].pos), file.imports[i].end); + if (importedFile && resolution.isExternalLibraryImport) { if (!isExternalModule(importedFile)) { let start = getTokenPosOfNode(file.imports[i], file); @@ -880,15 +896,10 @@ namespace ts { file.resolvedModules = undefined; } return; - - function findModuleSourceFile(fileName: string, nameLiteral: Expression) { - return findSourceFile(fileName, /* isDefaultLib */ false, file, skipTrivia(file.text, nameLiteral.pos), nameLiteral.end); - } } function computeCommonSourceDirectory(sourceFiles: SourceFile[]): string { let commonPathComponents: string[]; - let currentDirectory = host.getCurrentDirectory(); forEach(files, sourceFile => { // Each file contributes into common source file path if (isDeclarationFile(sourceFile)) { @@ -929,7 +940,6 @@ namespace ts { function checkSourceFilesBelongToPath(sourceFiles: SourceFile[], rootDirectory: string): boolean { let allFilesBelongToPath = true; if (sourceFiles) { - let currentDirectory = host.getCurrentDirectory(); let absoluteRootDirectoryPath = host.getCanonicalFileName(getNormalizedAbsolutePath(rootDirectory, currentDirectory)); for (var sourceFile of sourceFiles) { @@ -1034,7 +1044,7 @@ namespace ts { if (options.rootDir && checkSourceFilesBelongToPath(files, options.rootDir)) { // If a rootDir is specified and is valid use it as the commonSourceDirectory - commonSourceDirectory = getNormalizedAbsolutePath(options.rootDir, host.getCurrentDirectory()); + commonSourceDirectory = getNormalizedAbsolutePath(options.rootDir, currentDirectory); } else { // Compute the commonSourceDirectory from the input files diff --git a/src/compiler/types.ts b/src/compiler/types.ts index c44c6ad2cc0..c42273e8d3d 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -2088,6 +2088,7 @@ namespace ts { experimentalDecorators?: boolean; emitDecoratorMetadata?: boolean; moduleResolution?: ModuleResolutionKind; + forceConsistentCasingInFileNames?: boolean; /* @internal */ stripInternal?: boolean; // Skip checking lib.d.ts to help speed up tests. diff --git a/src/harness/harness.ts b/src/harness/harness.ts index a37b647a124..93d3e896d3a 100644 --- a/src/harness/harness.ts +++ b/src/harness/harness.ts @@ -921,7 +921,9 @@ namespace Harness { function register(file: { unitName: string; content: string; }) { if (file.content !== undefined) { let fileName = ts.normalizePath(file.unitName); - filemap[getCanonicalFileName(fileName)] = createSourceFileAndAssertInvariants(fileName, file.content, scriptTarget); + const sourceFile = createSourceFileAndAssertInvariants(fileName, file.content, scriptTarget); + filemap[getCanonicalFileName(fileName)] = sourceFile; + filemap[getCanonicalFileName(ts.getNormalizedAbsolutePath(fileName, getCurrentDirectory()))] = sourceFile; } }; inputFiles.forEach(register); diff --git a/src/harness/projectsRunner.ts b/src/harness/projectsRunner.ts index 862e446352d..74539b70848 100644 --- a/src/harness/projectsRunner.ts +++ b/src/harness/projectsRunner.ts @@ -127,7 +127,7 @@ class ProjectRunner extends RunnerBase { } function compileProjectFiles(moduleKind: ts.ModuleKind, getInputFiles: () => string[], - getSourceFileText: (fileName: string) => string, + getSourceFileTextImpl: (fileName: string) => string, writeFile: (fileName: string, data: string, writeByteOrderMark: boolean) => void): CompileProjectFilesResult { let program = ts.createProgram(getInputFiles(), createCompilerOptions(), createCompilerHost()); @@ -170,6 +170,11 @@ class ProjectRunner extends RunnerBase { }; } + function getSourceFileText(fileName: string): string { + const text = getSourceFileTextImpl(fileName); + return text !== undefined ? text : getSourceFileTextImpl(ts.getNormalizedAbsolutePath(fileName, getCurrentDirectory())); + } + function getSourceFile(fileName: string, languageVersion: ts.ScriptTarget): ts.SourceFile { let sourceFile: ts.SourceFile = undefined; if (fileName === Harness.Compiler.defaultLibFileName) { @@ -194,7 +199,7 @@ class ProjectRunner extends RunnerBase { getCanonicalFileName: Harness.Compiler.getCanonicalFileName, useCaseSensitiveFileNames: () => Harness.IO.useCaseSensitiveFileNames(), getNewLine: () => Harness.IO.newLine(), - fileExists: fileName => getSourceFile(fileName, ts.ScriptTarget.ES5) !== undefined, + fileExists: fileName => fileName === Harness.Compiler.defaultLibFileName || getSourceFileText(fileName) !== undefined, readFile: fileName => Harness.IO.readFile(fileName) }; } @@ -318,7 +323,16 @@ class ProjectRunner extends RunnerBase { return ts.map(allInputFiles, outputFile => outputFile.emittedFileName); } function getSourceFileText(fileName: string): string { - return ts.forEach(allInputFiles, inputFile => inputFile.emittedFileName === fileName ? inputFile.code : undefined); + for (const inputFile of allInputFiles) { + const isMatchingFile = ts.isRootedDiskPath(fileName) + ? ts.getNormalizedAbsolutePath(inputFile.emittedFileName, getCurrentDirectory()) === fileName + : inputFile.emittedFileName === fileName; + + if (isMatchingFile) { + return inputFile.code; + } + } + return undefined; } function writeFile(fileName: string, data: string, writeByteOrderMark: boolean) { diff --git a/tests/cases/unittests/moduleResolution.ts b/tests/cases/unittests/moduleResolution.ts index b5c2c70e491..0758fe7cfd5 100644 --- a/tests/cases/unittests/moduleResolution.ts +++ b/tests/cases/unittests/moduleResolution.ts @@ -6,21 +6,35 @@ declare namespace chai.assert { } module ts { + function diagnosticToString(diagnostic: Diagnostic) { + let output = ""; + + if (diagnostic.file) { + let loc = getLineAndCharacterOfPosition(diagnostic.file, diagnostic.start); + + output += `${diagnostic.file.fileName}(${loc.line + 1},${loc.character + 1}): `; + } + + let category = DiagnosticCategory[diagnostic.category].toLowerCase(); + output += `${category} TS${diagnostic.code}: ${flattenDiagnosticMessageText(diagnostic.messageText, sys.newLine)}${sys.newLine}`; + + return output; + } interface File { name: string - content?: string + content?: string } function createModuleResolutionHost(...files: File[]): ModuleResolutionHost { let map = arrayToMap(files, f => f.name); - + return { fileExists, readFile }; - + function fileExists(path: string): boolean { return hasProperty(map, path); } - + function readFile(path: string): string { return hasProperty(map, path) ? map[path].content : undefined; } @@ -28,18 +42,18 @@ module ts { function splitPath(path: string): { dir: string; rel: string } { let index = path.indexOf(directorySeparator); - return index === -1 + return index === -1 ? { dir: path, rel: undefined } : { dir: path.substr(0, index), rel: path.substr(index + 1) }; } describe("Node module resolution - relative paths", () => { - + function testLoadAsFile(containingFileName: string, moduleFileNameNoExt: string, moduleName: string): void { for (let ext of supportedExtensions) { let containingFile = { name: containingFileName } let moduleFile = { name: moduleFileNameNoExt + ext } - let resolution = nodeModuleNameResolver(moduleName, containingFile.name, createModuleResolutionHost(containingFile, moduleFile)); + let resolution = nodeModuleNameResolver(moduleName, containingFile.name, createModuleResolutionHost(containingFile, moduleFile)); assert.equal(resolution.resolvedModule.resolvedFileName, moduleFile.name); assert.equal(!!resolution.resolvedModule.isExternalLibraryImport, false); @@ -53,11 +67,11 @@ module ts { failedLookupLocations.push(normalizePath(getRootLength(moduleName) === 0 ? combinePaths(dir, moduleName) : moduleName) + e); } } - + assert.deepEqual(resolution.failedLookupLocations, failedLookupLocations); } } - + it("module name that starts with './' resolved as relative file name", () => { testLoadAsFile("/foo/bar/baz.ts", "/foo/bar/foo", "./foo"); }); @@ -73,7 +87,7 @@ module ts { it("module name that starts with 'c:/' script extension resolved as relative file name", () => { testLoadAsFile("c:/foo/bar/baz.ts", "c:/foo", "c:/foo"); }); - + function testLoadingFromPackageJson(containingFileName: string, packageJsonFileName: string, fieldRef: string, moduleFileName: string, moduleName: string): void { let containingFile = { name: containingFileName }; let packageJson = { name: packageJsonFileName, content: JSON.stringify({ "typings": fieldRef }) }; @@ -84,17 +98,17 @@ module ts { // expect three failed lookup location - attempt to load module as file with all supported extensions assert.equal(resolution.failedLookupLocations.length, 3); } - + it("module name as directory - load from typings", () => { testLoadingFromPackageJson("/a/b/c/d.ts", "/a/b/c/bar/package.json", "c/d/e.d.ts", "/a/b/c/bar/c/d/e.d.ts", "./bar"); testLoadingFromPackageJson("/a/b/c/d.ts", "/a/bar/package.json", "e.d.ts", "/a/bar/e.d.ts", "../../bar"); testLoadingFromPackageJson("/a/b/c/d.ts", "/bar/package.json", "e.d.ts", "/bar/e.d.ts", "/bar"); testLoadingFromPackageJson("c:/a/b/c/d.ts", "c:/bar/package.json", "e.d.ts", "c:/bar/e.d.ts", "c:/bar"); }); - - it ("module name as directory - load index.d.ts", () => { - let containingFile = {name: "/a/b/c.ts"}; - let packageJson = {name: "/a/b/foo/package.json", content: JSON.stringify({main: "/c/d"})}; + + it("module name as directory - load index.d.ts", () => { + let containingFile = { name: "/a/b/c.ts" }; + let packageJson = { name: "/a/b/foo/package.json", content: JSON.stringify({ main: "/c/d" }) }; let indexFile = { name: "/a/b/foo/index.d.ts" }; let resolution = nodeModuleNameResolver("./foo", containingFile.name, createModuleResolutionHost(containingFile, packageJson, indexFile)); assert.equal(resolution.resolvedModule.resolvedFileName, indexFile.name); @@ -108,7 +122,7 @@ module ts { ]); }); }); - + describe("Node module resolution - non-relative paths", () => { it("load module as file - ts files not loaded", () => { let containingFile = { name: "/a/b/c/d/e.ts" }; @@ -140,7 +154,7 @@ module ts { assert.equal(resolution.resolvedModule.resolvedFileName, moduleFile.name); assert.equal(resolution.resolvedModule.isExternalLibraryImport, true); }); - + it("load module as directory", () => { let containingFile = { name: "/a/node_modules/b/c/node_modules/d/e.ts" }; let moduleFile = { name: "/a/node_modules/foo/index.d.ts" }; @@ -178,31 +192,15 @@ module ts { ]); }); }); - + describe("Module resolution - relative imports", () => { - it("should find all modules", () => { - const options: CompilerOptions = { module: ModuleKind.CommonJS }; - const files: Map = { - "/a/b/c/first/shared.ts": ` -class A {} -export = A`, - "/a/b/c/first/second/class_a.ts": ` -import Shared = require('../shared'); -import C = require('../../third/class_c'); -class B {} -export = B;`, - "/a/b/c/third/class_c.ts":` -import Shared = require('../first/shared'); -class C {} -export = C; - ` - }; - const currentDirectory = "/a/b/c/first/second"; - const host: CompilerHost = { - getSourceFile: (fileName: string, languageVersion: ScriptTarget) => { - let path = normalizePath(combinePaths(currentDirectory, fileName)); - return hasProperty(files, path) ? createSourceFile(fileName, files[path], languageVersion) : undefined; - }, + function test(files: Map, currentDirectory: string, rootFiles: string[], expectedFilesCount: number, relativeNamesToCheck: string[]) { + const options: CompilerOptions = { module: ModuleKind.CommonJS }; + const host: CompilerHost = { + getSourceFile: (fileName: string, languageVersion: ScriptTarget) => { + let path = normalizePath(combinePaths(currentDirectory, fileName)); + return hasProperty(files, path) ? createSourceFile(fileName, files[path], languageVersion) : undefined; + }, getDefaultLibFileName: () => "lib.d.ts", writeFile: (fileName, content): void => { throw new Error("NotImplemented"); }, getCurrentDirectory: () => currentDirectory, @@ -210,38 +208,125 @@ export = C; getNewLine: () => "\r\n", useCaseSensitiveFileNames: () => false, fileExists: fileName => { - let path = normalizePath(combinePaths(currentDirectory, fileName)); - return hasProperty(files, path); + let path = normalizePath(combinePaths(currentDirectory, fileName)); + return hasProperty(files, path); }, readFile: (fileName): string => { throw new Error("NotImplemented"); } - }; + }; - const program = createProgram(["class_a.ts"], options, host); + const program = createProgram(rootFiles, options, host); - assert.equal(program.getSourceFiles().length, 3); - const syntacticDiagnostics = program.getSyntacticDiagnostics(); - assert.equal(syntacticDiagnostics.length, 0, `expect no syntactic diagnostics, got: ${JSON.stringify(syntacticDiagnostics.map(diagnosticToString))}`); - const semanticDiagnostics = program.getSemanticDiagnostics(); - assert.equal(semanticDiagnostics.length, 0, `expect no semantic diagnostics, got: ${JSON.stringify(semanticDiagnostics.map(diagnosticToString))}`); + assert.equal(program.getSourceFiles().length, expectedFilesCount); + const syntacticDiagnostics = program.getSyntacticDiagnostics(); + assert.equal(syntacticDiagnostics.length, 0, `expect no syntactic diagnostics, got: ${JSON.stringify(syntacticDiagnostics.map(diagnosticToString))}`); + const semanticDiagnostics = program.getSemanticDiagnostics(); + assert.equal(semanticDiagnostics.length, 0, `expect no semantic diagnostics, got: ${JSON.stringify(semanticDiagnostics.map(diagnosticToString))}`); - // try to get file using a relative name - const fileC = program.getSourceFile("../../../c/third/class_c.ts"); - assert.isTrue(fileC !== undefined, `expected to get file by relative name, got ${fileC}`); - }); - - function diagnosticToString(diagnostic: Diagnostic) { - let output = ""; - - if (diagnostic.file) { - let loc = getLineAndCharacterOfPosition(diagnostic.file, diagnostic.start); - - output += `${ diagnostic.file.fileName }(${ loc.line + 1 },${ loc.character + 1 }): `; + // try to get file using a relative name + for (const relativeFileName of relativeNamesToCheck) { + assert.isTrue(program.getSourceFile(relativeFileName) !== undefined, `expected to get file by relative name, got undefined`); } - - let category = DiagnosticCategory[diagnostic.category].toLowerCase(); - output += `${ category } TS${ diagnostic.code }: ${ flattenDiagnosticMessageText(diagnostic.messageText, sys.newLine) }${ sys.newLine }`; - - return output; } + + it("should find all modules", () => { + const files: Map = { + "/a/b/c/first/shared.ts": ` +class A {} +export = A`, + "/a/b/c/first/second/class_a.ts": ` +import Shared = require('../shared'); +import C = require('../../third/class_c'); +class B {} +export = B;`, + "/a/b/c/third/class_c.ts": ` +import Shared = require('../first/shared'); +class C {} +export = C; + ` + }; + test(files, "/a/b/c/first/second", ["class_a.ts"], 3, ["../../../c/third/class_c.ts"]); + }); + + it("should find modules in node_modules", () => { + const files: Map = { + "/parent/node_modules/mod/index.d.ts": "export var x", + "/parent/app/myapp.ts": `import {x} from "mod"` + }; + test(files, "/parent/app",["myapp.ts"], 2, []); + }); + }); + + describe("Files with different casing", () => { + const library = createSourceFile("lib.d.ts", "", ScriptTarget.ES5); + function test(files: Map, options: CompilerOptions, currentDirectory: string, useCaseSensitiveFileNames: boolean, rootFiles: string[], diagnosticCodes: number[]): void { + const getCanonicalFileName = createGetCanonicalFileName(useCaseSensitiveFileNames); + if (!useCaseSensitiveFileNames) { + let f: Map = {}; + for (let fileName in files) { + f[getCanonicalFileName(fileName)] = files[fileName]; + } + files = f; + } + + const host: CompilerHost = { + getSourceFile: (fileName: string, languageVersion: ScriptTarget) => { + if (fileName === "lib.d.ts") { + return library; + } + let path = getCanonicalFileName(normalizePath(combinePaths(currentDirectory, fileName))); + return hasProperty(files, path) ? createSourceFile(fileName, files[path], languageVersion) : undefined; + }, + getDefaultLibFileName: () => "lib.d.ts", + writeFile: (fileName, content): void => { throw new Error("NotImplemented"); }, + getCurrentDirectory: () => currentDirectory, + getCanonicalFileName, + getNewLine: () => "\r\n", + useCaseSensitiveFileNames: () => useCaseSensitiveFileNames, + fileExists: fileName => { + let path = getCanonicalFileName(normalizePath(combinePaths(currentDirectory, fileName))); + return hasProperty(files, path); + }, + readFile: (fileName): string => { throw new Error("NotImplemented"); } + }; + const program = createProgram(rootFiles, options, host); + const diagnostics = sortAndDeduplicateDiagnostics(program.getSemanticDiagnostics().concat(program.getOptionsDiagnostics())); + assert.equal(diagnostics.length, diagnosticCodes.length, `Incorrect number of expected diagnostics, expected ${diagnosticCodes.length}, got '${map(diagnostics, diagnosticToString).join("\r\n")}'`); + for (let i = 0; i < diagnosticCodes.length; ++i) { + assert.equal(diagnostics[i].code, diagnosticCodes[i], `Expected diagnostic code ${diagnosticCodes[i]}, got '${diagnostics[i].code}': '${diagnostics[i].messageText}'`); + } + } + + it("should succeed when the same file is referenced using absolute and relative names", () => { + const files: Map = { + "/a/b/c.ts": `/// `, + "/a/b/d.ts": "var x" + }; + test(files, { module: ts.ModuleKind.AMD }, "/a/b", /* useCaseSensitiveFileNames */ false, ["c.ts", "/a/b/d.ts"], []); + }); + + it("should fail when two files used in program differ only in casing (tripleslash references)", () => { + const files: Map = { + "/a/b/c.ts": `/// `, + "/a/b/d.ts": "var x" + }; + test(files, { module: ts.ModuleKind.AMD, forceConsistentCasingInFileNames: true }, "/a/b", /* useCaseSensitiveFileNames */ false, ["c.ts", "d.ts"], [1149]); + }); + + it("should fail when two files used in program differ only in casing (imports)", () => { + const files: Map = { + "/a/b/c.ts": `import {x} from "D"`, + "/a/b/d.ts": "export var x" + }; + test(files, { module: ts.ModuleKind.AMD, forceConsistentCasingInFileNames: true }, "/a/b", /* useCaseSensitiveFileNames */ false, ["c.ts", "d.ts"], [1149]); + }); + + it("should fail when two files exist on disk that differs only in casing", () => { + const files: Map = { + "/a/b/c.ts": `import {x} from "D"`, + "/a/b/D.ts": "export var x", + "/a/b/d.ts": "export var y" + }; + test(files, { module: ts.ModuleKind.AMD }, "/a/b", /* useCaseSensitiveFileNames */ true, ["c.ts", "d.ts"], [1149]); + }); }); } \ No newline at end of file From 2f7719b61d3d97659a1bf430c4e48bf7897a3c0b Mon Sep 17 00:00:00 2001 From: Ryan Cavanaugh Date: Fri, 16 Oct 2015 16:40:04 -0700 Subject: [PATCH 070/227] Address CR feedback --- src/compiler/binder.ts | 22 +++++++++--------- src/compiler/checker.ts | 24 ++++++-------------- tests/cases/fourslash/javaScriptModules13.ts | 3 --- 3 files changed, 18 insertions(+), 31 deletions(-) diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index 4e0d5225f58..d5ab7dd11ca 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -166,13 +166,12 @@ namespace ts { return "__export"; case SyntaxKind.ExportAssignment: return (node).isExportEquals ? "export=" : "default"; + case SyntaxKind.BinaryExpression: + // Binary expression case is for JS module 'module.exports = expr' + return "export="; case SyntaxKind.FunctionDeclaration: case SyntaxKind.ClassDeclaration: return node.flags & NodeFlags.Default ? "default" : undefined; - - case SyntaxKind.BinaryExpression: - Debug.assert(isModuleExportsAssignment(node)); - return "__jsExports"; } } @@ -936,9 +935,7 @@ namespace ts { return bindAnonymousDeclaration(node, SymbolFlags.Function, bindingName); case SyntaxKind.CallExpression: - // We're only inspecting call expressions to detect CommonJS modules, so we can skip - // this check if we've already seen the module indicator - if (isJavaScriptFile && !file.commonJsModuleIndicator) { + if (isJavaScriptFile) { bindCallExpression(node); } break; @@ -984,12 +981,13 @@ namespace ts { bindAnonymousDeclaration(file, SymbolFlags.ValueModule, `"${removeFileExtension(file.fileName) }"`); } - function bindExportAssignment(node: ExportAssignment) { + function bindExportAssignment(node: ExportAssignment|BinaryExpression) { + let boundExpression = node.kind === SyntaxKind.ExportAssignment ? (node).expression : (node).right; if (!container.symbol || !container.symbol.exports) { // Export assignment in some sort of block construct bindAnonymousDeclaration(node, SymbolFlags.Alias, getDeclarationName(node)); } - else if (node.expression.kind === SyntaxKind.Identifier) { + else if (boundExpression.kind === SyntaxKind.Identifier) { // An export default clause with an identifier exports all meanings of that identifier declareSymbol(container.symbol.exports, container.symbol, node, SymbolFlags.Alias, SymbolFlags.PropertyExcludes | SymbolFlags.AliasExcludes); } @@ -1033,11 +1031,13 @@ namespace ts { function bindModuleExportsAssignment(node: BinaryExpression) { // 'module.exports = expr' assignment setCommonJsModuleIndicator(node); - declareSymbol(file.symbol.exports, file.symbol, node, SymbolFlags.None, SymbolFlags.None); + bindExportAssignment(node); } function bindCallExpression(node: CallExpression) { - if (isRequireCall(node)) { + // We're only inspecting call expressions to detect CommonJS modules, so we can skip + // this check if we've already seen the module indicator + if (!file.commonJsModuleIndicator && isRequireCall(node)) { setCommonJsModuleIndicator(node); } } diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 7e15f0a3ad0..f0c81940192 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -1087,20 +1087,6 @@ namespace ts { visit(resolveExternalModuleName(node, (node).moduleSpecifier)); } } - - // CommonJS 'module.exports = expr' assignments - let commonJsModuleExports = symbol.exports["__jsExports"]; - if (commonJsModuleExports) { - for (var i = 0; i < commonJsModuleExports.declarations.length; i++) { - let properties = getPropertiesOfType(checkExpression((commonJsModuleExports.declarations[i]).right)); - if (i === 0) { - result = createSymbolTable(properties); - } - else { - mergeSymbolTable(result, createSymbolTable(properties)); - } - } - } } } } @@ -2586,6 +2572,10 @@ namespace ts { if (declaration.kind === SyntaxKind.ExportAssignment) { return links.type = checkExpression((declaration).expression); } + // Handle module.exports = expr + if (declaration.kind === SyntaxKind.BinaryExpression) { + return links.type = checkExpression((declaration).right); + } // Handle exports.p = expr if (declaration.kind === SyntaxKind.PropertyAccessExpression && declaration.parent.kind === SyntaxKind.BinaryExpression) { return checkExpressionCached((declaration.parent).right); @@ -3839,9 +3829,9 @@ namespace ts { function resolveExternalModuleTypeByLiteral(name: StringLiteral) { let moduleSym = resolveExternalModuleName(name, name); if (moduleSym) { - let moduleSymSym = resolveExternalModuleSymbol(moduleSym); - if (moduleSymSym) { - return getTypeOfSymbol(moduleSymSym); + let resolvedModuleSymbol = resolveExternalModuleSymbol(moduleSym); + if (resolvedModuleSymbol) { + return getTypeOfSymbol(resolvedModuleSymbol); } } diff --git a/tests/cases/fourslash/javaScriptModules13.ts b/tests/cases/fourslash/javaScriptModules13.ts index 215f47e9ad6..8b22971009c 100644 --- a/tests/cases/fourslash/javaScriptModules13.ts +++ b/tests/cases/fourslash/javaScriptModules13.ts @@ -6,8 +6,6 @@ // @Filename: myMod.js //// if (true) { //// module.exports = { a: 10 }; -//// } else { -//// module.exports = { b: 10 }; //// } //// var invisible = true; @@ -26,4 +24,3 @@ verify.not.completionListContains('invisible'); edit.insert('x.'); verify.completionListContains('a'); -verify.completionListContains('b'); From 61b71008d71be7c65c3c75657c85875b810b1482 Mon Sep 17 00:00:00 2001 From: Ryan Cavanaugh Date: Fri, 16 Oct 2015 17:35:43 -0700 Subject: [PATCH 071/227] Remove obsolute AMD logic from reference preprocessing in services --- src/services/services.ts | 16 +------ .../unittests/services/preProcessFile.ts | 48 ------------------- 2 files changed, 1 insertion(+), 63 deletions(-) diff --git a/src/services/services.ts b/src/services/services.ts index a6611a3d39a..30d993cb6b6 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -2351,21 +2351,7 @@ namespace ts { while (token !== SyntaxKind.CloseBracketToken && token !== SyntaxKind.EndOfFileToken) { // record string literals as module names if (token === SyntaxKind.StringLiteral) { - const moduleName = scanner.getTokenValue(); - // record first item in the list only if its name is not "require" - // record second item in the list only if its name is not "exports" - // record third item in the list only if its name is not "module" - // record all other items in the list unconditionally - const shouldRecordName = - i === 0 - ? moduleName !== "require" - : i === 1 - ? moduleName !== "exports" - : i !== 2 || moduleName !== "module"; - - if (shouldRecordName) { - recordModuleName(); - } + recordModuleName(); i++; } diff --git a/tests/cases/unittests/services/preProcessFile.ts b/tests/cases/unittests/services/preProcessFile.ts index aba5ce15c03..d9ddaf0f256 100644 --- a/tests/cases/unittests/services/preProcessFile.ts +++ b/tests/cases/unittests/services/preProcessFile.ts @@ -262,54 +262,6 @@ describe('PreProcessFile:', function () { isLibFile: false }) }); - it("Excludes require/exports/module names from dependency lists in define(modName, [deplist]) calls in JavaScript files", function () { - test(` - define(["require", "exports", "module", "mod1", "mod2"], (m1, m2) => { - }); - `, - /* readImports */true, - /* detectJavaScriptImports */ true, - { - referencedFiles: [], - importedFiles: [ - { fileName: "mod1", pos: 53, end: 57 }, - { fileName: "mod2", pos: 61, end: 65 }, - ], - ambientExternalModules: undefined, - isLibFile: false - }); - - test(` - define(["require", "exports", "mod1", "module"], (m1, m2) => { - }); - `, - /* readImports */true, - /* detectJavaScriptImports */ true, - { - referencedFiles: [], - importedFiles: [ - { fileName: "mod1", pos: 43, end: 47 }, - { fileName: "module", pos: 51, end: 57 }, - ], - ambientExternalModules: undefined, - isLibFile: false - }); - test(` - define(["require", "require", "exports"], (m1, m2) => { - }); - `, - /* readImports */true, - /* detectJavaScriptImports */ true, - { - referencedFiles: [], - importedFiles: [ - { fileName: "require", pos: 32, end: 39 }, - { fileName: "exports", pos: 43, end: 50 }, - ], - ambientExternalModules: undefined, - isLibFile: false - }); - }); }); }); From 5725fc4497d2aa2d0711cd2918ddde62f43cedff Mon Sep 17 00:00:00 2001 From: Ryan Cavanaugh Date: Mon, 19 Oct 2015 11:02:20 -0700 Subject: [PATCH 072/227] CR feedback --- lib/lib.core.d.ts | 16 ---- lib/lib.core.es6.d.ts | 45 ++++++---- lib/lib.d.ts | 168 ++++++-------------------------------- lib/lib.dom.d.ts | 152 ++++++---------------------------- lib/lib.es6.d.ts | 168 ++++++-------------------------------- lib/lib.webworker.d.ts | 7 +- src/compiler/checker.ts | 18 +--- src/compiler/utilities.ts | 5 +- src/lib/core.d.ts | 16 ---- 9 files changed, 119 insertions(+), 476 deletions(-) diff --git a/lib/lib.core.d.ts b/lib/lib.core.d.ts index c1a71dd8d1d..b588c9fdb77 100644 --- a/lib/lib.core.d.ts +++ b/lib/lib.core.d.ts @@ -1198,22 +1198,6 @@ interface PromiseLike { then(onfulfilled?: (value: T) => TResult | PromiseLike, onrejected?: (reason: any) => void): PromiseLike; } - -declare namespace CommonJS { - export var require: Require; - - export var exports: any; - - interface Exports { } - interface Module { - exports: Exports; - } - - interface Require { - (moduleName: string): any; - } -} - interface ArrayLike { length: number; [n: number]: T; diff --git a/lib/lib.core.es6.d.ts b/lib/lib.core.es6.d.ts index b0d4120b4b9..6d6a68559f8 100644 --- a/lib/lib.core.es6.d.ts +++ b/lib/lib.core.es6.d.ts @@ -1198,22 +1198,6 @@ interface PromiseLike { then(onfulfilled?: (value: T) => TResult | PromiseLike, onrejected?: (reason: any) => void): PromiseLike; } - -declare namespace CommonJS { - export var require: Require; - - export var exports: any; - - interface Exports { } - interface Module { - exports: Exports; - } - - interface Require { - (moduleName: string): any; - } -} - interface ArrayLike { length: number; [n: number]: T; @@ -3981,7 +3965,34 @@ interface ObjectConstructor { * Copy the values of all of the enumerable own properties from one or more source objects to a * target object. Returns the target object. * @param target The target object to copy to. - * @param sources One or more source objects to copy properties from. + * @param source The source object from which to copy properties. + */ + assign(target: T, source: U): T & U; + + /** + * Copy the values of all of the enumerable own properties from one or more source objects to a + * target object. Returns the target object. + * @param target The target object to copy to. + * @param source1 The first source object from which to copy properties. + * @param source2 The second source object from which to copy properties. + */ + assign(target: T, source1: U, source2: V): T & U & V; + + /** + * Copy the values of all of the enumerable own properties from one or more source objects to a + * target object. Returns the target object. + * @param target The target object to copy to. + * @param source1 The first source object from which to copy properties. + * @param source2 The second source object from which to copy properties. + * @param source3 The third source object from which to copy properties. + */ + assign(target: T, source1: U, source2: V, source3: W): T & U & V & W; + + /** + * Copy the values of all of the enumerable own properties from one or more source objects to a + * target object. Returns the target object. + * @param target The target object to copy to. + * @param sources One or more source objects from which to copy properties */ assign(target: any, ...sources: any[]): any; diff --git a/lib/lib.d.ts b/lib/lib.d.ts index 450f79b36e9..40a29796586 100644 --- a/lib/lib.d.ts +++ b/lib/lib.d.ts @@ -1198,22 +1198,6 @@ interface PromiseLike { then(onfulfilled?: (value: T) => TResult | PromiseLike, onrejected?: (reason: any) => void): PromiseLike; } - -declare namespace CommonJS { - export var require: Require; - - export var exports: any; - - interface Exports { } - interface Module { - exports: Exports; - } - - interface Require { - (moduleName: string): any; - } -} - interface ArrayLike { length: number; [n: number]: T; @@ -4259,8 +4243,8 @@ interface AnalyserNode extends AudioNode { smoothingTimeConstant: number; getByteFrequencyData(array: Uint8Array): void; getByteTimeDomainData(array: Uint8Array): void; - getFloatFrequencyData(array: any): void; - getFloatTimeDomainData(array: any): void; + getFloatFrequencyData(array: Float32Array): void; + getFloatTimeDomainData(array: Float32Array): void; } declare var AnalyserNode: { @@ -4347,7 +4331,7 @@ interface AudioBuffer { length: number; numberOfChannels: number; sampleRate: number; - getChannelData(channel: number): any; + getChannelData(channel: number): Float32Array; } declare var AudioBuffer: { @@ -4391,7 +4375,7 @@ interface AudioContext extends EventTarget { createMediaElementSource(mediaElement: HTMLMediaElement): MediaElementAudioSourceNode; createOscillator(): OscillatorNode; createPanner(): PannerNode; - createPeriodicWave(real: any, imag: any): PeriodicWave; + createPeriodicWave(real: Float32Array, imag: Float32Array): PeriodicWave; createScriptProcessor(bufferSize?: number, numberOfInputChannels?: number, numberOfOutputChannels?: number): ScriptProcessorNode; createStereoPanner(): StereoPannerNode; createWaveShaper(): WaveShaperNode; @@ -4449,7 +4433,7 @@ interface AudioParam { linearRampToValueAtTime(value: number, endTime: number): void; setTargetAtTime(target: number, startTime: number, timeConstant: number): void; setValueAtTime(value: number, startTime: number): void; - setValueCurveAtTime(values: any, startTime: number, duration: number): void; + setValueCurveAtTime(values: Float32Array, startTime: number, duration: number): void; } declare var AudioParam: { @@ -4525,7 +4509,7 @@ interface BiquadFilterNode extends AudioNode { frequency: AudioParam; gain: AudioParam; type: string; - getFrequencyResponse(frequencyHz: any, magResponse: any, phaseResponse: any): void; + getFrequencyResponse(frequencyHz: Float32Array, magResponse: Float32Array, phaseResponse: Float32Array): void; } declare var BiquadFilterNode: { @@ -5124,7 +5108,7 @@ declare var CanvasPattern: { interface CanvasRenderingContext2D { canvas: HTMLCanvasElement; - fillStyle: any; + fillStyle: string | CanvasGradient | CanvasPattern; font: string; globalAlpha: number; globalCompositeOperation: string; @@ -5139,7 +5123,7 @@ interface CanvasRenderingContext2D { shadowColor: string; shadowOffsetX: number; shadowOffsetY: number; - strokeStyle: any; + strokeStyle: string | CanvasGradient | CanvasPattern; textAlign: string; textBaseline: string; arc(x: number, y: number, radius: number, startAngle: number, endAngle: number, anticlockwise?: boolean): void; @@ -6507,8 +6491,6 @@ interface Document extends Node, GlobalEventHandlers, NodeSelector, DocumentEven importNode(importedNode: Node, deep: boolean): Node; msElementsFromPoint(x: number, y: number): NodeList; msElementsFromRect(left: number, top: number, width: number, height: number): NodeList; - msGetPrintDocumentForNamedFlow(flowName: string): Document; - msSetPrintDocumentUriForNamedFlow(flowName: string, uri: string): void; /** * Opens a new window and loads a document specified by a given URL. Also, opens a new window that uses the url parameter and the name parameter to collect the output of the write method and the writeln method. * @param url Specifies a MIME type for the document. @@ -11330,27 +11312,6 @@ declare var MSHTMLWebViewElement: { new(): MSHTMLWebViewElement; } -interface MSHeaderFooter { - URL: string; - dateLong: string; - dateShort: string; - font: string; - htmlFoot: string; - htmlHead: string; - page: number; - pageTotal: number; - textFoot: string; - textHead: string; - timeLong: string; - timeShort: string; - title: string; -} - -declare var MSHeaderFooter: { - prototype: MSHeaderFooter; - new(): MSHeaderFooter; -} - interface MSInputMethodContext extends EventTarget { compositionEndOffset: number; compositionStartOffset: number; @@ -11509,24 +11470,6 @@ declare var MSPointerEvent: { new(typeArg: string, eventInitDict?: PointerEventInit): MSPointerEvent; } -interface MSPrintManagerTemplatePrinter extends MSTemplatePrinter, EventTarget { - percentScale: number; - showHeaderFooter: boolean; - shrinkToFit: boolean; - drawPreviewPage(element: HTMLElement, pageNumber: number): void; - endPrint(): void; - getPrintTaskOptionValue(key: string): any; - invalidatePreview(): void; - setPageCount(pageCount: number): void; - startPrint(): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; -} - -declare var MSPrintManagerTemplatePrinter: { - prototype: MSPrintManagerTemplatePrinter; - new(): MSPrintManagerTemplatePrinter; -} - interface MSRangeCollection { length: number; item(index: number): Range; @@ -11574,63 +11517,6 @@ declare var MSStreamReader: { new(): MSStreamReader; } -interface MSTemplatePrinter { - collate: boolean; - copies: number; - currentPage: boolean; - currentPageAvail: boolean; - duplex: boolean; - footer: string; - frameActive: boolean; - frameActiveEnabled: boolean; - frameAsShown: boolean; - framesetDocument: boolean; - header: string; - headerFooterFont: string; - marginBottom: number; - marginLeft: number; - marginRight: number; - marginTop: number; - orientation: string; - pageFrom: number; - pageHeight: number; - pageTo: number; - pageWidth: number; - selectedPages: boolean; - selection: boolean; - selectionEnabled: boolean; - unprintableBottom: number; - unprintableLeft: number; - unprintableRight: number; - unprintableTop: number; - usePrinterCopyCollate: boolean; - createHeaderFooter(): MSHeaderFooter; - deviceSupports(property: string): any; - ensurePrintDialogDefaults(): boolean; - getPageMarginBottom(pageRule: CSSPageRule, pageWidth: number, pageHeight: number): any; - getPageMarginBottomImportant(pageRule: CSSPageRule): boolean; - getPageMarginLeft(pageRule: CSSPageRule, pageWidth: number, pageHeight: number): any; - getPageMarginLeftImportant(pageRule: CSSPageRule): boolean; - getPageMarginRight(pageRule: CSSPageRule, pageWidth: number, pageHeight: number): any; - getPageMarginRightImportant(pageRule: CSSPageRule): boolean; - getPageMarginTop(pageRule: CSSPageRule, pageWidth: number, pageHeight: number): any; - getPageMarginTopImportant(pageRule: CSSPageRule): boolean; - printBlankPage(): void; - printNonNative(document: any): boolean; - printNonNativeFrames(document: any, activeFrame: boolean): void; - printPage(element: HTMLElement): void; - showPageSetupDialog(): boolean; - showPrintDialog(): boolean; - startDoc(title: string): boolean; - stopDoc(): void; - updatePageStatus(status: number): void; -} - -declare var MSTemplatePrinter: { - prototype: MSTemplatePrinter; - new(): MSTemplatePrinter; -} - interface MSWebViewAsyncOperation extends EventTarget { error: DOMError; oncomplete: (ev: Event) => any; @@ -12048,6 +11934,10 @@ declare var Node: { } interface NodeFilter { + acceptNode(n: Node): number; +} + +declare var NodeFilter: { FILTER_ACCEPT: number; FILTER_REJECT: number; FILTER_SKIP: number; @@ -12065,7 +11955,6 @@ interface NodeFilter { SHOW_PROCESSING_INSTRUCTION: number; SHOW_TEXT: number; } -declare var NodeFilter: NodeFilter; interface NodeIterator { expandEntityReferences: boolean; @@ -12775,7 +12664,6 @@ declare var SVGDescElement: { interface SVGElement extends Element { id: string; - className: any; onclick: (ev: MouseEvent) => any; ondblclick: (ev: MouseEvent) => any; onfocusin: (ev: FocusEvent) => any; @@ -12789,6 +12677,7 @@ interface SVGElement extends Element { ownerSVGElement: SVGSVGElement; viewportElement: SVGElement; xmlbase: string; + className: any; addEventListener(type: "MSGestureChange", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; addEventListener(type: "MSGestureDoubleTap", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; addEventListener(type: "MSGestureEnd", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; @@ -14950,7 +14839,7 @@ declare var WEBGL_depth_texture: { } interface WaveShaperNode extends AudioNode { - curve: any; + curve: Float32Array; oversample: string; } @@ -15137,34 +15026,34 @@ interface WebGLRenderingContext { texSubImage2D(target: number, level: number, xoffset: number, yoffset: number, format: number, type: number, video: HTMLVideoElement): void; texSubImage2D(target: number, level: number, xoffset: number, yoffset: number, format: number, type: number, pixels: ImageData): void; uniform1f(location: WebGLUniformLocation, x: number): void; - uniform1fv(location: WebGLUniformLocation, v: any): void; + uniform1fv(location: WebGLUniformLocation, v: Float32Array): void; uniform1i(location: WebGLUniformLocation, x: number): void; uniform1iv(location: WebGLUniformLocation, v: Int32Array): void; uniform2f(location: WebGLUniformLocation, x: number, y: number): void; - uniform2fv(location: WebGLUniformLocation, v: any): void; + uniform2fv(location: WebGLUniformLocation, v: Float32Array): void; uniform2i(location: WebGLUniformLocation, x: number, y: number): void; uniform2iv(location: WebGLUniformLocation, v: Int32Array): void; uniform3f(location: WebGLUniformLocation, x: number, y: number, z: number): void; - uniform3fv(location: WebGLUniformLocation, v: any): void; + uniform3fv(location: WebGLUniformLocation, v: Float32Array): void; uniform3i(location: WebGLUniformLocation, x: number, y: number, z: number): void; uniform3iv(location: WebGLUniformLocation, v: Int32Array): void; uniform4f(location: WebGLUniformLocation, x: number, y: number, z: number, w: number): void; - uniform4fv(location: WebGLUniformLocation, v: any): void; + uniform4fv(location: WebGLUniformLocation, v: Float32Array): void; uniform4i(location: WebGLUniformLocation, x: number, y: number, z: number, w: number): void; uniform4iv(location: WebGLUniformLocation, v: Int32Array): void; - uniformMatrix2fv(location: WebGLUniformLocation, transpose: boolean, value: any): void; - uniformMatrix3fv(location: WebGLUniformLocation, transpose: boolean, value: any): void; - uniformMatrix4fv(location: WebGLUniformLocation, transpose: boolean, value: any): void; + uniformMatrix2fv(location: WebGLUniformLocation, transpose: boolean, value: Float32Array): void; + uniformMatrix3fv(location: WebGLUniformLocation, transpose: boolean, value: Float32Array): void; + uniformMatrix4fv(location: WebGLUniformLocation, transpose: boolean, value: Float32Array): void; useProgram(program: WebGLProgram): void; validateProgram(program: WebGLProgram): void; vertexAttrib1f(indx: number, x: number): void; - vertexAttrib1fv(indx: number, values: any): void; + vertexAttrib1fv(indx: number, values: Float32Array): void; vertexAttrib2f(indx: number, x: number, y: number): void; - vertexAttrib2fv(indx: number, values: any): void; + vertexAttrib2fv(indx: number, values: Float32Array): void; vertexAttrib3f(indx: number, x: number, y: number, z: number): void; - vertexAttrib3fv(indx: number, values: any): void; + vertexAttrib3fv(indx: number, values: Float32Array): void; vertexAttrib4f(indx: number, x: number, y: number, z: number, w: number): void; - vertexAttrib4fv(indx: number, values: any): void; + vertexAttrib4fv(indx: number, values: Float32Array): void; vertexAttribPointer(indx: number, size: number, type: number, normalized: boolean, stride: number, offset: number): void; viewport(x: number, y: number, width: number, height: number): void; ACTIVE_ATTRIBUTES: number; @@ -15928,7 +15817,6 @@ interface Window extends EventTarget, WindowTimers, WindowSessionStorage, Window locationbar: BarProp; menubar: BarProp; msAnimationStartTime: number; - msTemplatePrinter: MSTemplatePrinter; name: string; navigator: Navigator; offscreenBuffering: string | boolean; @@ -16665,7 +16553,6 @@ interface XMLHttpRequestEventTarget { addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } - interface NodeListOf extends NodeList { length: number; item(index: number): TNode; @@ -16686,8 +16573,6 @@ interface EventListenerObject { handleEvent(evt: Event): void; } -declare type EventListenerOrEventListenerObject = EventListener | EventListenerObject; - interface MessageEventInit extends EventInit { data?: any; origin?: string; @@ -16703,6 +16588,8 @@ interface ProgressEventInit extends EventInit { total?: number; } +declare type EventListenerOrEventListenerObject = EventListener | EventListenerObject; + interface ErrorEventHandler { (message: string, filename?: string, lineno?: number, colno?: number, error?:Error): void; } @@ -16763,7 +16650,6 @@ declare var location: Location; declare var locationbar: BarProp; declare var menubar: BarProp; declare var msAnimationStartTime: number; -declare var msTemplatePrinter: MSTemplatePrinter; declare var name: string; declare var navigator: Navigator; declare var offscreenBuffering: string | boolean; diff --git a/lib/lib.dom.d.ts b/lib/lib.dom.d.ts index 849560ac0d2..41d569ba9f7 100644 --- a/lib/lib.dom.d.ts +++ b/lib/lib.dom.d.ts @@ -419,8 +419,8 @@ interface AnalyserNode extends AudioNode { smoothingTimeConstant: number; getByteFrequencyData(array: Uint8Array): void; getByteTimeDomainData(array: Uint8Array): void; - getFloatFrequencyData(array: any): void; - getFloatTimeDomainData(array: any): void; + getFloatFrequencyData(array: Float32Array): void; + getFloatTimeDomainData(array: Float32Array): void; } declare var AnalyserNode: { @@ -507,7 +507,7 @@ interface AudioBuffer { length: number; numberOfChannels: number; sampleRate: number; - getChannelData(channel: number): any; + getChannelData(channel: number): Float32Array; } declare var AudioBuffer: { @@ -551,7 +551,7 @@ interface AudioContext extends EventTarget { createMediaElementSource(mediaElement: HTMLMediaElement): MediaElementAudioSourceNode; createOscillator(): OscillatorNode; createPanner(): PannerNode; - createPeriodicWave(real: any, imag: any): PeriodicWave; + createPeriodicWave(real: Float32Array, imag: Float32Array): PeriodicWave; createScriptProcessor(bufferSize?: number, numberOfInputChannels?: number, numberOfOutputChannels?: number): ScriptProcessorNode; createStereoPanner(): StereoPannerNode; createWaveShaper(): WaveShaperNode; @@ -609,7 +609,7 @@ interface AudioParam { linearRampToValueAtTime(value: number, endTime: number): void; setTargetAtTime(target: number, startTime: number, timeConstant: number): void; setValueAtTime(value: number, startTime: number): void; - setValueCurveAtTime(values: any, startTime: number, duration: number): void; + setValueCurveAtTime(values: Float32Array, startTime: number, duration: number): void; } declare var AudioParam: { @@ -685,7 +685,7 @@ interface BiquadFilterNode extends AudioNode { frequency: AudioParam; gain: AudioParam; type: string; - getFrequencyResponse(frequencyHz: any, magResponse: any, phaseResponse: any): void; + getFrequencyResponse(frequencyHz: Float32Array, magResponse: Float32Array, phaseResponse: Float32Array): void; } declare var BiquadFilterNode: { @@ -1284,7 +1284,7 @@ declare var CanvasPattern: { interface CanvasRenderingContext2D { canvas: HTMLCanvasElement; - fillStyle: any; + fillStyle: string | CanvasGradient | CanvasPattern; font: string; globalAlpha: number; globalCompositeOperation: string; @@ -1299,7 +1299,7 @@ interface CanvasRenderingContext2D { shadowColor: string; shadowOffsetX: number; shadowOffsetY: number; - strokeStyle: any; + strokeStyle: string | CanvasGradient | CanvasPattern; textAlign: string; textBaseline: string; arc(x: number, y: number, radius: number, startAngle: number, endAngle: number, anticlockwise?: boolean): void; @@ -2667,8 +2667,6 @@ interface Document extends Node, GlobalEventHandlers, NodeSelector, DocumentEven importNode(importedNode: Node, deep: boolean): Node; msElementsFromPoint(x: number, y: number): NodeList; msElementsFromRect(left: number, top: number, width: number, height: number): NodeList; - msGetPrintDocumentForNamedFlow(flowName: string): Document; - msSetPrintDocumentUriForNamedFlow(flowName: string, uri: string): void; /** * Opens a new window and loads a document specified by a given URL. Also, opens a new window that uses the url parameter and the name parameter to collect the output of the write method and the writeln method. * @param url Specifies a MIME type for the document. @@ -7490,27 +7488,6 @@ declare var MSHTMLWebViewElement: { new(): MSHTMLWebViewElement; } -interface MSHeaderFooter { - URL: string; - dateLong: string; - dateShort: string; - font: string; - htmlFoot: string; - htmlHead: string; - page: number; - pageTotal: number; - textFoot: string; - textHead: string; - timeLong: string; - timeShort: string; - title: string; -} - -declare var MSHeaderFooter: { - prototype: MSHeaderFooter; - new(): MSHeaderFooter; -} - interface MSInputMethodContext extends EventTarget { compositionEndOffset: number; compositionStartOffset: number; @@ -7669,24 +7646,6 @@ declare var MSPointerEvent: { new(typeArg: string, eventInitDict?: PointerEventInit): MSPointerEvent; } -interface MSPrintManagerTemplatePrinter extends MSTemplatePrinter, EventTarget { - percentScale: number; - showHeaderFooter: boolean; - shrinkToFit: boolean; - drawPreviewPage(element: HTMLElement, pageNumber: number): void; - endPrint(): void; - getPrintTaskOptionValue(key: string): any; - invalidatePreview(): void; - setPageCount(pageCount: number): void; - startPrint(): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; -} - -declare var MSPrintManagerTemplatePrinter: { - prototype: MSPrintManagerTemplatePrinter; - new(): MSPrintManagerTemplatePrinter; -} - interface MSRangeCollection { length: number; item(index: number): Range; @@ -7734,63 +7693,6 @@ declare var MSStreamReader: { new(): MSStreamReader; } -interface MSTemplatePrinter { - collate: boolean; - copies: number; - currentPage: boolean; - currentPageAvail: boolean; - duplex: boolean; - footer: string; - frameActive: boolean; - frameActiveEnabled: boolean; - frameAsShown: boolean; - framesetDocument: boolean; - header: string; - headerFooterFont: string; - marginBottom: number; - marginLeft: number; - marginRight: number; - marginTop: number; - orientation: string; - pageFrom: number; - pageHeight: number; - pageTo: number; - pageWidth: number; - selectedPages: boolean; - selection: boolean; - selectionEnabled: boolean; - unprintableBottom: number; - unprintableLeft: number; - unprintableRight: number; - unprintableTop: number; - usePrinterCopyCollate: boolean; - createHeaderFooter(): MSHeaderFooter; - deviceSupports(property: string): any; - ensurePrintDialogDefaults(): boolean; - getPageMarginBottom(pageRule: CSSPageRule, pageWidth: number, pageHeight: number): any; - getPageMarginBottomImportant(pageRule: CSSPageRule): boolean; - getPageMarginLeft(pageRule: CSSPageRule, pageWidth: number, pageHeight: number): any; - getPageMarginLeftImportant(pageRule: CSSPageRule): boolean; - getPageMarginRight(pageRule: CSSPageRule, pageWidth: number, pageHeight: number): any; - getPageMarginRightImportant(pageRule: CSSPageRule): boolean; - getPageMarginTop(pageRule: CSSPageRule, pageWidth: number, pageHeight: number): any; - getPageMarginTopImportant(pageRule: CSSPageRule): boolean; - printBlankPage(): void; - printNonNative(document: any): boolean; - printNonNativeFrames(document: any, activeFrame: boolean): void; - printPage(element: HTMLElement): void; - showPageSetupDialog(): boolean; - showPrintDialog(): boolean; - startDoc(title: string): boolean; - stopDoc(): void; - updatePageStatus(status: number): void; -} - -declare var MSTemplatePrinter: { - prototype: MSTemplatePrinter; - new(): MSTemplatePrinter; -} - interface MSWebViewAsyncOperation extends EventTarget { error: DOMError; oncomplete: (ev: Event) => any; @@ -8208,6 +8110,10 @@ declare var Node: { } interface NodeFilter { + acceptNode(n: Node): number; +} + +declare var NodeFilter: { FILTER_ACCEPT: number; FILTER_REJECT: number; FILTER_SKIP: number; @@ -8225,7 +8131,6 @@ interface NodeFilter { SHOW_PROCESSING_INSTRUCTION: number; SHOW_TEXT: number; } -declare var NodeFilter: NodeFilter; interface NodeIterator { expandEntityReferences: boolean; @@ -8935,7 +8840,6 @@ declare var SVGDescElement: { interface SVGElement extends Element { id: string; - className: any; onclick: (ev: MouseEvent) => any; ondblclick: (ev: MouseEvent) => any; onfocusin: (ev: FocusEvent) => any; @@ -8949,6 +8853,7 @@ interface SVGElement extends Element { ownerSVGElement: SVGSVGElement; viewportElement: SVGElement; xmlbase: string; + className: any; addEventListener(type: "MSGestureChange", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; addEventListener(type: "MSGestureDoubleTap", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; addEventListener(type: "MSGestureEnd", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; @@ -11110,7 +11015,7 @@ declare var WEBGL_depth_texture: { } interface WaveShaperNode extends AudioNode { - curve: any; + curve: Float32Array; oversample: string; } @@ -11297,34 +11202,34 @@ interface WebGLRenderingContext { texSubImage2D(target: number, level: number, xoffset: number, yoffset: number, format: number, type: number, video: HTMLVideoElement): void; texSubImage2D(target: number, level: number, xoffset: number, yoffset: number, format: number, type: number, pixels: ImageData): void; uniform1f(location: WebGLUniformLocation, x: number): void; - uniform1fv(location: WebGLUniformLocation, v: any): void; + uniform1fv(location: WebGLUniformLocation, v: Float32Array): void; uniform1i(location: WebGLUniformLocation, x: number): void; uniform1iv(location: WebGLUniformLocation, v: Int32Array): void; uniform2f(location: WebGLUniformLocation, x: number, y: number): void; - uniform2fv(location: WebGLUniformLocation, v: any): void; + uniform2fv(location: WebGLUniformLocation, v: Float32Array): void; uniform2i(location: WebGLUniformLocation, x: number, y: number): void; uniform2iv(location: WebGLUniformLocation, v: Int32Array): void; uniform3f(location: WebGLUniformLocation, x: number, y: number, z: number): void; - uniform3fv(location: WebGLUniformLocation, v: any): void; + uniform3fv(location: WebGLUniformLocation, v: Float32Array): void; uniform3i(location: WebGLUniformLocation, x: number, y: number, z: number): void; uniform3iv(location: WebGLUniformLocation, v: Int32Array): void; uniform4f(location: WebGLUniformLocation, x: number, y: number, z: number, w: number): void; - uniform4fv(location: WebGLUniformLocation, v: any): void; + uniform4fv(location: WebGLUniformLocation, v: Float32Array): void; uniform4i(location: WebGLUniformLocation, x: number, y: number, z: number, w: number): void; uniform4iv(location: WebGLUniformLocation, v: Int32Array): void; - uniformMatrix2fv(location: WebGLUniformLocation, transpose: boolean, value: any): void; - uniformMatrix3fv(location: WebGLUniformLocation, transpose: boolean, value: any): void; - uniformMatrix4fv(location: WebGLUniformLocation, transpose: boolean, value: any): void; + uniformMatrix2fv(location: WebGLUniformLocation, transpose: boolean, value: Float32Array): void; + uniformMatrix3fv(location: WebGLUniformLocation, transpose: boolean, value: Float32Array): void; + uniformMatrix4fv(location: WebGLUniformLocation, transpose: boolean, value: Float32Array): void; useProgram(program: WebGLProgram): void; validateProgram(program: WebGLProgram): void; vertexAttrib1f(indx: number, x: number): void; - vertexAttrib1fv(indx: number, values: any): void; + vertexAttrib1fv(indx: number, values: Float32Array): void; vertexAttrib2f(indx: number, x: number, y: number): void; - vertexAttrib2fv(indx: number, values: any): void; + vertexAttrib2fv(indx: number, values: Float32Array): void; vertexAttrib3f(indx: number, x: number, y: number, z: number): void; - vertexAttrib3fv(indx: number, values: any): void; + vertexAttrib3fv(indx: number, values: Float32Array): void; vertexAttrib4f(indx: number, x: number, y: number, z: number, w: number): void; - vertexAttrib4fv(indx: number, values: any): void; + vertexAttrib4fv(indx: number, values: Float32Array): void; vertexAttribPointer(indx: number, size: number, type: number, normalized: boolean, stride: number, offset: number): void; viewport(x: number, y: number, width: number, height: number): void; ACTIVE_ATTRIBUTES: number; @@ -12088,7 +11993,6 @@ interface Window extends EventTarget, WindowTimers, WindowSessionStorage, Window locationbar: BarProp; menubar: BarProp; msAnimationStartTime: number; - msTemplatePrinter: MSTemplatePrinter; name: string; navigator: Navigator; offscreenBuffering: string | boolean; @@ -12825,7 +12729,6 @@ interface XMLHttpRequestEventTarget { addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } - interface NodeListOf extends NodeList { length: number; item(index: number): TNode; @@ -12846,8 +12749,6 @@ interface EventListenerObject { handleEvent(evt: Event): void; } -declare type EventListenerOrEventListenerObject = EventListener | EventListenerObject; - interface MessageEventInit extends EventInit { data?: any; origin?: string; @@ -12863,6 +12764,8 @@ interface ProgressEventInit extends EventInit { total?: number; } +declare type EventListenerOrEventListenerObject = EventListener | EventListenerObject; + interface ErrorEventHandler { (message: string, filename?: string, lineno?: number, colno?: number, error?:Error): void; } @@ -12923,7 +12826,6 @@ declare var location: Location; declare var locationbar: BarProp; declare var menubar: BarProp; declare var msAnimationStartTime: number; -declare var msTemplatePrinter: MSTemplatePrinter; declare var name: string; declare var navigator: Navigator; declare var offscreenBuffering: string | boolean; diff --git a/lib/lib.es6.d.ts b/lib/lib.es6.d.ts index 63e6a101fbc..a7bf8f05076 100644 --- a/lib/lib.es6.d.ts +++ b/lib/lib.es6.d.ts @@ -1198,22 +1198,6 @@ interface PromiseLike { then(onfulfilled?: (value: T) => TResult | PromiseLike, onrejected?: (reason: any) => void): PromiseLike; } - -declare namespace CommonJS { - export var require: Require; - - export var exports: any; - - interface Exports { } - interface Module { - exports: Exports; - } - - interface Require { - (moduleName: string): any; - } -} - interface ArrayLike { length: number; [n: number]: T; @@ -5574,8 +5558,8 @@ interface AnalyserNode extends AudioNode { smoothingTimeConstant: number; getByteFrequencyData(array: Uint8Array): void; getByteTimeDomainData(array: Uint8Array): void; - getFloatFrequencyData(array: any): void; - getFloatTimeDomainData(array: any): void; + getFloatFrequencyData(array: Float32Array): void; + getFloatTimeDomainData(array: Float32Array): void; } declare var AnalyserNode: { @@ -5662,7 +5646,7 @@ interface AudioBuffer { length: number; numberOfChannels: number; sampleRate: number; - getChannelData(channel: number): any; + getChannelData(channel: number): Float32Array; } declare var AudioBuffer: { @@ -5706,7 +5690,7 @@ interface AudioContext extends EventTarget { createMediaElementSource(mediaElement: HTMLMediaElement): MediaElementAudioSourceNode; createOscillator(): OscillatorNode; createPanner(): PannerNode; - createPeriodicWave(real: any, imag: any): PeriodicWave; + createPeriodicWave(real: Float32Array, imag: Float32Array): PeriodicWave; createScriptProcessor(bufferSize?: number, numberOfInputChannels?: number, numberOfOutputChannels?: number): ScriptProcessorNode; createStereoPanner(): StereoPannerNode; createWaveShaper(): WaveShaperNode; @@ -5764,7 +5748,7 @@ interface AudioParam { linearRampToValueAtTime(value: number, endTime: number): void; setTargetAtTime(target: number, startTime: number, timeConstant: number): void; setValueAtTime(value: number, startTime: number): void; - setValueCurveAtTime(values: any, startTime: number, duration: number): void; + setValueCurveAtTime(values: Float32Array, startTime: number, duration: number): void; } declare var AudioParam: { @@ -5840,7 +5824,7 @@ interface BiquadFilterNode extends AudioNode { frequency: AudioParam; gain: AudioParam; type: string; - getFrequencyResponse(frequencyHz: any, magResponse: any, phaseResponse: any): void; + getFrequencyResponse(frequencyHz: Float32Array, magResponse: Float32Array, phaseResponse: Float32Array): void; } declare var BiquadFilterNode: { @@ -6439,7 +6423,7 @@ declare var CanvasPattern: { interface CanvasRenderingContext2D { canvas: HTMLCanvasElement; - fillStyle: any; + fillStyle: string | CanvasGradient | CanvasPattern; font: string; globalAlpha: number; globalCompositeOperation: string; @@ -6454,7 +6438,7 @@ interface CanvasRenderingContext2D { shadowColor: string; shadowOffsetX: number; shadowOffsetY: number; - strokeStyle: any; + strokeStyle: string | CanvasGradient | CanvasPattern; textAlign: string; textBaseline: string; arc(x: number, y: number, radius: number, startAngle: number, endAngle: number, anticlockwise?: boolean): void; @@ -7822,8 +7806,6 @@ interface Document extends Node, GlobalEventHandlers, NodeSelector, DocumentEven importNode(importedNode: Node, deep: boolean): Node; msElementsFromPoint(x: number, y: number): NodeList; msElementsFromRect(left: number, top: number, width: number, height: number): NodeList; - msGetPrintDocumentForNamedFlow(flowName: string): Document; - msSetPrintDocumentUriForNamedFlow(flowName: string, uri: string): void; /** * Opens a new window and loads a document specified by a given URL. Also, opens a new window that uses the url parameter and the name parameter to collect the output of the write method and the writeln method. * @param url Specifies a MIME type for the document. @@ -12645,27 +12627,6 @@ declare var MSHTMLWebViewElement: { new(): MSHTMLWebViewElement; } -interface MSHeaderFooter { - URL: string; - dateLong: string; - dateShort: string; - font: string; - htmlFoot: string; - htmlHead: string; - page: number; - pageTotal: number; - textFoot: string; - textHead: string; - timeLong: string; - timeShort: string; - title: string; -} - -declare var MSHeaderFooter: { - prototype: MSHeaderFooter; - new(): MSHeaderFooter; -} - interface MSInputMethodContext extends EventTarget { compositionEndOffset: number; compositionStartOffset: number; @@ -12824,24 +12785,6 @@ declare var MSPointerEvent: { new(typeArg: string, eventInitDict?: PointerEventInit): MSPointerEvent; } -interface MSPrintManagerTemplatePrinter extends MSTemplatePrinter, EventTarget { - percentScale: number; - showHeaderFooter: boolean; - shrinkToFit: boolean; - drawPreviewPage(element: HTMLElement, pageNumber: number): void; - endPrint(): void; - getPrintTaskOptionValue(key: string): any; - invalidatePreview(): void; - setPageCount(pageCount: number): void; - startPrint(): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; -} - -declare var MSPrintManagerTemplatePrinter: { - prototype: MSPrintManagerTemplatePrinter; - new(): MSPrintManagerTemplatePrinter; -} - interface MSRangeCollection { length: number; item(index: number): Range; @@ -12889,63 +12832,6 @@ declare var MSStreamReader: { new(): MSStreamReader; } -interface MSTemplatePrinter { - collate: boolean; - copies: number; - currentPage: boolean; - currentPageAvail: boolean; - duplex: boolean; - footer: string; - frameActive: boolean; - frameActiveEnabled: boolean; - frameAsShown: boolean; - framesetDocument: boolean; - header: string; - headerFooterFont: string; - marginBottom: number; - marginLeft: number; - marginRight: number; - marginTop: number; - orientation: string; - pageFrom: number; - pageHeight: number; - pageTo: number; - pageWidth: number; - selectedPages: boolean; - selection: boolean; - selectionEnabled: boolean; - unprintableBottom: number; - unprintableLeft: number; - unprintableRight: number; - unprintableTop: number; - usePrinterCopyCollate: boolean; - createHeaderFooter(): MSHeaderFooter; - deviceSupports(property: string): any; - ensurePrintDialogDefaults(): boolean; - getPageMarginBottom(pageRule: CSSPageRule, pageWidth: number, pageHeight: number): any; - getPageMarginBottomImportant(pageRule: CSSPageRule): boolean; - getPageMarginLeft(pageRule: CSSPageRule, pageWidth: number, pageHeight: number): any; - getPageMarginLeftImportant(pageRule: CSSPageRule): boolean; - getPageMarginRight(pageRule: CSSPageRule, pageWidth: number, pageHeight: number): any; - getPageMarginRightImportant(pageRule: CSSPageRule): boolean; - getPageMarginTop(pageRule: CSSPageRule, pageWidth: number, pageHeight: number): any; - getPageMarginTopImportant(pageRule: CSSPageRule): boolean; - printBlankPage(): void; - printNonNative(document: any): boolean; - printNonNativeFrames(document: any, activeFrame: boolean): void; - printPage(element: HTMLElement): void; - showPageSetupDialog(): boolean; - showPrintDialog(): boolean; - startDoc(title: string): boolean; - stopDoc(): void; - updatePageStatus(status: number): void; -} - -declare var MSTemplatePrinter: { - prototype: MSTemplatePrinter; - new(): MSTemplatePrinter; -} - interface MSWebViewAsyncOperation extends EventTarget { error: DOMError; oncomplete: (ev: Event) => any; @@ -13363,6 +13249,10 @@ declare var Node: { } interface NodeFilter { + acceptNode(n: Node): number; +} + +declare var NodeFilter: { FILTER_ACCEPT: number; FILTER_REJECT: number; FILTER_SKIP: number; @@ -13380,7 +13270,6 @@ interface NodeFilter { SHOW_PROCESSING_INSTRUCTION: number; SHOW_TEXT: number; } -declare var NodeFilter: NodeFilter; interface NodeIterator { expandEntityReferences: boolean; @@ -14090,7 +13979,6 @@ declare var SVGDescElement: { interface SVGElement extends Element { id: string; - className: any; onclick: (ev: MouseEvent) => any; ondblclick: (ev: MouseEvent) => any; onfocusin: (ev: FocusEvent) => any; @@ -14104,6 +13992,7 @@ interface SVGElement extends Element { ownerSVGElement: SVGSVGElement; viewportElement: SVGElement; xmlbase: string; + className: any; addEventListener(type: "MSGestureChange", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; addEventListener(type: "MSGestureDoubleTap", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; addEventListener(type: "MSGestureEnd", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; @@ -16265,7 +16154,7 @@ declare var WEBGL_depth_texture: { } interface WaveShaperNode extends AudioNode { - curve: any; + curve: Float32Array; oversample: string; } @@ -16452,34 +16341,34 @@ interface WebGLRenderingContext { texSubImage2D(target: number, level: number, xoffset: number, yoffset: number, format: number, type: number, video: HTMLVideoElement): void; texSubImage2D(target: number, level: number, xoffset: number, yoffset: number, format: number, type: number, pixels: ImageData): void; uniform1f(location: WebGLUniformLocation, x: number): void; - uniform1fv(location: WebGLUniformLocation, v: any): void; + uniform1fv(location: WebGLUniformLocation, v: Float32Array): void; uniform1i(location: WebGLUniformLocation, x: number): void; uniform1iv(location: WebGLUniformLocation, v: Int32Array): void; uniform2f(location: WebGLUniformLocation, x: number, y: number): void; - uniform2fv(location: WebGLUniformLocation, v: any): void; + uniform2fv(location: WebGLUniformLocation, v: Float32Array): void; uniform2i(location: WebGLUniformLocation, x: number, y: number): void; uniform2iv(location: WebGLUniformLocation, v: Int32Array): void; uniform3f(location: WebGLUniformLocation, x: number, y: number, z: number): void; - uniform3fv(location: WebGLUniformLocation, v: any): void; + uniform3fv(location: WebGLUniformLocation, v: Float32Array): void; uniform3i(location: WebGLUniformLocation, x: number, y: number, z: number): void; uniform3iv(location: WebGLUniformLocation, v: Int32Array): void; uniform4f(location: WebGLUniformLocation, x: number, y: number, z: number, w: number): void; - uniform4fv(location: WebGLUniformLocation, v: any): void; + uniform4fv(location: WebGLUniformLocation, v: Float32Array): void; uniform4i(location: WebGLUniformLocation, x: number, y: number, z: number, w: number): void; uniform4iv(location: WebGLUniformLocation, v: Int32Array): void; - uniformMatrix2fv(location: WebGLUniformLocation, transpose: boolean, value: any): void; - uniformMatrix3fv(location: WebGLUniformLocation, transpose: boolean, value: any): void; - uniformMatrix4fv(location: WebGLUniformLocation, transpose: boolean, value: any): void; + uniformMatrix2fv(location: WebGLUniformLocation, transpose: boolean, value: Float32Array): void; + uniformMatrix3fv(location: WebGLUniformLocation, transpose: boolean, value: Float32Array): void; + uniformMatrix4fv(location: WebGLUniformLocation, transpose: boolean, value: Float32Array): void; useProgram(program: WebGLProgram): void; validateProgram(program: WebGLProgram): void; vertexAttrib1f(indx: number, x: number): void; - vertexAttrib1fv(indx: number, values: any): void; + vertexAttrib1fv(indx: number, values: Float32Array): void; vertexAttrib2f(indx: number, x: number, y: number): void; - vertexAttrib2fv(indx: number, values: any): void; + vertexAttrib2fv(indx: number, values: Float32Array): void; vertexAttrib3f(indx: number, x: number, y: number, z: number): void; - vertexAttrib3fv(indx: number, values: any): void; + vertexAttrib3fv(indx: number, values: Float32Array): void; vertexAttrib4f(indx: number, x: number, y: number, z: number, w: number): void; - vertexAttrib4fv(indx: number, values: any): void; + vertexAttrib4fv(indx: number, values: Float32Array): void; vertexAttribPointer(indx: number, size: number, type: number, normalized: boolean, stride: number, offset: number): void; viewport(x: number, y: number, width: number, height: number): void; ACTIVE_ATTRIBUTES: number; @@ -17243,7 +17132,6 @@ interface Window extends EventTarget, WindowTimers, WindowSessionStorage, Window locationbar: BarProp; menubar: BarProp; msAnimationStartTime: number; - msTemplatePrinter: MSTemplatePrinter; name: string; navigator: Navigator; offscreenBuffering: string | boolean; @@ -17980,7 +17868,6 @@ interface XMLHttpRequestEventTarget { addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } - interface NodeListOf extends NodeList { length: number; item(index: number): TNode; @@ -18001,8 +17888,6 @@ interface EventListenerObject { handleEvent(evt: Event): void; } -declare type EventListenerOrEventListenerObject = EventListener | EventListenerObject; - interface MessageEventInit extends EventInit { data?: any; origin?: string; @@ -18018,6 +17903,8 @@ interface ProgressEventInit extends EventInit { total?: number; } +declare type EventListenerOrEventListenerObject = EventListener | EventListenerObject; + interface ErrorEventHandler { (message: string, filename?: string, lineno?: number, colno?: number, error?:Error): void; } @@ -18078,7 +17965,6 @@ declare var location: Location; declare var locationbar: BarProp; declare var menubar: BarProp; declare var msAnimationStartTime: number; -declare var msTemplatePrinter: MSTemplatePrinter; declare var name: string; declare var navigator: Navigator; declare var offscreenBuffering: string | boolean; diff --git a/lib/lib.webworker.d.ts b/lib/lib.webworker.d.ts index 85bcfb1498e..7995a03a40f 100644 --- a/lib/lib.webworker.d.ts +++ b/lib/lib.webworker.d.ts @@ -234,7 +234,7 @@ interface AudioBuffer { length: number; numberOfChannels: number; sampleRate: number; - getChannelData(channel: number): any; + getChannelData(channel: number): Float32Array; } declare var AudioBuffer: { @@ -1111,7 +1111,6 @@ interface WorkerUtils extends Object, WindowBase64 { setTimeout(handler: any, timeout?: any, ...args: any[]): number; } - interface BlobPropertyBag { type?: string; endings?: string; @@ -1126,8 +1125,6 @@ interface EventListenerObject { handleEvent(evt: Event): void; } -declare type EventListenerOrEventListenerObject = EventListener | EventListenerObject; - interface MessageEventInit extends EventInit { data?: any; origin?: string; @@ -1143,6 +1140,8 @@ interface ProgressEventInit extends EventInit { total?: number; } +declare type EventListenerOrEventListenerObject = EventListener | EventListenerObject; + interface ErrorEventHandler { (message: string, filename?: string, lineno?: number, colno?: number, error?:Error): void; } diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index f0c81940192..aa3e9b44815 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -2577,7 +2577,7 @@ namespace ts { return links.type = checkExpression((declaration).right); } // Handle exports.p = expr - if (declaration.kind === SyntaxKind.PropertyAccessExpression && declaration.parent.kind === SyntaxKind.BinaryExpression) { + if (declaration.kind === SyntaxKind.PropertyAccessExpression) { return checkExpressionCached((declaration.parent).right); } // Handle variable, parameter or property @@ -9377,11 +9377,9 @@ namespace ts { } } - let exprType = checkExpression(node.expression); - if (exprType === cjsRequireType) { - if (node.arguments.length === 1 && node.arguments[0].kind === SyntaxKind.StringLiteral) { - return resolveExternalModuleTypeByLiteral(node.arguments[0]); - } + // In JavaScript files, calls to any identifier 'require' are treated as external module imports + if (isInJavaScriptFile(node) && isRequireCall(node)) { + return resolveExternalModuleTypeByLiteral(node.arguments[0]); } return getReturnTypeOfSignature(signature); @@ -14925,14 +14923,6 @@ namespace ts { } }); - // Initialize special symbols - if (compilerOptions.allowNonTsExtensions) { - let req = getExportedSymbolFromNamespace("CommonJS", "require"); - if (req) { - globals["require"] = req; - } - } - getSymbolLinks(undefinedSymbol).type = undefinedType; getSymbolLinks(argumentsSymbol).type = getGlobalType("IArguments"); getSymbolLinks(unknownSymbol).type = unknownType; diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index c5dfcf8947e..1c875ec1b51 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -1039,7 +1039,7 @@ namespace ts { return isInJavaScriptFile(file); } - function isInJavaScriptFile(node: Node): boolean { + export function isInJavaScriptFile(node: Node): boolean { return node && !!(node.parserContextFlags & ParserContextFlags.JavaScriptFile); } @@ -1053,7 +1053,8 @@ namespace ts { return expression.kind === SyntaxKind.CallExpression && (expression).expression.kind === SyntaxKind.Identifier && ((expression).expression).text === "require" && - (expression).arguments.length === 1; + (expression).arguments.length === 1 && + (expression).arguments[0].kind === SyntaxKind.StringLiteral; } /** diff --git a/src/lib/core.d.ts b/src/lib/core.d.ts index 86dee00638d..7259ff5081c 100644 --- a/src/lib/core.d.ts +++ b/src/lib/core.d.ts @@ -1183,22 +1183,6 @@ interface PromiseLike { then(onfulfilled?: (value: T) => TResult | PromiseLike, onrejected?: (reason: any) => void): PromiseLike; } - -declare namespace CommonJS { - export var require: Require; - - export var exports: any; - - interface Exports { } - interface Module { - exports: Exports; - } - - interface Require { - (moduleName: string): any; - } -} - interface ArrayLike { length: number; [n: number]: T; From efa63b98bb529ee9cb35a04d9adbe76a453de81f Mon Sep 17 00:00:00 2001 From: Ryan Cavanaugh Date: Mon, 19 Oct 2015 11:02:27 -0700 Subject: [PATCH 073/227] LKG update --- lib/tsc.js | 17143 +++++++++++++------------ lib/tsserver.js | 19769 +++++++++++++++-------------- lib/typescript.d.ts | 527 +- lib/typescript.js | 22898 ++++++++++++++++++---------------- lib/typescriptServices.d.ts | 527 +- lib/typescriptServices.js | 22898 ++++++++++++++++++---------------- 6 files changed, 43463 insertions(+), 40299 deletions(-) diff --git a/lib/tsc.js b/lib/tsc.js index a4c2586f041..ed982c2d941 100644 --- a/lib/tsc.js +++ b/lib/tsc.js @@ -410,8 +410,11 @@ var ts; } ts.chainDiagnosticMessages = chainDiagnosticMessages; function concatenateDiagnosticMessageChains(headChain, tailChain) { - Debug.assert(!headChain.next); - headChain.next = tailChain; + var lastChain = headChain; + while (lastChain.next) { + lastChain = lastChain.next; + } + lastChain.next = tailChain; return headChain; } ts.concatenateDiagnosticMessageChains = concatenateDiagnosticMessageChains; @@ -950,10 +953,14 @@ var ts; close: function () { _fs.unwatchFile(fileName, fileChanged); } }; function fileChanged(curr, prev) { + if (curr.mtime.getTime() === 0) { + callback(fileName, true); + return; + } if (+curr.mtime <= +prev.mtime) { return; } - callback(fileName); + callback(fileName, false); } }, resolvePath: function (path) { @@ -1051,7 +1058,7 @@ var ts; Enum_member_must_have_initializer: { code: 1061, category: ts.DiagnosticCategory.Error, key: "Enum member must have initializer." }, _0_is_referenced_directly_or_indirectly_in_the_fulfillment_callback_of_its_own_then_method: { code: 1062, category: ts.DiagnosticCategory.Error, key: "{0} is referenced directly or indirectly in the fulfillment callback of its own 'then' method." }, An_export_assignment_cannot_be_used_in_a_namespace: { code: 1063, category: ts.DiagnosticCategory.Error, key: "An export assignment cannot be used in a namespace." }, - Ambient_enum_elements_can_only_have_integer_literal_initializers: { code: 1066, category: ts.DiagnosticCategory.Error, key: "Ambient enum elements can only have integer literal initializers." }, + In_ambient_enum_declarations_member_initializer_must_be_constant_expression: { code: 1066, category: ts.DiagnosticCategory.Error, key: "In ambient enum declarations member initializer must be constant expression." }, Unexpected_token_A_constructor_method_accessor_or_property_was_expected: { code: 1068, category: ts.DiagnosticCategory.Error, key: "Unexpected token. A constructor, method, accessor, or property was expected." }, A_0_modifier_cannot_be_used_with_an_import_declaration: { code: 1079, category: ts.DiagnosticCategory.Error, key: "A '{0}' modifier cannot be used with an import declaration." }, Invalid_reference_directive_syntax: { code: 1084, category: ts.DiagnosticCategory.Error, key: "Invalid 'reference' directive syntax." }, @@ -1139,7 +1146,7 @@ var ts; Property_destructuring_pattern_expected: { code: 1180, category: ts.DiagnosticCategory.Error, key: "Property destructuring pattern expected." }, Array_element_destructuring_pattern_expected: { code: 1181, category: ts.DiagnosticCategory.Error, key: "Array element destructuring pattern expected." }, A_destructuring_declaration_must_have_an_initializer: { code: 1182, category: ts.DiagnosticCategory.Error, key: "A destructuring declaration must have an initializer." }, - An_implementation_cannot_be_declared_in_ambient_contexts: { code: 1184, category: ts.DiagnosticCategory.Error, key: "An implementation cannot be declared in ambient contexts." }, + An_implementation_cannot_be_declared_in_ambient_contexts: { code: 1183, category: ts.DiagnosticCategory.Error, key: "An implementation cannot be declared in ambient contexts." }, Modifiers_cannot_appear_here: { code: 1184, category: ts.DiagnosticCategory.Error, key: "Modifiers cannot appear here." }, Merge_conflict_marker_encountered: { code: 1185, category: ts.DiagnosticCategory.Error, key: "Merge conflict marker encountered." }, A_rest_element_cannot_have_an_initializer: { code: 1186, category: ts.DiagnosticCategory.Error, key: "A rest element cannot have an initializer." }, @@ -1157,10 +1164,9 @@ var ts; An_extended_Unicode_escape_value_must_be_between_0x0_and_0x10FFFF_inclusive: { code: 1198, category: ts.DiagnosticCategory.Error, key: "An extended Unicode escape value must be between 0x0 and 0x10FFFF inclusive." }, Unterminated_Unicode_escape_sequence: { code: 1199, category: ts.DiagnosticCategory.Error, key: "Unterminated Unicode escape sequence." }, Line_terminator_not_permitted_before_arrow: { code: 1200, category: ts.DiagnosticCategory.Error, key: "Line terminator not permitted before arrow." }, - Import_assignment_cannot_be_used_when_targeting_ECMAScript_6_or_higher_Consider_using_import_Asterisk_as_ns_from_mod_import_a_from_mod_or_import_d_from_mod_instead: { code: 1202, category: ts.DiagnosticCategory.Error, key: "Import assignment cannot be used when targeting ECMAScript 6 or higher. Consider using 'import * as ns from \"mod\"', 'import {a} from \"mod\"' or 'import d from \"mod\"' instead." }, - Export_assignment_cannot_be_used_when_targeting_ECMAScript_6_or_higher_Consider_using_export_default_instead: { code: 1203, category: ts.DiagnosticCategory.Error, key: "Export assignment cannot be used when targeting ECMAScript 6 or higher. Consider using 'export default' instead." }, - Cannot_compile_modules_into_commonjs_amd_system_or_umd_when_targeting_ES6_or_higher: { code: 1204, category: ts.DiagnosticCategory.Error, key: "Cannot compile modules into 'commonjs', 'amd', 'system' or 'umd' when targeting 'ES6' or higher." }, - Decorators_are_only_available_when_targeting_ECMAScript_5_and_higher: { code: 1205, category: ts.DiagnosticCategory.Error, key: "Decorators are only available when targeting ECMAScript 5 and higher." }, + Import_assignment_cannot_be_used_when_targeting_ECMAScript_6_modules_Consider_using_import_Asterisk_as_ns_from_mod_import_a_from_mod_import_d_from_mod_or_another_module_format_instead: { code: 1202, category: ts.DiagnosticCategory.Error, key: "Import assignment cannot be used when targeting ECMAScript 6 modules. Consider using 'import * as ns from \"mod\"', 'import {a} from \"mod\"', 'import d from \"mod\"', or another module format instead." }, + Export_assignment_cannot_be_used_when_targeting_ECMAScript_6_modules_Consider_using_export_default_or_another_module_format_instead: { code: 1203, category: ts.DiagnosticCategory.Error, key: "Export assignment cannot be used when targeting ECMAScript 6 modules. Consider using 'export default' or another module format instead." }, + Cannot_compile_modules_into_es6_when_targeting_ES5_or_lower: { code: 1204, category: ts.DiagnosticCategory.Error, key: "Cannot compile modules into 'es6' when targeting 'ES5' or lower." }, Decorators_are_not_valid_here: { code: 1206, category: ts.DiagnosticCategory.Error, key: "Decorators are not valid here." }, Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name: { code: 1207, category: ts.DiagnosticCategory.Error, key: "Decorators cannot be applied to multiple get/set accessors of the same name." }, Cannot_compile_namespaces_when_the_isolatedModules_flag_is_provided: { code: 1208, category: ts.DiagnosticCategory.Error, key: "Cannot compile namespaces when the '--isolatedModules' flag is provided." }, @@ -1189,10 +1195,6 @@ var ts; An_export_declaration_can_only_be_used_in_a_module: { code: 1233, category: ts.DiagnosticCategory.Error, key: "An export declaration can only be used in a module." }, An_ambient_module_declaration_is_only_allowed_at_the_top_level_in_a_file: { code: 1234, category: ts.DiagnosticCategory.Error, key: "An ambient module declaration is only allowed at the top level in a file." }, A_namespace_declaration_is_only_allowed_in_a_namespace_or_module: { code: 1235, category: ts.DiagnosticCategory.Error, key: "A namespace declaration is only allowed in a namespace or module." }, - Experimental_support_for_async_functions_is_a_feature_that_is_subject_to_change_in_a_future_release_Specify_experimentalAsyncFunctions_to_remove_this_warning: { code: 1236, category: ts.DiagnosticCategory.Error, key: "Experimental support for async functions is a feature that is subject to change in a future release. Specify '--experimentalAsyncFunctions' to remove this warning." }, - with_statements_are_not_allowed_in_an_async_function_block: { code: 1300, category: ts.DiagnosticCategory.Error, key: "'with' statements are not allowed in an async function block." }, - await_expression_is_only_allowed_within_an_async_function: { code: 1308, category: ts.DiagnosticCategory.Error, key: "'await' expression is only allowed within an async function." }, - Async_functions_are_only_available_when_targeting_ECMAScript_6_and_higher: { code: 1311, category: ts.DiagnosticCategory.Error, key: "Async functions are only available when targeting ECMAScript 6 and higher." }, The_return_type_of_a_property_decorator_function_must_be_either_void_or_any: { code: 1236, category: ts.DiagnosticCategory.Error, key: "The return type of a property decorator function must be either 'void' or 'any'." }, The_return_type_of_a_parameter_decorator_function_must_be_either_void_or_any: { code: 1237, category: ts.DiagnosticCategory.Error, key: "The return type of a parameter decorator function must be either 'void' or 'any'." }, Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression: { code: 1238, category: ts.DiagnosticCategory.Error, key: "Unable to resolve signature of class decorator when called as an expression." }, @@ -1203,6 +1205,10 @@ var ts; _0_modifier_cannot_be_used_with_1_modifier: { code: 1243, category: ts.DiagnosticCategory.Error, key: "'{0}' modifier cannot be used with '{1}' modifier." }, Abstract_methods_can_only_appear_within_an_abstract_class: { code: 1244, category: ts.DiagnosticCategory.Error, key: "Abstract methods can only appear within an abstract class." }, Method_0_cannot_have_an_implementation_because_it_is_marked_abstract: { code: 1245, category: ts.DiagnosticCategory.Error, key: "Method '{0}' cannot have an implementation because it is marked abstract." }, + with_statements_are_not_allowed_in_an_async_function_block: { code: 1300, category: ts.DiagnosticCategory.Error, key: "'with' statements are not allowed in an async function block." }, + await_expression_is_only_allowed_within_an_async_function: { code: 1308, category: ts.DiagnosticCategory.Error, key: "'await' expression is only allowed within an async function." }, + Async_functions_are_only_available_when_targeting_ECMAScript_6_and_higher: { code: 1311, category: ts.DiagnosticCategory.Error, key: "Async functions are only available when targeting ECMAScript 6 and higher." }, + can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment: { code: 1312, category: ts.DiagnosticCategory.Error, key: "'=' can only be used in an object literal property inside a destructuring assignment." }, Duplicate_identifier_0: { code: 2300, category: ts.DiagnosticCategory.Error, key: "Duplicate identifier '{0}'." }, Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor: { code: 2301, category: ts.DiagnosticCategory.Error, key: "Initializer of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor." }, Static_members_cannot_reference_class_type_parameters: { code: 2302, category: ts.DiagnosticCategory.Error, key: "Static members cannot reference class type parameters." }, @@ -1327,7 +1333,7 @@ var ts; In_an_enum_with_multiple_declarations_only_one_declaration_can_omit_an_initializer_for_its_first_enum_element: { code: 2432, category: ts.DiagnosticCategory.Error, key: "In an enum with multiple declarations, only one declaration can omit an initializer for its first enum element." }, A_namespace_declaration_cannot_be_in_a_different_file_from_a_class_or_function_with_which_it_is_merged: { code: 2433, category: ts.DiagnosticCategory.Error, key: "A namespace declaration cannot be in a different file from a class or function with which it is merged" }, A_namespace_declaration_cannot_be_located_prior_to_a_class_or_function_with_which_it_is_merged: { code: 2434, category: ts.DiagnosticCategory.Error, key: "A namespace declaration cannot be located prior to a class or function with which it is merged" }, - Ambient_modules_cannot_be_nested_in_other_modules: { code: 2435, category: ts.DiagnosticCategory.Error, key: "Ambient modules cannot be nested in other modules." }, + Ambient_modules_cannot_be_nested_in_other_modules_or_namespaces: { code: 2435, category: ts.DiagnosticCategory.Error, key: "Ambient modules cannot be nested in other modules or namespaces." }, Ambient_module_declaration_cannot_specify_relative_module_name: { code: 2436, category: ts.DiagnosticCategory.Error, key: "Ambient module declaration cannot specify relative module name." }, Module_0_is_hidden_by_a_local_declaration_with_the_same_name: { code: 2437, category: ts.DiagnosticCategory.Error, key: "Module '{0}' is hidden by a local declaration with the same name" }, Import_name_cannot_be_0: { code: 2438, category: ts.DiagnosticCategory.Error, key: "Import name cannot be '{0}'" }, @@ -1415,6 +1421,9 @@ var ts; yield_expressions_cannot_be_used_in_a_parameter_initializer: { code: 2523, category: ts.DiagnosticCategory.Error, key: "'yield' expressions cannot be used in a parameter initializer." }, await_expressions_cannot_be_used_in_a_parameter_initializer: { code: 2524, category: ts.DiagnosticCategory.Error, key: "'await' expressions cannot be used in a parameter initializer." }, Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value: { code: 2525, category: ts.DiagnosticCategory.Error, key: "Initializer provides no value for this binding element and the binding element has no default value." }, + A_this_type_is_available_only_in_a_non_static_member_of_a_class_or_interface: { code: 2526, category: ts.DiagnosticCategory.Error, key: "A 'this' type is available only in a non-static member of a class or interface." }, + The_inferred_type_of_0_references_an_inaccessible_this_type_A_type_annotation_is_necessary: { code: 2527, category: ts.DiagnosticCategory.Error, key: "The inferred type of '{0}' references an inaccessible 'this' type. A type annotation is necessary." }, + A_module_cannot_have_multiple_default_exports: { code: 2528, category: ts.DiagnosticCategory.Error, key: "A module cannot have multiple default exports." }, JSX_element_attributes_type_0_must_be_an_object_type: { code: 2600, category: ts.DiagnosticCategory.Error, key: "JSX element attributes type '{0}' must be an object type." }, The_return_type_of_a_JSX_element_constructor_must_return_an_object_type: { code: 2601, category: ts.DiagnosticCategory.Error, key: "The return type of a JSX element constructor must return an object type." }, JSX_element_implicitly_has_type_any_because_the_global_type_JSX_Element_does_not_exist: { code: 2602, category: ts.DiagnosticCategory.Error, key: "JSX element implicitly has type 'any' because the global type 'JSX.Element' does not exist." }, @@ -1515,7 +1524,7 @@ var ts; Option_inlineSources_can_only_be_used_when_either_option_inlineSourceMap_or_option_sourceMap_is_provided: { code: 5051, category: ts.DiagnosticCategory.Error, key: "Option 'inlineSources' can only be used when either option '--inlineSourceMap' or option '--sourceMap' is provided." }, Option_0_cannot_be_specified_without_specifying_option_1: { code: 5052, category: ts.DiagnosticCategory.Error, key: "Option '{0}' cannot be specified without specifying option '{1}'." }, Option_0_cannot_be_specified_with_option_1: { code: 5053, category: ts.DiagnosticCategory.Error, key: "Option '{0}' cannot be specified with option '{1}'." }, - A_tsconfig_json_file_is_already_defined_at_Colon_0: { code: 5053, category: ts.DiagnosticCategory.Error, key: "A 'tsconfig.json' file is already defined at: '{0}'." }, + A_tsconfig_json_file_is_already_defined_at_Colon_0: { code: 5054, category: ts.DiagnosticCategory.Error, key: "A 'tsconfig.json' file is already defined at: '{0}'." }, Concatenate_and_emit_output_to_single_file: { code: 6001, category: ts.DiagnosticCategory.Message, key: "Concatenate and emit output to single file." }, Generates_corresponding_d_ts_file: { code: 6002, category: ts.DiagnosticCategory.Message, key: "Generates corresponding '.d.ts' file." }, Specifies_the_location_where_debugger_should_locate_map_files_instead_of_generated_locations: { code: 6003, category: ts.DiagnosticCategory.Message, key: "Specifies the location where debugger should locate map files instead of generated locations." }, @@ -1527,7 +1536,7 @@ var ts; Do_not_emit_comments_to_output: { code: 6009, category: ts.DiagnosticCategory.Message, key: "Do not emit comments to output." }, Do_not_emit_outputs: { code: 6010, category: ts.DiagnosticCategory.Message, key: "Do not emit outputs." }, Specify_ECMAScript_target_version_Colon_ES3_default_ES5_or_ES6_experimental: { code: 6015, category: ts.DiagnosticCategory.Message, key: "Specify ECMAScript target version: 'ES3' (default), 'ES5', or 'ES6' (experimental)" }, - Specify_module_code_generation_Colon_commonjs_amd_system_or_umd: { code: 6016, category: ts.DiagnosticCategory.Message, key: "Specify module code generation: 'commonjs', 'amd', 'system' or 'umd'" }, + Specify_module_code_generation_Colon_commonjs_amd_system_umd_or_es6: { code: 6016, category: ts.DiagnosticCategory.Message, key: "Specify module code generation: 'commonjs', 'amd', 'system', 'umd' or 'es6'" }, Print_this_message: { code: 6017, category: ts.DiagnosticCategory.Message, key: "Print this message." }, Print_the_compiler_s_version: { code: 6019, category: ts.DiagnosticCategory.Message, key: "Print the compiler's version." }, Compile_the_project_in_the_given_directory: { code: 6020, category: ts.DiagnosticCategory.Message, key: "Compile the project in the given directory." }, @@ -1548,7 +1557,7 @@ var ts; Generates_corresponding_map_file: { code: 6043, category: ts.DiagnosticCategory.Message, key: "Generates corresponding '.map' file." }, Compiler_option_0_expects_an_argument: { code: 6044, category: ts.DiagnosticCategory.Error, key: "Compiler option '{0}' expects an argument." }, Unterminated_quoted_string_in_response_file_0: { code: 6045, category: ts.DiagnosticCategory.Error, key: "Unterminated quoted string in response file '{0}'." }, - Argument_for_module_option_must_be_commonjs_amd_system_or_umd: { code: 6046, category: ts.DiagnosticCategory.Error, key: "Argument for '--module' option must be 'commonjs', 'amd', 'system' or 'umd'." }, + Argument_for_module_option_must_be_commonjs_amd_system_umd_or_es6: { code: 6046, category: ts.DiagnosticCategory.Error, key: "Argument for '--module' option must be 'commonjs', 'amd', 'system', 'umd', or 'es6'." }, Argument_for_target_option_must_be_ES3_ES5_or_ES6: { code: 6047, category: ts.DiagnosticCategory.Error, key: "Argument for '--target' option must be 'ES3', 'ES5', or 'ES6'." }, Locale_must_be_of_the_form_language_or_language_territory_For_example_0_or_1: { code: 6048, category: ts.DiagnosticCategory.Error, key: "Locale must be of the form or -. For example '{0}' or '{1}'." }, Unsupported_locale_0: { code: 6049, category: ts.DiagnosticCategory.Error, key: "Unsupported locale '{0}'." }, @@ -1569,7 +1578,6 @@ var ts; Argument_for_jsx_must_be_preserve_or_react: { code: 6081, category: ts.DiagnosticCategory.Message, key: "Argument for '--jsx' must be 'preserve' or 'react'." }, Enables_experimental_support_for_ES7_decorators: { code: 6065, category: ts.DiagnosticCategory.Message, key: "Enables experimental support for ES7 decorators." }, Enables_experimental_support_for_emitting_type_metadata_for_decorators: { code: 6066, category: ts.DiagnosticCategory.Message, key: "Enables experimental support for emitting type metadata for decorators." }, - Option_experimentalAsyncFunctions_cannot_be_specified_when_targeting_ES5_or_lower: { code: 6067, category: ts.DiagnosticCategory.Message, key: "Option 'experimentalAsyncFunctions' cannot be specified when targeting ES5 or lower." }, Enables_experimental_support_for_ES7_async_functions: { code: 6068, category: ts.DiagnosticCategory.Message, key: "Enables experimental support for ES7 async functions." }, Specifies_module_resolution_strategy_Colon_node_Node_js_or_classic_TypeScript_pre_1_6: { code: 6069, category: ts.DiagnosticCategory.Message, key: "Specifies module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6)." }, Initializes_a_TypeScript_project_and_creates_a_tsconfig_json_file: { code: 6070, category: ts.DiagnosticCategory.Message, key: "Initializes a TypeScript project and creates a tsconfig.json file." }, @@ -1616,81 +1624,83 @@ var ts; Expected_corresponding_JSX_closing_tag_for_0: { code: 17002, category: ts.DiagnosticCategory.Error, key: "Expected corresponding JSX closing tag for '{0}'." }, JSX_attribute_expected: { code: 17003, category: ts.DiagnosticCategory.Error, key: "JSX attribute expected." }, Cannot_use_JSX_unless_the_jsx_flag_is_provided: { code: 17004, category: ts.DiagnosticCategory.Error, key: "Cannot use JSX unless the '--jsx' flag is provided." }, - A_constructor_cannot_contain_a_super_call_when_its_class_extends_null: { code: 17005, category: ts.DiagnosticCategory.Error, key: "A constructor cannot contain a 'super' call when its class extends 'null'" } + A_constructor_cannot_contain_a_super_call_when_its_class_extends_null: { code: 17005, category: ts.DiagnosticCategory.Error, key: "A constructor cannot contain a 'super' call when its class extends 'null'" }, + An_unary_expression_with_the_0_operator_is_not_allowed_in_the_left_hand_side_of_an_exponentiation_expression_Consider_enclosing_the_expression_in_parentheses: { code: 17006, category: ts.DiagnosticCategory.Error, key: "An unary expression with the '{0}' operator is not allowed in the left-hand side of an exponentiation expression. Consider enclosing the expression in parentheses." }, + A_type_assertion_expression_is_not_allowed_in_the_left_hand_side_of_an_exponentiation_expression_Consider_enclosing_the_expression_in_parentheses: { code: 17007, category: ts.DiagnosticCategory.Error, key: "A type assertion expression is not allowed in the left-hand side of an exponentiation expression. Consider enclosing the expression in parentheses." } }; })(ts || (ts = {})); var ts; (function (ts) { function tokenIsIdentifierOrKeyword(token) { - return token >= 67; + return token >= 69; } ts.tokenIsIdentifierOrKeyword = tokenIsIdentifierOrKeyword; var textToToken = { - "abstract": 113, - "any": 115, - "as": 114, - "boolean": 118, - "break": 68, - "case": 69, - "catch": 70, - "class": 71, - "continue": 73, - "const": 72, - "constructor": 119, - "debugger": 74, - "declare": 120, - "default": 75, - "delete": 76, - "do": 77, - "else": 78, - "enum": 79, - "export": 80, - "extends": 81, - "false": 82, - "finally": 83, - "for": 84, - "from": 131, - "function": 85, - "get": 121, - "if": 86, - "implements": 104, - "import": 87, - "in": 88, - "instanceof": 89, - "interface": 105, - "is": 122, - "let": 106, - "module": 123, - "namespace": 124, - "new": 90, - "null": 91, - "number": 126, - "package": 107, - "private": 108, - "protected": 109, - "public": 110, - "require": 125, - "return": 92, - "set": 127, - "static": 111, - "string": 128, - "super": 93, - "switch": 94, - "symbol": 129, - "this": 95, - "throw": 96, - "true": 97, - "try": 98, - "type": 130, - "typeof": 99, - "var": 100, - "void": 101, - "while": 102, - "with": 103, - "yield": 112, - "async": 116, - "await": 117, - "of": 132, + "abstract": 115, + "any": 117, + "as": 116, + "boolean": 120, + "break": 70, + "case": 71, + "catch": 72, + "class": 73, + "continue": 75, + "const": 74, + "constructor": 121, + "debugger": 76, + "declare": 122, + "default": 77, + "delete": 78, + "do": 79, + "else": 80, + "enum": 81, + "export": 82, + "extends": 83, + "false": 84, + "finally": 85, + "for": 86, + "from": 133, + "function": 87, + "get": 123, + "if": 88, + "implements": 106, + "import": 89, + "in": 90, + "instanceof": 91, + "interface": 107, + "is": 124, + "let": 108, + "module": 125, + "namespace": 126, + "new": 92, + "null": 93, + "number": 128, + "package": 109, + "private": 110, + "protected": 111, + "public": 112, + "require": 127, + "return": 94, + "set": 129, + "static": 113, + "string": 130, + "super": 95, + "switch": 96, + "symbol": 131, + "this": 97, + "throw": 98, + "true": 99, + "try": 100, + "type": 132, + "typeof": 101, + "var": 102, + "void": 103, + "while": 104, + "with": 105, + "yield": 114, + "async": 118, + "await": 119, + "of": 134, "{": 15, "}": 16, "(": 17, @@ -1712,37 +1722,39 @@ var ts; "=>": 34, "+": 35, "-": 36, + "**": 38, "*": 37, - "/": 38, - "%": 39, - "++": 40, - "--": 41, - "<<": 42, + "/": 39, + "%": 40, + "++": 41, + "--": 42, + "<<": 43, ">": 43, - ">>>": 44, - "&": 45, - "|": 46, - "^": 47, - "!": 48, - "~": 49, - "&&": 50, - "||": 51, - "?": 52, - ":": 53, - "=": 55, - "+=": 56, - "-=": 57, - "*=": 58, - "/=": 59, - "%=": 60, - "<<=": 61, - ">>=": 62, - ">>>=": 63, - "&=": 64, - "|=": 65, - "^=": 66, - "@": 54 + ">>": 44, + ">>>": 45, + "&": 46, + "|": 47, + "^": 48, + "!": 49, + "~": 50, + "&&": 51, + "||": 52, + "?": 53, + ":": 54, + "=": 56, + "+=": 57, + "-=": 58, + "*=": 59, + "**=": 60, + "/=": 61, + "%=": 62, + "<<=": 63, + ">>=": 64, + ">>>=": 65, + "&=": 66, + "|=": 67, + "^=": 68, + "@": 55 }; var unicodeES3IdentifierStart = [170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 543, 546, 563, 592, 685, 688, 696, 699, 705, 720, 721, 736, 740, 750, 750, 890, 890, 902, 902, 904, 906, 908, 908, 910, 929, 931, 974, 976, 983, 986, 1011, 1024, 1153, 1164, 1220, 1223, 1224, 1227, 1228, 1232, 1269, 1272, 1273, 1329, 1366, 1369, 1369, 1377, 1415, 1488, 1514, 1520, 1522, 1569, 1594, 1600, 1610, 1649, 1747, 1749, 1749, 1765, 1766, 1786, 1788, 1808, 1808, 1810, 1836, 1920, 1957, 2309, 2361, 2365, 2365, 2384, 2384, 2392, 2401, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2524, 2525, 2527, 2529, 2544, 2545, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2649, 2652, 2654, 2654, 2674, 2676, 2693, 2699, 2701, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2749, 2749, 2768, 2768, 2784, 2784, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2870, 2873, 2877, 2877, 2908, 2909, 2911, 2913, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 2997, 2999, 3001, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3123, 3125, 3129, 3168, 3169, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3294, 3294, 3296, 3297, 3333, 3340, 3342, 3344, 3346, 3368, 3370, 3385, 3424, 3425, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3585, 3632, 3634, 3635, 3648, 3654, 3713, 3714, 3716, 3716, 3719, 3720, 3722, 3722, 3725, 3725, 3732, 3735, 3737, 3743, 3745, 3747, 3749, 3749, 3751, 3751, 3754, 3755, 3757, 3760, 3762, 3763, 3773, 3773, 3776, 3780, 3782, 3782, 3804, 3805, 3840, 3840, 3904, 3911, 3913, 3946, 3976, 3979, 4096, 4129, 4131, 4135, 4137, 4138, 4176, 4181, 4256, 4293, 4304, 4342, 4352, 4441, 4447, 4514, 4520, 4601, 4608, 4614, 4616, 4678, 4680, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4742, 4744, 4744, 4746, 4749, 4752, 4782, 4784, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4814, 4816, 4822, 4824, 4846, 4848, 4878, 4880, 4880, 4882, 4885, 4888, 4894, 4896, 4934, 4936, 4954, 5024, 5108, 5121, 5740, 5743, 5750, 5761, 5786, 5792, 5866, 6016, 6067, 6176, 6263, 6272, 6312, 7680, 7835, 7840, 7929, 7936, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8319, 8319, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8473, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8493, 8495, 8497, 8499, 8505, 8544, 8579, 12293, 12295, 12321, 12329, 12337, 12341, 12344, 12346, 12353, 12436, 12445, 12446, 12449, 12538, 12540, 12542, 12549, 12588, 12593, 12686, 12704, 12727, 13312, 19893, 19968, 40869, 40960, 42124, 44032, 55203, 63744, 64045, 64256, 64262, 64275, 64279, 64285, 64285, 64287, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65136, 65138, 65140, 65140, 65142, 65276, 65313, 65338, 65345, 65370, 65382, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500,]; var unicodeES3IdentifierPart = [170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 543, 546, 563, 592, 685, 688, 696, 699, 705, 720, 721, 736, 740, 750, 750, 768, 846, 864, 866, 890, 890, 902, 902, 904, 906, 908, 908, 910, 929, 931, 974, 976, 983, 986, 1011, 1024, 1153, 1155, 1158, 1164, 1220, 1223, 1224, 1227, 1228, 1232, 1269, 1272, 1273, 1329, 1366, 1369, 1369, 1377, 1415, 1425, 1441, 1443, 1465, 1467, 1469, 1471, 1471, 1473, 1474, 1476, 1476, 1488, 1514, 1520, 1522, 1569, 1594, 1600, 1621, 1632, 1641, 1648, 1747, 1749, 1756, 1759, 1768, 1770, 1773, 1776, 1788, 1808, 1836, 1840, 1866, 1920, 1968, 2305, 2307, 2309, 2361, 2364, 2381, 2384, 2388, 2392, 2403, 2406, 2415, 2433, 2435, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2492, 2492, 2494, 2500, 2503, 2504, 2507, 2509, 2519, 2519, 2524, 2525, 2527, 2531, 2534, 2545, 2562, 2562, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2620, 2620, 2622, 2626, 2631, 2632, 2635, 2637, 2649, 2652, 2654, 2654, 2662, 2676, 2689, 2691, 2693, 2699, 2701, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2748, 2757, 2759, 2761, 2763, 2765, 2768, 2768, 2784, 2784, 2790, 2799, 2817, 2819, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2870, 2873, 2876, 2883, 2887, 2888, 2891, 2893, 2902, 2903, 2908, 2909, 2911, 2913, 2918, 2927, 2946, 2947, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 2997, 2999, 3001, 3006, 3010, 3014, 3016, 3018, 3021, 3031, 3031, 3047, 3055, 3073, 3075, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3123, 3125, 3129, 3134, 3140, 3142, 3144, 3146, 3149, 3157, 3158, 3168, 3169, 3174, 3183, 3202, 3203, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3262, 3268, 3270, 3272, 3274, 3277, 3285, 3286, 3294, 3294, 3296, 3297, 3302, 3311, 3330, 3331, 3333, 3340, 3342, 3344, 3346, 3368, 3370, 3385, 3390, 3395, 3398, 3400, 3402, 3405, 3415, 3415, 3424, 3425, 3430, 3439, 3458, 3459, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3530, 3530, 3535, 3540, 3542, 3542, 3544, 3551, 3570, 3571, 3585, 3642, 3648, 3662, 3664, 3673, 3713, 3714, 3716, 3716, 3719, 3720, 3722, 3722, 3725, 3725, 3732, 3735, 3737, 3743, 3745, 3747, 3749, 3749, 3751, 3751, 3754, 3755, 3757, 3769, 3771, 3773, 3776, 3780, 3782, 3782, 3784, 3789, 3792, 3801, 3804, 3805, 3840, 3840, 3864, 3865, 3872, 3881, 3893, 3893, 3895, 3895, 3897, 3897, 3902, 3911, 3913, 3946, 3953, 3972, 3974, 3979, 3984, 3991, 3993, 4028, 4038, 4038, 4096, 4129, 4131, 4135, 4137, 4138, 4140, 4146, 4150, 4153, 4160, 4169, 4176, 4185, 4256, 4293, 4304, 4342, 4352, 4441, 4447, 4514, 4520, 4601, 4608, 4614, 4616, 4678, 4680, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4742, 4744, 4744, 4746, 4749, 4752, 4782, 4784, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4814, 4816, 4822, 4824, 4846, 4848, 4878, 4880, 4880, 4882, 4885, 4888, 4894, 4896, 4934, 4936, 4954, 4969, 4977, 5024, 5108, 5121, 5740, 5743, 5750, 5761, 5786, 5792, 5866, 6016, 6099, 6112, 6121, 6160, 6169, 6176, 6263, 6272, 6313, 7680, 7835, 7840, 7929, 7936, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8255, 8256, 8319, 8319, 8400, 8412, 8417, 8417, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8473, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8493, 8495, 8497, 8499, 8505, 8544, 8579, 12293, 12295, 12321, 12335, 12337, 12341, 12344, 12346, 12353, 12436, 12441, 12442, 12445, 12446, 12449, 12542, 12549, 12588, 12593, 12686, 12704, 12727, 13312, 19893, 19968, 40869, 40960, 42124, 44032, 55203, 63744, 64045, 64256, 64262, 64275, 64279, 64285, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65056, 65059, 65075, 65076, 65101, 65103, 65136, 65138, 65140, 65140, 65142, 65276, 65296, 65305, 65313, 65338, 65343, 65343, 65345, 65370, 65381, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500,]; @@ -2144,8 +2156,8 @@ var ts; getTokenValue: function () { return tokenValue; }, hasExtendedUnicodeEscape: function () { return hasExtendedUnicodeEscape; }, hasPrecedingLineBreak: function () { return precedingLineBreak; }, - isIdentifier: function () { return token === 67 || token > 103; }, - isReservedWord: function () { return token >= 68 && token <= 103; }, + isIdentifier: function () { return token === 69 || token > 105; }, + isReservedWord: function () { return token >= 70 && token <= 105; }, isUnterminated: function () { return tokenIsUnterminated; }, reScanGreaterToken: reScanGreaterToken, reScanSlashToken: reScanSlashToken, @@ -2167,16 +2179,6 @@ var ts; onError(message, length || 0); } } - function isIdentifierStart(ch) { - return ch >= 65 && ch <= 90 || ch >= 97 && ch <= 122 || - ch === 36 || ch === 95 || - ch > 127 && isUnicodeIdentifierStart(ch, languageVersion); - } - function isIdentifierPart(ch) { - return ch >= 65 && ch <= 90 || ch >= 97 && ch <= 122 || - ch >= 48 && ch <= 57 || ch === 36 || ch === 95 || - ch > 127 && isUnicodeIdentifierPart(ch, languageVersion); - } function scanNumber() { var start = pos; while (isDigit(text.charCodeAt(pos))) @@ -2431,12 +2433,12 @@ var ts; var start = pos; while (pos < end) { var ch = text.charCodeAt(pos); - if (isIdentifierPart(ch)) { + if (isIdentifierPart(ch, languageVersion)) { pos++; } else if (ch === 92) { ch = peekUnicodeEscape(); - if (!(ch >= 0 && isIdentifierPart(ch))) { + if (!(ch >= 0 && isIdentifierPart(ch, languageVersion))) { break; } result += text.substring(start, pos); @@ -2459,7 +2461,7 @@ var ts; return token = textToToken[tokenValue]; } } - return token = 67; + return token = 69; } function scanBinaryOrOctalDigits(base) { ts.Debug.assert(base !== 2 || base !== 8, "Expected either base 2 or base 8"); @@ -2538,7 +2540,7 @@ var ts; } return pos += 2, token = 31; } - return pos++, token = 48; + return pos++, token = 49; case 34: case 39: tokenValue = scanString(); @@ -2547,42 +2549,48 @@ var ts; return token = scanTemplateAndSetTokenValue(); case 37: if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 60; + return pos += 2, token = 62; } - return pos++, token = 39; + return pos++, token = 40; case 38: if (text.charCodeAt(pos + 1) === 38) { - return pos += 2, token = 50; + return pos += 2, token = 51; } if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 64; + return pos += 2, token = 66; } - return pos++, token = 45; + return pos++, token = 46; case 40: return pos++, token = 17; case 41: return pos++, token = 18; case 42: if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 58; + return pos += 2, token = 59; + } + if (text.charCodeAt(pos + 1) === 42) { + if (text.charCodeAt(pos + 2) === 61) { + return pos += 3, token = 60; + } + return pos += 2, token = 38; } return pos++, token = 37; case 43: if (text.charCodeAt(pos + 1) === 43) { - return pos += 2, token = 40; + return pos += 2, token = 41; } if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 56; + return pos += 2, token = 57; } return pos++, token = 35; case 44: return pos++, token = 24; case 45: if (text.charCodeAt(pos + 1) === 45) { - return pos += 2, token = 41; + return pos += 2, token = 42; } if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 57; + return pos += 2, token = 58; } return pos++, token = 36; case 46: @@ -2637,9 +2645,9 @@ var ts; } } if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 59; + return pos += 2, token = 61; } - return pos++, token = 38; + return pos++, token = 39; case 48: if (pos + 2 < end && (text.charCodeAt(pos + 1) === 88 || text.charCodeAt(pos + 1) === 120)) { pos += 2; @@ -2687,7 +2695,7 @@ var ts; tokenValue = "" + scanNumber(); return token = 8; case 58: - return pos++, token = 53; + return pos++, token = 54; case 59: return pos++, token = 23; case 60: @@ -2702,14 +2710,16 @@ var ts; } if (text.charCodeAt(pos + 1) === 60) { if (text.charCodeAt(pos + 2) === 61) { - return pos += 3, token = 61; + return pos += 3, token = 63; } - return pos += 2, token = 42; + return pos += 2, token = 43; } if (text.charCodeAt(pos + 1) === 61) { return pos += 2, token = 28; } - if (text.charCodeAt(pos + 1) === 47 && languageVariant === 1) { + if (languageVariant === 1 && + text.charCodeAt(pos + 1) === 47 && + text.charCodeAt(pos + 2) !== 42) { return pos += 2, token = 26; } return pos++, token = 25; @@ -2732,7 +2742,7 @@ var ts; if (text.charCodeAt(pos + 1) === 62) { return pos += 2, token = 34; } - return pos++, token = 55; + return pos++, token = 56; case 62: if (isConflictMarkerTrivia(text, pos)) { pos = scanConflictMarkerTrivia(text, pos, error); @@ -2745,35 +2755,35 @@ var ts; } return pos++, token = 27; case 63: - return pos++, token = 52; + return pos++, token = 53; case 91: return pos++, token = 19; case 93: return pos++, token = 20; case 94: if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 66; + return pos += 2, token = 68; } - return pos++, token = 47; + return pos++, token = 48; case 123: return pos++, token = 15; case 124: if (text.charCodeAt(pos + 1) === 124) { - return pos += 2, token = 51; + return pos += 2, token = 52; } if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 65; + return pos += 2, token = 67; } - return pos++, token = 46; + return pos++, token = 47; case 125: return pos++, token = 16; case 126: - return pos++, token = 49; + return pos++, token = 50; case 64: - return pos++, token = 54; + return pos++, token = 55; case 92: var cookedChar = peekUnicodeEscape(); - if (cookedChar >= 0 && isIdentifierStart(cookedChar)) { + if (cookedChar >= 0 && isIdentifierStart(cookedChar, languageVersion)) { pos += 6; tokenValue = String.fromCharCode(cookedChar) + scanIdentifierParts(); return token = getIdentifierToken(); @@ -2781,9 +2791,9 @@ var ts; error(ts.Diagnostics.Invalid_character); return pos++, token = 0; default: - if (isIdentifierStart(ch)) { + if (isIdentifierStart(ch, languageVersion)) { pos++; - while (pos < end && isIdentifierPart(ch = text.charCodeAt(pos))) + while (pos < end && isIdentifierPart(ch = text.charCodeAt(pos), languageVersion)) pos++; tokenValue = text.substring(tokenPos, pos); if (ch === 92) { @@ -2810,14 +2820,14 @@ var ts; if (text.charCodeAt(pos) === 62) { if (text.charCodeAt(pos + 1) === 62) { if (text.charCodeAt(pos + 2) === 61) { - return pos += 3, token = 63; + return pos += 3, token = 65; } - return pos += 2, token = 44; + return pos += 2, token = 45; } if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 62; + return pos += 2, token = 64; } - return pos++, token = 43; + return pos++, token = 44; } if (text.charCodeAt(pos) === 61) { return pos++, token = 29; @@ -2826,7 +2836,7 @@ var ts; return token; } function reScanSlashToken() { - if (token === 38 || token === 59) { + if (token === 39 || token === 61) { var p = tokenPos + 1; var inEscape = false; var inCharacterClass = false; @@ -2860,7 +2870,7 @@ var ts; } p++; } - while (p < end && isIdentifierPart(text.charCodeAt(p))) { + while (p < end && isIdentifierPart(text.charCodeAt(p), languageVersion)) { p++; } pos = p; @@ -2903,14 +2913,14 @@ var ts; break; } } - return token = 234; + return token = 236; } function scanJsxIdentifier() { if (tokenIsIdentifierOrKeyword(token)) { var firstCharPosition = pos; while (pos < end) { var ch = text.charCodeAt(pos); - if (ch === 45 || ((firstCharPosition === pos) ? isIdentifierStart(ch) : isIdentifierPart(ch))) { + if (ch === 45 || ((firstCharPosition === pos) ? isIdentifierStart(ch, languageVersion) : isIdentifierPart(ch, languageVersion))) { pos++; } else { @@ -2977,16 +2987,16 @@ var ts; (function (ts) { ts.bindTime = 0; function getModuleInstanceState(node) { - if (node.kind === 213 || node.kind === 214) { + if (node.kind === 215 || node.kind === 216) { return 0; } else if (ts.isConstEnumDeclaration(node)) { return 2; } - else if ((node.kind === 220 || node.kind === 219) && !(node.flags & 1)) { + else if ((node.kind === 222 || node.kind === 221) && !(node.flags & 1)) { return 0; } - else if (node.kind === 217) { + else if (node.kind === 219) { var state = 0; ts.forEachChild(node, function (n) { switch (getModuleInstanceState(n)) { @@ -3002,7 +3012,7 @@ var ts; }); return state; } - else if (node.kind === 216) { + else if (node.kind === 218) { return getModuleInstanceState(node.body); } else { @@ -3021,6 +3031,8 @@ var ts; var container; var blockScopeContainer; var lastContainer; + var seenThisKeyword; + var isJavaScriptFile = ts.isSourceFileJavaScript(file); var inStrictMode = !!file.externalModuleIndicator; var symbolCount = 0; var Symbol = ts.objectAllocator.getSymbolConstructor(); @@ -3054,10 +3066,10 @@ var ts; } function getDeclarationName(node) { if (node.name) { - if (node.kind === 216 && node.name.kind === 9) { + if (node.kind === 218 && node.name.kind === 9) { return "\"" + node.name.text + "\""; } - if (node.name.kind === 134) { + if (node.name.kind === 136) { var nameExpression = node.name.expression; ts.Debug.assert(ts.isWellKnownSymbolSyntactically(nameExpression)); return ts.getPropertyNameForKnownSymbolName(nameExpression.name.text); @@ -3065,22 +3077,24 @@ var ts; return node.name.text; } switch (node.kind) { - case 142: + case 144: return "__constructor"; - case 150: - case 145: - return "__call"; - case 151: - case 146: - return "__new"; + case 152: case 147: + return "__call"; + case 153: + case 148: + return "__new"; + case 149: return "__index"; - case 226: + case 228: return "__export"; - case 225: + case 227: return node.isExportEquals ? "export=" : "default"; - case 211: - case 212: + case 181: + return "export="; + case 213: + case 214: return node.flags & 1024 ? "default" : undefined; } } @@ -3089,7 +3103,8 @@ var ts; } function declareSymbol(symbolTable, parent, node, includes, excludes) { ts.Debug.assert(!ts.hasDynamicName(node)); - var name = node.flags & 1024 && parent ? "default" : getDeclarationName(node); + var isDefaultExport = node.flags & 1024; + var name = isDefaultExport && parent ? "default" : getDeclarationName(node); var symbol; if (name !== undefined) { symbol = ts.hasProperty(symbolTable, name) @@ -3105,6 +3120,11 @@ var ts; var message = symbol.flags & 2 ? ts.Diagnostics.Cannot_redeclare_block_scoped_variable_0 : ts.Diagnostics.Duplicate_identifier_0; + ts.forEach(symbol.declarations, function (declaration) { + if (declaration.flags & 1024) { + message = ts.Diagnostics.A_module_cannot_have_multiple_default_exports; + } + }); ts.forEach(symbol.declarations, function (declaration) { file.bindDiagnostics.push(ts.createDiagnosticForNode(declaration.name || declaration, message, getDisplayName(declaration))); }); @@ -3122,7 +3142,7 @@ var ts; function declareModuleMember(node, symbolFlags, symbolExcludes) { var hasExportModifier = ts.getCombinedNodeFlags(node) & 1; if (symbolFlags & 8388608) { - if (node.kind === 228 || (node.kind === 219 && hasExportModifier)) { + if (node.kind === 230 || (node.kind === 221 && hasExportModifier)) { return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); } else { @@ -3161,44 +3181,51 @@ var ts; blockScopeContainer = node; blockScopeContainer.locals = undefined; } - ts.forEachChild(node, bind); + if (node.kind === 215) { + seenThisKeyword = false; + ts.forEachChild(node, bind); + node.flags = seenThisKeyword ? node.flags | 524288 : node.flags & ~524288; + } + else { + ts.forEachChild(node, bind); + } container = saveContainer; parent = saveParent; blockScopeContainer = savedBlockScopeContainer; } function getContainerFlags(node) { switch (node.kind) { - case 184: - case 212: - case 213: + case 186: + case 214: case 215: - case 153: - case 163: + case 217: + case 155: + case 165: return 1; + case 147: + case 148: + case 149: + case 143: + case 142: + case 213: + case 144: case 145: case 146: - case 147: - case 141: - case 140: - case 211: - case 142: - case 143: - case 144: - case 150: - case 151: - case 171: - case 172: - case 216: - case 246: - case 214: - return 5; - case 242: - case 197: - case 198: - case 199: + case 152: + case 153: + case 173: + case 174: case 218: + case 248: + case 216: + return 5; + case 244: + case 199: + case 200: + case 201: + case 220: return 2; - case 190: + case 192: return ts.isFunctionLike(node.parent) ? 0 : 2; } return 0; @@ -3214,33 +3241,33 @@ var ts; } function declareSymbolAndAddToSymbolTableWorker(node, symbolFlags, symbolExcludes) { switch (container.kind) { - case 216: + case 218: return declareModuleMember(node, symbolFlags, symbolExcludes); - case 246: + case 248: return declareSourceFileMember(node, symbolFlags, symbolExcludes); - case 184: - case 212: + case 186: + case 214: return declareClassMember(node, symbolFlags, symbolExcludes); - case 215: + case 217: return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); - case 153: - case 163: - case 213: + case 155: + case 165: + case 215: return declareSymbol(container.symbol.members, container.symbol, node, symbolFlags, symbolExcludes); - case 150: - case 151: + case 152: + case 153: + case 147: + case 148: + case 149: + case 143: + case 142: + case 144: case 145: case 146: - case 147: - case 141: - case 140: - case 142: - case 143: - case 144: - case 211: - case 171: - case 172: - case 214: + case 213: + case 173: + case 174: + case 216: return declareSymbol(container.locals, undefined, node, symbolFlags, symbolExcludes); } } @@ -3264,11 +3291,11 @@ var ts; return false; } function hasExportDeclarations(node) { - var body = node.kind === 246 ? node : node.body; - if (body.kind === 246 || body.kind === 217) { + var body = node.kind === 248 ? node : node.body; + if (body.kind === 248 || body.kind === 219) { for (var _i = 0, _a = body.statements; _i < _a.length; _i++) { var stat = _a[_i]; - if (stat.kind === 226 || stat.kind === 225) { + if (stat.kind === 228 || stat.kind === 227) { return true; } } @@ -3323,11 +3350,11 @@ var ts; var seen = {}; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; - if (prop.name.kind !== 67) { + if (prop.name.kind !== 69) { continue; } var identifier = prop.name; - var currentKind = prop.kind === 243 || prop.kind === 244 || prop.kind === 141 + var currentKind = prop.kind === 245 || prop.kind === 246 || prop.kind === 143 ? 1 : 2; var existingKind = seen[identifier.text]; @@ -3349,10 +3376,10 @@ var ts; } function bindBlockScopedDeclaration(node, symbolFlags, symbolExcludes) { switch (blockScopeContainer.kind) { - case 216: + case 218: declareModuleMember(node, symbolFlags, symbolExcludes); break; - case 246: + case 248: if (ts.isExternalModule(container)) { declareModuleMember(node, symbolFlags, symbolExcludes); break; @@ -3370,8 +3397,8 @@ var ts; } function checkStrictModeIdentifier(node) { if (inStrictMode && - node.originalKeywordKind >= 104 && - node.originalKeywordKind <= 112 && + node.originalKeywordKind >= 106 && + node.originalKeywordKind <= 114 && !ts.isIdentifierName(node)) { if (!file.parseDiagnostics.length) { file.bindDiagnostics.push(ts.createDiagnosticForNode(node, getStrictModeIdentifierMessage(node), ts.declarationNameToString(node))); @@ -3398,17 +3425,17 @@ var ts; } } function checkStrictModeDeleteExpression(node) { - if (inStrictMode && node.expression.kind === 67) { + if (inStrictMode && node.expression.kind === 69) { var span = ts.getErrorSpanForNode(file, node.expression); file.bindDiagnostics.push(ts.createFileDiagnostic(file, span.start, span.length, ts.Diagnostics.delete_cannot_be_called_on_an_identifier_in_strict_mode)); } } function isEvalOrArgumentsIdentifier(node) { - return node.kind === 67 && + return node.kind === 69 && (node.text === "eval" || node.text === "arguments"); } function checkStrictModeEvalOrArguments(contextNode, name) { - if (name && name.kind === 67) { + if (name && name.kind === 69) { var identifier = name; if (isEvalOrArgumentsIdentifier(identifier)) { var span = ts.getErrorSpanForNode(file, name); @@ -3442,7 +3469,7 @@ var ts; } function checkStrictModePrefixUnaryExpression(node) { if (inStrictMode) { - if (node.operator === 40 || node.operator === 41) { + if (node.operator === 41 || node.operator === 42) { checkStrictModeEvalOrArguments(node, node.operand); } } @@ -3471,17 +3498,17 @@ var ts; } function updateStrictMode(node) { switch (node.kind) { - case 246: - case 217: + case 248: + case 219: updateStrictModeStatementList(node.statements); return; - case 190: + case 192: if (ts.isFunctionLike(node.parent)) { updateStrictModeStatementList(node.statements); } return; - case 212: - case 184: + case 214: + case 186: inStrictMode = true; return; } @@ -3504,102 +3531,122 @@ var ts; } function bindWorker(node) { switch (node.kind) { - case 67: + case 69: return checkStrictModeIdentifier(node); - case 179: + case 181: + if (isJavaScriptFile) { + if (ts.isExportsPropertyAssignment(node)) { + bindExportsPropertyAssignment(node); + } + else if (ts.isModuleExportsAssignment(node)) { + bindModuleExportsAssignment(node); + } + } return checkStrictModeBinaryExpression(node); - case 242: + case 244: return checkStrictModeCatchClause(node); - case 173: + case 175: return checkStrictModeDeleteExpression(node); case 8: return checkStrictModeNumericLiteral(node); - case 178: + case 180: return checkStrictModePostfixUnaryExpression(node); - case 177: + case 179: return checkStrictModePrefixUnaryExpression(node); - case 203: + case 205: return checkStrictModeWithStatement(node); - case 135: + case 97: + seenThisKeyword = true; + return; + case 137: return declareSymbolAndAddToSymbolTable(node, 262144, 530912); - case 136: - return bindParameter(node); - case 209: - case 161: - return bindVariableDeclarationOrBindingElement(node); - case 139: case 138: - return bindPropertyOrMethodOrAccessor(node, 4 | (node.questionToken ? 536870912 : 0), 107455); - case 243: - case 244: - return bindPropertyOrMethodOrAccessor(node, 4, 107455); - case 245: - return bindPropertyOrMethodOrAccessor(node, 8, 107455); - case 145: - case 146: - case 147: - return declareSymbolAndAddToSymbolTable(node, 131072, 0); + return bindParameter(node); + case 211: + case 163: + return bindVariableDeclarationOrBindingElement(node); case 141: case 140: + return bindPropertyOrMethodOrAccessor(node, 4 | (node.questionToken ? 536870912 : 0), 107455); + case 245: + case 246: + return bindPropertyOrMethodOrAccessor(node, 4, 107455); + case 247: + return bindPropertyOrMethodOrAccessor(node, 8, 107455); + case 147: + case 148: + case 149: + return declareSymbolAndAddToSymbolTable(node, 131072, 0); + case 143: + case 142: return bindPropertyOrMethodOrAccessor(node, 8192 | (node.questionToken ? 536870912 : 0), ts.isObjectLiteralMethod(node) ? 107455 : 99263); - case 211: + case 213: checkStrictModeFunctionName(node); return declareSymbolAndAddToSymbolTable(node, 16, 106927); - case 142: - return declareSymbolAndAddToSymbolTable(node, 16384, 0); - case 143: - return bindPropertyOrMethodOrAccessor(node, 32768, 41919); case 144: + return declareSymbolAndAddToSymbolTable(node, 16384, 0); + case 145: + return bindPropertyOrMethodOrAccessor(node, 32768, 41919); + case 146: return bindPropertyOrMethodOrAccessor(node, 65536, 74687); - case 150: - case 151: - return bindFunctionOrConstructorType(node); + case 152: case 153: + return bindFunctionOrConstructorType(node); + case 155: return bindAnonymousDeclaration(node, 2048, "__type"); - case 163: + case 165: return bindObjectLiteralExpression(node); - case 171: - case 172: + case 173: + case 174: checkStrictModeFunctionName(node); var bindingName = node.name ? node.name.text : "__function"; return bindAnonymousDeclaration(node, 16, bindingName); - case 184: - case 212: - return bindClassLikeDeclaration(node); - case 213: - return bindBlockScopedDeclaration(node, 64, 792960); + case 168: + if (isJavaScriptFile) { + bindCallExpression(node); + } + break; + case 186: case 214: - return bindBlockScopedDeclaration(node, 524288, 793056); + return bindClassLikeDeclaration(node); case 215: - return bindEnumDeclaration(node); + return bindBlockScopedDeclaration(node, 64, 792960); case 216: + return bindBlockScopedDeclaration(node, 524288, 793056); + case 217: + return bindEnumDeclaration(node); + case 218: return bindModuleDeclaration(node); - case 219: - case 222: - case 224: - case 228: - return declareSymbolAndAddToSymbolTable(node, 8388608, 8388608); case 221: - return bindImportClause(node); + case 224: case 226: + case 230: + return declareSymbolAndAddToSymbolTable(node, 8388608, 8388608); + case 223: + return bindImportClause(node); + case 228: return bindExportDeclaration(node); - case 225: + case 227: return bindExportAssignment(node); - case 246: + case 248: return bindSourceFileIfExternalModule(); } } function bindSourceFileIfExternalModule() { setExportContextFlag(file); if (ts.isExternalModule(file)) { - bindAnonymousDeclaration(file, 512, "\"" + ts.removeFileExtension(file.fileName) + "\""); + bindSourceFileAsExternalModule(); } } + function bindSourceFileAsExternalModule() { + bindAnonymousDeclaration(file, 512, "\"" + ts.removeFileExtension(file.fileName) + "\""); + } function bindExportAssignment(node) { + var boundExpression = node.kind === 227 ? node.expression : node.right; if (!container.symbol || !container.symbol.exports) { bindAnonymousDeclaration(node, 8388608, getDeclarationName(node)); } - else if (node.expression.kind === 67) { + else if (boundExpression.kind === 69) { declareSymbol(container.symbol.exports, container.symbol, node, 8388608, 107455 | 8388608); } else { @@ -3619,8 +3666,27 @@ var ts; declareSymbolAndAddToSymbolTable(node, 8388608, 8388608); } } + function setCommonJsModuleIndicator(node) { + if (!file.commonJsModuleIndicator) { + file.commonJsModuleIndicator = node; + bindSourceFileAsExternalModule(); + } + } + function bindExportsPropertyAssignment(node) { + setCommonJsModuleIndicator(node); + declareSymbol(file.symbol.exports, file.symbol, node.left, 4 | 7340032, 0); + } + function bindModuleExportsAssignment(node) { + setCommonJsModuleIndicator(node); + bindExportAssignment(node); + } + function bindCallExpression(node) { + if (!file.commonJsModuleIndicator && ts.isRequireCall(node)) { + setCommonJsModuleIndicator(node); + } + } function bindClassLikeDeclaration(node) { - if (node.kind === 212) { + if (node.kind === 214) { bindBlockScopedDeclaration(node, 32, 899519); } else { @@ -3673,7 +3739,7 @@ var ts; declareSymbolAndAddToSymbolTable(node, 1, 107455); } if (node.flags & 112 && - node.parent.kind === 142 && + node.parent.kind === 144 && ts.isClassLike(node.parent.parent)) { var classDeclaration = node.parent.parent; declareSymbol(classDeclaration.symbol.members, classDeclaration.symbol, node, 4, 107455); @@ -3719,7 +3785,8 @@ var ts; increaseIndent: function () { }, decreaseIndent: function () { }, clear: function () { return str = ""; }, - trackSymbol: function () { } + trackSymbol: function () { }, + reportInaccessibleThisError: function () { } }; } return stringWriters.pop(); @@ -3781,7 +3848,7 @@ var ts; } } function getSourceFileOfNode(node) { - while (node && node.kind !== 246) { + while (node && node.kind !== 248) { node = node.parent; } return node; @@ -3872,15 +3939,15 @@ var ts; return current; } switch (current.kind) { - case 246: + case 248: + case 220: + case 244: case 218: - case 242: - case 216: - case 197: - case 198: case 199: + case 200: + case 201: return current; - case 190: + case 192: if (!isFunctionLike(current.parent)) { return current; } @@ -3891,9 +3958,9 @@ var ts; ts.getEnclosingBlockScopeContainer = getEnclosingBlockScopeContainer; function isCatchClauseVariableDeclaration(declaration) { return declaration && - declaration.kind === 209 && + declaration.kind === 211 && declaration.parent && - declaration.parent.kind === 242; + declaration.parent.kind === 244; } ts.isCatchClauseVariableDeclaration = isCatchClauseVariableDeclaration; function declarationNameToString(name) { @@ -3929,22 +3996,22 @@ var ts; function getErrorSpanForNode(sourceFile, node) { var errorNode = node; switch (node.kind) { - case 246: + case 248: var pos_1 = ts.skipTrivia(sourceFile.text, 0, false); if (pos_1 === sourceFile.text.length) { return ts.createTextSpan(0, 0); } return getSpanOfTokenAtPosition(sourceFile, pos_1); - case 209: - case 161: - case 212: - case 184: - case 213: - case 216: - case 215: - case 245: case 211: - case 171: + case 163: + case 214: + case 186: + case 215: + case 218: + case 217: + case 247: + case 213: + case 173: errorNode = node.name; break; } @@ -3961,16 +4028,20 @@ var ts; return file.externalModuleIndicator !== undefined; } ts.isExternalModule = isExternalModule; + function isExternalOrCommonJsModule(file) { + return (file.externalModuleIndicator || file.commonJsModuleIndicator) !== undefined; + } + ts.isExternalOrCommonJsModule = isExternalOrCommonJsModule; function isDeclarationFile(file) { return (file.flags & 8192) !== 0; } ts.isDeclarationFile = isDeclarationFile; function isConstEnumDeclaration(node) { - return node.kind === 215 && isConst(node); + return node.kind === 217 && isConst(node); } ts.isConstEnumDeclaration = isConstEnumDeclaration; function walkUpBindingElementsAndPatterns(node) { - while (node && (node.kind === 161 || isBindingPattern(node))) { + while (node && (node.kind === 163 || isBindingPattern(node))) { node = node.parent; } return node; @@ -3978,14 +4049,14 @@ var ts; function getCombinedNodeFlags(node) { node = walkUpBindingElementsAndPatterns(node); var flags = node.flags; - if (node.kind === 209) { + if (node.kind === 211) { node = node.parent; } - if (node && node.kind === 210) { + if (node && node.kind === 212) { flags |= node.flags; node = node.parent; } - if (node && node.kind === 191) { + if (node && node.kind === 193) { flags |= node.flags; } return flags; @@ -4000,7 +4071,7 @@ var ts; } ts.isLet = isLet; function isPrologueDirective(node) { - return node.kind === 193 && node.expression.kind === 9; + return node.kind === 195 && node.expression.kind === 9; } ts.isPrologueDirective = isPrologueDirective; function getLeadingCommentRangesOfNode(node, sourceFileOfNode) { @@ -4008,7 +4079,7 @@ var ts; } ts.getLeadingCommentRangesOfNode = getLeadingCommentRangesOfNode; function getJsDocComments(node, sourceFileOfNode) { - var commentRanges = (node.kind === 136 || node.kind === 135) ? + var commentRanges = (node.kind === 138 || node.kind === 137) ? ts.concatenate(ts.getTrailingCommentRanges(sourceFileOfNode.text, node.pos), ts.getLeadingCommentRanges(sourceFileOfNode.text, node.pos)) : getLeadingCommentRangesOfNode(node, sourceFileOfNode); return ts.filter(commentRanges, isJsDocComment); @@ -4022,68 +4093,69 @@ var ts; ts.fullTripleSlashReferencePathRegEx = /^(\/\/\/\s*/; ts.fullTripleSlashAMDReferencePathRegEx = /^(\/\/\/\s*/; function isTypeNode(node) { - if (149 <= node.kind && node.kind <= 158) { + if (151 <= node.kind && node.kind <= 160) { return true; } switch (node.kind) { - case 115: - case 126: + case 117: case 128: - case 118: - case 129: + case 130: + case 120: + case 131: return true; - case 101: - return node.parent.kind !== 175; + case 103: + return node.parent.kind !== 177; case 9: - return node.parent.kind === 136; - case 186: + return node.parent.kind === 138; + case 188: return !isExpressionWithTypeArgumentsInClassExtendsClause(node); - case 67: - if (node.parent.kind === 133 && node.parent.right === node) { + case 69: + if (node.parent.kind === 135 && node.parent.right === node) { node = node.parent; } - else if (node.parent.kind === 164 && node.parent.name === node) { + else if (node.parent.kind === 166 && node.parent.name === node) { node = node.parent; } - case 133: - case 164: - ts.Debug.assert(node.kind === 67 || node.kind === 133 || node.kind === 164, "'node' was expected to be a qualified name, identifier or property access in 'isTypeNode'."); + ts.Debug.assert(node.kind === 69 || node.kind === 135 || node.kind === 166, "'node' was expected to be a qualified name, identifier or property access in 'isTypeNode'."); + case 135: + case 166: + case 97: var parent_1 = node.parent; - if (parent_1.kind === 152) { + if (parent_1.kind === 154) { return false; } - if (149 <= parent_1.kind && parent_1.kind <= 158) { + if (151 <= parent_1.kind && parent_1.kind <= 160) { return true; } switch (parent_1.kind) { - case 186: + case 188: return !isExpressionWithTypeArgumentsInClassExtendsClause(parent_1); - case 135: + case 137: return node === parent_1.constraint; - case 139: - case 138: - case 136: - case 209: - return node === parent_1.type; - case 211: - case 171: - case 172: - case 142: case 141: case 140: - case 143: - case 144: + case 138: + case 211: return node === parent_1.type; + case 213: + case 173: + case 174: + case 144: + case 143: + case 142: case 145: case 146: + return node === parent_1.type; case 147: + case 148: + case 149: return node === parent_1.type; - case 169: + case 171: return node === parent_1.type; - case 166: - case 167: - return parent_1.typeArguments && ts.indexOf(parent_1.typeArguments, node) >= 0; case 168: + case 169: + return parent_1.typeArguments && ts.indexOf(parent_1.typeArguments, node) >= 0; + case 170: return false; } } @@ -4094,23 +4166,23 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 202: + case 204: return visitor(node); - case 218: - case 190: - case 194: - case 195: + case 220: + case 192: case 196: case 197: case 198: case 199: - case 203: - case 204: - case 239: - case 240: + case 200: + case 201: case 205: - case 207: + case 206: + case 241: case 242: + case 207: + case 209: + case 244: return ts.forEachChild(node, traverse); } } @@ -4120,23 +4192,23 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 182: + case 184: visitor(node); var operand = node.expression; if (operand) { traverse(operand); } + case 217: case 215: - case 213: + case 218: case 216: case 214: - case 212: - case 184: + case 186: return; default: if (isFunctionLike(node)) { var name_5 = node.name; - if (name_5 && name_5.kind === 134) { + if (name_5 && name_5.kind === 136) { traverse(name_5.expression); return; } @@ -4151,14 +4223,14 @@ var ts; function isVariableLike(node) { if (node) { switch (node.kind) { - case 161: - case 245: - case 136: - case 243: - case 139: + case 163: + case 247: case 138: - case 244: - case 209: + case 245: + case 141: + case 140: + case 246: + case 211: return true; } } @@ -4166,29 +4238,29 @@ var ts; } ts.isVariableLike = isVariableLike; function isAccessor(node) { - return node && (node.kind === 143 || node.kind === 144); + return node && (node.kind === 145 || node.kind === 146); } ts.isAccessor = isAccessor; function isClassLike(node) { - return node && (node.kind === 212 || node.kind === 184); + return node && (node.kind === 214 || node.kind === 186); } ts.isClassLike = isClassLike; function isFunctionLike(node) { if (node) { switch (node.kind) { - case 142: - case 171: - case 211: - case 172: - case 141: - case 140: - case 143: case 144: + case 173: + case 213: + case 174: + case 143: + case 142: case 145: case 146: case 147: - case 150: - case 151: + case 148: + case 149: + case 152: + case 153: return true; } } @@ -4197,24 +4269,24 @@ var ts; ts.isFunctionLike = isFunctionLike; function introducesArgumentsExoticObject(node) { switch (node.kind) { - case 141: - case 140: - case 142: case 143: + case 142: case 144: - case 211: - case 171: + case 145: + case 146: + case 213: + case 173: return true; } return false; } ts.introducesArgumentsExoticObject = introducesArgumentsExoticObject; function isFunctionBlock(node) { - return node && node.kind === 190 && isFunctionLike(node.parent); + return node && node.kind === 192 && isFunctionLike(node.parent); } ts.isFunctionBlock = isFunctionBlock; function isObjectLiteralMethod(node) { - return node && node.kind === 141 && node.parent.kind === 163; + return node && node.kind === 143 && node.parent.kind === 165; } ts.isObjectLiteralMethod = isObjectLiteralMethod; function getContainingFunction(node) { @@ -4242,36 +4314,39 @@ var ts; return undefined; } switch (node.kind) { - case 134: + case 136: if (isClassLike(node.parent.parent)) { return node; } node = node.parent; break; - case 137: - if (node.parent.kind === 136 && isClassElement(node.parent.parent)) { + case 139: + if (node.parent.kind === 138 && isClassElement(node.parent.parent)) { node = node.parent.parent; } else if (isClassElement(node.parent)) { node = node.parent; } break; - case 172: + case 174: if (!includeArrowFunctions) { continue; } - case 211: - case 171: - case 216: - case 139: - case 138: + case 213: + case 173: + case 218: case 141: case 140: - case 142: case 143: + case 142: case 144: - case 215: - case 246: + case 145: + case 146: + case 147: + case 148: + case 149: + case 217: + case 248: return node; } } @@ -4283,33 +4358,33 @@ var ts; if (!node) return node; switch (node.kind) { - case 134: + case 136: if (isClassLike(node.parent.parent)) { return node; } node = node.parent; break; - case 137: - if (node.parent.kind === 136 && isClassElement(node.parent.parent)) { + case 139: + if (node.parent.kind === 138 && isClassElement(node.parent.parent)) { node = node.parent.parent; } else if (isClassElement(node.parent)) { node = node.parent; } break; - case 211: - case 171: - case 172: + case 213: + case 173: + case 174: if (!includeFunctions) { continue; } - case 139: - case 138: case 141: case 140: - case 142: case 143: + case 142: case 144: + case 145: + case 146: return node; } } @@ -4318,12 +4393,12 @@ var ts; function getEntityNameFromTypeNode(node) { if (node) { switch (node.kind) { - case 149: + case 151: return node.typeName; - case 186: + case 188: return node.expression; - case 67: - case 133: + case 69: + case 135: return node; } } @@ -4331,7 +4406,7 @@ var ts; } ts.getEntityNameFromTypeNode = getEntityNameFromTypeNode; function getInvokedExpression(node) { - if (node.kind === 168) { + if (node.kind === 170) { return node.tag; } return node.expression; @@ -4339,40 +4414,40 @@ var ts; ts.getInvokedExpression = getInvokedExpression; function nodeCanBeDecorated(node) { switch (node.kind) { - case 212: + case 214: return true; - case 139: - return node.parent.kind === 212; - case 136: - return node.parent.body && node.parent.parent.kind === 212; - case 143: - case 144: case 141: - return node.body && node.parent.kind === 212; + return node.parent.kind === 214; + case 138: + return node.parent.body && node.parent.parent.kind === 214; + case 145: + case 146: + case 143: + return node.body && node.parent.kind === 214; } return false; } ts.nodeCanBeDecorated = nodeCanBeDecorated; function nodeIsDecorated(node) { switch (node.kind) { - case 212: + case 214: if (node.decorators) { return true; } return false; - case 139: - case 136: - if (node.decorators) { - return true; - } - return false; - case 143: - if (node.body && node.decorators) { - return true; - } - return false; case 141: - case 144: + case 138: + if (node.decorators) { + return true; + } + return false; + case 145: + if (node.body && node.decorators) { + return true; + } + return false; + case 143: + case 146: if (node.body && node.decorators) { return true; } @@ -4383,10 +4458,10 @@ var ts; ts.nodeIsDecorated = nodeIsDecorated; function childIsDecorated(node) { switch (node.kind) { - case 212: + case 214: return ts.forEach(node.members, nodeOrChildIsDecorated); - case 141: - case 144: + case 143: + case 146: return ts.forEach(node.parameters, nodeIsDecorated); } return false; @@ -4396,95 +4471,105 @@ var ts; return nodeIsDecorated(node) || childIsDecorated(node); } ts.nodeOrChildIsDecorated = nodeOrChildIsDecorated; + function isPropertyAccessExpression(node) { + return node.kind === 166; + } + ts.isPropertyAccessExpression = isPropertyAccessExpression; + function isElementAccessExpression(node) { + return node.kind === 167; + } + ts.isElementAccessExpression = isElementAccessExpression; function isExpression(node) { switch (node.kind) { case 95: case 93: - case 91: - case 97: - case 82: + case 99: + case 84: case 10: - case 162: - case 163: case 164: case 165: case 166: case 167: case 168: - case 187: case 169: case 170: + case 189: case 171: - case 184: case 172: - case 175: case 173: + case 186: case 174: case 177: - case 178: + case 175: + case 176: case 179: case 180: - case 183: case 181: - case 11: - case 185: - case 231: - case 232: case 182: + case 185: + case 183: + case 11: + case 187: + case 233: + case 234: + case 184: + case 178: return true; - case 133: - while (node.parent.kind === 133) { + case 135: + while (node.parent.kind === 135) { node = node.parent; } - return node.parent.kind === 152; - case 67: - if (node.parent.kind === 152) { + return node.parent.kind === 154; + case 69: + if (node.parent.kind === 154) { return true; } case 8: case 9: + case 97: var parent_2 = node.parent; switch (parent_2.kind) { - case 209: - case 136: - case 139: + case 211: case 138: + case 141: + case 140: + case 247: case 245: - case 243: - case 161: + case 163: return parent_2.initializer === node; - case 193: - case 194: case 195: case 196: - case 202: - case 203: - case 204: - case 239: - case 206: - case 204: - return parent_2.expression === node; case 197: + case 198: + case 204: + case 205: + case 206: + case 241: + case 208: + case 206: + return parent_2.expression === node; + case 199: var forStatement = parent_2; - return (forStatement.initializer === node && forStatement.initializer.kind !== 210) || + return (forStatement.initializer === node && forStatement.initializer.kind !== 212) || forStatement.condition === node || forStatement.incrementor === node; - case 198: - case 199: + case 200: + case 201: var forInStatement = parent_2; - return (forInStatement.initializer === node && forInStatement.initializer.kind !== 210) || + return (forInStatement.initializer === node && forInStatement.initializer.kind !== 212) || forInStatement.expression === node; - case 169: - case 187: + case 171: + case 189: return node === parent_2.expression; - case 188: + case 190: return node === parent_2.expression; - case 134: + case 136: return node === parent_2.expression; - case 137: - case 238: + case 139: + case 240: + case 239: return true; - case 186: + case 188: return parent_2.expression === node && isExpressionWithTypeArgumentsInClassExtendsClause(parent_2); default: if (isExpression(parent_2)) { @@ -4495,6 +4580,10 @@ var ts; return false; } ts.isExpression = isExpression; + function isExternalModuleNameRelative(moduleName) { + return moduleName.substr(0, 2) === "./" || moduleName.substr(0, 3) === "../" || moduleName.substr(0, 2) === ".\\" || moduleName.substr(0, 3) === "..\\"; + } + ts.isExternalModuleNameRelative = isExternalModuleNameRelative; function isInstantiatedModule(node, preserveConstEnums) { var moduleState = ts.getModuleInstanceState(node); return moduleState === 1 || @@ -4502,7 +4591,7 @@ var ts; } ts.isInstantiatedModule = isInstantiatedModule; function isExternalModuleImportEqualsDeclaration(node) { - return node.kind === 219 && node.moduleReference.kind === 230; + return node.kind === 221 && node.moduleReference.kind === 232; } ts.isExternalModuleImportEqualsDeclaration = isExternalModuleImportEqualsDeclaration; function getExternalModuleImportEqualsDeclarationExpression(node) { @@ -4511,20 +4600,54 @@ var ts; } ts.getExternalModuleImportEqualsDeclarationExpression = getExternalModuleImportEqualsDeclarationExpression; function isInternalModuleImportEqualsDeclaration(node) { - return node.kind === 219 && node.moduleReference.kind !== 230; + return node.kind === 221 && node.moduleReference.kind !== 232; } ts.isInternalModuleImportEqualsDeclaration = isInternalModuleImportEqualsDeclaration; + function isSourceFileJavaScript(file) { + return isInJavaScriptFile(file); + } + ts.isSourceFileJavaScript = isSourceFileJavaScript; + function isInJavaScriptFile(node) { + return node && !!(node.parserContextFlags & 32); + } + ts.isInJavaScriptFile = isInJavaScriptFile; + function isRequireCall(expression) { + return expression.kind === 168 && + expression.expression.kind === 69 && + expression.expression.text === "require" && + expression.arguments.length === 1; + } + ts.isRequireCall = isRequireCall; + function isExportsPropertyAssignment(expression) { + return isInJavaScriptFile(expression) && + (expression.kind === 181) && + (expression.operatorToken.kind === 56) && + (expression.left.kind === 166) && + (expression.left.expression.kind === 69) && + ((expression.left.expression).text === "exports"); + } + ts.isExportsPropertyAssignment = isExportsPropertyAssignment; + function isModuleExportsAssignment(expression) { + return isInJavaScriptFile(expression) && + (expression.kind === 181) && + (expression.operatorToken.kind === 56) && + (expression.left.kind === 166) && + (expression.left.expression.kind === 69) && + ((expression.left.expression).text === "module") && + (expression.left.name.text === "exports"); + } + ts.isModuleExportsAssignment = isModuleExportsAssignment; function getExternalModuleName(node) { - if (node.kind === 220) { + if (node.kind === 222) { return node.moduleSpecifier; } - if (node.kind === 219) { + if (node.kind === 221) { var reference = node.moduleReference; - if (reference.kind === 230) { + if (reference.kind === 232) { return reference.expression; } } - if (node.kind === 226) { + if (node.kind === 228) { return node.moduleSpecifier; } } @@ -4532,13 +4655,13 @@ var ts; function hasQuestionToken(node) { if (node) { switch (node.kind) { - case 136: + case 138: + case 143: + case 142: + case 246: + case 245: case 141: case 140: - case 244: - case 243: - case 139: - case 138: return node.questionToken !== undefined; } } @@ -4546,9 +4669,9 @@ var ts; } ts.hasQuestionToken = hasQuestionToken; function isJSDocConstructSignature(node) { - return node.kind === 259 && + return node.kind === 261 && node.parameters.length > 0 && - node.parameters[0].type.kind === 261; + node.parameters[0].type.kind === 263; } ts.isJSDocConstructSignature = isJSDocConstructSignature; function getJSDocTag(node, kind) { @@ -4562,24 +4685,24 @@ var ts; } } function getJSDocTypeTag(node) { - return getJSDocTag(node, 267); + return getJSDocTag(node, 269); } ts.getJSDocTypeTag = getJSDocTypeTag; function getJSDocReturnTag(node) { - return getJSDocTag(node, 266); + return getJSDocTag(node, 268); } ts.getJSDocReturnTag = getJSDocReturnTag; function getJSDocTemplateTag(node) { - return getJSDocTag(node, 268); + return getJSDocTag(node, 270); } ts.getJSDocTemplateTag = getJSDocTemplateTag; function getCorrespondingJSDocParameterTag(parameter) { - if (parameter.name && parameter.name.kind === 67) { + if (parameter.name && parameter.name.kind === 69) { var parameterName = parameter.name.text; var docComment = parameter.parent.jsDocComment; if (docComment) { return ts.forEach(docComment.tags, function (t) { - if (t.kind === 265) { + if (t.kind === 267) { var parameterTag = t; var name_6 = parameterTag.preParameterName || parameterTag.postParameterName; if (name_6.text === parameterName) { @@ -4598,12 +4721,12 @@ var ts; function isRestParameter(node) { if (node) { if (node.parserContextFlags & 32) { - if (node.type && node.type.kind === 260) { + if (node.type && node.type.kind === 262) { return true; } var paramTag = getCorrespondingJSDocParameterTag(node); if (paramTag && paramTag.typeExpression) { - return paramTag.typeExpression.type.kind === 260; + return paramTag.typeExpression.type.kind === 262; } } return node.dotDotDotToken !== undefined; @@ -4624,7 +4747,7 @@ var ts; } ts.isTemplateLiteralKind = isTemplateLiteralKind; function isBindingPattern(node) { - return !!node && (node.kind === 160 || node.kind === 159); + return !!node && (node.kind === 162 || node.kind === 161); } ts.isBindingPattern = isBindingPattern; function isInAmbientContext(node) { @@ -4639,34 +4762,34 @@ var ts; ts.isInAmbientContext = isInAmbientContext; function isDeclaration(node) { switch (node.kind) { - case 172: - case 161: - case 212: - case 184: - case 142: - case 215: - case 245: - case 228: - case 211: - case 171: - case 143: - case 221: - case 219: - case 224: + case 174: + case 163: + case 214: + case 186: + case 144: + case 217: + case 247: + case 230: case 213: + case 173: + case 145: + case 223: + case 221: + case 226: + case 215: + case 143: + case 142: + case 218: + case 224: + case 138: + case 245: case 141: case 140: + case 146: + case 246: case 216: - case 222: - case 136: - case 243: - case 139: - case 138: - case 144: - case 244: - case 214: - case 135: - case 209: + case 137: + case 211: return true; } return false; @@ -4674,25 +4797,25 @@ var ts; ts.isDeclaration = isDeclaration; function isStatement(n) { switch (n.kind) { - case 201: - case 200: - case 208: - case 195: - case 193: - case 192: - case 198: - case 199: - case 197: - case 194: - case 205: - case 202: - case 204: - case 96: - case 207: - case 191: - case 196: case 203: - case 225: + case 202: + case 210: + case 197: + case 195: + case 194: + case 200: + case 201: + case 199: + case 196: + case 207: + case 204: + case 206: + case 98: + case 209: + case 193: + case 198: + case 205: + case 227: return true; default: return false; @@ -4701,13 +4824,13 @@ var ts; ts.isStatement = isStatement; function isClassElement(n) { switch (n.kind) { - case 142: - case 139: + case 144: case 141: case 143: - case 144: - case 140: - case 147: + case 145: + case 146: + case 142: + case 149: return true; default: return false; @@ -4715,11 +4838,11 @@ var ts; } ts.isClassElement = isClassElement; function isDeclarationName(name) { - if (name.kind !== 67 && name.kind !== 9 && name.kind !== 8) { + if (name.kind !== 69 && name.kind !== 9 && name.kind !== 8) { return false; } var parent = name.parent; - if (parent.kind === 224 || parent.kind === 228) { + if (parent.kind === 226 || parent.kind === 230) { if (parent.propertyName) { return true; } @@ -4733,54 +4856,54 @@ var ts; function isIdentifierName(node) { var parent = node.parent; switch (parent.kind) { - case 139: - case 138: case 141: case 140: case 143: - case 144: + case 142: + case 145: + case 146: + case 247: case 245: - case 243: - case 164: + case 166: return parent.name === node; - case 133: + case 135: if (parent.right === node) { - while (parent.kind === 133) { + while (parent.kind === 135) { parent = parent.parent; } - return parent.kind === 152; + return parent.kind === 154; } return false; - case 161: - case 224: + case 163: + case 226: return parent.propertyName === node; - case 228: + case 230: return true; } return false; } ts.isIdentifierName = isIdentifierName; function isAliasSymbolDeclaration(node) { - return node.kind === 219 || - node.kind === 221 && !!node.name || - node.kind === 222 || + return node.kind === 221 || + node.kind === 223 && !!node.name || node.kind === 224 || - node.kind === 228 || - node.kind === 225 && node.expression.kind === 67; + node.kind === 226 || + node.kind === 230 || + node.kind === 227 && node.expression.kind === 69; } ts.isAliasSymbolDeclaration = isAliasSymbolDeclaration; function getClassExtendsHeritageClauseElement(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 81); + var heritageClause = getHeritageClause(node.heritageClauses, 83); return heritageClause && heritageClause.types.length > 0 ? heritageClause.types[0] : undefined; } ts.getClassExtendsHeritageClauseElement = getClassExtendsHeritageClauseElement; function getClassImplementsHeritageClauseElements(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 104); + var heritageClause = getHeritageClause(node.heritageClauses, 106); return heritageClause ? heritageClause.types : undefined; } ts.getClassImplementsHeritageClauseElements = getClassImplementsHeritageClauseElements; function getInterfaceBaseTypeNodes(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 81); + var heritageClause = getHeritageClause(node.heritageClauses, 83); return heritageClause ? heritageClause.types : undefined; } ts.getInterfaceBaseTypeNodes = getInterfaceBaseTypeNodes; @@ -4849,7 +4972,7 @@ var ts; } ts.getFileReferenceFromReferencePath = getFileReferenceFromReferencePath; function isKeyword(token) { - return 68 <= token && token <= 132; + return 70 <= token && token <= 134; } ts.isKeyword = isKeyword; function isTrivia(token) { @@ -4862,19 +4985,19 @@ var ts; ts.isAsyncFunctionLike = isAsyncFunctionLike; function hasDynamicName(declaration) { return declaration.name && - declaration.name.kind === 134 && + declaration.name.kind === 136 && !isWellKnownSymbolSyntactically(declaration.name.expression); } ts.hasDynamicName = hasDynamicName; function isWellKnownSymbolSyntactically(node) { - return node.kind === 164 && isESSymbolIdentifier(node.expression); + return isPropertyAccessExpression(node) && isESSymbolIdentifier(node.expression); } ts.isWellKnownSymbolSyntactically = isWellKnownSymbolSyntactically; function getPropertyNameForPropertyNameNode(name) { - if (name.kind === 67 || name.kind === 9 || name.kind === 8) { + if (name.kind === 69 || name.kind === 9 || name.kind === 8) { return name.text; } - if (name.kind === 134) { + if (name.kind === 136) { var nameExpression = name.expression; if (isWellKnownSymbolSyntactically(nameExpression)) { var rightHandSideName = nameExpression.name.text; @@ -4889,21 +5012,21 @@ var ts; } ts.getPropertyNameForKnownSymbolName = getPropertyNameForKnownSymbolName; function isESSymbolIdentifier(node) { - return node.kind === 67 && node.text === "Symbol"; + return node.kind === 69 && node.text === "Symbol"; } ts.isESSymbolIdentifier = isESSymbolIdentifier; function isModifier(token) { switch (token) { - case 113: - case 116: - case 72: - case 120: - case 75: - case 80: + case 115: + case 118: + case 74: + case 122: + case 77: + case 82: + case 112: case 110: - case 108: - case 109: case 111: + case 113: return true; } return false; @@ -4911,28 +5034,28 @@ var ts; ts.isModifier = isModifier; function isParameterDeclaration(node) { var root = getRootDeclaration(node); - return root.kind === 136; + return root.kind === 138; } ts.isParameterDeclaration = isParameterDeclaration; function getRootDeclaration(node) { - while (node.kind === 161) { + while (node.kind === 163) { node = node.parent.parent; } return node; } ts.getRootDeclaration = getRootDeclaration; function nodeStartsNewLexicalEnvironment(n) { - return isFunctionLike(n) || n.kind === 216 || n.kind === 246; + return isFunctionLike(n) || n.kind === 218 || n.kind === 248; } ts.nodeStartsNewLexicalEnvironment = nodeStartsNewLexicalEnvironment; function cloneEntityName(node) { - if (node.kind === 67) { - var clone_1 = createSynthesizedNode(67); + if (node.kind === 69) { + var clone_1 = createSynthesizedNode(69); clone_1.text = node.text; return clone_1; } else { - var clone_2 = createSynthesizedNode(133); + var clone_2 = createSynthesizedNode(135); clone_2.left = cloneEntityName(node.left); clone_2.left.parent = clone_2; clone_2.right = cloneEntityName(node.right); @@ -5175,7 +5298,7 @@ var ts; ts.getLineOfLocalPosition = getLineOfLocalPosition; function getFirstConstructorWithBody(node) { return ts.forEach(node.members, function (member) { - if (member.kind === 142 && nodeIsPresent(member.body)) { + if (member.kind === 144 && nodeIsPresent(member.body)) { return member; } }); @@ -5202,10 +5325,10 @@ var ts; var setAccessor; if (hasDynamicName(accessor)) { firstAccessor = accessor; - if (accessor.kind === 143) { + if (accessor.kind === 145) { getAccessor = accessor; } - else if (accessor.kind === 144) { + else if (accessor.kind === 146) { setAccessor = accessor; } else { @@ -5214,7 +5337,7 @@ var ts; } else { ts.forEach(declarations, function (member) { - if ((member.kind === 143 || member.kind === 144) + if ((member.kind === 145 || member.kind === 146) && (member.flags & 128) === (accessor.flags & 128)) { var memberName = getPropertyNameForPropertyNameNode(member.name); var accessorName = getPropertyNameForPropertyNameNode(accessor.name); @@ -5225,10 +5348,10 @@ var ts; else if (!secondAccessor) { secondAccessor = member; } - if (member.kind === 143 && !getAccessor) { + if (member.kind === 145 && !getAccessor) { getAccessor = member; } - if (member.kind === 144 && !setAccessor) { + if (member.kind === 146 && !setAccessor) { setAccessor = member; } } @@ -5334,16 +5457,16 @@ var ts; ts.writeCommentRange = writeCommentRange; function modifierToFlag(token) { switch (token) { - case 111: return 128; - case 110: return 16; - case 109: return 64; - case 108: return 32; - case 113: return 256; - case 80: return 1; - case 120: return 2; - case 72: return 32768; - case 75: return 1024; - case 116: return 512; + case 113: return 128; + case 112: return 16; + case 111: return 64; + case 110: return 32; + case 115: return 256; + case 82: return 1; + case 122: return 2; + case 74: return 32768; + case 77: return 1024; + case 118: return 512; } return 0; } @@ -5351,29 +5474,29 @@ var ts; function isLeftHandSideExpression(expr) { if (expr) { switch (expr.kind) { - case 164: - case 165: - case 167: case 166: - case 231: - case 232: + case 167: + case 169: case 168: - case 162: + case 233: + case 234: case 170: - case 163: - case 184: - case 171: - case 67: + case 164: + case 172: + case 165: + case 186: + case 173: + case 69: case 10: case 8: case 9: case 11: - case 181: - case 82: - case 91: - case 95: - case 97: + case 183: + case 84: case 93: + case 97: + case 99: + case 95: return true; } } @@ -5381,12 +5504,12 @@ var ts; } ts.isLeftHandSideExpression = isLeftHandSideExpression; function isAssignmentOperator(token) { - return token >= 55 && token <= 66; + return token >= 56 && token <= 68; } ts.isAssignmentOperator = isAssignmentOperator; function isExpressionWithTypeArgumentsInClassExtendsClause(node) { - return node.kind === 186 && - node.parent.token === 81 && + return node.kind === 188 && + node.parent.token === 83 && isClassLike(node.parent.parent); } ts.isExpressionWithTypeArgumentsInClassExtendsClause = isExpressionWithTypeArgumentsInClassExtendsClause; @@ -5395,10 +5518,10 @@ var ts; } ts.isSupportedExpressionWithTypeArguments = isSupportedExpressionWithTypeArguments; function isSupportedExpressionWithTypeArgumentsRest(node) { - if (node.kind === 67) { + if (node.kind === 69) { return true; } - else if (node.kind === 164) { + else if (isPropertyAccessExpression(node)) { return isSupportedExpressionWithTypeArgumentsRest(node.expression); } else { @@ -5406,16 +5529,16 @@ var ts; } } function isRightSideOfQualifiedNameOrPropertyAccess(node) { - return (node.parent.kind === 133 && node.parent.right === node) || - (node.parent.kind === 164 && node.parent.name === node); + return (node.parent.kind === 135 && node.parent.right === node) || + (node.parent.kind === 166 && node.parent.name === node); } ts.isRightSideOfQualifiedNameOrPropertyAccess = isRightSideOfQualifiedNameOrPropertyAccess; function isEmptyObjectLiteralOrArrayLiteral(expression) { var kind = expression.kind; - if (kind === 163) { + if (kind === 165) { return expression.properties.length === 0; } - if (kind === 162) { + if (kind === 164) { return expression.elements.length === 0; } return false; @@ -5425,12 +5548,12 @@ var ts; return symbol && symbol.valueDeclaration && (symbol.valueDeclaration.flags & 1024) ? symbol.valueDeclaration.localSymbol : undefined; } ts.getLocalSymbolForExportDefault = getLocalSymbolForExportDefault; - function isJavaScript(fileName) { - return ts.fileExtensionIs(fileName, ".js"); + function hasJavaScriptFileExtension(fileName) { + return ts.fileExtensionIs(fileName, ".js") || ts.fileExtensionIs(fileName, ".jsx"); } - ts.isJavaScript = isJavaScript; + ts.hasJavaScriptFileExtension = hasJavaScriptFileExtension; function isTsx(fileName) { - return ts.fileExtensionIs(fileName, ".tsx"); + return ts.fileExtensionIs(fileName, ".tsx") || ts.fileExtensionIs(fileName, ".jsx"); } ts.isTsx = isTsx; function getExpandedCharCodes(input) { @@ -5624,9 +5747,9 @@ var ts; } ts.collapseTextChangeRangesAcrossMultipleVersions = collapseTextChangeRangesAcrossMultipleVersions; function getTypeParameterOwner(d) { - if (d && d.kind === 135) { + if (d && d.kind === 137) { for (var current = d; current; current = current.parent) { - if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 213) { + if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 215) { return current; } } @@ -5636,7 +5759,7 @@ var ts; })(ts || (ts = {})); var ts; (function (ts) { - var nodeConstructors = new Array(270); + var nodeConstructors = new Array(272); ts.parseTime = 0; function getNodeConstructor(kind) { return nodeConstructors[kind] || (nodeConstructors[kind] = ts.objectAllocator.getNodeConstructor(kind)); @@ -5674,20 +5797,26 @@ var ts; var visitNodes = cbNodeArray ? visitNodeArray : visitEachNode; var cbNodes = cbNodeArray || cbNode; switch (node.kind) { - case 133: + case 135: return visitNode(cbNode, node.left) || visitNode(cbNode, node.right); - case 135: + case 137: return visitNode(cbNode, node.name) || visitNode(cbNode, node.constraint) || visitNode(cbNode, node.expression); - case 136: - case 139: + case 246: + return visitNodes(cbNodes, node.decorators) || + visitNodes(cbNodes, node.modifiers) || + visitNode(cbNode, node.name) || + visitNode(cbNode, node.questionToken) || + visitNode(cbNode, node.equalsToken) || + visitNode(cbNode, node.objectAssignmentInitializer); case 138: - case 243: - case 244: - case 209: - case 161: + case 141: + case 140: + case 245: + case 211: + case 163: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.propertyName) || @@ -5696,24 +5825,24 @@ var ts; visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 150: - case 151: - case 145: - case 146: + case 152: + case 153: case 147: + case 148: + case 149: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNodes(cbNodes, node.typeParameters) || visitNodes(cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 141: - case 140: - case 142: case 143: + case 142: case 144: - case 171: - case 211: - case 172: + case 145: + case 146: + case 173: + case 213: + case 174: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.asteriskToken) || @@ -5724,290 +5853,290 @@ var ts; visitNode(cbNode, node.type) || visitNode(cbNode, node.equalsGreaterThanToken) || visitNode(cbNode, node.body); - case 149: + case 151: return visitNode(cbNode, node.typeName) || visitNodes(cbNodes, node.typeArguments); - case 148: + case 150: return visitNode(cbNode, node.parameterName) || visitNode(cbNode, node.type); - case 152: - return visitNode(cbNode, node.exprName); - case 153: - return visitNodes(cbNodes, node.members); case 154: - return visitNode(cbNode, node.elementType); + return visitNode(cbNode, node.exprName); case 155: - return visitNodes(cbNodes, node.elementTypes); + return visitNodes(cbNodes, node.members); case 156: + return visitNode(cbNode, node.elementType); case 157: - return visitNodes(cbNodes, node.types); + return visitNodes(cbNodes, node.elementTypes); case 158: - return visitNode(cbNode, node.type); case 159: + return visitNodes(cbNodes, node.types); case 160: - return visitNodes(cbNodes, node.elements); + return visitNode(cbNode, node.type); + case 161: case 162: return visitNodes(cbNodes, node.elements); - case 163: - return visitNodes(cbNodes, node.properties); case 164: + return visitNodes(cbNodes, node.elements); + case 165: + return visitNodes(cbNodes, node.properties); + case 166: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.dotToken) || visitNode(cbNode, node.name); - case 165: + case 167: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.argumentExpression); - case 166: - case 167: + case 168: + case 169: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.typeArguments) || visitNodes(cbNodes, node.arguments); - case 168: + case 170: return visitNode(cbNode, node.tag) || visitNode(cbNode, node.template); - case 169: + case 171: return visitNode(cbNode, node.type) || visitNode(cbNode, node.expression); - case 170: - return visitNode(cbNode, node.expression); - case 173: - return visitNode(cbNode, node.expression); - case 174: + case 172: return visitNode(cbNode, node.expression); case 175: return visitNode(cbNode, node.expression); - case 177: - return visitNode(cbNode, node.operand); - case 182: - return visitNode(cbNode, node.asteriskToken) || - visitNode(cbNode, node.expression); case 176: return visitNode(cbNode, node.expression); - case 178: - return visitNode(cbNode, node.operand); + case 177: + return visitNode(cbNode, node.expression); case 179: + return visitNode(cbNode, node.operand); + case 184: + return visitNode(cbNode, node.asteriskToken) || + visitNode(cbNode, node.expression); + case 178: + return visitNode(cbNode, node.expression); + case 180: + return visitNode(cbNode, node.operand); + case 181: return visitNode(cbNode, node.left) || visitNode(cbNode, node.operatorToken) || visitNode(cbNode, node.right); - case 187: + case 189: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.type); - case 180: + case 182: return visitNode(cbNode, node.condition) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.whenTrue) || visitNode(cbNode, node.colonToken) || visitNode(cbNode, node.whenFalse); - case 183: + case 185: return visitNode(cbNode, node.expression); - case 190: - case 217: + case 192: + case 219: return visitNodes(cbNodes, node.statements); - case 246: + case 248: return visitNodes(cbNodes, node.statements) || visitNode(cbNode, node.endOfFileToken); - case 191: + case 193: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.declarationList); - case 210: + case 212: return visitNodes(cbNodes, node.declarations); - case 193: + case 195: return visitNode(cbNode, node.expression); - case 194: + case 196: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.thenStatement) || visitNode(cbNode, node.elseStatement); - case 195: + case 197: return visitNode(cbNode, node.statement) || visitNode(cbNode, node.expression); - case 196: + case 198: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 197: + case 199: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.condition) || visitNode(cbNode, node.incrementor) || visitNode(cbNode, node.statement); - case 198: - return visitNode(cbNode, node.initializer) || - visitNode(cbNode, node.expression) || - visitNode(cbNode, node.statement); - case 199: - return visitNode(cbNode, node.initializer) || - visitNode(cbNode, node.expression) || - visitNode(cbNode, node.statement); case 200: - case 201: - return visitNode(cbNode, node.label); - case 202: - return visitNode(cbNode, node.expression); - case 203: - return visitNode(cbNode, node.expression) || + return visitNode(cbNode, node.initializer) || + visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); + case 201: + return visitNode(cbNode, node.initializer) || + visitNode(cbNode, node.expression) || + visitNode(cbNode, node.statement); + case 202: + case 203: + return visitNode(cbNode, node.label); case 204: - return visitNode(cbNode, node.expression) || - visitNode(cbNode, node.caseBlock); - case 218: - return visitNodes(cbNodes, node.clauses); - case 239: - return visitNode(cbNode, node.expression) || - visitNodes(cbNodes, node.statements); - case 240: - return visitNodes(cbNodes, node.statements); + return visitNode(cbNode, node.expression); case 205: - return visitNode(cbNode, node.label) || + return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); case 206: - return visitNode(cbNode, node.expression); + return visitNode(cbNode, node.expression) || + visitNode(cbNode, node.caseBlock); + case 220: + return visitNodes(cbNodes, node.clauses); + case 241: + return visitNode(cbNode, node.expression) || + visitNodes(cbNodes, node.statements); + case 242: + return visitNodes(cbNodes, node.statements); case 207: + return visitNode(cbNode, node.label) || + visitNode(cbNode, node.statement); + case 208: + return visitNode(cbNode, node.expression); + case 209: return visitNode(cbNode, node.tryBlock) || visitNode(cbNode, node.catchClause) || visitNode(cbNode, node.finallyBlock); - case 242: + case 244: return visitNode(cbNode, node.variableDeclaration) || visitNode(cbNode, node.block); - case 137: + case 139: return visitNode(cbNode, node.expression); - case 212: - case 184: - return visitNodes(cbNodes, node.decorators) || - visitNodes(cbNodes, node.modifiers) || - visitNode(cbNode, node.name) || - visitNodes(cbNodes, node.typeParameters) || - visitNodes(cbNodes, node.heritageClauses) || - visitNodes(cbNodes, node.members); - case 213: - return visitNodes(cbNodes, node.decorators) || - visitNodes(cbNodes, node.modifiers) || - visitNode(cbNode, node.name) || - visitNodes(cbNodes, node.typeParameters) || - visitNodes(cbNodes, node.heritageClauses) || - visitNodes(cbNodes, node.members); case 214: + case 186: return visitNodes(cbNodes, node.decorators) || 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 215: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || + visitNodes(cbNodes, node.typeParameters) || + visitNodes(cbNodes, node.heritageClauses) || visitNodes(cbNodes, node.members); - case 245: - return visitNode(cbNode, node.name) || - visitNode(cbNode, node.initializer); case 216: + return visitNodes(cbNodes, node.decorators) || + visitNodes(cbNodes, node.modifiers) || + visitNode(cbNode, node.name) || + visitNodes(cbNodes, node.typeParameters) || + visitNode(cbNode, node.type); + case 217: + return visitNodes(cbNodes, node.decorators) || + visitNodes(cbNodes, node.modifiers) || + visitNode(cbNode, node.name) || + visitNodes(cbNodes, node.members); + case 247: + return visitNode(cbNode, node.name) || + visitNode(cbNode, node.initializer); + case 218: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.body); - case 219: + case 221: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.moduleReference); - case 220: + case 222: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.importClause) || visitNode(cbNode, node.moduleSpecifier); - case 221: + case 223: return visitNode(cbNode, node.name) || visitNode(cbNode, node.namedBindings); - case 222: + case 224: return visitNode(cbNode, node.name); - case 223: - case 227: + case 225: + case 229: return visitNodes(cbNodes, node.elements); - case 226: + case 228: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.exportClause) || visitNode(cbNode, node.moduleSpecifier); - case 224: - case 228: + case 226: + case 230: return visitNode(cbNode, node.propertyName) || visitNode(cbNode, node.name); - case 225: + case 227: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.expression); - case 181: + case 183: return visitNode(cbNode, node.head) || visitNodes(cbNodes, node.templateSpans); - case 188: + case 190: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.literal); - case 134: + case 136: return visitNode(cbNode, node.expression); - case 241: + case 243: return visitNodes(cbNodes, node.types); - case 186: + case 188: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.typeArguments); - case 230: + case 232: return visitNode(cbNode, node.expression); - case 229: - return visitNodes(cbNodes, node.decorators); case 231: + return visitNodes(cbNodes, node.decorators); + case 233: return visitNode(cbNode, node.openingElement) || visitNodes(cbNodes, node.children) || visitNode(cbNode, node.closingElement); - case 232: - case 233: + case 234: + case 235: return visitNode(cbNode, node.tagName) || visitNodes(cbNodes, node.attributes); - case 236: + case 238: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); + case 239: + return visitNode(cbNode, node.expression); + case 240: + return visitNode(cbNode, node.expression); case 237: - return visitNode(cbNode, node.expression); - case 238: - return visitNode(cbNode, node.expression); - case 235: return visitNode(cbNode, node.tagName); - case 247: - return visitNode(cbNode, node.type); - case 251: - return visitNodes(cbNodes, node.types); - case 252: - return visitNodes(cbNodes, node.types); - case 250: - return visitNode(cbNode, node.elementType); - case 254: + case 249: return visitNode(cbNode, node.type); case 253: + return visitNodes(cbNodes, node.types); + case 254: + return visitNodes(cbNodes, node.types); + case 252: + return visitNode(cbNode, node.elementType); + case 256: return visitNode(cbNode, node.type); case 255: - return visitNodes(cbNodes, node.members); + return visitNode(cbNode, node.type); case 257: + return visitNodes(cbNodes, node.members); + case 259: return visitNode(cbNode, node.name) || visitNodes(cbNodes, node.typeArguments); - case 258: - return visitNode(cbNode, node.type); - case 259: - return visitNodes(cbNodes, node.parameters) || - visitNode(cbNode, node.type); case 260: return visitNode(cbNode, node.type); case 261: - return visitNode(cbNode, node.type); + return visitNodes(cbNodes, node.parameters) || + visitNode(cbNode, node.type); case 262: return visitNode(cbNode, node.type); - case 256: + case 263: + return visitNode(cbNode, node.type); + case 264: + return visitNode(cbNode, node.type); + case 258: return visitNode(cbNode, node.name) || visitNode(cbNode, node.type); - case 263: - return visitNodes(cbNodes, node.tags); case 265: + return visitNodes(cbNodes, node.tags); + case 267: return visitNode(cbNode, node.preParameterName) || visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.postParameterName); - case 266: - return visitNode(cbNode, node.typeExpression); - case 267: - return visitNode(cbNode, node.typeExpression); case 268: + return visitNode(cbNode, node.typeExpression); + case 269: + return visitNode(cbNode, node.typeExpression); + case 270: return visitNodes(cbNodes, node.typeParameters); } } @@ -6048,13 +6177,14 @@ var ts; var contextFlags; var parseErrorBeforeNextFinishedNode = false; function parseSourceFile(fileName, _sourceText, languageVersion, _syntaxCursor, setParentNodes) { - initializeState(fileName, _sourceText, languageVersion, _syntaxCursor); + var isJavaScriptFile = ts.hasJavaScriptFileExtension(fileName) || _sourceText.lastIndexOf("// @language=javascript", 0) === 0; + initializeState(fileName, _sourceText, languageVersion, isJavaScriptFile, _syntaxCursor); var result = parseSourceFileWorker(fileName, languageVersion, setParentNodes); clearState(); return result; } Parser.parseSourceFile = parseSourceFile; - function initializeState(fileName, _sourceText, languageVersion, _syntaxCursor) { + function initializeState(fileName, _sourceText, languageVersion, isJavaScriptFile, _syntaxCursor) { sourceText = _sourceText; syntaxCursor = _syntaxCursor; parseDiagnostics = []; @@ -6062,7 +6192,7 @@ var ts; identifiers = {}; identifierCount = 0; nodeCount = 0; - contextFlags = ts.isJavaScript(fileName) ? 32 : 0; + contextFlags = isJavaScriptFile ? 32 : 0; parseErrorBeforeNextFinishedNode = false; scanner.setText(sourceText); scanner.setOnError(scanError); @@ -6080,6 +6210,9 @@ var ts; } function parseSourceFileWorker(fileName, languageVersion, setParentNodes) { sourceFile = createSourceFile(fileName, languageVersion); + if (contextFlags & 32) { + sourceFile.parserContextFlags = 32; + } token = nextToken(); processReferenceComments(sourceFile); sourceFile.statements = parseList(0, parseStatement); @@ -6093,7 +6226,7 @@ var ts; if (setParentNodes) { fixupParentReferences(sourceFile); } - if (ts.isJavaScript(fileName)) { + if (ts.isSourceFileJavaScript(sourceFile)) { addJSDocComments(); } return sourceFile; @@ -6103,9 +6236,9 @@ var ts; return; function visit(node) { switch (node.kind) { - case 191: - case 211: - case 136: + case 193: + case 213: + case 138: addJSDocComment(node); } forEachChild(node, visit); @@ -6139,7 +6272,7 @@ var ts; } Parser.fixupParentReferences = fixupParentReferences; function createSourceFile(fileName, languageVersion) { - var sourceFile = createNode(246, 0); + var sourceFile = createNode(248, 0); sourceFile.pos = 0; sourceFile.end = sourceText.length; sourceFile.text = sourceText; @@ -6298,16 +6431,16 @@ var ts; return speculationHelper(callback, false); } function isIdentifier() { - if (token === 67) { + if (token === 69) { return true; } - if (token === 112 && inYieldContext()) { + if (token === 114 && inYieldContext()) { return false; } - if (token === 117 && inAwaitContext()) { + if (token === 119 && inAwaitContext()) { return false; } - return token > 103; + return token > 105; } function parseExpected(kind, diagnosticMessage, shouldAdvance) { if (shouldAdvance === void 0) { shouldAdvance = true; } @@ -6403,15 +6536,15 @@ var ts; function createIdentifier(isIdentifier, diagnosticMessage) { identifierCount++; if (isIdentifier) { - var node = createNode(67); - if (token !== 67) { + var node = createNode(69); + if (token !== 69) { node.originalKeywordKind = token; } node.text = internIdentifier(scanner.getTokenValue()); nextToken(); return finishNode(node); } - return createMissingNode(67, false, diagnosticMessage || ts.Diagnostics.Identifier_expected); + return createMissingNode(69, false, diagnosticMessage || ts.Diagnostics.Identifier_expected); } function parseIdentifier(diagnosticMessage) { return createIdentifier(isIdentifier(), diagnosticMessage); @@ -6443,7 +6576,7 @@ var ts; return token === 9 || token === 8 || ts.tokenIsIdentifierOrKeyword(token); } function parseComputedPropertyName() { - var node = createNode(134); + var node = createNode(136); parseExpected(19); node.expression = allowInAnd(parseExpression); parseExpected(20); @@ -6453,20 +6586,27 @@ var ts; return token === t && tryParse(nextTokenCanFollowModifier); } function nextTokenCanFollowModifier() { - if (token === 72) { - return nextToken() === 79; + if (token === 74) { + return nextToken() === 81; } - if (token === 80) { + if (token === 82) { nextToken(); - if (token === 75) { + if (token === 77) { return lookAhead(nextTokenIsClassOrFunction); } return token !== 37 && token !== 15 && canFollowModifier(); } - if (token === 75) { + if (token === 77) { return nextTokenIsClassOrFunction(); } + if (token === 113) { + nextToken(); + return canFollowModifier(); + } nextToken(); + if (scanner.hasPrecedingLineBreak()) { + return false; + } return canFollowModifier(); } function parseAnyContextualModifier() { @@ -6480,7 +6620,7 @@ var ts; } function nextTokenIsClassOrFunction() { nextToken(); - return token === 71 || token === 85; + return token === 73 || token === 87; } function isListElement(parsingContext, inErrorRecovery) { var node = currentNode(parsingContext); @@ -6493,7 +6633,7 @@ var ts; case 3: return !(token === 23 && inErrorRecovery) && isStartOfStatement(); case 2: - return token === 69 || token === 75; + return token === 71 || token === 77; case 4: return isStartOfTypeMember(); case 5: @@ -6549,7 +6689,7 @@ var ts; ts.Debug.assert(token === 15); if (nextToken() === 16) { var next = nextToken(); - return next === 24 || next === 15 || next === 81 || next === 104; + return next === 24 || next === 15 || next === 83 || next === 106; } return true; } @@ -6562,8 +6702,8 @@ var ts; return ts.tokenIsIdentifierOrKeyword(token); } function isHeritageClauseExtendsOrImplementsKeyword() { - if (token === 104 || - token === 81) { + if (token === 106 || + token === 83) { return lookAhead(nextTokenIsStartOfExpression); } return false; @@ -6587,13 +6727,13 @@ var ts; case 21: return token === 16; case 3: - return token === 16 || token === 69 || token === 75; + return token === 16 || token === 71 || token === 77; case 7: - return token === 15 || token === 81 || token === 104; + return token === 15 || token === 83 || token === 106; case 8: return isVariableDeclaratorListTerminator(); case 17: - return token === 27 || token === 17 || token === 15 || token === 81 || token === 104; + return token === 27 || token === 17 || token === 15 || token === 83 || token === 106; case 11: return token === 18 || token === 23; case 15: @@ -6607,11 +6747,11 @@ var ts; case 20: return token === 15 || token === 16; case 13: - return token === 27 || token === 38; + return token === 27 || token === 39; case 14: return token === 25 && lookAhead(nextTokenIsSlash); case 22: - return token === 18 || token === 53 || token === 16; + return token === 18 || token === 54 || token === 16; case 23: return token === 27 || token === 16; case 25: @@ -6732,17 +6872,17 @@ var ts; function isReusableClassMember(node) { if (node) { switch (node.kind) { - case 142: - case 147: - case 143: case 144: - case 139: - case 189: - return true; + case 149: + case 145: + case 146: case 141: + case 191: + return true; + case 143: var methodDeclaration = node; - var nameIsConstructor = methodDeclaration.name.kind === 67 && - methodDeclaration.name.originalKeywordKind === 119; + var nameIsConstructor = methodDeclaration.name.kind === 69 && + methodDeclaration.name.originalKeywordKind === 121; return !nameIsConstructor; } } @@ -6751,8 +6891,8 @@ var ts; function isReusableSwitchClause(node) { if (node) { switch (node.kind) { - case 239: - case 240: + case 241: + case 242: return true; } } @@ -6761,65 +6901,65 @@ var ts; function isReusableStatement(node) { if (node) { switch (node.kind) { - case 211: - case 191: - case 190: - case 194: + case 213: case 193: - case 206: - case 202: - case 204: - case 201: - case 200: - case 198: - case 199: - case 197: - case 196: - case 203: case 192: - case 207: - case 205: + case 196: case 195: case 208: - case 220: - case 219: - case 226: - case 225: - case 216: - case 212: - case 213: - case 215: + case 204: + case 206: + case 203: + case 202: + case 200: + case 201: + case 199: + case 198: + case 205: + case 194: + case 209: + case 207: + case 197: + case 210: + case 222: + case 221: + case 228: + case 227: + case 218: case 214: + case 215: + case 217: + case 216: return true; } } return false; } function isReusableEnumMember(node) { - return node.kind === 245; + return node.kind === 247; } function isReusableTypeMember(node) { if (node) { switch (node.kind) { - case 146: + case 148: + case 142: + case 149: case 140: case 147: - case 138: - case 145: return true; } } return false; } function isReusableVariableDeclaration(node) { - if (node.kind !== 209) { + if (node.kind !== 211) { return false; } var variableDeclarator = node; return variableDeclarator.initializer === undefined; } function isReusableParameter(node) { - if (node.kind !== 136) { + if (node.kind !== 138) { return false; } var parameter = node; @@ -6919,7 +7059,7 @@ var ts; function parseEntityName(allowReservedWords, diagnosticMessage) { var entity = parseIdentifier(diagnosticMessage); while (parseOptional(21)) { - var node = createNode(133, entity.pos); + var node = createNode(135, entity.pos); node.left = entity; node.right = parseRightSideOfDot(allowReservedWords); entity = finishNode(node); @@ -6930,13 +7070,13 @@ var ts; if (scanner.hasPrecedingLineBreak() && ts.tokenIsIdentifierOrKeyword(token)) { var matchesPattern = lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine); if (matchesPattern) { - return createMissingNode(67, true, ts.Diagnostics.Identifier_expected); + return createMissingNode(69, true, ts.Diagnostics.Identifier_expected); } } return allowIdentifierNames ? parseIdentifierName() : parseIdentifier(); } function parseTemplateExpression() { - var template = createNode(181); + var template = createNode(183); template.head = parseLiteralNode(); ts.Debug.assert(template.head.kind === 12, "Template head has wrong token kind"); var templateSpans = []; @@ -6949,7 +7089,7 @@ var ts; return finishNode(template); } function parseTemplateSpan() { - var span = createNode(188); + var span = createNode(190); span.expression = allowInAnd(parseExpression); var literal; if (token === 16) { @@ -6984,14 +7124,14 @@ var ts; } function parseTypeReferenceOrTypePredicate() { var typeName = parseEntityName(false, ts.Diagnostics.Type_expected); - if (typeName.kind === 67 && token === 122 && !scanner.hasPrecedingLineBreak()) { + if (typeName.kind === 69 && token === 124 && !scanner.hasPrecedingLineBreak()) { nextToken(); - var node_1 = createNode(148, typeName.pos); + var node_1 = createNode(150, typeName.pos); node_1.parameterName = typeName; node_1.type = parseType(); return finishNode(node_1); } - var node = createNode(149, typeName.pos); + var node = createNode(151, typeName.pos); node.typeName = typeName; if (!scanner.hasPrecedingLineBreak() && token === 25) { node.typeArguments = parseBracketedList(18, parseType, 25, 27); @@ -6999,15 +7139,15 @@ var ts; return finishNode(node); } function parseTypeQuery() { - var node = createNode(152); - parseExpected(99); + var node = createNode(154); + parseExpected(101); node.exprName = parseEntityName(true); return finishNode(node); } function parseTypeParameter() { - var node = createNode(135); + var node = createNode(137); node.name = parseIdentifier(); - if (parseOptional(81)) { + if (parseOptional(83)) { if (isStartOfType() || !isStartOfExpression()) { node.constraint = parseType(); } @@ -7023,7 +7163,7 @@ var ts; } } function parseParameterType() { - if (parseOptional(53)) { + if (parseOptional(54)) { return token === 9 ? parseLiteralNode(true) : parseType(); @@ -7031,7 +7171,7 @@ var ts; return undefined; } function isStartOfParameter() { - return token === 22 || isIdentifierOrPattern() || ts.isModifier(token) || token === 54; + return token === 22 || isIdentifierOrPattern() || ts.isModifier(token) || token === 55; } function setModifiers(node, modifiers) { if (modifiers) { @@ -7040,7 +7180,7 @@ var ts; } } function parseParameter() { - var node = createNode(136); + var node = createNode(138); node.decorators = parseDecorators(); setModifiers(node, parseModifiers()); node.dotDotDotToken = parseOptionalToken(22); @@ -7048,7 +7188,7 @@ var ts; if (ts.getFullWidth(node.name) === 0 && node.flags === 0 && ts.isModifier(token)) { nextToken(); } - node.questionToken = parseOptionalToken(52); + node.questionToken = parseOptionalToken(53); node.type = parseParameterType(); node.initializer = parseBindingElementInitializer(true); return finishNode(node); @@ -7095,10 +7235,10 @@ var ts; } function parseSignatureMember(kind) { var node = createNode(kind); - if (kind === 146) { - parseExpected(90); + if (kind === 148) { + parseExpected(92); } - fillSignature(53, false, false, false, node); + fillSignature(54, false, false, false, node); parseTypeMemberSemicolon(); return finishNode(node); } @@ -7125,17 +7265,17 @@ var ts; else { nextToken(); } - if (token === 53 || token === 24) { + if (token === 54 || token === 24) { return true; } - if (token !== 52) { + if (token !== 53) { return false; } nextToken(); - return token === 53 || token === 24 || token === 20; + return token === 54 || token === 24 || token === 20; } function parseIndexSignatureDeclaration(fullStart, decorators, modifiers) { - var node = createNode(147, fullStart); + var node = createNode(149, fullStart); node.decorators = decorators; setModifiers(node, modifiers); node.parameters = parseBracketedList(16, parseParameter, 19, 20); @@ -7146,17 +7286,17 @@ var ts; function parsePropertyOrMethodSignature() { var fullStart = scanner.getStartPos(); var name = parsePropertyName(); - var questionToken = parseOptionalToken(52); + var questionToken = parseOptionalToken(53); if (token === 17 || token === 25) { - var method = createNode(140, fullStart); + var method = createNode(142, fullStart); method.name = name; method.questionToken = questionToken; - fillSignature(53, false, false, false, method); + fillSignature(54, false, false, false, method); parseTypeMemberSemicolon(); return finishNode(method); } else { - var property = createNode(138, fullStart); + var property = createNode(140, fullStart); property.name = name; property.questionToken = questionToken; property.type = parseTypeAnnotation(); @@ -7190,22 +7330,22 @@ var ts; nextToken(); return token === 17 || token === 25 || - token === 52 || token === 53 || + token === 54 || canParseSemicolon(); } function parseTypeMember() { switch (token) { case 17: case 25: - return parseSignatureMember(145); + return parseSignatureMember(147); case 19: return isIndexSignature() ? parseIndexSignatureDeclaration(scanner.getStartPos(), undefined, undefined) : parsePropertyOrMethodSignature(); - case 90: + case 92: if (lookAhead(isStartOfConstructSignature)) { - return parseSignatureMember(146); + return parseSignatureMember(148); } case 9: case 8: @@ -7235,7 +7375,7 @@ var ts; return token === 17 || token === 25; } function parseTypeLiteral() { - var node = createNode(153); + var node = createNode(155); node.members = parseObjectTypeMembers(); return finishNode(node); } @@ -7251,12 +7391,12 @@ var ts; return members; } function parseTupleType() { - var node = createNode(155); + var node = createNode(157); node.elementTypes = parseBracketedList(19, parseType, 19, 20); return finishNode(node); } function parseParenthesizedType() { - var node = createNode(158); + var node = createNode(160); parseExpected(17); node.type = parseType(); parseExpected(18); @@ -7264,8 +7404,8 @@ var ts; } function parseFunctionOrConstructorType(kind) { var node = createNode(kind); - if (kind === 151) { - parseExpected(90); + if (kind === 153) { + parseExpected(92); } fillSignature(34, false, false, false, node); return finishNode(node); @@ -7276,16 +7416,17 @@ var ts; } function parseNonArrayType() { switch (token) { - case 115: + case 117: + case 130: case 128: - case 126: - case 118: - case 129: + case 120: + case 131: var node = tryParse(parseKeywordAndNoDot); return node || parseTypeReferenceOrTypePredicate(); - case 101: + case 103: + case 97: return parseTokenNode(); - case 99: + case 101: return parseTypeQuery(); case 15: return parseTypeLiteral(); @@ -7299,17 +7440,18 @@ var ts; } function isStartOfType() { switch (token) { - case 115: + case 117: + case 130: case 128: - case 126: - case 118: - case 129: + case 120: + case 131: + case 103: + case 97: case 101: - case 99: case 15: case 19: case 25: - case 90: + case 92: return true; case 17: return lookAhead(isStartOfParenthesizedOrFunctionType); @@ -7325,7 +7467,7 @@ var ts; var type = parseNonArrayType(); while (!scanner.hasPrecedingLineBreak() && parseOptional(19)) { parseExpected(20); - var node = createNode(154, type.pos); + var node = createNode(156, type.pos); node.elementType = type; type = finishNode(node); } @@ -7347,10 +7489,10 @@ var ts; return type; } function parseIntersectionTypeOrHigher() { - return parseUnionOrIntersectionType(157, parseArrayTypeOrHigher, 45); + return parseUnionOrIntersectionType(159, parseArrayTypeOrHigher, 46); } function parseUnionTypeOrHigher() { - return parseUnionOrIntersectionType(156, parseIntersectionTypeOrHigher, 46); + return parseUnionOrIntersectionType(158, parseIntersectionTypeOrHigher, 47); } function isStartOfFunctionType() { if (token === 25) { @@ -7365,8 +7507,8 @@ var ts; } if (isIdentifier() || ts.isModifier(token)) { nextToken(); - if (token === 53 || token === 24 || - token === 52 || token === 55 || + if (token === 54 || token === 24 || + token === 53 || token === 56 || isIdentifier() || ts.isModifier(token)) { return true; } @@ -7384,23 +7526,23 @@ var ts; } function parseTypeWorker() { if (isStartOfFunctionType()) { - return parseFunctionOrConstructorType(150); + return parseFunctionOrConstructorType(152); } - if (token === 90) { - return parseFunctionOrConstructorType(151); + if (token === 92) { + return parseFunctionOrConstructorType(153); } return parseUnionTypeOrHigher(); } function parseTypeAnnotation() { - return parseOptional(53) ? parseType() : undefined; + return parseOptional(54) ? parseType() : undefined; } function isStartOfLeftHandSideExpression() { switch (token) { + case 97: case 95: case 93: - case 91: - case 97: - case 82: + case 99: + case 84: case 8: case 9: case 11: @@ -7408,12 +7550,12 @@ var ts; case 17: case 19: case 15: - case 85: - case 71: - case 90: - case 38: - case 59: - case 67: + case 87: + case 73: + case 92: + case 39: + case 61: + case 69: return true; default: return isIdentifier(); @@ -7426,16 +7568,16 @@ var ts; switch (token) { case 35: case 36: + case 50: case 49: - case 48: - case 76: - case 99: + case 78: case 101: - case 40: + case 103: case 41: + case 42: case 25: - case 117: - case 112: + case 119: + case 114: return true; default: if (isBinaryOperator()) { @@ -7446,9 +7588,9 @@ var ts; } function isStartOfExpressionStatement() { return token !== 15 && - token !== 85 && - token !== 71 && - token !== 54 && + token !== 87 && + token !== 73 && + token !== 55 && isStartOfExpression(); } function allowInAndParseExpression() { @@ -7470,12 +7612,12 @@ var ts; return expr; } function parseInitializer(inParameter) { - if (token !== 55) { + if (token !== 56) { if (scanner.hasPrecedingLineBreak() || (inParameter && token === 15) || !isStartOfExpression()) { return undefined; } } - parseExpected(55); + parseExpected(56); return parseAssignmentExpressionOrHigher(); } function parseAssignmentExpressionOrHigher() { @@ -7487,7 +7629,7 @@ var ts; return arrowExpression; } var expr = parseBinaryExpressionOrHigher(0); - if (expr.kind === 67 && token === 34) { + if (expr.kind === 69 && token === 34) { return parseSimpleArrowFunctionExpression(expr); } if (ts.isLeftHandSideExpression(expr) && ts.isAssignmentOperator(reScanGreaterToken())) { @@ -7496,7 +7638,7 @@ var ts; return parseConditionalExpressionRest(expr); } function isYieldExpression() { - if (token === 112) { + if (token === 114) { if (inYieldContext()) { return true; } @@ -7509,7 +7651,7 @@ var ts; return !scanner.hasPrecedingLineBreak() && isIdentifier(); } function parseYieldExpression() { - var node = createNode(182); + var node = createNode(184); nextToken(); if (!scanner.hasPrecedingLineBreak() && (token === 37 || isStartOfExpression())) { @@ -7523,8 +7665,8 @@ var ts; } function parseSimpleArrowFunctionExpression(identifier) { ts.Debug.assert(token === 34, "parseSimpleArrowFunctionExpression should only have been called if we had a =>"); - var node = createNode(172, identifier.pos); - var parameter = createNode(136, identifier.pos); + var node = createNode(174, identifier.pos); + var parameter = createNode(138, identifier.pos); parameter.name = identifier; finishNode(parameter); node.parameters = [parameter]; @@ -7554,7 +7696,7 @@ var ts; return finishNode(arrowFunction); } function isParenthesizedArrowFunctionExpression() { - if (token === 17 || token === 25 || token === 116) { + if (token === 17 || token === 25 || token === 118) { return lookAhead(isParenthesizedArrowFunctionExpressionWorker); } if (token === 34) { @@ -7563,7 +7705,7 @@ var ts; return 0; } function isParenthesizedArrowFunctionExpressionWorker() { - if (token === 116) { + if (token === 118) { nextToken(); if (scanner.hasPrecedingLineBreak()) { return 0; @@ -7579,7 +7721,7 @@ var ts; var third = nextToken(); switch (third) { case 34: - case 53: + case 54: case 15: return 1; default: @@ -7595,7 +7737,7 @@ var ts; if (!isIdentifier()) { return 0; } - if (nextToken() === 53) { + if (nextToken() === 54) { return 1; } return 2; @@ -7608,10 +7750,10 @@ var ts; if (sourceFile.languageVariant === 1) { var isArrowFunctionInJsx = lookAhead(function () { var third = nextToken(); - if (third === 81) { + if (third === 83) { var fourth = nextToken(); switch (fourth) { - case 55: + case 56: case 27: return false; default: @@ -7635,10 +7777,10 @@ var ts; return parseParenthesizedArrowFunctionExpressionHead(false); } function parseParenthesizedArrowFunctionExpressionHead(allowAmbiguity) { - var node = createNode(172); + var node = createNode(174); setModifiers(node, parseModifiersForArrowFunction()); var isAsync = !!(node.flags & 512); - fillSignature(53, false, isAsync, !allowAmbiguity, node); + fillSignature(54, false, isAsync, !allowAmbiguity, node); if (!node.parameters) { return undefined; } @@ -7652,8 +7794,8 @@ var ts; return parseFunctionBlock(false, isAsync, false); } if (token !== 23 && - token !== 85 && - token !== 71 && + token !== 87 && + token !== 73 && isStartOfStatement() && !isStartOfExpressionStatement()) { return parseFunctionBlock(false, isAsync, true); @@ -7663,15 +7805,15 @@ var ts; : doOutsideOfAwaitContext(parseAssignmentExpressionOrHigher); } function parseConditionalExpressionRest(leftOperand) { - var questionToken = parseOptionalToken(52); + var questionToken = parseOptionalToken(53); if (!questionToken) { return leftOperand; } - var node = createNode(180, leftOperand.pos); + var node = createNode(182, leftOperand.pos); node.condition = leftOperand; node.questionToken = questionToken; node.whenTrue = doOutsideOfContext(disallowInAndDecoratorContext, parseAssignmentExpressionOrHigher); - node.colonToken = parseExpectedToken(53, false, ts.Diagnostics._0_expected, ts.tokenToString(53)); + node.colonToken = parseExpectedToken(54, false, ts.Diagnostics._0_expected, ts.tokenToString(54)); node.whenFalse = parseAssignmentExpressionOrHigher(); return finishNode(node); } @@ -7680,19 +7822,22 @@ var ts; return parseBinaryExpressionRest(precedence, leftOperand); } function isInOrOfKeyword(t) { - return t === 88 || t === 132; + return t === 90 || t === 134; } function parseBinaryExpressionRest(precedence, leftOperand) { while (true) { reScanGreaterToken(); var newPrecedence = getBinaryOperatorPrecedence(); - if (newPrecedence <= precedence) { + var consumeCurrentOperator = token === 38 ? + newPrecedence >= precedence : + newPrecedence > precedence; + if (!consumeCurrentOperator) { break; } - if (token === 88 && inDisallowInContext()) { + if (token === 90 && inDisallowInContext()) { break; } - if (token === 114) { + if (token === 116) { if (scanner.hasPrecedingLineBreak()) { break; } @@ -7708,22 +7853,22 @@ var ts; return leftOperand; } function isBinaryOperator() { - if (inDisallowInContext() && token === 88) { + if (inDisallowInContext() && token === 90) { return false; } return getBinaryOperatorPrecedence() > 0; } function getBinaryOperatorPrecedence() { switch (token) { - case 51: + case 52: return 1; - case 50: + case 51: return 2; - case 46: - return 3; case 47: + return 3; + case 48: return 4; - case 45: + case 46: return 5; case 30: case 31: @@ -7734,64 +7879,66 @@ var ts; case 27: case 28: case 29: - case 89: - case 88: - case 114: + case 91: + case 90: + case 116: return 7; - case 42: case 43: case 44: + case 45: return 8; case 35: case 36: return 9; case 37: - case 38: case 39: + case 40: return 10; + case 38: + return 11; } return -1; } function makeBinaryExpression(left, operatorToken, right) { - var node = createNode(179, left.pos); + var node = createNode(181, left.pos); node.left = left; node.operatorToken = operatorToken; node.right = right; return finishNode(node); } function makeAsExpression(left, right) { - var node = createNode(187, left.pos); + var node = createNode(189, left.pos); node.expression = left; node.type = right; return finishNode(node); } function parsePrefixUnaryExpression() { - var node = createNode(177); + var node = createNode(179); node.operator = token; nextToken(); - node.operand = parseUnaryExpressionOrHigher(); + node.operand = parseSimpleUnaryExpression(); return finishNode(node); } function parseDeleteExpression() { - var node = createNode(173); + var node = createNode(175); nextToken(); - node.expression = parseUnaryExpressionOrHigher(); + node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function parseTypeOfExpression() { - var node = createNode(174); + var node = createNode(176); nextToken(); - node.expression = parseUnaryExpressionOrHigher(); + node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function parseVoidExpression() { - var node = createNode(175); + var node = createNode(177); nextToken(); - node.expression = parseUnaryExpressionOrHigher(); + node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function isAwaitExpression() { - if (token === 117) { + if (token === 119) { if (inAwaitContext()) { return true; } @@ -7800,45 +7947,87 @@ var ts; return false; } function parseAwaitExpression() { - var node = createNode(176); + var node = createNode(178); nextToken(); - node.expression = parseUnaryExpressionOrHigher(); + node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function parseUnaryExpressionOrHigher() { if (isAwaitExpression()) { return parseAwaitExpression(); } + if (isIncrementExpression()) { + var incrementExpression = parseIncrementExpression(); + return token === 38 ? + parseBinaryExpressionRest(getBinaryOperatorPrecedence(), incrementExpression) : + incrementExpression; + } + var unaryOperator = token; + var simpleUnaryExpression = parseSimpleUnaryExpression(); + if (token === 38) { + var diagnostic; + var start = ts.skipTrivia(sourceText, simpleUnaryExpression.pos); + if (simpleUnaryExpression.kind === 171) { + parseErrorAtPosition(start, simpleUnaryExpression.end - start, ts.Diagnostics.A_type_assertion_expression_is_not_allowed_in_the_left_hand_side_of_an_exponentiation_expression_Consider_enclosing_the_expression_in_parentheses); + } + else { + parseErrorAtPosition(start, simpleUnaryExpression.end - start, ts.Diagnostics.An_unary_expression_with_the_0_operator_is_not_allowed_in_the_left_hand_side_of_an_exponentiation_expression_Consider_enclosing_the_expression_in_parentheses, ts.tokenToString(unaryOperator)); + } + } + return simpleUnaryExpression; + } + function parseSimpleUnaryExpression() { switch (token) { case 35: case 36: + case 50: case 49: - case 48: - case 40: - case 41: return parsePrefixUnaryExpression(); - case 76: + case 78: return parseDeleteExpression(); - case 99: - return parseTypeOfExpression(); case 101: + return parseTypeOfExpression(); + case 103: return parseVoidExpression(); case 25: - if (sourceFile.languageVariant !== 1) { - return parseTypeAssertion(); - } - if (lookAhead(nextTokenIsIdentifierOrKeyword)) { - return parseJsxElementOrSelfClosingElement(true); - } + return parseTypeAssertion(); default: - return parsePostfixExpressionOrHigher(); + return parseIncrementExpression(); } } - function parsePostfixExpressionOrHigher() { + function isIncrementExpression() { + switch (token) { + case 35: + case 36: + case 50: + case 49: + case 78: + case 101: + case 103: + return false; + case 25: + if (sourceFile.languageVariant !== 1) { + return false; + } + default: + return true; + } + } + function parseIncrementExpression() { + if (token === 41 || token === 42) { + var node = createNode(179); + node.operator = token; + nextToken(); + node.operand = parseLeftHandSideExpressionOrHigher(); + return finishNode(node); + } + else if (sourceFile.languageVariant === 1 && token === 25 && lookAhead(nextTokenIsIdentifierOrKeyword)) { + return parseJsxElementOrSelfClosingElement(true); + } var expression = parseLeftHandSideExpressionOrHigher(); ts.Debug.assert(ts.isLeftHandSideExpression(expression)); - if ((token === 40 || token === 41) && !scanner.hasPrecedingLineBreak()) { - var node = createNode(178, expression.pos); + if ((token === 41 || token === 42) && !scanner.hasPrecedingLineBreak()) { + var node = createNode(180, expression.pos); node.operand = expression; node.operator = token; nextToken(); @@ -7847,7 +8036,7 @@ var ts; return expression; } function parseLeftHandSideExpressionOrHigher() { - var expression = token === 93 + var expression = token === 95 ? parseSuperExpression() : parseMemberExpressionOrHigher(); return parseCallExpressionRest(expression); @@ -7861,7 +8050,7 @@ var ts; if (token === 17 || token === 21 || token === 19) { return expression; } - var node = createNode(164, expression.pos); + var node = createNode(166, expression.pos); node.expression = expression; node.dotToken = parseExpectedToken(21, false, ts.Diagnostics.super_must_be_followed_by_an_argument_list_or_member_access); node.name = parseRightSideOfDot(true); @@ -7869,26 +8058,26 @@ var ts; } function parseJsxElementOrSelfClosingElement(inExpressionContext) { var opening = parseJsxOpeningOrSelfClosingElement(inExpressionContext); - if (opening.kind === 233) { - var node = createNode(231, opening.pos); + if (opening.kind === 235) { + var node = createNode(233, opening.pos); node.openingElement = opening; node.children = parseJsxChildren(node.openingElement.tagName); node.closingElement = parseJsxClosingElement(inExpressionContext); return finishNode(node); } else { - ts.Debug.assert(opening.kind === 232); + ts.Debug.assert(opening.kind === 234); return opening; } } function parseJsxText() { - var node = createNode(234, scanner.getStartPos()); + var node = createNode(236, scanner.getStartPos()); token = scanner.scanJsxToken(); return finishNode(node); } function parseJsxChild() { switch (token) { - case 234: + case 236: return parseJsxText(); case 15: return parseJsxExpression(false); @@ -7924,11 +8113,11 @@ var ts; var attributes = parseList(13, parseJsxAttribute); var node; if (token === 27) { - node = createNode(233, fullStart); + node = createNode(235, fullStart); scanJsxText(); } else { - parseExpected(38); + parseExpected(39); if (inExpressionContext) { parseExpected(27); } @@ -7936,7 +8125,7 @@ var ts; parseExpected(27, undefined, false); scanJsxText(); } - node = createNode(232, fullStart); + node = createNode(234, fullStart); } node.tagName = tagName; node.attributes = attributes; @@ -7947,7 +8136,7 @@ var ts; var elementName = parseIdentifierName(); while (parseOptional(21)) { scanJsxIdentifier(); - var node = createNode(133, elementName.pos); + var node = createNode(135, elementName.pos); node.left = elementName; node.right = parseIdentifierName(); elementName = finishNode(node); @@ -7955,7 +8144,7 @@ var ts; return elementName; } function parseJsxExpression(inExpressionContext) { - var node = createNode(238); + var node = createNode(240); parseExpected(15); if (token !== 16) { node.expression = parseExpression(); @@ -7974,9 +8163,9 @@ var ts; return parseJsxSpreadAttribute(); } scanJsxIdentifier(); - var node = createNode(236); + var node = createNode(238); node.name = parseIdentifierName(); - if (parseOptional(55)) { + if (parseOptional(56)) { switch (token) { case 9: node.initializer = parseLiteralNode(); @@ -7989,7 +8178,7 @@ var ts; return finishNode(node); } function parseJsxSpreadAttribute() { - var node = createNode(237); + var node = createNode(239); parseExpected(15); parseExpected(22); node.expression = parseExpression(); @@ -7997,7 +8186,7 @@ var ts; return finishNode(node); } function parseJsxClosingElement(inExpressionContext) { - var node = createNode(235); + var node = createNode(237); parseExpected(26); node.tagName = parseJsxElementName(); if (inExpressionContext) { @@ -8010,18 +8199,18 @@ var ts; return finishNode(node); } function parseTypeAssertion() { - var node = createNode(169); + var node = createNode(171); parseExpected(25); node.type = parseType(); parseExpected(27); - node.expression = parseUnaryExpressionOrHigher(); + node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function parseMemberExpressionRest(expression) { while (true) { var dotToken = parseOptionalToken(21); if (dotToken) { - var propertyAccess = createNode(164, expression.pos); + var propertyAccess = createNode(166, expression.pos); propertyAccess.expression = expression; propertyAccess.dotToken = dotToken; propertyAccess.name = parseRightSideOfDot(true); @@ -8029,7 +8218,7 @@ var ts; continue; } if (!inDecoratorContext() && parseOptional(19)) { - var indexedAccess = createNode(165, expression.pos); + var indexedAccess = createNode(167, expression.pos); indexedAccess.expression = expression; if (token !== 20) { indexedAccess.argumentExpression = allowInAnd(parseExpression); @@ -8043,7 +8232,7 @@ var ts; continue; } if (token === 11 || token === 12) { - var tagExpression = createNode(168, expression.pos); + var tagExpression = createNode(170, expression.pos); tagExpression.tag = expression; tagExpression.template = token === 11 ? parseLiteralNode() @@ -8062,7 +8251,7 @@ var ts; if (!typeArguments) { return expression; } - var callExpr = createNode(166, expression.pos); + var callExpr = createNode(168, expression.pos); callExpr.expression = expression; callExpr.typeArguments = typeArguments; callExpr.arguments = parseArgumentList(); @@ -8070,7 +8259,7 @@ var ts; continue; } else if (token === 17) { - var callExpr = createNode(166, expression.pos); + var callExpr = createNode(168, expression.pos); callExpr.expression = expression; callExpr.arguments = parseArgumentList(); expression = finishNode(callExpr); @@ -8103,18 +8292,18 @@ var ts; case 21: case 18: case 20: - case 53: + case 54: case 23: - case 52: + case 53: case 30: case 32: case 31: case 33: - case 50: case 51: - case 47: - case 45: + case 52: + case 48: case 46: + case 47: case 16: case 1: return true; @@ -8130,11 +8319,11 @@ var ts; case 9: case 11: return parseLiteralNode(); + case 97: case 95: case 93: - case 91: - case 97: - case 82: + case 99: + case 84: return parseTokenNode(); case 17: return parseParenthesizedExpression(); @@ -8142,19 +8331,19 @@ var ts; return parseArrayLiteralExpression(); case 15: return parseObjectLiteralExpression(); - case 116: + case 118: if (!lookAhead(nextTokenIsFunctionKeywordOnSameLine)) { break; } return parseFunctionExpression(); - case 71: + case 73: return parseClassExpression(); - case 85: + case 87: return parseFunctionExpression(); - case 90: + case 92: return parseNewExpression(); - case 38: - case 59: + case 39: + case 61: if (reScanSlashToken() === 10) { return parseLiteralNode(); } @@ -8165,28 +8354,28 @@ var ts; return parseIdentifier(ts.Diagnostics.Expression_expected); } function parseParenthesizedExpression() { - var node = createNode(170); + var node = createNode(172); parseExpected(17); node.expression = allowInAnd(parseExpression); parseExpected(18); return finishNode(node); } function parseSpreadElement() { - var node = createNode(183); + var node = createNode(185); parseExpected(22); node.expression = parseAssignmentExpressionOrHigher(); return finishNode(node); } function parseArgumentOrArrayLiteralElement() { return token === 22 ? parseSpreadElement() : - token === 24 ? createNode(185) : + token === 24 ? createNode(187) : parseAssignmentExpressionOrHigher(); } function parseArgumentExpression() { return doOutsideOfContext(disallowInAndDecoratorContext, parseArgumentOrArrayLiteralElement); } function parseArrayLiteralExpression() { - var node = createNode(162); + var node = createNode(164); parseExpected(19); if (scanner.hasPrecedingLineBreak()) node.flags |= 2048; @@ -8195,11 +8384,11 @@ var ts; return finishNode(node); } function tryParseAccessorDeclaration(fullStart, decorators, modifiers) { - if (parseContextualModifier(121)) { - return parseAccessorDeclaration(143, fullStart, decorators, modifiers); + if (parseContextualModifier(123)) { + return parseAccessorDeclaration(145, fullStart, decorators, modifiers); } - else if (parseContextualModifier(127)) { - return parseAccessorDeclaration(144, fullStart, decorators, modifiers); + else if (parseContextualModifier(129)) { + return parseAccessorDeclaration(146, fullStart, decorators, modifiers); } return undefined; } @@ -8215,27 +8404,33 @@ var ts; var tokenIsIdentifier = isIdentifier(); var nameToken = token; var propertyName = parsePropertyName(); - var questionToken = parseOptionalToken(52); + var questionToken = parseOptionalToken(53); if (asteriskToken || token === 17 || token === 25) { return parseMethodDeclaration(fullStart, decorators, modifiers, asteriskToken, propertyName, questionToken); } - if ((token === 24 || token === 16) && tokenIsIdentifier) { - var shorthandDeclaration = createNode(244, fullStart); + var isShorthandPropertyAssignment = tokenIsIdentifier && (token === 24 || token === 16 || token === 56); + if (isShorthandPropertyAssignment) { + var shorthandDeclaration = createNode(246, fullStart); shorthandDeclaration.name = propertyName; shorthandDeclaration.questionToken = questionToken; + var equalsToken = parseOptionalToken(56); + if (equalsToken) { + shorthandDeclaration.equalsToken = equalsToken; + shorthandDeclaration.objectAssignmentInitializer = allowInAnd(parseAssignmentExpressionOrHigher); + } return finishNode(shorthandDeclaration); } else { - var propertyAssignment = createNode(243, fullStart); + var propertyAssignment = createNode(245, fullStart); propertyAssignment.name = propertyName; propertyAssignment.questionToken = questionToken; - parseExpected(53); + parseExpected(54); propertyAssignment.initializer = allowInAnd(parseAssignmentExpressionOrHigher); return finishNode(propertyAssignment); } } function parseObjectLiteralExpression() { - var node = createNode(163); + var node = createNode(165); parseExpected(15); if (scanner.hasPrecedingLineBreak()) { node.flags |= 2048; @@ -8249,9 +8444,9 @@ var ts; if (saveDecoratorContext) { setDecoratorContext(false); } - var node = createNode(171); + var node = createNode(173); setModifiers(node, parseModifiers()); - parseExpected(85); + parseExpected(87); node.asteriskToken = parseOptionalToken(37); var isGenerator = !!node.asteriskToken; var isAsync = !!(node.flags & 512); @@ -8260,7 +8455,7 @@ var ts; isGenerator ? doInYieldContext(parseOptionalIdentifier) : isAsync ? doInAwaitContext(parseOptionalIdentifier) : parseOptionalIdentifier(); - fillSignature(53, isGenerator, isAsync, false, node); + fillSignature(54, isGenerator, isAsync, false, node); node.body = parseFunctionBlock(isGenerator, isAsync, false); if (saveDecoratorContext) { setDecoratorContext(true); @@ -8271,8 +8466,8 @@ var ts; return isIdentifier() ? parseIdentifier() : undefined; } function parseNewExpression() { - var node = createNode(167); - parseExpected(90); + var node = createNode(169); + parseExpected(92); node.expression = parseMemberExpressionOrHigher(); node.typeArguments = tryParse(parseTypeArgumentsInExpression); if (node.typeArguments || token === 17) { @@ -8281,7 +8476,7 @@ var ts; return finishNode(node); } function parseBlock(ignoreMissingOpenBrace, diagnosticMessage) { - var node = createNode(190); + var node = createNode(192); if (parseExpected(15, diagnosticMessage) || ignoreMissingOpenBrace) { node.statements = parseList(1, parseStatement); parseExpected(16); @@ -8309,25 +8504,25 @@ var ts; return block; } function parseEmptyStatement() { - var node = createNode(192); + var node = createNode(194); parseExpected(23); return finishNode(node); } function parseIfStatement() { - var node = createNode(194); - parseExpected(86); + var node = createNode(196); + parseExpected(88); parseExpected(17); node.expression = allowInAnd(parseExpression); parseExpected(18); node.thenStatement = parseStatement(); - node.elseStatement = parseOptional(78) ? parseStatement() : undefined; + node.elseStatement = parseOptional(80) ? parseStatement() : undefined; return finishNode(node); } function parseDoStatement() { - var node = createNode(195); - parseExpected(77); + var node = createNode(197); + parseExpected(79); node.statement = parseStatement(); - parseExpected(102); + parseExpected(104); parseExpected(17); node.expression = allowInAnd(parseExpression); parseExpected(18); @@ -8335,8 +8530,8 @@ var ts; return finishNode(node); } function parseWhileStatement() { - var node = createNode(196); - parseExpected(102); + var node = createNode(198); + parseExpected(104); parseExpected(17); node.expression = allowInAnd(parseExpression); parseExpected(18); @@ -8345,11 +8540,11 @@ var ts; } function parseForOrForInOrForOfStatement() { var pos = getNodePos(); - parseExpected(84); + parseExpected(86); parseExpected(17); var initializer = undefined; if (token !== 23) { - if (token === 100 || token === 106 || token === 72) { + if (token === 102 || token === 108 || token === 74) { initializer = parseVariableDeclarationList(true); } else { @@ -8357,22 +8552,22 @@ var ts; } } var forOrForInOrForOfStatement; - if (parseOptional(88)) { - var forInStatement = createNode(198, pos); + if (parseOptional(90)) { + var forInStatement = createNode(200, pos); forInStatement.initializer = initializer; forInStatement.expression = allowInAnd(parseExpression); parseExpected(18); forOrForInOrForOfStatement = forInStatement; } - else if (parseOptional(132)) { - var forOfStatement = createNode(199, pos); + else if (parseOptional(134)) { + var forOfStatement = createNode(201, pos); forOfStatement.initializer = initializer; forOfStatement.expression = allowInAnd(parseAssignmentExpressionOrHigher); parseExpected(18); forOrForInOrForOfStatement = forOfStatement; } else { - var forStatement = createNode(197, pos); + var forStatement = createNode(199, pos); forStatement.initializer = initializer; parseExpected(23); if (token !== 23 && token !== 18) { @@ -8390,7 +8585,7 @@ var ts; } function parseBreakOrContinueStatement(kind) { var node = createNode(kind); - parseExpected(kind === 201 ? 68 : 73); + parseExpected(kind === 203 ? 70 : 75); if (!canParseSemicolon()) { node.label = parseIdentifier(); } @@ -8398,8 +8593,8 @@ var ts; return finishNode(node); } function parseReturnStatement() { - var node = createNode(202); - parseExpected(92); + var node = createNode(204); + parseExpected(94); if (!canParseSemicolon()) { node.expression = allowInAnd(parseExpression); } @@ -8407,8 +8602,8 @@ var ts; return finishNode(node); } function parseWithStatement() { - var node = createNode(203); - parseExpected(103); + var node = createNode(205); + parseExpected(105); parseExpected(17); node.expression = allowInAnd(parseExpression); parseExpected(18); @@ -8416,30 +8611,30 @@ var ts; return finishNode(node); } function parseCaseClause() { - var node = createNode(239); - parseExpected(69); + var node = createNode(241); + parseExpected(71); node.expression = allowInAnd(parseExpression); - parseExpected(53); + parseExpected(54); node.statements = parseList(3, parseStatement); return finishNode(node); } function parseDefaultClause() { - var node = createNode(240); - parseExpected(75); - parseExpected(53); + var node = createNode(242); + parseExpected(77); + parseExpected(54); node.statements = parseList(3, parseStatement); return finishNode(node); } function parseCaseOrDefaultClause() { - return token === 69 ? parseCaseClause() : parseDefaultClause(); + return token === 71 ? parseCaseClause() : parseDefaultClause(); } function parseSwitchStatement() { - var node = createNode(204); - parseExpected(94); + var node = createNode(206); + parseExpected(96); parseExpected(17); node.expression = allowInAnd(parseExpression); parseExpected(18); - var caseBlock = createNode(218, scanner.getStartPos()); + var caseBlock = createNode(220, scanner.getStartPos()); parseExpected(15); caseBlock.clauses = parseList(2, parseCaseOrDefaultClause); parseExpected(16); @@ -8447,26 +8642,26 @@ var ts; return finishNode(node); } function parseThrowStatement() { - var node = createNode(206); - parseExpected(96); + var node = createNode(208); + parseExpected(98); node.expression = scanner.hasPrecedingLineBreak() ? undefined : allowInAnd(parseExpression); parseSemicolon(); return finishNode(node); } function parseTryStatement() { - var node = createNode(207); - parseExpected(98); + var node = createNode(209); + parseExpected(100); node.tryBlock = parseBlock(false); - node.catchClause = token === 70 ? parseCatchClause() : undefined; - if (!node.catchClause || token === 83) { - parseExpected(83); + node.catchClause = token === 72 ? parseCatchClause() : undefined; + if (!node.catchClause || token === 85) { + parseExpected(85); node.finallyBlock = parseBlock(false); } return finishNode(node); } function parseCatchClause() { - var result = createNode(242); - parseExpected(70); + var result = createNode(244); + parseExpected(72); if (parseExpected(17)) { result.variableDeclaration = parseVariableDeclaration(); } @@ -8475,22 +8670,22 @@ var ts; return finishNode(result); } function parseDebuggerStatement() { - var node = createNode(208); - parseExpected(74); + var node = createNode(210); + parseExpected(76); parseSemicolon(); return finishNode(node); } function parseExpressionOrLabeledStatement() { var fullStart = scanner.getStartPos(); var expression = allowInAnd(parseExpression); - if (expression.kind === 67 && parseOptional(53)) { - var labeledStatement = createNode(205, fullStart); + if (expression.kind === 69 && parseOptional(54)) { + var labeledStatement = createNode(207, fullStart); labeledStatement.label = expression; labeledStatement.statement = parseStatement(); return finishNode(labeledStatement); } else { - var expressionStatement = createNode(193, fullStart); + var expressionStatement = createNode(195, fullStart); expressionStatement.expression = expression; parseSemicolon(); return finishNode(expressionStatement); @@ -8502,7 +8697,7 @@ var ts; } function nextTokenIsFunctionKeywordOnSameLine() { nextToken(); - return token === 85 && !scanner.hasPrecedingLineBreak(); + return token === 87 && !scanner.hasPrecedingLineBreak(); } function nextTokenIsIdentifierOrKeywordOrNumberOnSameLine() { nextToken(); @@ -8511,41 +8706,41 @@ var ts; function isDeclaration() { while (true) { switch (token) { - case 100: - case 106: - case 72: - case 85: - case 71: - case 79: + case 102: + case 108: + case 74: + case 87: + case 73: + case 81: return true; - case 105: - case 130: + case 107: + case 132: return nextTokenIsIdentifierOnSameLine(); - case 123: - case 124: + case 125: + case 126: return nextTokenIsIdentifierOrStringLiteralOnSameLine(); - case 116: - case 120: + case 115: + case 118: + case 122: + case 110: + case 111: + case 112: nextToken(); if (scanner.hasPrecedingLineBreak()) { return false; } continue; - case 87: + case 89: nextToken(); return token === 9 || token === 37 || token === 15 || ts.tokenIsIdentifierOrKeyword(token); - case 80: + case 82: nextToken(); - if (token === 55 || token === 37 || - token === 15 || token === 75) { + if (token === 56 || token === 37 || + token === 15 || token === 77) { return true; } continue; - case 110: - case 108: - case 109: - case 111: case 113: nextToken(); continue; @@ -8559,44 +8754,44 @@ var ts; } function isStartOfStatement() { switch (token) { - case 54: + case 55: case 23: case 15: - case 100: - case 106: - case 85: - case 71: - case 79: - case 86: - case 77: case 102: - case 84: + case 108: + case 87: case 73: - case 68: - case 92: - case 103: + case 81: + case 88: + case 79: + case 104: + case 86: + case 75: + case 70: case 94: + case 105: case 96: case 98: - case 74: - case 70: - case 83: - return true; + case 100: + case 76: case 72: - case 80: - case 87: - return isStartOfDeclaration(); - case 116: - case 120: - case 105: - case 123: - case 124: - case 130: + case 85: return true; + case 74: + case 82: + case 89: + return isStartOfDeclaration(); + case 118: + case 122: + case 107: + case 125: + case 126: + case 132: + return true; + case 112: case 110: - case 108: - case 109: case 111: + case 113: return isStartOfDeclaration() || !lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine); default: return isStartOfExpression(); @@ -8615,60 +8810,60 @@ var ts; return parseEmptyStatement(); case 15: return parseBlock(false); - case 100: + case 102: return parseVariableStatement(scanner.getStartPos(), undefined, undefined); - case 106: + case 108: if (isLetDeclaration()) { return parseVariableStatement(scanner.getStartPos(), undefined, undefined); } break; - case 85: - return parseFunctionDeclaration(scanner.getStartPos(), undefined, undefined); - case 71: - return parseClassDeclaration(scanner.getStartPos(), undefined, undefined); - case 86: - return parseIfStatement(); - case 77: - return parseDoStatement(); - case 102: - return parseWhileStatement(); - case 84: - return parseForOrForInOrForOfStatement(); - case 73: - return parseBreakOrContinueStatement(200); - case 68: - return parseBreakOrContinueStatement(201); - case 92: - return parseReturnStatement(); - case 103: - return parseWithStatement(); - case 94: - return parseSwitchStatement(); - case 96: - return parseThrowStatement(); - case 98: - case 70: - case 83: - return parseTryStatement(); - case 74: - return parseDebuggerStatement(); - case 54: - return parseDeclaration(); - case 116: - case 105: - case 130: - case 123: - case 124: - case 120: - case 72: - case 79: - case 80: case 87: - case 108: - case 109: + 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(202); + case 70: + return parseBreakOrContinueStatement(203); + 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 132: + case 125: + case 126: + case 122: + case 74: + case 81: + case 82: + case 89: case 110: - case 113: case 111: + case 112: + case 115: + case 113: if (isStartOfDeclaration()) { return parseDeclaration(); } @@ -8681,33 +8876,33 @@ var ts; var decorators = parseDecorators(); var modifiers = parseModifiers(); switch (token) { - case 100: - case 106: - case 72: + case 102: + case 108: + case 74: return parseVariableStatement(fullStart, decorators, modifiers); - case 85: - return parseFunctionDeclaration(fullStart, decorators, modifiers); - case 71: - return parseClassDeclaration(fullStart, decorators, modifiers); - case 105: - return parseInterfaceDeclaration(fullStart, decorators, modifiers); - case 130: - return parseTypeAliasDeclaration(fullStart, decorators, modifiers); - case 79: - return parseEnumDeclaration(fullStart, decorators, modifiers); - case 123: - case 124: - return parseModuleDeclaration(fullStart, decorators, modifiers); case 87: + return parseFunctionDeclaration(fullStart, decorators, modifiers); + case 73: + return parseClassDeclaration(fullStart, decorators, modifiers); + case 107: + return parseInterfaceDeclaration(fullStart, decorators, modifiers); + case 132: + return parseTypeAliasDeclaration(fullStart, decorators, modifiers); + case 81: + return parseEnumDeclaration(fullStart, decorators, modifiers); + case 125: + case 126: + return parseModuleDeclaration(fullStart, decorators, modifiers); + case 89: return parseImportDeclarationOrImportEqualsDeclaration(fullStart, decorators, modifiers); - case 80: + case 82: nextToken(); - return token === 75 || token === 55 ? + return token === 77 || token === 56 ? parseExportAssignment(fullStart, decorators, modifiers) : parseExportDeclaration(fullStart, decorators, modifiers); default: if (decorators || modifiers) { - var node = createMissingNode(229, true, ts.Diagnostics.Declaration_expected); + var node = createMissingNode(231, true, ts.Diagnostics.Declaration_expected); node.pos = fullStart; node.decorators = decorators; setModifiers(node, modifiers); @@ -8728,23 +8923,23 @@ var ts; } function parseArrayBindingElement() { if (token === 24) { - return createNode(185); + return createNode(187); } - var node = createNode(161); + var node = createNode(163); node.dotDotDotToken = parseOptionalToken(22); node.name = parseIdentifierOrPattern(); node.initializer = parseBindingElementInitializer(false); return finishNode(node); } function parseObjectBindingElement() { - var node = createNode(161); + var node = createNode(163); var tokenIsIdentifier = isIdentifier(); var propertyName = parsePropertyName(); - if (tokenIsIdentifier && token !== 53) { + if (tokenIsIdentifier && token !== 54) { node.name = propertyName; } else { - parseExpected(53); + parseExpected(54); node.propertyName = propertyName; node.name = parseIdentifierOrPattern(); } @@ -8752,14 +8947,14 @@ var ts; return finishNode(node); } function parseObjectBindingPattern() { - var node = createNode(159); + var node = createNode(161); parseExpected(15); node.elements = parseDelimitedList(9, parseObjectBindingElement); parseExpected(16); return finishNode(node); } function parseArrayBindingPattern() { - var node = createNode(160); + var node = createNode(162); parseExpected(19); node.elements = parseDelimitedList(10, parseArrayBindingElement); parseExpected(20); @@ -8778,7 +8973,7 @@ var ts; return parseIdentifier(); } function parseVariableDeclaration() { - var node = createNode(209); + var node = createNode(211); node.name = parseIdentifierOrPattern(); node.type = parseTypeAnnotation(); if (!isInOrOfKeyword(token)) { @@ -8787,21 +8982,21 @@ var ts; return finishNode(node); } function parseVariableDeclarationList(inForStatementInitializer) { - var node = createNode(210); + var node = createNode(212); switch (token) { - case 100: + case 102: break; - case 106: + case 108: node.flags |= 16384; break; - case 72: + case 74: node.flags |= 32768; break; default: ts.Debug.fail(); } nextToken(); - if (token === 132 && lookAhead(canFollowContextualOfKeyword)) { + if (token === 134 && lookAhead(canFollowContextualOfKeyword)) { node.declarations = createMissingList(); } else { @@ -8816,7 +9011,7 @@ var ts; return nextTokenIsIdentifier() && nextToken() === 18; } function parseVariableStatement(fullStart, decorators, modifiers) { - var node = createNode(191, fullStart); + var node = createNode(193, fullStart); node.decorators = decorators; setModifiers(node, modifiers); node.declarationList = parseVariableDeclarationList(false); @@ -8824,29 +9019,29 @@ var ts; return finishNode(node); } function parseFunctionDeclaration(fullStart, decorators, modifiers) { - var node = createNode(211, fullStart); + var node = createNode(213, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - parseExpected(85); + parseExpected(87); node.asteriskToken = parseOptionalToken(37); node.name = node.flags & 1024 ? parseOptionalIdentifier() : parseIdentifier(); var isGenerator = !!node.asteriskToken; var isAsync = !!(node.flags & 512); - fillSignature(53, isGenerator, isAsync, false, node); + fillSignature(54, isGenerator, isAsync, false, node); node.body = parseFunctionBlockOrSemicolon(isGenerator, isAsync, ts.Diagnostics.or_expected); return finishNode(node); } function parseConstructorDeclaration(pos, decorators, modifiers) { - var node = createNode(142, pos); + var node = createNode(144, pos); node.decorators = decorators; setModifiers(node, modifiers); - parseExpected(119); - fillSignature(53, false, false, false, node); + parseExpected(121); + fillSignature(54, false, false, false, node); node.body = parseFunctionBlockOrSemicolon(false, false, ts.Diagnostics.or_expected); return finishNode(node); } function parseMethodDeclaration(fullStart, decorators, modifiers, asteriskToken, name, questionToken, diagnosticMessage) { - var method = createNode(141, fullStart); + var method = createNode(143, fullStart); method.decorators = decorators; setModifiers(method, modifiers); method.asteriskToken = asteriskToken; @@ -8854,12 +9049,12 @@ var ts; method.questionToken = questionToken; var isGenerator = !!asteriskToken; var isAsync = !!(method.flags & 512); - fillSignature(53, isGenerator, isAsync, false, method); + fillSignature(54, isGenerator, isAsync, false, method); method.body = parseFunctionBlockOrSemicolon(isGenerator, isAsync, diagnosticMessage); return finishNode(method); } function parsePropertyDeclaration(fullStart, decorators, modifiers, name, questionToken) { - var property = createNode(139, fullStart); + var property = createNode(141, fullStart); property.decorators = decorators; setModifiers(property, modifiers); property.name = name; @@ -8874,7 +9069,7 @@ var ts; function parsePropertyOrMethodDeclaration(fullStart, decorators, modifiers) { var asteriskToken = parseOptionalToken(37); var name = parsePropertyName(); - var questionToken = parseOptionalToken(52); + var questionToken = parseOptionalToken(53); if (asteriskToken || token === 17 || token === 25) { return parseMethodDeclaration(fullStart, decorators, modifiers, asteriskToken, name, questionToken, ts.Diagnostics.or_expected); } @@ -8890,16 +9085,16 @@ var ts; node.decorators = decorators; setModifiers(node, modifiers); node.name = parsePropertyName(); - fillSignature(53, false, false, false, node); + fillSignature(54, false, false, false, node); node.body = parseFunctionBlockOrSemicolon(false, false); return finishNode(node); } function isClassMemberModifier(idToken) { switch (idToken) { + case 112: case 110: - case 108: - case 109: case 111: + case 113: return true; default: return false; @@ -8907,7 +9102,7 @@ var ts; } function isClassMemberStart() { var idToken; - if (token === 54) { + if (token === 55) { return true; } while (ts.isModifier(token)) { @@ -8928,15 +9123,15 @@ var ts; return true; } if (idToken !== undefined) { - if (!ts.isKeyword(idToken) || idToken === 127 || idToken === 121) { + if (!ts.isKeyword(idToken) || idToken === 129 || idToken === 123) { return true; } switch (token) { case 17: case 25: + case 54: + case 56: case 53: - case 55: - case 52: return true; default: return canParseSemicolon(); @@ -8948,14 +9143,14 @@ var ts; var decorators; while (true) { var decoratorStart = getNodePos(); - if (!parseOptional(54)) { + if (!parseOptional(55)) { break; } if (!decorators) { decorators = []; decorators.pos = scanner.getStartPos(); } - var decorator = createNode(137, decoratorStart); + var decorator = createNode(139, decoratorStart); decorator.expression = doInDecoratorContext(parseLeftHandSideExpressionOrHigher); decorators.push(finishNode(decorator)); } @@ -8989,7 +9184,7 @@ var ts; function parseModifiersForArrowFunction() { var flags = 0; var modifiers; - if (token === 116) { + if (token === 118) { var modifierStart = scanner.getStartPos(); var modifierKind = token; nextToken(); @@ -9004,7 +9199,7 @@ var ts; } function parseClassElement() { if (token === 23) { - var result = createNode(189); + var result = createNode(191); nextToken(); return finishNode(result); } @@ -9015,7 +9210,7 @@ var ts; if (accessor) { return accessor; } - if (token === 119) { + if (token === 121) { return parseConstructorDeclaration(fullStart, decorators, modifiers); } if (isIndexSignature()) { @@ -9029,23 +9224,23 @@ var ts; return parsePropertyOrMethodDeclaration(fullStart, decorators, modifiers); } if (decorators || modifiers) { - var name_7 = createMissingNode(67, true, ts.Diagnostics.Declaration_expected); + var name_7 = createMissingNode(69, true, ts.Diagnostics.Declaration_expected); return parsePropertyDeclaration(fullStart, decorators, modifiers, name_7, undefined); } ts.Debug.fail("Should not have attempted to parse class member declaration."); } function parseClassExpression() { - return parseClassDeclarationOrExpression(scanner.getStartPos(), undefined, undefined, 184); + return parseClassDeclarationOrExpression(scanner.getStartPos(), undefined, undefined, 186); } function parseClassDeclaration(fullStart, decorators, modifiers) { - return parseClassDeclarationOrExpression(fullStart, decorators, modifiers, 212); + return parseClassDeclarationOrExpression(fullStart, decorators, modifiers, 214); } function parseClassDeclarationOrExpression(fullStart, decorators, modifiers, kind) { var node = createNode(kind, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - parseExpected(71); - node.name = parseOptionalIdentifier(); + parseExpected(73); + node.name = parseNameOfClassDeclarationOrExpression(); node.typeParameters = parseTypeParameters(); node.heritageClauses = parseHeritageClauses(true); if (parseExpected(15)) { @@ -9057,6 +9252,14 @@ var ts; } return finishNode(node); } + function parseNameOfClassDeclarationOrExpression() { + return isIdentifier() && !isImplementsClause() + ? parseIdentifier() + : undefined; + } + function isImplementsClause() { + return token === 106 && lookAhead(nextTokenIsIdentifierOrKeyword); + } function parseHeritageClauses(isClassHeritageClause) { if (isHeritageClause()) { return parseList(20, parseHeritageClause); @@ -9067,8 +9270,8 @@ var ts; return parseList(20, parseHeritageClause); } function parseHeritageClause() { - if (token === 81 || token === 104) { - var node = createNode(241); + if (token === 83 || token === 106) { + var node = createNode(243); node.token = token; nextToken(); node.types = parseDelimitedList(7, parseExpressionWithTypeArguments); @@ -9077,7 +9280,7 @@ var ts; return undefined; } function parseExpressionWithTypeArguments() { - var node = createNode(186); + var node = createNode(188); node.expression = parseLeftHandSideExpressionOrHigher(); if (token === 25) { node.typeArguments = parseBracketedList(18, parseType, 25, 27); @@ -9085,16 +9288,16 @@ var ts; return finishNode(node); } function isHeritageClause() { - return token === 81 || token === 104; + return token === 83 || token === 106; } function parseClassMembers() { return parseList(5, parseClassElement); } function parseInterfaceDeclaration(fullStart, decorators, modifiers) { - var node = createNode(213, fullStart); + var node = createNode(215, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - parseExpected(105); + parseExpected(107); node.name = parseIdentifier(); node.typeParameters = parseTypeParameters(); node.heritageClauses = parseHeritageClauses(false); @@ -9102,28 +9305,28 @@ var ts; return finishNode(node); } function parseTypeAliasDeclaration(fullStart, decorators, modifiers) { - var node = createNode(214, fullStart); + var node = createNode(216, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - parseExpected(130); + parseExpected(132); node.name = parseIdentifier(); node.typeParameters = parseTypeParameters(); - parseExpected(55); + parseExpected(56); node.type = parseType(); parseSemicolon(); return finishNode(node); } function parseEnumMember() { - var node = createNode(245, scanner.getStartPos()); + var node = createNode(247, scanner.getStartPos()); node.name = parsePropertyName(); node.initializer = allowInAnd(parseNonParameterInitializer); return finishNode(node); } function parseEnumDeclaration(fullStart, decorators, modifiers) { - var node = createNode(215, fullStart); + var node = createNode(217, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - parseExpected(79); + parseExpected(81); node.name = parseIdentifier(); if (parseExpected(15)) { node.members = parseDelimitedList(6, parseEnumMember); @@ -9135,7 +9338,7 @@ var ts; return finishNode(node); } function parseModuleBlock() { - var node = createNode(217, scanner.getStartPos()); + var node = createNode(219, scanner.getStartPos()); if (parseExpected(15)) { node.statements = parseList(1, parseStatement); parseExpected(16); @@ -9146,7 +9349,7 @@ var ts; return finishNode(node); } function parseModuleOrNamespaceDeclaration(fullStart, decorators, modifiers, flags) { - var node = createNode(216, fullStart); + var node = createNode(218, fullStart); var namespaceFlag = flags & 131072; node.decorators = decorators; setModifiers(node, modifiers); @@ -9158,7 +9361,7 @@ var ts; return finishNode(node); } function parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers) { - var node = createNode(216, fullStart); + var node = createNode(218, fullStart); node.decorators = decorators; setModifiers(node, modifiers); node.name = parseLiteralNode(true); @@ -9167,11 +9370,11 @@ var ts; } function parseModuleDeclaration(fullStart, decorators, modifiers) { var flags = modifiers ? modifiers.flags : 0; - if (parseOptional(124)) { + if (parseOptional(126)) { flags |= 131072; } else { - parseExpected(123); + parseExpected(125); if (token === 9) { return parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers); } @@ -9179,58 +9382,58 @@ var ts; return parseModuleOrNamespaceDeclaration(fullStart, decorators, modifiers, flags); } function isExternalModuleReference() { - return token === 125 && + return token === 127 && lookAhead(nextTokenIsOpenParen); } function nextTokenIsOpenParen() { return nextToken() === 17; } function nextTokenIsSlash() { - return nextToken() === 38; + return nextToken() === 39; } function nextTokenIsCommaOrFromKeyword() { nextToken(); return token === 24 || - token === 131; + token === 133; } function parseImportDeclarationOrImportEqualsDeclaration(fullStart, decorators, modifiers) { - parseExpected(87); + parseExpected(89); var afterImportPos = scanner.getStartPos(); var identifier; if (isIdentifier()) { identifier = parseIdentifier(); - if (token !== 24 && token !== 131) { - var importEqualsDeclaration = createNode(219, fullStart); + if (token !== 24 && token !== 133) { + var importEqualsDeclaration = createNode(221, fullStart); importEqualsDeclaration.decorators = decorators; setModifiers(importEqualsDeclaration, modifiers); importEqualsDeclaration.name = identifier; - parseExpected(55); + parseExpected(56); importEqualsDeclaration.moduleReference = parseModuleReference(); parseSemicolon(); return finishNode(importEqualsDeclaration); } } - var importDeclaration = createNode(220, fullStart); + var importDeclaration = createNode(222, fullStart); importDeclaration.decorators = decorators; setModifiers(importDeclaration, modifiers); if (identifier || token === 37 || token === 15) { importDeclaration.importClause = parseImportClause(identifier, afterImportPos); - parseExpected(131); + parseExpected(133); } importDeclaration.moduleSpecifier = parseModuleSpecifier(); parseSemicolon(); return finishNode(importDeclaration); } function parseImportClause(identifier, fullStart) { - var importClause = createNode(221, fullStart); + var importClause = createNode(223, fullStart); if (identifier) { importClause.name = identifier; } if (!importClause.name || parseOptional(24)) { - importClause.namedBindings = token === 37 ? parseNamespaceImport() : parseNamedImportsOrExports(223); + importClause.namedBindings = token === 37 ? parseNamespaceImport() : parseNamedImportsOrExports(225); } return finishNode(importClause); } @@ -9240,8 +9443,8 @@ var ts; : parseEntityName(false); } function parseExternalModuleReference() { - var node = createNode(230); - parseExpected(125); + var node = createNode(232); + parseExpected(127); parseExpected(17); node.expression = parseModuleSpecifier(); parseExpected(18); @@ -9255,22 +9458,22 @@ var ts; return result; } function parseNamespaceImport() { - var namespaceImport = createNode(222); + var namespaceImport = createNode(224); parseExpected(37); - parseExpected(114); + parseExpected(116); namespaceImport.name = parseIdentifier(); return finishNode(namespaceImport); } function parseNamedImportsOrExports(kind) { var node = createNode(kind); - node.elements = parseBracketedList(21, kind === 223 ? parseImportSpecifier : parseExportSpecifier, 15, 16); + node.elements = parseBracketedList(21, kind === 225 ? parseImportSpecifier : parseExportSpecifier, 15, 16); return finishNode(node); } function parseExportSpecifier() { - return parseImportOrExportSpecifier(228); + return parseImportOrExportSpecifier(230); } function parseImportSpecifier() { - return parseImportOrExportSpecifier(224); + return parseImportOrExportSpecifier(226); } function parseImportOrExportSpecifier(kind) { var node = createNode(kind); @@ -9278,9 +9481,9 @@ var ts; var checkIdentifierStart = scanner.getTokenPos(); var checkIdentifierEnd = scanner.getTextPos(); var identifierName = parseIdentifierName(); - if (token === 114) { + if (token === 116) { node.propertyName = identifierName; - parseExpected(114); + parseExpected(116); checkIdentifierIsKeyword = ts.isKeyword(token) && !isIdentifier(); checkIdentifierStart = scanner.getTokenPos(); checkIdentifierEnd = scanner.getTextPos(); @@ -9289,23 +9492,23 @@ var ts; else { node.name = identifierName; } - if (kind === 224 && checkIdentifierIsKeyword) { + if (kind === 226 && checkIdentifierIsKeyword) { parseErrorAtPosition(checkIdentifierStart, checkIdentifierEnd - checkIdentifierStart, ts.Diagnostics.Identifier_expected); } return finishNode(node); } function parseExportDeclaration(fullStart, decorators, modifiers) { - var node = createNode(226, fullStart); + var node = createNode(228, fullStart); node.decorators = decorators; setModifiers(node, modifiers); if (parseOptional(37)) { - parseExpected(131); + parseExpected(133); node.moduleSpecifier = parseModuleSpecifier(); } else { - node.exportClause = parseNamedImportsOrExports(227); - if (token === 131 || (token === 9 && !scanner.hasPrecedingLineBreak())) { - parseExpected(131); + node.exportClause = parseNamedImportsOrExports(229); + if (token === 133 || (token === 9 && !scanner.hasPrecedingLineBreak())) { + parseExpected(133); node.moduleSpecifier = parseModuleSpecifier(); } } @@ -9313,14 +9516,14 @@ var ts; return finishNode(node); } function parseExportAssignment(fullStart, decorators, modifiers) { - var node = createNode(225, fullStart); + var node = createNode(227, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - if (parseOptional(55)) { + if (parseOptional(56)) { node.isExportEquals = true; } else { - parseExpected(75); + parseExpected(77); } node.expression = parseAssignmentExpressionOrHigher(); parseSemicolon(); @@ -9383,10 +9586,10 @@ var ts; function setExternalModuleIndicator(sourceFile) { sourceFile.externalModuleIndicator = ts.forEach(sourceFile.statements, function (node) { return node.flags & 1 - || node.kind === 219 && node.moduleReference.kind === 230 - || node.kind === 220 - || node.kind === 225 - || node.kind === 226 + || node.kind === 221 && node.moduleReference.kind === 232 + || node.kind === 222 + || node.kind === 227 + || node.kind === 228 ? node : undefined; }); @@ -9396,22 +9599,22 @@ var ts; function isJSDocType() { switch (token) { case 37: - case 52: + case 53: case 17: case 19: - case 48: + case 49: case 15: - case 85: + case 87: case 22: - case 90: - case 95: + case 92: + case 97: return true; } return ts.tokenIsIdentifierOrKeyword(token); } JSDocParser.isJSDocType = isJSDocType; function parseJSDocTypeExpressionForTests(content, start, length) { - initializeState("file.js", content, 2, undefined); + initializeState("file.js", content, 2, true, undefined); var jsDocTypeExpression = parseJSDocTypeExpression(start, length); var diagnostics = parseDiagnostics; clearState(); @@ -9421,7 +9624,7 @@ var ts; function parseJSDocTypeExpression(start, length) { scanner.setText(sourceText, start, length); token = nextToken(); - var result = createNode(247); + var result = createNode(249); parseExpected(15); result.type = parseJSDocTopLevelType(); parseExpected(16); @@ -9431,13 +9634,13 @@ var ts; JSDocParser.parseJSDocTypeExpression = parseJSDocTypeExpression; function parseJSDocTopLevelType() { var type = parseJSDocType(); - if (token === 46) { - var unionType = createNode(251, type.pos); + if (token === 47) { + var unionType = createNode(253, type.pos); unionType.types = parseJSDocTypeList(type); type = finishNode(unionType); } - if (token === 55) { - var optionalType = createNode(258, type.pos); + if (token === 56) { + var optionalType = createNode(260, type.pos); nextToken(); optionalType.type = type; type = finishNode(optionalType); @@ -9448,20 +9651,20 @@ var ts; var type = parseBasicTypeExpression(); while (true) { if (token === 19) { - var arrayType = createNode(250, type.pos); + var arrayType = createNode(252, type.pos); arrayType.elementType = type; nextToken(); parseExpected(20); type = finishNode(arrayType); } - else if (token === 52) { - var nullableType = createNode(253, type.pos); + else if (token === 53) { + var nullableType = createNode(255, type.pos); nullableType.type = type; nextToken(); type = finishNode(nullableType); } - else if (token === 48) { - var nonNullableType = createNode(254, type.pos); + else if (token === 49) { + var nonNullableType = createNode(256, type.pos); nonNullableType.type = type; nextToken(); type = finishNode(nonNullableType); @@ -9476,80 +9679,80 @@ var ts; switch (token) { case 37: return parseJSDocAllType(); - case 52: + case 53: return parseJSDocUnknownOrNullableType(); case 17: return parseJSDocUnionType(); case 19: return parseJSDocTupleType(); - case 48: + case 49: return parseJSDocNonNullableType(); case 15: return parseJSDocRecordType(); - case 85: + case 87: return parseJSDocFunctionType(); case 22: return parseJSDocVariadicType(); - case 90: + case 92: return parseJSDocConstructorType(); - case 95: + case 97: return parseJSDocThisType(); - case 115: + case 117: + case 130: case 128: - case 126: - case 118: - case 129: - case 101: + case 120: + case 131: + case 103: return parseTokenNode(); } return parseJSDocTypeReference(); } function parseJSDocThisType() { - var result = createNode(262); + var result = createNode(264); nextToken(); - parseExpected(53); + parseExpected(54); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocConstructorType() { - var result = createNode(261); + var result = createNode(263); nextToken(); - parseExpected(53); + parseExpected(54); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocVariadicType() { - var result = createNode(260); + var result = createNode(262); nextToken(); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocFunctionType() { - var result = createNode(259); + var result = createNode(261); nextToken(); parseExpected(17); result.parameters = parseDelimitedList(22, parseJSDocParameter); checkForTrailingComma(result.parameters); parseExpected(18); - if (token === 53) { + if (token === 54) { nextToken(); result.type = parseJSDocType(); } return finishNode(result); } function parseJSDocParameter() { - var parameter = createNode(136); + var parameter = createNode(138); parameter.type = parseJSDocType(); return finishNode(parameter); } function parseJSDocOptionalType(type) { - var result = createNode(258, type.pos); + var result = createNode(260, type.pos); nextToken(); result.type = type; return finishNode(result); } function parseJSDocTypeReference() { - var result = createNode(257); + var result = createNode(259); result.name = parseSimplePropertyName(); while (parseOptional(21)) { if (token === 25) { @@ -9578,13 +9781,13 @@ var ts; } } function parseQualifiedName(left) { - var result = createNode(133, left.pos); + var result = createNode(135, left.pos); result.left = left; result.right = parseIdentifierName(); return finishNode(result); } function parseJSDocRecordType() { - var result = createNode(255); + var result = createNode(257); nextToken(); result.members = parseDelimitedList(24, parseJSDocRecordMember); checkForTrailingComma(result.members); @@ -9592,22 +9795,22 @@ var ts; return finishNode(result); } function parseJSDocRecordMember() { - var result = createNode(256); + var result = createNode(258); result.name = parseSimplePropertyName(); - if (token === 53) { + if (token === 54) { nextToken(); result.type = parseJSDocType(); } return finishNode(result); } function parseJSDocNonNullableType() { - var result = createNode(254); + var result = createNode(256); nextToken(); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocTupleType() { - var result = createNode(252); + var result = createNode(254); nextToken(); result.types = parseDelimitedList(25, parseJSDocType); checkForTrailingComma(result.types); @@ -9621,7 +9824,7 @@ var ts; } } function parseJSDocUnionType() { - var result = createNode(251); + var result = createNode(253); nextToken(); result.types = parseJSDocTypeList(parseJSDocType()); parseExpected(18); @@ -9632,14 +9835,14 @@ var ts; var types = []; types.pos = firstType.pos; types.push(firstType); - while (parseOptional(46)) { + while (parseOptional(47)) { types.push(parseJSDocType()); } types.end = scanner.getStartPos(); return types; } function parseJSDocAllType() { - var result = createNode(248); + var result = createNode(250); nextToken(); return finishNode(result); } @@ -9650,19 +9853,19 @@ var ts; token === 16 || token === 18 || token === 27 || - token === 55 || - token === 46) { - var result = createNode(249, pos); + token === 56 || + token === 47) { + var result = createNode(251, pos); return finishNode(result); } else { - var result = createNode(253, pos); + var result = createNode(255, pos); result.type = parseJSDocType(); return finishNode(result); } } function parseIsolatedJSDocComment(content, start, length) { - initializeState("file.js", content, 2, undefined); + initializeState("file.js", content, 2, true, undefined); var jsDocComment = parseJSDocComment(undefined, start, length); var diagnostics = parseDiagnostics; clearState(); @@ -9727,7 +9930,7 @@ var ts; if (!tags) { return undefined; } - var result = createNode(263, start); + var result = createNode(265, start); result.tags = tags; return finishNode(result, end); } @@ -9738,7 +9941,7 @@ var ts; } function parseTag() { ts.Debug.assert(content.charCodeAt(pos - 1) === 64); - var atToken = createNode(54, pos - 1); + var atToken = createNode(55, pos - 1); atToken.end = pos; var tagName = scanIdentifier(); if (!tagName) { @@ -9764,7 +9967,7 @@ var ts; return undefined; } function handleUnknownTag(atToken, tagName) { - var result = createNode(264, atToken.pos); + var result = createNode(266, atToken.pos); result.atToken = atToken; result.tagName = tagName; return finishNode(result, pos); @@ -9815,7 +10018,7 @@ var ts; if (!typeExpression) { typeExpression = tryParseTypeExpression(); } - var result = createNode(265, atToken.pos); + var result = createNode(267, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.preParameterName = preName; @@ -9825,27 +10028,27 @@ var ts; return finishNode(result, pos); } function handleReturnTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 266; })) { + if (ts.forEach(tags, function (t) { return t.kind === 268; })) { parseErrorAtPosition(tagName.pos, pos - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); } - var result = createNode(266, atToken.pos); + var result = createNode(268, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeExpression = tryParseTypeExpression(); return finishNode(result, pos); } function handleTypeTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 267; })) { + if (ts.forEach(tags, function (t) { return t.kind === 269; })) { parseErrorAtPosition(tagName.pos, pos - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); } - var result = createNode(267, atToken.pos); + var result = createNode(269, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeExpression = tryParseTypeExpression(); return finishNode(result, pos); } function handleTemplateTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 268; })) { + if (ts.forEach(tags, function (t) { return t.kind === 270; })) { parseErrorAtPosition(tagName.pos, pos - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); } var typeParameters = []; @@ -9858,7 +10061,7 @@ var ts; parseErrorAtPosition(startPos, 0, ts.Diagnostics.Identifier_expected); return undefined; } - var typeParameter = createNode(135, name_8.pos); + var typeParameter = createNode(137, name_8.pos); typeParameter.name = name_8; finishNode(typeParameter, pos); typeParameters.push(typeParameter); @@ -9869,7 +10072,7 @@ var ts; pos++; } typeParameters.end = pos; - var result = createNode(268, atToken.pos); + var result = createNode(270, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeParameters = typeParameters; @@ -9890,7 +10093,7 @@ var ts; if (startPos === pos) { return undefined; } - var result = createNode(67, startPos); + var result = createNode(69, startPos); result.text = content.substring(startPos, pos); return finishNode(result, pos); } @@ -9966,7 +10169,7 @@ var ts; switch (node.kind) { case 9: case 8: - case 67: + case 69: return true; } return false; @@ -10205,17 +10408,19 @@ var ts; var Type = ts.objectAllocator.getTypeConstructor(); var Signature = ts.objectAllocator.getSignatureConstructor(); var typeCount = 0; + var symbolCount = 0; var emptyArray = []; var emptySymbols = {}; var compilerOptions = host.getCompilerOptions(); var languageVersion = compilerOptions.target || 0; + var modulekind = compilerOptions.module ? compilerOptions.module : languageVersion === 2 ? 5 : 0; var emitResolver = createResolver(); var undefinedSymbol = createSymbol(4 | 67108864, "undefined"); var argumentsSymbol = createSymbol(4 | 67108864, "arguments"); var checker = { getNodeCount: function () { return ts.sum(host.getSourceFiles(), "nodeCount"); }, getIdentifierCount: function () { return ts.sum(host.getSourceFiles(), "identifierCount"); }, - getSymbolCount: function () { return ts.sum(host.getSourceFiles(), "symbolCount"); }, + getSymbolCount: function () { return ts.sum(host.getSourceFiles(), "symbolCount") + symbolCount; }, getTypeCount: function () { return typeCount; }, isUndefinedSymbol: function (symbol) { return symbol === undefinedSymbol; }, isArgumentsSymbol: function (symbol) { return symbol === argumentsSymbol; }, @@ -10301,6 +10506,7 @@ var ts; var getInstantiatedGlobalPromiseLikeType; var getGlobalPromiseConstructorLikeType; var getGlobalThenableType; + var cjsRequireType; var tupleTypes = {}; var unionTypes = {}; var intersectionTypes = {}; @@ -10361,6 +10567,7 @@ var ts; diagnostics.add(diagnostic); } function createSymbol(flags, name) { + symbolCount++; return new Symbol(flags, name); } function getExcludedSymbolFlags(flags) { @@ -10489,10 +10696,10 @@ var ts; return nodeLinks[nodeId] || (nodeLinks[nodeId] = {}); } function getSourceFile(node) { - return ts.getAncestor(node, 246); + return ts.getAncestor(node, 248); } function isGlobalSourceFile(node) { - return node.kind === 246 && !ts.isExternalModule(node); + return node.kind === 248 && !ts.isExternalOrCommonJsModule(node); } function getSymbol(symbols, name, meaning) { if (meaning && ts.hasProperty(symbols, name)) { @@ -10509,17 +10716,54 @@ var ts; } } } - function isDefinedBefore(node1, node2) { - var file1 = ts.getSourceFileOfNode(node1); - var file2 = ts.getSourceFileOfNode(node2); - if (file1 === file2) { - return node1.pos <= node2.pos; + function isBlockScopedNameDeclaredBeforeUse(declaration, usage) { + var declarationFile = ts.getSourceFileOfNode(declaration); + var useFile = ts.getSourceFileOfNode(usage); + if (declarationFile !== useFile) { + if (modulekind || (!compilerOptions.outFile && !compilerOptions.out)) { + return true; + } + var sourceFiles = host.getSourceFiles(); + return ts.indexOf(sourceFiles, declarationFile) <= ts.indexOf(sourceFiles, useFile); } - if (!compilerOptions.outFile && !compilerOptions.out) { - return true; + if (declaration.pos <= usage.pos) { + return declaration.kind !== 211 || + !isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage); + } + return isUsedInFunctionOrNonStaticProperty(declaration, usage); + function isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage) { + var container = ts.getEnclosingBlockScopeContainer(declaration); + if (declaration.parent.parent.kind === 193 || + declaration.parent.parent.kind === 199) { + return isSameScopeDescendentOf(usage, declaration, container); + } + else if (declaration.parent.parent.kind === 201 || + declaration.parent.parent.kind === 200) { + var expression = declaration.parent.parent.expression; + return isSameScopeDescendentOf(usage, expression, container); + } + } + function isUsedInFunctionOrNonStaticProperty(declaration, usage) { + var container = ts.getEnclosingBlockScopeContainer(declaration); + var current = usage; + while (current) { + if (current === container) { + return false; + } + if (ts.isFunctionLike(current)) { + return true; + } + var initializerOfNonStaticProperty = current.parent && + current.parent.kind === 141 && + (current.parent.flags & 128) === 0 && + current.parent.initializer === current; + if (initializerOfNonStaticProperty) { + return true; + } + current = current.parent; + } + return false; } - var sourceFiles = host.getSourceFiles(); - return sourceFiles.indexOf(file1) <= sourceFiles.indexOf(file2); } function resolveName(location, name, meaning, nameNotFoundMessage, nameArg) { var result; @@ -10540,16 +10784,16 @@ var ts; } } switch (location.kind) { - case 246: - if (!ts.isExternalModule(location)) + case 248: + if (!ts.isExternalOrCommonJsModule(location)) break; - case 216: + case 218: var moduleExports = getSymbolOfNode(location).exports; - if (location.kind === 246 || - (location.kind === 216 && location.name.kind === 9)) { + if (location.kind === 248 || + (location.kind === 218 && location.name.kind === 9)) { if (ts.hasProperty(moduleExports, name) && moduleExports[name].flags === 8388608 && - ts.getDeclarationOfKind(moduleExports[name], 228)) { + ts.getDeclarationOfKind(moduleExports[name], 230)) { break; } result = moduleExports["default"]; @@ -10563,13 +10807,13 @@ var ts; break loop; } break; - case 215: + case 217: if (result = getSymbol(getSymbolOfNode(location).exports, name, meaning & 8)) { break loop; } break; - case 139: - case 138: + case 141: + case 140: if (ts.isClassLike(location.parent) && !(location.flags & 128)) { var ctor = findConstructorDeclaration(location.parent); if (ctor && ctor.locals) { @@ -10579,9 +10823,9 @@ var ts; } } break; - case 212: - case 184: - case 213: + case 214: + case 186: + case 215: if (result = getSymbol(getSymbolOfNode(location).members, name, meaning & 793056)) { if (lastLocation && lastLocation.flags & 128) { error(errorLocation, ts.Diagnostics.Static_members_cannot_reference_class_type_parameters); @@ -10589,7 +10833,7 @@ var ts; } break loop; } - if (location.kind === 184 && meaning & 32) { + if (location.kind === 186 && meaning & 32) { var className = location.name; if (className && name === className.text) { result = location.symbol; @@ -10597,28 +10841,28 @@ var ts; } } break; - case 134: + case 136: grandparent = location.parent.parent; - if (ts.isClassLike(grandparent) || grandparent.kind === 213) { + if (ts.isClassLike(grandparent) || grandparent.kind === 215) { if (result = getSymbol(getSymbolOfNode(grandparent).members, name, meaning & 793056)) { error(errorLocation, ts.Diagnostics.A_computed_property_name_cannot_reference_a_type_parameter_from_its_containing_type); return undefined; } } break; - case 141: - case 140: - case 142: case 143: + case 142: case 144: - case 211: - case 172: + case 145: + case 146: + case 213: + case 174: if (meaning & 3 && name === "arguments") { result = argumentsSymbol; break loop; } break; - case 171: + case 173: if (meaning & 3 && name === "arguments") { result = argumentsSymbol; break loop; @@ -10631,8 +10875,8 @@ var ts; } } break; - case 137: - if (location.parent && location.parent.kind === 136) { + case 139: + if (location.parent && location.parent.kind === 138) { location = location.parent; } if (location.parent && ts.isClassElement(location.parent)) { @@ -10658,8 +10902,11 @@ var ts; error(errorLocation, ts.Diagnostics.Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor, ts.declarationNameToString(propertyName), typeof nameArg === "string" ? nameArg : ts.declarationNameToString(nameArg)); return undefined; } - if (meaning & 2 && result.flags & 2) { - checkResolvedBlockScopedVariable(result, errorLocation); + if (meaning & 2) { + var exportOrLocalSymbol = getExportSymbolOfValueSymbolIfExported(result); + if (exportOrLocalSymbol.flags & 2) { + checkResolvedBlockScopedVariable(exportOrLocalSymbol, errorLocation); + } } } return result; @@ -10668,21 +10915,7 @@ var ts; ts.Debug.assert((result.flags & 2) !== 0); var declaration = ts.forEach(result.declarations, function (d) { return ts.isBlockOrCatchScoped(d) ? d : undefined; }); ts.Debug.assert(declaration !== undefined, "Block-scoped variable declaration is undefined"); - var isUsedBeforeDeclaration = !isDefinedBefore(declaration, errorLocation); - if (!isUsedBeforeDeclaration) { - var variableDeclaration = ts.getAncestor(declaration, 209); - var container = ts.getEnclosingBlockScopeContainer(variableDeclaration); - if (variableDeclaration.parent.parent.kind === 191 || - variableDeclaration.parent.parent.kind === 197) { - isUsedBeforeDeclaration = isSameScopeDescendentOf(errorLocation, variableDeclaration, container); - } - else if (variableDeclaration.parent.parent.kind === 199 || - variableDeclaration.parent.parent.kind === 198) { - var expression = variableDeclaration.parent.parent.expression; - isUsedBeforeDeclaration = isSameScopeDescendentOf(errorLocation, expression, container); - } - } - if (isUsedBeforeDeclaration) { + if (!isBlockScopedNameDeclaredBeforeUse(ts.getAncestor(declaration, 211), errorLocation)) { error(errorLocation, ts.Diagnostics.Block_scoped_variable_0_used_before_its_declaration, ts.declarationNameToString(declaration.name)); } } @@ -10699,10 +10932,10 @@ var ts; } function getAnyImportSyntax(node) { if (ts.isAliasSymbolDeclaration(node)) { - if (node.kind === 219) { + if (node.kind === 221) { return node; } - while (node && node.kind !== 220) { + while (node && node.kind !== 222) { node = node.parent; } return node; @@ -10712,7 +10945,7 @@ var ts; return ts.forEach(symbol.declarations, function (d) { return ts.isAliasSymbolDeclaration(d) ? d : undefined; }); } function getTargetOfImportEqualsDeclaration(node) { - if (node.moduleReference.kind === 230) { + if (node.moduleReference.kind === 232) { return resolveExternalModuleSymbol(resolveExternalModuleName(node, ts.getExternalModuleImportEqualsDeclarationExpression(node))); } return getSymbolOfPartOfRightHandSideOfImportEquals(node.moduleReference, node); @@ -10801,17 +11034,17 @@ var ts; } function getTargetOfAliasDeclaration(node) { switch (node.kind) { - case 219: - return getTargetOfImportEqualsDeclaration(node); case 221: + return getTargetOfImportEqualsDeclaration(node); + case 223: return getTargetOfImportClause(node); - case 222: - return getTargetOfNamespaceImport(node); case 224: + return getTargetOfNamespaceImport(node); + case 226: return getTargetOfImportSpecifier(node); - case 228: + case 230: return getTargetOfExportSpecifier(node); - case 225: + case 227: return getTargetOfExportAssignment(node); } } @@ -10853,10 +11086,10 @@ var ts; if (!links.referenced) { links.referenced = true; var node = getDeclarationOfAliasSymbol(symbol); - if (node.kind === 225) { + if (node.kind === 227) { checkExpressionCached(node.expression); } - else if (node.kind === 228) { + else if (node.kind === 230) { checkExpressionCached(node.propertyName || node.name); } else if (ts.isInternalModuleImportEqualsDeclaration(node)) { @@ -10866,17 +11099,17 @@ var ts; } function getSymbolOfPartOfRightHandSideOfImportEquals(entityName, importDeclaration) { if (!importDeclaration) { - importDeclaration = ts.getAncestor(entityName, 219); + importDeclaration = ts.getAncestor(entityName, 221); ts.Debug.assert(importDeclaration !== undefined); } - if (entityName.kind === 67 && ts.isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { + if (entityName.kind === 69 && ts.isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { entityName = entityName.parent; } - if (entityName.kind === 67 || entityName.parent.kind === 133) { + if (entityName.kind === 69 || entityName.parent.kind === 135) { return resolveEntityName(entityName, 1536); } else { - ts.Debug.assert(entityName.parent.kind === 219); + ts.Debug.assert(entityName.parent.kind === 221); return resolveEntityName(entityName, 107455 | 793056 | 1536); } } @@ -10888,16 +11121,16 @@ var ts; return undefined; } var symbol; - if (name.kind === 67) { + if (name.kind === 69) { var message = meaning === 1536 ? ts.Diagnostics.Cannot_find_namespace_0 : ts.Diagnostics.Cannot_find_name_0; symbol = resolveName(name, name.text, meaning, ignoreErrors ? undefined : message, name); if (!symbol) { return undefined; } } - else if (name.kind === 133 || name.kind === 164) { - var left = name.kind === 133 ? name.left : name.expression; - var right = name.kind === 133 ? name.right : name.name; + else if (name.kind === 135 || name.kind === 166) { + var left = name.kind === 135 ? name.left : name.expression; + var right = name.kind === 135 ? name.right : name.name; var namespace = resolveEntityName(left, 1536, ignoreErrors); if (!namespace || namespace === unknownSymbol || ts.nodeIsMissing(right)) { return undefined; @@ -10916,9 +11149,6 @@ var ts; ts.Debug.assert((symbol.flags & 16777216) === 0, "Should never get an instantiated symbol here."); return symbol.flags & meaning ? symbol : resolveAlias(symbol); } - function isExternalModuleNameRelative(moduleName) { - return moduleName.substr(0, 2) === "./" || moduleName.substr(0, 3) === "../" || moduleName.substr(0, 2) === ".\\" || moduleName.substr(0, 3) === "..\\"; - } function resolveExternalModuleName(location, moduleReferenceExpression) { if (moduleReferenceExpression.kind !== 9) { return; @@ -10929,7 +11159,10 @@ var ts; if (moduleName === undefined) { return; } - var isRelative = isExternalModuleNameRelative(moduleName); + if (moduleName.indexOf("!") >= 0) { + moduleName = moduleName.substr(0, moduleName.indexOf("!")); + } + var isRelative = ts.isExternalModuleNameRelative(moduleName); if (!isRelative) { var symbol = getSymbol(globals, "\"" + moduleName + "\"", 512); if (symbol) { @@ -11033,7 +11266,7 @@ var ts; var members = node.members; for (var _i = 0; _i < members.length; _i++) { var member = members[_i]; - if (member.kind === 142 && ts.nodeIsPresent(member.body)) { + if (member.kind === 144 && ts.nodeIsPresent(member.body)) { return member; } } @@ -11098,17 +11331,17 @@ var ts; } } switch (location_1.kind) { - case 246: - if (!ts.isExternalModule(location_1)) { + case 248: + if (!ts.isExternalOrCommonJsModule(location_1)) { break; } - case 216: + case 218: if (result = callback(getSymbolOfNode(location_1).exports)) { return result; } break; - case 212: - case 213: + case 214: + case 215: if (result = callback(getSymbolOfNode(location_1).members)) { return result; } @@ -11141,7 +11374,7 @@ var ts; return ts.forEachValue(symbols, function (symbolFromSymbolTable) { if (symbolFromSymbolTable.flags & 8388608 && symbolFromSymbolTable.name !== "export=" - && !ts.getDeclarationOfKind(symbolFromSymbolTable, 228)) { + && !ts.getDeclarationOfKind(symbolFromSymbolTable, 230)) { if (!useOnlyExternalAliasing || ts.forEach(symbolFromSymbolTable.declarations, ts.isExternalModuleImportEqualsDeclaration)) { var resolvedImportedSymbol = resolveAlias(symbolFromSymbolTable); @@ -11170,7 +11403,7 @@ var ts; if (symbolFromSymbolTable === symbol) { return true; } - symbolFromSymbolTable = (symbolFromSymbolTable.flags & 8388608 && !ts.getDeclarationOfKind(symbolFromSymbolTable, 228)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; + symbolFromSymbolTable = (symbolFromSymbolTable.flags & 8388608 && !ts.getDeclarationOfKind(symbolFromSymbolTable, 230)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; if (symbolFromSymbolTable.flags & meaning) { qualify = true; return true; @@ -11225,8 +11458,8 @@ var ts; } } function hasExternalModuleSymbol(declaration) { - return (declaration.kind === 216 && declaration.name.kind === 9) || - (declaration.kind === 246 && ts.isExternalModule(declaration)); + return (declaration.kind === 218 && declaration.name.kind === 9) || + (declaration.kind === 248 && ts.isExternalOrCommonJsModule(declaration)); } function hasVisibleDeclarations(symbol) { var aliasesToMakeVisible; @@ -11258,11 +11491,11 @@ var ts; } function isEntityNameVisible(entityName, enclosingDeclaration) { var meaning; - if (entityName.parent.kind === 152) { + if (entityName.parent.kind === 154) { meaning = 107455 | 1048576; } - else if (entityName.kind === 133 || entityName.kind === 164 || - entityName.parent.kind === 219) { + else if (entityName.kind === 135 || entityName.kind === 166 || + entityName.parent.kind === 221) { meaning = 1536; } else { @@ -11313,10 +11546,10 @@ var ts; function getTypeAliasForTypeLiteral(type) { if (type.symbol && type.symbol.flags & 2048) { var node = type.symbol.declarations[0].parent; - while (node.kind === 158) { + while (node.kind === 160) { node = node.parent; } - if (node.kind === 214) { + if (node.kind === 216) { return getSymbolOfNode(node); } } @@ -11330,10 +11563,10 @@ var ts; return ts.declarationNameToString(declaration.name); } switch (declaration.kind) { - case 184: + case 186: return "(Anonymous class)"; - case 171: - case 172: + case 173: + case 174: return "(Anonymous function)"; } } @@ -11394,6 +11627,7 @@ var ts; } function buildTypeDisplay(type, writer, enclosingDeclaration, globalFlags, symbolStack) { var globalFlagsToPass = globalFlags & 16; + var inObjectTypeLiteral = false; return writeType(type, globalFlags); function writeType(type, flags) { if (type.flags & 16777343) { @@ -11401,6 +11635,12 @@ var ts; ? "any" : type.intrinsicName); } + else if (type.flags & 33554432) { + if (inObjectTypeLiteral) { + writer.reportInaccessibleThisError(); + } + writer.writeKeyword("this"); + } else if (type.flags & 4096) { writeTypeReference(type, flags); } @@ -11439,9 +11679,9 @@ var ts; writeType(types[i], delimiter === 24 ? 0 : 64); } } - function writeSymbolTypeReference(symbol, typeArguments, pos, end) { - if (!isReservedMemberName(symbol.name)) { - buildSymbolDisplay(symbol, writer, enclosingDeclaration, 793056); + function writeSymbolTypeReference(symbol, typeArguments, pos, end, flags) { + if (symbol.flags & 32 || !isReservedMemberName(symbol.name)) { + buildSymbolDisplay(symbol, writer, enclosingDeclaration, 793056, 0, flags); } if (pos < end) { writePunctuation(writer, 25); @@ -11455,7 +11695,7 @@ var ts; } } function writeTypeReference(type, flags) { - var typeArguments = type.typeArguments; + var typeArguments = type.typeArguments || emptyArray; if (type.target === globalArrayType && !(flags & 1)) { writeType(typeArguments[0], 64); writePunctuation(writer, 19); @@ -11473,12 +11713,13 @@ var ts; i++; } while (i < length_1 && getParentSymbolOfTypeParameter(outerTypeParameters[i]) === parent_3); if (!ts.rangeEquals(outerTypeParameters, typeArguments, start, i)) { - writeSymbolTypeReference(parent_3, typeArguments, start, i); + writeSymbolTypeReference(parent_3, typeArguments, start, i, flags); writePunctuation(writer, 21); } } } - writeSymbolTypeReference(type.symbol, typeArguments, i, typeArguments.length); + var typeParameterCount = (type.target.typeParameters || emptyArray).length; + writeSymbolTypeReference(type.symbol, typeArguments, i, typeParameterCount, flags); } } function writeTupleType(type) { @@ -11490,7 +11731,7 @@ var ts; if (flags & 64) { writePunctuation(writer, 17); } - writeTypeList(type.types, type.flags & 16384 ? 46 : 45); + writeTypeList(type.types, type.flags & 16384 ? 47 : 46); if (flags & 64) { writePunctuation(writer, 18); } @@ -11510,7 +11751,7 @@ var ts; buildSymbolDisplay(typeAlias, writer, enclosingDeclaration, 793056, 0, flags); } else { - writeKeyword(writer, 115); + writeKeyword(writer, 117); } } else { @@ -11531,7 +11772,7 @@ var ts; var isNonLocalFunctionSymbol = !!(symbol.flags & 16) && (symbol.parent || ts.forEach(symbol.declarations, function (declaration) { - return declaration.parent.kind === 246 || declaration.parent.kind === 217; + return declaration.parent.kind === 248 || declaration.parent.kind === 219; })); if (isStaticMethodSymbol || isNonLocalFunctionSymbol) { return !!(flags & 2) || @@ -11540,7 +11781,7 @@ var ts; } } function writeTypeofSymbol(type, typeFormatFlags) { - writeKeyword(writer, 99); + writeKeyword(writer, 101); writeSpace(writer); buildSymbolDisplay(type.symbol, writer, enclosingDeclaration, 107455, 0, typeFormatFlags); } @@ -11574,7 +11815,7 @@ var ts; if (flags & 64) { writePunctuation(writer, 17); } - writeKeyword(writer, 90); + writeKeyword(writer, 92); writeSpace(writer); buildSignatureDisplay(resolved.constructSignatures[0], writer, enclosingDeclaration, globalFlagsToPass | 8, symbolStack); if (flags & 64) { @@ -11583,6 +11824,8 @@ var ts; return; } } + var saveInObjectTypeLiteral = inObjectTypeLiteral; + inObjectTypeLiteral = true; writePunctuation(writer, 15); writer.writeLine(); writer.increaseIndent(); @@ -11594,7 +11837,7 @@ var ts; } for (var _b = 0, _c = resolved.constructSignatures; _b < _c.length; _b++) { var signature = _c[_b]; - writeKeyword(writer, 90); + writeKeyword(writer, 92); writeSpace(writer); buildSignatureDisplay(signature, writer, enclosingDeclaration, globalFlagsToPass, symbolStack); writePunctuation(writer, 23); @@ -11603,11 +11846,11 @@ var ts; if (resolved.stringIndexType) { writePunctuation(writer, 19); writer.writeParameter(getIndexerParameterName(resolved, 0, "x")); - writePunctuation(writer, 53); + writePunctuation(writer, 54); writeSpace(writer); - writeKeyword(writer, 128); + writeKeyword(writer, 130); writePunctuation(writer, 20); - writePunctuation(writer, 53); + writePunctuation(writer, 54); writeSpace(writer); writeType(resolved.stringIndexType, 0); writePunctuation(writer, 23); @@ -11616,11 +11859,11 @@ var ts; if (resolved.numberIndexType) { writePunctuation(writer, 19); writer.writeParameter(getIndexerParameterName(resolved, 1, "x")); - writePunctuation(writer, 53); + writePunctuation(writer, 54); writeSpace(writer); - writeKeyword(writer, 126); + writeKeyword(writer, 128); writePunctuation(writer, 20); - writePunctuation(writer, 53); + writePunctuation(writer, 54); writeSpace(writer); writeType(resolved.numberIndexType, 0); writePunctuation(writer, 23); @@ -11635,7 +11878,7 @@ var ts; var signature = signatures[_f]; buildSymbolDisplay(p, writer); if (p.flags & 536870912) { - writePunctuation(writer, 52); + writePunctuation(writer, 53); } buildSignatureDisplay(signature, writer, enclosingDeclaration, globalFlagsToPass, symbolStack); writePunctuation(writer, 23); @@ -11645,9 +11888,9 @@ var ts; else { buildSymbolDisplay(p, writer); if (p.flags & 536870912) { - writePunctuation(writer, 52); + writePunctuation(writer, 53); } - writePunctuation(writer, 53); + writePunctuation(writer, 54); writeSpace(writer); writeType(t, 0); writePunctuation(writer, 23); @@ -11656,6 +11899,7 @@ var ts; } writer.decreaseIndent(); writePunctuation(writer, 16); + inObjectTypeLiteral = saveInObjectTypeLiteral; } } function buildTypeParameterDisplayFromSymbol(symbol, writer, enclosingDeclaraiton, flags) { @@ -11669,7 +11913,7 @@ var ts; var constraint = getConstraintOfTypeParameter(tp); if (constraint) { writeSpace(writer); - writeKeyword(writer, 81); + writeKeyword(writer, 83); writeSpace(writer); buildTypeDisplay(constraint, writer, enclosingDeclaration, flags, symbolStack); } @@ -11681,9 +11925,9 @@ var ts; } appendSymbolNameOnly(p, writer); if (isOptionalParameter(parameterNode)) { - writePunctuation(writer, 52); + writePunctuation(writer, 53); } - writePunctuation(writer, 53); + writePunctuation(writer, 54); writeSpace(writer); buildTypeDisplay(getTypeOfSymbol(p), writer, enclosingDeclaration, flags, symbolStack); } @@ -11730,14 +11974,14 @@ var ts; writePunctuation(writer, 34); } else { - writePunctuation(writer, 53); + writePunctuation(writer, 54); } writeSpace(writer); var returnType; if (signature.typePredicate) { writer.writeParameter(signature.typePredicate.parameterName); writeSpace(writer); - writeKeyword(writer, 122); + writeKeyword(writer, 124); writeSpace(writer); returnType = signature.typePredicate.type; } @@ -11771,13 +12015,13 @@ var ts; function isDeclarationVisible(node) { function getContainingExternalModule(node) { for (; node; node = node.parent) { - if (node.kind === 216) { + if (node.kind === 218) { if (node.name.kind === 9) { return node; } } - else if (node.kind === 246) { - return ts.isExternalModule(node) ? node : undefined; + else if (node.kind === 248) { + return ts.isExternalOrCommonJsModule(node) ? node : undefined; } } ts.Debug.fail("getContainingModule cant reach here"); @@ -11819,59 +12063,59 @@ var ts; } function determineIfDeclarationIsVisible() { switch (node.kind) { - case 161: + case 163: return isDeclarationVisible(node.parent.parent); - case 209: + case 211: if (ts.isBindingPattern(node.name) && !node.name.elements.length) { return false; } - case 216: - case 212: - case 213: + case 218: case 214: - case 211: case 215: - case 219: + case 216: + case 213: + case 217: + case 221: var parent_4 = getDeclarationContainer(node); if (!(ts.getCombinedNodeFlags(node) & 1) && - !(node.kind !== 219 && parent_4.kind !== 246 && ts.isInAmbientContext(parent_4))) { + !(node.kind !== 221 && parent_4.kind !== 248 && ts.isInAmbientContext(parent_4))) { return isGlobalSourceFile(parent_4); } return isDeclarationVisible(parent_4); - case 139: - case 138: - case 143: - case 144: case 141: case 140: + case 145: + case 146: + case 143: + case 142: if (node.flags & (32 | 64)) { return false; } - case 142: - case 146: - case 145: + case 144: + case 148: case 147: - case 136: - case 217: - case 150: - case 151: - case 153: case 149: - case 154: + case 138: + case 219: + case 152: + case 153: case 155: + case 151: case 156: case 157: case 158: + case 159: + case 160: return isDeclarationVisible(node.parent); - case 221: - case 222: + case 223: case 224: + case 226: return false; - case 135: - case 246: + case 137: + case 248: return true; - case 225: + case 227: return false; default: ts.Debug.fail("isDeclarationVisible unknown: SyntaxKind: " + node.kind); @@ -11887,10 +12131,10 @@ var ts; } function collectLinkedAliases(node) { var exportSymbol; - if (node.parent && node.parent.kind === 225) { + if (node.parent && node.parent.kind === 227) { exportSymbol = resolveName(node.parent, node.text, 107455 | 793056 | 1536 | 8388608, ts.Diagnostics.Cannot_find_name_0, node); } - else if (node.parent.kind === 228) { + else if (node.parent.kind === 230) { var exportSpecifier = node.parent; exportSymbol = exportSpecifier.parent.parent.moduleSpecifier ? getExternalModuleMember(exportSpecifier.parent.parent, exportSpecifier) : @@ -11965,7 +12209,7 @@ var ts; } function getDeclarationContainer(node) { node = ts.getRootDeclaration(node); - return node.kind === 209 ? node.parent.parent.parent : node.parent; + return node.kind === 211 ? node.parent.parent.parent : node.parent; } function getTypeOfPrototypeProperty(prototype) { var classType = getDeclaredTypeOfSymbol(prototype.parent); @@ -11978,9 +12222,13 @@ var ts; function isTypeAny(type) { return type && (type.flags & 1) !== 0; } + function getTypeForBindingElementParent(node) { + var symbol = getSymbolOfNode(node); + return symbol && getSymbolLinks(symbol).type || getTypeForVariableLikeDeclaration(node); + } function getTypeForBindingElement(declaration) { var pattern = declaration.parent; - var parentType = getTypeForVariableLikeDeclaration(pattern.parent); + var parentType = getTypeForBindingElementParent(pattern.parent); if (parentType === unknownType) { return unknownType; } @@ -11991,7 +12239,7 @@ var ts; return parentType; } var type; - if (pattern.kind === 159) { + if (pattern.kind === 161) { var name_10 = declaration.propertyName || declaration.name; type = getTypeOfPropertyOfType(parentType, name_10.text) || isNumericLiteralName(name_10.text) && getIndexTypeOfType(parentType, 1) || @@ -12025,10 +12273,10 @@ var ts; return type; } function getTypeForVariableLikeDeclaration(declaration) { - if (declaration.parent.parent.kind === 198) { + if (declaration.parent.parent.kind === 200) { return anyType; } - if (declaration.parent.parent.kind === 199) { + if (declaration.parent.parent.kind === 201) { return checkRightHandSideOfForOf(declaration.parent.parent.expression) || anyType; } if (ts.isBindingPattern(declaration.parent)) { @@ -12037,10 +12285,10 @@ var ts; if (declaration.type) { return getTypeFromTypeNode(declaration.type); } - if (declaration.kind === 136) { + if (declaration.kind === 138) { var func = declaration.parent; - if (func.kind === 144 && !ts.hasDynamicName(func)) { - var getter = ts.getDeclarationOfKind(declaration.parent.symbol, 143); + if (func.kind === 146 && !ts.hasDynamicName(func)) { + var getter = ts.getDeclarationOfKind(declaration.parent.symbol, 145); if (getter) { return getReturnTypeOfSignature(getSignatureFromDeclaration(getter)); } @@ -12053,7 +12301,7 @@ var ts; if (declaration.initializer) { return checkExpressionCached(declaration.initializer); } - if (declaration.kind === 244) { + if (declaration.kind === 246) { return checkIdentifier(declaration.name); } if (ts.isBindingPattern(declaration.name)) { @@ -12091,7 +12339,7 @@ var ts; if (elements.length === 0 || elements[elements.length - 1].dotDotDotToken) { return languageVersion >= 2 ? createIterableType(anyType) : anyArrayType; } - var elementTypes = ts.map(elements, function (e) { return e.kind === 185 ? anyType : getTypeFromBindingElement(e, includePatternInType); }); + var elementTypes = ts.map(elements, function (e) { return e.kind === 187 ? anyType : getTypeFromBindingElement(e, includePatternInType); }); if (includePatternInType) { var result = createNewTupleType(elementTypes); result.pattern = pattern; @@ -12100,7 +12348,7 @@ var ts; return createTupleType(elementTypes); } function getTypeFromBindingPattern(pattern, includePatternInType) { - return pattern.kind === 159 + return pattern.kind === 161 ? getTypeFromObjectBindingPattern(pattern, includePatternInType) : getTypeFromArrayBindingPattern(pattern, includePatternInType); } @@ -12110,12 +12358,12 @@ var ts; if (reportErrors) { reportErrorsFromWidening(declaration, type); } - return declaration.kind !== 243 ? getWidenedType(type) : type; + return declaration.kind !== 245 ? getWidenedType(type) : type; } type = declaration.dotDotDotToken ? anyArrayType : anyType; if (reportErrors && compilerOptions.noImplicitAny) { var root = ts.getRootDeclaration(declaration); - if (!isPrivateWithinAmbient(root) && !(root.kind === 136 && isPrivateWithinAmbient(root.parent))) { + if (!isPrivateWithinAmbient(root) && !(root.kind === 138 && isPrivateWithinAmbient(root.parent))) { reportImplicitAnyError(declaration, type); } } @@ -12128,12 +12376,18 @@ var ts; return links.type = getTypeOfPrototypeProperty(symbol); } var declaration = symbol.valueDeclaration; - if (declaration.parent.kind === 242) { + if (declaration.parent.kind === 244) { return links.type = anyType; } - if (declaration.kind === 225) { + if (declaration.kind === 227) { return links.type = checkExpression(declaration.expression); } + if (declaration.kind === 181) { + return links.type = checkExpression(declaration.right); + } + if (declaration.kind === 166) { + return checkExpressionCached(declaration.parent.right); + } if (!pushTypeResolution(symbol, 0)) { return unknownType; } @@ -12156,7 +12410,7 @@ var ts; } function getAnnotatedAccessorType(accessor) { if (accessor) { - if (accessor.kind === 143) { + if (accessor.kind === 145) { return accessor.type && getTypeFromTypeNode(accessor.type); } else { @@ -12172,8 +12426,8 @@ var ts; if (!pushTypeResolution(symbol, 0)) { return unknownType; } - var getter = ts.getDeclarationOfKind(symbol, 143); - var setter = ts.getDeclarationOfKind(symbol, 144); + var getter = ts.getDeclarationOfKind(symbol, 145); + var setter = ts.getDeclarationOfKind(symbol, 146); var type; var getterReturnType = getAnnotatedAccessorType(getter); if (getterReturnType) { @@ -12199,7 +12453,7 @@ var ts; if (!popTypeResolution()) { type = anyType; if (compilerOptions.noImplicitAny) { - var getter_1 = ts.getDeclarationOfKind(symbol, 143); + var getter_1 = ts.getDeclarationOfKind(symbol, 145); error(getter_1, ts.Diagnostics._0_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions, symbolToString(symbol)); } } @@ -12288,9 +12542,9 @@ var ts; if (!node) { return typeParameters; } - if (node.kind === 212 || node.kind === 184 || - node.kind === 211 || node.kind === 171 || - node.kind === 141 || node.kind === 172) { + if (node.kind === 214 || node.kind === 186 || + node.kind === 213 || node.kind === 173 || + node.kind === 143 || node.kind === 174) { var declarations = node.typeParameters; if (declarations) { return appendTypeParameters(appendOuterTypeParameters(typeParameters, node), declarations); @@ -12299,15 +12553,15 @@ var ts; } } function getOuterTypeParametersOfClassOrInterface(symbol) { - var declaration = symbol.flags & 32 ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 213); + var declaration = symbol.flags & 32 ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 215); return appendOuterTypeParameters(undefined, declaration); } function getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol) { var result; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var node = _a[_i]; - if (node.kind === 213 || node.kind === 212 || - node.kind === 184 || node.kind === 214) { + if (node.kind === 215 || node.kind === 214 || + node.kind === 186 || node.kind === 216) { var declaration = node; if (declaration.typeParameters) { result = appendTypeParameters(result, declaration.typeParameters); @@ -12412,7 +12666,7 @@ var ts; type.resolvedBaseTypes = []; for (var _i = 0, _a = type.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 213 && ts.getInterfaceBaseTypeNodes(declaration)) { + if (declaration.kind === 215 && ts.getInterfaceBaseTypeNodes(declaration)) { for (var _b = 0, _c = ts.getInterfaceBaseTypeNodes(declaration); _b < _c.length; _b++) { var node = _c[_b]; var baseType = getTypeFromTypeNode(node); @@ -12433,6 +12687,29 @@ var ts; } } } + function isIndependentInterface(symbol) { + for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { + var declaration = _a[_i]; + if (declaration.kind === 215) { + if (declaration.flags & 524288) { + return false; + } + var baseTypeNodes = ts.getInterfaceBaseTypeNodes(declaration); + if (baseTypeNodes) { + for (var _b = 0; _b < baseTypeNodes.length; _b++) { + var node = baseTypeNodes[_b]; + if (ts.isSupportedExpressionWithTypeArguments(node)) { + var baseSymbol = resolveEntityName(node.expression, 793056, true); + if (!baseSymbol || !(baseSymbol.flags & 64) || getDeclaredTypeOfClassOrInterface(baseSymbol).thisType) { + return false; + } + } + } + } + } + } + return true; + } function getDeclaredTypeOfClassOrInterface(symbol) { var links = getSymbolLinks(symbol); if (!links.declaredType) { @@ -12440,7 +12717,7 @@ var ts; var type = links.declaredType = createObjectType(kind, symbol); var outerTypeParameters = getOuterTypeParametersOfClassOrInterface(symbol); var localTypeParameters = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol); - if (outerTypeParameters || localTypeParameters) { + if (outerTypeParameters || localTypeParameters || kind === 1024 || !isIndependentInterface(symbol)) { type.flags |= 4096; type.typeParameters = ts.concatenate(outerTypeParameters, localTypeParameters); type.outerTypeParameters = outerTypeParameters; @@ -12449,6 +12726,9 @@ var ts; type.instantiations[getTypeListId(type.typeParameters)] = type; type.target = type; type.typeArguments = type.typeParameters; + type.thisType = createType(512 | 33554432); + type.thisType.symbol = symbol; + type.thisType.constraint = getTypeWithThisArgument(type); } } return links.declaredType; @@ -12459,7 +12739,7 @@ var ts; if (!pushTypeResolution(symbol, 2)) { return unknownType; } - var declaration = ts.getDeclarationOfKind(symbol, 214); + var declaration = ts.getDeclarationOfKind(symbol, 216); var type = getTypeFromTypeNode(declaration.type); if (popTypeResolution()) { links.typeParameters = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol); @@ -12490,7 +12770,7 @@ var ts; if (!links.declaredType) { var type = createType(512); type.symbol = symbol; - if (!ts.getDeclarationOfKind(symbol, 135).constraint) { + if (!ts.getDeclarationOfKind(symbol, 137).constraint) { type.constraint = noConstraintType; } links.declaredType = type; @@ -12523,6 +12803,66 @@ var ts; } return unknownType; } + function isIndependentTypeReference(node) { + if (node.typeArguments) { + for (var _i = 0, _a = node.typeArguments; _i < _a.length; _i++) { + var typeNode = _a[_i]; + if (!isIndependentType(typeNode)) { + return false; + } + } + } + return true; + } + function isIndependentType(node) { + switch (node.kind) { + case 117: + case 130: + case 128: + case 120: + case 131: + case 103: + case 9: + return true; + case 156: + return isIndependentType(node.elementType); + case 151: + return isIndependentTypeReference(node); + } + return false; + } + function isIndependentVariableLikeDeclaration(node) { + return node.type && isIndependentType(node.type) || !node.type && !node.initializer; + } + function isIndependentFunctionLikeDeclaration(node) { + if (node.kind !== 144 && (!node.type || !isIndependentType(node.type))) { + return false; + } + for (var _i = 0, _a = node.parameters; _i < _a.length; _i++) { + var parameter = _a[_i]; + if (!isIndependentVariableLikeDeclaration(parameter)) { + return false; + } + } + return true; + } + function isIndependentMember(symbol) { + if (symbol.declarations && symbol.declarations.length === 1) { + var declaration = symbol.declarations[0]; + if (declaration) { + switch (declaration.kind) { + case 141: + case 140: + return isIndependentVariableLikeDeclaration(declaration); + case 143: + case 142: + case 144: + return isIndependentFunctionLikeDeclaration(declaration); + } + } + } + return false; + } function createSymbolTable(symbols) { var result = {}; for (var _i = 0; _i < symbols.length; _i++) { @@ -12531,11 +12871,11 @@ var ts; } return result; } - function createInstantiatedSymbolTable(symbols, mapper) { + function createInstantiatedSymbolTable(symbols, mapper, mappingThisOnly) { var result = {}; for (var _i = 0; _i < symbols.length; _i++) { var symbol = symbols[_i]; - result[symbol.name] = instantiateSymbol(symbol, mapper); + result[symbol.name] = mappingThisOnly && isIndependentMember(symbol) ? symbol : instantiateSymbol(symbol, mapper); } return result; } @@ -12566,44 +12906,54 @@ var ts; } return type; } - function resolveClassOrInterfaceMembers(type) { - var target = resolveDeclaredMembers(type); - var members = target.symbol.members; - var callSignatures = target.declaredCallSignatures; - var constructSignatures = target.declaredConstructSignatures; - var stringIndexType = target.declaredStringIndexType; - var numberIndexType = target.declaredNumberIndexType; - var baseTypes = getBaseTypes(target); + function getTypeWithThisArgument(type, thisArgument) { + if (type.flags & 4096) { + return createTypeReference(type.target, ts.concatenate(type.typeArguments, [thisArgument || type.target.thisType])); + } + return type; + } + function resolveObjectTypeMembers(type, source, typeParameters, typeArguments) { + var mapper = identityMapper; + var members = source.symbol.members; + var callSignatures = source.declaredCallSignatures; + var constructSignatures = source.declaredConstructSignatures; + var stringIndexType = source.declaredStringIndexType; + var numberIndexType = source.declaredNumberIndexType; + if (!ts.rangeEquals(typeParameters, typeArguments, 0, typeParameters.length)) { + mapper = createTypeMapper(typeParameters, typeArguments); + members = createInstantiatedSymbolTable(source.declaredProperties, mapper, typeParameters.length === 1); + callSignatures = instantiateList(source.declaredCallSignatures, mapper, instantiateSignature); + constructSignatures = instantiateList(source.declaredConstructSignatures, mapper, instantiateSignature); + stringIndexType = instantiateType(source.declaredStringIndexType, mapper); + numberIndexType = instantiateType(source.declaredNumberIndexType, mapper); + } + var baseTypes = getBaseTypes(source); if (baseTypes.length) { - members = createSymbolTable(target.declaredProperties); + if (members === source.symbol.members) { + members = createSymbolTable(source.declaredProperties); + } + var thisArgument = ts.lastOrUndefined(typeArguments); for (var _i = 0; _i < baseTypes.length; _i++) { var baseType = baseTypes[_i]; - addInheritedMembers(members, getPropertiesOfObjectType(baseType)); - callSignatures = ts.concatenate(callSignatures, getSignaturesOfType(baseType, 0)); - constructSignatures = ts.concatenate(constructSignatures, getSignaturesOfType(baseType, 1)); - stringIndexType = stringIndexType || getIndexTypeOfType(baseType, 0); - numberIndexType = numberIndexType || getIndexTypeOfType(baseType, 1); + var instantiatedBaseType = thisArgument ? getTypeWithThisArgument(instantiateType(baseType, mapper), thisArgument) : baseType; + addInheritedMembers(members, getPropertiesOfObjectType(instantiatedBaseType)); + callSignatures = ts.concatenate(callSignatures, getSignaturesOfType(instantiatedBaseType, 0)); + constructSignatures = ts.concatenate(constructSignatures, getSignaturesOfType(instantiatedBaseType, 1)); + stringIndexType = stringIndexType || getIndexTypeOfType(instantiatedBaseType, 0); + numberIndexType = numberIndexType || getIndexTypeOfType(instantiatedBaseType, 1); } } setObjectTypeMembers(type, members, callSignatures, constructSignatures, stringIndexType, numberIndexType); } + function resolveClassOrInterfaceMembers(type) { + resolveObjectTypeMembers(type, resolveDeclaredMembers(type), emptyArray, emptyArray); + } function resolveTypeReferenceMembers(type) { - var target = resolveDeclaredMembers(type.target); - var mapper = createTypeMapper(target.typeParameters, type.typeArguments); - var members = createInstantiatedSymbolTable(target.declaredProperties, mapper); - var callSignatures = instantiateList(target.declaredCallSignatures, mapper, instantiateSignature); - var constructSignatures = instantiateList(target.declaredConstructSignatures, mapper, instantiateSignature); - var stringIndexType = target.declaredStringIndexType ? instantiateType(target.declaredStringIndexType, mapper) : undefined; - var numberIndexType = target.declaredNumberIndexType ? instantiateType(target.declaredNumberIndexType, mapper) : undefined; - ts.forEach(getBaseTypes(target), function (baseType) { - var instantiatedBaseType = instantiateType(baseType, mapper); - addInheritedMembers(members, getPropertiesOfObjectType(instantiatedBaseType)); - callSignatures = ts.concatenate(callSignatures, getSignaturesOfType(instantiatedBaseType, 0)); - constructSignatures = ts.concatenate(constructSignatures, getSignaturesOfType(instantiatedBaseType, 1)); - stringIndexType = stringIndexType || getIndexTypeOfType(instantiatedBaseType, 0); - numberIndexType = numberIndexType || getIndexTypeOfType(instantiatedBaseType, 1); - }); - setObjectTypeMembers(type, members, callSignatures, constructSignatures, stringIndexType, numberIndexType); + var source = resolveDeclaredMembers(type.target); + var typeParameters = ts.concatenate(source.typeParameters, [source.thisType]); + var typeArguments = type.typeArguments && type.typeArguments.length === typeParameters.length ? + type.typeArguments : ts.concatenate(type.typeArguments, [type]); + resolveObjectTypeMembers(type, source, typeParameters, typeArguments); } function createSignature(declaration, typeParameters, parameters, resolvedReturnType, typePredicate, minArgumentCount, hasRestParameter, hasStringLiterals) { var sig = new Signature(checker); @@ -12652,7 +13002,8 @@ var ts; return members; } function resolveTupleTypeMembers(type) { - var arrayType = resolveStructuredTypeMembers(createArrayType(getUnionType(type.elementTypes, true))); + var arrayElementType = getUnionType(type.elementTypes, true); + var arrayType = resolveStructuredTypeMembers(createTypeFromGenericGlobalType(globalArrayType, [arrayElementType, type])); var members = createTupleTypeMemberSymbols(type.elementTypes); addInheritedMembers(members, arrayType.properties); setObjectTypeMembers(type, members, arrayType.callSignatures, arrayType.constructSignatures, arrayType.stringIndexType, arrayType.numberIndexType); @@ -12754,7 +13105,14 @@ var ts; var constructSignatures; var stringIndexType; var numberIndexType; - if (symbol.flags & 2048) { + if (type.target) { + members = createInstantiatedSymbolTable(getPropertiesOfObjectType(type.target), type.mapper, false); + callSignatures = instantiateList(getSignaturesOfType(type.target, 0), type.mapper, instantiateSignature); + constructSignatures = instantiateList(getSignaturesOfType(type.target, 1), type.mapper, instantiateSignature); + stringIndexType = instantiateType(getIndexTypeOfType(type.target, 0), type.mapper); + numberIndexType = instantiateType(getIndexTypeOfType(type.target, 1), type.mapper); + } + else if (symbol.flags & 2048) { members = symbol.members; callSignatures = getSignaturesOfSymbol(members["__call"]); constructSignatures = getSignaturesOfSymbol(members["__new"]); @@ -12790,7 +13148,10 @@ var ts; } function resolveStructuredTypeMembers(type) { if (!type.members) { - if (type.flags & (1024 | 2048)) { + if (type.flags & 4096) { + resolveTypeReferenceMembers(type); + } + else if (type.flags & (1024 | 2048)) { resolveClassOrInterfaceMembers(type); } else if (type.flags & 65536) { @@ -12805,9 +13166,6 @@ var ts; else if (type.flags & 32768) { resolveIntersectionTypeMembers(type); } - else { - resolveTypeReferenceMembers(type); - } } return type; } @@ -13014,7 +13372,7 @@ var ts; function getSignatureFromDeclaration(declaration) { var links = getNodeLinks(declaration); if (!links.resolvedSignature) { - var classType = declaration.kind === 142 ? getDeclaredTypeOfClassOrInterface(declaration.parent.symbol) : undefined; + var classType = declaration.kind === 144 ? getDeclaredTypeOfClassOrInterface(declaration.parent.symbol) : undefined; var typeParameters = classType ? classType.localTypeParameters : declaration.typeParameters ? getTypeParametersFromDeclaration(declaration.typeParameters) : undefined; var parameters = []; @@ -13045,7 +13403,7 @@ var ts; } else if (declaration.type) { returnType = getTypeFromTypeNode(declaration.type); - if (declaration.type.kind === 148) { + if (declaration.type.kind === 150) { var typePredicateNode = declaration.type; typePredicate = { parameterName: typePredicateNode.parameterName ? typePredicateNode.parameterName.text : undefined, @@ -13055,8 +13413,8 @@ var ts; } } else { - if (declaration.kind === 143 && !ts.hasDynamicName(declaration)) { - var setter = ts.getDeclarationOfKind(declaration.symbol, 144); + if (declaration.kind === 145 && !ts.hasDynamicName(declaration)) { + var setter = ts.getDeclarationOfKind(declaration.symbol, 146); returnType = getAnnotatedAccessorType(setter); } if (!returnType && ts.nodeIsMissing(declaration.body)) { @@ -13074,19 +13432,19 @@ var ts; for (var i = 0, len = symbol.declarations.length; i < len; i++) { var node = symbol.declarations[i]; switch (node.kind) { - case 150: - case 151: - case 211: - case 141: - case 140: + case 152: + case 153: + case 213: + case 143: case 142: + case 144: + case 147: + case 148: + case 149: case 145: case 146: - case 147: - case 143: - case 144: - case 171: - case 172: + case 173: + case 174: if (i > 0 && node.body) { var previous = symbol.declarations[i - 1]; if (node.parent === previous.parent && node.kind === previous.kind && node.pos === previous.end) { @@ -13098,6 +13456,16 @@ var ts; } return result; } + function resolveExternalModuleTypeByLiteral(name) { + var moduleSym = resolveExternalModuleName(name, name); + if (moduleSym) { + var resolvedModuleSymbol = resolveExternalModuleSymbol(moduleSym); + if (resolvedModuleSymbol) { + return getTypeOfSymbol(resolvedModuleSymbol); + } + } + return anyType; + } function getReturnTypeOfSignature(signature) { if (!signature.resolvedReturnType) { if (!pushTypeResolution(signature, 3)) { @@ -13156,7 +13524,7 @@ var ts; } function getOrCreateTypeFromSignature(signature) { if (!signature.isolatedSignatureType) { - var isConstructor = signature.declaration.kind === 142 || signature.declaration.kind === 146; + var isConstructor = signature.declaration.kind === 144 || signature.declaration.kind === 148; var type = createObjectType(65536 | 262144); type.members = emptySymbols; type.properties = emptyArray; @@ -13170,7 +13538,7 @@ var ts; return symbol.members["__index"]; } function getIndexDeclarationOfSymbol(symbol, kind) { - var syntaxKind = kind === 1 ? 126 : 128; + var syntaxKind = kind === 1 ? 128 : 130; var indexSymbol = getIndexSymbol(symbol); if (indexSymbol) { for (var _i = 0, _a = indexSymbol.declarations; _i < _a.length; _i++) { @@ -13199,30 +13567,33 @@ var ts; type.constraint = targetConstraint ? instantiateType(targetConstraint, type.mapper) : noConstraintType; } else { - type.constraint = getTypeFromTypeNode(ts.getDeclarationOfKind(type.symbol, 135).constraint); + type.constraint = getTypeFromTypeNode(ts.getDeclarationOfKind(type.symbol, 137).constraint); } } return type.constraint === noConstraintType ? undefined : type.constraint; } function getParentSymbolOfTypeParameter(typeParameter) { - return getSymbolOfNode(ts.getDeclarationOfKind(typeParameter.symbol, 135).parent); + return getSymbolOfNode(ts.getDeclarationOfKind(typeParameter.symbol, 137).parent); } function getTypeListId(types) { - switch (types.length) { - case 1: - return "" + types[0].id; - case 2: - return types[0].id + "," + types[1].id; - default: - var result = ""; - for (var i = 0; i < types.length; i++) { - if (i > 0) { - result += ","; + if (types) { + switch (types.length) { + case 1: + return "" + types[0].id; + case 2: + return types[0].id + "," + types[1].id; + default: + var result = ""; + for (var i = 0; i < types.length; i++) { + if (i > 0) { + result += ","; + } + result += types[i].id; } - result += types[i].id; - } - return result; + return result; + } } + return ""; } function getPropagatingFlagsOfTypes(types) { var result = 0; @@ -13236,7 +13607,7 @@ var ts; var id = getTypeListId(typeArguments); var type = target.instantiations[id]; if (!type) { - var flags = 4096 | getPropagatingFlagsOfTypes(typeArguments); + var flags = 4096 | (typeArguments ? getPropagatingFlagsOfTypes(typeArguments) : 0); type = target.instantiations[id] = createObjectType(flags, target.symbol); type.target = target; type.typeArguments = typeArguments; @@ -13252,13 +13623,13 @@ var ts; while (!ts.forEach(typeParameterSymbol.declarations, function (d) { return d.parent === currentNode.parent; })) { currentNode = currentNode.parent; } - links.isIllegalTypeReferenceInConstraint = currentNode.kind === 135; + links.isIllegalTypeReferenceInConstraint = currentNode.kind === 137; return links.isIllegalTypeReferenceInConstraint; } function checkTypeParameterHasIllegalReferencesInConstraint(typeParameter) { var typeParameterSymbol; function check(n) { - if (n.kind === 149 && n.typeName.kind === 67) { + if (n.kind === 151 && n.typeName.kind === 69) { var links = getNodeLinks(n); if (links.isIllegalTypeReferenceInConstraint === undefined) { var symbol = resolveName(typeParameter, n.typeName.text, 793056, undefined, undefined); @@ -13325,7 +13696,7 @@ var ts; function getTypeFromTypeReference(node) { var links = getNodeLinks(node); if (!links.resolvedType) { - var typeNameOrExpression = node.kind === 149 ? node.typeName : + var typeNameOrExpression = node.kind === 151 ? node.typeName : ts.isSupportedExpressionWithTypeArguments(node) ? node.expression : undefined; var symbol = typeNameOrExpression && resolveEntityName(typeNameOrExpression, 793056) || unknownSymbol; @@ -13351,9 +13722,9 @@ var ts; for (var _i = 0; _i < declarations.length; _i++) { var declaration = declarations[_i]; switch (declaration.kind) { - case 212: - case 213: + case 214: case 215: + case 217: return declaration; } } @@ -13390,10 +13761,13 @@ var ts; return getTypeOfGlobalSymbol(getGlobalSymbol(name, 793056, undefined), arity); } function getExportedTypeFromNamespace(namespace, name) { - var namespaceSymbol = getGlobalSymbol(namespace, 1536, undefined); - var typeSymbol = namespaceSymbol && getSymbol(namespaceSymbol.exports, name, 793056); + var typeSymbol = getExportedSymbolFromNamespace(namespace, name); return typeSymbol && getDeclaredTypeOfSymbol(typeSymbol); } + function getExportedSymbolFromNamespace(namespace, name) { + var namespaceSymbol = getGlobalSymbol(namespace, 1536, undefined); + return namespaceSymbol && getSymbol(namespaceSymbol.exports, name, 793056 | 107455); + } function getGlobalESSymbolConstructorSymbol() { return globalESSymbolConstructorSymbol || (globalESSymbolConstructorSymbol = getGlobalValueSymbol("Symbol")); } @@ -13403,17 +13777,17 @@ var ts; ? createTypeReference(globalTypedPropertyDescriptorType, [propertyType]) : emptyObjectType; } - function createTypeFromGenericGlobalType(genericGlobalType, elementType) { - return genericGlobalType !== emptyGenericType ? createTypeReference(genericGlobalType, [elementType]) : emptyObjectType; + function createTypeFromGenericGlobalType(genericGlobalType, typeArguments) { + return genericGlobalType !== emptyGenericType ? createTypeReference(genericGlobalType, typeArguments) : emptyObjectType; } function createIterableType(elementType) { - return createTypeFromGenericGlobalType(globalIterableType, elementType); + return createTypeFromGenericGlobalType(globalIterableType, [elementType]); } function createIterableIteratorType(elementType) { - return createTypeFromGenericGlobalType(globalIterableIteratorType, elementType); + return createTypeFromGenericGlobalType(globalIterableIteratorType, [elementType]); } function createArrayType(elementType) { - return createTypeFromGenericGlobalType(globalArrayType, elementType); + return createTypeFromGenericGlobalType(globalArrayType, [elementType]); } function getTypeFromArrayTypeNode(node) { var links = getNodeLinks(node); @@ -13570,46 +13944,66 @@ var ts; } return links.resolvedType; } + function getThisType(node) { + var container = ts.getThisContainer(node, false); + var parent = container && container.parent; + if (parent && (ts.isClassLike(parent) || parent.kind === 215)) { + if (!(container.flags & 128)) { + return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(parent)).thisType; + } + } + error(node, ts.Diagnostics.A_this_type_is_available_only_in_a_non_static_member_of_a_class_or_interface); + return unknownType; + } + function getTypeFromThisTypeNode(node) { + var links = getNodeLinks(node); + if (!links.resolvedType) { + links.resolvedType = getThisType(node); + } + return links.resolvedType; + } function getTypeFromTypeNode(node) { switch (node.kind) { - case 115: + case 117: return anyType; - case 128: + case 130: return stringType; - case 126: + case 128: return numberType; - case 118: + case 120: return booleanType; - case 129: + case 131: return esSymbolType; - case 101: + case 103: return voidType; + case 97: + return getTypeFromThisTypeNode(node); case 9: return getTypeFromStringLiteral(node); - case 149: - return getTypeFromTypeReference(node); - case 148: - return booleanType; - case 186: - return getTypeFromTypeReference(node); - case 152: - return getTypeFromTypeQueryNode(node); - case 154: - return getTypeFromArrayTypeNode(node); - case 155: - return getTypeFromTupleTypeNode(node); - case 156: - return getTypeFromUnionTypeNode(node); - case 157: - return getTypeFromIntersectionTypeNode(node); - case 158: - return getTypeFromTypeNode(node.type); - case 150: case 151: + return getTypeFromTypeReference(node); + case 150: + return booleanType; + case 188: + return getTypeFromTypeReference(node); + case 154: + return getTypeFromTypeQueryNode(node); + case 156: + return getTypeFromArrayTypeNode(node); + case 157: + return getTypeFromTupleTypeNode(node); + case 158: + return getTypeFromUnionTypeNode(node); + case 159: + return getTypeFromIntersectionTypeNode(node); + case 160: + return getTypeFromTypeNode(node.type); + case 152: case 153: + case 155: return getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node); - case 67: - case 133: + case 69: + case 135: var symbol = getSymbolAtLocation(node); return symbol && getDeclaredTypeOfSymbol(symbol); default: @@ -13713,7 +14107,7 @@ var ts; type: instantiateType(signature.typePredicate.type, mapper) }; } - var result = createSignature(signature.declaration, freshTypeParameters, instantiateList(signature.parameters, mapper, instantiateSymbol), signature.resolvedReturnType ? instantiateType(signature.resolvedReturnType, mapper) : undefined, freshTypePredicate, signature.minArgumentCount, signature.hasRestParameter, signature.hasStringLiterals); + var result = createSignature(signature.declaration, freshTypeParameters, instantiateList(signature.parameters, mapper, instantiateSymbol), instantiateType(signature.resolvedReturnType, mapper), freshTypePredicate, signature.minArgumentCount, signature.hasRestParameter, signature.hasStringLiterals); result.target = signature; result.mapper = mapper; return result; @@ -13745,21 +14139,13 @@ var ts; mapper.instantiations = []; } var result = createObjectType(65536 | 131072, type.symbol); - result.properties = instantiateList(getPropertiesOfObjectType(type), mapper, instantiateSymbol); - result.members = createSymbolTable(result.properties); - result.callSignatures = instantiateList(getSignaturesOfType(type, 0), mapper, instantiateSignature); - result.constructSignatures = instantiateList(getSignaturesOfType(type, 1), mapper, instantiateSignature); - var stringIndexType = getIndexTypeOfType(type, 0); - var numberIndexType = getIndexTypeOfType(type, 1); - if (stringIndexType) - result.stringIndexType = instantiateType(stringIndexType, mapper); - if (numberIndexType) - result.numberIndexType = instantiateType(numberIndexType, mapper); + result.target = type; + result.mapper = mapper; mapper.instantiations[type.id] = result; return result; } function instantiateType(type, mapper) { - if (mapper !== identityMapper) { + if (type && mapper !== identityMapper) { if (type.flags & 512) { return mapper(type); } @@ -13783,27 +14169,27 @@ var ts; return type; } function isContextSensitive(node) { - ts.Debug.assert(node.kind !== 141 || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 143 || ts.isObjectLiteralMethod(node)); switch (node.kind) { - case 171: - case 172: + case 173: + case 174: return isContextSensitiveFunctionLikeDeclaration(node); - case 163: + case 165: return ts.forEach(node.properties, isContextSensitive); - case 162: + case 164: return ts.forEach(node.elements, isContextSensitive); - case 180: + case 182: return isContextSensitive(node.whenTrue) || isContextSensitive(node.whenFalse); - case 179: - return node.operatorToken.kind === 51 && + case 181: + return node.operatorToken.kind === 52 && (isContextSensitive(node.left) || isContextSensitive(node.right)); - case 243: + case 245: return isContextSensitive(node.initializer); - case 141: - case 140: + case 143: + case 142: return isContextSensitiveFunctionLikeDeclaration(node); - case 170: + case 172: return isContextSensitive(node.expression); } return false; @@ -13956,7 +14342,7 @@ var ts; } else { if (source.flags & 4096 && target.flags & 4096 && source.target === target.target) { - if (result = typesRelatedTo(source.typeArguments, target.typeArguments, reportErrors)) { + if (result = typeArgumentsRelatedTo(source, target, reportErrors)) { return result; } } @@ -13978,7 +14364,7 @@ var ts; var result; if (source.flags & 80896 && target.flags & 80896) { if (source.flags & 4096 && target.flags & 4096 && source.target === target.target) { - if (result = typesRelatedTo(source.typeArguments, target.typeArguments, false)) { + if (result = typeArgumentsRelatedTo(source, target, false)) { return result; } } @@ -14088,9 +14474,14 @@ var ts; } return result; } - function typesRelatedTo(sources, targets, reportErrors) { + function typeArgumentsRelatedTo(source, target, reportErrors) { + var sources = source.typeArguments || emptyArray; + var targets = target.typeArguments || emptyArray; + if (sources.length !== targets.length && relation === identityRelation) { + return 0; + } var result = -1; - for (var i = 0, len = sources.length; i < len; i++) { + for (var i = 0; i < targets.length; i++) { var related = isRelatedTo(sources[i], targets[i], reportErrors); if (!related) { return 0; @@ -14741,22 +15132,22 @@ var ts; var typeAsString = typeToString(getWidenedType(type)); var diagnostic; switch (declaration.kind) { - case 139: - case 138: + case 141: + case 140: diagnostic = ts.Diagnostics.Member_0_implicitly_has_an_1_type; break; - case 136: + case 138: diagnostic = declaration.dotDotDotToken ? ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type : ts.Diagnostics.Parameter_0_implicitly_has_an_1_type; break; - case 211: - case 141: - case 140: + case 213: case 143: - case 144: - case 171: - case 172: + case 142: + case 145: + case 146: + case 173: + case 174: if (!declaration.name) { error(declaration, ts.Diagnostics.Function_expression_which_lacks_return_type_annotation_implicitly_has_an_0_return_type, typeAsString); return; @@ -14852,9 +15243,10 @@ var ts; } } else if (source.flags & 4096 && target.flags & 4096 && source.target === target.target) { - var sourceTypes = source.typeArguments; - var targetTypes = target.typeArguments; - for (var i = 0; i < sourceTypes.length; i++) { + var sourceTypes = source.typeArguments || emptyArray; + var targetTypes = target.typeArguments || emptyArray; + var count = sourceTypes.length < targetTypes.length ? sourceTypes.length : targetTypes.length; + for (var i = 0; i < count; i++) { inferFromTypes(sourceTypes[i], targetTypes[i]); } } @@ -15008,10 +15400,10 @@ var ts; function isInTypeQuery(node) { while (node) { switch (node.kind) { - case 152: + case 154: return true; - case 67: - case 133: + case 69: + case 135: node = node.parent; continue; default: @@ -15051,12 +15443,12 @@ var ts; } return links.assignmentChecks[symbol.id] = isAssignedIn(node); function isAssignedInBinaryExpression(node) { - if (node.operatorToken.kind >= 55 && node.operatorToken.kind <= 66) { + if (node.operatorToken.kind >= 56 && node.operatorToken.kind <= 68) { var n = node.left; - while (n.kind === 170) { + while (n.kind === 172) { n = n.expression; } - if (n.kind === 67 && getResolvedSymbol(n) === symbol) { + if (n.kind === 69 && getResolvedSymbol(n) === symbol) { return true; } } @@ -15070,55 +15462,55 @@ var ts; } function isAssignedIn(node) { switch (node.kind) { - case 179: + case 181: return isAssignedInBinaryExpression(node); - case 209: - case 161: - return isAssignedInVariableDeclaration(node); - case 159: - case 160: - case 162: + case 211: case 163: + return isAssignedInVariableDeclaration(node); + case 161: + case 162: case 164: case 165: case 166: case 167: + case 168: case 169: - case 187: - case 170: - case 177: - case 173: - case 176: - case 174: + case 171: + case 189: + case 172: + case 179: case 175: case 178: - case 182: + case 176: + case 177: case 180: - case 183: - case 190: - case 191: + case 184: + case 182: + case 185: + case 192: case 193: - case 194: case 195: case 196: case 197: case 198: case 199: - case 202: - case 203: + case 200: + case 201: case 204: - case 239: - case 240: case 205: case 206: - case 207: + case 241: case 242: - case 231: - case 232: - case 236: - case 237: + case 207: + case 208: + case 209: + case 244: case 233: + case 234: case 238: + case 239: + case 235: + case 240: return ts.forEachChild(node, isAssignedIn); } return false; @@ -15133,34 +15525,34 @@ var ts; node = node.parent; var narrowedType = type; switch (node.kind) { - case 194: + case 196: if (child !== node.expression) { narrowedType = narrowType(type, node.expression, child === node.thenStatement); } break; - case 180: + case 182: if (child !== node.condition) { narrowedType = narrowType(type, node.condition, child === node.whenTrue); } break; - case 179: + case 181: if (child === node.right) { - if (node.operatorToken.kind === 50) { + if (node.operatorToken.kind === 51) { narrowedType = narrowType(type, node.left, true); } - else if (node.operatorToken.kind === 51) { + else if (node.operatorToken.kind === 52) { narrowedType = narrowType(type, node.left, false); } } break; - case 246: - case 216: - case 211: - case 141: - case 140: + case 248: + case 218: + case 213: case 143: - case 144: case 142: + case 145: + case 146: + case 144: break loop; } if (narrowedType !== type) { @@ -15174,12 +15566,12 @@ var ts; } return type; function narrowTypeByEquality(type, expr, assumeTrue) { - if (expr.left.kind !== 174 || expr.right.kind !== 9) { + if (expr.left.kind !== 176 || expr.right.kind !== 9) { return type; } var left = expr.left; var right = expr.right; - if (left.expression.kind !== 67 || getResolvedSymbol(left.expression) !== symbol) { + if (left.expression.kind !== 69 || getResolvedSymbol(left.expression) !== symbol) { return type; } var typeInfo = primitiveTypeInfo[right.text]; @@ -15225,7 +15617,7 @@ var ts; } } function narrowTypeByInstanceof(type, expr, assumeTrue) { - if (isTypeAny(type) || !assumeTrue || expr.left.kind !== 67 || getResolvedSymbol(expr.left) !== symbol) { + if (isTypeAny(type) || !assumeTrue || expr.left.kind !== 69 || getResolvedSymbol(expr.left) !== symbol) { return type; } var rightType = checkExpression(expr.right); @@ -15289,27 +15681,27 @@ var ts; } function narrowType(type, expr, assumeTrue) { switch (expr.kind) { - case 166: + case 168: return narrowTypeByTypePredicate(type, expr, assumeTrue); - case 170: + case 172: return narrowType(type, expr.expression, assumeTrue); - case 179: + case 181: var operator = expr.operatorToken.kind; if (operator === 32 || operator === 33) { return narrowTypeByEquality(type, expr, assumeTrue); } - else if (operator === 50) { + else if (operator === 51) { return narrowTypeByAnd(type, expr, assumeTrue); } - else if (operator === 51) { + else if (operator === 52) { return narrowTypeByOr(type, expr, assumeTrue); } - else if (operator === 89) { + else if (operator === 91) { return narrowTypeByInstanceof(type, expr, assumeTrue); } break; - case 177: - if (expr.operator === 48) { + case 179: + if (expr.operator === 49) { return narrowType(type, expr.operand, !assumeTrue); } break; @@ -15321,7 +15713,7 @@ var ts; var symbol = getResolvedSymbol(node); if (symbol === argumentsSymbol) { var container = ts.getContainingFunction(node); - if (container.kind === 172) { + if (container.kind === 174) { if (languageVersion < 2) { error(node, ts.Diagnostics.The_arguments_object_cannot_be_referenced_in_an_arrow_function_in_ES3_and_ES5_Consider_using_a_standard_function_expression); } @@ -15352,15 +15744,15 @@ var ts; function checkBlockScopedBindingCapturedInLoop(node, symbol) { if (languageVersion >= 2 || (symbol.flags & 2) === 0 || - symbol.valueDeclaration.parent.kind === 242) { + symbol.valueDeclaration.parent.kind === 244) { return; } var container = symbol.valueDeclaration; - while (container.kind !== 210) { + while (container.kind !== 212) { container = container.parent; } container = container.parent; - if (container.kind === 191) { + if (container.kind === 193) { container = container.parent; } var inFunction = isInsideFunction(node.parent, container); @@ -15378,7 +15770,7 @@ var ts; } function captureLexicalThis(node, container) { getNodeLinks(node).flags |= 2; - if (container.kind === 139 || container.kind === 142) { + if (container.kind === 141 || container.kind === 144) { var classNode = container.parent; getNodeLinks(classNode).flags |= 4; } @@ -15389,29 +15781,29 @@ var ts; function checkThisExpression(node) { var container = ts.getThisContainer(node, true); var needToCaptureLexicalThis = false; - if (container.kind === 172) { + if (container.kind === 174) { container = ts.getThisContainer(container, false); needToCaptureLexicalThis = (languageVersion < 2); } switch (container.kind) { - case 216: + case 218: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_module_or_namespace_body); break; - case 215: + case 217: error(node, ts.Diagnostics.this_cannot_be_referenced_in_current_location); break; - case 142: + case 144: if (isInConstructorArgumentInitializer(node, container)) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_constructor_arguments); } break; - case 139: - case 138: + case 141: + case 140: if (container.flags & 128) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_static_property_initializer); } break; - case 134: + case 136: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_computed_property_name); break; } @@ -15420,27 +15812,27 @@ var ts; } if (ts.isClassLike(container.parent)) { var symbol = getSymbolOfNode(container.parent); - return container.flags & 128 ? getTypeOfSymbol(symbol) : getDeclaredTypeOfSymbol(symbol); + return container.flags & 128 ? getTypeOfSymbol(symbol) : getDeclaredTypeOfSymbol(symbol).thisType; } return anyType; } function isInConstructorArgumentInitializer(node, constructorDecl) { for (var n = node; n && n !== constructorDecl; n = n.parent) { - if (n.kind === 136) { + if (n.kind === 138) { return true; } } return false; } function checkSuperExpression(node) { - var isCallExpression = node.parent.kind === 166 && node.parent.expression === node; + var isCallExpression = node.parent.kind === 168 && node.parent.expression === node; var classDeclaration = ts.getContainingClass(node); var classType = classDeclaration && getDeclaredTypeOfSymbol(getSymbolOfNode(classDeclaration)); var baseClassType = classType && getBaseTypes(classType)[0]; var container = ts.getSuperContainer(node, true); var needToCaptureLexicalThis = false; if (!isCallExpression) { - while (container && container.kind === 172) { + while (container && container.kind === 174) { container = ts.getSuperContainer(container, true); needToCaptureLexicalThis = languageVersion < 2; } @@ -15466,7 +15858,7 @@ var ts; return unknownType; } if (!canUseSuperExpression) { - if (container && container.kind === 134) { + if (container && container.kind === 136) { error(node, ts.Diagnostics.super_cannot_be_referenced_in_a_computed_property_name); } else if (isCallExpression) { @@ -15477,7 +15869,7 @@ var ts; } return unknownType; } - if (container.kind === 142 && isInConstructorArgumentInitializer(node, container)) { + if (container.kind === 144 && isInConstructorArgumentInitializer(node, container)) { error(node, ts.Diagnostics.super_cannot_be_referenced_in_constructor_arguments); return unknownType; } @@ -15489,24 +15881,24 @@ var ts; return false; } if (isCallExpression) { - return container.kind === 142; + return container.kind === 144; } else { if (container && ts.isClassLike(container.parent)) { if (container.flags & 128) { - return container.kind === 141 || - container.kind === 140 || - container.kind === 143 || - container.kind === 144; + return container.kind === 143 || + container.kind === 142 || + container.kind === 145 || + container.kind === 146; } else { - return container.kind === 141 || + return container.kind === 143 || + container.kind === 142 || + container.kind === 145 || + container.kind === 146 || + container.kind === 141 || container.kind === 140 || - container.kind === 143 || - container.kind === 144 || - container.kind === 139 || - container.kind === 138 || - container.kind === 142; + container.kind === 144; } } } @@ -15540,7 +15932,7 @@ var ts; if (declaration.type) { return getTypeFromTypeNode(declaration.type); } - if (declaration.kind === 136) { + if (declaration.kind === 138) { var type = getContextuallyTypedParameterType(declaration); if (type) { return type; @@ -15573,7 +15965,7 @@ var ts; } function isInParameterInitializerBeforeContainingFunction(node) { while (node.parent && !ts.isFunctionLike(node.parent)) { - if (node.parent.kind === 136 && node.parent.initializer === node) { + if (node.parent.kind === 138 && node.parent.initializer === node) { return true; } node = node.parent; @@ -15582,8 +15974,8 @@ var ts; } function getContextualReturnType(functionDecl) { if (functionDecl.type || - functionDecl.kind === 142 || - functionDecl.kind === 143 && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(functionDecl.symbol, 144))) { + functionDecl.kind === 144 || + functionDecl.kind === 145 && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(functionDecl.symbol, 146))) { return getReturnTypeOfSignature(getSignatureFromDeclaration(functionDecl)); } var signature = getContextualSignatureForFunctionLikeDeclaration(functionDecl); @@ -15602,7 +15994,7 @@ var ts; return undefined; } function getContextualTypeForSubstitutionExpression(template, substitutionExpression) { - if (template.parent.kind === 168) { + if (template.parent.kind === 170) { return getContextualTypeForArgument(template.parent, substitutionExpression); } return undefined; @@ -15610,12 +16002,12 @@ var ts; function getContextualTypeForBinaryOperand(node) { var binaryExpression = node.parent; var operator = binaryExpression.operatorToken.kind; - if (operator >= 55 && operator <= 66) { + if (operator >= 56 && operator <= 68) { if (node === binaryExpression.right) { return checkExpression(binaryExpression.left); } } - else if (operator === 51) { + else if (operator === 52) { var type = getContextualType(binaryExpression); if (!type && node === binaryExpression.right) { type = checkExpression(binaryExpression.left); @@ -15702,7 +16094,7 @@ var ts; return node === conditional.whenTrue || node === conditional.whenFalse ? getContextualType(conditional) : undefined; } function getContextualTypeForJsxExpression(expr) { - if (expr.parent.kind === 236) { + if (expr.parent.kind === 238) { var attrib = expr.parent; var attrsType = getJsxElementAttributesType(attrib.parent); if (!attrsType || isTypeAny(attrsType)) { @@ -15712,7 +16104,7 @@ var ts; return getTypeOfPropertyOfType(attrsType, attrib.name.text); } } - if (expr.kind === 237) { + if (expr.kind === 239) { return getJsxElementAttributesType(expr.parent); } return undefined; @@ -15730,38 +16122,38 @@ var ts; } var parent = node.parent; switch (parent.kind) { - case 209: - case 136: - case 139: + case 211: case 138: - case 161: + case 141: + case 140: + case 163: return getContextualTypeForInitializerExpression(node); - case 172: - case 202: + case 174: + case 204: return getContextualTypeForReturnExpression(node); - case 182: + case 184: return getContextualTypeForYieldOperand(parent); - case 166: - case 167: - return getContextualTypeForArgument(parent, node); + case 168: case 169: - case 187: + return getContextualTypeForArgument(parent, node); + case 171: + case 189: return getTypeFromTypeNode(parent.type); - case 179: + case 181: return getContextualTypeForBinaryOperand(node); - case 243: + case 245: return getContextualTypeForObjectLiteralElement(parent); - case 162: + case 164: return getContextualTypeForElementExpression(node); - case 180: + case 182: return getContextualTypeForConditionalOperand(node); - case 188: - ts.Debug.assert(parent.parent.kind === 181); + case 190: + ts.Debug.assert(parent.parent.kind === 183); return getContextualTypeForSubstitutionExpression(parent.parent, node); - case 170: + case 172: return getContextualType(parent); - case 238: - case 237: + case 240: + case 239: return getContextualTypeForJsxExpression(parent); } return undefined; @@ -15776,7 +16168,7 @@ var ts; } } function isFunctionExpressionOrArrowFunction(node) { - return node.kind === 171 || node.kind === 172; + return node.kind === 173 || node.kind === 174; } function getContextualSignatureForFunctionLikeDeclaration(node) { return isFunctionExpressionOrArrowFunction(node) || ts.isObjectLiteralMethod(node) @@ -15784,7 +16176,7 @@ var ts; : undefined; } function getContextualSignature(node) { - ts.Debug.assert(node.kind !== 141 || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 143 || ts.isObjectLiteralMethod(node)); var type = ts.isObjectLiteralMethod(node) ? getContextualTypeForObjectLiteralMethod(node) : getContextualType(node); @@ -15824,13 +16216,13 @@ var ts; } function isAssignmentTarget(node) { var parent = node.parent; - if (parent.kind === 179 && parent.operatorToken.kind === 55 && parent.left === node) { + if (parent.kind === 181 && parent.operatorToken.kind === 56 && parent.left === node) { return true; } - if (parent.kind === 243) { + if (parent.kind === 245) { return isAssignmentTarget(parent.parent); } - if (parent.kind === 162) { + if (parent.kind === 164) { return isAssignmentTarget(parent); } return false; @@ -15840,8 +16232,8 @@ var ts; return checkIteratedTypeOrElementType(arrayOrIterableType, node.expression, false); } function hasDefaultValue(node) { - return (node.kind === 161 && !!node.initializer) || - (node.kind === 179 && node.operatorToken.kind === 55); + return (node.kind === 163 && !!node.initializer) || + (node.kind === 181 && node.operatorToken.kind === 56); } function checkArrayLiteral(node, contextualMapper) { var elements = node.elements; @@ -15850,7 +16242,7 @@ var ts; var inDestructuringPattern = isAssignmentTarget(node); for (var _i = 0; _i < elements.length; _i++) { var e = elements[_i]; - if (inDestructuringPattern && e.kind === 183) { + if (inDestructuringPattern && e.kind === 185) { var restArrayType = checkExpression(e.expression, contextualMapper); var restElementType = getIndexTypeOfType(restArrayType, 1) || (languageVersion >= 2 ? getElementTypeOfIterable(restArrayType, undefined) : undefined); @@ -15862,7 +16254,7 @@ var ts; var type = checkExpression(e, contextualMapper); elementTypes.push(type); } - hasSpreadElement = hasSpreadElement || e.kind === 183; + hasSpreadElement = hasSpreadElement || e.kind === 185; } if (!hasSpreadElement) { if (inDestructuringPattern && elementTypes.length) { @@ -15873,7 +16265,7 @@ var ts; var contextualType = getContextualType(node); if (contextualType && contextualTypeIsTupleLikeType(contextualType)) { var pattern = contextualType.pattern; - if (pattern && (pattern.kind === 160 || pattern.kind === 162)) { + if (pattern && (pattern.kind === 162 || pattern.kind === 164)) { var patternElements = pattern.elements; for (var i = elementTypes.length; i < patternElements.length; i++) { var patternElement = patternElements[i]; @@ -15881,7 +16273,7 @@ var ts; elementTypes.push(contextualType.elementTypes[i]); } else { - if (patternElement.kind !== 185) { + if (patternElement.kind !== 187) { error(patternElement, ts.Diagnostics.Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value); } elementTypes.push(unknownType); @@ -15896,7 +16288,7 @@ var ts; return createArrayType(elementTypes.length ? getUnionType(elementTypes) : undefinedType); } function isNumericName(name) { - return name.kind === 134 ? isNumericComputedName(name) : isNumericLiteralName(name.text); + return name.kind === 136 ? isNumericComputedName(name) : isNumericLiteralName(name.text); } function isNumericComputedName(name) { return isTypeAnyOrAllConstituentTypesHaveKind(checkComputedPropertyName(name), 132); @@ -15921,35 +16313,37 @@ var ts; return links.resolvedType; } function checkObjectLiteral(node, contextualMapper) { - checkGrammarObjectLiteralExpression(node); + var inDestructuringPattern = isAssignmentTarget(node); + checkGrammarObjectLiteralExpression(node, inDestructuringPattern); var propertiesTable = {}; var propertiesArray = []; var contextualType = getContextualType(node); var contextualTypeHasPattern = contextualType && contextualType.pattern && - (contextualType.pattern.kind === 159 || contextualType.pattern.kind === 163); - var inDestructuringPattern = isAssignmentTarget(node); + (contextualType.pattern.kind === 161 || contextualType.pattern.kind === 165); var typeFlags = 0; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var memberDecl = _a[_i]; var member = memberDecl.symbol; - if (memberDecl.kind === 243 || - memberDecl.kind === 244 || + if (memberDecl.kind === 245 || + memberDecl.kind === 246 || ts.isObjectLiteralMethod(memberDecl)) { var type = void 0; - if (memberDecl.kind === 243) { + if (memberDecl.kind === 245) { type = checkPropertyAssignment(memberDecl, contextualMapper); } - else if (memberDecl.kind === 141) { + else if (memberDecl.kind === 143) { type = checkObjectLiteralMethod(memberDecl, contextualMapper); } else { - ts.Debug.assert(memberDecl.kind === 244); + ts.Debug.assert(memberDecl.kind === 246); type = checkExpression(memberDecl.name, contextualMapper); } typeFlags |= type.flags; var prop = createSymbol(4 | 67108864 | member.flags, member.name); if (inDestructuringPattern) { - if (memberDecl.kind === 243 && hasDefaultValue(memberDecl.initializer)) { + var isOptional = (memberDecl.kind === 245 && hasDefaultValue(memberDecl.initializer)) || + (memberDecl.kind === 246 && memberDecl.objectAssignmentInitializer); + if (isOptional) { prop.flags |= 536870912; } } @@ -15972,7 +16366,7 @@ var ts; member = prop; } else { - ts.Debug.assert(memberDecl.kind === 143 || memberDecl.kind === 144); + ts.Debug.assert(memberDecl.kind === 145 || memberDecl.kind === 146); checkAccessorDeclaration(memberDecl); } if (!ts.hasDynamicName(memberDecl)) { @@ -16028,7 +16422,7 @@ var ts; if (lhs.kind !== rhs.kind) { return false; } - if (lhs.kind === 67) { + if (lhs.kind === 69) { return lhs.text === rhs.text; } return lhs.right.text === rhs.right.text && @@ -16045,17 +16439,17 @@ var ts; for (var _i = 0, _a = node.children; _i < _a.length; _i++) { var child = _a[_i]; switch (child.kind) { - case 238: + case 240: checkJsxExpression(child); break; - case 231: + case 233: checkJsxElement(child); break; - case 232: + case 234: checkJsxSelfClosingElement(child); break; default: - ts.Debug.assert(child.kind === 234); + ts.Debug.assert(child.kind === 236); } } return jsxElementType || anyType; @@ -16064,7 +16458,7 @@ var ts; return name.indexOf("-") < 0; } function isJsxIntrinsicIdentifier(tagName) { - if (tagName.kind === 133) { + if (tagName.kind === 135) { return false; } else { @@ -16165,12 +16559,14 @@ var ts; var valueSymbol = resolveJsxTagName(node); if (valueSymbol && valueSymbol !== unknownSymbol) { links.jsxFlags |= 4; - getSymbolLinks(valueSymbol).referenced = true; + if (valueSymbol.flags & 8388608) { + markAliasSymbolAsReferenced(valueSymbol); + } } return valueSymbol || unknownSymbol; } function resolveJsxTagName(node) { - if (node.tagName.kind === 67) { + if (node.tagName.kind === 69) { var tag = node.tagName; var sym = getResolvedSymbol(tag); return sym.exportSymbol || sym; @@ -16310,11 +16706,11 @@ var ts; var nameTable = {}; var sawSpreadedAny = false; for (var i = node.attributes.length - 1; i >= 0; i--) { - if (node.attributes[i].kind === 236) { + if (node.attributes[i].kind === 238) { checkJsxAttribute((node.attributes[i]), targetAttributesType, nameTable); } else { - ts.Debug.assert(node.attributes[i].kind === 237); + ts.Debug.assert(node.attributes[i].kind === 239); var spreadType = checkJsxSpreadAttribute((node.attributes[i]), targetAttributesType, nameTable); if (isTypeAny(spreadType)) { sawSpreadedAny = true; @@ -16340,7 +16736,7 @@ var ts; } } function getDeclarationKindFromSymbol(s) { - return s.valueDeclaration ? s.valueDeclaration.kind : 139; + return s.valueDeclaration ? s.valueDeclaration.kind : 141; } function getDeclarationFlagsFromSymbol(s) { return s.valueDeclaration ? ts.getCombinedNodeFlags(s.valueDeclaration) : s.flags & 134217728 ? 16 | 128 : 0; @@ -16348,11 +16744,11 @@ var ts; function checkClassPropertyAccess(node, left, type, prop) { var flags = getDeclarationFlagsFromSymbol(prop); var declaringClass = getDeclaredTypeOfSymbol(prop.parent); - if (left.kind === 93) { - var errorNode = node.kind === 164 ? + if (left.kind === 95) { + var errorNode = node.kind === 166 ? node.name : node.right; - if (getDeclarationKindFromSymbol(prop) !== 141) { + if (getDeclarationKindFromSymbol(prop) !== 143) { error(errorNode, ts.Diagnostics.Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword); return false; } @@ -16373,7 +16769,7 @@ var ts; } return true; } - if (left.kind === 93) { + if (left.kind === 95) { return true; } if (!enclosingClass || !hasBaseType(enclosingClass, declaringClass)) { @@ -16383,6 +16779,9 @@ var ts; if (flags & 128) { return true; } + if (type.flags & 33554432) { + type = getConstraintOfTypeParameter(type); + } if (!(getTargetType(type).flags & (1024 | 2048) && hasBaseType(type, enclosingClass))) { error(node, ts.Diagnostics.Property_0_is_protected_and_only_accessible_through_an_instance_of_class_1, symbolToString(prop), typeToString(enclosingClass)); return false; @@ -16407,18 +16806,18 @@ var ts; var prop = getPropertyOfType(apparentType, right.text); if (!prop) { if (right.text) { - error(right, ts.Diagnostics.Property_0_does_not_exist_on_type_1, ts.declarationNameToString(right), typeToString(type)); + error(right, ts.Diagnostics.Property_0_does_not_exist_on_type_1, ts.declarationNameToString(right), typeToString(type.flags & 33554432 ? apparentType : type)); } return unknownType; } getNodeLinks(node).resolvedSymbol = prop; if (prop.parent && prop.parent.flags & 32) { - checkClassPropertyAccess(node, left, type, prop); + checkClassPropertyAccess(node, left, apparentType, prop); } return getTypeOfSymbol(prop); } function isValidPropertyAccess(node, propertyName) { - var left = node.kind === 164 + var left = node.kind === 166 ? node.expression : node.left; var type = checkExpression(left); @@ -16433,7 +16832,7 @@ var ts; function checkIndexedAccess(node) { if (!node.argumentExpression) { var sourceFile = getSourceFile(node); - if (node.parent.kind === 167 && node.parent.expression === node) { + if (node.parent.kind === 169 && node.parent.expression === node) { var start = ts.skipTrivia(sourceFile.text, node.expression.end); var end = node.end; grammarErrorAtPos(sourceFile, start, end - start, ts.Diagnostics.new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead); @@ -16492,6 +16891,12 @@ var ts; if (indexArgumentExpression.kind === 9 || indexArgumentExpression.kind === 8) { return indexArgumentExpression.text; } + if (indexArgumentExpression.kind === 167 || indexArgumentExpression.kind === 166) { + var value = getConstantValue(indexArgumentExpression); + if (value !== undefined) { + return value.toString(); + } + } if (checkThatExpressionIsProperSymbolReference(indexArgumentExpression, indexArgumentType, false)) { var rightHandSideName = indexArgumentExpression.name.text; return ts.getPropertyNameForKnownSymbolName(rightHandSideName); @@ -16529,10 +16934,10 @@ var ts; return true; } function resolveUntypedCall(node) { - if (node.kind === 168) { + if (node.kind === 170) { checkExpression(node.template); } - else if (node.kind !== 137) { + else if (node.kind !== 139) { ts.forEach(node.arguments, function (argument) { checkExpression(argument); }); @@ -16583,7 +16988,7 @@ var ts; function getSpreadArgumentIndex(args) { for (var i = 0; i < args.length; i++) { var arg = args[i]; - if (arg && arg.kind === 183) { + if (arg && arg.kind === 185) { return i; } } @@ -16595,11 +17000,11 @@ var ts; var callIsIncomplete; var isDecorator; var spreadArgIndex = -1; - if (node.kind === 168) { + if (node.kind === 170) { var tagExpression = node; adjustedArgCount = args.length; typeArguments = undefined; - if (tagExpression.template.kind === 181) { + if (tagExpression.template.kind === 183) { var templateExpression = tagExpression.template; var lastSpan = ts.lastOrUndefined(templateExpression.templateSpans); ts.Debug.assert(lastSpan !== undefined); @@ -16611,7 +17016,7 @@ var ts; callIsIncomplete = !!templateLiteral.isUnterminated; } } - else if (node.kind === 137) { + else if (node.kind === 139) { isDecorator = true; typeArguments = undefined; adjustedArgCount = getEffectiveArgumentCount(node, undefined, signature); @@ -16619,7 +17024,7 @@ var ts; else { var callExpression = node; if (!callExpression.arguments) { - ts.Debug.assert(callExpression.kind === 167); + ts.Debug.assert(callExpression.kind === 169); return signature.minArgumentCount === 0; } adjustedArgCount = callExpression.arguments.hasTrailingComma ? args.length + 1 : args.length; @@ -16672,7 +17077,7 @@ var ts; var argCount = getEffectiveArgumentCount(node, args, signature); for (var i = 0; i < argCount; i++) { var arg = getEffectiveArgument(node, args, i); - if (arg === undefined || arg.kind !== 185) { + if (arg === undefined || arg.kind !== 187) { var paramType = getTypeAtPosition(signature, i); var argType = getEffectiveArgumentType(node, i, arg); if (argType === undefined) { @@ -16719,7 +17124,7 @@ var ts; var argCount = getEffectiveArgumentCount(node, args, signature); for (var i = 0; i < argCount; i++) { var arg = getEffectiveArgument(node, args, i); - if (arg === undefined || arg.kind !== 185) { + if (arg === undefined || arg.kind !== 187) { var paramType = getTypeAtPosition(signature, i); var argType = getEffectiveArgumentType(node, i, arg); if (argType === undefined) { @@ -16738,16 +17143,16 @@ var ts; } function getEffectiveCallArguments(node) { var args; - if (node.kind === 168) { + if (node.kind === 170) { var template = node.template; args = [undefined]; - if (template.kind === 181) { + if (template.kind === 183) { ts.forEach(template.templateSpans, function (span) { args.push(span.expression); }); } } - else if (node.kind === 137) { + else if (node.kind === 139) { return undefined; } else { @@ -16756,18 +17161,21 @@ var ts; return args; } function getEffectiveArgumentCount(node, args, signature) { - if (node.kind === 137) { + if (node.kind === 139) { switch (node.parent.kind) { - case 212: - case 184: + case 214: + case 186: return 1; - case 139: - return 2; case 141: + return 2; case 143: - case 144: + case 145: + case 146: + if (languageVersion === 0) { + return 2; + } return signature.parameters.length >= 3 ? 3 : 2; - case 136: + case 138: return 3; } } @@ -16777,20 +17185,20 @@ var ts; } function getEffectiveDecoratorFirstArgumentType(node) { switch (node.kind) { - case 212: - case 184: + case 214: + case 186: var classSymbol = getSymbolOfNode(node); return getTypeOfSymbol(classSymbol); - case 136: + case 138: node = node.parent; - if (node.kind === 142) { + if (node.kind === 144) { var classSymbol_1 = getSymbolOfNode(node); return getTypeOfSymbol(classSymbol_1); } - case 139: case 141: case 143: - case 144: + case 145: + case 146: return getParentTypeOfClassElement(node); default: ts.Debug.fail("Unsupported decorator target."); @@ -16799,25 +17207,25 @@ var ts; } function getEffectiveDecoratorSecondArgumentType(node) { switch (node.kind) { - case 212: + case 214: ts.Debug.fail("Class decorators should not have a second synthetic argument."); return unknownType; - case 136: + case 138: node = node.parent; - if (node.kind === 142) { + if (node.kind === 144) { return anyType; } - case 139: case 141: case 143: - case 144: + case 145: + case 146: var element = node; switch (element.name.kind) { - case 67: + case 69: case 8: case 9: return getStringLiteralType(element.name); - case 134: + case 136: var nameType = checkComputedPropertyName(element.name); if (allConstituentTypesHaveKind(nameType, 16777216)) { return nameType; @@ -16836,17 +17244,17 @@ var ts; } function getEffectiveDecoratorThirdArgumentType(node) { switch (node.kind) { - case 212: + case 214: ts.Debug.fail("Class decorators should not have a third synthetic argument."); return unknownType; - case 136: + case 138: return numberType; - case 139: + case 141: ts.Debug.fail("Property decorators should not have a third synthetic argument."); return unknownType; - case 141: case 143: - case 144: + case 145: + case 146: var propertyType = getTypeOfNode(node); return createTypedPropertyDescriptorType(propertyType); default: @@ -16868,26 +17276,26 @@ var ts; return unknownType; } function getEffectiveArgumentType(node, argIndex, arg) { - if (node.kind === 137) { + if (node.kind === 139) { return getEffectiveDecoratorArgumentType(node, argIndex); } - else if (argIndex === 0 && node.kind === 168) { + else if (argIndex === 0 && node.kind === 170) { return globalTemplateStringsArrayType; } return undefined; } function getEffectiveArgument(node, args, argIndex) { - if (node.kind === 137 || - (argIndex === 0 && node.kind === 168)) { + if (node.kind === 139 || + (argIndex === 0 && node.kind === 170)) { return undefined; } return args[argIndex]; } function getEffectiveArgumentErrorNode(node, argIndex, arg) { - if (node.kind === 137) { + if (node.kind === 139) { return node.expression; } - else if (argIndex === 0 && node.kind === 168) { + else if (argIndex === 0 && node.kind === 170) { return node.template; } else { @@ -16895,12 +17303,12 @@ var ts; } } function resolveCall(node, signatures, candidatesOutArray, headMessage) { - var isTaggedTemplate = node.kind === 168; - var isDecorator = node.kind === 137; + var isTaggedTemplate = node.kind === 170; + var isDecorator = node.kind === 139; var typeArguments; if (!isTaggedTemplate && !isDecorator) { typeArguments = node.typeArguments; - if (node.expression.kind !== 93) { + if (node.expression.kind !== 95) { ts.forEach(typeArguments, checkSourceElement); } } @@ -17038,7 +17446,7 @@ var ts; } } function resolveCallExpression(node, candidatesOutArray) { - if (node.expression.kind === 93) { + if (node.expression.kind === 95) { var superType = checkSuperExpression(node.expression); if (superType !== unknownType) { var baseTypeNode = ts.getClassExtendsHeritageClauseElement(ts.getContainingClass(node)); @@ -17127,16 +17535,16 @@ var ts; } function getDiagnosticHeadMessageForDecoratorResolution(node) { switch (node.parent.kind) { - case 212: - case 184: + case 214: + case 186: return ts.Diagnostics.Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression; - case 136: + case 138: return ts.Diagnostics.Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression; - case 139: - return ts.Diagnostics.Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression; case 141: + return ts.Diagnostics.Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression; case 143: - case 144: + case 145: + case 146: return ts.Diagnostics.Unable_to_resolve_signature_of_method_decorator_when_called_as_an_expression; } } @@ -17164,16 +17572,16 @@ var ts; var links = getNodeLinks(node); if (!links.resolvedSignature || candidatesOutArray) { links.resolvedSignature = anySignature; - if (node.kind === 166) { + if (node.kind === 168) { links.resolvedSignature = resolveCallExpression(node, candidatesOutArray); } - else if (node.kind === 167) { + else if (node.kind === 169) { links.resolvedSignature = resolveNewExpression(node, candidatesOutArray); } - else if (node.kind === 168) { + else if (node.kind === 170) { links.resolvedSignature = resolveTaggedTemplateExpression(node, candidatesOutArray); } - else if (node.kind === 137) { + else if (node.kind === 139) { links.resolvedSignature = resolveDecorator(node, candidatesOutArray); } else { @@ -17185,21 +17593,24 @@ var ts; function checkCallExpression(node) { checkGrammarTypeArguments(node, node.typeArguments) || checkGrammarArguments(node, node.arguments); var signature = getResolvedSignature(node); - if (node.expression.kind === 93) { + if (node.expression.kind === 95) { return voidType; } - if (node.kind === 167) { + if (node.kind === 169) { var declaration = signature.declaration; if (declaration && - declaration.kind !== 142 && - declaration.kind !== 146 && - declaration.kind !== 151) { + declaration.kind !== 144 && + declaration.kind !== 148 && + declaration.kind !== 153) { if (compilerOptions.noImplicitAny) { error(node, ts.Diagnostics.new_expression_whose_target_lacks_a_construct_signature_implicitly_has_an_any_type); } return anyType; } } + if (ts.isInJavaScriptFile(node) && ts.isRequireCall(node)) { + return resolveExternalModuleTypeByLiteral(node.arguments[0]); + } return getReturnTypeOfSignature(signature); } function checkTaggedTemplateExpression(node) { @@ -17234,10 +17645,22 @@ var ts; assignTypeToParameterAndFixTypeParameters(parameter, contextualParameterType, mapper); } } + function assignBindingElementTypes(node) { + if (ts.isBindingPattern(node.name)) { + for (var _i = 0, _a = node.name.elements; _i < _a.length; _i++) { + var element = _a[_i]; + if (element.kind !== 187) { + getSymbolLinks(getSymbolOfNode(element)).type = getTypeForBindingElement(element); + assignBindingElementTypes(element); + } + } + } + } function assignTypeToParameterAndFixTypeParameters(parameter, contextualType, mapper) { var links = getSymbolLinks(parameter); if (!links.type) { links.type = instantiateType(contextualType, mapper); + assignBindingElementTypes(parameter.valueDeclaration); } else if (isInferentialContext(mapper)) { inferTypes(mapper.context, links.type, instantiateType(contextualType, mapper)); @@ -17258,7 +17681,7 @@ var ts; } var isAsync = ts.isAsyncFunctionLike(func); var type; - if (func.body.kind !== 190) { + if (func.body.kind !== 192) { type = checkExpressionCached(func.body, contextualMapper); if (isAsync) { type = checkAwaitedType(type, func, ts.Diagnostics.Return_expression_in_async_function_does_not_have_a_valid_callable_then_member); @@ -17362,7 +17785,7 @@ var ts; }); } function bodyContainsSingleThrowStatement(body) { - return (body.statements.length === 1) && (body.statements[0].kind === 206); + return (body.statements.length === 1) && (body.statements[0].kind === 208); } function checkIfNonVoidFunctionHasReturnExpressionsOrSingleThrowStatment(func, returnType) { if (!produceDiagnostics) { @@ -17371,7 +17794,7 @@ var ts; if (returnType === voidType || isTypeAny(returnType)) { return; } - if (ts.nodeIsMissing(func.body) || func.body.kind !== 190) { + if (ts.nodeIsMissing(func.body) || func.body.kind !== 192) { return; } var bodyBlock = func.body; @@ -17384,9 +17807,9 @@ var ts; error(func.type, ts.Diagnostics.A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value_or_consist_of_a_single_throw_statement); } function checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper) { - ts.Debug.assert(node.kind !== 141 || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 143 || ts.isObjectLiteralMethod(node)); var hasGrammarError = checkGrammarFunctionLikeDeclaration(node); - if (!hasGrammarError && node.kind === 171) { + if (!hasGrammarError && node.kind === 173) { checkGrammarForGenerator(node); } if (contextualMapper === identityMapper && isContextSensitive(node)) { @@ -17422,14 +17845,14 @@ var ts; } } } - if (produceDiagnostics && node.kind !== 141 && node.kind !== 140) { + if (produceDiagnostics && node.kind !== 143 && node.kind !== 142) { checkCollisionWithCapturedSuperVariable(node, node.name); checkCollisionWithCapturedThisVariable(node, node.name); } return type; } function checkFunctionExpressionOrObjectLiteralMethodBody(node) { - ts.Debug.assert(node.kind !== 141 || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 143 || ts.isObjectLiteralMethod(node)); var isAsync = ts.isAsyncFunctionLike(node); if (isAsync) { emitAwaiter = true; @@ -17446,7 +17869,7 @@ var ts; if (!node.type) { getReturnTypeOfSignature(getSignatureFromDeclaration(node)); } - if (node.body.kind === 190) { + if (node.body.kind === 192) { checkSourceElement(node.body); } else { @@ -17478,17 +17901,17 @@ var ts; } function isReferenceOrErrorExpression(n) { switch (n.kind) { - case 67: { + case 69: { var symbol = findSymbol(n); return !symbol || symbol === unknownSymbol || symbol === argumentsSymbol || (symbol.flags & 3) !== 0; } - case 164: { + case 166: { var symbol = findSymbol(n); return !symbol || symbol === unknownSymbol || (symbol.flags & ~8) !== 0; } - case 165: + case 167: return true; - case 170: + case 172: return isReferenceOrErrorExpression(n.expression); default: return false; @@ -17496,12 +17919,12 @@ var ts; } function isConstVariableReference(n) { switch (n.kind) { - case 67: - case 164: { + case 69: + case 166: { var symbol = findSymbol(n); return symbol && (symbol.flags & 3) !== 0 && (getDeclarationFlagsFromSymbol(symbol) & 32768) !== 0; } - case 165: { + case 167: { var index = n.argumentExpression; var symbol = findSymbol(n.expression); if (symbol && index && index.kind === 9) { @@ -17511,7 +17934,7 @@ var ts; } return false; } - case 170: + case 172: return isConstVariableReference(n.expression); default: return false; @@ -17556,15 +17979,15 @@ var ts; switch (node.operator) { case 35: case 36: - case 49: + case 50: if (someConstituentTypeHasKind(operandType, 16777216)) { error(node.operand, ts.Diagnostics.The_0_operator_cannot_be_applied_to_type_symbol, ts.tokenToString(node.operator)); } return numberType; - case 48: + case 49: return booleanType; - case 40: case 41: + case 42: var ok = checkArithmeticOperandType(node.operand, operandType, ts.Diagnostics.An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type); if (ok) { checkReferenceExpression(node.operand, ts.Diagnostics.The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_property_or_indexer, ts.Diagnostics.The_operand_of_an_increment_or_decrement_operator_cannot_be_a_constant); @@ -17619,21 +18042,21 @@ var ts; function isConstEnumSymbol(symbol) { return (symbol.flags & 128) !== 0; } - function checkInstanceOfExpression(node, leftType, rightType) { + function checkInstanceOfExpression(left, right, leftType, rightType) { if (allConstituentTypesHaveKind(leftType, 16777726)) { - error(node.left, ts.Diagnostics.The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_parameter); + error(left, ts.Diagnostics.The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_parameter); } if (!(isTypeAny(rightType) || isTypeSubtypeOf(rightType, globalFunctionType))) { - error(node.right, ts.Diagnostics.The_right_hand_side_of_an_instanceof_expression_must_be_of_type_any_or_of_a_type_assignable_to_the_Function_interface_type); + error(right, ts.Diagnostics.The_right_hand_side_of_an_instanceof_expression_must_be_of_type_any_or_of_a_type_assignable_to_the_Function_interface_type); } return booleanType; } - function checkInExpression(node, leftType, rightType) { + function checkInExpression(left, right, leftType, rightType) { if (!isTypeAnyOrAllConstituentTypesHaveKind(leftType, 258 | 132 | 16777216)) { - error(node.left, ts.Diagnostics.The_left_hand_side_of_an_in_expression_must_be_of_type_any_string_number_or_symbol); + error(left, ts.Diagnostics.The_left_hand_side_of_an_in_expression_must_be_of_type_any_string_number_or_symbol); } if (!isTypeAnyOrAllConstituentTypesHaveKind(rightType, 80896 | 512)) { - error(node.right, ts.Diagnostics.The_right_hand_side_of_an_in_expression_must_be_of_type_any_an_object_type_or_a_type_parameter); + error(right, ts.Diagnostics.The_right_hand_side_of_an_in_expression_must_be_of_type_any_an_object_type_or_a_type_parameter); } return booleanType; } @@ -17641,7 +18064,7 @@ var ts; var properties = node.properties; for (var _i = 0; _i < properties.length; _i++) { var p = properties[_i]; - if (p.kind === 243 || p.kind === 244) { + if (p.kind === 245 || p.kind === 246) { var name_13 = p.name; var type = isTypeAny(sourceType) ? sourceType @@ -17649,7 +18072,12 @@ var ts; isNumericLiteralName(name_13.text) && getIndexTypeOfType(sourceType, 1) || getIndexTypeOfType(sourceType, 0); if (type) { - checkDestructuringAssignment(p.initializer || name_13, type); + if (p.kind === 246) { + checkDestructuringAssignment(p, type); + } + else { + checkDestructuringAssignment(p.initializer || name_13, type); + } } else { error(name_13, ts.Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(sourceType), ts.declarationNameToString(name_13)); @@ -17666,8 +18094,8 @@ var ts; var elements = node.elements; for (var i = 0; i < elements.length; i++) { var e = elements[i]; - if (e.kind !== 185) { - if (e.kind !== 183) { + if (e.kind !== 187) { + if (e.kind !== 185) { var propName = "" + i; var type = isTypeAny(sourceType) ? sourceType @@ -17692,7 +18120,7 @@ var ts; } else { var restExpression = e.expression; - if (restExpression.kind === 179 && restExpression.operatorToken.kind === 55) { + if (restExpression.kind === 181 && restExpression.operatorToken.kind === 56) { error(restExpression.operatorToken, ts.Diagnostics.A_rest_element_cannot_have_an_initializer); } else { @@ -17704,15 +18132,26 @@ var ts; } return sourceType; } - function checkDestructuringAssignment(target, sourceType, contextualMapper) { - if (target.kind === 179 && target.operatorToken.kind === 55) { + function checkDestructuringAssignment(exprOrAssignment, sourceType, contextualMapper) { + var target; + if (exprOrAssignment.kind === 246) { + var prop = exprOrAssignment; + if (prop.objectAssignmentInitializer) { + checkBinaryLikeExpression(prop.name, prop.equalsToken, prop.objectAssignmentInitializer, contextualMapper); + } + target = exprOrAssignment.name; + } + else { + target = exprOrAssignment; + } + if (target.kind === 181 && target.operatorToken.kind === 56) { checkBinaryExpression(target, contextualMapper); target = target.left; } - if (target.kind === 163) { + if (target.kind === 165) { return checkObjectLiteralAssignment(target, sourceType, contextualMapper); } - if (target.kind === 162) { + if (target.kind === 164) { return checkArrayLiteralAssignment(target, sourceType, contextualMapper); } return checkReferenceAssignment(target, sourceType, contextualMapper); @@ -17725,33 +18164,38 @@ var ts; return sourceType; } function checkBinaryExpression(node, contextualMapper) { - var operator = node.operatorToken.kind; - if (operator === 55 && (node.left.kind === 163 || node.left.kind === 162)) { - return checkDestructuringAssignment(node.left, checkExpression(node.right, contextualMapper), contextualMapper); + return checkBinaryLikeExpression(node.left, node.operatorToken, node.right, contextualMapper, node); + } + function checkBinaryLikeExpression(left, operatorToken, right, contextualMapper, errorNode) { + var operator = operatorToken.kind; + if (operator === 56 && (left.kind === 165 || left.kind === 164)) { + return checkDestructuringAssignment(left, checkExpression(right, contextualMapper), contextualMapper); } - var leftType = checkExpression(node.left, contextualMapper); - var rightType = checkExpression(node.right, contextualMapper); + var leftType = checkExpression(left, contextualMapper); + var rightType = checkExpression(right, contextualMapper); switch (operator) { case 37: - case 58: case 38: case 59: - case 39: case 60: - case 36: - case 57: - case 42: + case 39: case 61: - case 43: + case 40: case 62: - case 44: + case 36: + case 58: + case 43: case 63: - case 46: + case 44: + case 64: + case 45: case 65: case 47: + case 67: + case 48: + case 68: + case 46: case 66: - case 45: - case 64: if (leftType.flags & (32 | 64)) leftType = rightType; if (rightType.flags & (32 | 64)) @@ -17759,19 +18203,19 @@ var ts; var suggestedOperator; if ((leftType.flags & 8) && (rightType.flags & 8) && - (suggestedOperator = getSuggestedBooleanOperator(node.operatorToken.kind)) !== undefined) { - error(node, ts.Diagnostics.The_0_operator_is_not_allowed_for_boolean_types_Consider_using_1_instead, ts.tokenToString(node.operatorToken.kind), ts.tokenToString(suggestedOperator)); + (suggestedOperator = getSuggestedBooleanOperator(operatorToken.kind)) !== undefined) { + error(errorNode || operatorToken, ts.Diagnostics.The_0_operator_is_not_allowed_for_boolean_types_Consider_using_1_instead, ts.tokenToString(operatorToken.kind), ts.tokenToString(suggestedOperator)); } else { - var leftOk = checkArithmeticOperandType(node.left, leftType, ts.Diagnostics.The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type); - var rightOk = checkArithmeticOperandType(node.right, rightType, ts.Diagnostics.The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type); + var leftOk = checkArithmeticOperandType(left, leftType, ts.Diagnostics.The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type); + var rightOk = checkArithmeticOperandType(right, rightType, ts.Diagnostics.The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type); if (leftOk && rightOk) { checkAssignmentOperator(numberType); } } return numberType; case 35: - case 56: + case 57: if (leftType.flags & (32 | 64)) leftType = rightType; if (rightType.flags & (32 | 64)) @@ -17795,7 +18239,7 @@ var ts; reportOperatorError(); return anyType; } - if (operator === 56) { + if (operator === 57) { checkAssignmentOperator(resultType); } return resultType; @@ -17814,23 +18258,23 @@ var ts; reportOperatorError(); } return booleanType; - case 89: - return checkInstanceOfExpression(node, leftType, rightType); - case 88: - return checkInExpression(node, leftType, rightType); - case 50: - return rightType; + case 91: + return checkInstanceOfExpression(left, right, leftType, rightType); + case 90: + return checkInExpression(left, right, leftType, rightType); case 51: + return rightType; + case 52: return getUnionType([leftType, rightType]); - case 55: + case 56: checkAssignmentOperator(rightType); return getRegularTypeOfObjectLiteral(rightType); case 24: return rightType; } function checkForDisallowedESSymbolOperand(operator) { - var offendingSymbolOperand = someConstituentTypeHasKind(leftType, 16777216) ? node.left : - someConstituentTypeHasKind(rightType, 16777216) ? node.right : + var offendingSymbolOperand = someConstituentTypeHasKind(leftType, 16777216) ? left : + someConstituentTypeHasKind(rightType, 16777216) ? right : undefined; if (offendingSymbolOperand) { error(offendingSymbolOperand, ts.Diagnostics.The_0_operator_cannot_be_applied_to_type_symbol, ts.tokenToString(operator)); @@ -17840,29 +18284,29 @@ var ts; } function getSuggestedBooleanOperator(operator) { switch (operator) { - case 46: - case 65: - return 51; case 47: - case 66: + case 67: + return 52; + case 48: + case 68: return 33; - case 45: - case 64: - return 50; + case 46: + case 66: + return 51; default: return undefined; } } function checkAssignmentOperator(valueType) { - if (produceDiagnostics && operator >= 55 && operator <= 66) { - var ok = checkReferenceExpression(node.left, ts.Diagnostics.Invalid_left_hand_side_of_assignment_expression, ts.Diagnostics.Left_hand_side_of_assignment_expression_cannot_be_a_constant); + if (produceDiagnostics && operator >= 56 && operator <= 68) { + var ok = checkReferenceExpression(left, ts.Diagnostics.Invalid_left_hand_side_of_assignment_expression, ts.Diagnostics.Left_hand_side_of_assignment_expression_cannot_be_a_constant); if (ok) { - checkTypeAssignableTo(valueType, leftType, node.left, undefined); + checkTypeAssignableTo(valueType, leftType, left, undefined); } } } function reportOperatorError() { - error(node, ts.Diagnostics.Operator_0_cannot_be_applied_to_types_1_and_2, ts.tokenToString(node.operatorToken.kind), typeToString(leftType), typeToString(rightType)); + error(errorNode || operatorToken, ts.Diagnostics.Operator_0_cannot_be_applied_to_types_1_and_2, ts.tokenToString(operatorToken.kind), typeToString(leftType), typeToString(rightType)); } } function isYieldExpressionInClass(node) { @@ -17938,14 +18382,14 @@ var ts; return links.resolvedType; } function checkPropertyAssignment(node, contextualMapper) { - if (node.name.kind === 134) { + if (node.name.kind === 136) { checkComputedPropertyName(node.name); } return checkExpression(node.initializer, contextualMapper); } function checkObjectLiteralMethod(node, contextualMapper) { checkGrammarMethod(node); - if (node.name.kind === 134) { + if (node.name.kind === 136) { checkComputedPropertyName(node.name); } var uninstantiatedType = checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); @@ -17968,7 +18412,7 @@ var ts; } function checkExpression(node, contextualMapper) { var type; - if (node.kind === 133) { + if (node.kind === 135) { type = checkQualifiedName(node); } else { @@ -17976,9 +18420,9 @@ var ts; type = instantiateTypeWithSingleGenericCallSignature(node, uninstantiatedType, contextualMapper); } if (isConstEnumObjectType(type)) { - var ok = (node.parent.kind === 164 && node.parent.expression === node) || - (node.parent.kind === 165 && node.parent.expression === node) || - ((node.kind === 67 || node.kind === 133) && isInRightSideOfImportOrExportAssignment(node)); + var ok = (node.parent.kind === 166 && node.parent.expression === node) || + (node.parent.kind === 167 && node.parent.expression === node) || + ((node.kind === 69 || node.kind === 135) && isInRightSideOfImportOrExportAssignment(node)); if (!ok) { error(node, ts.Diagnostics.const_enums_can_only_be_used_in_property_or_index_access_expressions_or_the_right_hand_side_of_an_import_declaration_or_export_assignment); } @@ -17991,78 +18435,78 @@ var ts; } function checkExpressionWorker(node, contextualMapper) { switch (node.kind) { - case 67: + case 69: return checkIdentifier(node); - case 95: - return checkThisExpression(node); - case 93: - return checkSuperExpression(node); - case 91: - return nullType; case 97: - case 82: + return checkThisExpression(node); + case 95: + return checkSuperExpression(node); + case 93: + return nullType; + case 99: + case 84: return booleanType; case 8: return checkNumericLiteral(node); - case 181: + case 183: return checkTemplateExpression(node); case 9: case 11: return stringType; case 10: return globalRegExpType; - case 162: - return checkArrayLiteral(node, contextualMapper); - case 163: - return checkObjectLiteral(node, contextualMapper); case 164: - return checkPropertyAccessExpression(node); + return checkArrayLiteral(node, contextualMapper); case 165: - return checkIndexedAccess(node); + return checkObjectLiteral(node, contextualMapper); case 166: + return checkPropertyAccessExpression(node); case 167: - return checkCallExpression(node); + return checkIndexedAccess(node); case 168: - return checkTaggedTemplateExpression(node); - case 170: - return checkExpression(node.expression, contextualMapper); - case 184: - return checkClassExpression(node); - case 171: - case 172: - return checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); - case 174: - return checkTypeOfExpression(node); case 169: - case 187: - return checkAssertion(node); + return checkCallExpression(node); + case 170: + return checkTaggedTemplateExpression(node); + case 172: + return checkExpression(node.expression, contextualMapper); + case 186: + return checkClassExpression(node); case 173: - return checkDeleteExpression(node); - case 175: - return checkVoidExpression(node); + case 174: + return checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); case 176: - return checkAwaitExpression(node); + return checkTypeOfExpression(node); + case 171: + case 189: + return checkAssertion(node); + case 175: + return checkDeleteExpression(node); case 177: - return checkPrefixUnaryExpression(node); + return checkVoidExpression(node); case 178: - return checkPostfixUnaryExpression(node); + return checkAwaitExpression(node); case 179: - return checkBinaryExpression(node, contextualMapper); + return checkPrefixUnaryExpression(node); case 180: - return checkConditionalExpression(node, contextualMapper); - case 183: - return checkSpreadElementExpression(node, contextualMapper); - case 185: - return undefinedType; + return checkPostfixUnaryExpression(node); + case 181: + return checkBinaryExpression(node, contextualMapper); case 182: + return checkConditionalExpression(node, contextualMapper); + case 185: + return checkSpreadElementExpression(node, contextualMapper); + case 187: + return undefinedType; + case 184: return checkYieldExpression(node); - case 238: + case 240: return checkJsxExpression(node); - case 231: - return checkJsxElement(node); - case 232: - return checkJsxSelfClosingElement(node); case 233: + return checkJsxElement(node); + case 234: + return checkJsxSelfClosingElement(node); + case 235: ts.Debug.fail("Shouldn't ever directly check a JsxOpeningElement"); } return unknownType; @@ -18083,7 +18527,7 @@ var ts; var func = ts.getContainingFunction(node); if (node.flags & 112) { func = ts.getContainingFunction(node); - if (!(func.kind === 142 && ts.nodeIsPresent(func.body))) { + if (!(func.kind === 144 && ts.nodeIsPresent(func.body))) { error(node, ts.Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation); } } @@ -18098,15 +18542,15 @@ var ts; if (!node.asteriskToken || !node.body) { return false; } - return node.kind === 141 || - node.kind === 211 || - node.kind === 171; + return node.kind === 143 || + node.kind === 213 || + node.kind === 173; } function getTypePredicateParameterIndex(parameterList, parameter) { if (parameterList) { for (var i = 0; i < parameterList.length; i++) { var param = parameterList[i]; - if (param.name.kind === 67 && + if (param.name.kind === 69 && param.name.text === parameter.text) { return i; } @@ -18116,30 +18560,30 @@ var ts; } function isInLegalTypePredicatePosition(node) { switch (node.parent.kind) { - case 172: - case 145: - case 211: - case 171: - case 150: - case 141: - case 140: + case 174: + case 147: + case 213: + case 173: + case 152: + case 143: + case 142: return node === node.parent.type; } return false; } function checkSignatureDeclaration(node) { - if (node.kind === 147) { + if (node.kind === 149) { checkGrammarIndexSignature(node); } - else if (node.kind === 150 || node.kind === 211 || node.kind === 151 || - node.kind === 145 || node.kind === 142 || - node.kind === 146) { + else if (node.kind === 152 || node.kind === 213 || node.kind === 153 || + node.kind === 147 || node.kind === 144 || + node.kind === 148) { checkGrammarFunctionLikeDeclaration(node); } checkTypeParameters(node.typeParameters); ts.forEach(node.parameters, checkParameter); if (node.type) { - if (node.type.kind === 148) { + if (node.type.kind === 150) { var typePredicate = getSignatureFromDeclaration(node).typePredicate; var typePredicateNode = node.type; if (isInLegalTypePredicatePosition(typePredicateNode)) { @@ -18158,19 +18602,19 @@ var ts; if (hasReportedError) { break; } - if (param.name.kind === 159 || - param.name.kind === 160) { + if (param.name.kind === 161 || + param.name.kind === 162) { (function checkBindingPattern(pattern) { for (var _i = 0, _a = pattern.elements; _i < _a.length; _i++) { var element = _a[_i]; - if (element.name.kind === 67 && + if (element.name.kind === 69 && element.name.text === typePredicate.parameterName) { error(typePredicateNode.parameterName, ts.Diagnostics.A_type_predicate_cannot_reference_element_0_in_a_binding_pattern, typePredicate.parameterName); hasReportedError = true; break; } - else if (element.name.kind === 160 || - element.name.kind === 159) { + else if (element.name.kind === 162 || + element.name.kind === 161) { checkBindingPattern(element.name); } } @@ -18194,10 +18638,10 @@ var ts; checkCollisionWithArgumentsInGeneratedCode(node); if (compilerOptions.noImplicitAny && !node.type) { switch (node.kind) { - case 146: + case 148: error(node, ts.Diagnostics.Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; - case 145: + case 147: error(node, ts.Diagnostics.Call_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; } @@ -18219,7 +18663,7 @@ var ts; checkSpecializedSignatureDeclaration(node); } function checkTypeForDuplicateIndexSignatures(node) { - if (node.kind === 213) { + if (node.kind === 215) { var nodeSymbol = getSymbolOfNode(node); if (nodeSymbol.declarations.length > 0 && nodeSymbol.declarations[0] !== node) { return; @@ -18234,7 +18678,7 @@ var ts; var declaration = decl; if (declaration.parameters.length === 1 && declaration.parameters[0].type) { switch (declaration.parameters[0].type.kind) { - case 128: + case 130: if (!seenStringIndexer) { seenStringIndexer = true; } @@ -18242,7 +18686,7 @@ var ts; error(declaration, ts.Diagnostics.Duplicate_string_index_signature); } break; - case 126: + case 128: if (!seenNumericIndexer) { seenNumericIndexer = true; } @@ -18282,7 +18726,7 @@ var ts; return; } function isSuperCallExpression(n) { - return n.kind === 166 && n.expression.kind === 93; + return n.kind === 168 && n.expression.kind === 95; } function containsSuperCallAsComputedPropertyName(n) { return n.name && containsSuperCall(n.name); @@ -18300,15 +18744,15 @@ var ts; return ts.forEachChild(n, containsSuperCall); } function markThisReferencesAsErrors(n) { - if (n.kind === 95) { + if (n.kind === 97) { error(n, ts.Diagnostics.this_cannot_be_referenced_in_current_location); } - else if (n.kind !== 171 && n.kind !== 211) { + else if (n.kind !== 173 && n.kind !== 213) { ts.forEachChild(n, markThisReferencesAsErrors); } } function isInstancePropertyWithInitializer(n) { - return n.kind === 139 && + return n.kind === 141 && !(n.flags & 128) && !!n.initializer; } @@ -18328,7 +18772,7 @@ var ts; var superCallStatement; for (var _i = 0; _i < statements.length; _i++) { var statement = statements[_i]; - if (statement.kind === 193 && isSuperCallExpression(statement.expression)) { + if (statement.kind === 195 && isSuperCallExpression(statement.expression)) { superCallStatement = statement; break; } @@ -18352,13 +18796,13 @@ var ts; function checkAccessorDeclaration(node) { if (produceDiagnostics) { checkGrammarFunctionLikeDeclaration(node) || checkGrammarAccessor(node) || checkGrammarComputedPropertyName(node.name); - if (node.kind === 143) { + if (node.kind === 145) { if (!ts.isInAmbientContext(node) && ts.nodeIsPresent(node.body) && !(bodyContainsAReturnStatement(node.body) || bodyContainsSingleThrowStatement(node.body))) { error(node.name, ts.Diagnostics.A_get_accessor_must_return_a_value_or_consist_of_a_single_throw_statement); } } if (!ts.hasDynamicName(node)) { - var otherKind = node.kind === 143 ? 144 : 143; + var otherKind = node.kind === 145 ? 146 : 145; var otherAccessor = ts.getDeclarationOfKind(node.symbol, otherKind); if (otherAccessor) { if (((node.flags & 112) !== (otherAccessor.flags & 112))) { @@ -18443,9 +18887,9 @@ var ts; return; } var signaturesToCheck; - if (!signatureDeclarationNode.name && signatureDeclarationNode.parent && signatureDeclarationNode.parent.kind === 213) { - ts.Debug.assert(signatureDeclarationNode.kind === 145 || signatureDeclarationNode.kind === 146); - var signatureKind = signatureDeclarationNode.kind === 145 ? 0 : 1; + if (!signatureDeclarationNode.name && signatureDeclarationNode.parent && signatureDeclarationNode.parent.kind === 215) { + ts.Debug.assert(signatureDeclarationNode.kind === 147 || signatureDeclarationNode.kind === 148); + var signatureKind = signatureDeclarationNode.kind === 147 ? 0 : 1; var containingSymbol = getSymbolOfNode(signatureDeclarationNode.parent); var containingType = getDeclaredTypeOfSymbol(containingSymbol); signaturesToCheck = getSignaturesOfType(containingType, signatureKind); @@ -18463,7 +18907,7 @@ var ts; } function getEffectiveDeclarationFlags(n, flagsToCheck) { var flags = ts.getCombinedNodeFlags(n); - if (n.parent.kind !== 213 && ts.isInAmbientContext(n)) { + if (n.parent.kind !== 215 && ts.isInAmbientContext(n)) { if (!(flags & 2)) { flags |= 1; } @@ -18539,7 +18983,7 @@ var ts; if (subsequentNode.kind === node.kind) { var errorNode_1 = subsequentNode.name || subsequentNode; if (node.name && subsequentNode.name && node.name.text === subsequentNode.name.text) { - ts.Debug.assert(node.kind === 141 || node.kind === 140); + ts.Debug.assert(node.kind === 143 || node.kind === 142); ts.Debug.assert((node.flags & 128) !== (subsequentNode.flags & 128)); var diagnostic = node.flags & 128 ? ts.Diagnostics.Function_overload_must_be_static : ts.Diagnostics.Function_overload_must_not_be_static; error(errorNode_1, diagnostic); @@ -18571,11 +19015,11 @@ var ts; var current = declarations[_i]; var node = current; var inAmbientContext = ts.isInAmbientContext(node); - var inAmbientContextOrInterface = node.parent.kind === 213 || node.parent.kind === 153 || inAmbientContext; + var inAmbientContextOrInterface = node.parent.kind === 215 || node.parent.kind === 155 || inAmbientContext; if (inAmbientContextOrInterface) { previousDeclaration = undefined; } - if (node.kind === 211 || node.kind === 141 || node.kind === 140 || node.kind === 142) { + if (node.kind === 213 || node.kind === 143 || node.kind === 142 || node.kind === 144) { var currentNodeFlags = getEffectiveDeclarationFlags(node, flagsToCheck); someNodeFlags |= currentNodeFlags; allNodeFlags &= currentNodeFlags; @@ -18688,16 +19132,16 @@ var ts; } function getDeclarationSpaces(d) { switch (d.kind) { - case 213: + case 215: return 2097152; - case 216: + case 218: return d.name.kind === 9 || ts.getModuleInstanceState(d) !== 0 ? 4194304 | 1048576 : 4194304; - case 212: - case 215: + case 214: + case 217: return 2097152 | 1048576; - case 219: + case 221: var result = 0; var target = resolveAlias(getSymbolOfNode(d)); ts.forEach(target.declarations, function (d) { result |= getDeclarationSpaces(d); }); @@ -18708,7 +19152,8 @@ var ts; } } function checkNonThenableType(type, location, message) { - if (!(type.flags & 1) && isTypeAssignableTo(type, getGlobalThenableType())) { + type = getWidenedType(type); + if (!isTypeAny(type) && isTypeAssignableTo(type, getGlobalThenableType())) { if (location) { if (!message) { message = ts.Diagnostics.Operand_for_await_does_not_have_a_valid_callable_then_member; @@ -18823,22 +19268,22 @@ var ts; var headMessage = getDiagnosticHeadMessageForDecoratorResolution(node); var errorInfo; switch (node.parent.kind) { - case 212: + case 214: var classSymbol = getSymbolOfNode(node.parent); var classConstructorType = getTypeOfSymbol(classSymbol); expectedReturnType = getUnionType([classConstructorType, voidType]); break; - case 136: + case 138: expectedReturnType = voidType; errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.The_return_type_of_a_parameter_decorator_function_must_be_either_void_or_any); break; - case 139: + case 141: expectedReturnType = voidType; errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.The_return_type_of_a_property_decorator_function_must_be_either_void_or_any); break; - case 141: case 143: - case 144: + case 145: + case 146: var methodType = getTypeOfNode(node.parent); var descriptorType = createTypedPropertyDescriptorType(methodType); expectedReturnType = getUnionType([descriptorType, voidType]); @@ -18847,9 +19292,9 @@ var ts; checkTypeAssignableTo(returnType, expectedReturnType, node, headMessage, errorInfo); } function checkTypeNodeAsExpression(node) { - if (node && node.kind === 149) { + if (node && node.kind === 151) { var root = getFirstIdentifier(node.typeName); - var meaning = root.parent.kind === 149 ? 793056 : 1536; + var meaning = root.parent.kind === 151 ? 793056 : 1536; var rootSymbol = resolveName(root, root.text, meaning | 8388608, undefined, undefined); if (rootSymbol && rootSymbol.flags & 8388608) { var aliasTarget = resolveAlias(rootSymbol); @@ -18861,19 +19306,19 @@ var ts; } function checkTypeAnnotationAsExpression(node) { switch (node.kind) { - case 139: - checkTypeNodeAsExpression(node.type); - break; - case 136: - checkTypeNodeAsExpression(node.type); - break; case 141: checkTypeNodeAsExpression(node.type); break; + case 138: + checkTypeNodeAsExpression(node.type); + break; case 143: checkTypeNodeAsExpression(node.type); break; - case 144: + case 145: + checkTypeNodeAsExpression(node.type); + break; + case 146: checkTypeNodeAsExpression(ts.getSetAccessorTypeAnnotationNode(node)); break; } @@ -18896,24 +19341,24 @@ var ts; } if (compilerOptions.emitDecoratorMetadata) { switch (node.kind) { - case 212: + case 214: var constructor = ts.getFirstConstructorWithBody(node); if (constructor) { checkParameterTypeAnnotationsAsExpressions(constructor); } break; - case 141: - checkParameterTypeAnnotationsAsExpressions(node); - case 144: case 143: - case 139: - case 136: + checkParameterTypeAnnotationsAsExpressions(node); + case 146: + case 145: + case 141: + case 138: checkTypeAnnotationAsExpression(node); break; } } emitDecorate = true; - if (node.kind === 136) { + if (node.kind === 138) { emitParam = true; } ts.forEach(node.decorators, checkDecorator); @@ -18931,12 +19376,9 @@ var ts; checkSignatureDeclaration(node); var isAsync = ts.isAsyncFunctionLike(node); if (isAsync) { - if (!compilerOptions.experimentalAsyncFunctions) { - error(node, ts.Diagnostics.Experimental_support_for_async_functions_is_a_feature_that_is_subject_to_change_in_a_future_release_Specify_experimentalAsyncFunctions_to_remove_this_warning); - } emitAwaiter = true; } - if (node.name && node.name.kind === 134) { + if (node.name && node.name.kind === 136) { checkComputedPropertyName(node.name); } if (!ts.hasDynamicName(node)) { @@ -18971,11 +19413,11 @@ var ts; } } function checkBlock(node) { - if (node.kind === 190) { + if (node.kind === 192) { checkGrammarStatementInAmbientContext(node); } ts.forEach(node.statements, checkSourceElement); - if (ts.isFunctionBlock(node) || node.kind === 217) { + if (ts.isFunctionBlock(node) || node.kind === 219) { checkFunctionAndClassExpressionBodies(node); } } @@ -18993,19 +19435,19 @@ var ts; if (!(identifier && identifier.text === name)) { return false; } - if (node.kind === 139 || - node.kind === 138 || - node.kind === 141 || + if (node.kind === 141 || node.kind === 140 || node.kind === 143 || - node.kind === 144) { + node.kind === 142 || + node.kind === 145 || + node.kind === 146) { return false; } if (ts.isInAmbientContext(node)) { return false; } var root = ts.getRootDeclaration(node); - if (root.kind === 136 && ts.nodeIsMissing(root.parent.body)) { + if (root.kind === 138 && ts.nodeIsMissing(root.parent.body)) { return false; } return true; @@ -19019,7 +19461,7 @@ var ts; var current = node; while (current) { if (getNodeCheckFlags(current) & 4) { - var isDeclaration_1 = node.kind !== 67; + var isDeclaration_1 = node.kind !== 69; if (isDeclaration_1) { error(node.name, ts.Diagnostics.Duplicate_identifier_this_Compiler_uses_variable_declaration_this_to_capture_this_reference); } @@ -19040,7 +19482,7 @@ var ts; return; } if (ts.getClassExtendsHeritageClauseElement(enclosingClass)) { - var isDeclaration_2 = node.kind !== 67; + var isDeclaration_2 = node.kind !== 69; if (isDeclaration_2) { error(node, ts.Diagnostics.Duplicate_identifier_super_Compiler_uses_super_to_capture_base_class_reference); } @@ -19053,11 +19495,11 @@ var ts; if (!needCollisionCheckForIdentifier(node, name, "require") && !needCollisionCheckForIdentifier(node, name, "exports")) { return; } - if (node.kind === 216 && ts.getModuleInstanceState(node) !== 1) { + if (node.kind === 218 && ts.getModuleInstanceState(node) !== 1) { return; } var parent = getDeclarationContainer(node); - if (parent.kind === 246 && ts.isExternalModule(parent)) { + if (parent.kind === 248 && ts.isExternalOrCommonJsModule(parent)) { error(name, ts.Diagnostics.Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module, ts.declarationNameToString(name), ts.declarationNameToString(name)); } } @@ -19065,7 +19507,7 @@ var ts; if ((ts.getCombinedNodeFlags(node) & 49152) !== 0 || ts.isParameterDeclaration(node)) { return; } - if (node.kind === 209 && !node.initializer) { + if (node.kind === 211 && !node.initializer) { return; } var symbol = getSymbolOfNode(node); @@ -19075,15 +19517,15 @@ var ts; localDeclarationSymbol !== symbol && localDeclarationSymbol.flags & 2) { if (getDeclarationFlagsFromSymbol(localDeclarationSymbol) & 49152) { - var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 210); - var container = varDeclList.parent.kind === 191 && varDeclList.parent.parent + var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 212); + var container = varDeclList.parent.kind === 193 && varDeclList.parent.parent ? varDeclList.parent.parent : undefined; var namesShareScope = container && - (container.kind === 190 && ts.isFunctionLike(container.parent) || - container.kind === 217 || - container.kind === 216 || - container.kind === 246); + (container.kind === 192 && ts.isFunctionLike(container.parent) || + container.kind === 219 || + container.kind === 218 || + container.kind === 248); if (!namesShareScope) { var name_14 = symbolToString(localDeclarationSymbol); error(node, ts.Diagnostics.Cannot_initialize_outer_scoped_variable_0_in_the_same_scope_as_block_scoped_declaration_1, name_14, name_14); @@ -19093,16 +19535,16 @@ var ts; } } function checkParameterInitializer(node) { - if (ts.getRootDeclaration(node).kind !== 136) { + if (ts.getRootDeclaration(node).kind !== 138) { return; } var func = ts.getContainingFunction(node); visit(node.initializer); function visit(n) { - if (n.kind === 67) { + if (n.kind === 69) { var referencedSymbol = getNodeLinks(n).resolvedSymbol; if (referencedSymbol && referencedSymbol !== unknownSymbol && getSymbol(func.locals, referencedSymbol.name, 107455) === referencedSymbol) { - if (referencedSymbol.valueDeclaration.kind === 136) { + if (referencedSymbol.valueDeclaration.kind === 138) { if (referencedSymbol.valueDeclaration === node) { error(n, ts.Diagnostics.Parameter_0_cannot_be_referenced_in_its_initializer, ts.declarationNameToString(node.name)); return; @@ -19122,7 +19564,7 @@ var ts; function checkVariableLikeDeclaration(node) { checkDecorators(node); checkSourceElement(node.type); - if (node.name.kind === 134) { + if (node.name.kind === 136) { checkComputedPropertyName(node.name); if (node.initializer) { checkExpressionCached(node.initializer); @@ -19131,7 +19573,7 @@ var ts; if (ts.isBindingPattern(node.name)) { ts.forEach(node.name.elements, checkSourceElement); } - if (node.initializer && ts.getRootDeclaration(node).kind === 136 && ts.nodeIsMissing(ts.getContainingFunction(node).body)) { + if (node.initializer && ts.getRootDeclaration(node).kind === 138 && ts.nodeIsMissing(ts.getContainingFunction(node).body)) { error(node, ts.Diagnostics.A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation); return; } @@ -19159,9 +19601,9 @@ var ts; checkTypeAssignableTo(checkExpressionCached(node.initializer), declarationType, node, undefined); } } - if (node.kind !== 139 && node.kind !== 138) { + if (node.kind !== 141 && node.kind !== 140) { checkExportsOnMergedDeclarations(node); - if (node.kind === 209 || node.kind === 161) { + if (node.kind === 211 || node.kind === 163) { checkVarDeclaredNamesNotShadowed(node); } checkCollisionWithCapturedSuperVariable(node, node.name); @@ -19182,7 +19624,7 @@ var ts; ts.forEach(node.declarationList.declarations, checkSourceElement); } function checkGrammarDisallowedModifiersOnObjectLiteralExpressionMethod(node) { - if (node.modifiers && node.parent.kind === 163) { + if (node.modifiers && node.parent.kind === 165) { if (ts.isAsyncFunctionLike(node)) { if (node.modifiers.length > 1) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); @@ -19215,12 +19657,12 @@ var ts; } function checkForStatement(node) { if (!checkGrammarStatementInAmbientContext(node)) { - if (node.initializer && node.initializer.kind === 210) { + if (node.initializer && node.initializer.kind === 212) { checkGrammarVariableDeclarationList(node.initializer); } } if (node.initializer) { - if (node.initializer.kind === 210) { + if (node.initializer.kind === 212) { ts.forEach(node.initializer.declarations, checkVariableDeclaration); } else { @@ -19235,13 +19677,13 @@ var ts; } function checkForOfStatement(node) { checkGrammarForInOrForOfStatement(node); - if (node.initializer.kind === 210) { + if (node.initializer.kind === 212) { checkForInOrForOfVariableDeclaration(node); } else { var varExpr = node.initializer; var iteratedType = checkRightHandSideOfForOf(node.expression); - if (varExpr.kind === 162 || varExpr.kind === 163) { + if (varExpr.kind === 164 || varExpr.kind === 165) { checkDestructuringAssignment(varExpr, iteratedType || unknownType); } else { @@ -19256,7 +19698,7 @@ var ts; } function checkForInStatement(node) { checkGrammarForInOrForOfStatement(node); - if (node.initializer.kind === 210) { + if (node.initializer.kind === 212) { var variable = node.initializer.declarations[0]; if (variable && ts.isBindingPattern(variable.name)) { error(variable.name, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern); @@ -19266,7 +19708,7 @@ var ts; else { var varExpr = node.initializer; var leftType = checkExpression(varExpr); - if (varExpr.kind === 162 || varExpr.kind === 163) { + if (varExpr.kind === 164 || varExpr.kind === 165) { error(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern); } else if (!isTypeAnyOrAllConstituentTypesHaveKind(leftType, 258)) { @@ -19428,7 +19870,7 @@ var ts; checkGrammarStatementInAmbientContext(node) || checkGrammarBreakOrContinueStatement(node); } function isGetAccessorWithAnnotatatedSetAccessor(node) { - return !!(node.kind === 143 && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(node.symbol, 144))); + return !!(node.kind === 145 && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(node.symbol, 146))); } function checkReturnStatement(node) { if (!checkGrammarStatementInAmbientContext(node)) { @@ -19446,10 +19888,10 @@ var ts; if (func.asteriskToken) { return; } - if (func.kind === 144) { + if (func.kind === 146) { error(node.expression, ts.Diagnostics.Setters_cannot_return_a_value); } - else if (func.kind === 142) { + else if (func.kind === 144) { if (!isTypeAssignableTo(exprType, returnType)) { error(node.expression, ts.Diagnostics.Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class); } @@ -19458,7 +19900,9 @@ var ts; if (ts.isAsyncFunctionLike(func)) { var promisedType = getPromisedType(returnType); var awaitedType = checkAwaitedType(exprType, node.expression, ts.Diagnostics.Return_expression_in_async_function_does_not_have_a_valid_callable_then_member); - checkTypeAssignableTo(awaitedType, promisedType, node.expression); + if (promisedType) { + checkTypeAssignableTo(awaitedType, promisedType, node.expression); + } } else { checkTypeAssignableTo(exprType, returnType, node.expression); @@ -19482,7 +19926,7 @@ var ts; var hasDuplicateDefaultClause = false; var expressionType = checkExpression(node.expression); ts.forEach(node.caseBlock.clauses, function (clause) { - if (clause.kind === 240 && !hasDuplicateDefaultClause) { + if (clause.kind === 242 && !hasDuplicateDefaultClause) { if (firstDefaultClause === undefined) { firstDefaultClause = clause; } @@ -19494,7 +19938,7 @@ var ts; hasDuplicateDefaultClause = true; } } - if (produceDiagnostics && clause.kind === 239) { + if (produceDiagnostics && clause.kind === 241) { var caseClause = clause; var caseType = checkExpression(caseClause.expression); if (!isTypeAssignableTo(expressionType, caseType)) { @@ -19511,7 +19955,7 @@ var ts; if (ts.isFunctionLike(current)) { break; } - if (current.kind === 205 && current.label.text === node.label.text) { + if (current.kind === 207 && current.label.text === node.label.text) { var sourceFile = ts.getSourceFileOfNode(node); grammarErrorOnNode(node.label, ts.Diagnostics.Duplicate_label_0, ts.getTextOfNodeFromSourceText(sourceFile.text, node.label)); break; @@ -19537,7 +19981,7 @@ var ts; var catchClause = node.catchClause; if (catchClause) { if (catchClause.variableDeclaration) { - if (catchClause.variableDeclaration.name.kind !== 67) { + if (catchClause.variableDeclaration.name.kind !== 69) { grammarErrorOnFirstToken(catchClause.variableDeclaration.name, ts.Diagnostics.Catch_clause_variable_name_must_be_an_identifier); } else if (catchClause.variableDeclaration.type) { @@ -19605,7 +20049,7 @@ var ts; return; } var errorNode; - if (prop.valueDeclaration.name.kind === 134 || prop.parent === containingType.symbol) { + if (prop.valueDeclaration.name.kind === 136 || prop.parent === containingType.symbol) { errorNode = prop.valueDeclaration; } else if (indexDeclaration) { @@ -19675,6 +20119,7 @@ var ts; checkExportsOnMergedDeclarations(node); var symbol = getSymbolOfNode(node); var type = getDeclaredTypeOfSymbol(symbol); + var typeWithThis = getTypeWithThisArgument(type); var staticType = getTypeOfSymbol(symbol); var baseTypeNode = ts.getClassExtendsHeritageClauseElement(node); if (baseTypeNode) { @@ -19693,7 +20138,7 @@ var ts; } } } - checkTypeAssignableTo(type, baseType, node.name || node, ts.Diagnostics.Class_0_incorrectly_extends_base_class_1); + checkTypeAssignableTo(typeWithThis, getTypeWithThisArgument(baseType, type.thisType), node.name || node, ts.Diagnostics.Class_0_incorrectly_extends_base_class_1); checkTypeAssignableTo(staticType, getTypeWithoutSignatures(staticBaseType), node.name || node, ts.Diagnostics.Class_static_side_0_incorrectly_extends_base_class_static_side_1); if (!(staticBaseType.symbol && staticBaseType.symbol.flags & 32)) { var constructors = getInstantiatedConstructorsForTypeArguments(staticBaseType, baseTypeNode.typeArguments); @@ -19706,7 +20151,8 @@ var ts; } var implementedTypeNodes = ts.getClassImplementsHeritageClauseElements(node); if (implementedTypeNodes) { - ts.forEach(implementedTypeNodes, function (typeRefNode) { + for (var _b = 0; _b < implementedTypeNodes.length; _b++) { + var typeRefNode = implementedTypeNodes[_b]; if (!ts.isSupportedExpressionWithTypeArguments(typeRefNode)) { error(typeRefNode.expression, ts.Diagnostics.A_class_can_only_implement_an_identifier_Slashqualified_name_with_optional_type_arguments); } @@ -19716,14 +20162,14 @@ var ts; if (t !== unknownType) { var declaredType = (t.flags & 4096) ? t.target : t; if (declaredType.flags & (1024 | 2048)) { - checkTypeAssignableTo(type, t, node.name || node, ts.Diagnostics.Class_0_incorrectly_implements_interface_1); + checkTypeAssignableTo(typeWithThis, getTypeWithThisArgument(t, type.thisType), node.name || node, ts.Diagnostics.Class_0_incorrectly_implements_interface_1); } else { error(typeRefNode, ts.Diagnostics.A_class_may_only_implement_another_class_or_interface); } } } - }); + } } if (produceDiagnostics) { checkIndexConstraints(type); @@ -19751,7 +20197,7 @@ var ts; if (derived === base) { var derivedClassDecl = getClassLikeDeclarationOfSymbol(type.symbol); if (baseDeclarationFlags & 256 && (!derivedClassDecl || !(derivedClassDecl.flags & 256))) { - if (derivedClassDecl.kind === 184) { + if (derivedClassDecl.kind === 186) { error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1, symbolToString(baseProperty), typeToString(baseType)); } else { @@ -19795,7 +20241,7 @@ var ts; } } function isAccessor(kind) { - return kind === 143 || kind === 144; + return kind === 145 || kind === 146; } function areTypeParametersIdentical(list1, list2) { if (!list1 && !list2) { @@ -19832,7 +20278,7 @@ var ts; var ok = true; for (var _i = 0; _i < baseTypes.length; _i++) { var base = baseTypes[_i]; - var properties = getPropertiesOfObjectType(base); + var properties = getPropertiesOfObjectType(getTypeWithThisArgument(base, type.thisType)); for (var _a = 0; _a < properties.length; _a++) { var prop = properties[_a]; if (!ts.hasProperty(seen, prop.name)) { @@ -19861,7 +20307,7 @@ var ts; checkTypeNameIsReserved(node.name, ts.Diagnostics.Interface_name_cannot_be_0); checkExportsOnMergedDeclarations(node); var symbol = getSymbolOfNode(node); - var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 213); + var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 215); if (symbol.declarations.length > 1) { if (node !== firstInterfaceDecl && !areTypeParametersIdentical(firstInterfaceDecl.typeParameters, node.typeParameters)) { error(node.name, ts.Diagnostics.All_declarations_of_an_interface_must_have_identical_type_parameters); @@ -19869,17 +20315,19 @@ var ts; } if (node === firstInterfaceDecl) { var type = getDeclaredTypeOfSymbol(symbol); + var typeWithThis = getTypeWithThisArgument(type); if (checkInheritedPropertiesAreIdentical(type, node.name)) { - ts.forEach(getBaseTypes(type), function (baseType) { - checkTypeAssignableTo(type, baseType, node.name, ts.Diagnostics.Interface_0_incorrectly_extends_interface_1); - }); + for (var _i = 0, _a = getBaseTypes(type); _i < _a.length; _i++) { + var baseType = _a[_i]; + checkTypeAssignableTo(typeWithThis, getTypeWithThisArgument(baseType, type.thisType), node.name, ts.Diagnostics.Interface_0_incorrectly_extends_interface_1); + } checkIndexConstraints(type); } } if (symbol && symbol.declarations) { - for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { - var declaration = _a[_i]; - if (declaration.kind === 212 && !ts.isInAmbientContext(declaration)) { + for (var _b = 0, _c = symbol.declarations; _b < _c.length; _b++) { + var declaration = _c[_b]; + if (declaration.kind === 214 && !ts.isInAmbientContext(declaration)) { error(node, ts.Diagnostics.Only_an_ambient_class_can_be_merged_with_an_interface); break; } @@ -19910,10 +20358,15 @@ var ts; var autoValue = 0; var ambient = ts.isInAmbientContext(node); var enumIsConst = ts.isConst(node); - ts.forEach(node.members, function (member) { - if (member.name.kind !== 134 && isNumericLiteralName(member.name.text)) { + for (var _i = 0, _a = node.members; _i < _a.length; _i++) { + var member = _a[_i]; + if (member.name.kind === 136) { + error(member.name, ts.Diagnostics.Computed_property_names_are_not_allowed_in_enums); + } + else if (isNumericLiteralName(member.name.text)) { error(member.name, ts.Diagnostics.An_enum_member_cannot_have_a_numeric_name); } + var previousEnumMemberIsNonConstant = autoValue === undefined; var initializer = member.initializer; if (initializer) { autoValue = computeConstantValueForEnumMemberInitializer(initializer, enumType, enumIsConst, ambient); @@ -19921,10 +20374,13 @@ var ts; else if (ambient && !enumIsConst) { autoValue = undefined; } + else if (previousEnumMemberIsNonConstant) { + error(member.name, ts.Diagnostics.Enum_member_must_have_initializer); + } if (autoValue !== undefined) { getNodeLinks(member).enumMemberValue = autoValue++; } - }); + } nodeLinks.flags |= 8192; } function computeConstantValueForEnumMemberInitializer(initializer, enumType, enumIsConst, ambient) { @@ -19935,7 +20391,10 @@ var ts; if (enumIsConst) { error(initializer, ts.Diagnostics.In_const_enum_declarations_member_initializer_must_be_constant_expression); } - else if (!ambient) { + else if (ambient) { + error(initializer, ts.Diagnostics.In_ambient_enum_declarations_member_initializer_must_be_constant_expression); + } + else { checkTypeAssignableTo(checkExpression(initializer), enumType, initializer, undefined); } } @@ -19951,7 +20410,7 @@ var ts; return value; function evalConstant(e) { switch (e.kind) { - case 177: + case 179: var value_1 = evalConstant(e.operand); if (value_1 === undefined) { return undefined; @@ -19959,10 +20418,10 @@ var ts; switch (e.operator) { case 35: return value_1; case 36: return -value_1; - case 49: return ~value_1; + case 50: return ~value_1; } return undefined; - case 179: + case 181: var left = evalConstant(e.left); if (left === undefined) { return undefined; @@ -19972,37 +20431,37 @@ var ts; return undefined; } switch (e.operatorToken.kind) { - case 46: return left | right; - case 45: return left & right; - case 43: return left >> right; - case 44: return left >>> right; - case 42: return left << right; - case 47: return left ^ right; + case 47: return left | right; + case 46: return left & right; + case 44: return left >> right; + case 45: return left >>> right; + case 43: return left << right; + case 48: return left ^ right; case 37: return left * right; - case 38: return left / right; + case 39: return left / right; case 35: return left + right; case 36: return left - right; - case 39: return left % right; + case 40: return left % right; } return undefined; case 8: return +e.text; - case 170: + case 172: return evalConstant(e.expression); - case 67: - case 165: - case 164: + case 69: + case 167: + case 166: var member = initializer.parent; var currentType = getTypeOfSymbol(getSymbolOfNode(member.parent)); var enumType_1; var propertyName; - if (e.kind === 67) { + if (e.kind === 69) { enumType_1 = currentType; propertyName = e.text; } else { var expression; - if (e.kind === 165) { + if (e.kind === 167) { if (e.argumentExpression === undefined || e.argumentExpression.kind !== 9) { return undefined; @@ -20016,10 +20475,10 @@ var ts; } var current = expression; while (current) { - if (current.kind === 67) { + if (current.kind === 69) { break; } - else if (current.kind === 164) { + else if (current.kind === 166) { current = current.expression; } else { @@ -20042,7 +20501,7 @@ var ts; if (member === propertyDecl) { return undefined; } - if (!isDefinedBefore(propertyDecl, member)) { + if (!isBlockScopedNameDeclaredBeforeUse(propertyDecl, member)) { reportError = false; error(e, ts.Diagnostics.A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_enums); return undefined; @@ -20056,7 +20515,7 @@ var ts; if (!produceDiagnostics) { return; } - checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarEnumDeclaration(node); + checkGrammarDecorators(node) || checkGrammarModifiers(node); checkTypeNameIsReserved(node.name, ts.Diagnostics.Enum_name_cannot_be_0); checkCollisionWithCapturedThisVariable(node, node.name); checkCollisionWithRequireExportsInGeneratedCode(node, node.name); @@ -20078,7 +20537,7 @@ var ts; } var seenEnumMissingInitialInitializer = false; ts.forEach(enumSymbol.declarations, function (declaration) { - if (declaration.kind !== 215) { + if (declaration.kind !== 217) { return false; } var enumDeclaration = declaration; @@ -20101,8 +20560,8 @@ var ts; var declarations = symbol.declarations; for (var _i = 0; _i < declarations.length; _i++) { var declaration = declarations[_i]; - if ((declaration.kind === 212 || - (declaration.kind === 211 && ts.nodeIsPresent(declaration.body))) && + if ((declaration.kind === 214 || + (declaration.kind === 213 && ts.nodeIsPresent(declaration.body))) && !ts.isInAmbientContext(declaration)) { return declaration; } @@ -20153,7 +20612,7 @@ var ts; error(node.name, ts.Diagnostics.A_namespace_declaration_cannot_be_located_prior_to_a_class_or_function_with_which_it_is_merged); } } - var mergedClass = ts.getDeclarationOfKind(symbol, 212); + var mergedClass = ts.getDeclarationOfKind(symbol, 214); if (mergedClass && inSameLexicalScope(node, mergedClass)) { getNodeLinks(node).flags |= 32768; @@ -20161,9 +20620,9 @@ var ts; } if (isAmbientExternalModule) { if (!isGlobalSourceFile(node.parent)) { - error(node.name, ts.Diagnostics.Ambient_modules_cannot_be_nested_in_other_modules); + error(node.name, ts.Diagnostics.Ambient_modules_cannot_be_nested_in_other_modules_or_namespaces); } - if (isExternalModuleNameRelative(node.name.text)) { + if (ts.isExternalModuleNameRelative(node.name.text)) { error(node.name, ts.Diagnostics.Ambient_module_declaration_cannot_specify_relative_module_name); } } @@ -20172,17 +20631,17 @@ var ts; } function getFirstIdentifier(node) { while (true) { - if (node.kind === 133) { + if (node.kind === 135) { node = node.left; } - else if (node.kind === 164) { + else if (node.kind === 166) { node = node.expression; } else { break; } } - ts.Debug.assert(node.kind === 67); + ts.Debug.assert(node.kind === 69); return node; } function checkExternalImportOrExportDeclaration(node) { @@ -20191,14 +20650,14 @@ var ts; error(moduleName, ts.Diagnostics.String_literal_expected); return false; } - var inAmbientExternalModule = node.parent.kind === 217 && node.parent.parent.name.kind === 9; - if (node.parent.kind !== 246 && !inAmbientExternalModule) { - error(moduleName, node.kind === 226 ? + var inAmbientExternalModule = node.parent.kind === 219 && node.parent.parent.name.kind === 9; + if (node.parent.kind !== 248 && !inAmbientExternalModule) { + error(moduleName, node.kind === 228 ? ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace : ts.Diagnostics.Import_declarations_in_a_namespace_cannot_reference_a_module); return false; } - if (inAmbientExternalModule && isExternalModuleNameRelative(moduleName.text)) { + if (inAmbientExternalModule && ts.isExternalModuleNameRelative(moduleName.text)) { error(node, ts.Diagnostics.Import_or_export_declaration_in_an_ambient_module_declaration_cannot_reference_module_through_relative_module_name); return false; } @@ -20212,7 +20671,7 @@ var ts; (symbol.flags & 793056 ? 793056 : 0) | (symbol.flags & 1536 ? 1536 : 0); if (target.flags & excludedMeanings) { - var message = node.kind === 228 ? + var message = node.kind === 230 ? ts.Diagnostics.Export_declaration_conflicts_with_exported_declaration_of_0 : ts.Diagnostics.Import_declaration_conflicts_with_local_declaration_of_0; error(node, message, symbolToString(symbol)); @@ -20238,7 +20697,7 @@ var ts; checkImportBinding(importClause); } if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 222) { + if (importClause.namedBindings.kind === 224) { checkImportBinding(importClause.namedBindings); } else { @@ -20273,8 +20732,8 @@ var ts; } } else { - if (languageVersion >= 2 && !ts.isInAmbientContext(node)) { - grammarErrorOnNode(node, ts.Diagnostics.Import_assignment_cannot_be_used_when_targeting_ECMAScript_6_or_higher_Consider_using_import_Asterisk_as_ns_from_mod_import_a_from_mod_or_import_d_from_mod_instead); + if (modulekind === 5 && !ts.isInAmbientContext(node)) { + grammarErrorOnNode(node, ts.Diagnostics.Import_assignment_cannot_be_used_when_targeting_ECMAScript_6_modules_Consider_using_import_Asterisk_as_ns_from_mod_import_a_from_mod_import_d_from_mod_or_another_module_format_instead); } } } @@ -20289,8 +20748,8 @@ var ts; if (!node.moduleSpecifier || checkExternalImportOrExportDeclaration(node)) { if (node.exportClause) { ts.forEach(node.exportClause.elements, checkExportSpecifier); - var inAmbientExternalModule = node.parent.kind === 217 && node.parent.parent.name.kind === 9; - if (node.parent.kind !== 246 && !inAmbientExternalModule) { + var inAmbientExternalModule = node.parent.kind === 219 && node.parent.parent.name.kind === 9; + if (node.parent.kind !== 248 && !inAmbientExternalModule) { error(node, ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace); } } @@ -20303,7 +20762,7 @@ var ts; } } function checkGrammarModuleElementContext(node, errorMessage) { - if (node.parent.kind !== 246 && node.parent.kind !== 217 && node.parent.kind !== 216) { + if (node.parent.kind !== 248 && node.parent.kind !== 219 && node.parent.kind !== 218) { return grammarErrorOnFirstToken(node, errorMessage); } } @@ -20317,15 +20776,15 @@ var ts; if (checkGrammarModuleElementContext(node, ts.Diagnostics.An_export_assignment_can_only_be_used_in_a_module)) { return; } - var container = node.parent.kind === 246 ? node.parent : node.parent.parent; - if (container.kind === 216 && container.name.kind === 67) { + var container = node.parent.kind === 248 ? node.parent : node.parent.parent; + if (container.kind === 218 && container.name.kind === 69) { error(node, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_namespace); return; } if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && (node.flags & 2035)) { grammarErrorOnFirstToken(node, ts.Diagnostics.An_export_assignment_cannot_have_modifiers); } - if (node.expression.kind === 67) { + if (node.expression.kind === 69) { markExportAsReferenced(node); } else { @@ -20333,19 +20792,19 @@ var ts; } checkExternalModuleExports(container); if (node.isExportEquals && !ts.isInAmbientContext(node)) { - if (languageVersion >= 2) { - grammarErrorOnNode(node, ts.Diagnostics.Export_assignment_cannot_be_used_when_targeting_ECMAScript_6_or_higher_Consider_using_export_default_instead); + if (modulekind === 5) { + grammarErrorOnNode(node, ts.Diagnostics.Export_assignment_cannot_be_used_when_targeting_ECMAScript_6_modules_Consider_using_export_default_or_another_module_format_instead); } - else if (compilerOptions.module === 4) { + else if (modulekind === 4) { grammarErrorOnNode(node, ts.Diagnostics.Export_assignment_is_not_supported_when_module_flag_is_system); } } } function getModuleStatements(node) { - if (node.kind === 246) { + if (node.kind === 248) { return node.statements; } - if (node.kind === 216 && node.body.kind === 217) { + if (node.kind === 218 && node.body.kind === 219) { return node.body.statements; } return emptyArray; @@ -20382,183 +20841,182 @@ var ts; var kind = node.kind; if (cancellationToken) { switch (kind) { - case 216: - case 212: + case 218: + case 214: + case 215: case 213: - case 211: cancellationToken.throwIfCancellationRequested(); } } switch (kind) { - case 135: + case 137: return checkTypeParameter(node); - case 136: - return checkParameter(node); - case 139: case 138: - return checkPropertyDeclaration(node); - case 150: - case 151: - case 145: - case 146: - return checkSignatureDeclaration(node); - case 147: - return checkSignatureDeclaration(node); + return checkParameter(node); case 141: case 140: - return checkMethodDeclaration(node); - case 142: - return checkConstructorDeclaration(node); - case 143: - case 144: - return checkAccessorDeclaration(node); - case 149: - return checkTypeReferenceNode(node); - case 148: - return checkTypePredicate(node); + return checkPropertyDeclaration(node); case 152: - return checkTypeQuery(node); case 153: - return checkTypeLiteral(node); + case 147: + case 148: + return checkSignatureDeclaration(node); + case 149: + return checkSignatureDeclaration(node); + case 143: + case 142: + return checkMethodDeclaration(node); + case 144: + return checkConstructorDeclaration(node); + case 145: + case 146: + return checkAccessorDeclaration(node); + case 151: + return checkTypeReferenceNode(node); + case 150: + return checkTypePredicate(node); case 154: - return checkArrayType(node); + return checkTypeQuery(node); case 155: - return checkTupleType(node); + return checkTypeLiteral(node); case 156: + return checkArrayType(node); case 157: - return checkUnionOrIntersectionType(node); + return checkTupleType(node); case 158: + case 159: + return checkUnionOrIntersectionType(node); + case 160: return checkSourceElement(node.type); - case 211: - return checkFunctionDeclaration(node); - case 190: - case 217: - return checkBlock(node); - case 191: - return checkVariableStatement(node); - case 193: - return checkExpressionStatement(node); - case 194: - return checkIfStatement(node); - case 195: - return checkDoStatement(node); - case 196: - return checkWhileStatement(node); - case 197: - return checkForStatement(node); - case 198: - return checkForInStatement(node); - case 199: - return checkForOfStatement(node); - case 200: - case 201: - return checkBreakOrContinueStatement(node); - case 202: - return checkReturnStatement(node); - case 203: - return checkWithStatement(node); - case 204: - return checkSwitchStatement(node); - case 205: - return checkLabeledStatement(node); - case 206: - return checkThrowStatement(node); - case 207: - return checkTryStatement(node); - case 209: - return checkVariableDeclaration(node); - case 161: - return checkBindingElement(node); - case 212: - return checkClassDeclaration(node); case 213: - return checkInterfaceDeclaration(node); - case 214: - return checkTypeAliasDeclaration(node); - case 215: - return checkEnumDeclaration(node); - case 216: - return checkModuleDeclaration(node); - case 220: - return checkImportDeclaration(node); - case 219: - return checkImportEqualsDeclaration(node); - case 226: - return checkExportDeclaration(node); - case 225: - return checkExportAssignment(node); + return checkFunctionDeclaration(node); case 192: - checkGrammarStatementInAmbientContext(node); - return; + case 219: + return checkBlock(node); + case 193: + return checkVariableStatement(node); + case 195: + return checkExpressionStatement(node); + case 196: + return checkIfStatement(node); + case 197: + return checkDoStatement(node); + case 198: + return checkWhileStatement(node); + case 199: + return checkForStatement(node); + case 200: + return checkForInStatement(node); + case 201: + return checkForOfStatement(node); + case 202: + case 203: + return checkBreakOrContinueStatement(node); + case 204: + return checkReturnStatement(node); + case 205: + return checkWithStatement(node); + case 206: + return checkSwitchStatement(node); + case 207: + return checkLabeledStatement(node); case 208: + return checkThrowStatement(node); + case 209: + return checkTryStatement(node); + case 211: + return checkVariableDeclaration(node); + case 163: + return checkBindingElement(node); + case 214: + return checkClassDeclaration(node); + case 215: + return checkInterfaceDeclaration(node); + case 216: + return checkTypeAliasDeclaration(node); + case 217: + return checkEnumDeclaration(node); + case 218: + return checkModuleDeclaration(node); + case 222: + return checkImportDeclaration(node); + case 221: + return checkImportEqualsDeclaration(node); + case 228: + return checkExportDeclaration(node); + case 227: + return checkExportAssignment(node); + case 194: checkGrammarStatementInAmbientContext(node); return; - case 229: + case 210: + checkGrammarStatementInAmbientContext(node); + return; + case 231: return checkMissingDeclaration(node); } } function checkFunctionAndClassExpressionBodies(node) { switch (node.kind) { - case 171: - case 172: + case 173: + case 174: ts.forEach(node.parameters, checkFunctionAndClassExpressionBodies); checkFunctionExpressionOrObjectLiteralMethodBody(node); break; - case 184: + case 186: ts.forEach(node.members, checkSourceElement); + ts.forEachChild(node, checkFunctionAndClassExpressionBodies); break; - case 141: - case 140: + case 143: + case 142: ts.forEach(node.decorators, checkFunctionAndClassExpressionBodies); ts.forEach(node.parameters, checkFunctionAndClassExpressionBodies); if (ts.isObjectLiteralMethod(node)) { checkFunctionExpressionOrObjectLiteralMethodBody(node); } break; - case 142: - case 143: case 144: - case 211: + case 145: + case 146: + case 213: ts.forEach(node.parameters, checkFunctionAndClassExpressionBodies); break; - case 203: + case 205: checkFunctionAndClassExpressionBodies(node.expression); break; - case 137: - case 136: case 139: case 138: - case 159: - case 160: + case 141: + case 140: case 161: case 162: case 163: - case 243: case 164: case 165: + case 245: case 166: case 167: case 168: - case 181: - case 188: case 169: - case 187: case 170: - case 174: - case 175: + case 183: + case 190: + case 171: + case 189: + case 172: case 176: - case 173: case 177: case 178: + case 175: case 179: case 180: - case 183: + case 181: case 182: - case 190: - case 217: - case 191: + case 185: + case 184: + case 192: + case 219: case 193: - case 194: case 195: case 196: case 197: @@ -20567,29 +21025,31 @@ var ts; case 200: case 201: case 202: + case 203: case 204: - case 218: - case 239: - case 240: - case 205: case 206: - case 207: - case 242: - case 209: - case 210: - case 212: + case 220: case 241: - case 186: - case 215: - case 245: - case 225: - case 246: - case 238: - case 231: - case 232: - case 236: - case 237: + case 242: + case 207: + case 208: + case 209: + case 244: + case 211: + case 212: + case 214: + case 243: + case 188: + case 217: + case 247: + case 227: + case 248: + case 240: case 233: + case 234: + case 238: + case 239: + case 235: ts.forEachChild(node, checkFunctionAndClassExpressionBodies); break; } @@ -20612,7 +21072,7 @@ var ts; potentialThisCollisions.length = 0; ts.forEach(node.statements, checkSourceElement); checkFunctionAndClassExpressionBodies(node); - if (ts.isExternalModule(node)) { + if (ts.isExternalOrCommonJsModule(node)) { checkExternalModuleExports(node); } if (potentialThisCollisions.length) { @@ -20667,7 +21127,7 @@ var ts; function isInsideWithStatementBody(node) { if (node) { while (node.parent) { - if (node.parent.kind === 203 && node.parent.statement === node) { + if (node.parent.kind === 205 && node.parent.statement === node) { return true; } node = node.parent; @@ -20689,28 +21149,28 @@ var ts; copySymbols(location.locals, meaning); } switch (location.kind) { - case 246: - if (!ts.isExternalModule(location)) { + case 248: + if (!ts.isExternalOrCommonJsModule(location)) { break; } - case 216: + case 218: copySymbols(getSymbolOfNode(location).exports, meaning & 8914931); break; - case 215: + case 217: copySymbols(getSymbolOfNode(location).exports, meaning & 8); break; - case 184: + case 186: var className = location.name; if (className) { copySymbol(location.symbol, meaning); } - case 212: - case 213: + case 214: + case 215: if (!(memberFlags & 128)) { copySymbols(getSymbolOfNode(location).members, meaning & 793056); } break; - case 171: + case 173: var funcName = location.name; if (funcName) { copySymbol(location.symbol, meaning); @@ -20743,42 +21203,42 @@ var ts; } } function isTypeDeclarationName(name) { - return name.kind === 67 && + return name.kind === 69 && isTypeDeclaration(name.parent) && name.parent.name === name; } function isTypeDeclaration(node) { switch (node.kind) { - case 135: - case 212: - case 213: + case 137: case 214: case 215: + case 216: + case 217: return true; } } function isTypeReferenceIdentifier(entityName) { var node = entityName; - while (node.parent && node.parent.kind === 133) { + while (node.parent && node.parent.kind === 135) { node = node.parent; } - return node.parent && node.parent.kind === 149; + return node.parent && node.parent.kind === 151; } function isHeritageClauseElementIdentifier(entityName) { var node = entityName; - while (node.parent && node.parent.kind === 164) { + while (node.parent && node.parent.kind === 166) { node = node.parent; } - return node.parent && node.parent.kind === 186; + return node.parent && node.parent.kind === 188; } function getLeftSideOfImportEqualsOrExportAssignment(nodeOnRightSide) { - while (nodeOnRightSide.parent.kind === 133) { + while (nodeOnRightSide.parent.kind === 135) { nodeOnRightSide = nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 219) { + if (nodeOnRightSide.parent.kind === 221) { return nodeOnRightSide.parent.moduleReference === nodeOnRightSide && nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 225) { + if (nodeOnRightSide.parent.kind === 227) { return nodeOnRightSide.parent.expression === nodeOnRightSide && nodeOnRightSide.parent; } return undefined; @@ -20790,10 +21250,10 @@ var ts; if (ts.isDeclarationName(entityName)) { return getSymbolOfNode(entityName.parent); } - if (entityName.parent.kind === 225) { + if (entityName.parent.kind === 227) { return resolveEntityName(entityName, 107455 | 793056 | 1536 | 8388608); } - if (entityName.kind !== 164) { + if (entityName.kind !== 166) { if (isInRightSideOfImportOrExportAssignment(entityName)) { return getSymbolOfPartOfRightHandSideOfImportEquals(entityName); } @@ -20802,31 +21262,40 @@ var ts; entityName = entityName.parent; } if (isHeritageClauseElementIdentifier(entityName)) { - var meaning = entityName.parent.kind === 186 ? 793056 : 1536; + var meaning = 0; + if (entityName.parent.kind === 188) { + meaning = 793056; + if (ts.isExpressionWithTypeArgumentsInClassExtendsClause(entityName.parent)) { + meaning |= 107455; + } + } + else { + meaning = 1536; + } meaning |= 8388608; return resolveEntityName(entityName, meaning); } - else if ((entityName.parent.kind === 233) || - (entityName.parent.kind === 232) || - (entityName.parent.kind === 235)) { + else if ((entityName.parent.kind === 235) || + (entityName.parent.kind === 234) || + (entityName.parent.kind === 237)) { return getJsxElementTagSymbol(entityName.parent); } else if (ts.isExpression(entityName)) { if (ts.nodeIsMissing(entityName)) { return undefined; } - if (entityName.kind === 67) { + if (entityName.kind === 69) { var meaning = 107455 | 8388608; return resolveEntityName(entityName, meaning); } - else if (entityName.kind === 164) { + else if (entityName.kind === 166) { var symbol = getNodeLinks(entityName).resolvedSymbol; if (!symbol) { checkPropertyAccessExpression(entityName); } return getNodeLinks(entityName).resolvedSymbol; } - else if (entityName.kind === 133) { + else if (entityName.kind === 135) { var symbol = getNodeLinks(entityName).resolvedSymbol; if (!symbol) { checkQualifiedName(entityName); @@ -20835,14 +21304,14 @@ var ts; } } else if (isTypeReferenceIdentifier(entityName)) { - var meaning = entityName.parent.kind === 149 ? 793056 : 1536; + var meaning = entityName.parent.kind === 151 ? 793056 : 1536; meaning |= 8388608; return resolveEntityName(entityName, meaning); } - else if (entityName.parent.kind === 236) { + else if (entityName.parent.kind === 238) { return getJsxAttributePropertySymbol(entityName.parent); } - if (entityName.parent.kind === 148) { + if (entityName.parent.kind === 150) { return resolveEntityName(entityName, 1); } return undefined; @@ -20854,14 +21323,14 @@ var ts; if (ts.isDeclarationName(node)) { return getSymbolOfNode(node.parent); } - if (node.kind === 67) { + if (node.kind === 69) { if (isInRightSideOfImportOrExportAssignment(node)) { - return node.parent.kind === 225 + return node.parent.kind === 227 ? getSymbolOfEntityNameOrPropertyAccessExpression(node) : getSymbolOfPartOfRightHandSideOfImportEquals(node); } - else if (node.parent.kind === 161 && - node.parent.parent.kind === 159 && + else if (node.parent.kind === 163 && + node.parent.parent.kind === 161 && node === node.parent.propertyName) { var typeOfPattern = getTypeOfNode(node.parent.parent); var propertyDeclaration = typeOfPattern && getPropertyOfType(typeOfPattern, node.text); @@ -20871,29 +21340,29 @@ var ts; } } switch (node.kind) { - case 67: - case 164: - case 133: + case 69: + case 166: + case 135: return getSymbolOfEntityNameOrPropertyAccessExpression(node); + case 97: case 95: - case 93: - var type = checkExpression(node); + var type = ts.isExpression(node) ? checkExpression(node) : getTypeFromTypeNode(node); return type.symbol; - case 119: + case 121: var constructorDeclaration = node.parent; - if (constructorDeclaration && constructorDeclaration.kind === 142) { + if (constructorDeclaration && constructorDeclaration.kind === 144) { return constructorDeclaration.parent.symbol; } return undefined; case 9: if ((ts.isExternalModuleImportEqualsDeclaration(node.parent.parent) && ts.getExternalModuleImportEqualsDeclarationExpression(node.parent.parent) === node) || - ((node.parent.kind === 220 || node.parent.kind === 226) && + ((node.parent.kind === 222 || node.parent.kind === 228) && node.parent.moduleSpecifier === node)) { return resolveExternalModuleName(node, node); } case 8: - if (node.parent.kind === 165 && node.parent.argumentExpression === node) { + if (node.parent.kind === 167 && node.parent.argumentExpression === node) { var objectType = checkExpression(node.parent.expression); if (objectType === unknownType) return undefined; @@ -20907,7 +21376,7 @@ var ts; return undefined; } function getShorthandAssignmentValueSymbol(location) { - if (location && location.kind === 244) { + if (location && location.kind === 246) { return resolveEntityName(location.name, 107455); } return undefined; @@ -21007,11 +21476,11 @@ var ts; } var parentSymbol = getParentOfSymbol(symbol); if (parentSymbol) { - if (parentSymbol.flags & 512 && parentSymbol.valueDeclaration.kind === 246) { + if (parentSymbol.flags & 512 && parentSymbol.valueDeclaration.kind === 248) { return parentSymbol.valueDeclaration; } for (var n = node.parent; n; n = n.parent) { - if ((n.kind === 216 || n.kind === 215) && getSymbolOfNode(n) === parentSymbol) { + if ((n.kind === 218 || n.kind === 217) && getSymbolOfNode(n) === parentSymbol) { return n; } } @@ -21024,11 +21493,11 @@ var ts; } function isStatementWithLocals(node) { switch (node.kind) { - case 190: - case 218: - case 197: - case 198: + case 192: + case 220: case 199: + case 200: + case 201: return true; } return false; @@ -21054,22 +21523,22 @@ var ts; } function isValueAliasDeclaration(node) { switch (node.kind) { - case 219: case 221: - case 222: + case 223: case 224: - case 228: - return isAliasResolvedToValue(getSymbolOfNode(node)); case 226: + case 230: + return isAliasResolvedToValue(getSymbolOfNode(node)); + case 228: var exportClause = node.exportClause; return exportClause && ts.forEach(exportClause.elements, isValueAliasDeclaration); - case 225: - return node.expression && node.expression.kind === 67 ? isAliasResolvedToValue(getSymbolOfNode(node)) : true; + case 227: + return node.expression && node.expression.kind === 69 ? isAliasResolvedToValue(getSymbolOfNode(node)) : true; } return false; } function isTopLevelValueImportEqualsWithEntityName(node) { - if (node.parent.kind !== 246 || !ts.isInternalModuleImportEqualsDeclaration(node)) { + if (node.parent.kind !== 248 || !ts.isInternalModuleImportEqualsDeclaration(node)) { return false; } var isValue = isAliasResolvedToValue(getSymbolOfNode(node)); @@ -21117,7 +21586,7 @@ var ts; return getNodeLinks(node).enumMemberValue; } function getConstantValue(node) { - if (node.kind === 245) { + if (node.kind === 247) { return getEnumMemberValue(node); } var symbol = getNodeLinks(node).resolvedSymbol; @@ -21203,21 +21672,6 @@ var ts; var symbol = getReferencedValueSymbol(reference); return symbol && getExportSymbolOfValueSymbolIfExported(symbol).valueDeclaration; } - function getBlockScopedVariableId(n) { - ts.Debug.assert(!ts.nodeIsSynthesized(n)); - var isVariableDeclarationOrBindingElement = n.parent.kind === 161 || (n.parent.kind === 209 && n.parent.name === n); - var symbol = (isVariableDeclarationOrBindingElement ? getSymbolOfNode(n.parent) : undefined) || - getNodeLinks(n).resolvedSymbol || - resolveName(n, n.text, 107455 | 8388608, undefined, undefined); - var isLetOrConst = symbol && - (symbol.flags & 2) && - symbol.valueDeclaration.parent.kind !== 242; - if (isLetOrConst) { - getSymbolLinks(symbol); - return symbol.id; - } - return undefined; - } function instantiateSingleCallFunctionType(functionType, typeArguments) { if (functionType === unknownType) { return unknownType; @@ -21249,7 +21703,6 @@ var ts; isEntityNameVisible: isEntityNameVisible, getConstantValue: getConstantValue, collectLinkedAliases: collectLinkedAliases, - getBlockScopedVariableId: getBlockScopedVariableId, getReferencedValueDeclaration: getReferencedValueDeclaration, getTypeReferenceSerializationKind: getTypeReferenceSerializationKind, isOptionalParameter: isOptionalParameter @@ -21260,7 +21713,7 @@ var ts; ts.bindSourceFile(file); }); ts.forEach(host.getSourceFiles(), function (file) { - if (!ts.isExternalModule(file)) { + if (!ts.isExternalOrCommonJsModule(file)) { mergeSymbolTable(globals, file.locals); } }); @@ -21288,6 +21741,7 @@ var ts; getGlobalPromiseConstructorSymbol = ts.memoize(function () { return getGlobalValueSymbol("Promise"); }); getGlobalPromiseConstructorLikeType = ts.memoize(function () { return getGlobalType("PromiseConstructorLike"); }); getGlobalThenableType = ts.memoize(createThenableType); + cjsRequireType = getExportedTypeFromNamespace("CommonJS", "Require"); if (languageVersion >= 2) { globalTemplateStringsArrayType = getGlobalType("TemplateStringsArray"); globalESSymbolType = getGlobalType("Symbol"); @@ -21330,10 +21784,7 @@ var ts; if (!ts.nodeCanBeDecorated(node)) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Decorators_are_not_valid_here); } - else if (languageVersion < 1) { - return grammarErrorOnFirstToken(node, ts.Diagnostics.Decorators_are_only_available_when_targeting_ECMAScript_5_and_higher); - } - else if (node.kind === 143 || node.kind === 144) { + else if (node.kind === 145 || node.kind === 146) { var accessors = ts.getAllAccessorDeclarations(node.parent.members, node); if (accessors.firstAccessor.decorators && node === accessors.secondAccessor) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name); @@ -21343,38 +21794,38 @@ var ts; } function checkGrammarModifiers(node) { switch (node.kind) { - case 143: + case 145: + case 146: case 144: - case 142: - case 139: - case 138: case 141: case 140: - case 147: - case 216: - case 220: - case 219: - case 226: - case 225: - case 136: + case 143: + case 142: + case 149: + case 218: + case 222: + case 221: + case 228: + case 227: + case 138: break; - case 211: - if (node.modifiers && (node.modifiers.length > 1 || node.modifiers[0].kind !== 116) && - node.parent.kind !== 217 && node.parent.kind !== 246) { - return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); - } - break; - case 212: case 213: - case 191: - case 214: - if (node.modifiers && node.parent.kind !== 217 && node.parent.kind !== 246) { + if (node.modifiers && (node.modifiers.length > 1 || node.modifiers[0].kind !== 118) && + node.parent.kind !== 219 && node.parent.kind !== 248) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); } break; + case 214: case 215: - if (node.modifiers && (node.modifiers.length > 1 || node.modifiers[0].kind !== 72) && - node.parent.kind !== 217 && node.parent.kind !== 246) { + case 193: + case 216: + if (node.modifiers && node.parent.kind !== 219 && node.parent.kind !== 248) { + return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); + } + break; + case 217: + if (node.modifiers && (node.modifiers.length > 1 || node.modifiers[0].kind !== 74) && + node.parent.kind !== 219 && node.parent.kind !== 248) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); } break; @@ -21389,14 +21840,14 @@ var ts; for (var _i = 0, _a = node.modifiers; _i < _a.length; _i++) { var modifier = _a[_i]; switch (modifier.kind) { + case 112: + case 111: case 110: - case 109: - case 108: var text = void 0; - if (modifier.kind === 110) { + if (modifier.kind === 112) { text = "public"; } - else if (modifier.kind === 109) { + else if (modifier.kind === 111) { text = "protected"; lastProtected = modifier; } @@ -21413,11 +21864,11 @@ var ts; else if (flags & 512) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "async"); } - else if (node.parent.kind === 217 || node.parent.kind === 246) { + else if (node.parent.kind === 219 || node.parent.kind === 248) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_element, text); } else if (flags & 256) { - if (modifier.kind === 108) { + if (modifier.kind === 110) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, text, "abstract"); } else { @@ -21426,17 +21877,17 @@ var ts; } flags |= ts.modifierToFlag(modifier.kind); break; - case 111: + case 113: if (flags & 128) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "static"); } else if (flags & 512) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "static", "async"); } - else if (node.parent.kind === 217 || node.parent.kind === 246) { + else if (node.parent.kind === 219 || node.parent.kind === 248) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_element, "static"); } - else if (node.kind === 136) { + else if (node.kind === 138) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "static"); } else if (flags & 256) { @@ -21445,7 +21896,7 @@ var ts; flags |= 128; lastStatic = modifier; break; - case 80: + case 82: if (flags & 1) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "export"); } @@ -21458,42 +21909,42 @@ var ts; else if (flags & 512) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "async"); } - else if (node.parent.kind === 212) { + else if (node.parent.kind === 214) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "export"); } - else if (node.kind === 136) { + else if (node.kind === 138) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "export"); } flags |= 1; break; - case 120: + case 122: if (flags & 2) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "declare"); } else if (flags & 512) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); } - else if (node.parent.kind === 212) { + else if (node.parent.kind === 214) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "declare"); } - else if (node.kind === 136) { + else if (node.kind === 138) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "declare"); } - else if (ts.isInAmbientContext(node.parent) && node.parent.kind === 217) { + else if (ts.isInAmbientContext(node.parent) && node.parent.kind === 219) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_declare_modifier_cannot_be_used_in_an_already_ambient_context); } flags |= 2; lastDeclare = modifier; break; - case 113: + case 115: if (flags & 256) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "abstract"); } - if (node.kind !== 212) { - if (node.kind !== 141) { + if (node.kind !== 214) { + if (node.kind !== 143) { return grammarErrorOnNode(modifier, ts.Diagnostics.abstract_modifier_can_only_appear_on_a_class_or_method_declaration); } - if (!(node.parent.kind === 212 && node.parent.flags & 256)) { + if (!(node.parent.kind === 214 && node.parent.flags & 256)) { return grammarErrorOnNode(modifier, ts.Diagnostics.Abstract_methods_can_only_appear_within_an_abstract_class); } if (flags & 128) { @@ -21505,14 +21956,14 @@ var ts; } flags |= 256; break; - case 116: + case 118: if (flags & 512) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "async"); } else if (flags & 2 || ts.isInAmbientContext(node.parent)) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); } - else if (node.kind === 136) { + else if (node.kind === 138) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "async"); } flags |= 512; @@ -21520,7 +21971,7 @@ var ts; break; } } - if (node.kind === 142) { + if (node.kind === 144) { if (flags & 128) { return grammarErrorOnNode(lastStatic, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "static"); } @@ -21538,10 +21989,10 @@ var ts; } return; } - else if ((node.kind === 220 || node.kind === 219) && flags & 2) { + else if ((node.kind === 222 || node.kind === 221) && flags & 2) { return grammarErrorOnNode(lastDeclare, ts.Diagnostics.A_0_modifier_cannot_be_used_with_an_import_declaration, "declare"); } - else if (node.kind === 136 && (flags & 112) && ts.isBindingPattern(node.name)) { + else if (node.kind === 138 && (flags & 112) && ts.isBindingPattern(node.name)) { return grammarErrorOnNode(node, ts.Diagnostics.A_parameter_property_may_not_be_a_binding_pattern); } if (flags & 512) { @@ -21553,10 +22004,10 @@ var ts; return grammarErrorOnNode(asyncModifier, ts.Diagnostics.Async_functions_are_only_available_when_targeting_ECMAScript_6_and_higher); } switch (node.kind) { - case 141: - case 211: - case 171: - case 172: + case 143: + case 213: + case 173: + case 174: if (!node.asteriskToken) { return false; } @@ -21621,7 +22072,7 @@ var ts; checkGrammarParameterList(node.parameters) || checkGrammarArrowFunction(node, file); } function checkGrammarArrowFunction(node, file) { - if (node.kind === 172) { + if (node.kind === 174) { var arrowFunction = node; var startLine = ts.getLineAndCharacterOfPosition(file, arrowFunction.equalsGreaterThanToken.pos).line; var endLine = ts.getLineAndCharacterOfPosition(file, arrowFunction.equalsGreaterThanToken.end).line; @@ -21656,7 +22107,7 @@ var ts; if (!parameter.type) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_must_have_a_type_annotation); } - if (parameter.type.kind !== 128 && parameter.type.kind !== 126) { + if (parameter.type.kind !== 130 && parameter.type.kind !== 128) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_type_must_be_string_or_number); } if (!node.type) { @@ -21688,7 +22139,7 @@ var ts; var sourceFile = ts.getSourceFileOfNode(node); for (var _i = 0; _i < args.length; _i++) { var arg = args[_i]; - if (arg.kind === 185) { + if (arg.kind === 187) { return grammarErrorAtPos(sourceFile, arg.pos, 0, ts.Diagnostics.Argument_expression_expected); } } @@ -21715,7 +22166,7 @@ var ts; if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && node.heritageClauses) { for (var _i = 0, _a = node.heritageClauses; _i < _a.length; _i++) { var heritageClause = _a[_i]; - if (heritageClause.token === 81) { + if (heritageClause.token === 83) { if (seenExtendsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_already_seen); } @@ -21728,7 +22179,7 @@ var ts; seenExtendsClause = true; } else { - ts.Debug.assert(heritageClause.token === 104); + ts.Debug.assert(heritageClause.token === 106); if (seenImplementsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.implements_clause_already_seen); } @@ -21743,14 +22194,14 @@ var ts; if (node.heritageClauses) { for (var _i = 0, _a = node.heritageClauses; _i < _a.length; _i++) { var heritageClause = _a[_i]; - if (heritageClause.token === 81) { + if (heritageClause.token === 83) { if (seenExtendsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_already_seen); } seenExtendsClause = true; } else { - ts.Debug.assert(heritageClause.token === 104); + ts.Debug.assert(heritageClause.token === 106); return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.Interface_declaration_cannot_have_implements_clause); } checkGrammarHeritageClause(heritageClause); @@ -21759,19 +22210,19 @@ var ts; return false; } function checkGrammarComputedPropertyName(node) { - if (node.kind !== 134) { + if (node.kind !== 136) { return false; } var computedPropertyName = node; - if (computedPropertyName.expression.kind === 179 && computedPropertyName.expression.operatorToken.kind === 24) { + if (computedPropertyName.expression.kind === 181 && computedPropertyName.expression.operatorToken.kind === 24) { return grammarErrorOnNode(computedPropertyName.expression, ts.Diagnostics.A_comma_expression_is_not_allowed_in_a_computed_property_name); } } function checkGrammarForGenerator(node) { if (node.asteriskToken) { - ts.Debug.assert(node.kind === 211 || - node.kind === 171 || - node.kind === 141); + ts.Debug.assert(node.kind === 213 || + node.kind === 173 || + node.kind === 143); if (ts.isInAmbientContext(node)) { return grammarErrorOnNode(node.asteriskToken, ts.Diagnostics.Generators_are_not_allowed_in_an_ambient_context); } @@ -21788,7 +22239,7 @@ var ts; return grammarErrorOnNode(questionToken, message); } } - function checkGrammarObjectLiteralExpression(node) { + function checkGrammarObjectLiteralExpression(node, inDestructuring) { var seen = {}; var Property = 1; var GetAccessor = 2; @@ -21797,26 +22248,29 @@ var ts; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; var name_16 = prop.name; - if (prop.kind === 185 || - name_16.kind === 134) { + if (prop.kind === 187 || + name_16.kind === 136) { checkGrammarComputedPropertyName(name_16); continue; } + if (prop.kind === 246 && !inDestructuring && prop.objectAssignmentInitializer) { + return grammarErrorOnNode(prop.equalsToken, ts.Diagnostics.can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment); + } var currentKind = void 0; - if (prop.kind === 243 || prop.kind === 244) { + if (prop.kind === 245 || prop.kind === 246) { checkGrammarForInvalidQuestionMark(prop, prop.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional); if (name_16.kind === 8) { checkGrammarNumericLiteral(name_16); } currentKind = Property; } - else if (prop.kind === 141) { + else if (prop.kind === 143) { currentKind = Property; } - else if (prop.kind === 143) { + else if (prop.kind === 145) { currentKind = GetAccessor; } - else if (prop.kind === 144) { + else if (prop.kind === 146) { currentKind = SetAccesor; } else { @@ -21848,7 +22302,7 @@ var ts; var seen = {}; for (var _i = 0, _a = node.attributes; _i < _a.length; _i++) { var attr = _a[_i]; - if (attr.kind === 237) { + if (attr.kind === 239) { continue; } var jsxAttr = attr; @@ -21860,7 +22314,7 @@ var ts; return grammarErrorOnNode(name_17, ts.Diagnostics.JSX_elements_cannot_have_multiple_attributes_with_the_same_name); } var initializer = jsxAttr.initializer; - if (initializer && initializer.kind === 238 && !initializer.expression) { + if (initializer && initializer.kind === 240 && !initializer.expression) { return grammarErrorOnNode(jsxAttr.initializer, ts.Diagnostics.JSX_attributes_must_only_be_assigned_a_non_empty_expression); } } @@ -21869,24 +22323,24 @@ var ts; if (checkGrammarStatementInAmbientContext(forInOrOfStatement)) { return true; } - if (forInOrOfStatement.initializer.kind === 210) { + if (forInOrOfStatement.initializer.kind === 212) { var variableList = forInOrOfStatement.initializer; if (!checkGrammarVariableDeclarationList(variableList)) { if (variableList.declarations.length > 1) { - var diagnostic = forInOrOfStatement.kind === 198 + var diagnostic = forInOrOfStatement.kind === 200 ? ts.Diagnostics.Only_a_single_variable_declaration_is_allowed_in_a_for_in_statement : ts.Diagnostics.Only_a_single_variable_declaration_is_allowed_in_a_for_of_statement; return grammarErrorOnFirstToken(variableList.declarations[1], diagnostic); } var firstDeclaration = variableList.declarations[0]; if (firstDeclaration.initializer) { - var diagnostic = forInOrOfStatement.kind === 198 + var diagnostic = forInOrOfStatement.kind === 200 ? ts.Diagnostics.The_variable_declaration_of_a_for_in_statement_cannot_have_an_initializer : ts.Diagnostics.The_variable_declaration_of_a_for_of_statement_cannot_have_an_initializer; return grammarErrorOnNode(firstDeclaration.name, diagnostic); } if (firstDeclaration.type) { - var diagnostic = forInOrOfStatement.kind === 198 + var diagnostic = forInOrOfStatement.kind === 200 ? ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_use_a_type_annotation : ts.Diagnostics.The_left_hand_side_of_a_for_of_statement_cannot_use_a_type_annotation; return grammarErrorOnNode(firstDeclaration, diagnostic); @@ -21909,10 +22363,10 @@ var ts; else if (accessor.typeParameters) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.An_accessor_cannot_have_type_parameters); } - else if (kind === 143 && accessor.parameters.length) { + else if (kind === 145 && accessor.parameters.length) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_get_accessor_cannot_have_parameters); } - else if (kind === 144) { + else if (kind === 146) { if (accessor.type) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_set_accessor_cannot_have_a_return_type_annotation); } @@ -21937,7 +22391,7 @@ var ts; } } function checkGrammarForNonSymbolComputedProperty(node, message) { - if (node.kind === 134 && !ts.isWellKnownSymbolSyntactically(node.expression)) { + if (node.kind === 136 && !ts.isWellKnownSymbolSyntactically(node.expression)) { return grammarErrorOnNode(node, message); } } @@ -21947,7 +22401,7 @@ var ts; checkGrammarForGenerator(node)) { return true; } - if (node.parent.kind === 163) { + if (node.parent.kind === 165) { if (checkGrammarForInvalidQuestionMark(node, node.questionToken, ts.Diagnostics.A_class_member_cannot_be_declared_optional)) { return true; } @@ -21966,22 +22420,22 @@ var ts; return checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_method_overload_must_directly_refer_to_a_built_in_symbol); } } - else if (node.parent.kind === 213) { + else if (node.parent.kind === 215) { return checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_an_interface_must_directly_refer_to_a_built_in_symbol); } - else if (node.parent.kind === 153) { + else if (node.parent.kind === 155) { return checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_type_literal_must_directly_refer_to_a_built_in_symbol); } } function isIterationStatement(node, lookInLabeledStatements) { switch (node.kind) { + case 199: + case 200: + case 201: case 197: case 198: - case 199: - case 195: - case 196: return true; - case 205: + case 207: return lookInLabeledStatements && isIterationStatement(node.statement, lookInLabeledStatements); } return false; @@ -21993,9 +22447,9 @@ var ts; return grammarErrorOnNode(node, ts.Diagnostics.Jump_target_cannot_cross_function_boundary); } switch (current.kind) { - case 205: + case 207: if (node.label && current.label.text === node.label.text) { - var isMisplacedContinueLabel = node.kind === 200 + var isMisplacedContinueLabel = node.kind === 202 && !isIterationStatement(current.statement, true); if (isMisplacedContinueLabel) { return grammarErrorOnNode(node, ts.Diagnostics.A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement); @@ -22003,8 +22457,8 @@ var ts; return false; } break; - case 204: - if (node.kind === 201 && !node.label) { + case 206: + if (node.kind === 203 && !node.label) { return false; } break; @@ -22017,13 +22471,13 @@ var ts; current = current.parent; } if (node.label) { - var message = node.kind === 201 + var message = node.kind === 203 ? ts.Diagnostics.A_break_statement_can_only_jump_to_a_label_of_an_enclosing_statement : ts.Diagnostics.A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement; return grammarErrorOnNode(node, message); } else { - var message = node.kind === 201 + var message = node.kind === 203 ? ts.Diagnostics.A_break_statement_can_only_be_used_within_an_enclosing_iteration_or_switch_statement : ts.Diagnostics.A_continue_statement_can_only_be_used_within_an_enclosing_iteration_statement; return grammarErrorOnNode(node, message); @@ -22035,7 +22489,7 @@ var ts; if (node !== ts.lastOrUndefined(elements)) { return grammarErrorOnNode(node, ts.Diagnostics.A_rest_element_must_be_last_in_an_array_destructuring_pattern); } - if (node.name.kind === 160 || node.name.kind === 159) { + if (node.name.kind === 162 || node.name.kind === 161) { return grammarErrorOnNode(node.name, ts.Diagnostics.A_rest_element_cannot_contain_a_binding_pattern); } if (node.initializer) { @@ -22044,7 +22498,7 @@ var ts; } } function checkGrammarVariableDeclaration(node) { - if (node.parent.parent.kind !== 198 && node.parent.parent.kind !== 199) { + if (node.parent.parent.kind !== 200 && node.parent.parent.kind !== 201) { if (ts.isInAmbientContext(node)) { if (node.initializer) { var equalsTokenLength = "=".length; @@ -22064,7 +22518,7 @@ var ts; return checkLetConstNames && checkGrammarNameInLetOrConstDeclarations(node.name); } function checkGrammarNameInLetOrConstDeclarations(name) { - if (name.kind === 67) { + if (name.kind === 69) { if (name.text === "let") { return grammarErrorOnNode(name, ts.Diagnostics.let_is_not_allowed_to_be_used_as_a_name_in_let_or_const_declarations); } @@ -22073,7 +22527,7 @@ var ts; var elements = name.elements; for (var _i = 0; _i < elements.length; _i++) { var element = elements[_i]; - if (element.kind !== 185) { + if (element.kind !== 187) { checkGrammarNameInLetOrConstDeclarations(element.name); } } @@ -22090,15 +22544,15 @@ var ts; } function allowLetAndConstDeclarations(parent) { switch (parent.kind) { - case 194: - case 195: case 196: - case 203: case 197: case 198: - case 199: - return false; case 205: + case 199: + case 200: + case 201: + return false; + case 207: return allowLetAndConstDeclarations(parent.parent); } return true; @@ -22114,7 +22568,7 @@ var ts; } } function isIntegerLiteral(expression) { - if (expression.kind === 177) { + if (expression.kind === 179) { var unaryExpression = expression; if (unaryExpression.operator === 35 || unaryExpression.operator === 36) { expression = unaryExpression.operand; @@ -22125,32 +22579,6 @@ var ts; } return false; } - function checkGrammarEnumDeclaration(enumDecl) { - var enumIsConst = (enumDecl.flags & 32768) !== 0; - var hasError = false; - if (!enumIsConst) { - var inConstantEnumMemberSection = true; - var inAmbientContext = ts.isInAmbientContext(enumDecl); - for (var _i = 0, _a = enumDecl.members; _i < _a.length; _i++) { - var node = _a[_i]; - if (node.name.kind === 134) { - hasError = grammarErrorOnNode(node.name, ts.Diagnostics.Computed_property_names_are_not_allowed_in_enums); - } - else if (inAmbientContext) { - if (node.initializer && !isIntegerLiteral(node.initializer)) { - hasError = grammarErrorOnNode(node.name, ts.Diagnostics.Ambient_enum_elements_can_only_have_integer_literal_initializers) || hasError; - } - } - else if (node.initializer) { - inConstantEnumMemberSection = isIntegerLiteral(node.initializer); - } - else if (!inConstantEnumMemberSection) { - hasError = grammarErrorOnNode(node.name, ts.Diagnostics.Enum_member_must_have_initializer) || hasError; - } - } - } - return hasError; - } function hasParseDiagnostics(sourceFile) { return sourceFile.parseDiagnostics.length > 0; } @@ -22176,7 +22604,7 @@ var ts; } } function isEvalOrArgumentsIdentifier(node) { - return node.kind === 67 && + return node.kind === 69 && (node.text === "eval" || node.text === "arguments"); } function checkGrammarConstructorTypeParameters(node) { @@ -22196,12 +22624,12 @@ var ts; return true; } } - else if (node.parent.kind === 213) { + else if (node.parent.kind === 215) { if (checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_an_interface_must_directly_refer_to_a_built_in_symbol)) { return true; } } - else if (node.parent.kind === 153) { + else if (node.parent.kind === 155) { if (checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_type_literal_must_directly_refer_to_a_built_in_symbol)) { return true; } @@ -22211,11 +22639,11 @@ var ts; } } function checkGrammarTopLevelElementForRequiredDeclareModifier(node) { - if (node.kind === 213 || - node.kind === 220 || - node.kind === 219 || - node.kind === 226 || - node.kind === 225 || + if (node.kind === 215 || + node.kind === 222 || + node.kind === 221 || + node.kind === 228 || + node.kind === 227 || (node.flags & 2) || (node.flags & (1 | 1024))) { return false; @@ -22225,7 +22653,7 @@ var ts; function checkGrammarTopLevelElementsForRequiredDeclareModifier(file) { for (var _i = 0, _a = file.statements; _i < _a.length; _i++) { var decl = _a[_i]; - if (ts.isDeclaration(decl) || decl.kind === 191) { + if (ts.isDeclaration(decl) || decl.kind === 193) { if (checkGrammarTopLevelElementForRequiredDeclareModifier(decl)) { return true; } @@ -22244,7 +22672,7 @@ var ts; if (!links.hasReportedStatementInAmbientContext && ts.isFunctionLike(node.parent)) { return getNodeLinks(node).hasReportedStatementInAmbientContext = grammarErrorOnFirstToken(node, ts.Diagnostics.An_implementation_cannot_be_declared_in_ambient_contexts); } - if (node.parent.kind === 190 || node.parent.kind === 217 || node.parent.kind === 246) { + if (node.parent.kind === 192 || node.parent.kind === 219 || node.parent.kind === 248) { var links_1 = getNodeLinks(node.parent); if (!links_1.hasReportedStatementInAmbientContext) { return links_1.hasReportedStatementInAmbientContext = grammarErrorOnFirstToken(node, ts.Diagnostics.Statements_are_not_allowed_in_ambient_contexts); @@ -22291,6 +22719,7 @@ var ts; var enclosingDeclaration; var currentSourceFile; var reportedDeclarationError = false; + var errorNameNode; var emitJsDocComments = compilerOptions.removeComments ? function (declaration) { } : writeJsDocComments; var emit = compilerOptions.stripInternal ? stripInternal : emitNode; var moduleElementDeclarationEmitInfo = []; @@ -22316,7 +22745,7 @@ var ts; var oldWriter = writer; ts.forEach(moduleElementDeclarationEmitInfo, function (aliasEmitInfo) { if (aliasEmitInfo.isVisible) { - ts.Debug.assert(aliasEmitInfo.node.kind === 220); + ts.Debug.assert(aliasEmitInfo.node.kind === 222); createAndSetNewTextWriterWithSymbolWriter(); ts.Debug.assert(aliasEmitInfo.indent === 0); writeImportDeclaration(aliasEmitInfo.node); @@ -22367,6 +22796,7 @@ var ts; function createAndSetNewTextWriterWithSymbolWriter() { var writer = ts.createTextWriter(newLine); writer.trackSymbol = trackSymbol; + writer.reportInaccessibleThisError = reportInaccessibleThisError; writer.writeKeyword = writer.write; writer.writeOperator = writer.write; writer.writePunctuation = writer.write; @@ -22389,10 +22819,10 @@ var ts; var oldWriter = writer; ts.forEach(nodes, function (declaration) { var nodeToCheck; - if (declaration.kind === 209) { + if (declaration.kind === 211) { nodeToCheck = declaration.parent.parent; } - else if (declaration.kind === 223 || declaration.kind === 224 || declaration.kind === 221) { + else if (declaration.kind === 225 || declaration.kind === 226 || declaration.kind === 223) { ts.Debug.fail("We should be getting ImportDeclaration instead to write"); } else { @@ -22403,7 +22833,7 @@ var ts; moduleElementEmitInfo = ts.forEach(asynchronousSubModuleDeclarationEmitInfo, function (declEmitInfo) { return declEmitInfo.node === nodeToCheck ? declEmitInfo : undefined; }); } if (moduleElementEmitInfo) { - if (moduleElementEmitInfo.node.kind === 220) { + if (moduleElementEmitInfo.node.kind === 222) { moduleElementEmitInfo.isVisible = true; } else { @@ -22411,12 +22841,12 @@ var ts; for (var declarationIndent = moduleElementEmitInfo.indent; declarationIndent; declarationIndent--) { increaseIndent(); } - if (nodeToCheck.kind === 216) { + if (nodeToCheck.kind === 218) { ts.Debug.assert(asynchronousSubModuleDeclarationEmitInfo === undefined); asynchronousSubModuleDeclarationEmitInfo = []; } writeModuleElement(nodeToCheck); - if (nodeToCheck.kind === 216) { + if (nodeToCheck.kind === 218) { moduleElementEmitInfo.subModuleElementDeclarationEmitInfo = asynchronousSubModuleDeclarationEmitInfo; asynchronousSubModuleDeclarationEmitInfo = undefined; } @@ -22448,6 +22878,11 @@ var ts; function trackSymbol(symbol, enclosingDeclaration, meaning) { handleSymbolAccessibilityError(resolver.isSymbolAccessible(symbol, enclosingDeclaration, meaning)); } + function reportInaccessibleThisError() { + if (errorNameNode) { + diagnostics.push(ts.createDiagnosticForNode(errorNameNode, ts.Diagnostics.The_inferred_type_of_0_references_an_inaccessible_this_type_A_type_annotation_is_necessary, ts.declarationNameToString(errorNameNode))); + } + } function writeTypeOfDeclaration(declaration, type, getSymbolAccessibilityDiagnostic) { writer.getSymbolAccessibilityDiagnostic = getSymbolAccessibilityDiagnostic; write(": "); @@ -22455,7 +22890,9 @@ var ts; emitType(type); } else { + errorNameNode = declaration.name; resolver.writeTypeOfDeclaration(declaration, enclosingDeclaration, 2, writer); + errorNameNode = undefined; } } function writeReturnTypeAtSignature(signature, getSymbolAccessibilityDiagnostic) { @@ -22465,7 +22902,9 @@ var ts; emitType(signature.type); } else { + errorNameNode = signature.name; resolver.writeReturnTypeOfSignatureDeclaration(signature, enclosingDeclaration, 2, writer); + errorNameNode = undefined; } } function emitLines(nodes) { @@ -22503,62 +22942,63 @@ var ts; } function emitType(type) { switch (type.kind) { - case 115: + case 117: + case 130: case 128: - case 126: - case 118: - case 129: - case 101: + case 120: + case 131: + case 103: + case 97: case 9: return writeTextOfNode(currentSourceFile, type); - case 186: + case 188: return emitExpressionWithTypeArguments(type); - case 149: - return emitTypeReference(type); - case 152: - return emitTypeQuery(type); - case 154: - return emitArrayType(type); - case 155: - return emitTupleType(type); - case 156: - return emitUnionType(type); - case 157: - return emitIntersectionType(type); - case 158: - return emitParenType(type); - case 150: case 151: - return emitSignatureDeclarationWithJsDocComments(type); + return emitTypeReference(type); + case 154: + return emitTypeQuery(type); + case 156: + return emitArrayType(type); + case 157: + return emitTupleType(type); + case 158: + return emitUnionType(type); + case 159: + return emitIntersectionType(type); + case 160: + return emitParenType(type); + case 152: case 153: + return emitSignatureDeclarationWithJsDocComments(type); + case 155: return emitTypeLiteral(type); - case 67: + case 69: return emitEntityName(type); - case 133: + case 135: return emitEntityName(type); - case 148: + case 150: return emitTypePredicate(type); } function writeEntityName(entityName) { - if (entityName.kind === 67) { + if (entityName.kind === 69) { writeTextOfNode(currentSourceFile, entityName); } else { - var left = entityName.kind === 133 ? entityName.left : entityName.expression; - var right = entityName.kind === 133 ? entityName.right : entityName.name; + var left = entityName.kind === 135 ? entityName.left : entityName.expression; + var right = entityName.kind === 135 ? entityName.right : entityName.name; writeEntityName(left); write("."); writeTextOfNode(currentSourceFile, right); } } function emitEntityName(entityName) { - var visibilityResult = resolver.isEntityNameVisible(entityName, entityName.parent.kind === 219 ? entityName.parent : enclosingDeclaration); + var visibilityResult = resolver.isEntityNameVisible(entityName, entityName.parent.kind === 221 ? entityName.parent : enclosingDeclaration); handleSymbolAccessibilityError(visibilityResult); writeEntityName(entityName); } function emitExpressionWithTypeArguments(node) { if (ts.isSupportedExpressionWithTypeArguments(node)) { - ts.Debug.assert(node.expression.kind === 67 || node.expression.kind === 164); + ts.Debug.assert(node.expression.kind === 69 || node.expression.kind === 166); emitEntityName(node.expression); if (node.typeArguments) { write("<"); @@ -22634,7 +23074,7 @@ var ts; } } function emitExportAssignment(node) { - if (node.expression.kind === 67) { + if (node.expression.kind === 69) { write(node.isExportEquals ? "export = " : "export default "); writeTextOfNode(currentSourceFile, node.expression); } @@ -22652,7 +23092,7 @@ var ts; } write(";"); writeLine(); - if (node.expression.kind === 67) { + if (node.expression.kind === 69) { var nodes = resolver.collectLinkedAliases(node.expression); writeAsynchronousModuleElements(nodes); } @@ -22670,10 +23110,10 @@ var ts; if (isModuleElementVisible) { writeModuleElement(node); } - else if (node.kind === 219 || - (node.parent.kind === 246 && ts.isExternalModule(currentSourceFile))) { + else if (node.kind === 221 || + (node.parent.kind === 248 && ts.isExternalModule(currentSourceFile))) { var isVisible; - if (asynchronousSubModuleDeclarationEmitInfo && node.parent.kind !== 246) { + if (asynchronousSubModuleDeclarationEmitInfo && node.parent.kind !== 248) { asynchronousSubModuleDeclarationEmitInfo.push({ node: node, outputPos: writer.getTextPos(), @@ -22682,7 +23122,7 @@ var ts; }); } else { - if (node.kind === 220) { + if (node.kind === 222) { var importDeclaration = node; if (importDeclaration.importClause) { isVisible = (importDeclaration.importClause.name && resolver.isDeclarationVisible(importDeclaration.importClause)) || @@ -22700,23 +23140,23 @@ var ts; } function writeModuleElement(node) { switch (node.kind) { - case 211: - return writeFunctionDeclaration(node); - case 191: - return writeVariableStatement(node); case 213: - return writeInterfaceDeclaration(node); - case 212: - return writeClassDeclaration(node); - case 214: - return writeTypeAliasDeclaration(node); + return writeFunctionDeclaration(node); + case 193: + return writeVariableStatement(node); case 215: - return writeEnumDeclaration(node); + return writeInterfaceDeclaration(node); + case 214: + return writeClassDeclaration(node); case 216: + return writeTypeAliasDeclaration(node); + case 217: + return writeEnumDeclaration(node); + case 218: return writeModuleDeclaration(node); - case 219: + case 221: return writeImportEqualsDeclaration(node); - case 220: + case 222: return writeImportDeclaration(node); default: ts.Debug.fail("Unknown symbol kind"); @@ -22730,7 +23170,7 @@ var ts; if (node.flags & 1024) { write("default "); } - else if (node.kind !== 213) { + else if (node.kind !== 215) { write("declare "); } } @@ -22777,7 +23217,7 @@ var ts; } function isVisibleNamedBinding(namedBindings) { if (namedBindings) { - if (namedBindings.kind === 222) { + if (namedBindings.kind === 224) { return resolver.isDeclarationVisible(namedBindings); } else { @@ -22803,7 +23243,7 @@ var ts; if (currentWriterPos !== writer.getTextPos()) { write(", "); } - if (node.importClause.namedBindings.kind === 222) { + if (node.importClause.namedBindings.kind === 224) { write("* as "); writeTextOfNode(currentSourceFile, node.importClause.namedBindings.name); } @@ -22859,7 +23299,7 @@ var ts; write("module "); } writeTextOfNode(currentSourceFile, node.name); - while (node.body.kind !== 217) { + while (node.body.kind !== 219) { node = node.body; write("."); writeTextOfNode(currentSourceFile, node.name); @@ -22924,7 +23364,7 @@ var ts; writeLine(); } function isPrivateMethodTypeParameter(node) { - return node.parent.kind === 141 && (node.parent.flags & 32); + return node.parent.kind === 143 && (node.parent.flags & 32); } function emitTypeParameters(typeParameters) { function emitTypeParameter(node) { @@ -22934,15 +23374,15 @@ var ts; writeTextOfNode(currentSourceFile, node.name); if (node.constraint && !isPrivateMethodTypeParameter(node)) { write(" extends "); - if (node.parent.kind === 150 || - node.parent.kind === 151 || - (node.parent.parent && node.parent.parent.kind === 153)) { - ts.Debug.assert(node.parent.kind === 141 || - node.parent.kind === 140 || - node.parent.kind === 150 || - node.parent.kind === 151 || - node.parent.kind === 145 || - node.parent.kind === 146); + if (node.parent.kind === 152 || + node.parent.kind === 153 || + (node.parent.parent && node.parent.parent.kind === 155)) { + ts.Debug.assert(node.parent.kind === 143 || + node.parent.kind === 142 || + node.parent.kind === 152 || + node.parent.kind === 153 || + node.parent.kind === 147 || + node.parent.kind === 148); emitType(node.constraint); } else { @@ -22952,31 +23392,31 @@ var ts; function getTypeParameterConstraintVisibilityError(symbolAccesibilityResult) { var diagnosticMessage; switch (node.parent.kind) { - case 212: + case 214: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_class_has_or_is_using_private_name_1; break; - case 213: + case 215: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1; break; - case 146: + case 148: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 145: + case 147: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 141: - case 140: + case 143: + case 142: if (node.parent.flags & 128) { diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.parent.kind === 212) { + else if (node.parent.parent.kind === 214) { diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_public_method_from_exported_class_has_or_is_using_private_name_1; } else { diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1; } break; - case 211: + case 213: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_function_has_or_is_using_private_name_1; break; default: @@ -23004,12 +23444,12 @@ var ts; if (ts.isSupportedExpressionWithTypeArguments(node)) { emitTypeWithNewGetSymbolAccessibilityDiagnostic(node, getHeritageClauseVisibilityError); } - else if (!isImplementsList && node.expression.kind === 91) { + else if (!isImplementsList && node.expression.kind === 93) { write("null"); } function getHeritageClauseVisibilityError(symbolAccesibilityResult) { var diagnosticMessage; - if (node.parent.parent.kind === 212) { + if (node.parent.parent.kind === 214) { diagnosticMessage = isImplementsList ? ts.Diagnostics.Implements_clause_of_exported_class_0_has_or_is_using_private_name_1 : ts.Diagnostics.Extends_clause_of_exported_class_0_has_or_is_using_private_name_1; @@ -23089,16 +23529,16 @@ var ts; writeLine(); } function emitVariableDeclaration(node) { - if (node.kind !== 209 || resolver.isDeclarationVisible(node)) { + if (node.kind !== 211 || resolver.isDeclarationVisible(node)) { if (ts.isBindingPattern(node.name)) { emitBindingPattern(node.name); } else { writeTextOfNode(currentSourceFile, node.name); - if ((node.kind === 139 || node.kind === 138) && ts.hasQuestionToken(node)) { + if ((node.kind === 141 || node.kind === 140) && ts.hasQuestionToken(node)) { write("?"); } - if ((node.kind === 139 || node.kind === 138) && node.parent.kind === 153) { + if ((node.kind === 141 || node.kind === 140) && node.parent.kind === 155) { emitTypeOfVariableDeclarationFromTypeLiteral(node); } else if (!(node.flags & 32)) { @@ -23107,14 +23547,14 @@ var ts; } } function getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccesibilityResult) { - if (node.kind === 209) { + if (node.kind === 211) { return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 ? ts.Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Exported_variable_0_has_or_is_using_private_name_1; } - else if (node.kind === 139 || node.kind === 138) { + else if (node.kind === 141 || node.kind === 140) { if (node.flags & 128) { return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 ? @@ -23122,7 +23562,7 @@ var ts; ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.kind === 212) { + else if (node.parent.kind === 214) { return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 ? ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -23148,7 +23588,7 @@ var ts; var elements = []; for (var _i = 0, _a = bindingPattern.elements; _i < _a.length; _i++) { var element = _a[_i]; - if (element.kind !== 185) { + if (element.kind !== 187) { elements.push(element); } } @@ -23214,7 +23654,7 @@ var ts; accessorWithTypeAnnotation = node; var type = getTypeAnnotationFromAccessor(node); if (!type) { - var anotherAccessor = node.kind === 143 ? accessors.setAccessor : accessors.getAccessor; + var anotherAccessor = node.kind === 145 ? accessors.setAccessor : accessors.getAccessor; type = getTypeAnnotationFromAccessor(anotherAccessor); if (type) { accessorWithTypeAnnotation = anotherAccessor; @@ -23227,7 +23667,7 @@ var ts; } function getTypeAnnotationFromAccessor(accessor) { if (accessor) { - return accessor.kind === 143 + return accessor.kind === 145 ? accessor.type : accessor.parameters.length > 0 ? accessor.parameters[0].type @@ -23236,7 +23676,7 @@ var ts; } function getAccessorDeclarationTypeVisibilityError(symbolAccesibilityResult) { var diagnosticMessage; - if (accessorWithTypeAnnotation.kind === 144) { + if (accessorWithTypeAnnotation.kind === 146) { if (accessorWithTypeAnnotation.parent.flags & 128) { diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_public_static_property_setter_from_exported_class_has_or_is_using_name_1_from_private_module_2 : @@ -23282,17 +23722,17 @@ var ts; } if (!resolver.isImplementationOfOverload(node)) { emitJsDocComments(node); - if (node.kind === 211) { + if (node.kind === 213) { emitModuleElementDeclarationFlags(node); } - else if (node.kind === 141) { + else if (node.kind === 143) { emitClassMemberDeclarationFlags(node); } - if (node.kind === 211) { + if (node.kind === 213) { write("function "); writeTextOfNode(currentSourceFile, node.name); } - else if (node.kind === 142) { + else if (node.kind === 144) { write("constructor"); } else { @@ -23309,11 +23749,11 @@ var ts; emitSignatureDeclaration(node); } function emitSignatureDeclaration(node) { - if (node.kind === 146 || node.kind === 151) { + if (node.kind === 148 || node.kind === 153) { write("new "); } emitTypeParameters(node.typeParameters); - if (node.kind === 147) { + if (node.kind === 149) { write("["); } else { @@ -23322,20 +23762,20 @@ var ts; var prevEnclosingDeclaration = enclosingDeclaration; enclosingDeclaration = node; emitCommaList(node.parameters, emitParameterDeclaration); - if (node.kind === 147) { + if (node.kind === 149) { write("]"); } else { write(")"); } - var isFunctionTypeOrConstructorType = node.kind === 150 || node.kind === 151; - if (isFunctionTypeOrConstructorType || node.parent.kind === 153) { + var isFunctionTypeOrConstructorType = node.kind === 152 || node.kind === 153; + if (isFunctionTypeOrConstructorType || node.parent.kind === 155) { if (node.type) { write(isFunctionTypeOrConstructorType ? " => " : ": "); emitType(node.type); } } - else if (node.kind !== 142 && !(node.flags & 32)) { + else if (node.kind !== 144 && !(node.flags & 32)) { writeReturnTypeAtSignature(node, getReturnTypeVisibilityError); } enclosingDeclaration = prevEnclosingDeclaration; @@ -23346,23 +23786,23 @@ var ts; function getReturnTypeVisibilityError(symbolAccesibilityResult) { var diagnosticMessage; switch (node.kind) { - case 146: + case 148: diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_0; break; - case 145: + case 147: diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_call_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_call_signature_from_exported_interface_has_or_is_using_private_name_0; break; - case 147: + case 149: diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_index_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_index_signature_from_exported_interface_has_or_is_using_private_name_0; break; - case 141: - case 140: + case 143: + case 142: if (node.flags & 128) { diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 ? @@ -23370,7 +23810,7 @@ var ts; ts.Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_private_name_0; } - else if (node.parent.kind === 212) { + else if (node.parent.kind === 214) { diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 ? ts.Diagnostics.Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : @@ -23383,7 +23823,7 @@ var ts; ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0; } break; - case 211: + case 213: diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 ? ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : @@ -23415,9 +23855,9 @@ var ts; write("?"); } decreaseIndent(); - if (node.parent.kind === 150 || - node.parent.kind === 151 || - node.parent.parent.kind === 153) { + if (node.parent.kind === 152 || + node.parent.kind === 153 || + node.parent.parent.kind === 155) { emitTypeOfVariableDeclarationFromTypeLiteral(node); } else if (!(node.parent.flags & 32)) { @@ -23433,22 +23873,22 @@ var ts; } function getParameterDeclarationTypeVisibilityDiagnosticMessage(symbolAccesibilityResult) { switch (node.parent.kind) { - case 142: + case 144: return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 ? ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_private_name_1; - case 146: + case 148: return symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; - case 145: + case 147: return symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; - case 141: - case 140: + case 143: + case 142: if (node.parent.flags & 128) { return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 ? @@ -23456,7 +23896,7 @@ var ts; ts.Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.parent.kind === 212) { + else if (node.parent.parent.kind === 214) { return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 ? ts.Diagnostics.Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -23468,7 +23908,7 @@ var ts; ts.Diagnostics.Parameter_0_of_method_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1; } - case 211: + case 213: return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 ? ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -23479,12 +23919,12 @@ var ts; } } function emitBindingPattern(bindingPattern) { - if (bindingPattern.kind === 159) { + if (bindingPattern.kind === 161) { write("{"); emitCommaList(bindingPattern.elements, emitBindingElement); write("}"); } - else if (bindingPattern.kind === 160) { + else if (bindingPattern.kind === 162) { write("["); var elements = bindingPattern.elements; emitCommaList(elements, emitBindingElement); @@ -23503,10 +23943,10 @@ var ts; typeName: bindingElement.name } : undefined; } - if (bindingElement.kind === 185) { + if (bindingElement.kind === 187) { write(" "); } - else if (bindingElement.kind === 161) { + else if (bindingElement.kind === 163) { if (bindingElement.propertyName) { writeTextOfNode(currentSourceFile, bindingElement.propertyName); write(": "); @@ -23516,7 +23956,7 @@ var ts; emitBindingPattern(bindingElement.name); } else { - ts.Debug.assert(bindingElement.name.kind === 67); + ts.Debug.assert(bindingElement.name.kind === 69); if (bindingElement.dotDotDotToken) { write("..."); } @@ -23528,39 +23968,39 @@ var ts; } function emitNode(node) { switch (node.kind) { - case 211: - case 216: - case 219: case 213: - case 212: - case 214: + case 218: + case 221: case 215: + case 214: + case 216: + case 217: return emitModuleElement(node, isModuleElementVisible(node)); - case 191: + case 193: return emitModuleElement(node, isVariableStatementVisible(node)); - case 220: + case 222: return emitModuleElement(node, !node.importClause); - case 226: + case 228: return emitExportDeclaration(node); + case 144: + case 143: case 142: + return writeFunctionDeclaration(node); + case 148: + case 147: + case 149: + return emitSignatureDeclarationWithJsDocComments(node); + case 145: + case 146: + return emitAccessorDeclaration(node); case 141: case 140: - return writeFunctionDeclaration(node); - case 146: - case 145: - case 147: - return emitSignatureDeclarationWithJsDocComments(node); - case 143: - case 144: - return emitAccessorDeclaration(node); - case 139: - case 138: return emitPropertyDeclaration(node); - case 245: + case 247: return emitEnumMemberDeclaration(node); - case 225: + case 227: return emitExportAssignment(node); - case 246: + case 248: return emitSourceFile(node); } } @@ -23603,5471 +24043,6 @@ var ts; return ts.isExternalModule(sourceFile) || ts.isDeclarationFile(sourceFile); } ts.isExternalModuleOrDeclarationFile = isExternalModuleOrDeclarationFile; - function emitFiles(resolver, host, targetSourceFile) { - var extendsHelper = "\nvar __extends = (this && this.__extends) || function (d, b) {\n for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];\n function __() { this.constructor = d; }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n};"; - var decorateHelper = "\nvar __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") return Reflect.decorate(decorators, target, key, desc);\n switch (arguments.length) {\n case 2: return decorators.reduceRight(function(o, d) { return (d && d(o)) || o; }, target);\n case 3: return decorators.reduceRight(function(o, d) { return (d && d(target, key)), void 0; }, void 0);\n case 4: return decorators.reduceRight(function(o, d) { return (d && d(target, key, o)) || o; }, desc);\n }\n};"; - var metadataHelper = "\nvar __metadata = (this && this.__metadata) || function (k, v) {\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(k, v);\n};"; - var paramHelper = "\nvar __param = (this && this.__param) || function (paramIndex, decorator) {\n return function (target, key) { decorator(target, key, paramIndex); }\n};"; - var awaiterHelper = "\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promise, generator) {\n return new Promise(function (resolve, reject) {\n generator = generator.call(thisArg, _arguments);\n function cast(value) { return value instanceof Promise && value.constructor === Promise ? value : new Promise(function (resolve) { resolve(value); }); }\n function onfulfill(value) { try { step(\"next\", value); } catch (e) { reject(e); } }\n function onreject(value) { try { step(\"throw\", value); } catch (e) { reject(e); } }\n function step(verb, value) {\n var result = generator[verb](value);\n result.done ? resolve(result.value) : cast(result.value).then(onfulfill, onreject);\n }\n step(\"next\", void 0);\n });\n};"; - var compilerOptions = host.getCompilerOptions(); - var languageVersion = compilerOptions.target || 0; - var sourceMapDataList = compilerOptions.sourceMap || compilerOptions.inlineSourceMap ? [] : undefined; - var diagnostics = []; - var newLine = host.getNewLine(); - var jsxDesugaring = host.getCompilerOptions().jsx !== 1; - var shouldEmitJsx = function (s) { return (s.languageVariant === 1 && !jsxDesugaring); }; - if (targetSourceFile === undefined) { - ts.forEach(host.getSourceFiles(), function (sourceFile) { - if (ts.shouldEmitToOwnFile(sourceFile, compilerOptions)) { - var jsFilePath = ts.getOwnEmitOutputFilePath(sourceFile, host, shouldEmitJsx(sourceFile) ? ".jsx" : ".js"); - emitFile(jsFilePath, sourceFile); - } - }); - if (compilerOptions.outFile || compilerOptions.out) { - emitFile(compilerOptions.outFile || compilerOptions.out); - } - } - else { - if (ts.shouldEmitToOwnFile(targetSourceFile, compilerOptions)) { - var jsFilePath = ts.getOwnEmitOutputFilePath(targetSourceFile, host, shouldEmitJsx(targetSourceFile) ? ".jsx" : ".js"); - emitFile(jsFilePath, targetSourceFile); - } - else if (!ts.isDeclarationFile(targetSourceFile) && (compilerOptions.outFile || compilerOptions.out)) { - emitFile(compilerOptions.outFile || compilerOptions.out); - } - } - diagnostics = ts.sortAndDeduplicateDiagnostics(diagnostics); - return { - emitSkipped: false, - diagnostics: diagnostics, - sourceMaps: sourceMapDataList - }; - function isNodeDescendentOf(node, ancestor) { - while (node) { - if (node === ancestor) - return true; - node = node.parent; - } - return false; - } - function isUniqueLocalName(name, container) { - for (var node = container; isNodeDescendentOf(node, container); node = node.nextContainer) { - if (node.locals && ts.hasProperty(node.locals, name)) { - if (node.locals[name].flags & (107455 | 1048576 | 8388608)) { - return false; - } - } - } - return true; - } - function emitJavaScript(jsFilePath, root) { - var writer = ts.createTextWriter(newLine); - var write = writer.write, writeTextOfNode = writer.writeTextOfNode, writeLine = writer.writeLine, increaseIndent = writer.increaseIndent, decreaseIndent = writer.decreaseIndent; - var currentSourceFile; - var exportFunctionForFile; - var generatedNameSet = {}; - var nodeToGeneratedName = []; - var computedPropertyNamesToGeneratedNames; - var extendsEmitted = false; - var decorateEmitted = false; - var paramEmitted = false; - var awaiterEmitted = false; - var tempFlags = 0; - var tempVariables; - var tempParameters; - var externalImports; - var exportSpecifiers; - var exportEquals; - var hasExportStars; - var writeEmittedFiles = writeJavaScriptFile; - var detachedCommentsInfo; - var writeComment = ts.writeCommentRange; - var emit = emitNodeWithCommentsAndWithoutSourcemap; - var emitStart = function (node) { }; - var emitEnd = function (node) { }; - var emitToken = emitTokenText; - var scopeEmitStart = function (scopeDeclaration, scopeName) { }; - var scopeEmitEnd = function () { }; - var sourceMapData; - var emitLeadingCommentsOfPosition = compilerOptions.removeComments ? function (pos) { } : emitLeadingCommentsOfPositionWorker; - if (compilerOptions.sourceMap || compilerOptions.inlineSourceMap) { - initializeEmitterWithSourceMaps(); - } - if (root) { - emitSourceFile(root); - } - else { - ts.forEach(host.getSourceFiles(), function (sourceFile) { - if (!isExternalModuleOrDeclarationFile(sourceFile)) { - emitSourceFile(sourceFile); - } - }); - } - writeLine(); - writeEmittedFiles(writer.getText(), compilerOptions.emitBOM); - return; - function emitSourceFile(sourceFile) { - currentSourceFile = sourceFile; - exportFunctionForFile = undefined; - emit(sourceFile); - } - function isUniqueName(name) { - return !resolver.hasGlobalName(name) && - !ts.hasProperty(currentSourceFile.identifiers, name) && - !ts.hasProperty(generatedNameSet, name); - } - function makeTempVariableName(flags) { - if (flags && !(tempFlags & flags)) { - var name_19 = flags === 268435456 ? "_i" : "_n"; - if (isUniqueName(name_19)) { - tempFlags |= flags; - return name_19; - } - } - while (true) { - var count = tempFlags & 268435455; - tempFlags++; - if (count !== 8 && count !== 13) { - var name_20 = count < 26 ? "_" + String.fromCharCode(97 + count) : "_" + (count - 26); - if (isUniqueName(name_20)) { - return name_20; - } - } - } - } - function makeUniqueName(baseName) { - if (baseName.charCodeAt(baseName.length - 1) !== 95) { - baseName += "_"; - } - var i = 1; - while (true) { - var generatedName = baseName + i; - if (isUniqueName(generatedName)) { - return generatedNameSet[generatedName] = generatedName; - } - i++; - } - } - function generateNameForModuleOrEnum(node) { - var name = node.name.text; - return isUniqueLocalName(name, node) ? name : makeUniqueName(name); - } - function generateNameForImportOrExportDeclaration(node) { - var expr = ts.getExternalModuleName(node); - var baseName = expr.kind === 9 ? - ts.escapeIdentifier(ts.makeIdentifierFromModuleName(expr.text)) : "module"; - return makeUniqueName(baseName); - } - function generateNameForExportDefault() { - return makeUniqueName("default"); - } - function generateNameForClassExpression() { - return makeUniqueName("class"); - } - function generateNameForNode(node) { - switch (node.kind) { - case 67: - return makeUniqueName(node.text); - case 216: - case 215: - return generateNameForModuleOrEnum(node); - case 220: - case 226: - return generateNameForImportOrExportDeclaration(node); - case 211: - case 212: - case 225: - return generateNameForExportDefault(); - case 184: - return generateNameForClassExpression(); - } - } - function getGeneratedNameForNode(node) { - var id = ts.getNodeId(node); - return nodeToGeneratedName[id] || (nodeToGeneratedName[id] = ts.unescapeIdentifier(generateNameForNode(node))); - } - function initializeEmitterWithSourceMaps() { - var sourceMapDir; - var sourceMapSourceIndex = -1; - var sourceMapNameIndexMap = {}; - var sourceMapNameIndices = []; - function getSourceMapNameIndex() { - return sourceMapNameIndices.length ? ts.lastOrUndefined(sourceMapNameIndices) : -1; - } - var lastRecordedSourceMapSpan; - var lastEncodedSourceMapSpan = { - emittedLine: 1, - emittedColumn: 1, - sourceLine: 1, - sourceColumn: 1, - sourceIndex: 0 - }; - var lastEncodedNameIndex = 0; - function encodeLastRecordedSourceMapSpan() { - if (!lastRecordedSourceMapSpan || lastRecordedSourceMapSpan === lastEncodedSourceMapSpan) { - return; - } - var prevEncodedEmittedColumn = lastEncodedSourceMapSpan.emittedColumn; - if (lastEncodedSourceMapSpan.emittedLine === lastRecordedSourceMapSpan.emittedLine) { - if (sourceMapData.sourceMapMappings) { - sourceMapData.sourceMapMappings += ","; - } - } - else { - for (var encodedLine = lastEncodedSourceMapSpan.emittedLine; encodedLine < lastRecordedSourceMapSpan.emittedLine; encodedLine++) { - sourceMapData.sourceMapMappings += ";"; - } - prevEncodedEmittedColumn = 1; - } - sourceMapData.sourceMapMappings += base64VLQFormatEncode(lastRecordedSourceMapSpan.emittedColumn - prevEncodedEmittedColumn); - sourceMapData.sourceMapMappings += base64VLQFormatEncode(lastRecordedSourceMapSpan.sourceIndex - lastEncodedSourceMapSpan.sourceIndex); - sourceMapData.sourceMapMappings += base64VLQFormatEncode(lastRecordedSourceMapSpan.sourceLine - lastEncodedSourceMapSpan.sourceLine); - sourceMapData.sourceMapMappings += base64VLQFormatEncode(lastRecordedSourceMapSpan.sourceColumn - lastEncodedSourceMapSpan.sourceColumn); - if (lastRecordedSourceMapSpan.nameIndex >= 0) { - sourceMapData.sourceMapMappings += base64VLQFormatEncode(lastRecordedSourceMapSpan.nameIndex - lastEncodedNameIndex); - lastEncodedNameIndex = lastRecordedSourceMapSpan.nameIndex; - } - lastEncodedSourceMapSpan = lastRecordedSourceMapSpan; - sourceMapData.sourceMapDecodedMappings.push(lastEncodedSourceMapSpan); - function base64VLQFormatEncode(inValue) { - function base64FormatEncode(inValue) { - if (inValue < 64) { - return "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(inValue); - } - throw TypeError(inValue + ": not a 64 based value"); - } - if (inValue < 0) { - inValue = ((-inValue) << 1) + 1; - } - else { - inValue = inValue << 1; - } - var encodedStr = ""; - do { - var currentDigit = inValue & 31; - inValue = inValue >> 5; - if (inValue > 0) { - currentDigit = currentDigit | 32; - } - encodedStr = encodedStr + base64FormatEncode(currentDigit); - } while (inValue > 0); - return encodedStr; - } - } - function recordSourceMapSpan(pos) { - var sourceLinePos = ts.getLineAndCharacterOfPosition(currentSourceFile, pos); - sourceLinePos.line++; - sourceLinePos.character++; - var emittedLine = writer.getLine(); - var emittedColumn = writer.getColumn(); - if (!lastRecordedSourceMapSpan || - lastRecordedSourceMapSpan.emittedLine !== emittedLine || - lastRecordedSourceMapSpan.emittedColumn !== emittedColumn || - (lastRecordedSourceMapSpan.sourceIndex === sourceMapSourceIndex && - (lastRecordedSourceMapSpan.sourceLine > sourceLinePos.line || - (lastRecordedSourceMapSpan.sourceLine === sourceLinePos.line && lastRecordedSourceMapSpan.sourceColumn > sourceLinePos.character)))) { - encodeLastRecordedSourceMapSpan(); - lastRecordedSourceMapSpan = { - emittedLine: emittedLine, - emittedColumn: emittedColumn, - sourceLine: sourceLinePos.line, - sourceColumn: sourceLinePos.character, - nameIndex: getSourceMapNameIndex(), - sourceIndex: sourceMapSourceIndex - }; - } - else { - lastRecordedSourceMapSpan.sourceLine = sourceLinePos.line; - lastRecordedSourceMapSpan.sourceColumn = sourceLinePos.character; - lastRecordedSourceMapSpan.sourceIndex = sourceMapSourceIndex; - } - } - function recordEmitNodeStartSpan(node) { - recordSourceMapSpan(ts.skipTrivia(currentSourceFile.text, node.pos)); - } - function recordEmitNodeEndSpan(node) { - recordSourceMapSpan(node.end); - } - function writeTextWithSpanRecord(tokenKind, startPos, emitFn) { - var tokenStartPos = ts.skipTrivia(currentSourceFile.text, startPos); - recordSourceMapSpan(tokenStartPos); - var tokenEndPos = emitTokenText(tokenKind, tokenStartPos, emitFn); - recordSourceMapSpan(tokenEndPos); - return tokenEndPos; - } - function recordNewSourceFileStart(node) { - var sourcesDirectoryPath = compilerOptions.sourceRoot ? host.getCommonSourceDirectory() : sourceMapDir; - sourceMapData.sourceMapSources.push(ts.getRelativePathToDirectoryOrUrl(sourcesDirectoryPath, node.fileName, host.getCurrentDirectory(), host.getCanonicalFileName, true)); - sourceMapSourceIndex = sourceMapData.sourceMapSources.length - 1; - sourceMapData.inputSourceFileNames.push(node.fileName); - if (compilerOptions.inlineSources) { - if (!sourceMapData.sourceMapSourcesContent) { - sourceMapData.sourceMapSourcesContent = []; - } - sourceMapData.sourceMapSourcesContent.push(node.text); - } - } - function recordScopeNameOfNode(node, scopeName) { - function recordScopeNameIndex(scopeNameIndex) { - sourceMapNameIndices.push(scopeNameIndex); - } - function recordScopeNameStart(scopeName) { - var scopeNameIndex = -1; - if (scopeName) { - var parentIndex = getSourceMapNameIndex(); - if (parentIndex !== -1) { - var name_21 = node.name; - if (!name_21 || name_21.kind !== 134) { - scopeName = "." + scopeName; - } - scopeName = sourceMapData.sourceMapNames[parentIndex] + scopeName; - } - scopeNameIndex = ts.getProperty(sourceMapNameIndexMap, scopeName); - if (scopeNameIndex === undefined) { - scopeNameIndex = sourceMapData.sourceMapNames.length; - sourceMapData.sourceMapNames.push(scopeName); - sourceMapNameIndexMap[scopeName] = scopeNameIndex; - } - } - recordScopeNameIndex(scopeNameIndex); - } - if (scopeName) { - recordScopeNameStart(scopeName); - } - else if (node.kind === 211 || - node.kind === 171 || - node.kind === 141 || - node.kind === 140 || - node.kind === 143 || - node.kind === 144 || - node.kind === 216 || - node.kind === 212 || - node.kind === 215) { - if (node.name) { - var name_22 = node.name; - scopeName = name_22.kind === 134 - ? ts.getTextOfNode(name_22) - : node.name.text; - } - recordScopeNameStart(scopeName); - } - else { - recordScopeNameIndex(getSourceMapNameIndex()); - } - } - function recordScopeNameEnd() { - sourceMapNameIndices.pop(); - } - ; - function writeCommentRangeWithMap(curentSourceFile, writer, comment, newLine) { - recordSourceMapSpan(comment.pos); - ts.writeCommentRange(currentSourceFile, writer, comment, newLine); - recordSourceMapSpan(comment.end); - } - function serializeSourceMapContents(version, file, sourceRoot, sources, names, mappings, sourcesContent) { - if (typeof JSON !== "undefined") { - var map_1 = { - version: version, - file: file, - sourceRoot: sourceRoot, - sources: sources, - names: names, - mappings: mappings - }; - if (sourcesContent !== undefined) { - map_1.sourcesContent = sourcesContent; - } - return JSON.stringify(map_1); - } - return "{\"version\":" + version + ",\"file\":\"" + ts.escapeString(file) + "\",\"sourceRoot\":\"" + ts.escapeString(sourceRoot) + "\",\"sources\":[" + serializeStringArray(sources) + "],\"names\":[" + serializeStringArray(names) + "],\"mappings\":\"" + ts.escapeString(mappings) + "\" " + (sourcesContent !== undefined ? ",\"sourcesContent\":[" + serializeStringArray(sourcesContent) + "]" : "") + "}"; - function serializeStringArray(list) { - var output = ""; - for (var i = 0, n = list.length; i < n; i++) { - if (i) { - output += ","; - } - output += "\"" + ts.escapeString(list[i]) + "\""; - } - return output; - } - } - function writeJavaScriptAndSourceMapFile(emitOutput, writeByteOrderMark) { - encodeLastRecordedSourceMapSpan(); - var sourceMapText = serializeSourceMapContents(3, sourceMapData.sourceMapFile, sourceMapData.sourceMapSourceRoot, sourceMapData.sourceMapSources, sourceMapData.sourceMapNames, sourceMapData.sourceMapMappings, sourceMapData.sourceMapSourcesContent); - sourceMapDataList.push(sourceMapData); - var sourceMapUrl; - if (compilerOptions.inlineSourceMap) { - var base64SourceMapText = ts.convertToBase64(sourceMapText); - sourceMapUrl = "//# sourceMappingURL=data:application/json;base64," + base64SourceMapText; - } - else { - ts.writeFile(host, diagnostics, sourceMapData.sourceMapFilePath, sourceMapText, false); - sourceMapUrl = "//# sourceMappingURL=" + sourceMapData.jsSourceMappingURL; - } - writeJavaScriptFile(emitOutput + sourceMapUrl, writeByteOrderMark); - } - var sourceMapJsFile = ts.getBaseFileName(ts.normalizeSlashes(jsFilePath)); - sourceMapData = { - sourceMapFilePath: jsFilePath + ".map", - jsSourceMappingURL: sourceMapJsFile + ".map", - sourceMapFile: sourceMapJsFile, - sourceMapSourceRoot: compilerOptions.sourceRoot || "", - sourceMapSources: [], - inputSourceFileNames: [], - sourceMapNames: [], - sourceMapMappings: "", - sourceMapSourcesContent: undefined, - sourceMapDecodedMappings: [] - }; - sourceMapData.sourceMapSourceRoot = ts.normalizeSlashes(sourceMapData.sourceMapSourceRoot); - if (sourceMapData.sourceMapSourceRoot.length && sourceMapData.sourceMapSourceRoot.charCodeAt(sourceMapData.sourceMapSourceRoot.length - 1) !== 47) { - sourceMapData.sourceMapSourceRoot += ts.directorySeparator; - } - if (compilerOptions.mapRoot) { - sourceMapDir = ts.normalizeSlashes(compilerOptions.mapRoot); - if (root) { - sourceMapDir = ts.getDirectoryPath(ts.getSourceFilePathInNewDir(root, host, sourceMapDir)); - } - if (!ts.isRootedDiskPath(sourceMapDir) && !ts.isUrl(sourceMapDir)) { - sourceMapDir = ts.combinePaths(host.getCommonSourceDirectory(), sourceMapDir); - sourceMapData.jsSourceMappingURL = ts.getRelativePathToDirectoryOrUrl(ts.getDirectoryPath(ts.normalizePath(jsFilePath)), ts.combinePaths(sourceMapDir, sourceMapData.jsSourceMappingURL), host.getCurrentDirectory(), host.getCanonicalFileName, true); - } - else { - sourceMapData.jsSourceMappingURL = ts.combinePaths(sourceMapDir, sourceMapData.jsSourceMappingURL); - } - } - else { - sourceMapDir = ts.getDirectoryPath(ts.normalizePath(jsFilePath)); - } - function emitNodeWithSourceMap(node) { - if (node) { - if (ts.nodeIsSynthesized(node)) { - return emitNodeWithoutSourceMap(node); - } - if (node.kind !== 246) { - recordEmitNodeStartSpan(node); - emitNodeWithoutSourceMap(node); - recordEmitNodeEndSpan(node); - } - else { - recordNewSourceFileStart(node); - emitNodeWithoutSourceMap(node); - } - } - } - function emitNodeWithCommentsAndWithSourcemap(node) { - emitNodeConsideringCommentsOption(node, emitNodeWithSourceMap); - } - writeEmittedFiles = writeJavaScriptAndSourceMapFile; - emit = emitNodeWithCommentsAndWithSourcemap; - emitStart = recordEmitNodeStartSpan; - emitEnd = recordEmitNodeEndSpan; - emitToken = writeTextWithSpanRecord; - scopeEmitStart = recordScopeNameOfNode; - scopeEmitEnd = recordScopeNameEnd; - writeComment = writeCommentRangeWithMap; - } - function writeJavaScriptFile(emitOutput, writeByteOrderMark) { - ts.writeFile(host, diagnostics, jsFilePath, emitOutput, writeByteOrderMark); - } - function createTempVariable(flags) { - var result = ts.createSynthesizedNode(67); - result.text = makeTempVariableName(flags); - return result; - } - function recordTempDeclaration(name) { - if (!tempVariables) { - tempVariables = []; - } - tempVariables.push(name); - } - function createAndRecordTempVariable(flags) { - var temp = createTempVariable(flags); - recordTempDeclaration(temp); - return temp; - } - function emitTempDeclarations(newLine) { - if (tempVariables) { - if (newLine) { - writeLine(); - } - else { - write(" "); - } - write("var "); - emitCommaList(tempVariables); - write(";"); - } - } - function emitTokenText(tokenKind, startPos, emitFn) { - var tokenString = ts.tokenToString(tokenKind); - if (emitFn) { - emitFn(); - } - else { - write(tokenString); - } - return startPos + tokenString.length; - } - function emitOptional(prefix, node) { - if (node) { - write(prefix); - emit(node); - } - } - function emitParenthesizedIf(node, parenthesized) { - if (parenthesized) { - write("("); - } - emit(node); - if (parenthesized) { - write(")"); - } - } - function emitTrailingCommaIfPresent(nodeList) { - if (nodeList.hasTrailingComma) { - write(","); - } - } - function emitLinePreservingList(parent, nodes, allowTrailingComma, spacesBetweenBraces) { - ts.Debug.assert(nodes.length > 0); - increaseIndent(); - if (nodeStartPositionsAreOnSameLine(parent, nodes[0])) { - if (spacesBetweenBraces) { - write(" "); - } - } - else { - writeLine(); - } - for (var i = 0, n = nodes.length; i < n; i++) { - if (i) { - if (nodeEndIsOnSameLineAsNodeStart(nodes[i - 1], nodes[i])) { - write(", "); - } - else { - write(","); - writeLine(); - } - } - emit(nodes[i]); - } - if (nodes.hasTrailingComma && allowTrailingComma) { - write(","); - } - decreaseIndent(); - if (nodeEndPositionsAreOnSameLine(parent, ts.lastOrUndefined(nodes))) { - if (spacesBetweenBraces) { - write(" "); - } - } - else { - writeLine(); - } - } - function emitList(nodes, start, count, multiLine, trailingComma, leadingComma, noTrailingNewLine, emitNode) { - if (!emitNode) { - emitNode = emit; - } - for (var i = 0; i < count; i++) { - if (multiLine) { - if (i || leadingComma) { - write(","); - } - writeLine(); - } - else { - if (i || leadingComma) { - write(", "); - } - } - var node = nodes[start + i]; - emitTrailingCommentsOfPosition(node.pos); - emitNode(node); - leadingComma = true; - } - if (trailingComma) { - write(","); - } - if (multiLine && !noTrailingNewLine) { - writeLine(); - } - return count; - } - function emitCommaList(nodes) { - if (nodes) { - emitList(nodes, 0, nodes.length, false, false); - } - } - function emitLines(nodes) { - emitLinesStartingAt(nodes, 0); - } - function emitLinesStartingAt(nodes, startIndex) { - for (var i = startIndex; i < nodes.length; i++) { - writeLine(); - emit(nodes[i]); - } - } - function isBinaryOrOctalIntegerLiteral(node, text) { - if (node.kind === 8 && text.length > 1) { - switch (text.charCodeAt(1)) { - case 98: - case 66: - case 111: - case 79: - return true; - } - } - return false; - } - function emitLiteral(node) { - var text = getLiteralText(node); - if ((compilerOptions.sourceMap || compilerOptions.inlineSourceMap) && (node.kind === 9 || ts.isTemplateLiteralKind(node.kind))) { - writer.writeLiteral(text); - } - else if (languageVersion < 2 && isBinaryOrOctalIntegerLiteral(node, text)) { - write(node.text); - } - else { - write(text); - } - } - function getLiteralText(node) { - if (languageVersion < 2 && (ts.isTemplateLiteralKind(node.kind) || node.hasExtendedUnicodeEscape)) { - return getQuotedEscapedLiteralText("\"", node.text, "\""); - } - if (node.parent) { - return ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, node); - } - switch (node.kind) { - case 9: - return getQuotedEscapedLiteralText("\"", node.text, "\""); - case 11: - return getQuotedEscapedLiteralText("`", node.text, "`"); - case 12: - return getQuotedEscapedLiteralText("`", node.text, "${"); - case 13: - return getQuotedEscapedLiteralText("}", node.text, "${"); - case 14: - return getQuotedEscapedLiteralText("}", node.text, "`"); - case 8: - return node.text; - } - ts.Debug.fail("Literal kind '" + node.kind + "' not accounted for."); - } - function getQuotedEscapedLiteralText(leftQuote, text, rightQuote) { - return leftQuote + ts.escapeNonAsciiCharacters(ts.escapeString(text)) + rightQuote; - } - function emitDownlevelRawTemplateLiteral(node) { - var text = ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, node); - var isLast = node.kind === 11 || node.kind === 14; - text = text.substring(1, text.length - (isLast ? 1 : 2)); - text = text.replace(/\r\n?/g, "\n"); - text = ts.escapeString(text); - write("\"" + text + "\""); - } - function emitDownlevelTaggedTemplateArray(node, literalEmitter) { - write("["); - if (node.template.kind === 11) { - literalEmitter(node.template); - } - else { - literalEmitter(node.template.head); - ts.forEach(node.template.templateSpans, function (child) { - write(", "); - literalEmitter(child.literal); - }); - } - write("]"); - } - function emitDownlevelTaggedTemplate(node) { - var tempVariable = createAndRecordTempVariable(0); - write("("); - emit(tempVariable); - write(" = "); - emitDownlevelTaggedTemplateArray(node, emit); - write(", "); - emit(tempVariable); - write(".raw = "); - emitDownlevelTaggedTemplateArray(node, emitDownlevelRawTemplateLiteral); - write(", "); - emitParenthesizedIf(node.tag, needsParenthesisForPropertyAccessOrInvocation(node.tag)); - write("("); - emit(tempVariable); - if (node.template.kind === 181) { - ts.forEach(node.template.templateSpans, function (templateSpan) { - write(", "); - var needsParens = templateSpan.expression.kind === 179 - && templateSpan.expression.operatorToken.kind === 24; - emitParenthesizedIf(templateSpan.expression, needsParens); - }); - } - write("))"); - } - function emitTemplateExpression(node) { - if (languageVersion >= 2) { - ts.forEachChild(node, emit); - return; - } - var emitOuterParens = ts.isExpression(node.parent) - && templateNeedsParens(node, node.parent); - if (emitOuterParens) { - write("("); - } - var headEmitted = false; - if (shouldEmitTemplateHead()) { - emitLiteral(node.head); - headEmitted = true; - } - for (var i = 0, n = node.templateSpans.length; i < n; i++) { - var templateSpan = node.templateSpans[i]; - var needsParens = templateSpan.expression.kind !== 170 - && comparePrecedenceToBinaryPlus(templateSpan.expression) !== 1; - if (i > 0 || headEmitted) { - write(" + "); - } - emitParenthesizedIf(templateSpan.expression, needsParens); - if (templateSpan.literal.text.length !== 0) { - write(" + "); - emitLiteral(templateSpan.literal); - } - } - if (emitOuterParens) { - write(")"); - } - function shouldEmitTemplateHead() { - ts.Debug.assert(node.templateSpans.length !== 0); - return node.head.text.length !== 0 || node.templateSpans[0].literal.text.length === 0; - } - function templateNeedsParens(template, parent) { - switch (parent.kind) { - case 166: - case 167: - return parent.expression === template; - case 168: - case 170: - return false; - default: - return comparePrecedenceToBinaryPlus(parent) !== -1; - } - } - function comparePrecedenceToBinaryPlus(expression) { - switch (expression.kind) { - case 179: - switch (expression.operatorToken.kind) { - case 37: - case 38: - case 39: - return 1; - case 35: - case 36: - return 0; - default: - return -1; - } - case 182: - case 180: - return -1; - default: - return 1; - } - } - } - function emitTemplateSpan(span) { - emit(span.expression); - emit(span.literal); - } - function jsxEmitReact(node) { - function emitTagName(name) { - if (name.kind === 67 && ts.isIntrinsicJsxName(name.text)) { - write("\""); - emit(name); - write("\""); - } - else { - emit(name); - } - } - function emitAttributeName(name) { - if (/[A-Za-z_]+[\w*]/.test(name.text)) { - write("\""); - emit(name); - write("\""); - } - else { - emit(name); - } - } - function emitJsxAttribute(node) { - emitAttributeName(node.name); - write(": "); - if (node.initializer) { - emit(node.initializer); - } - else { - write("true"); - } - } - function emitJsxElement(openingNode, children) { - var syntheticReactRef = ts.createSynthesizedNode(67); - syntheticReactRef.text = 'React'; - syntheticReactRef.parent = openingNode; - emitLeadingComments(openingNode); - emitExpressionIdentifier(syntheticReactRef); - write(".createElement("); - emitTagName(openingNode.tagName); - write(", "); - if (openingNode.attributes.length === 0) { - write("null"); - } - else { - var attrs = openingNode.attributes; - if (ts.forEach(attrs, function (attr) { return attr.kind === 237; })) { - emitExpressionIdentifier(syntheticReactRef); - write(".__spread("); - var haveOpenedObjectLiteral = false; - for (var i_1 = 0; i_1 < attrs.length; i_1++) { - if (attrs[i_1].kind === 237) { - if (i_1 === 0) { - write("{}, "); - } - if (haveOpenedObjectLiteral) { - write("}"); - haveOpenedObjectLiteral = false; - } - if (i_1 > 0) { - write(", "); - } - emit(attrs[i_1].expression); - } - else { - ts.Debug.assert(attrs[i_1].kind === 236); - if (haveOpenedObjectLiteral) { - write(", "); - } - else { - haveOpenedObjectLiteral = true; - if (i_1 > 0) { - write(", "); - } - write("{"); - } - emitJsxAttribute(attrs[i_1]); - } - } - if (haveOpenedObjectLiteral) - write("}"); - write(")"); - } - else { - write("{"); - for (var i = 0; i < attrs.length; i++) { - if (i > 0) { - write(", "); - } - emitJsxAttribute(attrs[i]); - } - write("}"); - } - } - if (children) { - for (var i = 0; i < children.length; i++) { - if (children[i].kind === 238 && !(children[i].expression)) { - continue; - } - if (children[i].kind === 234) { - var text = getTextToEmit(children[i]); - if (text !== undefined) { - write(", \""); - write(text); - write("\""); - } - } - else { - write(", "); - emit(children[i]); - } - } - } - write(")"); - emitTrailingComments(openingNode); - } - if (node.kind === 231) { - emitJsxElement(node.openingElement, node.children); - } - else { - ts.Debug.assert(node.kind === 232); - emitJsxElement(node); - } - } - function jsxEmitPreserve(node) { - function emitJsxAttribute(node) { - emit(node.name); - if (node.initializer) { - write("="); - emit(node.initializer); - } - } - function emitJsxSpreadAttribute(node) { - write("{..."); - emit(node.expression); - write("}"); - } - function emitAttributes(attribs) { - for (var i = 0, n = attribs.length; i < n; i++) { - if (i > 0) { - write(" "); - } - if (attribs[i].kind === 237) { - emitJsxSpreadAttribute(attribs[i]); - } - else { - ts.Debug.assert(attribs[i].kind === 236); - emitJsxAttribute(attribs[i]); - } - } - } - function emitJsxOpeningOrSelfClosingElement(node) { - write("<"); - emit(node.tagName); - if (node.attributes.length > 0 || (node.kind === 232)) { - write(" "); - } - emitAttributes(node.attributes); - if (node.kind === 232) { - write("/>"); - } - else { - write(">"); - } - } - function emitJsxClosingElement(node) { - write(""); - } - function emitJsxElement(node) { - emitJsxOpeningOrSelfClosingElement(node.openingElement); - for (var i = 0, n = node.children.length; i < n; i++) { - emit(node.children[i]); - } - emitJsxClosingElement(node.closingElement); - } - if (node.kind === 231) { - emitJsxElement(node); - } - else { - ts.Debug.assert(node.kind === 232); - emitJsxOpeningOrSelfClosingElement(node); - } - } - function emitExpressionForPropertyName(node) { - ts.Debug.assert(node.kind !== 161); - if (node.kind === 9) { - emitLiteral(node); - } - else if (node.kind === 134) { - if (ts.nodeIsDecorated(node.parent)) { - if (!computedPropertyNamesToGeneratedNames) { - computedPropertyNamesToGeneratedNames = []; - } - var generatedName = computedPropertyNamesToGeneratedNames[ts.getNodeId(node)]; - if (generatedName) { - write(generatedName); - return; - } - generatedName = createAndRecordTempVariable(0).text; - computedPropertyNamesToGeneratedNames[ts.getNodeId(node)] = generatedName; - write(generatedName); - write(" = "); - } - emit(node.expression); - } - else { - write("\""); - if (node.kind === 8) { - write(node.text); - } - else { - writeTextOfNode(currentSourceFile, node); - } - write("\""); - } - } - function isExpressionIdentifier(node) { - var parent = node.parent; - switch (parent.kind) { - case 162: - case 179: - case 166: - case 239: - case 134: - case 180: - case 137: - case 173: - case 195: - case 165: - case 225: - case 193: - case 186: - case 197: - case 198: - case 199: - case 194: - case 232: - case 233: - case 237: - case 238: - case 167: - case 170: - case 178: - case 177: - case 202: - case 244: - case 183: - case 204: - case 168: - case 188: - case 206: - case 169: - case 174: - case 175: - case 196: - case 203: - case 182: - return true; - case 161: - case 245: - case 136: - case 243: - case 139: - case 209: - return parent.initializer === node; - case 164: - return parent.expression === node; - case 172: - case 171: - return parent.body === node; - case 219: - return parent.moduleReference === node; - case 133: - return parent.left === node; - } - return false; - } - function emitExpressionIdentifier(node) { - if (resolver.getNodeCheckFlags(node) & 2048) { - write("_arguments"); - return; - } - var container = resolver.getReferencedExportContainer(node); - if (container) { - if (container.kind === 246) { - if (languageVersion < 2 && compilerOptions.module !== 4) { - write("exports."); - } - } - else { - write(getGeneratedNameForNode(container)); - write("."); - } - } - else if (languageVersion < 2) { - var declaration = resolver.getReferencedImportDeclaration(node); - if (declaration) { - if (declaration.kind === 221) { - write(getGeneratedNameForNode(declaration.parent)); - write(languageVersion === 0 ? "[\"default\"]" : ".default"); - return; - } - else if (declaration.kind === 224) { - write(getGeneratedNameForNode(declaration.parent.parent.parent)); - var name = declaration.propertyName || declaration.name; - var identifier = ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, name); - if (languageVersion === 0 && identifier === "default") { - write("[\"default\"]"); - } - else { - write("."); - write(identifier); - } - return; - } - } - declaration = resolver.getReferencedNestedRedeclaration(node); - if (declaration) { - write(getGeneratedNameForNode(declaration.name)); - return; - } - } - if (ts.nodeIsSynthesized(node)) { - write(node.text); - } - else { - writeTextOfNode(currentSourceFile, node); - } - } - function isNameOfNestedRedeclaration(node) { - if (languageVersion < 2) { - var parent_6 = node.parent; - switch (parent_6.kind) { - case 161: - case 212: - case 215: - case 209: - return parent_6.name === node && resolver.isNestedRedeclaration(parent_6); - } - } - return false; - } - function emitIdentifier(node) { - if (!node.parent) { - write(node.text); - } - else if (isExpressionIdentifier(node)) { - emitExpressionIdentifier(node); - } - else if (isNameOfNestedRedeclaration(node)) { - write(getGeneratedNameForNode(node)); - } - else if (ts.nodeIsSynthesized(node)) { - write(node.text); - } - else { - writeTextOfNode(currentSourceFile, node); - } - } - function emitThis(node) { - if (resolver.getNodeCheckFlags(node) & 2) { - write("_this"); - } - else { - write("this"); - } - } - function emitSuper(node) { - if (languageVersion >= 2) { - write("super"); - } - else { - var flags = resolver.getNodeCheckFlags(node); - if (flags & 256) { - write("_super.prototype"); - } - else { - write("_super"); - } - } - } - function emitObjectBindingPattern(node) { - write("{ "); - var elements = node.elements; - emitList(elements, 0, elements.length, false, elements.hasTrailingComma); - write(" }"); - } - function emitArrayBindingPattern(node) { - write("["); - var elements = node.elements; - emitList(elements, 0, elements.length, false, elements.hasTrailingComma); - write("]"); - } - function emitBindingElement(node) { - if (node.propertyName) { - emit(node.propertyName); - write(": "); - } - if (node.dotDotDotToken) { - write("..."); - } - if (ts.isBindingPattern(node.name)) { - emit(node.name); - } - else { - emitModuleMemberName(node); - } - emitOptional(" = ", node.initializer); - } - function emitSpreadElementExpression(node) { - write("..."); - emit(node.expression); - } - function emitYieldExpression(node) { - write(ts.tokenToString(112)); - if (node.asteriskToken) { - write("*"); - } - if (node.expression) { - write(" "); - emit(node.expression); - } - } - function emitAwaitExpression(node) { - var needsParenthesis = needsParenthesisForAwaitExpressionAsYield(node); - if (needsParenthesis) { - write("("); - } - write(ts.tokenToString(112)); - write(" "); - emit(node.expression); - if (needsParenthesis) { - write(")"); - } - } - function needsParenthesisForAwaitExpressionAsYield(node) { - if (node.parent.kind === 179 && !ts.isAssignmentOperator(node.parent.operatorToken.kind)) { - return true; - } - else if (node.parent.kind === 180 && node.parent.condition === node) { - return true; - } - return false; - } - function needsParenthesisForPropertyAccessOrInvocation(node) { - switch (node.kind) { - case 67: - case 162: - case 164: - case 165: - case 166: - case 170: - return false; - } - return true; - } - function emitListWithSpread(elements, needsUniqueCopy, multiLine, trailingComma, useConcat) { - var pos = 0; - var group = 0; - var length = elements.length; - while (pos < length) { - if (group === 1 && useConcat) { - write(".concat("); - } - else if (group > 0) { - write(", "); - } - var e = elements[pos]; - if (e.kind === 183) { - e = e.expression; - emitParenthesizedIf(e, group === 0 && needsParenthesisForPropertyAccessOrInvocation(e)); - pos++; - if (pos === length && group === 0 && needsUniqueCopy && e.kind !== 162) { - write(".slice()"); - } - } - else { - var i = pos; - while (i < length && elements[i].kind !== 183) { - i++; - } - write("["); - if (multiLine) { - increaseIndent(); - } - emitList(elements, pos, i - pos, multiLine, trailingComma && i === length); - if (multiLine) { - decreaseIndent(); - } - write("]"); - pos = i; - } - group++; - } - if (group > 1) { - if (useConcat) { - write(")"); - } - } - } - function isSpreadElementExpression(node) { - return node.kind === 183; - } - function emitArrayLiteral(node) { - var elements = node.elements; - if (elements.length === 0) { - write("[]"); - } - else if (languageVersion >= 2 || !ts.forEach(elements, isSpreadElementExpression)) { - write("["); - emitLinePreservingList(node, node.elements, elements.hasTrailingComma, false); - write("]"); - } - else { - emitListWithSpread(elements, true, (node.flags & 2048) !== 0, elements.hasTrailingComma, true); - } - } - function emitObjectLiteralBody(node, numElements) { - if (numElements === 0) { - write("{}"); - return; - } - write("{"); - if (numElements > 0) { - var properties = node.properties; - if (numElements === properties.length) { - emitLinePreservingList(node, properties, languageVersion >= 1, true); - } - else { - var multiLine = (node.flags & 2048) !== 0; - if (!multiLine) { - write(" "); - } - else { - increaseIndent(); - } - emitList(properties, 0, numElements, multiLine, false); - if (!multiLine) { - write(" "); - } - else { - decreaseIndent(); - } - } - } - write("}"); - } - function emitDownlevelObjectLiteralWithComputedProperties(node, firstComputedPropertyIndex) { - var multiLine = (node.flags & 2048) !== 0; - var properties = node.properties; - write("("); - if (multiLine) { - increaseIndent(); - } - var tempVar = createAndRecordTempVariable(0); - emit(tempVar); - write(" = "); - emitObjectLiteralBody(node, firstComputedPropertyIndex); - for (var i = firstComputedPropertyIndex, n = properties.length; i < n; i++) { - writeComma(); - var property = properties[i]; - emitStart(property); - if (property.kind === 143 || property.kind === 144) { - var accessors = ts.getAllAccessorDeclarations(node.properties, property); - if (property !== accessors.firstAccessor) { - continue; - } - write("Object.defineProperty("); - emit(tempVar); - write(", "); - emitStart(node.name); - emitExpressionForPropertyName(property.name); - emitEnd(property.name); - write(", {"); - increaseIndent(); - if (accessors.getAccessor) { - writeLine(); - emitLeadingComments(accessors.getAccessor); - write("get: "); - emitStart(accessors.getAccessor); - write("function "); - emitSignatureAndBody(accessors.getAccessor); - emitEnd(accessors.getAccessor); - emitTrailingComments(accessors.getAccessor); - write(","); - } - if (accessors.setAccessor) { - writeLine(); - emitLeadingComments(accessors.setAccessor); - write("set: "); - emitStart(accessors.setAccessor); - write("function "); - emitSignatureAndBody(accessors.setAccessor); - emitEnd(accessors.setAccessor); - emitTrailingComments(accessors.setAccessor); - write(","); - } - writeLine(); - write("enumerable: true,"); - writeLine(); - write("configurable: true"); - decreaseIndent(); - writeLine(); - write("})"); - emitEnd(property); - } - else { - emitLeadingComments(property); - emitStart(property.name); - emit(tempVar); - emitMemberAccessForPropertyName(property.name); - emitEnd(property.name); - write(" = "); - if (property.kind === 243) { - emit(property.initializer); - } - else if (property.kind === 244) { - emitExpressionIdentifier(property.name); - } - else if (property.kind === 141) { - emitFunctionDeclaration(property); - } - else { - ts.Debug.fail("ObjectLiteralElement type not accounted for: " + property.kind); - } - } - emitEnd(property); - } - writeComma(); - emit(tempVar); - if (multiLine) { - decreaseIndent(); - writeLine(); - } - write(")"); - function writeComma() { - if (multiLine) { - write(","); - writeLine(); - } - else { - write(", "); - } - } - } - function emitObjectLiteral(node) { - var properties = node.properties; - if (languageVersion < 2) { - var numProperties = properties.length; - var numInitialNonComputedProperties = numProperties; - for (var i = 0, n = properties.length; i < n; i++) { - if (properties[i].name.kind === 134) { - numInitialNonComputedProperties = i; - break; - } - } - var hasComputedProperty = numInitialNonComputedProperties !== properties.length; - if (hasComputedProperty) { - emitDownlevelObjectLiteralWithComputedProperties(node, numInitialNonComputedProperties); - return; - } - } - emitObjectLiteralBody(node, properties.length); - } - function createBinaryExpression(left, operator, right, startsOnNewLine) { - var result = ts.createSynthesizedNode(179, startsOnNewLine); - result.operatorToken = ts.createSynthesizedNode(operator); - result.left = left; - result.right = right; - return result; - } - function createPropertyAccessExpression(expression, name) { - var result = ts.createSynthesizedNode(164); - result.expression = parenthesizeForAccess(expression); - result.dotToken = ts.createSynthesizedNode(21); - result.name = name; - return result; - } - function createElementAccessExpression(expression, argumentExpression) { - var result = ts.createSynthesizedNode(165); - result.expression = parenthesizeForAccess(expression); - result.argumentExpression = argumentExpression; - return result; - } - function parenthesizeForAccess(expr) { - while (expr.kind === 169 || expr.kind === 187) { - expr = expr.expression; - } - if (ts.isLeftHandSideExpression(expr) && - expr.kind !== 167 && - expr.kind !== 8) { - return expr; - } - var node = ts.createSynthesizedNode(170); - node.expression = expr; - return node; - } - function emitComputedPropertyName(node) { - write("["); - emitExpressionForPropertyName(node); - write("]"); - } - function emitMethod(node) { - if (languageVersion >= 2 && node.asteriskToken) { - write("*"); - } - emit(node.name); - if (languageVersion < 2) { - write(": function "); - } - emitSignatureAndBody(node); - } - function emitPropertyAssignment(node) { - emit(node.name); - write(": "); - emitTrailingCommentsOfPosition(node.initializer.pos); - emit(node.initializer); - } - function isNamespaceExportReference(node) { - var container = resolver.getReferencedExportContainer(node); - return container && container.kind !== 246; - } - function emitShorthandPropertyAssignment(node) { - writeTextOfNode(currentSourceFile, node.name); - if (languageVersion < 2 || isNamespaceExportReference(node.name)) { - write(": "); - emit(node.name); - } - } - function tryEmitConstantValue(node) { - var constantValue = tryGetConstEnumValue(node); - if (constantValue !== undefined) { - write(constantValue.toString()); - if (!compilerOptions.removeComments) { - var propertyName = node.kind === 164 ? ts.declarationNameToString(node.name) : ts.getTextOfNode(node.argumentExpression); - write(" /* " + propertyName + " */"); - } - return true; - } - return false; - } - function tryGetConstEnumValue(node) { - if (compilerOptions.isolatedModules) { - return undefined; - } - return node.kind === 164 || node.kind === 165 - ? resolver.getConstantValue(node) - : undefined; - } - function indentIfOnDifferentLines(parent, node1, node2, valueToWriteWhenNotIndenting) { - var realNodesAreOnDifferentLines = !ts.nodeIsSynthesized(parent) && !nodeEndIsOnSameLineAsNodeStart(node1, node2); - var synthesizedNodeIsOnDifferentLine = synthesizedNodeStartsOnNewLine(node2); - if (realNodesAreOnDifferentLines || synthesizedNodeIsOnDifferentLine) { - increaseIndent(); - writeLine(); - return true; - } - else { - if (valueToWriteWhenNotIndenting) { - write(valueToWriteWhenNotIndenting); - } - return false; - } - } - function emitPropertyAccess(node) { - if (tryEmitConstantValue(node)) { - return; - } - emit(node.expression); - var indentedBeforeDot = indentIfOnDifferentLines(node, node.expression, node.dotToken); - var shouldEmitSpace; - if (!indentedBeforeDot) { - if (node.expression.kind === 8) { - var text = ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, node.expression); - shouldEmitSpace = text.indexOf(ts.tokenToString(21)) < 0; - } - else { - var constantValue = tryGetConstEnumValue(node.expression); - shouldEmitSpace = isFinite(constantValue) && Math.floor(constantValue) === constantValue; - } - } - if (shouldEmitSpace) { - write(" ."); - } - else { - write("."); - } - var indentedAfterDot = indentIfOnDifferentLines(node, node.dotToken, node.name); - emit(node.name); - decreaseIndentIf(indentedBeforeDot, indentedAfterDot); - } - function emitQualifiedName(node) { - emit(node.left); - write("."); - emit(node.right); - } - function emitQualifiedNameAsExpression(node, useFallback) { - if (node.left.kind === 67) { - emitEntityNameAsExpression(node.left, useFallback); - } - else if (useFallback) { - var temp = createAndRecordTempVariable(0); - write("("); - emitNodeWithoutSourceMap(temp); - write(" = "); - emitEntityNameAsExpression(node.left, true); - write(") && "); - emitNodeWithoutSourceMap(temp); - } - else { - emitEntityNameAsExpression(node.left, false); - } - write("."); - emit(node.right); - } - function emitEntityNameAsExpression(node, useFallback) { - switch (node.kind) { - case 67: - if (useFallback) { - write("typeof "); - emitExpressionIdentifier(node); - write(" !== 'undefined' && "); - } - emitExpressionIdentifier(node); - break; - case 133: - emitQualifiedNameAsExpression(node, useFallback); - break; - } - } - function emitIndexedAccess(node) { - if (tryEmitConstantValue(node)) { - return; - } - emit(node.expression); - write("["); - emit(node.argumentExpression); - write("]"); - } - function hasSpreadElement(elements) { - return ts.forEach(elements, function (e) { return e.kind === 183; }); - } - function skipParentheses(node) { - while (node.kind === 170 || node.kind === 169 || node.kind === 187) { - node = node.expression; - } - return node; - } - function emitCallTarget(node) { - if (node.kind === 67 || node.kind === 95 || node.kind === 93) { - emit(node); - return node; - } - var temp = createAndRecordTempVariable(0); - write("("); - emit(temp); - write(" = "); - emit(node); - write(")"); - return temp; - } - function emitCallWithSpread(node) { - var target; - var expr = skipParentheses(node.expression); - if (expr.kind === 164) { - target = emitCallTarget(expr.expression); - write("."); - emit(expr.name); - } - else if (expr.kind === 165) { - target = emitCallTarget(expr.expression); - write("["); - emit(expr.argumentExpression); - write("]"); - } - else if (expr.kind === 93) { - target = expr; - write("_super"); - } - else { - emit(node.expression); - } - write(".apply("); - if (target) { - if (target.kind === 93) { - emitThis(target); - } - else { - emit(target); - } - } - else { - write("void 0"); - } - write(", "); - emitListWithSpread(node.arguments, false, false, false, true); - write(")"); - } - function emitCallExpression(node) { - if (languageVersion < 2 && hasSpreadElement(node.arguments)) { - emitCallWithSpread(node); - return; - } - var superCall = false; - if (node.expression.kind === 93) { - emitSuper(node.expression); - superCall = true; - } - else { - emit(node.expression); - superCall = node.expression.kind === 164 && node.expression.expression.kind === 93; - } - if (superCall && languageVersion < 2) { - write(".call("); - emitThis(node.expression); - if (node.arguments.length) { - write(", "); - emitCommaList(node.arguments); - } - write(")"); - } - else { - write("("); - emitCommaList(node.arguments); - write(")"); - } - } - function emitNewExpression(node) { - write("new "); - if (languageVersion === 1 && - node.arguments && - hasSpreadElement(node.arguments)) { - write("("); - var target = emitCallTarget(node.expression); - write(".bind.apply("); - emit(target); - write(", [void 0].concat("); - emitListWithSpread(node.arguments, false, false, false, false); - write(")))"); - write("()"); - } - else { - emit(node.expression); - if (node.arguments) { - write("("); - emitCommaList(node.arguments); - write(")"); - } - } - } - function emitTaggedTemplateExpression(node) { - if (languageVersion >= 2) { - emit(node.tag); - write(" "); - emit(node.template); - } - else { - emitDownlevelTaggedTemplate(node); - } - } - function emitParenExpression(node) { - if (!ts.nodeIsSynthesized(node) && node.parent.kind !== 172) { - if (node.expression.kind === 169 || node.expression.kind === 187) { - var operand = node.expression.expression; - while (operand.kind === 169 || operand.kind === 187) { - operand = operand.expression; - } - if (operand.kind !== 177 && - operand.kind !== 175 && - operand.kind !== 174 && - operand.kind !== 173 && - operand.kind !== 178 && - operand.kind !== 167 && - !(operand.kind === 166 && node.parent.kind === 167) && - !(operand.kind === 171 && node.parent.kind === 166) && - !(operand.kind === 8 && node.parent.kind === 164)) { - emit(operand); - return; - } - } - } - write("("); - emit(node.expression); - write(")"); - } - function emitDeleteExpression(node) { - write(ts.tokenToString(76)); - write(" "); - emit(node.expression); - } - function emitVoidExpression(node) { - write(ts.tokenToString(101)); - write(" "); - emit(node.expression); - } - function emitTypeOfExpression(node) { - write(ts.tokenToString(99)); - write(" "); - emit(node.expression); - } - function isNameOfExportedSourceLevelDeclarationInSystemExternalModule(node) { - if (!isCurrentFileSystemExternalModule() || node.kind !== 67 || ts.nodeIsSynthesized(node)) { - return false; - } - var isVariableDeclarationOrBindingElement = node.parent && (node.parent.kind === 209 || node.parent.kind === 161); - var targetDeclaration = isVariableDeclarationOrBindingElement - ? node.parent - : resolver.getReferencedValueDeclaration(node); - return isSourceFileLevelDeclarationInSystemJsModule(targetDeclaration, true); - } - function emitPrefixUnaryExpression(node) { - var exportChanged = isNameOfExportedSourceLevelDeclarationInSystemExternalModule(node.operand); - if (exportChanged) { - write(exportFunctionForFile + "(\""); - emitNodeWithoutSourceMap(node.operand); - write("\", "); - } - write(ts.tokenToString(node.operator)); - if (node.operand.kind === 177) { - var operand = node.operand; - if (node.operator === 35 && (operand.operator === 35 || operand.operator === 40)) { - write(" "); - } - else if (node.operator === 36 && (operand.operator === 36 || operand.operator === 41)) { - write(" "); - } - } - emit(node.operand); - if (exportChanged) { - write(")"); - } - } - function emitPostfixUnaryExpression(node) { - var exportChanged = isNameOfExportedSourceLevelDeclarationInSystemExternalModule(node.operand); - if (exportChanged) { - write("(" + exportFunctionForFile + "(\""); - emitNodeWithoutSourceMap(node.operand); - write("\", "); - write(ts.tokenToString(node.operator)); - emit(node.operand); - if (node.operator === 40) { - write(") - 1)"); - } - else { - write(") + 1)"); - } - } - else { - emit(node.operand); - write(ts.tokenToString(node.operator)); - } - } - function shouldHoistDeclarationInSystemJsModule(node) { - return isSourceFileLevelDeclarationInSystemJsModule(node, false); - } - function isSourceFileLevelDeclarationInSystemJsModule(node, isExported) { - if (!node || languageVersion >= 2 || !isCurrentFileSystemExternalModule()) { - return false; - } - var current = node; - while (current) { - if (current.kind === 246) { - return !isExported || ((ts.getCombinedNodeFlags(node) & 1) !== 0); - } - else if (ts.isFunctionLike(current) || current.kind === 217) { - return false; - } - else { - current = current.parent; - } - } - } - function emitBinaryExpression(node) { - if (languageVersion < 2 && node.operatorToken.kind === 55 && - (node.left.kind === 163 || node.left.kind === 162)) { - emitDestructuring(node, node.parent.kind === 193); - } - else { - var exportChanged = node.operatorToken.kind >= 55 && - node.operatorToken.kind <= 66 && - isNameOfExportedSourceLevelDeclarationInSystemExternalModule(node.left); - if (exportChanged) { - write(exportFunctionForFile + "(\""); - emitNodeWithoutSourceMap(node.left); - write("\", "); - } - emit(node.left); - var indentedBeforeOperator = indentIfOnDifferentLines(node, node.left, node.operatorToken, node.operatorToken.kind !== 24 ? " " : undefined); - write(ts.tokenToString(node.operatorToken.kind)); - var indentedAfterOperator = indentIfOnDifferentLines(node, node.operatorToken, node.right, " "); - emit(node.right); - decreaseIndentIf(indentedBeforeOperator, indentedAfterOperator); - if (exportChanged) { - write(")"); - } - } - } - function synthesizedNodeStartsOnNewLine(node) { - return ts.nodeIsSynthesized(node) && node.startsOnNewLine; - } - function emitConditionalExpression(node) { - emit(node.condition); - var indentedBeforeQuestion = indentIfOnDifferentLines(node, node.condition, node.questionToken, " "); - write("?"); - var indentedAfterQuestion = indentIfOnDifferentLines(node, node.questionToken, node.whenTrue, " "); - emit(node.whenTrue); - decreaseIndentIf(indentedBeforeQuestion, indentedAfterQuestion); - var indentedBeforeColon = indentIfOnDifferentLines(node, node.whenTrue, node.colonToken, " "); - write(":"); - var indentedAfterColon = indentIfOnDifferentLines(node, node.colonToken, node.whenFalse, " "); - emit(node.whenFalse); - decreaseIndentIf(indentedBeforeColon, indentedAfterColon); - } - function decreaseIndentIf(value1, value2) { - if (value1) { - decreaseIndent(); - } - if (value2) { - decreaseIndent(); - } - } - function isSingleLineEmptyBlock(node) { - if (node && node.kind === 190) { - var block = node; - return block.statements.length === 0 && nodeEndIsOnSameLineAsNodeStart(block, block); - } - } - function emitBlock(node) { - if (isSingleLineEmptyBlock(node)) { - emitToken(15, node.pos); - write(" "); - emitToken(16, node.statements.end); - return; - } - emitToken(15, node.pos); - increaseIndent(); - scopeEmitStart(node.parent); - if (node.kind === 217) { - ts.Debug.assert(node.parent.kind === 216); - emitCaptureThisForNodeIfNecessary(node.parent); - } - emitLines(node.statements); - if (node.kind === 217) { - emitTempDeclarations(true); - } - decreaseIndent(); - writeLine(); - emitToken(16, node.statements.end); - scopeEmitEnd(); - } - function emitEmbeddedStatement(node) { - if (node.kind === 190) { - write(" "); - emit(node); - } - else { - increaseIndent(); - writeLine(); - emit(node); - decreaseIndent(); - } - } - function emitExpressionStatement(node) { - emitParenthesizedIf(node.expression, node.expression.kind === 172); - write(";"); - } - function emitIfStatement(node) { - var endPos = emitToken(86, node.pos); - write(" "); - endPos = emitToken(17, endPos); - emit(node.expression); - emitToken(18, node.expression.end); - emitEmbeddedStatement(node.thenStatement); - if (node.elseStatement) { - writeLine(); - emitToken(78, node.thenStatement.end); - if (node.elseStatement.kind === 194) { - write(" "); - emit(node.elseStatement); - } - else { - emitEmbeddedStatement(node.elseStatement); - } - } - } - function emitDoStatement(node) { - write("do"); - emitEmbeddedStatement(node.statement); - if (node.statement.kind === 190) { - write(" "); - } - else { - writeLine(); - } - write("while ("); - emit(node.expression); - write(");"); - } - function emitWhileStatement(node) { - write("while ("); - emit(node.expression); - write(")"); - emitEmbeddedStatement(node.statement); - } - function tryEmitStartOfVariableDeclarationList(decl, startPos) { - if (shouldHoistVariable(decl, true)) { - return false; - } - var tokenKind = 100; - if (decl && languageVersion >= 2) { - if (ts.isLet(decl)) { - tokenKind = 106; - } - else if (ts.isConst(decl)) { - tokenKind = 72; - } - } - if (startPos !== undefined) { - emitToken(tokenKind, startPos); - write(" "); - } - else { - switch (tokenKind) { - case 100: - write("var "); - break; - case 106: - write("let "); - break; - case 72: - write("const "); - break; - } - } - return true; - } - function emitVariableDeclarationListSkippingUninitializedEntries(list) { - var started = false; - for (var _a = 0, _b = list.declarations; _a < _b.length; _a++) { - var decl = _b[_a]; - if (!decl.initializer) { - continue; - } - if (!started) { - started = true; - } - else { - write(", "); - } - emit(decl); - } - return started; - } - function emitForStatement(node) { - var endPos = emitToken(84, node.pos); - write(" "); - endPos = emitToken(17, endPos); - if (node.initializer && node.initializer.kind === 210) { - var variableDeclarationList = node.initializer; - var startIsEmitted = tryEmitStartOfVariableDeclarationList(variableDeclarationList, endPos); - if (startIsEmitted) { - emitCommaList(variableDeclarationList.declarations); - } - else { - emitVariableDeclarationListSkippingUninitializedEntries(variableDeclarationList); - } - } - else if (node.initializer) { - emit(node.initializer); - } - write(";"); - emitOptional(" ", node.condition); - write(";"); - emitOptional(" ", node.incrementor); - write(")"); - emitEmbeddedStatement(node.statement); - } - function emitForInOrForOfStatement(node) { - if (languageVersion < 2 && node.kind === 199) { - return emitDownLevelForOfStatement(node); - } - var endPos = emitToken(84, node.pos); - write(" "); - endPos = emitToken(17, endPos); - if (node.initializer.kind === 210) { - var variableDeclarationList = node.initializer; - if (variableDeclarationList.declarations.length >= 1) { - tryEmitStartOfVariableDeclarationList(variableDeclarationList, endPos); - emit(variableDeclarationList.declarations[0]); - } - } - else { - emit(node.initializer); - } - if (node.kind === 198) { - write(" in "); - } - else { - write(" of "); - } - emit(node.expression); - emitToken(18, node.expression.end); - emitEmbeddedStatement(node.statement); - } - function emitDownLevelForOfStatement(node) { - var endPos = emitToken(84, node.pos); - write(" "); - endPos = emitToken(17, endPos); - var rhsIsIdentifier = node.expression.kind === 67; - var counter = createTempVariable(268435456); - var rhsReference = rhsIsIdentifier ? node.expression : createTempVariable(0); - emitStart(node.expression); - write("var "); - emitNodeWithoutSourceMap(counter); - write(" = 0"); - emitEnd(node.expression); - if (!rhsIsIdentifier) { - write(", "); - emitStart(node.expression); - emitNodeWithoutSourceMap(rhsReference); - write(" = "); - emitNodeWithoutSourceMap(node.expression); - emitEnd(node.expression); - } - write("; "); - emitStart(node.initializer); - emitNodeWithoutSourceMap(counter); - write(" < "); - emitNodeWithCommentsAndWithoutSourcemap(rhsReference); - write(".length"); - emitEnd(node.initializer); - write("; "); - emitStart(node.initializer); - emitNodeWithoutSourceMap(counter); - write("++"); - emitEnd(node.initializer); - emitToken(18, node.expression.end); - write(" {"); - writeLine(); - increaseIndent(); - var rhsIterationValue = createElementAccessExpression(rhsReference, counter); - emitStart(node.initializer); - if (node.initializer.kind === 210) { - write("var "); - var variableDeclarationList = node.initializer; - if (variableDeclarationList.declarations.length > 0) { - var declaration = variableDeclarationList.declarations[0]; - if (ts.isBindingPattern(declaration.name)) { - emitDestructuring(declaration, false, rhsIterationValue); - } - else { - emitNodeWithCommentsAndWithoutSourcemap(declaration); - write(" = "); - emitNodeWithoutSourceMap(rhsIterationValue); - } - } - else { - emitNodeWithoutSourceMap(createTempVariable(0)); - write(" = "); - emitNodeWithoutSourceMap(rhsIterationValue); - } - } - else { - var assignmentExpression = createBinaryExpression(node.initializer, 55, rhsIterationValue, false); - if (node.initializer.kind === 162 || node.initializer.kind === 163) { - emitDestructuring(assignmentExpression, true, undefined); - } - else { - emitNodeWithCommentsAndWithoutSourcemap(assignmentExpression); - } - } - emitEnd(node.initializer); - write(";"); - if (node.statement.kind === 190) { - emitLines(node.statement.statements); - } - else { - writeLine(); - emit(node.statement); - } - writeLine(); - decreaseIndent(); - write("}"); - } - function emitBreakOrContinueStatement(node) { - emitToken(node.kind === 201 ? 68 : 73, node.pos); - emitOptional(" ", node.label); - write(";"); - } - function emitReturnStatement(node) { - emitToken(92, node.pos); - emitOptional(" ", node.expression); - write(";"); - } - function emitWithStatement(node) { - write("with ("); - emit(node.expression); - write(")"); - emitEmbeddedStatement(node.statement); - } - function emitSwitchStatement(node) { - var endPos = emitToken(94, node.pos); - write(" "); - emitToken(17, endPos); - emit(node.expression); - endPos = emitToken(18, node.expression.end); - write(" "); - emitCaseBlock(node.caseBlock, endPos); - } - function emitCaseBlock(node, startPos) { - emitToken(15, startPos); - increaseIndent(); - emitLines(node.clauses); - decreaseIndent(); - writeLine(); - emitToken(16, node.clauses.end); - } - function nodeStartPositionsAreOnSameLine(node1, node2) { - return ts.getLineOfLocalPosition(currentSourceFile, ts.skipTrivia(currentSourceFile.text, node1.pos)) === - ts.getLineOfLocalPosition(currentSourceFile, ts.skipTrivia(currentSourceFile.text, node2.pos)); - } - function nodeEndPositionsAreOnSameLine(node1, node2) { - return ts.getLineOfLocalPosition(currentSourceFile, node1.end) === - ts.getLineOfLocalPosition(currentSourceFile, node2.end); - } - function nodeEndIsOnSameLineAsNodeStart(node1, node2) { - return ts.getLineOfLocalPosition(currentSourceFile, node1.end) === - ts.getLineOfLocalPosition(currentSourceFile, ts.skipTrivia(currentSourceFile.text, node2.pos)); - } - function emitCaseOrDefaultClause(node) { - if (node.kind === 239) { - write("case "); - emit(node.expression); - write(":"); - } - else { - write("default:"); - } - if (node.statements.length === 1 && nodeStartPositionsAreOnSameLine(node, node.statements[0])) { - write(" "); - emit(node.statements[0]); - } - else { - increaseIndent(); - emitLines(node.statements); - decreaseIndent(); - } - } - function emitThrowStatement(node) { - write("throw "); - emit(node.expression); - write(";"); - } - function emitTryStatement(node) { - write("try "); - emit(node.tryBlock); - emit(node.catchClause); - if (node.finallyBlock) { - writeLine(); - write("finally "); - emit(node.finallyBlock); - } - } - function emitCatchClause(node) { - writeLine(); - var endPos = emitToken(70, node.pos); - write(" "); - emitToken(17, endPos); - emit(node.variableDeclaration); - emitToken(18, node.variableDeclaration ? node.variableDeclaration.end : endPos); - write(" "); - emitBlock(node.block); - } - function emitDebuggerStatement(node) { - emitToken(74, node.pos); - write(";"); - } - function emitLabelledStatement(node) { - emit(node.label); - write(": "); - emit(node.statement); - } - function getContainingModule(node) { - do { - node = node.parent; - } while (node && node.kind !== 216); - return node; - } - function emitContainingModuleName(node) { - var container = getContainingModule(node); - write(container ? getGeneratedNameForNode(container) : "exports"); - } - function emitModuleMemberName(node) { - emitStart(node.name); - if (ts.getCombinedNodeFlags(node) & 1) { - var container = getContainingModule(node); - if (container) { - write(getGeneratedNameForNode(container)); - write("."); - } - else if (languageVersion < 2 && compilerOptions.module !== 4) { - write("exports."); - } - } - emitNodeWithCommentsAndWithoutSourcemap(node.name); - emitEnd(node.name); - } - function createVoidZero() { - var zero = ts.createSynthesizedNode(8); - zero.text = "0"; - var result = ts.createSynthesizedNode(175); - result.expression = zero; - return result; - } - function emitEs6ExportDefaultCompat(node) { - if (node.parent.kind === 246) { - ts.Debug.assert(!!(node.flags & 1024) || node.kind === 225); - if (compilerOptions.module === 1 || compilerOptions.module === 2 || compilerOptions.module === 3) { - if (!currentSourceFile.symbol.exports["___esModule"]) { - if (languageVersion === 1) { - write("Object.defineProperty(exports, \"__esModule\", { value: true });"); - writeLine(); - } - else if (languageVersion === 0) { - write("exports.__esModule = true;"); - writeLine(); - } - } - } - } - } - function emitExportMemberAssignment(node) { - if (node.flags & 1) { - writeLine(); - emitStart(node); - if (compilerOptions.module === 4 && node.parent === currentSourceFile) { - write(exportFunctionForFile + "(\""); - if (node.flags & 1024) { - write("default"); - } - else { - emitNodeWithCommentsAndWithoutSourcemap(node.name); - } - write("\", "); - emitDeclarationName(node); - write(")"); - } - else { - if (node.flags & 1024) { - emitEs6ExportDefaultCompat(node); - if (languageVersion === 0) { - write("exports[\"default\"]"); - } - else { - write("exports.default"); - } - } - else { - emitModuleMemberName(node); - } - write(" = "); - emitDeclarationName(node); - } - emitEnd(node); - write(";"); - } - } - function emitExportMemberAssignments(name) { - if (compilerOptions.module === 4) { - return; - } - if (!exportEquals && exportSpecifiers && ts.hasProperty(exportSpecifiers, name.text)) { - for (var _a = 0, _b = exportSpecifiers[name.text]; _a < _b.length; _a++) { - var specifier = _b[_a]; - writeLine(); - emitStart(specifier.name); - emitContainingModuleName(specifier); - write("."); - emitNodeWithCommentsAndWithoutSourcemap(specifier.name); - emitEnd(specifier.name); - write(" = "); - emitExpressionIdentifier(name); - write(";"); - } - } - } - function emitExportSpecifierInSystemModule(specifier) { - ts.Debug.assert(compilerOptions.module === 4); - if (!resolver.getReferencedValueDeclaration(specifier.propertyName || specifier.name) && !resolver.isValueAliasDeclaration(specifier)) { - return; - } - writeLine(); - emitStart(specifier.name); - write(exportFunctionForFile + "(\""); - emitNodeWithCommentsAndWithoutSourcemap(specifier.name); - write("\", "); - emitExpressionIdentifier(specifier.propertyName || specifier.name); - write(")"); - emitEnd(specifier.name); - write(";"); - } - function emitDestructuring(root, isAssignmentExpressionStatement, value) { - var emitCount = 0; - var canDefineTempVariablesInPlace = false; - if (root.kind === 209) { - var isExported = ts.getCombinedNodeFlags(root) & 1; - var isSourceLevelForSystemModuleKind = shouldHoistDeclarationInSystemJsModule(root); - canDefineTempVariablesInPlace = !isExported && !isSourceLevelForSystemModuleKind; - } - else if (root.kind === 136) { - canDefineTempVariablesInPlace = true; - } - if (root.kind === 179) { - emitAssignmentExpression(root); - } - else { - ts.Debug.assert(!isAssignmentExpressionStatement); - emitBindingElement(root, value); - } - function emitAssignment(name, value) { - if (emitCount++) { - write(", "); - } - var isVariableDeclarationOrBindingElement = name.parent && (name.parent.kind === 209 || name.parent.kind === 161); - var exportChanged = isNameOfExportedSourceLevelDeclarationInSystemExternalModule(name); - if (exportChanged) { - write(exportFunctionForFile + "(\""); - emitNodeWithCommentsAndWithoutSourcemap(name); - write("\", "); - } - if (isVariableDeclarationOrBindingElement) { - emitModuleMemberName(name.parent); - } - else { - emit(name); - } - write(" = "); - emit(value); - if (exportChanged) { - write(")"); - } - } - function ensureIdentifier(expr, reuseIdentifierExpressions) { - if (expr.kind === 67 && reuseIdentifierExpressions) { - return expr; - } - var identifier = createTempVariable(0); - if (!canDefineTempVariablesInPlace) { - recordTempDeclaration(identifier); - } - emitAssignment(identifier, expr); - return identifier; - } - function createDefaultValueCheck(value, defaultValue) { - value = ensureIdentifier(value, true); - var equals = ts.createSynthesizedNode(179); - equals.left = value; - equals.operatorToken = ts.createSynthesizedNode(32); - equals.right = createVoidZero(); - return createConditionalExpression(equals, defaultValue, value); - } - function createConditionalExpression(condition, whenTrue, whenFalse) { - var cond = ts.createSynthesizedNode(180); - cond.condition = condition; - cond.questionToken = ts.createSynthesizedNode(52); - cond.whenTrue = whenTrue; - cond.colonToken = ts.createSynthesizedNode(53); - cond.whenFalse = whenFalse; - return cond; - } - function createNumericLiteral(value) { - var node = ts.createSynthesizedNode(8); - node.text = "" + value; - return node; - } - function createPropertyAccessForDestructuringProperty(object, propName) { - var syntheticName = ts.createSynthesizedNode(propName.kind); - syntheticName.text = propName.text; - if (syntheticName.kind !== 67) { - return createElementAccessExpression(object, syntheticName); - } - return createPropertyAccessExpression(object, syntheticName); - } - function createSliceCall(value, sliceIndex) { - var call = ts.createSynthesizedNode(166); - var sliceIdentifier = ts.createSynthesizedNode(67); - sliceIdentifier.text = "slice"; - call.expression = createPropertyAccessExpression(value, sliceIdentifier); - call.arguments = ts.createSynthesizedNodeArray(); - call.arguments[0] = createNumericLiteral(sliceIndex); - return call; - } - function emitObjectLiteralAssignment(target, value) { - var properties = target.properties; - if (properties.length !== 1) { - value = ensureIdentifier(value, true); - } - for (var _a = 0; _a < properties.length; _a++) { - var p = properties[_a]; - if (p.kind === 243 || p.kind === 244) { - var propName = p.name; - emitDestructuringAssignment(p.initializer || propName, createPropertyAccessForDestructuringProperty(value, propName)); - } - } - } - function emitArrayLiteralAssignment(target, value) { - var elements = target.elements; - if (elements.length !== 1) { - value = ensureIdentifier(value, true); - } - for (var i = 0; i < elements.length; i++) { - var e = elements[i]; - if (e.kind !== 185) { - if (e.kind !== 183) { - emitDestructuringAssignment(e, createElementAccessExpression(value, createNumericLiteral(i))); - } - else if (i === elements.length - 1) { - emitDestructuringAssignment(e.expression, createSliceCall(value, i)); - } - } - } - } - function emitDestructuringAssignment(target, value) { - if (target.kind === 179 && target.operatorToken.kind === 55) { - value = createDefaultValueCheck(value, target.right); - target = target.left; - } - if (target.kind === 163) { - emitObjectLiteralAssignment(target, value); - } - else if (target.kind === 162) { - emitArrayLiteralAssignment(target, value); - } - else { - emitAssignment(target, value); - } - } - function emitAssignmentExpression(root) { - var target = root.left; - var value = root.right; - if (ts.isEmptyObjectLiteralOrArrayLiteral(target)) { - emit(value); - } - else if (isAssignmentExpressionStatement) { - emitDestructuringAssignment(target, value); - } - else { - if (root.parent.kind !== 170) { - write("("); - } - value = ensureIdentifier(value, true); - emitDestructuringAssignment(target, value); - write(", "); - emit(value); - if (root.parent.kind !== 170) { - write(")"); - } - } - } - function emitBindingElement(target, value) { - if (target.initializer) { - value = value ? createDefaultValueCheck(value, target.initializer) : target.initializer; - } - else if (!value) { - value = createVoidZero(); - } - if (ts.isBindingPattern(target.name)) { - var pattern = target.name; - var elements = pattern.elements; - var numElements = elements.length; - if (numElements !== 1) { - value = ensureIdentifier(value, numElements !== 0); - } - for (var i = 0; i < numElements; i++) { - var element = elements[i]; - if (pattern.kind === 159) { - var propName = element.propertyName || element.name; - emitBindingElement(element, createPropertyAccessForDestructuringProperty(value, propName)); - } - else if (element.kind !== 185) { - if (!element.dotDotDotToken) { - emitBindingElement(element, createElementAccessExpression(value, createNumericLiteral(i))); - } - else if (i === numElements - 1) { - emitBindingElement(element, createSliceCall(value, i)); - } - } - } - } - else { - emitAssignment(target.name, value); - } - } - } - function emitVariableDeclaration(node) { - if (ts.isBindingPattern(node.name)) { - if (languageVersion < 2) { - emitDestructuring(node, false); - } - else { - emit(node.name); - emitOptional(" = ", node.initializer); - } - } - else { - var initializer = node.initializer; - if (!initializer && languageVersion < 2) { - var isUninitializedLet = (resolver.getNodeCheckFlags(node) & 16384) && - (getCombinedFlagsForIdentifier(node.name) & 16384); - if (isUninitializedLet && - node.parent.parent.kind !== 198 && - node.parent.parent.kind !== 199) { - initializer = createVoidZero(); - } - } - var exportChanged = isNameOfExportedSourceLevelDeclarationInSystemExternalModule(node.name); - if (exportChanged) { - write(exportFunctionForFile + "(\""); - emitNodeWithCommentsAndWithoutSourcemap(node.name); - write("\", "); - } - emitModuleMemberName(node); - emitOptional(" = ", initializer); - if (exportChanged) { - write(")"); - } - } - } - function emitExportVariableAssignments(node) { - if (node.kind === 185) { - return; - } - var name = node.name; - if (name.kind === 67) { - emitExportMemberAssignments(name); - } - else if (ts.isBindingPattern(name)) { - ts.forEach(name.elements, emitExportVariableAssignments); - } - } - function getCombinedFlagsForIdentifier(node) { - if (!node.parent || (node.parent.kind !== 209 && node.parent.kind !== 161)) { - return 0; - } - return ts.getCombinedNodeFlags(node.parent); - } - function isES6ExportedDeclaration(node) { - return !!(node.flags & 1) && - languageVersion >= 2 && - node.parent.kind === 246; - } - function emitVariableStatement(node) { - var startIsEmitted = false; - if (node.flags & 1) { - if (isES6ExportedDeclaration(node)) { - write("export "); - startIsEmitted = tryEmitStartOfVariableDeclarationList(node.declarationList); - } - } - else { - startIsEmitted = tryEmitStartOfVariableDeclarationList(node.declarationList); - } - if (startIsEmitted) { - emitCommaList(node.declarationList.declarations); - write(";"); - } - else { - var atLeastOneItem = emitVariableDeclarationListSkippingUninitializedEntries(node.declarationList); - if (atLeastOneItem) { - write(";"); - } - } - if (languageVersion < 2 && node.parent === currentSourceFile) { - ts.forEach(node.declarationList.declarations, emitExportVariableAssignments); - } - } - function shouldEmitLeadingAndTrailingCommentsForVariableStatement(node) { - if (!(node.flags & 1)) { - return true; - } - if (isES6ExportedDeclaration(node)) { - return true; - } - for (var _a = 0, _b = node.declarationList.declarations; _a < _b.length; _a++) { - var declaration = _b[_a]; - if (declaration.initializer) { - return true; - } - } - return false; - } - function emitParameter(node) { - if (languageVersion < 2) { - if (ts.isBindingPattern(node.name)) { - var name_23 = createTempVariable(0); - if (!tempParameters) { - tempParameters = []; - } - tempParameters.push(name_23); - emit(name_23); - } - else { - emit(node.name); - } - } - else { - if (node.dotDotDotToken) { - write("..."); - } - emit(node.name); - emitOptional(" = ", node.initializer); - } - } - function emitDefaultValueAssignments(node) { - if (languageVersion < 2) { - var tempIndex = 0; - ts.forEach(node.parameters, function (parameter) { - if (parameter.dotDotDotToken) { - return; - } - var paramName = parameter.name, initializer = parameter.initializer; - if (ts.isBindingPattern(paramName)) { - var hasBindingElements = paramName.elements.length > 0; - if (hasBindingElements || initializer) { - writeLine(); - write("var "); - if (hasBindingElements) { - emitDestructuring(parameter, false, tempParameters[tempIndex]); - } - else { - emit(tempParameters[tempIndex]); - write(" = "); - emit(initializer); - } - write(";"); - tempIndex++; - } - } - else if (initializer) { - writeLine(); - emitStart(parameter); - write("if ("); - emitNodeWithoutSourceMap(paramName); - write(" === void 0)"); - emitEnd(parameter); - write(" { "); - emitStart(parameter); - emitNodeWithCommentsAndWithoutSourcemap(paramName); - write(" = "); - emitNodeWithCommentsAndWithoutSourcemap(initializer); - emitEnd(parameter); - write("; }"); - } - }); - } - } - function emitRestParameter(node) { - if (languageVersion < 2 && ts.hasRestParameter(node)) { - var restIndex = node.parameters.length - 1; - var restParam = node.parameters[restIndex]; - if (ts.isBindingPattern(restParam.name)) { - return; - } - var tempName = createTempVariable(268435456).text; - writeLine(); - emitLeadingComments(restParam); - emitStart(restParam); - write("var "); - emitNodeWithCommentsAndWithoutSourcemap(restParam.name); - write(" = [];"); - emitEnd(restParam); - emitTrailingComments(restParam); - writeLine(); - write("for ("); - emitStart(restParam); - write("var " + tempName + " = " + restIndex + ";"); - emitEnd(restParam); - write(" "); - emitStart(restParam); - write(tempName + " < arguments.length;"); - emitEnd(restParam); - write(" "); - emitStart(restParam); - write(tempName + "++"); - emitEnd(restParam); - write(") {"); - increaseIndent(); - writeLine(); - emitStart(restParam); - emitNodeWithCommentsAndWithoutSourcemap(restParam.name); - write("[" + tempName + " - " + restIndex + "] = arguments[" + tempName + "];"); - emitEnd(restParam); - decreaseIndent(); - writeLine(); - write("}"); - } - } - function emitAccessor(node) { - write(node.kind === 143 ? "get " : "set "); - emit(node.name); - emitSignatureAndBody(node); - } - function shouldEmitAsArrowFunction(node) { - return node.kind === 172 && languageVersion >= 2; - } - function emitDeclarationName(node) { - if (node.name) { - emitNodeWithCommentsAndWithoutSourcemap(node.name); - } - else { - write(getGeneratedNameForNode(node)); - } - } - function shouldEmitFunctionName(node) { - if (node.kind === 171) { - return !!node.name; - } - if (node.kind === 211) { - return !!node.name || languageVersion < 2; - } - } - function emitFunctionDeclaration(node) { - if (ts.nodeIsMissing(node.body)) { - return emitCommentsOnNotEmittedNode(node); - } - if (node.kind !== 141 && node.kind !== 140 && - node.parent && node.parent.kind !== 243 && - node.parent.kind !== 166) { - emitLeadingComments(node); - } - emitStart(node); - if (!shouldEmitAsArrowFunction(node)) { - if (isES6ExportedDeclaration(node)) { - write("export "); - if (node.flags & 1024) { - write("default "); - } - } - write("function"); - if (languageVersion >= 2 && node.asteriskToken) { - write("*"); - } - write(" "); - } - if (shouldEmitFunctionName(node)) { - emitDeclarationName(node); - } - emitSignatureAndBody(node); - if (languageVersion < 2 && node.kind === 211 && node.parent === currentSourceFile && node.name) { - emitExportMemberAssignments(node.name); - } - emitEnd(node); - if (node.kind !== 141 && node.kind !== 140) { - emitTrailingComments(node); - } - } - function emitCaptureThisForNodeIfNecessary(node) { - if (resolver.getNodeCheckFlags(node) & 4) { - writeLine(); - emitStart(node); - write("var _this = this;"); - emitEnd(node); - } - } - function emitSignatureParameters(node) { - increaseIndent(); - write("("); - if (node) { - var parameters = node.parameters; - var omitCount = languageVersion < 2 && ts.hasRestParameter(node) ? 1 : 0; - emitList(parameters, 0, parameters.length - omitCount, false, false); - } - write(")"); - decreaseIndent(); - } - function emitSignatureParametersForArrow(node) { - if (node.parameters.length === 1 && node.pos === node.parameters[0].pos) { - emit(node.parameters[0]); - return; - } - emitSignatureParameters(node); - } - function emitAsyncFunctionBodyForES6(node) { - var promiseConstructor = ts.getEntityNameFromTypeNode(node.type); - var isArrowFunction = node.kind === 172; - var hasLexicalArguments = (resolver.getNodeCheckFlags(node) & 4096) !== 0; - var args; - if (!isArrowFunction) { - write(" {"); - increaseIndent(); - writeLine(); - write("return"); - } - write(" __awaiter(this"); - if (hasLexicalArguments) { - write(", arguments"); - } - else { - write(", void 0"); - } - if (promiseConstructor) { - write(", "); - emitNodeWithoutSourceMap(promiseConstructor); - } - else { - write(", Promise"); - } - if (hasLexicalArguments) { - write(", function* (_arguments)"); - } - else { - write(", function* ()"); - } - emitFunctionBody(node); - write(")"); - if (!isArrowFunction) { - write(";"); - decreaseIndent(); - writeLine(); - write("}"); - } - } - function emitFunctionBody(node) { - if (!node.body) { - write(" { }"); - } - else { - if (node.body.kind === 190) { - emitBlockFunctionBody(node, node.body); - } - else { - emitExpressionFunctionBody(node, node.body); - } - } - } - function emitSignatureAndBody(node) { - var saveTempFlags = tempFlags; - var saveTempVariables = tempVariables; - var saveTempParameters = tempParameters; - tempFlags = 0; - tempVariables = undefined; - tempParameters = undefined; - if (shouldEmitAsArrowFunction(node)) { - emitSignatureParametersForArrow(node); - write(" =>"); - } - else { - emitSignatureParameters(node); - } - var isAsync = ts.isAsyncFunctionLike(node); - if (isAsync && languageVersion === 2) { - emitAsyncFunctionBodyForES6(node); - } - else { - emitFunctionBody(node); - } - if (!isES6ExportedDeclaration(node)) { - emitExportMemberAssignment(node); - } - tempFlags = saveTempFlags; - tempVariables = saveTempVariables; - tempParameters = saveTempParameters; - } - function emitFunctionBodyPreamble(node) { - emitCaptureThisForNodeIfNecessary(node); - emitDefaultValueAssignments(node); - emitRestParameter(node); - } - function emitExpressionFunctionBody(node, body) { - if (languageVersion < 2 || node.flags & 512) { - emitDownLevelExpressionFunctionBody(node, body); - return; - } - write(" "); - var current = body; - while (current.kind === 169) { - current = current.expression; - } - emitParenthesizedIf(body, current.kind === 163); - } - function emitDownLevelExpressionFunctionBody(node, body) { - write(" {"); - scopeEmitStart(node); - increaseIndent(); - var outPos = writer.getTextPos(); - emitDetachedComments(node.body); - emitFunctionBodyPreamble(node); - var preambleEmitted = writer.getTextPos() !== outPos; - decreaseIndent(); - if (!preambleEmitted && nodeStartPositionsAreOnSameLine(node, body)) { - write(" "); - emitStart(body); - write("return "); - emit(body); - emitEnd(body); - write(";"); - emitTempDeclarations(false); - write(" "); - } - else { - increaseIndent(); - writeLine(); - emitLeadingComments(node.body); - write("return "); - emit(body); - write(";"); - emitTrailingComments(node.body); - emitTempDeclarations(true); - decreaseIndent(); - writeLine(); - } - emitStart(node.body); - write("}"); - emitEnd(node.body); - scopeEmitEnd(); - } - function emitBlockFunctionBody(node, body) { - write(" {"); - scopeEmitStart(node); - var initialTextPos = writer.getTextPos(); - increaseIndent(); - emitDetachedComments(body.statements); - var startIndex = emitDirectivePrologues(body.statements, true); - emitFunctionBodyPreamble(node); - decreaseIndent(); - var preambleEmitted = writer.getTextPos() !== initialTextPos; - if (!preambleEmitted && nodeEndIsOnSameLineAsNodeStart(body, body)) { - for (var _a = 0, _b = body.statements; _a < _b.length; _a++) { - var statement = _b[_a]; - write(" "); - emit(statement); - } - emitTempDeclarations(false); - write(" "); - emitLeadingCommentsOfPosition(body.statements.end); - } - else { - increaseIndent(); - emitLinesStartingAt(body.statements, startIndex); - emitTempDeclarations(true); - writeLine(); - emitLeadingCommentsOfPosition(body.statements.end); - decreaseIndent(); - } - emitToken(16, body.statements.end); - scopeEmitEnd(); - } - function findInitialSuperCall(ctor) { - if (ctor.body) { - var statement = ctor.body.statements[0]; - if (statement && statement.kind === 193) { - var expr = statement.expression; - if (expr && expr.kind === 166) { - var func = expr.expression; - if (func && func.kind === 93) { - return statement; - } - } - } - } - } - function emitParameterPropertyAssignments(node) { - ts.forEach(node.parameters, function (param) { - if (param.flags & 112) { - writeLine(); - emitStart(param); - emitStart(param.name); - write("this."); - emitNodeWithoutSourceMap(param.name); - emitEnd(param.name); - write(" = "); - emit(param.name); - write(";"); - emitEnd(param); - } - }); - } - function emitMemberAccessForPropertyName(memberName) { - if (memberName.kind === 9 || memberName.kind === 8) { - write("["); - emitNodeWithCommentsAndWithoutSourcemap(memberName); - write("]"); - } - else if (memberName.kind === 134) { - emitComputedPropertyName(memberName); - } - else { - write("."); - emitNodeWithCommentsAndWithoutSourcemap(memberName); - } - } - function getInitializedProperties(node, isStatic) { - var properties = []; - for (var _a = 0, _b = node.members; _a < _b.length; _a++) { - var member = _b[_a]; - if (member.kind === 139 && isStatic === ((member.flags & 128) !== 0) && member.initializer) { - properties.push(member); - } - } - return properties; - } - function emitPropertyDeclarations(node, properties) { - for (var _a = 0; _a < properties.length; _a++) { - var property = properties[_a]; - emitPropertyDeclaration(node, property); - } - } - function emitPropertyDeclaration(node, property, receiver, isExpression) { - writeLine(); - emitLeadingComments(property); - emitStart(property); - emitStart(property.name); - if (receiver) { - emit(receiver); - } - else { - if (property.flags & 128) { - emitDeclarationName(node); - } - else { - write("this"); - } - } - emitMemberAccessForPropertyName(property.name); - emitEnd(property.name); - write(" = "); - emit(property.initializer); - if (!isExpression) { - write(";"); - } - emitEnd(property); - emitTrailingComments(property); - } - function emitMemberFunctionsForES5AndLower(node) { - ts.forEach(node.members, function (member) { - if (member.kind === 189) { - writeLine(); - write(";"); - } - else if (member.kind === 141 || node.kind === 140) { - if (!member.body) { - return emitCommentsOnNotEmittedNode(member); - } - writeLine(); - emitLeadingComments(member); - emitStart(member); - emitStart(member.name); - emitClassMemberPrefix(node, member); - emitMemberAccessForPropertyName(member.name); - emitEnd(member.name); - write(" = "); - emitFunctionDeclaration(member); - emitEnd(member); - write(";"); - emitTrailingComments(member); - } - else if (member.kind === 143 || member.kind === 144) { - var accessors = ts.getAllAccessorDeclarations(node.members, member); - if (member === accessors.firstAccessor) { - writeLine(); - emitStart(member); - write("Object.defineProperty("); - emitStart(member.name); - emitClassMemberPrefix(node, member); - write(", "); - emitExpressionForPropertyName(member.name); - emitEnd(member.name); - write(", {"); - increaseIndent(); - if (accessors.getAccessor) { - writeLine(); - emitLeadingComments(accessors.getAccessor); - write("get: "); - emitStart(accessors.getAccessor); - write("function "); - emitSignatureAndBody(accessors.getAccessor); - emitEnd(accessors.getAccessor); - emitTrailingComments(accessors.getAccessor); - write(","); - } - if (accessors.setAccessor) { - writeLine(); - emitLeadingComments(accessors.setAccessor); - write("set: "); - emitStart(accessors.setAccessor); - write("function "); - emitSignatureAndBody(accessors.setAccessor); - emitEnd(accessors.setAccessor); - emitTrailingComments(accessors.setAccessor); - write(","); - } - writeLine(); - write("enumerable: true,"); - writeLine(); - write("configurable: true"); - decreaseIndent(); - writeLine(); - write("});"); - emitEnd(member); - } - } - }); - } - function emitMemberFunctionsForES6AndHigher(node) { - for (var _a = 0, _b = node.members; _a < _b.length; _a++) { - var member = _b[_a]; - if ((member.kind === 141 || node.kind === 140) && !member.body) { - emitCommentsOnNotEmittedNode(member); - } - else if (member.kind === 141 || - member.kind === 143 || - member.kind === 144) { - writeLine(); - emitLeadingComments(member); - emitStart(member); - if (member.flags & 128) { - write("static "); - } - if (member.kind === 143) { - write("get "); - } - else if (member.kind === 144) { - write("set "); - } - if (member.asteriskToken) { - write("*"); - } - emit(member.name); - emitSignatureAndBody(member); - emitEnd(member); - emitTrailingComments(member); - } - else if (member.kind === 189) { - writeLine(); - write(";"); - } - } - } - function emitConstructor(node, baseTypeElement) { - var saveTempFlags = tempFlags; - var saveTempVariables = tempVariables; - var saveTempParameters = tempParameters; - tempFlags = 0; - tempVariables = undefined; - tempParameters = undefined; - emitConstructorWorker(node, baseTypeElement); - tempFlags = saveTempFlags; - tempVariables = saveTempVariables; - tempParameters = saveTempParameters; - } - function emitConstructorWorker(node, baseTypeElement) { - var hasInstancePropertyWithInitializer = false; - ts.forEach(node.members, function (member) { - if (member.kind === 142 && !member.body) { - emitCommentsOnNotEmittedNode(member); - } - if (member.kind === 139 && member.initializer && (member.flags & 128) === 0) { - hasInstancePropertyWithInitializer = true; - } - }); - var ctor = ts.getFirstConstructorWithBody(node); - if (languageVersion >= 2 && !ctor && !hasInstancePropertyWithInitializer) { - return; - } - if (ctor) { - emitLeadingComments(ctor); - } - emitStart(ctor || node); - if (languageVersion < 2) { - write("function "); - emitDeclarationName(node); - emitSignatureParameters(ctor); - } - else { - write("constructor"); - if (ctor) { - emitSignatureParameters(ctor); - } - else { - if (baseTypeElement) { - write("(...args)"); - } - else { - write("()"); - } - } - } - var startIndex = 0; - write(" {"); - scopeEmitStart(node, "constructor"); - increaseIndent(); - if (ctor) { - startIndex = emitDirectivePrologues(ctor.body.statements, true); - emitDetachedComments(ctor.body.statements); - } - emitCaptureThisForNodeIfNecessary(node); - var superCall; - if (ctor) { - emitDefaultValueAssignments(ctor); - emitRestParameter(ctor); - if (baseTypeElement) { - superCall = findInitialSuperCall(ctor); - if (superCall) { - writeLine(); - emit(superCall); - } - } - emitParameterPropertyAssignments(ctor); - } - else { - if (baseTypeElement) { - writeLine(); - emitStart(baseTypeElement); - if (languageVersion < 2) { - write("_super.apply(this, arguments);"); - } - else { - write("super(...args);"); - } - emitEnd(baseTypeElement); - } - } - emitPropertyDeclarations(node, getInitializedProperties(node, false)); - if (ctor) { - var statements = ctor.body.statements; - if (superCall) { - statements = statements.slice(1); - } - emitLinesStartingAt(statements, startIndex); - } - emitTempDeclarations(true); - writeLine(); - if (ctor) { - emitLeadingCommentsOfPosition(ctor.body.statements.end); - } - decreaseIndent(); - emitToken(16, ctor ? ctor.body.statements.end : node.members.end); - scopeEmitEnd(); - emitEnd(ctor || node); - if (ctor) { - emitTrailingComments(ctor); - } - } - function emitClassExpression(node) { - return emitClassLikeDeclaration(node); - } - function emitClassDeclaration(node) { - return emitClassLikeDeclaration(node); - } - function emitClassLikeDeclaration(node) { - if (languageVersion < 2) { - emitClassLikeDeclarationBelowES6(node); - } - else { - emitClassLikeDeclarationForES6AndHigher(node); - } - } - function emitClassLikeDeclarationForES6AndHigher(node) { - var thisNodeIsDecorated = ts.nodeIsDecorated(node); - if (node.kind === 212) { - if (thisNodeIsDecorated) { - if (isES6ExportedDeclaration(node) && !(node.flags & 1024)) { - write("export "); - } - write("let "); - emitDeclarationName(node); - write(" = "); - } - else if (isES6ExportedDeclaration(node)) { - write("export "); - if (node.flags & 1024) { - write("default "); - } - } - } - var staticProperties = getInitializedProperties(node, true); - var isClassExpressionWithStaticProperties = staticProperties.length > 0 && node.kind === 184; - var tempVariable; - if (isClassExpressionWithStaticProperties) { - tempVariable = createAndRecordTempVariable(0); - write("("); - increaseIndent(); - emit(tempVariable); - write(" = "); - } - write("class"); - if ((node.name || !(node.flags & 1024)) && !thisNodeIsDecorated) { - write(" "); - emitDeclarationName(node); - } - var baseTypeNode = ts.getClassExtendsHeritageClauseElement(node); - if (baseTypeNode) { - write(" extends "); - emit(baseTypeNode.expression); - } - write(" {"); - increaseIndent(); - scopeEmitStart(node); - writeLine(); - emitConstructor(node, baseTypeNode); - emitMemberFunctionsForES6AndHigher(node); - decreaseIndent(); - writeLine(); - emitToken(16, node.members.end); - scopeEmitEnd(); - if (thisNodeIsDecorated) { - write(";"); - } - if (isClassExpressionWithStaticProperties) { - for (var _a = 0; _a < staticProperties.length; _a++) { - var property = staticProperties[_a]; - write(","); - writeLine(); - emitPropertyDeclaration(node, property, tempVariable, true); - } - write(","); - writeLine(); - emit(tempVariable); - decreaseIndent(); - write(")"); - } - else { - writeLine(); - emitPropertyDeclarations(node, staticProperties); - emitDecoratorsOfClass(node); - } - if (!isES6ExportedDeclaration(node) && (node.flags & 1)) { - writeLine(); - emitStart(node); - emitModuleMemberName(node); - write(" = "); - emitDeclarationName(node); - emitEnd(node); - write(";"); - } - else if (isES6ExportedDeclaration(node) && (node.flags & 1024) && thisNodeIsDecorated) { - writeLine(); - write("export default "); - emitDeclarationName(node); - write(";"); - } - } - function emitClassLikeDeclarationBelowES6(node) { - if (node.kind === 212) { - if (!shouldHoistDeclarationInSystemJsModule(node)) { - write("var "); - } - emitDeclarationName(node); - write(" = "); - } - write("(function ("); - var baseTypeNode = ts.getClassExtendsHeritageClauseElement(node); - if (baseTypeNode) { - write("_super"); - } - write(") {"); - var saveTempFlags = tempFlags; - var saveTempVariables = tempVariables; - var saveTempParameters = tempParameters; - var saveComputedPropertyNamesToGeneratedNames = computedPropertyNamesToGeneratedNames; - tempFlags = 0; - tempVariables = undefined; - tempParameters = undefined; - computedPropertyNamesToGeneratedNames = undefined; - increaseIndent(); - scopeEmitStart(node); - if (baseTypeNode) { - writeLine(); - emitStart(baseTypeNode); - write("__extends("); - emitDeclarationName(node); - write(", _super);"); - emitEnd(baseTypeNode); - } - writeLine(); - emitConstructor(node, baseTypeNode); - emitMemberFunctionsForES5AndLower(node); - emitPropertyDeclarations(node, getInitializedProperties(node, true)); - writeLine(); - emitDecoratorsOfClass(node); - writeLine(); - emitToken(16, node.members.end, function () { - write("return "); - emitDeclarationName(node); - }); - write(";"); - emitTempDeclarations(true); - tempFlags = saveTempFlags; - tempVariables = saveTempVariables; - tempParameters = saveTempParameters; - computedPropertyNamesToGeneratedNames = saveComputedPropertyNamesToGeneratedNames; - decreaseIndent(); - writeLine(); - emitToken(16, node.members.end); - scopeEmitEnd(); - emitStart(node); - write(")("); - if (baseTypeNode) { - emit(baseTypeNode.expression); - } - write(")"); - if (node.kind === 212) { - write(";"); - } - emitEnd(node); - if (node.kind === 212) { - emitExportMemberAssignment(node); - } - if (languageVersion < 2 && node.parent === currentSourceFile && node.name) { - emitExportMemberAssignments(node.name); - } - } - function emitClassMemberPrefix(node, member) { - emitDeclarationName(node); - if (!(member.flags & 128)) { - write(".prototype"); - } - } - function emitDecoratorsOfClass(node) { - emitDecoratorsOfMembers(node, 0); - emitDecoratorsOfMembers(node, 128); - emitDecoratorsOfConstructor(node); - } - function emitDecoratorsOfConstructor(node) { - var decorators = node.decorators; - var constructor = ts.getFirstConstructorWithBody(node); - var hasDecoratedParameters = constructor && ts.forEach(constructor.parameters, ts.nodeIsDecorated); - if (!decorators && !hasDecoratedParameters) { - return; - } - writeLine(); - emitStart(node); - emitDeclarationName(node); - write(" = __decorate(["); - increaseIndent(); - writeLine(); - var decoratorCount = decorators ? decorators.length : 0; - var argumentsWritten = emitList(decorators, 0, decoratorCount, true, false, false, true, function (decorator) { - emitStart(decorator); - emit(decorator.expression); - emitEnd(decorator); - }); - argumentsWritten += emitDecoratorsOfParameters(constructor, argumentsWritten > 0); - emitSerializedTypeMetadata(node, argumentsWritten >= 0); - decreaseIndent(); - writeLine(); - write("], "); - emitDeclarationName(node); - write(");"); - emitEnd(node); - writeLine(); - } - function emitDecoratorsOfMembers(node, staticFlag) { - for (var _a = 0, _b = node.members; _a < _b.length; _a++) { - var member = _b[_a]; - if ((member.flags & 128) !== staticFlag) { - continue; - } - if (!ts.nodeCanBeDecorated(member)) { - continue; - } - if (!ts.nodeOrChildIsDecorated(member)) { - continue; - } - var decorators = void 0; - var functionLikeMember = void 0; - if (ts.isAccessor(member)) { - var accessors = ts.getAllAccessorDeclarations(node.members, member); - if (member !== accessors.firstAccessor) { - continue; - } - decorators = accessors.firstAccessor.decorators; - if (!decorators && accessors.secondAccessor) { - decorators = accessors.secondAccessor.decorators; - } - functionLikeMember = accessors.setAccessor; - } - else { - decorators = member.decorators; - if (member.kind === 141) { - functionLikeMember = member; - } - } - writeLine(); - emitStart(member); - if (member.kind !== 139) { - write("Object.defineProperty("); - emitStart(member.name); - emitClassMemberPrefix(node, member); - write(", "); - emitExpressionForPropertyName(member.name); - emitEnd(member.name); - write(","); - increaseIndent(); - writeLine(); - } - write("__decorate(["); - increaseIndent(); - writeLine(); - var decoratorCount = decorators ? decorators.length : 0; - var argumentsWritten = emitList(decorators, 0, decoratorCount, true, false, false, true, function (decorator) { - emitStart(decorator); - emit(decorator.expression); - emitEnd(decorator); - }); - argumentsWritten += emitDecoratorsOfParameters(functionLikeMember, argumentsWritten > 0); - emitSerializedTypeMetadata(member, argumentsWritten > 0); - decreaseIndent(); - writeLine(); - write("], "); - emitStart(member.name); - emitClassMemberPrefix(node, member); - write(", "); - emitExpressionForPropertyName(member.name); - emitEnd(member.name); - if (member.kind !== 139) { - write(", Object.getOwnPropertyDescriptor("); - emitStart(member.name); - emitClassMemberPrefix(node, member); - write(", "); - emitExpressionForPropertyName(member.name); - emitEnd(member.name); - write("))"); - decreaseIndent(); - } - write(");"); - emitEnd(member); - writeLine(); - } - } - function emitDecoratorsOfParameters(node, leadingComma) { - var argumentsWritten = 0; - if (node) { - var parameterIndex = 0; - for (var _a = 0, _b = node.parameters; _a < _b.length; _a++) { - var parameter = _b[_a]; - if (ts.nodeIsDecorated(parameter)) { - var decorators = parameter.decorators; - argumentsWritten += emitList(decorators, 0, decorators.length, true, false, leadingComma, true, function (decorator) { - emitStart(decorator); - write("__param(" + parameterIndex + ", "); - emit(decorator.expression); - write(")"); - emitEnd(decorator); - }); - leadingComma = true; - } - ++parameterIndex; - } - } - return argumentsWritten; - } - function shouldEmitTypeMetadata(node) { - switch (node.kind) { - case 141: - case 143: - case 144: - case 139: - return true; - } - return false; - } - function shouldEmitReturnTypeMetadata(node) { - switch (node.kind) { - case 141: - return true; - } - return false; - } - function shouldEmitParamTypesMetadata(node) { - switch (node.kind) { - case 212: - case 141: - case 144: - return true; - } - return false; - } - function emitSerializedTypeOfNode(node) { - switch (node.kind) { - case 212: - write("Function"); - return; - case 139: - emitSerializedTypeNode(node.type); - return; - case 136: - emitSerializedTypeNode(node.type); - return; - case 143: - emitSerializedTypeNode(node.type); - return; - case 144: - emitSerializedTypeNode(ts.getSetAccessorTypeAnnotationNode(node)); - return; - } - if (ts.isFunctionLike(node)) { - write("Function"); - return; - } - write("void 0"); - } - function emitSerializedTypeNode(node) { - if (node) { - switch (node.kind) { - case 101: - write("void 0"); - return; - case 158: - emitSerializedTypeNode(node.type); - return; - case 150: - case 151: - write("Function"); - return; - case 154: - case 155: - write("Array"); - return; - case 148: - case 118: - write("Boolean"); - return; - case 128: - case 9: - write("String"); - return; - case 126: - write("Number"); - return; - case 129: - write("Symbol"); - return; - case 149: - emitSerializedTypeReferenceNode(node); - return; - case 152: - case 153: - case 156: - case 157: - case 115: - break; - default: - ts.Debug.fail("Cannot serialize unexpected type node."); - break; - } - } - write("Object"); - } - function emitSerializedTypeReferenceNode(node) { - var location = node.parent; - while (ts.isDeclaration(location) || ts.isTypeNode(location)) { - location = location.parent; - } - var typeName = ts.cloneEntityName(node.typeName); - typeName.parent = location; - var result = resolver.getTypeReferenceSerializationKind(typeName); - switch (result) { - case ts.TypeReferenceSerializationKind.Unknown: - var temp = createAndRecordTempVariable(0); - write("(typeof ("); - emitNodeWithoutSourceMap(temp); - write(" = "); - emitEntityNameAsExpression(typeName, true); - write(") === 'function' && "); - emitNodeWithoutSourceMap(temp); - write(") || Object"); - break; - case ts.TypeReferenceSerializationKind.TypeWithConstructSignatureAndValue: - emitEntityNameAsExpression(typeName, false); - break; - case ts.TypeReferenceSerializationKind.VoidType: - write("void 0"); - break; - case ts.TypeReferenceSerializationKind.BooleanType: - write("Boolean"); - break; - case ts.TypeReferenceSerializationKind.NumberLikeType: - write("Number"); - break; - case ts.TypeReferenceSerializationKind.StringLikeType: - write("String"); - break; - case ts.TypeReferenceSerializationKind.ArrayLikeType: - write("Array"); - break; - case ts.TypeReferenceSerializationKind.ESSymbolType: - if (languageVersion < 2) { - write("typeof Symbol === 'function' ? Symbol : Object"); - } - else { - write("Symbol"); - } - break; - case ts.TypeReferenceSerializationKind.TypeWithCallSignature: - write("Function"); - break; - case ts.TypeReferenceSerializationKind.ObjectType: - write("Object"); - break; - } - } - function emitSerializedParameterTypesOfNode(node) { - if (node) { - var valueDeclaration; - if (node.kind === 212) { - valueDeclaration = ts.getFirstConstructorWithBody(node); - } - else if (ts.isFunctionLike(node) && ts.nodeIsPresent(node.body)) { - valueDeclaration = node; - } - if (valueDeclaration) { - var parameters = valueDeclaration.parameters; - var parameterCount = parameters.length; - if (parameterCount > 0) { - for (var i = 0; i < parameterCount; i++) { - if (i > 0) { - write(", "); - } - if (parameters[i].dotDotDotToken) { - var parameterType = parameters[i].type; - if (parameterType.kind === 154) { - parameterType = parameterType.elementType; - } - else if (parameterType.kind === 149 && parameterType.typeArguments && parameterType.typeArguments.length === 1) { - parameterType = parameterType.typeArguments[0]; - } - else { - parameterType = undefined; - } - emitSerializedTypeNode(parameterType); - } - else { - emitSerializedTypeOfNode(parameters[i]); - } - } - } - } - } - } - function emitSerializedReturnTypeOfNode(node) { - if (node && ts.isFunctionLike(node) && node.type) { - emitSerializedTypeNode(node.type); - return; - } - write("void 0"); - } - function emitSerializedTypeMetadata(node, writeComma) { - var argumentsWritten = 0; - if (compilerOptions.emitDecoratorMetadata) { - if (shouldEmitTypeMetadata(node)) { - if (writeComma) { - write(", "); - } - writeLine(); - write("__metadata('design:type', "); - emitSerializedTypeOfNode(node); - write(")"); - argumentsWritten++; - } - if (shouldEmitParamTypesMetadata(node)) { - if (writeComma || argumentsWritten) { - write(", "); - } - writeLine(); - write("__metadata('design:paramtypes', ["); - emitSerializedParameterTypesOfNode(node); - write("])"); - argumentsWritten++; - } - if (shouldEmitReturnTypeMetadata(node)) { - if (writeComma || argumentsWritten) { - write(", "); - } - writeLine(); - write("__metadata('design:returntype', "); - emitSerializedReturnTypeOfNode(node); - write(")"); - argumentsWritten++; - } - } - return argumentsWritten; - } - function emitInterfaceDeclaration(node) { - emitCommentsOnNotEmittedNode(node); - } - function shouldEmitEnumDeclaration(node) { - var isConstEnum = ts.isConst(node); - return !isConstEnum || compilerOptions.preserveConstEnums || compilerOptions.isolatedModules; - } - function emitEnumDeclaration(node) { - if (!shouldEmitEnumDeclaration(node)) { - return; - } - if (!shouldHoistDeclarationInSystemJsModule(node)) { - if (!(node.flags & 1) || isES6ExportedDeclaration(node)) { - emitStart(node); - if (isES6ExportedDeclaration(node)) { - write("export "); - } - write("var "); - emit(node.name); - emitEnd(node); - write(";"); - } - } - writeLine(); - emitStart(node); - write("(function ("); - emitStart(node.name); - write(getGeneratedNameForNode(node)); - emitEnd(node.name); - write(") {"); - increaseIndent(); - scopeEmitStart(node); - emitLines(node.members); - decreaseIndent(); - writeLine(); - emitToken(16, node.members.end); - scopeEmitEnd(); - write(")("); - emitModuleMemberName(node); - write(" || ("); - emitModuleMemberName(node); - write(" = {}));"); - emitEnd(node); - if (!isES6ExportedDeclaration(node) && node.flags & 1 && !shouldHoistDeclarationInSystemJsModule(node)) { - writeLine(); - emitStart(node); - write("var "); - emit(node.name); - write(" = "); - emitModuleMemberName(node); - emitEnd(node); - write(";"); - } - if (languageVersion < 2 && node.parent === currentSourceFile) { - if (compilerOptions.module === 4 && (node.flags & 1)) { - writeLine(); - write(exportFunctionForFile + "(\""); - emitDeclarationName(node); - write("\", "); - emitDeclarationName(node); - write(");"); - } - emitExportMemberAssignments(node.name); - } - } - function emitEnumMember(node) { - var enumParent = node.parent; - emitStart(node); - write(getGeneratedNameForNode(enumParent)); - write("["); - write(getGeneratedNameForNode(enumParent)); - write("["); - emitExpressionForPropertyName(node.name); - write("] = "); - writeEnumMemberDeclarationValue(node); - write("] = "); - emitExpressionForPropertyName(node.name); - emitEnd(node); - write(";"); - } - function writeEnumMemberDeclarationValue(member) { - var value = resolver.getConstantValue(member); - if (value !== undefined) { - write(value.toString()); - return; - } - else if (member.initializer) { - emit(member.initializer); - } - else { - write("undefined"); - } - } - function getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration) { - if (moduleDeclaration.body.kind === 216) { - var recursiveInnerModule = getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration.body); - return recursiveInnerModule || moduleDeclaration.body; - } - } - function shouldEmitModuleDeclaration(node) { - return ts.isInstantiatedModule(node, compilerOptions.preserveConstEnums || compilerOptions.isolatedModules); - } - function isModuleMergedWithES6Class(node) { - return languageVersion === 2 && !!(resolver.getNodeCheckFlags(node) & 32768); - } - function emitModuleDeclaration(node) { - var shouldEmit = shouldEmitModuleDeclaration(node); - if (!shouldEmit) { - return emitCommentsOnNotEmittedNode(node); - } - var hoistedInDeclarationScope = shouldHoistDeclarationInSystemJsModule(node); - var emitVarForModule = !hoistedInDeclarationScope && !isModuleMergedWithES6Class(node); - if (emitVarForModule) { - emitStart(node); - if (isES6ExportedDeclaration(node)) { - write("export "); - } - write("var "); - emit(node.name); - write(";"); - emitEnd(node); - writeLine(); - } - emitStart(node); - write("(function ("); - emitStart(node.name); - write(getGeneratedNameForNode(node)); - emitEnd(node.name); - write(") "); - if (node.body.kind === 217) { - var saveTempFlags = tempFlags; - var saveTempVariables = tempVariables; - tempFlags = 0; - tempVariables = undefined; - emit(node.body); - tempFlags = saveTempFlags; - tempVariables = saveTempVariables; - } - else { - write("{"); - increaseIndent(); - scopeEmitStart(node); - emitCaptureThisForNodeIfNecessary(node); - writeLine(); - emit(node.body); - decreaseIndent(); - writeLine(); - var moduleBlock = getInnerMostModuleDeclarationFromDottedModule(node).body; - emitToken(16, moduleBlock.statements.end); - scopeEmitEnd(); - } - write(")("); - if ((node.flags & 1) && !isES6ExportedDeclaration(node)) { - emit(node.name); - write(" = "); - } - emitModuleMemberName(node); - write(" || ("); - emitModuleMemberName(node); - write(" = {}));"); - emitEnd(node); - if (!isES6ExportedDeclaration(node) && node.name.kind === 67 && node.parent === currentSourceFile) { - if (compilerOptions.module === 4 && (node.flags & 1)) { - writeLine(); - write(exportFunctionForFile + "(\""); - emitDeclarationName(node); - write("\", "); - emitDeclarationName(node); - write(");"); - } - emitExportMemberAssignments(node.name); - } - } - function tryRenameExternalModule(moduleName) { - if (currentSourceFile.renamedDependencies && ts.hasProperty(currentSourceFile.renamedDependencies, moduleName.text)) { - return "\"" + currentSourceFile.renamedDependencies[moduleName.text] + "\""; - } - return undefined; - } - function emitRequire(moduleName) { - if (moduleName.kind === 9) { - write("require("); - var text = tryRenameExternalModule(moduleName); - if (text) { - write(text); - } - else { - emitStart(moduleName); - emitLiteral(moduleName); - emitEnd(moduleName); - } - emitToken(18, moduleName.end); - } - else { - write("require()"); - } - } - function getNamespaceDeclarationNode(node) { - if (node.kind === 219) { - return node; - } - var importClause = node.importClause; - if (importClause && importClause.namedBindings && importClause.namedBindings.kind === 222) { - return importClause.namedBindings; - } - } - function isDefaultImport(node) { - return node.kind === 220 && node.importClause && !!node.importClause.name; - } - function emitExportImportAssignments(node) { - if (ts.isAliasSymbolDeclaration(node) && resolver.isValueAliasDeclaration(node)) { - emitExportMemberAssignments(node.name); - } - ts.forEachChild(node, emitExportImportAssignments); - } - function emitImportDeclaration(node) { - if (languageVersion < 2) { - return emitExternalImportDeclaration(node); - } - if (node.importClause) { - var shouldEmitDefaultBindings = resolver.isReferencedAliasDeclaration(node.importClause); - var shouldEmitNamedBindings = node.importClause.namedBindings && resolver.isReferencedAliasDeclaration(node.importClause.namedBindings, true); - if (shouldEmitDefaultBindings || shouldEmitNamedBindings) { - write("import "); - emitStart(node.importClause); - if (shouldEmitDefaultBindings) { - emit(node.importClause.name); - if (shouldEmitNamedBindings) { - write(", "); - } - } - if (shouldEmitNamedBindings) { - emitLeadingComments(node.importClause.namedBindings); - emitStart(node.importClause.namedBindings); - if (node.importClause.namedBindings.kind === 222) { - write("* as "); - emit(node.importClause.namedBindings.name); - } - else { - write("{ "); - emitExportOrImportSpecifierList(node.importClause.namedBindings.elements, resolver.isReferencedAliasDeclaration); - write(" }"); - } - emitEnd(node.importClause.namedBindings); - emitTrailingComments(node.importClause.namedBindings); - } - emitEnd(node.importClause); - write(" from "); - emit(node.moduleSpecifier); - write(";"); - } - } - else { - write("import "); - emit(node.moduleSpecifier); - write(";"); - } - } - function emitExternalImportDeclaration(node) { - if (ts.contains(externalImports, node)) { - var isExportedImport = node.kind === 219 && (node.flags & 1) !== 0; - var namespaceDeclaration = getNamespaceDeclarationNode(node); - if (compilerOptions.module !== 2) { - emitLeadingComments(node); - emitStart(node); - if (namespaceDeclaration && !isDefaultImport(node)) { - if (!isExportedImport) - write("var "); - emitModuleMemberName(namespaceDeclaration); - write(" = "); - } - else { - var isNakedImport = 220 && !node.importClause; - if (!isNakedImport) { - write("var "); - write(getGeneratedNameForNode(node)); - write(" = "); - } - } - emitRequire(ts.getExternalModuleName(node)); - if (namespaceDeclaration && isDefaultImport(node)) { - write(", "); - emitModuleMemberName(namespaceDeclaration); - write(" = "); - write(getGeneratedNameForNode(node)); - } - write(";"); - emitEnd(node); - emitExportImportAssignments(node); - emitTrailingComments(node); - } - else { - if (isExportedImport) { - emitModuleMemberName(namespaceDeclaration); - write(" = "); - emit(namespaceDeclaration.name); - write(";"); - } - else if (namespaceDeclaration && isDefaultImport(node)) { - write("var "); - emitModuleMemberName(namespaceDeclaration); - write(" = "); - write(getGeneratedNameForNode(node)); - write(";"); - } - emitExportImportAssignments(node); - } - } - } - function emitImportEqualsDeclaration(node) { - if (ts.isExternalModuleImportEqualsDeclaration(node)) { - emitExternalImportDeclaration(node); - return; - } - if (resolver.isReferencedAliasDeclaration(node) || - (!ts.isExternalModule(currentSourceFile) && resolver.isTopLevelValueImportEqualsWithEntityName(node))) { - emitLeadingComments(node); - emitStart(node); - var variableDeclarationIsHoisted = shouldHoistVariable(node, true); - var isExported = isSourceFileLevelDeclarationInSystemJsModule(node, true); - if (!variableDeclarationIsHoisted) { - ts.Debug.assert(!isExported); - if (isES6ExportedDeclaration(node)) { - write("export "); - write("var "); - } - else if (!(node.flags & 1)) { - write("var "); - } - } - if (isExported) { - write(exportFunctionForFile + "(\""); - emitNodeWithoutSourceMap(node.name); - write("\", "); - } - emitModuleMemberName(node); - write(" = "); - emit(node.moduleReference); - if (isExported) { - write(")"); - } - write(";"); - emitEnd(node); - emitExportImportAssignments(node); - emitTrailingComments(node); - } - } - function emitExportDeclaration(node) { - ts.Debug.assert(compilerOptions.module !== 4); - if (languageVersion < 2) { - if (node.moduleSpecifier && (!node.exportClause || resolver.isValueAliasDeclaration(node))) { - emitStart(node); - var generatedName = getGeneratedNameForNode(node); - if (node.exportClause) { - if (compilerOptions.module !== 2) { - write("var "); - write(generatedName); - write(" = "); - emitRequire(ts.getExternalModuleName(node)); - write(";"); - } - for (var _a = 0, _b = node.exportClause.elements; _a < _b.length; _a++) { - var specifier = _b[_a]; - if (resolver.isValueAliasDeclaration(specifier)) { - writeLine(); - emitStart(specifier); - emitContainingModuleName(specifier); - write("."); - emitNodeWithCommentsAndWithoutSourcemap(specifier.name); - write(" = "); - write(generatedName); - write("."); - emitNodeWithCommentsAndWithoutSourcemap(specifier.propertyName || specifier.name); - write(";"); - emitEnd(specifier); - } - } - } - else { - writeLine(); - write("__export("); - if (compilerOptions.module !== 2) { - emitRequire(ts.getExternalModuleName(node)); - } - else { - write(generatedName); - } - write(");"); - } - emitEnd(node); - } - } - else { - if (!node.exportClause || resolver.isValueAliasDeclaration(node)) { - write("export "); - if (node.exportClause) { - write("{ "); - emitExportOrImportSpecifierList(node.exportClause.elements, resolver.isValueAliasDeclaration); - write(" }"); - } - else { - write("*"); - } - if (node.moduleSpecifier) { - write(" from "); - emit(node.moduleSpecifier); - } - write(";"); - } - } - } - function emitExportOrImportSpecifierList(specifiers, shouldEmit) { - ts.Debug.assert(languageVersion >= 2); - var needsComma = false; - for (var _a = 0; _a < specifiers.length; _a++) { - var specifier = specifiers[_a]; - if (shouldEmit(specifier)) { - if (needsComma) { - write(", "); - } - if (specifier.propertyName) { - emit(specifier.propertyName); - write(" as "); - } - emit(specifier.name); - needsComma = true; - } - } - } - function emitExportAssignment(node) { - if (!node.isExportEquals && resolver.isValueAliasDeclaration(node)) { - if (languageVersion >= 2) { - writeLine(); - emitStart(node); - write("export default "); - var expression = node.expression; - emit(expression); - if (expression.kind !== 211 && - expression.kind !== 212) { - write(";"); - } - emitEnd(node); - } - else { - writeLine(); - emitStart(node); - if (compilerOptions.module === 4) { - write(exportFunctionForFile + "(\"default\","); - emit(node.expression); - write(")"); - } - else { - emitEs6ExportDefaultCompat(node); - emitContainingModuleName(node); - if (languageVersion === 0) { - write("[\"default\"] = "); - } - else { - write(".default = "); - } - emit(node.expression); - } - write(";"); - emitEnd(node); - } - } - } - function collectExternalModuleInfo(sourceFile) { - externalImports = []; - exportSpecifiers = {}; - exportEquals = undefined; - hasExportStars = false; - for (var _a = 0, _b = sourceFile.statements; _a < _b.length; _a++) { - var node = _b[_a]; - switch (node.kind) { - case 220: - if (!node.importClause || - resolver.isReferencedAliasDeclaration(node.importClause, true)) { - externalImports.push(node); - } - break; - case 219: - if (node.moduleReference.kind === 230 && resolver.isReferencedAliasDeclaration(node)) { - externalImports.push(node); - } - break; - case 226: - if (node.moduleSpecifier) { - if (!node.exportClause) { - externalImports.push(node); - hasExportStars = true; - } - else if (resolver.isValueAliasDeclaration(node)) { - externalImports.push(node); - } - } - else { - for (var _c = 0, _d = node.exportClause.elements; _c < _d.length; _c++) { - var specifier = _d[_c]; - var name_24 = (specifier.propertyName || specifier.name).text; - (exportSpecifiers[name_24] || (exportSpecifiers[name_24] = [])).push(specifier); - } - } - break; - case 225: - if (node.isExportEquals && !exportEquals) { - exportEquals = node; - } - break; - } - } - } - function emitExportStarHelper() { - if (hasExportStars) { - writeLine(); - write("function __export(m) {"); - increaseIndent(); - writeLine(); - write("for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];"); - decreaseIndent(); - writeLine(); - write("}"); - } - } - function getLocalNameForExternalImport(node) { - var namespaceDeclaration = getNamespaceDeclarationNode(node); - if (namespaceDeclaration && !isDefaultImport(node)) { - return ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, namespaceDeclaration.name); - } - if (node.kind === 220 && node.importClause) { - return getGeneratedNameForNode(node); - } - if (node.kind === 226 && node.moduleSpecifier) { - return getGeneratedNameForNode(node); - } - } - function getExternalModuleNameText(importNode) { - var moduleName = ts.getExternalModuleName(importNode); - if (moduleName.kind === 9) { - return tryRenameExternalModule(moduleName) || getLiteralText(moduleName); - } - return undefined; - } - function emitVariableDeclarationsForImports() { - if (externalImports.length === 0) { - return; - } - writeLine(); - var started = false; - for (var _a = 0; _a < externalImports.length; _a++) { - var importNode = externalImports[_a]; - var skipNode = importNode.kind === 226 || - (importNode.kind === 220 && !importNode.importClause); - if (skipNode) { - continue; - } - if (!started) { - write("var "); - started = true; - } - else { - write(", "); - } - write(getLocalNameForExternalImport(importNode)); - } - if (started) { - write(";"); - } - } - function emitLocalStorageForExportedNamesIfNecessary(exportedDeclarations) { - if (!hasExportStars) { - return undefined; - } - if (!exportedDeclarations && ts.isEmpty(exportSpecifiers)) { - var hasExportDeclarationWithExportClause = false; - for (var _a = 0; _a < externalImports.length; _a++) { - var externalImport = externalImports[_a]; - if (externalImport.kind === 226 && externalImport.exportClause) { - hasExportDeclarationWithExportClause = true; - break; - } - } - if (!hasExportDeclarationWithExportClause) { - return emitExportStarFunction(undefined); - } - } - var exportedNamesStorageRef = makeUniqueName("exportedNames"); - writeLine(); - write("var " + exportedNamesStorageRef + " = {"); - increaseIndent(); - var started = false; - if (exportedDeclarations) { - for (var i = 0; i < exportedDeclarations.length; ++i) { - writeExportedName(exportedDeclarations[i]); - } - } - if (exportSpecifiers) { - for (var n in exportSpecifiers) { - for (var _b = 0, _c = exportSpecifiers[n]; _b < _c.length; _b++) { - var specifier = _c[_b]; - writeExportedName(specifier.name); - } - } - } - for (var _d = 0; _d < externalImports.length; _d++) { - var externalImport = externalImports[_d]; - if (externalImport.kind !== 226) { - continue; - } - var exportDecl = externalImport; - if (!exportDecl.exportClause) { - continue; - } - for (var _e = 0, _f = exportDecl.exportClause.elements; _e < _f.length; _e++) { - var element = _f[_e]; - writeExportedName(element.name || element.propertyName); - } - } - decreaseIndent(); - writeLine(); - write("};"); - return emitExportStarFunction(exportedNamesStorageRef); - function emitExportStarFunction(localNames) { - var exportStarFunction = makeUniqueName("exportStar"); - writeLine(); - write("function " + exportStarFunction + "(m) {"); - increaseIndent(); - writeLine(); - write("var exports = {};"); - writeLine(); - write("for(var n in m) {"); - increaseIndent(); - writeLine(); - write("if (n !== \"default\""); - if (localNames) { - write("&& !" + localNames + ".hasOwnProperty(n)"); - } - write(") exports[n] = m[n];"); - decreaseIndent(); - writeLine(); - write("}"); - writeLine(); - write(exportFunctionForFile + "(exports);"); - decreaseIndent(); - writeLine(); - write("}"); - return exportStarFunction; - } - function writeExportedName(node) { - if (node.kind !== 67 && node.flags & 1024) { - return; - } - if (started) { - write(","); - } - else { - started = true; - } - writeLine(); - write("'"); - if (node.kind === 67) { - emitNodeWithCommentsAndWithoutSourcemap(node); - } - else { - emitDeclarationName(node); - } - write("': true"); - } - } - function processTopLevelVariableAndFunctionDeclarations(node) { - var hoistedVars; - var hoistedFunctionDeclarations; - var exportedDeclarations; - visit(node); - if (hoistedVars) { - writeLine(); - write("var "); - var seen = {}; - for (var i = 0; i < hoistedVars.length; ++i) { - var local = hoistedVars[i]; - var name_25 = local.kind === 67 - ? local - : local.name; - if (name_25) { - var text = ts.unescapeIdentifier(name_25.text); - if (ts.hasProperty(seen, text)) { - continue; - } - else { - seen[text] = text; - } - } - if (i !== 0) { - write(", "); - } - if (local.kind === 212 || local.kind === 216 || local.kind === 215) { - emitDeclarationName(local); - } - else { - emit(local); - } - var flags = ts.getCombinedNodeFlags(local.kind === 67 ? local.parent : local); - if (flags & 1) { - if (!exportedDeclarations) { - exportedDeclarations = []; - } - exportedDeclarations.push(local); - } - } - write(";"); - } - if (hoistedFunctionDeclarations) { - for (var _a = 0; _a < hoistedFunctionDeclarations.length; _a++) { - var f = hoistedFunctionDeclarations[_a]; - writeLine(); - emit(f); - if (f.flags & 1) { - if (!exportedDeclarations) { - exportedDeclarations = []; - } - exportedDeclarations.push(f); - } - } - } - return exportedDeclarations; - function visit(node) { - if (node.flags & 2) { - return; - } - if (node.kind === 211) { - if (!hoistedFunctionDeclarations) { - hoistedFunctionDeclarations = []; - } - hoistedFunctionDeclarations.push(node); - return; - } - if (node.kind === 212) { - if (!hoistedVars) { - hoistedVars = []; - } - hoistedVars.push(node); - return; - } - if (node.kind === 215) { - if (shouldEmitEnumDeclaration(node)) { - if (!hoistedVars) { - hoistedVars = []; - } - hoistedVars.push(node); - } - return; - } - if (node.kind === 216) { - if (shouldEmitModuleDeclaration(node)) { - if (!hoistedVars) { - hoistedVars = []; - } - hoistedVars.push(node); - } - return; - } - if (node.kind === 209 || node.kind === 161) { - if (shouldHoistVariable(node, false)) { - var name_26 = node.name; - if (name_26.kind === 67) { - if (!hoistedVars) { - hoistedVars = []; - } - hoistedVars.push(name_26); - } - else { - ts.forEachChild(name_26, visit); - } - } - return; - } - if (ts.isInternalModuleImportEqualsDeclaration(node) && resolver.isValueAliasDeclaration(node)) { - if (!hoistedVars) { - hoistedVars = []; - } - hoistedVars.push(node.name); - return; - } - if (ts.isBindingPattern(node)) { - ts.forEach(node.elements, visit); - return; - } - if (!ts.isDeclaration(node)) { - ts.forEachChild(node, visit); - } - } - } - function shouldHoistVariable(node, checkIfSourceFileLevelDecl) { - if (checkIfSourceFileLevelDecl && !shouldHoistDeclarationInSystemJsModule(node)) { - return false; - } - return (ts.getCombinedNodeFlags(node) & 49152) === 0 || - ts.getEnclosingBlockScopeContainer(node).kind === 246; - } - function isCurrentFileSystemExternalModule() { - return compilerOptions.module === 4 && ts.isExternalModule(currentSourceFile); - } - function emitSystemModuleBody(node, dependencyGroups, startIndex) { - emitVariableDeclarationsForImports(); - writeLine(); - var exportedDeclarations = processTopLevelVariableAndFunctionDeclarations(node); - var exportStarFunction = emitLocalStorageForExportedNamesIfNecessary(exportedDeclarations); - writeLine(); - write("return {"); - increaseIndent(); - writeLine(); - emitSetters(exportStarFunction, dependencyGroups); - writeLine(); - emitExecute(node, startIndex); - decreaseIndent(); - writeLine(); - write("}"); - emitTempDeclarations(true); - } - function emitSetters(exportStarFunction, dependencyGroups) { - write("setters:["); - for (var i = 0; i < dependencyGroups.length; ++i) { - if (i !== 0) { - write(","); - } - writeLine(); - increaseIndent(); - var group = dependencyGroups[i]; - var parameterName = makeUniqueName(ts.forEach(group, getLocalNameForExternalImport) || ""); - write("function (" + parameterName + ") {"); - increaseIndent(); - for (var _a = 0; _a < group.length; _a++) { - var entry = group[_a]; - var importVariableName = getLocalNameForExternalImport(entry) || ""; - switch (entry.kind) { - case 220: - if (!entry.importClause) { - break; - } - case 219: - ts.Debug.assert(importVariableName !== ""); - writeLine(); - write(importVariableName + " = " + parameterName + ";"); - writeLine(); - break; - case 226: - ts.Debug.assert(importVariableName !== ""); - if (entry.exportClause) { - writeLine(); - write(exportFunctionForFile + "({"); - writeLine(); - increaseIndent(); - for (var i_2 = 0, len = entry.exportClause.elements.length; i_2 < len; ++i_2) { - if (i_2 !== 0) { - write(","); - writeLine(); - } - var e = entry.exportClause.elements[i_2]; - write("\""); - emitNodeWithCommentsAndWithoutSourcemap(e.name); - write("\": " + parameterName + "[\""); - emitNodeWithCommentsAndWithoutSourcemap(e.propertyName || e.name); - write("\"]"); - } - decreaseIndent(); - writeLine(); - write("});"); - } - else { - writeLine(); - write(exportStarFunction + "(" + parameterName + ");"); - } - writeLine(); - break; - } - } - decreaseIndent(); - write("}"); - decreaseIndent(); - } - write("],"); - } - function emitExecute(node, startIndex) { - write("execute: function() {"); - increaseIndent(); - writeLine(); - for (var i = startIndex; i < node.statements.length; ++i) { - var statement = node.statements[i]; - switch (statement.kind) { - case 211: - case 220: - continue; - case 226: - if (!statement.moduleSpecifier) { - for (var _a = 0, _b = statement.exportClause.elements; _a < _b.length; _a++) { - var element = _b[_a]; - emitExportSpecifierInSystemModule(element); - } - } - continue; - case 219: - if (!ts.isInternalModuleImportEqualsDeclaration(statement)) { - continue; - } - default: - writeLine(); - emit(statement); - } - } - decreaseIndent(); - writeLine(); - write("}"); - } - function emitSystemModule(node, startIndex) { - collectExternalModuleInfo(node); - ts.Debug.assert(!exportFunctionForFile); - exportFunctionForFile = makeUniqueName("exports"); - writeLine(); - write("System.register("); - if (node.moduleName) { - write("\"" + node.moduleName + "\", "); - } - write("["); - var groupIndices = {}; - var dependencyGroups = []; - for (var i = 0; i < externalImports.length; ++i) { - var text = getExternalModuleNameText(externalImports[i]); - if (ts.hasProperty(groupIndices, text)) { - var groupIndex = groupIndices[text]; - dependencyGroups[groupIndex].push(externalImports[i]); - continue; - } - else { - groupIndices[text] = dependencyGroups.length; - dependencyGroups.push([externalImports[i]]); - } - if (i !== 0) { - write(", "); - } - write(text); - } - write("], function(" + exportFunctionForFile + ") {"); - writeLine(); - increaseIndent(); - emitEmitHelpers(node); - emitCaptureThisForNodeIfNecessary(node); - emitSystemModuleBody(node, dependencyGroups, startIndex); - decreaseIndent(); - writeLine(); - write("});"); - } - function emitAMDDependencies(node, includeNonAmdDependencies) { - var aliasedModuleNames = []; - var unaliasedModuleNames = []; - var importAliasNames = []; - for (var _a = 0, _b = node.amdDependencies; _a < _b.length; _a++) { - var amdDependency = _b[_a]; - if (amdDependency.name) { - aliasedModuleNames.push("\"" + amdDependency.path + "\""); - importAliasNames.push(amdDependency.name); - } - else { - unaliasedModuleNames.push("\"" + amdDependency.path + "\""); - } - } - for (var _c = 0; _c < externalImports.length; _c++) { - var importNode = externalImports[_c]; - var externalModuleName = getExternalModuleNameText(importNode); - var importAliasName = getLocalNameForExternalImport(importNode); - if (includeNonAmdDependencies && importAliasName) { - aliasedModuleNames.push(externalModuleName); - importAliasNames.push(importAliasName); - } - else { - unaliasedModuleNames.push(externalModuleName); - } - } - write("[\"require\", \"exports\""); - if (aliasedModuleNames.length) { - write(", "); - write(aliasedModuleNames.join(", ")); - } - if (unaliasedModuleNames.length) { - write(", "); - write(unaliasedModuleNames.join(", ")); - } - write("], function (require, exports"); - if (importAliasNames.length) { - write(", "); - write(importAliasNames.join(", ")); - } - } - function emitAMDModule(node, startIndex) { - emitEmitHelpers(node); - collectExternalModuleInfo(node); - writeLine(); - write("define("); - if (node.moduleName) { - write("\"" + node.moduleName + "\", "); - } - emitAMDDependencies(node, true); - write(") {"); - increaseIndent(); - emitExportStarHelper(); - emitCaptureThisForNodeIfNecessary(node); - emitLinesStartingAt(node.statements, startIndex); - emitTempDeclarations(true); - emitExportEquals(true); - decreaseIndent(); - writeLine(); - write("});"); - } - function emitCommonJSModule(node, startIndex) { - emitEmitHelpers(node); - collectExternalModuleInfo(node); - emitExportStarHelper(); - emitCaptureThisForNodeIfNecessary(node); - emitLinesStartingAt(node.statements, startIndex); - emitTempDeclarations(true); - emitExportEquals(false); - } - function emitUMDModule(node, startIndex) { - emitEmitHelpers(node); - collectExternalModuleInfo(node); - writeLines("(function (deps, factory) {\n if (typeof module === 'object' && typeof module.exports === 'object') {\n var v = factory(require, exports); if (v !== undefined) module.exports = v;\n }\n else if (typeof define === 'function' && define.amd) {\n define(deps, factory);\n }\n})("); - emitAMDDependencies(node, false); - write(") {"); - increaseIndent(); - emitExportStarHelper(); - emitCaptureThisForNodeIfNecessary(node); - emitLinesStartingAt(node.statements, startIndex); - emitTempDeclarations(true); - emitExportEquals(true); - decreaseIndent(); - writeLine(); - write("});"); - } - function emitES6Module(node, startIndex) { - externalImports = undefined; - exportSpecifiers = undefined; - exportEquals = undefined; - hasExportStars = false; - emitEmitHelpers(node); - emitCaptureThisForNodeIfNecessary(node); - emitLinesStartingAt(node.statements, startIndex); - emitTempDeclarations(true); - } - function emitExportEquals(emitAsReturn) { - if (exportEquals && resolver.isValueAliasDeclaration(exportEquals)) { - writeLine(); - emitStart(exportEquals); - write(emitAsReturn ? "return " : "module.exports = "); - emit(exportEquals.expression); - write(";"); - emitEnd(exportEquals); - } - } - function emitJsxElement(node) { - switch (compilerOptions.jsx) { - case 2: - jsxEmitReact(node); - break; - case 1: - default: - jsxEmitPreserve(node); - break; - } - } - function trimReactWhitespaceAndApplyEntities(node) { - var result = undefined; - var text = ts.getTextOfNode(node, true); - var firstNonWhitespace = 0; - var lastNonWhitespace = -1; - for (var i = 0; i < text.length; i++) { - var c = text.charCodeAt(i); - if (ts.isLineBreak(c)) { - if (firstNonWhitespace !== -1 && (lastNonWhitespace - firstNonWhitespace + 1 > 0)) { - var part = text.substr(firstNonWhitespace, lastNonWhitespace - firstNonWhitespace + 1); - result = (result ? result + "\" + ' ' + \"" : "") + part; - } - firstNonWhitespace = -1; - } - else if (!ts.isWhiteSpace(c)) { - lastNonWhitespace = i; - if (firstNonWhitespace === -1) { - firstNonWhitespace = i; - } - } - } - if (firstNonWhitespace !== -1) { - var part = text.substr(firstNonWhitespace); - result = (result ? result + "\" + ' ' + \"" : "") + part; - } - if (result) { - result = result.replace(/&(\w+);/g, function (s, m) { - if (entities[m] !== undefined) { - return String.fromCharCode(entities[m]); - } - else { - return s; - } - }); - } - return result; - } - function getTextToEmit(node) { - switch (compilerOptions.jsx) { - case 2: - var text = trimReactWhitespaceAndApplyEntities(node); - if (text === undefined || text.length === 0) { - return undefined; - } - else { - return text; - } - case 1: - default: - return ts.getTextOfNode(node, true); - } - } - function emitJsxText(node) { - switch (compilerOptions.jsx) { - case 2: - write("\""); - write(trimReactWhitespaceAndApplyEntities(node)); - write("\""); - break; - case 1: - default: - writer.writeLiteral(ts.getTextOfNode(node, true)); - break; - } - } - function emitJsxExpression(node) { - if (node.expression) { - switch (compilerOptions.jsx) { - case 1: - default: - write("{"); - emit(node.expression); - write("}"); - break; - case 2: - emit(node.expression); - break; - } - } - } - function emitDirectivePrologues(statements, startWithNewLine) { - for (var i = 0; i < statements.length; ++i) { - if (ts.isPrologueDirective(statements[i])) { - if (startWithNewLine || i > 0) { - writeLine(); - } - emit(statements[i]); - } - else { - return i; - } - } - return statements.length; - } - function writeLines(text) { - var lines = text.split(/\r\n|\r|\n/g); - for (var i = 0; i < lines.length; ++i) { - var line = lines[i]; - if (line.length) { - writeLine(); - write(line); - } - } - } - function emitEmitHelpers(node) { - if (!compilerOptions.noEmitHelpers) { - if ((languageVersion < 2) && (!extendsEmitted && resolver.getNodeCheckFlags(node) & 8)) { - writeLines(extendsHelper); - extendsEmitted = true; - } - if (!decorateEmitted && resolver.getNodeCheckFlags(node) & 16) { - writeLines(decorateHelper); - if (compilerOptions.emitDecoratorMetadata) { - writeLines(metadataHelper); - } - decorateEmitted = true; - } - if (!paramEmitted && resolver.getNodeCheckFlags(node) & 32) { - writeLines(paramHelper); - paramEmitted = true; - } - if (!awaiterEmitted && resolver.getNodeCheckFlags(node) & 64) { - writeLines(awaiterHelper); - awaiterEmitted = true; - } - } - } - function emitSourceFileNode(node) { - writeLine(); - emitShebang(); - emitDetachedComments(node); - var startIndex = emitDirectivePrologues(node.statements, false); - if (ts.isExternalModule(node) || compilerOptions.isolatedModules) { - if (languageVersion >= 2) { - emitES6Module(node, startIndex); - } - else if (compilerOptions.module === 2) { - emitAMDModule(node, startIndex); - } - else if (compilerOptions.module === 4) { - emitSystemModule(node, startIndex); - } - else if (compilerOptions.module === 3) { - emitUMDModule(node, startIndex); - } - else { - emitCommonJSModule(node, startIndex); - } - } - else { - externalImports = undefined; - exportSpecifiers = undefined; - exportEquals = undefined; - hasExportStars = false; - emitEmitHelpers(node); - emitCaptureThisForNodeIfNecessary(node); - emitLinesStartingAt(node.statements, startIndex); - emitTempDeclarations(true); - } - emitLeadingComments(node.endOfFileToken); - } - function emitNodeWithCommentsAndWithoutSourcemap(node) { - emitNodeConsideringCommentsOption(node, emitNodeWithoutSourceMap); - } - function emitNodeConsideringCommentsOption(node, emitNodeConsideringSourcemap) { - if (node) { - if (node.flags & 2) { - return emitCommentsOnNotEmittedNode(node); - } - if (isSpecializedCommentHandling(node)) { - return emitNodeWithoutSourceMap(node); - } - var emitComments_1 = shouldEmitLeadingAndTrailingComments(node); - if (emitComments_1) { - emitLeadingComments(node); - } - emitNodeConsideringSourcemap(node); - if (emitComments_1) { - emitTrailingComments(node); - } - } - } - function emitNodeWithoutSourceMap(node) { - if (node) { - emitJavaScriptWorker(node); - } - } - function isSpecializedCommentHandling(node) { - switch (node.kind) { - case 213: - case 211: - case 220: - case 219: - case 214: - case 225: - return true; - } - } - function shouldEmitLeadingAndTrailingComments(node) { - switch (node.kind) { - case 191: - return shouldEmitLeadingAndTrailingCommentsForVariableStatement(node); - case 216: - return shouldEmitModuleDeclaration(node); - case 215: - return shouldEmitEnumDeclaration(node); - } - ts.Debug.assert(!isSpecializedCommentHandling(node)); - if (node.kind !== 190 && - node.parent && - node.parent.kind === 172 && - node.parent.body === node && - compilerOptions.target <= 1) { - return false; - } - return true; - } - function emitJavaScriptWorker(node) { - switch (node.kind) { - case 67: - return emitIdentifier(node); - case 136: - return emitParameter(node); - case 141: - case 140: - return emitMethod(node); - case 143: - case 144: - return emitAccessor(node); - case 95: - return emitThis(node); - case 93: - return emitSuper(node); - case 91: - return write("null"); - case 97: - return write("true"); - case 82: - return write("false"); - case 8: - case 9: - case 10: - case 11: - case 12: - case 13: - case 14: - return emitLiteral(node); - case 181: - return emitTemplateExpression(node); - case 188: - return emitTemplateSpan(node); - case 231: - case 232: - return emitJsxElement(node); - case 234: - return emitJsxText(node); - case 238: - return emitJsxExpression(node); - case 133: - return emitQualifiedName(node); - case 159: - return emitObjectBindingPattern(node); - case 160: - return emitArrayBindingPattern(node); - case 161: - return emitBindingElement(node); - case 162: - return emitArrayLiteral(node); - case 163: - return emitObjectLiteral(node); - case 243: - return emitPropertyAssignment(node); - case 244: - return emitShorthandPropertyAssignment(node); - case 134: - return emitComputedPropertyName(node); - case 164: - return emitPropertyAccess(node); - case 165: - return emitIndexedAccess(node); - case 166: - return emitCallExpression(node); - case 167: - return emitNewExpression(node); - case 168: - return emitTaggedTemplateExpression(node); - case 169: - return emit(node.expression); - case 187: - return emit(node.expression); - case 170: - return emitParenExpression(node); - case 211: - case 171: - case 172: - return emitFunctionDeclaration(node); - case 173: - return emitDeleteExpression(node); - case 174: - return emitTypeOfExpression(node); - case 175: - return emitVoidExpression(node); - case 176: - return emitAwaitExpression(node); - case 177: - return emitPrefixUnaryExpression(node); - case 178: - return emitPostfixUnaryExpression(node); - case 179: - return emitBinaryExpression(node); - case 180: - return emitConditionalExpression(node); - case 183: - return emitSpreadElementExpression(node); - case 182: - return emitYieldExpression(node); - case 185: - return; - case 190: - case 217: - return emitBlock(node); - case 191: - return emitVariableStatement(node); - case 192: - return write(";"); - case 193: - return emitExpressionStatement(node); - case 194: - return emitIfStatement(node); - case 195: - return emitDoStatement(node); - case 196: - return emitWhileStatement(node); - case 197: - return emitForStatement(node); - case 199: - case 198: - return emitForInOrForOfStatement(node); - case 200: - case 201: - return emitBreakOrContinueStatement(node); - case 202: - return emitReturnStatement(node); - case 203: - return emitWithStatement(node); - case 204: - return emitSwitchStatement(node); - case 239: - case 240: - return emitCaseOrDefaultClause(node); - case 205: - return emitLabelledStatement(node); - case 206: - return emitThrowStatement(node); - case 207: - return emitTryStatement(node); - case 242: - return emitCatchClause(node); - case 208: - return emitDebuggerStatement(node); - case 209: - return emitVariableDeclaration(node); - case 184: - return emitClassExpression(node); - case 212: - return emitClassDeclaration(node); - case 213: - return emitInterfaceDeclaration(node); - case 215: - return emitEnumDeclaration(node); - case 245: - return emitEnumMember(node); - case 216: - return emitModuleDeclaration(node); - case 220: - return emitImportDeclaration(node); - case 219: - return emitImportEqualsDeclaration(node); - case 226: - return emitExportDeclaration(node); - case 225: - return emitExportAssignment(node); - case 246: - return emitSourceFileNode(node); - } - } - function hasDetachedComments(pos) { - return detachedCommentsInfo !== undefined && ts.lastOrUndefined(detachedCommentsInfo).nodePos === pos; - } - function getLeadingCommentsWithoutDetachedComments() { - var leadingComments = ts.getLeadingCommentRanges(currentSourceFile.text, ts.lastOrUndefined(detachedCommentsInfo).detachedCommentEndPos); - if (detachedCommentsInfo.length - 1) { - detachedCommentsInfo.pop(); - } - else { - detachedCommentsInfo = undefined; - } - return leadingComments; - } - function isPinnedComments(comment) { - return currentSourceFile.text.charCodeAt(comment.pos + 1) === 42 && - currentSourceFile.text.charCodeAt(comment.pos + 2) === 33; - } - function isTripleSlashComment(comment) { - if (currentSourceFile.text.charCodeAt(comment.pos + 1) === 47 && - comment.pos + 2 < comment.end && - currentSourceFile.text.charCodeAt(comment.pos + 2) === 47) { - var textSubStr = currentSourceFile.text.substring(comment.pos, comment.end); - return textSubStr.match(ts.fullTripleSlashReferencePathRegEx) || - textSubStr.match(ts.fullTripleSlashAMDReferencePathRegEx) ? - true : false; - } - return false; - } - function getLeadingCommentsToEmit(node) { - if (node.parent) { - if (node.parent.kind === 246 || node.pos !== node.parent.pos) { - if (hasDetachedComments(node.pos)) { - return getLeadingCommentsWithoutDetachedComments(); - } - else { - return ts.getLeadingCommentRangesOfNode(node, currentSourceFile); - } - } - } - } - function getTrailingCommentsToEmit(node) { - if (node.parent) { - if (node.parent.kind === 246 || node.end !== node.parent.end) { - return ts.getTrailingCommentRanges(currentSourceFile.text, node.end); - } - } - } - function emitCommentsOnNotEmittedNode(node) { - emitLeadingCommentsWorker(node, false); - } - function emitLeadingComments(node) { - return emitLeadingCommentsWorker(node, true); - } - function emitLeadingCommentsWorker(node, isEmittedNode) { - if (compilerOptions.removeComments) { - return; - } - var leadingComments; - if (isEmittedNode) { - leadingComments = getLeadingCommentsToEmit(node); - } - else { - if (node.pos === 0) { - leadingComments = ts.filter(getLeadingCommentsToEmit(node), isTripleSlashComment); - } - } - ts.emitNewLineBeforeLeadingComments(currentSourceFile, writer, node, leadingComments); - ts.emitComments(currentSourceFile, writer, leadingComments, true, newLine, writeComment); - } - function emitTrailingComments(node) { - if (compilerOptions.removeComments) { - return; - } - var trailingComments = getTrailingCommentsToEmit(node); - ts.emitComments(currentSourceFile, writer, trailingComments, false, newLine, writeComment); - } - function emitTrailingCommentsOfPosition(pos) { - if (compilerOptions.removeComments) { - return; - } - var trailingComments = ts.getTrailingCommentRanges(currentSourceFile.text, pos); - ts.emitComments(currentSourceFile, writer, trailingComments, true, newLine, writeComment); - } - function emitLeadingCommentsOfPositionWorker(pos) { - if (compilerOptions.removeComments) { - return; - } - var leadingComments; - if (hasDetachedComments(pos)) { - leadingComments = getLeadingCommentsWithoutDetachedComments(); - } - else { - leadingComments = ts.getLeadingCommentRanges(currentSourceFile.text, pos); - } - ts.emitNewLineBeforeLeadingComments(currentSourceFile, writer, { pos: pos, end: pos }, leadingComments); - ts.emitComments(currentSourceFile, writer, leadingComments, true, newLine, writeComment); - } - function emitDetachedComments(node) { - var leadingComments; - if (compilerOptions.removeComments) { - if (node.pos === 0) { - leadingComments = ts.filter(ts.getLeadingCommentRanges(currentSourceFile.text, node.pos), isPinnedComments); - } - } - else { - leadingComments = ts.getLeadingCommentRanges(currentSourceFile.text, node.pos); - } - if (leadingComments) { - var detachedComments = []; - var lastComment; - ts.forEach(leadingComments, function (comment) { - if (lastComment) { - var lastCommentLine = ts.getLineOfLocalPosition(currentSourceFile, lastComment.end); - var commentLine = ts.getLineOfLocalPosition(currentSourceFile, comment.pos); - if (commentLine >= lastCommentLine + 2) { - return detachedComments; - } - } - detachedComments.push(comment); - lastComment = comment; - }); - if (detachedComments.length) { - var lastCommentLine = ts.getLineOfLocalPosition(currentSourceFile, ts.lastOrUndefined(detachedComments).end); - var nodeLine = ts.getLineOfLocalPosition(currentSourceFile, ts.skipTrivia(currentSourceFile.text, node.pos)); - if (nodeLine >= lastCommentLine + 2) { - ts.emitNewLineBeforeLeadingComments(currentSourceFile, writer, node, leadingComments); - ts.emitComments(currentSourceFile, writer, detachedComments, true, newLine, writeComment); - var currentDetachedCommentInfo = { nodePos: node.pos, detachedCommentEndPos: ts.lastOrUndefined(detachedComments).end }; - if (detachedCommentsInfo) { - detachedCommentsInfo.push(currentDetachedCommentInfo); - } - else { - detachedCommentsInfo = [currentDetachedCommentInfo]; - } - } - } - } - } - function emitShebang() { - var shebang = ts.getShebang(currentSourceFile.text); - if (shebang) { - write(shebang); - } - } - } - function emitFile(jsFilePath, sourceFile) { - emitJavaScript(jsFilePath, sourceFile); - if (compilerOptions.declaration) { - ts.writeDeclarationFile(jsFilePath, sourceFile, host, resolver, diagnostics); - } - } - } - ts.emitFiles = emitFiles; var entities = { "quot": 0x0022, "amp": 0x0026, @@ -29323,6 +24298,5552 @@ var ts; "hearts": 0x2665, "diams": 0x2666 }; + function emitFiles(resolver, host, targetSourceFile) { + var extendsHelper = "\nvar __extends = (this && this.__extends) || function (d, b) {\n for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];\n function __() { this.constructor = d; }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n};"; + var decorateHelper = "\nvar __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\n return c > 3 && r && Object.defineProperty(target, key, r), r;\n};"; + var metadataHelper = "\nvar __metadata = (this && this.__metadata) || function (k, v) {\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(k, v);\n};"; + var paramHelper = "\nvar __param = (this && this.__param) || function (paramIndex, decorator) {\n return function (target, key) { decorator(target, key, paramIndex); }\n};"; + var awaiterHelper = "\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promise, generator) {\n return new Promise(function (resolve, reject) {\n generator = generator.call(thisArg, _arguments);\n function cast(value) { return value instanceof Promise && value.constructor === Promise ? value : new Promise(function (resolve) { resolve(value); }); }\n function onfulfill(value) { try { step(\"next\", value); } catch (e) { reject(e); } }\n function onreject(value) { try { step(\"throw\", value); } catch (e) { reject(e); } }\n function step(verb, value) {\n var result = generator[verb](value);\n result.done ? resolve(result.value) : cast(result.value).then(onfulfill, onreject);\n }\n step(\"next\", void 0);\n });\n};"; + var compilerOptions = host.getCompilerOptions(); + var languageVersion = compilerOptions.target || 0; + var modulekind = compilerOptions.module ? compilerOptions.module : languageVersion === 2 ? 5 : 0; + var sourceMapDataList = compilerOptions.sourceMap || compilerOptions.inlineSourceMap ? [] : undefined; + var diagnostics = []; + var newLine = host.getNewLine(); + var jsxDesugaring = host.getCompilerOptions().jsx !== 1; + var shouldEmitJsx = function (s) { return (s.languageVariant === 1 && !jsxDesugaring); }; + if (targetSourceFile === undefined) { + ts.forEach(host.getSourceFiles(), function (sourceFile) { + if (ts.shouldEmitToOwnFile(sourceFile, compilerOptions)) { + var jsFilePath = ts.getOwnEmitOutputFilePath(sourceFile, host, shouldEmitJsx(sourceFile) ? ".jsx" : ".js"); + emitFile(jsFilePath, sourceFile); + } + }); + if (compilerOptions.outFile || compilerOptions.out) { + emitFile(compilerOptions.outFile || compilerOptions.out); + } + } + else { + if (ts.shouldEmitToOwnFile(targetSourceFile, compilerOptions)) { + var jsFilePath = ts.getOwnEmitOutputFilePath(targetSourceFile, host, shouldEmitJsx(targetSourceFile) ? ".jsx" : ".js"); + emitFile(jsFilePath, targetSourceFile); + } + else if (!ts.isDeclarationFile(targetSourceFile) && (compilerOptions.outFile || compilerOptions.out)) { + emitFile(compilerOptions.outFile || compilerOptions.out); + } + } + diagnostics = ts.sortAndDeduplicateDiagnostics(diagnostics); + return { + emitSkipped: false, + diagnostics: diagnostics, + sourceMaps: sourceMapDataList + }; + function isNodeDescendentOf(node, ancestor) { + while (node) { + if (node === ancestor) + return true; + node = node.parent; + } + return false; + } + function isUniqueLocalName(name, container) { + for (var node = container; isNodeDescendentOf(node, container); node = node.nextContainer) { + if (node.locals && ts.hasProperty(node.locals, name)) { + if (node.locals[name].flags & (107455 | 1048576 | 8388608)) { + return false; + } + } + } + return true; + } + function emitJavaScript(jsFilePath, root) { + var writer = ts.createTextWriter(newLine); + var write = writer.write, writeTextOfNode = writer.writeTextOfNode, writeLine = writer.writeLine, increaseIndent = writer.increaseIndent, decreaseIndent = writer.decreaseIndent; + var currentSourceFile; + var exportFunctionForFile; + var generatedNameSet = {}; + var nodeToGeneratedName = []; + var computedPropertyNamesToGeneratedNames; + var extendsEmitted = false; + var decorateEmitted = false; + var paramEmitted = false; + var awaiterEmitted = false; + var tempFlags = 0; + var tempVariables; + var tempParameters; + var externalImports; + var exportSpecifiers; + var exportEquals; + var hasExportStars; + var writeEmittedFiles = writeJavaScriptFile; + var detachedCommentsInfo; + var writeComment = ts.writeCommentRange; + var emit = emitNodeWithCommentsAndWithoutSourcemap; + var emitStart = function (node) { }; + var emitEnd = function (node) { }; + var emitToken = emitTokenText; + var scopeEmitStart = function (scopeDeclaration, scopeName) { }; + var scopeEmitEnd = function () { }; + var sourceMapData; + var emitLeadingCommentsOfPosition = compilerOptions.removeComments ? function (pos) { } : emitLeadingCommentsOfPositionWorker; + var moduleEmitDelegates = (_a = {}, + _a[5] = emitES6Module, + _a[2] = emitAMDModule, + _a[4] = emitSystemModule, + _a[3] = emitUMDModule, + _a[1] = emitCommonJSModule, + _a + ); + if (compilerOptions.sourceMap || compilerOptions.inlineSourceMap) { + initializeEmitterWithSourceMaps(); + } + if (root) { + emitSourceFile(root); + } + else { + ts.forEach(host.getSourceFiles(), function (sourceFile) { + if (!isExternalModuleOrDeclarationFile(sourceFile)) { + emitSourceFile(sourceFile); + } + }); + } + writeLine(); + writeEmittedFiles(writer.getText(), compilerOptions.emitBOM); + return; + function emitSourceFile(sourceFile) { + currentSourceFile = sourceFile; + exportFunctionForFile = undefined; + emit(sourceFile); + } + function isUniqueName(name) { + return !resolver.hasGlobalName(name) && + !ts.hasProperty(currentSourceFile.identifiers, name) && + !ts.hasProperty(generatedNameSet, name); + } + function makeTempVariableName(flags) { + if (flags && !(tempFlags & flags)) { + var name_19 = flags === 268435456 ? "_i" : "_n"; + if (isUniqueName(name_19)) { + tempFlags |= flags; + return name_19; + } + } + while (true) { + var count = tempFlags & 268435455; + tempFlags++; + if (count !== 8 && count !== 13) { + var name_20 = count < 26 ? "_" + String.fromCharCode(97 + count) : "_" + (count - 26); + if (isUniqueName(name_20)) { + return name_20; + } + } + } + } + function makeUniqueName(baseName) { + if (baseName.charCodeAt(baseName.length - 1) !== 95) { + baseName += "_"; + } + var i = 1; + while (true) { + var generatedName = baseName + i; + if (isUniqueName(generatedName)) { + return generatedNameSet[generatedName] = generatedName; + } + i++; + } + } + function generateNameForModuleOrEnum(node) { + var name = node.name.text; + return isUniqueLocalName(name, node) ? name : makeUniqueName(name); + } + function generateNameForImportOrExportDeclaration(node) { + var expr = ts.getExternalModuleName(node); + var baseName = expr.kind === 9 ? + ts.escapeIdentifier(ts.makeIdentifierFromModuleName(expr.text)) : "module"; + return makeUniqueName(baseName); + } + function generateNameForExportDefault() { + return makeUniqueName("default"); + } + function generateNameForClassExpression() { + return makeUniqueName("class"); + } + function generateNameForNode(node) { + switch (node.kind) { + case 69: + return makeUniqueName(node.text); + case 218: + case 217: + return generateNameForModuleOrEnum(node); + case 222: + case 228: + return generateNameForImportOrExportDeclaration(node); + case 213: + case 214: + case 227: + return generateNameForExportDefault(); + case 186: + return generateNameForClassExpression(); + } + } + function getGeneratedNameForNode(node) { + var id = ts.getNodeId(node); + return nodeToGeneratedName[id] || (nodeToGeneratedName[id] = ts.unescapeIdentifier(generateNameForNode(node))); + } + function initializeEmitterWithSourceMaps() { + var sourceMapDir; + var sourceMapSourceIndex = -1; + var sourceMapNameIndexMap = {}; + var sourceMapNameIndices = []; + function getSourceMapNameIndex() { + return sourceMapNameIndices.length ? ts.lastOrUndefined(sourceMapNameIndices) : -1; + } + var lastRecordedSourceMapSpan; + var lastEncodedSourceMapSpan = { + emittedLine: 1, + emittedColumn: 1, + sourceLine: 1, + sourceColumn: 1, + sourceIndex: 0 + }; + var lastEncodedNameIndex = 0; + function encodeLastRecordedSourceMapSpan() { + if (!lastRecordedSourceMapSpan || lastRecordedSourceMapSpan === lastEncodedSourceMapSpan) { + return; + } + var prevEncodedEmittedColumn = lastEncodedSourceMapSpan.emittedColumn; + if (lastEncodedSourceMapSpan.emittedLine === lastRecordedSourceMapSpan.emittedLine) { + if (sourceMapData.sourceMapMappings) { + sourceMapData.sourceMapMappings += ","; + } + } + else { + for (var encodedLine = lastEncodedSourceMapSpan.emittedLine; encodedLine < lastRecordedSourceMapSpan.emittedLine; encodedLine++) { + sourceMapData.sourceMapMappings += ";"; + } + prevEncodedEmittedColumn = 1; + } + sourceMapData.sourceMapMappings += base64VLQFormatEncode(lastRecordedSourceMapSpan.emittedColumn - prevEncodedEmittedColumn); + sourceMapData.sourceMapMappings += base64VLQFormatEncode(lastRecordedSourceMapSpan.sourceIndex - lastEncodedSourceMapSpan.sourceIndex); + sourceMapData.sourceMapMappings += base64VLQFormatEncode(lastRecordedSourceMapSpan.sourceLine - lastEncodedSourceMapSpan.sourceLine); + sourceMapData.sourceMapMappings += base64VLQFormatEncode(lastRecordedSourceMapSpan.sourceColumn - lastEncodedSourceMapSpan.sourceColumn); + if (lastRecordedSourceMapSpan.nameIndex >= 0) { + sourceMapData.sourceMapMappings += base64VLQFormatEncode(lastRecordedSourceMapSpan.nameIndex - lastEncodedNameIndex); + lastEncodedNameIndex = lastRecordedSourceMapSpan.nameIndex; + } + lastEncodedSourceMapSpan = lastRecordedSourceMapSpan; + sourceMapData.sourceMapDecodedMappings.push(lastEncodedSourceMapSpan); + function base64VLQFormatEncode(inValue) { + function base64FormatEncode(inValue) { + if (inValue < 64) { + return "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(inValue); + } + throw TypeError(inValue + ": not a 64 based value"); + } + if (inValue < 0) { + inValue = ((-inValue) << 1) + 1; + } + else { + inValue = inValue << 1; + } + var encodedStr = ""; + do { + var currentDigit = inValue & 31; + inValue = inValue >> 5; + if (inValue > 0) { + currentDigit = currentDigit | 32; + } + encodedStr = encodedStr + base64FormatEncode(currentDigit); + } while (inValue > 0); + return encodedStr; + } + } + function recordSourceMapSpan(pos) { + var sourceLinePos = ts.getLineAndCharacterOfPosition(currentSourceFile, pos); + sourceLinePos.line++; + sourceLinePos.character++; + var emittedLine = writer.getLine(); + var emittedColumn = writer.getColumn(); + if (!lastRecordedSourceMapSpan || + lastRecordedSourceMapSpan.emittedLine !== emittedLine || + lastRecordedSourceMapSpan.emittedColumn !== emittedColumn || + (lastRecordedSourceMapSpan.sourceIndex === sourceMapSourceIndex && + (lastRecordedSourceMapSpan.sourceLine > sourceLinePos.line || + (lastRecordedSourceMapSpan.sourceLine === sourceLinePos.line && lastRecordedSourceMapSpan.sourceColumn > sourceLinePos.character)))) { + encodeLastRecordedSourceMapSpan(); + lastRecordedSourceMapSpan = { + emittedLine: emittedLine, + emittedColumn: emittedColumn, + sourceLine: sourceLinePos.line, + sourceColumn: sourceLinePos.character, + nameIndex: getSourceMapNameIndex(), + sourceIndex: sourceMapSourceIndex + }; + } + else { + lastRecordedSourceMapSpan.sourceLine = sourceLinePos.line; + lastRecordedSourceMapSpan.sourceColumn = sourceLinePos.character; + lastRecordedSourceMapSpan.sourceIndex = sourceMapSourceIndex; + } + } + function recordEmitNodeStartSpan(node) { + recordSourceMapSpan(ts.skipTrivia(currentSourceFile.text, node.pos)); + } + function recordEmitNodeEndSpan(node) { + recordSourceMapSpan(node.end); + } + function writeTextWithSpanRecord(tokenKind, startPos, emitFn) { + var tokenStartPos = ts.skipTrivia(currentSourceFile.text, startPos); + recordSourceMapSpan(tokenStartPos); + var tokenEndPos = emitTokenText(tokenKind, tokenStartPos, emitFn); + recordSourceMapSpan(tokenEndPos); + return tokenEndPos; + } + function recordNewSourceFileStart(node) { + var sourcesDirectoryPath = compilerOptions.sourceRoot ? host.getCommonSourceDirectory() : sourceMapDir; + sourceMapData.sourceMapSources.push(ts.getRelativePathToDirectoryOrUrl(sourcesDirectoryPath, node.fileName, host.getCurrentDirectory(), host.getCanonicalFileName, true)); + sourceMapSourceIndex = sourceMapData.sourceMapSources.length - 1; + sourceMapData.inputSourceFileNames.push(node.fileName); + if (compilerOptions.inlineSources) { + if (!sourceMapData.sourceMapSourcesContent) { + sourceMapData.sourceMapSourcesContent = []; + } + sourceMapData.sourceMapSourcesContent.push(node.text); + } + } + function recordScopeNameOfNode(node, scopeName) { + function recordScopeNameIndex(scopeNameIndex) { + sourceMapNameIndices.push(scopeNameIndex); + } + function recordScopeNameStart(scopeName) { + var scopeNameIndex = -1; + if (scopeName) { + var parentIndex = getSourceMapNameIndex(); + if (parentIndex !== -1) { + var name_21 = node.name; + if (!name_21 || name_21.kind !== 136) { + scopeName = "." + scopeName; + } + scopeName = sourceMapData.sourceMapNames[parentIndex] + scopeName; + } + scopeNameIndex = ts.getProperty(sourceMapNameIndexMap, scopeName); + if (scopeNameIndex === undefined) { + scopeNameIndex = sourceMapData.sourceMapNames.length; + sourceMapData.sourceMapNames.push(scopeName); + sourceMapNameIndexMap[scopeName] = scopeNameIndex; + } + } + recordScopeNameIndex(scopeNameIndex); + } + if (scopeName) { + recordScopeNameStart(scopeName); + } + else if (node.kind === 213 || + node.kind === 173 || + node.kind === 143 || + node.kind === 142 || + node.kind === 145 || + node.kind === 146 || + node.kind === 218 || + node.kind === 214 || + node.kind === 217) { + if (node.name) { + var name_22 = node.name; + scopeName = name_22.kind === 136 + ? ts.getTextOfNode(name_22) + : node.name.text; + } + recordScopeNameStart(scopeName); + } + else { + recordScopeNameIndex(getSourceMapNameIndex()); + } + } + function recordScopeNameEnd() { + sourceMapNameIndices.pop(); + } + ; + function writeCommentRangeWithMap(curentSourceFile, writer, comment, newLine) { + recordSourceMapSpan(comment.pos); + ts.writeCommentRange(currentSourceFile, writer, comment, newLine); + recordSourceMapSpan(comment.end); + } + function serializeSourceMapContents(version, file, sourceRoot, sources, names, mappings, sourcesContent) { + if (typeof JSON !== "undefined") { + var map_1 = { + version: version, + file: file, + sourceRoot: sourceRoot, + sources: sources, + names: names, + mappings: mappings + }; + if (sourcesContent !== undefined) { + map_1.sourcesContent = sourcesContent; + } + return JSON.stringify(map_1); + } + return "{\"version\":" + version + ",\"file\":\"" + ts.escapeString(file) + "\",\"sourceRoot\":\"" + ts.escapeString(sourceRoot) + "\",\"sources\":[" + serializeStringArray(sources) + "],\"names\":[" + serializeStringArray(names) + "],\"mappings\":\"" + ts.escapeString(mappings) + "\" " + (sourcesContent !== undefined ? ",\"sourcesContent\":[" + serializeStringArray(sourcesContent) + "]" : "") + "}"; + function serializeStringArray(list) { + var output = ""; + for (var i = 0, n = list.length; i < n; i++) { + if (i) { + output += ","; + } + output += "\"" + ts.escapeString(list[i]) + "\""; + } + return output; + } + } + function writeJavaScriptAndSourceMapFile(emitOutput, writeByteOrderMark) { + encodeLastRecordedSourceMapSpan(); + var sourceMapText = serializeSourceMapContents(3, sourceMapData.sourceMapFile, sourceMapData.sourceMapSourceRoot, sourceMapData.sourceMapSources, sourceMapData.sourceMapNames, sourceMapData.sourceMapMappings, sourceMapData.sourceMapSourcesContent); + sourceMapDataList.push(sourceMapData); + var sourceMapUrl; + if (compilerOptions.inlineSourceMap) { + var base64SourceMapText = ts.convertToBase64(sourceMapText); + sourceMapUrl = "//# sourceMappingURL=data:application/json;base64," + base64SourceMapText; + } + else { + ts.writeFile(host, diagnostics, sourceMapData.sourceMapFilePath, sourceMapText, false); + sourceMapUrl = "//# sourceMappingURL=" + sourceMapData.jsSourceMappingURL; + } + writeJavaScriptFile(emitOutput + sourceMapUrl, writeByteOrderMark); + } + var sourceMapJsFile = ts.getBaseFileName(ts.normalizeSlashes(jsFilePath)); + sourceMapData = { + sourceMapFilePath: jsFilePath + ".map", + jsSourceMappingURL: sourceMapJsFile + ".map", + sourceMapFile: sourceMapJsFile, + sourceMapSourceRoot: compilerOptions.sourceRoot || "", + sourceMapSources: [], + inputSourceFileNames: [], + sourceMapNames: [], + sourceMapMappings: "", + sourceMapSourcesContent: undefined, + sourceMapDecodedMappings: [] + }; + sourceMapData.sourceMapSourceRoot = ts.normalizeSlashes(sourceMapData.sourceMapSourceRoot); + if (sourceMapData.sourceMapSourceRoot.length && sourceMapData.sourceMapSourceRoot.charCodeAt(sourceMapData.sourceMapSourceRoot.length - 1) !== 47) { + sourceMapData.sourceMapSourceRoot += ts.directorySeparator; + } + if (compilerOptions.mapRoot) { + sourceMapDir = ts.normalizeSlashes(compilerOptions.mapRoot); + if (root) { + sourceMapDir = ts.getDirectoryPath(ts.getSourceFilePathInNewDir(root, host, sourceMapDir)); + } + if (!ts.isRootedDiskPath(sourceMapDir) && !ts.isUrl(sourceMapDir)) { + sourceMapDir = ts.combinePaths(host.getCommonSourceDirectory(), sourceMapDir); + sourceMapData.jsSourceMappingURL = ts.getRelativePathToDirectoryOrUrl(ts.getDirectoryPath(ts.normalizePath(jsFilePath)), ts.combinePaths(sourceMapDir, sourceMapData.jsSourceMappingURL), host.getCurrentDirectory(), host.getCanonicalFileName, true); + } + else { + sourceMapData.jsSourceMappingURL = ts.combinePaths(sourceMapDir, sourceMapData.jsSourceMappingURL); + } + } + else { + sourceMapDir = ts.getDirectoryPath(ts.normalizePath(jsFilePath)); + } + function emitNodeWithSourceMap(node) { + if (node) { + if (ts.nodeIsSynthesized(node)) { + return emitNodeWithoutSourceMap(node); + } + if (node.kind !== 248) { + recordEmitNodeStartSpan(node); + emitNodeWithoutSourceMap(node); + recordEmitNodeEndSpan(node); + } + else { + recordNewSourceFileStart(node); + emitNodeWithoutSourceMap(node); + } + } + } + function emitNodeWithCommentsAndWithSourcemap(node) { + emitNodeConsideringCommentsOption(node, emitNodeWithSourceMap); + } + writeEmittedFiles = writeJavaScriptAndSourceMapFile; + emit = emitNodeWithCommentsAndWithSourcemap; + emitStart = recordEmitNodeStartSpan; + emitEnd = recordEmitNodeEndSpan; + emitToken = writeTextWithSpanRecord; + scopeEmitStart = recordScopeNameOfNode; + scopeEmitEnd = recordScopeNameEnd; + writeComment = writeCommentRangeWithMap; + } + function writeJavaScriptFile(emitOutput, writeByteOrderMark) { + ts.writeFile(host, diagnostics, jsFilePath, emitOutput, writeByteOrderMark); + } + function createTempVariable(flags) { + var result = ts.createSynthesizedNode(69); + result.text = makeTempVariableName(flags); + return result; + } + function recordTempDeclaration(name) { + if (!tempVariables) { + tempVariables = []; + } + tempVariables.push(name); + } + function createAndRecordTempVariable(flags) { + var temp = createTempVariable(flags); + recordTempDeclaration(temp); + return temp; + } + function emitTempDeclarations(newLine) { + if (tempVariables) { + if (newLine) { + writeLine(); + } + else { + write(" "); + } + write("var "); + emitCommaList(tempVariables); + write(";"); + } + } + function emitTokenText(tokenKind, startPos, emitFn) { + var tokenString = ts.tokenToString(tokenKind); + if (emitFn) { + emitFn(); + } + else { + write(tokenString); + } + return startPos + tokenString.length; + } + function emitOptional(prefix, node) { + if (node) { + write(prefix); + emit(node); + } + } + function emitParenthesizedIf(node, parenthesized) { + if (parenthesized) { + write("("); + } + emit(node); + if (parenthesized) { + write(")"); + } + } + function emitTrailingCommaIfPresent(nodeList) { + if (nodeList.hasTrailingComma) { + write(","); + } + } + function emitLinePreservingList(parent, nodes, allowTrailingComma, spacesBetweenBraces) { + ts.Debug.assert(nodes.length > 0); + increaseIndent(); + if (nodeStartPositionsAreOnSameLine(parent, nodes[0])) { + if (spacesBetweenBraces) { + write(" "); + } + } + else { + writeLine(); + } + for (var i = 0, n = nodes.length; i < n; i++) { + if (i) { + if (nodeEndIsOnSameLineAsNodeStart(nodes[i - 1], nodes[i])) { + write(", "); + } + else { + write(","); + writeLine(); + } + } + emit(nodes[i]); + } + if (nodes.hasTrailingComma && allowTrailingComma) { + write(","); + } + decreaseIndent(); + if (nodeEndPositionsAreOnSameLine(parent, ts.lastOrUndefined(nodes))) { + if (spacesBetweenBraces) { + write(" "); + } + } + else { + writeLine(); + } + } + function emitList(nodes, start, count, multiLine, trailingComma, leadingComma, noTrailingNewLine, emitNode) { + if (!emitNode) { + emitNode = emit; + } + for (var i = 0; i < count; i++) { + if (multiLine) { + if (i || leadingComma) { + write(","); + } + writeLine(); + } + else { + if (i || leadingComma) { + write(", "); + } + } + var node = nodes[start + i]; + emitTrailingCommentsOfPosition(node.pos); + emitNode(node); + leadingComma = true; + } + if (trailingComma) { + write(","); + } + if (multiLine && !noTrailingNewLine) { + writeLine(); + } + return count; + } + function emitCommaList(nodes) { + if (nodes) { + emitList(nodes, 0, nodes.length, false, false); + } + } + function emitLines(nodes) { + emitLinesStartingAt(nodes, 0); + } + function emitLinesStartingAt(nodes, startIndex) { + for (var i = startIndex; i < nodes.length; i++) { + writeLine(); + emit(nodes[i]); + } + } + function isBinaryOrOctalIntegerLiteral(node, text) { + if (node.kind === 8 && text.length > 1) { + switch (text.charCodeAt(1)) { + case 98: + case 66: + case 111: + case 79: + return true; + } + } + return false; + } + function emitLiteral(node) { + var text = getLiteralText(node); + if ((compilerOptions.sourceMap || compilerOptions.inlineSourceMap) && (node.kind === 9 || ts.isTemplateLiteralKind(node.kind))) { + writer.writeLiteral(text); + } + else if (languageVersion < 2 && isBinaryOrOctalIntegerLiteral(node, text)) { + write(node.text); + } + else { + write(text); + } + } + function getLiteralText(node) { + if (languageVersion < 2 && (ts.isTemplateLiteralKind(node.kind) || node.hasExtendedUnicodeEscape)) { + return getQuotedEscapedLiteralText("\"", node.text, "\""); + } + if (node.parent) { + return ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, node); + } + switch (node.kind) { + case 9: + return getQuotedEscapedLiteralText("\"", node.text, "\""); + case 11: + return getQuotedEscapedLiteralText("`", node.text, "`"); + case 12: + return getQuotedEscapedLiteralText("`", node.text, "${"); + case 13: + return getQuotedEscapedLiteralText("}", node.text, "${"); + case 14: + return getQuotedEscapedLiteralText("}", node.text, "`"); + case 8: + return node.text; + } + ts.Debug.fail("Literal kind '" + node.kind + "' not accounted for."); + } + function getQuotedEscapedLiteralText(leftQuote, text, rightQuote) { + return leftQuote + ts.escapeNonAsciiCharacters(ts.escapeString(text)) + rightQuote; + } + function emitDownlevelRawTemplateLiteral(node) { + var text = ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, node); + var isLast = node.kind === 11 || node.kind === 14; + text = text.substring(1, text.length - (isLast ? 1 : 2)); + text = text.replace(/\r\n?/g, "\n"); + text = ts.escapeString(text); + write("\"" + text + "\""); + } + function emitDownlevelTaggedTemplateArray(node, literalEmitter) { + write("["); + if (node.template.kind === 11) { + literalEmitter(node.template); + } + else { + literalEmitter(node.template.head); + ts.forEach(node.template.templateSpans, function (child) { + write(", "); + literalEmitter(child.literal); + }); + } + write("]"); + } + function emitDownlevelTaggedTemplate(node) { + var tempVariable = createAndRecordTempVariable(0); + write("("); + emit(tempVariable); + write(" = "); + emitDownlevelTaggedTemplateArray(node, emit); + write(", "); + emit(tempVariable); + write(".raw = "); + emitDownlevelTaggedTemplateArray(node, emitDownlevelRawTemplateLiteral); + write(", "); + emitParenthesizedIf(node.tag, needsParenthesisForPropertyAccessOrInvocation(node.tag)); + write("("); + emit(tempVariable); + if (node.template.kind === 183) { + ts.forEach(node.template.templateSpans, function (templateSpan) { + write(", "); + var needsParens = templateSpan.expression.kind === 181 + && templateSpan.expression.operatorToken.kind === 24; + emitParenthesizedIf(templateSpan.expression, needsParens); + }); + } + write("))"); + } + function emitTemplateExpression(node) { + if (languageVersion >= 2) { + ts.forEachChild(node, emit); + return; + } + var emitOuterParens = ts.isExpression(node.parent) + && templateNeedsParens(node, node.parent); + if (emitOuterParens) { + write("("); + } + var headEmitted = false; + if (shouldEmitTemplateHead()) { + emitLiteral(node.head); + headEmitted = true; + } + for (var i = 0, n = node.templateSpans.length; i < n; i++) { + var templateSpan = node.templateSpans[i]; + var needsParens = templateSpan.expression.kind !== 172 + && comparePrecedenceToBinaryPlus(templateSpan.expression) !== 1; + if (i > 0 || headEmitted) { + write(" + "); + } + emitParenthesizedIf(templateSpan.expression, needsParens); + if (templateSpan.literal.text.length !== 0) { + write(" + "); + emitLiteral(templateSpan.literal); + } + } + if (emitOuterParens) { + write(")"); + } + function shouldEmitTemplateHead() { + ts.Debug.assert(node.templateSpans.length !== 0); + return node.head.text.length !== 0 || node.templateSpans[0].literal.text.length === 0; + } + function templateNeedsParens(template, parent) { + switch (parent.kind) { + case 168: + case 169: + return parent.expression === template; + case 170: + case 172: + return false; + default: + return comparePrecedenceToBinaryPlus(parent) !== -1; + } + } + function comparePrecedenceToBinaryPlus(expression) { + switch (expression.kind) { + case 181: + switch (expression.operatorToken.kind) { + case 37: + case 39: + case 40: + return 1; + case 35: + case 36: + return 0; + default: + return -1; + } + case 184: + case 182: + return -1; + default: + return 1; + } + } + } + function emitTemplateSpan(span) { + emit(span.expression); + emit(span.literal); + } + function jsxEmitReact(node) { + function emitTagName(name) { + if (name.kind === 69 && ts.isIntrinsicJsxName(name.text)) { + write("\""); + emit(name); + write("\""); + } + else { + emit(name); + } + } + function emitAttributeName(name) { + if (/[A-Za-z_]+[\w*]/.test(name.text)) { + write("\""); + emit(name); + write("\""); + } + else { + emit(name); + } + } + function emitJsxAttribute(node) { + emitAttributeName(node.name); + write(": "); + if (node.initializer) { + emit(node.initializer); + } + else { + write("true"); + } + } + function emitJsxElement(openingNode, children) { + var syntheticReactRef = ts.createSynthesizedNode(69); + syntheticReactRef.text = "React"; + syntheticReactRef.parent = openingNode; + emitLeadingComments(openingNode); + emitExpressionIdentifier(syntheticReactRef); + write(".createElement("); + emitTagName(openingNode.tagName); + write(", "); + if (openingNode.attributes.length === 0) { + write("null"); + } + else { + var attrs = openingNode.attributes; + if (ts.forEach(attrs, function (attr) { return attr.kind === 239; })) { + emitExpressionIdentifier(syntheticReactRef); + write(".__spread("); + var haveOpenedObjectLiteral = false; + for (var i_1 = 0; i_1 < attrs.length; i_1++) { + if (attrs[i_1].kind === 239) { + if (i_1 === 0) { + write("{}, "); + } + if (haveOpenedObjectLiteral) { + write("}"); + haveOpenedObjectLiteral = false; + } + if (i_1 > 0) { + write(", "); + } + emit(attrs[i_1].expression); + } + else { + ts.Debug.assert(attrs[i_1].kind === 238); + if (haveOpenedObjectLiteral) { + write(", "); + } + else { + haveOpenedObjectLiteral = true; + if (i_1 > 0) { + write(", "); + } + write("{"); + } + emitJsxAttribute(attrs[i_1]); + } + } + if (haveOpenedObjectLiteral) + write("}"); + write(")"); + } + else { + write("{"); + for (var i = 0; i < attrs.length; i++) { + if (i > 0) { + write(", "); + } + emitJsxAttribute(attrs[i]); + } + write("}"); + } + } + if (children) { + for (var i = 0; i < children.length; i++) { + if (children[i].kind === 240 && !(children[i].expression)) { + continue; + } + if (children[i].kind === 236) { + var text = getTextToEmit(children[i]); + if (text !== undefined) { + write(", \""); + write(text); + write("\""); + } + } + else { + write(", "); + emit(children[i]); + } + } + } + write(")"); + emitTrailingComments(openingNode); + } + if (node.kind === 233) { + emitJsxElement(node.openingElement, node.children); + } + else { + ts.Debug.assert(node.kind === 234); + emitJsxElement(node); + } + } + function jsxEmitPreserve(node) { + function emitJsxAttribute(node) { + emit(node.name); + if (node.initializer) { + write("="); + emit(node.initializer); + } + } + function emitJsxSpreadAttribute(node) { + write("{..."); + emit(node.expression); + write("}"); + } + function emitAttributes(attribs) { + for (var i = 0, n = attribs.length; i < n; i++) { + if (i > 0) { + write(" "); + } + if (attribs[i].kind === 239) { + emitJsxSpreadAttribute(attribs[i]); + } + else { + ts.Debug.assert(attribs[i].kind === 238); + emitJsxAttribute(attribs[i]); + } + } + } + function emitJsxOpeningOrSelfClosingElement(node) { + write("<"); + emit(node.tagName); + if (node.attributes.length > 0 || (node.kind === 234)) { + write(" "); + } + emitAttributes(node.attributes); + if (node.kind === 234) { + write("/>"); + } + else { + write(">"); + } + } + function emitJsxClosingElement(node) { + write(""); + } + function emitJsxElement(node) { + emitJsxOpeningOrSelfClosingElement(node.openingElement); + for (var i = 0, n = node.children.length; i < n; i++) { + emit(node.children[i]); + } + emitJsxClosingElement(node.closingElement); + } + if (node.kind === 233) { + emitJsxElement(node); + } + else { + ts.Debug.assert(node.kind === 234); + emitJsxOpeningOrSelfClosingElement(node); + } + } + function emitExpressionForPropertyName(node) { + ts.Debug.assert(node.kind !== 163); + if (node.kind === 9) { + emitLiteral(node); + } + else if (node.kind === 136) { + if (ts.nodeIsDecorated(node.parent)) { + if (!computedPropertyNamesToGeneratedNames) { + computedPropertyNamesToGeneratedNames = []; + } + var generatedName = computedPropertyNamesToGeneratedNames[ts.getNodeId(node)]; + if (generatedName) { + write(generatedName); + return; + } + generatedName = createAndRecordTempVariable(0).text; + computedPropertyNamesToGeneratedNames[ts.getNodeId(node)] = generatedName; + write(generatedName); + write(" = "); + } + emit(node.expression); + } + else { + write("\""); + if (node.kind === 8) { + write(node.text); + } + else { + writeTextOfNode(currentSourceFile, node); + } + write("\""); + } + } + function isExpressionIdentifier(node) { + var parent = node.parent; + switch (parent.kind) { + case 164: + case 189: + case 181: + case 168: + case 241: + case 136: + case 182: + case 139: + case 175: + case 197: + case 167: + case 227: + case 195: + case 188: + case 199: + case 200: + case 201: + case 196: + case 234: + case 235: + case 239: + case 240: + case 169: + case 172: + case 180: + case 179: + case 204: + case 246: + case 185: + case 206: + case 170: + case 190: + case 208: + case 171: + case 176: + case 177: + case 198: + case 205: + case 184: + return true; + case 163: + case 247: + case 138: + case 245: + case 141: + case 211: + return parent.initializer === node; + case 166: + return parent.expression === node; + case 174: + case 173: + return parent.body === node; + case 221: + return parent.moduleReference === node; + case 135: + return parent.left === node; + } + return false; + } + function emitExpressionIdentifier(node) { + if (resolver.getNodeCheckFlags(node) & 2048) { + write("_arguments"); + return; + } + var container = resolver.getReferencedExportContainer(node); + if (container) { + if (container.kind === 248) { + if (modulekind !== 5 && modulekind !== 4) { + write("exports."); + } + } + else { + write(getGeneratedNameForNode(container)); + write("."); + } + } + else if (modulekind !== 5) { + var declaration = resolver.getReferencedImportDeclaration(node); + if (declaration) { + if (declaration.kind === 223) { + write(getGeneratedNameForNode(declaration.parent)); + write(languageVersion === 0 ? "[\"default\"]" : ".default"); + return; + } + else if (declaration.kind === 226) { + write(getGeneratedNameForNode(declaration.parent.parent.parent)); + var name_23 = declaration.propertyName || declaration.name; + var identifier = ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, name_23); + if (languageVersion === 0 && identifier === "default") { + write("[\"default\"]"); + } + else { + write("."); + write(identifier); + } + return; + } + } + declaration = resolver.getReferencedNestedRedeclaration(node); + if (declaration) { + write(getGeneratedNameForNode(declaration.name)); + return; + } + } + if (ts.nodeIsSynthesized(node)) { + write(node.text); + } + else { + writeTextOfNode(currentSourceFile, node); + } + } + function isNameOfNestedRedeclaration(node) { + if (languageVersion < 2) { + var parent_6 = node.parent; + switch (parent_6.kind) { + case 163: + case 214: + case 217: + case 211: + return parent_6.name === node && resolver.isNestedRedeclaration(parent_6); + } + } + return false; + } + function emitIdentifier(node) { + if (!node.parent) { + write(node.text); + } + else if (isExpressionIdentifier(node)) { + emitExpressionIdentifier(node); + } + else if (isNameOfNestedRedeclaration(node)) { + write(getGeneratedNameForNode(node)); + } + else if (ts.nodeIsSynthesized(node)) { + write(node.text); + } + else { + writeTextOfNode(currentSourceFile, node); + } + } + function emitThis(node) { + if (resolver.getNodeCheckFlags(node) & 2) { + write("_this"); + } + else { + write("this"); + } + } + function emitSuper(node) { + if (languageVersion >= 2) { + write("super"); + } + else { + var flags = resolver.getNodeCheckFlags(node); + if (flags & 256) { + write("_super.prototype"); + } + else { + write("_super"); + } + } + } + function emitObjectBindingPattern(node) { + write("{ "); + var elements = node.elements; + emitList(elements, 0, elements.length, false, elements.hasTrailingComma); + write(" }"); + } + function emitArrayBindingPattern(node) { + write("["); + var elements = node.elements; + emitList(elements, 0, elements.length, false, elements.hasTrailingComma); + write("]"); + } + function emitBindingElement(node) { + if (node.propertyName) { + emit(node.propertyName); + write(": "); + } + if (node.dotDotDotToken) { + write("..."); + } + if (ts.isBindingPattern(node.name)) { + emit(node.name); + } + else { + emitModuleMemberName(node); + } + emitOptional(" = ", node.initializer); + } + function emitSpreadElementExpression(node) { + write("..."); + emit(node.expression); + } + function emitYieldExpression(node) { + write(ts.tokenToString(114)); + if (node.asteriskToken) { + write("*"); + } + if (node.expression) { + write(" "); + emit(node.expression); + } + } + function emitAwaitExpression(node) { + var needsParenthesis = needsParenthesisForAwaitExpressionAsYield(node); + if (needsParenthesis) { + write("("); + } + write(ts.tokenToString(114)); + write(" "); + emit(node.expression); + if (needsParenthesis) { + write(")"); + } + } + function needsParenthesisForAwaitExpressionAsYield(node) { + if (node.parent.kind === 181 && !ts.isAssignmentOperator(node.parent.operatorToken.kind)) { + return true; + } + else if (node.parent.kind === 182 && node.parent.condition === node) { + return true; + } + return false; + } + function needsParenthesisForPropertyAccessOrInvocation(node) { + switch (node.kind) { + case 69: + case 164: + case 166: + case 167: + case 168: + case 172: + return false; + } + return true; + } + function emitListWithSpread(elements, needsUniqueCopy, multiLine, trailingComma, useConcat) { + var pos = 0; + var group = 0; + var length = elements.length; + while (pos < length) { + if (group === 1 && useConcat) { + write(".concat("); + } + else if (group > 0) { + write(", "); + } + var e = elements[pos]; + if (e.kind === 185) { + e = e.expression; + emitParenthesizedIf(e, group === 0 && needsParenthesisForPropertyAccessOrInvocation(e)); + pos++; + if (pos === length && group === 0 && needsUniqueCopy && e.kind !== 164) { + write(".slice()"); + } + } + else { + var i = pos; + while (i < length && elements[i].kind !== 185) { + i++; + } + write("["); + if (multiLine) { + increaseIndent(); + } + emitList(elements, pos, i - pos, multiLine, trailingComma && i === length); + if (multiLine) { + decreaseIndent(); + } + write("]"); + pos = i; + } + group++; + } + if (group > 1) { + if (useConcat) { + write(")"); + } + } + } + function isSpreadElementExpression(node) { + return node.kind === 185; + } + function emitArrayLiteral(node) { + var elements = node.elements; + if (elements.length === 0) { + write("[]"); + } + else if (languageVersion >= 2 || !ts.forEach(elements, isSpreadElementExpression)) { + write("["); + emitLinePreservingList(node, node.elements, elements.hasTrailingComma, false); + write("]"); + } + else { + emitListWithSpread(elements, true, (node.flags & 2048) !== 0, elements.hasTrailingComma, true); + } + } + function emitObjectLiteralBody(node, numElements) { + if (numElements === 0) { + write("{}"); + return; + } + write("{"); + if (numElements > 0) { + var properties = node.properties; + if (numElements === properties.length) { + emitLinePreservingList(node, properties, languageVersion >= 1, true); + } + else { + var multiLine = (node.flags & 2048) !== 0; + if (!multiLine) { + write(" "); + } + else { + increaseIndent(); + } + emitList(properties, 0, numElements, multiLine, false); + if (!multiLine) { + write(" "); + } + else { + decreaseIndent(); + } + } + } + write("}"); + } + function emitDownlevelObjectLiteralWithComputedProperties(node, firstComputedPropertyIndex) { + var multiLine = (node.flags & 2048) !== 0; + var properties = node.properties; + write("("); + if (multiLine) { + increaseIndent(); + } + var tempVar = createAndRecordTempVariable(0); + emit(tempVar); + write(" = "); + emitObjectLiteralBody(node, firstComputedPropertyIndex); + for (var i = firstComputedPropertyIndex, n = properties.length; i < n; i++) { + writeComma(); + var property = properties[i]; + emitStart(property); + if (property.kind === 145 || property.kind === 146) { + var accessors = ts.getAllAccessorDeclarations(node.properties, property); + if (property !== accessors.firstAccessor) { + continue; + } + write("Object.defineProperty("); + emit(tempVar); + write(", "); + emitStart(node.name); + emitExpressionForPropertyName(property.name); + emitEnd(property.name); + write(", {"); + increaseIndent(); + if (accessors.getAccessor) { + writeLine(); + emitLeadingComments(accessors.getAccessor); + write("get: "); + emitStart(accessors.getAccessor); + write("function "); + emitSignatureAndBody(accessors.getAccessor); + emitEnd(accessors.getAccessor); + emitTrailingComments(accessors.getAccessor); + write(","); + } + if (accessors.setAccessor) { + writeLine(); + emitLeadingComments(accessors.setAccessor); + write("set: "); + emitStart(accessors.setAccessor); + write("function "); + emitSignatureAndBody(accessors.setAccessor); + emitEnd(accessors.setAccessor); + emitTrailingComments(accessors.setAccessor); + write(","); + } + writeLine(); + write("enumerable: true,"); + writeLine(); + write("configurable: true"); + decreaseIndent(); + writeLine(); + write("})"); + emitEnd(property); + } + else { + emitLeadingComments(property); + emitStart(property.name); + emit(tempVar); + emitMemberAccessForPropertyName(property.name); + emitEnd(property.name); + write(" = "); + if (property.kind === 245) { + emit(property.initializer); + } + else if (property.kind === 246) { + emitExpressionIdentifier(property.name); + } + else if (property.kind === 143) { + emitFunctionDeclaration(property); + } + else { + ts.Debug.fail("ObjectLiteralElement type not accounted for: " + property.kind); + } + } + emitEnd(property); + } + writeComma(); + emit(tempVar); + if (multiLine) { + decreaseIndent(); + writeLine(); + } + write(")"); + function writeComma() { + if (multiLine) { + write(","); + writeLine(); + } + else { + write(", "); + } + } + } + function emitObjectLiteral(node) { + var properties = node.properties; + if (languageVersion < 2) { + var numProperties = properties.length; + var numInitialNonComputedProperties = numProperties; + for (var i = 0, n = properties.length; i < n; i++) { + if (properties[i].name.kind === 136) { + numInitialNonComputedProperties = i; + break; + } + } + var hasComputedProperty = numInitialNonComputedProperties !== properties.length; + if (hasComputedProperty) { + emitDownlevelObjectLiteralWithComputedProperties(node, numInitialNonComputedProperties); + return; + } + } + emitObjectLiteralBody(node, properties.length); + } + function createBinaryExpression(left, operator, right, startsOnNewLine) { + var result = ts.createSynthesizedNode(181, startsOnNewLine); + result.operatorToken = ts.createSynthesizedNode(operator); + result.left = left; + result.right = right; + return result; + } + function createPropertyAccessExpression(expression, name) { + var result = ts.createSynthesizedNode(166); + result.expression = parenthesizeForAccess(expression); + result.dotToken = ts.createSynthesizedNode(21); + result.name = name; + return result; + } + function createElementAccessExpression(expression, argumentExpression) { + var result = ts.createSynthesizedNode(167); + result.expression = parenthesizeForAccess(expression); + result.argumentExpression = argumentExpression; + return result; + } + function parenthesizeForAccess(expr) { + while (expr.kind === 171 || expr.kind === 189) { + expr = expr.expression; + } + if (ts.isLeftHandSideExpression(expr) && + expr.kind !== 169 && + expr.kind !== 8) { + return expr; + } + var node = ts.createSynthesizedNode(172); + node.expression = expr; + return node; + } + function emitComputedPropertyName(node) { + write("["); + emitExpressionForPropertyName(node); + write("]"); + } + function emitMethod(node) { + if (languageVersion >= 2 && node.asteriskToken) { + write("*"); + } + emit(node.name); + if (languageVersion < 2) { + write(": function "); + } + emitSignatureAndBody(node); + } + function emitPropertyAssignment(node) { + emit(node.name); + write(": "); + emitTrailingCommentsOfPosition(node.initializer.pos); + emit(node.initializer); + } + function isNamespaceExportReference(node) { + var container = resolver.getReferencedExportContainer(node); + return container && container.kind !== 248; + } + function emitShorthandPropertyAssignment(node) { + writeTextOfNode(currentSourceFile, node.name); + if (languageVersion < 2 || isNamespaceExportReference(node.name)) { + write(": "); + emit(node.name); + } + if (languageVersion >= 2 && node.objectAssignmentInitializer) { + write(" = "); + emit(node.objectAssignmentInitializer); + } + } + function tryEmitConstantValue(node) { + var constantValue = tryGetConstEnumValue(node); + if (constantValue !== undefined) { + write(constantValue.toString()); + if (!compilerOptions.removeComments) { + var propertyName = node.kind === 166 ? ts.declarationNameToString(node.name) : ts.getTextOfNode(node.argumentExpression); + write(" /* " + propertyName + " */"); + } + return true; + } + return false; + } + function tryGetConstEnumValue(node) { + if (compilerOptions.isolatedModules) { + return undefined; + } + return node.kind === 166 || node.kind === 167 + ? resolver.getConstantValue(node) + : undefined; + } + function indentIfOnDifferentLines(parent, node1, node2, valueToWriteWhenNotIndenting) { + var realNodesAreOnDifferentLines = !ts.nodeIsSynthesized(parent) && !nodeEndIsOnSameLineAsNodeStart(node1, node2); + var synthesizedNodeIsOnDifferentLine = synthesizedNodeStartsOnNewLine(node2); + if (realNodesAreOnDifferentLines || synthesizedNodeIsOnDifferentLine) { + increaseIndent(); + writeLine(); + return true; + } + else { + if (valueToWriteWhenNotIndenting) { + write(valueToWriteWhenNotIndenting); + } + return false; + } + } + function emitPropertyAccess(node) { + if (tryEmitConstantValue(node)) { + return; + } + emit(node.expression); + var indentedBeforeDot = indentIfOnDifferentLines(node, node.expression, node.dotToken); + var shouldEmitSpace; + if (!indentedBeforeDot) { + if (node.expression.kind === 8) { + var text = ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, node.expression); + shouldEmitSpace = text.indexOf(ts.tokenToString(21)) < 0; + } + else { + var constantValue = tryGetConstEnumValue(node.expression); + shouldEmitSpace = isFinite(constantValue) && Math.floor(constantValue) === constantValue; + } + } + if (shouldEmitSpace) { + write(" ."); + } + else { + write("."); + } + var indentedAfterDot = indentIfOnDifferentLines(node, node.dotToken, node.name); + emit(node.name); + decreaseIndentIf(indentedBeforeDot, indentedAfterDot); + } + function emitQualifiedName(node) { + emit(node.left); + write("."); + emit(node.right); + } + function emitQualifiedNameAsExpression(node, useFallback) { + if (node.left.kind === 69) { + emitEntityNameAsExpression(node.left, useFallback); + } + else if (useFallback) { + var temp = createAndRecordTempVariable(0); + write("("); + emitNodeWithoutSourceMap(temp); + write(" = "); + emitEntityNameAsExpression(node.left, true); + write(") && "); + emitNodeWithoutSourceMap(temp); + } + else { + emitEntityNameAsExpression(node.left, false); + } + write("."); + emit(node.right); + } + function emitEntityNameAsExpression(node, useFallback) { + switch (node.kind) { + case 69: + if (useFallback) { + write("typeof "); + emitExpressionIdentifier(node); + write(" !== 'undefined' && "); + } + emitExpressionIdentifier(node); + break; + case 135: + emitQualifiedNameAsExpression(node, useFallback); + break; + } + } + function emitIndexedAccess(node) { + if (tryEmitConstantValue(node)) { + return; + } + emit(node.expression); + write("["); + emit(node.argumentExpression); + write("]"); + } + function hasSpreadElement(elements) { + return ts.forEach(elements, function (e) { return e.kind === 185; }); + } + function skipParentheses(node) { + while (node.kind === 172 || node.kind === 171 || node.kind === 189) { + node = node.expression; + } + return node; + } + function emitCallTarget(node) { + if (node.kind === 69 || node.kind === 97 || node.kind === 95) { + emit(node); + return node; + } + var temp = createAndRecordTempVariable(0); + write("("); + emit(temp); + write(" = "); + emit(node); + write(")"); + return temp; + } + function emitCallWithSpread(node) { + var target; + var expr = skipParentheses(node.expression); + if (expr.kind === 166) { + target = emitCallTarget(expr.expression); + write("."); + emit(expr.name); + } + else if (expr.kind === 167) { + target = emitCallTarget(expr.expression); + write("["); + emit(expr.argumentExpression); + write("]"); + } + else if (expr.kind === 95) { + target = expr; + write("_super"); + } + else { + emit(node.expression); + } + write(".apply("); + if (target) { + if (target.kind === 95) { + emitThis(target); + } + else { + emit(target); + } + } + else { + write("void 0"); + } + write(", "); + emitListWithSpread(node.arguments, false, false, false, true); + write(")"); + } + function emitCallExpression(node) { + if (languageVersion < 2 && hasSpreadElement(node.arguments)) { + emitCallWithSpread(node); + return; + } + var superCall = false; + if (node.expression.kind === 95) { + emitSuper(node.expression); + superCall = true; + } + else { + emit(node.expression); + superCall = node.expression.kind === 166 && node.expression.expression.kind === 95; + } + if (superCall && languageVersion < 2) { + write(".call("); + emitThis(node.expression); + if (node.arguments.length) { + write(", "); + emitCommaList(node.arguments); + } + write(")"); + } + else { + write("("); + emitCommaList(node.arguments); + write(")"); + } + } + function emitNewExpression(node) { + write("new "); + if (languageVersion === 1 && + node.arguments && + hasSpreadElement(node.arguments)) { + write("("); + var target = emitCallTarget(node.expression); + write(".bind.apply("); + emit(target); + write(", [void 0].concat("); + emitListWithSpread(node.arguments, false, false, false, false); + write(")))"); + write("()"); + } + else { + emit(node.expression); + if (node.arguments) { + write("("); + emitCommaList(node.arguments); + write(")"); + } + } + } + function emitTaggedTemplateExpression(node) { + if (languageVersion >= 2) { + emit(node.tag); + write(" "); + emit(node.template); + } + else { + emitDownlevelTaggedTemplate(node); + } + } + function emitParenExpression(node) { + if (!ts.nodeIsSynthesized(node) && node.parent.kind !== 174) { + if (node.expression.kind === 171 || node.expression.kind === 189) { + var operand = node.expression.expression; + while (operand.kind === 171 || operand.kind === 189) { + operand = operand.expression; + } + if (operand.kind !== 179 && + operand.kind !== 177 && + operand.kind !== 176 && + operand.kind !== 175 && + operand.kind !== 180 && + operand.kind !== 169 && + !(operand.kind === 168 && node.parent.kind === 169) && + !(operand.kind === 173 && node.parent.kind === 168) && + !(operand.kind === 8 && node.parent.kind === 166)) { + emit(operand); + return; + } + } + } + write("("); + emit(node.expression); + write(")"); + } + function emitDeleteExpression(node) { + write(ts.tokenToString(78)); + write(" "); + emit(node.expression); + } + function emitVoidExpression(node) { + write(ts.tokenToString(103)); + write(" "); + emit(node.expression); + } + function emitTypeOfExpression(node) { + write(ts.tokenToString(101)); + write(" "); + emit(node.expression); + } + function isNameOfExportedSourceLevelDeclarationInSystemExternalModule(node) { + if (!isCurrentFileSystemExternalModule() || node.kind !== 69 || ts.nodeIsSynthesized(node)) { + return false; + } + var isVariableDeclarationOrBindingElement = node.parent && (node.parent.kind === 211 || node.parent.kind === 163); + var targetDeclaration = isVariableDeclarationOrBindingElement + ? node.parent + : resolver.getReferencedValueDeclaration(node); + return isSourceFileLevelDeclarationInSystemJsModule(targetDeclaration, true); + } + function emitPrefixUnaryExpression(node) { + var exportChanged = isNameOfExportedSourceLevelDeclarationInSystemExternalModule(node.operand); + if (exportChanged) { + write(exportFunctionForFile + "(\""); + emitNodeWithoutSourceMap(node.operand); + write("\", "); + } + write(ts.tokenToString(node.operator)); + if (node.operand.kind === 179) { + var operand = node.operand; + if (node.operator === 35 && (operand.operator === 35 || operand.operator === 41)) { + write(" "); + } + else if (node.operator === 36 && (operand.operator === 36 || operand.operator === 42)) { + write(" "); + } + } + emit(node.operand); + if (exportChanged) { + write(")"); + } + } + function emitPostfixUnaryExpression(node) { + var exportChanged = isNameOfExportedSourceLevelDeclarationInSystemExternalModule(node.operand); + if (exportChanged) { + write("(" + exportFunctionForFile + "(\""); + emitNodeWithoutSourceMap(node.operand); + write("\", "); + write(ts.tokenToString(node.operator)); + emit(node.operand); + if (node.operator === 41) { + write(") - 1)"); + } + else { + write(") + 1)"); + } + } + else { + emit(node.operand); + write(ts.tokenToString(node.operator)); + } + } + function shouldHoistDeclarationInSystemJsModule(node) { + return isSourceFileLevelDeclarationInSystemJsModule(node, false); + } + function isSourceFileLevelDeclarationInSystemJsModule(node, isExported) { + if (!node || languageVersion >= 2 || !isCurrentFileSystemExternalModule()) { + return false; + } + var current = node; + while (current) { + if (current.kind === 248) { + return !isExported || ((ts.getCombinedNodeFlags(node) & 1) !== 0); + } + else if (ts.isFunctionLike(current) || current.kind === 219) { + return false; + } + else { + current = current.parent; + } + } + } + function emitExponentiationOperator(node) { + var leftHandSideExpression = node.left; + if (node.operatorToken.kind === 60) { + var synthesizedLHS; + var shouldEmitParentheses = false; + if (ts.isElementAccessExpression(leftHandSideExpression)) { + shouldEmitParentheses = true; + write("("); + synthesizedLHS = ts.createSynthesizedNode(167, false); + var identifier = emitTempVariableAssignment(leftHandSideExpression.expression, false, false); + synthesizedLHS.expression = identifier; + if (leftHandSideExpression.argumentExpression.kind !== 8 && + leftHandSideExpression.argumentExpression.kind !== 9) { + var tempArgumentExpression = createAndRecordTempVariable(268435456); + synthesizedLHS.argumentExpression = tempArgumentExpression; + emitAssignment(tempArgumentExpression, leftHandSideExpression.argumentExpression, true); + } + else { + synthesizedLHS.argumentExpression = leftHandSideExpression.argumentExpression; + } + write(", "); + } + else if (ts.isPropertyAccessExpression(leftHandSideExpression)) { + shouldEmitParentheses = true; + write("("); + synthesizedLHS = ts.createSynthesizedNode(166, false); + var identifier = emitTempVariableAssignment(leftHandSideExpression.expression, false, false); + synthesizedLHS.expression = identifier; + synthesizedLHS.dotToken = leftHandSideExpression.dotToken; + synthesizedLHS.name = leftHandSideExpression.name; + write(", "); + } + emit(synthesizedLHS || leftHandSideExpression); + write(" = "); + write("Math.pow("); + emit(synthesizedLHS || leftHandSideExpression); + write(", "); + emit(node.right); + write(")"); + if (shouldEmitParentheses) { + write(")"); + } + } + else { + write("Math.pow("); + emit(leftHandSideExpression); + write(", "); + emit(node.right); + write(")"); + } + } + function emitBinaryExpression(node) { + if (languageVersion < 2 && node.operatorToken.kind === 56 && + (node.left.kind === 165 || node.left.kind === 164)) { + emitDestructuring(node, node.parent.kind === 195); + } + else { + var exportChanged = node.operatorToken.kind >= 56 && + node.operatorToken.kind <= 68 && + isNameOfExportedSourceLevelDeclarationInSystemExternalModule(node.left); + if (exportChanged) { + write(exportFunctionForFile + "(\""); + emitNodeWithoutSourceMap(node.left); + write("\", "); + } + if (node.operatorToken.kind === 38 || node.operatorToken.kind === 60) { + emitExponentiationOperator(node); + } + else { + emit(node.left); + var indentedBeforeOperator = indentIfOnDifferentLines(node, node.left, node.operatorToken, node.operatorToken.kind !== 24 ? " " : undefined); + write(ts.tokenToString(node.operatorToken.kind)); + var indentedAfterOperator = indentIfOnDifferentLines(node, node.operatorToken, node.right, " "); + emit(node.right); + decreaseIndentIf(indentedBeforeOperator, indentedAfterOperator); + } + if (exportChanged) { + write(")"); + } + } + } + function synthesizedNodeStartsOnNewLine(node) { + return ts.nodeIsSynthesized(node) && node.startsOnNewLine; + } + function emitConditionalExpression(node) { + emit(node.condition); + var indentedBeforeQuestion = indentIfOnDifferentLines(node, node.condition, node.questionToken, " "); + write("?"); + var indentedAfterQuestion = indentIfOnDifferentLines(node, node.questionToken, node.whenTrue, " "); + emit(node.whenTrue); + decreaseIndentIf(indentedBeforeQuestion, indentedAfterQuestion); + var indentedBeforeColon = indentIfOnDifferentLines(node, node.whenTrue, node.colonToken, " "); + write(":"); + var indentedAfterColon = indentIfOnDifferentLines(node, node.colonToken, node.whenFalse, " "); + emit(node.whenFalse); + decreaseIndentIf(indentedBeforeColon, indentedAfterColon); + } + function decreaseIndentIf(value1, value2) { + if (value1) { + decreaseIndent(); + } + if (value2) { + decreaseIndent(); + } + } + function isSingleLineEmptyBlock(node) { + if (node && node.kind === 192) { + var block = node; + return block.statements.length === 0 && nodeEndIsOnSameLineAsNodeStart(block, block); + } + } + function emitBlock(node) { + if (isSingleLineEmptyBlock(node)) { + emitToken(15, node.pos); + write(" "); + emitToken(16, node.statements.end); + return; + } + emitToken(15, node.pos); + increaseIndent(); + scopeEmitStart(node.parent); + if (node.kind === 219) { + ts.Debug.assert(node.parent.kind === 218); + emitCaptureThisForNodeIfNecessary(node.parent); + } + emitLines(node.statements); + if (node.kind === 219) { + emitTempDeclarations(true); + } + decreaseIndent(); + writeLine(); + emitToken(16, node.statements.end); + scopeEmitEnd(); + } + function emitEmbeddedStatement(node) { + if (node.kind === 192) { + write(" "); + emit(node); + } + else { + increaseIndent(); + writeLine(); + emit(node); + decreaseIndent(); + } + } + function emitExpressionStatement(node) { + emitParenthesizedIf(node.expression, node.expression.kind === 174); + write(";"); + } + function emitIfStatement(node) { + var endPos = emitToken(88, node.pos); + write(" "); + endPos = emitToken(17, endPos); + emit(node.expression); + emitToken(18, node.expression.end); + emitEmbeddedStatement(node.thenStatement); + if (node.elseStatement) { + writeLine(); + emitToken(80, node.thenStatement.end); + if (node.elseStatement.kind === 196) { + write(" "); + emit(node.elseStatement); + } + else { + emitEmbeddedStatement(node.elseStatement); + } + } + } + function emitDoStatement(node) { + write("do"); + emitEmbeddedStatement(node.statement); + if (node.statement.kind === 192) { + write(" "); + } + else { + writeLine(); + } + write("while ("); + emit(node.expression); + write(");"); + } + function emitWhileStatement(node) { + write("while ("); + emit(node.expression); + write(")"); + emitEmbeddedStatement(node.statement); + } + function tryEmitStartOfVariableDeclarationList(decl, startPos) { + if (shouldHoistVariable(decl, true)) { + return false; + } + var tokenKind = 102; + if (decl && languageVersion >= 2) { + if (ts.isLet(decl)) { + tokenKind = 108; + } + else if (ts.isConst(decl)) { + tokenKind = 74; + } + } + if (startPos !== undefined) { + emitToken(tokenKind, startPos); + write(" "); + } + else { + switch (tokenKind) { + case 102: + write("var "); + break; + case 108: + write("let "); + break; + case 74: + write("const "); + break; + } + } + return true; + } + function emitVariableDeclarationListSkippingUninitializedEntries(list) { + var started = false; + for (var _a = 0, _b = list.declarations; _a < _b.length; _a++) { + var decl = _b[_a]; + if (!decl.initializer) { + continue; + } + if (!started) { + started = true; + } + else { + write(", "); + } + emit(decl); + } + return started; + } + function emitForStatement(node) { + var endPos = emitToken(86, node.pos); + write(" "); + endPos = emitToken(17, endPos); + if (node.initializer && node.initializer.kind === 212) { + var variableDeclarationList = node.initializer; + var startIsEmitted = tryEmitStartOfVariableDeclarationList(variableDeclarationList, endPos); + if (startIsEmitted) { + emitCommaList(variableDeclarationList.declarations); + } + else { + emitVariableDeclarationListSkippingUninitializedEntries(variableDeclarationList); + } + } + else if (node.initializer) { + emit(node.initializer); + } + write(";"); + emitOptional(" ", node.condition); + write(";"); + emitOptional(" ", node.incrementor); + write(")"); + emitEmbeddedStatement(node.statement); + } + function emitForInOrForOfStatement(node) { + if (languageVersion < 2 && node.kind === 201) { + return emitDownLevelForOfStatement(node); + } + var endPos = emitToken(86, node.pos); + write(" "); + endPos = emitToken(17, endPos); + if (node.initializer.kind === 212) { + var variableDeclarationList = node.initializer; + if (variableDeclarationList.declarations.length >= 1) { + tryEmitStartOfVariableDeclarationList(variableDeclarationList, endPos); + emit(variableDeclarationList.declarations[0]); + } + } + else { + emit(node.initializer); + } + if (node.kind === 200) { + write(" in "); + } + else { + write(" of "); + } + emit(node.expression); + emitToken(18, node.expression.end); + emitEmbeddedStatement(node.statement); + } + function emitDownLevelForOfStatement(node) { + var endPos = emitToken(86, node.pos); + write(" "); + endPos = emitToken(17, endPos); + var rhsIsIdentifier = node.expression.kind === 69; + var counter = createTempVariable(268435456); + var rhsReference = rhsIsIdentifier ? node.expression : createTempVariable(0); + emitStart(node.expression); + write("var "); + emitNodeWithoutSourceMap(counter); + write(" = 0"); + emitEnd(node.expression); + if (!rhsIsIdentifier) { + write(", "); + emitStart(node.expression); + emitNodeWithoutSourceMap(rhsReference); + write(" = "); + emitNodeWithoutSourceMap(node.expression); + emitEnd(node.expression); + } + write("; "); + emitStart(node.initializer); + emitNodeWithoutSourceMap(counter); + write(" < "); + emitNodeWithCommentsAndWithoutSourcemap(rhsReference); + write(".length"); + emitEnd(node.initializer); + write("; "); + emitStart(node.initializer); + emitNodeWithoutSourceMap(counter); + write("++"); + emitEnd(node.initializer); + emitToken(18, node.expression.end); + write(" {"); + writeLine(); + increaseIndent(); + var rhsIterationValue = createElementAccessExpression(rhsReference, counter); + emitStart(node.initializer); + if (node.initializer.kind === 212) { + write("var "); + var variableDeclarationList = node.initializer; + if (variableDeclarationList.declarations.length > 0) { + var declaration = variableDeclarationList.declarations[0]; + if (ts.isBindingPattern(declaration.name)) { + emitDestructuring(declaration, false, rhsIterationValue); + } + else { + emitNodeWithCommentsAndWithoutSourcemap(declaration); + write(" = "); + emitNodeWithoutSourceMap(rhsIterationValue); + } + } + else { + emitNodeWithoutSourceMap(createTempVariable(0)); + write(" = "); + emitNodeWithoutSourceMap(rhsIterationValue); + } + } + else { + var assignmentExpression = createBinaryExpression(node.initializer, 56, rhsIterationValue, false); + if (node.initializer.kind === 164 || node.initializer.kind === 165) { + emitDestructuring(assignmentExpression, true, undefined); + } + else { + emitNodeWithCommentsAndWithoutSourcemap(assignmentExpression); + } + } + emitEnd(node.initializer); + write(";"); + if (node.statement.kind === 192) { + emitLines(node.statement.statements); + } + else { + writeLine(); + emit(node.statement); + } + writeLine(); + decreaseIndent(); + write("}"); + } + function emitBreakOrContinueStatement(node) { + emitToken(node.kind === 203 ? 70 : 75, node.pos); + emitOptional(" ", node.label); + write(";"); + } + function emitReturnStatement(node) { + emitToken(94, node.pos); + emitOptional(" ", node.expression); + write(";"); + } + function emitWithStatement(node) { + write("with ("); + emit(node.expression); + write(")"); + emitEmbeddedStatement(node.statement); + } + function emitSwitchStatement(node) { + var endPos = emitToken(96, node.pos); + write(" "); + emitToken(17, endPos); + emit(node.expression); + endPos = emitToken(18, node.expression.end); + write(" "); + emitCaseBlock(node.caseBlock, endPos); + } + function emitCaseBlock(node, startPos) { + emitToken(15, startPos); + increaseIndent(); + emitLines(node.clauses); + decreaseIndent(); + writeLine(); + emitToken(16, node.clauses.end); + } + function nodeStartPositionsAreOnSameLine(node1, node2) { + return ts.getLineOfLocalPosition(currentSourceFile, ts.skipTrivia(currentSourceFile.text, node1.pos)) === + ts.getLineOfLocalPosition(currentSourceFile, ts.skipTrivia(currentSourceFile.text, node2.pos)); + } + function nodeEndPositionsAreOnSameLine(node1, node2) { + return ts.getLineOfLocalPosition(currentSourceFile, node1.end) === + ts.getLineOfLocalPosition(currentSourceFile, node2.end); + } + function nodeEndIsOnSameLineAsNodeStart(node1, node2) { + return ts.getLineOfLocalPosition(currentSourceFile, node1.end) === + ts.getLineOfLocalPosition(currentSourceFile, ts.skipTrivia(currentSourceFile.text, node2.pos)); + } + function emitCaseOrDefaultClause(node) { + if (node.kind === 241) { + write("case "); + emit(node.expression); + write(":"); + } + else { + write("default:"); + } + if (node.statements.length === 1 && nodeStartPositionsAreOnSameLine(node, node.statements[0])) { + write(" "); + emit(node.statements[0]); + } + else { + increaseIndent(); + emitLines(node.statements); + decreaseIndent(); + } + } + function emitThrowStatement(node) { + write("throw "); + emit(node.expression); + write(";"); + } + function emitTryStatement(node) { + write("try "); + emit(node.tryBlock); + emit(node.catchClause); + if (node.finallyBlock) { + writeLine(); + write("finally "); + emit(node.finallyBlock); + } + } + function emitCatchClause(node) { + writeLine(); + var endPos = emitToken(72, node.pos); + write(" "); + emitToken(17, endPos); + emit(node.variableDeclaration); + emitToken(18, node.variableDeclaration ? node.variableDeclaration.end : endPos); + write(" "); + emitBlock(node.block); + } + function emitDebuggerStatement(node) { + emitToken(76, node.pos); + write(";"); + } + function emitLabelledStatement(node) { + emit(node.label); + write(": "); + emit(node.statement); + } + function getContainingModule(node) { + do { + node = node.parent; + } while (node && node.kind !== 218); + return node; + } + function emitContainingModuleName(node) { + var container = getContainingModule(node); + write(container ? getGeneratedNameForNode(container) : "exports"); + } + function emitModuleMemberName(node) { + emitStart(node.name); + if (ts.getCombinedNodeFlags(node) & 1) { + var container = getContainingModule(node); + if (container) { + write(getGeneratedNameForNode(container)); + write("."); + } + else if (modulekind !== 5 && modulekind !== 4) { + write("exports."); + } + } + emitNodeWithCommentsAndWithoutSourcemap(node.name); + emitEnd(node.name); + } + function createVoidZero() { + var zero = ts.createSynthesizedNode(8); + zero.text = "0"; + var result = ts.createSynthesizedNode(177); + result.expression = zero; + return result; + } + function emitEs6ExportDefaultCompat(node) { + if (node.parent.kind === 248) { + ts.Debug.assert(!!(node.flags & 1024) || node.kind === 227); + if (modulekind === 1 || modulekind === 2 || modulekind === 3) { + if (!currentSourceFile.symbol.exports["___esModule"]) { + if (languageVersion === 1) { + write("Object.defineProperty(exports, \"__esModule\", { value: true });"); + writeLine(); + } + else if (languageVersion === 0) { + write("exports.__esModule = true;"); + writeLine(); + } + } + } + } + } + function emitExportMemberAssignment(node) { + if (node.flags & 1) { + writeLine(); + emitStart(node); + if (modulekind === 4 && node.parent === currentSourceFile) { + write(exportFunctionForFile + "(\""); + if (node.flags & 1024) { + write("default"); + } + else { + emitNodeWithCommentsAndWithoutSourcemap(node.name); + } + write("\", "); + emitDeclarationName(node); + write(")"); + } + else { + if (node.flags & 1024) { + emitEs6ExportDefaultCompat(node); + if (languageVersion === 0) { + write("exports[\"default\"]"); + } + else { + write("exports.default"); + } + } + else { + emitModuleMemberName(node); + } + write(" = "); + emitDeclarationName(node); + } + emitEnd(node); + write(";"); + } + } + function emitExportMemberAssignments(name) { + if (modulekind === 4) { + return; + } + if (!exportEquals && exportSpecifiers && ts.hasProperty(exportSpecifiers, name.text)) { + for (var _a = 0, _b = exportSpecifiers[name.text]; _a < _b.length; _a++) { + var specifier = _b[_a]; + writeLine(); + emitStart(specifier.name); + emitContainingModuleName(specifier); + write("."); + emitNodeWithCommentsAndWithoutSourcemap(specifier.name); + emitEnd(specifier.name); + write(" = "); + emitExpressionIdentifier(name); + write(";"); + } + } + } + function emitExportSpecifierInSystemModule(specifier) { + ts.Debug.assert(modulekind === 4); + if (!resolver.getReferencedValueDeclaration(specifier.propertyName || specifier.name) && !resolver.isValueAliasDeclaration(specifier)) { + return; + } + writeLine(); + emitStart(specifier.name); + write(exportFunctionForFile + "(\""); + emitNodeWithCommentsAndWithoutSourcemap(specifier.name); + write("\", "); + emitExpressionIdentifier(specifier.propertyName || specifier.name); + write(")"); + emitEnd(specifier.name); + write(";"); + } + function emitAssignment(name, value, shouldEmitCommaBeforeAssignment) { + if (shouldEmitCommaBeforeAssignment) { + write(", "); + } + var exportChanged = isNameOfExportedSourceLevelDeclarationInSystemExternalModule(name); + if (exportChanged) { + write(exportFunctionForFile + "(\""); + emitNodeWithCommentsAndWithoutSourcemap(name); + write("\", "); + } + var isVariableDeclarationOrBindingElement = name.parent && (name.parent.kind === 211 || name.parent.kind === 163); + if (isVariableDeclarationOrBindingElement) { + emitModuleMemberName(name.parent); + } + else { + emit(name); + } + write(" = "); + emit(value); + if (exportChanged) { + write(")"); + } + } + function emitTempVariableAssignment(expression, canDefineTempVariablesInPlace, shouldEmitCommaBeforeAssignment) { + var identifier = createTempVariable(0); + if (!canDefineTempVariablesInPlace) { + recordTempDeclaration(identifier); + } + emitAssignment(identifier, expression, shouldEmitCommaBeforeAssignment); + return identifier; + } + function emitDestructuring(root, isAssignmentExpressionStatement, value) { + var emitCount = 0; + var canDefineTempVariablesInPlace = false; + if (root.kind === 211) { + var isExported = ts.getCombinedNodeFlags(root) & 1; + var isSourceLevelForSystemModuleKind = shouldHoistDeclarationInSystemJsModule(root); + canDefineTempVariablesInPlace = !isExported && !isSourceLevelForSystemModuleKind; + } + else if (root.kind === 138) { + canDefineTempVariablesInPlace = true; + } + if (root.kind === 181) { + emitAssignmentExpression(root); + } + else { + ts.Debug.assert(!isAssignmentExpressionStatement); + emitBindingElement(root, value); + } + function ensureIdentifier(expr, reuseIdentifierExpressions) { + if (expr.kind === 69 && reuseIdentifierExpressions) { + return expr; + } + var identifier = emitTempVariableAssignment(expr, canDefineTempVariablesInPlace, emitCount > 0); + emitCount++; + return identifier; + } + function createDefaultValueCheck(value, defaultValue) { + value = ensureIdentifier(value, true); + var equals = ts.createSynthesizedNode(181); + equals.left = value; + equals.operatorToken = ts.createSynthesizedNode(32); + equals.right = createVoidZero(); + return createConditionalExpression(equals, defaultValue, value); + } + function createConditionalExpression(condition, whenTrue, whenFalse) { + var cond = ts.createSynthesizedNode(182); + cond.condition = condition; + cond.questionToken = ts.createSynthesizedNode(53); + cond.whenTrue = whenTrue; + cond.colonToken = ts.createSynthesizedNode(54); + cond.whenFalse = whenFalse; + return cond; + } + function createNumericLiteral(value) { + var node = ts.createSynthesizedNode(8); + node.text = "" + value; + return node; + } + function createPropertyAccessForDestructuringProperty(object, propName) { + var syntheticName = ts.createSynthesizedNode(propName.kind); + syntheticName.text = propName.text; + if (syntheticName.kind !== 69) { + return createElementAccessExpression(object, syntheticName); + } + return createPropertyAccessExpression(object, syntheticName); + } + function createSliceCall(value, sliceIndex) { + var call = ts.createSynthesizedNode(168); + var sliceIdentifier = ts.createSynthesizedNode(69); + sliceIdentifier.text = "slice"; + call.expression = createPropertyAccessExpression(value, sliceIdentifier); + call.arguments = ts.createSynthesizedNodeArray(); + call.arguments[0] = createNumericLiteral(sliceIndex); + return call; + } + function emitObjectLiteralAssignment(target, value) { + var properties = target.properties; + if (properties.length !== 1) { + value = ensureIdentifier(value, true); + } + for (var _a = 0; _a < properties.length; _a++) { + var p = properties[_a]; + if (p.kind === 245 || p.kind === 246) { + var propName = p.name; + var target_1 = p.kind === 246 ? p : p.initializer || propName; + emitDestructuringAssignment(target_1, createPropertyAccessForDestructuringProperty(value, propName)); + } + } + } + function emitArrayLiteralAssignment(target, value) { + var elements = target.elements; + if (elements.length !== 1) { + value = ensureIdentifier(value, true); + } + for (var i = 0; i < elements.length; i++) { + var e = elements[i]; + if (e.kind !== 187) { + if (e.kind !== 185) { + emitDestructuringAssignment(e, createElementAccessExpression(value, createNumericLiteral(i))); + } + else if (i === elements.length - 1) { + emitDestructuringAssignment(e.expression, createSliceCall(value, i)); + } + } + } + } + function emitDestructuringAssignment(target, value) { + if (target.kind === 246) { + if (target.objectAssignmentInitializer) { + value = createDefaultValueCheck(value, target.objectAssignmentInitializer); + } + target = target.name; + } + else if (target.kind === 181 && target.operatorToken.kind === 56) { + value = createDefaultValueCheck(value, target.right); + target = target.left; + } + if (target.kind === 165) { + emitObjectLiteralAssignment(target, value); + } + else if (target.kind === 164) { + emitArrayLiteralAssignment(target, value); + } + else { + emitAssignment(target, value, emitCount > 0); + emitCount++; + } + } + function emitAssignmentExpression(root) { + var target = root.left; + var value = root.right; + if (ts.isEmptyObjectLiteralOrArrayLiteral(target)) { + emit(value); + } + else if (isAssignmentExpressionStatement) { + emitDestructuringAssignment(target, value); + } + else { + if (root.parent.kind !== 172) { + write("("); + } + value = ensureIdentifier(value, true); + emitDestructuringAssignment(target, value); + write(", "); + emit(value); + if (root.parent.kind !== 172) { + write(")"); + } + } + } + function emitBindingElement(target, value) { + if (target.initializer) { + value = value ? createDefaultValueCheck(value, target.initializer) : target.initializer; + } + else if (!value) { + value = createVoidZero(); + } + if (ts.isBindingPattern(target.name)) { + var pattern = target.name; + var elements = pattern.elements; + var numElements = elements.length; + if (numElements !== 1) { + value = ensureIdentifier(value, numElements !== 0); + } + for (var i = 0; i < numElements; i++) { + var element = elements[i]; + if (pattern.kind === 161) { + var propName = element.propertyName || element.name; + emitBindingElement(element, createPropertyAccessForDestructuringProperty(value, propName)); + } + else if (element.kind !== 187) { + if (!element.dotDotDotToken) { + emitBindingElement(element, createElementAccessExpression(value, createNumericLiteral(i))); + } + else if (i === numElements - 1) { + emitBindingElement(element, createSliceCall(value, i)); + } + } + } + } + else { + emitAssignment(target.name, value, emitCount > 0); + emitCount++; + } + } + } + function emitVariableDeclaration(node) { + if (ts.isBindingPattern(node.name)) { + if (languageVersion < 2) { + emitDestructuring(node, false); + } + else { + emit(node.name); + emitOptional(" = ", node.initializer); + } + } + else { + var initializer = node.initializer; + if (!initializer && languageVersion < 2) { + var isUninitializedLet = (resolver.getNodeCheckFlags(node) & 16384) && + (getCombinedFlagsForIdentifier(node.name) & 16384); + if (isUninitializedLet && + node.parent.parent.kind !== 200 && + node.parent.parent.kind !== 201) { + initializer = createVoidZero(); + } + } + var exportChanged = isNameOfExportedSourceLevelDeclarationInSystemExternalModule(node.name); + if (exportChanged) { + write(exportFunctionForFile + "(\""); + emitNodeWithCommentsAndWithoutSourcemap(node.name); + write("\", "); + } + emitModuleMemberName(node); + emitOptional(" = ", initializer); + if (exportChanged) { + write(")"); + } + } + } + function emitExportVariableAssignments(node) { + if (node.kind === 187) { + return; + } + var name = node.name; + if (name.kind === 69) { + emitExportMemberAssignments(name); + } + else if (ts.isBindingPattern(name)) { + ts.forEach(name.elements, emitExportVariableAssignments); + } + } + function getCombinedFlagsForIdentifier(node) { + if (!node.parent || (node.parent.kind !== 211 && node.parent.kind !== 163)) { + return 0; + } + return ts.getCombinedNodeFlags(node.parent); + } + function isES6ExportedDeclaration(node) { + return !!(node.flags & 1) && + modulekind === 5 && + node.parent.kind === 248; + } + function emitVariableStatement(node) { + var startIsEmitted = false; + if (node.flags & 1) { + if (isES6ExportedDeclaration(node)) { + write("export "); + startIsEmitted = tryEmitStartOfVariableDeclarationList(node.declarationList); + } + } + else { + startIsEmitted = tryEmitStartOfVariableDeclarationList(node.declarationList); + } + if (startIsEmitted) { + emitCommaList(node.declarationList.declarations); + write(";"); + } + else { + var atLeastOneItem = emitVariableDeclarationListSkippingUninitializedEntries(node.declarationList); + if (atLeastOneItem) { + write(";"); + } + } + if (modulekind !== 5 && node.parent === currentSourceFile) { + ts.forEach(node.declarationList.declarations, emitExportVariableAssignments); + } + } + function shouldEmitLeadingAndTrailingCommentsForVariableStatement(node) { + if (!(node.flags & 1)) { + return true; + } + if (isES6ExportedDeclaration(node)) { + return true; + } + for (var _a = 0, _b = node.declarationList.declarations; _a < _b.length; _a++) { + var declaration = _b[_a]; + if (declaration.initializer) { + return true; + } + } + return false; + } + function emitParameter(node) { + if (languageVersion < 2) { + if (ts.isBindingPattern(node.name)) { + var name_24 = createTempVariable(0); + if (!tempParameters) { + tempParameters = []; + } + tempParameters.push(name_24); + emit(name_24); + } + else { + emit(node.name); + } + } + else { + if (node.dotDotDotToken) { + write("..."); + } + emit(node.name); + emitOptional(" = ", node.initializer); + } + } + function emitDefaultValueAssignments(node) { + if (languageVersion < 2) { + var tempIndex = 0; + ts.forEach(node.parameters, function (parameter) { + if (parameter.dotDotDotToken) { + return; + } + var paramName = parameter.name, initializer = parameter.initializer; + if (ts.isBindingPattern(paramName)) { + var hasBindingElements = paramName.elements.length > 0; + if (hasBindingElements || initializer) { + writeLine(); + write("var "); + if (hasBindingElements) { + emitDestructuring(parameter, false, tempParameters[tempIndex]); + } + else { + emit(tempParameters[tempIndex]); + write(" = "); + emit(initializer); + } + write(";"); + tempIndex++; + } + } + else if (initializer) { + writeLine(); + emitStart(parameter); + write("if ("); + emitNodeWithoutSourceMap(paramName); + write(" === void 0)"); + emitEnd(parameter); + write(" { "); + emitStart(parameter); + emitNodeWithCommentsAndWithoutSourcemap(paramName); + write(" = "); + emitNodeWithCommentsAndWithoutSourcemap(initializer); + emitEnd(parameter); + write("; }"); + } + }); + } + } + function emitRestParameter(node) { + if (languageVersion < 2 && ts.hasRestParameter(node)) { + var restIndex = node.parameters.length - 1; + var restParam = node.parameters[restIndex]; + if (ts.isBindingPattern(restParam.name)) { + return; + } + var tempName = createTempVariable(268435456).text; + writeLine(); + emitLeadingComments(restParam); + emitStart(restParam); + write("var "); + emitNodeWithCommentsAndWithoutSourcemap(restParam.name); + write(" = [];"); + emitEnd(restParam); + emitTrailingComments(restParam); + writeLine(); + write("for ("); + emitStart(restParam); + write("var " + tempName + " = " + restIndex + ";"); + emitEnd(restParam); + write(" "); + emitStart(restParam); + write(tempName + " < arguments.length;"); + emitEnd(restParam); + write(" "); + emitStart(restParam); + write(tempName + "++"); + emitEnd(restParam); + write(") {"); + increaseIndent(); + writeLine(); + emitStart(restParam); + emitNodeWithCommentsAndWithoutSourcemap(restParam.name); + write("[" + tempName + " - " + restIndex + "] = arguments[" + tempName + "];"); + emitEnd(restParam); + decreaseIndent(); + writeLine(); + write("}"); + } + } + function emitAccessor(node) { + write(node.kind === 145 ? "get " : "set "); + emit(node.name); + emitSignatureAndBody(node); + } + function shouldEmitAsArrowFunction(node) { + return node.kind === 174 && languageVersion >= 2; + } + function emitDeclarationName(node) { + if (node.name) { + emitNodeWithCommentsAndWithoutSourcemap(node.name); + } + else { + write(getGeneratedNameForNode(node)); + } + } + function shouldEmitFunctionName(node) { + if (node.kind === 173) { + return !!node.name; + } + if (node.kind === 213) { + return !!node.name || languageVersion < 2; + } + } + function emitFunctionDeclaration(node) { + if (ts.nodeIsMissing(node.body)) { + return emitCommentsOnNotEmittedNode(node); + } + if (node.kind !== 143 && node.kind !== 142 && + node.parent && node.parent.kind !== 245 && + node.parent.kind !== 168) { + emitLeadingComments(node); + } + emitStart(node); + if (!shouldEmitAsArrowFunction(node)) { + if (isES6ExportedDeclaration(node)) { + write("export "); + if (node.flags & 1024) { + write("default "); + } + } + write("function"); + if (languageVersion >= 2 && node.asteriskToken) { + write("*"); + } + write(" "); + } + if (shouldEmitFunctionName(node)) { + emitDeclarationName(node); + } + emitSignatureAndBody(node); + if (modulekind !== 5 && node.kind === 213 && node.parent === currentSourceFile && node.name) { + emitExportMemberAssignments(node.name); + } + emitEnd(node); + if (node.kind !== 143 && node.kind !== 142) { + emitTrailingComments(node); + } + } + function emitCaptureThisForNodeIfNecessary(node) { + if (resolver.getNodeCheckFlags(node) & 4) { + writeLine(); + emitStart(node); + write("var _this = this;"); + emitEnd(node); + } + } + function emitSignatureParameters(node) { + increaseIndent(); + write("("); + if (node) { + var parameters = node.parameters; + var omitCount = languageVersion < 2 && ts.hasRestParameter(node) ? 1 : 0; + emitList(parameters, 0, parameters.length - omitCount, false, false); + } + write(")"); + decreaseIndent(); + } + function emitSignatureParametersForArrow(node) { + if (node.parameters.length === 1 && node.pos === node.parameters[0].pos) { + emit(node.parameters[0]); + return; + } + emitSignatureParameters(node); + } + function emitAsyncFunctionBodyForES6(node) { + var promiseConstructor = ts.getEntityNameFromTypeNode(node.type); + var isArrowFunction = node.kind === 174; + var hasLexicalArguments = (resolver.getNodeCheckFlags(node) & 4096) !== 0; + var args; + if (!isArrowFunction) { + write(" {"); + increaseIndent(); + writeLine(); + write("return"); + } + write(" __awaiter(this"); + if (hasLexicalArguments) { + write(", arguments"); + } + else { + write(", void 0"); + } + if (promiseConstructor) { + write(", "); + emitNodeWithoutSourceMap(promiseConstructor); + } + else { + write(", Promise"); + } + if (hasLexicalArguments) { + write(", function* (_arguments)"); + } + else { + write(", function* ()"); + } + emitFunctionBody(node); + write(")"); + if (!isArrowFunction) { + write(";"); + decreaseIndent(); + writeLine(); + write("}"); + } + } + function emitFunctionBody(node) { + if (!node.body) { + write(" { }"); + } + else { + if (node.body.kind === 192) { + emitBlockFunctionBody(node, node.body); + } + else { + emitExpressionFunctionBody(node, node.body); + } + } + } + function emitSignatureAndBody(node) { + var saveTempFlags = tempFlags; + var saveTempVariables = tempVariables; + var saveTempParameters = tempParameters; + tempFlags = 0; + tempVariables = undefined; + tempParameters = undefined; + if (shouldEmitAsArrowFunction(node)) { + emitSignatureParametersForArrow(node); + write(" =>"); + } + else { + emitSignatureParameters(node); + } + var isAsync = ts.isAsyncFunctionLike(node); + if (isAsync && languageVersion === 2) { + emitAsyncFunctionBodyForES6(node); + } + else { + emitFunctionBody(node); + } + if (!isES6ExportedDeclaration(node)) { + emitExportMemberAssignment(node); + } + tempFlags = saveTempFlags; + tempVariables = saveTempVariables; + tempParameters = saveTempParameters; + } + function emitFunctionBodyPreamble(node) { + emitCaptureThisForNodeIfNecessary(node); + emitDefaultValueAssignments(node); + emitRestParameter(node); + } + function emitExpressionFunctionBody(node, body) { + if (languageVersion < 2 || node.flags & 512) { + emitDownLevelExpressionFunctionBody(node, body); + return; + } + write(" "); + var current = body; + while (current.kind === 171) { + current = current.expression; + } + emitParenthesizedIf(body, current.kind === 165); + } + function emitDownLevelExpressionFunctionBody(node, body) { + write(" {"); + scopeEmitStart(node); + increaseIndent(); + var outPos = writer.getTextPos(); + emitDetachedComments(node.body); + emitFunctionBodyPreamble(node); + var preambleEmitted = writer.getTextPos() !== outPos; + decreaseIndent(); + if (!preambleEmitted && nodeStartPositionsAreOnSameLine(node, body)) { + write(" "); + emitStart(body); + write("return "); + emit(body); + emitEnd(body); + write(";"); + emitTempDeclarations(false); + write(" "); + } + else { + increaseIndent(); + writeLine(); + emitLeadingComments(node.body); + write("return "); + emit(body); + write(";"); + emitTrailingComments(node.body); + emitTempDeclarations(true); + decreaseIndent(); + writeLine(); + } + emitStart(node.body); + write("}"); + emitEnd(node.body); + scopeEmitEnd(); + } + function emitBlockFunctionBody(node, body) { + write(" {"); + scopeEmitStart(node); + var initialTextPos = writer.getTextPos(); + increaseIndent(); + emitDetachedComments(body.statements); + var startIndex = emitDirectivePrologues(body.statements, true); + emitFunctionBodyPreamble(node); + decreaseIndent(); + var preambleEmitted = writer.getTextPos() !== initialTextPos; + if (!preambleEmitted && nodeEndIsOnSameLineAsNodeStart(body, body)) { + for (var _a = 0, _b = body.statements; _a < _b.length; _a++) { + var statement = _b[_a]; + write(" "); + emit(statement); + } + emitTempDeclarations(false); + write(" "); + emitLeadingCommentsOfPosition(body.statements.end); + } + else { + increaseIndent(); + emitLinesStartingAt(body.statements, startIndex); + emitTempDeclarations(true); + writeLine(); + emitLeadingCommentsOfPosition(body.statements.end); + decreaseIndent(); + } + emitToken(16, body.statements.end); + scopeEmitEnd(); + } + function findInitialSuperCall(ctor) { + if (ctor.body) { + var statement = ctor.body.statements[0]; + if (statement && statement.kind === 195) { + var expr = statement.expression; + if (expr && expr.kind === 168) { + var func = expr.expression; + if (func && func.kind === 95) { + return statement; + } + } + } + } + } + function emitParameterPropertyAssignments(node) { + ts.forEach(node.parameters, function (param) { + if (param.flags & 112) { + writeLine(); + emitStart(param); + emitStart(param.name); + write("this."); + emitNodeWithoutSourceMap(param.name); + emitEnd(param.name); + write(" = "); + emit(param.name); + write(";"); + emitEnd(param); + } + }); + } + function emitMemberAccessForPropertyName(memberName) { + if (memberName.kind === 9 || memberName.kind === 8) { + write("["); + emitNodeWithCommentsAndWithoutSourcemap(memberName); + write("]"); + } + else if (memberName.kind === 136) { + emitComputedPropertyName(memberName); + } + else { + write("."); + emitNodeWithCommentsAndWithoutSourcemap(memberName); + } + } + function getInitializedProperties(node, isStatic) { + var properties = []; + for (var _a = 0, _b = node.members; _a < _b.length; _a++) { + var member = _b[_a]; + if (member.kind === 141 && isStatic === ((member.flags & 128) !== 0) && member.initializer) { + properties.push(member); + } + } + return properties; + } + function emitPropertyDeclarations(node, properties) { + for (var _a = 0; _a < properties.length; _a++) { + var property = properties[_a]; + emitPropertyDeclaration(node, property); + } + } + function emitPropertyDeclaration(node, property, receiver, isExpression) { + writeLine(); + emitLeadingComments(property); + emitStart(property); + emitStart(property.name); + if (receiver) { + emit(receiver); + } + else { + if (property.flags & 128) { + emitDeclarationName(node); + } + else { + write("this"); + } + } + emitMemberAccessForPropertyName(property.name); + emitEnd(property.name); + write(" = "); + emit(property.initializer); + if (!isExpression) { + write(";"); + } + emitEnd(property); + emitTrailingComments(property); + } + function emitMemberFunctionsForES5AndLower(node) { + ts.forEach(node.members, function (member) { + if (member.kind === 191) { + writeLine(); + write(";"); + } + else if (member.kind === 143 || node.kind === 142) { + if (!member.body) { + return emitCommentsOnNotEmittedNode(member); + } + writeLine(); + emitLeadingComments(member); + emitStart(member); + emitStart(member.name); + emitClassMemberPrefix(node, member); + emitMemberAccessForPropertyName(member.name); + emitEnd(member.name); + write(" = "); + emitFunctionDeclaration(member); + emitEnd(member); + write(";"); + emitTrailingComments(member); + } + else if (member.kind === 145 || member.kind === 146) { + var accessors = ts.getAllAccessorDeclarations(node.members, member); + if (member === accessors.firstAccessor) { + writeLine(); + emitStart(member); + write("Object.defineProperty("); + emitStart(member.name); + emitClassMemberPrefix(node, member); + write(", "); + emitExpressionForPropertyName(member.name); + emitEnd(member.name); + write(", {"); + increaseIndent(); + if (accessors.getAccessor) { + writeLine(); + emitLeadingComments(accessors.getAccessor); + write("get: "); + emitStart(accessors.getAccessor); + write("function "); + emitSignatureAndBody(accessors.getAccessor); + emitEnd(accessors.getAccessor); + emitTrailingComments(accessors.getAccessor); + write(","); + } + if (accessors.setAccessor) { + writeLine(); + emitLeadingComments(accessors.setAccessor); + write("set: "); + emitStart(accessors.setAccessor); + write("function "); + emitSignatureAndBody(accessors.setAccessor); + emitEnd(accessors.setAccessor); + emitTrailingComments(accessors.setAccessor); + write(","); + } + writeLine(); + write("enumerable: true,"); + writeLine(); + write("configurable: true"); + decreaseIndent(); + writeLine(); + write("});"); + emitEnd(member); + } + } + }); + } + function emitMemberFunctionsForES6AndHigher(node) { + for (var _a = 0, _b = node.members; _a < _b.length; _a++) { + var member = _b[_a]; + if ((member.kind === 143 || node.kind === 142) && !member.body) { + emitCommentsOnNotEmittedNode(member); + } + else if (member.kind === 143 || + member.kind === 145 || + member.kind === 146) { + writeLine(); + emitLeadingComments(member); + emitStart(member); + if (member.flags & 128) { + write("static "); + } + if (member.kind === 145) { + write("get "); + } + else if (member.kind === 146) { + write("set "); + } + if (member.asteriskToken) { + write("*"); + } + emit(member.name); + emitSignatureAndBody(member); + emitEnd(member); + emitTrailingComments(member); + } + else if (member.kind === 191) { + writeLine(); + write(";"); + } + } + } + function emitConstructor(node, baseTypeElement) { + var saveTempFlags = tempFlags; + var saveTempVariables = tempVariables; + var saveTempParameters = tempParameters; + tempFlags = 0; + tempVariables = undefined; + tempParameters = undefined; + emitConstructorWorker(node, baseTypeElement); + tempFlags = saveTempFlags; + tempVariables = saveTempVariables; + tempParameters = saveTempParameters; + } + function emitConstructorWorker(node, baseTypeElement) { + var hasInstancePropertyWithInitializer = false; + ts.forEach(node.members, function (member) { + if (member.kind === 144 && !member.body) { + emitCommentsOnNotEmittedNode(member); + } + if (member.kind === 141 && member.initializer && (member.flags & 128) === 0) { + hasInstancePropertyWithInitializer = true; + } + }); + var ctor = ts.getFirstConstructorWithBody(node); + if (languageVersion >= 2 && !ctor && !hasInstancePropertyWithInitializer) { + return; + } + if (ctor) { + emitLeadingComments(ctor); + } + emitStart(ctor || node); + if (languageVersion < 2) { + write("function "); + emitDeclarationName(node); + emitSignatureParameters(ctor); + } + else { + write("constructor"); + if (ctor) { + emitSignatureParameters(ctor); + } + else { + if (baseTypeElement) { + write("(...args)"); + } + else { + write("()"); + } + } + } + var startIndex = 0; + write(" {"); + scopeEmitStart(node, "constructor"); + increaseIndent(); + if (ctor) { + startIndex = emitDirectivePrologues(ctor.body.statements, true); + emitDetachedComments(ctor.body.statements); + } + emitCaptureThisForNodeIfNecessary(node); + var superCall; + if (ctor) { + emitDefaultValueAssignments(ctor); + emitRestParameter(ctor); + if (baseTypeElement) { + superCall = findInitialSuperCall(ctor); + if (superCall) { + writeLine(); + emit(superCall); + } + } + emitParameterPropertyAssignments(ctor); + } + else { + if (baseTypeElement) { + writeLine(); + emitStart(baseTypeElement); + if (languageVersion < 2) { + write("_super.apply(this, arguments);"); + } + else { + write("super(...args);"); + } + emitEnd(baseTypeElement); + } + } + emitPropertyDeclarations(node, getInitializedProperties(node, false)); + if (ctor) { + var statements = ctor.body.statements; + if (superCall) { + statements = statements.slice(1); + } + emitLinesStartingAt(statements, startIndex); + } + emitTempDeclarations(true); + writeLine(); + if (ctor) { + emitLeadingCommentsOfPosition(ctor.body.statements.end); + } + decreaseIndent(); + emitToken(16, ctor ? ctor.body.statements.end : node.members.end); + scopeEmitEnd(); + emitEnd(ctor || node); + if (ctor) { + emitTrailingComments(ctor); + } + } + function emitClassExpression(node) { + return emitClassLikeDeclaration(node); + } + function emitClassDeclaration(node) { + return emitClassLikeDeclaration(node); + } + function emitClassLikeDeclaration(node) { + if (languageVersion < 2) { + emitClassLikeDeclarationBelowES6(node); + } + else { + emitClassLikeDeclarationForES6AndHigher(node); + } + if (modulekind !== 5 && node.parent === currentSourceFile && node.name) { + emitExportMemberAssignments(node.name); + } + } + function emitClassLikeDeclarationForES6AndHigher(node) { + var thisNodeIsDecorated = ts.nodeIsDecorated(node); + if (node.kind === 214) { + if (thisNodeIsDecorated) { + if (isES6ExportedDeclaration(node) && !(node.flags & 1024)) { + write("export "); + } + write("let "); + emitDeclarationName(node); + write(" = "); + } + else if (isES6ExportedDeclaration(node)) { + write("export "); + if (node.flags & 1024) { + write("default "); + } + } + } + var staticProperties = getInitializedProperties(node, true); + var isClassExpressionWithStaticProperties = staticProperties.length > 0 && node.kind === 186; + var tempVariable; + if (isClassExpressionWithStaticProperties) { + tempVariable = createAndRecordTempVariable(0); + write("("); + increaseIndent(); + emit(tempVariable); + write(" = "); + } + write("class"); + if ((node.name || (node.flags & 1024 && staticProperties.length > 0)) && !thisNodeIsDecorated) { + write(" "); + emitDeclarationName(node); + } + var baseTypeNode = ts.getClassExtendsHeritageClauseElement(node); + if (baseTypeNode) { + write(" extends "); + emit(baseTypeNode.expression); + } + write(" {"); + increaseIndent(); + scopeEmitStart(node); + writeLine(); + emitConstructor(node, baseTypeNode); + emitMemberFunctionsForES6AndHigher(node); + decreaseIndent(); + writeLine(); + emitToken(16, node.members.end); + scopeEmitEnd(); + if (thisNodeIsDecorated) { + write(";"); + } + if (isClassExpressionWithStaticProperties) { + for (var _a = 0; _a < staticProperties.length; _a++) { + var property = staticProperties[_a]; + write(","); + writeLine(); + emitPropertyDeclaration(node, property, tempVariable, true); + } + write(","); + writeLine(); + emit(tempVariable); + decreaseIndent(); + write(")"); + } + else { + writeLine(); + emitPropertyDeclarations(node, staticProperties); + emitDecoratorsOfClass(node); + } + if (!isES6ExportedDeclaration(node) && (node.flags & 1)) { + writeLine(); + emitStart(node); + emitModuleMemberName(node); + write(" = "); + emitDeclarationName(node); + emitEnd(node); + write(";"); + } + else if (isES6ExportedDeclaration(node) && (node.flags & 1024) && thisNodeIsDecorated) { + writeLine(); + write("export default "); + emitDeclarationName(node); + write(";"); + } + } + function emitClassLikeDeclarationBelowES6(node) { + if (node.kind === 214) { + if (!shouldHoistDeclarationInSystemJsModule(node)) { + write("var "); + } + emitDeclarationName(node); + write(" = "); + } + write("(function ("); + var baseTypeNode = ts.getClassExtendsHeritageClauseElement(node); + if (baseTypeNode) { + write("_super"); + } + write(") {"); + var saveTempFlags = tempFlags; + var saveTempVariables = tempVariables; + var saveTempParameters = tempParameters; + var saveComputedPropertyNamesToGeneratedNames = computedPropertyNamesToGeneratedNames; + tempFlags = 0; + tempVariables = undefined; + tempParameters = undefined; + computedPropertyNamesToGeneratedNames = undefined; + increaseIndent(); + scopeEmitStart(node); + if (baseTypeNode) { + writeLine(); + emitStart(baseTypeNode); + write("__extends("); + emitDeclarationName(node); + write(", _super);"); + emitEnd(baseTypeNode); + } + writeLine(); + emitConstructor(node, baseTypeNode); + emitMemberFunctionsForES5AndLower(node); + emitPropertyDeclarations(node, getInitializedProperties(node, true)); + writeLine(); + emitDecoratorsOfClass(node); + writeLine(); + emitToken(16, node.members.end, function () { + write("return "); + emitDeclarationName(node); + }); + write(";"); + emitTempDeclarations(true); + tempFlags = saveTempFlags; + tempVariables = saveTempVariables; + tempParameters = saveTempParameters; + computedPropertyNamesToGeneratedNames = saveComputedPropertyNamesToGeneratedNames; + decreaseIndent(); + writeLine(); + emitToken(16, node.members.end); + scopeEmitEnd(); + emitStart(node); + write(")("); + if (baseTypeNode) { + emit(baseTypeNode.expression); + } + write(")"); + if (node.kind === 214) { + write(";"); + } + emitEnd(node); + if (node.kind === 214) { + emitExportMemberAssignment(node); + } + } + function emitClassMemberPrefix(node, member) { + emitDeclarationName(node); + if (!(member.flags & 128)) { + write(".prototype"); + } + } + function emitDecoratorsOfClass(node) { + emitDecoratorsOfMembers(node, 0); + emitDecoratorsOfMembers(node, 128); + emitDecoratorsOfConstructor(node); + } + function emitDecoratorsOfConstructor(node) { + var decorators = node.decorators; + var constructor = ts.getFirstConstructorWithBody(node); + var hasDecoratedParameters = constructor && ts.forEach(constructor.parameters, ts.nodeIsDecorated); + if (!decorators && !hasDecoratedParameters) { + return; + } + writeLine(); + emitStart(node); + emitDeclarationName(node); + write(" = __decorate(["); + increaseIndent(); + writeLine(); + var decoratorCount = decorators ? decorators.length : 0; + var argumentsWritten = emitList(decorators, 0, decoratorCount, true, false, false, true, function (decorator) { + emitStart(decorator); + emit(decorator.expression); + emitEnd(decorator); + }); + argumentsWritten += emitDecoratorsOfParameters(constructor, argumentsWritten > 0); + emitSerializedTypeMetadata(node, argumentsWritten >= 0); + decreaseIndent(); + writeLine(); + write("], "); + emitDeclarationName(node); + write(");"); + emitEnd(node); + writeLine(); + } + function emitDecoratorsOfMembers(node, staticFlag) { + for (var _a = 0, _b = node.members; _a < _b.length; _a++) { + var member = _b[_a]; + if ((member.flags & 128) !== staticFlag) { + continue; + } + if (!ts.nodeCanBeDecorated(member)) { + continue; + } + if (!ts.nodeOrChildIsDecorated(member)) { + continue; + } + var decorators = void 0; + var functionLikeMember = void 0; + if (ts.isAccessor(member)) { + var accessors = ts.getAllAccessorDeclarations(node.members, member); + if (member !== accessors.firstAccessor) { + continue; + } + decorators = accessors.firstAccessor.decorators; + if (!decorators && accessors.secondAccessor) { + decorators = accessors.secondAccessor.decorators; + } + functionLikeMember = accessors.setAccessor; + } + else { + decorators = member.decorators; + if (member.kind === 143) { + functionLikeMember = member; + } + } + writeLine(); + emitStart(member); + write("__decorate(["); + increaseIndent(); + writeLine(); + var decoratorCount = decorators ? decorators.length : 0; + var argumentsWritten = emitList(decorators, 0, decoratorCount, true, false, false, true, function (decorator) { + emitStart(decorator); + emit(decorator.expression); + emitEnd(decorator); + }); + argumentsWritten += emitDecoratorsOfParameters(functionLikeMember, argumentsWritten > 0); + emitSerializedTypeMetadata(member, argumentsWritten > 0); + decreaseIndent(); + writeLine(); + write("], "); + emitStart(member.name); + emitClassMemberPrefix(node, member); + write(", "); + emitExpressionForPropertyName(member.name); + emitEnd(member.name); + if (languageVersion > 0) { + if (member.kind !== 141) { + write(", null"); + } + else { + write(", void 0"); + } + } + write(");"); + emitEnd(member); + writeLine(); + } + } + function emitDecoratorsOfParameters(node, leadingComma) { + var argumentsWritten = 0; + if (node) { + var parameterIndex = 0; + for (var _a = 0, _b = node.parameters; _a < _b.length; _a++) { + var parameter = _b[_a]; + if (ts.nodeIsDecorated(parameter)) { + var decorators = parameter.decorators; + argumentsWritten += emitList(decorators, 0, decorators.length, true, false, leadingComma, true, function (decorator) { + emitStart(decorator); + write("__param(" + parameterIndex + ", "); + emit(decorator.expression); + write(")"); + emitEnd(decorator); + }); + leadingComma = true; + } + ++parameterIndex; + } + } + return argumentsWritten; + } + function shouldEmitTypeMetadata(node) { + switch (node.kind) { + case 143: + case 145: + case 146: + case 141: + return true; + } + return false; + } + function shouldEmitReturnTypeMetadata(node) { + switch (node.kind) { + case 143: + return true; + } + return false; + } + function shouldEmitParamTypesMetadata(node) { + switch (node.kind) { + case 214: + case 143: + case 146: + return true; + } + return false; + } + function emitSerializedTypeOfNode(node) { + switch (node.kind) { + case 214: + write("Function"); + return; + case 141: + emitSerializedTypeNode(node.type); + return; + case 138: + emitSerializedTypeNode(node.type); + return; + case 145: + emitSerializedTypeNode(node.type); + return; + case 146: + emitSerializedTypeNode(ts.getSetAccessorTypeAnnotationNode(node)); + return; + } + if (ts.isFunctionLike(node)) { + write("Function"); + return; + } + write("void 0"); + } + function emitSerializedTypeNode(node) { + if (node) { + switch (node.kind) { + case 103: + write("void 0"); + return; + case 160: + emitSerializedTypeNode(node.type); + return; + case 152: + case 153: + write("Function"); + return; + case 156: + case 157: + write("Array"); + return; + case 150: + case 120: + write("Boolean"); + return; + case 130: + case 9: + write("String"); + return; + case 128: + write("Number"); + return; + case 131: + write("Symbol"); + return; + case 151: + emitSerializedTypeReferenceNode(node); + return; + case 154: + case 155: + case 158: + case 159: + case 117: + break; + default: + ts.Debug.fail("Cannot serialize unexpected type node."); + break; + } + } + write("Object"); + } + function emitSerializedTypeReferenceNode(node) { + var location = node.parent; + while (ts.isDeclaration(location) || ts.isTypeNode(location)) { + location = location.parent; + } + var typeName = ts.cloneEntityName(node.typeName); + typeName.parent = location; + var result = resolver.getTypeReferenceSerializationKind(typeName); + switch (result) { + case ts.TypeReferenceSerializationKind.Unknown: + var temp = createAndRecordTempVariable(0); + write("(typeof ("); + emitNodeWithoutSourceMap(temp); + write(" = "); + emitEntityNameAsExpression(typeName, true); + write(") === 'function' && "); + emitNodeWithoutSourceMap(temp); + write(") || Object"); + break; + case ts.TypeReferenceSerializationKind.TypeWithConstructSignatureAndValue: + emitEntityNameAsExpression(typeName, false); + break; + case ts.TypeReferenceSerializationKind.VoidType: + write("void 0"); + break; + case ts.TypeReferenceSerializationKind.BooleanType: + write("Boolean"); + break; + case ts.TypeReferenceSerializationKind.NumberLikeType: + write("Number"); + break; + case ts.TypeReferenceSerializationKind.StringLikeType: + write("String"); + break; + case ts.TypeReferenceSerializationKind.ArrayLikeType: + write("Array"); + break; + case ts.TypeReferenceSerializationKind.ESSymbolType: + if (languageVersion < 2) { + write("typeof Symbol === 'function' ? Symbol : Object"); + } + else { + write("Symbol"); + } + break; + case ts.TypeReferenceSerializationKind.TypeWithCallSignature: + write("Function"); + break; + case ts.TypeReferenceSerializationKind.ObjectType: + write("Object"); + break; + } + } + function emitSerializedParameterTypesOfNode(node) { + if (node) { + var valueDeclaration; + if (node.kind === 214) { + valueDeclaration = ts.getFirstConstructorWithBody(node); + } + else if (ts.isFunctionLike(node) && ts.nodeIsPresent(node.body)) { + valueDeclaration = node; + } + if (valueDeclaration) { + var parameters = valueDeclaration.parameters; + var parameterCount = parameters.length; + if (parameterCount > 0) { + for (var i = 0; i < parameterCount; i++) { + if (i > 0) { + write(", "); + } + if (parameters[i].dotDotDotToken) { + var parameterType = parameters[i].type; + if (parameterType.kind === 156) { + parameterType = parameterType.elementType; + } + else if (parameterType.kind === 151 && parameterType.typeArguments && parameterType.typeArguments.length === 1) { + parameterType = parameterType.typeArguments[0]; + } + else { + parameterType = undefined; + } + emitSerializedTypeNode(parameterType); + } + else { + emitSerializedTypeOfNode(parameters[i]); + } + } + } + } + } + } + function emitSerializedReturnTypeOfNode(node) { + if (node && ts.isFunctionLike(node) && node.type) { + emitSerializedTypeNode(node.type); + return; + } + write("void 0"); + } + function emitSerializedTypeMetadata(node, writeComma) { + var argumentsWritten = 0; + if (compilerOptions.emitDecoratorMetadata) { + if (shouldEmitTypeMetadata(node)) { + if (writeComma) { + write(", "); + } + writeLine(); + write("__metadata('design:type', "); + emitSerializedTypeOfNode(node); + write(")"); + argumentsWritten++; + } + if (shouldEmitParamTypesMetadata(node)) { + if (writeComma || argumentsWritten) { + write(", "); + } + writeLine(); + write("__metadata('design:paramtypes', ["); + emitSerializedParameterTypesOfNode(node); + write("])"); + argumentsWritten++; + } + if (shouldEmitReturnTypeMetadata(node)) { + if (writeComma || argumentsWritten) { + write(", "); + } + writeLine(); + write("__metadata('design:returntype', "); + emitSerializedReturnTypeOfNode(node); + write(")"); + argumentsWritten++; + } + } + return argumentsWritten; + } + function emitInterfaceDeclaration(node) { + emitCommentsOnNotEmittedNode(node); + } + function shouldEmitEnumDeclaration(node) { + var isConstEnum = ts.isConst(node); + return !isConstEnum || compilerOptions.preserveConstEnums || compilerOptions.isolatedModules; + } + function emitEnumDeclaration(node) { + if (!shouldEmitEnumDeclaration(node)) { + return; + } + if (!shouldHoistDeclarationInSystemJsModule(node)) { + if (!(node.flags & 1) || isES6ExportedDeclaration(node)) { + emitStart(node); + if (isES6ExportedDeclaration(node)) { + write("export "); + } + write("var "); + emit(node.name); + emitEnd(node); + write(";"); + } + } + writeLine(); + emitStart(node); + write("(function ("); + emitStart(node.name); + write(getGeneratedNameForNode(node)); + emitEnd(node.name); + write(") {"); + increaseIndent(); + scopeEmitStart(node); + emitLines(node.members); + decreaseIndent(); + writeLine(); + emitToken(16, node.members.end); + scopeEmitEnd(); + write(")("); + emitModuleMemberName(node); + write(" || ("); + emitModuleMemberName(node); + write(" = {}));"); + emitEnd(node); + if (!isES6ExportedDeclaration(node) && node.flags & 1 && !shouldHoistDeclarationInSystemJsModule(node)) { + writeLine(); + emitStart(node); + write("var "); + emit(node.name); + write(" = "); + emitModuleMemberName(node); + emitEnd(node); + write(";"); + } + if (modulekind !== 5 && node.parent === currentSourceFile) { + if (modulekind === 4 && (node.flags & 1)) { + writeLine(); + write(exportFunctionForFile + "(\""); + emitDeclarationName(node); + write("\", "); + emitDeclarationName(node); + write(");"); + } + emitExportMemberAssignments(node.name); + } + } + function emitEnumMember(node) { + var enumParent = node.parent; + emitStart(node); + write(getGeneratedNameForNode(enumParent)); + write("["); + write(getGeneratedNameForNode(enumParent)); + write("["); + emitExpressionForPropertyName(node.name); + write("] = "); + writeEnumMemberDeclarationValue(node); + write("] = "); + emitExpressionForPropertyName(node.name); + emitEnd(node); + write(";"); + } + function writeEnumMemberDeclarationValue(member) { + var value = resolver.getConstantValue(member); + if (value !== undefined) { + write(value.toString()); + return; + } + else if (member.initializer) { + emit(member.initializer); + } + else { + write("undefined"); + } + } + function getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration) { + if (moduleDeclaration.body.kind === 218) { + var recursiveInnerModule = getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration.body); + return recursiveInnerModule || moduleDeclaration.body; + } + } + function shouldEmitModuleDeclaration(node) { + return ts.isInstantiatedModule(node, compilerOptions.preserveConstEnums || compilerOptions.isolatedModules); + } + function isModuleMergedWithES6Class(node) { + return languageVersion === 2 && !!(resolver.getNodeCheckFlags(node) & 32768); + } + function emitModuleDeclaration(node) { + var shouldEmit = shouldEmitModuleDeclaration(node); + if (!shouldEmit) { + return emitCommentsOnNotEmittedNode(node); + } + var hoistedInDeclarationScope = shouldHoistDeclarationInSystemJsModule(node); + var emitVarForModule = !hoistedInDeclarationScope && !isModuleMergedWithES6Class(node); + if (emitVarForModule) { + emitStart(node); + if (isES6ExportedDeclaration(node)) { + write("export "); + } + write("var "); + emit(node.name); + write(";"); + emitEnd(node); + writeLine(); + } + emitStart(node); + write("(function ("); + emitStart(node.name); + write(getGeneratedNameForNode(node)); + emitEnd(node.name); + write(") "); + if (node.body.kind === 219) { + var saveTempFlags = tempFlags; + var saveTempVariables = tempVariables; + tempFlags = 0; + tempVariables = undefined; + emit(node.body); + tempFlags = saveTempFlags; + tempVariables = saveTempVariables; + } + else { + write("{"); + increaseIndent(); + scopeEmitStart(node); + emitCaptureThisForNodeIfNecessary(node); + writeLine(); + emit(node.body); + decreaseIndent(); + writeLine(); + var moduleBlock = getInnerMostModuleDeclarationFromDottedModule(node).body; + emitToken(16, moduleBlock.statements.end); + scopeEmitEnd(); + } + write(")("); + if ((node.flags & 1) && !isES6ExportedDeclaration(node)) { + emit(node.name); + write(" = "); + } + emitModuleMemberName(node); + write(" || ("); + emitModuleMemberName(node); + write(" = {}));"); + emitEnd(node); + if (!isES6ExportedDeclaration(node) && node.name.kind === 69 && node.parent === currentSourceFile) { + if (modulekind === 4 && (node.flags & 1)) { + writeLine(); + write(exportFunctionForFile + "(\""); + emitDeclarationName(node); + write("\", "); + emitDeclarationName(node); + write(");"); + } + emitExportMemberAssignments(node.name); + } + } + function tryRenameExternalModule(moduleName) { + if (currentSourceFile.renamedDependencies && ts.hasProperty(currentSourceFile.renamedDependencies, moduleName.text)) { + return "\"" + currentSourceFile.renamedDependencies[moduleName.text] + "\""; + } + return undefined; + } + function emitRequire(moduleName) { + if (moduleName.kind === 9) { + write("require("); + var text = tryRenameExternalModule(moduleName); + if (text) { + write(text); + } + else { + emitStart(moduleName); + emitLiteral(moduleName); + emitEnd(moduleName); + } + emitToken(18, moduleName.end); + } + else { + write("require()"); + } + } + function getNamespaceDeclarationNode(node) { + if (node.kind === 221) { + return node; + } + var importClause = node.importClause; + if (importClause && importClause.namedBindings && importClause.namedBindings.kind === 224) { + return importClause.namedBindings; + } + } + function isDefaultImport(node) { + return node.kind === 222 && node.importClause && !!node.importClause.name; + } + function emitExportImportAssignments(node) { + if (ts.isAliasSymbolDeclaration(node) && resolver.isValueAliasDeclaration(node)) { + emitExportMemberAssignments(node.name); + } + ts.forEachChild(node, emitExportImportAssignments); + } + function emitImportDeclaration(node) { + if (modulekind !== 5) { + return emitExternalImportDeclaration(node); + } + if (node.importClause) { + var shouldEmitDefaultBindings = resolver.isReferencedAliasDeclaration(node.importClause); + var shouldEmitNamedBindings = node.importClause.namedBindings && resolver.isReferencedAliasDeclaration(node.importClause.namedBindings, true); + if (shouldEmitDefaultBindings || shouldEmitNamedBindings) { + write("import "); + emitStart(node.importClause); + if (shouldEmitDefaultBindings) { + emit(node.importClause.name); + if (shouldEmitNamedBindings) { + write(", "); + } + } + if (shouldEmitNamedBindings) { + emitLeadingComments(node.importClause.namedBindings); + emitStart(node.importClause.namedBindings); + if (node.importClause.namedBindings.kind === 224) { + write("* as "); + emit(node.importClause.namedBindings.name); + } + else { + write("{ "); + emitExportOrImportSpecifierList(node.importClause.namedBindings.elements, resolver.isReferencedAliasDeclaration); + write(" }"); + } + emitEnd(node.importClause.namedBindings); + emitTrailingComments(node.importClause.namedBindings); + } + emitEnd(node.importClause); + write(" from "); + emit(node.moduleSpecifier); + write(";"); + } + } + else { + write("import "); + emit(node.moduleSpecifier); + write(";"); + } + } + function emitExternalImportDeclaration(node) { + if (ts.contains(externalImports, node)) { + var isExportedImport = node.kind === 221 && (node.flags & 1) !== 0; + var namespaceDeclaration = getNamespaceDeclarationNode(node); + if (modulekind !== 2) { + emitLeadingComments(node); + emitStart(node); + if (namespaceDeclaration && !isDefaultImport(node)) { + if (!isExportedImport) + write("var "); + emitModuleMemberName(namespaceDeclaration); + write(" = "); + } + else { + var isNakedImport = 222 && !node.importClause; + if (!isNakedImport) { + write("var "); + write(getGeneratedNameForNode(node)); + write(" = "); + } + } + emitRequire(ts.getExternalModuleName(node)); + if (namespaceDeclaration && isDefaultImport(node)) { + write(", "); + emitModuleMemberName(namespaceDeclaration); + write(" = "); + write(getGeneratedNameForNode(node)); + } + write(";"); + emitEnd(node); + emitExportImportAssignments(node); + emitTrailingComments(node); + } + else { + if (isExportedImport) { + emitModuleMemberName(namespaceDeclaration); + write(" = "); + emit(namespaceDeclaration.name); + write(";"); + } + else if (namespaceDeclaration && isDefaultImport(node)) { + write("var "); + emitModuleMemberName(namespaceDeclaration); + write(" = "); + write(getGeneratedNameForNode(node)); + write(";"); + } + emitExportImportAssignments(node); + } + } + } + function emitImportEqualsDeclaration(node) { + if (ts.isExternalModuleImportEqualsDeclaration(node)) { + emitExternalImportDeclaration(node); + return; + } + if (resolver.isReferencedAliasDeclaration(node) || + (!ts.isExternalModule(currentSourceFile) && resolver.isTopLevelValueImportEqualsWithEntityName(node))) { + emitLeadingComments(node); + emitStart(node); + var variableDeclarationIsHoisted = shouldHoistVariable(node, true); + var isExported = isSourceFileLevelDeclarationInSystemJsModule(node, true); + if (!variableDeclarationIsHoisted) { + ts.Debug.assert(!isExported); + if (isES6ExportedDeclaration(node)) { + write("export "); + write("var "); + } + else if (!(node.flags & 1)) { + write("var "); + } + } + if (isExported) { + write(exportFunctionForFile + "(\""); + emitNodeWithoutSourceMap(node.name); + write("\", "); + } + emitModuleMemberName(node); + write(" = "); + emit(node.moduleReference); + if (isExported) { + write(")"); + } + write(";"); + emitEnd(node); + emitExportImportAssignments(node); + emitTrailingComments(node); + } + } + function emitExportDeclaration(node) { + ts.Debug.assert(modulekind !== 4); + if (modulekind !== 5) { + if (node.moduleSpecifier && (!node.exportClause || resolver.isValueAliasDeclaration(node))) { + emitStart(node); + var generatedName = getGeneratedNameForNode(node); + if (node.exportClause) { + if (modulekind !== 2) { + write("var "); + write(generatedName); + write(" = "); + emitRequire(ts.getExternalModuleName(node)); + write(";"); + } + for (var _a = 0, _b = node.exportClause.elements; _a < _b.length; _a++) { + var specifier = _b[_a]; + if (resolver.isValueAliasDeclaration(specifier)) { + writeLine(); + emitStart(specifier); + emitContainingModuleName(specifier); + write("."); + emitNodeWithCommentsAndWithoutSourcemap(specifier.name); + write(" = "); + write(generatedName); + write("."); + emitNodeWithCommentsAndWithoutSourcemap(specifier.propertyName || specifier.name); + write(";"); + emitEnd(specifier); + } + } + } + else { + writeLine(); + write("__export("); + if (modulekind !== 2) { + emitRequire(ts.getExternalModuleName(node)); + } + else { + write(generatedName); + } + write(");"); + } + emitEnd(node); + } + } + else { + if (!node.exportClause || resolver.isValueAliasDeclaration(node)) { + write("export "); + if (node.exportClause) { + write("{ "); + emitExportOrImportSpecifierList(node.exportClause.elements, resolver.isValueAliasDeclaration); + write(" }"); + } + else { + write("*"); + } + if (node.moduleSpecifier) { + write(" from "); + emit(node.moduleSpecifier); + } + write(";"); + } + } + } + function emitExportOrImportSpecifierList(specifiers, shouldEmit) { + ts.Debug.assert(modulekind === 5); + var needsComma = false; + for (var _a = 0; _a < specifiers.length; _a++) { + var specifier = specifiers[_a]; + if (shouldEmit(specifier)) { + if (needsComma) { + write(", "); + } + if (specifier.propertyName) { + emit(specifier.propertyName); + write(" as "); + } + emit(specifier.name); + needsComma = true; + } + } + } + function emitExportAssignment(node) { + if (!node.isExportEquals && resolver.isValueAliasDeclaration(node)) { + if (modulekind === 5) { + writeLine(); + emitStart(node); + write("export default "); + var expression = node.expression; + emit(expression); + if (expression.kind !== 213 && + expression.kind !== 214) { + write(";"); + } + emitEnd(node); + } + else { + writeLine(); + emitStart(node); + if (modulekind === 4) { + write(exportFunctionForFile + "(\"default\","); + emit(node.expression); + write(")"); + } + else { + emitEs6ExportDefaultCompat(node); + emitContainingModuleName(node); + if (languageVersion === 0) { + write("[\"default\"] = "); + } + else { + write(".default = "); + } + emit(node.expression); + } + write(";"); + emitEnd(node); + } + } + } + function collectExternalModuleInfo(sourceFile) { + externalImports = []; + exportSpecifiers = {}; + exportEquals = undefined; + hasExportStars = false; + for (var _a = 0, _b = sourceFile.statements; _a < _b.length; _a++) { + var node = _b[_a]; + switch (node.kind) { + case 222: + if (!node.importClause || + resolver.isReferencedAliasDeclaration(node.importClause, true)) { + externalImports.push(node); + } + break; + case 221: + if (node.moduleReference.kind === 232 && resolver.isReferencedAliasDeclaration(node)) { + externalImports.push(node); + } + break; + case 228: + if (node.moduleSpecifier) { + if (!node.exportClause) { + externalImports.push(node); + hasExportStars = true; + } + else if (resolver.isValueAliasDeclaration(node)) { + externalImports.push(node); + } + } + else { + for (var _c = 0, _d = node.exportClause.elements; _c < _d.length; _c++) { + var specifier = _d[_c]; + var name_25 = (specifier.propertyName || specifier.name).text; + (exportSpecifiers[name_25] || (exportSpecifiers[name_25] = [])).push(specifier); + } + } + break; + case 227: + if (node.isExportEquals && !exportEquals) { + exportEquals = node; + } + break; + } + } + } + function emitExportStarHelper() { + if (hasExportStars) { + writeLine(); + write("function __export(m) {"); + increaseIndent(); + writeLine(); + write("for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];"); + decreaseIndent(); + writeLine(); + write("}"); + } + } + function getLocalNameForExternalImport(node) { + var namespaceDeclaration = getNamespaceDeclarationNode(node); + if (namespaceDeclaration && !isDefaultImport(node)) { + return ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, namespaceDeclaration.name); + } + if (node.kind === 222 && node.importClause) { + return getGeneratedNameForNode(node); + } + if (node.kind === 228 && node.moduleSpecifier) { + return getGeneratedNameForNode(node); + } + } + function getExternalModuleNameText(importNode) { + var moduleName = ts.getExternalModuleName(importNode); + if (moduleName.kind === 9) { + return tryRenameExternalModule(moduleName) || getLiteralText(moduleName); + } + return undefined; + } + function emitVariableDeclarationsForImports() { + if (externalImports.length === 0) { + return; + } + writeLine(); + var started = false; + for (var _a = 0; _a < externalImports.length; _a++) { + var importNode = externalImports[_a]; + var skipNode = importNode.kind === 228 || + (importNode.kind === 222 && !importNode.importClause); + if (skipNode) { + continue; + } + if (!started) { + write("var "); + started = true; + } + else { + write(", "); + } + write(getLocalNameForExternalImport(importNode)); + } + if (started) { + write(";"); + } + } + function emitLocalStorageForExportedNamesIfNecessary(exportedDeclarations) { + if (!hasExportStars) { + return undefined; + } + if (!exportedDeclarations && ts.isEmpty(exportSpecifiers)) { + var hasExportDeclarationWithExportClause = false; + for (var _a = 0; _a < externalImports.length; _a++) { + var externalImport = externalImports[_a]; + if (externalImport.kind === 228 && externalImport.exportClause) { + hasExportDeclarationWithExportClause = true; + break; + } + } + if (!hasExportDeclarationWithExportClause) { + return emitExportStarFunction(undefined); + } + } + var exportedNamesStorageRef = makeUniqueName("exportedNames"); + writeLine(); + write("var " + exportedNamesStorageRef + " = {"); + increaseIndent(); + var started = false; + if (exportedDeclarations) { + for (var i = 0; i < exportedDeclarations.length; ++i) { + writeExportedName(exportedDeclarations[i]); + } + } + if (exportSpecifiers) { + for (var n in exportSpecifiers) { + for (var _b = 0, _c = exportSpecifiers[n]; _b < _c.length; _b++) { + var specifier = _c[_b]; + writeExportedName(specifier.name); + } + } + } + for (var _d = 0; _d < externalImports.length; _d++) { + var externalImport = externalImports[_d]; + if (externalImport.kind !== 228) { + continue; + } + var exportDecl = externalImport; + if (!exportDecl.exportClause) { + continue; + } + for (var _e = 0, _f = exportDecl.exportClause.elements; _e < _f.length; _e++) { + var element = _f[_e]; + writeExportedName(element.name || element.propertyName); + } + } + decreaseIndent(); + writeLine(); + write("};"); + return emitExportStarFunction(exportedNamesStorageRef); + function emitExportStarFunction(localNames) { + var exportStarFunction = makeUniqueName("exportStar"); + writeLine(); + write("function " + exportStarFunction + "(m) {"); + increaseIndent(); + writeLine(); + write("var exports = {};"); + writeLine(); + write("for(var n in m) {"); + increaseIndent(); + writeLine(); + write("if (n !== \"default\""); + if (localNames) { + write("&& !" + localNames + ".hasOwnProperty(n)"); + } + write(") exports[n] = m[n];"); + decreaseIndent(); + writeLine(); + write("}"); + writeLine(); + write(exportFunctionForFile + "(exports);"); + decreaseIndent(); + writeLine(); + write("}"); + return exportStarFunction; + } + function writeExportedName(node) { + if (node.kind !== 69 && node.flags & 1024) { + return; + } + if (started) { + write(","); + } + else { + started = true; + } + writeLine(); + write("'"); + if (node.kind === 69) { + emitNodeWithCommentsAndWithoutSourcemap(node); + } + else { + emitDeclarationName(node); + } + write("': true"); + } + } + function processTopLevelVariableAndFunctionDeclarations(node) { + var hoistedVars; + var hoistedFunctionDeclarations; + var exportedDeclarations; + visit(node); + if (hoistedVars) { + writeLine(); + write("var "); + var seen = {}; + for (var i = 0; i < hoistedVars.length; ++i) { + var local = hoistedVars[i]; + var name_26 = local.kind === 69 + ? local + : local.name; + if (name_26) { + var text = ts.unescapeIdentifier(name_26.text); + if (ts.hasProperty(seen, text)) { + continue; + } + else { + seen[text] = text; + } + } + if (i !== 0) { + write(", "); + } + if (local.kind === 214 || local.kind === 218 || local.kind === 217) { + emitDeclarationName(local); + } + else { + emit(local); + } + var flags = ts.getCombinedNodeFlags(local.kind === 69 ? local.parent : local); + if (flags & 1) { + if (!exportedDeclarations) { + exportedDeclarations = []; + } + exportedDeclarations.push(local); + } + } + write(";"); + } + if (hoistedFunctionDeclarations) { + for (var _a = 0; _a < hoistedFunctionDeclarations.length; _a++) { + var f = hoistedFunctionDeclarations[_a]; + writeLine(); + emit(f); + if (f.flags & 1) { + if (!exportedDeclarations) { + exportedDeclarations = []; + } + exportedDeclarations.push(f); + } + } + } + return exportedDeclarations; + function visit(node) { + if (node.flags & 2) { + return; + } + if (node.kind === 213) { + if (!hoistedFunctionDeclarations) { + hoistedFunctionDeclarations = []; + } + hoistedFunctionDeclarations.push(node); + return; + } + if (node.kind === 214) { + if (!hoistedVars) { + hoistedVars = []; + } + hoistedVars.push(node); + return; + } + if (node.kind === 217) { + if (shouldEmitEnumDeclaration(node)) { + if (!hoistedVars) { + hoistedVars = []; + } + hoistedVars.push(node); + } + return; + } + if (node.kind === 218) { + if (shouldEmitModuleDeclaration(node)) { + if (!hoistedVars) { + hoistedVars = []; + } + hoistedVars.push(node); + } + return; + } + if (node.kind === 211 || node.kind === 163) { + if (shouldHoistVariable(node, false)) { + var name_27 = node.name; + if (name_27.kind === 69) { + if (!hoistedVars) { + hoistedVars = []; + } + hoistedVars.push(name_27); + } + else { + ts.forEachChild(name_27, visit); + } + } + return; + } + if (ts.isInternalModuleImportEqualsDeclaration(node) && resolver.isValueAliasDeclaration(node)) { + if (!hoistedVars) { + hoistedVars = []; + } + hoistedVars.push(node.name); + return; + } + if (ts.isBindingPattern(node)) { + ts.forEach(node.elements, visit); + return; + } + if (!ts.isDeclaration(node)) { + ts.forEachChild(node, visit); + } + } + } + function shouldHoistVariable(node, checkIfSourceFileLevelDecl) { + if (checkIfSourceFileLevelDecl && !shouldHoistDeclarationInSystemJsModule(node)) { + return false; + } + return (ts.getCombinedNodeFlags(node) & 49152) === 0 || + ts.getEnclosingBlockScopeContainer(node).kind === 248; + } + function isCurrentFileSystemExternalModule() { + return modulekind === 4 && ts.isExternalModule(currentSourceFile); + } + function emitSystemModuleBody(node, dependencyGroups, startIndex) { + emitVariableDeclarationsForImports(); + writeLine(); + var exportedDeclarations = processTopLevelVariableAndFunctionDeclarations(node); + var exportStarFunction = emitLocalStorageForExportedNamesIfNecessary(exportedDeclarations); + writeLine(); + write("return {"); + increaseIndent(); + writeLine(); + emitSetters(exportStarFunction, dependencyGroups); + writeLine(); + emitExecute(node, startIndex); + decreaseIndent(); + writeLine(); + write("}"); + emitTempDeclarations(true); + } + function emitSetters(exportStarFunction, dependencyGroups) { + write("setters:["); + for (var i = 0; i < dependencyGroups.length; ++i) { + if (i !== 0) { + write(","); + } + writeLine(); + increaseIndent(); + var group = dependencyGroups[i]; + var parameterName = makeUniqueName(ts.forEach(group, getLocalNameForExternalImport) || ""); + write("function (" + parameterName + ") {"); + increaseIndent(); + for (var _a = 0; _a < group.length; _a++) { + var entry = group[_a]; + var importVariableName = getLocalNameForExternalImport(entry) || ""; + switch (entry.kind) { + case 222: + if (!entry.importClause) { + break; + } + case 221: + ts.Debug.assert(importVariableName !== ""); + writeLine(); + write(importVariableName + " = " + parameterName + ";"); + writeLine(); + break; + case 228: + ts.Debug.assert(importVariableName !== ""); + if (entry.exportClause) { + writeLine(); + write(exportFunctionForFile + "({"); + writeLine(); + increaseIndent(); + for (var i_2 = 0, len = entry.exportClause.elements.length; i_2 < len; ++i_2) { + if (i_2 !== 0) { + write(","); + writeLine(); + } + var e = entry.exportClause.elements[i_2]; + write("\""); + emitNodeWithCommentsAndWithoutSourcemap(e.name); + write("\": " + parameterName + "[\""); + emitNodeWithCommentsAndWithoutSourcemap(e.propertyName || e.name); + write("\"]"); + } + decreaseIndent(); + writeLine(); + write("});"); + } + else { + writeLine(); + write(exportStarFunction + "(" + parameterName + ");"); + } + writeLine(); + break; + } + } + decreaseIndent(); + write("}"); + decreaseIndent(); + } + write("],"); + } + function emitExecute(node, startIndex) { + write("execute: function() {"); + increaseIndent(); + writeLine(); + for (var i = startIndex; i < node.statements.length; ++i) { + var statement = node.statements[i]; + switch (statement.kind) { + case 213: + case 222: + continue; + case 228: + if (!statement.moduleSpecifier) { + for (var _a = 0, _b = statement.exportClause.elements; _a < _b.length; _a++) { + var element = _b[_a]; + emitExportSpecifierInSystemModule(element); + } + } + continue; + case 221: + if (!ts.isInternalModuleImportEqualsDeclaration(statement)) { + continue; + } + default: + writeLine(); + emit(statement); + } + } + decreaseIndent(); + writeLine(); + write("}"); + } + function emitSystemModule(node) { + collectExternalModuleInfo(node); + ts.Debug.assert(!exportFunctionForFile); + exportFunctionForFile = makeUniqueName("exports"); + writeLine(); + write("System.register("); + if (node.moduleName) { + write("\"" + node.moduleName + "\", "); + } + write("["); + var groupIndices = {}; + var dependencyGroups = []; + for (var i = 0; i < externalImports.length; ++i) { + var text = getExternalModuleNameText(externalImports[i]); + if (ts.hasProperty(groupIndices, text)) { + var groupIndex = groupIndices[text]; + dependencyGroups[groupIndex].push(externalImports[i]); + continue; + } + else { + groupIndices[text] = dependencyGroups.length; + dependencyGroups.push([externalImports[i]]); + } + if (i !== 0) { + write(", "); + } + write(text); + } + write("], function(" + exportFunctionForFile + ") {"); + writeLine(); + increaseIndent(); + var startIndex = emitDirectivePrologues(node.statements, true); + emitEmitHelpers(node); + emitCaptureThisForNodeIfNecessary(node); + emitSystemModuleBody(node, dependencyGroups, startIndex); + decreaseIndent(); + writeLine(); + write("});"); + } + function getAMDDependencyNames(node, includeNonAmdDependencies) { + var aliasedModuleNames = []; + var unaliasedModuleNames = []; + var importAliasNames = []; + for (var _a = 0, _b = node.amdDependencies; _a < _b.length; _a++) { + var amdDependency = _b[_a]; + if (amdDependency.name) { + aliasedModuleNames.push("\"" + amdDependency.path + "\""); + importAliasNames.push(amdDependency.name); + } + else { + unaliasedModuleNames.push("\"" + amdDependency.path + "\""); + } + } + for (var _c = 0; _c < externalImports.length; _c++) { + var importNode = externalImports[_c]; + var externalModuleName = getExternalModuleNameText(importNode); + var importAliasName = getLocalNameForExternalImport(importNode); + if (includeNonAmdDependencies && importAliasName) { + aliasedModuleNames.push(externalModuleName); + importAliasNames.push(importAliasName); + } + else { + unaliasedModuleNames.push(externalModuleName); + } + } + return { aliasedModuleNames: aliasedModuleNames, unaliasedModuleNames: unaliasedModuleNames, importAliasNames: importAliasNames }; + } + function emitAMDDependencies(node, includeNonAmdDependencies) { + var dependencyNames = getAMDDependencyNames(node, includeNonAmdDependencies); + emitAMDDependencyList(dependencyNames); + write(", "); + emitAMDFactoryHeader(dependencyNames); + } + function emitAMDDependencyList(_a) { + var aliasedModuleNames = _a.aliasedModuleNames, unaliasedModuleNames = _a.unaliasedModuleNames; + write("[\"require\", \"exports\""); + if (aliasedModuleNames.length) { + write(", "); + write(aliasedModuleNames.join(", ")); + } + if (unaliasedModuleNames.length) { + write(", "); + write(unaliasedModuleNames.join(", ")); + } + write("]"); + } + function emitAMDFactoryHeader(_a) { + var importAliasNames = _a.importAliasNames; + write("function (require, exports"); + if (importAliasNames.length) { + write(", "); + write(importAliasNames.join(", ")); + } + write(") {"); + } + function emitAMDModule(node) { + emitEmitHelpers(node); + collectExternalModuleInfo(node); + writeLine(); + write("define("); + if (node.moduleName) { + write("\"" + node.moduleName + "\", "); + } + emitAMDDependencies(node, true); + increaseIndent(); + var startIndex = emitDirectivePrologues(node.statements, true); + emitExportStarHelper(); + emitCaptureThisForNodeIfNecessary(node); + emitLinesStartingAt(node.statements, startIndex); + emitTempDeclarations(true); + emitExportEquals(true); + decreaseIndent(); + writeLine(); + write("});"); + } + function emitCommonJSModule(node) { + var startIndex = emitDirectivePrologues(node.statements, false); + emitEmitHelpers(node); + collectExternalModuleInfo(node); + emitExportStarHelper(); + emitCaptureThisForNodeIfNecessary(node); + emitLinesStartingAt(node.statements, startIndex); + emitTempDeclarations(true); + emitExportEquals(false); + } + function emitUMDModule(node) { + emitEmitHelpers(node); + collectExternalModuleInfo(node); + var dependencyNames = getAMDDependencyNames(node, false); + writeLines("(function (factory) {\n if (typeof module === 'object' && typeof module.exports === 'object') {\n var v = factory(require, exports); if (v !== undefined) module.exports = v;\n }\n else if (typeof define === 'function' && define.amd) {\n define("); + emitAMDDependencyList(dependencyNames); + write(", factory);"); + writeLines(" }\n})("); + emitAMDFactoryHeader(dependencyNames); + increaseIndent(); + var startIndex = emitDirectivePrologues(node.statements, true); + emitExportStarHelper(); + emitCaptureThisForNodeIfNecessary(node); + emitLinesStartingAt(node.statements, startIndex); + emitTempDeclarations(true); + emitExportEquals(true); + decreaseIndent(); + writeLine(); + write("});"); + } + function emitES6Module(node) { + externalImports = undefined; + exportSpecifiers = undefined; + exportEquals = undefined; + hasExportStars = false; + var startIndex = emitDirectivePrologues(node.statements, false); + emitEmitHelpers(node); + emitCaptureThisForNodeIfNecessary(node); + emitLinesStartingAt(node.statements, startIndex); + emitTempDeclarations(true); + } + function emitExportEquals(emitAsReturn) { + if (exportEquals && resolver.isValueAliasDeclaration(exportEquals)) { + writeLine(); + emitStart(exportEquals); + write(emitAsReturn ? "return " : "module.exports = "); + emit(exportEquals.expression); + write(";"); + emitEnd(exportEquals); + } + } + function emitJsxElement(node) { + switch (compilerOptions.jsx) { + case 2: + jsxEmitReact(node); + break; + case 1: + default: + jsxEmitPreserve(node); + break; + } + } + function trimReactWhitespaceAndApplyEntities(node) { + var result = undefined; + var text = ts.getTextOfNode(node, true); + var firstNonWhitespace = 0; + var lastNonWhitespace = -1; + for (var i = 0; i < text.length; i++) { + var c = text.charCodeAt(i); + if (ts.isLineBreak(c)) { + if (firstNonWhitespace !== -1 && (lastNonWhitespace - firstNonWhitespace + 1 > 0)) { + var part = text.substr(firstNonWhitespace, lastNonWhitespace - firstNonWhitespace + 1); + result = (result ? result + "\" + ' ' + \"" : "") + ts.escapeString(part); + } + firstNonWhitespace = -1; + } + else if (!ts.isWhiteSpace(c)) { + lastNonWhitespace = i; + if (firstNonWhitespace === -1) { + firstNonWhitespace = i; + } + } + } + if (firstNonWhitespace !== -1) { + var part = text.substr(firstNonWhitespace); + result = (result ? result + "\" + ' ' + \"" : "") + ts.escapeString(part); + } + if (result) { + result = result.replace(/&(\w+);/g, function (s, m) { + if (entities[m] !== undefined) { + return String.fromCharCode(entities[m]); + } + else { + return s; + } + }); + } + return result; + } + function getTextToEmit(node) { + switch (compilerOptions.jsx) { + case 2: + var text = trimReactWhitespaceAndApplyEntities(node); + if (text === undefined || text.length === 0) { + return undefined; + } + else { + return text; + } + case 1: + default: + return ts.getTextOfNode(node, true); + } + } + function emitJsxText(node) { + switch (compilerOptions.jsx) { + case 2: + write("\""); + write(trimReactWhitespaceAndApplyEntities(node)); + write("\""); + break; + case 1: + default: + writer.writeLiteral(ts.getTextOfNode(node, true)); + break; + } + } + function emitJsxExpression(node) { + if (node.expression) { + switch (compilerOptions.jsx) { + case 1: + default: + write("{"); + emit(node.expression); + write("}"); + break; + case 2: + emit(node.expression); + break; + } + } + } + function emitDirectivePrologues(statements, startWithNewLine) { + for (var i = 0; i < statements.length; ++i) { + if (ts.isPrologueDirective(statements[i])) { + if (startWithNewLine || i > 0) { + writeLine(); + } + emit(statements[i]); + } + else { + return i; + } + } + return statements.length; + } + function writeLines(text) { + var lines = text.split(/\r\n|\r|\n/g); + for (var i = 0; i < lines.length; ++i) { + var line = lines[i]; + if (line.length) { + writeLine(); + write(line); + } + } + } + function emitEmitHelpers(node) { + if (!compilerOptions.noEmitHelpers) { + if ((languageVersion < 2) && (!extendsEmitted && resolver.getNodeCheckFlags(node) & 8)) { + writeLines(extendsHelper); + extendsEmitted = true; + } + if (!decorateEmitted && resolver.getNodeCheckFlags(node) & 16) { + writeLines(decorateHelper); + if (compilerOptions.emitDecoratorMetadata) { + writeLines(metadataHelper); + } + decorateEmitted = true; + } + if (!paramEmitted && resolver.getNodeCheckFlags(node) & 32) { + writeLines(paramHelper); + paramEmitted = true; + } + if (!awaiterEmitted && resolver.getNodeCheckFlags(node) & 64) { + writeLines(awaiterHelper); + awaiterEmitted = true; + } + } + } + function emitSourceFileNode(node) { + writeLine(); + emitShebang(); + emitDetachedComments(node); + if (ts.isExternalModule(node) || compilerOptions.isolatedModules) { + var emitModule = moduleEmitDelegates[modulekind] || moduleEmitDelegates[1]; + emitModule(node); + } + else { + var startIndex = emitDirectivePrologues(node.statements, false); + externalImports = undefined; + exportSpecifiers = undefined; + exportEquals = undefined; + hasExportStars = false; + emitEmitHelpers(node); + emitCaptureThisForNodeIfNecessary(node); + emitLinesStartingAt(node.statements, startIndex); + emitTempDeclarations(true); + } + emitLeadingComments(node.endOfFileToken); + } + function emitNodeWithCommentsAndWithoutSourcemap(node) { + emitNodeConsideringCommentsOption(node, emitNodeWithoutSourceMap); + } + function emitNodeConsideringCommentsOption(node, emitNodeConsideringSourcemap) { + if (node) { + if (node.flags & 2) { + return emitCommentsOnNotEmittedNode(node); + } + if (isSpecializedCommentHandling(node)) { + return emitNodeWithoutSourceMap(node); + } + var emitComments_1 = shouldEmitLeadingAndTrailingComments(node); + if (emitComments_1) { + emitLeadingComments(node); + } + emitNodeConsideringSourcemap(node); + if (emitComments_1) { + emitTrailingComments(node); + } + } + } + function emitNodeWithoutSourceMap(node) { + if (node) { + emitJavaScriptWorker(node); + } + } + function isSpecializedCommentHandling(node) { + switch (node.kind) { + case 215: + case 213: + case 222: + case 221: + case 216: + case 227: + return true; + } + } + function shouldEmitLeadingAndTrailingComments(node) { + switch (node.kind) { + case 193: + return shouldEmitLeadingAndTrailingCommentsForVariableStatement(node); + case 218: + return shouldEmitModuleDeclaration(node); + case 217: + return shouldEmitEnumDeclaration(node); + } + ts.Debug.assert(!isSpecializedCommentHandling(node)); + if (node.kind !== 192 && + node.parent && + node.parent.kind === 174 && + node.parent.body === node && + compilerOptions.target <= 1) { + return false; + } + return true; + } + function emitJavaScriptWorker(node) { + switch (node.kind) { + case 69: + return emitIdentifier(node); + case 138: + return emitParameter(node); + case 143: + case 142: + return emitMethod(node); + case 145: + case 146: + return emitAccessor(node); + case 97: + return emitThis(node); + case 95: + return emitSuper(node); + case 93: + return write("null"); + case 99: + return write("true"); + case 84: + return write("false"); + case 8: + case 9: + case 10: + case 11: + case 12: + case 13: + case 14: + return emitLiteral(node); + case 183: + return emitTemplateExpression(node); + case 190: + return emitTemplateSpan(node); + case 233: + case 234: + return emitJsxElement(node); + case 236: + return emitJsxText(node); + case 240: + return emitJsxExpression(node); + case 135: + return emitQualifiedName(node); + case 161: + return emitObjectBindingPattern(node); + case 162: + return emitArrayBindingPattern(node); + case 163: + return emitBindingElement(node); + case 164: + return emitArrayLiteral(node); + case 165: + return emitObjectLiteral(node); + case 245: + return emitPropertyAssignment(node); + case 246: + return emitShorthandPropertyAssignment(node); + case 136: + return emitComputedPropertyName(node); + case 166: + return emitPropertyAccess(node); + case 167: + return emitIndexedAccess(node); + case 168: + return emitCallExpression(node); + case 169: + return emitNewExpression(node); + case 170: + return emitTaggedTemplateExpression(node); + case 171: + return emit(node.expression); + case 189: + return emit(node.expression); + case 172: + return emitParenExpression(node); + case 213: + case 173: + case 174: + return emitFunctionDeclaration(node); + case 175: + return emitDeleteExpression(node); + case 176: + return emitTypeOfExpression(node); + case 177: + return emitVoidExpression(node); + case 178: + return emitAwaitExpression(node); + case 179: + return emitPrefixUnaryExpression(node); + case 180: + return emitPostfixUnaryExpression(node); + case 181: + return emitBinaryExpression(node); + case 182: + return emitConditionalExpression(node); + case 185: + return emitSpreadElementExpression(node); + case 184: + return emitYieldExpression(node); + case 187: + return; + case 192: + case 219: + return emitBlock(node); + case 193: + return emitVariableStatement(node); + case 194: + return write(";"); + case 195: + return emitExpressionStatement(node); + case 196: + return emitIfStatement(node); + case 197: + return emitDoStatement(node); + case 198: + return emitWhileStatement(node); + case 199: + return emitForStatement(node); + case 201: + case 200: + return emitForInOrForOfStatement(node); + case 202: + case 203: + return emitBreakOrContinueStatement(node); + case 204: + return emitReturnStatement(node); + case 205: + return emitWithStatement(node); + case 206: + return emitSwitchStatement(node); + case 241: + case 242: + return emitCaseOrDefaultClause(node); + case 207: + return emitLabelledStatement(node); + case 208: + return emitThrowStatement(node); + case 209: + return emitTryStatement(node); + case 244: + return emitCatchClause(node); + case 210: + return emitDebuggerStatement(node); + case 211: + return emitVariableDeclaration(node); + case 186: + return emitClassExpression(node); + case 214: + return emitClassDeclaration(node); + case 215: + return emitInterfaceDeclaration(node); + case 217: + return emitEnumDeclaration(node); + case 247: + return emitEnumMember(node); + case 218: + return emitModuleDeclaration(node); + case 222: + return emitImportDeclaration(node); + case 221: + return emitImportEqualsDeclaration(node); + case 228: + return emitExportDeclaration(node); + case 227: + return emitExportAssignment(node); + case 248: + return emitSourceFileNode(node); + } + } + function hasDetachedComments(pos) { + return detachedCommentsInfo !== undefined && ts.lastOrUndefined(detachedCommentsInfo).nodePos === pos; + } + function getLeadingCommentsWithoutDetachedComments() { + var leadingComments = ts.getLeadingCommentRanges(currentSourceFile.text, ts.lastOrUndefined(detachedCommentsInfo).detachedCommentEndPos); + if (detachedCommentsInfo.length - 1) { + detachedCommentsInfo.pop(); + } + else { + detachedCommentsInfo = undefined; + } + return leadingComments; + } + function isPinnedComments(comment) { + return currentSourceFile.text.charCodeAt(comment.pos + 1) === 42 && + currentSourceFile.text.charCodeAt(comment.pos + 2) === 33; + } + function isTripleSlashComment(comment) { + if (currentSourceFile.text.charCodeAt(comment.pos + 1) === 47 && + comment.pos + 2 < comment.end && + currentSourceFile.text.charCodeAt(comment.pos + 2) === 47) { + var textSubStr = currentSourceFile.text.substring(comment.pos, comment.end); + return textSubStr.match(ts.fullTripleSlashReferencePathRegEx) || + textSubStr.match(ts.fullTripleSlashAMDReferencePathRegEx) ? + true : false; + } + return false; + } + function getLeadingCommentsToEmit(node) { + if (node.parent) { + if (node.parent.kind === 248 || node.pos !== node.parent.pos) { + if (hasDetachedComments(node.pos)) { + return getLeadingCommentsWithoutDetachedComments(); + } + else { + return ts.getLeadingCommentRangesOfNode(node, currentSourceFile); + } + } + } + } + function getTrailingCommentsToEmit(node) { + if (node.parent) { + if (node.parent.kind === 248 || node.end !== node.parent.end) { + return ts.getTrailingCommentRanges(currentSourceFile.text, node.end); + } + } + } + function emitCommentsOnNotEmittedNode(node) { + emitLeadingCommentsWorker(node, false); + } + function emitLeadingComments(node) { + return emitLeadingCommentsWorker(node, true); + } + function emitLeadingCommentsWorker(node, isEmittedNode) { + if (compilerOptions.removeComments) { + return; + } + var leadingComments; + if (isEmittedNode) { + leadingComments = getLeadingCommentsToEmit(node); + } + else { + if (node.pos === 0) { + leadingComments = ts.filter(getLeadingCommentsToEmit(node), isTripleSlashComment); + } + } + ts.emitNewLineBeforeLeadingComments(currentSourceFile, writer, node, leadingComments); + ts.emitComments(currentSourceFile, writer, leadingComments, true, newLine, writeComment); + } + function emitTrailingComments(node) { + if (compilerOptions.removeComments) { + return; + } + var trailingComments = getTrailingCommentsToEmit(node); + ts.emitComments(currentSourceFile, writer, trailingComments, false, newLine, writeComment); + } + function emitTrailingCommentsOfPosition(pos) { + if (compilerOptions.removeComments) { + return; + } + var trailingComments = ts.getTrailingCommentRanges(currentSourceFile.text, pos); + ts.emitComments(currentSourceFile, writer, trailingComments, true, newLine, writeComment); + } + function emitLeadingCommentsOfPositionWorker(pos) { + if (compilerOptions.removeComments) { + return; + } + var leadingComments; + if (hasDetachedComments(pos)) { + leadingComments = getLeadingCommentsWithoutDetachedComments(); + } + else { + leadingComments = ts.getLeadingCommentRanges(currentSourceFile.text, pos); + } + ts.emitNewLineBeforeLeadingComments(currentSourceFile, writer, { pos: pos, end: pos }, leadingComments); + ts.emitComments(currentSourceFile, writer, leadingComments, true, newLine, writeComment); + } + function emitDetachedComments(node) { + var leadingComments; + if (compilerOptions.removeComments) { + if (node.pos === 0) { + leadingComments = ts.filter(ts.getLeadingCommentRanges(currentSourceFile.text, node.pos), isPinnedComments); + } + } + else { + leadingComments = ts.getLeadingCommentRanges(currentSourceFile.text, node.pos); + } + if (leadingComments) { + var detachedComments = []; + var lastComment; + ts.forEach(leadingComments, function (comment) { + if (lastComment) { + var lastCommentLine = ts.getLineOfLocalPosition(currentSourceFile, lastComment.end); + var commentLine = ts.getLineOfLocalPosition(currentSourceFile, comment.pos); + if (commentLine >= lastCommentLine + 2) { + return detachedComments; + } + } + detachedComments.push(comment); + lastComment = comment; + }); + if (detachedComments.length) { + var lastCommentLine = ts.getLineOfLocalPosition(currentSourceFile, ts.lastOrUndefined(detachedComments).end); + var nodeLine = ts.getLineOfLocalPosition(currentSourceFile, ts.skipTrivia(currentSourceFile.text, node.pos)); + if (nodeLine >= lastCommentLine + 2) { + ts.emitNewLineBeforeLeadingComments(currentSourceFile, writer, node, leadingComments); + ts.emitComments(currentSourceFile, writer, detachedComments, true, newLine, writeComment); + var currentDetachedCommentInfo = { nodePos: node.pos, detachedCommentEndPos: ts.lastOrUndefined(detachedComments).end }; + if (detachedCommentsInfo) { + detachedCommentsInfo.push(currentDetachedCommentInfo); + } + else { + detachedCommentsInfo = [currentDetachedCommentInfo]; + } + } + } + } + } + function emitShebang() { + var shebang = ts.getShebang(currentSourceFile.text); + if (shebang) { + write(shebang); + } + } + var _a; + } + function emitFile(jsFilePath, sourceFile) { + emitJavaScript(jsFilePath, sourceFile); + if (compilerOptions.declaration) { + ts.writeDeclarationFile(jsFilePath, sourceFile, host, resolver, diagnostics); + } + } + } + ts.emitFiles = emitFiles; })(ts || (ts = {})); var ts; (function (ts) { @@ -29369,11 +29890,11 @@ var ts; if (ts.getRootLength(moduleName) !== 0 || nameStartsWithDotSlashOrDotDotSlash(moduleName)) { var failedLookupLocations = []; var candidate = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName)); - var resolvedFileName = loadNodeModuleFromFile(candidate, false, failedLookupLocations, host); + var resolvedFileName = loadNodeModuleFromFile(candidate, failedLookupLocations, host); if (resolvedFileName) { return { resolvedModule: { resolvedFileName: resolvedFileName }, failedLookupLocations: failedLookupLocations }; } - resolvedFileName = loadNodeModuleFromDirectory(candidate, false, failedLookupLocations, host); + resolvedFileName = loadNodeModuleFromDirectory(candidate, failedLookupLocations, host); return resolvedFileName ? { resolvedModule: { resolvedFileName: resolvedFileName }, failedLookupLocations: failedLookupLocations } : { resolvedModule: undefined, failedLookupLocations: failedLookupLocations }; @@ -29383,13 +29904,8 @@ var ts; } } ts.nodeModuleNameResolver = nodeModuleNameResolver; - function loadNodeModuleFromFile(candidate, loadOnlyDts, failedLookupLocation, host) { - if (loadOnlyDts) { - return tryLoad(".d.ts"); - } - else { - return ts.forEach(ts.supportedExtensions, tryLoad); - } + function loadNodeModuleFromFile(candidate, failedLookupLocation, host) { + return ts.forEach(ts.supportedJsExtensions, tryLoad); function tryLoad(ext) { var fileName = ts.fileExtensionIs(candidate, ext) ? candidate : candidate + ext; if (host.fileExists(fileName)) { @@ -29401,7 +29917,7 @@ var ts; } } } - function loadNodeModuleFromDirectory(candidate, loadOnlyDts, failedLookupLocation, host) { + function loadNodeModuleFromDirectory(candidate, failedLookupLocation, host) { var packageJsonPath = ts.combinePaths(candidate, "package.json"); if (host.fileExists(packageJsonPath)) { var jsonContent; @@ -29413,7 +29929,7 @@ var ts; jsonContent = { typings: undefined }; } if (jsonContent.typings) { - var result = loadNodeModuleFromFile(ts.normalizePath(ts.combinePaths(candidate, jsonContent.typings)), loadOnlyDts, failedLookupLocation, host); + var result = loadNodeModuleFromFile(ts.normalizePath(ts.combinePaths(candidate, jsonContent.typings)), failedLookupLocation, host); if (result) { return result; } @@ -29422,7 +29938,7 @@ var ts; else { failedLookupLocation.push(packageJsonPath); } - return loadNodeModuleFromFile(ts.combinePaths(candidate, "index"), loadOnlyDts, failedLookupLocation, host); + return loadNodeModuleFromFile(ts.combinePaths(candidate, "index"), failedLookupLocation, host); } function loadModuleFromNodeModules(moduleName, directory, host) { var failedLookupLocations = []; @@ -29432,11 +29948,11 @@ var ts; if (baseName !== "node_modules") { var nodeModulesFolder = ts.combinePaths(directory, "node_modules"); var candidate = ts.normalizePath(ts.combinePaths(nodeModulesFolder, moduleName)); - var result = loadNodeModuleFromFile(candidate, true, failedLookupLocations, host); + var result = loadNodeModuleFromFile(candidate, failedLookupLocations, host); if (result) { return { resolvedModule: { resolvedFileName: result, isExternalLibraryImport: true }, failedLookupLocations: failedLookupLocations }; } - result = loadNodeModuleFromDirectory(candidate, true, failedLookupLocations, host); + result = loadNodeModuleFromDirectory(candidate, failedLookupLocations, host); if (result) { return { resolvedModule: { resolvedFileName: result, isExternalLibraryImport: true }, failedLookupLocations: failedLookupLocations }; } @@ -29454,16 +29970,17 @@ var ts; return i === 0 || (i === 1 && name.charCodeAt(0) === 46); } function classicNameResolver(moduleName, containingFile, compilerOptions, host) { - if (moduleName.indexOf('!') != -1) { + if (moduleName.indexOf("!") != -1) { return { resolvedModule: undefined, failedLookupLocations: [] }; } var searchPath = ts.getDirectoryPath(containingFile); var searchName; var failedLookupLocations = []; var referencedSourceFile; + var extensions = compilerOptions.allowNonTsExtensions ? ts.supportedJsExtensions : ts.supportedExtensions; while (true) { searchName = ts.normalizePath(ts.combinePaths(searchPath, moduleName)); - referencedSourceFile = ts.forEach(ts.supportedExtensions, function (extension) { + referencedSourceFile = ts.forEach(extensions, function (extension) { if (extension === ".tsx" && !compilerOptions.jsx) { return undefined; } @@ -29763,7 +30280,7 @@ var ts; return emitResult; } function getSourceFile(fileName) { - return filesByName.get(fileName); + return filesByName.get(fileName) || filesByName.get(ts.getNormalizedAbsolutePath(fileName, host.getCurrentDirectory())); } function getDiagnosticsHelper(sourceFile, getDiagnostics, cancellationToken) { if (sourceFile) { @@ -29849,13 +30366,18 @@ var ts; if (file.imports) { return; } + var isJavaScriptFile = ts.isSourceFileJavaScript(file); var imports; for (var _i = 0, _a = file.statements; _i < _a.length; _i++) { var node = _a[_i]; + collect(node, true); + } + file.imports = imports || emptyArray; + function collect(node, allowRelativeModuleNames) { switch (node.kind) { - case 220: - case 219: - case 226: + case 222: + case 221: + case 228: var moduleNameExpr = ts.getExternalModuleName(node); if (!moduleNameExpr || moduleNameExpr.kind !== 9) { break; @@ -29863,24 +30385,35 @@ var ts; if (!moduleNameExpr.text) { break; } - (imports || (imports = [])).push(moduleNameExpr); + if (allowRelativeModuleNames || !ts.isExternalModuleNameRelative(moduleNameExpr.text)) { + (imports || (imports = [])).push(moduleNameExpr); + } break; - case 216: - if (node.name.kind === 9 && (node.flags & 2 || ts.isDeclarationFile(file))) { - ts.forEachChild(node.body, function (node) { - if (ts.isExternalModuleImportEqualsDeclaration(node) && - ts.getExternalModuleImportEqualsDeclarationExpression(node).kind === 9) { - var moduleName = ts.getExternalModuleImportEqualsDeclarationExpression(node); - if (moduleName) { - (imports || (imports = [])).push(moduleName); + case 168: + if (isJavaScriptFile && ts.isRequireCall(node)) { + var jsImports = node.arguments; + if (jsImports) { + imports = (imports || []); + for (var i = 0; i < jsImports.length; i++) { + if (jsImports[i].kind === 9) { + imports.push(jsImports[i]); } } + } + } + break; + case 218: + if (node.name.kind === 9 && (node.flags & 2 || ts.isDeclarationFile(file))) { + ts.forEachChild(node.body, function (node) { + collect(node, false); }); } break; } + if (ts.isSourceFileJavaScript(file)) { + ts.forEachChild(node, function (node) { return collect(node, allowRelativeModuleNames); }); + } } - file.imports = imports || emptyArray; } function processSourceFile(fileName, isDefaultLib, refFile, refPos, refEnd) { var diagnosticArgument; @@ -29923,48 +30456,46 @@ var ts; } } function findSourceFile(fileName, isDefaultLib, refFile, refPos, refEnd) { - var canonicalName = host.getCanonicalFileName(ts.normalizeSlashes(fileName)); - if (filesByName.contains(canonicalName)) { - return getSourceFileFromCache(fileName, canonicalName, false); + if (filesByName.contains(fileName)) { + return getSourceFileFromCache(fileName, false); } - else { - var normalizedAbsolutePath = ts.getNormalizedAbsolutePath(fileName, host.getCurrentDirectory()); - var canonicalAbsolutePath = host.getCanonicalFileName(normalizedAbsolutePath); - if (filesByName.contains(canonicalAbsolutePath)) { - return getSourceFileFromCache(normalizedAbsolutePath, canonicalAbsolutePath, true); - } - var file = host.getSourceFile(fileName, options.target, function (hostErrorMessage) { - if (refFile !== undefined && refPos !== undefined && refEnd !== undefined) { - fileProcessingDiagnostics.add(ts.createFileDiagnostic(refFile, refPos, refEnd - refPos, ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage)); - } - else { - fileProcessingDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage)); - } - }); - filesByName.set(canonicalName, file); - if (file) { - skipDefaultLib = skipDefaultLib || file.hasNoDefaultLib; - filesByName.set(canonicalAbsolutePath, file); - var basePath = ts.getDirectoryPath(fileName); - if (!options.noResolve) { - processReferencedFiles(file, basePath); - } - processImportedModules(file, basePath); - if (isDefaultLib) { - file.isDefaultLib = true; - files.unshift(file); - } - else { - files.push(file); - } - } - return file; + var normalizedAbsolutePath = ts.getNormalizedAbsolutePath(fileName, host.getCurrentDirectory()); + if (filesByName.contains(normalizedAbsolutePath)) { + var file_1 = getSourceFileFromCache(normalizedAbsolutePath, true); + filesByName.set(fileName, file_1); + return file_1; } - function getSourceFileFromCache(fileName, canonicalName, useAbsolutePath) { - var file = filesByName.get(canonicalName); + var file = host.getSourceFile(fileName, options.target, function (hostErrorMessage) { + if (refFile !== undefined && refPos !== undefined && refEnd !== undefined) { + fileProcessingDiagnostics.add(ts.createFileDiagnostic(refFile, refPos, refEnd - refPos, ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage)); + } + else { + fileProcessingDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage)); + } + }); + filesByName.set(fileName, file); + if (file) { + skipDefaultLib = skipDefaultLib || file.hasNoDefaultLib; + filesByName.set(normalizedAbsolutePath, file); + var basePath = ts.getDirectoryPath(fileName); + if (!options.noResolve) { + processReferencedFiles(file, basePath); + } + processImportedModules(file, basePath); + if (isDefaultLib) { + file.isDefaultLib = true; + files.unshift(file); + } + else { + files.push(file); + } + } + return file; + function getSourceFileFromCache(fileName, useAbsolutePath) { + var file = filesByName.get(fileName); if (file && host.useCaseSensitiveFileNames()) { var sourceFileName = useAbsolutePath ? ts.getNormalizedAbsolutePath(file.fileName, host.getCurrentDirectory()) : file.fileName; - if (canonicalName !== sourceFileName) { + if (ts.normalizeSlashes(fileName) !== ts.normalizeSlashes(sourceFileName)) { if (refFile !== undefined && refPos !== undefined && refEnd !== undefined) { fileProcessingDiagnostics.add(ts.createFileDiagnostic(refFile, refPos, refEnd - refPos, ts.Diagnostics.File_name_0_differs_from_already_included_file_name_1_only_in_casing, fileName, sourceFileName)); } @@ -30125,8 +30656,8 @@ var ts; var span = ts.getErrorSpanForNode(firstExternalModuleSourceFile, firstExternalModuleSourceFile.externalModuleIndicator); programDiagnostics.add(ts.createFileDiagnostic(firstExternalModuleSourceFile, span.start, span.length, ts.Diagnostics.Cannot_compile_modules_unless_the_module_flag_is_provided)); } - if (options.module && languageVersion >= 2) { - programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_compile_modules_into_commonjs_amd_system_or_umd_when_targeting_ES6_or_higher)); + if (options.module === 5 && languageVersion < 2) { + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_compile_modules_into_es6_when_targeting_ES5_or_lower)); } if (options.outDir || options.sourceRoot || @@ -30160,10 +30691,6 @@ var ts; !options.experimentalDecorators) { programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "emitDecoratorMetadata", "experimentalDecorators")); } - if (options.experimentalAsyncFunctions && - options.target !== 2) { - programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_experimentalAsyncFunctions_cannot_be_specified_when_targeting_ES5_or_lower)); - } } } ts.createProgram = createProgram; @@ -30240,11 +30767,12 @@ var ts; "commonjs": 1, "amd": 2, "system": 4, - "umd": 3 + "umd": 3, + "es6": 5 }, - description: ts.Diagnostics.Specify_module_code_generation_Colon_commonjs_amd_system_or_umd, + description: ts.Diagnostics.Specify_module_code_generation_Colon_commonjs_amd_system_umd_or_es6, paramType: ts.Diagnostics.KIND, - error: ts.Diagnostics.Argument_for_module_option_must_be_commonjs_amd_system_or_umd + error: ts.Diagnostics.Argument_for_module_option_must_be_commonjs_amd_system_umd_or_es6 }, { name: "newLine", @@ -30385,11 +30913,6 @@ var ts; type: "boolean", description: ts.Diagnostics.Watch_input_files }, - { - name: "experimentalAsyncFunctions", - type: "boolean", - description: ts.Diagnostics.Enables_experimental_support_for_ES7_async_functions - }, { name: "experimentalDecorators", type: "boolean", @@ -30576,6 +31099,9 @@ var ts; } if (opt.isFilePath) { value = ts.normalizePath(ts.combinePaths(basePath, value)); + if (value === "") { + value = "."; + } } options[opt.name] = value; } @@ -30604,20 +31130,20 @@ var ts; var exclude = json["exclude"] instanceof Array ? ts.map(json["exclude"], ts.normalizeSlashes) : undefined; var sysFiles = host.readDirectory(basePath, ".ts", exclude).concat(host.readDirectory(basePath, ".tsx", exclude)); for (var i = 0; i < sysFiles.length; i++) { - var name_27 = sysFiles[i]; - if (ts.fileExtensionIs(name_27, ".d.ts")) { - var baseName = name_27.substr(0, name_27.length - ".d.ts".length); + var name_28 = sysFiles[i]; + if (ts.fileExtensionIs(name_28, ".d.ts")) { + var baseName = name_28.substr(0, name_28.length - ".d.ts".length); if (!ts.contains(sysFiles, baseName + ".tsx") && !ts.contains(sysFiles, baseName + ".ts")) { - fileNames.push(name_27); + fileNames.push(name_28); } } - else if (ts.fileExtensionIs(name_27, ".ts")) { - if (!ts.contains(sysFiles, name_27 + "x")) { - fileNames.push(name_27); + else if (ts.fileExtensionIs(name_28, ".ts")) { + if (!ts.contains(sysFiles, name_28 + "x")) { + fileNames.push(name_28); } } else { - fileNames.push(name_27); + fileNames.push(name_28); } } } @@ -30701,6 +31227,15 @@ var ts; reportDiagnostic(diagnostics[i]); } } + function reportWatchDiagnostic(diagnostic) { + var output = new Date().toLocaleTimeString() + " - "; + if (diagnostic.file) { + var loc = ts.getLineAndCharacterOfPosition(diagnostic.file, diagnostic.start); + output += diagnostic.file.fileName + "(" + (loc.line + 1) + "," + (loc.character + 1) + "): "; + } + output += "" + ts.flattenDiagnosticMessageText(diagnostic.messageText, ts.sys.newLine) + ts.sys.newLine; + ts.sys.write(output); + } function padLeft(s, length) { while (s.length < length) { s = " " + s; @@ -30794,7 +31329,7 @@ var ts; if (configFileName) { var result = ts.readConfigFile(configFileName, ts.sys.readFile); if (result.error) { - reportDiagnostic(result.error); + reportWatchDiagnostic(result.error); return ts.sys.exit(ts.ExitStatus.DiagnosticsPresent_OutputsSkipped); } var configObject = result.config; @@ -30819,7 +31354,7 @@ var ts; return ts.sys.exit(compileResult.exitStatus); } setCachedProgram(compileResult.program); - reportDiagnostic(ts.createCompilerDiagnostic(ts.Diagnostics.Compilation_complete_Watching_for_file_changes)); + reportWatchDiagnostic(ts.createCompilerDiagnostic(ts.Diagnostics.Compilation_complete_Watching_for_file_changes)); } function getSourceFile(fileName, languageVersion, onError) { if (cachedProgram) { @@ -30830,7 +31365,7 @@ var ts; } var sourceFile = hostGetSourceFile(fileName, languageVersion, onError); if (sourceFile && compilerOptions.watch) { - sourceFile.fileWatcher = ts.sys.watchFile(sourceFile.fileName, function () { return sourceFileChanged(sourceFile); }); + sourceFile.fileWatcher = ts.sys.watchFile(sourceFile.fileName, function (fileName, removed) { return sourceFileChanged(sourceFile, removed); }); } return sourceFile; } @@ -30848,9 +31383,15 @@ var ts; } cachedProgram = program; } - function sourceFileChanged(sourceFile) { + function sourceFileChanged(sourceFile, removed) { sourceFile.fileWatcher.close(); sourceFile.fileWatcher = undefined; + if (removed) { + var index = rootFileNames.indexOf(sourceFile.fileName); + if (index >= 0) { + rootFileNames.splice(index, 1); + } + } startTimer(); } function configFileChanged() { @@ -30865,7 +31406,7 @@ var ts; } function recompile() { timerHandle = undefined; - reportDiagnostic(ts.createCompilerDiagnostic(ts.Diagnostics.File_change_detected_Starting_incremental_compilation)); + reportWatchDiagnostic(ts.createCompilerDiagnostic(ts.Diagnostics.File_change_detected_Starting_incremental_compilation)); performCompilation(); } } @@ -30993,7 +31534,7 @@ var ts; } function writeConfigFile(options, fileNames) { var currentDirectory = ts.sys.getCurrentDirectory(); - var file = ts.combinePaths(currentDirectory, 'tsconfig.json'); + var file = ts.combinePaths(currentDirectory, "tsconfig.json"); if (ts.sys.fileExists(file)) { reportDiagnostic(ts.createCompilerDiagnostic(ts.Diagnostics.A_tsconfig_json_file_is_already_defined_at_Colon_0, file)); } @@ -31013,10 +31554,10 @@ var ts; function serializeCompilerOptions(options) { var result = {}; var optionsNameMap = ts.getOptionNameMap().optionNameMap; - for (var name_28 in options) { - if (ts.hasProperty(options, name_28)) { - var value = options[name_28]; - switch (name_28) { + for (var name_29 in options) { + if (ts.hasProperty(options, name_29)) { + var value = options[name_29]; + switch (name_29) { case "init": case "watch": case "version": @@ -31024,17 +31565,17 @@ var ts; case "project": break; default: - var optionDefinition = optionsNameMap[name_28.toLowerCase()]; + var optionDefinition = optionsNameMap[name_29.toLowerCase()]; if (optionDefinition) { if (typeof optionDefinition.type === "string") { - result[name_28] = value; + result[name_29] = value; } else { var typeMap = optionDefinition.type; for (var key in typeMap) { if (ts.hasProperty(typeMap, key)) { if (typeMap[key] === value) - result[name_28] = key; + result[name_29] = key; } } } diff --git a/lib/tsserver.js b/lib/tsserver.js index 82199e1222d..0368e826f13 100644 --- a/lib/tsserver.js +++ b/lib/tsserver.js @@ -410,8 +410,11 @@ var ts; } ts.chainDiagnosticMessages = chainDiagnosticMessages; function concatenateDiagnosticMessageChains(headChain, tailChain) { - Debug.assert(!headChain.next); - headChain.next = tailChain; + var lastChain = headChain; + while (lastChain.next) { + lastChain = lastChain.next; + } + lastChain.next = tailChain; return headChain; } ts.concatenateDiagnosticMessageChains = concatenateDiagnosticMessageChains; @@ -650,6 +653,7 @@ var ts; } ts.fileExtensionIs = fileExtensionIs; ts.supportedExtensions = [".ts", ".tsx", ".d.ts"]; + ts.supportedJsExtensions = ts.supportedExtensions.concat(".js", ".jsx"); var extensionsToRemove = [".d.ts", ".ts", ".js", ".tsx", ".jsx"]; function removeFileExtension(path) { for (var _i = 0; _i < extensionsToRemove.length; _i++) { @@ -949,10 +953,14 @@ var ts; close: function () { _fs.unwatchFile(fileName, fileChanged); } }; function fileChanged(curr, prev) { + if (curr.mtime.getTime() === 0) { + callback(fileName, true); + return; + } if (+curr.mtime <= +prev.mtime) { return; } - callback(fileName); + callback(fileName, false); } }, resolvePath: function (path) { @@ -1050,7 +1058,7 @@ var ts; Enum_member_must_have_initializer: { code: 1061, category: ts.DiagnosticCategory.Error, key: "Enum member must have initializer." }, _0_is_referenced_directly_or_indirectly_in_the_fulfillment_callback_of_its_own_then_method: { code: 1062, category: ts.DiagnosticCategory.Error, key: "{0} is referenced directly or indirectly in the fulfillment callback of its own 'then' method." }, An_export_assignment_cannot_be_used_in_a_namespace: { code: 1063, category: ts.DiagnosticCategory.Error, key: "An export assignment cannot be used in a namespace." }, - Ambient_enum_elements_can_only_have_integer_literal_initializers: { code: 1066, category: ts.DiagnosticCategory.Error, key: "Ambient enum elements can only have integer literal initializers." }, + In_ambient_enum_declarations_member_initializer_must_be_constant_expression: { code: 1066, category: ts.DiagnosticCategory.Error, key: "In ambient enum declarations member initializer must be constant expression." }, Unexpected_token_A_constructor_method_accessor_or_property_was_expected: { code: 1068, category: ts.DiagnosticCategory.Error, key: "Unexpected token. A constructor, method, accessor, or property was expected." }, A_0_modifier_cannot_be_used_with_an_import_declaration: { code: 1079, category: ts.DiagnosticCategory.Error, key: "A '{0}' modifier cannot be used with an import declaration." }, Invalid_reference_directive_syntax: { code: 1084, category: ts.DiagnosticCategory.Error, key: "Invalid 'reference' directive syntax." }, @@ -1138,7 +1146,7 @@ var ts; Property_destructuring_pattern_expected: { code: 1180, category: ts.DiagnosticCategory.Error, key: "Property destructuring pattern expected." }, Array_element_destructuring_pattern_expected: { code: 1181, category: ts.DiagnosticCategory.Error, key: "Array element destructuring pattern expected." }, A_destructuring_declaration_must_have_an_initializer: { code: 1182, category: ts.DiagnosticCategory.Error, key: "A destructuring declaration must have an initializer." }, - An_implementation_cannot_be_declared_in_ambient_contexts: { code: 1184, category: ts.DiagnosticCategory.Error, key: "An implementation cannot be declared in ambient contexts." }, + An_implementation_cannot_be_declared_in_ambient_contexts: { code: 1183, category: ts.DiagnosticCategory.Error, key: "An implementation cannot be declared in ambient contexts." }, Modifiers_cannot_appear_here: { code: 1184, category: ts.DiagnosticCategory.Error, key: "Modifiers cannot appear here." }, Merge_conflict_marker_encountered: { code: 1185, category: ts.DiagnosticCategory.Error, key: "Merge conflict marker encountered." }, A_rest_element_cannot_have_an_initializer: { code: 1186, category: ts.DiagnosticCategory.Error, key: "A rest element cannot have an initializer." }, @@ -1156,10 +1164,9 @@ var ts; An_extended_Unicode_escape_value_must_be_between_0x0_and_0x10FFFF_inclusive: { code: 1198, category: ts.DiagnosticCategory.Error, key: "An extended Unicode escape value must be between 0x0 and 0x10FFFF inclusive." }, Unterminated_Unicode_escape_sequence: { code: 1199, category: ts.DiagnosticCategory.Error, key: "Unterminated Unicode escape sequence." }, Line_terminator_not_permitted_before_arrow: { code: 1200, category: ts.DiagnosticCategory.Error, key: "Line terminator not permitted before arrow." }, - Import_assignment_cannot_be_used_when_targeting_ECMAScript_6_or_higher_Consider_using_import_Asterisk_as_ns_from_mod_import_a_from_mod_or_import_d_from_mod_instead: { code: 1202, category: ts.DiagnosticCategory.Error, key: "Import assignment cannot be used when targeting ECMAScript 6 or higher. Consider using 'import * as ns from \"mod\"', 'import {a} from \"mod\"' or 'import d from \"mod\"' instead." }, - Export_assignment_cannot_be_used_when_targeting_ECMAScript_6_or_higher_Consider_using_export_default_instead: { code: 1203, category: ts.DiagnosticCategory.Error, key: "Export assignment cannot be used when targeting ECMAScript 6 or higher. Consider using 'export default' instead." }, - Cannot_compile_modules_into_commonjs_amd_system_or_umd_when_targeting_ES6_or_higher: { code: 1204, category: ts.DiagnosticCategory.Error, key: "Cannot compile modules into 'commonjs', 'amd', 'system' or 'umd' when targeting 'ES6' or higher." }, - Decorators_are_only_available_when_targeting_ECMAScript_5_and_higher: { code: 1205, category: ts.DiagnosticCategory.Error, key: "Decorators are only available when targeting ECMAScript 5 and higher." }, + Import_assignment_cannot_be_used_when_targeting_ECMAScript_6_modules_Consider_using_import_Asterisk_as_ns_from_mod_import_a_from_mod_import_d_from_mod_or_another_module_format_instead: { code: 1202, category: ts.DiagnosticCategory.Error, key: "Import assignment cannot be used when targeting ECMAScript 6 modules. Consider using 'import * as ns from \"mod\"', 'import {a} from \"mod\"', 'import d from \"mod\"', or another module format instead." }, + Export_assignment_cannot_be_used_when_targeting_ECMAScript_6_modules_Consider_using_export_default_or_another_module_format_instead: { code: 1203, category: ts.DiagnosticCategory.Error, key: "Export assignment cannot be used when targeting ECMAScript 6 modules. Consider using 'export default' or another module format instead." }, + Cannot_compile_modules_into_es6_when_targeting_ES5_or_lower: { code: 1204, category: ts.DiagnosticCategory.Error, key: "Cannot compile modules into 'es6' when targeting 'ES5' or lower." }, Decorators_are_not_valid_here: { code: 1206, category: ts.DiagnosticCategory.Error, key: "Decorators are not valid here." }, Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name: { code: 1207, category: ts.DiagnosticCategory.Error, key: "Decorators cannot be applied to multiple get/set accessors of the same name." }, Cannot_compile_namespaces_when_the_isolatedModules_flag_is_provided: { code: 1208, category: ts.DiagnosticCategory.Error, key: "Cannot compile namespaces when the '--isolatedModules' flag is provided." }, @@ -1188,10 +1195,6 @@ var ts; An_export_declaration_can_only_be_used_in_a_module: { code: 1233, category: ts.DiagnosticCategory.Error, key: "An export declaration can only be used in a module." }, An_ambient_module_declaration_is_only_allowed_at_the_top_level_in_a_file: { code: 1234, category: ts.DiagnosticCategory.Error, key: "An ambient module declaration is only allowed at the top level in a file." }, A_namespace_declaration_is_only_allowed_in_a_namespace_or_module: { code: 1235, category: ts.DiagnosticCategory.Error, key: "A namespace declaration is only allowed in a namespace or module." }, - Experimental_support_for_async_functions_is_a_feature_that_is_subject_to_change_in_a_future_release_Specify_experimentalAsyncFunctions_to_remove_this_warning: { code: 1236, category: ts.DiagnosticCategory.Error, key: "Experimental support for async functions is a feature that is subject to change in a future release. Specify '--experimentalAsyncFunctions' to remove this warning." }, - with_statements_are_not_allowed_in_an_async_function_block: { code: 1300, category: ts.DiagnosticCategory.Error, key: "'with' statements are not allowed in an async function block." }, - await_expression_is_only_allowed_within_an_async_function: { code: 1308, category: ts.DiagnosticCategory.Error, key: "'await' expression is only allowed within an async function." }, - Async_functions_are_only_available_when_targeting_ECMAScript_6_and_higher: { code: 1311, category: ts.DiagnosticCategory.Error, key: "Async functions are only available when targeting ECMAScript 6 and higher." }, The_return_type_of_a_property_decorator_function_must_be_either_void_or_any: { code: 1236, category: ts.DiagnosticCategory.Error, key: "The return type of a property decorator function must be either 'void' or 'any'." }, The_return_type_of_a_parameter_decorator_function_must_be_either_void_or_any: { code: 1237, category: ts.DiagnosticCategory.Error, key: "The return type of a parameter decorator function must be either 'void' or 'any'." }, Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression: { code: 1238, category: ts.DiagnosticCategory.Error, key: "Unable to resolve signature of class decorator when called as an expression." }, @@ -1202,6 +1205,10 @@ var ts; _0_modifier_cannot_be_used_with_1_modifier: { code: 1243, category: ts.DiagnosticCategory.Error, key: "'{0}' modifier cannot be used with '{1}' modifier." }, Abstract_methods_can_only_appear_within_an_abstract_class: { code: 1244, category: ts.DiagnosticCategory.Error, key: "Abstract methods can only appear within an abstract class." }, Method_0_cannot_have_an_implementation_because_it_is_marked_abstract: { code: 1245, category: ts.DiagnosticCategory.Error, key: "Method '{0}' cannot have an implementation because it is marked abstract." }, + with_statements_are_not_allowed_in_an_async_function_block: { code: 1300, category: ts.DiagnosticCategory.Error, key: "'with' statements are not allowed in an async function block." }, + await_expression_is_only_allowed_within_an_async_function: { code: 1308, category: ts.DiagnosticCategory.Error, key: "'await' expression is only allowed within an async function." }, + Async_functions_are_only_available_when_targeting_ECMAScript_6_and_higher: { code: 1311, category: ts.DiagnosticCategory.Error, key: "Async functions are only available when targeting ECMAScript 6 and higher." }, + can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment: { code: 1312, category: ts.DiagnosticCategory.Error, key: "'=' can only be used in an object literal property inside a destructuring assignment." }, Duplicate_identifier_0: { code: 2300, category: ts.DiagnosticCategory.Error, key: "Duplicate identifier '{0}'." }, Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor: { code: 2301, category: ts.DiagnosticCategory.Error, key: "Initializer of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor." }, Static_members_cannot_reference_class_type_parameters: { code: 2302, category: ts.DiagnosticCategory.Error, key: "Static members cannot reference class type parameters." }, @@ -1326,7 +1333,7 @@ var ts; In_an_enum_with_multiple_declarations_only_one_declaration_can_omit_an_initializer_for_its_first_enum_element: { code: 2432, category: ts.DiagnosticCategory.Error, key: "In an enum with multiple declarations, only one declaration can omit an initializer for its first enum element." }, A_namespace_declaration_cannot_be_in_a_different_file_from_a_class_or_function_with_which_it_is_merged: { code: 2433, category: ts.DiagnosticCategory.Error, key: "A namespace declaration cannot be in a different file from a class or function with which it is merged" }, A_namespace_declaration_cannot_be_located_prior_to_a_class_or_function_with_which_it_is_merged: { code: 2434, category: ts.DiagnosticCategory.Error, key: "A namespace declaration cannot be located prior to a class or function with which it is merged" }, - Ambient_modules_cannot_be_nested_in_other_modules: { code: 2435, category: ts.DiagnosticCategory.Error, key: "Ambient modules cannot be nested in other modules." }, + Ambient_modules_cannot_be_nested_in_other_modules_or_namespaces: { code: 2435, category: ts.DiagnosticCategory.Error, key: "Ambient modules cannot be nested in other modules or namespaces." }, Ambient_module_declaration_cannot_specify_relative_module_name: { code: 2436, category: ts.DiagnosticCategory.Error, key: "Ambient module declaration cannot specify relative module name." }, Module_0_is_hidden_by_a_local_declaration_with_the_same_name: { code: 2437, category: ts.DiagnosticCategory.Error, key: "Module '{0}' is hidden by a local declaration with the same name" }, Import_name_cannot_be_0: { code: 2438, category: ts.DiagnosticCategory.Error, key: "Import name cannot be '{0}'" }, @@ -1414,6 +1421,9 @@ var ts; yield_expressions_cannot_be_used_in_a_parameter_initializer: { code: 2523, category: ts.DiagnosticCategory.Error, key: "'yield' expressions cannot be used in a parameter initializer." }, await_expressions_cannot_be_used_in_a_parameter_initializer: { code: 2524, category: ts.DiagnosticCategory.Error, key: "'await' expressions cannot be used in a parameter initializer." }, Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value: { code: 2525, category: ts.DiagnosticCategory.Error, key: "Initializer provides no value for this binding element and the binding element has no default value." }, + A_this_type_is_available_only_in_a_non_static_member_of_a_class_or_interface: { code: 2526, category: ts.DiagnosticCategory.Error, key: "A 'this' type is available only in a non-static member of a class or interface." }, + The_inferred_type_of_0_references_an_inaccessible_this_type_A_type_annotation_is_necessary: { code: 2527, category: ts.DiagnosticCategory.Error, key: "The inferred type of '{0}' references an inaccessible 'this' type. A type annotation is necessary." }, + A_module_cannot_have_multiple_default_exports: { code: 2528, category: ts.DiagnosticCategory.Error, key: "A module cannot have multiple default exports." }, JSX_element_attributes_type_0_must_be_an_object_type: { code: 2600, category: ts.DiagnosticCategory.Error, key: "JSX element attributes type '{0}' must be an object type." }, The_return_type_of_a_JSX_element_constructor_must_return_an_object_type: { code: 2601, category: ts.DiagnosticCategory.Error, key: "The return type of a JSX element constructor must return an object type." }, JSX_element_implicitly_has_type_any_because_the_global_type_JSX_Element_does_not_exist: { code: 2602, category: ts.DiagnosticCategory.Error, key: "JSX element implicitly has type 'any' because the global type 'JSX.Element' does not exist." }, @@ -1514,7 +1524,7 @@ var ts; Option_inlineSources_can_only_be_used_when_either_option_inlineSourceMap_or_option_sourceMap_is_provided: { code: 5051, category: ts.DiagnosticCategory.Error, key: "Option 'inlineSources' can only be used when either option '--inlineSourceMap' or option '--sourceMap' is provided." }, Option_0_cannot_be_specified_without_specifying_option_1: { code: 5052, category: ts.DiagnosticCategory.Error, key: "Option '{0}' cannot be specified without specifying option '{1}'." }, Option_0_cannot_be_specified_with_option_1: { code: 5053, category: ts.DiagnosticCategory.Error, key: "Option '{0}' cannot be specified with option '{1}'." }, - A_tsconfig_json_file_is_already_defined_at_Colon_0: { code: 5053, category: ts.DiagnosticCategory.Error, key: "A 'tsconfig.json' file is already defined at: '{0}'." }, + A_tsconfig_json_file_is_already_defined_at_Colon_0: { code: 5054, category: ts.DiagnosticCategory.Error, key: "A 'tsconfig.json' file is already defined at: '{0}'." }, Concatenate_and_emit_output_to_single_file: { code: 6001, category: ts.DiagnosticCategory.Message, key: "Concatenate and emit output to single file." }, Generates_corresponding_d_ts_file: { code: 6002, category: ts.DiagnosticCategory.Message, key: "Generates corresponding '.d.ts' file." }, Specifies_the_location_where_debugger_should_locate_map_files_instead_of_generated_locations: { code: 6003, category: ts.DiagnosticCategory.Message, key: "Specifies the location where debugger should locate map files instead of generated locations." }, @@ -1526,7 +1536,7 @@ var ts; Do_not_emit_comments_to_output: { code: 6009, category: ts.DiagnosticCategory.Message, key: "Do not emit comments to output." }, Do_not_emit_outputs: { code: 6010, category: ts.DiagnosticCategory.Message, key: "Do not emit outputs." }, Specify_ECMAScript_target_version_Colon_ES3_default_ES5_or_ES6_experimental: { code: 6015, category: ts.DiagnosticCategory.Message, key: "Specify ECMAScript target version: 'ES3' (default), 'ES5', or 'ES6' (experimental)" }, - Specify_module_code_generation_Colon_commonjs_amd_system_or_umd: { code: 6016, category: ts.DiagnosticCategory.Message, key: "Specify module code generation: 'commonjs', 'amd', 'system' or 'umd'" }, + Specify_module_code_generation_Colon_commonjs_amd_system_umd_or_es6: { code: 6016, category: ts.DiagnosticCategory.Message, key: "Specify module code generation: 'commonjs', 'amd', 'system', 'umd' or 'es6'" }, Print_this_message: { code: 6017, category: ts.DiagnosticCategory.Message, key: "Print this message." }, Print_the_compiler_s_version: { code: 6019, category: ts.DiagnosticCategory.Message, key: "Print the compiler's version." }, Compile_the_project_in_the_given_directory: { code: 6020, category: ts.DiagnosticCategory.Message, key: "Compile the project in the given directory." }, @@ -1547,7 +1557,7 @@ var ts; Generates_corresponding_map_file: { code: 6043, category: ts.DiagnosticCategory.Message, key: "Generates corresponding '.map' file." }, Compiler_option_0_expects_an_argument: { code: 6044, category: ts.DiagnosticCategory.Error, key: "Compiler option '{0}' expects an argument." }, Unterminated_quoted_string_in_response_file_0: { code: 6045, category: ts.DiagnosticCategory.Error, key: "Unterminated quoted string in response file '{0}'." }, - Argument_for_module_option_must_be_commonjs_amd_system_or_umd: { code: 6046, category: ts.DiagnosticCategory.Error, key: "Argument for '--module' option must be 'commonjs', 'amd', 'system' or 'umd'." }, + Argument_for_module_option_must_be_commonjs_amd_system_umd_or_es6: { code: 6046, category: ts.DiagnosticCategory.Error, key: "Argument for '--module' option must be 'commonjs', 'amd', 'system', 'umd', or 'es6'." }, Argument_for_target_option_must_be_ES3_ES5_or_ES6: { code: 6047, category: ts.DiagnosticCategory.Error, key: "Argument for '--target' option must be 'ES3', 'ES5', or 'ES6'." }, Locale_must_be_of_the_form_language_or_language_territory_For_example_0_or_1: { code: 6048, category: ts.DiagnosticCategory.Error, key: "Locale must be of the form or -. For example '{0}' or '{1}'." }, Unsupported_locale_0: { code: 6049, category: ts.DiagnosticCategory.Error, key: "Unsupported locale '{0}'." }, @@ -1568,7 +1578,6 @@ var ts; Argument_for_jsx_must_be_preserve_or_react: { code: 6081, category: ts.DiagnosticCategory.Message, key: "Argument for '--jsx' must be 'preserve' or 'react'." }, Enables_experimental_support_for_ES7_decorators: { code: 6065, category: ts.DiagnosticCategory.Message, key: "Enables experimental support for ES7 decorators." }, Enables_experimental_support_for_emitting_type_metadata_for_decorators: { code: 6066, category: ts.DiagnosticCategory.Message, key: "Enables experimental support for emitting type metadata for decorators." }, - Option_experimentalAsyncFunctions_cannot_be_specified_when_targeting_ES5_or_lower: { code: 6067, category: ts.DiagnosticCategory.Message, key: "Option 'experimentalAsyncFunctions' cannot be specified when targeting ES5 or lower." }, Enables_experimental_support_for_ES7_async_functions: { code: 6068, category: ts.DiagnosticCategory.Message, key: "Enables experimental support for ES7 async functions." }, Specifies_module_resolution_strategy_Colon_node_Node_js_or_classic_TypeScript_pre_1_6: { code: 6069, category: ts.DiagnosticCategory.Message, key: "Specifies module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6)." }, Initializes_a_TypeScript_project_and_creates_a_tsconfig_json_file: { code: 6070, category: ts.DiagnosticCategory.Message, key: "Initializes a TypeScript project and creates a tsconfig.json file." }, @@ -1615,81 +1624,83 @@ var ts; Expected_corresponding_JSX_closing_tag_for_0: { code: 17002, category: ts.DiagnosticCategory.Error, key: "Expected corresponding JSX closing tag for '{0}'." }, JSX_attribute_expected: { code: 17003, category: ts.DiagnosticCategory.Error, key: "JSX attribute expected." }, Cannot_use_JSX_unless_the_jsx_flag_is_provided: { code: 17004, category: ts.DiagnosticCategory.Error, key: "Cannot use JSX unless the '--jsx' flag is provided." }, - A_constructor_cannot_contain_a_super_call_when_its_class_extends_null: { code: 17005, category: ts.DiagnosticCategory.Error, key: "A constructor cannot contain a 'super' call when its class extends 'null'" } + A_constructor_cannot_contain_a_super_call_when_its_class_extends_null: { code: 17005, category: ts.DiagnosticCategory.Error, key: "A constructor cannot contain a 'super' call when its class extends 'null'" }, + An_unary_expression_with_the_0_operator_is_not_allowed_in_the_left_hand_side_of_an_exponentiation_expression_Consider_enclosing_the_expression_in_parentheses: { code: 17006, category: ts.DiagnosticCategory.Error, key: "An unary expression with the '{0}' operator is not allowed in the left-hand side of an exponentiation expression. Consider enclosing the expression in parentheses." }, + A_type_assertion_expression_is_not_allowed_in_the_left_hand_side_of_an_exponentiation_expression_Consider_enclosing_the_expression_in_parentheses: { code: 17007, category: ts.DiagnosticCategory.Error, key: "A type assertion expression is not allowed in the left-hand side of an exponentiation expression. Consider enclosing the expression in parentheses." } }; })(ts || (ts = {})); var ts; (function (ts) { function tokenIsIdentifierOrKeyword(token) { - return token >= 67; + return token >= 69; } ts.tokenIsIdentifierOrKeyword = tokenIsIdentifierOrKeyword; var textToToken = { - "abstract": 113, - "any": 115, - "as": 114, - "boolean": 118, - "break": 68, - "case": 69, - "catch": 70, - "class": 71, - "continue": 73, - "const": 72, - "constructor": 119, - "debugger": 74, - "declare": 120, - "default": 75, - "delete": 76, - "do": 77, - "else": 78, - "enum": 79, - "export": 80, - "extends": 81, - "false": 82, - "finally": 83, - "for": 84, - "from": 131, - "function": 85, - "get": 121, - "if": 86, - "implements": 104, - "import": 87, - "in": 88, - "instanceof": 89, - "interface": 105, - "is": 122, - "let": 106, - "module": 123, - "namespace": 124, - "new": 90, - "null": 91, - "number": 126, - "package": 107, - "private": 108, - "protected": 109, - "public": 110, - "require": 125, - "return": 92, - "set": 127, - "static": 111, - "string": 128, - "super": 93, - "switch": 94, - "symbol": 129, - "this": 95, - "throw": 96, - "true": 97, - "try": 98, - "type": 130, - "typeof": 99, - "var": 100, - "void": 101, - "while": 102, - "with": 103, - "yield": 112, - "async": 116, - "await": 117, - "of": 132, + "abstract": 115, + "any": 117, + "as": 116, + "boolean": 120, + "break": 70, + "case": 71, + "catch": 72, + "class": 73, + "continue": 75, + "const": 74, + "constructor": 121, + "debugger": 76, + "declare": 122, + "default": 77, + "delete": 78, + "do": 79, + "else": 80, + "enum": 81, + "export": 82, + "extends": 83, + "false": 84, + "finally": 85, + "for": 86, + "from": 133, + "function": 87, + "get": 123, + "if": 88, + "implements": 106, + "import": 89, + "in": 90, + "instanceof": 91, + "interface": 107, + "is": 124, + "let": 108, + "module": 125, + "namespace": 126, + "new": 92, + "null": 93, + "number": 128, + "package": 109, + "private": 110, + "protected": 111, + "public": 112, + "require": 127, + "return": 94, + "set": 129, + "static": 113, + "string": 130, + "super": 95, + "switch": 96, + "symbol": 131, + "this": 97, + "throw": 98, + "true": 99, + "try": 100, + "type": 132, + "typeof": 101, + "var": 102, + "void": 103, + "while": 104, + "with": 105, + "yield": 114, + "async": 118, + "await": 119, + "of": 134, "{": 15, "}": 16, "(": 17, @@ -1711,37 +1722,39 @@ var ts; "=>": 34, "+": 35, "-": 36, + "**": 38, "*": 37, - "/": 38, - "%": 39, - "++": 40, - "--": 41, - "<<": 42, + "/": 39, + "%": 40, + "++": 41, + "--": 42, + "<<": 43, ">": 43, - ">>>": 44, - "&": 45, - "|": 46, - "^": 47, - "!": 48, - "~": 49, - "&&": 50, - "||": 51, - "?": 52, - ":": 53, - "=": 55, - "+=": 56, - "-=": 57, - "*=": 58, - "/=": 59, - "%=": 60, - "<<=": 61, - ">>=": 62, - ">>>=": 63, - "&=": 64, - "|=": 65, - "^=": 66, - "@": 54 + ">>": 44, + ">>>": 45, + "&": 46, + "|": 47, + "^": 48, + "!": 49, + "~": 50, + "&&": 51, + "||": 52, + "?": 53, + ":": 54, + "=": 56, + "+=": 57, + "-=": 58, + "*=": 59, + "**=": 60, + "/=": 61, + "%=": 62, + "<<=": 63, + ">>=": 64, + ">>>=": 65, + "&=": 66, + "|=": 67, + "^=": 68, + "@": 55 }; var unicodeES3IdentifierStart = [170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 543, 546, 563, 592, 685, 688, 696, 699, 705, 720, 721, 736, 740, 750, 750, 890, 890, 902, 902, 904, 906, 908, 908, 910, 929, 931, 974, 976, 983, 986, 1011, 1024, 1153, 1164, 1220, 1223, 1224, 1227, 1228, 1232, 1269, 1272, 1273, 1329, 1366, 1369, 1369, 1377, 1415, 1488, 1514, 1520, 1522, 1569, 1594, 1600, 1610, 1649, 1747, 1749, 1749, 1765, 1766, 1786, 1788, 1808, 1808, 1810, 1836, 1920, 1957, 2309, 2361, 2365, 2365, 2384, 2384, 2392, 2401, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2524, 2525, 2527, 2529, 2544, 2545, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2649, 2652, 2654, 2654, 2674, 2676, 2693, 2699, 2701, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2749, 2749, 2768, 2768, 2784, 2784, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2870, 2873, 2877, 2877, 2908, 2909, 2911, 2913, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 2997, 2999, 3001, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3123, 3125, 3129, 3168, 3169, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3294, 3294, 3296, 3297, 3333, 3340, 3342, 3344, 3346, 3368, 3370, 3385, 3424, 3425, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3585, 3632, 3634, 3635, 3648, 3654, 3713, 3714, 3716, 3716, 3719, 3720, 3722, 3722, 3725, 3725, 3732, 3735, 3737, 3743, 3745, 3747, 3749, 3749, 3751, 3751, 3754, 3755, 3757, 3760, 3762, 3763, 3773, 3773, 3776, 3780, 3782, 3782, 3804, 3805, 3840, 3840, 3904, 3911, 3913, 3946, 3976, 3979, 4096, 4129, 4131, 4135, 4137, 4138, 4176, 4181, 4256, 4293, 4304, 4342, 4352, 4441, 4447, 4514, 4520, 4601, 4608, 4614, 4616, 4678, 4680, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4742, 4744, 4744, 4746, 4749, 4752, 4782, 4784, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4814, 4816, 4822, 4824, 4846, 4848, 4878, 4880, 4880, 4882, 4885, 4888, 4894, 4896, 4934, 4936, 4954, 5024, 5108, 5121, 5740, 5743, 5750, 5761, 5786, 5792, 5866, 6016, 6067, 6176, 6263, 6272, 6312, 7680, 7835, 7840, 7929, 7936, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8319, 8319, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8473, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8493, 8495, 8497, 8499, 8505, 8544, 8579, 12293, 12295, 12321, 12329, 12337, 12341, 12344, 12346, 12353, 12436, 12445, 12446, 12449, 12538, 12540, 12542, 12549, 12588, 12593, 12686, 12704, 12727, 13312, 19893, 19968, 40869, 40960, 42124, 44032, 55203, 63744, 64045, 64256, 64262, 64275, 64279, 64285, 64285, 64287, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65136, 65138, 65140, 65140, 65142, 65276, 65313, 65338, 65345, 65370, 65382, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500,]; var unicodeES3IdentifierPart = [170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 543, 546, 563, 592, 685, 688, 696, 699, 705, 720, 721, 736, 740, 750, 750, 768, 846, 864, 866, 890, 890, 902, 902, 904, 906, 908, 908, 910, 929, 931, 974, 976, 983, 986, 1011, 1024, 1153, 1155, 1158, 1164, 1220, 1223, 1224, 1227, 1228, 1232, 1269, 1272, 1273, 1329, 1366, 1369, 1369, 1377, 1415, 1425, 1441, 1443, 1465, 1467, 1469, 1471, 1471, 1473, 1474, 1476, 1476, 1488, 1514, 1520, 1522, 1569, 1594, 1600, 1621, 1632, 1641, 1648, 1747, 1749, 1756, 1759, 1768, 1770, 1773, 1776, 1788, 1808, 1836, 1840, 1866, 1920, 1968, 2305, 2307, 2309, 2361, 2364, 2381, 2384, 2388, 2392, 2403, 2406, 2415, 2433, 2435, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2492, 2492, 2494, 2500, 2503, 2504, 2507, 2509, 2519, 2519, 2524, 2525, 2527, 2531, 2534, 2545, 2562, 2562, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2620, 2620, 2622, 2626, 2631, 2632, 2635, 2637, 2649, 2652, 2654, 2654, 2662, 2676, 2689, 2691, 2693, 2699, 2701, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2748, 2757, 2759, 2761, 2763, 2765, 2768, 2768, 2784, 2784, 2790, 2799, 2817, 2819, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2870, 2873, 2876, 2883, 2887, 2888, 2891, 2893, 2902, 2903, 2908, 2909, 2911, 2913, 2918, 2927, 2946, 2947, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 2997, 2999, 3001, 3006, 3010, 3014, 3016, 3018, 3021, 3031, 3031, 3047, 3055, 3073, 3075, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3123, 3125, 3129, 3134, 3140, 3142, 3144, 3146, 3149, 3157, 3158, 3168, 3169, 3174, 3183, 3202, 3203, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3262, 3268, 3270, 3272, 3274, 3277, 3285, 3286, 3294, 3294, 3296, 3297, 3302, 3311, 3330, 3331, 3333, 3340, 3342, 3344, 3346, 3368, 3370, 3385, 3390, 3395, 3398, 3400, 3402, 3405, 3415, 3415, 3424, 3425, 3430, 3439, 3458, 3459, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3530, 3530, 3535, 3540, 3542, 3542, 3544, 3551, 3570, 3571, 3585, 3642, 3648, 3662, 3664, 3673, 3713, 3714, 3716, 3716, 3719, 3720, 3722, 3722, 3725, 3725, 3732, 3735, 3737, 3743, 3745, 3747, 3749, 3749, 3751, 3751, 3754, 3755, 3757, 3769, 3771, 3773, 3776, 3780, 3782, 3782, 3784, 3789, 3792, 3801, 3804, 3805, 3840, 3840, 3864, 3865, 3872, 3881, 3893, 3893, 3895, 3895, 3897, 3897, 3902, 3911, 3913, 3946, 3953, 3972, 3974, 3979, 3984, 3991, 3993, 4028, 4038, 4038, 4096, 4129, 4131, 4135, 4137, 4138, 4140, 4146, 4150, 4153, 4160, 4169, 4176, 4185, 4256, 4293, 4304, 4342, 4352, 4441, 4447, 4514, 4520, 4601, 4608, 4614, 4616, 4678, 4680, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4742, 4744, 4744, 4746, 4749, 4752, 4782, 4784, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4814, 4816, 4822, 4824, 4846, 4848, 4878, 4880, 4880, 4882, 4885, 4888, 4894, 4896, 4934, 4936, 4954, 4969, 4977, 5024, 5108, 5121, 5740, 5743, 5750, 5761, 5786, 5792, 5866, 6016, 6099, 6112, 6121, 6160, 6169, 6176, 6263, 6272, 6313, 7680, 7835, 7840, 7929, 7936, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8255, 8256, 8319, 8319, 8400, 8412, 8417, 8417, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8473, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8493, 8495, 8497, 8499, 8505, 8544, 8579, 12293, 12295, 12321, 12335, 12337, 12341, 12344, 12346, 12353, 12436, 12441, 12442, 12445, 12446, 12449, 12542, 12549, 12588, 12593, 12686, 12704, 12727, 13312, 19893, 19968, 40869, 40960, 42124, 44032, 55203, 63744, 64045, 64256, 64262, 64275, 64279, 64285, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65056, 65059, 65075, 65076, 65101, 65103, 65136, 65138, 65140, 65140, 65142, 65276, 65296, 65305, 65313, 65338, 65343, 65343, 65345, 65370, 65381, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500,]; @@ -2143,8 +2156,8 @@ var ts; getTokenValue: function () { return tokenValue; }, hasExtendedUnicodeEscape: function () { return hasExtendedUnicodeEscape; }, hasPrecedingLineBreak: function () { return precedingLineBreak; }, - isIdentifier: function () { return token === 67 || token > 103; }, - isReservedWord: function () { return token >= 68 && token <= 103; }, + isIdentifier: function () { return token === 69 || token > 105; }, + isReservedWord: function () { return token >= 70 && token <= 105; }, isUnterminated: function () { return tokenIsUnterminated; }, reScanGreaterToken: reScanGreaterToken, reScanSlashToken: reScanSlashToken, @@ -2166,16 +2179,6 @@ var ts; onError(message, length || 0); } } - function isIdentifierStart(ch) { - return ch >= 65 && ch <= 90 || ch >= 97 && ch <= 122 || - ch === 36 || ch === 95 || - ch > 127 && isUnicodeIdentifierStart(ch, languageVersion); - } - function isIdentifierPart(ch) { - return ch >= 65 && ch <= 90 || ch >= 97 && ch <= 122 || - ch >= 48 && ch <= 57 || ch === 36 || ch === 95 || - ch > 127 && isUnicodeIdentifierPart(ch, languageVersion); - } function scanNumber() { var start = pos; while (isDigit(text.charCodeAt(pos))) @@ -2430,12 +2433,12 @@ var ts; var start = pos; while (pos < end) { var ch = text.charCodeAt(pos); - if (isIdentifierPart(ch)) { + if (isIdentifierPart(ch, languageVersion)) { pos++; } else if (ch === 92) { ch = peekUnicodeEscape(); - if (!(ch >= 0 && isIdentifierPart(ch))) { + if (!(ch >= 0 && isIdentifierPart(ch, languageVersion))) { break; } result += text.substring(start, pos); @@ -2458,7 +2461,7 @@ var ts; return token = textToToken[tokenValue]; } } - return token = 67; + return token = 69; } function scanBinaryOrOctalDigits(base) { ts.Debug.assert(base !== 2 || base !== 8, "Expected either base 2 or base 8"); @@ -2537,7 +2540,7 @@ var ts; } return pos += 2, token = 31; } - return pos++, token = 48; + return pos++, token = 49; case 34: case 39: tokenValue = scanString(); @@ -2546,42 +2549,48 @@ var ts; return token = scanTemplateAndSetTokenValue(); case 37: if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 60; + return pos += 2, token = 62; } - return pos++, token = 39; + return pos++, token = 40; case 38: if (text.charCodeAt(pos + 1) === 38) { - return pos += 2, token = 50; + return pos += 2, token = 51; } if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 64; + return pos += 2, token = 66; } - return pos++, token = 45; + return pos++, token = 46; case 40: return pos++, token = 17; case 41: return pos++, token = 18; case 42: if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 58; + return pos += 2, token = 59; + } + if (text.charCodeAt(pos + 1) === 42) { + if (text.charCodeAt(pos + 2) === 61) { + return pos += 3, token = 60; + } + return pos += 2, token = 38; } return pos++, token = 37; case 43: if (text.charCodeAt(pos + 1) === 43) { - return pos += 2, token = 40; + return pos += 2, token = 41; } if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 56; + return pos += 2, token = 57; } return pos++, token = 35; case 44: return pos++, token = 24; case 45: if (text.charCodeAt(pos + 1) === 45) { - return pos += 2, token = 41; + return pos += 2, token = 42; } if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 57; + return pos += 2, token = 58; } return pos++, token = 36; case 46: @@ -2636,9 +2645,9 @@ var ts; } } if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 59; + return pos += 2, token = 61; } - return pos++, token = 38; + return pos++, token = 39; case 48: if (pos + 2 < end && (text.charCodeAt(pos + 1) === 88 || text.charCodeAt(pos + 1) === 120)) { pos += 2; @@ -2686,7 +2695,7 @@ var ts; tokenValue = "" + scanNumber(); return token = 8; case 58: - return pos++, token = 53; + return pos++, token = 54; case 59: return pos++, token = 23; case 60: @@ -2701,14 +2710,16 @@ var ts; } if (text.charCodeAt(pos + 1) === 60) { if (text.charCodeAt(pos + 2) === 61) { - return pos += 3, token = 61; + return pos += 3, token = 63; } - return pos += 2, token = 42; + return pos += 2, token = 43; } if (text.charCodeAt(pos + 1) === 61) { return pos += 2, token = 28; } - if (text.charCodeAt(pos + 1) === 47 && languageVariant === 1) { + if (languageVariant === 1 && + text.charCodeAt(pos + 1) === 47 && + text.charCodeAt(pos + 2) !== 42) { return pos += 2, token = 26; } return pos++, token = 25; @@ -2731,7 +2742,7 @@ var ts; if (text.charCodeAt(pos + 1) === 62) { return pos += 2, token = 34; } - return pos++, token = 55; + return pos++, token = 56; case 62: if (isConflictMarkerTrivia(text, pos)) { pos = scanConflictMarkerTrivia(text, pos, error); @@ -2744,35 +2755,35 @@ var ts; } return pos++, token = 27; case 63: - return pos++, token = 52; + return pos++, token = 53; case 91: return pos++, token = 19; case 93: return pos++, token = 20; case 94: if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 66; + return pos += 2, token = 68; } - return pos++, token = 47; + return pos++, token = 48; case 123: return pos++, token = 15; case 124: if (text.charCodeAt(pos + 1) === 124) { - return pos += 2, token = 51; + return pos += 2, token = 52; } if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 65; + return pos += 2, token = 67; } - return pos++, token = 46; + return pos++, token = 47; case 125: return pos++, token = 16; case 126: - return pos++, token = 49; + return pos++, token = 50; case 64: - return pos++, token = 54; + return pos++, token = 55; case 92: var cookedChar = peekUnicodeEscape(); - if (cookedChar >= 0 && isIdentifierStart(cookedChar)) { + if (cookedChar >= 0 && isIdentifierStart(cookedChar, languageVersion)) { pos += 6; tokenValue = String.fromCharCode(cookedChar) + scanIdentifierParts(); return token = getIdentifierToken(); @@ -2780,9 +2791,9 @@ var ts; error(ts.Diagnostics.Invalid_character); return pos++, token = 0; default: - if (isIdentifierStart(ch)) { + if (isIdentifierStart(ch, languageVersion)) { pos++; - while (pos < end && isIdentifierPart(ch = text.charCodeAt(pos))) + while (pos < end && isIdentifierPart(ch = text.charCodeAt(pos), languageVersion)) pos++; tokenValue = text.substring(tokenPos, pos); if (ch === 92) { @@ -2809,14 +2820,14 @@ var ts; if (text.charCodeAt(pos) === 62) { if (text.charCodeAt(pos + 1) === 62) { if (text.charCodeAt(pos + 2) === 61) { - return pos += 3, token = 63; + return pos += 3, token = 65; } - return pos += 2, token = 44; + return pos += 2, token = 45; } if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 62; + return pos += 2, token = 64; } - return pos++, token = 43; + return pos++, token = 44; } if (text.charCodeAt(pos) === 61) { return pos++, token = 29; @@ -2825,7 +2836,7 @@ var ts; return token; } function reScanSlashToken() { - if (token === 38 || token === 59) { + if (token === 39 || token === 61) { var p = tokenPos + 1; var inEscape = false; var inCharacterClass = false; @@ -2859,7 +2870,7 @@ var ts; } p++; } - while (p < end && isIdentifierPart(text.charCodeAt(p))) { + while (p < end && isIdentifierPart(text.charCodeAt(p), languageVersion)) { p++; } pos = p; @@ -2902,14 +2913,14 @@ var ts; break; } } - return token = 234; + return token = 236; } function scanJsxIdentifier() { if (tokenIsIdentifierOrKeyword(token)) { var firstCharPosition = pos; while (pos < end) { var ch = text.charCodeAt(pos); - if (ch === 45 || ((firstCharPosition === pos) ? isIdentifierStart(ch) : isIdentifierPart(ch))) { + if (ch === 45 || ((firstCharPosition === pos) ? isIdentifierStart(ch, languageVersion) : isIdentifierPart(ch, languageVersion))) { pos++; } else { @@ -3044,11 +3055,12 @@ var ts; "commonjs": 1, "amd": 2, "system": 4, - "umd": 3 + "umd": 3, + "es6": 5 }, - description: ts.Diagnostics.Specify_module_code_generation_Colon_commonjs_amd_system_or_umd, + description: ts.Diagnostics.Specify_module_code_generation_Colon_commonjs_amd_system_umd_or_es6, paramType: ts.Diagnostics.KIND, - error: ts.Diagnostics.Argument_for_module_option_must_be_commonjs_amd_system_or_umd + error: ts.Diagnostics.Argument_for_module_option_must_be_commonjs_amd_system_umd_or_es6 }, { name: "newLine", @@ -3189,11 +3201,6 @@ var ts; type: "boolean", description: ts.Diagnostics.Watch_input_files }, - { - name: "experimentalAsyncFunctions", - type: "boolean", - description: ts.Diagnostics.Enables_experimental_support_for_ES7_async_functions - }, { name: "experimentalDecorators", type: "boolean", @@ -3380,6 +3387,9 @@ var ts; } if (opt.isFilePath) { value = ts.normalizePath(ts.combinePaths(basePath, value)); + if (value === "") { + value = "."; + } } options[opt.name] = value; } @@ -3463,7 +3473,8 @@ var ts; increaseIndent: function () { }, decreaseIndent: function () { }, clear: function () { return str = ""; }, - trackSymbol: function () { } + trackSymbol: function () { }, + reportInaccessibleThisError: function () { } }; } return stringWriters.pop(); @@ -3525,7 +3536,7 @@ var ts; } } function getSourceFileOfNode(node) { - while (node && node.kind !== 246) { + while (node && node.kind !== 248) { node = node.parent; } return node; @@ -3616,15 +3627,15 @@ var ts; return current; } switch (current.kind) { - case 246: + case 248: + case 220: + case 244: case 218: - case 242: - case 216: - case 197: - case 198: case 199: + case 200: + case 201: return current; - case 190: + case 192: if (!isFunctionLike(current.parent)) { return current; } @@ -3635,9 +3646,9 @@ var ts; ts.getEnclosingBlockScopeContainer = getEnclosingBlockScopeContainer; function isCatchClauseVariableDeclaration(declaration) { return declaration && - declaration.kind === 209 && + declaration.kind === 211 && declaration.parent && - declaration.parent.kind === 242; + declaration.parent.kind === 244; } ts.isCatchClauseVariableDeclaration = isCatchClauseVariableDeclaration; function declarationNameToString(name) { @@ -3673,22 +3684,22 @@ var ts; function getErrorSpanForNode(sourceFile, node) { var errorNode = node; switch (node.kind) { - case 246: + case 248: var pos_1 = ts.skipTrivia(sourceFile.text, 0, false); if (pos_1 === sourceFile.text.length) { return ts.createTextSpan(0, 0); } return getSpanOfTokenAtPosition(sourceFile, pos_1); - case 209: - case 161: - case 212: - case 184: - case 213: - case 216: - case 215: - case 245: case 211: - case 171: + case 163: + case 214: + case 186: + case 215: + case 218: + case 217: + case 247: + case 213: + case 173: errorNode = node.name; break; } @@ -3705,16 +3716,20 @@ var ts; return file.externalModuleIndicator !== undefined; } ts.isExternalModule = isExternalModule; + function isExternalOrCommonJsModule(file) { + return (file.externalModuleIndicator || file.commonJsModuleIndicator) !== undefined; + } + ts.isExternalOrCommonJsModule = isExternalOrCommonJsModule; function isDeclarationFile(file) { return (file.flags & 8192) !== 0; } ts.isDeclarationFile = isDeclarationFile; function isConstEnumDeclaration(node) { - return node.kind === 215 && isConst(node); + return node.kind === 217 && isConst(node); } ts.isConstEnumDeclaration = isConstEnumDeclaration; function walkUpBindingElementsAndPatterns(node) { - while (node && (node.kind === 161 || isBindingPattern(node))) { + while (node && (node.kind === 163 || isBindingPattern(node))) { node = node.parent; } return node; @@ -3722,14 +3737,14 @@ var ts; function getCombinedNodeFlags(node) { node = walkUpBindingElementsAndPatterns(node); var flags = node.flags; - if (node.kind === 209) { + if (node.kind === 211) { node = node.parent; } - if (node && node.kind === 210) { + if (node && node.kind === 212) { flags |= node.flags; node = node.parent; } - if (node && node.kind === 191) { + if (node && node.kind === 193) { flags |= node.flags; } return flags; @@ -3744,7 +3759,7 @@ var ts; } ts.isLet = isLet; function isPrologueDirective(node) { - return node.kind === 193 && node.expression.kind === 9; + return node.kind === 195 && node.expression.kind === 9; } ts.isPrologueDirective = isPrologueDirective; function getLeadingCommentRangesOfNode(node, sourceFileOfNode) { @@ -3752,7 +3767,7 @@ var ts; } ts.getLeadingCommentRangesOfNode = getLeadingCommentRangesOfNode; function getJsDocComments(node, sourceFileOfNode) { - var commentRanges = (node.kind === 136 || node.kind === 135) ? + var commentRanges = (node.kind === 138 || node.kind === 137) ? ts.concatenate(ts.getTrailingCommentRanges(sourceFileOfNode.text, node.pos), ts.getLeadingCommentRanges(sourceFileOfNode.text, node.pos)) : getLeadingCommentRangesOfNode(node, sourceFileOfNode); return ts.filter(commentRanges, isJsDocComment); @@ -3766,68 +3781,69 @@ var ts; ts.fullTripleSlashReferencePathRegEx = /^(\/\/\/\s*/; ts.fullTripleSlashAMDReferencePathRegEx = /^(\/\/\/\s*/; function isTypeNode(node) { - if (149 <= node.kind && node.kind <= 158) { + if (151 <= node.kind && node.kind <= 160) { return true; } switch (node.kind) { - case 115: - case 126: + case 117: case 128: - case 118: - case 129: + case 130: + case 120: + case 131: return true; - case 101: - return node.parent.kind !== 175; + case 103: + return node.parent.kind !== 177; case 9: - return node.parent.kind === 136; - case 186: + return node.parent.kind === 138; + case 188: return !isExpressionWithTypeArgumentsInClassExtendsClause(node); - case 67: - if (node.parent.kind === 133 && node.parent.right === node) { + case 69: + if (node.parent.kind === 135 && node.parent.right === node) { node = node.parent; } - else if (node.parent.kind === 164 && node.parent.name === node) { + else if (node.parent.kind === 166 && node.parent.name === node) { node = node.parent; } - case 133: - case 164: - ts.Debug.assert(node.kind === 67 || node.kind === 133 || node.kind === 164, "'node' was expected to be a qualified name, identifier or property access in 'isTypeNode'."); + ts.Debug.assert(node.kind === 69 || node.kind === 135 || node.kind === 166, "'node' was expected to be a qualified name, identifier or property access in 'isTypeNode'."); + case 135: + case 166: + case 97: var parent_1 = node.parent; - if (parent_1.kind === 152) { + if (parent_1.kind === 154) { return false; } - if (149 <= parent_1.kind && parent_1.kind <= 158) { + if (151 <= parent_1.kind && parent_1.kind <= 160) { return true; } switch (parent_1.kind) { - case 186: + case 188: return !isExpressionWithTypeArgumentsInClassExtendsClause(parent_1); - case 135: + case 137: return node === parent_1.constraint; - case 139: - case 138: - case 136: - case 209: - return node === parent_1.type; - case 211: - case 171: - case 172: - case 142: case 141: case 140: - case 143: - case 144: + case 138: + case 211: return node === parent_1.type; + case 213: + case 173: + case 174: + case 144: + case 143: + case 142: case 145: case 146: + return node === parent_1.type; case 147: + case 148: + case 149: return node === parent_1.type; - case 169: + case 171: return node === parent_1.type; - case 166: - case 167: - return parent_1.typeArguments && ts.indexOf(parent_1.typeArguments, node) >= 0; case 168: + case 169: + return parent_1.typeArguments && ts.indexOf(parent_1.typeArguments, node) >= 0; + case 170: return false; } } @@ -3838,23 +3854,23 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 202: + case 204: return visitor(node); - case 218: - case 190: - case 194: - case 195: + case 220: + case 192: case 196: case 197: case 198: case 199: - case 203: - case 204: - case 239: - case 240: + case 200: + case 201: case 205: - case 207: + case 206: + case 241: case 242: + case 207: + case 209: + case 244: return ts.forEachChild(node, traverse); } } @@ -3864,23 +3880,23 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 182: + case 184: visitor(node); var operand = node.expression; if (operand) { traverse(operand); } + case 217: case 215: - case 213: + case 218: case 216: case 214: - case 212: - case 184: + case 186: return; default: if (isFunctionLike(node)) { var name_6 = node.name; - if (name_6 && name_6.kind === 134) { + if (name_6 && name_6.kind === 136) { traverse(name_6.expression); return; } @@ -3895,14 +3911,14 @@ var ts; function isVariableLike(node) { if (node) { switch (node.kind) { - case 161: - case 245: - case 136: - case 243: - case 139: + case 163: + case 247: case 138: - case 244: - case 209: + case 245: + case 141: + case 140: + case 246: + case 211: return true; } } @@ -3910,29 +3926,29 @@ var ts; } ts.isVariableLike = isVariableLike; function isAccessor(node) { - return node && (node.kind === 143 || node.kind === 144); + return node && (node.kind === 145 || node.kind === 146); } ts.isAccessor = isAccessor; function isClassLike(node) { - return node && (node.kind === 212 || node.kind === 184); + return node && (node.kind === 214 || node.kind === 186); } ts.isClassLike = isClassLike; function isFunctionLike(node) { if (node) { switch (node.kind) { - case 142: - case 171: - case 211: - case 172: - case 141: - case 140: - case 143: case 144: + case 173: + case 213: + case 174: + case 143: + case 142: case 145: case 146: case 147: - case 150: - case 151: + case 148: + case 149: + case 152: + case 153: return true; } } @@ -3941,24 +3957,24 @@ var ts; ts.isFunctionLike = isFunctionLike; function introducesArgumentsExoticObject(node) { switch (node.kind) { - case 141: - case 140: - case 142: case 143: + case 142: case 144: - case 211: - case 171: + case 145: + case 146: + case 213: + case 173: return true; } return false; } ts.introducesArgumentsExoticObject = introducesArgumentsExoticObject; function isFunctionBlock(node) { - return node && node.kind === 190 && isFunctionLike(node.parent); + return node && node.kind === 192 && isFunctionLike(node.parent); } ts.isFunctionBlock = isFunctionBlock; function isObjectLiteralMethod(node) { - return node && node.kind === 141 && node.parent.kind === 163; + return node && node.kind === 143 && node.parent.kind === 165; } ts.isObjectLiteralMethod = isObjectLiteralMethod; function getContainingFunction(node) { @@ -3986,36 +4002,39 @@ var ts; return undefined; } switch (node.kind) { - case 134: + case 136: if (isClassLike(node.parent.parent)) { return node; } node = node.parent; break; - case 137: - if (node.parent.kind === 136 && isClassElement(node.parent.parent)) { + case 139: + if (node.parent.kind === 138 && isClassElement(node.parent.parent)) { node = node.parent.parent; } else if (isClassElement(node.parent)) { node = node.parent; } break; - case 172: + case 174: if (!includeArrowFunctions) { continue; } - case 211: - case 171: - case 216: - case 139: - case 138: + case 213: + case 173: + case 218: case 141: case 140: - case 142: case 143: + case 142: case 144: - case 215: - case 246: + case 145: + case 146: + case 147: + case 148: + case 149: + case 217: + case 248: return node; } } @@ -4027,33 +4046,33 @@ var ts; if (!node) return node; switch (node.kind) { - case 134: + case 136: if (isClassLike(node.parent.parent)) { return node; } node = node.parent; break; - case 137: - if (node.parent.kind === 136 && isClassElement(node.parent.parent)) { + case 139: + if (node.parent.kind === 138 && isClassElement(node.parent.parent)) { node = node.parent.parent; } else if (isClassElement(node.parent)) { node = node.parent; } break; - case 211: - case 171: - case 172: + case 213: + case 173: + case 174: if (!includeFunctions) { continue; } - case 139: - case 138: case 141: case 140: - case 142: case 143: + case 142: case 144: + case 145: + case 146: return node; } } @@ -4062,12 +4081,12 @@ var ts; function getEntityNameFromTypeNode(node) { if (node) { switch (node.kind) { - case 149: + case 151: return node.typeName; - case 186: + case 188: return node.expression; - case 67: - case 133: + case 69: + case 135: return node; } } @@ -4075,7 +4094,7 @@ var ts; } ts.getEntityNameFromTypeNode = getEntityNameFromTypeNode; function getInvokedExpression(node) { - if (node.kind === 168) { + if (node.kind === 170) { return node.tag; } return node.expression; @@ -4083,40 +4102,40 @@ var ts; ts.getInvokedExpression = getInvokedExpression; function nodeCanBeDecorated(node) { switch (node.kind) { - case 212: + case 214: return true; - case 139: - return node.parent.kind === 212; - case 136: - return node.parent.body && node.parent.parent.kind === 212; - case 143: - case 144: case 141: - return node.body && node.parent.kind === 212; + return node.parent.kind === 214; + case 138: + return node.parent.body && node.parent.parent.kind === 214; + case 145: + case 146: + case 143: + return node.body && node.parent.kind === 214; } return false; } ts.nodeCanBeDecorated = nodeCanBeDecorated; function nodeIsDecorated(node) { switch (node.kind) { - case 212: + case 214: if (node.decorators) { return true; } return false; - case 139: - case 136: - if (node.decorators) { - return true; - } - return false; - case 143: - if (node.body && node.decorators) { - return true; - } - return false; case 141: - case 144: + case 138: + if (node.decorators) { + return true; + } + return false; + case 145: + if (node.body && node.decorators) { + return true; + } + return false; + case 143: + case 146: if (node.body && node.decorators) { return true; } @@ -4127,10 +4146,10 @@ var ts; ts.nodeIsDecorated = nodeIsDecorated; function childIsDecorated(node) { switch (node.kind) { - case 212: + case 214: return ts.forEach(node.members, nodeOrChildIsDecorated); - case 141: - case 144: + case 143: + case 146: return ts.forEach(node.parameters, nodeIsDecorated); } return false; @@ -4140,95 +4159,105 @@ var ts; return nodeIsDecorated(node) || childIsDecorated(node); } ts.nodeOrChildIsDecorated = nodeOrChildIsDecorated; + function isPropertyAccessExpression(node) { + return node.kind === 166; + } + ts.isPropertyAccessExpression = isPropertyAccessExpression; + function isElementAccessExpression(node) { + return node.kind === 167; + } + ts.isElementAccessExpression = isElementAccessExpression; function isExpression(node) { switch (node.kind) { case 95: case 93: - case 91: - case 97: - case 82: + case 99: + case 84: case 10: - case 162: - case 163: case 164: case 165: case 166: case 167: case 168: - case 187: case 169: case 170: + case 189: case 171: - case 184: case 172: - case 175: case 173: + case 186: case 174: case 177: - case 178: + case 175: + case 176: case 179: case 180: - case 183: case 181: - case 11: - case 185: - case 231: - case 232: case 182: + case 185: + case 183: + case 11: + case 187: + case 233: + case 234: + case 184: + case 178: return true; - case 133: - while (node.parent.kind === 133) { + case 135: + while (node.parent.kind === 135) { node = node.parent; } - return node.parent.kind === 152; - case 67: - if (node.parent.kind === 152) { + return node.parent.kind === 154; + case 69: + if (node.parent.kind === 154) { return true; } case 8: case 9: + case 97: var parent_2 = node.parent; switch (parent_2.kind) { - case 209: - case 136: - case 139: + case 211: case 138: + case 141: + case 140: + case 247: case 245: - case 243: - case 161: + case 163: return parent_2.initializer === node; - case 193: - case 194: case 195: case 196: - case 202: - case 203: - case 204: - case 239: - case 206: - case 204: - return parent_2.expression === node; case 197: + case 198: + case 204: + case 205: + case 206: + case 241: + case 208: + case 206: + return parent_2.expression === node; + case 199: var forStatement = parent_2; - return (forStatement.initializer === node && forStatement.initializer.kind !== 210) || + return (forStatement.initializer === node && forStatement.initializer.kind !== 212) || forStatement.condition === node || forStatement.incrementor === node; - case 198: - case 199: + case 200: + case 201: var forInStatement = parent_2; - return (forInStatement.initializer === node && forInStatement.initializer.kind !== 210) || + return (forInStatement.initializer === node && forInStatement.initializer.kind !== 212) || forInStatement.expression === node; - case 169: - case 187: + case 171: + case 189: return node === parent_2.expression; - case 188: + case 190: return node === parent_2.expression; - case 134: + case 136: return node === parent_2.expression; - case 137: - case 238: + case 139: + case 240: + case 239: return true; - case 186: + case 188: return parent_2.expression === node && isExpressionWithTypeArgumentsInClassExtendsClause(parent_2); default: if (isExpression(parent_2)) { @@ -4239,6 +4268,10 @@ var ts; return false; } ts.isExpression = isExpression; + function isExternalModuleNameRelative(moduleName) { + return moduleName.substr(0, 2) === "./" || moduleName.substr(0, 3) === "../" || moduleName.substr(0, 2) === ".\\" || moduleName.substr(0, 3) === "..\\"; + } + ts.isExternalModuleNameRelative = isExternalModuleNameRelative; function isInstantiatedModule(node, preserveConstEnums) { var moduleState = ts.getModuleInstanceState(node); return moduleState === 1 || @@ -4246,7 +4279,7 @@ var ts; } ts.isInstantiatedModule = isInstantiatedModule; function isExternalModuleImportEqualsDeclaration(node) { - return node.kind === 219 && node.moduleReference.kind === 230; + return node.kind === 221 && node.moduleReference.kind === 232; } ts.isExternalModuleImportEqualsDeclaration = isExternalModuleImportEqualsDeclaration; function getExternalModuleImportEqualsDeclarationExpression(node) { @@ -4255,20 +4288,54 @@ var ts; } ts.getExternalModuleImportEqualsDeclarationExpression = getExternalModuleImportEqualsDeclarationExpression; function isInternalModuleImportEqualsDeclaration(node) { - return node.kind === 219 && node.moduleReference.kind !== 230; + return node.kind === 221 && node.moduleReference.kind !== 232; } ts.isInternalModuleImportEqualsDeclaration = isInternalModuleImportEqualsDeclaration; + function isSourceFileJavaScript(file) { + return isInJavaScriptFile(file); + } + ts.isSourceFileJavaScript = isSourceFileJavaScript; + function isInJavaScriptFile(node) { + return node && !!(node.parserContextFlags & 32); + } + ts.isInJavaScriptFile = isInJavaScriptFile; + function isRequireCall(expression) { + return expression.kind === 168 && + expression.expression.kind === 69 && + expression.expression.text === "require" && + expression.arguments.length === 1; + } + ts.isRequireCall = isRequireCall; + function isExportsPropertyAssignment(expression) { + return isInJavaScriptFile(expression) && + (expression.kind === 181) && + (expression.operatorToken.kind === 56) && + (expression.left.kind === 166) && + (expression.left.expression.kind === 69) && + ((expression.left.expression).text === "exports"); + } + ts.isExportsPropertyAssignment = isExportsPropertyAssignment; + function isModuleExportsAssignment(expression) { + return isInJavaScriptFile(expression) && + (expression.kind === 181) && + (expression.operatorToken.kind === 56) && + (expression.left.kind === 166) && + (expression.left.expression.kind === 69) && + ((expression.left.expression).text === "module") && + (expression.left.name.text === "exports"); + } + ts.isModuleExportsAssignment = isModuleExportsAssignment; function getExternalModuleName(node) { - if (node.kind === 220) { + if (node.kind === 222) { return node.moduleSpecifier; } - if (node.kind === 219) { + if (node.kind === 221) { var reference = node.moduleReference; - if (reference.kind === 230) { + if (reference.kind === 232) { return reference.expression; } } - if (node.kind === 226) { + if (node.kind === 228) { return node.moduleSpecifier; } } @@ -4276,13 +4343,13 @@ var ts; function hasQuestionToken(node) { if (node) { switch (node.kind) { - case 136: + case 138: + case 143: + case 142: + case 246: + case 245: case 141: case 140: - case 244: - case 243: - case 139: - case 138: return node.questionToken !== undefined; } } @@ -4290,9 +4357,9 @@ var ts; } ts.hasQuestionToken = hasQuestionToken; function isJSDocConstructSignature(node) { - return node.kind === 259 && + return node.kind === 261 && node.parameters.length > 0 && - node.parameters[0].type.kind === 261; + node.parameters[0].type.kind === 263; } ts.isJSDocConstructSignature = isJSDocConstructSignature; function getJSDocTag(node, kind) { @@ -4306,24 +4373,24 @@ var ts; } } function getJSDocTypeTag(node) { - return getJSDocTag(node, 267); + return getJSDocTag(node, 269); } ts.getJSDocTypeTag = getJSDocTypeTag; function getJSDocReturnTag(node) { - return getJSDocTag(node, 266); + return getJSDocTag(node, 268); } ts.getJSDocReturnTag = getJSDocReturnTag; function getJSDocTemplateTag(node) { - return getJSDocTag(node, 268); + return getJSDocTag(node, 270); } ts.getJSDocTemplateTag = getJSDocTemplateTag; function getCorrespondingJSDocParameterTag(parameter) { - if (parameter.name && parameter.name.kind === 67) { + if (parameter.name && parameter.name.kind === 69) { var parameterName = parameter.name.text; var docComment = parameter.parent.jsDocComment; if (docComment) { return ts.forEach(docComment.tags, function (t) { - if (t.kind === 265) { + if (t.kind === 267) { var parameterTag = t; var name_7 = parameterTag.preParameterName || parameterTag.postParameterName; if (name_7.text === parameterName) { @@ -4342,12 +4409,12 @@ var ts; function isRestParameter(node) { if (node) { if (node.parserContextFlags & 32) { - if (node.type && node.type.kind === 260) { + if (node.type && node.type.kind === 262) { return true; } var paramTag = getCorrespondingJSDocParameterTag(node); if (paramTag && paramTag.typeExpression) { - return paramTag.typeExpression.type.kind === 260; + return paramTag.typeExpression.type.kind === 262; } } return node.dotDotDotToken !== undefined; @@ -4368,7 +4435,7 @@ var ts; } ts.isTemplateLiteralKind = isTemplateLiteralKind; function isBindingPattern(node) { - return !!node && (node.kind === 160 || node.kind === 159); + return !!node && (node.kind === 162 || node.kind === 161); } ts.isBindingPattern = isBindingPattern; function isInAmbientContext(node) { @@ -4383,34 +4450,34 @@ var ts; ts.isInAmbientContext = isInAmbientContext; function isDeclaration(node) { switch (node.kind) { - case 172: - case 161: - case 212: - case 184: - case 142: - case 215: - case 245: - case 228: - case 211: - case 171: - case 143: - case 221: - case 219: - case 224: + case 174: + case 163: + case 214: + case 186: + case 144: + case 217: + case 247: + case 230: case 213: + case 173: + case 145: + case 223: + case 221: + case 226: + case 215: + case 143: + case 142: + case 218: + case 224: + case 138: + case 245: case 141: case 140: + case 146: + case 246: case 216: - case 222: - case 136: - case 243: - case 139: - case 138: - case 144: - case 244: - case 214: - case 135: - case 209: + case 137: + case 211: return true; } return false; @@ -4418,25 +4485,25 @@ var ts; ts.isDeclaration = isDeclaration; function isStatement(n) { switch (n.kind) { - case 201: - case 200: - case 208: - case 195: - case 193: - case 192: - case 198: - case 199: - case 197: - case 194: - case 205: - case 202: - case 204: - case 96: - case 207: - case 191: - case 196: case 203: - case 225: + case 202: + case 210: + case 197: + case 195: + case 194: + case 200: + case 201: + case 199: + case 196: + case 207: + case 204: + case 206: + case 98: + case 209: + case 193: + case 198: + case 205: + case 227: return true; default: return false; @@ -4445,13 +4512,13 @@ var ts; ts.isStatement = isStatement; function isClassElement(n) { switch (n.kind) { - case 142: - case 139: + case 144: case 141: case 143: - case 144: - case 140: - case 147: + case 145: + case 146: + case 142: + case 149: return true; default: return false; @@ -4459,11 +4526,11 @@ var ts; } ts.isClassElement = isClassElement; function isDeclarationName(name) { - if (name.kind !== 67 && name.kind !== 9 && name.kind !== 8) { + if (name.kind !== 69 && name.kind !== 9 && name.kind !== 8) { return false; } var parent = name.parent; - if (parent.kind === 224 || parent.kind === 228) { + if (parent.kind === 226 || parent.kind === 230) { if (parent.propertyName) { return true; } @@ -4477,54 +4544,54 @@ var ts; function isIdentifierName(node) { var parent = node.parent; switch (parent.kind) { - case 139: - case 138: case 141: case 140: case 143: - case 144: + case 142: + case 145: + case 146: + case 247: case 245: - case 243: - case 164: + case 166: return parent.name === node; - case 133: + case 135: if (parent.right === node) { - while (parent.kind === 133) { + while (parent.kind === 135) { parent = parent.parent; } - return parent.kind === 152; + return parent.kind === 154; } return false; - case 161: - case 224: + case 163: + case 226: return parent.propertyName === node; - case 228: + case 230: return true; } return false; } ts.isIdentifierName = isIdentifierName; function isAliasSymbolDeclaration(node) { - return node.kind === 219 || - node.kind === 221 && !!node.name || - node.kind === 222 || + return node.kind === 221 || + node.kind === 223 && !!node.name || node.kind === 224 || - node.kind === 228 || - node.kind === 225 && node.expression.kind === 67; + node.kind === 226 || + node.kind === 230 || + node.kind === 227 && node.expression.kind === 69; } ts.isAliasSymbolDeclaration = isAliasSymbolDeclaration; function getClassExtendsHeritageClauseElement(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 81); + var heritageClause = getHeritageClause(node.heritageClauses, 83); return heritageClause && heritageClause.types.length > 0 ? heritageClause.types[0] : undefined; } ts.getClassExtendsHeritageClauseElement = getClassExtendsHeritageClauseElement; function getClassImplementsHeritageClauseElements(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 104); + var heritageClause = getHeritageClause(node.heritageClauses, 106); return heritageClause ? heritageClause.types : undefined; } ts.getClassImplementsHeritageClauseElements = getClassImplementsHeritageClauseElements; function getInterfaceBaseTypeNodes(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 81); + var heritageClause = getHeritageClause(node.heritageClauses, 83); return heritageClause ? heritageClause.types : undefined; } ts.getInterfaceBaseTypeNodes = getInterfaceBaseTypeNodes; @@ -4593,7 +4660,7 @@ var ts; } ts.getFileReferenceFromReferencePath = getFileReferenceFromReferencePath; function isKeyword(token) { - return 68 <= token && token <= 132; + return 70 <= token && token <= 134; } ts.isKeyword = isKeyword; function isTrivia(token) { @@ -4606,19 +4673,19 @@ var ts; ts.isAsyncFunctionLike = isAsyncFunctionLike; function hasDynamicName(declaration) { return declaration.name && - declaration.name.kind === 134 && + declaration.name.kind === 136 && !isWellKnownSymbolSyntactically(declaration.name.expression); } ts.hasDynamicName = hasDynamicName; function isWellKnownSymbolSyntactically(node) { - return node.kind === 164 && isESSymbolIdentifier(node.expression); + return isPropertyAccessExpression(node) && isESSymbolIdentifier(node.expression); } ts.isWellKnownSymbolSyntactically = isWellKnownSymbolSyntactically; function getPropertyNameForPropertyNameNode(name) { - if (name.kind === 67 || name.kind === 9 || name.kind === 8) { + if (name.kind === 69 || name.kind === 9 || name.kind === 8) { return name.text; } - if (name.kind === 134) { + if (name.kind === 136) { var nameExpression = name.expression; if (isWellKnownSymbolSyntactically(nameExpression)) { var rightHandSideName = nameExpression.name.text; @@ -4633,21 +4700,21 @@ var ts; } ts.getPropertyNameForKnownSymbolName = getPropertyNameForKnownSymbolName; function isESSymbolIdentifier(node) { - return node.kind === 67 && node.text === "Symbol"; + return node.kind === 69 && node.text === "Symbol"; } ts.isESSymbolIdentifier = isESSymbolIdentifier; function isModifier(token) { switch (token) { - case 113: - case 116: - case 72: - case 120: - case 75: - case 80: + case 115: + case 118: + case 74: + case 122: + case 77: + case 82: + case 112: case 110: - case 108: - case 109: case 111: + case 113: return true; } return false; @@ -4655,28 +4722,28 @@ var ts; ts.isModifier = isModifier; function isParameterDeclaration(node) { var root = getRootDeclaration(node); - return root.kind === 136; + return root.kind === 138; } ts.isParameterDeclaration = isParameterDeclaration; function getRootDeclaration(node) { - while (node.kind === 161) { + while (node.kind === 163) { node = node.parent.parent; } return node; } ts.getRootDeclaration = getRootDeclaration; function nodeStartsNewLexicalEnvironment(n) { - return isFunctionLike(n) || n.kind === 216 || n.kind === 246; + return isFunctionLike(n) || n.kind === 218 || n.kind === 248; } ts.nodeStartsNewLexicalEnvironment = nodeStartsNewLexicalEnvironment; function cloneEntityName(node) { - if (node.kind === 67) { - var clone_1 = createSynthesizedNode(67); + if (node.kind === 69) { + var clone_1 = createSynthesizedNode(69); clone_1.text = node.text; return clone_1; } else { - var clone_2 = createSynthesizedNode(133); + var clone_2 = createSynthesizedNode(135); clone_2.left = cloneEntityName(node.left); clone_2.left.parent = clone_2; clone_2.right = cloneEntityName(node.right); @@ -4919,7 +4986,7 @@ var ts; ts.getLineOfLocalPosition = getLineOfLocalPosition; function getFirstConstructorWithBody(node) { return ts.forEach(node.members, function (member) { - if (member.kind === 142 && nodeIsPresent(member.body)) { + if (member.kind === 144 && nodeIsPresent(member.body)) { return member; } }); @@ -4946,10 +5013,10 @@ var ts; var setAccessor; if (hasDynamicName(accessor)) { firstAccessor = accessor; - if (accessor.kind === 143) { + if (accessor.kind === 145) { getAccessor = accessor; } - else if (accessor.kind === 144) { + else if (accessor.kind === 146) { setAccessor = accessor; } else { @@ -4958,7 +5025,7 @@ var ts; } else { ts.forEach(declarations, function (member) { - if ((member.kind === 143 || member.kind === 144) + if ((member.kind === 145 || member.kind === 146) && (member.flags & 128) === (accessor.flags & 128)) { var memberName = getPropertyNameForPropertyNameNode(member.name); var accessorName = getPropertyNameForPropertyNameNode(accessor.name); @@ -4969,10 +5036,10 @@ var ts; else if (!secondAccessor) { secondAccessor = member; } - if (member.kind === 143 && !getAccessor) { + if (member.kind === 145 && !getAccessor) { getAccessor = member; } - if (member.kind === 144 && !setAccessor) { + if (member.kind === 146 && !setAccessor) { setAccessor = member; } } @@ -5078,16 +5145,16 @@ var ts; ts.writeCommentRange = writeCommentRange; function modifierToFlag(token) { switch (token) { - case 111: return 128; - case 110: return 16; - case 109: return 64; - case 108: return 32; - case 113: return 256; - case 80: return 1; - case 120: return 2; - case 72: return 32768; - case 75: return 1024; - case 116: return 512; + case 113: return 128; + case 112: return 16; + case 111: return 64; + case 110: return 32; + case 115: return 256; + case 82: return 1; + case 122: return 2; + case 74: return 32768; + case 77: return 1024; + case 118: return 512; } return 0; } @@ -5095,29 +5162,29 @@ var ts; function isLeftHandSideExpression(expr) { if (expr) { switch (expr.kind) { - case 164: - case 165: - case 167: case 166: - case 231: - case 232: + case 167: + case 169: case 168: - case 162: + case 233: + case 234: case 170: - case 163: - case 184: - case 171: - case 67: + case 164: + case 172: + case 165: + case 186: + case 173: + case 69: case 10: case 8: case 9: case 11: - case 181: - case 82: - case 91: - case 95: - case 97: + case 183: + case 84: case 93: + case 97: + case 99: + case 95: return true; } } @@ -5125,12 +5192,12 @@ var ts; } ts.isLeftHandSideExpression = isLeftHandSideExpression; function isAssignmentOperator(token) { - return token >= 55 && token <= 66; + return token >= 56 && token <= 68; } ts.isAssignmentOperator = isAssignmentOperator; function isExpressionWithTypeArgumentsInClassExtendsClause(node) { - return node.kind === 186 && - node.parent.token === 81 && + return node.kind === 188 && + node.parent.token === 83 && isClassLike(node.parent.parent); } ts.isExpressionWithTypeArgumentsInClassExtendsClause = isExpressionWithTypeArgumentsInClassExtendsClause; @@ -5139,10 +5206,10 @@ var ts; } ts.isSupportedExpressionWithTypeArguments = isSupportedExpressionWithTypeArguments; function isSupportedExpressionWithTypeArgumentsRest(node) { - if (node.kind === 67) { + if (node.kind === 69) { return true; } - else if (node.kind === 164) { + else if (isPropertyAccessExpression(node)) { return isSupportedExpressionWithTypeArgumentsRest(node.expression); } else { @@ -5150,16 +5217,16 @@ var ts; } } function isRightSideOfQualifiedNameOrPropertyAccess(node) { - return (node.parent.kind === 133 && node.parent.right === node) || - (node.parent.kind === 164 && node.parent.name === node); + return (node.parent.kind === 135 && node.parent.right === node) || + (node.parent.kind === 166 && node.parent.name === node); } ts.isRightSideOfQualifiedNameOrPropertyAccess = isRightSideOfQualifiedNameOrPropertyAccess; function isEmptyObjectLiteralOrArrayLiteral(expression) { var kind = expression.kind; - if (kind === 163) { + if (kind === 165) { return expression.properties.length === 0; } - if (kind === 162) { + if (kind === 164) { return expression.elements.length === 0; } return false; @@ -5169,12 +5236,12 @@ var ts; return symbol && symbol.valueDeclaration && (symbol.valueDeclaration.flags & 1024) ? symbol.valueDeclaration.localSymbol : undefined; } ts.getLocalSymbolForExportDefault = getLocalSymbolForExportDefault; - function isJavaScript(fileName) { - return ts.fileExtensionIs(fileName, ".js"); + function hasJavaScriptFileExtension(fileName) { + return ts.fileExtensionIs(fileName, ".js") || ts.fileExtensionIs(fileName, ".jsx"); } - ts.isJavaScript = isJavaScript; + ts.hasJavaScriptFileExtension = hasJavaScriptFileExtension; function isTsx(fileName) { - return ts.fileExtensionIs(fileName, ".tsx"); + return ts.fileExtensionIs(fileName, ".tsx") || ts.fileExtensionIs(fileName, ".jsx"); } ts.isTsx = isTsx; function getExpandedCharCodes(input) { @@ -5368,9 +5435,9 @@ var ts; } ts.collapseTextChangeRangesAcrossMultipleVersions = collapseTextChangeRangesAcrossMultipleVersions; function getTypeParameterOwner(d) { - if (d && d.kind === 135) { + if (d && d.kind === 137) { for (var current = d; current; current = current.parent) { - if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 213) { + if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 215) { return current; } } @@ -5380,7 +5447,7 @@ var ts; })(ts || (ts = {})); var ts; (function (ts) { - var nodeConstructors = new Array(270); + var nodeConstructors = new Array(272); ts.parseTime = 0; function getNodeConstructor(kind) { return nodeConstructors[kind] || (nodeConstructors[kind] = ts.objectAllocator.getNodeConstructor(kind)); @@ -5418,20 +5485,26 @@ var ts; var visitNodes = cbNodeArray ? visitNodeArray : visitEachNode; var cbNodes = cbNodeArray || cbNode; switch (node.kind) { - case 133: + case 135: return visitNode(cbNode, node.left) || visitNode(cbNode, node.right); - case 135: + case 137: return visitNode(cbNode, node.name) || visitNode(cbNode, node.constraint) || visitNode(cbNode, node.expression); - case 136: - case 139: + case 246: + return visitNodes(cbNodes, node.decorators) || + visitNodes(cbNodes, node.modifiers) || + visitNode(cbNode, node.name) || + visitNode(cbNode, node.questionToken) || + visitNode(cbNode, node.equalsToken) || + visitNode(cbNode, node.objectAssignmentInitializer); case 138: - case 243: - case 244: - case 209: - case 161: + case 141: + case 140: + case 245: + case 211: + case 163: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.propertyName) || @@ -5440,24 +5513,24 @@ var ts; visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 150: - case 151: - case 145: - case 146: + case 152: + case 153: case 147: + case 148: + case 149: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNodes(cbNodes, node.typeParameters) || visitNodes(cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 141: - case 140: - case 142: case 143: + case 142: case 144: - case 171: - case 211: - case 172: + case 145: + case 146: + case 173: + case 213: + case 174: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.asteriskToken) || @@ -5468,290 +5541,290 @@ var ts; visitNode(cbNode, node.type) || visitNode(cbNode, node.equalsGreaterThanToken) || visitNode(cbNode, node.body); - case 149: + case 151: return visitNode(cbNode, node.typeName) || visitNodes(cbNodes, node.typeArguments); - case 148: + case 150: return visitNode(cbNode, node.parameterName) || visitNode(cbNode, node.type); - case 152: - return visitNode(cbNode, node.exprName); - case 153: - return visitNodes(cbNodes, node.members); case 154: - return visitNode(cbNode, node.elementType); + return visitNode(cbNode, node.exprName); case 155: - return visitNodes(cbNodes, node.elementTypes); + return visitNodes(cbNodes, node.members); case 156: + return visitNode(cbNode, node.elementType); case 157: - return visitNodes(cbNodes, node.types); + return visitNodes(cbNodes, node.elementTypes); case 158: - return visitNode(cbNode, node.type); case 159: + return visitNodes(cbNodes, node.types); case 160: - return visitNodes(cbNodes, node.elements); + return visitNode(cbNode, node.type); + case 161: case 162: return visitNodes(cbNodes, node.elements); - case 163: - return visitNodes(cbNodes, node.properties); case 164: + return visitNodes(cbNodes, node.elements); + case 165: + return visitNodes(cbNodes, node.properties); + case 166: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.dotToken) || visitNode(cbNode, node.name); - case 165: + case 167: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.argumentExpression); - case 166: - case 167: + case 168: + case 169: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.typeArguments) || visitNodes(cbNodes, node.arguments); - case 168: + case 170: return visitNode(cbNode, node.tag) || visitNode(cbNode, node.template); - case 169: + case 171: return visitNode(cbNode, node.type) || visitNode(cbNode, node.expression); - case 170: - return visitNode(cbNode, node.expression); - case 173: - return visitNode(cbNode, node.expression); - case 174: + case 172: return visitNode(cbNode, node.expression); case 175: return visitNode(cbNode, node.expression); - case 177: - return visitNode(cbNode, node.operand); - case 182: - return visitNode(cbNode, node.asteriskToken) || - visitNode(cbNode, node.expression); case 176: return visitNode(cbNode, node.expression); - case 178: - return visitNode(cbNode, node.operand); + case 177: + return visitNode(cbNode, node.expression); case 179: + return visitNode(cbNode, node.operand); + case 184: + return visitNode(cbNode, node.asteriskToken) || + visitNode(cbNode, node.expression); + case 178: + return visitNode(cbNode, node.expression); + case 180: + return visitNode(cbNode, node.operand); + case 181: return visitNode(cbNode, node.left) || visitNode(cbNode, node.operatorToken) || visitNode(cbNode, node.right); - case 187: + case 189: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.type); - case 180: + case 182: return visitNode(cbNode, node.condition) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.whenTrue) || visitNode(cbNode, node.colonToken) || visitNode(cbNode, node.whenFalse); - case 183: + case 185: return visitNode(cbNode, node.expression); - case 190: - case 217: + case 192: + case 219: return visitNodes(cbNodes, node.statements); - case 246: + case 248: return visitNodes(cbNodes, node.statements) || visitNode(cbNode, node.endOfFileToken); - case 191: + case 193: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.declarationList); - case 210: + case 212: return visitNodes(cbNodes, node.declarations); - case 193: + case 195: return visitNode(cbNode, node.expression); - case 194: + case 196: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.thenStatement) || visitNode(cbNode, node.elseStatement); - case 195: + case 197: return visitNode(cbNode, node.statement) || visitNode(cbNode, node.expression); - case 196: + case 198: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 197: + case 199: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.condition) || visitNode(cbNode, node.incrementor) || visitNode(cbNode, node.statement); - case 198: - return visitNode(cbNode, node.initializer) || - visitNode(cbNode, node.expression) || - visitNode(cbNode, node.statement); - case 199: - return visitNode(cbNode, node.initializer) || - visitNode(cbNode, node.expression) || - visitNode(cbNode, node.statement); case 200: - case 201: - return visitNode(cbNode, node.label); - case 202: - return visitNode(cbNode, node.expression); - case 203: - return visitNode(cbNode, node.expression) || + return visitNode(cbNode, node.initializer) || + visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); + case 201: + return visitNode(cbNode, node.initializer) || + visitNode(cbNode, node.expression) || + visitNode(cbNode, node.statement); + case 202: + case 203: + return visitNode(cbNode, node.label); case 204: - return visitNode(cbNode, node.expression) || - visitNode(cbNode, node.caseBlock); - case 218: - return visitNodes(cbNodes, node.clauses); - case 239: - return visitNode(cbNode, node.expression) || - visitNodes(cbNodes, node.statements); - case 240: - return visitNodes(cbNodes, node.statements); + return visitNode(cbNode, node.expression); case 205: - return visitNode(cbNode, node.label) || + return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); case 206: - return visitNode(cbNode, node.expression); + return visitNode(cbNode, node.expression) || + visitNode(cbNode, node.caseBlock); + case 220: + return visitNodes(cbNodes, node.clauses); + case 241: + return visitNode(cbNode, node.expression) || + visitNodes(cbNodes, node.statements); + case 242: + return visitNodes(cbNodes, node.statements); case 207: + return visitNode(cbNode, node.label) || + visitNode(cbNode, node.statement); + case 208: + return visitNode(cbNode, node.expression); + case 209: return visitNode(cbNode, node.tryBlock) || visitNode(cbNode, node.catchClause) || visitNode(cbNode, node.finallyBlock); - case 242: + case 244: return visitNode(cbNode, node.variableDeclaration) || visitNode(cbNode, node.block); - case 137: + case 139: return visitNode(cbNode, node.expression); - case 212: - case 184: - return visitNodes(cbNodes, node.decorators) || - visitNodes(cbNodes, node.modifiers) || - visitNode(cbNode, node.name) || - visitNodes(cbNodes, node.typeParameters) || - visitNodes(cbNodes, node.heritageClauses) || - visitNodes(cbNodes, node.members); - case 213: - return visitNodes(cbNodes, node.decorators) || - visitNodes(cbNodes, node.modifiers) || - visitNode(cbNode, node.name) || - visitNodes(cbNodes, node.typeParameters) || - visitNodes(cbNodes, node.heritageClauses) || - visitNodes(cbNodes, node.members); case 214: + case 186: return visitNodes(cbNodes, node.decorators) || 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 215: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || + visitNodes(cbNodes, node.typeParameters) || + visitNodes(cbNodes, node.heritageClauses) || visitNodes(cbNodes, node.members); - case 245: - return visitNode(cbNode, node.name) || - visitNode(cbNode, node.initializer); case 216: + return visitNodes(cbNodes, node.decorators) || + visitNodes(cbNodes, node.modifiers) || + visitNode(cbNode, node.name) || + visitNodes(cbNodes, node.typeParameters) || + visitNode(cbNode, node.type); + case 217: + return visitNodes(cbNodes, node.decorators) || + visitNodes(cbNodes, node.modifiers) || + visitNode(cbNode, node.name) || + visitNodes(cbNodes, node.members); + case 247: + return visitNode(cbNode, node.name) || + visitNode(cbNode, node.initializer); + case 218: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.body); - case 219: + case 221: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.moduleReference); - case 220: + case 222: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.importClause) || visitNode(cbNode, node.moduleSpecifier); - case 221: + case 223: return visitNode(cbNode, node.name) || visitNode(cbNode, node.namedBindings); - case 222: + case 224: return visitNode(cbNode, node.name); - case 223: - case 227: + case 225: + case 229: return visitNodes(cbNodes, node.elements); - case 226: + case 228: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.exportClause) || visitNode(cbNode, node.moduleSpecifier); - case 224: - case 228: + case 226: + case 230: return visitNode(cbNode, node.propertyName) || visitNode(cbNode, node.name); - case 225: + case 227: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.expression); - case 181: + case 183: return visitNode(cbNode, node.head) || visitNodes(cbNodes, node.templateSpans); - case 188: + case 190: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.literal); - case 134: + case 136: return visitNode(cbNode, node.expression); - case 241: + case 243: return visitNodes(cbNodes, node.types); - case 186: + case 188: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.typeArguments); - case 230: + case 232: return visitNode(cbNode, node.expression); - case 229: - return visitNodes(cbNodes, node.decorators); case 231: + return visitNodes(cbNodes, node.decorators); + case 233: return visitNode(cbNode, node.openingElement) || visitNodes(cbNodes, node.children) || visitNode(cbNode, node.closingElement); - case 232: - case 233: + case 234: + case 235: return visitNode(cbNode, node.tagName) || visitNodes(cbNodes, node.attributes); - case 236: + case 238: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); + case 239: + return visitNode(cbNode, node.expression); + case 240: + return visitNode(cbNode, node.expression); case 237: - return visitNode(cbNode, node.expression); - case 238: - return visitNode(cbNode, node.expression); - case 235: return visitNode(cbNode, node.tagName); - case 247: - return visitNode(cbNode, node.type); - case 251: - return visitNodes(cbNodes, node.types); - case 252: - return visitNodes(cbNodes, node.types); - case 250: - return visitNode(cbNode, node.elementType); - case 254: + case 249: return visitNode(cbNode, node.type); case 253: + return visitNodes(cbNodes, node.types); + case 254: + return visitNodes(cbNodes, node.types); + case 252: + return visitNode(cbNode, node.elementType); + case 256: return visitNode(cbNode, node.type); case 255: - return visitNodes(cbNodes, node.members); + return visitNode(cbNode, node.type); case 257: + return visitNodes(cbNodes, node.members); + case 259: return visitNode(cbNode, node.name) || visitNodes(cbNodes, node.typeArguments); - case 258: - return visitNode(cbNode, node.type); - case 259: - return visitNodes(cbNodes, node.parameters) || - visitNode(cbNode, node.type); case 260: return visitNode(cbNode, node.type); case 261: - return visitNode(cbNode, node.type); + return visitNodes(cbNodes, node.parameters) || + visitNode(cbNode, node.type); case 262: return visitNode(cbNode, node.type); - case 256: + case 263: + return visitNode(cbNode, node.type); + case 264: + return visitNode(cbNode, node.type); + case 258: return visitNode(cbNode, node.name) || visitNode(cbNode, node.type); - case 263: - return visitNodes(cbNodes, node.tags); case 265: + return visitNodes(cbNodes, node.tags); + case 267: return visitNode(cbNode, node.preParameterName) || visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.postParameterName); - case 266: - return visitNode(cbNode, node.typeExpression); - case 267: - return visitNode(cbNode, node.typeExpression); case 268: + return visitNode(cbNode, node.typeExpression); + case 269: + return visitNode(cbNode, node.typeExpression); + case 270: return visitNodes(cbNodes, node.typeParameters); } } @@ -5792,13 +5865,14 @@ var ts; var contextFlags; var parseErrorBeforeNextFinishedNode = false; function parseSourceFile(fileName, _sourceText, languageVersion, _syntaxCursor, setParentNodes) { - initializeState(fileName, _sourceText, languageVersion, _syntaxCursor); + var isJavaScriptFile = ts.hasJavaScriptFileExtension(fileName) || _sourceText.lastIndexOf("// @language=javascript", 0) === 0; + initializeState(fileName, _sourceText, languageVersion, isJavaScriptFile, _syntaxCursor); var result = parseSourceFileWorker(fileName, languageVersion, setParentNodes); clearState(); return result; } Parser.parseSourceFile = parseSourceFile; - function initializeState(fileName, _sourceText, languageVersion, _syntaxCursor) { + function initializeState(fileName, _sourceText, languageVersion, isJavaScriptFile, _syntaxCursor) { sourceText = _sourceText; syntaxCursor = _syntaxCursor; parseDiagnostics = []; @@ -5806,7 +5880,7 @@ var ts; identifiers = {}; identifierCount = 0; nodeCount = 0; - contextFlags = ts.isJavaScript(fileName) ? 32 : 0; + contextFlags = isJavaScriptFile ? 32 : 0; parseErrorBeforeNextFinishedNode = false; scanner.setText(sourceText); scanner.setOnError(scanError); @@ -5824,6 +5898,9 @@ var ts; } function parseSourceFileWorker(fileName, languageVersion, setParentNodes) { sourceFile = createSourceFile(fileName, languageVersion); + if (contextFlags & 32) { + sourceFile.parserContextFlags = 32; + } token = nextToken(); processReferenceComments(sourceFile); sourceFile.statements = parseList(0, parseStatement); @@ -5837,7 +5914,7 @@ var ts; if (setParentNodes) { fixupParentReferences(sourceFile); } - if (ts.isJavaScript(fileName)) { + if (ts.isSourceFileJavaScript(sourceFile)) { addJSDocComments(); } return sourceFile; @@ -5847,9 +5924,9 @@ var ts; return; function visit(node) { switch (node.kind) { - case 191: - case 211: - case 136: + case 193: + case 213: + case 138: addJSDocComment(node); } forEachChild(node, visit); @@ -5883,7 +5960,7 @@ var ts; } Parser.fixupParentReferences = fixupParentReferences; function createSourceFile(fileName, languageVersion) { - var sourceFile = createNode(246, 0); + var sourceFile = createNode(248, 0); sourceFile.pos = 0; sourceFile.end = sourceText.length; sourceFile.text = sourceText; @@ -6042,16 +6119,16 @@ var ts; return speculationHelper(callback, false); } function isIdentifier() { - if (token === 67) { + if (token === 69) { return true; } - if (token === 112 && inYieldContext()) { + if (token === 114 && inYieldContext()) { return false; } - if (token === 117 && inAwaitContext()) { + if (token === 119 && inAwaitContext()) { return false; } - return token > 103; + return token > 105; } function parseExpected(kind, diagnosticMessage, shouldAdvance) { if (shouldAdvance === void 0) { shouldAdvance = true; } @@ -6147,15 +6224,15 @@ var ts; function createIdentifier(isIdentifier, diagnosticMessage) { identifierCount++; if (isIdentifier) { - var node = createNode(67); - if (token !== 67) { + var node = createNode(69); + if (token !== 69) { node.originalKeywordKind = token; } node.text = internIdentifier(scanner.getTokenValue()); nextToken(); return finishNode(node); } - return createMissingNode(67, false, diagnosticMessage || ts.Diagnostics.Identifier_expected); + return createMissingNode(69, false, diagnosticMessage || ts.Diagnostics.Identifier_expected); } function parseIdentifier(diagnosticMessage) { return createIdentifier(isIdentifier(), diagnosticMessage); @@ -6187,7 +6264,7 @@ var ts; return token === 9 || token === 8 || ts.tokenIsIdentifierOrKeyword(token); } function parseComputedPropertyName() { - var node = createNode(134); + var node = createNode(136); parseExpected(19); node.expression = allowInAnd(parseExpression); parseExpected(20); @@ -6197,20 +6274,27 @@ var ts; return token === t && tryParse(nextTokenCanFollowModifier); } function nextTokenCanFollowModifier() { - if (token === 72) { - return nextToken() === 79; + if (token === 74) { + return nextToken() === 81; } - if (token === 80) { + if (token === 82) { nextToken(); - if (token === 75) { + if (token === 77) { return lookAhead(nextTokenIsClassOrFunction); } return token !== 37 && token !== 15 && canFollowModifier(); } - if (token === 75) { + if (token === 77) { return nextTokenIsClassOrFunction(); } + if (token === 113) { + nextToken(); + return canFollowModifier(); + } nextToken(); + if (scanner.hasPrecedingLineBreak()) { + return false; + } return canFollowModifier(); } function parseAnyContextualModifier() { @@ -6224,7 +6308,7 @@ var ts; } function nextTokenIsClassOrFunction() { nextToken(); - return token === 71 || token === 85; + return token === 73 || token === 87; } function isListElement(parsingContext, inErrorRecovery) { var node = currentNode(parsingContext); @@ -6237,7 +6321,7 @@ var ts; case 3: return !(token === 23 && inErrorRecovery) && isStartOfStatement(); case 2: - return token === 69 || token === 75; + return token === 71 || token === 77; case 4: return isStartOfTypeMember(); case 5: @@ -6293,7 +6377,7 @@ var ts; ts.Debug.assert(token === 15); if (nextToken() === 16) { var next = nextToken(); - return next === 24 || next === 15 || next === 81 || next === 104; + return next === 24 || next === 15 || next === 83 || next === 106; } return true; } @@ -6306,8 +6390,8 @@ var ts; return ts.tokenIsIdentifierOrKeyword(token); } function isHeritageClauseExtendsOrImplementsKeyword() { - if (token === 104 || - token === 81) { + if (token === 106 || + token === 83) { return lookAhead(nextTokenIsStartOfExpression); } return false; @@ -6331,13 +6415,13 @@ var ts; case 21: return token === 16; case 3: - return token === 16 || token === 69 || token === 75; + return token === 16 || token === 71 || token === 77; case 7: - return token === 15 || token === 81 || token === 104; + return token === 15 || token === 83 || token === 106; case 8: return isVariableDeclaratorListTerminator(); case 17: - return token === 27 || token === 17 || token === 15 || token === 81 || token === 104; + return token === 27 || token === 17 || token === 15 || token === 83 || token === 106; case 11: return token === 18 || token === 23; case 15: @@ -6351,11 +6435,11 @@ var ts; case 20: return token === 15 || token === 16; case 13: - return token === 27 || token === 38; + return token === 27 || token === 39; case 14: return token === 25 && lookAhead(nextTokenIsSlash); case 22: - return token === 18 || token === 53 || token === 16; + return token === 18 || token === 54 || token === 16; case 23: return token === 27 || token === 16; case 25: @@ -6476,17 +6560,17 @@ var ts; function isReusableClassMember(node) { if (node) { switch (node.kind) { - case 142: - case 147: - case 143: case 144: - case 139: - case 189: - return true; + case 149: + case 145: + case 146: case 141: + case 191: + return true; + case 143: var methodDeclaration = node; - var nameIsConstructor = methodDeclaration.name.kind === 67 && - methodDeclaration.name.originalKeywordKind === 119; + var nameIsConstructor = methodDeclaration.name.kind === 69 && + methodDeclaration.name.originalKeywordKind === 121; return !nameIsConstructor; } } @@ -6495,8 +6579,8 @@ var ts; function isReusableSwitchClause(node) { if (node) { switch (node.kind) { - case 239: - case 240: + case 241: + case 242: return true; } } @@ -6505,65 +6589,65 @@ var ts; function isReusableStatement(node) { if (node) { switch (node.kind) { - case 211: - case 191: - case 190: - case 194: + case 213: case 193: - case 206: - case 202: - case 204: - case 201: - case 200: - case 198: - case 199: - case 197: - case 196: - case 203: case 192: - case 207: - case 205: + case 196: case 195: case 208: - case 220: - case 219: - case 226: - case 225: - case 216: - case 212: - case 213: - case 215: + case 204: + case 206: + case 203: + case 202: + case 200: + case 201: + case 199: + case 198: + case 205: + case 194: + case 209: + case 207: + case 197: + case 210: + case 222: + case 221: + case 228: + case 227: + case 218: case 214: + case 215: + case 217: + case 216: return true; } } return false; } function isReusableEnumMember(node) { - return node.kind === 245; + return node.kind === 247; } function isReusableTypeMember(node) { if (node) { switch (node.kind) { - case 146: + case 148: + case 142: + case 149: case 140: case 147: - case 138: - case 145: return true; } } return false; } function isReusableVariableDeclaration(node) { - if (node.kind !== 209) { + if (node.kind !== 211) { return false; } var variableDeclarator = node; return variableDeclarator.initializer === undefined; } function isReusableParameter(node) { - if (node.kind !== 136) { + if (node.kind !== 138) { return false; } var parameter = node; @@ -6663,7 +6747,7 @@ var ts; function parseEntityName(allowReservedWords, diagnosticMessage) { var entity = parseIdentifier(diagnosticMessage); while (parseOptional(21)) { - var node = createNode(133, entity.pos); + var node = createNode(135, entity.pos); node.left = entity; node.right = parseRightSideOfDot(allowReservedWords); entity = finishNode(node); @@ -6674,13 +6758,13 @@ var ts; if (scanner.hasPrecedingLineBreak() && ts.tokenIsIdentifierOrKeyword(token)) { var matchesPattern = lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine); if (matchesPattern) { - return createMissingNode(67, true, ts.Diagnostics.Identifier_expected); + return createMissingNode(69, true, ts.Diagnostics.Identifier_expected); } } return allowIdentifierNames ? parseIdentifierName() : parseIdentifier(); } function parseTemplateExpression() { - var template = createNode(181); + var template = createNode(183); template.head = parseLiteralNode(); ts.Debug.assert(template.head.kind === 12, "Template head has wrong token kind"); var templateSpans = []; @@ -6693,7 +6777,7 @@ var ts; return finishNode(template); } function parseTemplateSpan() { - var span = createNode(188); + var span = createNode(190); span.expression = allowInAnd(parseExpression); var literal; if (token === 16) { @@ -6728,14 +6812,14 @@ var ts; } function parseTypeReferenceOrTypePredicate() { var typeName = parseEntityName(false, ts.Diagnostics.Type_expected); - if (typeName.kind === 67 && token === 122 && !scanner.hasPrecedingLineBreak()) { + if (typeName.kind === 69 && token === 124 && !scanner.hasPrecedingLineBreak()) { nextToken(); - var node_1 = createNode(148, typeName.pos); + var node_1 = createNode(150, typeName.pos); node_1.parameterName = typeName; node_1.type = parseType(); return finishNode(node_1); } - var node = createNode(149, typeName.pos); + var node = createNode(151, typeName.pos); node.typeName = typeName; if (!scanner.hasPrecedingLineBreak() && token === 25) { node.typeArguments = parseBracketedList(18, parseType, 25, 27); @@ -6743,15 +6827,15 @@ var ts; return finishNode(node); } function parseTypeQuery() { - var node = createNode(152); - parseExpected(99); + var node = createNode(154); + parseExpected(101); node.exprName = parseEntityName(true); return finishNode(node); } function parseTypeParameter() { - var node = createNode(135); + var node = createNode(137); node.name = parseIdentifier(); - if (parseOptional(81)) { + if (parseOptional(83)) { if (isStartOfType() || !isStartOfExpression()) { node.constraint = parseType(); } @@ -6767,7 +6851,7 @@ var ts; } } function parseParameterType() { - if (parseOptional(53)) { + if (parseOptional(54)) { return token === 9 ? parseLiteralNode(true) : parseType(); @@ -6775,7 +6859,7 @@ var ts; return undefined; } function isStartOfParameter() { - return token === 22 || isIdentifierOrPattern() || ts.isModifier(token) || token === 54; + return token === 22 || isIdentifierOrPattern() || ts.isModifier(token) || token === 55; } function setModifiers(node, modifiers) { if (modifiers) { @@ -6784,7 +6868,7 @@ var ts; } } function parseParameter() { - var node = createNode(136); + var node = createNode(138); node.decorators = parseDecorators(); setModifiers(node, parseModifiers()); node.dotDotDotToken = parseOptionalToken(22); @@ -6792,7 +6876,7 @@ var ts; if (ts.getFullWidth(node.name) === 0 && node.flags === 0 && ts.isModifier(token)) { nextToken(); } - node.questionToken = parseOptionalToken(52); + node.questionToken = parseOptionalToken(53); node.type = parseParameterType(); node.initializer = parseBindingElementInitializer(true); return finishNode(node); @@ -6839,10 +6923,10 @@ var ts; } function parseSignatureMember(kind) { var node = createNode(kind); - if (kind === 146) { - parseExpected(90); + if (kind === 148) { + parseExpected(92); } - fillSignature(53, false, false, false, node); + fillSignature(54, false, false, false, node); parseTypeMemberSemicolon(); return finishNode(node); } @@ -6869,17 +6953,17 @@ var ts; else { nextToken(); } - if (token === 53 || token === 24) { + if (token === 54 || token === 24) { return true; } - if (token !== 52) { + if (token !== 53) { return false; } nextToken(); - return token === 53 || token === 24 || token === 20; + return token === 54 || token === 24 || token === 20; } function parseIndexSignatureDeclaration(fullStart, decorators, modifiers) { - var node = createNode(147, fullStart); + var node = createNode(149, fullStart); node.decorators = decorators; setModifiers(node, modifiers); node.parameters = parseBracketedList(16, parseParameter, 19, 20); @@ -6890,17 +6974,17 @@ var ts; function parsePropertyOrMethodSignature() { var fullStart = scanner.getStartPos(); var name = parsePropertyName(); - var questionToken = parseOptionalToken(52); + var questionToken = parseOptionalToken(53); if (token === 17 || token === 25) { - var method = createNode(140, fullStart); + var method = createNode(142, fullStart); method.name = name; method.questionToken = questionToken; - fillSignature(53, false, false, false, method); + fillSignature(54, false, false, false, method); parseTypeMemberSemicolon(); return finishNode(method); } else { - var property = createNode(138, fullStart); + var property = createNode(140, fullStart); property.name = name; property.questionToken = questionToken; property.type = parseTypeAnnotation(); @@ -6934,22 +7018,22 @@ var ts; nextToken(); return token === 17 || token === 25 || - token === 52 || token === 53 || + token === 54 || canParseSemicolon(); } function parseTypeMember() { switch (token) { case 17: case 25: - return parseSignatureMember(145); + return parseSignatureMember(147); case 19: return isIndexSignature() ? parseIndexSignatureDeclaration(scanner.getStartPos(), undefined, undefined) : parsePropertyOrMethodSignature(); - case 90: + case 92: if (lookAhead(isStartOfConstructSignature)) { - return parseSignatureMember(146); + return parseSignatureMember(148); } case 9: case 8: @@ -6979,7 +7063,7 @@ var ts; return token === 17 || token === 25; } function parseTypeLiteral() { - var node = createNode(153); + var node = createNode(155); node.members = parseObjectTypeMembers(); return finishNode(node); } @@ -6995,12 +7079,12 @@ var ts; return members; } function parseTupleType() { - var node = createNode(155); + var node = createNode(157); node.elementTypes = parseBracketedList(19, parseType, 19, 20); return finishNode(node); } function parseParenthesizedType() { - var node = createNode(158); + var node = createNode(160); parseExpected(17); node.type = parseType(); parseExpected(18); @@ -7008,8 +7092,8 @@ var ts; } function parseFunctionOrConstructorType(kind) { var node = createNode(kind); - if (kind === 151) { - parseExpected(90); + if (kind === 153) { + parseExpected(92); } fillSignature(34, false, false, false, node); return finishNode(node); @@ -7020,16 +7104,17 @@ var ts; } function parseNonArrayType() { switch (token) { - case 115: + case 117: + case 130: case 128: - case 126: - case 118: - case 129: + case 120: + case 131: var node = tryParse(parseKeywordAndNoDot); return node || parseTypeReferenceOrTypePredicate(); - case 101: + case 103: + case 97: return parseTokenNode(); - case 99: + case 101: return parseTypeQuery(); case 15: return parseTypeLiteral(); @@ -7043,17 +7128,18 @@ var ts; } function isStartOfType() { switch (token) { - case 115: + case 117: + case 130: case 128: - case 126: - case 118: - case 129: + case 120: + case 131: + case 103: + case 97: case 101: - case 99: case 15: case 19: case 25: - case 90: + case 92: return true; case 17: return lookAhead(isStartOfParenthesizedOrFunctionType); @@ -7069,7 +7155,7 @@ var ts; var type = parseNonArrayType(); while (!scanner.hasPrecedingLineBreak() && parseOptional(19)) { parseExpected(20); - var node = createNode(154, type.pos); + var node = createNode(156, type.pos); node.elementType = type; type = finishNode(node); } @@ -7091,10 +7177,10 @@ var ts; return type; } function parseIntersectionTypeOrHigher() { - return parseUnionOrIntersectionType(157, parseArrayTypeOrHigher, 45); + return parseUnionOrIntersectionType(159, parseArrayTypeOrHigher, 46); } function parseUnionTypeOrHigher() { - return parseUnionOrIntersectionType(156, parseIntersectionTypeOrHigher, 46); + return parseUnionOrIntersectionType(158, parseIntersectionTypeOrHigher, 47); } function isStartOfFunctionType() { if (token === 25) { @@ -7109,8 +7195,8 @@ var ts; } if (isIdentifier() || ts.isModifier(token)) { nextToken(); - if (token === 53 || token === 24 || - token === 52 || token === 55 || + if (token === 54 || token === 24 || + token === 53 || token === 56 || isIdentifier() || ts.isModifier(token)) { return true; } @@ -7128,23 +7214,23 @@ var ts; } function parseTypeWorker() { if (isStartOfFunctionType()) { - return parseFunctionOrConstructorType(150); + return parseFunctionOrConstructorType(152); } - if (token === 90) { - return parseFunctionOrConstructorType(151); + if (token === 92) { + return parseFunctionOrConstructorType(153); } return parseUnionTypeOrHigher(); } function parseTypeAnnotation() { - return parseOptional(53) ? parseType() : undefined; + return parseOptional(54) ? parseType() : undefined; } function isStartOfLeftHandSideExpression() { switch (token) { + case 97: case 95: case 93: - case 91: - case 97: - case 82: + case 99: + case 84: case 8: case 9: case 11: @@ -7152,12 +7238,12 @@ var ts; case 17: case 19: case 15: - case 85: - case 71: - case 90: - case 38: - case 59: - case 67: + case 87: + case 73: + case 92: + case 39: + case 61: + case 69: return true; default: return isIdentifier(); @@ -7170,16 +7256,16 @@ var ts; switch (token) { case 35: case 36: + case 50: case 49: - case 48: - case 76: - case 99: + case 78: case 101: - case 40: + case 103: case 41: + case 42: case 25: - case 117: - case 112: + case 119: + case 114: return true; default: if (isBinaryOperator()) { @@ -7190,9 +7276,9 @@ var ts; } function isStartOfExpressionStatement() { return token !== 15 && - token !== 85 && - token !== 71 && - token !== 54 && + token !== 87 && + token !== 73 && + token !== 55 && isStartOfExpression(); } function allowInAndParseExpression() { @@ -7214,12 +7300,12 @@ var ts; return expr; } function parseInitializer(inParameter) { - if (token !== 55) { + if (token !== 56) { if (scanner.hasPrecedingLineBreak() || (inParameter && token === 15) || !isStartOfExpression()) { return undefined; } } - parseExpected(55); + parseExpected(56); return parseAssignmentExpressionOrHigher(); } function parseAssignmentExpressionOrHigher() { @@ -7231,7 +7317,7 @@ var ts; return arrowExpression; } var expr = parseBinaryExpressionOrHigher(0); - if (expr.kind === 67 && token === 34) { + if (expr.kind === 69 && token === 34) { return parseSimpleArrowFunctionExpression(expr); } if (ts.isLeftHandSideExpression(expr) && ts.isAssignmentOperator(reScanGreaterToken())) { @@ -7240,7 +7326,7 @@ var ts; return parseConditionalExpressionRest(expr); } function isYieldExpression() { - if (token === 112) { + if (token === 114) { if (inYieldContext()) { return true; } @@ -7253,7 +7339,7 @@ var ts; return !scanner.hasPrecedingLineBreak() && isIdentifier(); } function parseYieldExpression() { - var node = createNode(182); + var node = createNode(184); nextToken(); if (!scanner.hasPrecedingLineBreak() && (token === 37 || isStartOfExpression())) { @@ -7267,8 +7353,8 @@ var ts; } function parseSimpleArrowFunctionExpression(identifier) { ts.Debug.assert(token === 34, "parseSimpleArrowFunctionExpression should only have been called if we had a =>"); - var node = createNode(172, identifier.pos); - var parameter = createNode(136, identifier.pos); + var node = createNode(174, identifier.pos); + var parameter = createNode(138, identifier.pos); parameter.name = identifier; finishNode(parameter); node.parameters = [parameter]; @@ -7298,7 +7384,7 @@ var ts; return finishNode(arrowFunction); } function isParenthesizedArrowFunctionExpression() { - if (token === 17 || token === 25 || token === 116) { + if (token === 17 || token === 25 || token === 118) { return lookAhead(isParenthesizedArrowFunctionExpressionWorker); } if (token === 34) { @@ -7307,7 +7393,7 @@ var ts; return 0; } function isParenthesizedArrowFunctionExpressionWorker() { - if (token === 116) { + if (token === 118) { nextToken(); if (scanner.hasPrecedingLineBreak()) { return 0; @@ -7323,7 +7409,7 @@ var ts; var third = nextToken(); switch (third) { case 34: - case 53: + case 54: case 15: return 1; default: @@ -7339,7 +7425,7 @@ var ts; if (!isIdentifier()) { return 0; } - if (nextToken() === 53) { + if (nextToken() === 54) { return 1; } return 2; @@ -7352,10 +7438,10 @@ var ts; if (sourceFile.languageVariant === 1) { var isArrowFunctionInJsx = lookAhead(function () { var third = nextToken(); - if (third === 81) { + if (third === 83) { var fourth = nextToken(); switch (fourth) { - case 55: + case 56: case 27: return false; default: @@ -7379,10 +7465,10 @@ var ts; return parseParenthesizedArrowFunctionExpressionHead(false); } function parseParenthesizedArrowFunctionExpressionHead(allowAmbiguity) { - var node = createNode(172); + var node = createNode(174); setModifiers(node, parseModifiersForArrowFunction()); var isAsync = !!(node.flags & 512); - fillSignature(53, false, isAsync, !allowAmbiguity, node); + fillSignature(54, false, isAsync, !allowAmbiguity, node); if (!node.parameters) { return undefined; } @@ -7396,8 +7482,8 @@ var ts; return parseFunctionBlock(false, isAsync, false); } if (token !== 23 && - token !== 85 && - token !== 71 && + token !== 87 && + token !== 73 && isStartOfStatement() && !isStartOfExpressionStatement()) { return parseFunctionBlock(false, isAsync, true); @@ -7407,15 +7493,15 @@ var ts; : doOutsideOfAwaitContext(parseAssignmentExpressionOrHigher); } function parseConditionalExpressionRest(leftOperand) { - var questionToken = parseOptionalToken(52); + var questionToken = parseOptionalToken(53); if (!questionToken) { return leftOperand; } - var node = createNode(180, leftOperand.pos); + var node = createNode(182, leftOperand.pos); node.condition = leftOperand; node.questionToken = questionToken; node.whenTrue = doOutsideOfContext(disallowInAndDecoratorContext, parseAssignmentExpressionOrHigher); - node.colonToken = parseExpectedToken(53, false, ts.Diagnostics._0_expected, ts.tokenToString(53)); + node.colonToken = parseExpectedToken(54, false, ts.Diagnostics._0_expected, ts.tokenToString(54)); node.whenFalse = parseAssignmentExpressionOrHigher(); return finishNode(node); } @@ -7424,19 +7510,22 @@ var ts; return parseBinaryExpressionRest(precedence, leftOperand); } function isInOrOfKeyword(t) { - return t === 88 || t === 132; + return t === 90 || t === 134; } function parseBinaryExpressionRest(precedence, leftOperand) { while (true) { reScanGreaterToken(); var newPrecedence = getBinaryOperatorPrecedence(); - if (newPrecedence <= precedence) { + var consumeCurrentOperator = token === 38 ? + newPrecedence >= precedence : + newPrecedence > precedence; + if (!consumeCurrentOperator) { break; } - if (token === 88 && inDisallowInContext()) { + if (token === 90 && inDisallowInContext()) { break; } - if (token === 114) { + if (token === 116) { if (scanner.hasPrecedingLineBreak()) { break; } @@ -7452,22 +7541,22 @@ var ts; return leftOperand; } function isBinaryOperator() { - if (inDisallowInContext() && token === 88) { + if (inDisallowInContext() && token === 90) { return false; } return getBinaryOperatorPrecedence() > 0; } function getBinaryOperatorPrecedence() { switch (token) { - case 51: + case 52: return 1; - case 50: + case 51: return 2; - case 46: - return 3; case 47: + return 3; + case 48: return 4; - case 45: + case 46: return 5; case 30: case 31: @@ -7478,64 +7567,66 @@ var ts; case 27: case 28: case 29: - case 89: - case 88: - case 114: + case 91: + case 90: + case 116: return 7; - case 42: case 43: case 44: + case 45: return 8; case 35: case 36: return 9; case 37: - case 38: case 39: + case 40: return 10; + case 38: + return 11; } return -1; } function makeBinaryExpression(left, operatorToken, right) { - var node = createNode(179, left.pos); + var node = createNode(181, left.pos); node.left = left; node.operatorToken = operatorToken; node.right = right; return finishNode(node); } function makeAsExpression(left, right) { - var node = createNode(187, left.pos); + var node = createNode(189, left.pos); node.expression = left; node.type = right; return finishNode(node); } function parsePrefixUnaryExpression() { - var node = createNode(177); + var node = createNode(179); node.operator = token; nextToken(); - node.operand = parseUnaryExpressionOrHigher(); + node.operand = parseSimpleUnaryExpression(); return finishNode(node); } function parseDeleteExpression() { - var node = createNode(173); + var node = createNode(175); nextToken(); - node.expression = parseUnaryExpressionOrHigher(); + node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function parseTypeOfExpression() { - var node = createNode(174); + var node = createNode(176); nextToken(); - node.expression = parseUnaryExpressionOrHigher(); + node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function parseVoidExpression() { - var node = createNode(175); + var node = createNode(177); nextToken(); - node.expression = parseUnaryExpressionOrHigher(); + node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function isAwaitExpression() { - if (token === 117) { + if (token === 119) { if (inAwaitContext()) { return true; } @@ -7544,45 +7635,87 @@ var ts; return false; } function parseAwaitExpression() { - var node = createNode(176); + var node = createNode(178); nextToken(); - node.expression = parseUnaryExpressionOrHigher(); + node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function parseUnaryExpressionOrHigher() { if (isAwaitExpression()) { return parseAwaitExpression(); } + if (isIncrementExpression()) { + var incrementExpression = parseIncrementExpression(); + return token === 38 ? + parseBinaryExpressionRest(getBinaryOperatorPrecedence(), incrementExpression) : + incrementExpression; + } + var unaryOperator = token; + var simpleUnaryExpression = parseSimpleUnaryExpression(); + if (token === 38) { + var diagnostic; + var start = ts.skipTrivia(sourceText, simpleUnaryExpression.pos); + if (simpleUnaryExpression.kind === 171) { + parseErrorAtPosition(start, simpleUnaryExpression.end - start, ts.Diagnostics.A_type_assertion_expression_is_not_allowed_in_the_left_hand_side_of_an_exponentiation_expression_Consider_enclosing_the_expression_in_parentheses); + } + else { + parseErrorAtPosition(start, simpleUnaryExpression.end - start, ts.Diagnostics.An_unary_expression_with_the_0_operator_is_not_allowed_in_the_left_hand_side_of_an_exponentiation_expression_Consider_enclosing_the_expression_in_parentheses, ts.tokenToString(unaryOperator)); + } + } + return simpleUnaryExpression; + } + function parseSimpleUnaryExpression() { switch (token) { case 35: case 36: + case 50: case 49: - case 48: - case 40: - case 41: return parsePrefixUnaryExpression(); - case 76: + case 78: return parseDeleteExpression(); - case 99: - return parseTypeOfExpression(); case 101: + return parseTypeOfExpression(); + case 103: return parseVoidExpression(); case 25: - if (sourceFile.languageVariant !== 1) { - return parseTypeAssertion(); - } - if (lookAhead(nextTokenIsIdentifierOrKeyword)) { - return parseJsxElementOrSelfClosingElement(true); - } + return parseTypeAssertion(); default: - return parsePostfixExpressionOrHigher(); + return parseIncrementExpression(); } } - function parsePostfixExpressionOrHigher() { + function isIncrementExpression() { + switch (token) { + case 35: + case 36: + case 50: + case 49: + case 78: + case 101: + case 103: + return false; + case 25: + if (sourceFile.languageVariant !== 1) { + return false; + } + default: + return true; + } + } + function parseIncrementExpression() { + if (token === 41 || token === 42) { + var node = createNode(179); + node.operator = token; + nextToken(); + node.operand = parseLeftHandSideExpressionOrHigher(); + return finishNode(node); + } + else if (sourceFile.languageVariant === 1 && token === 25 && lookAhead(nextTokenIsIdentifierOrKeyword)) { + return parseJsxElementOrSelfClosingElement(true); + } var expression = parseLeftHandSideExpressionOrHigher(); ts.Debug.assert(ts.isLeftHandSideExpression(expression)); - if ((token === 40 || token === 41) && !scanner.hasPrecedingLineBreak()) { - var node = createNode(178, expression.pos); + if ((token === 41 || token === 42) && !scanner.hasPrecedingLineBreak()) { + var node = createNode(180, expression.pos); node.operand = expression; node.operator = token; nextToken(); @@ -7591,7 +7724,7 @@ var ts; return expression; } function parseLeftHandSideExpressionOrHigher() { - var expression = token === 93 + var expression = token === 95 ? parseSuperExpression() : parseMemberExpressionOrHigher(); return parseCallExpressionRest(expression); @@ -7605,7 +7738,7 @@ var ts; if (token === 17 || token === 21 || token === 19) { return expression; } - var node = createNode(164, expression.pos); + var node = createNode(166, expression.pos); node.expression = expression; node.dotToken = parseExpectedToken(21, false, ts.Diagnostics.super_must_be_followed_by_an_argument_list_or_member_access); node.name = parseRightSideOfDot(true); @@ -7613,26 +7746,26 @@ var ts; } function parseJsxElementOrSelfClosingElement(inExpressionContext) { var opening = parseJsxOpeningOrSelfClosingElement(inExpressionContext); - if (opening.kind === 233) { - var node = createNode(231, opening.pos); + if (opening.kind === 235) { + var node = createNode(233, opening.pos); node.openingElement = opening; node.children = parseJsxChildren(node.openingElement.tagName); node.closingElement = parseJsxClosingElement(inExpressionContext); return finishNode(node); } else { - ts.Debug.assert(opening.kind === 232); + ts.Debug.assert(opening.kind === 234); return opening; } } function parseJsxText() { - var node = createNode(234, scanner.getStartPos()); + var node = createNode(236, scanner.getStartPos()); token = scanner.scanJsxToken(); return finishNode(node); } function parseJsxChild() { switch (token) { - case 234: + case 236: return parseJsxText(); case 15: return parseJsxExpression(false); @@ -7668,11 +7801,11 @@ var ts; var attributes = parseList(13, parseJsxAttribute); var node; if (token === 27) { - node = createNode(233, fullStart); + node = createNode(235, fullStart); scanJsxText(); } else { - parseExpected(38); + parseExpected(39); if (inExpressionContext) { parseExpected(27); } @@ -7680,7 +7813,7 @@ var ts; parseExpected(27, undefined, false); scanJsxText(); } - node = createNode(232, fullStart); + node = createNode(234, fullStart); } node.tagName = tagName; node.attributes = attributes; @@ -7691,7 +7824,7 @@ var ts; var elementName = parseIdentifierName(); while (parseOptional(21)) { scanJsxIdentifier(); - var node = createNode(133, elementName.pos); + var node = createNode(135, elementName.pos); node.left = elementName; node.right = parseIdentifierName(); elementName = finishNode(node); @@ -7699,7 +7832,7 @@ var ts; return elementName; } function parseJsxExpression(inExpressionContext) { - var node = createNode(238); + var node = createNode(240); parseExpected(15); if (token !== 16) { node.expression = parseExpression(); @@ -7718,9 +7851,9 @@ var ts; return parseJsxSpreadAttribute(); } scanJsxIdentifier(); - var node = createNode(236); + var node = createNode(238); node.name = parseIdentifierName(); - if (parseOptional(55)) { + if (parseOptional(56)) { switch (token) { case 9: node.initializer = parseLiteralNode(); @@ -7733,7 +7866,7 @@ var ts; return finishNode(node); } function parseJsxSpreadAttribute() { - var node = createNode(237); + var node = createNode(239); parseExpected(15); parseExpected(22); node.expression = parseExpression(); @@ -7741,7 +7874,7 @@ var ts; return finishNode(node); } function parseJsxClosingElement(inExpressionContext) { - var node = createNode(235); + var node = createNode(237); parseExpected(26); node.tagName = parseJsxElementName(); if (inExpressionContext) { @@ -7754,18 +7887,18 @@ var ts; return finishNode(node); } function parseTypeAssertion() { - var node = createNode(169); + var node = createNode(171); parseExpected(25); node.type = parseType(); parseExpected(27); - node.expression = parseUnaryExpressionOrHigher(); + node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function parseMemberExpressionRest(expression) { while (true) { var dotToken = parseOptionalToken(21); if (dotToken) { - var propertyAccess = createNode(164, expression.pos); + var propertyAccess = createNode(166, expression.pos); propertyAccess.expression = expression; propertyAccess.dotToken = dotToken; propertyAccess.name = parseRightSideOfDot(true); @@ -7773,7 +7906,7 @@ var ts; continue; } if (!inDecoratorContext() && parseOptional(19)) { - var indexedAccess = createNode(165, expression.pos); + var indexedAccess = createNode(167, expression.pos); indexedAccess.expression = expression; if (token !== 20) { indexedAccess.argumentExpression = allowInAnd(parseExpression); @@ -7787,7 +7920,7 @@ var ts; continue; } if (token === 11 || token === 12) { - var tagExpression = createNode(168, expression.pos); + var tagExpression = createNode(170, expression.pos); tagExpression.tag = expression; tagExpression.template = token === 11 ? parseLiteralNode() @@ -7806,7 +7939,7 @@ var ts; if (!typeArguments) { return expression; } - var callExpr = createNode(166, expression.pos); + var callExpr = createNode(168, expression.pos); callExpr.expression = expression; callExpr.typeArguments = typeArguments; callExpr.arguments = parseArgumentList(); @@ -7814,7 +7947,7 @@ var ts; continue; } else if (token === 17) { - var callExpr = createNode(166, expression.pos); + var callExpr = createNode(168, expression.pos); callExpr.expression = expression; callExpr.arguments = parseArgumentList(); expression = finishNode(callExpr); @@ -7847,18 +7980,18 @@ var ts; case 21: case 18: case 20: - case 53: + case 54: case 23: - case 52: + case 53: case 30: case 32: case 31: case 33: - case 50: case 51: - case 47: - case 45: + case 52: + case 48: case 46: + case 47: case 16: case 1: return true; @@ -7874,11 +8007,11 @@ var ts; case 9: case 11: return parseLiteralNode(); + case 97: case 95: case 93: - case 91: - case 97: - case 82: + case 99: + case 84: return parseTokenNode(); case 17: return parseParenthesizedExpression(); @@ -7886,19 +8019,19 @@ var ts; return parseArrayLiteralExpression(); case 15: return parseObjectLiteralExpression(); - case 116: + case 118: if (!lookAhead(nextTokenIsFunctionKeywordOnSameLine)) { break; } return parseFunctionExpression(); - case 71: + case 73: return parseClassExpression(); - case 85: + case 87: return parseFunctionExpression(); - case 90: + case 92: return parseNewExpression(); - case 38: - case 59: + case 39: + case 61: if (reScanSlashToken() === 10) { return parseLiteralNode(); } @@ -7909,28 +8042,28 @@ var ts; return parseIdentifier(ts.Diagnostics.Expression_expected); } function parseParenthesizedExpression() { - var node = createNode(170); + var node = createNode(172); parseExpected(17); node.expression = allowInAnd(parseExpression); parseExpected(18); return finishNode(node); } function parseSpreadElement() { - var node = createNode(183); + var node = createNode(185); parseExpected(22); node.expression = parseAssignmentExpressionOrHigher(); return finishNode(node); } function parseArgumentOrArrayLiteralElement() { return token === 22 ? parseSpreadElement() : - token === 24 ? createNode(185) : + token === 24 ? createNode(187) : parseAssignmentExpressionOrHigher(); } function parseArgumentExpression() { return doOutsideOfContext(disallowInAndDecoratorContext, parseArgumentOrArrayLiteralElement); } function parseArrayLiteralExpression() { - var node = createNode(162); + var node = createNode(164); parseExpected(19); if (scanner.hasPrecedingLineBreak()) node.flags |= 2048; @@ -7939,11 +8072,11 @@ var ts; return finishNode(node); } function tryParseAccessorDeclaration(fullStart, decorators, modifiers) { - if (parseContextualModifier(121)) { - return parseAccessorDeclaration(143, fullStart, decorators, modifiers); + if (parseContextualModifier(123)) { + return parseAccessorDeclaration(145, fullStart, decorators, modifiers); } - else if (parseContextualModifier(127)) { - return parseAccessorDeclaration(144, fullStart, decorators, modifiers); + else if (parseContextualModifier(129)) { + return parseAccessorDeclaration(146, fullStart, decorators, modifiers); } return undefined; } @@ -7959,27 +8092,33 @@ var ts; var tokenIsIdentifier = isIdentifier(); var nameToken = token; var propertyName = parsePropertyName(); - var questionToken = parseOptionalToken(52); + var questionToken = parseOptionalToken(53); if (asteriskToken || token === 17 || token === 25) { return parseMethodDeclaration(fullStart, decorators, modifiers, asteriskToken, propertyName, questionToken); } - if ((token === 24 || token === 16) && tokenIsIdentifier) { - var shorthandDeclaration = createNode(244, fullStart); + var isShorthandPropertyAssignment = tokenIsIdentifier && (token === 24 || token === 16 || token === 56); + if (isShorthandPropertyAssignment) { + var shorthandDeclaration = createNode(246, fullStart); shorthandDeclaration.name = propertyName; shorthandDeclaration.questionToken = questionToken; + var equalsToken = parseOptionalToken(56); + if (equalsToken) { + shorthandDeclaration.equalsToken = equalsToken; + shorthandDeclaration.objectAssignmentInitializer = allowInAnd(parseAssignmentExpressionOrHigher); + } return finishNode(shorthandDeclaration); } else { - var propertyAssignment = createNode(243, fullStart); + var propertyAssignment = createNode(245, fullStart); propertyAssignment.name = propertyName; propertyAssignment.questionToken = questionToken; - parseExpected(53); + parseExpected(54); propertyAssignment.initializer = allowInAnd(parseAssignmentExpressionOrHigher); return finishNode(propertyAssignment); } } function parseObjectLiteralExpression() { - var node = createNode(163); + var node = createNode(165); parseExpected(15); if (scanner.hasPrecedingLineBreak()) { node.flags |= 2048; @@ -7993,9 +8132,9 @@ var ts; if (saveDecoratorContext) { setDecoratorContext(false); } - var node = createNode(171); + var node = createNode(173); setModifiers(node, parseModifiers()); - parseExpected(85); + parseExpected(87); node.asteriskToken = parseOptionalToken(37); var isGenerator = !!node.asteriskToken; var isAsync = !!(node.flags & 512); @@ -8004,7 +8143,7 @@ var ts; isGenerator ? doInYieldContext(parseOptionalIdentifier) : isAsync ? doInAwaitContext(parseOptionalIdentifier) : parseOptionalIdentifier(); - fillSignature(53, isGenerator, isAsync, false, node); + fillSignature(54, isGenerator, isAsync, false, node); node.body = parseFunctionBlock(isGenerator, isAsync, false); if (saveDecoratorContext) { setDecoratorContext(true); @@ -8015,8 +8154,8 @@ var ts; return isIdentifier() ? parseIdentifier() : undefined; } function parseNewExpression() { - var node = createNode(167); - parseExpected(90); + var node = createNode(169); + parseExpected(92); node.expression = parseMemberExpressionOrHigher(); node.typeArguments = tryParse(parseTypeArgumentsInExpression); if (node.typeArguments || token === 17) { @@ -8025,7 +8164,7 @@ var ts; return finishNode(node); } function parseBlock(ignoreMissingOpenBrace, diagnosticMessage) { - var node = createNode(190); + var node = createNode(192); if (parseExpected(15, diagnosticMessage) || ignoreMissingOpenBrace) { node.statements = parseList(1, parseStatement); parseExpected(16); @@ -8053,25 +8192,25 @@ var ts; return block; } function parseEmptyStatement() { - var node = createNode(192); + var node = createNode(194); parseExpected(23); return finishNode(node); } function parseIfStatement() { - var node = createNode(194); - parseExpected(86); + var node = createNode(196); + parseExpected(88); parseExpected(17); node.expression = allowInAnd(parseExpression); parseExpected(18); node.thenStatement = parseStatement(); - node.elseStatement = parseOptional(78) ? parseStatement() : undefined; + node.elseStatement = parseOptional(80) ? parseStatement() : undefined; return finishNode(node); } function parseDoStatement() { - var node = createNode(195); - parseExpected(77); + var node = createNode(197); + parseExpected(79); node.statement = parseStatement(); - parseExpected(102); + parseExpected(104); parseExpected(17); node.expression = allowInAnd(parseExpression); parseExpected(18); @@ -8079,8 +8218,8 @@ var ts; return finishNode(node); } function parseWhileStatement() { - var node = createNode(196); - parseExpected(102); + var node = createNode(198); + parseExpected(104); parseExpected(17); node.expression = allowInAnd(parseExpression); parseExpected(18); @@ -8089,11 +8228,11 @@ var ts; } function parseForOrForInOrForOfStatement() { var pos = getNodePos(); - parseExpected(84); + parseExpected(86); parseExpected(17); var initializer = undefined; if (token !== 23) { - if (token === 100 || token === 106 || token === 72) { + if (token === 102 || token === 108 || token === 74) { initializer = parseVariableDeclarationList(true); } else { @@ -8101,22 +8240,22 @@ var ts; } } var forOrForInOrForOfStatement; - if (parseOptional(88)) { - var forInStatement = createNode(198, pos); + if (parseOptional(90)) { + var forInStatement = createNode(200, pos); forInStatement.initializer = initializer; forInStatement.expression = allowInAnd(parseExpression); parseExpected(18); forOrForInOrForOfStatement = forInStatement; } - else if (parseOptional(132)) { - var forOfStatement = createNode(199, pos); + else if (parseOptional(134)) { + var forOfStatement = createNode(201, pos); forOfStatement.initializer = initializer; forOfStatement.expression = allowInAnd(parseAssignmentExpressionOrHigher); parseExpected(18); forOrForInOrForOfStatement = forOfStatement; } else { - var forStatement = createNode(197, pos); + var forStatement = createNode(199, pos); forStatement.initializer = initializer; parseExpected(23); if (token !== 23 && token !== 18) { @@ -8134,7 +8273,7 @@ var ts; } function parseBreakOrContinueStatement(kind) { var node = createNode(kind); - parseExpected(kind === 201 ? 68 : 73); + parseExpected(kind === 203 ? 70 : 75); if (!canParseSemicolon()) { node.label = parseIdentifier(); } @@ -8142,8 +8281,8 @@ var ts; return finishNode(node); } function parseReturnStatement() { - var node = createNode(202); - parseExpected(92); + var node = createNode(204); + parseExpected(94); if (!canParseSemicolon()) { node.expression = allowInAnd(parseExpression); } @@ -8151,8 +8290,8 @@ var ts; return finishNode(node); } function parseWithStatement() { - var node = createNode(203); - parseExpected(103); + var node = createNode(205); + parseExpected(105); parseExpected(17); node.expression = allowInAnd(parseExpression); parseExpected(18); @@ -8160,30 +8299,30 @@ var ts; return finishNode(node); } function parseCaseClause() { - var node = createNode(239); - parseExpected(69); + var node = createNode(241); + parseExpected(71); node.expression = allowInAnd(parseExpression); - parseExpected(53); + parseExpected(54); node.statements = parseList(3, parseStatement); return finishNode(node); } function parseDefaultClause() { - var node = createNode(240); - parseExpected(75); - parseExpected(53); + var node = createNode(242); + parseExpected(77); + parseExpected(54); node.statements = parseList(3, parseStatement); return finishNode(node); } function parseCaseOrDefaultClause() { - return token === 69 ? parseCaseClause() : parseDefaultClause(); + return token === 71 ? parseCaseClause() : parseDefaultClause(); } function parseSwitchStatement() { - var node = createNode(204); - parseExpected(94); + var node = createNode(206); + parseExpected(96); parseExpected(17); node.expression = allowInAnd(parseExpression); parseExpected(18); - var caseBlock = createNode(218, scanner.getStartPos()); + var caseBlock = createNode(220, scanner.getStartPos()); parseExpected(15); caseBlock.clauses = parseList(2, parseCaseOrDefaultClause); parseExpected(16); @@ -8191,26 +8330,26 @@ var ts; return finishNode(node); } function parseThrowStatement() { - var node = createNode(206); - parseExpected(96); + var node = createNode(208); + parseExpected(98); node.expression = scanner.hasPrecedingLineBreak() ? undefined : allowInAnd(parseExpression); parseSemicolon(); return finishNode(node); } function parseTryStatement() { - var node = createNode(207); - parseExpected(98); + var node = createNode(209); + parseExpected(100); node.tryBlock = parseBlock(false); - node.catchClause = token === 70 ? parseCatchClause() : undefined; - if (!node.catchClause || token === 83) { - parseExpected(83); + node.catchClause = token === 72 ? parseCatchClause() : undefined; + if (!node.catchClause || token === 85) { + parseExpected(85); node.finallyBlock = parseBlock(false); } return finishNode(node); } function parseCatchClause() { - var result = createNode(242); - parseExpected(70); + var result = createNode(244); + parseExpected(72); if (parseExpected(17)) { result.variableDeclaration = parseVariableDeclaration(); } @@ -8219,22 +8358,22 @@ var ts; return finishNode(result); } function parseDebuggerStatement() { - var node = createNode(208); - parseExpected(74); + var node = createNode(210); + parseExpected(76); parseSemicolon(); return finishNode(node); } function parseExpressionOrLabeledStatement() { var fullStart = scanner.getStartPos(); var expression = allowInAnd(parseExpression); - if (expression.kind === 67 && parseOptional(53)) { - var labeledStatement = createNode(205, fullStart); + if (expression.kind === 69 && parseOptional(54)) { + var labeledStatement = createNode(207, fullStart); labeledStatement.label = expression; labeledStatement.statement = parseStatement(); return finishNode(labeledStatement); } else { - var expressionStatement = createNode(193, fullStart); + var expressionStatement = createNode(195, fullStart); expressionStatement.expression = expression; parseSemicolon(); return finishNode(expressionStatement); @@ -8246,7 +8385,7 @@ var ts; } function nextTokenIsFunctionKeywordOnSameLine() { nextToken(); - return token === 85 && !scanner.hasPrecedingLineBreak(); + return token === 87 && !scanner.hasPrecedingLineBreak(); } function nextTokenIsIdentifierOrKeywordOrNumberOnSameLine() { nextToken(); @@ -8255,41 +8394,41 @@ var ts; function isDeclaration() { while (true) { switch (token) { - case 100: - case 106: - case 72: - case 85: - case 71: - case 79: + case 102: + case 108: + case 74: + case 87: + case 73: + case 81: return true; - case 105: - case 130: + case 107: + case 132: return nextTokenIsIdentifierOnSameLine(); - case 123: - case 124: + case 125: + case 126: return nextTokenIsIdentifierOrStringLiteralOnSameLine(); - case 116: - case 120: + case 115: + case 118: + case 122: + case 110: + case 111: + case 112: nextToken(); if (scanner.hasPrecedingLineBreak()) { return false; } continue; - case 87: + case 89: nextToken(); return token === 9 || token === 37 || token === 15 || ts.tokenIsIdentifierOrKeyword(token); - case 80: + case 82: nextToken(); - if (token === 55 || token === 37 || - token === 15 || token === 75) { + if (token === 56 || token === 37 || + token === 15 || token === 77) { return true; } continue; - case 110: - case 108: - case 109: - case 111: case 113: nextToken(); continue; @@ -8303,44 +8442,44 @@ var ts; } function isStartOfStatement() { switch (token) { - case 54: + case 55: case 23: case 15: - case 100: - case 106: - case 85: - case 71: - case 79: - case 86: - case 77: case 102: - case 84: + case 108: + case 87: case 73: - case 68: - case 92: - case 103: + case 81: + case 88: + case 79: + case 104: + case 86: + case 75: + case 70: case 94: + case 105: case 96: case 98: - case 74: - case 70: - case 83: - return true; + case 100: + case 76: case 72: - case 80: - case 87: - return isStartOfDeclaration(); - case 116: - case 120: - case 105: - case 123: - case 124: - case 130: + case 85: return true; + case 74: + case 82: + case 89: + return isStartOfDeclaration(); + case 118: + case 122: + case 107: + case 125: + case 126: + case 132: + return true; + case 112: case 110: - case 108: - case 109: case 111: + case 113: return isStartOfDeclaration() || !lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine); default: return isStartOfExpression(); @@ -8359,60 +8498,60 @@ var ts; return parseEmptyStatement(); case 15: return parseBlock(false); - case 100: + case 102: return parseVariableStatement(scanner.getStartPos(), undefined, undefined); - case 106: + case 108: if (isLetDeclaration()) { return parseVariableStatement(scanner.getStartPos(), undefined, undefined); } break; - case 85: - return parseFunctionDeclaration(scanner.getStartPos(), undefined, undefined); - case 71: - return parseClassDeclaration(scanner.getStartPos(), undefined, undefined); - case 86: - return parseIfStatement(); - case 77: - return parseDoStatement(); - case 102: - return parseWhileStatement(); - case 84: - return parseForOrForInOrForOfStatement(); - case 73: - return parseBreakOrContinueStatement(200); - case 68: - return parseBreakOrContinueStatement(201); - case 92: - return parseReturnStatement(); - case 103: - return parseWithStatement(); - case 94: - return parseSwitchStatement(); - case 96: - return parseThrowStatement(); - case 98: - case 70: - case 83: - return parseTryStatement(); - case 74: - return parseDebuggerStatement(); - case 54: - return parseDeclaration(); - case 116: - case 105: - case 130: - case 123: - case 124: - case 120: - case 72: - case 79: - case 80: case 87: - case 108: - case 109: + 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(202); + case 70: + return parseBreakOrContinueStatement(203); + 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 132: + case 125: + case 126: + case 122: + case 74: + case 81: + case 82: + case 89: case 110: - case 113: case 111: + case 112: + case 115: + case 113: if (isStartOfDeclaration()) { return parseDeclaration(); } @@ -8425,33 +8564,33 @@ var ts; var decorators = parseDecorators(); var modifiers = parseModifiers(); switch (token) { - case 100: - case 106: - case 72: + case 102: + case 108: + case 74: return parseVariableStatement(fullStart, decorators, modifiers); - case 85: - return parseFunctionDeclaration(fullStart, decorators, modifiers); - case 71: - return parseClassDeclaration(fullStart, decorators, modifiers); - case 105: - return parseInterfaceDeclaration(fullStart, decorators, modifiers); - case 130: - return parseTypeAliasDeclaration(fullStart, decorators, modifiers); - case 79: - return parseEnumDeclaration(fullStart, decorators, modifiers); - case 123: - case 124: - return parseModuleDeclaration(fullStart, decorators, modifiers); case 87: + return parseFunctionDeclaration(fullStart, decorators, modifiers); + case 73: + return parseClassDeclaration(fullStart, decorators, modifiers); + case 107: + return parseInterfaceDeclaration(fullStart, decorators, modifiers); + case 132: + return parseTypeAliasDeclaration(fullStart, decorators, modifiers); + case 81: + return parseEnumDeclaration(fullStart, decorators, modifiers); + case 125: + case 126: + return parseModuleDeclaration(fullStart, decorators, modifiers); + case 89: return parseImportDeclarationOrImportEqualsDeclaration(fullStart, decorators, modifiers); - case 80: + case 82: nextToken(); - return token === 75 || token === 55 ? + return token === 77 || token === 56 ? parseExportAssignment(fullStart, decorators, modifiers) : parseExportDeclaration(fullStart, decorators, modifiers); default: if (decorators || modifiers) { - var node = createMissingNode(229, true, ts.Diagnostics.Declaration_expected); + var node = createMissingNode(231, true, ts.Diagnostics.Declaration_expected); node.pos = fullStart; node.decorators = decorators; setModifiers(node, modifiers); @@ -8472,23 +8611,23 @@ var ts; } function parseArrayBindingElement() { if (token === 24) { - return createNode(185); + return createNode(187); } - var node = createNode(161); + var node = createNode(163); node.dotDotDotToken = parseOptionalToken(22); node.name = parseIdentifierOrPattern(); node.initializer = parseBindingElementInitializer(false); return finishNode(node); } function parseObjectBindingElement() { - var node = createNode(161); + var node = createNode(163); var tokenIsIdentifier = isIdentifier(); var propertyName = parsePropertyName(); - if (tokenIsIdentifier && token !== 53) { + if (tokenIsIdentifier && token !== 54) { node.name = propertyName; } else { - parseExpected(53); + parseExpected(54); node.propertyName = propertyName; node.name = parseIdentifierOrPattern(); } @@ -8496,14 +8635,14 @@ var ts; return finishNode(node); } function parseObjectBindingPattern() { - var node = createNode(159); + var node = createNode(161); parseExpected(15); node.elements = parseDelimitedList(9, parseObjectBindingElement); parseExpected(16); return finishNode(node); } function parseArrayBindingPattern() { - var node = createNode(160); + var node = createNode(162); parseExpected(19); node.elements = parseDelimitedList(10, parseArrayBindingElement); parseExpected(20); @@ -8522,7 +8661,7 @@ var ts; return parseIdentifier(); } function parseVariableDeclaration() { - var node = createNode(209); + var node = createNode(211); node.name = parseIdentifierOrPattern(); node.type = parseTypeAnnotation(); if (!isInOrOfKeyword(token)) { @@ -8531,21 +8670,21 @@ var ts; return finishNode(node); } function parseVariableDeclarationList(inForStatementInitializer) { - var node = createNode(210); + var node = createNode(212); switch (token) { - case 100: + case 102: break; - case 106: + case 108: node.flags |= 16384; break; - case 72: + case 74: node.flags |= 32768; break; default: ts.Debug.fail(); } nextToken(); - if (token === 132 && lookAhead(canFollowContextualOfKeyword)) { + if (token === 134 && lookAhead(canFollowContextualOfKeyword)) { node.declarations = createMissingList(); } else { @@ -8560,7 +8699,7 @@ var ts; return nextTokenIsIdentifier() && nextToken() === 18; } function parseVariableStatement(fullStart, decorators, modifiers) { - var node = createNode(191, fullStart); + var node = createNode(193, fullStart); node.decorators = decorators; setModifiers(node, modifiers); node.declarationList = parseVariableDeclarationList(false); @@ -8568,29 +8707,29 @@ var ts; return finishNode(node); } function parseFunctionDeclaration(fullStart, decorators, modifiers) { - var node = createNode(211, fullStart); + var node = createNode(213, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - parseExpected(85); + parseExpected(87); node.asteriskToken = parseOptionalToken(37); node.name = node.flags & 1024 ? parseOptionalIdentifier() : parseIdentifier(); var isGenerator = !!node.asteriskToken; var isAsync = !!(node.flags & 512); - fillSignature(53, isGenerator, isAsync, false, node); + fillSignature(54, isGenerator, isAsync, false, node); node.body = parseFunctionBlockOrSemicolon(isGenerator, isAsync, ts.Diagnostics.or_expected); return finishNode(node); } function parseConstructorDeclaration(pos, decorators, modifiers) { - var node = createNode(142, pos); + var node = createNode(144, pos); node.decorators = decorators; setModifiers(node, modifiers); - parseExpected(119); - fillSignature(53, false, false, false, node); + parseExpected(121); + fillSignature(54, false, false, false, node); node.body = parseFunctionBlockOrSemicolon(false, false, ts.Diagnostics.or_expected); return finishNode(node); } function parseMethodDeclaration(fullStart, decorators, modifiers, asteriskToken, name, questionToken, diagnosticMessage) { - var method = createNode(141, fullStart); + var method = createNode(143, fullStart); method.decorators = decorators; setModifiers(method, modifiers); method.asteriskToken = asteriskToken; @@ -8598,12 +8737,12 @@ var ts; method.questionToken = questionToken; var isGenerator = !!asteriskToken; var isAsync = !!(method.flags & 512); - fillSignature(53, isGenerator, isAsync, false, method); + fillSignature(54, isGenerator, isAsync, false, method); method.body = parseFunctionBlockOrSemicolon(isGenerator, isAsync, diagnosticMessage); return finishNode(method); } function parsePropertyDeclaration(fullStart, decorators, modifiers, name, questionToken) { - var property = createNode(139, fullStart); + var property = createNode(141, fullStart); property.decorators = decorators; setModifiers(property, modifiers); property.name = name; @@ -8618,7 +8757,7 @@ var ts; function parsePropertyOrMethodDeclaration(fullStart, decorators, modifiers) { var asteriskToken = parseOptionalToken(37); var name = parsePropertyName(); - var questionToken = parseOptionalToken(52); + var questionToken = parseOptionalToken(53); if (asteriskToken || token === 17 || token === 25) { return parseMethodDeclaration(fullStart, decorators, modifiers, asteriskToken, name, questionToken, ts.Diagnostics.or_expected); } @@ -8634,16 +8773,16 @@ var ts; node.decorators = decorators; setModifiers(node, modifiers); node.name = parsePropertyName(); - fillSignature(53, false, false, false, node); + fillSignature(54, false, false, false, node); node.body = parseFunctionBlockOrSemicolon(false, false); return finishNode(node); } function isClassMemberModifier(idToken) { switch (idToken) { + case 112: case 110: - case 108: - case 109: case 111: + case 113: return true; default: return false; @@ -8651,7 +8790,7 @@ var ts; } function isClassMemberStart() { var idToken; - if (token === 54) { + if (token === 55) { return true; } while (ts.isModifier(token)) { @@ -8672,15 +8811,15 @@ var ts; return true; } if (idToken !== undefined) { - if (!ts.isKeyword(idToken) || idToken === 127 || idToken === 121) { + if (!ts.isKeyword(idToken) || idToken === 129 || idToken === 123) { return true; } switch (token) { case 17: case 25: + case 54: + case 56: case 53: - case 55: - case 52: return true; default: return canParseSemicolon(); @@ -8692,14 +8831,14 @@ var ts; var decorators; while (true) { var decoratorStart = getNodePos(); - if (!parseOptional(54)) { + if (!parseOptional(55)) { break; } if (!decorators) { decorators = []; decorators.pos = scanner.getStartPos(); } - var decorator = createNode(137, decoratorStart); + var decorator = createNode(139, decoratorStart); decorator.expression = doInDecoratorContext(parseLeftHandSideExpressionOrHigher); decorators.push(finishNode(decorator)); } @@ -8733,7 +8872,7 @@ var ts; function parseModifiersForArrowFunction() { var flags = 0; var modifiers; - if (token === 116) { + if (token === 118) { var modifierStart = scanner.getStartPos(); var modifierKind = token; nextToken(); @@ -8748,7 +8887,7 @@ var ts; } function parseClassElement() { if (token === 23) { - var result = createNode(189); + var result = createNode(191); nextToken(); return finishNode(result); } @@ -8759,7 +8898,7 @@ var ts; if (accessor) { return accessor; } - if (token === 119) { + if (token === 121) { return parseConstructorDeclaration(fullStart, decorators, modifiers); } if (isIndexSignature()) { @@ -8773,23 +8912,23 @@ var ts; return parsePropertyOrMethodDeclaration(fullStart, decorators, modifiers); } if (decorators || modifiers) { - var name_8 = createMissingNode(67, true, ts.Diagnostics.Declaration_expected); + var name_8 = createMissingNode(69, true, ts.Diagnostics.Declaration_expected); return parsePropertyDeclaration(fullStart, decorators, modifiers, name_8, undefined); } ts.Debug.fail("Should not have attempted to parse class member declaration."); } function parseClassExpression() { - return parseClassDeclarationOrExpression(scanner.getStartPos(), undefined, undefined, 184); + return parseClassDeclarationOrExpression(scanner.getStartPos(), undefined, undefined, 186); } function parseClassDeclaration(fullStart, decorators, modifiers) { - return parseClassDeclarationOrExpression(fullStart, decorators, modifiers, 212); + return parseClassDeclarationOrExpression(fullStart, decorators, modifiers, 214); } function parseClassDeclarationOrExpression(fullStart, decorators, modifiers, kind) { var node = createNode(kind, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - parseExpected(71); - node.name = parseOptionalIdentifier(); + parseExpected(73); + node.name = parseNameOfClassDeclarationOrExpression(); node.typeParameters = parseTypeParameters(); node.heritageClauses = parseHeritageClauses(true); if (parseExpected(15)) { @@ -8801,6 +8940,14 @@ var ts; } return finishNode(node); } + function parseNameOfClassDeclarationOrExpression() { + return isIdentifier() && !isImplementsClause() + ? parseIdentifier() + : undefined; + } + function isImplementsClause() { + return token === 106 && lookAhead(nextTokenIsIdentifierOrKeyword); + } function parseHeritageClauses(isClassHeritageClause) { if (isHeritageClause()) { return parseList(20, parseHeritageClause); @@ -8811,8 +8958,8 @@ var ts; return parseList(20, parseHeritageClause); } function parseHeritageClause() { - if (token === 81 || token === 104) { - var node = createNode(241); + if (token === 83 || token === 106) { + var node = createNode(243); node.token = token; nextToken(); node.types = parseDelimitedList(7, parseExpressionWithTypeArguments); @@ -8821,7 +8968,7 @@ var ts; return undefined; } function parseExpressionWithTypeArguments() { - var node = createNode(186); + var node = createNode(188); node.expression = parseLeftHandSideExpressionOrHigher(); if (token === 25) { node.typeArguments = parseBracketedList(18, parseType, 25, 27); @@ -8829,16 +8976,16 @@ var ts; return finishNode(node); } function isHeritageClause() { - return token === 81 || token === 104; + return token === 83 || token === 106; } function parseClassMembers() { return parseList(5, parseClassElement); } function parseInterfaceDeclaration(fullStart, decorators, modifiers) { - var node = createNode(213, fullStart); + var node = createNode(215, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - parseExpected(105); + parseExpected(107); node.name = parseIdentifier(); node.typeParameters = parseTypeParameters(); node.heritageClauses = parseHeritageClauses(false); @@ -8846,28 +8993,28 @@ var ts; return finishNode(node); } function parseTypeAliasDeclaration(fullStart, decorators, modifiers) { - var node = createNode(214, fullStart); + var node = createNode(216, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - parseExpected(130); + parseExpected(132); node.name = parseIdentifier(); node.typeParameters = parseTypeParameters(); - parseExpected(55); + parseExpected(56); node.type = parseType(); parseSemicolon(); return finishNode(node); } function parseEnumMember() { - var node = createNode(245, scanner.getStartPos()); + var node = createNode(247, scanner.getStartPos()); node.name = parsePropertyName(); node.initializer = allowInAnd(parseNonParameterInitializer); return finishNode(node); } function parseEnumDeclaration(fullStart, decorators, modifiers) { - var node = createNode(215, fullStart); + var node = createNode(217, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - parseExpected(79); + parseExpected(81); node.name = parseIdentifier(); if (parseExpected(15)) { node.members = parseDelimitedList(6, parseEnumMember); @@ -8879,7 +9026,7 @@ var ts; return finishNode(node); } function parseModuleBlock() { - var node = createNode(217, scanner.getStartPos()); + var node = createNode(219, scanner.getStartPos()); if (parseExpected(15)) { node.statements = parseList(1, parseStatement); parseExpected(16); @@ -8890,7 +9037,7 @@ var ts; return finishNode(node); } function parseModuleOrNamespaceDeclaration(fullStart, decorators, modifiers, flags) { - var node = createNode(216, fullStart); + var node = createNode(218, fullStart); var namespaceFlag = flags & 131072; node.decorators = decorators; setModifiers(node, modifiers); @@ -8902,7 +9049,7 @@ var ts; return finishNode(node); } function parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers) { - var node = createNode(216, fullStart); + var node = createNode(218, fullStart); node.decorators = decorators; setModifiers(node, modifiers); node.name = parseLiteralNode(true); @@ -8911,11 +9058,11 @@ var ts; } function parseModuleDeclaration(fullStart, decorators, modifiers) { var flags = modifiers ? modifiers.flags : 0; - if (parseOptional(124)) { + if (parseOptional(126)) { flags |= 131072; } else { - parseExpected(123); + parseExpected(125); if (token === 9) { return parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers); } @@ -8923,58 +9070,58 @@ var ts; return parseModuleOrNamespaceDeclaration(fullStart, decorators, modifiers, flags); } function isExternalModuleReference() { - return token === 125 && + return token === 127 && lookAhead(nextTokenIsOpenParen); } function nextTokenIsOpenParen() { return nextToken() === 17; } function nextTokenIsSlash() { - return nextToken() === 38; + return nextToken() === 39; } function nextTokenIsCommaOrFromKeyword() { nextToken(); return token === 24 || - token === 131; + token === 133; } function parseImportDeclarationOrImportEqualsDeclaration(fullStart, decorators, modifiers) { - parseExpected(87); + parseExpected(89); var afterImportPos = scanner.getStartPos(); var identifier; if (isIdentifier()) { identifier = parseIdentifier(); - if (token !== 24 && token !== 131) { - var importEqualsDeclaration = createNode(219, fullStart); + if (token !== 24 && token !== 133) { + var importEqualsDeclaration = createNode(221, fullStart); importEqualsDeclaration.decorators = decorators; setModifiers(importEqualsDeclaration, modifiers); importEqualsDeclaration.name = identifier; - parseExpected(55); + parseExpected(56); importEqualsDeclaration.moduleReference = parseModuleReference(); parseSemicolon(); return finishNode(importEqualsDeclaration); } } - var importDeclaration = createNode(220, fullStart); + var importDeclaration = createNode(222, fullStart); importDeclaration.decorators = decorators; setModifiers(importDeclaration, modifiers); if (identifier || token === 37 || token === 15) { importDeclaration.importClause = parseImportClause(identifier, afterImportPos); - parseExpected(131); + parseExpected(133); } importDeclaration.moduleSpecifier = parseModuleSpecifier(); parseSemicolon(); return finishNode(importDeclaration); } function parseImportClause(identifier, fullStart) { - var importClause = createNode(221, fullStart); + var importClause = createNode(223, fullStart); if (identifier) { importClause.name = identifier; } if (!importClause.name || parseOptional(24)) { - importClause.namedBindings = token === 37 ? parseNamespaceImport() : parseNamedImportsOrExports(223); + importClause.namedBindings = token === 37 ? parseNamespaceImport() : parseNamedImportsOrExports(225); } return finishNode(importClause); } @@ -8984,8 +9131,8 @@ var ts; : parseEntityName(false); } function parseExternalModuleReference() { - var node = createNode(230); - parseExpected(125); + var node = createNode(232); + parseExpected(127); parseExpected(17); node.expression = parseModuleSpecifier(); parseExpected(18); @@ -8999,22 +9146,22 @@ var ts; return result; } function parseNamespaceImport() { - var namespaceImport = createNode(222); + var namespaceImport = createNode(224); parseExpected(37); - parseExpected(114); + parseExpected(116); namespaceImport.name = parseIdentifier(); return finishNode(namespaceImport); } function parseNamedImportsOrExports(kind) { var node = createNode(kind); - node.elements = parseBracketedList(21, kind === 223 ? parseImportSpecifier : parseExportSpecifier, 15, 16); + node.elements = parseBracketedList(21, kind === 225 ? parseImportSpecifier : parseExportSpecifier, 15, 16); return finishNode(node); } function parseExportSpecifier() { - return parseImportOrExportSpecifier(228); + return parseImportOrExportSpecifier(230); } function parseImportSpecifier() { - return parseImportOrExportSpecifier(224); + return parseImportOrExportSpecifier(226); } function parseImportOrExportSpecifier(kind) { var node = createNode(kind); @@ -9022,9 +9169,9 @@ var ts; var checkIdentifierStart = scanner.getTokenPos(); var checkIdentifierEnd = scanner.getTextPos(); var identifierName = parseIdentifierName(); - if (token === 114) { + if (token === 116) { node.propertyName = identifierName; - parseExpected(114); + parseExpected(116); checkIdentifierIsKeyword = ts.isKeyword(token) && !isIdentifier(); checkIdentifierStart = scanner.getTokenPos(); checkIdentifierEnd = scanner.getTextPos(); @@ -9033,23 +9180,23 @@ var ts; else { node.name = identifierName; } - if (kind === 224 && checkIdentifierIsKeyword) { + if (kind === 226 && checkIdentifierIsKeyword) { parseErrorAtPosition(checkIdentifierStart, checkIdentifierEnd - checkIdentifierStart, ts.Diagnostics.Identifier_expected); } return finishNode(node); } function parseExportDeclaration(fullStart, decorators, modifiers) { - var node = createNode(226, fullStart); + var node = createNode(228, fullStart); node.decorators = decorators; setModifiers(node, modifiers); if (parseOptional(37)) { - parseExpected(131); + parseExpected(133); node.moduleSpecifier = parseModuleSpecifier(); } else { - node.exportClause = parseNamedImportsOrExports(227); - if (token === 131 || (token === 9 && !scanner.hasPrecedingLineBreak())) { - parseExpected(131); + node.exportClause = parseNamedImportsOrExports(229); + if (token === 133 || (token === 9 && !scanner.hasPrecedingLineBreak())) { + parseExpected(133); node.moduleSpecifier = parseModuleSpecifier(); } } @@ -9057,14 +9204,14 @@ var ts; return finishNode(node); } function parseExportAssignment(fullStart, decorators, modifiers) { - var node = createNode(225, fullStart); + var node = createNode(227, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - if (parseOptional(55)) { + if (parseOptional(56)) { node.isExportEquals = true; } else { - parseExpected(75); + parseExpected(77); } node.expression = parseAssignmentExpressionOrHigher(); parseSemicolon(); @@ -9127,10 +9274,10 @@ var ts; function setExternalModuleIndicator(sourceFile) { sourceFile.externalModuleIndicator = ts.forEach(sourceFile.statements, function (node) { return node.flags & 1 - || node.kind === 219 && node.moduleReference.kind === 230 - || node.kind === 220 - || node.kind === 225 - || node.kind === 226 + || node.kind === 221 && node.moduleReference.kind === 232 + || node.kind === 222 + || node.kind === 227 + || node.kind === 228 ? node : undefined; }); @@ -9140,22 +9287,22 @@ var ts; function isJSDocType() { switch (token) { case 37: - case 52: + case 53: case 17: case 19: - case 48: + case 49: case 15: - case 85: + case 87: case 22: - case 90: - case 95: + case 92: + case 97: return true; } return ts.tokenIsIdentifierOrKeyword(token); } JSDocParser.isJSDocType = isJSDocType; function parseJSDocTypeExpressionForTests(content, start, length) { - initializeState("file.js", content, 2, undefined); + initializeState("file.js", content, 2, true, undefined); var jsDocTypeExpression = parseJSDocTypeExpression(start, length); var diagnostics = parseDiagnostics; clearState(); @@ -9165,7 +9312,7 @@ var ts; function parseJSDocTypeExpression(start, length) { scanner.setText(sourceText, start, length); token = nextToken(); - var result = createNode(247); + var result = createNode(249); parseExpected(15); result.type = parseJSDocTopLevelType(); parseExpected(16); @@ -9175,13 +9322,13 @@ var ts; JSDocParser.parseJSDocTypeExpression = parseJSDocTypeExpression; function parseJSDocTopLevelType() { var type = parseJSDocType(); - if (token === 46) { - var unionType = createNode(251, type.pos); + if (token === 47) { + var unionType = createNode(253, type.pos); unionType.types = parseJSDocTypeList(type); type = finishNode(unionType); } - if (token === 55) { - var optionalType = createNode(258, type.pos); + if (token === 56) { + var optionalType = createNode(260, type.pos); nextToken(); optionalType.type = type; type = finishNode(optionalType); @@ -9192,20 +9339,20 @@ var ts; var type = parseBasicTypeExpression(); while (true) { if (token === 19) { - var arrayType = createNode(250, type.pos); + var arrayType = createNode(252, type.pos); arrayType.elementType = type; nextToken(); parseExpected(20); type = finishNode(arrayType); } - else if (token === 52) { - var nullableType = createNode(253, type.pos); + else if (token === 53) { + var nullableType = createNode(255, type.pos); nullableType.type = type; nextToken(); type = finishNode(nullableType); } - else if (token === 48) { - var nonNullableType = createNode(254, type.pos); + else if (token === 49) { + var nonNullableType = createNode(256, type.pos); nonNullableType.type = type; nextToken(); type = finishNode(nonNullableType); @@ -9220,80 +9367,80 @@ var ts; switch (token) { case 37: return parseJSDocAllType(); - case 52: + case 53: return parseJSDocUnknownOrNullableType(); case 17: return parseJSDocUnionType(); case 19: return parseJSDocTupleType(); - case 48: + case 49: return parseJSDocNonNullableType(); case 15: return parseJSDocRecordType(); - case 85: + case 87: return parseJSDocFunctionType(); case 22: return parseJSDocVariadicType(); - case 90: + case 92: return parseJSDocConstructorType(); - case 95: + case 97: return parseJSDocThisType(); - case 115: + case 117: + case 130: case 128: - case 126: - case 118: - case 129: - case 101: + case 120: + case 131: + case 103: return parseTokenNode(); } return parseJSDocTypeReference(); } function parseJSDocThisType() { - var result = createNode(262); + var result = createNode(264); nextToken(); - parseExpected(53); + parseExpected(54); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocConstructorType() { - var result = createNode(261); + var result = createNode(263); nextToken(); - parseExpected(53); + parseExpected(54); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocVariadicType() { - var result = createNode(260); + var result = createNode(262); nextToken(); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocFunctionType() { - var result = createNode(259); + var result = createNode(261); nextToken(); parseExpected(17); result.parameters = parseDelimitedList(22, parseJSDocParameter); checkForTrailingComma(result.parameters); parseExpected(18); - if (token === 53) { + if (token === 54) { nextToken(); result.type = parseJSDocType(); } return finishNode(result); } function parseJSDocParameter() { - var parameter = createNode(136); + var parameter = createNode(138); parameter.type = parseJSDocType(); return finishNode(parameter); } function parseJSDocOptionalType(type) { - var result = createNode(258, type.pos); + var result = createNode(260, type.pos); nextToken(); result.type = type; return finishNode(result); } function parseJSDocTypeReference() { - var result = createNode(257); + var result = createNode(259); result.name = parseSimplePropertyName(); while (parseOptional(21)) { if (token === 25) { @@ -9322,13 +9469,13 @@ var ts; } } function parseQualifiedName(left) { - var result = createNode(133, left.pos); + var result = createNode(135, left.pos); result.left = left; result.right = parseIdentifierName(); return finishNode(result); } function parseJSDocRecordType() { - var result = createNode(255); + var result = createNode(257); nextToken(); result.members = parseDelimitedList(24, parseJSDocRecordMember); checkForTrailingComma(result.members); @@ -9336,22 +9483,22 @@ var ts; return finishNode(result); } function parseJSDocRecordMember() { - var result = createNode(256); + var result = createNode(258); result.name = parseSimplePropertyName(); - if (token === 53) { + if (token === 54) { nextToken(); result.type = parseJSDocType(); } return finishNode(result); } function parseJSDocNonNullableType() { - var result = createNode(254); + var result = createNode(256); nextToken(); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocTupleType() { - var result = createNode(252); + var result = createNode(254); nextToken(); result.types = parseDelimitedList(25, parseJSDocType); checkForTrailingComma(result.types); @@ -9365,7 +9512,7 @@ var ts; } } function parseJSDocUnionType() { - var result = createNode(251); + var result = createNode(253); nextToken(); result.types = parseJSDocTypeList(parseJSDocType()); parseExpected(18); @@ -9376,14 +9523,14 @@ var ts; var types = []; types.pos = firstType.pos; types.push(firstType); - while (parseOptional(46)) { + while (parseOptional(47)) { types.push(parseJSDocType()); } types.end = scanner.getStartPos(); return types; } function parseJSDocAllType() { - var result = createNode(248); + var result = createNode(250); nextToken(); return finishNode(result); } @@ -9394,19 +9541,19 @@ var ts; token === 16 || token === 18 || token === 27 || - token === 55 || - token === 46) { - var result = createNode(249, pos); + token === 56 || + token === 47) { + var result = createNode(251, pos); return finishNode(result); } else { - var result = createNode(253, pos); + var result = createNode(255, pos); result.type = parseJSDocType(); return finishNode(result); } } function parseIsolatedJSDocComment(content, start, length) { - initializeState("file.js", content, 2, undefined); + initializeState("file.js", content, 2, true, undefined); var jsDocComment = parseJSDocComment(undefined, start, length); var diagnostics = parseDiagnostics; clearState(); @@ -9471,7 +9618,7 @@ var ts; if (!tags) { return undefined; } - var result = createNode(263, start); + var result = createNode(265, start); result.tags = tags; return finishNode(result, end); } @@ -9482,7 +9629,7 @@ var ts; } function parseTag() { ts.Debug.assert(content.charCodeAt(pos - 1) === 64); - var atToken = createNode(54, pos - 1); + var atToken = createNode(55, pos - 1); atToken.end = pos; var tagName = scanIdentifier(); if (!tagName) { @@ -9508,7 +9655,7 @@ var ts; return undefined; } function handleUnknownTag(atToken, tagName) { - var result = createNode(264, atToken.pos); + var result = createNode(266, atToken.pos); result.atToken = atToken; result.tagName = tagName; return finishNode(result, pos); @@ -9559,7 +9706,7 @@ var ts; if (!typeExpression) { typeExpression = tryParseTypeExpression(); } - var result = createNode(265, atToken.pos); + var result = createNode(267, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.preParameterName = preName; @@ -9569,27 +9716,27 @@ var ts; return finishNode(result, pos); } function handleReturnTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 266; })) { + if (ts.forEach(tags, function (t) { return t.kind === 268; })) { parseErrorAtPosition(tagName.pos, pos - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); } - var result = createNode(266, atToken.pos); + var result = createNode(268, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeExpression = tryParseTypeExpression(); return finishNode(result, pos); } function handleTypeTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 267; })) { + if (ts.forEach(tags, function (t) { return t.kind === 269; })) { parseErrorAtPosition(tagName.pos, pos - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); } - var result = createNode(267, atToken.pos); + var result = createNode(269, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeExpression = tryParseTypeExpression(); return finishNode(result, pos); } function handleTemplateTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 268; })) { + if (ts.forEach(tags, function (t) { return t.kind === 270; })) { parseErrorAtPosition(tagName.pos, pos - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); } var typeParameters = []; @@ -9602,7 +9749,7 @@ var ts; parseErrorAtPosition(startPos, 0, ts.Diagnostics.Identifier_expected); return undefined; } - var typeParameter = createNode(135, name_9.pos); + var typeParameter = createNode(137, name_9.pos); typeParameter.name = name_9; finishNode(typeParameter, pos); typeParameters.push(typeParameter); @@ -9613,7 +9760,7 @@ var ts; pos++; } typeParameters.end = pos; - var result = createNode(268, atToken.pos); + var result = createNode(270, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeParameters = typeParameters; @@ -9634,7 +9781,7 @@ var ts; if (startPos === pos) { return undefined; } - var result = createNode(67, startPos); + var result = createNode(69, startPos); result.text = content.substring(startPos, pos); return finishNode(result, pos); } @@ -9710,7 +9857,7 @@ var ts; switch (node.kind) { case 9: case 8: - case 67: + case 69: return true; } return false; @@ -9928,16 +10075,16 @@ var ts; (function (ts) { ts.bindTime = 0; function getModuleInstanceState(node) { - if (node.kind === 213 || node.kind === 214) { + if (node.kind === 215 || node.kind === 216) { return 0; } else if (ts.isConstEnumDeclaration(node)) { return 2; } - else if ((node.kind === 220 || node.kind === 219) && !(node.flags & 1)) { + else if ((node.kind === 222 || node.kind === 221) && !(node.flags & 1)) { return 0; } - else if (node.kind === 217) { + else if (node.kind === 219) { var state = 0; ts.forEachChild(node, function (n) { switch (getModuleInstanceState(n)) { @@ -9953,7 +10100,7 @@ var ts; }); return state; } - else if (node.kind === 216) { + else if (node.kind === 218) { return getModuleInstanceState(node.body); } else { @@ -9972,6 +10119,8 @@ var ts; var container; var blockScopeContainer; var lastContainer; + var seenThisKeyword; + var isJavaScriptFile = ts.isSourceFileJavaScript(file); var inStrictMode = !!file.externalModuleIndicator; var symbolCount = 0; var Symbol = ts.objectAllocator.getSymbolConstructor(); @@ -10005,10 +10154,10 @@ var ts; } function getDeclarationName(node) { if (node.name) { - if (node.kind === 216 && node.name.kind === 9) { + if (node.kind === 218 && node.name.kind === 9) { return "\"" + node.name.text + "\""; } - if (node.name.kind === 134) { + if (node.name.kind === 136) { var nameExpression = node.name.expression; ts.Debug.assert(ts.isWellKnownSymbolSyntactically(nameExpression)); return ts.getPropertyNameForKnownSymbolName(nameExpression.name.text); @@ -10016,22 +10165,24 @@ var ts; return node.name.text; } switch (node.kind) { - case 142: + case 144: return "__constructor"; - case 150: - case 145: - return "__call"; - case 151: - case 146: - return "__new"; + case 152: case 147: + return "__call"; + case 153: + case 148: + return "__new"; + case 149: return "__index"; - case 226: + case 228: return "__export"; - case 225: + case 227: return node.isExportEquals ? "export=" : "default"; - case 211: - case 212: + case 181: + return "export="; + case 213: + case 214: return node.flags & 1024 ? "default" : undefined; } } @@ -10040,7 +10191,8 @@ var ts; } function declareSymbol(symbolTable, parent, node, includes, excludes) { ts.Debug.assert(!ts.hasDynamicName(node)); - var name = node.flags & 1024 && parent ? "default" : getDeclarationName(node); + var isDefaultExport = node.flags & 1024; + var name = isDefaultExport && parent ? "default" : getDeclarationName(node); var symbol; if (name !== undefined) { symbol = ts.hasProperty(symbolTable, name) @@ -10056,6 +10208,11 @@ var ts; var message = symbol.flags & 2 ? ts.Diagnostics.Cannot_redeclare_block_scoped_variable_0 : ts.Diagnostics.Duplicate_identifier_0; + ts.forEach(symbol.declarations, function (declaration) { + if (declaration.flags & 1024) { + message = ts.Diagnostics.A_module_cannot_have_multiple_default_exports; + } + }); ts.forEach(symbol.declarations, function (declaration) { file.bindDiagnostics.push(ts.createDiagnosticForNode(declaration.name || declaration, message, getDisplayName(declaration))); }); @@ -10073,7 +10230,7 @@ var ts; function declareModuleMember(node, symbolFlags, symbolExcludes) { var hasExportModifier = ts.getCombinedNodeFlags(node) & 1; if (symbolFlags & 8388608) { - if (node.kind === 228 || (node.kind === 219 && hasExportModifier)) { + if (node.kind === 230 || (node.kind === 221 && hasExportModifier)) { return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); } else { @@ -10112,44 +10269,51 @@ var ts; blockScopeContainer = node; blockScopeContainer.locals = undefined; } - ts.forEachChild(node, bind); + if (node.kind === 215) { + seenThisKeyword = false; + ts.forEachChild(node, bind); + node.flags = seenThisKeyword ? node.flags | 524288 : node.flags & ~524288; + } + else { + ts.forEachChild(node, bind); + } container = saveContainer; parent = saveParent; blockScopeContainer = savedBlockScopeContainer; } function getContainerFlags(node) { switch (node.kind) { - case 184: - case 212: - case 213: + case 186: + case 214: case 215: - case 153: - case 163: + case 217: + case 155: + case 165: return 1; + case 147: + case 148: + case 149: + case 143: + case 142: + case 213: + case 144: case 145: case 146: - case 147: - case 141: - case 140: - case 211: - case 142: - case 143: - case 144: - case 150: - case 151: - case 171: - case 172: - case 216: - case 246: - case 214: - return 5; - case 242: - case 197: - case 198: - case 199: + case 152: + case 153: + case 173: + case 174: case 218: + case 248: + case 216: + return 5; + case 244: + case 199: + case 200: + case 201: + case 220: return 2; - case 190: + case 192: return ts.isFunctionLike(node.parent) ? 0 : 2; } return 0; @@ -10165,33 +10329,33 @@ var ts; } function declareSymbolAndAddToSymbolTableWorker(node, symbolFlags, symbolExcludes) { switch (container.kind) { - case 216: + case 218: return declareModuleMember(node, symbolFlags, symbolExcludes); - case 246: + case 248: return declareSourceFileMember(node, symbolFlags, symbolExcludes); - case 184: - case 212: + case 186: + case 214: return declareClassMember(node, symbolFlags, symbolExcludes); - case 215: + case 217: return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); - case 153: - case 163: - case 213: + case 155: + case 165: + case 215: return declareSymbol(container.symbol.members, container.symbol, node, symbolFlags, symbolExcludes); - case 150: - case 151: + case 152: + case 153: + case 147: + case 148: + case 149: + case 143: + case 142: + case 144: case 145: case 146: - case 147: - case 141: - case 140: - case 142: - case 143: - case 144: - case 211: - case 171: - case 172: - case 214: + case 213: + case 173: + case 174: + case 216: return declareSymbol(container.locals, undefined, node, symbolFlags, symbolExcludes); } } @@ -10215,11 +10379,11 @@ var ts; return false; } function hasExportDeclarations(node) { - var body = node.kind === 246 ? node : node.body; - if (body.kind === 246 || body.kind === 217) { + var body = node.kind === 248 ? node : node.body; + if (body.kind === 248 || body.kind === 219) { for (var _i = 0, _a = body.statements; _i < _a.length; _i++) { var stat = _a[_i]; - if (stat.kind === 226 || stat.kind === 225) { + if (stat.kind === 228 || stat.kind === 227) { return true; } } @@ -10274,11 +10438,11 @@ var ts; var seen = {}; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; - if (prop.name.kind !== 67) { + if (prop.name.kind !== 69) { continue; } var identifier = prop.name; - var currentKind = prop.kind === 243 || prop.kind === 244 || prop.kind === 141 + var currentKind = prop.kind === 245 || prop.kind === 246 || prop.kind === 143 ? 1 : 2; var existingKind = seen[identifier.text]; @@ -10300,10 +10464,10 @@ var ts; } function bindBlockScopedDeclaration(node, symbolFlags, symbolExcludes) { switch (blockScopeContainer.kind) { - case 216: + case 218: declareModuleMember(node, symbolFlags, symbolExcludes); break; - case 246: + case 248: if (ts.isExternalModule(container)) { declareModuleMember(node, symbolFlags, symbolExcludes); break; @@ -10321,8 +10485,8 @@ var ts; } function checkStrictModeIdentifier(node) { if (inStrictMode && - node.originalKeywordKind >= 104 && - node.originalKeywordKind <= 112 && + node.originalKeywordKind >= 106 && + node.originalKeywordKind <= 114 && !ts.isIdentifierName(node)) { if (!file.parseDiagnostics.length) { file.bindDiagnostics.push(ts.createDiagnosticForNode(node, getStrictModeIdentifierMessage(node), ts.declarationNameToString(node))); @@ -10349,17 +10513,17 @@ var ts; } } function checkStrictModeDeleteExpression(node) { - if (inStrictMode && node.expression.kind === 67) { + if (inStrictMode && node.expression.kind === 69) { var span = ts.getErrorSpanForNode(file, node.expression); file.bindDiagnostics.push(ts.createFileDiagnostic(file, span.start, span.length, ts.Diagnostics.delete_cannot_be_called_on_an_identifier_in_strict_mode)); } } function isEvalOrArgumentsIdentifier(node) { - return node.kind === 67 && + return node.kind === 69 && (node.text === "eval" || node.text === "arguments"); } function checkStrictModeEvalOrArguments(contextNode, name) { - if (name && name.kind === 67) { + if (name && name.kind === 69) { var identifier = name; if (isEvalOrArgumentsIdentifier(identifier)) { var span = ts.getErrorSpanForNode(file, name); @@ -10393,7 +10557,7 @@ var ts; } function checkStrictModePrefixUnaryExpression(node) { if (inStrictMode) { - if (node.operator === 40 || node.operator === 41) { + if (node.operator === 41 || node.operator === 42) { checkStrictModeEvalOrArguments(node, node.operand); } } @@ -10422,17 +10586,17 @@ var ts; } function updateStrictMode(node) { switch (node.kind) { - case 246: - case 217: + case 248: + case 219: updateStrictModeStatementList(node.statements); return; - case 190: + case 192: if (ts.isFunctionLike(node.parent)) { updateStrictModeStatementList(node.statements); } return; - case 212: - case 184: + case 214: + case 186: inStrictMode = true; return; } @@ -10455,102 +10619,122 @@ var ts; } function bindWorker(node) { switch (node.kind) { - case 67: + case 69: return checkStrictModeIdentifier(node); - case 179: + case 181: + if (isJavaScriptFile) { + if (ts.isExportsPropertyAssignment(node)) { + bindExportsPropertyAssignment(node); + } + else if (ts.isModuleExportsAssignment(node)) { + bindModuleExportsAssignment(node); + } + } return checkStrictModeBinaryExpression(node); - case 242: + case 244: return checkStrictModeCatchClause(node); - case 173: + case 175: return checkStrictModeDeleteExpression(node); case 8: return checkStrictModeNumericLiteral(node); - case 178: + case 180: return checkStrictModePostfixUnaryExpression(node); - case 177: + case 179: return checkStrictModePrefixUnaryExpression(node); - case 203: + case 205: return checkStrictModeWithStatement(node); - case 135: + case 97: + seenThisKeyword = true; + return; + case 137: return declareSymbolAndAddToSymbolTable(node, 262144, 530912); - case 136: - return bindParameter(node); - case 209: - case 161: - return bindVariableDeclarationOrBindingElement(node); - case 139: case 138: - return bindPropertyOrMethodOrAccessor(node, 4 | (node.questionToken ? 536870912 : 0), 107455); - case 243: - case 244: - return bindPropertyOrMethodOrAccessor(node, 4, 107455); - case 245: - return bindPropertyOrMethodOrAccessor(node, 8, 107455); - case 145: - case 146: - case 147: - return declareSymbolAndAddToSymbolTable(node, 131072, 0); + return bindParameter(node); + case 211: + case 163: + return bindVariableDeclarationOrBindingElement(node); case 141: case 140: + return bindPropertyOrMethodOrAccessor(node, 4 | (node.questionToken ? 536870912 : 0), 107455); + case 245: + case 246: + return bindPropertyOrMethodOrAccessor(node, 4, 107455); + case 247: + return bindPropertyOrMethodOrAccessor(node, 8, 107455); + case 147: + case 148: + case 149: + return declareSymbolAndAddToSymbolTable(node, 131072, 0); + case 143: + case 142: return bindPropertyOrMethodOrAccessor(node, 8192 | (node.questionToken ? 536870912 : 0), ts.isObjectLiteralMethod(node) ? 107455 : 99263); - case 211: + case 213: checkStrictModeFunctionName(node); return declareSymbolAndAddToSymbolTable(node, 16, 106927); - case 142: - return declareSymbolAndAddToSymbolTable(node, 16384, 0); - case 143: - return bindPropertyOrMethodOrAccessor(node, 32768, 41919); case 144: + return declareSymbolAndAddToSymbolTable(node, 16384, 0); + case 145: + return bindPropertyOrMethodOrAccessor(node, 32768, 41919); + case 146: return bindPropertyOrMethodOrAccessor(node, 65536, 74687); - case 150: - case 151: - return bindFunctionOrConstructorType(node); + case 152: case 153: + return bindFunctionOrConstructorType(node); + case 155: return bindAnonymousDeclaration(node, 2048, "__type"); - case 163: + case 165: return bindObjectLiteralExpression(node); - case 171: - case 172: + case 173: + case 174: checkStrictModeFunctionName(node); var bindingName = node.name ? node.name.text : "__function"; return bindAnonymousDeclaration(node, 16, bindingName); - case 184: - case 212: - return bindClassLikeDeclaration(node); - case 213: - return bindBlockScopedDeclaration(node, 64, 792960); + case 168: + if (isJavaScriptFile) { + bindCallExpression(node); + } + break; + case 186: case 214: - return bindBlockScopedDeclaration(node, 524288, 793056); + return bindClassLikeDeclaration(node); case 215: - return bindEnumDeclaration(node); + return bindBlockScopedDeclaration(node, 64, 792960); case 216: + return bindBlockScopedDeclaration(node, 524288, 793056); + case 217: + return bindEnumDeclaration(node); + case 218: return bindModuleDeclaration(node); - case 219: - case 222: - case 224: - case 228: - return declareSymbolAndAddToSymbolTable(node, 8388608, 8388608); case 221: - return bindImportClause(node); + case 224: case 226: + case 230: + return declareSymbolAndAddToSymbolTable(node, 8388608, 8388608); + case 223: + return bindImportClause(node); + case 228: return bindExportDeclaration(node); - case 225: + case 227: return bindExportAssignment(node); - case 246: + case 248: return bindSourceFileIfExternalModule(); } } function bindSourceFileIfExternalModule() { setExportContextFlag(file); if (ts.isExternalModule(file)) { - bindAnonymousDeclaration(file, 512, "\"" + ts.removeFileExtension(file.fileName) + "\""); + bindSourceFileAsExternalModule(); } } + function bindSourceFileAsExternalModule() { + bindAnonymousDeclaration(file, 512, "\"" + ts.removeFileExtension(file.fileName) + "\""); + } function bindExportAssignment(node) { + var boundExpression = node.kind === 227 ? node.expression : node.right; if (!container.symbol || !container.symbol.exports) { bindAnonymousDeclaration(node, 8388608, getDeclarationName(node)); } - else if (node.expression.kind === 67) { + else if (boundExpression.kind === 69) { declareSymbol(container.symbol.exports, container.symbol, node, 8388608, 107455 | 8388608); } else { @@ -10570,8 +10754,27 @@ var ts; declareSymbolAndAddToSymbolTable(node, 8388608, 8388608); } } + function setCommonJsModuleIndicator(node) { + if (!file.commonJsModuleIndicator) { + file.commonJsModuleIndicator = node; + bindSourceFileAsExternalModule(); + } + } + function bindExportsPropertyAssignment(node) { + setCommonJsModuleIndicator(node); + declareSymbol(file.symbol.exports, file.symbol, node.left, 4 | 7340032, 0); + } + function bindModuleExportsAssignment(node) { + setCommonJsModuleIndicator(node); + bindExportAssignment(node); + } + function bindCallExpression(node) { + if (!file.commonJsModuleIndicator && ts.isRequireCall(node)) { + setCommonJsModuleIndicator(node); + } + } function bindClassLikeDeclaration(node) { - if (node.kind === 212) { + if (node.kind === 214) { bindBlockScopedDeclaration(node, 32, 899519); } else { @@ -10624,7 +10827,7 @@ var ts; declareSymbolAndAddToSymbolTable(node, 1, 107455); } if (node.flags & 112 && - node.parent.kind === 142 && + node.parent.kind === 144 && ts.isClassLike(node.parent.parent)) { var classDeclaration = node.parent.parent; declareSymbol(classDeclaration.symbol.members, classDeclaration.symbol, node, 4, 107455); @@ -10662,17 +10865,19 @@ var ts; var Type = ts.objectAllocator.getTypeConstructor(); var Signature = ts.objectAllocator.getSignatureConstructor(); var typeCount = 0; + var symbolCount = 0; var emptyArray = []; var emptySymbols = {}; var compilerOptions = host.getCompilerOptions(); var languageVersion = compilerOptions.target || 0; + var modulekind = compilerOptions.module ? compilerOptions.module : languageVersion === 2 ? 5 : 0; var emitResolver = createResolver(); var undefinedSymbol = createSymbol(4 | 67108864, "undefined"); var argumentsSymbol = createSymbol(4 | 67108864, "arguments"); var checker = { getNodeCount: function () { return ts.sum(host.getSourceFiles(), "nodeCount"); }, getIdentifierCount: function () { return ts.sum(host.getSourceFiles(), "identifierCount"); }, - getSymbolCount: function () { return ts.sum(host.getSourceFiles(), "symbolCount"); }, + getSymbolCount: function () { return ts.sum(host.getSourceFiles(), "symbolCount") + symbolCount; }, getTypeCount: function () { return typeCount; }, isUndefinedSymbol: function (symbol) { return symbol === undefinedSymbol; }, isArgumentsSymbol: function (symbol) { return symbol === argumentsSymbol; }, @@ -10758,6 +10963,7 @@ var ts; var getInstantiatedGlobalPromiseLikeType; var getGlobalPromiseConstructorLikeType; var getGlobalThenableType; + var cjsRequireType; var tupleTypes = {}; var unionTypes = {}; var intersectionTypes = {}; @@ -10818,6 +11024,7 @@ var ts; diagnostics.add(diagnostic); } function createSymbol(flags, name) { + symbolCount++; return new Symbol(flags, name); } function getExcludedSymbolFlags(flags) { @@ -10946,10 +11153,10 @@ var ts; return nodeLinks[nodeId] || (nodeLinks[nodeId] = {}); } function getSourceFile(node) { - return ts.getAncestor(node, 246); + return ts.getAncestor(node, 248); } function isGlobalSourceFile(node) { - return node.kind === 246 && !ts.isExternalModule(node); + return node.kind === 248 && !ts.isExternalOrCommonJsModule(node); } function getSymbol(symbols, name, meaning) { if (meaning && ts.hasProperty(symbols, name)) { @@ -10966,17 +11173,54 @@ var ts; } } } - function isDefinedBefore(node1, node2) { - var file1 = ts.getSourceFileOfNode(node1); - var file2 = ts.getSourceFileOfNode(node2); - if (file1 === file2) { - return node1.pos <= node2.pos; + function isBlockScopedNameDeclaredBeforeUse(declaration, usage) { + var declarationFile = ts.getSourceFileOfNode(declaration); + var useFile = ts.getSourceFileOfNode(usage); + if (declarationFile !== useFile) { + if (modulekind || (!compilerOptions.outFile && !compilerOptions.out)) { + return true; + } + var sourceFiles = host.getSourceFiles(); + return ts.indexOf(sourceFiles, declarationFile) <= ts.indexOf(sourceFiles, useFile); } - if (!compilerOptions.outFile && !compilerOptions.out) { - return true; + if (declaration.pos <= usage.pos) { + return declaration.kind !== 211 || + !isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage); + } + return isUsedInFunctionOrNonStaticProperty(declaration, usage); + function isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage) { + var container = ts.getEnclosingBlockScopeContainer(declaration); + if (declaration.parent.parent.kind === 193 || + declaration.parent.parent.kind === 199) { + return isSameScopeDescendentOf(usage, declaration, container); + } + else if (declaration.parent.parent.kind === 201 || + declaration.parent.parent.kind === 200) { + var expression = declaration.parent.parent.expression; + return isSameScopeDescendentOf(usage, expression, container); + } + } + function isUsedInFunctionOrNonStaticProperty(declaration, usage) { + var container = ts.getEnclosingBlockScopeContainer(declaration); + var current = usage; + while (current) { + if (current === container) { + return false; + } + if (ts.isFunctionLike(current)) { + return true; + } + var initializerOfNonStaticProperty = current.parent && + current.parent.kind === 141 && + (current.parent.flags & 128) === 0 && + current.parent.initializer === current; + if (initializerOfNonStaticProperty) { + return true; + } + current = current.parent; + } + return false; } - var sourceFiles = host.getSourceFiles(); - return sourceFiles.indexOf(file1) <= sourceFiles.indexOf(file2); } function resolveName(location, name, meaning, nameNotFoundMessage, nameArg) { var result; @@ -10997,16 +11241,16 @@ var ts; } } switch (location.kind) { - case 246: - if (!ts.isExternalModule(location)) + case 248: + if (!ts.isExternalOrCommonJsModule(location)) break; - case 216: + case 218: var moduleExports = getSymbolOfNode(location).exports; - if (location.kind === 246 || - (location.kind === 216 && location.name.kind === 9)) { + if (location.kind === 248 || + (location.kind === 218 && location.name.kind === 9)) { if (ts.hasProperty(moduleExports, name) && moduleExports[name].flags === 8388608 && - ts.getDeclarationOfKind(moduleExports[name], 228)) { + ts.getDeclarationOfKind(moduleExports[name], 230)) { break; } result = moduleExports["default"]; @@ -11020,13 +11264,13 @@ var ts; break loop; } break; - case 215: + case 217: if (result = getSymbol(getSymbolOfNode(location).exports, name, meaning & 8)) { break loop; } break; - case 139: - case 138: + case 141: + case 140: if (ts.isClassLike(location.parent) && !(location.flags & 128)) { var ctor = findConstructorDeclaration(location.parent); if (ctor && ctor.locals) { @@ -11036,9 +11280,9 @@ var ts; } } break; - case 212: - case 184: - case 213: + case 214: + case 186: + case 215: if (result = getSymbol(getSymbolOfNode(location).members, name, meaning & 793056)) { if (lastLocation && lastLocation.flags & 128) { error(errorLocation, ts.Diagnostics.Static_members_cannot_reference_class_type_parameters); @@ -11046,7 +11290,7 @@ var ts; } break loop; } - if (location.kind === 184 && meaning & 32) { + if (location.kind === 186 && meaning & 32) { var className = location.name; if (className && name === className.text) { result = location.symbol; @@ -11054,28 +11298,28 @@ var ts; } } break; - case 134: + case 136: grandparent = location.parent.parent; - if (ts.isClassLike(grandparent) || grandparent.kind === 213) { + if (ts.isClassLike(grandparent) || grandparent.kind === 215) { if (result = getSymbol(getSymbolOfNode(grandparent).members, name, meaning & 793056)) { error(errorLocation, ts.Diagnostics.A_computed_property_name_cannot_reference_a_type_parameter_from_its_containing_type); return undefined; } } break; - case 141: - case 140: - case 142: case 143: + case 142: case 144: - case 211: - case 172: + case 145: + case 146: + case 213: + case 174: if (meaning & 3 && name === "arguments") { result = argumentsSymbol; break loop; } break; - case 171: + case 173: if (meaning & 3 && name === "arguments") { result = argumentsSymbol; break loop; @@ -11088,8 +11332,8 @@ var ts; } } break; - case 137: - if (location.parent && location.parent.kind === 136) { + case 139: + if (location.parent && location.parent.kind === 138) { location = location.parent; } if (location.parent && ts.isClassElement(location.parent)) { @@ -11115,8 +11359,11 @@ var ts; error(errorLocation, ts.Diagnostics.Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor, ts.declarationNameToString(propertyName), typeof nameArg === "string" ? nameArg : ts.declarationNameToString(nameArg)); return undefined; } - if (meaning & 2 && result.flags & 2) { - checkResolvedBlockScopedVariable(result, errorLocation); + if (meaning & 2) { + var exportOrLocalSymbol = getExportSymbolOfValueSymbolIfExported(result); + if (exportOrLocalSymbol.flags & 2) { + checkResolvedBlockScopedVariable(exportOrLocalSymbol, errorLocation); + } } } return result; @@ -11125,21 +11372,7 @@ var ts; ts.Debug.assert((result.flags & 2) !== 0); var declaration = ts.forEach(result.declarations, function (d) { return ts.isBlockOrCatchScoped(d) ? d : undefined; }); ts.Debug.assert(declaration !== undefined, "Block-scoped variable declaration is undefined"); - var isUsedBeforeDeclaration = !isDefinedBefore(declaration, errorLocation); - if (!isUsedBeforeDeclaration) { - var variableDeclaration = ts.getAncestor(declaration, 209); - var container = ts.getEnclosingBlockScopeContainer(variableDeclaration); - if (variableDeclaration.parent.parent.kind === 191 || - variableDeclaration.parent.parent.kind === 197) { - isUsedBeforeDeclaration = isSameScopeDescendentOf(errorLocation, variableDeclaration, container); - } - else if (variableDeclaration.parent.parent.kind === 199 || - variableDeclaration.parent.parent.kind === 198) { - var expression = variableDeclaration.parent.parent.expression; - isUsedBeforeDeclaration = isSameScopeDescendentOf(errorLocation, expression, container); - } - } - if (isUsedBeforeDeclaration) { + if (!isBlockScopedNameDeclaredBeforeUse(ts.getAncestor(declaration, 211), errorLocation)) { error(errorLocation, ts.Diagnostics.Block_scoped_variable_0_used_before_its_declaration, ts.declarationNameToString(declaration.name)); } } @@ -11156,10 +11389,10 @@ var ts; } function getAnyImportSyntax(node) { if (ts.isAliasSymbolDeclaration(node)) { - if (node.kind === 219) { + if (node.kind === 221) { return node; } - while (node && node.kind !== 220) { + while (node && node.kind !== 222) { node = node.parent; } return node; @@ -11169,7 +11402,7 @@ var ts; return ts.forEach(symbol.declarations, function (d) { return ts.isAliasSymbolDeclaration(d) ? d : undefined; }); } function getTargetOfImportEqualsDeclaration(node) { - if (node.moduleReference.kind === 230) { + if (node.moduleReference.kind === 232) { return resolveExternalModuleSymbol(resolveExternalModuleName(node, ts.getExternalModuleImportEqualsDeclarationExpression(node))); } return getSymbolOfPartOfRightHandSideOfImportEquals(node.moduleReference, node); @@ -11258,17 +11491,17 @@ var ts; } function getTargetOfAliasDeclaration(node) { switch (node.kind) { - case 219: - return getTargetOfImportEqualsDeclaration(node); case 221: + return getTargetOfImportEqualsDeclaration(node); + case 223: return getTargetOfImportClause(node); - case 222: - return getTargetOfNamespaceImport(node); case 224: + return getTargetOfNamespaceImport(node); + case 226: return getTargetOfImportSpecifier(node); - case 228: + case 230: return getTargetOfExportSpecifier(node); - case 225: + case 227: return getTargetOfExportAssignment(node); } } @@ -11310,10 +11543,10 @@ var ts; if (!links.referenced) { links.referenced = true; var node = getDeclarationOfAliasSymbol(symbol); - if (node.kind === 225) { + if (node.kind === 227) { checkExpressionCached(node.expression); } - else if (node.kind === 228) { + else if (node.kind === 230) { checkExpressionCached(node.propertyName || node.name); } else if (ts.isInternalModuleImportEqualsDeclaration(node)) { @@ -11323,17 +11556,17 @@ var ts; } function getSymbolOfPartOfRightHandSideOfImportEquals(entityName, importDeclaration) { if (!importDeclaration) { - importDeclaration = ts.getAncestor(entityName, 219); + importDeclaration = ts.getAncestor(entityName, 221); ts.Debug.assert(importDeclaration !== undefined); } - if (entityName.kind === 67 && ts.isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { + if (entityName.kind === 69 && ts.isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { entityName = entityName.parent; } - if (entityName.kind === 67 || entityName.parent.kind === 133) { + if (entityName.kind === 69 || entityName.parent.kind === 135) { return resolveEntityName(entityName, 1536); } else { - ts.Debug.assert(entityName.parent.kind === 219); + ts.Debug.assert(entityName.parent.kind === 221); return resolveEntityName(entityName, 107455 | 793056 | 1536); } } @@ -11345,16 +11578,16 @@ var ts; return undefined; } var symbol; - if (name.kind === 67) { + if (name.kind === 69) { var message = meaning === 1536 ? ts.Diagnostics.Cannot_find_namespace_0 : ts.Diagnostics.Cannot_find_name_0; symbol = resolveName(name, name.text, meaning, ignoreErrors ? undefined : message, name); if (!symbol) { return undefined; } } - else if (name.kind === 133 || name.kind === 164) { - var left = name.kind === 133 ? name.left : name.expression; - var right = name.kind === 133 ? name.right : name.name; + else if (name.kind === 135 || name.kind === 166) { + var left = name.kind === 135 ? name.left : name.expression; + var right = name.kind === 135 ? name.right : name.name; var namespace = resolveEntityName(left, 1536, ignoreErrors); if (!namespace || namespace === unknownSymbol || ts.nodeIsMissing(right)) { return undefined; @@ -11373,9 +11606,6 @@ var ts; ts.Debug.assert((symbol.flags & 16777216) === 0, "Should never get an instantiated symbol here."); return symbol.flags & meaning ? symbol : resolveAlias(symbol); } - function isExternalModuleNameRelative(moduleName) { - return moduleName.substr(0, 2) === "./" || moduleName.substr(0, 3) === "../" || moduleName.substr(0, 2) === ".\\" || moduleName.substr(0, 3) === "..\\"; - } function resolveExternalModuleName(location, moduleReferenceExpression) { if (moduleReferenceExpression.kind !== 9) { return; @@ -11386,7 +11616,10 @@ var ts; if (moduleName === undefined) { return; } - var isRelative = isExternalModuleNameRelative(moduleName); + if (moduleName.indexOf("!") >= 0) { + moduleName = moduleName.substr(0, moduleName.indexOf("!")); + } + var isRelative = ts.isExternalModuleNameRelative(moduleName); if (!isRelative) { var symbol = getSymbol(globals, "\"" + moduleName + "\"", 512); if (symbol) { @@ -11490,7 +11723,7 @@ var ts; var members = node.members; for (var _i = 0; _i < members.length; _i++) { var member = members[_i]; - if (member.kind === 142 && ts.nodeIsPresent(member.body)) { + if (member.kind === 144 && ts.nodeIsPresent(member.body)) { return member; } } @@ -11555,17 +11788,17 @@ var ts; } } switch (location_1.kind) { - case 246: - if (!ts.isExternalModule(location_1)) { + case 248: + if (!ts.isExternalOrCommonJsModule(location_1)) { break; } - case 216: + case 218: if (result = callback(getSymbolOfNode(location_1).exports)) { return result; } break; - case 212: - case 213: + case 214: + case 215: if (result = callback(getSymbolOfNode(location_1).members)) { return result; } @@ -11598,7 +11831,7 @@ var ts; return ts.forEachValue(symbols, function (symbolFromSymbolTable) { if (symbolFromSymbolTable.flags & 8388608 && symbolFromSymbolTable.name !== "export=" - && !ts.getDeclarationOfKind(symbolFromSymbolTable, 228)) { + && !ts.getDeclarationOfKind(symbolFromSymbolTable, 230)) { if (!useOnlyExternalAliasing || ts.forEach(symbolFromSymbolTable.declarations, ts.isExternalModuleImportEqualsDeclaration)) { var resolvedImportedSymbol = resolveAlias(symbolFromSymbolTable); @@ -11627,7 +11860,7 @@ var ts; if (symbolFromSymbolTable === symbol) { return true; } - symbolFromSymbolTable = (symbolFromSymbolTable.flags & 8388608 && !ts.getDeclarationOfKind(symbolFromSymbolTable, 228)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; + symbolFromSymbolTable = (symbolFromSymbolTable.flags & 8388608 && !ts.getDeclarationOfKind(symbolFromSymbolTable, 230)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; if (symbolFromSymbolTable.flags & meaning) { qualify = true; return true; @@ -11682,8 +11915,8 @@ var ts; } } function hasExternalModuleSymbol(declaration) { - return (declaration.kind === 216 && declaration.name.kind === 9) || - (declaration.kind === 246 && ts.isExternalModule(declaration)); + return (declaration.kind === 218 && declaration.name.kind === 9) || + (declaration.kind === 248 && ts.isExternalOrCommonJsModule(declaration)); } function hasVisibleDeclarations(symbol) { var aliasesToMakeVisible; @@ -11715,11 +11948,11 @@ var ts; } function isEntityNameVisible(entityName, enclosingDeclaration) { var meaning; - if (entityName.parent.kind === 152) { + if (entityName.parent.kind === 154) { meaning = 107455 | 1048576; } - else if (entityName.kind === 133 || entityName.kind === 164 || - entityName.parent.kind === 219) { + else if (entityName.kind === 135 || entityName.kind === 166 || + entityName.parent.kind === 221) { meaning = 1536; } else { @@ -11770,10 +12003,10 @@ var ts; function getTypeAliasForTypeLiteral(type) { if (type.symbol && type.symbol.flags & 2048) { var node = type.symbol.declarations[0].parent; - while (node.kind === 158) { + while (node.kind === 160) { node = node.parent; } - if (node.kind === 214) { + if (node.kind === 216) { return getSymbolOfNode(node); } } @@ -11787,10 +12020,10 @@ var ts; return ts.declarationNameToString(declaration.name); } switch (declaration.kind) { - case 184: + case 186: return "(Anonymous class)"; - case 171: - case 172: + case 173: + case 174: return "(Anonymous function)"; } } @@ -11851,6 +12084,7 @@ var ts; } function buildTypeDisplay(type, writer, enclosingDeclaration, globalFlags, symbolStack) { var globalFlagsToPass = globalFlags & 16; + var inObjectTypeLiteral = false; return writeType(type, globalFlags); function writeType(type, flags) { if (type.flags & 16777343) { @@ -11858,6 +12092,12 @@ var ts; ? "any" : type.intrinsicName); } + else if (type.flags & 33554432) { + if (inObjectTypeLiteral) { + writer.reportInaccessibleThisError(); + } + writer.writeKeyword("this"); + } else if (type.flags & 4096) { writeTypeReference(type, flags); } @@ -11896,9 +12136,9 @@ var ts; writeType(types[i], delimiter === 24 ? 0 : 64); } } - function writeSymbolTypeReference(symbol, typeArguments, pos, end) { - if (!isReservedMemberName(symbol.name)) { - buildSymbolDisplay(symbol, writer, enclosingDeclaration, 793056); + function writeSymbolTypeReference(symbol, typeArguments, pos, end, flags) { + if (symbol.flags & 32 || !isReservedMemberName(symbol.name)) { + buildSymbolDisplay(symbol, writer, enclosingDeclaration, 793056, 0, flags); } if (pos < end) { writePunctuation(writer, 25); @@ -11912,7 +12152,7 @@ var ts; } } function writeTypeReference(type, flags) { - var typeArguments = type.typeArguments; + var typeArguments = type.typeArguments || emptyArray; if (type.target === globalArrayType && !(flags & 1)) { writeType(typeArguments[0], 64); writePunctuation(writer, 19); @@ -11930,12 +12170,13 @@ var ts; i++; } while (i < length_1 && getParentSymbolOfTypeParameter(outerTypeParameters[i]) === parent_3); if (!ts.rangeEquals(outerTypeParameters, typeArguments, start, i)) { - writeSymbolTypeReference(parent_3, typeArguments, start, i); + writeSymbolTypeReference(parent_3, typeArguments, start, i, flags); writePunctuation(writer, 21); } } } - writeSymbolTypeReference(type.symbol, typeArguments, i, typeArguments.length); + var typeParameterCount = (type.target.typeParameters || emptyArray).length; + writeSymbolTypeReference(type.symbol, typeArguments, i, typeParameterCount, flags); } } function writeTupleType(type) { @@ -11947,7 +12188,7 @@ var ts; if (flags & 64) { writePunctuation(writer, 17); } - writeTypeList(type.types, type.flags & 16384 ? 46 : 45); + writeTypeList(type.types, type.flags & 16384 ? 47 : 46); if (flags & 64) { writePunctuation(writer, 18); } @@ -11967,7 +12208,7 @@ var ts; buildSymbolDisplay(typeAlias, writer, enclosingDeclaration, 793056, 0, flags); } else { - writeKeyword(writer, 115); + writeKeyword(writer, 117); } } else { @@ -11988,7 +12229,7 @@ var ts; var isNonLocalFunctionSymbol = !!(symbol.flags & 16) && (symbol.parent || ts.forEach(symbol.declarations, function (declaration) { - return declaration.parent.kind === 246 || declaration.parent.kind === 217; + return declaration.parent.kind === 248 || declaration.parent.kind === 219; })); if (isStaticMethodSymbol || isNonLocalFunctionSymbol) { return !!(flags & 2) || @@ -11997,7 +12238,7 @@ var ts; } } function writeTypeofSymbol(type, typeFormatFlags) { - writeKeyword(writer, 99); + writeKeyword(writer, 101); writeSpace(writer); buildSymbolDisplay(type.symbol, writer, enclosingDeclaration, 107455, 0, typeFormatFlags); } @@ -12031,7 +12272,7 @@ var ts; if (flags & 64) { writePunctuation(writer, 17); } - writeKeyword(writer, 90); + writeKeyword(writer, 92); writeSpace(writer); buildSignatureDisplay(resolved.constructSignatures[0], writer, enclosingDeclaration, globalFlagsToPass | 8, symbolStack); if (flags & 64) { @@ -12040,6 +12281,8 @@ var ts; return; } } + var saveInObjectTypeLiteral = inObjectTypeLiteral; + inObjectTypeLiteral = true; writePunctuation(writer, 15); writer.writeLine(); writer.increaseIndent(); @@ -12051,7 +12294,7 @@ var ts; } for (var _b = 0, _c = resolved.constructSignatures; _b < _c.length; _b++) { var signature = _c[_b]; - writeKeyword(writer, 90); + writeKeyword(writer, 92); writeSpace(writer); buildSignatureDisplay(signature, writer, enclosingDeclaration, globalFlagsToPass, symbolStack); writePunctuation(writer, 23); @@ -12060,11 +12303,11 @@ var ts; if (resolved.stringIndexType) { writePunctuation(writer, 19); writer.writeParameter(getIndexerParameterName(resolved, 0, "x")); - writePunctuation(writer, 53); + writePunctuation(writer, 54); writeSpace(writer); - writeKeyword(writer, 128); + writeKeyword(writer, 130); writePunctuation(writer, 20); - writePunctuation(writer, 53); + writePunctuation(writer, 54); writeSpace(writer); writeType(resolved.stringIndexType, 0); writePunctuation(writer, 23); @@ -12073,11 +12316,11 @@ var ts; if (resolved.numberIndexType) { writePunctuation(writer, 19); writer.writeParameter(getIndexerParameterName(resolved, 1, "x")); - writePunctuation(writer, 53); + writePunctuation(writer, 54); writeSpace(writer); - writeKeyword(writer, 126); + writeKeyword(writer, 128); writePunctuation(writer, 20); - writePunctuation(writer, 53); + writePunctuation(writer, 54); writeSpace(writer); writeType(resolved.numberIndexType, 0); writePunctuation(writer, 23); @@ -12092,7 +12335,7 @@ var ts; var signature = signatures[_f]; buildSymbolDisplay(p, writer); if (p.flags & 536870912) { - writePunctuation(writer, 52); + writePunctuation(writer, 53); } buildSignatureDisplay(signature, writer, enclosingDeclaration, globalFlagsToPass, symbolStack); writePunctuation(writer, 23); @@ -12102,9 +12345,9 @@ var ts; else { buildSymbolDisplay(p, writer); if (p.flags & 536870912) { - writePunctuation(writer, 52); + writePunctuation(writer, 53); } - writePunctuation(writer, 53); + writePunctuation(writer, 54); writeSpace(writer); writeType(t, 0); writePunctuation(writer, 23); @@ -12113,6 +12356,7 @@ var ts; } writer.decreaseIndent(); writePunctuation(writer, 16); + inObjectTypeLiteral = saveInObjectTypeLiteral; } } function buildTypeParameterDisplayFromSymbol(symbol, writer, enclosingDeclaraiton, flags) { @@ -12126,7 +12370,7 @@ var ts; var constraint = getConstraintOfTypeParameter(tp); if (constraint) { writeSpace(writer); - writeKeyword(writer, 81); + writeKeyword(writer, 83); writeSpace(writer); buildTypeDisplay(constraint, writer, enclosingDeclaration, flags, symbolStack); } @@ -12138,9 +12382,9 @@ var ts; } appendSymbolNameOnly(p, writer); if (isOptionalParameter(parameterNode)) { - writePunctuation(writer, 52); + writePunctuation(writer, 53); } - writePunctuation(writer, 53); + writePunctuation(writer, 54); writeSpace(writer); buildTypeDisplay(getTypeOfSymbol(p), writer, enclosingDeclaration, flags, symbolStack); } @@ -12187,14 +12431,14 @@ var ts; writePunctuation(writer, 34); } else { - writePunctuation(writer, 53); + writePunctuation(writer, 54); } writeSpace(writer); var returnType; if (signature.typePredicate) { writer.writeParameter(signature.typePredicate.parameterName); writeSpace(writer); - writeKeyword(writer, 122); + writeKeyword(writer, 124); writeSpace(writer); returnType = signature.typePredicate.type; } @@ -12228,13 +12472,13 @@ var ts; function isDeclarationVisible(node) { function getContainingExternalModule(node) { for (; node; node = node.parent) { - if (node.kind === 216) { + if (node.kind === 218) { if (node.name.kind === 9) { return node; } } - else if (node.kind === 246) { - return ts.isExternalModule(node) ? node : undefined; + else if (node.kind === 248) { + return ts.isExternalOrCommonJsModule(node) ? node : undefined; } } ts.Debug.fail("getContainingModule cant reach here"); @@ -12276,59 +12520,59 @@ var ts; } function determineIfDeclarationIsVisible() { switch (node.kind) { - case 161: + case 163: return isDeclarationVisible(node.parent.parent); - case 209: + case 211: if (ts.isBindingPattern(node.name) && !node.name.elements.length) { return false; } - case 216: - case 212: - case 213: + case 218: case 214: - case 211: case 215: - case 219: + case 216: + case 213: + case 217: + case 221: var parent_4 = getDeclarationContainer(node); if (!(ts.getCombinedNodeFlags(node) & 1) && - !(node.kind !== 219 && parent_4.kind !== 246 && ts.isInAmbientContext(parent_4))) { + !(node.kind !== 221 && parent_4.kind !== 248 && ts.isInAmbientContext(parent_4))) { return isGlobalSourceFile(parent_4); } return isDeclarationVisible(parent_4); - case 139: - case 138: - case 143: - case 144: case 141: case 140: + case 145: + case 146: + case 143: + case 142: if (node.flags & (32 | 64)) { return false; } - case 142: - case 146: - case 145: + case 144: + case 148: case 147: - case 136: - case 217: - case 150: - case 151: - case 153: case 149: - case 154: + case 138: + case 219: + case 152: + case 153: case 155: + case 151: case 156: case 157: case 158: + case 159: + case 160: return isDeclarationVisible(node.parent); - case 221: - case 222: + case 223: case 224: + case 226: return false; - case 135: - case 246: + case 137: + case 248: return true; - case 225: + case 227: return false; default: ts.Debug.fail("isDeclarationVisible unknown: SyntaxKind: " + node.kind); @@ -12344,10 +12588,10 @@ var ts; } function collectLinkedAliases(node) { var exportSymbol; - if (node.parent && node.parent.kind === 225) { + if (node.parent && node.parent.kind === 227) { exportSymbol = resolveName(node.parent, node.text, 107455 | 793056 | 1536 | 8388608, ts.Diagnostics.Cannot_find_name_0, node); } - else if (node.parent.kind === 228) { + else if (node.parent.kind === 230) { var exportSpecifier = node.parent; exportSymbol = exportSpecifier.parent.parent.moduleSpecifier ? getExternalModuleMember(exportSpecifier.parent.parent, exportSpecifier) : @@ -12422,7 +12666,7 @@ var ts; } function getDeclarationContainer(node) { node = ts.getRootDeclaration(node); - return node.kind === 209 ? node.parent.parent.parent : node.parent; + return node.kind === 211 ? node.parent.parent.parent : node.parent; } function getTypeOfPrototypeProperty(prototype) { var classType = getDeclaredTypeOfSymbol(prototype.parent); @@ -12435,9 +12679,13 @@ var ts; function isTypeAny(type) { return type && (type.flags & 1) !== 0; } + function getTypeForBindingElementParent(node) { + var symbol = getSymbolOfNode(node); + return symbol && getSymbolLinks(symbol).type || getTypeForVariableLikeDeclaration(node); + } function getTypeForBindingElement(declaration) { var pattern = declaration.parent; - var parentType = getTypeForVariableLikeDeclaration(pattern.parent); + var parentType = getTypeForBindingElementParent(pattern.parent); if (parentType === unknownType) { return unknownType; } @@ -12448,7 +12696,7 @@ var ts; return parentType; } var type; - if (pattern.kind === 159) { + if (pattern.kind === 161) { var name_11 = declaration.propertyName || declaration.name; type = getTypeOfPropertyOfType(parentType, name_11.text) || isNumericLiteralName(name_11.text) && getIndexTypeOfType(parentType, 1) || @@ -12482,10 +12730,10 @@ var ts; return type; } function getTypeForVariableLikeDeclaration(declaration) { - if (declaration.parent.parent.kind === 198) { + if (declaration.parent.parent.kind === 200) { return anyType; } - if (declaration.parent.parent.kind === 199) { + if (declaration.parent.parent.kind === 201) { return checkRightHandSideOfForOf(declaration.parent.parent.expression) || anyType; } if (ts.isBindingPattern(declaration.parent)) { @@ -12494,10 +12742,10 @@ var ts; if (declaration.type) { return getTypeFromTypeNode(declaration.type); } - if (declaration.kind === 136) { + if (declaration.kind === 138) { var func = declaration.parent; - if (func.kind === 144 && !ts.hasDynamicName(func)) { - var getter = ts.getDeclarationOfKind(declaration.parent.symbol, 143); + if (func.kind === 146 && !ts.hasDynamicName(func)) { + var getter = ts.getDeclarationOfKind(declaration.parent.symbol, 145); if (getter) { return getReturnTypeOfSignature(getSignatureFromDeclaration(getter)); } @@ -12510,7 +12758,7 @@ var ts; if (declaration.initializer) { return checkExpressionCached(declaration.initializer); } - if (declaration.kind === 244) { + if (declaration.kind === 246) { return checkIdentifier(declaration.name); } if (ts.isBindingPattern(declaration.name)) { @@ -12548,7 +12796,7 @@ var ts; if (elements.length === 0 || elements[elements.length - 1].dotDotDotToken) { return languageVersion >= 2 ? createIterableType(anyType) : anyArrayType; } - var elementTypes = ts.map(elements, function (e) { return e.kind === 185 ? anyType : getTypeFromBindingElement(e, includePatternInType); }); + var elementTypes = ts.map(elements, function (e) { return e.kind === 187 ? anyType : getTypeFromBindingElement(e, includePatternInType); }); if (includePatternInType) { var result = createNewTupleType(elementTypes); result.pattern = pattern; @@ -12557,7 +12805,7 @@ var ts; return createTupleType(elementTypes); } function getTypeFromBindingPattern(pattern, includePatternInType) { - return pattern.kind === 159 + return pattern.kind === 161 ? getTypeFromObjectBindingPattern(pattern, includePatternInType) : getTypeFromArrayBindingPattern(pattern, includePatternInType); } @@ -12567,12 +12815,12 @@ var ts; if (reportErrors) { reportErrorsFromWidening(declaration, type); } - return declaration.kind !== 243 ? getWidenedType(type) : type; + return declaration.kind !== 245 ? getWidenedType(type) : type; } type = declaration.dotDotDotToken ? anyArrayType : anyType; if (reportErrors && compilerOptions.noImplicitAny) { var root = ts.getRootDeclaration(declaration); - if (!isPrivateWithinAmbient(root) && !(root.kind === 136 && isPrivateWithinAmbient(root.parent))) { + if (!isPrivateWithinAmbient(root) && !(root.kind === 138 && isPrivateWithinAmbient(root.parent))) { reportImplicitAnyError(declaration, type); } } @@ -12585,12 +12833,18 @@ var ts; return links.type = getTypeOfPrototypeProperty(symbol); } var declaration = symbol.valueDeclaration; - if (declaration.parent.kind === 242) { + if (declaration.parent.kind === 244) { return links.type = anyType; } - if (declaration.kind === 225) { + if (declaration.kind === 227) { return links.type = checkExpression(declaration.expression); } + if (declaration.kind === 181) { + return links.type = checkExpression(declaration.right); + } + if (declaration.kind === 166) { + return checkExpressionCached(declaration.parent.right); + } if (!pushTypeResolution(symbol, 0)) { return unknownType; } @@ -12613,7 +12867,7 @@ var ts; } function getAnnotatedAccessorType(accessor) { if (accessor) { - if (accessor.kind === 143) { + if (accessor.kind === 145) { return accessor.type && getTypeFromTypeNode(accessor.type); } else { @@ -12629,8 +12883,8 @@ var ts; if (!pushTypeResolution(symbol, 0)) { return unknownType; } - var getter = ts.getDeclarationOfKind(symbol, 143); - var setter = ts.getDeclarationOfKind(symbol, 144); + var getter = ts.getDeclarationOfKind(symbol, 145); + var setter = ts.getDeclarationOfKind(symbol, 146); var type; var getterReturnType = getAnnotatedAccessorType(getter); if (getterReturnType) { @@ -12656,7 +12910,7 @@ var ts; if (!popTypeResolution()) { type = anyType; if (compilerOptions.noImplicitAny) { - var getter_1 = ts.getDeclarationOfKind(symbol, 143); + var getter_1 = ts.getDeclarationOfKind(symbol, 145); error(getter_1, ts.Diagnostics._0_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions, symbolToString(symbol)); } } @@ -12745,9 +12999,9 @@ var ts; if (!node) { return typeParameters; } - if (node.kind === 212 || node.kind === 184 || - node.kind === 211 || node.kind === 171 || - node.kind === 141 || node.kind === 172) { + if (node.kind === 214 || node.kind === 186 || + node.kind === 213 || node.kind === 173 || + node.kind === 143 || node.kind === 174) { var declarations = node.typeParameters; if (declarations) { return appendTypeParameters(appendOuterTypeParameters(typeParameters, node), declarations); @@ -12756,15 +13010,15 @@ var ts; } } function getOuterTypeParametersOfClassOrInterface(symbol) { - var declaration = symbol.flags & 32 ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 213); + var declaration = symbol.flags & 32 ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 215); return appendOuterTypeParameters(undefined, declaration); } function getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol) { var result; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var node = _a[_i]; - if (node.kind === 213 || node.kind === 212 || - node.kind === 184 || node.kind === 214) { + if (node.kind === 215 || node.kind === 214 || + node.kind === 186 || node.kind === 216) { var declaration = node; if (declaration.typeParameters) { result = appendTypeParameters(result, declaration.typeParameters); @@ -12869,7 +13123,7 @@ var ts; type.resolvedBaseTypes = []; for (var _i = 0, _a = type.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 213 && ts.getInterfaceBaseTypeNodes(declaration)) { + if (declaration.kind === 215 && ts.getInterfaceBaseTypeNodes(declaration)) { for (var _b = 0, _c = ts.getInterfaceBaseTypeNodes(declaration); _b < _c.length; _b++) { var node = _c[_b]; var baseType = getTypeFromTypeNode(node); @@ -12890,6 +13144,29 @@ var ts; } } } + function isIndependentInterface(symbol) { + for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { + var declaration = _a[_i]; + if (declaration.kind === 215) { + if (declaration.flags & 524288) { + return false; + } + var baseTypeNodes = ts.getInterfaceBaseTypeNodes(declaration); + if (baseTypeNodes) { + for (var _b = 0; _b < baseTypeNodes.length; _b++) { + var node = baseTypeNodes[_b]; + if (ts.isSupportedExpressionWithTypeArguments(node)) { + var baseSymbol = resolveEntityName(node.expression, 793056, true); + if (!baseSymbol || !(baseSymbol.flags & 64) || getDeclaredTypeOfClassOrInterface(baseSymbol).thisType) { + return false; + } + } + } + } + } + } + return true; + } function getDeclaredTypeOfClassOrInterface(symbol) { var links = getSymbolLinks(symbol); if (!links.declaredType) { @@ -12897,7 +13174,7 @@ var ts; var type = links.declaredType = createObjectType(kind, symbol); var outerTypeParameters = getOuterTypeParametersOfClassOrInterface(symbol); var localTypeParameters = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol); - if (outerTypeParameters || localTypeParameters) { + if (outerTypeParameters || localTypeParameters || kind === 1024 || !isIndependentInterface(symbol)) { type.flags |= 4096; type.typeParameters = ts.concatenate(outerTypeParameters, localTypeParameters); type.outerTypeParameters = outerTypeParameters; @@ -12906,6 +13183,9 @@ var ts; type.instantiations[getTypeListId(type.typeParameters)] = type; type.target = type; type.typeArguments = type.typeParameters; + type.thisType = createType(512 | 33554432); + type.thisType.symbol = symbol; + type.thisType.constraint = getTypeWithThisArgument(type); } } return links.declaredType; @@ -12916,7 +13196,7 @@ var ts; if (!pushTypeResolution(symbol, 2)) { return unknownType; } - var declaration = ts.getDeclarationOfKind(symbol, 214); + var declaration = ts.getDeclarationOfKind(symbol, 216); var type = getTypeFromTypeNode(declaration.type); if (popTypeResolution()) { links.typeParameters = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol); @@ -12947,7 +13227,7 @@ var ts; if (!links.declaredType) { var type = createType(512); type.symbol = symbol; - if (!ts.getDeclarationOfKind(symbol, 135).constraint) { + if (!ts.getDeclarationOfKind(symbol, 137).constraint) { type.constraint = noConstraintType; } links.declaredType = type; @@ -12980,6 +13260,66 @@ var ts; } return unknownType; } + function isIndependentTypeReference(node) { + if (node.typeArguments) { + for (var _i = 0, _a = node.typeArguments; _i < _a.length; _i++) { + var typeNode = _a[_i]; + if (!isIndependentType(typeNode)) { + return false; + } + } + } + return true; + } + function isIndependentType(node) { + switch (node.kind) { + case 117: + case 130: + case 128: + case 120: + case 131: + case 103: + case 9: + return true; + case 156: + return isIndependentType(node.elementType); + case 151: + return isIndependentTypeReference(node); + } + return false; + } + function isIndependentVariableLikeDeclaration(node) { + return node.type && isIndependentType(node.type) || !node.type && !node.initializer; + } + function isIndependentFunctionLikeDeclaration(node) { + if (node.kind !== 144 && (!node.type || !isIndependentType(node.type))) { + return false; + } + for (var _i = 0, _a = node.parameters; _i < _a.length; _i++) { + var parameter = _a[_i]; + if (!isIndependentVariableLikeDeclaration(parameter)) { + return false; + } + } + return true; + } + function isIndependentMember(symbol) { + if (symbol.declarations && symbol.declarations.length === 1) { + var declaration = symbol.declarations[0]; + if (declaration) { + switch (declaration.kind) { + case 141: + case 140: + return isIndependentVariableLikeDeclaration(declaration); + case 143: + case 142: + case 144: + return isIndependentFunctionLikeDeclaration(declaration); + } + } + } + return false; + } function createSymbolTable(symbols) { var result = {}; for (var _i = 0; _i < symbols.length; _i++) { @@ -12988,11 +13328,11 @@ var ts; } return result; } - function createInstantiatedSymbolTable(symbols, mapper) { + function createInstantiatedSymbolTable(symbols, mapper, mappingThisOnly) { var result = {}; for (var _i = 0; _i < symbols.length; _i++) { var symbol = symbols[_i]; - result[symbol.name] = instantiateSymbol(symbol, mapper); + result[symbol.name] = mappingThisOnly && isIndependentMember(symbol) ? symbol : instantiateSymbol(symbol, mapper); } return result; } @@ -13023,44 +13363,54 @@ var ts; } return type; } - function resolveClassOrInterfaceMembers(type) { - var target = resolveDeclaredMembers(type); - var members = target.symbol.members; - var callSignatures = target.declaredCallSignatures; - var constructSignatures = target.declaredConstructSignatures; - var stringIndexType = target.declaredStringIndexType; - var numberIndexType = target.declaredNumberIndexType; - var baseTypes = getBaseTypes(target); + function getTypeWithThisArgument(type, thisArgument) { + if (type.flags & 4096) { + return createTypeReference(type.target, ts.concatenate(type.typeArguments, [thisArgument || type.target.thisType])); + } + return type; + } + function resolveObjectTypeMembers(type, source, typeParameters, typeArguments) { + var mapper = identityMapper; + var members = source.symbol.members; + var callSignatures = source.declaredCallSignatures; + var constructSignatures = source.declaredConstructSignatures; + var stringIndexType = source.declaredStringIndexType; + var numberIndexType = source.declaredNumberIndexType; + if (!ts.rangeEquals(typeParameters, typeArguments, 0, typeParameters.length)) { + mapper = createTypeMapper(typeParameters, typeArguments); + members = createInstantiatedSymbolTable(source.declaredProperties, mapper, typeParameters.length === 1); + callSignatures = instantiateList(source.declaredCallSignatures, mapper, instantiateSignature); + constructSignatures = instantiateList(source.declaredConstructSignatures, mapper, instantiateSignature); + stringIndexType = instantiateType(source.declaredStringIndexType, mapper); + numberIndexType = instantiateType(source.declaredNumberIndexType, mapper); + } + var baseTypes = getBaseTypes(source); if (baseTypes.length) { - members = createSymbolTable(target.declaredProperties); + if (members === source.symbol.members) { + members = createSymbolTable(source.declaredProperties); + } + var thisArgument = ts.lastOrUndefined(typeArguments); for (var _i = 0; _i < baseTypes.length; _i++) { var baseType = baseTypes[_i]; - addInheritedMembers(members, getPropertiesOfObjectType(baseType)); - callSignatures = ts.concatenate(callSignatures, getSignaturesOfType(baseType, 0)); - constructSignatures = ts.concatenate(constructSignatures, getSignaturesOfType(baseType, 1)); - stringIndexType = stringIndexType || getIndexTypeOfType(baseType, 0); - numberIndexType = numberIndexType || getIndexTypeOfType(baseType, 1); + var instantiatedBaseType = thisArgument ? getTypeWithThisArgument(instantiateType(baseType, mapper), thisArgument) : baseType; + addInheritedMembers(members, getPropertiesOfObjectType(instantiatedBaseType)); + callSignatures = ts.concatenate(callSignatures, getSignaturesOfType(instantiatedBaseType, 0)); + constructSignatures = ts.concatenate(constructSignatures, getSignaturesOfType(instantiatedBaseType, 1)); + stringIndexType = stringIndexType || getIndexTypeOfType(instantiatedBaseType, 0); + numberIndexType = numberIndexType || getIndexTypeOfType(instantiatedBaseType, 1); } } setObjectTypeMembers(type, members, callSignatures, constructSignatures, stringIndexType, numberIndexType); } + function resolveClassOrInterfaceMembers(type) { + resolveObjectTypeMembers(type, resolveDeclaredMembers(type), emptyArray, emptyArray); + } function resolveTypeReferenceMembers(type) { - var target = resolveDeclaredMembers(type.target); - var mapper = createTypeMapper(target.typeParameters, type.typeArguments); - var members = createInstantiatedSymbolTable(target.declaredProperties, mapper); - var callSignatures = instantiateList(target.declaredCallSignatures, mapper, instantiateSignature); - var constructSignatures = instantiateList(target.declaredConstructSignatures, mapper, instantiateSignature); - var stringIndexType = target.declaredStringIndexType ? instantiateType(target.declaredStringIndexType, mapper) : undefined; - var numberIndexType = target.declaredNumberIndexType ? instantiateType(target.declaredNumberIndexType, mapper) : undefined; - ts.forEach(getBaseTypes(target), function (baseType) { - var instantiatedBaseType = instantiateType(baseType, mapper); - addInheritedMembers(members, getPropertiesOfObjectType(instantiatedBaseType)); - callSignatures = ts.concatenate(callSignatures, getSignaturesOfType(instantiatedBaseType, 0)); - constructSignatures = ts.concatenate(constructSignatures, getSignaturesOfType(instantiatedBaseType, 1)); - stringIndexType = stringIndexType || getIndexTypeOfType(instantiatedBaseType, 0); - numberIndexType = numberIndexType || getIndexTypeOfType(instantiatedBaseType, 1); - }); - setObjectTypeMembers(type, members, callSignatures, constructSignatures, stringIndexType, numberIndexType); + var source = resolveDeclaredMembers(type.target); + var typeParameters = ts.concatenate(source.typeParameters, [source.thisType]); + var typeArguments = type.typeArguments && type.typeArguments.length === typeParameters.length ? + type.typeArguments : ts.concatenate(type.typeArguments, [type]); + resolveObjectTypeMembers(type, source, typeParameters, typeArguments); } function createSignature(declaration, typeParameters, parameters, resolvedReturnType, typePredicate, minArgumentCount, hasRestParameter, hasStringLiterals) { var sig = new Signature(checker); @@ -13109,7 +13459,8 @@ var ts; return members; } function resolveTupleTypeMembers(type) { - var arrayType = resolveStructuredTypeMembers(createArrayType(getUnionType(type.elementTypes, true))); + var arrayElementType = getUnionType(type.elementTypes, true); + var arrayType = resolveStructuredTypeMembers(createTypeFromGenericGlobalType(globalArrayType, [arrayElementType, type])); var members = createTupleTypeMemberSymbols(type.elementTypes); addInheritedMembers(members, arrayType.properties); setObjectTypeMembers(type, members, arrayType.callSignatures, arrayType.constructSignatures, arrayType.stringIndexType, arrayType.numberIndexType); @@ -13211,7 +13562,14 @@ var ts; var constructSignatures; var stringIndexType; var numberIndexType; - if (symbol.flags & 2048) { + if (type.target) { + members = createInstantiatedSymbolTable(getPropertiesOfObjectType(type.target), type.mapper, false); + callSignatures = instantiateList(getSignaturesOfType(type.target, 0), type.mapper, instantiateSignature); + constructSignatures = instantiateList(getSignaturesOfType(type.target, 1), type.mapper, instantiateSignature); + stringIndexType = instantiateType(getIndexTypeOfType(type.target, 0), type.mapper); + numberIndexType = instantiateType(getIndexTypeOfType(type.target, 1), type.mapper); + } + else if (symbol.flags & 2048) { members = symbol.members; callSignatures = getSignaturesOfSymbol(members["__call"]); constructSignatures = getSignaturesOfSymbol(members["__new"]); @@ -13247,7 +13605,10 @@ var ts; } function resolveStructuredTypeMembers(type) { if (!type.members) { - if (type.flags & (1024 | 2048)) { + if (type.flags & 4096) { + resolveTypeReferenceMembers(type); + } + else if (type.flags & (1024 | 2048)) { resolveClassOrInterfaceMembers(type); } else if (type.flags & 65536) { @@ -13262,9 +13623,6 @@ var ts; else if (type.flags & 32768) { resolveIntersectionTypeMembers(type); } - else { - resolveTypeReferenceMembers(type); - } } return type; } @@ -13471,7 +13829,7 @@ var ts; function getSignatureFromDeclaration(declaration) { var links = getNodeLinks(declaration); if (!links.resolvedSignature) { - var classType = declaration.kind === 142 ? getDeclaredTypeOfClassOrInterface(declaration.parent.symbol) : undefined; + var classType = declaration.kind === 144 ? getDeclaredTypeOfClassOrInterface(declaration.parent.symbol) : undefined; var typeParameters = classType ? classType.localTypeParameters : declaration.typeParameters ? getTypeParametersFromDeclaration(declaration.typeParameters) : undefined; var parameters = []; @@ -13502,7 +13860,7 @@ var ts; } else if (declaration.type) { returnType = getTypeFromTypeNode(declaration.type); - if (declaration.type.kind === 148) { + if (declaration.type.kind === 150) { var typePredicateNode = declaration.type; typePredicate = { parameterName: typePredicateNode.parameterName ? typePredicateNode.parameterName.text : undefined, @@ -13512,8 +13870,8 @@ var ts; } } else { - if (declaration.kind === 143 && !ts.hasDynamicName(declaration)) { - var setter = ts.getDeclarationOfKind(declaration.symbol, 144); + if (declaration.kind === 145 && !ts.hasDynamicName(declaration)) { + var setter = ts.getDeclarationOfKind(declaration.symbol, 146); returnType = getAnnotatedAccessorType(setter); } if (!returnType && ts.nodeIsMissing(declaration.body)) { @@ -13531,19 +13889,19 @@ var ts; for (var i = 0, len = symbol.declarations.length; i < len; i++) { var node = symbol.declarations[i]; switch (node.kind) { - case 150: - case 151: - case 211: - case 141: - case 140: + case 152: + case 153: + case 213: + case 143: case 142: + case 144: + case 147: + case 148: + case 149: case 145: case 146: - case 147: - case 143: - case 144: - case 171: - case 172: + case 173: + case 174: if (i > 0 && node.body) { var previous = symbol.declarations[i - 1]; if (node.parent === previous.parent && node.kind === previous.kind && node.pos === previous.end) { @@ -13555,6 +13913,16 @@ var ts; } return result; } + function resolveExternalModuleTypeByLiteral(name) { + var moduleSym = resolveExternalModuleName(name, name); + if (moduleSym) { + var resolvedModuleSymbol = resolveExternalModuleSymbol(moduleSym); + if (resolvedModuleSymbol) { + return getTypeOfSymbol(resolvedModuleSymbol); + } + } + return anyType; + } function getReturnTypeOfSignature(signature) { if (!signature.resolvedReturnType) { if (!pushTypeResolution(signature, 3)) { @@ -13613,7 +13981,7 @@ var ts; } function getOrCreateTypeFromSignature(signature) { if (!signature.isolatedSignatureType) { - var isConstructor = signature.declaration.kind === 142 || signature.declaration.kind === 146; + var isConstructor = signature.declaration.kind === 144 || signature.declaration.kind === 148; var type = createObjectType(65536 | 262144); type.members = emptySymbols; type.properties = emptyArray; @@ -13627,7 +13995,7 @@ var ts; return symbol.members["__index"]; } function getIndexDeclarationOfSymbol(symbol, kind) { - var syntaxKind = kind === 1 ? 126 : 128; + var syntaxKind = kind === 1 ? 128 : 130; var indexSymbol = getIndexSymbol(symbol); if (indexSymbol) { for (var _i = 0, _a = indexSymbol.declarations; _i < _a.length; _i++) { @@ -13656,30 +14024,33 @@ var ts; type.constraint = targetConstraint ? instantiateType(targetConstraint, type.mapper) : noConstraintType; } else { - type.constraint = getTypeFromTypeNode(ts.getDeclarationOfKind(type.symbol, 135).constraint); + type.constraint = getTypeFromTypeNode(ts.getDeclarationOfKind(type.symbol, 137).constraint); } } return type.constraint === noConstraintType ? undefined : type.constraint; } function getParentSymbolOfTypeParameter(typeParameter) { - return getSymbolOfNode(ts.getDeclarationOfKind(typeParameter.symbol, 135).parent); + return getSymbolOfNode(ts.getDeclarationOfKind(typeParameter.symbol, 137).parent); } function getTypeListId(types) { - switch (types.length) { - case 1: - return "" + types[0].id; - case 2: - return types[0].id + "," + types[1].id; - default: - var result = ""; - for (var i = 0; i < types.length; i++) { - if (i > 0) { - result += ","; + if (types) { + switch (types.length) { + case 1: + return "" + types[0].id; + case 2: + return types[0].id + "," + types[1].id; + default: + var result = ""; + for (var i = 0; i < types.length; i++) { + if (i > 0) { + result += ","; + } + result += types[i].id; } - result += types[i].id; - } - return result; + return result; + } } + return ""; } function getPropagatingFlagsOfTypes(types) { var result = 0; @@ -13693,7 +14064,7 @@ var ts; var id = getTypeListId(typeArguments); var type = target.instantiations[id]; if (!type) { - var flags = 4096 | getPropagatingFlagsOfTypes(typeArguments); + var flags = 4096 | (typeArguments ? getPropagatingFlagsOfTypes(typeArguments) : 0); type = target.instantiations[id] = createObjectType(flags, target.symbol); type.target = target; type.typeArguments = typeArguments; @@ -13709,13 +14080,13 @@ var ts; while (!ts.forEach(typeParameterSymbol.declarations, function (d) { return d.parent === currentNode.parent; })) { currentNode = currentNode.parent; } - links.isIllegalTypeReferenceInConstraint = currentNode.kind === 135; + links.isIllegalTypeReferenceInConstraint = currentNode.kind === 137; return links.isIllegalTypeReferenceInConstraint; } function checkTypeParameterHasIllegalReferencesInConstraint(typeParameter) { var typeParameterSymbol; function check(n) { - if (n.kind === 149 && n.typeName.kind === 67) { + if (n.kind === 151 && n.typeName.kind === 69) { var links = getNodeLinks(n); if (links.isIllegalTypeReferenceInConstraint === undefined) { var symbol = resolveName(typeParameter, n.typeName.text, 793056, undefined, undefined); @@ -13782,7 +14153,7 @@ var ts; function getTypeFromTypeReference(node) { var links = getNodeLinks(node); if (!links.resolvedType) { - var typeNameOrExpression = node.kind === 149 ? node.typeName : + var typeNameOrExpression = node.kind === 151 ? node.typeName : ts.isSupportedExpressionWithTypeArguments(node) ? node.expression : undefined; var symbol = typeNameOrExpression && resolveEntityName(typeNameOrExpression, 793056) || unknownSymbol; @@ -13808,9 +14179,9 @@ var ts; for (var _i = 0; _i < declarations.length; _i++) { var declaration = declarations[_i]; switch (declaration.kind) { - case 212: - case 213: + case 214: case 215: + case 217: return declaration; } } @@ -13847,10 +14218,13 @@ var ts; return getTypeOfGlobalSymbol(getGlobalSymbol(name, 793056, undefined), arity); } function getExportedTypeFromNamespace(namespace, name) { - var namespaceSymbol = getGlobalSymbol(namespace, 1536, undefined); - var typeSymbol = namespaceSymbol && getSymbol(namespaceSymbol.exports, name, 793056); + var typeSymbol = getExportedSymbolFromNamespace(namespace, name); return typeSymbol && getDeclaredTypeOfSymbol(typeSymbol); } + function getExportedSymbolFromNamespace(namespace, name) { + var namespaceSymbol = getGlobalSymbol(namespace, 1536, undefined); + return namespaceSymbol && getSymbol(namespaceSymbol.exports, name, 793056 | 107455); + } function getGlobalESSymbolConstructorSymbol() { return globalESSymbolConstructorSymbol || (globalESSymbolConstructorSymbol = getGlobalValueSymbol("Symbol")); } @@ -13860,17 +14234,17 @@ var ts; ? createTypeReference(globalTypedPropertyDescriptorType, [propertyType]) : emptyObjectType; } - function createTypeFromGenericGlobalType(genericGlobalType, elementType) { - return genericGlobalType !== emptyGenericType ? createTypeReference(genericGlobalType, [elementType]) : emptyObjectType; + function createTypeFromGenericGlobalType(genericGlobalType, typeArguments) { + return genericGlobalType !== emptyGenericType ? createTypeReference(genericGlobalType, typeArguments) : emptyObjectType; } function createIterableType(elementType) { - return createTypeFromGenericGlobalType(globalIterableType, elementType); + return createTypeFromGenericGlobalType(globalIterableType, [elementType]); } function createIterableIteratorType(elementType) { - return createTypeFromGenericGlobalType(globalIterableIteratorType, elementType); + return createTypeFromGenericGlobalType(globalIterableIteratorType, [elementType]); } function createArrayType(elementType) { - return createTypeFromGenericGlobalType(globalArrayType, elementType); + return createTypeFromGenericGlobalType(globalArrayType, [elementType]); } function getTypeFromArrayTypeNode(node) { var links = getNodeLinks(node); @@ -14027,46 +14401,66 @@ var ts; } return links.resolvedType; } + function getThisType(node) { + var container = ts.getThisContainer(node, false); + var parent = container && container.parent; + if (parent && (ts.isClassLike(parent) || parent.kind === 215)) { + if (!(container.flags & 128)) { + return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(parent)).thisType; + } + } + error(node, ts.Diagnostics.A_this_type_is_available_only_in_a_non_static_member_of_a_class_or_interface); + return unknownType; + } + function getTypeFromThisTypeNode(node) { + var links = getNodeLinks(node); + if (!links.resolvedType) { + links.resolvedType = getThisType(node); + } + return links.resolvedType; + } function getTypeFromTypeNode(node) { switch (node.kind) { - case 115: + case 117: return anyType; - case 128: + case 130: return stringType; - case 126: + case 128: return numberType; - case 118: + case 120: return booleanType; - case 129: + case 131: return esSymbolType; - case 101: + case 103: return voidType; + case 97: + return getTypeFromThisTypeNode(node); case 9: return getTypeFromStringLiteral(node); - case 149: - return getTypeFromTypeReference(node); - case 148: - return booleanType; - case 186: - return getTypeFromTypeReference(node); - case 152: - return getTypeFromTypeQueryNode(node); - case 154: - return getTypeFromArrayTypeNode(node); - case 155: - return getTypeFromTupleTypeNode(node); - case 156: - return getTypeFromUnionTypeNode(node); - case 157: - return getTypeFromIntersectionTypeNode(node); - case 158: - return getTypeFromTypeNode(node.type); - case 150: case 151: + return getTypeFromTypeReference(node); + case 150: + return booleanType; + case 188: + return getTypeFromTypeReference(node); + case 154: + return getTypeFromTypeQueryNode(node); + case 156: + return getTypeFromArrayTypeNode(node); + case 157: + return getTypeFromTupleTypeNode(node); + case 158: + return getTypeFromUnionTypeNode(node); + case 159: + return getTypeFromIntersectionTypeNode(node); + case 160: + return getTypeFromTypeNode(node.type); + case 152: case 153: + case 155: return getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node); - case 67: - case 133: + case 69: + case 135: var symbol = getSymbolAtLocation(node); return symbol && getDeclaredTypeOfSymbol(symbol); default: @@ -14170,7 +14564,7 @@ var ts; type: instantiateType(signature.typePredicate.type, mapper) }; } - var result = createSignature(signature.declaration, freshTypeParameters, instantiateList(signature.parameters, mapper, instantiateSymbol), signature.resolvedReturnType ? instantiateType(signature.resolvedReturnType, mapper) : undefined, freshTypePredicate, signature.minArgumentCount, signature.hasRestParameter, signature.hasStringLiterals); + var result = createSignature(signature.declaration, freshTypeParameters, instantiateList(signature.parameters, mapper, instantiateSymbol), instantiateType(signature.resolvedReturnType, mapper), freshTypePredicate, signature.minArgumentCount, signature.hasRestParameter, signature.hasStringLiterals); result.target = signature; result.mapper = mapper; return result; @@ -14202,21 +14596,13 @@ var ts; mapper.instantiations = []; } var result = createObjectType(65536 | 131072, type.symbol); - result.properties = instantiateList(getPropertiesOfObjectType(type), mapper, instantiateSymbol); - result.members = createSymbolTable(result.properties); - result.callSignatures = instantiateList(getSignaturesOfType(type, 0), mapper, instantiateSignature); - result.constructSignatures = instantiateList(getSignaturesOfType(type, 1), mapper, instantiateSignature); - var stringIndexType = getIndexTypeOfType(type, 0); - var numberIndexType = getIndexTypeOfType(type, 1); - if (stringIndexType) - result.stringIndexType = instantiateType(stringIndexType, mapper); - if (numberIndexType) - result.numberIndexType = instantiateType(numberIndexType, mapper); + result.target = type; + result.mapper = mapper; mapper.instantiations[type.id] = result; return result; } function instantiateType(type, mapper) { - if (mapper !== identityMapper) { + if (type && mapper !== identityMapper) { if (type.flags & 512) { return mapper(type); } @@ -14240,27 +14626,27 @@ var ts; return type; } function isContextSensitive(node) { - ts.Debug.assert(node.kind !== 141 || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 143 || ts.isObjectLiteralMethod(node)); switch (node.kind) { - case 171: - case 172: + case 173: + case 174: return isContextSensitiveFunctionLikeDeclaration(node); - case 163: + case 165: return ts.forEach(node.properties, isContextSensitive); - case 162: + case 164: return ts.forEach(node.elements, isContextSensitive); - case 180: + case 182: return isContextSensitive(node.whenTrue) || isContextSensitive(node.whenFalse); - case 179: - return node.operatorToken.kind === 51 && + case 181: + return node.operatorToken.kind === 52 && (isContextSensitive(node.left) || isContextSensitive(node.right)); - case 243: + case 245: return isContextSensitive(node.initializer); - case 141: - case 140: + case 143: + case 142: return isContextSensitiveFunctionLikeDeclaration(node); - case 170: + case 172: return isContextSensitive(node.expression); } return false; @@ -14413,7 +14799,7 @@ var ts; } else { if (source.flags & 4096 && target.flags & 4096 && source.target === target.target) { - if (result = typesRelatedTo(source.typeArguments, target.typeArguments, reportErrors)) { + if (result = typeArgumentsRelatedTo(source, target, reportErrors)) { return result; } } @@ -14435,7 +14821,7 @@ var ts; var result; if (source.flags & 80896 && target.flags & 80896) { if (source.flags & 4096 && target.flags & 4096 && source.target === target.target) { - if (result = typesRelatedTo(source.typeArguments, target.typeArguments, false)) { + if (result = typeArgumentsRelatedTo(source, target, false)) { return result; } } @@ -14545,9 +14931,14 @@ var ts; } return result; } - function typesRelatedTo(sources, targets, reportErrors) { + function typeArgumentsRelatedTo(source, target, reportErrors) { + var sources = source.typeArguments || emptyArray; + var targets = target.typeArguments || emptyArray; + if (sources.length !== targets.length && relation === identityRelation) { + return 0; + } var result = -1; - for (var i = 0, len = sources.length; i < len; i++) { + for (var i = 0; i < targets.length; i++) { var related = isRelatedTo(sources[i], targets[i], reportErrors); if (!related) { return 0; @@ -15198,22 +15589,22 @@ var ts; var typeAsString = typeToString(getWidenedType(type)); var diagnostic; switch (declaration.kind) { - case 139: - case 138: + case 141: + case 140: diagnostic = ts.Diagnostics.Member_0_implicitly_has_an_1_type; break; - case 136: + case 138: diagnostic = declaration.dotDotDotToken ? ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type : ts.Diagnostics.Parameter_0_implicitly_has_an_1_type; break; - case 211: - case 141: - case 140: + case 213: case 143: - case 144: - case 171: - case 172: + case 142: + case 145: + case 146: + case 173: + case 174: if (!declaration.name) { error(declaration, ts.Diagnostics.Function_expression_which_lacks_return_type_annotation_implicitly_has_an_0_return_type, typeAsString); return; @@ -15309,9 +15700,10 @@ var ts; } } else if (source.flags & 4096 && target.flags & 4096 && source.target === target.target) { - var sourceTypes = source.typeArguments; - var targetTypes = target.typeArguments; - for (var i = 0; i < sourceTypes.length; i++) { + var sourceTypes = source.typeArguments || emptyArray; + var targetTypes = target.typeArguments || emptyArray; + var count = sourceTypes.length < targetTypes.length ? sourceTypes.length : targetTypes.length; + for (var i = 0; i < count; i++) { inferFromTypes(sourceTypes[i], targetTypes[i]); } } @@ -15465,10 +15857,10 @@ var ts; function isInTypeQuery(node) { while (node) { switch (node.kind) { - case 152: + case 154: return true; - case 67: - case 133: + case 69: + case 135: node = node.parent; continue; default: @@ -15508,12 +15900,12 @@ var ts; } return links.assignmentChecks[symbol.id] = isAssignedIn(node); function isAssignedInBinaryExpression(node) { - if (node.operatorToken.kind >= 55 && node.operatorToken.kind <= 66) { + if (node.operatorToken.kind >= 56 && node.operatorToken.kind <= 68) { var n = node.left; - while (n.kind === 170) { + while (n.kind === 172) { n = n.expression; } - if (n.kind === 67 && getResolvedSymbol(n) === symbol) { + if (n.kind === 69 && getResolvedSymbol(n) === symbol) { return true; } } @@ -15527,55 +15919,55 @@ var ts; } function isAssignedIn(node) { switch (node.kind) { - case 179: + case 181: return isAssignedInBinaryExpression(node); - case 209: - case 161: - return isAssignedInVariableDeclaration(node); - case 159: - case 160: - case 162: + case 211: case 163: + return isAssignedInVariableDeclaration(node); + case 161: + case 162: case 164: case 165: case 166: case 167: + case 168: case 169: - case 187: - case 170: - case 177: - case 173: - case 176: - case 174: + case 171: + case 189: + case 172: + case 179: case 175: case 178: - case 182: + case 176: + case 177: case 180: - case 183: - case 190: - case 191: + case 184: + case 182: + case 185: + case 192: case 193: - case 194: case 195: case 196: case 197: case 198: case 199: - case 202: - case 203: + case 200: + case 201: case 204: - case 239: - case 240: case 205: case 206: - case 207: + case 241: case 242: - case 231: - case 232: - case 236: - case 237: + case 207: + case 208: + case 209: + case 244: case 233: + case 234: case 238: + case 239: + case 235: + case 240: return ts.forEachChild(node, isAssignedIn); } return false; @@ -15590,34 +15982,34 @@ var ts; node = node.parent; var narrowedType = type; switch (node.kind) { - case 194: + case 196: if (child !== node.expression) { narrowedType = narrowType(type, node.expression, child === node.thenStatement); } break; - case 180: + case 182: if (child !== node.condition) { narrowedType = narrowType(type, node.condition, child === node.whenTrue); } break; - case 179: + case 181: if (child === node.right) { - if (node.operatorToken.kind === 50) { + if (node.operatorToken.kind === 51) { narrowedType = narrowType(type, node.left, true); } - else if (node.operatorToken.kind === 51) { + else if (node.operatorToken.kind === 52) { narrowedType = narrowType(type, node.left, false); } } break; - case 246: - case 216: - case 211: - case 141: - case 140: + case 248: + case 218: + case 213: case 143: - case 144: case 142: + case 145: + case 146: + case 144: break loop; } if (narrowedType !== type) { @@ -15631,12 +16023,12 @@ var ts; } return type; function narrowTypeByEquality(type, expr, assumeTrue) { - if (expr.left.kind !== 174 || expr.right.kind !== 9) { + if (expr.left.kind !== 176 || expr.right.kind !== 9) { return type; } var left = expr.left; var right = expr.right; - if (left.expression.kind !== 67 || getResolvedSymbol(left.expression) !== symbol) { + if (left.expression.kind !== 69 || getResolvedSymbol(left.expression) !== symbol) { return type; } var typeInfo = primitiveTypeInfo[right.text]; @@ -15682,7 +16074,7 @@ var ts; } } function narrowTypeByInstanceof(type, expr, assumeTrue) { - if (isTypeAny(type) || !assumeTrue || expr.left.kind !== 67 || getResolvedSymbol(expr.left) !== symbol) { + if (isTypeAny(type) || !assumeTrue || expr.left.kind !== 69 || getResolvedSymbol(expr.left) !== symbol) { return type; } var rightType = checkExpression(expr.right); @@ -15746,27 +16138,27 @@ var ts; } function narrowType(type, expr, assumeTrue) { switch (expr.kind) { - case 166: + case 168: return narrowTypeByTypePredicate(type, expr, assumeTrue); - case 170: + case 172: return narrowType(type, expr.expression, assumeTrue); - case 179: + case 181: var operator = expr.operatorToken.kind; if (operator === 32 || operator === 33) { return narrowTypeByEquality(type, expr, assumeTrue); } - else if (operator === 50) { + else if (operator === 51) { return narrowTypeByAnd(type, expr, assumeTrue); } - else if (operator === 51) { + else if (operator === 52) { return narrowTypeByOr(type, expr, assumeTrue); } - else if (operator === 89) { + else if (operator === 91) { return narrowTypeByInstanceof(type, expr, assumeTrue); } break; - case 177: - if (expr.operator === 48) { + case 179: + if (expr.operator === 49) { return narrowType(type, expr.operand, !assumeTrue); } break; @@ -15778,7 +16170,7 @@ var ts; var symbol = getResolvedSymbol(node); if (symbol === argumentsSymbol) { var container = ts.getContainingFunction(node); - if (container.kind === 172) { + if (container.kind === 174) { if (languageVersion < 2) { error(node, ts.Diagnostics.The_arguments_object_cannot_be_referenced_in_an_arrow_function_in_ES3_and_ES5_Consider_using_a_standard_function_expression); } @@ -15809,15 +16201,15 @@ var ts; function checkBlockScopedBindingCapturedInLoop(node, symbol) { if (languageVersion >= 2 || (symbol.flags & 2) === 0 || - symbol.valueDeclaration.parent.kind === 242) { + symbol.valueDeclaration.parent.kind === 244) { return; } var container = symbol.valueDeclaration; - while (container.kind !== 210) { + while (container.kind !== 212) { container = container.parent; } container = container.parent; - if (container.kind === 191) { + if (container.kind === 193) { container = container.parent; } var inFunction = isInsideFunction(node.parent, container); @@ -15835,7 +16227,7 @@ var ts; } function captureLexicalThis(node, container) { getNodeLinks(node).flags |= 2; - if (container.kind === 139 || container.kind === 142) { + if (container.kind === 141 || container.kind === 144) { var classNode = container.parent; getNodeLinks(classNode).flags |= 4; } @@ -15846,29 +16238,29 @@ var ts; function checkThisExpression(node) { var container = ts.getThisContainer(node, true); var needToCaptureLexicalThis = false; - if (container.kind === 172) { + if (container.kind === 174) { container = ts.getThisContainer(container, false); needToCaptureLexicalThis = (languageVersion < 2); } switch (container.kind) { - case 216: + case 218: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_module_or_namespace_body); break; - case 215: + case 217: error(node, ts.Diagnostics.this_cannot_be_referenced_in_current_location); break; - case 142: + case 144: if (isInConstructorArgumentInitializer(node, container)) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_constructor_arguments); } break; - case 139: - case 138: + case 141: + case 140: if (container.flags & 128) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_static_property_initializer); } break; - case 134: + case 136: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_computed_property_name); break; } @@ -15877,27 +16269,27 @@ var ts; } if (ts.isClassLike(container.parent)) { var symbol = getSymbolOfNode(container.parent); - return container.flags & 128 ? getTypeOfSymbol(symbol) : getDeclaredTypeOfSymbol(symbol); + return container.flags & 128 ? getTypeOfSymbol(symbol) : getDeclaredTypeOfSymbol(symbol).thisType; } return anyType; } function isInConstructorArgumentInitializer(node, constructorDecl) { for (var n = node; n && n !== constructorDecl; n = n.parent) { - if (n.kind === 136) { + if (n.kind === 138) { return true; } } return false; } function checkSuperExpression(node) { - var isCallExpression = node.parent.kind === 166 && node.parent.expression === node; + var isCallExpression = node.parent.kind === 168 && node.parent.expression === node; var classDeclaration = ts.getContainingClass(node); var classType = classDeclaration && getDeclaredTypeOfSymbol(getSymbolOfNode(classDeclaration)); var baseClassType = classType && getBaseTypes(classType)[0]; var container = ts.getSuperContainer(node, true); var needToCaptureLexicalThis = false; if (!isCallExpression) { - while (container && container.kind === 172) { + while (container && container.kind === 174) { container = ts.getSuperContainer(container, true); needToCaptureLexicalThis = languageVersion < 2; } @@ -15923,7 +16315,7 @@ var ts; return unknownType; } if (!canUseSuperExpression) { - if (container && container.kind === 134) { + if (container && container.kind === 136) { error(node, ts.Diagnostics.super_cannot_be_referenced_in_a_computed_property_name); } else if (isCallExpression) { @@ -15934,7 +16326,7 @@ var ts; } return unknownType; } - if (container.kind === 142 && isInConstructorArgumentInitializer(node, container)) { + if (container.kind === 144 && isInConstructorArgumentInitializer(node, container)) { error(node, ts.Diagnostics.super_cannot_be_referenced_in_constructor_arguments); return unknownType; } @@ -15946,24 +16338,24 @@ var ts; return false; } if (isCallExpression) { - return container.kind === 142; + return container.kind === 144; } else { if (container && ts.isClassLike(container.parent)) { if (container.flags & 128) { - return container.kind === 141 || - container.kind === 140 || - container.kind === 143 || - container.kind === 144; + return container.kind === 143 || + container.kind === 142 || + container.kind === 145 || + container.kind === 146; } else { - return container.kind === 141 || + return container.kind === 143 || + container.kind === 142 || + container.kind === 145 || + container.kind === 146 || + container.kind === 141 || container.kind === 140 || - container.kind === 143 || - container.kind === 144 || - container.kind === 139 || - container.kind === 138 || - container.kind === 142; + container.kind === 144; } } } @@ -15997,7 +16389,7 @@ var ts; if (declaration.type) { return getTypeFromTypeNode(declaration.type); } - if (declaration.kind === 136) { + if (declaration.kind === 138) { var type = getContextuallyTypedParameterType(declaration); if (type) { return type; @@ -16030,7 +16422,7 @@ var ts; } function isInParameterInitializerBeforeContainingFunction(node) { while (node.parent && !ts.isFunctionLike(node.parent)) { - if (node.parent.kind === 136 && node.parent.initializer === node) { + if (node.parent.kind === 138 && node.parent.initializer === node) { return true; } node = node.parent; @@ -16039,8 +16431,8 @@ var ts; } function getContextualReturnType(functionDecl) { if (functionDecl.type || - functionDecl.kind === 142 || - functionDecl.kind === 143 && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(functionDecl.symbol, 144))) { + functionDecl.kind === 144 || + functionDecl.kind === 145 && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(functionDecl.symbol, 146))) { return getReturnTypeOfSignature(getSignatureFromDeclaration(functionDecl)); } var signature = getContextualSignatureForFunctionLikeDeclaration(functionDecl); @@ -16059,7 +16451,7 @@ var ts; return undefined; } function getContextualTypeForSubstitutionExpression(template, substitutionExpression) { - if (template.parent.kind === 168) { + if (template.parent.kind === 170) { return getContextualTypeForArgument(template.parent, substitutionExpression); } return undefined; @@ -16067,12 +16459,12 @@ var ts; function getContextualTypeForBinaryOperand(node) { var binaryExpression = node.parent; var operator = binaryExpression.operatorToken.kind; - if (operator >= 55 && operator <= 66) { + if (operator >= 56 && operator <= 68) { if (node === binaryExpression.right) { return checkExpression(binaryExpression.left); } } - else if (operator === 51) { + else if (operator === 52) { var type = getContextualType(binaryExpression); if (!type && node === binaryExpression.right) { type = checkExpression(binaryExpression.left); @@ -16159,7 +16551,7 @@ var ts; return node === conditional.whenTrue || node === conditional.whenFalse ? getContextualType(conditional) : undefined; } function getContextualTypeForJsxExpression(expr) { - if (expr.parent.kind === 236) { + if (expr.parent.kind === 238) { var attrib = expr.parent; var attrsType = getJsxElementAttributesType(attrib.parent); if (!attrsType || isTypeAny(attrsType)) { @@ -16169,7 +16561,7 @@ var ts; return getTypeOfPropertyOfType(attrsType, attrib.name.text); } } - if (expr.kind === 237) { + if (expr.kind === 239) { return getJsxElementAttributesType(expr.parent); } return undefined; @@ -16187,38 +16579,38 @@ var ts; } var parent = node.parent; switch (parent.kind) { - case 209: - case 136: - case 139: + case 211: case 138: - case 161: + case 141: + case 140: + case 163: return getContextualTypeForInitializerExpression(node); - case 172: - case 202: + case 174: + case 204: return getContextualTypeForReturnExpression(node); - case 182: + case 184: return getContextualTypeForYieldOperand(parent); - case 166: - case 167: - return getContextualTypeForArgument(parent, node); + case 168: case 169: - case 187: + return getContextualTypeForArgument(parent, node); + case 171: + case 189: return getTypeFromTypeNode(parent.type); - case 179: + case 181: return getContextualTypeForBinaryOperand(node); - case 243: + case 245: return getContextualTypeForObjectLiteralElement(parent); - case 162: + case 164: return getContextualTypeForElementExpression(node); - case 180: + case 182: return getContextualTypeForConditionalOperand(node); - case 188: - ts.Debug.assert(parent.parent.kind === 181); + case 190: + ts.Debug.assert(parent.parent.kind === 183); return getContextualTypeForSubstitutionExpression(parent.parent, node); - case 170: + case 172: return getContextualType(parent); - case 238: - case 237: + case 240: + case 239: return getContextualTypeForJsxExpression(parent); } return undefined; @@ -16233,7 +16625,7 @@ var ts; } } function isFunctionExpressionOrArrowFunction(node) { - return node.kind === 171 || node.kind === 172; + return node.kind === 173 || node.kind === 174; } function getContextualSignatureForFunctionLikeDeclaration(node) { return isFunctionExpressionOrArrowFunction(node) || ts.isObjectLiteralMethod(node) @@ -16241,7 +16633,7 @@ var ts; : undefined; } function getContextualSignature(node) { - ts.Debug.assert(node.kind !== 141 || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 143 || ts.isObjectLiteralMethod(node)); var type = ts.isObjectLiteralMethod(node) ? getContextualTypeForObjectLiteralMethod(node) : getContextualType(node); @@ -16281,13 +16673,13 @@ var ts; } function isAssignmentTarget(node) { var parent = node.parent; - if (parent.kind === 179 && parent.operatorToken.kind === 55 && parent.left === node) { + if (parent.kind === 181 && parent.operatorToken.kind === 56 && parent.left === node) { return true; } - if (parent.kind === 243) { + if (parent.kind === 245) { return isAssignmentTarget(parent.parent); } - if (parent.kind === 162) { + if (parent.kind === 164) { return isAssignmentTarget(parent); } return false; @@ -16297,8 +16689,8 @@ var ts; return checkIteratedTypeOrElementType(arrayOrIterableType, node.expression, false); } function hasDefaultValue(node) { - return (node.kind === 161 && !!node.initializer) || - (node.kind === 179 && node.operatorToken.kind === 55); + return (node.kind === 163 && !!node.initializer) || + (node.kind === 181 && node.operatorToken.kind === 56); } function checkArrayLiteral(node, contextualMapper) { var elements = node.elements; @@ -16307,7 +16699,7 @@ var ts; var inDestructuringPattern = isAssignmentTarget(node); for (var _i = 0; _i < elements.length; _i++) { var e = elements[_i]; - if (inDestructuringPattern && e.kind === 183) { + if (inDestructuringPattern && e.kind === 185) { var restArrayType = checkExpression(e.expression, contextualMapper); var restElementType = getIndexTypeOfType(restArrayType, 1) || (languageVersion >= 2 ? getElementTypeOfIterable(restArrayType, undefined) : undefined); @@ -16319,7 +16711,7 @@ var ts; var type = checkExpression(e, contextualMapper); elementTypes.push(type); } - hasSpreadElement = hasSpreadElement || e.kind === 183; + hasSpreadElement = hasSpreadElement || e.kind === 185; } if (!hasSpreadElement) { if (inDestructuringPattern && elementTypes.length) { @@ -16330,7 +16722,7 @@ var ts; var contextualType = getContextualType(node); if (contextualType && contextualTypeIsTupleLikeType(contextualType)) { var pattern = contextualType.pattern; - if (pattern && (pattern.kind === 160 || pattern.kind === 162)) { + if (pattern && (pattern.kind === 162 || pattern.kind === 164)) { var patternElements = pattern.elements; for (var i = elementTypes.length; i < patternElements.length; i++) { var patternElement = patternElements[i]; @@ -16338,7 +16730,7 @@ var ts; elementTypes.push(contextualType.elementTypes[i]); } else { - if (patternElement.kind !== 185) { + if (patternElement.kind !== 187) { error(patternElement, ts.Diagnostics.Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value); } elementTypes.push(unknownType); @@ -16353,7 +16745,7 @@ var ts; return createArrayType(elementTypes.length ? getUnionType(elementTypes) : undefinedType); } function isNumericName(name) { - return name.kind === 134 ? isNumericComputedName(name) : isNumericLiteralName(name.text); + return name.kind === 136 ? isNumericComputedName(name) : isNumericLiteralName(name.text); } function isNumericComputedName(name) { return isTypeAnyOrAllConstituentTypesHaveKind(checkComputedPropertyName(name), 132); @@ -16378,35 +16770,37 @@ var ts; return links.resolvedType; } function checkObjectLiteral(node, contextualMapper) { - checkGrammarObjectLiteralExpression(node); + var inDestructuringPattern = isAssignmentTarget(node); + checkGrammarObjectLiteralExpression(node, inDestructuringPattern); var propertiesTable = {}; var propertiesArray = []; var contextualType = getContextualType(node); var contextualTypeHasPattern = contextualType && contextualType.pattern && - (contextualType.pattern.kind === 159 || contextualType.pattern.kind === 163); - var inDestructuringPattern = isAssignmentTarget(node); + (contextualType.pattern.kind === 161 || contextualType.pattern.kind === 165); var typeFlags = 0; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var memberDecl = _a[_i]; var member = memberDecl.symbol; - if (memberDecl.kind === 243 || - memberDecl.kind === 244 || + if (memberDecl.kind === 245 || + memberDecl.kind === 246 || ts.isObjectLiteralMethod(memberDecl)) { var type = void 0; - if (memberDecl.kind === 243) { + if (memberDecl.kind === 245) { type = checkPropertyAssignment(memberDecl, contextualMapper); } - else if (memberDecl.kind === 141) { + else if (memberDecl.kind === 143) { type = checkObjectLiteralMethod(memberDecl, contextualMapper); } else { - ts.Debug.assert(memberDecl.kind === 244); + ts.Debug.assert(memberDecl.kind === 246); type = checkExpression(memberDecl.name, contextualMapper); } typeFlags |= type.flags; var prop = createSymbol(4 | 67108864 | member.flags, member.name); if (inDestructuringPattern) { - if (memberDecl.kind === 243 && hasDefaultValue(memberDecl.initializer)) { + var isOptional = (memberDecl.kind === 245 && hasDefaultValue(memberDecl.initializer)) || + (memberDecl.kind === 246 && memberDecl.objectAssignmentInitializer); + if (isOptional) { prop.flags |= 536870912; } } @@ -16429,7 +16823,7 @@ var ts; member = prop; } else { - ts.Debug.assert(memberDecl.kind === 143 || memberDecl.kind === 144); + ts.Debug.assert(memberDecl.kind === 145 || memberDecl.kind === 146); checkAccessorDeclaration(memberDecl); } if (!ts.hasDynamicName(memberDecl)) { @@ -16485,7 +16879,7 @@ var ts; if (lhs.kind !== rhs.kind) { return false; } - if (lhs.kind === 67) { + if (lhs.kind === 69) { return lhs.text === rhs.text; } return lhs.right.text === rhs.right.text && @@ -16502,17 +16896,17 @@ var ts; for (var _i = 0, _a = node.children; _i < _a.length; _i++) { var child = _a[_i]; switch (child.kind) { - case 238: + case 240: checkJsxExpression(child); break; - case 231: + case 233: checkJsxElement(child); break; - case 232: + case 234: checkJsxSelfClosingElement(child); break; default: - ts.Debug.assert(child.kind === 234); + ts.Debug.assert(child.kind === 236); } } return jsxElementType || anyType; @@ -16521,7 +16915,7 @@ var ts; return name.indexOf("-") < 0; } function isJsxIntrinsicIdentifier(tagName) { - if (tagName.kind === 133) { + if (tagName.kind === 135) { return false; } else { @@ -16622,12 +17016,14 @@ var ts; var valueSymbol = resolveJsxTagName(node); if (valueSymbol && valueSymbol !== unknownSymbol) { links.jsxFlags |= 4; - getSymbolLinks(valueSymbol).referenced = true; + if (valueSymbol.flags & 8388608) { + markAliasSymbolAsReferenced(valueSymbol); + } } return valueSymbol || unknownSymbol; } function resolveJsxTagName(node) { - if (node.tagName.kind === 67) { + if (node.tagName.kind === 69) { var tag = node.tagName; var sym = getResolvedSymbol(tag); return sym.exportSymbol || sym; @@ -16767,11 +17163,11 @@ var ts; var nameTable = {}; var sawSpreadedAny = false; for (var i = node.attributes.length - 1; i >= 0; i--) { - if (node.attributes[i].kind === 236) { + if (node.attributes[i].kind === 238) { checkJsxAttribute((node.attributes[i]), targetAttributesType, nameTable); } else { - ts.Debug.assert(node.attributes[i].kind === 237); + ts.Debug.assert(node.attributes[i].kind === 239); var spreadType = checkJsxSpreadAttribute((node.attributes[i]), targetAttributesType, nameTable); if (isTypeAny(spreadType)) { sawSpreadedAny = true; @@ -16797,7 +17193,7 @@ var ts; } } function getDeclarationKindFromSymbol(s) { - return s.valueDeclaration ? s.valueDeclaration.kind : 139; + return s.valueDeclaration ? s.valueDeclaration.kind : 141; } function getDeclarationFlagsFromSymbol(s) { return s.valueDeclaration ? ts.getCombinedNodeFlags(s.valueDeclaration) : s.flags & 134217728 ? 16 | 128 : 0; @@ -16805,11 +17201,11 @@ var ts; function checkClassPropertyAccess(node, left, type, prop) { var flags = getDeclarationFlagsFromSymbol(prop); var declaringClass = getDeclaredTypeOfSymbol(prop.parent); - if (left.kind === 93) { - var errorNode = node.kind === 164 ? + if (left.kind === 95) { + var errorNode = node.kind === 166 ? node.name : node.right; - if (getDeclarationKindFromSymbol(prop) !== 141) { + if (getDeclarationKindFromSymbol(prop) !== 143) { error(errorNode, ts.Diagnostics.Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword); return false; } @@ -16830,7 +17226,7 @@ var ts; } return true; } - if (left.kind === 93) { + if (left.kind === 95) { return true; } if (!enclosingClass || !hasBaseType(enclosingClass, declaringClass)) { @@ -16840,6 +17236,9 @@ var ts; if (flags & 128) { return true; } + if (type.flags & 33554432) { + type = getConstraintOfTypeParameter(type); + } if (!(getTargetType(type).flags & (1024 | 2048) && hasBaseType(type, enclosingClass))) { error(node, ts.Diagnostics.Property_0_is_protected_and_only_accessible_through_an_instance_of_class_1, symbolToString(prop), typeToString(enclosingClass)); return false; @@ -16864,18 +17263,18 @@ var ts; var prop = getPropertyOfType(apparentType, right.text); if (!prop) { if (right.text) { - error(right, ts.Diagnostics.Property_0_does_not_exist_on_type_1, ts.declarationNameToString(right), typeToString(type)); + error(right, ts.Diagnostics.Property_0_does_not_exist_on_type_1, ts.declarationNameToString(right), typeToString(type.flags & 33554432 ? apparentType : type)); } return unknownType; } getNodeLinks(node).resolvedSymbol = prop; if (prop.parent && prop.parent.flags & 32) { - checkClassPropertyAccess(node, left, type, prop); + checkClassPropertyAccess(node, left, apparentType, prop); } return getTypeOfSymbol(prop); } function isValidPropertyAccess(node, propertyName) { - var left = node.kind === 164 + var left = node.kind === 166 ? node.expression : node.left; var type = checkExpression(left); @@ -16890,7 +17289,7 @@ var ts; function checkIndexedAccess(node) { if (!node.argumentExpression) { var sourceFile = getSourceFile(node); - if (node.parent.kind === 167 && node.parent.expression === node) { + if (node.parent.kind === 169 && node.parent.expression === node) { var start = ts.skipTrivia(sourceFile.text, node.expression.end); var end = node.end; grammarErrorAtPos(sourceFile, start, end - start, ts.Diagnostics.new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead); @@ -16949,6 +17348,12 @@ var ts; if (indexArgumentExpression.kind === 9 || indexArgumentExpression.kind === 8) { return indexArgumentExpression.text; } + if (indexArgumentExpression.kind === 167 || indexArgumentExpression.kind === 166) { + var value = getConstantValue(indexArgumentExpression); + if (value !== undefined) { + return value.toString(); + } + } if (checkThatExpressionIsProperSymbolReference(indexArgumentExpression, indexArgumentType, false)) { var rightHandSideName = indexArgumentExpression.name.text; return ts.getPropertyNameForKnownSymbolName(rightHandSideName); @@ -16986,10 +17391,10 @@ var ts; return true; } function resolveUntypedCall(node) { - if (node.kind === 168) { + if (node.kind === 170) { checkExpression(node.template); } - else if (node.kind !== 137) { + else if (node.kind !== 139) { ts.forEach(node.arguments, function (argument) { checkExpression(argument); }); @@ -17040,7 +17445,7 @@ var ts; function getSpreadArgumentIndex(args) { for (var i = 0; i < args.length; i++) { var arg = args[i]; - if (arg && arg.kind === 183) { + if (arg && arg.kind === 185) { return i; } } @@ -17052,11 +17457,11 @@ var ts; var callIsIncomplete; var isDecorator; var spreadArgIndex = -1; - if (node.kind === 168) { + if (node.kind === 170) { var tagExpression = node; adjustedArgCount = args.length; typeArguments = undefined; - if (tagExpression.template.kind === 181) { + if (tagExpression.template.kind === 183) { var templateExpression = tagExpression.template; var lastSpan = ts.lastOrUndefined(templateExpression.templateSpans); ts.Debug.assert(lastSpan !== undefined); @@ -17068,7 +17473,7 @@ var ts; callIsIncomplete = !!templateLiteral.isUnterminated; } } - else if (node.kind === 137) { + else if (node.kind === 139) { isDecorator = true; typeArguments = undefined; adjustedArgCount = getEffectiveArgumentCount(node, undefined, signature); @@ -17076,7 +17481,7 @@ var ts; else { var callExpression = node; if (!callExpression.arguments) { - ts.Debug.assert(callExpression.kind === 167); + ts.Debug.assert(callExpression.kind === 169); return signature.minArgumentCount === 0; } adjustedArgCount = callExpression.arguments.hasTrailingComma ? args.length + 1 : args.length; @@ -17129,7 +17534,7 @@ var ts; var argCount = getEffectiveArgumentCount(node, args, signature); for (var i = 0; i < argCount; i++) { var arg = getEffectiveArgument(node, args, i); - if (arg === undefined || arg.kind !== 185) { + if (arg === undefined || arg.kind !== 187) { var paramType = getTypeAtPosition(signature, i); var argType = getEffectiveArgumentType(node, i, arg); if (argType === undefined) { @@ -17176,7 +17581,7 @@ var ts; var argCount = getEffectiveArgumentCount(node, args, signature); for (var i = 0; i < argCount; i++) { var arg = getEffectiveArgument(node, args, i); - if (arg === undefined || arg.kind !== 185) { + if (arg === undefined || arg.kind !== 187) { var paramType = getTypeAtPosition(signature, i); var argType = getEffectiveArgumentType(node, i, arg); if (argType === undefined) { @@ -17195,16 +17600,16 @@ var ts; } function getEffectiveCallArguments(node) { var args; - if (node.kind === 168) { + if (node.kind === 170) { var template = node.template; args = [undefined]; - if (template.kind === 181) { + if (template.kind === 183) { ts.forEach(template.templateSpans, function (span) { args.push(span.expression); }); } } - else if (node.kind === 137) { + else if (node.kind === 139) { return undefined; } else { @@ -17213,18 +17618,21 @@ var ts; return args; } function getEffectiveArgumentCount(node, args, signature) { - if (node.kind === 137) { + if (node.kind === 139) { switch (node.parent.kind) { - case 212: - case 184: + case 214: + case 186: return 1; - case 139: - return 2; case 141: + return 2; case 143: - case 144: + case 145: + case 146: + if (languageVersion === 0) { + return 2; + } return signature.parameters.length >= 3 ? 3 : 2; - case 136: + case 138: return 3; } } @@ -17234,20 +17642,20 @@ var ts; } function getEffectiveDecoratorFirstArgumentType(node) { switch (node.kind) { - case 212: - case 184: + case 214: + case 186: var classSymbol = getSymbolOfNode(node); return getTypeOfSymbol(classSymbol); - case 136: + case 138: node = node.parent; - if (node.kind === 142) { + if (node.kind === 144) { var classSymbol_1 = getSymbolOfNode(node); return getTypeOfSymbol(classSymbol_1); } - case 139: case 141: case 143: - case 144: + case 145: + case 146: return getParentTypeOfClassElement(node); default: ts.Debug.fail("Unsupported decorator target."); @@ -17256,25 +17664,25 @@ var ts; } function getEffectiveDecoratorSecondArgumentType(node) { switch (node.kind) { - case 212: + case 214: ts.Debug.fail("Class decorators should not have a second synthetic argument."); return unknownType; - case 136: + case 138: node = node.parent; - if (node.kind === 142) { + if (node.kind === 144) { return anyType; } - case 139: case 141: case 143: - case 144: + case 145: + case 146: var element = node; switch (element.name.kind) { - case 67: + case 69: case 8: case 9: return getStringLiteralType(element.name); - case 134: + case 136: var nameType = checkComputedPropertyName(element.name); if (allConstituentTypesHaveKind(nameType, 16777216)) { return nameType; @@ -17293,17 +17701,17 @@ var ts; } function getEffectiveDecoratorThirdArgumentType(node) { switch (node.kind) { - case 212: + case 214: ts.Debug.fail("Class decorators should not have a third synthetic argument."); return unknownType; - case 136: + case 138: return numberType; - case 139: + case 141: ts.Debug.fail("Property decorators should not have a third synthetic argument."); return unknownType; - case 141: case 143: - case 144: + case 145: + case 146: var propertyType = getTypeOfNode(node); return createTypedPropertyDescriptorType(propertyType); default: @@ -17325,26 +17733,26 @@ var ts; return unknownType; } function getEffectiveArgumentType(node, argIndex, arg) { - if (node.kind === 137) { + if (node.kind === 139) { return getEffectiveDecoratorArgumentType(node, argIndex); } - else if (argIndex === 0 && node.kind === 168) { + else if (argIndex === 0 && node.kind === 170) { return globalTemplateStringsArrayType; } return undefined; } function getEffectiveArgument(node, args, argIndex) { - if (node.kind === 137 || - (argIndex === 0 && node.kind === 168)) { + if (node.kind === 139 || + (argIndex === 0 && node.kind === 170)) { return undefined; } return args[argIndex]; } function getEffectiveArgumentErrorNode(node, argIndex, arg) { - if (node.kind === 137) { + if (node.kind === 139) { return node.expression; } - else if (argIndex === 0 && node.kind === 168) { + else if (argIndex === 0 && node.kind === 170) { return node.template; } else { @@ -17352,12 +17760,12 @@ var ts; } } function resolveCall(node, signatures, candidatesOutArray, headMessage) { - var isTaggedTemplate = node.kind === 168; - var isDecorator = node.kind === 137; + var isTaggedTemplate = node.kind === 170; + var isDecorator = node.kind === 139; var typeArguments; if (!isTaggedTemplate && !isDecorator) { typeArguments = node.typeArguments; - if (node.expression.kind !== 93) { + if (node.expression.kind !== 95) { ts.forEach(typeArguments, checkSourceElement); } } @@ -17495,7 +17903,7 @@ var ts; } } function resolveCallExpression(node, candidatesOutArray) { - if (node.expression.kind === 93) { + if (node.expression.kind === 95) { var superType = checkSuperExpression(node.expression); if (superType !== unknownType) { var baseTypeNode = ts.getClassExtendsHeritageClauseElement(ts.getContainingClass(node)); @@ -17584,16 +17992,16 @@ var ts; } function getDiagnosticHeadMessageForDecoratorResolution(node) { switch (node.parent.kind) { - case 212: - case 184: + case 214: + case 186: return ts.Diagnostics.Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression; - case 136: + case 138: return ts.Diagnostics.Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression; - case 139: - return ts.Diagnostics.Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression; case 141: + return ts.Diagnostics.Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression; case 143: - case 144: + case 145: + case 146: return ts.Diagnostics.Unable_to_resolve_signature_of_method_decorator_when_called_as_an_expression; } } @@ -17621,16 +18029,16 @@ var ts; var links = getNodeLinks(node); if (!links.resolvedSignature || candidatesOutArray) { links.resolvedSignature = anySignature; - if (node.kind === 166) { + if (node.kind === 168) { links.resolvedSignature = resolveCallExpression(node, candidatesOutArray); } - else if (node.kind === 167) { + else if (node.kind === 169) { links.resolvedSignature = resolveNewExpression(node, candidatesOutArray); } - else if (node.kind === 168) { + else if (node.kind === 170) { links.resolvedSignature = resolveTaggedTemplateExpression(node, candidatesOutArray); } - else if (node.kind === 137) { + else if (node.kind === 139) { links.resolvedSignature = resolveDecorator(node, candidatesOutArray); } else { @@ -17642,21 +18050,24 @@ var ts; function checkCallExpression(node) { checkGrammarTypeArguments(node, node.typeArguments) || checkGrammarArguments(node, node.arguments); var signature = getResolvedSignature(node); - if (node.expression.kind === 93) { + if (node.expression.kind === 95) { return voidType; } - if (node.kind === 167) { + if (node.kind === 169) { var declaration = signature.declaration; if (declaration && - declaration.kind !== 142 && - declaration.kind !== 146 && - declaration.kind !== 151) { + declaration.kind !== 144 && + declaration.kind !== 148 && + declaration.kind !== 153) { if (compilerOptions.noImplicitAny) { error(node, ts.Diagnostics.new_expression_whose_target_lacks_a_construct_signature_implicitly_has_an_any_type); } return anyType; } } + if (ts.isInJavaScriptFile(node) && ts.isRequireCall(node)) { + return resolveExternalModuleTypeByLiteral(node.arguments[0]); + } return getReturnTypeOfSignature(signature); } function checkTaggedTemplateExpression(node) { @@ -17691,10 +18102,22 @@ var ts; assignTypeToParameterAndFixTypeParameters(parameter, contextualParameterType, mapper); } } + function assignBindingElementTypes(node) { + if (ts.isBindingPattern(node.name)) { + for (var _i = 0, _a = node.name.elements; _i < _a.length; _i++) { + var element = _a[_i]; + if (element.kind !== 187) { + getSymbolLinks(getSymbolOfNode(element)).type = getTypeForBindingElement(element); + assignBindingElementTypes(element); + } + } + } + } function assignTypeToParameterAndFixTypeParameters(parameter, contextualType, mapper) { var links = getSymbolLinks(parameter); if (!links.type) { links.type = instantiateType(contextualType, mapper); + assignBindingElementTypes(parameter.valueDeclaration); } else if (isInferentialContext(mapper)) { inferTypes(mapper.context, links.type, instantiateType(contextualType, mapper)); @@ -17715,7 +18138,7 @@ var ts; } var isAsync = ts.isAsyncFunctionLike(func); var type; - if (func.body.kind !== 190) { + if (func.body.kind !== 192) { type = checkExpressionCached(func.body, contextualMapper); if (isAsync) { type = checkAwaitedType(type, func, ts.Diagnostics.Return_expression_in_async_function_does_not_have_a_valid_callable_then_member); @@ -17819,7 +18242,7 @@ var ts; }); } function bodyContainsSingleThrowStatement(body) { - return (body.statements.length === 1) && (body.statements[0].kind === 206); + return (body.statements.length === 1) && (body.statements[0].kind === 208); } function checkIfNonVoidFunctionHasReturnExpressionsOrSingleThrowStatment(func, returnType) { if (!produceDiagnostics) { @@ -17828,7 +18251,7 @@ var ts; if (returnType === voidType || isTypeAny(returnType)) { return; } - if (ts.nodeIsMissing(func.body) || func.body.kind !== 190) { + if (ts.nodeIsMissing(func.body) || func.body.kind !== 192) { return; } var bodyBlock = func.body; @@ -17841,9 +18264,9 @@ var ts; error(func.type, ts.Diagnostics.A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value_or_consist_of_a_single_throw_statement); } function checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper) { - ts.Debug.assert(node.kind !== 141 || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 143 || ts.isObjectLiteralMethod(node)); var hasGrammarError = checkGrammarFunctionLikeDeclaration(node); - if (!hasGrammarError && node.kind === 171) { + if (!hasGrammarError && node.kind === 173) { checkGrammarForGenerator(node); } if (contextualMapper === identityMapper && isContextSensitive(node)) { @@ -17879,14 +18302,14 @@ var ts; } } } - if (produceDiagnostics && node.kind !== 141 && node.kind !== 140) { + if (produceDiagnostics && node.kind !== 143 && node.kind !== 142) { checkCollisionWithCapturedSuperVariable(node, node.name); checkCollisionWithCapturedThisVariable(node, node.name); } return type; } function checkFunctionExpressionOrObjectLiteralMethodBody(node) { - ts.Debug.assert(node.kind !== 141 || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 143 || ts.isObjectLiteralMethod(node)); var isAsync = ts.isAsyncFunctionLike(node); if (isAsync) { emitAwaiter = true; @@ -17903,7 +18326,7 @@ var ts; if (!node.type) { getReturnTypeOfSignature(getSignatureFromDeclaration(node)); } - if (node.body.kind === 190) { + if (node.body.kind === 192) { checkSourceElement(node.body); } else { @@ -17935,17 +18358,17 @@ var ts; } function isReferenceOrErrorExpression(n) { switch (n.kind) { - case 67: { + case 69: { var symbol = findSymbol(n); return !symbol || symbol === unknownSymbol || symbol === argumentsSymbol || (symbol.flags & 3) !== 0; } - case 164: { + case 166: { var symbol = findSymbol(n); return !symbol || symbol === unknownSymbol || (symbol.flags & ~8) !== 0; } - case 165: + case 167: return true; - case 170: + case 172: return isReferenceOrErrorExpression(n.expression); default: return false; @@ -17953,12 +18376,12 @@ var ts; } function isConstVariableReference(n) { switch (n.kind) { - case 67: - case 164: { + case 69: + case 166: { var symbol = findSymbol(n); return symbol && (symbol.flags & 3) !== 0 && (getDeclarationFlagsFromSymbol(symbol) & 32768) !== 0; } - case 165: { + case 167: { var index = n.argumentExpression; var symbol = findSymbol(n.expression); if (symbol && index && index.kind === 9) { @@ -17968,7 +18391,7 @@ var ts; } return false; } - case 170: + case 172: return isConstVariableReference(n.expression); default: return false; @@ -18013,15 +18436,15 @@ var ts; switch (node.operator) { case 35: case 36: - case 49: + case 50: if (someConstituentTypeHasKind(operandType, 16777216)) { error(node.operand, ts.Diagnostics.The_0_operator_cannot_be_applied_to_type_symbol, ts.tokenToString(node.operator)); } return numberType; - case 48: + case 49: return booleanType; - case 40: case 41: + case 42: var ok = checkArithmeticOperandType(node.operand, operandType, ts.Diagnostics.An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type); if (ok) { checkReferenceExpression(node.operand, ts.Diagnostics.The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_property_or_indexer, ts.Diagnostics.The_operand_of_an_increment_or_decrement_operator_cannot_be_a_constant); @@ -18076,21 +18499,21 @@ var ts; function isConstEnumSymbol(symbol) { return (symbol.flags & 128) !== 0; } - function checkInstanceOfExpression(node, leftType, rightType) { + function checkInstanceOfExpression(left, right, leftType, rightType) { if (allConstituentTypesHaveKind(leftType, 16777726)) { - error(node.left, ts.Diagnostics.The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_parameter); + error(left, ts.Diagnostics.The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_parameter); } if (!(isTypeAny(rightType) || isTypeSubtypeOf(rightType, globalFunctionType))) { - error(node.right, ts.Diagnostics.The_right_hand_side_of_an_instanceof_expression_must_be_of_type_any_or_of_a_type_assignable_to_the_Function_interface_type); + error(right, ts.Diagnostics.The_right_hand_side_of_an_instanceof_expression_must_be_of_type_any_or_of_a_type_assignable_to_the_Function_interface_type); } return booleanType; } - function checkInExpression(node, leftType, rightType) { + function checkInExpression(left, right, leftType, rightType) { if (!isTypeAnyOrAllConstituentTypesHaveKind(leftType, 258 | 132 | 16777216)) { - error(node.left, ts.Diagnostics.The_left_hand_side_of_an_in_expression_must_be_of_type_any_string_number_or_symbol); + error(left, ts.Diagnostics.The_left_hand_side_of_an_in_expression_must_be_of_type_any_string_number_or_symbol); } if (!isTypeAnyOrAllConstituentTypesHaveKind(rightType, 80896 | 512)) { - error(node.right, ts.Diagnostics.The_right_hand_side_of_an_in_expression_must_be_of_type_any_an_object_type_or_a_type_parameter); + error(right, ts.Diagnostics.The_right_hand_side_of_an_in_expression_must_be_of_type_any_an_object_type_or_a_type_parameter); } return booleanType; } @@ -18098,7 +18521,7 @@ var ts; var properties = node.properties; for (var _i = 0; _i < properties.length; _i++) { var p = properties[_i]; - if (p.kind === 243 || p.kind === 244) { + if (p.kind === 245 || p.kind === 246) { var name_14 = p.name; var type = isTypeAny(sourceType) ? sourceType @@ -18106,7 +18529,12 @@ var ts; isNumericLiteralName(name_14.text) && getIndexTypeOfType(sourceType, 1) || getIndexTypeOfType(sourceType, 0); if (type) { - checkDestructuringAssignment(p.initializer || name_14, type); + if (p.kind === 246) { + checkDestructuringAssignment(p, type); + } + else { + checkDestructuringAssignment(p.initializer || name_14, type); + } } else { error(name_14, ts.Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(sourceType), ts.declarationNameToString(name_14)); @@ -18123,8 +18551,8 @@ var ts; var elements = node.elements; for (var i = 0; i < elements.length; i++) { var e = elements[i]; - if (e.kind !== 185) { - if (e.kind !== 183) { + if (e.kind !== 187) { + if (e.kind !== 185) { var propName = "" + i; var type = isTypeAny(sourceType) ? sourceType @@ -18149,7 +18577,7 @@ var ts; } else { var restExpression = e.expression; - if (restExpression.kind === 179 && restExpression.operatorToken.kind === 55) { + if (restExpression.kind === 181 && restExpression.operatorToken.kind === 56) { error(restExpression.operatorToken, ts.Diagnostics.A_rest_element_cannot_have_an_initializer); } else { @@ -18161,15 +18589,26 @@ var ts; } return sourceType; } - function checkDestructuringAssignment(target, sourceType, contextualMapper) { - if (target.kind === 179 && target.operatorToken.kind === 55) { + function checkDestructuringAssignment(exprOrAssignment, sourceType, contextualMapper) { + var target; + if (exprOrAssignment.kind === 246) { + var prop = exprOrAssignment; + if (prop.objectAssignmentInitializer) { + checkBinaryLikeExpression(prop.name, prop.equalsToken, prop.objectAssignmentInitializer, contextualMapper); + } + target = exprOrAssignment.name; + } + else { + target = exprOrAssignment; + } + if (target.kind === 181 && target.operatorToken.kind === 56) { checkBinaryExpression(target, contextualMapper); target = target.left; } - if (target.kind === 163) { + if (target.kind === 165) { return checkObjectLiteralAssignment(target, sourceType, contextualMapper); } - if (target.kind === 162) { + if (target.kind === 164) { return checkArrayLiteralAssignment(target, sourceType, contextualMapper); } return checkReferenceAssignment(target, sourceType, contextualMapper); @@ -18182,33 +18621,38 @@ var ts; return sourceType; } function checkBinaryExpression(node, contextualMapper) { - var operator = node.operatorToken.kind; - if (operator === 55 && (node.left.kind === 163 || node.left.kind === 162)) { - return checkDestructuringAssignment(node.left, checkExpression(node.right, contextualMapper), contextualMapper); + return checkBinaryLikeExpression(node.left, node.operatorToken, node.right, contextualMapper, node); + } + function checkBinaryLikeExpression(left, operatorToken, right, contextualMapper, errorNode) { + var operator = operatorToken.kind; + if (operator === 56 && (left.kind === 165 || left.kind === 164)) { + return checkDestructuringAssignment(left, checkExpression(right, contextualMapper), contextualMapper); } - var leftType = checkExpression(node.left, contextualMapper); - var rightType = checkExpression(node.right, contextualMapper); + var leftType = checkExpression(left, contextualMapper); + var rightType = checkExpression(right, contextualMapper); switch (operator) { case 37: - case 58: case 38: case 59: - case 39: case 60: - case 36: - case 57: - case 42: + case 39: case 61: - case 43: + case 40: case 62: - case 44: + case 36: + case 58: + case 43: case 63: - case 46: + case 44: + case 64: + case 45: case 65: case 47: + case 67: + case 48: + case 68: + case 46: case 66: - case 45: - case 64: if (leftType.flags & (32 | 64)) leftType = rightType; if (rightType.flags & (32 | 64)) @@ -18216,19 +18660,19 @@ var ts; var suggestedOperator; if ((leftType.flags & 8) && (rightType.flags & 8) && - (suggestedOperator = getSuggestedBooleanOperator(node.operatorToken.kind)) !== undefined) { - error(node, ts.Diagnostics.The_0_operator_is_not_allowed_for_boolean_types_Consider_using_1_instead, ts.tokenToString(node.operatorToken.kind), ts.tokenToString(suggestedOperator)); + (suggestedOperator = getSuggestedBooleanOperator(operatorToken.kind)) !== undefined) { + error(errorNode || operatorToken, ts.Diagnostics.The_0_operator_is_not_allowed_for_boolean_types_Consider_using_1_instead, ts.tokenToString(operatorToken.kind), ts.tokenToString(suggestedOperator)); } else { - var leftOk = checkArithmeticOperandType(node.left, leftType, ts.Diagnostics.The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type); - var rightOk = checkArithmeticOperandType(node.right, rightType, ts.Diagnostics.The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type); + var leftOk = checkArithmeticOperandType(left, leftType, ts.Diagnostics.The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type); + var rightOk = checkArithmeticOperandType(right, rightType, ts.Diagnostics.The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type); if (leftOk && rightOk) { checkAssignmentOperator(numberType); } } return numberType; case 35: - case 56: + case 57: if (leftType.flags & (32 | 64)) leftType = rightType; if (rightType.flags & (32 | 64)) @@ -18252,7 +18696,7 @@ var ts; reportOperatorError(); return anyType; } - if (operator === 56) { + if (operator === 57) { checkAssignmentOperator(resultType); } return resultType; @@ -18271,23 +18715,23 @@ var ts; reportOperatorError(); } return booleanType; - case 89: - return checkInstanceOfExpression(node, leftType, rightType); - case 88: - return checkInExpression(node, leftType, rightType); - case 50: - return rightType; + case 91: + return checkInstanceOfExpression(left, right, leftType, rightType); + case 90: + return checkInExpression(left, right, leftType, rightType); case 51: + return rightType; + case 52: return getUnionType([leftType, rightType]); - case 55: + case 56: checkAssignmentOperator(rightType); return getRegularTypeOfObjectLiteral(rightType); case 24: return rightType; } function checkForDisallowedESSymbolOperand(operator) { - var offendingSymbolOperand = someConstituentTypeHasKind(leftType, 16777216) ? node.left : - someConstituentTypeHasKind(rightType, 16777216) ? node.right : + var offendingSymbolOperand = someConstituentTypeHasKind(leftType, 16777216) ? left : + someConstituentTypeHasKind(rightType, 16777216) ? right : undefined; if (offendingSymbolOperand) { error(offendingSymbolOperand, ts.Diagnostics.The_0_operator_cannot_be_applied_to_type_symbol, ts.tokenToString(operator)); @@ -18297,29 +18741,29 @@ var ts; } function getSuggestedBooleanOperator(operator) { switch (operator) { - case 46: - case 65: - return 51; case 47: - case 66: + case 67: + return 52; + case 48: + case 68: return 33; - case 45: - case 64: - return 50; + case 46: + case 66: + return 51; default: return undefined; } } function checkAssignmentOperator(valueType) { - if (produceDiagnostics && operator >= 55 && operator <= 66) { - var ok = checkReferenceExpression(node.left, ts.Diagnostics.Invalid_left_hand_side_of_assignment_expression, ts.Diagnostics.Left_hand_side_of_assignment_expression_cannot_be_a_constant); + if (produceDiagnostics && operator >= 56 && operator <= 68) { + var ok = checkReferenceExpression(left, ts.Diagnostics.Invalid_left_hand_side_of_assignment_expression, ts.Diagnostics.Left_hand_side_of_assignment_expression_cannot_be_a_constant); if (ok) { - checkTypeAssignableTo(valueType, leftType, node.left, undefined); + checkTypeAssignableTo(valueType, leftType, left, undefined); } } } function reportOperatorError() { - error(node, ts.Diagnostics.Operator_0_cannot_be_applied_to_types_1_and_2, ts.tokenToString(node.operatorToken.kind), typeToString(leftType), typeToString(rightType)); + error(errorNode || operatorToken, ts.Diagnostics.Operator_0_cannot_be_applied_to_types_1_and_2, ts.tokenToString(operatorToken.kind), typeToString(leftType), typeToString(rightType)); } } function isYieldExpressionInClass(node) { @@ -18395,14 +18839,14 @@ var ts; return links.resolvedType; } function checkPropertyAssignment(node, contextualMapper) { - if (node.name.kind === 134) { + if (node.name.kind === 136) { checkComputedPropertyName(node.name); } return checkExpression(node.initializer, contextualMapper); } function checkObjectLiteralMethod(node, contextualMapper) { checkGrammarMethod(node); - if (node.name.kind === 134) { + if (node.name.kind === 136) { checkComputedPropertyName(node.name); } var uninstantiatedType = checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); @@ -18425,7 +18869,7 @@ var ts; } function checkExpression(node, contextualMapper) { var type; - if (node.kind === 133) { + if (node.kind === 135) { type = checkQualifiedName(node); } else { @@ -18433,9 +18877,9 @@ var ts; type = instantiateTypeWithSingleGenericCallSignature(node, uninstantiatedType, contextualMapper); } if (isConstEnumObjectType(type)) { - var ok = (node.parent.kind === 164 && node.parent.expression === node) || - (node.parent.kind === 165 && node.parent.expression === node) || - ((node.kind === 67 || node.kind === 133) && isInRightSideOfImportOrExportAssignment(node)); + var ok = (node.parent.kind === 166 && node.parent.expression === node) || + (node.parent.kind === 167 && node.parent.expression === node) || + ((node.kind === 69 || node.kind === 135) && isInRightSideOfImportOrExportAssignment(node)); if (!ok) { error(node, ts.Diagnostics.const_enums_can_only_be_used_in_property_or_index_access_expressions_or_the_right_hand_side_of_an_import_declaration_or_export_assignment); } @@ -18448,78 +18892,78 @@ var ts; } function checkExpressionWorker(node, contextualMapper) { switch (node.kind) { - case 67: + case 69: return checkIdentifier(node); - case 95: - return checkThisExpression(node); - case 93: - return checkSuperExpression(node); - case 91: - return nullType; case 97: - case 82: + return checkThisExpression(node); + case 95: + return checkSuperExpression(node); + case 93: + return nullType; + case 99: + case 84: return booleanType; case 8: return checkNumericLiteral(node); - case 181: + case 183: return checkTemplateExpression(node); case 9: case 11: return stringType; case 10: return globalRegExpType; - case 162: - return checkArrayLiteral(node, contextualMapper); - case 163: - return checkObjectLiteral(node, contextualMapper); case 164: - return checkPropertyAccessExpression(node); + return checkArrayLiteral(node, contextualMapper); case 165: - return checkIndexedAccess(node); + return checkObjectLiteral(node, contextualMapper); case 166: + return checkPropertyAccessExpression(node); case 167: - return checkCallExpression(node); + return checkIndexedAccess(node); case 168: - return checkTaggedTemplateExpression(node); - case 170: - return checkExpression(node.expression, contextualMapper); - case 184: - return checkClassExpression(node); - case 171: - case 172: - return checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); - case 174: - return checkTypeOfExpression(node); case 169: - case 187: - return checkAssertion(node); + return checkCallExpression(node); + case 170: + return checkTaggedTemplateExpression(node); + case 172: + return checkExpression(node.expression, contextualMapper); + case 186: + return checkClassExpression(node); case 173: - return checkDeleteExpression(node); - case 175: - return checkVoidExpression(node); + case 174: + return checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); case 176: - return checkAwaitExpression(node); + return checkTypeOfExpression(node); + case 171: + case 189: + return checkAssertion(node); + case 175: + return checkDeleteExpression(node); case 177: - return checkPrefixUnaryExpression(node); + return checkVoidExpression(node); case 178: - return checkPostfixUnaryExpression(node); + return checkAwaitExpression(node); case 179: - return checkBinaryExpression(node, contextualMapper); + return checkPrefixUnaryExpression(node); case 180: - return checkConditionalExpression(node, contextualMapper); - case 183: - return checkSpreadElementExpression(node, contextualMapper); - case 185: - return undefinedType; + return checkPostfixUnaryExpression(node); + case 181: + return checkBinaryExpression(node, contextualMapper); case 182: + return checkConditionalExpression(node, contextualMapper); + case 185: + return checkSpreadElementExpression(node, contextualMapper); + case 187: + return undefinedType; + case 184: return checkYieldExpression(node); - case 238: + case 240: return checkJsxExpression(node); - case 231: - return checkJsxElement(node); - case 232: - return checkJsxSelfClosingElement(node); case 233: + return checkJsxElement(node); + case 234: + return checkJsxSelfClosingElement(node); + case 235: ts.Debug.fail("Shouldn't ever directly check a JsxOpeningElement"); } return unknownType; @@ -18540,7 +18984,7 @@ var ts; var func = ts.getContainingFunction(node); if (node.flags & 112) { func = ts.getContainingFunction(node); - if (!(func.kind === 142 && ts.nodeIsPresent(func.body))) { + if (!(func.kind === 144 && ts.nodeIsPresent(func.body))) { error(node, ts.Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation); } } @@ -18555,15 +18999,15 @@ var ts; if (!node.asteriskToken || !node.body) { return false; } - return node.kind === 141 || - node.kind === 211 || - node.kind === 171; + return node.kind === 143 || + node.kind === 213 || + node.kind === 173; } function getTypePredicateParameterIndex(parameterList, parameter) { if (parameterList) { for (var i = 0; i < parameterList.length; i++) { var param = parameterList[i]; - if (param.name.kind === 67 && + if (param.name.kind === 69 && param.name.text === parameter.text) { return i; } @@ -18573,30 +19017,30 @@ var ts; } function isInLegalTypePredicatePosition(node) { switch (node.parent.kind) { - case 172: - case 145: - case 211: - case 171: - case 150: - case 141: - case 140: + case 174: + case 147: + case 213: + case 173: + case 152: + case 143: + case 142: return node === node.parent.type; } return false; } function checkSignatureDeclaration(node) { - if (node.kind === 147) { + if (node.kind === 149) { checkGrammarIndexSignature(node); } - else if (node.kind === 150 || node.kind === 211 || node.kind === 151 || - node.kind === 145 || node.kind === 142 || - node.kind === 146) { + else if (node.kind === 152 || node.kind === 213 || node.kind === 153 || + node.kind === 147 || node.kind === 144 || + node.kind === 148) { checkGrammarFunctionLikeDeclaration(node); } checkTypeParameters(node.typeParameters); ts.forEach(node.parameters, checkParameter); if (node.type) { - if (node.type.kind === 148) { + if (node.type.kind === 150) { var typePredicate = getSignatureFromDeclaration(node).typePredicate; var typePredicateNode = node.type; if (isInLegalTypePredicatePosition(typePredicateNode)) { @@ -18615,19 +19059,19 @@ var ts; if (hasReportedError) { break; } - if (param.name.kind === 159 || - param.name.kind === 160) { + if (param.name.kind === 161 || + param.name.kind === 162) { (function checkBindingPattern(pattern) { for (var _i = 0, _a = pattern.elements; _i < _a.length; _i++) { var element = _a[_i]; - if (element.name.kind === 67 && + if (element.name.kind === 69 && element.name.text === typePredicate.parameterName) { error(typePredicateNode.parameterName, ts.Diagnostics.A_type_predicate_cannot_reference_element_0_in_a_binding_pattern, typePredicate.parameterName); hasReportedError = true; break; } - else if (element.name.kind === 160 || - element.name.kind === 159) { + else if (element.name.kind === 162 || + element.name.kind === 161) { checkBindingPattern(element.name); } } @@ -18651,10 +19095,10 @@ var ts; checkCollisionWithArgumentsInGeneratedCode(node); if (compilerOptions.noImplicitAny && !node.type) { switch (node.kind) { - case 146: + case 148: error(node, ts.Diagnostics.Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; - case 145: + case 147: error(node, ts.Diagnostics.Call_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; } @@ -18676,7 +19120,7 @@ var ts; checkSpecializedSignatureDeclaration(node); } function checkTypeForDuplicateIndexSignatures(node) { - if (node.kind === 213) { + if (node.kind === 215) { var nodeSymbol = getSymbolOfNode(node); if (nodeSymbol.declarations.length > 0 && nodeSymbol.declarations[0] !== node) { return; @@ -18691,7 +19135,7 @@ var ts; var declaration = decl; if (declaration.parameters.length === 1 && declaration.parameters[0].type) { switch (declaration.parameters[0].type.kind) { - case 128: + case 130: if (!seenStringIndexer) { seenStringIndexer = true; } @@ -18699,7 +19143,7 @@ var ts; error(declaration, ts.Diagnostics.Duplicate_string_index_signature); } break; - case 126: + case 128: if (!seenNumericIndexer) { seenNumericIndexer = true; } @@ -18739,7 +19183,7 @@ var ts; return; } function isSuperCallExpression(n) { - return n.kind === 166 && n.expression.kind === 93; + return n.kind === 168 && n.expression.kind === 95; } function containsSuperCallAsComputedPropertyName(n) { return n.name && containsSuperCall(n.name); @@ -18757,15 +19201,15 @@ var ts; return ts.forEachChild(n, containsSuperCall); } function markThisReferencesAsErrors(n) { - if (n.kind === 95) { + if (n.kind === 97) { error(n, ts.Diagnostics.this_cannot_be_referenced_in_current_location); } - else if (n.kind !== 171 && n.kind !== 211) { + else if (n.kind !== 173 && n.kind !== 213) { ts.forEachChild(n, markThisReferencesAsErrors); } } function isInstancePropertyWithInitializer(n) { - return n.kind === 139 && + return n.kind === 141 && !(n.flags & 128) && !!n.initializer; } @@ -18785,7 +19229,7 @@ var ts; var superCallStatement; for (var _i = 0; _i < statements.length; _i++) { var statement = statements[_i]; - if (statement.kind === 193 && isSuperCallExpression(statement.expression)) { + if (statement.kind === 195 && isSuperCallExpression(statement.expression)) { superCallStatement = statement; break; } @@ -18809,13 +19253,13 @@ var ts; function checkAccessorDeclaration(node) { if (produceDiagnostics) { checkGrammarFunctionLikeDeclaration(node) || checkGrammarAccessor(node) || checkGrammarComputedPropertyName(node.name); - if (node.kind === 143) { + if (node.kind === 145) { if (!ts.isInAmbientContext(node) && ts.nodeIsPresent(node.body) && !(bodyContainsAReturnStatement(node.body) || bodyContainsSingleThrowStatement(node.body))) { error(node.name, ts.Diagnostics.A_get_accessor_must_return_a_value_or_consist_of_a_single_throw_statement); } } if (!ts.hasDynamicName(node)) { - var otherKind = node.kind === 143 ? 144 : 143; + var otherKind = node.kind === 145 ? 146 : 145; var otherAccessor = ts.getDeclarationOfKind(node.symbol, otherKind); if (otherAccessor) { if (((node.flags & 112) !== (otherAccessor.flags & 112))) { @@ -18900,9 +19344,9 @@ var ts; return; } var signaturesToCheck; - if (!signatureDeclarationNode.name && signatureDeclarationNode.parent && signatureDeclarationNode.parent.kind === 213) { - ts.Debug.assert(signatureDeclarationNode.kind === 145 || signatureDeclarationNode.kind === 146); - var signatureKind = signatureDeclarationNode.kind === 145 ? 0 : 1; + if (!signatureDeclarationNode.name && signatureDeclarationNode.parent && signatureDeclarationNode.parent.kind === 215) { + ts.Debug.assert(signatureDeclarationNode.kind === 147 || signatureDeclarationNode.kind === 148); + var signatureKind = signatureDeclarationNode.kind === 147 ? 0 : 1; var containingSymbol = getSymbolOfNode(signatureDeclarationNode.parent); var containingType = getDeclaredTypeOfSymbol(containingSymbol); signaturesToCheck = getSignaturesOfType(containingType, signatureKind); @@ -18920,7 +19364,7 @@ var ts; } function getEffectiveDeclarationFlags(n, flagsToCheck) { var flags = ts.getCombinedNodeFlags(n); - if (n.parent.kind !== 213 && ts.isInAmbientContext(n)) { + if (n.parent.kind !== 215 && ts.isInAmbientContext(n)) { if (!(flags & 2)) { flags |= 1; } @@ -18996,7 +19440,7 @@ var ts; if (subsequentNode.kind === node.kind) { var errorNode_1 = subsequentNode.name || subsequentNode; if (node.name && subsequentNode.name && node.name.text === subsequentNode.name.text) { - ts.Debug.assert(node.kind === 141 || node.kind === 140); + ts.Debug.assert(node.kind === 143 || node.kind === 142); ts.Debug.assert((node.flags & 128) !== (subsequentNode.flags & 128)); var diagnostic = node.flags & 128 ? ts.Diagnostics.Function_overload_must_be_static : ts.Diagnostics.Function_overload_must_not_be_static; error(errorNode_1, diagnostic); @@ -19028,11 +19472,11 @@ var ts; var current = declarations[_i]; var node = current; var inAmbientContext = ts.isInAmbientContext(node); - var inAmbientContextOrInterface = node.parent.kind === 213 || node.parent.kind === 153 || inAmbientContext; + var inAmbientContextOrInterface = node.parent.kind === 215 || node.parent.kind === 155 || inAmbientContext; if (inAmbientContextOrInterface) { previousDeclaration = undefined; } - if (node.kind === 211 || node.kind === 141 || node.kind === 140 || node.kind === 142) { + if (node.kind === 213 || node.kind === 143 || node.kind === 142 || node.kind === 144) { var currentNodeFlags = getEffectiveDeclarationFlags(node, flagsToCheck); someNodeFlags |= currentNodeFlags; allNodeFlags &= currentNodeFlags; @@ -19145,16 +19589,16 @@ var ts; } function getDeclarationSpaces(d) { switch (d.kind) { - case 213: + case 215: return 2097152; - case 216: + case 218: return d.name.kind === 9 || ts.getModuleInstanceState(d) !== 0 ? 4194304 | 1048576 : 4194304; - case 212: - case 215: + case 214: + case 217: return 2097152 | 1048576; - case 219: + case 221: var result = 0; var target = resolveAlias(getSymbolOfNode(d)); ts.forEach(target.declarations, function (d) { result |= getDeclarationSpaces(d); }); @@ -19165,7 +19609,8 @@ var ts; } } function checkNonThenableType(type, location, message) { - if (!(type.flags & 1) && isTypeAssignableTo(type, getGlobalThenableType())) { + type = getWidenedType(type); + if (!isTypeAny(type) && isTypeAssignableTo(type, getGlobalThenableType())) { if (location) { if (!message) { message = ts.Diagnostics.Operand_for_await_does_not_have_a_valid_callable_then_member; @@ -19280,22 +19725,22 @@ var ts; var headMessage = getDiagnosticHeadMessageForDecoratorResolution(node); var errorInfo; switch (node.parent.kind) { - case 212: + case 214: var classSymbol = getSymbolOfNode(node.parent); var classConstructorType = getTypeOfSymbol(classSymbol); expectedReturnType = getUnionType([classConstructorType, voidType]); break; - case 136: + case 138: expectedReturnType = voidType; errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.The_return_type_of_a_parameter_decorator_function_must_be_either_void_or_any); break; - case 139: + case 141: expectedReturnType = voidType; errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.The_return_type_of_a_property_decorator_function_must_be_either_void_or_any); break; - case 141: case 143: - case 144: + case 145: + case 146: var methodType = getTypeOfNode(node.parent); var descriptorType = createTypedPropertyDescriptorType(methodType); expectedReturnType = getUnionType([descriptorType, voidType]); @@ -19304,9 +19749,9 @@ var ts; checkTypeAssignableTo(returnType, expectedReturnType, node, headMessage, errorInfo); } function checkTypeNodeAsExpression(node) { - if (node && node.kind === 149) { + if (node && node.kind === 151) { var root = getFirstIdentifier(node.typeName); - var meaning = root.parent.kind === 149 ? 793056 : 1536; + var meaning = root.parent.kind === 151 ? 793056 : 1536; var rootSymbol = resolveName(root, root.text, meaning | 8388608, undefined, undefined); if (rootSymbol && rootSymbol.flags & 8388608) { var aliasTarget = resolveAlias(rootSymbol); @@ -19318,19 +19763,19 @@ var ts; } function checkTypeAnnotationAsExpression(node) { switch (node.kind) { - case 139: - checkTypeNodeAsExpression(node.type); - break; - case 136: - checkTypeNodeAsExpression(node.type); - break; case 141: checkTypeNodeAsExpression(node.type); break; + case 138: + checkTypeNodeAsExpression(node.type); + break; case 143: checkTypeNodeAsExpression(node.type); break; - case 144: + case 145: + checkTypeNodeAsExpression(node.type); + break; + case 146: checkTypeNodeAsExpression(ts.getSetAccessorTypeAnnotationNode(node)); break; } @@ -19353,24 +19798,24 @@ var ts; } if (compilerOptions.emitDecoratorMetadata) { switch (node.kind) { - case 212: + case 214: var constructor = ts.getFirstConstructorWithBody(node); if (constructor) { checkParameterTypeAnnotationsAsExpressions(constructor); } break; - case 141: - checkParameterTypeAnnotationsAsExpressions(node); - case 144: case 143: - case 139: - case 136: + checkParameterTypeAnnotationsAsExpressions(node); + case 146: + case 145: + case 141: + case 138: checkTypeAnnotationAsExpression(node); break; } } emitDecorate = true; - if (node.kind === 136) { + if (node.kind === 138) { emitParam = true; } ts.forEach(node.decorators, checkDecorator); @@ -19388,12 +19833,9 @@ var ts; checkSignatureDeclaration(node); var isAsync = ts.isAsyncFunctionLike(node); if (isAsync) { - if (!compilerOptions.experimentalAsyncFunctions) { - error(node, ts.Diagnostics.Experimental_support_for_async_functions_is_a_feature_that_is_subject_to_change_in_a_future_release_Specify_experimentalAsyncFunctions_to_remove_this_warning); - } emitAwaiter = true; } - if (node.name && node.name.kind === 134) { + if (node.name && node.name.kind === 136) { checkComputedPropertyName(node.name); } if (!ts.hasDynamicName(node)) { @@ -19428,11 +19870,11 @@ var ts; } } function checkBlock(node) { - if (node.kind === 190) { + if (node.kind === 192) { checkGrammarStatementInAmbientContext(node); } ts.forEach(node.statements, checkSourceElement); - if (ts.isFunctionBlock(node) || node.kind === 217) { + if (ts.isFunctionBlock(node) || node.kind === 219) { checkFunctionAndClassExpressionBodies(node); } } @@ -19450,19 +19892,19 @@ var ts; if (!(identifier && identifier.text === name)) { return false; } - if (node.kind === 139 || - node.kind === 138 || - node.kind === 141 || + if (node.kind === 141 || node.kind === 140 || node.kind === 143 || - node.kind === 144) { + node.kind === 142 || + node.kind === 145 || + node.kind === 146) { return false; } if (ts.isInAmbientContext(node)) { return false; } var root = ts.getRootDeclaration(node); - if (root.kind === 136 && ts.nodeIsMissing(root.parent.body)) { + if (root.kind === 138 && ts.nodeIsMissing(root.parent.body)) { return false; } return true; @@ -19476,7 +19918,7 @@ var ts; var current = node; while (current) { if (getNodeCheckFlags(current) & 4) { - var isDeclaration_1 = node.kind !== 67; + var isDeclaration_1 = node.kind !== 69; if (isDeclaration_1) { error(node.name, ts.Diagnostics.Duplicate_identifier_this_Compiler_uses_variable_declaration_this_to_capture_this_reference); } @@ -19497,7 +19939,7 @@ var ts; return; } if (ts.getClassExtendsHeritageClauseElement(enclosingClass)) { - var isDeclaration_2 = node.kind !== 67; + var isDeclaration_2 = node.kind !== 69; if (isDeclaration_2) { error(node, ts.Diagnostics.Duplicate_identifier_super_Compiler_uses_super_to_capture_base_class_reference); } @@ -19510,11 +19952,11 @@ var ts; if (!needCollisionCheckForIdentifier(node, name, "require") && !needCollisionCheckForIdentifier(node, name, "exports")) { return; } - if (node.kind === 216 && ts.getModuleInstanceState(node) !== 1) { + if (node.kind === 218 && ts.getModuleInstanceState(node) !== 1) { return; } var parent = getDeclarationContainer(node); - if (parent.kind === 246 && ts.isExternalModule(parent)) { + if (parent.kind === 248 && ts.isExternalOrCommonJsModule(parent)) { error(name, ts.Diagnostics.Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module, ts.declarationNameToString(name), ts.declarationNameToString(name)); } } @@ -19522,7 +19964,7 @@ var ts; if ((ts.getCombinedNodeFlags(node) & 49152) !== 0 || ts.isParameterDeclaration(node)) { return; } - if (node.kind === 209 && !node.initializer) { + if (node.kind === 211 && !node.initializer) { return; } var symbol = getSymbolOfNode(node); @@ -19532,15 +19974,15 @@ var ts; localDeclarationSymbol !== symbol && localDeclarationSymbol.flags & 2) { if (getDeclarationFlagsFromSymbol(localDeclarationSymbol) & 49152) { - var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 210); - var container = varDeclList.parent.kind === 191 && varDeclList.parent.parent + var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 212); + var container = varDeclList.parent.kind === 193 && varDeclList.parent.parent ? varDeclList.parent.parent : undefined; var namesShareScope = container && - (container.kind === 190 && ts.isFunctionLike(container.parent) || - container.kind === 217 || - container.kind === 216 || - container.kind === 246); + (container.kind === 192 && ts.isFunctionLike(container.parent) || + container.kind === 219 || + container.kind === 218 || + container.kind === 248); if (!namesShareScope) { var name_15 = symbolToString(localDeclarationSymbol); error(node, ts.Diagnostics.Cannot_initialize_outer_scoped_variable_0_in_the_same_scope_as_block_scoped_declaration_1, name_15, name_15); @@ -19550,16 +19992,16 @@ var ts; } } function checkParameterInitializer(node) { - if (ts.getRootDeclaration(node).kind !== 136) { + if (ts.getRootDeclaration(node).kind !== 138) { return; } var func = ts.getContainingFunction(node); visit(node.initializer); function visit(n) { - if (n.kind === 67) { + if (n.kind === 69) { var referencedSymbol = getNodeLinks(n).resolvedSymbol; if (referencedSymbol && referencedSymbol !== unknownSymbol && getSymbol(func.locals, referencedSymbol.name, 107455) === referencedSymbol) { - if (referencedSymbol.valueDeclaration.kind === 136) { + if (referencedSymbol.valueDeclaration.kind === 138) { if (referencedSymbol.valueDeclaration === node) { error(n, ts.Diagnostics.Parameter_0_cannot_be_referenced_in_its_initializer, ts.declarationNameToString(node.name)); return; @@ -19579,7 +20021,7 @@ var ts; function checkVariableLikeDeclaration(node) { checkDecorators(node); checkSourceElement(node.type); - if (node.name.kind === 134) { + if (node.name.kind === 136) { checkComputedPropertyName(node.name); if (node.initializer) { checkExpressionCached(node.initializer); @@ -19588,7 +20030,7 @@ var ts; if (ts.isBindingPattern(node.name)) { ts.forEach(node.name.elements, checkSourceElement); } - if (node.initializer && ts.getRootDeclaration(node).kind === 136 && ts.nodeIsMissing(ts.getContainingFunction(node).body)) { + if (node.initializer && ts.getRootDeclaration(node).kind === 138 && ts.nodeIsMissing(ts.getContainingFunction(node).body)) { error(node, ts.Diagnostics.A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation); return; } @@ -19616,9 +20058,9 @@ var ts; checkTypeAssignableTo(checkExpressionCached(node.initializer), declarationType, node, undefined); } } - if (node.kind !== 139 && node.kind !== 138) { + if (node.kind !== 141 && node.kind !== 140) { checkExportsOnMergedDeclarations(node); - if (node.kind === 209 || node.kind === 161) { + if (node.kind === 211 || node.kind === 163) { checkVarDeclaredNamesNotShadowed(node); } checkCollisionWithCapturedSuperVariable(node, node.name); @@ -19639,7 +20081,7 @@ var ts; ts.forEach(node.declarationList.declarations, checkSourceElement); } function checkGrammarDisallowedModifiersOnObjectLiteralExpressionMethod(node) { - if (node.modifiers && node.parent.kind === 163) { + if (node.modifiers && node.parent.kind === 165) { if (ts.isAsyncFunctionLike(node)) { if (node.modifiers.length > 1) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); @@ -19672,12 +20114,12 @@ var ts; } function checkForStatement(node) { if (!checkGrammarStatementInAmbientContext(node)) { - if (node.initializer && node.initializer.kind === 210) { + if (node.initializer && node.initializer.kind === 212) { checkGrammarVariableDeclarationList(node.initializer); } } if (node.initializer) { - if (node.initializer.kind === 210) { + if (node.initializer.kind === 212) { ts.forEach(node.initializer.declarations, checkVariableDeclaration); } else { @@ -19692,13 +20134,13 @@ var ts; } function checkForOfStatement(node) { checkGrammarForInOrForOfStatement(node); - if (node.initializer.kind === 210) { + if (node.initializer.kind === 212) { checkForInOrForOfVariableDeclaration(node); } else { var varExpr = node.initializer; var iteratedType = checkRightHandSideOfForOf(node.expression); - if (varExpr.kind === 162 || varExpr.kind === 163) { + if (varExpr.kind === 164 || varExpr.kind === 165) { checkDestructuringAssignment(varExpr, iteratedType || unknownType); } else { @@ -19713,7 +20155,7 @@ var ts; } function checkForInStatement(node) { checkGrammarForInOrForOfStatement(node); - if (node.initializer.kind === 210) { + if (node.initializer.kind === 212) { var variable = node.initializer.declarations[0]; if (variable && ts.isBindingPattern(variable.name)) { error(variable.name, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern); @@ -19723,7 +20165,7 @@ var ts; else { var varExpr = node.initializer; var leftType = checkExpression(varExpr); - if (varExpr.kind === 162 || varExpr.kind === 163) { + if (varExpr.kind === 164 || varExpr.kind === 165) { error(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern); } else if (!isTypeAnyOrAllConstituentTypesHaveKind(leftType, 258)) { @@ -19885,7 +20327,7 @@ var ts; checkGrammarStatementInAmbientContext(node) || checkGrammarBreakOrContinueStatement(node); } function isGetAccessorWithAnnotatatedSetAccessor(node) { - return !!(node.kind === 143 && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(node.symbol, 144))); + return !!(node.kind === 145 && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(node.symbol, 146))); } function checkReturnStatement(node) { if (!checkGrammarStatementInAmbientContext(node)) { @@ -19903,10 +20345,10 @@ var ts; if (func.asteriskToken) { return; } - if (func.kind === 144) { + if (func.kind === 146) { error(node.expression, ts.Diagnostics.Setters_cannot_return_a_value); } - else if (func.kind === 142) { + else if (func.kind === 144) { if (!isTypeAssignableTo(exprType, returnType)) { error(node.expression, ts.Diagnostics.Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class); } @@ -19915,7 +20357,9 @@ var ts; if (ts.isAsyncFunctionLike(func)) { var promisedType = getPromisedType(returnType); var awaitedType = checkAwaitedType(exprType, node.expression, ts.Diagnostics.Return_expression_in_async_function_does_not_have_a_valid_callable_then_member); - checkTypeAssignableTo(awaitedType, promisedType, node.expression); + if (promisedType) { + checkTypeAssignableTo(awaitedType, promisedType, node.expression); + } } else { checkTypeAssignableTo(exprType, returnType, node.expression); @@ -19939,7 +20383,7 @@ var ts; var hasDuplicateDefaultClause = false; var expressionType = checkExpression(node.expression); ts.forEach(node.caseBlock.clauses, function (clause) { - if (clause.kind === 240 && !hasDuplicateDefaultClause) { + if (clause.kind === 242 && !hasDuplicateDefaultClause) { if (firstDefaultClause === undefined) { firstDefaultClause = clause; } @@ -19951,7 +20395,7 @@ var ts; hasDuplicateDefaultClause = true; } } - if (produceDiagnostics && clause.kind === 239) { + if (produceDiagnostics && clause.kind === 241) { var caseClause = clause; var caseType = checkExpression(caseClause.expression); if (!isTypeAssignableTo(expressionType, caseType)) { @@ -19968,7 +20412,7 @@ var ts; if (ts.isFunctionLike(current)) { break; } - if (current.kind === 205 && current.label.text === node.label.text) { + if (current.kind === 207 && current.label.text === node.label.text) { var sourceFile = ts.getSourceFileOfNode(node); grammarErrorOnNode(node.label, ts.Diagnostics.Duplicate_label_0, ts.getTextOfNodeFromSourceText(sourceFile.text, node.label)); break; @@ -19994,7 +20438,7 @@ var ts; var catchClause = node.catchClause; if (catchClause) { if (catchClause.variableDeclaration) { - if (catchClause.variableDeclaration.name.kind !== 67) { + if (catchClause.variableDeclaration.name.kind !== 69) { grammarErrorOnFirstToken(catchClause.variableDeclaration.name, ts.Diagnostics.Catch_clause_variable_name_must_be_an_identifier); } else if (catchClause.variableDeclaration.type) { @@ -20062,7 +20506,7 @@ var ts; return; } var errorNode; - if (prop.valueDeclaration.name.kind === 134 || prop.parent === containingType.symbol) { + if (prop.valueDeclaration.name.kind === 136 || prop.parent === containingType.symbol) { errorNode = prop.valueDeclaration; } else if (indexDeclaration) { @@ -20132,6 +20576,7 @@ var ts; checkExportsOnMergedDeclarations(node); var symbol = getSymbolOfNode(node); var type = getDeclaredTypeOfSymbol(symbol); + var typeWithThis = getTypeWithThisArgument(type); var staticType = getTypeOfSymbol(symbol); var baseTypeNode = ts.getClassExtendsHeritageClauseElement(node); if (baseTypeNode) { @@ -20150,7 +20595,7 @@ var ts; } } } - checkTypeAssignableTo(type, baseType, node.name || node, ts.Diagnostics.Class_0_incorrectly_extends_base_class_1); + checkTypeAssignableTo(typeWithThis, getTypeWithThisArgument(baseType, type.thisType), node.name || node, ts.Diagnostics.Class_0_incorrectly_extends_base_class_1); checkTypeAssignableTo(staticType, getTypeWithoutSignatures(staticBaseType), node.name || node, ts.Diagnostics.Class_static_side_0_incorrectly_extends_base_class_static_side_1); if (!(staticBaseType.symbol && staticBaseType.symbol.flags & 32)) { var constructors = getInstantiatedConstructorsForTypeArguments(staticBaseType, baseTypeNode.typeArguments); @@ -20163,7 +20608,8 @@ var ts; } var implementedTypeNodes = ts.getClassImplementsHeritageClauseElements(node); if (implementedTypeNodes) { - ts.forEach(implementedTypeNodes, function (typeRefNode) { + for (var _b = 0; _b < implementedTypeNodes.length; _b++) { + var typeRefNode = implementedTypeNodes[_b]; if (!ts.isSupportedExpressionWithTypeArguments(typeRefNode)) { error(typeRefNode.expression, ts.Diagnostics.A_class_can_only_implement_an_identifier_Slashqualified_name_with_optional_type_arguments); } @@ -20173,14 +20619,14 @@ var ts; if (t !== unknownType) { var declaredType = (t.flags & 4096) ? t.target : t; if (declaredType.flags & (1024 | 2048)) { - checkTypeAssignableTo(type, t, node.name || node, ts.Diagnostics.Class_0_incorrectly_implements_interface_1); + checkTypeAssignableTo(typeWithThis, getTypeWithThisArgument(t, type.thisType), node.name || node, ts.Diagnostics.Class_0_incorrectly_implements_interface_1); } else { error(typeRefNode, ts.Diagnostics.A_class_may_only_implement_another_class_or_interface); } } } - }); + } } if (produceDiagnostics) { checkIndexConstraints(type); @@ -20208,7 +20654,7 @@ var ts; if (derived === base) { var derivedClassDecl = getClassLikeDeclarationOfSymbol(type.symbol); if (baseDeclarationFlags & 256 && (!derivedClassDecl || !(derivedClassDecl.flags & 256))) { - if (derivedClassDecl.kind === 184) { + if (derivedClassDecl.kind === 186) { error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1, symbolToString(baseProperty), typeToString(baseType)); } else { @@ -20252,7 +20698,7 @@ var ts; } } function isAccessor(kind) { - return kind === 143 || kind === 144; + return kind === 145 || kind === 146; } function areTypeParametersIdentical(list1, list2) { if (!list1 && !list2) { @@ -20289,7 +20735,7 @@ var ts; var ok = true; for (var _i = 0; _i < baseTypes.length; _i++) { var base = baseTypes[_i]; - var properties = getPropertiesOfObjectType(base); + var properties = getPropertiesOfObjectType(getTypeWithThisArgument(base, type.thisType)); for (var _a = 0; _a < properties.length; _a++) { var prop = properties[_a]; if (!ts.hasProperty(seen, prop.name)) { @@ -20318,7 +20764,7 @@ var ts; checkTypeNameIsReserved(node.name, ts.Diagnostics.Interface_name_cannot_be_0); checkExportsOnMergedDeclarations(node); var symbol = getSymbolOfNode(node); - var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 213); + var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 215); if (symbol.declarations.length > 1) { if (node !== firstInterfaceDecl && !areTypeParametersIdentical(firstInterfaceDecl.typeParameters, node.typeParameters)) { error(node.name, ts.Diagnostics.All_declarations_of_an_interface_must_have_identical_type_parameters); @@ -20326,17 +20772,19 @@ var ts; } if (node === firstInterfaceDecl) { var type = getDeclaredTypeOfSymbol(symbol); + var typeWithThis = getTypeWithThisArgument(type); if (checkInheritedPropertiesAreIdentical(type, node.name)) { - ts.forEach(getBaseTypes(type), function (baseType) { - checkTypeAssignableTo(type, baseType, node.name, ts.Diagnostics.Interface_0_incorrectly_extends_interface_1); - }); + for (var _i = 0, _a = getBaseTypes(type); _i < _a.length; _i++) { + var baseType = _a[_i]; + checkTypeAssignableTo(typeWithThis, getTypeWithThisArgument(baseType, type.thisType), node.name, ts.Diagnostics.Interface_0_incorrectly_extends_interface_1); + } checkIndexConstraints(type); } } if (symbol && symbol.declarations) { - for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { - var declaration = _a[_i]; - if (declaration.kind === 212 && !ts.isInAmbientContext(declaration)) { + for (var _b = 0, _c = symbol.declarations; _b < _c.length; _b++) { + var declaration = _c[_b]; + if (declaration.kind === 214 && !ts.isInAmbientContext(declaration)) { error(node, ts.Diagnostics.Only_an_ambient_class_can_be_merged_with_an_interface); break; } @@ -20367,10 +20815,15 @@ var ts; var autoValue = 0; var ambient = ts.isInAmbientContext(node); var enumIsConst = ts.isConst(node); - ts.forEach(node.members, function (member) { - if (member.name.kind !== 134 && isNumericLiteralName(member.name.text)) { + for (var _i = 0, _a = node.members; _i < _a.length; _i++) { + var member = _a[_i]; + if (member.name.kind === 136) { + error(member.name, ts.Diagnostics.Computed_property_names_are_not_allowed_in_enums); + } + else if (isNumericLiteralName(member.name.text)) { error(member.name, ts.Diagnostics.An_enum_member_cannot_have_a_numeric_name); } + var previousEnumMemberIsNonConstant = autoValue === undefined; var initializer = member.initializer; if (initializer) { autoValue = computeConstantValueForEnumMemberInitializer(initializer, enumType, enumIsConst, ambient); @@ -20378,10 +20831,13 @@ var ts; else if (ambient && !enumIsConst) { autoValue = undefined; } + else if (previousEnumMemberIsNonConstant) { + error(member.name, ts.Diagnostics.Enum_member_must_have_initializer); + } if (autoValue !== undefined) { getNodeLinks(member).enumMemberValue = autoValue++; } - }); + } nodeLinks.flags |= 8192; } function computeConstantValueForEnumMemberInitializer(initializer, enumType, enumIsConst, ambient) { @@ -20392,7 +20848,10 @@ var ts; if (enumIsConst) { error(initializer, ts.Diagnostics.In_const_enum_declarations_member_initializer_must_be_constant_expression); } - else if (!ambient) { + else if (ambient) { + error(initializer, ts.Diagnostics.In_ambient_enum_declarations_member_initializer_must_be_constant_expression); + } + else { checkTypeAssignableTo(checkExpression(initializer), enumType, initializer, undefined); } } @@ -20408,7 +20867,7 @@ var ts; return value; function evalConstant(e) { switch (e.kind) { - case 177: + case 179: var value_1 = evalConstant(e.operand); if (value_1 === undefined) { return undefined; @@ -20416,10 +20875,10 @@ var ts; switch (e.operator) { case 35: return value_1; case 36: return -value_1; - case 49: return ~value_1; + case 50: return ~value_1; } return undefined; - case 179: + case 181: var left = evalConstant(e.left); if (left === undefined) { return undefined; @@ -20429,37 +20888,37 @@ var ts; return undefined; } switch (e.operatorToken.kind) { - case 46: return left | right; - case 45: return left & right; - case 43: return left >> right; - case 44: return left >>> right; - case 42: return left << right; - case 47: return left ^ right; + case 47: return left | right; + case 46: return left & right; + case 44: return left >> right; + case 45: return left >>> right; + case 43: return left << right; + case 48: return left ^ right; case 37: return left * right; - case 38: return left / right; + case 39: return left / right; case 35: return left + right; case 36: return left - right; - case 39: return left % right; + case 40: return left % right; } return undefined; case 8: return +e.text; - case 170: + case 172: return evalConstant(e.expression); - case 67: - case 165: - case 164: + case 69: + case 167: + case 166: var member = initializer.parent; var currentType = getTypeOfSymbol(getSymbolOfNode(member.parent)); var enumType_1; var propertyName; - if (e.kind === 67) { + if (e.kind === 69) { enumType_1 = currentType; propertyName = e.text; } else { var expression; - if (e.kind === 165) { + if (e.kind === 167) { if (e.argumentExpression === undefined || e.argumentExpression.kind !== 9) { return undefined; @@ -20473,10 +20932,10 @@ var ts; } var current = expression; while (current) { - if (current.kind === 67) { + if (current.kind === 69) { break; } - else if (current.kind === 164) { + else if (current.kind === 166) { current = current.expression; } else { @@ -20499,7 +20958,7 @@ var ts; if (member === propertyDecl) { return undefined; } - if (!isDefinedBefore(propertyDecl, member)) { + if (!isBlockScopedNameDeclaredBeforeUse(propertyDecl, member)) { reportError = false; error(e, ts.Diagnostics.A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_enums); return undefined; @@ -20513,7 +20972,7 @@ var ts; if (!produceDiagnostics) { return; } - checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarEnumDeclaration(node); + checkGrammarDecorators(node) || checkGrammarModifiers(node); checkTypeNameIsReserved(node.name, ts.Diagnostics.Enum_name_cannot_be_0); checkCollisionWithCapturedThisVariable(node, node.name); checkCollisionWithRequireExportsInGeneratedCode(node, node.name); @@ -20535,7 +20994,7 @@ var ts; } var seenEnumMissingInitialInitializer = false; ts.forEach(enumSymbol.declarations, function (declaration) { - if (declaration.kind !== 215) { + if (declaration.kind !== 217) { return false; } var enumDeclaration = declaration; @@ -20558,8 +21017,8 @@ var ts; var declarations = symbol.declarations; for (var _i = 0; _i < declarations.length; _i++) { var declaration = declarations[_i]; - if ((declaration.kind === 212 || - (declaration.kind === 211 && ts.nodeIsPresent(declaration.body))) && + if ((declaration.kind === 214 || + (declaration.kind === 213 && ts.nodeIsPresent(declaration.body))) && !ts.isInAmbientContext(declaration)) { return declaration; } @@ -20610,7 +21069,7 @@ var ts; error(node.name, ts.Diagnostics.A_namespace_declaration_cannot_be_located_prior_to_a_class_or_function_with_which_it_is_merged); } } - var mergedClass = ts.getDeclarationOfKind(symbol, 212); + var mergedClass = ts.getDeclarationOfKind(symbol, 214); if (mergedClass && inSameLexicalScope(node, mergedClass)) { getNodeLinks(node).flags |= 32768; @@ -20618,9 +21077,9 @@ var ts; } if (isAmbientExternalModule) { if (!isGlobalSourceFile(node.parent)) { - error(node.name, ts.Diagnostics.Ambient_modules_cannot_be_nested_in_other_modules); + error(node.name, ts.Diagnostics.Ambient_modules_cannot_be_nested_in_other_modules_or_namespaces); } - if (isExternalModuleNameRelative(node.name.text)) { + if (ts.isExternalModuleNameRelative(node.name.text)) { error(node.name, ts.Diagnostics.Ambient_module_declaration_cannot_specify_relative_module_name); } } @@ -20629,17 +21088,17 @@ var ts; } function getFirstIdentifier(node) { while (true) { - if (node.kind === 133) { + if (node.kind === 135) { node = node.left; } - else if (node.kind === 164) { + else if (node.kind === 166) { node = node.expression; } else { break; } } - ts.Debug.assert(node.kind === 67); + ts.Debug.assert(node.kind === 69); return node; } function checkExternalImportOrExportDeclaration(node) { @@ -20648,14 +21107,14 @@ var ts; error(moduleName, ts.Diagnostics.String_literal_expected); return false; } - var inAmbientExternalModule = node.parent.kind === 217 && node.parent.parent.name.kind === 9; - if (node.parent.kind !== 246 && !inAmbientExternalModule) { - error(moduleName, node.kind === 226 ? + var inAmbientExternalModule = node.parent.kind === 219 && node.parent.parent.name.kind === 9; + if (node.parent.kind !== 248 && !inAmbientExternalModule) { + error(moduleName, node.kind === 228 ? ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace : ts.Diagnostics.Import_declarations_in_a_namespace_cannot_reference_a_module); return false; } - if (inAmbientExternalModule && isExternalModuleNameRelative(moduleName.text)) { + if (inAmbientExternalModule && ts.isExternalModuleNameRelative(moduleName.text)) { error(node, ts.Diagnostics.Import_or_export_declaration_in_an_ambient_module_declaration_cannot_reference_module_through_relative_module_name); return false; } @@ -20669,7 +21128,7 @@ var ts; (symbol.flags & 793056 ? 793056 : 0) | (symbol.flags & 1536 ? 1536 : 0); if (target.flags & excludedMeanings) { - var message = node.kind === 228 ? + var message = node.kind === 230 ? ts.Diagnostics.Export_declaration_conflicts_with_exported_declaration_of_0 : ts.Diagnostics.Import_declaration_conflicts_with_local_declaration_of_0; error(node, message, symbolToString(symbol)); @@ -20695,7 +21154,7 @@ var ts; checkImportBinding(importClause); } if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 222) { + if (importClause.namedBindings.kind === 224) { checkImportBinding(importClause.namedBindings); } else { @@ -20730,8 +21189,8 @@ var ts; } } else { - if (languageVersion >= 2 && !ts.isInAmbientContext(node)) { - grammarErrorOnNode(node, ts.Diagnostics.Import_assignment_cannot_be_used_when_targeting_ECMAScript_6_or_higher_Consider_using_import_Asterisk_as_ns_from_mod_import_a_from_mod_or_import_d_from_mod_instead); + if (modulekind === 5 && !ts.isInAmbientContext(node)) { + grammarErrorOnNode(node, ts.Diagnostics.Import_assignment_cannot_be_used_when_targeting_ECMAScript_6_modules_Consider_using_import_Asterisk_as_ns_from_mod_import_a_from_mod_import_d_from_mod_or_another_module_format_instead); } } } @@ -20746,8 +21205,8 @@ var ts; if (!node.moduleSpecifier || checkExternalImportOrExportDeclaration(node)) { if (node.exportClause) { ts.forEach(node.exportClause.elements, checkExportSpecifier); - var inAmbientExternalModule = node.parent.kind === 217 && node.parent.parent.name.kind === 9; - if (node.parent.kind !== 246 && !inAmbientExternalModule) { + var inAmbientExternalModule = node.parent.kind === 219 && node.parent.parent.name.kind === 9; + if (node.parent.kind !== 248 && !inAmbientExternalModule) { error(node, ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace); } } @@ -20760,7 +21219,7 @@ var ts; } } function checkGrammarModuleElementContext(node, errorMessage) { - if (node.parent.kind !== 246 && node.parent.kind !== 217 && node.parent.kind !== 216) { + if (node.parent.kind !== 248 && node.parent.kind !== 219 && node.parent.kind !== 218) { return grammarErrorOnFirstToken(node, errorMessage); } } @@ -20774,15 +21233,15 @@ var ts; if (checkGrammarModuleElementContext(node, ts.Diagnostics.An_export_assignment_can_only_be_used_in_a_module)) { return; } - var container = node.parent.kind === 246 ? node.parent : node.parent.parent; - if (container.kind === 216 && container.name.kind === 67) { + var container = node.parent.kind === 248 ? node.parent : node.parent.parent; + if (container.kind === 218 && container.name.kind === 69) { error(node, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_namespace); return; } if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && (node.flags & 2035)) { grammarErrorOnFirstToken(node, ts.Diagnostics.An_export_assignment_cannot_have_modifiers); } - if (node.expression.kind === 67) { + if (node.expression.kind === 69) { markExportAsReferenced(node); } else { @@ -20790,19 +21249,19 @@ var ts; } checkExternalModuleExports(container); if (node.isExportEquals && !ts.isInAmbientContext(node)) { - if (languageVersion >= 2) { - grammarErrorOnNode(node, ts.Diagnostics.Export_assignment_cannot_be_used_when_targeting_ECMAScript_6_or_higher_Consider_using_export_default_instead); + if (modulekind === 5) { + grammarErrorOnNode(node, ts.Diagnostics.Export_assignment_cannot_be_used_when_targeting_ECMAScript_6_modules_Consider_using_export_default_or_another_module_format_instead); } - else if (compilerOptions.module === 4) { + else if (modulekind === 4) { grammarErrorOnNode(node, ts.Diagnostics.Export_assignment_is_not_supported_when_module_flag_is_system); } } } function getModuleStatements(node) { - if (node.kind === 246) { + if (node.kind === 248) { return node.statements; } - if (node.kind === 216 && node.body.kind === 217) { + if (node.kind === 218 && node.body.kind === 219) { return node.body.statements; } return emptyArray; @@ -20839,183 +21298,182 @@ var ts; var kind = node.kind; if (cancellationToken) { switch (kind) { - case 216: - case 212: + case 218: + case 214: + case 215: case 213: - case 211: cancellationToken.throwIfCancellationRequested(); } } switch (kind) { - case 135: + case 137: return checkTypeParameter(node); - case 136: - return checkParameter(node); - case 139: case 138: - return checkPropertyDeclaration(node); - case 150: - case 151: - case 145: - case 146: - return checkSignatureDeclaration(node); - case 147: - return checkSignatureDeclaration(node); + return checkParameter(node); case 141: case 140: - return checkMethodDeclaration(node); - case 142: - return checkConstructorDeclaration(node); - case 143: - case 144: - return checkAccessorDeclaration(node); - case 149: - return checkTypeReferenceNode(node); - case 148: - return checkTypePredicate(node); + return checkPropertyDeclaration(node); case 152: - return checkTypeQuery(node); case 153: - return checkTypeLiteral(node); + case 147: + case 148: + return checkSignatureDeclaration(node); + case 149: + return checkSignatureDeclaration(node); + case 143: + case 142: + return checkMethodDeclaration(node); + case 144: + return checkConstructorDeclaration(node); + case 145: + case 146: + return checkAccessorDeclaration(node); + case 151: + return checkTypeReferenceNode(node); + case 150: + return checkTypePredicate(node); case 154: - return checkArrayType(node); + return checkTypeQuery(node); case 155: - return checkTupleType(node); + return checkTypeLiteral(node); case 156: + return checkArrayType(node); case 157: - return checkUnionOrIntersectionType(node); + return checkTupleType(node); case 158: + case 159: + return checkUnionOrIntersectionType(node); + case 160: return checkSourceElement(node.type); - case 211: - return checkFunctionDeclaration(node); - case 190: - case 217: - return checkBlock(node); - case 191: - return checkVariableStatement(node); - case 193: - return checkExpressionStatement(node); - case 194: - return checkIfStatement(node); - case 195: - return checkDoStatement(node); - case 196: - return checkWhileStatement(node); - case 197: - return checkForStatement(node); - case 198: - return checkForInStatement(node); - case 199: - return checkForOfStatement(node); - case 200: - case 201: - return checkBreakOrContinueStatement(node); - case 202: - return checkReturnStatement(node); - case 203: - return checkWithStatement(node); - case 204: - return checkSwitchStatement(node); - case 205: - return checkLabeledStatement(node); - case 206: - return checkThrowStatement(node); - case 207: - return checkTryStatement(node); - case 209: - return checkVariableDeclaration(node); - case 161: - return checkBindingElement(node); - case 212: - return checkClassDeclaration(node); case 213: - return checkInterfaceDeclaration(node); - case 214: - return checkTypeAliasDeclaration(node); - case 215: - return checkEnumDeclaration(node); - case 216: - return checkModuleDeclaration(node); - case 220: - return checkImportDeclaration(node); - case 219: - return checkImportEqualsDeclaration(node); - case 226: - return checkExportDeclaration(node); - case 225: - return checkExportAssignment(node); + return checkFunctionDeclaration(node); case 192: - checkGrammarStatementInAmbientContext(node); - return; + case 219: + return checkBlock(node); + case 193: + return checkVariableStatement(node); + case 195: + return checkExpressionStatement(node); + case 196: + return checkIfStatement(node); + case 197: + return checkDoStatement(node); + case 198: + return checkWhileStatement(node); + case 199: + return checkForStatement(node); + case 200: + return checkForInStatement(node); + case 201: + return checkForOfStatement(node); + case 202: + case 203: + return checkBreakOrContinueStatement(node); + case 204: + return checkReturnStatement(node); + case 205: + return checkWithStatement(node); + case 206: + return checkSwitchStatement(node); + case 207: + return checkLabeledStatement(node); case 208: + return checkThrowStatement(node); + case 209: + return checkTryStatement(node); + case 211: + return checkVariableDeclaration(node); + case 163: + return checkBindingElement(node); + case 214: + return checkClassDeclaration(node); + case 215: + return checkInterfaceDeclaration(node); + case 216: + return checkTypeAliasDeclaration(node); + case 217: + return checkEnumDeclaration(node); + case 218: + return checkModuleDeclaration(node); + case 222: + return checkImportDeclaration(node); + case 221: + return checkImportEqualsDeclaration(node); + case 228: + return checkExportDeclaration(node); + case 227: + return checkExportAssignment(node); + case 194: checkGrammarStatementInAmbientContext(node); return; - case 229: + case 210: + checkGrammarStatementInAmbientContext(node); + return; + case 231: return checkMissingDeclaration(node); } } function checkFunctionAndClassExpressionBodies(node) { switch (node.kind) { - case 171: - case 172: + case 173: + case 174: ts.forEach(node.parameters, checkFunctionAndClassExpressionBodies); checkFunctionExpressionOrObjectLiteralMethodBody(node); break; - case 184: + case 186: ts.forEach(node.members, checkSourceElement); + ts.forEachChild(node, checkFunctionAndClassExpressionBodies); break; - case 141: - case 140: + case 143: + case 142: ts.forEach(node.decorators, checkFunctionAndClassExpressionBodies); ts.forEach(node.parameters, checkFunctionAndClassExpressionBodies); if (ts.isObjectLiteralMethod(node)) { checkFunctionExpressionOrObjectLiteralMethodBody(node); } break; - case 142: - case 143: case 144: - case 211: + case 145: + case 146: + case 213: ts.forEach(node.parameters, checkFunctionAndClassExpressionBodies); break; - case 203: + case 205: checkFunctionAndClassExpressionBodies(node.expression); break; - case 137: - case 136: case 139: case 138: - case 159: - case 160: + case 141: + case 140: case 161: case 162: case 163: - case 243: case 164: case 165: + case 245: case 166: case 167: case 168: - case 181: - case 188: case 169: - case 187: case 170: - case 174: - case 175: + case 183: + case 190: + case 171: + case 189: + case 172: case 176: - case 173: case 177: case 178: + case 175: case 179: case 180: - case 183: + case 181: case 182: - case 190: - case 217: - case 191: + case 185: + case 184: + case 192: + case 219: case 193: - case 194: case 195: case 196: case 197: @@ -21024,29 +21482,31 @@ var ts; case 200: case 201: case 202: + case 203: case 204: - case 218: - case 239: - case 240: - case 205: case 206: - case 207: - case 242: - case 209: - case 210: - case 212: + case 220: case 241: - case 186: - case 215: - case 245: - case 225: - case 246: - case 238: - case 231: - case 232: - case 236: - case 237: + case 242: + case 207: + case 208: + case 209: + case 244: + case 211: + case 212: + case 214: + case 243: + case 188: + case 217: + case 247: + case 227: + case 248: + case 240: case 233: + case 234: + case 238: + case 239: + case 235: ts.forEachChild(node, checkFunctionAndClassExpressionBodies); break; } @@ -21069,7 +21529,7 @@ var ts; potentialThisCollisions.length = 0; ts.forEach(node.statements, checkSourceElement); checkFunctionAndClassExpressionBodies(node); - if (ts.isExternalModule(node)) { + if (ts.isExternalOrCommonJsModule(node)) { checkExternalModuleExports(node); } if (potentialThisCollisions.length) { @@ -21124,7 +21584,7 @@ var ts; function isInsideWithStatementBody(node) { if (node) { while (node.parent) { - if (node.parent.kind === 203 && node.parent.statement === node) { + if (node.parent.kind === 205 && node.parent.statement === node) { return true; } node = node.parent; @@ -21146,28 +21606,28 @@ var ts; copySymbols(location.locals, meaning); } switch (location.kind) { - case 246: - if (!ts.isExternalModule(location)) { + case 248: + if (!ts.isExternalOrCommonJsModule(location)) { break; } - case 216: + case 218: copySymbols(getSymbolOfNode(location).exports, meaning & 8914931); break; - case 215: + case 217: copySymbols(getSymbolOfNode(location).exports, meaning & 8); break; - case 184: + case 186: var className = location.name; if (className) { copySymbol(location.symbol, meaning); } - case 212: - case 213: + case 214: + case 215: if (!(memberFlags & 128)) { copySymbols(getSymbolOfNode(location).members, meaning & 793056); } break; - case 171: + case 173: var funcName = location.name; if (funcName) { copySymbol(location.symbol, meaning); @@ -21200,42 +21660,42 @@ var ts; } } function isTypeDeclarationName(name) { - return name.kind === 67 && + return name.kind === 69 && isTypeDeclaration(name.parent) && name.parent.name === name; } function isTypeDeclaration(node) { switch (node.kind) { - case 135: - case 212: - case 213: + case 137: case 214: case 215: + case 216: + case 217: return true; } } function isTypeReferenceIdentifier(entityName) { var node = entityName; - while (node.parent && node.parent.kind === 133) { + while (node.parent && node.parent.kind === 135) { node = node.parent; } - return node.parent && node.parent.kind === 149; + return node.parent && node.parent.kind === 151; } function isHeritageClauseElementIdentifier(entityName) { var node = entityName; - while (node.parent && node.parent.kind === 164) { + while (node.parent && node.parent.kind === 166) { node = node.parent; } - return node.parent && node.parent.kind === 186; + return node.parent && node.parent.kind === 188; } function getLeftSideOfImportEqualsOrExportAssignment(nodeOnRightSide) { - while (nodeOnRightSide.parent.kind === 133) { + while (nodeOnRightSide.parent.kind === 135) { nodeOnRightSide = nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 219) { + if (nodeOnRightSide.parent.kind === 221) { return nodeOnRightSide.parent.moduleReference === nodeOnRightSide && nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 225) { + if (nodeOnRightSide.parent.kind === 227) { return nodeOnRightSide.parent.expression === nodeOnRightSide && nodeOnRightSide.parent; } return undefined; @@ -21247,10 +21707,10 @@ var ts; if (ts.isDeclarationName(entityName)) { return getSymbolOfNode(entityName.parent); } - if (entityName.parent.kind === 225) { + if (entityName.parent.kind === 227) { return resolveEntityName(entityName, 107455 | 793056 | 1536 | 8388608); } - if (entityName.kind !== 164) { + if (entityName.kind !== 166) { if (isInRightSideOfImportOrExportAssignment(entityName)) { return getSymbolOfPartOfRightHandSideOfImportEquals(entityName); } @@ -21259,31 +21719,40 @@ var ts; entityName = entityName.parent; } if (isHeritageClauseElementIdentifier(entityName)) { - var meaning = entityName.parent.kind === 186 ? 793056 : 1536; + var meaning = 0; + if (entityName.parent.kind === 188) { + meaning = 793056; + if (ts.isExpressionWithTypeArgumentsInClassExtendsClause(entityName.parent)) { + meaning |= 107455; + } + } + else { + meaning = 1536; + } meaning |= 8388608; return resolveEntityName(entityName, meaning); } - else if ((entityName.parent.kind === 233) || - (entityName.parent.kind === 232) || - (entityName.parent.kind === 235)) { + else if ((entityName.parent.kind === 235) || + (entityName.parent.kind === 234) || + (entityName.parent.kind === 237)) { return getJsxElementTagSymbol(entityName.parent); } else if (ts.isExpression(entityName)) { if (ts.nodeIsMissing(entityName)) { return undefined; } - if (entityName.kind === 67) { + if (entityName.kind === 69) { var meaning = 107455 | 8388608; return resolveEntityName(entityName, meaning); } - else if (entityName.kind === 164) { + else if (entityName.kind === 166) { var symbol = getNodeLinks(entityName).resolvedSymbol; if (!symbol) { checkPropertyAccessExpression(entityName); } return getNodeLinks(entityName).resolvedSymbol; } - else if (entityName.kind === 133) { + else if (entityName.kind === 135) { var symbol = getNodeLinks(entityName).resolvedSymbol; if (!symbol) { checkQualifiedName(entityName); @@ -21292,14 +21761,14 @@ var ts; } } else if (isTypeReferenceIdentifier(entityName)) { - var meaning = entityName.parent.kind === 149 ? 793056 : 1536; + var meaning = entityName.parent.kind === 151 ? 793056 : 1536; meaning |= 8388608; return resolveEntityName(entityName, meaning); } - else if (entityName.parent.kind === 236) { + else if (entityName.parent.kind === 238) { return getJsxAttributePropertySymbol(entityName.parent); } - if (entityName.parent.kind === 148) { + if (entityName.parent.kind === 150) { return resolveEntityName(entityName, 1); } return undefined; @@ -21311,14 +21780,14 @@ var ts; if (ts.isDeclarationName(node)) { return getSymbolOfNode(node.parent); } - if (node.kind === 67) { + if (node.kind === 69) { if (isInRightSideOfImportOrExportAssignment(node)) { - return node.parent.kind === 225 + return node.parent.kind === 227 ? getSymbolOfEntityNameOrPropertyAccessExpression(node) : getSymbolOfPartOfRightHandSideOfImportEquals(node); } - else if (node.parent.kind === 161 && - node.parent.parent.kind === 159 && + else if (node.parent.kind === 163 && + node.parent.parent.kind === 161 && node === node.parent.propertyName) { var typeOfPattern = getTypeOfNode(node.parent.parent); var propertyDeclaration = typeOfPattern && getPropertyOfType(typeOfPattern, node.text); @@ -21328,29 +21797,29 @@ var ts; } } switch (node.kind) { - case 67: - case 164: - case 133: + case 69: + case 166: + case 135: return getSymbolOfEntityNameOrPropertyAccessExpression(node); + case 97: case 95: - case 93: - var type = checkExpression(node); + var type = ts.isExpression(node) ? checkExpression(node) : getTypeFromTypeNode(node); return type.symbol; - case 119: + case 121: var constructorDeclaration = node.parent; - if (constructorDeclaration && constructorDeclaration.kind === 142) { + if (constructorDeclaration && constructorDeclaration.kind === 144) { return constructorDeclaration.parent.symbol; } return undefined; case 9: if ((ts.isExternalModuleImportEqualsDeclaration(node.parent.parent) && ts.getExternalModuleImportEqualsDeclarationExpression(node.parent.parent) === node) || - ((node.parent.kind === 220 || node.parent.kind === 226) && + ((node.parent.kind === 222 || node.parent.kind === 228) && node.parent.moduleSpecifier === node)) { return resolveExternalModuleName(node, node); } case 8: - if (node.parent.kind === 165 && node.parent.argumentExpression === node) { + if (node.parent.kind === 167 && node.parent.argumentExpression === node) { var objectType = checkExpression(node.parent.expression); if (objectType === unknownType) return undefined; @@ -21364,7 +21833,7 @@ var ts; return undefined; } function getShorthandAssignmentValueSymbol(location) { - if (location && location.kind === 244) { + if (location && location.kind === 246) { return resolveEntityName(location.name, 107455); } return undefined; @@ -21464,11 +21933,11 @@ var ts; } var parentSymbol = getParentOfSymbol(symbol); if (parentSymbol) { - if (parentSymbol.flags & 512 && parentSymbol.valueDeclaration.kind === 246) { + if (parentSymbol.flags & 512 && parentSymbol.valueDeclaration.kind === 248) { return parentSymbol.valueDeclaration; } for (var n = node.parent; n; n = n.parent) { - if ((n.kind === 216 || n.kind === 215) && getSymbolOfNode(n) === parentSymbol) { + if ((n.kind === 218 || n.kind === 217) && getSymbolOfNode(n) === parentSymbol) { return n; } } @@ -21481,11 +21950,11 @@ var ts; } function isStatementWithLocals(node) { switch (node.kind) { - case 190: - case 218: - case 197: - case 198: + case 192: + case 220: case 199: + case 200: + case 201: return true; } return false; @@ -21511,22 +21980,22 @@ var ts; } function isValueAliasDeclaration(node) { switch (node.kind) { - case 219: case 221: - case 222: + case 223: case 224: - case 228: - return isAliasResolvedToValue(getSymbolOfNode(node)); case 226: + case 230: + return isAliasResolvedToValue(getSymbolOfNode(node)); + case 228: var exportClause = node.exportClause; return exportClause && ts.forEach(exportClause.elements, isValueAliasDeclaration); - case 225: - return node.expression && node.expression.kind === 67 ? isAliasResolvedToValue(getSymbolOfNode(node)) : true; + case 227: + return node.expression && node.expression.kind === 69 ? isAliasResolvedToValue(getSymbolOfNode(node)) : true; } return false; } function isTopLevelValueImportEqualsWithEntityName(node) { - if (node.parent.kind !== 246 || !ts.isInternalModuleImportEqualsDeclaration(node)) { + if (node.parent.kind !== 248 || !ts.isInternalModuleImportEqualsDeclaration(node)) { return false; } var isValue = isAliasResolvedToValue(getSymbolOfNode(node)); @@ -21574,7 +22043,7 @@ var ts; return getNodeLinks(node).enumMemberValue; } function getConstantValue(node) { - if (node.kind === 245) { + if (node.kind === 247) { return getEnumMemberValue(node); } var symbol = getNodeLinks(node).resolvedSymbol; @@ -21660,21 +22129,6 @@ var ts; var symbol = getReferencedValueSymbol(reference); return symbol && getExportSymbolOfValueSymbolIfExported(symbol).valueDeclaration; } - function getBlockScopedVariableId(n) { - ts.Debug.assert(!ts.nodeIsSynthesized(n)); - var isVariableDeclarationOrBindingElement = n.parent.kind === 161 || (n.parent.kind === 209 && n.parent.name === n); - var symbol = (isVariableDeclarationOrBindingElement ? getSymbolOfNode(n.parent) : undefined) || - getNodeLinks(n).resolvedSymbol || - resolveName(n, n.text, 107455 | 8388608, undefined, undefined); - var isLetOrConst = symbol && - (symbol.flags & 2) && - symbol.valueDeclaration.parent.kind !== 242; - if (isLetOrConst) { - getSymbolLinks(symbol); - return symbol.id; - } - return undefined; - } function instantiateSingleCallFunctionType(functionType, typeArguments) { if (functionType === unknownType) { return unknownType; @@ -21706,7 +22160,6 @@ var ts; isEntityNameVisible: isEntityNameVisible, getConstantValue: getConstantValue, collectLinkedAliases: collectLinkedAliases, - getBlockScopedVariableId: getBlockScopedVariableId, getReferencedValueDeclaration: getReferencedValueDeclaration, getTypeReferenceSerializationKind: getTypeReferenceSerializationKind, isOptionalParameter: isOptionalParameter @@ -21717,7 +22170,7 @@ var ts; ts.bindSourceFile(file); }); ts.forEach(host.getSourceFiles(), function (file) { - if (!ts.isExternalModule(file)) { + if (!ts.isExternalOrCommonJsModule(file)) { mergeSymbolTable(globals, file.locals); } }); @@ -21745,6 +22198,7 @@ var ts; getGlobalPromiseConstructorSymbol = ts.memoize(function () { return getGlobalValueSymbol("Promise"); }); getGlobalPromiseConstructorLikeType = ts.memoize(function () { return getGlobalType("PromiseConstructorLike"); }); getGlobalThenableType = ts.memoize(createThenableType); + cjsRequireType = getExportedTypeFromNamespace("CommonJS", "Require"); if (languageVersion >= 2) { globalTemplateStringsArrayType = getGlobalType("TemplateStringsArray"); globalESSymbolType = getGlobalType("Symbol"); @@ -21787,10 +22241,7 @@ var ts; if (!ts.nodeCanBeDecorated(node)) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Decorators_are_not_valid_here); } - else if (languageVersion < 1) { - return grammarErrorOnFirstToken(node, ts.Diagnostics.Decorators_are_only_available_when_targeting_ECMAScript_5_and_higher); - } - else if (node.kind === 143 || node.kind === 144) { + else if (node.kind === 145 || node.kind === 146) { var accessors = ts.getAllAccessorDeclarations(node.parent.members, node); if (accessors.firstAccessor.decorators && node === accessors.secondAccessor) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name); @@ -21800,38 +22251,38 @@ var ts; } function checkGrammarModifiers(node) { switch (node.kind) { - case 143: + case 145: + case 146: case 144: - case 142: - case 139: - case 138: case 141: case 140: - case 147: - case 216: - case 220: - case 219: - case 226: - case 225: - case 136: + case 143: + case 142: + case 149: + case 218: + case 222: + case 221: + case 228: + case 227: + case 138: break; - case 211: - if (node.modifiers && (node.modifiers.length > 1 || node.modifiers[0].kind !== 116) && - node.parent.kind !== 217 && node.parent.kind !== 246) { - return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); - } - break; - case 212: case 213: - case 191: - case 214: - if (node.modifiers && node.parent.kind !== 217 && node.parent.kind !== 246) { + if (node.modifiers && (node.modifiers.length > 1 || node.modifiers[0].kind !== 118) && + node.parent.kind !== 219 && node.parent.kind !== 248) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); } break; + case 214: case 215: - if (node.modifiers && (node.modifiers.length > 1 || node.modifiers[0].kind !== 72) && - node.parent.kind !== 217 && node.parent.kind !== 246) { + case 193: + case 216: + if (node.modifiers && node.parent.kind !== 219 && node.parent.kind !== 248) { + return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); + } + break; + case 217: + if (node.modifiers && (node.modifiers.length > 1 || node.modifiers[0].kind !== 74) && + node.parent.kind !== 219 && node.parent.kind !== 248) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); } break; @@ -21846,14 +22297,14 @@ var ts; for (var _i = 0, _a = node.modifiers; _i < _a.length; _i++) { var modifier = _a[_i]; switch (modifier.kind) { + case 112: + case 111: case 110: - case 109: - case 108: var text = void 0; - if (modifier.kind === 110) { + if (modifier.kind === 112) { text = "public"; } - else if (modifier.kind === 109) { + else if (modifier.kind === 111) { text = "protected"; lastProtected = modifier; } @@ -21870,11 +22321,11 @@ var ts; else if (flags & 512) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "async"); } - else if (node.parent.kind === 217 || node.parent.kind === 246) { + else if (node.parent.kind === 219 || node.parent.kind === 248) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_element, text); } else if (flags & 256) { - if (modifier.kind === 108) { + if (modifier.kind === 110) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, text, "abstract"); } else { @@ -21883,17 +22334,17 @@ var ts; } flags |= ts.modifierToFlag(modifier.kind); break; - case 111: + case 113: if (flags & 128) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "static"); } else if (flags & 512) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "static", "async"); } - else if (node.parent.kind === 217 || node.parent.kind === 246) { + else if (node.parent.kind === 219 || node.parent.kind === 248) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_element, "static"); } - else if (node.kind === 136) { + else if (node.kind === 138) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "static"); } else if (flags & 256) { @@ -21902,7 +22353,7 @@ var ts; flags |= 128; lastStatic = modifier; break; - case 80: + case 82: if (flags & 1) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "export"); } @@ -21915,42 +22366,42 @@ var ts; else if (flags & 512) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "async"); } - else if (node.parent.kind === 212) { + else if (node.parent.kind === 214) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "export"); } - else if (node.kind === 136) { + else if (node.kind === 138) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "export"); } flags |= 1; break; - case 120: + case 122: if (flags & 2) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "declare"); } else if (flags & 512) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); } - else if (node.parent.kind === 212) { + else if (node.parent.kind === 214) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "declare"); } - else if (node.kind === 136) { + else if (node.kind === 138) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "declare"); } - else if (ts.isInAmbientContext(node.parent) && node.parent.kind === 217) { + else if (ts.isInAmbientContext(node.parent) && node.parent.kind === 219) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_declare_modifier_cannot_be_used_in_an_already_ambient_context); } flags |= 2; lastDeclare = modifier; break; - case 113: + case 115: if (flags & 256) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "abstract"); } - if (node.kind !== 212) { - if (node.kind !== 141) { + if (node.kind !== 214) { + if (node.kind !== 143) { return grammarErrorOnNode(modifier, ts.Diagnostics.abstract_modifier_can_only_appear_on_a_class_or_method_declaration); } - if (!(node.parent.kind === 212 && node.parent.flags & 256)) { + if (!(node.parent.kind === 214 && node.parent.flags & 256)) { return grammarErrorOnNode(modifier, ts.Diagnostics.Abstract_methods_can_only_appear_within_an_abstract_class); } if (flags & 128) { @@ -21962,14 +22413,14 @@ var ts; } flags |= 256; break; - case 116: + case 118: if (flags & 512) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "async"); } else if (flags & 2 || ts.isInAmbientContext(node.parent)) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); } - else if (node.kind === 136) { + else if (node.kind === 138) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "async"); } flags |= 512; @@ -21977,7 +22428,7 @@ var ts; break; } } - if (node.kind === 142) { + if (node.kind === 144) { if (flags & 128) { return grammarErrorOnNode(lastStatic, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "static"); } @@ -21995,10 +22446,10 @@ var ts; } return; } - else if ((node.kind === 220 || node.kind === 219) && flags & 2) { + else if ((node.kind === 222 || node.kind === 221) && flags & 2) { return grammarErrorOnNode(lastDeclare, ts.Diagnostics.A_0_modifier_cannot_be_used_with_an_import_declaration, "declare"); } - else if (node.kind === 136 && (flags & 112) && ts.isBindingPattern(node.name)) { + else if (node.kind === 138 && (flags & 112) && ts.isBindingPattern(node.name)) { return grammarErrorOnNode(node, ts.Diagnostics.A_parameter_property_may_not_be_a_binding_pattern); } if (flags & 512) { @@ -22010,10 +22461,10 @@ var ts; return grammarErrorOnNode(asyncModifier, ts.Diagnostics.Async_functions_are_only_available_when_targeting_ECMAScript_6_and_higher); } switch (node.kind) { - case 141: - case 211: - case 171: - case 172: + case 143: + case 213: + case 173: + case 174: if (!node.asteriskToken) { return false; } @@ -22078,7 +22529,7 @@ var ts; checkGrammarParameterList(node.parameters) || checkGrammarArrowFunction(node, file); } function checkGrammarArrowFunction(node, file) { - if (node.kind === 172) { + if (node.kind === 174) { var arrowFunction = node; var startLine = ts.getLineAndCharacterOfPosition(file, arrowFunction.equalsGreaterThanToken.pos).line; var endLine = ts.getLineAndCharacterOfPosition(file, arrowFunction.equalsGreaterThanToken.end).line; @@ -22113,7 +22564,7 @@ var ts; if (!parameter.type) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_must_have_a_type_annotation); } - if (parameter.type.kind !== 128 && parameter.type.kind !== 126) { + if (parameter.type.kind !== 130 && parameter.type.kind !== 128) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_type_must_be_string_or_number); } if (!node.type) { @@ -22145,7 +22596,7 @@ var ts; var sourceFile = ts.getSourceFileOfNode(node); for (var _i = 0; _i < args.length; _i++) { var arg = args[_i]; - if (arg.kind === 185) { + if (arg.kind === 187) { return grammarErrorAtPos(sourceFile, arg.pos, 0, ts.Diagnostics.Argument_expression_expected); } } @@ -22172,7 +22623,7 @@ var ts; if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && node.heritageClauses) { for (var _i = 0, _a = node.heritageClauses; _i < _a.length; _i++) { var heritageClause = _a[_i]; - if (heritageClause.token === 81) { + if (heritageClause.token === 83) { if (seenExtendsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_already_seen); } @@ -22185,7 +22636,7 @@ var ts; seenExtendsClause = true; } else { - ts.Debug.assert(heritageClause.token === 104); + ts.Debug.assert(heritageClause.token === 106); if (seenImplementsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.implements_clause_already_seen); } @@ -22200,14 +22651,14 @@ var ts; if (node.heritageClauses) { for (var _i = 0, _a = node.heritageClauses; _i < _a.length; _i++) { var heritageClause = _a[_i]; - if (heritageClause.token === 81) { + if (heritageClause.token === 83) { if (seenExtendsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_already_seen); } seenExtendsClause = true; } else { - ts.Debug.assert(heritageClause.token === 104); + ts.Debug.assert(heritageClause.token === 106); return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.Interface_declaration_cannot_have_implements_clause); } checkGrammarHeritageClause(heritageClause); @@ -22216,19 +22667,19 @@ var ts; return false; } function checkGrammarComputedPropertyName(node) { - if (node.kind !== 134) { + if (node.kind !== 136) { return false; } var computedPropertyName = node; - if (computedPropertyName.expression.kind === 179 && computedPropertyName.expression.operatorToken.kind === 24) { + if (computedPropertyName.expression.kind === 181 && computedPropertyName.expression.operatorToken.kind === 24) { return grammarErrorOnNode(computedPropertyName.expression, ts.Diagnostics.A_comma_expression_is_not_allowed_in_a_computed_property_name); } } function checkGrammarForGenerator(node) { if (node.asteriskToken) { - ts.Debug.assert(node.kind === 211 || - node.kind === 171 || - node.kind === 141); + ts.Debug.assert(node.kind === 213 || + node.kind === 173 || + node.kind === 143); if (ts.isInAmbientContext(node)) { return grammarErrorOnNode(node.asteriskToken, ts.Diagnostics.Generators_are_not_allowed_in_an_ambient_context); } @@ -22245,7 +22696,7 @@ var ts; return grammarErrorOnNode(questionToken, message); } } - function checkGrammarObjectLiteralExpression(node) { + function checkGrammarObjectLiteralExpression(node, inDestructuring) { var seen = {}; var Property = 1; var GetAccessor = 2; @@ -22254,26 +22705,29 @@ var ts; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; var name_17 = prop.name; - if (prop.kind === 185 || - name_17.kind === 134) { + if (prop.kind === 187 || + name_17.kind === 136) { checkGrammarComputedPropertyName(name_17); continue; } + if (prop.kind === 246 && !inDestructuring && prop.objectAssignmentInitializer) { + return grammarErrorOnNode(prop.equalsToken, ts.Diagnostics.can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment); + } var currentKind = void 0; - if (prop.kind === 243 || prop.kind === 244) { + if (prop.kind === 245 || prop.kind === 246) { checkGrammarForInvalidQuestionMark(prop, prop.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional); if (name_17.kind === 8) { checkGrammarNumericLiteral(name_17); } currentKind = Property; } - else if (prop.kind === 141) { + else if (prop.kind === 143) { currentKind = Property; } - else if (prop.kind === 143) { + else if (prop.kind === 145) { currentKind = GetAccessor; } - else if (prop.kind === 144) { + else if (prop.kind === 146) { currentKind = SetAccesor; } else { @@ -22305,7 +22759,7 @@ var ts; var seen = {}; for (var _i = 0, _a = node.attributes; _i < _a.length; _i++) { var attr = _a[_i]; - if (attr.kind === 237) { + if (attr.kind === 239) { continue; } var jsxAttr = attr; @@ -22317,7 +22771,7 @@ var ts; return grammarErrorOnNode(name_18, ts.Diagnostics.JSX_elements_cannot_have_multiple_attributes_with_the_same_name); } var initializer = jsxAttr.initializer; - if (initializer && initializer.kind === 238 && !initializer.expression) { + if (initializer && initializer.kind === 240 && !initializer.expression) { return grammarErrorOnNode(jsxAttr.initializer, ts.Diagnostics.JSX_attributes_must_only_be_assigned_a_non_empty_expression); } } @@ -22326,24 +22780,24 @@ var ts; if (checkGrammarStatementInAmbientContext(forInOrOfStatement)) { return true; } - if (forInOrOfStatement.initializer.kind === 210) { + if (forInOrOfStatement.initializer.kind === 212) { var variableList = forInOrOfStatement.initializer; if (!checkGrammarVariableDeclarationList(variableList)) { if (variableList.declarations.length > 1) { - var diagnostic = forInOrOfStatement.kind === 198 + var diagnostic = forInOrOfStatement.kind === 200 ? ts.Diagnostics.Only_a_single_variable_declaration_is_allowed_in_a_for_in_statement : ts.Diagnostics.Only_a_single_variable_declaration_is_allowed_in_a_for_of_statement; return grammarErrorOnFirstToken(variableList.declarations[1], diagnostic); } var firstDeclaration = variableList.declarations[0]; if (firstDeclaration.initializer) { - var diagnostic = forInOrOfStatement.kind === 198 + var diagnostic = forInOrOfStatement.kind === 200 ? ts.Diagnostics.The_variable_declaration_of_a_for_in_statement_cannot_have_an_initializer : ts.Diagnostics.The_variable_declaration_of_a_for_of_statement_cannot_have_an_initializer; return grammarErrorOnNode(firstDeclaration.name, diagnostic); } if (firstDeclaration.type) { - var diagnostic = forInOrOfStatement.kind === 198 + var diagnostic = forInOrOfStatement.kind === 200 ? ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_use_a_type_annotation : ts.Diagnostics.The_left_hand_side_of_a_for_of_statement_cannot_use_a_type_annotation; return grammarErrorOnNode(firstDeclaration, diagnostic); @@ -22366,10 +22820,10 @@ var ts; else if (accessor.typeParameters) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.An_accessor_cannot_have_type_parameters); } - else if (kind === 143 && accessor.parameters.length) { + else if (kind === 145 && accessor.parameters.length) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_get_accessor_cannot_have_parameters); } - else if (kind === 144) { + else if (kind === 146) { if (accessor.type) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_set_accessor_cannot_have_a_return_type_annotation); } @@ -22394,7 +22848,7 @@ var ts; } } function checkGrammarForNonSymbolComputedProperty(node, message) { - if (node.kind === 134 && !ts.isWellKnownSymbolSyntactically(node.expression)) { + if (node.kind === 136 && !ts.isWellKnownSymbolSyntactically(node.expression)) { return grammarErrorOnNode(node, message); } } @@ -22404,7 +22858,7 @@ var ts; checkGrammarForGenerator(node)) { return true; } - if (node.parent.kind === 163) { + if (node.parent.kind === 165) { if (checkGrammarForInvalidQuestionMark(node, node.questionToken, ts.Diagnostics.A_class_member_cannot_be_declared_optional)) { return true; } @@ -22423,22 +22877,22 @@ var ts; return checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_method_overload_must_directly_refer_to_a_built_in_symbol); } } - else if (node.parent.kind === 213) { + else if (node.parent.kind === 215) { return checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_an_interface_must_directly_refer_to_a_built_in_symbol); } - else if (node.parent.kind === 153) { + else if (node.parent.kind === 155) { return checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_type_literal_must_directly_refer_to_a_built_in_symbol); } } function isIterationStatement(node, lookInLabeledStatements) { switch (node.kind) { + case 199: + case 200: + case 201: case 197: case 198: - case 199: - case 195: - case 196: return true; - case 205: + case 207: return lookInLabeledStatements && isIterationStatement(node.statement, lookInLabeledStatements); } return false; @@ -22450,9 +22904,9 @@ var ts; return grammarErrorOnNode(node, ts.Diagnostics.Jump_target_cannot_cross_function_boundary); } switch (current.kind) { - case 205: + case 207: if (node.label && current.label.text === node.label.text) { - var isMisplacedContinueLabel = node.kind === 200 + var isMisplacedContinueLabel = node.kind === 202 && !isIterationStatement(current.statement, true); if (isMisplacedContinueLabel) { return grammarErrorOnNode(node, ts.Diagnostics.A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement); @@ -22460,8 +22914,8 @@ var ts; return false; } break; - case 204: - if (node.kind === 201 && !node.label) { + case 206: + if (node.kind === 203 && !node.label) { return false; } break; @@ -22474,13 +22928,13 @@ var ts; current = current.parent; } if (node.label) { - var message = node.kind === 201 + var message = node.kind === 203 ? ts.Diagnostics.A_break_statement_can_only_jump_to_a_label_of_an_enclosing_statement : ts.Diagnostics.A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement; return grammarErrorOnNode(node, message); } else { - var message = node.kind === 201 + var message = node.kind === 203 ? ts.Diagnostics.A_break_statement_can_only_be_used_within_an_enclosing_iteration_or_switch_statement : ts.Diagnostics.A_continue_statement_can_only_be_used_within_an_enclosing_iteration_statement; return grammarErrorOnNode(node, message); @@ -22492,7 +22946,7 @@ var ts; if (node !== ts.lastOrUndefined(elements)) { return grammarErrorOnNode(node, ts.Diagnostics.A_rest_element_must_be_last_in_an_array_destructuring_pattern); } - if (node.name.kind === 160 || node.name.kind === 159) { + if (node.name.kind === 162 || node.name.kind === 161) { return grammarErrorOnNode(node.name, ts.Diagnostics.A_rest_element_cannot_contain_a_binding_pattern); } if (node.initializer) { @@ -22501,7 +22955,7 @@ var ts; } } function checkGrammarVariableDeclaration(node) { - if (node.parent.parent.kind !== 198 && node.parent.parent.kind !== 199) { + if (node.parent.parent.kind !== 200 && node.parent.parent.kind !== 201) { if (ts.isInAmbientContext(node)) { if (node.initializer) { var equalsTokenLength = "=".length; @@ -22521,7 +22975,7 @@ var ts; return checkLetConstNames && checkGrammarNameInLetOrConstDeclarations(node.name); } function checkGrammarNameInLetOrConstDeclarations(name) { - if (name.kind === 67) { + if (name.kind === 69) { if (name.text === "let") { return grammarErrorOnNode(name, ts.Diagnostics.let_is_not_allowed_to_be_used_as_a_name_in_let_or_const_declarations); } @@ -22530,7 +22984,7 @@ var ts; var elements = name.elements; for (var _i = 0; _i < elements.length; _i++) { var element = elements[_i]; - if (element.kind !== 185) { + if (element.kind !== 187) { checkGrammarNameInLetOrConstDeclarations(element.name); } } @@ -22547,15 +23001,15 @@ var ts; } function allowLetAndConstDeclarations(parent) { switch (parent.kind) { - case 194: - case 195: case 196: - case 203: case 197: case 198: - case 199: - return false; case 205: + case 199: + case 200: + case 201: + return false; + case 207: return allowLetAndConstDeclarations(parent.parent); } return true; @@ -22571,7 +23025,7 @@ var ts; } } function isIntegerLiteral(expression) { - if (expression.kind === 177) { + if (expression.kind === 179) { var unaryExpression = expression; if (unaryExpression.operator === 35 || unaryExpression.operator === 36) { expression = unaryExpression.operand; @@ -22582,32 +23036,6 @@ var ts; } return false; } - function checkGrammarEnumDeclaration(enumDecl) { - var enumIsConst = (enumDecl.flags & 32768) !== 0; - var hasError = false; - if (!enumIsConst) { - var inConstantEnumMemberSection = true; - var inAmbientContext = ts.isInAmbientContext(enumDecl); - for (var _i = 0, _a = enumDecl.members; _i < _a.length; _i++) { - var node = _a[_i]; - if (node.name.kind === 134) { - hasError = grammarErrorOnNode(node.name, ts.Diagnostics.Computed_property_names_are_not_allowed_in_enums); - } - else if (inAmbientContext) { - if (node.initializer && !isIntegerLiteral(node.initializer)) { - hasError = grammarErrorOnNode(node.name, ts.Diagnostics.Ambient_enum_elements_can_only_have_integer_literal_initializers) || hasError; - } - } - else if (node.initializer) { - inConstantEnumMemberSection = isIntegerLiteral(node.initializer); - } - else if (!inConstantEnumMemberSection) { - hasError = grammarErrorOnNode(node.name, ts.Diagnostics.Enum_member_must_have_initializer) || hasError; - } - } - } - return hasError; - } function hasParseDiagnostics(sourceFile) { return sourceFile.parseDiagnostics.length > 0; } @@ -22633,7 +23061,7 @@ var ts; } } function isEvalOrArgumentsIdentifier(node) { - return node.kind === 67 && + return node.kind === 69 && (node.text === "eval" || node.text === "arguments"); } function checkGrammarConstructorTypeParameters(node) { @@ -22653,12 +23081,12 @@ var ts; return true; } } - else if (node.parent.kind === 213) { + else if (node.parent.kind === 215) { if (checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_an_interface_must_directly_refer_to_a_built_in_symbol)) { return true; } } - else if (node.parent.kind === 153) { + else if (node.parent.kind === 155) { if (checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_type_literal_must_directly_refer_to_a_built_in_symbol)) { return true; } @@ -22668,11 +23096,11 @@ var ts; } } function checkGrammarTopLevelElementForRequiredDeclareModifier(node) { - if (node.kind === 213 || - node.kind === 220 || - node.kind === 219 || - node.kind === 226 || - node.kind === 225 || + if (node.kind === 215 || + node.kind === 222 || + node.kind === 221 || + node.kind === 228 || + node.kind === 227 || (node.flags & 2) || (node.flags & (1 | 1024))) { return false; @@ -22682,7 +23110,7 @@ var ts; function checkGrammarTopLevelElementsForRequiredDeclareModifier(file) { for (var _i = 0, _a = file.statements; _i < _a.length; _i++) { var decl = _a[_i]; - if (ts.isDeclaration(decl) || decl.kind === 191) { + if (ts.isDeclaration(decl) || decl.kind === 193) { if (checkGrammarTopLevelElementForRequiredDeclareModifier(decl)) { return true; } @@ -22701,7 +23129,7 @@ var ts; if (!links.hasReportedStatementInAmbientContext && ts.isFunctionLike(node.parent)) { return getNodeLinks(node).hasReportedStatementInAmbientContext = grammarErrorOnFirstToken(node, ts.Diagnostics.An_implementation_cannot_be_declared_in_ambient_contexts); } - if (node.parent.kind === 190 || node.parent.kind === 217 || node.parent.kind === 246) { + if (node.parent.kind === 192 || node.parent.kind === 219 || node.parent.kind === 248) { var links_1 = getNodeLinks(node.parent); if (!links_1.hasReportedStatementInAmbientContext) { return links_1.hasReportedStatementInAmbientContext = grammarErrorOnFirstToken(node, ts.Diagnostics.Statements_are_not_allowed_in_ambient_contexts); @@ -22748,6 +23176,7 @@ var ts; var enclosingDeclaration; var currentSourceFile; var reportedDeclarationError = false; + var errorNameNode; var emitJsDocComments = compilerOptions.removeComments ? function (declaration) { } : writeJsDocComments; var emit = compilerOptions.stripInternal ? stripInternal : emitNode; var moduleElementDeclarationEmitInfo = []; @@ -22773,7 +23202,7 @@ var ts; var oldWriter = writer; ts.forEach(moduleElementDeclarationEmitInfo, function (aliasEmitInfo) { if (aliasEmitInfo.isVisible) { - ts.Debug.assert(aliasEmitInfo.node.kind === 220); + ts.Debug.assert(aliasEmitInfo.node.kind === 222); createAndSetNewTextWriterWithSymbolWriter(); ts.Debug.assert(aliasEmitInfo.indent === 0); writeImportDeclaration(aliasEmitInfo.node); @@ -22824,6 +23253,7 @@ var ts; function createAndSetNewTextWriterWithSymbolWriter() { var writer = ts.createTextWriter(newLine); writer.trackSymbol = trackSymbol; + writer.reportInaccessibleThisError = reportInaccessibleThisError; writer.writeKeyword = writer.write; writer.writeOperator = writer.write; writer.writePunctuation = writer.write; @@ -22846,10 +23276,10 @@ var ts; var oldWriter = writer; ts.forEach(nodes, function (declaration) { var nodeToCheck; - if (declaration.kind === 209) { + if (declaration.kind === 211) { nodeToCheck = declaration.parent.parent; } - else if (declaration.kind === 223 || declaration.kind === 224 || declaration.kind === 221) { + else if (declaration.kind === 225 || declaration.kind === 226 || declaration.kind === 223) { ts.Debug.fail("We should be getting ImportDeclaration instead to write"); } else { @@ -22860,7 +23290,7 @@ var ts; moduleElementEmitInfo = ts.forEach(asynchronousSubModuleDeclarationEmitInfo, function (declEmitInfo) { return declEmitInfo.node === nodeToCheck ? declEmitInfo : undefined; }); } if (moduleElementEmitInfo) { - if (moduleElementEmitInfo.node.kind === 220) { + if (moduleElementEmitInfo.node.kind === 222) { moduleElementEmitInfo.isVisible = true; } else { @@ -22868,12 +23298,12 @@ var ts; for (var declarationIndent = moduleElementEmitInfo.indent; declarationIndent; declarationIndent--) { increaseIndent(); } - if (nodeToCheck.kind === 216) { + if (nodeToCheck.kind === 218) { ts.Debug.assert(asynchronousSubModuleDeclarationEmitInfo === undefined); asynchronousSubModuleDeclarationEmitInfo = []; } writeModuleElement(nodeToCheck); - if (nodeToCheck.kind === 216) { + if (nodeToCheck.kind === 218) { moduleElementEmitInfo.subModuleElementDeclarationEmitInfo = asynchronousSubModuleDeclarationEmitInfo; asynchronousSubModuleDeclarationEmitInfo = undefined; } @@ -22905,6 +23335,11 @@ var ts; function trackSymbol(symbol, enclosingDeclaration, meaning) { handleSymbolAccessibilityError(resolver.isSymbolAccessible(symbol, enclosingDeclaration, meaning)); } + function reportInaccessibleThisError() { + if (errorNameNode) { + diagnostics.push(ts.createDiagnosticForNode(errorNameNode, ts.Diagnostics.The_inferred_type_of_0_references_an_inaccessible_this_type_A_type_annotation_is_necessary, ts.declarationNameToString(errorNameNode))); + } + } function writeTypeOfDeclaration(declaration, type, getSymbolAccessibilityDiagnostic) { writer.getSymbolAccessibilityDiagnostic = getSymbolAccessibilityDiagnostic; write(": "); @@ -22912,7 +23347,9 @@ var ts; emitType(type); } else { + errorNameNode = declaration.name; resolver.writeTypeOfDeclaration(declaration, enclosingDeclaration, 2, writer); + errorNameNode = undefined; } } function writeReturnTypeAtSignature(signature, getSymbolAccessibilityDiagnostic) { @@ -22922,7 +23359,9 @@ var ts; emitType(signature.type); } else { + errorNameNode = signature.name; resolver.writeReturnTypeOfSignatureDeclaration(signature, enclosingDeclaration, 2, writer); + errorNameNode = undefined; } } function emitLines(nodes) { @@ -22960,62 +23399,63 @@ var ts; } function emitType(type) { switch (type.kind) { - case 115: + case 117: + case 130: case 128: - case 126: - case 118: - case 129: - case 101: + case 120: + case 131: + case 103: + case 97: case 9: return writeTextOfNode(currentSourceFile, type); - case 186: + case 188: return emitExpressionWithTypeArguments(type); - case 149: - return emitTypeReference(type); - case 152: - return emitTypeQuery(type); - case 154: - return emitArrayType(type); - case 155: - return emitTupleType(type); - case 156: - return emitUnionType(type); - case 157: - return emitIntersectionType(type); - case 158: - return emitParenType(type); - case 150: case 151: - return emitSignatureDeclarationWithJsDocComments(type); + return emitTypeReference(type); + case 154: + return emitTypeQuery(type); + case 156: + return emitArrayType(type); + case 157: + return emitTupleType(type); + case 158: + return emitUnionType(type); + case 159: + return emitIntersectionType(type); + case 160: + return emitParenType(type); + case 152: case 153: + return emitSignatureDeclarationWithJsDocComments(type); + case 155: return emitTypeLiteral(type); - case 67: + case 69: return emitEntityName(type); - case 133: + case 135: return emitEntityName(type); - case 148: + case 150: return emitTypePredicate(type); } function writeEntityName(entityName) { - if (entityName.kind === 67) { + if (entityName.kind === 69) { writeTextOfNode(currentSourceFile, entityName); } else { - var left = entityName.kind === 133 ? entityName.left : entityName.expression; - var right = entityName.kind === 133 ? entityName.right : entityName.name; + var left = entityName.kind === 135 ? entityName.left : entityName.expression; + var right = entityName.kind === 135 ? entityName.right : entityName.name; writeEntityName(left); write("."); writeTextOfNode(currentSourceFile, right); } } function emitEntityName(entityName) { - var visibilityResult = resolver.isEntityNameVisible(entityName, entityName.parent.kind === 219 ? entityName.parent : enclosingDeclaration); + var visibilityResult = resolver.isEntityNameVisible(entityName, entityName.parent.kind === 221 ? entityName.parent : enclosingDeclaration); handleSymbolAccessibilityError(visibilityResult); writeEntityName(entityName); } function emitExpressionWithTypeArguments(node) { if (ts.isSupportedExpressionWithTypeArguments(node)) { - ts.Debug.assert(node.expression.kind === 67 || node.expression.kind === 164); + ts.Debug.assert(node.expression.kind === 69 || node.expression.kind === 166); emitEntityName(node.expression); if (node.typeArguments) { write("<"); @@ -23091,7 +23531,7 @@ var ts; } } function emitExportAssignment(node) { - if (node.expression.kind === 67) { + if (node.expression.kind === 69) { write(node.isExportEquals ? "export = " : "export default "); writeTextOfNode(currentSourceFile, node.expression); } @@ -23109,7 +23549,7 @@ var ts; } write(";"); writeLine(); - if (node.expression.kind === 67) { + if (node.expression.kind === 69) { var nodes = resolver.collectLinkedAliases(node.expression); writeAsynchronousModuleElements(nodes); } @@ -23127,10 +23567,10 @@ var ts; if (isModuleElementVisible) { writeModuleElement(node); } - else if (node.kind === 219 || - (node.parent.kind === 246 && ts.isExternalModule(currentSourceFile))) { + else if (node.kind === 221 || + (node.parent.kind === 248 && ts.isExternalModule(currentSourceFile))) { var isVisible; - if (asynchronousSubModuleDeclarationEmitInfo && node.parent.kind !== 246) { + if (asynchronousSubModuleDeclarationEmitInfo && node.parent.kind !== 248) { asynchronousSubModuleDeclarationEmitInfo.push({ node: node, outputPos: writer.getTextPos(), @@ -23139,7 +23579,7 @@ var ts; }); } else { - if (node.kind === 220) { + if (node.kind === 222) { var importDeclaration = node; if (importDeclaration.importClause) { isVisible = (importDeclaration.importClause.name && resolver.isDeclarationVisible(importDeclaration.importClause)) || @@ -23157,23 +23597,23 @@ var ts; } function writeModuleElement(node) { switch (node.kind) { - case 211: - return writeFunctionDeclaration(node); - case 191: - return writeVariableStatement(node); case 213: - return writeInterfaceDeclaration(node); - case 212: - return writeClassDeclaration(node); - case 214: - return writeTypeAliasDeclaration(node); + return writeFunctionDeclaration(node); + case 193: + return writeVariableStatement(node); case 215: - return writeEnumDeclaration(node); + return writeInterfaceDeclaration(node); + case 214: + return writeClassDeclaration(node); case 216: + return writeTypeAliasDeclaration(node); + case 217: + return writeEnumDeclaration(node); + case 218: return writeModuleDeclaration(node); - case 219: + case 221: return writeImportEqualsDeclaration(node); - case 220: + case 222: return writeImportDeclaration(node); default: ts.Debug.fail("Unknown symbol kind"); @@ -23187,7 +23627,7 @@ var ts; if (node.flags & 1024) { write("default "); } - else if (node.kind !== 213) { + else if (node.kind !== 215) { write("declare "); } } @@ -23234,7 +23674,7 @@ var ts; } function isVisibleNamedBinding(namedBindings) { if (namedBindings) { - if (namedBindings.kind === 222) { + if (namedBindings.kind === 224) { return resolver.isDeclarationVisible(namedBindings); } else { @@ -23260,7 +23700,7 @@ var ts; if (currentWriterPos !== writer.getTextPos()) { write(", "); } - if (node.importClause.namedBindings.kind === 222) { + if (node.importClause.namedBindings.kind === 224) { write("* as "); writeTextOfNode(currentSourceFile, node.importClause.namedBindings.name); } @@ -23316,7 +23756,7 @@ var ts; write("module "); } writeTextOfNode(currentSourceFile, node.name); - while (node.body.kind !== 217) { + while (node.body.kind !== 219) { node = node.body; write("."); writeTextOfNode(currentSourceFile, node.name); @@ -23381,7 +23821,7 @@ var ts; writeLine(); } function isPrivateMethodTypeParameter(node) { - return node.parent.kind === 141 && (node.parent.flags & 32); + return node.parent.kind === 143 && (node.parent.flags & 32); } function emitTypeParameters(typeParameters) { function emitTypeParameter(node) { @@ -23391,15 +23831,15 @@ var ts; writeTextOfNode(currentSourceFile, node.name); if (node.constraint && !isPrivateMethodTypeParameter(node)) { write(" extends "); - if (node.parent.kind === 150 || - node.parent.kind === 151 || - (node.parent.parent && node.parent.parent.kind === 153)) { - ts.Debug.assert(node.parent.kind === 141 || - node.parent.kind === 140 || - node.parent.kind === 150 || - node.parent.kind === 151 || - node.parent.kind === 145 || - node.parent.kind === 146); + if (node.parent.kind === 152 || + node.parent.kind === 153 || + (node.parent.parent && node.parent.parent.kind === 155)) { + ts.Debug.assert(node.parent.kind === 143 || + node.parent.kind === 142 || + node.parent.kind === 152 || + node.parent.kind === 153 || + node.parent.kind === 147 || + node.parent.kind === 148); emitType(node.constraint); } else { @@ -23409,31 +23849,31 @@ var ts; function getTypeParameterConstraintVisibilityError(symbolAccesibilityResult) { var diagnosticMessage; switch (node.parent.kind) { - case 212: + case 214: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_class_has_or_is_using_private_name_1; break; - case 213: + case 215: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1; break; - case 146: + case 148: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 145: + case 147: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 141: - case 140: + case 143: + case 142: if (node.parent.flags & 128) { diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.parent.kind === 212) { + else if (node.parent.parent.kind === 214) { diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_public_method_from_exported_class_has_or_is_using_private_name_1; } else { diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1; } break; - case 211: + case 213: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_function_has_or_is_using_private_name_1; break; default: @@ -23461,12 +23901,12 @@ var ts; if (ts.isSupportedExpressionWithTypeArguments(node)) { emitTypeWithNewGetSymbolAccessibilityDiagnostic(node, getHeritageClauseVisibilityError); } - else if (!isImplementsList && node.expression.kind === 91) { + else if (!isImplementsList && node.expression.kind === 93) { write("null"); } function getHeritageClauseVisibilityError(symbolAccesibilityResult) { var diagnosticMessage; - if (node.parent.parent.kind === 212) { + if (node.parent.parent.kind === 214) { diagnosticMessage = isImplementsList ? ts.Diagnostics.Implements_clause_of_exported_class_0_has_or_is_using_private_name_1 : ts.Diagnostics.Extends_clause_of_exported_class_0_has_or_is_using_private_name_1; @@ -23546,16 +23986,16 @@ var ts; writeLine(); } function emitVariableDeclaration(node) { - if (node.kind !== 209 || resolver.isDeclarationVisible(node)) { + if (node.kind !== 211 || resolver.isDeclarationVisible(node)) { if (ts.isBindingPattern(node.name)) { emitBindingPattern(node.name); } else { writeTextOfNode(currentSourceFile, node.name); - if ((node.kind === 139 || node.kind === 138) && ts.hasQuestionToken(node)) { + if ((node.kind === 141 || node.kind === 140) && ts.hasQuestionToken(node)) { write("?"); } - if ((node.kind === 139 || node.kind === 138) && node.parent.kind === 153) { + if ((node.kind === 141 || node.kind === 140) && node.parent.kind === 155) { emitTypeOfVariableDeclarationFromTypeLiteral(node); } else if (!(node.flags & 32)) { @@ -23564,14 +24004,14 @@ var ts; } } function getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccesibilityResult) { - if (node.kind === 209) { + if (node.kind === 211) { return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 ? ts.Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Exported_variable_0_has_or_is_using_private_name_1; } - else if (node.kind === 139 || node.kind === 138) { + else if (node.kind === 141 || node.kind === 140) { if (node.flags & 128) { return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 ? @@ -23579,7 +24019,7 @@ var ts; ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.kind === 212) { + else if (node.parent.kind === 214) { return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 ? ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -23605,7 +24045,7 @@ var ts; var elements = []; for (var _i = 0, _a = bindingPattern.elements; _i < _a.length; _i++) { var element = _a[_i]; - if (element.kind !== 185) { + if (element.kind !== 187) { elements.push(element); } } @@ -23671,7 +24111,7 @@ var ts; accessorWithTypeAnnotation = node; var type = getTypeAnnotationFromAccessor(node); if (!type) { - var anotherAccessor = node.kind === 143 ? accessors.setAccessor : accessors.getAccessor; + var anotherAccessor = node.kind === 145 ? accessors.setAccessor : accessors.getAccessor; type = getTypeAnnotationFromAccessor(anotherAccessor); if (type) { accessorWithTypeAnnotation = anotherAccessor; @@ -23684,7 +24124,7 @@ var ts; } function getTypeAnnotationFromAccessor(accessor) { if (accessor) { - return accessor.kind === 143 + return accessor.kind === 145 ? accessor.type : accessor.parameters.length > 0 ? accessor.parameters[0].type @@ -23693,7 +24133,7 @@ var ts; } function getAccessorDeclarationTypeVisibilityError(symbolAccesibilityResult) { var diagnosticMessage; - if (accessorWithTypeAnnotation.kind === 144) { + if (accessorWithTypeAnnotation.kind === 146) { if (accessorWithTypeAnnotation.parent.flags & 128) { diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_public_static_property_setter_from_exported_class_has_or_is_using_name_1_from_private_module_2 : @@ -23739,17 +24179,17 @@ var ts; } if (!resolver.isImplementationOfOverload(node)) { emitJsDocComments(node); - if (node.kind === 211) { + if (node.kind === 213) { emitModuleElementDeclarationFlags(node); } - else if (node.kind === 141) { + else if (node.kind === 143) { emitClassMemberDeclarationFlags(node); } - if (node.kind === 211) { + if (node.kind === 213) { write("function "); writeTextOfNode(currentSourceFile, node.name); } - else if (node.kind === 142) { + else if (node.kind === 144) { write("constructor"); } else { @@ -23766,11 +24206,11 @@ var ts; emitSignatureDeclaration(node); } function emitSignatureDeclaration(node) { - if (node.kind === 146 || node.kind === 151) { + if (node.kind === 148 || node.kind === 153) { write("new "); } emitTypeParameters(node.typeParameters); - if (node.kind === 147) { + if (node.kind === 149) { write("["); } else { @@ -23779,20 +24219,20 @@ var ts; var prevEnclosingDeclaration = enclosingDeclaration; enclosingDeclaration = node; emitCommaList(node.parameters, emitParameterDeclaration); - if (node.kind === 147) { + if (node.kind === 149) { write("]"); } else { write(")"); } - var isFunctionTypeOrConstructorType = node.kind === 150 || node.kind === 151; - if (isFunctionTypeOrConstructorType || node.parent.kind === 153) { + var isFunctionTypeOrConstructorType = node.kind === 152 || node.kind === 153; + if (isFunctionTypeOrConstructorType || node.parent.kind === 155) { if (node.type) { write(isFunctionTypeOrConstructorType ? " => " : ": "); emitType(node.type); } } - else if (node.kind !== 142 && !(node.flags & 32)) { + else if (node.kind !== 144 && !(node.flags & 32)) { writeReturnTypeAtSignature(node, getReturnTypeVisibilityError); } enclosingDeclaration = prevEnclosingDeclaration; @@ -23803,23 +24243,23 @@ var ts; function getReturnTypeVisibilityError(symbolAccesibilityResult) { var diagnosticMessage; switch (node.kind) { - case 146: + case 148: diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_0; break; - case 145: + case 147: diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_call_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_call_signature_from_exported_interface_has_or_is_using_private_name_0; break; - case 147: + case 149: diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_index_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_index_signature_from_exported_interface_has_or_is_using_private_name_0; break; - case 141: - case 140: + case 143: + case 142: if (node.flags & 128) { diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 ? @@ -23827,7 +24267,7 @@ var ts; ts.Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_private_name_0; } - else if (node.parent.kind === 212) { + else if (node.parent.kind === 214) { diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 ? ts.Diagnostics.Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : @@ -23840,7 +24280,7 @@ var ts; ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0; } break; - case 211: + case 213: diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 ? ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : @@ -23872,9 +24312,9 @@ var ts; write("?"); } decreaseIndent(); - if (node.parent.kind === 150 || - node.parent.kind === 151 || - node.parent.parent.kind === 153) { + if (node.parent.kind === 152 || + node.parent.kind === 153 || + node.parent.parent.kind === 155) { emitTypeOfVariableDeclarationFromTypeLiteral(node); } else if (!(node.parent.flags & 32)) { @@ -23890,22 +24330,22 @@ var ts; } function getParameterDeclarationTypeVisibilityDiagnosticMessage(symbolAccesibilityResult) { switch (node.parent.kind) { - case 142: + case 144: return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 ? ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_private_name_1; - case 146: + case 148: return symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; - case 145: + case 147: return symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; - case 141: - case 140: + case 143: + case 142: if (node.parent.flags & 128) { return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 ? @@ -23913,7 +24353,7 @@ var ts; ts.Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.parent.kind === 212) { + else if (node.parent.parent.kind === 214) { return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 ? ts.Diagnostics.Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -23925,7 +24365,7 @@ var ts; ts.Diagnostics.Parameter_0_of_method_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1; } - case 211: + case 213: return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 ? ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -23936,12 +24376,12 @@ var ts; } } function emitBindingPattern(bindingPattern) { - if (bindingPattern.kind === 159) { + if (bindingPattern.kind === 161) { write("{"); emitCommaList(bindingPattern.elements, emitBindingElement); write("}"); } - else if (bindingPattern.kind === 160) { + else if (bindingPattern.kind === 162) { write("["); var elements = bindingPattern.elements; emitCommaList(elements, emitBindingElement); @@ -23960,10 +24400,10 @@ var ts; typeName: bindingElement.name } : undefined; } - if (bindingElement.kind === 185) { + if (bindingElement.kind === 187) { write(" "); } - else if (bindingElement.kind === 161) { + else if (bindingElement.kind === 163) { if (bindingElement.propertyName) { writeTextOfNode(currentSourceFile, bindingElement.propertyName); write(": "); @@ -23973,7 +24413,7 @@ var ts; emitBindingPattern(bindingElement.name); } else { - ts.Debug.assert(bindingElement.name.kind === 67); + ts.Debug.assert(bindingElement.name.kind === 69); if (bindingElement.dotDotDotToken) { write("..."); } @@ -23985,39 +24425,39 @@ var ts; } function emitNode(node) { switch (node.kind) { - case 211: - case 216: - case 219: case 213: - case 212: - case 214: + case 218: + case 221: case 215: + case 214: + case 216: + case 217: return emitModuleElement(node, isModuleElementVisible(node)); - case 191: + case 193: return emitModuleElement(node, isVariableStatementVisible(node)); - case 220: + case 222: return emitModuleElement(node, !node.importClause); - case 226: + case 228: return emitExportDeclaration(node); + case 144: + case 143: case 142: + return writeFunctionDeclaration(node); + case 148: + case 147: + case 149: + return emitSignatureDeclarationWithJsDocComments(node); + case 145: + case 146: + return emitAccessorDeclaration(node); case 141: case 140: - return writeFunctionDeclaration(node); - case 146: - case 145: - case 147: - return emitSignatureDeclarationWithJsDocComments(node); - case 143: - case 144: - return emitAccessorDeclaration(node); - case 139: - case 138: return emitPropertyDeclaration(node); - case 245: + case 247: return emitEnumMemberDeclaration(node); - case 225: + case 227: return emitExportAssignment(node); - case 246: + case 248: return emitSourceFile(node); } } @@ -24060,5471 +24500,6 @@ var ts; return ts.isExternalModule(sourceFile) || ts.isDeclarationFile(sourceFile); } ts.isExternalModuleOrDeclarationFile = isExternalModuleOrDeclarationFile; - function emitFiles(resolver, host, targetSourceFile) { - var extendsHelper = "\nvar __extends = (this && this.__extends) || function (d, b) {\n for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];\n function __() { this.constructor = d; }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n};"; - var decorateHelper = "\nvar __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") return Reflect.decorate(decorators, target, key, desc);\n switch (arguments.length) {\n case 2: return decorators.reduceRight(function(o, d) { return (d && d(o)) || o; }, target);\n case 3: return decorators.reduceRight(function(o, d) { return (d && d(target, key)), void 0; }, void 0);\n case 4: return decorators.reduceRight(function(o, d) { return (d && d(target, key, o)) || o; }, desc);\n }\n};"; - var metadataHelper = "\nvar __metadata = (this && this.__metadata) || function (k, v) {\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(k, v);\n};"; - var paramHelper = "\nvar __param = (this && this.__param) || function (paramIndex, decorator) {\n return function (target, key) { decorator(target, key, paramIndex); }\n};"; - var awaiterHelper = "\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promise, generator) {\n return new Promise(function (resolve, reject) {\n generator = generator.call(thisArg, _arguments);\n function cast(value) { return value instanceof Promise && value.constructor === Promise ? value : new Promise(function (resolve) { resolve(value); }); }\n function onfulfill(value) { try { step(\"next\", value); } catch (e) { reject(e); } }\n function onreject(value) { try { step(\"throw\", value); } catch (e) { reject(e); } }\n function step(verb, value) {\n var result = generator[verb](value);\n result.done ? resolve(result.value) : cast(result.value).then(onfulfill, onreject);\n }\n step(\"next\", void 0);\n });\n};"; - var compilerOptions = host.getCompilerOptions(); - var languageVersion = compilerOptions.target || 0; - var sourceMapDataList = compilerOptions.sourceMap || compilerOptions.inlineSourceMap ? [] : undefined; - var diagnostics = []; - var newLine = host.getNewLine(); - var jsxDesugaring = host.getCompilerOptions().jsx !== 1; - var shouldEmitJsx = function (s) { return (s.languageVariant === 1 && !jsxDesugaring); }; - if (targetSourceFile === undefined) { - ts.forEach(host.getSourceFiles(), function (sourceFile) { - if (ts.shouldEmitToOwnFile(sourceFile, compilerOptions)) { - var jsFilePath = ts.getOwnEmitOutputFilePath(sourceFile, host, shouldEmitJsx(sourceFile) ? ".jsx" : ".js"); - emitFile(jsFilePath, sourceFile); - } - }); - if (compilerOptions.outFile || compilerOptions.out) { - emitFile(compilerOptions.outFile || compilerOptions.out); - } - } - else { - if (ts.shouldEmitToOwnFile(targetSourceFile, compilerOptions)) { - var jsFilePath = ts.getOwnEmitOutputFilePath(targetSourceFile, host, shouldEmitJsx(targetSourceFile) ? ".jsx" : ".js"); - emitFile(jsFilePath, targetSourceFile); - } - else if (!ts.isDeclarationFile(targetSourceFile) && (compilerOptions.outFile || compilerOptions.out)) { - emitFile(compilerOptions.outFile || compilerOptions.out); - } - } - diagnostics = ts.sortAndDeduplicateDiagnostics(diagnostics); - return { - emitSkipped: false, - diagnostics: diagnostics, - sourceMaps: sourceMapDataList - }; - function isNodeDescendentOf(node, ancestor) { - while (node) { - if (node === ancestor) - return true; - node = node.parent; - } - return false; - } - function isUniqueLocalName(name, container) { - for (var node = container; isNodeDescendentOf(node, container); node = node.nextContainer) { - if (node.locals && ts.hasProperty(node.locals, name)) { - if (node.locals[name].flags & (107455 | 1048576 | 8388608)) { - return false; - } - } - } - return true; - } - function emitJavaScript(jsFilePath, root) { - var writer = ts.createTextWriter(newLine); - var write = writer.write, writeTextOfNode = writer.writeTextOfNode, writeLine = writer.writeLine, increaseIndent = writer.increaseIndent, decreaseIndent = writer.decreaseIndent; - var currentSourceFile; - var exportFunctionForFile; - var generatedNameSet = {}; - var nodeToGeneratedName = []; - var computedPropertyNamesToGeneratedNames; - var extendsEmitted = false; - var decorateEmitted = false; - var paramEmitted = false; - var awaiterEmitted = false; - var tempFlags = 0; - var tempVariables; - var tempParameters; - var externalImports; - var exportSpecifiers; - var exportEquals; - var hasExportStars; - var writeEmittedFiles = writeJavaScriptFile; - var detachedCommentsInfo; - var writeComment = ts.writeCommentRange; - var emit = emitNodeWithCommentsAndWithoutSourcemap; - var emitStart = function (node) { }; - var emitEnd = function (node) { }; - var emitToken = emitTokenText; - var scopeEmitStart = function (scopeDeclaration, scopeName) { }; - var scopeEmitEnd = function () { }; - var sourceMapData; - var emitLeadingCommentsOfPosition = compilerOptions.removeComments ? function (pos) { } : emitLeadingCommentsOfPositionWorker; - if (compilerOptions.sourceMap || compilerOptions.inlineSourceMap) { - initializeEmitterWithSourceMaps(); - } - if (root) { - emitSourceFile(root); - } - else { - ts.forEach(host.getSourceFiles(), function (sourceFile) { - if (!isExternalModuleOrDeclarationFile(sourceFile)) { - emitSourceFile(sourceFile); - } - }); - } - writeLine(); - writeEmittedFiles(writer.getText(), compilerOptions.emitBOM); - return; - function emitSourceFile(sourceFile) { - currentSourceFile = sourceFile; - exportFunctionForFile = undefined; - emit(sourceFile); - } - function isUniqueName(name) { - return !resolver.hasGlobalName(name) && - !ts.hasProperty(currentSourceFile.identifiers, name) && - !ts.hasProperty(generatedNameSet, name); - } - function makeTempVariableName(flags) { - if (flags && !(tempFlags & flags)) { - var name_20 = flags === 268435456 ? "_i" : "_n"; - if (isUniqueName(name_20)) { - tempFlags |= flags; - return name_20; - } - } - while (true) { - var count = tempFlags & 268435455; - tempFlags++; - if (count !== 8 && count !== 13) { - var name_21 = count < 26 ? "_" + String.fromCharCode(97 + count) : "_" + (count - 26); - if (isUniqueName(name_21)) { - return name_21; - } - } - } - } - function makeUniqueName(baseName) { - if (baseName.charCodeAt(baseName.length - 1) !== 95) { - baseName += "_"; - } - var i = 1; - while (true) { - var generatedName = baseName + i; - if (isUniqueName(generatedName)) { - return generatedNameSet[generatedName] = generatedName; - } - i++; - } - } - function generateNameForModuleOrEnum(node) { - var name = node.name.text; - return isUniqueLocalName(name, node) ? name : makeUniqueName(name); - } - function generateNameForImportOrExportDeclaration(node) { - var expr = ts.getExternalModuleName(node); - var baseName = expr.kind === 9 ? - ts.escapeIdentifier(ts.makeIdentifierFromModuleName(expr.text)) : "module"; - return makeUniqueName(baseName); - } - function generateNameForExportDefault() { - return makeUniqueName("default"); - } - function generateNameForClassExpression() { - return makeUniqueName("class"); - } - function generateNameForNode(node) { - switch (node.kind) { - case 67: - return makeUniqueName(node.text); - case 216: - case 215: - return generateNameForModuleOrEnum(node); - case 220: - case 226: - return generateNameForImportOrExportDeclaration(node); - case 211: - case 212: - case 225: - return generateNameForExportDefault(); - case 184: - return generateNameForClassExpression(); - } - } - function getGeneratedNameForNode(node) { - var id = ts.getNodeId(node); - return nodeToGeneratedName[id] || (nodeToGeneratedName[id] = ts.unescapeIdentifier(generateNameForNode(node))); - } - function initializeEmitterWithSourceMaps() { - var sourceMapDir; - var sourceMapSourceIndex = -1; - var sourceMapNameIndexMap = {}; - var sourceMapNameIndices = []; - function getSourceMapNameIndex() { - return sourceMapNameIndices.length ? ts.lastOrUndefined(sourceMapNameIndices) : -1; - } - var lastRecordedSourceMapSpan; - var lastEncodedSourceMapSpan = { - emittedLine: 1, - emittedColumn: 1, - sourceLine: 1, - sourceColumn: 1, - sourceIndex: 0 - }; - var lastEncodedNameIndex = 0; - function encodeLastRecordedSourceMapSpan() { - if (!lastRecordedSourceMapSpan || lastRecordedSourceMapSpan === lastEncodedSourceMapSpan) { - return; - } - var prevEncodedEmittedColumn = lastEncodedSourceMapSpan.emittedColumn; - if (lastEncodedSourceMapSpan.emittedLine === lastRecordedSourceMapSpan.emittedLine) { - if (sourceMapData.sourceMapMappings) { - sourceMapData.sourceMapMappings += ","; - } - } - else { - for (var encodedLine = lastEncodedSourceMapSpan.emittedLine; encodedLine < lastRecordedSourceMapSpan.emittedLine; encodedLine++) { - sourceMapData.sourceMapMappings += ";"; - } - prevEncodedEmittedColumn = 1; - } - sourceMapData.sourceMapMappings += base64VLQFormatEncode(lastRecordedSourceMapSpan.emittedColumn - prevEncodedEmittedColumn); - sourceMapData.sourceMapMappings += base64VLQFormatEncode(lastRecordedSourceMapSpan.sourceIndex - lastEncodedSourceMapSpan.sourceIndex); - sourceMapData.sourceMapMappings += base64VLQFormatEncode(lastRecordedSourceMapSpan.sourceLine - lastEncodedSourceMapSpan.sourceLine); - sourceMapData.sourceMapMappings += base64VLQFormatEncode(lastRecordedSourceMapSpan.sourceColumn - lastEncodedSourceMapSpan.sourceColumn); - if (lastRecordedSourceMapSpan.nameIndex >= 0) { - sourceMapData.sourceMapMappings += base64VLQFormatEncode(lastRecordedSourceMapSpan.nameIndex - lastEncodedNameIndex); - lastEncodedNameIndex = lastRecordedSourceMapSpan.nameIndex; - } - lastEncodedSourceMapSpan = lastRecordedSourceMapSpan; - sourceMapData.sourceMapDecodedMappings.push(lastEncodedSourceMapSpan); - function base64VLQFormatEncode(inValue) { - function base64FormatEncode(inValue) { - if (inValue < 64) { - return "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(inValue); - } - throw TypeError(inValue + ": not a 64 based value"); - } - if (inValue < 0) { - inValue = ((-inValue) << 1) + 1; - } - else { - inValue = inValue << 1; - } - var encodedStr = ""; - do { - var currentDigit = inValue & 31; - inValue = inValue >> 5; - if (inValue > 0) { - currentDigit = currentDigit | 32; - } - encodedStr = encodedStr + base64FormatEncode(currentDigit); - } while (inValue > 0); - return encodedStr; - } - } - function recordSourceMapSpan(pos) { - var sourceLinePos = ts.getLineAndCharacterOfPosition(currentSourceFile, pos); - sourceLinePos.line++; - sourceLinePos.character++; - var emittedLine = writer.getLine(); - var emittedColumn = writer.getColumn(); - if (!lastRecordedSourceMapSpan || - lastRecordedSourceMapSpan.emittedLine !== emittedLine || - lastRecordedSourceMapSpan.emittedColumn !== emittedColumn || - (lastRecordedSourceMapSpan.sourceIndex === sourceMapSourceIndex && - (lastRecordedSourceMapSpan.sourceLine > sourceLinePos.line || - (lastRecordedSourceMapSpan.sourceLine === sourceLinePos.line && lastRecordedSourceMapSpan.sourceColumn > sourceLinePos.character)))) { - encodeLastRecordedSourceMapSpan(); - lastRecordedSourceMapSpan = { - emittedLine: emittedLine, - emittedColumn: emittedColumn, - sourceLine: sourceLinePos.line, - sourceColumn: sourceLinePos.character, - nameIndex: getSourceMapNameIndex(), - sourceIndex: sourceMapSourceIndex - }; - } - else { - lastRecordedSourceMapSpan.sourceLine = sourceLinePos.line; - lastRecordedSourceMapSpan.sourceColumn = sourceLinePos.character; - lastRecordedSourceMapSpan.sourceIndex = sourceMapSourceIndex; - } - } - function recordEmitNodeStartSpan(node) { - recordSourceMapSpan(ts.skipTrivia(currentSourceFile.text, node.pos)); - } - function recordEmitNodeEndSpan(node) { - recordSourceMapSpan(node.end); - } - function writeTextWithSpanRecord(tokenKind, startPos, emitFn) { - var tokenStartPos = ts.skipTrivia(currentSourceFile.text, startPos); - recordSourceMapSpan(tokenStartPos); - var tokenEndPos = emitTokenText(tokenKind, tokenStartPos, emitFn); - recordSourceMapSpan(tokenEndPos); - return tokenEndPos; - } - function recordNewSourceFileStart(node) { - var sourcesDirectoryPath = compilerOptions.sourceRoot ? host.getCommonSourceDirectory() : sourceMapDir; - sourceMapData.sourceMapSources.push(ts.getRelativePathToDirectoryOrUrl(sourcesDirectoryPath, node.fileName, host.getCurrentDirectory(), host.getCanonicalFileName, true)); - sourceMapSourceIndex = sourceMapData.sourceMapSources.length - 1; - sourceMapData.inputSourceFileNames.push(node.fileName); - if (compilerOptions.inlineSources) { - if (!sourceMapData.sourceMapSourcesContent) { - sourceMapData.sourceMapSourcesContent = []; - } - sourceMapData.sourceMapSourcesContent.push(node.text); - } - } - function recordScopeNameOfNode(node, scopeName) { - function recordScopeNameIndex(scopeNameIndex) { - sourceMapNameIndices.push(scopeNameIndex); - } - function recordScopeNameStart(scopeName) { - var scopeNameIndex = -1; - if (scopeName) { - var parentIndex = getSourceMapNameIndex(); - if (parentIndex !== -1) { - var name_22 = node.name; - if (!name_22 || name_22.kind !== 134) { - scopeName = "." + scopeName; - } - scopeName = sourceMapData.sourceMapNames[parentIndex] + scopeName; - } - scopeNameIndex = ts.getProperty(sourceMapNameIndexMap, scopeName); - if (scopeNameIndex === undefined) { - scopeNameIndex = sourceMapData.sourceMapNames.length; - sourceMapData.sourceMapNames.push(scopeName); - sourceMapNameIndexMap[scopeName] = scopeNameIndex; - } - } - recordScopeNameIndex(scopeNameIndex); - } - if (scopeName) { - recordScopeNameStart(scopeName); - } - else if (node.kind === 211 || - node.kind === 171 || - node.kind === 141 || - node.kind === 140 || - node.kind === 143 || - node.kind === 144 || - node.kind === 216 || - node.kind === 212 || - node.kind === 215) { - if (node.name) { - var name_23 = node.name; - scopeName = name_23.kind === 134 - ? ts.getTextOfNode(name_23) - : node.name.text; - } - recordScopeNameStart(scopeName); - } - else { - recordScopeNameIndex(getSourceMapNameIndex()); - } - } - function recordScopeNameEnd() { - sourceMapNameIndices.pop(); - } - ; - function writeCommentRangeWithMap(curentSourceFile, writer, comment, newLine) { - recordSourceMapSpan(comment.pos); - ts.writeCommentRange(currentSourceFile, writer, comment, newLine); - recordSourceMapSpan(comment.end); - } - function serializeSourceMapContents(version, file, sourceRoot, sources, names, mappings, sourcesContent) { - if (typeof JSON !== "undefined") { - var map_2 = { - version: version, - file: file, - sourceRoot: sourceRoot, - sources: sources, - names: names, - mappings: mappings - }; - if (sourcesContent !== undefined) { - map_2.sourcesContent = sourcesContent; - } - return JSON.stringify(map_2); - } - return "{\"version\":" + version + ",\"file\":\"" + ts.escapeString(file) + "\",\"sourceRoot\":\"" + ts.escapeString(sourceRoot) + "\",\"sources\":[" + serializeStringArray(sources) + "],\"names\":[" + serializeStringArray(names) + "],\"mappings\":\"" + ts.escapeString(mappings) + "\" " + (sourcesContent !== undefined ? ",\"sourcesContent\":[" + serializeStringArray(sourcesContent) + "]" : "") + "}"; - function serializeStringArray(list) { - var output = ""; - for (var i = 0, n = list.length; i < n; i++) { - if (i) { - output += ","; - } - output += "\"" + ts.escapeString(list[i]) + "\""; - } - return output; - } - } - function writeJavaScriptAndSourceMapFile(emitOutput, writeByteOrderMark) { - encodeLastRecordedSourceMapSpan(); - var sourceMapText = serializeSourceMapContents(3, sourceMapData.sourceMapFile, sourceMapData.sourceMapSourceRoot, sourceMapData.sourceMapSources, sourceMapData.sourceMapNames, sourceMapData.sourceMapMappings, sourceMapData.sourceMapSourcesContent); - sourceMapDataList.push(sourceMapData); - var sourceMapUrl; - if (compilerOptions.inlineSourceMap) { - var base64SourceMapText = ts.convertToBase64(sourceMapText); - sourceMapUrl = "//# sourceMappingURL=data:application/json;base64," + base64SourceMapText; - } - else { - ts.writeFile(host, diagnostics, sourceMapData.sourceMapFilePath, sourceMapText, false); - sourceMapUrl = "//# sourceMappingURL=" + sourceMapData.jsSourceMappingURL; - } - writeJavaScriptFile(emitOutput + sourceMapUrl, writeByteOrderMark); - } - var sourceMapJsFile = ts.getBaseFileName(ts.normalizeSlashes(jsFilePath)); - sourceMapData = { - sourceMapFilePath: jsFilePath + ".map", - jsSourceMappingURL: sourceMapJsFile + ".map", - sourceMapFile: sourceMapJsFile, - sourceMapSourceRoot: compilerOptions.sourceRoot || "", - sourceMapSources: [], - inputSourceFileNames: [], - sourceMapNames: [], - sourceMapMappings: "", - sourceMapSourcesContent: undefined, - sourceMapDecodedMappings: [] - }; - sourceMapData.sourceMapSourceRoot = ts.normalizeSlashes(sourceMapData.sourceMapSourceRoot); - if (sourceMapData.sourceMapSourceRoot.length && sourceMapData.sourceMapSourceRoot.charCodeAt(sourceMapData.sourceMapSourceRoot.length - 1) !== 47) { - sourceMapData.sourceMapSourceRoot += ts.directorySeparator; - } - if (compilerOptions.mapRoot) { - sourceMapDir = ts.normalizeSlashes(compilerOptions.mapRoot); - if (root) { - sourceMapDir = ts.getDirectoryPath(ts.getSourceFilePathInNewDir(root, host, sourceMapDir)); - } - if (!ts.isRootedDiskPath(sourceMapDir) && !ts.isUrl(sourceMapDir)) { - sourceMapDir = ts.combinePaths(host.getCommonSourceDirectory(), sourceMapDir); - sourceMapData.jsSourceMappingURL = ts.getRelativePathToDirectoryOrUrl(ts.getDirectoryPath(ts.normalizePath(jsFilePath)), ts.combinePaths(sourceMapDir, sourceMapData.jsSourceMappingURL), host.getCurrentDirectory(), host.getCanonicalFileName, true); - } - else { - sourceMapData.jsSourceMappingURL = ts.combinePaths(sourceMapDir, sourceMapData.jsSourceMappingURL); - } - } - else { - sourceMapDir = ts.getDirectoryPath(ts.normalizePath(jsFilePath)); - } - function emitNodeWithSourceMap(node) { - if (node) { - if (ts.nodeIsSynthesized(node)) { - return emitNodeWithoutSourceMap(node); - } - if (node.kind !== 246) { - recordEmitNodeStartSpan(node); - emitNodeWithoutSourceMap(node); - recordEmitNodeEndSpan(node); - } - else { - recordNewSourceFileStart(node); - emitNodeWithoutSourceMap(node); - } - } - } - function emitNodeWithCommentsAndWithSourcemap(node) { - emitNodeConsideringCommentsOption(node, emitNodeWithSourceMap); - } - writeEmittedFiles = writeJavaScriptAndSourceMapFile; - emit = emitNodeWithCommentsAndWithSourcemap; - emitStart = recordEmitNodeStartSpan; - emitEnd = recordEmitNodeEndSpan; - emitToken = writeTextWithSpanRecord; - scopeEmitStart = recordScopeNameOfNode; - scopeEmitEnd = recordScopeNameEnd; - writeComment = writeCommentRangeWithMap; - } - function writeJavaScriptFile(emitOutput, writeByteOrderMark) { - ts.writeFile(host, diagnostics, jsFilePath, emitOutput, writeByteOrderMark); - } - function createTempVariable(flags) { - var result = ts.createSynthesizedNode(67); - result.text = makeTempVariableName(flags); - return result; - } - function recordTempDeclaration(name) { - if (!tempVariables) { - tempVariables = []; - } - tempVariables.push(name); - } - function createAndRecordTempVariable(flags) { - var temp = createTempVariable(flags); - recordTempDeclaration(temp); - return temp; - } - function emitTempDeclarations(newLine) { - if (tempVariables) { - if (newLine) { - writeLine(); - } - else { - write(" "); - } - write("var "); - emitCommaList(tempVariables); - write(";"); - } - } - function emitTokenText(tokenKind, startPos, emitFn) { - var tokenString = ts.tokenToString(tokenKind); - if (emitFn) { - emitFn(); - } - else { - write(tokenString); - } - return startPos + tokenString.length; - } - function emitOptional(prefix, node) { - if (node) { - write(prefix); - emit(node); - } - } - function emitParenthesizedIf(node, parenthesized) { - if (parenthesized) { - write("("); - } - emit(node); - if (parenthesized) { - write(")"); - } - } - function emitTrailingCommaIfPresent(nodeList) { - if (nodeList.hasTrailingComma) { - write(","); - } - } - function emitLinePreservingList(parent, nodes, allowTrailingComma, spacesBetweenBraces) { - ts.Debug.assert(nodes.length > 0); - increaseIndent(); - if (nodeStartPositionsAreOnSameLine(parent, nodes[0])) { - if (spacesBetweenBraces) { - write(" "); - } - } - else { - writeLine(); - } - for (var i = 0, n = nodes.length; i < n; i++) { - if (i) { - if (nodeEndIsOnSameLineAsNodeStart(nodes[i - 1], nodes[i])) { - write(", "); - } - else { - write(","); - writeLine(); - } - } - emit(nodes[i]); - } - if (nodes.hasTrailingComma && allowTrailingComma) { - write(","); - } - decreaseIndent(); - if (nodeEndPositionsAreOnSameLine(parent, ts.lastOrUndefined(nodes))) { - if (spacesBetweenBraces) { - write(" "); - } - } - else { - writeLine(); - } - } - function emitList(nodes, start, count, multiLine, trailingComma, leadingComma, noTrailingNewLine, emitNode) { - if (!emitNode) { - emitNode = emit; - } - for (var i = 0; i < count; i++) { - if (multiLine) { - if (i || leadingComma) { - write(","); - } - writeLine(); - } - else { - if (i || leadingComma) { - write(", "); - } - } - var node = nodes[start + i]; - emitTrailingCommentsOfPosition(node.pos); - emitNode(node); - leadingComma = true; - } - if (trailingComma) { - write(","); - } - if (multiLine && !noTrailingNewLine) { - writeLine(); - } - return count; - } - function emitCommaList(nodes) { - if (nodes) { - emitList(nodes, 0, nodes.length, false, false); - } - } - function emitLines(nodes) { - emitLinesStartingAt(nodes, 0); - } - function emitLinesStartingAt(nodes, startIndex) { - for (var i = startIndex; i < nodes.length; i++) { - writeLine(); - emit(nodes[i]); - } - } - function isBinaryOrOctalIntegerLiteral(node, text) { - if (node.kind === 8 && text.length > 1) { - switch (text.charCodeAt(1)) { - case 98: - case 66: - case 111: - case 79: - return true; - } - } - return false; - } - function emitLiteral(node) { - var text = getLiteralText(node); - if ((compilerOptions.sourceMap || compilerOptions.inlineSourceMap) && (node.kind === 9 || ts.isTemplateLiteralKind(node.kind))) { - writer.writeLiteral(text); - } - else if (languageVersion < 2 && isBinaryOrOctalIntegerLiteral(node, text)) { - write(node.text); - } - else { - write(text); - } - } - function getLiteralText(node) { - if (languageVersion < 2 && (ts.isTemplateLiteralKind(node.kind) || node.hasExtendedUnicodeEscape)) { - return getQuotedEscapedLiteralText("\"", node.text, "\""); - } - if (node.parent) { - return ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, node); - } - switch (node.kind) { - case 9: - return getQuotedEscapedLiteralText("\"", node.text, "\""); - case 11: - return getQuotedEscapedLiteralText("`", node.text, "`"); - case 12: - return getQuotedEscapedLiteralText("`", node.text, "${"); - case 13: - return getQuotedEscapedLiteralText("}", node.text, "${"); - case 14: - return getQuotedEscapedLiteralText("}", node.text, "`"); - case 8: - return node.text; - } - ts.Debug.fail("Literal kind '" + node.kind + "' not accounted for."); - } - function getQuotedEscapedLiteralText(leftQuote, text, rightQuote) { - return leftQuote + ts.escapeNonAsciiCharacters(ts.escapeString(text)) + rightQuote; - } - function emitDownlevelRawTemplateLiteral(node) { - var text = ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, node); - var isLast = node.kind === 11 || node.kind === 14; - text = text.substring(1, text.length - (isLast ? 1 : 2)); - text = text.replace(/\r\n?/g, "\n"); - text = ts.escapeString(text); - write("\"" + text + "\""); - } - function emitDownlevelTaggedTemplateArray(node, literalEmitter) { - write("["); - if (node.template.kind === 11) { - literalEmitter(node.template); - } - else { - literalEmitter(node.template.head); - ts.forEach(node.template.templateSpans, function (child) { - write(", "); - literalEmitter(child.literal); - }); - } - write("]"); - } - function emitDownlevelTaggedTemplate(node) { - var tempVariable = createAndRecordTempVariable(0); - write("("); - emit(tempVariable); - write(" = "); - emitDownlevelTaggedTemplateArray(node, emit); - write(", "); - emit(tempVariable); - write(".raw = "); - emitDownlevelTaggedTemplateArray(node, emitDownlevelRawTemplateLiteral); - write(", "); - emitParenthesizedIf(node.tag, needsParenthesisForPropertyAccessOrInvocation(node.tag)); - write("("); - emit(tempVariable); - if (node.template.kind === 181) { - ts.forEach(node.template.templateSpans, function (templateSpan) { - write(", "); - var needsParens = templateSpan.expression.kind === 179 - && templateSpan.expression.operatorToken.kind === 24; - emitParenthesizedIf(templateSpan.expression, needsParens); - }); - } - write("))"); - } - function emitTemplateExpression(node) { - if (languageVersion >= 2) { - ts.forEachChild(node, emit); - return; - } - var emitOuterParens = ts.isExpression(node.parent) - && templateNeedsParens(node, node.parent); - if (emitOuterParens) { - write("("); - } - var headEmitted = false; - if (shouldEmitTemplateHead()) { - emitLiteral(node.head); - headEmitted = true; - } - for (var i = 0, n = node.templateSpans.length; i < n; i++) { - var templateSpan = node.templateSpans[i]; - var needsParens = templateSpan.expression.kind !== 170 - && comparePrecedenceToBinaryPlus(templateSpan.expression) !== 1; - if (i > 0 || headEmitted) { - write(" + "); - } - emitParenthesizedIf(templateSpan.expression, needsParens); - if (templateSpan.literal.text.length !== 0) { - write(" + "); - emitLiteral(templateSpan.literal); - } - } - if (emitOuterParens) { - write(")"); - } - function shouldEmitTemplateHead() { - ts.Debug.assert(node.templateSpans.length !== 0); - return node.head.text.length !== 0 || node.templateSpans[0].literal.text.length === 0; - } - function templateNeedsParens(template, parent) { - switch (parent.kind) { - case 166: - case 167: - return parent.expression === template; - case 168: - case 170: - return false; - default: - return comparePrecedenceToBinaryPlus(parent) !== -1; - } - } - function comparePrecedenceToBinaryPlus(expression) { - switch (expression.kind) { - case 179: - switch (expression.operatorToken.kind) { - case 37: - case 38: - case 39: - return 1; - case 35: - case 36: - return 0; - default: - return -1; - } - case 182: - case 180: - return -1; - default: - return 1; - } - } - } - function emitTemplateSpan(span) { - emit(span.expression); - emit(span.literal); - } - function jsxEmitReact(node) { - function emitTagName(name) { - if (name.kind === 67 && ts.isIntrinsicJsxName(name.text)) { - write("\""); - emit(name); - write("\""); - } - else { - emit(name); - } - } - function emitAttributeName(name) { - if (/[A-Za-z_]+[\w*]/.test(name.text)) { - write("\""); - emit(name); - write("\""); - } - else { - emit(name); - } - } - function emitJsxAttribute(node) { - emitAttributeName(node.name); - write(": "); - if (node.initializer) { - emit(node.initializer); - } - else { - write("true"); - } - } - function emitJsxElement(openingNode, children) { - var syntheticReactRef = ts.createSynthesizedNode(67); - syntheticReactRef.text = 'React'; - syntheticReactRef.parent = openingNode; - emitLeadingComments(openingNode); - emitExpressionIdentifier(syntheticReactRef); - write(".createElement("); - emitTagName(openingNode.tagName); - write(", "); - if (openingNode.attributes.length === 0) { - write("null"); - } - else { - var attrs = openingNode.attributes; - if (ts.forEach(attrs, function (attr) { return attr.kind === 237; })) { - emitExpressionIdentifier(syntheticReactRef); - write(".__spread("); - var haveOpenedObjectLiteral = false; - for (var i_1 = 0; i_1 < attrs.length; i_1++) { - if (attrs[i_1].kind === 237) { - if (i_1 === 0) { - write("{}, "); - } - if (haveOpenedObjectLiteral) { - write("}"); - haveOpenedObjectLiteral = false; - } - if (i_1 > 0) { - write(", "); - } - emit(attrs[i_1].expression); - } - else { - ts.Debug.assert(attrs[i_1].kind === 236); - if (haveOpenedObjectLiteral) { - write(", "); - } - else { - haveOpenedObjectLiteral = true; - if (i_1 > 0) { - write(", "); - } - write("{"); - } - emitJsxAttribute(attrs[i_1]); - } - } - if (haveOpenedObjectLiteral) - write("}"); - write(")"); - } - else { - write("{"); - for (var i = 0; i < attrs.length; i++) { - if (i > 0) { - write(", "); - } - emitJsxAttribute(attrs[i]); - } - write("}"); - } - } - if (children) { - for (var i = 0; i < children.length; i++) { - if (children[i].kind === 238 && !(children[i].expression)) { - continue; - } - if (children[i].kind === 234) { - var text = getTextToEmit(children[i]); - if (text !== undefined) { - write(", \""); - write(text); - write("\""); - } - } - else { - write(", "); - emit(children[i]); - } - } - } - write(")"); - emitTrailingComments(openingNode); - } - if (node.kind === 231) { - emitJsxElement(node.openingElement, node.children); - } - else { - ts.Debug.assert(node.kind === 232); - emitJsxElement(node); - } - } - function jsxEmitPreserve(node) { - function emitJsxAttribute(node) { - emit(node.name); - if (node.initializer) { - write("="); - emit(node.initializer); - } - } - function emitJsxSpreadAttribute(node) { - write("{..."); - emit(node.expression); - write("}"); - } - function emitAttributes(attribs) { - for (var i = 0, n = attribs.length; i < n; i++) { - if (i > 0) { - write(" "); - } - if (attribs[i].kind === 237) { - emitJsxSpreadAttribute(attribs[i]); - } - else { - ts.Debug.assert(attribs[i].kind === 236); - emitJsxAttribute(attribs[i]); - } - } - } - function emitJsxOpeningOrSelfClosingElement(node) { - write("<"); - emit(node.tagName); - if (node.attributes.length > 0 || (node.kind === 232)) { - write(" "); - } - emitAttributes(node.attributes); - if (node.kind === 232) { - write("/>"); - } - else { - write(">"); - } - } - function emitJsxClosingElement(node) { - write(""); - } - function emitJsxElement(node) { - emitJsxOpeningOrSelfClosingElement(node.openingElement); - for (var i = 0, n = node.children.length; i < n; i++) { - emit(node.children[i]); - } - emitJsxClosingElement(node.closingElement); - } - if (node.kind === 231) { - emitJsxElement(node); - } - else { - ts.Debug.assert(node.kind === 232); - emitJsxOpeningOrSelfClosingElement(node); - } - } - function emitExpressionForPropertyName(node) { - ts.Debug.assert(node.kind !== 161); - if (node.kind === 9) { - emitLiteral(node); - } - else if (node.kind === 134) { - if (ts.nodeIsDecorated(node.parent)) { - if (!computedPropertyNamesToGeneratedNames) { - computedPropertyNamesToGeneratedNames = []; - } - var generatedName = computedPropertyNamesToGeneratedNames[ts.getNodeId(node)]; - if (generatedName) { - write(generatedName); - return; - } - generatedName = createAndRecordTempVariable(0).text; - computedPropertyNamesToGeneratedNames[ts.getNodeId(node)] = generatedName; - write(generatedName); - write(" = "); - } - emit(node.expression); - } - else { - write("\""); - if (node.kind === 8) { - write(node.text); - } - else { - writeTextOfNode(currentSourceFile, node); - } - write("\""); - } - } - function isExpressionIdentifier(node) { - var parent = node.parent; - switch (parent.kind) { - case 162: - case 179: - case 166: - case 239: - case 134: - case 180: - case 137: - case 173: - case 195: - case 165: - case 225: - case 193: - case 186: - case 197: - case 198: - case 199: - case 194: - case 232: - case 233: - case 237: - case 238: - case 167: - case 170: - case 178: - case 177: - case 202: - case 244: - case 183: - case 204: - case 168: - case 188: - case 206: - case 169: - case 174: - case 175: - case 196: - case 203: - case 182: - return true; - case 161: - case 245: - case 136: - case 243: - case 139: - case 209: - return parent.initializer === node; - case 164: - return parent.expression === node; - case 172: - case 171: - return parent.body === node; - case 219: - return parent.moduleReference === node; - case 133: - return parent.left === node; - } - return false; - } - function emitExpressionIdentifier(node) { - if (resolver.getNodeCheckFlags(node) & 2048) { - write("_arguments"); - return; - } - var container = resolver.getReferencedExportContainer(node); - if (container) { - if (container.kind === 246) { - if (languageVersion < 2 && compilerOptions.module !== 4) { - write("exports."); - } - } - else { - write(getGeneratedNameForNode(container)); - write("."); - } - } - else if (languageVersion < 2) { - var declaration = resolver.getReferencedImportDeclaration(node); - if (declaration) { - if (declaration.kind === 221) { - write(getGeneratedNameForNode(declaration.parent)); - write(languageVersion === 0 ? "[\"default\"]" : ".default"); - return; - } - else if (declaration.kind === 224) { - write(getGeneratedNameForNode(declaration.parent.parent.parent)); - var name = declaration.propertyName || declaration.name; - var identifier = ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, name); - if (languageVersion === 0 && identifier === "default") { - write("[\"default\"]"); - } - else { - write("."); - write(identifier); - } - return; - } - } - declaration = resolver.getReferencedNestedRedeclaration(node); - if (declaration) { - write(getGeneratedNameForNode(declaration.name)); - return; - } - } - if (ts.nodeIsSynthesized(node)) { - write(node.text); - } - else { - writeTextOfNode(currentSourceFile, node); - } - } - function isNameOfNestedRedeclaration(node) { - if (languageVersion < 2) { - var parent_6 = node.parent; - switch (parent_6.kind) { - case 161: - case 212: - case 215: - case 209: - return parent_6.name === node && resolver.isNestedRedeclaration(parent_6); - } - } - return false; - } - function emitIdentifier(node) { - if (!node.parent) { - write(node.text); - } - else if (isExpressionIdentifier(node)) { - emitExpressionIdentifier(node); - } - else if (isNameOfNestedRedeclaration(node)) { - write(getGeneratedNameForNode(node)); - } - else if (ts.nodeIsSynthesized(node)) { - write(node.text); - } - else { - writeTextOfNode(currentSourceFile, node); - } - } - function emitThis(node) { - if (resolver.getNodeCheckFlags(node) & 2) { - write("_this"); - } - else { - write("this"); - } - } - function emitSuper(node) { - if (languageVersion >= 2) { - write("super"); - } - else { - var flags = resolver.getNodeCheckFlags(node); - if (flags & 256) { - write("_super.prototype"); - } - else { - write("_super"); - } - } - } - function emitObjectBindingPattern(node) { - write("{ "); - var elements = node.elements; - emitList(elements, 0, elements.length, false, elements.hasTrailingComma); - write(" }"); - } - function emitArrayBindingPattern(node) { - write("["); - var elements = node.elements; - emitList(elements, 0, elements.length, false, elements.hasTrailingComma); - write("]"); - } - function emitBindingElement(node) { - if (node.propertyName) { - emit(node.propertyName); - write(": "); - } - if (node.dotDotDotToken) { - write("..."); - } - if (ts.isBindingPattern(node.name)) { - emit(node.name); - } - else { - emitModuleMemberName(node); - } - emitOptional(" = ", node.initializer); - } - function emitSpreadElementExpression(node) { - write("..."); - emit(node.expression); - } - function emitYieldExpression(node) { - write(ts.tokenToString(112)); - if (node.asteriskToken) { - write("*"); - } - if (node.expression) { - write(" "); - emit(node.expression); - } - } - function emitAwaitExpression(node) { - var needsParenthesis = needsParenthesisForAwaitExpressionAsYield(node); - if (needsParenthesis) { - write("("); - } - write(ts.tokenToString(112)); - write(" "); - emit(node.expression); - if (needsParenthesis) { - write(")"); - } - } - function needsParenthesisForAwaitExpressionAsYield(node) { - if (node.parent.kind === 179 && !ts.isAssignmentOperator(node.parent.operatorToken.kind)) { - return true; - } - else if (node.parent.kind === 180 && node.parent.condition === node) { - return true; - } - return false; - } - function needsParenthesisForPropertyAccessOrInvocation(node) { - switch (node.kind) { - case 67: - case 162: - case 164: - case 165: - case 166: - case 170: - return false; - } - return true; - } - function emitListWithSpread(elements, needsUniqueCopy, multiLine, trailingComma, useConcat) { - var pos = 0; - var group = 0; - var length = elements.length; - while (pos < length) { - if (group === 1 && useConcat) { - write(".concat("); - } - else if (group > 0) { - write(", "); - } - var e = elements[pos]; - if (e.kind === 183) { - e = e.expression; - emitParenthesizedIf(e, group === 0 && needsParenthesisForPropertyAccessOrInvocation(e)); - pos++; - if (pos === length && group === 0 && needsUniqueCopy && e.kind !== 162) { - write(".slice()"); - } - } - else { - var i = pos; - while (i < length && elements[i].kind !== 183) { - i++; - } - write("["); - if (multiLine) { - increaseIndent(); - } - emitList(elements, pos, i - pos, multiLine, trailingComma && i === length); - if (multiLine) { - decreaseIndent(); - } - write("]"); - pos = i; - } - group++; - } - if (group > 1) { - if (useConcat) { - write(")"); - } - } - } - function isSpreadElementExpression(node) { - return node.kind === 183; - } - function emitArrayLiteral(node) { - var elements = node.elements; - if (elements.length === 0) { - write("[]"); - } - else if (languageVersion >= 2 || !ts.forEach(elements, isSpreadElementExpression)) { - write("["); - emitLinePreservingList(node, node.elements, elements.hasTrailingComma, false); - write("]"); - } - else { - emitListWithSpread(elements, true, (node.flags & 2048) !== 0, elements.hasTrailingComma, true); - } - } - function emitObjectLiteralBody(node, numElements) { - if (numElements === 0) { - write("{}"); - return; - } - write("{"); - if (numElements > 0) { - var properties = node.properties; - if (numElements === properties.length) { - emitLinePreservingList(node, properties, languageVersion >= 1, true); - } - else { - var multiLine = (node.flags & 2048) !== 0; - if (!multiLine) { - write(" "); - } - else { - increaseIndent(); - } - emitList(properties, 0, numElements, multiLine, false); - if (!multiLine) { - write(" "); - } - else { - decreaseIndent(); - } - } - } - write("}"); - } - function emitDownlevelObjectLiteralWithComputedProperties(node, firstComputedPropertyIndex) { - var multiLine = (node.flags & 2048) !== 0; - var properties = node.properties; - write("("); - if (multiLine) { - increaseIndent(); - } - var tempVar = createAndRecordTempVariable(0); - emit(tempVar); - write(" = "); - emitObjectLiteralBody(node, firstComputedPropertyIndex); - for (var i = firstComputedPropertyIndex, n = properties.length; i < n; i++) { - writeComma(); - var property = properties[i]; - emitStart(property); - if (property.kind === 143 || property.kind === 144) { - var accessors = ts.getAllAccessorDeclarations(node.properties, property); - if (property !== accessors.firstAccessor) { - continue; - } - write("Object.defineProperty("); - emit(tempVar); - write(", "); - emitStart(node.name); - emitExpressionForPropertyName(property.name); - emitEnd(property.name); - write(", {"); - increaseIndent(); - if (accessors.getAccessor) { - writeLine(); - emitLeadingComments(accessors.getAccessor); - write("get: "); - emitStart(accessors.getAccessor); - write("function "); - emitSignatureAndBody(accessors.getAccessor); - emitEnd(accessors.getAccessor); - emitTrailingComments(accessors.getAccessor); - write(","); - } - if (accessors.setAccessor) { - writeLine(); - emitLeadingComments(accessors.setAccessor); - write("set: "); - emitStart(accessors.setAccessor); - write("function "); - emitSignatureAndBody(accessors.setAccessor); - emitEnd(accessors.setAccessor); - emitTrailingComments(accessors.setAccessor); - write(","); - } - writeLine(); - write("enumerable: true,"); - writeLine(); - write("configurable: true"); - decreaseIndent(); - writeLine(); - write("})"); - emitEnd(property); - } - else { - emitLeadingComments(property); - emitStart(property.name); - emit(tempVar); - emitMemberAccessForPropertyName(property.name); - emitEnd(property.name); - write(" = "); - if (property.kind === 243) { - emit(property.initializer); - } - else if (property.kind === 244) { - emitExpressionIdentifier(property.name); - } - else if (property.kind === 141) { - emitFunctionDeclaration(property); - } - else { - ts.Debug.fail("ObjectLiteralElement type not accounted for: " + property.kind); - } - } - emitEnd(property); - } - writeComma(); - emit(tempVar); - if (multiLine) { - decreaseIndent(); - writeLine(); - } - write(")"); - function writeComma() { - if (multiLine) { - write(","); - writeLine(); - } - else { - write(", "); - } - } - } - function emitObjectLiteral(node) { - var properties = node.properties; - if (languageVersion < 2) { - var numProperties = properties.length; - var numInitialNonComputedProperties = numProperties; - for (var i = 0, n = properties.length; i < n; i++) { - if (properties[i].name.kind === 134) { - numInitialNonComputedProperties = i; - break; - } - } - var hasComputedProperty = numInitialNonComputedProperties !== properties.length; - if (hasComputedProperty) { - emitDownlevelObjectLiteralWithComputedProperties(node, numInitialNonComputedProperties); - return; - } - } - emitObjectLiteralBody(node, properties.length); - } - function createBinaryExpression(left, operator, right, startsOnNewLine) { - var result = ts.createSynthesizedNode(179, startsOnNewLine); - result.operatorToken = ts.createSynthesizedNode(operator); - result.left = left; - result.right = right; - return result; - } - function createPropertyAccessExpression(expression, name) { - var result = ts.createSynthesizedNode(164); - result.expression = parenthesizeForAccess(expression); - result.dotToken = ts.createSynthesizedNode(21); - result.name = name; - return result; - } - function createElementAccessExpression(expression, argumentExpression) { - var result = ts.createSynthesizedNode(165); - result.expression = parenthesizeForAccess(expression); - result.argumentExpression = argumentExpression; - return result; - } - function parenthesizeForAccess(expr) { - while (expr.kind === 169 || expr.kind === 187) { - expr = expr.expression; - } - if (ts.isLeftHandSideExpression(expr) && - expr.kind !== 167 && - expr.kind !== 8) { - return expr; - } - var node = ts.createSynthesizedNode(170); - node.expression = expr; - return node; - } - function emitComputedPropertyName(node) { - write("["); - emitExpressionForPropertyName(node); - write("]"); - } - function emitMethod(node) { - if (languageVersion >= 2 && node.asteriskToken) { - write("*"); - } - emit(node.name); - if (languageVersion < 2) { - write(": function "); - } - emitSignatureAndBody(node); - } - function emitPropertyAssignment(node) { - emit(node.name); - write(": "); - emitTrailingCommentsOfPosition(node.initializer.pos); - emit(node.initializer); - } - function isNamespaceExportReference(node) { - var container = resolver.getReferencedExportContainer(node); - return container && container.kind !== 246; - } - function emitShorthandPropertyAssignment(node) { - writeTextOfNode(currentSourceFile, node.name); - if (languageVersion < 2 || isNamespaceExportReference(node.name)) { - write(": "); - emit(node.name); - } - } - function tryEmitConstantValue(node) { - var constantValue = tryGetConstEnumValue(node); - if (constantValue !== undefined) { - write(constantValue.toString()); - if (!compilerOptions.removeComments) { - var propertyName = node.kind === 164 ? ts.declarationNameToString(node.name) : ts.getTextOfNode(node.argumentExpression); - write(" /* " + propertyName + " */"); - } - return true; - } - return false; - } - function tryGetConstEnumValue(node) { - if (compilerOptions.isolatedModules) { - return undefined; - } - return node.kind === 164 || node.kind === 165 - ? resolver.getConstantValue(node) - : undefined; - } - function indentIfOnDifferentLines(parent, node1, node2, valueToWriteWhenNotIndenting) { - var realNodesAreOnDifferentLines = !ts.nodeIsSynthesized(parent) && !nodeEndIsOnSameLineAsNodeStart(node1, node2); - var synthesizedNodeIsOnDifferentLine = synthesizedNodeStartsOnNewLine(node2); - if (realNodesAreOnDifferentLines || synthesizedNodeIsOnDifferentLine) { - increaseIndent(); - writeLine(); - return true; - } - else { - if (valueToWriteWhenNotIndenting) { - write(valueToWriteWhenNotIndenting); - } - return false; - } - } - function emitPropertyAccess(node) { - if (tryEmitConstantValue(node)) { - return; - } - emit(node.expression); - var indentedBeforeDot = indentIfOnDifferentLines(node, node.expression, node.dotToken); - var shouldEmitSpace; - if (!indentedBeforeDot) { - if (node.expression.kind === 8) { - var text = ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, node.expression); - shouldEmitSpace = text.indexOf(ts.tokenToString(21)) < 0; - } - else { - var constantValue = tryGetConstEnumValue(node.expression); - shouldEmitSpace = isFinite(constantValue) && Math.floor(constantValue) === constantValue; - } - } - if (shouldEmitSpace) { - write(" ."); - } - else { - write("."); - } - var indentedAfterDot = indentIfOnDifferentLines(node, node.dotToken, node.name); - emit(node.name); - decreaseIndentIf(indentedBeforeDot, indentedAfterDot); - } - function emitQualifiedName(node) { - emit(node.left); - write("."); - emit(node.right); - } - function emitQualifiedNameAsExpression(node, useFallback) { - if (node.left.kind === 67) { - emitEntityNameAsExpression(node.left, useFallback); - } - else if (useFallback) { - var temp = createAndRecordTempVariable(0); - write("("); - emitNodeWithoutSourceMap(temp); - write(" = "); - emitEntityNameAsExpression(node.left, true); - write(") && "); - emitNodeWithoutSourceMap(temp); - } - else { - emitEntityNameAsExpression(node.left, false); - } - write("."); - emit(node.right); - } - function emitEntityNameAsExpression(node, useFallback) { - switch (node.kind) { - case 67: - if (useFallback) { - write("typeof "); - emitExpressionIdentifier(node); - write(" !== 'undefined' && "); - } - emitExpressionIdentifier(node); - break; - case 133: - emitQualifiedNameAsExpression(node, useFallback); - break; - } - } - function emitIndexedAccess(node) { - if (tryEmitConstantValue(node)) { - return; - } - emit(node.expression); - write("["); - emit(node.argumentExpression); - write("]"); - } - function hasSpreadElement(elements) { - return ts.forEach(elements, function (e) { return e.kind === 183; }); - } - function skipParentheses(node) { - while (node.kind === 170 || node.kind === 169 || node.kind === 187) { - node = node.expression; - } - return node; - } - function emitCallTarget(node) { - if (node.kind === 67 || node.kind === 95 || node.kind === 93) { - emit(node); - return node; - } - var temp = createAndRecordTempVariable(0); - write("("); - emit(temp); - write(" = "); - emit(node); - write(")"); - return temp; - } - function emitCallWithSpread(node) { - var target; - var expr = skipParentheses(node.expression); - if (expr.kind === 164) { - target = emitCallTarget(expr.expression); - write("."); - emit(expr.name); - } - else if (expr.kind === 165) { - target = emitCallTarget(expr.expression); - write("["); - emit(expr.argumentExpression); - write("]"); - } - else if (expr.kind === 93) { - target = expr; - write("_super"); - } - else { - emit(node.expression); - } - write(".apply("); - if (target) { - if (target.kind === 93) { - emitThis(target); - } - else { - emit(target); - } - } - else { - write("void 0"); - } - write(", "); - emitListWithSpread(node.arguments, false, false, false, true); - write(")"); - } - function emitCallExpression(node) { - if (languageVersion < 2 && hasSpreadElement(node.arguments)) { - emitCallWithSpread(node); - return; - } - var superCall = false; - if (node.expression.kind === 93) { - emitSuper(node.expression); - superCall = true; - } - else { - emit(node.expression); - superCall = node.expression.kind === 164 && node.expression.expression.kind === 93; - } - if (superCall && languageVersion < 2) { - write(".call("); - emitThis(node.expression); - if (node.arguments.length) { - write(", "); - emitCommaList(node.arguments); - } - write(")"); - } - else { - write("("); - emitCommaList(node.arguments); - write(")"); - } - } - function emitNewExpression(node) { - write("new "); - if (languageVersion === 1 && - node.arguments && - hasSpreadElement(node.arguments)) { - write("("); - var target = emitCallTarget(node.expression); - write(".bind.apply("); - emit(target); - write(", [void 0].concat("); - emitListWithSpread(node.arguments, false, false, false, false); - write(")))"); - write("()"); - } - else { - emit(node.expression); - if (node.arguments) { - write("("); - emitCommaList(node.arguments); - write(")"); - } - } - } - function emitTaggedTemplateExpression(node) { - if (languageVersion >= 2) { - emit(node.tag); - write(" "); - emit(node.template); - } - else { - emitDownlevelTaggedTemplate(node); - } - } - function emitParenExpression(node) { - if (!ts.nodeIsSynthesized(node) && node.parent.kind !== 172) { - if (node.expression.kind === 169 || node.expression.kind === 187) { - var operand = node.expression.expression; - while (operand.kind === 169 || operand.kind === 187) { - operand = operand.expression; - } - if (operand.kind !== 177 && - operand.kind !== 175 && - operand.kind !== 174 && - operand.kind !== 173 && - operand.kind !== 178 && - operand.kind !== 167 && - !(operand.kind === 166 && node.parent.kind === 167) && - !(operand.kind === 171 && node.parent.kind === 166) && - !(operand.kind === 8 && node.parent.kind === 164)) { - emit(operand); - return; - } - } - } - write("("); - emit(node.expression); - write(")"); - } - function emitDeleteExpression(node) { - write(ts.tokenToString(76)); - write(" "); - emit(node.expression); - } - function emitVoidExpression(node) { - write(ts.tokenToString(101)); - write(" "); - emit(node.expression); - } - function emitTypeOfExpression(node) { - write(ts.tokenToString(99)); - write(" "); - emit(node.expression); - } - function isNameOfExportedSourceLevelDeclarationInSystemExternalModule(node) { - if (!isCurrentFileSystemExternalModule() || node.kind !== 67 || ts.nodeIsSynthesized(node)) { - return false; - } - var isVariableDeclarationOrBindingElement = node.parent && (node.parent.kind === 209 || node.parent.kind === 161); - var targetDeclaration = isVariableDeclarationOrBindingElement - ? node.parent - : resolver.getReferencedValueDeclaration(node); - return isSourceFileLevelDeclarationInSystemJsModule(targetDeclaration, true); - } - function emitPrefixUnaryExpression(node) { - var exportChanged = isNameOfExportedSourceLevelDeclarationInSystemExternalModule(node.operand); - if (exportChanged) { - write(exportFunctionForFile + "(\""); - emitNodeWithoutSourceMap(node.operand); - write("\", "); - } - write(ts.tokenToString(node.operator)); - if (node.operand.kind === 177) { - var operand = node.operand; - if (node.operator === 35 && (operand.operator === 35 || operand.operator === 40)) { - write(" "); - } - else if (node.operator === 36 && (operand.operator === 36 || operand.operator === 41)) { - write(" "); - } - } - emit(node.operand); - if (exportChanged) { - write(")"); - } - } - function emitPostfixUnaryExpression(node) { - var exportChanged = isNameOfExportedSourceLevelDeclarationInSystemExternalModule(node.operand); - if (exportChanged) { - write("(" + exportFunctionForFile + "(\""); - emitNodeWithoutSourceMap(node.operand); - write("\", "); - write(ts.tokenToString(node.operator)); - emit(node.operand); - if (node.operator === 40) { - write(") - 1)"); - } - else { - write(") + 1)"); - } - } - else { - emit(node.operand); - write(ts.tokenToString(node.operator)); - } - } - function shouldHoistDeclarationInSystemJsModule(node) { - return isSourceFileLevelDeclarationInSystemJsModule(node, false); - } - function isSourceFileLevelDeclarationInSystemJsModule(node, isExported) { - if (!node || languageVersion >= 2 || !isCurrentFileSystemExternalModule()) { - return false; - } - var current = node; - while (current) { - if (current.kind === 246) { - return !isExported || ((ts.getCombinedNodeFlags(node) & 1) !== 0); - } - else if (ts.isFunctionLike(current) || current.kind === 217) { - return false; - } - else { - current = current.parent; - } - } - } - function emitBinaryExpression(node) { - if (languageVersion < 2 && node.operatorToken.kind === 55 && - (node.left.kind === 163 || node.left.kind === 162)) { - emitDestructuring(node, node.parent.kind === 193); - } - else { - var exportChanged = node.operatorToken.kind >= 55 && - node.operatorToken.kind <= 66 && - isNameOfExportedSourceLevelDeclarationInSystemExternalModule(node.left); - if (exportChanged) { - write(exportFunctionForFile + "(\""); - emitNodeWithoutSourceMap(node.left); - write("\", "); - } - emit(node.left); - var indentedBeforeOperator = indentIfOnDifferentLines(node, node.left, node.operatorToken, node.operatorToken.kind !== 24 ? " " : undefined); - write(ts.tokenToString(node.operatorToken.kind)); - var indentedAfterOperator = indentIfOnDifferentLines(node, node.operatorToken, node.right, " "); - emit(node.right); - decreaseIndentIf(indentedBeforeOperator, indentedAfterOperator); - if (exportChanged) { - write(")"); - } - } - } - function synthesizedNodeStartsOnNewLine(node) { - return ts.nodeIsSynthesized(node) && node.startsOnNewLine; - } - function emitConditionalExpression(node) { - emit(node.condition); - var indentedBeforeQuestion = indentIfOnDifferentLines(node, node.condition, node.questionToken, " "); - write("?"); - var indentedAfterQuestion = indentIfOnDifferentLines(node, node.questionToken, node.whenTrue, " "); - emit(node.whenTrue); - decreaseIndentIf(indentedBeforeQuestion, indentedAfterQuestion); - var indentedBeforeColon = indentIfOnDifferentLines(node, node.whenTrue, node.colonToken, " "); - write(":"); - var indentedAfterColon = indentIfOnDifferentLines(node, node.colonToken, node.whenFalse, " "); - emit(node.whenFalse); - decreaseIndentIf(indentedBeforeColon, indentedAfterColon); - } - function decreaseIndentIf(value1, value2) { - if (value1) { - decreaseIndent(); - } - if (value2) { - decreaseIndent(); - } - } - function isSingleLineEmptyBlock(node) { - if (node && node.kind === 190) { - var block = node; - return block.statements.length === 0 && nodeEndIsOnSameLineAsNodeStart(block, block); - } - } - function emitBlock(node) { - if (isSingleLineEmptyBlock(node)) { - emitToken(15, node.pos); - write(" "); - emitToken(16, node.statements.end); - return; - } - emitToken(15, node.pos); - increaseIndent(); - scopeEmitStart(node.parent); - if (node.kind === 217) { - ts.Debug.assert(node.parent.kind === 216); - emitCaptureThisForNodeIfNecessary(node.parent); - } - emitLines(node.statements); - if (node.kind === 217) { - emitTempDeclarations(true); - } - decreaseIndent(); - writeLine(); - emitToken(16, node.statements.end); - scopeEmitEnd(); - } - function emitEmbeddedStatement(node) { - if (node.kind === 190) { - write(" "); - emit(node); - } - else { - increaseIndent(); - writeLine(); - emit(node); - decreaseIndent(); - } - } - function emitExpressionStatement(node) { - emitParenthesizedIf(node.expression, node.expression.kind === 172); - write(";"); - } - function emitIfStatement(node) { - var endPos = emitToken(86, node.pos); - write(" "); - endPos = emitToken(17, endPos); - emit(node.expression); - emitToken(18, node.expression.end); - emitEmbeddedStatement(node.thenStatement); - if (node.elseStatement) { - writeLine(); - emitToken(78, node.thenStatement.end); - if (node.elseStatement.kind === 194) { - write(" "); - emit(node.elseStatement); - } - else { - emitEmbeddedStatement(node.elseStatement); - } - } - } - function emitDoStatement(node) { - write("do"); - emitEmbeddedStatement(node.statement); - if (node.statement.kind === 190) { - write(" "); - } - else { - writeLine(); - } - write("while ("); - emit(node.expression); - write(");"); - } - function emitWhileStatement(node) { - write("while ("); - emit(node.expression); - write(")"); - emitEmbeddedStatement(node.statement); - } - function tryEmitStartOfVariableDeclarationList(decl, startPos) { - if (shouldHoistVariable(decl, true)) { - return false; - } - var tokenKind = 100; - if (decl && languageVersion >= 2) { - if (ts.isLet(decl)) { - tokenKind = 106; - } - else if (ts.isConst(decl)) { - tokenKind = 72; - } - } - if (startPos !== undefined) { - emitToken(tokenKind, startPos); - write(" "); - } - else { - switch (tokenKind) { - case 100: - write("var "); - break; - case 106: - write("let "); - break; - case 72: - write("const "); - break; - } - } - return true; - } - function emitVariableDeclarationListSkippingUninitializedEntries(list) { - var started = false; - for (var _a = 0, _b = list.declarations; _a < _b.length; _a++) { - var decl = _b[_a]; - if (!decl.initializer) { - continue; - } - if (!started) { - started = true; - } - else { - write(", "); - } - emit(decl); - } - return started; - } - function emitForStatement(node) { - var endPos = emitToken(84, node.pos); - write(" "); - endPos = emitToken(17, endPos); - if (node.initializer && node.initializer.kind === 210) { - var variableDeclarationList = node.initializer; - var startIsEmitted = tryEmitStartOfVariableDeclarationList(variableDeclarationList, endPos); - if (startIsEmitted) { - emitCommaList(variableDeclarationList.declarations); - } - else { - emitVariableDeclarationListSkippingUninitializedEntries(variableDeclarationList); - } - } - else if (node.initializer) { - emit(node.initializer); - } - write(";"); - emitOptional(" ", node.condition); - write(";"); - emitOptional(" ", node.incrementor); - write(")"); - emitEmbeddedStatement(node.statement); - } - function emitForInOrForOfStatement(node) { - if (languageVersion < 2 && node.kind === 199) { - return emitDownLevelForOfStatement(node); - } - var endPos = emitToken(84, node.pos); - write(" "); - endPos = emitToken(17, endPos); - if (node.initializer.kind === 210) { - var variableDeclarationList = node.initializer; - if (variableDeclarationList.declarations.length >= 1) { - tryEmitStartOfVariableDeclarationList(variableDeclarationList, endPos); - emit(variableDeclarationList.declarations[0]); - } - } - else { - emit(node.initializer); - } - if (node.kind === 198) { - write(" in "); - } - else { - write(" of "); - } - emit(node.expression); - emitToken(18, node.expression.end); - emitEmbeddedStatement(node.statement); - } - function emitDownLevelForOfStatement(node) { - var endPos = emitToken(84, node.pos); - write(" "); - endPos = emitToken(17, endPos); - var rhsIsIdentifier = node.expression.kind === 67; - var counter = createTempVariable(268435456); - var rhsReference = rhsIsIdentifier ? node.expression : createTempVariable(0); - emitStart(node.expression); - write("var "); - emitNodeWithoutSourceMap(counter); - write(" = 0"); - emitEnd(node.expression); - if (!rhsIsIdentifier) { - write(", "); - emitStart(node.expression); - emitNodeWithoutSourceMap(rhsReference); - write(" = "); - emitNodeWithoutSourceMap(node.expression); - emitEnd(node.expression); - } - write("; "); - emitStart(node.initializer); - emitNodeWithoutSourceMap(counter); - write(" < "); - emitNodeWithCommentsAndWithoutSourcemap(rhsReference); - write(".length"); - emitEnd(node.initializer); - write("; "); - emitStart(node.initializer); - emitNodeWithoutSourceMap(counter); - write("++"); - emitEnd(node.initializer); - emitToken(18, node.expression.end); - write(" {"); - writeLine(); - increaseIndent(); - var rhsIterationValue = createElementAccessExpression(rhsReference, counter); - emitStart(node.initializer); - if (node.initializer.kind === 210) { - write("var "); - var variableDeclarationList = node.initializer; - if (variableDeclarationList.declarations.length > 0) { - var declaration = variableDeclarationList.declarations[0]; - if (ts.isBindingPattern(declaration.name)) { - emitDestructuring(declaration, false, rhsIterationValue); - } - else { - emitNodeWithCommentsAndWithoutSourcemap(declaration); - write(" = "); - emitNodeWithoutSourceMap(rhsIterationValue); - } - } - else { - emitNodeWithoutSourceMap(createTempVariable(0)); - write(" = "); - emitNodeWithoutSourceMap(rhsIterationValue); - } - } - else { - var assignmentExpression = createBinaryExpression(node.initializer, 55, rhsIterationValue, false); - if (node.initializer.kind === 162 || node.initializer.kind === 163) { - emitDestructuring(assignmentExpression, true, undefined); - } - else { - emitNodeWithCommentsAndWithoutSourcemap(assignmentExpression); - } - } - emitEnd(node.initializer); - write(";"); - if (node.statement.kind === 190) { - emitLines(node.statement.statements); - } - else { - writeLine(); - emit(node.statement); - } - writeLine(); - decreaseIndent(); - write("}"); - } - function emitBreakOrContinueStatement(node) { - emitToken(node.kind === 201 ? 68 : 73, node.pos); - emitOptional(" ", node.label); - write(";"); - } - function emitReturnStatement(node) { - emitToken(92, node.pos); - emitOptional(" ", node.expression); - write(";"); - } - function emitWithStatement(node) { - write("with ("); - emit(node.expression); - write(")"); - emitEmbeddedStatement(node.statement); - } - function emitSwitchStatement(node) { - var endPos = emitToken(94, node.pos); - write(" "); - emitToken(17, endPos); - emit(node.expression); - endPos = emitToken(18, node.expression.end); - write(" "); - emitCaseBlock(node.caseBlock, endPos); - } - function emitCaseBlock(node, startPos) { - emitToken(15, startPos); - increaseIndent(); - emitLines(node.clauses); - decreaseIndent(); - writeLine(); - emitToken(16, node.clauses.end); - } - function nodeStartPositionsAreOnSameLine(node1, node2) { - return ts.getLineOfLocalPosition(currentSourceFile, ts.skipTrivia(currentSourceFile.text, node1.pos)) === - ts.getLineOfLocalPosition(currentSourceFile, ts.skipTrivia(currentSourceFile.text, node2.pos)); - } - function nodeEndPositionsAreOnSameLine(node1, node2) { - return ts.getLineOfLocalPosition(currentSourceFile, node1.end) === - ts.getLineOfLocalPosition(currentSourceFile, node2.end); - } - function nodeEndIsOnSameLineAsNodeStart(node1, node2) { - return ts.getLineOfLocalPosition(currentSourceFile, node1.end) === - ts.getLineOfLocalPosition(currentSourceFile, ts.skipTrivia(currentSourceFile.text, node2.pos)); - } - function emitCaseOrDefaultClause(node) { - if (node.kind === 239) { - write("case "); - emit(node.expression); - write(":"); - } - else { - write("default:"); - } - if (node.statements.length === 1 && nodeStartPositionsAreOnSameLine(node, node.statements[0])) { - write(" "); - emit(node.statements[0]); - } - else { - increaseIndent(); - emitLines(node.statements); - decreaseIndent(); - } - } - function emitThrowStatement(node) { - write("throw "); - emit(node.expression); - write(";"); - } - function emitTryStatement(node) { - write("try "); - emit(node.tryBlock); - emit(node.catchClause); - if (node.finallyBlock) { - writeLine(); - write("finally "); - emit(node.finallyBlock); - } - } - function emitCatchClause(node) { - writeLine(); - var endPos = emitToken(70, node.pos); - write(" "); - emitToken(17, endPos); - emit(node.variableDeclaration); - emitToken(18, node.variableDeclaration ? node.variableDeclaration.end : endPos); - write(" "); - emitBlock(node.block); - } - function emitDebuggerStatement(node) { - emitToken(74, node.pos); - write(";"); - } - function emitLabelledStatement(node) { - emit(node.label); - write(": "); - emit(node.statement); - } - function getContainingModule(node) { - do { - node = node.parent; - } while (node && node.kind !== 216); - return node; - } - function emitContainingModuleName(node) { - var container = getContainingModule(node); - write(container ? getGeneratedNameForNode(container) : "exports"); - } - function emitModuleMemberName(node) { - emitStart(node.name); - if (ts.getCombinedNodeFlags(node) & 1) { - var container = getContainingModule(node); - if (container) { - write(getGeneratedNameForNode(container)); - write("."); - } - else if (languageVersion < 2 && compilerOptions.module !== 4) { - write("exports."); - } - } - emitNodeWithCommentsAndWithoutSourcemap(node.name); - emitEnd(node.name); - } - function createVoidZero() { - var zero = ts.createSynthesizedNode(8); - zero.text = "0"; - var result = ts.createSynthesizedNode(175); - result.expression = zero; - return result; - } - function emitEs6ExportDefaultCompat(node) { - if (node.parent.kind === 246) { - ts.Debug.assert(!!(node.flags & 1024) || node.kind === 225); - if (compilerOptions.module === 1 || compilerOptions.module === 2 || compilerOptions.module === 3) { - if (!currentSourceFile.symbol.exports["___esModule"]) { - if (languageVersion === 1) { - write("Object.defineProperty(exports, \"__esModule\", { value: true });"); - writeLine(); - } - else if (languageVersion === 0) { - write("exports.__esModule = true;"); - writeLine(); - } - } - } - } - } - function emitExportMemberAssignment(node) { - if (node.flags & 1) { - writeLine(); - emitStart(node); - if (compilerOptions.module === 4 && node.parent === currentSourceFile) { - write(exportFunctionForFile + "(\""); - if (node.flags & 1024) { - write("default"); - } - else { - emitNodeWithCommentsAndWithoutSourcemap(node.name); - } - write("\", "); - emitDeclarationName(node); - write(")"); - } - else { - if (node.flags & 1024) { - emitEs6ExportDefaultCompat(node); - if (languageVersion === 0) { - write("exports[\"default\"]"); - } - else { - write("exports.default"); - } - } - else { - emitModuleMemberName(node); - } - write(" = "); - emitDeclarationName(node); - } - emitEnd(node); - write(";"); - } - } - function emitExportMemberAssignments(name) { - if (compilerOptions.module === 4) { - return; - } - if (!exportEquals && exportSpecifiers && ts.hasProperty(exportSpecifiers, name.text)) { - for (var _a = 0, _b = exportSpecifiers[name.text]; _a < _b.length; _a++) { - var specifier = _b[_a]; - writeLine(); - emitStart(specifier.name); - emitContainingModuleName(specifier); - write("."); - emitNodeWithCommentsAndWithoutSourcemap(specifier.name); - emitEnd(specifier.name); - write(" = "); - emitExpressionIdentifier(name); - write(";"); - } - } - } - function emitExportSpecifierInSystemModule(specifier) { - ts.Debug.assert(compilerOptions.module === 4); - if (!resolver.getReferencedValueDeclaration(specifier.propertyName || specifier.name) && !resolver.isValueAliasDeclaration(specifier)) { - return; - } - writeLine(); - emitStart(specifier.name); - write(exportFunctionForFile + "(\""); - emitNodeWithCommentsAndWithoutSourcemap(specifier.name); - write("\", "); - emitExpressionIdentifier(specifier.propertyName || specifier.name); - write(")"); - emitEnd(specifier.name); - write(";"); - } - function emitDestructuring(root, isAssignmentExpressionStatement, value) { - var emitCount = 0; - var canDefineTempVariablesInPlace = false; - if (root.kind === 209) { - var isExported = ts.getCombinedNodeFlags(root) & 1; - var isSourceLevelForSystemModuleKind = shouldHoistDeclarationInSystemJsModule(root); - canDefineTempVariablesInPlace = !isExported && !isSourceLevelForSystemModuleKind; - } - else if (root.kind === 136) { - canDefineTempVariablesInPlace = true; - } - if (root.kind === 179) { - emitAssignmentExpression(root); - } - else { - ts.Debug.assert(!isAssignmentExpressionStatement); - emitBindingElement(root, value); - } - function emitAssignment(name, value) { - if (emitCount++) { - write(", "); - } - var isVariableDeclarationOrBindingElement = name.parent && (name.parent.kind === 209 || name.parent.kind === 161); - var exportChanged = isNameOfExportedSourceLevelDeclarationInSystemExternalModule(name); - if (exportChanged) { - write(exportFunctionForFile + "(\""); - emitNodeWithCommentsAndWithoutSourcemap(name); - write("\", "); - } - if (isVariableDeclarationOrBindingElement) { - emitModuleMemberName(name.parent); - } - else { - emit(name); - } - write(" = "); - emit(value); - if (exportChanged) { - write(")"); - } - } - function ensureIdentifier(expr, reuseIdentifierExpressions) { - if (expr.kind === 67 && reuseIdentifierExpressions) { - return expr; - } - var identifier = createTempVariable(0); - if (!canDefineTempVariablesInPlace) { - recordTempDeclaration(identifier); - } - emitAssignment(identifier, expr); - return identifier; - } - function createDefaultValueCheck(value, defaultValue) { - value = ensureIdentifier(value, true); - var equals = ts.createSynthesizedNode(179); - equals.left = value; - equals.operatorToken = ts.createSynthesizedNode(32); - equals.right = createVoidZero(); - return createConditionalExpression(equals, defaultValue, value); - } - function createConditionalExpression(condition, whenTrue, whenFalse) { - var cond = ts.createSynthesizedNode(180); - cond.condition = condition; - cond.questionToken = ts.createSynthesizedNode(52); - cond.whenTrue = whenTrue; - cond.colonToken = ts.createSynthesizedNode(53); - cond.whenFalse = whenFalse; - return cond; - } - function createNumericLiteral(value) { - var node = ts.createSynthesizedNode(8); - node.text = "" + value; - return node; - } - function createPropertyAccessForDestructuringProperty(object, propName) { - var syntheticName = ts.createSynthesizedNode(propName.kind); - syntheticName.text = propName.text; - if (syntheticName.kind !== 67) { - return createElementAccessExpression(object, syntheticName); - } - return createPropertyAccessExpression(object, syntheticName); - } - function createSliceCall(value, sliceIndex) { - var call = ts.createSynthesizedNode(166); - var sliceIdentifier = ts.createSynthesizedNode(67); - sliceIdentifier.text = "slice"; - call.expression = createPropertyAccessExpression(value, sliceIdentifier); - call.arguments = ts.createSynthesizedNodeArray(); - call.arguments[0] = createNumericLiteral(sliceIndex); - return call; - } - function emitObjectLiteralAssignment(target, value) { - var properties = target.properties; - if (properties.length !== 1) { - value = ensureIdentifier(value, true); - } - for (var _a = 0; _a < properties.length; _a++) { - var p = properties[_a]; - if (p.kind === 243 || p.kind === 244) { - var propName = p.name; - emitDestructuringAssignment(p.initializer || propName, createPropertyAccessForDestructuringProperty(value, propName)); - } - } - } - function emitArrayLiteralAssignment(target, value) { - var elements = target.elements; - if (elements.length !== 1) { - value = ensureIdentifier(value, true); - } - for (var i = 0; i < elements.length; i++) { - var e = elements[i]; - if (e.kind !== 185) { - if (e.kind !== 183) { - emitDestructuringAssignment(e, createElementAccessExpression(value, createNumericLiteral(i))); - } - else if (i === elements.length - 1) { - emitDestructuringAssignment(e.expression, createSliceCall(value, i)); - } - } - } - } - function emitDestructuringAssignment(target, value) { - if (target.kind === 179 && target.operatorToken.kind === 55) { - value = createDefaultValueCheck(value, target.right); - target = target.left; - } - if (target.kind === 163) { - emitObjectLiteralAssignment(target, value); - } - else if (target.kind === 162) { - emitArrayLiteralAssignment(target, value); - } - else { - emitAssignment(target, value); - } - } - function emitAssignmentExpression(root) { - var target = root.left; - var value = root.right; - if (ts.isEmptyObjectLiteralOrArrayLiteral(target)) { - emit(value); - } - else if (isAssignmentExpressionStatement) { - emitDestructuringAssignment(target, value); - } - else { - if (root.parent.kind !== 170) { - write("("); - } - value = ensureIdentifier(value, true); - emitDestructuringAssignment(target, value); - write(", "); - emit(value); - if (root.parent.kind !== 170) { - write(")"); - } - } - } - function emitBindingElement(target, value) { - if (target.initializer) { - value = value ? createDefaultValueCheck(value, target.initializer) : target.initializer; - } - else if (!value) { - value = createVoidZero(); - } - if (ts.isBindingPattern(target.name)) { - var pattern = target.name; - var elements = pattern.elements; - var numElements = elements.length; - if (numElements !== 1) { - value = ensureIdentifier(value, numElements !== 0); - } - for (var i = 0; i < numElements; i++) { - var element = elements[i]; - if (pattern.kind === 159) { - var propName = element.propertyName || element.name; - emitBindingElement(element, createPropertyAccessForDestructuringProperty(value, propName)); - } - else if (element.kind !== 185) { - if (!element.dotDotDotToken) { - emitBindingElement(element, createElementAccessExpression(value, createNumericLiteral(i))); - } - else if (i === numElements - 1) { - emitBindingElement(element, createSliceCall(value, i)); - } - } - } - } - else { - emitAssignment(target.name, value); - } - } - } - function emitVariableDeclaration(node) { - if (ts.isBindingPattern(node.name)) { - if (languageVersion < 2) { - emitDestructuring(node, false); - } - else { - emit(node.name); - emitOptional(" = ", node.initializer); - } - } - else { - var initializer = node.initializer; - if (!initializer && languageVersion < 2) { - var isUninitializedLet = (resolver.getNodeCheckFlags(node) & 16384) && - (getCombinedFlagsForIdentifier(node.name) & 16384); - if (isUninitializedLet && - node.parent.parent.kind !== 198 && - node.parent.parent.kind !== 199) { - initializer = createVoidZero(); - } - } - var exportChanged = isNameOfExportedSourceLevelDeclarationInSystemExternalModule(node.name); - if (exportChanged) { - write(exportFunctionForFile + "(\""); - emitNodeWithCommentsAndWithoutSourcemap(node.name); - write("\", "); - } - emitModuleMemberName(node); - emitOptional(" = ", initializer); - if (exportChanged) { - write(")"); - } - } - } - function emitExportVariableAssignments(node) { - if (node.kind === 185) { - return; - } - var name = node.name; - if (name.kind === 67) { - emitExportMemberAssignments(name); - } - else if (ts.isBindingPattern(name)) { - ts.forEach(name.elements, emitExportVariableAssignments); - } - } - function getCombinedFlagsForIdentifier(node) { - if (!node.parent || (node.parent.kind !== 209 && node.parent.kind !== 161)) { - return 0; - } - return ts.getCombinedNodeFlags(node.parent); - } - function isES6ExportedDeclaration(node) { - return !!(node.flags & 1) && - languageVersion >= 2 && - node.parent.kind === 246; - } - function emitVariableStatement(node) { - var startIsEmitted = false; - if (node.flags & 1) { - if (isES6ExportedDeclaration(node)) { - write("export "); - startIsEmitted = tryEmitStartOfVariableDeclarationList(node.declarationList); - } - } - else { - startIsEmitted = tryEmitStartOfVariableDeclarationList(node.declarationList); - } - if (startIsEmitted) { - emitCommaList(node.declarationList.declarations); - write(";"); - } - else { - var atLeastOneItem = emitVariableDeclarationListSkippingUninitializedEntries(node.declarationList); - if (atLeastOneItem) { - write(";"); - } - } - if (languageVersion < 2 && node.parent === currentSourceFile) { - ts.forEach(node.declarationList.declarations, emitExportVariableAssignments); - } - } - function shouldEmitLeadingAndTrailingCommentsForVariableStatement(node) { - if (!(node.flags & 1)) { - return true; - } - if (isES6ExportedDeclaration(node)) { - return true; - } - for (var _a = 0, _b = node.declarationList.declarations; _a < _b.length; _a++) { - var declaration = _b[_a]; - if (declaration.initializer) { - return true; - } - } - return false; - } - function emitParameter(node) { - if (languageVersion < 2) { - if (ts.isBindingPattern(node.name)) { - var name_24 = createTempVariable(0); - if (!tempParameters) { - tempParameters = []; - } - tempParameters.push(name_24); - emit(name_24); - } - else { - emit(node.name); - } - } - else { - if (node.dotDotDotToken) { - write("..."); - } - emit(node.name); - emitOptional(" = ", node.initializer); - } - } - function emitDefaultValueAssignments(node) { - if (languageVersion < 2) { - var tempIndex = 0; - ts.forEach(node.parameters, function (parameter) { - if (parameter.dotDotDotToken) { - return; - } - var paramName = parameter.name, initializer = parameter.initializer; - if (ts.isBindingPattern(paramName)) { - var hasBindingElements = paramName.elements.length > 0; - if (hasBindingElements || initializer) { - writeLine(); - write("var "); - if (hasBindingElements) { - emitDestructuring(parameter, false, tempParameters[tempIndex]); - } - else { - emit(tempParameters[tempIndex]); - write(" = "); - emit(initializer); - } - write(";"); - tempIndex++; - } - } - else if (initializer) { - writeLine(); - emitStart(parameter); - write("if ("); - emitNodeWithoutSourceMap(paramName); - write(" === void 0)"); - emitEnd(parameter); - write(" { "); - emitStart(parameter); - emitNodeWithCommentsAndWithoutSourcemap(paramName); - write(" = "); - emitNodeWithCommentsAndWithoutSourcemap(initializer); - emitEnd(parameter); - write("; }"); - } - }); - } - } - function emitRestParameter(node) { - if (languageVersion < 2 && ts.hasRestParameter(node)) { - var restIndex = node.parameters.length - 1; - var restParam = node.parameters[restIndex]; - if (ts.isBindingPattern(restParam.name)) { - return; - } - var tempName = createTempVariable(268435456).text; - writeLine(); - emitLeadingComments(restParam); - emitStart(restParam); - write("var "); - emitNodeWithCommentsAndWithoutSourcemap(restParam.name); - write(" = [];"); - emitEnd(restParam); - emitTrailingComments(restParam); - writeLine(); - write("for ("); - emitStart(restParam); - write("var " + tempName + " = " + restIndex + ";"); - emitEnd(restParam); - write(" "); - emitStart(restParam); - write(tempName + " < arguments.length;"); - emitEnd(restParam); - write(" "); - emitStart(restParam); - write(tempName + "++"); - emitEnd(restParam); - write(") {"); - increaseIndent(); - writeLine(); - emitStart(restParam); - emitNodeWithCommentsAndWithoutSourcemap(restParam.name); - write("[" + tempName + " - " + restIndex + "] = arguments[" + tempName + "];"); - emitEnd(restParam); - decreaseIndent(); - writeLine(); - write("}"); - } - } - function emitAccessor(node) { - write(node.kind === 143 ? "get " : "set "); - emit(node.name); - emitSignatureAndBody(node); - } - function shouldEmitAsArrowFunction(node) { - return node.kind === 172 && languageVersion >= 2; - } - function emitDeclarationName(node) { - if (node.name) { - emitNodeWithCommentsAndWithoutSourcemap(node.name); - } - else { - write(getGeneratedNameForNode(node)); - } - } - function shouldEmitFunctionName(node) { - if (node.kind === 171) { - return !!node.name; - } - if (node.kind === 211) { - return !!node.name || languageVersion < 2; - } - } - function emitFunctionDeclaration(node) { - if (ts.nodeIsMissing(node.body)) { - return emitCommentsOnNotEmittedNode(node); - } - if (node.kind !== 141 && node.kind !== 140 && - node.parent && node.parent.kind !== 243 && - node.parent.kind !== 166) { - emitLeadingComments(node); - } - emitStart(node); - if (!shouldEmitAsArrowFunction(node)) { - if (isES6ExportedDeclaration(node)) { - write("export "); - if (node.flags & 1024) { - write("default "); - } - } - write("function"); - if (languageVersion >= 2 && node.asteriskToken) { - write("*"); - } - write(" "); - } - if (shouldEmitFunctionName(node)) { - emitDeclarationName(node); - } - emitSignatureAndBody(node); - if (languageVersion < 2 && node.kind === 211 && node.parent === currentSourceFile && node.name) { - emitExportMemberAssignments(node.name); - } - emitEnd(node); - if (node.kind !== 141 && node.kind !== 140) { - emitTrailingComments(node); - } - } - function emitCaptureThisForNodeIfNecessary(node) { - if (resolver.getNodeCheckFlags(node) & 4) { - writeLine(); - emitStart(node); - write("var _this = this;"); - emitEnd(node); - } - } - function emitSignatureParameters(node) { - increaseIndent(); - write("("); - if (node) { - var parameters = node.parameters; - var omitCount = languageVersion < 2 && ts.hasRestParameter(node) ? 1 : 0; - emitList(parameters, 0, parameters.length - omitCount, false, false); - } - write(")"); - decreaseIndent(); - } - function emitSignatureParametersForArrow(node) { - if (node.parameters.length === 1 && node.pos === node.parameters[0].pos) { - emit(node.parameters[0]); - return; - } - emitSignatureParameters(node); - } - function emitAsyncFunctionBodyForES6(node) { - var promiseConstructor = ts.getEntityNameFromTypeNode(node.type); - var isArrowFunction = node.kind === 172; - var hasLexicalArguments = (resolver.getNodeCheckFlags(node) & 4096) !== 0; - var args; - if (!isArrowFunction) { - write(" {"); - increaseIndent(); - writeLine(); - write("return"); - } - write(" __awaiter(this"); - if (hasLexicalArguments) { - write(", arguments"); - } - else { - write(", void 0"); - } - if (promiseConstructor) { - write(", "); - emitNodeWithoutSourceMap(promiseConstructor); - } - else { - write(", Promise"); - } - if (hasLexicalArguments) { - write(", function* (_arguments)"); - } - else { - write(", function* ()"); - } - emitFunctionBody(node); - write(")"); - if (!isArrowFunction) { - write(";"); - decreaseIndent(); - writeLine(); - write("}"); - } - } - function emitFunctionBody(node) { - if (!node.body) { - write(" { }"); - } - else { - if (node.body.kind === 190) { - emitBlockFunctionBody(node, node.body); - } - else { - emitExpressionFunctionBody(node, node.body); - } - } - } - function emitSignatureAndBody(node) { - var saveTempFlags = tempFlags; - var saveTempVariables = tempVariables; - var saveTempParameters = tempParameters; - tempFlags = 0; - tempVariables = undefined; - tempParameters = undefined; - if (shouldEmitAsArrowFunction(node)) { - emitSignatureParametersForArrow(node); - write(" =>"); - } - else { - emitSignatureParameters(node); - } - var isAsync = ts.isAsyncFunctionLike(node); - if (isAsync && languageVersion === 2) { - emitAsyncFunctionBodyForES6(node); - } - else { - emitFunctionBody(node); - } - if (!isES6ExportedDeclaration(node)) { - emitExportMemberAssignment(node); - } - tempFlags = saveTempFlags; - tempVariables = saveTempVariables; - tempParameters = saveTempParameters; - } - function emitFunctionBodyPreamble(node) { - emitCaptureThisForNodeIfNecessary(node); - emitDefaultValueAssignments(node); - emitRestParameter(node); - } - function emitExpressionFunctionBody(node, body) { - if (languageVersion < 2 || node.flags & 512) { - emitDownLevelExpressionFunctionBody(node, body); - return; - } - write(" "); - var current = body; - while (current.kind === 169) { - current = current.expression; - } - emitParenthesizedIf(body, current.kind === 163); - } - function emitDownLevelExpressionFunctionBody(node, body) { - write(" {"); - scopeEmitStart(node); - increaseIndent(); - var outPos = writer.getTextPos(); - emitDetachedComments(node.body); - emitFunctionBodyPreamble(node); - var preambleEmitted = writer.getTextPos() !== outPos; - decreaseIndent(); - if (!preambleEmitted && nodeStartPositionsAreOnSameLine(node, body)) { - write(" "); - emitStart(body); - write("return "); - emit(body); - emitEnd(body); - write(";"); - emitTempDeclarations(false); - write(" "); - } - else { - increaseIndent(); - writeLine(); - emitLeadingComments(node.body); - write("return "); - emit(body); - write(";"); - emitTrailingComments(node.body); - emitTempDeclarations(true); - decreaseIndent(); - writeLine(); - } - emitStart(node.body); - write("}"); - emitEnd(node.body); - scopeEmitEnd(); - } - function emitBlockFunctionBody(node, body) { - write(" {"); - scopeEmitStart(node); - var initialTextPos = writer.getTextPos(); - increaseIndent(); - emitDetachedComments(body.statements); - var startIndex = emitDirectivePrologues(body.statements, true); - emitFunctionBodyPreamble(node); - decreaseIndent(); - var preambleEmitted = writer.getTextPos() !== initialTextPos; - if (!preambleEmitted && nodeEndIsOnSameLineAsNodeStart(body, body)) { - for (var _a = 0, _b = body.statements; _a < _b.length; _a++) { - var statement = _b[_a]; - write(" "); - emit(statement); - } - emitTempDeclarations(false); - write(" "); - emitLeadingCommentsOfPosition(body.statements.end); - } - else { - increaseIndent(); - emitLinesStartingAt(body.statements, startIndex); - emitTempDeclarations(true); - writeLine(); - emitLeadingCommentsOfPosition(body.statements.end); - decreaseIndent(); - } - emitToken(16, body.statements.end); - scopeEmitEnd(); - } - function findInitialSuperCall(ctor) { - if (ctor.body) { - var statement = ctor.body.statements[0]; - if (statement && statement.kind === 193) { - var expr = statement.expression; - if (expr && expr.kind === 166) { - var func = expr.expression; - if (func && func.kind === 93) { - return statement; - } - } - } - } - } - function emitParameterPropertyAssignments(node) { - ts.forEach(node.parameters, function (param) { - if (param.flags & 112) { - writeLine(); - emitStart(param); - emitStart(param.name); - write("this."); - emitNodeWithoutSourceMap(param.name); - emitEnd(param.name); - write(" = "); - emit(param.name); - write(";"); - emitEnd(param); - } - }); - } - function emitMemberAccessForPropertyName(memberName) { - if (memberName.kind === 9 || memberName.kind === 8) { - write("["); - emitNodeWithCommentsAndWithoutSourcemap(memberName); - write("]"); - } - else if (memberName.kind === 134) { - emitComputedPropertyName(memberName); - } - else { - write("."); - emitNodeWithCommentsAndWithoutSourcemap(memberName); - } - } - function getInitializedProperties(node, isStatic) { - var properties = []; - for (var _a = 0, _b = node.members; _a < _b.length; _a++) { - var member = _b[_a]; - if (member.kind === 139 && isStatic === ((member.flags & 128) !== 0) && member.initializer) { - properties.push(member); - } - } - return properties; - } - function emitPropertyDeclarations(node, properties) { - for (var _a = 0; _a < properties.length; _a++) { - var property = properties[_a]; - emitPropertyDeclaration(node, property); - } - } - function emitPropertyDeclaration(node, property, receiver, isExpression) { - writeLine(); - emitLeadingComments(property); - emitStart(property); - emitStart(property.name); - if (receiver) { - emit(receiver); - } - else { - if (property.flags & 128) { - emitDeclarationName(node); - } - else { - write("this"); - } - } - emitMemberAccessForPropertyName(property.name); - emitEnd(property.name); - write(" = "); - emit(property.initializer); - if (!isExpression) { - write(";"); - } - emitEnd(property); - emitTrailingComments(property); - } - function emitMemberFunctionsForES5AndLower(node) { - ts.forEach(node.members, function (member) { - if (member.kind === 189) { - writeLine(); - write(";"); - } - else if (member.kind === 141 || node.kind === 140) { - if (!member.body) { - return emitCommentsOnNotEmittedNode(member); - } - writeLine(); - emitLeadingComments(member); - emitStart(member); - emitStart(member.name); - emitClassMemberPrefix(node, member); - emitMemberAccessForPropertyName(member.name); - emitEnd(member.name); - write(" = "); - emitFunctionDeclaration(member); - emitEnd(member); - write(";"); - emitTrailingComments(member); - } - else if (member.kind === 143 || member.kind === 144) { - var accessors = ts.getAllAccessorDeclarations(node.members, member); - if (member === accessors.firstAccessor) { - writeLine(); - emitStart(member); - write("Object.defineProperty("); - emitStart(member.name); - emitClassMemberPrefix(node, member); - write(", "); - emitExpressionForPropertyName(member.name); - emitEnd(member.name); - write(", {"); - increaseIndent(); - if (accessors.getAccessor) { - writeLine(); - emitLeadingComments(accessors.getAccessor); - write("get: "); - emitStart(accessors.getAccessor); - write("function "); - emitSignatureAndBody(accessors.getAccessor); - emitEnd(accessors.getAccessor); - emitTrailingComments(accessors.getAccessor); - write(","); - } - if (accessors.setAccessor) { - writeLine(); - emitLeadingComments(accessors.setAccessor); - write("set: "); - emitStart(accessors.setAccessor); - write("function "); - emitSignatureAndBody(accessors.setAccessor); - emitEnd(accessors.setAccessor); - emitTrailingComments(accessors.setAccessor); - write(","); - } - writeLine(); - write("enumerable: true,"); - writeLine(); - write("configurable: true"); - decreaseIndent(); - writeLine(); - write("});"); - emitEnd(member); - } - } - }); - } - function emitMemberFunctionsForES6AndHigher(node) { - for (var _a = 0, _b = node.members; _a < _b.length; _a++) { - var member = _b[_a]; - if ((member.kind === 141 || node.kind === 140) && !member.body) { - emitCommentsOnNotEmittedNode(member); - } - else if (member.kind === 141 || - member.kind === 143 || - member.kind === 144) { - writeLine(); - emitLeadingComments(member); - emitStart(member); - if (member.flags & 128) { - write("static "); - } - if (member.kind === 143) { - write("get "); - } - else if (member.kind === 144) { - write("set "); - } - if (member.asteriskToken) { - write("*"); - } - emit(member.name); - emitSignatureAndBody(member); - emitEnd(member); - emitTrailingComments(member); - } - else if (member.kind === 189) { - writeLine(); - write(";"); - } - } - } - function emitConstructor(node, baseTypeElement) { - var saveTempFlags = tempFlags; - var saveTempVariables = tempVariables; - var saveTempParameters = tempParameters; - tempFlags = 0; - tempVariables = undefined; - tempParameters = undefined; - emitConstructorWorker(node, baseTypeElement); - tempFlags = saveTempFlags; - tempVariables = saveTempVariables; - tempParameters = saveTempParameters; - } - function emitConstructorWorker(node, baseTypeElement) { - var hasInstancePropertyWithInitializer = false; - ts.forEach(node.members, function (member) { - if (member.kind === 142 && !member.body) { - emitCommentsOnNotEmittedNode(member); - } - if (member.kind === 139 && member.initializer && (member.flags & 128) === 0) { - hasInstancePropertyWithInitializer = true; - } - }); - var ctor = ts.getFirstConstructorWithBody(node); - if (languageVersion >= 2 && !ctor && !hasInstancePropertyWithInitializer) { - return; - } - if (ctor) { - emitLeadingComments(ctor); - } - emitStart(ctor || node); - if (languageVersion < 2) { - write("function "); - emitDeclarationName(node); - emitSignatureParameters(ctor); - } - else { - write("constructor"); - if (ctor) { - emitSignatureParameters(ctor); - } - else { - if (baseTypeElement) { - write("(...args)"); - } - else { - write("()"); - } - } - } - var startIndex = 0; - write(" {"); - scopeEmitStart(node, "constructor"); - increaseIndent(); - if (ctor) { - startIndex = emitDirectivePrologues(ctor.body.statements, true); - emitDetachedComments(ctor.body.statements); - } - emitCaptureThisForNodeIfNecessary(node); - var superCall; - if (ctor) { - emitDefaultValueAssignments(ctor); - emitRestParameter(ctor); - if (baseTypeElement) { - superCall = findInitialSuperCall(ctor); - if (superCall) { - writeLine(); - emit(superCall); - } - } - emitParameterPropertyAssignments(ctor); - } - else { - if (baseTypeElement) { - writeLine(); - emitStart(baseTypeElement); - if (languageVersion < 2) { - write("_super.apply(this, arguments);"); - } - else { - write("super(...args);"); - } - emitEnd(baseTypeElement); - } - } - emitPropertyDeclarations(node, getInitializedProperties(node, false)); - if (ctor) { - var statements = ctor.body.statements; - if (superCall) { - statements = statements.slice(1); - } - emitLinesStartingAt(statements, startIndex); - } - emitTempDeclarations(true); - writeLine(); - if (ctor) { - emitLeadingCommentsOfPosition(ctor.body.statements.end); - } - decreaseIndent(); - emitToken(16, ctor ? ctor.body.statements.end : node.members.end); - scopeEmitEnd(); - emitEnd(ctor || node); - if (ctor) { - emitTrailingComments(ctor); - } - } - function emitClassExpression(node) { - return emitClassLikeDeclaration(node); - } - function emitClassDeclaration(node) { - return emitClassLikeDeclaration(node); - } - function emitClassLikeDeclaration(node) { - if (languageVersion < 2) { - emitClassLikeDeclarationBelowES6(node); - } - else { - emitClassLikeDeclarationForES6AndHigher(node); - } - } - function emitClassLikeDeclarationForES6AndHigher(node) { - var thisNodeIsDecorated = ts.nodeIsDecorated(node); - if (node.kind === 212) { - if (thisNodeIsDecorated) { - if (isES6ExportedDeclaration(node) && !(node.flags & 1024)) { - write("export "); - } - write("let "); - emitDeclarationName(node); - write(" = "); - } - else if (isES6ExportedDeclaration(node)) { - write("export "); - if (node.flags & 1024) { - write("default "); - } - } - } - var staticProperties = getInitializedProperties(node, true); - var isClassExpressionWithStaticProperties = staticProperties.length > 0 && node.kind === 184; - var tempVariable; - if (isClassExpressionWithStaticProperties) { - tempVariable = createAndRecordTempVariable(0); - write("("); - increaseIndent(); - emit(tempVariable); - write(" = "); - } - write("class"); - if ((node.name || !(node.flags & 1024)) && !thisNodeIsDecorated) { - write(" "); - emitDeclarationName(node); - } - var baseTypeNode = ts.getClassExtendsHeritageClauseElement(node); - if (baseTypeNode) { - write(" extends "); - emit(baseTypeNode.expression); - } - write(" {"); - increaseIndent(); - scopeEmitStart(node); - writeLine(); - emitConstructor(node, baseTypeNode); - emitMemberFunctionsForES6AndHigher(node); - decreaseIndent(); - writeLine(); - emitToken(16, node.members.end); - scopeEmitEnd(); - if (thisNodeIsDecorated) { - write(";"); - } - if (isClassExpressionWithStaticProperties) { - for (var _a = 0; _a < staticProperties.length; _a++) { - var property = staticProperties[_a]; - write(","); - writeLine(); - emitPropertyDeclaration(node, property, tempVariable, true); - } - write(","); - writeLine(); - emit(tempVariable); - decreaseIndent(); - write(")"); - } - else { - writeLine(); - emitPropertyDeclarations(node, staticProperties); - emitDecoratorsOfClass(node); - } - if (!isES6ExportedDeclaration(node) && (node.flags & 1)) { - writeLine(); - emitStart(node); - emitModuleMemberName(node); - write(" = "); - emitDeclarationName(node); - emitEnd(node); - write(";"); - } - else if (isES6ExportedDeclaration(node) && (node.flags & 1024) && thisNodeIsDecorated) { - writeLine(); - write("export default "); - emitDeclarationName(node); - write(";"); - } - } - function emitClassLikeDeclarationBelowES6(node) { - if (node.kind === 212) { - if (!shouldHoistDeclarationInSystemJsModule(node)) { - write("var "); - } - emitDeclarationName(node); - write(" = "); - } - write("(function ("); - var baseTypeNode = ts.getClassExtendsHeritageClauseElement(node); - if (baseTypeNode) { - write("_super"); - } - write(") {"); - var saveTempFlags = tempFlags; - var saveTempVariables = tempVariables; - var saveTempParameters = tempParameters; - var saveComputedPropertyNamesToGeneratedNames = computedPropertyNamesToGeneratedNames; - tempFlags = 0; - tempVariables = undefined; - tempParameters = undefined; - computedPropertyNamesToGeneratedNames = undefined; - increaseIndent(); - scopeEmitStart(node); - if (baseTypeNode) { - writeLine(); - emitStart(baseTypeNode); - write("__extends("); - emitDeclarationName(node); - write(", _super);"); - emitEnd(baseTypeNode); - } - writeLine(); - emitConstructor(node, baseTypeNode); - emitMemberFunctionsForES5AndLower(node); - emitPropertyDeclarations(node, getInitializedProperties(node, true)); - writeLine(); - emitDecoratorsOfClass(node); - writeLine(); - emitToken(16, node.members.end, function () { - write("return "); - emitDeclarationName(node); - }); - write(";"); - emitTempDeclarations(true); - tempFlags = saveTempFlags; - tempVariables = saveTempVariables; - tempParameters = saveTempParameters; - computedPropertyNamesToGeneratedNames = saveComputedPropertyNamesToGeneratedNames; - decreaseIndent(); - writeLine(); - emitToken(16, node.members.end); - scopeEmitEnd(); - emitStart(node); - write(")("); - if (baseTypeNode) { - emit(baseTypeNode.expression); - } - write(")"); - if (node.kind === 212) { - write(";"); - } - emitEnd(node); - if (node.kind === 212) { - emitExportMemberAssignment(node); - } - if (languageVersion < 2 && node.parent === currentSourceFile && node.name) { - emitExportMemberAssignments(node.name); - } - } - function emitClassMemberPrefix(node, member) { - emitDeclarationName(node); - if (!(member.flags & 128)) { - write(".prototype"); - } - } - function emitDecoratorsOfClass(node) { - emitDecoratorsOfMembers(node, 0); - emitDecoratorsOfMembers(node, 128); - emitDecoratorsOfConstructor(node); - } - function emitDecoratorsOfConstructor(node) { - var decorators = node.decorators; - var constructor = ts.getFirstConstructorWithBody(node); - var hasDecoratedParameters = constructor && ts.forEach(constructor.parameters, ts.nodeIsDecorated); - if (!decorators && !hasDecoratedParameters) { - return; - } - writeLine(); - emitStart(node); - emitDeclarationName(node); - write(" = __decorate(["); - increaseIndent(); - writeLine(); - var decoratorCount = decorators ? decorators.length : 0; - var argumentsWritten = emitList(decorators, 0, decoratorCount, true, false, false, true, function (decorator) { - emitStart(decorator); - emit(decorator.expression); - emitEnd(decorator); - }); - argumentsWritten += emitDecoratorsOfParameters(constructor, argumentsWritten > 0); - emitSerializedTypeMetadata(node, argumentsWritten >= 0); - decreaseIndent(); - writeLine(); - write("], "); - emitDeclarationName(node); - write(");"); - emitEnd(node); - writeLine(); - } - function emitDecoratorsOfMembers(node, staticFlag) { - for (var _a = 0, _b = node.members; _a < _b.length; _a++) { - var member = _b[_a]; - if ((member.flags & 128) !== staticFlag) { - continue; - } - if (!ts.nodeCanBeDecorated(member)) { - continue; - } - if (!ts.nodeOrChildIsDecorated(member)) { - continue; - } - var decorators = void 0; - var functionLikeMember = void 0; - if (ts.isAccessor(member)) { - var accessors = ts.getAllAccessorDeclarations(node.members, member); - if (member !== accessors.firstAccessor) { - continue; - } - decorators = accessors.firstAccessor.decorators; - if (!decorators && accessors.secondAccessor) { - decorators = accessors.secondAccessor.decorators; - } - functionLikeMember = accessors.setAccessor; - } - else { - decorators = member.decorators; - if (member.kind === 141) { - functionLikeMember = member; - } - } - writeLine(); - emitStart(member); - if (member.kind !== 139) { - write("Object.defineProperty("); - emitStart(member.name); - emitClassMemberPrefix(node, member); - write(", "); - emitExpressionForPropertyName(member.name); - emitEnd(member.name); - write(","); - increaseIndent(); - writeLine(); - } - write("__decorate(["); - increaseIndent(); - writeLine(); - var decoratorCount = decorators ? decorators.length : 0; - var argumentsWritten = emitList(decorators, 0, decoratorCount, true, false, false, true, function (decorator) { - emitStart(decorator); - emit(decorator.expression); - emitEnd(decorator); - }); - argumentsWritten += emitDecoratorsOfParameters(functionLikeMember, argumentsWritten > 0); - emitSerializedTypeMetadata(member, argumentsWritten > 0); - decreaseIndent(); - writeLine(); - write("], "); - emitStart(member.name); - emitClassMemberPrefix(node, member); - write(", "); - emitExpressionForPropertyName(member.name); - emitEnd(member.name); - if (member.kind !== 139) { - write(", Object.getOwnPropertyDescriptor("); - emitStart(member.name); - emitClassMemberPrefix(node, member); - write(", "); - emitExpressionForPropertyName(member.name); - emitEnd(member.name); - write("))"); - decreaseIndent(); - } - write(");"); - emitEnd(member); - writeLine(); - } - } - function emitDecoratorsOfParameters(node, leadingComma) { - var argumentsWritten = 0; - if (node) { - var parameterIndex = 0; - for (var _a = 0, _b = node.parameters; _a < _b.length; _a++) { - var parameter = _b[_a]; - if (ts.nodeIsDecorated(parameter)) { - var decorators = parameter.decorators; - argumentsWritten += emitList(decorators, 0, decorators.length, true, false, leadingComma, true, function (decorator) { - emitStart(decorator); - write("__param(" + parameterIndex + ", "); - emit(decorator.expression); - write(")"); - emitEnd(decorator); - }); - leadingComma = true; - } - ++parameterIndex; - } - } - return argumentsWritten; - } - function shouldEmitTypeMetadata(node) { - switch (node.kind) { - case 141: - case 143: - case 144: - case 139: - return true; - } - return false; - } - function shouldEmitReturnTypeMetadata(node) { - switch (node.kind) { - case 141: - return true; - } - return false; - } - function shouldEmitParamTypesMetadata(node) { - switch (node.kind) { - case 212: - case 141: - case 144: - return true; - } - return false; - } - function emitSerializedTypeOfNode(node) { - switch (node.kind) { - case 212: - write("Function"); - return; - case 139: - emitSerializedTypeNode(node.type); - return; - case 136: - emitSerializedTypeNode(node.type); - return; - case 143: - emitSerializedTypeNode(node.type); - return; - case 144: - emitSerializedTypeNode(ts.getSetAccessorTypeAnnotationNode(node)); - return; - } - if (ts.isFunctionLike(node)) { - write("Function"); - return; - } - write("void 0"); - } - function emitSerializedTypeNode(node) { - if (node) { - switch (node.kind) { - case 101: - write("void 0"); - return; - case 158: - emitSerializedTypeNode(node.type); - return; - case 150: - case 151: - write("Function"); - return; - case 154: - case 155: - write("Array"); - return; - case 148: - case 118: - write("Boolean"); - return; - case 128: - case 9: - write("String"); - return; - case 126: - write("Number"); - return; - case 129: - write("Symbol"); - return; - case 149: - emitSerializedTypeReferenceNode(node); - return; - case 152: - case 153: - case 156: - case 157: - case 115: - break; - default: - ts.Debug.fail("Cannot serialize unexpected type node."); - break; - } - } - write("Object"); - } - function emitSerializedTypeReferenceNode(node) { - var location = node.parent; - while (ts.isDeclaration(location) || ts.isTypeNode(location)) { - location = location.parent; - } - var typeName = ts.cloneEntityName(node.typeName); - typeName.parent = location; - var result = resolver.getTypeReferenceSerializationKind(typeName); - switch (result) { - case ts.TypeReferenceSerializationKind.Unknown: - var temp = createAndRecordTempVariable(0); - write("(typeof ("); - emitNodeWithoutSourceMap(temp); - write(" = "); - emitEntityNameAsExpression(typeName, true); - write(") === 'function' && "); - emitNodeWithoutSourceMap(temp); - write(") || Object"); - break; - case ts.TypeReferenceSerializationKind.TypeWithConstructSignatureAndValue: - emitEntityNameAsExpression(typeName, false); - break; - case ts.TypeReferenceSerializationKind.VoidType: - write("void 0"); - break; - case ts.TypeReferenceSerializationKind.BooleanType: - write("Boolean"); - break; - case ts.TypeReferenceSerializationKind.NumberLikeType: - write("Number"); - break; - case ts.TypeReferenceSerializationKind.StringLikeType: - write("String"); - break; - case ts.TypeReferenceSerializationKind.ArrayLikeType: - write("Array"); - break; - case ts.TypeReferenceSerializationKind.ESSymbolType: - if (languageVersion < 2) { - write("typeof Symbol === 'function' ? Symbol : Object"); - } - else { - write("Symbol"); - } - break; - case ts.TypeReferenceSerializationKind.TypeWithCallSignature: - write("Function"); - break; - case ts.TypeReferenceSerializationKind.ObjectType: - write("Object"); - break; - } - } - function emitSerializedParameterTypesOfNode(node) { - if (node) { - var valueDeclaration; - if (node.kind === 212) { - valueDeclaration = ts.getFirstConstructorWithBody(node); - } - else if (ts.isFunctionLike(node) && ts.nodeIsPresent(node.body)) { - valueDeclaration = node; - } - if (valueDeclaration) { - var parameters = valueDeclaration.parameters; - var parameterCount = parameters.length; - if (parameterCount > 0) { - for (var i = 0; i < parameterCount; i++) { - if (i > 0) { - write(", "); - } - if (parameters[i].dotDotDotToken) { - var parameterType = parameters[i].type; - if (parameterType.kind === 154) { - parameterType = parameterType.elementType; - } - else if (parameterType.kind === 149 && parameterType.typeArguments && parameterType.typeArguments.length === 1) { - parameterType = parameterType.typeArguments[0]; - } - else { - parameterType = undefined; - } - emitSerializedTypeNode(parameterType); - } - else { - emitSerializedTypeOfNode(parameters[i]); - } - } - } - } - } - } - function emitSerializedReturnTypeOfNode(node) { - if (node && ts.isFunctionLike(node) && node.type) { - emitSerializedTypeNode(node.type); - return; - } - write("void 0"); - } - function emitSerializedTypeMetadata(node, writeComma) { - var argumentsWritten = 0; - if (compilerOptions.emitDecoratorMetadata) { - if (shouldEmitTypeMetadata(node)) { - if (writeComma) { - write(", "); - } - writeLine(); - write("__metadata('design:type', "); - emitSerializedTypeOfNode(node); - write(")"); - argumentsWritten++; - } - if (shouldEmitParamTypesMetadata(node)) { - if (writeComma || argumentsWritten) { - write(", "); - } - writeLine(); - write("__metadata('design:paramtypes', ["); - emitSerializedParameterTypesOfNode(node); - write("])"); - argumentsWritten++; - } - if (shouldEmitReturnTypeMetadata(node)) { - if (writeComma || argumentsWritten) { - write(", "); - } - writeLine(); - write("__metadata('design:returntype', "); - emitSerializedReturnTypeOfNode(node); - write(")"); - argumentsWritten++; - } - } - return argumentsWritten; - } - function emitInterfaceDeclaration(node) { - emitCommentsOnNotEmittedNode(node); - } - function shouldEmitEnumDeclaration(node) { - var isConstEnum = ts.isConst(node); - return !isConstEnum || compilerOptions.preserveConstEnums || compilerOptions.isolatedModules; - } - function emitEnumDeclaration(node) { - if (!shouldEmitEnumDeclaration(node)) { - return; - } - if (!shouldHoistDeclarationInSystemJsModule(node)) { - if (!(node.flags & 1) || isES6ExportedDeclaration(node)) { - emitStart(node); - if (isES6ExportedDeclaration(node)) { - write("export "); - } - write("var "); - emit(node.name); - emitEnd(node); - write(";"); - } - } - writeLine(); - emitStart(node); - write("(function ("); - emitStart(node.name); - write(getGeneratedNameForNode(node)); - emitEnd(node.name); - write(") {"); - increaseIndent(); - scopeEmitStart(node); - emitLines(node.members); - decreaseIndent(); - writeLine(); - emitToken(16, node.members.end); - scopeEmitEnd(); - write(")("); - emitModuleMemberName(node); - write(" || ("); - emitModuleMemberName(node); - write(" = {}));"); - emitEnd(node); - if (!isES6ExportedDeclaration(node) && node.flags & 1 && !shouldHoistDeclarationInSystemJsModule(node)) { - writeLine(); - emitStart(node); - write("var "); - emit(node.name); - write(" = "); - emitModuleMemberName(node); - emitEnd(node); - write(";"); - } - if (languageVersion < 2 && node.parent === currentSourceFile) { - if (compilerOptions.module === 4 && (node.flags & 1)) { - writeLine(); - write(exportFunctionForFile + "(\""); - emitDeclarationName(node); - write("\", "); - emitDeclarationName(node); - write(");"); - } - emitExportMemberAssignments(node.name); - } - } - function emitEnumMember(node) { - var enumParent = node.parent; - emitStart(node); - write(getGeneratedNameForNode(enumParent)); - write("["); - write(getGeneratedNameForNode(enumParent)); - write("["); - emitExpressionForPropertyName(node.name); - write("] = "); - writeEnumMemberDeclarationValue(node); - write("] = "); - emitExpressionForPropertyName(node.name); - emitEnd(node); - write(";"); - } - function writeEnumMemberDeclarationValue(member) { - var value = resolver.getConstantValue(member); - if (value !== undefined) { - write(value.toString()); - return; - } - else if (member.initializer) { - emit(member.initializer); - } - else { - write("undefined"); - } - } - function getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration) { - if (moduleDeclaration.body.kind === 216) { - var recursiveInnerModule = getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration.body); - return recursiveInnerModule || moduleDeclaration.body; - } - } - function shouldEmitModuleDeclaration(node) { - return ts.isInstantiatedModule(node, compilerOptions.preserveConstEnums || compilerOptions.isolatedModules); - } - function isModuleMergedWithES6Class(node) { - return languageVersion === 2 && !!(resolver.getNodeCheckFlags(node) & 32768); - } - function emitModuleDeclaration(node) { - var shouldEmit = shouldEmitModuleDeclaration(node); - if (!shouldEmit) { - return emitCommentsOnNotEmittedNode(node); - } - var hoistedInDeclarationScope = shouldHoistDeclarationInSystemJsModule(node); - var emitVarForModule = !hoistedInDeclarationScope && !isModuleMergedWithES6Class(node); - if (emitVarForModule) { - emitStart(node); - if (isES6ExportedDeclaration(node)) { - write("export "); - } - write("var "); - emit(node.name); - write(";"); - emitEnd(node); - writeLine(); - } - emitStart(node); - write("(function ("); - emitStart(node.name); - write(getGeneratedNameForNode(node)); - emitEnd(node.name); - write(") "); - if (node.body.kind === 217) { - var saveTempFlags = tempFlags; - var saveTempVariables = tempVariables; - tempFlags = 0; - tempVariables = undefined; - emit(node.body); - tempFlags = saveTempFlags; - tempVariables = saveTempVariables; - } - else { - write("{"); - increaseIndent(); - scopeEmitStart(node); - emitCaptureThisForNodeIfNecessary(node); - writeLine(); - emit(node.body); - decreaseIndent(); - writeLine(); - var moduleBlock = getInnerMostModuleDeclarationFromDottedModule(node).body; - emitToken(16, moduleBlock.statements.end); - scopeEmitEnd(); - } - write(")("); - if ((node.flags & 1) && !isES6ExportedDeclaration(node)) { - emit(node.name); - write(" = "); - } - emitModuleMemberName(node); - write(" || ("); - emitModuleMemberName(node); - write(" = {}));"); - emitEnd(node); - if (!isES6ExportedDeclaration(node) && node.name.kind === 67 && node.parent === currentSourceFile) { - if (compilerOptions.module === 4 && (node.flags & 1)) { - writeLine(); - write(exportFunctionForFile + "(\""); - emitDeclarationName(node); - write("\", "); - emitDeclarationName(node); - write(");"); - } - emitExportMemberAssignments(node.name); - } - } - function tryRenameExternalModule(moduleName) { - if (currentSourceFile.renamedDependencies && ts.hasProperty(currentSourceFile.renamedDependencies, moduleName.text)) { - return "\"" + currentSourceFile.renamedDependencies[moduleName.text] + "\""; - } - return undefined; - } - function emitRequire(moduleName) { - if (moduleName.kind === 9) { - write("require("); - var text = tryRenameExternalModule(moduleName); - if (text) { - write(text); - } - else { - emitStart(moduleName); - emitLiteral(moduleName); - emitEnd(moduleName); - } - emitToken(18, moduleName.end); - } - else { - write("require()"); - } - } - function getNamespaceDeclarationNode(node) { - if (node.kind === 219) { - return node; - } - var importClause = node.importClause; - if (importClause && importClause.namedBindings && importClause.namedBindings.kind === 222) { - return importClause.namedBindings; - } - } - function isDefaultImport(node) { - return node.kind === 220 && node.importClause && !!node.importClause.name; - } - function emitExportImportAssignments(node) { - if (ts.isAliasSymbolDeclaration(node) && resolver.isValueAliasDeclaration(node)) { - emitExportMemberAssignments(node.name); - } - ts.forEachChild(node, emitExportImportAssignments); - } - function emitImportDeclaration(node) { - if (languageVersion < 2) { - return emitExternalImportDeclaration(node); - } - if (node.importClause) { - var shouldEmitDefaultBindings = resolver.isReferencedAliasDeclaration(node.importClause); - var shouldEmitNamedBindings = node.importClause.namedBindings && resolver.isReferencedAliasDeclaration(node.importClause.namedBindings, true); - if (shouldEmitDefaultBindings || shouldEmitNamedBindings) { - write("import "); - emitStart(node.importClause); - if (shouldEmitDefaultBindings) { - emit(node.importClause.name); - if (shouldEmitNamedBindings) { - write(", "); - } - } - if (shouldEmitNamedBindings) { - emitLeadingComments(node.importClause.namedBindings); - emitStart(node.importClause.namedBindings); - if (node.importClause.namedBindings.kind === 222) { - write("* as "); - emit(node.importClause.namedBindings.name); - } - else { - write("{ "); - emitExportOrImportSpecifierList(node.importClause.namedBindings.elements, resolver.isReferencedAliasDeclaration); - write(" }"); - } - emitEnd(node.importClause.namedBindings); - emitTrailingComments(node.importClause.namedBindings); - } - emitEnd(node.importClause); - write(" from "); - emit(node.moduleSpecifier); - write(";"); - } - } - else { - write("import "); - emit(node.moduleSpecifier); - write(";"); - } - } - function emitExternalImportDeclaration(node) { - if (ts.contains(externalImports, node)) { - var isExportedImport = node.kind === 219 && (node.flags & 1) !== 0; - var namespaceDeclaration = getNamespaceDeclarationNode(node); - if (compilerOptions.module !== 2) { - emitLeadingComments(node); - emitStart(node); - if (namespaceDeclaration && !isDefaultImport(node)) { - if (!isExportedImport) - write("var "); - emitModuleMemberName(namespaceDeclaration); - write(" = "); - } - else { - var isNakedImport = 220 && !node.importClause; - if (!isNakedImport) { - write("var "); - write(getGeneratedNameForNode(node)); - write(" = "); - } - } - emitRequire(ts.getExternalModuleName(node)); - if (namespaceDeclaration && isDefaultImport(node)) { - write(", "); - emitModuleMemberName(namespaceDeclaration); - write(" = "); - write(getGeneratedNameForNode(node)); - } - write(";"); - emitEnd(node); - emitExportImportAssignments(node); - emitTrailingComments(node); - } - else { - if (isExportedImport) { - emitModuleMemberName(namespaceDeclaration); - write(" = "); - emit(namespaceDeclaration.name); - write(";"); - } - else if (namespaceDeclaration && isDefaultImport(node)) { - write("var "); - emitModuleMemberName(namespaceDeclaration); - write(" = "); - write(getGeneratedNameForNode(node)); - write(";"); - } - emitExportImportAssignments(node); - } - } - } - function emitImportEqualsDeclaration(node) { - if (ts.isExternalModuleImportEqualsDeclaration(node)) { - emitExternalImportDeclaration(node); - return; - } - if (resolver.isReferencedAliasDeclaration(node) || - (!ts.isExternalModule(currentSourceFile) && resolver.isTopLevelValueImportEqualsWithEntityName(node))) { - emitLeadingComments(node); - emitStart(node); - var variableDeclarationIsHoisted = shouldHoistVariable(node, true); - var isExported = isSourceFileLevelDeclarationInSystemJsModule(node, true); - if (!variableDeclarationIsHoisted) { - ts.Debug.assert(!isExported); - if (isES6ExportedDeclaration(node)) { - write("export "); - write("var "); - } - else if (!(node.flags & 1)) { - write("var "); - } - } - if (isExported) { - write(exportFunctionForFile + "(\""); - emitNodeWithoutSourceMap(node.name); - write("\", "); - } - emitModuleMemberName(node); - write(" = "); - emit(node.moduleReference); - if (isExported) { - write(")"); - } - write(";"); - emitEnd(node); - emitExportImportAssignments(node); - emitTrailingComments(node); - } - } - function emitExportDeclaration(node) { - ts.Debug.assert(compilerOptions.module !== 4); - if (languageVersion < 2) { - if (node.moduleSpecifier && (!node.exportClause || resolver.isValueAliasDeclaration(node))) { - emitStart(node); - var generatedName = getGeneratedNameForNode(node); - if (node.exportClause) { - if (compilerOptions.module !== 2) { - write("var "); - write(generatedName); - write(" = "); - emitRequire(ts.getExternalModuleName(node)); - write(";"); - } - for (var _a = 0, _b = node.exportClause.elements; _a < _b.length; _a++) { - var specifier = _b[_a]; - if (resolver.isValueAliasDeclaration(specifier)) { - writeLine(); - emitStart(specifier); - emitContainingModuleName(specifier); - write("."); - emitNodeWithCommentsAndWithoutSourcemap(specifier.name); - write(" = "); - write(generatedName); - write("."); - emitNodeWithCommentsAndWithoutSourcemap(specifier.propertyName || specifier.name); - write(";"); - emitEnd(specifier); - } - } - } - else { - writeLine(); - write("__export("); - if (compilerOptions.module !== 2) { - emitRequire(ts.getExternalModuleName(node)); - } - else { - write(generatedName); - } - write(");"); - } - emitEnd(node); - } - } - else { - if (!node.exportClause || resolver.isValueAliasDeclaration(node)) { - write("export "); - if (node.exportClause) { - write("{ "); - emitExportOrImportSpecifierList(node.exportClause.elements, resolver.isValueAliasDeclaration); - write(" }"); - } - else { - write("*"); - } - if (node.moduleSpecifier) { - write(" from "); - emit(node.moduleSpecifier); - } - write(";"); - } - } - } - function emitExportOrImportSpecifierList(specifiers, shouldEmit) { - ts.Debug.assert(languageVersion >= 2); - var needsComma = false; - for (var _a = 0; _a < specifiers.length; _a++) { - var specifier = specifiers[_a]; - if (shouldEmit(specifier)) { - if (needsComma) { - write(", "); - } - if (specifier.propertyName) { - emit(specifier.propertyName); - write(" as "); - } - emit(specifier.name); - needsComma = true; - } - } - } - function emitExportAssignment(node) { - if (!node.isExportEquals && resolver.isValueAliasDeclaration(node)) { - if (languageVersion >= 2) { - writeLine(); - emitStart(node); - write("export default "); - var expression = node.expression; - emit(expression); - if (expression.kind !== 211 && - expression.kind !== 212) { - write(";"); - } - emitEnd(node); - } - else { - writeLine(); - emitStart(node); - if (compilerOptions.module === 4) { - write(exportFunctionForFile + "(\"default\","); - emit(node.expression); - write(")"); - } - else { - emitEs6ExportDefaultCompat(node); - emitContainingModuleName(node); - if (languageVersion === 0) { - write("[\"default\"] = "); - } - else { - write(".default = "); - } - emit(node.expression); - } - write(";"); - emitEnd(node); - } - } - } - function collectExternalModuleInfo(sourceFile) { - externalImports = []; - exportSpecifiers = {}; - exportEquals = undefined; - hasExportStars = false; - for (var _a = 0, _b = sourceFile.statements; _a < _b.length; _a++) { - var node = _b[_a]; - switch (node.kind) { - case 220: - if (!node.importClause || - resolver.isReferencedAliasDeclaration(node.importClause, true)) { - externalImports.push(node); - } - break; - case 219: - if (node.moduleReference.kind === 230 && resolver.isReferencedAliasDeclaration(node)) { - externalImports.push(node); - } - break; - case 226: - if (node.moduleSpecifier) { - if (!node.exportClause) { - externalImports.push(node); - hasExportStars = true; - } - else if (resolver.isValueAliasDeclaration(node)) { - externalImports.push(node); - } - } - else { - for (var _c = 0, _d = node.exportClause.elements; _c < _d.length; _c++) { - var specifier = _d[_c]; - var name_25 = (specifier.propertyName || specifier.name).text; - (exportSpecifiers[name_25] || (exportSpecifiers[name_25] = [])).push(specifier); - } - } - break; - case 225: - if (node.isExportEquals && !exportEquals) { - exportEquals = node; - } - break; - } - } - } - function emitExportStarHelper() { - if (hasExportStars) { - writeLine(); - write("function __export(m) {"); - increaseIndent(); - writeLine(); - write("for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];"); - decreaseIndent(); - writeLine(); - write("}"); - } - } - function getLocalNameForExternalImport(node) { - var namespaceDeclaration = getNamespaceDeclarationNode(node); - if (namespaceDeclaration && !isDefaultImport(node)) { - return ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, namespaceDeclaration.name); - } - if (node.kind === 220 && node.importClause) { - return getGeneratedNameForNode(node); - } - if (node.kind === 226 && node.moduleSpecifier) { - return getGeneratedNameForNode(node); - } - } - function getExternalModuleNameText(importNode) { - var moduleName = ts.getExternalModuleName(importNode); - if (moduleName.kind === 9) { - return tryRenameExternalModule(moduleName) || getLiteralText(moduleName); - } - return undefined; - } - function emitVariableDeclarationsForImports() { - if (externalImports.length === 0) { - return; - } - writeLine(); - var started = false; - for (var _a = 0; _a < externalImports.length; _a++) { - var importNode = externalImports[_a]; - var skipNode = importNode.kind === 226 || - (importNode.kind === 220 && !importNode.importClause); - if (skipNode) { - continue; - } - if (!started) { - write("var "); - started = true; - } - else { - write(", "); - } - write(getLocalNameForExternalImport(importNode)); - } - if (started) { - write(";"); - } - } - function emitLocalStorageForExportedNamesIfNecessary(exportedDeclarations) { - if (!hasExportStars) { - return undefined; - } - if (!exportedDeclarations && ts.isEmpty(exportSpecifiers)) { - var hasExportDeclarationWithExportClause = false; - for (var _a = 0; _a < externalImports.length; _a++) { - var externalImport = externalImports[_a]; - if (externalImport.kind === 226 && externalImport.exportClause) { - hasExportDeclarationWithExportClause = true; - break; - } - } - if (!hasExportDeclarationWithExportClause) { - return emitExportStarFunction(undefined); - } - } - var exportedNamesStorageRef = makeUniqueName("exportedNames"); - writeLine(); - write("var " + exportedNamesStorageRef + " = {"); - increaseIndent(); - var started = false; - if (exportedDeclarations) { - for (var i = 0; i < exportedDeclarations.length; ++i) { - writeExportedName(exportedDeclarations[i]); - } - } - if (exportSpecifiers) { - for (var n in exportSpecifiers) { - for (var _b = 0, _c = exportSpecifiers[n]; _b < _c.length; _b++) { - var specifier = _c[_b]; - writeExportedName(specifier.name); - } - } - } - for (var _d = 0; _d < externalImports.length; _d++) { - var externalImport = externalImports[_d]; - if (externalImport.kind !== 226) { - continue; - } - var exportDecl = externalImport; - if (!exportDecl.exportClause) { - continue; - } - for (var _e = 0, _f = exportDecl.exportClause.elements; _e < _f.length; _e++) { - var element = _f[_e]; - writeExportedName(element.name || element.propertyName); - } - } - decreaseIndent(); - writeLine(); - write("};"); - return emitExportStarFunction(exportedNamesStorageRef); - function emitExportStarFunction(localNames) { - var exportStarFunction = makeUniqueName("exportStar"); - writeLine(); - write("function " + exportStarFunction + "(m) {"); - increaseIndent(); - writeLine(); - write("var exports = {};"); - writeLine(); - write("for(var n in m) {"); - increaseIndent(); - writeLine(); - write("if (n !== \"default\""); - if (localNames) { - write("&& !" + localNames + ".hasOwnProperty(n)"); - } - write(") exports[n] = m[n];"); - decreaseIndent(); - writeLine(); - write("}"); - writeLine(); - write(exportFunctionForFile + "(exports);"); - decreaseIndent(); - writeLine(); - write("}"); - return exportStarFunction; - } - function writeExportedName(node) { - if (node.kind !== 67 && node.flags & 1024) { - return; - } - if (started) { - write(","); - } - else { - started = true; - } - writeLine(); - write("'"); - if (node.kind === 67) { - emitNodeWithCommentsAndWithoutSourcemap(node); - } - else { - emitDeclarationName(node); - } - write("': true"); - } - } - function processTopLevelVariableAndFunctionDeclarations(node) { - var hoistedVars; - var hoistedFunctionDeclarations; - var exportedDeclarations; - visit(node); - if (hoistedVars) { - writeLine(); - write("var "); - var seen = {}; - for (var i = 0; i < hoistedVars.length; ++i) { - var local = hoistedVars[i]; - var name_26 = local.kind === 67 - ? local - : local.name; - if (name_26) { - var text = ts.unescapeIdentifier(name_26.text); - if (ts.hasProperty(seen, text)) { - continue; - } - else { - seen[text] = text; - } - } - if (i !== 0) { - write(", "); - } - if (local.kind === 212 || local.kind === 216 || local.kind === 215) { - emitDeclarationName(local); - } - else { - emit(local); - } - var flags = ts.getCombinedNodeFlags(local.kind === 67 ? local.parent : local); - if (flags & 1) { - if (!exportedDeclarations) { - exportedDeclarations = []; - } - exportedDeclarations.push(local); - } - } - write(";"); - } - if (hoistedFunctionDeclarations) { - for (var _a = 0; _a < hoistedFunctionDeclarations.length; _a++) { - var f = hoistedFunctionDeclarations[_a]; - writeLine(); - emit(f); - if (f.flags & 1) { - if (!exportedDeclarations) { - exportedDeclarations = []; - } - exportedDeclarations.push(f); - } - } - } - return exportedDeclarations; - function visit(node) { - if (node.flags & 2) { - return; - } - if (node.kind === 211) { - if (!hoistedFunctionDeclarations) { - hoistedFunctionDeclarations = []; - } - hoistedFunctionDeclarations.push(node); - return; - } - if (node.kind === 212) { - if (!hoistedVars) { - hoistedVars = []; - } - hoistedVars.push(node); - return; - } - if (node.kind === 215) { - if (shouldEmitEnumDeclaration(node)) { - if (!hoistedVars) { - hoistedVars = []; - } - hoistedVars.push(node); - } - return; - } - if (node.kind === 216) { - if (shouldEmitModuleDeclaration(node)) { - if (!hoistedVars) { - hoistedVars = []; - } - hoistedVars.push(node); - } - return; - } - if (node.kind === 209 || node.kind === 161) { - if (shouldHoistVariable(node, false)) { - var name_27 = node.name; - if (name_27.kind === 67) { - if (!hoistedVars) { - hoistedVars = []; - } - hoistedVars.push(name_27); - } - else { - ts.forEachChild(name_27, visit); - } - } - return; - } - if (ts.isInternalModuleImportEqualsDeclaration(node) && resolver.isValueAliasDeclaration(node)) { - if (!hoistedVars) { - hoistedVars = []; - } - hoistedVars.push(node.name); - return; - } - if (ts.isBindingPattern(node)) { - ts.forEach(node.elements, visit); - return; - } - if (!ts.isDeclaration(node)) { - ts.forEachChild(node, visit); - } - } - } - function shouldHoistVariable(node, checkIfSourceFileLevelDecl) { - if (checkIfSourceFileLevelDecl && !shouldHoistDeclarationInSystemJsModule(node)) { - return false; - } - return (ts.getCombinedNodeFlags(node) & 49152) === 0 || - ts.getEnclosingBlockScopeContainer(node).kind === 246; - } - function isCurrentFileSystemExternalModule() { - return compilerOptions.module === 4 && ts.isExternalModule(currentSourceFile); - } - function emitSystemModuleBody(node, dependencyGroups, startIndex) { - emitVariableDeclarationsForImports(); - writeLine(); - var exportedDeclarations = processTopLevelVariableAndFunctionDeclarations(node); - var exportStarFunction = emitLocalStorageForExportedNamesIfNecessary(exportedDeclarations); - writeLine(); - write("return {"); - increaseIndent(); - writeLine(); - emitSetters(exportStarFunction, dependencyGroups); - writeLine(); - emitExecute(node, startIndex); - decreaseIndent(); - writeLine(); - write("}"); - emitTempDeclarations(true); - } - function emitSetters(exportStarFunction, dependencyGroups) { - write("setters:["); - for (var i = 0; i < dependencyGroups.length; ++i) { - if (i !== 0) { - write(","); - } - writeLine(); - increaseIndent(); - var group = dependencyGroups[i]; - var parameterName = makeUniqueName(ts.forEach(group, getLocalNameForExternalImport) || ""); - write("function (" + parameterName + ") {"); - increaseIndent(); - for (var _a = 0; _a < group.length; _a++) { - var entry = group[_a]; - var importVariableName = getLocalNameForExternalImport(entry) || ""; - switch (entry.kind) { - case 220: - if (!entry.importClause) { - break; - } - case 219: - ts.Debug.assert(importVariableName !== ""); - writeLine(); - write(importVariableName + " = " + parameterName + ";"); - writeLine(); - break; - case 226: - ts.Debug.assert(importVariableName !== ""); - if (entry.exportClause) { - writeLine(); - write(exportFunctionForFile + "({"); - writeLine(); - increaseIndent(); - for (var i_2 = 0, len = entry.exportClause.elements.length; i_2 < len; ++i_2) { - if (i_2 !== 0) { - write(","); - writeLine(); - } - var e = entry.exportClause.elements[i_2]; - write("\""); - emitNodeWithCommentsAndWithoutSourcemap(e.name); - write("\": " + parameterName + "[\""); - emitNodeWithCommentsAndWithoutSourcemap(e.propertyName || e.name); - write("\"]"); - } - decreaseIndent(); - writeLine(); - write("});"); - } - else { - writeLine(); - write(exportStarFunction + "(" + parameterName + ");"); - } - writeLine(); - break; - } - } - decreaseIndent(); - write("}"); - decreaseIndent(); - } - write("],"); - } - function emitExecute(node, startIndex) { - write("execute: function() {"); - increaseIndent(); - writeLine(); - for (var i = startIndex; i < node.statements.length; ++i) { - var statement = node.statements[i]; - switch (statement.kind) { - case 211: - case 220: - continue; - case 226: - if (!statement.moduleSpecifier) { - for (var _a = 0, _b = statement.exportClause.elements; _a < _b.length; _a++) { - var element = _b[_a]; - emitExportSpecifierInSystemModule(element); - } - } - continue; - case 219: - if (!ts.isInternalModuleImportEqualsDeclaration(statement)) { - continue; - } - default: - writeLine(); - emit(statement); - } - } - decreaseIndent(); - writeLine(); - write("}"); - } - function emitSystemModule(node, startIndex) { - collectExternalModuleInfo(node); - ts.Debug.assert(!exportFunctionForFile); - exportFunctionForFile = makeUniqueName("exports"); - writeLine(); - write("System.register("); - if (node.moduleName) { - write("\"" + node.moduleName + "\", "); - } - write("["); - var groupIndices = {}; - var dependencyGroups = []; - for (var i = 0; i < externalImports.length; ++i) { - var text = getExternalModuleNameText(externalImports[i]); - if (ts.hasProperty(groupIndices, text)) { - var groupIndex = groupIndices[text]; - dependencyGroups[groupIndex].push(externalImports[i]); - continue; - } - else { - groupIndices[text] = dependencyGroups.length; - dependencyGroups.push([externalImports[i]]); - } - if (i !== 0) { - write(", "); - } - write(text); - } - write("], function(" + exportFunctionForFile + ") {"); - writeLine(); - increaseIndent(); - emitEmitHelpers(node); - emitCaptureThisForNodeIfNecessary(node); - emitSystemModuleBody(node, dependencyGroups, startIndex); - decreaseIndent(); - writeLine(); - write("});"); - } - function emitAMDDependencies(node, includeNonAmdDependencies) { - var aliasedModuleNames = []; - var unaliasedModuleNames = []; - var importAliasNames = []; - for (var _a = 0, _b = node.amdDependencies; _a < _b.length; _a++) { - var amdDependency = _b[_a]; - if (amdDependency.name) { - aliasedModuleNames.push("\"" + amdDependency.path + "\""); - importAliasNames.push(amdDependency.name); - } - else { - unaliasedModuleNames.push("\"" + amdDependency.path + "\""); - } - } - for (var _c = 0; _c < externalImports.length; _c++) { - var importNode = externalImports[_c]; - var externalModuleName = getExternalModuleNameText(importNode); - var importAliasName = getLocalNameForExternalImport(importNode); - if (includeNonAmdDependencies && importAliasName) { - aliasedModuleNames.push(externalModuleName); - importAliasNames.push(importAliasName); - } - else { - unaliasedModuleNames.push(externalModuleName); - } - } - write("[\"require\", \"exports\""); - if (aliasedModuleNames.length) { - write(", "); - write(aliasedModuleNames.join(", ")); - } - if (unaliasedModuleNames.length) { - write(", "); - write(unaliasedModuleNames.join(", ")); - } - write("], function (require, exports"); - if (importAliasNames.length) { - write(", "); - write(importAliasNames.join(", ")); - } - } - function emitAMDModule(node, startIndex) { - emitEmitHelpers(node); - collectExternalModuleInfo(node); - writeLine(); - write("define("); - if (node.moduleName) { - write("\"" + node.moduleName + "\", "); - } - emitAMDDependencies(node, true); - write(") {"); - increaseIndent(); - emitExportStarHelper(); - emitCaptureThisForNodeIfNecessary(node); - emitLinesStartingAt(node.statements, startIndex); - emitTempDeclarations(true); - emitExportEquals(true); - decreaseIndent(); - writeLine(); - write("});"); - } - function emitCommonJSModule(node, startIndex) { - emitEmitHelpers(node); - collectExternalModuleInfo(node); - emitExportStarHelper(); - emitCaptureThisForNodeIfNecessary(node); - emitLinesStartingAt(node.statements, startIndex); - emitTempDeclarations(true); - emitExportEquals(false); - } - function emitUMDModule(node, startIndex) { - emitEmitHelpers(node); - collectExternalModuleInfo(node); - writeLines("(function (deps, factory) {\n if (typeof module === 'object' && typeof module.exports === 'object') {\n var v = factory(require, exports); if (v !== undefined) module.exports = v;\n }\n else if (typeof define === 'function' && define.amd) {\n define(deps, factory);\n }\n})("); - emitAMDDependencies(node, false); - write(") {"); - increaseIndent(); - emitExportStarHelper(); - emitCaptureThisForNodeIfNecessary(node); - emitLinesStartingAt(node.statements, startIndex); - emitTempDeclarations(true); - emitExportEquals(true); - decreaseIndent(); - writeLine(); - write("});"); - } - function emitES6Module(node, startIndex) { - externalImports = undefined; - exportSpecifiers = undefined; - exportEquals = undefined; - hasExportStars = false; - emitEmitHelpers(node); - emitCaptureThisForNodeIfNecessary(node); - emitLinesStartingAt(node.statements, startIndex); - emitTempDeclarations(true); - } - function emitExportEquals(emitAsReturn) { - if (exportEquals && resolver.isValueAliasDeclaration(exportEquals)) { - writeLine(); - emitStart(exportEquals); - write(emitAsReturn ? "return " : "module.exports = "); - emit(exportEquals.expression); - write(";"); - emitEnd(exportEquals); - } - } - function emitJsxElement(node) { - switch (compilerOptions.jsx) { - case 2: - jsxEmitReact(node); - break; - case 1: - default: - jsxEmitPreserve(node); - break; - } - } - function trimReactWhitespaceAndApplyEntities(node) { - var result = undefined; - var text = ts.getTextOfNode(node, true); - var firstNonWhitespace = 0; - var lastNonWhitespace = -1; - for (var i = 0; i < text.length; i++) { - var c = text.charCodeAt(i); - if (ts.isLineBreak(c)) { - if (firstNonWhitespace !== -1 && (lastNonWhitespace - firstNonWhitespace + 1 > 0)) { - var part = text.substr(firstNonWhitespace, lastNonWhitespace - firstNonWhitespace + 1); - result = (result ? result + "\" + ' ' + \"" : "") + part; - } - firstNonWhitespace = -1; - } - else if (!ts.isWhiteSpace(c)) { - lastNonWhitespace = i; - if (firstNonWhitespace === -1) { - firstNonWhitespace = i; - } - } - } - if (firstNonWhitespace !== -1) { - var part = text.substr(firstNonWhitespace); - result = (result ? result + "\" + ' ' + \"" : "") + part; - } - if (result) { - result = result.replace(/&(\w+);/g, function (s, m) { - if (entities[m] !== undefined) { - return String.fromCharCode(entities[m]); - } - else { - return s; - } - }); - } - return result; - } - function getTextToEmit(node) { - switch (compilerOptions.jsx) { - case 2: - var text = trimReactWhitespaceAndApplyEntities(node); - if (text === undefined || text.length === 0) { - return undefined; - } - else { - return text; - } - case 1: - default: - return ts.getTextOfNode(node, true); - } - } - function emitJsxText(node) { - switch (compilerOptions.jsx) { - case 2: - write("\""); - write(trimReactWhitespaceAndApplyEntities(node)); - write("\""); - break; - case 1: - default: - writer.writeLiteral(ts.getTextOfNode(node, true)); - break; - } - } - function emitJsxExpression(node) { - if (node.expression) { - switch (compilerOptions.jsx) { - case 1: - default: - write("{"); - emit(node.expression); - write("}"); - break; - case 2: - emit(node.expression); - break; - } - } - } - function emitDirectivePrologues(statements, startWithNewLine) { - for (var i = 0; i < statements.length; ++i) { - if (ts.isPrologueDirective(statements[i])) { - if (startWithNewLine || i > 0) { - writeLine(); - } - emit(statements[i]); - } - else { - return i; - } - } - return statements.length; - } - function writeLines(text) { - var lines = text.split(/\r\n|\r|\n/g); - for (var i = 0; i < lines.length; ++i) { - var line = lines[i]; - if (line.length) { - writeLine(); - write(line); - } - } - } - function emitEmitHelpers(node) { - if (!compilerOptions.noEmitHelpers) { - if ((languageVersion < 2) && (!extendsEmitted && resolver.getNodeCheckFlags(node) & 8)) { - writeLines(extendsHelper); - extendsEmitted = true; - } - if (!decorateEmitted && resolver.getNodeCheckFlags(node) & 16) { - writeLines(decorateHelper); - if (compilerOptions.emitDecoratorMetadata) { - writeLines(metadataHelper); - } - decorateEmitted = true; - } - if (!paramEmitted && resolver.getNodeCheckFlags(node) & 32) { - writeLines(paramHelper); - paramEmitted = true; - } - if (!awaiterEmitted && resolver.getNodeCheckFlags(node) & 64) { - writeLines(awaiterHelper); - awaiterEmitted = true; - } - } - } - function emitSourceFileNode(node) { - writeLine(); - emitShebang(); - emitDetachedComments(node); - var startIndex = emitDirectivePrologues(node.statements, false); - if (ts.isExternalModule(node) || compilerOptions.isolatedModules) { - if (languageVersion >= 2) { - emitES6Module(node, startIndex); - } - else if (compilerOptions.module === 2) { - emitAMDModule(node, startIndex); - } - else if (compilerOptions.module === 4) { - emitSystemModule(node, startIndex); - } - else if (compilerOptions.module === 3) { - emitUMDModule(node, startIndex); - } - else { - emitCommonJSModule(node, startIndex); - } - } - else { - externalImports = undefined; - exportSpecifiers = undefined; - exportEquals = undefined; - hasExportStars = false; - emitEmitHelpers(node); - emitCaptureThisForNodeIfNecessary(node); - emitLinesStartingAt(node.statements, startIndex); - emitTempDeclarations(true); - } - emitLeadingComments(node.endOfFileToken); - } - function emitNodeWithCommentsAndWithoutSourcemap(node) { - emitNodeConsideringCommentsOption(node, emitNodeWithoutSourceMap); - } - function emitNodeConsideringCommentsOption(node, emitNodeConsideringSourcemap) { - if (node) { - if (node.flags & 2) { - return emitCommentsOnNotEmittedNode(node); - } - if (isSpecializedCommentHandling(node)) { - return emitNodeWithoutSourceMap(node); - } - var emitComments_1 = shouldEmitLeadingAndTrailingComments(node); - if (emitComments_1) { - emitLeadingComments(node); - } - emitNodeConsideringSourcemap(node); - if (emitComments_1) { - emitTrailingComments(node); - } - } - } - function emitNodeWithoutSourceMap(node) { - if (node) { - emitJavaScriptWorker(node); - } - } - function isSpecializedCommentHandling(node) { - switch (node.kind) { - case 213: - case 211: - case 220: - case 219: - case 214: - case 225: - return true; - } - } - function shouldEmitLeadingAndTrailingComments(node) { - switch (node.kind) { - case 191: - return shouldEmitLeadingAndTrailingCommentsForVariableStatement(node); - case 216: - return shouldEmitModuleDeclaration(node); - case 215: - return shouldEmitEnumDeclaration(node); - } - ts.Debug.assert(!isSpecializedCommentHandling(node)); - if (node.kind !== 190 && - node.parent && - node.parent.kind === 172 && - node.parent.body === node && - compilerOptions.target <= 1) { - return false; - } - return true; - } - function emitJavaScriptWorker(node) { - switch (node.kind) { - case 67: - return emitIdentifier(node); - case 136: - return emitParameter(node); - case 141: - case 140: - return emitMethod(node); - case 143: - case 144: - return emitAccessor(node); - case 95: - return emitThis(node); - case 93: - return emitSuper(node); - case 91: - return write("null"); - case 97: - return write("true"); - case 82: - return write("false"); - case 8: - case 9: - case 10: - case 11: - case 12: - case 13: - case 14: - return emitLiteral(node); - case 181: - return emitTemplateExpression(node); - case 188: - return emitTemplateSpan(node); - case 231: - case 232: - return emitJsxElement(node); - case 234: - return emitJsxText(node); - case 238: - return emitJsxExpression(node); - case 133: - return emitQualifiedName(node); - case 159: - return emitObjectBindingPattern(node); - case 160: - return emitArrayBindingPattern(node); - case 161: - return emitBindingElement(node); - case 162: - return emitArrayLiteral(node); - case 163: - return emitObjectLiteral(node); - case 243: - return emitPropertyAssignment(node); - case 244: - return emitShorthandPropertyAssignment(node); - case 134: - return emitComputedPropertyName(node); - case 164: - return emitPropertyAccess(node); - case 165: - return emitIndexedAccess(node); - case 166: - return emitCallExpression(node); - case 167: - return emitNewExpression(node); - case 168: - return emitTaggedTemplateExpression(node); - case 169: - return emit(node.expression); - case 187: - return emit(node.expression); - case 170: - return emitParenExpression(node); - case 211: - case 171: - case 172: - return emitFunctionDeclaration(node); - case 173: - return emitDeleteExpression(node); - case 174: - return emitTypeOfExpression(node); - case 175: - return emitVoidExpression(node); - case 176: - return emitAwaitExpression(node); - case 177: - return emitPrefixUnaryExpression(node); - case 178: - return emitPostfixUnaryExpression(node); - case 179: - return emitBinaryExpression(node); - case 180: - return emitConditionalExpression(node); - case 183: - return emitSpreadElementExpression(node); - case 182: - return emitYieldExpression(node); - case 185: - return; - case 190: - case 217: - return emitBlock(node); - case 191: - return emitVariableStatement(node); - case 192: - return write(";"); - case 193: - return emitExpressionStatement(node); - case 194: - return emitIfStatement(node); - case 195: - return emitDoStatement(node); - case 196: - return emitWhileStatement(node); - case 197: - return emitForStatement(node); - case 199: - case 198: - return emitForInOrForOfStatement(node); - case 200: - case 201: - return emitBreakOrContinueStatement(node); - case 202: - return emitReturnStatement(node); - case 203: - return emitWithStatement(node); - case 204: - return emitSwitchStatement(node); - case 239: - case 240: - return emitCaseOrDefaultClause(node); - case 205: - return emitLabelledStatement(node); - case 206: - return emitThrowStatement(node); - case 207: - return emitTryStatement(node); - case 242: - return emitCatchClause(node); - case 208: - return emitDebuggerStatement(node); - case 209: - return emitVariableDeclaration(node); - case 184: - return emitClassExpression(node); - case 212: - return emitClassDeclaration(node); - case 213: - return emitInterfaceDeclaration(node); - case 215: - return emitEnumDeclaration(node); - case 245: - return emitEnumMember(node); - case 216: - return emitModuleDeclaration(node); - case 220: - return emitImportDeclaration(node); - case 219: - return emitImportEqualsDeclaration(node); - case 226: - return emitExportDeclaration(node); - case 225: - return emitExportAssignment(node); - case 246: - return emitSourceFileNode(node); - } - } - function hasDetachedComments(pos) { - return detachedCommentsInfo !== undefined && ts.lastOrUndefined(detachedCommentsInfo).nodePos === pos; - } - function getLeadingCommentsWithoutDetachedComments() { - var leadingComments = ts.getLeadingCommentRanges(currentSourceFile.text, ts.lastOrUndefined(detachedCommentsInfo).detachedCommentEndPos); - if (detachedCommentsInfo.length - 1) { - detachedCommentsInfo.pop(); - } - else { - detachedCommentsInfo = undefined; - } - return leadingComments; - } - function isPinnedComments(comment) { - return currentSourceFile.text.charCodeAt(comment.pos + 1) === 42 && - currentSourceFile.text.charCodeAt(comment.pos + 2) === 33; - } - function isTripleSlashComment(comment) { - if (currentSourceFile.text.charCodeAt(comment.pos + 1) === 47 && - comment.pos + 2 < comment.end && - currentSourceFile.text.charCodeAt(comment.pos + 2) === 47) { - var textSubStr = currentSourceFile.text.substring(comment.pos, comment.end); - return textSubStr.match(ts.fullTripleSlashReferencePathRegEx) || - textSubStr.match(ts.fullTripleSlashAMDReferencePathRegEx) ? - true : false; - } - return false; - } - function getLeadingCommentsToEmit(node) { - if (node.parent) { - if (node.parent.kind === 246 || node.pos !== node.parent.pos) { - if (hasDetachedComments(node.pos)) { - return getLeadingCommentsWithoutDetachedComments(); - } - else { - return ts.getLeadingCommentRangesOfNode(node, currentSourceFile); - } - } - } - } - function getTrailingCommentsToEmit(node) { - if (node.parent) { - if (node.parent.kind === 246 || node.end !== node.parent.end) { - return ts.getTrailingCommentRanges(currentSourceFile.text, node.end); - } - } - } - function emitCommentsOnNotEmittedNode(node) { - emitLeadingCommentsWorker(node, false); - } - function emitLeadingComments(node) { - return emitLeadingCommentsWorker(node, true); - } - function emitLeadingCommentsWorker(node, isEmittedNode) { - if (compilerOptions.removeComments) { - return; - } - var leadingComments; - if (isEmittedNode) { - leadingComments = getLeadingCommentsToEmit(node); - } - else { - if (node.pos === 0) { - leadingComments = ts.filter(getLeadingCommentsToEmit(node), isTripleSlashComment); - } - } - ts.emitNewLineBeforeLeadingComments(currentSourceFile, writer, node, leadingComments); - ts.emitComments(currentSourceFile, writer, leadingComments, true, newLine, writeComment); - } - function emitTrailingComments(node) { - if (compilerOptions.removeComments) { - return; - } - var trailingComments = getTrailingCommentsToEmit(node); - ts.emitComments(currentSourceFile, writer, trailingComments, false, newLine, writeComment); - } - function emitTrailingCommentsOfPosition(pos) { - if (compilerOptions.removeComments) { - return; - } - var trailingComments = ts.getTrailingCommentRanges(currentSourceFile.text, pos); - ts.emitComments(currentSourceFile, writer, trailingComments, true, newLine, writeComment); - } - function emitLeadingCommentsOfPositionWorker(pos) { - if (compilerOptions.removeComments) { - return; - } - var leadingComments; - if (hasDetachedComments(pos)) { - leadingComments = getLeadingCommentsWithoutDetachedComments(); - } - else { - leadingComments = ts.getLeadingCommentRanges(currentSourceFile.text, pos); - } - ts.emitNewLineBeforeLeadingComments(currentSourceFile, writer, { pos: pos, end: pos }, leadingComments); - ts.emitComments(currentSourceFile, writer, leadingComments, true, newLine, writeComment); - } - function emitDetachedComments(node) { - var leadingComments; - if (compilerOptions.removeComments) { - if (node.pos === 0) { - leadingComments = ts.filter(ts.getLeadingCommentRanges(currentSourceFile.text, node.pos), isPinnedComments); - } - } - else { - leadingComments = ts.getLeadingCommentRanges(currentSourceFile.text, node.pos); - } - if (leadingComments) { - var detachedComments = []; - var lastComment; - ts.forEach(leadingComments, function (comment) { - if (lastComment) { - var lastCommentLine = ts.getLineOfLocalPosition(currentSourceFile, lastComment.end); - var commentLine = ts.getLineOfLocalPosition(currentSourceFile, comment.pos); - if (commentLine >= lastCommentLine + 2) { - return detachedComments; - } - } - detachedComments.push(comment); - lastComment = comment; - }); - if (detachedComments.length) { - var lastCommentLine = ts.getLineOfLocalPosition(currentSourceFile, ts.lastOrUndefined(detachedComments).end); - var nodeLine = ts.getLineOfLocalPosition(currentSourceFile, ts.skipTrivia(currentSourceFile.text, node.pos)); - if (nodeLine >= lastCommentLine + 2) { - ts.emitNewLineBeforeLeadingComments(currentSourceFile, writer, node, leadingComments); - ts.emitComments(currentSourceFile, writer, detachedComments, true, newLine, writeComment); - var currentDetachedCommentInfo = { nodePos: node.pos, detachedCommentEndPos: ts.lastOrUndefined(detachedComments).end }; - if (detachedCommentsInfo) { - detachedCommentsInfo.push(currentDetachedCommentInfo); - } - else { - detachedCommentsInfo = [currentDetachedCommentInfo]; - } - } - } - } - } - function emitShebang() { - var shebang = ts.getShebang(currentSourceFile.text); - if (shebang) { - write(shebang); - } - } - } - function emitFile(jsFilePath, sourceFile) { - emitJavaScript(jsFilePath, sourceFile); - if (compilerOptions.declaration) { - ts.writeDeclarationFile(jsFilePath, sourceFile, host, resolver, diagnostics); - } - } - } - ts.emitFiles = emitFiles; var entities = { "quot": 0x0022, "amp": 0x0026, @@ -29780,6 +24755,5552 @@ var ts; "hearts": 0x2665, "diams": 0x2666 }; + function emitFiles(resolver, host, targetSourceFile) { + var extendsHelper = "\nvar __extends = (this && this.__extends) || function (d, b) {\n for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];\n function __() { this.constructor = d; }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n};"; + var decorateHelper = "\nvar __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\n return c > 3 && r && Object.defineProperty(target, key, r), r;\n};"; + var metadataHelper = "\nvar __metadata = (this && this.__metadata) || function (k, v) {\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(k, v);\n};"; + var paramHelper = "\nvar __param = (this && this.__param) || function (paramIndex, decorator) {\n return function (target, key) { decorator(target, key, paramIndex); }\n};"; + var awaiterHelper = "\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promise, generator) {\n return new Promise(function (resolve, reject) {\n generator = generator.call(thisArg, _arguments);\n function cast(value) { return value instanceof Promise && value.constructor === Promise ? value : new Promise(function (resolve) { resolve(value); }); }\n function onfulfill(value) { try { step(\"next\", value); } catch (e) { reject(e); } }\n function onreject(value) { try { step(\"throw\", value); } catch (e) { reject(e); } }\n function step(verb, value) {\n var result = generator[verb](value);\n result.done ? resolve(result.value) : cast(result.value).then(onfulfill, onreject);\n }\n step(\"next\", void 0);\n });\n};"; + var compilerOptions = host.getCompilerOptions(); + var languageVersion = compilerOptions.target || 0; + var modulekind = compilerOptions.module ? compilerOptions.module : languageVersion === 2 ? 5 : 0; + var sourceMapDataList = compilerOptions.sourceMap || compilerOptions.inlineSourceMap ? [] : undefined; + var diagnostics = []; + var newLine = host.getNewLine(); + var jsxDesugaring = host.getCompilerOptions().jsx !== 1; + var shouldEmitJsx = function (s) { return (s.languageVariant === 1 && !jsxDesugaring); }; + if (targetSourceFile === undefined) { + ts.forEach(host.getSourceFiles(), function (sourceFile) { + if (ts.shouldEmitToOwnFile(sourceFile, compilerOptions)) { + var jsFilePath = ts.getOwnEmitOutputFilePath(sourceFile, host, shouldEmitJsx(sourceFile) ? ".jsx" : ".js"); + emitFile(jsFilePath, sourceFile); + } + }); + if (compilerOptions.outFile || compilerOptions.out) { + emitFile(compilerOptions.outFile || compilerOptions.out); + } + } + else { + if (ts.shouldEmitToOwnFile(targetSourceFile, compilerOptions)) { + var jsFilePath = ts.getOwnEmitOutputFilePath(targetSourceFile, host, shouldEmitJsx(targetSourceFile) ? ".jsx" : ".js"); + emitFile(jsFilePath, targetSourceFile); + } + else if (!ts.isDeclarationFile(targetSourceFile) && (compilerOptions.outFile || compilerOptions.out)) { + emitFile(compilerOptions.outFile || compilerOptions.out); + } + } + diagnostics = ts.sortAndDeduplicateDiagnostics(diagnostics); + return { + emitSkipped: false, + diagnostics: diagnostics, + sourceMaps: sourceMapDataList + }; + function isNodeDescendentOf(node, ancestor) { + while (node) { + if (node === ancestor) + return true; + node = node.parent; + } + return false; + } + function isUniqueLocalName(name, container) { + for (var node = container; isNodeDescendentOf(node, container); node = node.nextContainer) { + if (node.locals && ts.hasProperty(node.locals, name)) { + if (node.locals[name].flags & (107455 | 1048576 | 8388608)) { + return false; + } + } + } + return true; + } + function emitJavaScript(jsFilePath, root) { + var writer = ts.createTextWriter(newLine); + var write = writer.write, writeTextOfNode = writer.writeTextOfNode, writeLine = writer.writeLine, increaseIndent = writer.increaseIndent, decreaseIndent = writer.decreaseIndent; + var currentSourceFile; + var exportFunctionForFile; + var generatedNameSet = {}; + var nodeToGeneratedName = []; + var computedPropertyNamesToGeneratedNames; + var extendsEmitted = false; + var decorateEmitted = false; + var paramEmitted = false; + var awaiterEmitted = false; + var tempFlags = 0; + var tempVariables; + var tempParameters; + var externalImports; + var exportSpecifiers; + var exportEquals; + var hasExportStars; + var writeEmittedFiles = writeJavaScriptFile; + var detachedCommentsInfo; + var writeComment = ts.writeCommentRange; + var emit = emitNodeWithCommentsAndWithoutSourcemap; + var emitStart = function (node) { }; + var emitEnd = function (node) { }; + var emitToken = emitTokenText; + var scopeEmitStart = function (scopeDeclaration, scopeName) { }; + var scopeEmitEnd = function () { }; + var sourceMapData; + var emitLeadingCommentsOfPosition = compilerOptions.removeComments ? function (pos) { } : emitLeadingCommentsOfPositionWorker; + var moduleEmitDelegates = (_a = {}, + _a[5] = emitES6Module, + _a[2] = emitAMDModule, + _a[4] = emitSystemModule, + _a[3] = emitUMDModule, + _a[1] = emitCommonJSModule, + _a + ); + if (compilerOptions.sourceMap || compilerOptions.inlineSourceMap) { + initializeEmitterWithSourceMaps(); + } + if (root) { + emitSourceFile(root); + } + else { + ts.forEach(host.getSourceFiles(), function (sourceFile) { + if (!isExternalModuleOrDeclarationFile(sourceFile)) { + emitSourceFile(sourceFile); + } + }); + } + writeLine(); + writeEmittedFiles(writer.getText(), compilerOptions.emitBOM); + return; + function emitSourceFile(sourceFile) { + currentSourceFile = sourceFile; + exportFunctionForFile = undefined; + emit(sourceFile); + } + function isUniqueName(name) { + return !resolver.hasGlobalName(name) && + !ts.hasProperty(currentSourceFile.identifiers, name) && + !ts.hasProperty(generatedNameSet, name); + } + function makeTempVariableName(flags) { + if (flags && !(tempFlags & flags)) { + var name_20 = flags === 268435456 ? "_i" : "_n"; + if (isUniqueName(name_20)) { + tempFlags |= flags; + return name_20; + } + } + while (true) { + var count = tempFlags & 268435455; + tempFlags++; + if (count !== 8 && count !== 13) { + var name_21 = count < 26 ? "_" + String.fromCharCode(97 + count) : "_" + (count - 26); + if (isUniqueName(name_21)) { + return name_21; + } + } + } + } + function makeUniqueName(baseName) { + if (baseName.charCodeAt(baseName.length - 1) !== 95) { + baseName += "_"; + } + var i = 1; + while (true) { + var generatedName = baseName + i; + if (isUniqueName(generatedName)) { + return generatedNameSet[generatedName] = generatedName; + } + i++; + } + } + function generateNameForModuleOrEnum(node) { + var name = node.name.text; + return isUniqueLocalName(name, node) ? name : makeUniqueName(name); + } + function generateNameForImportOrExportDeclaration(node) { + var expr = ts.getExternalModuleName(node); + var baseName = expr.kind === 9 ? + ts.escapeIdentifier(ts.makeIdentifierFromModuleName(expr.text)) : "module"; + return makeUniqueName(baseName); + } + function generateNameForExportDefault() { + return makeUniqueName("default"); + } + function generateNameForClassExpression() { + return makeUniqueName("class"); + } + function generateNameForNode(node) { + switch (node.kind) { + case 69: + return makeUniqueName(node.text); + case 218: + case 217: + return generateNameForModuleOrEnum(node); + case 222: + case 228: + return generateNameForImportOrExportDeclaration(node); + case 213: + case 214: + case 227: + return generateNameForExportDefault(); + case 186: + return generateNameForClassExpression(); + } + } + function getGeneratedNameForNode(node) { + var id = ts.getNodeId(node); + return nodeToGeneratedName[id] || (nodeToGeneratedName[id] = ts.unescapeIdentifier(generateNameForNode(node))); + } + function initializeEmitterWithSourceMaps() { + var sourceMapDir; + var sourceMapSourceIndex = -1; + var sourceMapNameIndexMap = {}; + var sourceMapNameIndices = []; + function getSourceMapNameIndex() { + return sourceMapNameIndices.length ? ts.lastOrUndefined(sourceMapNameIndices) : -1; + } + var lastRecordedSourceMapSpan; + var lastEncodedSourceMapSpan = { + emittedLine: 1, + emittedColumn: 1, + sourceLine: 1, + sourceColumn: 1, + sourceIndex: 0 + }; + var lastEncodedNameIndex = 0; + function encodeLastRecordedSourceMapSpan() { + if (!lastRecordedSourceMapSpan || lastRecordedSourceMapSpan === lastEncodedSourceMapSpan) { + return; + } + var prevEncodedEmittedColumn = lastEncodedSourceMapSpan.emittedColumn; + if (lastEncodedSourceMapSpan.emittedLine === lastRecordedSourceMapSpan.emittedLine) { + if (sourceMapData.sourceMapMappings) { + sourceMapData.sourceMapMappings += ","; + } + } + else { + for (var encodedLine = lastEncodedSourceMapSpan.emittedLine; encodedLine < lastRecordedSourceMapSpan.emittedLine; encodedLine++) { + sourceMapData.sourceMapMappings += ";"; + } + prevEncodedEmittedColumn = 1; + } + sourceMapData.sourceMapMappings += base64VLQFormatEncode(lastRecordedSourceMapSpan.emittedColumn - prevEncodedEmittedColumn); + sourceMapData.sourceMapMappings += base64VLQFormatEncode(lastRecordedSourceMapSpan.sourceIndex - lastEncodedSourceMapSpan.sourceIndex); + sourceMapData.sourceMapMappings += base64VLQFormatEncode(lastRecordedSourceMapSpan.sourceLine - lastEncodedSourceMapSpan.sourceLine); + sourceMapData.sourceMapMappings += base64VLQFormatEncode(lastRecordedSourceMapSpan.sourceColumn - lastEncodedSourceMapSpan.sourceColumn); + if (lastRecordedSourceMapSpan.nameIndex >= 0) { + sourceMapData.sourceMapMappings += base64VLQFormatEncode(lastRecordedSourceMapSpan.nameIndex - lastEncodedNameIndex); + lastEncodedNameIndex = lastRecordedSourceMapSpan.nameIndex; + } + lastEncodedSourceMapSpan = lastRecordedSourceMapSpan; + sourceMapData.sourceMapDecodedMappings.push(lastEncodedSourceMapSpan); + function base64VLQFormatEncode(inValue) { + function base64FormatEncode(inValue) { + if (inValue < 64) { + return "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(inValue); + } + throw TypeError(inValue + ": not a 64 based value"); + } + if (inValue < 0) { + inValue = ((-inValue) << 1) + 1; + } + else { + inValue = inValue << 1; + } + var encodedStr = ""; + do { + var currentDigit = inValue & 31; + inValue = inValue >> 5; + if (inValue > 0) { + currentDigit = currentDigit | 32; + } + encodedStr = encodedStr + base64FormatEncode(currentDigit); + } while (inValue > 0); + return encodedStr; + } + } + function recordSourceMapSpan(pos) { + var sourceLinePos = ts.getLineAndCharacterOfPosition(currentSourceFile, pos); + sourceLinePos.line++; + sourceLinePos.character++; + var emittedLine = writer.getLine(); + var emittedColumn = writer.getColumn(); + if (!lastRecordedSourceMapSpan || + lastRecordedSourceMapSpan.emittedLine !== emittedLine || + lastRecordedSourceMapSpan.emittedColumn !== emittedColumn || + (lastRecordedSourceMapSpan.sourceIndex === sourceMapSourceIndex && + (lastRecordedSourceMapSpan.sourceLine > sourceLinePos.line || + (lastRecordedSourceMapSpan.sourceLine === sourceLinePos.line && lastRecordedSourceMapSpan.sourceColumn > sourceLinePos.character)))) { + encodeLastRecordedSourceMapSpan(); + lastRecordedSourceMapSpan = { + emittedLine: emittedLine, + emittedColumn: emittedColumn, + sourceLine: sourceLinePos.line, + sourceColumn: sourceLinePos.character, + nameIndex: getSourceMapNameIndex(), + sourceIndex: sourceMapSourceIndex + }; + } + else { + lastRecordedSourceMapSpan.sourceLine = sourceLinePos.line; + lastRecordedSourceMapSpan.sourceColumn = sourceLinePos.character; + lastRecordedSourceMapSpan.sourceIndex = sourceMapSourceIndex; + } + } + function recordEmitNodeStartSpan(node) { + recordSourceMapSpan(ts.skipTrivia(currentSourceFile.text, node.pos)); + } + function recordEmitNodeEndSpan(node) { + recordSourceMapSpan(node.end); + } + function writeTextWithSpanRecord(tokenKind, startPos, emitFn) { + var tokenStartPos = ts.skipTrivia(currentSourceFile.text, startPos); + recordSourceMapSpan(tokenStartPos); + var tokenEndPos = emitTokenText(tokenKind, tokenStartPos, emitFn); + recordSourceMapSpan(tokenEndPos); + return tokenEndPos; + } + function recordNewSourceFileStart(node) { + var sourcesDirectoryPath = compilerOptions.sourceRoot ? host.getCommonSourceDirectory() : sourceMapDir; + sourceMapData.sourceMapSources.push(ts.getRelativePathToDirectoryOrUrl(sourcesDirectoryPath, node.fileName, host.getCurrentDirectory(), host.getCanonicalFileName, true)); + sourceMapSourceIndex = sourceMapData.sourceMapSources.length - 1; + sourceMapData.inputSourceFileNames.push(node.fileName); + if (compilerOptions.inlineSources) { + if (!sourceMapData.sourceMapSourcesContent) { + sourceMapData.sourceMapSourcesContent = []; + } + sourceMapData.sourceMapSourcesContent.push(node.text); + } + } + function recordScopeNameOfNode(node, scopeName) { + function recordScopeNameIndex(scopeNameIndex) { + sourceMapNameIndices.push(scopeNameIndex); + } + function recordScopeNameStart(scopeName) { + var scopeNameIndex = -1; + if (scopeName) { + var parentIndex = getSourceMapNameIndex(); + if (parentIndex !== -1) { + var name_22 = node.name; + if (!name_22 || name_22.kind !== 136) { + scopeName = "." + scopeName; + } + scopeName = sourceMapData.sourceMapNames[parentIndex] + scopeName; + } + scopeNameIndex = ts.getProperty(sourceMapNameIndexMap, scopeName); + if (scopeNameIndex === undefined) { + scopeNameIndex = sourceMapData.sourceMapNames.length; + sourceMapData.sourceMapNames.push(scopeName); + sourceMapNameIndexMap[scopeName] = scopeNameIndex; + } + } + recordScopeNameIndex(scopeNameIndex); + } + if (scopeName) { + recordScopeNameStart(scopeName); + } + else if (node.kind === 213 || + node.kind === 173 || + node.kind === 143 || + node.kind === 142 || + node.kind === 145 || + node.kind === 146 || + node.kind === 218 || + node.kind === 214 || + node.kind === 217) { + if (node.name) { + var name_23 = node.name; + scopeName = name_23.kind === 136 + ? ts.getTextOfNode(name_23) + : node.name.text; + } + recordScopeNameStart(scopeName); + } + else { + recordScopeNameIndex(getSourceMapNameIndex()); + } + } + function recordScopeNameEnd() { + sourceMapNameIndices.pop(); + } + ; + function writeCommentRangeWithMap(curentSourceFile, writer, comment, newLine) { + recordSourceMapSpan(comment.pos); + ts.writeCommentRange(currentSourceFile, writer, comment, newLine); + recordSourceMapSpan(comment.end); + } + function serializeSourceMapContents(version, file, sourceRoot, sources, names, mappings, sourcesContent) { + if (typeof JSON !== "undefined") { + var map_2 = { + version: version, + file: file, + sourceRoot: sourceRoot, + sources: sources, + names: names, + mappings: mappings + }; + if (sourcesContent !== undefined) { + map_2.sourcesContent = sourcesContent; + } + return JSON.stringify(map_2); + } + return "{\"version\":" + version + ",\"file\":\"" + ts.escapeString(file) + "\",\"sourceRoot\":\"" + ts.escapeString(sourceRoot) + "\",\"sources\":[" + serializeStringArray(sources) + "],\"names\":[" + serializeStringArray(names) + "],\"mappings\":\"" + ts.escapeString(mappings) + "\" " + (sourcesContent !== undefined ? ",\"sourcesContent\":[" + serializeStringArray(sourcesContent) + "]" : "") + "}"; + function serializeStringArray(list) { + var output = ""; + for (var i = 0, n = list.length; i < n; i++) { + if (i) { + output += ","; + } + output += "\"" + ts.escapeString(list[i]) + "\""; + } + return output; + } + } + function writeJavaScriptAndSourceMapFile(emitOutput, writeByteOrderMark) { + encodeLastRecordedSourceMapSpan(); + var sourceMapText = serializeSourceMapContents(3, sourceMapData.sourceMapFile, sourceMapData.sourceMapSourceRoot, sourceMapData.sourceMapSources, sourceMapData.sourceMapNames, sourceMapData.sourceMapMappings, sourceMapData.sourceMapSourcesContent); + sourceMapDataList.push(sourceMapData); + var sourceMapUrl; + if (compilerOptions.inlineSourceMap) { + var base64SourceMapText = ts.convertToBase64(sourceMapText); + sourceMapUrl = "//# sourceMappingURL=data:application/json;base64," + base64SourceMapText; + } + else { + ts.writeFile(host, diagnostics, sourceMapData.sourceMapFilePath, sourceMapText, false); + sourceMapUrl = "//# sourceMappingURL=" + sourceMapData.jsSourceMappingURL; + } + writeJavaScriptFile(emitOutput + sourceMapUrl, writeByteOrderMark); + } + var sourceMapJsFile = ts.getBaseFileName(ts.normalizeSlashes(jsFilePath)); + sourceMapData = { + sourceMapFilePath: jsFilePath + ".map", + jsSourceMappingURL: sourceMapJsFile + ".map", + sourceMapFile: sourceMapJsFile, + sourceMapSourceRoot: compilerOptions.sourceRoot || "", + sourceMapSources: [], + inputSourceFileNames: [], + sourceMapNames: [], + sourceMapMappings: "", + sourceMapSourcesContent: undefined, + sourceMapDecodedMappings: [] + }; + sourceMapData.sourceMapSourceRoot = ts.normalizeSlashes(sourceMapData.sourceMapSourceRoot); + if (sourceMapData.sourceMapSourceRoot.length && sourceMapData.sourceMapSourceRoot.charCodeAt(sourceMapData.sourceMapSourceRoot.length - 1) !== 47) { + sourceMapData.sourceMapSourceRoot += ts.directorySeparator; + } + if (compilerOptions.mapRoot) { + sourceMapDir = ts.normalizeSlashes(compilerOptions.mapRoot); + if (root) { + sourceMapDir = ts.getDirectoryPath(ts.getSourceFilePathInNewDir(root, host, sourceMapDir)); + } + if (!ts.isRootedDiskPath(sourceMapDir) && !ts.isUrl(sourceMapDir)) { + sourceMapDir = ts.combinePaths(host.getCommonSourceDirectory(), sourceMapDir); + sourceMapData.jsSourceMappingURL = ts.getRelativePathToDirectoryOrUrl(ts.getDirectoryPath(ts.normalizePath(jsFilePath)), ts.combinePaths(sourceMapDir, sourceMapData.jsSourceMappingURL), host.getCurrentDirectory(), host.getCanonicalFileName, true); + } + else { + sourceMapData.jsSourceMappingURL = ts.combinePaths(sourceMapDir, sourceMapData.jsSourceMappingURL); + } + } + else { + sourceMapDir = ts.getDirectoryPath(ts.normalizePath(jsFilePath)); + } + function emitNodeWithSourceMap(node) { + if (node) { + if (ts.nodeIsSynthesized(node)) { + return emitNodeWithoutSourceMap(node); + } + if (node.kind !== 248) { + recordEmitNodeStartSpan(node); + emitNodeWithoutSourceMap(node); + recordEmitNodeEndSpan(node); + } + else { + recordNewSourceFileStart(node); + emitNodeWithoutSourceMap(node); + } + } + } + function emitNodeWithCommentsAndWithSourcemap(node) { + emitNodeConsideringCommentsOption(node, emitNodeWithSourceMap); + } + writeEmittedFiles = writeJavaScriptAndSourceMapFile; + emit = emitNodeWithCommentsAndWithSourcemap; + emitStart = recordEmitNodeStartSpan; + emitEnd = recordEmitNodeEndSpan; + emitToken = writeTextWithSpanRecord; + scopeEmitStart = recordScopeNameOfNode; + scopeEmitEnd = recordScopeNameEnd; + writeComment = writeCommentRangeWithMap; + } + function writeJavaScriptFile(emitOutput, writeByteOrderMark) { + ts.writeFile(host, diagnostics, jsFilePath, emitOutput, writeByteOrderMark); + } + function createTempVariable(flags) { + var result = ts.createSynthesizedNode(69); + result.text = makeTempVariableName(flags); + return result; + } + function recordTempDeclaration(name) { + if (!tempVariables) { + tempVariables = []; + } + tempVariables.push(name); + } + function createAndRecordTempVariable(flags) { + var temp = createTempVariable(flags); + recordTempDeclaration(temp); + return temp; + } + function emitTempDeclarations(newLine) { + if (tempVariables) { + if (newLine) { + writeLine(); + } + else { + write(" "); + } + write("var "); + emitCommaList(tempVariables); + write(";"); + } + } + function emitTokenText(tokenKind, startPos, emitFn) { + var tokenString = ts.tokenToString(tokenKind); + if (emitFn) { + emitFn(); + } + else { + write(tokenString); + } + return startPos + tokenString.length; + } + function emitOptional(prefix, node) { + if (node) { + write(prefix); + emit(node); + } + } + function emitParenthesizedIf(node, parenthesized) { + if (parenthesized) { + write("("); + } + emit(node); + if (parenthesized) { + write(")"); + } + } + function emitTrailingCommaIfPresent(nodeList) { + if (nodeList.hasTrailingComma) { + write(","); + } + } + function emitLinePreservingList(parent, nodes, allowTrailingComma, spacesBetweenBraces) { + ts.Debug.assert(nodes.length > 0); + increaseIndent(); + if (nodeStartPositionsAreOnSameLine(parent, nodes[0])) { + if (spacesBetweenBraces) { + write(" "); + } + } + else { + writeLine(); + } + for (var i = 0, n = nodes.length; i < n; i++) { + if (i) { + if (nodeEndIsOnSameLineAsNodeStart(nodes[i - 1], nodes[i])) { + write(", "); + } + else { + write(","); + writeLine(); + } + } + emit(nodes[i]); + } + if (nodes.hasTrailingComma && allowTrailingComma) { + write(","); + } + decreaseIndent(); + if (nodeEndPositionsAreOnSameLine(parent, ts.lastOrUndefined(nodes))) { + if (spacesBetweenBraces) { + write(" "); + } + } + else { + writeLine(); + } + } + function emitList(nodes, start, count, multiLine, trailingComma, leadingComma, noTrailingNewLine, emitNode) { + if (!emitNode) { + emitNode = emit; + } + for (var i = 0; i < count; i++) { + if (multiLine) { + if (i || leadingComma) { + write(","); + } + writeLine(); + } + else { + if (i || leadingComma) { + write(", "); + } + } + var node = nodes[start + i]; + emitTrailingCommentsOfPosition(node.pos); + emitNode(node); + leadingComma = true; + } + if (trailingComma) { + write(","); + } + if (multiLine && !noTrailingNewLine) { + writeLine(); + } + return count; + } + function emitCommaList(nodes) { + if (nodes) { + emitList(nodes, 0, nodes.length, false, false); + } + } + function emitLines(nodes) { + emitLinesStartingAt(nodes, 0); + } + function emitLinesStartingAt(nodes, startIndex) { + for (var i = startIndex; i < nodes.length; i++) { + writeLine(); + emit(nodes[i]); + } + } + function isBinaryOrOctalIntegerLiteral(node, text) { + if (node.kind === 8 && text.length > 1) { + switch (text.charCodeAt(1)) { + case 98: + case 66: + case 111: + case 79: + return true; + } + } + return false; + } + function emitLiteral(node) { + var text = getLiteralText(node); + if ((compilerOptions.sourceMap || compilerOptions.inlineSourceMap) && (node.kind === 9 || ts.isTemplateLiteralKind(node.kind))) { + writer.writeLiteral(text); + } + else if (languageVersion < 2 && isBinaryOrOctalIntegerLiteral(node, text)) { + write(node.text); + } + else { + write(text); + } + } + function getLiteralText(node) { + if (languageVersion < 2 && (ts.isTemplateLiteralKind(node.kind) || node.hasExtendedUnicodeEscape)) { + return getQuotedEscapedLiteralText("\"", node.text, "\""); + } + if (node.parent) { + return ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, node); + } + switch (node.kind) { + case 9: + return getQuotedEscapedLiteralText("\"", node.text, "\""); + case 11: + return getQuotedEscapedLiteralText("`", node.text, "`"); + case 12: + return getQuotedEscapedLiteralText("`", node.text, "${"); + case 13: + return getQuotedEscapedLiteralText("}", node.text, "${"); + case 14: + return getQuotedEscapedLiteralText("}", node.text, "`"); + case 8: + return node.text; + } + ts.Debug.fail("Literal kind '" + node.kind + "' not accounted for."); + } + function getQuotedEscapedLiteralText(leftQuote, text, rightQuote) { + return leftQuote + ts.escapeNonAsciiCharacters(ts.escapeString(text)) + rightQuote; + } + function emitDownlevelRawTemplateLiteral(node) { + var text = ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, node); + var isLast = node.kind === 11 || node.kind === 14; + text = text.substring(1, text.length - (isLast ? 1 : 2)); + text = text.replace(/\r\n?/g, "\n"); + text = ts.escapeString(text); + write("\"" + text + "\""); + } + function emitDownlevelTaggedTemplateArray(node, literalEmitter) { + write("["); + if (node.template.kind === 11) { + literalEmitter(node.template); + } + else { + literalEmitter(node.template.head); + ts.forEach(node.template.templateSpans, function (child) { + write(", "); + literalEmitter(child.literal); + }); + } + write("]"); + } + function emitDownlevelTaggedTemplate(node) { + var tempVariable = createAndRecordTempVariable(0); + write("("); + emit(tempVariable); + write(" = "); + emitDownlevelTaggedTemplateArray(node, emit); + write(", "); + emit(tempVariable); + write(".raw = "); + emitDownlevelTaggedTemplateArray(node, emitDownlevelRawTemplateLiteral); + write(", "); + emitParenthesizedIf(node.tag, needsParenthesisForPropertyAccessOrInvocation(node.tag)); + write("("); + emit(tempVariable); + if (node.template.kind === 183) { + ts.forEach(node.template.templateSpans, function (templateSpan) { + write(", "); + var needsParens = templateSpan.expression.kind === 181 + && templateSpan.expression.operatorToken.kind === 24; + emitParenthesizedIf(templateSpan.expression, needsParens); + }); + } + write("))"); + } + function emitTemplateExpression(node) { + if (languageVersion >= 2) { + ts.forEachChild(node, emit); + return; + } + var emitOuterParens = ts.isExpression(node.parent) + && templateNeedsParens(node, node.parent); + if (emitOuterParens) { + write("("); + } + var headEmitted = false; + if (shouldEmitTemplateHead()) { + emitLiteral(node.head); + headEmitted = true; + } + for (var i = 0, n = node.templateSpans.length; i < n; i++) { + var templateSpan = node.templateSpans[i]; + var needsParens = templateSpan.expression.kind !== 172 + && comparePrecedenceToBinaryPlus(templateSpan.expression) !== 1; + if (i > 0 || headEmitted) { + write(" + "); + } + emitParenthesizedIf(templateSpan.expression, needsParens); + if (templateSpan.literal.text.length !== 0) { + write(" + "); + emitLiteral(templateSpan.literal); + } + } + if (emitOuterParens) { + write(")"); + } + function shouldEmitTemplateHead() { + ts.Debug.assert(node.templateSpans.length !== 0); + return node.head.text.length !== 0 || node.templateSpans[0].literal.text.length === 0; + } + function templateNeedsParens(template, parent) { + switch (parent.kind) { + case 168: + case 169: + return parent.expression === template; + case 170: + case 172: + return false; + default: + return comparePrecedenceToBinaryPlus(parent) !== -1; + } + } + function comparePrecedenceToBinaryPlus(expression) { + switch (expression.kind) { + case 181: + switch (expression.operatorToken.kind) { + case 37: + case 39: + case 40: + return 1; + case 35: + case 36: + return 0; + default: + return -1; + } + case 184: + case 182: + return -1; + default: + return 1; + } + } + } + function emitTemplateSpan(span) { + emit(span.expression); + emit(span.literal); + } + function jsxEmitReact(node) { + function emitTagName(name) { + if (name.kind === 69 && ts.isIntrinsicJsxName(name.text)) { + write("\""); + emit(name); + write("\""); + } + else { + emit(name); + } + } + function emitAttributeName(name) { + if (/[A-Za-z_]+[\w*]/.test(name.text)) { + write("\""); + emit(name); + write("\""); + } + else { + emit(name); + } + } + function emitJsxAttribute(node) { + emitAttributeName(node.name); + write(": "); + if (node.initializer) { + emit(node.initializer); + } + else { + write("true"); + } + } + function emitJsxElement(openingNode, children) { + var syntheticReactRef = ts.createSynthesizedNode(69); + syntheticReactRef.text = "React"; + syntheticReactRef.parent = openingNode; + emitLeadingComments(openingNode); + emitExpressionIdentifier(syntheticReactRef); + write(".createElement("); + emitTagName(openingNode.tagName); + write(", "); + if (openingNode.attributes.length === 0) { + write("null"); + } + else { + var attrs = openingNode.attributes; + if (ts.forEach(attrs, function (attr) { return attr.kind === 239; })) { + emitExpressionIdentifier(syntheticReactRef); + write(".__spread("); + var haveOpenedObjectLiteral = false; + for (var i_1 = 0; i_1 < attrs.length; i_1++) { + if (attrs[i_1].kind === 239) { + if (i_1 === 0) { + write("{}, "); + } + if (haveOpenedObjectLiteral) { + write("}"); + haveOpenedObjectLiteral = false; + } + if (i_1 > 0) { + write(", "); + } + emit(attrs[i_1].expression); + } + else { + ts.Debug.assert(attrs[i_1].kind === 238); + if (haveOpenedObjectLiteral) { + write(", "); + } + else { + haveOpenedObjectLiteral = true; + if (i_1 > 0) { + write(", "); + } + write("{"); + } + emitJsxAttribute(attrs[i_1]); + } + } + if (haveOpenedObjectLiteral) + write("}"); + write(")"); + } + else { + write("{"); + for (var i = 0; i < attrs.length; i++) { + if (i > 0) { + write(", "); + } + emitJsxAttribute(attrs[i]); + } + write("}"); + } + } + if (children) { + for (var i = 0; i < children.length; i++) { + if (children[i].kind === 240 && !(children[i].expression)) { + continue; + } + if (children[i].kind === 236) { + var text = getTextToEmit(children[i]); + if (text !== undefined) { + write(", \""); + write(text); + write("\""); + } + } + else { + write(", "); + emit(children[i]); + } + } + } + write(")"); + emitTrailingComments(openingNode); + } + if (node.kind === 233) { + emitJsxElement(node.openingElement, node.children); + } + else { + ts.Debug.assert(node.kind === 234); + emitJsxElement(node); + } + } + function jsxEmitPreserve(node) { + function emitJsxAttribute(node) { + emit(node.name); + if (node.initializer) { + write("="); + emit(node.initializer); + } + } + function emitJsxSpreadAttribute(node) { + write("{..."); + emit(node.expression); + write("}"); + } + function emitAttributes(attribs) { + for (var i = 0, n = attribs.length; i < n; i++) { + if (i > 0) { + write(" "); + } + if (attribs[i].kind === 239) { + emitJsxSpreadAttribute(attribs[i]); + } + else { + ts.Debug.assert(attribs[i].kind === 238); + emitJsxAttribute(attribs[i]); + } + } + } + function emitJsxOpeningOrSelfClosingElement(node) { + write("<"); + emit(node.tagName); + if (node.attributes.length > 0 || (node.kind === 234)) { + write(" "); + } + emitAttributes(node.attributes); + if (node.kind === 234) { + write("/>"); + } + else { + write(">"); + } + } + function emitJsxClosingElement(node) { + write(""); + } + function emitJsxElement(node) { + emitJsxOpeningOrSelfClosingElement(node.openingElement); + for (var i = 0, n = node.children.length; i < n; i++) { + emit(node.children[i]); + } + emitJsxClosingElement(node.closingElement); + } + if (node.kind === 233) { + emitJsxElement(node); + } + else { + ts.Debug.assert(node.kind === 234); + emitJsxOpeningOrSelfClosingElement(node); + } + } + function emitExpressionForPropertyName(node) { + ts.Debug.assert(node.kind !== 163); + if (node.kind === 9) { + emitLiteral(node); + } + else if (node.kind === 136) { + if (ts.nodeIsDecorated(node.parent)) { + if (!computedPropertyNamesToGeneratedNames) { + computedPropertyNamesToGeneratedNames = []; + } + var generatedName = computedPropertyNamesToGeneratedNames[ts.getNodeId(node)]; + if (generatedName) { + write(generatedName); + return; + } + generatedName = createAndRecordTempVariable(0).text; + computedPropertyNamesToGeneratedNames[ts.getNodeId(node)] = generatedName; + write(generatedName); + write(" = "); + } + emit(node.expression); + } + else { + write("\""); + if (node.kind === 8) { + write(node.text); + } + else { + writeTextOfNode(currentSourceFile, node); + } + write("\""); + } + } + function isExpressionIdentifier(node) { + var parent = node.parent; + switch (parent.kind) { + case 164: + case 189: + case 181: + case 168: + case 241: + case 136: + case 182: + case 139: + case 175: + case 197: + case 167: + case 227: + case 195: + case 188: + case 199: + case 200: + case 201: + case 196: + case 234: + case 235: + case 239: + case 240: + case 169: + case 172: + case 180: + case 179: + case 204: + case 246: + case 185: + case 206: + case 170: + case 190: + case 208: + case 171: + case 176: + case 177: + case 198: + case 205: + case 184: + return true; + case 163: + case 247: + case 138: + case 245: + case 141: + case 211: + return parent.initializer === node; + case 166: + return parent.expression === node; + case 174: + case 173: + return parent.body === node; + case 221: + return parent.moduleReference === node; + case 135: + return parent.left === node; + } + return false; + } + function emitExpressionIdentifier(node) { + if (resolver.getNodeCheckFlags(node) & 2048) { + write("_arguments"); + return; + } + var container = resolver.getReferencedExportContainer(node); + if (container) { + if (container.kind === 248) { + if (modulekind !== 5 && modulekind !== 4) { + write("exports."); + } + } + else { + write(getGeneratedNameForNode(container)); + write("."); + } + } + else if (modulekind !== 5) { + var declaration = resolver.getReferencedImportDeclaration(node); + if (declaration) { + if (declaration.kind === 223) { + write(getGeneratedNameForNode(declaration.parent)); + write(languageVersion === 0 ? "[\"default\"]" : ".default"); + return; + } + else if (declaration.kind === 226) { + write(getGeneratedNameForNode(declaration.parent.parent.parent)); + var name_24 = declaration.propertyName || declaration.name; + var identifier = ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, name_24); + if (languageVersion === 0 && identifier === "default") { + write("[\"default\"]"); + } + else { + write("."); + write(identifier); + } + return; + } + } + declaration = resolver.getReferencedNestedRedeclaration(node); + if (declaration) { + write(getGeneratedNameForNode(declaration.name)); + return; + } + } + if (ts.nodeIsSynthesized(node)) { + write(node.text); + } + else { + writeTextOfNode(currentSourceFile, node); + } + } + function isNameOfNestedRedeclaration(node) { + if (languageVersion < 2) { + var parent_6 = node.parent; + switch (parent_6.kind) { + case 163: + case 214: + case 217: + case 211: + return parent_6.name === node && resolver.isNestedRedeclaration(parent_6); + } + } + return false; + } + function emitIdentifier(node) { + if (!node.parent) { + write(node.text); + } + else if (isExpressionIdentifier(node)) { + emitExpressionIdentifier(node); + } + else if (isNameOfNestedRedeclaration(node)) { + write(getGeneratedNameForNode(node)); + } + else if (ts.nodeIsSynthesized(node)) { + write(node.text); + } + else { + writeTextOfNode(currentSourceFile, node); + } + } + function emitThis(node) { + if (resolver.getNodeCheckFlags(node) & 2) { + write("_this"); + } + else { + write("this"); + } + } + function emitSuper(node) { + if (languageVersion >= 2) { + write("super"); + } + else { + var flags = resolver.getNodeCheckFlags(node); + if (flags & 256) { + write("_super.prototype"); + } + else { + write("_super"); + } + } + } + function emitObjectBindingPattern(node) { + write("{ "); + var elements = node.elements; + emitList(elements, 0, elements.length, false, elements.hasTrailingComma); + write(" }"); + } + function emitArrayBindingPattern(node) { + write("["); + var elements = node.elements; + emitList(elements, 0, elements.length, false, elements.hasTrailingComma); + write("]"); + } + function emitBindingElement(node) { + if (node.propertyName) { + emit(node.propertyName); + write(": "); + } + if (node.dotDotDotToken) { + write("..."); + } + if (ts.isBindingPattern(node.name)) { + emit(node.name); + } + else { + emitModuleMemberName(node); + } + emitOptional(" = ", node.initializer); + } + function emitSpreadElementExpression(node) { + write("..."); + emit(node.expression); + } + function emitYieldExpression(node) { + write(ts.tokenToString(114)); + if (node.asteriskToken) { + write("*"); + } + if (node.expression) { + write(" "); + emit(node.expression); + } + } + function emitAwaitExpression(node) { + var needsParenthesis = needsParenthesisForAwaitExpressionAsYield(node); + if (needsParenthesis) { + write("("); + } + write(ts.tokenToString(114)); + write(" "); + emit(node.expression); + if (needsParenthesis) { + write(")"); + } + } + function needsParenthesisForAwaitExpressionAsYield(node) { + if (node.parent.kind === 181 && !ts.isAssignmentOperator(node.parent.operatorToken.kind)) { + return true; + } + else if (node.parent.kind === 182 && node.parent.condition === node) { + return true; + } + return false; + } + function needsParenthesisForPropertyAccessOrInvocation(node) { + switch (node.kind) { + case 69: + case 164: + case 166: + case 167: + case 168: + case 172: + return false; + } + return true; + } + function emitListWithSpread(elements, needsUniqueCopy, multiLine, trailingComma, useConcat) { + var pos = 0; + var group = 0; + var length = elements.length; + while (pos < length) { + if (group === 1 && useConcat) { + write(".concat("); + } + else if (group > 0) { + write(", "); + } + var e = elements[pos]; + if (e.kind === 185) { + e = e.expression; + emitParenthesizedIf(e, group === 0 && needsParenthesisForPropertyAccessOrInvocation(e)); + pos++; + if (pos === length && group === 0 && needsUniqueCopy && e.kind !== 164) { + write(".slice()"); + } + } + else { + var i = pos; + while (i < length && elements[i].kind !== 185) { + i++; + } + write("["); + if (multiLine) { + increaseIndent(); + } + emitList(elements, pos, i - pos, multiLine, trailingComma && i === length); + if (multiLine) { + decreaseIndent(); + } + write("]"); + pos = i; + } + group++; + } + if (group > 1) { + if (useConcat) { + write(")"); + } + } + } + function isSpreadElementExpression(node) { + return node.kind === 185; + } + function emitArrayLiteral(node) { + var elements = node.elements; + if (elements.length === 0) { + write("[]"); + } + else if (languageVersion >= 2 || !ts.forEach(elements, isSpreadElementExpression)) { + write("["); + emitLinePreservingList(node, node.elements, elements.hasTrailingComma, false); + write("]"); + } + else { + emitListWithSpread(elements, true, (node.flags & 2048) !== 0, elements.hasTrailingComma, true); + } + } + function emitObjectLiteralBody(node, numElements) { + if (numElements === 0) { + write("{}"); + return; + } + write("{"); + if (numElements > 0) { + var properties = node.properties; + if (numElements === properties.length) { + emitLinePreservingList(node, properties, languageVersion >= 1, true); + } + else { + var multiLine = (node.flags & 2048) !== 0; + if (!multiLine) { + write(" "); + } + else { + increaseIndent(); + } + emitList(properties, 0, numElements, multiLine, false); + if (!multiLine) { + write(" "); + } + else { + decreaseIndent(); + } + } + } + write("}"); + } + function emitDownlevelObjectLiteralWithComputedProperties(node, firstComputedPropertyIndex) { + var multiLine = (node.flags & 2048) !== 0; + var properties = node.properties; + write("("); + if (multiLine) { + increaseIndent(); + } + var tempVar = createAndRecordTempVariable(0); + emit(tempVar); + write(" = "); + emitObjectLiteralBody(node, firstComputedPropertyIndex); + for (var i = firstComputedPropertyIndex, n = properties.length; i < n; i++) { + writeComma(); + var property = properties[i]; + emitStart(property); + if (property.kind === 145 || property.kind === 146) { + var accessors = ts.getAllAccessorDeclarations(node.properties, property); + if (property !== accessors.firstAccessor) { + continue; + } + write("Object.defineProperty("); + emit(tempVar); + write(", "); + emitStart(node.name); + emitExpressionForPropertyName(property.name); + emitEnd(property.name); + write(", {"); + increaseIndent(); + if (accessors.getAccessor) { + writeLine(); + emitLeadingComments(accessors.getAccessor); + write("get: "); + emitStart(accessors.getAccessor); + write("function "); + emitSignatureAndBody(accessors.getAccessor); + emitEnd(accessors.getAccessor); + emitTrailingComments(accessors.getAccessor); + write(","); + } + if (accessors.setAccessor) { + writeLine(); + emitLeadingComments(accessors.setAccessor); + write("set: "); + emitStart(accessors.setAccessor); + write("function "); + emitSignatureAndBody(accessors.setAccessor); + emitEnd(accessors.setAccessor); + emitTrailingComments(accessors.setAccessor); + write(","); + } + writeLine(); + write("enumerable: true,"); + writeLine(); + write("configurable: true"); + decreaseIndent(); + writeLine(); + write("})"); + emitEnd(property); + } + else { + emitLeadingComments(property); + emitStart(property.name); + emit(tempVar); + emitMemberAccessForPropertyName(property.name); + emitEnd(property.name); + write(" = "); + if (property.kind === 245) { + emit(property.initializer); + } + else if (property.kind === 246) { + emitExpressionIdentifier(property.name); + } + else if (property.kind === 143) { + emitFunctionDeclaration(property); + } + else { + ts.Debug.fail("ObjectLiteralElement type not accounted for: " + property.kind); + } + } + emitEnd(property); + } + writeComma(); + emit(tempVar); + if (multiLine) { + decreaseIndent(); + writeLine(); + } + write(")"); + function writeComma() { + if (multiLine) { + write(","); + writeLine(); + } + else { + write(", "); + } + } + } + function emitObjectLiteral(node) { + var properties = node.properties; + if (languageVersion < 2) { + var numProperties = properties.length; + var numInitialNonComputedProperties = numProperties; + for (var i = 0, n = properties.length; i < n; i++) { + if (properties[i].name.kind === 136) { + numInitialNonComputedProperties = i; + break; + } + } + var hasComputedProperty = numInitialNonComputedProperties !== properties.length; + if (hasComputedProperty) { + emitDownlevelObjectLiteralWithComputedProperties(node, numInitialNonComputedProperties); + return; + } + } + emitObjectLiteralBody(node, properties.length); + } + function createBinaryExpression(left, operator, right, startsOnNewLine) { + var result = ts.createSynthesizedNode(181, startsOnNewLine); + result.operatorToken = ts.createSynthesizedNode(operator); + result.left = left; + result.right = right; + return result; + } + function createPropertyAccessExpression(expression, name) { + var result = ts.createSynthesizedNode(166); + result.expression = parenthesizeForAccess(expression); + result.dotToken = ts.createSynthesizedNode(21); + result.name = name; + return result; + } + function createElementAccessExpression(expression, argumentExpression) { + var result = ts.createSynthesizedNode(167); + result.expression = parenthesizeForAccess(expression); + result.argumentExpression = argumentExpression; + return result; + } + function parenthesizeForAccess(expr) { + while (expr.kind === 171 || expr.kind === 189) { + expr = expr.expression; + } + if (ts.isLeftHandSideExpression(expr) && + expr.kind !== 169 && + expr.kind !== 8) { + return expr; + } + var node = ts.createSynthesizedNode(172); + node.expression = expr; + return node; + } + function emitComputedPropertyName(node) { + write("["); + emitExpressionForPropertyName(node); + write("]"); + } + function emitMethod(node) { + if (languageVersion >= 2 && node.asteriskToken) { + write("*"); + } + emit(node.name); + if (languageVersion < 2) { + write(": function "); + } + emitSignatureAndBody(node); + } + function emitPropertyAssignment(node) { + emit(node.name); + write(": "); + emitTrailingCommentsOfPosition(node.initializer.pos); + emit(node.initializer); + } + function isNamespaceExportReference(node) { + var container = resolver.getReferencedExportContainer(node); + return container && container.kind !== 248; + } + function emitShorthandPropertyAssignment(node) { + writeTextOfNode(currentSourceFile, node.name); + if (languageVersion < 2 || isNamespaceExportReference(node.name)) { + write(": "); + emit(node.name); + } + if (languageVersion >= 2 && node.objectAssignmentInitializer) { + write(" = "); + emit(node.objectAssignmentInitializer); + } + } + function tryEmitConstantValue(node) { + var constantValue = tryGetConstEnumValue(node); + if (constantValue !== undefined) { + write(constantValue.toString()); + if (!compilerOptions.removeComments) { + var propertyName = node.kind === 166 ? ts.declarationNameToString(node.name) : ts.getTextOfNode(node.argumentExpression); + write(" /* " + propertyName + " */"); + } + return true; + } + return false; + } + function tryGetConstEnumValue(node) { + if (compilerOptions.isolatedModules) { + return undefined; + } + return node.kind === 166 || node.kind === 167 + ? resolver.getConstantValue(node) + : undefined; + } + function indentIfOnDifferentLines(parent, node1, node2, valueToWriteWhenNotIndenting) { + var realNodesAreOnDifferentLines = !ts.nodeIsSynthesized(parent) && !nodeEndIsOnSameLineAsNodeStart(node1, node2); + var synthesizedNodeIsOnDifferentLine = synthesizedNodeStartsOnNewLine(node2); + if (realNodesAreOnDifferentLines || synthesizedNodeIsOnDifferentLine) { + increaseIndent(); + writeLine(); + return true; + } + else { + if (valueToWriteWhenNotIndenting) { + write(valueToWriteWhenNotIndenting); + } + return false; + } + } + function emitPropertyAccess(node) { + if (tryEmitConstantValue(node)) { + return; + } + emit(node.expression); + var indentedBeforeDot = indentIfOnDifferentLines(node, node.expression, node.dotToken); + var shouldEmitSpace; + if (!indentedBeforeDot) { + if (node.expression.kind === 8) { + var text = ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, node.expression); + shouldEmitSpace = text.indexOf(ts.tokenToString(21)) < 0; + } + else { + var constantValue = tryGetConstEnumValue(node.expression); + shouldEmitSpace = isFinite(constantValue) && Math.floor(constantValue) === constantValue; + } + } + if (shouldEmitSpace) { + write(" ."); + } + else { + write("."); + } + var indentedAfterDot = indentIfOnDifferentLines(node, node.dotToken, node.name); + emit(node.name); + decreaseIndentIf(indentedBeforeDot, indentedAfterDot); + } + function emitQualifiedName(node) { + emit(node.left); + write("."); + emit(node.right); + } + function emitQualifiedNameAsExpression(node, useFallback) { + if (node.left.kind === 69) { + emitEntityNameAsExpression(node.left, useFallback); + } + else if (useFallback) { + var temp = createAndRecordTempVariable(0); + write("("); + emitNodeWithoutSourceMap(temp); + write(" = "); + emitEntityNameAsExpression(node.left, true); + write(") && "); + emitNodeWithoutSourceMap(temp); + } + else { + emitEntityNameAsExpression(node.left, false); + } + write("."); + emit(node.right); + } + function emitEntityNameAsExpression(node, useFallback) { + switch (node.kind) { + case 69: + if (useFallback) { + write("typeof "); + emitExpressionIdentifier(node); + write(" !== 'undefined' && "); + } + emitExpressionIdentifier(node); + break; + case 135: + emitQualifiedNameAsExpression(node, useFallback); + break; + } + } + function emitIndexedAccess(node) { + if (tryEmitConstantValue(node)) { + return; + } + emit(node.expression); + write("["); + emit(node.argumentExpression); + write("]"); + } + function hasSpreadElement(elements) { + return ts.forEach(elements, function (e) { return e.kind === 185; }); + } + function skipParentheses(node) { + while (node.kind === 172 || node.kind === 171 || node.kind === 189) { + node = node.expression; + } + return node; + } + function emitCallTarget(node) { + if (node.kind === 69 || node.kind === 97 || node.kind === 95) { + emit(node); + return node; + } + var temp = createAndRecordTempVariable(0); + write("("); + emit(temp); + write(" = "); + emit(node); + write(")"); + return temp; + } + function emitCallWithSpread(node) { + var target; + var expr = skipParentheses(node.expression); + if (expr.kind === 166) { + target = emitCallTarget(expr.expression); + write("."); + emit(expr.name); + } + else if (expr.kind === 167) { + target = emitCallTarget(expr.expression); + write("["); + emit(expr.argumentExpression); + write("]"); + } + else if (expr.kind === 95) { + target = expr; + write("_super"); + } + else { + emit(node.expression); + } + write(".apply("); + if (target) { + if (target.kind === 95) { + emitThis(target); + } + else { + emit(target); + } + } + else { + write("void 0"); + } + write(", "); + emitListWithSpread(node.arguments, false, false, false, true); + write(")"); + } + function emitCallExpression(node) { + if (languageVersion < 2 && hasSpreadElement(node.arguments)) { + emitCallWithSpread(node); + return; + } + var superCall = false; + if (node.expression.kind === 95) { + emitSuper(node.expression); + superCall = true; + } + else { + emit(node.expression); + superCall = node.expression.kind === 166 && node.expression.expression.kind === 95; + } + if (superCall && languageVersion < 2) { + write(".call("); + emitThis(node.expression); + if (node.arguments.length) { + write(", "); + emitCommaList(node.arguments); + } + write(")"); + } + else { + write("("); + emitCommaList(node.arguments); + write(")"); + } + } + function emitNewExpression(node) { + write("new "); + if (languageVersion === 1 && + node.arguments && + hasSpreadElement(node.arguments)) { + write("("); + var target = emitCallTarget(node.expression); + write(".bind.apply("); + emit(target); + write(", [void 0].concat("); + emitListWithSpread(node.arguments, false, false, false, false); + write(")))"); + write("()"); + } + else { + emit(node.expression); + if (node.arguments) { + write("("); + emitCommaList(node.arguments); + write(")"); + } + } + } + function emitTaggedTemplateExpression(node) { + if (languageVersion >= 2) { + emit(node.tag); + write(" "); + emit(node.template); + } + else { + emitDownlevelTaggedTemplate(node); + } + } + function emitParenExpression(node) { + if (!ts.nodeIsSynthesized(node) && node.parent.kind !== 174) { + if (node.expression.kind === 171 || node.expression.kind === 189) { + var operand = node.expression.expression; + while (operand.kind === 171 || operand.kind === 189) { + operand = operand.expression; + } + if (operand.kind !== 179 && + operand.kind !== 177 && + operand.kind !== 176 && + operand.kind !== 175 && + operand.kind !== 180 && + operand.kind !== 169 && + !(operand.kind === 168 && node.parent.kind === 169) && + !(operand.kind === 173 && node.parent.kind === 168) && + !(operand.kind === 8 && node.parent.kind === 166)) { + emit(operand); + return; + } + } + } + write("("); + emit(node.expression); + write(")"); + } + function emitDeleteExpression(node) { + write(ts.tokenToString(78)); + write(" "); + emit(node.expression); + } + function emitVoidExpression(node) { + write(ts.tokenToString(103)); + write(" "); + emit(node.expression); + } + function emitTypeOfExpression(node) { + write(ts.tokenToString(101)); + write(" "); + emit(node.expression); + } + function isNameOfExportedSourceLevelDeclarationInSystemExternalModule(node) { + if (!isCurrentFileSystemExternalModule() || node.kind !== 69 || ts.nodeIsSynthesized(node)) { + return false; + } + var isVariableDeclarationOrBindingElement = node.parent && (node.parent.kind === 211 || node.parent.kind === 163); + var targetDeclaration = isVariableDeclarationOrBindingElement + ? node.parent + : resolver.getReferencedValueDeclaration(node); + return isSourceFileLevelDeclarationInSystemJsModule(targetDeclaration, true); + } + function emitPrefixUnaryExpression(node) { + var exportChanged = isNameOfExportedSourceLevelDeclarationInSystemExternalModule(node.operand); + if (exportChanged) { + write(exportFunctionForFile + "(\""); + emitNodeWithoutSourceMap(node.operand); + write("\", "); + } + write(ts.tokenToString(node.operator)); + if (node.operand.kind === 179) { + var operand = node.operand; + if (node.operator === 35 && (operand.operator === 35 || operand.operator === 41)) { + write(" "); + } + else if (node.operator === 36 && (operand.operator === 36 || operand.operator === 42)) { + write(" "); + } + } + emit(node.operand); + if (exportChanged) { + write(")"); + } + } + function emitPostfixUnaryExpression(node) { + var exportChanged = isNameOfExportedSourceLevelDeclarationInSystemExternalModule(node.operand); + if (exportChanged) { + write("(" + exportFunctionForFile + "(\""); + emitNodeWithoutSourceMap(node.operand); + write("\", "); + write(ts.tokenToString(node.operator)); + emit(node.operand); + if (node.operator === 41) { + write(") - 1)"); + } + else { + write(") + 1)"); + } + } + else { + emit(node.operand); + write(ts.tokenToString(node.operator)); + } + } + function shouldHoistDeclarationInSystemJsModule(node) { + return isSourceFileLevelDeclarationInSystemJsModule(node, false); + } + function isSourceFileLevelDeclarationInSystemJsModule(node, isExported) { + if (!node || languageVersion >= 2 || !isCurrentFileSystemExternalModule()) { + return false; + } + var current = node; + while (current) { + if (current.kind === 248) { + return !isExported || ((ts.getCombinedNodeFlags(node) & 1) !== 0); + } + else if (ts.isFunctionLike(current) || current.kind === 219) { + return false; + } + else { + current = current.parent; + } + } + } + function emitExponentiationOperator(node) { + var leftHandSideExpression = node.left; + if (node.operatorToken.kind === 60) { + var synthesizedLHS; + var shouldEmitParentheses = false; + if (ts.isElementAccessExpression(leftHandSideExpression)) { + shouldEmitParentheses = true; + write("("); + synthesizedLHS = ts.createSynthesizedNode(167, false); + var identifier = emitTempVariableAssignment(leftHandSideExpression.expression, false, false); + synthesizedLHS.expression = identifier; + if (leftHandSideExpression.argumentExpression.kind !== 8 && + leftHandSideExpression.argumentExpression.kind !== 9) { + var tempArgumentExpression = createAndRecordTempVariable(268435456); + synthesizedLHS.argumentExpression = tempArgumentExpression; + emitAssignment(tempArgumentExpression, leftHandSideExpression.argumentExpression, true); + } + else { + synthesizedLHS.argumentExpression = leftHandSideExpression.argumentExpression; + } + write(", "); + } + else if (ts.isPropertyAccessExpression(leftHandSideExpression)) { + shouldEmitParentheses = true; + write("("); + synthesizedLHS = ts.createSynthesizedNode(166, false); + var identifier = emitTempVariableAssignment(leftHandSideExpression.expression, false, false); + synthesizedLHS.expression = identifier; + synthesizedLHS.dotToken = leftHandSideExpression.dotToken; + synthesizedLHS.name = leftHandSideExpression.name; + write(", "); + } + emit(synthesizedLHS || leftHandSideExpression); + write(" = "); + write("Math.pow("); + emit(synthesizedLHS || leftHandSideExpression); + write(", "); + emit(node.right); + write(")"); + if (shouldEmitParentheses) { + write(")"); + } + } + else { + write("Math.pow("); + emit(leftHandSideExpression); + write(", "); + emit(node.right); + write(")"); + } + } + function emitBinaryExpression(node) { + if (languageVersion < 2 && node.operatorToken.kind === 56 && + (node.left.kind === 165 || node.left.kind === 164)) { + emitDestructuring(node, node.parent.kind === 195); + } + else { + var exportChanged = node.operatorToken.kind >= 56 && + node.operatorToken.kind <= 68 && + isNameOfExportedSourceLevelDeclarationInSystemExternalModule(node.left); + if (exportChanged) { + write(exportFunctionForFile + "(\""); + emitNodeWithoutSourceMap(node.left); + write("\", "); + } + if (node.operatorToken.kind === 38 || node.operatorToken.kind === 60) { + emitExponentiationOperator(node); + } + else { + emit(node.left); + var indentedBeforeOperator = indentIfOnDifferentLines(node, node.left, node.operatorToken, node.operatorToken.kind !== 24 ? " " : undefined); + write(ts.tokenToString(node.operatorToken.kind)); + var indentedAfterOperator = indentIfOnDifferentLines(node, node.operatorToken, node.right, " "); + emit(node.right); + decreaseIndentIf(indentedBeforeOperator, indentedAfterOperator); + } + if (exportChanged) { + write(")"); + } + } + } + function synthesizedNodeStartsOnNewLine(node) { + return ts.nodeIsSynthesized(node) && node.startsOnNewLine; + } + function emitConditionalExpression(node) { + emit(node.condition); + var indentedBeforeQuestion = indentIfOnDifferentLines(node, node.condition, node.questionToken, " "); + write("?"); + var indentedAfterQuestion = indentIfOnDifferentLines(node, node.questionToken, node.whenTrue, " "); + emit(node.whenTrue); + decreaseIndentIf(indentedBeforeQuestion, indentedAfterQuestion); + var indentedBeforeColon = indentIfOnDifferentLines(node, node.whenTrue, node.colonToken, " "); + write(":"); + var indentedAfterColon = indentIfOnDifferentLines(node, node.colonToken, node.whenFalse, " "); + emit(node.whenFalse); + decreaseIndentIf(indentedBeforeColon, indentedAfterColon); + } + function decreaseIndentIf(value1, value2) { + if (value1) { + decreaseIndent(); + } + if (value2) { + decreaseIndent(); + } + } + function isSingleLineEmptyBlock(node) { + if (node && node.kind === 192) { + var block = node; + return block.statements.length === 0 && nodeEndIsOnSameLineAsNodeStart(block, block); + } + } + function emitBlock(node) { + if (isSingleLineEmptyBlock(node)) { + emitToken(15, node.pos); + write(" "); + emitToken(16, node.statements.end); + return; + } + emitToken(15, node.pos); + increaseIndent(); + scopeEmitStart(node.parent); + if (node.kind === 219) { + ts.Debug.assert(node.parent.kind === 218); + emitCaptureThisForNodeIfNecessary(node.parent); + } + emitLines(node.statements); + if (node.kind === 219) { + emitTempDeclarations(true); + } + decreaseIndent(); + writeLine(); + emitToken(16, node.statements.end); + scopeEmitEnd(); + } + function emitEmbeddedStatement(node) { + if (node.kind === 192) { + write(" "); + emit(node); + } + else { + increaseIndent(); + writeLine(); + emit(node); + decreaseIndent(); + } + } + function emitExpressionStatement(node) { + emitParenthesizedIf(node.expression, node.expression.kind === 174); + write(";"); + } + function emitIfStatement(node) { + var endPos = emitToken(88, node.pos); + write(" "); + endPos = emitToken(17, endPos); + emit(node.expression); + emitToken(18, node.expression.end); + emitEmbeddedStatement(node.thenStatement); + if (node.elseStatement) { + writeLine(); + emitToken(80, node.thenStatement.end); + if (node.elseStatement.kind === 196) { + write(" "); + emit(node.elseStatement); + } + else { + emitEmbeddedStatement(node.elseStatement); + } + } + } + function emitDoStatement(node) { + write("do"); + emitEmbeddedStatement(node.statement); + if (node.statement.kind === 192) { + write(" "); + } + else { + writeLine(); + } + write("while ("); + emit(node.expression); + write(");"); + } + function emitWhileStatement(node) { + write("while ("); + emit(node.expression); + write(")"); + emitEmbeddedStatement(node.statement); + } + function tryEmitStartOfVariableDeclarationList(decl, startPos) { + if (shouldHoistVariable(decl, true)) { + return false; + } + var tokenKind = 102; + if (decl && languageVersion >= 2) { + if (ts.isLet(decl)) { + tokenKind = 108; + } + else if (ts.isConst(decl)) { + tokenKind = 74; + } + } + if (startPos !== undefined) { + emitToken(tokenKind, startPos); + write(" "); + } + else { + switch (tokenKind) { + case 102: + write("var "); + break; + case 108: + write("let "); + break; + case 74: + write("const "); + break; + } + } + return true; + } + function emitVariableDeclarationListSkippingUninitializedEntries(list) { + var started = false; + for (var _a = 0, _b = list.declarations; _a < _b.length; _a++) { + var decl = _b[_a]; + if (!decl.initializer) { + continue; + } + if (!started) { + started = true; + } + else { + write(", "); + } + emit(decl); + } + return started; + } + function emitForStatement(node) { + var endPos = emitToken(86, node.pos); + write(" "); + endPos = emitToken(17, endPos); + if (node.initializer && node.initializer.kind === 212) { + var variableDeclarationList = node.initializer; + var startIsEmitted = tryEmitStartOfVariableDeclarationList(variableDeclarationList, endPos); + if (startIsEmitted) { + emitCommaList(variableDeclarationList.declarations); + } + else { + emitVariableDeclarationListSkippingUninitializedEntries(variableDeclarationList); + } + } + else if (node.initializer) { + emit(node.initializer); + } + write(";"); + emitOptional(" ", node.condition); + write(";"); + emitOptional(" ", node.incrementor); + write(")"); + emitEmbeddedStatement(node.statement); + } + function emitForInOrForOfStatement(node) { + if (languageVersion < 2 && node.kind === 201) { + return emitDownLevelForOfStatement(node); + } + var endPos = emitToken(86, node.pos); + write(" "); + endPos = emitToken(17, endPos); + if (node.initializer.kind === 212) { + var variableDeclarationList = node.initializer; + if (variableDeclarationList.declarations.length >= 1) { + tryEmitStartOfVariableDeclarationList(variableDeclarationList, endPos); + emit(variableDeclarationList.declarations[0]); + } + } + else { + emit(node.initializer); + } + if (node.kind === 200) { + write(" in "); + } + else { + write(" of "); + } + emit(node.expression); + emitToken(18, node.expression.end); + emitEmbeddedStatement(node.statement); + } + function emitDownLevelForOfStatement(node) { + var endPos = emitToken(86, node.pos); + write(" "); + endPos = emitToken(17, endPos); + var rhsIsIdentifier = node.expression.kind === 69; + var counter = createTempVariable(268435456); + var rhsReference = rhsIsIdentifier ? node.expression : createTempVariable(0); + emitStart(node.expression); + write("var "); + emitNodeWithoutSourceMap(counter); + write(" = 0"); + emitEnd(node.expression); + if (!rhsIsIdentifier) { + write(", "); + emitStart(node.expression); + emitNodeWithoutSourceMap(rhsReference); + write(" = "); + emitNodeWithoutSourceMap(node.expression); + emitEnd(node.expression); + } + write("; "); + emitStart(node.initializer); + emitNodeWithoutSourceMap(counter); + write(" < "); + emitNodeWithCommentsAndWithoutSourcemap(rhsReference); + write(".length"); + emitEnd(node.initializer); + write("; "); + emitStart(node.initializer); + emitNodeWithoutSourceMap(counter); + write("++"); + emitEnd(node.initializer); + emitToken(18, node.expression.end); + write(" {"); + writeLine(); + increaseIndent(); + var rhsIterationValue = createElementAccessExpression(rhsReference, counter); + emitStart(node.initializer); + if (node.initializer.kind === 212) { + write("var "); + var variableDeclarationList = node.initializer; + if (variableDeclarationList.declarations.length > 0) { + var declaration = variableDeclarationList.declarations[0]; + if (ts.isBindingPattern(declaration.name)) { + emitDestructuring(declaration, false, rhsIterationValue); + } + else { + emitNodeWithCommentsAndWithoutSourcemap(declaration); + write(" = "); + emitNodeWithoutSourceMap(rhsIterationValue); + } + } + else { + emitNodeWithoutSourceMap(createTempVariable(0)); + write(" = "); + emitNodeWithoutSourceMap(rhsIterationValue); + } + } + else { + var assignmentExpression = createBinaryExpression(node.initializer, 56, rhsIterationValue, false); + if (node.initializer.kind === 164 || node.initializer.kind === 165) { + emitDestructuring(assignmentExpression, true, undefined); + } + else { + emitNodeWithCommentsAndWithoutSourcemap(assignmentExpression); + } + } + emitEnd(node.initializer); + write(";"); + if (node.statement.kind === 192) { + emitLines(node.statement.statements); + } + else { + writeLine(); + emit(node.statement); + } + writeLine(); + decreaseIndent(); + write("}"); + } + function emitBreakOrContinueStatement(node) { + emitToken(node.kind === 203 ? 70 : 75, node.pos); + emitOptional(" ", node.label); + write(";"); + } + function emitReturnStatement(node) { + emitToken(94, node.pos); + emitOptional(" ", node.expression); + write(";"); + } + function emitWithStatement(node) { + write("with ("); + emit(node.expression); + write(")"); + emitEmbeddedStatement(node.statement); + } + function emitSwitchStatement(node) { + var endPos = emitToken(96, node.pos); + write(" "); + emitToken(17, endPos); + emit(node.expression); + endPos = emitToken(18, node.expression.end); + write(" "); + emitCaseBlock(node.caseBlock, endPos); + } + function emitCaseBlock(node, startPos) { + emitToken(15, startPos); + increaseIndent(); + emitLines(node.clauses); + decreaseIndent(); + writeLine(); + emitToken(16, node.clauses.end); + } + function nodeStartPositionsAreOnSameLine(node1, node2) { + return ts.getLineOfLocalPosition(currentSourceFile, ts.skipTrivia(currentSourceFile.text, node1.pos)) === + ts.getLineOfLocalPosition(currentSourceFile, ts.skipTrivia(currentSourceFile.text, node2.pos)); + } + function nodeEndPositionsAreOnSameLine(node1, node2) { + return ts.getLineOfLocalPosition(currentSourceFile, node1.end) === + ts.getLineOfLocalPosition(currentSourceFile, node2.end); + } + function nodeEndIsOnSameLineAsNodeStart(node1, node2) { + return ts.getLineOfLocalPosition(currentSourceFile, node1.end) === + ts.getLineOfLocalPosition(currentSourceFile, ts.skipTrivia(currentSourceFile.text, node2.pos)); + } + function emitCaseOrDefaultClause(node) { + if (node.kind === 241) { + write("case "); + emit(node.expression); + write(":"); + } + else { + write("default:"); + } + if (node.statements.length === 1 && nodeStartPositionsAreOnSameLine(node, node.statements[0])) { + write(" "); + emit(node.statements[0]); + } + else { + increaseIndent(); + emitLines(node.statements); + decreaseIndent(); + } + } + function emitThrowStatement(node) { + write("throw "); + emit(node.expression); + write(";"); + } + function emitTryStatement(node) { + write("try "); + emit(node.tryBlock); + emit(node.catchClause); + if (node.finallyBlock) { + writeLine(); + write("finally "); + emit(node.finallyBlock); + } + } + function emitCatchClause(node) { + writeLine(); + var endPos = emitToken(72, node.pos); + write(" "); + emitToken(17, endPos); + emit(node.variableDeclaration); + emitToken(18, node.variableDeclaration ? node.variableDeclaration.end : endPos); + write(" "); + emitBlock(node.block); + } + function emitDebuggerStatement(node) { + emitToken(76, node.pos); + write(";"); + } + function emitLabelledStatement(node) { + emit(node.label); + write(": "); + emit(node.statement); + } + function getContainingModule(node) { + do { + node = node.parent; + } while (node && node.kind !== 218); + return node; + } + function emitContainingModuleName(node) { + var container = getContainingModule(node); + write(container ? getGeneratedNameForNode(container) : "exports"); + } + function emitModuleMemberName(node) { + emitStart(node.name); + if (ts.getCombinedNodeFlags(node) & 1) { + var container = getContainingModule(node); + if (container) { + write(getGeneratedNameForNode(container)); + write("."); + } + else if (modulekind !== 5 && modulekind !== 4) { + write("exports."); + } + } + emitNodeWithCommentsAndWithoutSourcemap(node.name); + emitEnd(node.name); + } + function createVoidZero() { + var zero = ts.createSynthesizedNode(8); + zero.text = "0"; + var result = ts.createSynthesizedNode(177); + result.expression = zero; + return result; + } + function emitEs6ExportDefaultCompat(node) { + if (node.parent.kind === 248) { + ts.Debug.assert(!!(node.flags & 1024) || node.kind === 227); + if (modulekind === 1 || modulekind === 2 || modulekind === 3) { + if (!currentSourceFile.symbol.exports["___esModule"]) { + if (languageVersion === 1) { + write("Object.defineProperty(exports, \"__esModule\", { value: true });"); + writeLine(); + } + else if (languageVersion === 0) { + write("exports.__esModule = true;"); + writeLine(); + } + } + } + } + } + function emitExportMemberAssignment(node) { + if (node.flags & 1) { + writeLine(); + emitStart(node); + if (modulekind === 4 && node.parent === currentSourceFile) { + write(exportFunctionForFile + "(\""); + if (node.flags & 1024) { + write("default"); + } + else { + emitNodeWithCommentsAndWithoutSourcemap(node.name); + } + write("\", "); + emitDeclarationName(node); + write(")"); + } + else { + if (node.flags & 1024) { + emitEs6ExportDefaultCompat(node); + if (languageVersion === 0) { + write("exports[\"default\"]"); + } + else { + write("exports.default"); + } + } + else { + emitModuleMemberName(node); + } + write(" = "); + emitDeclarationName(node); + } + emitEnd(node); + write(";"); + } + } + function emitExportMemberAssignments(name) { + if (modulekind === 4) { + return; + } + if (!exportEquals && exportSpecifiers && ts.hasProperty(exportSpecifiers, name.text)) { + for (var _a = 0, _b = exportSpecifiers[name.text]; _a < _b.length; _a++) { + var specifier = _b[_a]; + writeLine(); + emitStart(specifier.name); + emitContainingModuleName(specifier); + write("."); + emitNodeWithCommentsAndWithoutSourcemap(specifier.name); + emitEnd(specifier.name); + write(" = "); + emitExpressionIdentifier(name); + write(";"); + } + } + } + function emitExportSpecifierInSystemModule(specifier) { + ts.Debug.assert(modulekind === 4); + if (!resolver.getReferencedValueDeclaration(specifier.propertyName || specifier.name) && !resolver.isValueAliasDeclaration(specifier)) { + return; + } + writeLine(); + emitStart(specifier.name); + write(exportFunctionForFile + "(\""); + emitNodeWithCommentsAndWithoutSourcemap(specifier.name); + write("\", "); + emitExpressionIdentifier(specifier.propertyName || specifier.name); + write(")"); + emitEnd(specifier.name); + write(";"); + } + function emitAssignment(name, value, shouldEmitCommaBeforeAssignment) { + if (shouldEmitCommaBeforeAssignment) { + write(", "); + } + var exportChanged = isNameOfExportedSourceLevelDeclarationInSystemExternalModule(name); + if (exportChanged) { + write(exportFunctionForFile + "(\""); + emitNodeWithCommentsAndWithoutSourcemap(name); + write("\", "); + } + var isVariableDeclarationOrBindingElement = name.parent && (name.parent.kind === 211 || name.parent.kind === 163); + if (isVariableDeclarationOrBindingElement) { + emitModuleMemberName(name.parent); + } + else { + emit(name); + } + write(" = "); + emit(value); + if (exportChanged) { + write(")"); + } + } + function emitTempVariableAssignment(expression, canDefineTempVariablesInPlace, shouldEmitCommaBeforeAssignment) { + var identifier = createTempVariable(0); + if (!canDefineTempVariablesInPlace) { + recordTempDeclaration(identifier); + } + emitAssignment(identifier, expression, shouldEmitCommaBeforeAssignment); + return identifier; + } + function emitDestructuring(root, isAssignmentExpressionStatement, value) { + var emitCount = 0; + var canDefineTempVariablesInPlace = false; + if (root.kind === 211) { + var isExported = ts.getCombinedNodeFlags(root) & 1; + var isSourceLevelForSystemModuleKind = shouldHoistDeclarationInSystemJsModule(root); + canDefineTempVariablesInPlace = !isExported && !isSourceLevelForSystemModuleKind; + } + else if (root.kind === 138) { + canDefineTempVariablesInPlace = true; + } + if (root.kind === 181) { + emitAssignmentExpression(root); + } + else { + ts.Debug.assert(!isAssignmentExpressionStatement); + emitBindingElement(root, value); + } + function ensureIdentifier(expr, reuseIdentifierExpressions) { + if (expr.kind === 69 && reuseIdentifierExpressions) { + return expr; + } + var identifier = emitTempVariableAssignment(expr, canDefineTempVariablesInPlace, emitCount > 0); + emitCount++; + return identifier; + } + function createDefaultValueCheck(value, defaultValue) { + value = ensureIdentifier(value, true); + var equals = ts.createSynthesizedNode(181); + equals.left = value; + equals.operatorToken = ts.createSynthesizedNode(32); + equals.right = createVoidZero(); + return createConditionalExpression(equals, defaultValue, value); + } + function createConditionalExpression(condition, whenTrue, whenFalse) { + var cond = ts.createSynthesizedNode(182); + cond.condition = condition; + cond.questionToken = ts.createSynthesizedNode(53); + cond.whenTrue = whenTrue; + cond.colonToken = ts.createSynthesizedNode(54); + cond.whenFalse = whenFalse; + return cond; + } + function createNumericLiteral(value) { + var node = ts.createSynthesizedNode(8); + node.text = "" + value; + return node; + } + function createPropertyAccessForDestructuringProperty(object, propName) { + var syntheticName = ts.createSynthesizedNode(propName.kind); + syntheticName.text = propName.text; + if (syntheticName.kind !== 69) { + return createElementAccessExpression(object, syntheticName); + } + return createPropertyAccessExpression(object, syntheticName); + } + function createSliceCall(value, sliceIndex) { + var call = ts.createSynthesizedNode(168); + var sliceIdentifier = ts.createSynthesizedNode(69); + sliceIdentifier.text = "slice"; + call.expression = createPropertyAccessExpression(value, sliceIdentifier); + call.arguments = ts.createSynthesizedNodeArray(); + call.arguments[0] = createNumericLiteral(sliceIndex); + return call; + } + function emitObjectLiteralAssignment(target, value) { + var properties = target.properties; + if (properties.length !== 1) { + value = ensureIdentifier(value, true); + } + for (var _a = 0; _a < properties.length; _a++) { + var p = properties[_a]; + if (p.kind === 245 || p.kind === 246) { + var propName = p.name; + var target_1 = p.kind === 246 ? p : p.initializer || propName; + emitDestructuringAssignment(target_1, createPropertyAccessForDestructuringProperty(value, propName)); + } + } + } + function emitArrayLiteralAssignment(target, value) { + var elements = target.elements; + if (elements.length !== 1) { + value = ensureIdentifier(value, true); + } + for (var i = 0; i < elements.length; i++) { + var e = elements[i]; + if (e.kind !== 187) { + if (e.kind !== 185) { + emitDestructuringAssignment(e, createElementAccessExpression(value, createNumericLiteral(i))); + } + else if (i === elements.length - 1) { + emitDestructuringAssignment(e.expression, createSliceCall(value, i)); + } + } + } + } + function emitDestructuringAssignment(target, value) { + if (target.kind === 246) { + if (target.objectAssignmentInitializer) { + value = createDefaultValueCheck(value, target.objectAssignmentInitializer); + } + target = target.name; + } + else if (target.kind === 181 && target.operatorToken.kind === 56) { + value = createDefaultValueCheck(value, target.right); + target = target.left; + } + if (target.kind === 165) { + emitObjectLiteralAssignment(target, value); + } + else if (target.kind === 164) { + emitArrayLiteralAssignment(target, value); + } + else { + emitAssignment(target, value, emitCount > 0); + emitCount++; + } + } + function emitAssignmentExpression(root) { + var target = root.left; + var value = root.right; + if (ts.isEmptyObjectLiteralOrArrayLiteral(target)) { + emit(value); + } + else if (isAssignmentExpressionStatement) { + emitDestructuringAssignment(target, value); + } + else { + if (root.parent.kind !== 172) { + write("("); + } + value = ensureIdentifier(value, true); + emitDestructuringAssignment(target, value); + write(", "); + emit(value); + if (root.parent.kind !== 172) { + write(")"); + } + } + } + function emitBindingElement(target, value) { + if (target.initializer) { + value = value ? createDefaultValueCheck(value, target.initializer) : target.initializer; + } + else if (!value) { + value = createVoidZero(); + } + if (ts.isBindingPattern(target.name)) { + var pattern = target.name; + var elements = pattern.elements; + var numElements = elements.length; + if (numElements !== 1) { + value = ensureIdentifier(value, numElements !== 0); + } + for (var i = 0; i < numElements; i++) { + var element = elements[i]; + if (pattern.kind === 161) { + var propName = element.propertyName || element.name; + emitBindingElement(element, createPropertyAccessForDestructuringProperty(value, propName)); + } + else if (element.kind !== 187) { + if (!element.dotDotDotToken) { + emitBindingElement(element, createElementAccessExpression(value, createNumericLiteral(i))); + } + else if (i === numElements - 1) { + emitBindingElement(element, createSliceCall(value, i)); + } + } + } + } + else { + emitAssignment(target.name, value, emitCount > 0); + emitCount++; + } + } + } + function emitVariableDeclaration(node) { + if (ts.isBindingPattern(node.name)) { + if (languageVersion < 2) { + emitDestructuring(node, false); + } + else { + emit(node.name); + emitOptional(" = ", node.initializer); + } + } + else { + var initializer = node.initializer; + if (!initializer && languageVersion < 2) { + var isUninitializedLet = (resolver.getNodeCheckFlags(node) & 16384) && + (getCombinedFlagsForIdentifier(node.name) & 16384); + if (isUninitializedLet && + node.parent.parent.kind !== 200 && + node.parent.parent.kind !== 201) { + initializer = createVoidZero(); + } + } + var exportChanged = isNameOfExportedSourceLevelDeclarationInSystemExternalModule(node.name); + if (exportChanged) { + write(exportFunctionForFile + "(\""); + emitNodeWithCommentsAndWithoutSourcemap(node.name); + write("\", "); + } + emitModuleMemberName(node); + emitOptional(" = ", initializer); + if (exportChanged) { + write(")"); + } + } + } + function emitExportVariableAssignments(node) { + if (node.kind === 187) { + return; + } + var name = node.name; + if (name.kind === 69) { + emitExportMemberAssignments(name); + } + else if (ts.isBindingPattern(name)) { + ts.forEach(name.elements, emitExportVariableAssignments); + } + } + function getCombinedFlagsForIdentifier(node) { + if (!node.parent || (node.parent.kind !== 211 && node.parent.kind !== 163)) { + return 0; + } + return ts.getCombinedNodeFlags(node.parent); + } + function isES6ExportedDeclaration(node) { + return !!(node.flags & 1) && + modulekind === 5 && + node.parent.kind === 248; + } + function emitVariableStatement(node) { + var startIsEmitted = false; + if (node.flags & 1) { + if (isES6ExportedDeclaration(node)) { + write("export "); + startIsEmitted = tryEmitStartOfVariableDeclarationList(node.declarationList); + } + } + else { + startIsEmitted = tryEmitStartOfVariableDeclarationList(node.declarationList); + } + if (startIsEmitted) { + emitCommaList(node.declarationList.declarations); + write(";"); + } + else { + var atLeastOneItem = emitVariableDeclarationListSkippingUninitializedEntries(node.declarationList); + if (atLeastOneItem) { + write(";"); + } + } + if (modulekind !== 5 && node.parent === currentSourceFile) { + ts.forEach(node.declarationList.declarations, emitExportVariableAssignments); + } + } + function shouldEmitLeadingAndTrailingCommentsForVariableStatement(node) { + if (!(node.flags & 1)) { + return true; + } + if (isES6ExportedDeclaration(node)) { + return true; + } + for (var _a = 0, _b = node.declarationList.declarations; _a < _b.length; _a++) { + var declaration = _b[_a]; + if (declaration.initializer) { + return true; + } + } + return false; + } + function emitParameter(node) { + if (languageVersion < 2) { + if (ts.isBindingPattern(node.name)) { + var name_25 = createTempVariable(0); + if (!tempParameters) { + tempParameters = []; + } + tempParameters.push(name_25); + emit(name_25); + } + else { + emit(node.name); + } + } + else { + if (node.dotDotDotToken) { + write("..."); + } + emit(node.name); + emitOptional(" = ", node.initializer); + } + } + function emitDefaultValueAssignments(node) { + if (languageVersion < 2) { + var tempIndex = 0; + ts.forEach(node.parameters, function (parameter) { + if (parameter.dotDotDotToken) { + return; + } + var paramName = parameter.name, initializer = parameter.initializer; + if (ts.isBindingPattern(paramName)) { + var hasBindingElements = paramName.elements.length > 0; + if (hasBindingElements || initializer) { + writeLine(); + write("var "); + if (hasBindingElements) { + emitDestructuring(parameter, false, tempParameters[tempIndex]); + } + else { + emit(tempParameters[tempIndex]); + write(" = "); + emit(initializer); + } + write(";"); + tempIndex++; + } + } + else if (initializer) { + writeLine(); + emitStart(parameter); + write("if ("); + emitNodeWithoutSourceMap(paramName); + write(" === void 0)"); + emitEnd(parameter); + write(" { "); + emitStart(parameter); + emitNodeWithCommentsAndWithoutSourcemap(paramName); + write(" = "); + emitNodeWithCommentsAndWithoutSourcemap(initializer); + emitEnd(parameter); + write("; }"); + } + }); + } + } + function emitRestParameter(node) { + if (languageVersion < 2 && ts.hasRestParameter(node)) { + var restIndex = node.parameters.length - 1; + var restParam = node.parameters[restIndex]; + if (ts.isBindingPattern(restParam.name)) { + return; + } + var tempName = createTempVariable(268435456).text; + writeLine(); + emitLeadingComments(restParam); + emitStart(restParam); + write("var "); + emitNodeWithCommentsAndWithoutSourcemap(restParam.name); + write(" = [];"); + emitEnd(restParam); + emitTrailingComments(restParam); + writeLine(); + write("for ("); + emitStart(restParam); + write("var " + tempName + " = " + restIndex + ";"); + emitEnd(restParam); + write(" "); + emitStart(restParam); + write(tempName + " < arguments.length;"); + emitEnd(restParam); + write(" "); + emitStart(restParam); + write(tempName + "++"); + emitEnd(restParam); + write(") {"); + increaseIndent(); + writeLine(); + emitStart(restParam); + emitNodeWithCommentsAndWithoutSourcemap(restParam.name); + write("[" + tempName + " - " + restIndex + "] = arguments[" + tempName + "];"); + emitEnd(restParam); + decreaseIndent(); + writeLine(); + write("}"); + } + } + function emitAccessor(node) { + write(node.kind === 145 ? "get " : "set "); + emit(node.name); + emitSignatureAndBody(node); + } + function shouldEmitAsArrowFunction(node) { + return node.kind === 174 && languageVersion >= 2; + } + function emitDeclarationName(node) { + if (node.name) { + emitNodeWithCommentsAndWithoutSourcemap(node.name); + } + else { + write(getGeneratedNameForNode(node)); + } + } + function shouldEmitFunctionName(node) { + if (node.kind === 173) { + return !!node.name; + } + if (node.kind === 213) { + return !!node.name || languageVersion < 2; + } + } + function emitFunctionDeclaration(node) { + if (ts.nodeIsMissing(node.body)) { + return emitCommentsOnNotEmittedNode(node); + } + if (node.kind !== 143 && node.kind !== 142 && + node.parent && node.parent.kind !== 245 && + node.parent.kind !== 168) { + emitLeadingComments(node); + } + emitStart(node); + if (!shouldEmitAsArrowFunction(node)) { + if (isES6ExportedDeclaration(node)) { + write("export "); + if (node.flags & 1024) { + write("default "); + } + } + write("function"); + if (languageVersion >= 2 && node.asteriskToken) { + write("*"); + } + write(" "); + } + if (shouldEmitFunctionName(node)) { + emitDeclarationName(node); + } + emitSignatureAndBody(node); + if (modulekind !== 5 && node.kind === 213 && node.parent === currentSourceFile && node.name) { + emitExportMemberAssignments(node.name); + } + emitEnd(node); + if (node.kind !== 143 && node.kind !== 142) { + emitTrailingComments(node); + } + } + function emitCaptureThisForNodeIfNecessary(node) { + if (resolver.getNodeCheckFlags(node) & 4) { + writeLine(); + emitStart(node); + write("var _this = this;"); + emitEnd(node); + } + } + function emitSignatureParameters(node) { + increaseIndent(); + write("("); + if (node) { + var parameters = node.parameters; + var omitCount = languageVersion < 2 && ts.hasRestParameter(node) ? 1 : 0; + emitList(parameters, 0, parameters.length - omitCount, false, false); + } + write(")"); + decreaseIndent(); + } + function emitSignatureParametersForArrow(node) { + if (node.parameters.length === 1 && node.pos === node.parameters[0].pos) { + emit(node.parameters[0]); + return; + } + emitSignatureParameters(node); + } + function emitAsyncFunctionBodyForES6(node) { + var promiseConstructor = ts.getEntityNameFromTypeNode(node.type); + var isArrowFunction = node.kind === 174; + var hasLexicalArguments = (resolver.getNodeCheckFlags(node) & 4096) !== 0; + var args; + if (!isArrowFunction) { + write(" {"); + increaseIndent(); + writeLine(); + write("return"); + } + write(" __awaiter(this"); + if (hasLexicalArguments) { + write(", arguments"); + } + else { + write(", void 0"); + } + if (promiseConstructor) { + write(", "); + emitNodeWithoutSourceMap(promiseConstructor); + } + else { + write(", Promise"); + } + if (hasLexicalArguments) { + write(", function* (_arguments)"); + } + else { + write(", function* ()"); + } + emitFunctionBody(node); + write(")"); + if (!isArrowFunction) { + write(";"); + decreaseIndent(); + writeLine(); + write("}"); + } + } + function emitFunctionBody(node) { + if (!node.body) { + write(" { }"); + } + else { + if (node.body.kind === 192) { + emitBlockFunctionBody(node, node.body); + } + else { + emitExpressionFunctionBody(node, node.body); + } + } + } + function emitSignatureAndBody(node) { + var saveTempFlags = tempFlags; + var saveTempVariables = tempVariables; + var saveTempParameters = tempParameters; + tempFlags = 0; + tempVariables = undefined; + tempParameters = undefined; + if (shouldEmitAsArrowFunction(node)) { + emitSignatureParametersForArrow(node); + write(" =>"); + } + else { + emitSignatureParameters(node); + } + var isAsync = ts.isAsyncFunctionLike(node); + if (isAsync && languageVersion === 2) { + emitAsyncFunctionBodyForES6(node); + } + else { + emitFunctionBody(node); + } + if (!isES6ExportedDeclaration(node)) { + emitExportMemberAssignment(node); + } + tempFlags = saveTempFlags; + tempVariables = saveTempVariables; + tempParameters = saveTempParameters; + } + function emitFunctionBodyPreamble(node) { + emitCaptureThisForNodeIfNecessary(node); + emitDefaultValueAssignments(node); + emitRestParameter(node); + } + function emitExpressionFunctionBody(node, body) { + if (languageVersion < 2 || node.flags & 512) { + emitDownLevelExpressionFunctionBody(node, body); + return; + } + write(" "); + var current = body; + while (current.kind === 171) { + current = current.expression; + } + emitParenthesizedIf(body, current.kind === 165); + } + function emitDownLevelExpressionFunctionBody(node, body) { + write(" {"); + scopeEmitStart(node); + increaseIndent(); + var outPos = writer.getTextPos(); + emitDetachedComments(node.body); + emitFunctionBodyPreamble(node); + var preambleEmitted = writer.getTextPos() !== outPos; + decreaseIndent(); + if (!preambleEmitted && nodeStartPositionsAreOnSameLine(node, body)) { + write(" "); + emitStart(body); + write("return "); + emit(body); + emitEnd(body); + write(";"); + emitTempDeclarations(false); + write(" "); + } + else { + increaseIndent(); + writeLine(); + emitLeadingComments(node.body); + write("return "); + emit(body); + write(";"); + emitTrailingComments(node.body); + emitTempDeclarations(true); + decreaseIndent(); + writeLine(); + } + emitStart(node.body); + write("}"); + emitEnd(node.body); + scopeEmitEnd(); + } + function emitBlockFunctionBody(node, body) { + write(" {"); + scopeEmitStart(node); + var initialTextPos = writer.getTextPos(); + increaseIndent(); + emitDetachedComments(body.statements); + var startIndex = emitDirectivePrologues(body.statements, true); + emitFunctionBodyPreamble(node); + decreaseIndent(); + var preambleEmitted = writer.getTextPos() !== initialTextPos; + if (!preambleEmitted && nodeEndIsOnSameLineAsNodeStart(body, body)) { + for (var _a = 0, _b = body.statements; _a < _b.length; _a++) { + var statement = _b[_a]; + write(" "); + emit(statement); + } + emitTempDeclarations(false); + write(" "); + emitLeadingCommentsOfPosition(body.statements.end); + } + else { + increaseIndent(); + emitLinesStartingAt(body.statements, startIndex); + emitTempDeclarations(true); + writeLine(); + emitLeadingCommentsOfPosition(body.statements.end); + decreaseIndent(); + } + emitToken(16, body.statements.end); + scopeEmitEnd(); + } + function findInitialSuperCall(ctor) { + if (ctor.body) { + var statement = ctor.body.statements[0]; + if (statement && statement.kind === 195) { + var expr = statement.expression; + if (expr && expr.kind === 168) { + var func = expr.expression; + if (func && func.kind === 95) { + return statement; + } + } + } + } + } + function emitParameterPropertyAssignments(node) { + ts.forEach(node.parameters, function (param) { + if (param.flags & 112) { + writeLine(); + emitStart(param); + emitStart(param.name); + write("this."); + emitNodeWithoutSourceMap(param.name); + emitEnd(param.name); + write(" = "); + emit(param.name); + write(";"); + emitEnd(param); + } + }); + } + function emitMemberAccessForPropertyName(memberName) { + if (memberName.kind === 9 || memberName.kind === 8) { + write("["); + emitNodeWithCommentsAndWithoutSourcemap(memberName); + write("]"); + } + else if (memberName.kind === 136) { + emitComputedPropertyName(memberName); + } + else { + write("."); + emitNodeWithCommentsAndWithoutSourcemap(memberName); + } + } + function getInitializedProperties(node, isStatic) { + var properties = []; + for (var _a = 0, _b = node.members; _a < _b.length; _a++) { + var member = _b[_a]; + if (member.kind === 141 && isStatic === ((member.flags & 128) !== 0) && member.initializer) { + properties.push(member); + } + } + return properties; + } + function emitPropertyDeclarations(node, properties) { + for (var _a = 0; _a < properties.length; _a++) { + var property = properties[_a]; + emitPropertyDeclaration(node, property); + } + } + function emitPropertyDeclaration(node, property, receiver, isExpression) { + writeLine(); + emitLeadingComments(property); + emitStart(property); + emitStart(property.name); + if (receiver) { + emit(receiver); + } + else { + if (property.flags & 128) { + emitDeclarationName(node); + } + else { + write("this"); + } + } + emitMemberAccessForPropertyName(property.name); + emitEnd(property.name); + write(" = "); + emit(property.initializer); + if (!isExpression) { + write(";"); + } + emitEnd(property); + emitTrailingComments(property); + } + function emitMemberFunctionsForES5AndLower(node) { + ts.forEach(node.members, function (member) { + if (member.kind === 191) { + writeLine(); + write(";"); + } + else if (member.kind === 143 || node.kind === 142) { + if (!member.body) { + return emitCommentsOnNotEmittedNode(member); + } + writeLine(); + emitLeadingComments(member); + emitStart(member); + emitStart(member.name); + emitClassMemberPrefix(node, member); + emitMemberAccessForPropertyName(member.name); + emitEnd(member.name); + write(" = "); + emitFunctionDeclaration(member); + emitEnd(member); + write(";"); + emitTrailingComments(member); + } + else if (member.kind === 145 || member.kind === 146) { + var accessors = ts.getAllAccessorDeclarations(node.members, member); + if (member === accessors.firstAccessor) { + writeLine(); + emitStart(member); + write("Object.defineProperty("); + emitStart(member.name); + emitClassMemberPrefix(node, member); + write(", "); + emitExpressionForPropertyName(member.name); + emitEnd(member.name); + write(", {"); + increaseIndent(); + if (accessors.getAccessor) { + writeLine(); + emitLeadingComments(accessors.getAccessor); + write("get: "); + emitStart(accessors.getAccessor); + write("function "); + emitSignatureAndBody(accessors.getAccessor); + emitEnd(accessors.getAccessor); + emitTrailingComments(accessors.getAccessor); + write(","); + } + if (accessors.setAccessor) { + writeLine(); + emitLeadingComments(accessors.setAccessor); + write("set: "); + emitStart(accessors.setAccessor); + write("function "); + emitSignatureAndBody(accessors.setAccessor); + emitEnd(accessors.setAccessor); + emitTrailingComments(accessors.setAccessor); + write(","); + } + writeLine(); + write("enumerable: true,"); + writeLine(); + write("configurable: true"); + decreaseIndent(); + writeLine(); + write("});"); + emitEnd(member); + } + } + }); + } + function emitMemberFunctionsForES6AndHigher(node) { + for (var _a = 0, _b = node.members; _a < _b.length; _a++) { + var member = _b[_a]; + if ((member.kind === 143 || node.kind === 142) && !member.body) { + emitCommentsOnNotEmittedNode(member); + } + else if (member.kind === 143 || + member.kind === 145 || + member.kind === 146) { + writeLine(); + emitLeadingComments(member); + emitStart(member); + if (member.flags & 128) { + write("static "); + } + if (member.kind === 145) { + write("get "); + } + else if (member.kind === 146) { + write("set "); + } + if (member.asteriskToken) { + write("*"); + } + emit(member.name); + emitSignatureAndBody(member); + emitEnd(member); + emitTrailingComments(member); + } + else if (member.kind === 191) { + writeLine(); + write(";"); + } + } + } + function emitConstructor(node, baseTypeElement) { + var saveTempFlags = tempFlags; + var saveTempVariables = tempVariables; + var saveTempParameters = tempParameters; + tempFlags = 0; + tempVariables = undefined; + tempParameters = undefined; + emitConstructorWorker(node, baseTypeElement); + tempFlags = saveTempFlags; + tempVariables = saveTempVariables; + tempParameters = saveTempParameters; + } + function emitConstructorWorker(node, baseTypeElement) { + var hasInstancePropertyWithInitializer = false; + ts.forEach(node.members, function (member) { + if (member.kind === 144 && !member.body) { + emitCommentsOnNotEmittedNode(member); + } + if (member.kind === 141 && member.initializer && (member.flags & 128) === 0) { + hasInstancePropertyWithInitializer = true; + } + }); + var ctor = ts.getFirstConstructorWithBody(node); + if (languageVersion >= 2 && !ctor && !hasInstancePropertyWithInitializer) { + return; + } + if (ctor) { + emitLeadingComments(ctor); + } + emitStart(ctor || node); + if (languageVersion < 2) { + write("function "); + emitDeclarationName(node); + emitSignatureParameters(ctor); + } + else { + write("constructor"); + if (ctor) { + emitSignatureParameters(ctor); + } + else { + if (baseTypeElement) { + write("(...args)"); + } + else { + write("()"); + } + } + } + var startIndex = 0; + write(" {"); + scopeEmitStart(node, "constructor"); + increaseIndent(); + if (ctor) { + startIndex = emitDirectivePrologues(ctor.body.statements, true); + emitDetachedComments(ctor.body.statements); + } + emitCaptureThisForNodeIfNecessary(node); + var superCall; + if (ctor) { + emitDefaultValueAssignments(ctor); + emitRestParameter(ctor); + if (baseTypeElement) { + superCall = findInitialSuperCall(ctor); + if (superCall) { + writeLine(); + emit(superCall); + } + } + emitParameterPropertyAssignments(ctor); + } + else { + if (baseTypeElement) { + writeLine(); + emitStart(baseTypeElement); + if (languageVersion < 2) { + write("_super.apply(this, arguments);"); + } + else { + write("super(...args);"); + } + emitEnd(baseTypeElement); + } + } + emitPropertyDeclarations(node, getInitializedProperties(node, false)); + if (ctor) { + var statements = ctor.body.statements; + if (superCall) { + statements = statements.slice(1); + } + emitLinesStartingAt(statements, startIndex); + } + emitTempDeclarations(true); + writeLine(); + if (ctor) { + emitLeadingCommentsOfPosition(ctor.body.statements.end); + } + decreaseIndent(); + emitToken(16, ctor ? ctor.body.statements.end : node.members.end); + scopeEmitEnd(); + emitEnd(ctor || node); + if (ctor) { + emitTrailingComments(ctor); + } + } + function emitClassExpression(node) { + return emitClassLikeDeclaration(node); + } + function emitClassDeclaration(node) { + return emitClassLikeDeclaration(node); + } + function emitClassLikeDeclaration(node) { + if (languageVersion < 2) { + emitClassLikeDeclarationBelowES6(node); + } + else { + emitClassLikeDeclarationForES6AndHigher(node); + } + if (modulekind !== 5 && node.parent === currentSourceFile && node.name) { + emitExportMemberAssignments(node.name); + } + } + function emitClassLikeDeclarationForES6AndHigher(node) { + var thisNodeIsDecorated = ts.nodeIsDecorated(node); + if (node.kind === 214) { + if (thisNodeIsDecorated) { + if (isES6ExportedDeclaration(node) && !(node.flags & 1024)) { + write("export "); + } + write("let "); + emitDeclarationName(node); + write(" = "); + } + else if (isES6ExportedDeclaration(node)) { + write("export "); + if (node.flags & 1024) { + write("default "); + } + } + } + var staticProperties = getInitializedProperties(node, true); + var isClassExpressionWithStaticProperties = staticProperties.length > 0 && node.kind === 186; + var tempVariable; + if (isClassExpressionWithStaticProperties) { + tempVariable = createAndRecordTempVariable(0); + write("("); + increaseIndent(); + emit(tempVariable); + write(" = "); + } + write("class"); + if ((node.name || (node.flags & 1024 && staticProperties.length > 0)) && !thisNodeIsDecorated) { + write(" "); + emitDeclarationName(node); + } + var baseTypeNode = ts.getClassExtendsHeritageClauseElement(node); + if (baseTypeNode) { + write(" extends "); + emit(baseTypeNode.expression); + } + write(" {"); + increaseIndent(); + scopeEmitStart(node); + writeLine(); + emitConstructor(node, baseTypeNode); + emitMemberFunctionsForES6AndHigher(node); + decreaseIndent(); + writeLine(); + emitToken(16, node.members.end); + scopeEmitEnd(); + if (thisNodeIsDecorated) { + write(";"); + } + if (isClassExpressionWithStaticProperties) { + for (var _a = 0; _a < staticProperties.length; _a++) { + var property = staticProperties[_a]; + write(","); + writeLine(); + emitPropertyDeclaration(node, property, tempVariable, true); + } + write(","); + writeLine(); + emit(tempVariable); + decreaseIndent(); + write(")"); + } + else { + writeLine(); + emitPropertyDeclarations(node, staticProperties); + emitDecoratorsOfClass(node); + } + if (!isES6ExportedDeclaration(node) && (node.flags & 1)) { + writeLine(); + emitStart(node); + emitModuleMemberName(node); + write(" = "); + emitDeclarationName(node); + emitEnd(node); + write(";"); + } + else if (isES6ExportedDeclaration(node) && (node.flags & 1024) && thisNodeIsDecorated) { + writeLine(); + write("export default "); + emitDeclarationName(node); + write(";"); + } + } + function emitClassLikeDeclarationBelowES6(node) { + if (node.kind === 214) { + if (!shouldHoistDeclarationInSystemJsModule(node)) { + write("var "); + } + emitDeclarationName(node); + write(" = "); + } + write("(function ("); + var baseTypeNode = ts.getClassExtendsHeritageClauseElement(node); + if (baseTypeNode) { + write("_super"); + } + write(") {"); + var saveTempFlags = tempFlags; + var saveTempVariables = tempVariables; + var saveTempParameters = tempParameters; + var saveComputedPropertyNamesToGeneratedNames = computedPropertyNamesToGeneratedNames; + tempFlags = 0; + tempVariables = undefined; + tempParameters = undefined; + computedPropertyNamesToGeneratedNames = undefined; + increaseIndent(); + scopeEmitStart(node); + if (baseTypeNode) { + writeLine(); + emitStart(baseTypeNode); + write("__extends("); + emitDeclarationName(node); + write(", _super);"); + emitEnd(baseTypeNode); + } + writeLine(); + emitConstructor(node, baseTypeNode); + emitMemberFunctionsForES5AndLower(node); + emitPropertyDeclarations(node, getInitializedProperties(node, true)); + writeLine(); + emitDecoratorsOfClass(node); + writeLine(); + emitToken(16, node.members.end, function () { + write("return "); + emitDeclarationName(node); + }); + write(";"); + emitTempDeclarations(true); + tempFlags = saveTempFlags; + tempVariables = saveTempVariables; + tempParameters = saveTempParameters; + computedPropertyNamesToGeneratedNames = saveComputedPropertyNamesToGeneratedNames; + decreaseIndent(); + writeLine(); + emitToken(16, node.members.end); + scopeEmitEnd(); + emitStart(node); + write(")("); + if (baseTypeNode) { + emit(baseTypeNode.expression); + } + write(")"); + if (node.kind === 214) { + write(";"); + } + emitEnd(node); + if (node.kind === 214) { + emitExportMemberAssignment(node); + } + } + function emitClassMemberPrefix(node, member) { + emitDeclarationName(node); + if (!(member.flags & 128)) { + write(".prototype"); + } + } + function emitDecoratorsOfClass(node) { + emitDecoratorsOfMembers(node, 0); + emitDecoratorsOfMembers(node, 128); + emitDecoratorsOfConstructor(node); + } + function emitDecoratorsOfConstructor(node) { + var decorators = node.decorators; + var constructor = ts.getFirstConstructorWithBody(node); + var hasDecoratedParameters = constructor && ts.forEach(constructor.parameters, ts.nodeIsDecorated); + if (!decorators && !hasDecoratedParameters) { + return; + } + writeLine(); + emitStart(node); + emitDeclarationName(node); + write(" = __decorate(["); + increaseIndent(); + writeLine(); + var decoratorCount = decorators ? decorators.length : 0; + var argumentsWritten = emitList(decorators, 0, decoratorCount, true, false, false, true, function (decorator) { + emitStart(decorator); + emit(decorator.expression); + emitEnd(decorator); + }); + argumentsWritten += emitDecoratorsOfParameters(constructor, argumentsWritten > 0); + emitSerializedTypeMetadata(node, argumentsWritten >= 0); + decreaseIndent(); + writeLine(); + write("], "); + emitDeclarationName(node); + write(");"); + emitEnd(node); + writeLine(); + } + function emitDecoratorsOfMembers(node, staticFlag) { + for (var _a = 0, _b = node.members; _a < _b.length; _a++) { + var member = _b[_a]; + if ((member.flags & 128) !== staticFlag) { + continue; + } + if (!ts.nodeCanBeDecorated(member)) { + continue; + } + if (!ts.nodeOrChildIsDecorated(member)) { + continue; + } + var decorators = void 0; + var functionLikeMember = void 0; + if (ts.isAccessor(member)) { + var accessors = ts.getAllAccessorDeclarations(node.members, member); + if (member !== accessors.firstAccessor) { + continue; + } + decorators = accessors.firstAccessor.decorators; + if (!decorators && accessors.secondAccessor) { + decorators = accessors.secondAccessor.decorators; + } + functionLikeMember = accessors.setAccessor; + } + else { + decorators = member.decorators; + if (member.kind === 143) { + functionLikeMember = member; + } + } + writeLine(); + emitStart(member); + write("__decorate(["); + increaseIndent(); + writeLine(); + var decoratorCount = decorators ? decorators.length : 0; + var argumentsWritten = emitList(decorators, 0, decoratorCount, true, false, false, true, function (decorator) { + emitStart(decorator); + emit(decorator.expression); + emitEnd(decorator); + }); + argumentsWritten += emitDecoratorsOfParameters(functionLikeMember, argumentsWritten > 0); + emitSerializedTypeMetadata(member, argumentsWritten > 0); + decreaseIndent(); + writeLine(); + write("], "); + emitStart(member.name); + emitClassMemberPrefix(node, member); + write(", "); + emitExpressionForPropertyName(member.name); + emitEnd(member.name); + if (languageVersion > 0) { + if (member.kind !== 141) { + write(", null"); + } + else { + write(", void 0"); + } + } + write(");"); + emitEnd(member); + writeLine(); + } + } + function emitDecoratorsOfParameters(node, leadingComma) { + var argumentsWritten = 0; + if (node) { + var parameterIndex = 0; + for (var _a = 0, _b = node.parameters; _a < _b.length; _a++) { + var parameter = _b[_a]; + if (ts.nodeIsDecorated(parameter)) { + var decorators = parameter.decorators; + argumentsWritten += emitList(decorators, 0, decorators.length, true, false, leadingComma, true, function (decorator) { + emitStart(decorator); + write("__param(" + parameterIndex + ", "); + emit(decorator.expression); + write(")"); + emitEnd(decorator); + }); + leadingComma = true; + } + ++parameterIndex; + } + } + return argumentsWritten; + } + function shouldEmitTypeMetadata(node) { + switch (node.kind) { + case 143: + case 145: + case 146: + case 141: + return true; + } + return false; + } + function shouldEmitReturnTypeMetadata(node) { + switch (node.kind) { + case 143: + return true; + } + return false; + } + function shouldEmitParamTypesMetadata(node) { + switch (node.kind) { + case 214: + case 143: + case 146: + return true; + } + return false; + } + function emitSerializedTypeOfNode(node) { + switch (node.kind) { + case 214: + write("Function"); + return; + case 141: + emitSerializedTypeNode(node.type); + return; + case 138: + emitSerializedTypeNode(node.type); + return; + case 145: + emitSerializedTypeNode(node.type); + return; + case 146: + emitSerializedTypeNode(ts.getSetAccessorTypeAnnotationNode(node)); + return; + } + if (ts.isFunctionLike(node)) { + write("Function"); + return; + } + write("void 0"); + } + function emitSerializedTypeNode(node) { + if (node) { + switch (node.kind) { + case 103: + write("void 0"); + return; + case 160: + emitSerializedTypeNode(node.type); + return; + case 152: + case 153: + write("Function"); + return; + case 156: + case 157: + write("Array"); + return; + case 150: + case 120: + write("Boolean"); + return; + case 130: + case 9: + write("String"); + return; + case 128: + write("Number"); + return; + case 131: + write("Symbol"); + return; + case 151: + emitSerializedTypeReferenceNode(node); + return; + case 154: + case 155: + case 158: + case 159: + case 117: + break; + default: + ts.Debug.fail("Cannot serialize unexpected type node."); + break; + } + } + write("Object"); + } + function emitSerializedTypeReferenceNode(node) { + var location = node.parent; + while (ts.isDeclaration(location) || ts.isTypeNode(location)) { + location = location.parent; + } + var typeName = ts.cloneEntityName(node.typeName); + typeName.parent = location; + var result = resolver.getTypeReferenceSerializationKind(typeName); + switch (result) { + case ts.TypeReferenceSerializationKind.Unknown: + var temp = createAndRecordTempVariable(0); + write("(typeof ("); + emitNodeWithoutSourceMap(temp); + write(" = "); + emitEntityNameAsExpression(typeName, true); + write(") === 'function' && "); + emitNodeWithoutSourceMap(temp); + write(") || Object"); + break; + case ts.TypeReferenceSerializationKind.TypeWithConstructSignatureAndValue: + emitEntityNameAsExpression(typeName, false); + break; + case ts.TypeReferenceSerializationKind.VoidType: + write("void 0"); + break; + case ts.TypeReferenceSerializationKind.BooleanType: + write("Boolean"); + break; + case ts.TypeReferenceSerializationKind.NumberLikeType: + write("Number"); + break; + case ts.TypeReferenceSerializationKind.StringLikeType: + write("String"); + break; + case ts.TypeReferenceSerializationKind.ArrayLikeType: + write("Array"); + break; + case ts.TypeReferenceSerializationKind.ESSymbolType: + if (languageVersion < 2) { + write("typeof Symbol === 'function' ? Symbol : Object"); + } + else { + write("Symbol"); + } + break; + case ts.TypeReferenceSerializationKind.TypeWithCallSignature: + write("Function"); + break; + case ts.TypeReferenceSerializationKind.ObjectType: + write("Object"); + break; + } + } + function emitSerializedParameterTypesOfNode(node) { + if (node) { + var valueDeclaration; + if (node.kind === 214) { + valueDeclaration = ts.getFirstConstructorWithBody(node); + } + else if (ts.isFunctionLike(node) && ts.nodeIsPresent(node.body)) { + valueDeclaration = node; + } + if (valueDeclaration) { + var parameters = valueDeclaration.parameters; + var parameterCount = parameters.length; + if (parameterCount > 0) { + for (var i = 0; i < parameterCount; i++) { + if (i > 0) { + write(", "); + } + if (parameters[i].dotDotDotToken) { + var parameterType = parameters[i].type; + if (parameterType.kind === 156) { + parameterType = parameterType.elementType; + } + else if (parameterType.kind === 151 && parameterType.typeArguments && parameterType.typeArguments.length === 1) { + parameterType = parameterType.typeArguments[0]; + } + else { + parameterType = undefined; + } + emitSerializedTypeNode(parameterType); + } + else { + emitSerializedTypeOfNode(parameters[i]); + } + } + } + } + } + } + function emitSerializedReturnTypeOfNode(node) { + if (node && ts.isFunctionLike(node) && node.type) { + emitSerializedTypeNode(node.type); + return; + } + write("void 0"); + } + function emitSerializedTypeMetadata(node, writeComma) { + var argumentsWritten = 0; + if (compilerOptions.emitDecoratorMetadata) { + if (shouldEmitTypeMetadata(node)) { + if (writeComma) { + write(", "); + } + writeLine(); + write("__metadata('design:type', "); + emitSerializedTypeOfNode(node); + write(")"); + argumentsWritten++; + } + if (shouldEmitParamTypesMetadata(node)) { + if (writeComma || argumentsWritten) { + write(", "); + } + writeLine(); + write("__metadata('design:paramtypes', ["); + emitSerializedParameterTypesOfNode(node); + write("])"); + argumentsWritten++; + } + if (shouldEmitReturnTypeMetadata(node)) { + if (writeComma || argumentsWritten) { + write(", "); + } + writeLine(); + write("__metadata('design:returntype', "); + emitSerializedReturnTypeOfNode(node); + write(")"); + argumentsWritten++; + } + } + return argumentsWritten; + } + function emitInterfaceDeclaration(node) { + emitCommentsOnNotEmittedNode(node); + } + function shouldEmitEnumDeclaration(node) { + var isConstEnum = ts.isConst(node); + return !isConstEnum || compilerOptions.preserveConstEnums || compilerOptions.isolatedModules; + } + function emitEnumDeclaration(node) { + if (!shouldEmitEnumDeclaration(node)) { + return; + } + if (!shouldHoistDeclarationInSystemJsModule(node)) { + if (!(node.flags & 1) || isES6ExportedDeclaration(node)) { + emitStart(node); + if (isES6ExportedDeclaration(node)) { + write("export "); + } + write("var "); + emit(node.name); + emitEnd(node); + write(";"); + } + } + writeLine(); + emitStart(node); + write("(function ("); + emitStart(node.name); + write(getGeneratedNameForNode(node)); + emitEnd(node.name); + write(") {"); + increaseIndent(); + scopeEmitStart(node); + emitLines(node.members); + decreaseIndent(); + writeLine(); + emitToken(16, node.members.end); + scopeEmitEnd(); + write(")("); + emitModuleMemberName(node); + write(" || ("); + emitModuleMemberName(node); + write(" = {}));"); + emitEnd(node); + if (!isES6ExportedDeclaration(node) && node.flags & 1 && !shouldHoistDeclarationInSystemJsModule(node)) { + writeLine(); + emitStart(node); + write("var "); + emit(node.name); + write(" = "); + emitModuleMemberName(node); + emitEnd(node); + write(";"); + } + if (modulekind !== 5 && node.parent === currentSourceFile) { + if (modulekind === 4 && (node.flags & 1)) { + writeLine(); + write(exportFunctionForFile + "(\""); + emitDeclarationName(node); + write("\", "); + emitDeclarationName(node); + write(");"); + } + emitExportMemberAssignments(node.name); + } + } + function emitEnumMember(node) { + var enumParent = node.parent; + emitStart(node); + write(getGeneratedNameForNode(enumParent)); + write("["); + write(getGeneratedNameForNode(enumParent)); + write("["); + emitExpressionForPropertyName(node.name); + write("] = "); + writeEnumMemberDeclarationValue(node); + write("] = "); + emitExpressionForPropertyName(node.name); + emitEnd(node); + write(";"); + } + function writeEnumMemberDeclarationValue(member) { + var value = resolver.getConstantValue(member); + if (value !== undefined) { + write(value.toString()); + return; + } + else if (member.initializer) { + emit(member.initializer); + } + else { + write("undefined"); + } + } + function getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration) { + if (moduleDeclaration.body.kind === 218) { + var recursiveInnerModule = getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration.body); + return recursiveInnerModule || moduleDeclaration.body; + } + } + function shouldEmitModuleDeclaration(node) { + return ts.isInstantiatedModule(node, compilerOptions.preserveConstEnums || compilerOptions.isolatedModules); + } + function isModuleMergedWithES6Class(node) { + return languageVersion === 2 && !!(resolver.getNodeCheckFlags(node) & 32768); + } + function emitModuleDeclaration(node) { + var shouldEmit = shouldEmitModuleDeclaration(node); + if (!shouldEmit) { + return emitCommentsOnNotEmittedNode(node); + } + var hoistedInDeclarationScope = shouldHoistDeclarationInSystemJsModule(node); + var emitVarForModule = !hoistedInDeclarationScope && !isModuleMergedWithES6Class(node); + if (emitVarForModule) { + emitStart(node); + if (isES6ExportedDeclaration(node)) { + write("export "); + } + write("var "); + emit(node.name); + write(";"); + emitEnd(node); + writeLine(); + } + emitStart(node); + write("(function ("); + emitStart(node.name); + write(getGeneratedNameForNode(node)); + emitEnd(node.name); + write(") "); + if (node.body.kind === 219) { + var saveTempFlags = tempFlags; + var saveTempVariables = tempVariables; + tempFlags = 0; + tempVariables = undefined; + emit(node.body); + tempFlags = saveTempFlags; + tempVariables = saveTempVariables; + } + else { + write("{"); + increaseIndent(); + scopeEmitStart(node); + emitCaptureThisForNodeIfNecessary(node); + writeLine(); + emit(node.body); + decreaseIndent(); + writeLine(); + var moduleBlock = getInnerMostModuleDeclarationFromDottedModule(node).body; + emitToken(16, moduleBlock.statements.end); + scopeEmitEnd(); + } + write(")("); + if ((node.flags & 1) && !isES6ExportedDeclaration(node)) { + emit(node.name); + write(" = "); + } + emitModuleMemberName(node); + write(" || ("); + emitModuleMemberName(node); + write(" = {}));"); + emitEnd(node); + if (!isES6ExportedDeclaration(node) && node.name.kind === 69 && node.parent === currentSourceFile) { + if (modulekind === 4 && (node.flags & 1)) { + writeLine(); + write(exportFunctionForFile + "(\""); + emitDeclarationName(node); + write("\", "); + emitDeclarationName(node); + write(");"); + } + emitExportMemberAssignments(node.name); + } + } + function tryRenameExternalModule(moduleName) { + if (currentSourceFile.renamedDependencies && ts.hasProperty(currentSourceFile.renamedDependencies, moduleName.text)) { + return "\"" + currentSourceFile.renamedDependencies[moduleName.text] + "\""; + } + return undefined; + } + function emitRequire(moduleName) { + if (moduleName.kind === 9) { + write("require("); + var text = tryRenameExternalModule(moduleName); + if (text) { + write(text); + } + else { + emitStart(moduleName); + emitLiteral(moduleName); + emitEnd(moduleName); + } + emitToken(18, moduleName.end); + } + else { + write("require()"); + } + } + function getNamespaceDeclarationNode(node) { + if (node.kind === 221) { + return node; + } + var importClause = node.importClause; + if (importClause && importClause.namedBindings && importClause.namedBindings.kind === 224) { + return importClause.namedBindings; + } + } + function isDefaultImport(node) { + return node.kind === 222 && node.importClause && !!node.importClause.name; + } + function emitExportImportAssignments(node) { + if (ts.isAliasSymbolDeclaration(node) && resolver.isValueAliasDeclaration(node)) { + emitExportMemberAssignments(node.name); + } + ts.forEachChild(node, emitExportImportAssignments); + } + function emitImportDeclaration(node) { + if (modulekind !== 5) { + return emitExternalImportDeclaration(node); + } + if (node.importClause) { + var shouldEmitDefaultBindings = resolver.isReferencedAliasDeclaration(node.importClause); + var shouldEmitNamedBindings = node.importClause.namedBindings && resolver.isReferencedAliasDeclaration(node.importClause.namedBindings, true); + if (shouldEmitDefaultBindings || shouldEmitNamedBindings) { + write("import "); + emitStart(node.importClause); + if (shouldEmitDefaultBindings) { + emit(node.importClause.name); + if (shouldEmitNamedBindings) { + write(", "); + } + } + if (shouldEmitNamedBindings) { + emitLeadingComments(node.importClause.namedBindings); + emitStart(node.importClause.namedBindings); + if (node.importClause.namedBindings.kind === 224) { + write("* as "); + emit(node.importClause.namedBindings.name); + } + else { + write("{ "); + emitExportOrImportSpecifierList(node.importClause.namedBindings.elements, resolver.isReferencedAliasDeclaration); + write(" }"); + } + emitEnd(node.importClause.namedBindings); + emitTrailingComments(node.importClause.namedBindings); + } + emitEnd(node.importClause); + write(" from "); + emit(node.moduleSpecifier); + write(";"); + } + } + else { + write("import "); + emit(node.moduleSpecifier); + write(";"); + } + } + function emitExternalImportDeclaration(node) { + if (ts.contains(externalImports, node)) { + var isExportedImport = node.kind === 221 && (node.flags & 1) !== 0; + var namespaceDeclaration = getNamespaceDeclarationNode(node); + if (modulekind !== 2) { + emitLeadingComments(node); + emitStart(node); + if (namespaceDeclaration && !isDefaultImport(node)) { + if (!isExportedImport) + write("var "); + emitModuleMemberName(namespaceDeclaration); + write(" = "); + } + else { + var isNakedImport = 222 && !node.importClause; + if (!isNakedImport) { + write("var "); + write(getGeneratedNameForNode(node)); + write(" = "); + } + } + emitRequire(ts.getExternalModuleName(node)); + if (namespaceDeclaration && isDefaultImport(node)) { + write(", "); + emitModuleMemberName(namespaceDeclaration); + write(" = "); + write(getGeneratedNameForNode(node)); + } + write(";"); + emitEnd(node); + emitExportImportAssignments(node); + emitTrailingComments(node); + } + else { + if (isExportedImport) { + emitModuleMemberName(namespaceDeclaration); + write(" = "); + emit(namespaceDeclaration.name); + write(";"); + } + else if (namespaceDeclaration && isDefaultImport(node)) { + write("var "); + emitModuleMemberName(namespaceDeclaration); + write(" = "); + write(getGeneratedNameForNode(node)); + write(";"); + } + emitExportImportAssignments(node); + } + } + } + function emitImportEqualsDeclaration(node) { + if (ts.isExternalModuleImportEqualsDeclaration(node)) { + emitExternalImportDeclaration(node); + return; + } + if (resolver.isReferencedAliasDeclaration(node) || + (!ts.isExternalModule(currentSourceFile) && resolver.isTopLevelValueImportEqualsWithEntityName(node))) { + emitLeadingComments(node); + emitStart(node); + var variableDeclarationIsHoisted = shouldHoistVariable(node, true); + var isExported = isSourceFileLevelDeclarationInSystemJsModule(node, true); + if (!variableDeclarationIsHoisted) { + ts.Debug.assert(!isExported); + if (isES6ExportedDeclaration(node)) { + write("export "); + write("var "); + } + else if (!(node.flags & 1)) { + write("var "); + } + } + if (isExported) { + write(exportFunctionForFile + "(\""); + emitNodeWithoutSourceMap(node.name); + write("\", "); + } + emitModuleMemberName(node); + write(" = "); + emit(node.moduleReference); + if (isExported) { + write(")"); + } + write(";"); + emitEnd(node); + emitExportImportAssignments(node); + emitTrailingComments(node); + } + } + function emitExportDeclaration(node) { + ts.Debug.assert(modulekind !== 4); + if (modulekind !== 5) { + if (node.moduleSpecifier && (!node.exportClause || resolver.isValueAliasDeclaration(node))) { + emitStart(node); + var generatedName = getGeneratedNameForNode(node); + if (node.exportClause) { + if (modulekind !== 2) { + write("var "); + write(generatedName); + write(" = "); + emitRequire(ts.getExternalModuleName(node)); + write(";"); + } + for (var _a = 0, _b = node.exportClause.elements; _a < _b.length; _a++) { + var specifier = _b[_a]; + if (resolver.isValueAliasDeclaration(specifier)) { + writeLine(); + emitStart(specifier); + emitContainingModuleName(specifier); + write("."); + emitNodeWithCommentsAndWithoutSourcemap(specifier.name); + write(" = "); + write(generatedName); + write("."); + emitNodeWithCommentsAndWithoutSourcemap(specifier.propertyName || specifier.name); + write(";"); + emitEnd(specifier); + } + } + } + else { + writeLine(); + write("__export("); + if (modulekind !== 2) { + emitRequire(ts.getExternalModuleName(node)); + } + else { + write(generatedName); + } + write(");"); + } + emitEnd(node); + } + } + else { + if (!node.exportClause || resolver.isValueAliasDeclaration(node)) { + write("export "); + if (node.exportClause) { + write("{ "); + emitExportOrImportSpecifierList(node.exportClause.elements, resolver.isValueAliasDeclaration); + write(" }"); + } + else { + write("*"); + } + if (node.moduleSpecifier) { + write(" from "); + emit(node.moduleSpecifier); + } + write(";"); + } + } + } + function emitExportOrImportSpecifierList(specifiers, shouldEmit) { + ts.Debug.assert(modulekind === 5); + var needsComma = false; + for (var _a = 0; _a < specifiers.length; _a++) { + var specifier = specifiers[_a]; + if (shouldEmit(specifier)) { + if (needsComma) { + write(", "); + } + if (specifier.propertyName) { + emit(specifier.propertyName); + write(" as "); + } + emit(specifier.name); + needsComma = true; + } + } + } + function emitExportAssignment(node) { + if (!node.isExportEquals && resolver.isValueAliasDeclaration(node)) { + if (modulekind === 5) { + writeLine(); + emitStart(node); + write("export default "); + var expression = node.expression; + emit(expression); + if (expression.kind !== 213 && + expression.kind !== 214) { + write(";"); + } + emitEnd(node); + } + else { + writeLine(); + emitStart(node); + if (modulekind === 4) { + write(exportFunctionForFile + "(\"default\","); + emit(node.expression); + write(")"); + } + else { + emitEs6ExportDefaultCompat(node); + emitContainingModuleName(node); + if (languageVersion === 0) { + write("[\"default\"] = "); + } + else { + write(".default = "); + } + emit(node.expression); + } + write(";"); + emitEnd(node); + } + } + } + function collectExternalModuleInfo(sourceFile) { + externalImports = []; + exportSpecifiers = {}; + exportEquals = undefined; + hasExportStars = false; + for (var _a = 0, _b = sourceFile.statements; _a < _b.length; _a++) { + var node = _b[_a]; + switch (node.kind) { + case 222: + if (!node.importClause || + resolver.isReferencedAliasDeclaration(node.importClause, true)) { + externalImports.push(node); + } + break; + case 221: + if (node.moduleReference.kind === 232 && resolver.isReferencedAliasDeclaration(node)) { + externalImports.push(node); + } + break; + case 228: + if (node.moduleSpecifier) { + if (!node.exportClause) { + externalImports.push(node); + hasExportStars = true; + } + else if (resolver.isValueAliasDeclaration(node)) { + externalImports.push(node); + } + } + else { + for (var _c = 0, _d = node.exportClause.elements; _c < _d.length; _c++) { + var specifier = _d[_c]; + var name_26 = (specifier.propertyName || specifier.name).text; + (exportSpecifiers[name_26] || (exportSpecifiers[name_26] = [])).push(specifier); + } + } + break; + case 227: + if (node.isExportEquals && !exportEquals) { + exportEquals = node; + } + break; + } + } + } + function emitExportStarHelper() { + if (hasExportStars) { + writeLine(); + write("function __export(m) {"); + increaseIndent(); + writeLine(); + write("for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];"); + decreaseIndent(); + writeLine(); + write("}"); + } + } + function getLocalNameForExternalImport(node) { + var namespaceDeclaration = getNamespaceDeclarationNode(node); + if (namespaceDeclaration && !isDefaultImport(node)) { + return ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, namespaceDeclaration.name); + } + if (node.kind === 222 && node.importClause) { + return getGeneratedNameForNode(node); + } + if (node.kind === 228 && node.moduleSpecifier) { + return getGeneratedNameForNode(node); + } + } + function getExternalModuleNameText(importNode) { + var moduleName = ts.getExternalModuleName(importNode); + if (moduleName.kind === 9) { + return tryRenameExternalModule(moduleName) || getLiteralText(moduleName); + } + return undefined; + } + function emitVariableDeclarationsForImports() { + if (externalImports.length === 0) { + return; + } + writeLine(); + var started = false; + for (var _a = 0; _a < externalImports.length; _a++) { + var importNode = externalImports[_a]; + var skipNode = importNode.kind === 228 || + (importNode.kind === 222 && !importNode.importClause); + if (skipNode) { + continue; + } + if (!started) { + write("var "); + started = true; + } + else { + write(", "); + } + write(getLocalNameForExternalImport(importNode)); + } + if (started) { + write(";"); + } + } + function emitLocalStorageForExportedNamesIfNecessary(exportedDeclarations) { + if (!hasExportStars) { + return undefined; + } + if (!exportedDeclarations && ts.isEmpty(exportSpecifiers)) { + var hasExportDeclarationWithExportClause = false; + for (var _a = 0; _a < externalImports.length; _a++) { + var externalImport = externalImports[_a]; + if (externalImport.kind === 228 && externalImport.exportClause) { + hasExportDeclarationWithExportClause = true; + break; + } + } + if (!hasExportDeclarationWithExportClause) { + return emitExportStarFunction(undefined); + } + } + var exportedNamesStorageRef = makeUniqueName("exportedNames"); + writeLine(); + write("var " + exportedNamesStorageRef + " = {"); + increaseIndent(); + var started = false; + if (exportedDeclarations) { + for (var i = 0; i < exportedDeclarations.length; ++i) { + writeExportedName(exportedDeclarations[i]); + } + } + if (exportSpecifiers) { + for (var n in exportSpecifiers) { + for (var _b = 0, _c = exportSpecifiers[n]; _b < _c.length; _b++) { + var specifier = _c[_b]; + writeExportedName(specifier.name); + } + } + } + for (var _d = 0; _d < externalImports.length; _d++) { + var externalImport = externalImports[_d]; + if (externalImport.kind !== 228) { + continue; + } + var exportDecl = externalImport; + if (!exportDecl.exportClause) { + continue; + } + for (var _e = 0, _f = exportDecl.exportClause.elements; _e < _f.length; _e++) { + var element = _f[_e]; + writeExportedName(element.name || element.propertyName); + } + } + decreaseIndent(); + writeLine(); + write("};"); + return emitExportStarFunction(exportedNamesStorageRef); + function emitExportStarFunction(localNames) { + var exportStarFunction = makeUniqueName("exportStar"); + writeLine(); + write("function " + exportStarFunction + "(m) {"); + increaseIndent(); + writeLine(); + write("var exports = {};"); + writeLine(); + write("for(var n in m) {"); + increaseIndent(); + writeLine(); + write("if (n !== \"default\""); + if (localNames) { + write("&& !" + localNames + ".hasOwnProperty(n)"); + } + write(") exports[n] = m[n];"); + decreaseIndent(); + writeLine(); + write("}"); + writeLine(); + write(exportFunctionForFile + "(exports);"); + decreaseIndent(); + writeLine(); + write("}"); + return exportStarFunction; + } + function writeExportedName(node) { + if (node.kind !== 69 && node.flags & 1024) { + return; + } + if (started) { + write(","); + } + else { + started = true; + } + writeLine(); + write("'"); + if (node.kind === 69) { + emitNodeWithCommentsAndWithoutSourcemap(node); + } + else { + emitDeclarationName(node); + } + write("': true"); + } + } + function processTopLevelVariableAndFunctionDeclarations(node) { + var hoistedVars; + var hoistedFunctionDeclarations; + var exportedDeclarations; + visit(node); + if (hoistedVars) { + writeLine(); + write("var "); + var seen = {}; + for (var i = 0; i < hoistedVars.length; ++i) { + var local = hoistedVars[i]; + var name_27 = local.kind === 69 + ? local + : local.name; + if (name_27) { + var text = ts.unescapeIdentifier(name_27.text); + if (ts.hasProperty(seen, text)) { + continue; + } + else { + seen[text] = text; + } + } + if (i !== 0) { + write(", "); + } + if (local.kind === 214 || local.kind === 218 || local.kind === 217) { + emitDeclarationName(local); + } + else { + emit(local); + } + var flags = ts.getCombinedNodeFlags(local.kind === 69 ? local.parent : local); + if (flags & 1) { + if (!exportedDeclarations) { + exportedDeclarations = []; + } + exportedDeclarations.push(local); + } + } + write(";"); + } + if (hoistedFunctionDeclarations) { + for (var _a = 0; _a < hoistedFunctionDeclarations.length; _a++) { + var f = hoistedFunctionDeclarations[_a]; + writeLine(); + emit(f); + if (f.flags & 1) { + if (!exportedDeclarations) { + exportedDeclarations = []; + } + exportedDeclarations.push(f); + } + } + } + return exportedDeclarations; + function visit(node) { + if (node.flags & 2) { + return; + } + if (node.kind === 213) { + if (!hoistedFunctionDeclarations) { + hoistedFunctionDeclarations = []; + } + hoistedFunctionDeclarations.push(node); + return; + } + if (node.kind === 214) { + if (!hoistedVars) { + hoistedVars = []; + } + hoistedVars.push(node); + return; + } + if (node.kind === 217) { + if (shouldEmitEnumDeclaration(node)) { + if (!hoistedVars) { + hoistedVars = []; + } + hoistedVars.push(node); + } + return; + } + if (node.kind === 218) { + if (shouldEmitModuleDeclaration(node)) { + if (!hoistedVars) { + hoistedVars = []; + } + hoistedVars.push(node); + } + return; + } + if (node.kind === 211 || node.kind === 163) { + if (shouldHoistVariable(node, false)) { + var name_28 = node.name; + if (name_28.kind === 69) { + if (!hoistedVars) { + hoistedVars = []; + } + hoistedVars.push(name_28); + } + else { + ts.forEachChild(name_28, visit); + } + } + return; + } + if (ts.isInternalModuleImportEqualsDeclaration(node) && resolver.isValueAliasDeclaration(node)) { + if (!hoistedVars) { + hoistedVars = []; + } + hoistedVars.push(node.name); + return; + } + if (ts.isBindingPattern(node)) { + ts.forEach(node.elements, visit); + return; + } + if (!ts.isDeclaration(node)) { + ts.forEachChild(node, visit); + } + } + } + function shouldHoistVariable(node, checkIfSourceFileLevelDecl) { + if (checkIfSourceFileLevelDecl && !shouldHoistDeclarationInSystemJsModule(node)) { + return false; + } + return (ts.getCombinedNodeFlags(node) & 49152) === 0 || + ts.getEnclosingBlockScopeContainer(node).kind === 248; + } + function isCurrentFileSystemExternalModule() { + return modulekind === 4 && ts.isExternalModule(currentSourceFile); + } + function emitSystemModuleBody(node, dependencyGroups, startIndex) { + emitVariableDeclarationsForImports(); + writeLine(); + var exportedDeclarations = processTopLevelVariableAndFunctionDeclarations(node); + var exportStarFunction = emitLocalStorageForExportedNamesIfNecessary(exportedDeclarations); + writeLine(); + write("return {"); + increaseIndent(); + writeLine(); + emitSetters(exportStarFunction, dependencyGroups); + writeLine(); + emitExecute(node, startIndex); + decreaseIndent(); + writeLine(); + write("}"); + emitTempDeclarations(true); + } + function emitSetters(exportStarFunction, dependencyGroups) { + write("setters:["); + for (var i = 0; i < dependencyGroups.length; ++i) { + if (i !== 0) { + write(","); + } + writeLine(); + increaseIndent(); + var group = dependencyGroups[i]; + var parameterName = makeUniqueName(ts.forEach(group, getLocalNameForExternalImport) || ""); + write("function (" + parameterName + ") {"); + increaseIndent(); + for (var _a = 0; _a < group.length; _a++) { + var entry = group[_a]; + var importVariableName = getLocalNameForExternalImport(entry) || ""; + switch (entry.kind) { + case 222: + if (!entry.importClause) { + break; + } + case 221: + ts.Debug.assert(importVariableName !== ""); + writeLine(); + write(importVariableName + " = " + parameterName + ";"); + writeLine(); + break; + case 228: + ts.Debug.assert(importVariableName !== ""); + if (entry.exportClause) { + writeLine(); + write(exportFunctionForFile + "({"); + writeLine(); + increaseIndent(); + for (var i_2 = 0, len = entry.exportClause.elements.length; i_2 < len; ++i_2) { + if (i_2 !== 0) { + write(","); + writeLine(); + } + var e = entry.exportClause.elements[i_2]; + write("\""); + emitNodeWithCommentsAndWithoutSourcemap(e.name); + write("\": " + parameterName + "[\""); + emitNodeWithCommentsAndWithoutSourcemap(e.propertyName || e.name); + write("\"]"); + } + decreaseIndent(); + writeLine(); + write("});"); + } + else { + writeLine(); + write(exportStarFunction + "(" + parameterName + ");"); + } + writeLine(); + break; + } + } + decreaseIndent(); + write("}"); + decreaseIndent(); + } + write("],"); + } + function emitExecute(node, startIndex) { + write("execute: function() {"); + increaseIndent(); + writeLine(); + for (var i = startIndex; i < node.statements.length; ++i) { + var statement = node.statements[i]; + switch (statement.kind) { + case 213: + case 222: + continue; + case 228: + if (!statement.moduleSpecifier) { + for (var _a = 0, _b = statement.exportClause.elements; _a < _b.length; _a++) { + var element = _b[_a]; + emitExportSpecifierInSystemModule(element); + } + } + continue; + case 221: + if (!ts.isInternalModuleImportEqualsDeclaration(statement)) { + continue; + } + default: + writeLine(); + emit(statement); + } + } + decreaseIndent(); + writeLine(); + write("}"); + } + function emitSystemModule(node) { + collectExternalModuleInfo(node); + ts.Debug.assert(!exportFunctionForFile); + exportFunctionForFile = makeUniqueName("exports"); + writeLine(); + write("System.register("); + if (node.moduleName) { + write("\"" + node.moduleName + "\", "); + } + write("["); + var groupIndices = {}; + var dependencyGroups = []; + for (var i = 0; i < externalImports.length; ++i) { + var text = getExternalModuleNameText(externalImports[i]); + if (ts.hasProperty(groupIndices, text)) { + var groupIndex = groupIndices[text]; + dependencyGroups[groupIndex].push(externalImports[i]); + continue; + } + else { + groupIndices[text] = dependencyGroups.length; + dependencyGroups.push([externalImports[i]]); + } + if (i !== 0) { + write(", "); + } + write(text); + } + write("], function(" + exportFunctionForFile + ") {"); + writeLine(); + increaseIndent(); + var startIndex = emitDirectivePrologues(node.statements, true); + emitEmitHelpers(node); + emitCaptureThisForNodeIfNecessary(node); + emitSystemModuleBody(node, dependencyGroups, startIndex); + decreaseIndent(); + writeLine(); + write("});"); + } + function getAMDDependencyNames(node, includeNonAmdDependencies) { + var aliasedModuleNames = []; + var unaliasedModuleNames = []; + var importAliasNames = []; + for (var _a = 0, _b = node.amdDependencies; _a < _b.length; _a++) { + var amdDependency = _b[_a]; + if (amdDependency.name) { + aliasedModuleNames.push("\"" + amdDependency.path + "\""); + importAliasNames.push(amdDependency.name); + } + else { + unaliasedModuleNames.push("\"" + amdDependency.path + "\""); + } + } + for (var _c = 0; _c < externalImports.length; _c++) { + var importNode = externalImports[_c]; + var externalModuleName = getExternalModuleNameText(importNode); + var importAliasName = getLocalNameForExternalImport(importNode); + if (includeNonAmdDependencies && importAliasName) { + aliasedModuleNames.push(externalModuleName); + importAliasNames.push(importAliasName); + } + else { + unaliasedModuleNames.push(externalModuleName); + } + } + return { aliasedModuleNames: aliasedModuleNames, unaliasedModuleNames: unaliasedModuleNames, importAliasNames: importAliasNames }; + } + function emitAMDDependencies(node, includeNonAmdDependencies) { + var dependencyNames = getAMDDependencyNames(node, includeNonAmdDependencies); + emitAMDDependencyList(dependencyNames); + write(", "); + emitAMDFactoryHeader(dependencyNames); + } + function emitAMDDependencyList(_a) { + var aliasedModuleNames = _a.aliasedModuleNames, unaliasedModuleNames = _a.unaliasedModuleNames; + write("[\"require\", \"exports\""); + if (aliasedModuleNames.length) { + write(", "); + write(aliasedModuleNames.join(", ")); + } + if (unaliasedModuleNames.length) { + write(", "); + write(unaliasedModuleNames.join(", ")); + } + write("]"); + } + function emitAMDFactoryHeader(_a) { + var importAliasNames = _a.importAliasNames; + write("function (require, exports"); + if (importAliasNames.length) { + write(", "); + write(importAliasNames.join(", ")); + } + write(") {"); + } + function emitAMDModule(node) { + emitEmitHelpers(node); + collectExternalModuleInfo(node); + writeLine(); + write("define("); + if (node.moduleName) { + write("\"" + node.moduleName + "\", "); + } + emitAMDDependencies(node, true); + increaseIndent(); + var startIndex = emitDirectivePrologues(node.statements, true); + emitExportStarHelper(); + emitCaptureThisForNodeIfNecessary(node); + emitLinesStartingAt(node.statements, startIndex); + emitTempDeclarations(true); + emitExportEquals(true); + decreaseIndent(); + writeLine(); + write("});"); + } + function emitCommonJSModule(node) { + var startIndex = emitDirectivePrologues(node.statements, false); + emitEmitHelpers(node); + collectExternalModuleInfo(node); + emitExportStarHelper(); + emitCaptureThisForNodeIfNecessary(node); + emitLinesStartingAt(node.statements, startIndex); + emitTempDeclarations(true); + emitExportEquals(false); + } + function emitUMDModule(node) { + emitEmitHelpers(node); + collectExternalModuleInfo(node); + var dependencyNames = getAMDDependencyNames(node, false); + writeLines("(function (factory) {\n if (typeof module === 'object' && typeof module.exports === 'object') {\n var v = factory(require, exports); if (v !== undefined) module.exports = v;\n }\n else if (typeof define === 'function' && define.amd) {\n define("); + emitAMDDependencyList(dependencyNames); + write(", factory);"); + writeLines(" }\n})("); + emitAMDFactoryHeader(dependencyNames); + increaseIndent(); + var startIndex = emitDirectivePrologues(node.statements, true); + emitExportStarHelper(); + emitCaptureThisForNodeIfNecessary(node); + emitLinesStartingAt(node.statements, startIndex); + emitTempDeclarations(true); + emitExportEquals(true); + decreaseIndent(); + writeLine(); + write("});"); + } + function emitES6Module(node) { + externalImports = undefined; + exportSpecifiers = undefined; + exportEquals = undefined; + hasExportStars = false; + var startIndex = emitDirectivePrologues(node.statements, false); + emitEmitHelpers(node); + emitCaptureThisForNodeIfNecessary(node); + emitLinesStartingAt(node.statements, startIndex); + emitTempDeclarations(true); + } + function emitExportEquals(emitAsReturn) { + if (exportEquals && resolver.isValueAliasDeclaration(exportEquals)) { + writeLine(); + emitStart(exportEquals); + write(emitAsReturn ? "return " : "module.exports = "); + emit(exportEquals.expression); + write(";"); + emitEnd(exportEquals); + } + } + function emitJsxElement(node) { + switch (compilerOptions.jsx) { + case 2: + jsxEmitReact(node); + break; + case 1: + default: + jsxEmitPreserve(node); + break; + } + } + function trimReactWhitespaceAndApplyEntities(node) { + var result = undefined; + var text = ts.getTextOfNode(node, true); + var firstNonWhitespace = 0; + var lastNonWhitespace = -1; + for (var i = 0; i < text.length; i++) { + var c = text.charCodeAt(i); + if (ts.isLineBreak(c)) { + if (firstNonWhitespace !== -1 && (lastNonWhitespace - firstNonWhitespace + 1 > 0)) { + var part = text.substr(firstNonWhitespace, lastNonWhitespace - firstNonWhitespace + 1); + result = (result ? result + "\" + ' ' + \"" : "") + ts.escapeString(part); + } + firstNonWhitespace = -1; + } + else if (!ts.isWhiteSpace(c)) { + lastNonWhitespace = i; + if (firstNonWhitespace === -1) { + firstNonWhitespace = i; + } + } + } + if (firstNonWhitespace !== -1) { + var part = text.substr(firstNonWhitespace); + result = (result ? result + "\" + ' ' + \"" : "") + ts.escapeString(part); + } + if (result) { + result = result.replace(/&(\w+);/g, function (s, m) { + if (entities[m] !== undefined) { + return String.fromCharCode(entities[m]); + } + else { + return s; + } + }); + } + return result; + } + function getTextToEmit(node) { + switch (compilerOptions.jsx) { + case 2: + var text = trimReactWhitespaceAndApplyEntities(node); + if (text === undefined || text.length === 0) { + return undefined; + } + else { + return text; + } + case 1: + default: + return ts.getTextOfNode(node, true); + } + } + function emitJsxText(node) { + switch (compilerOptions.jsx) { + case 2: + write("\""); + write(trimReactWhitespaceAndApplyEntities(node)); + write("\""); + break; + case 1: + default: + writer.writeLiteral(ts.getTextOfNode(node, true)); + break; + } + } + function emitJsxExpression(node) { + if (node.expression) { + switch (compilerOptions.jsx) { + case 1: + default: + write("{"); + emit(node.expression); + write("}"); + break; + case 2: + emit(node.expression); + break; + } + } + } + function emitDirectivePrologues(statements, startWithNewLine) { + for (var i = 0; i < statements.length; ++i) { + if (ts.isPrologueDirective(statements[i])) { + if (startWithNewLine || i > 0) { + writeLine(); + } + emit(statements[i]); + } + else { + return i; + } + } + return statements.length; + } + function writeLines(text) { + var lines = text.split(/\r\n|\r|\n/g); + for (var i = 0; i < lines.length; ++i) { + var line = lines[i]; + if (line.length) { + writeLine(); + write(line); + } + } + } + function emitEmitHelpers(node) { + if (!compilerOptions.noEmitHelpers) { + if ((languageVersion < 2) && (!extendsEmitted && resolver.getNodeCheckFlags(node) & 8)) { + writeLines(extendsHelper); + extendsEmitted = true; + } + if (!decorateEmitted && resolver.getNodeCheckFlags(node) & 16) { + writeLines(decorateHelper); + if (compilerOptions.emitDecoratorMetadata) { + writeLines(metadataHelper); + } + decorateEmitted = true; + } + if (!paramEmitted && resolver.getNodeCheckFlags(node) & 32) { + writeLines(paramHelper); + paramEmitted = true; + } + if (!awaiterEmitted && resolver.getNodeCheckFlags(node) & 64) { + writeLines(awaiterHelper); + awaiterEmitted = true; + } + } + } + function emitSourceFileNode(node) { + writeLine(); + emitShebang(); + emitDetachedComments(node); + if (ts.isExternalModule(node) || compilerOptions.isolatedModules) { + var emitModule = moduleEmitDelegates[modulekind] || moduleEmitDelegates[1]; + emitModule(node); + } + else { + var startIndex = emitDirectivePrologues(node.statements, false); + externalImports = undefined; + exportSpecifiers = undefined; + exportEquals = undefined; + hasExportStars = false; + emitEmitHelpers(node); + emitCaptureThisForNodeIfNecessary(node); + emitLinesStartingAt(node.statements, startIndex); + emitTempDeclarations(true); + } + emitLeadingComments(node.endOfFileToken); + } + function emitNodeWithCommentsAndWithoutSourcemap(node) { + emitNodeConsideringCommentsOption(node, emitNodeWithoutSourceMap); + } + function emitNodeConsideringCommentsOption(node, emitNodeConsideringSourcemap) { + if (node) { + if (node.flags & 2) { + return emitCommentsOnNotEmittedNode(node); + } + if (isSpecializedCommentHandling(node)) { + return emitNodeWithoutSourceMap(node); + } + var emitComments_1 = shouldEmitLeadingAndTrailingComments(node); + if (emitComments_1) { + emitLeadingComments(node); + } + emitNodeConsideringSourcemap(node); + if (emitComments_1) { + emitTrailingComments(node); + } + } + } + function emitNodeWithoutSourceMap(node) { + if (node) { + emitJavaScriptWorker(node); + } + } + function isSpecializedCommentHandling(node) { + switch (node.kind) { + case 215: + case 213: + case 222: + case 221: + case 216: + case 227: + return true; + } + } + function shouldEmitLeadingAndTrailingComments(node) { + switch (node.kind) { + case 193: + return shouldEmitLeadingAndTrailingCommentsForVariableStatement(node); + case 218: + return shouldEmitModuleDeclaration(node); + case 217: + return shouldEmitEnumDeclaration(node); + } + ts.Debug.assert(!isSpecializedCommentHandling(node)); + if (node.kind !== 192 && + node.parent && + node.parent.kind === 174 && + node.parent.body === node && + compilerOptions.target <= 1) { + return false; + } + return true; + } + function emitJavaScriptWorker(node) { + switch (node.kind) { + case 69: + return emitIdentifier(node); + case 138: + return emitParameter(node); + case 143: + case 142: + return emitMethod(node); + case 145: + case 146: + return emitAccessor(node); + case 97: + return emitThis(node); + case 95: + return emitSuper(node); + case 93: + return write("null"); + case 99: + return write("true"); + case 84: + return write("false"); + case 8: + case 9: + case 10: + case 11: + case 12: + case 13: + case 14: + return emitLiteral(node); + case 183: + return emitTemplateExpression(node); + case 190: + return emitTemplateSpan(node); + case 233: + case 234: + return emitJsxElement(node); + case 236: + return emitJsxText(node); + case 240: + return emitJsxExpression(node); + case 135: + return emitQualifiedName(node); + case 161: + return emitObjectBindingPattern(node); + case 162: + return emitArrayBindingPattern(node); + case 163: + return emitBindingElement(node); + case 164: + return emitArrayLiteral(node); + case 165: + return emitObjectLiteral(node); + case 245: + return emitPropertyAssignment(node); + case 246: + return emitShorthandPropertyAssignment(node); + case 136: + return emitComputedPropertyName(node); + case 166: + return emitPropertyAccess(node); + case 167: + return emitIndexedAccess(node); + case 168: + return emitCallExpression(node); + case 169: + return emitNewExpression(node); + case 170: + return emitTaggedTemplateExpression(node); + case 171: + return emit(node.expression); + case 189: + return emit(node.expression); + case 172: + return emitParenExpression(node); + case 213: + case 173: + case 174: + return emitFunctionDeclaration(node); + case 175: + return emitDeleteExpression(node); + case 176: + return emitTypeOfExpression(node); + case 177: + return emitVoidExpression(node); + case 178: + return emitAwaitExpression(node); + case 179: + return emitPrefixUnaryExpression(node); + case 180: + return emitPostfixUnaryExpression(node); + case 181: + return emitBinaryExpression(node); + case 182: + return emitConditionalExpression(node); + case 185: + return emitSpreadElementExpression(node); + case 184: + return emitYieldExpression(node); + case 187: + return; + case 192: + case 219: + return emitBlock(node); + case 193: + return emitVariableStatement(node); + case 194: + return write(";"); + case 195: + return emitExpressionStatement(node); + case 196: + return emitIfStatement(node); + case 197: + return emitDoStatement(node); + case 198: + return emitWhileStatement(node); + case 199: + return emitForStatement(node); + case 201: + case 200: + return emitForInOrForOfStatement(node); + case 202: + case 203: + return emitBreakOrContinueStatement(node); + case 204: + return emitReturnStatement(node); + case 205: + return emitWithStatement(node); + case 206: + return emitSwitchStatement(node); + case 241: + case 242: + return emitCaseOrDefaultClause(node); + case 207: + return emitLabelledStatement(node); + case 208: + return emitThrowStatement(node); + case 209: + return emitTryStatement(node); + case 244: + return emitCatchClause(node); + case 210: + return emitDebuggerStatement(node); + case 211: + return emitVariableDeclaration(node); + case 186: + return emitClassExpression(node); + case 214: + return emitClassDeclaration(node); + case 215: + return emitInterfaceDeclaration(node); + case 217: + return emitEnumDeclaration(node); + case 247: + return emitEnumMember(node); + case 218: + return emitModuleDeclaration(node); + case 222: + return emitImportDeclaration(node); + case 221: + return emitImportEqualsDeclaration(node); + case 228: + return emitExportDeclaration(node); + case 227: + return emitExportAssignment(node); + case 248: + return emitSourceFileNode(node); + } + } + function hasDetachedComments(pos) { + return detachedCommentsInfo !== undefined && ts.lastOrUndefined(detachedCommentsInfo).nodePos === pos; + } + function getLeadingCommentsWithoutDetachedComments() { + var leadingComments = ts.getLeadingCommentRanges(currentSourceFile.text, ts.lastOrUndefined(detachedCommentsInfo).detachedCommentEndPos); + if (detachedCommentsInfo.length - 1) { + detachedCommentsInfo.pop(); + } + else { + detachedCommentsInfo = undefined; + } + return leadingComments; + } + function isPinnedComments(comment) { + return currentSourceFile.text.charCodeAt(comment.pos + 1) === 42 && + currentSourceFile.text.charCodeAt(comment.pos + 2) === 33; + } + function isTripleSlashComment(comment) { + if (currentSourceFile.text.charCodeAt(comment.pos + 1) === 47 && + comment.pos + 2 < comment.end && + currentSourceFile.text.charCodeAt(comment.pos + 2) === 47) { + var textSubStr = currentSourceFile.text.substring(comment.pos, comment.end); + return textSubStr.match(ts.fullTripleSlashReferencePathRegEx) || + textSubStr.match(ts.fullTripleSlashAMDReferencePathRegEx) ? + true : false; + } + return false; + } + function getLeadingCommentsToEmit(node) { + if (node.parent) { + if (node.parent.kind === 248 || node.pos !== node.parent.pos) { + if (hasDetachedComments(node.pos)) { + return getLeadingCommentsWithoutDetachedComments(); + } + else { + return ts.getLeadingCommentRangesOfNode(node, currentSourceFile); + } + } + } + } + function getTrailingCommentsToEmit(node) { + if (node.parent) { + if (node.parent.kind === 248 || node.end !== node.parent.end) { + return ts.getTrailingCommentRanges(currentSourceFile.text, node.end); + } + } + } + function emitCommentsOnNotEmittedNode(node) { + emitLeadingCommentsWorker(node, false); + } + function emitLeadingComments(node) { + return emitLeadingCommentsWorker(node, true); + } + function emitLeadingCommentsWorker(node, isEmittedNode) { + if (compilerOptions.removeComments) { + return; + } + var leadingComments; + if (isEmittedNode) { + leadingComments = getLeadingCommentsToEmit(node); + } + else { + if (node.pos === 0) { + leadingComments = ts.filter(getLeadingCommentsToEmit(node), isTripleSlashComment); + } + } + ts.emitNewLineBeforeLeadingComments(currentSourceFile, writer, node, leadingComments); + ts.emitComments(currentSourceFile, writer, leadingComments, true, newLine, writeComment); + } + function emitTrailingComments(node) { + if (compilerOptions.removeComments) { + return; + } + var trailingComments = getTrailingCommentsToEmit(node); + ts.emitComments(currentSourceFile, writer, trailingComments, false, newLine, writeComment); + } + function emitTrailingCommentsOfPosition(pos) { + if (compilerOptions.removeComments) { + return; + } + var trailingComments = ts.getTrailingCommentRanges(currentSourceFile.text, pos); + ts.emitComments(currentSourceFile, writer, trailingComments, true, newLine, writeComment); + } + function emitLeadingCommentsOfPositionWorker(pos) { + if (compilerOptions.removeComments) { + return; + } + var leadingComments; + if (hasDetachedComments(pos)) { + leadingComments = getLeadingCommentsWithoutDetachedComments(); + } + else { + leadingComments = ts.getLeadingCommentRanges(currentSourceFile.text, pos); + } + ts.emitNewLineBeforeLeadingComments(currentSourceFile, writer, { pos: pos, end: pos }, leadingComments); + ts.emitComments(currentSourceFile, writer, leadingComments, true, newLine, writeComment); + } + function emitDetachedComments(node) { + var leadingComments; + if (compilerOptions.removeComments) { + if (node.pos === 0) { + leadingComments = ts.filter(ts.getLeadingCommentRanges(currentSourceFile.text, node.pos), isPinnedComments); + } + } + else { + leadingComments = ts.getLeadingCommentRanges(currentSourceFile.text, node.pos); + } + if (leadingComments) { + var detachedComments = []; + var lastComment; + ts.forEach(leadingComments, function (comment) { + if (lastComment) { + var lastCommentLine = ts.getLineOfLocalPosition(currentSourceFile, lastComment.end); + var commentLine = ts.getLineOfLocalPosition(currentSourceFile, comment.pos); + if (commentLine >= lastCommentLine + 2) { + return detachedComments; + } + } + detachedComments.push(comment); + lastComment = comment; + }); + if (detachedComments.length) { + var lastCommentLine = ts.getLineOfLocalPosition(currentSourceFile, ts.lastOrUndefined(detachedComments).end); + var nodeLine = ts.getLineOfLocalPosition(currentSourceFile, ts.skipTrivia(currentSourceFile.text, node.pos)); + if (nodeLine >= lastCommentLine + 2) { + ts.emitNewLineBeforeLeadingComments(currentSourceFile, writer, node, leadingComments); + ts.emitComments(currentSourceFile, writer, detachedComments, true, newLine, writeComment); + var currentDetachedCommentInfo = { nodePos: node.pos, detachedCommentEndPos: ts.lastOrUndefined(detachedComments).end }; + if (detachedCommentsInfo) { + detachedCommentsInfo.push(currentDetachedCommentInfo); + } + else { + detachedCommentsInfo = [currentDetachedCommentInfo]; + } + } + } + } + } + function emitShebang() { + var shebang = ts.getShebang(currentSourceFile.text); + if (shebang) { + write(shebang); + } + } + var _a; + } + function emitFile(jsFilePath, sourceFile) { + emitJavaScript(jsFilePath, sourceFile); + if (compilerOptions.declaration) { + ts.writeDeclarationFile(jsFilePath, sourceFile, host, resolver, diagnostics); + } + } + } + ts.emitFiles = emitFiles; })(ts || (ts = {})); var ts; (function (ts) { @@ -29826,11 +30347,11 @@ var ts; if (ts.getRootLength(moduleName) !== 0 || nameStartsWithDotSlashOrDotDotSlash(moduleName)) { var failedLookupLocations = []; var candidate = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName)); - var resolvedFileName = loadNodeModuleFromFile(candidate, false, failedLookupLocations, host); + var resolvedFileName = loadNodeModuleFromFile(candidate, failedLookupLocations, host); if (resolvedFileName) { return { resolvedModule: { resolvedFileName: resolvedFileName }, failedLookupLocations: failedLookupLocations }; } - resolvedFileName = loadNodeModuleFromDirectory(candidate, false, failedLookupLocations, host); + resolvedFileName = loadNodeModuleFromDirectory(candidate, failedLookupLocations, host); return resolvedFileName ? { resolvedModule: { resolvedFileName: resolvedFileName }, failedLookupLocations: failedLookupLocations } : { resolvedModule: undefined, failedLookupLocations: failedLookupLocations }; @@ -29840,13 +30361,8 @@ var ts; } } ts.nodeModuleNameResolver = nodeModuleNameResolver; - function loadNodeModuleFromFile(candidate, loadOnlyDts, failedLookupLocation, host) { - if (loadOnlyDts) { - return tryLoad(".d.ts"); - } - else { - return ts.forEach(ts.supportedExtensions, tryLoad); - } + function loadNodeModuleFromFile(candidate, failedLookupLocation, host) { + return ts.forEach(ts.supportedJsExtensions, tryLoad); function tryLoad(ext) { var fileName = ts.fileExtensionIs(candidate, ext) ? candidate : candidate + ext; if (host.fileExists(fileName)) { @@ -29858,7 +30374,7 @@ var ts; } } } - function loadNodeModuleFromDirectory(candidate, loadOnlyDts, failedLookupLocation, host) { + function loadNodeModuleFromDirectory(candidate, failedLookupLocation, host) { var packageJsonPath = ts.combinePaths(candidate, "package.json"); if (host.fileExists(packageJsonPath)) { var jsonContent; @@ -29870,7 +30386,7 @@ var ts; jsonContent = { typings: undefined }; } if (jsonContent.typings) { - var result = loadNodeModuleFromFile(ts.normalizePath(ts.combinePaths(candidate, jsonContent.typings)), loadOnlyDts, failedLookupLocation, host); + var result = loadNodeModuleFromFile(ts.normalizePath(ts.combinePaths(candidate, jsonContent.typings)), failedLookupLocation, host); if (result) { return result; } @@ -29879,7 +30395,7 @@ var ts; else { failedLookupLocation.push(packageJsonPath); } - return loadNodeModuleFromFile(ts.combinePaths(candidate, "index"), loadOnlyDts, failedLookupLocation, host); + return loadNodeModuleFromFile(ts.combinePaths(candidate, "index"), failedLookupLocation, host); } function loadModuleFromNodeModules(moduleName, directory, host) { var failedLookupLocations = []; @@ -29889,11 +30405,11 @@ var ts; if (baseName !== "node_modules") { var nodeModulesFolder = ts.combinePaths(directory, "node_modules"); var candidate = ts.normalizePath(ts.combinePaths(nodeModulesFolder, moduleName)); - var result = loadNodeModuleFromFile(candidate, true, failedLookupLocations, host); + var result = loadNodeModuleFromFile(candidate, failedLookupLocations, host); if (result) { return { resolvedModule: { resolvedFileName: result, isExternalLibraryImport: true }, failedLookupLocations: failedLookupLocations }; } - result = loadNodeModuleFromDirectory(candidate, true, failedLookupLocations, host); + result = loadNodeModuleFromDirectory(candidate, failedLookupLocations, host); if (result) { return { resolvedModule: { resolvedFileName: result, isExternalLibraryImport: true }, failedLookupLocations: failedLookupLocations }; } @@ -29911,16 +30427,17 @@ var ts; return i === 0 || (i === 1 && name.charCodeAt(0) === 46); } function classicNameResolver(moduleName, containingFile, compilerOptions, host) { - if (moduleName.indexOf('!') != -1) { + if (moduleName.indexOf("!") != -1) { return { resolvedModule: undefined, failedLookupLocations: [] }; } var searchPath = ts.getDirectoryPath(containingFile); var searchName; var failedLookupLocations = []; var referencedSourceFile; + var extensions = compilerOptions.allowNonTsExtensions ? ts.supportedJsExtensions : ts.supportedExtensions; while (true) { searchName = ts.normalizePath(ts.combinePaths(searchPath, moduleName)); - referencedSourceFile = ts.forEach(ts.supportedExtensions, function (extension) { + referencedSourceFile = ts.forEach(extensions, function (extension) { if (extension === ".tsx" && !compilerOptions.jsx) { return undefined; } @@ -30220,7 +30737,7 @@ var ts; return emitResult; } function getSourceFile(fileName) { - return filesByName.get(fileName); + return filesByName.get(fileName) || filesByName.get(ts.getNormalizedAbsolutePath(fileName, host.getCurrentDirectory())); } function getDiagnosticsHelper(sourceFile, getDiagnostics, cancellationToken) { if (sourceFile) { @@ -30306,13 +30823,18 @@ var ts; if (file.imports) { return; } + var isJavaScriptFile = ts.isSourceFileJavaScript(file); var imports; for (var _i = 0, _a = file.statements; _i < _a.length; _i++) { var node = _a[_i]; + collect(node, true); + } + file.imports = imports || emptyArray; + function collect(node, allowRelativeModuleNames) { switch (node.kind) { - case 220: - case 219: - case 226: + case 222: + case 221: + case 228: var moduleNameExpr = ts.getExternalModuleName(node); if (!moduleNameExpr || moduleNameExpr.kind !== 9) { break; @@ -30320,24 +30842,35 @@ var ts; if (!moduleNameExpr.text) { break; } - (imports || (imports = [])).push(moduleNameExpr); + if (allowRelativeModuleNames || !ts.isExternalModuleNameRelative(moduleNameExpr.text)) { + (imports || (imports = [])).push(moduleNameExpr); + } break; - case 216: - if (node.name.kind === 9 && (node.flags & 2 || ts.isDeclarationFile(file))) { - ts.forEachChild(node.body, function (node) { - if (ts.isExternalModuleImportEqualsDeclaration(node) && - ts.getExternalModuleImportEqualsDeclarationExpression(node).kind === 9) { - var moduleName = ts.getExternalModuleImportEqualsDeclarationExpression(node); - if (moduleName) { - (imports || (imports = [])).push(moduleName); + case 168: + if (isJavaScriptFile && ts.isRequireCall(node)) { + var jsImports = node.arguments; + if (jsImports) { + imports = (imports || []); + for (var i = 0; i < jsImports.length; i++) { + if (jsImports[i].kind === 9) { + imports.push(jsImports[i]); } } + } + } + break; + case 218: + if (node.name.kind === 9 && (node.flags & 2 || ts.isDeclarationFile(file))) { + ts.forEachChild(node.body, function (node) { + collect(node, false); }); } break; } + if (ts.isSourceFileJavaScript(file)) { + ts.forEachChild(node, function (node) { return collect(node, allowRelativeModuleNames); }); + } } - file.imports = imports || emptyArray; } function processSourceFile(fileName, isDefaultLib, refFile, refPos, refEnd) { var diagnosticArgument; @@ -30380,48 +30913,46 @@ var ts; } } function findSourceFile(fileName, isDefaultLib, refFile, refPos, refEnd) { - var canonicalName = host.getCanonicalFileName(ts.normalizeSlashes(fileName)); - if (filesByName.contains(canonicalName)) { - return getSourceFileFromCache(fileName, canonicalName, false); + if (filesByName.contains(fileName)) { + return getSourceFileFromCache(fileName, false); } - else { - var normalizedAbsolutePath = ts.getNormalizedAbsolutePath(fileName, host.getCurrentDirectory()); - var canonicalAbsolutePath = host.getCanonicalFileName(normalizedAbsolutePath); - if (filesByName.contains(canonicalAbsolutePath)) { - return getSourceFileFromCache(normalizedAbsolutePath, canonicalAbsolutePath, true); - } - var file = host.getSourceFile(fileName, options.target, function (hostErrorMessage) { - if (refFile !== undefined && refPos !== undefined && refEnd !== undefined) { - fileProcessingDiagnostics.add(ts.createFileDiagnostic(refFile, refPos, refEnd - refPos, ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage)); - } - else { - fileProcessingDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage)); - } - }); - filesByName.set(canonicalName, file); - if (file) { - skipDefaultLib = skipDefaultLib || file.hasNoDefaultLib; - filesByName.set(canonicalAbsolutePath, file); - var basePath = ts.getDirectoryPath(fileName); - if (!options.noResolve) { - processReferencedFiles(file, basePath); - } - processImportedModules(file, basePath); - if (isDefaultLib) { - file.isDefaultLib = true; - files.unshift(file); - } - else { - files.push(file); - } - } - return file; + var normalizedAbsolutePath = ts.getNormalizedAbsolutePath(fileName, host.getCurrentDirectory()); + if (filesByName.contains(normalizedAbsolutePath)) { + var file_1 = getSourceFileFromCache(normalizedAbsolutePath, true); + filesByName.set(fileName, file_1); + return file_1; } - function getSourceFileFromCache(fileName, canonicalName, useAbsolutePath) { - var file = filesByName.get(canonicalName); + var file = host.getSourceFile(fileName, options.target, function (hostErrorMessage) { + if (refFile !== undefined && refPos !== undefined && refEnd !== undefined) { + fileProcessingDiagnostics.add(ts.createFileDiagnostic(refFile, refPos, refEnd - refPos, ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage)); + } + else { + fileProcessingDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage)); + } + }); + filesByName.set(fileName, file); + if (file) { + skipDefaultLib = skipDefaultLib || file.hasNoDefaultLib; + filesByName.set(normalizedAbsolutePath, file); + var basePath = ts.getDirectoryPath(fileName); + if (!options.noResolve) { + processReferencedFiles(file, basePath); + } + processImportedModules(file, basePath); + if (isDefaultLib) { + file.isDefaultLib = true; + files.unshift(file); + } + else { + files.push(file); + } + } + return file; + function getSourceFileFromCache(fileName, useAbsolutePath) { + var file = filesByName.get(fileName); if (file && host.useCaseSensitiveFileNames()) { var sourceFileName = useAbsolutePath ? ts.getNormalizedAbsolutePath(file.fileName, host.getCurrentDirectory()) : file.fileName; - if (canonicalName !== sourceFileName) { + if (ts.normalizeSlashes(fileName) !== ts.normalizeSlashes(sourceFileName)) { if (refFile !== undefined && refPos !== undefined && refEnd !== undefined) { fileProcessingDiagnostics.add(ts.createFileDiagnostic(refFile, refPos, refEnd - refPos, ts.Diagnostics.File_name_0_differs_from_already_included_file_name_1_only_in_casing, fileName, sourceFileName)); } @@ -30582,8 +31113,8 @@ var ts; var span = ts.getErrorSpanForNode(firstExternalModuleSourceFile, firstExternalModuleSourceFile.externalModuleIndicator); programDiagnostics.add(ts.createFileDiagnostic(firstExternalModuleSourceFile, span.start, span.length, ts.Diagnostics.Cannot_compile_modules_unless_the_module_flag_is_provided)); } - if (options.module && languageVersion >= 2) { - programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_compile_modules_into_commonjs_amd_system_or_umd_when_targeting_ES6_or_higher)); + if (options.module === 5 && languageVersion < 2) { + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_compile_modules_into_es6_when_targeting_ES5_or_lower)); } if (options.outDir || options.sourceRoot || @@ -30617,10 +31148,6 @@ var ts; !options.experimentalDecorators) { programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "emitDecoratorMetadata", "experimentalDecorators")); } - if (options.experimentalAsyncFunctions && - options.target !== 2) { - programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_experimentalAsyncFunctions_cannot_be_specified_when_targeting_ES5_or_lower)); - } } } ts.createProgram = createProgram; @@ -30663,98 +31190,98 @@ var ts; function spanInNode(node) { if (node) { if (ts.isExpression(node)) { - if (node.parent.kind === 195) { + if (node.parent.kind === 197) { return spanInPreviousNode(node); } - if (node.parent.kind === 197) { + if (node.parent.kind === 199) { return textSpan(node); } - if (node.parent.kind === 179 && node.parent.operatorToken.kind === 24) { + if (node.parent.kind === 181 && node.parent.operatorToken.kind === 24) { return textSpan(node); } - if (node.parent.kind === 172 && node.parent.body === node) { + if (node.parent.kind === 174 && node.parent.body === node) { return textSpan(node); } } switch (node.kind) { - case 191: + case 193: return spanInVariableDeclaration(node.declarationList.declarations[0]); - case 209: - case 139: - case 138: - return spanInVariableDeclaration(node); - case 136: - return spanInParameterDeclaration(node); case 211: case 141: case 140: + return spanInVariableDeclaration(node); + case 138: + return spanInParameterDeclaration(node); + case 213: case 143: - case 144: case 142: - case 171: - case 172: + case 145: + case 146: + case 144: + case 173: + case 174: return spanInFunctionDeclaration(node); - case 190: + case 192: if (ts.isFunctionBlock(node)) { return spanInFunctionBlock(node); } - case 217: + case 219: return spanInBlock(node); - case 242: + case 244: return spanInBlock(node.block); - case 193: + case 195: return textSpan(node.expression); - case 202: + case 204: return textSpan(node.getChildAt(0), node.expression); + case 198: + return textSpan(node, ts.findNextToken(node.expression, node)); + case 197: + return spanInNode(node.statement); + case 210: + return textSpan(node.getChildAt(0)); case 196: return textSpan(node, ts.findNextToken(node.expression, node)); - case 195: - return spanInNode(node.statement); - case 208: - return textSpan(node.getChildAt(0)); - case 194: - return textSpan(node, ts.findNextToken(node.expression, node)); - case 205: - return spanInNode(node.statement); - case 201: - case 200: - return textSpan(node.getChildAt(0), node.label); - case 197: - return spanInForStatement(node); - case 198: - case 199: - return textSpan(node, ts.findNextToken(node.expression, node)); - case 204: - return textSpan(node, ts.findNextToken(node.expression, node)); - case 239: - case 240: - return spanInNode(node.statements[0]); case 207: - return spanInBlock(node.tryBlock); + return spanInNode(node.statement); + case 203: + case 202: + return textSpan(node.getChildAt(0), node.label); + case 199: + return spanInForStatement(node); + case 200: + case 201: + return textSpan(node, ts.findNextToken(node.expression, node)); case 206: + return textSpan(node, ts.findNextToken(node.expression, node)); + case 241: + case 242: + return spanInNode(node.statements[0]); + case 209: + return spanInBlock(node.tryBlock); + case 208: return textSpan(node, node.expression); - case 225: + case 227: return textSpan(node, node.expression); - case 219: + case 221: return textSpan(node, node.moduleReference); - case 220: + case 222: return textSpan(node, node.moduleSpecifier); - case 226: + case 228: return textSpan(node, node.moduleSpecifier); - case 216: + case 218: if (ts.getModuleInstanceState(node) !== 1) { return undefined; } - case 212: - case 215: - case 245: - case 166: - case 167: - return textSpan(node); - case 203: - return spanInNode(node.statement); - case 213: case 214: + case 217: + case 247: + case 168: + case 169: + return textSpan(node); + case 205: + return spanInNode(node.statement); + case 215: + case 216: return undefined; case 23: case 1: @@ -30769,22 +31296,22 @@ var ts; return spanInOpenParenToken(node); case 18: return spanInCloseParenToken(node); - case 53: + case 54: return spanInColonToken(node); case 27: case 25: return spanInGreaterThanOrLessThanToken(node); - case 102: + case 104: return spanInWhileKeyword(node); - case 78: - case 70: - case 83: + case 80: + case 72: + case 85: return spanInNextNode(node); default: - if (node.parent.kind === 243 && node.parent.name === node) { + if (node.parent.kind === 245 && node.parent.name === node) { return spanInNode(node.parent.initializer); } - if (node.parent.kind === 169 && node.parent.type === node) { + if (node.parent.kind === 171 && node.parent.type === node) { return spanInNode(node.parent.expression); } if (ts.isFunctionLike(node.parent) && node.parent.type === node) { @@ -30794,12 +31321,12 @@ var ts; } } function spanInVariableDeclaration(variableDeclaration) { - if (variableDeclaration.parent.parent.kind === 198 || - variableDeclaration.parent.parent.kind === 199) { + if (variableDeclaration.parent.parent.kind === 200 || + variableDeclaration.parent.parent.kind === 201) { return spanInNode(variableDeclaration.parent.parent); } - var isParentVariableStatement = variableDeclaration.parent.parent.kind === 191; - var isDeclarationOfForStatement = variableDeclaration.parent.parent.kind === 197 && ts.contains(variableDeclaration.parent.parent.initializer.declarations, variableDeclaration); + var isParentVariableStatement = variableDeclaration.parent.parent.kind === 193; + var isDeclarationOfForStatement = variableDeclaration.parent.parent.kind === 199 && ts.contains(variableDeclaration.parent.parent.initializer.declarations, variableDeclaration); var declarations = isParentVariableStatement ? variableDeclaration.parent.parent.declarationList.declarations : isDeclarationOfForStatement @@ -30845,7 +31372,7 @@ var ts; } function canFunctionHaveSpanInWholeDeclaration(functionDeclaration) { return !!(functionDeclaration.flags & 1) || - (functionDeclaration.parent.kind === 212 && functionDeclaration.kind !== 142); + (functionDeclaration.parent.kind === 214 && functionDeclaration.kind !== 144); } function spanInFunctionDeclaration(functionDeclaration) { if (!functionDeclaration.body) { @@ -30865,23 +31392,23 @@ var ts; } function spanInBlock(block) { switch (block.parent.kind) { - case 216: + case 218: if (ts.getModuleInstanceState(block.parent) !== 1) { return undefined; } - case 196: - case 194: case 198: - case 199: + case 196: + case 200: + case 201: return spanInNodeIfStartsOnSameLine(block.parent, block.statements[0]); - case 197: + case 199: return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(block.pos, sourceFile, block.parent), block.statements[0]); } return spanInNode(block.statements[0]); } function spanInForStatement(forStatement) { if (forStatement.initializer) { - if (forStatement.initializer.kind === 210) { + if (forStatement.initializer.kind === 212) { var variableDeclarationList = forStatement.initializer; if (variableDeclarationList.declarations.length > 0) { return spanInNode(variableDeclarationList.declarations[0]); @@ -30900,34 +31427,34 @@ var ts; } function spanInOpenBraceToken(node) { switch (node.parent.kind) { - case 215: + case 217: var enumDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), enumDeclaration.members.length ? enumDeclaration.members[0] : enumDeclaration.getLastToken(sourceFile)); - case 212: + case 214: var classDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), classDeclaration.members.length ? classDeclaration.members[0] : classDeclaration.getLastToken(sourceFile)); - case 218: + case 220: return spanInNodeIfStartsOnSameLine(node.parent.parent, node.parent.clauses[0]); } return spanInNode(node.parent); } function spanInCloseBraceToken(node) { switch (node.parent.kind) { - case 217: + case 219: if (ts.getModuleInstanceState(node.parent.parent) !== 1) { return undefined; } - case 215: - case 212: + case 217: + case 214: return textSpan(node); - case 190: + case 192: if (ts.isFunctionBlock(node.parent)) { return textSpan(node); } - case 242: + case 244: return spanInNode(ts.lastOrUndefined(node.parent.statements)); ; - case 218: + case 220: var caseBlock = node.parent; var lastClause = ts.lastOrUndefined(caseBlock.clauses); if (lastClause) { @@ -30939,24 +31466,24 @@ var ts; } } function spanInOpenParenToken(node) { - if (node.parent.kind === 195) { + if (node.parent.kind === 197) { return spanInPreviousNode(node); } return spanInNode(node.parent); } function spanInCloseParenToken(node) { switch (node.parent.kind) { - case 171: - case 211: - case 172: - case 141: - case 140: + case 173: + case 213: + case 174: case 143: - case 144: case 142: - case 196: - case 195: + case 145: + case 146: + case 144: + case 198: case 197: + case 199: return spanInPreviousNode(node); default: return spanInNode(node.parent); @@ -30964,19 +31491,19 @@ var ts; return spanInNode(node.parent); } function spanInColonToken(node) { - if (ts.isFunctionLike(node.parent) || node.parent.kind === 243) { + if (ts.isFunctionLike(node.parent) || node.parent.kind === 245) { return spanInPreviousNode(node); } return spanInNode(node.parent); } function spanInGreaterThanOrLessThanToken(node) { - if (node.parent.kind === 169) { + if (node.parent.kind === 171) { return spanInNode(node.parent.expression); } return spanInNode(node.parent); } function spanInWhileKeyword(node) { - if (node.parent.kind === 195) { + if (node.parent.kind === 197) { return textSpan(node, ts.findNextToken(node.parent.expression, node.parent)); } return spanInNode(node.parent); @@ -31054,7 +31581,7 @@ var ts; } } function autoCollapse(node) { - return ts.isFunctionBlock(node) && node.parent.kind !== 172; + return ts.isFunctionBlock(node) && node.parent.kind !== 174; } var depth = 0; var maxDepth = 20; @@ -31066,30 +31593,30 @@ var ts; addOutliningForLeadingCommentsForNode(n); } switch (n.kind) { - case 190: + case 192: if (!ts.isFunctionBlock(n)) { var parent_7 = n.parent; var openBrace = ts.findChildOfKind(n, 15, sourceFile); var closeBrace = ts.findChildOfKind(n, 16, sourceFile); - if (parent_7.kind === 195 || - parent_7.kind === 198 || + if (parent_7.kind === 197 || + parent_7.kind === 200 || + parent_7.kind === 201 || parent_7.kind === 199 || - parent_7.kind === 197 || - parent_7.kind === 194 || parent_7.kind === 196 || - parent_7.kind === 203 || - parent_7.kind === 242) { + parent_7.kind === 198 || + parent_7.kind === 205 || + parent_7.kind === 244) { addOutliningSpan(parent_7, openBrace, closeBrace, autoCollapse(n)); break; } - if (parent_7.kind === 207) { + if (parent_7.kind === 209) { var tryStatement = parent_7; if (tryStatement.tryBlock === n) { addOutliningSpan(parent_7, openBrace, closeBrace, autoCollapse(n)); break; } else if (tryStatement.finallyBlock === n) { - var finallyKeyword = ts.findChildOfKind(tryStatement, 83, sourceFile); + var finallyKeyword = ts.findChildOfKind(tryStatement, 85, sourceFile); if (finallyKeyword) { addOutliningSpan(finallyKeyword, openBrace, closeBrace, autoCollapse(n)); break; @@ -31105,23 +31632,23 @@ var ts; }); break; } - case 217: { + case 219: { var openBrace = ts.findChildOfKind(n, 15, sourceFile); var closeBrace = ts.findChildOfKind(n, 16, sourceFile); addOutliningSpan(n.parent, openBrace, closeBrace, autoCollapse(n)); break; } - case 212: - case 213: + case 214: case 215: - case 163: - case 218: { + case 217: + case 165: + case 220: { var openBrace = ts.findChildOfKind(n, 15, sourceFile); var closeBrace = ts.findChildOfKind(n, 16, sourceFile); addOutliningSpan(n, openBrace, closeBrace, autoCollapse(n)); break; } - case 162: + case 164: var openBracket = ts.findChildOfKind(n, 19, sourceFile); var closeBracket = ts.findChildOfKind(n, 20, sourceFile); addOutliningSpan(n, openBracket, closeBracket, autoCollapse(n)); @@ -31147,10 +31674,10 @@ var ts; ts.forEach(program.getSourceFiles(), function (sourceFile) { cancellationToken.throwIfCancellationRequested(); var nameToDeclarations = sourceFile.getNamedDeclarations(); - for (var name_28 in nameToDeclarations) { - var declarations = ts.getProperty(nameToDeclarations, name_28); + for (var name_29 in nameToDeclarations) { + var declarations = ts.getProperty(nameToDeclarations, name_29); if (declarations) { - var matches = patternMatcher.getMatchesForLastSegmentOfPattern(name_28); + var matches = patternMatcher.getMatchesForLastSegmentOfPattern(name_29); if (!matches) { continue; } @@ -31161,14 +31688,14 @@ var ts; if (!containers) { return undefined; } - matches = patternMatcher.getMatches(containers, name_28); + matches = patternMatcher.getMatches(containers, name_29); if (!matches) { continue; } } var fileName = sourceFile.fileName; var matchKind = bestMatchKind(matches); - rawItems.push({ name: name_28, fileName: fileName, matchKind: matchKind, isCaseSensitive: allMatchesAreCaseSensitive(matches), declaration: declaration }); + rawItems.push({ name: name_29, fileName: fileName, matchKind: matchKind, isCaseSensitive: allMatchesAreCaseSensitive(matches), declaration: declaration }); } } } @@ -31191,7 +31718,7 @@ var ts; } function getTextOfIdentifierOrLiteral(node) { if (node) { - if (node.kind === 67 || + if (node.kind === 69 || node.kind === 9 || node.kind === 8) { return node.text; @@ -31205,7 +31732,7 @@ var ts; if (text !== undefined) { containers.unshift(text); } - else if (declaration.name.kind === 134) { + else if (declaration.name.kind === 136) { return tryAddComputedPropertyName(declaration.name.expression, containers, true); } else { @@ -31222,7 +31749,7 @@ var ts; } return true; } - if (expression.kind === 164) { + if (expression.kind === 166) { var propertyAccess = expression; if (includeLastPortion) { containers.unshift(propertyAccess.name.text); @@ -31233,7 +31760,7 @@ var ts; } function getContainers(declaration) { var containers = []; - if (declaration.name.kind === 134) { + if (declaration.name.kind === 136) { if (!tryAddComputedPropertyName(declaration.name.expression, containers, false)) { return undefined; } @@ -31296,14 +31823,14 @@ var ts; var current = node.parent; while (current) { switch (current.kind) { - case 216: + case 218: do { current = current.parent; - } while (current.kind === 216); - case 212: + } while (current.kind === 218); + case 214: + case 217: case 215: case 213: - case 211: indent++; } current = current.parent; @@ -31314,26 +31841,26 @@ var ts; var childNodes = []; function visit(node) { switch (node.kind) { - case 191: + case 193: ts.forEach(node.declarationList.declarations, visit); break; - case 159: - case 160: + case 161: + case 162: ts.forEach(node.elements, visit); break; - case 226: + case 228: if (node.exportClause) { ts.forEach(node.exportClause.elements, visit); } break; - case 220: + case 222: var importClause = node.importClause; if (importClause) { if (importClause.name) { childNodes.push(importClause); } if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 222) { + if (importClause.namedBindings.kind === 224) { childNodes.push(importClause.namedBindings); } else { @@ -31342,20 +31869,20 @@ var ts; } } break; - case 161: - case 209: + case 163: + case 211: if (ts.isBindingPattern(node.name)) { visit(node.name); break; } - case 212: + case 214: + case 217: case 215: + case 218: case 213: - case 216: - case 211: - case 219: - case 224: - case 228: + case 221: + case 226: + case 230: childNodes.push(node); break; } @@ -31390,17 +31917,17 @@ var ts; for (var _i = 0; _i < nodes.length; _i++) { var node = nodes[_i]; switch (node.kind) { - case 212: + case 214: + case 217: case 215: - case 213: topLevelNodes.push(node); break; - case 216: + case 218: var moduleDeclaration = node; topLevelNodes.push(node); addTopLevelNodes(getInnermostModule(moduleDeclaration).body.statements, topLevelNodes); break; - case 211: + case 213: var functionDeclaration = node; if (isTopLevelFunctionDeclaration(functionDeclaration)) { topLevelNodes.push(node); @@ -31411,9 +31938,9 @@ var ts; } } function isTopLevelFunctionDeclaration(functionDeclaration) { - if (functionDeclaration.kind === 211) { - if (functionDeclaration.body && functionDeclaration.body.kind === 190) { - if (ts.forEach(functionDeclaration.body.statements, function (s) { return s.kind === 211 && !isEmpty(s.name.text); })) { + if (functionDeclaration.kind === 213) { + if (functionDeclaration.body && functionDeclaration.body.kind === 192) { + if (ts.forEach(functionDeclaration.body.statements, function (s) { return s.kind === 213 && !isEmpty(s.name.text); })) { return true; } if (!ts.isFunctionBlock(functionDeclaration.parent)) { @@ -31466,7 +31993,7 @@ var ts; } function createChildItem(node) { switch (node.kind) { - case 136: + case 138: if (ts.isBindingPattern(node.name)) { break; } @@ -31474,34 +32001,34 @@ var ts; return undefined; } return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberVariableElement); + case 143: + case 142: + return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberFunctionElement); + case 145: + return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberGetAccessorElement); + case 146: + return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberSetAccessorElement); + case 149: + return createItem(node, "[]", ts.ScriptElementKind.indexSignatureElement); + case 247: + return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberVariableElement); + case 147: + return createItem(node, "()", ts.ScriptElementKind.callSignatureElement); + case 148: + return createItem(node, "new()", ts.ScriptElementKind.constructSignatureElement); case 141: case 140: - return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberFunctionElement); - case 143: - return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberGetAccessorElement); - case 144: - return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberSetAccessorElement); - case 147: - return createItem(node, "[]", ts.ScriptElementKind.indexSignatureElement); - case 245: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberVariableElement); - case 145: - return createItem(node, "()", ts.ScriptElementKind.callSignatureElement); - case 146: - return createItem(node, "new()", ts.ScriptElementKind.constructSignatureElement); - case 139: - case 138: - return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberVariableElement); - case 211: + case 213: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.functionElement); - case 209: - case 161: + case 211: + case 163: var variableDeclarationNode; - var name_29; - if (node.kind === 161) { - name_29 = node.name; + var name_30; + if (node.kind === 163) { + name_30 = node.name; variableDeclarationNode = node; - while (variableDeclarationNode && variableDeclarationNode.kind !== 209) { + while (variableDeclarationNode && variableDeclarationNode.kind !== 211) { variableDeclarationNode = variableDeclarationNode.parent; } ts.Debug.assert(variableDeclarationNode !== undefined); @@ -31509,24 +32036,24 @@ var ts; else { ts.Debug.assert(!ts.isBindingPattern(node.name)); variableDeclarationNode = node; - name_29 = node.name; + name_30 = node.name; } if (ts.isConst(variableDeclarationNode)) { - return createItem(node, getTextOfNode(name_29), ts.ScriptElementKind.constElement); + return createItem(node, getTextOfNode(name_30), ts.ScriptElementKind.constElement); } else if (ts.isLet(variableDeclarationNode)) { - return createItem(node, getTextOfNode(name_29), ts.ScriptElementKind.letElement); + return createItem(node, getTextOfNode(name_30), ts.ScriptElementKind.letElement); } else { - return createItem(node, getTextOfNode(name_29), ts.ScriptElementKind.variableElement); + return createItem(node, getTextOfNode(name_30), ts.ScriptElementKind.variableElement); } - case 142: + case 144: return createItem(node, "constructor", ts.ScriptElementKind.constructorImplementationElement); - case 228: - case 224: - case 219: + case 230: + case 226: case 221: - case 222: + case 223: + case 224: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.alias); } return undefined; @@ -31556,17 +32083,17 @@ var ts; } function createTopLevelItem(node) { switch (node.kind) { - case 246: + case 248: return createSourceFileItem(node); - case 212: + case 214: return createClassItem(node); - case 215: + case 217: return createEnumItem(node); - case 213: + case 215: return createIterfaceItem(node); - case 216: + case 218: return createModuleItem(node); - case 211: + case 213: return createFunctionItem(node); } return undefined; @@ -31576,7 +32103,7 @@ var ts; } var result = []; result.push(moduleDeclaration.name.text); - while (moduleDeclaration.body && moduleDeclaration.body.kind === 216) { + while (moduleDeclaration.body && moduleDeclaration.body.kind === 218) { moduleDeclaration = moduleDeclaration.body; result.push(moduleDeclaration.name.text); } @@ -31588,7 +32115,7 @@ var ts; return getNavigationBarItem(moduleName, ts.ScriptElementKind.moduleElement, ts.getNodeModifiers(node), [getNodeSpan(node)], childItems, getIndent(node)); } function createFunctionItem(node) { - if (node.body && node.body.kind === 190) { + if (node.body && node.body.kind === 192) { var childItems = getItemsWorker(sortNodes(node.body.statements), createChildItem); return getNavigationBarItem(!node.name ? "default" : node.name.text, ts.ScriptElementKind.functionElement, ts.getNodeModifiers(node), [getNodeSpan(node)], childItems, getIndent(node)); } @@ -31609,7 +32136,7 @@ var ts; var childItems; if (node.members) { var constructor = ts.forEach(node.members, function (member) { - return member.kind === 142 && member; + return member.kind === 144 && member; }); var nodes = removeDynamicallyNamedProperties(node); if (constructor) { @@ -31630,19 +32157,19 @@ var ts; } } function removeComputedProperties(node) { - return ts.filter(node.members, function (member) { return member.name === undefined || member.name.kind !== 134; }); + return ts.filter(node.members, function (member) { return member.name === undefined || member.name.kind !== 136; }); } function removeDynamicallyNamedProperties(node) { return ts.filter(node.members, function (member) { return !ts.hasDynamicName(member); }); } function getInnermostModule(node) { - while (node.body.kind === 216) { + while (node.body.kind === 218) { node = node.body; } return node; } function getNodeSpan(node) { - return node.kind === 246 + return node.kind === 248 ? ts.createTextSpanFromBounds(node.getFullStart(), node.getEnd()) : ts.createTextSpanFromBounds(node.getStart(), node.getEnd()); } @@ -32125,21 +32652,21 @@ var ts; var resolvedSignature = typeChecker.getResolvedSignature(call, candidates); cancellationToken.throwIfCancellationRequested(); if (!candidates.length) { - if (ts.isJavaScript(sourceFile.fileName)) { + if (ts.isSourceFileJavaScript(sourceFile)) { return createJavaScriptSignatureHelpItems(argumentInfo); } return undefined; } return createSignatureHelpItems(candidates, resolvedSignature, argumentInfo); function createJavaScriptSignatureHelpItems(argumentInfo) { - if (argumentInfo.invocation.kind !== 166) { + if (argumentInfo.invocation.kind !== 168) { return undefined; } var callExpression = argumentInfo.invocation; var expression = callExpression.expression; - var name = expression.kind === 67 + var name = expression.kind === 69 ? expression - : expression.kind === 164 + : expression.kind === 166 ? expression.name : undefined; if (!name || !name.text) { @@ -32168,7 +32695,7 @@ var ts; } } function getImmediatelyContainingArgumentInfo(node) { - if (node.parent.kind === 166 || node.parent.kind === 167) { + if (node.parent.kind === 168 || node.parent.kind === 169) { var callExpression = node.parent; if (node.kind === 25 || node.kind === 17) { @@ -32199,23 +32726,23 @@ var ts; }; } } - else if (node.kind === 11 && node.parent.kind === 168) { + else if (node.kind === 11 && node.parent.kind === 170) { if (ts.isInsideTemplateLiteral(node, position)) { return getArgumentListInfoForTemplate(node.parent, 0); } } - else if (node.kind === 12 && node.parent.parent.kind === 168) { + else if (node.kind === 12 && node.parent.parent.kind === 170) { var templateExpression = node.parent; var tagExpression = templateExpression.parent; - ts.Debug.assert(templateExpression.kind === 181); + ts.Debug.assert(templateExpression.kind === 183); var argumentIndex = ts.isInsideTemplateLiteral(node, position) ? 0 : 1; return getArgumentListInfoForTemplate(tagExpression, argumentIndex); } - else if (node.parent.kind === 188 && node.parent.parent.parent.kind === 168) { + else if (node.parent.kind === 190 && node.parent.parent.parent.kind === 170) { var templateSpan = node.parent; var templateExpression = templateSpan.parent; var tagExpression = templateExpression.parent; - ts.Debug.assert(templateExpression.kind === 181); + ts.Debug.assert(templateExpression.kind === 183); if (node.kind === 14 && !ts.isInsideTemplateLiteral(node, position)) { return undefined; } @@ -32279,7 +32806,7 @@ var ts; var template = taggedTemplate.template; var applicableSpanStart = template.getStart(); var applicableSpanEnd = template.getEnd(); - if (template.kind === 181) { + if (template.kind === 183) { var lastSpan = ts.lastOrUndefined(template.templateSpans); if (lastSpan.literal.getFullWidth() === 0) { applicableSpanEnd = ts.skipTrivia(sourceFile.text, applicableSpanEnd, false); @@ -32288,7 +32815,7 @@ var ts; return ts.createTextSpan(applicableSpanStart, applicableSpanEnd - applicableSpanStart); } function getContainingArgumentInfo(node) { - for (var n = node; n.kind !== 246; n = n.parent) { + for (var n = node; n.kind !== 248; n = n.parent) { if (ts.isFunctionBlock(n)) { return undefined; } @@ -32468,39 +32995,39 @@ var ts; return false; } switch (n.kind) { - case 212: - case 213: + case 214: case 215: - case 163: - case 159: - case 153: - case 190: case 217: - case 218: + case 165: + case 161: + case 155: + case 192: + case 219: + case 220: return nodeEndsWith(n, 16, sourceFile); - case 242: + case 244: return isCompletedNode(n.block, sourceFile); - case 167: + case 169: if (!n.arguments) { return true; } - case 166: - case 170: - case 158: - return nodeEndsWith(n, 18, sourceFile); - case 150: - case 151: - return isCompletedNode(n.type, sourceFile); - case 142: - case 143: - case 144: - case 211: - case 171: - case 141: - case 140: - case 146: - case 145: + case 168: case 172: + case 160: + return nodeEndsWith(n, 18, sourceFile); + case 152: + case 153: + return isCompletedNode(n.type, sourceFile); + case 144: + case 145: + case 146: + case 213: + case 173: + case 143: + case 142: + case 148: + case 147: + case 174: if (n.body) { return isCompletedNode(n.body, sourceFile); } @@ -32508,61 +33035,62 @@ var ts; return isCompletedNode(n.type, sourceFile); } return hasChildOfKind(n, 18, sourceFile); - case 216: + case 218: return n.body && isCompletedNode(n.body, sourceFile); - case 194: + case 196: if (n.elseStatement) { return isCompletedNode(n.elseStatement, sourceFile); } return isCompletedNode(n.thenStatement, sourceFile); - case 193: - return isCompletedNode(n.expression, sourceFile); + case 195: + return isCompletedNode(n.expression, sourceFile) || + hasChildOfKind(n, 23); + case 164: case 162: - case 160: - case 165: - case 134: - case 155: + case 167: + case 136: + case 157: return nodeEndsWith(n, 20, sourceFile); - case 147: + case 149: if (n.type) { return isCompletedNode(n.type, sourceFile); } return hasChildOfKind(n, 20, sourceFile); - case 239: - case 240: + case 241: + case 242: return false; - case 197: - case 198: case 199: - case 196: + case 200: + case 201: + case 198: return isCompletedNode(n.statement, sourceFile); - case 195: - var hasWhileKeyword = findChildOfKind(n, 102, sourceFile); + case 197: + var hasWhileKeyword = findChildOfKind(n, 104, sourceFile); if (hasWhileKeyword) { return nodeEndsWith(n, 18, sourceFile); } return isCompletedNode(n.statement, sourceFile); - case 152: + case 154: return isCompletedNode(n.exprName, sourceFile); - case 174: - case 173: + case 176: case 175: - case 182: - case 183: + case 177: + case 184: + case 185: var unaryWordExpression = n; return isCompletedNode(unaryWordExpression.expression, sourceFile); - case 168: + case 170: return isCompletedNode(n.template, sourceFile); - case 181: + case 183: var lastSpan = ts.lastOrUndefined(n.templateSpans); return isCompletedNode(lastSpan, sourceFile); - case 188: + case 190: return ts.nodeIsPresent(n.literal); - case 177: - return isCompletedNode(n.operand, sourceFile); case 179: + return isCompletedNode(n.operand, sourceFile); + case 181: return isCompletedNode(n.right, sourceFile); - case 180: + case 182: return isCompletedNode(n.whenFalse, sourceFile); default: return true; @@ -32605,7 +33133,7 @@ var ts; ts.findChildOfKind = findChildOfKind; function findContainingList(node) { var syntaxList = ts.forEach(node.parent.getChildren(), function (c) { - if (c.kind === 269 && c.pos <= node.pos && c.end >= node.end) { + if (c.kind === 271 && c.pos <= node.pos && c.end >= node.end) { return c; } }); @@ -32685,7 +33213,7 @@ var ts; function findPrecedingToken(position, sourceFile, startNode) { return find(startNode || sourceFile); function findRightmostToken(n) { - if (isToken(n) || n.kind === 234) { + if (isToken(n) || n.kind === 236) { return n; } var children = n.getChildren(); @@ -32693,16 +33221,16 @@ var ts; return candidate && findRightmostToken(candidate); } function find(n) { - if (isToken(n) || n.kind === 234) { + if (isToken(n) || n.kind === 236) { return n; } var children = n.getChildren(); for (var i = 0, len = children.length; i < len; i++) { var child = children[i]; - if (position < child.end && (nodeHasTokens(child) || child.kind === 234)) { + if (position < child.end && (nodeHasTokens(child) || child.kind === 236)) { var start = child.getStart(sourceFile); var lookInPreviousChild = (start >= position) || - (child.kind === 234 && start === child.end); + (child.kind === 236 && start === child.end); if (lookInPreviousChild) { var candidate = findRightmostChildNodeWithTokens(children, i); return candidate && findRightmostToken(candidate); @@ -32712,7 +33240,7 @@ var ts; } } } - ts.Debug.assert(startNode !== undefined || n.kind === 246); + ts.Debug.assert(startNode !== undefined || n.kind === 248); if (children.length) { var candidate = findRightmostChildNodeWithTokens(children, children.length); return candidate && findRightmostToken(candidate); @@ -32764,9 +33292,9 @@ var ts; var node = ts.getTokenAtPosition(sourceFile, position); if (isToken(node)) { switch (node.kind) { - case 100: - case 106: - case 72: + case 102: + case 108: + case 74: node = node.parent === undefined ? undefined : node.parent.parent; break; default: @@ -32812,21 +33340,21 @@ var ts; } ts.getNodeModifiers = getNodeModifiers; function getTypeArgumentOrTypeParameterList(node) { - if (node.kind === 149 || node.kind === 166) { + if (node.kind === 151 || node.kind === 168) { return node.typeArguments; } - if (ts.isFunctionLike(node) || node.kind === 212 || node.kind === 213) { + if (ts.isFunctionLike(node) || node.kind === 214 || node.kind === 215) { return node.typeParameters; } return undefined; } ts.getTypeArgumentOrTypeParameterList = getTypeArgumentOrTypeParameterList; function isToken(n) { - return n.kind >= 0 && n.kind <= 132; + return n.kind >= 0 && n.kind <= 134; } ts.isToken = isToken; function isWord(kind) { - return kind === 67 || ts.isKeyword(kind); + return kind === 69 || ts.isKeyword(kind); } ts.isWord = isWord; function isPropertyName(kind) { @@ -32836,8 +33364,17 @@ var ts; return kind === 2 || kind === 3; } ts.isComment = isComment; + function isStringOrRegularExpressionOrTemplateLiteral(kind) { + if (kind === 9 + || kind === 10 + || ts.isTemplateLiteralKind(kind)) { + return true; + } + return false; + } + ts.isStringOrRegularExpressionOrTemplateLiteral = isStringOrRegularExpressionOrTemplateLiteral; function isPunctuation(kind) { - return 15 <= kind && kind <= 66; + return 15 <= kind && kind <= 68; } ts.isPunctuation = isPunctuation; function isInsideTemplateLiteral(node, position) { @@ -32847,9 +33384,9 @@ var ts; ts.isInsideTemplateLiteral = isInsideTemplateLiteral; function isAccessibilityModifier(kind) { switch (kind) { + case 112: case 110: - case 108: - case 109: + case 111: return true; } return false; @@ -32875,7 +33412,7 @@ var ts; var ts; (function (ts) { function isFirstDeclarationOfSymbolParameter(symbol) { - return symbol.declarations && symbol.declarations.length > 0 && symbol.declarations[0].kind === 136; + return symbol.declarations && symbol.declarations.length > 0 && symbol.declarations[0].kind === 138; } ts.isFirstDeclarationOfSymbolParameter = isFirstDeclarationOfSymbolParameter; var displayPartWriter = getDisplayPartWriter(); @@ -32897,7 +33434,8 @@ var ts; increaseIndent: function () { indent++; }, decreaseIndent: function () { indent--; }, clear: resetWriter, - trackSymbol: function () { } + trackSymbol: function () { }, + reportInaccessibleThisError: function () { } }; function writeIndent() { if (lineStart) { @@ -33055,7 +33593,7 @@ var ts; ts.getDeclaredName = getDeclaredName; function isImportOrExportSpecifierName(location) { return location.parent && - (location.parent.kind === 224 || location.parent.kind === 228) && + (location.parent.kind === 226 || location.parent.kind === 230) && location.parent.propertyName === location; } ts.isImportOrExportSpecifierName = isImportOrExportSpecifierName; @@ -33075,8 +33613,12 @@ var ts; (function (ts) { var formatting; (function (formatting) { - var scanner = ts.createScanner(2, false); + var standardScanner = ts.createScanner(2, false, 0); + var jsxScanner = ts.createScanner(2, false, 1); + var scanner; function getFormattingScanner(sourceFile, startPos, endPos) { + ts.Debug.assert(scanner === undefined); + scanner = sourceFile.languageVariant === 1 ? jsxScanner : standardScanner; scanner.setText(sourceFile.text); scanner.setTextPos(startPos); var wasNewLine = true; @@ -33091,11 +33633,14 @@ var ts; isOnToken: isOnToken, lastTrailingTriviaWasNewLine: function () { return wasNewLine; }, close: function () { + ts.Debug.assert(scanner !== undefined); lastTokenInfo = undefined; scanner.setText(undefined); + scanner = undefined; } }; function advance() { + ts.Debug.assert(scanner !== undefined); lastTokenInfo = undefined; var isStarted = scanner.getStartPos() !== startPos; if (isStarted) { @@ -33137,10 +33682,10 @@ var ts; if (node) { switch (node.kind) { case 29: - case 62: - case 63: + case 64: + case 65: + case 45: case 44: - case 43: return true; } } @@ -33149,11 +33694,11 @@ var ts; function shouldRescanJsxIdentifier(node) { if (node.parent) { switch (node.parent.kind) { - case 236: - case 233: + case 238: case 235: - case 232: - return node.kind === 67; + case 237: + case 234: + return node.kind === 69; } } return false; @@ -33166,9 +33711,10 @@ var ts; container.kind === 14; } function startsWithSlashToken(t) { - return t === 38 || t === 59; + return t === 39 || t === 61; } function readTokenInfo(n) { + ts.Debug.assert(scanner !== undefined); if (!isOnToken()) { return { leadingTrivia: leadingTrivia, @@ -33208,7 +33754,7 @@ var ts; currentToken = scanner.reScanTemplateToken(); lastScanAction = 3; } - else if (expectedScanAction === 4 && currentToken === 67) { + else if (expectedScanAction === 4 && currentToken === 69) { currentToken = scanner.scanJsxIdentifier(); lastScanAction = 4; } @@ -33250,6 +33796,7 @@ var ts; return fixTokenKind(lastTokenInfo, n); } function isOnToken() { + ts.Debug.assert(scanner !== undefined); var current = (lastTokenInfo && lastTokenInfo.token.kind) || scanner.getToken(); var startPos = (lastTokenInfo && lastTokenInfo.token.pos) || scanner.getStartPos(); return startPos < endPos && current !== 1 && !ts.isTrivia(current); @@ -33462,15 +34009,15 @@ var ts; this.IgnoreBeforeComment = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.Comments), formatting.RuleOperation.create1(1)); this.IgnoreAfterLineComment = new formatting.Rule(formatting.RuleDescriptor.create3(2, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create1(1)); this.NoSpaceBeforeSemicolon = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 23), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); - this.NoSpaceBeforeColon = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 53), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 8)); - this.NoSpaceBeforeQuestionMark = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 52), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 8)); - this.SpaceAfterColon = new formatting.Rule(formatting.RuleDescriptor.create3(53, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 2)); - this.SpaceAfterQuestionMarkInConditionalOperator = new formatting.Rule(formatting.RuleDescriptor.create3(52, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsConditionalOperatorContext), 2)); - this.NoSpaceAfterQuestionMark = new formatting.Rule(formatting.RuleDescriptor.create3(52, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); + this.NoSpaceBeforeColon = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 54), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 8)); + this.NoSpaceBeforeQuestionMark = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 53), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 8)); + this.SpaceAfterColon = new formatting.Rule(formatting.RuleDescriptor.create3(54, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 2)); + this.SpaceAfterQuestionMarkInConditionalOperator = new formatting.Rule(formatting.RuleDescriptor.create3(53, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsConditionalOperatorContext), 2)); + this.NoSpaceAfterQuestionMark = new formatting.Rule(formatting.RuleDescriptor.create3(53, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); this.SpaceAfterSemicolon = new formatting.Rule(formatting.RuleDescriptor.create3(23, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); this.SpaceAfterCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create3(16, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsAfterCodeBlockContext), 2)); - this.SpaceBetweenCloseBraceAndElse = new formatting.Rule(formatting.RuleDescriptor.create1(16, 78), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); - this.SpaceBetweenCloseBraceAndWhile = new formatting.Rule(formatting.RuleDescriptor.create1(16, 102), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); + this.SpaceBetweenCloseBraceAndElse = new formatting.Rule(formatting.RuleDescriptor.create1(16, 80), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); + this.SpaceBetweenCloseBraceAndWhile = new formatting.Rule(formatting.RuleDescriptor.create1(16, 104), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); this.NoSpaceAfterCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create3(16, formatting.Shared.TokenRange.FromTokens([18, 20, 24, 23])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); this.NoSpaceBeforeDot = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 21), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); this.NoSpaceAfterDot = new formatting.Rule(formatting.RuleDescriptor.create3(21, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); @@ -33478,9 +34025,9 @@ var ts; this.NoSpaceAfterCloseBracket = new formatting.Rule(formatting.RuleDescriptor.create3(20, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBeforeBlockInFunctionDeclarationContext), 8)); this.FunctionOpenBraceLeftTokenRange = formatting.Shared.TokenRange.AnyIncludingMultilineComments; this.SpaceBeforeOpenBraceInFunction = new formatting.Rule(formatting.RuleDescriptor.create2(this.FunctionOpenBraceLeftTokenRange, 15), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext, Rules.IsBeforeBlockContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), 2), 1); - this.TypeScriptOpenBraceLeftTokenRange = formatting.Shared.TokenRange.FromTokens([67, 3, 71]); + this.TypeScriptOpenBraceLeftTokenRange = formatting.Shared.TokenRange.FromTokens([69, 3, 73]); this.SpaceBeforeOpenBraceInTypeScriptDeclWithBlock = new formatting.Rule(formatting.RuleDescriptor.create2(this.TypeScriptOpenBraceLeftTokenRange, 15), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsTypeScriptDeclWithBlockContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), 2), 1); - this.ControlOpenBraceLeftTokenRange = formatting.Shared.TokenRange.FromTokens([18, 3, 77, 98, 83, 78]); + this.ControlOpenBraceLeftTokenRange = formatting.Shared.TokenRange.FromTokens([18, 3, 79, 100, 85, 80]); this.SpaceBeforeOpenBraceInControl = new formatting.Rule(formatting.RuleDescriptor.create2(this.ControlOpenBraceLeftTokenRange, 15), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsControlDeclContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), 2), 1); this.SpaceAfterOpenBrace = new formatting.Rule(formatting.RuleDescriptor.create3(15, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSingleLineBlockContext), 2)); this.SpaceBeforeCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 16), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSingleLineBlockContext), 2)); @@ -33488,37 +34035,37 @@ var ts; this.NewLineAfterOpenBraceInBlockContext = new formatting.Rule(formatting.RuleDescriptor.create3(15, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsMultilineBlockContext), 4)); this.NewLineBeforeCloseBraceInBlockContext = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.AnyIncludingMultilineComments, 16), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsMultilineBlockContext), 4)); this.NoSpaceAfterUnaryPrefixOperator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.UnaryPrefixOperators, formatting.Shared.TokenRange.UnaryPrefixExpressions), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 8)); - this.NoSpaceAfterUnaryPreincrementOperator = new formatting.Rule(formatting.RuleDescriptor.create3(40, formatting.Shared.TokenRange.UnaryPreincrementExpressions), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); - this.NoSpaceAfterUnaryPredecrementOperator = new formatting.Rule(formatting.RuleDescriptor.create3(41, formatting.Shared.TokenRange.UnaryPredecrementExpressions), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); - this.NoSpaceBeforeUnaryPostincrementOperator = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.UnaryPostincrementExpressions, 40), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); - this.NoSpaceBeforeUnaryPostdecrementOperator = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.UnaryPostdecrementExpressions, 41), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); - this.SpaceAfterPostincrementWhenFollowedByAdd = new formatting.Rule(formatting.RuleDescriptor.create1(40, 35), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2)); + this.NoSpaceAfterUnaryPreincrementOperator = new formatting.Rule(formatting.RuleDescriptor.create3(41, formatting.Shared.TokenRange.UnaryPreincrementExpressions), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); + this.NoSpaceAfterUnaryPredecrementOperator = new formatting.Rule(formatting.RuleDescriptor.create3(42, formatting.Shared.TokenRange.UnaryPredecrementExpressions), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); + this.NoSpaceBeforeUnaryPostincrementOperator = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.UnaryPostincrementExpressions, 41), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); + this.NoSpaceBeforeUnaryPostdecrementOperator = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.UnaryPostdecrementExpressions, 42), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); + this.SpaceAfterPostincrementWhenFollowedByAdd = new formatting.Rule(formatting.RuleDescriptor.create1(41, 35), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2)); this.SpaceAfterAddWhenFollowedByUnaryPlus = new formatting.Rule(formatting.RuleDescriptor.create1(35, 35), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2)); - this.SpaceAfterAddWhenFollowedByPreincrement = new formatting.Rule(formatting.RuleDescriptor.create1(35, 40), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2)); - this.SpaceAfterPostdecrementWhenFollowedBySubtract = new formatting.Rule(formatting.RuleDescriptor.create1(41, 36), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2)); + this.SpaceAfterAddWhenFollowedByPreincrement = new formatting.Rule(formatting.RuleDescriptor.create1(35, 41), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2)); + this.SpaceAfterPostdecrementWhenFollowedBySubtract = new formatting.Rule(formatting.RuleDescriptor.create1(42, 36), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2)); this.SpaceAfterSubtractWhenFollowedByUnaryMinus = new formatting.Rule(formatting.RuleDescriptor.create1(36, 36), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2)); - this.SpaceAfterSubtractWhenFollowedByPredecrement = new formatting.Rule(formatting.RuleDescriptor.create1(36, 41), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2)); + this.SpaceAfterSubtractWhenFollowedByPredecrement = new formatting.Rule(formatting.RuleDescriptor.create1(36, 42), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2)); this.NoSpaceBeforeComma = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 24), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); - this.SpaceAfterCertainKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([100, 96, 90, 76, 92, 99, 117]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); - this.SpaceAfterLetConstInVariableDeclaration = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([106, 72]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsStartOfVariableDeclarationList), 2)); + this.SpaceAfterCertainKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([102, 98, 92, 78, 94, 101, 119]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); + this.SpaceAfterLetConstInVariableDeclaration = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([108, 74]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsStartOfVariableDeclarationList), 2)); this.NoSpaceBeforeOpenParenInFuncCall = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsFunctionCallOrNewContext, Rules.IsPreviousTokenNotComma), 8)); - this.SpaceAfterFunctionInFuncDecl = new formatting.Rule(formatting.RuleDescriptor.create3(85, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2)); + this.SpaceAfterFunctionInFuncDecl = new formatting.Rule(formatting.RuleDescriptor.create3(87, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2)); this.NoSpaceBeforeOpenParenInFuncDecl = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsFunctionDeclContext), 8)); - this.SpaceAfterVoidOperator = new formatting.Rule(formatting.RuleDescriptor.create3(101, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsVoidOpContext), 2)); - this.NoSpaceBetweenReturnAndSemicolon = new formatting.Rule(formatting.RuleDescriptor.create1(92, 23), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); - this.SpaceBetweenStatements = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([18, 77, 78, 69]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotForContext), 2)); - this.SpaceAfterTryFinally = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([98, 83]), 15), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); - this.SpaceAfterGetSetInMember = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([121, 127]), 67), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2)); + this.SpaceAfterVoidOperator = new formatting.Rule(formatting.RuleDescriptor.create3(103, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsVoidOpContext), 2)); + this.NoSpaceBetweenReturnAndSemicolon = new formatting.Rule(formatting.RuleDescriptor.create1(94, 23), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); + this.SpaceBetweenStatements = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([18, 79, 80, 71]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotForContext), 2)); + this.SpaceAfterTryFinally = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([100, 85]), 15), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); + this.SpaceAfterGetSetInMember = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([123, 129]), 69), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2)); this.SpaceBeforeBinaryKeywordOperator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.BinaryKeywordOperators), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2)); this.SpaceAfterBinaryKeywordOperator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.BinaryKeywordOperators, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2)); - this.NoSpaceAfterConstructor = new formatting.Rule(formatting.RuleDescriptor.create1(119, 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); - this.NoSpaceAfterModuleImport = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([123, 125]), 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); - this.SpaceAfterCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([113, 71, 120, 75, 79, 80, 81, 121, 104, 87, 105, 123, 124, 108, 110, 109, 127, 111, 130]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); - this.SpaceBeforeCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([81, 104])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); + this.NoSpaceAfterConstructor = new formatting.Rule(formatting.RuleDescriptor.create1(121, 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); + this.NoSpaceAfterModuleImport = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([125, 127]), 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); + this.SpaceAfterCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([115, 73, 122, 77, 81, 82, 83, 123, 106, 89, 107, 125, 126, 110, 112, 111, 129, 113, 132]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); + this.SpaceBeforeCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([83, 106])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); this.SpaceAfterModuleName = new formatting.Rule(formatting.RuleDescriptor.create1(9, 15), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsModuleDeclContext), 2)); this.SpaceAfterArrow = new formatting.Rule(formatting.RuleDescriptor.create3(34, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); - this.NoSpaceAfterEllipsis = new formatting.Rule(formatting.RuleDescriptor.create1(22, 67), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); - this.NoSpaceAfterOptionalParameters = new formatting.Rule(formatting.RuleDescriptor.create3(52, formatting.Shared.TokenRange.FromTokens([18, 24])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 8)); + this.NoSpaceAfterEllipsis = new formatting.Rule(formatting.RuleDescriptor.create1(22, 69), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); + this.NoSpaceAfterOptionalParameters = new formatting.Rule(formatting.RuleDescriptor.create3(53, formatting.Shared.TokenRange.FromTokens([18, 24])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 8)); this.NoSpaceBeforeOpenAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.TypeNames, 25), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), 8)); this.NoSpaceBetweenCloseParenAndAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create1(18, 25), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), 8)); this.NoSpaceAfterOpenAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create3(25, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), 8)); @@ -33526,15 +34073,18 @@ var ts; this.NoSpaceAfterCloseAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create3(27, formatting.Shared.TokenRange.FromTokens([17, 19, 27, 24])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), 8)); this.NoSpaceAfterTypeAssertion = new formatting.Rule(formatting.RuleDescriptor.create3(27, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsTypeAssertionContext), 8)); this.NoSpaceBetweenEmptyInterfaceBraceBrackets = new formatting.Rule(formatting.RuleDescriptor.create1(15, 16), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsObjectTypeContext), 8)); - this.SpaceBeforeAt = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 54), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); - this.NoSpaceAfterAt = new formatting.Rule(formatting.RuleDescriptor.create3(54, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); - this.SpaceAfterDecorator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([113, 67, 80, 75, 71, 111, 110, 108, 109, 121, 127, 19, 37])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsEndOfDecoratorContextOnSameLine), 2)); - this.NoSpaceBetweenFunctionKeywordAndStar = new formatting.Rule(formatting.RuleDescriptor.create1(85, 37), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclarationOrFunctionExpressionContext), 8)); - this.SpaceAfterStarInGeneratorDeclaration = new formatting.Rule(formatting.RuleDescriptor.create3(37, formatting.Shared.TokenRange.FromTokens([67, 17])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclarationOrFunctionExpressionContext), 2)); - this.NoSpaceBetweenYieldKeywordAndStar = new formatting.Rule(formatting.RuleDescriptor.create1(112, 37), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsYieldOrYieldStarWithOperand), 8)); - this.SpaceBetweenYieldOrYieldStarAndOperand = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([112, 37]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsYieldOrYieldStarWithOperand), 2)); - this.SpaceBetweenAsyncAndFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(116, 85), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); - this.SpaceBetweenTagAndTemplateString = new formatting.Rule(formatting.RuleDescriptor.create3(67, formatting.Shared.TokenRange.FromTokens([11, 12])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); + this.SpaceBeforeAt = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 55), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); + this.NoSpaceAfterAt = new formatting.Rule(formatting.RuleDescriptor.create3(55, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); + this.SpaceAfterDecorator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([115, 69, 82, 77, 73, 113, 112, 110, 111, 123, 129, 19, 37])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsEndOfDecoratorContextOnSameLine), 2)); + this.NoSpaceBetweenFunctionKeywordAndStar = new formatting.Rule(formatting.RuleDescriptor.create1(87, 37), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclarationOrFunctionExpressionContext), 8)); + this.SpaceAfterStarInGeneratorDeclaration = new formatting.Rule(formatting.RuleDescriptor.create3(37, formatting.Shared.TokenRange.FromTokens([69, 17])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclarationOrFunctionExpressionContext), 2)); + this.NoSpaceBetweenYieldKeywordAndStar = new formatting.Rule(formatting.RuleDescriptor.create1(114, 37), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsYieldOrYieldStarWithOperand), 8)); + this.SpaceBetweenYieldOrYieldStarAndOperand = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([114, 37]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsYieldOrYieldStarWithOperand), 2)); + this.SpaceBetweenAsyncAndOpenParen = new formatting.Rule(formatting.RuleDescriptor.create1(118, 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsArrowFunctionContext, Rules.IsSameLineTokenContext), 2)); + this.SpaceBetweenAsyncAndFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(118, 87), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); + this.SpaceBetweenTagAndTemplateString = new formatting.Rule(formatting.RuleDescriptor.create3(69, formatting.Shared.TokenRange.FromTokens([11, 12])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); + this.NoSpaceAfterTemplateHeadAndMiddle = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([12, 13]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); + this.NoSpaceBeforeTemplateMiddleAndTail = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([13, 14])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); this.HighPriorityCommonRules = [ this.IgnoreBeforeComment, this.IgnoreAfterLineComment, @@ -33560,8 +34110,8 @@ var ts; this.NoSpaceBeforeOpenParenInFuncCall, this.SpaceBeforeBinaryKeywordOperator, this.SpaceAfterBinaryKeywordOperator, this.SpaceAfterVoidOperator, - this.SpaceBetweenAsyncAndFunctionKeyword, - this.SpaceBetweenTagAndTemplateString, + this.SpaceBetweenAsyncAndOpenParen, this.SpaceBetweenAsyncAndFunctionKeyword, + this.SpaceBetweenTagAndTemplateString, this.NoSpaceAfterTemplateHeadAndMiddle, this.NoSpaceBeforeTemplateMiddleAndTail, this.NoSpaceAfterConstructor, this.NoSpaceAfterModuleImport, this.SpaceAfterCertainTypeScriptKeywords, this.SpaceBeforeCertainTypeScriptKeywords, this.SpaceAfterModuleName, @@ -33613,46 +34163,46 @@ var ts; this.NoSpaceBetweenBrackets = new formatting.Rule(formatting.RuleDescriptor.create1(19, 20), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); this.NoSpaceAfterOpenBracket = new formatting.Rule(formatting.RuleDescriptor.create3(19, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); this.NoSpaceBeforeCloseBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 20), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); - this.SpaceAfterAnonymousFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(85, 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2)); - this.NoSpaceAfterAnonymousFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(85, 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 8)); + this.SpaceAfterAnonymousFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(87, 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2)); + this.NoSpaceAfterAnonymousFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(87, 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 8)); } Rules.prototype.getRuleName = function (rule) { var o = this; - for (var name_30 in o) { - if (o[name_30] === rule) { - return name_30; + for (var name_31 in o) { + if (o[name_31] === rule) { + return name_31; } } throw new Error("Unknown rule"); }; Rules.IsForContext = function (context) { - return context.contextNode.kind === 197; + return context.contextNode.kind === 199; }; Rules.IsNotForContext = function (context) { return !Rules.IsForContext(context); }; Rules.IsBinaryOpContext = function (context) { switch (context.contextNode.kind) { - case 179: - case 180: - case 187: - case 148: - case 156: - case 157: + case 181: + case 182: + case 189: + case 150: + case 158: + case 159: return true; - case 161: - case 214: - case 219: - case 209: - case 136: - case 245: - case 139: + case 163: + case 216: + case 221: + case 211: case 138: - return context.currentTokenSpan.kind === 55 || context.nextTokenSpan.kind === 55; - case 198: - return context.currentTokenSpan.kind === 88 || context.nextTokenSpan.kind === 88; - case 199: - return context.currentTokenSpan.kind === 132 || context.nextTokenSpan.kind === 132; + case 247: + case 141: + case 140: + return context.currentTokenSpan.kind === 56 || context.nextTokenSpan.kind === 56; + case 200: + return context.currentTokenSpan.kind === 90 || context.nextTokenSpan.kind === 90; + case 201: + return context.currentTokenSpan.kind === 134 || context.nextTokenSpan.kind === 134; } return false; }; @@ -33660,7 +34210,7 @@ var ts; return !Rules.IsBinaryOpContext(context); }; Rules.IsConditionalOperatorContext = function (context) { - return context.contextNode.kind === 180; + return context.contextNode.kind === 182; }; Rules.IsSameLineTokenOrBeforeMultilineBlockContext = function (context) { return context.TokensAreOnSameLine() || Rules.IsBeforeMultilineBlockContext(context); @@ -33685,86 +34235,86 @@ var ts; return true; } switch (node.kind) { - case 190: - case 218: - case 163: - case 217: + case 192: + case 220: + case 165: + case 219: return true; } return false; }; Rules.IsFunctionDeclContext = function (context) { switch (context.contextNode.kind) { - case 211: - case 141: - case 140: - case 143: - case 144: - case 145: - case 171: - case 142: - case 172: case 213: + case 143: + case 142: + case 145: + case 146: + case 147: + case 173: + case 144: + case 174: + case 215: return true; } return false; }; Rules.IsFunctionDeclarationOrFunctionExpressionContext = function (context) { - return context.contextNode.kind === 211 || context.contextNode.kind === 171; + return context.contextNode.kind === 213 || context.contextNode.kind === 173; }; Rules.IsTypeScriptDeclWithBlockContext = function (context) { return Rules.NodeIsTypeScriptDeclWithBlockContext(context.contextNode); }; Rules.NodeIsTypeScriptDeclWithBlockContext = function (node) { switch (node.kind) { - case 212: - case 184: - case 213: + case 214: + case 186: case 215: - case 153: - case 216: + case 217: + case 155: + case 218: return true; } return false; }; Rules.IsAfterCodeBlockContext = function (context) { switch (context.currentTokenParent.kind) { - case 212: - case 216: - case 215: - case 190: - case 242: + case 214: + case 218: case 217: - case 204: + case 192: + case 244: + case 219: + case 206: return true; } return false; }; Rules.IsControlDeclContext = function (context) { switch (context.contextNode.kind) { - case 194: - case 204: - case 197: - case 198: - case 199: case 196: - case 207: - case 195: - case 203: - case 242: + case 206: + case 199: + case 200: + case 201: + case 198: + case 209: + case 197: + case 205: + case 244: return true; default: return false; } }; Rules.IsObjectContext = function (context) { - return context.contextNode.kind === 163; + return context.contextNode.kind === 165; }; Rules.IsFunctionCallContext = function (context) { - return context.contextNode.kind === 166; + return context.contextNode.kind === 168; }; Rules.IsNewContext = function (context) { - return context.contextNode.kind === 167; + return context.contextNode.kind === 169; }; Rules.IsFunctionCallOrNewContext = function (context) { return Rules.IsFunctionCallContext(context) || Rules.IsNewContext(context); @@ -33772,6 +34322,9 @@ var ts; Rules.IsPreviousTokenNotComma = function (context) { return context.currentTokenSpan.kind !== 24; }; + Rules.IsArrowFunctionContext = function (context) { + return context.contextNode.kind === 174; + }; Rules.IsSameLineTokenContext = function (context) { return context.TokensAreOnSameLine(); }; @@ -33788,41 +34341,41 @@ var ts; while (ts.isExpression(node)) { node = node.parent; } - return node.kind === 137; + return node.kind === 139; }; Rules.IsStartOfVariableDeclarationList = function (context) { - return context.currentTokenParent.kind === 210 && + return context.currentTokenParent.kind === 212 && context.currentTokenParent.getStart(context.sourceFile) === context.currentTokenSpan.pos; }; Rules.IsNotFormatOnEnter = function (context) { return context.formattingRequestKind !== 2; }; Rules.IsModuleDeclContext = function (context) { - return context.contextNode.kind === 216; + return context.contextNode.kind === 218; }; Rules.IsObjectTypeContext = function (context) { - return context.contextNode.kind === 153; + return context.contextNode.kind === 155; }; Rules.IsTypeArgumentOrParameterOrAssertion = function (token, parent) { if (token.kind !== 25 && token.kind !== 27) { return false; } switch (parent.kind) { - case 149: - case 169: - case 212: - case 184: - case 213: - case 211: + case 151: case 171: - case 172: - case 141: - case 140: - case 145: - case 146: - case 166: - case 167: + case 214: case 186: + case 215: + case 213: + case 173: + case 174: + case 143: + case 142: + case 147: + case 148: + case 168: + case 169: + case 188: return true; default: return false; @@ -33833,13 +34386,13 @@ var ts; Rules.IsTypeArgumentOrParameterOrAssertion(context.nextTokenSpan, context.nextTokenParent); }; Rules.IsTypeAssertionContext = function (context) { - return context.contextNode.kind === 169; + return context.contextNode.kind === 171; }; Rules.IsVoidOpContext = function (context) { - return context.currentTokenSpan.kind === 101 && context.currentTokenParent.kind === 175; + return context.currentTokenSpan.kind === 103 && context.currentTokenParent.kind === 177; }; Rules.IsYieldOrYieldStarWithOperand = function (context) { - return context.contextNode.kind === 182 && context.contextNode.expression !== undefined; + return context.contextNode.kind === 184 && context.contextNode.expression !== undefined; }; return Rules; })(); @@ -33861,7 +34414,7 @@ var ts; return result; }; RulesMap.prototype.Initialize = function (rules) { - this.mapRowLength = 132 + 1; + this.mapRowLength = 134 + 1; this.map = new Array(this.mapRowLength * this.mapRowLength); var rulesBucketConstructionStateList = new Array(this.map.length); this.FillRules(rules, rulesBucketConstructionStateList); @@ -34037,7 +34590,7 @@ var ts; } TokenAllAccess.prototype.GetTokens = function () { var result = []; - for (var token = 0; token <= 132; token++) { + for (var token = 0; token <= 134; token++) { result.push(token); } return result; @@ -34079,17 +34632,17 @@ var ts; }; TokenRange.Any = TokenRange.AllTokens(); TokenRange.AnyIncludingMultilineComments = TokenRange.FromTokens(TokenRange.Any.GetTokens().concat([3])); - TokenRange.Keywords = TokenRange.FromRange(68, 132); - TokenRange.BinaryOperators = TokenRange.FromRange(25, 66); - TokenRange.BinaryKeywordOperators = TokenRange.FromTokens([88, 89, 132, 114, 122]); - TokenRange.UnaryPrefixOperators = TokenRange.FromTokens([40, 41, 49, 48]); - TokenRange.UnaryPrefixExpressions = TokenRange.FromTokens([8, 67, 17, 19, 15, 95, 90]); - TokenRange.UnaryPreincrementExpressions = TokenRange.FromTokens([67, 17, 95, 90]); - TokenRange.UnaryPostincrementExpressions = TokenRange.FromTokens([67, 18, 20, 90]); - TokenRange.UnaryPredecrementExpressions = TokenRange.FromTokens([67, 17, 95, 90]); - TokenRange.UnaryPostdecrementExpressions = TokenRange.FromTokens([67, 18, 20, 90]); + TokenRange.Keywords = TokenRange.FromRange(70, 134); + TokenRange.BinaryOperators = TokenRange.FromRange(25, 68); + TokenRange.BinaryKeywordOperators = TokenRange.FromTokens([90, 91, 134, 116, 124]); + TokenRange.UnaryPrefixOperators = TokenRange.FromTokens([41, 42, 50, 49]); + TokenRange.UnaryPrefixExpressions = TokenRange.FromTokens([8, 69, 17, 19, 15, 97, 92]); + TokenRange.UnaryPreincrementExpressions = TokenRange.FromTokens([69, 17, 97, 92]); + TokenRange.UnaryPostincrementExpressions = TokenRange.FromTokens([69, 18, 20, 92]); + TokenRange.UnaryPredecrementExpressions = TokenRange.FromTokens([69, 17, 97, 92]); + TokenRange.UnaryPostdecrementExpressions = TokenRange.FromTokens([69, 18, 20, 92]); TokenRange.Comments = TokenRange.FromTokens([2, 3]); - TokenRange.TypeNames = TokenRange.FromTokens([67, 126, 128, 118, 129, 101, 115]); + TokenRange.TypeNames = TokenRange.FromTokens([69, 128, 130, 120, 131, 103, 117]); return TokenRange; })(); Shared.TokenRange = TokenRange; @@ -34260,17 +34813,17 @@ var ts; } function isListElement(parent, node) { switch (parent.kind) { - case 212: - case 213: + case 214: + case 215: return ts.rangeContainsRange(parent.members, node); - case 216: + case 218: var body = parent.body; - return body && body.kind === 190 && ts.rangeContainsRange(body.statements, node); - case 246: - case 190: - case 217: + return body && body.kind === 192 && ts.rangeContainsRange(body.statements, node); + case 248: + case 192: + case 219: return ts.rangeContainsRange(parent.statements, node); - case 242: + case 244: return ts.rangeContainsRange(parent.block.statements, node); } return false; @@ -34395,9 +34948,9 @@ var ts; if (indentation === -1) { if (isSomeBlock(node.kind)) { if (isSomeBlock(parent.kind) || - parent.kind === 246 || - parent.kind === 239 || - parent.kind === 240) { + parent.kind === 248 || + parent.kind === 241 || + parent.kind === 242) { indentation = parentDynamicIndentation.getIndentation() + parentDynamicIndentation.getDelta(); } else { @@ -34430,18 +34983,18 @@ var ts; return node.modifiers[0].kind; } switch (node.kind) { - case 212: return 71; - case 213: return 105; - case 211: return 85; - case 215: return 215; - case 143: return 121; - case 144: return 127; - case 141: + case 214: return 73; + case 215: return 107; + case 213: return 87; + case 217: return 217; + case 145: return 123; + case 146: return 129; + case 143: if (node.asteriskToken) { return 37; } - case 139: - case 136: + case 141: + case 138: return node.name.kind; } } @@ -34469,9 +35022,9 @@ var ts; case 20: case 17: case 18: - case 78: - case 102: - case 54: + case 80: + case 104: + case 55: return indentation; default: return nodeStartLine !== line ? indentation + delta : indentation; @@ -34551,7 +35104,7 @@ var ts; consumeTokenAndAdvanceScanner(tokenInfo, node, parentDynamicIndentation); return inheritedIndentation; } - var effectiveParentStartLine = child.kind === 137 ? childStartLine : undecoratedParentStartLine; + var effectiveParentStartLine = child.kind === 139 ? childStartLine : undecoratedParentStartLine; var childIndentation = computeIndentation(child, childStartLine, childIndentationAmount, node, parentDynamicIndentation, effectiveParentStartLine); processNode(child, childContextNode, childStartLine, undecoratedChildStartLine, childIndentation.indentation, childIndentation.delta); childContextNode = node; @@ -34783,7 +35336,7 @@ var ts; for (var line = line1; line < line2; ++line) { var lineStartPosition = ts.getStartPositionOfLine(line, sourceFile); var lineEndPosition = ts.getEndLinePosition(line, sourceFile); - if (range && ts.isComment(range.kind) && range.pos <= lineEndPosition && range.end > lineEndPosition) { + if (range && (ts.isComment(range.kind) || ts.isStringOrRegularExpressionOrTemplateLiteral(range.kind)) && range.pos <= lineEndPosition && range.end > lineEndPosition) { continue; } var pos = lineEndPosition; @@ -34842,20 +35395,20 @@ var ts; } function isSomeBlock(kind) { switch (kind) { - case 190: - case 217: + case 192: + case 219: return true; } return false; } function getOpenTokenForList(node, list) { switch (node.kind) { + case 144: + case 213: + case 173: + case 143: case 142: - case 211: - case 171: - case 141: - case 140: - case 172: + case 174: if (node.typeParameters === list) { return 25; } @@ -34863,8 +35416,8 @@ var ts; return 17; } break; - case 166: - case 167: + case 168: + case 169: if (node.typeArguments === list) { return 25; } @@ -34872,7 +35425,7 @@ var ts; return 17; } break; - case 149: + case 151: if (node.typeArguments === list) { return 25; } @@ -34949,21 +35502,31 @@ var ts; if (position > sourceFile.text.length) { return 0; } + if (options.IndentStyle === ts.IndentStyle.None) { + return 0; + } var precedingToken = ts.findPrecedingToken(position, sourceFile); if (!precedingToken) { return 0; } - var precedingTokenIsLiteral = precedingToken.kind === 9 || - precedingToken.kind === 10 || - precedingToken.kind === 11 || - precedingToken.kind === 12 || - precedingToken.kind === 13 || - precedingToken.kind === 14; + var precedingTokenIsLiteral = ts.isStringOrRegularExpressionOrTemplateLiteral(precedingToken.kind); if (precedingTokenIsLiteral && precedingToken.getStart(sourceFile) <= position && precedingToken.end > position) { return 0; } var lineAtPosition = sourceFile.getLineAndCharacterOfPosition(position).line; - if (precedingToken.kind === 24 && precedingToken.parent.kind !== 179) { + if (options.IndentStyle === ts.IndentStyle.Block) { + var current_1 = position; + while (current_1 > 0) { + var char = sourceFile.text.charCodeAt(current_1); + if (!ts.isWhiteSpace(char) && !ts.isLineBreak(char)) { + break; + } + current_1--; + } + var lineStart = ts.getLineStartPositionForPosition(current_1, sourceFile); + return SmartIndenter.findFirstNonWhitespaceColumn(lineStart, current_1, sourceFile, options); + } + if (precedingToken.kind === 24 && precedingToken.parent.kind !== 181) { var actualIndentation = getActualIndentationForListItemBeforeComma(precedingToken, sourceFile, options); if (actualIndentation !== -1) { return actualIndentation; @@ -35061,7 +35624,7 @@ var ts; } function getActualIndentationForNode(current, parent, currentLineAndChar, parentAndChildShareLine, sourceFile, options) { var useActualIndentation = (ts.isDeclaration(current) || ts.isStatement(current)) && - (parent.kind === 246 || !parentAndChildShareLine); + (parent.kind === 248 || !parentAndChildShareLine); if (!useActualIndentation) { return -1; } @@ -35085,8 +35648,8 @@ var ts; return sourceFile.getLineAndCharacterOfPosition(n.getStart(sourceFile)); } function childStartsOnTheSameLineWithElseInIfStatement(parent, child, childStartLine, sourceFile) { - if (parent.kind === 194 && parent.elseStatement === child) { - var elseKeyword = ts.findChildOfKind(parent, 78, sourceFile); + if (parent.kind === 196 && parent.elseStatement === child) { + var elseKeyword = ts.findChildOfKind(parent, 80, sourceFile); ts.Debug.assert(elseKeyword !== undefined); var elseKeywordStartLine = getStartLineAndCharacterForNode(elseKeyword, sourceFile).line; return elseKeywordStartLine === childStartLine; @@ -35097,23 +35660,23 @@ var ts; function getContainingList(node, sourceFile) { if (node.parent) { switch (node.parent.kind) { - case 149: + case 151: if (node.parent.typeArguments && ts.rangeContainsStartEnd(node.parent.typeArguments, node.getStart(sourceFile), node.getEnd())) { return node.parent.typeArguments; } break; - case 163: + case 165: return node.parent.properties; - case 162: + case 164: return node.parent.elements; - case 211: - case 171: - case 172: - case 141: - case 140: - case 145: - case 146: { + case 213: + case 173: + case 174: + case 143: + case 142: + case 147: + case 148: { var start = node.getStart(sourceFile); if (node.parent.typeParameters && ts.rangeContainsStartEnd(node.parent.typeParameters, start, node.getEnd())) { @@ -35124,8 +35687,8 @@ var ts; } break; } - case 167: - case 166: { + case 169: + case 168: { var start = node.getStart(sourceFile); if (node.parent.typeArguments && ts.rangeContainsStartEnd(node.parent.typeArguments, start, node.getEnd())) { @@ -35153,8 +35716,8 @@ var ts; if (node.kind === 18) { return -1; } - if (node.parent && (node.parent.kind === 166 || - node.parent.kind === 167) && + if (node.parent && (node.parent.kind === 168 || + node.parent.kind === 169) && node.parent.expression !== node) { var fullCallOrNewExpression = node.parent.expression; var startingExpression = getStartingExpression(fullCallOrNewExpression); @@ -35172,10 +35735,10 @@ var ts; function getStartingExpression(node) { while (true) { switch (node.kind) { + case 168: + case 169: case 166: case 167: - case 164: - case 165: node = node.expression; break; default: @@ -35230,42 +35793,43 @@ var ts; SmartIndenter.findFirstNonWhitespaceColumn = findFirstNonWhitespaceColumn; function nodeContentIsAlwaysIndented(kind) { switch (kind) { - case 212: - case 184: - case 213: - case 215: + case 195: case 214: - case 162: - case 190: + case 186: + case 215: case 217: - case 163: - case 153: - case 155: - case 218: - case 240: - case 239: - case 170: + case 216: case 164: + case 192: + case 219: + case 165: + case 155: + case 157: + case 220: + case 242: + case 241: + case 172: case 166: - case 167: - case 191: - case 209: - case 225: - case 202: - case 180: - case 160: - case 159: - case 231: - case 232: - case 140: - case 145: - case 146: - case 136: - case 150: - case 151: - case 158: case 168: - case 176: + case 169: + case 193: + case 211: + case 227: + case 204: + case 182: + case 162: + case 161: + case 233: + case 234: + case 142: + case 147: + case 148: + case 138: + case 152: + case 153: + case 160: + case 170: + case 178: return true; } return false; @@ -35275,20 +35839,20 @@ var ts; return true; } switch (parent) { - case 195: - case 196: - case 198: - case 199: case 197: - case 194: - case 211: - case 171: - case 141: - case 172: - case 142: + case 198: + case 200: + case 201: + case 199: + case 196: + case 213: + case 173: case 143: + case 174: case 144: - return child !== 190; + case 145: + case 146: + return child !== 192; default: return false; } @@ -35417,7 +35981,7 @@ var ts; return pos; }; NodeObject.prototype.createSyntaxList = function (nodes) { - var list = createNode(269, nodes.pos, nodes.end, 4096, this); + var list = createNode(271, nodes.pos, nodes.end, 4096, this); list._children = []; var pos = nodes.pos; for (var _i = 0; _i < nodes.length; _i++) { @@ -35436,7 +36000,7 @@ var ts; NodeObject.prototype.createChildren = function (sourceFile) { var _this = this; var children; - if (this.kind >= 133) { + if (this.kind >= 135) { scanner.setText((sourceFile || this.getSourceFile()).text); children = []; var pos = this.pos; @@ -35483,7 +36047,7 @@ var ts; return undefined; } var child = children[0]; - return child.kind < 133 ? child : child.getFirstToken(sourceFile); + return child.kind < 135 ? child : child.getFirstToken(sourceFile); }; NodeObject.prototype.getLastToken = function (sourceFile) { var children = this.getChildren(sourceFile); @@ -35491,7 +36055,7 @@ var ts; if (!child) { return undefined; } - return child.kind < 133 ? child : child.getLastToken(sourceFile); + return child.kind < 135 ? child : child.getLastToken(sourceFile); }; return NodeObject; })(); @@ -35533,7 +36097,7 @@ var ts; ts.forEach(declarations, function (declaration, indexOfDeclaration) { if (ts.indexOf(declarations, declaration) === indexOfDeclaration) { var sourceFileOfDeclaration = ts.getSourceFileOfNode(declaration); - if (canUseParsedParamTagComments && declaration.kind === 136) { + if (canUseParsedParamTagComments && declaration.kind === 138) { ts.forEach(getJsDocCommentTextRange(declaration.parent, sourceFileOfDeclaration), function (jsDocCommentTextRange) { var cleanedParamJsDocComment = getCleanedParamJsDocComment(jsDocCommentTextRange.pos, jsDocCommentTextRange.end, sourceFileOfDeclaration); if (cleanedParamJsDocComment) { @@ -35541,13 +36105,13 @@ var ts; } }); } - if (declaration.kind === 216 && declaration.body.kind === 216) { + if (declaration.kind === 218 && declaration.body.kind === 218) { return; } - while (declaration.kind === 216 && declaration.parent.kind === 216) { + while (declaration.kind === 218 && declaration.parent.kind === 218) { declaration = declaration.parent; } - ts.forEach(getJsDocCommentTextRange(declaration.kind === 209 ? declaration.parent.parent : declaration, sourceFileOfDeclaration), function (jsDocCommentTextRange) { + ts.forEach(getJsDocCommentTextRange(declaration.kind === 211 ? declaration.parent.parent : declaration, sourceFileOfDeclaration), function (jsDocCommentTextRange) { var cleanedJsDocComment = getCleanedJsDocComment(jsDocCommentTextRange.pos, jsDocCommentTextRange.end, sourceFileOfDeclaration); if (cleanedJsDocComment) { ts.addRange(jsDocCommentParts, cleanedJsDocComment); @@ -35857,9 +36421,9 @@ var ts; if (result_2 !== undefined) { return result_2; } - if (declaration.name.kind === 134) { + if (declaration.name.kind === 136) { var expr = declaration.name.expression; - if (expr.kind === 164) { + if (expr.kind === 166) { return expr.name.text; } return getTextOfIdentifierOrLiteral(expr); @@ -35869,7 +36433,7 @@ var ts; } function getTextOfIdentifierOrLiteral(node) { if (node) { - if (node.kind === 67 || + if (node.kind === 69 || node.kind === 9 || node.kind === 8) { return node.text; @@ -35879,9 +36443,9 @@ var ts; } function visit(node) { switch (node.kind) { - case 211: - case 141: - case 140: + case 213: + case 143: + case 142: var functionDeclaration = node; var declarationName = getDeclarationName(functionDeclaration); if (declarationName) { @@ -35898,62 +36462,62 @@ var ts; ts.forEachChild(node, visit); } break; - case 212: - case 213: case 214: case 215: case 216: - case 219: - case 228: - case 224: - case 219: - case 221: - case 222: - case 143: - case 144: - case 153: - addDeclaration(node); - case 142: - case 191: - case 210: - case 159: - case 160: case 217: + case 218: + case 221: + case 230: + case 226: + case 221: + case 223: + case 224: + case 145: + case 146: + case 155: + addDeclaration(node); + case 144: + case 193: + case 212: + case 161: + case 162: + case 219: ts.forEachChild(node, visit); break; - case 190: + case 192: if (ts.isFunctionBlock(node)) { ts.forEachChild(node, visit); } break; - case 136: + case 138: if (!(node.flags & 112)) { break; } - case 209: - case 161: + case 211: + case 163: if (ts.isBindingPattern(node.name)) { ts.forEachChild(node.name, visit); break; } - case 245: - case 139: - case 138: + case 247: + case 141: + case 140: addDeclaration(node); break; - case 226: + case 228: if (node.exportClause) { ts.forEach(node.exportClause.elements, visit); } break; - case 220: + case 222: var importClause = node.importClause; if (importClause) { if (importClause.name) { addDeclaration(importClause); } if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 222) { + if (importClause.namedBindings.kind === 224) { addDeclaration(importClause.namedBindings); } else { @@ -35980,6 +36544,12 @@ var ts; HighlightSpanKind.reference = "reference"; HighlightSpanKind.writtenReference = "writtenReference"; })(HighlightSpanKind = ts.HighlightSpanKind || (ts.HighlightSpanKind = {})); + (function (IndentStyle) { + IndentStyle[IndentStyle["None"] = 0] = "None"; + IndentStyle[IndentStyle["Block"] = 1] = "Block"; + IndentStyle[IndentStyle["Smart"] = 2] = "Smart"; + })(ts.IndentStyle || (ts.IndentStyle = {})); + var IndentStyle = ts.IndentStyle; (function (SymbolDisplayPartKind) { SymbolDisplayPartKind[SymbolDisplayPartKind["aliasName"] = 0] = "aliasName"; SymbolDisplayPartKind[SymbolDisplayPartKind["className"] = 1] = "className"; @@ -36095,14 +36665,14 @@ var ts; return false; } return ts.forEach(symbol.declarations, function (declaration) { - if (declaration.kind === 171) { + if (declaration.kind === 173) { return true; } - if (declaration.kind !== 209 && declaration.kind !== 211) { + if (declaration.kind !== 211 && declaration.kind !== 213) { return false; } for (var parent_8 = declaration.parent; !ts.isFunctionBlock(parent_8); parent_8 = parent_8.parent) { - if (parent_8.kind === 246 || parent_8.kind === 217) { + if (parent_8.kind === 248 || parent_8.kind === 219) { return false; } } @@ -36213,7 +36783,7 @@ var ts; options.allowNonTsExtensions = true; options.noLib = true; options.noResolve = true; - var inputFileName = transpileOptions.fileName || "module.ts"; + var inputFileName = transpileOptions.fileName || (options.jsx ? "module.tsx" : "module.ts"); var sourceFile = ts.createSourceFile(inputFileName, input, options.target); if (transpileOptions.moduleName) { sourceFile.moduleName = transpileOptions.moduleName; @@ -36394,8 +36964,9 @@ var ts; }; } ts.createDocumentRegistry = createDocumentRegistry; - function preProcessFile(sourceText, readImportFiles) { + function preProcessFile(sourceText, readImportFiles, detectJavaScriptImports) { if (readImportFiles === void 0) { readImportFiles = true; } + if (detectJavaScriptImports === void 0) { detectJavaScriptImports = false; } var referencedFiles = []; var importedFiles = []; var ambientExternalModules; @@ -36429,98 +37000,58 @@ var ts; end: pos + importPath.length }); } - function processImport() { - scanner.setText(sourceText); - var token = scanner.scan(); - while (token !== 1) { - if (token === 120) { - token = scanner.scan(); - if (token === 123) { - token = scanner.scan(); - if (token === 9) { - recordAmbientExternalModule(); - continue; - } - } - } - else if (token === 87) { + function tryConsumeDeclare() { + var token = scanner.getToken(); + if (token === 122) { + token = scanner.scan(); + if (token === 125) { token = scanner.scan(); if (token === 9) { - recordModuleName(); - continue; - } - else { - if (token === 67 || ts.isKeyword(token)) { - token = scanner.scan(); - if (token === 131) { - token = scanner.scan(); - if (token === 9) { - recordModuleName(); - continue; - } - } - else if (token === 55) { - token = scanner.scan(); - if (token === 125) { - token = scanner.scan(); - if (token === 17) { - token = scanner.scan(); - if (token === 9) { - recordModuleName(); - continue; - } - } - } - } - else if (token === 24) { - token = scanner.scan(); - } - else { - continue; - } - } - if (token === 15) { - token = scanner.scan(); - while (token !== 16) { - token = scanner.scan(); - } - if (token === 16) { - token = scanner.scan(); - if (token === 131) { - token = scanner.scan(); - if (token === 9) { - recordModuleName(); - } - } - } - } - else if (token === 37) { - token = scanner.scan(); - if (token === 114) { - token = scanner.scan(); - if (token === 67 || ts.isKeyword(token)) { - token = scanner.scan(); - if (token === 131) { - token = scanner.scan(); - if (token === 9) { - recordModuleName(); - } - } - } - } - } + recordAmbientExternalModule(); } } - else if (token === 80) { - token = scanner.scan(); + return true; + } + return false; + } + function tryConsumeImport() { + var token = scanner.getToken(); + if (token === 89) { + token = scanner.scan(); + if (token === 9) { + recordModuleName(); + return true; + } + else { + if (token === 69 || ts.isKeyword(token)) { + token = scanner.scan(); + if (token === 133) { + token = scanner.scan(); + if (token === 9) { + recordModuleName(); + return true; + } + } + else if (token === 56) { + if (tryConsumeRequireCall(true)) { + return true; + } + } + else if (token === 24) { + token = scanner.scan(); + } + else { + return true; + } + } if (token === 15) { token = scanner.scan(); - while (token !== 16) { + while (token !== 16 && token !== 1) { token = scanner.scan(); } if (token === 16) { token = scanner.scan(); - if (token === 131) { + if (token === 133) { token = scanner.scan(); if (token === 9) { recordModuleName(); @@ -36530,38 +37061,135 @@ var ts; } else if (token === 37) { token = scanner.scan(); - if (token === 131) { + if (token === 116) { token = scanner.scan(); - if (token === 9) { - recordModuleName(); - } - } - } - else if (token === 87) { - token = scanner.scan(); - if (token === 67 || ts.isKeyword(token)) { - token = scanner.scan(); - if (token === 55) { + if (token === 69 || ts.isKeyword(token)) { token = scanner.scan(); - if (token === 125) { + if (token === 133) { token = scanner.scan(); - if (token === 17) { - token = scanner.scan(); - if (token === 9) { - recordModuleName(); - } + if (token === 9) { + recordModuleName(); } } } } } } + return true; + } + return false; + } + function tryConsumeExport() { + var token = scanner.getToken(); + if (token === 82) { token = scanner.scan(); + if (token === 15) { + token = scanner.scan(); + while (token !== 16 && token !== 1) { + token = scanner.scan(); + } + if (token === 16) { + token = scanner.scan(); + if (token === 133) { + token = scanner.scan(); + if (token === 9) { + recordModuleName(); + } + } + } + } + else if (token === 37) { + token = scanner.scan(); + if (token === 133) { + token = scanner.scan(); + if (token === 9) { + recordModuleName(); + } + } + } + else if (token === 89) { + token = scanner.scan(); + if (token === 69 || ts.isKeyword(token)) { + token = scanner.scan(); + if (token === 56) { + if (tryConsumeRequireCall(true)) { + return true; + } + } + } + } + return true; + } + return false; + } + function tryConsumeRequireCall(skipCurrentToken) { + var token = skipCurrentToken ? scanner.scan() : scanner.getToken(); + if (token === 127) { + token = scanner.scan(); + if (token === 17) { + token = scanner.scan(); + if (token === 9) { + recordModuleName(); + } + } + return true; + } + return false; + } + function tryConsumeDefine() { + var token = scanner.getToken(); + if (token === 69 && scanner.getTokenValue() === "define") { + token = scanner.scan(); + if (token !== 17) { + return true; + } + token = scanner.scan(); + if (token === 9) { + token = scanner.scan(); + if (token === 24) { + token = scanner.scan(); + } + else { + return true; + } + } + if (token !== 19) { + return true; + } + token = scanner.scan(); + var i = 0; + while (token !== 20 && token !== 1) { + if (token === 9) { + recordModuleName(); + i++; + } + token = scanner.scan(); + } + return true; + } + return false; + } + function processImports() { + scanner.setText(sourceText); + scanner.scan(); + while (true) { + if (scanner.getToken() === 1) { + break; + } + if (tryConsumeDeclare() || + tryConsumeImport() || + tryConsumeExport() || + (detectJavaScriptImports && (tryConsumeRequireCall(false) || tryConsumeDefine()))) { + continue; + } + else { + scanner.scan(); + } } scanner.setText(undefined); } if (readImportFiles) { - processImport(); + processImports(); } processTripleSlashDirectives(); return { referencedFiles: referencedFiles, importedFiles: importedFiles, isLibFile: isNoDefaultLib, ambientExternalModules: ambientExternalModules }; @@ -36569,7 +37197,7 @@ var ts; ts.preProcessFile = preProcessFile; function getTargetLabel(referenceNode, labelName) { while (referenceNode) { - if (referenceNode.kind === 205 && referenceNode.label.text === labelName) { + if (referenceNode.kind === 207 && referenceNode.label.text === labelName) { return referenceNode.label; } referenceNode = referenceNode.parent; @@ -36577,17 +37205,17 @@ var ts; return undefined; } function isJumpStatementTarget(node) { - return node.kind === 67 && - (node.parent.kind === 201 || node.parent.kind === 200) && + return node.kind === 69 && + (node.parent.kind === 203 || node.parent.kind === 202) && node.parent.label === node; } function isLabelOfLabeledStatement(node) { - return node.kind === 67 && - node.parent.kind === 205 && + return node.kind === 69 && + node.parent.kind === 207 && node.parent.label === node; } function isLabeledBy(node, labelName) { - for (var owner = node.parent; owner.kind === 205; owner = owner.parent) { + for (var owner = node.parent; owner.kind === 207; owner = owner.parent) { if (owner.label.text === labelName) { return true; } @@ -36598,48 +37226,48 @@ var ts; return isLabelOfLabeledStatement(node) || isJumpStatementTarget(node); } function isRightSideOfQualifiedName(node) { - return node.parent.kind === 133 && node.parent.right === node; + return node.parent.kind === 135 && node.parent.right === node; } function isRightSideOfPropertyAccess(node) { - return node && node.parent && node.parent.kind === 164 && node.parent.name === node; + return node && node.parent && node.parent.kind === 166 && node.parent.name === node; } function isCallExpressionTarget(node) { if (isRightSideOfPropertyAccess(node)) { node = node.parent; } - return node && node.parent && node.parent.kind === 166 && node.parent.expression === node; + return node && node.parent && node.parent.kind === 168 && node.parent.expression === node; } function isNewExpressionTarget(node) { if (isRightSideOfPropertyAccess(node)) { node = node.parent; } - return node && node.parent && node.parent.kind === 167 && node.parent.expression === node; + return node && node.parent && node.parent.kind === 169 && node.parent.expression === node; } function isNameOfModuleDeclaration(node) { - return node.parent.kind === 216 && node.parent.name === node; + return node.parent.kind === 218 && node.parent.name === node; } function isNameOfFunctionDeclaration(node) { - return node.kind === 67 && + return node.kind === 69 && ts.isFunctionLike(node.parent) && node.parent.name === node; } function isNameOfPropertyAssignment(node) { - return (node.kind === 67 || node.kind === 9 || node.kind === 8) && - (node.parent.kind === 243 || node.parent.kind === 244) && node.parent.name === node; + return (node.kind === 69 || node.kind === 9 || node.kind === 8) && + (node.parent.kind === 245 || node.parent.kind === 246) && node.parent.name === node; } function isLiteralNameOfPropertyDeclarationOrIndexAccess(node) { if (node.kind === 9 || node.kind === 8) { switch (node.parent.kind) { - case 139: - case 138: - case 243: - case 245: case 141: case 140: + case 245: + case 247: case 143: - case 144: - case 216: + case 142: + case 145: + case 146: + case 218: return node.parent.name === node; - case 165: + case 167: return node.parent.argumentExpression === node; } } @@ -36677,7 +37305,7 @@ var ts; } } var keywordCompletions = []; - for (var i = 68; i <= 132; i++) { + for (var i = 70; i <= 134; i++) { keywordCompletions.push({ name: ts.tokenToString(i), kind: ScriptElementKind.keyword, @@ -36692,17 +37320,17 @@ var ts; return undefined; } switch (node.kind) { - case 246: - case 141: - case 140: - case 211: - case 171: + case 248: case 143: - case 144: - case 212: + case 142: case 213: + case 173: + case 145: + case 146: + case 214: case 215: - case 216: + case 217: + case 218: return node; } } @@ -36710,38 +37338,38 @@ var ts; ts.getContainerNode = getContainerNode; function getNodeKind(node) { switch (node.kind) { - case 216: return ScriptElementKind.moduleElement; - case 212: return ScriptElementKind.classElement; - case 213: return ScriptElementKind.interfaceElement; - case 214: return ScriptElementKind.typeElement; - case 215: return ScriptElementKind.enumElement; - case 209: + case 218: return ScriptElementKind.moduleElement; + case 214: return ScriptElementKind.classElement; + case 215: return ScriptElementKind.interfaceElement; + case 216: return ScriptElementKind.typeElement; + case 217: return ScriptElementKind.enumElement; + case 211: return ts.isConst(node) ? ScriptElementKind.constElement : ts.isLet(node) ? ScriptElementKind.letElement : ScriptElementKind.variableElement; - case 211: return ScriptElementKind.functionElement; - case 143: return ScriptElementKind.memberGetAccessorElement; - case 144: return ScriptElementKind.memberSetAccessorElement; + case 213: return ScriptElementKind.functionElement; + case 145: return ScriptElementKind.memberGetAccessorElement; + case 146: return ScriptElementKind.memberSetAccessorElement; + case 143: + case 142: + return ScriptElementKind.memberFunctionElement; case 141: case 140: - return ScriptElementKind.memberFunctionElement; - case 139: - case 138: return ScriptElementKind.memberVariableElement; - case 147: return ScriptElementKind.indexSignatureElement; - case 146: return ScriptElementKind.constructSignatureElement; - case 145: return ScriptElementKind.callSignatureElement; - case 142: return ScriptElementKind.constructorImplementationElement; - case 135: return ScriptElementKind.typeParameterElement; - case 245: return ScriptElementKind.variableElement; - case 136: return (node.flags & 112) ? ScriptElementKind.memberVariableElement : ScriptElementKind.parameterElement; - case 219: - case 224: + case 149: return ScriptElementKind.indexSignatureElement; + case 148: return ScriptElementKind.constructSignatureElement; + case 147: return ScriptElementKind.callSignatureElement; + case 144: return ScriptElementKind.constructorImplementationElement; + case 137: return ScriptElementKind.typeParameterElement; + case 247: return ScriptElementKind.variableElement; + case 138: return (node.flags & 112) ? ScriptElementKind.memberVariableElement : ScriptElementKind.parameterElement; case 221: - case 228: - case 222: + case 226: + case 223: + case 230: + case 224: return ScriptElementKind.alias; } return ScriptElementKind.unknown; @@ -36904,7 +37532,7 @@ var ts; function getSemanticDiagnostics(fileName) { synchronizeHostData(); var targetSourceFile = getValidSourceFile(fileName); - if (ts.isJavaScript(fileName)) { + if (ts.isSourceFileJavaScript(targetSourceFile)) { return getJavaScriptSemanticDiagnostics(targetSourceFile); } var semanticDiagnostics = program.getSemanticDiagnostics(targetSourceFile, cancellationToken); @@ -36923,44 +37551,44 @@ var ts; return false; } switch (node.kind) { - case 219: + case 221: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.import_can_only_be_used_in_a_ts_file)); return true; - case 225: + case 227: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.export_can_only_be_used_in_a_ts_file)); return true; - case 212: + case 214: var classDeclaration = node; if (checkModifiers(classDeclaration.modifiers) || checkTypeParameters(classDeclaration.typeParameters)) { return true; } break; - case 241: + case 243: var heritageClause = node; - if (heritageClause.token === 104) { + if (heritageClause.token === 106) { diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.implements_clauses_can_only_be_used_in_a_ts_file)); return true; } break; - case 213: + case 215: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.interface_declarations_can_only_be_used_in_a_ts_file)); return true; - case 216: + case 218: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.module_declarations_can_only_be_used_in_a_ts_file)); return true; - case 214: + case 216: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.type_aliases_can_only_be_used_in_a_ts_file)); return true; - case 141: - case 140: - case 142: case 143: + case 142: case 144: - case 171: - case 211: - case 172: - case 211: + case 145: + case 146: + case 173: + case 213: + case 174: + case 213: var functionDeclaration = node; if (checkModifiers(functionDeclaration.modifiers) || checkTypeParameters(functionDeclaration.typeParameters) || @@ -36968,20 +37596,20 @@ var ts; return true; } break; - case 191: + case 193: var variableStatement = node; if (checkModifiers(variableStatement.modifiers)) { return true; } break; - case 209: + case 211: var variableDeclaration = node; if (checkTypeAnnotation(variableDeclaration.type)) { return true; } break; - case 166: - case 167: + case 168: + case 169: var expression = node; if (expression.typeArguments && expression.typeArguments.length > 0) { var start = expression.typeArguments.pos; @@ -36989,7 +37617,7 @@ var ts; return true; } break; - case 136: + case 138: var parameter = node; if (parameter.modifiers) { var start = parameter.modifiers.pos; @@ -37005,17 +37633,17 @@ var ts; return true; } break; - case 139: + case 141: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.property_declarations_can_only_be_used_in_a_ts_file)); return true; - case 215: + case 217: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.enum_declarations_can_only_be_used_in_a_ts_file)); return true; - case 169: + case 171: var typeAssertionExpression = node; diagnostics.push(ts.createDiagnosticForNode(typeAssertionExpression.type, ts.Diagnostics.type_assertion_expressions_can_only_be_used_in_a_ts_file)); return true; - case 137: + case 139: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.decorators_can_only_be_used_in_a_ts_file)); return true; } @@ -37041,17 +37669,17 @@ var ts; for (var _i = 0; _i < modifiers.length; _i++) { var modifier = modifiers[_i]; switch (modifier.kind) { + case 112: case 110: - case 108: - case 109: - case 120: + case 111: + case 122: diagnostics.push(ts.createDiagnosticForNode(modifier, ts.Diagnostics._0_can_only_be_used_in_a_ts_file, ts.tokenToString(modifier.kind))); return true; - case 111: - case 80: - case 72: - case 75: case 113: + case 82: + case 74: + case 77: + case 115: } } } @@ -37096,7 +37724,7 @@ var ts; var typeChecker = program.getTypeChecker(); var syntacticStart = new Date().getTime(); var sourceFile = getValidSourceFile(fileName); - var isJavaScriptFile = ts.isJavaScript(fileName); + var isJavaScriptFile = ts.isSourceFileJavaScript(sourceFile); var isJsDocTagName = false; var start = new Date().getTime(); var currentToken = ts.getTokenAtPosition(sourceFile, position); @@ -37115,9 +37743,9 @@ var ts; isJsDocTagName = true; } switch (tag.kind) { + case 269: case 267: - case 265: - case 266: + case 268: var tagWithExpression = tag; if (tagWithExpression.typeExpression) { insideJsDocTagExpression = tagWithExpression.typeExpression.pos < position && position < tagWithExpression.typeExpression.end; @@ -37145,6 +37773,7 @@ var ts; var node = currentToken; var isRightOfDot = false; var isRightOfOpenTag = false; + var isStartingCloseTag = false; var location = ts.getTouchingPropertyName(sourceFile, position); if (contextToken) { if (isCompletionListBlocker(contextToken)) { @@ -37153,11 +37782,11 @@ var ts; } var parent_9 = contextToken.parent, kind = contextToken.kind; if (kind === 21) { - if (parent_9.kind === 164) { + if (parent_9.kind === 166) { node = contextToken.parent.expression; isRightOfDot = true; } - else if (parent_9.kind === 133) { + else if (parent_9.kind === 135) { node = contextToken.parent.left; isRightOfDot = true; } @@ -37165,9 +37794,14 @@ var ts; return undefined; } } - else if (kind === 25 && sourceFile.languageVariant === 1) { - isRightOfOpenTag = true; - location = contextToken; + else if (sourceFile.languageVariant === 1) { + if (kind === 25) { + isRightOfOpenTag = true; + location = contextToken; + } + else if (kind === 39 && contextToken.parent.kind === 237) { + isStartingCloseTag = true; + } } } var semanticStart = new Date().getTime(); @@ -37188,6 +37822,12 @@ var ts; isMemberCompletion = true; isNewIdentifierLocation = false; } + else if (isStartingCloseTag) { + var tagName = contextToken.parent.parent.openingElement.tagName; + symbols = [typeChecker.getSymbolAtLocation(tagName)]; + isMemberCompletion = true; + isNewIdentifierLocation = false; + } else { if (!tryGetGlobalSymbols()) { return undefined; @@ -37198,7 +37838,7 @@ var ts; function getTypeScriptMemberSymbols() { isMemberCompletion = true; isNewIdentifierLocation = false; - if (node.kind === 67 || node.kind === 133 || node.kind === 164) { + if (node.kind === 69 || node.kind === 135 || node.kind === 166) { var symbol = typeChecker.getSymbolAtLocation(node); if (symbol && symbol.flags & 8388608) { symbol = typeChecker.getAliasedSymbol(symbol); @@ -37244,7 +37884,7 @@ var ts; } if (jsxContainer = tryGetContainingJsxElement(contextToken)) { var attrsType; - if ((jsxContainer.kind === 232) || (jsxContainer.kind === 233)) { + if ((jsxContainer.kind === 234) || (jsxContainer.kind === 235)) { attrsType = typeChecker.getJsxElementAttributesType(jsxContainer); if (attrsType) { symbols = filterJsxAttributes(typeChecker.getPropertiesOfType(attrsType), jsxContainer.attributes); @@ -37278,49 +37918,64 @@ var ts; var start = new Date().getTime(); var result = isInStringOrRegularExpressionOrTemplateLiteral(contextToken) || isSolelyIdentifierDefinitionLocation(contextToken) || - isDotOfNumericLiteral(contextToken); + isDotOfNumericLiteral(contextToken) || + isInJsxText(contextToken); log("getCompletionsAtPosition: isCompletionListBlocker: " + (new Date().getTime() - start)); return result; } + function isInJsxText(contextToken) { + if (contextToken.kind === 236) { + return true; + } + if (contextToken.kind === 27 && contextToken.parent) { + if (contextToken.parent.kind === 235) { + return true; + } + if (contextToken.parent.kind === 237 || contextToken.parent.kind === 234) { + return contextToken.parent.parent && contextToken.parent.parent.kind === 233; + } + } + return false; + } function isNewIdentifierDefinitionLocation(previousToken) { if (previousToken) { var containingNodeKind = previousToken.parent.kind; switch (previousToken.kind) { case 24: - return containingNodeKind === 166 - || containingNodeKind === 142 - || containingNodeKind === 167 - || containingNodeKind === 162 - || containingNodeKind === 179 - || containingNodeKind === 150; + return containingNodeKind === 168 + || containingNodeKind === 144 + || containingNodeKind === 169 + || containingNodeKind === 164 + || containingNodeKind === 181 + || containingNodeKind === 152; case 17: - return containingNodeKind === 166 - || containingNodeKind === 142 - || containingNodeKind === 167 - || containingNodeKind === 170 - || containingNodeKind === 158; + return containingNodeKind === 168 + || containingNodeKind === 144 + || containingNodeKind === 169 + || containingNodeKind === 172 + || containingNodeKind === 160; case 19: - return containingNodeKind === 162 - || containingNodeKind === 147 - || containingNodeKind === 134; - case 123: - case 124: + return containingNodeKind === 164 + || containingNodeKind === 149 + || containingNodeKind === 136; + case 125: + case 126: return true; case 21: - return containingNodeKind === 216; + return containingNodeKind === 218; case 15: - return containingNodeKind === 212; - case 55: - return containingNodeKind === 209 - || containingNodeKind === 179; + return containingNodeKind === 214; + case 56: + return containingNodeKind === 211 + || containingNodeKind === 181; case 12: - return containingNodeKind === 181; + return containingNodeKind === 183; case 13: - return containingNodeKind === 188; + return containingNodeKind === 190; + case 112: case 110: - case 108: - case 109: - return containingNodeKind === 139; + case 111: + return containingNodeKind === 141; } switch (previousToken.getText()) { case "public": @@ -37351,12 +38006,12 @@ var ts; isMemberCompletion = true; var typeForObject; var existingMembers; - if (objectLikeContainer.kind === 163) { + if (objectLikeContainer.kind === 165) { isNewIdentifierLocation = true; typeForObject = typeChecker.getContextualType(objectLikeContainer); existingMembers = objectLikeContainer.properties; } - else if (objectLikeContainer.kind === 159) { + else if (objectLikeContainer.kind === 161) { isNewIdentifierLocation = false; var rootDeclaration = ts.getRootDeclaration(objectLikeContainer.parent); if (ts.isVariableLike(rootDeclaration)) { @@ -37382,9 +38037,9 @@ var ts; return true; } function tryGetImportOrExportClauseCompletionSymbols(namedImportsOrExports) { - var declarationKind = namedImportsOrExports.kind === 223 ? - 220 : - 226; + var declarationKind = namedImportsOrExports.kind === 225 ? + 222 : + 228; var importOrExportDeclaration = ts.getAncestor(namedImportsOrExports, declarationKind); var moduleSpecifier = importOrExportDeclaration.moduleSpecifier; if (!moduleSpecifier) { @@ -37406,7 +38061,7 @@ var ts; case 15: case 24: var parent_10 = contextToken.parent; - if (parent_10 && (parent_10.kind === 163 || parent_10.kind === 159)) { + if (parent_10 && (parent_10.kind === 165 || parent_10.kind === 161)) { return parent_10; } break; @@ -37420,8 +38075,8 @@ var ts; case 15: case 24: switch (contextToken.parent.kind) { - case 223: - case 227: + case 225: + case 229: return contextToken.parent; } } @@ -37433,27 +38088,30 @@ var ts; var parent_11 = contextToken.parent; switch (contextToken.kind) { case 26: - case 38: - case 67: - case 236: - case 237: - if (parent_11 && (parent_11.kind === 232 || parent_11.kind === 233)) { + case 39: + case 69: + case 238: + case 239: + if (parent_11 && (parent_11.kind === 234 || parent_11.kind === 235)) { return parent_11; } + else if (parent_11.kind === 238) { + return parent_11.parent; + } break; case 9: - if (parent_11 && ((parent_11.kind === 236) || (parent_11.kind === 237))) { + if (parent_11 && ((parent_11.kind === 238) || (parent_11.kind === 239))) { return parent_11.parent; } break; case 16: if (parent_11 && - parent_11.kind === 238 && + parent_11.kind === 240 && parent_11.parent && - (parent_11.parent.kind === 236)) { + (parent_11.parent.kind === 238)) { return parent_11.parent.parent; } - if (parent_11 && parent_11.kind === 237) { + if (parent_11 && parent_11.kind === 239) { return parent_11.parent; } break; @@ -37463,16 +38121,16 @@ var ts; } function isFunction(kind) { switch (kind) { - case 171: - case 172: - case 211: - case 141: - case 140: + case 173: + case 174: + case 213: case 143: - case 144: + case 142: case 145: case 146: case 147: + case 148: + case 149: return true; } return false; @@ -37481,77 +38139,83 @@ var ts; var containingNodeKind = contextToken.parent.kind; switch (contextToken.kind) { case 24: - return containingNodeKind === 209 || - containingNodeKind === 210 || - containingNodeKind === 191 || - containingNodeKind === 215 || - isFunction(containingNodeKind) || + return containingNodeKind === 211 || containingNodeKind === 212 || - containingNodeKind === 184 || - containingNodeKind === 213 || - containingNodeKind === 160 || - containingNodeKind === 214; + containingNodeKind === 193 || + containingNodeKind === 217 || + isFunction(containingNodeKind) || + containingNodeKind === 214 || + containingNodeKind === 186 || + containingNodeKind === 215 || + containingNodeKind === 162 || + containingNodeKind === 216; case 21: - return containingNodeKind === 160; - case 53: - return containingNodeKind === 161; + return containingNodeKind === 162; + case 54: + return containingNodeKind === 163; case 19: - return containingNodeKind === 160; + return containingNodeKind === 162; case 17: - return containingNodeKind === 242 || + return containingNodeKind === 244 || isFunction(containingNodeKind); case 15: - return containingNodeKind === 215 || - containingNodeKind === 213 || - containingNodeKind === 153; + return containingNodeKind === 217 || + containingNodeKind === 215 || + containingNodeKind === 155; case 23: - return containingNodeKind === 138 && + return containingNodeKind === 140 && contextToken.parent && contextToken.parent.parent && - (contextToken.parent.parent.kind === 213 || - contextToken.parent.parent.kind === 153); + (contextToken.parent.parent.kind === 215 || + contextToken.parent.parent.kind === 155); case 25: - return containingNodeKind === 212 || - containingNodeKind === 184 || - containingNodeKind === 213 || - containingNodeKind === 214 || + return containingNodeKind === 214 || + containingNodeKind === 186 || + containingNodeKind === 215 || + containingNodeKind === 216 || isFunction(containingNodeKind); - case 111: - return containingNodeKind === 139; + case 113: + return containingNodeKind === 141; case 22: - return containingNodeKind === 136 || + return containingNodeKind === 138 || (contextToken.parent && contextToken.parent.parent && - contextToken.parent.parent.kind === 160); - case 110: - case 108: - case 109: - return containingNodeKind === 136; - case 114: - containingNodeKind === 224 || - containingNodeKind === 228 || - containingNodeKind === 222; - case 71: - case 79: - case 105: - case 85: - case 100: - case 121: - case 127: - case 87: - case 106: - case 72: + contextToken.parent.parent.kind === 162); case 112: - case 130: + case 110: + case 111: + return containingNodeKind === 138; + case 116: + return containingNodeKind === 226 || + containingNodeKind === 230 || + containingNodeKind === 224; + case 73: + case 81: + case 107: + case 87: + case 102: + case 123: + case 129: + case 89: + case 108: + case 74: + case 114: + case 132: return true; } switch (contextToken.getText()) { + case "abstract": + case "async": case "class": - case "interface": + case "const": + case "declare": case "enum": case "function": - case "var": - case "static": + case "interface": case "let": - case "const": + case "private": + case "protected": + case "public": + case "static": + case "var": case "yield": return true; } @@ -37571,8 +38235,8 @@ var ts; if (element.getStart() <= position && position <= element.getEnd()) { continue; } - var name_31 = element.propertyName || element.name; - exisingImportsOrExports[name_31.text] = true; + var name_32 = element.propertyName || element.name; + exisingImportsOrExports[name_32.text] = true; } if (ts.isEmpty(exisingImportsOrExports)) { return exportsOfModule; @@ -37586,16 +38250,16 @@ var ts; var existingMemberNames = {}; for (var _i = 0; _i < existingMembers.length; _i++) { var m = existingMembers[_i]; - if (m.kind !== 243 && - m.kind !== 244 && - m.kind !== 161) { + if (m.kind !== 245 && + m.kind !== 246 && + m.kind !== 163) { continue; } if (m.getStart() <= position && position <= m.getEnd()) { continue; } var existingName = void 0; - if (m.kind === 161 && m.propertyName) { + if (m.kind === 163 && m.propertyName) { existingName = m.propertyName.text; } else { @@ -37612,7 +38276,7 @@ var ts; if (attr.getStart() <= position && position <= attr.getEnd()) { continue; } - if (attr.kind === 236) { + if (attr.kind === 238) { seenNames[attr.name.text] = true; } } @@ -37626,44 +38290,41 @@ var ts; return undefined; } var symbols = completionData.symbols, isMemberCompletion = completionData.isMemberCompletion, isNewIdentifierLocation = completionData.isNewIdentifierLocation, location = completionData.location, isRightOfDot = completionData.isRightOfDot, isJsDocTagName = completionData.isJsDocTagName; - var entries; if (isJsDocTagName) { return { isMemberCompletion: false, isNewIdentifierLocation: false, entries: getAllJsDocCompletionEntries() }; } - if (isRightOfDot && ts.isJavaScript(fileName)) { - entries = getCompletionEntriesFromSymbols(symbols); - ts.addRange(entries, getJavaScriptCompletionEntries()); + var sourceFile = getValidSourceFile(fileName); + var entries = []; + if (isRightOfDot && ts.isSourceFileJavaScript(sourceFile)) { + var uniqueNames = getCompletionEntriesFromSymbols(symbols, entries); + ts.addRange(entries, getJavaScriptCompletionEntries(sourceFile, uniqueNames)); } else { if (!symbols || symbols.length === 0) { return undefined; } - entries = getCompletionEntriesFromSymbols(symbols); + getCompletionEntriesFromSymbols(symbols, entries); } if (!isMemberCompletion && !isJsDocTagName) { ts.addRange(entries, keywordCompletions); } return { isMemberCompletion: isMemberCompletion, isNewIdentifierLocation: isNewIdentifierLocation, entries: entries }; - function getJavaScriptCompletionEntries() { + function getJavaScriptCompletionEntries(sourceFile, uniqueNames) { var entries = []; - var allNames = {}; var target = program.getCompilerOptions().target; - for (var _i = 0, _a = program.getSourceFiles(); _i < _a.length; _i++) { - var sourceFile = _a[_i]; - var nameTable = getNameTable(sourceFile); - for (var name_32 in nameTable) { - if (!allNames[name_32]) { - allNames[name_32] = name_32; - var displayName = getCompletionEntryDisplayName(name_32, target, true); - if (displayName) { - var entry = { - name: displayName, - kind: ScriptElementKind.warning, - kindModifiers: "", - sortText: "1" - }; - entries.push(entry); - } + var nameTable = getNameTable(sourceFile); + for (var name_33 in nameTable) { + if (!uniqueNames[name_33]) { + uniqueNames[name_33] = name_33; + var displayName = getCompletionEntryDisplayName(name_33, target, true); + if (displayName) { + var entry = { + name: displayName, + kind: ScriptElementKind.warning, + kindModifiers: "", + sortText: "1" + }; + entries.push(entry); } } } @@ -37691,25 +38352,24 @@ var ts; sortText: "0" }; } - function getCompletionEntriesFromSymbols(symbols) { + function getCompletionEntriesFromSymbols(symbols, entries) { var start = new Date().getTime(); - var entries = []; + var uniqueNames = {}; if (symbols) { - var nameToSymbol = {}; for (var _i = 0; _i < symbols.length; _i++) { var symbol = symbols[_i]; var entry = createCompletionEntry(symbol, location); if (entry) { var id = ts.escapeIdentifier(entry.name); - if (!ts.lookUp(nameToSymbol, id)) { + if (!ts.lookUp(uniqueNames, id)) { entries.push(entry); - nameToSymbol[id] = symbol; + uniqueNames[id] = id; } } } } log("getCompletionsAtPosition: getCompletionEntriesFromSymbols: " + (new Date().getTime() - start)); - return entries; + return uniqueNames; } } function getCompletionEntryDetails(fileName, position, entryName) { @@ -37745,7 +38405,7 @@ var ts; function getSymbolKind(symbol, location) { var flags = symbol.getFlags(); if (flags & 32) - return ts.getDeclarationOfKind(symbol, 184) ? + return ts.getDeclarationOfKind(symbol, 186) ? ScriptElementKind.localClassElement : ScriptElementKind.classElement; if (flags & 384) return ScriptElementKind.enumElement; @@ -37841,14 +38501,14 @@ var ts; var signature; type = typeChecker.getTypeOfSymbolAtLocation(symbol, location); if (type) { - if (location.parent && location.parent.kind === 164) { + if (location.parent && location.parent.kind === 166) { var right = location.parent.name; if (right === location || (right && right.getFullWidth() === 0)) { location = location.parent; } } var callExpression; - if (location.kind === 166 || location.kind === 167) { + if (location.kind === 168 || location.kind === 169) { callExpression = location; } else if (isCallExpressionTarget(location) || isNewExpressionTarget(location)) { @@ -37860,9 +38520,9 @@ var ts; if (!signature && candidateSignatures.length) { signature = candidateSignatures[0]; } - var useConstructSignatures = callExpression.kind === 167 || callExpression.expression.kind === 93; + var useConstructSignatures = callExpression.kind === 169 || callExpression.expression.kind === 95; var allSignatures = useConstructSignatures ? type.getConstructSignatures() : type.getCallSignatures(); - if (!ts.contains(allSignatures, signature.target || signature)) { + if (!ts.contains(allSignatures, signature.target) && !ts.contains(allSignatures, signature)) { signature = allSignatures.length ? allSignatures[0] : undefined; } if (signature) { @@ -37875,7 +38535,7 @@ var ts; pushTypePart(symbolKind); displayParts.push(ts.spacePart()); if (useConstructSignatures) { - displayParts.push(ts.keywordPart(90)); + displayParts.push(ts.keywordPart(92)); displayParts.push(ts.spacePart()); } addFullSymbolName(symbol); @@ -37890,10 +38550,10 @@ var ts; case ScriptElementKind.letElement: case ScriptElementKind.parameterElement: case ScriptElementKind.localVariableElement: - displayParts.push(ts.punctuationPart(53)); + displayParts.push(ts.punctuationPart(54)); displayParts.push(ts.spacePart()); if (useConstructSignatures) { - displayParts.push(ts.keywordPart(90)); + displayParts.push(ts.keywordPart(92)); displayParts.push(ts.spacePart()); } if (!(type.flags & 65536)) { @@ -37908,21 +38568,21 @@ var ts; } } else if ((isNameOfFunctionDeclaration(location) && !(symbol.flags & 98304)) || - (location.kind === 119 && location.parent.kind === 142)) { + (location.kind === 121 && location.parent.kind === 144)) { var functionDeclaration = location.parent; - var allSignatures = functionDeclaration.kind === 142 ? type.getConstructSignatures() : type.getCallSignatures(); + var allSignatures = functionDeclaration.kind === 144 ? type.getConstructSignatures() : type.getCallSignatures(); if (!typeChecker.isImplementationOfOverload(functionDeclaration)) { signature = typeChecker.getSignatureFromDeclaration(functionDeclaration); } else { signature = allSignatures[0]; } - if (functionDeclaration.kind === 142) { + if (functionDeclaration.kind === 144) { symbolKind = ScriptElementKind.constructorImplementationElement; addPrefixForAnyFunctionOrVar(type.symbol, symbolKind); } else { - addPrefixForAnyFunctionOrVar(functionDeclaration.kind === 145 && + addPrefixForAnyFunctionOrVar(functionDeclaration.kind === 147 && !(type.symbol.flags & 2048 || type.symbol.flags & 4096) ? type.symbol : symbol, symbolKind); } addSignatureDisplayParts(signature, allSignatures); @@ -37931,11 +38591,11 @@ var ts; } } if (symbolFlags & 32 && !hasAddedSymbolInfo) { - if (ts.getDeclarationOfKind(symbol, 184)) { + if (ts.getDeclarationOfKind(symbol, 186)) { pushTypePart(ScriptElementKind.localClassElement); } else { - displayParts.push(ts.keywordPart(71)); + displayParts.push(ts.keywordPart(73)); } displayParts.push(ts.spacePart()); addFullSymbolName(symbol); @@ -37943,37 +38603,37 @@ var ts; } if ((symbolFlags & 64) && (semanticMeaning & 2)) { addNewLineIfDisplayPartsExist(); - displayParts.push(ts.keywordPart(105)); + displayParts.push(ts.keywordPart(107)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); writeTypeParametersOfSymbol(symbol, sourceFile); } if (symbolFlags & 524288) { addNewLineIfDisplayPartsExist(); - displayParts.push(ts.keywordPart(130)); + displayParts.push(ts.keywordPart(132)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); writeTypeParametersOfSymbol(symbol, sourceFile); displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(55)); + displayParts.push(ts.operatorPart(56)); displayParts.push(ts.spacePart()); ts.addRange(displayParts, ts.typeToDisplayParts(typeChecker, typeChecker.getDeclaredTypeOfSymbol(symbol), enclosingDeclaration)); } if (symbolFlags & 384) { addNewLineIfDisplayPartsExist(); if (ts.forEach(symbol.declarations, ts.isConstEnumDeclaration)) { - displayParts.push(ts.keywordPart(72)); + displayParts.push(ts.keywordPart(74)); displayParts.push(ts.spacePart()); } - displayParts.push(ts.keywordPart(79)); + displayParts.push(ts.keywordPart(81)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); } if (symbolFlags & 1536) { addNewLineIfDisplayPartsExist(); - var declaration = ts.getDeclarationOfKind(symbol, 216); - var isNamespace = declaration && declaration.name && declaration.name.kind === 67; - displayParts.push(ts.keywordPart(isNamespace ? 124 : 123)); + var declaration = ts.getDeclarationOfKind(symbol, 218); + var isNamespace = declaration && declaration.name && declaration.name.kind === 69; + displayParts.push(ts.keywordPart(isNamespace ? 126 : 125)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); } @@ -37985,7 +38645,7 @@ var ts; displayParts.push(ts.spacePart()); addFullSymbolName(symbol); displayParts.push(ts.spacePart()); - displayParts.push(ts.keywordPart(88)); + displayParts.push(ts.keywordPart(90)); displayParts.push(ts.spacePart()); if (symbol.parent) { addFullSymbolName(symbol.parent, enclosingDeclaration); @@ -37994,20 +38654,20 @@ var ts; else { var container = ts.getContainingFunction(location); if (container) { - var signatureDeclaration = ts.getDeclarationOfKind(symbol, 135).parent; + var signatureDeclaration = ts.getDeclarationOfKind(symbol, 137).parent; var signature = typeChecker.getSignatureFromDeclaration(signatureDeclaration); - if (signatureDeclaration.kind === 146) { - displayParts.push(ts.keywordPart(90)); + if (signatureDeclaration.kind === 148) { + displayParts.push(ts.keywordPart(92)); displayParts.push(ts.spacePart()); } - else if (signatureDeclaration.kind !== 145 && signatureDeclaration.name) { + else if (signatureDeclaration.kind !== 147 && signatureDeclaration.name) { addFullSymbolName(signatureDeclaration.symbol); } ts.addRange(displayParts, ts.signatureToDisplayParts(typeChecker, signature, sourceFile, 32)); } else { - var declaration = ts.getDeclarationOfKind(symbol, 135).parent; - displayParts.push(ts.keywordPart(130)); + var declaration = ts.getDeclarationOfKind(symbol, 137).parent; + displayParts.push(ts.keywordPart(132)); displayParts.push(ts.spacePart()); addFullSymbolName(declaration.symbol); writeTypeParametersOfSymbol(declaration.symbol, sourceFile); @@ -38017,11 +38677,11 @@ var ts; if (symbolFlags & 8) { addPrefixForAnyFunctionOrVar(symbol, "enum member"); var declaration = symbol.declarations[0]; - if (declaration.kind === 245) { + if (declaration.kind === 247) { var constantValue = typeChecker.getConstantValue(declaration); if (constantValue !== undefined) { displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(55)); + displayParts.push(ts.operatorPart(56)); displayParts.push(ts.spacePart()); displayParts.push(ts.displayPart(constantValue.toString(), SymbolDisplayPartKind.numericLiteral)); } @@ -38029,17 +38689,17 @@ var ts; } if (symbolFlags & 8388608) { addNewLineIfDisplayPartsExist(); - displayParts.push(ts.keywordPart(87)); + displayParts.push(ts.keywordPart(89)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); ts.forEach(symbol.declarations, function (declaration) { - if (declaration.kind === 219) { + if (declaration.kind === 221) { var importEqualsDeclaration = declaration; if (ts.isExternalModuleImportEqualsDeclaration(importEqualsDeclaration)) { displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(55)); + displayParts.push(ts.operatorPart(56)); displayParts.push(ts.spacePart()); - displayParts.push(ts.keywordPart(125)); + displayParts.push(ts.keywordPart(127)); displayParts.push(ts.punctuationPart(17)); displayParts.push(ts.displayPart(ts.getTextOfNode(ts.getExternalModuleImportEqualsDeclarationExpression(importEqualsDeclaration)), SymbolDisplayPartKind.stringLiteral)); displayParts.push(ts.punctuationPart(18)); @@ -38048,7 +38708,7 @@ var ts; var internalAliasSymbol = typeChecker.getSymbolAtLocation(importEqualsDeclaration.moduleReference); if (internalAliasSymbol) { displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(55)); + displayParts.push(ts.operatorPart(56)); displayParts.push(ts.spacePart()); addFullSymbolName(internalAliasSymbol, enclosingDeclaration); } @@ -38064,7 +38724,7 @@ var ts; if (symbolKind === ScriptElementKind.memberVariableElement || symbolFlags & 3 || symbolKind === ScriptElementKind.localVariableElement) { - displayParts.push(ts.punctuationPart(53)); + displayParts.push(ts.punctuationPart(54)); displayParts.push(ts.spacePart()); if (type.symbol && type.symbol.flags & 262144) { var typeParameterParts = ts.mapToDisplayParts(function (writer) { @@ -38162,11 +38822,11 @@ var ts; var symbol = typeChecker.getSymbolAtLocation(node); if (!symbol) { switch (node.kind) { - case 67: - case 164: - case 133: + case 69: + case 166: + case 135: + case 97: case 95: - case 93: var type = typeChecker.getTypeAtLocation(node); if (type) { return { @@ -38215,7 +38875,7 @@ var ts; } return result; function tryAddConstructSignature(symbol, location, symbolKind, symbolName, containerName, result) { - if (isNewExpressionTarget(location) || location.kind === 119) { + if (isNewExpressionTarget(location) || location.kind === 121) { if (symbol.flags & 32) { for (var _i = 0, _a = symbol.getDeclarations(); _i < _a.length; _i++) { var declaration = _a[_i]; @@ -38238,8 +38898,8 @@ var ts; var declarations = []; var definition; ts.forEach(signatureDeclarations, function (d) { - if ((selectConstructors && d.kind === 142) || - (!selectConstructors && (d.kind === 211 || d.kind === 141 || d.kind === 140))) { + if ((selectConstructors && d.kind === 144) || + (!selectConstructors && (d.kind === 213 || d.kind === 143 || d.kind === 142))) { declarations.push(d); if (d.body) definition = d; @@ -38290,11 +38950,11 @@ var ts; } if (symbol.flags & 8388608) { var declaration = symbol.declarations[0]; - if (node.kind === 67 && node.parent === declaration) { + if (node.kind === 69 && node.parent === declaration) { symbol = typeChecker.getAliasedSymbol(symbol); } } - if (node.parent.kind === 244) { + if (node.parent.kind === 246) { var shorthandSymbol = typeChecker.getShorthandAssignmentValueSymbol(symbol.valueDeclaration); if (!shorthandSymbol) { return []; @@ -38365,9 +39025,9 @@ var ts; }; } function getSemanticDocumentHighlights(node) { - if (node.kind === 67 || + if (node.kind === 69 || + node.kind === 97 || node.kind === 95 || - node.kind === 93 || isLiteralNameOfPropertyDeclarationOrIndexAccess(node) || isNameOfExternalModuleImportOrDeclaration(node)) { var referencedSymbols = getReferencedSymbolsForNode(node, sourceFilesToSearch, false, false); @@ -38416,77 +39076,77 @@ var ts; function getHighlightSpans(node) { if (node) { switch (node.kind) { - case 86: - case 78: - if (hasKind(node.parent, 194)) { + case 88: + case 80: + if (hasKind(node.parent, 196)) { return getIfElseOccurrences(node.parent); } break; - case 92: - if (hasKind(node.parent, 202)) { - return getReturnOccurrences(node.parent); - } - break; - case 96: - if (hasKind(node.parent, 206)) { - return getThrowOccurrences(node.parent); - } - break; - case 70: - if (hasKind(parent(parent(node)), 207)) { - return getTryCatchFinallyOccurrences(node.parent.parent); - } - break; - case 98: - case 83: - if (hasKind(parent(node), 207)) { - return getTryCatchFinallyOccurrences(node.parent); - } - break; case 94: if (hasKind(node.parent, 204)) { + return getReturnOccurrences(node.parent); + } + break; + case 98: + if (hasKind(node.parent, 208)) { + return getThrowOccurrences(node.parent); + } + break; + case 72: + if (hasKind(parent(parent(node)), 209)) { + return getTryCatchFinallyOccurrences(node.parent.parent); + } + break; + case 100: + case 85: + if (hasKind(parent(node), 209)) { + return getTryCatchFinallyOccurrences(node.parent); + } + break; + case 96: + if (hasKind(node.parent, 206)) { return getSwitchCaseDefaultOccurrences(node.parent); } break; - case 69: - case 75: - if (hasKind(parent(parent(parent(node))), 204)) { + case 71: + case 77: + if (hasKind(parent(parent(parent(node))), 206)) { return getSwitchCaseDefaultOccurrences(node.parent.parent.parent); } break; - case 68: - case 73: - if (hasKind(node.parent, 201) || hasKind(node.parent, 200)) { + case 70: + case 75: + if (hasKind(node.parent, 203) || hasKind(node.parent, 202)) { return getBreakOrContinueStatementOccurrences(node.parent); } break; - case 84: - if (hasKind(node.parent, 197) || - hasKind(node.parent, 198) || - hasKind(node.parent, 199)) { + case 86: + if (hasKind(node.parent, 199) || + hasKind(node.parent, 200) || + hasKind(node.parent, 201)) { return getLoopBreakContinueOccurrences(node.parent); } break; - case 102: - case 77: - if (hasKind(node.parent, 196) || hasKind(node.parent, 195)) { + case 104: + case 79: + if (hasKind(node.parent, 198) || hasKind(node.parent, 197)) { return getLoopBreakContinueOccurrences(node.parent); } break; - case 119: - if (hasKind(node.parent, 142)) { - return getConstructorOccurrences(node.parent); - } - break; case 121: - case 127: - if (hasKind(node.parent, 143) || hasKind(node.parent, 144)) { + if (hasKind(node.parent, 144)) { + return getConstructorOccurrences(node.parent); + } + break; + case 123: + case 129: + if (hasKind(node.parent, 145) || hasKind(node.parent, 146)) { return getGetAndSetOccurrences(node.parent); } break; default: if (ts.isModifier(node.kind) && node.parent && - (ts.isDeclaration(node.parent) || node.parent.kind === 191)) { + (ts.isDeclaration(node.parent) || node.parent.kind === 193)) { return getModifierOccurrences(node.kind, node.parent); } } @@ -38498,10 +39158,10 @@ var ts; aggregate(node); return statementAccumulator; function aggregate(node) { - if (node.kind === 206) { + if (node.kind === 208) { statementAccumulator.push(node); } - else if (node.kind === 207) { + else if (node.kind === 209) { var tryStatement = node; if (tryStatement.catchClause) { aggregate(tryStatement.catchClause); @@ -38523,10 +39183,10 @@ var ts; var child = throwStatement; while (child.parent) { var parent_12 = child.parent; - if (ts.isFunctionBlock(parent_12) || parent_12.kind === 246) { + if (ts.isFunctionBlock(parent_12) || parent_12.kind === 248) { return parent_12; } - if (parent_12.kind === 207) { + if (parent_12.kind === 209) { var tryStatement = parent_12; if (tryStatement.tryBlock === child && tryStatement.catchClause) { return child; @@ -38541,7 +39201,7 @@ var ts; aggregate(node); return statementAccumulator; function aggregate(node) { - if (node.kind === 201 || node.kind === 200) { + if (node.kind === 203 || node.kind === 202) { statementAccumulator.push(node); } else if (!ts.isFunctionLike(node)) { @@ -38557,15 +39217,15 @@ var ts; function getBreakOrContinueOwner(statement) { for (var node_2 = statement.parent; node_2; node_2 = node_2.parent) { switch (node_2.kind) { - case 204: - if (statement.kind === 200) { + case 206: + if (statement.kind === 202) { continue; } - case 197: - case 198: case 199: - case 196: - case 195: + case 200: + case 201: + case 198: + case 197: if (!statement.label || isLabeledBy(node_2, statement.label.text)) { return node_2; } @@ -38582,24 +39242,24 @@ var ts; function getModifierOccurrences(modifier, declaration) { var container = declaration.parent; if (ts.isAccessibilityModifier(modifier)) { - if (!(container.kind === 212 || - container.kind === 184 || - (declaration.kind === 136 && hasKind(container, 142)))) { - return undefined; - } - } - else if (modifier === 111) { - if (!(container.kind === 212 || container.kind === 184)) { - return undefined; - } - } - else if (modifier === 80 || modifier === 120) { - if (!(container.kind === 217 || container.kind === 246)) { + if (!(container.kind === 214 || + container.kind === 186 || + (declaration.kind === 138 && hasKind(container, 144)))) { return undefined; } } else if (modifier === 113) { - if (!(container.kind === 212 || declaration.kind === 212)) { + if (!(container.kind === 214 || container.kind === 186)) { + return undefined; + } + } + else if (modifier === 82 || modifier === 122) { + if (!(container.kind === 219 || container.kind === 248)) { + return undefined; + } + } + else if (modifier === 115) { + if (!(container.kind === 214 || declaration.kind === 214)) { return undefined; } } @@ -38610,8 +39270,8 @@ var ts; var modifierFlag = getFlagFromModifier(modifier); var nodes; switch (container.kind) { - case 217: - case 246: + case 219: + case 248: if (modifierFlag & 256) { nodes = declaration.members.concat(declaration); } @@ -38619,15 +39279,15 @@ var ts; nodes = container.statements; } break; - case 142: + case 144: nodes = container.parameters.concat(container.parent.members); break; - case 212: - case 184: + case 214: + case 186: nodes = container.members; if (modifierFlag & 112) { var constructor = ts.forEach(container.members, function (member) { - return member.kind === 142 && member; + return member.kind === 144 && member; }); if (constructor) { nodes = nodes.concat(constructor.parameters); @@ -38648,19 +39308,19 @@ var ts; return ts.map(keywords, getHighlightSpanForNode); function getFlagFromModifier(modifier) { switch (modifier) { - case 110: + case 112: return 16; - case 108: + case 110: return 32; - case 109: - return 64; case 111: - return 128; - case 80: - return 1; - case 120: - return 2; + return 64; case 113: + return 128; + case 82: + return 1; + case 122: + return 2; + case 115: return 256; default: ts.Debug.fail(); @@ -38680,13 +39340,13 @@ var ts; } function getGetAndSetOccurrences(accessorDeclaration) { var keywords = []; - tryPushAccessorKeyword(accessorDeclaration.symbol, 143); - tryPushAccessorKeyword(accessorDeclaration.symbol, 144); + tryPushAccessorKeyword(accessorDeclaration.symbol, 145); + tryPushAccessorKeyword(accessorDeclaration.symbol, 146); return ts.map(keywords, getHighlightSpanForNode); function tryPushAccessorKeyword(accessorSymbol, accessorKind) { var accessor = ts.getDeclarationOfKind(accessorSymbol, accessorKind); if (accessor) { - ts.forEach(accessor.getChildren(), function (child) { return pushKeywordIf(keywords, child, 121, 127); }); + ts.forEach(accessor.getChildren(), function (child) { return pushKeywordIf(keywords, child, 123, 129); }); } } } @@ -38695,18 +39355,18 @@ var ts; var keywords = []; ts.forEach(declarations, function (declaration) { ts.forEach(declaration.getChildren(), function (token) { - return pushKeywordIf(keywords, token, 119); + return pushKeywordIf(keywords, token, 121); }); }); return ts.map(keywords, getHighlightSpanForNode); } function getLoopBreakContinueOccurrences(loopNode) { var keywords = []; - if (pushKeywordIf(keywords, loopNode.getFirstToken(), 84, 102, 77)) { - if (loopNode.kind === 195) { + if (pushKeywordIf(keywords, loopNode.getFirstToken(), 86, 104, 79)) { + if (loopNode.kind === 197) { var loopTokens = loopNode.getChildren(); for (var i = loopTokens.length - 1; i >= 0; i--) { - if (pushKeywordIf(keywords, loopTokens[i], 102)) { + if (pushKeywordIf(keywords, loopTokens[i], 104)) { break; } } @@ -38715,7 +39375,7 @@ var ts; var breaksAndContinues = aggregateAllBreakAndContinueStatements(loopNode.statement); ts.forEach(breaksAndContinues, function (statement) { if (ownsBreakOrContinueStatement(loopNode, statement)) { - pushKeywordIf(keywords, statement.getFirstToken(), 68, 73); + pushKeywordIf(keywords, statement.getFirstToken(), 70, 75); } }); return ts.map(keywords, getHighlightSpanForNode); @@ -38724,13 +39384,13 @@ var ts; var owner = getBreakOrContinueOwner(breakOrContinueStatement); if (owner) { switch (owner.kind) { + case 199: + case 200: + case 201: case 197: case 198: - case 199: - case 195: - case 196: return getLoopBreakContinueOccurrences(owner); - case 204: + case 206: return getSwitchCaseDefaultOccurrences(owner); } } @@ -38738,13 +39398,13 @@ var ts; } function getSwitchCaseDefaultOccurrences(switchStatement) { var keywords = []; - pushKeywordIf(keywords, switchStatement.getFirstToken(), 94); + pushKeywordIf(keywords, switchStatement.getFirstToken(), 96); ts.forEach(switchStatement.caseBlock.clauses, function (clause) { - pushKeywordIf(keywords, clause.getFirstToken(), 69, 75); + pushKeywordIf(keywords, clause.getFirstToken(), 71, 77); var breaksAndContinues = aggregateAllBreakAndContinueStatements(clause); ts.forEach(breaksAndContinues, function (statement) { if (ownsBreakOrContinueStatement(switchStatement, statement)) { - pushKeywordIf(keywords, statement.getFirstToken(), 68); + pushKeywordIf(keywords, statement.getFirstToken(), 70); } }); }); @@ -38752,13 +39412,13 @@ var ts; } function getTryCatchFinallyOccurrences(tryStatement) { var keywords = []; - pushKeywordIf(keywords, tryStatement.getFirstToken(), 98); + pushKeywordIf(keywords, tryStatement.getFirstToken(), 100); if (tryStatement.catchClause) { - pushKeywordIf(keywords, tryStatement.catchClause.getFirstToken(), 70); + pushKeywordIf(keywords, tryStatement.catchClause.getFirstToken(), 72); } if (tryStatement.finallyBlock) { - var finallyKeyword = ts.findChildOfKind(tryStatement, 83, sourceFile); - pushKeywordIf(keywords, finallyKeyword, 83); + var finallyKeyword = ts.findChildOfKind(tryStatement, 85, sourceFile); + pushKeywordIf(keywords, finallyKeyword, 85); } return ts.map(keywords, getHighlightSpanForNode); } @@ -38769,50 +39429,50 @@ var ts; } var keywords = []; ts.forEach(aggregateOwnedThrowStatements(owner), function (throwStatement) { - pushKeywordIf(keywords, throwStatement.getFirstToken(), 96); + pushKeywordIf(keywords, throwStatement.getFirstToken(), 98); }); if (ts.isFunctionBlock(owner)) { ts.forEachReturnStatement(owner, function (returnStatement) { - pushKeywordIf(keywords, returnStatement.getFirstToken(), 92); + pushKeywordIf(keywords, returnStatement.getFirstToken(), 94); }); } return ts.map(keywords, getHighlightSpanForNode); } function getReturnOccurrences(returnStatement) { var func = ts.getContainingFunction(returnStatement); - if (!(func && hasKind(func.body, 190))) { + if (!(func && hasKind(func.body, 192))) { return undefined; } var keywords = []; ts.forEachReturnStatement(func.body, function (returnStatement) { - pushKeywordIf(keywords, returnStatement.getFirstToken(), 92); + pushKeywordIf(keywords, returnStatement.getFirstToken(), 94); }); ts.forEach(aggregateOwnedThrowStatements(func.body), function (throwStatement) { - pushKeywordIf(keywords, throwStatement.getFirstToken(), 96); + pushKeywordIf(keywords, throwStatement.getFirstToken(), 98); }); return ts.map(keywords, getHighlightSpanForNode); } function getIfElseOccurrences(ifStatement) { var keywords = []; - while (hasKind(ifStatement.parent, 194) && ifStatement.parent.elseStatement === ifStatement) { + while (hasKind(ifStatement.parent, 196) && ifStatement.parent.elseStatement === ifStatement) { ifStatement = ifStatement.parent; } while (ifStatement) { var children = ifStatement.getChildren(); - pushKeywordIf(keywords, children[0], 86); + pushKeywordIf(keywords, children[0], 88); for (var i = children.length - 1; i >= 0; i--) { - if (pushKeywordIf(keywords, children[i], 78)) { + if (pushKeywordIf(keywords, children[i], 80)) { break; } } - if (!hasKind(ifStatement.elseStatement, 194)) { + if (!hasKind(ifStatement.elseStatement, 196)) { break; } ifStatement = ifStatement.elseStatement; } var result = []; for (var i = 0; i < keywords.length; i++) { - if (keywords[i].kind === 78 && i < keywords.length - 1) { + if (keywords[i].kind === 80 && i < keywords.length - 1) { var elseKeyword = keywords[i]; var ifKeyword = keywords[i + 1]; var shouldCombindElseAndIf = true; @@ -38890,12 +39550,12 @@ var ts; if (!node) { return undefined; } - if (node.kind !== 67 && + if (node.kind !== 69 && !isLiteralNameOfPropertyDeclarationOrIndexAccess(node) && !isNameOfExternalModuleImportOrDeclaration(node)) { return undefined; } - ts.Debug.assert(node.kind === 67 || node.kind === 8 || node.kind === 9); + ts.Debug.assert(node.kind === 69 || node.kind === 8 || node.kind === 9); return getReferencedSymbolsForNode(node, program.getSourceFiles(), findInStrings, findInComments); } function getReferencedSymbolsForNode(node, sourceFiles, findInStrings, findInComments) { @@ -38909,10 +39569,10 @@ var ts; return getLabelReferencesInNode(node.parent, node); } } - if (node.kind === 95) { + if (node.kind === 97) { return getReferencesForThisKeyword(node, sourceFiles); } - if (node.kind === 93) { + if (node.kind === 95) { return getReferencesForSuperKeyword(node); } var symbol = typeChecker.getSymbolAtLocation(node); @@ -38963,7 +39623,7 @@ var ts; } function isImportOrExportSpecifierImportSymbol(symbol) { return (symbol.flags & 8388608) && ts.forEach(symbol.declarations, function (declaration) { - return declaration.kind === 224 || declaration.kind === 228; + return declaration.kind === 226 || declaration.kind === 230; }); } function getInternedName(symbol, location, declarations) { @@ -38976,13 +39636,13 @@ var ts; } function getSymbolScope(symbol) { var valueDeclaration = symbol.valueDeclaration; - if (valueDeclaration && (valueDeclaration.kind === 171 || valueDeclaration.kind === 184)) { + if (valueDeclaration && (valueDeclaration.kind === 173 || valueDeclaration.kind === 186)) { return valueDeclaration; } if (symbol.flags & (4 | 8192)) { var privateDeclaration = ts.forEach(symbol.getDeclarations(), function (d) { return (d.flags & 32) ? d : undefined; }); if (privateDeclaration) { - return ts.getAncestor(privateDeclaration, 212); + return ts.getAncestor(privateDeclaration, 214); } } if (symbol.flags & 8388608) { @@ -39003,7 +39663,7 @@ var ts; if (scope && scope !== container) { return undefined; } - if (container.kind === 246 && !ts.isExternalModule(container)) { + if (container.kind === 248 && !ts.isExternalModule(container)) { return undefined; } scope = container; @@ -39062,7 +39722,7 @@ var ts; function isValidReferencePosition(node, searchSymbolName) { if (node) { switch (node.kind) { - case 67: + case 69: return node.getWidth() === searchSymbolName.length; case 9: if (isLiteralNameOfPropertyDeclarationOrIndexAccess(node) || @@ -39150,13 +39810,13 @@ var ts; } var staticFlag = 128; switch (searchSpaceNode.kind) { - case 139: - case 138: case 141: case 140: - case 142: case 143: + case 142: case 144: + case 145: + case 146: staticFlag &= searchSpaceNode.flags; searchSpaceNode = searchSpaceNode.parent; break; @@ -39169,7 +39829,7 @@ var ts; ts.forEach(possiblePositions, function (position) { cancellationToken.throwIfCancellationRequested(); var node = ts.getTouchingWord(sourceFile, position); - if (!node || node.kind !== 93) { + if (!node || node.kind !== 95) { return; } var container = ts.getSuperContainer(node, false); @@ -39184,32 +39844,32 @@ var ts; var searchSpaceNode = ts.getThisContainer(thisOrSuperKeyword, false); var staticFlag = 128; switch (searchSpaceNode.kind) { - case 141: - case 140: + case 143: + case 142: if (ts.isObjectLiteralMethod(searchSpaceNode)) { break; } - case 139: - case 138: - case 142: - case 143: + case 141: + case 140: case 144: + case 145: + case 146: staticFlag &= searchSpaceNode.flags; searchSpaceNode = searchSpaceNode.parent; break; - case 246: + case 248: if (ts.isExternalModule(searchSpaceNode)) { return undefined; } - case 211: - case 171: + case 213: + case 173: break; default: return undefined; } var references = []; var possiblePositions; - if (searchSpaceNode.kind === 246) { + if (searchSpaceNode.kind === 248) { ts.forEach(sourceFiles, function (sourceFile) { possiblePositions = getPossibleSymbolReferencePositions(sourceFile, "this", sourceFile.getStart(), sourceFile.getEnd()); getThisReferencesInFile(sourceFile, sourceFile, possiblePositions, references); @@ -39235,31 +39895,31 @@ var ts; ts.forEach(possiblePositions, function (position) { cancellationToken.throwIfCancellationRequested(); var node = ts.getTouchingWord(sourceFile, position); - if (!node || node.kind !== 95) { + if (!node || node.kind !== 97) { return; } var container = ts.getThisContainer(node, false); switch (searchSpaceNode.kind) { - case 171: - case 211: + case 173: + case 213: if (searchSpaceNode.symbol === container.symbol) { result.push(getReferenceEntryFromNode(node)); } break; - case 141: - case 140: + case 143: + case 142: if (ts.isObjectLiteralMethod(searchSpaceNode) && searchSpaceNode.symbol === container.symbol) { result.push(getReferenceEntryFromNode(node)); } break; - case 184: - case 212: + case 186: + case 214: if (container.parent && searchSpaceNode.symbol === container.parent.symbol && (container.flags & 128) === staticFlag) { result.push(getReferenceEntryFromNode(node)); } break; - case 246: - if (container.kind === 246 && !ts.isExternalModule(container)) { + case 248: + if (container.kind === 248 && !ts.isExternalModule(container)) { result.push(getReferenceEntryFromNode(node)); } break; @@ -39294,11 +39954,11 @@ var ts; function getPropertySymbolsFromBaseTypes(symbol, propertyName, result) { if (symbol && symbol.flags & (32 | 64)) { ts.forEach(symbol.getDeclarations(), function (declaration) { - if (declaration.kind === 212) { + if (declaration.kind === 214) { getPropertySymbolFromTypeReference(ts.getClassExtendsHeritageClauseElement(declaration)); ts.forEach(ts.getClassImplementsHeritageClauseElements(declaration), getPropertySymbolFromTypeReference); } - else if (declaration.kind === 213) { + else if (declaration.kind === 215) { ts.forEach(ts.getInterfaceBaseTypeNodes(declaration), getPropertySymbolFromTypeReference); } }); @@ -39348,17 +40008,17 @@ var ts; if (isNameOfPropertyAssignment(node)) { var objectLiteral = node.parent.parent; var contextualType = typeChecker.getContextualType(objectLiteral); - var name_33 = node.text; + var name_34 = node.text; if (contextualType) { if (contextualType.flags & 16384) { - var unionProperty = contextualType.getProperty(name_33); + var unionProperty = contextualType.getProperty(name_34); if (unionProperty) { return [unionProperty]; } else { var result_4 = []; ts.forEach(contextualType.types, function (t) { - var symbol = t.getProperty(name_33); + var symbol = t.getProperty(name_34); if (symbol) { result_4.push(symbol); } @@ -39367,7 +40027,7 @@ var ts; } } else { - var symbol_1 = contextualType.getProperty(name_33); + var symbol_1 = contextualType.getProperty(name_34); if (symbol_1) { return [symbol_1]; } @@ -39407,17 +40067,17 @@ var ts; }; } function isWriteAccess(node) { - if (node.kind === 67 && ts.isDeclarationName(node)) { + if (node.kind === 69 && ts.isDeclarationName(node)) { return true; } var parent = node.parent; if (parent) { - if (parent.kind === 178 || parent.kind === 177) { + if (parent.kind === 180 || parent.kind === 179) { return true; } - else if (parent.kind === 179 && parent.left === node) { + else if (parent.kind === 181 && parent.left === node) { var operator = parent.operatorToken.kind; - return 55 <= operator && operator <= 66; + return 56 <= operator && operator <= 68; } } return false; @@ -39448,33 +40108,33 @@ var ts; } function getMeaningFromDeclaration(node) { switch (node.kind) { - case 136: - case 209: - case 161: - case 139: case 138: - case 243: - case 244: - case 245: + case 211: + case 163: case 141: case 140: - case 142: + case 245: + case 246: + case 247: case 143: + case 142: case 144: - case 211: - case 171: - case 172: - case 242: - return 1; - case 135: + case 145: + case 146: case 213: - case 214: - case 153: - return 2; - case 212: + case 173: + case 174: + case 244: + return 1; + case 137: case 215: - return 1 | 2; case 216: + case 155: + return 2; + case 214: + case 217: + return 1 | 2; + case 218: if (node.name.kind === 9) { return 4 | 1; } @@ -39484,14 +40144,14 @@ var ts; else { return 4; } - case 223: - case 224: - case 219: - case 220: case 225: case 226: + case 221: + case 222: + case 227: + case 228: return 1 | 2 | 4; - case 246: + case 248: return 4 | 1; } return 1 | 2 | 4; @@ -39501,8 +40161,9 @@ var ts; if (ts.isRightSideOfQualifiedNameOrPropertyAccess(node)) { node = node.parent; } - return node.parent.kind === 149 || - (node.parent.kind === 186 && !ts.isExpressionWithTypeArgumentsInClassExtendsClause(node.parent)); + return node.parent.kind === 151 || + (node.parent.kind === 188 && !ts.isExpressionWithTypeArgumentsInClassExtendsClause(node.parent)) || + node.kind === 97 && !ts.isExpression(node); } function isNamespaceReference(node) { return isQualifiedNameNamespaceReference(node) || isPropertyAccessNamespaceReference(node); @@ -39510,47 +40171,47 @@ var ts; function isPropertyAccessNamespaceReference(node) { var root = node; var isLastClause = true; - if (root.parent.kind === 164) { - while (root.parent && root.parent.kind === 164) { + if (root.parent.kind === 166) { + while (root.parent && root.parent.kind === 166) { root = root.parent; } isLastClause = root.name === node; } - if (!isLastClause && root.parent.kind === 186 && root.parent.parent.kind === 241) { + if (!isLastClause && root.parent.kind === 188 && root.parent.parent.kind === 243) { var decl = root.parent.parent.parent; - return (decl.kind === 212 && root.parent.parent.token === 104) || - (decl.kind === 213 && root.parent.parent.token === 81); + return (decl.kind === 214 && root.parent.parent.token === 106) || + (decl.kind === 215 && root.parent.parent.token === 83); } return false; } function isQualifiedNameNamespaceReference(node) { var root = node; var isLastClause = true; - if (root.parent.kind === 133) { - while (root.parent && root.parent.kind === 133) { + if (root.parent.kind === 135) { + while (root.parent && root.parent.kind === 135) { root = root.parent; } isLastClause = root.right === node; } - return root.parent.kind === 149 && !isLastClause; + return root.parent.kind === 151 && !isLastClause; } function isInRightSideOfImport(node) { - while (node.parent.kind === 133) { + while (node.parent.kind === 135) { node = node.parent; } return ts.isInternalModuleImportEqualsDeclaration(node.parent) && node.parent.moduleReference === node; } function getMeaningFromRightHandSideOfImportEquals(node) { - ts.Debug.assert(node.kind === 67); - if (node.parent.kind === 133 && + ts.Debug.assert(node.kind === 69); + if (node.parent.kind === 135 && node.parent.right === node && - node.parent.parent.kind === 219) { + node.parent.parent.kind === 221) { return 1 | 2 | 4; } return 4; } function getMeaningFromLocation(node) { - if (node.parent.kind === 225) { + if (node.parent.kind === 227) { return 1 | 2 | 4; } else if (isInRightSideOfImport(node)) { @@ -39584,15 +40245,15 @@ var ts; return; } switch (node.kind) { - case 164: - case 133: + case 166: + case 135: case 9: - case 82: - case 97: - case 91: + case 84: + case 99: case 93: case 95: - case 67: + case 97: + case 69: break; default: return; @@ -39603,7 +40264,7 @@ var ts; nodeForStartPos = nodeForStartPos.parent; } else if (isNameOfModuleDeclaration(nodeForStartPos)) { - if (nodeForStartPos.parent.parent.kind === 216 && + if (nodeForStartPos.parent.parent.kind === 218 && nodeForStartPos.parent.parent.body === nodeForStartPos.parent) { nodeForStartPos = nodeForStartPos.parent.parent.name; } @@ -39630,10 +40291,10 @@ var ts; } function checkForClassificationCancellation(kind) { switch (kind) { - case 216: - case 212: + case 218: + case 214: + case 215: case 213: - case 211: cancellationToken.throwIfCancellationRequested(); } } @@ -39681,7 +40342,7 @@ var ts; return undefined; function hasValueSideModule(symbol) { return ts.forEach(symbol.declarations, function (declaration) { - return declaration.kind === 216 && + return declaration.kind === 218 && ts.getModuleInstanceState(declaration) === 1; }); } @@ -39690,7 +40351,7 @@ var ts; if (node && ts.textSpanIntersectsWith(span, node.getFullStart(), node.getFullWidth())) { var kind = node.kind; checkForClassificationCancellation(kind); - if (kind === 67 && !ts.nodeIsMissing(node)) { + if (kind === 69 && !ts.nodeIsMissing(node)) { var identifier = node; if (classifiableNames[identifier.text]) { var symbol = typeChecker.getSymbolAtLocation(node); @@ -39814,16 +40475,16 @@ var ts; pushClassification(tag.tagName.pos, tag.tagName.end - tag.tagName.pos, 18); pos = tag.tagName.end; switch (tag.kind) { - case 265: + case 267: processJSDocParameterTag(tag); break; - case 268: + case 270: processJSDocTemplateTag(tag); break; - case 267: + case 269: processElement(tag.typeExpression); break; - case 266: + case 268: processElement(tag.typeExpression); break; } @@ -39903,17 +40564,17 @@ var ts; } if (ts.isPunctuation(tokenKind)) { if (token) { - if (tokenKind === 55) { - if (token.parent.kind === 209 || - token.parent.kind === 139 || - token.parent.kind === 136) { + if (tokenKind === 56) { + if (token.parent.kind === 211 || + token.parent.kind === 141 || + token.parent.kind === 138) { return 5; } } - if (token.parent.kind === 179 || - token.parent.kind === 177 || - token.parent.kind === 178 || - token.parent.kind === 180) { + if (token.parent.kind === 181 || + token.parent.kind === 179 || + token.parent.kind === 180 || + token.parent.kind === 182) { return 5; } } @@ -39931,35 +40592,35 @@ var ts; else if (ts.isTemplateLiteralKind(tokenKind)) { return 6; } - else if (tokenKind === 67) { + else if (tokenKind === 69) { if (token) { switch (token.parent.kind) { - case 212: + case 214: if (token.parent.name === token) { return 11; } return; - case 135: + case 137: if (token.parent.name === token) { return 15; } return; - case 213: + case 215: if (token.parent.name === token) { return 13; } return; - case 215: + case 217: if (token.parent.name === token) { return 12; } return; - case 216: + case 218: if (token.parent.name === token) { return 14; } return; - case 136: + case 138: if (token.parent.name === token) { return 17; } @@ -40073,19 +40734,40 @@ var ts; if (!tokenAtPos || tokenStart < position) { return undefined; } - var containingFunction = ts.getAncestor(tokenAtPos, 211); - if (!containingFunction || containingFunction.getStart() < position) { + var commentOwner; + findOwner: for (commentOwner = tokenAtPos; commentOwner; commentOwner = commentOwner.parent) { + switch (commentOwner.kind) { + case 213: + case 143: + case 144: + case 214: + case 193: + break findOwner; + case 248: + return undefined; + case 218: + if (commentOwner.parent.kind === 218) { + return undefined; + } + break findOwner; + } + } + if (!commentOwner || commentOwner.getStart() < position) { return undefined; } - var parameters = containingFunction.parameters; + var parameters = getParametersForJsDocOwningNode(commentOwner); var posLineAndChar = sourceFile.getLineAndCharacterOfPosition(position); var lineStart = sourceFile.getLineStarts()[posLineAndChar.line]; var indentationStr = sourceFile.text.substr(lineStart, posLineAndChar.character); var newLine = host.getNewLine ? host.getNewLine() : "\r\n"; - var docParams = parameters.reduce(function (prev, cur, index) { - return prev + - indentationStr + " * @param " + (cur.name.kind === 67 ? cur.name.text : "param" + index) + newLine; - }, ""); + var docParams = ""; + for (var i = 0, numParams = parameters.length; i < numParams; i++) { + var currentName = parameters[i].name; + var paramName = currentName.kind === 69 ? + currentName.text : + "param" + i; + docParams += indentationStr + " * @param " + paramName + newLine; + } var preamble = "/**" + newLine + indentationStr + " * "; var result = preamble + newLine + @@ -40094,6 +40776,38 @@ var ts; (tokenStart === position ? newLine + indentationStr : ""); return { newText: result, caretOffset: preamble.length }; } + function getParametersForJsDocOwningNode(commentOwner) { + if (ts.isFunctionLike(commentOwner)) { + return commentOwner.parameters; + } + if (commentOwner.kind === 193) { + var varStatement = commentOwner; + var varDeclarations = varStatement.declarationList.declarations; + if (varDeclarations.length === 1 && varDeclarations[0].initializer) { + return getParametersFromRightHandSideOfAssignment(varDeclarations[0].initializer); + } + } + return emptyArray; + } + function getParametersFromRightHandSideOfAssignment(rightHandSide) { + while (rightHandSide.kind === 172) { + rightHandSide = rightHandSide.expression; + } + switch (rightHandSide.kind) { + case 173: + case 174: + return rightHandSide.parameters; + case 186: + for (var _i = 0, _a = rightHandSide.members; _i < _a.length; _i++) { + var member = _a[_i]; + if (member.kind === 144) { + return member.parameters; + } + } + break; + } + return emptyArray; + } function getTodoComments(fileName, descriptors) { synchronizeHostData(); var sourceFile = getValidSourceFile(fileName); @@ -40158,7 +40872,7 @@ var ts; var sourceFile = getValidSourceFile(fileName); var typeChecker = program.getTypeChecker(); var node = ts.getTouchingWord(sourceFile, position); - if (node && node.kind === 67) { + if (node && node.kind === 69) { var symbol = typeChecker.getSymbolAtLocation(node); if (symbol) { var declarations = symbol.getDeclarations(); @@ -40256,13 +40970,13 @@ var ts; sourceFile.nameTable = nameTable; function walk(node) { switch (node.kind) { - case 67: + case 69: nameTable[node.text] = node.text; break; case 9: case 8: if (ts.isDeclarationName(node) || - node.parent.kind === 230 || + node.parent.kind === 232 || isArgumentOfElementAccessExpression(node)) { nameTable[node.text] = node.text; } @@ -40275,31 +40989,31 @@ var ts; function isArgumentOfElementAccessExpression(node) { return node && node.parent && - node.parent.kind === 165 && + node.parent.kind === 167 && node.parent.argumentExpression === node; } function createClassifier() { var scanner = ts.createScanner(2, false); var noRegexTable = []; - noRegexTable[67] = true; + noRegexTable[69] = true; noRegexTable[9] = true; noRegexTable[8] = true; noRegexTable[10] = true; - noRegexTable[95] = true; - noRegexTable[40] = true; + noRegexTable[97] = true; noRegexTable[41] = true; + noRegexTable[42] = true; noRegexTable[18] = true; noRegexTable[20] = true; noRegexTable[16] = true; - noRegexTable[97] = true; - noRegexTable[82] = true; + noRegexTable[99] = true; + noRegexTable[84] = true; var templateStack = []; function canFollow(keyword1, keyword2) { if (ts.isAccessibilityModifier(keyword1)) { - if (keyword2 === 121 || - keyword2 === 127 || - keyword2 === 119 || - keyword2 === 111) { + if (keyword2 === 123 || + keyword2 === 129 || + keyword2 === 121 || + keyword2 === 113) { return true; } return false; @@ -40394,31 +41108,31 @@ var ts; do { token = scanner.scan(); if (!ts.isTrivia(token)) { - if ((token === 38 || token === 59) && !noRegexTable[lastNonTriviaToken]) { + if ((token === 39 || token === 61) && !noRegexTable[lastNonTriviaToken]) { if (scanner.reScanSlashToken() === 10) { token = 10; } } else if (lastNonTriviaToken === 21 && isKeyword(token)) { - token = 67; + token = 69; } else if (isKeyword(lastNonTriviaToken) && isKeyword(token) && !canFollow(lastNonTriviaToken, token)) { - token = 67; + token = 69; } - else if (lastNonTriviaToken === 67 && + else if (lastNonTriviaToken === 69 && token === 25) { angleBracketStack++; } else if (token === 27 && angleBracketStack > 0) { angleBracketStack--; } - else if (token === 115 || + else if (token === 117 || + token === 130 || token === 128 || - token === 126 || - token === 118 || - token === 129) { + token === 120 || + token === 131) { if (angleBracketStack > 0 && !syntacticClassifierAbsent) { - token = 67; + token = 69; } } else if (token === 12) { @@ -40516,40 +41230,41 @@ var ts; function isBinaryExpressionOperatorToken(token) { switch (token) { case 37: - case 38: case 39: + case 40: case 35: case 36: - case 42: case 43: case 44: + case 45: case 25: case 27: case 28: case 29: - case 89: - case 88: + case 91: + case 90: + case 116: case 30: case 31: case 32: case 33: - case 45: - case 47: case 46: - case 50: + case 48: + case 47: case 51: - case 65: - case 64: + case 52: + case 67: case 66: - case 61: - case 62: + case 68: case 63: - case 56: + case 64: + case 65: case 57: case 58: case 59: - case 60: - case 55: + case 61: + case 62: + case 56: case 24: return true; default: @@ -40560,17 +41275,17 @@ var ts; switch (token) { case 35: case 36: + case 50: case 49: - case 48: - case 40: case 41: + case 42: return true; default: return false; } } function isKeyword(token) { - return token >= 68 && token <= 132; + return token >= 70 && token <= 134; } function classFromKind(token) { if (isKeyword(token)) { @@ -40579,7 +41294,7 @@ var ts; else if (isBinaryExpressionOperatorToken(token) || isPrefixUnaryExpressionOperatorToken(token)) { return 5; } - else if (token >= 15 && token <= 66) { + else if (token >= 15 && token <= 68) { return 10; } switch (token) { @@ -40596,7 +41311,7 @@ var ts; case 5: case 4: return 8; - case 67: + case 69: default: if (ts.isTemplateLiteralKind(token)) { return 6; @@ -40622,7 +41337,7 @@ var ts; getNodeConstructor: function (kind) { function Node() { } - var proto = kind === 246 ? new SourceFileObject() : new NodeObject(); + var proto = kind === 248 ? new SourceFileObject() : new NodeObject(); proto.kind = kind; proto.pos = -1; proto.end = -1; @@ -40654,6 +41369,22 @@ var ts; return spaceCache[n]; } server.generateSpaces = generateSpaces; + function generateIndentString(n, editorOptions) { + if (editorOptions.ConvertTabsToSpaces) { + return generateSpaces(n); + } + else { + var result = ""; + for (var i = 0; i < Math.floor(n / editorOptions.TabSize); i++) { + result += "\t"; + } + for (var i = 0; i < n % editorOptions.TabSize; i++) { + result += " "; + } + return result; + } + } + server.generateIndentString = generateIndentString; function compareNumber(a, b) { if (a < b) { return -1; @@ -41265,28 +41996,27 @@ var ts; IndentSize: formatOptions.IndentSize, TabSize: formatOptions.TabSize, NewLineCharacter: "\n", - ConvertTabsToSpaces: formatOptions.ConvertTabsToSpaces + ConvertTabsToSpaces: formatOptions.ConvertTabsToSpaces, + IndentStyle: ts.IndentStyle.Smart }; - var indentPosition = compilerService.languageService.getIndentationAtPosition(file, position, editorOptions); + var preferredIndent = compilerService.languageService.getIndentationAtPosition(file, position, editorOptions); + var hasIndent = 0; for (var i = 0, len = lineText.length; i < len; i++) { if (lineText.charAt(i) == " ") { - indentPosition--; + hasIndent++; } else if (lineText.charAt(i) == "\t") { - indentPosition -= editorOptions.IndentSize; + hasIndent += editorOptions.TabSize; } else { break; } } - if (indentPosition > 0) { - var spaces = generateSpaces(indentPosition); - edits.push({ span: ts.createTextSpanFromBounds(position, position), newText: spaces }); - } - else if (indentPosition < 0) { + if (preferredIndent !== hasIndent) { + var firstNoWhiteSpacePosition = lineInfo.offset + i; edits.push({ - span: ts.createTextSpanFromBounds(position, position - indentPosition), - newText: "" + span: ts.createTextSpanFromBounds(lineInfo.offset, firstNoWhiteSpacePosition), + newText: generateIndentString(preferredIndent, editorOptions) }); } } @@ -41870,6 +42600,9 @@ var ts; this.filenameToSourceFile = {}; this.updateGraphSeq = 0; this.openRefCount = 0; + if (projectOptions && projectOptions.files) { + projectOptions.compilerOptions.allowNonTsExtensions = true; + } this.compilerService = new CompilerService(this, projectOptions && projectOptions.compilerOptions); } Project.prototype.addOpenRef = function () { @@ -41939,6 +42672,7 @@ var ts; Project.prototype.setProjectOptions = function (projectOptions) { this.projectOptions = projectOptions; if (projectOptions.compilerOptions) { + projectOptions.compilerOptions.allowNonTsExtensions = true; this.compilerService.setCompilerOptions(projectOptions.compilerOptions); } }; @@ -42524,7 +43258,9 @@ var ts; this.setCompilerOptions(opt); } else { - this.setCompilerOptions(ts.getDefaultCompilerOptions()); + var defaultOpts = ts.getDefaultCompilerOptions(); + defaultOpts.allowNonTsExtensions = true; + this.setCompilerOptions(defaultOpts); } this.languageService = ts.createLanguageService(this.host, this.documentRegistry); this.classifier = ts.createClassifier(); @@ -42542,6 +43278,7 @@ var ts; TabSize: 4, NewLineCharacter: ts.sys ? ts.sys.newLine : '\n', ConvertTabsToSpaces: true, + IndentStyle: ts.IndentStyle.Smart, InsertSpaceAfterCommaDelimiter: true, InsertSpaceAfterSemicolonInForStatements: true, InsertSpaceBeforeAndAfterBinaryOperators: true, @@ -43485,11 +44222,11 @@ var ts; } fs.stat(watchedFile.fileName, function (err, stats) { if (err) { - watchedFile.callback(watchedFile.fileName); + watchedFile.callback(watchedFile.fileName, false); } else if (watchedFile.mtime.getTime() !== stats.mtime.getTime()) { watchedFile.mtime = WatchedFileSet.getModifiedTime(watchedFile.fileName); - watchedFile.callback(watchedFile.fileName); + watchedFile.callback(watchedFile.fileName, watchedFile.mtime.getTime() === 0); } }); }; @@ -44135,7 +44872,7 @@ var ts; }; CoreServicesShimObject.prototype.getPreProcessedFileInfo = function (fileName, sourceTextSnapshot) { return this.forwardJSONCall("getPreProcessedFileInfo('" + fileName + "')", function () { - var result = ts.preProcessFile(sourceTextSnapshot.getText(0, sourceTextSnapshot.getLength())); + var result = ts.preProcessFile(sourceTextSnapshot.getText(0, sourceTextSnapshot.getLength()), true, true); var convertResult = { referencedFiles: [], importedFiles: [], diff --git a/lib/typescript.d.ts b/lib/typescript.d.ts index 2cd3a663fce..abfa9a002b5 100644 --- a/lib/typescript.d.ts +++ b/lib/typescript.d.ts @@ -68,253 +68,255 @@ declare namespace ts { PlusToken = 35, MinusToken = 36, AsteriskToken = 37, - SlashToken = 38, - PercentToken = 39, - PlusPlusToken = 40, - MinusMinusToken = 41, - LessThanLessThanToken = 42, - GreaterThanGreaterThanToken = 43, - GreaterThanGreaterThanGreaterThanToken = 44, - AmpersandToken = 45, - BarToken = 46, - CaretToken = 47, - ExclamationToken = 48, - TildeToken = 49, - AmpersandAmpersandToken = 50, - BarBarToken = 51, - QuestionToken = 52, - ColonToken = 53, - AtToken = 54, - EqualsToken = 55, - PlusEqualsToken = 56, - MinusEqualsToken = 57, - AsteriskEqualsToken = 58, - SlashEqualsToken = 59, - PercentEqualsToken = 60, - LessThanLessThanEqualsToken = 61, - GreaterThanGreaterThanEqualsToken = 62, - GreaterThanGreaterThanGreaterThanEqualsToken = 63, - AmpersandEqualsToken = 64, - BarEqualsToken = 65, - CaretEqualsToken = 66, - Identifier = 67, - BreakKeyword = 68, - CaseKeyword = 69, - CatchKeyword = 70, - ClassKeyword = 71, - ConstKeyword = 72, - ContinueKeyword = 73, - DebuggerKeyword = 74, - DefaultKeyword = 75, - DeleteKeyword = 76, - DoKeyword = 77, - ElseKeyword = 78, - EnumKeyword = 79, - ExportKeyword = 80, - ExtendsKeyword = 81, - FalseKeyword = 82, - FinallyKeyword = 83, - ForKeyword = 84, - FunctionKeyword = 85, - IfKeyword = 86, - ImportKeyword = 87, - InKeyword = 88, - InstanceOfKeyword = 89, - NewKeyword = 90, - NullKeyword = 91, - ReturnKeyword = 92, - SuperKeyword = 93, - SwitchKeyword = 94, - ThisKeyword = 95, - ThrowKeyword = 96, - TrueKeyword = 97, - TryKeyword = 98, - TypeOfKeyword = 99, - VarKeyword = 100, - VoidKeyword = 101, - WhileKeyword = 102, - WithKeyword = 103, - ImplementsKeyword = 104, - InterfaceKeyword = 105, - LetKeyword = 106, - PackageKeyword = 107, - PrivateKeyword = 108, - ProtectedKeyword = 109, - PublicKeyword = 110, - StaticKeyword = 111, - YieldKeyword = 112, - AbstractKeyword = 113, - AsKeyword = 114, - AnyKeyword = 115, - AsyncKeyword = 116, - AwaitKeyword = 117, - BooleanKeyword = 118, - ConstructorKeyword = 119, - DeclareKeyword = 120, - GetKeyword = 121, - IsKeyword = 122, - ModuleKeyword = 123, - NamespaceKeyword = 124, - RequireKeyword = 125, - NumberKeyword = 126, - SetKeyword = 127, - StringKeyword = 128, - SymbolKeyword = 129, - TypeKeyword = 130, - FromKeyword = 131, - OfKeyword = 132, - QualifiedName = 133, - ComputedPropertyName = 134, - TypeParameter = 135, - Parameter = 136, - Decorator = 137, - PropertySignature = 138, - PropertyDeclaration = 139, - MethodSignature = 140, - MethodDeclaration = 141, - Constructor = 142, - GetAccessor = 143, - SetAccessor = 144, - CallSignature = 145, - ConstructSignature = 146, - IndexSignature = 147, - TypePredicate = 148, - TypeReference = 149, - FunctionType = 150, - ConstructorType = 151, - TypeQuery = 152, - TypeLiteral = 153, - ArrayType = 154, - TupleType = 155, - UnionType = 156, - IntersectionType = 157, - ParenthesizedType = 158, - ObjectBindingPattern = 159, - ArrayBindingPattern = 160, - BindingElement = 161, - ArrayLiteralExpression = 162, - ObjectLiteralExpression = 163, - PropertyAccessExpression = 164, - ElementAccessExpression = 165, - CallExpression = 166, - NewExpression = 167, - TaggedTemplateExpression = 168, - TypeAssertionExpression = 169, - ParenthesizedExpression = 170, - FunctionExpression = 171, - ArrowFunction = 172, - DeleteExpression = 173, - TypeOfExpression = 174, - VoidExpression = 175, - AwaitExpression = 176, - PrefixUnaryExpression = 177, - PostfixUnaryExpression = 178, - BinaryExpression = 179, - ConditionalExpression = 180, - TemplateExpression = 181, - YieldExpression = 182, - SpreadElementExpression = 183, - ClassExpression = 184, - OmittedExpression = 185, - ExpressionWithTypeArguments = 186, - AsExpression = 187, - TemplateSpan = 188, - SemicolonClassElement = 189, - Block = 190, - VariableStatement = 191, - EmptyStatement = 192, - ExpressionStatement = 193, - IfStatement = 194, - DoStatement = 195, - WhileStatement = 196, - ForStatement = 197, - ForInStatement = 198, - ForOfStatement = 199, - ContinueStatement = 200, - BreakStatement = 201, - ReturnStatement = 202, - WithStatement = 203, - SwitchStatement = 204, - LabeledStatement = 205, - ThrowStatement = 206, - TryStatement = 207, - DebuggerStatement = 208, - VariableDeclaration = 209, - VariableDeclarationList = 210, - FunctionDeclaration = 211, - ClassDeclaration = 212, - InterfaceDeclaration = 213, - TypeAliasDeclaration = 214, - EnumDeclaration = 215, - ModuleDeclaration = 216, - ModuleBlock = 217, - CaseBlock = 218, - ImportEqualsDeclaration = 219, - ImportDeclaration = 220, - ImportClause = 221, - NamespaceImport = 222, - NamedImports = 223, - ImportSpecifier = 224, - ExportAssignment = 225, - ExportDeclaration = 226, - NamedExports = 227, - ExportSpecifier = 228, - MissingDeclaration = 229, - ExternalModuleReference = 230, - JsxElement = 231, - JsxSelfClosingElement = 232, - JsxOpeningElement = 233, - JsxText = 234, - JsxClosingElement = 235, - JsxAttribute = 236, - JsxSpreadAttribute = 237, - JsxExpression = 238, - CaseClause = 239, - DefaultClause = 240, - HeritageClause = 241, - CatchClause = 242, - PropertyAssignment = 243, - ShorthandPropertyAssignment = 244, - EnumMember = 245, - SourceFile = 246, - JSDocTypeExpression = 247, - JSDocAllType = 248, - JSDocUnknownType = 249, - JSDocArrayType = 250, - JSDocUnionType = 251, - JSDocTupleType = 252, - JSDocNullableType = 253, - JSDocNonNullableType = 254, - JSDocRecordType = 255, - JSDocRecordMember = 256, - JSDocTypeReference = 257, - JSDocOptionalType = 258, - JSDocFunctionType = 259, - JSDocVariadicType = 260, - JSDocConstructorType = 261, - JSDocThisType = 262, - JSDocComment = 263, - JSDocTag = 264, - JSDocParameterTag = 265, - JSDocReturnTag = 266, - JSDocTypeTag = 267, - JSDocTemplateTag = 268, - SyntaxList = 269, - Count = 270, - FirstAssignment = 55, - LastAssignment = 66, - FirstReservedWord = 68, - LastReservedWord = 103, - FirstKeyword = 68, - LastKeyword = 132, - FirstFutureReservedWord = 104, - LastFutureReservedWord = 112, - FirstTypeNode = 149, - LastTypeNode = 158, + AsteriskAsteriskToken = 38, + SlashToken = 39, + PercentToken = 40, + PlusPlusToken = 41, + MinusMinusToken = 42, + LessThanLessThanToken = 43, + GreaterThanGreaterThanToken = 44, + GreaterThanGreaterThanGreaterThanToken = 45, + AmpersandToken = 46, + BarToken = 47, + CaretToken = 48, + ExclamationToken = 49, + TildeToken = 50, + AmpersandAmpersandToken = 51, + BarBarToken = 52, + QuestionToken = 53, + ColonToken = 54, + AtToken = 55, + EqualsToken = 56, + PlusEqualsToken = 57, + MinusEqualsToken = 58, + AsteriskEqualsToken = 59, + AsteriskAsteriskEqualsToken = 60, + SlashEqualsToken = 61, + PercentEqualsToken = 62, + LessThanLessThanEqualsToken = 63, + GreaterThanGreaterThanEqualsToken = 64, + GreaterThanGreaterThanGreaterThanEqualsToken = 65, + AmpersandEqualsToken = 66, + BarEqualsToken = 67, + CaretEqualsToken = 68, + Identifier = 69, + BreakKeyword = 70, + CaseKeyword = 71, + CatchKeyword = 72, + ClassKeyword = 73, + ConstKeyword = 74, + ContinueKeyword = 75, + DebuggerKeyword = 76, + DefaultKeyword = 77, + DeleteKeyword = 78, + DoKeyword = 79, + ElseKeyword = 80, + EnumKeyword = 81, + ExportKeyword = 82, + ExtendsKeyword = 83, + FalseKeyword = 84, + FinallyKeyword = 85, + ForKeyword = 86, + FunctionKeyword = 87, + IfKeyword = 88, + ImportKeyword = 89, + InKeyword = 90, + InstanceOfKeyword = 91, + NewKeyword = 92, + NullKeyword = 93, + ReturnKeyword = 94, + SuperKeyword = 95, + SwitchKeyword = 96, + ThisKeyword = 97, + ThrowKeyword = 98, + TrueKeyword = 99, + TryKeyword = 100, + TypeOfKeyword = 101, + VarKeyword = 102, + VoidKeyword = 103, + WhileKeyword = 104, + WithKeyword = 105, + ImplementsKeyword = 106, + InterfaceKeyword = 107, + LetKeyword = 108, + PackageKeyword = 109, + PrivateKeyword = 110, + ProtectedKeyword = 111, + PublicKeyword = 112, + StaticKeyword = 113, + YieldKeyword = 114, + AbstractKeyword = 115, + AsKeyword = 116, + AnyKeyword = 117, + AsyncKeyword = 118, + AwaitKeyword = 119, + BooleanKeyword = 120, + ConstructorKeyword = 121, + DeclareKeyword = 122, + GetKeyword = 123, + IsKeyword = 124, + ModuleKeyword = 125, + NamespaceKeyword = 126, + RequireKeyword = 127, + NumberKeyword = 128, + SetKeyword = 129, + StringKeyword = 130, + SymbolKeyword = 131, + TypeKeyword = 132, + FromKeyword = 133, + OfKeyword = 134, + QualifiedName = 135, + ComputedPropertyName = 136, + TypeParameter = 137, + Parameter = 138, + Decorator = 139, + PropertySignature = 140, + PropertyDeclaration = 141, + MethodSignature = 142, + MethodDeclaration = 143, + Constructor = 144, + GetAccessor = 145, + SetAccessor = 146, + CallSignature = 147, + ConstructSignature = 148, + IndexSignature = 149, + TypePredicate = 150, + TypeReference = 151, + FunctionType = 152, + ConstructorType = 153, + TypeQuery = 154, + TypeLiteral = 155, + ArrayType = 156, + TupleType = 157, + UnionType = 158, + IntersectionType = 159, + ParenthesizedType = 160, + ObjectBindingPattern = 161, + ArrayBindingPattern = 162, + BindingElement = 163, + ArrayLiteralExpression = 164, + ObjectLiteralExpression = 165, + PropertyAccessExpression = 166, + ElementAccessExpression = 167, + CallExpression = 168, + NewExpression = 169, + TaggedTemplateExpression = 170, + TypeAssertionExpression = 171, + ParenthesizedExpression = 172, + FunctionExpression = 173, + ArrowFunction = 174, + DeleteExpression = 175, + TypeOfExpression = 176, + VoidExpression = 177, + AwaitExpression = 178, + PrefixUnaryExpression = 179, + PostfixUnaryExpression = 180, + BinaryExpression = 181, + ConditionalExpression = 182, + TemplateExpression = 183, + YieldExpression = 184, + SpreadElementExpression = 185, + ClassExpression = 186, + OmittedExpression = 187, + ExpressionWithTypeArguments = 188, + AsExpression = 189, + TemplateSpan = 190, + SemicolonClassElement = 191, + Block = 192, + VariableStatement = 193, + EmptyStatement = 194, + ExpressionStatement = 195, + IfStatement = 196, + DoStatement = 197, + WhileStatement = 198, + ForStatement = 199, + ForInStatement = 200, + ForOfStatement = 201, + ContinueStatement = 202, + BreakStatement = 203, + ReturnStatement = 204, + WithStatement = 205, + SwitchStatement = 206, + LabeledStatement = 207, + ThrowStatement = 208, + TryStatement = 209, + DebuggerStatement = 210, + VariableDeclaration = 211, + VariableDeclarationList = 212, + FunctionDeclaration = 213, + ClassDeclaration = 214, + InterfaceDeclaration = 215, + TypeAliasDeclaration = 216, + EnumDeclaration = 217, + ModuleDeclaration = 218, + ModuleBlock = 219, + CaseBlock = 220, + ImportEqualsDeclaration = 221, + ImportDeclaration = 222, + ImportClause = 223, + NamespaceImport = 224, + NamedImports = 225, + ImportSpecifier = 226, + ExportAssignment = 227, + ExportDeclaration = 228, + NamedExports = 229, + ExportSpecifier = 230, + MissingDeclaration = 231, + ExternalModuleReference = 232, + JsxElement = 233, + JsxSelfClosingElement = 234, + JsxOpeningElement = 235, + JsxText = 236, + JsxClosingElement = 237, + JsxAttribute = 238, + JsxSpreadAttribute = 239, + JsxExpression = 240, + CaseClause = 241, + DefaultClause = 242, + HeritageClause = 243, + CatchClause = 244, + PropertyAssignment = 245, + ShorthandPropertyAssignment = 246, + EnumMember = 247, + SourceFile = 248, + JSDocTypeExpression = 249, + JSDocAllType = 250, + JSDocUnknownType = 251, + JSDocArrayType = 252, + JSDocUnionType = 253, + JSDocTupleType = 254, + JSDocNullableType = 255, + JSDocNonNullableType = 256, + JSDocRecordType = 257, + JSDocRecordMember = 258, + JSDocTypeReference = 259, + JSDocOptionalType = 260, + JSDocFunctionType = 261, + JSDocVariadicType = 262, + JSDocConstructorType = 263, + JSDocThisType = 264, + JSDocComment = 265, + JSDocTag = 266, + JSDocParameterTag = 267, + JSDocReturnTag = 268, + JSDocTypeTag = 269, + JSDocTemplateTag = 270, + SyntaxList = 271, + Count = 272, + FirstAssignment = 56, + LastAssignment = 68, + FirstReservedWord = 70, + LastReservedWord = 105, + FirstKeyword = 70, + LastKeyword = 134, + FirstFutureReservedWord = 106, + LastFutureReservedWord = 114, + FirstTypeNode = 151, + LastTypeNode = 160, FirstPunctuation = 15, - LastPunctuation = 66, + LastPunctuation = 68, FirstToken = 0, - LastToken = 132, + LastToken = 134, FirstTriviaToken = 2, LastTriviaToken = 7, FirstLiteralToken = 8, @@ -322,8 +324,8 @@ declare namespace ts { FirstTemplateToken = 11, LastTemplateToken = 14, FirstBinaryOperator = 25, - LastBinaryOperator = 66, - FirstNode = 133, + LastBinaryOperator = 68, + FirstNode = 135, } const enum NodeFlags { Export = 1, @@ -343,6 +345,7 @@ declare namespace ts { OctalLiteral = 65536, Namespace = 131072, ExportContext = 262144, + ContainsThis = 524288, Modifier = 2035, AccessibilityModifier = 112, BlockScoped = 49152, @@ -438,6 +441,8 @@ declare namespace ts { interface ShorthandPropertyAssignment extends ObjectLiteralElement { name: Identifier; questionToken?: Node; + equalsToken?: Node; + objectAssignmentInitializer?: Expression; } interface VariableLikeDeclaration extends Declaration { propertyName?: Identifier; @@ -530,18 +535,21 @@ declare namespace ts { interface UnaryExpression extends Expression { _unaryExpressionBrand: any; } - interface PrefixUnaryExpression extends UnaryExpression { + interface IncrementExpression extends UnaryExpression { + _incrementExpressionBrand: any; + } + interface PrefixUnaryExpression extends IncrementExpression { operator: SyntaxKind; operand: UnaryExpression; } - interface PostfixUnaryExpression extends PostfixExpression { + interface PostfixUnaryExpression extends IncrementExpression { operand: LeftHandSideExpression; operator: SyntaxKind; } interface PostfixExpression extends UnaryExpression { _postfixExpressionBrand: any; } - interface LeftHandSideExpression extends PostfixExpression { + interface LeftHandSideExpression extends IncrementExpression { _leftHandSideExpressionBrand: any; } interface MemberExpression extends LeftHandSideExpression { @@ -566,7 +574,7 @@ declare namespace ts { asteriskToken?: Node; expression?: Expression; } - interface BinaryExpression extends Expression { + interface BinaryExpression extends Expression, Declaration { left: Expression; operatorToken: Node; right: Expression; @@ -610,7 +618,7 @@ declare namespace ts { interface ObjectLiteralExpression extends PrimaryExpression, Declaration { properties: NodeArray; } - interface PropertyAccessExpression extends MemberExpression { + interface PropertyAccessExpression extends MemberExpression, Declaration { expression: LeftHandSideExpression; dotToken: Node; name: Identifier; @@ -1082,6 +1090,7 @@ declare namespace ts { decreaseIndent(): void; clear(): void; trackSymbol(symbol: Symbol, enclosingDeclaration?: Node, meaning?: SymbolFlags): void; + reportInaccessibleThisError(): void; } const enum TypeFormatFlags { None = 0, @@ -1202,6 +1211,7 @@ declare namespace ts { Instantiated = 131072, ObjectLiteral = 524288, ESSymbol = 16777216, + ThisType = 33554432, StringLike = 258, NumberLike = 132, ObjectType = 80896, @@ -1223,6 +1233,7 @@ declare namespace ts { typeParameters: TypeParameter[]; outerTypeParameters: TypeParameter[]; localTypeParameters: TypeParameter[]; + thisType: TypeParameter; } interface InterfaceTypeWithDeclaredMembers extends InterfaceType { declaredProperties: Symbol[]; @@ -1337,7 +1348,6 @@ declare namespace ts { watch?: boolean; isolatedModules?: boolean; experimentalDecorators?: boolean; - experimentalAsyncFunctions?: boolean; emitDecoratorMetadata?: boolean; moduleResolution?: ModuleResolutionKind; [option: string]: string | number | boolean; @@ -1348,6 +1358,7 @@ declare namespace ts { AMD = 2, UMD = 3, System = 4, + ES6 = 5, } const enum JsxEmit { None = 0, @@ -1417,7 +1428,7 @@ declare namespace ts { write(s: string): void; readFile(path: string, encoding?: string): string; writeFile(path: string, data: string, writeByteOrderMark?: boolean): void; - watchFile?(path: string, callback: (path: string) => void): FileWatcher; + watchFile?(path: string, callback: (path: string, removed: boolean) => void): FileWatcher; resolvePath(path: string): string; fileExists(path: string): boolean; directoryExists(path: string): boolean; @@ -1775,6 +1786,12 @@ declare namespace ts { TabSize: number; NewLineCharacter: string; ConvertTabsToSpaces: boolean; + IndentStyle: IndentStyle; + } + enum IndentStyle { + None = 0, + Block = 1, + Smart = 2, } interface FormatCodeOptions extends EditorOptions { InsertSpaceAfterCommaDelimiter: boolean; @@ -2132,7 +2149,7 @@ declare namespace ts { function updateLanguageServiceSourceFile(sourceFile: SourceFile, scriptSnapshot: IScriptSnapshot, version: string, textChangeRange: TextChangeRange, aggressiveChecks?: boolean): SourceFile; function createGetCanonicalFileName(useCaseSensitivefileNames: boolean): (fileName: string) => string; function createDocumentRegistry(useCaseSensitiveFileNames?: boolean): DocumentRegistry; - function preProcessFile(sourceText: string, readImportFiles?: boolean): PreProcessedFileInfo; + function preProcessFile(sourceText: string, readImportFiles?: boolean, detectJavaScriptImports?: boolean): PreProcessedFileInfo; function createLanguageService(host: LanguageServiceHost, documentRegistry?: DocumentRegistry): LanguageService; function createClassifier(): Classifier; /** diff --git a/lib/typescript.js b/lib/typescript.js index a1f9651570e..d261ce125fc 100644 --- a/lib/typescript.js +++ b/lib/typescript.js @@ -62,279 +62,281 @@ var ts; SyntaxKind[SyntaxKind["PlusToken"] = 35] = "PlusToken"; SyntaxKind[SyntaxKind["MinusToken"] = 36] = "MinusToken"; SyntaxKind[SyntaxKind["AsteriskToken"] = 37] = "AsteriskToken"; - SyntaxKind[SyntaxKind["SlashToken"] = 38] = "SlashToken"; - SyntaxKind[SyntaxKind["PercentToken"] = 39] = "PercentToken"; - SyntaxKind[SyntaxKind["PlusPlusToken"] = 40] = "PlusPlusToken"; - SyntaxKind[SyntaxKind["MinusMinusToken"] = 41] = "MinusMinusToken"; - SyntaxKind[SyntaxKind["LessThanLessThanToken"] = 42] = "LessThanLessThanToken"; - SyntaxKind[SyntaxKind["GreaterThanGreaterThanToken"] = 43] = "GreaterThanGreaterThanToken"; - SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanToken"] = 44] = "GreaterThanGreaterThanGreaterThanToken"; - SyntaxKind[SyntaxKind["AmpersandToken"] = 45] = "AmpersandToken"; - SyntaxKind[SyntaxKind["BarToken"] = 46] = "BarToken"; - SyntaxKind[SyntaxKind["CaretToken"] = 47] = "CaretToken"; - SyntaxKind[SyntaxKind["ExclamationToken"] = 48] = "ExclamationToken"; - SyntaxKind[SyntaxKind["TildeToken"] = 49] = "TildeToken"; - SyntaxKind[SyntaxKind["AmpersandAmpersandToken"] = 50] = "AmpersandAmpersandToken"; - SyntaxKind[SyntaxKind["BarBarToken"] = 51] = "BarBarToken"; - SyntaxKind[SyntaxKind["QuestionToken"] = 52] = "QuestionToken"; - SyntaxKind[SyntaxKind["ColonToken"] = 53] = "ColonToken"; - SyntaxKind[SyntaxKind["AtToken"] = 54] = "AtToken"; + SyntaxKind[SyntaxKind["AsteriskAsteriskToken"] = 38] = "AsteriskAsteriskToken"; + SyntaxKind[SyntaxKind["SlashToken"] = 39] = "SlashToken"; + SyntaxKind[SyntaxKind["PercentToken"] = 40] = "PercentToken"; + SyntaxKind[SyntaxKind["PlusPlusToken"] = 41] = "PlusPlusToken"; + SyntaxKind[SyntaxKind["MinusMinusToken"] = 42] = "MinusMinusToken"; + SyntaxKind[SyntaxKind["LessThanLessThanToken"] = 43] = "LessThanLessThanToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanToken"] = 44] = "GreaterThanGreaterThanToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanToken"] = 45] = "GreaterThanGreaterThanGreaterThanToken"; + SyntaxKind[SyntaxKind["AmpersandToken"] = 46] = "AmpersandToken"; + SyntaxKind[SyntaxKind["BarToken"] = 47] = "BarToken"; + SyntaxKind[SyntaxKind["CaretToken"] = 48] = "CaretToken"; + SyntaxKind[SyntaxKind["ExclamationToken"] = 49] = "ExclamationToken"; + SyntaxKind[SyntaxKind["TildeToken"] = 50] = "TildeToken"; + SyntaxKind[SyntaxKind["AmpersandAmpersandToken"] = 51] = "AmpersandAmpersandToken"; + SyntaxKind[SyntaxKind["BarBarToken"] = 52] = "BarBarToken"; + SyntaxKind[SyntaxKind["QuestionToken"] = 53] = "QuestionToken"; + SyntaxKind[SyntaxKind["ColonToken"] = 54] = "ColonToken"; + SyntaxKind[SyntaxKind["AtToken"] = 55] = "AtToken"; // Assignments - SyntaxKind[SyntaxKind["EqualsToken"] = 55] = "EqualsToken"; - SyntaxKind[SyntaxKind["PlusEqualsToken"] = 56] = "PlusEqualsToken"; - SyntaxKind[SyntaxKind["MinusEqualsToken"] = 57] = "MinusEqualsToken"; - SyntaxKind[SyntaxKind["AsteriskEqualsToken"] = 58] = "AsteriskEqualsToken"; - SyntaxKind[SyntaxKind["SlashEqualsToken"] = 59] = "SlashEqualsToken"; - SyntaxKind[SyntaxKind["PercentEqualsToken"] = 60] = "PercentEqualsToken"; - SyntaxKind[SyntaxKind["LessThanLessThanEqualsToken"] = 61] = "LessThanLessThanEqualsToken"; - SyntaxKind[SyntaxKind["GreaterThanGreaterThanEqualsToken"] = 62] = "GreaterThanGreaterThanEqualsToken"; - SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanEqualsToken"] = 63] = "GreaterThanGreaterThanGreaterThanEqualsToken"; - SyntaxKind[SyntaxKind["AmpersandEqualsToken"] = 64] = "AmpersandEqualsToken"; - SyntaxKind[SyntaxKind["BarEqualsToken"] = 65] = "BarEqualsToken"; - SyntaxKind[SyntaxKind["CaretEqualsToken"] = 66] = "CaretEqualsToken"; + SyntaxKind[SyntaxKind["EqualsToken"] = 56] = "EqualsToken"; + SyntaxKind[SyntaxKind["PlusEqualsToken"] = 57] = "PlusEqualsToken"; + SyntaxKind[SyntaxKind["MinusEqualsToken"] = 58] = "MinusEqualsToken"; + SyntaxKind[SyntaxKind["AsteriskEqualsToken"] = 59] = "AsteriskEqualsToken"; + SyntaxKind[SyntaxKind["AsteriskAsteriskEqualsToken"] = 60] = "AsteriskAsteriskEqualsToken"; + SyntaxKind[SyntaxKind["SlashEqualsToken"] = 61] = "SlashEqualsToken"; + SyntaxKind[SyntaxKind["PercentEqualsToken"] = 62] = "PercentEqualsToken"; + SyntaxKind[SyntaxKind["LessThanLessThanEqualsToken"] = 63] = "LessThanLessThanEqualsToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanEqualsToken"] = 64] = "GreaterThanGreaterThanEqualsToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanEqualsToken"] = 65] = "GreaterThanGreaterThanGreaterThanEqualsToken"; + SyntaxKind[SyntaxKind["AmpersandEqualsToken"] = 66] = "AmpersandEqualsToken"; + SyntaxKind[SyntaxKind["BarEqualsToken"] = 67] = "BarEqualsToken"; + SyntaxKind[SyntaxKind["CaretEqualsToken"] = 68] = "CaretEqualsToken"; // Identifiers - SyntaxKind[SyntaxKind["Identifier"] = 67] = "Identifier"; + SyntaxKind[SyntaxKind["Identifier"] = 69] = "Identifier"; // Reserved words - SyntaxKind[SyntaxKind["BreakKeyword"] = 68] = "BreakKeyword"; - SyntaxKind[SyntaxKind["CaseKeyword"] = 69] = "CaseKeyword"; - SyntaxKind[SyntaxKind["CatchKeyword"] = 70] = "CatchKeyword"; - SyntaxKind[SyntaxKind["ClassKeyword"] = 71] = "ClassKeyword"; - SyntaxKind[SyntaxKind["ConstKeyword"] = 72] = "ConstKeyword"; - SyntaxKind[SyntaxKind["ContinueKeyword"] = 73] = "ContinueKeyword"; - SyntaxKind[SyntaxKind["DebuggerKeyword"] = 74] = "DebuggerKeyword"; - SyntaxKind[SyntaxKind["DefaultKeyword"] = 75] = "DefaultKeyword"; - SyntaxKind[SyntaxKind["DeleteKeyword"] = 76] = "DeleteKeyword"; - SyntaxKind[SyntaxKind["DoKeyword"] = 77] = "DoKeyword"; - SyntaxKind[SyntaxKind["ElseKeyword"] = 78] = "ElseKeyword"; - SyntaxKind[SyntaxKind["EnumKeyword"] = 79] = "EnumKeyword"; - SyntaxKind[SyntaxKind["ExportKeyword"] = 80] = "ExportKeyword"; - SyntaxKind[SyntaxKind["ExtendsKeyword"] = 81] = "ExtendsKeyword"; - SyntaxKind[SyntaxKind["FalseKeyword"] = 82] = "FalseKeyword"; - SyntaxKind[SyntaxKind["FinallyKeyword"] = 83] = "FinallyKeyword"; - SyntaxKind[SyntaxKind["ForKeyword"] = 84] = "ForKeyword"; - SyntaxKind[SyntaxKind["FunctionKeyword"] = 85] = "FunctionKeyword"; - SyntaxKind[SyntaxKind["IfKeyword"] = 86] = "IfKeyword"; - SyntaxKind[SyntaxKind["ImportKeyword"] = 87] = "ImportKeyword"; - SyntaxKind[SyntaxKind["InKeyword"] = 88] = "InKeyword"; - SyntaxKind[SyntaxKind["InstanceOfKeyword"] = 89] = "InstanceOfKeyword"; - SyntaxKind[SyntaxKind["NewKeyword"] = 90] = "NewKeyword"; - SyntaxKind[SyntaxKind["NullKeyword"] = 91] = "NullKeyword"; - SyntaxKind[SyntaxKind["ReturnKeyword"] = 92] = "ReturnKeyword"; - SyntaxKind[SyntaxKind["SuperKeyword"] = 93] = "SuperKeyword"; - SyntaxKind[SyntaxKind["SwitchKeyword"] = 94] = "SwitchKeyword"; - SyntaxKind[SyntaxKind["ThisKeyword"] = 95] = "ThisKeyword"; - SyntaxKind[SyntaxKind["ThrowKeyword"] = 96] = "ThrowKeyword"; - SyntaxKind[SyntaxKind["TrueKeyword"] = 97] = "TrueKeyword"; - SyntaxKind[SyntaxKind["TryKeyword"] = 98] = "TryKeyword"; - SyntaxKind[SyntaxKind["TypeOfKeyword"] = 99] = "TypeOfKeyword"; - SyntaxKind[SyntaxKind["VarKeyword"] = 100] = "VarKeyword"; - SyntaxKind[SyntaxKind["VoidKeyword"] = 101] = "VoidKeyword"; - SyntaxKind[SyntaxKind["WhileKeyword"] = 102] = "WhileKeyword"; - SyntaxKind[SyntaxKind["WithKeyword"] = 103] = "WithKeyword"; + SyntaxKind[SyntaxKind["BreakKeyword"] = 70] = "BreakKeyword"; + SyntaxKind[SyntaxKind["CaseKeyword"] = 71] = "CaseKeyword"; + SyntaxKind[SyntaxKind["CatchKeyword"] = 72] = "CatchKeyword"; + SyntaxKind[SyntaxKind["ClassKeyword"] = 73] = "ClassKeyword"; + SyntaxKind[SyntaxKind["ConstKeyword"] = 74] = "ConstKeyword"; + SyntaxKind[SyntaxKind["ContinueKeyword"] = 75] = "ContinueKeyword"; + SyntaxKind[SyntaxKind["DebuggerKeyword"] = 76] = "DebuggerKeyword"; + SyntaxKind[SyntaxKind["DefaultKeyword"] = 77] = "DefaultKeyword"; + SyntaxKind[SyntaxKind["DeleteKeyword"] = 78] = "DeleteKeyword"; + SyntaxKind[SyntaxKind["DoKeyword"] = 79] = "DoKeyword"; + SyntaxKind[SyntaxKind["ElseKeyword"] = 80] = "ElseKeyword"; + SyntaxKind[SyntaxKind["EnumKeyword"] = 81] = "EnumKeyword"; + SyntaxKind[SyntaxKind["ExportKeyword"] = 82] = "ExportKeyword"; + SyntaxKind[SyntaxKind["ExtendsKeyword"] = 83] = "ExtendsKeyword"; + SyntaxKind[SyntaxKind["FalseKeyword"] = 84] = "FalseKeyword"; + SyntaxKind[SyntaxKind["FinallyKeyword"] = 85] = "FinallyKeyword"; + SyntaxKind[SyntaxKind["ForKeyword"] = 86] = "ForKeyword"; + SyntaxKind[SyntaxKind["FunctionKeyword"] = 87] = "FunctionKeyword"; + SyntaxKind[SyntaxKind["IfKeyword"] = 88] = "IfKeyword"; + SyntaxKind[SyntaxKind["ImportKeyword"] = 89] = "ImportKeyword"; + SyntaxKind[SyntaxKind["InKeyword"] = 90] = "InKeyword"; + SyntaxKind[SyntaxKind["InstanceOfKeyword"] = 91] = "InstanceOfKeyword"; + SyntaxKind[SyntaxKind["NewKeyword"] = 92] = "NewKeyword"; + SyntaxKind[SyntaxKind["NullKeyword"] = 93] = "NullKeyword"; + SyntaxKind[SyntaxKind["ReturnKeyword"] = 94] = "ReturnKeyword"; + SyntaxKind[SyntaxKind["SuperKeyword"] = 95] = "SuperKeyword"; + SyntaxKind[SyntaxKind["SwitchKeyword"] = 96] = "SwitchKeyword"; + SyntaxKind[SyntaxKind["ThisKeyword"] = 97] = "ThisKeyword"; + SyntaxKind[SyntaxKind["ThrowKeyword"] = 98] = "ThrowKeyword"; + SyntaxKind[SyntaxKind["TrueKeyword"] = 99] = "TrueKeyword"; + SyntaxKind[SyntaxKind["TryKeyword"] = 100] = "TryKeyword"; + SyntaxKind[SyntaxKind["TypeOfKeyword"] = 101] = "TypeOfKeyword"; + SyntaxKind[SyntaxKind["VarKeyword"] = 102] = "VarKeyword"; + SyntaxKind[SyntaxKind["VoidKeyword"] = 103] = "VoidKeyword"; + SyntaxKind[SyntaxKind["WhileKeyword"] = 104] = "WhileKeyword"; + SyntaxKind[SyntaxKind["WithKeyword"] = 105] = "WithKeyword"; // Strict mode reserved words - SyntaxKind[SyntaxKind["ImplementsKeyword"] = 104] = "ImplementsKeyword"; - SyntaxKind[SyntaxKind["InterfaceKeyword"] = 105] = "InterfaceKeyword"; - SyntaxKind[SyntaxKind["LetKeyword"] = 106] = "LetKeyword"; - SyntaxKind[SyntaxKind["PackageKeyword"] = 107] = "PackageKeyword"; - SyntaxKind[SyntaxKind["PrivateKeyword"] = 108] = "PrivateKeyword"; - SyntaxKind[SyntaxKind["ProtectedKeyword"] = 109] = "ProtectedKeyword"; - SyntaxKind[SyntaxKind["PublicKeyword"] = 110] = "PublicKeyword"; - SyntaxKind[SyntaxKind["StaticKeyword"] = 111] = "StaticKeyword"; - SyntaxKind[SyntaxKind["YieldKeyword"] = 112] = "YieldKeyword"; + SyntaxKind[SyntaxKind["ImplementsKeyword"] = 106] = "ImplementsKeyword"; + SyntaxKind[SyntaxKind["InterfaceKeyword"] = 107] = "InterfaceKeyword"; + SyntaxKind[SyntaxKind["LetKeyword"] = 108] = "LetKeyword"; + SyntaxKind[SyntaxKind["PackageKeyword"] = 109] = "PackageKeyword"; + SyntaxKind[SyntaxKind["PrivateKeyword"] = 110] = "PrivateKeyword"; + SyntaxKind[SyntaxKind["ProtectedKeyword"] = 111] = "ProtectedKeyword"; + SyntaxKind[SyntaxKind["PublicKeyword"] = 112] = "PublicKeyword"; + SyntaxKind[SyntaxKind["StaticKeyword"] = 113] = "StaticKeyword"; + SyntaxKind[SyntaxKind["YieldKeyword"] = 114] = "YieldKeyword"; // Contextual keywords - SyntaxKind[SyntaxKind["AbstractKeyword"] = 113] = "AbstractKeyword"; - SyntaxKind[SyntaxKind["AsKeyword"] = 114] = "AsKeyword"; - SyntaxKind[SyntaxKind["AnyKeyword"] = 115] = "AnyKeyword"; - SyntaxKind[SyntaxKind["AsyncKeyword"] = 116] = "AsyncKeyword"; - SyntaxKind[SyntaxKind["AwaitKeyword"] = 117] = "AwaitKeyword"; - SyntaxKind[SyntaxKind["BooleanKeyword"] = 118] = "BooleanKeyword"; - SyntaxKind[SyntaxKind["ConstructorKeyword"] = 119] = "ConstructorKeyword"; - SyntaxKind[SyntaxKind["DeclareKeyword"] = 120] = "DeclareKeyword"; - SyntaxKind[SyntaxKind["GetKeyword"] = 121] = "GetKeyword"; - SyntaxKind[SyntaxKind["IsKeyword"] = 122] = "IsKeyword"; - SyntaxKind[SyntaxKind["ModuleKeyword"] = 123] = "ModuleKeyword"; - SyntaxKind[SyntaxKind["NamespaceKeyword"] = 124] = "NamespaceKeyword"; - SyntaxKind[SyntaxKind["RequireKeyword"] = 125] = "RequireKeyword"; - SyntaxKind[SyntaxKind["NumberKeyword"] = 126] = "NumberKeyword"; - SyntaxKind[SyntaxKind["SetKeyword"] = 127] = "SetKeyword"; - SyntaxKind[SyntaxKind["StringKeyword"] = 128] = "StringKeyword"; - SyntaxKind[SyntaxKind["SymbolKeyword"] = 129] = "SymbolKeyword"; - SyntaxKind[SyntaxKind["TypeKeyword"] = 130] = "TypeKeyword"; - SyntaxKind[SyntaxKind["FromKeyword"] = 131] = "FromKeyword"; - SyntaxKind[SyntaxKind["OfKeyword"] = 132] = "OfKeyword"; + SyntaxKind[SyntaxKind["AbstractKeyword"] = 115] = "AbstractKeyword"; + SyntaxKind[SyntaxKind["AsKeyword"] = 116] = "AsKeyword"; + SyntaxKind[SyntaxKind["AnyKeyword"] = 117] = "AnyKeyword"; + SyntaxKind[SyntaxKind["AsyncKeyword"] = 118] = "AsyncKeyword"; + SyntaxKind[SyntaxKind["AwaitKeyword"] = 119] = "AwaitKeyword"; + SyntaxKind[SyntaxKind["BooleanKeyword"] = 120] = "BooleanKeyword"; + SyntaxKind[SyntaxKind["ConstructorKeyword"] = 121] = "ConstructorKeyword"; + SyntaxKind[SyntaxKind["DeclareKeyword"] = 122] = "DeclareKeyword"; + SyntaxKind[SyntaxKind["GetKeyword"] = 123] = "GetKeyword"; + SyntaxKind[SyntaxKind["IsKeyword"] = 124] = "IsKeyword"; + SyntaxKind[SyntaxKind["ModuleKeyword"] = 125] = "ModuleKeyword"; + SyntaxKind[SyntaxKind["NamespaceKeyword"] = 126] = "NamespaceKeyword"; + SyntaxKind[SyntaxKind["RequireKeyword"] = 127] = "RequireKeyword"; + SyntaxKind[SyntaxKind["NumberKeyword"] = 128] = "NumberKeyword"; + SyntaxKind[SyntaxKind["SetKeyword"] = 129] = "SetKeyword"; + SyntaxKind[SyntaxKind["StringKeyword"] = 130] = "StringKeyword"; + SyntaxKind[SyntaxKind["SymbolKeyword"] = 131] = "SymbolKeyword"; + SyntaxKind[SyntaxKind["TypeKeyword"] = 132] = "TypeKeyword"; + SyntaxKind[SyntaxKind["FromKeyword"] = 133] = "FromKeyword"; + SyntaxKind[SyntaxKind["OfKeyword"] = 134] = "OfKeyword"; // Parse tree nodes // Names - SyntaxKind[SyntaxKind["QualifiedName"] = 133] = "QualifiedName"; - SyntaxKind[SyntaxKind["ComputedPropertyName"] = 134] = "ComputedPropertyName"; + SyntaxKind[SyntaxKind["QualifiedName"] = 135] = "QualifiedName"; + SyntaxKind[SyntaxKind["ComputedPropertyName"] = 136] = "ComputedPropertyName"; // Signature elements - SyntaxKind[SyntaxKind["TypeParameter"] = 135] = "TypeParameter"; - SyntaxKind[SyntaxKind["Parameter"] = 136] = "Parameter"; - SyntaxKind[SyntaxKind["Decorator"] = 137] = "Decorator"; + SyntaxKind[SyntaxKind["TypeParameter"] = 137] = "TypeParameter"; + SyntaxKind[SyntaxKind["Parameter"] = 138] = "Parameter"; + SyntaxKind[SyntaxKind["Decorator"] = 139] = "Decorator"; // TypeMember - SyntaxKind[SyntaxKind["PropertySignature"] = 138] = "PropertySignature"; - SyntaxKind[SyntaxKind["PropertyDeclaration"] = 139] = "PropertyDeclaration"; - SyntaxKind[SyntaxKind["MethodSignature"] = 140] = "MethodSignature"; - SyntaxKind[SyntaxKind["MethodDeclaration"] = 141] = "MethodDeclaration"; - SyntaxKind[SyntaxKind["Constructor"] = 142] = "Constructor"; - SyntaxKind[SyntaxKind["GetAccessor"] = 143] = "GetAccessor"; - SyntaxKind[SyntaxKind["SetAccessor"] = 144] = "SetAccessor"; - SyntaxKind[SyntaxKind["CallSignature"] = 145] = "CallSignature"; - SyntaxKind[SyntaxKind["ConstructSignature"] = 146] = "ConstructSignature"; - SyntaxKind[SyntaxKind["IndexSignature"] = 147] = "IndexSignature"; + SyntaxKind[SyntaxKind["PropertySignature"] = 140] = "PropertySignature"; + SyntaxKind[SyntaxKind["PropertyDeclaration"] = 141] = "PropertyDeclaration"; + SyntaxKind[SyntaxKind["MethodSignature"] = 142] = "MethodSignature"; + SyntaxKind[SyntaxKind["MethodDeclaration"] = 143] = "MethodDeclaration"; + SyntaxKind[SyntaxKind["Constructor"] = 144] = "Constructor"; + SyntaxKind[SyntaxKind["GetAccessor"] = 145] = "GetAccessor"; + SyntaxKind[SyntaxKind["SetAccessor"] = 146] = "SetAccessor"; + SyntaxKind[SyntaxKind["CallSignature"] = 147] = "CallSignature"; + SyntaxKind[SyntaxKind["ConstructSignature"] = 148] = "ConstructSignature"; + SyntaxKind[SyntaxKind["IndexSignature"] = 149] = "IndexSignature"; // Type - SyntaxKind[SyntaxKind["TypePredicate"] = 148] = "TypePredicate"; - SyntaxKind[SyntaxKind["TypeReference"] = 149] = "TypeReference"; - SyntaxKind[SyntaxKind["FunctionType"] = 150] = "FunctionType"; - SyntaxKind[SyntaxKind["ConstructorType"] = 151] = "ConstructorType"; - SyntaxKind[SyntaxKind["TypeQuery"] = 152] = "TypeQuery"; - SyntaxKind[SyntaxKind["TypeLiteral"] = 153] = "TypeLiteral"; - SyntaxKind[SyntaxKind["ArrayType"] = 154] = "ArrayType"; - SyntaxKind[SyntaxKind["TupleType"] = 155] = "TupleType"; - SyntaxKind[SyntaxKind["UnionType"] = 156] = "UnionType"; - SyntaxKind[SyntaxKind["IntersectionType"] = 157] = "IntersectionType"; - SyntaxKind[SyntaxKind["ParenthesizedType"] = 158] = "ParenthesizedType"; + SyntaxKind[SyntaxKind["TypePredicate"] = 150] = "TypePredicate"; + SyntaxKind[SyntaxKind["TypeReference"] = 151] = "TypeReference"; + SyntaxKind[SyntaxKind["FunctionType"] = 152] = "FunctionType"; + SyntaxKind[SyntaxKind["ConstructorType"] = 153] = "ConstructorType"; + SyntaxKind[SyntaxKind["TypeQuery"] = 154] = "TypeQuery"; + SyntaxKind[SyntaxKind["TypeLiteral"] = 155] = "TypeLiteral"; + SyntaxKind[SyntaxKind["ArrayType"] = 156] = "ArrayType"; + SyntaxKind[SyntaxKind["TupleType"] = 157] = "TupleType"; + SyntaxKind[SyntaxKind["UnionType"] = 158] = "UnionType"; + SyntaxKind[SyntaxKind["IntersectionType"] = 159] = "IntersectionType"; + SyntaxKind[SyntaxKind["ParenthesizedType"] = 160] = "ParenthesizedType"; // Binding patterns - SyntaxKind[SyntaxKind["ObjectBindingPattern"] = 159] = "ObjectBindingPattern"; - SyntaxKind[SyntaxKind["ArrayBindingPattern"] = 160] = "ArrayBindingPattern"; - SyntaxKind[SyntaxKind["BindingElement"] = 161] = "BindingElement"; + SyntaxKind[SyntaxKind["ObjectBindingPattern"] = 161] = "ObjectBindingPattern"; + SyntaxKind[SyntaxKind["ArrayBindingPattern"] = 162] = "ArrayBindingPattern"; + SyntaxKind[SyntaxKind["BindingElement"] = 163] = "BindingElement"; // Expression - SyntaxKind[SyntaxKind["ArrayLiteralExpression"] = 162] = "ArrayLiteralExpression"; - SyntaxKind[SyntaxKind["ObjectLiteralExpression"] = 163] = "ObjectLiteralExpression"; - SyntaxKind[SyntaxKind["PropertyAccessExpression"] = 164] = "PropertyAccessExpression"; - SyntaxKind[SyntaxKind["ElementAccessExpression"] = 165] = "ElementAccessExpression"; - SyntaxKind[SyntaxKind["CallExpression"] = 166] = "CallExpression"; - SyntaxKind[SyntaxKind["NewExpression"] = 167] = "NewExpression"; - SyntaxKind[SyntaxKind["TaggedTemplateExpression"] = 168] = "TaggedTemplateExpression"; - SyntaxKind[SyntaxKind["TypeAssertionExpression"] = 169] = "TypeAssertionExpression"; - SyntaxKind[SyntaxKind["ParenthesizedExpression"] = 170] = "ParenthesizedExpression"; - SyntaxKind[SyntaxKind["FunctionExpression"] = 171] = "FunctionExpression"; - SyntaxKind[SyntaxKind["ArrowFunction"] = 172] = "ArrowFunction"; - SyntaxKind[SyntaxKind["DeleteExpression"] = 173] = "DeleteExpression"; - SyntaxKind[SyntaxKind["TypeOfExpression"] = 174] = "TypeOfExpression"; - SyntaxKind[SyntaxKind["VoidExpression"] = 175] = "VoidExpression"; - SyntaxKind[SyntaxKind["AwaitExpression"] = 176] = "AwaitExpression"; - SyntaxKind[SyntaxKind["PrefixUnaryExpression"] = 177] = "PrefixUnaryExpression"; - SyntaxKind[SyntaxKind["PostfixUnaryExpression"] = 178] = "PostfixUnaryExpression"; - SyntaxKind[SyntaxKind["BinaryExpression"] = 179] = "BinaryExpression"; - SyntaxKind[SyntaxKind["ConditionalExpression"] = 180] = "ConditionalExpression"; - SyntaxKind[SyntaxKind["TemplateExpression"] = 181] = "TemplateExpression"; - SyntaxKind[SyntaxKind["YieldExpression"] = 182] = "YieldExpression"; - SyntaxKind[SyntaxKind["SpreadElementExpression"] = 183] = "SpreadElementExpression"; - SyntaxKind[SyntaxKind["ClassExpression"] = 184] = "ClassExpression"; - SyntaxKind[SyntaxKind["OmittedExpression"] = 185] = "OmittedExpression"; - SyntaxKind[SyntaxKind["ExpressionWithTypeArguments"] = 186] = "ExpressionWithTypeArguments"; - SyntaxKind[SyntaxKind["AsExpression"] = 187] = "AsExpression"; + SyntaxKind[SyntaxKind["ArrayLiteralExpression"] = 164] = "ArrayLiteralExpression"; + SyntaxKind[SyntaxKind["ObjectLiteralExpression"] = 165] = "ObjectLiteralExpression"; + SyntaxKind[SyntaxKind["PropertyAccessExpression"] = 166] = "PropertyAccessExpression"; + SyntaxKind[SyntaxKind["ElementAccessExpression"] = 167] = "ElementAccessExpression"; + SyntaxKind[SyntaxKind["CallExpression"] = 168] = "CallExpression"; + SyntaxKind[SyntaxKind["NewExpression"] = 169] = "NewExpression"; + SyntaxKind[SyntaxKind["TaggedTemplateExpression"] = 170] = "TaggedTemplateExpression"; + SyntaxKind[SyntaxKind["TypeAssertionExpression"] = 171] = "TypeAssertionExpression"; + SyntaxKind[SyntaxKind["ParenthesizedExpression"] = 172] = "ParenthesizedExpression"; + SyntaxKind[SyntaxKind["FunctionExpression"] = 173] = "FunctionExpression"; + SyntaxKind[SyntaxKind["ArrowFunction"] = 174] = "ArrowFunction"; + SyntaxKind[SyntaxKind["DeleteExpression"] = 175] = "DeleteExpression"; + SyntaxKind[SyntaxKind["TypeOfExpression"] = 176] = "TypeOfExpression"; + SyntaxKind[SyntaxKind["VoidExpression"] = 177] = "VoidExpression"; + SyntaxKind[SyntaxKind["AwaitExpression"] = 178] = "AwaitExpression"; + SyntaxKind[SyntaxKind["PrefixUnaryExpression"] = 179] = "PrefixUnaryExpression"; + SyntaxKind[SyntaxKind["PostfixUnaryExpression"] = 180] = "PostfixUnaryExpression"; + SyntaxKind[SyntaxKind["BinaryExpression"] = 181] = "BinaryExpression"; + SyntaxKind[SyntaxKind["ConditionalExpression"] = 182] = "ConditionalExpression"; + SyntaxKind[SyntaxKind["TemplateExpression"] = 183] = "TemplateExpression"; + SyntaxKind[SyntaxKind["YieldExpression"] = 184] = "YieldExpression"; + SyntaxKind[SyntaxKind["SpreadElementExpression"] = 185] = "SpreadElementExpression"; + SyntaxKind[SyntaxKind["ClassExpression"] = 186] = "ClassExpression"; + SyntaxKind[SyntaxKind["OmittedExpression"] = 187] = "OmittedExpression"; + SyntaxKind[SyntaxKind["ExpressionWithTypeArguments"] = 188] = "ExpressionWithTypeArguments"; + SyntaxKind[SyntaxKind["AsExpression"] = 189] = "AsExpression"; // Misc - SyntaxKind[SyntaxKind["TemplateSpan"] = 188] = "TemplateSpan"; - SyntaxKind[SyntaxKind["SemicolonClassElement"] = 189] = "SemicolonClassElement"; + SyntaxKind[SyntaxKind["TemplateSpan"] = 190] = "TemplateSpan"; + SyntaxKind[SyntaxKind["SemicolonClassElement"] = 191] = "SemicolonClassElement"; // Element - SyntaxKind[SyntaxKind["Block"] = 190] = "Block"; - SyntaxKind[SyntaxKind["VariableStatement"] = 191] = "VariableStatement"; - SyntaxKind[SyntaxKind["EmptyStatement"] = 192] = "EmptyStatement"; - SyntaxKind[SyntaxKind["ExpressionStatement"] = 193] = "ExpressionStatement"; - SyntaxKind[SyntaxKind["IfStatement"] = 194] = "IfStatement"; - SyntaxKind[SyntaxKind["DoStatement"] = 195] = "DoStatement"; - SyntaxKind[SyntaxKind["WhileStatement"] = 196] = "WhileStatement"; - SyntaxKind[SyntaxKind["ForStatement"] = 197] = "ForStatement"; - SyntaxKind[SyntaxKind["ForInStatement"] = 198] = "ForInStatement"; - SyntaxKind[SyntaxKind["ForOfStatement"] = 199] = "ForOfStatement"; - SyntaxKind[SyntaxKind["ContinueStatement"] = 200] = "ContinueStatement"; - SyntaxKind[SyntaxKind["BreakStatement"] = 201] = "BreakStatement"; - SyntaxKind[SyntaxKind["ReturnStatement"] = 202] = "ReturnStatement"; - SyntaxKind[SyntaxKind["WithStatement"] = 203] = "WithStatement"; - SyntaxKind[SyntaxKind["SwitchStatement"] = 204] = "SwitchStatement"; - SyntaxKind[SyntaxKind["LabeledStatement"] = 205] = "LabeledStatement"; - SyntaxKind[SyntaxKind["ThrowStatement"] = 206] = "ThrowStatement"; - SyntaxKind[SyntaxKind["TryStatement"] = 207] = "TryStatement"; - SyntaxKind[SyntaxKind["DebuggerStatement"] = 208] = "DebuggerStatement"; - SyntaxKind[SyntaxKind["VariableDeclaration"] = 209] = "VariableDeclaration"; - SyntaxKind[SyntaxKind["VariableDeclarationList"] = 210] = "VariableDeclarationList"; - SyntaxKind[SyntaxKind["FunctionDeclaration"] = 211] = "FunctionDeclaration"; - SyntaxKind[SyntaxKind["ClassDeclaration"] = 212] = "ClassDeclaration"; - SyntaxKind[SyntaxKind["InterfaceDeclaration"] = 213] = "InterfaceDeclaration"; - SyntaxKind[SyntaxKind["TypeAliasDeclaration"] = 214] = "TypeAliasDeclaration"; - SyntaxKind[SyntaxKind["EnumDeclaration"] = 215] = "EnumDeclaration"; - SyntaxKind[SyntaxKind["ModuleDeclaration"] = 216] = "ModuleDeclaration"; - SyntaxKind[SyntaxKind["ModuleBlock"] = 217] = "ModuleBlock"; - SyntaxKind[SyntaxKind["CaseBlock"] = 218] = "CaseBlock"; - SyntaxKind[SyntaxKind["ImportEqualsDeclaration"] = 219] = "ImportEqualsDeclaration"; - SyntaxKind[SyntaxKind["ImportDeclaration"] = 220] = "ImportDeclaration"; - SyntaxKind[SyntaxKind["ImportClause"] = 221] = "ImportClause"; - SyntaxKind[SyntaxKind["NamespaceImport"] = 222] = "NamespaceImport"; - SyntaxKind[SyntaxKind["NamedImports"] = 223] = "NamedImports"; - SyntaxKind[SyntaxKind["ImportSpecifier"] = 224] = "ImportSpecifier"; - SyntaxKind[SyntaxKind["ExportAssignment"] = 225] = "ExportAssignment"; - SyntaxKind[SyntaxKind["ExportDeclaration"] = 226] = "ExportDeclaration"; - SyntaxKind[SyntaxKind["NamedExports"] = 227] = "NamedExports"; - SyntaxKind[SyntaxKind["ExportSpecifier"] = 228] = "ExportSpecifier"; - SyntaxKind[SyntaxKind["MissingDeclaration"] = 229] = "MissingDeclaration"; + SyntaxKind[SyntaxKind["Block"] = 192] = "Block"; + SyntaxKind[SyntaxKind["VariableStatement"] = 193] = "VariableStatement"; + SyntaxKind[SyntaxKind["EmptyStatement"] = 194] = "EmptyStatement"; + SyntaxKind[SyntaxKind["ExpressionStatement"] = 195] = "ExpressionStatement"; + SyntaxKind[SyntaxKind["IfStatement"] = 196] = "IfStatement"; + SyntaxKind[SyntaxKind["DoStatement"] = 197] = "DoStatement"; + SyntaxKind[SyntaxKind["WhileStatement"] = 198] = "WhileStatement"; + SyntaxKind[SyntaxKind["ForStatement"] = 199] = "ForStatement"; + SyntaxKind[SyntaxKind["ForInStatement"] = 200] = "ForInStatement"; + SyntaxKind[SyntaxKind["ForOfStatement"] = 201] = "ForOfStatement"; + SyntaxKind[SyntaxKind["ContinueStatement"] = 202] = "ContinueStatement"; + SyntaxKind[SyntaxKind["BreakStatement"] = 203] = "BreakStatement"; + SyntaxKind[SyntaxKind["ReturnStatement"] = 204] = "ReturnStatement"; + SyntaxKind[SyntaxKind["WithStatement"] = 205] = "WithStatement"; + SyntaxKind[SyntaxKind["SwitchStatement"] = 206] = "SwitchStatement"; + SyntaxKind[SyntaxKind["LabeledStatement"] = 207] = "LabeledStatement"; + SyntaxKind[SyntaxKind["ThrowStatement"] = 208] = "ThrowStatement"; + SyntaxKind[SyntaxKind["TryStatement"] = 209] = "TryStatement"; + SyntaxKind[SyntaxKind["DebuggerStatement"] = 210] = "DebuggerStatement"; + SyntaxKind[SyntaxKind["VariableDeclaration"] = 211] = "VariableDeclaration"; + SyntaxKind[SyntaxKind["VariableDeclarationList"] = 212] = "VariableDeclarationList"; + SyntaxKind[SyntaxKind["FunctionDeclaration"] = 213] = "FunctionDeclaration"; + SyntaxKind[SyntaxKind["ClassDeclaration"] = 214] = "ClassDeclaration"; + SyntaxKind[SyntaxKind["InterfaceDeclaration"] = 215] = "InterfaceDeclaration"; + SyntaxKind[SyntaxKind["TypeAliasDeclaration"] = 216] = "TypeAliasDeclaration"; + SyntaxKind[SyntaxKind["EnumDeclaration"] = 217] = "EnumDeclaration"; + SyntaxKind[SyntaxKind["ModuleDeclaration"] = 218] = "ModuleDeclaration"; + SyntaxKind[SyntaxKind["ModuleBlock"] = 219] = "ModuleBlock"; + SyntaxKind[SyntaxKind["CaseBlock"] = 220] = "CaseBlock"; + SyntaxKind[SyntaxKind["ImportEqualsDeclaration"] = 221] = "ImportEqualsDeclaration"; + SyntaxKind[SyntaxKind["ImportDeclaration"] = 222] = "ImportDeclaration"; + SyntaxKind[SyntaxKind["ImportClause"] = 223] = "ImportClause"; + SyntaxKind[SyntaxKind["NamespaceImport"] = 224] = "NamespaceImport"; + SyntaxKind[SyntaxKind["NamedImports"] = 225] = "NamedImports"; + SyntaxKind[SyntaxKind["ImportSpecifier"] = 226] = "ImportSpecifier"; + SyntaxKind[SyntaxKind["ExportAssignment"] = 227] = "ExportAssignment"; + SyntaxKind[SyntaxKind["ExportDeclaration"] = 228] = "ExportDeclaration"; + SyntaxKind[SyntaxKind["NamedExports"] = 229] = "NamedExports"; + SyntaxKind[SyntaxKind["ExportSpecifier"] = 230] = "ExportSpecifier"; + SyntaxKind[SyntaxKind["MissingDeclaration"] = 231] = "MissingDeclaration"; // Module references - SyntaxKind[SyntaxKind["ExternalModuleReference"] = 230] = "ExternalModuleReference"; + SyntaxKind[SyntaxKind["ExternalModuleReference"] = 232] = "ExternalModuleReference"; // JSX - SyntaxKind[SyntaxKind["JsxElement"] = 231] = "JsxElement"; - SyntaxKind[SyntaxKind["JsxSelfClosingElement"] = 232] = "JsxSelfClosingElement"; - SyntaxKind[SyntaxKind["JsxOpeningElement"] = 233] = "JsxOpeningElement"; - SyntaxKind[SyntaxKind["JsxText"] = 234] = "JsxText"; - SyntaxKind[SyntaxKind["JsxClosingElement"] = 235] = "JsxClosingElement"; - SyntaxKind[SyntaxKind["JsxAttribute"] = 236] = "JsxAttribute"; - SyntaxKind[SyntaxKind["JsxSpreadAttribute"] = 237] = "JsxSpreadAttribute"; - SyntaxKind[SyntaxKind["JsxExpression"] = 238] = "JsxExpression"; + SyntaxKind[SyntaxKind["JsxElement"] = 233] = "JsxElement"; + SyntaxKind[SyntaxKind["JsxSelfClosingElement"] = 234] = "JsxSelfClosingElement"; + SyntaxKind[SyntaxKind["JsxOpeningElement"] = 235] = "JsxOpeningElement"; + SyntaxKind[SyntaxKind["JsxText"] = 236] = "JsxText"; + SyntaxKind[SyntaxKind["JsxClosingElement"] = 237] = "JsxClosingElement"; + SyntaxKind[SyntaxKind["JsxAttribute"] = 238] = "JsxAttribute"; + SyntaxKind[SyntaxKind["JsxSpreadAttribute"] = 239] = "JsxSpreadAttribute"; + SyntaxKind[SyntaxKind["JsxExpression"] = 240] = "JsxExpression"; // Clauses - SyntaxKind[SyntaxKind["CaseClause"] = 239] = "CaseClause"; - SyntaxKind[SyntaxKind["DefaultClause"] = 240] = "DefaultClause"; - SyntaxKind[SyntaxKind["HeritageClause"] = 241] = "HeritageClause"; - SyntaxKind[SyntaxKind["CatchClause"] = 242] = "CatchClause"; + SyntaxKind[SyntaxKind["CaseClause"] = 241] = "CaseClause"; + SyntaxKind[SyntaxKind["DefaultClause"] = 242] = "DefaultClause"; + SyntaxKind[SyntaxKind["HeritageClause"] = 243] = "HeritageClause"; + SyntaxKind[SyntaxKind["CatchClause"] = 244] = "CatchClause"; // Property assignments - SyntaxKind[SyntaxKind["PropertyAssignment"] = 243] = "PropertyAssignment"; - SyntaxKind[SyntaxKind["ShorthandPropertyAssignment"] = 244] = "ShorthandPropertyAssignment"; + SyntaxKind[SyntaxKind["PropertyAssignment"] = 245] = "PropertyAssignment"; + SyntaxKind[SyntaxKind["ShorthandPropertyAssignment"] = 246] = "ShorthandPropertyAssignment"; // Enum - SyntaxKind[SyntaxKind["EnumMember"] = 245] = "EnumMember"; + SyntaxKind[SyntaxKind["EnumMember"] = 247] = "EnumMember"; // Top-level nodes - SyntaxKind[SyntaxKind["SourceFile"] = 246] = "SourceFile"; + SyntaxKind[SyntaxKind["SourceFile"] = 248] = "SourceFile"; // JSDoc nodes. - SyntaxKind[SyntaxKind["JSDocTypeExpression"] = 247] = "JSDocTypeExpression"; + SyntaxKind[SyntaxKind["JSDocTypeExpression"] = 249] = "JSDocTypeExpression"; // The * type. - SyntaxKind[SyntaxKind["JSDocAllType"] = 248] = "JSDocAllType"; + SyntaxKind[SyntaxKind["JSDocAllType"] = 250] = "JSDocAllType"; // The ? type. - SyntaxKind[SyntaxKind["JSDocUnknownType"] = 249] = "JSDocUnknownType"; - SyntaxKind[SyntaxKind["JSDocArrayType"] = 250] = "JSDocArrayType"; - SyntaxKind[SyntaxKind["JSDocUnionType"] = 251] = "JSDocUnionType"; - SyntaxKind[SyntaxKind["JSDocTupleType"] = 252] = "JSDocTupleType"; - SyntaxKind[SyntaxKind["JSDocNullableType"] = 253] = "JSDocNullableType"; - SyntaxKind[SyntaxKind["JSDocNonNullableType"] = 254] = "JSDocNonNullableType"; - SyntaxKind[SyntaxKind["JSDocRecordType"] = 255] = "JSDocRecordType"; - SyntaxKind[SyntaxKind["JSDocRecordMember"] = 256] = "JSDocRecordMember"; - SyntaxKind[SyntaxKind["JSDocTypeReference"] = 257] = "JSDocTypeReference"; - SyntaxKind[SyntaxKind["JSDocOptionalType"] = 258] = "JSDocOptionalType"; - SyntaxKind[SyntaxKind["JSDocFunctionType"] = 259] = "JSDocFunctionType"; - SyntaxKind[SyntaxKind["JSDocVariadicType"] = 260] = "JSDocVariadicType"; - SyntaxKind[SyntaxKind["JSDocConstructorType"] = 261] = "JSDocConstructorType"; - SyntaxKind[SyntaxKind["JSDocThisType"] = 262] = "JSDocThisType"; - SyntaxKind[SyntaxKind["JSDocComment"] = 263] = "JSDocComment"; - SyntaxKind[SyntaxKind["JSDocTag"] = 264] = "JSDocTag"; - SyntaxKind[SyntaxKind["JSDocParameterTag"] = 265] = "JSDocParameterTag"; - SyntaxKind[SyntaxKind["JSDocReturnTag"] = 266] = "JSDocReturnTag"; - SyntaxKind[SyntaxKind["JSDocTypeTag"] = 267] = "JSDocTypeTag"; - SyntaxKind[SyntaxKind["JSDocTemplateTag"] = 268] = "JSDocTemplateTag"; + SyntaxKind[SyntaxKind["JSDocUnknownType"] = 251] = "JSDocUnknownType"; + SyntaxKind[SyntaxKind["JSDocArrayType"] = 252] = "JSDocArrayType"; + SyntaxKind[SyntaxKind["JSDocUnionType"] = 253] = "JSDocUnionType"; + SyntaxKind[SyntaxKind["JSDocTupleType"] = 254] = "JSDocTupleType"; + SyntaxKind[SyntaxKind["JSDocNullableType"] = 255] = "JSDocNullableType"; + SyntaxKind[SyntaxKind["JSDocNonNullableType"] = 256] = "JSDocNonNullableType"; + SyntaxKind[SyntaxKind["JSDocRecordType"] = 257] = "JSDocRecordType"; + SyntaxKind[SyntaxKind["JSDocRecordMember"] = 258] = "JSDocRecordMember"; + SyntaxKind[SyntaxKind["JSDocTypeReference"] = 259] = "JSDocTypeReference"; + SyntaxKind[SyntaxKind["JSDocOptionalType"] = 260] = "JSDocOptionalType"; + SyntaxKind[SyntaxKind["JSDocFunctionType"] = 261] = "JSDocFunctionType"; + SyntaxKind[SyntaxKind["JSDocVariadicType"] = 262] = "JSDocVariadicType"; + SyntaxKind[SyntaxKind["JSDocConstructorType"] = 263] = "JSDocConstructorType"; + SyntaxKind[SyntaxKind["JSDocThisType"] = 264] = "JSDocThisType"; + SyntaxKind[SyntaxKind["JSDocComment"] = 265] = "JSDocComment"; + SyntaxKind[SyntaxKind["JSDocTag"] = 266] = "JSDocTag"; + SyntaxKind[SyntaxKind["JSDocParameterTag"] = 267] = "JSDocParameterTag"; + SyntaxKind[SyntaxKind["JSDocReturnTag"] = 268] = "JSDocReturnTag"; + SyntaxKind[SyntaxKind["JSDocTypeTag"] = 269] = "JSDocTypeTag"; + SyntaxKind[SyntaxKind["JSDocTemplateTag"] = 270] = "JSDocTemplateTag"; // Synthesized list - SyntaxKind[SyntaxKind["SyntaxList"] = 269] = "SyntaxList"; + SyntaxKind[SyntaxKind["SyntaxList"] = 271] = "SyntaxList"; // Enum value count - SyntaxKind[SyntaxKind["Count"] = 270] = "Count"; + SyntaxKind[SyntaxKind["Count"] = 272] = "Count"; // Markers - SyntaxKind[SyntaxKind["FirstAssignment"] = 55] = "FirstAssignment"; - SyntaxKind[SyntaxKind["LastAssignment"] = 66] = "LastAssignment"; - SyntaxKind[SyntaxKind["FirstReservedWord"] = 68] = "FirstReservedWord"; - SyntaxKind[SyntaxKind["LastReservedWord"] = 103] = "LastReservedWord"; - SyntaxKind[SyntaxKind["FirstKeyword"] = 68] = "FirstKeyword"; - SyntaxKind[SyntaxKind["LastKeyword"] = 132] = "LastKeyword"; - SyntaxKind[SyntaxKind["FirstFutureReservedWord"] = 104] = "FirstFutureReservedWord"; - SyntaxKind[SyntaxKind["LastFutureReservedWord"] = 112] = "LastFutureReservedWord"; - SyntaxKind[SyntaxKind["FirstTypeNode"] = 149] = "FirstTypeNode"; - SyntaxKind[SyntaxKind["LastTypeNode"] = 158] = "LastTypeNode"; + SyntaxKind[SyntaxKind["FirstAssignment"] = 56] = "FirstAssignment"; + SyntaxKind[SyntaxKind["LastAssignment"] = 68] = "LastAssignment"; + SyntaxKind[SyntaxKind["FirstReservedWord"] = 70] = "FirstReservedWord"; + SyntaxKind[SyntaxKind["LastReservedWord"] = 105] = "LastReservedWord"; + SyntaxKind[SyntaxKind["FirstKeyword"] = 70] = "FirstKeyword"; + SyntaxKind[SyntaxKind["LastKeyword"] = 134] = "LastKeyword"; + SyntaxKind[SyntaxKind["FirstFutureReservedWord"] = 106] = "FirstFutureReservedWord"; + SyntaxKind[SyntaxKind["LastFutureReservedWord"] = 114] = "LastFutureReservedWord"; + SyntaxKind[SyntaxKind["FirstTypeNode"] = 151] = "FirstTypeNode"; + SyntaxKind[SyntaxKind["LastTypeNode"] = 160] = "LastTypeNode"; SyntaxKind[SyntaxKind["FirstPunctuation"] = 15] = "FirstPunctuation"; - SyntaxKind[SyntaxKind["LastPunctuation"] = 66] = "LastPunctuation"; + SyntaxKind[SyntaxKind["LastPunctuation"] = 68] = "LastPunctuation"; SyntaxKind[SyntaxKind["FirstToken"] = 0] = "FirstToken"; - SyntaxKind[SyntaxKind["LastToken"] = 132] = "LastToken"; + SyntaxKind[SyntaxKind["LastToken"] = 134] = "LastToken"; SyntaxKind[SyntaxKind["FirstTriviaToken"] = 2] = "FirstTriviaToken"; SyntaxKind[SyntaxKind["LastTriviaToken"] = 7] = "LastTriviaToken"; SyntaxKind[SyntaxKind["FirstLiteralToken"] = 8] = "FirstLiteralToken"; @@ -342,8 +344,8 @@ var ts; SyntaxKind[SyntaxKind["FirstTemplateToken"] = 11] = "FirstTemplateToken"; SyntaxKind[SyntaxKind["LastTemplateToken"] = 14] = "LastTemplateToken"; SyntaxKind[SyntaxKind["FirstBinaryOperator"] = 25] = "FirstBinaryOperator"; - SyntaxKind[SyntaxKind["LastBinaryOperator"] = 66] = "LastBinaryOperator"; - SyntaxKind[SyntaxKind["FirstNode"] = 133] = "FirstNode"; + SyntaxKind[SyntaxKind["LastBinaryOperator"] = 68] = "LastBinaryOperator"; + SyntaxKind[SyntaxKind["FirstNode"] = 135] = "FirstNode"; })(ts.SyntaxKind || (ts.SyntaxKind = {})); var SyntaxKind = ts.SyntaxKind; (function (NodeFlags) { @@ -364,6 +366,7 @@ var ts; NodeFlags[NodeFlags["OctalLiteral"] = 65536] = "OctalLiteral"; NodeFlags[NodeFlags["Namespace"] = 131072] = "Namespace"; NodeFlags[NodeFlags["ExportContext"] = 262144] = "ExportContext"; + NodeFlags[NodeFlags["ContainsThis"] = 524288] = "ContainsThis"; NodeFlags[NodeFlags["Modifier"] = 2035] = "Modifier"; NodeFlags[NodeFlags["AccessibilityModifier"] = 112] = "AccessibilityModifier"; NodeFlags[NodeFlags["BlockScoped"] = 49152] = "BlockScoped"; @@ -613,6 +616,7 @@ var ts; /* @internal */ TypeFlags[TypeFlags["ContainsAnyFunctionType"] = 8388608] = "ContainsAnyFunctionType"; TypeFlags[TypeFlags["ESSymbol"] = 16777216] = "ESSymbol"; + TypeFlags[TypeFlags["ThisType"] = 33554432] = "ThisType"; /* @internal */ TypeFlags[TypeFlags["Intrinsic"] = 16777343] = "Intrinsic"; /* @internal */ @@ -655,6 +659,7 @@ var ts; ModuleKind[ModuleKind["AMD"] = 2] = "AMD"; ModuleKind[ModuleKind["UMD"] = 3] = "UMD"; ModuleKind[ModuleKind["System"] = 4] = "System"; + ModuleKind[ModuleKind["ES6"] = 5] = "ES6"; })(ts.ModuleKind || (ts.ModuleKind = {})); var ModuleKind = ts.ModuleKind; (function (JsxEmit) { @@ -1221,8 +1226,11 @@ var ts; } ts.chainDiagnosticMessages = chainDiagnosticMessages; function concatenateDiagnosticMessageChains(headChain, tailChain) { - Debug.assert(!headChain.next); - headChain.next = tailChain; + var lastChain = headChain; + while (lastChain.next) { + lastChain = lastChain.next; + } + lastChain.next = tailChain; return headChain; } ts.concatenateDiagnosticMessageChains = concatenateDiagnosticMessageChains; @@ -1496,6 +1504,7 @@ var ts; * List of supported extensions in order of file resolution precedence. */ ts.supportedExtensions = [".ts", ".tsx", ".d.ts"]; + ts.supportedJsExtensions = ts.supportedExtensions.concat(".js", ".jsx"); var extensionsToRemove = [".d.ts", ".ts", ".js", ".tsx", ".jsx"]; function removeFileExtension(path) { for (var _i = 0; _i < extensionsToRemove.length; _i++) { @@ -1819,10 +1828,15 @@ var ts; close: function () { _fs.unwatchFile(fileName, fileChanged); } }; function fileChanged(curr, prev) { + // mtime.getTime() equals 0 if file was removed + if (curr.mtime.getTime() === 0) { + callback(fileName, /* removed */ true); + return; + } if (+curr.mtime <= +prev.mtime) { return; } - callback(fileName); + callback(fileName, /* removed */ false); } }, resolvePath: function (path) { @@ -1925,7 +1939,7 @@ var ts; Enum_member_must_have_initializer: { code: 1061, category: ts.DiagnosticCategory.Error, key: "Enum member must have initializer." }, _0_is_referenced_directly_or_indirectly_in_the_fulfillment_callback_of_its_own_then_method: { code: 1062, category: ts.DiagnosticCategory.Error, key: "{0} is referenced directly or indirectly in the fulfillment callback of its own 'then' method." }, An_export_assignment_cannot_be_used_in_a_namespace: { code: 1063, category: ts.DiagnosticCategory.Error, key: "An export assignment cannot be used in a namespace." }, - Ambient_enum_elements_can_only_have_integer_literal_initializers: { code: 1066, category: ts.DiagnosticCategory.Error, key: "Ambient enum elements can only have integer literal initializers." }, + In_ambient_enum_declarations_member_initializer_must_be_constant_expression: { code: 1066, category: ts.DiagnosticCategory.Error, key: "In ambient enum declarations member initializer must be constant expression." }, Unexpected_token_A_constructor_method_accessor_or_property_was_expected: { code: 1068, category: ts.DiagnosticCategory.Error, key: "Unexpected token. A constructor, method, accessor, or property was expected." }, A_0_modifier_cannot_be_used_with_an_import_declaration: { code: 1079, category: ts.DiagnosticCategory.Error, key: "A '{0}' modifier cannot be used with an import declaration." }, Invalid_reference_directive_syntax: { code: 1084, category: ts.DiagnosticCategory.Error, key: "Invalid 'reference' directive syntax." }, @@ -2013,7 +2027,7 @@ var ts; Property_destructuring_pattern_expected: { code: 1180, category: ts.DiagnosticCategory.Error, key: "Property destructuring pattern expected." }, Array_element_destructuring_pattern_expected: { code: 1181, category: ts.DiagnosticCategory.Error, key: "Array element destructuring pattern expected." }, A_destructuring_declaration_must_have_an_initializer: { code: 1182, category: ts.DiagnosticCategory.Error, key: "A destructuring declaration must have an initializer." }, - An_implementation_cannot_be_declared_in_ambient_contexts: { code: 1184, category: ts.DiagnosticCategory.Error, key: "An implementation cannot be declared in ambient contexts." }, + An_implementation_cannot_be_declared_in_ambient_contexts: { code: 1183, category: ts.DiagnosticCategory.Error, key: "An implementation cannot be declared in ambient contexts." }, Modifiers_cannot_appear_here: { code: 1184, category: ts.DiagnosticCategory.Error, key: "Modifiers cannot appear here." }, Merge_conflict_marker_encountered: { code: 1185, category: ts.DiagnosticCategory.Error, key: "Merge conflict marker encountered." }, A_rest_element_cannot_have_an_initializer: { code: 1186, category: ts.DiagnosticCategory.Error, key: "A rest element cannot have an initializer." }, @@ -2031,10 +2045,9 @@ var ts; An_extended_Unicode_escape_value_must_be_between_0x0_and_0x10FFFF_inclusive: { code: 1198, category: ts.DiagnosticCategory.Error, key: "An extended Unicode escape value must be between 0x0 and 0x10FFFF inclusive." }, Unterminated_Unicode_escape_sequence: { code: 1199, category: ts.DiagnosticCategory.Error, key: "Unterminated Unicode escape sequence." }, Line_terminator_not_permitted_before_arrow: { code: 1200, category: ts.DiagnosticCategory.Error, key: "Line terminator not permitted before arrow." }, - Import_assignment_cannot_be_used_when_targeting_ECMAScript_6_or_higher_Consider_using_import_Asterisk_as_ns_from_mod_import_a_from_mod_or_import_d_from_mod_instead: { code: 1202, category: ts.DiagnosticCategory.Error, key: "Import assignment cannot be used when targeting ECMAScript 6 or higher. Consider using 'import * as ns from \"mod\"', 'import {a} from \"mod\"' or 'import d from \"mod\"' instead." }, - Export_assignment_cannot_be_used_when_targeting_ECMAScript_6_or_higher_Consider_using_export_default_instead: { code: 1203, category: ts.DiagnosticCategory.Error, key: "Export assignment cannot be used when targeting ECMAScript 6 or higher. Consider using 'export default' instead." }, - Cannot_compile_modules_into_commonjs_amd_system_or_umd_when_targeting_ES6_or_higher: { code: 1204, category: ts.DiagnosticCategory.Error, key: "Cannot compile modules into 'commonjs', 'amd', 'system' or 'umd' when targeting 'ES6' or higher." }, - Decorators_are_only_available_when_targeting_ECMAScript_5_and_higher: { code: 1205, category: ts.DiagnosticCategory.Error, key: "Decorators are only available when targeting ECMAScript 5 and higher." }, + Import_assignment_cannot_be_used_when_targeting_ECMAScript_6_modules_Consider_using_import_Asterisk_as_ns_from_mod_import_a_from_mod_import_d_from_mod_or_another_module_format_instead: { code: 1202, category: ts.DiagnosticCategory.Error, key: "Import assignment cannot be used when targeting ECMAScript 6 modules. Consider using 'import * as ns from \"mod\"', 'import {a} from \"mod\"', 'import d from \"mod\"', or another module format instead." }, + Export_assignment_cannot_be_used_when_targeting_ECMAScript_6_modules_Consider_using_export_default_or_another_module_format_instead: { code: 1203, category: ts.DiagnosticCategory.Error, key: "Export assignment cannot be used when targeting ECMAScript 6 modules. Consider using 'export default' or another module format instead." }, + Cannot_compile_modules_into_es6_when_targeting_ES5_or_lower: { code: 1204, category: ts.DiagnosticCategory.Error, key: "Cannot compile modules into 'es6' when targeting 'ES5' or lower." }, Decorators_are_not_valid_here: { code: 1206, category: ts.DiagnosticCategory.Error, key: "Decorators are not valid here." }, Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name: { code: 1207, category: ts.DiagnosticCategory.Error, key: "Decorators cannot be applied to multiple get/set accessors of the same name." }, Cannot_compile_namespaces_when_the_isolatedModules_flag_is_provided: { code: 1208, category: ts.DiagnosticCategory.Error, key: "Cannot compile namespaces when the '--isolatedModules' flag is provided." }, @@ -2063,10 +2076,6 @@ var ts; An_export_declaration_can_only_be_used_in_a_module: { code: 1233, category: ts.DiagnosticCategory.Error, key: "An export declaration can only be used in a module." }, An_ambient_module_declaration_is_only_allowed_at_the_top_level_in_a_file: { code: 1234, category: ts.DiagnosticCategory.Error, key: "An ambient module declaration is only allowed at the top level in a file." }, A_namespace_declaration_is_only_allowed_in_a_namespace_or_module: { code: 1235, category: ts.DiagnosticCategory.Error, key: "A namespace declaration is only allowed in a namespace or module." }, - Experimental_support_for_async_functions_is_a_feature_that_is_subject_to_change_in_a_future_release_Specify_experimentalAsyncFunctions_to_remove_this_warning: { code: 1236, category: ts.DiagnosticCategory.Error, key: "Experimental support for async functions is a feature that is subject to change in a future release. Specify '--experimentalAsyncFunctions' to remove this warning." }, - with_statements_are_not_allowed_in_an_async_function_block: { code: 1300, category: ts.DiagnosticCategory.Error, key: "'with' statements are not allowed in an async function block." }, - await_expression_is_only_allowed_within_an_async_function: { code: 1308, category: ts.DiagnosticCategory.Error, key: "'await' expression is only allowed within an async function." }, - Async_functions_are_only_available_when_targeting_ECMAScript_6_and_higher: { code: 1311, category: ts.DiagnosticCategory.Error, key: "Async functions are only available when targeting ECMAScript 6 and higher." }, The_return_type_of_a_property_decorator_function_must_be_either_void_or_any: { code: 1236, category: ts.DiagnosticCategory.Error, key: "The return type of a property decorator function must be either 'void' or 'any'." }, The_return_type_of_a_parameter_decorator_function_must_be_either_void_or_any: { code: 1237, category: ts.DiagnosticCategory.Error, key: "The return type of a parameter decorator function must be either 'void' or 'any'." }, Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression: { code: 1238, category: ts.DiagnosticCategory.Error, key: "Unable to resolve signature of class decorator when called as an expression." }, @@ -2077,6 +2086,10 @@ var ts; _0_modifier_cannot_be_used_with_1_modifier: { code: 1243, category: ts.DiagnosticCategory.Error, key: "'{0}' modifier cannot be used with '{1}' modifier." }, Abstract_methods_can_only_appear_within_an_abstract_class: { code: 1244, category: ts.DiagnosticCategory.Error, key: "Abstract methods can only appear within an abstract class." }, Method_0_cannot_have_an_implementation_because_it_is_marked_abstract: { code: 1245, category: ts.DiagnosticCategory.Error, key: "Method '{0}' cannot have an implementation because it is marked abstract." }, + with_statements_are_not_allowed_in_an_async_function_block: { code: 1300, category: ts.DiagnosticCategory.Error, key: "'with' statements are not allowed in an async function block." }, + await_expression_is_only_allowed_within_an_async_function: { code: 1308, category: ts.DiagnosticCategory.Error, key: "'await' expression is only allowed within an async function." }, + Async_functions_are_only_available_when_targeting_ECMAScript_6_and_higher: { code: 1311, category: ts.DiagnosticCategory.Error, key: "Async functions are only available when targeting ECMAScript 6 and higher." }, + can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment: { code: 1312, category: ts.DiagnosticCategory.Error, key: "'=' can only be used in an object literal property inside a destructuring assignment." }, Duplicate_identifier_0: { code: 2300, category: ts.DiagnosticCategory.Error, key: "Duplicate identifier '{0}'." }, Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor: { code: 2301, category: ts.DiagnosticCategory.Error, key: "Initializer of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor." }, Static_members_cannot_reference_class_type_parameters: { code: 2302, category: ts.DiagnosticCategory.Error, key: "Static members cannot reference class type parameters." }, @@ -2201,7 +2214,7 @@ var ts; In_an_enum_with_multiple_declarations_only_one_declaration_can_omit_an_initializer_for_its_first_enum_element: { code: 2432, category: ts.DiagnosticCategory.Error, key: "In an enum with multiple declarations, only one declaration can omit an initializer for its first enum element." }, A_namespace_declaration_cannot_be_in_a_different_file_from_a_class_or_function_with_which_it_is_merged: { code: 2433, category: ts.DiagnosticCategory.Error, key: "A namespace declaration cannot be in a different file from a class or function with which it is merged" }, A_namespace_declaration_cannot_be_located_prior_to_a_class_or_function_with_which_it_is_merged: { code: 2434, category: ts.DiagnosticCategory.Error, key: "A namespace declaration cannot be located prior to a class or function with which it is merged" }, - Ambient_modules_cannot_be_nested_in_other_modules: { code: 2435, category: ts.DiagnosticCategory.Error, key: "Ambient modules cannot be nested in other modules." }, + Ambient_modules_cannot_be_nested_in_other_modules_or_namespaces: { code: 2435, category: ts.DiagnosticCategory.Error, key: "Ambient modules cannot be nested in other modules or namespaces." }, Ambient_module_declaration_cannot_specify_relative_module_name: { code: 2436, category: ts.DiagnosticCategory.Error, key: "Ambient module declaration cannot specify relative module name." }, Module_0_is_hidden_by_a_local_declaration_with_the_same_name: { code: 2437, category: ts.DiagnosticCategory.Error, key: "Module '{0}' is hidden by a local declaration with the same name" }, Import_name_cannot_be_0: { code: 2438, category: ts.DiagnosticCategory.Error, key: "Import name cannot be '{0}'" }, @@ -2289,6 +2302,9 @@ var ts; yield_expressions_cannot_be_used_in_a_parameter_initializer: { code: 2523, category: ts.DiagnosticCategory.Error, key: "'yield' expressions cannot be used in a parameter initializer." }, await_expressions_cannot_be_used_in_a_parameter_initializer: { code: 2524, category: ts.DiagnosticCategory.Error, key: "'await' expressions cannot be used in a parameter initializer." }, Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value: { code: 2525, category: ts.DiagnosticCategory.Error, key: "Initializer provides no value for this binding element and the binding element has no default value." }, + A_this_type_is_available_only_in_a_non_static_member_of_a_class_or_interface: { code: 2526, category: ts.DiagnosticCategory.Error, key: "A 'this' type is available only in a non-static member of a class or interface." }, + The_inferred_type_of_0_references_an_inaccessible_this_type_A_type_annotation_is_necessary: { code: 2527, category: ts.DiagnosticCategory.Error, key: "The inferred type of '{0}' references an inaccessible 'this' type. A type annotation is necessary." }, + A_module_cannot_have_multiple_default_exports: { code: 2528, category: ts.DiagnosticCategory.Error, key: "A module cannot have multiple default exports." }, JSX_element_attributes_type_0_must_be_an_object_type: { code: 2600, category: ts.DiagnosticCategory.Error, key: "JSX element attributes type '{0}' must be an object type." }, The_return_type_of_a_JSX_element_constructor_must_return_an_object_type: { code: 2601, category: ts.DiagnosticCategory.Error, key: "The return type of a JSX element constructor must return an object type." }, JSX_element_implicitly_has_type_any_because_the_global_type_JSX_Element_does_not_exist: { code: 2602, category: ts.DiagnosticCategory.Error, key: "JSX element implicitly has type 'any' because the global type 'JSX.Element' does not exist." }, @@ -2389,7 +2405,7 @@ var ts; Option_inlineSources_can_only_be_used_when_either_option_inlineSourceMap_or_option_sourceMap_is_provided: { code: 5051, category: ts.DiagnosticCategory.Error, key: "Option 'inlineSources' can only be used when either option '--inlineSourceMap' or option '--sourceMap' is provided." }, Option_0_cannot_be_specified_without_specifying_option_1: { code: 5052, category: ts.DiagnosticCategory.Error, key: "Option '{0}' cannot be specified without specifying option '{1}'." }, Option_0_cannot_be_specified_with_option_1: { code: 5053, category: ts.DiagnosticCategory.Error, key: "Option '{0}' cannot be specified with option '{1}'." }, - A_tsconfig_json_file_is_already_defined_at_Colon_0: { code: 5053, category: ts.DiagnosticCategory.Error, key: "A 'tsconfig.json' file is already defined at: '{0}'." }, + A_tsconfig_json_file_is_already_defined_at_Colon_0: { code: 5054, category: ts.DiagnosticCategory.Error, key: "A 'tsconfig.json' file is already defined at: '{0}'." }, Concatenate_and_emit_output_to_single_file: { code: 6001, category: ts.DiagnosticCategory.Message, key: "Concatenate and emit output to single file." }, Generates_corresponding_d_ts_file: { code: 6002, category: ts.DiagnosticCategory.Message, key: "Generates corresponding '.d.ts' file." }, Specifies_the_location_where_debugger_should_locate_map_files_instead_of_generated_locations: { code: 6003, category: ts.DiagnosticCategory.Message, key: "Specifies the location where debugger should locate map files instead of generated locations." }, @@ -2401,7 +2417,7 @@ var ts; Do_not_emit_comments_to_output: { code: 6009, category: ts.DiagnosticCategory.Message, key: "Do not emit comments to output." }, Do_not_emit_outputs: { code: 6010, category: ts.DiagnosticCategory.Message, key: "Do not emit outputs." }, Specify_ECMAScript_target_version_Colon_ES3_default_ES5_or_ES6_experimental: { code: 6015, category: ts.DiagnosticCategory.Message, key: "Specify ECMAScript target version: 'ES3' (default), 'ES5', or 'ES6' (experimental)" }, - Specify_module_code_generation_Colon_commonjs_amd_system_or_umd: { code: 6016, category: ts.DiagnosticCategory.Message, key: "Specify module code generation: 'commonjs', 'amd', 'system' or 'umd'" }, + Specify_module_code_generation_Colon_commonjs_amd_system_umd_or_es6: { code: 6016, category: ts.DiagnosticCategory.Message, key: "Specify module code generation: 'commonjs', 'amd', 'system', 'umd' or 'es6'" }, Print_this_message: { code: 6017, category: ts.DiagnosticCategory.Message, key: "Print this message." }, Print_the_compiler_s_version: { code: 6019, category: ts.DiagnosticCategory.Message, key: "Print the compiler's version." }, Compile_the_project_in_the_given_directory: { code: 6020, category: ts.DiagnosticCategory.Message, key: "Compile the project in the given directory." }, @@ -2422,7 +2438,7 @@ var ts; Generates_corresponding_map_file: { code: 6043, category: ts.DiagnosticCategory.Message, key: "Generates corresponding '.map' file." }, Compiler_option_0_expects_an_argument: { code: 6044, category: ts.DiagnosticCategory.Error, key: "Compiler option '{0}' expects an argument." }, Unterminated_quoted_string_in_response_file_0: { code: 6045, category: ts.DiagnosticCategory.Error, key: "Unterminated quoted string in response file '{0}'." }, - Argument_for_module_option_must_be_commonjs_amd_system_or_umd: { code: 6046, category: ts.DiagnosticCategory.Error, key: "Argument for '--module' option must be 'commonjs', 'amd', 'system' or 'umd'." }, + Argument_for_module_option_must_be_commonjs_amd_system_umd_or_es6: { code: 6046, category: ts.DiagnosticCategory.Error, key: "Argument for '--module' option must be 'commonjs', 'amd', 'system', 'umd', or 'es6'." }, Argument_for_target_option_must_be_ES3_ES5_or_ES6: { code: 6047, category: ts.DiagnosticCategory.Error, key: "Argument for '--target' option must be 'ES3', 'ES5', or 'ES6'." }, Locale_must_be_of_the_form_language_or_language_territory_For_example_0_or_1: { code: 6048, category: ts.DiagnosticCategory.Error, key: "Locale must be of the form or -. For example '{0}' or '{1}'." }, Unsupported_locale_0: { code: 6049, category: ts.DiagnosticCategory.Error, key: "Unsupported locale '{0}'." }, @@ -2443,7 +2459,6 @@ var ts; Argument_for_jsx_must_be_preserve_or_react: { code: 6081, category: ts.DiagnosticCategory.Message, key: "Argument for '--jsx' must be 'preserve' or 'react'." }, Enables_experimental_support_for_ES7_decorators: { code: 6065, category: ts.DiagnosticCategory.Message, key: "Enables experimental support for ES7 decorators." }, Enables_experimental_support_for_emitting_type_metadata_for_decorators: { code: 6066, category: ts.DiagnosticCategory.Message, key: "Enables experimental support for emitting type metadata for decorators." }, - Option_experimentalAsyncFunctions_cannot_be_specified_when_targeting_ES5_or_lower: { code: 6067, category: ts.DiagnosticCategory.Message, key: "Option 'experimentalAsyncFunctions' cannot be specified when targeting ES5 or lower." }, Enables_experimental_support_for_ES7_async_functions: { code: 6068, category: ts.DiagnosticCategory.Message, key: "Enables experimental support for ES7 async functions." }, Specifies_module_resolution_strategy_Colon_node_Node_js_or_classic_TypeScript_pre_1_6: { code: 6069, category: ts.DiagnosticCategory.Message, key: "Specifies module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6)." }, Initializes_a_TypeScript_project_and_creates_a_tsconfig_json_file: { code: 6070, category: ts.DiagnosticCategory.Message, key: "Initializes a TypeScript project and creates a tsconfig.json file." }, @@ -2490,7 +2505,9 @@ var ts; Expected_corresponding_JSX_closing_tag_for_0: { code: 17002, category: ts.DiagnosticCategory.Error, key: "Expected corresponding JSX closing tag for '{0}'." }, JSX_attribute_expected: { code: 17003, category: ts.DiagnosticCategory.Error, key: "JSX attribute expected." }, Cannot_use_JSX_unless_the_jsx_flag_is_provided: { code: 17004, category: ts.DiagnosticCategory.Error, key: "Cannot use JSX unless the '--jsx' flag is provided." }, - A_constructor_cannot_contain_a_super_call_when_its_class_extends_null: { code: 17005, category: ts.DiagnosticCategory.Error, key: "A constructor cannot contain a 'super' call when its class extends 'null'" } + A_constructor_cannot_contain_a_super_call_when_its_class_extends_null: { code: 17005, category: ts.DiagnosticCategory.Error, key: "A constructor cannot contain a 'super' call when its class extends 'null'" }, + An_unary_expression_with_the_0_operator_is_not_allowed_in_the_left_hand_side_of_an_exponentiation_expression_Consider_enclosing_the_expression_in_parentheses: { code: 17006, category: ts.DiagnosticCategory.Error, key: "An unary expression with the '{0}' operator is not allowed in the left-hand side of an exponentiation expression. Consider enclosing the expression in parentheses." }, + A_type_assertion_expression_is_not_allowed_in_the_left_hand_side_of_an_exponentiation_expression_Consider_enclosing_the_expression_in_parentheses: { code: 17007, category: ts.DiagnosticCategory.Error, key: "A type assertion expression is not allowed in the left-hand side of an exponentiation expression. Consider enclosing the expression in parentheses." } }; })(ts || (ts = {})); /// @@ -2499,75 +2516,75 @@ var ts; (function (ts) { /* @internal */ function tokenIsIdentifierOrKeyword(token) { - return token >= 67 /* Identifier */; + return token >= 69 /* Identifier */; } ts.tokenIsIdentifierOrKeyword = tokenIsIdentifierOrKeyword; var textToToken = { - "abstract": 113 /* AbstractKeyword */, - "any": 115 /* AnyKeyword */, - "as": 114 /* AsKeyword */, - "boolean": 118 /* BooleanKeyword */, - "break": 68 /* BreakKeyword */, - "case": 69 /* CaseKeyword */, - "catch": 70 /* CatchKeyword */, - "class": 71 /* ClassKeyword */, - "continue": 73 /* ContinueKeyword */, - "const": 72 /* ConstKeyword */, - "constructor": 119 /* ConstructorKeyword */, - "debugger": 74 /* DebuggerKeyword */, - "declare": 120 /* DeclareKeyword */, - "default": 75 /* DefaultKeyword */, - "delete": 76 /* DeleteKeyword */, - "do": 77 /* DoKeyword */, - "else": 78 /* ElseKeyword */, - "enum": 79 /* EnumKeyword */, - "export": 80 /* ExportKeyword */, - "extends": 81 /* ExtendsKeyword */, - "false": 82 /* FalseKeyword */, - "finally": 83 /* FinallyKeyword */, - "for": 84 /* ForKeyword */, - "from": 131 /* FromKeyword */, - "function": 85 /* FunctionKeyword */, - "get": 121 /* GetKeyword */, - "if": 86 /* IfKeyword */, - "implements": 104 /* ImplementsKeyword */, - "import": 87 /* ImportKeyword */, - "in": 88 /* InKeyword */, - "instanceof": 89 /* InstanceOfKeyword */, - "interface": 105 /* InterfaceKeyword */, - "is": 122 /* IsKeyword */, - "let": 106 /* LetKeyword */, - "module": 123 /* ModuleKeyword */, - "namespace": 124 /* NamespaceKeyword */, - "new": 90 /* NewKeyword */, - "null": 91 /* NullKeyword */, - "number": 126 /* NumberKeyword */, - "package": 107 /* PackageKeyword */, - "private": 108 /* PrivateKeyword */, - "protected": 109 /* ProtectedKeyword */, - "public": 110 /* PublicKeyword */, - "require": 125 /* RequireKeyword */, - "return": 92 /* ReturnKeyword */, - "set": 127 /* SetKeyword */, - "static": 111 /* StaticKeyword */, - "string": 128 /* StringKeyword */, - "super": 93 /* SuperKeyword */, - "switch": 94 /* SwitchKeyword */, - "symbol": 129 /* SymbolKeyword */, - "this": 95 /* ThisKeyword */, - "throw": 96 /* ThrowKeyword */, - "true": 97 /* TrueKeyword */, - "try": 98 /* TryKeyword */, - "type": 130 /* TypeKeyword */, - "typeof": 99 /* TypeOfKeyword */, - "var": 100 /* VarKeyword */, - "void": 101 /* VoidKeyword */, - "while": 102 /* WhileKeyword */, - "with": 103 /* WithKeyword */, - "yield": 112 /* YieldKeyword */, - "async": 116 /* AsyncKeyword */, - "await": 117 /* AwaitKeyword */, - "of": 132 /* OfKeyword */, + "abstract": 115 /* AbstractKeyword */, + "any": 117 /* AnyKeyword */, + "as": 116 /* AsKeyword */, + "boolean": 120 /* BooleanKeyword */, + "break": 70 /* BreakKeyword */, + "case": 71 /* CaseKeyword */, + "catch": 72 /* CatchKeyword */, + "class": 73 /* ClassKeyword */, + "continue": 75 /* ContinueKeyword */, + "const": 74 /* ConstKeyword */, + "constructor": 121 /* ConstructorKeyword */, + "debugger": 76 /* DebuggerKeyword */, + "declare": 122 /* DeclareKeyword */, + "default": 77 /* DefaultKeyword */, + "delete": 78 /* DeleteKeyword */, + "do": 79 /* DoKeyword */, + "else": 80 /* ElseKeyword */, + "enum": 81 /* EnumKeyword */, + "export": 82 /* ExportKeyword */, + "extends": 83 /* ExtendsKeyword */, + "false": 84 /* FalseKeyword */, + "finally": 85 /* FinallyKeyword */, + "for": 86 /* ForKeyword */, + "from": 133 /* FromKeyword */, + "function": 87 /* FunctionKeyword */, + "get": 123 /* GetKeyword */, + "if": 88 /* IfKeyword */, + "implements": 106 /* ImplementsKeyword */, + "import": 89 /* ImportKeyword */, + "in": 90 /* InKeyword */, + "instanceof": 91 /* InstanceOfKeyword */, + "interface": 107 /* InterfaceKeyword */, + "is": 124 /* IsKeyword */, + "let": 108 /* LetKeyword */, + "module": 125 /* ModuleKeyword */, + "namespace": 126 /* NamespaceKeyword */, + "new": 92 /* NewKeyword */, + "null": 93 /* NullKeyword */, + "number": 128 /* NumberKeyword */, + "package": 109 /* PackageKeyword */, + "private": 110 /* PrivateKeyword */, + "protected": 111 /* ProtectedKeyword */, + "public": 112 /* PublicKeyword */, + "require": 127 /* RequireKeyword */, + "return": 94 /* ReturnKeyword */, + "set": 129 /* SetKeyword */, + "static": 113 /* StaticKeyword */, + "string": 130 /* StringKeyword */, + "super": 95 /* SuperKeyword */, + "switch": 96 /* SwitchKeyword */, + "symbol": 131 /* SymbolKeyword */, + "this": 97 /* ThisKeyword */, + "throw": 98 /* ThrowKeyword */, + "true": 99 /* TrueKeyword */, + "try": 100 /* TryKeyword */, + "type": 132 /* TypeKeyword */, + "typeof": 101 /* TypeOfKeyword */, + "var": 102 /* VarKeyword */, + "void": 103 /* VoidKeyword */, + "while": 104 /* WhileKeyword */, + "with": 105 /* WithKeyword */, + "yield": 114 /* YieldKeyword */, + "async": 118 /* AsyncKeyword */, + "await": 119 /* AwaitKeyword */, + "of": 134 /* OfKeyword */, "{": 15 /* OpenBraceToken */, "}": 16 /* CloseBraceToken */, "(": 17 /* OpenParenToken */, @@ -2589,37 +2606,39 @@ var ts; "=>": 34 /* EqualsGreaterThanToken */, "+": 35 /* PlusToken */, "-": 36 /* MinusToken */, + "**": 38 /* AsteriskAsteriskToken */, "*": 37 /* AsteriskToken */, - "/": 38 /* SlashToken */, - "%": 39 /* PercentToken */, - "++": 40 /* PlusPlusToken */, - "--": 41 /* MinusMinusToken */, - "<<": 42 /* LessThanLessThanToken */, + "/": 39 /* SlashToken */, + "%": 40 /* PercentToken */, + "++": 41 /* PlusPlusToken */, + "--": 42 /* MinusMinusToken */, + "<<": 43 /* LessThanLessThanToken */, ">": 43 /* GreaterThanGreaterThanToken */, - ">>>": 44 /* GreaterThanGreaterThanGreaterThanToken */, - "&": 45 /* AmpersandToken */, - "|": 46 /* BarToken */, - "^": 47 /* CaretToken */, - "!": 48 /* ExclamationToken */, - "~": 49 /* TildeToken */, - "&&": 50 /* AmpersandAmpersandToken */, - "||": 51 /* BarBarToken */, - "?": 52 /* QuestionToken */, - ":": 53 /* ColonToken */, - "=": 55 /* EqualsToken */, - "+=": 56 /* PlusEqualsToken */, - "-=": 57 /* MinusEqualsToken */, - "*=": 58 /* AsteriskEqualsToken */, - "/=": 59 /* SlashEqualsToken */, - "%=": 60 /* PercentEqualsToken */, - "<<=": 61 /* LessThanLessThanEqualsToken */, - ">>=": 62 /* GreaterThanGreaterThanEqualsToken */, - ">>>=": 63 /* GreaterThanGreaterThanGreaterThanEqualsToken */, - "&=": 64 /* AmpersandEqualsToken */, - "|=": 65 /* BarEqualsToken */, - "^=": 66 /* CaretEqualsToken */, - "@": 54 /* AtToken */ + ">>": 44 /* GreaterThanGreaterThanToken */, + ">>>": 45 /* GreaterThanGreaterThanGreaterThanToken */, + "&": 46 /* AmpersandToken */, + "|": 47 /* BarToken */, + "^": 48 /* CaretToken */, + "!": 49 /* ExclamationToken */, + "~": 50 /* TildeToken */, + "&&": 51 /* AmpersandAmpersandToken */, + "||": 52 /* BarBarToken */, + "?": 53 /* QuestionToken */, + ":": 54 /* ColonToken */, + "=": 56 /* EqualsToken */, + "+=": 57 /* PlusEqualsToken */, + "-=": 58 /* MinusEqualsToken */, + "*=": 59 /* AsteriskEqualsToken */, + "**=": 60 /* AsteriskAsteriskEqualsToken */, + "/=": 61 /* SlashEqualsToken */, + "%=": 62 /* PercentEqualsToken */, + "<<=": 63 /* LessThanLessThanEqualsToken */, + ">>=": 64 /* GreaterThanGreaterThanEqualsToken */, + ">>>=": 65 /* GreaterThanGreaterThanGreaterThanEqualsToken */, + "&=": 66 /* AmpersandEqualsToken */, + "|=": 67 /* BarEqualsToken */, + "^=": 68 /* CaretEqualsToken */, + "@": 55 /* AtToken */ }; /* As per ECMAScript Language Specification 3th Edition, Section 7.6: Identifiers @@ -3123,8 +3142,8 @@ var ts; getTokenValue: function () { return tokenValue; }, hasExtendedUnicodeEscape: function () { return hasExtendedUnicodeEscape; }, hasPrecedingLineBreak: function () { return precedingLineBreak; }, - isIdentifier: function () { return token === 67 /* Identifier */ || token > 103 /* LastReservedWord */; }, - isReservedWord: function () { return token >= 68 /* FirstReservedWord */ && token <= 103 /* LastReservedWord */; }, + isIdentifier: function () { return token === 69 /* Identifier */ || token > 105 /* LastReservedWord */; }, + isReservedWord: function () { return token >= 70 /* FirstReservedWord */ && token <= 105 /* LastReservedWord */; }, isUnterminated: function () { return tokenIsUnterminated; }, reScanGreaterToken: reScanGreaterToken, reScanSlashToken: reScanSlashToken, @@ -3146,16 +3165,6 @@ var ts; onError(message, length || 0); } } - function isIdentifierStart(ch) { - return ch >= 65 /* A */ && ch <= 90 /* Z */ || ch >= 97 /* a */ && ch <= 122 /* z */ || - ch === 36 /* $ */ || ch === 95 /* _ */ || - ch > 127 /* maxAsciiCharacter */ && isUnicodeIdentifierStart(ch, languageVersion); - } - function isIdentifierPart(ch) { - return ch >= 65 /* A */ && ch <= 90 /* Z */ || ch >= 97 /* a */ && ch <= 122 /* z */ || - ch >= 48 /* _0 */ && ch <= 57 /* _9 */ || ch === 36 /* $ */ || ch === 95 /* _ */ || - ch > 127 /* maxAsciiCharacter */ && isUnicodeIdentifierPart(ch, languageVersion); - } function scanNumber() { var start = pos; while (isDigit(text.charCodeAt(pos))) @@ -3438,12 +3447,12 @@ var ts; var start = pos; while (pos < end) { var ch = text.charCodeAt(pos); - if (isIdentifierPart(ch)) { + if (isIdentifierPart(ch, languageVersion)) { pos++; } else if (ch === 92 /* backslash */) { ch = peekUnicodeEscape(); - if (!(ch >= 0 && isIdentifierPart(ch))) { + if (!(ch >= 0 && isIdentifierPart(ch, languageVersion))) { break; } result += text.substring(start, pos); @@ -3468,7 +3477,7 @@ var ts; return token = textToToken[tokenValue]; } } - return token = 67 /* Identifier */; + return token = 69 /* Identifier */; } function scanBinaryOrOctalDigits(base) { ts.Debug.assert(base !== 2 || base !== 8, "Expected either base 2 or base 8"); @@ -3552,7 +3561,7 @@ var ts; } return pos += 2, token = 31 /* ExclamationEqualsToken */; } - return pos++, token = 48 /* ExclamationToken */; + return pos++, token = 49 /* ExclamationToken */; case 34 /* doubleQuote */: case 39 /* singleQuote */: tokenValue = scanString(); @@ -3561,42 +3570,48 @@ var ts; return token = scanTemplateAndSetTokenValue(); case 37 /* percent */: if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 60 /* PercentEqualsToken */; + return pos += 2, token = 62 /* PercentEqualsToken */; } - return pos++, token = 39 /* PercentToken */; + return pos++, token = 40 /* PercentToken */; case 38 /* ampersand */: if (text.charCodeAt(pos + 1) === 38 /* ampersand */) { - return pos += 2, token = 50 /* AmpersandAmpersandToken */; + return pos += 2, token = 51 /* AmpersandAmpersandToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 64 /* AmpersandEqualsToken */; + return pos += 2, token = 66 /* AmpersandEqualsToken */; } - return pos++, token = 45 /* AmpersandToken */; + return pos++, token = 46 /* AmpersandToken */; case 40 /* openParen */: return pos++, token = 17 /* OpenParenToken */; case 41 /* closeParen */: return pos++, token = 18 /* CloseParenToken */; case 42 /* asterisk */: if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 58 /* AsteriskEqualsToken */; + return pos += 2, token = 59 /* AsteriskEqualsToken */; + } + if (text.charCodeAt(pos + 1) === 42 /* asterisk */) { + if (text.charCodeAt(pos + 2) === 61 /* equals */) { + return pos += 3, token = 60 /* AsteriskAsteriskEqualsToken */; + } + return pos += 2, token = 38 /* AsteriskAsteriskToken */; } return pos++, token = 37 /* AsteriskToken */; case 43 /* plus */: if (text.charCodeAt(pos + 1) === 43 /* plus */) { - return pos += 2, token = 40 /* PlusPlusToken */; + return pos += 2, token = 41 /* PlusPlusToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 56 /* PlusEqualsToken */; + return pos += 2, token = 57 /* PlusEqualsToken */; } return pos++, token = 35 /* PlusToken */; case 44 /* comma */: return pos++, token = 24 /* CommaToken */; case 45 /* minus */: if (text.charCodeAt(pos + 1) === 45 /* minus */) { - return pos += 2, token = 41 /* MinusMinusToken */; + return pos += 2, token = 42 /* MinusMinusToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 57 /* MinusEqualsToken */; + return pos += 2, token = 58 /* MinusEqualsToken */; } return pos++, token = 36 /* MinusToken */; case 46 /* dot */: @@ -3653,9 +3668,9 @@ var ts; } } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 59 /* SlashEqualsToken */; + return pos += 2, token = 61 /* SlashEqualsToken */; } - return pos++, token = 38 /* SlashToken */; + return pos++, token = 39 /* SlashToken */; case 48 /* _0 */: if (pos + 2 < end && (text.charCodeAt(pos + 1) === 88 /* X */ || text.charCodeAt(pos + 1) === 120 /* x */)) { pos += 2; @@ -3707,7 +3722,7 @@ var ts; tokenValue = "" + scanNumber(); return token = 8 /* NumericLiteral */; case 58 /* colon */: - return pos++, token = 53 /* ColonToken */; + return pos++, token = 54 /* ColonToken */; case 59 /* semicolon */: return pos++, token = 23 /* SemicolonToken */; case 60 /* lessThan */: @@ -3722,14 +3737,16 @@ var ts; } if (text.charCodeAt(pos + 1) === 60 /* lessThan */) { if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 61 /* LessThanLessThanEqualsToken */; + return pos += 3, token = 63 /* LessThanLessThanEqualsToken */; } - return pos += 2, token = 42 /* LessThanLessThanToken */; + return pos += 2, token = 43 /* LessThanLessThanToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { return pos += 2, token = 28 /* LessThanEqualsToken */; } - if (text.charCodeAt(pos + 1) === 47 /* slash */ && languageVariant === 1 /* JSX */) { + if (languageVariant === 1 /* JSX */ && + text.charCodeAt(pos + 1) === 47 /* slash */ && + text.charCodeAt(pos + 2) !== 42 /* asterisk */) { return pos += 2, token = 26 /* LessThanSlashToken */; } return pos++, token = 25 /* LessThanToken */; @@ -3752,7 +3769,7 @@ var ts; if (text.charCodeAt(pos + 1) === 62 /* greaterThan */) { return pos += 2, token = 34 /* EqualsGreaterThanToken */; } - return pos++, token = 55 /* EqualsToken */; + return pos++, token = 56 /* EqualsToken */; case 62 /* greaterThan */: if (isConflictMarkerTrivia(text, pos)) { pos = scanConflictMarkerTrivia(text, pos, error); @@ -3765,35 +3782,35 @@ var ts; } return pos++, token = 27 /* GreaterThanToken */; case 63 /* question */: - return pos++, token = 52 /* QuestionToken */; + return pos++, token = 53 /* QuestionToken */; case 91 /* openBracket */: return pos++, token = 19 /* OpenBracketToken */; case 93 /* closeBracket */: return pos++, token = 20 /* CloseBracketToken */; case 94 /* caret */: if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 66 /* CaretEqualsToken */; + return pos += 2, token = 68 /* CaretEqualsToken */; } - return pos++, token = 47 /* CaretToken */; + return pos++, token = 48 /* CaretToken */; case 123 /* openBrace */: return pos++, token = 15 /* OpenBraceToken */; case 124 /* bar */: if (text.charCodeAt(pos + 1) === 124 /* bar */) { - return pos += 2, token = 51 /* BarBarToken */; + return pos += 2, token = 52 /* BarBarToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 65 /* BarEqualsToken */; + return pos += 2, token = 67 /* BarEqualsToken */; } - return pos++, token = 46 /* BarToken */; + return pos++, token = 47 /* BarToken */; case 125 /* closeBrace */: return pos++, token = 16 /* CloseBraceToken */; case 126 /* tilde */: - return pos++, token = 49 /* TildeToken */; + return pos++, token = 50 /* TildeToken */; case 64 /* at */: - return pos++, token = 54 /* AtToken */; + return pos++, token = 55 /* AtToken */; case 92 /* backslash */: var cookedChar = peekUnicodeEscape(); - if (cookedChar >= 0 && isIdentifierStart(cookedChar)) { + if (cookedChar >= 0 && isIdentifierStart(cookedChar, languageVersion)) { pos += 6; tokenValue = String.fromCharCode(cookedChar) + scanIdentifierParts(); return token = getIdentifierToken(); @@ -3801,9 +3818,9 @@ var ts; error(ts.Diagnostics.Invalid_character); return pos++, token = 0 /* Unknown */; default: - if (isIdentifierStart(ch)) { + if (isIdentifierStart(ch, languageVersion)) { pos++; - while (pos < end && isIdentifierPart(ch = text.charCodeAt(pos))) + while (pos < end && isIdentifierPart(ch = text.charCodeAt(pos), languageVersion)) pos++; tokenValue = text.substring(tokenPos, pos); if (ch === 92 /* backslash */) { @@ -3830,14 +3847,14 @@ var ts; if (text.charCodeAt(pos) === 62 /* greaterThan */) { if (text.charCodeAt(pos + 1) === 62 /* greaterThan */) { if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 63 /* GreaterThanGreaterThanGreaterThanEqualsToken */; + return pos += 3, token = 65 /* GreaterThanGreaterThanGreaterThanEqualsToken */; } - return pos += 2, token = 44 /* GreaterThanGreaterThanGreaterThanToken */; + return pos += 2, token = 45 /* GreaterThanGreaterThanGreaterThanToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 62 /* GreaterThanGreaterThanEqualsToken */; + return pos += 2, token = 64 /* GreaterThanGreaterThanEqualsToken */; } - return pos++, token = 43 /* GreaterThanGreaterThanToken */; + return pos++, token = 44 /* GreaterThanGreaterThanToken */; } if (text.charCodeAt(pos) === 61 /* equals */) { return pos++, token = 29 /* GreaterThanEqualsToken */; @@ -3846,7 +3863,7 @@ var ts; return token; } function reScanSlashToken() { - if (token === 38 /* SlashToken */ || token === 59 /* SlashEqualsToken */) { + if (token === 39 /* SlashToken */ || token === 61 /* SlashEqualsToken */) { var p = tokenPos + 1; var inEscape = false; var inCharacterClass = false; @@ -3886,7 +3903,7 @@ var ts; } p++; } - while (p < end && isIdentifierPart(text.charCodeAt(p))) { + while (p < end && isIdentifierPart(text.charCodeAt(p), languageVersion)) { p++; } pos = p; @@ -3932,7 +3949,7 @@ var ts; break; } } - return token = 234 /* JsxText */; + return token = 236 /* JsxText */; } // Scans a JSX identifier; these differ from normal identifiers in that // they allow dashes @@ -3941,7 +3958,7 @@ var ts; var firstCharPosition = pos; while (pos < end) { var ch = text.charCodeAt(pos); - if (ch === 45 /* minus */ || ((firstCharPosition === pos) ? isIdentifierStart(ch) : isIdentifierPart(ch))) { + if (ch === 45 /* minus */ || ((firstCharPosition === pos) ? isIdentifierStart(ch, languageVersion) : isIdentifierPart(ch, languageVersion))) { pos++; } else { @@ -4020,16 +4037,16 @@ var ts; function getModuleInstanceState(node) { // A module is uninstantiated if it contains only // 1. interface declarations, type alias declarations - if (node.kind === 213 /* InterfaceDeclaration */ || node.kind === 214 /* TypeAliasDeclaration */) { + if (node.kind === 215 /* InterfaceDeclaration */ || node.kind === 216 /* TypeAliasDeclaration */) { return 0 /* NonInstantiated */; } else if (ts.isConstEnumDeclaration(node)) { return 2 /* ConstEnumOnly */; } - else if ((node.kind === 220 /* ImportDeclaration */ || node.kind === 219 /* ImportEqualsDeclaration */) && !(node.flags & 1 /* Export */)) { + else if ((node.kind === 222 /* ImportDeclaration */ || node.kind === 221 /* ImportEqualsDeclaration */) && !(node.flags & 1 /* Export */)) { return 0 /* NonInstantiated */; } - else if (node.kind === 217 /* ModuleBlock */) { + else if (node.kind === 219 /* ModuleBlock */) { var state = 0 /* NonInstantiated */; ts.forEachChild(node, function (n) { switch (getModuleInstanceState(n)) { @@ -4048,7 +4065,7 @@ var ts; }); return state; } - else if (node.kind === 216 /* ModuleDeclaration */) { + else if (node.kind === 218 /* ModuleDeclaration */) { return getModuleInstanceState(node.body); } else { @@ -4088,6 +4105,8 @@ var ts; var container; var blockScopeContainer; var lastContainer; + var seenThisKeyword; + var isJavaScriptFile = ts.isSourceFileJavaScript(file); // If this file is an external module, then it is automatically in strict-mode according to // ES6. If it is not an external module, then we'll determine if it is in strict mode or // not depending on if we see "use strict" in certain places (or if we hit a class/namespace). @@ -4126,10 +4145,10 @@ var ts; // unless it is a well known Symbol. function getDeclarationName(node) { if (node.name) { - if (node.kind === 216 /* ModuleDeclaration */ && node.name.kind === 9 /* StringLiteral */) { + if (node.kind === 218 /* ModuleDeclaration */ && node.name.kind === 9 /* StringLiteral */) { return "\"" + node.name.text + "\""; } - if (node.name.kind === 134 /* ComputedPropertyName */) { + if (node.name.kind === 136 /* ComputedPropertyName */) { var nameExpression = node.name.expression; ts.Debug.assert(ts.isWellKnownSymbolSyntactically(nameExpression)); return ts.getPropertyNameForKnownSymbolName(nameExpression.name.text); @@ -4137,22 +4156,25 @@ var ts; return node.name.text; } switch (node.kind) { - case 142 /* Constructor */: + case 144 /* Constructor */: return "__constructor"; - case 150 /* FunctionType */: - case 145 /* CallSignature */: + case 152 /* FunctionType */: + case 147 /* CallSignature */: return "__call"; - case 151 /* ConstructorType */: - case 146 /* ConstructSignature */: + case 153 /* ConstructorType */: + case 148 /* ConstructSignature */: return "__new"; - case 147 /* IndexSignature */: + case 149 /* IndexSignature */: return "__index"; - case 226 /* ExportDeclaration */: + case 228 /* ExportDeclaration */: return "__export"; - case 225 /* ExportAssignment */: + case 227 /* ExportAssignment */: return node.isExportEquals ? "export=" : "default"; - case 211 /* FunctionDeclaration */: - case 212 /* ClassDeclaration */: + case 181 /* BinaryExpression */: + // Binary expression case is for JS module 'module.exports = expr' + return "export="; + case 213 /* FunctionDeclaration */: + case 214 /* ClassDeclaration */: return node.flags & 1024 /* Default */ ? "default" : undefined; } } @@ -4169,8 +4191,9 @@ var ts; */ function declareSymbol(symbolTable, parent, node, includes, excludes) { ts.Debug.assert(!ts.hasDynamicName(node)); + var isDefaultExport = node.flags & 1024 /* Default */; // The exported symbol for an export default function/class node is always named "default" - var name = node.flags & 1024 /* Default */ && parent ? "default" : getDeclarationName(node); + var name = isDefaultExport && parent ? "default" : getDeclarationName(node); var symbol; if (name !== undefined) { // Check and see if the symbol table already has a symbol with this name. If not, @@ -4206,6 +4229,11 @@ var ts; var message = symbol.flags & 2 /* BlockScopedVariable */ ? ts.Diagnostics.Cannot_redeclare_block_scoped_variable_0 : ts.Diagnostics.Duplicate_identifier_0; + ts.forEach(symbol.declarations, function (declaration) { + if (declaration.flags & 1024 /* Default */) { + message = ts.Diagnostics.A_module_cannot_have_multiple_default_exports; + } + }); ts.forEach(symbol.declarations, function (declaration) { file.bindDiagnostics.push(ts.createDiagnosticForNode(declaration.name || declaration, message, getDisplayName(declaration))); }); @@ -4223,7 +4251,7 @@ var ts; function declareModuleMember(node, symbolFlags, symbolExcludes) { var hasExportModifier = ts.getCombinedNodeFlags(node) & 1 /* Export */; if (symbolFlags & 8388608 /* Alias */) { - if (node.kind === 228 /* ExportSpecifier */ || (node.kind === 219 /* ImportEqualsDeclaration */ && hasExportModifier)) { + if (node.kind === 230 /* ExportSpecifier */ || (node.kind === 221 /* ImportEqualsDeclaration */ && hasExportModifier)) { return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); } else { @@ -4297,44 +4325,51 @@ var ts; blockScopeContainer = node; blockScopeContainer.locals = undefined; } - ts.forEachChild(node, bind); + if (node.kind === 215 /* InterfaceDeclaration */) { + seenThisKeyword = false; + ts.forEachChild(node, bind); + node.flags = seenThisKeyword ? node.flags | 524288 /* ContainsThis */ : node.flags & ~524288 /* ContainsThis */; + } + else { + ts.forEachChild(node, bind); + } container = saveContainer; parent = saveParent; blockScopeContainer = savedBlockScopeContainer; } function getContainerFlags(node) { switch (node.kind) { - case 184 /* ClassExpression */: - case 212 /* ClassDeclaration */: - case 213 /* InterfaceDeclaration */: - case 215 /* EnumDeclaration */: - case 153 /* TypeLiteral */: - case 163 /* ObjectLiteralExpression */: + case 186 /* ClassExpression */: + case 214 /* ClassDeclaration */: + case 215 /* InterfaceDeclaration */: + case 217 /* EnumDeclaration */: + case 155 /* TypeLiteral */: + case 165 /* ObjectLiteralExpression */: return 1 /* IsContainer */; - case 145 /* CallSignature */: - case 146 /* ConstructSignature */: - case 147 /* IndexSignature */: - case 141 /* MethodDeclaration */: - case 140 /* MethodSignature */: - case 211 /* FunctionDeclaration */: - case 142 /* Constructor */: - case 143 /* GetAccessor */: - case 144 /* SetAccessor */: - case 150 /* FunctionType */: - case 151 /* ConstructorType */: - case 171 /* FunctionExpression */: - case 172 /* ArrowFunction */: - case 216 /* ModuleDeclaration */: - case 246 /* SourceFile */: - case 214 /* TypeAliasDeclaration */: + case 147 /* CallSignature */: + case 148 /* ConstructSignature */: + case 149 /* IndexSignature */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: + case 213 /* FunctionDeclaration */: + case 144 /* Constructor */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: + case 152 /* FunctionType */: + case 153 /* ConstructorType */: + case 173 /* FunctionExpression */: + case 174 /* ArrowFunction */: + case 218 /* ModuleDeclaration */: + case 248 /* SourceFile */: + case 216 /* TypeAliasDeclaration */: return 5 /* IsContainerWithLocals */; - case 242 /* CatchClause */: - case 197 /* ForStatement */: - case 198 /* ForInStatement */: - case 199 /* ForOfStatement */: - case 218 /* CaseBlock */: + case 244 /* CatchClause */: + case 199 /* ForStatement */: + case 200 /* ForInStatement */: + case 201 /* ForOfStatement */: + case 220 /* CaseBlock */: return 2 /* IsBlockScopedContainer */; - case 190 /* Block */: + case 192 /* Block */: // do not treat blocks directly inside a function as a block-scoped-container. // Locals that reside in this block should go to the function locals. Othewise 'x' // would not appear to be a redeclaration of a block scoped local in the following @@ -4371,38 +4406,38 @@ var ts; // members are declared (for example, a member of a class will go into a specific // symbol table depending on if it is static or not). We defer to specialized // handlers to take care of declaring these child members. - case 216 /* ModuleDeclaration */: + case 218 /* ModuleDeclaration */: return declareModuleMember(node, symbolFlags, symbolExcludes); - case 246 /* SourceFile */: + case 248 /* SourceFile */: return declareSourceFileMember(node, symbolFlags, symbolExcludes); - case 184 /* ClassExpression */: - case 212 /* ClassDeclaration */: + case 186 /* ClassExpression */: + case 214 /* ClassDeclaration */: return declareClassMember(node, symbolFlags, symbolExcludes); - case 215 /* EnumDeclaration */: + case 217 /* EnumDeclaration */: return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); - case 153 /* TypeLiteral */: - case 163 /* ObjectLiteralExpression */: - case 213 /* InterfaceDeclaration */: + case 155 /* TypeLiteral */: + case 165 /* ObjectLiteralExpression */: + case 215 /* InterfaceDeclaration */: // Interface/Object-types always have their children added to the 'members' of // their container. They are only accessible through an instance of their // container, and are never in scope otherwise (even inside the body of the // object / type / interface declaring them). An exception is type parameters, // which are in scope without qualification (similar to 'locals'). return declareSymbol(container.symbol.members, container.symbol, node, symbolFlags, symbolExcludes); - case 150 /* FunctionType */: - case 151 /* ConstructorType */: - case 145 /* CallSignature */: - case 146 /* ConstructSignature */: - case 147 /* IndexSignature */: - case 141 /* MethodDeclaration */: - case 140 /* MethodSignature */: - case 142 /* Constructor */: - case 143 /* GetAccessor */: - case 144 /* SetAccessor */: - case 211 /* FunctionDeclaration */: - case 171 /* FunctionExpression */: - case 172 /* ArrowFunction */: - case 214 /* TypeAliasDeclaration */: + case 152 /* FunctionType */: + case 153 /* ConstructorType */: + case 147 /* CallSignature */: + case 148 /* ConstructSignature */: + case 149 /* IndexSignature */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: + case 144 /* Constructor */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: + case 213 /* FunctionDeclaration */: + case 173 /* FunctionExpression */: + case 174 /* ArrowFunction */: + case 216 /* TypeAliasDeclaration */: // All the children of these container types are never visible through another // symbol (i.e. through another symbol's 'exports' or 'members'). Instead, // they're only accessed 'lexically' (i.e. from code that exists underneath @@ -4432,11 +4467,11 @@ var ts; return false; } function hasExportDeclarations(node) { - var body = node.kind === 246 /* SourceFile */ ? node : node.body; - if (body.kind === 246 /* SourceFile */ || body.kind === 217 /* ModuleBlock */) { + var body = node.kind === 248 /* SourceFile */ ? node : node.body; + if (body.kind === 248 /* SourceFile */ || body.kind === 219 /* ModuleBlock */) { for (var _i = 0, _a = body.statements; _i < _a.length; _i++) { var stat = _a[_i]; - if (stat.kind === 226 /* ExportDeclaration */ || stat.kind === 225 /* ExportAssignment */) { + if (stat.kind === 228 /* ExportDeclaration */ || stat.kind === 227 /* ExportAssignment */) { return true; } } @@ -4508,7 +4543,7 @@ var ts; var seen = {}; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; - if (prop.name.kind !== 67 /* Identifier */) { + if (prop.name.kind !== 69 /* Identifier */) { continue; } var identifier = prop.name; @@ -4520,7 +4555,7 @@ var ts; // c.IsAccessorDescriptor(previous) is true and IsDataDescriptor(propId.descriptor) is true. // d.IsAccessorDescriptor(previous) is true and IsAccessorDescriptor(propId.descriptor) is true // and either both previous and propId.descriptor have[[Get]] fields or both previous and propId.descriptor have[[Set]] fields - var currentKind = prop.kind === 243 /* PropertyAssignment */ || prop.kind === 244 /* ShorthandPropertyAssignment */ || prop.kind === 141 /* MethodDeclaration */ + var currentKind = prop.kind === 245 /* PropertyAssignment */ || prop.kind === 246 /* ShorthandPropertyAssignment */ || prop.kind === 143 /* MethodDeclaration */ ? 1 /* Property */ : 2 /* Accessor */; var existingKind = seen[identifier.text]; @@ -4542,10 +4577,10 @@ var ts; } function bindBlockScopedDeclaration(node, symbolFlags, symbolExcludes) { switch (blockScopeContainer.kind) { - case 216 /* ModuleDeclaration */: + case 218 /* ModuleDeclaration */: declareModuleMember(node, symbolFlags, symbolExcludes); break; - case 246 /* SourceFile */: + case 248 /* SourceFile */: if (ts.isExternalModule(container)) { declareModuleMember(node, symbolFlags, symbolExcludes); break; @@ -4566,8 +4601,8 @@ var ts; // check for reserved words used as identifiers in strict mode code. function checkStrictModeIdentifier(node) { if (inStrictMode && - node.originalKeywordKind >= 104 /* FirstFutureReservedWord */ && - node.originalKeywordKind <= 112 /* LastFutureReservedWord */ && + node.originalKeywordKind >= 106 /* FirstFutureReservedWord */ && + node.originalKeywordKind <= 114 /* LastFutureReservedWord */ && !ts.isIdentifierName(node)) { // Report error only if there are no parse errors in file if (!file.parseDiagnostics.length) { @@ -4602,7 +4637,7 @@ var ts; } function checkStrictModeDeleteExpression(node) { // Grammar checking - if (inStrictMode && node.expression.kind === 67 /* Identifier */) { + if (inStrictMode && node.expression.kind === 69 /* Identifier */) { // When a delete operator occurs within strict mode code, a SyntaxError is thrown if its // UnaryExpression is a direct reference to a variable, function argument, or function name var span = ts.getErrorSpanForNode(file, node.expression); @@ -4610,11 +4645,11 @@ var ts; } } function isEvalOrArgumentsIdentifier(node) { - return node.kind === 67 /* Identifier */ && + return node.kind === 69 /* Identifier */ && (node.text === "eval" || node.text === "arguments"); } function checkStrictModeEvalOrArguments(contextNode, name) { - if (name && name.kind === 67 /* Identifier */) { + if (name && name.kind === 69 /* Identifier */) { var identifier = name; if (isEvalOrArgumentsIdentifier(identifier)) { // We check first if the name is inside class declaration or class expression; if so give explicit message @@ -4658,7 +4693,7 @@ var ts; function checkStrictModePrefixUnaryExpression(node) { // Grammar checking if (inStrictMode) { - if (node.operator === 40 /* PlusPlusToken */ || node.operator === 41 /* MinusMinusToken */) { + if (node.operator === 41 /* PlusPlusToken */ || node.operator === 42 /* MinusMinusToken */) { checkStrictModeEvalOrArguments(node, node.operand); } } @@ -4702,17 +4737,17 @@ var ts; } function updateStrictMode(node) { switch (node.kind) { - case 246 /* SourceFile */: - case 217 /* ModuleBlock */: + case 248 /* SourceFile */: + case 219 /* ModuleBlock */: updateStrictModeStatementList(node.statements); return; - case 190 /* Block */: + case 192 /* Block */: if (ts.isFunctionLike(node.parent)) { updateStrictModeStatementList(node.statements); } return; - case 212 /* ClassDeclaration */: - case 184 /* ClassExpression */: + case 214 /* ClassDeclaration */: + case 186 /* ClassExpression */: // All classes are automatically in strict mode in ES6. inStrictMode = true; return; @@ -4739,107 +4774,130 @@ var ts; } function bindWorker(node) { switch (node.kind) { - case 67 /* Identifier */: + /* Strict mode checks */ + case 69 /* Identifier */: return checkStrictModeIdentifier(node); - case 179 /* BinaryExpression */: + case 181 /* BinaryExpression */: + if (isJavaScriptFile) { + if (ts.isExportsPropertyAssignment(node)) { + bindExportsPropertyAssignment(node); + } + else if (ts.isModuleExportsAssignment(node)) { + bindModuleExportsAssignment(node); + } + } return checkStrictModeBinaryExpression(node); - case 242 /* CatchClause */: + case 244 /* CatchClause */: return checkStrictModeCatchClause(node); - case 173 /* DeleteExpression */: + case 175 /* DeleteExpression */: return checkStrictModeDeleteExpression(node); case 8 /* NumericLiteral */: return checkStrictModeNumericLiteral(node); - case 178 /* PostfixUnaryExpression */: + case 180 /* PostfixUnaryExpression */: return checkStrictModePostfixUnaryExpression(node); - case 177 /* PrefixUnaryExpression */: + case 179 /* PrefixUnaryExpression */: return checkStrictModePrefixUnaryExpression(node); - case 203 /* WithStatement */: + case 205 /* WithStatement */: return checkStrictModeWithStatement(node); - case 135 /* TypeParameter */: + case 97 /* ThisKeyword */: + seenThisKeyword = true; + return; + case 137 /* TypeParameter */: return declareSymbolAndAddToSymbolTable(node, 262144 /* TypeParameter */, 530912 /* TypeParameterExcludes */); - case 136 /* Parameter */: + case 138 /* Parameter */: return bindParameter(node); - case 209 /* VariableDeclaration */: - case 161 /* BindingElement */: + case 211 /* VariableDeclaration */: + case 163 /* BindingElement */: return bindVariableDeclarationOrBindingElement(node); - case 139 /* PropertyDeclaration */: - case 138 /* PropertySignature */: + case 141 /* PropertyDeclaration */: + case 140 /* PropertySignature */: return bindPropertyOrMethodOrAccessor(node, 4 /* Property */ | (node.questionToken ? 536870912 /* Optional */ : 0 /* None */), 107455 /* PropertyExcludes */); - case 243 /* PropertyAssignment */: - case 244 /* ShorthandPropertyAssignment */: + case 245 /* PropertyAssignment */: + case 246 /* ShorthandPropertyAssignment */: return bindPropertyOrMethodOrAccessor(node, 4 /* Property */, 107455 /* PropertyExcludes */); - case 245 /* EnumMember */: + case 247 /* EnumMember */: return bindPropertyOrMethodOrAccessor(node, 8 /* EnumMember */, 107455 /* EnumMemberExcludes */); - case 145 /* CallSignature */: - case 146 /* ConstructSignature */: - case 147 /* IndexSignature */: + case 147 /* CallSignature */: + case 148 /* ConstructSignature */: + case 149 /* IndexSignature */: return declareSymbolAndAddToSymbolTable(node, 131072 /* Signature */, 0 /* None */); - case 141 /* MethodDeclaration */: - case 140 /* MethodSignature */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: // If this is an ObjectLiteralExpression method, then it sits in the same space // as other properties in the object literal. So we use SymbolFlags.PropertyExcludes // so that it will conflict with any other object literal members with the same // name. return bindPropertyOrMethodOrAccessor(node, 8192 /* Method */ | (node.questionToken ? 536870912 /* Optional */ : 0 /* None */), ts.isObjectLiteralMethod(node) ? 107455 /* PropertyExcludes */ : 99263 /* MethodExcludes */); - case 211 /* FunctionDeclaration */: + case 213 /* FunctionDeclaration */: checkStrictModeFunctionName(node); return declareSymbolAndAddToSymbolTable(node, 16 /* Function */, 106927 /* FunctionExcludes */); - case 142 /* Constructor */: + case 144 /* Constructor */: return declareSymbolAndAddToSymbolTable(node, 16384 /* Constructor */, /*symbolExcludes:*/ 0 /* None */); - case 143 /* GetAccessor */: + case 145 /* GetAccessor */: return bindPropertyOrMethodOrAccessor(node, 32768 /* GetAccessor */, 41919 /* GetAccessorExcludes */); - case 144 /* SetAccessor */: + case 146 /* SetAccessor */: return bindPropertyOrMethodOrAccessor(node, 65536 /* SetAccessor */, 74687 /* SetAccessorExcludes */); - case 150 /* FunctionType */: - case 151 /* ConstructorType */: + case 152 /* FunctionType */: + case 153 /* ConstructorType */: return bindFunctionOrConstructorType(node); - case 153 /* TypeLiteral */: + case 155 /* TypeLiteral */: return bindAnonymousDeclaration(node, 2048 /* TypeLiteral */, "__type"); - case 163 /* ObjectLiteralExpression */: + case 165 /* ObjectLiteralExpression */: return bindObjectLiteralExpression(node); - case 171 /* FunctionExpression */: - case 172 /* ArrowFunction */: + case 173 /* FunctionExpression */: + case 174 /* ArrowFunction */: checkStrictModeFunctionName(node); var bindingName = node.name ? node.name.text : "__function"; return bindAnonymousDeclaration(node, 16 /* Function */, bindingName); - case 184 /* ClassExpression */: - case 212 /* ClassDeclaration */: + case 168 /* CallExpression */: + if (isJavaScriptFile) { + bindCallExpression(node); + } + break; + // Members of classes, interfaces, and modules + case 186 /* ClassExpression */: + case 214 /* ClassDeclaration */: return bindClassLikeDeclaration(node); - case 213 /* InterfaceDeclaration */: + case 215 /* InterfaceDeclaration */: return bindBlockScopedDeclaration(node, 64 /* Interface */, 792960 /* InterfaceExcludes */); - case 214 /* TypeAliasDeclaration */: + case 216 /* TypeAliasDeclaration */: return bindBlockScopedDeclaration(node, 524288 /* TypeAlias */, 793056 /* TypeAliasExcludes */); - case 215 /* EnumDeclaration */: + case 217 /* EnumDeclaration */: return bindEnumDeclaration(node); - case 216 /* ModuleDeclaration */: + case 218 /* ModuleDeclaration */: return bindModuleDeclaration(node); - case 219 /* ImportEqualsDeclaration */: - case 222 /* NamespaceImport */: - case 224 /* ImportSpecifier */: - case 228 /* ExportSpecifier */: + // Imports and exports + case 221 /* ImportEqualsDeclaration */: + case 224 /* NamespaceImport */: + case 226 /* ImportSpecifier */: + case 230 /* ExportSpecifier */: return declareSymbolAndAddToSymbolTable(node, 8388608 /* Alias */, 8388608 /* AliasExcludes */); - case 221 /* ImportClause */: + case 223 /* ImportClause */: return bindImportClause(node); - case 226 /* ExportDeclaration */: + case 228 /* ExportDeclaration */: return bindExportDeclaration(node); - case 225 /* ExportAssignment */: + case 227 /* ExportAssignment */: return bindExportAssignment(node); - case 246 /* SourceFile */: + case 248 /* SourceFile */: return bindSourceFileIfExternalModule(); } } function bindSourceFileIfExternalModule() { setExportContextFlag(file); if (ts.isExternalModule(file)) { - bindAnonymousDeclaration(file, 512 /* ValueModule */, "\"" + ts.removeFileExtension(file.fileName) + "\""); + bindSourceFileAsExternalModule(); } } + function bindSourceFileAsExternalModule() { + bindAnonymousDeclaration(file, 512 /* ValueModule */, "\"" + ts.removeFileExtension(file.fileName) + "\""); + } function bindExportAssignment(node) { + var boundExpression = node.kind === 227 /* ExportAssignment */ ? node.expression : node.right; if (!container.symbol || !container.symbol.exports) { // Export assignment in some sort of block construct bindAnonymousDeclaration(node, 8388608 /* Alias */, getDeclarationName(node)); } - else if (node.expression.kind === 67 /* Identifier */) { + else if (boundExpression.kind === 69 /* Identifier */) { // An export default clause with an identifier exports all meanings of that identifier declareSymbol(container.symbol.exports, container.symbol, node, 8388608 /* Alias */, 107455 /* PropertyExcludes */ | 8388608 /* AliasExcludes */); } @@ -4863,8 +4921,32 @@ var ts; declareSymbolAndAddToSymbolTable(node, 8388608 /* Alias */, 8388608 /* AliasExcludes */); } } + function setCommonJsModuleIndicator(node) { + if (!file.commonJsModuleIndicator) { + file.commonJsModuleIndicator = node; + bindSourceFileAsExternalModule(); + } + } + function bindExportsPropertyAssignment(node) { + // When we create a property via 'exports.foo = bar', the 'exports.foo' property access + // expression is the declaration + setCommonJsModuleIndicator(node); + declareSymbol(file.symbol.exports, file.symbol, node.left, 4 /* Property */ | 7340032 /* Export */, 0 /* None */); + } + function bindModuleExportsAssignment(node) { + // 'module.exports = expr' assignment + setCommonJsModuleIndicator(node); + bindExportAssignment(node); + } + function bindCallExpression(node) { + // We're only inspecting call expressions to detect CommonJS modules, so we can skip + // this check if we've already seen the module indicator + if (!file.commonJsModuleIndicator && ts.isRequireCall(node)) { + setCommonJsModuleIndicator(node); + } + } function bindClassLikeDeclaration(node) { - if (node.kind === 212 /* ClassDeclaration */) { + if (node.kind === 214 /* ClassDeclaration */) { bindBlockScopedDeclaration(node, 32 /* Class */, 899519 /* ClassExcludes */); } else { @@ -4940,7 +5022,7 @@ var ts; // If this is a property-parameter, then also declare the property symbol into the // containing class. if (node.flags & 112 /* AccessibilityModifier */ && - node.parent.kind === 142 /* Constructor */ && + node.parent.kind === 144 /* Constructor */ && ts.isClassLike(node.parent.parent)) { var classDeclaration = node.parent.parent; declareSymbol(classDeclaration.symbol.members, classDeclaration.symbol, node, 4 /* Property */, 107455 /* PropertyExcludes */); @@ -4992,7 +5074,8 @@ var ts; increaseIndent: function () { }, decreaseIndent: function () { }, clear: function () { return str = ""; }, - trackSymbol: function () { } + trackSymbol: function () { }, + reportInaccessibleThisError: function () { } }; } return stringWriters.pop(); @@ -5062,7 +5145,7 @@ var ts; } } function getSourceFileOfNode(node) { - while (node && node.kind !== 246 /* SourceFile */) { + while (node && node.kind !== 248 /* SourceFile */) { node = node.parent; } return node; @@ -5174,15 +5257,15 @@ var ts; return current; } switch (current.kind) { - case 246 /* SourceFile */: - case 218 /* CaseBlock */: - case 242 /* CatchClause */: - case 216 /* ModuleDeclaration */: - case 197 /* ForStatement */: - case 198 /* ForInStatement */: - case 199 /* ForOfStatement */: + case 248 /* SourceFile */: + case 220 /* CaseBlock */: + case 244 /* CatchClause */: + case 218 /* ModuleDeclaration */: + case 199 /* ForStatement */: + case 200 /* ForInStatement */: + case 201 /* ForOfStatement */: return current; - case 190 /* Block */: + case 192 /* Block */: // function block is not considered block-scope container // see comment in binder.ts: bind(...), case for SyntaxKind.Block if (!isFunctionLike(current.parent)) { @@ -5195,9 +5278,9 @@ var ts; ts.getEnclosingBlockScopeContainer = getEnclosingBlockScopeContainer; function isCatchClauseVariableDeclaration(declaration) { return declaration && - declaration.kind === 209 /* VariableDeclaration */ && + declaration.kind === 211 /* VariableDeclaration */ && declaration.parent && - declaration.parent.kind === 242 /* CatchClause */; + declaration.parent.kind === 244 /* CatchClause */; } ts.isCatchClauseVariableDeclaration = isCatchClauseVariableDeclaration; // Return display name of an identifier @@ -5236,7 +5319,7 @@ var ts; function getErrorSpanForNode(sourceFile, node) { var errorNode = node; switch (node.kind) { - case 246 /* SourceFile */: + case 248 /* SourceFile */: var pos_1 = ts.skipTrivia(sourceFile.text, 0, /*stopAfterLineBreak*/ false); if (pos_1 === sourceFile.text.length) { // file is empty - return span for the beginning of the file @@ -5245,16 +5328,16 @@ var ts; return getSpanOfTokenAtPosition(sourceFile, pos_1); // This list is a work in progress. Add missing node kinds to improve their error // spans. - case 209 /* VariableDeclaration */: - case 161 /* BindingElement */: - case 212 /* ClassDeclaration */: - case 184 /* ClassExpression */: - case 213 /* InterfaceDeclaration */: - case 216 /* ModuleDeclaration */: - case 215 /* EnumDeclaration */: - case 245 /* EnumMember */: - case 211 /* FunctionDeclaration */: - case 171 /* FunctionExpression */: + case 211 /* VariableDeclaration */: + case 163 /* BindingElement */: + case 214 /* ClassDeclaration */: + case 186 /* ClassExpression */: + case 215 /* InterfaceDeclaration */: + case 218 /* ModuleDeclaration */: + case 217 /* EnumDeclaration */: + case 247 /* EnumMember */: + case 213 /* FunctionDeclaration */: + case 173 /* FunctionExpression */: errorNode = node.name; break; } @@ -5273,16 +5356,20 @@ var ts; return file.externalModuleIndicator !== undefined; } ts.isExternalModule = isExternalModule; + function isExternalOrCommonJsModule(file) { + return (file.externalModuleIndicator || file.commonJsModuleIndicator) !== undefined; + } + ts.isExternalOrCommonJsModule = isExternalOrCommonJsModule; function isDeclarationFile(file) { return (file.flags & 8192 /* DeclarationFile */) !== 0; } ts.isDeclarationFile = isDeclarationFile; function isConstEnumDeclaration(node) { - return node.kind === 215 /* EnumDeclaration */ && isConst(node); + return node.kind === 217 /* EnumDeclaration */ && isConst(node); } ts.isConstEnumDeclaration = isConstEnumDeclaration; function walkUpBindingElementsAndPatterns(node) { - while (node && (node.kind === 161 /* BindingElement */ || isBindingPattern(node))) { + while (node && (node.kind === 163 /* BindingElement */ || isBindingPattern(node))) { node = node.parent; } return node; @@ -5297,14 +5384,14 @@ var ts; function getCombinedNodeFlags(node) { node = walkUpBindingElementsAndPatterns(node); var flags = node.flags; - if (node.kind === 209 /* VariableDeclaration */) { + if (node.kind === 211 /* VariableDeclaration */) { node = node.parent; } - if (node && node.kind === 210 /* VariableDeclarationList */) { + if (node && node.kind === 212 /* VariableDeclarationList */) { flags |= node.flags; node = node.parent; } - if (node && node.kind === 191 /* VariableStatement */) { + if (node && node.kind === 193 /* VariableStatement */) { flags |= node.flags; } return flags; @@ -5319,7 +5406,7 @@ var ts; } ts.isLet = isLet; function isPrologueDirective(node) { - return node.kind === 193 /* ExpressionStatement */ && node.expression.kind === 9 /* StringLiteral */; + return node.kind === 195 /* ExpressionStatement */ && node.expression.kind === 9 /* StringLiteral */; } ts.isPrologueDirective = isPrologueDirective; function getLeadingCommentRangesOfNode(node, sourceFileOfNode) { @@ -5327,7 +5414,7 @@ var ts; } ts.getLeadingCommentRangesOfNode = getLeadingCommentRangesOfNode; function getJsDocComments(node, sourceFileOfNode) { - var commentRanges = (node.kind === 136 /* Parameter */ || node.kind === 135 /* TypeParameter */) ? + var commentRanges = (node.kind === 138 /* Parameter */ || node.kind === 137 /* TypeParameter */) ? ts.concatenate(ts.getTrailingCommentRanges(sourceFileOfNode.text, node.pos), ts.getLeadingCommentRanges(sourceFileOfNode.text, node.pos)) : getLeadingCommentRangesOfNode(node, sourceFileOfNode); return ts.filter(commentRanges, isJsDocComment); @@ -5342,40 +5429,40 @@ var ts; ts.fullTripleSlashReferencePathRegEx = /^(\/\/\/\s*/; ts.fullTripleSlashAMDReferencePathRegEx = /^(\/\/\/\s*/; function isTypeNode(node) { - if (149 /* FirstTypeNode */ <= node.kind && node.kind <= 158 /* LastTypeNode */) { + if (151 /* FirstTypeNode */ <= node.kind && node.kind <= 160 /* LastTypeNode */) { return true; } switch (node.kind) { - case 115 /* AnyKeyword */: - case 126 /* NumberKeyword */: - case 128 /* StringKeyword */: - case 118 /* BooleanKeyword */: - case 129 /* SymbolKeyword */: + case 117 /* AnyKeyword */: + case 128 /* NumberKeyword */: + case 130 /* StringKeyword */: + case 120 /* BooleanKeyword */: + case 131 /* SymbolKeyword */: return true; - case 101 /* VoidKeyword */: - return node.parent.kind !== 175 /* VoidExpression */; + case 103 /* VoidKeyword */: + return node.parent.kind !== 177 /* VoidExpression */; case 9 /* StringLiteral */: // Specialized signatures can have string literals as their parameters' type names - return node.parent.kind === 136 /* Parameter */; - case 186 /* ExpressionWithTypeArguments */: + return node.parent.kind === 138 /* Parameter */; + case 188 /* ExpressionWithTypeArguments */: return !isExpressionWithTypeArgumentsInClassExtendsClause(node); // Identifiers and qualified names may be type nodes, depending on their context. Climb // above them to find the lowest container - case 67 /* Identifier */: + case 69 /* Identifier */: // If the identifier is the RHS of a qualified name, then it's a type iff its parent is. - if (node.parent.kind === 133 /* QualifiedName */ && node.parent.right === node) { + if (node.parent.kind === 135 /* QualifiedName */ && node.parent.right === node) { node = node.parent; } - else if (node.parent.kind === 164 /* PropertyAccessExpression */ && node.parent.name === node) { + else if (node.parent.kind === 166 /* PropertyAccessExpression */ && node.parent.name === node) { node = node.parent; } - // fall through - case 133 /* QualifiedName */: - case 164 /* PropertyAccessExpression */: // At this point, node is either a qualified name or an identifier - ts.Debug.assert(node.kind === 67 /* Identifier */ || node.kind === 133 /* QualifiedName */ || node.kind === 164 /* PropertyAccessExpression */, "'node' was expected to be a qualified name, identifier or property access in 'isTypeNode'."); + ts.Debug.assert(node.kind === 69 /* Identifier */ || node.kind === 135 /* QualifiedName */ || node.kind === 166 /* PropertyAccessExpression */, "'node' was expected to be a qualified name, identifier or property access in 'isTypeNode'."); + case 135 /* QualifiedName */: + case 166 /* PropertyAccessExpression */: + case 97 /* ThisKeyword */: var parent_1 = node.parent; - if (parent_1.kind === 152 /* TypeQuery */) { + if (parent_1.kind === 154 /* TypeQuery */) { return false; } // Do not recursively call isTypeNode on the parent. In the example: @@ -5384,38 +5471,38 @@ var ts; // // Calling isTypeNode would consider the qualified name A.B a type node. Only C or // A.B.C is a type node. - if (149 /* FirstTypeNode */ <= parent_1.kind && parent_1.kind <= 158 /* LastTypeNode */) { + if (151 /* FirstTypeNode */ <= parent_1.kind && parent_1.kind <= 160 /* LastTypeNode */) { return true; } switch (parent_1.kind) { - case 186 /* ExpressionWithTypeArguments */: + case 188 /* ExpressionWithTypeArguments */: return !isExpressionWithTypeArgumentsInClassExtendsClause(parent_1); - case 135 /* TypeParameter */: + case 137 /* TypeParameter */: return node === parent_1.constraint; - case 139 /* PropertyDeclaration */: - case 138 /* PropertySignature */: - case 136 /* Parameter */: - case 209 /* VariableDeclaration */: + case 141 /* PropertyDeclaration */: + case 140 /* PropertySignature */: + case 138 /* Parameter */: + case 211 /* VariableDeclaration */: return node === parent_1.type; - case 211 /* FunctionDeclaration */: - case 171 /* FunctionExpression */: - case 172 /* ArrowFunction */: - case 142 /* Constructor */: - case 141 /* MethodDeclaration */: - case 140 /* MethodSignature */: - case 143 /* GetAccessor */: - case 144 /* SetAccessor */: + case 213 /* FunctionDeclaration */: + case 173 /* FunctionExpression */: + case 174 /* ArrowFunction */: + case 144 /* Constructor */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: return node === parent_1.type; - case 145 /* CallSignature */: - case 146 /* ConstructSignature */: - case 147 /* IndexSignature */: + case 147 /* CallSignature */: + case 148 /* ConstructSignature */: + case 149 /* IndexSignature */: return node === parent_1.type; - case 169 /* TypeAssertionExpression */: + case 171 /* TypeAssertionExpression */: return node === parent_1.type; - case 166 /* CallExpression */: - case 167 /* NewExpression */: + case 168 /* CallExpression */: + case 169 /* NewExpression */: return parent_1.typeArguments && ts.indexOf(parent_1.typeArguments, node) >= 0; - case 168 /* TaggedTemplateExpression */: + case 170 /* TaggedTemplateExpression */: // TODO (drosen): TaggedTemplateExpressions may eventually support type arguments. return false; } @@ -5429,23 +5516,23 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 202 /* ReturnStatement */: + case 204 /* ReturnStatement */: return visitor(node); - case 218 /* CaseBlock */: - case 190 /* Block */: - case 194 /* IfStatement */: - case 195 /* DoStatement */: - case 196 /* WhileStatement */: - case 197 /* ForStatement */: - case 198 /* ForInStatement */: - case 199 /* ForOfStatement */: - case 203 /* WithStatement */: - case 204 /* SwitchStatement */: - case 239 /* CaseClause */: - case 240 /* DefaultClause */: - case 205 /* LabeledStatement */: - case 207 /* TryStatement */: - case 242 /* CatchClause */: + case 220 /* CaseBlock */: + case 192 /* Block */: + case 196 /* IfStatement */: + case 197 /* DoStatement */: + case 198 /* WhileStatement */: + case 199 /* ForStatement */: + case 200 /* ForInStatement */: + case 201 /* ForOfStatement */: + case 205 /* WithStatement */: + case 206 /* SwitchStatement */: + case 241 /* CaseClause */: + case 242 /* DefaultClause */: + case 207 /* LabeledStatement */: + case 209 /* TryStatement */: + case 244 /* CatchClause */: return ts.forEachChild(node, traverse); } } @@ -5455,18 +5542,18 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 182 /* YieldExpression */: + case 184 /* YieldExpression */: visitor(node); var operand = node.expression; if (operand) { traverse(operand); } - case 215 /* EnumDeclaration */: - case 213 /* InterfaceDeclaration */: - case 216 /* ModuleDeclaration */: - case 214 /* TypeAliasDeclaration */: - case 212 /* ClassDeclaration */: - case 184 /* ClassExpression */: + case 217 /* EnumDeclaration */: + case 215 /* InterfaceDeclaration */: + case 218 /* ModuleDeclaration */: + case 216 /* TypeAliasDeclaration */: + case 214 /* ClassDeclaration */: + case 186 /* ClassExpression */: // These are not allowed inside a generator now, but eventually they may be allowed // as local types. Regardless, any yield statements contained within them should be // skipped in this traversal. @@ -5474,7 +5561,7 @@ var ts; default: if (isFunctionLike(node)) { var name_5 = node.name; - if (name_5 && name_5.kind === 134 /* ComputedPropertyName */) { + if (name_5 && name_5.kind === 136 /* ComputedPropertyName */) { // Note that we will not include methods/accessors of a class because they would require // first descending into the class. This is by design. traverse(name_5.expression); @@ -5493,14 +5580,14 @@ var ts; function isVariableLike(node) { if (node) { switch (node.kind) { - case 161 /* BindingElement */: - case 245 /* EnumMember */: - case 136 /* Parameter */: - case 243 /* PropertyAssignment */: - case 139 /* PropertyDeclaration */: - case 138 /* PropertySignature */: - case 244 /* ShorthandPropertyAssignment */: - case 209 /* VariableDeclaration */: + case 163 /* BindingElement */: + case 247 /* EnumMember */: + case 138 /* Parameter */: + case 245 /* PropertyAssignment */: + case 141 /* PropertyDeclaration */: + case 140 /* PropertySignature */: + case 246 /* ShorthandPropertyAssignment */: + case 211 /* VariableDeclaration */: return true; } } @@ -5508,29 +5595,29 @@ var ts; } ts.isVariableLike = isVariableLike; function isAccessor(node) { - return node && (node.kind === 143 /* GetAccessor */ || node.kind === 144 /* SetAccessor */); + return node && (node.kind === 145 /* GetAccessor */ || node.kind === 146 /* SetAccessor */); } ts.isAccessor = isAccessor; function isClassLike(node) { - return node && (node.kind === 212 /* ClassDeclaration */ || node.kind === 184 /* ClassExpression */); + return node && (node.kind === 214 /* ClassDeclaration */ || node.kind === 186 /* ClassExpression */); } ts.isClassLike = isClassLike; function isFunctionLike(node) { if (node) { switch (node.kind) { - case 142 /* Constructor */: - case 171 /* FunctionExpression */: - case 211 /* FunctionDeclaration */: - case 172 /* ArrowFunction */: - case 141 /* MethodDeclaration */: - case 140 /* MethodSignature */: - case 143 /* GetAccessor */: - case 144 /* SetAccessor */: - case 145 /* CallSignature */: - case 146 /* ConstructSignature */: - case 147 /* IndexSignature */: - case 150 /* FunctionType */: - case 151 /* ConstructorType */: + case 144 /* Constructor */: + case 173 /* FunctionExpression */: + case 213 /* FunctionDeclaration */: + case 174 /* ArrowFunction */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: + case 147 /* CallSignature */: + case 148 /* ConstructSignature */: + case 149 /* IndexSignature */: + case 152 /* FunctionType */: + case 153 /* ConstructorType */: return true; } } @@ -5539,24 +5626,24 @@ var ts; ts.isFunctionLike = isFunctionLike; function introducesArgumentsExoticObject(node) { switch (node.kind) { - case 141 /* MethodDeclaration */: - case 140 /* MethodSignature */: - case 142 /* Constructor */: - case 143 /* GetAccessor */: - case 144 /* SetAccessor */: - case 211 /* FunctionDeclaration */: - case 171 /* FunctionExpression */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: + case 144 /* Constructor */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: + case 213 /* FunctionDeclaration */: + case 173 /* FunctionExpression */: return true; } return false; } ts.introducesArgumentsExoticObject = introducesArgumentsExoticObject; function isFunctionBlock(node) { - return node && node.kind === 190 /* Block */ && isFunctionLike(node.parent); + return node && node.kind === 192 /* Block */ && isFunctionLike(node.parent); } ts.isFunctionBlock = isFunctionBlock; function isObjectLiteralMethod(node) { - return node && node.kind === 141 /* MethodDeclaration */ && node.parent.kind === 163 /* ObjectLiteralExpression */; + return node && node.kind === 143 /* MethodDeclaration */ && node.parent.kind === 165 /* ObjectLiteralExpression */; } ts.isObjectLiteralMethod = isObjectLiteralMethod; function getContainingFunction(node) { @@ -5584,7 +5671,7 @@ var ts; return undefined; } switch (node.kind) { - case 134 /* ComputedPropertyName */: + case 136 /* ComputedPropertyName */: // If the grandparent node is an object literal (as opposed to a class), // then the computed property is not a 'this' container. // A computed property name in a class needs to be a this container @@ -5599,9 +5686,9 @@ var ts; // the *body* of the container. node = node.parent; break; - case 137 /* Decorator */: + case 139 /* Decorator */: // Decorators are always applied outside of the body of a class or method. - if (node.parent.kind === 136 /* Parameter */ && isClassElement(node.parent.parent)) { + if (node.parent.kind === 138 /* Parameter */ && isClassElement(node.parent.parent)) { // If the decorator's parent is a Parameter, we resolve the this container from // the grandparent class declaration. node = node.parent.parent; @@ -5612,23 +5699,26 @@ var ts; node = node.parent; } break; - case 172 /* ArrowFunction */: + case 174 /* ArrowFunction */: if (!includeArrowFunctions) { continue; } // Fall through - case 211 /* FunctionDeclaration */: - case 171 /* FunctionExpression */: - case 216 /* ModuleDeclaration */: - case 139 /* PropertyDeclaration */: - case 138 /* PropertySignature */: - case 141 /* MethodDeclaration */: - case 140 /* MethodSignature */: - case 142 /* Constructor */: - case 143 /* GetAccessor */: - case 144 /* SetAccessor */: - case 215 /* EnumDeclaration */: - case 246 /* SourceFile */: + case 213 /* FunctionDeclaration */: + case 173 /* FunctionExpression */: + case 218 /* ModuleDeclaration */: + case 141 /* PropertyDeclaration */: + case 140 /* PropertySignature */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: + case 144 /* Constructor */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: + case 147 /* CallSignature */: + case 148 /* ConstructSignature */: + case 149 /* IndexSignature */: + case 217 /* EnumDeclaration */: + case 248 /* SourceFile */: return node; } } @@ -5640,7 +5730,7 @@ var ts; if (!node) return node; switch (node.kind) { - case 134 /* ComputedPropertyName */: + case 136 /* ComputedPropertyName */: // If the grandparent node is an object literal (as opposed to a class), // then the computed property is not a 'super' container. // A computed property name in a class needs to be a super container @@ -5655,9 +5745,9 @@ var ts; // the *body* of the container. node = node.parent; break; - case 137 /* Decorator */: + case 139 /* Decorator */: // Decorators are always applied outside of the body of a class or method. - if (node.parent.kind === 136 /* Parameter */ && isClassElement(node.parent.parent)) { + if (node.parent.kind === 138 /* Parameter */ && isClassElement(node.parent.parent)) { // If the decorator's parent is a Parameter, we resolve the this container from // the grandparent class declaration. node = node.parent.parent; @@ -5668,19 +5758,19 @@ var ts; node = node.parent; } break; - case 211 /* FunctionDeclaration */: - case 171 /* FunctionExpression */: - case 172 /* ArrowFunction */: + case 213 /* FunctionDeclaration */: + case 173 /* FunctionExpression */: + case 174 /* ArrowFunction */: if (!includeFunctions) { continue; } - case 139 /* PropertyDeclaration */: - case 138 /* PropertySignature */: - case 141 /* MethodDeclaration */: - case 140 /* MethodSignature */: - case 142 /* Constructor */: - case 143 /* GetAccessor */: - case 144 /* SetAccessor */: + case 141 /* PropertyDeclaration */: + case 140 /* PropertySignature */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: + case 144 /* Constructor */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: return node; } } @@ -5689,12 +5779,12 @@ var ts; function getEntityNameFromTypeNode(node) { if (node) { switch (node.kind) { - case 149 /* TypeReference */: + case 151 /* TypeReference */: return node.typeName; - case 186 /* ExpressionWithTypeArguments */: + case 188 /* ExpressionWithTypeArguments */: return node.expression; - case 67 /* Identifier */: - case 133 /* QualifiedName */: + case 69 /* Identifier */: + case 135 /* QualifiedName */: return node; } } @@ -5702,7 +5792,7 @@ var ts; } ts.getEntityNameFromTypeNode = getEntityNameFromTypeNode; function getInvokedExpression(node) { - if (node.kind === 168 /* TaggedTemplateExpression */) { + if (node.kind === 170 /* TaggedTemplateExpression */) { return node.tag; } // Will either be a CallExpression, NewExpression, or Decorator. @@ -5711,44 +5801,44 @@ var ts; ts.getInvokedExpression = getInvokedExpression; function nodeCanBeDecorated(node) { switch (node.kind) { - case 212 /* ClassDeclaration */: + case 214 /* ClassDeclaration */: // classes are valid targets return true; - case 139 /* PropertyDeclaration */: + case 141 /* PropertyDeclaration */: // property declarations are valid if their parent is a class declaration. - return node.parent.kind === 212 /* ClassDeclaration */; - case 136 /* Parameter */: + return node.parent.kind === 214 /* ClassDeclaration */; + case 138 /* Parameter */: // if the parameter's parent has a body and its grandparent is a class declaration, this is a valid target; - return node.parent.body && node.parent.parent.kind === 212 /* ClassDeclaration */; - case 143 /* GetAccessor */: - case 144 /* SetAccessor */: - case 141 /* MethodDeclaration */: + return node.parent.body && node.parent.parent.kind === 214 /* ClassDeclaration */; + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: + case 143 /* MethodDeclaration */: // if this method has a body and its parent is a class declaration, this is a valid target. - return node.body && node.parent.kind === 212 /* ClassDeclaration */; + return node.body && node.parent.kind === 214 /* ClassDeclaration */; } return false; } ts.nodeCanBeDecorated = nodeCanBeDecorated; function nodeIsDecorated(node) { switch (node.kind) { - case 212 /* ClassDeclaration */: + case 214 /* ClassDeclaration */: if (node.decorators) { return true; } return false; - case 139 /* PropertyDeclaration */: - case 136 /* Parameter */: + case 141 /* PropertyDeclaration */: + case 138 /* Parameter */: if (node.decorators) { return true; } return false; - case 143 /* GetAccessor */: + case 145 /* GetAccessor */: if (node.body && node.decorators) { return true; } return false; - case 141 /* MethodDeclaration */: - case 144 /* SetAccessor */: + case 143 /* MethodDeclaration */: + case 146 /* SetAccessor */: if (node.body && node.decorators) { return true; } @@ -5759,10 +5849,10 @@ var ts; ts.nodeIsDecorated = nodeIsDecorated; function childIsDecorated(node) { switch (node.kind) { - case 212 /* ClassDeclaration */: + case 214 /* ClassDeclaration */: return ts.forEach(node.members, nodeOrChildIsDecorated); - case 141 /* MethodDeclaration */: - case 144 /* SetAccessor */: + case 143 /* MethodDeclaration */: + case 146 /* SetAccessor */: return ts.forEach(node.parameters, nodeIsDecorated); } return false; @@ -5772,96 +5862,106 @@ var ts; return nodeIsDecorated(node) || childIsDecorated(node); } ts.nodeOrChildIsDecorated = nodeOrChildIsDecorated; + function isPropertyAccessExpression(node) { + return node.kind === 166 /* PropertyAccessExpression */; + } + ts.isPropertyAccessExpression = isPropertyAccessExpression; + function isElementAccessExpression(node) { + return node.kind === 167 /* ElementAccessExpression */; + } + ts.isElementAccessExpression = isElementAccessExpression; function isExpression(node) { switch (node.kind) { - case 95 /* ThisKeyword */: - case 93 /* SuperKeyword */: - case 91 /* NullKeyword */: - case 97 /* TrueKeyword */: - case 82 /* FalseKeyword */: + case 95 /* SuperKeyword */: + case 93 /* NullKeyword */: + case 99 /* TrueKeyword */: + case 84 /* FalseKeyword */: case 10 /* RegularExpressionLiteral */: - case 162 /* ArrayLiteralExpression */: - case 163 /* ObjectLiteralExpression */: - case 164 /* PropertyAccessExpression */: - case 165 /* ElementAccessExpression */: - case 166 /* CallExpression */: - case 167 /* NewExpression */: - case 168 /* TaggedTemplateExpression */: - case 187 /* AsExpression */: - case 169 /* TypeAssertionExpression */: - case 170 /* ParenthesizedExpression */: - case 171 /* FunctionExpression */: - case 184 /* ClassExpression */: - case 172 /* ArrowFunction */: - case 175 /* VoidExpression */: - case 173 /* DeleteExpression */: - case 174 /* TypeOfExpression */: - case 177 /* PrefixUnaryExpression */: - case 178 /* PostfixUnaryExpression */: - case 179 /* BinaryExpression */: - case 180 /* ConditionalExpression */: - case 183 /* SpreadElementExpression */: - case 181 /* TemplateExpression */: + case 164 /* ArrayLiteralExpression */: + case 165 /* ObjectLiteralExpression */: + case 166 /* PropertyAccessExpression */: + case 167 /* ElementAccessExpression */: + case 168 /* CallExpression */: + case 169 /* NewExpression */: + case 170 /* TaggedTemplateExpression */: + case 189 /* AsExpression */: + case 171 /* TypeAssertionExpression */: + case 172 /* ParenthesizedExpression */: + case 173 /* FunctionExpression */: + case 186 /* ClassExpression */: + case 174 /* ArrowFunction */: + case 177 /* VoidExpression */: + case 175 /* DeleteExpression */: + case 176 /* TypeOfExpression */: + case 179 /* PrefixUnaryExpression */: + case 180 /* PostfixUnaryExpression */: + case 181 /* BinaryExpression */: + case 182 /* ConditionalExpression */: + case 185 /* SpreadElementExpression */: + case 183 /* TemplateExpression */: case 11 /* NoSubstitutionTemplateLiteral */: - case 185 /* OmittedExpression */: - case 231 /* JsxElement */: - case 232 /* JsxSelfClosingElement */: - case 182 /* YieldExpression */: + case 187 /* OmittedExpression */: + case 233 /* JsxElement */: + case 234 /* JsxSelfClosingElement */: + case 184 /* YieldExpression */: + case 178 /* AwaitExpression */: return true; - case 133 /* QualifiedName */: - while (node.parent.kind === 133 /* QualifiedName */) { + case 135 /* QualifiedName */: + while (node.parent.kind === 135 /* QualifiedName */) { node = node.parent; } - return node.parent.kind === 152 /* TypeQuery */; - case 67 /* Identifier */: - if (node.parent.kind === 152 /* TypeQuery */) { + return node.parent.kind === 154 /* TypeQuery */; + case 69 /* Identifier */: + if (node.parent.kind === 154 /* TypeQuery */) { return true; } // fall through case 8 /* NumericLiteral */: case 9 /* StringLiteral */: + case 97 /* ThisKeyword */: var parent_2 = node.parent; switch (parent_2.kind) { - case 209 /* VariableDeclaration */: - case 136 /* Parameter */: - case 139 /* PropertyDeclaration */: - case 138 /* PropertySignature */: - case 245 /* EnumMember */: - case 243 /* PropertyAssignment */: - case 161 /* BindingElement */: + case 211 /* VariableDeclaration */: + case 138 /* Parameter */: + case 141 /* PropertyDeclaration */: + case 140 /* PropertySignature */: + case 247 /* EnumMember */: + case 245 /* PropertyAssignment */: + case 163 /* BindingElement */: return parent_2.initializer === node; - case 193 /* ExpressionStatement */: - case 194 /* IfStatement */: - case 195 /* DoStatement */: - case 196 /* WhileStatement */: - case 202 /* ReturnStatement */: - case 203 /* WithStatement */: - case 204 /* SwitchStatement */: - case 239 /* CaseClause */: - case 206 /* ThrowStatement */: - case 204 /* SwitchStatement */: + case 195 /* ExpressionStatement */: + case 196 /* IfStatement */: + case 197 /* DoStatement */: + case 198 /* WhileStatement */: + case 204 /* ReturnStatement */: + case 205 /* WithStatement */: + case 206 /* SwitchStatement */: + case 241 /* CaseClause */: + case 208 /* ThrowStatement */: + case 206 /* SwitchStatement */: return parent_2.expression === node; - case 197 /* ForStatement */: + case 199 /* ForStatement */: var forStatement = parent_2; - return (forStatement.initializer === node && forStatement.initializer.kind !== 210 /* VariableDeclarationList */) || + return (forStatement.initializer === node && forStatement.initializer.kind !== 212 /* VariableDeclarationList */) || forStatement.condition === node || forStatement.incrementor === node; - case 198 /* ForInStatement */: - case 199 /* ForOfStatement */: + case 200 /* ForInStatement */: + case 201 /* ForOfStatement */: var forInStatement = parent_2; - return (forInStatement.initializer === node && forInStatement.initializer.kind !== 210 /* VariableDeclarationList */) || + return (forInStatement.initializer === node && forInStatement.initializer.kind !== 212 /* VariableDeclarationList */) || forInStatement.expression === node; - case 169 /* TypeAssertionExpression */: - case 187 /* AsExpression */: + case 171 /* TypeAssertionExpression */: + case 189 /* AsExpression */: return node === parent_2.expression; - case 188 /* TemplateSpan */: + case 190 /* TemplateSpan */: return node === parent_2.expression; - case 134 /* ComputedPropertyName */: + case 136 /* ComputedPropertyName */: return node === parent_2.expression; - case 137 /* Decorator */: - case 238 /* JsxExpression */: + case 139 /* Decorator */: + case 240 /* JsxExpression */: + case 239 /* JsxSpreadAttribute */: return true; - case 186 /* ExpressionWithTypeArguments */: + case 188 /* ExpressionWithTypeArguments */: return parent_2.expression === node && isExpressionWithTypeArgumentsInClassExtendsClause(parent_2); default: if (isExpression(parent_2)) { @@ -5872,6 +5972,12 @@ var ts; return false; } ts.isExpression = isExpression; + function isExternalModuleNameRelative(moduleName) { + // TypeScript 1.0 spec (April 2014): 11.2.1 + // An external module name is "relative" if the first term is "." or "..". + return moduleName.substr(0, 2) === "./" || moduleName.substr(0, 3) === "../" || moduleName.substr(0, 2) === ".\\" || moduleName.substr(0, 3) === "..\\"; + } + ts.isExternalModuleNameRelative = isExternalModuleNameRelative; function isInstantiatedModule(node, preserveConstEnums) { var moduleState = ts.getModuleInstanceState(node); return moduleState === 1 /* Instantiated */ || @@ -5879,7 +5985,7 @@ var ts; } ts.isInstantiatedModule = isInstantiatedModule; function isExternalModuleImportEqualsDeclaration(node) { - return node.kind === 219 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 230 /* ExternalModuleReference */; + return node.kind === 221 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 232 /* ExternalModuleReference */; } ts.isExternalModuleImportEqualsDeclaration = isExternalModuleImportEqualsDeclaration; function getExternalModuleImportEqualsDeclarationExpression(node) { @@ -5888,20 +5994,70 @@ var ts; } ts.getExternalModuleImportEqualsDeclarationExpression = getExternalModuleImportEqualsDeclarationExpression; function isInternalModuleImportEqualsDeclaration(node) { - return node.kind === 219 /* ImportEqualsDeclaration */ && node.moduleReference.kind !== 230 /* ExternalModuleReference */; + return node.kind === 221 /* ImportEqualsDeclaration */ && node.moduleReference.kind !== 232 /* ExternalModuleReference */; } ts.isInternalModuleImportEqualsDeclaration = isInternalModuleImportEqualsDeclaration; + function isSourceFileJavaScript(file) { + return isInJavaScriptFile(file); + } + ts.isSourceFileJavaScript = isSourceFileJavaScript; + function isInJavaScriptFile(node) { + return node && !!(node.parserContextFlags & 32 /* JavaScriptFile */); + } + ts.isInJavaScriptFile = isInJavaScriptFile; + /** + * Returns true if the node is a CallExpression to the identifier 'require' with + * exactly one argument. + * This function does not test if the node is in a JavaScript file or not. + */ + function isRequireCall(expression) { + // of the form 'require("name")' + return expression.kind === 168 /* CallExpression */ && + expression.expression.kind === 69 /* Identifier */ && + expression.expression.text === "require" && + expression.arguments.length === 1; + } + ts.isRequireCall = isRequireCall; + /** + * Returns true if the node is an assignment to a property on the identifier 'exports'. + * This function does not test if the node is in a JavaScript file or not. + */ + function isExportsPropertyAssignment(expression) { + // of the form 'exports.name = expr' where 'name' and 'expr' are arbitrary + return isInJavaScriptFile(expression) && + (expression.kind === 181 /* BinaryExpression */) && + (expression.operatorToken.kind === 56 /* EqualsToken */) && + (expression.left.kind === 166 /* PropertyAccessExpression */) && + (expression.left.expression.kind === 69 /* Identifier */) && + ((expression.left.expression).text === "exports"); + } + ts.isExportsPropertyAssignment = isExportsPropertyAssignment; + /** + * Returns true if the node is an assignment to the property access expression 'module.exports'. + * This function does not test if the node is in a JavaScript file or not. + */ + function isModuleExportsAssignment(expression) { + // of the form 'module.exports = expr' where 'expr' is arbitrary + return isInJavaScriptFile(expression) && + (expression.kind === 181 /* BinaryExpression */) && + (expression.operatorToken.kind === 56 /* EqualsToken */) && + (expression.left.kind === 166 /* PropertyAccessExpression */) && + (expression.left.expression.kind === 69 /* Identifier */) && + ((expression.left.expression).text === "module") && + (expression.left.name.text === "exports"); + } + ts.isModuleExportsAssignment = isModuleExportsAssignment; function getExternalModuleName(node) { - if (node.kind === 220 /* ImportDeclaration */) { + if (node.kind === 222 /* ImportDeclaration */) { return node.moduleSpecifier; } - if (node.kind === 219 /* ImportEqualsDeclaration */) { + if (node.kind === 221 /* ImportEqualsDeclaration */) { var reference = node.moduleReference; - if (reference.kind === 230 /* ExternalModuleReference */) { + if (reference.kind === 232 /* ExternalModuleReference */) { return reference.expression; } } - if (node.kind === 226 /* ExportDeclaration */) { + if (node.kind === 228 /* ExportDeclaration */) { return node.moduleSpecifier; } } @@ -5909,13 +6065,13 @@ var ts; function hasQuestionToken(node) { if (node) { switch (node.kind) { - case 136 /* Parameter */: - case 141 /* MethodDeclaration */: - case 140 /* MethodSignature */: - case 244 /* ShorthandPropertyAssignment */: - case 243 /* PropertyAssignment */: - case 139 /* PropertyDeclaration */: - case 138 /* PropertySignature */: + case 138 /* Parameter */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: + case 246 /* ShorthandPropertyAssignment */: + case 245 /* PropertyAssignment */: + case 141 /* PropertyDeclaration */: + case 140 /* PropertySignature */: return node.questionToken !== undefined; } } @@ -5923,9 +6079,9 @@ var ts; } ts.hasQuestionToken = hasQuestionToken; function isJSDocConstructSignature(node) { - return node.kind === 259 /* JSDocFunctionType */ && + return node.kind === 261 /* JSDocFunctionType */ && node.parameters.length > 0 && - node.parameters[0].type.kind === 261 /* JSDocConstructorType */; + node.parameters[0].type.kind === 263 /* JSDocConstructorType */; } ts.isJSDocConstructSignature = isJSDocConstructSignature; function getJSDocTag(node, kind) { @@ -5939,26 +6095,26 @@ var ts; } } function getJSDocTypeTag(node) { - return getJSDocTag(node, 267 /* JSDocTypeTag */); + return getJSDocTag(node, 269 /* JSDocTypeTag */); } ts.getJSDocTypeTag = getJSDocTypeTag; function getJSDocReturnTag(node) { - return getJSDocTag(node, 266 /* JSDocReturnTag */); + return getJSDocTag(node, 268 /* JSDocReturnTag */); } ts.getJSDocReturnTag = getJSDocReturnTag; function getJSDocTemplateTag(node) { - return getJSDocTag(node, 268 /* JSDocTemplateTag */); + return getJSDocTag(node, 270 /* JSDocTemplateTag */); } ts.getJSDocTemplateTag = getJSDocTemplateTag; function getCorrespondingJSDocParameterTag(parameter) { - if (parameter.name && parameter.name.kind === 67 /* Identifier */) { + if (parameter.name && parameter.name.kind === 69 /* Identifier */) { // If it's a parameter, see if the parent has a jsdoc comment with an @param // annotation. var parameterName = parameter.name.text; var docComment = parameter.parent.jsDocComment; if (docComment) { return ts.forEach(docComment.tags, function (t) { - if (t.kind === 265 /* JSDocParameterTag */) { + if (t.kind === 267 /* JSDocParameterTag */) { var parameterTag = t; var name_6 = parameterTag.preParameterName || parameterTag.postParameterName; if (name_6.text === parameterName) { @@ -5977,12 +6133,12 @@ var ts; function isRestParameter(node) { if (node) { if (node.parserContextFlags & 32 /* JavaScriptFile */) { - if (node.type && node.type.kind === 260 /* JSDocVariadicType */) { + if (node.type && node.type.kind === 262 /* JSDocVariadicType */) { return true; } var paramTag = getCorrespondingJSDocParameterTag(node); if (paramTag && paramTag.typeExpression) { - return paramTag.typeExpression.type.kind === 260 /* JSDocVariadicType */; + return paramTag.typeExpression.type.kind === 262 /* JSDocVariadicType */; } } return node.dotDotDotToken !== undefined; @@ -6003,7 +6159,7 @@ var ts; } ts.isTemplateLiteralKind = isTemplateLiteralKind; function isBindingPattern(node) { - return !!node && (node.kind === 160 /* ArrayBindingPattern */ || node.kind === 159 /* ObjectBindingPattern */); + return !!node && (node.kind === 162 /* ArrayBindingPattern */ || node.kind === 161 /* ObjectBindingPattern */); } ts.isBindingPattern = isBindingPattern; function isInAmbientContext(node) { @@ -6018,34 +6174,34 @@ var ts; ts.isInAmbientContext = isInAmbientContext; function isDeclaration(node) { switch (node.kind) { - case 172 /* ArrowFunction */: - case 161 /* BindingElement */: - case 212 /* ClassDeclaration */: - case 184 /* ClassExpression */: - case 142 /* Constructor */: - case 215 /* EnumDeclaration */: - case 245 /* EnumMember */: - case 228 /* ExportSpecifier */: - case 211 /* FunctionDeclaration */: - case 171 /* FunctionExpression */: - case 143 /* GetAccessor */: - case 221 /* ImportClause */: - case 219 /* ImportEqualsDeclaration */: - case 224 /* ImportSpecifier */: - case 213 /* InterfaceDeclaration */: - case 141 /* MethodDeclaration */: - case 140 /* MethodSignature */: - case 216 /* ModuleDeclaration */: - case 222 /* NamespaceImport */: - case 136 /* Parameter */: - case 243 /* PropertyAssignment */: - case 139 /* PropertyDeclaration */: - case 138 /* PropertySignature */: - case 144 /* SetAccessor */: - case 244 /* ShorthandPropertyAssignment */: - case 214 /* TypeAliasDeclaration */: - case 135 /* TypeParameter */: - case 209 /* VariableDeclaration */: + case 174 /* ArrowFunction */: + case 163 /* BindingElement */: + case 214 /* ClassDeclaration */: + case 186 /* ClassExpression */: + case 144 /* Constructor */: + case 217 /* EnumDeclaration */: + case 247 /* EnumMember */: + case 230 /* ExportSpecifier */: + case 213 /* FunctionDeclaration */: + case 173 /* FunctionExpression */: + case 145 /* GetAccessor */: + case 223 /* ImportClause */: + case 221 /* ImportEqualsDeclaration */: + case 226 /* ImportSpecifier */: + case 215 /* InterfaceDeclaration */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: + case 218 /* ModuleDeclaration */: + case 224 /* NamespaceImport */: + case 138 /* Parameter */: + case 245 /* PropertyAssignment */: + case 141 /* PropertyDeclaration */: + case 140 /* PropertySignature */: + case 146 /* SetAccessor */: + case 246 /* ShorthandPropertyAssignment */: + case 216 /* TypeAliasDeclaration */: + case 137 /* TypeParameter */: + case 211 /* VariableDeclaration */: return true; } return false; @@ -6053,25 +6209,25 @@ var ts; ts.isDeclaration = isDeclaration; function isStatement(n) { switch (n.kind) { - case 201 /* BreakStatement */: - case 200 /* ContinueStatement */: - case 208 /* DebuggerStatement */: - case 195 /* DoStatement */: - case 193 /* ExpressionStatement */: - case 192 /* EmptyStatement */: - case 198 /* ForInStatement */: - case 199 /* ForOfStatement */: - case 197 /* ForStatement */: - case 194 /* IfStatement */: - case 205 /* LabeledStatement */: - case 202 /* ReturnStatement */: - case 204 /* SwitchStatement */: - case 96 /* ThrowKeyword */: - case 207 /* TryStatement */: - case 191 /* VariableStatement */: - case 196 /* WhileStatement */: - case 203 /* WithStatement */: - case 225 /* ExportAssignment */: + case 203 /* BreakStatement */: + case 202 /* ContinueStatement */: + case 210 /* DebuggerStatement */: + case 197 /* DoStatement */: + case 195 /* ExpressionStatement */: + case 194 /* EmptyStatement */: + case 200 /* ForInStatement */: + case 201 /* ForOfStatement */: + case 199 /* ForStatement */: + case 196 /* IfStatement */: + case 207 /* LabeledStatement */: + case 204 /* ReturnStatement */: + case 206 /* SwitchStatement */: + case 98 /* ThrowKeyword */: + case 209 /* TryStatement */: + case 193 /* VariableStatement */: + case 198 /* WhileStatement */: + case 205 /* WithStatement */: + case 227 /* ExportAssignment */: return true; default: return false; @@ -6080,13 +6236,13 @@ var ts; ts.isStatement = isStatement; function isClassElement(n) { switch (n.kind) { - case 142 /* Constructor */: - case 139 /* PropertyDeclaration */: - case 141 /* MethodDeclaration */: - case 143 /* GetAccessor */: - case 144 /* SetAccessor */: - case 140 /* MethodSignature */: - case 147 /* IndexSignature */: + case 144 /* Constructor */: + case 141 /* PropertyDeclaration */: + case 143 /* MethodDeclaration */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: + case 142 /* MethodSignature */: + case 149 /* IndexSignature */: return true; default: return false; @@ -6095,11 +6251,11 @@ var ts; ts.isClassElement = isClassElement; // True if the given identifier, string literal, or number literal is the name of a declaration node function isDeclarationName(name) { - if (name.kind !== 67 /* Identifier */ && name.kind !== 9 /* StringLiteral */ && name.kind !== 8 /* NumericLiteral */) { + if (name.kind !== 69 /* Identifier */ && name.kind !== 9 /* StringLiteral */ && name.kind !== 8 /* NumericLiteral */) { return false; } var parent = name.parent; - if (parent.kind === 224 /* ImportSpecifier */ || parent.kind === 228 /* ExportSpecifier */) { + if (parent.kind === 226 /* ImportSpecifier */ || parent.kind === 230 /* ExportSpecifier */) { if (parent.propertyName) { return true; } @@ -6114,31 +6270,31 @@ var ts; function isIdentifierName(node) { var parent = node.parent; switch (parent.kind) { - case 139 /* PropertyDeclaration */: - case 138 /* PropertySignature */: - case 141 /* MethodDeclaration */: - case 140 /* MethodSignature */: - case 143 /* GetAccessor */: - case 144 /* SetAccessor */: - case 245 /* EnumMember */: - case 243 /* PropertyAssignment */: - case 164 /* PropertyAccessExpression */: + case 141 /* PropertyDeclaration */: + case 140 /* PropertySignature */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: + case 247 /* EnumMember */: + case 245 /* PropertyAssignment */: + case 166 /* PropertyAccessExpression */: // Name in member declaration or property name in property access return parent.name === node; - case 133 /* QualifiedName */: + case 135 /* QualifiedName */: // Name on right hand side of dot in a type query if (parent.right === node) { - while (parent.kind === 133 /* QualifiedName */) { + while (parent.kind === 135 /* QualifiedName */) { parent = parent.parent; } - return parent.kind === 152 /* TypeQuery */; + return parent.kind === 154 /* TypeQuery */; } return false; - case 161 /* BindingElement */: - case 224 /* ImportSpecifier */: + case 163 /* BindingElement */: + case 226 /* ImportSpecifier */: // Property name in binding element or import specifier return parent.propertyName === node; - case 228 /* ExportSpecifier */: + case 230 /* ExportSpecifier */: // Any name in an export specifier return true; } @@ -6154,26 +6310,26 @@ var ts; // export = ... // export default ... function isAliasSymbolDeclaration(node) { - return node.kind === 219 /* ImportEqualsDeclaration */ || - node.kind === 221 /* ImportClause */ && !!node.name || - node.kind === 222 /* NamespaceImport */ || - node.kind === 224 /* ImportSpecifier */ || - node.kind === 228 /* ExportSpecifier */ || - node.kind === 225 /* ExportAssignment */ && node.expression.kind === 67 /* Identifier */; + return node.kind === 221 /* ImportEqualsDeclaration */ || + node.kind === 223 /* ImportClause */ && !!node.name || + node.kind === 224 /* NamespaceImport */ || + node.kind === 226 /* ImportSpecifier */ || + node.kind === 230 /* ExportSpecifier */ || + node.kind === 227 /* ExportAssignment */ && node.expression.kind === 69 /* Identifier */; } ts.isAliasSymbolDeclaration = isAliasSymbolDeclaration; function getClassExtendsHeritageClauseElement(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 81 /* ExtendsKeyword */); + var heritageClause = getHeritageClause(node.heritageClauses, 83 /* ExtendsKeyword */); return heritageClause && heritageClause.types.length > 0 ? heritageClause.types[0] : undefined; } ts.getClassExtendsHeritageClauseElement = getClassExtendsHeritageClauseElement; function getClassImplementsHeritageClauseElements(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 104 /* ImplementsKeyword */); + var heritageClause = getHeritageClause(node.heritageClauses, 106 /* ImplementsKeyword */); return heritageClause ? heritageClause.types : undefined; } ts.getClassImplementsHeritageClauseElements = getClassImplementsHeritageClauseElements; function getInterfaceBaseTypeNodes(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 81 /* ExtendsKeyword */); + var heritageClause = getHeritageClause(node.heritageClauses, 83 /* ExtendsKeyword */); return heritageClause ? heritageClause.types : undefined; } ts.getInterfaceBaseTypeNodes = getInterfaceBaseTypeNodes; @@ -6242,7 +6398,7 @@ var ts; } ts.getFileReferenceFromReferencePath = getFileReferenceFromReferencePath; function isKeyword(token) { - return 68 /* FirstKeyword */ <= token && token <= 132 /* LastKeyword */; + return 70 /* FirstKeyword */ <= token && token <= 134 /* LastKeyword */; } ts.isKeyword = isKeyword; function isTrivia(token) { @@ -6262,7 +6418,7 @@ var ts; */ function hasDynamicName(declaration) { return declaration.name && - declaration.name.kind === 134 /* ComputedPropertyName */ && + declaration.name.kind === 136 /* ComputedPropertyName */ && !isWellKnownSymbolSyntactically(declaration.name.expression); } ts.hasDynamicName = hasDynamicName; @@ -6272,14 +6428,14 @@ var ts; * where Symbol is literally the word "Symbol", and name is any identifierName */ function isWellKnownSymbolSyntactically(node) { - return node.kind === 164 /* PropertyAccessExpression */ && isESSymbolIdentifier(node.expression); + return isPropertyAccessExpression(node) && isESSymbolIdentifier(node.expression); } ts.isWellKnownSymbolSyntactically = isWellKnownSymbolSyntactically; function getPropertyNameForPropertyNameNode(name) { - if (name.kind === 67 /* Identifier */ || name.kind === 9 /* StringLiteral */ || name.kind === 8 /* NumericLiteral */) { + if (name.kind === 69 /* Identifier */ || name.kind === 9 /* StringLiteral */ || name.kind === 8 /* NumericLiteral */) { return name.text; } - if (name.kind === 134 /* ComputedPropertyName */) { + if (name.kind === 136 /* ComputedPropertyName */) { var nameExpression = name.expression; if (isWellKnownSymbolSyntactically(nameExpression)) { var rightHandSideName = nameExpression.name.text; @@ -6297,21 +6453,21 @@ var ts; * Includes the word "Symbol" with unicode escapes */ function isESSymbolIdentifier(node) { - return node.kind === 67 /* Identifier */ && node.text === "Symbol"; + return node.kind === 69 /* Identifier */ && node.text === "Symbol"; } ts.isESSymbolIdentifier = isESSymbolIdentifier; function isModifier(token) { switch (token) { - case 113 /* AbstractKeyword */: - case 116 /* AsyncKeyword */: - case 72 /* ConstKeyword */: - case 120 /* DeclareKeyword */: - case 75 /* DefaultKeyword */: - case 80 /* ExportKeyword */: - case 110 /* PublicKeyword */: - case 108 /* PrivateKeyword */: - case 109 /* ProtectedKeyword */: - case 111 /* StaticKeyword */: + case 115 /* AbstractKeyword */: + case 118 /* AsyncKeyword */: + case 74 /* ConstKeyword */: + case 122 /* DeclareKeyword */: + case 77 /* DefaultKeyword */: + case 82 /* ExportKeyword */: + case 112 /* PublicKeyword */: + case 110 /* PrivateKeyword */: + case 111 /* ProtectedKeyword */: + case 113 /* StaticKeyword */: return true; } return false; @@ -6319,28 +6475,28 @@ var ts; ts.isModifier = isModifier; function isParameterDeclaration(node) { var root = getRootDeclaration(node); - return root.kind === 136 /* Parameter */; + return root.kind === 138 /* Parameter */; } ts.isParameterDeclaration = isParameterDeclaration; function getRootDeclaration(node) { - while (node.kind === 161 /* BindingElement */) { + while (node.kind === 163 /* BindingElement */) { node = node.parent.parent; } return node; } ts.getRootDeclaration = getRootDeclaration; function nodeStartsNewLexicalEnvironment(n) { - return isFunctionLike(n) || n.kind === 216 /* ModuleDeclaration */ || n.kind === 246 /* SourceFile */; + return isFunctionLike(n) || n.kind === 218 /* ModuleDeclaration */ || n.kind === 248 /* SourceFile */; } ts.nodeStartsNewLexicalEnvironment = nodeStartsNewLexicalEnvironment; function cloneEntityName(node) { - if (node.kind === 67 /* Identifier */) { - var clone_1 = createSynthesizedNode(67 /* Identifier */); + if (node.kind === 69 /* Identifier */) { + var clone_1 = createSynthesizedNode(69 /* Identifier */); clone_1.text = node.text; return clone_1; } else { - var clone_2 = createSynthesizedNode(133 /* QualifiedName */); + var clone_2 = createSynthesizedNode(135 /* QualifiedName */); clone_2.left = cloneEntityName(node.left); clone_2.left.parent = clone_2; clone_2.right = cloneEntityName(node.right); @@ -6595,7 +6751,7 @@ var ts; ts.getLineOfLocalPosition = getLineOfLocalPosition; function getFirstConstructorWithBody(node) { return ts.forEach(node.members, function (member) { - if (member.kind === 142 /* Constructor */ && nodeIsPresent(member.body)) { + if (member.kind === 144 /* Constructor */ && nodeIsPresent(member.body)) { return member; } }); @@ -6624,10 +6780,10 @@ var ts; var setAccessor; if (hasDynamicName(accessor)) { firstAccessor = accessor; - if (accessor.kind === 143 /* GetAccessor */) { + if (accessor.kind === 145 /* GetAccessor */) { getAccessor = accessor; } - else if (accessor.kind === 144 /* SetAccessor */) { + else if (accessor.kind === 146 /* SetAccessor */) { setAccessor = accessor; } else { @@ -6636,7 +6792,7 @@ var ts; } else { ts.forEach(declarations, function (member) { - if ((member.kind === 143 /* GetAccessor */ || member.kind === 144 /* SetAccessor */) + if ((member.kind === 145 /* GetAccessor */ || member.kind === 146 /* SetAccessor */) && (member.flags & 128 /* Static */) === (accessor.flags & 128 /* Static */)) { var memberName = getPropertyNameForPropertyNameNode(member.name); var accessorName = getPropertyNameForPropertyNameNode(accessor.name); @@ -6647,10 +6803,10 @@ var ts; else if (!secondAccessor) { secondAccessor = member; } - if (member.kind === 143 /* GetAccessor */ && !getAccessor) { + if (member.kind === 145 /* GetAccessor */ && !getAccessor) { getAccessor = member; } - if (member.kind === 144 /* SetAccessor */ && !setAccessor) { + if (member.kind === 146 /* SetAccessor */ && !setAccessor) { setAccessor = member; } } @@ -6783,16 +6939,16 @@ var ts; ts.writeCommentRange = writeCommentRange; function modifierToFlag(token) { switch (token) { - case 111 /* StaticKeyword */: return 128 /* Static */; - case 110 /* PublicKeyword */: return 16 /* Public */; - case 109 /* ProtectedKeyword */: return 64 /* Protected */; - case 108 /* PrivateKeyword */: return 32 /* Private */; - case 113 /* AbstractKeyword */: return 256 /* Abstract */; - case 80 /* ExportKeyword */: return 1 /* Export */; - case 120 /* DeclareKeyword */: return 2 /* Ambient */; - case 72 /* ConstKeyword */: return 32768 /* Const */; - case 75 /* DefaultKeyword */: return 1024 /* Default */; - case 116 /* AsyncKeyword */: return 512 /* Async */; + case 113 /* StaticKeyword */: return 128 /* Static */; + case 112 /* PublicKeyword */: return 16 /* Public */; + case 111 /* ProtectedKeyword */: return 64 /* Protected */; + case 110 /* PrivateKeyword */: return 32 /* Private */; + case 115 /* AbstractKeyword */: return 256 /* Abstract */; + case 82 /* ExportKeyword */: return 1 /* Export */; + case 122 /* DeclareKeyword */: return 2 /* Ambient */; + case 74 /* ConstKeyword */: return 32768 /* Const */; + case 77 /* DefaultKeyword */: return 1024 /* Default */; + case 118 /* AsyncKeyword */: return 512 /* Async */; } return 0; } @@ -6800,29 +6956,29 @@ var ts; function isLeftHandSideExpression(expr) { if (expr) { switch (expr.kind) { - case 164 /* PropertyAccessExpression */: - case 165 /* ElementAccessExpression */: - case 167 /* NewExpression */: - case 166 /* CallExpression */: - case 231 /* JsxElement */: - case 232 /* JsxSelfClosingElement */: - case 168 /* TaggedTemplateExpression */: - case 162 /* ArrayLiteralExpression */: - case 170 /* ParenthesizedExpression */: - case 163 /* ObjectLiteralExpression */: - case 184 /* ClassExpression */: - case 171 /* FunctionExpression */: - case 67 /* Identifier */: + case 166 /* PropertyAccessExpression */: + case 167 /* ElementAccessExpression */: + case 169 /* NewExpression */: + case 168 /* CallExpression */: + case 233 /* JsxElement */: + case 234 /* JsxSelfClosingElement */: + case 170 /* TaggedTemplateExpression */: + case 164 /* ArrayLiteralExpression */: + case 172 /* ParenthesizedExpression */: + case 165 /* ObjectLiteralExpression */: + case 186 /* ClassExpression */: + case 173 /* FunctionExpression */: + case 69 /* Identifier */: case 10 /* RegularExpressionLiteral */: case 8 /* NumericLiteral */: case 9 /* StringLiteral */: case 11 /* NoSubstitutionTemplateLiteral */: - case 181 /* TemplateExpression */: - case 82 /* FalseKeyword */: - case 91 /* NullKeyword */: - case 95 /* ThisKeyword */: - case 97 /* TrueKeyword */: - case 93 /* SuperKeyword */: + case 183 /* TemplateExpression */: + case 84 /* FalseKeyword */: + case 93 /* NullKeyword */: + case 97 /* ThisKeyword */: + case 99 /* TrueKeyword */: + case 95 /* SuperKeyword */: return true; } } @@ -6830,12 +6986,12 @@ var ts; } ts.isLeftHandSideExpression = isLeftHandSideExpression; function isAssignmentOperator(token) { - return token >= 55 /* FirstAssignment */ && token <= 66 /* LastAssignment */; + return token >= 56 /* FirstAssignment */ && token <= 68 /* LastAssignment */; } ts.isAssignmentOperator = isAssignmentOperator; function isExpressionWithTypeArgumentsInClassExtendsClause(node) { - return node.kind === 186 /* ExpressionWithTypeArguments */ && - node.parent.token === 81 /* ExtendsKeyword */ && + return node.kind === 188 /* ExpressionWithTypeArguments */ && + node.parent.token === 83 /* ExtendsKeyword */ && isClassLike(node.parent.parent); } ts.isExpressionWithTypeArgumentsInClassExtendsClause = isExpressionWithTypeArgumentsInClassExtendsClause; @@ -6846,10 +7002,10 @@ var ts; } ts.isSupportedExpressionWithTypeArguments = isSupportedExpressionWithTypeArguments; function isSupportedExpressionWithTypeArgumentsRest(node) { - if (node.kind === 67 /* Identifier */) { + if (node.kind === 69 /* Identifier */) { return true; } - else if (node.kind === 164 /* PropertyAccessExpression */) { + else if (isPropertyAccessExpression(node)) { return isSupportedExpressionWithTypeArgumentsRest(node.expression); } else { @@ -6857,16 +7013,16 @@ var ts; } } function isRightSideOfQualifiedNameOrPropertyAccess(node) { - return (node.parent.kind === 133 /* QualifiedName */ && node.parent.right === node) || - (node.parent.kind === 164 /* PropertyAccessExpression */ && node.parent.name === node); + return (node.parent.kind === 135 /* QualifiedName */ && node.parent.right === node) || + (node.parent.kind === 166 /* PropertyAccessExpression */ && node.parent.name === node); } ts.isRightSideOfQualifiedNameOrPropertyAccess = isRightSideOfQualifiedNameOrPropertyAccess; function isEmptyObjectLiteralOrArrayLiteral(expression) { var kind = expression.kind; - if (kind === 163 /* ObjectLiteralExpression */) { + if (kind === 165 /* ObjectLiteralExpression */) { return expression.properties.length === 0; } - if (kind === 162 /* ArrayLiteralExpression */) { + if (kind === 164 /* ArrayLiteralExpression */) { return expression.elements.length === 0; } return false; @@ -6876,12 +7032,12 @@ var ts; return symbol && symbol.valueDeclaration && (symbol.valueDeclaration.flags & 1024 /* Default */) ? symbol.valueDeclaration.localSymbol : undefined; } ts.getLocalSymbolForExportDefault = getLocalSymbolForExportDefault; - function isJavaScript(fileName) { - return ts.fileExtensionIs(fileName, ".js"); + function hasJavaScriptFileExtension(fileName) { + return ts.fileExtensionIs(fileName, ".js") || ts.fileExtensionIs(fileName, ".jsx"); } - ts.isJavaScript = isJavaScript; + ts.hasJavaScriptFileExtension = hasJavaScriptFileExtension; function isTsx(fileName) { - return ts.fileExtensionIs(fileName, ".tsx"); + return ts.fileExtensionIs(fileName, ".tsx") || ts.fileExtensionIs(fileName, ".jsx"); } ts.isTsx = isTsx; /** @@ -7178,9 +7334,9 @@ var ts; } ts.collapseTextChangeRangesAcrossMultipleVersions = collapseTextChangeRangesAcrossMultipleVersions; function getTypeParameterOwner(d) { - if (d && d.kind === 135 /* TypeParameter */) { + if (d && d.kind === 137 /* TypeParameter */) { for (var current = d; current; current = current.parent) { - if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 213 /* InterfaceDeclaration */) { + if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 215 /* InterfaceDeclaration */) { return current; } } @@ -7192,7 +7348,7 @@ var ts; /// var ts; (function (ts) { - var nodeConstructors = new Array(270 /* Count */); + var nodeConstructors = new Array(272 /* Count */); /* @internal */ ts.parseTime = 0; function getNodeConstructor(kind) { return nodeConstructors[kind] || (nodeConstructors[kind] = ts.objectAllocator.getNodeConstructor(kind)); @@ -7237,20 +7393,26 @@ var ts; var visitNodes = cbNodeArray ? visitNodeArray : visitEachNode; var cbNodes = cbNodeArray || cbNode; switch (node.kind) { - case 133 /* QualifiedName */: + case 135 /* QualifiedName */: return visitNode(cbNode, node.left) || visitNode(cbNode, node.right); - case 135 /* TypeParameter */: + case 137 /* TypeParameter */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.constraint) || visitNode(cbNode, node.expression); - case 136 /* Parameter */: - case 139 /* PropertyDeclaration */: - case 138 /* PropertySignature */: - case 243 /* PropertyAssignment */: - case 244 /* ShorthandPropertyAssignment */: - case 209 /* VariableDeclaration */: - case 161 /* BindingElement */: + case 246 /* ShorthandPropertyAssignment */: + return visitNodes(cbNodes, node.decorators) || + visitNodes(cbNodes, node.modifiers) || + visitNode(cbNode, node.name) || + visitNode(cbNode, node.questionToken) || + visitNode(cbNode, node.equalsToken) || + visitNode(cbNode, node.objectAssignmentInitializer); + case 138 /* Parameter */: + case 141 /* PropertyDeclaration */: + case 140 /* PropertySignature */: + case 245 /* PropertyAssignment */: + case 211 /* VariableDeclaration */: + case 163 /* BindingElement */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.propertyName) || @@ -7259,24 +7421,24 @@ var ts; visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 150 /* FunctionType */: - case 151 /* ConstructorType */: - case 145 /* CallSignature */: - case 146 /* ConstructSignature */: - case 147 /* IndexSignature */: + case 152 /* FunctionType */: + case 153 /* ConstructorType */: + case 147 /* CallSignature */: + case 148 /* ConstructSignature */: + case 149 /* IndexSignature */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNodes(cbNodes, node.typeParameters) || visitNodes(cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 141 /* MethodDeclaration */: - case 140 /* MethodSignature */: - case 142 /* Constructor */: - case 143 /* GetAccessor */: - case 144 /* SetAccessor */: - case 171 /* FunctionExpression */: - case 211 /* FunctionDeclaration */: - case 172 /* ArrowFunction */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: + case 144 /* Constructor */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: + case 173 /* FunctionExpression */: + case 213 /* FunctionDeclaration */: + case 174 /* ArrowFunction */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.asteriskToken) || @@ -7287,290 +7449,290 @@ var ts; visitNode(cbNode, node.type) || visitNode(cbNode, node.equalsGreaterThanToken) || visitNode(cbNode, node.body); - case 149 /* TypeReference */: + case 151 /* TypeReference */: return visitNode(cbNode, node.typeName) || visitNodes(cbNodes, node.typeArguments); - case 148 /* TypePredicate */: + case 150 /* TypePredicate */: return visitNode(cbNode, node.parameterName) || visitNode(cbNode, node.type); - case 152 /* TypeQuery */: + case 154 /* TypeQuery */: return visitNode(cbNode, node.exprName); - case 153 /* TypeLiteral */: + case 155 /* TypeLiteral */: return visitNodes(cbNodes, node.members); - case 154 /* ArrayType */: + case 156 /* ArrayType */: return visitNode(cbNode, node.elementType); - case 155 /* TupleType */: + case 157 /* TupleType */: return visitNodes(cbNodes, node.elementTypes); - case 156 /* UnionType */: - case 157 /* IntersectionType */: + case 158 /* UnionType */: + case 159 /* IntersectionType */: return visitNodes(cbNodes, node.types); - case 158 /* ParenthesizedType */: + case 160 /* ParenthesizedType */: return visitNode(cbNode, node.type); - case 159 /* ObjectBindingPattern */: - case 160 /* ArrayBindingPattern */: + case 161 /* ObjectBindingPattern */: + case 162 /* ArrayBindingPattern */: return visitNodes(cbNodes, node.elements); - case 162 /* ArrayLiteralExpression */: + case 164 /* ArrayLiteralExpression */: return visitNodes(cbNodes, node.elements); - case 163 /* ObjectLiteralExpression */: + case 165 /* ObjectLiteralExpression */: return visitNodes(cbNodes, node.properties); - case 164 /* PropertyAccessExpression */: + case 166 /* PropertyAccessExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.dotToken) || visitNode(cbNode, node.name); - case 165 /* ElementAccessExpression */: + case 167 /* ElementAccessExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.argumentExpression); - case 166 /* CallExpression */: - case 167 /* NewExpression */: + case 168 /* CallExpression */: + case 169 /* NewExpression */: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.typeArguments) || visitNodes(cbNodes, node.arguments); - case 168 /* TaggedTemplateExpression */: + case 170 /* TaggedTemplateExpression */: return visitNode(cbNode, node.tag) || visitNode(cbNode, node.template); - case 169 /* TypeAssertionExpression */: + case 171 /* TypeAssertionExpression */: return visitNode(cbNode, node.type) || visitNode(cbNode, node.expression); - case 170 /* ParenthesizedExpression */: + case 172 /* ParenthesizedExpression */: return visitNode(cbNode, node.expression); - case 173 /* DeleteExpression */: + case 175 /* DeleteExpression */: return visitNode(cbNode, node.expression); - case 174 /* TypeOfExpression */: + case 176 /* TypeOfExpression */: return visitNode(cbNode, node.expression); - case 175 /* VoidExpression */: + case 177 /* VoidExpression */: return visitNode(cbNode, node.expression); - case 177 /* PrefixUnaryExpression */: + case 179 /* PrefixUnaryExpression */: return visitNode(cbNode, node.operand); - case 182 /* YieldExpression */: + case 184 /* YieldExpression */: return visitNode(cbNode, node.asteriskToken) || visitNode(cbNode, node.expression); - case 176 /* AwaitExpression */: + case 178 /* AwaitExpression */: return visitNode(cbNode, node.expression); - case 178 /* PostfixUnaryExpression */: + case 180 /* PostfixUnaryExpression */: return visitNode(cbNode, node.operand); - case 179 /* BinaryExpression */: + case 181 /* BinaryExpression */: return visitNode(cbNode, node.left) || visitNode(cbNode, node.operatorToken) || visitNode(cbNode, node.right); - case 187 /* AsExpression */: + case 189 /* AsExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.type); - case 180 /* ConditionalExpression */: + case 182 /* ConditionalExpression */: return visitNode(cbNode, node.condition) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.whenTrue) || visitNode(cbNode, node.colonToken) || visitNode(cbNode, node.whenFalse); - case 183 /* SpreadElementExpression */: + case 185 /* SpreadElementExpression */: return visitNode(cbNode, node.expression); - case 190 /* Block */: - case 217 /* ModuleBlock */: + case 192 /* Block */: + case 219 /* ModuleBlock */: return visitNodes(cbNodes, node.statements); - case 246 /* SourceFile */: + case 248 /* SourceFile */: return visitNodes(cbNodes, node.statements) || visitNode(cbNode, node.endOfFileToken); - case 191 /* VariableStatement */: + case 193 /* VariableStatement */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.declarationList); - case 210 /* VariableDeclarationList */: + case 212 /* VariableDeclarationList */: return visitNodes(cbNodes, node.declarations); - case 193 /* ExpressionStatement */: + case 195 /* ExpressionStatement */: return visitNode(cbNode, node.expression); - case 194 /* IfStatement */: + case 196 /* IfStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.thenStatement) || visitNode(cbNode, node.elseStatement); - case 195 /* DoStatement */: + case 197 /* DoStatement */: return visitNode(cbNode, node.statement) || visitNode(cbNode, node.expression); - case 196 /* WhileStatement */: + case 198 /* WhileStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 197 /* ForStatement */: + case 199 /* ForStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.condition) || visitNode(cbNode, node.incrementor) || visitNode(cbNode, node.statement); - case 198 /* ForInStatement */: + case 200 /* ForInStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 199 /* ForOfStatement */: + case 201 /* ForOfStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 200 /* ContinueStatement */: - case 201 /* BreakStatement */: + case 202 /* ContinueStatement */: + case 203 /* BreakStatement */: return visitNode(cbNode, node.label); - case 202 /* ReturnStatement */: + case 204 /* ReturnStatement */: return visitNode(cbNode, node.expression); - case 203 /* WithStatement */: + case 205 /* WithStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 204 /* SwitchStatement */: + case 206 /* SwitchStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.caseBlock); - case 218 /* CaseBlock */: + case 220 /* CaseBlock */: return visitNodes(cbNodes, node.clauses); - case 239 /* CaseClause */: + case 241 /* CaseClause */: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.statements); - case 240 /* DefaultClause */: + case 242 /* DefaultClause */: return visitNodes(cbNodes, node.statements); - case 205 /* LabeledStatement */: + case 207 /* LabeledStatement */: return visitNode(cbNode, node.label) || visitNode(cbNode, node.statement); - case 206 /* ThrowStatement */: + case 208 /* ThrowStatement */: return visitNode(cbNode, node.expression); - case 207 /* TryStatement */: + case 209 /* TryStatement */: return visitNode(cbNode, node.tryBlock) || visitNode(cbNode, node.catchClause) || visitNode(cbNode, node.finallyBlock); - case 242 /* CatchClause */: + case 244 /* CatchClause */: return visitNode(cbNode, node.variableDeclaration) || visitNode(cbNode, node.block); - case 137 /* Decorator */: + case 139 /* Decorator */: return visitNode(cbNode, node.expression); - case 212 /* ClassDeclaration */: - case 184 /* ClassExpression */: + case 214 /* ClassDeclaration */: + case 186 /* ClassExpression */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNodes, node.typeParameters) || visitNodes(cbNodes, node.heritageClauses) || visitNodes(cbNodes, node.members); - case 213 /* InterfaceDeclaration */: + case 215 /* InterfaceDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNodes, node.typeParameters) || visitNodes(cbNodes, node.heritageClauses) || visitNodes(cbNodes, node.members); - case 214 /* TypeAliasDeclaration */: + case 216 /* TypeAliasDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNodes, node.typeParameters) || visitNode(cbNode, node.type); - case 215 /* EnumDeclaration */: + case 217 /* EnumDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNodes, node.members); - case 245 /* EnumMember */: + case 247 /* EnumMember */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 216 /* ModuleDeclaration */: + case 218 /* ModuleDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.body); - case 219 /* ImportEqualsDeclaration */: + case 221 /* ImportEqualsDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.moduleReference); - case 220 /* ImportDeclaration */: + case 222 /* ImportDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.importClause) || visitNode(cbNode, node.moduleSpecifier); - case 221 /* ImportClause */: + case 223 /* ImportClause */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.namedBindings); - case 222 /* NamespaceImport */: + case 224 /* NamespaceImport */: return visitNode(cbNode, node.name); - case 223 /* NamedImports */: - case 227 /* NamedExports */: + case 225 /* NamedImports */: + case 229 /* NamedExports */: return visitNodes(cbNodes, node.elements); - case 226 /* ExportDeclaration */: + case 228 /* ExportDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.exportClause) || visitNode(cbNode, node.moduleSpecifier); - case 224 /* ImportSpecifier */: - case 228 /* ExportSpecifier */: + case 226 /* ImportSpecifier */: + case 230 /* ExportSpecifier */: return visitNode(cbNode, node.propertyName) || visitNode(cbNode, node.name); - case 225 /* ExportAssignment */: + case 227 /* ExportAssignment */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.expression); - case 181 /* TemplateExpression */: + case 183 /* TemplateExpression */: return visitNode(cbNode, node.head) || visitNodes(cbNodes, node.templateSpans); - case 188 /* TemplateSpan */: + case 190 /* TemplateSpan */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.literal); - case 134 /* ComputedPropertyName */: + case 136 /* ComputedPropertyName */: return visitNode(cbNode, node.expression); - case 241 /* HeritageClause */: + case 243 /* HeritageClause */: return visitNodes(cbNodes, node.types); - case 186 /* ExpressionWithTypeArguments */: + case 188 /* ExpressionWithTypeArguments */: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.typeArguments); - case 230 /* ExternalModuleReference */: + case 232 /* ExternalModuleReference */: return visitNode(cbNode, node.expression); - case 229 /* MissingDeclaration */: + case 231 /* MissingDeclaration */: return visitNodes(cbNodes, node.decorators); - case 231 /* JsxElement */: + case 233 /* JsxElement */: return visitNode(cbNode, node.openingElement) || visitNodes(cbNodes, node.children) || visitNode(cbNode, node.closingElement); - case 232 /* JsxSelfClosingElement */: - case 233 /* JsxOpeningElement */: + case 234 /* JsxSelfClosingElement */: + case 235 /* JsxOpeningElement */: return visitNode(cbNode, node.tagName) || visitNodes(cbNodes, node.attributes); - case 236 /* JsxAttribute */: + case 238 /* JsxAttribute */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 237 /* JsxSpreadAttribute */: + case 239 /* JsxSpreadAttribute */: return visitNode(cbNode, node.expression); - case 238 /* JsxExpression */: + case 240 /* JsxExpression */: return visitNode(cbNode, node.expression); - case 235 /* JsxClosingElement */: + case 237 /* JsxClosingElement */: return visitNode(cbNode, node.tagName); - case 247 /* JSDocTypeExpression */: + case 249 /* JSDocTypeExpression */: return visitNode(cbNode, node.type); - case 251 /* JSDocUnionType */: + case 253 /* JSDocUnionType */: return visitNodes(cbNodes, node.types); - case 252 /* JSDocTupleType */: + case 254 /* JSDocTupleType */: return visitNodes(cbNodes, node.types); - case 250 /* JSDocArrayType */: + case 252 /* JSDocArrayType */: return visitNode(cbNode, node.elementType); - case 254 /* JSDocNonNullableType */: + case 256 /* JSDocNonNullableType */: return visitNode(cbNode, node.type); - case 253 /* JSDocNullableType */: + case 255 /* JSDocNullableType */: return visitNode(cbNode, node.type); - case 255 /* JSDocRecordType */: + case 257 /* JSDocRecordType */: return visitNodes(cbNodes, node.members); - case 257 /* JSDocTypeReference */: + case 259 /* JSDocTypeReference */: return visitNode(cbNode, node.name) || visitNodes(cbNodes, node.typeArguments); - case 258 /* JSDocOptionalType */: + case 260 /* JSDocOptionalType */: return visitNode(cbNode, node.type); - case 259 /* JSDocFunctionType */: + case 261 /* JSDocFunctionType */: return visitNodes(cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 260 /* JSDocVariadicType */: + case 262 /* JSDocVariadicType */: return visitNode(cbNode, node.type); - case 261 /* JSDocConstructorType */: + case 263 /* JSDocConstructorType */: return visitNode(cbNode, node.type); - case 262 /* JSDocThisType */: + case 264 /* JSDocThisType */: return visitNode(cbNode, node.type); - case 256 /* JSDocRecordMember */: + case 258 /* JSDocRecordMember */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.type); - case 263 /* JSDocComment */: + case 265 /* JSDocComment */: return visitNodes(cbNodes, node.tags); - case 265 /* JSDocParameterTag */: + case 267 /* JSDocParameterTag */: return visitNode(cbNode, node.preParameterName) || visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.postParameterName); - case 266 /* JSDocReturnTag */: + case 268 /* JSDocReturnTag */: return visitNode(cbNode, node.typeExpression); - case 267 /* JSDocTypeTag */: + case 269 /* JSDocTypeTag */: return visitNode(cbNode, node.typeExpression); - case 268 /* JSDocTemplateTag */: + case 270 /* JSDocTemplateTag */: return visitNodes(cbNodes, node.typeParameters); } } @@ -7701,13 +7863,14 @@ var ts; // attached to the EOF token. var parseErrorBeforeNextFinishedNode = false; function parseSourceFile(fileName, _sourceText, languageVersion, _syntaxCursor, setParentNodes) { - initializeState(fileName, _sourceText, languageVersion, _syntaxCursor); + var isJavaScriptFile = ts.hasJavaScriptFileExtension(fileName) || _sourceText.lastIndexOf("// @language=javascript", 0) === 0; + initializeState(fileName, _sourceText, languageVersion, isJavaScriptFile, _syntaxCursor); var result = parseSourceFileWorker(fileName, languageVersion, setParentNodes); clearState(); return result; } Parser.parseSourceFile = parseSourceFile; - function initializeState(fileName, _sourceText, languageVersion, _syntaxCursor) { + function initializeState(fileName, _sourceText, languageVersion, isJavaScriptFile, _syntaxCursor) { sourceText = _sourceText; syntaxCursor = _syntaxCursor; parseDiagnostics = []; @@ -7715,7 +7878,7 @@ var ts; identifiers = {}; identifierCount = 0; nodeCount = 0; - contextFlags = ts.isJavaScript(fileName) ? 32 /* JavaScriptFile */ : 0 /* None */; + contextFlags = isJavaScriptFile ? 32 /* JavaScriptFile */ : 0 /* None */; parseErrorBeforeNextFinishedNode = false; // Initialize and prime the scanner before parsing the source elements. scanner.setText(sourceText); @@ -7736,6 +7899,9 @@ var ts; } function parseSourceFileWorker(fileName, languageVersion, setParentNodes) { sourceFile = createSourceFile(fileName, languageVersion); + if (contextFlags & 32 /* JavaScriptFile */) { + sourceFile.parserContextFlags = 32 /* JavaScriptFile */; + } // Prime the scanner. token = nextToken(); processReferenceComments(sourceFile); @@ -7753,7 +7919,7 @@ var ts; // If this is a javascript file, proactively see if we can get JSDoc comments for // relevant nodes in the file. We'll use these to provide typing informaion if they're // available. - if (ts.isJavaScript(fileName)) { + if (ts.isSourceFileJavaScript(sourceFile)) { addJSDocComments(); } return sourceFile; @@ -7765,9 +7931,9 @@ var ts; // Add additional cases as necessary depending on how we see JSDoc comments used // in the wild. switch (node.kind) { - case 191 /* VariableStatement */: - case 211 /* FunctionDeclaration */: - case 136 /* Parameter */: + case 193 /* VariableStatement */: + case 213 /* FunctionDeclaration */: + case 138 /* Parameter */: addJSDocComment(node); } forEachChild(node, visit); @@ -7808,7 +7974,7 @@ var ts; } Parser.fixupParentReferences = fixupParentReferences; function createSourceFile(fileName, languageVersion) { - var sourceFile = createNode(246 /* SourceFile */, /*pos*/ 0); + var sourceFile = createNode(248 /* SourceFile */, /*pos*/ 0); sourceFile.pos = 0; sourceFile.end = sourceText.length; sourceFile.text = sourceText; @@ -7972,7 +8138,7 @@ var ts; var saveParseDiagnosticsLength = parseDiagnostics.length; var saveParseErrorBeforeNextFinishedNode = parseErrorBeforeNextFinishedNode; // Note: it is not actually necessary to save/restore the context flags here. That's - // because the saving/restorating of these flags happens naturally through the recursive + // because the saving/restoring of these flags happens naturally through the recursive // descent nature of our parser. However, we still store this here just so we can // assert that that invariant holds. var saveContextFlags = contextFlags; @@ -8007,20 +8173,20 @@ var ts; } // Ignore strict mode flag because we will report an error in type checker instead. function isIdentifier() { - if (token === 67 /* Identifier */) { + if (token === 69 /* Identifier */) { return true; } // If we have a 'yield' keyword, and we're in the [yield] context, then 'yield' is // considered a keyword and is not an identifier. - if (token === 112 /* YieldKeyword */ && inYieldContext()) { + if (token === 114 /* YieldKeyword */ && inYieldContext()) { return false; } // If we have a 'await' keyword, and we're in the [Await] context, then 'await' is // considered a keyword and is not an identifier. - if (token === 117 /* AwaitKeyword */ && inAwaitContext()) { + if (token === 119 /* AwaitKeyword */ && inAwaitContext()) { return false; } - return token > 103 /* LastReservedWord */; + return token > 105 /* LastReservedWord */; } function parseExpected(kind, diagnosticMessage, shouldAdvance) { if (shouldAdvance === void 0) { shouldAdvance = true; } @@ -8126,16 +8292,16 @@ var ts; function createIdentifier(isIdentifier, diagnosticMessage) { identifierCount++; if (isIdentifier) { - var node = createNode(67 /* Identifier */); + var node = createNode(69 /* Identifier */); // Store original token kind if it is not just an Identifier so we can report appropriate error later in type checker - if (token !== 67 /* Identifier */) { + if (token !== 69 /* Identifier */) { node.originalKeywordKind = token; } node.text = internIdentifier(scanner.getTokenValue()); nextToken(); return finishNode(node); } - return createMissingNode(67 /* Identifier */, /*reportAtCurrentPosition*/ false, diagnosticMessage || ts.Diagnostics.Identifier_expected); + return createMissingNode(69 /* Identifier */, /*reportAtCurrentPosition*/ false, diagnosticMessage || ts.Diagnostics.Identifier_expected); } function parseIdentifier(diagnosticMessage) { return createIdentifier(isIdentifier(), diagnosticMessage); @@ -8170,7 +8336,7 @@ var ts; // PropertyName [Yield]: // LiteralPropertyName // ComputedPropertyName[?Yield] - var node = createNode(134 /* ComputedPropertyName */); + var node = createNode(136 /* ComputedPropertyName */); parseExpected(19 /* OpenBracketToken */); // We parse any expression (including a comma expression). But the grammar // says that only an assignment expression is allowed, so the grammar checker @@ -8183,21 +8349,28 @@ var ts; return token === t && tryParse(nextTokenCanFollowModifier); } function nextTokenCanFollowModifier() { - if (token === 72 /* ConstKeyword */) { + if (token === 74 /* ConstKeyword */) { // 'const' is only a modifier if followed by 'enum'. - return nextToken() === 79 /* EnumKeyword */; + return nextToken() === 81 /* EnumKeyword */; } - if (token === 80 /* ExportKeyword */) { + if (token === 82 /* ExportKeyword */) { nextToken(); - if (token === 75 /* DefaultKeyword */) { + if (token === 77 /* DefaultKeyword */) { return lookAhead(nextTokenIsClassOrFunction); } return token !== 37 /* AsteriskToken */ && token !== 15 /* OpenBraceToken */ && canFollowModifier(); } - if (token === 75 /* DefaultKeyword */) { + if (token === 77 /* DefaultKeyword */) { return nextTokenIsClassOrFunction(); } + if (token === 113 /* StaticKeyword */) { + nextToken(); + return canFollowModifier(); + } nextToken(); + if (scanner.hasPrecedingLineBreak()) { + return false; + } return canFollowModifier(); } function parseAnyContextualModifier() { @@ -8211,7 +8384,7 @@ var ts; } function nextTokenIsClassOrFunction() { nextToken(); - return token === 71 /* ClassKeyword */ || token === 85 /* FunctionKeyword */; + return token === 73 /* ClassKeyword */ || token === 87 /* FunctionKeyword */; } // True if positioned at the start of a list element function isListElement(parsingContext, inErrorRecovery) { @@ -8231,7 +8404,7 @@ var ts; // outer module. We just want to consume and move on. return !(token === 23 /* SemicolonToken */ && inErrorRecovery) && isStartOfStatement(); case 2 /* SwitchClauses */: - return token === 69 /* CaseKeyword */ || token === 75 /* DefaultKeyword */; + return token === 71 /* CaseKeyword */ || token === 77 /* DefaultKeyword */; case 4 /* TypeMembers */: return isStartOfTypeMember(); case 5 /* ClassMembers */: @@ -8305,7 +8478,7 @@ var ts; // extends {} extends // extends {} implements var next = nextToken(); - return next === 24 /* CommaToken */ || next === 15 /* OpenBraceToken */ || next === 81 /* ExtendsKeyword */ || next === 104 /* ImplementsKeyword */; + return next === 24 /* CommaToken */ || next === 15 /* OpenBraceToken */ || next === 83 /* ExtendsKeyword */ || next === 106 /* ImplementsKeyword */; } return true; } @@ -8318,8 +8491,8 @@ var ts; return ts.tokenIsIdentifierOrKeyword(token); } function isHeritageClauseExtendsOrImplementsKeyword() { - if (token === 104 /* ImplementsKeyword */ || - token === 81 /* ExtendsKeyword */) { + if (token === 106 /* ImplementsKeyword */ || + token === 83 /* ExtendsKeyword */) { return lookAhead(nextTokenIsStartOfExpression); } return false; @@ -8345,14 +8518,14 @@ var ts; case 21 /* ImportOrExportSpecifiers */: return token === 16 /* CloseBraceToken */; case 3 /* SwitchClauseStatements */: - return token === 16 /* CloseBraceToken */ || token === 69 /* CaseKeyword */ || token === 75 /* DefaultKeyword */; + return token === 16 /* CloseBraceToken */ || token === 71 /* CaseKeyword */ || token === 77 /* DefaultKeyword */; case 7 /* HeritageClauseElement */: - return token === 15 /* OpenBraceToken */ || token === 81 /* ExtendsKeyword */ || token === 104 /* ImplementsKeyword */; + return token === 15 /* OpenBraceToken */ || token === 83 /* ExtendsKeyword */ || token === 106 /* ImplementsKeyword */; case 8 /* VariableDeclarations */: return isVariableDeclaratorListTerminator(); case 17 /* TypeParameters */: // Tokens other than '>' are here for better error recovery - return token === 27 /* GreaterThanToken */ || token === 17 /* OpenParenToken */ || token === 15 /* OpenBraceToken */ || token === 81 /* ExtendsKeyword */ || token === 104 /* ImplementsKeyword */; + return token === 27 /* GreaterThanToken */ || token === 17 /* OpenParenToken */ || token === 15 /* OpenBraceToken */ || token === 83 /* ExtendsKeyword */ || token === 106 /* ImplementsKeyword */; case 11 /* ArgumentExpressions */: // Tokens other than ')' are here for better error recovery return token === 18 /* CloseParenToken */ || token === 23 /* SemicolonToken */; @@ -8369,11 +8542,11 @@ var ts; case 20 /* HeritageClauses */: return token === 15 /* OpenBraceToken */ || token === 16 /* CloseBraceToken */; case 13 /* JsxAttributes */: - return token === 27 /* GreaterThanToken */ || token === 38 /* SlashToken */; + return token === 27 /* GreaterThanToken */ || token === 39 /* SlashToken */; case 14 /* JsxChildren */: return token === 25 /* LessThanToken */ && lookAhead(nextTokenIsSlash); case 22 /* JSDocFunctionParameters */: - return token === 18 /* CloseParenToken */ || token === 53 /* ColonToken */ || token === 16 /* CloseBraceToken */; + return token === 18 /* CloseParenToken */ || token === 54 /* ColonToken */ || token === 16 /* CloseBraceToken */; case 23 /* JSDocTypeArguments */: return token === 27 /* GreaterThanToken */ || token === 16 /* CloseBraceToken */; case 25 /* JSDocTupleTypes */: @@ -8561,20 +8734,20 @@ var ts; function isReusableClassMember(node) { if (node) { switch (node.kind) { - case 142 /* Constructor */: - case 147 /* IndexSignature */: - case 143 /* GetAccessor */: - case 144 /* SetAccessor */: - case 139 /* PropertyDeclaration */: - case 189 /* SemicolonClassElement */: + case 144 /* Constructor */: + case 149 /* IndexSignature */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: + case 141 /* PropertyDeclaration */: + case 191 /* SemicolonClassElement */: return true; - case 141 /* MethodDeclaration */: + case 143 /* MethodDeclaration */: // Method declarations are not necessarily reusable. An object-literal // may have a method calls "constructor(...)" and we must reparse that // into an actual .ConstructorDeclaration. var methodDeclaration = node; - var nameIsConstructor = methodDeclaration.name.kind === 67 /* Identifier */ && - methodDeclaration.name.originalKeywordKind === 119 /* ConstructorKeyword */; + var nameIsConstructor = methodDeclaration.name.kind === 69 /* Identifier */ && + methodDeclaration.name.originalKeywordKind === 121 /* ConstructorKeyword */; return !nameIsConstructor; } } @@ -8583,8 +8756,8 @@ var ts; function isReusableSwitchClause(node) { if (node) { switch (node.kind) { - case 239 /* CaseClause */: - case 240 /* DefaultClause */: + case 241 /* CaseClause */: + case 242 /* DefaultClause */: return true; } } @@ -8593,58 +8766,58 @@ var ts; function isReusableStatement(node) { if (node) { switch (node.kind) { - case 211 /* FunctionDeclaration */: - case 191 /* VariableStatement */: - case 190 /* Block */: - case 194 /* IfStatement */: - case 193 /* ExpressionStatement */: - case 206 /* ThrowStatement */: - case 202 /* ReturnStatement */: - case 204 /* SwitchStatement */: - case 201 /* BreakStatement */: - case 200 /* ContinueStatement */: - case 198 /* ForInStatement */: - case 199 /* ForOfStatement */: - case 197 /* ForStatement */: - case 196 /* WhileStatement */: - case 203 /* WithStatement */: - case 192 /* EmptyStatement */: - case 207 /* TryStatement */: - case 205 /* LabeledStatement */: - case 195 /* DoStatement */: - case 208 /* DebuggerStatement */: - case 220 /* ImportDeclaration */: - case 219 /* ImportEqualsDeclaration */: - case 226 /* ExportDeclaration */: - case 225 /* ExportAssignment */: - case 216 /* ModuleDeclaration */: - case 212 /* ClassDeclaration */: - case 213 /* InterfaceDeclaration */: - case 215 /* EnumDeclaration */: - case 214 /* TypeAliasDeclaration */: + case 213 /* FunctionDeclaration */: + case 193 /* VariableStatement */: + case 192 /* Block */: + case 196 /* IfStatement */: + case 195 /* ExpressionStatement */: + case 208 /* ThrowStatement */: + case 204 /* ReturnStatement */: + case 206 /* SwitchStatement */: + case 203 /* BreakStatement */: + case 202 /* ContinueStatement */: + case 200 /* ForInStatement */: + case 201 /* ForOfStatement */: + case 199 /* ForStatement */: + case 198 /* WhileStatement */: + case 205 /* WithStatement */: + case 194 /* EmptyStatement */: + case 209 /* TryStatement */: + case 207 /* LabeledStatement */: + case 197 /* DoStatement */: + case 210 /* DebuggerStatement */: + case 222 /* ImportDeclaration */: + case 221 /* ImportEqualsDeclaration */: + case 228 /* ExportDeclaration */: + case 227 /* ExportAssignment */: + case 218 /* ModuleDeclaration */: + case 214 /* ClassDeclaration */: + case 215 /* InterfaceDeclaration */: + case 217 /* EnumDeclaration */: + case 216 /* TypeAliasDeclaration */: return true; } } return false; } function isReusableEnumMember(node) { - return node.kind === 245 /* EnumMember */; + return node.kind === 247 /* EnumMember */; } function isReusableTypeMember(node) { if (node) { switch (node.kind) { - case 146 /* ConstructSignature */: - case 140 /* MethodSignature */: - case 147 /* IndexSignature */: - case 138 /* PropertySignature */: - case 145 /* CallSignature */: + case 148 /* ConstructSignature */: + case 142 /* MethodSignature */: + case 149 /* IndexSignature */: + case 140 /* PropertySignature */: + case 147 /* CallSignature */: return true; } } return false; } function isReusableVariableDeclaration(node) { - if (node.kind !== 209 /* VariableDeclaration */) { + if (node.kind !== 211 /* VariableDeclaration */) { return false; } // Very subtle incremental parsing bug. Consider the following code: @@ -8665,7 +8838,7 @@ var ts; return variableDeclarator.initializer === undefined; } function isReusableParameter(node) { - if (node.kind !== 136 /* Parameter */) { + if (node.kind !== 138 /* Parameter */) { return false; } // See the comment in isReusableVariableDeclaration for why we do this. @@ -8782,7 +8955,7 @@ var ts; function parseEntityName(allowReservedWords, diagnosticMessage) { var entity = parseIdentifier(diagnosticMessage); while (parseOptional(21 /* DotToken */)) { - var node = createNode(133 /* QualifiedName */, entity.pos); + var node = createNode(135 /* QualifiedName */, entity.pos); node.left = entity; node.right = parseRightSideOfDot(allowReservedWords); entity = finishNode(node); @@ -8815,13 +8988,13 @@ var ts; // Report that we need an identifier. However, report it right after the dot, // and not on the next token. This is because the next token might actually // be an identifier and the error would be quite confusing. - return createMissingNode(67 /* Identifier */, /*reportAtCurrentToken*/ true, ts.Diagnostics.Identifier_expected); + return createMissingNode(69 /* Identifier */, /*reportAtCurrentToken*/ true, ts.Diagnostics.Identifier_expected); } } return allowIdentifierNames ? parseIdentifierName() : parseIdentifier(); } function parseTemplateExpression() { - var template = createNode(181 /* TemplateExpression */); + var template = createNode(183 /* TemplateExpression */); template.head = parseLiteralNode(); ts.Debug.assert(template.head.kind === 12 /* TemplateHead */, "Template head has wrong token kind"); var templateSpans = []; @@ -8834,7 +9007,7 @@ var ts; return finishNode(template); } function parseTemplateSpan() { - var span = createNode(188 /* TemplateSpan */); + var span = createNode(190 /* TemplateSpan */); span.expression = allowInAnd(parseExpression); var literal; if (token === 16 /* CloseBraceToken */) { @@ -8876,14 +9049,14 @@ var ts; // TYPES function parseTypeReferenceOrTypePredicate() { var typeName = parseEntityName(/*allowReservedWords*/ false, ts.Diagnostics.Type_expected); - if (typeName.kind === 67 /* Identifier */ && token === 122 /* IsKeyword */ && !scanner.hasPrecedingLineBreak()) { + if (typeName.kind === 69 /* Identifier */ && token === 124 /* IsKeyword */ && !scanner.hasPrecedingLineBreak()) { nextToken(); - var node_1 = createNode(148 /* TypePredicate */, typeName.pos); + var node_1 = createNode(150 /* TypePredicate */, typeName.pos); node_1.parameterName = typeName; node_1.type = parseType(); return finishNode(node_1); } - var node = createNode(149 /* TypeReference */, typeName.pos); + var node = createNode(151 /* TypeReference */, typeName.pos); node.typeName = typeName; if (!scanner.hasPrecedingLineBreak() && token === 25 /* LessThanToken */) { node.typeArguments = parseBracketedList(18 /* TypeArguments */, parseType, 25 /* LessThanToken */, 27 /* GreaterThanToken */); @@ -8891,15 +9064,15 @@ var ts; return finishNode(node); } function parseTypeQuery() { - var node = createNode(152 /* TypeQuery */); - parseExpected(99 /* TypeOfKeyword */); + var node = createNode(154 /* TypeQuery */); + parseExpected(101 /* TypeOfKeyword */); node.exprName = parseEntityName(/*allowReservedWords*/ true); return finishNode(node); } function parseTypeParameter() { - var node = createNode(135 /* TypeParameter */); + var node = createNode(137 /* TypeParameter */); node.name = parseIdentifier(); - if (parseOptional(81 /* ExtendsKeyword */)) { + if (parseOptional(83 /* ExtendsKeyword */)) { // It's not uncommon for people to write improper constraints to a generic. If the // user writes a constraint that is an expression and not an actual type, then parse // it out as an expression (so we can recover well), but report that a type is needed @@ -8926,7 +9099,7 @@ var ts; } } function parseParameterType() { - if (parseOptional(53 /* ColonToken */)) { + if (parseOptional(54 /* ColonToken */)) { return token === 9 /* StringLiteral */ ? parseLiteralNode(/*internName*/ true) : parseType(); @@ -8934,7 +9107,7 @@ var ts; return undefined; } function isStartOfParameter() { - return token === 22 /* DotDotDotToken */ || isIdentifierOrPattern() || ts.isModifier(token) || token === 54 /* AtToken */; + return token === 22 /* DotDotDotToken */ || isIdentifierOrPattern() || ts.isModifier(token) || token === 55 /* AtToken */; } function setModifiers(node, modifiers) { if (modifiers) { @@ -8943,7 +9116,7 @@ var ts; } } function parseParameter() { - var node = createNode(136 /* Parameter */); + var node = createNode(138 /* Parameter */); node.decorators = parseDecorators(); setModifiers(node, parseModifiers()); node.dotDotDotToken = parseOptionalToken(22 /* DotDotDotToken */); @@ -8961,7 +9134,7 @@ var ts; // to avoid this we'll advance cursor to the next token. nextToken(); } - node.questionToken = parseOptionalToken(52 /* QuestionToken */); + node.questionToken = parseOptionalToken(53 /* QuestionToken */); node.type = parseParameterType(); node.initializer = parseBindingElementInitializer(/*inParameter*/ true); // Do not check for initializers in an ambient context for parameters. This is not @@ -9037,10 +9210,10 @@ var ts; } function parseSignatureMember(kind) { var node = createNode(kind); - if (kind === 146 /* ConstructSignature */) { - parseExpected(90 /* NewKeyword */); + if (kind === 148 /* ConstructSignature */) { + parseExpected(92 /* NewKeyword */); } - fillSignature(53 /* ColonToken */, /*yieldContext*/ false, /*awaitContext*/ false, /*requireCompleteParameterList*/ false, node); + fillSignature(54 /* ColonToken */, /*yieldContext*/ false, /*awaitContext*/ false, /*requireCompleteParameterList*/ false, node); parseTypeMemberSemicolon(); return finishNode(node); } @@ -9087,21 +9260,21 @@ var ts; // A colon signifies a well formed indexer // A comma should be a badly formed indexer because comma expressions are not allowed // in computed properties. - if (token === 53 /* ColonToken */ || token === 24 /* CommaToken */) { + if (token === 54 /* ColonToken */ || token === 24 /* CommaToken */) { return true; } // Question mark could be an indexer with an optional property, // or it could be a conditional expression in a computed property. - if (token !== 52 /* QuestionToken */) { + if (token !== 53 /* QuestionToken */) { return false; } // If any of the following tokens are after the question mark, it cannot // be a conditional expression, so treat it as an indexer. nextToken(); - return token === 53 /* ColonToken */ || token === 24 /* CommaToken */ || token === 20 /* CloseBracketToken */; + return token === 54 /* ColonToken */ || token === 24 /* CommaToken */ || token === 20 /* CloseBracketToken */; } function parseIndexSignatureDeclaration(fullStart, decorators, modifiers) { - var node = createNode(147 /* IndexSignature */, fullStart); + var node = createNode(149 /* IndexSignature */, fullStart); node.decorators = decorators; setModifiers(node, modifiers); node.parameters = parseBracketedList(16 /* Parameters */, parseParameter, 19 /* OpenBracketToken */, 20 /* CloseBracketToken */); @@ -9112,19 +9285,19 @@ var ts; function parsePropertyOrMethodSignature() { var fullStart = scanner.getStartPos(); var name = parsePropertyName(); - var questionToken = parseOptionalToken(52 /* QuestionToken */); + var questionToken = parseOptionalToken(53 /* QuestionToken */); if (token === 17 /* OpenParenToken */ || token === 25 /* LessThanToken */) { - var method = createNode(140 /* MethodSignature */, fullStart); + var method = createNode(142 /* MethodSignature */, fullStart); method.name = name; method.questionToken = questionToken; // Method signatues don't exist in expression contexts. So they have neither // [Yield] nor [Await] - fillSignature(53 /* ColonToken */, /*yieldContext*/ false, /*awaitContext*/ false, /*requireCompleteParameterList*/ false, method); + fillSignature(54 /* ColonToken */, /*yieldContext*/ false, /*awaitContext*/ false, /*requireCompleteParameterList*/ false, method); parseTypeMemberSemicolon(); return finishNode(method); } else { - var property = createNode(138 /* PropertySignature */, fullStart); + var property = createNode(140 /* PropertySignature */, fullStart); property.name = name; property.questionToken = questionToken; property.type = parseTypeAnnotation(); @@ -9158,23 +9331,23 @@ var ts; nextToken(); return token === 17 /* OpenParenToken */ || token === 25 /* LessThanToken */ || - token === 52 /* QuestionToken */ || - token === 53 /* ColonToken */ || + token === 53 /* QuestionToken */ || + token === 54 /* ColonToken */ || canParseSemicolon(); } function parseTypeMember() { switch (token) { case 17 /* OpenParenToken */: case 25 /* LessThanToken */: - return parseSignatureMember(145 /* CallSignature */); + return parseSignatureMember(147 /* CallSignature */); case 19 /* OpenBracketToken */: // Indexer or computed property return isIndexSignature() ? parseIndexSignatureDeclaration(scanner.getStartPos(), /*decorators*/ undefined, /*modifiers*/ undefined) : parsePropertyOrMethodSignature(); - case 90 /* NewKeyword */: + case 92 /* NewKeyword */: if (lookAhead(isStartOfConstructSignature)) { - return parseSignatureMember(146 /* ConstructSignature */); + return parseSignatureMember(148 /* ConstructSignature */); } // fall through. case 9 /* StringLiteral */: @@ -9211,7 +9384,7 @@ var ts; return token === 17 /* OpenParenToken */ || token === 25 /* LessThanToken */; } function parseTypeLiteral() { - var node = createNode(153 /* TypeLiteral */); + var node = createNode(155 /* TypeLiteral */); node.members = parseObjectTypeMembers(); return finishNode(node); } @@ -9227,12 +9400,12 @@ var ts; return members; } function parseTupleType() { - var node = createNode(155 /* TupleType */); + var node = createNode(157 /* TupleType */); node.elementTypes = parseBracketedList(19 /* TupleElementTypes */, parseType, 19 /* OpenBracketToken */, 20 /* CloseBracketToken */); return finishNode(node); } function parseParenthesizedType() { - var node = createNode(158 /* ParenthesizedType */); + var node = createNode(160 /* ParenthesizedType */); parseExpected(17 /* OpenParenToken */); node.type = parseType(); parseExpected(18 /* CloseParenToken */); @@ -9240,8 +9413,8 @@ var ts; } function parseFunctionOrConstructorType(kind) { var node = createNode(kind); - if (kind === 151 /* ConstructorType */) { - parseExpected(90 /* NewKeyword */); + if (kind === 153 /* ConstructorType */) { + parseExpected(92 /* NewKeyword */); } fillSignature(34 /* EqualsGreaterThanToken */, /*yieldContext*/ false, /*awaitContext*/ false, /*requireCompleteParameterList*/ false, node); return finishNode(node); @@ -9252,17 +9425,18 @@ var ts; } function parseNonArrayType() { switch (token) { - case 115 /* AnyKeyword */: - case 128 /* StringKeyword */: - case 126 /* NumberKeyword */: - case 118 /* BooleanKeyword */: - case 129 /* SymbolKeyword */: + case 117 /* AnyKeyword */: + case 130 /* StringKeyword */: + case 128 /* NumberKeyword */: + case 120 /* BooleanKeyword */: + case 131 /* SymbolKeyword */: // If these are followed by a dot, then parse these out as a dotted type reference instead. var node = tryParse(parseKeywordAndNoDot); return node || parseTypeReferenceOrTypePredicate(); - case 101 /* VoidKeyword */: + case 103 /* VoidKeyword */: + case 97 /* ThisKeyword */: return parseTokenNode(); - case 99 /* TypeOfKeyword */: + case 101 /* TypeOfKeyword */: return parseTypeQuery(); case 15 /* OpenBraceToken */: return parseTypeLiteral(); @@ -9276,17 +9450,18 @@ var ts; } function isStartOfType() { switch (token) { - case 115 /* AnyKeyword */: - case 128 /* StringKeyword */: - case 126 /* NumberKeyword */: - case 118 /* BooleanKeyword */: - case 129 /* SymbolKeyword */: - case 101 /* VoidKeyword */: - case 99 /* TypeOfKeyword */: + case 117 /* AnyKeyword */: + case 130 /* StringKeyword */: + case 128 /* NumberKeyword */: + case 120 /* BooleanKeyword */: + case 131 /* SymbolKeyword */: + case 103 /* VoidKeyword */: + case 97 /* ThisKeyword */: + case 101 /* TypeOfKeyword */: case 15 /* OpenBraceToken */: case 19 /* OpenBracketToken */: case 25 /* LessThanToken */: - case 90 /* NewKeyword */: + case 92 /* NewKeyword */: return true; case 17 /* OpenParenToken */: // Only consider '(' the start of a type if followed by ')', '...', an identifier, a modifier, @@ -9304,7 +9479,7 @@ var ts; var type = parseNonArrayType(); while (!scanner.hasPrecedingLineBreak() && parseOptional(19 /* OpenBracketToken */)) { parseExpected(20 /* CloseBracketToken */); - var node = createNode(154 /* ArrayType */, type.pos); + var node = createNode(156 /* ArrayType */, type.pos); node.elementType = type; type = finishNode(node); } @@ -9326,10 +9501,10 @@ var ts; return type; } function parseIntersectionTypeOrHigher() { - return parseUnionOrIntersectionType(157 /* IntersectionType */, parseArrayTypeOrHigher, 45 /* AmpersandToken */); + return parseUnionOrIntersectionType(159 /* IntersectionType */, parseArrayTypeOrHigher, 46 /* AmpersandToken */); } function parseUnionTypeOrHigher() { - return parseUnionOrIntersectionType(156 /* UnionType */, parseIntersectionTypeOrHigher, 46 /* BarToken */); + return parseUnionOrIntersectionType(158 /* UnionType */, parseIntersectionTypeOrHigher, 47 /* BarToken */); } function isStartOfFunctionType() { if (token === 25 /* LessThanToken */) { @@ -9346,8 +9521,8 @@ var ts; } if (isIdentifier() || ts.isModifier(token)) { nextToken(); - if (token === 53 /* ColonToken */ || token === 24 /* CommaToken */ || - token === 52 /* QuestionToken */ || token === 55 /* EqualsToken */ || + if (token === 54 /* ColonToken */ || token === 24 /* CommaToken */ || + token === 53 /* QuestionToken */ || token === 56 /* EqualsToken */ || isIdentifier() || ts.isModifier(token)) { // ( id : // ( id , @@ -9373,24 +9548,24 @@ var ts; } function parseTypeWorker() { if (isStartOfFunctionType()) { - return parseFunctionOrConstructorType(150 /* FunctionType */); + return parseFunctionOrConstructorType(152 /* FunctionType */); } - if (token === 90 /* NewKeyword */) { - return parseFunctionOrConstructorType(151 /* ConstructorType */); + if (token === 92 /* NewKeyword */) { + return parseFunctionOrConstructorType(153 /* ConstructorType */); } return parseUnionTypeOrHigher(); } function parseTypeAnnotation() { - return parseOptional(53 /* ColonToken */) ? parseType() : undefined; + return parseOptional(54 /* ColonToken */) ? parseType() : undefined; } // EXPRESSIONS function isStartOfLeftHandSideExpression() { switch (token) { - case 95 /* ThisKeyword */: - case 93 /* SuperKeyword */: - case 91 /* NullKeyword */: - case 97 /* TrueKeyword */: - case 82 /* FalseKeyword */: + case 97 /* ThisKeyword */: + case 95 /* SuperKeyword */: + case 93 /* NullKeyword */: + case 99 /* TrueKeyword */: + case 84 /* FalseKeyword */: case 8 /* NumericLiteral */: case 9 /* StringLiteral */: case 11 /* NoSubstitutionTemplateLiteral */: @@ -9398,12 +9573,12 @@ var ts; case 17 /* OpenParenToken */: case 19 /* OpenBracketToken */: case 15 /* OpenBraceToken */: - case 85 /* FunctionKeyword */: - case 71 /* ClassKeyword */: - case 90 /* NewKeyword */: - case 38 /* SlashToken */: - case 59 /* SlashEqualsToken */: - case 67 /* Identifier */: + case 87 /* FunctionKeyword */: + case 73 /* ClassKeyword */: + case 92 /* NewKeyword */: + case 39 /* SlashToken */: + case 61 /* SlashEqualsToken */: + case 69 /* Identifier */: return true; default: return isIdentifier(); @@ -9416,16 +9591,16 @@ var ts; switch (token) { case 35 /* PlusToken */: case 36 /* MinusToken */: - case 49 /* TildeToken */: - case 48 /* ExclamationToken */: - case 76 /* DeleteKeyword */: - case 99 /* TypeOfKeyword */: - case 101 /* VoidKeyword */: - case 40 /* PlusPlusToken */: - case 41 /* MinusMinusToken */: + case 50 /* TildeToken */: + case 49 /* ExclamationToken */: + case 78 /* DeleteKeyword */: + case 101 /* TypeOfKeyword */: + case 103 /* VoidKeyword */: + case 41 /* PlusPlusToken */: + case 42 /* MinusMinusToken */: case 25 /* LessThanToken */: - case 117 /* AwaitKeyword */: - case 112 /* YieldKeyword */: + case 119 /* AwaitKeyword */: + case 114 /* YieldKeyword */: // Yield/await always starts an expression. Either it is an identifier (in which case // it is definitely an expression). Or it's a keyword (either because we're in // a generator or async function, or in strict mode (or both)) and it started a yield or await expression. @@ -9444,9 +9619,9 @@ var ts; function isStartOfExpressionStatement() { // As per the grammar, none of '{' or 'function' or 'class' can start an expression statement. return token !== 15 /* OpenBraceToken */ && - token !== 85 /* FunctionKeyword */ && - token !== 71 /* ClassKeyword */ && - token !== 54 /* AtToken */ && + token !== 87 /* FunctionKeyword */ && + token !== 73 /* ClassKeyword */ && + token !== 55 /* AtToken */ && isStartOfExpression(); } function allowInAndParseExpression() { @@ -9472,7 +9647,7 @@ var ts; return expr; } function parseInitializer(inParameter) { - if (token !== 55 /* EqualsToken */) { + if (token !== 56 /* EqualsToken */) { // It's not uncommon during typing for the user to miss writing the '=' token. Check if // there is no newline after the last token and if we're on an expression. If so, parse // this as an equals-value clause with a missing equals. @@ -9489,7 +9664,7 @@ var ts; } // Initializer[In, Yield] : // = AssignmentExpression[?In, ?Yield] - parseExpected(55 /* EqualsToken */); + parseExpected(56 /* EqualsToken */); return parseAssignmentExpressionOrHigher(); } function parseAssignmentExpressionOrHigher() { @@ -9527,7 +9702,7 @@ var ts; // To avoid a look-ahead, we did not handle the case of an arrow function with a single un-parenthesized // parameter ('x => ...') above. We handle it here by checking if the parsed expression was a single // identifier and the current token is an arrow. - if (expr.kind === 67 /* Identifier */ && token === 34 /* EqualsGreaterThanToken */) { + if (expr.kind === 69 /* Identifier */ && token === 34 /* EqualsGreaterThanToken */) { return parseSimpleArrowFunctionExpression(expr); } // Now see if we might be in cases '2' or '3'. @@ -9543,7 +9718,7 @@ var ts; return parseConditionalExpressionRest(expr); } function isYieldExpression() { - if (token === 112 /* YieldKeyword */) { + if (token === 114 /* YieldKeyword */) { // If we have a 'yield' keyword, and htis is a context where yield expressions are // allowed, then definitely parse out a yield expression. if (inYieldContext()) { @@ -9572,7 +9747,7 @@ var ts; return !scanner.hasPrecedingLineBreak() && isIdentifier(); } function parseYieldExpression() { - var node = createNode(182 /* YieldExpression */); + var node = createNode(184 /* YieldExpression */); // YieldExpression[In] : // yield // yield [no LineTerminator here] [Lexical goal InputElementRegExp]AssignmentExpression[?In, Yield] @@ -9592,8 +9767,8 @@ var ts; } function parseSimpleArrowFunctionExpression(identifier) { ts.Debug.assert(token === 34 /* EqualsGreaterThanToken */, "parseSimpleArrowFunctionExpression should only have been called if we had a =>"); - var node = createNode(172 /* ArrowFunction */, identifier.pos); - var parameter = createNode(136 /* Parameter */, identifier.pos); + var node = createNode(174 /* ArrowFunction */, identifier.pos); + var parameter = createNode(138 /* Parameter */, identifier.pos); parameter.name = identifier; finishNode(parameter); node.parameters = [parameter]; @@ -9635,7 +9810,7 @@ var ts; // Unknown -> There *might* be a parenthesized arrow function here. // Speculatively look ahead to be sure, and rollback if not. function isParenthesizedArrowFunctionExpression() { - if (token === 17 /* OpenParenToken */ || token === 25 /* LessThanToken */ || token === 116 /* AsyncKeyword */) { + if (token === 17 /* OpenParenToken */ || token === 25 /* LessThanToken */ || token === 118 /* AsyncKeyword */) { return lookAhead(isParenthesizedArrowFunctionExpressionWorker); } if (token === 34 /* EqualsGreaterThanToken */) { @@ -9648,7 +9823,7 @@ var ts; return 0 /* False */; } function isParenthesizedArrowFunctionExpressionWorker() { - if (token === 116 /* AsyncKeyword */) { + if (token === 118 /* AsyncKeyword */) { nextToken(); if (scanner.hasPrecedingLineBreak()) { return 0 /* False */; @@ -9668,7 +9843,7 @@ var ts; var third = nextToken(); switch (third) { case 34 /* EqualsGreaterThanToken */: - case 53 /* ColonToken */: + case 54 /* ColonToken */: case 15 /* OpenBraceToken */: return 1 /* True */; default: @@ -9699,7 +9874,7 @@ var ts; } // If we have something like "(a:", then we must have a // type-annotated parameter in an arrow function expression. - if (nextToken() === 53 /* ColonToken */) { + if (nextToken() === 54 /* ColonToken */) { return 1 /* True */; } // This *could* be a parenthesized arrow function. @@ -9717,10 +9892,10 @@ var ts; if (sourceFile.languageVariant === 1 /* JSX */) { var isArrowFunctionInJsx = lookAhead(function () { var third = nextToken(); - if (third === 81 /* ExtendsKeyword */) { + if (third === 83 /* ExtendsKeyword */) { var fourth = nextToken(); switch (fourth) { - case 55 /* EqualsToken */: + case 56 /* EqualsToken */: case 27 /* GreaterThanToken */: return false; default: @@ -9745,7 +9920,7 @@ var ts; return parseParenthesizedArrowFunctionExpressionHead(/*allowAmbiguity*/ false); } function parseParenthesizedArrowFunctionExpressionHead(allowAmbiguity) { - var node = createNode(172 /* ArrowFunction */); + var node = createNode(174 /* ArrowFunction */); setModifiers(node, parseModifiersForArrowFunction()); var isAsync = !!(node.flags & 512 /* Async */); // Arrow functions are never generators. @@ -9755,7 +9930,7 @@ var ts; // a => (b => c) // And think that "(b =>" was actually a parenthesized arrow function with a missing // close paren. - fillSignature(53 /* ColonToken */, /*yieldContext*/ false, /*awaitContext*/ isAsync, /*requireCompleteParameterList*/ !allowAmbiguity, node); + fillSignature(54 /* ColonToken */, /*yieldContext*/ false, /*awaitContext*/ isAsync, /*requireCompleteParameterList*/ !allowAmbiguity, node); // If we couldn't get parameters, we definitely could not parse out an arrow function. if (!node.parameters) { return undefined; @@ -9779,8 +9954,8 @@ var ts; return parseFunctionBlock(/*allowYield*/ false, /*allowAwait*/ isAsync, /*ignoreMissingOpenBrace*/ false); } if (token !== 23 /* SemicolonToken */ && - token !== 85 /* FunctionKeyword */ && - token !== 71 /* ClassKeyword */ && + token !== 87 /* FunctionKeyword */ && + token !== 73 /* ClassKeyword */ && isStartOfStatement() && !isStartOfExpressionStatement()) { // Check if we got a plain statement (i.e. no expression-statements, no function/class expressions/declarations) @@ -9805,17 +9980,17 @@ var ts; } function parseConditionalExpressionRest(leftOperand) { // Note: we are passed in an expression which was produced from parseBinaryExpressionOrHigher. - var questionToken = parseOptionalToken(52 /* QuestionToken */); + var questionToken = parseOptionalToken(53 /* QuestionToken */); if (!questionToken) { return leftOperand; } // Note: we explicitly 'allowIn' in the whenTrue part of the condition expression, and // we do not that for the 'whenFalse' part. - var node = createNode(180 /* ConditionalExpression */, leftOperand.pos); + var node = createNode(182 /* ConditionalExpression */, leftOperand.pos); node.condition = leftOperand; node.questionToken = questionToken; node.whenTrue = doOutsideOfContext(disallowInAndDecoratorContext, parseAssignmentExpressionOrHigher); - node.colonToken = parseExpectedToken(53 /* ColonToken */, /*reportAtCurrentPosition*/ false, ts.Diagnostics._0_expected, ts.tokenToString(53 /* ColonToken */)); + node.colonToken = parseExpectedToken(54 /* ColonToken */, /*reportAtCurrentPosition*/ false, ts.Diagnostics._0_expected, ts.tokenToString(54 /* ColonToken */)); node.whenFalse = parseAssignmentExpressionOrHigher(); return finishNode(node); } @@ -9824,7 +9999,7 @@ var ts; return parseBinaryExpressionRest(precedence, leftOperand); } function isInOrOfKeyword(t) { - return t === 88 /* InKeyword */ || t === 132 /* OfKeyword */; + return t === 90 /* InKeyword */ || t === 134 /* OfKeyword */; } function parseBinaryExpressionRest(precedence, leftOperand) { while (true) { @@ -9833,13 +10008,36 @@ var ts; reScanGreaterToken(); var newPrecedence = getBinaryOperatorPrecedence(); // Check the precedence to see if we should "take" this operator - if (newPrecedence <= precedence) { + // - For left associative operator (all operator but **), consume the operator, + // recursively call the function below, and parse binaryExpression as a rightOperand + // of the caller if the new precendence of the operator is greater then or equal to the current precendence. + // For example: + // a - b - c; + // ^token; leftOperand = b. Return b to the caller as a rightOperand + // a * b - c + // ^token; leftOperand = b. Return b to the caller as a rightOperand + // a - b * c; + // ^token; leftOperand = b. Return b * c to the caller as a rightOperand + // - For right associative operator (**), consume the operator, recursively call the function + // and parse binaryExpression as a rightOperand of the caller if the new precendence of + // the operator is strictly grater than the current precendence + // For example: + // a ** b ** c; + // ^^token; leftOperand = b. Return b ** c to the caller as a rightOperand + // a - b ** c; + // ^^token; leftOperand = b. Return b ** c to the caller as a rightOperand + // a ** b - c + // ^token; leftOperand = b. Return b to the caller as a rightOperand + var consumeCurrentOperator = token === 38 /* AsteriskAsteriskToken */ ? + newPrecedence >= precedence : + newPrecedence > precedence; + if (!consumeCurrentOperator) { break; } - if (token === 88 /* InKeyword */ && inDisallowInContext()) { + if (token === 90 /* InKeyword */ && inDisallowInContext()) { break; } - if (token === 114 /* AsKeyword */) { + if (token === 116 /* AsKeyword */) { // Make sure we *do* perform ASI for constructs like this: // var x = foo // as (Bar) @@ -9860,22 +10058,22 @@ var ts; return leftOperand; } function isBinaryOperator() { - if (inDisallowInContext() && token === 88 /* InKeyword */) { + if (inDisallowInContext() && token === 90 /* InKeyword */) { return false; } return getBinaryOperatorPrecedence() > 0; } function getBinaryOperatorPrecedence() { switch (token) { - case 51 /* BarBarToken */: + case 52 /* BarBarToken */: return 1; - case 50 /* AmpersandAmpersandToken */: + case 51 /* AmpersandAmpersandToken */: return 2; - case 46 /* BarToken */: + case 47 /* BarToken */: return 3; - case 47 /* CaretToken */: + case 48 /* CaretToken */: return 4; - case 45 /* AmpersandToken */: + case 46 /* AmpersandToken */: return 5; case 30 /* EqualsEqualsToken */: case 31 /* ExclamationEqualsToken */: @@ -9886,66 +10084,68 @@ var ts; case 27 /* GreaterThanToken */: case 28 /* LessThanEqualsToken */: case 29 /* GreaterThanEqualsToken */: - case 89 /* InstanceOfKeyword */: - case 88 /* InKeyword */: - case 114 /* AsKeyword */: + case 91 /* InstanceOfKeyword */: + case 90 /* InKeyword */: + case 116 /* AsKeyword */: return 7; - case 42 /* LessThanLessThanToken */: - case 43 /* GreaterThanGreaterThanToken */: - case 44 /* GreaterThanGreaterThanGreaterThanToken */: + case 43 /* LessThanLessThanToken */: + case 44 /* GreaterThanGreaterThanToken */: + case 45 /* GreaterThanGreaterThanGreaterThanToken */: return 8; case 35 /* PlusToken */: case 36 /* MinusToken */: return 9; case 37 /* AsteriskToken */: - case 38 /* SlashToken */: - case 39 /* PercentToken */: + case 39 /* SlashToken */: + case 40 /* PercentToken */: return 10; + case 38 /* AsteriskAsteriskToken */: + return 11; } // -1 is lower than all other precedences. Returning it will cause binary expression // parsing to stop. return -1; } function makeBinaryExpression(left, operatorToken, right) { - var node = createNode(179 /* BinaryExpression */, left.pos); + var node = createNode(181 /* BinaryExpression */, left.pos); node.left = left; node.operatorToken = operatorToken; node.right = right; return finishNode(node); } function makeAsExpression(left, right) { - var node = createNode(187 /* AsExpression */, left.pos); + var node = createNode(189 /* AsExpression */, left.pos); node.expression = left; node.type = right; return finishNode(node); } function parsePrefixUnaryExpression() { - var node = createNode(177 /* PrefixUnaryExpression */); + var node = createNode(179 /* PrefixUnaryExpression */); node.operator = token; nextToken(); - node.operand = parseUnaryExpressionOrHigher(); + node.operand = parseSimpleUnaryExpression(); return finishNode(node); } function parseDeleteExpression() { - var node = createNode(173 /* DeleteExpression */); + var node = createNode(175 /* DeleteExpression */); nextToken(); - node.expression = parseUnaryExpressionOrHigher(); + node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function parseTypeOfExpression() { - var node = createNode(174 /* TypeOfExpression */); + var node = createNode(176 /* TypeOfExpression */); nextToken(); - node.expression = parseUnaryExpressionOrHigher(); + node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function parseVoidExpression() { - var node = createNode(175 /* VoidExpression */); + var node = createNode(177 /* VoidExpression */); nextToken(); - node.expression = parseUnaryExpressionOrHigher(); + node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function isAwaitExpression() { - if (token === 117 /* AwaitKeyword */) { + if (token === 119 /* AwaitKeyword */) { if (inAwaitContext()) { return true; } @@ -9955,46 +10155,137 @@ var ts; return false; } function parseAwaitExpression() { - var node = createNode(176 /* AwaitExpression */); + var node = createNode(178 /* AwaitExpression */); nextToken(); - node.expression = parseUnaryExpressionOrHigher(); + node.expression = parseSimpleUnaryExpression(); return finishNode(node); } + /** + * Parse ES7 unary expression and await expression + * + * ES7 UnaryExpression: + * 1) SimpleUnaryExpression[?yield] + * 2) IncrementExpression[?yield] ** UnaryExpression[?yield] + */ function parseUnaryExpressionOrHigher() { if (isAwaitExpression()) { return parseAwaitExpression(); } + if (isIncrementExpression()) { + var incrementExpression = parseIncrementExpression(); + return token === 38 /* AsteriskAsteriskToken */ ? + parseBinaryExpressionRest(getBinaryOperatorPrecedence(), incrementExpression) : + incrementExpression; + } + var unaryOperator = token; + var simpleUnaryExpression = parseSimpleUnaryExpression(); + if (token === 38 /* AsteriskAsteriskToken */) { + var diagnostic; + var start = ts.skipTrivia(sourceText, simpleUnaryExpression.pos); + if (simpleUnaryExpression.kind === 171 /* TypeAssertionExpression */) { + parseErrorAtPosition(start, simpleUnaryExpression.end - start, ts.Diagnostics.A_type_assertion_expression_is_not_allowed_in_the_left_hand_side_of_an_exponentiation_expression_Consider_enclosing_the_expression_in_parentheses); + } + else { + parseErrorAtPosition(start, simpleUnaryExpression.end - start, ts.Diagnostics.An_unary_expression_with_the_0_operator_is_not_allowed_in_the_left_hand_side_of_an_exponentiation_expression_Consider_enclosing_the_expression_in_parentheses, ts.tokenToString(unaryOperator)); + } + } + return simpleUnaryExpression; + } + /** + * Parse ES7 simple-unary expression or higher: + * + * ES7 SimpleUnaryExpression: + * 1) IncrementExpression[?yield] + * 2) delete UnaryExpression[?yield] + * 3) void UnaryExpression[?yield] + * 4) typeof UnaryExpression[?yield] + * 5) + UnaryExpression[?yield] + * 6) - UnaryExpression[?yield] + * 7) ~ UnaryExpression[?yield] + * 8) ! UnaryExpression[?yield] + */ + function parseSimpleUnaryExpression() { switch (token) { case 35 /* PlusToken */: case 36 /* MinusToken */: - case 49 /* TildeToken */: - case 48 /* ExclamationToken */: - case 40 /* PlusPlusToken */: - case 41 /* MinusMinusToken */: + case 50 /* TildeToken */: + case 49 /* ExclamationToken */: return parsePrefixUnaryExpression(); - case 76 /* DeleteKeyword */: + case 78 /* DeleteKeyword */: return parseDeleteExpression(); - case 99 /* TypeOfKeyword */: + case 101 /* TypeOfKeyword */: return parseTypeOfExpression(); - case 101 /* VoidKeyword */: + case 103 /* VoidKeyword */: return parseVoidExpression(); case 25 /* LessThanToken */: - if (sourceFile.languageVariant !== 1 /* JSX */) { - return parseTypeAssertion(); - } - if (lookAhead(nextTokenIsIdentifierOrKeyword)) { - return parseJsxElementOrSelfClosingElement(/*inExpressionContext*/ true); - } - // Fall through + // This is modified UnaryExpression grammar in TypeScript + // UnaryExpression (modified): + // < type > UnaryExpression + return parseTypeAssertion(); default: - return parsePostfixExpressionOrHigher(); + return parseIncrementExpression(); } } - function parsePostfixExpressionOrHigher() { + /** + * Check if the current token can possibly be an ES7 increment expression. + * + * ES7 IncrementExpression: + * LeftHandSideExpression[?Yield] + * LeftHandSideExpression[?Yield][no LineTerminator here]++ + * LeftHandSideExpression[?Yield][no LineTerminator here]-- + * ++LeftHandSideExpression[?Yield] + * --LeftHandSideExpression[?Yield] + */ + function isIncrementExpression() { + // This function is called inside parseUnaryExpression to decide + // whether to call parseSimpleUnaryExpression or call parseIncrmentExpression directly + switch (token) { + case 35 /* PlusToken */: + case 36 /* MinusToken */: + case 50 /* TildeToken */: + case 49 /* ExclamationToken */: + case 78 /* DeleteKeyword */: + case 101 /* TypeOfKeyword */: + case 103 /* VoidKeyword */: + return false; + case 25 /* LessThanToken */: + // If we are not in JSX context, we are parsing TypeAssertion which is an UnaryExpression + if (sourceFile.languageVariant !== 1 /* JSX */) { + return false; + } + // We are in JSX context and the token is part of JSXElement. + // Fall through + default: + return true; + } + } + /** + * Parse ES7 IncrementExpression. IncrementExpression is used instead of ES6's PostFixExpression. + * + * ES7 IncrementExpression[yield]: + * 1) LeftHandSideExpression[?yield] + * 2) LeftHandSideExpression[?yield] [[no LineTerminator here]]++ + * 3) LeftHandSideExpression[?yield] [[no LineTerminator here]]-- + * 4) ++LeftHandSideExpression[?yield] + * 5) --LeftHandSideExpression[?yield] + * In TypeScript (2), (3) are parsed as PostfixUnaryExpression. (4), (5) are parsed as PrefixUnaryExpression + */ + function parseIncrementExpression() { + if (token === 41 /* PlusPlusToken */ || token === 42 /* MinusMinusToken */) { + var node = createNode(179 /* PrefixUnaryExpression */); + node.operator = token; + nextToken(); + node.operand = parseLeftHandSideExpressionOrHigher(); + return finishNode(node); + } + else if (sourceFile.languageVariant === 1 /* JSX */ && token === 25 /* LessThanToken */ && lookAhead(nextTokenIsIdentifierOrKeyword)) { + // JSXElement is part of primaryExpression + return parseJsxElementOrSelfClosingElement(/*inExpressionContext*/ true); + } var expression = parseLeftHandSideExpressionOrHigher(); ts.Debug.assert(ts.isLeftHandSideExpression(expression)); - if ((token === 40 /* PlusPlusToken */ || token === 41 /* MinusMinusToken */) && !scanner.hasPrecedingLineBreak()) { - var node = createNode(178 /* PostfixUnaryExpression */, expression.pos); + if ((token === 41 /* PlusPlusToken */ || token === 42 /* MinusMinusToken */) && !scanner.hasPrecedingLineBreak()) { + var node = createNode(180 /* PostfixUnaryExpression */, expression.pos); node.operand = expression; node.operator = token; nextToken(); @@ -10033,7 +10324,7 @@ var ts; // the last two CallExpression productions. Or we have a MemberExpression which either // completes the LeftHandSideExpression, or starts the beginning of the first four // CallExpression productions. - var expression = token === 93 /* SuperKeyword */ + var expression = token === 95 /* SuperKeyword */ ? parseSuperExpression() : parseMemberExpressionOrHigher(); // Now, we *may* be complete. However, we might have consumed the start of a @@ -10098,7 +10389,7 @@ var ts; } // If we have seen "super" it must be followed by '(' or '.'. // If it wasn't then just try to parse out a '.' and report an error. - var node = createNode(164 /* PropertyAccessExpression */, expression.pos); + var node = createNode(166 /* PropertyAccessExpression */, expression.pos); node.expression = expression; node.dotToken = parseExpectedToken(21 /* DotToken */, /*reportAtCurrentPosition*/ false, ts.Diagnostics.super_must_be_followed_by_an_argument_list_or_member_access); node.name = parseRightSideOfDot(/*allowIdentifierNames*/ true); @@ -10106,27 +10397,27 @@ var ts; } function parseJsxElementOrSelfClosingElement(inExpressionContext) { var opening = parseJsxOpeningOrSelfClosingElement(inExpressionContext); - if (opening.kind === 233 /* JsxOpeningElement */) { - var node = createNode(231 /* JsxElement */, opening.pos); + if (opening.kind === 235 /* JsxOpeningElement */) { + var node = createNode(233 /* JsxElement */, opening.pos); node.openingElement = opening; node.children = parseJsxChildren(node.openingElement.tagName); node.closingElement = parseJsxClosingElement(inExpressionContext); return finishNode(node); } else { - ts.Debug.assert(opening.kind === 232 /* JsxSelfClosingElement */); + ts.Debug.assert(opening.kind === 234 /* JsxSelfClosingElement */); // Nothing else to do for self-closing elements return opening; } } function parseJsxText() { - var node = createNode(234 /* JsxText */, scanner.getStartPos()); + var node = createNode(236 /* JsxText */, scanner.getStartPos()); token = scanner.scanJsxToken(); return finishNode(node); } function parseJsxChild() { switch (token) { - case 234 /* JsxText */: + case 236 /* JsxText */: return parseJsxText(); case 15 /* OpenBraceToken */: return parseJsxExpression(/*inExpressionContext*/ false); @@ -10165,11 +10456,11 @@ var ts; // Closing tag, so scan the immediately-following text with the JSX scanning instead // of regular scanning to avoid treating illegal characters (e.g. '#') as immediate // scanning errors - node = createNode(233 /* JsxOpeningElement */, fullStart); + node = createNode(235 /* JsxOpeningElement */, fullStart); scanJsxText(); } else { - parseExpected(38 /* SlashToken */); + parseExpected(39 /* SlashToken */); if (inExpressionContext) { parseExpected(27 /* GreaterThanToken */); } @@ -10177,7 +10468,7 @@ var ts; parseExpected(27 /* GreaterThanToken */, /*diagnostic*/ undefined, /*advance*/ false); scanJsxText(); } - node = createNode(232 /* JsxSelfClosingElement */, fullStart); + node = createNode(234 /* JsxSelfClosingElement */, fullStart); } node.tagName = tagName; node.attributes = attributes; @@ -10188,7 +10479,7 @@ var ts; var elementName = parseIdentifierName(); while (parseOptional(21 /* DotToken */)) { scanJsxIdentifier(); - var node = createNode(133 /* QualifiedName */, elementName.pos); + var node = createNode(135 /* QualifiedName */, elementName.pos); node.left = elementName; node.right = parseIdentifierName(); elementName = finishNode(node); @@ -10196,7 +10487,7 @@ var ts; return elementName; } function parseJsxExpression(inExpressionContext) { - var node = createNode(238 /* JsxExpression */); + var node = createNode(240 /* JsxExpression */); parseExpected(15 /* OpenBraceToken */); if (token !== 16 /* CloseBraceToken */) { node.expression = parseExpression(); @@ -10215,9 +10506,9 @@ var ts; return parseJsxSpreadAttribute(); } scanJsxIdentifier(); - var node = createNode(236 /* JsxAttribute */); + var node = createNode(238 /* JsxAttribute */); node.name = parseIdentifierName(); - if (parseOptional(55 /* EqualsToken */)) { + if (parseOptional(56 /* EqualsToken */)) { switch (token) { case 9 /* StringLiteral */: node.initializer = parseLiteralNode(); @@ -10230,7 +10521,7 @@ var ts; return finishNode(node); } function parseJsxSpreadAttribute() { - var node = createNode(237 /* JsxSpreadAttribute */); + var node = createNode(239 /* JsxSpreadAttribute */); parseExpected(15 /* OpenBraceToken */); parseExpected(22 /* DotDotDotToken */); node.expression = parseExpression(); @@ -10238,7 +10529,7 @@ var ts; return finishNode(node); } function parseJsxClosingElement(inExpressionContext) { - var node = createNode(235 /* JsxClosingElement */); + var node = createNode(237 /* JsxClosingElement */); parseExpected(26 /* LessThanSlashToken */); node.tagName = parseJsxElementName(); if (inExpressionContext) { @@ -10251,18 +10542,18 @@ var ts; return finishNode(node); } function parseTypeAssertion() { - var node = createNode(169 /* TypeAssertionExpression */); + var node = createNode(171 /* TypeAssertionExpression */); parseExpected(25 /* LessThanToken */); node.type = parseType(); parseExpected(27 /* GreaterThanToken */); - node.expression = parseUnaryExpressionOrHigher(); + node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function parseMemberExpressionRest(expression) { while (true) { var dotToken = parseOptionalToken(21 /* DotToken */); if (dotToken) { - var propertyAccess = createNode(164 /* PropertyAccessExpression */, expression.pos); + var propertyAccess = createNode(166 /* PropertyAccessExpression */, expression.pos); propertyAccess.expression = expression; propertyAccess.dotToken = dotToken; propertyAccess.name = parseRightSideOfDot(/*allowIdentifierNames*/ true); @@ -10271,7 +10562,7 @@ var ts; } // when in the [Decorator] context, we do not parse ElementAccess as it could be part of a ComputedPropertyName if (!inDecoratorContext() && parseOptional(19 /* OpenBracketToken */)) { - var indexedAccess = createNode(165 /* ElementAccessExpression */, expression.pos); + var indexedAccess = createNode(167 /* ElementAccessExpression */, expression.pos); indexedAccess.expression = expression; // It's not uncommon for a user to write: "new Type[]". // Check for that common pattern and report a better error message. @@ -10287,7 +10578,7 @@ var ts; continue; } if (token === 11 /* NoSubstitutionTemplateLiteral */ || token === 12 /* TemplateHead */) { - var tagExpression = createNode(168 /* TaggedTemplateExpression */, expression.pos); + var tagExpression = createNode(170 /* TaggedTemplateExpression */, expression.pos); tagExpression.tag = expression; tagExpression.template = token === 11 /* NoSubstitutionTemplateLiteral */ ? parseLiteralNode() @@ -10310,7 +10601,7 @@ var ts; if (!typeArguments) { return expression; } - var callExpr = createNode(166 /* CallExpression */, expression.pos); + var callExpr = createNode(168 /* CallExpression */, expression.pos); callExpr.expression = expression; callExpr.typeArguments = typeArguments; callExpr.arguments = parseArgumentList(); @@ -10318,7 +10609,7 @@ var ts; continue; } else if (token === 17 /* OpenParenToken */) { - var callExpr = createNode(166 /* CallExpression */, expression.pos); + var callExpr = createNode(168 /* CallExpression */, expression.pos); callExpr.expression = expression; callExpr.arguments = parseArgumentList(); expression = finishNode(callExpr); @@ -10356,18 +10647,18 @@ var ts; case 21 /* DotToken */: // foo. case 18 /* CloseParenToken */: // foo) case 20 /* CloseBracketToken */: // foo] - case 53 /* ColonToken */: // foo: + case 54 /* ColonToken */: // foo: case 23 /* SemicolonToken */: // foo; - case 52 /* QuestionToken */: // foo? + case 53 /* QuestionToken */: // foo? case 30 /* EqualsEqualsToken */: // foo == case 32 /* EqualsEqualsEqualsToken */: // foo === case 31 /* ExclamationEqualsToken */: // foo != case 33 /* ExclamationEqualsEqualsToken */: // foo !== - case 50 /* AmpersandAmpersandToken */: // foo && - case 51 /* BarBarToken */: // foo || - case 47 /* CaretToken */: // foo ^ - case 45 /* AmpersandToken */: // foo & - case 46 /* BarToken */: // foo | + case 51 /* AmpersandAmpersandToken */: // foo && + case 52 /* BarBarToken */: // foo || + case 48 /* CaretToken */: // foo ^ + case 46 /* AmpersandToken */: // foo & + case 47 /* BarToken */: // foo | case 16 /* CloseBraceToken */: // foo } case 1 /* EndOfFileToken */: // these cases can't legally follow a type arg list. However, they're not legal @@ -10390,11 +10681,11 @@ var ts; case 9 /* StringLiteral */: case 11 /* NoSubstitutionTemplateLiteral */: return parseLiteralNode(); - case 95 /* ThisKeyword */: - case 93 /* SuperKeyword */: - case 91 /* NullKeyword */: - case 97 /* TrueKeyword */: - case 82 /* FalseKeyword */: + case 97 /* ThisKeyword */: + case 95 /* SuperKeyword */: + case 93 /* NullKeyword */: + case 99 /* TrueKeyword */: + case 84 /* FalseKeyword */: return parseTokenNode(); case 17 /* OpenParenToken */: return parseParenthesizedExpression(); @@ -10402,7 +10693,7 @@ var ts; return parseArrayLiteralExpression(); case 15 /* OpenBraceToken */: return parseObjectLiteralExpression(); - case 116 /* AsyncKeyword */: + case 118 /* AsyncKeyword */: // Async arrow functions are parsed earlier in parseAssignmentExpressionOrHigher. // If we encounter `async [no LineTerminator here] function` then this is an async // function; otherwise, its an identifier. @@ -10410,14 +10701,14 @@ var ts; break; } return parseFunctionExpression(); - case 71 /* ClassKeyword */: + case 73 /* ClassKeyword */: return parseClassExpression(); - case 85 /* FunctionKeyword */: + case 87 /* FunctionKeyword */: return parseFunctionExpression(); - case 90 /* NewKeyword */: + case 92 /* NewKeyword */: return parseNewExpression(); - case 38 /* SlashToken */: - case 59 /* SlashEqualsToken */: + case 39 /* SlashToken */: + case 61 /* SlashEqualsToken */: if (reScanSlashToken() === 10 /* RegularExpressionLiteral */) { return parseLiteralNode(); } @@ -10428,28 +10719,28 @@ var ts; return parseIdentifier(ts.Diagnostics.Expression_expected); } function parseParenthesizedExpression() { - var node = createNode(170 /* ParenthesizedExpression */); + var node = createNode(172 /* ParenthesizedExpression */); parseExpected(17 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); parseExpected(18 /* CloseParenToken */); return finishNode(node); } function parseSpreadElement() { - var node = createNode(183 /* SpreadElementExpression */); + var node = createNode(185 /* SpreadElementExpression */); parseExpected(22 /* DotDotDotToken */); node.expression = parseAssignmentExpressionOrHigher(); return finishNode(node); } function parseArgumentOrArrayLiteralElement() { return token === 22 /* DotDotDotToken */ ? parseSpreadElement() : - token === 24 /* CommaToken */ ? createNode(185 /* OmittedExpression */) : + token === 24 /* CommaToken */ ? createNode(187 /* OmittedExpression */) : parseAssignmentExpressionOrHigher(); } function parseArgumentExpression() { return doOutsideOfContext(disallowInAndDecoratorContext, parseArgumentOrArrayLiteralElement); } function parseArrayLiteralExpression() { - var node = createNode(162 /* ArrayLiteralExpression */); + var node = createNode(164 /* ArrayLiteralExpression */); parseExpected(19 /* OpenBracketToken */); if (scanner.hasPrecedingLineBreak()) node.flags |= 2048 /* MultiLine */; @@ -10458,11 +10749,11 @@ var ts; return finishNode(node); } function tryParseAccessorDeclaration(fullStart, decorators, modifiers) { - if (parseContextualModifier(121 /* GetKeyword */)) { - return parseAccessorDeclaration(143 /* GetAccessor */, fullStart, decorators, modifiers); + if (parseContextualModifier(123 /* GetKeyword */)) { + return parseAccessorDeclaration(145 /* GetAccessor */, fullStart, decorators, modifiers); } - else if (parseContextualModifier(127 /* SetKeyword */)) { - return parseAccessorDeclaration(144 /* SetAccessor */, fullStart, decorators, modifiers); + else if (parseContextualModifier(129 /* SetKeyword */)) { + return parseAccessorDeclaration(146 /* SetAccessor */, fullStart, decorators, modifiers); } return undefined; } @@ -10479,28 +10770,38 @@ var ts; var nameToken = token; var propertyName = parsePropertyName(); // Disallowing of optional property assignments happens in the grammar checker. - var questionToken = parseOptionalToken(52 /* QuestionToken */); + var questionToken = parseOptionalToken(53 /* QuestionToken */); if (asteriskToken || token === 17 /* OpenParenToken */ || token === 25 /* LessThanToken */) { return parseMethodDeclaration(fullStart, decorators, modifiers, asteriskToken, propertyName, questionToken); } - // Parse to check if it is short-hand property assignment or normal property assignment - if ((token === 24 /* CommaToken */ || token === 16 /* CloseBraceToken */) && tokenIsIdentifier) { - var shorthandDeclaration = createNode(244 /* ShorthandPropertyAssignment */, fullStart); + // check if it is short-hand property assignment or normal property assignment + // NOTE: if token is EqualsToken it is interpreted as CoverInitializedName production + // CoverInitializedName[Yield] : + // IdentifierReference[?Yield] Initializer[In, ?Yield] + // this is necessary because ObjectLiteral productions are also used to cover grammar for ObjectAssignmentPattern + var isShorthandPropertyAssignment = tokenIsIdentifier && (token === 24 /* CommaToken */ || token === 16 /* CloseBraceToken */ || token === 56 /* EqualsToken */); + if (isShorthandPropertyAssignment) { + var shorthandDeclaration = createNode(246 /* ShorthandPropertyAssignment */, fullStart); shorthandDeclaration.name = propertyName; shorthandDeclaration.questionToken = questionToken; + var equalsToken = parseOptionalToken(56 /* EqualsToken */); + if (equalsToken) { + shorthandDeclaration.equalsToken = equalsToken; + shorthandDeclaration.objectAssignmentInitializer = allowInAnd(parseAssignmentExpressionOrHigher); + } return finishNode(shorthandDeclaration); } else { - var propertyAssignment = createNode(243 /* PropertyAssignment */, fullStart); + var propertyAssignment = createNode(245 /* PropertyAssignment */, fullStart); propertyAssignment.name = propertyName; propertyAssignment.questionToken = questionToken; - parseExpected(53 /* ColonToken */); + parseExpected(54 /* ColonToken */); propertyAssignment.initializer = allowInAnd(parseAssignmentExpressionOrHigher); return finishNode(propertyAssignment); } } function parseObjectLiteralExpression() { - var node = createNode(163 /* ObjectLiteralExpression */); + var node = createNode(165 /* ObjectLiteralExpression */); parseExpected(15 /* OpenBraceToken */); if (scanner.hasPrecedingLineBreak()) { node.flags |= 2048 /* MultiLine */; @@ -10519,9 +10820,9 @@ var ts; if (saveDecoratorContext) { setDecoratorContext(false); } - var node = createNode(171 /* FunctionExpression */); + var node = createNode(173 /* FunctionExpression */); setModifiers(node, parseModifiers()); - parseExpected(85 /* FunctionKeyword */); + parseExpected(87 /* FunctionKeyword */); node.asteriskToken = parseOptionalToken(37 /* AsteriskToken */); var isGenerator = !!node.asteriskToken; var isAsync = !!(node.flags & 512 /* Async */); @@ -10530,7 +10831,7 @@ var ts; isGenerator ? doInYieldContext(parseOptionalIdentifier) : isAsync ? doInAwaitContext(parseOptionalIdentifier) : parseOptionalIdentifier(); - fillSignature(53 /* ColonToken */, /*yieldContext*/ isGenerator, /*awaitContext*/ isAsync, /*requireCompleteParameterList*/ false, node); + fillSignature(54 /* ColonToken */, /*yieldContext*/ isGenerator, /*awaitContext*/ isAsync, /*requireCompleteParameterList*/ false, node); node.body = parseFunctionBlock(/*allowYield*/ isGenerator, /*allowAwait*/ isAsync, /*ignoreMissingOpenBrace*/ false); if (saveDecoratorContext) { setDecoratorContext(true); @@ -10541,8 +10842,8 @@ var ts; return isIdentifier() ? parseIdentifier() : undefined; } function parseNewExpression() { - var node = createNode(167 /* NewExpression */); - parseExpected(90 /* NewKeyword */); + var node = createNode(169 /* NewExpression */); + parseExpected(92 /* NewKeyword */); node.expression = parseMemberExpressionOrHigher(); node.typeArguments = tryParse(parseTypeArgumentsInExpression); if (node.typeArguments || token === 17 /* OpenParenToken */) { @@ -10552,7 +10853,7 @@ var ts; } // STATEMENTS function parseBlock(ignoreMissingOpenBrace, diagnosticMessage) { - var node = createNode(190 /* Block */); + var node = createNode(192 /* Block */); if (parseExpected(15 /* OpenBraceToken */, diagnosticMessage) || ignoreMissingOpenBrace) { node.statements = parseList(1 /* BlockStatements */, parseStatement); parseExpected(16 /* CloseBraceToken */); @@ -10582,25 +10883,25 @@ var ts; return block; } function parseEmptyStatement() { - var node = createNode(192 /* EmptyStatement */); + var node = createNode(194 /* EmptyStatement */); parseExpected(23 /* SemicolonToken */); return finishNode(node); } function parseIfStatement() { - var node = createNode(194 /* IfStatement */); - parseExpected(86 /* IfKeyword */); + var node = createNode(196 /* IfStatement */); + parseExpected(88 /* IfKeyword */); parseExpected(17 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); parseExpected(18 /* CloseParenToken */); node.thenStatement = parseStatement(); - node.elseStatement = parseOptional(78 /* ElseKeyword */) ? parseStatement() : undefined; + node.elseStatement = parseOptional(80 /* ElseKeyword */) ? parseStatement() : undefined; return finishNode(node); } function parseDoStatement() { - var node = createNode(195 /* DoStatement */); - parseExpected(77 /* DoKeyword */); + var node = createNode(197 /* DoStatement */); + parseExpected(79 /* DoKeyword */); node.statement = parseStatement(); - parseExpected(102 /* WhileKeyword */); + parseExpected(104 /* WhileKeyword */); parseExpected(17 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); parseExpected(18 /* CloseParenToken */); @@ -10612,8 +10913,8 @@ var ts; return finishNode(node); } function parseWhileStatement() { - var node = createNode(196 /* WhileStatement */); - parseExpected(102 /* WhileKeyword */); + var node = createNode(198 /* WhileStatement */); + parseExpected(104 /* WhileKeyword */); parseExpected(17 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); parseExpected(18 /* CloseParenToken */); @@ -10622,11 +10923,11 @@ var ts; } function parseForOrForInOrForOfStatement() { var pos = getNodePos(); - parseExpected(84 /* ForKeyword */); + parseExpected(86 /* ForKeyword */); parseExpected(17 /* OpenParenToken */); var initializer = undefined; if (token !== 23 /* SemicolonToken */) { - if (token === 100 /* VarKeyword */ || token === 106 /* LetKeyword */ || token === 72 /* ConstKeyword */) { + if (token === 102 /* VarKeyword */ || token === 108 /* LetKeyword */ || token === 74 /* ConstKeyword */) { initializer = parseVariableDeclarationList(/*inForStatementInitializer*/ true); } else { @@ -10634,22 +10935,22 @@ var ts; } } var forOrForInOrForOfStatement; - if (parseOptional(88 /* InKeyword */)) { - var forInStatement = createNode(198 /* ForInStatement */, pos); + if (parseOptional(90 /* InKeyword */)) { + var forInStatement = createNode(200 /* ForInStatement */, pos); forInStatement.initializer = initializer; forInStatement.expression = allowInAnd(parseExpression); parseExpected(18 /* CloseParenToken */); forOrForInOrForOfStatement = forInStatement; } - else if (parseOptional(132 /* OfKeyword */)) { - var forOfStatement = createNode(199 /* ForOfStatement */, pos); + else if (parseOptional(134 /* OfKeyword */)) { + var forOfStatement = createNode(201 /* ForOfStatement */, pos); forOfStatement.initializer = initializer; forOfStatement.expression = allowInAnd(parseAssignmentExpressionOrHigher); parseExpected(18 /* CloseParenToken */); forOrForInOrForOfStatement = forOfStatement; } else { - var forStatement = createNode(197 /* ForStatement */, pos); + var forStatement = createNode(199 /* ForStatement */, pos); forStatement.initializer = initializer; parseExpected(23 /* SemicolonToken */); if (token !== 23 /* SemicolonToken */ && token !== 18 /* CloseParenToken */) { @@ -10667,7 +10968,7 @@ var ts; } function parseBreakOrContinueStatement(kind) { var node = createNode(kind); - parseExpected(kind === 201 /* BreakStatement */ ? 68 /* BreakKeyword */ : 73 /* ContinueKeyword */); + parseExpected(kind === 203 /* BreakStatement */ ? 70 /* BreakKeyword */ : 75 /* ContinueKeyword */); if (!canParseSemicolon()) { node.label = parseIdentifier(); } @@ -10675,8 +10976,8 @@ var ts; return finishNode(node); } function parseReturnStatement() { - var node = createNode(202 /* ReturnStatement */); - parseExpected(92 /* ReturnKeyword */); + var node = createNode(204 /* ReturnStatement */); + parseExpected(94 /* ReturnKeyword */); if (!canParseSemicolon()) { node.expression = allowInAnd(parseExpression); } @@ -10684,8 +10985,8 @@ var ts; return finishNode(node); } function parseWithStatement() { - var node = createNode(203 /* WithStatement */); - parseExpected(103 /* WithKeyword */); + var node = createNode(205 /* WithStatement */); + parseExpected(105 /* WithKeyword */); parseExpected(17 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); parseExpected(18 /* CloseParenToken */); @@ -10693,30 +10994,30 @@ var ts; return finishNode(node); } function parseCaseClause() { - var node = createNode(239 /* CaseClause */); - parseExpected(69 /* CaseKeyword */); + var node = createNode(241 /* CaseClause */); + parseExpected(71 /* CaseKeyword */); node.expression = allowInAnd(parseExpression); - parseExpected(53 /* ColonToken */); + parseExpected(54 /* ColonToken */); node.statements = parseList(3 /* SwitchClauseStatements */, parseStatement); return finishNode(node); } function parseDefaultClause() { - var node = createNode(240 /* DefaultClause */); - parseExpected(75 /* DefaultKeyword */); - parseExpected(53 /* ColonToken */); + var node = createNode(242 /* DefaultClause */); + parseExpected(77 /* DefaultKeyword */); + parseExpected(54 /* ColonToken */); node.statements = parseList(3 /* SwitchClauseStatements */, parseStatement); return finishNode(node); } function parseCaseOrDefaultClause() { - return token === 69 /* CaseKeyword */ ? parseCaseClause() : parseDefaultClause(); + return token === 71 /* CaseKeyword */ ? parseCaseClause() : parseDefaultClause(); } function parseSwitchStatement() { - var node = createNode(204 /* SwitchStatement */); - parseExpected(94 /* SwitchKeyword */); + var node = createNode(206 /* SwitchStatement */); + parseExpected(96 /* SwitchKeyword */); parseExpected(17 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); parseExpected(18 /* CloseParenToken */); - var caseBlock = createNode(218 /* CaseBlock */, scanner.getStartPos()); + var caseBlock = createNode(220 /* CaseBlock */, scanner.getStartPos()); parseExpected(15 /* OpenBraceToken */); caseBlock.clauses = parseList(2 /* SwitchClauses */, parseCaseOrDefaultClause); parseExpected(16 /* CloseBraceToken */); @@ -10731,29 +11032,29 @@ var ts; // directly as that might consume an expression on the following line. // We just return 'undefined' in that case. The actual error will be reported in the // grammar walker. - var node = createNode(206 /* ThrowStatement */); - parseExpected(96 /* ThrowKeyword */); + var node = createNode(208 /* ThrowStatement */); + parseExpected(98 /* ThrowKeyword */); node.expression = scanner.hasPrecedingLineBreak() ? undefined : allowInAnd(parseExpression); parseSemicolon(); return finishNode(node); } // TODO: Review for error recovery function parseTryStatement() { - var node = createNode(207 /* TryStatement */); - parseExpected(98 /* TryKeyword */); + var node = createNode(209 /* TryStatement */); + parseExpected(100 /* TryKeyword */); node.tryBlock = parseBlock(/*ignoreMissingOpenBrace*/ false); - node.catchClause = token === 70 /* CatchKeyword */ ? parseCatchClause() : undefined; + node.catchClause = token === 72 /* CatchKeyword */ ? parseCatchClause() : undefined; // If we don't have a catch clause, then we must have a finally clause. Try to parse // one out no matter what. - if (!node.catchClause || token === 83 /* FinallyKeyword */) { - parseExpected(83 /* FinallyKeyword */); + if (!node.catchClause || token === 85 /* FinallyKeyword */) { + parseExpected(85 /* FinallyKeyword */); node.finallyBlock = parseBlock(/*ignoreMissingOpenBrace*/ false); } return finishNode(node); } function parseCatchClause() { - var result = createNode(242 /* CatchClause */); - parseExpected(70 /* CatchKeyword */); + var result = createNode(244 /* CatchClause */); + parseExpected(72 /* CatchKeyword */); if (parseExpected(17 /* OpenParenToken */)) { result.variableDeclaration = parseVariableDeclaration(); } @@ -10762,8 +11063,8 @@ var ts; return finishNode(result); } function parseDebuggerStatement() { - var node = createNode(208 /* DebuggerStatement */); - parseExpected(74 /* DebuggerKeyword */); + var node = createNode(210 /* DebuggerStatement */); + parseExpected(76 /* DebuggerKeyword */); parseSemicolon(); return finishNode(node); } @@ -10773,14 +11074,14 @@ var ts; // a colon. var fullStart = scanner.getStartPos(); var expression = allowInAnd(parseExpression); - if (expression.kind === 67 /* Identifier */ && parseOptional(53 /* ColonToken */)) { - var labeledStatement = createNode(205 /* LabeledStatement */, fullStart); + if (expression.kind === 69 /* Identifier */ && parseOptional(54 /* ColonToken */)) { + var labeledStatement = createNode(207 /* LabeledStatement */, fullStart); labeledStatement.label = expression; labeledStatement.statement = parseStatement(); return finishNode(labeledStatement); } else { - var expressionStatement = createNode(193 /* ExpressionStatement */, fullStart); + var expressionStatement = createNode(195 /* ExpressionStatement */, fullStart); expressionStatement.expression = expression; parseSemicolon(); return finishNode(expressionStatement); @@ -10792,7 +11093,7 @@ var ts; } function nextTokenIsFunctionKeywordOnSameLine() { nextToken(); - return token === 85 /* FunctionKeyword */ && !scanner.hasPrecedingLineBreak(); + return token === 87 /* FunctionKeyword */ && !scanner.hasPrecedingLineBreak(); } function nextTokenIsIdentifierOrKeywordOrNumberOnSameLine() { nextToken(); @@ -10801,12 +11102,12 @@ var ts; function isDeclaration() { while (true) { switch (token) { - case 100 /* VarKeyword */: - case 106 /* LetKeyword */: - case 72 /* ConstKeyword */: - case 85 /* FunctionKeyword */: - case 71 /* ClassKeyword */: - case 79 /* EnumKeyword */: + case 102 /* VarKeyword */: + case 108 /* LetKeyword */: + case 74 /* ConstKeyword */: + case 87 /* FunctionKeyword */: + case 73 /* ClassKeyword */: + case 81 /* EnumKeyword */: return true; // 'declare', 'module', 'namespace', 'interface'* and 'type' are all legal JavaScript identifiers; // however, an identifier cannot be followed by another identifier on the same line. This is what we @@ -10829,36 +11130,36 @@ var ts; // I {} // // could be legal, it would add complexity for very little gain. - case 105 /* InterfaceKeyword */: - case 130 /* TypeKeyword */: + case 107 /* InterfaceKeyword */: + case 132 /* TypeKeyword */: return nextTokenIsIdentifierOnSameLine(); - case 123 /* ModuleKeyword */: - case 124 /* NamespaceKeyword */: + case 125 /* ModuleKeyword */: + case 126 /* NamespaceKeyword */: return nextTokenIsIdentifierOrStringLiteralOnSameLine(); - case 116 /* AsyncKeyword */: - case 120 /* DeclareKeyword */: + case 115 /* AbstractKeyword */: + case 118 /* AsyncKeyword */: + case 122 /* DeclareKeyword */: + case 110 /* PrivateKeyword */: + case 111 /* ProtectedKeyword */: + case 112 /* PublicKeyword */: nextToken(); // ASI takes effect for this modifier. if (scanner.hasPrecedingLineBreak()) { return false; } continue; - case 87 /* ImportKeyword */: + case 89 /* ImportKeyword */: nextToken(); return token === 9 /* StringLiteral */ || token === 37 /* AsteriskToken */ || token === 15 /* OpenBraceToken */ || ts.tokenIsIdentifierOrKeyword(token); - case 80 /* ExportKeyword */: + case 82 /* ExportKeyword */: nextToken(); - if (token === 55 /* EqualsToken */ || token === 37 /* AsteriskToken */ || - token === 15 /* OpenBraceToken */ || token === 75 /* DefaultKeyword */) { + if (token === 56 /* EqualsToken */ || token === 37 /* AsteriskToken */ || + token === 15 /* OpenBraceToken */ || token === 77 /* DefaultKeyword */) { return true; } continue; - case 110 /* PublicKeyword */: - case 108 /* PrivateKeyword */: - case 109 /* ProtectedKeyword */: - case 111 /* StaticKeyword */: - case 113 /* AbstractKeyword */: + case 113 /* StaticKeyword */: nextToken(); continue; default: @@ -10871,47 +11172,47 @@ var ts; } function isStartOfStatement() { switch (token) { - case 54 /* AtToken */: + case 55 /* AtToken */: case 23 /* SemicolonToken */: case 15 /* OpenBraceToken */: - case 100 /* VarKeyword */: - case 106 /* LetKeyword */: - case 85 /* FunctionKeyword */: - case 71 /* ClassKeyword */: - case 79 /* EnumKeyword */: - case 86 /* IfKeyword */: - case 77 /* DoKeyword */: - case 102 /* WhileKeyword */: - case 84 /* ForKeyword */: - case 73 /* ContinueKeyword */: - case 68 /* BreakKeyword */: - case 92 /* ReturnKeyword */: - case 103 /* WithKeyword */: - case 94 /* SwitchKeyword */: - case 96 /* ThrowKeyword */: - case 98 /* TryKeyword */: - case 74 /* DebuggerKeyword */: + case 102 /* VarKeyword */: + case 108 /* LetKeyword */: + case 87 /* FunctionKeyword */: + case 73 /* ClassKeyword */: + case 81 /* EnumKeyword */: + case 88 /* IfKeyword */: + case 79 /* DoKeyword */: + case 104 /* WhileKeyword */: + case 86 /* ForKeyword */: + case 75 /* ContinueKeyword */: + case 70 /* BreakKeyword */: + case 94 /* ReturnKeyword */: + case 105 /* WithKeyword */: + case 96 /* SwitchKeyword */: + case 98 /* ThrowKeyword */: + case 100 /* TryKeyword */: + case 76 /* DebuggerKeyword */: // 'catch' and 'finally' do not actually indicate that the code is part of a statement, // however, we say they are here so that we may gracefully parse them and error later. - case 70 /* CatchKeyword */: - case 83 /* FinallyKeyword */: + case 72 /* CatchKeyword */: + case 85 /* FinallyKeyword */: return true; - case 72 /* ConstKeyword */: - case 80 /* ExportKeyword */: - case 87 /* ImportKeyword */: + case 74 /* ConstKeyword */: + case 82 /* ExportKeyword */: + case 89 /* ImportKeyword */: return isStartOfDeclaration(); - case 116 /* AsyncKeyword */: - case 120 /* DeclareKeyword */: - case 105 /* InterfaceKeyword */: - case 123 /* ModuleKeyword */: - case 124 /* NamespaceKeyword */: - case 130 /* TypeKeyword */: + case 118 /* AsyncKeyword */: + case 122 /* DeclareKeyword */: + case 107 /* InterfaceKeyword */: + case 125 /* ModuleKeyword */: + case 126 /* NamespaceKeyword */: + case 132 /* TypeKeyword */: // When these don't start a declaration, they're an identifier in an expression statement return true; - case 110 /* PublicKeyword */: - case 108 /* PrivateKeyword */: - case 109 /* ProtectedKeyword */: - case 111 /* StaticKeyword */: + case 112 /* PublicKeyword */: + case 110 /* PrivateKeyword */: + case 111 /* ProtectedKeyword */: + case 113 /* StaticKeyword */: // When these don't start a declaration, they may be the start of a class member if an identifier // immediately follows. Otherwise they're an identifier in an expression statement. return isStartOfDeclaration() || !lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine); @@ -10934,61 +11235,61 @@ var ts; return parseEmptyStatement(); case 15 /* OpenBraceToken */: return parseBlock(/*ignoreMissingOpenBrace*/ false); - case 100 /* VarKeyword */: + case 102 /* VarKeyword */: return parseVariableStatement(scanner.getStartPos(), /*decorators*/ undefined, /*modifiers*/ undefined); - case 106 /* LetKeyword */: + case 108 /* LetKeyword */: if (isLetDeclaration()) { return parseVariableStatement(scanner.getStartPos(), /*decorators*/ undefined, /*modifiers*/ undefined); } break; - case 85 /* FunctionKeyword */: + case 87 /* FunctionKeyword */: return parseFunctionDeclaration(scanner.getStartPos(), /*decorators*/ undefined, /*modifiers*/ undefined); - case 71 /* ClassKeyword */: + case 73 /* ClassKeyword */: return parseClassDeclaration(scanner.getStartPos(), /*decorators*/ undefined, /*modifiers*/ undefined); - case 86 /* IfKeyword */: + case 88 /* IfKeyword */: return parseIfStatement(); - case 77 /* DoKeyword */: + case 79 /* DoKeyword */: return parseDoStatement(); - case 102 /* WhileKeyword */: + case 104 /* WhileKeyword */: return parseWhileStatement(); - case 84 /* ForKeyword */: + case 86 /* ForKeyword */: return parseForOrForInOrForOfStatement(); - case 73 /* ContinueKeyword */: - return parseBreakOrContinueStatement(200 /* ContinueStatement */); - case 68 /* BreakKeyword */: - return parseBreakOrContinueStatement(201 /* BreakStatement */); - case 92 /* ReturnKeyword */: + case 75 /* ContinueKeyword */: + return parseBreakOrContinueStatement(202 /* ContinueStatement */); + case 70 /* BreakKeyword */: + return parseBreakOrContinueStatement(203 /* BreakStatement */); + case 94 /* ReturnKeyword */: return parseReturnStatement(); - case 103 /* WithKeyword */: + case 105 /* WithKeyword */: return parseWithStatement(); - case 94 /* SwitchKeyword */: + case 96 /* SwitchKeyword */: return parseSwitchStatement(); - case 96 /* ThrowKeyword */: + case 98 /* ThrowKeyword */: return parseThrowStatement(); - case 98 /* TryKeyword */: + case 100 /* TryKeyword */: // Include 'catch' and 'finally' for error recovery. - case 70 /* CatchKeyword */: - case 83 /* FinallyKeyword */: + case 72 /* CatchKeyword */: + case 85 /* FinallyKeyword */: return parseTryStatement(); - case 74 /* DebuggerKeyword */: + case 76 /* DebuggerKeyword */: return parseDebuggerStatement(); - case 54 /* AtToken */: + case 55 /* AtToken */: return parseDeclaration(); - case 116 /* AsyncKeyword */: - case 105 /* InterfaceKeyword */: - case 130 /* TypeKeyword */: - case 123 /* ModuleKeyword */: - case 124 /* NamespaceKeyword */: - case 120 /* DeclareKeyword */: - case 72 /* ConstKeyword */: - case 79 /* EnumKeyword */: - case 80 /* ExportKeyword */: - case 87 /* ImportKeyword */: - case 108 /* PrivateKeyword */: - case 109 /* ProtectedKeyword */: - case 110 /* PublicKeyword */: - case 113 /* AbstractKeyword */: - case 111 /* StaticKeyword */: + case 118 /* AsyncKeyword */: + case 107 /* InterfaceKeyword */: + case 132 /* TypeKeyword */: + case 125 /* ModuleKeyword */: + case 126 /* NamespaceKeyword */: + case 122 /* DeclareKeyword */: + case 74 /* ConstKeyword */: + case 81 /* EnumKeyword */: + case 82 /* ExportKeyword */: + case 89 /* ImportKeyword */: + case 110 /* PrivateKeyword */: + case 111 /* ProtectedKeyword */: + case 112 /* PublicKeyword */: + case 115 /* AbstractKeyword */: + case 113 /* StaticKeyword */: if (isStartOfDeclaration()) { return parseDeclaration(); } @@ -11001,35 +11302,35 @@ var ts; var decorators = parseDecorators(); var modifiers = parseModifiers(); switch (token) { - case 100 /* VarKeyword */: - case 106 /* LetKeyword */: - case 72 /* ConstKeyword */: + case 102 /* VarKeyword */: + case 108 /* LetKeyword */: + case 74 /* ConstKeyword */: return parseVariableStatement(fullStart, decorators, modifiers); - case 85 /* FunctionKeyword */: + case 87 /* FunctionKeyword */: return parseFunctionDeclaration(fullStart, decorators, modifiers); - case 71 /* ClassKeyword */: + case 73 /* ClassKeyword */: return parseClassDeclaration(fullStart, decorators, modifiers); - case 105 /* InterfaceKeyword */: + case 107 /* InterfaceKeyword */: return parseInterfaceDeclaration(fullStart, decorators, modifiers); - case 130 /* TypeKeyword */: + case 132 /* TypeKeyword */: return parseTypeAliasDeclaration(fullStart, decorators, modifiers); - case 79 /* EnumKeyword */: + case 81 /* EnumKeyword */: return parseEnumDeclaration(fullStart, decorators, modifiers); - case 123 /* ModuleKeyword */: - case 124 /* NamespaceKeyword */: + case 125 /* ModuleKeyword */: + case 126 /* NamespaceKeyword */: return parseModuleDeclaration(fullStart, decorators, modifiers); - case 87 /* ImportKeyword */: + case 89 /* ImportKeyword */: return parseImportDeclarationOrImportEqualsDeclaration(fullStart, decorators, modifiers); - case 80 /* ExportKeyword */: + case 82 /* ExportKeyword */: nextToken(); - return token === 75 /* DefaultKeyword */ || token === 55 /* EqualsToken */ ? + return token === 77 /* DefaultKeyword */ || token === 56 /* EqualsToken */ ? parseExportAssignment(fullStart, decorators, modifiers) : parseExportDeclaration(fullStart, decorators, modifiers); default: if (decorators || modifiers) { // We reached this point because we encountered decorators and/or modifiers and assumed a declaration // would follow. For recovery and error reporting purposes, return an incomplete declaration. - var node = createMissingNode(229 /* MissingDeclaration */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); + var node = createMissingNode(231 /* MissingDeclaration */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); node.pos = fullStart; node.decorators = decorators; setModifiers(node, modifiers); @@ -11051,24 +11352,24 @@ var ts; // DECLARATIONS function parseArrayBindingElement() { if (token === 24 /* CommaToken */) { - return createNode(185 /* OmittedExpression */); + return createNode(187 /* OmittedExpression */); } - var node = createNode(161 /* BindingElement */); + var node = createNode(163 /* BindingElement */); node.dotDotDotToken = parseOptionalToken(22 /* DotDotDotToken */); node.name = parseIdentifierOrPattern(); node.initializer = parseBindingElementInitializer(/*inParameter*/ false); return finishNode(node); } function parseObjectBindingElement() { - var node = createNode(161 /* BindingElement */); + var node = createNode(163 /* BindingElement */); // TODO(andersh): Handle computed properties var tokenIsIdentifier = isIdentifier(); var propertyName = parsePropertyName(); - if (tokenIsIdentifier && token !== 53 /* ColonToken */) { + if (tokenIsIdentifier && token !== 54 /* ColonToken */) { node.name = propertyName; } else { - parseExpected(53 /* ColonToken */); + parseExpected(54 /* ColonToken */); node.propertyName = propertyName; node.name = parseIdentifierOrPattern(); } @@ -11076,14 +11377,14 @@ var ts; return finishNode(node); } function parseObjectBindingPattern() { - var node = createNode(159 /* ObjectBindingPattern */); + var node = createNode(161 /* ObjectBindingPattern */); parseExpected(15 /* OpenBraceToken */); node.elements = parseDelimitedList(9 /* ObjectBindingElements */, parseObjectBindingElement); parseExpected(16 /* CloseBraceToken */); return finishNode(node); } function parseArrayBindingPattern() { - var node = createNode(160 /* ArrayBindingPattern */); + var node = createNode(162 /* ArrayBindingPattern */); parseExpected(19 /* OpenBracketToken */); node.elements = parseDelimitedList(10 /* ArrayBindingElements */, parseArrayBindingElement); parseExpected(20 /* CloseBracketToken */); @@ -11102,7 +11403,7 @@ var ts; return parseIdentifier(); } function parseVariableDeclaration() { - var node = createNode(209 /* VariableDeclaration */); + var node = createNode(211 /* VariableDeclaration */); node.name = parseIdentifierOrPattern(); node.type = parseTypeAnnotation(); if (!isInOrOfKeyword(token)) { @@ -11111,14 +11412,14 @@ var ts; return finishNode(node); } function parseVariableDeclarationList(inForStatementInitializer) { - var node = createNode(210 /* VariableDeclarationList */); + var node = createNode(212 /* VariableDeclarationList */); switch (token) { - case 100 /* VarKeyword */: + case 102 /* VarKeyword */: break; - case 106 /* LetKeyword */: + case 108 /* LetKeyword */: node.flags |= 16384 /* Let */; break; - case 72 /* ConstKeyword */: + case 74 /* ConstKeyword */: node.flags |= 32768 /* Const */; break; default: @@ -11134,7 +11435,7 @@ var ts; // So we need to look ahead to determine if 'of' should be treated as a keyword in // this context. // The checker will then give an error that there is an empty declaration list. - if (token === 132 /* OfKeyword */ && lookAhead(canFollowContextualOfKeyword)) { + if (token === 134 /* OfKeyword */ && lookAhead(canFollowContextualOfKeyword)) { node.declarations = createMissingList(); } else { @@ -11149,7 +11450,7 @@ var ts; return nextTokenIsIdentifier() && nextToken() === 18 /* CloseParenToken */; } function parseVariableStatement(fullStart, decorators, modifiers) { - var node = createNode(191 /* VariableStatement */, fullStart); + var node = createNode(193 /* VariableStatement */, fullStart); node.decorators = decorators; setModifiers(node, modifiers); node.declarationList = parseVariableDeclarationList(/*inForStatementInitializer*/ false); @@ -11157,29 +11458,29 @@ var ts; return finishNode(node); } function parseFunctionDeclaration(fullStart, decorators, modifiers) { - var node = createNode(211 /* FunctionDeclaration */, fullStart); + var node = createNode(213 /* FunctionDeclaration */, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - parseExpected(85 /* FunctionKeyword */); + parseExpected(87 /* FunctionKeyword */); node.asteriskToken = parseOptionalToken(37 /* AsteriskToken */); node.name = node.flags & 1024 /* Default */ ? parseOptionalIdentifier() : parseIdentifier(); var isGenerator = !!node.asteriskToken; var isAsync = !!(node.flags & 512 /* Async */); - fillSignature(53 /* ColonToken */, /*yieldContext*/ isGenerator, /*awaitContext*/ isAsync, /*requireCompleteParameterList*/ false, node); + fillSignature(54 /* ColonToken */, /*yieldContext*/ isGenerator, /*awaitContext*/ isAsync, /*requireCompleteParameterList*/ false, node); node.body = parseFunctionBlockOrSemicolon(isGenerator, isAsync, ts.Diagnostics.or_expected); return finishNode(node); } function parseConstructorDeclaration(pos, decorators, modifiers) { - var node = createNode(142 /* Constructor */, pos); + var node = createNode(144 /* Constructor */, pos); node.decorators = decorators; setModifiers(node, modifiers); - parseExpected(119 /* ConstructorKeyword */); - fillSignature(53 /* ColonToken */, /*yieldContext*/ false, /*awaitContext*/ false, /*requireCompleteParameterList*/ false, node); + parseExpected(121 /* ConstructorKeyword */); + fillSignature(54 /* ColonToken */, /*yieldContext*/ false, /*awaitContext*/ false, /*requireCompleteParameterList*/ false, node); node.body = parseFunctionBlockOrSemicolon(/*isGenerator*/ false, /*isAsync*/ false, ts.Diagnostics.or_expected); return finishNode(node); } function parseMethodDeclaration(fullStart, decorators, modifiers, asteriskToken, name, questionToken, diagnosticMessage) { - var method = createNode(141 /* MethodDeclaration */, fullStart); + var method = createNode(143 /* MethodDeclaration */, fullStart); method.decorators = decorators; setModifiers(method, modifiers); method.asteriskToken = asteriskToken; @@ -11187,12 +11488,12 @@ var ts; method.questionToken = questionToken; var isGenerator = !!asteriskToken; var isAsync = !!(method.flags & 512 /* Async */); - fillSignature(53 /* ColonToken */, /*yieldContext*/ isGenerator, /*awaitContext*/ isAsync, /*requireCompleteParameterList*/ false, method); + fillSignature(54 /* ColonToken */, /*yieldContext*/ isGenerator, /*awaitContext*/ isAsync, /*requireCompleteParameterList*/ false, method); method.body = parseFunctionBlockOrSemicolon(isGenerator, isAsync, diagnosticMessage); return finishNode(method); } function parsePropertyDeclaration(fullStart, decorators, modifiers, name, questionToken) { - var property = createNode(139 /* PropertyDeclaration */, fullStart); + var property = createNode(141 /* PropertyDeclaration */, fullStart); property.decorators = decorators; setModifiers(property, modifiers); property.name = name; @@ -11218,7 +11519,7 @@ var ts; var name = parsePropertyName(); // Note: this is not legal as per the grammar. But we allow it in the parser and // report an error in the grammar checker. - var questionToken = parseOptionalToken(52 /* QuestionToken */); + var questionToken = parseOptionalToken(53 /* QuestionToken */); if (asteriskToken || token === 17 /* OpenParenToken */ || token === 25 /* LessThanToken */) { return parseMethodDeclaration(fullStart, decorators, modifiers, asteriskToken, name, questionToken, ts.Diagnostics.or_expected); } @@ -11234,16 +11535,16 @@ var ts; node.decorators = decorators; setModifiers(node, modifiers); node.name = parsePropertyName(); - fillSignature(53 /* ColonToken */, /*yieldContext*/ false, /*awaitContext*/ false, /*requireCompleteParameterList*/ false, node); + fillSignature(54 /* ColonToken */, /*yieldContext*/ false, /*awaitContext*/ false, /*requireCompleteParameterList*/ false, node); node.body = parseFunctionBlockOrSemicolon(/*isGenerator*/ false, /*isAsync*/ false); return finishNode(node); } function isClassMemberModifier(idToken) { switch (idToken) { - case 110 /* PublicKeyword */: - case 108 /* PrivateKeyword */: - case 109 /* ProtectedKeyword */: - case 111 /* StaticKeyword */: + case 112 /* PublicKeyword */: + case 110 /* PrivateKeyword */: + case 111 /* ProtectedKeyword */: + case 113 /* StaticKeyword */: return true; default: return false; @@ -11251,7 +11552,7 @@ var ts; } function isClassMemberStart() { var idToken; - if (token === 54 /* AtToken */) { + if (token === 55 /* AtToken */) { return true; } // Eat up all modifiers, but hold on to the last one in case it is actually an identifier. @@ -11284,7 +11585,7 @@ var ts; // If we were able to get any potential identifier... if (idToken !== undefined) { // If we have a non-keyword identifier, or if we have an accessor, then it's safe to parse. - if (!ts.isKeyword(idToken) || idToken === 127 /* SetKeyword */ || idToken === 121 /* GetKeyword */) { + if (!ts.isKeyword(idToken) || idToken === 129 /* SetKeyword */ || idToken === 123 /* GetKeyword */) { return true; } // If it *is* a keyword, but not an accessor, check a little farther along @@ -11292,9 +11593,9 @@ var ts; switch (token) { case 17 /* OpenParenToken */: // Method declaration case 25 /* LessThanToken */: // Generic Method declaration - case 53 /* ColonToken */: // Type Annotation for declaration - case 55 /* EqualsToken */: // Initializer for declaration - case 52 /* QuestionToken */: + case 54 /* ColonToken */: // Type Annotation for declaration + case 56 /* EqualsToken */: // Initializer for declaration + case 53 /* QuestionToken */: return true; default: // Covers @@ -11311,14 +11612,14 @@ var ts; var decorators; while (true) { var decoratorStart = getNodePos(); - if (!parseOptional(54 /* AtToken */)) { + if (!parseOptional(55 /* AtToken */)) { break; } if (!decorators) { decorators = []; decorators.pos = scanner.getStartPos(); } - var decorator = createNode(137 /* Decorator */, decoratorStart); + var decorator = createNode(139 /* Decorator */, decoratorStart); decorator.expression = doInDecoratorContext(parseLeftHandSideExpressionOrHigher); decorators.push(finishNode(decorator)); } @@ -11352,7 +11653,7 @@ var ts; function parseModifiersForArrowFunction() { var flags = 0; var modifiers; - if (token === 116 /* AsyncKeyword */) { + if (token === 118 /* AsyncKeyword */) { var modifierStart = scanner.getStartPos(); var modifierKind = token; nextToken(); @@ -11367,7 +11668,7 @@ var ts; } function parseClassElement() { if (token === 23 /* SemicolonToken */) { - var result = createNode(189 /* SemicolonClassElement */); + var result = createNode(191 /* SemicolonClassElement */); nextToken(); return finishNode(result); } @@ -11378,7 +11679,7 @@ var ts; if (accessor) { return accessor; } - if (token === 119 /* ConstructorKeyword */) { + if (token === 121 /* ConstructorKeyword */) { return parseConstructorDeclaration(fullStart, decorators, modifiers); } if (isIndexSignature()) { @@ -11395,7 +11696,7 @@ var ts; } if (decorators || modifiers) { // treat this as a property declaration with a missing name. - var name_7 = createMissingNode(67 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); + var name_7 = createMissingNode(69 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); return parsePropertyDeclaration(fullStart, decorators, modifiers, name_7, /*questionToken*/ undefined); } // 'isClassMemberStart' should have hinted not to attempt parsing. @@ -11405,17 +11706,17 @@ var ts; return parseClassDeclarationOrExpression( /*fullStart*/ scanner.getStartPos(), /*decorators*/ undefined, - /*modifiers*/ undefined, 184 /* ClassExpression */); + /*modifiers*/ undefined, 186 /* ClassExpression */); } function parseClassDeclaration(fullStart, decorators, modifiers) { - return parseClassDeclarationOrExpression(fullStart, decorators, modifiers, 212 /* ClassDeclaration */); + return parseClassDeclarationOrExpression(fullStart, decorators, modifiers, 214 /* ClassDeclaration */); } function parseClassDeclarationOrExpression(fullStart, decorators, modifiers, kind) { var node = createNode(kind, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - parseExpected(71 /* ClassKeyword */); - node.name = parseOptionalIdentifier(); + parseExpected(73 /* ClassKeyword */); + node.name = parseNameOfClassDeclarationOrExpression(); node.typeParameters = parseTypeParameters(); node.heritageClauses = parseHeritageClauses(/*isClassHeritageClause*/ true); if (parseExpected(15 /* OpenBraceToken */)) { @@ -11429,6 +11730,19 @@ var ts; } return finishNode(node); } + function parseNameOfClassDeclarationOrExpression() { + // implements is a future reserved word so + // 'class implements' might mean either + // - class expression with omitted name, 'implements' starts heritage clause + // - class with name 'implements' + // 'isImplementsClause' helps to disambiguate between these two cases + return isIdentifier() && !isImplementsClause() + ? parseIdentifier() + : undefined; + } + function isImplementsClause() { + return token === 106 /* ImplementsKeyword */ && lookAhead(nextTokenIsIdentifierOrKeyword); + } function parseHeritageClauses(isClassHeritageClause) { // ClassTail[Yield,Await] : (Modified) See 14.5 // ClassHeritage[?Yield,?Await]opt { ClassBody[?Yield,?Await]opt } @@ -11441,8 +11755,8 @@ var ts; return parseList(20 /* HeritageClauses */, parseHeritageClause); } function parseHeritageClause() { - if (token === 81 /* ExtendsKeyword */ || token === 104 /* ImplementsKeyword */) { - var node = createNode(241 /* HeritageClause */); + if (token === 83 /* ExtendsKeyword */ || token === 106 /* ImplementsKeyword */) { + var node = createNode(243 /* HeritageClause */); node.token = token; nextToken(); node.types = parseDelimitedList(7 /* HeritageClauseElement */, parseExpressionWithTypeArguments); @@ -11451,7 +11765,7 @@ var ts; return undefined; } function parseExpressionWithTypeArguments() { - var node = createNode(186 /* ExpressionWithTypeArguments */); + var node = createNode(188 /* ExpressionWithTypeArguments */); node.expression = parseLeftHandSideExpressionOrHigher(); if (token === 25 /* LessThanToken */) { node.typeArguments = parseBracketedList(18 /* TypeArguments */, parseType, 25 /* LessThanToken */, 27 /* GreaterThanToken */); @@ -11459,16 +11773,16 @@ var ts; return finishNode(node); } function isHeritageClause() { - return token === 81 /* ExtendsKeyword */ || token === 104 /* ImplementsKeyword */; + return token === 83 /* ExtendsKeyword */ || token === 106 /* ImplementsKeyword */; } function parseClassMembers() { return parseList(5 /* ClassMembers */, parseClassElement); } function parseInterfaceDeclaration(fullStart, decorators, modifiers) { - var node = createNode(213 /* InterfaceDeclaration */, fullStart); + var node = createNode(215 /* InterfaceDeclaration */, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - parseExpected(105 /* InterfaceKeyword */); + parseExpected(107 /* InterfaceKeyword */); node.name = parseIdentifier(); node.typeParameters = parseTypeParameters(); node.heritageClauses = parseHeritageClauses(/*isClassHeritageClause*/ false); @@ -11476,13 +11790,13 @@ var ts; return finishNode(node); } function parseTypeAliasDeclaration(fullStart, decorators, modifiers) { - var node = createNode(214 /* TypeAliasDeclaration */, fullStart); + var node = createNode(216 /* TypeAliasDeclaration */, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - parseExpected(130 /* TypeKeyword */); + parseExpected(132 /* TypeKeyword */); node.name = parseIdentifier(); node.typeParameters = parseTypeParameters(); - parseExpected(55 /* EqualsToken */); + parseExpected(56 /* EqualsToken */); node.type = parseType(); parseSemicolon(); return finishNode(node); @@ -11492,16 +11806,16 @@ var ts; // ConstantEnumMemberSection, which starts at the beginning of an enum declaration // or any time an integer literal initializer is encountered. function parseEnumMember() { - var node = createNode(245 /* EnumMember */, scanner.getStartPos()); + var node = createNode(247 /* EnumMember */, scanner.getStartPos()); node.name = parsePropertyName(); node.initializer = allowInAnd(parseNonParameterInitializer); return finishNode(node); } function parseEnumDeclaration(fullStart, decorators, modifiers) { - var node = createNode(215 /* EnumDeclaration */, fullStart); + var node = createNode(217 /* EnumDeclaration */, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - parseExpected(79 /* EnumKeyword */); + parseExpected(81 /* EnumKeyword */); node.name = parseIdentifier(); if (parseExpected(15 /* OpenBraceToken */)) { node.members = parseDelimitedList(6 /* EnumMembers */, parseEnumMember); @@ -11513,7 +11827,7 @@ var ts; return finishNode(node); } function parseModuleBlock() { - var node = createNode(217 /* ModuleBlock */, scanner.getStartPos()); + var node = createNode(219 /* ModuleBlock */, scanner.getStartPos()); if (parseExpected(15 /* OpenBraceToken */)) { node.statements = parseList(1 /* BlockStatements */, parseStatement); parseExpected(16 /* CloseBraceToken */); @@ -11524,7 +11838,7 @@ var ts; return finishNode(node); } function parseModuleOrNamespaceDeclaration(fullStart, decorators, modifiers, flags) { - var node = createNode(216 /* ModuleDeclaration */, fullStart); + var node = createNode(218 /* ModuleDeclaration */, fullStart); // If we are parsing a dotted namespace name, we want to // propagate the 'Namespace' flag across the names if set. var namespaceFlag = flags & 131072 /* Namespace */; @@ -11538,7 +11852,7 @@ var ts; return finishNode(node); } function parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers) { - var node = createNode(216 /* ModuleDeclaration */, fullStart); + var node = createNode(218 /* ModuleDeclaration */, fullStart); node.decorators = decorators; setModifiers(node, modifiers); node.name = parseLiteralNode(/*internName*/ true); @@ -11547,11 +11861,11 @@ var ts; } function parseModuleDeclaration(fullStart, decorators, modifiers) { var flags = modifiers ? modifiers.flags : 0; - if (parseOptional(124 /* NamespaceKeyword */)) { + if (parseOptional(126 /* NamespaceKeyword */)) { flags |= 131072 /* Namespace */; } else { - parseExpected(123 /* ModuleKeyword */); + parseExpected(125 /* ModuleKeyword */); if (token === 9 /* StringLiteral */) { return parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers); } @@ -11559,42 +11873,42 @@ var ts; return parseModuleOrNamespaceDeclaration(fullStart, decorators, modifiers, flags); } function isExternalModuleReference() { - return token === 125 /* RequireKeyword */ && + return token === 127 /* RequireKeyword */ && lookAhead(nextTokenIsOpenParen); } function nextTokenIsOpenParen() { return nextToken() === 17 /* OpenParenToken */; } function nextTokenIsSlash() { - return nextToken() === 38 /* SlashToken */; + return nextToken() === 39 /* SlashToken */; } function nextTokenIsCommaOrFromKeyword() { nextToken(); return token === 24 /* CommaToken */ || - token === 131 /* FromKeyword */; + token === 133 /* FromKeyword */; } function parseImportDeclarationOrImportEqualsDeclaration(fullStart, decorators, modifiers) { - parseExpected(87 /* ImportKeyword */); + parseExpected(89 /* ImportKeyword */); var afterImportPos = scanner.getStartPos(); var identifier; if (isIdentifier()) { identifier = parseIdentifier(); - if (token !== 24 /* CommaToken */ && token !== 131 /* FromKeyword */) { + if (token !== 24 /* CommaToken */ && token !== 133 /* FromKeyword */) { // ImportEquals declaration of type: // import x = require("mod"); or // import x = M.x; - var importEqualsDeclaration = createNode(219 /* ImportEqualsDeclaration */, fullStart); + var importEqualsDeclaration = createNode(221 /* ImportEqualsDeclaration */, fullStart); importEqualsDeclaration.decorators = decorators; setModifiers(importEqualsDeclaration, modifiers); importEqualsDeclaration.name = identifier; - parseExpected(55 /* EqualsToken */); + parseExpected(56 /* EqualsToken */); importEqualsDeclaration.moduleReference = parseModuleReference(); parseSemicolon(); return finishNode(importEqualsDeclaration); } } // Import statement - var importDeclaration = createNode(220 /* ImportDeclaration */, fullStart); + var importDeclaration = createNode(222 /* ImportDeclaration */, fullStart); importDeclaration.decorators = decorators; setModifiers(importDeclaration, modifiers); // ImportDeclaration: @@ -11604,7 +11918,7 @@ var ts; token === 37 /* AsteriskToken */ || token === 15 /* OpenBraceToken */) { importDeclaration.importClause = parseImportClause(identifier, afterImportPos); - parseExpected(131 /* FromKeyword */); + parseExpected(133 /* FromKeyword */); } importDeclaration.moduleSpecifier = parseModuleSpecifier(); parseSemicolon(); @@ -11617,7 +11931,7 @@ var ts; // NamedImports // ImportedDefaultBinding, NameSpaceImport // ImportedDefaultBinding, NamedImports - var importClause = createNode(221 /* ImportClause */, fullStart); + var importClause = createNode(223 /* ImportClause */, fullStart); if (identifier) { // ImportedDefaultBinding: // ImportedBinding @@ -11627,7 +11941,7 @@ var ts; // parse namespace or named imports if (!importClause.name || parseOptional(24 /* CommaToken */)) { - importClause.namedBindings = token === 37 /* AsteriskToken */ ? parseNamespaceImport() : parseNamedImportsOrExports(223 /* NamedImports */); + importClause.namedBindings = token === 37 /* AsteriskToken */ ? parseNamespaceImport() : parseNamedImportsOrExports(225 /* NamedImports */); } return finishNode(importClause); } @@ -11637,8 +11951,8 @@ var ts; : parseEntityName(/*allowReservedWords*/ false); } function parseExternalModuleReference() { - var node = createNode(230 /* ExternalModuleReference */); - parseExpected(125 /* RequireKeyword */); + var node = createNode(232 /* ExternalModuleReference */); + parseExpected(127 /* RequireKeyword */); parseExpected(17 /* OpenParenToken */); node.expression = parseModuleSpecifier(); parseExpected(18 /* CloseParenToken */); @@ -11659,9 +11973,9 @@ var ts; function parseNamespaceImport() { // NameSpaceImport: // * as ImportedBinding - var namespaceImport = createNode(222 /* NamespaceImport */); + var namespaceImport = createNode(224 /* NamespaceImport */); parseExpected(37 /* AsteriskToken */); - parseExpected(114 /* AsKeyword */); + parseExpected(116 /* AsKeyword */); namespaceImport.name = parseIdentifier(); return finishNode(namespaceImport); } @@ -11674,14 +11988,14 @@ var ts; // ImportsList: // ImportSpecifier // ImportsList, ImportSpecifier - node.elements = parseBracketedList(21 /* ImportOrExportSpecifiers */, kind === 223 /* NamedImports */ ? parseImportSpecifier : parseExportSpecifier, 15 /* OpenBraceToken */, 16 /* CloseBraceToken */); + node.elements = parseBracketedList(21 /* ImportOrExportSpecifiers */, kind === 225 /* NamedImports */ ? parseImportSpecifier : parseExportSpecifier, 15 /* OpenBraceToken */, 16 /* CloseBraceToken */); return finishNode(node); } function parseExportSpecifier() { - return parseImportOrExportSpecifier(228 /* ExportSpecifier */); + return parseImportOrExportSpecifier(230 /* ExportSpecifier */); } function parseImportSpecifier() { - return parseImportOrExportSpecifier(224 /* ImportSpecifier */); + return parseImportOrExportSpecifier(226 /* ImportSpecifier */); } function parseImportOrExportSpecifier(kind) { var node = createNode(kind); @@ -11695,9 +12009,9 @@ var ts; var checkIdentifierStart = scanner.getTokenPos(); var checkIdentifierEnd = scanner.getTextPos(); var identifierName = parseIdentifierName(); - if (token === 114 /* AsKeyword */) { + if (token === 116 /* AsKeyword */) { node.propertyName = identifierName; - parseExpected(114 /* AsKeyword */); + parseExpected(116 /* AsKeyword */); checkIdentifierIsKeyword = ts.isKeyword(token) && !isIdentifier(); checkIdentifierStart = scanner.getTokenPos(); checkIdentifierEnd = scanner.getTextPos(); @@ -11706,27 +12020,27 @@ var ts; else { node.name = identifierName; } - if (kind === 224 /* ImportSpecifier */ && checkIdentifierIsKeyword) { + if (kind === 226 /* ImportSpecifier */ && checkIdentifierIsKeyword) { // Report error identifier expected parseErrorAtPosition(checkIdentifierStart, checkIdentifierEnd - checkIdentifierStart, ts.Diagnostics.Identifier_expected); } return finishNode(node); } function parseExportDeclaration(fullStart, decorators, modifiers) { - var node = createNode(226 /* ExportDeclaration */, fullStart); + var node = createNode(228 /* ExportDeclaration */, fullStart); node.decorators = decorators; setModifiers(node, modifiers); if (parseOptional(37 /* AsteriskToken */)) { - parseExpected(131 /* FromKeyword */); + parseExpected(133 /* FromKeyword */); node.moduleSpecifier = parseModuleSpecifier(); } else { - node.exportClause = parseNamedImportsOrExports(227 /* NamedExports */); + node.exportClause = parseNamedImportsOrExports(229 /* NamedExports */); // It is not uncommon to accidentally omit the 'from' keyword. Additionally, in editing scenarios, // the 'from' keyword can be parsed as a named export when the export clause is unterminated (i.e. `export { from "moduleName";`) // If we don't have a 'from' keyword, see if we have a string literal such that ASI won't take effect. - if (token === 131 /* FromKeyword */ || (token === 9 /* StringLiteral */ && !scanner.hasPrecedingLineBreak())) { - parseExpected(131 /* FromKeyword */); + if (token === 133 /* FromKeyword */ || (token === 9 /* StringLiteral */ && !scanner.hasPrecedingLineBreak())) { + parseExpected(133 /* FromKeyword */); node.moduleSpecifier = parseModuleSpecifier(); } } @@ -11734,14 +12048,14 @@ var ts; return finishNode(node); } function parseExportAssignment(fullStart, decorators, modifiers) { - var node = createNode(225 /* ExportAssignment */, fullStart); + var node = createNode(227 /* ExportAssignment */, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - if (parseOptional(55 /* EqualsToken */)) { + if (parseOptional(56 /* EqualsToken */)) { node.isExportEquals = true; } else { - parseExpected(75 /* DefaultKeyword */); + parseExpected(77 /* DefaultKeyword */); } node.expression = parseAssignmentExpressionOrHigher(); parseSemicolon(); @@ -11807,10 +12121,10 @@ var ts; function setExternalModuleIndicator(sourceFile) { sourceFile.externalModuleIndicator = ts.forEach(sourceFile.statements, function (node) { return node.flags & 1 /* Export */ - || node.kind === 219 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 230 /* ExternalModuleReference */ - || node.kind === 220 /* ImportDeclaration */ - || node.kind === 225 /* ExportAssignment */ - || node.kind === 226 /* ExportDeclaration */ + || node.kind === 221 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 232 /* ExternalModuleReference */ + || node.kind === 222 /* ImportDeclaration */ + || node.kind === 227 /* ExportAssignment */ + || node.kind === 228 /* ExportDeclaration */ ? node : undefined; }); @@ -11856,22 +12170,22 @@ var ts; function isJSDocType() { switch (token) { case 37 /* AsteriskToken */: - case 52 /* QuestionToken */: + case 53 /* QuestionToken */: case 17 /* OpenParenToken */: case 19 /* OpenBracketToken */: - case 48 /* ExclamationToken */: + case 49 /* ExclamationToken */: case 15 /* OpenBraceToken */: - case 85 /* FunctionKeyword */: + case 87 /* FunctionKeyword */: case 22 /* DotDotDotToken */: - case 90 /* NewKeyword */: - case 95 /* ThisKeyword */: + case 92 /* NewKeyword */: + case 97 /* ThisKeyword */: return true; } return ts.tokenIsIdentifierOrKeyword(token); } JSDocParser.isJSDocType = isJSDocType; function parseJSDocTypeExpressionForTests(content, start, length) { - initializeState("file.js", content, 2 /* Latest */, /*_syntaxCursor:*/ undefined); + initializeState("file.js", content, 2 /* Latest */, /*isJavaScriptFile*/ true, /*_syntaxCursor:*/ undefined); var jsDocTypeExpression = parseJSDocTypeExpression(start, length); var diagnostics = parseDiagnostics; clearState(); @@ -11885,7 +12199,7 @@ var ts; scanner.setText(sourceText, start, length); // Prime the first token for us to start processing. token = nextToken(); - var result = createNode(247 /* JSDocTypeExpression */); + var result = createNode(249 /* JSDocTypeExpression */); parseExpected(15 /* OpenBraceToken */); result.type = parseJSDocTopLevelType(); parseExpected(16 /* CloseBraceToken */); @@ -11895,13 +12209,13 @@ var ts; JSDocParser.parseJSDocTypeExpression = parseJSDocTypeExpression; function parseJSDocTopLevelType() { var type = parseJSDocType(); - if (token === 46 /* BarToken */) { - var unionType = createNode(251 /* JSDocUnionType */, type.pos); + if (token === 47 /* BarToken */) { + var unionType = createNode(253 /* JSDocUnionType */, type.pos); unionType.types = parseJSDocTypeList(type); type = finishNode(unionType); } - if (token === 55 /* EqualsToken */) { - var optionalType = createNode(258 /* JSDocOptionalType */, type.pos); + if (token === 56 /* EqualsToken */) { + var optionalType = createNode(260 /* JSDocOptionalType */, type.pos); nextToken(); optionalType.type = type; type = finishNode(optionalType); @@ -11912,20 +12226,20 @@ var ts; var type = parseBasicTypeExpression(); while (true) { if (token === 19 /* OpenBracketToken */) { - var arrayType = createNode(250 /* JSDocArrayType */, type.pos); + var arrayType = createNode(252 /* JSDocArrayType */, type.pos); arrayType.elementType = type; nextToken(); parseExpected(20 /* CloseBracketToken */); type = finishNode(arrayType); } - else if (token === 52 /* QuestionToken */) { - var nullableType = createNode(253 /* JSDocNullableType */, type.pos); + else if (token === 53 /* QuestionToken */) { + var nullableType = createNode(255 /* JSDocNullableType */, type.pos); nullableType.type = type; nextToken(); type = finishNode(nullableType); } - else if (token === 48 /* ExclamationToken */) { - var nonNullableType = createNode(254 /* JSDocNonNullableType */, type.pos); + else if (token === 49 /* ExclamationToken */) { + var nonNullableType = createNode(256 /* JSDocNonNullableType */, type.pos); nonNullableType.type = type; nextToken(); type = finishNode(nonNullableType); @@ -11940,80 +12254,80 @@ var ts; switch (token) { case 37 /* AsteriskToken */: return parseJSDocAllType(); - case 52 /* QuestionToken */: + case 53 /* QuestionToken */: return parseJSDocUnknownOrNullableType(); case 17 /* OpenParenToken */: return parseJSDocUnionType(); case 19 /* OpenBracketToken */: return parseJSDocTupleType(); - case 48 /* ExclamationToken */: + case 49 /* ExclamationToken */: return parseJSDocNonNullableType(); case 15 /* OpenBraceToken */: return parseJSDocRecordType(); - case 85 /* FunctionKeyword */: + case 87 /* FunctionKeyword */: return parseJSDocFunctionType(); case 22 /* DotDotDotToken */: return parseJSDocVariadicType(); - case 90 /* NewKeyword */: + case 92 /* NewKeyword */: return parseJSDocConstructorType(); - case 95 /* ThisKeyword */: + case 97 /* ThisKeyword */: return parseJSDocThisType(); - case 115 /* AnyKeyword */: - case 128 /* StringKeyword */: - case 126 /* NumberKeyword */: - case 118 /* BooleanKeyword */: - case 129 /* SymbolKeyword */: - case 101 /* VoidKeyword */: + case 117 /* AnyKeyword */: + case 130 /* StringKeyword */: + case 128 /* NumberKeyword */: + case 120 /* BooleanKeyword */: + case 131 /* SymbolKeyword */: + case 103 /* VoidKeyword */: return parseTokenNode(); } return parseJSDocTypeReference(); } function parseJSDocThisType() { - var result = createNode(262 /* JSDocThisType */); + var result = createNode(264 /* JSDocThisType */); nextToken(); - parseExpected(53 /* ColonToken */); + parseExpected(54 /* ColonToken */); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocConstructorType() { - var result = createNode(261 /* JSDocConstructorType */); + var result = createNode(263 /* JSDocConstructorType */); nextToken(); - parseExpected(53 /* ColonToken */); + parseExpected(54 /* ColonToken */); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocVariadicType() { - var result = createNode(260 /* JSDocVariadicType */); + var result = createNode(262 /* JSDocVariadicType */); nextToken(); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocFunctionType() { - var result = createNode(259 /* JSDocFunctionType */); + var result = createNode(261 /* JSDocFunctionType */); nextToken(); parseExpected(17 /* OpenParenToken */); result.parameters = parseDelimitedList(22 /* JSDocFunctionParameters */, parseJSDocParameter); checkForTrailingComma(result.parameters); parseExpected(18 /* CloseParenToken */); - if (token === 53 /* ColonToken */) { + if (token === 54 /* ColonToken */) { nextToken(); result.type = parseJSDocType(); } return finishNode(result); } function parseJSDocParameter() { - var parameter = createNode(136 /* Parameter */); + var parameter = createNode(138 /* Parameter */); parameter.type = parseJSDocType(); return finishNode(parameter); } function parseJSDocOptionalType(type) { - var result = createNode(258 /* JSDocOptionalType */, type.pos); + var result = createNode(260 /* JSDocOptionalType */, type.pos); nextToken(); result.type = type; return finishNode(result); } function parseJSDocTypeReference() { - var result = createNode(257 /* JSDocTypeReference */); + var result = createNode(259 /* JSDocTypeReference */); result.name = parseSimplePropertyName(); while (parseOptional(21 /* DotToken */)) { if (token === 25 /* LessThanToken */) { @@ -12043,13 +12357,13 @@ var ts; } } function parseQualifiedName(left) { - var result = createNode(133 /* QualifiedName */, left.pos); + var result = createNode(135 /* QualifiedName */, left.pos); result.left = left; result.right = parseIdentifierName(); return finishNode(result); } function parseJSDocRecordType() { - var result = createNode(255 /* JSDocRecordType */); + var result = createNode(257 /* JSDocRecordType */); nextToken(); result.members = parseDelimitedList(24 /* JSDocRecordMembers */, parseJSDocRecordMember); checkForTrailingComma(result.members); @@ -12057,22 +12371,22 @@ var ts; return finishNode(result); } function parseJSDocRecordMember() { - var result = createNode(256 /* JSDocRecordMember */); + var result = createNode(258 /* JSDocRecordMember */); result.name = parseSimplePropertyName(); - if (token === 53 /* ColonToken */) { + if (token === 54 /* ColonToken */) { nextToken(); result.type = parseJSDocType(); } return finishNode(result); } function parseJSDocNonNullableType() { - var result = createNode(254 /* JSDocNonNullableType */); + var result = createNode(256 /* JSDocNonNullableType */); nextToken(); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocTupleType() { - var result = createNode(252 /* JSDocTupleType */); + var result = createNode(254 /* JSDocTupleType */); nextToken(); result.types = parseDelimitedList(25 /* JSDocTupleTypes */, parseJSDocType); checkForTrailingComma(result.types); @@ -12086,7 +12400,7 @@ var ts; } } function parseJSDocUnionType() { - var result = createNode(251 /* JSDocUnionType */); + var result = createNode(253 /* JSDocUnionType */); nextToken(); result.types = parseJSDocTypeList(parseJSDocType()); parseExpected(18 /* CloseParenToken */); @@ -12097,14 +12411,14 @@ var ts; var types = []; types.pos = firstType.pos; types.push(firstType); - while (parseOptional(46 /* BarToken */)) { + while (parseOptional(47 /* BarToken */)) { types.push(parseJSDocType()); } types.end = scanner.getStartPos(); return types; } function parseJSDocAllType() { - var result = createNode(248 /* JSDocAllType */); + var result = createNode(250 /* JSDocAllType */); nextToken(); return finishNode(result); } @@ -12125,19 +12439,19 @@ var ts; token === 16 /* CloseBraceToken */ || token === 18 /* CloseParenToken */ || token === 27 /* GreaterThanToken */ || - token === 55 /* EqualsToken */ || - token === 46 /* BarToken */) { - var result = createNode(249 /* JSDocUnknownType */, pos); + token === 56 /* EqualsToken */ || + token === 47 /* BarToken */) { + var result = createNode(251 /* JSDocUnknownType */, pos); return finishNode(result); } else { - var result = createNode(253 /* JSDocNullableType */, pos); + var result = createNode(255 /* JSDocNullableType */, pos); result.type = parseJSDocType(); return finishNode(result); } } function parseIsolatedJSDocComment(content, start, length) { - initializeState("file.js", content, 2 /* Latest */, /*_syntaxCursor:*/ undefined); + initializeState("file.js", content, 2 /* Latest */, /*isJavaScriptFile*/ true, /*_syntaxCursor:*/ undefined); var jsDocComment = parseJSDocComment(/*parent:*/ undefined, start, length); var diagnostics = parseDiagnostics; clearState(); @@ -12219,7 +12533,7 @@ var ts; if (!tags) { return undefined; } - var result = createNode(263 /* JSDocComment */, start); + var result = createNode(265 /* JSDocComment */, start); result.tags = tags; return finishNode(result, end); } @@ -12230,7 +12544,7 @@ var ts; } function parseTag() { ts.Debug.assert(content.charCodeAt(pos - 1) === 64 /* at */); - var atToken = createNode(54 /* AtToken */, pos - 1); + var atToken = createNode(55 /* AtToken */, pos - 1); atToken.end = pos; var tagName = scanIdentifier(); if (!tagName) { @@ -12256,7 +12570,7 @@ var ts; return undefined; } function handleUnknownTag(atToken, tagName) { - var result = createNode(264 /* JSDocTag */, atToken.pos); + var result = createNode(266 /* JSDocTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; return finishNode(result, pos); @@ -12307,7 +12621,7 @@ var ts; if (!typeExpression) { typeExpression = tryParseTypeExpression(); } - var result = createNode(265 /* JSDocParameterTag */, atToken.pos); + var result = createNode(267 /* JSDocParameterTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.preParameterName = preName; @@ -12317,27 +12631,27 @@ var ts; return finishNode(result, pos); } function handleReturnTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 266 /* JSDocReturnTag */; })) { + if (ts.forEach(tags, function (t) { return t.kind === 268 /* JSDocReturnTag */; })) { parseErrorAtPosition(tagName.pos, pos - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); } - var result = createNode(266 /* JSDocReturnTag */, atToken.pos); + var result = createNode(268 /* JSDocReturnTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeExpression = tryParseTypeExpression(); return finishNode(result, pos); } function handleTypeTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 267 /* JSDocTypeTag */; })) { + if (ts.forEach(tags, function (t) { return t.kind === 269 /* JSDocTypeTag */; })) { parseErrorAtPosition(tagName.pos, pos - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); } - var result = createNode(267 /* JSDocTypeTag */, atToken.pos); + var result = createNode(269 /* JSDocTypeTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeExpression = tryParseTypeExpression(); return finishNode(result, pos); } function handleTemplateTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 268 /* JSDocTemplateTag */; })) { + if (ts.forEach(tags, function (t) { return t.kind === 270 /* JSDocTemplateTag */; })) { parseErrorAtPosition(tagName.pos, pos - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); } var typeParameters = []; @@ -12350,7 +12664,7 @@ var ts; parseErrorAtPosition(startPos, 0, ts.Diagnostics.Identifier_expected); return undefined; } - var typeParameter = createNode(135 /* TypeParameter */, name_8.pos); + var typeParameter = createNode(137 /* TypeParameter */, name_8.pos); typeParameter.name = name_8; finishNode(typeParameter, pos); typeParameters.push(typeParameter); @@ -12361,7 +12675,7 @@ var ts; pos++; } typeParameters.end = pos; - var result = createNode(268 /* JSDocTemplateTag */, atToken.pos); + var result = createNode(270 /* JSDocTemplateTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeParameters = typeParameters; @@ -12382,7 +12696,7 @@ var ts; if (startPos === pos) { return undefined; } - var result = createNode(67 /* Identifier */, startPos); + var result = createNode(69 /* Identifier */, startPos); result.text = content.substring(startPos, pos); return finishNode(result, pos); } @@ -12505,7 +12819,7 @@ var ts; switch (node.kind) { case 9 /* StringLiteral */: case 8 /* NumericLiteral */: - case 67 /* Identifier */: + case 69 /* Identifier */: return true; } return false; @@ -12898,17 +13212,19 @@ var ts; var Type = ts.objectAllocator.getTypeConstructor(); var Signature = ts.objectAllocator.getSignatureConstructor(); var typeCount = 0; + var symbolCount = 0; var emptyArray = []; var emptySymbols = {}; var compilerOptions = host.getCompilerOptions(); var languageVersion = compilerOptions.target || 0 /* ES3 */; + var modulekind = compilerOptions.module ? compilerOptions.module : languageVersion === 2 /* ES6 */ ? 5 /* ES6 */ : 0 /* None */; var emitResolver = createResolver(); var undefinedSymbol = createSymbol(4 /* Property */ | 67108864 /* Transient */, "undefined"); var argumentsSymbol = createSymbol(4 /* Property */ | 67108864 /* Transient */, "arguments"); var checker = { getNodeCount: function () { return ts.sum(host.getSourceFiles(), "nodeCount"); }, getIdentifierCount: function () { return ts.sum(host.getSourceFiles(), "identifierCount"); }, - getSymbolCount: function () { return ts.sum(host.getSourceFiles(), "symbolCount"); }, + getSymbolCount: function () { return ts.sum(host.getSourceFiles(), "symbolCount") + symbolCount; }, getTypeCount: function () { return typeCount; }, isUndefinedSymbol: function (symbol) { return symbol === undefinedSymbol; }, isArgumentsSymbol: function (symbol) { return symbol === argumentsSymbol; }, @@ -12999,6 +13315,7 @@ var ts; var getInstantiatedGlobalPromiseLikeType; var getGlobalPromiseConstructorLikeType; var getGlobalThenableType; + var cjsRequireType; var tupleTypes = {}; var unionTypes = {}; var intersectionTypes = {}; @@ -13069,6 +13386,7 @@ var ts; diagnostics.add(diagnostic); } function createSymbol(flags, name) { + symbolCount++; return new Symbol(flags, name); } function getExcludedSymbolFlags(flags) { @@ -13198,10 +13516,10 @@ var ts; return nodeLinks[nodeId] || (nodeLinks[nodeId] = {}); } function getSourceFile(node) { - return ts.getAncestor(node, 246 /* SourceFile */); + return ts.getAncestor(node, 248 /* SourceFile */); } function isGlobalSourceFile(node) { - return node.kind === 246 /* SourceFile */ && !ts.isExternalModule(node); + return node.kind === 248 /* SourceFile */ && !ts.isExternalOrCommonJsModule(node); } function getSymbol(symbols, name, meaning) { if (meaning && ts.hasProperty(symbols, name)) { @@ -13220,18 +13538,62 @@ var ts; } // return undefined if we can't find a symbol. } - /** Returns true if node1 is defined before node 2**/ - function isDefinedBefore(node1, node2) { - var file1 = ts.getSourceFileOfNode(node1); - var file2 = ts.getSourceFileOfNode(node2); - if (file1 === file2) { - return node1.pos <= node2.pos; + function isBlockScopedNameDeclaredBeforeUse(declaration, usage) { + var declarationFile = ts.getSourceFileOfNode(declaration); + var useFile = ts.getSourceFileOfNode(usage); + if (declarationFile !== useFile) { + if (modulekind || (!compilerOptions.outFile && !compilerOptions.out)) { + // nodes are in different files and order cannot be determines + return true; + } + var sourceFiles = host.getSourceFiles(); + return ts.indexOf(sourceFiles, declarationFile) <= ts.indexOf(sourceFiles, useFile); } - if (!compilerOptions.outFile && !compilerOptions.out) { - return true; + if (declaration.pos <= usage.pos) { + // declaration is before usage + // still might be illegal if usage is in the initializer of the variable declaration + return declaration.kind !== 211 /* VariableDeclaration */ || + !isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage); + } + // declaration is after usage + // can be legal if usage is deferred (i.e. inside function or in initializer of instance property) + return isUsedInFunctionOrNonStaticProperty(declaration, usage); + function isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage) { + var container = ts.getEnclosingBlockScopeContainer(declaration); + if (declaration.parent.parent.kind === 193 /* VariableStatement */ || + declaration.parent.parent.kind === 199 /* ForStatement */) { + // variable statement/for statement case, + // use site should not be inside variable declaration (initializer of declaration or binding element) + return isSameScopeDescendentOf(usage, declaration, container); + } + else if (declaration.parent.parent.kind === 201 /* ForOfStatement */ || + declaration.parent.parent.kind === 200 /* ForInStatement */) { + // ForIn/ForOf case - use site should not be used in expression part + var expression = declaration.parent.parent.expression; + return isSameScopeDescendentOf(usage, expression, container); + } + } + function isUsedInFunctionOrNonStaticProperty(declaration, usage) { + var container = ts.getEnclosingBlockScopeContainer(declaration); + var current = usage; + while (current) { + if (current === container) { + return false; + } + if (ts.isFunctionLike(current)) { + return true; + } + var initializerOfNonStaticProperty = current.parent && + current.parent.kind === 141 /* PropertyDeclaration */ && + (current.parent.flags & 128 /* Static */) === 0 && + current.parent.initializer === current; + if (initializerOfNonStaticProperty) { + return true; + } + current = current.parent; + } + return false; } - var sourceFiles = host.getSourceFiles(); - return sourceFiles.indexOf(file1) <= sourceFiles.indexOf(file2); } // Resolve a given name for a given meaning at a given location. An error is reported if the name was not found and // the nameNotFoundMessage argument is not undefined. Returns the resolved symbol, or undefined if no symbol with @@ -13258,13 +13620,13 @@ var ts; } } switch (location.kind) { - case 246 /* SourceFile */: - if (!ts.isExternalModule(location)) + case 248 /* SourceFile */: + if (!ts.isExternalOrCommonJsModule(location)) break; - case 216 /* ModuleDeclaration */: + case 218 /* ModuleDeclaration */: var moduleExports = getSymbolOfNode(location).exports; - if (location.kind === 246 /* SourceFile */ || - (location.kind === 216 /* ModuleDeclaration */ && location.name.kind === 9 /* StringLiteral */)) { + if (location.kind === 248 /* SourceFile */ || + (location.kind === 218 /* ModuleDeclaration */ && location.name.kind === 9 /* StringLiteral */)) { // It's an external module. Because of module/namespace merging, a module's exports are in scope, // yet we never want to treat an export specifier as putting a member in scope. Therefore, // if the name we find is purely an export specifier, it is not actually considered in scope. @@ -13278,7 +13640,7 @@ var ts; // which is not the desired behavior. if (ts.hasProperty(moduleExports, name) && moduleExports[name].flags === 8388608 /* Alias */ && - ts.getDeclarationOfKind(moduleExports[name], 228 /* ExportSpecifier */)) { + ts.getDeclarationOfKind(moduleExports[name], 230 /* ExportSpecifier */)) { break; } result = moduleExports["default"]; @@ -13292,13 +13654,13 @@ var ts; break loop; } break; - case 215 /* EnumDeclaration */: + case 217 /* EnumDeclaration */: if (result = getSymbol(getSymbolOfNode(location).exports, name, meaning & 8 /* EnumMember */)) { break loop; } break; - case 139 /* PropertyDeclaration */: - case 138 /* PropertySignature */: + case 141 /* PropertyDeclaration */: + case 140 /* PropertySignature */: // TypeScript 1.0 spec (April 2014): 8.4.1 // Initializer expressions for instance member variables are evaluated in the scope // of the class constructor body but are not permitted to reference parameters or @@ -13315,9 +13677,9 @@ var ts; } } break; - case 212 /* ClassDeclaration */: - case 184 /* ClassExpression */: - case 213 /* InterfaceDeclaration */: + case 214 /* ClassDeclaration */: + case 186 /* ClassExpression */: + case 215 /* InterfaceDeclaration */: if (result = getSymbol(getSymbolOfNode(location).members, name, meaning & 793056 /* Type */)) { if (lastLocation && lastLocation.flags & 128 /* Static */) { // TypeScript 1.0 spec (April 2014): 3.4.1 @@ -13328,7 +13690,7 @@ var ts; } break loop; } - if (location.kind === 184 /* ClassExpression */ && meaning & 32 /* Class */) { + if (location.kind === 186 /* ClassExpression */ && meaning & 32 /* Class */) { var className = location.name; if (className && name === className.text) { result = location.symbol; @@ -13344,9 +13706,9 @@ var ts; // [foo()]() { } // <-- Reference to T from class's own computed property // } // - case 134 /* ComputedPropertyName */: + case 136 /* ComputedPropertyName */: grandparent = location.parent.parent; - if (ts.isClassLike(grandparent) || grandparent.kind === 213 /* InterfaceDeclaration */) { + if (ts.isClassLike(grandparent) || grandparent.kind === 215 /* InterfaceDeclaration */) { // A reference to this grandparent's type parameters would be an error if (result = getSymbol(getSymbolOfNode(grandparent).members, name, meaning & 793056 /* Type */)) { error(errorLocation, ts.Diagnostics.A_computed_property_name_cannot_reference_a_type_parameter_from_its_containing_type); @@ -13354,19 +13716,19 @@ var ts; } } break; - case 141 /* MethodDeclaration */: - case 140 /* MethodSignature */: - case 142 /* Constructor */: - case 143 /* GetAccessor */: - case 144 /* SetAccessor */: - case 211 /* FunctionDeclaration */: - case 172 /* ArrowFunction */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: + case 144 /* Constructor */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: + case 213 /* FunctionDeclaration */: + case 174 /* ArrowFunction */: if (meaning & 3 /* Variable */ && name === "arguments") { result = argumentsSymbol; break loop; } break; - case 171 /* FunctionExpression */: + case 173 /* FunctionExpression */: if (meaning & 3 /* Variable */ && name === "arguments") { result = argumentsSymbol; break loop; @@ -13379,7 +13741,7 @@ var ts; } } break; - case 137 /* Decorator */: + case 139 /* Decorator */: // Decorators are resolved at the class declaration. Resolving at the parameter // or member would result in looking up locals in the method. // @@ -13388,7 +13750,7 @@ var ts; // method(@y x, y) {} // <-- decorator y should be resolved at the class declaration, not the parameter. // } // - if (location.parent && location.parent.kind === 136 /* Parameter */) { + if (location.parent && location.parent.kind === 138 /* Parameter */) { location = location.parent; } // @@ -13434,8 +13796,11 @@ var ts; // block - scope variable and namespace module. However, only when we // try to resolve name in /*1*/ which is used in variable position, // we want to check for block- scoped - if (meaning & 2 /* BlockScopedVariable */ && result.flags & 2 /* BlockScopedVariable */) { - checkResolvedBlockScopedVariable(result, errorLocation); + if (meaning & 2 /* BlockScopedVariable */) { + var exportOrLocalSymbol = getExportSymbolOfValueSymbolIfExported(result); + if (exportOrLocalSymbol.flags & 2 /* BlockScopedVariable */) { + checkResolvedBlockScopedVariable(exportOrLocalSymbol, errorLocation); + } } } return result; @@ -13445,32 +13810,7 @@ var ts; // Block-scoped variables cannot be used before their definition var declaration = ts.forEach(result.declarations, function (d) { return ts.isBlockOrCatchScoped(d) ? d : undefined; }); ts.Debug.assert(declaration !== undefined, "Block-scoped variable declaration is undefined"); - // first check if usage is lexically located after the declaration - var isUsedBeforeDeclaration = !isDefinedBefore(declaration, errorLocation); - if (!isUsedBeforeDeclaration) { - // lexical check succeeded however code still can be illegal. - // - block scoped variables cannot be used in its initializers - // let x = x; // illegal but usage is lexically after definition - // - in ForIn/ForOf statements variable cannot be contained in expression part - // for (let x in x) - // for (let x of x) - // climb up to the variable declaration skipping binding patterns - var variableDeclaration = ts.getAncestor(declaration, 209 /* VariableDeclaration */); - var container = ts.getEnclosingBlockScopeContainer(variableDeclaration); - if (variableDeclaration.parent.parent.kind === 191 /* VariableStatement */ || - variableDeclaration.parent.parent.kind === 197 /* ForStatement */) { - // variable statement/for statement case, - // use site should not be inside variable declaration (initializer of declaration or binding element) - isUsedBeforeDeclaration = isSameScopeDescendentOf(errorLocation, variableDeclaration, container); - } - else if (variableDeclaration.parent.parent.kind === 199 /* ForOfStatement */ || - variableDeclaration.parent.parent.kind === 198 /* ForInStatement */) { - // ForIn/ForOf case - use site should not be used in expression part - var expression = variableDeclaration.parent.parent.expression; - isUsedBeforeDeclaration = isSameScopeDescendentOf(errorLocation, expression, container); - } - } - if (isUsedBeforeDeclaration) { + if (!isBlockScopedNameDeclaredBeforeUse(ts.getAncestor(declaration, 211 /* VariableDeclaration */), errorLocation)) { error(errorLocation, ts.Diagnostics.Block_scoped_variable_0_used_before_its_declaration, ts.declarationNameToString(declaration.name)); } } @@ -13491,10 +13831,10 @@ var ts; } function getAnyImportSyntax(node) { if (ts.isAliasSymbolDeclaration(node)) { - if (node.kind === 219 /* ImportEqualsDeclaration */) { + if (node.kind === 221 /* ImportEqualsDeclaration */) { return node; } - while (node && node.kind !== 220 /* ImportDeclaration */) { + while (node && node.kind !== 222 /* ImportDeclaration */) { node = node.parent; } return node; @@ -13504,7 +13844,7 @@ var ts; return ts.forEach(symbol.declarations, function (d) { return ts.isAliasSymbolDeclaration(d) ? d : undefined; }); } function getTargetOfImportEqualsDeclaration(node) { - if (node.moduleReference.kind === 230 /* ExternalModuleReference */) { + if (node.moduleReference.kind === 232 /* ExternalModuleReference */) { return resolveExternalModuleSymbol(resolveExternalModuleName(node, ts.getExternalModuleImportEqualsDeclarationExpression(node))); } return getSymbolOfPartOfRightHandSideOfImportEquals(node.moduleReference, node); @@ -13611,17 +13951,17 @@ var ts; } function getTargetOfAliasDeclaration(node) { switch (node.kind) { - case 219 /* ImportEqualsDeclaration */: + case 221 /* ImportEqualsDeclaration */: return getTargetOfImportEqualsDeclaration(node); - case 221 /* ImportClause */: + case 223 /* ImportClause */: return getTargetOfImportClause(node); - case 222 /* NamespaceImport */: + case 224 /* NamespaceImport */: return getTargetOfNamespaceImport(node); - case 224 /* ImportSpecifier */: + case 226 /* ImportSpecifier */: return getTargetOfImportSpecifier(node); - case 228 /* ExportSpecifier */: + case 230 /* ExportSpecifier */: return getTargetOfExportSpecifier(node); - case 225 /* ExportAssignment */: + case 227 /* ExportAssignment */: return getTargetOfExportAssignment(node); } } @@ -13666,11 +14006,11 @@ var ts; if (!links.referenced) { links.referenced = true; var node = getDeclarationOfAliasSymbol(symbol); - if (node.kind === 225 /* ExportAssignment */) { + if (node.kind === 227 /* ExportAssignment */) { // export default checkExpressionCached(node.expression); } - else if (node.kind === 228 /* ExportSpecifier */) { + else if (node.kind === 230 /* ExportSpecifier */) { // export { } or export { as foo } checkExpressionCached(node.propertyName || node.name); } @@ -13683,7 +14023,7 @@ var ts; // This function is only for imports with entity names function getSymbolOfPartOfRightHandSideOfImportEquals(entityName, importDeclaration) { if (!importDeclaration) { - importDeclaration = ts.getAncestor(entityName, 219 /* ImportEqualsDeclaration */); + importDeclaration = ts.getAncestor(entityName, 221 /* ImportEqualsDeclaration */); ts.Debug.assert(importDeclaration !== undefined); } // There are three things we might try to look for. In the following examples, @@ -13692,17 +14032,17 @@ var ts; // import a = |b|; // Namespace // import a = |b.c|; // Value, type, namespace // import a = |b.c|.d; // Namespace - if (entityName.kind === 67 /* Identifier */ && ts.isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { + if (entityName.kind === 69 /* Identifier */ && ts.isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { entityName = entityName.parent; } // Check for case 1 and 3 in the above example - if (entityName.kind === 67 /* Identifier */ || entityName.parent.kind === 133 /* QualifiedName */) { + if (entityName.kind === 69 /* Identifier */ || entityName.parent.kind === 135 /* QualifiedName */) { return resolveEntityName(entityName, 1536 /* Namespace */); } else { // Case 2 in above example // entityName.kind could be a QualifiedName or a Missing identifier - ts.Debug.assert(entityName.parent.kind === 219 /* ImportEqualsDeclaration */); + ts.Debug.assert(entityName.parent.kind === 221 /* ImportEqualsDeclaration */); return resolveEntityName(entityName, 107455 /* Value */ | 793056 /* Type */ | 1536 /* Namespace */); } } @@ -13715,16 +14055,16 @@ var ts; return undefined; } var symbol; - if (name.kind === 67 /* Identifier */) { + if (name.kind === 69 /* Identifier */) { var message = meaning === 1536 /* Namespace */ ? ts.Diagnostics.Cannot_find_namespace_0 : ts.Diagnostics.Cannot_find_name_0; symbol = resolveName(name, name.text, meaning, ignoreErrors ? undefined : message, name); if (!symbol) { return undefined; } } - else if (name.kind === 133 /* QualifiedName */ || name.kind === 164 /* PropertyAccessExpression */) { - var left = name.kind === 133 /* QualifiedName */ ? name.left : name.expression; - var right = name.kind === 133 /* QualifiedName */ ? name.right : name.name; + else if (name.kind === 135 /* QualifiedName */ || name.kind === 166 /* PropertyAccessExpression */) { + var left = name.kind === 135 /* QualifiedName */ ? name.left : name.expression; + var right = name.kind === 135 /* QualifiedName */ ? name.right : name.name; var namespace = resolveEntityName(left, 1536 /* Namespace */, ignoreErrors); if (!namespace || namespace === unknownSymbol || ts.nodeIsMissing(right)) { return undefined; @@ -13743,11 +14083,6 @@ var ts; ts.Debug.assert((symbol.flags & 16777216 /* Instantiated */) === 0, "Should never get an instantiated symbol here."); return symbol.flags & meaning ? symbol : resolveAlias(symbol); } - function isExternalModuleNameRelative(moduleName) { - // TypeScript 1.0 spec (April 2014): 11.2.1 - // An external module name is "relative" if the first term is "." or "..". - return moduleName.substr(0, 2) === "./" || moduleName.substr(0, 3) === "../" || moduleName.substr(0, 2) === ".\\" || moduleName.substr(0, 3) === "..\\"; - } function resolveExternalModuleName(location, moduleReferenceExpression) { if (moduleReferenceExpression.kind !== 9 /* StringLiteral */) { return; @@ -13760,7 +14095,10 @@ var ts; if (moduleName === undefined) { return; } - var isRelative = isExternalModuleNameRelative(moduleName); + if (moduleName.indexOf("!") >= 0) { + moduleName = moduleName.substr(0, moduleName.indexOf("!")); + } + var isRelative = ts.isExternalModuleNameRelative(moduleName); if (!isRelative) { var symbol = getSymbol(globals, "\"" + moduleName + "\"", 512 /* ValueModule */); if (symbol) { @@ -13876,7 +14214,7 @@ var ts; var members = node.members; for (var _i = 0; _i < members.length; _i++) { var member = members[_i]; - if (member.kind === 142 /* Constructor */ && ts.nodeIsPresent(member.body)) { + if (member.kind === 144 /* Constructor */ && ts.nodeIsPresent(member.body)) { return member; } } @@ -13946,17 +14284,17 @@ var ts; } } switch (location_1.kind) { - case 246 /* SourceFile */: - if (!ts.isExternalModule(location_1)) { + case 248 /* SourceFile */: + if (!ts.isExternalOrCommonJsModule(location_1)) { break; } - case 216 /* ModuleDeclaration */: + case 218 /* ModuleDeclaration */: if (result = callback(getSymbolOfNode(location_1).exports)) { return result; } break; - case 212 /* ClassDeclaration */: - case 213 /* InterfaceDeclaration */: + case 214 /* ClassDeclaration */: + case 215 /* InterfaceDeclaration */: if (result = callback(getSymbolOfNode(location_1).members)) { return result; } @@ -13997,7 +14335,7 @@ var ts; return ts.forEachValue(symbols, function (symbolFromSymbolTable) { if (symbolFromSymbolTable.flags & 8388608 /* Alias */ && symbolFromSymbolTable.name !== "export=" - && !ts.getDeclarationOfKind(symbolFromSymbolTable, 228 /* ExportSpecifier */)) { + && !ts.getDeclarationOfKind(symbolFromSymbolTable, 230 /* ExportSpecifier */)) { if (!useOnlyExternalAliasing || // Is this external alias, then use it to name ts.forEach(symbolFromSymbolTable.declarations, ts.isExternalModuleImportEqualsDeclaration)) { @@ -14034,7 +14372,7 @@ var ts; return true; } // Qualify if the symbol from symbol table has same meaning as expected - symbolFromSymbolTable = (symbolFromSymbolTable.flags & 8388608 /* Alias */ && !ts.getDeclarationOfKind(symbolFromSymbolTable, 228 /* ExportSpecifier */)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; + symbolFromSymbolTable = (symbolFromSymbolTable.flags & 8388608 /* Alias */ && !ts.getDeclarationOfKind(symbolFromSymbolTable, 230 /* ExportSpecifier */)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; if (symbolFromSymbolTable.flags & meaning) { qualify = true; return true; @@ -14107,8 +14445,8 @@ var ts; } } function hasExternalModuleSymbol(declaration) { - return (declaration.kind === 216 /* ModuleDeclaration */ && declaration.name.kind === 9 /* StringLiteral */) || - (declaration.kind === 246 /* SourceFile */ && ts.isExternalModule(declaration)); + return (declaration.kind === 218 /* ModuleDeclaration */ && declaration.name.kind === 9 /* StringLiteral */) || + (declaration.kind === 248 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); } function hasVisibleDeclarations(symbol) { var aliasesToMakeVisible; @@ -14144,12 +14482,12 @@ var ts; function isEntityNameVisible(entityName, enclosingDeclaration) { // get symbol of the first identifier of the entityName var meaning; - if (entityName.parent.kind === 152 /* TypeQuery */) { + if (entityName.parent.kind === 154 /* TypeQuery */) { // Typeof value meaning = 107455 /* Value */ | 1048576 /* ExportValue */; } - else if (entityName.kind === 133 /* QualifiedName */ || entityName.kind === 164 /* PropertyAccessExpression */ || - entityName.parent.kind === 219 /* ImportEqualsDeclaration */) { + else if (entityName.kind === 135 /* QualifiedName */ || entityName.kind === 166 /* PropertyAccessExpression */ || + entityName.parent.kind === 221 /* ImportEqualsDeclaration */) { // Left identifier from type reference or TypeAlias // Entity name of the import declaration meaning = 1536 /* Namespace */; @@ -14204,10 +14542,10 @@ var ts; function getTypeAliasForTypeLiteral(type) { if (type.symbol && type.symbol.flags & 2048 /* TypeLiteral */) { var node = type.symbol.declarations[0].parent; - while (node.kind === 158 /* ParenthesizedType */) { + while (node.kind === 160 /* ParenthesizedType */) { node = node.parent; } - if (node.kind === 214 /* TypeAliasDeclaration */) { + if (node.kind === 216 /* TypeAliasDeclaration */) { return getSymbolOfNode(node); } } @@ -14221,10 +14559,10 @@ var ts; return ts.declarationNameToString(declaration.name); } switch (declaration.kind) { - case 184 /* ClassExpression */: + case 186 /* ClassExpression */: return "(Anonymous class)"; - case 171 /* FunctionExpression */: - case 172 /* ArrowFunction */: + case 173 /* FunctionExpression */: + case 174 /* ArrowFunction */: return "(Anonymous function)"; } } @@ -14307,6 +14645,7 @@ var ts; } function buildTypeDisplay(type, writer, enclosingDeclaration, globalFlags, symbolStack) { var globalFlagsToPass = globalFlags & 16 /* WriteOwnNameForAnyLike */; + var inObjectTypeLiteral = false; return writeType(type, globalFlags); function writeType(type, flags) { // Write undefined/null type as any @@ -14316,6 +14655,12 @@ var ts; ? "any" : type.intrinsicName); } + else if (type.flags & 33554432 /* ThisType */) { + if (inObjectTypeLiteral) { + writer.reportInaccessibleThisError(); + } + writer.writeKeyword("this"); + } else if (type.flags & 4096 /* Reference */) { writeTypeReference(type, flags); } @@ -14357,11 +14702,10 @@ var ts; writeType(types[i], delimiter === 24 /* CommaToken */ ? 0 /* None */ : 64 /* InElementType */); } } - function writeSymbolTypeReference(symbol, typeArguments, pos, end) { - // Unnamed function expressions, arrow functions, and unnamed class expressions have reserved names that - // we don't want to display - if (!isReservedMemberName(symbol.name)) { - buildSymbolDisplay(symbol, writer, enclosingDeclaration, 793056 /* Type */); + function writeSymbolTypeReference(symbol, typeArguments, pos, end, flags) { + // Unnamed function expressions and arrow functions have reserved names that we don't want to display + if (symbol.flags & 32 /* Class */ || !isReservedMemberName(symbol.name)) { + buildSymbolDisplay(symbol, writer, enclosingDeclaration, 793056 /* Type */, 0 /* None */, flags); } if (pos < end) { writePunctuation(writer, 25 /* LessThanToken */); @@ -14375,7 +14719,7 @@ var ts; } } function writeTypeReference(type, flags) { - var typeArguments = type.typeArguments; + var typeArguments = type.typeArguments || emptyArray; if (type.target === globalArrayType && !(flags & 1 /* WriteArrayAsGenericType */)) { writeType(typeArguments[0], 64 /* InElementType */); writePunctuation(writer, 19 /* OpenBracketToken */); @@ -14399,12 +14743,13 @@ var ts; // When type parameters are their own type arguments for the whole group (i.e. we have // the default outer type arguments), we don't show the group. if (!ts.rangeEquals(outerTypeParameters, typeArguments, start, i)) { - writeSymbolTypeReference(parent_3, typeArguments, start, i); + writeSymbolTypeReference(parent_3, typeArguments, start, i, flags); writePunctuation(writer, 21 /* DotToken */); } } } - writeSymbolTypeReference(type.symbol, typeArguments, i, typeArguments.length); + var typeParameterCount = (type.target.typeParameters || emptyArray).length; + writeSymbolTypeReference(type.symbol, typeArguments, i, typeParameterCount, flags); } } function writeTupleType(type) { @@ -14416,7 +14761,7 @@ var ts; if (flags & 64 /* InElementType */) { writePunctuation(writer, 17 /* OpenParenToken */); } - writeTypeList(type.types, type.flags & 16384 /* Union */ ? 46 /* BarToken */ : 45 /* AmpersandToken */); + writeTypeList(type.types, type.flags & 16384 /* Union */ ? 47 /* BarToken */ : 46 /* AmpersandToken */); if (flags & 64 /* InElementType */) { writePunctuation(writer, 18 /* CloseParenToken */); } @@ -14440,7 +14785,7 @@ var ts; } else { // Recursive usage, use any - writeKeyword(writer, 115 /* AnyKeyword */); + writeKeyword(writer, 117 /* AnyKeyword */); } } else { @@ -14464,7 +14809,7 @@ var ts; var isNonLocalFunctionSymbol = !!(symbol.flags & 16 /* Function */) && (symbol.parent || ts.forEach(symbol.declarations, function (declaration) { - return declaration.parent.kind === 246 /* SourceFile */ || declaration.parent.kind === 217 /* ModuleBlock */; + return declaration.parent.kind === 248 /* SourceFile */ || declaration.parent.kind === 219 /* ModuleBlock */; })); if (isStaticMethodSymbol || isNonLocalFunctionSymbol) { // typeof is allowed only for static/non local functions @@ -14474,7 +14819,7 @@ var ts; } } function writeTypeofSymbol(type, typeFormatFlags) { - writeKeyword(writer, 99 /* TypeOfKeyword */); + writeKeyword(writer, 101 /* TypeOfKeyword */); writeSpace(writer); buildSymbolDisplay(type.symbol, writer, enclosingDeclaration, 107455 /* Value */, 0 /* None */, typeFormatFlags); } @@ -14510,7 +14855,7 @@ var ts; if (flags & 64 /* InElementType */) { writePunctuation(writer, 17 /* OpenParenToken */); } - writeKeyword(writer, 90 /* NewKeyword */); + writeKeyword(writer, 92 /* NewKeyword */); writeSpace(writer); buildSignatureDisplay(resolved.constructSignatures[0], writer, enclosingDeclaration, globalFlagsToPass | 8 /* WriteArrowStyleSignature */, symbolStack); if (flags & 64 /* InElementType */) { @@ -14519,6 +14864,8 @@ var ts; return; } } + var saveInObjectTypeLiteral = inObjectTypeLiteral; + inObjectTypeLiteral = true; writePunctuation(writer, 15 /* OpenBraceToken */); writer.writeLine(); writer.increaseIndent(); @@ -14530,7 +14877,7 @@ var ts; } for (var _b = 0, _c = resolved.constructSignatures; _b < _c.length; _b++) { var signature = _c[_b]; - writeKeyword(writer, 90 /* NewKeyword */); + writeKeyword(writer, 92 /* NewKeyword */); writeSpace(writer); buildSignatureDisplay(signature, writer, enclosingDeclaration, globalFlagsToPass, symbolStack); writePunctuation(writer, 23 /* SemicolonToken */); @@ -14540,11 +14887,11 @@ var ts; // [x: string]: writePunctuation(writer, 19 /* OpenBracketToken */); writer.writeParameter(getIndexerParameterName(resolved, 0 /* String */, /*fallbackName*/ "x")); - writePunctuation(writer, 53 /* ColonToken */); + writePunctuation(writer, 54 /* ColonToken */); writeSpace(writer); - writeKeyword(writer, 128 /* StringKeyword */); + writeKeyword(writer, 130 /* StringKeyword */); writePunctuation(writer, 20 /* CloseBracketToken */); - writePunctuation(writer, 53 /* ColonToken */); + writePunctuation(writer, 54 /* ColonToken */); writeSpace(writer); writeType(resolved.stringIndexType, 0 /* None */); writePunctuation(writer, 23 /* SemicolonToken */); @@ -14554,11 +14901,11 @@ var ts; // [x: number]: writePunctuation(writer, 19 /* OpenBracketToken */); writer.writeParameter(getIndexerParameterName(resolved, 1 /* Number */, /*fallbackName*/ "x")); - writePunctuation(writer, 53 /* ColonToken */); + writePunctuation(writer, 54 /* ColonToken */); writeSpace(writer); - writeKeyword(writer, 126 /* NumberKeyword */); + writeKeyword(writer, 128 /* NumberKeyword */); writePunctuation(writer, 20 /* CloseBracketToken */); - writePunctuation(writer, 53 /* ColonToken */); + writePunctuation(writer, 54 /* ColonToken */); writeSpace(writer); writeType(resolved.numberIndexType, 0 /* None */); writePunctuation(writer, 23 /* SemicolonToken */); @@ -14573,7 +14920,7 @@ var ts; var signature = signatures[_f]; buildSymbolDisplay(p, writer); if (p.flags & 536870912 /* Optional */) { - writePunctuation(writer, 52 /* QuestionToken */); + writePunctuation(writer, 53 /* QuestionToken */); } buildSignatureDisplay(signature, writer, enclosingDeclaration, globalFlagsToPass, symbolStack); writePunctuation(writer, 23 /* SemicolonToken */); @@ -14583,9 +14930,9 @@ var ts; else { buildSymbolDisplay(p, writer); if (p.flags & 536870912 /* Optional */) { - writePunctuation(writer, 52 /* QuestionToken */); + writePunctuation(writer, 53 /* QuestionToken */); } - writePunctuation(writer, 53 /* ColonToken */); + writePunctuation(writer, 54 /* ColonToken */); writeSpace(writer); writeType(t, 0 /* None */); writePunctuation(writer, 23 /* SemicolonToken */); @@ -14594,6 +14941,7 @@ var ts; } writer.decreaseIndent(); writePunctuation(writer, 16 /* CloseBraceToken */); + inObjectTypeLiteral = saveInObjectTypeLiteral; } } function buildTypeParameterDisplayFromSymbol(symbol, writer, enclosingDeclaraiton, flags) { @@ -14607,7 +14955,7 @@ var ts; var constraint = getConstraintOfTypeParameter(tp); if (constraint) { writeSpace(writer); - writeKeyword(writer, 81 /* ExtendsKeyword */); + writeKeyword(writer, 83 /* ExtendsKeyword */); writeSpace(writer); buildTypeDisplay(constraint, writer, enclosingDeclaration, flags, symbolStack); } @@ -14619,9 +14967,9 @@ var ts; } appendSymbolNameOnly(p, writer); if (isOptionalParameter(parameterNode)) { - writePunctuation(writer, 52 /* QuestionToken */); + writePunctuation(writer, 53 /* QuestionToken */); } - writePunctuation(writer, 53 /* ColonToken */); + writePunctuation(writer, 54 /* ColonToken */); writeSpace(writer); buildTypeDisplay(getTypeOfSymbol(p), writer, enclosingDeclaration, flags, symbolStack); } @@ -14668,14 +15016,14 @@ var ts; writePunctuation(writer, 34 /* EqualsGreaterThanToken */); } else { - writePunctuation(writer, 53 /* ColonToken */); + writePunctuation(writer, 54 /* ColonToken */); } writeSpace(writer); var returnType; if (signature.typePredicate) { writer.writeParameter(signature.typePredicate.parameterName); writeSpace(writer); - writeKeyword(writer, 122 /* IsKeyword */); + writeKeyword(writer, 124 /* IsKeyword */); writeSpace(writer); returnType = signature.typePredicate.type; } @@ -14711,13 +15059,13 @@ var ts; function isDeclarationVisible(node) { function getContainingExternalModule(node) { for (; node; node = node.parent) { - if (node.kind === 216 /* ModuleDeclaration */) { + if (node.kind === 218 /* ModuleDeclaration */) { if (node.name.kind === 9 /* StringLiteral */) { return node; } } - else if (node.kind === 246 /* SourceFile */) { - return ts.isExternalModule(node) ? node : undefined; + else if (node.kind === 248 /* SourceFile */) { + return ts.isExternalOrCommonJsModule(node) ? node : undefined; } } ts.Debug.fail("getContainingModule cant reach here"); @@ -14765,70 +15113,70 @@ var ts; } function determineIfDeclarationIsVisible() { switch (node.kind) { - case 161 /* BindingElement */: + case 163 /* BindingElement */: return isDeclarationVisible(node.parent.parent); - case 209 /* VariableDeclaration */: + case 211 /* VariableDeclaration */: if (ts.isBindingPattern(node.name) && !node.name.elements.length) { // If the binding pattern is empty, this variable declaration is not visible return false; } // Otherwise fall through - case 216 /* ModuleDeclaration */: - case 212 /* ClassDeclaration */: - case 213 /* InterfaceDeclaration */: - case 214 /* TypeAliasDeclaration */: - case 211 /* FunctionDeclaration */: - case 215 /* EnumDeclaration */: - case 219 /* ImportEqualsDeclaration */: + case 218 /* ModuleDeclaration */: + case 214 /* ClassDeclaration */: + case 215 /* InterfaceDeclaration */: + case 216 /* TypeAliasDeclaration */: + case 213 /* FunctionDeclaration */: + case 217 /* EnumDeclaration */: + case 221 /* ImportEqualsDeclaration */: var parent_4 = getDeclarationContainer(node); // If the node is not exported or it is not ambient module element (except import declaration) if (!(ts.getCombinedNodeFlags(node) & 1 /* Export */) && - !(node.kind !== 219 /* ImportEqualsDeclaration */ && parent_4.kind !== 246 /* SourceFile */ && ts.isInAmbientContext(parent_4))) { + !(node.kind !== 221 /* ImportEqualsDeclaration */ && parent_4.kind !== 248 /* SourceFile */ && ts.isInAmbientContext(parent_4))) { return isGlobalSourceFile(parent_4); } // Exported members/ambient module elements (exception import declaration) are visible if parent is visible return isDeclarationVisible(parent_4); - case 139 /* PropertyDeclaration */: - case 138 /* PropertySignature */: - case 143 /* GetAccessor */: - case 144 /* SetAccessor */: - case 141 /* MethodDeclaration */: - case 140 /* MethodSignature */: + case 141 /* PropertyDeclaration */: + case 140 /* PropertySignature */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: if (node.flags & (32 /* Private */ | 64 /* Protected */)) { // Private/protected properties/methods are not visible return false; } // Public properties/methods are visible if its parents are visible, so let it fall into next case statement - case 142 /* Constructor */: - case 146 /* ConstructSignature */: - case 145 /* CallSignature */: - case 147 /* IndexSignature */: - case 136 /* Parameter */: - case 217 /* ModuleBlock */: - case 150 /* FunctionType */: - case 151 /* ConstructorType */: - case 153 /* TypeLiteral */: - case 149 /* TypeReference */: - case 154 /* ArrayType */: - case 155 /* TupleType */: - case 156 /* UnionType */: - case 157 /* IntersectionType */: - case 158 /* ParenthesizedType */: + case 144 /* Constructor */: + case 148 /* ConstructSignature */: + case 147 /* CallSignature */: + case 149 /* IndexSignature */: + case 138 /* Parameter */: + case 219 /* ModuleBlock */: + case 152 /* FunctionType */: + case 153 /* ConstructorType */: + case 155 /* TypeLiteral */: + case 151 /* TypeReference */: + case 156 /* ArrayType */: + case 157 /* TupleType */: + case 158 /* UnionType */: + case 159 /* IntersectionType */: + case 160 /* ParenthesizedType */: return isDeclarationVisible(node.parent); // Default binding, import specifier and namespace import is visible // only on demand so by default it is not visible - case 221 /* ImportClause */: - case 222 /* NamespaceImport */: - case 224 /* ImportSpecifier */: + case 223 /* ImportClause */: + case 224 /* NamespaceImport */: + case 226 /* ImportSpecifier */: return false; // Type parameters are always visible - case 135 /* TypeParameter */: + case 137 /* TypeParameter */: // Source file is always visible - case 246 /* SourceFile */: + case 248 /* SourceFile */: return true; - // Export assignements do not create name bindings outside the module - case 225 /* ExportAssignment */: + // Export assignments do not create name bindings outside the module + case 227 /* ExportAssignment */: return false; default: ts.Debug.fail("isDeclarationVisible unknown: SyntaxKind: " + node.kind); @@ -14844,10 +15192,10 @@ var ts; } function collectLinkedAliases(node) { var exportSymbol; - if (node.parent && node.parent.kind === 225 /* ExportAssignment */) { + if (node.parent && node.parent.kind === 227 /* ExportAssignment */) { exportSymbol = resolveName(node.parent, node.text, 107455 /* Value */ | 793056 /* Type */ | 1536 /* Namespace */ | 8388608 /* Alias */, ts.Diagnostics.Cannot_find_name_0, node); } - else if (node.parent.kind === 228 /* ExportSpecifier */) { + else if (node.parent.kind === 230 /* ExportSpecifier */) { var exportSpecifier = node.parent; exportSymbol = exportSpecifier.parent.parent.moduleSpecifier ? getExternalModuleMember(exportSpecifier.parent.parent, exportSpecifier) : @@ -14939,7 +15287,7 @@ var ts; node = ts.getRootDeclaration(node); // Parent chain: // VaribleDeclaration -> VariableDeclarationList -> VariableStatement -> 'Declaration Container' - return node.kind === 209 /* VariableDeclaration */ ? node.parent.parent.parent : node.parent; + return node.kind === 211 /* VariableDeclaration */ ? node.parent.parent.parent : node.parent; } function getTypeOfPrototypeProperty(prototype) { // TypeScript 1.0 spec (April 2014): 8.4 @@ -14957,10 +15305,16 @@ var ts; function isTypeAny(type) { return type && (type.flags & 1 /* Any */) !== 0; } + // Return the type of a binding element parent. We check SymbolLinks first to see if a type has been + // assigned by contextual typing. + function getTypeForBindingElementParent(node) { + var symbol = getSymbolOfNode(node); + return symbol && getSymbolLinks(symbol).type || getTypeForVariableLikeDeclaration(node); + } // Return the inferred type for a binding element function getTypeForBindingElement(declaration) { var pattern = declaration.parent; - var parentType = getTypeForVariableLikeDeclaration(pattern.parent); + var parentType = getTypeForBindingElementParent(pattern.parent); // If parent has the unknown (error) type, then so does this binding element if (parentType === unknownType) { return unknownType; @@ -14975,7 +15329,7 @@ var ts; return parentType; } var type; - if (pattern.kind === 159 /* ObjectBindingPattern */) { + if (pattern.kind === 161 /* ObjectBindingPattern */) { // Use explicitly specified property name ({ p: xxx } form), or otherwise the implied name ({ p } form) var name_10 = declaration.propertyName || declaration.name; // Use type of the specified property, or otherwise, for a numeric name, the type of the numeric index signature, @@ -15019,10 +15373,10 @@ var ts; // Return the inferred type for a variable, parameter, or property declaration function getTypeForVariableLikeDeclaration(declaration) { // A variable declared in a for..in statement is always of type any - if (declaration.parent.parent.kind === 198 /* ForInStatement */) { + if (declaration.parent.parent.kind === 200 /* ForInStatement */) { return anyType; } - if (declaration.parent.parent.kind === 199 /* ForOfStatement */) { + if (declaration.parent.parent.kind === 201 /* ForOfStatement */) { // checkRightHandSideOfForOf will return undefined if the for-of expression type was // missing properties/signatures required to get its iteratedType (like // [Symbol.iterator] or next). This may be because we accessed properties from anyType, @@ -15036,11 +15390,11 @@ var ts; if (declaration.type) { return getTypeFromTypeNode(declaration.type); } - if (declaration.kind === 136 /* Parameter */) { + if (declaration.kind === 138 /* Parameter */) { var func = declaration.parent; // For a parameter of a set accessor, use the type of the get accessor if one is present - if (func.kind === 144 /* SetAccessor */ && !ts.hasDynamicName(func)) { - var getter = ts.getDeclarationOfKind(declaration.parent.symbol, 143 /* GetAccessor */); + if (func.kind === 146 /* SetAccessor */ && !ts.hasDynamicName(func)) { + var getter = ts.getDeclarationOfKind(declaration.parent.symbol, 145 /* GetAccessor */); if (getter) { return getReturnTypeOfSignature(getSignatureFromDeclaration(getter)); } @@ -15056,7 +15410,7 @@ var ts; return checkExpressionCached(declaration.initializer); } // If it is a short-hand property assignment, use the type of the identifier - if (declaration.kind === 244 /* ShorthandPropertyAssignment */) { + if (declaration.kind === 246 /* ShorthandPropertyAssignment */) { return checkIdentifier(declaration.name); } // If the declaration specifies a binding pattern, use the type implied by the binding pattern @@ -15102,7 +15456,7 @@ var ts; return languageVersion >= 2 /* ES6 */ ? createIterableType(anyType) : anyArrayType; } // If the pattern has at least one element, and no rest element, then it should imply a tuple type. - var elementTypes = ts.map(elements, function (e) { return e.kind === 185 /* OmittedExpression */ ? anyType : getTypeFromBindingElement(e, includePatternInType); }); + var elementTypes = ts.map(elements, function (e) { return e.kind === 187 /* OmittedExpression */ ? anyType : getTypeFromBindingElement(e, includePatternInType); }); if (includePatternInType) { var result = createNewTupleType(elementTypes); result.pattern = pattern; @@ -15118,7 +15472,7 @@ var ts; // parameter with no type annotation or initializer, the type implied by the binding pattern becomes the type of // the parameter. function getTypeFromBindingPattern(pattern, includePatternInType) { - return pattern.kind === 159 /* ObjectBindingPattern */ + return pattern.kind === 161 /* ObjectBindingPattern */ ? getTypeFromObjectBindingPattern(pattern, includePatternInType) : getTypeFromArrayBindingPattern(pattern, includePatternInType); } @@ -15140,14 +15494,14 @@ var ts; // During a normal type check we'll never get to here with a property assignment (the check of the containing // object literal uses a different path). We exclude widening only so that language services and type verification // tools see the actual type. - return declaration.kind !== 243 /* PropertyAssignment */ ? getWidenedType(type) : type; + return declaration.kind !== 245 /* PropertyAssignment */ ? getWidenedType(type) : type; } // Rest parameters default to type any[], other parameters default to type any type = declaration.dotDotDotToken ? anyArrayType : anyType; // Report implicit any errors unless this is a private property within an ambient declaration if (reportErrors && compilerOptions.noImplicitAny) { var root = ts.getRootDeclaration(declaration); - if (!isPrivateWithinAmbient(root) && !(root.kind === 136 /* Parameter */ && isPrivateWithinAmbient(root.parent))) { + if (!isPrivateWithinAmbient(root) && !(root.kind === 138 /* Parameter */ && isPrivateWithinAmbient(root.parent))) { reportImplicitAnyError(declaration, type); } } @@ -15162,13 +15516,21 @@ var ts; } // Handle catch clause variables var declaration = symbol.valueDeclaration; - if (declaration.parent.kind === 242 /* CatchClause */) { + if (declaration.parent.kind === 244 /* CatchClause */) { return links.type = anyType; } // Handle export default expressions - if (declaration.kind === 225 /* ExportAssignment */) { + if (declaration.kind === 227 /* ExportAssignment */) { return links.type = checkExpression(declaration.expression); } + // Handle module.exports = expr + if (declaration.kind === 181 /* BinaryExpression */) { + return links.type = checkExpression(declaration.right); + } + // Handle exports.p = expr + if (declaration.kind === 166 /* PropertyAccessExpression */) { + return checkExpressionCached(declaration.parent.right); + } // Handle variable, parameter or property if (!pushTypeResolution(symbol, 0 /* Type */)) { return unknownType; @@ -15194,7 +15556,7 @@ var ts; } function getAnnotatedAccessorType(accessor) { if (accessor) { - if (accessor.kind === 143 /* GetAccessor */) { + if (accessor.kind === 145 /* GetAccessor */) { return accessor.type && getTypeFromTypeNode(accessor.type); } else { @@ -15210,8 +15572,8 @@ var ts; if (!pushTypeResolution(symbol, 0 /* Type */)) { return unknownType; } - var getter = ts.getDeclarationOfKind(symbol, 143 /* GetAccessor */); - var setter = ts.getDeclarationOfKind(symbol, 144 /* SetAccessor */); + var getter = ts.getDeclarationOfKind(symbol, 145 /* GetAccessor */); + var setter = ts.getDeclarationOfKind(symbol, 146 /* SetAccessor */); var type; // First try to see if the user specified a return type on the get-accessor. var getterReturnType = getAnnotatedAccessorType(getter); @@ -15240,7 +15602,7 @@ var ts; if (!popTypeResolution()) { type = anyType; if (compilerOptions.noImplicitAny) { - var getter_1 = ts.getDeclarationOfKind(symbol, 143 /* GetAccessor */); + var getter_1 = ts.getDeclarationOfKind(symbol, 145 /* GetAccessor */); error(getter_1, ts.Diagnostics._0_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions, symbolToString(symbol)); } } @@ -15340,9 +15702,9 @@ var ts; if (!node) { return typeParameters; } - if (node.kind === 212 /* ClassDeclaration */ || node.kind === 184 /* ClassExpression */ || - node.kind === 211 /* FunctionDeclaration */ || node.kind === 171 /* FunctionExpression */ || - node.kind === 141 /* MethodDeclaration */ || node.kind === 172 /* ArrowFunction */) { + if (node.kind === 214 /* ClassDeclaration */ || node.kind === 186 /* ClassExpression */ || + node.kind === 213 /* FunctionDeclaration */ || node.kind === 173 /* FunctionExpression */ || + node.kind === 143 /* MethodDeclaration */ || node.kind === 174 /* ArrowFunction */) { var declarations = node.typeParameters; if (declarations) { return appendTypeParameters(appendOuterTypeParameters(typeParameters, node), declarations); @@ -15352,7 +15714,7 @@ var ts; } // The outer type parameters are those defined by enclosing generic classes, methods, or functions. function getOuterTypeParametersOfClassOrInterface(symbol) { - var declaration = symbol.flags & 32 /* Class */ ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 213 /* InterfaceDeclaration */); + var declaration = symbol.flags & 32 /* Class */ ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 215 /* InterfaceDeclaration */); return appendOuterTypeParameters(undefined, declaration); } // The local type parameters are the combined set of type parameters from all declarations of the class, @@ -15361,8 +15723,8 @@ var ts; var result; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var node = _a[_i]; - if (node.kind === 213 /* InterfaceDeclaration */ || node.kind === 212 /* ClassDeclaration */ || - node.kind === 184 /* ClassExpression */ || node.kind === 214 /* TypeAliasDeclaration */) { + if (node.kind === 215 /* InterfaceDeclaration */ || node.kind === 214 /* ClassDeclaration */ || + node.kind === 186 /* ClassExpression */ || node.kind === 216 /* TypeAliasDeclaration */) { var declaration = node; if (declaration.typeParameters) { result = appendTypeParameters(result, declaration.typeParameters); @@ -15482,7 +15844,7 @@ var ts; type.resolvedBaseTypes = []; for (var _i = 0, _a = type.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 213 /* InterfaceDeclaration */ && ts.getInterfaceBaseTypeNodes(declaration)) { + if (declaration.kind === 215 /* InterfaceDeclaration */ && ts.getInterfaceBaseTypeNodes(declaration)) { for (var _b = 0, _c = ts.getInterfaceBaseTypeNodes(declaration); _b < _c.length; _b++) { var node = _c[_b]; var baseType = getTypeFromTypeNode(node); @@ -15503,6 +15865,32 @@ var ts; } } } + // Returns true if the interface given by the symbol is free of "this" references. Specifically, the result is + // true if the interface itself contains no references to "this" in its body, if all base types are interfaces, + // and if none of the base interfaces have a "this" type. + function isIndependentInterface(symbol) { + for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { + var declaration = _a[_i]; + if (declaration.kind === 215 /* InterfaceDeclaration */) { + if (declaration.flags & 524288 /* ContainsThis */) { + return false; + } + var baseTypeNodes = ts.getInterfaceBaseTypeNodes(declaration); + if (baseTypeNodes) { + for (var _b = 0; _b < baseTypeNodes.length; _b++) { + var node = baseTypeNodes[_b]; + if (ts.isSupportedExpressionWithTypeArguments(node)) { + var baseSymbol = resolveEntityName(node.expression, 793056 /* Type */, /*ignoreErrors*/ true); + if (!baseSymbol || !(baseSymbol.flags & 64 /* Interface */) || getDeclaredTypeOfClassOrInterface(baseSymbol).thisType) { + return false; + } + } + } + } + } + } + return true; + } function getDeclaredTypeOfClassOrInterface(symbol) { var links = getSymbolLinks(symbol); if (!links.declaredType) { @@ -15510,7 +15898,12 @@ var ts; var type = links.declaredType = createObjectType(kind, symbol); var outerTypeParameters = getOuterTypeParametersOfClassOrInterface(symbol); var localTypeParameters = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol); - if (outerTypeParameters || localTypeParameters) { + // A class or interface is generic if it has type parameters or a "this" type. We always give classes a "this" type + // because it is not feasible to analyze all members to determine if the "this" type escapes the class (in particular, + // property types inferred from initializers and method return types inferred from return statements are very hard + // to exhaustively analyze). We give interfaces a "this" type if we can't definitely determine that they are free of + // "this" references. + if (outerTypeParameters || localTypeParameters || kind === 1024 /* Class */ || !isIndependentInterface(symbol)) { type.flags |= 4096 /* Reference */; type.typeParameters = ts.concatenate(outerTypeParameters, localTypeParameters); type.outerTypeParameters = outerTypeParameters; @@ -15519,6 +15912,9 @@ var ts; type.instantiations[getTypeListId(type.typeParameters)] = type; type.target = type; type.typeArguments = type.typeParameters; + type.thisType = createType(512 /* TypeParameter */ | 33554432 /* ThisType */); + type.thisType.symbol = symbol; + type.thisType.constraint = getTypeWithThisArgument(type); } } return links.declaredType; @@ -15531,7 +15927,7 @@ var ts; if (!pushTypeResolution(symbol, 2 /* DeclaredType */)) { return unknownType; } - var declaration = ts.getDeclarationOfKind(symbol, 214 /* TypeAliasDeclaration */); + var declaration = ts.getDeclarationOfKind(symbol, 216 /* TypeAliasDeclaration */); var type = getTypeFromTypeNode(declaration.type); if (popTypeResolution()) { links.typeParameters = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol); @@ -15564,7 +15960,7 @@ var ts; if (!links.declaredType) { var type = createType(512 /* TypeParameter */); type.symbol = symbol; - if (!ts.getDeclarationOfKind(symbol, 135 /* TypeParameter */).constraint) { + if (!ts.getDeclarationOfKind(symbol, 137 /* TypeParameter */).constraint) { type.constraint = noConstraintType; } links.declaredType = type; @@ -15597,6 +15993,79 @@ var ts; } return unknownType; } + // A type reference is considered independent if each type argument is considered independent. + function isIndependentTypeReference(node) { + if (node.typeArguments) { + for (var _i = 0, _a = node.typeArguments; _i < _a.length; _i++) { + var typeNode = _a[_i]; + if (!isIndependentType(typeNode)) { + return false; + } + } + } + return true; + } + // A type is considered independent if it the any, string, number, boolean, symbol, or void keyword, a string + // literal type, an array with an element type that is considered independent, or a type reference that is + // considered independent. + function isIndependentType(node) { + switch (node.kind) { + case 117 /* AnyKeyword */: + case 130 /* StringKeyword */: + case 128 /* NumberKeyword */: + case 120 /* BooleanKeyword */: + case 131 /* SymbolKeyword */: + case 103 /* VoidKeyword */: + case 9 /* StringLiteral */: + return true; + case 156 /* ArrayType */: + return isIndependentType(node.elementType); + case 151 /* TypeReference */: + return isIndependentTypeReference(node); + } + return false; + } + // A variable-like declaration is considered independent (free of this references) if it has a type annotation + // that specifies an independent type, or if it has no type annotation and no initializer (and thus of type any). + function isIndependentVariableLikeDeclaration(node) { + return node.type && isIndependentType(node.type) || !node.type && !node.initializer; + } + // A function-like declaration is considered independent (free of this references) if it has a return type + // annotation that is considered independent and if each parameter is considered independent. + function isIndependentFunctionLikeDeclaration(node) { + if (node.kind !== 144 /* Constructor */ && (!node.type || !isIndependentType(node.type))) { + return false; + } + for (var _i = 0, _a = node.parameters; _i < _a.length; _i++) { + var parameter = _a[_i]; + if (!isIndependentVariableLikeDeclaration(parameter)) { + return false; + } + } + return true; + } + // Returns true if the class or interface member given by the symbol is free of "this" references. The + // function may return false for symbols that are actually free of "this" references because it is not + // feasible to perform a complete analysis in all cases. In particular, property members with types + // inferred from their initializers and function members with inferred return types are convervatively + // assumed not to be free of "this" references. + function isIndependentMember(symbol) { + if (symbol.declarations && symbol.declarations.length === 1) { + var declaration = symbol.declarations[0]; + if (declaration) { + switch (declaration.kind) { + case 141 /* PropertyDeclaration */: + case 140 /* PropertySignature */: + return isIndependentVariableLikeDeclaration(declaration); + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: + case 144 /* Constructor */: + return isIndependentFunctionLikeDeclaration(declaration); + } + } + } + return false; + } function createSymbolTable(symbols) { var result = {}; for (var _i = 0; _i < symbols.length; _i++) { @@ -15605,11 +16074,13 @@ var ts; } return result; } - function createInstantiatedSymbolTable(symbols, mapper) { + // The mappingThisOnly flag indicates that the only type parameter being mapped is "this". When the flag is true, + // we check symbols to see if we can quickly conclude they are free of "this" references, thus needing no instantiation. + function createInstantiatedSymbolTable(symbols, mapper, mappingThisOnly) { var result = {}; for (var _i = 0; _i < symbols.length; _i++) { var symbol = symbols[_i]; - result[symbol.name] = instantiateSymbol(symbol, mapper); + result[symbol.name] = mappingThisOnly && isIndependentMember(symbol) ? symbol : instantiateSymbol(symbol, mapper); } return result; } @@ -15640,44 +16111,54 @@ var ts; } return type; } - function resolveClassOrInterfaceMembers(type) { - var target = resolveDeclaredMembers(type); - var members = target.symbol.members; - var callSignatures = target.declaredCallSignatures; - var constructSignatures = target.declaredConstructSignatures; - var stringIndexType = target.declaredStringIndexType; - var numberIndexType = target.declaredNumberIndexType; - var baseTypes = getBaseTypes(target); + function getTypeWithThisArgument(type, thisArgument) { + if (type.flags & 4096 /* Reference */) { + return createTypeReference(type.target, ts.concatenate(type.typeArguments, [thisArgument || type.target.thisType])); + } + return type; + } + function resolveObjectTypeMembers(type, source, typeParameters, typeArguments) { + var mapper = identityMapper; + var members = source.symbol.members; + var callSignatures = source.declaredCallSignatures; + var constructSignatures = source.declaredConstructSignatures; + var stringIndexType = source.declaredStringIndexType; + var numberIndexType = source.declaredNumberIndexType; + if (!ts.rangeEquals(typeParameters, typeArguments, 0, typeParameters.length)) { + mapper = createTypeMapper(typeParameters, typeArguments); + members = createInstantiatedSymbolTable(source.declaredProperties, mapper, /*mappingThisOnly*/ typeParameters.length === 1); + callSignatures = instantiateList(source.declaredCallSignatures, mapper, instantiateSignature); + constructSignatures = instantiateList(source.declaredConstructSignatures, mapper, instantiateSignature); + stringIndexType = instantiateType(source.declaredStringIndexType, mapper); + numberIndexType = instantiateType(source.declaredNumberIndexType, mapper); + } + var baseTypes = getBaseTypes(source); if (baseTypes.length) { - members = createSymbolTable(target.declaredProperties); + if (members === source.symbol.members) { + members = createSymbolTable(source.declaredProperties); + } + var thisArgument = ts.lastOrUndefined(typeArguments); for (var _i = 0; _i < baseTypes.length; _i++) { var baseType = baseTypes[_i]; - addInheritedMembers(members, getPropertiesOfObjectType(baseType)); - callSignatures = ts.concatenate(callSignatures, getSignaturesOfType(baseType, 0 /* Call */)); - constructSignatures = ts.concatenate(constructSignatures, getSignaturesOfType(baseType, 1 /* Construct */)); - stringIndexType = stringIndexType || getIndexTypeOfType(baseType, 0 /* String */); - numberIndexType = numberIndexType || getIndexTypeOfType(baseType, 1 /* Number */); + var instantiatedBaseType = thisArgument ? getTypeWithThisArgument(instantiateType(baseType, mapper), thisArgument) : baseType; + addInheritedMembers(members, getPropertiesOfObjectType(instantiatedBaseType)); + callSignatures = ts.concatenate(callSignatures, getSignaturesOfType(instantiatedBaseType, 0 /* Call */)); + constructSignatures = ts.concatenate(constructSignatures, getSignaturesOfType(instantiatedBaseType, 1 /* Construct */)); + stringIndexType = stringIndexType || getIndexTypeOfType(instantiatedBaseType, 0 /* String */); + numberIndexType = numberIndexType || getIndexTypeOfType(instantiatedBaseType, 1 /* Number */); } } setObjectTypeMembers(type, members, callSignatures, constructSignatures, stringIndexType, numberIndexType); } + function resolveClassOrInterfaceMembers(type) { + resolveObjectTypeMembers(type, resolveDeclaredMembers(type), emptyArray, emptyArray); + } function resolveTypeReferenceMembers(type) { - var target = resolveDeclaredMembers(type.target); - var mapper = createTypeMapper(target.typeParameters, type.typeArguments); - var members = createInstantiatedSymbolTable(target.declaredProperties, mapper); - var callSignatures = instantiateList(target.declaredCallSignatures, mapper, instantiateSignature); - var constructSignatures = instantiateList(target.declaredConstructSignatures, mapper, instantiateSignature); - var stringIndexType = target.declaredStringIndexType ? instantiateType(target.declaredStringIndexType, mapper) : undefined; - var numberIndexType = target.declaredNumberIndexType ? instantiateType(target.declaredNumberIndexType, mapper) : undefined; - ts.forEach(getBaseTypes(target), function (baseType) { - var instantiatedBaseType = instantiateType(baseType, mapper); - addInheritedMembers(members, getPropertiesOfObjectType(instantiatedBaseType)); - callSignatures = ts.concatenate(callSignatures, getSignaturesOfType(instantiatedBaseType, 0 /* Call */)); - constructSignatures = ts.concatenate(constructSignatures, getSignaturesOfType(instantiatedBaseType, 1 /* Construct */)); - stringIndexType = stringIndexType || getIndexTypeOfType(instantiatedBaseType, 0 /* String */); - numberIndexType = numberIndexType || getIndexTypeOfType(instantiatedBaseType, 1 /* Number */); - }); - setObjectTypeMembers(type, members, callSignatures, constructSignatures, stringIndexType, numberIndexType); + var source = resolveDeclaredMembers(type.target); + var typeParameters = ts.concatenate(source.typeParameters, [source.thisType]); + var typeArguments = type.typeArguments && type.typeArguments.length === typeParameters.length ? + type.typeArguments : ts.concatenate(type.typeArguments, [type]); + resolveObjectTypeMembers(type, source, typeParameters, typeArguments); } function createSignature(declaration, typeParameters, parameters, resolvedReturnType, typePredicate, minArgumentCount, hasRestParameter, hasStringLiterals) { var sig = new Signature(checker); @@ -15726,7 +16207,9 @@ var ts; return members; } function resolveTupleTypeMembers(type) { - var arrayType = resolveStructuredTypeMembers(createArrayType(getUnionType(type.elementTypes, /*noSubtypeReduction*/ true))); + var arrayElementType = getUnionType(type.elementTypes, /*noSubtypeReduction*/ true); + // Make the tuple type itself the 'this' type by including an extra type argument + var arrayType = resolveStructuredTypeMembers(createTypeFromGenericGlobalType(globalArrayType, [arrayElementType, type])); var members = createTupleTypeMemberSymbols(type.elementTypes); addInheritedMembers(members, arrayType.properties); setObjectTypeMembers(type, members, arrayType.callSignatures, arrayType.constructSignatures, arrayType.stringIndexType, arrayType.numberIndexType); @@ -15842,7 +16325,14 @@ var ts; var constructSignatures; var stringIndexType; var numberIndexType; - if (symbol.flags & 2048 /* TypeLiteral */) { + if (type.target) { + members = createInstantiatedSymbolTable(getPropertiesOfObjectType(type.target), type.mapper, /*mappingThisOnly*/ false); + callSignatures = instantiateList(getSignaturesOfType(type.target, 0 /* Call */), type.mapper, instantiateSignature); + constructSignatures = instantiateList(getSignaturesOfType(type.target, 1 /* Construct */), type.mapper, instantiateSignature); + stringIndexType = instantiateType(getIndexTypeOfType(type.target, 0 /* String */), type.mapper); + numberIndexType = instantiateType(getIndexTypeOfType(type.target, 1 /* Number */), type.mapper); + } + else if (symbol.flags & 2048 /* TypeLiteral */) { members = symbol.members; callSignatures = getSignaturesOfSymbol(members["__call"]); constructSignatures = getSignaturesOfSymbol(members["__new"]); @@ -15879,7 +16369,10 @@ var ts; } function resolveStructuredTypeMembers(type) { if (!type.members) { - if (type.flags & (1024 /* Class */ | 2048 /* Interface */)) { + if (type.flags & 4096 /* Reference */) { + resolveTypeReferenceMembers(type); + } + else if (type.flags & (1024 /* Class */ | 2048 /* Interface */)) { resolveClassOrInterfaceMembers(type); } else if (type.flags & 65536 /* Anonymous */) { @@ -15894,9 +16387,6 @@ var ts; else if (type.flags & 32768 /* Intersection */) { resolveIntersectionTypeMembers(type); } - else { - resolveTypeReferenceMembers(type); - } } return type; } @@ -16125,7 +16615,7 @@ var ts; function getSignatureFromDeclaration(declaration) { var links = getNodeLinks(declaration); if (!links.resolvedSignature) { - var classType = declaration.kind === 142 /* Constructor */ ? getDeclaredTypeOfClassOrInterface(declaration.parent.symbol) : undefined; + var classType = declaration.kind === 144 /* Constructor */ ? getDeclaredTypeOfClassOrInterface(declaration.parent.symbol) : undefined; var typeParameters = classType ? classType.localTypeParameters : declaration.typeParameters ? getTypeParametersFromDeclaration(declaration.typeParameters) : undefined; var parameters = []; @@ -16157,7 +16647,7 @@ var ts; } else if (declaration.type) { returnType = getTypeFromTypeNode(declaration.type); - if (declaration.type.kind === 148 /* TypePredicate */) { + if (declaration.type.kind === 150 /* TypePredicate */) { var typePredicateNode = declaration.type; typePredicate = { parameterName: typePredicateNode.parameterName ? typePredicateNode.parameterName.text : undefined, @@ -16169,8 +16659,8 @@ var ts; else { // TypeScript 1.0 spec (April 2014): // If only one accessor includes a type annotation, the other behaves as if it had the same type annotation. - if (declaration.kind === 143 /* GetAccessor */ && !ts.hasDynamicName(declaration)) { - var setter = ts.getDeclarationOfKind(declaration.symbol, 144 /* SetAccessor */); + if (declaration.kind === 145 /* GetAccessor */ && !ts.hasDynamicName(declaration)) { + var setter = ts.getDeclarationOfKind(declaration.symbol, 146 /* SetAccessor */); returnType = getAnnotatedAccessorType(setter); } if (!returnType && ts.nodeIsMissing(declaration.body)) { @@ -16188,19 +16678,19 @@ var ts; for (var i = 0, len = symbol.declarations.length; i < len; i++) { var node = symbol.declarations[i]; switch (node.kind) { - case 150 /* FunctionType */: - case 151 /* ConstructorType */: - case 211 /* FunctionDeclaration */: - case 141 /* MethodDeclaration */: - case 140 /* MethodSignature */: - case 142 /* Constructor */: - case 145 /* CallSignature */: - case 146 /* ConstructSignature */: - case 147 /* IndexSignature */: - case 143 /* GetAccessor */: - case 144 /* SetAccessor */: - case 171 /* FunctionExpression */: - case 172 /* ArrowFunction */: + case 152 /* FunctionType */: + case 153 /* ConstructorType */: + case 213 /* FunctionDeclaration */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: + case 144 /* Constructor */: + case 147 /* CallSignature */: + case 148 /* ConstructSignature */: + case 149 /* IndexSignature */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: + case 173 /* FunctionExpression */: + case 174 /* ArrowFunction */: // Don't include signature if node is the implementation of an overloaded function. A node is considered // an implementation node if it has a body and the previous node is of the same kind and immediately // precedes the implementation node (i.e. has the same parent and ends where the implementation starts). @@ -16215,6 +16705,16 @@ var ts; } return result; } + function resolveExternalModuleTypeByLiteral(name) { + var moduleSym = resolveExternalModuleName(name, name); + if (moduleSym) { + var resolvedModuleSymbol = resolveExternalModuleSymbol(moduleSym); + if (resolvedModuleSymbol) { + return getTypeOfSymbol(resolvedModuleSymbol); + } + } + return anyType; + } function getReturnTypeOfSignature(signature) { if (!signature.resolvedReturnType) { if (!pushTypeResolution(signature, 3 /* ResolvedReturnType */)) { @@ -16277,7 +16777,7 @@ var ts; // object type literal or interface (using the new keyword). Each way of declaring a constructor // will result in a different declaration kind. if (!signature.isolatedSignatureType) { - var isConstructor = signature.declaration.kind === 142 /* Constructor */ || signature.declaration.kind === 146 /* ConstructSignature */; + var isConstructor = signature.declaration.kind === 144 /* Constructor */ || signature.declaration.kind === 148 /* ConstructSignature */; var type = createObjectType(65536 /* Anonymous */ | 262144 /* FromSignature */); type.members = emptySymbols; type.properties = emptyArray; @@ -16291,7 +16791,7 @@ var ts; return symbol.members["__index"]; } function getIndexDeclarationOfSymbol(symbol, kind) { - var syntaxKind = kind === 1 /* Number */ ? 126 /* NumberKeyword */ : 128 /* StringKeyword */; + var syntaxKind = kind === 1 /* Number */ ? 128 /* NumberKeyword */ : 130 /* StringKeyword */; var indexSymbol = getIndexSymbol(symbol); if (indexSymbol) { for (var _i = 0, _a = indexSymbol.declarations; _i < _a.length; _i++) { @@ -16320,30 +16820,33 @@ var ts; type.constraint = targetConstraint ? instantiateType(targetConstraint, type.mapper) : noConstraintType; } else { - type.constraint = getTypeFromTypeNode(ts.getDeclarationOfKind(type.symbol, 135 /* TypeParameter */).constraint); + type.constraint = getTypeFromTypeNode(ts.getDeclarationOfKind(type.symbol, 137 /* TypeParameter */).constraint); } } return type.constraint === noConstraintType ? undefined : type.constraint; } function getParentSymbolOfTypeParameter(typeParameter) { - return getSymbolOfNode(ts.getDeclarationOfKind(typeParameter.symbol, 135 /* TypeParameter */).parent); + return getSymbolOfNode(ts.getDeclarationOfKind(typeParameter.symbol, 137 /* TypeParameter */).parent); } function getTypeListId(types) { - switch (types.length) { - case 1: - return "" + types[0].id; - case 2: - return types[0].id + "," + types[1].id; - default: - var result = ""; - for (var i = 0; i < types.length; i++) { - if (i > 0) { - result += ","; + if (types) { + switch (types.length) { + case 1: + return "" + types[0].id; + case 2: + return types[0].id + "," + types[1].id; + default: + var result = ""; + for (var i = 0; i < types.length; i++) { + if (i > 0) { + result += ","; + } + result += types[i].id; } - result += types[i].id; - } - return result; + return result; + } } + return ""; } // This function is used to propagate certain flags when creating new object type references and union types. // It is only necessary to do so if a constituent type might be the undefined type, the null type, the type @@ -16361,7 +16864,7 @@ var ts; var id = getTypeListId(typeArguments); var type = target.instantiations[id]; if (!type) { - var flags = 4096 /* Reference */ | getPropagatingFlagsOfTypes(typeArguments); + var flags = 4096 /* Reference */ | (typeArguments ? getPropagatingFlagsOfTypes(typeArguments) : 0); type = target.instantiations[id] = createObjectType(flags, target.symbol); type.target = target; type.typeArguments = typeArguments; @@ -16380,13 +16883,13 @@ var ts; currentNode = currentNode.parent; } // if last step was made from the type parameter this means that path has started somewhere in constraint which is illegal - links.isIllegalTypeReferenceInConstraint = currentNode.kind === 135 /* TypeParameter */; + links.isIllegalTypeReferenceInConstraint = currentNode.kind === 137 /* TypeParameter */; return links.isIllegalTypeReferenceInConstraint; } function checkTypeParameterHasIllegalReferencesInConstraint(typeParameter) { var typeParameterSymbol; function check(n) { - if (n.kind === 149 /* TypeReference */ && n.typeName.kind === 67 /* Identifier */) { + if (n.kind === 151 /* TypeReference */ && n.typeName.kind === 69 /* Identifier */) { var links = getNodeLinks(n); if (links.isIllegalTypeReferenceInConstraint === undefined) { var symbol = resolveName(typeParameter, n.typeName.text, 793056 /* Type */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined); @@ -16473,7 +16976,7 @@ var ts; var links = getNodeLinks(node); if (!links.resolvedType) { // We only support expressions that are simple qualified names. For other expressions this produces undefined. - var typeNameOrExpression = node.kind === 149 /* TypeReference */ ? node.typeName : + var typeNameOrExpression = node.kind === 151 /* TypeReference */ ? node.typeName : ts.isSupportedExpressionWithTypeArguments(node) ? node.expression : undefined; var symbol = typeNameOrExpression && resolveEntityName(typeNameOrExpression, 793056 /* Type */) || unknownSymbol; @@ -16505,9 +17008,9 @@ var ts; for (var _i = 0; _i < declarations.length; _i++) { var declaration = declarations[_i]; switch (declaration.kind) { - case 212 /* ClassDeclaration */: - case 213 /* InterfaceDeclaration */: - case 215 /* EnumDeclaration */: + case 214 /* ClassDeclaration */: + case 215 /* InterfaceDeclaration */: + case 217 /* EnumDeclaration */: return declaration; } } @@ -16548,10 +17051,13 @@ var ts; * getExportedTypeFromNamespace('JSX', 'Element') returns the JSX.Element type */ function getExportedTypeFromNamespace(namespace, name) { - var namespaceSymbol = getGlobalSymbol(namespace, 1536 /* Namespace */, /*diagnosticMessage*/ undefined); - var typeSymbol = namespaceSymbol && getSymbol(namespaceSymbol.exports, name, 793056 /* Type */); + var typeSymbol = getExportedSymbolFromNamespace(namespace, name); return typeSymbol && getDeclaredTypeOfSymbol(typeSymbol); } + function getExportedSymbolFromNamespace(namespace, name) { + var namespaceSymbol = getGlobalSymbol(namespace, 1536 /* Namespace */, /*diagnosticMessage*/ undefined); + return namespaceSymbol && getSymbol(namespaceSymbol.exports, name, 793056 /* Type */ | 107455 /* Value */); + } function getGlobalESSymbolConstructorSymbol() { return globalESSymbolConstructorSymbol || (globalESSymbolConstructorSymbol = getGlobalValueSymbol("Symbol")); } @@ -16567,17 +17073,17 @@ var ts; /** * Instantiates a global type that is generic with some element type, and returns that instantiation. */ - function createTypeFromGenericGlobalType(genericGlobalType, elementType) { - return genericGlobalType !== emptyGenericType ? createTypeReference(genericGlobalType, [elementType]) : emptyObjectType; + function createTypeFromGenericGlobalType(genericGlobalType, typeArguments) { + return genericGlobalType !== emptyGenericType ? createTypeReference(genericGlobalType, typeArguments) : emptyObjectType; } function createIterableType(elementType) { - return createTypeFromGenericGlobalType(globalIterableType, elementType); + return createTypeFromGenericGlobalType(globalIterableType, [elementType]); } function createIterableIteratorType(elementType) { - return createTypeFromGenericGlobalType(globalIterableIteratorType, elementType); + return createTypeFromGenericGlobalType(globalIterableIteratorType, [elementType]); } function createArrayType(elementType) { - return createTypeFromGenericGlobalType(globalArrayType, elementType); + return createTypeFromGenericGlobalType(globalArrayType, [elementType]); } function getTypeFromArrayTypeNode(node) { var links = getNodeLinks(node); @@ -16749,48 +17255,68 @@ var ts; } return links.resolvedType; } + function getThisType(node) { + var container = ts.getThisContainer(node, /*includeArrowFunctions*/ false); + var parent = container && container.parent; + if (parent && (ts.isClassLike(parent) || parent.kind === 215 /* InterfaceDeclaration */)) { + if (!(container.flags & 128 /* Static */)) { + return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(parent)).thisType; + } + } + error(node, ts.Diagnostics.A_this_type_is_available_only_in_a_non_static_member_of_a_class_or_interface); + return unknownType; + } + function getTypeFromThisTypeNode(node) { + var links = getNodeLinks(node); + if (!links.resolvedType) { + links.resolvedType = getThisType(node); + } + return links.resolvedType; + } function getTypeFromTypeNode(node) { switch (node.kind) { - case 115 /* AnyKeyword */: + case 117 /* AnyKeyword */: return anyType; - case 128 /* StringKeyword */: + case 130 /* StringKeyword */: return stringType; - case 126 /* NumberKeyword */: + case 128 /* NumberKeyword */: return numberType; - case 118 /* BooleanKeyword */: + case 120 /* BooleanKeyword */: return booleanType; - case 129 /* SymbolKeyword */: + case 131 /* SymbolKeyword */: return esSymbolType; - case 101 /* VoidKeyword */: + case 103 /* VoidKeyword */: return voidType; + case 97 /* ThisKeyword */: + return getTypeFromThisTypeNode(node); case 9 /* StringLiteral */: return getTypeFromStringLiteral(node); - case 149 /* TypeReference */: + case 151 /* TypeReference */: return getTypeFromTypeReference(node); - case 148 /* TypePredicate */: + case 150 /* TypePredicate */: return booleanType; - case 186 /* ExpressionWithTypeArguments */: + case 188 /* ExpressionWithTypeArguments */: return getTypeFromTypeReference(node); - case 152 /* TypeQuery */: + case 154 /* TypeQuery */: return getTypeFromTypeQueryNode(node); - case 154 /* ArrayType */: + case 156 /* ArrayType */: return getTypeFromArrayTypeNode(node); - case 155 /* TupleType */: + case 157 /* TupleType */: return getTypeFromTupleTypeNode(node); - case 156 /* UnionType */: + case 158 /* UnionType */: return getTypeFromUnionTypeNode(node); - case 157 /* IntersectionType */: + case 159 /* IntersectionType */: return getTypeFromIntersectionTypeNode(node); - case 158 /* ParenthesizedType */: + case 160 /* ParenthesizedType */: return getTypeFromTypeNode(node.type); - case 150 /* FunctionType */: - case 151 /* ConstructorType */: - case 153 /* TypeLiteral */: + case 152 /* FunctionType */: + case 153 /* ConstructorType */: + case 155 /* TypeLiteral */: return getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node); // This function assumes that an identifier or qualified name is a type expression // Callers should first ensure this by calling isTypeNode - case 67 /* Identifier */: - case 133 /* QualifiedName */: + case 69 /* Identifier */: + case 135 /* QualifiedName */: var symbol = getSymbolAtLocation(node); return symbol && getDeclaredTypeOfSymbol(symbol); default: @@ -16894,7 +17420,7 @@ var ts; type: instantiateType(signature.typePredicate.type, mapper) }; } - var result = createSignature(signature.declaration, freshTypeParameters, instantiateList(signature.parameters, mapper, instantiateSymbol), signature.resolvedReturnType ? instantiateType(signature.resolvedReturnType, mapper) : undefined, freshTypePredicate, signature.minArgumentCount, signature.hasRestParameter, signature.hasStringLiterals); + var result = createSignature(signature.declaration, freshTypeParameters, instantiateList(signature.parameters, mapper, instantiateSymbol), instantiateType(signature.resolvedReturnType, mapper), freshTypePredicate, signature.minArgumentCount, signature.hasRestParameter, signature.hasStringLiterals); result.target = signature; result.mapper = mapper; return result; @@ -16932,21 +17458,13 @@ var ts; } // Mark the anonymous type as instantiated such that our infinite instantiation detection logic can recognize it var result = createObjectType(65536 /* Anonymous */ | 131072 /* Instantiated */, type.symbol); - result.properties = instantiateList(getPropertiesOfObjectType(type), mapper, instantiateSymbol); - result.members = createSymbolTable(result.properties); - result.callSignatures = instantiateList(getSignaturesOfType(type, 0 /* Call */), mapper, instantiateSignature); - result.constructSignatures = instantiateList(getSignaturesOfType(type, 1 /* Construct */), mapper, instantiateSignature); - var stringIndexType = getIndexTypeOfType(type, 0 /* String */); - var numberIndexType = getIndexTypeOfType(type, 1 /* Number */); - if (stringIndexType) - result.stringIndexType = instantiateType(stringIndexType, mapper); - if (numberIndexType) - result.numberIndexType = instantiateType(numberIndexType, mapper); + result.target = type; + result.mapper = mapper; mapper.instantiations[type.id] = result; return result; } function instantiateType(type, mapper) { - if (mapper !== identityMapper) { + if (type && mapper !== identityMapper) { if (type.flags & 512 /* TypeParameter */) { return mapper(type); } @@ -16972,27 +17490,27 @@ var ts; // Returns true if the given expression contains (at any level of nesting) a function or arrow expression // that is subject to contextual typing. function isContextSensitive(node) { - ts.Debug.assert(node.kind !== 141 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 143 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); switch (node.kind) { - case 171 /* FunctionExpression */: - case 172 /* ArrowFunction */: + case 173 /* FunctionExpression */: + case 174 /* ArrowFunction */: return isContextSensitiveFunctionLikeDeclaration(node); - case 163 /* ObjectLiteralExpression */: + case 165 /* ObjectLiteralExpression */: return ts.forEach(node.properties, isContextSensitive); - case 162 /* ArrayLiteralExpression */: + case 164 /* ArrayLiteralExpression */: return ts.forEach(node.elements, isContextSensitive); - case 180 /* ConditionalExpression */: + case 182 /* ConditionalExpression */: return isContextSensitive(node.whenTrue) || isContextSensitive(node.whenFalse); - case 179 /* BinaryExpression */: - return node.operatorToken.kind === 51 /* BarBarToken */ && + case 181 /* BinaryExpression */: + return node.operatorToken.kind === 52 /* BarBarToken */ && (isContextSensitive(node.left) || isContextSensitive(node.right)); - case 243 /* PropertyAssignment */: + case 245 /* PropertyAssignment */: return isContextSensitive(node.initializer); - case 141 /* MethodDeclaration */: - case 140 /* MethodSignature */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: return isContextSensitiveFunctionLikeDeclaration(node); - case 170 /* ParenthesizedExpression */: + case 172 /* ParenthesizedExpression */: return isContextSensitive(node.expression); } return false; @@ -17176,7 +17694,7 @@ var ts; else { if (source.flags & 4096 /* Reference */ && target.flags & 4096 /* Reference */ && source.target === target.target) { // We have type references to same target type, see if relationship holds for all type arguments - if (result = typesRelatedTo(source.typeArguments, target.typeArguments, reportErrors)) { + if (result = typeArgumentsRelatedTo(source, target, reportErrors)) { return result; } } @@ -17205,7 +17723,7 @@ var ts; if (source.flags & 80896 /* ObjectType */ && target.flags & 80896 /* ObjectType */) { if (source.flags & 4096 /* Reference */ && target.flags & 4096 /* Reference */ && source.target === target.target) { // We have type references to same target type, see if all type arguments are identical - if (result = typesRelatedTo(source.typeArguments, target.typeArguments, /*reportErrors*/ false)) { + if (result = typeArgumentsRelatedTo(source, target, /*reportErrors*/ false)) { return result; } } @@ -17322,9 +17840,14 @@ var ts; } return result; } - function typesRelatedTo(sources, targets, reportErrors) { + function typeArgumentsRelatedTo(source, target, reportErrors) { + var sources = source.typeArguments || emptyArray; + var targets = target.typeArguments || emptyArray; + if (sources.length !== targets.length && relation === identityRelation) { + return 0 /* False */; + } var result = -1 /* True */; - for (var i = 0, len = sources.length; i < len; i++) { + for (var i = 0; i < targets.length; i++) { var related = isRelatedTo(sources[i], targets[i], reportErrors); if (!related) { return 0 /* False */; @@ -17542,7 +18065,7 @@ var ts; if (kind === 1 /* Construct */) { // Only want to compare the construct signatures for abstractness guarantees. // Because the "abstractness" of a class is the same across all construct signatures - // (internally we are checking the corresponding declaration), it is enough to perform + // (internally we are checking the corresponding declaration), it is enough to perform // the check and report an error once over all pairs of source and target construct signatures. // // sourceSig and targetSig are (possibly) undefined. @@ -18042,22 +18565,22 @@ var ts; var typeAsString = typeToString(getWidenedType(type)); var diagnostic; switch (declaration.kind) { - case 139 /* PropertyDeclaration */: - case 138 /* PropertySignature */: + case 141 /* PropertyDeclaration */: + case 140 /* PropertySignature */: diagnostic = ts.Diagnostics.Member_0_implicitly_has_an_1_type; break; - case 136 /* Parameter */: + case 138 /* Parameter */: diagnostic = declaration.dotDotDotToken ? ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type : ts.Diagnostics.Parameter_0_implicitly_has_an_1_type; break; - case 211 /* FunctionDeclaration */: - case 141 /* MethodDeclaration */: - case 140 /* MethodSignature */: - case 143 /* GetAccessor */: - case 144 /* SetAccessor */: - case 171 /* FunctionExpression */: - case 172 /* ArrowFunction */: + case 213 /* FunctionDeclaration */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: + case 173 /* FunctionExpression */: + case 174 /* ArrowFunction */: if (!declaration.name) { error(declaration, ts.Diagnostics.Function_expression_which_lacks_return_type_annotation_implicitly_has_an_0_return_type, typeAsString); return; @@ -18167,9 +18690,10 @@ var ts; } else if (source.flags & 4096 /* Reference */ && target.flags & 4096 /* Reference */ && source.target === target.target) { // If source and target are references to the same generic type, infer from type arguments - var sourceTypes = source.typeArguments; - var targetTypes = target.typeArguments; - for (var i = 0; i < sourceTypes.length; i++) { + var sourceTypes = source.typeArguments || emptyArray; + var targetTypes = target.typeArguments || emptyArray; + var count = sourceTypes.length < targetTypes.length ? sourceTypes.length : targetTypes.length; + for (var i = 0; i < count; i++) { inferFromTypes(sourceTypes[i], targetTypes[i]); } } @@ -18347,10 +18871,10 @@ var ts; // The expression is restricted to a single identifier or a sequence of identifiers separated by periods while (node) { switch (node.kind) { - case 152 /* TypeQuery */: + case 154 /* TypeQuery */: return true; - case 67 /* Identifier */: - case 133 /* QualifiedName */: + case 69 /* Identifier */: + case 135 /* QualifiedName */: node = node.parent; continue; default: @@ -18396,12 +18920,12 @@ var ts; } return links.assignmentChecks[symbol.id] = isAssignedIn(node); function isAssignedInBinaryExpression(node) { - if (node.operatorToken.kind >= 55 /* FirstAssignment */ && node.operatorToken.kind <= 66 /* LastAssignment */) { + if (node.operatorToken.kind >= 56 /* FirstAssignment */ && node.operatorToken.kind <= 68 /* LastAssignment */) { var n = node.left; - while (n.kind === 170 /* ParenthesizedExpression */) { + while (n.kind === 172 /* ParenthesizedExpression */) { n = n.expression; } - if (n.kind === 67 /* Identifier */ && getResolvedSymbol(n) === symbol) { + if (n.kind === 69 /* Identifier */ && getResolvedSymbol(n) === symbol) { return true; } } @@ -18415,55 +18939,55 @@ var ts; } function isAssignedIn(node) { switch (node.kind) { - case 179 /* BinaryExpression */: + case 181 /* BinaryExpression */: return isAssignedInBinaryExpression(node); - case 209 /* VariableDeclaration */: - case 161 /* BindingElement */: + case 211 /* VariableDeclaration */: + case 163 /* BindingElement */: return isAssignedInVariableDeclaration(node); - case 159 /* ObjectBindingPattern */: - case 160 /* ArrayBindingPattern */: - case 162 /* ArrayLiteralExpression */: - case 163 /* ObjectLiteralExpression */: - case 164 /* PropertyAccessExpression */: - case 165 /* ElementAccessExpression */: - case 166 /* CallExpression */: - case 167 /* NewExpression */: - case 169 /* TypeAssertionExpression */: - case 187 /* AsExpression */: - case 170 /* ParenthesizedExpression */: - case 177 /* PrefixUnaryExpression */: - case 173 /* DeleteExpression */: - case 176 /* AwaitExpression */: - case 174 /* TypeOfExpression */: - case 175 /* VoidExpression */: - case 178 /* PostfixUnaryExpression */: - case 182 /* YieldExpression */: - case 180 /* ConditionalExpression */: - case 183 /* SpreadElementExpression */: - case 190 /* Block */: - case 191 /* VariableStatement */: - case 193 /* ExpressionStatement */: - case 194 /* IfStatement */: - case 195 /* DoStatement */: - case 196 /* WhileStatement */: - case 197 /* ForStatement */: - case 198 /* ForInStatement */: - case 199 /* ForOfStatement */: - case 202 /* ReturnStatement */: - case 203 /* WithStatement */: - case 204 /* SwitchStatement */: - case 239 /* CaseClause */: - case 240 /* DefaultClause */: - case 205 /* LabeledStatement */: - case 206 /* ThrowStatement */: - case 207 /* TryStatement */: - case 242 /* CatchClause */: - case 231 /* JsxElement */: - case 232 /* JsxSelfClosingElement */: - case 236 /* JsxAttribute */: - case 237 /* JsxSpreadAttribute */: - case 233 /* JsxOpeningElement */: - case 238 /* JsxExpression */: + case 161 /* ObjectBindingPattern */: + case 162 /* ArrayBindingPattern */: + case 164 /* ArrayLiteralExpression */: + case 165 /* ObjectLiteralExpression */: + case 166 /* PropertyAccessExpression */: + case 167 /* ElementAccessExpression */: + case 168 /* CallExpression */: + case 169 /* NewExpression */: + case 171 /* TypeAssertionExpression */: + case 189 /* AsExpression */: + case 172 /* ParenthesizedExpression */: + case 179 /* PrefixUnaryExpression */: + case 175 /* DeleteExpression */: + case 178 /* AwaitExpression */: + case 176 /* TypeOfExpression */: + case 177 /* VoidExpression */: + case 180 /* PostfixUnaryExpression */: + case 184 /* YieldExpression */: + case 182 /* ConditionalExpression */: + case 185 /* SpreadElementExpression */: + case 192 /* Block */: + case 193 /* VariableStatement */: + case 195 /* ExpressionStatement */: + case 196 /* IfStatement */: + case 197 /* DoStatement */: + case 198 /* WhileStatement */: + case 199 /* ForStatement */: + case 200 /* ForInStatement */: + case 201 /* ForOfStatement */: + case 204 /* ReturnStatement */: + case 205 /* WithStatement */: + case 206 /* SwitchStatement */: + case 241 /* CaseClause */: + case 242 /* DefaultClause */: + case 207 /* LabeledStatement */: + case 208 /* ThrowStatement */: + case 209 /* TryStatement */: + case 244 /* CatchClause */: + case 233 /* JsxElement */: + case 234 /* JsxSelfClosingElement */: + case 238 /* JsxAttribute */: + case 239 /* JsxSpreadAttribute */: + case 235 /* JsxOpeningElement */: + case 240 /* JsxExpression */: return ts.forEachChild(node, isAssignedIn); } return false; @@ -18480,37 +19004,37 @@ var ts; node = node.parent; var narrowedType = type; switch (node.kind) { - case 194 /* IfStatement */: + case 196 /* IfStatement */: // In a branch of an if statement, narrow based on controlling expression if (child !== node.expression) { narrowedType = narrowType(type, node.expression, /*assumeTrue*/ child === node.thenStatement); } break; - case 180 /* ConditionalExpression */: + case 182 /* ConditionalExpression */: // In a branch of a conditional expression, narrow based on controlling condition if (child !== node.condition) { narrowedType = narrowType(type, node.condition, /*assumeTrue*/ child === node.whenTrue); } break; - case 179 /* BinaryExpression */: + case 181 /* BinaryExpression */: // In the right operand of an && or ||, narrow based on left operand if (child === node.right) { - if (node.operatorToken.kind === 50 /* AmpersandAmpersandToken */) { + if (node.operatorToken.kind === 51 /* AmpersandAmpersandToken */) { narrowedType = narrowType(type, node.left, /*assumeTrue*/ true); } - else if (node.operatorToken.kind === 51 /* BarBarToken */) { + else if (node.operatorToken.kind === 52 /* BarBarToken */) { narrowedType = narrowType(type, node.left, /*assumeTrue*/ false); } } break; - case 246 /* SourceFile */: - case 216 /* ModuleDeclaration */: - case 211 /* FunctionDeclaration */: - case 141 /* MethodDeclaration */: - case 140 /* MethodSignature */: - case 143 /* GetAccessor */: - case 144 /* SetAccessor */: - case 142 /* Constructor */: + case 248 /* SourceFile */: + case 218 /* ModuleDeclaration */: + case 213 /* FunctionDeclaration */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: + case 144 /* Constructor */: // Stop at the first containing function or module declaration break loop; } @@ -18527,12 +19051,12 @@ var ts; return type; function narrowTypeByEquality(type, expr, assumeTrue) { // Check that we have 'typeof ' on the left and string literal on the right - if (expr.left.kind !== 174 /* TypeOfExpression */ || expr.right.kind !== 9 /* StringLiteral */) { + if (expr.left.kind !== 176 /* TypeOfExpression */ || expr.right.kind !== 9 /* StringLiteral */) { return type; } var left = expr.left; var right = expr.right; - if (left.expression.kind !== 67 /* Identifier */ || getResolvedSymbol(left.expression) !== symbol) { + if (left.expression.kind !== 69 /* Identifier */ || getResolvedSymbol(left.expression) !== symbol) { return type; } var typeInfo = primitiveTypeInfo[right.text]; @@ -18592,7 +19116,7 @@ var ts; } function narrowTypeByInstanceof(type, expr, assumeTrue) { // Check that type is not any, assumed result is true, and we have variable symbol on the left - if (isTypeAny(type) || !assumeTrue || expr.left.kind !== 67 /* Identifier */ || getResolvedSymbol(expr.left) !== symbol) { + if (isTypeAny(type) || !assumeTrue || expr.left.kind !== 69 /* Identifier */ || getResolvedSymbol(expr.left) !== symbol) { return type; } // Check that right operand is a function type with a prototype property @@ -18664,27 +19188,27 @@ var ts; // will be a subtype or the same type as the argument. function narrowType(type, expr, assumeTrue) { switch (expr.kind) { - case 166 /* CallExpression */: + case 168 /* CallExpression */: return narrowTypeByTypePredicate(type, expr, assumeTrue); - case 170 /* ParenthesizedExpression */: + case 172 /* ParenthesizedExpression */: return narrowType(type, expr.expression, assumeTrue); - case 179 /* BinaryExpression */: + case 181 /* BinaryExpression */: var operator = expr.operatorToken.kind; if (operator === 32 /* EqualsEqualsEqualsToken */ || operator === 33 /* ExclamationEqualsEqualsToken */) { return narrowTypeByEquality(type, expr, assumeTrue); } - else if (operator === 50 /* AmpersandAmpersandToken */) { + else if (operator === 51 /* AmpersandAmpersandToken */) { return narrowTypeByAnd(type, expr, assumeTrue); } - else if (operator === 51 /* BarBarToken */) { + else if (operator === 52 /* BarBarToken */) { return narrowTypeByOr(type, expr, assumeTrue); } - else if (operator === 89 /* InstanceOfKeyword */) { + else if (operator === 91 /* InstanceOfKeyword */) { return narrowTypeByInstanceof(type, expr, assumeTrue); } break; - case 177 /* PrefixUnaryExpression */: - if (expr.operator === 48 /* ExclamationToken */) { + case 179 /* PrefixUnaryExpression */: + if (expr.operator === 49 /* ExclamationToken */) { return narrowType(type, expr.operand, !assumeTrue); } break; @@ -18702,7 +19226,7 @@ var ts; // can explicitly bound arguments objects if (symbol === argumentsSymbol) { var container = ts.getContainingFunction(node); - if (container.kind === 172 /* ArrowFunction */) { + if (container.kind === 174 /* ArrowFunction */) { if (languageVersion < 2 /* ES6 */) { error(node, ts.Diagnostics.The_arguments_object_cannot_be_referenced_in_an_arrow_function_in_ES3_and_ES5_Consider_using_a_standard_function_expression); } @@ -18733,7 +19257,7 @@ var ts; function checkBlockScopedBindingCapturedInLoop(node, symbol) { if (languageVersion >= 2 /* ES6 */ || (symbol.flags & 2 /* BlockScopedVariable */) === 0 || - symbol.valueDeclaration.parent.kind === 242 /* CatchClause */) { + symbol.valueDeclaration.parent.kind === 244 /* CatchClause */) { return; } // - check if binding is used in some function @@ -18742,12 +19266,12 @@ var ts; // nesting structure: // (variable declaration or binding element) -> variable declaration list -> container var container = symbol.valueDeclaration; - while (container.kind !== 210 /* VariableDeclarationList */) { + while (container.kind !== 212 /* VariableDeclarationList */) { container = container.parent; } // get the parent of variable declaration list container = container.parent; - if (container.kind === 191 /* VariableStatement */) { + if (container.kind === 193 /* VariableStatement */) { // if parent is variable statement - get its parent container = container.parent; } @@ -18767,7 +19291,7 @@ var ts; } function captureLexicalThis(node, container) { getNodeLinks(node).flags |= 2 /* LexicalThis */; - if (container.kind === 139 /* PropertyDeclaration */ || container.kind === 142 /* Constructor */) { + if (container.kind === 141 /* PropertyDeclaration */ || container.kind === 144 /* Constructor */) { var classNode = container.parent; getNodeLinks(classNode).flags |= 4 /* CaptureThis */; } @@ -18781,32 +19305,32 @@ var ts; var container = ts.getThisContainer(node, /* includeArrowFunctions */ true); var needToCaptureLexicalThis = false; // Now skip arrow functions to get the "real" owner of 'this'. - if (container.kind === 172 /* ArrowFunction */) { + if (container.kind === 174 /* ArrowFunction */) { container = ts.getThisContainer(container, /* includeArrowFunctions */ false); // When targeting es6, arrow function lexically bind "this" so we do not need to do the work of binding "this" in emitted code needToCaptureLexicalThis = (languageVersion < 2 /* ES6 */); } switch (container.kind) { - case 216 /* ModuleDeclaration */: + case 218 /* ModuleDeclaration */: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_module_or_namespace_body); // do not return here so in case if lexical this is captured - it will be reflected in flags on NodeLinks break; - case 215 /* EnumDeclaration */: + case 217 /* EnumDeclaration */: error(node, ts.Diagnostics.this_cannot_be_referenced_in_current_location); // do not return here so in case if lexical this is captured - it will be reflected in flags on NodeLinks break; - case 142 /* Constructor */: + case 144 /* Constructor */: if (isInConstructorArgumentInitializer(node, container)) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_constructor_arguments); } break; - case 139 /* PropertyDeclaration */: - case 138 /* PropertySignature */: + case 141 /* PropertyDeclaration */: + case 140 /* PropertySignature */: if (container.flags & 128 /* Static */) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_static_property_initializer); } break; - case 134 /* ComputedPropertyName */: + case 136 /* ComputedPropertyName */: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_computed_property_name); break; } @@ -18815,35 +19339,35 @@ var ts; } if (ts.isClassLike(container.parent)) { var symbol = getSymbolOfNode(container.parent); - return container.flags & 128 /* Static */ ? getTypeOfSymbol(symbol) : getDeclaredTypeOfSymbol(symbol); + return container.flags & 128 /* Static */ ? getTypeOfSymbol(symbol) : getDeclaredTypeOfSymbol(symbol).thisType; } return anyType; } function isInConstructorArgumentInitializer(node, constructorDecl) { for (var n = node; n && n !== constructorDecl; n = n.parent) { - if (n.kind === 136 /* Parameter */) { + if (n.kind === 138 /* Parameter */) { return true; } } return false; } function checkSuperExpression(node) { - var isCallExpression = node.parent.kind === 166 /* CallExpression */ && node.parent.expression === node; + var isCallExpression = node.parent.kind === 168 /* CallExpression */ && node.parent.expression === node; var classDeclaration = ts.getContainingClass(node); var classType = classDeclaration && getDeclaredTypeOfSymbol(getSymbolOfNode(classDeclaration)); var baseClassType = classType && getBaseTypes(classType)[0]; var container = ts.getSuperContainer(node, /*includeFunctions*/ true); var needToCaptureLexicalThis = false; if (!isCallExpression) { - // adjust the container reference in case if super is used inside arrow functions with arbitrary deep nesting - while (container && container.kind === 172 /* ArrowFunction */) { + // adjust the container reference in case if super is used inside arrow functions with arbitrary deep nesting + while (container && container.kind === 174 /* ArrowFunction */) { container = ts.getSuperContainer(container, /*includeFunctions*/ true); needToCaptureLexicalThis = languageVersion < 2 /* ES6 */; } } var canUseSuperExpression = isLegalUsageOfSuperExpression(container); var nodeCheckFlag = 0; - // always set NodeCheckFlags for 'super' expression node + // always set NodeCheckFlags for 'super' expression node if (canUseSuperExpression) { if ((container.flags & 128 /* Static */) || isCallExpression) { nodeCheckFlag = 512 /* SuperStatic */; @@ -18866,7 +19390,7 @@ var ts; return unknownType; } if (!canUseSuperExpression) { - if (container && container.kind === 134 /* ComputedPropertyName */) { + if (container && container.kind === 136 /* ComputedPropertyName */) { error(node, ts.Diagnostics.super_cannot_be_referenced_in_a_computed_property_name); } else if (isCallExpression) { @@ -18877,7 +19401,7 @@ var ts; } return unknownType; } - if (container.kind === 142 /* Constructor */ && isInConstructorArgumentInitializer(node, container)) { + if (container.kind === 144 /* Constructor */ && isInConstructorArgumentInitializer(node, container)) { // issue custom error message for super property access in constructor arguments (to be aligned with old compiler) error(node, ts.Diagnostics.super_cannot_be_referenced_in_constructor_arguments); return unknownType; @@ -18892,7 +19416,7 @@ var ts; if (isCallExpression) { // TS 1.0 SPEC (April 2014): 4.8.1 // Super calls are only permitted in constructors of derived classes - return container.kind === 142 /* Constructor */; + return container.kind === 144 /* Constructor */; } else { // TS 1.0 SPEC (April 2014) @@ -18902,19 +19426,19 @@ var ts; // topmost container must be something that is directly nested in the class declaration if (container && ts.isClassLike(container.parent)) { if (container.flags & 128 /* Static */) { - return container.kind === 141 /* MethodDeclaration */ || - container.kind === 140 /* MethodSignature */ || - container.kind === 143 /* GetAccessor */ || - container.kind === 144 /* SetAccessor */; + return container.kind === 143 /* MethodDeclaration */ || + container.kind === 142 /* MethodSignature */ || + container.kind === 145 /* GetAccessor */ || + container.kind === 146 /* SetAccessor */; } else { - return container.kind === 141 /* MethodDeclaration */ || - container.kind === 140 /* MethodSignature */ || - container.kind === 143 /* GetAccessor */ || - container.kind === 144 /* SetAccessor */ || - container.kind === 139 /* PropertyDeclaration */ || - container.kind === 138 /* PropertySignature */ || - container.kind === 142 /* Constructor */; + return container.kind === 143 /* MethodDeclaration */ || + container.kind === 142 /* MethodSignature */ || + container.kind === 145 /* GetAccessor */ || + container.kind === 146 /* SetAccessor */ || + container.kind === 141 /* PropertyDeclaration */ || + container.kind === 140 /* PropertySignature */ || + container.kind === 144 /* Constructor */; } } } @@ -18955,7 +19479,7 @@ var ts; if (declaration.type) { return getTypeFromTypeNode(declaration.type); } - if (declaration.kind === 136 /* Parameter */) { + if (declaration.kind === 138 /* Parameter */) { var type = getContextuallyTypedParameterType(declaration); if (type) { return type; @@ -18988,7 +19512,7 @@ var ts; } function isInParameterInitializerBeforeContainingFunction(node) { while (node.parent && !ts.isFunctionLike(node.parent)) { - if (node.parent.kind === 136 /* Parameter */ && node.parent.initializer === node) { + if (node.parent.kind === 138 /* Parameter */ && node.parent.initializer === node) { return true; } node = node.parent; @@ -18999,8 +19523,8 @@ var ts; // If the containing function has a return type annotation, is a constructor, or is a get accessor whose // corresponding set accessor has a type annotation, return statements in the function are contextually typed if (functionDecl.type || - functionDecl.kind === 142 /* Constructor */ || - functionDecl.kind === 143 /* GetAccessor */ && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(functionDecl.symbol, 144 /* SetAccessor */))) { + functionDecl.kind === 144 /* Constructor */ || + functionDecl.kind === 145 /* GetAccessor */ && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(functionDecl.symbol, 146 /* SetAccessor */))) { return getReturnTypeOfSignature(getSignatureFromDeclaration(functionDecl)); } // Otherwise, if the containing function is contextually typed by a function type with exactly one call signature @@ -19022,7 +19546,7 @@ var ts; return undefined; } function getContextualTypeForSubstitutionExpression(template, substitutionExpression) { - if (template.parent.kind === 168 /* TaggedTemplateExpression */) { + if (template.parent.kind === 170 /* TaggedTemplateExpression */) { return getContextualTypeForArgument(template.parent, substitutionExpression); } return undefined; @@ -19030,13 +19554,13 @@ var ts; function getContextualTypeForBinaryOperand(node) { var binaryExpression = node.parent; var operator = binaryExpression.operatorToken.kind; - if (operator >= 55 /* FirstAssignment */ && operator <= 66 /* LastAssignment */) { + if (operator >= 56 /* FirstAssignment */ && operator <= 68 /* LastAssignment */) { // In an assignment expression, the right operand is contextually typed by the type of the left operand. if (node === binaryExpression.right) { return checkExpression(binaryExpression.left); } } - else if (operator === 51 /* BarBarToken */) { + else if (operator === 52 /* BarBarToken */) { // When an || expression has a contextual type, the operands are contextually typed by that type. When an || // expression has no contextual type, the right operand is contextually typed by the type of the left operand. var type = getContextualType(binaryExpression); @@ -19143,7 +19667,7 @@ var ts; } function getContextualTypeForJsxExpression(expr) { // Contextual type only applies to JSX expressions that are in attribute assignments (not in 'Children' positions) - if (expr.parent.kind === 236 /* JsxAttribute */) { + if (expr.parent.kind === 238 /* JsxAttribute */) { var attrib = expr.parent; var attrsType = getJsxElementAttributesType(attrib.parent); if (!attrsType || isTypeAny(attrsType)) { @@ -19153,7 +19677,7 @@ var ts; return getTypeOfPropertyOfType(attrsType, attrib.name.text); } } - if (expr.kind === 237 /* JsxSpreadAttribute */) { + if (expr.kind === 239 /* JsxSpreadAttribute */) { return getJsxElementAttributesType(expr.parent); } return undefined; @@ -19174,38 +19698,38 @@ var ts; } var parent = node.parent; switch (parent.kind) { - case 209 /* VariableDeclaration */: - case 136 /* Parameter */: - case 139 /* PropertyDeclaration */: - case 138 /* PropertySignature */: - case 161 /* BindingElement */: + case 211 /* VariableDeclaration */: + case 138 /* Parameter */: + case 141 /* PropertyDeclaration */: + case 140 /* PropertySignature */: + case 163 /* BindingElement */: return getContextualTypeForInitializerExpression(node); - case 172 /* ArrowFunction */: - case 202 /* ReturnStatement */: + case 174 /* ArrowFunction */: + case 204 /* ReturnStatement */: return getContextualTypeForReturnExpression(node); - case 182 /* YieldExpression */: + case 184 /* YieldExpression */: return getContextualTypeForYieldOperand(parent); - case 166 /* CallExpression */: - case 167 /* NewExpression */: + case 168 /* CallExpression */: + case 169 /* NewExpression */: return getContextualTypeForArgument(parent, node); - case 169 /* TypeAssertionExpression */: - case 187 /* AsExpression */: + case 171 /* TypeAssertionExpression */: + case 189 /* AsExpression */: return getTypeFromTypeNode(parent.type); - case 179 /* BinaryExpression */: + case 181 /* BinaryExpression */: return getContextualTypeForBinaryOperand(node); - case 243 /* PropertyAssignment */: + case 245 /* PropertyAssignment */: return getContextualTypeForObjectLiteralElement(parent); - case 162 /* ArrayLiteralExpression */: + case 164 /* ArrayLiteralExpression */: return getContextualTypeForElementExpression(node); - case 180 /* ConditionalExpression */: + case 182 /* ConditionalExpression */: return getContextualTypeForConditionalOperand(node); - case 188 /* TemplateSpan */: - ts.Debug.assert(parent.parent.kind === 181 /* TemplateExpression */); + case 190 /* TemplateSpan */: + ts.Debug.assert(parent.parent.kind === 183 /* TemplateExpression */); return getContextualTypeForSubstitutionExpression(parent.parent, node); - case 170 /* ParenthesizedExpression */: + case 172 /* ParenthesizedExpression */: return getContextualType(parent); - case 238 /* JsxExpression */: - case 237 /* JsxSpreadAttribute */: + case 240 /* JsxExpression */: + case 239 /* JsxSpreadAttribute */: return getContextualTypeForJsxExpression(parent); } return undefined; @@ -19222,7 +19746,7 @@ var ts; } } function isFunctionExpressionOrArrowFunction(node) { - return node.kind === 171 /* FunctionExpression */ || node.kind === 172 /* ArrowFunction */; + return node.kind === 173 /* FunctionExpression */ || node.kind === 174 /* ArrowFunction */; } function getContextualSignatureForFunctionLikeDeclaration(node) { // Only function expressions, arrow functions, and object literal methods are contextually typed. @@ -19236,7 +19760,7 @@ var ts; // all identical ignoring their return type, the result is same signature but with return type as // union type of return types from these signatures function getContextualSignature(node) { - ts.Debug.assert(node.kind !== 141 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 143 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); var type = ts.isObjectLiteralMethod(node) ? getContextualTypeForObjectLiteralMethod(node) : getContextualType(node); @@ -19299,13 +19823,13 @@ var ts; // an assignment target. Examples include 'a = xxx', '{ p: a } = xxx', '[{ p: a}] = xxx'. function isAssignmentTarget(node) { var parent = node.parent; - if (parent.kind === 179 /* BinaryExpression */ && parent.operatorToken.kind === 55 /* EqualsToken */ && parent.left === node) { + if (parent.kind === 181 /* BinaryExpression */ && parent.operatorToken.kind === 56 /* EqualsToken */ && parent.left === node) { return true; } - if (parent.kind === 243 /* PropertyAssignment */) { + if (parent.kind === 245 /* PropertyAssignment */) { return isAssignmentTarget(parent.parent); } - if (parent.kind === 162 /* ArrayLiteralExpression */) { + if (parent.kind === 164 /* ArrayLiteralExpression */) { return isAssignmentTarget(parent); } return false; @@ -19321,8 +19845,8 @@ var ts; return checkIteratedTypeOrElementType(arrayOrIterableType, node.expression, /*allowStringInput*/ false); } function hasDefaultValue(node) { - return (node.kind === 161 /* BindingElement */ && !!node.initializer) || - (node.kind === 179 /* BinaryExpression */ && node.operatorToken.kind === 55 /* EqualsToken */); + return (node.kind === 163 /* BindingElement */ && !!node.initializer) || + (node.kind === 181 /* BinaryExpression */ && node.operatorToken.kind === 56 /* EqualsToken */); } function checkArrayLiteral(node, contextualMapper) { var elements = node.elements; @@ -19331,7 +19855,7 @@ var ts; var inDestructuringPattern = isAssignmentTarget(node); for (var _i = 0; _i < elements.length; _i++) { var e = elements[_i]; - if (inDestructuringPattern && e.kind === 183 /* SpreadElementExpression */) { + if (inDestructuringPattern && e.kind === 185 /* SpreadElementExpression */) { // Given the following situation: // var c: {}; // [...c] = ["", 0]; @@ -19355,7 +19879,7 @@ var ts; var type = checkExpression(e, contextualMapper); elementTypes.push(type); } - hasSpreadElement = hasSpreadElement || e.kind === 183 /* SpreadElementExpression */; + hasSpreadElement = hasSpreadElement || e.kind === 185 /* SpreadElementExpression */; } if (!hasSpreadElement) { // If array literal is actually a destructuring pattern, mark it as an implied type. We do this such @@ -19370,7 +19894,7 @@ var ts; var pattern = contextualType.pattern; // If array literal is contextually typed by a binding pattern or an assignment pattern, pad the resulting // tuple type with the corresponding binding or assignment element types to make the lengths equal. - if (pattern && (pattern.kind === 160 /* ArrayBindingPattern */ || pattern.kind === 162 /* ArrayLiteralExpression */)) { + if (pattern && (pattern.kind === 162 /* ArrayBindingPattern */ || pattern.kind === 164 /* ArrayLiteralExpression */)) { var patternElements = pattern.elements; for (var i = elementTypes.length; i < patternElements.length; i++) { var patternElement = patternElements[i]; @@ -19378,7 +19902,7 @@ var ts; elementTypes.push(contextualType.elementTypes[i]); } else { - if (patternElement.kind !== 185 /* OmittedExpression */) { + if (patternElement.kind !== 187 /* OmittedExpression */) { error(patternElement, ts.Diagnostics.Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value); } elementTypes.push(unknownType); @@ -19393,7 +19917,7 @@ var ts; return createArrayType(elementTypes.length ? getUnionType(elementTypes) : undefinedType); } function isNumericName(name) { - return name.kind === 134 /* ComputedPropertyName */ ? isNumericComputedName(name) : isNumericLiteralName(name.text); + return name.kind === 136 /* ComputedPropertyName */ ? isNumericComputedName(name) : isNumericLiteralName(name.text); } function isNumericComputedName(name) { // It seems odd to consider an expression of type Any to result in a numeric name, @@ -19443,30 +19967,30 @@ var ts; return links.resolvedType; } function checkObjectLiteral(node, contextualMapper) { + var inDestructuringPattern = isAssignmentTarget(node); // Grammar checking - checkGrammarObjectLiteralExpression(node); + checkGrammarObjectLiteralExpression(node, inDestructuringPattern); var propertiesTable = {}; var propertiesArray = []; var contextualType = getContextualType(node); var contextualTypeHasPattern = contextualType && contextualType.pattern && - (contextualType.pattern.kind === 159 /* ObjectBindingPattern */ || contextualType.pattern.kind === 163 /* ObjectLiteralExpression */); - var inDestructuringPattern = isAssignmentTarget(node); + (contextualType.pattern.kind === 161 /* ObjectBindingPattern */ || contextualType.pattern.kind === 165 /* ObjectLiteralExpression */); var typeFlags = 0; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var memberDecl = _a[_i]; var member = memberDecl.symbol; - if (memberDecl.kind === 243 /* PropertyAssignment */ || - memberDecl.kind === 244 /* ShorthandPropertyAssignment */ || + if (memberDecl.kind === 245 /* PropertyAssignment */ || + memberDecl.kind === 246 /* ShorthandPropertyAssignment */ || ts.isObjectLiteralMethod(memberDecl)) { var type = void 0; - if (memberDecl.kind === 243 /* PropertyAssignment */) { + if (memberDecl.kind === 245 /* PropertyAssignment */) { type = checkPropertyAssignment(memberDecl, contextualMapper); } - else if (memberDecl.kind === 141 /* MethodDeclaration */) { + else if (memberDecl.kind === 143 /* MethodDeclaration */) { type = checkObjectLiteralMethod(memberDecl, contextualMapper); } else { - ts.Debug.assert(memberDecl.kind === 244 /* ShorthandPropertyAssignment */); + ts.Debug.assert(memberDecl.kind === 246 /* ShorthandPropertyAssignment */); type = checkExpression(memberDecl.name, contextualMapper); } typeFlags |= type.flags; @@ -19474,7 +19998,9 @@ var ts; if (inDestructuringPattern) { // If object literal is an assignment pattern and if the assignment pattern specifies a default value // for the property, make the property optional. - if (memberDecl.kind === 243 /* PropertyAssignment */ && hasDefaultValue(memberDecl.initializer)) { + var isOptional = (memberDecl.kind === 245 /* PropertyAssignment */ && hasDefaultValue(memberDecl.initializer)) || + (memberDecl.kind === 246 /* ShorthandPropertyAssignment */ && memberDecl.objectAssignmentInitializer); + if (isOptional) { prop.flags |= 536870912 /* Optional */; } } @@ -19504,7 +20030,7 @@ var ts; // an ordinary function declaration(section 6.1) with no parameters. // A set accessor declaration is processed in the same manner // as an ordinary function declaration with a single parameter and a Void return type. - ts.Debug.assert(memberDecl.kind === 143 /* GetAccessor */ || memberDecl.kind === 144 /* SetAccessor */); + ts.Debug.assert(memberDecl.kind === 145 /* GetAccessor */ || memberDecl.kind === 146 /* SetAccessor */); checkAccessorDeclaration(memberDecl); } if (!ts.hasDynamicName(memberDecl)) { @@ -19566,7 +20092,7 @@ var ts; if (lhs.kind !== rhs.kind) { return false; } - if (lhs.kind === 67 /* Identifier */) { + if (lhs.kind === 69 /* Identifier */) { return lhs.text === rhs.text; } return lhs.right.text === rhs.right.text && @@ -19587,18 +20113,18 @@ var ts; for (var _i = 0, _a = node.children; _i < _a.length; _i++) { var child = _a[_i]; switch (child.kind) { - case 238 /* JsxExpression */: + case 240 /* JsxExpression */: checkJsxExpression(child); break; - case 231 /* JsxElement */: + case 233 /* JsxElement */: checkJsxElement(child); break; - case 232 /* JsxSelfClosingElement */: + case 234 /* JsxSelfClosingElement */: checkJsxSelfClosingElement(child); break; default: // No checks for JSX Text - ts.Debug.assert(child.kind === 234 /* JsxText */); + ts.Debug.assert(child.kind === 236 /* JsxText */); } } return jsxElementType || anyType; @@ -19614,7 +20140,7 @@ var ts; * Returns true iff React would emit this tag name as a string rather than an identifier or qualified name */ function isJsxIntrinsicIdentifier(tagName) { - if (tagName.kind === 133 /* QualifiedName */) { + if (tagName.kind === 135 /* QualifiedName */) { return false; } else { @@ -19733,12 +20259,14 @@ var ts; // Look up the value in the current scope if (valueSymbol && valueSymbol !== unknownSymbol) { links.jsxFlags |= 4 /* ClassElement */; - getSymbolLinks(valueSymbol).referenced = true; + if (valueSymbol.flags & 8388608 /* Alias */) { + markAliasSymbolAsReferenced(valueSymbol); + } } return valueSymbol || unknownSymbol; } function resolveJsxTagName(node) { - if (node.tagName.kind === 67 /* Identifier */) { + if (node.tagName.kind === 69 /* Identifier */) { var tag = node.tagName; var sym = getResolvedSymbol(tag); return sym.exportSymbol || sym; @@ -19923,11 +20451,11 @@ var ts; // thus should have their types ignored var sawSpreadedAny = false; for (var i = node.attributes.length - 1; i >= 0; i--) { - if (node.attributes[i].kind === 236 /* JsxAttribute */) { + if (node.attributes[i].kind === 238 /* JsxAttribute */) { checkJsxAttribute((node.attributes[i]), targetAttributesType, nameTable); } else { - ts.Debug.assert(node.attributes[i].kind === 237 /* JsxSpreadAttribute */); + ts.Debug.assert(node.attributes[i].kind === 239 /* JsxSpreadAttribute */); var spreadType = checkJsxSpreadAttribute((node.attributes[i]), targetAttributesType, nameTable); if (isTypeAny(spreadType)) { sawSpreadedAny = true; @@ -19957,7 +20485,7 @@ var ts; // If a symbol is a synthesized symbol with no value declaration, we assume it is a property. Example of this are the synthesized // '.prototype' property as well as synthesized tuple index properties. function getDeclarationKindFromSymbol(s) { - return s.valueDeclaration ? s.valueDeclaration.kind : 139 /* PropertyDeclaration */; + return s.valueDeclaration ? s.valueDeclaration.kind : 141 /* PropertyDeclaration */; } function getDeclarationFlagsFromSymbol(s) { return s.valueDeclaration ? ts.getCombinedNodeFlags(s.valueDeclaration) : s.flags & 134217728 /* Prototype */ ? 16 /* Public */ | 128 /* Static */ : 0; @@ -19973,8 +20501,8 @@ var ts; function checkClassPropertyAccess(node, left, type, prop) { var flags = getDeclarationFlagsFromSymbol(prop); var declaringClass = getDeclaredTypeOfSymbol(prop.parent); - if (left.kind === 93 /* SuperKeyword */) { - var errorNode = node.kind === 164 /* PropertyAccessExpression */ ? + if (left.kind === 95 /* SuperKeyword */) { + var errorNode = node.kind === 166 /* PropertyAccessExpression */ ? node.name : node.right; // TS 1.0 spec (April 2014): 4.8.2 @@ -19984,7 +20512,7 @@ var ts; // - In a static member function or static member accessor // where this references the constructor function object of a derived class, // a super property access is permitted and must specify a public static member function of the base class. - if (getDeclarationKindFromSymbol(prop) !== 141 /* MethodDeclaration */) { + if (getDeclarationKindFromSymbol(prop) !== 143 /* MethodDeclaration */) { // `prop` refers to a *property* declared in the super class // rather than a *method*, so it does not satisfy the above criteria. error(errorNode, ts.Diagnostics.Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword); @@ -20017,7 +20545,7 @@ var ts; } // Property is known to be protected at this point // All protected properties of a supertype are accessible in a super access - if (left.kind === 93 /* SuperKeyword */) { + if (left.kind === 95 /* SuperKeyword */) { return true; } // A protected property is accessible in the declaring class and classes derived from it @@ -20030,6 +20558,10 @@ var ts; return true; } // An instance property must be accessed through an instance of the enclosing class + if (type.flags & 33554432 /* ThisType */) { + // get the original type -- represented as the type constraint of the 'this' type + type = getConstraintOfTypeParameter(type); + } // TODO: why is the first part of this check here? if (!(getTargetType(type).flags & (1024 /* Class */ | 2048 /* Interface */) && hasBaseType(type, enclosingClass))) { error(node, ts.Diagnostics.Property_0_is_protected_and_only_accessible_through_an_instance_of_class_1, symbolToString(prop), typeToString(enclosingClass)); @@ -20056,18 +20588,18 @@ var ts; var prop = getPropertyOfType(apparentType, right.text); if (!prop) { if (right.text) { - error(right, ts.Diagnostics.Property_0_does_not_exist_on_type_1, ts.declarationNameToString(right), typeToString(type)); + error(right, ts.Diagnostics.Property_0_does_not_exist_on_type_1, ts.declarationNameToString(right), typeToString(type.flags & 33554432 /* ThisType */ ? apparentType : type)); } return unknownType; } getNodeLinks(node).resolvedSymbol = prop; if (prop.parent && prop.parent.flags & 32 /* Class */) { - checkClassPropertyAccess(node, left, type, prop); + checkClassPropertyAccess(node, left, apparentType, prop); } return getTypeOfSymbol(prop); } function isValidPropertyAccess(node, propertyName) { - var left = node.kind === 164 /* PropertyAccessExpression */ + var left = node.kind === 166 /* PropertyAccessExpression */ ? node.expression : node.left; var type = checkExpression(left); @@ -20083,7 +20615,7 @@ var ts; // Grammar checking if (!node.argumentExpression) { var sourceFile = getSourceFile(node); - if (node.parent.kind === 167 /* NewExpression */ && node.parent.expression === node) { + if (node.parent.kind === 169 /* NewExpression */ && node.parent.expression === node) { var start = ts.skipTrivia(sourceFile.text, node.expression.end); var end = node.end; grammarErrorAtPos(sourceFile, start, end - start, ts.Diagnostics.new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead); @@ -20155,6 +20687,7 @@ var ts; } /** * If indexArgumentExpression is a string literal or number literal, returns its text. + * If indexArgumentExpression is a constant value, returns its string value. * If indexArgumentExpression is a well known symbol, returns the property name corresponding * to this symbol, as long as it is a proper symbol reference. * Otherwise, returns undefined. @@ -20163,6 +20696,12 @@ var ts; if (indexArgumentExpression.kind === 9 /* StringLiteral */ || indexArgumentExpression.kind === 8 /* NumericLiteral */) { return indexArgumentExpression.text; } + if (indexArgumentExpression.kind === 167 /* ElementAccessExpression */ || indexArgumentExpression.kind === 166 /* PropertyAccessExpression */) { + var value = getConstantValue(indexArgumentExpression); + if (value !== undefined) { + return value.toString(); + } + } if (checkThatExpressionIsProperSymbolReference(indexArgumentExpression, indexArgumentType, /*reportError*/ false)) { var rightHandSideName = indexArgumentExpression.name.text; return ts.getPropertyNameForKnownSymbolName(rightHandSideName); @@ -20212,10 +20751,10 @@ var ts; return true; } function resolveUntypedCall(node) { - if (node.kind === 168 /* TaggedTemplateExpression */) { + if (node.kind === 170 /* TaggedTemplateExpression */) { checkExpression(node.template); } - else if (node.kind !== 137 /* Decorator */) { + else if (node.kind !== 139 /* Decorator */) { ts.forEach(node.arguments, function (argument) { checkExpression(argument); }); @@ -20281,7 +20820,7 @@ var ts; function getSpreadArgumentIndex(args) { for (var i = 0; i < args.length; i++) { var arg = args[i]; - if (arg && arg.kind === 183 /* SpreadElementExpression */) { + if (arg && arg.kind === 185 /* SpreadElementExpression */) { return i; } } @@ -20293,13 +20832,13 @@ var ts; var callIsIncomplete; // In incomplete call we want to be lenient when we have too few arguments var isDecorator; var spreadArgIndex = -1; - if (node.kind === 168 /* TaggedTemplateExpression */) { + if (node.kind === 170 /* TaggedTemplateExpression */) { var tagExpression = node; // Even if the call is incomplete, we'll have a missing expression as our last argument, // so we can say the count is just the arg list length adjustedArgCount = args.length; typeArguments = undefined; - if (tagExpression.template.kind === 181 /* TemplateExpression */) { + if (tagExpression.template.kind === 183 /* TemplateExpression */) { // If a tagged template expression lacks a tail literal, the call is incomplete. // Specifically, a template only can end in a TemplateTail or a Missing literal. var templateExpression = tagExpression.template; @@ -20316,7 +20855,7 @@ var ts; callIsIncomplete = !!templateLiteral.isUnterminated; } } - else if (node.kind === 137 /* Decorator */) { + else if (node.kind === 139 /* Decorator */) { isDecorator = true; typeArguments = undefined; adjustedArgCount = getEffectiveArgumentCount(node, /*args*/ undefined, signature); @@ -20325,7 +20864,7 @@ var ts; var callExpression = node; if (!callExpression.arguments) { // This only happens when we have something of the form: 'new C' - ts.Debug.assert(callExpression.kind === 167 /* NewExpression */); + ts.Debug.assert(callExpression.kind === 169 /* NewExpression */); return signature.minArgumentCount === 0; } // For IDE scenarios we may have an incomplete call, so a trailing comma is tantamount to adding another argument. @@ -20404,7 +20943,7 @@ var ts; for (var i = 0; i < argCount; i++) { var arg = getEffectiveArgument(node, args, i); // If the effective argument is 'undefined', then it is an argument that is present but is synthetic. - if (arg === undefined || arg.kind !== 185 /* OmittedExpression */) { + if (arg === undefined || arg.kind !== 187 /* OmittedExpression */) { var paramType = getTypeAtPosition(signature, i); var argType = getEffectiveArgumentType(node, i, arg); // If the effective argument type is 'undefined', there is no synthetic type @@ -20463,7 +21002,7 @@ var ts; for (var i = 0; i < argCount; i++) { var arg = getEffectiveArgument(node, args, i); // If the effective argument is 'undefined', then it is an argument that is present but is synthetic. - if (arg === undefined || arg.kind !== 185 /* OmittedExpression */) { + if (arg === undefined || arg.kind !== 187 /* OmittedExpression */) { // Check spread elements against rest type (from arity check we know spread argument corresponds to a rest parameter) var paramType = getTypeAtPosition(signature, i); var argType = getEffectiveArgumentType(node, i, arg); @@ -20495,16 +21034,16 @@ var ts; */ function getEffectiveCallArguments(node) { var args; - if (node.kind === 168 /* TaggedTemplateExpression */) { + if (node.kind === 170 /* TaggedTemplateExpression */) { var template = node.template; args = [undefined]; - if (template.kind === 181 /* TemplateExpression */) { + if (template.kind === 183 /* TemplateExpression */) { ts.forEach(template.templateSpans, function (span) { args.push(span.expression); }); } } - else if (node.kind === 137 /* Decorator */) { + else if (node.kind === 139 /* Decorator */) { // For a decorator, we return undefined as we will determine // the number and types of arguments for a decorator using // `getEffectiveArgumentCount` and `getEffectiveArgumentType` below. @@ -20529,25 +21068,29 @@ var ts; * Otherwise, the argument count is the length of the 'args' array. */ function getEffectiveArgumentCount(node, args, signature) { - if (node.kind === 137 /* Decorator */) { + if (node.kind === 139 /* Decorator */) { switch (node.parent.kind) { - case 212 /* ClassDeclaration */: - case 184 /* ClassExpression */: + case 214 /* ClassDeclaration */: + case 186 /* ClassExpression */: // A class decorator will have one argument (see `ClassDecorator` in core.d.ts) return 1; - case 139 /* PropertyDeclaration */: + case 141 /* PropertyDeclaration */: // A property declaration decorator will have two arguments (see // `PropertyDecorator` in core.d.ts) return 2; - case 141 /* MethodDeclaration */: - case 143 /* GetAccessor */: - case 144 /* SetAccessor */: + case 143 /* MethodDeclaration */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: // A method or accessor declaration decorator will have two or three arguments (see // `PropertyDecorator` and `MethodDecorator` in core.d.ts) + // If we are emitting decorators for ES3, we will only pass two arguments. + if (languageVersion === 0 /* ES3 */) { + return 2; + } // If the method decorator signature only accepts a target and a key, we will only // type check those arguments. return signature.parameters.length >= 3 ? 3 : 2; - case 136 /* Parameter */: + case 138 /* Parameter */: // A parameter declaration decorator will have three arguments (see // `ParameterDecorator` in core.d.ts) return 3; @@ -20572,25 +21115,25 @@ var ts; function getEffectiveDecoratorFirstArgumentType(node) { // The first argument to a decorator is its `target`. switch (node.kind) { - case 212 /* ClassDeclaration */: - case 184 /* ClassExpression */: + case 214 /* ClassDeclaration */: + case 186 /* ClassExpression */: // For a class decorator, the `target` is the type of the class (e.g. the // "static" or "constructor" side of the class) var classSymbol = getSymbolOfNode(node); return getTypeOfSymbol(classSymbol); - case 136 /* Parameter */: + case 138 /* Parameter */: // For a parameter decorator, the `target` is the parent type of the // parameter's containing method. node = node.parent; - if (node.kind === 142 /* Constructor */) { + if (node.kind === 144 /* Constructor */) { var classSymbol_1 = getSymbolOfNode(node); return getTypeOfSymbol(classSymbol_1); } // fall-through - case 139 /* PropertyDeclaration */: - case 141 /* MethodDeclaration */: - case 143 /* GetAccessor */: - case 144 /* SetAccessor */: + case 141 /* PropertyDeclaration */: + case 143 /* MethodDeclaration */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: // For a property or method decorator, the `target` is the // "static"-side type of the parent of the member if the member is // declared "static"; otherwise, it is the "instance"-side type of the @@ -20619,33 +21162,33 @@ var ts; function getEffectiveDecoratorSecondArgumentType(node) { // The second argument to a decorator is its `propertyKey` switch (node.kind) { - case 212 /* ClassDeclaration */: + case 214 /* ClassDeclaration */: ts.Debug.fail("Class decorators should not have a second synthetic argument."); return unknownType; - case 136 /* Parameter */: + case 138 /* Parameter */: node = node.parent; - if (node.kind === 142 /* Constructor */) { + if (node.kind === 144 /* Constructor */) { // For a constructor parameter decorator, the `propertyKey` will be `undefined`. return anyType; } // For a non-constructor parameter decorator, the `propertyKey` will be either // a string or a symbol, based on the name of the parameter's containing method. // fall-through - case 139 /* PropertyDeclaration */: - case 141 /* MethodDeclaration */: - case 143 /* GetAccessor */: - case 144 /* SetAccessor */: + case 141 /* PropertyDeclaration */: + case 143 /* MethodDeclaration */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: // The `propertyKey` for a property or method decorator will be a // string literal type if the member name is an identifier, number, or string; // otherwise, if the member name is a computed property name it will // be either string or symbol. var element = node; switch (element.name.kind) { - case 67 /* Identifier */: + case 69 /* Identifier */: case 8 /* NumericLiteral */: case 9 /* StringLiteral */: return getStringLiteralType(element.name); - case 134 /* ComputedPropertyName */: + case 136 /* ComputedPropertyName */: var nameType = checkComputedPropertyName(element.name); if (allConstituentTypesHaveKind(nameType, 16777216 /* ESSymbol */)) { return nameType; @@ -20673,18 +21216,18 @@ var ts; // The third argument to a decorator is either its `descriptor` for a method decorator // or its `parameterIndex` for a paramter decorator switch (node.kind) { - case 212 /* ClassDeclaration */: + case 214 /* ClassDeclaration */: ts.Debug.fail("Class decorators should not have a third synthetic argument."); return unknownType; - case 136 /* Parameter */: + case 138 /* Parameter */: // The `parameterIndex` for a parameter decorator is always a number return numberType; - case 139 /* PropertyDeclaration */: + case 141 /* PropertyDeclaration */: ts.Debug.fail("Property decorators should not have a third synthetic argument."); return unknownType; - case 141 /* MethodDeclaration */: - case 143 /* GetAccessor */: - case 144 /* SetAccessor */: + case 143 /* MethodDeclaration */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: // The `descriptor` for a method decorator will be a `TypedPropertyDescriptor` // for the type of the member. var propertyType = getTypeOfNode(node); @@ -20717,10 +21260,10 @@ var ts; // Decorators provide special arguments, a tagged template expression provides // a special first argument, and string literals get string literal types // unless we're reporting errors - if (node.kind === 137 /* Decorator */) { + if (node.kind === 139 /* Decorator */) { return getEffectiveDecoratorArgumentType(node, argIndex); } - else if (argIndex === 0 && node.kind === 168 /* TaggedTemplateExpression */) { + else if (argIndex === 0 && node.kind === 170 /* TaggedTemplateExpression */) { return globalTemplateStringsArrayType; } // This is not a synthetic argument, so we return 'undefined' @@ -20732,8 +21275,8 @@ var ts; */ function getEffectiveArgument(node, args, argIndex) { // For a decorator or the first argument of a tagged template expression we return undefined. - if (node.kind === 137 /* Decorator */ || - (argIndex === 0 && node.kind === 168 /* TaggedTemplateExpression */)) { + if (node.kind === 139 /* Decorator */ || + (argIndex === 0 && node.kind === 170 /* TaggedTemplateExpression */)) { return undefined; } return args[argIndex]; @@ -20742,11 +21285,11 @@ var ts; * Gets the error node to use when reporting errors for an effective argument. */ function getEffectiveArgumentErrorNode(node, argIndex, arg) { - if (node.kind === 137 /* Decorator */) { + if (node.kind === 139 /* Decorator */) { // For a decorator, we use the expression of the decorator for error reporting. return node.expression; } - else if (argIndex === 0 && node.kind === 168 /* TaggedTemplateExpression */) { + else if (argIndex === 0 && node.kind === 170 /* TaggedTemplateExpression */) { // For a the first argument of a tagged template expression, we use the template of the tag for error reporting. return node.template; } @@ -20755,13 +21298,13 @@ var ts; } } function resolveCall(node, signatures, candidatesOutArray, headMessage) { - var isTaggedTemplate = node.kind === 168 /* TaggedTemplateExpression */; - var isDecorator = node.kind === 137 /* Decorator */; + var isTaggedTemplate = node.kind === 170 /* TaggedTemplateExpression */; + var isDecorator = node.kind === 139 /* Decorator */; var typeArguments; if (!isTaggedTemplate && !isDecorator) { typeArguments = node.typeArguments; // We already perform checking on the type arguments on the class declaration itself. - if (node.expression.kind !== 93 /* SuperKeyword */) { + if (node.expression.kind !== 95 /* SuperKeyword */) { ts.forEach(typeArguments, checkSourceElement); } } @@ -20968,7 +21511,7 @@ var ts; } } function resolveCallExpression(node, candidatesOutArray) { - if (node.expression.kind === 93 /* SuperKeyword */) { + if (node.expression.kind === 95 /* SuperKeyword */) { var superType = checkSuperExpression(node.expression); if (superType !== unknownType) { // In super call, the candidate signatures are the matching arity signatures of the base constructor function instantiated @@ -21101,16 +21644,16 @@ var ts; */ function getDiagnosticHeadMessageForDecoratorResolution(node) { switch (node.parent.kind) { - case 212 /* ClassDeclaration */: - case 184 /* ClassExpression */: + case 214 /* ClassDeclaration */: + case 186 /* ClassExpression */: return ts.Diagnostics.Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression; - case 136 /* Parameter */: + case 138 /* Parameter */: return ts.Diagnostics.Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression; - case 139 /* PropertyDeclaration */: + case 141 /* PropertyDeclaration */: return ts.Diagnostics.Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression; - case 141 /* MethodDeclaration */: - case 143 /* GetAccessor */: - case 144 /* SetAccessor */: + case 143 /* MethodDeclaration */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: return ts.Diagnostics.Unable_to_resolve_signature_of_method_decorator_when_called_as_an_expression; } } @@ -21147,16 +21690,16 @@ var ts; // to correctly fill the candidatesOutArray. if (!links.resolvedSignature || candidatesOutArray) { links.resolvedSignature = anySignature; - if (node.kind === 166 /* CallExpression */) { + if (node.kind === 168 /* CallExpression */) { links.resolvedSignature = resolveCallExpression(node, candidatesOutArray); } - else if (node.kind === 167 /* NewExpression */) { + else if (node.kind === 169 /* NewExpression */) { links.resolvedSignature = resolveNewExpression(node, candidatesOutArray); } - else if (node.kind === 168 /* TaggedTemplateExpression */) { + else if (node.kind === 170 /* TaggedTemplateExpression */) { links.resolvedSignature = resolveTaggedTemplateExpression(node, candidatesOutArray); } - else if (node.kind === 137 /* Decorator */) { + else if (node.kind === 139 /* Decorator */) { links.resolvedSignature = resolveDecorator(node, candidatesOutArray); } else { @@ -21174,15 +21717,15 @@ var ts; // Grammar checking; stop grammar-checking if checkGrammarTypeArguments return true checkGrammarTypeArguments(node, node.typeArguments) || checkGrammarArguments(node, node.arguments); var signature = getResolvedSignature(node); - if (node.expression.kind === 93 /* SuperKeyword */) { + if (node.expression.kind === 95 /* SuperKeyword */) { return voidType; } - if (node.kind === 167 /* NewExpression */) { + if (node.kind === 169 /* NewExpression */) { var declaration = signature.declaration; if (declaration && - declaration.kind !== 142 /* Constructor */ && - declaration.kind !== 146 /* ConstructSignature */ && - declaration.kind !== 151 /* ConstructorType */) { + declaration.kind !== 144 /* Constructor */ && + declaration.kind !== 148 /* ConstructSignature */ && + declaration.kind !== 153 /* ConstructorType */) { // When resolved signature is a call signature (and not a construct signature) the result type is any if (compilerOptions.noImplicitAny) { error(node, ts.Diagnostics.new_expression_whose_target_lacks_a_construct_signature_implicitly_has_an_any_type); @@ -21190,6 +21733,10 @@ var ts; return anyType; } } + // In JavaScript files, calls to any identifier 'require' are treated as external module imports + if (ts.isInJavaScriptFile(node) && ts.isRequireCall(node)) { + return resolveExternalModuleTypeByLiteral(node.arguments[0]); + } return getReturnTypeOfSignature(signature); } function checkTaggedTemplateExpression(node) { @@ -21224,10 +21771,24 @@ var ts; assignTypeToParameterAndFixTypeParameters(parameter, contextualParameterType, mapper); } } + // When contextual typing assigns a type to a parameter that contains a binding pattern, we also need to push + // the destructured type into the contained binding elements. + function assignBindingElementTypes(node) { + if (ts.isBindingPattern(node.name)) { + for (var _i = 0, _a = node.name.elements; _i < _a.length; _i++) { + var element = _a[_i]; + if (element.kind !== 187 /* OmittedExpression */) { + getSymbolLinks(getSymbolOfNode(element)).type = getTypeForBindingElement(element); + assignBindingElementTypes(element); + } + } + } + } function assignTypeToParameterAndFixTypeParameters(parameter, contextualType, mapper) { var links = getSymbolLinks(parameter); if (!links.type) { links.type = instantiateType(contextualType, mapper); + assignBindingElementTypes(parameter.valueDeclaration); } else if (isInferentialContext(mapper)) { // Even if the parameter already has a type, it might be because it was given a type while @@ -21279,7 +21840,7 @@ var ts; } var isAsync = ts.isAsyncFunctionLike(func); var type; - if (func.body.kind !== 190 /* Block */) { + if (func.body.kind !== 192 /* Block */) { type = checkExpressionCached(func.body, contextualMapper); if (isAsync) { // From within an async function you can return either a non-promise value or a promise. Any @@ -21398,7 +21959,7 @@ var ts; }); } function bodyContainsSingleThrowStatement(body) { - return (body.statements.length === 1) && (body.statements[0].kind === 206 /* ThrowStatement */); + return (body.statements.length === 1) && (body.statements[0].kind === 208 /* ThrowStatement */); } // TypeScript Specification 1.0 (6.3) - July 2014 // An explicitly typed function whose return type isn't the Void or the Any type @@ -21413,7 +21974,7 @@ var ts; return; } // If all we have is a function signature, or an arrow function with an expression body, then there is nothing to check. - if (ts.nodeIsMissing(func.body) || func.body.kind !== 190 /* Block */) { + if (ts.nodeIsMissing(func.body) || func.body.kind !== 192 /* Block */) { return; } var bodyBlock = func.body; @@ -21431,10 +21992,10 @@ var ts; error(func.type, ts.Diagnostics.A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value_or_consist_of_a_single_throw_statement); } function checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper) { - ts.Debug.assert(node.kind !== 141 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 143 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); // Grammar checking var hasGrammarError = checkGrammarFunctionLikeDeclaration(node); - if (!hasGrammarError && node.kind === 171 /* FunctionExpression */) { + if (!hasGrammarError && node.kind === 173 /* FunctionExpression */) { checkGrammarForGenerator(node); } // The identityMapper object is used to indicate that function expressions are wildcards @@ -21477,14 +22038,14 @@ var ts; } } } - if (produceDiagnostics && node.kind !== 141 /* MethodDeclaration */ && node.kind !== 140 /* MethodSignature */) { + if (produceDiagnostics && node.kind !== 143 /* MethodDeclaration */ && node.kind !== 142 /* MethodSignature */) { checkCollisionWithCapturedSuperVariable(node, node.name); checkCollisionWithCapturedThisVariable(node, node.name); } return type; } function checkFunctionExpressionOrObjectLiteralMethodBody(node) { - ts.Debug.assert(node.kind !== 141 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 143 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); var isAsync = ts.isAsyncFunctionLike(node); if (isAsync) { emitAwaiter = true; @@ -21506,7 +22067,7 @@ var ts; // checkFunctionExpressionBodies). So it must be done now. getReturnTypeOfSignature(getSignatureFromDeclaration(node)); } - if (node.body.kind === 190 /* Block */) { + if (node.body.kind === 192 /* Block */) { checkSourceElement(node.body); } else { @@ -21552,24 +22113,24 @@ var ts; // and property accesses(section 4.10). // All other expression constructs described in this chapter are classified as values. switch (n.kind) { - case 67 /* Identifier */: { + case 69 /* Identifier */: { var symbol = findSymbol(n); // TypeScript 1.0 spec (April 2014): 4.3 // An identifier expression that references a variable or parameter is classified as a reference. // An identifier expression that references any other kind of entity is classified as a value(and therefore cannot be the target of an assignment). return !symbol || symbol === unknownSymbol || symbol === argumentsSymbol || (symbol.flags & 3 /* Variable */) !== 0; } - case 164 /* PropertyAccessExpression */: { + case 166 /* PropertyAccessExpression */: { var symbol = findSymbol(n); // TypeScript 1.0 spec (April 2014): 4.10 // A property access expression is always classified as a reference. // NOTE (not in spec): assignment to enum members should not be allowed return !symbol || symbol === unknownSymbol || (symbol.flags & ~8 /* EnumMember */) !== 0; } - case 165 /* ElementAccessExpression */: - // old compiler doesn't check indexed assess + case 167 /* ElementAccessExpression */: + // old compiler doesn't check indexed access return true; - case 170 /* ParenthesizedExpression */: + case 172 /* ParenthesizedExpression */: return isReferenceOrErrorExpression(n.expression); default: return false; @@ -21577,12 +22138,12 @@ var ts; } function isConstVariableReference(n) { switch (n.kind) { - case 67 /* Identifier */: - case 164 /* PropertyAccessExpression */: { + case 69 /* Identifier */: + case 166 /* PropertyAccessExpression */: { var symbol = findSymbol(n); return symbol && (symbol.flags & 3 /* Variable */) !== 0 && (getDeclarationFlagsFromSymbol(symbol) & 32768 /* Const */) !== 0; } - case 165 /* ElementAccessExpression */: { + case 167 /* ElementAccessExpression */: { var index = n.argumentExpression; var symbol = findSymbol(n.expression); if (symbol && index && index.kind === 9 /* StringLiteral */) { @@ -21592,7 +22153,7 @@ var ts; } return false; } - case 170 /* ParenthesizedExpression */: + case 172 /* ParenthesizedExpression */: return isConstVariableReference(n.expression); default: return false; @@ -21638,15 +22199,15 @@ var ts; switch (node.operator) { case 35 /* PlusToken */: case 36 /* MinusToken */: - case 49 /* TildeToken */: + case 50 /* TildeToken */: if (someConstituentTypeHasKind(operandType, 16777216 /* ESSymbol */)) { error(node.operand, ts.Diagnostics.The_0_operator_cannot_be_applied_to_type_symbol, ts.tokenToString(node.operator)); } return numberType; - case 48 /* ExclamationToken */: + case 49 /* ExclamationToken */: return booleanType; - case 40 /* PlusPlusToken */: - case 41 /* MinusMinusToken */: + case 41 /* PlusPlusToken */: + case 42 /* MinusMinusToken */: var ok = checkArithmeticOperandType(node.operand, operandType, ts.Diagnostics.An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type); if (ok) { // run check only if former checks succeeded to avoid reporting cascading errors @@ -21706,31 +22267,31 @@ var ts; function isConstEnumSymbol(symbol) { return (symbol.flags & 128 /* ConstEnum */) !== 0; } - function checkInstanceOfExpression(node, leftType, rightType) { + function checkInstanceOfExpression(left, right, leftType, rightType) { // TypeScript 1.0 spec (April 2014): 4.15.4 // The instanceof operator requires the left operand to be of type Any, an object type, or a type parameter type, // and the right operand to be of type Any or a subtype of the 'Function' interface type. // The result is always of the Boolean primitive type. // NOTE: do not raise error if leftType is unknown as related error was already reported if (allConstituentTypesHaveKind(leftType, 16777726 /* Primitive */)) { - error(node.left, ts.Diagnostics.The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_parameter); + error(left, ts.Diagnostics.The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_parameter); } // NOTE: do not raise error if right is unknown as related error was already reported if (!(isTypeAny(rightType) || isTypeSubtypeOf(rightType, globalFunctionType))) { - error(node.right, ts.Diagnostics.The_right_hand_side_of_an_instanceof_expression_must_be_of_type_any_or_of_a_type_assignable_to_the_Function_interface_type); + error(right, ts.Diagnostics.The_right_hand_side_of_an_instanceof_expression_must_be_of_type_any_or_of_a_type_assignable_to_the_Function_interface_type); } return booleanType; } - function checkInExpression(node, leftType, rightType) { + function checkInExpression(left, right, leftType, rightType) { // TypeScript 1.0 spec (April 2014): 4.15.5 // The in operator requires the left operand to be of type Any, the String primitive type, or the Number primitive type, // and the right operand to be of type Any, an object type, or a type parameter type. // The result is always of the Boolean primitive type. if (!isTypeAnyOrAllConstituentTypesHaveKind(leftType, 258 /* StringLike */ | 132 /* NumberLike */ | 16777216 /* ESSymbol */)) { - error(node.left, ts.Diagnostics.The_left_hand_side_of_an_in_expression_must_be_of_type_any_string_number_or_symbol); + error(left, ts.Diagnostics.The_left_hand_side_of_an_in_expression_must_be_of_type_any_string_number_or_symbol); } if (!isTypeAnyOrAllConstituentTypesHaveKind(rightType, 80896 /* ObjectType */ | 512 /* TypeParameter */)) { - error(node.right, ts.Diagnostics.The_right_hand_side_of_an_in_expression_must_be_of_type_any_an_object_type_or_a_type_parameter); + error(right, ts.Diagnostics.The_right_hand_side_of_an_in_expression_must_be_of_type_any_an_object_type_or_a_type_parameter); } return booleanType; } @@ -21738,7 +22299,7 @@ var ts; var properties = node.properties; for (var _i = 0; _i < properties.length; _i++) { var p = properties[_i]; - if (p.kind === 243 /* PropertyAssignment */ || p.kind === 244 /* ShorthandPropertyAssignment */) { + if (p.kind === 245 /* PropertyAssignment */ || p.kind === 246 /* ShorthandPropertyAssignment */) { // TODO(andersh): Computed property support var name_13 = p.name; var type = isTypeAny(sourceType) @@ -21747,7 +22308,12 @@ var ts; isNumericLiteralName(name_13.text) && getIndexTypeOfType(sourceType, 1 /* Number */) || getIndexTypeOfType(sourceType, 0 /* String */); if (type) { - checkDestructuringAssignment(p.initializer || name_13, type); + if (p.kind === 246 /* ShorthandPropertyAssignment */) { + checkDestructuringAssignment(p, type); + } + else { + checkDestructuringAssignment(p.initializer || name_13, type); + } } else { error(name_13, ts.Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(sourceType), ts.declarationNameToString(name_13)); @@ -21767,8 +22333,8 @@ var ts; var elements = node.elements; for (var i = 0; i < elements.length; i++) { var e = elements[i]; - if (e.kind !== 185 /* OmittedExpression */) { - if (e.kind !== 183 /* SpreadElementExpression */) { + if (e.kind !== 187 /* OmittedExpression */) { + if (e.kind !== 185 /* SpreadElementExpression */) { var propName = "" + i; var type = isTypeAny(sourceType) ? sourceType @@ -21793,7 +22359,7 @@ var ts; } else { var restExpression = e.expression; - if (restExpression.kind === 179 /* BinaryExpression */ && restExpression.operatorToken.kind === 55 /* EqualsToken */) { + if (restExpression.kind === 181 /* BinaryExpression */ && restExpression.operatorToken.kind === 56 /* EqualsToken */) { error(restExpression.operatorToken, ts.Diagnostics.A_rest_element_cannot_have_an_initializer); } else { @@ -21805,15 +22371,26 @@ var ts; } return sourceType; } - function checkDestructuringAssignment(target, sourceType, contextualMapper) { - if (target.kind === 179 /* BinaryExpression */ && target.operatorToken.kind === 55 /* EqualsToken */) { + function checkDestructuringAssignment(exprOrAssignment, sourceType, contextualMapper) { + var target; + if (exprOrAssignment.kind === 246 /* ShorthandPropertyAssignment */) { + var prop = exprOrAssignment; + if (prop.objectAssignmentInitializer) { + checkBinaryLikeExpression(prop.name, prop.equalsToken, prop.objectAssignmentInitializer, contextualMapper); + } + target = exprOrAssignment.name; + } + else { + target = exprOrAssignment; + } + if (target.kind === 181 /* BinaryExpression */ && target.operatorToken.kind === 56 /* EqualsToken */) { checkBinaryExpression(target, contextualMapper); target = target.left; } - if (target.kind === 163 /* ObjectLiteralExpression */) { + if (target.kind === 165 /* ObjectLiteralExpression */) { return checkObjectLiteralAssignment(target, sourceType, contextualMapper); } - if (target.kind === 162 /* ArrayLiteralExpression */) { + if (target.kind === 164 /* ArrayLiteralExpression */) { return checkArrayLiteralAssignment(target, sourceType, contextualMapper); } return checkReferenceAssignment(target, sourceType, contextualMapper); @@ -21826,34 +22403,39 @@ var ts; return sourceType; } function checkBinaryExpression(node, contextualMapper) { - var operator = node.operatorToken.kind; - if (operator === 55 /* EqualsToken */ && (node.left.kind === 163 /* ObjectLiteralExpression */ || node.left.kind === 162 /* ArrayLiteralExpression */)) { - return checkDestructuringAssignment(node.left, checkExpression(node.right, contextualMapper), contextualMapper); + return checkBinaryLikeExpression(node.left, node.operatorToken, node.right, contextualMapper, node); + } + function checkBinaryLikeExpression(left, operatorToken, right, contextualMapper, errorNode) { + var operator = operatorToken.kind; + if (operator === 56 /* EqualsToken */ && (left.kind === 165 /* ObjectLiteralExpression */ || left.kind === 164 /* ArrayLiteralExpression */)) { + return checkDestructuringAssignment(left, checkExpression(right, contextualMapper), contextualMapper); } - var leftType = checkExpression(node.left, contextualMapper); - var rightType = checkExpression(node.right, contextualMapper); + var leftType = checkExpression(left, contextualMapper); + var rightType = checkExpression(right, contextualMapper); switch (operator) { case 37 /* AsteriskToken */: - case 58 /* AsteriskEqualsToken */: - case 38 /* SlashToken */: - case 59 /* SlashEqualsToken */: - case 39 /* PercentToken */: - case 60 /* PercentEqualsToken */: + case 38 /* AsteriskAsteriskToken */: + case 59 /* AsteriskEqualsToken */: + case 60 /* AsteriskAsteriskEqualsToken */: + case 39 /* SlashToken */: + case 61 /* SlashEqualsToken */: + case 40 /* PercentToken */: + case 62 /* PercentEqualsToken */: case 36 /* MinusToken */: - case 57 /* MinusEqualsToken */: - case 42 /* LessThanLessThanToken */: - case 61 /* LessThanLessThanEqualsToken */: - case 43 /* GreaterThanGreaterThanToken */: - case 62 /* GreaterThanGreaterThanEqualsToken */: - case 44 /* GreaterThanGreaterThanGreaterThanToken */: - case 63 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 46 /* BarToken */: - case 65 /* BarEqualsToken */: - case 47 /* CaretToken */: - case 66 /* CaretEqualsToken */: - case 45 /* AmpersandToken */: - case 64 /* AmpersandEqualsToken */: - // TypeScript 1.0 spec (April 2014): 4.15.1 + case 58 /* MinusEqualsToken */: + case 43 /* LessThanLessThanToken */: + case 63 /* LessThanLessThanEqualsToken */: + case 44 /* GreaterThanGreaterThanToken */: + case 64 /* GreaterThanGreaterThanEqualsToken */: + case 45 /* GreaterThanGreaterThanGreaterThanToken */: + case 65 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + case 47 /* BarToken */: + case 67 /* BarEqualsToken */: + case 48 /* CaretToken */: + case 68 /* CaretEqualsToken */: + case 46 /* AmpersandToken */: + case 66 /* AmpersandEqualsToken */: + // TypeScript 1.0 spec (April 2014): 4.19.1 // These operators require their operands to be of type Any, the Number primitive type, // or an enum type. Operands of an enum type are treated // as having the primitive type Number. If one operand is the null or undefined value, @@ -21868,21 +22450,21 @@ var ts; // try and return them a helpful suggestion if ((leftType.flags & 8 /* Boolean */) && (rightType.flags & 8 /* Boolean */) && - (suggestedOperator = getSuggestedBooleanOperator(node.operatorToken.kind)) !== undefined) { - error(node, ts.Diagnostics.The_0_operator_is_not_allowed_for_boolean_types_Consider_using_1_instead, ts.tokenToString(node.operatorToken.kind), ts.tokenToString(suggestedOperator)); + (suggestedOperator = getSuggestedBooleanOperator(operatorToken.kind)) !== undefined) { + error(errorNode || operatorToken, ts.Diagnostics.The_0_operator_is_not_allowed_for_boolean_types_Consider_using_1_instead, ts.tokenToString(operatorToken.kind), ts.tokenToString(suggestedOperator)); } else { // otherwise just check each operand separately and report errors as normal - var leftOk = checkArithmeticOperandType(node.left, leftType, ts.Diagnostics.The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type); - var rightOk = checkArithmeticOperandType(node.right, rightType, ts.Diagnostics.The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type); + var leftOk = checkArithmeticOperandType(left, leftType, ts.Diagnostics.The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type); + var rightOk = checkArithmeticOperandType(right, rightType, ts.Diagnostics.The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type); if (leftOk && rightOk) { checkAssignmentOperator(numberType); } } return numberType; case 35 /* PlusToken */: - case 56 /* PlusEqualsToken */: - // TypeScript 1.0 spec (April 2014): 4.15.2 + case 57 /* PlusEqualsToken */: + // TypeScript 1.0 spec (April 2014): 4.19.2 // The binary + operator requires both operands to be of the Number primitive type or an enum type, // or at least one of the operands to be of type Any or the String primitive type. // If one operand is the null or undefined value, it is treated as having the type of the other operand. @@ -21915,7 +22497,7 @@ var ts; reportOperatorError(); return anyType; } - if (operator === 56 /* PlusEqualsToken */) { + if (operator === 57 /* PlusEqualsToken */) { checkAssignmentOperator(resultType); } return resultType; @@ -21935,15 +22517,15 @@ var ts; reportOperatorError(); } return booleanType; - case 89 /* InstanceOfKeyword */: - return checkInstanceOfExpression(node, leftType, rightType); - case 88 /* InKeyword */: - return checkInExpression(node, leftType, rightType); - case 50 /* AmpersandAmpersandToken */: + case 91 /* InstanceOfKeyword */: + return checkInstanceOfExpression(left, right, leftType, rightType); + case 90 /* InKeyword */: + return checkInExpression(left, right, leftType, rightType); + case 51 /* AmpersandAmpersandToken */: return rightType; - case 51 /* BarBarToken */: + case 52 /* BarBarToken */: return getUnionType([leftType, rightType]); - case 55 /* EqualsToken */: + case 56 /* EqualsToken */: checkAssignmentOperator(rightType); return getRegularTypeOfObjectLiteral(rightType); case 24 /* CommaToken */: @@ -21951,8 +22533,8 @@ var ts; } // Return true if there was no error, false if there was an error. function checkForDisallowedESSymbolOperand(operator) { - var offendingSymbolOperand = someConstituentTypeHasKind(leftType, 16777216 /* ESSymbol */) ? node.left : - someConstituentTypeHasKind(rightType, 16777216 /* ESSymbol */) ? node.right : + var offendingSymbolOperand = someConstituentTypeHasKind(leftType, 16777216 /* ESSymbol */) ? left : + someConstituentTypeHasKind(rightType, 16777216 /* ESSymbol */) ? right : undefined; if (offendingSymbolOperand) { error(offendingSymbolOperand, ts.Diagnostics.The_0_operator_cannot_be_applied_to_type_symbol, ts.tokenToString(operator)); @@ -21962,37 +22544,37 @@ var ts; } function getSuggestedBooleanOperator(operator) { switch (operator) { - case 46 /* BarToken */: - case 65 /* BarEqualsToken */: - return 51 /* BarBarToken */; - case 47 /* CaretToken */: - case 66 /* CaretEqualsToken */: + case 47 /* BarToken */: + case 67 /* BarEqualsToken */: + return 52 /* BarBarToken */; + case 48 /* CaretToken */: + case 68 /* CaretEqualsToken */: return 33 /* ExclamationEqualsEqualsToken */; - case 45 /* AmpersandToken */: - case 64 /* AmpersandEqualsToken */: - return 50 /* AmpersandAmpersandToken */; + case 46 /* AmpersandToken */: + case 66 /* AmpersandEqualsToken */: + return 51 /* AmpersandAmpersandToken */; default: return undefined; } } function checkAssignmentOperator(valueType) { - if (produceDiagnostics && operator >= 55 /* FirstAssignment */ && operator <= 66 /* LastAssignment */) { + if (produceDiagnostics && operator >= 56 /* FirstAssignment */ && operator <= 68 /* LastAssignment */) { // TypeScript 1.0 spec (April 2014): 4.17 // An assignment of the form // VarExpr = ValueExpr // requires VarExpr to be classified as a reference // A compound assignment furthermore requires VarExpr to be classified as a reference (section 4.1) // and the type of the non - compound operation to be assignable to the type of VarExpr. - var ok = checkReferenceExpression(node.left, ts.Diagnostics.Invalid_left_hand_side_of_assignment_expression, ts.Diagnostics.Left_hand_side_of_assignment_expression_cannot_be_a_constant); + var ok = checkReferenceExpression(left, ts.Diagnostics.Invalid_left_hand_side_of_assignment_expression, ts.Diagnostics.Left_hand_side_of_assignment_expression_cannot_be_a_constant); // Use default messages if (ok) { // to avoid cascading errors check assignability only if 'isReference' check succeeded and no errors were reported - checkTypeAssignableTo(valueType, leftType, node.left, /*headMessage*/ undefined); + checkTypeAssignableTo(valueType, leftType, left, /*headMessage*/ undefined); } } } function reportOperatorError() { - error(node, ts.Diagnostics.Operator_0_cannot_be_applied_to_types_1_and_2, ts.tokenToString(node.operatorToken.kind), typeToString(leftType), typeToString(rightType)); + error(errorNode || operatorToken, ts.Diagnostics.Operator_0_cannot_be_applied_to_types_1_and_2, ts.tokenToString(operatorToken.kind), typeToString(leftType), typeToString(rightType)); } } function isYieldExpressionInClass(node) { @@ -22083,7 +22665,7 @@ var ts; // Do not use hasDynamicName here, because that returns false for well known symbols. // We want to perform checkComputedPropertyName for all computed properties, including // well known symbols. - if (node.name.kind === 134 /* ComputedPropertyName */) { + if (node.name.kind === 136 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); } return checkExpression(node.initializer, contextualMapper); @@ -22094,7 +22676,7 @@ var ts; // Do not use hasDynamicName here, because that returns false for well known symbols. // We want to perform checkComputedPropertyName for all computed properties, including // well known symbols. - if (node.name.kind === 134 /* ComputedPropertyName */) { + if (node.name.kind === 136 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); } var uninstantiatedType = checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); @@ -22124,7 +22706,7 @@ var ts; // contextually typed function and arrow expressions in the initial phase. function checkExpression(node, contextualMapper) { var type; - if (node.kind === 133 /* QualifiedName */) { + if (node.kind === 135 /* QualifiedName */) { type = checkQualifiedName(node); } else { @@ -22136,9 +22718,9 @@ var ts; // - 'left' in property access // - 'object' in indexed access // - target in rhs of import statement - var ok = (node.parent.kind === 164 /* PropertyAccessExpression */ && node.parent.expression === node) || - (node.parent.kind === 165 /* ElementAccessExpression */ && node.parent.expression === node) || - ((node.kind === 67 /* Identifier */ || node.kind === 133 /* QualifiedName */) && isInRightSideOfImportOrExportAssignment(node)); + var ok = (node.parent.kind === 166 /* PropertyAccessExpression */ && node.parent.expression === node) || + (node.parent.kind === 167 /* ElementAccessExpression */ && node.parent.expression === node) || + ((node.kind === 69 /* Identifier */ || node.kind === 135 /* QualifiedName */) && isInRightSideOfImportOrExportAssignment(node)); if (!ok) { error(node, ts.Diagnostics.const_enums_can_only_be_used_in_property_or_index_access_expressions_or_the_right_hand_side_of_an_import_declaration_or_export_assignment); } @@ -22152,78 +22734,78 @@ var ts; } function checkExpressionWorker(node, contextualMapper) { switch (node.kind) { - case 67 /* Identifier */: + case 69 /* Identifier */: return checkIdentifier(node); - case 95 /* ThisKeyword */: + case 97 /* ThisKeyword */: return checkThisExpression(node); - case 93 /* SuperKeyword */: + case 95 /* SuperKeyword */: return checkSuperExpression(node); - case 91 /* NullKeyword */: + case 93 /* NullKeyword */: return nullType; - case 97 /* TrueKeyword */: - case 82 /* FalseKeyword */: + case 99 /* TrueKeyword */: + case 84 /* FalseKeyword */: return booleanType; case 8 /* NumericLiteral */: return checkNumericLiteral(node); - case 181 /* TemplateExpression */: + case 183 /* TemplateExpression */: return checkTemplateExpression(node); case 9 /* StringLiteral */: case 11 /* NoSubstitutionTemplateLiteral */: return stringType; case 10 /* RegularExpressionLiteral */: return globalRegExpType; - case 162 /* ArrayLiteralExpression */: + case 164 /* ArrayLiteralExpression */: return checkArrayLiteral(node, contextualMapper); - case 163 /* ObjectLiteralExpression */: + case 165 /* ObjectLiteralExpression */: return checkObjectLiteral(node, contextualMapper); - case 164 /* PropertyAccessExpression */: + case 166 /* PropertyAccessExpression */: return checkPropertyAccessExpression(node); - case 165 /* ElementAccessExpression */: + case 167 /* ElementAccessExpression */: return checkIndexedAccess(node); - case 166 /* CallExpression */: - case 167 /* NewExpression */: + case 168 /* CallExpression */: + case 169 /* NewExpression */: return checkCallExpression(node); - case 168 /* TaggedTemplateExpression */: + case 170 /* TaggedTemplateExpression */: return checkTaggedTemplateExpression(node); - case 170 /* ParenthesizedExpression */: + case 172 /* ParenthesizedExpression */: return checkExpression(node.expression, contextualMapper); - case 184 /* ClassExpression */: + case 186 /* ClassExpression */: return checkClassExpression(node); - case 171 /* FunctionExpression */: - case 172 /* ArrowFunction */: + case 173 /* FunctionExpression */: + case 174 /* ArrowFunction */: return checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); - case 174 /* TypeOfExpression */: + case 176 /* TypeOfExpression */: return checkTypeOfExpression(node); - case 169 /* TypeAssertionExpression */: - case 187 /* AsExpression */: + case 171 /* TypeAssertionExpression */: + case 189 /* AsExpression */: return checkAssertion(node); - case 173 /* DeleteExpression */: + case 175 /* DeleteExpression */: return checkDeleteExpression(node); - case 175 /* VoidExpression */: + case 177 /* VoidExpression */: return checkVoidExpression(node); - case 176 /* AwaitExpression */: + case 178 /* AwaitExpression */: return checkAwaitExpression(node); - case 177 /* PrefixUnaryExpression */: + case 179 /* PrefixUnaryExpression */: return checkPrefixUnaryExpression(node); - case 178 /* PostfixUnaryExpression */: + case 180 /* PostfixUnaryExpression */: return checkPostfixUnaryExpression(node); - case 179 /* BinaryExpression */: + case 181 /* BinaryExpression */: return checkBinaryExpression(node, contextualMapper); - case 180 /* ConditionalExpression */: + case 182 /* ConditionalExpression */: return checkConditionalExpression(node, contextualMapper); - case 183 /* SpreadElementExpression */: + case 185 /* SpreadElementExpression */: return checkSpreadElementExpression(node, contextualMapper); - case 185 /* OmittedExpression */: + case 187 /* OmittedExpression */: return undefinedType; - case 182 /* YieldExpression */: + case 184 /* YieldExpression */: return checkYieldExpression(node); - case 238 /* JsxExpression */: + case 240 /* JsxExpression */: return checkJsxExpression(node); - case 231 /* JsxElement */: + case 233 /* JsxElement */: return checkJsxElement(node); - case 232 /* JsxSelfClosingElement */: + case 234 /* JsxSelfClosingElement */: return checkJsxSelfClosingElement(node); - case 233 /* JsxOpeningElement */: + case 235 /* JsxOpeningElement */: ts.Debug.fail("Shouldn't ever directly check a JsxOpeningElement"); } return unknownType; @@ -22252,7 +22834,7 @@ var ts; var func = ts.getContainingFunction(node); if (node.flags & 112 /* AccessibilityModifier */) { func = ts.getContainingFunction(node); - if (!(func.kind === 142 /* Constructor */ && ts.nodeIsPresent(func.body))) { + if (!(func.kind === 144 /* Constructor */ && ts.nodeIsPresent(func.body))) { error(node, ts.Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation); } } @@ -22269,15 +22851,15 @@ var ts; if (!node.asteriskToken || !node.body) { return false; } - return node.kind === 141 /* MethodDeclaration */ || - node.kind === 211 /* FunctionDeclaration */ || - node.kind === 171 /* FunctionExpression */; + return node.kind === 143 /* MethodDeclaration */ || + node.kind === 213 /* FunctionDeclaration */ || + node.kind === 173 /* FunctionExpression */; } function getTypePredicateParameterIndex(parameterList, parameter) { if (parameterList) { for (var i = 0; i < parameterList.length; i++) { var param = parameterList[i]; - if (param.name.kind === 67 /* Identifier */ && + if (param.name.kind === 69 /* Identifier */ && param.name.text === parameter.text) { return i; } @@ -22287,31 +22869,31 @@ var ts; } function isInLegalTypePredicatePosition(node) { switch (node.parent.kind) { - case 172 /* ArrowFunction */: - case 145 /* CallSignature */: - case 211 /* FunctionDeclaration */: - case 171 /* FunctionExpression */: - case 150 /* FunctionType */: - case 141 /* MethodDeclaration */: - case 140 /* MethodSignature */: + case 174 /* ArrowFunction */: + case 147 /* CallSignature */: + case 213 /* FunctionDeclaration */: + case 173 /* FunctionExpression */: + case 152 /* FunctionType */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: return node === node.parent.type; } return false; } function checkSignatureDeclaration(node) { // Grammar checking - if (node.kind === 147 /* IndexSignature */) { + if (node.kind === 149 /* IndexSignature */) { checkGrammarIndexSignature(node); } - else if (node.kind === 150 /* FunctionType */ || node.kind === 211 /* FunctionDeclaration */ || node.kind === 151 /* ConstructorType */ || - node.kind === 145 /* CallSignature */ || node.kind === 142 /* Constructor */ || - node.kind === 146 /* ConstructSignature */) { + else if (node.kind === 152 /* FunctionType */ || node.kind === 213 /* FunctionDeclaration */ || node.kind === 153 /* ConstructorType */ || + node.kind === 147 /* CallSignature */ || node.kind === 144 /* Constructor */ || + node.kind === 148 /* ConstructSignature */) { checkGrammarFunctionLikeDeclaration(node); } checkTypeParameters(node.typeParameters); ts.forEach(node.parameters, checkParameter); if (node.type) { - if (node.type.kind === 148 /* TypePredicate */) { + if (node.type.kind === 150 /* TypePredicate */) { var typePredicate = getSignatureFromDeclaration(node).typePredicate; var typePredicateNode = node.type; if (isInLegalTypePredicatePosition(typePredicateNode)) { @@ -22330,19 +22912,19 @@ var ts; if (hasReportedError) { break; } - if (param.name.kind === 159 /* ObjectBindingPattern */ || - param.name.kind === 160 /* ArrayBindingPattern */) { + if (param.name.kind === 161 /* ObjectBindingPattern */ || + param.name.kind === 162 /* ArrayBindingPattern */) { (function checkBindingPattern(pattern) { for (var _i = 0, _a = pattern.elements; _i < _a.length; _i++) { var element = _a[_i]; - if (element.name.kind === 67 /* Identifier */ && + if (element.name.kind === 69 /* Identifier */ && element.name.text === typePredicate.parameterName) { error(typePredicateNode.parameterName, ts.Diagnostics.A_type_predicate_cannot_reference_element_0_in_a_binding_pattern, typePredicate.parameterName); hasReportedError = true; break; } - else if (element.name.kind === 160 /* ArrayBindingPattern */ || - element.name.kind === 159 /* ObjectBindingPattern */) { + else if (element.name.kind === 162 /* ArrayBindingPattern */ || + element.name.kind === 161 /* ObjectBindingPattern */) { checkBindingPattern(element.name); } } @@ -22366,10 +22948,10 @@ var ts; checkCollisionWithArgumentsInGeneratedCode(node); if (compilerOptions.noImplicitAny && !node.type) { switch (node.kind) { - case 146 /* ConstructSignature */: + case 148 /* ConstructSignature */: error(node, ts.Diagnostics.Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; - case 145 /* CallSignature */: + case 147 /* CallSignature */: error(node, ts.Diagnostics.Call_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; } @@ -22397,7 +22979,7 @@ var ts; checkSpecializedSignatureDeclaration(node); } function checkTypeForDuplicateIndexSignatures(node) { - if (node.kind === 213 /* InterfaceDeclaration */) { + if (node.kind === 215 /* InterfaceDeclaration */) { var nodeSymbol = getSymbolOfNode(node); // in case of merging interface declaration it is possible that we'll enter this check procedure several times for every declaration // to prevent this run check only for the first declaration of a given kind @@ -22417,7 +22999,7 @@ var ts; var declaration = decl; if (declaration.parameters.length === 1 && declaration.parameters[0].type) { switch (declaration.parameters[0].type.kind) { - case 128 /* StringKeyword */: + case 130 /* StringKeyword */: if (!seenStringIndexer) { seenStringIndexer = true; } @@ -22425,7 +23007,7 @@ var ts; error(declaration, ts.Diagnostics.Duplicate_string_index_signature); } break; - case 126 /* NumberKeyword */: + case 128 /* NumberKeyword */: if (!seenNumericIndexer) { seenNumericIndexer = true; } @@ -22474,7 +23056,7 @@ var ts; return; } function isSuperCallExpression(n) { - return n.kind === 166 /* CallExpression */ && n.expression.kind === 93 /* SuperKeyword */; + return n.kind === 168 /* CallExpression */ && n.expression.kind === 95 /* SuperKeyword */; } function containsSuperCallAsComputedPropertyName(n) { return n.name && containsSuperCall(n.name); @@ -22492,15 +23074,15 @@ var ts; return ts.forEachChild(n, containsSuperCall); } function markThisReferencesAsErrors(n) { - if (n.kind === 95 /* ThisKeyword */) { + if (n.kind === 97 /* ThisKeyword */) { error(n, ts.Diagnostics.this_cannot_be_referenced_in_current_location); } - else if (n.kind !== 171 /* FunctionExpression */ && n.kind !== 211 /* FunctionDeclaration */) { + else if (n.kind !== 173 /* FunctionExpression */ && n.kind !== 213 /* FunctionDeclaration */) { ts.forEachChild(n, markThisReferencesAsErrors); } } function isInstancePropertyWithInitializer(n) { - return n.kind === 139 /* PropertyDeclaration */ && + return n.kind === 141 /* PropertyDeclaration */ && !(n.flags & 128 /* Static */) && !!n.initializer; } @@ -22530,7 +23112,7 @@ var ts; var superCallStatement; for (var _i = 0; _i < statements.length; _i++) { var statement = statements[_i]; - if (statement.kind === 193 /* ExpressionStatement */ && isSuperCallExpression(statement.expression)) { + if (statement.kind === 195 /* ExpressionStatement */ && isSuperCallExpression(statement.expression)) { superCallStatement = statement; break; } @@ -22556,7 +23138,7 @@ var ts; if (produceDiagnostics) { // Grammar checking accessors checkGrammarFunctionLikeDeclaration(node) || checkGrammarAccessor(node) || checkGrammarComputedPropertyName(node.name); - if (node.kind === 143 /* GetAccessor */) { + if (node.kind === 145 /* GetAccessor */) { if (!ts.isInAmbientContext(node) && ts.nodeIsPresent(node.body) && !(bodyContainsAReturnStatement(node.body) || bodyContainsSingleThrowStatement(node.body))) { error(node.name, ts.Diagnostics.A_get_accessor_must_return_a_value_or_consist_of_a_single_throw_statement); } @@ -22564,7 +23146,7 @@ var ts; if (!ts.hasDynamicName(node)) { // TypeScript 1.0 spec (April 2014): 8.4.3 // Accessors for the same member name must specify the same accessibility. - var otherKind = node.kind === 143 /* GetAccessor */ ? 144 /* SetAccessor */ : 143 /* GetAccessor */; + var otherKind = node.kind === 145 /* GetAccessor */ ? 146 /* SetAccessor */ : 145 /* GetAccessor */; var otherAccessor = ts.getDeclarationOfKind(node.symbol, otherKind); if (otherAccessor) { if (((node.flags & 112 /* AccessibilityModifier */) !== (otherAccessor.flags & 112 /* AccessibilityModifier */))) { @@ -22660,9 +23242,9 @@ var ts; var signaturesToCheck; // Unnamed (call\construct) signatures in interfaces are inherited and not shadowed so examining just node symbol won't give complete answer. // Use declaring type to obtain full list of signatures. - if (!signatureDeclarationNode.name && signatureDeclarationNode.parent && signatureDeclarationNode.parent.kind === 213 /* InterfaceDeclaration */) { - ts.Debug.assert(signatureDeclarationNode.kind === 145 /* CallSignature */ || signatureDeclarationNode.kind === 146 /* ConstructSignature */); - var signatureKind = signatureDeclarationNode.kind === 145 /* CallSignature */ ? 0 /* Call */ : 1 /* Construct */; + if (!signatureDeclarationNode.name && signatureDeclarationNode.parent && signatureDeclarationNode.parent.kind === 215 /* InterfaceDeclaration */) { + ts.Debug.assert(signatureDeclarationNode.kind === 147 /* CallSignature */ || signatureDeclarationNode.kind === 148 /* ConstructSignature */); + var signatureKind = signatureDeclarationNode.kind === 147 /* CallSignature */ ? 0 /* Call */ : 1 /* Construct */; var containingSymbol = getSymbolOfNode(signatureDeclarationNode.parent); var containingType = getDeclaredTypeOfSymbol(containingSymbol); signaturesToCheck = getSignaturesOfType(containingType, signatureKind); @@ -22680,7 +23262,7 @@ var ts; } function getEffectiveDeclarationFlags(n, flagsToCheck) { var flags = ts.getCombinedNodeFlags(n); - if (n.parent.kind !== 213 /* InterfaceDeclaration */ && ts.isInAmbientContext(n)) { + if (n.parent.kind !== 215 /* InterfaceDeclaration */ && ts.isInAmbientContext(n)) { if (!(flags & 2 /* Ambient */)) { // It is nested in an ambient context, which means it is automatically exported flags |= 1 /* Export */; @@ -22766,7 +23348,7 @@ var ts; // TODO(jfreeman): These are methods, so handle computed name case if (node.name && subsequentNode.name && node.name.text === subsequentNode.name.text) { // the only situation when this is possible (same kind\same name but different symbol) - mixed static and instance class members - ts.Debug.assert(node.kind === 141 /* MethodDeclaration */ || node.kind === 140 /* MethodSignature */); + ts.Debug.assert(node.kind === 143 /* MethodDeclaration */ || node.kind === 142 /* MethodSignature */); ts.Debug.assert((node.flags & 128 /* Static */) !== (subsequentNode.flags & 128 /* Static */)); var diagnostic = node.flags & 128 /* Static */ ? ts.Diagnostics.Function_overload_must_be_static : ts.Diagnostics.Function_overload_must_not_be_static; error(errorNode_1, diagnostic); @@ -22802,7 +23384,7 @@ var ts; var current = declarations[_i]; var node = current; var inAmbientContext = ts.isInAmbientContext(node); - var inAmbientContextOrInterface = node.parent.kind === 213 /* InterfaceDeclaration */ || node.parent.kind === 153 /* TypeLiteral */ || inAmbientContext; + var inAmbientContextOrInterface = node.parent.kind === 215 /* InterfaceDeclaration */ || node.parent.kind === 155 /* TypeLiteral */ || inAmbientContext; if (inAmbientContextOrInterface) { // check if declarations are consecutive only if they are non-ambient // 1. ambient declarations can be interleaved @@ -22813,7 +23395,7 @@ var ts; // 2. mixing ambient and non-ambient declarations is a separate error that will be reported - do not want to report an extra one previousDeclaration = undefined; } - if (node.kind === 211 /* FunctionDeclaration */ || node.kind === 141 /* MethodDeclaration */ || node.kind === 140 /* MethodSignature */ || node.kind === 142 /* Constructor */) { + if (node.kind === 213 /* FunctionDeclaration */ || node.kind === 143 /* MethodDeclaration */ || node.kind === 142 /* MethodSignature */ || node.kind === 144 /* Constructor */) { var currentNodeFlags = getEffectiveDeclarationFlags(node, flagsToCheck); someNodeFlags |= currentNodeFlags; allNodeFlags &= currentNodeFlags; @@ -22953,16 +23535,16 @@ var ts; } function getDeclarationSpaces(d) { switch (d.kind) { - case 213 /* InterfaceDeclaration */: + case 215 /* InterfaceDeclaration */: return 2097152 /* ExportType */; - case 216 /* ModuleDeclaration */: + case 218 /* ModuleDeclaration */: return d.name.kind === 9 /* StringLiteral */ || ts.getModuleInstanceState(d) !== 0 /* NonInstantiated */ ? 4194304 /* ExportNamespace */ | 1048576 /* ExportValue */ : 4194304 /* ExportNamespace */; - case 212 /* ClassDeclaration */: - case 215 /* EnumDeclaration */: + case 214 /* ClassDeclaration */: + case 217 /* EnumDeclaration */: return 2097152 /* ExportType */ | 1048576 /* ExportValue */; - case 219 /* ImportEqualsDeclaration */: + case 221 /* ImportEqualsDeclaration */: var result = 0; var target = resolveAlias(getSymbolOfNode(d)); ts.forEach(target.declarations, function (d) { result |= getDeclarationSpaces(d); }); @@ -22973,7 +23555,8 @@ var ts; } } function checkNonThenableType(type, location, message) { - if (!(type.flags & 1 /* Any */) && isTypeAssignableTo(type, getGlobalThenableType())) { + type = getWidenedType(type); + if (!isTypeAny(type) && isTypeAssignableTo(type, getGlobalThenableType())) { if (location) { if (!message) { message = ts.Diagnostics.Operand_for_await_does_not_have_a_valid_callable_then_member; @@ -23206,22 +23789,22 @@ var ts; var headMessage = getDiagnosticHeadMessageForDecoratorResolution(node); var errorInfo; switch (node.parent.kind) { - case 212 /* ClassDeclaration */: + case 214 /* ClassDeclaration */: var classSymbol = getSymbolOfNode(node.parent); var classConstructorType = getTypeOfSymbol(classSymbol); expectedReturnType = getUnionType([classConstructorType, voidType]); break; - case 136 /* Parameter */: + case 138 /* Parameter */: expectedReturnType = voidType; errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.The_return_type_of_a_parameter_decorator_function_must_be_either_void_or_any); break; - case 139 /* PropertyDeclaration */: + case 141 /* PropertyDeclaration */: expectedReturnType = voidType; errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.The_return_type_of_a_property_decorator_function_must_be_either_void_or_any); break; - case 141 /* MethodDeclaration */: - case 143 /* GetAccessor */: - case 144 /* SetAccessor */: + case 143 /* MethodDeclaration */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: var methodType = getTypeOfNode(node.parent); var descriptorType = createTypedPropertyDescriptorType(methodType); expectedReturnType = getUnionType([descriptorType, voidType]); @@ -23234,9 +23817,9 @@ var ts; // When we are emitting type metadata for decorators, we need to try to check the type // as if it were an expression so that we can emit the type in a value position when we // serialize the type metadata. - if (node && node.kind === 149 /* TypeReference */) { + if (node && node.kind === 151 /* TypeReference */) { var root = getFirstIdentifier(node.typeName); - var meaning = root.parent.kind === 149 /* TypeReference */ ? 793056 /* Type */ : 1536 /* Namespace */; + var meaning = root.parent.kind === 151 /* TypeReference */ ? 793056 /* Type */ : 1536 /* Namespace */; // Resolve type so we know which symbol is referenced var rootSymbol = resolveName(root, root.text, meaning | 8388608 /* Alias */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined); // Resolved symbol is alias @@ -23255,19 +23838,19 @@ var ts; */ function checkTypeAnnotationAsExpression(node) { switch (node.kind) { - case 139 /* PropertyDeclaration */: + case 141 /* PropertyDeclaration */: checkTypeNodeAsExpression(node.type); break; - case 136 /* Parameter */: + case 138 /* Parameter */: checkTypeNodeAsExpression(node.type); break; - case 141 /* MethodDeclaration */: + case 143 /* MethodDeclaration */: checkTypeNodeAsExpression(node.type); break; - case 143 /* GetAccessor */: + case 145 /* GetAccessor */: checkTypeNodeAsExpression(node.type); break; - case 144 /* SetAccessor */: + case 146 /* SetAccessor */: checkTypeNodeAsExpression(ts.getSetAccessorTypeAnnotationNode(node)); break; } @@ -23296,25 +23879,25 @@ var ts; if (compilerOptions.emitDecoratorMetadata) { // we only need to perform these checks if we are emitting serialized type metadata for the target of a decorator. switch (node.kind) { - case 212 /* ClassDeclaration */: + case 214 /* ClassDeclaration */: var constructor = ts.getFirstConstructorWithBody(node); if (constructor) { checkParameterTypeAnnotationsAsExpressions(constructor); } break; - case 141 /* MethodDeclaration */: + case 143 /* MethodDeclaration */: checkParameterTypeAnnotationsAsExpressions(node); // fall-through - case 144 /* SetAccessor */: - case 143 /* GetAccessor */: - case 139 /* PropertyDeclaration */: - case 136 /* Parameter */: + case 146 /* SetAccessor */: + case 145 /* GetAccessor */: + case 141 /* PropertyDeclaration */: + case 138 /* Parameter */: checkTypeAnnotationAsExpression(node); break; } } emitDecorate = true; - if (node.kind === 136 /* Parameter */) { + if (node.kind === 138 /* Parameter */) { emitParam = true; } ts.forEach(node.decorators, checkDecorator); @@ -23332,15 +23915,12 @@ var ts; checkSignatureDeclaration(node); var isAsync = ts.isAsyncFunctionLike(node); if (isAsync) { - if (!compilerOptions.experimentalAsyncFunctions) { - error(node, ts.Diagnostics.Experimental_support_for_async_functions_is_a_feature_that_is_subject_to_change_in_a_future_release_Specify_experimentalAsyncFunctions_to_remove_this_warning); - } emitAwaiter = true; } // Do not use hasDynamicName here, because that returns false for well known symbols. // We want to perform checkComputedPropertyName for all computed properties, including // well known symbols. - if (node.name && node.name.kind === 134 /* ComputedPropertyName */) { + if (node.name && node.name.kind === 136 /* ComputedPropertyName */) { // This check will account for methods in class/interface declarations, // as well as accessors in classes/object literals checkComputedPropertyName(node.name); @@ -23389,11 +23969,11 @@ var ts; } function checkBlock(node) { // Grammar checking for SyntaxKind.Block - if (node.kind === 190 /* Block */) { + if (node.kind === 192 /* Block */) { checkGrammarStatementInAmbientContext(node); } ts.forEach(node.statements, checkSourceElement); - if (ts.isFunctionBlock(node) || node.kind === 217 /* ModuleBlock */) { + if (ts.isFunctionBlock(node) || node.kind === 219 /* ModuleBlock */) { checkFunctionAndClassExpressionBodies(node); } } @@ -23412,12 +23992,12 @@ var ts; if (!(identifier && identifier.text === name)) { return false; } - if (node.kind === 139 /* PropertyDeclaration */ || - node.kind === 138 /* PropertySignature */ || - node.kind === 141 /* MethodDeclaration */ || - node.kind === 140 /* MethodSignature */ || - node.kind === 143 /* GetAccessor */ || - node.kind === 144 /* SetAccessor */) { + if (node.kind === 141 /* PropertyDeclaration */ || + node.kind === 140 /* PropertySignature */ || + node.kind === 143 /* MethodDeclaration */ || + node.kind === 142 /* MethodSignature */ || + node.kind === 145 /* GetAccessor */ || + node.kind === 146 /* SetAccessor */) { // it is ok to have member named '_super' or '_this' - member access is always qualified return false; } @@ -23426,7 +24006,7 @@ var ts; return false; } var root = ts.getRootDeclaration(node); - if (root.kind === 136 /* Parameter */ && ts.nodeIsMissing(root.parent.body)) { + if (root.kind === 138 /* Parameter */ && ts.nodeIsMissing(root.parent.body)) { // just an overload - no codegen impact return false; } @@ -23442,7 +24022,7 @@ var ts; var current = node; while (current) { if (getNodeCheckFlags(current) & 4 /* CaptureThis */) { - var isDeclaration_1 = node.kind !== 67 /* Identifier */; + var isDeclaration_1 = node.kind !== 69 /* Identifier */; if (isDeclaration_1) { error(node.name, ts.Diagnostics.Duplicate_identifier_this_Compiler_uses_variable_declaration_this_to_capture_this_reference); } @@ -23465,7 +24045,7 @@ var ts; return; } if (ts.getClassExtendsHeritageClauseElement(enclosingClass)) { - var isDeclaration_2 = node.kind !== 67 /* Identifier */; + var isDeclaration_2 = node.kind !== 69 /* Identifier */; if (isDeclaration_2) { error(node, ts.Diagnostics.Duplicate_identifier_super_Compiler_uses_super_to_capture_base_class_reference); } @@ -23479,12 +24059,12 @@ var ts; return; } // Uninstantiated modules shouldnt do this check - if (node.kind === 216 /* ModuleDeclaration */ && ts.getModuleInstanceState(node) !== 1 /* Instantiated */) { + if (node.kind === 218 /* ModuleDeclaration */ && ts.getModuleInstanceState(node) !== 1 /* Instantiated */) { return; } // In case of variable declaration, node.parent is variable statement so look at the variable statement's parent var parent = getDeclarationContainer(node); - if (parent.kind === 246 /* SourceFile */ && ts.isExternalModule(parent)) { + if (parent.kind === 248 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent)) { // If the declaration happens to be in external module, report error that require and exports are reserved keywords error(name, ts.Diagnostics.Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module, ts.declarationNameToString(name), ts.declarationNameToString(name)); } @@ -23519,7 +24099,7 @@ var ts; // skip variable declarations that don't have initializers // NOTE: in ES6 spec initializer is required in variable declarations where name is binding pattern // so we'll always treat binding elements as initialized - if (node.kind === 209 /* VariableDeclaration */ && !node.initializer) { + if (node.kind === 211 /* VariableDeclaration */ && !node.initializer) { return; } var symbol = getSymbolOfNode(node); @@ -23529,17 +24109,17 @@ var ts; localDeclarationSymbol !== symbol && localDeclarationSymbol.flags & 2 /* BlockScopedVariable */) { if (getDeclarationFlagsFromSymbol(localDeclarationSymbol) & 49152 /* BlockScoped */) { - var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 210 /* VariableDeclarationList */); - var container = varDeclList.parent.kind === 191 /* VariableStatement */ && varDeclList.parent.parent + var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 212 /* VariableDeclarationList */); + var container = varDeclList.parent.kind === 193 /* VariableStatement */ && varDeclList.parent.parent ? varDeclList.parent.parent : undefined; // names of block-scoped and function scoped variables can collide only // if block scoped variable is defined in the function\module\source file scope (because of variable hoisting) var namesShareScope = container && - (container.kind === 190 /* Block */ && ts.isFunctionLike(container.parent) || - container.kind === 217 /* ModuleBlock */ || - container.kind === 216 /* ModuleDeclaration */ || - container.kind === 246 /* SourceFile */); + (container.kind === 192 /* Block */ && ts.isFunctionLike(container.parent) || + container.kind === 219 /* ModuleBlock */ || + container.kind === 218 /* ModuleDeclaration */ || + container.kind === 248 /* SourceFile */); // here we know that function scoped variable is shadowed by block scoped one // if they are defined in the same scope - binder has already reported redeclaration error // otherwise if variable has an initializer - show error that initialization will fail @@ -23554,18 +24134,18 @@ var ts; } // Check that a parameter initializer contains no references to parameters declared to the right of itself function checkParameterInitializer(node) { - if (ts.getRootDeclaration(node).kind !== 136 /* Parameter */) { + if (ts.getRootDeclaration(node).kind !== 138 /* Parameter */) { return; } var func = ts.getContainingFunction(node); visit(node.initializer); function visit(n) { - if (n.kind === 67 /* Identifier */) { + if (n.kind === 69 /* Identifier */) { var referencedSymbol = getNodeLinks(n).resolvedSymbol; // check FunctionLikeDeclaration.locals (stores parameters\function local variable) // if it contains entry with a specified name and if this entry matches the resolved symbol if (referencedSymbol && referencedSymbol !== unknownSymbol && getSymbol(func.locals, referencedSymbol.name, 107455 /* Value */) === referencedSymbol) { - if (referencedSymbol.valueDeclaration.kind === 136 /* Parameter */) { + if (referencedSymbol.valueDeclaration.kind === 138 /* Parameter */) { if (referencedSymbol.valueDeclaration === node) { error(n, ts.Diagnostics.Parameter_0_cannot_be_referenced_in_its_initializer, ts.declarationNameToString(node.name)); return; @@ -23591,7 +24171,7 @@ var ts; // Do not use hasDynamicName here, because that returns false for well known symbols. // We want to perform checkComputedPropertyName for all computed properties, including // well known symbols. - if (node.name.kind === 134 /* ComputedPropertyName */) { + if (node.name.kind === 136 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); if (node.initializer) { checkExpressionCached(node.initializer); @@ -23602,7 +24182,7 @@ var ts; ts.forEach(node.name.elements, checkSourceElement); } // For a parameter declaration with an initializer, error and exit if the containing function doesn't have a body - if (node.initializer && ts.getRootDeclaration(node).kind === 136 /* Parameter */ && ts.nodeIsMissing(ts.getContainingFunction(node).body)) { + if (node.initializer && ts.getRootDeclaration(node).kind === 138 /* Parameter */ && ts.nodeIsMissing(ts.getContainingFunction(node).body)) { error(node, ts.Diagnostics.A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation); return; } @@ -23634,10 +24214,10 @@ var ts; checkTypeAssignableTo(checkExpressionCached(node.initializer), declarationType, node, /*headMessage*/ undefined); } } - if (node.kind !== 139 /* PropertyDeclaration */ && node.kind !== 138 /* PropertySignature */) { + if (node.kind !== 141 /* PropertyDeclaration */ && node.kind !== 140 /* PropertySignature */) { // We know we don't have a binding pattern or computed name here checkExportsOnMergedDeclarations(node); - if (node.kind === 209 /* VariableDeclaration */ || node.kind === 161 /* BindingElement */) { + if (node.kind === 211 /* VariableDeclaration */ || node.kind === 163 /* BindingElement */) { checkVarDeclaredNamesNotShadowed(node); } checkCollisionWithCapturedSuperVariable(node, node.name); @@ -23660,7 +24240,7 @@ var ts; } function checkGrammarDisallowedModifiersOnObjectLiteralExpressionMethod(node) { // We only disallow modifier on a method declaration if it is a property of object-literal-expression - if (node.modifiers && node.parent.kind === 163 /* ObjectLiteralExpression */) { + if (node.modifiers && node.parent.kind === 165 /* ObjectLiteralExpression */) { if (ts.isAsyncFunctionLike(node)) { if (node.modifiers.length > 1) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); @@ -23698,12 +24278,12 @@ var ts; function checkForStatement(node) { // Grammar checking if (!checkGrammarStatementInAmbientContext(node)) { - if (node.initializer && node.initializer.kind === 210 /* VariableDeclarationList */) { + if (node.initializer && node.initializer.kind === 212 /* VariableDeclarationList */) { checkGrammarVariableDeclarationList(node.initializer); } } if (node.initializer) { - if (node.initializer.kind === 210 /* VariableDeclarationList */) { + if (node.initializer.kind === 212 /* VariableDeclarationList */) { ts.forEach(node.initializer.declarations, checkVariableDeclaration); } else { @@ -23723,14 +24303,14 @@ var ts; // via checkRightHandSideOfForOf. // If the LHS is an expression, check the LHS, as a destructuring assignment or as a reference. // Then check that the RHS is assignable to it. - if (node.initializer.kind === 210 /* VariableDeclarationList */) { + if (node.initializer.kind === 212 /* VariableDeclarationList */) { checkForInOrForOfVariableDeclaration(node); } else { var varExpr = node.initializer; var iteratedType = checkRightHandSideOfForOf(node.expression); // There may be a destructuring assignment on the left side - if (varExpr.kind === 162 /* ArrayLiteralExpression */ || varExpr.kind === 163 /* ObjectLiteralExpression */) { + if (varExpr.kind === 164 /* ArrayLiteralExpression */ || varExpr.kind === 165 /* ObjectLiteralExpression */) { // iteratedType may be undefined. In this case, we still want to check the structure of // varExpr, in particular making sure it's a valid LeftHandSideExpression. But we'd like // to short circuit the type relation checking as much as possible, so we pass the unknownType. @@ -23759,7 +24339,7 @@ var ts; // for (let VarDecl in Expr) Statement // VarDecl must be a variable declaration without a type annotation that declares a variable of type Any, // and Expr must be an expression of type Any, an object type, or a type parameter type. - if (node.initializer.kind === 210 /* VariableDeclarationList */) { + if (node.initializer.kind === 212 /* VariableDeclarationList */) { var variable = node.initializer.declarations[0]; if (variable && ts.isBindingPattern(variable.name)) { error(variable.name, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern); @@ -23773,7 +24353,7 @@ var ts; // and Expr must be an expression of type Any, an object type, or a type parameter type. var varExpr = node.initializer; var leftType = checkExpression(varExpr); - if (varExpr.kind === 162 /* ArrayLiteralExpression */ || varExpr.kind === 163 /* ObjectLiteralExpression */) { + if (varExpr.kind === 164 /* ArrayLiteralExpression */ || varExpr.kind === 165 /* ObjectLiteralExpression */) { error(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern); } else if (!isTypeAnyOrAllConstituentTypesHaveKind(leftType, 258 /* StringLike */)) { @@ -24012,7 +24592,7 @@ var ts; // TODO: Check that target label is valid } function isGetAccessorWithAnnotatatedSetAccessor(node) { - return !!(node.kind === 143 /* GetAccessor */ && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(node.symbol, 144 /* SetAccessor */))); + return !!(node.kind === 145 /* GetAccessor */ && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(node.symbol, 146 /* SetAccessor */))); } function checkReturnStatement(node) { // Grammar checking @@ -24035,10 +24615,10 @@ var ts; // for generators. return; } - if (func.kind === 144 /* SetAccessor */) { + if (func.kind === 146 /* SetAccessor */) { error(node.expression, ts.Diagnostics.Setters_cannot_return_a_value); } - else if (func.kind === 142 /* Constructor */) { + else if (func.kind === 144 /* Constructor */) { if (!isTypeAssignableTo(exprType, returnType)) { error(node.expression, ts.Diagnostics.Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class); } @@ -24047,7 +24627,12 @@ var ts; if (ts.isAsyncFunctionLike(func)) { var promisedType = getPromisedType(returnType); var awaitedType = checkAwaitedType(exprType, node.expression, ts.Diagnostics.Return_expression_in_async_function_does_not_have_a_valid_callable_then_member); - checkTypeAssignableTo(awaitedType, promisedType, node.expression); + if (promisedType) { + // If the function has a return type, but promisedType is + // undefined, an error will be reported in checkAsyncFunctionReturnType + // so we don't need to report one here. + checkTypeAssignableTo(awaitedType, promisedType, node.expression); + } } else { checkTypeAssignableTo(exprType, returnType, node.expression); @@ -24074,7 +24659,7 @@ var ts; var expressionType = checkExpression(node.expression); ts.forEach(node.caseBlock.clauses, function (clause) { // Grammar check for duplicate default clauses, skip if we already report duplicate default clause - if (clause.kind === 240 /* DefaultClause */ && !hasDuplicateDefaultClause) { + if (clause.kind === 242 /* DefaultClause */ && !hasDuplicateDefaultClause) { if (firstDefaultClause === undefined) { firstDefaultClause = clause; } @@ -24086,7 +24671,7 @@ var ts; hasDuplicateDefaultClause = true; } } - if (produceDiagnostics && clause.kind === 239 /* CaseClause */) { + if (produceDiagnostics && clause.kind === 241 /* CaseClause */) { var caseClause = clause; // TypeScript 1.0 spec (April 2014):5.9 // In a 'switch' statement, each 'case' expression must be of a type that is assignable to or from the type of the 'switch' expression. @@ -24107,7 +24692,7 @@ var ts; if (ts.isFunctionLike(current)) { break; } - if (current.kind === 205 /* LabeledStatement */ && current.label.text === node.label.text) { + if (current.kind === 207 /* LabeledStatement */ && current.label.text === node.label.text) { var sourceFile = ts.getSourceFileOfNode(node); grammarErrorOnNode(node.label, ts.Diagnostics.Duplicate_label_0, ts.getTextOfNodeFromSourceText(sourceFile.text, node.label)); break; @@ -24137,7 +24722,7 @@ var ts; if (catchClause) { // Grammar checking if (catchClause.variableDeclaration) { - if (catchClause.variableDeclaration.name.kind !== 67 /* Identifier */) { + if (catchClause.variableDeclaration.name.kind !== 69 /* Identifier */) { grammarErrorOnFirstToken(catchClause.variableDeclaration.name, ts.Diagnostics.Catch_clause_variable_name_must_be_an_identifier); } else if (catchClause.variableDeclaration.type) { @@ -24212,7 +24797,7 @@ var ts; // perform property check if property or indexer is declared in 'type' // this allows to rule out cases when both property and indexer are inherited from the base class var errorNode; - if (prop.valueDeclaration.name.kind === 134 /* ComputedPropertyName */ || prop.parent === containingType.symbol) { + if (prop.valueDeclaration.name.kind === 136 /* ComputedPropertyName */ || prop.parent === containingType.symbol) { errorNode = prop.valueDeclaration; } else if (indexDeclaration) { @@ -24289,6 +24874,7 @@ var ts; checkExportsOnMergedDeclarations(node); var symbol = getSymbolOfNode(node); var type = getDeclaredTypeOfSymbol(symbol); + var typeWithThis = getTypeWithThisArgument(type); var staticType = getTypeOfSymbol(symbol); var baseTypeNode = ts.getClassExtendsHeritageClauseElement(node); if (baseTypeNode) { @@ -24307,7 +24893,7 @@ var ts; } } } - checkTypeAssignableTo(type, baseType, node.name || node, ts.Diagnostics.Class_0_incorrectly_extends_base_class_1); + checkTypeAssignableTo(typeWithThis, getTypeWithThisArgument(baseType, type.thisType), node.name || node, ts.Diagnostics.Class_0_incorrectly_extends_base_class_1); checkTypeAssignableTo(staticType, getTypeWithoutSignatures(staticBaseType), node.name || node, ts.Diagnostics.Class_static_side_0_incorrectly_extends_base_class_static_side_1); if (!(staticBaseType.symbol && staticBaseType.symbol.flags & 32 /* Class */)) { // When the static base type is a "class-like" constructor function (but not actually a class), we verify @@ -24324,7 +24910,8 @@ var ts; } var implementedTypeNodes = ts.getClassImplementsHeritageClauseElements(node); if (implementedTypeNodes) { - ts.forEach(implementedTypeNodes, function (typeRefNode) { + for (var _b = 0; _b < implementedTypeNodes.length; _b++) { + var typeRefNode = implementedTypeNodes[_b]; if (!ts.isSupportedExpressionWithTypeArguments(typeRefNode)) { error(typeRefNode.expression, ts.Diagnostics.A_class_can_only_implement_an_identifier_Slashqualified_name_with_optional_type_arguments); } @@ -24334,14 +24921,14 @@ var ts; if (t !== unknownType) { var declaredType = (t.flags & 4096 /* Reference */) ? t.target : t; if (declaredType.flags & (1024 /* Class */ | 2048 /* Interface */)) { - checkTypeAssignableTo(type, t, node.name || node, ts.Diagnostics.Class_0_incorrectly_implements_interface_1); + checkTypeAssignableTo(typeWithThis, getTypeWithThisArgument(t, type.thisType), node.name || node, ts.Diagnostics.Class_0_incorrectly_implements_interface_1); } else { error(typeRefNode, ts.Diagnostics.A_class_may_only_implement_another_class_or_interface); } } } - }); + } } if (produceDiagnostics) { checkIndexConstraints(type); @@ -24392,7 +24979,7 @@ var ts; // If there is no declaration for the derived class (as in the case of class expressions), // then the class cannot be declared abstract. if (baseDeclarationFlags & 256 /* Abstract */ && (!derivedClassDecl || !(derivedClassDecl.flags & 256 /* Abstract */))) { - if (derivedClassDecl.kind === 184 /* ClassExpression */) { + if (derivedClassDecl.kind === 186 /* ClassExpression */) { error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1, symbolToString(baseProperty), typeToString(baseType)); } else { @@ -24440,7 +25027,7 @@ var ts; } } function isAccessor(kind) { - return kind === 143 /* GetAccessor */ || kind === 144 /* SetAccessor */; + return kind === 145 /* GetAccessor */ || kind === 146 /* SetAccessor */; } function areTypeParametersIdentical(list1, list2) { if (!list1 && !list2) { @@ -24480,7 +25067,7 @@ var ts; var ok = true; for (var _i = 0; _i < baseTypes.length; _i++) { var base = baseTypes[_i]; - var properties = getPropertiesOfObjectType(base); + var properties = getPropertiesOfObjectType(getTypeWithThisArgument(base, type.thisType)); for (var _a = 0; _a < properties.length; _a++) { var prop = properties[_a]; if (!ts.hasProperty(seen, prop.name)) { @@ -24510,7 +25097,7 @@ var ts; checkTypeNameIsReserved(node.name, ts.Diagnostics.Interface_name_cannot_be_0); checkExportsOnMergedDeclarations(node); var symbol = getSymbolOfNode(node); - var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 213 /* InterfaceDeclaration */); + var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 215 /* InterfaceDeclaration */); if (symbol.declarations.length > 1) { if (node !== firstInterfaceDecl && !areTypeParametersIdentical(firstInterfaceDecl.typeParameters, node.typeParameters)) { error(node.name, ts.Diagnostics.All_declarations_of_an_interface_must_have_identical_type_parameters); @@ -24519,19 +25106,21 @@ var ts; // Only check this symbol once if (node === firstInterfaceDecl) { var type = getDeclaredTypeOfSymbol(symbol); + var typeWithThis = getTypeWithThisArgument(type); // run subsequent checks only if first set succeeded if (checkInheritedPropertiesAreIdentical(type, node.name)) { - ts.forEach(getBaseTypes(type), function (baseType) { - checkTypeAssignableTo(type, baseType, node.name, ts.Diagnostics.Interface_0_incorrectly_extends_interface_1); - }); + for (var _i = 0, _a = getBaseTypes(type); _i < _a.length; _i++) { + var baseType = _a[_i]; + checkTypeAssignableTo(typeWithThis, getTypeWithThisArgument(baseType, type.thisType), node.name, ts.Diagnostics.Interface_0_incorrectly_extends_interface_1); + } checkIndexConstraints(type); } } // Interfaces cannot merge with non-ambient classes. if (symbol && symbol.declarations) { - for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { - var declaration = _a[_i]; - if (declaration.kind === 212 /* ClassDeclaration */ && !ts.isInAmbientContext(declaration)) { + for (var _b = 0, _c = symbol.declarations; _b < _c.length; _b++) { + var declaration = _c[_b]; + if (declaration.kind === 214 /* ClassDeclaration */ && !ts.isInAmbientContext(declaration)) { error(node, ts.Diagnostics.Only_an_ambient_class_can_be_merged_with_an_interface); break; } @@ -24560,24 +25149,38 @@ var ts; if (!(nodeLinks.flags & 8192 /* EnumValuesComputed */)) { var enumSymbol = getSymbolOfNode(node); var enumType = getDeclaredTypeOfSymbol(enumSymbol); - var autoValue = 0; + var autoValue = 0; // set to undefined when enum member is non-constant var ambient = ts.isInAmbientContext(node); var enumIsConst = ts.isConst(node); - ts.forEach(node.members, function (member) { - if (member.name.kind !== 134 /* ComputedPropertyName */ && isNumericLiteralName(member.name.text)) { + for (var _i = 0, _a = node.members; _i < _a.length; _i++) { + var member = _a[_i]; + if (member.name.kind === 136 /* ComputedPropertyName */) { + error(member.name, ts.Diagnostics.Computed_property_names_are_not_allowed_in_enums); + } + else if (isNumericLiteralName(member.name.text)) { error(member.name, ts.Diagnostics.An_enum_member_cannot_have_a_numeric_name); } + var previousEnumMemberIsNonConstant = autoValue === undefined; var initializer = member.initializer; if (initializer) { autoValue = computeConstantValueForEnumMemberInitializer(initializer, enumType, enumIsConst, ambient); } else if (ambient && !enumIsConst) { + // In ambient enum declarations that specify no const modifier, enum member declarations + // that omit a value are considered computed members (as opposed to having auto-incremented values assigned). autoValue = undefined; } + else if (previousEnumMemberIsNonConstant) { + // If the member declaration specifies no value, the member is considered a constant enum member. + // If the member is the first member in the enum declaration, it is assigned the value zero. + // Otherwise, it is assigned the value of the immediately preceding member plus one, + // and an error occurs if the immediately preceding member is not a constant enum member + error(member.name, ts.Diagnostics.Enum_member_must_have_initializer); + } if (autoValue !== undefined) { getNodeLinks(member).enumMemberValue = autoValue++; } - }); + } nodeLinks.flags |= 8192 /* EnumValuesComputed */; } function computeConstantValueForEnumMemberInitializer(initializer, enumType, enumIsConst, ambient) { @@ -24590,11 +25193,11 @@ var ts; if (enumIsConst) { error(initializer, ts.Diagnostics.In_const_enum_declarations_member_initializer_must_be_constant_expression); } - else if (!ambient) { + else if (ambient) { + error(initializer, ts.Diagnostics.In_ambient_enum_declarations_member_initializer_must_be_constant_expression); + } + else { // Only here do we need to check that the initializer is assignable to the enum type. - // If it is a constant value (not undefined), it is syntactically constrained to be a number. - // Also, we do not need to check this for ambients because there is already - // a syntax error if it is not a constant. checkTypeAssignableTo(checkExpression(initializer), enumType, initializer, /*headMessage*/ undefined); } } @@ -24610,7 +25213,7 @@ var ts; return value; function evalConstant(e) { switch (e.kind) { - case 177 /* PrefixUnaryExpression */: + case 179 /* PrefixUnaryExpression */: var value_1 = evalConstant(e.operand); if (value_1 === undefined) { return undefined; @@ -24618,10 +25221,10 @@ var ts; switch (e.operator) { case 35 /* PlusToken */: return value_1; case 36 /* MinusToken */: return -value_1; - case 49 /* TildeToken */: return ~value_1; + case 50 /* TildeToken */: return ~value_1; } return undefined; - case 179 /* BinaryExpression */: + case 181 /* BinaryExpression */: var left = evalConstant(e.left); if (left === undefined) { return undefined; @@ -24631,31 +25234,31 @@ var ts; return undefined; } switch (e.operatorToken.kind) { - case 46 /* BarToken */: return left | right; - case 45 /* AmpersandToken */: return left & right; - case 43 /* GreaterThanGreaterThanToken */: return left >> right; - case 44 /* GreaterThanGreaterThanGreaterThanToken */: return left >>> right; - case 42 /* LessThanLessThanToken */: return left << right; - case 47 /* CaretToken */: return left ^ right; + case 47 /* BarToken */: return left | right; + case 46 /* AmpersandToken */: return left & right; + case 44 /* GreaterThanGreaterThanToken */: return left >> right; + case 45 /* GreaterThanGreaterThanGreaterThanToken */: return left >>> right; + case 43 /* LessThanLessThanToken */: return left << right; + case 48 /* CaretToken */: return left ^ right; case 37 /* AsteriskToken */: return left * right; - case 38 /* SlashToken */: return left / right; + case 39 /* SlashToken */: return left / right; case 35 /* PlusToken */: return left + right; case 36 /* MinusToken */: return left - right; - case 39 /* PercentToken */: return left % right; + case 40 /* PercentToken */: return left % right; } return undefined; case 8 /* NumericLiteral */: return +e.text; - case 170 /* ParenthesizedExpression */: + case 172 /* ParenthesizedExpression */: return evalConstant(e.expression); - case 67 /* Identifier */: - case 165 /* ElementAccessExpression */: - case 164 /* PropertyAccessExpression */: + case 69 /* Identifier */: + case 167 /* ElementAccessExpression */: + case 166 /* PropertyAccessExpression */: var member = initializer.parent; var currentType = getTypeOfSymbol(getSymbolOfNode(member.parent)); var enumType_1; var propertyName; - if (e.kind === 67 /* Identifier */) { + if (e.kind === 69 /* Identifier */) { // unqualified names can refer to member that reside in different declaration of the enum so just doing name resolution won't work. // instead pick current enum type and later try to fetch member from the type enumType_1 = currentType; @@ -24663,7 +25266,7 @@ var ts; } else { var expression; - if (e.kind === 165 /* ElementAccessExpression */) { + if (e.kind === 167 /* ElementAccessExpression */) { if (e.argumentExpression === undefined || e.argumentExpression.kind !== 9 /* StringLiteral */) { return undefined; @@ -24678,10 +25281,10 @@ var ts; // expression part in ElementAccess\PropertyAccess should be either identifier or dottedName var current = expression; while (current) { - if (current.kind === 67 /* Identifier */) { + if (current.kind === 69 /* Identifier */) { break; } - else if (current.kind === 164 /* PropertyAccessExpression */) { + else if (current.kind === 166 /* PropertyAccessExpression */) { current = current.expression; } else { @@ -24707,7 +25310,7 @@ var ts; return undefined; } // illegal case: forward reference - if (!isDefinedBefore(propertyDecl, member)) { + if (!isBlockScopedNameDeclaredBeforeUse(propertyDecl, member)) { reportError = false; error(e, ts.Diagnostics.A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_enums); return undefined; @@ -24722,7 +25325,7 @@ var ts; return; } // Grammar checking - checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarEnumDeclaration(node); + checkGrammarDecorators(node) || checkGrammarModifiers(node); checkTypeNameIsReserved(node.name, ts.Diagnostics.Enum_name_cannot_be_0); checkCollisionWithCapturedThisVariable(node, node.name); checkCollisionWithRequireExportsInGeneratedCode(node, node.name); @@ -24752,7 +25355,7 @@ var ts; var seenEnumMissingInitialInitializer = false; ts.forEach(enumSymbol.declarations, function (declaration) { // return true if we hit a violation of the rule, false otherwise - if (declaration.kind !== 215 /* EnumDeclaration */) { + if (declaration.kind !== 217 /* EnumDeclaration */) { return false; } var enumDeclaration = declaration; @@ -24775,8 +25378,8 @@ var ts; var declarations = symbol.declarations; for (var _i = 0; _i < declarations.length; _i++) { var declaration = declarations[_i]; - if ((declaration.kind === 212 /* ClassDeclaration */ || - (declaration.kind === 211 /* FunctionDeclaration */ && ts.nodeIsPresent(declaration.body))) && + if ((declaration.kind === 214 /* ClassDeclaration */ || + (declaration.kind === 213 /* FunctionDeclaration */ && ts.nodeIsPresent(declaration.body))) && !ts.isInAmbientContext(declaration)) { return declaration; } @@ -24832,7 +25435,7 @@ var ts; } // if the module merges with a class declaration in the same lexical scope, // we need to track this to ensure the correct emit. - var mergedClass = ts.getDeclarationOfKind(symbol, 212 /* ClassDeclaration */); + var mergedClass = ts.getDeclarationOfKind(symbol, 214 /* ClassDeclaration */); if (mergedClass && inSameLexicalScope(node, mergedClass)) { getNodeLinks(node).flags |= 32768 /* LexicalModuleMergesWithClass */; @@ -24841,9 +25444,9 @@ var ts; // Checks for ambient external modules. if (isAmbientExternalModule) { if (!isGlobalSourceFile(node.parent)) { - error(node.name, ts.Diagnostics.Ambient_modules_cannot_be_nested_in_other_modules); + error(node.name, ts.Diagnostics.Ambient_modules_cannot_be_nested_in_other_modules_or_namespaces); } - if (isExternalModuleNameRelative(node.name.text)) { + if (ts.isExternalModuleNameRelative(node.name.text)) { error(node.name, ts.Diagnostics.Ambient_module_declaration_cannot_specify_relative_module_name); } } @@ -24852,17 +25455,17 @@ var ts; } function getFirstIdentifier(node) { while (true) { - if (node.kind === 133 /* QualifiedName */) { + if (node.kind === 135 /* QualifiedName */) { node = node.left; } - else if (node.kind === 164 /* PropertyAccessExpression */) { + else if (node.kind === 166 /* PropertyAccessExpression */) { node = node.expression; } else { break; } } - ts.Debug.assert(node.kind === 67 /* Identifier */); + ts.Debug.assert(node.kind === 69 /* Identifier */); return node; } function checkExternalImportOrExportDeclaration(node) { @@ -24871,14 +25474,14 @@ var ts; error(moduleName, ts.Diagnostics.String_literal_expected); return false; } - var inAmbientExternalModule = node.parent.kind === 217 /* ModuleBlock */ && node.parent.parent.name.kind === 9 /* StringLiteral */; - if (node.parent.kind !== 246 /* SourceFile */ && !inAmbientExternalModule) { - error(moduleName, node.kind === 226 /* ExportDeclaration */ ? + var inAmbientExternalModule = node.parent.kind === 219 /* ModuleBlock */ && node.parent.parent.name.kind === 9 /* StringLiteral */; + if (node.parent.kind !== 248 /* SourceFile */ && !inAmbientExternalModule) { + error(moduleName, node.kind === 228 /* ExportDeclaration */ ? ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace : ts.Diagnostics.Import_declarations_in_a_namespace_cannot_reference_a_module); return false; } - if (inAmbientExternalModule && isExternalModuleNameRelative(moduleName.text)) { + if (inAmbientExternalModule && ts.isExternalModuleNameRelative(moduleName.text)) { // TypeScript 1.0 spec (April 2013): 12.1.6 // An ExternalImportDeclaration in an AmbientExternalModuleDeclaration may reference // other external modules only through top - level external module names. @@ -24896,7 +25499,7 @@ var ts; (symbol.flags & 793056 /* Type */ ? 793056 /* Type */ : 0) | (symbol.flags & 1536 /* Namespace */ ? 1536 /* Namespace */ : 0); if (target.flags & excludedMeanings) { - var message = node.kind === 228 /* ExportSpecifier */ ? + var message = node.kind === 230 /* ExportSpecifier */ ? ts.Diagnostics.Export_declaration_conflicts_with_exported_declaration_of_0 : ts.Diagnostics.Import_declaration_conflicts_with_local_declaration_of_0; error(node, message, symbolToString(symbol)); @@ -24923,7 +25526,7 @@ var ts; checkImportBinding(importClause); } if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 222 /* NamespaceImport */) { + if (importClause.namedBindings.kind === 224 /* NamespaceImport */) { checkImportBinding(importClause.namedBindings); } else { @@ -24960,9 +25563,9 @@ var ts; } } else { - if (languageVersion >= 2 /* ES6 */ && !ts.isInAmbientContext(node)) { + if (modulekind === 5 /* ES6 */ && !ts.isInAmbientContext(node)) { // Import equals declaration is deprecated in es6 or above - grammarErrorOnNode(node, ts.Diagnostics.Import_assignment_cannot_be_used_when_targeting_ECMAScript_6_or_higher_Consider_using_import_Asterisk_as_ns_from_mod_import_a_from_mod_or_import_d_from_mod_instead); + grammarErrorOnNode(node, ts.Diagnostics.Import_assignment_cannot_be_used_when_targeting_ECMAScript_6_modules_Consider_using_import_Asterisk_as_ns_from_mod_import_a_from_mod_import_d_from_mod_or_another_module_format_instead); } } } @@ -24980,8 +25583,8 @@ var ts; // export { x, y } // export { x, y } from "foo" ts.forEach(node.exportClause.elements, checkExportSpecifier); - var inAmbientExternalModule = node.parent.kind === 217 /* ModuleBlock */ && node.parent.parent.name.kind === 9 /* StringLiteral */; - if (node.parent.kind !== 246 /* SourceFile */ && !inAmbientExternalModule) { + var inAmbientExternalModule = node.parent.kind === 219 /* ModuleBlock */ && node.parent.parent.name.kind === 9 /* StringLiteral */; + if (node.parent.kind !== 248 /* SourceFile */ && !inAmbientExternalModule) { error(node, ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace); } } @@ -24995,7 +25598,7 @@ var ts; } } function checkGrammarModuleElementContext(node, errorMessage) { - if (node.parent.kind !== 246 /* SourceFile */ && node.parent.kind !== 217 /* ModuleBlock */ && node.parent.kind !== 216 /* ModuleDeclaration */) { + if (node.parent.kind !== 248 /* SourceFile */ && node.parent.kind !== 219 /* ModuleBlock */ && node.parent.kind !== 218 /* ModuleDeclaration */) { return grammarErrorOnFirstToken(node, errorMessage); } } @@ -25010,8 +25613,8 @@ var ts; // If we hit an export assignment in an illegal context, just bail out to avoid cascading errors. return; } - var container = node.parent.kind === 246 /* SourceFile */ ? node.parent : node.parent.parent; - if (container.kind === 216 /* ModuleDeclaration */ && container.name.kind === 67 /* Identifier */) { + var container = node.parent.kind === 248 /* SourceFile */ ? node.parent : node.parent.parent; + if (container.kind === 218 /* ModuleDeclaration */ && container.name.kind === 69 /* Identifier */) { error(node, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_namespace); return; } @@ -25019,7 +25622,7 @@ var ts; if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && (node.flags & 2035 /* Modifier */)) { grammarErrorOnFirstToken(node, ts.Diagnostics.An_export_assignment_cannot_have_modifiers); } - if (node.expression.kind === 67 /* Identifier */) { + if (node.expression.kind === 69 /* Identifier */) { markExportAsReferenced(node); } else { @@ -25027,21 +25630,21 @@ var ts; } checkExternalModuleExports(container); if (node.isExportEquals && !ts.isInAmbientContext(node)) { - if (languageVersion >= 2 /* ES6 */) { - // export assignment is deprecated in es6 or above - grammarErrorOnNode(node, ts.Diagnostics.Export_assignment_cannot_be_used_when_targeting_ECMAScript_6_or_higher_Consider_using_export_default_instead); + if (modulekind === 5 /* ES6 */) { + // export assignment is not supported in es6 modules + grammarErrorOnNode(node, ts.Diagnostics.Export_assignment_cannot_be_used_when_targeting_ECMAScript_6_modules_Consider_using_export_default_or_another_module_format_instead); } - else if (compilerOptions.module === 4 /* System */) { + else if (modulekind === 4 /* System */) { // system modules does not support export assignment grammarErrorOnNode(node, ts.Diagnostics.Export_assignment_is_not_supported_when_module_flag_is_system); } } } function getModuleStatements(node) { - if (node.kind === 246 /* SourceFile */) { + if (node.kind === 248 /* SourceFile */) { return node.statements; } - if (node.kind === 216 /* ModuleDeclaration */ && node.body.kind === 217 /* ModuleBlock */) { + if (node.kind === 218 /* ModuleDeclaration */ && node.body.kind === 219 /* ModuleBlock */) { return node.body.statements; } return emptyArray; @@ -25080,118 +25683,118 @@ var ts; // Only bother checking on a few construct kinds. We don't want to be excessivly // hitting the cancellation token on every node we check. switch (kind) { - case 216 /* ModuleDeclaration */: - case 212 /* ClassDeclaration */: - case 213 /* InterfaceDeclaration */: - case 211 /* FunctionDeclaration */: + case 218 /* ModuleDeclaration */: + case 214 /* ClassDeclaration */: + case 215 /* InterfaceDeclaration */: + case 213 /* FunctionDeclaration */: cancellationToken.throwIfCancellationRequested(); } } switch (kind) { - case 135 /* TypeParameter */: + case 137 /* TypeParameter */: return checkTypeParameter(node); - case 136 /* Parameter */: + case 138 /* Parameter */: return checkParameter(node); - case 139 /* PropertyDeclaration */: - case 138 /* PropertySignature */: + case 141 /* PropertyDeclaration */: + case 140 /* PropertySignature */: return checkPropertyDeclaration(node); - case 150 /* FunctionType */: - case 151 /* ConstructorType */: - case 145 /* CallSignature */: - case 146 /* ConstructSignature */: + case 152 /* FunctionType */: + case 153 /* ConstructorType */: + case 147 /* CallSignature */: + case 148 /* ConstructSignature */: return checkSignatureDeclaration(node); - case 147 /* IndexSignature */: + case 149 /* IndexSignature */: return checkSignatureDeclaration(node); - case 141 /* MethodDeclaration */: - case 140 /* MethodSignature */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: return checkMethodDeclaration(node); - case 142 /* Constructor */: + case 144 /* Constructor */: return checkConstructorDeclaration(node); - case 143 /* GetAccessor */: - case 144 /* SetAccessor */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: return checkAccessorDeclaration(node); - case 149 /* TypeReference */: + case 151 /* TypeReference */: return checkTypeReferenceNode(node); - case 148 /* TypePredicate */: + case 150 /* TypePredicate */: return checkTypePredicate(node); - case 152 /* TypeQuery */: + case 154 /* TypeQuery */: return checkTypeQuery(node); - case 153 /* TypeLiteral */: + case 155 /* TypeLiteral */: return checkTypeLiteral(node); - case 154 /* ArrayType */: + case 156 /* ArrayType */: return checkArrayType(node); - case 155 /* TupleType */: + case 157 /* TupleType */: return checkTupleType(node); - case 156 /* UnionType */: - case 157 /* IntersectionType */: + case 158 /* UnionType */: + case 159 /* IntersectionType */: return checkUnionOrIntersectionType(node); - case 158 /* ParenthesizedType */: + case 160 /* ParenthesizedType */: return checkSourceElement(node.type); - case 211 /* FunctionDeclaration */: + case 213 /* FunctionDeclaration */: return checkFunctionDeclaration(node); - case 190 /* Block */: - case 217 /* ModuleBlock */: + case 192 /* Block */: + case 219 /* ModuleBlock */: return checkBlock(node); - case 191 /* VariableStatement */: + case 193 /* VariableStatement */: return checkVariableStatement(node); - case 193 /* ExpressionStatement */: + case 195 /* ExpressionStatement */: return checkExpressionStatement(node); - case 194 /* IfStatement */: + case 196 /* IfStatement */: return checkIfStatement(node); - case 195 /* DoStatement */: + case 197 /* DoStatement */: return checkDoStatement(node); - case 196 /* WhileStatement */: + case 198 /* WhileStatement */: return checkWhileStatement(node); - case 197 /* ForStatement */: + case 199 /* ForStatement */: return checkForStatement(node); - case 198 /* ForInStatement */: + case 200 /* ForInStatement */: return checkForInStatement(node); - case 199 /* ForOfStatement */: + case 201 /* ForOfStatement */: return checkForOfStatement(node); - case 200 /* ContinueStatement */: - case 201 /* BreakStatement */: + case 202 /* ContinueStatement */: + case 203 /* BreakStatement */: return checkBreakOrContinueStatement(node); - case 202 /* ReturnStatement */: + case 204 /* ReturnStatement */: return checkReturnStatement(node); - case 203 /* WithStatement */: + case 205 /* WithStatement */: return checkWithStatement(node); - case 204 /* SwitchStatement */: + case 206 /* SwitchStatement */: return checkSwitchStatement(node); - case 205 /* LabeledStatement */: + case 207 /* LabeledStatement */: return checkLabeledStatement(node); - case 206 /* ThrowStatement */: + case 208 /* ThrowStatement */: return checkThrowStatement(node); - case 207 /* TryStatement */: + case 209 /* TryStatement */: return checkTryStatement(node); - case 209 /* VariableDeclaration */: + case 211 /* VariableDeclaration */: return checkVariableDeclaration(node); - case 161 /* BindingElement */: + case 163 /* BindingElement */: return checkBindingElement(node); - case 212 /* ClassDeclaration */: + case 214 /* ClassDeclaration */: return checkClassDeclaration(node); - case 213 /* InterfaceDeclaration */: + case 215 /* InterfaceDeclaration */: return checkInterfaceDeclaration(node); - case 214 /* TypeAliasDeclaration */: + case 216 /* TypeAliasDeclaration */: return checkTypeAliasDeclaration(node); - case 215 /* EnumDeclaration */: + case 217 /* EnumDeclaration */: return checkEnumDeclaration(node); - case 216 /* ModuleDeclaration */: + case 218 /* ModuleDeclaration */: return checkModuleDeclaration(node); - case 220 /* ImportDeclaration */: + case 222 /* ImportDeclaration */: return checkImportDeclaration(node); - case 219 /* ImportEqualsDeclaration */: + case 221 /* ImportEqualsDeclaration */: return checkImportEqualsDeclaration(node); - case 226 /* ExportDeclaration */: + case 228 /* ExportDeclaration */: return checkExportDeclaration(node); - case 225 /* ExportAssignment */: + case 227 /* ExportAssignment */: return checkExportAssignment(node); - case 192 /* EmptyStatement */: + case 194 /* EmptyStatement */: checkGrammarStatementInAmbientContext(node); return; - case 208 /* DebuggerStatement */: + case 210 /* DebuggerStatement */: checkGrammarStatementInAmbientContext(node); return; - case 229 /* MissingDeclaration */: + case 231 /* MissingDeclaration */: return checkMissingDeclaration(node); } } @@ -25206,97 +25809,98 @@ var ts; // Delaying the type check of the body ensures foo has been assigned a type. function checkFunctionAndClassExpressionBodies(node) { switch (node.kind) { - case 171 /* FunctionExpression */: - case 172 /* ArrowFunction */: + case 173 /* FunctionExpression */: + case 174 /* ArrowFunction */: ts.forEach(node.parameters, checkFunctionAndClassExpressionBodies); checkFunctionExpressionOrObjectLiteralMethodBody(node); break; - case 184 /* ClassExpression */: + case 186 /* ClassExpression */: ts.forEach(node.members, checkSourceElement); + ts.forEachChild(node, checkFunctionAndClassExpressionBodies); break; - case 141 /* MethodDeclaration */: - case 140 /* MethodSignature */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: ts.forEach(node.decorators, checkFunctionAndClassExpressionBodies); ts.forEach(node.parameters, checkFunctionAndClassExpressionBodies); if (ts.isObjectLiteralMethod(node)) { checkFunctionExpressionOrObjectLiteralMethodBody(node); } break; - case 142 /* Constructor */: - case 143 /* GetAccessor */: - case 144 /* SetAccessor */: - case 211 /* FunctionDeclaration */: + case 144 /* Constructor */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: + case 213 /* FunctionDeclaration */: ts.forEach(node.parameters, checkFunctionAndClassExpressionBodies); break; - case 203 /* WithStatement */: + case 205 /* WithStatement */: checkFunctionAndClassExpressionBodies(node.expression); break; - case 137 /* Decorator */: - case 136 /* Parameter */: - case 139 /* PropertyDeclaration */: - case 138 /* PropertySignature */: - case 159 /* ObjectBindingPattern */: - case 160 /* ArrayBindingPattern */: - case 161 /* BindingElement */: - case 162 /* ArrayLiteralExpression */: - case 163 /* ObjectLiteralExpression */: - case 243 /* PropertyAssignment */: - case 164 /* PropertyAccessExpression */: - case 165 /* ElementAccessExpression */: - case 166 /* CallExpression */: - case 167 /* NewExpression */: - case 168 /* TaggedTemplateExpression */: - case 181 /* TemplateExpression */: - case 188 /* TemplateSpan */: - case 169 /* TypeAssertionExpression */: - case 187 /* AsExpression */: - case 170 /* ParenthesizedExpression */: - case 174 /* TypeOfExpression */: - case 175 /* VoidExpression */: - case 176 /* AwaitExpression */: - case 173 /* DeleteExpression */: - case 177 /* PrefixUnaryExpression */: - case 178 /* PostfixUnaryExpression */: - case 179 /* BinaryExpression */: - case 180 /* ConditionalExpression */: - case 183 /* SpreadElementExpression */: - case 182 /* YieldExpression */: - case 190 /* Block */: - case 217 /* ModuleBlock */: - case 191 /* VariableStatement */: - case 193 /* ExpressionStatement */: - case 194 /* IfStatement */: - case 195 /* DoStatement */: - case 196 /* WhileStatement */: - case 197 /* ForStatement */: - case 198 /* ForInStatement */: - case 199 /* ForOfStatement */: - case 200 /* ContinueStatement */: - case 201 /* BreakStatement */: - case 202 /* ReturnStatement */: - case 204 /* SwitchStatement */: - case 218 /* CaseBlock */: - case 239 /* CaseClause */: - case 240 /* DefaultClause */: - case 205 /* LabeledStatement */: - case 206 /* ThrowStatement */: - case 207 /* TryStatement */: - case 242 /* CatchClause */: - case 209 /* VariableDeclaration */: - case 210 /* VariableDeclarationList */: - case 212 /* ClassDeclaration */: - case 241 /* HeritageClause */: - case 186 /* ExpressionWithTypeArguments */: - case 215 /* EnumDeclaration */: - case 245 /* EnumMember */: - case 225 /* ExportAssignment */: - case 246 /* SourceFile */: - case 238 /* JsxExpression */: - case 231 /* JsxElement */: - case 232 /* JsxSelfClosingElement */: - case 236 /* JsxAttribute */: - case 237 /* JsxSpreadAttribute */: - case 233 /* JsxOpeningElement */: + case 139 /* Decorator */: + case 138 /* Parameter */: + case 141 /* PropertyDeclaration */: + case 140 /* PropertySignature */: + case 161 /* ObjectBindingPattern */: + case 162 /* ArrayBindingPattern */: + case 163 /* BindingElement */: + case 164 /* ArrayLiteralExpression */: + case 165 /* ObjectLiteralExpression */: + case 245 /* PropertyAssignment */: + case 166 /* PropertyAccessExpression */: + case 167 /* ElementAccessExpression */: + case 168 /* CallExpression */: + case 169 /* NewExpression */: + case 170 /* TaggedTemplateExpression */: + case 183 /* TemplateExpression */: + case 190 /* TemplateSpan */: + case 171 /* TypeAssertionExpression */: + case 189 /* AsExpression */: + case 172 /* ParenthesizedExpression */: + case 176 /* TypeOfExpression */: + case 177 /* VoidExpression */: + case 178 /* AwaitExpression */: + case 175 /* DeleteExpression */: + case 179 /* PrefixUnaryExpression */: + case 180 /* PostfixUnaryExpression */: + case 181 /* BinaryExpression */: + case 182 /* ConditionalExpression */: + case 185 /* SpreadElementExpression */: + case 184 /* YieldExpression */: + case 192 /* Block */: + case 219 /* ModuleBlock */: + case 193 /* VariableStatement */: + case 195 /* ExpressionStatement */: + case 196 /* IfStatement */: + case 197 /* DoStatement */: + case 198 /* WhileStatement */: + case 199 /* ForStatement */: + case 200 /* ForInStatement */: + case 201 /* ForOfStatement */: + case 202 /* ContinueStatement */: + case 203 /* BreakStatement */: + case 204 /* ReturnStatement */: + case 206 /* SwitchStatement */: + case 220 /* CaseBlock */: + case 241 /* CaseClause */: + case 242 /* DefaultClause */: + case 207 /* LabeledStatement */: + case 208 /* ThrowStatement */: + case 209 /* TryStatement */: + case 244 /* CatchClause */: + case 211 /* VariableDeclaration */: + case 212 /* VariableDeclarationList */: + case 214 /* ClassDeclaration */: + case 243 /* HeritageClause */: + case 188 /* ExpressionWithTypeArguments */: + case 217 /* EnumDeclaration */: + case 247 /* EnumMember */: + case 227 /* ExportAssignment */: + case 248 /* SourceFile */: + case 240 /* JsxExpression */: + case 233 /* JsxElement */: + case 234 /* JsxSelfClosingElement */: + case 238 /* JsxAttribute */: + case 239 /* JsxSpreadAttribute */: + case 235 /* JsxOpeningElement */: ts.forEachChild(node, checkFunctionAndClassExpressionBodies); break; } @@ -25323,7 +25927,7 @@ var ts; potentialThisCollisions.length = 0; ts.forEach(node.statements, checkSourceElement); checkFunctionAndClassExpressionBodies(node); - if (ts.isExternalModule(node)) { + if (ts.isExternalOrCommonJsModule(node)) { checkExternalModuleExports(node); } if (potentialThisCollisions.length) { @@ -25382,7 +25986,7 @@ var ts; function isInsideWithStatementBody(node) { if (node) { while (node.parent) { - if (node.parent.kind === 203 /* WithStatement */ && node.parent.statement === node) { + if (node.parent.kind === 205 /* WithStatement */ && node.parent.statement === node) { return true; } node = node.parent; @@ -25405,34 +26009,34 @@ var ts; copySymbols(location.locals, meaning); } switch (location.kind) { - case 246 /* SourceFile */: - if (!ts.isExternalModule(location)) { + case 248 /* SourceFile */: + if (!ts.isExternalOrCommonJsModule(location)) { break; } - case 216 /* ModuleDeclaration */: + case 218 /* ModuleDeclaration */: copySymbols(getSymbolOfNode(location).exports, meaning & 8914931 /* ModuleMember */); break; - case 215 /* EnumDeclaration */: + case 217 /* EnumDeclaration */: copySymbols(getSymbolOfNode(location).exports, meaning & 8 /* EnumMember */); break; - case 184 /* ClassExpression */: + case 186 /* ClassExpression */: var className = location.name; if (className) { copySymbol(location.symbol, meaning); } // fall through; this fall-through is necessary because we would like to handle // type parameter inside class expression similar to how we handle it in classDeclaration and interface Declaration - case 212 /* ClassDeclaration */: - case 213 /* InterfaceDeclaration */: + case 214 /* ClassDeclaration */: + case 215 /* InterfaceDeclaration */: // If we didn't come from static member of class or interface, - // add the type parameters into the symbol table + // add the type parameters into the symbol table // (type parameters of classDeclaration/classExpression and interface are in member property of the symbol. // Note: that the memberFlags come from previous iteration. if (!(memberFlags & 128 /* Static */)) { copySymbols(getSymbolOfNode(location).members, meaning & 793056 /* Type */); } break; - case 171 /* FunctionExpression */: + case 173 /* FunctionExpression */: var funcName = location.name; if (funcName) { copySymbol(location.symbol, meaning); @@ -25475,43 +26079,43 @@ var ts; } } function isTypeDeclarationName(name) { - return name.kind === 67 /* Identifier */ && + return name.kind === 69 /* Identifier */ && isTypeDeclaration(name.parent) && name.parent.name === name; } function isTypeDeclaration(node) { switch (node.kind) { - case 135 /* TypeParameter */: - case 212 /* ClassDeclaration */: - case 213 /* InterfaceDeclaration */: - case 214 /* TypeAliasDeclaration */: - case 215 /* EnumDeclaration */: + case 137 /* TypeParameter */: + case 214 /* ClassDeclaration */: + case 215 /* InterfaceDeclaration */: + case 216 /* TypeAliasDeclaration */: + case 217 /* EnumDeclaration */: return true; } } // True if the given identifier is part of a type reference function isTypeReferenceIdentifier(entityName) { var node = entityName; - while (node.parent && node.parent.kind === 133 /* QualifiedName */) { + while (node.parent && node.parent.kind === 135 /* QualifiedName */) { node = node.parent; } - return node.parent && node.parent.kind === 149 /* TypeReference */; + return node.parent && node.parent.kind === 151 /* TypeReference */; } function isHeritageClauseElementIdentifier(entityName) { var node = entityName; - while (node.parent && node.parent.kind === 164 /* PropertyAccessExpression */) { + while (node.parent && node.parent.kind === 166 /* PropertyAccessExpression */) { node = node.parent; } - return node.parent && node.parent.kind === 186 /* ExpressionWithTypeArguments */; + return node.parent && node.parent.kind === 188 /* ExpressionWithTypeArguments */; } function getLeftSideOfImportEqualsOrExportAssignment(nodeOnRightSide) { - while (nodeOnRightSide.parent.kind === 133 /* QualifiedName */) { + while (nodeOnRightSide.parent.kind === 135 /* QualifiedName */) { nodeOnRightSide = nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 219 /* ImportEqualsDeclaration */) { + if (nodeOnRightSide.parent.kind === 221 /* ImportEqualsDeclaration */) { return nodeOnRightSide.parent.moduleReference === nodeOnRightSide && nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 225 /* ExportAssignment */) { + if (nodeOnRightSide.parent.kind === 227 /* ExportAssignment */) { return nodeOnRightSide.parent.expression === nodeOnRightSide && nodeOnRightSide.parent; } return undefined; @@ -25523,11 +26127,11 @@ var ts; if (ts.isDeclarationName(entityName)) { return getSymbolOfNode(entityName.parent); } - if (entityName.parent.kind === 225 /* ExportAssignment */) { + if (entityName.parent.kind === 227 /* ExportAssignment */) { return resolveEntityName(entityName, /*all meanings*/ 107455 /* Value */ | 793056 /* Type */ | 1536 /* Namespace */ | 8388608 /* Alias */); } - if (entityName.kind !== 164 /* PropertyAccessExpression */) { + if (entityName.kind !== 166 /* PropertyAccessExpression */) { if (isInRightSideOfImportOrExportAssignment(entityName)) { // Since we already checked for ExportAssignment, this really could only be an Import return getSymbolOfPartOfRightHandSideOfImportEquals(entityName); @@ -25537,13 +26141,24 @@ var ts; entityName = entityName.parent; } if (isHeritageClauseElementIdentifier(entityName)) { - var meaning = entityName.parent.kind === 186 /* ExpressionWithTypeArguments */ ? 793056 /* Type */ : 1536 /* Namespace */; + var meaning = 0 /* None */; + // In an interface or class, we're definitely interested in a type. + if (entityName.parent.kind === 188 /* ExpressionWithTypeArguments */) { + meaning = 793056 /* Type */; + // In a class 'extends' clause we are also looking for a value. + if (ts.isExpressionWithTypeArgumentsInClassExtendsClause(entityName.parent)) { + meaning |= 107455 /* Value */; + } + } + else { + meaning = 1536 /* Namespace */; + } meaning |= 8388608 /* Alias */; return resolveEntityName(entityName, meaning); } - else if ((entityName.parent.kind === 233 /* JsxOpeningElement */) || - (entityName.parent.kind === 232 /* JsxSelfClosingElement */) || - (entityName.parent.kind === 235 /* JsxClosingElement */)) { + else if ((entityName.parent.kind === 235 /* JsxOpeningElement */) || + (entityName.parent.kind === 234 /* JsxSelfClosingElement */) || + (entityName.parent.kind === 237 /* JsxClosingElement */)) { return getJsxElementTagSymbol(entityName.parent); } else if (ts.isExpression(entityName)) { @@ -25551,20 +26166,20 @@ var ts; // Missing entity name. return undefined; } - if (entityName.kind === 67 /* Identifier */) { + if (entityName.kind === 69 /* Identifier */) { // Include aliases in the meaning, this ensures that we do not follow aliases to where they point and instead // return the alias symbol. var meaning = 107455 /* Value */ | 8388608 /* Alias */; return resolveEntityName(entityName, meaning); } - else if (entityName.kind === 164 /* PropertyAccessExpression */) { + else if (entityName.kind === 166 /* PropertyAccessExpression */) { var symbol = getNodeLinks(entityName).resolvedSymbol; if (!symbol) { checkPropertyAccessExpression(entityName); } return getNodeLinks(entityName).resolvedSymbol; } - else if (entityName.kind === 133 /* QualifiedName */) { + else if (entityName.kind === 135 /* QualifiedName */) { var symbol = getNodeLinks(entityName).resolvedSymbol; if (!symbol) { checkQualifiedName(entityName); @@ -25573,16 +26188,16 @@ var ts; } } else if (isTypeReferenceIdentifier(entityName)) { - var meaning = entityName.parent.kind === 149 /* TypeReference */ ? 793056 /* Type */ : 1536 /* Namespace */; + var meaning = entityName.parent.kind === 151 /* TypeReference */ ? 793056 /* Type */ : 1536 /* Namespace */; // Include aliases in the meaning, this ensures that we do not follow aliases to where they point and instead // return the alias symbol. meaning |= 8388608 /* Alias */; return resolveEntityName(entityName, meaning); } - else if (entityName.parent.kind === 236 /* JsxAttribute */) { + else if (entityName.parent.kind === 238 /* JsxAttribute */) { return getJsxAttributePropertySymbol(entityName.parent); } - if (entityName.parent.kind === 148 /* TypePredicate */) { + if (entityName.parent.kind === 150 /* TypePredicate */) { return resolveEntityName(entityName, /*meaning*/ 1 /* FunctionScopedVariable */); } // Do we want to return undefined here? @@ -25597,14 +26212,14 @@ var ts; // This is a declaration, call getSymbolOfNode return getSymbolOfNode(node.parent); } - if (node.kind === 67 /* Identifier */) { + if (node.kind === 69 /* Identifier */) { if (isInRightSideOfImportOrExportAssignment(node)) { - return node.parent.kind === 225 /* ExportAssignment */ + return node.parent.kind === 227 /* ExportAssignment */ ? getSymbolOfEntityNameOrPropertyAccessExpression(node) : getSymbolOfPartOfRightHandSideOfImportEquals(node); } - else if (node.parent.kind === 161 /* BindingElement */ && - node.parent.parent.kind === 159 /* ObjectBindingPattern */ && + else if (node.parent.kind === 163 /* BindingElement */ && + node.parent.parent.kind === 161 /* ObjectBindingPattern */ && node === node.parent.propertyName) { var typeOfPattern = getTypeOfNode(node.parent.parent); var propertyDeclaration = typeOfPattern && getPropertyOfType(typeOfPattern, node.text); @@ -25614,18 +26229,18 @@ var ts; } } switch (node.kind) { - case 67 /* Identifier */: - case 164 /* PropertyAccessExpression */: - case 133 /* QualifiedName */: + case 69 /* Identifier */: + case 166 /* PropertyAccessExpression */: + case 135 /* QualifiedName */: return getSymbolOfEntityNameOrPropertyAccessExpression(node); - case 95 /* ThisKeyword */: - case 93 /* SuperKeyword */: - var type = checkExpression(node); + case 97 /* ThisKeyword */: + case 95 /* SuperKeyword */: + var type = ts.isExpression(node) ? checkExpression(node) : getTypeFromTypeNode(node); return type.symbol; - case 119 /* ConstructorKeyword */: + case 121 /* ConstructorKeyword */: // constructor keyword for an overload, should take us to the definition if it exist var constructorDeclaration = node.parent; - if (constructorDeclaration && constructorDeclaration.kind === 142 /* Constructor */) { + if (constructorDeclaration && constructorDeclaration.kind === 144 /* Constructor */) { return constructorDeclaration.parent.symbol; } return undefined; @@ -25633,14 +26248,14 @@ var ts; // External module name in an import declaration if ((ts.isExternalModuleImportEqualsDeclaration(node.parent.parent) && ts.getExternalModuleImportEqualsDeclarationExpression(node.parent.parent) === node) || - ((node.parent.kind === 220 /* ImportDeclaration */ || node.parent.kind === 226 /* ExportDeclaration */) && + ((node.parent.kind === 222 /* ImportDeclaration */ || node.parent.kind === 228 /* ExportDeclaration */) && node.parent.moduleSpecifier === node)) { return resolveExternalModuleName(node, node); } // Fall through case 8 /* NumericLiteral */: // index access - if (node.parent.kind === 165 /* ElementAccessExpression */ && node.parent.argumentExpression === node) { + if (node.parent.kind === 167 /* ElementAccessExpression */ && node.parent.argumentExpression === node) { var objectType = checkExpression(node.parent.expression); if (objectType === unknownType) return undefined; @@ -25657,7 +26272,7 @@ var ts; // The function returns a value symbol of an identifier in the short-hand property assignment. // This is necessary as an identifier in short-hand property assignment can contains two meaning: // property name and property value. - if (location && location.kind === 244 /* ShorthandPropertyAssignment */) { + if (location && location.kind === 246 /* ShorthandPropertyAssignment */) { return resolveEntityName(location.name, 107455 /* Value */); } return undefined; @@ -25774,11 +26389,11 @@ var ts; } var parentSymbol = getParentOfSymbol(symbol); if (parentSymbol) { - if (parentSymbol.flags & 512 /* ValueModule */ && parentSymbol.valueDeclaration.kind === 246 /* SourceFile */) { + if (parentSymbol.flags & 512 /* ValueModule */ && parentSymbol.valueDeclaration.kind === 248 /* SourceFile */) { return parentSymbol.valueDeclaration; } for (var n = node.parent; n; n = n.parent) { - if ((n.kind === 216 /* ModuleDeclaration */ || n.kind === 215 /* EnumDeclaration */) && getSymbolOfNode(n) === parentSymbol) { + if ((n.kind === 218 /* ModuleDeclaration */ || n.kind === 217 /* EnumDeclaration */) && getSymbolOfNode(n) === parentSymbol) { return n; } } @@ -25793,11 +26408,11 @@ var ts; } function isStatementWithLocals(node) { switch (node.kind) { - case 190 /* Block */: - case 218 /* CaseBlock */: - case 197 /* ForStatement */: - case 198 /* ForInStatement */: - case 199 /* ForOfStatement */: + case 192 /* Block */: + case 220 /* CaseBlock */: + case 199 /* ForStatement */: + case 200 /* ForInStatement */: + case 201 /* ForOfStatement */: return true; } return false; @@ -25827,22 +26442,22 @@ var ts; } function isValueAliasDeclaration(node) { switch (node.kind) { - case 219 /* ImportEqualsDeclaration */: - case 221 /* ImportClause */: - case 222 /* NamespaceImport */: - case 224 /* ImportSpecifier */: - case 228 /* ExportSpecifier */: + case 221 /* ImportEqualsDeclaration */: + case 223 /* ImportClause */: + case 224 /* NamespaceImport */: + case 226 /* ImportSpecifier */: + case 230 /* ExportSpecifier */: return isAliasResolvedToValue(getSymbolOfNode(node)); - case 226 /* ExportDeclaration */: + case 228 /* ExportDeclaration */: var exportClause = node.exportClause; return exportClause && ts.forEach(exportClause.elements, isValueAliasDeclaration); - case 225 /* ExportAssignment */: - return node.expression && node.expression.kind === 67 /* Identifier */ ? isAliasResolvedToValue(getSymbolOfNode(node)) : true; + case 227 /* ExportAssignment */: + return node.expression && node.expression.kind === 69 /* Identifier */ ? isAliasResolvedToValue(getSymbolOfNode(node)) : true; } return false; } function isTopLevelValueImportEqualsWithEntityName(node) { - if (node.parent.kind !== 246 /* SourceFile */ || !ts.isInternalModuleImportEqualsDeclaration(node)) { + if (node.parent.kind !== 248 /* SourceFile */ || !ts.isInternalModuleImportEqualsDeclaration(node)) { // parent is not source file or it is not reference to internal module return false; } @@ -25904,7 +26519,7 @@ var ts; return getNodeLinks(node).enumMemberValue; } function getConstantValue(node) { - if (node.kind === 245 /* EnumMember */) { + if (node.kind === 247 /* EnumMember */) { return getEnumMemberValue(node); } var symbol = getNodeLinks(node).resolvedSymbol; @@ -25996,23 +26611,6 @@ var ts; var symbol = getReferencedValueSymbol(reference); return symbol && getExportSymbolOfValueSymbolIfExported(symbol).valueDeclaration; } - function getBlockScopedVariableId(n) { - ts.Debug.assert(!ts.nodeIsSynthesized(n)); - var isVariableDeclarationOrBindingElement = n.parent.kind === 161 /* BindingElement */ || (n.parent.kind === 209 /* VariableDeclaration */ && n.parent.name === n); - var symbol = (isVariableDeclarationOrBindingElement ? getSymbolOfNode(n.parent) : undefined) || - getNodeLinks(n).resolvedSymbol || - resolveName(n, n.text, 107455 /* Value */ | 8388608 /* Alias */, /*nodeNotFoundMessage*/ undefined, /*nameArg*/ undefined); - var isLetOrConst = symbol && - (symbol.flags & 2 /* BlockScopedVariable */) && - symbol.valueDeclaration.parent.kind !== 242 /* CatchClause */; - if (isLetOrConst) { - // side-effect of calling this method: - // assign id to symbol if it was not yet set - getSymbolLinks(symbol); - return symbol.id; - } - return undefined; - } function instantiateSingleCallFunctionType(functionType, typeArguments) { if (functionType === unknownType) { return unknownType; @@ -26044,7 +26642,6 @@ var ts; isEntityNameVisible: isEntityNameVisible, getConstantValue: getConstantValue, collectLinkedAliases: collectLinkedAliases, - getBlockScopedVariableId: getBlockScopedVariableId, getReferencedValueDeclaration: getReferencedValueDeclaration, getTypeReferenceSerializationKind: getTypeReferenceSerializationKind, isOptionalParameter: isOptionalParameter @@ -26057,11 +26654,10 @@ var ts; }); // Initialize global symbol table ts.forEach(host.getSourceFiles(), function (file) { - if (!ts.isExternalModule(file)) { + if (!ts.isExternalOrCommonJsModule(file)) { mergeSymbolTable(globals, file.locals); } }); - // Initialize special symbols getSymbolLinks(undefinedSymbol).type = undefinedType; getSymbolLinks(argumentsSymbol).type = getGlobalType("IArguments"); getSymbolLinks(unknownSymbol).type = unknownType; @@ -26087,6 +26683,7 @@ var ts; getGlobalPromiseConstructorSymbol = ts.memoize(function () { return getGlobalValueSymbol("Promise"); }); getGlobalPromiseConstructorLikeType = ts.memoize(function () { return getGlobalType("PromiseConstructorLike"); }); getGlobalThenableType = ts.memoize(createThenableType); + cjsRequireType = getExportedTypeFromNamespace("CommonJS", "Require"); // If we're in ES6 mode, load the TemplateStringsArray. // Otherwise, default to 'unknown' for the purposes of type checking in LS scenarios. if (languageVersion >= 2 /* ES6 */) { @@ -26136,10 +26733,7 @@ var ts; if (!ts.nodeCanBeDecorated(node)) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Decorators_are_not_valid_here); } - else if (languageVersion < 1 /* ES5 */) { - return grammarErrorOnFirstToken(node, ts.Diagnostics.Decorators_are_only_available_when_targeting_ECMAScript_5_and_higher); - } - else if (node.kind === 143 /* GetAccessor */ || node.kind === 144 /* SetAccessor */) { + else if (node.kind === 145 /* GetAccessor */ || node.kind === 146 /* SetAccessor */) { var accessors = ts.getAllAccessorDeclarations(node.parent.members, node); if (accessors.firstAccessor.decorators && node === accessors.secondAccessor) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name); @@ -26149,38 +26743,38 @@ var ts; } function checkGrammarModifiers(node) { switch (node.kind) { - case 143 /* GetAccessor */: - case 144 /* SetAccessor */: - case 142 /* Constructor */: - case 139 /* PropertyDeclaration */: - case 138 /* PropertySignature */: - case 141 /* MethodDeclaration */: - case 140 /* MethodSignature */: - case 147 /* IndexSignature */: - case 216 /* ModuleDeclaration */: - case 220 /* ImportDeclaration */: - case 219 /* ImportEqualsDeclaration */: - case 226 /* ExportDeclaration */: - case 225 /* ExportAssignment */: - case 136 /* Parameter */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: + case 144 /* Constructor */: + case 141 /* PropertyDeclaration */: + case 140 /* PropertySignature */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: + case 149 /* IndexSignature */: + case 218 /* ModuleDeclaration */: + case 222 /* ImportDeclaration */: + case 221 /* ImportEqualsDeclaration */: + case 228 /* ExportDeclaration */: + case 227 /* ExportAssignment */: + case 138 /* Parameter */: break; - case 211 /* FunctionDeclaration */: - if (node.modifiers && (node.modifiers.length > 1 || node.modifiers[0].kind !== 116 /* AsyncKeyword */) && - node.parent.kind !== 217 /* ModuleBlock */ && node.parent.kind !== 246 /* SourceFile */) { + case 213 /* FunctionDeclaration */: + if (node.modifiers && (node.modifiers.length > 1 || node.modifiers[0].kind !== 118 /* AsyncKeyword */) && + node.parent.kind !== 219 /* ModuleBlock */ && node.parent.kind !== 248 /* SourceFile */) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); } break; - case 212 /* ClassDeclaration */: - case 213 /* InterfaceDeclaration */: - case 191 /* VariableStatement */: - case 214 /* TypeAliasDeclaration */: - if (node.modifiers && node.parent.kind !== 217 /* ModuleBlock */ && node.parent.kind !== 246 /* SourceFile */) { + case 214 /* ClassDeclaration */: + case 215 /* InterfaceDeclaration */: + case 193 /* VariableStatement */: + case 216 /* TypeAliasDeclaration */: + if (node.modifiers && node.parent.kind !== 219 /* ModuleBlock */ && node.parent.kind !== 248 /* SourceFile */) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); } break; - case 215 /* EnumDeclaration */: - if (node.modifiers && (node.modifiers.length > 1 || node.modifiers[0].kind !== 72 /* ConstKeyword */) && - node.parent.kind !== 217 /* ModuleBlock */ && node.parent.kind !== 246 /* SourceFile */) { + case 217 /* EnumDeclaration */: + if (node.modifiers && (node.modifiers.length > 1 || node.modifiers[0].kind !== 74 /* ConstKeyword */) && + node.parent.kind !== 219 /* ModuleBlock */ && node.parent.kind !== 248 /* SourceFile */) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); } break; @@ -26195,14 +26789,14 @@ var ts; for (var _i = 0, _a = node.modifiers; _i < _a.length; _i++) { var modifier = _a[_i]; switch (modifier.kind) { - case 110 /* PublicKeyword */: - case 109 /* ProtectedKeyword */: - case 108 /* PrivateKeyword */: + case 112 /* PublicKeyword */: + case 111 /* ProtectedKeyword */: + case 110 /* PrivateKeyword */: var text = void 0; - if (modifier.kind === 110 /* PublicKeyword */) { + if (modifier.kind === 112 /* PublicKeyword */) { text = "public"; } - else if (modifier.kind === 109 /* ProtectedKeyword */) { + else if (modifier.kind === 111 /* ProtectedKeyword */) { text = "protected"; lastProtected = modifier; } @@ -26219,11 +26813,11 @@ var ts; else if (flags & 512 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "async"); } - else if (node.parent.kind === 217 /* ModuleBlock */ || node.parent.kind === 246 /* SourceFile */) { + else if (node.parent.kind === 219 /* ModuleBlock */ || node.parent.kind === 248 /* SourceFile */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_element, text); } else if (flags & 256 /* Abstract */) { - if (modifier.kind === 108 /* PrivateKeyword */) { + if (modifier.kind === 110 /* PrivateKeyword */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, text, "abstract"); } else { @@ -26232,17 +26826,17 @@ var ts; } flags |= ts.modifierToFlag(modifier.kind); break; - case 111 /* StaticKeyword */: + case 113 /* StaticKeyword */: if (flags & 128 /* Static */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "static"); } else if (flags & 512 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "static", "async"); } - else if (node.parent.kind === 217 /* ModuleBlock */ || node.parent.kind === 246 /* SourceFile */) { + else if (node.parent.kind === 219 /* ModuleBlock */ || node.parent.kind === 248 /* SourceFile */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_element, "static"); } - else if (node.kind === 136 /* Parameter */) { + else if (node.kind === 138 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "static"); } else if (flags & 256 /* Abstract */) { @@ -26251,7 +26845,7 @@ var ts; flags |= 128 /* Static */; lastStatic = modifier; break; - case 80 /* ExportKeyword */: + case 82 /* ExportKeyword */: if (flags & 1 /* Export */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "export"); } @@ -26264,42 +26858,42 @@ var ts; else if (flags & 512 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "async"); } - else if (node.parent.kind === 212 /* ClassDeclaration */) { + else if (node.parent.kind === 214 /* ClassDeclaration */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "export"); } - else if (node.kind === 136 /* Parameter */) { + else if (node.kind === 138 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "export"); } flags |= 1 /* Export */; break; - case 120 /* DeclareKeyword */: + case 122 /* DeclareKeyword */: if (flags & 2 /* Ambient */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "declare"); } else if (flags & 512 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); } - else if (node.parent.kind === 212 /* ClassDeclaration */) { + else if (node.parent.kind === 214 /* ClassDeclaration */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "declare"); } - else if (node.kind === 136 /* Parameter */) { + else if (node.kind === 138 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "declare"); } - else if (ts.isInAmbientContext(node.parent) && node.parent.kind === 217 /* ModuleBlock */) { + else if (ts.isInAmbientContext(node.parent) && node.parent.kind === 219 /* ModuleBlock */) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_declare_modifier_cannot_be_used_in_an_already_ambient_context); } flags |= 2 /* Ambient */; lastDeclare = modifier; break; - case 113 /* AbstractKeyword */: + case 115 /* AbstractKeyword */: if (flags & 256 /* Abstract */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "abstract"); } - if (node.kind !== 212 /* ClassDeclaration */) { - if (node.kind !== 141 /* MethodDeclaration */) { + if (node.kind !== 214 /* ClassDeclaration */) { + if (node.kind !== 143 /* MethodDeclaration */) { return grammarErrorOnNode(modifier, ts.Diagnostics.abstract_modifier_can_only_appear_on_a_class_or_method_declaration); } - if (!(node.parent.kind === 212 /* ClassDeclaration */ && node.parent.flags & 256 /* Abstract */)) { + if (!(node.parent.kind === 214 /* ClassDeclaration */ && node.parent.flags & 256 /* Abstract */)) { return grammarErrorOnNode(modifier, ts.Diagnostics.Abstract_methods_can_only_appear_within_an_abstract_class); } if (flags & 128 /* Static */) { @@ -26311,14 +26905,14 @@ var ts; } flags |= 256 /* Abstract */; break; - case 116 /* AsyncKeyword */: + case 118 /* AsyncKeyword */: if (flags & 512 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "async"); } else if (flags & 2 /* Ambient */ || ts.isInAmbientContext(node.parent)) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); } - else if (node.kind === 136 /* Parameter */) { + else if (node.kind === 138 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "async"); } flags |= 512 /* Async */; @@ -26326,7 +26920,7 @@ var ts; break; } } - if (node.kind === 142 /* Constructor */) { + if (node.kind === 144 /* Constructor */) { if (flags & 128 /* Static */) { return grammarErrorOnNode(lastStatic, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "static"); } @@ -26344,10 +26938,10 @@ var ts; } return; } - else if ((node.kind === 220 /* ImportDeclaration */ || node.kind === 219 /* ImportEqualsDeclaration */) && flags & 2 /* Ambient */) { + else if ((node.kind === 222 /* ImportDeclaration */ || node.kind === 221 /* ImportEqualsDeclaration */) && flags & 2 /* Ambient */) { return grammarErrorOnNode(lastDeclare, ts.Diagnostics.A_0_modifier_cannot_be_used_with_an_import_declaration, "declare"); } - else if (node.kind === 136 /* Parameter */ && (flags & 112 /* AccessibilityModifier */) && ts.isBindingPattern(node.name)) { + else if (node.kind === 138 /* Parameter */ && (flags & 112 /* AccessibilityModifier */) && ts.isBindingPattern(node.name)) { return grammarErrorOnNode(node, ts.Diagnostics.A_parameter_property_may_not_be_a_binding_pattern); } if (flags & 512 /* Async */) { @@ -26359,10 +26953,10 @@ var ts; return grammarErrorOnNode(asyncModifier, ts.Diagnostics.Async_functions_are_only_available_when_targeting_ECMAScript_6_and_higher); } switch (node.kind) { - case 141 /* MethodDeclaration */: - case 211 /* FunctionDeclaration */: - case 171 /* FunctionExpression */: - case 172 /* ArrowFunction */: + case 143 /* MethodDeclaration */: + case 213 /* FunctionDeclaration */: + case 173 /* FunctionExpression */: + case 174 /* ArrowFunction */: if (!node.asteriskToken) { return false; } @@ -26428,7 +27022,7 @@ var ts; checkGrammarParameterList(node.parameters) || checkGrammarArrowFunction(node, file); } function checkGrammarArrowFunction(node, file) { - if (node.kind === 172 /* ArrowFunction */) { + if (node.kind === 174 /* ArrowFunction */) { var arrowFunction = node; var startLine = ts.getLineAndCharacterOfPosition(file, arrowFunction.equalsGreaterThanToken.pos).line; var endLine = ts.getLineAndCharacterOfPosition(file, arrowFunction.equalsGreaterThanToken.end).line; @@ -26463,7 +27057,7 @@ var ts; if (!parameter.type) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_must_have_a_type_annotation); } - if (parameter.type.kind !== 128 /* StringKeyword */ && parameter.type.kind !== 126 /* NumberKeyword */) { + if (parameter.type.kind !== 130 /* StringKeyword */ && parameter.type.kind !== 128 /* NumberKeyword */) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_type_must_be_string_or_number); } if (!node.type) { @@ -26496,7 +27090,7 @@ var ts; var sourceFile = ts.getSourceFileOfNode(node); for (var _i = 0; _i < args.length; _i++) { var arg = args[_i]; - if (arg.kind === 185 /* OmittedExpression */) { + if (arg.kind === 187 /* OmittedExpression */) { return grammarErrorAtPos(sourceFile, arg.pos, 0, ts.Diagnostics.Argument_expression_expected); } } @@ -26523,7 +27117,7 @@ var ts; if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && node.heritageClauses) { for (var _i = 0, _a = node.heritageClauses; _i < _a.length; _i++) { var heritageClause = _a[_i]; - if (heritageClause.token === 81 /* ExtendsKeyword */) { + if (heritageClause.token === 83 /* ExtendsKeyword */) { if (seenExtendsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_already_seen); } @@ -26536,7 +27130,7 @@ var ts; seenExtendsClause = true; } else { - ts.Debug.assert(heritageClause.token === 104 /* ImplementsKeyword */); + ts.Debug.assert(heritageClause.token === 106 /* ImplementsKeyword */); if (seenImplementsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.implements_clause_already_seen); } @@ -26552,14 +27146,14 @@ var ts; if (node.heritageClauses) { for (var _i = 0, _a = node.heritageClauses; _i < _a.length; _i++) { var heritageClause = _a[_i]; - if (heritageClause.token === 81 /* ExtendsKeyword */) { + if (heritageClause.token === 83 /* ExtendsKeyword */) { if (seenExtendsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_already_seen); } seenExtendsClause = true; } else { - ts.Debug.assert(heritageClause.token === 104 /* ImplementsKeyword */); + ts.Debug.assert(heritageClause.token === 106 /* ImplementsKeyword */); return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.Interface_declaration_cannot_have_implements_clause); } // Grammar checking heritageClause inside class declaration @@ -26570,19 +27164,19 @@ var ts; } function checkGrammarComputedPropertyName(node) { // If node is not a computedPropertyName, just skip the grammar checking - if (node.kind !== 134 /* ComputedPropertyName */) { + if (node.kind !== 136 /* ComputedPropertyName */) { return false; } var computedPropertyName = node; - if (computedPropertyName.expression.kind === 179 /* BinaryExpression */ && computedPropertyName.expression.operatorToken.kind === 24 /* CommaToken */) { + if (computedPropertyName.expression.kind === 181 /* BinaryExpression */ && computedPropertyName.expression.operatorToken.kind === 24 /* CommaToken */) { return grammarErrorOnNode(computedPropertyName.expression, ts.Diagnostics.A_comma_expression_is_not_allowed_in_a_computed_property_name); } } function checkGrammarForGenerator(node) { if (node.asteriskToken) { - ts.Debug.assert(node.kind === 211 /* FunctionDeclaration */ || - node.kind === 171 /* FunctionExpression */ || - node.kind === 141 /* MethodDeclaration */); + ts.Debug.assert(node.kind === 213 /* FunctionDeclaration */ || + node.kind === 173 /* FunctionExpression */ || + node.kind === 143 /* MethodDeclaration */); if (ts.isInAmbientContext(node)) { return grammarErrorOnNode(node.asteriskToken, ts.Diagnostics.Generators_are_not_allowed_in_an_ambient_context); } @@ -26599,7 +27193,7 @@ var ts; return grammarErrorOnNode(questionToken, message); } } - function checkGrammarObjectLiteralExpression(node) { + function checkGrammarObjectLiteralExpression(node, inDestructuring) { var seen = {}; var Property = 1; var GetAccessor = 2; @@ -26608,12 +27202,17 @@ var ts; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; var name_16 = prop.name; - if (prop.kind === 185 /* OmittedExpression */ || - name_16.kind === 134 /* ComputedPropertyName */) { + if (prop.kind === 187 /* OmittedExpression */ || + name_16.kind === 136 /* ComputedPropertyName */) { // If the name is not a ComputedPropertyName, the grammar checking will skip it checkGrammarComputedPropertyName(name_16); continue; } + if (prop.kind === 246 /* ShorthandPropertyAssignment */ && !inDestructuring && prop.objectAssignmentInitializer) { + // having objectAssignmentInitializer is only valid in ObjectAssignmentPattern + // outside of destructuring it is a syntax error + return grammarErrorOnNode(prop.equalsToken, ts.Diagnostics.can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment); + } // ECMA-262 11.1.5 Object Initialiser // If previous is not undefined then throw a SyntaxError exception if any of the following conditions are true // a.This production is contained in strict code and IsDataDescriptor(previous) is true and @@ -26623,7 +27222,7 @@ var ts; // d.IsAccessorDescriptor(previous) is true and IsAccessorDescriptor(propId.descriptor) is true // and either both previous and propId.descriptor have[[Get]] fields or both previous and propId.descriptor have[[Set]] fields var currentKind = void 0; - if (prop.kind === 243 /* PropertyAssignment */ || prop.kind === 244 /* ShorthandPropertyAssignment */) { + if (prop.kind === 245 /* PropertyAssignment */ || prop.kind === 246 /* ShorthandPropertyAssignment */) { // Grammar checking for computedPropertName and shorthandPropertyAssignment checkGrammarForInvalidQuestionMark(prop, prop.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional); if (name_16.kind === 8 /* NumericLiteral */) { @@ -26631,13 +27230,13 @@ var ts; } currentKind = Property; } - else if (prop.kind === 141 /* MethodDeclaration */) { + else if (prop.kind === 143 /* MethodDeclaration */) { currentKind = Property; } - else if (prop.kind === 143 /* GetAccessor */) { + else if (prop.kind === 145 /* GetAccessor */) { currentKind = GetAccessor; } - else if (prop.kind === 144 /* SetAccessor */) { + else if (prop.kind === 146 /* SetAccessor */) { currentKind = SetAccesor; } else { @@ -26669,7 +27268,7 @@ var ts; var seen = {}; for (var _i = 0, _a = node.attributes; _i < _a.length; _i++) { var attr = _a[_i]; - if (attr.kind === 237 /* JsxSpreadAttribute */) { + if (attr.kind === 239 /* JsxSpreadAttribute */) { continue; } var jsxAttr = attr; @@ -26681,7 +27280,7 @@ var ts; return grammarErrorOnNode(name_17, ts.Diagnostics.JSX_elements_cannot_have_multiple_attributes_with_the_same_name); } var initializer = jsxAttr.initializer; - if (initializer && initializer.kind === 238 /* JsxExpression */ && !initializer.expression) { + if (initializer && initializer.kind === 240 /* JsxExpression */ && !initializer.expression) { return grammarErrorOnNode(jsxAttr.initializer, ts.Diagnostics.JSX_attributes_must_only_be_assigned_a_non_empty_expression); } } @@ -26690,24 +27289,24 @@ var ts; if (checkGrammarStatementInAmbientContext(forInOrOfStatement)) { return true; } - if (forInOrOfStatement.initializer.kind === 210 /* VariableDeclarationList */) { + if (forInOrOfStatement.initializer.kind === 212 /* VariableDeclarationList */) { var variableList = forInOrOfStatement.initializer; if (!checkGrammarVariableDeclarationList(variableList)) { if (variableList.declarations.length > 1) { - var diagnostic = forInOrOfStatement.kind === 198 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 200 /* ForInStatement */ ? ts.Diagnostics.Only_a_single_variable_declaration_is_allowed_in_a_for_in_statement : ts.Diagnostics.Only_a_single_variable_declaration_is_allowed_in_a_for_of_statement; return grammarErrorOnFirstToken(variableList.declarations[1], diagnostic); } var firstDeclaration = variableList.declarations[0]; if (firstDeclaration.initializer) { - var diagnostic = forInOrOfStatement.kind === 198 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 200 /* ForInStatement */ ? ts.Diagnostics.The_variable_declaration_of_a_for_in_statement_cannot_have_an_initializer : ts.Diagnostics.The_variable_declaration_of_a_for_of_statement_cannot_have_an_initializer; return grammarErrorOnNode(firstDeclaration.name, diagnostic); } if (firstDeclaration.type) { - var diagnostic = forInOrOfStatement.kind === 198 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 200 /* ForInStatement */ ? ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_use_a_type_annotation : ts.Diagnostics.The_left_hand_side_of_a_for_of_statement_cannot_use_a_type_annotation; return grammarErrorOnNode(firstDeclaration, diagnostic); @@ -26730,10 +27329,10 @@ var ts; else if (accessor.typeParameters) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.An_accessor_cannot_have_type_parameters); } - else if (kind === 143 /* GetAccessor */ && accessor.parameters.length) { + else if (kind === 145 /* GetAccessor */ && accessor.parameters.length) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_get_accessor_cannot_have_parameters); } - else if (kind === 144 /* SetAccessor */) { + else if (kind === 146 /* SetAccessor */) { if (accessor.type) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_set_accessor_cannot_have_a_return_type_annotation); } @@ -26758,7 +27357,7 @@ var ts; } } function checkGrammarForNonSymbolComputedProperty(node, message) { - if (node.kind === 134 /* ComputedPropertyName */ && !ts.isWellKnownSymbolSyntactically(node.expression)) { + if (node.kind === 136 /* ComputedPropertyName */ && !ts.isWellKnownSymbolSyntactically(node.expression)) { return grammarErrorOnNode(node, message); } } @@ -26768,7 +27367,7 @@ var ts; checkGrammarForGenerator(node)) { return true; } - if (node.parent.kind === 163 /* ObjectLiteralExpression */) { + if (node.parent.kind === 165 /* ObjectLiteralExpression */) { if (checkGrammarForInvalidQuestionMark(node, node.questionToken, ts.Diagnostics.A_class_member_cannot_be_declared_optional)) { return true; } @@ -26792,22 +27391,22 @@ var ts; return checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_method_overload_must_directly_refer_to_a_built_in_symbol); } } - else if (node.parent.kind === 213 /* InterfaceDeclaration */) { + else if (node.parent.kind === 215 /* InterfaceDeclaration */) { return checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_an_interface_must_directly_refer_to_a_built_in_symbol); } - else if (node.parent.kind === 153 /* TypeLiteral */) { + else if (node.parent.kind === 155 /* TypeLiteral */) { return checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_type_literal_must_directly_refer_to_a_built_in_symbol); } } function isIterationStatement(node, lookInLabeledStatements) { switch (node.kind) { - case 197 /* ForStatement */: - case 198 /* ForInStatement */: - case 199 /* ForOfStatement */: - case 195 /* DoStatement */: - case 196 /* WhileStatement */: + case 199 /* ForStatement */: + case 200 /* ForInStatement */: + case 201 /* ForOfStatement */: + case 197 /* DoStatement */: + case 198 /* WhileStatement */: return true; - case 205 /* LabeledStatement */: + case 207 /* LabeledStatement */: return lookInLabeledStatements && isIterationStatement(node.statement, lookInLabeledStatements); } return false; @@ -26819,11 +27418,11 @@ var ts; return grammarErrorOnNode(node, ts.Diagnostics.Jump_target_cannot_cross_function_boundary); } switch (current.kind) { - case 205 /* LabeledStatement */: + case 207 /* LabeledStatement */: if (node.label && current.label.text === node.label.text) { // found matching label - verify that label usage is correct // continue can only target labels that are on iteration statements - var isMisplacedContinueLabel = node.kind === 200 /* ContinueStatement */ + var isMisplacedContinueLabel = node.kind === 202 /* ContinueStatement */ && !isIterationStatement(current.statement, /*lookInLabeledStatement*/ true); if (isMisplacedContinueLabel) { return grammarErrorOnNode(node, ts.Diagnostics.A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement); @@ -26831,8 +27430,8 @@ var ts; return false; } break; - case 204 /* SwitchStatement */: - if (node.kind === 201 /* BreakStatement */ && !node.label) { + case 206 /* SwitchStatement */: + if (node.kind === 203 /* BreakStatement */ && !node.label) { // unlabeled break within switch statement - ok return false; } @@ -26847,13 +27446,13 @@ var ts; current = current.parent; } if (node.label) { - var message = node.kind === 201 /* BreakStatement */ + var message = node.kind === 203 /* BreakStatement */ ? ts.Diagnostics.A_break_statement_can_only_jump_to_a_label_of_an_enclosing_statement : ts.Diagnostics.A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement; return grammarErrorOnNode(node, message); } else { - var message = node.kind === 201 /* BreakStatement */ + var message = node.kind === 203 /* BreakStatement */ ? ts.Diagnostics.A_break_statement_can_only_be_used_within_an_enclosing_iteration_or_switch_statement : ts.Diagnostics.A_continue_statement_can_only_be_used_within_an_enclosing_iteration_statement; return grammarErrorOnNode(node, message); @@ -26865,7 +27464,7 @@ var ts; if (node !== ts.lastOrUndefined(elements)) { return grammarErrorOnNode(node, ts.Diagnostics.A_rest_element_must_be_last_in_an_array_destructuring_pattern); } - if (node.name.kind === 160 /* ArrayBindingPattern */ || node.name.kind === 159 /* ObjectBindingPattern */) { + if (node.name.kind === 162 /* ArrayBindingPattern */ || node.name.kind === 161 /* ObjectBindingPattern */) { return grammarErrorOnNode(node.name, ts.Diagnostics.A_rest_element_cannot_contain_a_binding_pattern); } if (node.initializer) { @@ -26875,7 +27474,7 @@ var ts; } } function checkGrammarVariableDeclaration(node) { - if (node.parent.parent.kind !== 198 /* ForInStatement */ && node.parent.parent.kind !== 199 /* ForOfStatement */) { + if (node.parent.parent.kind !== 200 /* ForInStatement */ && node.parent.parent.kind !== 201 /* ForOfStatement */) { if (ts.isInAmbientContext(node)) { if (node.initializer) { // Error on equals token which immediate precedes the initializer @@ -26902,7 +27501,7 @@ var ts; return checkLetConstNames && checkGrammarNameInLetOrConstDeclarations(node.name); } function checkGrammarNameInLetOrConstDeclarations(name) { - if (name.kind === 67 /* Identifier */) { + if (name.kind === 69 /* Identifier */) { if (name.text === "let") { return grammarErrorOnNode(name, ts.Diagnostics.let_is_not_allowed_to_be_used_as_a_name_in_let_or_const_declarations); } @@ -26911,7 +27510,7 @@ var ts; var elements = name.elements; for (var _i = 0; _i < elements.length; _i++) { var element = elements[_i]; - if (element.kind !== 185 /* OmittedExpression */) { + if (element.kind !== 187 /* OmittedExpression */) { checkGrammarNameInLetOrConstDeclarations(element.name); } } @@ -26928,15 +27527,15 @@ var ts; } function allowLetAndConstDeclarations(parent) { switch (parent.kind) { - case 194 /* IfStatement */: - case 195 /* DoStatement */: - case 196 /* WhileStatement */: - case 203 /* WithStatement */: - case 197 /* ForStatement */: - case 198 /* ForInStatement */: - case 199 /* ForOfStatement */: + case 196 /* IfStatement */: + case 197 /* DoStatement */: + case 198 /* WhileStatement */: + case 205 /* WithStatement */: + case 199 /* ForStatement */: + case 200 /* ForInStatement */: + case 201 /* ForOfStatement */: return false; - case 205 /* LabeledStatement */: + case 207 /* LabeledStatement */: return allowLetAndConstDeclarations(parent.parent); } return true; @@ -26952,7 +27551,7 @@ var ts; } } function isIntegerLiteral(expression) { - if (expression.kind === 177 /* PrefixUnaryExpression */) { + if (expression.kind === 179 /* PrefixUnaryExpression */) { var unaryExpression = expression; if (unaryExpression.operator === 35 /* PlusToken */ || unaryExpression.operator === 36 /* MinusToken */) { expression = unaryExpression.operand; @@ -26968,37 +27567,6 @@ var ts; } return false; } - function checkGrammarEnumDeclaration(enumDecl) { - var enumIsConst = (enumDecl.flags & 32768 /* Const */) !== 0; - var hasError = false; - // skip checks below for const enums - they allow arbitrary initializers as long as they can be evaluated to constant expressions. - // since all values are known in compile time - it is not necessary to check that constant enum section precedes computed enum members. - if (!enumIsConst) { - var inConstantEnumMemberSection = true; - var inAmbientContext = ts.isInAmbientContext(enumDecl); - for (var _i = 0, _a = enumDecl.members; _i < _a.length; _i++) { - var node = _a[_i]; - // Do not use hasDynamicName here, because that returns false for well known symbols. - // We want to perform checkComputedPropertyName for all computed properties, including - // well known symbols. - if (node.name.kind === 134 /* ComputedPropertyName */) { - hasError = grammarErrorOnNode(node.name, ts.Diagnostics.Computed_property_names_are_not_allowed_in_enums); - } - else if (inAmbientContext) { - if (node.initializer && !isIntegerLiteral(node.initializer)) { - hasError = grammarErrorOnNode(node.name, ts.Diagnostics.Ambient_enum_elements_can_only_have_integer_literal_initializers) || hasError; - } - } - else if (node.initializer) { - inConstantEnumMemberSection = isIntegerLiteral(node.initializer); - } - else if (!inConstantEnumMemberSection) { - hasError = grammarErrorOnNode(node.name, ts.Diagnostics.Enum_member_must_have_initializer) || hasError; - } - } - } - return hasError; - } function hasParseDiagnostics(sourceFile) { return sourceFile.parseDiagnostics.length > 0; } @@ -27024,7 +27592,7 @@ var ts; } } function isEvalOrArgumentsIdentifier(node) { - return node.kind === 67 /* Identifier */ && + return node.kind === 69 /* Identifier */ && (node.text === "eval" || node.text === "arguments"); } function checkGrammarConstructorTypeParameters(node) { @@ -27044,12 +27612,12 @@ var ts; return true; } } - else if (node.parent.kind === 213 /* InterfaceDeclaration */) { + else if (node.parent.kind === 215 /* InterfaceDeclaration */) { if (checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_an_interface_must_directly_refer_to_a_built_in_symbol)) { return true; } } - else if (node.parent.kind === 153 /* TypeLiteral */) { + else if (node.parent.kind === 155 /* TypeLiteral */) { if (checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_type_literal_must_directly_refer_to_a_built_in_symbol)) { return true; } @@ -27069,11 +27637,11 @@ var ts; // export_opt ExternalImportDeclaration // export_opt AmbientDeclaration // - if (node.kind === 213 /* InterfaceDeclaration */ || - node.kind === 220 /* ImportDeclaration */ || - node.kind === 219 /* ImportEqualsDeclaration */ || - node.kind === 226 /* ExportDeclaration */ || - node.kind === 225 /* ExportAssignment */ || + if (node.kind === 215 /* InterfaceDeclaration */ || + node.kind === 222 /* ImportDeclaration */ || + node.kind === 221 /* ImportEqualsDeclaration */ || + node.kind === 228 /* ExportDeclaration */ || + node.kind === 227 /* ExportAssignment */ || (node.flags & 2 /* Ambient */) || (node.flags & (1 /* Export */ | 1024 /* Default */))) { return false; @@ -27083,7 +27651,7 @@ var ts; function checkGrammarTopLevelElementsForRequiredDeclareModifier(file) { for (var _i = 0, _a = file.statements; _i < _a.length; _i++) { var decl = _a[_i]; - if (ts.isDeclaration(decl) || decl.kind === 191 /* VariableStatement */) { + if (ts.isDeclaration(decl) || decl.kind === 193 /* VariableStatement */) { if (checkGrammarTopLevelElementForRequiredDeclareModifier(decl)) { return true; } @@ -27109,7 +27677,7 @@ var ts; // to prevent noisyness. So use a bit on the block to indicate if // this has already been reported, and don't report if it has. // - if (node.parent.kind === 190 /* Block */ || node.parent.kind === 217 /* ModuleBlock */ || node.parent.kind === 246 /* SourceFile */) { + if (node.parent.kind === 192 /* Block */ || node.parent.kind === 219 /* ModuleBlock */ || node.parent.kind === 248 /* SourceFile */) { var links_1 = getNodeLinks(node.parent); // Check if the containing block ever report this error if (!links_1.hasReportedStatementInAmbientContext) { @@ -27160,6 +27728,7 @@ var ts; var enclosingDeclaration; var currentSourceFile; var reportedDeclarationError = false; + var errorNameNode; var emitJsDocComments = compilerOptions.removeComments ? function (declaration) { } : writeJsDocComments; var emit = compilerOptions.stripInternal ? stripInternal : emitNode; var moduleElementDeclarationEmitInfo = []; @@ -27191,7 +27760,7 @@ var ts; var oldWriter = writer; ts.forEach(moduleElementDeclarationEmitInfo, function (aliasEmitInfo) { if (aliasEmitInfo.isVisible) { - ts.Debug.assert(aliasEmitInfo.node.kind === 220 /* ImportDeclaration */); + ts.Debug.assert(aliasEmitInfo.node.kind === 222 /* ImportDeclaration */); createAndSetNewTextWriterWithSymbolWriter(); ts.Debug.assert(aliasEmitInfo.indent === 0); writeImportDeclaration(aliasEmitInfo.node); @@ -27245,6 +27814,7 @@ var ts; function createAndSetNewTextWriterWithSymbolWriter() { var writer = ts.createTextWriter(newLine); writer.trackSymbol = trackSymbol; + writer.reportInaccessibleThisError = reportInaccessibleThisError; writer.writeKeyword = writer.write; writer.writeOperator = writer.write; writer.writePunctuation = writer.write; @@ -27267,10 +27837,10 @@ var ts; var oldWriter = writer; ts.forEach(nodes, function (declaration) { var nodeToCheck; - if (declaration.kind === 209 /* VariableDeclaration */) { + if (declaration.kind === 211 /* VariableDeclaration */) { nodeToCheck = declaration.parent.parent; } - else if (declaration.kind === 223 /* NamedImports */ || declaration.kind === 224 /* ImportSpecifier */ || declaration.kind === 221 /* ImportClause */) { + else if (declaration.kind === 225 /* NamedImports */ || declaration.kind === 226 /* ImportSpecifier */ || declaration.kind === 223 /* ImportClause */) { ts.Debug.fail("We should be getting ImportDeclaration instead to write"); } else { @@ -27288,7 +27858,7 @@ var ts; // Writing of function bar would mark alias declaration foo as visible but we haven't yet visited that declaration so do nothing, // we would write alias foo declaration when we visit it since it would now be marked as visible if (moduleElementEmitInfo) { - if (moduleElementEmitInfo.node.kind === 220 /* ImportDeclaration */) { + if (moduleElementEmitInfo.node.kind === 222 /* ImportDeclaration */) { // we have to create asynchronous output only after we have collected complete information // because it is possible to enable multiple bindings as asynchronously visible moduleElementEmitInfo.isVisible = true; @@ -27298,12 +27868,12 @@ var ts; for (var declarationIndent = moduleElementEmitInfo.indent; declarationIndent; declarationIndent--) { increaseIndent(); } - if (nodeToCheck.kind === 216 /* ModuleDeclaration */) { + if (nodeToCheck.kind === 218 /* ModuleDeclaration */) { ts.Debug.assert(asynchronousSubModuleDeclarationEmitInfo === undefined); asynchronousSubModuleDeclarationEmitInfo = []; } writeModuleElement(nodeToCheck); - if (nodeToCheck.kind === 216 /* ModuleDeclaration */) { + if (nodeToCheck.kind === 218 /* ModuleDeclaration */) { moduleElementEmitInfo.subModuleElementDeclarationEmitInfo = asynchronousSubModuleDeclarationEmitInfo; asynchronousSubModuleDeclarationEmitInfo = undefined; } @@ -27337,6 +27907,11 @@ var ts; function trackSymbol(symbol, enclosingDeclaration, meaning) { handleSymbolAccessibilityError(resolver.isSymbolAccessible(symbol, enclosingDeclaration, meaning)); } + function reportInaccessibleThisError() { + if (errorNameNode) { + diagnostics.push(ts.createDiagnosticForNode(errorNameNode, ts.Diagnostics.The_inferred_type_of_0_references_an_inaccessible_this_type_A_type_annotation_is_necessary, ts.declarationNameToString(errorNameNode))); + } + } function writeTypeOfDeclaration(declaration, type, getSymbolAccessibilityDiagnostic) { writer.getSymbolAccessibilityDiagnostic = getSymbolAccessibilityDiagnostic; write(": "); @@ -27345,7 +27920,9 @@ var ts; emitType(type); } else { + errorNameNode = declaration.name; resolver.writeTypeOfDeclaration(declaration, enclosingDeclaration, 2 /* UseTypeOfFunction */, writer); + errorNameNode = undefined; } } function writeReturnTypeAtSignature(signature, getSymbolAccessibilityDiagnostic) { @@ -27356,7 +27933,9 @@ var ts; emitType(signature.type); } else { + errorNameNode = signature.name; resolver.writeReturnTypeOfSignatureDeclaration(signature, enclosingDeclaration, 2 /* UseTypeOfFunction */, writer); + errorNameNode = undefined; } } function emitLines(nodes) { @@ -27395,49 +27974,50 @@ var ts; } function emitType(type) { switch (type.kind) { - case 115 /* AnyKeyword */: - case 128 /* StringKeyword */: - case 126 /* NumberKeyword */: - case 118 /* BooleanKeyword */: - case 129 /* SymbolKeyword */: - case 101 /* VoidKeyword */: + case 117 /* AnyKeyword */: + case 130 /* StringKeyword */: + case 128 /* NumberKeyword */: + case 120 /* BooleanKeyword */: + case 131 /* SymbolKeyword */: + case 103 /* VoidKeyword */: + case 97 /* ThisKeyword */: case 9 /* StringLiteral */: return writeTextOfNode(currentSourceFile, type); - case 186 /* ExpressionWithTypeArguments */: + case 188 /* ExpressionWithTypeArguments */: return emitExpressionWithTypeArguments(type); - case 149 /* TypeReference */: + case 151 /* TypeReference */: return emitTypeReference(type); - case 152 /* TypeQuery */: + case 154 /* TypeQuery */: return emitTypeQuery(type); - case 154 /* ArrayType */: + case 156 /* ArrayType */: return emitArrayType(type); - case 155 /* TupleType */: + case 157 /* TupleType */: return emitTupleType(type); - case 156 /* UnionType */: + case 158 /* UnionType */: return emitUnionType(type); - case 157 /* IntersectionType */: + case 159 /* IntersectionType */: return emitIntersectionType(type); - case 158 /* ParenthesizedType */: + case 160 /* ParenthesizedType */: return emitParenType(type); - case 150 /* FunctionType */: - case 151 /* ConstructorType */: + case 152 /* FunctionType */: + case 153 /* ConstructorType */: return emitSignatureDeclarationWithJsDocComments(type); - case 153 /* TypeLiteral */: + case 155 /* TypeLiteral */: return emitTypeLiteral(type); - case 67 /* Identifier */: + case 69 /* Identifier */: return emitEntityName(type); - case 133 /* QualifiedName */: + case 135 /* QualifiedName */: return emitEntityName(type); - case 148 /* TypePredicate */: + case 150 /* TypePredicate */: return emitTypePredicate(type); } function writeEntityName(entityName) { - if (entityName.kind === 67 /* Identifier */) { + if (entityName.kind === 69 /* Identifier */) { writeTextOfNode(currentSourceFile, entityName); } else { - var left = entityName.kind === 133 /* QualifiedName */ ? entityName.left : entityName.expression; - var right = entityName.kind === 133 /* QualifiedName */ ? entityName.right : entityName.name; + var left = entityName.kind === 135 /* QualifiedName */ ? entityName.left : entityName.expression; + var right = entityName.kind === 135 /* QualifiedName */ ? entityName.right : entityName.name; writeEntityName(left); write("."); writeTextOfNode(currentSourceFile, right); @@ -27446,13 +28026,13 @@ var ts; function emitEntityName(entityName) { var visibilityResult = resolver.isEntityNameVisible(entityName, // Aliases can be written asynchronously so use correct enclosing declaration - entityName.parent.kind === 219 /* ImportEqualsDeclaration */ ? entityName.parent : enclosingDeclaration); + entityName.parent.kind === 221 /* ImportEqualsDeclaration */ ? entityName.parent : enclosingDeclaration); handleSymbolAccessibilityError(visibilityResult); writeEntityName(entityName); } function emitExpressionWithTypeArguments(node) { if (ts.isSupportedExpressionWithTypeArguments(node)) { - ts.Debug.assert(node.expression.kind === 67 /* Identifier */ || node.expression.kind === 164 /* PropertyAccessExpression */); + ts.Debug.assert(node.expression.kind === 69 /* Identifier */ || node.expression.kind === 166 /* PropertyAccessExpression */); emitEntityName(node.expression); if (node.typeArguments) { write("<"); @@ -27533,7 +28113,7 @@ var ts; } } function emitExportAssignment(node) { - if (node.expression.kind === 67 /* Identifier */) { + if (node.expression.kind === 69 /* Identifier */) { write(node.isExportEquals ? "export = " : "export default "); writeTextOfNode(currentSourceFile, node.expression); } @@ -27553,7 +28133,7 @@ var ts; write(";"); writeLine(); // Make all the declarations visible for the export name - if (node.expression.kind === 67 /* Identifier */) { + if (node.expression.kind === 69 /* Identifier */) { var nodes = resolver.collectLinkedAliases(node.expression); // write each of these declarations asynchronously writeAsynchronousModuleElements(nodes); @@ -27572,10 +28152,10 @@ var ts; if (isModuleElementVisible) { writeModuleElement(node); } - else if (node.kind === 219 /* ImportEqualsDeclaration */ || - (node.parent.kind === 246 /* SourceFile */ && ts.isExternalModule(currentSourceFile))) { + else if (node.kind === 221 /* ImportEqualsDeclaration */ || + (node.parent.kind === 248 /* SourceFile */ && ts.isExternalModule(currentSourceFile))) { var isVisible; - if (asynchronousSubModuleDeclarationEmitInfo && node.parent.kind !== 246 /* SourceFile */) { + if (asynchronousSubModuleDeclarationEmitInfo && node.parent.kind !== 248 /* SourceFile */) { // Import declaration of another module that is visited async so lets put it in right spot asynchronousSubModuleDeclarationEmitInfo.push({ node: node, @@ -27585,7 +28165,7 @@ var ts; }); } else { - if (node.kind === 220 /* ImportDeclaration */) { + if (node.kind === 222 /* ImportDeclaration */) { var importDeclaration = node; if (importDeclaration.importClause) { isVisible = (importDeclaration.importClause.name && resolver.isDeclarationVisible(importDeclaration.importClause)) || @@ -27603,23 +28183,23 @@ var ts; } function writeModuleElement(node) { switch (node.kind) { - case 211 /* FunctionDeclaration */: + case 213 /* FunctionDeclaration */: return writeFunctionDeclaration(node); - case 191 /* VariableStatement */: + case 193 /* VariableStatement */: return writeVariableStatement(node); - case 213 /* InterfaceDeclaration */: + case 215 /* InterfaceDeclaration */: return writeInterfaceDeclaration(node); - case 212 /* ClassDeclaration */: + case 214 /* ClassDeclaration */: return writeClassDeclaration(node); - case 214 /* TypeAliasDeclaration */: + case 216 /* TypeAliasDeclaration */: return writeTypeAliasDeclaration(node); - case 215 /* EnumDeclaration */: + case 217 /* EnumDeclaration */: return writeEnumDeclaration(node); - case 216 /* ModuleDeclaration */: + case 218 /* ModuleDeclaration */: return writeModuleDeclaration(node); - case 219 /* ImportEqualsDeclaration */: + case 221 /* ImportEqualsDeclaration */: return writeImportEqualsDeclaration(node); - case 220 /* ImportDeclaration */: + case 222 /* ImportDeclaration */: return writeImportDeclaration(node); default: ts.Debug.fail("Unknown symbol kind"); @@ -27635,7 +28215,7 @@ var ts; if (node.flags & 1024 /* Default */) { write("default "); } - else if (node.kind !== 213 /* InterfaceDeclaration */) { + else if (node.kind !== 215 /* InterfaceDeclaration */) { write("declare "); } } @@ -27684,7 +28264,7 @@ var ts; } function isVisibleNamedBinding(namedBindings) { if (namedBindings) { - if (namedBindings.kind === 222 /* NamespaceImport */) { + if (namedBindings.kind === 224 /* NamespaceImport */) { return resolver.isDeclarationVisible(namedBindings); } else { @@ -27712,7 +28292,7 @@ var ts; // If the default binding was emitted, write the separated write(", "); } - if (node.importClause.namedBindings.kind === 222 /* NamespaceImport */) { + if (node.importClause.namedBindings.kind === 224 /* NamespaceImport */) { write("* as "); writeTextOfNode(currentSourceFile, node.importClause.namedBindings.name); } @@ -27770,7 +28350,7 @@ var ts; write("module "); } writeTextOfNode(currentSourceFile, node.name); - while (node.body.kind !== 217 /* ModuleBlock */) { + while (node.body.kind !== 219 /* ModuleBlock */) { node = node.body; write("."); writeTextOfNode(currentSourceFile, node.name); @@ -27835,7 +28415,7 @@ var ts; writeLine(); } function isPrivateMethodTypeParameter(node) { - return node.parent.kind === 141 /* MethodDeclaration */ && (node.parent.flags & 32 /* Private */); + return node.parent.kind === 143 /* MethodDeclaration */ && (node.parent.flags & 32 /* Private */); } function emitTypeParameters(typeParameters) { function emitTypeParameter(node) { @@ -27846,15 +28426,15 @@ var ts; // If there is constraint present and this is not a type parameter of the private method emit the constraint if (node.constraint && !isPrivateMethodTypeParameter(node)) { write(" extends "); - if (node.parent.kind === 150 /* FunctionType */ || - node.parent.kind === 151 /* ConstructorType */ || - (node.parent.parent && node.parent.parent.kind === 153 /* TypeLiteral */)) { - ts.Debug.assert(node.parent.kind === 141 /* MethodDeclaration */ || - node.parent.kind === 140 /* MethodSignature */ || - node.parent.kind === 150 /* FunctionType */ || - node.parent.kind === 151 /* ConstructorType */ || - node.parent.kind === 145 /* CallSignature */ || - node.parent.kind === 146 /* ConstructSignature */); + if (node.parent.kind === 152 /* FunctionType */ || + node.parent.kind === 153 /* ConstructorType */ || + (node.parent.parent && node.parent.parent.kind === 155 /* TypeLiteral */)) { + ts.Debug.assert(node.parent.kind === 143 /* MethodDeclaration */ || + node.parent.kind === 142 /* MethodSignature */ || + node.parent.kind === 152 /* FunctionType */ || + node.parent.kind === 153 /* ConstructorType */ || + node.parent.kind === 147 /* CallSignature */ || + node.parent.kind === 148 /* ConstructSignature */); emitType(node.constraint); } else { @@ -27865,31 +28445,31 @@ var ts; // Type parameter constraints are named by user so we should always be able to name it var diagnosticMessage; switch (node.parent.kind) { - case 212 /* ClassDeclaration */: + case 214 /* ClassDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_class_has_or_is_using_private_name_1; break; - case 213 /* InterfaceDeclaration */: + case 215 /* InterfaceDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1; break; - case 146 /* ConstructSignature */: + case 148 /* ConstructSignature */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 145 /* CallSignature */: + case 147 /* CallSignature */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 141 /* MethodDeclaration */: - case 140 /* MethodSignature */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: if (node.parent.flags & 128 /* Static */) { diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.parent.kind === 212 /* ClassDeclaration */) { + else if (node.parent.parent.kind === 214 /* ClassDeclaration */) { diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_public_method_from_exported_class_has_or_is_using_private_name_1; } else { diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1; } break; - case 211 /* FunctionDeclaration */: + case 213 /* FunctionDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_function_has_or_is_using_private_name_1; break; default: @@ -27917,13 +28497,13 @@ var ts; if (ts.isSupportedExpressionWithTypeArguments(node)) { emitTypeWithNewGetSymbolAccessibilityDiagnostic(node, getHeritageClauseVisibilityError); } - else if (!isImplementsList && node.expression.kind === 91 /* NullKeyword */) { + else if (!isImplementsList && node.expression.kind === 93 /* NullKeyword */) { write("null"); } function getHeritageClauseVisibilityError(symbolAccesibilityResult) { var diagnosticMessage; // Heritage clause is written by user so it can always be named - if (node.parent.parent.kind === 212 /* ClassDeclaration */) { + if (node.parent.parent.kind === 214 /* ClassDeclaration */) { // Class or Interface implemented/extended is inaccessible diagnosticMessage = isImplementsList ? ts.Diagnostics.Implements_clause_of_exported_class_0_has_or_is_using_private_name_1 : @@ -28007,7 +28587,7 @@ var ts; function emitVariableDeclaration(node) { // If we are emitting property it isn't moduleElement and hence we already know it needs to be emitted // so there is no check needed to see if declaration is visible - if (node.kind !== 209 /* VariableDeclaration */ || resolver.isDeclarationVisible(node)) { + if (node.kind !== 211 /* VariableDeclaration */ || resolver.isDeclarationVisible(node)) { if (ts.isBindingPattern(node.name)) { emitBindingPattern(node.name); } @@ -28017,10 +28597,10 @@ var ts; // what we want, namely the name expression enclosed in brackets. writeTextOfNode(currentSourceFile, node.name); // If optional property emit ? - if ((node.kind === 139 /* PropertyDeclaration */ || node.kind === 138 /* PropertySignature */) && ts.hasQuestionToken(node)) { + if ((node.kind === 141 /* PropertyDeclaration */ || node.kind === 140 /* PropertySignature */) && ts.hasQuestionToken(node)) { write("?"); } - if ((node.kind === 139 /* PropertyDeclaration */ || node.kind === 138 /* PropertySignature */) && node.parent.kind === 153 /* TypeLiteral */) { + if ((node.kind === 141 /* PropertyDeclaration */ || node.kind === 140 /* PropertySignature */) && node.parent.kind === 155 /* TypeLiteral */) { emitTypeOfVariableDeclarationFromTypeLiteral(node); } else if (!(node.flags & 32 /* Private */)) { @@ -28029,14 +28609,14 @@ var ts; } } function getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccesibilityResult) { - if (node.kind === 209 /* VariableDeclaration */) { + if (node.kind === 211 /* VariableDeclaration */) { return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Exported_variable_0_has_or_is_using_private_name_1; } - else if (node.kind === 139 /* PropertyDeclaration */ || node.kind === 138 /* PropertySignature */) { + else if (node.kind === 141 /* PropertyDeclaration */ || node.kind === 140 /* PropertySignature */) { // TODO(jfreeman): Deal with computed properties in error reporting. if (node.flags & 128 /* Static */) { return symbolAccesibilityResult.errorModuleName ? @@ -28045,7 +28625,7 @@ var ts; ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.kind === 212 /* ClassDeclaration */) { + else if (node.parent.kind === 214 /* ClassDeclaration */) { return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -28077,7 +28657,7 @@ var ts; var elements = []; for (var _i = 0, _a = bindingPattern.elements; _i < _a.length; _i++) { var element = _a[_i]; - if (element.kind !== 185 /* OmittedExpression */) { + if (element.kind !== 187 /* OmittedExpression */) { elements.push(element); } } @@ -28147,7 +28727,7 @@ var ts; var type = getTypeAnnotationFromAccessor(node); if (!type) { // couldn't get type for the first accessor, try the another one - var anotherAccessor = node.kind === 143 /* GetAccessor */ ? accessors.setAccessor : accessors.getAccessor; + var anotherAccessor = node.kind === 145 /* GetAccessor */ ? accessors.setAccessor : accessors.getAccessor; type = getTypeAnnotationFromAccessor(anotherAccessor); if (type) { accessorWithTypeAnnotation = anotherAccessor; @@ -28160,7 +28740,7 @@ var ts; } function getTypeAnnotationFromAccessor(accessor) { if (accessor) { - return accessor.kind === 143 /* GetAccessor */ + return accessor.kind === 145 /* GetAccessor */ ? accessor.type // Getter - return type : accessor.parameters.length > 0 ? accessor.parameters[0].type // Setter parameter type @@ -28169,7 +28749,7 @@ var ts; } function getAccessorDeclarationTypeVisibilityError(symbolAccesibilityResult) { var diagnosticMessage; - if (accessorWithTypeAnnotation.kind === 144 /* SetAccessor */) { + if (accessorWithTypeAnnotation.kind === 146 /* SetAccessor */) { // Setters have to have type named and cannot infer it so, the type should always be named if (accessorWithTypeAnnotation.parent.flags & 128 /* Static */) { diagnosticMessage = symbolAccesibilityResult.errorModuleName ? @@ -28219,17 +28799,17 @@ var ts; // so no need to verify if the declaration is visible if (!resolver.isImplementationOfOverload(node)) { emitJsDocComments(node); - if (node.kind === 211 /* FunctionDeclaration */) { + if (node.kind === 213 /* FunctionDeclaration */) { emitModuleElementDeclarationFlags(node); } - else if (node.kind === 141 /* MethodDeclaration */) { + else if (node.kind === 143 /* MethodDeclaration */) { emitClassMemberDeclarationFlags(node); } - if (node.kind === 211 /* FunctionDeclaration */) { + if (node.kind === 213 /* FunctionDeclaration */) { write("function "); writeTextOfNode(currentSourceFile, node.name); } - else if (node.kind === 142 /* Constructor */) { + else if (node.kind === 144 /* Constructor */) { write("constructor"); } else { @@ -28247,11 +28827,11 @@ var ts; } function emitSignatureDeclaration(node) { // Construct signature or constructor type write new Signature - if (node.kind === 146 /* ConstructSignature */ || node.kind === 151 /* ConstructorType */) { + if (node.kind === 148 /* ConstructSignature */ || node.kind === 153 /* ConstructorType */) { write("new "); } emitTypeParameters(node.typeParameters); - if (node.kind === 147 /* IndexSignature */) { + if (node.kind === 149 /* IndexSignature */) { write("["); } else { @@ -28261,22 +28841,22 @@ var ts; enclosingDeclaration = node; // Parameters emitCommaList(node.parameters, emitParameterDeclaration); - if (node.kind === 147 /* IndexSignature */) { + if (node.kind === 149 /* IndexSignature */) { write("]"); } else { write(")"); } // If this is not a constructor and is not private, emit the return type - var isFunctionTypeOrConstructorType = node.kind === 150 /* FunctionType */ || node.kind === 151 /* ConstructorType */; - if (isFunctionTypeOrConstructorType || node.parent.kind === 153 /* TypeLiteral */) { + var isFunctionTypeOrConstructorType = node.kind === 152 /* FunctionType */ || node.kind === 153 /* ConstructorType */; + if (isFunctionTypeOrConstructorType || node.parent.kind === 155 /* TypeLiteral */) { // Emit type literal signature return type only if specified if (node.type) { write(isFunctionTypeOrConstructorType ? " => " : ": "); emitType(node.type); } } - else if (node.kind !== 142 /* Constructor */ && !(node.flags & 32 /* Private */)) { + else if (node.kind !== 144 /* Constructor */ && !(node.flags & 32 /* Private */)) { writeReturnTypeAtSignature(node, getReturnTypeVisibilityError); } enclosingDeclaration = prevEnclosingDeclaration; @@ -28287,26 +28867,26 @@ var ts; function getReturnTypeVisibilityError(symbolAccesibilityResult) { var diagnosticMessage; switch (node.kind) { - case 146 /* ConstructSignature */: + case 148 /* ConstructSignature */: // Interfaces cannot have return types that cannot be named diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_0; break; - case 145 /* CallSignature */: + case 147 /* CallSignature */: // Interfaces cannot have return types that cannot be named diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_call_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_call_signature_from_exported_interface_has_or_is_using_private_name_0; break; - case 147 /* IndexSignature */: + case 149 /* IndexSignature */: // Interfaces cannot have return types that cannot be named diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_index_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_index_signature_from_exported_interface_has_or_is_using_private_name_0; break; - case 141 /* MethodDeclaration */: - case 140 /* MethodSignature */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: if (node.flags & 128 /* Static */) { diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? @@ -28314,7 +28894,7 @@ var ts; ts.Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_private_name_0; } - else if (node.parent.kind === 212 /* ClassDeclaration */) { + else if (node.parent.kind === 214 /* ClassDeclaration */) { diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : @@ -28328,7 +28908,7 @@ var ts; ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0; } break; - case 211 /* FunctionDeclaration */: + case 213 /* FunctionDeclaration */: diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : @@ -28363,9 +28943,9 @@ var ts; write("?"); } decreaseIndent(); - if (node.parent.kind === 150 /* FunctionType */ || - node.parent.kind === 151 /* ConstructorType */ || - node.parent.parent.kind === 153 /* TypeLiteral */) { + if (node.parent.kind === 152 /* FunctionType */ || + node.parent.kind === 153 /* ConstructorType */ || + node.parent.parent.kind === 155 /* TypeLiteral */) { emitTypeOfVariableDeclarationFromTypeLiteral(node); } else if (!(node.parent.flags & 32 /* Private */)) { @@ -28381,24 +28961,24 @@ var ts; } function getParameterDeclarationTypeVisibilityDiagnosticMessage(symbolAccesibilityResult) { switch (node.parent.kind) { - case 142 /* Constructor */: + case 144 /* Constructor */: return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_private_name_1; - case 146 /* ConstructSignature */: + case 148 /* ConstructSignature */: // Interfaces cannot have parameter types that cannot be named return symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; - case 145 /* CallSignature */: + case 147 /* CallSignature */: // Interfaces cannot have parameter types that cannot be named return symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; - case 141 /* MethodDeclaration */: - case 140 /* MethodSignature */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: if (node.parent.flags & 128 /* Static */) { return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? @@ -28406,7 +28986,7 @@ var ts; ts.Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.parent.kind === 212 /* ClassDeclaration */) { + else if (node.parent.parent.kind === 214 /* ClassDeclaration */) { return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -28419,7 +28999,7 @@ var ts; ts.Diagnostics.Parameter_0_of_method_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1; } - case 211 /* FunctionDeclaration */: + case 213 /* FunctionDeclaration */: return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -28431,12 +29011,12 @@ var ts; } function emitBindingPattern(bindingPattern) { // We have to explicitly emit square bracket and bracket because these tokens are not store inside the node. - if (bindingPattern.kind === 159 /* ObjectBindingPattern */) { + if (bindingPattern.kind === 161 /* ObjectBindingPattern */) { write("{"); emitCommaList(bindingPattern.elements, emitBindingElement); write("}"); } - else if (bindingPattern.kind === 160 /* ArrayBindingPattern */) { + else if (bindingPattern.kind === 162 /* ArrayBindingPattern */) { write("["); var elements = bindingPattern.elements; emitCommaList(elements, emitBindingElement); @@ -28455,7 +29035,7 @@ var ts; typeName: bindingElement.name } : undefined; } - if (bindingElement.kind === 185 /* OmittedExpression */) { + if (bindingElement.kind === 187 /* OmittedExpression */) { // If bindingElement is an omittedExpression (i.e. containing elision), // we will emit blank space (although this may differ from users' original code, // it allows emitSeparatedList to write separator appropriately) @@ -28464,7 +29044,7 @@ var ts; // emit : function foo([ , x, , ]) {} write(" "); } - else if (bindingElement.kind === 161 /* BindingElement */) { + else if (bindingElement.kind === 163 /* BindingElement */) { if (bindingElement.propertyName) { // bindingElement has propertyName property in the following case: // { y: [a,b,c] ...} -> bindingPattern will have a property called propertyName for "y" @@ -28487,7 +29067,7 @@ var ts; emitBindingPattern(bindingElement.name); } else { - ts.Debug.assert(bindingElement.name.kind === 67 /* Identifier */); + ts.Debug.assert(bindingElement.name.kind === 69 /* Identifier */); // If the node is just an identifier, we will simply emit the text associated with the node's name // Example: // original: function foo({y = 10, x}) {} @@ -28503,40 +29083,40 @@ var ts; } function emitNode(node) { switch (node.kind) { - case 211 /* FunctionDeclaration */: - case 216 /* ModuleDeclaration */: - case 219 /* ImportEqualsDeclaration */: - case 213 /* InterfaceDeclaration */: - case 212 /* ClassDeclaration */: - case 214 /* TypeAliasDeclaration */: - case 215 /* EnumDeclaration */: + case 213 /* FunctionDeclaration */: + case 218 /* ModuleDeclaration */: + case 221 /* ImportEqualsDeclaration */: + case 215 /* InterfaceDeclaration */: + case 214 /* ClassDeclaration */: + case 216 /* TypeAliasDeclaration */: + case 217 /* EnumDeclaration */: return emitModuleElement(node, isModuleElementVisible(node)); - case 191 /* VariableStatement */: + case 193 /* VariableStatement */: return emitModuleElement(node, isVariableStatementVisible(node)); - case 220 /* ImportDeclaration */: + case 222 /* ImportDeclaration */: // Import declaration without import clause is visible, otherwise it is not visible return emitModuleElement(node, /*isModuleElementVisible*/ !node.importClause); - case 226 /* ExportDeclaration */: + case 228 /* ExportDeclaration */: return emitExportDeclaration(node); - case 142 /* Constructor */: - case 141 /* MethodDeclaration */: - case 140 /* MethodSignature */: + case 144 /* Constructor */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: return writeFunctionDeclaration(node); - case 146 /* ConstructSignature */: - case 145 /* CallSignature */: - case 147 /* IndexSignature */: + case 148 /* ConstructSignature */: + case 147 /* CallSignature */: + case 149 /* IndexSignature */: return emitSignatureDeclarationWithJsDocComments(node); - case 143 /* GetAccessor */: - case 144 /* SetAccessor */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: return emitAccessorDeclaration(node); - case 139 /* PropertyDeclaration */: - case 138 /* PropertySignature */: + case 141 /* PropertyDeclaration */: + case 140 /* PropertySignature */: return emitPropertyDeclaration(node); - case 245 /* EnumMember */: + case 247 /* EnumMember */: return emitEnumMemberDeclaration(node); - case 225 /* ExportAssignment */: + case 227 /* ExportAssignment */: return emitExportAssignment(node); - case 246 /* SourceFile */: + case 248 /* SourceFile */: return emitSourceFile(node); } } @@ -28587,6425 +29167,6 @@ var ts; return ts.isExternalModule(sourceFile) || ts.isDeclarationFile(sourceFile); } ts.isExternalModuleOrDeclarationFile = isExternalModuleOrDeclarationFile; - // Flags enum to track count of temp variables and a few dedicated names - var TempFlags; - (function (TempFlags) { - TempFlags[TempFlags["Auto"] = 0] = "Auto"; - TempFlags[TempFlags["CountMask"] = 268435455] = "CountMask"; - TempFlags[TempFlags["_i"] = 268435456] = "_i"; - })(TempFlags || (TempFlags = {})); - // 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) { - // emit output for the __extends helper function - var extendsHelper = "\nvar __extends = (this && this.__extends) || function (d, b) {\n for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];\n function __() { this.constructor = d; }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n};"; - // emit output for the __decorate helper function - var decorateHelper = "\nvar __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") return Reflect.decorate(decorators, target, key, desc);\n switch (arguments.length) {\n case 2: return decorators.reduceRight(function(o, d) { return (d && d(o)) || o; }, target);\n case 3: return decorators.reduceRight(function(o, d) { return (d && d(target, key)), void 0; }, void 0);\n case 4: return decorators.reduceRight(function(o, d) { return (d && d(target, key, o)) || o; }, desc);\n }\n};"; - // emit output for the __metadata helper function - var metadataHelper = "\nvar __metadata = (this && this.__metadata) || function (k, v) {\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(k, v);\n};"; - // emit output for the __param helper function - var paramHelper = "\nvar __param = (this && this.__param) || function (paramIndex, decorator) {\n return function (target, key) { decorator(target, key, paramIndex); }\n};"; - var awaiterHelper = "\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promise, generator) {\n return new Promise(function (resolve, reject) {\n generator = generator.call(thisArg, _arguments);\n function cast(value) { return value instanceof Promise && value.constructor === Promise ? value : new Promise(function (resolve) { resolve(value); }); }\n function onfulfill(value) { try { step(\"next\", value); } catch (e) { reject(e); } }\n function onreject(value) { try { step(\"throw\", value); } catch (e) { reject(e); } }\n function step(verb, value) {\n var result = generator[verb](value);\n result.done ? resolve(result.value) : cast(result.value).then(onfulfill, onreject);\n }\n step(\"next\", void 0);\n });\n};"; - var compilerOptions = host.getCompilerOptions(); - var languageVersion = compilerOptions.target || 0 /* ES3 */; - var sourceMapDataList = compilerOptions.sourceMap || compilerOptions.inlineSourceMap ? [] : undefined; - var diagnostics = []; - var newLine = host.getNewLine(); - var jsxDesugaring = host.getCompilerOptions().jsx !== 1 /* Preserve */; - var shouldEmitJsx = function (s) { return (s.languageVariant === 1 /* JSX */ && !jsxDesugaring); }; - if (targetSourceFile === undefined) { - ts.forEach(host.getSourceFiles(), function (sourceFile) { - if (ts.shouldEmitToOwnFile(sourceFile, compilerOptions)) { - var jsFilePath = ts.getOwnEmitOutputFilePath(sourceFile, host, shouldEmitJsx(sourceFile) ? ".jsx" : ".js"); - emitFile(jsFilePath, sourceFile); - } - }); - if (compilerOptions.outFile || compilerOptions.out) { - emitFile(compilerOptions.outFile || compilerOptions.out); - } - } - else { - // targetSourceFile is specified (e.g calling emitter from language service or calling getSemanticDiagnostic from language service) - if (ts.shouldEmitToOwnFile(targetSourceFile, compilerOptions)) { - var jsFilePath = ts.getOwnEmitOutputFilePath(targetSourceFile, host, shouldEmitJsx(targetSourceFile) ? ".jsx" : ".js"); - emitFile(jsFilePath, targetSourceFile); - } - else if (!ts.isDeclarationFile(targetSourceFile) && (compilerOptions.outFile || compilerOptions.out)) { - emitFile(compilerOptions.outFile || compilerOptions.out); - } - } - // Sort and make the unique list of diagnostics - diagnostics = ts.sortAndDeduplicateDiagnostics(diagnostics); - return { - emitSkipped: false, - diagnostics: diagnostics, - sourceMaps: sourceMapDataList - }; - function isNodeDescendentOf(node, ancestor) { - while (node) { - if (node === ancestor) - return true; - node = node.parent; - } - return false; - } - function isUniqueLocalName(name, container) { - for (var node = container; isNodeDescendentOf(node, container); node = node.nextContainer) { - if (node.locals && ts.hasProperty(node.locals, name)) { - // We conservatively include alias symbols to cover cases where they're emitted as locals - if (node.locals[name].flags & (107455 /* Value */ | 1048576 /* ExportValue */ | 8388608 /* Alias */)) { - return false; - } - } - } - return true; - } - function emitJavaScript(jsFilePath, root) { - var writer = ts.createTextWriter(newLine); - var write = writer.write, writeTextOfNode = writer.writeTextOfNode, writeLine = writer.writeLine, increaseIndent = writer.increaseIndent, decreaseIndent = writer.decreaseIndent; - var currentSourceFile; - // name of an exporter function if file is a System external module - // System.register([...], function () {...}) - // exporting in System modules looks like: - // export var x; ... x = 1 - // => - // var x;... exporter("x", x = 1) - var exportFunctionForFile; - var generatedNameSet = {}; - var nodeToGeneratedName = []; - var computedPropertyNamesToGeneratedNames; - var extendsEmitted = false; - var decorateEmitted = false; - var paramEmitted = false; - var awaiterEmitted = false; - var tempFlags = 0; - var tempVariables; - var tempParameters; - var externalImports; - var exportSpecifiers; - var exportEquals; - var hasExportStars; - /** Write emitted output to disk */ - var writeEmittedFiles = writeJavaScriptFile; - var detachedCommentsInfo; - var writeComment = ts.writeCommentRange; - /** Emit a node */ - var emit = emitNodeWithCommentsAndWithoutSourcemap; - /** Called just before starting emit of a node */ - var emitStart = function (node) { }; - /** Called once the emit of the node is done */ - var emitEnd = function (node) { }; - /** Emit the text for the given token that comes after startPos - * This by default writes the text provided with the given tokenKind - * but if optional emitFn callback is provided the text is emitted using the callback instead of default text - * @param tokenKind the kind of the token to search and emit - * @param startPos the position in the source to start searching for the token - * @param emitFn if given will be invoked to emit the text instead of actual token emit */ - var emitToken = emitTokenText; - /** Called to before starting the lexical scopes as in function/class in the emitted code because of node - * @param scopeDeclaration node that starts the lexical scope - * @param scopeName Optional name of this scope instead of deducing one from the declaration node */ - var scopeEmitStart = function (scopeDeclaration, scopeName) { }; - /** Called after coming out of the scope */ - var scopeEmitEnd = function () { }; - /** Sourcemap data that will get encoded */ - var sourceMapData; - /** If removeComments is true, no leading-comments needed to be emitted **/ - var emitLeadingCommentsOfPosition = compilerOptions.removeComments ? function (pos) { } : emitLeadingCommentsOfPositionWorker; - if (compilerOptions.sourceMap || compilerOptions.inlineSourceMap) { - initializeEmitterWithSourceMaps(); - } - if (root) { - // Do not call emit directly. It does not set the currentSourceFile. - emitSourceFile(root); - } - else { - ts.forEach(host.getSourceFiles(), function (sourceFile) { - if (!isExternalModuleOrDeclarationFile(sourceFile)) { - emitSourceFile(sourceFile); - } - }); - } - writeLine(); - writeEmittedFiles(writer.getText(), /*writeByteOrderMark*/ compilerOptions.emitBOM); - return; - function emitSourceFile(sourceFile) { - currentSourceFile = sourceFile; - exportFunctionForFile = undefined; - emit(sourceFile); - } - function isUniqueName(name) { - return !resolver.hasGlobalName(name) && - !ts.hasProperty(currentSourceFile.identifiers, name) && - !ts.hasProperty(generatedNameSet, name); - } - // Return the next available name in the pattern _a ... _z, _0, _1, ... - // TempFlags._i or TempFlags._n may be used to express a preference for that dedicated name. - // Note that names generated by makeTempVariableName and makeUniqueName will never conflict. - function makeTempVariableName(flags) { - if (flags && !(tempFlags & flags)) { - var name_19 = flags === 268435456 /* _i */ ? "_i" : "_n"; - if (isUniqueName(name_19)) { - tempFlags |= flags; - return name_19; - } - } - while (true) { - var count = tempFlags & 268435455 /* CountMask */; - tempFlags++; - // Skip over 'i' and 'n' - if (count !== 8 && count !== 13) { - var name_20 = count < 26 ? "_" + String.fromCharCode(97 /* a */ + count) : "_" + (count - 26); - if (isUniqueName(name_20)) { - return name_20; - } - } - } - } - // Generate a name that is unique within the current file and doesn't conflict with any names - // in global scope. The name is formed by adding an '_n' suffix to the specified base name, - // where n is a positive integer. Note that names generated by makeTempVariableName and - // makeUniqueName are guaranteed to never conflict. - function makeUniqueName(baseName) { - // Find the first unique 'name_n', where n is a positive number - if (baseName.charCodeAt(baseName.length - 1) !== 95 /* _ */) { - baseName += "_"; - } - var i = 1; - while (true) { - var generatedName = baseName + i; - if (isUniqueName(generatedName)) { - return generatedNameSet[generatedName] = generatedName; - } - i++; - } - } - function generateNameForModuleOrEnum(node) { - var name = node.name.text; - // Use module/enum name itself if it is unique, otherwise make a unique variation - return isUniqueLocalName(name, node) ? name : makeUniqueName(name); - } - function generateNameForImportOrExportDeclaration(node) { - var expr = ts.getExternalModuleName(node); - var baseName = expr.kind === 9 /* StringLiteral */ ? - ts.escapeIdentifier(ts.makeIdentifierFromModuleName(expr.text)) : "module"; - return makeUniqueName(baseName); - } - function generateNameForExportDefault() { - return makeUniqueName("default"); - } - function generateNameForClassExpression() { - return makeUniqueName("class"); - } - function generateNameForNode(node) { - switch (node.kind) { - case 67 /* Identifier */: - return makeUniqueName(node.text); - case 216 /* ModuleDeclaration */: - case 215 /* EnumDeclaration */: - return generateNameForModuleOrEnum(node); - case 220 /* ImportDeclaration */: - case 226 /* ExportDeclaration */: - return generateNameForImportOrExportDeclaration(node); - case 211 /* FunctionDeclaration */: - case 212 /* ClassDeclaration */: - case 225 /* ExportAssignment */: - return generateNameForExportDefault(); - case 184 /* ClassExpression */: - return generateNameForClassExpression(); - } - } - function getGeneratedNameForNode(node) { - var id = ts.getNodeId(node); - return nodeToGeneratedName[id] || (nodeToGeneratedName[id] = ts.unescapeIdentifier(generateNameForNode(node))); - } - function initializeEmitterWithSourceMaps() { - var sourceMapDir; // The directory in which sourcemap will be - // Current source map file and its index in the sources list - var sourceMapSourceIndex = -1; - // Names and its index map - var sourceMapNameIndexMap = {}; - var sourceMapNameIndices = []; - function getSourceMapNameIndex() { - return sourceMapNameIndices.length ? ts.lastOrUndefined(sourceMapNameIndices) : -1; - } - // Last recorded and encoded spans - var lastRecordedSourceMapSpan; - var lastEncodedSourceMapSpan = { - emittedLine: 1, - emittedColumn: 1, - sourceLine: 1, - sourceColumn: 1, - sourceIndex: 0 - }; - var lastEncodedNameIndex = 0; - // Encoding for sourcemap span - function encodeLastRecordedSourceMapSpan() { - if (!lastRecordedSourceMapSpan || lastRecordedSourceMapSpan === lastEncodedSourceMapSpan) { - return; - } - var prevEncodedEmittedColumn = lastEncodedSourceMapSpan.emittedColumn; - // Line/Comma delimiters - if (lastEncodedSourceMapSpan.emittedLine === lastRecordedSourceMapSpan.emittedLine) { - // Emit comma to separate the entry - if (sourceMapData.sourceMapMappings) { - sourceMapData.sourceMapMappings += ","; - } - } - else { - // Emit line delimiters - for (var encodedLine = lastEncodedSourceMapSpan.emittedLine; encodedLine < lastRecordedSourceMapSpan.emittedLine; encodedLine++) { - sourceMapData.sourceMapMappings += ";"; - } - prevEncodedEmittedColumn = 1; - } - // 1. Relative Column 0 based - sourceMapData.sourceMapMappings += base64VLQFormatEncode(lastRecordedSourceMapSpan.emittedColumn - prevEncodedEmittedColumn); - // 2. Relative sourceIndex - sourceMapData.sourceMapMappings += base64VLQFormatEncode(lastRecordedSourceMapSpan.sourceIndex - lastEncodedSourceMapSpan.sourceIndex); - // 3. Relative sourceLine 0 based - sourceMapData.sourceMapMappings += base64VLQFormatEncode(lastRecordedSourceMapSpan.sourceLine - lastEncodedSourceMapSpan.sourceLine); - // 4. Relative sourceColumn 0 based - sourceMapData.sourceMapMappings += base64VLQFormatEncode(lastRecordedSourceMapSpan.sourceColumn - lastEncodedSourceMapSpan.sourceColumn); - // 5. Relative namePosition 0 based - if (lastRecordedSourceMapSpan.nameIndex >= 0) { - sourceMapData.sourceMapMappings += base64VLQFormatEncode(lastRecordedSourceMapSpan.nameIndex - lastEncodedNameIndex); - lastEncodedNameIndex = lastRecordedSourceMapSpan.nameIndex; - } - lastEncodedSourceMapSpan = lastRecordedSourceMapSpan; - sourceMapData.sourceMapDecodedMappings.push(lastEncodedSourceMapSpan); - function base64VLQFormatEncode(inValue) { - function base64FormatEncode(inValue) { - if (inValue < 64) { - return "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(inValue); - } - throw TypeError(inValue + ": not a 64 based value"); - } - // Add a new least significant bit that has the sign of the value. - // if negative number the least significant bit that gets added to the number has value 1 - // else least significant bit value that gets added is 0 - // eg. -1 changes to binary : 01 [1] => 3 - // +1 changes to binary : 01 [0] => 2 - if (inValue < 0) { - inValue = ((-inValue) << 1) + 1; - } - else { - inValue = inValue << 1; - } - // Encode 5 bits at a time starting from least significant bits - var encodedStr = ""; - do { - var currentDigit = inValue & 31; // 11111 - inValue = inValue >> 5; - if (inValue > 0) { - // There are still more digits to decode, set the msb (6th bit) - currentDigit = currentDigit | 32; - } - encodedStr = encodedStr + base64FormatEncode(currentDigit); - } while (inValue > 0); - return encodedStr; - } - } - function recordSourceMapSpan(pos) { - var sourceLinePos = ts.getLineAndCharacterOfPosition(currentSourceFile, pos); - // Convert the location to be one-based. - sourceLinePos.line++; - sourceLinePos.character++; - var emittedLine = writer.getLine(); - var emittedColumn = writer.getColumn(); - // If this location wasn't recorded or the location in source is going backwards, record the span - if (!lastRecordedSourceMapSpan || - lastRecordedSourceMapSpan.emittedLine !== emittedLine || - lastRecordedSourceMapSpan.emittedColumn !== emittedColumn || - (lastRecordedSourceMapSpan.sourceIndex === sourceMapSourceIndex && - (lastRecordedSourceMapSpan.sourceLine > sourceLinePos.line || - (lastRecordedSourceMapSpan.sourceLine === sourceLinePos.line && lastRecordedSourceMapSpan.sourceColumn > sourceLinePos.character)))) { - // Encode the last recordedSpan before assigning new - encodeLastRecordedSourceMapSpan(); - // New span - lastRecordedSourceMapSpan = { - emittedLine: emittedLine, - emittedColumn: emittedColumn, - sourceLine: sourceLinePos.line, - sourceColumn: sourceLinePos.character, - nameIndex: getSourceMapNameIndex(), - sourceIndex: sourceMapSourceIndex - }; - } - 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; - } - } - function recordEmitNodeStartSpan(node) { - // Get the token pos after skipping to the token (ignoring the leading trivia) - recordSourceMapSpan(ts.skipTrivia(currentSourceFile.text, node.pos)); - } - function recordEmitNodeEndSpan(node) { - recordSourceMapSpan(node.end); - } - function writeTextWithSpanRecord(tokenKind, startPos, emitFn) { - var tokenStartPos = ts.skipTrivia(currentSourceFile.text, startPos); - recordSourceMapSpan(tokenStartPos); - var tokenEndPos = emitTokenText(tokenKind, tokenStartPos, emitFn); - recordSourceMapSpan(tokenEndPos); - return tokenEndPos; - } - function recordNewSourceFileStart(node) { - // Add the file to tsFilePaths - // If sourceroot option: Use the relative path corresponding to the common directory path - // otherwise source locations relative to map file location - var sourcesDirectoryPath = compilerOptions.sourceRoot ? host.getCommonSourceDirectory() : sourceMapDir; - sourceMapData.sourceMapSources.push(ts.getRelativePathToDirectoryOrUrl(sourcesDirectoryPath, node.fileName, host.getCurrentDirectory(), host.getCanonicalFileName, - /*isAbsolutePathAnUrl*/ true)); - sourceMapSourceIndex = sourceMapData.sourceMapSources.length - 1; - // The one that can be used from program to get the actual source file - sourceMapData.inputSourceFileNames.push(node.fileName); - if (compilerOptions.inlineSources) { - if (!sourceMapData.sourceMapSourcesContent) { - sourceMapData.sourceMapSourcesContent = []; - } - sourceMapData.sourceMapSourcesContent.push(node.text); - } - } - function recordScopeNameOfNode(node, scopeName) { - function recordScopeNameIndex(scopeNameIndex) { - sourceMapNameIndices.push(scopeNameIndex); - } - function recordScopeNameStart(scopeName) { - var scopeNameIndex = -1; - if (scopeName) { - var parentIndex = getSourceMapNameIndex(); - if (parentIndex !== -1) { - // Child scopes are always shown with a dot (even if they have no name), - // unless it is a computed property. Then it is shown with brackets, - // but the brackets are included in the name. - var name_21 = node.name; - if (!name_21 || name_21.kind !== 134 /* ComputedPropertyName */) { - scopeName = "." + scopeName; - } - scopeName = sourceMapData.sourceMapNames[parentIndex] + scopeName; - } - scopeNameIndex = ts.getProperty(sourceMapNameIndexMap, scopeName); - if (scopeNameIndex === undefined) { - scopeNameIndex = sourceMapData.sourceMapNames.length; - sourceMapData.sourceMapNames.push(scopeName); - sourceMapNameIndexMap[scopeName] = scopeNameIndex; - } - } - recordScopeNameIndex(scopeNameIndex); - } - if (scopeName) { - // The scope was already given a name use it - recordScopeNameStart(scopeName); - } - else if (node.kind === 211 /* FunctionDeclaration */ || - node.kind === 171 /* FunctionExpression */ || - node.kind === 141 /* MethodDeclaration */ || - node.kind === 140 /* MethodSignature */ || - node.kind === 143 /* GetAccessor */ || - node.kind === 144 /* SetAccessor */ || - node.kind === 216 /* ModuleDeclaration */ || - node.kind === 212 /* ClassDeclaration */ || - node.kind === 215 /* EnumDeclaration */) { - // Declaration and has associated name use it - if (node.name) { - var name_22 = node.name; - // For computed property names, the text will include the brackets - scopeName = name_22.kind === 134 /* ComputedPropertyName */ - ? ts.getTextOfNode(name_22) - : node.name.text; - } - recordScopeNameStart(scopeName); - } - else { - // Block just use the name from upper level scope - recordScopeNameIndex(getSourceMapNameIndex()); - } - } - function recordScopeNameEnd() { - sourceMapNameIndices.pop(); - } - ; - function writeCommentRangeWithMap(curentSourceFile, writer, comment, newLine) { - recordSourceMapSpan(comment.pos); - ts.writeCommentRange(currentSourceFile, writer, comment, newLine); - recordSourceMapSpan(comment.end); - } - function serializeSourceMapContents(version, file, sourceRoot, sources, names, mappings, sourcesContent) { - if (typeof JSON !== "undefined") { - var map_1 = { - version: version, - file: file, - sourceRoot: sourceRoot, - sources: sources, - names: names, - mappings: mappings - }; - if (sourcesContent !== undefined) { - map_1.sourcesContent = sourcesContent; - } - return JSON.stringify(map_1); - } - return "{\"version\":" + version + ",\"file\":\"" + ts.escapeString(file) + "\",\"sourceRoot\":\"" + ts.escapeString(sourceRoot) + "\",\"sources\":[" + serializeStringArray(sources) + "],\"names\":[" + serializeStringArray(names) + "],\"mappings\":\"" + ts.escapeString(mappings) + "\" " + (sourcesContent !== undefined ? ",\"sourcesContent\":[" + serializeStringArray(sourcesContent) + "]" : "") + "}"; - function serializeStringArray(list) { - var output = ""; - for (var i = 0, n = list.length; i < n; i++) { - if (i) { - output += ","; - } - output += "\"" + ts.escapeString(list[i]) + "\""; - } - return output; - } - } - function writeJavaScriptAndSourceMapFile(emitOutput, writeByteOrderMark) { - encodeLastRecordedSourceMapSpan(); - var sourceMapText = serializeSourceMapContents(3, sourceMapData.sourceMapFile, sourceMapData.sourceMapSourceRoot, sourceMapData.sourceMapSources, sourceMapData.sourceMapNames, sourceMapData.sourceMapMappings, sourceMapData.sourceMapSourcesContent); - sourceMapDataList.push(sourceMapData); - var sourceMapUrl; - if (compilerOptions.inlineSourceMap) { - // Encode the sourceMap into the sourceMap url - var base64SourceMapText = ts.convertToBase64(sourceMapText); - sourceMapUrl = "//# sourceMappingURL=data:application/json;base64," + base64SourceMapText; - } - else { - // Write source map file - ts.writeFile(host, diagnostics, sourceMapData.sourceMapFilePath, sourceMapText, /*writeByteOrderMark*/ false); - sourceMapUrl = "//# sourceMappingURL=" + sourceMapData.jsSourceMappingURL; - } - // Write sourcemap url to the js file and write the js file - writeJavaScriptFile(emitOutput + sourceMapUrl, writeByteOrderMark); - } - // Initialize source map data - var sourceMapJsFile = ts.getBaseFileName(ts.normalizeSlashes(jsFilePath)); - sourceMapData = { - sourceMapFilePath: jsFilePath + ".map", - jsSourceMappingURL: sourceMapJsFile + ".map", - sourceMapFile: sourceMapJsFile, - sourceMapSourceRoot: compilerOptions.sourceRoot || "", - sourceMapSources: [], - inputSourceFileNames: [], - sourceMapNames: [], - sourceMapMappings: "", - sourceMapSourcesContent: undefined, - sourceMapDecodedMappings: [] - }; - // Normalize source root and make sure it has trailing "/" so that it can be used to combine paths with the - // relative paths of the sources list in the sourcemap - sourceMapData.sourceMapSourceRoot = ts.normalizeSlashes(sourceMapData.sourceMapSourceRoot); - if (sourceMapData.sourceMapSourceRoot.length && sourceMapData.sourceMapSourceRoot.charCodeAt(sourceMapData.sourceMapSourceRoot.length - 1) !== 47 /* slash */) { - sourceMapData.sourceMapSourceRoot += ts.directorySeparator; - } - if (compilerOptions.mapRoot) { - sourceMapDir = ts.normalizeSlashes(compilerOptions.mapRoot); - if (root) { - // For modules or multiple emit files the mapRoot will have directory structure like the sources - // So if src\a.ts and src\lib\b.ts are compiled together user would be moving the maps into mapRoot\a.js.map and mapRoot\lib\b.js.map - sourceMapDir = ts.getDirectoryPath(ts.getSourceFilePathInNewDir(root, host, sourceMapDir)); - } - if (!ts.isRootedDiskPath(sourceMapDir) && !ts.isUrl(sourceMapDir)) { - // The relative paths are relative to the common directory - sourceMapDir = ts.combinePaths(host.getCommonSourceDirectory(), sourceMapDir); - sourceMapData.jsSourceMappingURL = ts.getRelativePathToDirectoryOrUrl(ts.getDirectoryPath(ts.normalizePath(jsFilePath)), // get the relative sourceMapDir path based on jsFilePath - ts.combinePaths(sourceMapDir, sourceMapData.jsSourceMappingURL), // this is where user expects to see sourceMap - host.getCurrentDirectory(), host.getCanonicalFileName, - /*isAbsolutePathAnUrl*/ true); - } - else { - sourceMapData.jsSourceMappingURL = ts.combinePaths(sourceMapDir, sourceMapData.jsSourceMappingURL); - } - } - else { - sourceMapDir = ts.getDirectoryPath(ts.normalizePath(jsFilePath)); - } - function emitNodeWithSourceMap(node) { - if (node) { - if (ts.nodeIsSynthesized(node)) { - return emitNodeWithoutSourceMap(node); - } - if (node.kind !== 246 /* SourceFile */) { - recordEmitNodeStartSpan(node); - emitNodeWithoutSourceMap(node); - recordEmitNodeEndSpan(node); - } - else { - recordNewSourceFileStart(node); - emitNodeWithoutSourceMap(node); - } - } - } - function emitNodeWithCommentsAndWithSourcemap(node) { - emitNodeConsideringCommentsOption(node, emitNodeWithSourceMap); - } - writeEmittedFiles = writeJavaScriptAndSourceMapFile; - emit = emitNodeWithCommentsAndWithSourcemap; - emitStart = recordEmitNodeStartSpan; - emitEnd = recordEmitNodeEndSpan; - emitToken = writeTextWithSpanRecord; - scopeEmitStart = recordScopeNameOfNode; - scopeEmitEnd = recordScopeNameEnd; - writeComment = writeCommentRangeWithMap; - } - function writeJavaScriptFile(emitOutput, writeByteOrderMark) { - ts.writeFile(host, diagnostics, jsFilePath, emitOutput, writeByteOrderMark); - } - // Create a temporary variable with a unique unused name. - function createTempVariable(flags) { - var result = ts.createSynthesizedNode(67 /* Identifier */); - result.text = makeTempVariableName(flags); - return result; - } - function recordTempDeclaration(name) { - if (!tempVariables) { - tempVariables = []; - } - tempVariables.push(name); - } - function createAndRecordTempVariable(flags) { - var temp = createTempVariable(flags); - recordTempDeclaration(temp); - return temp; - } - function emitTempDeclarations(newLine) { - if (tempVariables) { - if (newLine) { - writeLine(); - } - else { - write(" "); - } - write("var "); - emitCommaList(tempVariables); - write(";"); - } - } - function emitTokenText(tokenKind, startPos, emitFn) { - var tokenString = ts.tokenToString(tokenKind); - if (emitFn) { - emitFn(); - } - else { - write(tokenString); - } - return startPos + tokenString.length; - } - function emitOptional(prefix, node) { - if (node) { - write(prefix); - emit(node); - } - } - function emitParenthesizedIf(node, parenthesized) { - if (parenthesized) { - write("("); - } - emit(node); - if (parenthesized) { - write(")"); - } - } - function emitTrailingCommaIfPresent(nodeList) { - if (nodeList.hasTrailingComma) { - write(","); - } - } - function emitLinePreservingList(parent, nodes, allowTrailingComma, spacesBetweenBraces) { - ts.Debug.assert(nodes.length > 0); - increaseIndent(); - if (nodeStartPositionsAreOnSameLine(parent, nodes[0])) { - if (spacesBetweenBraces) { - write(" "); - } - } - else { - writeLine(); - } - for (var i = 0, n = nodes.length; i < n; i++) { - if (i) { - if (nodeEndIsOnSameLineAsNodeStart(nodes[i - 1], nodes[i])) { - write(", "); - } - else { - write(","); - writeLine(); - } - } - emit(nodes[i]); - } - if (nodes.hasTrailingComma && allowTrailingComma) { - write(","); - } - decreaseIndent(); - if (nodeEndPositionsAreOnSameLine(parent, ts.lastOrUndefined(nodes))) { - if (spacesBetweenBraces) { - write(" "); - } - } - else { - writeLine(); - } - } - function emitList(nodes, start, count, multiLine, trailingComma, leadingComma, noTrailingNewLine, emitNode) { - if (!emitNode) { - emitNode = emit; - } - for (var i = 0; i < count; i++) { - if (multiLine) { - if (i || leadingComma) { - write(","); - } - writeLine(); - } - else { - if (i || leadingComma) { - write(", "); - } - } - var node = nodes[start + i]; - // This emitting is to make sure we emit following comment properly - // ...(x, /*comment1*/ y)... - // ^ => node.pos - // "comment1" is not considered leading comment for "y" but rather - // considered as trailing comment of the previous node. - emitTrailingCommentsOfPosition(node.pos); - emitNode(node); - leadingComma = true; - } - if (trailingComma) { - write(","); - } - if (multiLine && !noTrailingNewLine) { - writeLine(); - } - return count; - } - function emitCommaList(nodes) { - if (nodes) { - emitList(nodes, 0, nodes.length, /*multiline*/ false, /*trailingComma*/ false); - } - } - function emitLines(nodes) { - emitLinesStartingAt(nodes, /*startIndex*/ 0); - } - function emitLinesStartingAt(nodes, startIndex) { - for (var i = startIndex; i < nodes.length; i++) { - writeLine(); - emit(nodes[i]); - } - } - function isBinaryOrOctalIntegerLiteral(node, text) { - if (node.kind === 8 /* NumericLiteral */ && text.length > 1) { - switch (text.charCodeAt(1)) { - case 98 /* b */: - case 66 /* B */: - case 111 /* o */: - case 79 /* O */: - return true; - } - } - return false; - } - function emitLiteral(node) { - var text = getLiteralText(node); - if ((compilerOptions.sourceMap || compilerOptions.inlineSourceMap) && (node.kind === 9 /* StringLiteral */ || ts.isTemplateLiteralKind(node.kind))) { - writer.writeLiteral(text); - } - else if (languageVersion < 2 /* ES6 */ && isBinaryOrOctalIntegerLiteral(node, text)) { - write(node.text); - } - else { - write(text); - } - } - function getLiteralText(node) { - // 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 */ && (ts.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 (node.parent) { - return ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, node); - } - // If we can't reach the original source text, use the canonical form if it's a number, - // or an escaped quoted form of the original text if it's string-like. - switch (node.kind) { - case 9 /* StringLiteral */: - return getQuotedEscapedLiteralText("\"", node.text, "\""); - case 11 /* NoSubstitutionTemplateLiteral */: - return getQuotedEscapedLiteralText("`", node.text, "`"); - case 12 /* TemplateHead */: - return getQuotedEscapedLiteralText("`", node.text, "${"); - case 13 /* TemplateMiddle */: - return getQuotedEscapedLiteralText("}", node.text, "${"); - case 14 /* TemplateTail */: - return getQuotedEscapedLiteralText("}", node.text, "`"); - case 8 /* NumericLiteral */: - return node.text; - } - ts.Debug.fail("Literal kind '" + node.kind + "' not accounted for."); - } - function getQuotedEscapedLiteralText(leftQuote, text, rightQuote) { - return leftQuote + ts.escapeNonAsciiCharacters(ts.escapeString(text)) + rightQuote; - } - function emitDownlevelRawTemplateLiteral(node) { - // 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"); - text = ts.escapeString(text); - write("\"" + text + "\""); - } - function emitDownlevelTaggedTemplateArray(node, literalEmitter) { - write("["); - if (node.template.kind === 11 /* NoSubstitutionTemplateLiteral */) { - literalEmitter(node.template); - } - else { - literalEmitter(node.template.head); - ts.forEach(node.template.templateSpans, function (child) { - write(", "); - literalEmitter(child.literal); - }); - } - write("]"); - } - function emitDownlevelTaggedTemplate(node) { - var tempVariable = createAndRecordTempVariable(0 /* Auto */); - write("("); - emit(tempVariable); - write(" = "); - emitDownlevelTaggedTemplateArray(node, emit); - write(", "); - emit(tempVariable); - write(".raw = "); - emitDownlevelTaggedTemplateArray(node, emitDownlevelRawTemplateLiteral); - write(", "); - emitParenthesizedIf(node.tag, needsParenthesisForPropertyAccessOrInvocation(node.tag)); - write("("); - emit(tempVariable); - // Now we emit the expressions - if (node.template.kind === 181 /* TemplateExpression */) { - ts.forEach(node.template.templateSpans, function (templateSpan) { - write(", "); - var needsParens = templateSpan.expression.kind === 179 /* BinaryExpression */ - && templateSpan.expression.operatorToken.kind === 24 /* CommaToken */; - emitParenthesizedIf(templateSpan.expression, needsParens); - }); - } - write("))"); - } - function emitTemplateExpression(node) { - // In ES6 mode and above, we can simply emit each portion of a template in order, but in - // ES3 & ES5 we must convert the template expression into a series of string concatenations. - if (languageVersion >= 2 /* ES6 */) { - ts.forEachChild(node, emit); - return; - } - var emitOuterParens = ts.isExpression(node.parent) - && templateNeedsParens(node, node.parent); - if (emitOuterParens) { - write("("); - } - var headEmitted = false; - if (shouldEmitTemplateHead()) { - emitLiteral(node.head); - headEmitted = true; - } - for (var i = 0, n = node.templateSpans.length; i < n; i++) { - var templateSpan = node.templateSpans[i]; - // Check if the expression has operands and binds its operands less closely than binary '+'. - // If it does, we need to wrap 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 needsParens = templateSpan.expression.kind !== 170 /* ParenthesizedExpression */ - && comparePrecedenceToBinaryPlus(templateSpan.expression) !== 1 /* GreaterThan */; - if (i > 0 || headEmitted) { - // If this is the first span and the head was not emitted, then this templateSpan's - // expression will be the first to be emitted. Don't emit the preceding ' + ' in that - // case. - write(" + "); - } - emitParenthesizedIf(templateSpan.expression, needsParens); - // 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 (templateSpan.literal.text.length !== 0) { - write(" + "); - emitLiteral(templateSpan.literal); - } - } - if (emitOuterParens) { - write(")"); - } - function shouldEmitTemplateHead() { - // If this expression has an empty head literal and the first template span has a non-empty - // literal, then emitting the empty head literal is not necessary. - // `${ foo } and ${ bar }` - // can be emitted as - // foo + " and " + bar - // This is because it is only required that one of the first two operands in the emit - // output must be a string literal, so that the other operand and all following operands - // are forced into strings. - // - // If the first template span has an empty literal, then the head must still be emitted. - // `${ foo }${ bar }` - // must still be emitted as - // "" + foo + bar - // 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; - } - function templateNeedsParens(template, parent) { - switch (parent.kind) { - case 166 /* CallExpression */: - case 167 /* NewExpression */: - return parent.expression === template; - case 168 /* TaggedTemplateExpression */: - case 170 /* ParenthesizedExpression */: - return false; - default: - return comparePrecedenceToBinaryPlus(parent) !== -1 /* LessThan */; - } - } - /** - * Returns whether the expression has lesser, greater, - * or equal precedence to the binary '+' operator - */ - function comparePrecedenceToBinaryPlus(expression) { - // All binary expressions have lower precedence than '+' apart from '*', '/', and '%' - // which have greater precedence and '-' which has equal precedence. - // All unary operators have a higher precedence apart from yield. - // Arrow functions and conditionals have a lower precedence, - // although we convert the former into regular function expressions in ES5 mode, - // and in ES6 mode this function won't get called anyway. - // - // TODO (drosen): Note that we need to account for the upcoming 'yield' and - // spread ('...') unary operators that are anticipated for ES6. - switch (expression.kind) { - case 179 /* BinaryExpression */: - switch (expression.operatorToken.kind) { - case 37 /* AsteriskToken */: - case 38 /* SlashToken */: - case 39 /* PercentToken */: - return 1 /* GreaterThan */; - case 35 /* PlusToken */: - case 36 /* MinusToken */: - return 0 /* EqualTo */; - default: - return -1 /* LessThan */; - } - case 182 /* YieldExpression */: - case 180 /* ConditionalExpression */: - return -1 /* LessThan */; - default: - return 1 /* GreaterThan */; - } - } - } - function emitTemplateSpan(span) { - emit(span.expression); - emit(span.literal); - } - function jsxEmitReact(node) { - /// Emit a tag name, which is either '"div"' for lower-cased names, or - /// 'Div' for upper-cased or dotted names - function emitTagName(name) { - if (name.kind === 67 /* Identifier */ && ts.isIntrinsicJsxName(name.text)) { - write("\""); - emit(name); - write("\""); - } - else { - emit(name); - } - } - /// Emit an attribute name, which is quoted if it needs to be quoted. Because - /// these emit into an object literal property name, we don't need to be worried - /// about keywords, just non-identifier characters - function emitAttributeName(name) { - if (/[A-Za-z_]+[\w*]/.test(name.text)) { - write("\""); - emit(name); - write("\""); - } - else { - emit(name); - } - } - /// Emit an name/value pair for an attribute (e.g. "x: 3") - function emitJsxAttribute(node) { - emitAttributeName(node.name); - write(": "); - if (node.initializer) { - emit(node.initializer); - } - else { - write("true"); - } - } - function emitJsxElement(openingNode, children) { - var syntheticReactRef = ts.createSynthesizedNode(67 /* Identifier */); - syntheticReactRef.text = 'React'; - syntheticReactRef.parent = openingNode; - // Call React.createElement(tag, ... - emitLeadingComments(openingNode); - emitExpressionIdentifier(syntheticReactRef); - write(".createElement("); - emitTagName(openingNode.tagName); - write(", "); - // Attribute list - if (openingNode.attributes.length === 0) { - // When there are no attributes, React wants "null" - write("null"); - } - else { - // Either emit one big object literal (no spread attribs), or - // a call to React.__spread - var attrs = openingNode.attributes; - if (ts.forEach(attrs, function (attr) { return attr.kind === 237 /* JsxSpreadAttribute */; })) { - emitExpressionIdentifier(syntheticReactRef); - write(".__spread("); - var haveOpenedObjectLiteral = false; - for (var i_1 = 0; i_1 < attrs.length; i_1++) { - if (attrs[i_1].kind === 237 /* JsxSpreadAttribute */) { - // If this is the first argument, we need to emit a {} as the first argument - if (i_1 === 0) { - write("{}, "); - } - if (haveOpenedObjectLiteral) { - write("}"); - haveOpenedObjectLiteral = false; - } - if (i_1 > 0) { - write(", "); - } - emit(attrs[i_1].expression); - } - else { - ts.Debug.assert(attrs[i_1].kind === 236 /* JsxAttribute */); - if (haveOpenedObjectLiteral) { - write(", "); - } - else { - haveOpenedObjectLiteral = true; - if (i_1 > 0) { - write(", "); - } - write("{"); - } - emitJsxAttribute(attrs[i_1]); - } - } - if (haveOpenedObjectLiteral) - write("}"); - write(")"); // closing paren to React.__spread( - } - else { - // One object literal with all the attributes in them - write("{"); - for (var i = 0; i < attrs.length; i++) { - if (i > 0) { - write(", "); - } - emitJsxAttribute(attrs[i]); - } - write("}"); - } - } - // Children - if (children) { - for (var i = 0; i < children.length; i++) { - // Don't emit empty expressions - if (children[i].kind === 238 /* JsxExpression */ && !(children[i].expression)) { - continue; - } - // Don't emit empty strings - if (children[i].kind === 234 /* JsxText */) { - var text = getTextToEmit(children[i]); - if (text !== undefined) { - write(", \""); - write(text); - write("\""); - } - } - else { - write(", "); - emit(children[i]); - } - } - } - // Closing paren - write(")"); // closes "React.createElement(" - emitTrailingComments(openingNode); - } - if (node.kind === 231 /* JsxElement */) { - emitJsxElement(node.openingElement, node.children); - } - else { - ts.Debug.assert(node.kind === 232 /* JsxSelfClosingElement */); - emitJsxElement(node); - } - } - function jsxEmitPreserve(node) { - function emitJsxAttribute(node) { - emit(node.name); - if (node.initializer) { - write("="); - emit(node.initializer); - } - } - function emitJsxSpreadAttribute(node) { - write("{..."); - emit(node.expression); - write("}"); - } - function emitAttributes(attribs) { - for (var i = 0, n = attribs.length; i < n; i++) { - if (i > 0) { - write(" "); - } - if (attribs[i].kind === 237 /* JsxSpreadAttribute */) { - emitJsxSpreadAttribute(attribs[i]); - } - else { - ts.Debug.assert(attribs[i].kind === 236 /* JsxAttribute */); - emitJsxAttribute(attribs[i]); - } - } - } - function emitJsxOpeningOrSelfClosingElement(node) { - write("<"); - emit(node.tagName); - if (node.attributes.length > 0 || (node.kind === 232 /* JsxSelfClosingElement */)) { - write(" "); - } - emitAttributes(node.attributes); - if (node.kind === 232 /* JsxSelfClosingElement */) { - write("/>"); - } - else { - write(">"); - } - } - function emitJsxClosingElement(node) { - write(""); - } - function emitJsxElement(node) { - emitJsxOpeningOrSelfClosingElement(node.openingElement); - for (var i = 0, n = node.children.length; i < n; i++) { - emit(node.children[i]); - } - emitJsxClosingElement(node.closingElement); - } - if (node.kind === 231 /* JsxElement */) { - emitJsxElement(node); - } - else { - ts.Debug.assert(node.kind === 232 /* JsxSelfClosingElement */); - emitJsxOpeningOrSelfClosingElement(node); - } - } - // This function specifically handles numeric/string literals for enum and accessor 'identifiers'. - // In a sense, it does not actually emit identifiers as much as it declares a name for a specific property. - // For example, this is utilized when feeding in a result to Object.defineProperty. - function emitExpressionForPropertyName(node) { - ts.Debug.assert(node.kind !== 161 /* BindingElement */); - if (node.kind === 9 /* StringLiteral */) { - emitLiteral(node); - } - else if (node.kind === 134 /* ComputedPropertyName */) { - // if this is a decorated computed property, we will need to capture the result - // of the property expression so that we can apply decorators later. This is to ensure - // we don't introduce unintended side effects: - // - // class C { - // [_a = x]() { } - // } - // - // The emit for the decorated computed property decorator is: - // - // Object.defineProperty(C.prototype, _a, __decorate([dec], C.prototype, _a, Object.getOwnPropertyDescriptor(C.prototype, _a))); - // - if (ts.nodeIsDecorated(node.parent)) { - if (!computedPropertyNamesToGeneratedNames) { - computedPropertyNamesToGeneratedNames = []; - } - var generatedName = computedPropertyNamesToGeneratedNames[ts.getNodeId(node)]; - if (generatedName) { - // we have already generated a variable for this node, write that value instead. - write(generatedName); - return; - } - generatedName = createAndRecordTempVariable(0 /* Auto */).text; - computedPropertyNamesToGeneratedNames[ts.getNodeId(node)] = generatedName; - write(generatedName); - write(" = "); - } - emit(node.expression); - } - else { - write("\""); - if (node.kind === 8 /* NumericLiteral */) { - write(node.text); - } - else { - writeTextOfNode(currentSourceFile, node); - } - write("\""); - } - } - function isExpressionIdentifier(node) { - var parent = node.parent; - switch (parent.kind) { - case 162 /* ArrayLiteralExpression */: - case 179 /* BinaryExpression */: - case 166 /* CallExpression */: - case 239 /* CaseClause */: - case 134 /* ComputedPropertyName */: - case 180 /* ConditionalExpression */: - case 137 /* Decorator */: - case 173 /* DeleteExpression */: - case 195 /* DoStatement */: - case 165 /* ElementAccessExpression */: - case 225 /* ExportAssignment */: - case 193 /* ExpressionStatement */: - case 186 /* ExpressionWithTypeArguments */: - case 197 /* ForStatement */: - case 198 /* ForInStatement */: - case 199 /* ForOfStatement */: - case 194 /* IfStatement */: - case 232 /* JsxSelfClosingElement */: - case 233 /* JsxOpeningElement */: - case 237 /* JsxSpreadAttribute */: - case 238 /* JsxExpression */: - case 167 /* NewExpression */: - case 170 /* ParenthesizedExpression */: - case 178 /* PostfixUnaryExpression */: - case 177 /* PrefixUnaryExpression */: - case 202 /* ReturnStatement */: - case 244 /* ShorthandPropertyAssignment */: - case 183 /* SpreadElementExpression */: - case 204 /* SwitchStatement */: - case 168 /* TaggedTemplateExpression */: - case 188 /* TemplateSpan */: - case 206 /* ThrowStatement */: - case 169 /* TypeAssertionExpression */: - case 174 /* TypeOfExpression */: - case 175 /* VoidExpression */: - case 196 /* WhileStatement */: - case 203 /* WithStatement */: - case 182 /* YieldExpression */: - return true; - case 161 /* BindingElement */: - case 245 /* EnumMember */: - case 136 /* Parameter */: - case 243 /* PropertyAssignment */: - case 139 /* PropertyDeclaration */: - case 209 /* VariableDeclaration */: - return parent.initializer === node; - case 164 /* PropertyAccessExpression */: - return parent.expression === node; - case 172 /* ArrowFunction */: - case 171 /* FunctionExpression */: - return parent.body === node; - case 219 /* ImportEqualsDeclaration */: - return parent.moduleReference === node; - case 133 /* QualifiedName */: - return parent.left === node; - } - return false; - } - function emitExpressionIdentifier(node) { - if (resolver.getNodeCheckFlags(node) & 2048 /* LexicalArguments */) { - write("_arguments"); - return; - } - var container = resolver.getReferencedExportContainer(node); - if (container) { - if (container.kind === 246 /* SourceFile */) { - // Identifier references module export - if (languageVersion < 2 /* ES6 */ && compilerOptions.module !== 4 /* System */) { - write("exports."); - } - } - else { - // Identifier references namespace export - write(getGeneratedNameForNode(container)); - write("."); - } - } - else if (languageVersion < 2 /* ES6 */) { - var declaration = resolver.getReferencedImportDeclaration(node); - if (declaration) { - if (declaration.kind === 221 /* ImportClause */) { - // Identifier references default import - write(getGeneratedNameForNode(declaration.parent)); - write(languageVersion === 0 /* ES3 */ ? "[\"default\"]" : ".default"); - return; - } - else if (declaration.kind === 224 /* ImportSpecifier */) { - // Identifier references named import - write(getGeneratedNameForNode(declaration.parent.parent.parent)); - var name = declaration.propertyName || declaration.name; - var identifier = ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, name); - if (languageVersion === 0 /* ES3 */ && identifier === "default") { - write("[\"default\"]"); - } - else { - write("."); - write(identifier); - } - return; - } - } - declaration = resolver.getReferencedNestedRedeclaration(node); - if (declaration) { - write(getGeneratedNameForNode(declaration.name)); - return; - } - } - if (ts.nodeIsSynthesized(node)) { - write(node.text); - } - else { - writeTextOfNode(currentSourceFile, node); - } - } - function isNameOfNestedRedeclaration(node) { - if (languageVersion < 2 /* ES6 */) { - var parent_6 = node.parent; - switch (parent_6.kind) { - case 161 /* BindingElement */: - case 212 /* ClassDeclaration */: - case 215 /* EnumDeclaration */: - case 209 /* VariableDeclaration */: - return parent_6.name === node && resolver.isNestedRedeclaration(parent_6); - } - } - return false; - } - function emitIdentifier(node) { - if (!node.parent) { - write(node.text); - } - else if (isExpressionIdentifier(node)) { - emitExpressionIdentifier(node); - } - else if (isNameOfNestedRedeclaration(node)) { - write(getGeneratedNameForNode(node)); - } - else if (ts.nodeIsSynthesized(node)) { - write(node.text); - } - else { - writeTextOfNode(currentSourceFile, node); - } - } - function emitThis(node) { - if (resolver.getNodeCheckFlags(node) & 2 /* LexicalThis */) { - write("_this"); - } - else { - write("this"); - } - } - function emitSuper(node) { - if (languageVersion >= 2 /* ES6 */) { - write("super"); - } - else { - var flags = resolver.getNodeCheckFlags(node); - if (flags & 256 /* SuperInstance */) { - write("_super.prototype"); - } - else { - write("_super"); - } - } - } - function emitObjectBindingPattern(node) { - write("{ "); - var elements = node.elements; - emitList(elements, 0, elements.length, /*multiLine*/ false, /*trailingComma*/ elements.hasTrailingComma); - write(" }"); - } - function emitArrayBindingPattern(node) { - write("["); - var elements = node.elements; - emitList(elements, 0, elements.length, /*multiLine*/ false, /*trailingComma*/ elements.hasTrailingComma); - write("]"); - } - function emitBindingElement(node) { - if (node.propertyName) { - emit(node.propertyName); - write(": "); - } - if (node.dotDotDotToken) { - write("..."); - } - if (ts.isBindingPattern(node.name)) { - emit(node.name); - } - else { - emitModuleMemberName(node); - } - emitOptional(" = ", node.initializer); - } - function emitSpreadElementExpression(node) { - write("..."); - emit(node.expression); - } - function emitYieldExpression(node) { - write(ts.tokenToString(112 /* YieldKeyword */)); - if (node.asteriskToken) { - write("*"); - } - if (node.expression) { - write(" "); - emit(node.expression); - } - } - function emitAwaitExpression(node) { - var needsParenthesis = needsParenthesisForAwaitExpressionAsYield(node); - if (needsParenthesis) { - write("("); - } - write(ts.tokenToString(112 /* YieldKeyword */)); - write(" "); - emit(node.expression); - if (needsParenthesis) { - write(")"); - } - } - function needsParenthesisForAwaitExpressionAsYield(node) { - if (node.parent.kind === 179 /* BinaryExpression */ && !ts.isAssignmentOperator(node.parent.operatorToken.kind)) { - return true; - } - else if (node.parent.kind === 180 /* ConditionalExpression */ && node.parent.condition === node) { - return true; - } - return false; - } - function needsParenthesisForPropertyAccessOrInvocation(node) { - switch (node.kind) { - case 67 /* Identifier */: - case 162 /* ArrayLiteralExpression */: - case 164 /* PropertyAccessExpression */: - case 165 /* ElementAccessExpression */: - case 166 /* CallExpression */: - case 170 /* ParenthesizedExpression */: - // This list is not exhaustive and only includes those cases that are relevant - // to the check in emitArrayLiteral. More cases can be added as needed. - return false; - } - return true; - } - function emitListWithSpread(elements, needsUniqueCopy, multiLine, trailingComma, useConcat) { - var pos = 0; - var group = 0; - var length = elements.length; - while (pos < length) { - // Emit using the pattern .concat(, , ...) - if (group === 1 && useConcat) { - write(".concat("); - } - else if (group > 0) { - write(", "); - } - var e = elements[pos]; - if (e.kind === 183 /* SpreadElementExpression */) { - e = e.expression; - emitParenthesizedIf(e, /*parenthesized*/ group === 0 && needsParenthesisForPropertyAccessOrInvocation(e)); - pos++; - if (pos === length && group === 0 && needsUniqueCopy && e.kind !== 162 /* ArrayLiteralExpression */) { - write(".slice()"); - } - } - else { - var i = pos; - while (i < length && elements[i].kind !== 183 /* SpreadElementExpression */) { - i++; - } - write("["); - if (multiLine) { - increaseIndent(); - } - emitList(elements, pos, i - pos, multiLine, trailingComma && i === length); - if (multiLine) { - decreaseIndent(); - } - write("]"); - pos = i; - } - group++; - } - if (group > 1) { - if (useConcat) { - write(")"); - } - } - } - function isSpreadElementExpression(node) { - return node.kind === 183 /* SpreadElementExpression */; - } - function emitArrayLiteral(node) { - var elements = node.elements; - if (elements.length === 0) { - write("[]"); - } - else if (languageVersion >= 2 /* ES6 */ || !ts.forEach(elements, isSpreadElementExpression)) { - write("["); - emitLinePreservingList(node, node.elements, elements.hasTrailingComma, /*spacesBetweenBraces:*/ false); - write("]"); - } - else { - emitListWithSpread(elements, /*needsUniqueCopy*/ true, /*multiLine*/ (node.flags & 2048 /* MultiLine */) !== 0, - /*trailingComma*/ elements.hasTrailingComma, /*useConcat*/ true); - } - } - function emitObjectLiteralBody(node, numElements) { - if (numElements === 0) { - write("{}"); - return; - } - write("{"); - if (numElements > 0) { - var properties = node.properties; - // If we are not doing a downlevel transformation for object literals, - // then try to preserve the original shape of the object literal. - // Otherwise just try to preserve the formatting. - if (numElements === properties.length) { - emitLinePreservingList(node, properties, /* allowTrailingComma */ languageVersion >= 1 /* ES5 */, /* spacesBetweenBraces */ true); - } - else { - var multiLine = (node.flags & 2048 /* MultiLine */) !== 0; - if (!multiLine) { - write(" "); - } - else { - increaseIndent(); - } - emitList(properties, 0, numElements, /*multiLine*/ multiLine, /*trailingComma*/ false); - if (!multiLine) { - write(" "); - } - else { - decreaseIndent(); - } - } - } - write("}"); - } - function emitDownlevelObjectLiteralWithComputedProperties(node, firstComputedPropertyIndex) { - var multiLine = (node.flags & 2048 /* MultiLine */) !== 0; - var properties = node.properties; - write("("); - if (multiLine) { - increaseIndent(); - } - // 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 tempVar = createAndRecordTempVariable(0 /* Auto */); - // Write out the first non-computed properties - // (or all properties if none of them are computed), - // then emit the rest through indexing on the temp variable. - emit(tempVar); - write(" = "); - emitObjectLiteralBody(node, firstComputedPropertyIndex); - for (var i = firstComputedPropertyIndex, n = properties.length; i < n; i++) { - writeComma(); - var property = properties[i]; - emitStart(property); - if (property.kind === 143 /* GetAccessor */ || property.kind === 144 /* SetAccessor */) { - // TODO (drosen): Reconcile with 'emitMemberFunctions'. - var accessors = ts.getAllAccessorDeclarations(node.properties, property); - if (property !== accessors.firstAccessor) { - continue; - } - write("Object.defineProperty("); - emit(tempVar); - write(", "); - emitStart(node.name); - emitExpressionForPropertyName(property.name); - emitEnd(property.name); - write(", {"); - increaseIndent(); - if (accessors.getAccessor) { - writeLine(); - emitLeadingComments(accessors.getAccessor); - write("get: "); - emitStart(accessors.getAccessor); - write("function "); - emitSignatureAndBody(accessors.getAccessor); - emitEnd(accessors.getAccessor); - emitTrailingComments(accessors.getAccessor); - write(","); - } - if (accessors.setAccessor) { - writeLine(); - emitLeadingComments(accessors.setAccessor); - write("set: "); - emitStart(accessors.setAccessor); - write("function "); - emitSignatureAndBody(accessors.setAccessor); - emitEnd(accessors.setAccessor); - emitTrailingComments(accessors.setAccessor); - write(","); - } - writeLine(); - write("enumerable: true,"); - writeLine(); - write("configurable: true"); - decreaseIndent(); - writeLine(); - write("})"); - emitEnd(property); - } - else { - emitLeadingComments(property); - emitStart(property.name); - emit(tempVar); - emitMemberAccessForPropertyName(property.name); - emitEnd(property.name); - write(" = "); - if (property.kind === 243 /* PropertyAssignment */) { - emit(property.initializer); - } - else if (property.kind === 244 /* ShorthandPropertyAssignment */) { - emitExpressionIdentifier(property.name); - } - else if (property.kind === 141 /* MethodDeclaration */) { - emitFunctionDeclaration(property); - } - else { - ts.Debug.fail("ObjectLiteralElement type not accounted for: " + property.kind); - } - } - emitEnd(property); - } - writeComma(); - emit(tempVar); - if (multiLine) { - decreaseIndent(); - writeLine(); - } - write(")"); - function writeComma() { - if (multiLine) { - write(","); - writeLine(); - } - else { - write(", "); - } - } - } - function emitObjectLiteral(node) { - var properties = node.properties; - if (languageVersion < 2 /* ES6 */) { - var numProperties = properties.length; - // Find the first computed property. - // Everything until that point can be emitted as part of the initial object literal. - var numInitialNonComputedProperties = numProperties; - for (var i = 0, n = properties.length; i < n; i++) { - if (properties[i].name.kind === 134 /* ComputedPropertyName */) { - numInitialNonComputedProperties = i; - break; - } - } - var hasComputedProperty = numInitialNonComputedProperties !== properties.length; - if (hasComputedProperty) { - emitDownlevelObjectLiteralWithComputedProperties(node, numInitialNonComputedProperties); - return; - } - } - // Ordinary case: either the object has no computed properties - // or we're compiling with an ES6+ target. - emitObjectLiteralBody(node, properties.length); - } - function createBinaryExpression(left, operator, right, startsOnNewLine) { - var result = ts.createSynthesizedNode(179 /* BinaryExpression */, startsOnNewLine); - result.operatorToken = ts.createSynthesizedNode(operator); - result.left = left; - result.right = right; - return result; - } - function createPropertyAccessExpression(expression, name) { - var result = ts.createSynthesizedNode(164 /* PropertyAccessExpression */); - result.expression = parenthesizeForAccess(expression); - result.dotToken = ts.createSynthesizedNode(21 /* DotToken */); - result.name = name; - return result; - } - function createElementAccessExpression(expression, argumentExpression) { - var result = ts.createSynthesizedNode(165 /* ElementAccessExpression */); - result.expression = parenthesizeForAccess(expression); - result.argumentExpression = argumentExpression; - return result; - } - function parenthesizeForAccess(expr) { - // When diagnosing whether the expression needs parentheses, the decision should be based - // on the innermost expression in a chain of nested type assertions. - while (expr.kind === 169 /* TypeAssertionExpression */ || expr.kind === 187 /* AsExpression */) { - expr = expr.expression; - } - // isLeftHandSideExpression is almost the correct criterion for when it is not necessary - // to parenthesize the expression before a dot. The known exceptions are: - // - // NewExpression: - // new C.x -> not the same as (new C).x - // NumberLiteral - // 1.x -> not the same as (1).x - // - if (ts.isLeftHandSideExpression(expr) && - expr.kind !== 167 /* NewExpression */ && - expr.kind !== 8 /* NumericLiteral */) { - return expr; - } - var node = ts.createSynthesizedNode(170 /* ParenthesizedExpression */); - node.expression = expr; - return node; - } - function emitComputedPropertyName(node) { - write("["); - emitExpressionForPropertyName(node); - write("]"); - } - function emitMethod(node) { - if (languageVersion >= 2 /* ES6 */ && node.asteriskToken) { - write("*"); - } - emit(node.name); - if (languageVersion < 2 /* ES6 */) { - write(": function "); - } - emitSignatureAndBody(node); - } - function emitPropertyAssignment(node) { - emit(node.name); - write(": "); - // This is to ensure that we emit comment in the following case: - // For example: - // obj = { - // id: /*comment1*/ ()=>void - // } - // "comment1" is not considered to be leading comment for node.initializer - // but rather a trailing comment on the previous node. - emitTrailingCommentsOfPosition(node.initializer.pos); - emit(node.initializer); - } - // Return true if identifier resolves to an exported member of a namespace - function isNamespaceExportReference(node) { - var container = resolver.getReferencedExportContainer(node); - return container && container.kind !== 246 /* SourceFile */; - } - function emitShorthandPropertyAssignment(node) { - // The name property of a short-hand property assignment is considered an expression position, so here - // we manually emit the identifier to avoid rewriting. - writeTextOfNode(currentSourceFile, node.name); - // If emitting pre-ES6 code, or if the name requires rewriting when resolved as an expression identifier, - // we emit a normal property assignment. For example: - // module m { - // export let y; - // } - // module m { - // let obj = { y }; - // } - // Here we need to emit obj = { y : m.y } regardless of the output target. - if (languageVersion < 2 /* ES6 */ || isNamespaceExportReference(node.name)) { - // Emit identifier as an identifier - write(": "); - emit(node.name); - } - } - function tryEmitConstantValue(node) { - var constantValue = tryGetConstEnumValue(node); - if (constantValue !== undefined) { - write(constantValue.toString()); - if (!compilerOptions.removeComments) { - var propertyName = node.kind === 164 /* PropertyAccessExpression */ ? ts.declarationNameToString(node.name) : ts.getTextOfNode(node.argumentExpression); - write(" /* " + propertyName + " */"); - } - return true; - } - return false; - } - function tryGetConstEnumValue(node) { - if (compilerOptions.isolatedModules) { - return undefined; - } - return node.kind === 164 /* PropertyAccessExpression */ || node.kind === 165 /* ElementAccessExpression */ - ? resolver.getConstantValue(node) - : undefined; - } - // Returns 'true' if the code was actually indented, false otherwise. - // If the code is not indented, an optional valueToWriteWhenNotIndenting will be - // emitted instead. - function indentIfOnDifferentLines(parent, node1, node2, valueToWriteWhenNotIndenting) { - var realNodesAreOnDifferentLines = !ts.nodeIsSynthesized(parent) && !nodeEndIsOnSameLineAsNodeStart(node1, node2); - // Always use a newline for synthesized code if the synthesizer desires it. - var synthesizedNodeIsOnDifferentLine = synthesizedNodeStartsOnNewLine(node2); - if (realNodesAreOnDifferentLines || synthesizedNodeIsOnDifferentLine) { - increaseIndent(); - writeLine(); - return true; - } - else { - if (valueToWriteWhenNotIndenting) { - write(valueToWriteWhenNotIndenting); - } - return false; - } - } - function emitPropertyAccess(node) { - if (tryEmitConstantValue(node)) { - return; - } - emit(node.expression); - var indentedBeforeDot = indentIfOnDifferentLines(node, node.expression, node.dotToken); - // 1 .toString is a valid property access, emit a space after the literal - // Also emit a space if expression is a integer const enum value - it will appear in generated code as numeric literal - var shouldEmitSpace; - if (!indentedBeforeDot) { - if (node.expression.kind === 8 /* NumericLiteral */) { - // check if numeric literal was originally written with a dot - var text = ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, node.expression); - shouldEmitSpace = text.indexOf(ts.tokenToString(21 /* DotToken */)) < 0; - } - else { - // check if constant enum value is integer - var constantValue = tryGetConstEnumValue(node.expression); - // isFinite handles cases when constantValue is undefined - shouldEmitSpace = isFinite(constantValue) && Math.floor(constantValue) === constantValue; - } - } - if (shouldEmitSpace) { - write(" ."); - } - else { - write("."); - } - var indentedAfterDot = indentIfOnDifferentLines(node, node.dotToken, node.name); - emit(node.name); - decreaseIndentIf(indentedBeforeDot, indentedAfterDot); - } - function emitQualifiedName(node) { - emit(node.left); - write("."); - emit(node.right); - } - function emitQualifiedNameAsExpression(node, useFallback) { - if (node.left.kind === 67 /* Identifier */) { - emitEntityNameAsExpression(node.left, useFallback); - } - else if (useFallback) { - var temp = createAndRecordTempVariable(0 /* Auto */); - write("("); - emitNodeWithoutSourceMap(temp); - write(" = "); - emitEntityNameAsExpression(node.left, /*useFallback*/ true); - write(") && "); - emitNodeWithoutSourceMap(temp); - } - else { - emitEntityNameAsExpression(node.left, /*useFallback*/ false); - } - write("."); - emit(node.right); - } - function emitEntityNameAsExpression(node, useFallback) { - switch (node.kind) { - case 67 /* Identifier */: - if (useFallback) { - write("typeof "); - emitExpressionIdentifier(node); - write(" !== 'undefined' && "); - } - emitExpressionIdentifier(node); - break; - case 133 /* QualifiedName */: - emitQualifiedNameAsExpression(node, useFallback); - break; - } - } - function emitIndexedAccess(node) { - if (tryEmitConstantValue(node)) { - return; - } - emit(node.expression); - write("["); - emit(node.argumentExpression); - write("]"); - } - function hasSpreadElement(elements) { - return ts.forEach(elements, function (e) { return e.kind === 183 /* SpreadElementExpression */; }); - } - function skipParentheses(node) { - while (node.kind === 170 /* ParenthesizedExpression */ || node.kind === 169 /* TypeAssertionExpression */ || node.kind === 187 /* AsExpression */) { - node = node.expression; - } - return node; - } - function emitCallTarget(node) { - if (node.kind === 67 /* Identifier */ || node.kind === 95 /* ThisKeyword */ || node.kind === 93 /* SuperKeyword */) { - emit(node); - return node; - } - var temp = createAndRecordTempVariable(0 /* Auto */); - write("("); - emit(temp); - write(" = "); - emit(node); - write(")"); - return temp; - } - function emitCallWithSpread(node) { - var target; - var expr = skipParentheses(node.expression); - if (expr.kind === 164 /* PropertyAccessExpression */) { - // Target will be emitted as "this" argument - target = emitCallTarget(expr.expression); - write("."); - emit(expr.name); - } - else if (expr.kind === 165 /* ElementAccessExpression */) { - // Target will be emitted as "this" argument - target = emitCallTarget(expr.expression); - write("["); - emit(expr.argumentExpression); - write("]"); - } - else if (expr.kind === 93 /* SuperKeyword */) { - target = expr; - write("_super"); - } - else { - emit(node.expression); - } - write(".apply("); - if (target) { - if (target.kind === 93 /* SuperKeyword */) { - // Calls of form super(...) and super.foo(...) - emitThis(target); - } - else { - // Calls of form obj.foo(...) - emit(target); - } - } - else { - // Calls of form foo(...) - write("void 0"); - } - write(", "); - emitListWithSpread(node.arguments, /*needsUniqueCopy*/ false, /*multiLine*/ false, /*trailingComma*/ false, /*useConcat*/ true); - write(")"); - } - function emitCallExpression(node) { - if (languageVersion < 2 /* ES6 */ && hasSpreadElement(node.arguments)) { - emitCallWithSpread(node); - return; - } - var superCall = false; - if (node.expression.kind === 93 /* SuperKeyword */) { - emitSuper(node.expression); - superCall = true; - } - else { - emit(node.expression); - superCall = node.expression.kind === 164 /* PropertyAccessExpression */ && node.expression.expression.kind === 93 /* SuperKeyword */; - } - if (superCall && languageVersion < 2 /* ES6 */) { - write(".call("); - emitThis(node.expression); - if (node.arguments.length) { - write(", "); - emitCommaList(node.arguments); - } - write(")"); - } - else { - write("("); - emitCommaList(node.arguments); - write(")"); - } - } - function emitNewExpression(node) { - write("new "); - // Spread operator logic is supported in new expressions in ES5 using a combination - // of Function.prototype.bind() and Function.prototype.apply(). - // - // Example: - // - // var args = [1, 2, 3, 4, 5]; - // new Array(...args); - // - // is compiled into the following ES5: - // - // var args = [1, 2, 3, 4, 5]; - // new (Array.bind.apply(Array, [void 0].concat(args))); - // - // The 'thisArg' to 'bind' is ignored when invoking the result of 'bind' with 'new', - // Thus, we set it to undefined ('void 0'). - if (languageVersion === 1 /* ES5 */ && - node.arguments && - hasSpreadElement(node.arguments)) { - write("("); - var target = emitCallTarget(node.expression); - write(".bind.apply("); - emit(target); - write(", [void 0].concat("); - emitListWithSpread(node.arguments, /*needsUniqueCopy*/ false, /*multiline*/ false, /*trailingComma*/ false, /*useConcat*/ false); - write(")))"); - write("()"); - } - else { - emit(node.expression); - if (node.arguments) { - write("("); - emitCommaList(node.arguments); - write(")"); - } - } - } - function emitTaggedTemplateExpression(node) { - if (languageVersion >= 2 /* ES6 */) { - emit(node.tag); - write(" "); - emit(node.template); - } - else { - emitDownlevelTaggedTemplate(node); - } - } - function emitParenExpression(node) { - // If the node is synthesized, it means the emitter put the parentheses there, - // not the user. If we didn't want them, the emitter would not have put them - // there. - if (!ts.nodeIsSynthesized(node) && node.parent.kind !== 172 /* ArrowFunction */) { - if (node.expression.kind === 169 /* TypeAssertionExpression */ || node.expression.kind === 187 /* AsExpression */) { - var operand = node.expression.expression; - // Make sure we consider all nested cast expressions, e.g.: - // (-A).x; - while (operand.kind === 169 /* TypeAssertionExpression */ || operand.kind === 187 /* AsExpression */) { - operand = operand.expression; - } - // We have an expression of the form: (SubExpr) - // Emitting this as (SubExpr) is really not desirable. We would like to emit the subexpr as is. - // Omitting the parentheses, however, could cause change in the semantics of the generated - // code if the casted expression has a lower precedence than the rest of the expression, e.g.: - // (new A).foo should be emitted as (new A).foo and not new A.foo - // (typeof A).toString() should be emitted as (typeof A).toString() and not typeof A.toString() - // new (A()) should be emitted as new (A()) and not new A() - // (function foo() { })() should be emitted as an IIF (function foo(){})() and not declaration function foo(){} () - if (operand.kind !== 177 /* PrefixUnaryExpression */ && - operand.kind !== 175 /* VoidExpression */ && - operand.kind !== 174 /* TypeOfExpression */ && - operand.kind !== 173 /* DeleteExpression */ && - operand.kind !== 178 /* PostfixUnaryExpression */ && - operand.kind !== 167 /* NewExpression */ && - !(operand.kind === 166 /* CallExpression */ && node.parent.kind === 167 /* NewExpression */) && - !(operand.kind === 171 /* FunctionExpression */ && node.parent.kind === 166 /* CallExpression */) && - !(operand.kind === 8 /* NumericLiteral */ && node.parent.kind === 164 /* PropertyAccessExpression */)) { - emit(operand); - return; - } - } - } - write("("); - emit(node.expression); - write(")"); - } - function emitDeleteExpression(node) { - write(ts.tokenToString(76 /* DeleteKeyword */)); - write(" "); - emit(node.expression); - } - function emitVoidExpression(node) { - write(ts.tokenToString(101 /* VoidKeyword */)); - write(" "); - emit(node.expression); - } - function emitTypeOfExpression(node) { - write(ts.tokenToString(99 /* TypeOfKeyword */)); - write(" "); - emit(node.expression); - } - function isNameOfExportedSourceLevelDeclarationInSystemExternalModule(node) { - if (!isCurrentFileSystemExternalModule() || node.kind !== 67 /* Identifier */ || ts.nodeIsSynthesized(node)) { - return false; - } - var isVariableDeclarationOrBindingElement = node.parent && (node.parent.kind === 209 /* VariableDeclaration */ || node.parent.kind === 161 /* BindingElement */); - var targetDeclaration = isVariableDeclarationOrBindingElement - ? node.parent - : resolver.getReferencedValueDeclaration(node); - return isSourceFileLevelDeclarationInSystemJsModule(targetDeclaration, /*isExported*/ true); - } - function emitPrefixUnaryExpression(node) { - var exportChanged = isNameOfExportedSourceLevelDeclarationInSystemExternalModule(node.operand); - if (exportChanged) { - // emit - // ++x - // as - // exports('x', ++x) - write(exportFunctionForFile + "(\""); - emitNodeWithoutSourceMap(node.operand); - write("\", "); - } - write(ts.tokenToString(node.operator)); - // In some cases, we need to emit a space between the operator and the operand. One obvious case - // is when the operator is an identifier, like delete or typeof. We also need to do this for plus - // and minus expressions in certain cases. Specifically, consider the following two cases (parens - // are just for clarity of exposition, and not part of the source code): - // - // (+(+1)) - // (+(++1)) - // - // We need to emit a space in both cases. In the first case, the absence of a space will make - // the resulting expression a prefix increment operation. And in the second, it will make the resulting - // expression a prefix increment whose operand is a plus expression - (++(+x)) - // The same is true of minus of course. - if (node.operand.kind === 177 /* PrefixUnaryExpression */) { - var operand = node.operand; - if (node.operator === 35 /* PlusToken */ && (operand.operator === 35 /* PlusToken */ || operand.operator === 40 /* PlusPlusToken */)) { - write(" "); - } - else if (node.operator === 36 /* MinusToken */ && (operand.operator === 36 /* MinusToken */ || operand.operator === 41 /* MinusMinusToken */)) { - write(" "); - } - } - emit(node.operand); - if (exportChanged) { - write(")"); - } - } - function emitPostfixUnaryExpression(node) { - var exportChanged = isNameOfExportedSourceLevelDeclarationInSystemExternalModule(node.operand); - if (exportChanged) { - // 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)' - write("(" + exportFunctionForFile + "(\""); - emitNodeWithoutSourceMap(node.operand); - write("\", "); - write(ts.tokenToString(node.operator)); - emit(node.operand); - if (node.operator === 40 /* PlusPlusToken */) { - write(") - 1)"); - } - else { - write(") + 1)"); - } - } - else { - emit(node.operand); - write(ts.tokenToString(node.operator)); - } - } - function shouldHoistDeclarationInSystemJsModule(node) { - return isSourceFileLevelDeclarationInSystemJsModule(node, /*isExported*/ false); - } - /* - * Checks if given node is a source file level declaration (not nested in module/function). - * If 'isExported' is true - then declaration must also be exported. - * This function is used in two cases: - * - check if node is a exported source file level value to determine - * if we should also export the value after its it changed - * - check if node is a source level declaration to emit it differently, - * i.e non-exported variable statement 'var x = 1' is hoisted so - * we we emit variable statement 'var' should be dropped. - */ - function isSourceFileLevelDeclarationInSystemJsModule(node, isExported) { - if (!node || languageVersion >= 2 /* ES6 */ || !isCurrentFileSystemExternalModule()) { - return false; - } - var current = node; - while (current) { - if (current.kind === 246 /* SourceFile */) { - return !isExported || ((ts.getCombinedNodeFlags(node) & 1 /* Export */) !== 0); - } - else if (ts.isFunctionLike(current) || current.kind === 217 /* ModuleBlock */) { - return false; - } - else { - current = current.parent; - } - } - } - function emitBinaryExpression(node) { - if (languageVersion < 2 /* ES6 */ && node.operatorToken.kind === 55 /* EqualsToken */ && - (node.left.kind === 163 /* ObjectLiteralExpression */ || node.left.kind === 162 /* ArrayLiteralExpression */)) { - emitDestructuring(node, node.parent.kind === 193 /* ExpressionStatement */); - } - else { - var exportChanged = node.operatorToken.kind >= 55 /* FirstAssignment */ && - node.operatorToken.kind <= 66 /* LastAssignment */ && - isNameOfExportedSourceLevelDeclarationInSystemExternalModule(node.left); - if (exportChanged) { - // emit assignment 'x y' as 'exports("x", x y)' - write(exportFunctionForFile + "(\""); - emitNodeWithoutSourceMap(node.left); - write("\", "); - } - emit(node.left); - var indentedBeforeOperator = indentIfOnDifferentLines(node, node.left, node.operatorToken, node.operatorToken.kind !== 24 /* CommaToken */ ? " " : undefined); - write(ts.tokenToString(node.operatorToken.kind)); - var indentedAfterOperator = indentIfOnDifferentLines(node, node.operatorToken, node.right, " "); - emit(node.right); - decreaseIndentIf(indentedBeforeOperator, indentedAfterOperator); - if (exportChanged) { - write(")"); - } - } - } - function synthesizedNodeStartsOnNewLine(node) { - return ts.nodeIsSynthesized(node) && node.startsOnNewLine; - } - function emitConditionalExpression(node) { - emit(node.condition); - var indentedBeforeQuestion = indentIfOnDifferentLines(node, node.condition, node.questionToken, " "); - write("?"); - var indentedAfterQuestion = indentIfOnDifferentLines(node, node.questionToken, node.whenTrue, " "); - emit(node.whenTrue); - decreaseIndentIf(indentedBeforeQuestion, indentedAfterQuestion); - var indentedBeforeColon = indentIfOnDifferentLines(node, node.whenTrue, node.colonToken, " "); - write(":"); - var indentedAfterColon = indentIfOnDifferentLines(node, node.colonToken, node.whenFalse, " "); - emit(node.whenFalse); - decreaseIndentIf(indentedBeforeColon, indentedAfterColon); - } - // Helper function to decrease the indent if we previously indented. Allows multiple - // previous indent values to be considered at a time. This also allows caller to just - // call this once, passing in all their appropriate indent values, instead of needing - // to call this helper function multiple times. - function decreaseIndentIf(value1, value2) { - if (value1) { - decreaseIndent(); - } - if (value2) { - decreaseIndent(); - } - } - function isSingleLineEmptyBlock(node) { - if (node && node.kind === 190 /* Block */) { - var block = node; - return block.statements.length === 0 && nodeEndIsOnSameLineAsNodeStart(block, block); - } - } - function emitBlock(node) { - if (isSingleLineEmptyBlock(node)) { - emitToken(15 /* OpenBraceToken */, node.pos); - write(" "); - emitToken(16 /* CloseBraceToken */, node.statements.end); - return; - } - emitToken(15 /* OpenBraceToken */, node.pos); - increaseIndent(); - scopeEmitStart(node.parent); - if (node.kind === 217 /* ModuleBlock */) { - ts.Debug.assert(node.parent.kind === 216 /* ModuleDeclaration */); - emitCaptureThisForNodeIfNecessary(node.parent); - } - emitLines(node.statements); - if (node.kind === 217 /* ModuleBlock */) { - emitTempDeclarations(/*newLine*/ true); - } - decreaseIndent(); - writeLine(); - emitToken(16 /* CloseBraceToken */, node.statements.end); - scopeEmitEnd(); - } - function emitEmbeddedStatement(node) { - if (node.kind === 190 /* Block */) { - write(" "); - emit(node); - } - else { - increaseIndent(); - writeLine(); - emit(node); - decreaseIndent(); - } - } - function emitExpressionStatement(node) { - emitParenthesizedIf(node.expression, /*parenthesized*/ node.expression.kind === 172 /* ArrowFunction */); - write(";"); - } - function emitIfStatement(node) { - var endPos = emitToken(86 /* IfKeyword */, node.pos); - write(" "); - endPos = emitToken(17 /* OpenParenToken */, endPos); - emit(node.expression); - emitToken(18 /* CloseParenToken */, node.expression.end); - emitEmbeddedStatement(node.thenStatement); - if (node.elseStatement) { - writeLine(); - emitToken(78 /* ElseKeyword */, node.thenStatement.end); - if (node.elseStatement.kind === 194 /* IfStatement */) { - write(" "); - emit(node.elseStatement); - } - else { - emitEmbeddedStatement(node.elseStatement); - } - } - } - function emitDoStatement(node) { - write("do"); - emitEmbeddedStatement(node.statement); - if (node.statement.kind === 190 /* Block */) { - write(" "); - } - else { - writeLine(); - } - write("while ("); - emit(node.expression); - write(");"); - } - function emitWhileStatement(node) { - write("while ("); - emit(node.expression); - write(")"); - emitEmbeddedStatement(node.statement); - } - /** - * Returns true if start of variable declaration list was emitted. - * Returns false if nothing was written - this can happen for source file level variable declarations - * in system modules where such variable declarations are hoisted. - */ - function tryEmitStartOfVariableDeclarationList(decl, startPos) { - if (shouldHoistVariable(decl, /*checkIfSourceFileLevelDecl*/ true)) { - // variables in variable declaration list were already hoisted - return false; - } - var tokenKind = 100 /* VarKeyword */; - if (decl && languageVersion >= 2 /* ES6 */) { - if (ts.isLet(decl)) { - tokenKind = 106 /* LetKeyword */; - } - else if (ts.isConst(decl)) { - tokenKind = 72 /* ConstKeyword */; - } - } - if (startPos !== undefined) { - emitToken(tokenKind, startPos); - write(" "); - } - else { - switch (tokenKind) { - case 100 /* VarKeyword */: - write("var "); - break; - case 106 /* LetKeyword */: - write("let "); - break; - case 72 /* ConstKeyword */: - write("const "); - break; - } - } - return true; - } - function emitVariableDeclarationListSkippingUninitializedEntries(list) { - var started = false; - for (var _a = 0, _b = list.declarations; _a < _b.length; _a++) { - var decl = _b[_a]; - if (!decl.initializer) { - continue; - } - if (!started) { - started = true; - } - else { - write(", "); - } - emit(decl); - } - return started; - } - function emitForStatement(node) { - var endPos = emitToken(84 /* ForKeyword */, node.pos); - write(" "); - endPos = emitToken(17 /* OpenParenToken */, endPos); - if (node.initializer && node.initializer.kind === 210 /* VariableDeclarationList */) { - var variableDeclarationList = node.initializer; - var startIsEmitted = tryEmitStartOfVariableDeclarationList(variableDeclarationList, endPos); - if (startIsEmitted) { - emitCommaList(variableDeclarationList.declarations); - } - else { - emitVariableDeclarationListSkippingUninitializedEntries(variableDeclarationList); - } - } - else if (node.initializer) { - emit(node.initializer); - } - write(";"); - emitOptional(" ", node.condition); - write(";"); - emitOptional(" ", node.incrementor); - write(")"); - emitEmbeddedStatement(node.statement); - } - function emitForInOrForOfStatement(node) { - if (languageVersion < 2 /* ES6 */ && node.kind === 199 /* ForOfStatement */) { - return emitDownLevelForOfStatement(node); - } - var endPos = emitToken(84 /* ForKeyword */, node.pos); - write(" "); - endPos = emitToken(17 /* OpenParenToken */, endPos); - if (node.initializer.kind === 210 /* VariableDeclarationList */) { - var variableDeclarationList = node.initializer; - if (variableDeclarationList.declarations.length >= 1) { - tryEmitStartOfVariableDeclarationList(variableDeclarationList, endPos); - emit(variableDeclarationList.declarations[0]); - } - } - else { - emit(node.initializer); - } - if (node.kind === 198 /* ForInStatement */) { - write(" in "); - } - else { - write(" of "); - } - emit(node.expression); - emitToken(18 /* CloseParenToken */, node.expression.end); - emitEmbeddedStatement(node.statement); - } - function emitDownLevelForOfStatement(node) { - // The following ES6 code: - // - // for (let v of expr) { } - // - // should be emitted as - // - // for (let _i = 0, _a = expr; _i < _a.length; _i++) { - // let v = _a[_i]; - // } - // - // where _a and _i are temps emitted to capture the RHS and the counter, - // respectively. - // When the left hand side is an expression instead of a let declaration, - // the "let v" is not emitted. - // When the left hand side is a let/const, the v is renamed if there is - // another v in scope. - // Note that all assignments to the LHS are emitted in the body, including - // all destructuring. - // Note also that because an extra statement is needed to assign to the LHS, - // for-of bodies are always emitted as blocks. - var endPos = emitToken(84 /* ForKeyword */, node.pos); - write(" "); - endPos = emitToken(17 /* OpenParenToken */, endPos); - // Do not emit the LHS let declaration yet, because it might contain destructuring. - // Do not call recordTempDeclaration because we are declaring the temps - // right here. Recording means they will be declared later. - // 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 rhsIsIdentifier = node.expression.kind === 67 /* Identifier */; - var counter = createTempVariable(268435456 /* _i */); - var rhsReference = rhsIsIdentifier ? node.expression : createTempVariable(0 /* Auto */); - // This is the let keyword for the counter and rhsReference. The let keyword for - // the LHS will be emitted inside the body. - emitStart(node.expression); - write("var "); - // _i = 0 - emitNodeWithoutSourceMap(counter); - write(" = 0"); - emitEnd(node.expression); - if (!rhsIsIdentifier) { - // , _a = expr - write(", "); - emitStart(node.expression); - emitNodeWithoutSourceMap(rhsReference); - write(" = "); - emitNodeWithoutSourceMap(node.expression); - emitEnd(node.expression); - } - write("; "); - // _i < _a.length; - emitStart(node.initializer); - emitNodeWithoutSourceMap(counter); - write(" < "); - emitNodeWithCommentsAndWithoutSourcemap(rhsReference); - write(".length"); - emitEnd(node.initializer); - write("; "); - // _i++) - emitStart(node.initializer); - emitNodeWithoutSourceMap(counter); - write("++"); - emitEnd(node.initializer); - emitToken(18 /* CloseParenToken */, node.expression.end); - // Body - write(" {"); - writeLine(); - increaseIndent(); - // Initialize LHS - // let v = _a[_i]; - var rhsIterationValue = createElementAccessExpression(rhsReference, counter); - emitStart(node.initializer); - if (node.initializer.kind === 210 /* VariableDeclarationList */) { - write("var "); - var variableDeclarationList = node.initializer; - if (variableDeclarationList.declarations.length > 0) { - var declaration = variableDeclarationList.declarations[0]; - if (ts.isBindingPattern(declaration.name)) { - // This works whether the declaration is a var, let, or const. - // It will use rhsIterationValue _a[_i] as the initializer. - emitDestructuring(declaration, /*isAssignmentExpressionStatement*/ false, rhsIterationValue); - } - else { - // The following call does not include the initializer, so we have - // to emit it separately. - emitNodeWithCommentsAndWithoutSourcemap(declaration); - write(" = "); - emitNodeWithoutSourceMap(rhsIterationValue); - } - } - else { - // It's an empty declaration list. This can only happen in an error case, if the user wrote - // for (let of []) {} - emitNodeWithoutSourceMap(createTempVariable(0 /* Auto */)); - write(" = "); - emitNodeWithoutSourceMap(rhsIterationValue); - } - } - else { - // Initializer is an expression. Emit the expression in the body, so that it's - // evaluated on every iteration. - var assignmentExpression = createBinaryExpression(node.initializer, 55 /* EqualsToken */, rhsIterationValue, /*startsOnNewLine*/ false); - if (node.initializer.kind === 162 /* ArrayLiteralExpression */ || node.initializer.kind === 163 /* ObjectLiteralExpression */) { - // This is a destructuring pattern, so call emitDestructuring instead of emit. Calling emit will not work, because it will cause - // the BinaryExpression to be passed in instead of the expression statement, which will cause emitDestructuring to crash. - emitDestructuring(assignmentExpression, /*isAssignmentExpressionStatement*/ true, /*value*/ undefined); - } - else { - emitNodeWithCommentsAndWithoutSourcemap(assignmentExpression); - } - } - emitEnd(node.initializer); - write(";"); - if (node.statement.kind === 190 /* Block */) { - emitLines(node.statement.statements); - } - else { - writeLine(); - emit(node.statement); - } - writeLine(); - decreaseIndent(); - write("}"); - } - function emitBreakOrContinueStatement(node) { - emitToken(node.kind === 201 /* BreakStatement */ ? 68 /* BreakKeyword */ : 73 /* ContinueKeyword */, node.pos); - emitOptional(" ", node.label); - write(";"); - } - function emitReturnStatement(node) { - emitToken(92 /* ReturnKeyword */, node.pos); - emitOptional(" ", node.expression); - write(";"); - } - function emitWithStatement(node) { - write("with ("); - emit(node.expression); - write(")"); - emitEmbeddedStatement(node.statement); - } - function emitSwitchStatement(node) { - var endPos = emitToken(94 /* SwitchKeyword */, node.pos); - write(" "); - emitToken(17 /* OpenParenToken */, endPos); - emit(node.expression); - endPos = emitToken(18 /* CloseParenToken */, node.expression.end); - write(" "); - emitCaseBlock(node.caseBlock, endPos); - } - function emitCaseBlock(node, startPos) { - emitToken(15 /* OpenBraceToken */, startPos); - increaseIndent(); - emitLines(node.clauses); - decreaseIndent(); - writeLine(); - emitToken(16 /* CloseBraceToken */, node.clauses.end); - } - function nodeStartPositionsAreOnSameLine(node1, node2) { - return ts.getLineOfLocalPosition(currentSourceFile, ts.skipTrivia(currentSourceFile.text, node1.pos)) === - ts.getLineOfLocalPosition(currentSourceFile, ts.skipTrivia(currentSourceFile.text, node2.pos)); - } - function nodeEndPositionsAreOnSameLine(node1, node2) { - return ts.getLineOfLocalPosition(currentSourceFile, node1.end) === - ts.getLineOfLocalPosition(currentSourceFile, node2.end); - } - function nodeEndIsOnSameLineAsNodeStart(node1, node2) { - return ts.getLineOfLocalPosition(currentSourceFile, node1.end) === - ts.getLineOfLocalPosition(currentSourceFile, ts.skipTrivia(currentSourceFile.text, node2.pos)); - } - function emitCaseOrDefaultClause(node) { - if (node.kind === 239 /* CaseClause */) { - write("case "); - emit(node.expression); - write(":"); - } - else { - write("default:"); - } - if (node.statements.length === 1 && nodeStartPositionsAreOnSameLine(node, node.statements[0])) { - write(" "); - emit(node.statements[0]); - } - else { - increaseIndent(); - emitLines(node.statements); - decreaseIndent(); - } - } - function emitThrowStatement(node) { - write("throw "); - emit(node.expression); - write(";"); - } - function emitTryStatement(node) { - write("try "); - emit(node.tryBlock); - emit(node.catchClause); - if (node.finallyBlock) { - writeLine(); - write("finally "); - emit(node.finallyBlock); - } - } - function emitCatchClause(node) { - writeLine(); - var endPos = emitToken(70 /* CatchKeyword */, node.pos); - write(" "); - emitToken(17 /* OpenParenToken */, endPos); - emit(node.variableDeclaration); - emitToken(18 /* CloseParenToken */, node.variableDeclaration ? node.variableDeclaration.end : endPos); - write(" "); - emitBlock(node.block); - } - function emitDebuggerStatement(node) { - emitToken(74 /* DebuggerKeyword */, node.pos); - write(";"); - } - function emitLabelledStatement(node) { - emit(node.label); - write(": "); - emit(node.statement); - } - function getContainingModule(node) { - do { - node = node.parent; - } while (node && node.kind !== 216 /* ModuleDeclaration */); - return node; - } - function emitContainingModuleName(node) { - var container = getContainingModule(node); - write(container ? getGeneratedNameForNode(container) : "exports"); - } - function emitModuleMemberName(node) { - emitStart(node.name); - if (ts.getCombinedNodeFlags(node) & 1 /* Export */) { - var container = getContainingModule(node); - if (container) { - write(getGeneratedNameForNode(container)); - write("."); - } - else if (languageVersion < 2 /* ES6 */ && compilerOptions.module !== 4 /* System */) { - write("exports."); - } - } - emitNodeWithCommentsAndWithoutSourcemap(node.name); - emitEnd(node.name); - } - function createVoidZero() { - var zero = ts.createSynthesizedNode(8 /* NumericLiteral */); - zero.text = "0"; - var result = ts.createSynthesizedNode(175 /* VoidExpression */); - result.expression = zero; - return result; - } - function emitEs6ExportDefaultCompat(node) { - if (node.parent.kind === 246 /* SourceFile */) { - ts.Debug.assert(!!(node.flags & 1024 /* Default */) || node.kind === 225 /* ExportAssignment */); - // only allow export default at a source file level - if (compilerOptions.module === 1 /* CommonJS */ || compilerOptions.module === 2 /* AMD */ || compilerOptions.module === 3 /* UMD */) { - if (!currentSourceFile.symbol.exports["___esModule"]) { - if (languageVersion === 1 /* ES5 */) { - // default value of configurable, enumerable, writable are `false`. - write("Object.defineProperty(exports, \"__esModule\", { value: true });"); - writeLine(); - } - else if (languageVersion === 0 /* ES3 */) { - write("exports.__esModule = true;"); - writeLine(); - } - } - } - } - } - function emitExportMemberAssignment(node) { - if (node.flags & 1 /* Export */) { - writeLine(); - emitStart(node); - // emit call to exporter only for top level nodes - if (compilerOptions.module === 4 /* System */ && node.parent === currentSourceFile) { - // emit export default as - // export("default", ) - write(exportFunctionForFile + "(\""); - if (node.flags & 1024 /* Default */) { - write("default"); - } - else { - emitNodeWithCommentsAndWithoutSourcemap(node.name); - } - write("\", "); - emitDeclarationName(node); - write(")"); - } - else { - if (node.flags & 1024 /* Default */) { - emitEs6ExportDefaultCompat(node); - if (languageVersion === 0 /* ES3 */) { - write("exports[\"default\"]"); - } - else { - write("exports.default"); - } - } - else { - emitModuleMemberName(node); - } - write(" = "); - emitDeclarationName(node); - } - emitEnd(node); - write(";"); - } - } - function emitExportMemberAssignments(name) { - if (compilerOptions.module === 4 /* System */) { - return; - } - if (!exportEquals && exportSpecifiers && ts.hasProperty(exportSpecifiers, name.text)) { - for (var _a = 0, _b = exportSpecifiers[name.text]; _a < _b.length; _a++) { - var specifier = _b[_a]; - writeLine(); - emitStart(specifier.name); - emitContainingModuleName(specifier); - write("."); - emitNodeWithCommentsAndWithoutSourcemap(specifier.name); - emitEnd(specifier.name); - write(" = "); - emitExpressionIdentifier(name); - write(";"); - } - } - } - function emitExportSpecifierInSystemModule(specifier) { - ts.Debug.assert(compilerOptions.module === 4 /* System */); - if (!resolver.getReferencedValueDeclaration(specifier.propertyName || specifier.name) && !resolver.isValueAliasDeclaration(specifier)) { - return; - } - writeLine(); - emitStart(specifier.name); - write(exportFunctionForFile + "(\""); - emitNodeWithCommentsAndWithoutSourcemap(specifier.name); - write("\", "); - emitExpressionIdentifier(specifier.propertyName || specifier.name); - write(")"); - emitEnd(specifier.name); - write(";"); - } - function emitDestructuring(root, isAssignmentExpressionStatement, value) { - var emitCount = 0; - // An exported declaration is actually emitted as an assignment (to a property on the module object), so - // temporary variables in an exported declaration need to have real declarations elsewhere - // Also temporary variables should be explicitly allocated for source level declarations when module target is system - // because actual variable declarations are hoisted - var canDefineTempVariablesInPlace = false; - if (root.kind === 209 /* VariableDeclaration */) { - var isExported = ts.getCombinedNodeFlags(root) & 1 /* Export */; - var isSourceLevelForSystemModuleKind = shouldHoistDeclarationInSystemJsModule(root); - canDefineTempVariablesInPlace = !isExported && !isSourceLevelForSystemModuleKind; - } - else if (root.kind === 136 /* Parameter */) { - canDefineTempVariablesInPlace = true; - } - if (root.kind === 179 /* BinaryExpression */) { - emitAssignmentExpression(root); - } - else { - ts.Debug.assert(!isAssignmentExpressionStatement); - emitBindingElement(root, value); - } - function emitAssignment(name, value) { - if (emitCount++) { - write(", "); - } - var isVariableDeclarationOrBindingElement = name.parent && (name.parent.kind === 209 /* VariableDeclaration */ || name.parent.kind === 161 /* BindingElement */); - var exportChanged = isNameOfExportedSourceLevelDeclarationInSystemExternalModule(name); - if (exportChanged) { - write(exportFunctionForFile + "(\""); - emitNodeWithCommentsAndWithoutSourcemap(name); - write("\", "); - } - if (isVariableDeclarationOrBindingElement) { - emitModuleMemberName(name.parent); - } - else { - emit(name); - } - write(" = "); - emit(value); - if (exportChanged) { - write(")"); - } - } - /** - * Ensures that there exists a declared identifier whose value holds the given expression. - * This function is useful to ensure that the expression's value can be read from in subsequent expressions. - * Unless 'reuseIdentifierExpressions' is false, 'expr' will be returned if it is just an identifier. - * - * @param expr the expression whose value needs to be bound. - * @param reuseIdentifierExpressions true if identifier expressions can simply be returned; - * false if it is necessary to always emit an identifier. - */ - function ensureIdentifier(expr, reuseIdentifierExpressions) { - if (expr.kind === 67 /* Identifier */ && reuseIdentifierExpressions) { - return expr; - } - var identifier = createTempVariable(0 /* Auto */); - if (!canDefineTempVariablesInPlace) { - recordTempDeclaration(identifier); - } - emitAssignment(identifier, expr); - return identifier; - } - function createDefaultValueCheck(value, defaultValue) { - // The value expression will be evaluated twice, so for anything but a simple identifier - // we need to generate a temporary variable - value = ensureIdentifier(value, /*reuseIdentifierExpressions*/ true); - // Return the expression 'value === void 0 ? defaultValue : value' - var equals = ts.createSynthesizedNode(179 /* BinaryExpression */); - equals.left = value; - equals.operatorToken = ts.createSynthesizedNode(32 /* EqualsEqualsEqualsToken */); - equals.right = createVoidZero(); - return createConditionalExpression(equals, defaultValue, value); - } - function createConditionalExpression(condition, whenTrue, whenFalse) { - var cond = ts.createSynthesizedNode(180 /* ConditionalExpression */); - cond.condition = condition; - cond.questionToken = ts.createSynthesizedNode(52 /* QuestionToken */); - cond.whenTrue = whenTrue; - cond.colonToken = ts.createSynthesizedNode(53 /* ColonToken */); - cond.whenFalse = whenFalse; - return cond; - } - function createNumericLiteral(value) { - var node = ts.createSynthesizedNode(8 /* NumericLiteral */); - node.text = "" + value; - return node; - } - function createPropertyAccessForDestructuringProperty(object, propName) { - // We create a synthetic copy of the identifier in order to avoid the rewriting that might - // otherwise occur when the identifier is emitted. - var syntheticName = ts.createSynthesizedNode(propName.kind); - syntheticName.text = propName.text; - if (syntheticName.kind !== 67 /* Identifier */) { - return createElementAccessExpression(object, syntheticName); - } - return createPropertyAccessExpression(object, syntheticName); - } - function createSliceCall(value, sliceIndex) { - var call = ts.createSynthesizedNode(166 /* CallExpression */); - var sliceIdentifier = ts.createSynthesizedNode(67 /* Identifier */); - sliceIdentifier.text = "slice"; - call.expression = createPropertyAccessExpression(value, sliceIdentifier); - call.arguments = ts.createSynthesizedNodeArray(); - call.arguments[0] = createNumericLiteral(sliceIndex); - return call; - } - function emitObjectLiteralAssignment(target, value) { - var properties = target.properties; - if (properties.length !== 1) { - // For anything but a single element destructuring we need to generate a temporary - // to ensure value is evaluated exactly once. - value = ensureIdentifier(value, /*reuseIdentifierExpressions*/ true); - } - for (var _a = 0; _a < properties.length; _a++) { - var p = properties[_a]; - if (p.kind === 243 /* PropertyAssignment */ || p.kind === 244 /* ShorthandPropertyAssignment */) { - var propName = p.name; - emitDestructuringAssignment(p.initializer || propName, createPropertyAccessForDestructuringProperty(value, propName)); - } - } - } - function emitArrayLiteralAssignment(target, value) { - var elements = target.elements; - if (elements.length !== 1) { - // For anything but a single element destructuring we need to generate a temporary - // to ensure value is evaluated exactly once. - value = ensureIdentifier(value, /*reuseIdentifierExpressions*/ true); - } - for (var i = 0; i < elements.length; i++) { - var e = elements[i]; - if (e.kind !== 185 /* OmittedExpression */) { - if (e.kind !== 183 /* SpreadElementExpression */) { - emitDestructuringAssignment(e, createElementAccessExpression(value, createNumericLiteral(i))); - } - else if (i === elements.length - 1) { - emitDestructuringAssignment(e.expression, createSliceCall(value, i)); - } - } - } - } - function emitDestructuringAssignment(target, value) { - if (target.kind === 179 /* BinaryExpression */ && target.operatorToken.kind === 55 /* EqualsToken */) { - value = createDefaultValueCheck(value, target.right); - target = target.left; - } - if (target.kind === 163 /* ObjectLiteralExpression */) { - emitObjectLiteralAssignment(target, value); - } - else if (target.kind === 162 /* ArrayLiteralExpression */) { - emitArrayLiteralAssignment(target, value); - } - else { - emitAssignment(target, value); - } - } - function emitAssignmentExpression(root) { - var target = root.left; - var value = root.right; - if (ts.isEmptyObjectLiteralOrArrayLiteral(target)) { - emit(value); - } - else if (isAssignmentExpressionStatement) { - emitDestructuringAssignment(target, value); - } - else { - if (root.parent.kind !== 170 /* ParenthesizedExpression */) { - write("("); - } - value = ensureIdentifier(value, /*reuseIdentifierExpressions*/ true); - emitDestructuringAssignment(target, value); - write(", "); - emit(value); - if (root.parent.kind !== 170 /* ParenthesizedExpression */) { - write(")"); - } - } - } - function emitBindingElement(target, value) { - if (target.initializer) { - // Combine value and initializer - value = value ? createDefaultValueCheck(value, target.initializer) : target.initializer; - } - else if (!value) { - // Use 'void 0' in absence of value and initializer - value = createVoidZero(); - } - if (ts.isBindingPattern(target.name)) { - var pattern = target.name; - var elements = pattern.elements; - var numElements = elements.length; - if (numElements !== 1) { - // For anything other than a single-element destructuring we need to generate a temporary - // to ensure value is evaluated exactly once. Additionally, if we have zero elements - // we need to emit *something* to ensure that in case a 'var' keyword was already emitted, - // so in that case, we'll intentionally create that temporary. - value = ensureIdentifier(value, /*reuseIdentifierExpressions*/ numElements !== 0); - } - for (var i = 0; i < numElements; i++) { - var element = elements[i]; - if (pattern.kind === 159 /* ObjectBindingPattern */) { - // Rewrite element to a declaration with an initializer that fetches property - var propName = element.propertyName || element.name; - emitBindingElement(element, createPropertyAccessForDestructuringProperty(value, propName)); - } - else if (element.kind !== 185 /* OmittedExpression */) { - if (!element.dotDotDotToken) { - // Rewrite element to a declaration that accesses array element at index i - emitBindingElement(element, createElementAccessExpression(value, createNumericLiteral(i))); - } - else if (i === numElements - 1) { - emitBindingElement(element, createSliceCall(value, i)); - } - } - } - } - else { - emitAssignment(target.name, value); - } - } - } - function emitVariableDeclaration(node) { - if (ts.isBindingPattern(node.name)) { - if (languageVersion < 2 /* ES6 */) { - emitDestructuring(node, /*isAssignmentExpressionStatement*/ false); - } - else { - emit(node.name); - emitOptional(" = ", node.initializer); - } - } - else { - var initializer = node.initializer; - if (!initializer && languageVersion < 2 /* ES6 */) { - // downlevel emit for non-initialized let bindings defined in loops - // for (...) { let x; } - // should be - // for (...) { var = void 0; } - // this is necessary to preserve ES6 semantic in scenarios like - // for (...) { let x; console.log(x); x = 1 } // assignment on one iteration should not affect other iterations - var isUninitializedLet = (resolver.getNodeCheckFlags(node) & 16384 /* BlockScopedBindingInLoop */) && - (getCombinedFlagsForIdentifier(node.name) & 16384 /* Let */); - // NOTE: default initialization should not be added to let bindings in for-in\for-of statements - if (isUninitializedLet && - node.parent.parent.kind !== 198 /* ForInStatement */ && - node.parent.parent.kind !== 199 /* ForOfStatement */) { - initializer = createVoidZero(); - } - } - var exportChanged = isNameOfExportedSourceLevelDeclarationInSystemExternalModule(node.name); - if (exportChanged) { - write(exportFunctionForFile + "(\""); - emitNodeWithCommentsAndWithoutSourcemap(node.name); - write("\", "); - } - emitModuleMemberName(node); - emitOptional(" = ", initializer); - if (exportChanged) { - write(")"); - } - } - } - function emitExportVariableAssignments(node) { - if (node.kind === 185 /* OmittedExpression */) { - return; - } - var name = node.name; - if (name.kind === 67 /* Identifier */) { - emitExportMemberAssignments(name); - } - else if (ts.isBindingPattern(name)) { - ts.forEach(name.elements, emitExportVariableAssignments); - } - } - function getCombinedFlagsForIdentifier(node) { - if (!node.parent || (node.parent.kind !== 209 /* VariableDeclaration */ && node.parent.kind !== 161 /* BindingElement */)) { - return 0; - } - return ts.getCombinedNodeFlags(node.parent); - } - function isES6ExportedDeclaration(node) { - return !!(node.flags & 1 /* Export */) && - languageVersion >= 2 /* ES6 */ && - node.parent.kind === 246 /* SourceFile */; - } - function emitVariableStatement(node) { - var startIsEmitted = false; - if (node.flags & 1 /* Export */) { - if (isES6ExportedDeclaration(node)) { - // Exported ES6 module member - write("export "); - startIsEmitted = tryEmitStartOfVariableDeclarationList(node.declarationList); - } - } - else { - startIsEmitted = tryEmitStartOfVariableDeclarationList(node.declarationList); - } - if (startIsEmitted) { - emitCommaList(node.declarationList.declarations); - write(";"); - } - else { - var atLeastOneItem = emitVariableDeclarationListSkippingUninitializedEntries(node.declarationList); - if (atLeastOneItem) { - write(";"); - } - } - if (languageVersion < 2 /* ES6 */ && node.parent === currentSourceFile) { - ts.forEach(node.declarationList.declarations, emitExportVariableAssignments); - } - } - function shouldEmitLeadingAndTrailingCommentsForVariableStatement(node) { - // If we're not exporting the variables, there's nothing special here. - // Always emit comments for these nodes. - if (!(node.flags & 1 /* Export */)) { - return true; - } - // If we are exporting, but it's a top-level ES6 module exports, - // we'll emit the declaration list verbatim, so emit comments too. - if (isES6ExportedDeclaration(node)) { - return true; - } - // Otherwise, only emit if we have at least one initializer present. - for (var _a = 0, _b = node.declarationList.declarations; _a < _b.length; _a++) { - var declaration = _b[_a]; - if (declaration.initializer) { - return true; - } - } - return false; - } - function emitParameter(node) { - if (languageVersion < 2 /* ES6 */) { - if (ts.isBindingPattern(node.name)) { - var name_23 = createTempVariable(0 /* Auto */); - if (!tempParameters) { - tempParameters = []; - } - tempParameters.push(name_23); - emit(name_23); - } - else { - emit(node.name); - } - } - else { - if (node.dotDotDotToken) { - write("..."); - } - emit(node.name); - emitOptional(" = ", node.initializer); - } - } - function emitDefaultValueAssignments(node) { - if (languageVersion < 2 /* ES6 */) { - var tempIndex = 0; - ts.forEach(node.parameters, function (parameter) { - // A rest parameter cannot have a binding pattern or an initializer, - // so let's just ignore it. - if (parameter.dotDotDotToken) { - return; - } - var paramName = parameter.name, initializer = parameter.initializer; - if (ts.isBindingPattern(paramName)) { - // 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. - var hasBindingElements = paramName.elements.length > 0; - if (hasBindingElements || initializer) { - writeLine(); - write("var "); - if (hasBindingElements) { - emitDestructuring(parameter, /*isAssignmentExpressionStatement*/ false, tempParameters[tempIndex]); - } - else { - emit(tempParameters[tempIndex]); - write(" = "); - emit(initializer); - } - write(";"); - tempIndex++; - } - } - else if (initializer) { - writeLine(); - emitStart(parameter); - write("if ("); - emitNodeWithoutSourceMap(paramName); - write(" === void 0)"); - emitEnd(parameter); - write(" { "); - emitStart(parameter); - emitNodeWithCommentsAndWithoutSourcemap(paramName); - write(" = "); - emitNodeWithCommentsAndWithoutSourcemap(initializer); - emitEnd(parameter); - write("; }"); - } - }); - } - } - function emitRestParameter(node) { - if (languageVersion < 2 /* ES6 */ && ts.hasRestParameter(node)) { - var restIndex = node.parameters.length - 1; - var restParam = node.parameters[restIndex]; - // A rest parameter cannot have a binding pattern, so let's just ignore it if it does. - if (ts.isBindingPattern(restParam.name)) { - return; - } - var tempName = createTempVariable(268435456 /* _i */).text; - writeLine(); - emitLeadingComments(restParam); - emitStart(restParam); - write("var "); - emitNodeWithCommentsAndWithoutSourcemap(restParam.name); - write(" = [];"); - emitEnd(restParam); - emitTrailingComments(restParam); - writeLine(); - write("for ("); - emitStart(restParam); - write("var " + tempName + " = " + restIndex + ";"); - emitEnd(restParam); - write(" "); - emitStart(restParam); - write(tempName + " < arguments.length;"); - emitEnd(restParam); - write(" "); - emitStart(restParam); - write(tempName + "++"); - emitEnd(restParam); - write(") {"); - increaseIndent(); - writeLine(); - emitStart(restParam); - emitNodeWithCommentsAndWithoutSourcemap(restParam.name); - write("[" + tempName + " - " + restIndex + "] = arguments[" + tempName + "];"); - emitEnd(restParam); - decreaseIndent(); - writeLine(); - write("}"); - } - } - function emitAccessor(node) { - write(node.kind === 143 /* GetAccessor */ ? "get " : "set "); - emit(node.name); - emitSignatureAndBody(node); - } - function shouldEmitAsArrowFunction(node) { - return node.kind === 172 /* ArrowFunction */ && languageVersion >= 2 /* ES6 */; - } - function emitDeclarationName(node) { - if (node.name) { - emitNodeWithCommentsAndWithoutSourcemap(node.name); - } - else { - write(getGeneratedNameForNode(node)); - } - } - function shouldEmitFunctionName(node) { - if (node.kind === 171 /* FunctionExpression */) { - // Emit name if one is present - return !!node.name; - } - if (node.kind === 211 /* FunctionDeclaration */) { - // Emit name if one is present, or emit generated name in down-level case (for export default case) - return !!node.name || languageVersion < 2 /* ES6 */; - } - } - function emitFunctionDeclaration(node) { - if (ts.nodeIsMissing(node.body)) { - return emitCommentsOnNotEmittedNode(node); - } - // TODO (yuisu) : we should not have special cases to condition emitting comments - // but have one place to fix check for these conditions. - if (node.kind !== 141 /* MethodDeclaration */ && node.kind !== 140 /* MethodSignature */ && - node.parent && node.parent.kind !== 243 /* PropertyAssignment */ && - node.parent.kind !== 166 /* CallExpression */) { - // 1. Methods will emit the comments as part of emitting method declaration - // 2. If the function is a property of object literal, emitting leading-comments - // is done by emitNodeWithoutSourceMap which then call this function. - // In particular, we would like to avoid emit comments twice in following case: - // For example: - // var obj = { - // id: - // /*comment*/ () => void - // } - // 3. If the function is an argument in call expression, emitting of comments will be - // taken care of in emit list of arguments inside of emitCallexpression - emitLeadingComments(node); - } - emitStart(node); - // For targeting below es6, emit functions-like declaration including arrow function using function keyword. - // When targeting ES6, emit arrow function natively in ES6 by omitting function keyword and using fat arrow instead - if (!shouldEmitAsArrowFunction(node)) { - if (isES6ExportedDeclaration(node)) { - write("export "); - if (node.flags & 1024 /* Default */) { - write("default "); - } - } - write("function"); - if (languageVersion >= 2 /* ES6 */ && node.asteriskToken) { - write("*"); - } - write(" "); - } - if (shouldEmitFunctionName(node)) { - emitDeclarationName(node); - } - emitSignatureAndBody(node); - if (languageVersion < 2 /* ES6 */ && node.kind === 211 /* FunctionDeclaration */ && node.parent === currentSourceFile && node.name) { - emitExportMemberAssignments(node.name); - } - emitEnd(node); - if (node.kind !== 141 /* MethodDeclaration */ && node.kind !== 140 /* MethodSignature */) { - emitTrailingComments(node); - } - } - function emitCaptureThisForNodeIfNecessary(node) { - if (resolver.getNodeCheckFlags(node) & 4 /* CaptureThis */) { - writeLine(); - emitStart(node); - write("var _this = this;"); - emitEnd(node); - } - } - function emitSignatureParameters(node) { - increaseIndent(); - write("("); - if (node) { - var parameters = node.parameters; - var omitCount = languageVersion < 2 /* ES6 */ && ts.hasRestParameter(node) ? 1 : 0; - emitList(parameters, 0, parameters.length - omitCount, /*multiLine*/ false, /*trailingComma*/ false); - } - write(")"); - decreaseIndent(); - } - function emitSignatureParametersForArrow(node) { - // Check whether the parameter list needs parentheses and preserve no-parenthesis - if (node.parameters.length === 1 && node.pos === node.parameters[0].pos) { - emit(node.parameters[0]); - return; - } - emitSignatureParameters(node); - } - function emitAsyncFunctionBodyForES6(node) { - var promiseConstructor = ts.getEntityNameFromTypeNode(node.type); - var isArrowFunction = node.kind === 172 /* ArrowFunction */; - var hasLexicalArguments = (resolver.getNodeCheckFlags(node) & 4096 /* CaptureArguments */) !== 0; - var args; - // 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. - // - // The emit for an async arrow without a lexical `arguments` binding might be: - // - // // input - // let a = async (b) => { await b; } - // - // // output - // let a = (b) => __awaiter(this, void 0, void 0, function* () { - // yield b; - // }); - // - // The emit for an async arrow with a lexical `arguments` binding might be: - // - // // input - // let a = async (b) => { await arguments[0]; } - // - // // output - // let a = (b) => __awaiter(this, arguments, void 0, function* (arguments) { - // yield arguments[0]; - // }); - // - // The emit for an async function expression without a lexical `arguments` binding - // might be: - // - // // input - // let a = async function (b) { - // await b; - // } - // - // // output - // let a = function (b) { - // return __awaiter(this, void 0, void 0, function* () { - // yield b; - // }); - // } - // - // The emit for an async function expression with a lexical `arguments` binding - // might be: - // - // // input - // let a = async function (b) { - // await arguments[0]; - // } - // - // // output - // let a = function (b) { - // return __awaiter(this, arguments, void 0, function* (_arguments) { - // yield _arguments[0]; - // }); - // } - // - // The emit for an async function expression with a lexical `arguments` binding - // and a return type annotation might be: - // - // // input - // let a = async function (b): MyPromise { - // await arguments[0]; - // } - // - // // output - // let a = function (b) { - // return __awaiter(this, arguments, MyPromise, function* (_arguments) { - // yield _arguments[0]; - // }); - // } - // - // If this is not an async arrow, emit the opening brace of the function body - // and the start of the return statement. - if (!isArrowFunction) { - write(" {"); - increaseIndent(); - writeLine(); - write("return"); - } - write(" __awaiter(this"); - if (hasLexicalArguments) { - write(", arguments"); - } - else { - write(", void 0"); - } - if (promiseConstructor) { - write(", "); - emitNodeWithoutSourceMap(promiseConstructor); - } - else { - write(", Promise"); - } - // Emit the call to __awaiter. - if (hasLexicalArguments) { - write(", function* (_arguments)"); - } - else { - write(", function* ()"); - } - // Emit the signature and body for the inner generator function. - emitFunctionBody(node); - write(")"); - // If this is not an async arrow, emit the closing brace of the outer function body. - if (!isArrowFunction) { - write(";"); - decreaseIndent(); - writeLine(); - write("}"); - } - } - function emitFunctionBody(node) { - if (!node.body) { - // There can be no body when there are parse errors. Just emit an empty block - // in that case. - write(" { }"); - } - else { - if (node.body.kind === 190 /* Block */) { - emitBlockFunctionBody(node, node.body); - } - else { - emitExpressionFunctionBody(node, node.body); - } - } - } - function emitSignatureAndBody(node) { - var saveTempFlags = tempFlags; - var saveTempVariables = tempVariables; - var saveTempParameters = tempParameters; - tempFlags = 0; - tempVariables = undefined; - tempParameters = undefined; - // When targeting ES6, emit arrow function natively in ES6 - if (shouldEmitAsArrowFunction(node)) { - emitSignatureParametersForArrow(node); - write(" =>"); - } - else { - emitSignatureParameters(node); - } - var isAsync = ts.isAsyncFunctionLike(node); - if (isAsync && languageVersion === 2 /* ES6 */) { - emitAsyncFunctionBodyForES6(node); - } - else { - emitFunctionBody(node); - } - if (!isES6ExportedDeclaration(node)) { - emitExportMemberAssignment(node); - } - tempFlags = saveTempFlags; - tempVariables = saveTempVariables; - tempParameters = saveTempParameters; - } - // Returns true if any preamble code was emitted. - function emitFunctionBodyPreamble(node) { - emitCaptureThisForNodeIfNecessary(node); - emitDefaultValueAssignments(node); - emitRestParameter(node); - } - function emitExpressionFunctionBody(node, body) { - if (languageVersion < 2 /* ES6 */ || node.flags & 512 /* Async */) { - emitDownLevelExpressionFunctionBody(node, body); - return; - } - // For es6 and higher we can emit the expression as is. However, in the case - // where the expression might end up looking like a block when emitted, we'll - // also wrap it in parentheses first. For example if you have: a => {} - // then we need to generate: a => ({}) - write(" "); - // Unwrap all type assertions. - var current = body; - while (current.kind === 169 /* TypeAssertionExpression */) { - current = current.expression; - } - emitParenthesizedIf(body, current.kind === 163 /* ObjectLiteralExpression */); - } - function emitDownLevelExpressionFunctionBody(node, body) { - write(" {"); - scopeEmitStart(node); - increaseIndent(); - var outPos = writer.getTextPos(); - emitDetachedComments(node.body); - emitFunctionBodyPreamble(node); - var preambleEmitted = writer.getTextPos() !== outPos; - decreaseIndent(); - // If we didn't have to emit any preamble code, then attempt to keep the arrow - // function on one line. - if (!preambleEmitted && nodeStartPositionsAreOnSameLine(node, body)) { - write(" "); - emitStart(body); - write("return "); - emit(body); - emitEnd(body); - write(";"); - emitTempDeclarations(/*newLine*/ false); - write(" "); - } - else { - increaseIndent(); - writeLine(); - emitLeadingComments(node.body); - write("return "); - emit(body); - write(";"); - emitTrailingComments(node.body); - emitTempDeclarations(/*newLine*/ true); - decreaseIndent(); - writeLine(); - } - emitStart(node.body); - write("}"); - emitEnd(node.body); - scopeEmitEnd(); - } - function emitBlockFunctionBody(node, body) { - write(" {"); - scopeEmitStart(node); - var initialTextPos = writer.getTextPos(); - increaseIndent(); - emitDetachedComments(body.statements); - // Emit all the directive prologues (like "use strict"). These have to come before - // any other preamble code we write (like parameter initializers). - var startIndex = emitDirectivePrologues(body.statements, /*startWithNewLine*/ true); - emitFunctionBodyPreamble(node); - decreaseIndent(); - var preambleEmitted = writer.getTextPos() !== initialTextPos; - if (!preambleEmitted && nodeEndIsOnSameLineAsNodeStart(body, body)) { - for (var _a = 0, _b = body.statements; _a < _b.length; _a++) { - var statement = _b[_a]; - write(" "); - emit(statement); - } - emitTempDeclarations(/*newLine*/ false); - write(" "); - emitLeadingCommentsOfPosition(body.statements.end); - } - else { - increaseIndent(); - emitLinesStartingAt(body.statements, startIndex); - emitTempDeclarations(/*newLine*/ true); - writeLine(); - emitLeadingCommentsOfPosition(body.statements.end); - decreaseIndent(); - } - emitToken(16 /* CloseBraceToken */, body.statements.end); - scopeEmitEnd(); - } - function findInitialSuperCall(ctor) { - if (ctor.body) { - var statement = ctor.body.statements[0]; - if (statement && statement.kind === 193 /* ExpressionStatement */) { - var expr = statement.expression; - if (expr && expr.kind === 166 /* CallExpression */) { - var func = expr.expression; - if (func && func.kind === 93 /* SuperKeyword */) { - return statement; - } - } - } - } - } - function emitParameterPropertyAssignments(node) { - ts.forEach(node.parameters, function (param) { - if (param.flags & 112 /* AccessibilityModifier */) { - writeLine(); - emitStart(param); - emitStart(param.name); - write("this."); - emitNodeWithoutSourceMap(param.name); - emitEnd(param.name); - write(" = "); - emit(param.name); - write(";"); - emitEnd(param); - } - }); - } - function emitMemberAccessForPropertyName(memberName) { - // This does not emit source map because it is emitted by caller as caller - // is aware how the property name changes to the property access - // eg. public x = 10; becomes this.x and static x = 10 becomes className.x - if (memberName.kind === 9 /* StringLiteral */ || memberName.kind === 8 /* NumericLiteral */) { - write("["); - emitNodeWithCommentsAndWithoutSourcemap(memberName); - write("]"); - } - else if (memberName.kind === 134 /* ComputedPropertyName */) { - emitComputedPropertyName(memberName); - } - else { - write("."); - emitNodeWithCommentsAndWithoutSourcemap(memberName); - } - } - function getInitializedProperties(node, isStatic) { - var properties = []; - for (var _a = 0, _b = node.members; _a < _b.length; _a++) { - var member = _b[_a]; - if (member.kind === 139 /* PropertyDeclaration */ && isStatic === ((member.flags & 128 /* Static */) !== 0) && member.initializer) { - properties.push(member); - } - } - return properties; - } - function emitPropertyDeclarations(node, properties) { - for (var _a = 0; _a < properties.length; _a++) { - var property = properties[_a]; - emitPropertyDeclaration(node, property); - } - } - function emitPropertyDeclaration(node, property, receiver, isExpression) { - writeLine(); - emitLeadingComments(property); - emitStart(property); - emitStart(property.name); - if (receiver) { - emit(receiver); - } - else { - if (property.flags & 128 /* Static */) { - emitDeclarationName(node); - } - else { - write("this"); - } - } - emitMemberAccessForPropertyName(property.name); - emitEnd(property.name); - write(" = "); - emit(property.initializer); - if (!isExpression) { - write(";"); - } - emitEnd(property); - emitTrailingComments(property); - } - function emitMemberFunctionsForES5AndLower(node) { - ts.forEach(node.members, function (member) { - if (member.kind === 189 /* SemicolonClassElement */) { - writeLine(); - write(";"); - } - else if (member.kind === 141 /* MethodDeclaration */ || node.kind === 140 /* MethodSignature */) { - if (!member.body) { - return emitCommentsOnNotEmittedNode(member); - } - writeLine(); - emitLeadingComments(member); - emitStart(member); - emitStart(member.name); - emitClassMemberPrefix(node, member); - emitMemberAccessForPropertyName(member.name); - emitEnd(member.name); - write(" = "); - emitFunctionDeclaration(member); - emitEnd(member); - write(";"); - emitTrailingComments(member); - } - else if (member.kind === 143 /* GetAccessor */ || member.kind === 144 /* SetAccessor */) { - var accessors = ts.getAllAccessorDeclarations(node.members, member); - if (member === accessors.firstAccessor) { - writeLine(); - emitStart(member); - write("Object.defineProperty("); - emitStart(member.name); - emitClassMemberPrefix(node, member); - write(", "); - emitExpressionForPropertyName(member.name); - emitEnd(member.name); - write(", {"); - increaseIndent(); - if (accessors.getAccessor) { - writeLine(); - emitLeadingComments(accessors.getAccessor); - write("get: "); - emitStart(accessors.getAccessor); - write("function "); - emitSignatureAndBody(accessors.getAccessor); - emitEnd(accessors.getAccessor); - emitTrailingComments(accessors.getAccessor); - write(","); - } - if (accessors.setAccessor) { - writeLine(); - emitLeadingComments(accessors.setAccessor); - write("set: "); - emitStart(accessors.setAccessor); - write("function "); - emitSignatureAndBody(accessors.setAccessor); - emitEnd(accessors.setAccessor); - emitTrailingComments(accessors.setAccessor); - write(","); - } - writeLine(); - write("enumerable: true,"); - writeLine(); - write("configurable: true"); - decreaseIndent(); - writeLine(); - write("});"); - emitEnd(member); - } - } - }); - } - function emitMemberFunctionsForES6AndHigher(node) { - for (var _a = 0, _b = node.members; _a < _b.length; _a++) { - var member = _b[_a]; - if ((member.kind === 141 /* MethodDeclaration */ || node.kind === 140 /* MethodSignature */) && !member.body) { - emitCommentsOnNotEmittedNode(member); - } - else if (member.kind === 141 /* MethodDeclaration */ || - member.kind === 143 /* GetAccessor */ || - member.kind === 144 /* SetAccessor */) { - writeLine(); - emitLeadingComments(member); - emitStart(member); - if (member.flags & 128 /* Static */) { - write("static "); - } - if (member.kind === 143 /* GetAccessor */) { - write("get "); - } - else if (member.kind === 144 /* SetAccessor */) { - write("set "); - } - if (member.asteriskToken) { - write("*"); - } - emit(member.name); - emitSignatureAndBody(member); - emitEnd(member); - emitTrailingComments(member); - } - else if (member.kind === 189 /* SemicolonClassElement */) { - writeLine(); - write(";"); - } - } - } - function emitConstructor(node, baseTypeElement) { - var saveTempFlags = tempFlags; - var saveTempVariables = tempVariables; - var saveTempParameters = tempParameters; - tempFlags = 0; - tempVariables = undefined; - tempParameters = undefined; - emitConstructorWorker(node, baseTypeElement); - tempFlags = saveTempFlags; - tempVariables = saveTempVariables; - tempParameters = saveTempParameters; - } - function emitConstructorWorker(node, baseTypeElement) { - // Check if we have property assignment inside class declaration. - // If there is property assignment, we need to emit constructor whether users define it or not - // If there is no property assignment, we can omit constructor if users do not define it - var hasInstancePropertyWithInitializer = false; - // Emit the constructor overload pinned comments - ts.forEach(node.members, function (member) { - if (member.kind === 142 /* Constructor */ && !member.body) { - emitCommentsOnNotEmittedNode(member); - } - // Check if there is any non-static property assignment - if (member.kind === 139 /* PropertyDeclaration */ && member.initializer && (member.flags & 128 /* Static */) === 0) { - hasInstancePropertyWithInitializer = true; - } - }); - var ctor = ts.getFirstConstructorWithBody(node); - // For target ES6 and above, if there is no user-defined constructor and there is no property assignment - // do not emit constructor in class declaration. - if (languageVersion >= 2 /* ES6 */ && !ctor && !hasInstancePropertyWithInitializer) { - return; - } - if (ctor) { - emitLeadingComments(ctor); - } - emitStart(ctor || node); - if (languageVersion < 2 /* ES6 */) { - write("function "); - emitDeclarationName(node); - emitSignatureParameters(ctor); - } - else { - write("constructor"); - if (ctor) { - emitSignatureParameters(ctor); - } - else { - // Based on EcmaScript6 section 14.5.14: Runtime Semantics: ClassDefinitionEvaluation. - // If constructor is empty, then, - // If ClassHeritageopt is present, then - // Let constructor be the result of parsing the String "constructor(... args){ super (...args);}" using the syntactic grammar with the goal symbol MethodDefinition. - // Else, - // Let constructor be the result of parsing the String "constructor( ){ }" using the syntactic grammar with the goal symbol MethodDefinition - if (baseTypeElement) { - write("(...args)"); - } - else { - write("()"); - } - } - } - var startIndex = 0; - write(" {"); - scopeEmitStart(node, "constructor"); - increaseIndent(); - if (ctor) { - // Emit all the directive prologues (like "use strict"). These have to come before - // any other preamble code we write (like parameter initializers). - startIndex = emitDirectivePrologues(ctor.body.statements, /*startWithNewLine*/ true); - emitDetachedComments(ctor.body.statements); - } - emitCaptureThisForNodeIfNecessary(node); - var superCall; - if (ctor) { - emitDefaultValueAssignments(ctor); - emitRestParameter(ctor); - if (baseTypeElement) { - superCall = findInitialSuperCall(ctor); - if (superCall) { - writeLine(); - emit(superCall); - } - } - emitParameterPropertyAssignments(ctor); - } - else { - if (baseTypeElement) { - writeLine(); - emitStart(baseTypeElement); - if (languageVersion < 2 /* ES6 */) { - write("_super.apply(this, arguments);"); - } - else { - write("super(...args);"); - } - emitEnd(baseTypeElement); - } - } - emitPropertyDeclarations(node, getInitializedProperties(node, /*static:*/ false)); - if (ctor) { - var statements = ctor.body.statements; - if (superCall) { - statements = statements.slice(1); - } - emitLinesStartingAt(statements, startIndex); - } - emitTempDeclarations(/*newLine*/ true); - writeLine(); - if (ctor) { - emitLeadingCommentsOfPosition(ctor.body.statements.end); - } - decreaseIndent(); - emitToken(16 /* CloseBraceToken */, ctor ? ctor.body.statements.end : node.members.end); - scopeEmitEnd(); - emitEnd(ctor || node); - if (ctor) { - emitTrailingComments(ctor); - } - } - function emitClassExpression(node) { - return emitClassLikeDeclaration(node); - } - function emitClassDeclaration(node) { - return emitClassLikeDeclaration(node); - } - function emitClassLikeDeclaration(node) { - if (languageVersion < 2 /* ES6 */) { - emitClassLikeDeclarationBelowES6(node); - } - else { - emitClassLikeDeclarationForES6AndHigher(node); - } - } - function emitClassLikeDeclarationForES6AndHigher(node) { - var thisNodeIsDecorated = ts.nodeIsDecorated(node); - if (node.kind === 212 /* ClassDeclaration */) { - if (thisNodeIsDecorated) { - // To preserve the correct runtime semantics when decorators are applied to the class, - // the emit needs to follow one of the following rules: - // - // * For a local class declaration: - // - // @dec class C { - // } - // - // The emit should be: - // - // let C = class { - // }; - // Object.defineProperty(C, "name", { value: "C", configurable: true }); - // C = __decorate([dec], C); - // - // * For an exported class declaration: - // - // @dec export class C { - // } - // - // The emit should be: - // - // export let C = class { - // }; - // Object.defineProperty(C, "name", { value: "C", configurable: true }); - // C = __decorate([dec], C); - // - // * For a default export of a class declaration with a name: - // - // @dec default export class C { - // } - // - // The emit should be: - // - // let C = class { - // } - // Object.defineProperty(C, "name", { value: "C", configurable: true }); - // C = __decorate([dec], C); - // export default C; - // - // * For a default export of a class declaration without a name: - // - // @dec default export class { - // } - // - // The emit should be: - // - // let _default = class { - // } - // _default = __decorate([dec], _default); - // export default _default; - // - if (isES6ExportedDeclaration(node) && !(node.flags & 1024 /* Default */)) { - write("export "); - } - write("let "); - emitDeclarationName(node); - write(" = "); - } - else if (isES6ExportedDeclaration(node)) { - write("export "); - if (node.flags & 1024 /* Default */) { - write("default "); - } - } - } - // If the class has static properties, and it's a class expression, then we'll need - // to specialize the emit a bit. for a class expression of the form: - // - // class C { static a = 1; static b = 2; ... } - // - // We'll emit: - // - // (_temp = class C { ... }, _temp.a = 1, _temp.b = 2, _temp) - // - // This keeps the expression as an expression, while ensuring that the static parts - // of it have been initialized by the time it is used. - var staticProperties = getInitializedProperties(node, /*static:*/ true); - var isClassExpressionWithStaticProperties = staticProperties.length > 0 && node.kind === 184 /* ClassExpression */; - var tempVariable; - if (isClassExpressionWithStaticProperties) { - tempVariable = createAndRecordTempVariable(0 /* Auto */); - write("("); - increaseIndent(); - emit(tempVariable); - write(" = "); - } - write("class"); - // check if this is an "export default class" as it may not have a name. Do not emit the name if the class is decorated. - if ((node.name || !(node.flags & 1024 /* Default */)) && !thisNodeIsDecorated) { - write(" "); - emitDeclarationName(node); - } - var baseTypeNode = ts.getClassExtendsHeritageClauseElement(node); - if (baseTypeNode) { - write(" extends "); - emit(baseTypeNode.expression); - } - write(" {"); - increaseIndent(); - scopeEmitStart(node); - writeLine(); - emitConstructor(node, baseTypeNode); - emitMemberFunctionsForES6AndHigher(node); - decreaseIndent(); - writeLine(); - emitToken(16 /* CloseBraceToken */, node.members.end); - scopeEmitEnd(); - // TODO(rbuckton): Need to go back to `let _a = class C {}` approach, removing the defineProperty call for now. - // For a decorated class, we need to assign its name (if it has one). This is because we emit - // the class as a class expression to avoid the double-binding of the identifier: - // - // let C = class { - // } - // Object.defineProperty(C, "name", { value: "C", configurable: true }); - // - if (thisNodeIsDecorated) { - write(";"); - } - // Emit static property assignment. Because classDeclaration is lexically evaluated, - // it is safe to emit static property assignment after classDeclaration - // From ES6 specification: - // 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 (isClassExpressionWithStaticProperties) { - for (var _a = 0; _a < staticProperties.length; _a++) { - var property = staticProperties[_a]; - write(","); - writeLine(); - emitPropertyDeclaration(node, property, /*receiver:*/ tempVariable, /*isExpression:*/ true); - } - write(","); - writeLine(); - emit(tempVariable); - decreaseIndent(); - write(")"); - } - else { - writeLine(); - emitPropertyDeclarations(node, staticProperties); - emitDecoratorsOfClass(node); - } - // If this is an exported class, but not on the top level (i.e. on an internal - // module), export it - if (!isES6ExportedDeclaration(node) && (node.flags & 1 /* Export */)) { - writeLine(); - emitStart(node); - emitModuleMemberName(node); - write(" = "); - emitDeclarationName(node); - emitEnd(node); - write(";"); - } - else if (isES6ExportedDeclaration(node) && (node.flags & 1024 /* Default */) && thisNodeIsDecorated) { - // if this is a top level default export of decorated class, write the export after the declaration. - writeLine(); - write("export default "); - emitDeclarationName(node); - write(";"); - } - } - function emitClassLikeDeclarationBelowES6(node) { - if (node.kind === 212 /* ClassDeclaration */) { - // source file level classes in system modules are hoisted so 'var's for them are already defined - if (!shouldHoistDeclarationInSystemJsModule(node)) { - write("var "); - } - emitDeclarationName(node); - write(" = "); - } - write("(function ("); - var baseTypeNode = ts.getClassExtendsHeritageClauseElement(node); - if (baseTypeNode) { - write("_super"); - } - write(") {"); - var saveTempFlags = tempFlags; - var saveTempVariables = tempVariables; - var saveTempParameters = tempParameters; - var saveComputedPropertyNamesToGeneratedNames = computedPropertyNamesToGeneratedNames; - tempFlags = 0; - tempVariables = undefined; - tempParameters = undefined; - computedPropertyNamesToGeneratedNames = undefined; - increaseIndent(); - scopeEmitStart(node); - if (baseTypeNode) { - writeLine(); - emitStart(baseTypeNode); - write("__extends("); - emitDeclarationName(node); - write(", _super);"); - emitEnd(baseTypeNode); - } - writeLine(); - emitConstructor(node, baseTypeNode); - emitMemberFunctionsForES5AndLower(node); - emitPropertyDeclarations(node, getInitializedProperties(node, /*static:*/ true)); - writeLine(); - emitDecoratorsOfClass(node); - writeLine(); - emitToken(16 /* CloseBraceToken */, node.members.end, function () { - write("return "); - emitDeclarationName(node); - }); - write(";"); - emitTempDeclarations(/*newLine*/ true); - tempFlags = saveTempFlags; - tempVariables = saveTempVariables; - tempParameters = saveTempParameters; - computedPropertyNamesToGeneratedNames = saveComputedPropertyNamesToGeneratedNames; - decreaseIndent(); - writeLine(); - emitToken(16 /* CloseBraceToken */, node.members.end); - scopeEmitEnd(); - emitStart(node); - write(")("); - if (baseTypeNode) { - emit(baseTypeNode.expression); - } - write(")"); - if (node.kind === 212 /* ClassDeclaration */) { - write(";"); - } - emitEnd(node); - if (node.kind === 212 /* ClassDeclaration */) { - emitExportMemberAssignment(node); - } - if (languageVersion < 2 /* ES6 */ && node.parent === currentSourceFile && node.name) { - emitExportMemberAssignments(node.name); - } - } - function emitClassMemberPrefix(node, member) { - emitDeclarationName(node); - if (!(member.flags & 128 /* Static */)) { - write(".prototype"); - } - } - function emitDecoratorsOfClass(node) { - emitDecoratorsOfMembers(node, /*staticFlag*/ 0); - emitDecoratorsOfMembers(node, 128 /* Static */); - emitDecoratorsOfConstructor(node); - } - function emitDecoratorsOfConstructor(node) { - var decorators = node.decorators; - var constructor = ts.getFirstConstructorWithBody(node); - var hasDecoratedParameters = constructor && ts.forEach(constructor.parameters, ts.nodeIsDecorated); - // skip decoration of the constructor if neither it nor its parameters are decorated - if (!decorators && !hasDecoratedParameters) { - return; - } - // Emit the call to __decorate. Given the class: - // - // @dec - // class C { - // } - // - // The emit for the class is: - // - // C = __decorate([dec], C); - // - writeLine(); - emitStart(node); - emitDeclarationName(node); - write(" = __decorate(["); - increaseIndent(); - writeLine(); - var decoratorCount = decorators ? decorators.length : 0; - var argumentsWritten = emitList(decorators, 0, decoratorCount, /*multiLine*/ true, /*trailingComma*/ false, /*leadingComma*/ false, /*noTrailingNewLine*/ true, function (decorator) { - emitStart(decorator); - emit(decorator.expression); - emitEnd(decorator); - }); - argumentsWritten += emitDecoratorsOfParameters(constructor, /*leadingComma*/ argumentsWritten > 0); - emitSerializedTypeMetadata(node, /*leadingComma*/ argumentsWritten >= 0); - decreaseIndent(); - writeLine(); - write("], "); - emitDeclarationName(node); - write(");"); - emitEnd(node); - writeLine(); - } - function emitDecoratorsOfMembers(node, staticFlag) { - for (var _a = 0, _b = node.members; _a < _b.length; _a++) { - var member = _b[_a]; - // only emit members in the correct group - if ((member.flags & 128 /* Static */) !== staticFlag) { - continue; - } - // skip members that cannot be decorated (such as the constructor) - if (!ts.nodeCanBeDecorated(member)) { - continue; - } - // skip a member if it or any of its parameters are not decorated - if (!ts.nodeOrChildIsDecorated(member)) { - continue; - } - // skip an accessor declaration if it is not the first accessor - var decorators = void 0; - var functionLikeMember = void 0; - if (ts.isAccessor(member)) { - var accessors = ts.getAllAccessorDeclarations(node.members, member); - if (member !== accessors.firstAccessor) { - continue; - } - // get the decorators from the first accessor with decorators - decorators = accessors.firstAccessor.decorators; - if (!decorators && accessors.secondAccessor) { - decorators = accessors.secondAccessor.decorators; - } - // we only decorate parameters of the set accessor - functionLikeMember = accessors.setAccessor; - } - else { - decorators = member.decorators; - // we only decorate the parameters here if this is a method - if (member.kind === 141 /* MethodDeclaration */) { - functionLikeMember = member; - } - } - // Emit the call to __decorate. Given the following: - // - // class C { - // @dec method(@dec2 x) {} - // @dec get accessor() {} - // @dec prop; - // } - // - // The emit for a method is: - // - // Object.defineProperty(C.prototype, "method", - // __decorate([ - // dec, - // __param(0, dec2), - // __metadata("design:type", Function), - // __metadata("design:paramtypes", [Object]), - // __metadata("design:returntype", void 0) - // ], C.prototype, "method", Object.getOwnPropertyDescriptor(C.prototype, "method"))); - // - // The emit for an accessor is: - // - // Object.defineProperty(C.prototype, "accessor", - // __decorate([ - // dec - // ], C.prototype, "accessor", Object.getOwnPropertyDescriptor(C.prototype, "accessor"))); - // - // The emit for a property is: - // - // __decorate([ - // dec - // ], C.prototype, "prop"); - // - writeLine(); - emitStart(member); - if (member.kind !== 139 /* PropertyDeclaration */) { - write("Object.defineProperty("); - emitStart(member.name); - emitClassMemberPrefix(node, member); - write(", "); - emitExpressionForPropertyName(member.name); - emitEnd(member.name); - write(","); - increaseIndent(); - writeLine(); - } - write("__decorate(["); - increaseIndent(); - writeLine(); - var decoratorCount = decorators ? decorators.length : 0; - var argumentsWritten = emitList(decorators, 0, decoratorCount, /*multiLine*/ true, /*trailingComma*/ false, /*leadingComma*/ false, /*noTrailingNewLine*/ true, function (decorator) { - emitStart(decorator); - emit(decorator.expression); - emitEnd(decorator); - }); - argumentsWritten += emitDecoratorsOfParameters(functionLikeMember, argumentsWritten > 0); - emitSerializedTypeMetadata(member, argumentsWritten > 0); - decreaseIndent(); - writeLine(); - write("], "); - emitStart(member.name); - emitClassMemberPrefix(node, member); - write(", "); - emitExpressionForPropertyName(member.name); - emitEnd(member.name); - if (member.kind !== 139 /* PropertyDeclaration */) { - write(", Object.getOwnPropertyDescriptor("); - emitStart(member.name); - emitClassMemberPrefix(node, member); - write(", "); - emitExpressionForPropertyName(member.name); - emitEnd(member.name); - write("))"); - decreaseIndent(); - } - write(");"); - emitEnd(member); - writeLine(); - } - } - function emitDecoratorsOfParameters(node, leadingComma) { - var argumentsWritten = 0; - if (node) { - var parameterIndex = 0; - for (var _a = 0, _b = node.parameters; _a < _b.length; _a++) { - var parameter = _b[_a]; - if (ts.nodeIsDecorated(parameter)) { - var decorators = parameter.decorators; - argumentsWritten += emitList(decorators, 0, decorators.length, /*multiLine*/ true, /*trailingComma*/ false, /*leadingComma*/ leadingComma, /*noTrailingNewLine*/ true, function (decorator) { - emitStart(decorator); - write("__param(" + parameterIndex + ", "); - emit(decorator.expression); - write(")"); - emitEnd(decorator); - }); - leadingComma = true; - } - ++parameterIndex; - } - } - return argumentsWritten; - } - function shouldEmitTypeMetadata(node) { - // This method determines whether to emit the "design:type" metadata based on the node's kind. - // The caller should have already tested whether the node has decorators and whether the emitDecoratorMetadata - // compiler option is set. - switch (node.kind) { - case 141 /* MethodDeclaration */: - case 143 /* GetAccessor */: - case 144 /* SetAccessor */: - case 139 /* PropertyDeclaration */: - return true; - } - return false; - } - function shouldEmitReturnTypeMetadata(node) { - // This method determines whether to emit the "design:returntype" metadata based on the node's kind. - // The caller should have already tested whether the node has decorators and whether the emitDecoratorMetadata - // compiler option is set. - switch (node.kind) { - case 141 /* MethodDeclaration */: - return true; - } - return false; - } - function shouldEmitParamTypesMetadata(node) { - // This method determines whether to emit the "design:paramtypes" metadata based on the node's kind. - // The caller should have already tested whether the node has decorators and whether the emitDecoratorMetadata - // compiler option is set. - switch (node.kind) { - case 212 /* ClassDeclaration */: - case 141 /* MethodDeclaration */: - case 144 /* SetAccessor */: - return true; - } - return false; - } - /** Serializes the type of a declaration to an appropriate JS constructor value. Used by the __metadata decorator for a class member. */ - function emitSerializedTypeOfNode(node) { - // serialization of the type of a declaration uses the following rules: - // - // * The serialized type of a ClassDeclaration is "Function" - // * The serialized type of a ParameterDeclaration is the serialized type of its type annotation. - // * The serialized type of a PropertyDeclaration is the serialized type of its type annotation. - // * The serialized type of an AccessorDeclaration is the serialized type of the return type annotation of its getter or parameter type annotation of its setter. - // * The serialized type of any other FunctionLikeDeclaration is "Function". - // * The serialized type of any other node is "void 0". - // - // For rules on serializing type annotations, see `serializeTypeNode`. - switch (node.kind) { - case 212 /* ClassDeclaration */: - write("Function"); - return; - case 139 /* PropertyDeclaration */: - emitSerializedTypeNode(node.type); - return; - case 136 /* Parameter */: - emitSerializedTypeNode(node.type); - return; - case 143 /* GetAccessor */: - emitSerializedTypeNode(node.type); - return; - case 144 /* SetAccessor */: - emitSerializedTypeNode(ts.getSetAccessorTypeAnnotationNode(node)); - return; - } - if (ts.isFunctionLike(node)) { - write("Function"); - return; - } - write("void 0"); - } - function emitSerializedTypeNode(node) { - if (node) { - switch (node.kind) { - case 101 /* VoidKeyword */: - write("void 0"); - return; - case 158 /* ParenthesizedType */: - emitSerializedTypeNode(node.type); - return; - case 150 /* FunctionType */: - case 151 /* ConstructorType */: - write("Function"); - return; - case 154 /* ArrayType */: - case 155 /* TupleType */: - write("Array"); - return; - case 148 /* TypePredicate */: - case 118 /* BooleanKeyword */: - write("Boolean"); - return; - case 128 /* StringKeyword */: - case 9 /* StringLiteral */: - write("String"); - return; - case 126 /* NumberKeyword */: - write("Number"); - return; - case 129 /* SymbolKeyword */: - write("Symbol"); - return; - case 149 /* TypeReference */: - emitSerializedTypeReferenceNode(node); - return; - case 152 /* TypeQuery */: - case 153 /* TypeLiteral */: - case 156 /* UnionType */: - case 157 /* IntersectionType */: - case 115 /* AnyKeyword */: - break; - default: - ts.Debug.fail("Cannot serialize unexpected type node."); - break; - } - } - write("Object"); - } - /** Serializes a TypeReferenceNode to an appropriate JS constructor value. Used by the __metadata decorator. */ - function emitSerializedTypeReferenceNode(node) { - var location = node.parent; - while (ts.isDeclaration(location) || ts.isTypeNode(location)) { - location = location.parent; - } - // Clone the type name and parent it to a location outside of the current declaration. - var typeName = ts.cloneEntityName(node.typeName); - typeName.parent = location; - var result = resolver.getTypeReferenceSerializationKind(typeName); - switch (result) { - case ts.TypeReferenceSerializationKind.Unknown: - var temp = createAndRecordTempVariable(0 /* Auto */); - write("(typeof ("); - emitNodeWithoutSourceMap(temp); - write(" = "); - emitEntityNameAsExpression(typeName, /*useFallback*/ true); - write(") === 'function' && "); - emitNodeWithoutSourceMap(temp); - write(") || Object"); - break; - case ts.TypeReferenceSerializationKind.TypeWithConstructSignatureAndValue: - emitEntityNameAsExpression(typeName, /*useFallback*/ false); - break; - case ts.TypeReferenceSerializationKind.VoidType: - write("void 0"); - break; - case ts.TypeReferenceSerializationKind.BooleanType: - write("Boolean"); - break; - case ts.TypeReferenceSerializationKind.NumberLikeType: - write("Number"); - break; - case ts.TypeReferenceSerializationKind.StringLikeType: - write("String"); - break; - case ts.TypeReferenceSerializationKind.ArrayLikeType: - write("Array"); - break; - case ts.TypeReferenceSerializationKind.ESSymbolType: - if (languageVersion < 2 /* ES6 */) { - write("typeof Symbol === 'function' ? Symbol : Object"); - } - else { - write("Symbol"); - } - break; - case ts.TypeReferenceSerializationKind.TypeWithCallSignature: - write("Function"); - break; - case ts.TypeReferenceSerializationKind.ObjectType: - write("Object"); - break; - } - } - /** Serializes the parameter types of a function or the constructor of a class. Used by the __metadata decorator for a method or set accessor. */ - function emitSerializedParameterTypesOfNode(node) { - // serialization of parameter types uses the following rules: - // - // * If the declaration is a class, the parameters of the first constructor with a body are used. - // * If the declaration is function-like and has a body, the parameters of the function are used. - // - // For the rules on serializing the type of each parameter declaration, see `serializeTypeOfDeclaration`. - if (node) { - var valueDeclaration; - if (node.kind === 212 /* ClassDeclaration */) { - valueDeclaration = ts.getFirstConstructorWithBody(node); - } - else if (ts.isFunctionLike(node) && ts.nodeIsPresent(node.body)) { - valueDeclaration = node; - } - if (valueDeclaration) { - var parameters = valueDeclaration.parameters; - var parameterCount = parameters.length; - if (parameterCount > 0) { - for (var i = 0; i < parameterCount; i++) { - if (i > 0) { - write(", "); - } - if (parameters[i].dotDotDotToken) { - var parameterType = parameters[i].type; - if (parameterType.kind === 154 /* ArrayType */) { - parameterType = parameterType.elementType; - } - else if (parameterType.kind === 149 /* TypeReference */ && parameterType.typeArguments && parameterType.typeArguments.length === 1) { - parameterType = parameterType.typeArguments[0]; - } - else { - parameterType = undefined; - } - emitSerializedTypeNode(parameterType); - } - else { - emitSerializedTypeOfNode(parameters[i]); - } - } - } - } - } - } - /** Serializes the return type of function. Used by the __metadata decorator for a method. */ - function emitSerializedReturnTypeOfNode(node) { - if (node && ts.isFunctionLike(node) && node.type) { - emitSerializedTypeNode(node.type); - return; - } - write("void 0"); - } - function emitSerializedTypeMetadata(node, writeComma) { - // This method emits the serialized type metadata for a decorator target. - // The caller should have already tested whether the node has decorators. - var argumentsWritten = 0; - if (compilerOptions.emitDecoratorMetadata) { - if (shouldEmitTypeMetadata(node)) { - if (writeComma) { - write(", "); - } - writeLine(); - write("__metadata('design:type', "); - emitSerializedTypeOfNode(node); - write(")"); - argumentsWritten++; - } - if (shouldEmitParamTypesMetadata(node)) { - if (writeComma || argumentsWritten) { - write(", "); - } - writeLine(); - write("__metadata('design:paramtypes', ["); - emitSerializedParameterTypesOfNode(node); - write("])"); - argumentsWritten++; - } - if (shouldEmitReturnTypeMetadata(node)) { - if (writeComma || argumentsWritten) { - write(", "); - } - writeLine(); - write("__metadata('design:returntype', "); - emitSerializedReturnTypeOfNode(node); - write(")"); - argumentsWritten++; - } - } - return argumentsWritten; - } - function emitInterfaceDeclaration(node) { - emitCommentsOnNotEmittedNode(node); - } - function shouldEmitEnumDeclaration(node) { - var isConstEnum = ts.isConst(node); - return !isConstEnum || compilerOptions.preserveConstEnums || compilerOptions.isolatedModules; - } - function emitEnumDeclaration(node) { - // const enums are completely erased during compilation. - if (!shouldEmitEnumDeclaration(node)) { - return; - } - if (!shouldHoistDeclarationInSystemJsModule(node)) { - // do not emit var if variable was already hoisted - if (!(node.flags & 1 /* Export */) || isES6ExportedDeclaration(node)) { - emitStart(node); - if (isES6ExportedDeclaration(node)) { - write("export "); - } - write("var "); - emit(node.name); - emitEnd(node); - write(";"); - } - } - writeLine(); - emitStart(node); - write("(function ("); - emitStart(node.name); - write(getGeneratedNameForNode(node)); - emitEnd(node.name); - write(") {"); - increaseIndent(); - scopeEmitStart(node); - emitLines(node.members); - decreaseIndent(); - writeLine(); - emitToken(16 /* CloseBraceToken */, node.members.end); - scopeEmitEnd(); - write(")("); - emitModuleMemberName(node); - write(" || ("); - emitModuleMemberName(node); - write(" = {}));"); - emitEnd(node); - if (!isES6ExportedDeclaration(node) && node.flags & 1 /* Export */ && !shouldHoistDeclarationInSystemJsModule(node)) { - // do not emit var if variable was already hoisted - writeLine(); - emitStart(node); - write("var "); - emit(node.name); - write(" = "); - emitModuleMemberName(node); - emitEnd(node); - write(";"); - } - if (languageVersion < 2 /* ES6 */ && node.parent === currentSourceFile) { - if (compilerOptions.module === 4 /* System */ && (node.flags & 1 /* Export */)) { - // write the call to exporter for enum - writeLine(); - write(exportFunctionForFile + "(\""); - emitDeclarationName(node); - write("\", "); - emitDeclarationName(node); - write(");"); - } - emitExportMemberAssignments(node.name); - } - } - function emitEnumMember(node) { - var enumParent = node.parent; - emitStart(node); - write(getGeneratedNameForNode(enumParent)); - write("["); - write(getGeneratedNameForNode(enumParent)); - write("["); - emitExpressionForPropertyName(node.name); - write("] = "); - writeEnumMemberDeclarationValue(node); - write("] = "); - emitExpressionForPropertyName(node.name); - emitEnd(node); - write(";"); - } - function writeEnumMemberDeclarationValue(member) { - var value = resolver.getConstantValue(member); - if (value !== undefined) { - write(value.toString()); - return; - } - else if (member.initializer) { - emit(member.initializer); - } - else { - write("undefined"); - } - } - function getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration) { - if (moduleDeclaration.body.kind === 216 /* ModuleDeclaration */) { - var recursiveInnerModule = getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration.body); - return recursiveInnerModule || moduleDeclaration.body; - } - } - function shouldEmitModuleDeclaration(node) { - return ts.isInstantiatedModule(node, compilerOptions.preserveConstEnums || compilerOptions.isolatedModules); - } - function isModuleMergedWithES6Class(node) { - return languageVersion === 2 /* ES6 */ && !!(resolver.getNodeCheckFlags(node) & 32768 /* LexicalModuleMergesWithClass */); - } - function emitModuleDeclaration(node) { - // Emit only if this module is non-ambient. - var shouldEmit = shouldEmitModuleDeclaration(node); - if (!shouldEmit) { - return emitCommentsOnNotEmittedNode(node); - } - var hoistedInDeclarationScope = shouldHoistDeclarationInSystemJsModule(node); - var emitVarForModule = !hoistedInDeclarationScope && !isModuleMergedWithES6Class(node); - if (emitVarForModule) { - emitStart(node); - if (isES6ExportedDeclaration(node)) { - write("export "); - } - write("var "); - emit(node.name); - write(";"); - emitEnd(node); - writeLine(); - } - emitStart(node); - write("(function ("); - emitStart(node.name); - write(getGeneratedNameForNode(node)); - emitEnd(node.name); - write(") "); - if (node.body.kind === 217 /* ModuleBlock */) { - var saveTempFlags = tempFlags; - var saveTempVariables = tempVariables; - tempFlags = 0; - tempVariables = undefined; - emit(node.body); - tempFlags = saveTempFlags; - tempVariables = saveTempVariables; - } - else { - write("{"); - increaseIndent(); - scopeEmitStart(node); - emitCaptureThisForNodeIfNecessary(node); - writeLine(); - emit(node.body); - decreaseIndent(); - writeLine(); - var moduleBlock = getInnerMostModuleDeclarationFromDottedModule(node).body; - emitToken(16 /* CloseBraceToken */, moduleBlock.statements.end); - scopeEmitEnd(); - } - write(")("); - // write moduleDecl = containingModule.m only if it is not exported es6 module member - if ((node.flags & 1 /* Export */) && !isES6ExportedDeclaration(node)) { - emit(node.name); - write(" = "); - } - emitModuleMemberName(node); - write(" || ("); - emitModuleMemberName(node); - write(" = {}));"); - emitEnd(node); - if (!isES6ExportedDeclaration(node) && node.name.kind === 67 /* Identifier */ && node.parent === currentSourceFile) { - if (compilerOptions.module === 4 /* System */ && (node.flags & 1 /* Export */)) { - writeLine(); - write(exportFunctionForFile + "(\""); - emitDeclarationName(node); - write("\", "); - emitDeclarationName(node); - write(");"); - } - emitExportMemberAssignments(node.name); - } - } - /* - * Some bundlers (SystemJS builder) sometimes want to rename dependencies. - * Here we check if alternative name was provided for a given moduleName and return it if possible. - */ - function tryRenameExternalModule(moduleName) { - if (currentSourceFile.renamedDependencies && ts.hasProperty(currentSourceFile.renamedDependencies, moduleName.text)) { - return "\"" + currentSourceFile.renamedDependencies[moduleName.text] + "\""; - } - return undefined; - } - function emitRequire(moduleName) { - if (moduleName.kind === 9 /* StringLiteral */) { - write("require("); - var text = tryRenameExternalModule(moduleName); - if (text) { - write(text); - } - else { - emitStart(moduleName); - emitLiteral(moduleName); - emitEnd(moduleName); - } - emitToken(18 /* CloseParenToken */, moduleName.end); - } - else { - write("require()"); - } - } - function getNamespaceDeclarationNode(node) { - if (node.kind === 219 /* ImportEqualsDeclaration */) { - return node; - } - var importClause = node.importClause; - if (importClause && importClause.namedBindings && importClause.namedBindings.kind === 222 /* NamespaceImport */) { - return importClause.namedBindings; - } - } - function isDefaultImport(node) { - return node.kind === 220 /* ImportDeclaration */ && node.importClause && !!node.importClause.name; - } - function emitExportImportAssignments(node) { - if (ts.isAliasSymbolDeclaration(node) && resolver.isValueAliasDeclaration(node)) { - emitExportMemberAssignments(node.name); - } - ts.forEachChild(node, emitExportImportAssignments); - } - function emitImportDeclaration(node) { - if (languageVersion < 2 /* ES6 */) { - return emitExternalImportDeclaration(node); - } - // ES6 import - if (node.importClause) { - var shouldEmitDefaultBindings = resolver.isReferencedAliasDeclaration(node.importClause); - var shouldEmitNamedBindings = node.importClause.namedBindings && resolver.isReferencedAliasDeclaration(node.importClause.namedBindings, /* checkChildren */ true); - if (shouldEmitDefaultBindings || shouldEmitNamedBindings) { - write("import "); - emitStart(node.importClause); - if (shouldEmitDefaultBindings) { - emit(node.importClause.name); - if (shouldEmitNamedBindings) { - write(", "); - } - } - if (shouldEmitNamedBindings) { - emitLeadingComments(node.importClause.namedBindings); - emitStart(node.importClause.namedBindings); - if (node.importClause.namedBindings.kind === 222 /* NamespaceImport */) { - write("* as "); - emit(node.importClause.namedBindings.name); - } - else { - write("{ "); - emitExportOrImportSpecifierList(node.importClause.namedBindings.elements, resolver.isReferencedAliasDeclaration); - write(" }"); - } - emitEnd(node.importClause.namedBindings); - emitTrailingComments(node.importClause.namedBindings); - } - emitEnd(node.importClause); - write(" from "); - emit(node.moduleSpecifier); - write(";"); - } - } - else { - write("import "); - emit(node.moduleSpecifier); - write(";"); - } - } - function emitExternalImportDeclaration(node) { - if (ts.contains(externalImports, node)) { - var isExportedImport = node.kind === 219 /* ImportEqualsDeclaration */ && (node.flags & 1 /* Export */) !== 0; - var namespaceDeclaration = getNamespaceDeclarationNode(node); - if (compilerOptions.module !== 2 /* AMD */) { - emitLeadingComments(node); - emitStart(node); - if (namespaceDeclaration && !isDefaultImport(node)) { - // import x = require("foo") - // import * as x from "foo" - if (!isExportedImport) - write("var "); - emitModuleMemberName(namespaceDeclaration); - write(" = "); - } - else { - // import "foo" - // import x from "foo" - // import { x, y } from "foo" - // import d, * as x from "foo" - // import d, { x, y } from "foo" - var isNakedImport = 220 /* ImportDeclaration */ && !node.importClause; - if (!isNakedImport) { - write("var "); - write(getGeneratedNameForNode(node)); - write(" = "); - } - } - emitRequire(ts.getExternalModuleName(node)); - if (namespaceDeclaration && isDefaultImport(node)) { - // import d, * as x from "foo" - write(", "); - emitModuleMemberName(namespaceDeclaration); - write(" = "); - write(getGeneratedNameForNode(node)); - } - write(";"); - emitEnd(node); - emitExportImportAssignments(node); - emitTrailingComments(node); - } - else { - if (isExportedImport) { - emitModuleMemberName(namespaceDeclaration); - write(" = "); - emit(namespaceDeclaration.name); - write(";"); - } - else if (namespaceDeclaration && isDefaultImport(node)) { - // import d, * as x from "foo" - write("var "); - emitModuleMemberName(namespaceDeclaration); - write(" = "); - write(getGeneratedNameForNode(node)); - write(";"); - } - emitExportImportAssignments(node); - } - } - } - function emitImportEqualsDeclaration(node) { - if (ts.isExternalModuleImportEqualsDeclaration(node)) { - emitExternalImportDeclaration(node); - return; - } - // preserve old compiler's behavior: emit 'var' for import declaration (even if we do not consider them referenced) when - // - current file is not external module - // - import declaration is top level and target is value imported by entity name - if (resolver.isReferencedAliasDeclaration(node) || - (!ts.isExternalModule(currentSourceFile) && resolver.isTopLevelValueImportEqualsWithEntityName(node))) { - emitLeadingComments(node); - emitStart(node); - // variable declaration for import-equals declaration can be hoisted in system modules - // in this case 'var' should be omitted and emit should contain only initialization - var variableDeclarationIsHoisted = shouldHoistVariable(node, /*checkIfSourceFileLevelDecl*/ true); - // is it top level export import v = a.b.c in system module? - // if yes - it needs to be rewritten as exporter('v', v = a.b.c) - var isExported = isSourceFileLevelDeclarationInSystemJsModule(node, /*isExported*/ true); - if (!variableDeclarationIsHoisted) { - ts.Debug.assert(!isExported); - if (isES6ExportedDeclaration(node)) { - write("export "); - write("var "); - } - else if (!(node.flags & 1 /* Export */)) { - write("var "); - } - } - if (isExported) { - write(exportFunctionForFile + "(\""); - emitNodeWithoutSourceMap(node.name); - write("\", "); - } - emitModuleMemberName(node); - write(" = "); - emit(node.moduleReference); - if (isExported) { - write(")"); - } - write(";"); - emitEnd(node); - emitExportImportAssignments(node); - emitTrailingComments(node); - } - } - function emitExportDeclaration(node) { - ts.Debug.assert(compilerOptions.module !== 4 /* System */); - if (languageVersion < 2 /* ES6 */) { - if (node.moduleSpecifier && (!node.exportClause || resolver.isValueAliasDeclaration(node))) { - emitStart(node); - var generatedName = getGeneratedNameForNode(node); - if (node.exportClause) { - // export { x, y, ... } from "foo" - if (compilerOptions.module !== 2 /* AMD */) { - write("var "); - write(generatedName); - write(" = "); - emitRequire(ts.getExternalModuleName(node)); - write(";"); - } - for (var _a = 0, _b = node.exportClause.elements; _a < _b.length; _a++) { - var specifier = _b[_a]; - if (resolver.isValueAliasDeclaration(specifier)) { - writeLine(); - emitStart(specifier); - emitContainingModuleName(specifier); - write("."); - emitNodeWithCommentsAndWithoutSourcemap(specifier.name); - write(" = "); - write(generatedName); - write("."); - emitNodeWithCommentsAndWithoutSourcemap(specifier.propertyName || specifier.name); - write(";"); - emitEnd(specifier); - } - } - } - else { - // export * from "foo" - writeLine(); - write("__export("); - if (compilerOptions.module !== 2 /* AMD */) { - emitRequire(ts.getExternalModuleName(node)); - } - else { - write(generatedName); - } - write(");"); - } - emitEnd(node); - } - } - else { - if (!node.exportClause || resolver.isValueAliasDeclaration(node)) { - write("export "); - if (node.exportClause) { - // export { x, y, ... } - write("{ "); - emitExportOrImportSpecifierList(node.exportClause.elements, resolver.isValueAliasDeclaration); - write(" }"); - } - else { - write("*"); - } - if (node.moduleSpecifier) { - write(" from "); - emit(node.moduleSpecifier); - } - write(";"); - } - } - } - function emitExportOrImportSpecifierList(specifiers, shouldEmit) { - ts.Debug.assert(languageVersion >= 2 /* ES6 */); - var needsComma = false; - for (var _a = 0; _a < specifiers.length; _a++) { - var specifier = specifiers[_a]; - if (shouldEmit(specifier)) { - if (needsComma) { - write(", "); - } - if (specifier.propertyName) { - emit(specifier.propertyName); - write(" as "); - } - emit(specifier.name); - needsComma = true; - } - } - } - function emitExportAssignment(node) { - if (!node.isExportEquals && resolver.isValueAliasDeclaration(node)) { - if (languageVersion >= 2 /* ES6 */) { - writeLine(); - emitStart(node); - write("export default "); - var expression = node.expression; - emit(expression); - if (expression.kind !== 211 /* FunctionDeclaration */ && - expression.kind !== 212 /* ClassDeclaration */) { - write(";"); - } - emitEnd(node); - } - else { - writeLine(); - emitStart(node); - if (compilerOptions.module === 4 /* System */) { - write(exportFunctionForFile + "(\"default\","); - emit(node.expression); - write(")"); - } - else { - emitEs6ExportDefaultCompat(node); - emitContainingModuleName(node); - if (languageVersion === 0 /* ES3 */) { - write("[\"default\"] = "); - } - else { - write(".default = "); - } - emit(node.expression); - } - write(";"); - emitEnd(node); - } - } - } - function collectExternalModuleInfo(sourceFile) { - externalImports = []; - exportSpecifiers = {}; - exportEquals = undefined; - hasExportStars = false; - for (var _a = 0, _b = sourceFile.statements; _a < _b.length; _a++) { - var node = _b[_a]; - switch (node.kind) { - case 220 /* 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); - } - break; - case 219 /* ImportEqualsDeclaration */: - if (node.moduleReference.kind === 230 /* ExternalModuleReference */ && resolver.isReferencedAliasDeclaration(node)) { - // import x = require("mod") where x is referenced - externalImports.push(node); - } - break; - case 226 /* ExportDeclaration */: - if (node.moduleSpecifier) { - if (!node.exportClause) { - // export * from "mod" - externalImports.push(node); - hasExportStars = true; - } - else if (resolver.isValueAliasDeclaration(node)) { - // export { x, y } from "mod" where at least one export is a value symbol - externalImports.push(node); - } - } - else { - // export { x, y } - for (var _c = 0, _d = node.exportClause.elements; _c < _d.length; _c++) { - var specifier = _d[_c]; - var name_24 = (specifier.propertyName || specifier.name).text; - (exportSpecifiers[name_24] || (exportSpecifiers[name_24] = [])).push(specifier); - } - } - break; - case 225 /* ExportAssignment */: - if (node.isExportEquals && !exportEquals) { - // export = x - exportEquals = node; - } - break; - } - } - } - function emitExportStarHelper() { - if (hasExportStars) { - writeLine(); - write("function __export(m) {"); - increaseIndent(); - writeLine(); - write("for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];"); - decreaseIndent(); - writeLine(); - write("}"); - } - } - function getLocalNameForExternalImport(node) { - var namespaceDeclaration = getNamespaceDeclarationNode(node); - if (namespaceDeclaration && !isDefaultImport(node)) { - return ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, namespaceDeclaration.name); - } - if (node.kind === 220 /* ImportDeclaration */ && node.importClause) { - return getGeneratedNameForNode(node); - } - if (node.kind === 226 /* ExportDeclaration */ && node.moduleSpecifier) { - return getGeneratedNameForNode(node); - } - } - function getExternalModuleNameText(importNode) { - var moduleName = ts.getExternalModuleName(importNode); - if (moduleName.kind === 9 /* StringLiteral */) { - return tryRenameExternalModule(moduleName) || getLiteralText(moduleName); - } - return undefined; - } - function emitVariableDeclarationsForImports() { - if (externalImports.length === 0) { - return; - } - writeLine(); - var started = false; - for (var _a = 0; _a < externalImports.length; _a++) { - var importNode = externalImports[_a]; - // do not create variable declaration for exports and imports that lack import clause - var skipNode = importNode.kind === 226 /* ExportDeclaration */ || - (importNode.kind === 220 /* ImportDeclaration */ && !importNode.importClause); - if (skipNode) { - continue; - } - if (!started) { - write("var "); - started = true; - } - else { - write(", "); - } - write(getLocalNameForExternalImport(importNode)); - } - if (started) { - write(";"); - } - } - function emitLocalStorageForExportedNamesIfNecessary(exportedDeclarations) { - // 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. - if (!hasExportStars) { - // local names set is needed only in presence of star exports - return undefined; - } - // local names set should only be added if we have anything exported - if (!exportedDeclarations && 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 _a = 0; _a < externalImports.length; _a++) { - var externalImport = externalImports[_a]; - if (externalImport.kind === 226 /* ExportDeclaration */ && externalImport.exportClause) { - hasExportDeclarationWithExportClause = true; - break; - } - } - if (!hasExportDeclarationWithExportClause) { - // we still need to emit exportStar helper - return emitExportStarFunction(/*localNames*/ undefined); - } - } - var exportedNamesStorageRef = makeUniqueName("exportedNames"); - writeLine(); - write("var " + exportedNamesStorageRef + " = {"); - increaseIndent(); - var started = false; - if (exportedDeclarations) { - for (var i = 0; i < exportedDeclarations.length; ++i) { - // write name of exported declaration, i.e 'export var x...' - writeExportedName(exportedDeclarations[i]); - } - } - if (exportSpecifiers) { - for (var n in exportSpecifiers) { - for (var _b = 0, _c = exportSpecifiers[n]; _b < _c.length; _b++) { - var specifier = _c[_b]; - // write name of export specified, i.e. 'export {x}' - writeExportedName(specifier.name); - } - } - } - for (var _d = 0; _d < externalImports.length; _d++) { - var externalImport = externalImports[_d]; - if (externalImport.kind !== 226 /* ExportDeclaration */) { - continue; - } - var exportDecl = externalImport; - if (!exportDecl.exportClause) { - // export * from ... - continue; - } - for (var _e = 0, _f = exportDecl.exportClause.elements; _e < _f.length; _e++) { - var element = _f[_e]; - // write name of indirectly exported entry, i.e. 'export {x} from ...' - writeExportedName(element.name || element.propertyName); - } - } - decreaseIndent(); - writeLine(); - write("};"); - return emitExportStarFunction(exportedNamesStorageRef); - function emitExportStarFunction(localNames) { - var exportStarFunction = makeUniqueName("exportStar"); - writeLine(); - // define an export star helper function - write("function " + exportStarFunction + "(m) {"); - increaseIndent(); - writeLine(); - write("var exports = {};"); - writeLine(); - write("for(var n in m) {"); - increaseIndent(); - writeLine(); - write("if (n !== \"default\""); - if (localNames) { - write("&& !" + localNames + ".hasOwnProperty(n)"); - } - write(") exports[n] = m[n];"); - decreaseIndent(); - writeLine(); - write("}"); - writeLine(); - write(exportFunctionForFile + "(exports);"); - decreaseIndent(); - writeLine(); - write("}"); - return exportStarFunction; - } - function writeExportedName(node) { - // do not record default exports - // they are local to module and never overwritten (explicitly skipped) by star export - if (node.kind !== 67 /* Identifier */ && node.flags & 1024 /* Default */) { - return; - } - if (started) { - write(","); - } - else { - started = true; - } - writeLine(); - write("'"); - if (node.kind === 67 /* Identifier */) { - emitNodeWithCommentsAndWithoutSourcemap(node); - } - else { - emitDeclarationName(node); - } - write("': true"); - } - } - function processTopLevelVariableAndFunctionDeclarations(node) { - // per ES6 spec: - // 15.2.1.16.4 ModuleDeclarationInstantiation() Concrete Method - // - var declarations are initialized to undefined - 14.a.ii - // - function/generator declarations are instantiated - 16.a.iv - // this means that after module is instantiated but before its evaluation - // exported functions are already accessible at import sites - // in theory we should hoist only exported functions and its dependencies - // in practice to simplify things we'll hoist all source level functions and variable declaration - // including variables declarations for module and class declarations - var hoistedVars; - var hoistedFunctionDeclarations; - var exportedDeclarations; - visit(node); - if (hoistedVars) { - writeLine(); - write("var "); - var seen = {}; - for (var i = 0; i < hoistedVars.length; ++i) { - var local = hoistedVars[i]; - var name_25 = local.kind === 67 /* Identifier */ - ? local - : local.name; - if (name_25) { - // do not emit duplicate entries (in case of declaration merging) in the list of hoisted variables - var text = ts.unescapeIdentifier(name_25.text); - if (ts.hasProperty(seen, text)) { - continue; - } - else { - seen[text] = text; - } - } - if (i !== 0) { - write(", "); - } - if (local.kind === 212 /* ClassDeclaration */ || local.kind === 216 /* ModuleDeclaration */ || local.kind === 215 /* EnumDeclaration */) { - emitDeclarationName(local); - } - else { - emit(local); - } - var flags = ts.getCombinedNodeFlags(local.kind === 67 /* Identifier */ ? local.parent : local); - if (flags & 1 /* Export */) { - if (!exportedDeclarations) { - exportedDeclarations = []; - } - exportedDeclarations.push(local); - } - } - write(";"); - } - if (hoistedFunctionDeclarations) { - for (var _a = 0; _a < hoistedFunctionDeclarations.length; _a++) { - var f = hoistedFunctionDeclarations[_a]; - writeLine(); - emit(f); - if (f.flags & 1 /* Export */) { - if (!exportedDeclarations) { - exportedDeclarations = []; - } - exportedDeclarations.push(f); - } - } - } - return exportedDeclarations; - function visit(node) { - if (node.flags & 2 /* Ambient */) { - return; - } - if (node.kind === 211 /* FunctionDeclaration */) { - if (!hoistedFunctionDeclarations) { - hoistedFunctionDeclarations = []; - } - hoistedFunctionDeclarations.push(node); - return; - } - if (node.kind === 212 /* ClassDeclaration */) { - if (!hoistedVars) { - hoistedVars = []; - } - hoistedVars.push(node); - return; - } - if (node.kind === 215 /* EnumDeclaration */) { - if (shouldEmitEnumDeclaration(node)) { - if (!hoistedVars) { - hoistedVars = []; - } - hoistedVars.push(node); - } - return; - } - if (node.kind === 216 /* ModuleDeclaration */) { - if (shouldEmitModuleDeclaration(node)) { - if (!hoistedVars) { - hoistedVars = []; - } - hoistedVars.push(node); - } - return; - } - if (node.kind === 209 /* VariableDeclaration */ || node.kind === 161 /* BindingElement */) { - if (shouldHoistVariable(node, /*checkIfSourceFileLevelDecl*/ false)) { - var name_26 = node.name; - if (name_26.kind === 67 /* Identifier */) { - if (!hoistedVars) { - hoistedVars = []; - } - hoistedVars.push(name_26); - } - else { - ts.forEachChild(name_26, visit); - } - } - return; - } - if (ts.isInternalModuleImportEqualsDeclaration(node) && resolver.isValueAliasDeclaration(node)) { - if (!hoistedVars) { - hoistedVars = []; - } - hoistedVars.push(node.name); - return; - } - if (ts.isBindingPattern(node)) { - ts.forEach(node.elements, visit); - return; - } - if (!ts.isDeclaration(node)) { - ts.forEachChild(node, visit); - } - } - } - function shouldHoistVariable(node, checkIfSourceFileLevelDecl) { - if (checkIfSourceFileLevelDecl && !shouldHoistDeclarationInSystemJsModule(node)) { - return false; - } - // hoist variable if - // - it is not block scoped - // - it is top level block scoped - // if block scoped variables are nested in some another block then - // no other functions can use them except ones that are defined at least in the same block - return (ts.getCombinedNodeFlags(node) & 49152 /* BlockScoped */) === 0 || - ts.getEnclosingBlockScopeContainer(node).kind === 246 /* SourceFile */; - } - function isCurrentFileSystemExternalModule() { - return compilerOptions.module === 4 /* System */ && ts.isExternalModule(currentSourceFile); - } - function emitSystemModuleBody(node, dependencyGroups, startIndex) { - // 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 file1; // local alias - // var y; - // function foo() { return y + file1.x(); } - // exports("foo", foo); - // return { - // setters: [ - // function(v) { file1 = v } - // ], - // execute(): function() { - // y = 1; - // console.log(y); - // } - // }; - // } - emitVariableDeclarationsForImports(); - writeLine(); - var exportedDeclarations = processTopLevelVariableAndFunctionDeclarations(node); - var exportStarFunction = emitLocalStorageForExportedNamesIfNecessary(exportedDeclarations); - writeLine(); - write("return {"); - increaseIndent(); - writeLine(); - emitSetters(exportStarFunction, dependencyGroups); - writeLine(); - emitExecute(node, startIndex); - decreaseIndent(); - writeLine(); - write("}"); // return - emitTempDeclarations(/*newLine*/ true); - } - function emitSetters(exportStarFunction, dependencyGroups) { - write("setters:["); - for (var i = 0; i < dependencyGroups.length; ++i) { - if (i !== 0) { - write(","); - } - writeLine(); - increaseIndent(); - var group = dependencyGroups[i]; - // derive a unique name for parameter from the first named entry in the group - var parameterName = makeUniqueName(ts.forEach(group, getLocalNameForExternalImport) || ""); - write("function (" + parameterName + ") {"); - increaseIndent(); - for (var _a = 0; _a < group.length; _a++) { - var entry = group[_a]; - var importVariableName = getLocalNameForExternalImport(entry) || ""; - switch (entry.kind) { - case 220 /* ImportDeclaration */: - if (!entry.importClause) { - // 'import "..."' case - // module is imported only for side-effects, no emit required - break; - } - // fall-through - case 219 /* ImportEqualsDeclaration */: - ts.Debug.assert(importVariableName !== ""); - writeLine(); - // save import into the local - write(importVariableName + " = " + parameterName + ";"); - writeLine(); - break; - case 226 /* ExportDeclaration */: - ts.Debug.assert(importVariableName !== ""); - if (entry.exportClause) { - // export {a, b as c} from 'foo' - // emit as: - // exports_({ - // "a": _["a"], - // "c": _["b"] - // }); - writeLine(); - write(exportFunctionForFile + "({"); - writeLine(); - increaseIndent(); - for (var i_2 = 0, len = entry.exportClause.elements.length; i_2 < len; ++i_2) { - if (i_2 !== 0) { - write(","); - writeLine(); - } - var e = entry.exportClause.elements[i_2]; - write("\""); - emitNodeWithCommentsAndWithoutSourcemap(e.name); - write("\": " + parameterName + "[\""); - emitNodeWithCommentsAndWithoutSourcemap(e.propertyName || e.name); - write("\"]"); - } - decreaseIndent(); - writeLine(); - write("});"); - } - else { - writeLine(); - // export * from 'foo' - // emit as: - // exportStar(_foo); - write(exportStarFunction + "(" + parameterName + ");"); - } - writeLine(); - break; - } - } - decreaseIndent(); - write("}"); - decreaseIndent(); - } - write("],"); - } - function emitExecute(node, startIndex) { - write("execute: function() {"); - increaseIndent(); - writeLine(); - for (var i = startIndex; i < node.statements.length; ++i) { - var statement = node.statements[i]; - switch (statement.kind) { - // - function declarations are not emitted because they were already hoisted - // - import declarations are not emitted since they are already handled in setters - // - export declarations with module specifiers are not emitted since they were already written in setters - // - export declarations without module specifiers are emitted preserving the order - case 211 /* FunctionDeclaration */: - case 220 /* ImportDeclaration */: - continue; - case 226 /* ExportDeclaration */: - if (!statement.moduleSpecifier) { - for (var _a = 0, _b = statement.exportClause.elements; _a < _b.length; _a++) { - var element = _b[_a]; - // write call to exporter function for every export specifier in exports list - emitExportSpecifierInSystemModule(element); - } - } - continue; - case 219 /* ImportEqualsDeclaration */: - if (!ts.isInternalModuleImportEqualsDeclaration(statement)) { - // - import equals declarations that import external modules are not emitted - continue; - } - // fall-though for import declarations that import internal modules - default: - writeLine(); - emit(statement); - } - } - decreaseIndent(); - writeLine(); - write("}"); // execute - } - function emitSystemModule(node, startIndex) { - collectExternalModuleInfo(node); - // System modules has the following shape - // System.register(['dep-1', ... 'dep-n'], function(exports) {/* module body function */}) - // 'exports' here is a function 'exports(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 'emitPostfixUnaryExpression' for more details - ts.Debug.assert(!exportFunctionForFile); - // make sure that name of 'exports' function does not conflict with existing identifiers - exportFunctionForFile = makeUniqueName("exports"); - writeLine(); - write("System.register("); - if (node.moduleName) { - write("\"" + node.moduleName + "\", "); - } - write("["); - var groupIndices = {}; - var dependencyGroups = []; - for (var i = 0; i < externalImports.length; ++i) { - var text = getExternalModuleNameText(externalImports[i]); - if (ts.hasProperty(groupIndices, text)) { - // deduplicate/group entries in dependency list by the dependency name - var groupIndex = groupIndices[text]; - dependencyGroups[groupIndex].push(externalImports[i]); - continue; - } - else { - groupIndices[text] = dependencyGroups.length; - dependencyGroups.push([externalImports[i]]); - } - if (i !== 0) { - write(", "); - } - write(text); - } - write("], function(" + exportFunctionForFile + ") {"); - writeLine(); - increaseIndent(); - emitEmitHelpers(node); - emitCaptureThisForNodeIfNecessary(node); - emitSystemModuleBody(node, dependencyGroups, startIndex); - decreaseIndent(); - writeLine(); - write("});"); - } - function emitAMDDependencies(node, includeNonAmdDependencies) { - // An AMD define function has the following shape: - // define(id?, dependencies?, factory); - // - // This has the shape of - // define(name, ["module1", "module2"], function (module1Alias) { - // The location of the alias in the parameter list in the factory function needs to - // match the position of the module name in the dependency list. - // - // To ensure this is true in cases of modules with no aliases, e.g.: - // `import "module"` or `` - // we need to add modules without alias names to the end of the dependencies list - // names of modules with corresponding parameter in the factory function - var aliasedModuleNames = []; - // names of modules with no corresponding parameters in factory function - var unaliasedModuleNames = []; - var importAliasNames = []; // names of the parameters in the factory function; these - // parameters need to match the indexes of the corresponding - // module names in aliasedModuleNames. - // Fill in amd-dependency tags - for (var _a = 0, _b = node.amdDependencies; _a < _b.length; _a++) { - var amdDependency = _b[_a]; - if (amdDependency.name) { - aliasedModuleNames.push("\"" + amdDependency.path + "\""); - importAliasNames.push(amdDependency.name); - } - else { - unaliasedModuleNames.push("\"" + amdDependency.path + "\""); - } - } - for (var _c = 0; _c < externalImports.length; _c++) { - var importNode = externalImports[_c]; - // Find the name of the external module - var externalModuleName = getExternalModuleNameText(importNode); - // Find the name of the module alias, if there is one - var importAliasName = getLocalNameForExternalImport(importNode); - if (includeNonAmdDependencies && importAliasName) { - aliasedModuleNames.push(externalModuleName); - importAliasNames.push(importAliasName); - } - else { - unaliasedModuleNames.push(externalModuleName); - } - } - write("[\"require\", \"exports\""); - if (aliasedModuleNames.length) { - write(", "); - write(aliasedModuleNames.join(", ")); - } - if (unaliasedModuleNames.length) { - write(", "); - write(unaliasedModuleNames.join(", ")); - } - write("], function (require, exports"); - if (importAliasNames.length) { - write(", "); - write(importAliasNames.join(", ")); - } - } - function emitAMDModule(node, startIndex) { - emitEmitHelpers(node); - collectExternalModuleInfo(node); - writeLine(); - write("define("); - if (node.moduleName) { - write("\"" + node.moduleName + "\", "); - } - emitAMDDependencies(node, /*includeNonAmdDependencies*/ true); - write(") {"); - increaseIndent(); - emitExportStarHelper(); - emitCaptureThisForNodeIfNecessary(node); - emitLinesStartingAt(node.statements, startIndex); - emitTempDeclarations(/*newLine*/ true); - emitExportEquals(/*emitAsReturn*/ true); - decreaseIndent(); - writeLine(); - write("});"); - } - function emitCommonJSModule(node, startIndex) { - emitEmitHelpers(node); - collectExternalModuleInfo(node); - emitExportStarHelper(); - emitCaptureThisForNodeIfNecessary(node); - emitLinesStartingAt(node.statements, startIndex); - emitTempDeclarations(/*newLine*/ true); - emitExportEquals(/*emitAsReturn*/ false); - } - function emitUMDModule(node, startIndex) { - emitEmitHelpers(node); - collectExternalModuleInfo(node); - // Module is detected first to support Browserify users that load into a browser with an AMD loader - writeLines("(function (deps, factory) {\n if (typeof module === 'object' && typeof module.exports === 'object') {\n var v = factory(require, exports); if (v !== undefined) module.exports = v;\n }\n else if (typeof define === 'function' && define.amd) {\n define(deps, factory);\n }\n})("); - emitAMDDependencies(node, false); - write(") {"); - increaseIndent(); - emitExportStarHelper(); - emitCaptureThisForNodeIfNecessary(node); - emitLinesStartingAt(node.statements, startIndex); - emitTempDeclarations(/*newLine*/ true); - emitExportEquals(/*emitAsReturn*/ true); - decreaseIndent(); - writeLine(); - write("});"); - } - function emitES6Module(node, startIndex) { - externalImports = undefined; - exportSpecifiers = undefined; - exportEquals = undefined; - hasExportStars = false; - emitEmitHelpers(node); - emitCaptureThisForNodeIfNecessary(node); - emitLinesStartingAt(node.statements, startIndex); - emitTempDeclarations(/*newLine*/ true); - // Emit exportDefault if it exists will happen as part - // or normal statement emit. - } - function emitExportEquals(emitAsReturn) { - if (exportEquals && resolver.isValueAliasDeclaration(exportEquals)) { - writeLine(); - emitStart(exportEquals); - write(emitAsReturn ? "return " : "module.exports = "); - emit(exportEquals.expression); - write(";"); - emitEnd(exportEquals); - } - } - function emitJsxElement(node) { - switch (compilerOptions.jsx) { - case 2 /* React */: - jsxEmitReact(node); - break; - case 1 /* Preserve */: - // Fall back to preserve if None was specified (we'll error earlier) - default: - jsxEmitPreserve(node); - break; - } - } - function trimReactWhitespaceAndApplyEntities(node) { - var result = undefined; - var text = ts.getTextOfNode(node, /*includeTrivia*/ true); - var firstNonWhitespace = 0; - var lastNonWhitespace = -1; - // JSX trims whitespace at the end and beginning of lines, except that the - // start/end of a tag is considered a start/end of a line only if that line is - // on the same line as the closing tag. See examples in tests/cases/conformance/jsx/tsxReactEmitWhitespace.tsx - for (var i = 0; i < text.length; i++) { - var c = text.charCodeAt(i); - if (ts.isLineBreak(c)) { - if (firstNonWhitespace !== -1 && (lastNonWhitespace - firstNonWhitespace + 1 > 0)) { - var part = text.substr(firstNonWhitespace, lastNonWhitespace - firstNonWhitespace + 1); - result = (result ? result + "\" + ' ' + \"" : "") + part; - } - firstNonWhitespace = -1; - } - else if (!ts.isWhiteSpace(c)) { - lastNonWhitespace = i; - if (firstNonWhitespace === -1) { - firstNonWhitespace = i; - } - } - } - if (firstNonWhitespace !== -1) { - var part = text.substr(firstNonWhitespace); - result = (result ? result + "\" + ' ' + \"" : "") + part; - } - if (result) { - // Replace entities like   - result = result.replace(/&(\w+);/g, function (s, m) { - if (entities[m] !== undefined) { - return String.fromCharCode(entities[m]); - } - else { - return s; - } - }); - } - return result; - } - function getTextToEmit(node) { - switch (compilerOptions.jsx) { - case 2 /* React */: - var text = trimReactWhitespaceAndApplyEntities(node); - if (text === undefined || text.length === 0) { - return undefined; - } - else { - return text; - } - case 1 /* Preserve */: - default: - return ts.getTextOfNode(node, /*includeTrivia*/ true); - } - } - function emitJsxText(node) { - switch (compilerOptions.jsx) { - case 2 /* React */: - write("\""); - write(trimReactWhitespaceAndApplyEntities(node)); - write("\""); - break; - case 1 /* Preserve */: - default: - writer.writeLiteral(ts.getTextOfNode(node, /*includeTrivia*/ true)); - break; - } - } - function emitJsxExpression(node) { - if (node.expression) { - switch (compilerOptions.jsx) { - case 1 /* Preserve */: - default: - write("{"); - emit(node.expression); - write("}"); - break; - case 2 /* React */: - emit(node.expression); - break; - } - } - } - function emitDirectivePrologues(statements, startWithNewLine) { - for (var i = 0; i < statements.length; ++i) { - if (ts.isPrologueDirective(statements[i])) { - if (startWithNewLine || i > 0) { - writeLine(); - } - emit(statements[i]); - } - else { - // return index of the first non prologue directive - return i; - } - } - return statements.length; - } - function writeLines(text) { - var lines = text.split(/\r\n|\r|\n/g); - for (var i = 0; i < lines.length; ++i) { - var line = lines[i]; - if (line.length) { - writeLine(); - write(line); - } - } - } - function emitEmitHelpers(node) { - // Only emit helpers if the user did not say otherwise. - if (!compilerOptions.noEmitHelpers) { - // Only Emit __extends function when target ES5. - // For target ES6 and above, we can emit classDeclaration as is. - if ((languageVersion < 2 /* ES6 */) && (!extendsEmitted && resolver.getNodeCheckFlags(node) & 8 /* EmitExtends */)) { - writeLines(extendsHelper); - extendsEmitted = true; - } - if (!decorateEmitted && resolver.getNodeCheckFlags(node) & 16 /* EmitDecorate */) { - writeLines(decorateHelper); - if (compilerOptions.emitDecoratorMetadata) { - writeLines(metadataHelper); - } - decorateEmitted = true; - } - if (!paramEmitted && resolver.getNodeCheckFlags(node) & 32 /* EmitParam */) { - writeLines(paramHelper); - paramEmitted = true; - } - if (!awaiterEmitted && resolver.getNodeCheckFlags(node) & 64 /* EmitAwaiter */) { - writeLines(awaiterHelper); - awaiterEmitted = true; - } - } - } - function emitSourceFileNode(node) { - // Start new file on new line - writeLine(); - emitShebang(); - emitDetachedComments(node); - // emit prologue directives prior to __extends - var startIndex = emitDirectivePrologues(node.statements, /*startWithNewLine*/ false); - if (ts.isExternalModule(node) || compilerOptions.isolatedModules) { - if (languageVersion >= 2 /* ES6 */) { - emitES6Module(node, startIndex); - } - else if (compilerOptions.module === 2 /* AMD */) { - emitAMDModule(node, startIndex); - } - else if (compilerOptions.module === 4 /* System */) { - emitSystemModule(node, startIndex); - } - else if (compilerOptions.module === 3 /* UMD */) { - emitUMDModule(node, startIndex); - } - else { - emitCommonJSModule(node, startIndex); - } - } - else { - externalImports = undefined; - exportSpecifiers = undefined; - exportEquals = undefined; - hasExportStars = false; - emitEmitHelpers(node); - emitCaptureThisForNodeIfNecessary(node); - emitLinesStartingAt(node.statements, startIndex); - emitTempDeclarations(/*newLine*/ true); - } - emitLeadingComments(node.endOfFileToken); - } - function emitNodeWithCommentsAndWithoutSourcemap(node) { - emitNodeConsideringCommentsOption(node, emitNodeWithoutSourceMap); - } - function emitNodeConsideringCommentsOption(node, emitNodeConsideringSourcemap) { - if (node) { - if (node.flags & 2 /* Ambient */) { - return emitCommentsOnNotEmittedNode(node); - } - if (isSpecializedCommentHandling(node)) { - // This is the node that will handle its own comments and sourcemap - return emitNodeWithoutSourceMap(node); - } - var emitComments_1 = shouldEmitLeadingAndTrailingComments(node); - if (emitComments_1) { - emitLeadingComments(node); - } - emitNodeConsideringSourcemap(node); - if (emitComments_1) { - emitTrailingComments(node); - } - } - } - function emitNodeWithoutSourceMap(node) { - if (node) { - emitJavaScriptWorker(node); - } - } - function isSpecializedCommentHandling(node) { - switch (node.kind) { - // All of these entities are emitted in a specialized fashion. As such, we allow - // the specialized methods for each to handle the comments on the nodes. - case 213 /* InterfaceDeclaration */: - case 211 /* FunctionDeclaration */: - case 220 /* ImportDeclaration */: - case 219 /* ImportEqualsDeclaration */: - case 214 /* TypeAliasDeclaration */: - case 225 /* ExportAssignment */: - return true; - } - } - function shouldEmitLeadingAndTrailingComments(node) { - switch (node.kind) { - case 191 /* VariableStatement */: - return shouldEmitLeadingAndTrailingCommentsForVariableStatement(node); - case 216 /* ModuleDeclaration */: - // Only emit the leading/trailing comments for a module if we're actually - // emitting the module as well. - return shouldEmitModuleDeclaration(node); - case 215 /* EnumDeclaration */: - // Only emit the leading/trailing comments for an enum if we're actually - // emitting the module as well. - return shouldEmitEnumDeclaration(node); - } - // If the node is emitted in specialized fashion, dont emit comments as this node will handle - // emitting comments when emitting itself - ts.Debug.assert(!isSpecializedCommentHandling(node)); - // If this is the expression body of an arrow function that we're down-leveling, - // then we don't want to emit comments when we emit the body. It will have already - // been taken care of when we emitted the 'return' statement for the function - // expression body. - if (node.kind !== 190 /* Block */ && - node.parent && - node.parent.kind === 172 /* ArrowFunction */ && - node.parent.body === node && - compilerOptions.target <= 1 /* ES5 */) { - return false; - } - // Emit comments for everything else. - return true; - } - function emitJavaScriptWorker(node) { - // Check if the node can be emitted regardless of the ScriptTarget - switch (node.kind) { - case 67 /* Identifier */: - return emitIdentifier(node); - case 136 /* Parameter */: - return emitParameter(node); - case 141 /* MethodDeclaration */: - case 140 /* MethodSignature */: - return emitMethod(node); - case 143 /* GetAccessor */: - case 144 /* SetAccessor */: - return emitAccessor(node); - case 95 /* ThisKeyword */: - return emitThis(node); - case 93 /* SuperKeyword */: - return emitSuper(node); - case 91 /* NullKeyword */: - return write("null"); - case 97 /* TrueKeyword */: - return write("true"); - case 82 /* FalseKeyword */: - return write("false"); - case 8 /* NumericLiteral */: - case 9 /* StringLiteral */: - case 10 /* RegularExpressionLiteral */: - case 11 /* NoSubstitutionTemplateLiteral */: - case 12 /* TemplateHead */: - case 13 /* TemplateMiddle */: - case 14 /* TemplateTail */: - return emitLiteral(node); - case 181 /* TemplateExpression */: - return emitTemplateExpression(node); - case 188 /* TemplateSpan */: - return emitTemplateSpan(node); - case 231 /* JsxElement */: - case 232 /* JsxSelfClosingElement */: - return emitJsxElement(node); - case 234 /* JsxText */: - return emitJsxText(node); - case 238 /* JsxExpression */: - return emitJsxExpression(node); - case 133 /* QualifiedName */: - return emitQualifiedName(node); - case 159 /* ObjectBindingPattern */: - return emitObjectBindingPattern(node); - case 160 /* ArrayBindingPattern */: - return emitArrayBindingPattern(node); - case 161 /* BindingElement */: - return emitBindingElement(node); - case 162 /* ArrayLiteralExpression */: - return emitArrayLiteral(node); - case 163 /* ObjectLiteralExpression */: - return emitObjectLiteral(node); - case 243 /* PropertyAssignment */: - return emitPropertyAssignment(node); - case 244 /* ShorthandPropertyAssignment */: - return emitShorthandPropertyAssignment(node); - case 134 /* ComputedPropertyName */: - return emitComputedPropertyName(node); - case 164 /* PropertyAccessExpression */: - return emitPropertyAccess(node); - case 165 /* ElementAccessExpression */: - return emitIndexedAccess(node); - case 166 /* CallExpression */: - return emitCallExpression(node); - case 167 /* NewExpression */: - return emitNewExpression(node); - case 168 /* TaggedTemplateExpression */: - return emitTaggedTemplateExpression(node); - case 169 /* TypeAssertionExpression */: - return emit(node.expression); - case 187 /* AsExpression */: - return emit(node.expression); - case 170 /* ParenthesizedExpression */: - return emitParenExpression(node); - case 211 /* FunctionDeclaration */: - case 171 /* FunctionExpression */: - case 172 /* ArrowFunction */: - return emitFunctionDeclaration(node); - case 173 /* DeleteExpression */: - return emitDeleteExpression(node); - case 174 /* TypeOfExpression */: - return emitTypeOfExpression(node); - case 175 /* VoidExpression */: - return emitVoidExpression(node); - case 176 /* AwaitExpression */: - return emitAwaitExpression(node); - case 177 /* PrefixUnaryExpression */: - return emitPrefixUnaryExpression(node); - case 178 /* PostfixUnaryExpression */: - return emitPostfixUnaryExpression(node); - case 179 /* BinaryExpression */: - return emitBinaryExpression(node); - case 180 /* ConditionalExpression */: - return emitConditionalExpression(node); - case 183 /* SpreadElementExpression */: - return emitSpreadElementExpression(node); - case 182 /* YieldExpression */: - return emitYieldExpression(node); - case 185 /* OmittedExpression */: - return; - case 190 /* Block */: - case 217 /* ModuleBlock */: - return emitBlock(node); - case 191 /* VariableStatement */: - return emitVariableStatement(node); - case 192 /* EmptyStatement */: - return write(";"); - case 193 /* ExpressionStatement */: - return emitExpressionStatement(node); - case 194 /* IfStatement */: - return emitIfStatement(node); - case 195 /* DoStatement */: - return emitDoStatement(node); - case 196 /* WhileStatement */: - return emitWhileStatement(node); - case 197 /* ForStatement */: - return emitForStatement(node); - case 199 /* ForOfStatement */: - case 198 /* ForInStatement */: - return emitForInOrForOfStatement(node); - case 200 /* ContinueStatement */: - case 201 /* BreakStatement */: - return emitBreakOrContinueStatement(node); - case 202 /* ReturnStatement */: - return emitReturnStatement(node); - case 203 /* WithStatement */: - return emitWithStatement(node); - case 204 /* SwitchStatement */: - return emitSwitchStatement(node); - case 239 /* CaseClause */: - case 240 /* DefaultClause */: - return emitCaseOrDefaultClause(node); - case 205 /* LabeledStatement */: - return emitLabelledStatement(node); - case 206 /* ThrowStatement */: - return emitThrowStatement(node); - case 207 /* TryStatement */: - return emitTryStatement(node); - case 242 /* CatchClause */: - return emitCatchClause(node); - case 208 /* DebuggerStatement */: - return emitDebuggerStatement(node); - case 209 /* VariableDeclaration */: - return emitVariableDeclaration(node); - case 184 /* ClassExpression */: - return emitClassExpression(node); - case 212 /* ClassDeclaration */: - return emitClassDeclaration(node); - case 213 /* InterfaceDeclaration */: - return emitInterfaceDeclaration(node); - case 215 /* EnumDeclaration */: - return emitEnumDeclaration(node); - case 245 /* EnumMember */: - return emitEnumMember(node); - case 216 /* ModuleDeclaration */: - return emitModuleDeclaration(node); - case 220 /* ImportDeclaration */: - return emitImportDeclaration(node); - case 219 /* ImportEqualsDeclaration */: - return emitImportEqualsDeclaration(node); - case 226 /* ExportDeclaration */: - return emitExportDeclaration(node); - case 225 /* ExportAssignment */: - return emitExportAssignment(node); - case 246 /* SourceFile */: - return emitSourceFileNode(node); - } - } - function hasDetachedComments(pos) { - return detachedCommentsInfo !== undefined && ts.lastOrUndefined(detachedCommentsInfo).nodePos === pos; - } - function getLeadingCommentsWithoutDetachedComments() { - // get the leading comments from detachedPos - var leadingComments = ts.getLeadingCommentRanges(currentSourceFile.text, ts.lastOrUndefined(detachedCommentsInfo).detachedCommentEndPos); - if (detachedCommentsInfo.length - 1) { - detachedCommentsInfo.pop(); - } - else { - detachedCommentsInfo = undefined; - } - return leadingComments; - } - function isPinnedComments(comment) { - return currentSourceFile.text.charCodeAt(comment.pos + 1) === 42 /* asterisk */ && - currentSourceFile.text.charCodeAt(comment.pos + 2) === 33 /* exclamation */; - } - /** - * Determine if the given comment is a triple-slash - * - * @return true if the comment is a triple-slash comment else false - **/ - function isTripleSlashComment(comment) { - // Verify this is /// comment, but do the regexp match only when we first can find /// in the comment text - // so that we don't end up computing comment string and doing match for all // comments - if (currentSourceFile.text.charCodeAt(comment.pos + 1) === 47 /* slash */ && - comment.pos + 2 < comment.end && - currentSourceFile.text.charCodeAt(comment.pos + 2) === 47 /* slash */) { - var textSubStr = currentSourceFile.text.substring(comment.pos, comment.end); - return textSubStr.match(ts.fullTripleSlashReferencePathRegEx) || - textSubStr.match(ts.fullTripleSlashAMDReferencePathRegEx) ? - true : false; - } - return false; - } - function getLeadingCommentsToEmit(node) { - // Emit the leading comments only if the parent's pos doesn't match because parent should take care of emitting these comments - if (node.parent) { - if (node.parent.kind === 246 /* SourceFile */ || node.pos !== node.parent.pos) { - if (hasDetachedComments(node.pos)) { - // get comments without detached comments - return getLeadingCommentsWithoutDetachedComments(); - } - else { - // get the leading comments from the node - return ts.getLeadingCommentRangesOfNode(node, currentSourceFile); - } - } - } - } - function getTrailingCommentsToEmit(node) { - // Emit the trailing comments only if the parent's pos doesn't match because parent should take care of emitting these comments - if (node.parent) { - if (node.parent.kind === 246 /* SourceFile */ || node.end !== node.parent.end) { - return ts.getTrailingCommentRanges(currentSourceFile.text, node.end); - } - } - } - /** - * Emit comments associated with node that will not be emitted into JS file - */ - function emitCommentsOnNotEmittedNode(node) { - emitLeadingCommentsWorker(node, /*isEmittedNode:*/ false); - } - function emitLeadingComments(node) { - return emitLeadingCommentsWorker(node, /*isEmittedNode:*/ true); - } - function emitLeadingCommentsWorker(node, isEmittedNode) { - if (compilerOptions.removeComments) { - return; - } - var leadingComments; - if (isEmittedNode) { - leadingComments = getLeadingCommentsToEmit(node); - } - else { - // If the node will not be emitted in JS, remove all the comments(normal, pinned and ///) associated with the node, - // unless it is a triple slash comment at the top of the file. - // For Example: - // /// - // declare var x; - // /// - // interface F {} - // The first /// will NOT be removed while the second one will be removed eventhough both node will not be emitted - if (node.pos === 0) { - leadingComments = ts.filter(getLeadingCommentsToEmit(node), isTripleSlashComment); - } - } - ts.emitNewLineBeforeLeadingComments(currentSourceFile, writer, node, leadingComments); - // Leading comments are emitted at /*leading comment1 */space/*leading comment*/space - ts.emitComments(currentSourceFile, writer, leadingComments, /*trailingSeparator:*/ true, newLine, writeComment); - } - function emitTrailingComments(node) { - if (compilerOptions.removeComments) { - return; - } - // Emit the trailing comments only if the parent's end doesn't match - var trailingComments = getTrailingCommentsToEmit(node); - // trailing comments are emitted at space/*trailing comment1 */space/*trailing comment*/ - ts.emitComments(currentSourceFile, writer, trailingComments, /*trailingSeparator*/ false, newLine, writeComment); - } - /** - * Emit trailing comments at the position. The term trailing comment is used here to describe following comment: - * x, /comment1/ y - * ^ => pos; the function will emit "comment1" in the emitJS - */ - function emitTrailingCommentsOfPosition(pos) { - if (compilerOptions.removeComments) { - return; - } - var trailingComments = ts.getTrailingCommentRanges(currentSourceFile.text, pos); - // trailing comments are emitted at space/*trailing comment1 */space/*trailing comment*/ - ts.emitComments(currentSourceFile, writer, trailingComments, /*trailingSeparator*/ true, newLine, writeComment); - } - function emitLeadingCommentsOfPositionWorker(pos) { - if (compilerOptions.removeComments) { - return; - } - var leadingComments; - if (hasDetachedComments(pos)) { - // get comments without detached comments - leadingComments = getLeadingCommentsWithoutDetachedComments(); - } - else { - // get the leading comments from the node - leadingComments = ts.getLeadingCommentRanges(currentSourceFile.text, pos); - } - ts.emitNewLineBeforeLeadingComments(currentSourceFile, writer, { pos: pos, end: pos }, leadingComments); - // Leading comments are emitted at /*leading comment1 */space/*leading comment*/space - ts.emitComments(currentSourceFile, writer, leadingComments, /*trailingSeparator*/ true, newLine, writeComment); - } - function emitDetachedComments(node) { - var leadingComments; - if (compilerOptions.removeComments) { - // removeComments is true, only reserve pinned comment at the top of file - // For example: - // /*! Pinned Comment */ - // - // var x = 10; - if (node.pos === 0) { - leadingComments = ts.filter(ts.getLeadingCommentRanges(currentSourceFile.text, node.pos), isPinnedComments); - } - } - else { - // removeComments is false, just get detached as normal and bypass the process to filter comment - leadingComments = ts.getLeadingCommentRanges(currentSourceFile.text, node.pos); - } - if (leadingComments) { - var detachedComments = []; - var lastComment; - ts.forEach(leadingComments, function (comment) { - if (lastComment) { - var lastCommentLine = ts.getLineOfLocalPosition(currentSourceFile, lastComment.end); - var commentLine = ts.getLineOfLocalPosition(currentSourceFile, comment.pos); - if (commentLine >= lastCommentLine + 2) { - // There was a blank line between the last comment and this comment. This - // comment is not part of the copyright comments. Return what we have so - // far. - return detachedComments; - } - } - detachedComments.push(comment); - lastComment = comment; - }); - if (detachedComments.length) { - // All comments look like they could have been part of the copyright header. Make - // sure there is at least one blank line between it and the node. If not, it's not - // a copyright header. - var lastCommentLine = ts.getLineOfLocalPosition(currentSourceFile, ts.lastOrUndefined(detachedComments).end); - var nodeLine = ts.getLineOfLocalPosition(currentSourceFile, ts.skipTrivia(currentSourceFile.text, node.pos)); - if (nodeLine >= lastCommentLine + 2) { - // Valid detachedComments - ts.emitNewLineBeforeLeadingComments(currentSourceFile, writer, node, leadingComments); - ts.emitComments(currentSourceFile, writer, detachedComments, /*trailingSeparator*/ true, newLine, writeComment); - var currentDetachedCommentInfo = { nodePos: node.pos, detachedCommentEndPos: ts.lastOrUndefined(detachedComments).end }; - if (detachedCommentsInfo) { - detachedCommentsInfo.push(currentDetachedCommentInfo); - } - else { - detachedCommentsInfo = [currentDetachedCommentInfo]; - } - } - } - } - } - function emitShebang() { - var shebang = ts.getShebang(currentSourceFile.text); - if (shebang) { - write(shebang); - } - } - } - function emitFile(jsFilePath, sourceFile) { - emitJavaScript(jsFilePath, sourceFile); - if (compilerOptions.declaration) { - ts.writeDeclarationFile(jsFilePath, sourceFile, host, resolver, diagnostics); - } - } - } - ts.emitFiles = emitFiles; var entities = { "quot": 0x0022, "amp": 0x0026, @@ -35261,6 +29422,6531 @@ var ts; "hearts": 0x2665, "diams": 0x2666 }; + // Flags enum to track count of temp variables and a few dedicated names + var TempFlags; + (function (TempFlags) { + TempFlags[TempFlags["Auto"] = 0] = "Auto"; + TempFlags[TempFlags["CountMask"] = 268435455] = "CountMask"; + TempFlags[TempFlags["_i"] = 268435456] = "_i"; + })(TempFlags || (TempFlags = {})); + // 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) { + // emit output for the __extends helper function + var extendsHelper = "\nvar __extends = (this && this.__extends) || function (d, b) {\n for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];\n function __() { this.constructor = d; }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n};"; + // emit output for the __decorate helper function + var decorateHelper = "\nvar __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\n return c > 3 && r && Object.defineProperty(target, key, r), r;\n};"; + // emit output for the __metadata helper function + var metadataHelper = "\nvar __metadata = (this && this.__metadata) || function (k, v) {\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(k, v);\n};"; + // emit output for the __param helper function + var paramHelper = "\nvar __param = (this && this.__param) || function (paramIndex, decorator) {\n return function (target, key) { decorator(target, key, paramIndex); }\n};"; + var awaiterHelper = "\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promise, generator) {\n return new Promise(function (resolve, reject) {\n generator = generator.call(thisArg, _arguments);\n function cast(value) { return value instanceof Promise && value.constructor === Promise ? value : new Promise(function (resolve) { resolve(value); }); }\n function onfulfill(value) { try { step(\"next\", value); } catch (e) { reject(e); } }\n function onreject(value) { try { step(\"throw\", value); } catch (e) { reject(e); } }\n function step(verb, value) {\n var result = generator[verb](value);\n result.done ? resolve(result.value) : cast(result.value).then(onfulfill, onreject);\n }\n step(\"next\", void 0);\n });\n};"; + var compilerOptions = host.getCompilerOptions(); + var languageVersion = compilerOptions.target || 0 /* ES3 */; + var modulekind = compilerOptions.module ? compilerOptions.module : languageVersion === 2 /* ES6 */ ? 5 /* ES6 */ : 0 /* None */; + var sourceMapDataList = compilerOptions.sourceMap || compilerOptions.inlineSourceMap ? [] : undefined; + var diagnostics = []; + var newLine = host.getNewLine(); + var jsxDesugaring = host.getCompilerOptions().jsx !== 1 /* Preserve */; + var shouldEmitJsx = function (s) { return (s.languageVariant === 1 /* JSX */ && !jsxDesugaring); }; + if (targetSourceFile === undefined) { + ts.forEach(host.getSourceFiles(), function (sourceFile) { + if (ts.shouldEmitToOwnFile(sourceFile, compilerOptions)) { + var jsFilePath = ts.getOwnEmitOutputFilePath(sourceFile, host, shouldEmitJsx(sourceFile) ? ".jsx" : ".js"); + emitFile(jsFilePath, sourceFile); + } + }); + if (compilerOptions.outFile || compilerOptions.out) { + emitFile(compilerOptions.outFile || compilerOptions.out); + } + } + else { + // targetSourceFile is specified (e.g calling emitter from language service or calling getSemanticDiagnostic from language service) + if (ts.shouldEmitToOwnFile(targetSourceFile, compilerOptions)) { + var jsFilePath = ts.getOwnEmitOutputFilePath(targetSourceFile, host, shouldEmitJsx(targetSourceFile) ? ".jsx" : ".js"); + emitFile(jsFilePath, targetSourceFile); + } + else if (!ts.isDeclarationFile(targetSourceFile) && (compilerOptions.outFile || compilerOptions.out)) { + emitFile(compilerOptions.outFile || compilerOptions.out); + } + } + // Sort and make the unique list of diagnostics + diagnostics = ts.sortAndDeduplicateDiagnostics(diagnostics); + return { + emitSkipped: false, + diagnostics: diagnostics, + sourceMaps: sourceMapDataList + }; + function isNodeDescendentOf(node, ancestor) { + while (node) { + if (node === ancestor) + return true; + node = node.parent; + } + return false; + } + function isUniqueLocalName(name, container) { + for (var node = container; isNodeDescendentOf(node, container); node = node.nextContainer) { + if (node.locals && ts.hasProperty(node.locals, name)) { + // We conservatively include alias symbols to cover cases where they're emitted as locals + if (node.locals[name].flags & (107455 /* Value */ | 1048576 /* ExportValue */ | 8388608 /* Alias */)) { + return false; + } + } + } + return true; + } + function emitJavaScript(jsFilePath, root) { + var writer = ts.createTextWriter(newLine); + var write = writer.write, writeTextOfNode = writer.writeTextOfNode, writeLine = writer.writeLine, increaseIndent = writer.increaseIndent, decreaseIndent = writer.decreaseIndent; + var currentSourceFile; + // name of an exporter function if file is a System external module + // System.register([...], function () {...}) + // exporting in System modules looks like: + // export var x; ... x = 1 + // => + // var x;... exporter("x", x = 1) + var exportFunctionForFile; + var generatedNameSet = {}; + var nodeToGeneratedName = []; + var computedPropertyNamesToGeneratedNames; + var extendsEmitted = false; + var decorateEmitted = false; + var paramEmitted = false; + var awaiterEmitted = false; + var tempFlags = 0; + var tempVariables; + var tempParameters; + var externalImports; + var exportSpecifiers; + var exportEquals; + var hasExportStars; + /** Write emitted output to disk */ + var writeEmittedFiles = writeJavaScriptFile; + var detachedCommentsInfo; + var writeComment = ts.writeCommentRange; + /** Emit a node */ + var emit = emitNodeWithCommentsAndWithoutSourcemap; + /** Called just before starting emit of a node */ + var emitStart = function (node) { }; + /** Called once the emit of the node is done */ + var emitEnd = function (node) { }; + /** Emit the text for the given token that comes after startPos + * This by default writes the text provided with the given tokenKind + * but if optional emitFn callback is provided the text is emitted using the callback instead of default text + * @param tokenKind the kind of the token to search and emit + * @param startPos the position in the source to start searching for the token + * @param emitFn if given will be invoked to emit the text instead of actual token emit */ + var emitToken = emitTokenText; + /** Called to before starting the lexical scopes as in function/class in the emitted code because of node + * @param scopeDeclaration node that starts the lexical scope + * @param scopeName Optional name of this scope instead of deducing one from the declaration node */ + var scopeEmitStart = function (scopeDeclaration, scopeName) { }; + /** Called after coming out of the scope */ + var scopeEmitEnd = function () { }; + /** Sourcemap data that will get encoded */ + var sourceMapData; + /** If removeComments is true, no leading-comments needed to be emitted **/ + var emitLeadingCommentsOfPosition = compilerOptions.removeComments ? function (pos) { } : emitLeadingCommentsOfPositionWorker; + var moduleEmitDelegates = (_a = {}, + _a[5 /* ES6 */] = emitES6Module, + _a[2 /* AMD */] = emitAMDModule, + _a[4 /* System */] = emitSystemModule, + _a[3 /* UMD */] = emitUMDModule, + _a[1 /* CommonJS */] = emitCommonJSModule, + _a + ); + if (compilerOptions.sourceMap || compilerOptions.inlineSourceMap) { + initializeEmitterWithSourceMaps(); + } + if (root) { + // Do not call emit directly. It does not set the currentSourceFile. + emitSourceFile(root); + } + else { + ts.forEach(host.getSourceFiles(), function (sourceFile) { + if (!isExternalModuleOrDeclarationFile(sourceFile)) { + emitSourceFile(sourceFile); + } + }); + } + writeLine(); + writeEmittedFiles(writer.getText(), /*writeByteOrderMark*/ compilerOptions.emitBOM); + return; + function emitSourceFile(sourceFile) { + currentSourceFile = sourceFile; + exportFunctionForFile = undefined; + emit(sourceFile); + } + function isUniqueName(name) { + return !resolver.hasGlobalName(name) && + !ts.hasProperty(currentSourceFile.identifiers, name) && + !ts.hasProperty(generatedNameSet, name); + } + // Return the next available name in the pattern _a ... _z, _0, _1, ... + // TempFlags._i or TempFlags._n may be used to express a preference for that dedicated name. + // Note that names generated by makeTempVariableName and makeUniqueName will never conflict. + function makeTempVariableName(flags) { + if (flags && !(tempFlags & flags)) { + var name_19 = flags === 268435456 /* _i */ ? "_i" : "_n"; + if (isUniqueName(name_19)) { + tempFlags |= flags; + return name_19; + } + } + while (true) { + var count = tempFlags & 268435455 /* CountMask */; + tempFlags++; + // Skip over 'i' and 'n' + if (count !== 8 && count !== 13) { + var name_20 = count < 26 ? "_" + String.fromCharCode(97 /* a */ + count) : "_" + (count - 26); + if (isUniqueName(name_20)) { + return name_20; + } + } + } + } + // Generate a name that is unique within the current file and doesn't conflict with any names + // in global scope. The name is formed by adding an '_n' suffix to the specified base name, + // where n is a positive integer. Note that names generated by makeTempVariableName and + // makeUniqueName are guaranteed to never conflict. + function makeUniqueName(baseName) { + // Find the first unique 'name_n', where n is a positive number + if (baseName.charCodeAt(baseName.length - 1) !== 95 /* _ */) { + baseName += "_"; + } + var i = 1; + while (true) { + var generatedName = baseName + i; + if (isUniqueName(generatedName)) { + return generatedNameSet[generatedName] = generatedName; + } + i++; + } + } + function generateNameForModuleOrEnum(node) { + var name = node.name.text; + // Use module/enum name itself if it is unique, otherwise make a unique variation + return isUniqueLocalName(name, node) ? name : makeUniqueName(name); + } + function generateNameForImportOrExportDeclaration(node) { + var expr = ts.getExternalModuleName(node); + var baseName = expr.kind === 9 /* StringLiteral */ ? + ts.escapeIdentifier(ts.makeIdentifierFromModuleName(expr.text)) : "module"; + return makeUniqueName(baseName); + } + function generateNameForExportDefault() { + return makeUniqueName("default"); + } + function generateNameForClassExpression() { + return makeUniqueName("class"); + } + function generateNameForNode(node) { + switch (node.kind) { + case 69 /* Identifier */: + return makeUniqueName(node.text); + case 218 /* ModuleDeclaration */: + case 217 /* EnumDeclaration */: + return generateNameForModuleOrEnum(node); + case 222 /* ImportDeclaration */: + case 228 /* ExportDeclaration */: + return generateNameForImportOrExportDeclaration(node); + case 213 /* FunctionDeclaration */: + case 214 /* ClassDeclaration */: + case 227 /* ExportAssignment */: + return generateNameForExportDefault(); + case 186 /* ClassExpression */: + return generateNameForClassExpression(); + } + } + function getGeneratedNameForNode(node) { + var id = ts.getNodeId(node); + return nodeToGeneratedName[id] || (nodeToGeneratedName[id] = ts.unescapeIdentifier(generateNameForNode(node))); + } + function initializeEmitterWithSourceMaps() { + var sourceMapDir; // The directory in which sourcemap will be + // Current source map file and its index in the sources list + var sourceMapSourceIndex = -1; + // Names and its index map + var sourceMapNameIndexMap = {}; + var sourceMapNameIndices = []; + function getSourceMapNameIndex() { + return sourceMapNameIndices.length ? ts.lastOrUndefined(sourceMapNameIndices) : -1; + } + // Last recorded and encoded spans + var lastRecordedSourceMapSpan; + var lastEncodedSourceMapSpan = { + emittedLine: 1, + emittedColumn: 1, + sourceLine: 1, + sourceColumn: 1, + sourceIndex: 0 + }; + var lastEncodedNameIndex = 0; + // Encoding for sourcemap span + function encodeLastRecordedSourceMapSpan() { + if (!lastRecordedSourceMapSpan || lastRecordedSourceMapSpan === lastEncodedSourceMapSpan) { + return; + } + var prevEncodedEmittedColumn = lastEncodedSourceMapSpan.emittedColumn; + // Line/Comma delimiters + if (lastEncodedSourceMapSpan.emittedLine === lastRecordedSourceMapSpan.emittedLine) { + // Emit comma to separate the entry + if (sourceMapData.sourceMapMappings) { + sourceMapData.sourceMapMappings += ","; + } + } + else { + // Emit line delimiters + for (var encodedLine = lastEncodedSourceMapSpan.emittedLine; encodedLine < lastRecordedSourceMapSpan.emittedLine; encodedLine++) { + sourceMapData.sourceMapMappings += ";"; + } + prevEncodedEmittedColumn = 1; + } + // 1. Relative Column 0 based + sourceMapData.sourceMapMappings += base64VLQFormatEncode(lastRecordedSourceMapSpan.emittedColumn - prevEncodedEmittedColumn); + // 2. Relative sourceIndex + sourceMapData.sourceMapMappings += base64VLQFormatEncode(lastRecordedSourceMapSpan.sourceIndex - lastEncodedSourceMapSpan.sourceIndex); + // 3. Relative sourceLine 0 based + sourceMapData.sourceMapMappings += base64VLQFormatEncode(lastRecordedSourceMapSpan.sourceLine - lastEncodedSourceMapSpan.sourceLine); + // 4. Relative sourceColumn 0 based + sourceMapData.sourceMapMappings += base64VLQFormatEncode(lastRecordedSourceMapSpan.sourceColumn - lastEncodedSourceMapSpan.sourceColumn); + // 5. Relative namePosition 0 based + if (lastRecordedSourceMapSpan.nameIndex >= 0) { + sourceMapData.sourceMapMappings += base64VLQFormatEncode(lastRecordedSourceMapSpan.nameIndex - lastEncodedNameIndex); + lastEncodedNameIndex = lastRecordedSourceMapSpan.nameIndex; + } + lastEncodedSourceMapSpan = lastRecordedSourceMapSpan; + sourceMapData.sourceMapDecodedMappings.push(lastEncodedSourceMapSpan); + function base64VLQFormatEncode(inValue) { + function base64FormatEncode(inValue) { + if (inValue < 64) { + return "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(inValue); + } + throw TypeError(inValue + ": not a 64 based value"); + } + // Add a new least significant bit that has the sign of the value. + // if negative number the least significant bit that gets added to the number has value 1 + // else least significant bit value that gets added is 0 + // eg. -1 changes to binary : 01 [1] => 3 + // +1 changes to binary : 01 [0] => 2 + if (inValue < 0) { + inValue = ((-inValue) << 1) + 1; + } + else { + inValue = inValue << 1; + } + // Encode 5 bits at a time starting from least significant bits + var encodedStr = ""; + do { + var currentDigit = inValue & 31; // 11111 + inValue = inValue >> 5; + if (inValue > 0) { + // There are still more digits to decode, set the msb (6th bit) + currentDigit = currentDigit | 32; + } + encodedStr = encodedStr + base64FormatEncode(currentDigit); + } while (inValue > 0); + return encodedStr; + } + } + function recordSourceMapSpan(pos) { + var sourceLinePos = ts.getLineAndCharacterOfPosition(currentSourceFile, pos); + // Convert the location to be one-based. + sourceLinePos.line++; + sourceLinePos.character++; + var emittedLine = writer.getLine(); + var emittedColumn = writer.getColumn(); + // If this location wasn't recorded or the location in source is going backwards, record the span + if (!lastRecordedSourceMapSpan || + lastRecordedSourceMapSpan.emittedLine !== emittedLine || + lastRecordedSourceMapSpan.emittedColumn !== emittedColumn || + (lastRecordedSourceMapSpan.sourceIndex === sourceMapSourceIndex && + (lastRecordedSourceMapSpan.sourceLine > sourceLinePos.line || + (lastRecordedSourceMapSpan.sourceLine === sourceLinePos.line && lastRecordedSourceMapSpan.sourceColumn > sourceLinePos.character)))) { + // Encode the last recordedSpan before assigning new + encodeLastRecordedSourceMapSpan(); + // New span + lastRecordedSourceMapSpan = { + emittedLine: emittedLine, + emittedColumn: emittedColumn, + sourceLine: sourceLinePos.line, + sourceColumn: sourceLinePos.character, + nameIndex: getSourceMapNameIndex(), + sourceIndex: sourceMapSourceIndex + }; + } + 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; + } + } + function recordEmitNodeStartSpan(node) { + // Get the token pos after skipping to the token (ignoring the leading trivia) + recordSourceMapSpan(ts.skipTrivia(currentSourceFile.text, node.pos)); + } + function recordEmitNodeEndSpan(node) { + recordSourceMapSpan(node.end); + } + function writeTextWithSpanRecord(tokenKind, startPos, emitFn) { + var tokenStartPos = ts.skipTrivia(currentSourceFile.text, startPos); + recordSourceMapSpan(tokenStartPos); + var tokenEndPos = emitTokenText(tokenKind, tokenStartPos, emitFn); + recordSourceMapSpan(tokenEndPos); + return tokenEndPos; + } + function recordNewSourceFileStart(node) { + // Add the file to tsFilePaths + // If sourceroot option: Use the relative path corresponding to the common directory path + // otherwise source locations relative to map file location + var sourcesDirectoryPath = compilerOptions.sourceRoot ? host.getCommonSourceDirectory() : sourceMapDir; + sourceMapData.sourceMapSources.push(ts.getRelativePathToDirectoryOrUrl(sourcesDirectoryPath, node.fileName, host.getCurrentDirectory(), host.getCanonicalFileName, + /*isAbsolutePathAnUrl*/ true)); + sourceMapSourceIndex = sourceMapData.sourceMapSources.length - 1; + // The one that can be used from program to get the actual source file + sourceMapData.inputSourceFileNames.push(node.fileName); + if (compilerOptions.inlineSources) { + if (!sourceMapData.sourceMapSourcesContent) { + sourceMapData.sourceMapSourcesContent = []; + } + sourceMapData.sourceMapSourcesContent.push(node.text); + } + } + function recordScopeNameOfNode(node, scopeName) { + function recordScopeNameIndex(scopeNameIndex) { + sourceMapNameIndices.push(scopeNameIndex); + } + function recordScopeNameStart(scopeName) { + var scopeNameIndex = -1; + if (scopeName) { + var parentIndex = getSourceMapNameIndex(); + if (parentIndex !== -1) { + // Child scopes are always shown with a dot (even if they have no name), + // unless it is a computed property. Then it is shown with brackets, + // but the brackets are included in the name. + var name_21 = node.name; + if (!name_21 || name_21.kind !== 136 /* ComputedPropertyName */) { + scopeName = "." + scopeName; + } + scopeName = sourceMapData.sourceMapNames[parentIndex] + scopeName; + } + scopeNameIndex = ts.getProperty(sourceMapNameIndexMap, scopeName); + if (scopeNameIndex === undefined) { + scopeNameIndex = sourceMapData.sourceMapNames.length; + sourceMapData.sourceMapNames.push(scopeName); + sourceMapNameIndexMap[scopeName] = scopeNameIndex; + } + } + recordScopeNameIndex(scopeNameIndex); + } + if (scopeName) { + // The scope was already given a name use it + recordScopeNameStart(scopeName); + } + else if (node.kind === 213 /* FunctionDeclaration */ || + node.kind === 173 /* FunctionExpression */ || + node.kind === 143 /* MethodDeclaration */ || + node.kind === 142 /* MethodSignature */ || + node.kind === 145 /* GetAccessor */ || + node.kind === 146 /* SetAccessor */ || + node.kind === 218 /* ModuleDeclaration */ || + node.kind === 214 /* ClassDeclaration */ || + node.kind === 217 /* EnumDeclaration */) { + // Declaration and has associated name use it + if (node.name) { + var name_22 = node.name; + // For computed property names, the text will include the brackets + scopeName = name_22.kind === 136 /* ComputedPropertyName */ + ? ts.getTextOfNode(name_22) + : node.name.text; + } + recordScopeNameStart(scopeName); + } + else { + // Block just use the name from upper level scope + recordScopeNameIndex(getSourceMapNameIndex()); + } + } + function recordScopeNameEnd() { + sourceMapNameIndices.pop(); + } + ; + function writeCommentRangeWithMap(curentSourceFile, writer, comment, newLine) { + recordSourceMapSpan(comment.pos); + ts.writeCommentRange(currentSourceFile, writer, comment, newLine); + recordSourceMapSpan(comment.end); + } + function serializeSourceMapContents(version, file, sourceRoot, sources, names, mappings, sourcesContent) { + if (typeof JSON !== "undefined") { + var map_1 = { + version: version, + file: file, + sourceRoot: sourceRoot, + sources: sources, + names: names, + mappings: mappings + }; + if (sourcesContent !== undefined) { + map_1.sourcesContent = sourcesContent; + } + return JSON.stringify(map_1); + } + return "{\"version\":" + version + ",\"file\":\"" + ts.escapeString(file) + "\",\"sourceRoot\":\"" + ts.escapeString(sourceRoot) + "\",\"sources\":[" + serializeStringArray(sources) + "],\"names\":[" + serializeStringArray(names) + "],\"mappings\":\"" + ts.escapeString(mappings) + "\" " + (sourcesContent !== undefined ? ",\"sourcesContent\":[" + serializeStringArray(sourcesContent) + "]" : "") + "}"; + function serializeStringArray(list) { + var output = ""; + for (var i = 0, n = list.length; i < n; i++) { + if (i) { + output += ","; + } + output += "\"" + ts.escapeString(list[i]) + "\""; + } + return output; + } + } + function writeJavaScriptAndSourceMapFile(emitOutput, writeByteOrderMark) { + encodeLastRecordedSourceMapSpan(); + var sourceMapText = serializeSourceMapContents(3, sourceMapData.sourceMapFile, sourceMapData.sourceMapSourceRoot, sourceMapData.sourceMapSources, sourceMapData.sourceMapNames, sourceMapData.sourceMapMappings, sourceMapData.sourceMapSourcesContent); + sourceMapDataList.push(sourceMapData); + var sourceMapUrl; + if (compilerOptions.inlineSourceMap) { + // Encode the sourceMap into the sourceMap url + var base64SourceMapText = ts.convertToBase64(sourceMapText); + sourceMapUrl = "//# sourceMappingURL=data:application/json;base64," + base64SourceMapText; + } + else { + // Write source map file + ts.writeFile(host, diagnostics, sourceMapData.sourceMapFilePath, sourceMapText, /*writeByteOrderMark*/ false); + sourceMapUrl = "//# sourceMappingURL=" + sourceMapData.jsSourceMappingURL; + } + // Write sourcemap url to the js file and write the js file + writeJavaScriptFile(emitOutput + sourceMapUrl, writeByteOrderMark); + } + // Initialize source map data + var sourceMapJsFile = ts.getBaseFileName(ts.normalizeSlashes(jsFilePath)); + sourceMapData = { + sourceMapFilePath: jsFilePath + ".map", + jsSourceMappingURL: sourceMapJsFile + ".map", + sourceMapFile: sourceMapJsFile, + sourceMapSourceRoot: compilerOptions.sourceRoot || "", + sourceMapSources: [], + inputSourceFileNames: [], + sourceMapNames: [], + sourceMapMappings: "", + sourceMapSourcesContent: undefined, + sourceMapDecodedMappings: [] + }; + // Normalize source root and make sure it has trailing "/" so that it can be used to combine paths with the + // relative paths of the sources list in the sourcemap + sourceMapData.sourceMapSourceRoot = ts.normalizeSlashes(sourceMapData.sourceMapSourceRoot); + if (sourceMapData.sourceMapSourceRoot.length && sourceMapData.sourceMapSourceRoot.charCodeAt(sourceMapData.sourceMapSourceRoot.length - 1) !== 47 /* slash */) { + sourceMapData.sourceMapSourceRoot += ts.directorySeparator; + } + if (compilerOptions.mapRoot) { + sourceMapDir = ts.normalizeSlashes(compilerOptions.mapRoot); + if (root) { + // For modules or multiple emit files the mapRoot will have directory structure like the sources + // So if src\a.ts and src\lib\b.ts are compiled together user would be moving the maps into mapRoot\a.js.map and mapRoot\lib\b.js.map + sourceMapDir = ts.getDirectoryPath(ts.getSourceFilePathInNewDir(root, host, sourceMapDir)); + } + if (!ts.isRootedDiskPath(sourceMapDir) && !ts.isUrl(sourceMapDir)) { + // The relative paths are relative to the common directory + sourceMapDir = ts.combinePaths(host.getCommonSourceDirectory(), sourceMapDir); + sourceMapData.jsSourceMappingURL = ts.getRelativePathToDirectoryOrUrl(ts.getDirectoryPath(ts.normalizePath(jsFilePath)), // get the relative sourceMapDir path based on jsFilePath + ts.combinePaths(sourceMapDir, sourceMapData.jsSourceMappingURL), // this is where user expects to see sourceMap + host.getCurrentDirectory(), host.getCanonicalFileName, + /*isAbsolutePathAnUrl*/ true); + } + else { + sourceMapData.jsSourceMappingURL = ts.combinePaths(sourceMapDir, sourceMapData.jsSourceMappingURL); + } + } + else { + sourceMapDir = ts.getDirectoryPath(ts.normalizePath(jsFilePath)); + } + function emitNodeWithSourceMap(node) { + if (node) { + if (ts.nodeIsSynthesized(node)) { + return emitNodeWithoutSourceMap(node); + } + if (node.kind !== 248 /* SourceFile */) { + recordEmitNodeStartSpan(node); + emitNodeWithoutSourceMap(node); + recordEmitNodeEndSpan(node); + } + else { + recordNewSourceFileStart(node); + emitNodeWithoutSourceMap(node); + } + } + } + function emitNodeWithCommentsAndWithSourcemap(node) { + emitNodeConsideringCommentsOption(node, emitNodeWithSourceMap); + } + writeEmittedFiles = writeJavaScriptAndSourceMapFile; + emit = emitNodeWithCommentsAndWithSourcemap; + emitStart = recordEmitNodeStartSpan; + emitEnd = recordEmitNodeEndSpan; + emitToken = writeTextWithSpanRecord; + scopeEmitStart = recordScopeNameOfNode; + scopeEmitEnd = recordScopeNameEnd; + writeComment = writeCommentRangeWithMap; + } + function writeJavaScriptFile(emitOutput, writeByteOrderMark) { + ts.writeFile(host, diagnostics, jsFilePath, emitOutput, writeByteOrderMark); + } + // Create a temporary variable with a unique unused name. + function createTempVariable(flags) { + var result = ts.createSynthesizedNode(69 /* Identifier */); + result.text = makeTempVariableName(flags); + return result; + } + function recordTempDeclaration(name) { + if (!tempVariables) { + tempVariables = []; + } + tempVariables.push(name); + } + function createAndRecordTempVariable(flags) { + var temp = createTempVariable(flags); + recordTempDeclaration(temp); + return temp; + } + function emitTempDeclarations(newLine) { + if (tempVariables) { + if (newLine) { + writeLine(); + } + else { + write(" "); + } + write("var "); + emitCommaList(tempVariables); + write(";"); + } + } + function emitTokenText(tokenKind, startPos, emitFn) { + var tokenString = ts.tokenToString(tokenKind); + if (emitFn) { + emitFn(); + } + else { + write(tokenString); + } + return startPos + tokenString.length; + } + function emitOptional(prefix, node) { + if (node) { + write(prefix); + emit(node); + } + } + function emitParenthesizedIf(node, parenthesized) { + if (parenthesized) { + write("("); + } + emit(node); + if (parenthesized) { + write(")"); + } + } + function emitTrailingCommaIfPresent(nodeList) { + if (nodeList.hasTrailingComma) { + write(","); + } + } + function emitLinePreservingList(parent, nodes, allowTrailingComma, spacesBetweenBraces) { + ts.Debug.assert(nodes.length > 0); + increaseIndent(); + if (nodeStartPositionsAreOnSameLine(parent, nodes[0])) { + if (spacesBetweenBraces) { + write(" "); + } + } + else { + writeLine(); + } + for (var i = 0, n = nodes.length; i < n; i++) { + if (i) { + if (nodeEndIsOnSameLineAsNodeStart(nodes[i - 1], nodes[i])) { + write(", "); + } + else { + write(","); + writeLine(); + } + } + emit(nodes[i]); + } + if (nodes.hasTrailingComma && allowTrailingComma) { + write(","); + } + decreaseIndent(); + if (nodeEndPositionsAreOnSameLine(parent, ts.lastOrUndefined(nodes))) { + if (spacesBetweenBraces) { + write(" "); + } + } + else { + writeLine(); + } + } + function emitList(nodes, start, count, multiLine, trailingComma, leadingComma, noTrailingNewLine, emitNode) { + if (!emitNode) { + emitNode = emit; + } + for (var i = 0; i < count; i++) { + if (multiLine) { + if (i || leadingComma) { + write(","); + } + writeLine(); + } + else { + if (i || leadingComma) { + write(", "); + } + } + var node = nodes[start + i]; + // This emitting is to make sure we emit following comment properly + // ...(x, /*comment1*/ y)... + // ^ => node.pos + // "comment1" is not considered leading comment for "y" but rather + // considered as trailing comment of the previous node. + emitTrailingCommentsOfPosition(node.pos); + emitNode(node); + leadingComma = true; + } + if (trailingComma) { + write(","); + } + if (multiLine && !noTrailingNewLine) { + writeLine(); + } + return count; + } + function emitCommaList(nodes) { + if (nodes) { + emitList(nodes, 0, nodes.length, /*multiline*/ false, /*trailingComma*/ false); + } + } + function emitLines(nodes) { + emitLinesStartingAt(nodes, /*startIndex*/ 0); + } + function emitLinesStartingAt(nodes, startIndex) { + for (var i = startIndex; i < nodes.length; i++) { + writeLine(); + emit(nodes[i]); + } + } + function isBinaryOrOctalIntegerLiteral(node, text) { + if (node.kind === 8 /* NumericLiteral */ && text.length > 1) { + switch (text.charCodeAt(1)) { + case 98 /* b */: + case 66 /* B */: + case 111 /* o */: + case 79 /* O */: + return true; + } + } + return false; + } + function emitLiteral(node) { + var text = getLiteralText(node); + if ((compilerOptions.sourceMap || compilerOptions.inlineSourceMap) && (node.kind === 9 /* StringLiteral */ || ts.isTemplateLiteralKind(node.kind))) { + writer.writeLiteral(text); + } + else if (languageVersion < 2 /* ES6 */ && isBinaryOrOctalIntegerLiteral(node, text)) { + write(node.text); + } + else { + write(text); + } + } + function getLiteralText(node) { + // 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 */ && (ts.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 (node.parent) { + return ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, node); + } + // If we can't reach the original source text, use the canonical form if it's a number, + // or an escaped quoted form of the original text if it's string-like. + switch (node.kind) { + case 9 /* StringLiteral */: + return getQuotedEscapedLiteralText("\"", node.text, "\""); + case 11 /* NoSubstitutionTemplateLiteral */: + return getQuotedEscapedLiteralText("`", node.text, "`"); + case 12 /* TemplateHead */: + return getQuotedEscapedLiteralText("`", node.text, "${"); + case 13 /* TemplateMiddle */: + return getQuotedEscapedLiteralText("}", node.text, "${"); + case 14 /* TemplateTail */: + return getQuotedEscapedLiteralText("}", node.text, "`"); + case 8 /* NumericLiteral */: + return node.text; + } + ts.Debug.fail("Literal kind '" + node.kind + "' not accounted for."); + } + function getQuotedEscapedLiteralText(leftQuote, text, rightQuote) { + return leftQuote + ts.escapeNonAsciiCharacters(ts.escapeString(text)) + rightQuote; + } + function emitDownlevelRawTemplateLiteral(node) { + // 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"); + text = ts.escapeString(text); + write("\"" + text + "\""); + } + function emitDownlevelTaggedTemplateArray(node, literalEmitter) { + write("["); + if (node.template.kind === 11 /* NoSubstitutionTemplateLiteral */) { + literalEmitter(node.template); + } + else { + literalEmitter(node.template.head); + ts.forEach(node.template.templateSpans, function (child) { + write(", "); + literalEmitter(child.literal); + }); + } + write("]"); + } + function emitDownlevelTaggedTemplate(node) { + var tempVariable = createAndRecordTempVariable(0 /* Auto */); + write("("); + emit(tempVariable); + write(" = "); + emitDownlevelTaggedTemplateArray(node, emit); + write(", "); + emit(tempVariable); + write(".raw = "); + emitDownlevelTaggedTemplateArray(node, emitDownlevelRawTemplateLiteral); + write(", "); + emitParenthesizedIf(node.tag, needsParenthesisForPropertyAccessOrInvocation(node.tag)); + write("("); + emit(tempVariable); + // Now we emit the expressions + if (node.template.kind === 183 /* TemplateExpression */) { + ts.forEach(node.template.templateSpans, function (templateSpan) { + write(", "); + var needsParens = templateSpan.expression.kind === 181 /* BinaryExpression */ + && templateSpan.expression.operatorToken.kind === 24 /* CommaToken */; + emitParenthesizedIf(templateSpan.expression, needsParens); + }); + } + write("))"); + } + function emitTemplateExpression(node) { + // In ES6 mode and above, we can simply emit each portion of a template in order, but in + // ES3 & ES5 we must convert the template expression into a series of string concatenations. + if (languageVersion >= 2 /* ES6 */) { + ts.forEachChild(node, emit); + return; + } + var emitOuterParens = ts.isExpression(node.parent) + && templateNeedsParens(node, node.parent); + if (emitOuterParens) { + write("("); + } + var headEmitted = false; + if (shouldEmitTemplateHead()) { + emitLiteral(node.head); + headEmitted = true; + } + for (var i = 0, n = node.templateSpans.length; i < n; i++) { + var templateSpan = node.templateSpans[i]; + // Check if the expression has operands and binds its operands less closely than binary '+'. + // If it does, we need to wrap 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 needsParens = templateSpan.expression.kind !== 172 /* ParenthesizedExpression */ + && comparePrecedenceToBinaryPlus(templateSpan.expression) !== 1 /* GreaterThan */; + if (i > 0 || headEmitted) { + // If this is the first span and the head was not emitted, then this templateSpan's + // expression will be the first to be emitted. Don't emit the preceding ' + ' in that + // case. + write(" + "); + } + emitParenthesizedIf(templateSpan.expression, needsParens); + // 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 (templateSpan.literal.text.length !== 0) { + write(" + "); + emitLiteral(templateSpan.literal); + } + } + if (emitOuterParens) { + write(")"); + } + function shouldEmitTemplateHead() { + // If this expression has an empty head literal and the first template span has a non-empty + // literal, then emitting the empty head literal is not necessary. + // `${ foo } and ${ bar }` + // can be emitted as + // foo + " and " + bar + // This is because it is only required that one of the first two operands in the emit + // output must be a string literal, so that the other operand and all following operands + // are forced into strings. + // + // If the first template span has an empty literal, then the head must still be emitted. + // `${ foo }${ bar }` + // must still be emitted as + // "" + foo + bar + // 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; + } + function templateNeedsParens(template, parent) { + switch (parent.kind) { + case 168 /* CallExpression */: + case 169 /* NewExpression */: + return parent.expression === template; + case 170 /* TaggedTemplateExpression */: + case 172 /* ParenthesizedExpression */: + return false; + default: + return comparePrecedenceToBinaryPlus(parent) !== -1 /* LessThan */; + } + } + /** + * Returns whether the expression has lesser, greater, + * or equal precedence to the binary '+' operator + */ + function comparePrecedenceToBinaryPlus(expression) { + // All binary expressions have lower precedence than '+' apart from '*', '/', and '%' + // which have greater precedence and '-' which has equal precedence. + // All unary operators have a higher precedence apart from yield. + // Arrow functions and conditionals have a lower precedence, + // although we convert the former into regular function expressions in ES5 mode, + // and in ES6 mode this function won't get called anyway. + // + // TODO (drosen): Note that we need to account for the upcoming 'yield' and + // spread ('...') unary operators that are anticipated for ES6. + switch (expression.kind) { + case 181 /* BinaryExpression */: + switch (expression.operatorToken.kind) { + case 37 /* AsteriskToken */: + case 39 /* SlashToken */: + case 40 /* PercentToken */: + return 1 /* GreaterThan */; + case 35 /* PlusToken */: + case 36 /* MinusToken */: + return 0 /* EqualTo */; + default: + return -1 /* LessThan */; + } + case 184 /* YieldExpression */: + case 182 /* ConditionalExpression */: + return -1 /* LessThan */; + default: + return 1 /* GreaterThan */; + } + } + } + function emitTemplateSpan(span) { + emit(span.expression); + emit(span.literal); + } + function jsxEmitReact(node) { + /// Emit a tag name, which is either '"div"' for lower-cased names, or + /// 'Div' for upper-cased or dotted names + function emitTagName(name) { + if (name.kind === 69 /* Identifier */ && ts.isIntrinsicJsxName(name.text)) { + write("\""); + emit(name); + write("\""); + } + else { + emit(name); + } + } + /// Emit an attribute name, which is quoted if it needs to be quoted. Because + /// these emit into an object literal property name, we don't need to be worried + /// about keywords, just non-identifier characters + function emitAttributeName(name) { + if (/[A-Za-z_]+[\w*]/.test(name.text)) { + write("\""); + emit(name); + write("\""); + } + else { + emit(name); + } + } + /// Emit an name/value pair for an attribute (e.g. "x: 3") + function emitJsxAttribute(node) { + emitAttributeName(node.name); + write(": "); + if (node.initializer) { + emit(node.initializer); + } + else { + write("true"); + } + } + function emitJsxElement(openingNode, children) { + var syntheticReactRef = ts.createSynthesizedNode(69 /* Identifier */); + syntheticReactRef.text = "React"; + syntheticReactRef.parent = openingNode; + // Call React.createElement(tag, ... + emitLeadingComments(openingNode); + emitExpressionIdentifier(syntheticReactRef); + write(".createElement("); + emitTagName(openingNode.tagName); + write(", "); + // Attribute list + if (openingNode.attributes.length === 0) { + // When there are no attributes, React wants "null" + write("null"); + } + else { + // Either emit one big object literal (no spread attribs), or + // a call to React.__spread + var attrs = openingNode.attributes; + if (ts.forEach(attrs, function (attr) { return attr.kind === 239 /* JsxSpreadAttribute */; })) { + emitExpressionIdentifier(syntheticReactRef); + write(".__spread("); + var haveOpenedObjectLiteral = false; + for (var i_1 = 0; i_1 < attrs.length; i_1++) { + if (attrs[i_1].kind === 239 /* JsxSpreadAttribute */) { + // If this is the first argument, we need to emit a {} as the first argument + if (i_1 === 0) { + write("{}, "); + } + if (haveOpenedObjectLiteral) { + write("}"); + haveOpenedObjectLiteral = false; + } + if (i_1 > 0) { + write(", "); + } + emit(attrs[i_1].expression); + } + else { + ts.Debug.assert(attrs[i_1].kind === 238 /* JsxAttribute */); + if (haveOpenedObjectLiteral) { + write(", "); + } + else { + haveOpenedObjectLiteral = true; + if (i_1 > 0) { + write(", "); + } + write("{"); + } + emitJsxAttribute(attrs[i_1]); + } + } + if (haveOpenedObjectLiteral) + write("}"); + write(")"); // closing paren to React.__spread( + } + else { + // One object literal with all the attributes in them + write("{"); + for (var i = 0; i < attrs.length; i++) { + if (i > 0) { + write(", "); + } + emitJsxAttribute(attrs[i]); + } + write("}"); + } + } + // Children + if (children) { + for (var i = 0; i < children.length; i++) { + // Don't emit empty expressions + if (children[i].kind === 240 /* JsxExpression */ && !(children[i].expression)) { + continue; + } + // Don't emit empty strings + if (children[i].kind === 236 /* JsxText */) { + var text = getTextToEmit(children[i]); + if (text !== undefined) { + write(", \""); + write(text); + write("\""); + } + } + else { + write(", "); + emit(children[i]); + } + } + } + // Closing paren + write(")"); // closes "React.createElement(" + emitTrailingComments(openingNode); + } + if (node.kind === 233 /* JsxElement */) { + emitJsxElement(node.openingElement, node.children); + } + else { + ts.Debug.assert(node.kind === 234 /* JsxSelfClosingElement */); + emitJsxElement(node); + } + } + function jsxEmitPreserve(node) { + function emitJsxAttribute(node) { + emit(node.name); + if (node.initializer) { + write("="); + emit(node.initializer); + } + } + function emitJsxSpreadAttribute(node) { + write("{..."); + emit(node.expression); + write("}"); + } + function emitAttributes(attribs) { + for (var i = 0, n = attribs.length; i < n; i++) { + if (i > 0) { + write(" "); + } + if (attribs[i].kind === 239 /* JsxSpreadAttribute */) { + emitJsxSpreadAttribute(attribs[i]); + } + else { + ts.Debug.assert(attribs[i].kind === 238 /* JsxAttribute */); + emitJsxAttribute(attribs[i]); + } + } + } + function emitJsxOpeningOrSelfClosingElement(node) { + write("<"); + emit(node.tagName); + if (node.attributes.length > 0 || (node.kind === 234 /* JsxSelfClosingElement */)) { + write(" "); + } + emitAttributes(node.attributes); + if (node.kind === 234 /* JsxSelfClosingElement */) { + write("/>"); + } + else { + write(">"); + } + } + function emitJsxClosingElement(node) { + write(""); + } + function emitJsxElement(node) { + emitJsxOpeningOrSelfClosingElement(node.openingElement); + for (var i = 0, n = node.children.length; i < n; i++) { + emit(node.children[i]); + } + emitJsxClosingElement(node.closingElement); + } + if (node.kind === 233 /* JsxElement */) { + emitJsxElement(node); + } + else { + ts.Debug.assert(node.kind === 234 /* JsxSelfClosingElement */); + emitJsxOpeningOrSelfClosingElement(node); + } + } + // This function specifically handles numeric/string literals for enum and accessor 'identifiers'. + // In a sense, it does not actually emit identifiers as much as it declares a name for a specific property. + // For example, this is utilized when feeding in a result to Object.defineProperty. + function emitExpressionForPropertyName(node) { + ts.Debug.assert(node.kind !== 163 /* BindingElement */); + if (node.kind === 9 /* StringLiteral */) { + emitLiteral(node); + } + else if (node.kind === 136 /* ComputedPropertyName */) { + // if this is a decorated computed property, we will need to capture the result + // of the property expression so that we can apply decorators later. This is to ensure + // we don't introduce unintended side effects: + // + // class C { + // [_a = x]() { } + // } + // + // The emit for the decorated computed property decorator is: + // + // __decorate([dec], C.prototype, _a, Object.getOwnPropertyDescriptor(C.prototype, _a)); + // + if (ts.nodeIsDecorated(node.parent)) { + if (!computedPropertyNamesToGeneratedNames) { + computedPropertyNamesToGeneratedNames = []; + } + var generatedName = computedPropertyNamesToGeneratedNames[ts.getNodeId(node)]; + if (generatedName) { + // we have already generated a variable for this node, write that value instead. + write(generatedName); + return; + } + generatedName = createAndRecordTempVariable(0 /* Auto */).text; + computedPropertyNamesToGeneratedNames[ts.getNodeId(node)] = generatedName; + write(generatedName); + write(" = "); + } + emit(node.expression); + } + else { + write("\""); + if (node.kind === 8 /* NumericLiteral */) { + write(node.text); + } + else { + writeTextOfNode(currentSourceFile, node); + } + write("\""); + } + } + function isExpressionIdentifier(node) { + var parent = node.parent; + switch (parent.kind) { + case 164 /* ArrayLiteralExpression */: + case 189 /* AsExpression */: + case 181 /* BinaryExpression */: + case 168 /* CallExpression */: + case 241 /* CaseClause */: + case 136 /* ComputedPropertyName */: + case 182 /* ConditionalExpression */: + case 139 /* Decorator */: + case 175 /* DeleteExpression */: + case 197 /* DoStatement */: + case 167 /* ElementAccessExpression */: + case 227 /* ExportAssignment */: + case 195 /* ExpressionStatement */: + case 188 /* ExpressionWithTypeArguments */: + case 199 /* ForStatement */: + case 200 /* ForInStatement */: + case 201 /* ForOfStatement */: + case 196 /* IfStatement */: + case 234 /* JsxSelfClosingElement */: + case 235 /* JsxOpeningElement */: + case 239 /* JsxSpreadAttribute */: + case 240 /* JsxExpression */: + case 169 /* NewExpression */: + case 172 /* ParenthesizedExpression */: + case 180 /* PostfixUnaryExpression */: + case 179 /* PrefixUnaryExpression */: + case 204 /* ReturnStatement */: + case 246 /* ShorthandPropertyAssignment */: + case 185 /* SpreadElementExpression */: + case 206 /* SwitchStatement */: + case 170 /* TaggedTemplateExpression */: + case 190 /* TemplateSpan */: + case 208 /* ThrowStatement */: + case 171 /* TypeAssertionExpression */: + case 176 /* TypeOfExpression */: + case 177 /* VoidExpression */: + case 198 /* WhileStatement */: + case 205 /* WithStatement */: + case 184 /* YieldExpression */: + return true; + case 163 /* BindingElement */: + case 247 /* EnumMember */: + case 138 /* Parameter */: + case 245 /* PropertyAssignment */: + case 141 /* PropertyDeclaration */: + case 211 /* VariableDeclaration */: + return parent.initializer === node; + case 166 /* PropertyAccessExpression */: + return parent.expression === node; + case 174 /* ArrowFunction */: + case 173 /* FunctionExpression */: + return parent.body === node; + case 221 /* ImportEqualsDeclaration */: + return parent.moduleReference === node; + case 135 /* QualifiedName */: + return parent.left === node; + } + return false; + } + function emitExpressionIdentifier(node) { + if (resolver.getNodeCheckFlags(node) & 2048 /* LexicalArguments */) { + write("_arguments"); + return; + } + var container = resolver.getReferencedExportContainer(node); + if (container) { + if (container.kind === 248 /* SourceFile */) { + // Identifier references module export + if (modulekind !== 5 /* ES6 */ && modulekind !== 4 /* System */) { + write("exports."); + } + } + else { + // Identifier references namespace export + write(getGeneratedNameForNode(container)); + write("."); + } + } + else if (modulekind !== 5 /* ES6 */) { + var declaration = resolver.getReferencedImportDeclaration(node); + if (declaration) { + if (declaration.kind === 223 /* ImportClause */) { + // Identifier references default import + write(getGeneratedNameForNode(declaration.parent)); + write(languageVersion === 0 /* ES3 */ ? "[\"default\"]" : ".default"); + return; + } + else if (declaration.kind === 226 /* ImportSpecifier */) { + // Identifier references named import + write(getGeneratedNameForNode(declaration.parent.parent.parent)); + var name_23 = declaration.propertyName || declaration.name; + var identifier = ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, name_23); + if (languageVersion === 0 /* ES3 */ && identifier === "default") { + write("[\"default\"]"); + } + else { + write("."); + write(identifier); + } + return; + } + } + declaration = resolver.getReferencedNestedRedeclaration(node); + if (declaration) { + write(getGeneratedNameForNode(declaration.name)); + return; + } + } + if (ts.nodeIsSynthesized(node)) { + write(node.text); + } + else { + writeTextOfNode(currentSourceFile, node); + } + } + function isNameOfNestedRedeclaration(node) { + if (languageVersion < 2 /* ES6 */) { + var parent_6 = node.parent; + switch (parent_6.kind) { + case 163 /* BindingElement */: + case 214 /* ClassDeclaration */: + case 217 /* EnumDeclaration */: + case 211 /* VariableDeclaration */: + return parent_6.name === node && resolver.isNestedRedeclaration(parent_6); + } + } + return false; + } + function emitIdentifier(node) { + if (!node.parent) { + write(node.text); + } + else if (isExpressionIdentifier(node)) { + emitExpressionIdentifier(node); + } + else if (isNameOfNestedRedeclaration(node)) { + write(getGeneratedNameForNode(node)); + } + else if (ts.nodeIsSynthesized(node)) { + write(node.text); + } + else { + writeTextOfNode(currentSourceFile, node); + } + } + function emitThis(node) { + if (resolver.getNodeCheckFlags(node) & 2 /* LexicalThis */) { + write("_this"); + } + else { + write("this"); + } + } + function emitSuper(node) { + if (languageVersion >= 2 /* ES6 */) { + write("super"); + } + else { + var flags = resolver.getNodeCheckFlags(node); + if (flags & 256 /* SuperInstance */) { + write("_super.prototype"); + } + else { + write("_super"); + } + } + } + function emitObjectBindingPattern(node) { + write("{ "); + var elements = node.elements; + emitList(elements, 0, elements.length, /*multiLine*/ false, /*trailingComma*/ elements.hasTrailingComma); + write(" }"); + } + function emitArrayBindingPattern(node) { + write("["); + var elements = node.elements; + emitList(elements, 0, elements.length, /*multiLine*/ false, /*trailingComma*/ elements.hasTrailingComma); + write("]"); + } + function emitBindingElement(node) { + if (node.propertyName) { + emit(node.propertyName); + write(": "); + } + if (node.dotDotDotToken) { + write("..."); + } + if (ts.isBindingPattern(node.name)) { + emit(node.name); + } + else { + emitModuleMemberName(node); + } + emitOptional(" = ", node.initializer); + } + function emitSpreadElementExpression(node) { + write("..."); + emit(node.expression); + } + function emitYieldExpression(node) { + write(ts.tokenToString(114 /* YieldKeyword */)); + if (node.asteriskToken) { + write("*"); + } + if (node.expression) { + write(" "); + emit(node.expression); + } + } + function emitAwaitExpression(node) { + var needsParenthesis = needsParenthesisForAwaitExpressionAsYield(node); + if (needsParenthesis) { + write("("); + } + write(ts.tokenToString(114 /* YieldKeyword */)); + write(" "); + emit(node.expression); + if (needsParenthesis) { + write(")"); + } + } + function needsParenthesisForAwaitExpressionAsYield(node) { + if (node.parent.kind === 181 /* BinaryExpression */ && !ts.isAssignmentOperator(node.parent.operatorToken.kind)) { + return true; + } + else if (node.parent.kind === 182 /* ConditionalExpression */ && node.parent.condition === node) { + return true; + } + return false; + } + function needsParenthesisForPropertyAccessOrInvocation(node) { + switch (node.kind) { + case 69 /* Identifier */: + case 164 /* ArrayLiteralExpression */: + case 166 /* PropertyAccessExpression */: + case 167 /* ElementAccessExpression */: + case 168 /* CallExpression */: + case 172 /* ParenthesizedExpression */: + // This list is not exhaustive and only includes those cases that are relevant + // to the check in emitArrayLiteral. More cases can be added as needed. + return false; + } + return true; + } + function emitListWithSpread(elements, needsUniqueCopy, multiLine, trailingComma, useConcat) { + var pos = 0; + var group = 0; + var length = elements.length; + while (pos < length) { + // Emit using the pattern .concat(, , ...) + if (group === 1 && useConcat) { + write(".concat("); + } + else if (group > 0) { + write(", "); + } + var e = elements[pos]; + if (e.kind === 185 /* SpreadElementExpression */) { + e = e.expression; + emitParenthesizedIf(e, /*parenthesized*/ group === 0 && needsParenthesisForPropertyAccessOrInvocation(e)); + pos++; + if (pos === length && group === 0 && needsUniqueCopy && e.kind !== 164 /* ArrayLiteralExpression */) { + write(".slice()"); + } + } + else { + var i = pos; + while (i < length && elements[i].kind !== 185 /* SpreadElementExpression */) { + i++; + } + write("["); + if (multiLine) { + increaseIndent(); + } + emitList(elements, pos, i - pos, multiLine, trailingComma && i === length); + if (multiLine) { + decreaseIndent(); + } + write("]"); + pos = i; + } + group++; + } + if (group > 1) { + if (useConcat) { + write(")"); + } + } + } + function isSpreadElementExpression(node) { + return node.kind === 185 /* SpreadElementExpression */; + } + function emitArrayLiteral(node) { + var elements = node.elements; + if (elements.length === 0) { + write("[]"); + } + else if (languageVersion >= 2 /* ES6 */ || !ts.forEach(elements, isSpreadElementExpression)) { + write("["); + emitLinePreservingList(node, node.elements, elements.hasTrailingComma, /*spacesBetweenBraces:*/ false); + write("]"); + } + else { + emitListWithSpread(elements, /*needsUniqueCopy*/ true, /*multiLine*/ (node.flags & 2048 /* MultiLine */) !== 0, + /*trailingComma*/ elements.hasTrailingComma, /*useConcat*/ true); + } + } + function emitObjectLiteralBody(node, numElements) { + if (numElements === 0) { + write("{}"); + return; + } + write("{"); + if (numElements > 0) { + var properties = node.properties; + // If we are not doing a downlevel transformation for object literals, + // then try to preserve the original shape of the object literal. + // Otherwise just try to preserve the formatting. + if (numElements === properties.length) { + emitLinePreservingList(node, properties, /* allowTrailingComma */ languageVersion >= 1 /* ES5 */, /* spacesBetweenBraces */ true); + } + else { + var multiLine = (node.flags & 2048 /* MultiLine */) !== 0; + if (!multiLine) { + write(" "); + } + else { + increaseIndent(); + } + emitList(properties, 0, numElements, /*multiLine*/ multiLine, /*trailingComma*/ false); + if (!multiLine) { + write(" "); + } + else { + decreaseIndent(); + } + } + } + write("}"); + } + function emitDownlevelObjectLiteralWithComputedProperties(node, firstComputedPropertyIndex) { + var multiLine = (node.flags & 2048 /* MultiLine */) !== 0; + var properties = node.properties; + write("("); + if (multiLine) { + increaseIndent(); + } + // 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 tempVar = createAndRecordTempVariable(0 /* Auto */); + // Write out the first non-computed properties + // (or all properties if none of them are computed), + // then emit the rest through indexing on the temp variable. + emit(tempVar); + write(" = "); + emitObjectLiteralBody(node, firstComputedPropertyIndex); + for (var i = firstComputedPropertyIndex, n = properties.length; i < n; i++) { + writeComma(); + var property = properties[i]; + emitStart(property); + if (property.kind === 145 /* GetAccessor */ || property.kind === 146 /* SetAccessor */) { + // TODO (drosen): Reconcile with 'emitMemberFunctions'. + var accessors = ts.getAllAccessorDeclarations(node.properties, property); + if (property !== accessors.firstAccessor) { + continue; + } + write("Object.defineProperty("); + emit(tempVar); + write(", "); + emitStart(node.name); + emitExpressionForPropertyName(property.name); + emitEnd(property.name); + write(", {"); + increaseIndent(); + if (accessors.getAccessor) { + writeLine(); + emitLeadingComments(accessors.getAccessor); + write("get: "); + emitStart(accessors.getAccessor); + write("function "); + emitSignatureAndBody(accessors.getAccessor); + emitEnd(accessors.getAccessor); + emitTrailingComments(accessors.getAccessor); + write(","); + } + if (accessors.setAccessor) { + writeLine(); + emitLeadingComments(accessors.setAccessor); + write("set: "); + emitStart(accessors.setAccessor); + write("function "); + emitSignatureAndBody(accessors.setAccessor); + emitEnd(accessors.setAccessor); + emitTrailingComments(accessors.setAccessor); + write(","); + } + writeLine(); + write("enumerable: true,"); + writeLine(); + write("configurable: true"); + decreaseIndent(); + writeLine(); + write("})"); + emitEnd(property); + } + else { + emitLeadingComments(property); + emitStart(property.name); + emit(tempVar); + emitMemberAccessForPropertyName(property.name); + emitEnd(property.name); + write(" = "); + if (property.kind === 245 /* PropertyAssignment */) { + emit(property.initializer); + } + else if (property.kind === 246 /* ShorthandPropertyAssignment */) { + emitExpressionIdentifier(property.name); + } + else if (property.kind === 143 /* MethodDeclaration */) { + emitFunctionDeclaration(property); + } + else { + ts.Debug.fail("ObjectLiteralElement type not accounted for: " + property.kind); + } + } + emitEnd(property); + } + writeComma(); + emit(tempVar); + if (multiLine) { + decreaseIndent(); + writeLine(); + } + write(")"); + function writeComma() { + if (multiLine) { + write(","); + writeLine(); + } + else { + write(", "); + } + } + } + function emitObjectLiteral(node) { + var properties = node.properties; + if (languageVersion < 2 /* ES6 */) { + var numProperties = properties.length; + // Find the first computed property. + // Everything until that point can be emitted as part of the initial object literal. + var numInitialNonComputedProperties = numProperties; + for (var i = 0, n = properties.length; i < n; i++) { + if (properties[i].name.kind === 136 /* ComputedPropertyName */) { + numInitialNonComputedProperties = i; + break; + } + } + var hasComputedProperty = numInitialNonComputedProperties !== properties.length; + if (hasComputedProperty) { + emitDownlevelObjectLiteralWithComputedProperties(node, numInitialNonComputedProperties); + return; + } + } + // Ordinary case: either the object has no computed properties + // or we're compiling with an ES6+ target. + emitObjectLiteralBody(node, properties.length); + } + function createBinaryExpression(left, operator, right, startsOnNewLine) { + var result = ts.createSynthesizedNode(181 /* BinaryExpression */, startsOnNewLine); + result.operatorToken = ts.createSynthesizedNode(operator); + result.left = left; + result.right = right; + return result; + } + function createPropertyAccessExpression(expression, name) { + var result = ts.createSynthesizedNode(166 /* PropertyAccessExpression */); + result.expression = parenthesizeForAccess(expression); + result.dotToken = ts.createSynthesizedNode(21 /* DotToken */); + result.name = name; + return result; + } + function createElementAccessExpression(expression, argumentExpression) { + var result = ts.createSynthesizedNode(167 /* ElementAccessExpression */); + result.expression = parenthesizeForAccess(expression); + result.argumentExpression = argumentExpression; + return result; + } + function parenthesizeForAccess(expr) { + // When diagnosing whether the expression needs parentheses, the decision should be based + // on the innermost expression in a chain of nested type assertions. + while (expr.kind === 171 /* TypeAssertionExpression */ || expr.kind === 189 /* AsExpression */) { + expr = expr.expression; + } + // isLeftHandSideExpression is almost the correct criterion for when it is not necessary + // to parenthesize the expression before a dot. The known exceptions are: + // + // NewExpression: + // new C.x -> not the same as (new C).x + // NumberLiteral + // 1.x -> not the same as (1).x + // + if (ts.isLeftHandSideExpression(expr) && + expr.kind !== 169 /* NewExpression */ && + expr.kind !== 8 /* NumericLiteral */) { + return expr; + } + var node = ts.createSynthesizedNode(172 /* ParenthesizedExpression */); + node.expression = expr; + return node; + } + function emitComputedPropertyName(node) { + write("["); + emitExpressionForPropertyName(node); + write("]"); + } + function emitMethod(node) { + if (languageVersion >= 2 /* ES6 */ && node.asteriskToken) { + write("*"); + } + emit(node.name); + if (languageVersion < 2 /* ES6 */) { + write(": function "); + } + emitSignatureAndBody(node); + } + function emitPropertyAssignment(node) { + emit(node.name); + write(": "); + // This is to ensure that we emit comment in the following case: + // For example: + // obj = { + // id: /*comment1*/ ()=>void + // } + // "comment1" is not considered to be leading comment for node.initializer + // but rather a trailing comment on the previous node. + emitTrailingCommentsOfPosition(node.initializer.pos); + emit(node.initializer); + } + // Return true if identifier resolves to an exported member of a namespace + function isNamespaceExportReference(node) { + var container = resolver.getReferencedExportContainer(node); + return container && container.kind !== 248 /* SourceFile */; + } + function emitShorthandPropertyAssignment(node) { + // The name property of a short-hand property assignment is considered an expression position, so here + // we manually emit the identifier to avoid rewriting. + writeTextOfNode(currentSourceFile, node.name); + // If emitting pre-ES6 code, or if the name requires rewriting when resolved as an expression identifier, + // we emit a normal property assignment. For example: + // module m { + // export let y; + // } + // module m { + // let obj = { y }; + // } + // Here we need to emit obj = { y : m.y } regardless of the output target. + if (languageVersion < 2 /* ES6 */ || isNamespaceExportReference(node.name)) { + // Emit identifier as an identifier + write(": "); + emit(node.name); + } + if (languageVersion >= 2 /* ES6 */ && node.objectAssignmentInitializer) { + write(" = "); + emit(node.objectAssignmentInitializer); + } + } + function tryEmitConstantValue(node) { + var constantValue = tryGetConstEnumValue(node); + if (constantValue !== undefined) { + write(constantValue.toString()); + if (!compilerOptions.removeComments) { + var propertyName = node.kind === 166 /* PropertyAccessExpression */ ? ts.declarationNameToString(node.name) : ts.getTextOfNode(node.argumentExpression); + write(" /* " + propertyName + " */"); + } + return true; + } + return false; + } + function tryGetConstEnumValue(node) { + if (compilerOptions.isolatedModules) { + return undefined; + } + return node.kind === 166 /* PropertyAccessExpression */ || node.kind === 167 /* ElementAccessExpression */ + ? resolver.getConstantValue(node) + : undefined; + } + // Returns 'true' if the code was actually indented, false otherwise. + // If the code is not indented, an optional valueToWriteWhenNotIndenting will be + // emitted instead. + function indentIfOnDifferentLines(parent, node1, node2, valueToWriteWhenNotIndenting) { + var realNodesAreOnDifferentLines = !ts.nodeIsSynthesized(parent) && !nodeEndIsOnSameLineAsNodeStart(node1, node2); + // Always use a newline for synthesized code if the synthesizer desires it. + var synthesizedNodeIsOnDifferentLine = synthesizedNodeStartsOnNewLine(node2); + if (realNodesAreOnDifferentLines || synthesizedNodeIsOnDifferentLine) { + increaseIndent(); + writeLine(); + return true; + } + else { + if (valueToWriteWhenNotIndenting) { + write(valueToWriteWhenNotIndenting); + } + return false; + } + } + function emitPropertyAccess(node) { + if (tryEmitConstantValue(node)) { + return; + } + emit(node.expression); + var indentedBeforeDot = indentIfOnDifferentLines(node, node.expression, node.dotToken); + // 1 .toString is a valid property access, emit a space after the literal + // Also emit a space if expression is a integer const enum value - it will appear in generated code as numeric literal + var shouldEmitSpace; + if (!indentedBeforeDot) { + if (node.expression.kind === 8 /* NumericLiteral */) { + // check if numeric literal was originally written with a dot + var text = ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, node.expression); + shouldEmitSpace = text.indexOf(ts.tokenToString(21 /* DotToken */)) < 0; + } + else { + // check if constant enum value is integer + var constantValue = tryGetConstEnumValue(node.expression); + // isFinite handles cases when constantValue is undefined + shouldEmitSpace = isFinite(constantValue) && Math.floor(constantValue) === constantValue; + } + } + if (shouldEmitSpace) { + write(" ."); + } + else { + write("."); + } + var indentedAfterDot = indentIfOnDifferentLines(node, node.dotToken, node.name); + emit(node.name); + decreaseIndentIf(indentedBeforeDot, indentedAfterDot); + } + function emitQualifiedName(node) { + emit(node.left); + write("."); + emit(node.right); + } + function emitQualifiedNameAsExpression(node, useFallback) { + if (node.left.kind === 69 /* Identifier */) { + emitEntityNameAsExpression(node.left, useFallback); + } + else if (useFallback) { + var temp = createAndRecordTempVariable(0 /* Auto */); + write("("); + emitNodeWithoutSourceMap(temp); + write(" = "); + emitEntityNameAsExpression(node.left, /*useFallback*/ true); + write(") && "); + emitNodeWithoutSourceMap(temp); + } + else { + emitEntityNameAsExpression(node.left, /*useFallback*/ false); + } + write("."); + emit(node.right); + } + function emitEntityNameAsExpression(node, useFallback) { + switch (node.kind) { + case 69 /* Identifier */: + if (useFallback) { + write("typeof "); + emitExpressionIdentifier(node); + write(" !== 'undefined' && "); + } + emitExpressionIdentifier(node); + break; + case 135 /* QualifiedName */: + emitQualifiedNameAsExpression(node, useFallback); + break; + } + } + function emitIndexedAccess(node) { + if (tryEmitConstantValue(node)) { + return; + } + emit(node.expression); + write("["); + emit(node.argumentExpression); + write("]"); + } + function hasSpreadElement(elements) { + return ts.forEach(elements, function (e) { return e.kind === 185 /* SpreadElementExpression */; }); + } + function skipParentheses(node) { + while (node.kind === 172 /* ParenthesizedExpression */ || node.kind === 171 /* TypeAssertionExpression */ || node.kind === 189 /* AsExpression */) { + node = node.expression; + } + return node; + } + function emitCallTarget(node) { + if (node.kind === 69 /* Identifier */ || node.kind === 97 /* ThisKeyword */ || node.kind === 95 /* SuperKeyword */) { + emit(node); + return node; + } + var temp = createAndRecordTempVariable(0 /* Auto */); + write("("); + emit(temp); + write(" = "); + emit(node); + write(")"); + return temp; + } + function emitCallWithSpread(node) { + var target; + var expr = skipParentheses(node.expression); + if (expr.kind === 166 /* PropertyAccessExpression */) { + // Target will be emitted as "this" argument + target = emitCallTarget(expr.expression); + write("."); + emit(expr.name); + } + else if (expr.kind === 167 /* ElementAccessExpression */) { + // Target will be emitted as "this" argument + target = emitCallTarget(expr.expression); + write("["); + emit(expr.argumentExpression); + write("]"); + } + else if (expr.kind === 95 /* SuperKeyword */) { + target = expr; + write("_super"); + } + else { + emit(node.expression); + } + write(".apply("); + if (target) { + if (target.kind === 95 /* SuperKeyword */) { + // Calls of form super(...) and super.foo(...) + emitThis(target); + } + else { + // Calls of form obj.foo(...) + emit(target); + } + } + else { + // Calls of form foo(...) + write("void 0"); + } + write(", "); + emitListWithSpread(node.arguments, /*needsUniqueCopy*/ false, /*multiLine*/ false, /*trailingComma*/ false, /*useConcat*/ true); + write(")"); + } + function emitCallExpression(node) { + if (languageVersion < 2 /* ES6 */ && hasSpreadElement(node.arguments)) { + emitCallWithSpread(node); + return; + } + var superCall = false; + if (node.expression.kind === 95 /* SuperKeyword */) { + emitSuper(node.expression); + superCall = true; + } + else { + emit(node.expression); + superCall = node.expression.kind === 166 /* PropertyAccessExpression */ && node.expression.expression.kind === 95 /* SuperKeyword */; + } + if (superCall && languageVersion < 2 /* ES6 */) { + write(".call("); + emitThis(node.expression); + if (node.arguments.length) { + write(", "); + emitCommaList(node.arguments); + } + write(")"); + } + else { + write("("); + emitCommaList(node.arguments); + write(")"); + } + } + function emitNewExpression(node) { + write("new "); + // Spread operator logic is supported in new expressions in ES5 using a combination + // of Function.prototype.bind() and Function.prototype.apply(). + // + // Example: + // + // var args = [1, 2, 3, 4, 5]; + // new Array(...args); + // + // is compiled into the following ES5: + // + // var args = [1, 2, 3, 4, 5]; + // new (Array.bind.apply(Array, [void 0].concat(args))); + // + // The 'thisArg' to 'bind' is ignored when invoking the result of 'bind' with 'new', + // Thus, we set it to undefined ('void 0'). + if (languageVersion === 1 /* ES5 */ && + node.arguments && + hasSpreadElement(node.arguments)) { + write("("); + var target = emitCallTarget(node.expression); + write(".bind.apply("); + emit(target); + write(", [void 0].concat("); + emitListWithSpread(node.arguments, /*needsUniqueCopy*/ false, /*multiline*/ false, /*trailingComma*/ false, /*useConcat*/ false); + write(")))"); + write("()"); + } + else { + emit(node.expression); + if (node.arguments) { + write("("); + emitCommaList(node.arguments); + write(")"); + } + } + } + function emitTaggedTemplateExpression(node) { + if (languageVersion >= 2 /* ES6 */) { + emit(node.tag); + write(" "); + emit(node.template); + } + else { + emitDownlevelTaggedTemplate(node); + } + } + function emitParenExpression(node) { + // If the node is synthesized, it means the emitter put the parentheses there, + // not the user. If we didn't want them, the emitter would not have put them + // there. + if (!ts.nodeIsSynthesized(node) && node.parent.kind !== 174 /* ArrowFunction */) { + if (node.expression.kind === 171 /* TypeAssertionExpression */ || node.expression.kind === 189 /* AsExpression */) { + var operand = node.expression.expression; + // Make sure we consider all nested cast expressions, e.g.: + // (-A).x; + while (operand.kind === 171 /* TypeAssertionExpression */ || operand.kind === 189 /* AsExpression */) { + operand = operand.expression; + } + // We have an expression of the form: (SubExpr) + // Emitting this as (SubExpr) is really not desirable. We would like to emit the subexpr as is. + // Omitting the parentheses, however, could cause change in the semantics of the generated + // code if the casted expression has a lower precedence than the rest of the expression, e.g.: + // (new A).foo should be emitted as (new A).foo and not new A.foo + // (typeof A).toString() should be emitted as (typeof A).toString() and not typeof A.toString() + // new (A()) should be emitted as new (A()) and not new A() + // (function foo() { })() should be emitted as an IIF (function foo(){})() and not declaration function foo(){} () + if (operand.kind !== 179 /* PrefixUnaryExpression */ && + operand.kind !== 177 /* VoidExpression */ && + operand.kind !== 176 /* TypeOfExpression */ && + operand.kind !== 175 /* DeleteExpression */ && + operand.kind !== 180 /* PostfixUnaryExpression */ && + operand.kind !== 169 /* NewExpression */ && + !(operand.kind === 168 /* CallExpression */ && node.parent.kind === 169 /* NewExpression */) && + !(operand.kind === 173 /* FunctionExpression */ && node.parent.kind === 168 /* CallExpression */) && + !(operand.kind === 8 /* NumericLiteral */ && node.parent.kind === 166 /* PropertyAccessExpression */)) { + emit(operand); + return; + } + } + } + write("("); + emit(node.expression); + write(")"); + } + function emitDeleteExpression(node) { + write(ts.tokenToString(78 /* DeleteKeyword */)); + write(" "); + emit(node.expression); + } + function emitVoidExpression(node) { + write(ts.tokenToString(103 /* VoidKeyword */)); + write(" "); + emit(node.expression); + } + function emitTypeOfExpression(node) { + write(ts.tokenToString(101 /* TypeOfKeyword */)); + write(" "); + emit(node.expression); + } + function isNameOfExportedSourceLevelDeclarationInSystemExternalModule(node) { + if (!isCurrentFileSystemExternalModule() || node.kind !== 69 /* Identifier */ || ts.nodeIsSynthesized(node)) { + return false; + } + var isVariableDeclarationOrBindingElement = node.parent && (node.parent.kind === 211 /* VariableDeclaration */ || node.parent.kind === 163 /* BindingElement */); + var targetDeclaration = isVariableDeclarationOrBindingElement + ? node.parent + : resolver.getReferencedValueDeclaration(node); + return isSourceFileLevelDeclarationInSystemJsModule(targetDeclaration, /*isExported*/ true); + } + function emitPrefixUnaryExpression(node) { + var exportChanged = isNameOfExportedSourceLevelDeclarationInSystemExternalModule(node.operand); + if (exportChanged) { + // emit + // ++x + // as + // exports('x', ++x) + write(exportFunctionForFile + "(\""); + emitNodeWithoutSourceMap(node.operand); + write("\", "); + } + write(ts.tokenToString(node.operator)); + // In some cases, we need to emit a space between the operator and the operand. One obvious case + // is when the operator is an identifier, like delete or typeof. We also need to do this for plus + // and minus expressions in certain cases. Specifically, consider the following two cases (parens + // are just for clarity of exposition, and not part of the source code): + // + // (+(+1)) + // (+(++1)) + // + // We need to emit a space in both cases. In the first case, the absence of a space will make + // the resulting expression a prefix increment operation. And in the second, it will make the resulting + // expression a prefix increment whose operand is a plus expression - (++(+x)) + // The same is true of minus of course. + if (node.operand.kind === 179 /* PrefixUnaryExpression */) { + var operand = node.operand; + if (node.operator === 35 /* PlusToken */ && (operand.operator === 35 /* PlusToken */ || operand.operator === 41 /* PlusPlusToken */)) { + write(" "); + } + else if (node.operator === 36 /* MinusToken */ && (operand.operator === 36 /* MinusToken */ || operand.operator === 42 /* MinusMinusToken */)) { + write(" "); + } + } + emit(node.operand); + if (exportChanged) { + write(")"); + } + } + function emitPostfixUnaryExpression(node) { + var exportChanged = isNameOfExportedSourceLevelDeclarationInSystemExternalModule(node.operand); + if (exportChanged) { + // 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)' + write("(" + exportFunctionForFile + "(\""); + emitNodeWithoutSourceMap(node.operand); + write("\", "); + write(ts.tokenToString(node.operator)); + emit(node.operand); + if (node.operator === 41 /* PlusPlusToken */) { + write(") - 1)"); + } + else { + write(") + 1)"); + } + } + else { + emit(node.operand); + write(ts.tokenToString(node.operator)); + } + } + function shouldHoistDeclarationInSystemJsModule(node) { + return isSourceFileLevelDeclarationInSystemJsModule(node, /*isExported*/ false); + } + /* + * Checks if given node is a source file level declaration (not nested in module/function). + * If 'isExported' is true - then declaration must also be exported. + * This function is used in two cases: + * - check if node is a exported source file level value to determine + * if we should also export the value after its it changed + * - check if node is a source level declaration to emit it differently, + * i.e non-exported variable statement 'var x = 1' is hoisted so + * we we emit variable statement 'var' should be dropped. + */ + function isSourceFileLevelDeclarationInSystemJsModule(node, isExported) { + if (!node || languageVersion >= 2 /* ES6 */ || !isCurrentFileSystemExternalModule()) { + return false; + } + var current = node; + while (current) { + if (current.kind === 248 /* SourceFile */) { + return !isExported || ((ts.getCombinedNodeFlags(node) & 1 /* Export */) !== 0); + } + else if (ts.isFunctionLike(current) || current.kind === 219 /* ModuleBlock */) { + return false; + } + else { + current = current.parent; + } + } + } + /** + * Emit ES7 exponentiation operator downlevel using Math.pow + * @param node a binary expression node containing exponentiationOperator (**, **=) + */ + function emitExponentiationOperator(node) { + var leftHandSideExpression = node.left; + if (node.operatorToken.kind === 60 /* AsteriskAsteriskEqualsToken */) { + var synthesizedLHS; + var shouldEmitParentheses = false; + if (ts.isElementAccessExpression(leftHandSideExpression)) { + shouldEmitParentheses = true; + write("("); + synthesizedLHS = ts.createSynthesizedNode(167 /* ElementAccessExpression */, /*startsOnNewLine*/ false); + var identifier = emitTempVariableAssignment(leftHandSideExpression.expression, /*canDefinedTempVariablesInPlaces*/ false, /*shouldEmitCommaBeforeAssignment*/ false); + synthesizedLHS.expression = identifier; + if (leftHandSideExpression.argumentExpression.kind !== 8 /* NumericLiteral */ && + leftHandSideExpression.argumentExpression.kind !== 9 /* StringLiteral */) { + var tempArgumentExpression = createAndRecordTempVariable(268435456 /* _i */); + synthesizedLHS.argumentExpression = tempArgumentExpression; + emitAssignment(tempArgumentExpression, leftHandSideExpression.argumentExpression, /*shouldEmitCommaBeforeAssignment*/ true); + } + else { + synthesizedLHS.argumentExpression = leftHandSideExpression.argumentExpression; + } + write(", "); + } + else if (ts.isPropertyAccessExpression(leftHandSideExpression)) { + shouldEmitParentheses = true; + write("("); + synthesizedLHS = ts.createSynthesizedNode(166 /* PropertyAccessExpression */, /*startsOnNewLine*/ false); + var identifier = emitTempVariableAssignment(leftHandSideExpression.expression, /*canDefinedTempVariablesInPlaces*/ false, /*shouldemitCommaBeforeAssignment*/ false); + synthesizedLHS.expression = identifier; + synthesizedLHS.dotToken = leftHandSideExpression.dotToken; + synthesizedLHS.name = leftHandSideExpression.name; + write(", "); + } + emit(synthesizedLHS || leftHandSideExpression); + write(" = "); + write("Math.pow("); + emit(synthesizedLHS || leftHandSideExpression); + write(", "); + emit(node.right); + write(")"); + if (shouldEmitParentheses) { + write(")"); + } + } + else { + write("Math.pow("); + emit(leftHandSideExpression); + write(", "); + emit(node.right); + write(")"); + } + } + function emitBinaryExpression(node) { + if (languageVersion < 2 /* ES6 */ && node.operatorToken.kind === 56 /* EqualsToken */ && + (node.left.kind === 165 /* ObjectLiteralExpression */ || node.left.kind === 164 /* ArrayLiteralExpression */)) { + emitDestructuring(node, node.parent.kind === 195 /* ExpressionStatement */); + } + else { + var exportChanged = node.operatorToken.kind >= 56 /* FirstAssignment */ && + node.operatorToken.kind <= 68 /* LastAssignment */ && + isNameOfExportedSourceLevelDeclarationInSystemExternalModule(node.left); + if (exportChanged) { + // emit assignment 'x y' as 'exports("x", x y)' + write(exportFunctionForFile + "(\""); + emitNodeWithoutSourceMap(node.left); + write("\", "); + } + if (node.operatorToken.kind === 38 /* AsteriskAsteriskToken */ || node.operatorToken.kind === 60 /* AsteriskAsteriskEqualsToken */) { + // Downleveled emit exponentiation operator using Math.pow + emitExponentiationOperator(node); + } + else { + emit(node.left); + // Add indentation before emit the operator if the operator is on different line + // For example: + // 3 + // + 2; + // emitted as + // 3 + // + 2; + var indentedBeforeOperator = indentIfOnDifferentLines(node, node.left, node.operatorToken, node.operatorToken.kind !== 24 /* CommaToken */ ? " " : undefined); + write(ts.tokenToString(node.operatorToken.kind)); + var indentedAfterOperator = indentIfOnDifferentLines(node, node.operatorToken, node.right, " "); + emit(node.right); + decreaseIndentIf(indentedBeforeOperator, indentedAfterOperator); + } + if (exportChanged) { + write(")"); + } + } + } + function synthesizedNodeStartsOnNewLine(node) { + return ts.nodeIsSynthesized(node) && node.startsOnNewLine; + } + function emitConditionalExpression(node) { + emit(node.condition); + var indentedBeforeQuestion = indentIfOnDifferentLines(node, node.condition, node.questionToken, " "); + write("?"); + var indentedAfterQuestion = indentIfOnDifferentLines(node, node.questionToken, node.whenTrue, " "); + emit(node.whenTrue); + decreaseIndentIf(indentedBeforeQuestion, indentedAfterQuestion); + var indentedBeforeColon = indentIfOnDifferentLines(node, node.whenTrue, node.colonToken, " "); + write(":"); + var indentedAfterColon = indentIfOnDifferentLines(node, node.colonToken, node.whenFalse, " "); + emit(node.whenFalse); + decreaseIndentIf(indentedBeforeColon, indentedAfterColon); + } + // Helper function to decrease the indent if we previously indented. Allows multiple + // previous indent values to be considered at a time. This also allows caller to just + // call this once, passing in all their appropriate indent values, instead of needing + // to call this helper function multiple times. + function decreaseIndentIf(value1, value2) { + if (value1) { + decreaseIndent(); + } + if (value2) { + decreaseIndent(); + } + } + function isSingleLineEmptyBlock(node) { + if (node && node.kind === 192 /* Block */) { + var block = node; + return block.statements.length === 0 && nodeEndIsOnSameLineAsNodeStart(block, block); + } + } + function emitBlock(node) { + if (isSingleLineEmptyBlock(node)) { + emitToken(15 /* OpenBraceToken */, node.pos); + write(" "); + emitToken(16 /* CloseBraceToken */, node.statements.end); + return; + } + emitToken(15 /* OpenBraceToken */, node.pos); + increaseIndent(); + scopeEmitStart(node.parent); + if (node.kind === 219 /* ModuleBlock */) { + ts.Debug.assert(node.parent.kind === 218 /* ModuleDeclaration */); + emitCaptureThisForNodeIfNecessary(node.parent); + } + emitLines(node.statements); + if (node.kind === 219 /* ModuleBlock */) { + emitTempDeclarations(/*newLine*/ true); + } + decreaseIndent(); + writeLine(); + emitToken(16 /* CloseBraceToken */, node.statements.end); + scopeEmitEnd(); + } + function emitEmbeddedStatement(node) { + if (node.kind === 192 /* Block */) { + write(" "); + emit(node); + } + else { + increaseIndent(); + writeLine(); + emit(node); + decreaseIndent(); + } + } + function emitExpressionStatement(node) { + emitParenthesizedIf(node.expression, /*parenthesized*/ node.expression.kind === 174 /* ArrowFunction */); + write(";"); + } + function emitIfStatement(node) { + var endPos = emitToken(88 /* IfKeyword */, node.pos); + write(" "); + endPos = emitToken(17 /* OpenParenToken */, endPos); + emit(node.expression); + emitToken(18 /* CloseParenToken */, node.expression.end); + emitEmbeddedStatement(node.thenStatement); + if (node.elseStatement) { + writeLine(); + emitToken(80 /* ElseKeyword */, node.thenStatement.end); + if (node.elseStatement.kind === 196 /* IfStatement */) { + write(" "); + emit(node.elseStatement); + } + else { + emitEmbeddedStatement(node.elseStatement); + } + } + } + function emitDoStatement(node) { + write("do"); + emitEmbeddedStatement(node.statement); + if (node.statement.kind === 192 /* Block */) { + write(" "); + } + else { + writeLine(); + } + write("while ("); + emit(node.expression); + write(");"); + } + function emitWhileStatement(node) { + write("while ("); + emit(node.expression); + write(")"); + emitEmbeddedStatement(node.statement); + } + /** + * Returns true if start of variable declaration list was emitted. + * Returns false if nothing was written - this can happen for source file level variable declarations + * in system modules where such variable declarations are hoisted. + */ + function tryEmitStartOfVariableDeclarationList(decl, startPos) { + if (shouldHoistVariable(decl, /*checkIfSourceFileLevelDecl*/ true)) { + // variables in variable declaration list were already hoisted + return false; + } + var tokenKind = 102 /* VarKeyword */; + if (decl && languageVersion >= 2 /* ES6 */) { + if (ts.isLet(decl)) { + tokenKind = 108 /* LetKeyword */; + } + else if (ts.isConst(decl)) { + tokenKind = 74 /* ConstKeyword */; + } + } + if (startPos !== undefined) { + emitToken(tokenKind, startPos); + write(" "); + } + else { + switch (tokenKind) { + case 102 /* VarKeyword */: + write("var "); + break; + case 108 /* LetKeyword */: + write("let "); + break; + case 74 /* ConstKeyword */: + write("const "); + break; + } + } + return true; + } + function emitVariableDeclarationListSkippingUninitializedEntries(list) { + var started = false; + for (var _a = 0, _b = list.declarations; _a < _b.length; _a++) { + var decl = _b[_a]; + if (!decl.initializer) { + continue; + } + if (!started) { + started = true; + } + else { + write(", "); + } + emit(decl); + } + return started; + } + function emitForStatement(node) { + var endPos = emitToken(86 /* ForKeyword */, node.pos); + write(" "); + endPos = emitToken(17 /* OpenParenToken */, endPos); + if (node.initializer && node.initializer.kind === 212 /* VariableDeclarationList */) { + var variableDeclarationList = node.initializer; + var startIsEmitted = tryEmitStartOfVariableDeclarationList(variableDeclarationList, endPos); + if (startIsEmitted) { + emitCommaList(variableDeclarationList.declarations); + } + else { + emitVariableDeclarationListSkippingUninitializedEntries(variableDeclarationList); + } + } + else if (node.initializer) { + emit(node.initializer); + } + write(";"); + emitOptional(" ", node.condition); + write(";"); + emitOptional(" ", node.incrementor); + write(")"); + emitEmbeddedStatement(node.statement); + } + function emitForInOrForOfStatement(node) { + if (languageVersion < 2 /* ES6 */ && node.kind === 201 /* ForOfStatement */) { + return emitDownLevelForOfStatement(node); + } + var endPos = emitToken(86 /* ForKeyword */, node.pos); + write(" "); + endPos = emitToken(17 /* OpenParenToken */, endPos); + if (node.initializer.kind === 212 /* VariableDeclarationList */) { + var variableDeclarationList = node.initializer; + if (variableDeclarationList.declarations.length >= 1) { + tryEmitStartOfVariableDeclarationList(variableDeclarationList, endPos); + emit(variableDeclarationList.declarations[0]); + } + } + else { + emit(node.initializer); + } + if (node.kind === 200 /* ForInStatement */) { + write(" in "); + } + else { + write(" of "); + } + emit(node.expression); + emitToken(18 /* CloseParenToken */, node.expression.end); + emitEmbeddedStatement(node.statement); + } + function emitDownLevelForOfStatement(node) { + // The following ES6 code: + // + // for (let v of expr) { } + // + // should be emitted as + // + // for (let _i = 0, _a = expr; _i < _a.length; _i++) { + // let v = _a[_i]; + // } + // + // where _a and _i are temps emitted to capture the RHS and the counter, + // respectively. + // When the left hand side is an expression instead of a let declaration, + // the "let v" is not emitted. + // When the left hand side is a let/const, the v is renamed if there is + // another v in scope. + // Note that all assignments to the LHS are emitted in the body, including + // all destructuring. + // Note also that because an extra statement is needed to assign to the LHS, + // for-of bodies are always emitted as blocks. + var endPos = emitToken(86 /* ForKeyword */, node.pos); + write(" "); + endPos = emitToken(17 /* OpenParenToken */, endPos); + // Do not emit the LHS let declaration yet, because it might contain destructuring. + // Do not call recordTempDeclaration because we are declaring the temps + // right here. Recording means they will be declared later. + // 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 rhsIsIdentifier = node.expression.kind === 69 /* Identifier */; + var counter = createTempVariable(268435456 /* _i */); + var rhsReference = rhsIsIdentifier ? node.expression : createTempVariable(0 /* Auto */); + // This is the let keyword for the counter and rhsReference. The let keyword for + // the LHS will be emitted inside the body. + emitStart(node.expression); + write("var "); + // _i = 0 + emitNodeWithoutSourceMap(counter); + write(" = 0"); + emitEnd(node.expression); + if (!rhsIsIdentifier) { + // , _a = expr + write(", "); + emitStart(node.expression); + emitNodeWithoutSourceMap(rhsReference); + write(" = "); + emitNodeWithoutSourceMap(node.expression); + emitEnd(node.expression); + } + write("; "); + // _i < _a.length; + emitStart(node.initializer); + emitNodeWithoutSourceMap(counter); + write(" < "); + emitNodeWithCommentsAndWithoutSourcemap(rhsReference); + write(".length"); + emitEnd(node.initializer); + write("; "); + // _i++) + emitStart(node.initializer); + emitNodeWithoutSourceMap(counter); + write("++"); + emitEnd(node.initializer); + emitToken(18 /* CloseParenToken */, node.expression.end); + // Body + write(" {"); + writeLine(); + increaseIndent(); + // Initialize LHS + // let v = _a[_i]; + var rhsIterationValue = createElementAccessExpression(rhsReference, counter); + emitStart(node.initializer); + if (node.initializer.kind === 212 /* VariableDeclarationList */) { + write("var "); + var variableDeclarationList = node.initializer; + if (variableDeclarationList.declarations.length > 0) { + var declaration = variableDeclarationList.declarations[0]; + if (ts.isBindingPattern(declaration.name)) { + // This works whether the declaration is a var, let, or const. + // It will use rhsIterationValue _a[_i] as the initializer. + emitDestructuring(declaration, /*isAssignmentExpressionStatement*/ false, rhsIterationValue); + } + else { + // The following call does not include the initializer, so we have + // to emit it separately. + emitNodeWithCommentsAndWithoutSourcemap(declaration); + write(" = "); + emitNodeWithoutSourceMap(rhsIterationValue); + } + } + else { + // It's an empty declaration list. This can only happen in an error case, if the user wrote + // for (let of []) {} + emitNodeWithoutSourceMap(createTempVariable(0 /* Auto */)); + write(" = "); + emitNodeWithoutSourceMap(rhsIterationValue); + } + } + else { + // Initializer is an expression. Emit the expression in the body, so that it's + // evaluated on every iteration. + var assignmentExpression = createBinaryExpression(node.initializer, 56 /* EqualsToken */, rhsIterationValue, /*startsOnNewLine*/ false); + if (node.initializer.kind === 164 /* ArrayLiteralExpression */ || node.initializer.kind === 165 /* ObjectLiteralExpression */) { + // This is a destructuring pattern, so call emitDestructuring instead of emit. Calling emit will not work, because it will cause + // the BinaryExpression to be passed in instead of the expression statement, which will cause emitDestructuring to crash. + emitDestructuring(assignmentExpression, /*isAssignmentExpressionStatement*/ true, /*value*/ undefined); + } + else { + emitNodeWithCommentsAndWithoutSourcemap(assignmentExpression); + } + } + emitEnd(node.initializer); + write(";"); + if (node.statement.kind === 192 /* Block */) { + emitLines(node.statement.statements); + } + else { + writeLine(); + emit(node.statement); + } + writeLine(); + decreaseIndent(); + write("}"); + } + function emitBreakOrContinueStatement(node) { + emitToken(node.kind === 203 /* BreakStatement */ ? 70 /* BreakKeyword */ : 75 /* ContinueKeyword */, node.pos); + emitOptional(" ", node.label); + write(";"); + } + function emitReturnStatement(node) { + emitToken(94 /* ReturnKeyword */, node.pos); + emitOptional(" ", node.expression); + write(";"); + } + function emitWithStatement(node) { + write("with ("); + emit(node.expression); + write(")"); + emitEmbeddedStatement(node.statement); + } + function emitSwitchStatement(node) { + var endPos = emitToken(96 /* SwitchKeyword */, node.pos); + write(" "); + emitToken(17 /* OpenParenToken */, endPos); + emit(node.expression); + endPos = emitToken(18 /* CloseParenToken */, node.expression.end); + write(" "); + emitCaseBlock(node.caseBlock, endPos); + } + function emitCaseBlock(node, startPos) { + emitToken(15 /* OpenBraceToken */, startPos); + increaseIndent(); + emitLines(node.clauses); + decreaseIndent(); + writeLine(); + emitToken(16 /* CloseBraceToken */, node.clauses.end); + } + function nodeStartPositionsAreOnSameLine(node1, node2) { + return ts.getLineOfLocalPosition(currentSourceFile, ts.skipTrivia(currentSourceFile.text, node1.pos)) === + ts.getLineOfLocalPosition(currentSourceFile, ts.skipTrivia(currentSourceFile.text, node2.pos)); + } + function nodeEndPositionsAreOnSameLine(node1, node2) { + return ts.getLineOfLocalPosition(currentSourceFile, node1.end) === + ts.getLineOfLocalPosition(currentSourceFile, node2.end); + } + function nodeEndIsOnSameLineAsNodeStart(node1, node2) { + return ts.getLineOfLocalPosition(currentSourceFile, node1.end) === + ts.getLineOfLocalPosition(currentSourceFile, ts.skipTrivia(currentSourceFile.text, node2.pos)); + } + function emitCaseOrDefaultClause(node) { + if (node.kind === 241 /* CaseClause */) { + write("case "); + emit(node.expression); + write(":"); + } + else { + write("default:"); + } + if (node.statements.length === 1 && nodeStartPositionsAreOnSameLine(node, node.statements[0])) { + write(" "); + emit(node.statements[0]); + } + else { + increaseIndent(); + emitLines(node.statements); + decreaseIndent(); + } + } + function emitThrowStatement(node) { + write("throw "); + emit(node.expression); + write(";"); + } + function emitTryStatement(node) { + write("try "); + emit(node.tryBlock); + emit(node.catchClause); + if (node.finallyBlock) { + writeLine(); + write("finally "); + emit(node.finallyBlock); + } + } + function emitCatchClause(node) { + writeLine(); + var endPos = emitToken(72 /* CatchKeyword */, node.pos); + write(" "); + emitToken(17 /* OpenParenToken */, endPos); + emit(node.variableDeclaration); + emitToken(18 /* CloseParenToken */, node.variableDeclaration ? node.variableDeclaration.end : endPos); + write(" "); + emitBlock(node.block); + } + function emitDebuggerStatement(node) { + emitToken(76 /* DebuggerKeyword */, node.pos); + write(";"); + } + function emitLabelledStatement(node) { + emit(node.label); + write(": "); + emit(node.statement); + } + function getContainingModule(node) { + do { + node = node.parent; + } while (node && node.kind !== 218 /* ModuleDeclaration */); + return node; + } + function emitContainingModuleName(node) { + var container = getContainingModule(node); + write(container ? getGeneratedNameForNode(container) : "exports"); + } + function emitModuleMemberName(node) { + emitStart(node.name); + if (ts.getCombinedNodeFlags(node) & 1 /* Export */) { + var container = getContainingModule(node); + if (container) { + write(getGeneratedNameForNode(container)); + write("."); + } + else if (modulekind !== 5 /* ES6 */ && modulekind !== 4 /* System */) { + write("exports."); + } + } + emitNodeWithCommentsAndWithoutSourcemap(node.name); + emitEnd(node.name); + } + function createVoidZero() { + var zero = ts.createSynthesizedNode(8 /* NumericLiteral */); + zero.text = "0"; + var result = ts.createSynthesizedNode(177 /* VoidExpression */); + result.expression = zero; + return result; + } + function emitEs6ExportDefaultCompat(node) { + if (node.parent.kind === 248 /* SourceFile */) { + ts.Debug.assert(!!(node.flags & 1024 /* Default */) || node.kind === 227 /* ExportAssignment */); + // only allow export default at a source file level + if (modulekind === 1 /* CommonJS */ || modulekind === 2 /* AMD */ || modulekind === 3 /* UMD */) { + if (!currentSourceFile.symbol.exports["___esModule"]) { + if (languageVersion === 1 /* ES5 */) { + // default value of configurable, enumerable, writable are `false`. + write("Object.defineProperty(exports, \"__esModule\", { value: true });"); + writeLine(); + } + else if (languageVersion === 0 /* ES3 */) { + write("exports.__esModule = true;"); + writeLine(); + } + } + } + } + } + function emitExportMemberAssignment(node) { + if (node.flags & 1 /* Export */) { + writeLine(); + emitStart(node); + // emit call to exporter only for top level nodes + if (modulekind === 4 /* System */ && node.parent === currentSourceFile) { + // emit export default as + // export("default", ) + write(exportFunctionForFile + "(\""); + if (node.flags & 1024 /* Default */) { + write("default"); + } + else { + emitNodeWithCommentsAndWithoutSourcemap(node.name); + } + write("\", "); + emitDeclarationName(node); + write(")"); + } + else { + if (node.flags & 1024 /* Default */) { + emitEs6ExportDefaultCompat(node); + if (languageVersion === 0 /* ES3 */) { + write("exports[\"default\"]"); + } + else { + write("exports.default"); + } + } + else { + emitModuleMemberName(node); + } + write(" = "); + emitDeclarationName(node); + } + emitEnd(node); + write(";"); + } + } + function emitExportMemberAssignments(name) { + if (modulekind === 4 /* System */) { + return; + } + if (!exportEquals && exportSpecifiers && ts.hasProperty(exportSpecifiers, name.text)) { + for (var _a = 0, _b = exportSpecifiers[name.text]; _a < _b.length; _a++) { + var specifier = _b[_a]; + writeLine(); + emitStart(specifier.name); + emitContainingModuleName(specifier); + write("."); + emitNodeWithCommentsAndWithoutSourcemap(specifier.name); + emitEnd(specifier.name); + write(" = "); + emitExpressionIdentifier(name); + write(";"); + } + } + } + function emitExportSpecifierInSystemModule(specifier) { + ts.Debug.assert(modulekind === 4 /* System */); + if (!resolver.getReferencedValueDeclaration(specifier.propertyName || specifier.name) && !resolver.isValueAliasDeclaration(specifier)) { + return; + } + writeLine(); + emitStart(specifier.name); + write(exportFunctionForFile + "(\""); + emitNodeWithCommentsAndWithoutSourcemap(specifier.name); + write("\", "); + emitExpressionIdentifier(specifier.propertyName || specifier.name); + write(")"); + emitEnd(specifier.name); + write(";"); + } + /** + * Emit an assignment to a given identifier, 'name', with a given expression, 'value'. + * @param name an identifier as a left-hand-side operand of the assignment + * @param value an expression as a right-hand-side operand of the assignment + * @param shouldEmitCommaBeforeAssignment a boolean indicating whether to prefix an assignment with comma + */ + function emitAssignment(name, value, shouldEmitCommaBeforeAssignment) { + if (shouldEmitCommaBeforeAssignment) { + write(", "); + } + var exportChanged = isNameOfExportedSourceLevelDeclarationInSystemExternalModule(name); + if (exportChanged) { + write(exportFunctionForFile + "(\""); + emitNodeWithCommentsAndWithoutSourcemap(name); + write("\", "); + } + var isVariableDeclarationOrBindingElement = name.parent && (name.parent.kind === 211 /* VariableDeclaration */ || name.parent.kind === 163 /* BindingElement */); + if (isVariableDeclarationOrBindingElement) { + emitModuleMemberName(name.parent); + } + else { + emit(name); + } + write(" = "); + emit(value); + if (exportChanged) { + write(")"); + } + } + /** + * Create temporary variable, emit an assignment of the variable the given expression + * @param expression an expression to assign to the newly created temporary variable + * @param canDefineTempVariablesInPlace a boolean indicating whether you can define the temporary variable at an assignment location + * @param shouldEmitCommaBeforeAssignment a boolean indicating whether an assignment should prefix with comma + */ + function emitTempVariableAssignment(expression, canDefineTempVariablesInPlace, shouldEmitCommaBeforeAssignment) { + var identifier = createTempVariable(0 /* Auto */); + if (!canDefineTempVariablesInPlace) { + recordTempDeclaration(identifier); + } + emitAssignment(identifier, expression, shouldEmitCommaBeforeAssignment); + return identifier; + } + function emitDestructuring(root, isAssignmentExpressionStatement, value) { + var emitCount = 0; + // An exported declaration is actually emitted as an assignment (to a property on the module object), so + // temporary variables in an exported declaration need to have real declarations elsewhere + // Also temporary variables should be explicitly allocated for source level declarations when module target is system + // because actual variable declarations are hoisted + var canDefineTempVariablesInPlace = false; + if (root.kind === 211 /* VariableDeclaration */) { + var isExported = ts.getCombinedNodeFlags(root) & 1 /* Export */; + var isSourceLevelForSystemModuleKind = shouldHoistDeclarationInSystemJsModule(root); + canDefineTempVariablesInPlace = !isExported && !isSourceLevelForSystemModuleKind; + } + else if (root.kind === 138 /* Parameter */) { + canDefineTempVariablesInPlace = true; + } + if (root.kind === 181 /* BinaryExpression */) { + emitAssignmentExpression(root); + } + else { + ts.Debug.assert(!isAssignmentExpressionStatement); + emitBindingElement(root, value); + } + /** + * Ensures that there exists a declared identifier whose value holds the given expression. + * This function is useful to ensure that the expression's value can be read from in subsequent expressions. + * Unless 'reuseIdentifierExpressions' is false, 'expr' will be returned if it is just an identifier. + * + * @param expr the expression whose value needs to be bound. + * @param reuseIdentifierExpressions true if identifier expressions can simply be returned; + * false if it is necessary to always emit an identifier. + */ + function ensureIdentifier(expr, reuseIdentifierExpressions) { + if (expr.kind === 69 /* Identifier */ && reuseIdentifierExpressions) { + return expr; + } + var identifier = emitTempVariableAssignment(expr, canDefineTempVariablesInPlace, emitCount > 0); + emitCount++; + return identifier; + } + function createDefaultValueCheck(value, defaultValue) { + // The value expression will be evaluated twice, so for anything but a simple identifier + // we need to generate a temporary variable + value = ensureIdentifier(value, /*reuseIdentifierExpressions*/ true); + // Return the expression 'value === void 0 ? defaultValue : value' + var equals = ts.createSynthesizedNode(181 /* BinaryExpression */); + equals.left = value; + equals.operatorToken = ts.createSynthesizedNode(32 /* EqualsEqualsEqualsToken */); + equals.right = createVoidZero(); + return createConditionalExpression(equals, defaultValue, value); + } + function createConditionalExpression(condition, whenTrue, whenFalse) { + var cond = ts.createSynthesizedNode(182 /* ConditionalExpression */); + cond.condition = condition; + cond.questionToken = ts.createSynthesizedNode(53 /* QuestionToken */); + cond.whenTrue = whenTrue; + cond.colonToken = ts.createSynthesizedNode(54 /* ColonToken */); + cond.whenFalse = whenFalse; + return cond; + } + function createNumericLiteral(value) { + var node = ts.createSynthesizedNode(8 /* NumericLiteral */); + node.text = "" + value; + return node; + } + function createPropertyAccessForDestructuringProperty(object, propName) { + // We create a synthetic copy of the identifier in order to avoid the rewriting that might + // otherwise occur when the identifier is emitted. + var syntheticName = ts.createSynthesizedNode(propName.kind); + syntheticName.text = propName.text; + if (syntheticName.kind !== 69 /* Identifier */) { + return createElementAccessExpression(object, syntheticName); + } + return createPropertyAccessExpression(object, syntheticName); + } + function createSliceCall(value, sliceIndex) { + var call = ts.createSynthesizedNode(168 /* CallExpression */); + var sliceIdentifier = ts.createSynthesizedNode(69 /* Identifier */); + sliceIdentifier.text = "slice"; + call.expression = createPropertyAccessExpression(value, sliceIdentifier); + call.arguments = ts.createSynthesizedNodeArray(); + call.arguments[0] = createNumericLiteral(sliceIndex); + return call; + } + function emitObjectLiteralAssignment(target, value) { + var properties = target.properties; + if (properties.length !== 1) { + // For anything but a single element destructuring we need to generate a temporary + // to ensure value is evaluated exactly once. + value = ensureIdentifier(value, /*reuseIdentifierExpressions*/ true); + } + for (var _a = 0; _a < properties.length; _a++) { + var p = properties[_a]; + if (p.kind === 245 /* PropertyAssignment */ || p.kind === 246 /* ShorthandPropertyAssignment */) { + var propName = p.name; + var target_1 = p.kind === 246 /* ShorthandPropertyAssignment */ ? p : p.initializer || propName; + emitDestructuringAssignment(target_1, createPropertyAccessForDestructuringProperty(value, propName)); + } + } + } + function emitArrayLiteralAssignment(target, value) { + var elements = target.elements; + if (elements.length !== 1) { + // For anything but a single element destructuring we need to generate a temporary + // to ensure value is evaluated exactly once. + value = ensureIdentifier(value, /*reuseIdentifierExpressions*/ true); + } + for (var i = 0; i < elements.length; i++) { + var e = elements[i]; + if (e.kind !== 187 /* OmittedExpression */) { + if (e.kind !== 185 /* SpreadElementExpression */) { + emitDestructuringAssignment(e, createElementAccessExpression(value, createNumericLiteral(i))); + } + else if (i === elements.length - 1) { + emitDestructuringAssignment(e.expression, createSliceCall(value, i)); + } + } + } + } + function emitDestructuringAssignment(target, value) { + if (target.kind === 246 /* ShorthandPropertyAssignment */) { + if (target.objectAssignmentInitializer) { + value = createDefaultValueCheck(value, target.objectAssignmentInitializer); + } + target = target.name; + } + else if (target.kind === 181 /* BinaryExpression */ && target.operatorToken.kind === 56 /* EqualsToken */) { + value = createDefaultValueCheck(value, target.right); + target = target.left; + } + if (target.kind === 165 /* ObjectLiteralExpression */) { + emitObjectLiteralAssignment(target, value); + } + else if (target.kind === 164 /* ArrayLiteralExpression */) { + emitArrayLiteralAssignment(target, value); + } + else { + emitAssignment(target, value, /*shouldEmitCommaBeforeAssignment*/ emitCount > 0); + emitCount++; + } + } + function emitAssignmentExpression(root) { + var target = root.left; + var value = root.right; + if (ts.isEmptyObjectLiteralOrArrayLiteral(target)) { + emit(value); + } + else if (isAssignmentExpressionStatement) { + emitDestructuringAssignment(target, value); + } + else { + if (root.parent.kind !== 172 /* ParenthesizedExpression */) { + write("("); + } + value = ensureIdentifier(value, /*reuseIdentifierExpressions*/ true); + emitDestructuringAssignment(target, value); + write(", "); + emit(value); + if (root.parent.kind !== 172 /* ParenthesizedExpression */) { + write(")"); + } + } + } + function emitBindingElement(target, value) { + if (target.initializer) { + // Combine value and initializer + value = value ? createDefaultValueCheck(value, target.initializer) : target.initializer; + } + else if (!value) { + // Use 'void 0' in absence of value and initializer + value = createVoidZero(); + } + if (ts.isBindingPattern(target.name)) { + var pattern = target.name; + var elements = pattern.elements; + var numElements = elements.length; + if (numElements !== 1) { + // For anything other than a single-element destructuring we need to generate a temporary + // to ensure value is evaluated exactly once. Additionally, if we have zero elements + // we need to emit *something* to ensure that in case a 'var' keyword was already emitted, + // so in that case, we'll intentionally create that temporary. + value = ensureIdentifier(value, /*reuseIdentifierExpressions*/ numElements !== 0); + } + for (var i = 0; i < numElements; i++) { + var element = elements[i]; + if (pattern.kind === 161 /* ObjectBindingPattern */) { + // Rewrite element to a declaration with an initializer that fetches property + var propName = element.propertyName || element.name; + emitBindingElement(element, createPropertyAccessForDestructuringProperty(value, propName)); + } + else if (element.kind !== 187 /* OmittedExpression */) { + if (!element.dotDotDotToken) { + // Rewrite element to a declaration that accesses array element at index i + emitBindingElement(element, createElementAccessExpression(value, createNumericLiteral(i))); + } + else if (i === numElements - 1) { + emitBindingElement(element, createSliceCall(value, i)); + } + } + } + } + else { + emitAssignment(target.name, value, /*shouldEmitCommaBeforeAssignment*/ emitCount > 0); + emitCount++; + } + } + } + function emitVariableDeclaration(node) { + if (ts.isBindingPattern(node.name)) { + if (languageVersion < 2 /* ES6 */) { + emitDestructuring(node, /*isAssignmentExpressionStatement*/ false); + } + else { + emit(node.name); + emitOptional(" = ", node.initializer); + } + } + else { + var initializer = node.initializer; + if (!initializer && languageVersion < 2 /* ES6 */) { + // downlevel emit for non-initialized let bindings defined in loops + // for (...) { let x; } + // should be + // for (...) { var = void 0; } + // this is necessary to preserve ES6 semantic in scenarios like + // for (...) { let x; console.log(x); x = 1 } // assignment on one iteration should not affect other iterations + var isUninitializedLet = (resolver.getNodeCheckFlags(node) & 16384 /* BlockScopedBindingInLoop */) && + (getCombinedFlagsForIdentifier(node.name) & 16384 /* Let */); + // NOTE: default initialization should not be added to let bindings in for-in\for-of statements + if (isUninitializedLet && + node.parent.parent.kind !== 200 /* ForInStatement */ && + node.parent.parent.kind !== 201 /* ForOfStatement */) { + initializer = createVoidZero(); + } + } + var exportChanged = isNameOfExportedSourceLevelDeclarationInSystemExternalModule(node.name); + if (exportChanged) { + write(exportFunctionForFile + "(\""); + emitNodeWithCommentsAndWithoutSourcemap(node.name); + write("\", "); + } + emitModuleMemberName(node); + emitOptional(" = ", initializer); + if (exportChanged) { + write(")"); + } + } + } + function emitExportVariableAssignments(node) { + if (node.kind === 187 /* OmittedExpression */) { + return; + } + var name = node.name; + if (name.kind === 69 /* Identifier */) { + emitExportMemberAssignments(name); + } + else if (ts.isBindingPattern(name)) { + ts.forEach(name.elements, emitExportVariableAssignments); + } + } + function getCombinedFlagsForIdentifier(node) { + if (!node.parent || (node.parent.kind !== 211 /* VariableDeclaration */ && node.parent.kind !== 163 /* BindingElement */)) { + return 0; + } + return ts.getCombinedNodeFlags(node.parent); + } + function isES6ExportedDeclaration(node) { + return !!(node.flags & 1 /* Export */) && + modulekind === 5 /* ES6 */ && + node.parent.kind === 248 /* SourceFile */; + } + function emitVariableStatement(node) { + var startIsEmitted = false; + if (node.flags & 1 /* Export */) { + if (isES6ExportedDeclaration(node)) { + // Exported ES6 module member + write("export "); + startIsEmitted = tryEmitStartOfVariableDeclarationList(node.declarationList); + } + } + else { + startIsEmitted = tryEmitStartOfVariableDeclarationList(node.declarationList); + } + if (startIsEmitted) { + emitCommaList(node.declarationList.declarations); + write(";"); + } + else { + var atLeastOneItem = emitVariableDeclarationListSkippingUninitializedEntries(node.declarationList); + if (atLeastOneItem) { + write(";"); + } + } + if (modulekind !== 5 /* ES6 */ && node.parent === currentSourceFile) { + ts.forEach(node.declarationList.declarations, emitExportVariableAssignments); + } + } + function shouldEmitLeadingAndTrailingCommentsForVariableStatement(node) { + // If we're not exporting the variables, there's nothing special here. + // Always emit comments for these nodes. + if (!(node.flags & 1 /* Export */)) { + return true; + } + // If we are exporting, but it's a top-level ES6 module exports, + // we'll emit the declaration list verbatim, so emit comments too. + if (isES6ExportedDeclaration(node)) { + return true; + } + // Otherwise, only emit if we have at least one initializer present. + for (var _a = 0, _b = node.declarationList.declarations; _a < _b.length; _a++) { + var declaration = _b[_a]; + if (declaration.initializer) { + return true; + } + } + return false; + } + function emitParameter(node) { + if (languageVersion < 2 /* ES6 */) { + if (ts.isBindingPattern(node.name)) { + var name_24 = createTempVariable(0 /* Auto */); + if (!tempParameters) { + tempParameters = []; + } + tempParameters.push(name_24); + emit(name_24); + } + else { + emit(node.name); + } + } + else { + if (node.dotDotDotToken) { + write("..."); + } + emit(node.name); + emitOptional(" = ", node.initializer); + } + } + function emitDefaultValueAssignments(node) { + if (languageVersion < 2 /* ES6 */) { + var tempIndex = 0; + ts.forEach(node.parameters, function (parameter) { + // A rest parameter cannot have a binding pattern or an initializer, + // so let's just ignore it. + if (parameter.dotDotDotToken) { + return; + } + var paramName = parameter.name, initializer = parameter.initializer; + if (ts.isBindingPattern(paramName)) { + // 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. + var hasBindingElements = paramName.elements.length > 0; + if (hasBindingElements || initializer) { + writeLine(); + write("var "); + if (hasBindingElements) { + emitDestructuring(parameter, /*isAssignmentExpressionStatement*/ false, tempParameters[tempIndex]); + } + else { + emit(tempParameters[tempIndex]); + write(" = "); + emit(initializer); + } + write(";"); + tempIndex++; + } + } + else if (initializer) { + writeLine(); + emitStart(parameter); + write("if ("); + emitNodeWithoutSourceMap(paramName); + write(" === void 0)"); + emitEnd(parameter); + write(" { "); + emitStart(parameter); + emitNodeWithCommentsAndWithoutSourcemap(paramName); + write(" = "); + emitNodeWithCommentsAndWithoutSourcemap(initializer); + emitEnd(parameter); + write("; }"); + } + }); + } + } + function emitRestParameter(node) { + if (languageVersion < 2 /* ES6 */ && ts.hasRestParameter(node)) { + var restIndex = node.parameters.length - 1; + var restParam = node.parameters[restIndex]; + // A rest parameter cannot have a binding pattern, so let's just ignore it if it does. + if (ts.isBindingPattern(restParam.name)) { + return; + } + var tempName = createTempVariable(268435456 /* _i */).text; + writeLine(); + emitLeadingComments(restParam); + emitStart(restParam); + write("var "); + emitNodeWithCommentsAndWithoutSourcemap(restParam.name); + write(" = [];"); + emitEnd(restParam); + emitTrailingComments(restParam); + writeLine(); + write("for ("); + emitStart(restParam); + write("var " + tempName + " = " + restIndex + ";"); + emitEnd(restParam); + write(" "); + emitStart(restParam); + write(tempName + " < arguments.length;"); + emitEnd(restParam); + write(" "); + emitStart(restParam); + write(tempName + "++"); + emitEnd(restParam); + write(") {"); + increaseIndent(); + writeLine(); + emitStart(restParam); + emitNodeWithCommentsAndWithoutSourcemap(restParam.name); + write("[" + tempName + " - " + restIndex + "] = arguments[" + tempName + "];"); + emitEnd(restParam); + decreaseIndent(); + writeLine(); + write("}"); + } + } + function emitAccessor(node) { + write(node.kind === 145 /* GetAccessor */ ? "get " : "set "); + emit(node.name); + emitSignatureAndBody(node); + } + function shouldEmitAsArrowFunction(node) { + return node.kind === 174 /* ArrowFunction */ && languageVersion >= 2 /* ES6 */; + } + function emitDeclarationName(node) { + if (node.name) { + emitNodeWithCommentsAndWithoutSourcemap(node.name); + } + else { + write(getGeneratedNameForNode(node)); + } + } + function shouldEmitFunctionName(node) { + if (node.kind === 173 /* FunctionExpression */) { + // Emit name if one is present + return !!node.name; + } + if (node.kind === 213 /* FunctionDeclaration */) { + // Emit name if one is present, or emit generated name in down-level case (for export default case) + return !!node.name || languageVersion < 2 /* ES6 */; + } + } + function emitFunctionDeclaration(node) { + if (ts.nodeIsMissing(node.body)) { + return emitCommentsOnNotEmittedNode(node); + } + // TODO (yuisu) : we should not have special cases to condition emitting comments + // but have one place to fix check for these conditions. + if (node.kind !== 143 /* MethodDeclaration */ && node.kind !== 142 /* MethodSignature */ && + node.parent && node.parent.kind !== 245 /* PropertyAssignment */ && + node.parent.kind !== 168 /* CallExpression */) { + // 1. Methods will emit the comments as part of emitting method declaration + // 2. If the function is a property of object literal, emitting leading-comments + // is done by emitNodeWithoutSourceMap which then call this function. + // In particular, we would like to avoid emit comments twice in following case: + // For example: + // var obj = { + // id: + // /*comment*/ () => void + // } + // 3. If the function is an argument in call expression, emitting of comments will be + // taken care of in emit list of arguments inside of emitCallexpression + emitLeadingComments(node); + } + emitStart(node); + // For targeting below es6, emit functions-like declaration including arrow function using function keyword. + // When targeting ES6, emit arrow function natively in ES6 by omitting function keyword and using fat arrow instead + if (!shouldEmitAsArrowFunction(node)) { + if (isES6ExportedDeclaration(node)) { + write("export "); + if (node.flags & 1024 /* Default */) { + write("default "); + } + } + write("function"); + if (languageVersion >= 2 /* ES6 */ && node.asteriskToken) { + write("*"); + } + write(" "); + } + if (shouldEmitFunctionName(node)) { + emitDeclarationName(node); + } + emitSignatureAndBody(node); + if (modulekind !== 5 /* ES6 */ && node.kind === 213 /* FunctionDeclaration */ && node.parent === currentSourceFile && node.name) { + emitExportMemberAssignments(node.name); + } + emitEnd(node); + if (node.kind !== 143 /* MethodDeclaration */ && node.kind !== 142 /* MethodSignature */) { + emitTrailingComments(node); + } + } + function emitCaptureThisForNodeIfNecessary(node) { + if (resolver.getNodeCheckFlags(node) & 4 /* CaptureThis */) { + writeLine(); + emitStart(node); + write("var _this = this;"); + emitEnd(node); + } + } + function emitSignatureParameters(node) { + increaseIndent(); + write("("); + if (node) { + var parameters = node.parameters; + var omitCount = languageVersion < 2 /* ES6 */ && ts.hasRestParameter(node) ? 1 : 0; + emitList(parameters, 0, parameters.length - omitCount, /*multiLine*/ false, /*trailingComma*/ false); + } + write(")"); + decreaseIndent(); + } + function emitSignatureParametersForArrow(node) { + // Check whether the parameter list needs parentheses and preserve no-parenthesis + if (node.parameters.length === 1 && node.pos === node.parameters[0].pos) { + emit(node.parameters[0]); + return; + } + emitSignatureParameters(node); + } + function emitAsyncFunctionBodyForES6(node) { + var promiseConstructor = ts.getEntityNameFromTypeNode(node.type); + var isArrowFunction = node.kind === 174 /* ArrowFunction */; + var hasLexicalArguments = (resolver.getNodeCheckFlags(node) & 4096 /* CaptureArguments */) !== 0; + var args; + // 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. + // + // The emit for an async arrow without a lexical `arguments` binding might be: + // + // // input + // let a = async (b) => { await b; } + // + // // output + // let a = (b) => __awaiter(this, void 0, void 0, function* () { + // yield b; + // }); + // + // The emit for an async arrow with a lexical `arguments` binding might be: + // + // // input + // let a = async (b) => { await arguments[0]; } + // + // // output + // let a = (b) => __awaiter(this, arguments, void 0, function* (arguments) { + // yield arguments[0]; + // }); + // + // The emit for an async function expression without a lexical `arguments` binding + // might be: + // + // // input + // let a = async function (b) { + // await b; + // } + // + // // output + // let a = function (b) { + // return __awaiter(this, void 0, void 0, function* () { + // yield b; + // }); + // } + // + // The emit for an async function expression with a lexical `arguments` binding + // might be: + // + // // input + // let a = async function (b) { + // await arguments[0]; + // } + // + // // output + // let a = function (b) { + // return __awaiter(this, arguments, void 0, function* (_arguments) { + // yield _arguments[0]; + // }); + // } + // + // The emit for an async function expression with a lexical `arguments` binding + // and a return type annotation might be: + // + // // input + // let a = async function (b): MyPromise { + // await arguments[0]; + // } + // + // // output + // let a = function (b) { + // return __awaiter(this, arguments, MyPromise, function* (_arguments) { + // yield _arguments[0]; + // }); + // } + // + // If this is not an async arrow, emit the opening brace of the function body + // and the start of the return statement. + if (!isArrowFunction) { + write(" {"); + increaseIndent(); + writeLine(); + write("return"); + } + write(" __awaiter(this"); + if (hasLexicalArguments) { + write(", arguments"); + } + else { + write(", void 0"); + } + if (promiseConstructor) { + write(", "); + emitNodeWithoutSourceMap(promiseConstructor); + } + else { + write(", Promise"); + } + // Emit the call to __awaiter. + if (hasLexicalArguments) { + write(", function* (_arguments)"); + } + else { + write(", function* ()"); + } + // Emit the signature and body for the inner generator function. + emitFunctionBody(node); + write(")"); + // If this is not an async arrow, emit the closing brace of the outer function body. + if (!isArrowFunction) { + write(";"); + decreaseIndent(); + writeLine(); + write("}"); + } + } + function emitFunctionBody(node) { + if (!node.body) { + // There can be no body when there are parse errors. Just emit an empty block + // in that case. + write(" { }"); + } + else { + if (node.body.kind === 192 /* Block */) { + emitBlockFunctionBody(node, node.body); + } + else { + emitExpressionFunctionBody(node, node.body); + } + } + } + function emitSignatureAndBody(node) { + var saveTempFlags = tempFlags; + var saveTempVariables = tempVariables; + var saveTempParameters = tempParameters; + tempFlags = 0; + tempVariables = undefined; + tempParameters = undefined; + // When targeting ES6, emit arrow function natively in ES6 + if (shouldEmitAsArrowFunction(node)) { + emitSignatureParametersForArrow(node); + write(" =>"); + } + else { + emitSignatureParameters(node); + } + var isAsync = ts.isAsyncFunctionLike(node); + if (isAsync && languageVersion === 2 /* ES6 */) { + emitAsyncFunctionBodyForES6(node); + } + else { + emitFunctionBody(node); + } + if (!isES6ExportedDeclaration(node)) { + emitExportMemberAssignment(node); + } + tempFlags = saveTempFlags; + tempVariables = saveTempVariables; + tempParameters = saveTempParameters; + } + // Returns true if any preamble code was emitted. + function emitFunctionBodyPreamble(node) { + emitCaptureThisForNodeIfNecessary(node); + emitDefaultValueAssignments(node); + emitRestParameter(node); + } + function emitExpressionFunctionBody(node, body) { + if (languageVersion < 2 /* ES6 */ || node.flags & 512 /* Async */) { + emitDownLevelExpressionFunctionBody(node, body); + return; + } + // For es6 and higher we can emit the expression as is. However, in the case + // where the expression might end up looking like a block when emitted, we'll + // also wrap it in parentheses first. For example if you have: a => {} + // then we need to generate: a => ({}) + write(" "); + // Unwrap all type assertions. + var current = body; + while (current.kind === 171 /* TypeAssertionExpression */) { + current = current.expression; + } + emitParenthesizedIf(body, current.kind === 165 /* ObjectLiteralExpression */); + } + function emitDownLevelExpressionFunctionBody(node, body) { + write(" {"); + scopeEmitStart(node); + increaseIndent(); + var outPos = writer.getTextPos(); + emitDetachedComments(node.body); + emitFunctionBodyPreamble(node); + var preambleEmitted = writer.getTextPos() !== outPos; + decreaseIndent(); + // If we didn't have to emit any preamble code, then attempt to keep the arrow + // function on one line. + if (!preambleEmitted && nodeStartPositionsAreOnSameLine(node, body)) { + write(" "); + emitStart(body); + write("return "); + emit(body); + emitEnd(body); + write(";"); + emitTempDeclarations(/*newLine*/ false); + write(" "); + } + else { + increaseIndent(); + writeLine(); + emitLeadingComments(node.body); + write("return "); + emit(body); + write(";"); + emitTrailingComments(node.body); + emitTempDeclarations(/*newLine*/ true); + decreaseIndent(); + writeLine(); + } + emitStart(node.body); + write("}"); + emitEnd(node.body); + scopeEmitEnd(); + } + function emitBlockFunctionBody(node, body) { + write(" {"); + scopeEmitStart(node); + var initialTextPos = writer.getTextPos(); + increaseIndent(); + emitDetachedComments(body.statements); + // Emit all the directive prologues (like "use strict"). These have to come before + // any other preamble code we write (like parameter initializers). + var startIndex = emitDirectivePrologues(body.statements, /*startWithNewLine*/ true); + emitFunctionBodyPreamble(node); + decreaseIndent(); + var preambleEmitted = writer.getTextPos() !== initialTextPos; + if (!preambleEmitted && nodeEndIsOnSameLineAsNodeStart(body, body)) { + for (var _a = 0, _b = body.statements; _a < _b.length; _a++) { + var statement = _b[_a]; + write(" "); + emit(statement); + } + emitTempDeclarations(/*newLine*/ false); + write(" "); + emitLeadingCommentsOfPosition(body.statements.end); + } + else { + increaseIndent(); + emitLinesStartingAt(body.statements, startIndex); + emitTempDeclarations(/*newLine*/ true); + writeLine(); + emitLeadingCommentsOfPosition(body.statements.end); + decreaseIndent(); + } + emitToken(16 /* CloseBraceToken */, body.statements.end); + scopeEmitEnd(); + } + function findInitialSuperCall(ctor) { + if (ctor.body) { + var statement = ctor.body.statements[0]; + if (statement && statement.kind === 195 /* ExpressionStatement */) { + var expr = statement.expression; + if (expr && expr.kind === 168 /* CallExpression */) { + var func = expr.expression; + if (func && func.kind === 95 /* SuperKeyword */) { + return statement; + } + } + } + } + } + function emitParameterPropertyAssignments(node) { + ts.forEach(node.parameters, function (param) { + if (param.flags & 112 /* AccessibilityModifier */) { + writeLine(); + emitStart(param); + emitStart(param.name); + write("this."); + emitNodeWithoutSourceMap(param.name); + emitEnd(param.name); + write(" = "); + emit(param.name); + write(";"); + emitEnd(param); + } + }); + } + function emitMemberAccessForPropertyName(memberName) { + // This does not emit source map because it is emitted by caller as caller + // is aware how the property name changes to the property access + // eg. public x = 10; becomes this.x and static x = 10 becomes className.x + if (memberName.kind === 9 /* StringLiteral */ || memberName.kind === 8 /* NumericLiteral */) { + write("["); + emitNodeWithCommentsAndWithoutSourcemap(memberName); + write("]"); + } + else if (memberName.kind === 136 /* ComputedPropertyName */) { + emitComputedPropertyName(memberName); + } + else { + write("."); + emitNodeWithCommentsAndWithoutSourcemap(memberName); + } + } + function getInitializedProperties(node, isStatic) { + var properties = []; + for (var _a = 0, _b = node.members; _a < _b.length; _a++) { + var member = _b[_a]; + if (member.kind === 141 /* PropertyDeclaration */ && isStatic === ((member.flags & 128 /* Static */) !== 0) && member.initializer) { + properties.push(member); + } + } + return properties; + } + function emitPropertyDeclarations(node, properties) { + for (var _a = 0; _a < properties.length; _a++) { + var property = properties[_a]; + emitPropertyDeclaration(node, property); + } + } + function emitPropertyDeclaration(node, property, receiver, isExpression) { + writeLine(); + emitLeadingComments(property); + emitStart(property); + emitStart(property.name); + if (receiver) { + emit(receiver); + } + else { + if (property.flags & 128 /* Static */) { + emitDeclarationName(node); + } + else { + write("this"); + } + } + emitMemberAccessForPropertyName(property.name); + emitEnd(property.name); + write(" = "); + emit(property.initializer); + if (!isExpression) { + write(";"); + } + emitEnd(property); + emitTrailingComments(property); + } + function emitMemberFunctionsForES5AndLower(node) { + ts.forEach(node.members, function (member) { + if (member.kind === 191 /* SemicolonClassElement */) { + writeLine(); + write(";"); + } + else if (member.kind === 143 /* MethodDeclaration */ || node.kind === 142 /* MethodSignature */) { + if (!member.body) { + return emitCommentsOnNotEmittedNode(member); + } + writeLine(); + emitLeadingComments(member); + emitStart(member); + emitStart(member.name); + emitClassMemberPrefix(node, member); + emitMemberAccessForPropertyName(member.name); + emitEnd(member.name); + write(" = "); + emitFunctionDeclaration(member); + emitEnd(member); + write(";"); + emitTrailingComments(member); + } + else if (member.kind === 145 /* GetAccessor */ || member.kind === 146 /* SetAccessor */) { + var accessors = ts.getAllAccessorDeclarations(node.members, member); + if (member === accessors.firstAccessor) { + writeLine(); + emitStart(member); + write("Object.defineProperty("); + emitStart(member.name); + emitClassMemberPrefix(node, member); + write(", "); + emitExpressionForPropertyName(member.name); + emitEnd(member.name); + write(", {"); + increaseIndent(); + if (accessors.getAccessor) { + writeLine(); + emitLeadingComments(accessors.getAccessor); + write("get: "); + emitStart(accessors.getAccessor); + write("function "); + emitSignatureAndBody(accessors.getAccessor); + emitEnd(accessors.getAccessor); + emitTrailingComments(accessors.getAccessor); + write(","); + } + if (accessors.setAccessor) { + writeLine(); + emitLeadingComments(accessors.setAccessor); + write("set: "); + emitStart(accessors.setAccessor); + write("function "); + emitSignatureAndBody(accessors.setAccessor); + emitEnd(accessors.setAccessor); + emitTrailingComments(accessors.setAccessor); + write(","); + } + writeLine(); + write("enumerable: true,"); + writeLine(); + write("configurable: true"); + decreaseIndent(); + writeLine(); + write("});"); + emitEnd(member); + } + } + }); + } + function emitMemberFunctionsForES6AndHigher(node) { + for (var _a = 0, _b = node.members; _a < _b.length; _a++) { + var member = _b[_a]; + if ((member.kind === 143 /* MethodDeclaration */ || node.kind === 142 /* MethodSignature */) && !member.body) { + emitCommentsOnNotEmittedNode(member); + } + else if (member.kind === 143 /* MethodDeclaration */ || + member.kind === 145 /* GetAccessor */ || + member.kind === 146 /* SetAccessor */) { + writeLine(); + emitLeadingComments(member); + emitStart(member); + if (member.flags & 128 /* Static */) { + write("static "); + } + if (member.kind === 145 /* GetAccessor */) { + write("get "); + } + else if (member.kind === 146 /* SetAccessor */) { + write("set "); + } + if (member.asteriskToken) { + write("*"); + } + emit(member.name); + emitSignatureAndBody(member); + emitEnd(member); + emitTrailingComments(member); + } + else if (member.kind === 191 /* SemicolonClassElement */) { + writeLine(); + write(";"); + } + } + } + function emitConstructor(node, baseTypeElement) { + var saveTempFlags = tempFlags; + var saveTempVariables = tempVariables; + var saveTempParameters = tempParameters; + tempFlags = 0; + tempVariables = undefined; + tempParameters = undefined; + emitConstructorWorker(node, baseTypeElement); + tempFlags = saveTempFlags; + tempVariables = saveTempVariables; + tempParameters = saveTempParameters; + } + function emitConstructorWorker(node, baseTypeElement) { + // Check if we have property assignment inside class declaration. + // If there is property assignment, we need to emit constructor whether users define it or not + // If there is no property assignment, we can omit constructor if users do not define it + var hasInstancePropertyWithInitializer = false; + // Emit the constructor overload pinned comments + ts.forEach(node.members, function (member) { + if (member.kind === 144 /* Constructor */ && !member.body) { + emitCommentsOnNotEmittedNode(member); + } + // Check if there is any non-static property assignment + if (member.kind === 141 /* PropertyDeclaration */ && member.initializer && (member.flags & 128 /* Static */) === 0) { + hasInstancePropertyWithInitializer = true; + } + }); + var ctor = ts.getFirstConstructorWithBody(node); + // For target ES6 and above, if there is no user-defined constructor and there is no property assignment + // do not emit constructor in class declaration. + if (languageVersion >= 2 /* ES6 */ && !ctor && !hasInstancePropertyWithInitializer) { + return; + } + if (ctor) { + emitLeadingComments(ctor); + } + emitStart(ctor || node); + if (languageVersion < 2 /* ES6 */) { + write("function "); + emitDeclarationName(node); + emitSignatureParameters(ctor); + } + else { + write("constructor"); + if (ctor) { + emitSignatureParameters(ctor); + } + else { + // Based on EcmaScript6 section 14.5.14: Runtime Semantics: ClassDefinitionEvaluation. + // If constructor is empty, then, + // If ClassHeritageopt is present, then + // Let constructor be the result of parsing the String "constructor(... args){ super (...args);}" using the syntactic grammar with the goal symbol MethodDefinition. + // Else, + // Let constructor be the result of parsing the String "constructor( ){ }" using the syntactic grammar with the goal symbol MethodDefinition + if (baseTypeElement) { + write("(...args)"); + } + else { + write("()"); + } + } + } + var startIndex = 0; + write(" {"); + scopeEmitStart(node, "constructor"); + increaseIndent(); + if (ctor) { + // Emit all the directive prologues (like "use strict"). These have to come before + // any other preamble code we write (like parameter initializers). + startIndex = emitDirectivePrologues(ctor.body.statements, /*startWithNewLine*/ true); + emitDetachedComments(ctor.body.statements); + } + emitCaptureThisForNodeIfNecessary(node); + var superCall; + if (ctor) { + emitDefaultValueAssignments(ctor); + emitRestParameter(ctor); + if (baseTypeElement) { + superCall = findInitialSuperCall(ctor); + if (superCall) { + writeLine(); + emit(superCall); + } + } + emitParameterPropertyAssignments(ctor); + } + else { + if (baseTypeElement) { + writeLine(); + emitStart(baseTypeElement); + if (languageVersion < 2 /* ES6 */) { + write("_super.apply(this, arguments);"); + } + else { + write("super(...args);"); + } + emitEnd(baseTypeElement); + } + } + emitPropertyDeclarations(node, getInitializedProperties(node, /*static:*/ false)); + if (ctor) { + var statements = ctor.body.statements; + if (superCall) { + statements = statements.slice(1); + } + emitLinesStartingAt(statements, startIndex); + } + emitTempDeclarations(/*newLine*/ true); + writeLine(); + if (ctor) { + emitLeadingCommentsOfPosition(ctor.body.statements.end); + } + decreaseIndent(); + emitToken(16 /* CloseBraceToken */, ctor ? ctor.body.statements.end : node.members.end); + scopeEmitEnd(); + emitEnd(ctor || node); + if (ctor) { + emitTrailingComments(ctor); + } + } + function emitClassExpression(node) { + return emitClassLikeDeclaration(node); + } + function emitClassDeclaration(node) { + return emitClassLikeDeclaration(node); + } + function emitClassLikeDeclaration(node) { + if (languageVersion < 2 /* ES6 */) { + emitClassLikeDeclarationBelowES6(node); + } + else { + emitClassLikeDeclarationForES6AndHigher(node); + } + if (modulekind !== 5 /* ES6 */ && node.parent === currentSourceFile && node.name) { + emitExportMemberAssignments(node.name); + } + } + function emitClassLikeDeclarationForES6AndHigher(node) { + var thisNodeIsDecorated = ts.nodeIsDecorated(node); + if (node.kind === 214 /* ClassDeclaration */) { + if (thisNodeIsDecorated) { + // To preserve the correct runtime semantics when decorators are applied to the class, + // the emit needs to follow one of the following rules: + // + // * For a local class declaration: + // + // @dec class C { + // } + // + // The emit should be: + // + // let C = class { + // }; + // C = __decorate([dec], C); + // + // * For an exported class declaration: + // + // @dec export class C { + // } + // + // The emit should be: + // + // export let C = class { + // }; + // C = __decorate([dec], C); + // + // * For a default export of a class declaration with a name: + // + // @dec default export class C { + // } + // + // The emit should be: + // + // let C = class { + // } + // C = __decorate([dec], C); + // export default C; + // + // * For a default export of a class declaration without a name: + // + // @dec default export class { + // } + // + // The emit should be: + // + // let _default = class { + // } + // _default = __decorate([dec], _default); + // export default _default; + // + if (isES6ExportedDeclaration(node) && !(node.flags & 1024 /* Default */)) { + write("export "); + } + write("let "); + emitDeclarationName(node); + write(" = "); + } + else if (isES6ExportedDeclaration(node)) { + write("export "); + if (node.flags & 1024 /* Default */) { + write("default "); + } + } + } + // If the class has static properties, and it's a class expression, then we'll need + // to specialize the emit a bit. for a class expression of the form: + // + // class C { static a = 1; static b = 2; ... } + // + // We'll emit: + // + // (_temp = class C { ... }, _temp.a = 1, _temp.b = 2, _temp) + // + // This keeps the expression as an expression, while ensuring that the static parts + // of it have been initialized by the time it is used. + var staticProperties = getInitializedProperties(node, /*static:*/ true); + var isClassExpressionWithStaticProperties = staticProperties.length > 0 && node.kind === 186 /* ClassExpression */; + var tempVariable; + if (isClassExpressionWithStaticProperties) { + tempVariable = createAndRecordTempVariable(0 /* Auto */); + write("("); + increaseIndent(); + emit(tempVariable); + write(" = "); + } + write("class"); + // emit name if + // - node has a name + // - this is default export with static initializers + if ((node.name || (node.flags & 1024 /* Default */ && staticProperties.length > 0)) && !thisNodeIsDecorated) { + write(" "); + emitDeclarationName(node); + } + var baseTypeNode = ts.getClassExtendsHeritageClauseElement(node); + if (baseTypeNode) { + write(" extends "); + emit(baseTypeNode.expression); + } + write(" {"); + increaseIndent(); + scopeEmitStart(node); + writeLine(); + emitConstructor(node, baseTypeNode); + emitMemberFunctionsForES6AndHigher(node); + decreaseIndent(); + writeLine(); + emitToken(16 /* CloseBraceToken */, node.members.end); + scopeEmitEnd(); + // TODO(rbuckton): Need to go back to `let _a = class C {}` approach, removing the defineProperty call for now. + // For a decorated class, we need to assign its name (if it has one). This is because we emit + // the class as a class expression to avoid the double-binding of the identifier: + // + // let C = class { + // } + // Object.defineProperty(C, "name", { value: "C", configurable: true }); + // + if (thisNodeIsDecorated) { + write(";"); + } + // Emit static property assignment. Because classDeclaration is lexically evaluated, + // it is safe to emit static property assignment after classDeclaration + // From ES6 specification: + // 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 (isClassExpressionWithStaticProperties) { + for (var _a = 0; _a < staticProperties.length; _a++) { + var property = staticProperties[_a]; + write(","); + writeLine(); + emitPropertyDeclaration(node, property, /*receiver:*/ tempVariable, /*isExpression:*/ true); + } + write(","); + writeLine(); + emit(tempVariable); + decreaseIndent(); + write(")"); + } + else { + writeLine(); + emitPropertyDeclarations(node, staticProperties); + emitDecoratorsOfClass(node); + } + // If this is an exported class, but not on the top level (i.e. on an internal + // module), export it + if (!isES6ExportedDeclaration(node) && (node.flags & 1 /* Export */)) { + writeLine(); + emitStart(node); + emitModuleMemberName(node); + write(" = "); + emitDeclarationName(node); + emitEnd(node); + write(";"); + } + else if (isES6ExportedDeclaration(node) && (node.flags & 1024 /* Default */) && thisNodeIsDecorated) { + // if this is a top level default export of decorated class, write the export after the declaration. + writeLine(); + write("export default "); + emitDeclarationName(node); + write(";"); + } + } + function emitClassLikeDeclarationBelowES6(node) { + if (node.kind === 214 /* ClassDeclaration */) { + // source file level classes in system modules are hoisted so 'var's for them are already defined + if (!shouldHoistDeclarationInSystemJsModule(node)) { + write("var "); + } + emitDeclarationName(node); + write(" = "); + } + write("(function ("); + var baseTypeNode = ts.getClassExtendsHeritageClauseElement(node); + if (baseTypeNode) { + write("_super"); + } + write(") {"); + var saveTempFlags = tempFlags; + var saveTempVariables = tempVariables; + var saveTempParameters = tempParameters; + var saveComputedPropertyNamesToGeneratedNames = computedPropertyNamesToGeneratedNames; + tempFlags = 0; + tempVariables = undefined; + tempParameters = undefined; + computedPropertyNamesToGeneratedNames = undefined; + increaseIndent(); + scopeEmitStart(node); + if (baseTypeNode) { + writeLine(); + emitStart(baseTypeNode); + write("__extends("); + emitDeclarationName(node); + write(", _super);"); + emitEnd(baseTypeNode); + } + writeLine(); + emitConstructor(node, baseTypeNode); + emitMemberFunctionsForES5AndLower(node); + emitPropertyDeclarations(node, getInitializedProperties(node, /*static:*/ true)); + writeLine(); + emitDecoratorsOfClass(node); + writeLine(); + emitToken(16 /* CloseBraceToken */, node.members.end, function () { + write("return "); + emitDeclarationName(node); + }); + write(";"); + emitTempDeclarations(/*newLine*/ true); + tempFlags = saveTempFlags; + tempVariables = saveTempVariables; + tempParameters = saveTempParameters; + computedPropertyNamesToGeneratedNames = saveComputedPropertyNamesToGeneratedNames; + decreaseIndent(); + writeLine(); + emitToken(16 /* CloseBraceToken */, node.members.end); + scopeEmitEnd(); + emitStart(node); + write(")("); + if (baseTypeNode) { + emit(baseTypeNode.expression); + } + write(")"); + if (node.kind === 214 /* ClassDeclaration */) { + write(";"); + } + emitEnd(node); + if (node.kind === 214 /* ClassDeclaration */) { + emitExportMemberAssignment(node); + } + } + function emitClassMemberPrefix(node, member) { + emitDeclarationName(node); + if (!(member.flags & 128 /* Static */)) { + write(".prototype"); + } + } + function emitDecoratorsOfClass(node) { + emitDecoratorsOfMembers(node, /*staticFlag*/ 0); + emitDecoratorsOfMembers(node, 128 /* Static */); + emitDecoratorsOfConstructor(node); + } + function emitDecoratorsOfConstructor(node) { + var decorators = node.decorators; + var constructor = ts.getFirstConstructorWithBody(node); + var hasDecoratedParameters = constructor && ts.forEach(constructor.parameters, ts.nodeIsDecorated); + // skip decoration of the constructor if neither it nor its parameters are decorated + if (!decorators && !hasDecoratedParameters) { + return; + } + // Emit the call to __decorate. Given the class: + // + // @dec + // class C { + // } + // + // The emit for the class is: + // + // C = __decorate([dec], C); + // + writeLine(); + emitStart(node); + emitDeclarationName(node); + write(" = __decorate(["); + increaseIndent(); + writeLine(); + var decoratorCount = decorators ? decorators.length : 0; + var argumentsWritten = emitList(decorators, 0, decoratorCount, /*multiLine*/ true, /*trailingComma*/ false, /*leadingComma*/ false, /*noTrailingNewLine*/ true, function (decorator) { + emitStart(decorator); + emit(decorator.expression); + emitEnd(decorator); + }); + argumentsWritten += emitDecoratorsOfParameters(constructor, /*leadingComma*/ argumentsWritten > 0); + emitSerializedTypeMetadata(node, /*leadingComma*/ argumentsWritten >= 0); + decreaseIndent(); + writeLine(); + write("], "); + emitDeclarationName(node); + write(");"); + emitEnd(node); + writeLine(); + } + function emitDecoratorsOfMembers(node, staticFlag) { + for (var _a = 0, _b = node.members; _a < _b.length; _a++) { + var member = _b[_a]; + // only emit members in the correct group + if ((member.flags & 128 /* Static */) !== staticFlag) { + continue; + } + // skip members that cannot be decorated (such as the constructor) + if (!ts.nodeCanBeDecorated(member)) { + continue; + } + // skip a member if it or any of its parameters are not decorated + if (!ts.nodeOrChildIsDecorated(member)) { + continue; + } + // skip an accessor declaration if it is not the first accessor + var decorators = void 0; + var functionLikeMember = void 0; + if (ts.isAccessor(member)) { + var accessors = ts.getAllAccessorDeclarations(node.members, member); + if (member !== accessors.firstAccessor) { + continue; + } + // get the decorators from the first accessor with decorators + decorators = accessors.firstAccessor.decorators; + if (!decorators && accessors.secondAccessor) { + decorators = accessors.secondAccessor.decorators; + } + // we only decorate parameters of the set accessor + functionLikeMember = accessors.setAccessor; + } + else { + decorators = member.decorators; + // we only decorate the parameters here if this is a method + if (member.kind === 143 /* MethodDeclaration */) { + functionLikeMember = member; + } + } + // Emit the call to __decorate. Given the following: + // + // class C { + // @dec method(@dec2 x) {} + // @dec get accessor() {} + // @dec prop; + // } + // + // The emit for a method is: + // + // __decorate([ + // dec, + // __param(0, dec2), + // __metadata("design:type", Function), + // __metadata("design:paramtypes", [Object]), + // __metadata("design:returntype", void 0) + // ], C.prototype, "method", undefined); + // + // The emit for an accessor is: + // + // __decorate([ + // dec + // ], C.prototype, "accessor", undefined); + // + // The emit for a property is: + // + // __decorate([ + // dec + // ], C.prototype, "prop"); + // + writeLine(); + emitStart(member); + write("__decorate(["); + increaseIndent(); + writeLine(); + var decoratorCount = decorators ? decorators.length : 0; + var argumentsWritten = emitList(decorators, 0, decoratorCount, /*multiLine*/ true, /*trailingComma*/ false, /*leadingComma*/ false, /*noTrailingNewLine*/ true, function (decorator) { + emitStart(decorator); + emit(decorator.expression); + emitEnd(decorator); + }); + argumentsWritten += emitDecoratorsOfParameters(functionLikeMember, argumentsWritten > 0); + emitSerializedTypeMetadata(member, argumentsWritten > 0); + decreaseIndent(); + writeLine(); + write("], "); + emitStart(member.name); + emitClassMemberPrefix(node, member); + write(", "); + emitExpressionForPropertyName(member.name); + emitEnd(member.name); + if (languageVersion > 0 /* ES3 */) { + if (member.kind !== 141 /* PropertyDeclaration */) { + // We emit `null` here to indicate to `__decorate` that it can invoke `Object.getOwnPropertyDescriptor` directly. + // We have this extra argument here so that we can inject an explicit property descriptor at a later date. + write(", null"); + } + else { + // We emit `void 0` here to indicate to `__decorate` that it can invoke `Object.defineProperty` directly, but that it + // should not invoke `Object.getOwnPropertyDescriptor`. + write(", void 0"); + } + } + write(");"); + emitEnd(member); + writeLine(); + } + } + function emitDecoratorsOfParameters(node, leadingComma) { + var argumentsWritten = 0; + if (node) { + var parameterIndex = 0; + for (var _a = 0, _b = node.parameters; _a < _b.length; _a++) { + var parameter = _b[_a]; + if (ts.nodeIsDecorated(parameter)) { + var decorators = parameter.decorators; + argumentsWritten += emitList(decorators, 0, decorators.length, /*multiLine*/ true, /*trailingComma*/ false, /*leadingComma*/ leadingComma, /*noTrailingNewLine*/ true, function (decorator) { + emitStart(decorator); + write("__param(" + parameterIndex + ", "); + emit(decorator.expression); + write(")"); + emitEnd(decorator); + }); + leadingComma = true; + } + ++parameterIndex; + } + } + return argumentsWritten; + } + function shouldEmitTypeMetadata(node) { + // This method determines whether to emit the "design:type" metadata based on the node's kind. + // The caller should have already tested whether the node has decorators and whether the emitDecoratorMetadata + // compiler option is set. + switch (node.kind) { + case 143 /* MethodDeclaration */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: + case 141 /* PropertyDeclaration */: + return true; + } + return false; + } + function shouldEmitReturnTypeMetadata(node) { + // This method determines whether to emit the "design:returntype" metadata based on the node's kind. + // The caller should have already tested whether the node has decorators and whether the emitDecoratorMetadata + // compiler option is set. + switch (node.kind) { + case 143 /* MethodDeclaration */: + return true; + } + return false; + } + function shouldEmitParamTypesMetadata(node) { + // This method determines whether to emit the "design:paramtypes" metadata based on the node's kind. + // The caller should have already tested whether the node has decorators and whether the emitDecoratorMetadata + // compiler option is set. + switch (node.kind) { + case 214 /* ClassDeclaration */: + case 143 /* MethodDeclaration */: + case 146 /* SetAccessor */: + return true; + } + return false; + } + /** Serializes the type of a declaration to an appropriate JS constructor value. Used by the __metadata decorator for a class member. */ + function emitSerializedTypeOfNode(node) { + // serialization of the type of a declaration uses the following rules: + // + // * The serialized type of a ClassDeclaration is "Function" + // * The serialized type of a ParameterDeclaration is the serialized type of its type annotation. + // * The serialized type of a PropertyDeclaration is the serialized type of its type annotation. + // * The serialized type of an AccessorDeclaration is the serialized type of the return type annotation of its getter or parameter type annotation of its setter. + // * The serialized type of any other FunctionLikeDeclaration is "Function". + // * The serialized type of any other node is "void 0". + // + // For rules on serializing type annotations, see `serializeTypeNode`. + switch (node.kind) { + case 214 /* ClassDeclaration */: + write("Function"); + return; + case 141 /* PropertyDeclaration */: + emitSerializedTypeNode(node.type); + return; + case 138 /* Parameter */: + emitSerializedTypeNode(node.type); + return; + case 145 /* GetAccessor */: + emitSerializedTypeNode(node.type); + return; + case 146 /* SetAccessor */: + emitSerializedTypeNode(ts.getSetAccessorTypeAnnotationNode(node)); + return; + } + if (ts.isFunctionLike(node)) { + write("Function"); + return; + } + write("void 0"); + } + function emitSerializedTypeNode(node) { + if (node) { + switch (node.kind) { + case 103 /* VoidKeyword */: + write("void 0"); + return; + case 160 /* ParenthesizedType */: + emitSerializedTypeNode(node.type); + return; + case 152 /* FunctionType */: + case 153 /* ConstructorType */: + write("Function"); + return; + case 156 /* ArrayType */: + case 157 /* TupleType */: + write("Array"); + return; + case 150 /* TypePredicate */: + case 120 /* BooleanKeyword */: + write("Boolean"); + return; + case 130 /* StringKeyword */: + case 9 /* StringLiteral */: + write("String"); + return; + case 128 /* NumberKeyword */: + write("Number"); + return; + case 131 /* SymbolKeyword */: + write("Symbol"); + return; + case 151 /* TypeReference */: + emitSerializedTypeReferenceNode(node); + return; + case 154 /* TypeQuery */: + case 155 /* TypeLiteral */: + case 158 /* UnionType */: + case 159 /* IntersectionType */: + case 117 /* AnyKeyword */: + break; + default: + ts.Debug.fail("Cannot serialize unexpected type node."); + break; + } + } + write("Object"); + } + /** Serializes a TypeReferenceNode to an appropriate JS constructor value. Used by the __metadata decorator. */ + function emitSerializedTypeReferenceNode(node) { + var location = node.parent; + while (ts.isDeclaration(location) || ts.isTypeNode(location)) { + location = location.parent; + } + // Clone the type name and parent it to a location outside of the current declaration. + var typeName = ts.cloneEntityName(node.typeName); + typeName.parent = location; + var result = resolver.getTypeReferenceSerializationKind(typeName); + switch (result) { + case ts.TypeReferenceSerializationKind.Unknown: + var temp = createAndRecordTempVariable(0 /* Auto */); + write("(typeof ("); + emitNodeWithoutSourceMap(temp); + write(" = "); + emitEntityNameAsExpression(typeName, /*useFallback*/ true); + write(") === 'function' && "); + emitNodeWithoutSourceMap(temp); + write(") || Object"); + break; + case ts.TypeReferenceSerializationKind.TypeWithConstructSignatureAndValue: + emitEntityNameAsExpression(typeName, /*useFallback*/ false); + break; + case ts.TypeReferenceSerializationKind.VoidType: + write("void 0"); + break; + case ts.TypeReferenceSerializationKind.BooleanType: + write("Boolean"); + break; + case ts.TypeReferenceSerializationKind.NumberLikeType: + write("Number"); + break; + case ts.TypeReferenceSerializationKind.StringLikeType: + write("String"); + break; + case ts.TypeReferenceSerializationKind.ArrayLikeType: + write("Array"); + break; + case ts.TypeReferenceSerializationKind.ESSymbolType: + if (languageVersion < 2 /* ES6 */) { + write("typeof Symbol === 'function' ? Symbol : Object"); + } + else { + write("Symbol"); + } + break; + case ts.TypeReferenceSerializationKind.TypeWithCallSignature: + write("Function"); + break; + case ts.TypeReferenceSerializationKind.ObjectType: + write("Object"); + break; + } + } + /** Serializes the parameter types of a function or the constructor of a class. Used by the __metadata decorator for a method or set accessor. */ + function emitSerializedParameterTypesOfNode(node) { + // serialization of parameter types uses the following rules: + // + // * If the declaration is a class, the parameters of the first constructor with a body are used. + // * If the declaration is function-like and has a body, the parameters of the function are used. + // + // For the rules on serializing the type of each parameter declaration, see `serializeTypeOfDeclaration`. + if (node) { + var valueDeclaration; + if (node.kind === 214 /* ClassDeclaration */) { + valueDeclaration = ts.getFirstConstructorWithBody(node); + } + else if (ts.isFunctionLike(node) && ts.nodeIsPresent(node.body)) { + valueDeclaration = node; + } + if (valueDeclaration) { + var parameters = valueDeclaration.parameters; + var parameterCount = parameters.length; + if (parameterCount > 0) { + for (var i = 0; i < parameterCount; i++) { + if (i > 0) { + write(", "); + } + if (parameters[i].dotDotDotToken) { + var parameterType = parameters[i].type; + if (parameterType.kind === 156 /* ArrayType */) { + parameterType = parameterType.elementType; + } + else if (parameterType.kind === 151 /* TypeReference */ && parameterType.typeArguments && parameterType.typeArguments.length === 1) { + parameterType = parameterType.typeArguments[0]; + } + else { + parameterType = undefined; + } + emitSerializedTypeNode(parameterType); + } + else { + emitSerializedTypeOfNode(parameters[i]); + } + } + } + } + } + } + /** Serializes the return type of function. Used by the __metadata decorator for a method. */ + function emitSerializedReturnTypeOfNode(node) { + if (node && ts.isFunctionLike(node) && node.type) { + emitSerializedTypeNode(node.type); + return; + } + write("void 0"); + } + function emitSerializedTypeMetadata(node, writeComma) { + // This method emits the serialized type metadata for a decorator target. + // The caller should have already tested whether the node has decorators. + var argumentsWritten = 0; + if (compilerOptions.emitDecoratorMetadata) { + if (shouldEmitTypeMetadata(node)) { + if (writeComma) { + write(", "); + } + writeLine(); + write("__metadata('design:type', "); + emitSerializedTypeOfNode(node); + write(")"); + argumentsWritten++; + } + if (shouldEmitParamTypesMetadata(node)) { + if (writeComma || argumentsWritten) { + write(", "); + } + writeLine(); + write("__metadata('design:paramtypes', ["); + emitSerializedParameterTypesOfNode(node); + write("])"); + argumentsWritten++; + } + if (shouldEmitReturnTypeMetadata(node)) { + if (writeComma || argumentsWritten) { + write(", "); + } + writeLine(); + write("__metadata('design:returntype', "); + emitSerializedReturnTypeOfNode(node); + write(")"); + argumentsWritten++; + } + } + return argumentsWritten; + } + function emitInterfaceDeclaration(node) { + emitCommentsOnNotEmittedNode(node); + } + function shouldEmitEnumDeclaration(node) { + var isConstEnum = ts.isConst(node); + return !isConstEnum || compilerOptions.preserveConstEnums || compilerOptions.isolatedModules; + } + function emitEnumDeclaration(node) { + // const enums are completely erased during compilation. + if (!shouldEmitEnumDeclaration(node)) { + return; + } + if (!shouldHoistDeclarationInSystemJsModule(node)) { + // do not emit var if variable was already hoisted + if (!(node.flags & 1 /* Export */) || isES6ExportedDeclaration(node)) { + emitStart(node); + if (isES6ExportedDeclaration(node)) { + write("export "); + } + write("var "); + emit(node.name); + emitEnd(node); + write(";"); + } + } + writeLine(); + emitStart(node); + write("(function ("); + emitStart(node.name); + write(getGeneratedNameForNode(node)); + emitEnd(node.name); + write(") {"); + increaseIndent(); + scopeEmitStart(node); + emitLines(node.members); + decreaseIndent(); + writeLine(); + emitToken(16 /* CloseBraceToken */, node.members.end); + scopeEmitEnd(); + write(")("); + emitModuleMemberName(node); + write(" || ("); + emitModuleMemberName(node); + write(" = {}));"); + emitEnd(node); + if (!isES6ExportedDeclaration(node) && node.flags & 1 /* Export */ && !shouldHoistDeclarationInSystemJsModule(node)) { + // do not emit var if variable was already hoisted + writeLine(); + emitStart(node); + write("var "); + emit(node.name); + write(" = "); + emitModuleMemberName(node); + emitEnd(node); + write(";"); + } + if (modulekind !== 5 /* ES6 */ && node.parent === currentSourceFile) { + if (modulekind === 4 /* System */ && (node.flags & 1 /* Export */)) { + // write the call to exporter for enum + writeLine(); + write(exportFunctionForFile + "(\""); + emitDeclarationName(node); + write("\", "); + emitDeclarationName(node); + write(");"); + } + emitExportMemberAssignments(node.name); + } + } + function emitEnumMember(node) { + var enumParent = node.parent; + emitStart(node); + write(getGeneratedNameForNode(enumParent)); + write("["); + write(getGeneratedNameForNode(enumParent)); + write("["); + emitExpressionForPropertyName(node.name); + write("] = "); + writeEnumMemberDeclarationValue(node); + write("] = "); + emitExpressionForPropertyName(node.name); + emitEnd(node); + write(";"); + } + function writeEnumMemberDeclarationValue(member) { + var value = resolver.getConstantValue(member); + if (value !== undefined) { + write(value.toString()); + return; + } + else if (member.initializer) { + emit(member.initializer); + } + else { + write("undefined"); + } + } + function getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration) { + if (moduleDeclaration.body.kind === 218 /* ModuleDeclaration */) { + var recursiveInnerModule = getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration.body); + return recursiveInnerModule || moduleDeclaration.body; + } + } + function shouldEmitModuleDeclaration(node) { + return ts.isInstantiatedModule(node, compilerOptions.preserveConstEnums || compilerOptions.isolatedModules); + } + function isModuleMergedWithES6Class(node) { + return languageVersion === 2 /* ES6 */ && !!(resolver.getNodeCheckFlags(node) & 32768 /* LexicalModuleMergesWithClass */); + } + function emitModuleDeclaration(node) { + // Emit only if this module is non-ambient. + var shouldEmit = shouldEmitModuleDeclaration(node); + if (!shouldEmit) { + return emitCommentsOnNotEmittedNode(node); + } + var hoistedInDeclarationScope = shouldHoistDeclarationInSystemJsModule(node); + var emitVarForModule = !hoistedInDeclarationScope && !isModuleMergedWithES6Class(node); + if (emitVarForModule) { + emitStart(node); + if (isES6ExportedDeclaration(node)) { + write("export "); + } + write("var "); + emit(node.name); + write(";"); + emitEnd(node); + writeLine(); + } + emitStart(node); + write("(function ("); + emitStart(node.name); + write(getGeneratedNameForNode(node)); + emitEnd(node.name); + write(") "); + if (node.body.kind === 219 /* ModuleBlock */) { + var saveTempFlags = tempFlags; + var saveTempVariables = tempVariables; + tempFlags = 0; + tempVariables = undefined; + emit(node.body); + tempFlags = saveTempFlags; + tempVariables = saveTempVariables; + } + else { + write("{"); + increaseIndent(); + scopeEmitStart(node); + emitCaptureThisForNodeIfNecessary(node); + writeLine(); + emit(node.body); + decreaseIndent(); + writeLine(); + var moduleBlock = getInnerMostModuleDeclarationFromDottedModule(node).body; + emitToken(16 /* CloseBraceToken */, moduleBlock.statements.end); + scopeEmitEnd(); + } + write(")("); + // write moduleDecl = containingModule.m only if it is not exported es6 module member + if ((node.flags & 1 /* Export */) && !isES6ExportedDeclaration(node)) { + emit(node.name); + write(" = "); + } + emitModuleMemberName(node); + write(" || ("); + emitModuleMemberName(node); + write(" = {}));"); + emitEnd(node); + if (!isES6ExportedDeclaration(node) && node.name.kind === 69 /* Identifier */ && node.parent === currentSourceFile) { + if (modulekind === 4 /* System */ && (node.flags & 1 /* Export */)) { + writeLine(); + write(exportFunctionForFile + "(\""); + emitDeclarationName(node); + write("\", "); + emitDeclarationName(node); + write(");"); + } + emitExportMemberAssignments(node.name); + } + } + /* + * Some bundlers (SystemJS builder) sometimes want to rename dependencies. + * Here we check if alternative name was provided for a given moduleName and return it if possible. + */ + function tryRenameExternalModule(moduleName) { + if (currentSourceFile.renamedDependencies && ts.hasProperty(currentSourceFile.renamedDependencies, moduleName.text)) { + return "\"" + currentSourceFile.renamedDependencies[moduleName.text] + "\""; + } + return undefined; + } + function emitRequire(moduleName) { + if (moduleName.kind === 9 /* StringLiteral */) { + write("require("); + var text = tryRenameExternalModule(moduleName); + if (text) { + write(text); + } + else { + emitStart(moduleName); + emitLiteral(moduleName); + emitEnd(moduleName); + } + emitToken(18 /* CloseParenToken */, moduleName.end); + } + else { + write("require()"); + } + } + function getNamespaceDeclarationNode(node) { + if (node.kind === 221 /* ImportEqualsDeclaration */) { + return node; + } + var importClause = node.importClause; + if (importClause && importClause.namedBindings && importClause.namedBindings.kind === 224 /* NamespaceImport */) { + return importClause.namedBindings; + } + } + function isDefaultImport(node) { + return node.kind === 222 /* ImportDeclaration */ && node.importClause && !!node.importClause.name; + } + function emitExportImportAssignments(node) { + if (ts.isAliasSymbolDeclaration(node) && resolver.isValueAliasDeclaration(node)) { + emitExportMemberAssignments(node.name); + } + ts.forEachChild(node, emitExportImportAssignments); + } + function emitImportDeclaration(node) { + if (modulekind !== 5 /* ES6 */) { + return emitExternalImportDeclaration(node); + } + // ES6 import + if (node.importClause) { + var shouldEmitDefaultBindings = resolver.isReferencedAliasDeclaration(node.importClause); + var shouldEmitNamedBindings = node.importClause.namedBindings && resolver.isReferencedAliasDeclaration(node.importClause.namedBindings, /* checkChildren */ true); + if (shouldEmitDefaultBindings || shouldEmitNamedBindings) { + write("import "); + emitStart(node.importClause); + if (shouldEmitDefaultBindings) { + emit(node.importClause.name); + if (shouldEmitNamedBindings) { + write(", "); + } + } + if (shouldEmitNamedBindings) { + emitLeadingComments(node.importClause.namedBindings); + emitStart(node.importClause.namedBindings); + if (node.importClause.namedBindings.kind === 224 /* NamespaceImport */) { + write("* as "); + emit(node.importClause.namedBindings.name); + } + else { + write("{ "); + emitExportOrImportSpecifierList(node.importClause.namedBindings.elements, resolver.isReferencedAliasDeclaration); + write(" }"); + } + emitEnd(node.importClause.namedBindings); + emitTrailingComments(node.importClause.namedBindings); + } + emitEnd(node.importClause); + write(" from "); + emit(node.moduleSpecifier); + write(";"); + } + } + else { + write("import "); + emit(node.moduleSpecifier); + write(";"); + } + } + function emitExternalImportDeclaration(node) { + if (ts.contains(externalImports, node)) { + var isExportedImport = node.kind === 221 /* ImportEqualsDeclaration */ && (node.flags & 1 /* Export */) !== 0; + var namespaceDeclaration = getNamespaceDeclarationNode(node); + if (modulekind !== 2 /* AMD */) { + emitLeadingComments(node); + emitStart(node); + if (namespaceDeclaration && !isDefaultImport(node)) { + // import x = require("foo") + // import * as x from "foo" + if (!isExportedImport) + write("var "); + emitModuleMemberName(namespaceDeclaration); + write(" = "); + } + else { + // import "foo" + // import x from "foo" + // import { x, y } from "foo" + // import d, * as x from "foo" + // import d, { x, y } from "foo" + var isNakedImport = 222 /* ImportDeclaration */ && !node.importClause; + if (!isNakedImport) { + write("var "); + write(getGeneratedNameForNode(node)); + write(" = "); + } + } + emitRequire(ts.getExternalModuleName(node)); + if (namespaceDeclaration && isDefaultImport(node)) { + // import d, * as x from "foo" + write(", "); + emitModuleMemberName(namespaceDeclaration); + write(" = "); + write(getGeneratedNameForNode(node)); + } + write(";"); + emitEnd(node); + emitExportImportAssignments(node); + emitTrailingComments(node); + } + else { + if (isExportedImport) { + emitModuleMemberName(namespaceDeclaration); + write(" = "); + emit(namespaceDeclaration.name); + write(";"); + } + else if (namespaceDeclaration && isDefaultImport(node)) { + // import d, * as x from "foo" + write("var "); + emitModuleMemberName(namespaceDeclaration); + write(" = "); + write(getGeneratedNameForNode(node)); + write(";"); + } + emitExportImportAssignments(node); + } + } + } + function emitImportEqualsDeclaration(node) { + if (ts.isExternalModuleImportEqualsDeclaration(node)) { + emitExternalImportDeclaration(node); + return; + } + // preserve old compiler's behavior: emit 'var' for import declaration (even if we do not consider them referenced) when + // - current file is not external module + // - import declaration is top level and target is value imported by entity name + if (resolver.isReferencedAliasDeclaration(node) || + (!ts.isExternalModule(currentSourceFile) && resolver.isTopLevelValueImportEqualsWithEntityName(node))) { + emitLeadingComments(node); + emitStart(node); + // variable declaration for import-equals declaration can be hoisted in system modules + // in this case 'var' should be omitted and emit should contain only initialization + var variableDeclarationIsHoisted = shouldHoistVariable(node, /*checkIfSourceFileLevelDecl*/ true); + // is it top level export import v = a.b.c in system module? + // if yes - it needs to be rewritten as exporter('v', v = a.b.c) + var isExported = isSourceFileLevelDeclarationInSystemJsModule(node, /*isExported*/ true); + if (!variableDeclarationIsHoisted) { + ts.Debug.assert(!isExported); + if (isES6ExportedDeclaration(node)) { + write("export "); + write("var "); + } + else if (!(node.flags & 1 /* Export */)) { + write("var "); + } + } + if (isExported) { + write(exportFunctionForFile + "(\""); + emitNodeWithoutSourceMap(node.name); + write("\", "); + } + emitModuleMemberName(node); + write(" = "); + emit(node.moduleReference); + if (isExported) { + write(")"); + } + write(";"); + emitEnd(node); + emitExportImportAssignments(node); + emitTrailingComments(node); + } + } + function emitExportDeclaration(node) { + ts.Debug.assert(modulekind !== 4 /* System */); + if (modulekind !== 5 /* ES6 */) { + if (node.moduleSpecifier && (!node.exportClause || resolver.isValueAliasDeclaration(node))) { + emitStart(node); + var generatedName = getGeneratedNameForNode(node); + if (node.exportClause) { + // export { x, y, ... } from "foo" + if (modulekind !== 2 /* AMD */) { + write("var "); + write(generatedName); + write(" = "); + emitRequire(ts.getExternalModuleName(node)); + write(";"); + } + for (var _a = 0, _b = node.exportClause.elements; _a < _b.length; _a++) { + var specifier = _b[_a]; + if (resolver.isValueAliasDeclaration(specifier)) { + writeLine(); + emitStart(specifier); + emitContainingModuleName(specifier); + write("."); + emitNodeWithCommentsAndWithoutSourcemap(specifier.name); + write(" = "); + write(generatedName); + write("."); + emitNodeWithCommentsAndWithoutSourcemap(specifier.propertyName || specifier.name); + write(";"); + emitEnd(specifier); + } + } + } + else { + // export * from "foo" + writeLine(); + write("__export("); + if (modulekind !== 2 /* AMD */) { + emitRequire(ts.getExternalModuleName(node)); + } + else { + write(generatedName); + } + write(");"); + } + emitEnd(node); + } + } + else { + if (!node.exportClause || resolver.isValueAliasDeclaration(node)) { + write("export "); + if (node.exportClause) { + // export { x, y, ... } + write("{ "); + emitExportOrImportSpecifierList(node.exportClause.elements, resolver.isValueAliasDeclaration); + write(" }"); + } + else { + write("*"); + } + if (node.moduleSpecifier) { + write(" from "); + emit(node.moduleSpecifier); + } + write(";"); + } + } + } + function emitExportOrImportSpecifierList(specifiers, shouldEmit) { + ts.Debug.assert(modulekind === 5 /* ES6 */); + var needsComma = false; + for (var _a = 0; _a < specifiers.length; _a++) { + var specifier = specifiers[_a]; + if (shouldEmit(specifier)) { + if (needsComma) { + write(", "); + } + if (specifier.propertyName) { + emit(specifier.propertyName); + write(" as "); + } + emit(specifier.name); + needsComma = true; + } + } + } + function emitExportAssignment(node) { + if (!node.isExportEquals && resolver.isValueAliasDeclaration(node)) { + if (modulekind === 5 /* ES6 */) { + writeLine(); + emitStart(node); + write("export default "); + var expression = node.expression; + emit(expression); + if (expression.kind !== 213 /* FunctionDeclaration */ && + expression.kind !== 214 /* ClassDeclaration */) { + write(";"); + } + emitEnd(node); + } + else { + writeLine(); + emitStart(node); + if (modulekind === 4 /* System */) { + write(exportFunctionForFile + "(\"default\","); + emit(node.expression); + write(")"); + } + else { + emitEs6ExportDefaultCompat(node); + emitContainingModuleName(node); + if (languageVersion === 0 /* ES3 */) { + write("[\"default\"] = "); + } + else { + write(".default = "); + } + emit(node.expression); + } + write(";"); + emitEnd(node); + } + } + } + function collectExternalModuleInfo(sourceFile) { + externalImports = []; + exportSpecifiers = {}; + exportEquals = undefined; + hasExportStars = false; + for (var _a = 0, _b = sourceFile.statements; _a < _b.length; _a++) { + var node = _b[_a]; + switch (node.kind) { + case 222 /* 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); + } + break; + case 221 /* ImportEqualsDeclaration */: + if (node.moduleReference.kind === 232 /* ExternalModuleReference */ && resolver.isReferencedAliasDeclaration(node)) { + // import x = require("mod") where x is referenced + externalImports.push(node); + } + break; + case 228 /* ExportDeclaration */: + if (node.moduleSpecifier) { + if (!node.exportClause) { + // export * from "mod" + externalImports.push(node); + hasExportStars = true; + } + else if (resolver.isValueAliasDeclaration(node)) { + // export { x, y } from "mod" where at least one export is a value symbol + externalImports.push(node); + } + } + else { + // export { x, y } + for (var _c = 0, _d = node.exportClause.elements; _c < _d.length; _c++) { + var specifier = _d[_c]; + var name_25 = (specifier.propertyName || specifier.name).text; + (exportSpecifiers[name_25] || (exportSpecifiers[name_25] = [])).push(specifier); + } + } + break; + case 227 /* ExportAssignment */: + if (node.isExportEquals && !exportEquals) { + // export = x + exportEquals = node; + } + break; + } + } + } + function emitExportStarHelper() { + if (hasExportStars) { + writeLine(); + write("function __export(m) {"); + increaseIndent(); + writeLine(); + write("for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];"); + decreaseIndent(); + writeLine(); + write("}"); + } + } + function getLocalNameForExternalImport(node) { + var namespaceDeclaration = getNamespaceDeclarationNode(node); + if (namespaceDeclaration && !isDefaultImport(node)) { + return ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, namespaceDeclaration.name); + } + if (node.kind === 222 /* ImportDeclaration */ && node.importClause) { + return getGeneratedNameForNode(node); + } + if (node.kind === 228 /* ExportDeclaration */ && node.moduleSpecifier) { + return getGeneratedNameForNode(node); + } + } + function getExternalModuleNameText(importNode) { + var moduleName = ts.getExternalModuleName(importNode); + if (moduleName.kind === 9 /* StringLiteral */) { + return tryRenameExternalModule(moduleName) || getLiteralText(moduleName); + } + return undefined; + } + function emitVariableDeclarationsForImports() { + if (externalImports.length === 0) { + return; + } + writeLine(); + var started = false; + for (var _a = 0; _a < externalImports.length; _a++) { + var importNode = externalImports[_a]; + // do not create variable declaration for exports and imports that lack import clause + var skipNode = importNode.kind === 228 /* ExportDeclaration */ || + (importNode.kind === 222 /* ImportDeclaration */ && !importNode.importClause); + if (skipNode) { + continue; + } + if (!started) { + write("var "); + started = true; + } + else { + write(", "); + } + write(getLocalNameForExternalImport(importNode)); + } + if (started) { + write(";"); + } + } + function emitLocalStorageForExportedNamesIfNecessary(exportedDeclarations) { + // 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. + if (!hasExportStars) { + // local names set is needed only in presence of star exports + return undefined; + } + // local names set should only be added if we have anything exported + if (!exportedDeclarations && 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 _a = 0; _a < externalImports.length; _a++) { + var externalImport = externalImports[_a]; + if (externalImport.kind === 228 /* ExportDeclaration */ && externalImport.exportClause) { + hasExportDeclarationWithExportClause = true; + break; + } + } + if (!hasExportDeclarationWithExportClause) { + // we still need to emit exportStar helper + return emitExportStarFunction(/*localNames*/ undefined); + } + } + var exportedNamesStorageRef = makeUniqueName("exportedNames"); + writeLine(); + write("var " + exportedNamesStorageRef + " = {"); + increaseIndent(); + var started = false; + if (exportedDeclarations) { + for (var i = 0; i < exportedDeclarations.length; ++i) { + // write name of exported declaration, i.e 'export var x...' + writeExportedName(exportedDeclarations[i]); + } + } + if (exportSpecifiers) { + for (var n in exportSpecifiers) { + for (var _b = 0, _c = exportSpecifiers[n]; _b < _c.length; _b++) { + var specifier = _c[_b]; + // write name of export specified, i.e. 'export {x}' + writeExportedName(specifier.name); + } + } + } + for (var _d = 0; _d < externalImports.length; _d++) { + var externalImport = externalImports[_d]; + if (externalImport.kind !== 228 /* ExportDeclaration */) { + continue; + } + var exportDecl = externalImport; + if (!exportDecl.exportClause) { + // export * from ... + continue; + } + for (var _e = 0, _f = exportDecl.exportClause.elements; _e < _f.length; _e++) { + var element = _f[_e]; + // write name of indirectly exported entry, i.e. 'export {x} from ...' + writeExportedName(element.name || element.propertyName); + } + } + decreaseIndent(); + writeLine(); + write("};"); + return emitExportStarFunction(exportedNamesStorageRef); + function emitExportStarFunction(localNames) { + var exportStarFunction = makeUniqueName("exportStar"); + writeLine(); + // define an export star helper function + write("function " + exportStarFunction + "(m) {"); + increaseIndent(); + writeLine(); + write("var exports = {};"); + writeLine(); + write("for(var n in m) {"); + increaseIndent(); + writeLine(); + write("if (n !== \"default\""); + if (localNames) { + write("&& !" + localNames + ".hasOwnProperty(n)"); + } + write(") exports[n] = m[n];"); + decreaseIndent(); + writeLine(); + write("}"); + writeLine(); + write(exportFunctionForFile + "(exports);"); + decreaseIndent(); + writeLine(); + write("}"); + return exportStarFunction; + } + function writeExportedName(node) { + // do not record default exports + // they are local to module and never overwritten (explicitly skipped) by star export + if (node.kind !== 69 /* Identifier */ && node.flags & 1024 /* Default */) { + return; + } + if (started) { + write(","); + } + else { + started = true; + } + writeLine(); + write("'"); + if (node.kind === 69 /* Identifier */) { + emitNodeWithCommentsAndWithoutSourcemap(node); + } + else { + emitDeclarationName(node); + } + write("': true"); + } + } + function processTopLevelVariableAndFunctionDeclarations(node) { + // per ES6 spec: + // 15.2.1.16.4 ModuleDeclarationInstantiation() Concrete Method + // - var declarations are initialized to undefined - 14.a.ii + // - function/generator declarations are instantiated - 16.a.iv + // this means that after module is instantiated but before its evaluation + // exported functions are already accessible at import sites + // in theory we should hoist only exported functions and its dependencies + // in practice to simplify things we'll hoist all source level functions and variable declaration + // including variables declarations for module and class declarations + var hoistedVars; + var hoistedFunctionDeclarations; + var exportedDeclarations; + visit(node); + if (hoistedVars) { + writeLine(); + write("var "); + var seen = {}; + for (var i = 0; i < hoistedVars.length; ++i) { + var local = hoistedVars[i]; + var name_26 = local.kind === 69 /* Identifier */ + ? local + : local.name; + if (name_26) { + // do not emit duplicate entries (in case of declaration merging) in the list of hoisted variables + var text = ts.unescapeIdentifier(name_26.text); + if (ts.hasProperty(seen, text)) { + continue; + } + else { + seen[text] = text; + } + } + if (i !== 0) { + write(", "); + } + if (local.kind === 214 /* ClassDeclaration */ || local.kind === 218 /* ModuleDeclaration */ || local.kind === 217 /* EnumDeclaration */) { + emitDeclarationName(local); + } + else { + emit(local); + } + var flags = ts.getCombinedNodeFlags(local.kind === 69 /* Identifier */ ? local.parent : local); + if (flags & 1 /* Export */) { + if (!exportedDeclarations) { + exportedDeclarations = []; + } + exportedDeclarations.push(local); + } + } + write(";"); + } + if (hoistedFunctionDeclarations) { + for (var _a = 0; _a < hoistedFunctionDeclarations.length; _a++) { + var f = hoistedFunctionDeclarations[_a]; + writeLine(); + emit(f); + if (f.flags & 1 /* Export */) { + if (!exportedDeclarations) { + exportedDeclarations = []; + } + exportedDeclarations.push(f); + } + } + } + return exportedDeclarations; + function visit(node) { + if (node.flags & 2 /* Ambient */) { + return; + } + if (node.kind === 213 /* FunctionDeclaration */) { + if (!hoistedFunctionDeclarations) { + hoistedFunctionDeclarations = []; + } + hoistedFunctionDeclarations.push(node); + return; + } + if (node.kind === 214 /* ClassDeclaration */) { + if (!hoistedVars) { + hoistedVars = []; + } + hoistedVars.push(node); + return; + } + if (node.kind === 217 /* EnumDeclaration */) { + if (shouldEmitEnumDeclaration(node)) { + if (!hoistedVars) { + hoistedVars = []; + } + hoistedVars.push(node); + } + return; + } + if (node.kind === 218 /* ModuleDeclaration */) { + if (shouldEmitModuleDeclaration(node)) { + if (!hoistedVars) { + hoistedVars = []; + } + hoistedVars.push(node); + } + return; + } + if (node.kind === 211 /* VariableDeclaration */ || node.kind === 163 /* BindingElement */) { + if (shouldHoistVariable(node, /*checkIfSourceFileLevelDecl*/ false)) { + var name_27 = node.name; + if (name_27.kind === 69 /* Identifier */) { + if (!hoistedVars) { + hoistedVars = []; + } + hoistedVars.push(name_27); + } + else { + ts.forEachChild(name_27, visit); + } + } + return; + } + if (ts.isInternalModuleImportEqualsDeclaration(node) && resolver.isValueAliasDeclaration(node)) { + if (!hoistedVars) { + hoistedVars = []; + } + hoistedVars.push(node.name); + return; + } + if (ts.isBindingPattern(node)) { + ts.forEach(node.elements, visit); + return; + } + if (!ts.isDeclaration(node)) { + ts.forEachChild(node, visit); + } + } + } + function shouldHoistVariable(node, checkIfSourceFileLevelDecl) { + if (checkIfSourceFileLevelDecl && !shouldHoistDeclarationInSystemJsModule(node)) { + return false; + } + // hoist variable if + // - it is not block scoped + // - it is top level block scoped + // if block scoped variables are nested in some another block then + // no other functions can use them except ones that are defined at least in the same block + return (ts.getCombinedNodeFlags(node) & 49152 /* BlockScoped */) === 0 || + ts.getEnclosingBlockScopeContainer(node).kind === 248 /* SourceFile */; + } + function isCurrentFileSystemExternalModule() { + return modulekind === 4 /* System */ && ts.isExternalModule(currentSourceFile); + } + function emitSystemModuleBody(node, dependencyGroups, startIndex) { + // 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 file1; // local alias + // var y; + // function foo() { return y + file1.x(); } + // exports("foo", foo); + // return { + // setters: [ + // function(v) { file1 = v } + // ], + // execute(): function() { + // y = 1; + // console.log(y); + // } + // }; + // } + emitVariableDeclarationsForImports(); + writeLine(); + var exportedDeclarations = processTopLevelVariableAndFunctionDeclarations(node); + var exportStarFunction = emitLocalStorageForExportedNamesIfNecessary(exportedDeclarations); + writeLine(); + write("return {"); + increaseIndent(); + writeLine(); + emitSetters(exportStarFunction, dependencyGroups); + writeLine(); + emitExecute(node, startIndex); + decreaseIndent(); + writeLine(); + write("}"); // return + emitTempDeclarations(/*newLine*/ true); + } + function emitSetters(exportStarFunction, dependencyGroups) { + write("setters:["); + for (var i = 0; i < dependencyGroups.length; ++i) { + if (i !== 0) { + write(","); + } + writeLine(); + increaseIndent(); + var group = dependencyGroups[i]; + // derive a unique name for parameter from the first named entry in the group + var parameterName = makeUniqueName(ts.forEach(group, getLocalNameForExternalImport) || ""); + write("function (" + parameterName + ") {"); + increaseIndent(); + for (var _a = 0; _a < group.length; _a++) { + var entry = group[_a]; + var importVariableName = getLocalNameForExternalImport(entry) || ""; + switch (entry.kind) { + case 222 /* ImportDeclaration */: + if (!entry.importClause) { + // 'import "..."' case + // module is imported only for side-effects, no emit required + break; + } + // fall-through + case 221 /* ImportEqualsDeclaration */: + ts.Debug.assert(importVariableName !== ""); + writeLine(); + // save import into the local + write(importVariableName + " = " + parameterName + ";"); + writeLine(); + break; + case 228 /* ExportDeclaration */: + ts.Debug.assert(importVariableName !== ""); + if (entry.exportClause) { + // export {a, b as c} from 'foo' + // emit as: + // exports_({ + // "a": _["a"], + // "c": _["b"] + // }); + writeLine(); + write(exportFunctionForFile + "({"); + writeLine(); + increaseIndent(); + for (var i_2 = 0, len = entry.exportClause.elements.length; i_2 < len; ++i_2) { + if (i_2 !== 0) { + write(","); + writeLine(); + } + var e = entry.exportClause.elements[i_2]; + write("\""); + emitNodeWithCommentsAndWithoutSourcemap(e.name); + write("\": " + parameterName + "[\""); + emitNodeWithCommentsAndWithoutSourcemap(e.propertyName || e.name); + write("\"]"); + } + decreaseIndent(); + writeLine(); + write("});"); + } + else { + writeLine(); + // export * from 'foo' + // emit as: + // exportStar(_foo); + write(exportStarFunction + "(" + parameterName + ");"); + } + writeLine(); + break; + } + } + decreaseIndent(); + write("}"); + decreaseIndent(); + } + write("],"); + } + function emitExecute(node, startIndex) { + write("execute: function() {"); + increaseIndent(); + writeLine(); + for (var i = startIndex; i < node.statements.length; ++i) { + var statement = node.statements[i]; + switch (statement.kind) { + // - function declarations are not emitted because they were already hoisted + // - import declarations are not emitted since they are already handled in setters + // - export declarations with module specifiers are not emitted since they were already written in setters + // - export declarations without module specifiers are emitted preserving the order + case 213 /* FunctionDeclaration */: + case 222 /* ImportDeclaration */: + continue; + case 228 /* ExportDeclaration */: + if (!statement.moduleSpecifier) { + for (var _a = 0, _b = statement.exportClause.elements; _a < _b.length; _a++) { + var element = _b[_a]; + // write call to exporter function for every export specifier in exports list + emitExportSpecifierInSystemModule(element); + } + } + continue; + case 221 /* ImportEqualsDeclaration */: + if (!ts.isInternalModuleImportEqualsDeclaration(statement)) { + // - import equals declarations that import external modules are not emitted + continue; + } + // fall-though for import declarations that import internal modules + default: + writeLine(); + emit(statement); + } + } + decreaseIndent(); + writeLine(); + write("}"); // execute + } + function emitSystemModule(node) { + collectExternalModuleInfo(node); + // System modules has the following shape + // System.register(['dep-1', ... 'dep-n'], function(exports) {/* module body function */}) + // 'exports' here is a function 'exports(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 'emitPostfixUnaryExpression' for more details + ts.Debug.assert(!exportFunctionForFile); + // make sure that name of 'exports' function does not conflict with existing identifiers + exportFunctionForFile = makeUniqueName("exports"); + writeLine(); + write("System.register("); + if (node.moduleName) { + write("\"" + node.moduleName + "\", "); + } + write("["); + var groupIndices = {}; + var dependencyGroups = []; + for (var i = 0; i < externalImports.length; ++i) { + var text = getExternalModuleNameText(externalImports[i]); + if (ts.hasProperty(groupIndices, text)) { + // deduplicate/group entries in dependency list by the dependency name + var groupIndex = groupIndices[text]; + dependencyGroups[groupIndex].push(externalImports[i]); + continue; + } + else { + groupIndices[text] = dependencyGroups.length; + dependencyGroups.push([externalImports[i]]); + } + if (i !== 0) { + write(", "); + } + write(text); + } + write("], function(" + exportFunctionForFile + ") {"); + writeLine(); + increaseIndent(); + var startIndex = emitDirectivePrologues(node.statements, /*startWithNewLine*/ true); + emitEmitHelpers(node); + emitCaptureThisForNodeIfNecessary(node); + emitSystemModuleBody(node, dependencyGroups, startIndex); + decreaseIndent(); + writeLine(); + write("});"); + } + function getAMDDependencyNames(node, includeNonAmdDependencies) { + // names of modules with corresponding parameter in the factory function + var aliasedModuleNames = []; + // names of modules with no corresponding parameters in factory function + var unaliasedModuleNames = []; + var importAliasNames = []; // names of the parameters in the factory function; these + // parameters need to match the indexes of the corresponding + // module names in aliasedModuleNames. + // Fill in amd-dependency tags + for (var _a = 0, _b = node.amdDependencies; _a < _b.length; _a++) { + var amdDependency = _b[_a]; + if (amdDependency.name) { + aliasedModuleNames.push("\"" + amdDependency.path + "\""); + importAliasNames.push(amdDependency.name); + } + else { + unaliasedModuleNames.push("\"" + amdDependency.path + "\""); + } + } + for (var _c = 0; _c < externalImports.length; _c++) { + var importNode = externalImports[_c]; + // Find the name of the external module + var externalModuleName = getExternalModuleNameText(importNode); + // Find the name of the module alias, if there is one + var importAliasName = getLocalNameForExternalImport(importNode); + if (includeNonAmdDependencies && importAliasName) { + aliasedModuleNames.push(externalModuleName); + importAliasNames.push(importAliasName); + } + else { + unaliasedModuleNames.push(externalModuleName); + } + } + return { aliasedModuleNames: aliasedModuleNames, unaliasedModuleNames: unaliasedModuleNames, importAliasNames: importAliasNames }; + } + function emitAMDDependencies(node, includeNonAmdDependencies) { + // An AMD define function has the following shape: + // define(id?, dependencies?, factory); + // + // This has the shape of + // define(name, ["module1", "module2"], function (module1Alias) { + // The location of the alias in the parameter list in the factory function needs to + // match the position of the module name in the dependency list. + // + // To ensure this is true in cases of modules with no aliases, e.g.: + // `import "module"` or `` + // we need to add modules without alias names to the end of the dependencies list + var dependencyNames = getAMDDependencyNames(node, includeNonAmdDependencies); + emitAMDDependencyList(dependencyNames); + write(", "); + emitAMDFactoryHeader(dependencyNames); + } + function emitAMDDependencyList(_a) { + var aliasedModuleNames = _a.aliasedModuleNames, unaliasedModuleNames = _a.unaliasedModuleNames; + write("[\"require\", \"exports\""); + if (aliasedModuleNames.length) { + write(", "); + write(aliasedModuleNames.join(", ")); + } + if (unaliasedModuleNames.length) { + write(", "); + write(unaliasedModuleNames.join(", ")); + } + write("]"); + } + function emitAMDFactoryHeader(_a) { + var importAliasNames = _a.importAliasNames; + write("function (require, exports"); + if (importAliasNames.length) { + write(", "); + write(importAliasNames.join(", ")); + } + write(") {"); + } + function emitAMDModule(node) { + emitEmitHelpers(node); + collectExternalModuleInfo(node); + writeLine(); + write("define("); + if (node.moduleName) { + write("\"" + node.moduleName + "\", "); + } + emitAMDDependencies(node, /*includeNonAmdDependencies*/ true); + increaseIndent(); + var startIndex = emitDirectivePrologues(node.statements, /*startWithNewLine*/ true); + emitExportStarHelper(); + emitCaptureThisForNodeIfNecessary(node); + emitLinesStartingAt(node.statements, startIndex); + emitTempDeclarations(/*newLine*/ true); + emitExportEquals(/*emitAsReturn*/ true); + decreaseIndent(); + writeLine(); + write("});"); + } + function emitCommonJSModule(node) { + var startIndex = emitDirectivePrologues(node.statements, /*startWithNewLine*/ false); + emitEmitHelpers(node); + collectExternalModuleInfo(node); + emitExportStarHelper(); + emitCaptureThisForNodeIfNecessary(node); + emitLinesStartingAt(node.statements, startIndex); + emitTempDeclarations(/*newLine*/ true); + emitExportEquals(/*emitAsReturn*/ false); + } + function emitUMDModule(node) { + emitEmitHelpers(node); + collectExternalModuleInfo(node); + var dependencyNames = getAMDDependencyNames(node, /*includeNonAmdDependencies*/ false); + // Module is detected first to support Browserify users that load into a browser with an AMD loader + writeLines("(function (factory) {\n if (typeof module === 'object' && typeof module.exports === 'object') {\n var v = factory(require, exports); if (v !== undefined) module.exports = v;\n }\n else if (typeof define === 'function' && define.amd) {\n define("); + emitAMDDependencyList(dependencyNames); + write(", factory);"); + writeLines(" }\n})("); + emitAMDFactoryHeader(dependencyNames); + increaseIndent(); + var startIndex = emitDirectivePrologues(node.statements, /*startWithNewLine*/ true); + emitExportStarHelper(); + emitCaptureThisForNodeIfNecessary(node); + emitLinesStartingAt(node.statements, startIndex); + emitTempDeclarations(/*newLine*/ true); + emitExportEquals(/*emitAsReturn*/ true); + decreaseIndent(); + writeLine(); + write("});"); + } + function emitES6Module(node) { + externalImports = undefined; + exportSpecifiers = undefined; + exportEquals = undefined; + hasExportStars = false; + var startIndex = emitDirectivePrologues(node.statements, /*startWithNewLine*/ false); + emitEmitHelpers(node); + emitCaptureThisForNodeIfNecessary(node); + emitLinesStartingAt(node.statements, startIndex); + emitTempDeclarations(/*newLine*/ true); + // Emit exportDefault if it exists will happen as part + // or normal statement emit. + } + function emitExportEquals(emitAsReturn) { + if (exportEquals && resolver.isValueAliasDeclaration(exportEquals)) { + writeLine(); + emitStart(exportEquals); + write(emitAsReturn ? "return " : "module.exports = "); + emit(exportEquals.expression); + write(";"); + emitEnd(exportEquals); + } + } + function emitJsxElement(node) { + switch (compilerOptions.jsx) { + case 2 /* React */: + jsxEmitReact(node); + break; + case 1 /* Preserve */: + // Fall back to preserve if None was specified (we'll error earlier) + default: + jsxEmitPreserve(node); + break; + } + } + function trimReactWhitespaceAndApplyEntities(node) { + var result = undefined; + var text = ts.getTextOfNode(node, /*includeTrivia*/ true); + var firstNonWhitespace = 0; + var lastNonWhitespace = -1; + // JSX trims whitespace at the end and beginning of lines, except that the + // start/end of a tag is considered a start/end of a line only if that line is + // on the same line as the closing tag. See examples in tests/cases/conformance/jsx/tsxReactEmitWhitespace.tsx + for (var i = 0; i < text.length; i++) { + var c = text.charCodeAt(i); + if (ts.isLineBreak(c)) { + if (firstNonWhitespace !== -1 && (lastNonWhitespace - firstNonWhitespace + 1 > 0)) { + var part = text.substr(firstNonWhitespace, lastNonWhitespace - firstNonWhitespace + 1); + result = (result ? result + "\" + ' ' + \"" : "") + ts.escapeString(part); + } + firstNonWhitespace = -1; + } + else if (!ts.isWhiteSpace(c)) { + lastNonWhitespace = i; + if (firstNonWhitespace === -1) { + firstNonWhitespace = i; + } + } + } + if (firstNonWhitespace !== -1) { + var part = text.substr(firstNonWhitespace); + result = (result ? result + "\" + ' ' + \"" : "") + ts.escapeString(part); + } + if (result) { + // Replace entities like   + result = result.replace(/&(\w+);/g, function (s, m) { + if (entities[m] !== undefined) { + return String.fromCharCode(entities[m]); + } + else { + return s; + } + }); + } + return result; + } + function getTextToEmit(node) { + switch (compilerOptions.jsx) { + case 2 /* React */: + var text = trimReactWhitespaceAndApplyEntities(node); + if (text === undefined || text.length === 0) { + return undefined; + } + else { + return text; + } + case 1 /* Preserve */: + default: + return ts.getTextOfNode(node, /*includeTrivia*/ true); + } + } + function emitJsxText(node) { + switch (compilerOptions.jsx) { + case 2 /* React */: + write("\""); + write(trimReactWhitespaceAndApplyEntities(node)); + write("\""); + break; + case 1 /* Preserve */: + default: + writer.writeLiteral(ts.getTextOfNode(node, /*includeTrivia*/ true)); + break; + } + } + function emitJsxExpression(node) { + if (node.expression) { + switch (compilerOptions.jsx) { + case 1 /* Preserve */: + default: + write("{"); + emit(node.expression); + write("}"); + break; + case 2 /* React */: + emit(node.expression); + break; + } + } + } + function emitDirectivePrologues(statements, startWithNewLine) { + for (var i = 0; i < statements.length; ++i) { + if (ts.isPrologueDirective(statements[i])) { + if (startWithNewLine || i > 0) { + writeLine(); + } + emit(statements[i]); + } + else { + // return index of the first non prologue directive + return i; + } + } + return statements.length; + } + function writeLines(text) { + var lines = text.split(/\r\n|\r|\n/g); + for (var i = 0; i < lines.length; ++i) { + var line = lines[i]; + if (line.length) { + writeLine(); + write(line); + } + } + } + function emitEmitHelpers(node) { + // Only emit helpers if the user did not say otherwise. + if (!compilerOptions.noEmitHelpers) { + // Only Emit __extends function when target ES5. + // For target ES6 and above, we can emit classDeclaration as is. + if ((languageVersion < 2 /* ES6 */) && (!extendsEmitted && resolver.getNodeCheckFlags(node) & 8 /* EmitExtends */)) { + writeLines(extendsHelper); + extendsEmitted = true; + } + if (!decorateEmitted && resolver.getNodeCheckFlags(node) & 16 /* EmitDecorate */) { + writeLines(decorateHelper); + if (compilerOptions.emitDecoratorMetadata) { + writeLines(metadataHelper); + } + decorateEmitted = true; + } + if (!paramEmitted && resolver.getNodeCheckFlags(node) & 32 /* EmitParam */) { + writeLines(paramHelper); + paramEmitted = true; + } + if (!awaiterEmitted && resolver.getNodeCheckFlags(node) & 64 /* EmitAwaiter */) { + writeLines(awaiterHelper); + awaiterEmitted = true; + } + } + } + function emitSourceFileNode(node) { + // Start new file on new line + writeLine(); + emitShebang(); + emitDetachedComments(node); + if (ts.isExternalModule(node) || compilerOptions.isolatedModules) { + var emitModule = moduleEmitDelegates[modulekind] || moduleEmitDelegates[1 /* CommonJS */]; + emitModule(node); + } + else { + // emit prologue directives prior to __extends + var startIndex = emitDirectivePrologues(node.statements, /*startWithNewLine*/ false); + externalImports = undefined; + exportSpecifiers = undefined; + exportEquals = undefined; + hasExportStars = false; + emitEmitHelpers(node); + emitCaptureThisForNodeIfNecessary(node); + emitLinesStartingAt(node.statements, startIndex); + emitTempDeclarations(/*newLine*/ true); + } + emitLeadingComments(node.endOfFileToken); + } + function emitNodeWithCommentsAndWithoutSourcemap(node) { + emitNodeConsideringCommentsOption(node, emitNodeWithoutSourceMap); + } + function emitNodeConsideringCommentsOption(node, emitNodeConsideringSourcemap) { + if (node) { + if (node.flags & 2 /* Ambient */) { + return emitCommentsOnNotEmittedNode(node); + } + if (isSpecializedCommentHandling(node)) { + // This is the node that will handle its own comments and sourcemap + return emitNodeWithoutSourceMap(node); + } + var emitComments_1 = shouldEmitLeadingAndTrailingComments(node); + if (emitComments_1) { + emitLeadingComments(node); + } + emitNodeConsideringSourcemap(node); + if (emitComments_1) { + emitTrailingComments(node); + } + } + } + function emitNodeWithoutSourceMap(node) { + if (node) { + emitJavaScriptWorker(node); + } + } + function isSpecializedCommentHandling(node) { + switch (node.kind) { + // All of these entities are emitted in a specialized fashion. As such, we allow + // the specialized methods for each to handle the comments on the nodes. + case 215 /* InterfaceDeclaration */: + case 213 /* FunctionDeclaration */: + case 222 /* ImportDeclaration */: + case 221 /* ImportEqualsDeclaration */: + case 216 /* TypeAliasDeclaration */: + case 227 /* ExportAssignment */: + return true; + } + } + function shouldEmitLeadingAndTrailingComments(node) { + switch (node.kind) { + case 193 /* VariableStatement */: + return shouldEmitLeadingAndTrailingCommentsForVariableStatement(node); + case 218 /* ModuleDeclaration */: + // Only emit the leading/trailing comments for a module if we're actually + // emitting the module as well. + return shouldEmitModuleDeclaration(node); + case 217 /* EnumDeclaration */: + // Only emit the leading/trailing comments for an enum if we're actually + // emitting the module as well. + return shouldEmitEnumDeclaration(node); + } + // If the node is emitted in specialized fashion, dont emit comments as this node will handle + // emitting comments when emitting itself + ts.Debug.assert(!isSpecializedCommentHandling(node)); + // If this is the expression body of an arrow function that we're down-leveling, + // then we don't want to emit comments when we emit the body. It will have already + // been taken care of when we emitted the 'return' statement for the function + // expression body. + if (node.kind !== 192 /* Block */ && + node.parent && + node.parent.kind === 174 /* ArrowFunction */ && + node.parent.body === node && + compilerOptions.target <= 1 /* ES5 */) { + return false; + } + // Emit comments for everything else. + return true; + } + function emitJavaScriptWorker(node) { + // Check if the node can be emitted regardless of the ScriptTarget + switch (node.kind) { + case 69 /* Identifier */: + return emitIdentifier(node); + case 138 /* Parameter */: + return emitParameter(node); + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: + return emitMethod(node); + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: + return emitAccessor(node); + case 97 /* ThisKeyword */: + return emitThis(node); + case 95 /* SuperKeyword */: + return emitSuper(node); + case 93 /* NullKeyword */: + return write("null"); + case 99 /* TrueKeyword */: + return write("true"); + case 84 /* FalseKeyword */: + return write("false"); + case 8 /* NumericLiteral */: + case 9 /* StringLiteral */: + case 10 /* RegularExpressionLiteral */: + case 11 /* NoSubstitutionTemplateLiteral */: + case 12 /* TemplateHead */: + case 13 /* TemplateMiddle */: + case 14 /* TemplateTail */: + return emitLiteral(node); + case 183 /* TemplateExpression */: + return emitTemplateExpression(node); + case 190 /* TemplateSpan */: + return emitTemplateSpan(node); + case 233 /* JsxElement */: + case 234 /* JsxSelfClosingElement */: + return emitJsxElement(node); + case 236 /* JsxText */: + return emitJsxText(node); + case 240 /* JsxExpression */: + return emitJsxExpression(node); + case 135 /* QualifiedName */: + return emitQualifiedName(node); + case 161 /* ObjectBindingPattern */: + return emitObjectBindingPattern(node); + case 162 /* ArrayBindingPattern */: + return emitArrayBindingPattern(node); + case 163 /* BindingElement */: + return emitBindingElement(node); + case 164 /* ArrayLiteralExpression */: + return emitArrayLiteral(node); + case 165 /* ObjectLiteralExpression */: + return emitObjectLiteral(node); + case 245 /* PropertyAssignment */: + return emitPropertyAssignment(node); + case 246 /* ShorthandPropertyAssignment */: + return emitShorthandPropertyAssignment(node); + case 136 /* ComputedPropertyName */: + return emitComputedPropertyName(node); + case 166 /* PropertyAccessExpression */: + return emitPropertyAccess(node); + case 167 /* ElementAccessExpression */: + return emitIndexedAccess(node); + case 168 /* CallExpression */: + return emitCallExpression(node); + case 169 /* NewExpression */: + return emitNewExpression(node); + case 170 /* TaggedTemplateExpression */: + return emitTaggedTemplateExpression(node); + case 171 /* TypeAssertionExpression */: + return emit(node.expression); + case 189 /* AsExpression */: + return emit(node.expression); + case 172 /* ParenthesizedExpression */: + return emitParenExpression(node); + case 213 /* FunctionDeclaration */: + case 173 /* FunctionExpression */: + case 174 /* ArrowFunction */: + return emitFunctionDeclaration(node); + case 175 /* DeleteExpression */: + return emitDeleteExpression(node); + case 176 /* TypeOfExpression */: + return emitTypeOfExpression(node); + case 177 /* VoidExpression */: + return emitVoidExpression(node); + case 178 /* AwaitExpression */: + return emitAwaitExpression(node); + case 179 /* PrefixUnaryExpression */: + return emitPrefixUnaryExpression(node); + case 180 /* PostfixUnaryExpression */: + return emitPostfixUnaryExpression(node); + case 181 /* BinaryExpression */: + return emitBinaryExpression(node); + case 182 /* ConditionalExpression */: + return emitConditionalExpression(node); + case 185 /* SpreadElementExpression */: + return emitSpreadElementExpression(node); + case 184 /* YieldExpression */: + return emitYieldExpression(node); + case 187 /* OmittedExpression */: + return; + case 192 /* Block */: + case 219 /* ModuleBlock */: + return emitBlock(node); + case 193 /* VariableStatement */: + return emitVariableStatement(node); + case 194 /* EmptyStatement */: + return write(";"); + case 195 /* ExpressionStatement */: + return emitExpressionStatement(node); + case 196 /* IfStatement */: + return emitIfStatement(node); + case 197 /* DoStatement */: + return emitDoStatement(node); + case 198 /* WhileStatement */: + return emitWhileStatement(node); + case 199 /* ForStatement */: + return emitForStatement(node); + case 201 /* ForOfStatement */: + case 200 /* ForInStatement */: + return emitForInOrForOfStatement(node); + case 202 /* ContinueStatement */: + case 203 /* BreakStatement */: + return emitBreakOrContinueStatement(node); + case 204 /* ReturnStatement */: + return emitReturnStatement(node); + case 205 /* WithStatement */: + return emitWithStatement(node); + case 206 /* SwitchStatement */: + return emitSwitchStatement(node); + case 241 /* CaseClause */: + case 242 /* DefaultClause */: + return emitCaseOrDefaultClause(node); + case 207 /* LabeledStatement */: + return emitLabelledStatement(node); + case 208 /* ThrowStatement */: + return emitThrowStatement(node); + case 209 /* TryStatement */: + return emitTryStatement(node); + case 244 /* CatchClause */: + return emitCatchClause(node); + case 210 /* DebuggerStatement */: + return emitDebuggerStatement(node); + case 211 /* VariableDeclaration */: + return emitVariableDeclaration(node); + case 186 /* ClassExpression */: + return emitClassExpression(node); + case 214 /* ClassDeclaration */: + return emitClassDeclaration(node); + case 215 /* InterfaceDeclaration */: + return emitInterfaceDeclaration(node); + case 217 /* EnumDeclaration */: + return emitEnumDeclaration(node); + case 247 /* EnumMember */: + return emitEnumMember(node); + case 218 /* ModuleDeclaration */: + return emitModuleDeclaration(node); + case 222 /* ImportDeclaration */: + return emitImportDeclaration(node); + case 221 /* ImportEqualsDeclaration */: + return emitImportEqualsDeclaration(node); + case 228 /* ExportDeclaration */: + return emitExportDeclaration(node); + case 227 /* ExportAssignment */: + return emitExportAssignment(node); + case 248 /* SourceFile */: + return emitSourceFileNode(node); + } + } + function hasDetachedComments(pos) { + return detachedCommentsInfo !== undefined && ts.lastOrUndefined(detachedCommentsInfo).nodePos === pos; + } + function getLeadingCommentsWithoutDetachedComments() { + // get the leading comments from detachedPos + var leadingComments = ts.getLeadingCommentRanges(currentSourceFile.text, ts.lastOrUndefined(detachedCommentsInfo).detachedCommentEndPos); + if (detachedCommentsInfo.length - 1) { + detachedCommentsInfo.pop(); + } + else { + detachedCommentsInfo = undefined; + } + return leadingComments; + } + function isPinnedComments(comment) { + return currentSourceFile.text.charCodeAt(comment.pos + 1) === 42 /* asterisk */ && + currentSourceFile.text.charCodeAt(comment.pos + 2) === 33 /* exclamation */; + } + /** + * Determine if the given comment is a triple-slash + * + * @return true if the comment is a triple-slash comment else false + **/ + function isTripleSlashComment(comment) { + // Verify this is /// comment, but do the regexp match only when we first can find /// in the comment text + // so that we don't end up computing comment string and doing match for all // comments + if (currentSourceFile.text.charCodeAt(comment.pos + 1) === 47 /* slash */ && + comment.pos + 2 < comment.end && + currentSourceFile.text.charCodeAt(comment.pos + 2) === 47 /* slash */) { + var textSubStr = currentSourceFile.text.substring(comment.pos, comment.end); + return textSubStr.match(ts.fullTripleSlashReferencePathRegEx) || + textSubStr.match(ts.fullTripleSlashAMDReferencePathRegEx) ? + true : false; + } + return false; + } + function getLeadingCommentsToEmit(node) { + // Emit the leading comments only if the parent's pos doesn't match because parent should take care of emitting these comments + if (node.parent) { + if (node.parent.kind === 248 /* SourceFile */ || node.pos !== node.parent.pos) { + if (hasDetachedComments(node.pos)) { + // get comments without detached comments + return getLeadingCommentsWithoutDetachedComments(); + } + else { + // get the leading comments from the node + return ts.getLeadingCommentRangesOfNode(node, currentSourceFile); + } + } + } + } + function getTrailingCommentsToEmit(node) { + // Emit the trailing comments only if the parent's pos doesn't match because parent should take care of emitting these comments + if (node.parent) { + if (node.parent.kind === 248 /* SourceFile */ || node.end !== node.parent.end) { + return ts.getTrailingCommentRanges(currentSourceFile.text, node.end); + } + } + } + /** + * Emit comments associated with node that will not be emitted into JS file + */ + function emitCommentsOnNotEmittedNode(node) { + emitLeadingCommentsWorker(node, /*isEmittedNode:*/ false); + } + function emitLeadingComments(node) { + return emitLeadingCommentsWorker(node, /*isEmittedNode:*/ true); + } + function emitLeadingCommentsWorker(node, isEmittedNode) { + if (compilerOptions.removeComments) { + return; + } + var leadingComments; + if (isEmittedNode) { + leadingComments = getLeadingCommentsToEmit(node); + } + else { + // If the node will not be emitted in JS, remove all the comments(normal, pinned and ///) associated with the node, + // unless it is a triple slash comment at the top of the file. + // For Example: + // /// + // declare var x; + // /// + // interface F {} + // The first /// will NOT be removed while the second one will be removed eventhough both node will not be emitted + if (node.pos === 0) { + leadingComments = ts.filter(getLeadingCommentsToEmit(node), isTripleSlashComment); + } + } + ts.emitNewLineBeforeLeadingComments(currentSourceFile, writer, node, leadingComments); + // Leading comments are emitted at /*leading comment1 */space/*leading comment*/space + ts.emitComments(currentSourceFile, writer, leadingComments, /*trailingSeparator:*/ true, newLine, writeComment); + } + function emitTrailingComments(node) { + if (compilerOptions.removeComments) { + return; + } + // Emit the trailing comments only if the parent's end doesn't match + var trailingComments = getTrailingCommentsToEmit(node); + // trailing comments are emitted at space/*trailing comment1 */space/*trailing comment*/ + ts.emitComments(currentSourceFile, writer, trailingComments, /*trailingSeparator*/ false, newLine, writeComment); + } + /** + * Emit trailing comments at the position. The term trailing comment is used here to describe following comment: + * x, /comment1/ y + * ^ => pos; the function will emit "comment1" in the emitJS + */ + function emitTrailingCommentsOfPosition(pos) { + if (compilerOptions.removeComments) { + return; + } + var trailingComments = ts.getTrailingCommentRanges(currentSourceFile.text, pos); + // trailing comments are emitted at space/*trailing comment1 */space/*trailing comment*/ + ts.emitComments(currentSourceFile, writer, trailingComments, /*trailingSeparator*/ true, newLine, writeComment); + } + function emitLeadingCommentsOfPositionWorker(pos) { + if (compilerOptions.removeComments) { + return; + } + var leadingComments; + if (hasDetachedComments(pos)) { + // get comments without detached comments + leadingComments = getLeadingCommentsWithoutDetachedComments(); + } + else { + // get the leading comments from the node + leadingComments = ts.getLeadingCommentRanges(currentSourceFile.text, pos); + } + ts.emitNewLineBeforeLeadingComments(currentSourceFile, writer, { pos: pos, end: pos }, leadingComments); + // Leading comments are emitted at /*leading comment1 */space/*leading comment*/space + ts.emitComments(currentSourceFile, writer, leadingComments, /*trailingSeparator*/ true, newLine, writeComment); + } + function emitDetachedComments(node) { + var leadingComments; + if (compilerOptions.removeComments) { + // removeComments is true, only reserve pinned comment at the top of file + // For example: + // /*! Pinned Comment */ + // + // var x = 10; + if (node.pos === 0) { + leadingComments = ts.filter(ts.getLeadingCommentRanges(currentSourceFile.text, node.pos), isPinnedComments); + } + } + else { + // removeComments is false, just get detached as normal and bypass the process to filter comment + leadingComments = ts.getLeadingCommentRanges(currentSourceFile.text, node.pos); + } + if (leadingComments) { + var detachedComments = []; + var lastComment; + ts.forEach(leadingComments, function (comment) { + if (lastComment) { + var lastCommentLine = ts.getLineOfLocalPosition(currentSourceFile, lastComment.end); + var commentLine = ts.getLineOfLocalPosition(currentSourceFile, comment.pos); + if (commentLine >= lastCommentLine + 2) { + // There was a blank line between the last comment and this comment. This + // comment is not part of the copyright comments. Return what we have so + // far. + return detachedComments; + } + } + detachedComments.push(comment); + lastComment = comment; + }); + if (detachedComments.length) { + // All comments look like they could have been part of the copyright header. Make + // sure there is at least one blank line between it and the node. If not, it's not + // a copyright header. + var lastCommentLine = ts.getLineOfLocalPosition(currentSourceFile, ts.lastOrUndefined(detachedComments).end); + var nodeLine = ts.getLineOfLocalPosition(currentSourceFile, ts.skipTrivia(currentSourceFile.text, node.pos)); + if (nodeLine >= lastCommentLine + 2) { + // Valid detachedComments + ts.emitNewLineBeforeLeadingComments(currentSourceFile, writer, node, leadingComments); + ts.emitComments(currentSourceFile, writer, detachedComments, /*trailingSeparator*/ true, newLine, writeComment); + var currentDetachedCommentInfo = { nodePos: node.pos, detachedCommentEndPos: ts.lastOrUndefined(detachedComments).end }; + if (detachedCommentsInfo) { + detachedCommentsInfo.push(currentDetachedCommentInfo); + } + else { + detachedCommentsInfo = [currentDetachedCommentInfo]; + } + } + } + } + } + function emitShebang() { + var shebang = ts.getShebang(currentSourceFile.text); + if (shebang) { + write(shebang); + } + } + var _a; + } + function emitFile(jsFilePath, sourceFile) { + emitJavaScript(jsFilePath, sourceFile); + if (compilerOptions.declaration) { + ts.writeDeclarationFile(jsFilePath, sourceFile, host, resolver, diagnostics); + } + } + } + ts.emitFiles = emitFiles; })(ts || (ts = {})); /// /// @@ -35311,11 +35997,11 @@ var ts; if (ts.getRootLength(moduleName) !== 0 || nameStartsWithDotSlashOrDotDotSlash(moduleName)) { var failedLookupLocations = []; var candidate = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName)); - var resolvedFileName = loadNodeModuleFromFile(candidate, /* loadOnlyDts */ false, failedLookupLocations, host); + var resolvedFileName = loadNodeModuleFromFile(candidate, failedLookupLocations, host); if (resolvedFileName) { return { resolvedModule: { resolvedFileName: resolvedFileName }, failedLookupLocations: failedLookupLocations }; } - resolvedFileName = loadNodeModuleFromDirectory(candidate, /* loadOnlyDts */ false, failedLookupLocations, host); + resolvedFileName = loadNodeModuleFromDirectory(candidate, failedLookupLocations, host); return resolvedFileName ? { resolvedModule: { resolvedFileName: resolvedFileName }, failedLookupLocations: failedLookupLocations } : { resolvedModule: undefined, failedLookupLocations: failedLookupLocations }; @@ -35325,13 +36011,8 @@ var ts; } } ts.nodeModuleNameResolver = nodeModuleNameResolver; - function loadNodeModuleFromFile(candidate, loadOnlyDts, failedLookupLocation, host) { - if (loadOnlyDts) { - return tryLoad(".d.ts"); - } - else { - return ts.forEach(ts.supportedExtensions, tryLoad); - } + function loadNodeModuleFromFile(candidate, failedLookupLocation, host) { + return ts.forEach(ts.supportedJsExtensions, tryLoad); function tryLoad(ext) { var fileName = ts.fileExtensionIs(candidate, ext) ? candidate : candidate + ext; if (host.fileExists(fileName)) { @@ -35343,7 +36024,7 @@ var ts; } } } - function loadNodeModuleFromDirectory(candidate, loadOnlyDts, failedLookupLocation, host) { + function loadNodeModuleFromDirectory(candidate, failedLookupLocation, host) { var packageJsonPath = ts.combinePaths(candidate, "package.json"); if (host.fileExists(packageJsonPath)) { var jsonContent; @@ -35356,7 +36037,7 @@ var ts; jsonContent = { typings: undefined }; } if (jsonContent.typings) { - var result = loadNodeModuleFromFile(ts.normalizePath(ts.combinePaths(candidate, jsonContent.typings)), loadOnlyDts, failedLookupLocation, host); + var result = loadNodeModuleFromFile(ts.normalizePath(ts.combinePaths(candidate, jsonContent.typings)), failedLookupLocation, host); if (result) { return result; } @@ -35366,7 +36047,7 @@ var ts; // record package json as one of failed lookup locations - in the future if this file will appear it will invalidate resolution results failedLookupLocation.push(packageJsonPath); } - return loadNodeModuleFromFile(ts.combinePaths(candidate, "index"), loadOnlyDts, failedLookupLocation, host); + return loadNodeModuleFromFile(ts.combinePaths(candidate, "index"), failedLookupLocation, host); } function loadModuleFromNodeModules(moduleName, directory, host) { var failedLookupLocations = []; @@ -35376,11 +36057,11 @@ var ts; if (baseName !== "node_modules") { var nodeModulesFolder = ts.combinePaths(directory, "node_modules"); var candidate = ts.normalizePath(ts.combinePaths(nodeModulesFolder, moduleName)); - var result = loadNodeModuleFromFile(candidate, /* loadOnlyDts */ true, failedLookupLocations, host); + var result = loadNodeModuleFromFile(candidate, failedLookupLocations, host); if (result) { return { resolvedModule: { resolvedFileName: result, isExternalLibraryImport: true }, failedLookupLocations: failedLookupLocations }; } - result = loadNodeModuleFromDirectory(candidate, /* loadOnlyDts */ true, failedLookupLocations, host); + result = loadNodeModuleFromDirectory(candidate, failedLookupLocations, host); if (result) { return { resolvedModule: { resolvedFileName: result, isExternalLibraryImport: true }, failedLookupLocations: failedLookupLocations }; } @@ -35399,16 +36080,17 @@ var ts; } function classicNameResolver(moduleName, containingFile, compilerOptions, host) { // module names that contain '!' are used to reference resources and are not resolved to actual files on disk - if (moduleName.indexOf('!') != -1) { + if (moduleName.indexOf("!") != -1) { return { resolvedModule: undefined, failedLookupLocations: [] }; } var searchPath = ts.getDirectoryPath(containingFile); var searchName; var failedLookupLocations = []; var referencedSourceFile; + var extensions = compilerOptions.allowNonTsExtensions ? ts.supportedJsExtensions : ts.supportedExtensions; while (true) { searchName = ts.normalizePath(ts.combinePaths(searchPath, moduleName)); - referencedSourceFile = ts.forEach(ts.supportedExtensions, function (extension) { + referencedSourceFile = ts.forEach(extensions, function (extension) { if (extension === ".tsx" && !compilerOptions.jsx) { // resolve .tsx files only if jsx support is enabled // 'logical not' handles both undefined and None cases @@ -35746,7 +36428,9 @@ var ts; return emitResult; } function getSourceFile(fileName) { - return filesByName.get(fileName); + // first try to use file name as is to find file + // then try to convert relative file name to absolute and use it to retrieve source file + return filesByName.get(fileName) || filesByName.get(ts.getNormalizedAbsolutePath(fileName, host.getCurrentDirectory())); } function getDiagnosticsHelper(sourceFile, getDiagnostics, cancellationToken) { if (sourceFile) { @@ -35842,13 +36526,18 @@ var ts; if (file.imports) { return; } + var isJavaScriptFile = ts.isSourceFileJavaScript(file); var imports; for (var _i = 0, _a = file.statements; _i < _a.length; _i++) { var node = _a[_i]; + collect(node, /* allowRelativeModuleNames */ true); + } + file.imports = imports || emptyArray; + function collect(node, allowRelativeModuleNames) { switch (node.kind) { - case 220 /* ImportDeclaration */: - case 219 /* ImportEqualsDeclaration */: - case 226 /* ExportDeclaration */: + case 222 /* ImportDeclaration */: + case 221 /* ImportEqualsDeclaration */: + case 228 /* ExportDeclaration */: var moduleNameExpr = ts.getExternalModuleName(node); if (!moduleNameExpr || moduleNameExpr.kind !== 9 /* StringLiteral */) { break; @@ -35856,9 +36545,24 @@ var ts; if (!moduleNameExpr.text) { break; } - (imports || (imports = [])).push(moduleNameExpr); + if (allowRelativeModuleNames || !ts.isExternalModuleNameRelative(moduleNameExpr.text)) { + (imports || (imports = [])).push(moduleNameExpr); + } break; - case 216 /* ModuleDeclaration */: + case 168 /* CallExpression */: + if (isJavaScriptFile && ts.isRequireCall(node)) { + var jsImports = node.arguments; + if (jsImports) { + imports = (imports || []); + for (var i = 0; i < jsImports.length; i++) { + if (jsImports[i].kind === 9 /* StringLiteral */) { + imports.push(jsImports[i]); + } + } + } + } + break; + case 218 /* ModuleDeclaration */: if (node.name.kind === 9 /* StringLiteral */ && (node.flags & 2 /* Ambient */ || ts.isDeclarationFile(file))) { // TypeScript 1.0 spec (April 2014): 12.1.6 // An AmbientExternalModuleDeclaration declares an external module. @@ -35866,22 +36570,18 @@ var ts; // The StringLiteral must specify a top - level external module name. // Relative external module names are not permitted ts.forEachChild(node.body, function (node) { - if (ts.isExternalModuleImportEqualsDeclaration(node) && - ts.getExternalModuleImportEqualsDeclarationExpression(node).kind === 9 /* StringLiteral */) { - var moduleName = ts.getExternalModuleImportEqualsDeclarationExpression(node); - // TypeScript 1.0 spec (April 2014): 12.1.6 - // An ExternalImportDeclaration in anAmbientExternalModuleDeclaration may reference other external modules - // only through top - level external module names. Relative external module names are not permitted. - if (moduleName) { - (imports || (imports = [])).push(moduleName); - } - } + // TypeScript 1.0 spec (April 2014): 12.1.6 + // An ExternalImportDeclaration in anAmbientExternalModuleDeclaration may reference other external modules + // only through top - level external module names. Relative external module names are not permitted. + collect(node, /* allowRelativeModuleNames */ false); }); } break; } + if (ts.isSourceFileJavaScript(file)) { + ts.forEachChild(node, function (node) { return collect(node, allowRelativeModuleNames); }); + } } - file.imports = imports || emptyArray; } function processSourceFile(fileName, isDefaultLib, refFile, refPos, refEnd) { var diagnosticArgument; @@ -35925,52 +36625,52 @@ var ts; } // Get source file from normalized fileName function findSourceFile(fileName, isDefaultLib, refFile, refPos, refEnd) { - var canonicalName = host.getCanonicalFileName(ts.normalizeSlashes(fileName)); - if (filesByName.contains(canonicalName)) { + if (filesByName.contains(fileName)) { // We've already looked for this file, use cached result - return getSourceFileFromCache(fileName, canonicalName, /*useAbsolutePath*/ false); + return getSourceFileFromCache(fileName, /*useAbsolutePath*/ false); } - else { - var normalizedAbsolutePath = ts.getNormalizedAbsolutePath(fileName, host.getCurrentDirectory()); - var canonicalAbsolutePath = host.getCanonicalFileName(normalizedAbsolutePath); - if (filesByName.contains(canonicalAbsolutePath)) { - return getSourceFileFromCache(normalizedAbsolutePath, canonicalAbsolutePath, /*useAbsolutePath*/ true); - } - // We haven't looked for this file, do so now and cache result - var file = host.getSourceFile(fileName, options.target, function (hostErrorMessage) { - if (refFile !== undefined && refPos !== undefined && refEnd !== undefined) { - fileProcessingDiagnostics.add(ts.createFileDiagnostic(refFile, refPos, refEnd - refPos, ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage)); - } - else { - fileProcessingDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage)); - } - }); - filesByName.set(canonicalName, file); - if (file) { - skipDefaultLib = skipDefaultLib || file.hasNoDefaultLib; - // Set the source file for normalized absolute path - filesByName.set(canonicalAbsolutePath, file); - var basePath = ts.getDirectoryPath(fileName); - if (!options.noResolve) { - processReferencedFiles(file, basePath); - } - // always process imported modules to record module name resolutions - processImportedModules(file, basePath); - if (isDefaultLib) { - file.isDefaultLib = true; - files.unshift(file); - } - else { - files.push(file); - } - } - return file; + var normalizedAbsolutePath = ts.getNormalizedAbsolutePath(fileName, host.getCurrentDirectory()); + if (filesByName.contains(normalizedAbsolutePath)) { + var file_1 = getSourceFileFromCache(normalizedAbsolutePath, /*useAbsolutePath*/ true); + // we don't have resolution for this relative file name but the match was found by absolute file name + // store resolution for relative name as well + filesByName.set(fileName, file_1); + return file_1; } - function getSourceFileFromCache(fileName, canonicalName, useAbsolutePath) { - var file = filesByName.get(canonicalName); + // We haven't looked for this file, do so now and cache result + var file = host.getSourceFile(fileName, options.target, function (hostErrorMessage) { + if (refFile !== undefined && refPos !== undefined && refEnd !== undefined) { + fileProcessingDiagnostics.add(ts.createFileDiagnostic(refFile, refPos, refEnd - refPos, ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage)); + } + else { + fileProcessingDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage)); + } + }); + filesByName.set(fileName, file); + if (file) { + skipDefaultLib = skipDefaultLib || file.hasNoDefaultLib; + // Set the source file for normalized absolute path + filesByName.set(normalizedAbsolutePath, file); + var basePath = ts.getDirectoryPath(fileName); + if (!options.noResolve) { + processReferencedFiles(file, basePath); + } + // always process imported modules to record module name resolutions + processImportedModules(file, basePath); + if (isDefaultLib) { + file.isDefaultLib = true; + files.unshift(file); + } + else { + files.push(file); + } + } + return file; + function getSourceFileFromCache(fileName, useAbsolutePath) { + var file = filesByName.get(fileName); if (file && host.useCaseSensitiveFileNames()) { var sourceFileName = useAbsolutePath ? ts.getNormalizedAbsolutePath(file.fileName, host.getCurrentDirectory()) : file.fileName; - if (canonicalName !== sourceFileName) { + if (ts.normalizeSlashes(fileName) !== ts.normalizeSlashes(sourceFileName)) { if (refFile !== undefined && refPos !== undefined && refEnd !== undefined) { fileProcessingDiagnostics.add(ts.createFileDiagnostic(refFile, refPos, refEnd - refPos, ts.Diagnostics.File_name_0_differs_from_already_included_file_name_1_only_in_casing, fileName, sourceFileName)); } @@ -36138,9 +36838,9 @@ var ts; var span = ts.getErrorSpanForNode(firstExternalModuleSourceFile, firstExternalModuleSourceFile.externalModuleIndicator); programDiagnostics.add(ts.createFileDiagnostic(firstExternalModuleSourceFile, span.start, span.length, ts.Diagnostics.Cannot_compile_modules_unless_the_module_flag_is_provided)); } - // Cannot specify module gen target when in es6 or above - if (options.module && languageVersion >= 2 /* ES6 */) { - programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_compile_modules_into_commonjs_amd_system_or_umd_when_targeting_ES6_or_higher)); + // Cannot specify module gen target of es6 when below es6 + if (options.module === 5 /* ES6 */ && languageVersion < 2 /* ES6 */) { + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_compile_modules_into_es6_when_targeting_ES5_or_lower)); } // there has to be common source directory if user specified --outdir || --sourceRoot // if user specified --mapRoot, there needs to be common source directory if there would be multiple files being emitted @@ -36181,10 +36881,6 @@ var ts; !options.experimentalDecorators) { programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "emitDecoratorMetadata", "experimentalDecorators")); } - if (options.experimentalAsyncFunctions && - options.target !== 2 /* ES6 */) { - programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_experimentalAsyncFunctions_cannot_be_specified_when_targeting_ES5_or_lower)); - } } } ts.createProgram = createProgram; @@ -36266,11 +36962,12 @@ var ts; "commonjs": 1 /* CommonJS */, "amd": 2 /* AMD */, "system": 4 /* System */, - "umd": 3 /* UMD */ + "umd": 3 /* UMD */, + "es6": 5 /* ES6 */ }, - description: ts.Diagnostics.Specify_module_code_generation_Colon_commonjs_amd_system_or_umd, + description: ts.Diagnostics.Specify_module_code_generation_Colon_commonjs_amd_system_umd_or_es6, paramType: ts.Diagnostics.KIND, - error: ts.Diagnostics.Argument_for_module_option_must_be_commonjs_amd_system_or_umd + error: ts.Diagnostics.Argument_for_module_option_must_be_commonjs_amd_system_umd_or_es6 }, { name: "newLine", @@ -36412,11 +37109,6 @@ var ts; type: "boolean", description: ts.Diagnostics.Watch_input_files }, - { - name: "experimentalAsyncFunctions", - type: "boolean", - description: ts.Diagnostics.Enables_experimental_support_for_ES7_async_functions - }, { name: "experimentalDecorators", type: "boolean", @@ -36622,6 +37314,9 @@ var ts; } if (opt.isFilePath) { value = ts.normalizePath(ts.combinePaths(basePath, value)); + if (value === "") { + value = "."; + } } options[opt.name] = value; } @@ -36650,20 +37345,20 @@ var ts; var exclude = json["exclude"] instanceof Array ? ts.map(json["exclude"], ts.normalizeSlashes) : undefined; var sysFiles = host.readDirectory(basePath, ".ts", exclude).concat(host.readDirectory(basePath, ".tsx", exclude)); for (var i = 0; i < sysFiles.length; i++) { - var name_27 = sysFiles[i]; - if (ts.fileExtensionIs(name_27, ".d.ts")) { - var baseName = name_27.substr(0, name_27.length - ".d.ts".length); + var name_28 = sysFiles[i]; + if (ts.fileExtensionIs(name_28, ".d.ts")) { + var baseName = name_28.substr(0, name_28.length - ".d.ts".length); if (!ts.contains(sysFiles, baseName + ".tsx") && !ts.contains(sysFiles, baseName + ".ts")) { - fileNames.push(name_27); + fileNames.push(name_28); } } - else if (ts.fileExtensionIs(name_27, ".ts")) { - if (!ts.contains(sysFiles, name_27 + "x")) { - fileNames.push(name_27); + else if (ts.fileExtensionIs(name_28, ".ts")) { + if (!ts.contains(sysFiles, name_28 + "x")) { + fileNames.push(name_28); } } else { - fileNames.push(name_27); + fileNames.push(name_28); } } } @@ -36744,7 +37439,7 @@ var ts; } } function autoCollapse(node) { - return ts.isFunctionBlock(node) && node.parent.kind !== 172 /* ArrowFunction */; + return ts.isFunctionBlock(node) && node.parent.kind !== 174 /* ArrowFunction */; } var depth = 0; var maxDepth = 20; @@ -36756,7 +37451,7 @@ var ts; addOutliningForLeadingCommentsForNode(n); } switch (n.kind) { - case 190 /* Block */: + case 192 /* Block */: if (!ts.isFunctionBlock(n)) { var parent_7 = n.parent; var openBrace = ts.findChildOfKind(n, 15 /* OpenBraceToken */, sourceFile); @@ -36764,18 +37459,18 @@ var ts; // Check if the block is standalone, or 'attached' to some parent statement. // If the latter, we want to collaps the block, but consider its hint span // to be the entire span of the parent. - if (parent_7.kind === 195 /* DoStatement */ || - parent_7.kind === 198 /* ForInStatement */ || - parent_7.kind === 199 /* ForOfStatement */ || - parent_7.kind === 197 /* ForStatement */ || - parent_7.kind === 194 /* IfStatement */ || - parent_7.kind === 196 /* WhileStatement */ || - parent_7.kind === 203 /* WithStatement */ || - parent_7.kind === 242 /* CatchClause */) { + if (parent_7.kind === 197 /* DoStatement */ || + parent_7.kind === 200 /* ForInStatement */ || + parent_7.kind === 201 /* ForOfStatement */ || + parent_7.kind === 199 /* ForStatement */ || + parent_7.kind === 196 /* IfStatement */ || + parent_7.kind === 198 /* WhileStatement */ || + parent_7.kind === 205 /* WithStatement */ || + parent_7.kind === 244 /* CatchClause */) { addOutliningSpan(parent_7, openBrace, closeBrace, autoCollapse(n)); break; } - if (parent_7.kind === 207 /* TryStatement */) { + if (parent_7.kind === 209 /* TryStatement */) { // Could be the try-block, or the finally-block. var tryStatement = parent_7; if (tryStatement.tryBlock === n) { @@ -36783,7 +37478,7 @@ var ts; break; } else if (tryStatement.finallyBlock === n) { - var finallyKeyword = ts.findChildOfKind(tryStatement, 83 /* FinallyKeyword */, sourceFile); + var finallyKeyword = ts.findChildOfKind(tryStatement, 85 /* FinallyKeyword */, sourceFile); if (finallyKeyword) { addOutliningSpan(finallyKeyword, openBrace, closeBrace, autoCollapse(n)); break; @@ -36802,23 +37497,23 @@ var ts; break; } // Fallthrough. - case 217 /* ModuleBlock */: { + case 219 /* ModuleBlock */: { var openBrace = ts.findChildOfKind(n, 15 /* OpenBraceToken */, sourceFile); var closeBrace = ts.findChildOfKind(n, 16 /* CloseBraceToken */, sourceFile); addOutliningSpan(n.parent, openBrace, closeBrace, autoCollapse(n)); break; } - case 212 /* ClassDeclaration */: - case 213 /* InterfaceDeclaration */: - case 215 /* EnumDeclaration */: - case 163 /* ObjectLiteralExpression */: - case 218 /* CaseBlock */: { + case 214 /* ClassDeclaration */: + case 215 /* InterfaceDeclaration */: + case 217 /* EnumDeclaration */: + case 165 /* ObjectLiteralExpression */: + case 220 /* CaseBlock */: { var openBrace = ts.findChildOfKind(n, 15 /* OpenBraceToken */, sourceFile); var closeBrace = ts.findChildOfKind(n, 16 /* CloseBraceToken */, sourceFile); addOutliningSpan(n, openBrace, closeBrace, autoCollapse(n)); break; } - case 162 /* ArrayLiteralExpression */: + case 164 /* ArrayLiteralExpression */: var openBracket = ts.findChildOfKind(n, 19 /* OpenBracketToken */, sourceFile); var closeBracket = ts.findChildOfKind(n, 20 /* CloseBracketToken */, sourceFile); addOutliningSpan(n, openBracket, closeBracket, autoCollapse(n)); @@ -36846,12 +37541,12 @@ var ts; ts.forEach(program.getSourceFiles(), function (sourceFile) { cancellationToken.throwIfCancellationRequested(); var nameToDeclarations = sourceFile.getNamedDeclarations(); - for (var name_28 in nameToDeclarations) { - var declarations = ts.getProperty(nameToDeclarations, name_28); + for (var name_29 in nameToDeclarations) { + var declarations = ts.getProperty(nameToDeclarations, name_29); if (declarations) { // First do a quick check to see if the name of the declaration matches the // last portion of the (possibly) dotted name they're searching for. - var matches = patternMatcher.getMatchesForLastSegmentOfPattern(name_28); + var matches = patternMatcher.getMatchesForLastSegmentOfPattern(name_29); if (!matches) { continue; } @@ -36864,14 +37559,14 @@ var ts; if (!containers) { return undefined; } - matches = patternMatcher.getMatches(containers, name_28); + matches = patternMatcher.getMatches(containers, name_29); if (!matches) { continue; } } var fileName = sourceFile.fileName; var matchKind = bestMatchKind(matches); - rawItems.push({ name: name_28, fileName: fileName, matchKind: matchKind, isCaseSensitive: allMatchesAreCaseSensitive(matches), declaration: declaration }); + rawItems.push({ name: name_29, fileName: fileName, matchKind: matchKind, isCaseSensitive: allMatchesAreCaseSensitive(matches), declaration: declaration }); } } } @@ -36895,7 +37590,7 @@ var ts; } function getTextOfIdentifierOrLiteral(node) { if (node) { - if (node.kind === 67 /* Identifier */ || + if (node.kind === 69 /* Identifier */ || node.kind === 9 /* StringLiteral */ || node.kind === 8 /* NumericLiteral */) { return node.text; @@ -36909,7 +37604,7 @@ var ts; if (text !== undefined) { containers.unshift(text); } - else if (declaration.name.kind === 134 /* ComputedPropertyName */) { + else if (declaration.name.kind === 136 /* ComputedPropertyName */) { return tryAddComputedPropertyName(declaration.name.expression, containers, /*includeLastPortion:*/ true); } else { @@ -36930,7 +37625,7 @@ var ts; } return true; } - if (expression.kind === 164 /* PropertyAccessExpression */) { + if (expression.kind === 166 /* PropertyAccessExpression */) { var propertyAccess = expression; if (includeLastPortion) { containers.unshift(propertyAccess.name.text); @@ -36943,7 +37638,7 @@ var ts; var containers = []; // First, if we started with a computed property name, then add all but the last // portion into the container array. - if (declaration.name.kind === 134 /* ComputedPropertyName */) { + if (declaration.name.kind === 136 /* ComputedPropertyName */) { if (!tryAddComputedPropertyName(declaration.name.expression, containers, /*includeLastPortion:*/ false)) { return undefined; } @@ -37019,17 +37714,17 @@ var ts; var current = node.parent; while (current) { switch (current.kind) { - case 216 /* ModuleDeclaration */: + case 218 /* ModuleDeclaration */: // If we have a module declared as A.B.C, it is more "intuitive" // to say it only has a single layer of depth do { current = current.parent; - } while (current.kind === 216 /* ModuleDeclaration */); + } while (current.kind === 218 /* ModuleDeclaration */); // fall through - case 212 /* ClassDeclaration */: - case 215 /* EnumDeclaration */: - case 213 /* InterfaceDeclaration */: - case 211 /* FunctionDeclaration */: + case 214 /* ClassDeclaration */: + case 217 /* EnumDeclaration */: + case 215 /* InterfaceDeclaration */: + case 213 /* FunctionDeclaration */: indent++; } current = current.parent; @@ -37040,21 +37735,21 @@ var ts; var childNodes = []; function visit(node) { switch (node.kind) { - case 191 /* VariableStatement */: + case 193 /* VariableStatement */: ts.forEach(node.declarationList.declarations, visit); break; - case 159 /* ObjectBindingPattern */: - case 160 /* ArrayBindingPattern */: + case 161 /* ObjectBindingPattern */: + case 162 /* ArrayBindingPattern */: ts.forEach(node.elements, visit); break; - case 226 /* ExportDeclaration */: + case 228 /* ExportDeclaration */: // Handle named exports case e.g.: // export {a, b as B} from "mod"; if (node.exportClause) { ts.forEach(node.exportClause.elements, visit); } break; - case 220 /* ImportDeclaration */: + case 222 /* ImportDeclaration */: var importClause = node.importClause; if (importClause) { // Handle default import case e.g.: @@ -37066,7 +37761,7 @@ var ts; // import * as NS from "mod"; // import {a, b as B} from "mod"; if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 222 /* NamespaceImport */) { + if (importClause.namedBindings.kind === 224 /* NamespaceImport */) { childNodes.push(importClause.namedBindings); } else { @@ -37075,21 +37770,21 @@ var ts; } } break; - case 161 /* BindingElement */: - case 209 /* VariableDeclaration */: + case 163 /* BindingElement */: + case 211 /* VariableDeclaration */: if (ts.isBindingPattern(node.name)) { visit(node.name); break; } // Fall through - case 212 /* ClassDeclaration */: - case 215 /* EnumDeclaration */: - case 213 /* InterfaceDeclaration */: - case 216 /* ModuleDeclaration */: - case 211 /* FunctionDeclaration */: - case 219 /* ImportEqualsDeclaration */: - case 224 /* ImportSpecifier */: - case 228 /* ExportSpecifier */: + case 214 /* ClassDeclaration */: + case 217 /* EnumDeclaration */: + case 215 /* InterfaceDeclaration */: + case 218 /* ModuleDeclaration */: + case 213 /* FunctionDeclaration */: + case 221 /* ImportEqualsDeclaration */: + case 226 /* ImportSpecifier */: + case 230 /* ExportSpecifier */: childNodes.push(node); break; } @@ -37137,17 +37832,17 @@ var ts; for (var _i = 0; _i < nodes.length; _i++) { var node = nodes[_i]; switch (node.kind) { - case 212 /* ClassDeclaration */: - case 215 /* EnumDeclaration */: - case 213 /* InterfaceDeclaration */: + case 214 /* ClassDeclaration */: + case 217 /* EnumDeclaration */: + case 215 /* InterfaceDeclaration */: topLevelNodes.push(node); break; - case 216 /* ModuleDeclaration */: + case 218 /* ModuleDeclaration */: var moduleDeclaration = node; topLevelNodes.push(node); addTopLevelNodes(getInnermostModule(moduleDeclaration).body.statements, topLevelNodes); break; - case 211 /* FunctionDeclaration */: + case 213 /* FunctionDeclaration */: var functionDeclaration = node; if (isTopLevelFunctionDeclaration(functionDeclaration)) { topLevelNodes.push(node); @@ -37158,12 +37853,12 @@ var ts; } } function isTopLevelFunctionDeclaration(functionDeclaration) { - if (functionDeclaration.kind === 211 /* FunctionDeclaration */) { + if (functionDeclaration.kind === 213 /* FunctionDeclaration */) { // A function declaration is 'top level' if it contains any function declarations // within it. - if (functionDeclaration.body && functionDeclaration.body.kind === 190 /* Block */) { + if (functionDeclaration.body && functionDeclaration.body.kind === 192 /* Block */) { // Proper function declarations can only have identifier names - if (ts.forEach(functionDeclaration.body.statements, function (s) { return s.kind === 211 /* FunctionDeclaration */ && !isEmpty(s.name.text); })) { + if (ts.forEach(functionDeclaration.body.statements, function (s) { return s.kind === 213 /* FunctionDeclaration */ && !isEmpty(s.name.text); })) { return true; } // Or if it is not parented by another function. i.e all functions @@ -37223,7 +37918,7 @@ var ts; } function createChildItem(node) { switch (node.kind) { - case 136 /* Parameter */: + case 138 /* Parameter */: if (ts.isBindingPattern(node.name)) { break; } @@ -37231,36 +37926,36 @@ var ts; return undefined; } return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberVariableElement); - case 141 /* MethodDeclaration */: - case 140 /* MethodSignature */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberFunctionElement); - case 143 /* GetAccessor */: + case 145 /* GetAccessor */: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberGetAccessorElement); - case 144 /* SetAccessor */: + case 146 /* SetAccessor */: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberSetAccessorElement); - case 147 /* IndexSignature */: + case 149 /* IndexSignature */: return createItem(node, "[]", ts.ScriptElementKind.indexSignatureElement); - case 245 /* EnumMember */: + case 247 /* EnumMember */: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberVariableElement); - case 145 /* CallSignature */: + case 147 /* CallSignature */: return createItem(node, "()", ts.ScriptElementKind.callSignatureElement); - case 146 /* ConstructSignature */: + case 148 /* ConstructSignature */: return createItem(node, "new()", ts.ScriptElementKind.constructSignatureElement); - case 139 /* PropertyDeclaration */: - case 138 /* PropertySignature */: + case 141 /* PropertyDeclaration */: + case 140 /* PropertySignature */: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberVariableElement); - case 211 /* FunctionDeclaration */: + case 213 /* FunctionDeclaration */: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.functionElement); - case 209 /* VariableDeclaration */: - case 161 /* BindingElement */: + case 211 /* VariableDeclaration */: + case 163 /* BindingElement */: var variableDeclarationNode; - var name_29; - if (node.kind === 161 /* BindingElement */) { - name_29 = node.name; + var name_30; + if (node.kind === 163 /* BindingElement */) { + name_30 = node.name; variableDeclarationNode = node; // binding elements are added only for variable declarations // bubble up to the containing variable declaration - while (variableDeclarationNode && variableDeclarationNode.kind !== 209 /* VariableDeclaration */) { + while (variableDeclarationNode && variableDeclarationNode.kind !== 211 /* VariableDeclaration */) { variableDeclarationNode = variableDeclarationNode.parent; } ts.Debug.assert(variableDeclarationNode !== undefined); @@ -37268,24 +37963,24 @@ var ts; else { ts.Debug.assert(!ts.isBindingPattern(node.name)); variableDeclarationNode = node; - name_29 = node.name; + name_30 = node.name; } if (ts.isConst(variableDeclarationNode)) { - return createItem(node, getTextOfNode(name_29), ts.ScriptElementKind.constElement); + return createItem(node, getTextOfNode(name_30), ts.ScriptElementKind.constElement); } else if (ts.isLet(variableDeclarationNode)) { - return createItem(node, getTextOfNode(name_29), ts.ScriptElementKind.letElement); + return createItem(node, getTextOfNode(name_30), ts.ScriptElementKind.letElement); } else { - return createItem(node, getTextOfNode(name_29), ts.ScriptElementKind.variableElement); + return createItem(node, getTextOfNode(name_30), ts.ScriptElementKind.variableElement); } - case 142 /* Constructor */: + case 144 /* Constructor */: return createItem(node, "constructor", ts.ScriptElementKind.constructorImplementationElement); - case 228 /* ExportSpecifier */: - case 224 /* ImportSpecifier */: - case 219 /* ImportEqualsDeclaration */: - case 221 /* ImportClause */: - case 222 /* NamespaceImport */: + case 230 /* ExportSpecifier */: + case 226 /* ImportSpecifier */: + case 221 /* ImportEqualsDeclaration */: + case 223 /* ImportClause */: + case 224 /* NamespaceImport */: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.alias); } return undefined; @@ -37315,17 +38010,17 @@ var ts; } function createTopLevelItem(node) { switch (node.kind) { - case 246 /* SourceFile */: + case 248 /* SourceFile */: return createSourceFileItem(node); - case 212 /* ClassDeclaration */: + case 214 /* ClassDeclaration */: return createClassItem(node); - case 215 /* EnumDeclaration */: + case 217 /* EnumDeclaration */: return createEnumItem(node); - case 213 /* InterfaceDeclaration */: + case 215 /* InterfaceDeclaration */: return createIterfaceItem(node); - case 216 /* ModuleDeclaration */: + case 218 /* ModuleDeclaration */: return createModuleItem(node); - case 211 /* FunctionDeclaration */: + case 213 /* FunctionDeclaration */: return createFunctionItem(node); } return undefined; @@ -37337,7 +38032,7 @@ var ts; // Otherwise, we need to aggregate each identifier to build up the qualified name. var result = []; result.push(moduleDeclaration.name.text); - while (moduleDeclaration.body && moduleDeclaration.body.kind === 216 /* ModuleDeclaration */) { + while (moduleDeclaration.body && moduleDeclaration.body.kind === 218 /* ModuleDeclaration */) { moduleDeclaration = moduleDeclaration.body; result.push(moduleDeclaration.name.text); } @@ -37349,7 +38044,7 @@ var ts; return getNavigationBarItem(moduleName, ts.ScriptElementKind.moduleElement, ts.getNodeModifiers(node), [getNodeSpan(node)], childItems, getIndent(node)); } function createFunctionItem(node) { - if (node.body && node.body.kind === 190 /* Block */) { + if (node.body && node.body.kind === 192 /* Block */) { var childItems = getItemsWorker(sortNodes(node.body.statements), createChildItem); return getNavigationBarItem(!node.name ? "default" : node.name.text, ts.ScriptElementKind.functionElement, ts.getNodeModifiers(node), [getNodeSpan(node)], childItems, getIndent(node)); } @@ -37370,7 +38065,7 @@ var ts; var childItems; if (node.members) { var constructor = ts.forEach(node.members, function (member) { - return member.kind === 142 /* Constructor */ && member; + return member.kind === 144 /* Constructor */ && member; }); // Add the constructor parameters in as children of the class (for property parameters). // Note that *all non-binding pattern named* parameters will be added to the nodes array, but parameters that @@ -37394,7 +38089,7 @@ var ts; } } function removeComputedProperties(node) { - return ts.filter(node.members, function (member) { return member.name === undefined || member.name.kind !== 134 /* ComputedPropertyName */; }); + return ts.filter(node.members, function (member) { return member.name === undefined || member.name.kind !== 136 /* ComputedPropertyName */; }); } /** * Like removeComputedProperties, but retains the properties with well known symbol names @@ -37403,13 +38098,13 @@ var ts; return ts.filter(node.members, function (member) { return !ts.hasDynamicName(member); }); } function getInnermostModule(node) { - while (node.body.kind === 216 /* ModuleDeclaration */) { + while (node.body.kind === 218 /* ModuleDeclaration */) { node = node.body; } return node; } function getNodeSpan(node) { - return node.kind === 246 /* SourceFile */ + return node.kind === 248 /* SourceFile */ ? ts.createTextSpanFromBounds(node.getFullStart(), node.getEnd()) : ts.createTextSpanFromBounds(node.getStart(), node.getEnd()); } @@ -38197,22 +38892,22 @@ var ts; if (!candidates.length) { // We didn't have any sig help items produced by the TS compiler. If this is a JS // file, then see if we can figure out anything better. - if (ts.isJavaScript(sourceFile.fileName)) { + if (ts.isSourceFileJavaScript(sourceFile)) { return createJavaScriptSignatureHelpItems(argumentInfo); } return undefined; } return createSignatureHelpItems(candidates, resolvedSignature, argumentInfo); function createJavaScriptSignatureHelpItems(argumentInfo) { - if (argumentInfo.invocation.kind !== 166 /* CallExpression */) { + if (argumentInfo.invocation.kind !== 168 /* CallExpression */) { return undefined; } // See if we can find some symbol with the call expression name that has call signatures. var callExpression = argumentInfo.invocation; var expression = callExpression.expression; - var name = expression.kind === 67 /* Identifier */ + var name = expression.kind === 69 /* Identifier */ ? expression - : expression.kind === 164 /* PropertyAccessExpression */ + : expression.kind === 166 /* PropertyAccessExpression */ ? expression.name : undefined; if (!name || !name.text) { @@ -38245,7 +38940,7 @@ var ts; * in the argument of an invocation; returns undefined otherwise. */ function getImmediatelyContainingArgumentInfo(node) { - if (node.parent.kind === 166 /* CallExpression */ || node.parent.kind === 167 /* NewExpression */) { + if (node.parent.kind === 168 /* CallExpression */ || node.parent.kind === 169 /* NewExpression */) { var callExpression = node.parent; // There are 3 cases to handle: // 1. The token introduces a list, and should begin a sig help session @@ -38298,25 +38993,25 @@ var ts; }; } } - else if (node.kind === 11 /* NoSubstitutionTemplateLiteral */ && node.parent.kind === 168 /* TaggedTemplateExpression */) { + else if (node.kind === 11 /* NoSubstitutionTemplateLiteral */ && node.parent.kind === 170 /* TaggedTemplateExpression */) { // Check if we're actually inside the template; // otherwise we'll fall out and return undefined. if (ts.isInsideTemplateLiteral(node, position)) { return getArgumentListInfoForTemplate(node.parent, /*argumentIndex*/ 0); } } - else if (node.kind === 12 /* TemplateHead */ && node.parent.parent.kind === 168 /* TaggedTemplateExpression */) { + else if (node.kind === 12 /* TemplateHead */ && node.parent.parent.kind === 170 /* TaggedTemplateExpression */) { var templateExpression = node.parent; var tagExpression = templateExpression.parent; - ts.Debug.assert(templateExpression.kind === 181 /* TemplateExpression */); + ts.Debug.assert(templateExpression.kind === 183 /* TemplateExpression */); var argumentIndex = ts.isInsideTemplateLiteral(node, position) ? 0 : 1; return getArgumentListInfoForTemplate(tagExpression, argumentIndex); } - else if (node.parent.kind === 188 /* TemplateSpan */ && node.parent.parent.parent.kind === 168 /* TaggedTemplateExpression */) { + else if (node.parent.kind === 190 /* TemplateSpan */ && node.parent.parent.parent.kind === 170 /* TaggedTemplateExpression */) { var templateSpan = node.parent; var templateExpression = templateSpan.parent; var tagExpression = templateExpression.parent; - ts.Debug.assert(templateExpression.kind === 181 /* TemplateExpression */); + ts.Debug.assert(templateExpression.kind === 183 /* TemplateExpression */); // If we're just after a template tail, don't show signature help. if (node.kind === 14 /* TemplateTail */ && !ts.isInsideTemplateLiteral(node, position)) { return undefined; @@ -38434,7 +39129,7 @@ var ts; // // This is because a Missing node has no width. However, what we actually want is to include trivia // leading up to the next token in case the user is about to type in a TemplateMiddle or TemplateTail. - if (template.kind === 181 /* TemplateExpression */) { + if (template.kind === 183 /* TemplateExpression */) { var lastSpan = ts.lastOrUndefined(template.templateSpans); if (lastSpan.literal.getFullWidth() === 0) { applicableSpanEnd = ts.skipTrivia(sourceFile.text, applicableSpanEnd, /*stopAfterLineBreak*/ false); @@ -38443,7 +39138,7 @@ var ts; return ts.createTextSpan(applicableSpanStart, applicableSpanEnd - applicableSpanStart); } function getContainingArgumentInfo(node) { - for (var n = node; n.kind !== 246 /* SourceFile */; n = n.parent) { + for (var n = node; n.kind !== 248 /* SourceFile */; n = n.parent) { if (ts.isFunctionBlock(n)) { return undefined; } @@ -38643,40 +39338,40 @@ var ts; return false; } switch (n.kind) { - case 212 /* ClassDeclaration */: - case 213 /* InterfaceDeclaration */: - case 215 /* EnumDeclaration */: - case 163 /* ObjectLiteralExpression */: - case 159 /* ObjectBindingPattern */: - case 153 /* TypeLiteral */: - case 190 /* Block */: - case 217 /* ModuleBlock */: - case 218 /* CaseBlock */: + case 214 /* ClassDeclaration */: + case 215 /* InterfaceDeclaration */: + case 217 /* EnumDeclaration */: + case 165 /* ObjectLiteralExpression */: + case 161 /* ObjectBindingPattern */: + case 155 /* TypeLiteral */: + case 192 /* Block */: + case 219 /* ModuleBlock */: + case 220 /* CaseBlock */: return nodeEndsWith(n, 16 /* CloseBraceToken */, sourceFile); - case 242 /* CatchClause */: + case 244 /* CatchClause */: return isCompletedNode(n.block, sourceFile); - case 167 /* NewExpression */: + case 169 /* NewExpression */: if (!n.arguments) { return true; } // fall through - case 166 /* CallExpression */: - case 170 /* ParenthesizedExpression */: - case 158 /* ParenthesizedType */: + case 168 /* CallExpression */: + case 172 /* ParenthesizedExpression */: + case 160 /* ParenthesizedType */: return nodeEndsWith(n, 18 /* CloseParenToken */, sourceFile); - case 150 /* FunctionType */: - case 151 /* ConstructorType */: + case 152 /* FunctionType */: + case 153 /* ConstructorType */: return isCompletedNode(n.type, sourceFile); - case 142 /* Constructor */: - case 143 /* GetAccessor */: - case 144 /* SetAccessor */: - case 211 /* FunctionDeclaration */: - case 171 /* FunctionExpression */: - case 141 /* MethodDeclaration */: - case 140 /* MethodSignature */: - case 146 /* ConstructSignature */: - case 145 /* CallSignature */: - case 172 /* ArrowFunction */: + case 144 /* Constructor */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: + case 213 /* FunctionDeclaration */: + case 173 /* FunctionExpression */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: + case 148 /* ConstructSignature */: + case 147 /* CallSignature */: + case 174 /* ArrowFunction */: if (n.body) { return isCompletedNode(n.body, sourceFile); } @@ -38686,63 +39381,64 @@ var ts; // Even though type parameters can be unclosed, we can get away with // having at least a closing paren. return hasChildOfKind(n, 18 /* CloseParenToken */, sourceFile); - case 216 /* ModuleDeclaration */: + case 218 /* ModuleDeclaration */: return n.body && isCompletedNode(n.body, sourceFile); - case 194 /* IfStatement */: + case 196 /* IfStatement */: if (n.elseStatement) { return isCompletedNode(n.elseStatement, sourceFile); } return isCompletedNode(n.thenStatement, sourceFile); - case 193 /* ExpressionStatement */: - return isCompletedNode(n.expression, sourceFile); - case 162 /* ArrayLiteralExpression */: - case 160 /* ArrayBindingPattern */: - case 165 /* ElementAccessExpression */: - case 134 /* ComputedPropertyName */: - case 155 /* TupleType */: + case 195 /* ExpressionStatement */: + return isCompletedNode(n.expression, sourceFile) || + hasChildOfKind(n, 23 /* SemicolonToken */); + case 164 /* ArrayLiteralExpression */: + case 162 /* ArrayBindingPattern */: + case 167 /* ElementAccessExpression */: + case 136 /* ComputedPropertyName */: + case 157 /* TupleType */: return nodeEndsWith(n, 20 /* CloseBracketToken */, sourceFile); - case 147 /* IndexSignature */: + case 149 /* IndexSignature */: if (n.type) { return isCompletedNode(n.type, sourceFile); } return hasChildOfKind(n, 20 /* CloseBracketToken */, sourceFile); - case 239 /* CaseClause */: - case 240 /* DefaultClause */: + case 241 /* CaseClause */: + case 242 /* DefaultClause */: // there is no such thing as terminator token for CaseClause/DefaultClause so for simplicitly always consider them non-completed return false; - case 197 /* ForStatement */: - case 198 /* ForInStatement */: - case 199 /* ForOfStatement */: - case 196 /* WhileStatement */: + case 199 /* ForStatement */: + case 200 /* ForInStatement */: + case 201 /* ForOfStatement */: + case 198 /* WhileStatement */: return isCompletedNode(n.statement, sourceFile); - case 195 /* DoStatement */: + case 197 /* DoStatement */: // rough approximation: if DoStatement has While keyword - then if node is completed is checking the presence of ')'; - var hasWhileKeyword = findChildOfKind(n, 102 /* WhileKeyword */, sourceFile); + var hasWhileKeyword = findChildOfKind(n, 104 /* WhileKeyword */, sourceFile); if (hasWhileKeyword) { return nodeEndsWith(n, 18 /* CloseParenToken */, sourceFile); } return isCompletedNode(n.statement, sourceFile); - case 152 /* TypeQuery */: + case 154 /* TypeQuery */: return isCompletedNode(n.exprName, sourceFile); - case 174 /* TypeOfExpression */: - case 173 /* DeleteExpression */: - case 175 /* VoidExpression */: - case 182 /* YieldExpression */: - case 183 /* SpreadElementExpression */: + case 176 /* TypeOfExpression */: + case 175 /* DeleteExpression */: + case 177 /* VoidExpression */: + case 184 /* YieldExpression */: + case 185 /* SpreadElementExpression */: var unaryWordExpression = n; return isCompletedNode(unaryWordExpression.expression, sourceFile); - case 168 /* TaggedTemplateExpression */: + case 170 /* TaggedTemplateExpression */: return isCompletedNode(n.template, sourceFile); - case 181 /* TemplateExpression */: + case 183 /* TemplateExpression */: var lastSpan = ts.lastOrUndefined(n.templateSpans); return isCompletedNode(lastSpan, sourceFile); - case 188 /* TemplateSpan */: + case 190 /* TemplateSpan */: return ts.nodeIsPresent(n.literal); - case 177 /* PrefixUnaryExpression */: + case 179 /* PrefixUnaryExpression */: return isCompletedNode(n.operand, sourceFile); - case 179 /* BinaryExpression */: + case 181 /* BinaryExpression */: return isCompletedNode(n.right, sourceFile); - case 180 /* ConditionalExpression */: + case 182 /* ConditionalExpression */: return isCompletedNode(n.whenFalse, sourceFile); default: return true; @@ -38798,7 +39494,7 @@ var ts; // for the position of the relevant node (or comma). var syntaxList = ts.forEach(node.parent.getChildren(), function (c) { // find syntax list that covers the span of the node - if (c.kind === 269 /* SyntaxList */ && c.pos <= node.pos && c.end >= node.end) { + if (c.kind === 271 /* SyntaxList */ && c.pos <= node.pos && c.end >= node.end) { return c; } }); @@ -38904,7 +39600,7 @@ var ts; function findPrecedingToken(position, sourceFile, startNode) { return find(startNode || sourceFile); function findRightmostToken(n) { - if (isToken(n) || n.kind === 234 /* JsxText */) { + if (isToken(n) || n.kind === 236 /* JsxText */) { return n; } var children = n.getChildren(); @@ -38912,7 +39608,7 @@ var ts; return candidate && findRightmostToken(candidate); } function find(n) { - if (isToken(n) || n.kind === 234 /* JsxText */) { + if (isToken(n) || n.kind === 236 /* JsxText */) { return n; } var children = n.getChildren(); @@ -38926,10 +39622,10 @@ var ts; // if no - position is in the node itself so we should recurse in it. // NOTE: JsxText is a weird kind of node that can contain only whitespaces (since they are not counted as trivia). // if this is the case - then we should assume that token in question is located in previous child. - if (position < child.end && (nodeHasTokens(child) || child.kind === 234 /* JsxText */)) { + if (position < child.end && (nodeHasTokens(child) || child.kind === 236 /* JsxText */)) { var start = child.getStart(sourceFile); var lookInPreviousChild = (start >= position) || - (child.kind === 234 /* JsxText */ && start === child.end); // whitespace only JsxText + (child.kind === 236 /* JsxText */ && start === child.end); // whitespace only JsxText if (lookInPreviousChild) { // actual start of the node is past the position - previous token should be at the end of previous child var candidate = findRightmostChildNodeWithTokens(children, /*exclusiveStartPosition*/ i); @@ -38941,7 +39637,7 @@ var ts; } } } - ts.Debug.assert(startNode !== undefined || n.kind === 246 /* SourceFile */); + ts.Debug.assert(startNode !== undefined || n.kind === 248 /* SourceFile */); // Here we know that none of child token nodes embrace the position, // the only known case is when position is at the end of the file. // Try to find the rightmost token in the file without filtering. @@ -39016,9 +39712,9 @@ var ts; var node = ts.getTokenAtPosition(sourceFile, position); if (isToken(node)) { switch (node.kind) { - case 100 /* VarKeyword */: - case 106 /* LetKeyword */: - case 72 /* ConstKeyword */: + case 102 /* VarKeyword */: + case 108 /* LetKeyword */: + case 74 /* ConstKeyword */: // if the current token is var, let or const, skip the VariableDeclarationList node = node.parent === undefined ? undefined : node.parent.parent; break; @@ -39067,21 +39763,21 @@ var ts; } ts.getNodeModifiers = getNodeModifiers; function getTypeArgumentOrTypeParameterList(node) { - if (node.kind === 149 /* TypeReference */ || node.kind === 166 /* CallExpression */) { + if (node.kind === 151 /* TypeReference */ || node.kind === 168 /* CallExpression */) { return node.typeArguments; } - if (ts.isFunctionLike(node) || node.kind === 212 /* ClassDeclaration */ || node.kind === 213 /* InterfaceDeclaration */) { + if (ts.isFunctionLike(node) || node.kind === 214 /* ClassDeclaration */ || node.kind === 215 /* InterfaceDeclaration */) { return node.typeParameters; } return undefined; } ts.getTypeArgumentOrTypeParameterList = getTypeArgumentOrTypeParameterList; function isToken(n) { - return n.kind >= 0 /* FirstToken */ && n.kind <= 132 /* LastToken */; + return n.kind >= 0 /* FirstToken */ && n.kind <= 134 /* LastToken */; } ts.isToken = isToken; function isWord(kind) { - return kind === 67 /* Identifier */ || ts.isKeyword(kind); + return kind === 69 /* Identifier */ || ts.isKeyword(kind); } ts.isWord = isWord; function isPropertyName(kind) { @@ -39091,8 +39787,17 @@ var ts; return kind === 2 /* SingleLineCommentTrivia */ || kind === 3 /* MultiLineCommentTrivia */; } ts.isComment = isComment; + function isStringOrRegularExpressionOrTemplateLiteral(kind) { + if (kind === 9 /* StringLiteral */ + || kind === 10 /* RegularExpressionLiteral */ + || ts.isTemplateLiteralKind(kind)) { + return true; + } + return false; + } + ts.isStringOrRegularExpressionOrTemplateLiteral = isStringOrRegularExpressionOrTemplateLiteral; function isPunctuation(kind) { - return 15 /* FirstPunctuation */ <= kind && kind <= 66 /* LastPunctuation */; + return 15 /* FirstPunctuation */ <= kind && kind <= 68 /* LastPunctuation */; } ts.isPunctuation = isPunctuation; function isInsideTemplateLiteral(node, position) { @@ -39102,9 +39807,9 @@ var ts; ts.isInsideTemplateLiteral = isInsideTemplateLiteral; function isAccessibilityModifier(kind) { switch (kind) { - case 110 /* PublicKeyword */: - case 108 /* PrivateKeyword */: - case 109 /* ProtectedKeyword */: + case 112 /* PublicKeyword */: + case 110 /* PrivateKeyword */: + case 111 /* ProtectedKeyword */: return true; } return false; @@ -39132,7 +39837,7 @@ var ts; var ts; (function (ts) { function isFirstDeclarationOfSymbolParameter(symbol) { - return symbol.declarations && symbol.declarations.length > 0 && symbol.declarations[0].kind === 136 /* Parameter */; + return symbol.declarations && symbol.declarations.length > 0 && symbol.declarations[0].kind === 138 /* Parameter */; } ts.isFirstDeclarationOfSymbolParameter = isFirstDeclarationOfSymbolParameter; var displayPartWriter = getDisplayPartWriter(); @@ -39154,7 +39859,8 @@ var ts; increaseIndent: function () { indent++; }, decreaseIndent: function () { indent--; }, clear: resetWriter, - trackSymbol: function () { } + trackSymbol: function () { }, + reportInaccessibleThisError: function () { } }; function writeIndent() { if (lineStart) { @@ -39319,7 +40025,7 @@ var ts; ts.getDeclaredName = getDeclaredName; function isImportOrExportSpecifierName(location) { return location.parent && - (location.parent.kind === 224 /* ImportSpecifier */ || location.parent.kind === 228 /* ExportSpecifier */) && + (location.parent.kind === 226 /* ImportSpecifier */ || location.parent.kind === 230 /* ExportSpecifier */) && location.parent.propertyName === location; } ts.isImportOrExportSpecifierName = isImportOrExportSpecifierName; @@ -39347,7 +40053,12 @@ var ts; (function (ts) { var formatting; (function (formatting) { - var scanner = ts.createScanner(2 /* Latest */, /*skipTrivia*/ false); + var standardScanner = ts.createScanner(2 /* Latest */, /*skipTrivia*/ false, 0 /* Standard */); + var jsxScanner = ts.createScanner(2 /* Latest */, /*skipTrivia*/ false, 1 /* JSX */); + /** + * Scanner that is currently used for formatting + */ + var scanner; var ScanAction; (function (ScanAction) { ScanAction[ScanAction["Scan"] = 0] = "Scan"; @@ -39357,6 +40068,8 @@ var ts; ScanAction[ScanAction["RescanJsxIdentifier"] = 4] = "RescanJsxIdentifier"; })(ScanAction || (ScanAction = {})); function getFormattingScanner(sourceFile, startPos, endPos) { + ts.Debug.assert(scanner === undefined); + scanner = sourceFile.languageVariant === 1 /* JSX */ ? jsxScanner : standardScanner; scanner.setText(sourceFile.text); scanner.setTextPos(startPos); var wasNewLine = true; @@ -39371,11 +40084,14 @@ var ts; isOnToken: isOnToken, lastTrailingTriviaWasNewLine: function () { return wasNewLine; }, close: function () { + ts.Debug.assert(scanner !== undefined); lastTokenInfo = undefined; scanner.setText(undefined); + scanner = undefined; } }; function advance() { + ts.Debug.assert(scanner !== undefined); lastTokenInfo = undefined; var isStarted = scanner.getStartPos() !== startPos; if (isStarted) { @@ -39419,10 +40135,10 @@ var ts; if (node) { switch (node.kind) { case 29 /* GreaterThanEqualsToken */: - case 62 /* GreaterThanGreaterThanEqualsToken */: - case 63 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 44 /* GreaterThanGreaterThanGreaterThanToken */: - case 43 /* GreaterThanGreaterThanToken */: + case 64 /* GreaterThanGreaterThanEqualsToken */: + case 65 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + case 45 /* GreaterThanGreaterThanGreaterThanToken */: + case 44 /* GreaterThanGreaterThanToken */: return true; } } @@ -39431,11 +40147,11 @@ var ts; function shouldRescanJsxIdentifier(node) { if (node.parent) { switch (node.parent.kind) { - case 236 /* JsxAttribute */: - case 233 /* JsxOpeningElement */: - case 235 /* JsxClosingElement */: - case 232 /* JsxSelfClosingElement */: - return node.kind === 67 /* Identifier */; + case 238 /* JsxAttribute */: + case 235 /* JsxOpeningElement */: + case 237 /* JsxClosingElement */: + case 234 /* JsxSelfClosingElement */: + return node.kind === 69 /* Identifier */; } } return false; @@ -39448,9 +40164,10 @@ var ts; container.kind === 14 /* TemplateTail */; } function startsWithSlashToken(t) { - return t === 38 /* SlashToken */ || t === 59 /* SlashEqualsToken */; + return t === 39 /* SlashToken */ || t === 61 /* SlashEqualsToken */; } function readTokenInfo(n) { + ts.Debug.assert(scanner !== undefined); if (!isOnToken()) { // scanner is not on the token (either advance was not called yet or scanner is already past the end position) return { @@ -39500,7 +40217,7 @@ var ts; currentToken = scanner.reScanTemplateToken(); lastScanAction = 3 /* RescanTemplateToken */; } - else if (expectedScanAction === 4 /* RescanJsxIdentifier */ && currentToken === 67 /* Identifier */) { + else if (expectedScanAction === 4 /* RescanJsxIdentifier */ && currentToken === 69 /* Identifier */) { currentToken = scanner.scanJsxIdentifier(); lastScanAction = 4 /* RescanJsxIdentifier */; } @@ -39544,6 +40261,7 @@ var ts; return fixTokenKind(lastTokenInfo, n); } function isOnToken() { + ts.Debug.assert(scanner !== undefined); var current = (lastTokenInfo && lastTokenInfo.token.kind) || scanner.getToken(); var startPos = (lastTokenInfo && lastTokenInfo.token.pos) || scanner.getStartPos(); return startPos < endPos && current !== 1 /* EndOfFileToken */ && !ts.isTrivia(current); @@ -39822,17 +40540,17 @@ var ts; this.IgnoreAfterLineComment = new formatting.Rule(formatting.RuleDescriptor.create3(2 /* SingleLineCommentTrivia */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create1(1 /* Ignore */)); // Space after keyword but not before ; or : or ? this.NoSpaceBeforeSemicolon = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 23 /* SemicolonToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); - this.NoSpaceBeforeColon = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 53 /* ColonToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 8 /* Delete */)); - this.NoSpaceBeforeQuestionMark = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 52 /* QuestionToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 8 /* Delete */)); - this.SpaceAfterColon = new formatting.Rule(formatting.RuleDescriptor.create3(53 /* ColonToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 2 /* Space */)); - this.SpaceAfterQuestionMarkInConditionalOperator = new formatting.Rule(formatting.RuleDescriptor.create3(52 /* QuestionToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsConditionalOperatorContext), 2 /* Space */)); - this.NoSpaceAfterQuestionMark = new formatting.Rule(formatting.RuleDescriptor.create3(52 /* QuestionToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceBeforeColon = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 54 /* ColonToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 8 /* Delete */)); + this.NoSpaceBeforeQuestionMark = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 53 /* QuestionToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 8 /* Delete */)); + this.SpaceAfterColon = new formatting.Rule(formatting.RuleDescriptor.create3(54 /* ColonToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 2 /* Space */)); + this.SpaceAfterQuestionMarkInConditionalOperator = new formatting.Rule(formatting.RuleDescriptor.create3(53 /* QuestionToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsConditionalOperatorContext), 2 /* Space */)); + this.NoSpaceAfterQuestionMark = new formatting.Rule(formatting.RuleDescriptor.create3(53 /* QuestionToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); this.SpaceAfterSemicolon = new formatting.Rule(formatting.RuleDescriptor.create3(23 /* SemicolonToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); // Space after }. this.SpaceAfterCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create3(16 /* CloseBraceToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsAfterCodeBlockContext), 2 /* Space */)); // Special case for (}, else) and (}, while) since else & while tokens are not part of the tree which makes SpaceAfterCloseBrace rule not applied - this.SpaceBetweenCloseBraceAndElse = new formatting.Rule(formatting.RuleDescriptor.create1(16 /* CloseBraceToken */, 78 /* ElseKeyword */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); - this.SpaceBetweenCloseBraceAndWhile = new formatting.Rule(formatting.RuleDescriptor.create1(16 /* CloseBraceToken */, 102 /* WhileKeyword */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); + this.SpaceBetweenCloseBraceAndElse = new formatting.Rule(formatting.RuleDescriptor.create1(16 /* CloseBraceToken */, 80 /* ElseKeyword */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); + this.SpaceBetweenCloseBraceAndWhile = new formatting.Rule(formatting.RuleDescriptor.create1(16 /* CloseBraceToken */, 104 /* WhileKeyword */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); this.NoSpaceAfterCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create3(16 /* CloseBraceToken */, formatting.Shared.TokenRange.FromTokens([18 /* CloseParenToken */, 20 /* CloseBracketToken */, 24 /* CommaToken */, 23 /* SemicolonToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); // No space for dot this.NoSpaceBeforeDot = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 21 /* DotToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); @@ -39844,10 +40562,10 @@ var ts; this.FunctionOpenBraceLeftTokenRange = formatting.Shared.TokenRange.AnyIncludingMultilineComments; this.SpaceBeforeOpenBraceInFunction = new formatting.Rule(formatting.RuleDescriptor.create2(this.FunctionOpenBraceLeftTokenRange, 15 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext, Rules.IsBeforeBlockContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), 2 /* Space */), 1 /* CanDeleteNewLines */); // Place a space before open brace in a TypeScript declaration that has braces as children (class, module, enum, etc) - this.TypeScriptOpenBraceLeftTokenRange = formatting.Shared.TokenRange.FromTokens([67 /* Identifier */, 3 /* MultiLineCommentTrivia */, 71 /* ClassKeyword */]); + this.TypeScriptOpenBraceLeftTokenRange = formatting.Shared.TokenRange.FromTokens([69 /* Identifier */, 3 /* MultiLineCommentTrivia */, 73 /* ClassKeyword */]); this.SpaceBeforeOpenBraceInTypeScriptDeclWithBlock = new formatting.Rule(formatting.RuleDescriptor.create2(this.TypeScriptOpenBraceLeftTokenRange, 15 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsTypeScriptDeclWithBlockContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), 2 /* Space */), 1 /* CanDeleteNewLines */); // Place a space before open brace in a control flow construct - this.ControlOpenBraceLeftTokenRange = formatting.Shared.TokenRange.FromTokens([18 /* CloseParenToken */, 3 /* MultiLineCommentTrivia */, 77 /* DoKeyword */, 98 /* TryKeyword */, 83 /* FinallyKeyword */, 78 /* ElseKeyword */]); + this.ControlOpenBraceLeftTokenRange = formatting.Shared.TokenRange.FromTokens([18 /* CloseParenToken */, 3 /* MultiLineCommentTrivia */, 79 /* DoKeyword */, 100 /* TryKeyword */, 85 /* FinallyKeyword */, 80 /* ElseKeyword */]); this.SpaceBeforeOpenBraceInControl = new formatting.Rule(formatting.RuleDescriptor.create2(this.ControlOpenBraceLeftTokenRange, 15 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsControlDeclContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), 2 /* Space */), 1 /* CanDeleteNewLines */); // Insert a space after { and before } in single-line contexts, but remove space from empty object literals {}. this.SpaceAfterOpenBrace = new formatting.Rule(formatting.RuleDescriptor.create3(15 /* OpenBraceToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSingleLineBlockContext), 2 /* Space */)); @@ -39861,55 +40579,55 @@ var ts; // Prefix operators generally shouldn't have a space between // them and their target unary expression. this.NoSpaceAfterUnaryPrefixOperator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.UnaryPrefixOperators, formatting.Shared.TokenRange.UnaryPrefixExpressions), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 8 /* Delete */)); - this.NoSpaceAfterUnaryPreincrementOperator = new formatting.Rule(formatting.RuleDescriptor.create3(40 /* PlusPlusToken */, formatting.Shared.TokenRange.UnaryPreincrementExpressions), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); - this.NoSpaceAfterUnaryPredecrementOperator = new formatting.Rule(formatting.RuleDescriptor.create3(41 /* MinusMinusToken */, formatting.Shared.TokenRange.UnaryPredecrementExpressions), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); - this.NoSpaceBeforeUnaryPostincrementOperator = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.UnaryPostincrementExpressions, 40 /* PlusPlusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); - this.NoSpaceBeforeUnaryPostdecrementOperator = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.UnaryPostdecrementExpressions, 41 /* MinusMinusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceAfterUnaryPreincrementOperator = new formatting.Rule(formatting.RuleDescriptor.create3(41 /* PlusPlusToken */, formatting.Shared.TokenRange.UnaryPreincrementExpressions), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceAfterUnaryPredecrementOperator = new formatting.Rule(formatting.RuleDescriptor.create3(42 /* MinusMinusToken */, formatting.Shared.TokenRange.UnaryPredecrementExpressions), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceBeforeUnaryPostincrementOperator = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.UnaryPostincrementExpressions, 41 /* PlusPlusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceBeforeUnaryPostdecrementOperator = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.UnaryPostdecrementExpressions, 42 /* MinusMinusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); // More unary operator special-casing. // DevDiv 181814: Be careful when removing leading whitespace // around unary operators. Examples: // 1 - -2 --X--> 1--2 // a + ++b --X--> a+++b - this.SpaceAfterPostincrementWhenFollowedByAdd = new formatting.Rule(formatting.RuleDescriptor.create1(40 /* PlusPlusToken */, 35 /* PlusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); + this.SpaceAfterPostincrementWhenFollowedByAdd = new formatting.Rule(formatting.RuleDescriptor.create1(41 /* PlusPlusToken */, 35 /* PlusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); this.SpaceAfterAddWhenFollowedByUnaryPlus = new formatting.Rule(formatting.RuleDescriptor.create1(35 /* PlusToken */, 35 /* PlusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); - this.SpaceAfterAddWhenFollowedByPreincrement = new formatting.Rule(formatting.RuleDescriptor.create1(35 /* PlusToken */, 40 /* PlusPlusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); - this.SpaceAfterPostdecrementWhenFollowedBySubtract = new formatting.Rule(formatting.RuleDescriptor.create1(41 /* MinusMinusToken */, 36 /* MinusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); + this.SpaceAfterAddWhenFollowedByPreincrement = new formatting.Rule(formatting.RuleDescriptor.create1(35 /* PlusToken */, 41 /* PlusPlusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); + this.SpaceAfterPostdecrementWhenFollowedBySubtract = new formatting.Rule(formatting.RuleDescriptor.create1(42 /* MinusMinusToken */, 36 /* MinusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); this.SpaceAfterSubtractWhenFollowedByUnaryMinus = new formatting.Rule(formatting.RuleDescriptor.create1(36 /* MinusToken */, 36 /* MinusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); - this.SpaceAfterSubtractWhenFollowedByPredecrement = new formatting.Rule(formatting.RuleDescriptor.create1(36 /* MinusToken */, 41 /* MinusMinusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); + this.SpaceAfterSubtractWhenFollowedByPredecrement = new formatting.Rule(formatting.RuleDescriptor.create1(36 /* MinusToken */, 42 /* MinusMinusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); this.NoSpaceBeforeComma = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 24 /* CommaToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); - this.SpaceAfterCertainKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([100 /* VarKeyword */, 96 /* ThrowKeyword */, 90 /* NewKeyword */, 76 /* DeleteKeyword */, 92 /* ReturnKeyword */, 99 /* TypeOfKeyword */, 117 /* AwaitKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); - this.SpaceAfterLetConstInVariableDeclaration = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([106 /* LetKeyword */, 72 /* ConstKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsStartOfVariableDeclarationList), 2 /* Space */)); + this.SpaceAfterCertainKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([102 /* VarKeyword */, 98 /* ThrowKeyword */, 92 /* NewKeyword */, 78 /* DeleteKeyword */, 94 /* ReturnKeyword */, 101 /* TypeOfKeyword */, 119 /* AwaitKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); + this.SpaceAfterLetConstInVariableDeclaration = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([108 /* LetKeyword */, 74 /* ConstKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsStartOfVariableDeclarationList), 2 /* Space */)); this.NoSpaceBeforeOpenParenInFuncCall = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 17 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsFunctionCallOrNewContext, Rules.IsPreviousTokenNotComma), 8 /* Delete */)); - this.SpaceAfterFunctionInFuncDecl = new formatting.Rule(formatting.RuleDescriptor.create3(85 /* FunctionKeyword */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2 /* Space */)); + this.SpaceAfterFunctionInFuncDecl = new formatting.Rule(formatting.RuleDescriptor.create3(87 /* FunctionKeyword */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2 /* Space */)); this.NoSpaceBeforeOpenParenInFuncDecl = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 17 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsFunctionDeclContext), 8 /* Delete */)); - this.SpaceAfterVoidOperator = new formatting.Rule(formatting.RuleDescriptor.create3(101 /* VoidKeyword */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsVoidOpContext), 2 /* Space */)); - this.NoSpaceBetweenReturnAndSemicolon = new formatting.Rule(formatting.RuleDescriptor.create1(92 /* ReturnKeyword */, 23 /* SemicolonToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.SpaceAfterVoidOperator = new formatting.Rule(formatting.RuleDescriptor.create3(103 /* VoidKeyword */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsVoidOpContext), 2 /* Space */)); + this.NoSpaceBetweenReturnAndSemicolon = new formatting.Rule(formatting.RuleDescriptor.create1(94 /* ReturnKeyword */, 23 /* SemicolonToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); // Add a space between statements. All keywords except (do,else,case) has open/close parens after them. // So, we have a rule to add a space for [),Any], [do,Any], [else,Any], and [case,Any] - this.SpaceBetweenStatements = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([18 /* CloseParenToken */, 77 /* DoKeyword */, 78 /* ElseKeyword */, 69 /* CaseKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotForContext), 2 /* Space */)); + this.SpaceBetweenStatements = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([18 /* CloseParenToken */, 79 /* DoKeyword */, 80 /* ElseKeyword */, 71 /* CaseKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotForContext), 2 /* Space */)); // This low-pri rule takes care of "try {" and "finally {" in case the rule SpaceBeforeOpenBraceInControl didn't execute on FormatOnEnter. - this.SpaceAfterTryFinally = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([98 /* TryKeyword */, 83 /* FinallyKeyword */]), 15 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); + this.SpaceAfterTryFinally = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([100 /* TryKeyword */, 85 /* FinallyKeyword */]), 15 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); // get x() {} // set x(val) {} - this.SpaceAfterGetSetInMember = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([121 /* GetKeyword */, 127 /* SetKeyword */]), 67 /* Identifier */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2 /* Space */)); + this.SpaceAfterGetSetInMember = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([123 /* GetKeyword */, 129 /* SetKeyword */]), 69 /* Identifier */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2 /* Space */)); // Special case for binary operators (that are keywords). For these we have to add a space and shouldn't follow any user options. this.SpaceBeforeBinaryKeywordOperator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.BinaryKeywordOperators), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); this.SpaceAfterBinaryKeywordOperator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.BinaryKeywordOperators, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); // TypeScript-specific higher priority rules // Treat constructor as an identifier in a function declaration, and remove spaces between constructor and following left parentheses - this.NoSpaceAfterConstructor = new formatting.Rule(formatting.RuleDescriptor.create1(119 /* ConstructorKeyword */, 17 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceAfterConstructor = new formatting.Rule(formatting.RuleDescriptor.create1(121 /* ConstructorKeyword */, 17 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); // Use of module as a function call. e.g.: import m2 = module("m2"); - this.NoSpaceAfterModuleImport = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([123 /* ModuleKeyword */, 125 /* RequireKeyword */]), 17 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceAfterModuleImport = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([125 /* ModuleKeyword */, 127 /* RequireKeyword */]), 17 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); // Add a space around certain TypeScript keywords - this.SpaceAfterCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([113 /* AbstractKeyword */, 71 /* ClassKeyword */, 120 /* DeclareKeyword */, 75 /* DefaultKeyword */, 79 /* EnumKeyword */, 80 /* ExportKeyword */, 81 /* ExtendsKeyword */, 121 /* GetKeyword */, 104 /* ImplementsKeyword */, 87 /* ImportKeyword */, 105 /* InterfaceKeyword */, 123 /* ModuleKeyword */, 124 /* NamespaceKeyword */, 108 /* PrivateKeyword */, 110 /* PublicKeyword */, 109 /* ProtectedKeyword */, 127 /* SetKeyword */, 111 /* StaticKeyword */, 130 /* TypeKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); - this.SpaceBeforeCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([81 /* ExtendsKeyword */, 104 /* ImplementsKeyword */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); + this.SpaceAfterCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([115 /* AbstractKeyword */, 73 /* ClassKeyword */, 122 /* DeclareKeyword */, 77 /* DefaultKeyword */, 81 /* EnumKeyword */, 82 /* ExportKeyword */, 83 /* ExtendsKeyword */, 123 /* GetKeyword */, 106 /* ImplementsKeyword */, 89 /* ImportKeyword */, 107 /* InterfaceKeyword */, 125 /* ModuleKeyword */, 126 /* NamespaceKeyword */, 110 /* PrivateKeyword */, 112 /* PublicKeyword */, 111 /* ProtectedKeyword */, 129 /* SetKeyword */, 113 /* StaticKeyword */, 132 /* TypeKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); + this.SpaceBeforeCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([83 /* ExtendsKeyword */, 106 /* ImplementsKeyword */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); // Treat string literals in module names as identifiers, and add a space between the literal and the opening Brace braces, e.g.: module "m2" { this.SpaceAfterModuleName = new formatting.Rule(formatting.RuleDescriptor.create1(9 /* StringLiteral */, 15 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsModuleDeclContext), 2 /* Space */)); // Lambda expressions this.SpaceAfterArrow = new formatting.Rule(formatting.RuleDescriptor.create3(34 /* EqualsGreaterThanToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); // Optional parameters and let args - this.NoSpaceAfterEllipsis = new formatting.Rule(formatting.RuleDescriptor.create1(22 /* DotDotDotToken */, 67 /* Identifier */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); - this.NoSpaceAfterOptionalParameters = new formatting.Rule(formatting.RuleDescriptor.create3(52 /* QuestionToken */, formatting.Shared.TokenRange.FromTokens([18 /* CloseParenToken */, 24 /* CommaToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 8 /* Delete */)); + this.NoSpaceAfterEllipsis = new formatting.Rule(formatting.RuleDescriptor.create1(22 /* DotDotDotToken */, 69 /* Identifier */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceAfterOptionalParameters = new formatting.Rule(formatting.RuleDescriptor.create3(53 /* QuestionToken */, formatting.Shared.TokenRange.FromTokens([18 /* CloseParenToken */, 24 /* CommaToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 8 /* Delete */)); // generics and type assertions this.NoSpaceBeforeOpenAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.TypeNames, 25 /* LessThanToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), 8 /* Delete */)); this.NoSpaceBetweenCloseParenAndAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create1(18 /* CloseParenToken */, 25 /* LessThanToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), 8 /* Delete */)); @@ -39920,17 +40638,20 @@ var ts; // Remove spaces in empty interface literals. e.g.: x: {} this.NoSpaceBetweenEmptyInterfaceBraceBrackets = new formatting.Rule(formatting.RuleDescriptor.create1(15 /* OpenBraceToken */, 16 /* CloseBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsObjectTypeContext), 8 /* Delete */)); // decorators - this.SpaceBeforeAt = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 54 /* AtToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); - this.NoSpaceAfterAt = new formatting.Rule(formatting.RuleDescriptor.create3(54 /* AtToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); - this.SpaceAfterDecorator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([113 /* AbstractKeyword */, 67 /* Identifier */, 80 /* ExportKeyword */, 75 /* DefaultKeyword */, 71 /* ClassKeyword */, 111 /* StaticKeyword */, 110 /* PublicKeyword */, 108 /* PrivateKeyword */, 109 /* ProtectedKeyword */, 121 /* GetKeyword */, 127 /* SetKeyword */, 19 /* OpenBracketToken */, 37 /* AsteriskToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsEndOfDecoratorContextOnSameLine), 2 /* Space */)); - this.NoSpaceBetweenFunctionKeywordAndStar = new formatting.Rule(formatting.RuleDescriptor.create1(85 /* FunctionKeyword */, 37 /* AsteriskToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclarationOrFunctionExpressionContext), 8 /* Delete */)); - this.SpaceAfterStarInGeneratorDeclaration = new formatting.Rule(formatting.RuleDescriptor.create3(37 /* AsteriskToken */, formatting.Shared.TokenRange.FromTokens([67 /* Identifier */, 17 /* OpenParenToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclarationOrFunctionExpressionContext), 2 /* Space */)); - this.NoSpaceBetweenYieldKeywordAndStar = new formatting.Rule(formatting.RuleDescriptor.create1(112 /* YieldKeyword */, 37 /* AsteriskToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsYieldOrYieldStarWithOperand), 8 /* Delete */)); - this.SpaceBetweenYieldOrYieldStarAndOperand = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([112 /* YieldKeyword */, 37 /* AsteriskToken */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsYieldOrYieldStarWithOperand), 2 /* Space */)); + this.SpaceBeforeAt = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 55 /* AtToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); + this.NoSpaceAfterAt = new formatting.Rule(formatting.RuleDescriptor.create3(55 /* AtToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.SpaceAfterDecorator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([115 /* AbstractKeyword */, 69 /* Identifier */, 82 /* ExportKeyword */, 77 /* DefaultKeyword */, 73 /* ClassKeyword */, 113 /* StaticKeyword */, 112 /* PublicKeyword */, 110 /* PrivateKeyword */, 111 /* ProtectedKeyword */, 123 /* GetKeyword */, 129 /* SetKeyword */, 19 /* OpenBracketToken */, 37 /* AsteriskToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsEndOfDecoratorContextOnSameLine), 2 /* Space */)); + this.NoSpaceBetweenFunctionKeywordAndStar = new formatting.Rule(formatting.RuleDescriptor.create1(87 /* FunctionKeyword */, 37 /* AsteriskToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclarationOrFunctionExpressionContext), 8 /* Delete */)); + this.SpaceAfterStarInGeneratorDeclaration = new formatting.Rule(formatting.RuleDescriptor.create3(37 /* AsteriskToken */, formatting.Shared.TokenRange.FromTokens([69 /* Identifier */, 17 /* OpenParenToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclarationOrFunctionExpressionContext), 2 /* Space */)); + this.NoSpaceBetweenYieldKeywordAndStar = new formatting.Rule(formatting.RuleDescriptor.create1(114 /* YieldKeyword */, 37 /* AsteriskToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsYieldOrYieldStarWithOperand), 8 /* Delete */)); + this.SpaceBetweenYieldOrYieldStarAndOperand = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([114 /* YieldKeyword */, 37 /* AsteriskToken */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsYieldOrYieldStarWithOperand), 2 /* Space */)); // Async-await - this.SpaceBetweenAsyncAndFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(116 /* AsyncKeyword */, 85 /* FunctionKeyword */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); + this.SpaceBetweenAsyncAndOpenParen = new formatting.Rule(formatting.RuleDescriptor.create1(118 /* AsyncKeyword */, 17 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsArrowFunctionContext, Rules.IsSameLineTokenContext), 2 /* Space */)); + this.SpaceBetweenAsyncAndFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(118 /* AsyncKeyword */, 87 /* FunctionKeyword */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); // template string - this.SpaceBetweenTagAndTemplateString = new formatting.Rule(formatting.RuleDescriptor.create3(67 /* Identifier */, formatting.Shared.TokenRange.FromTokens([11 /* NoSubstitutionTemplateLiteral */, 12 /* TemplateHead */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); + this.SpaceBetweenTagAndTemplateString = new formatting.Rule(formatting.RuleDescriptor.create3(69 /* Identifier */, formatting.Shared.TokenRange.FromTokens([11 /* NoSubstitutionTemplateLiteral */, 12 /* TemplateHead */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); + this.NoSpaceAfterTemplateHeadAndMiddle = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([12 /* TemplateHead */, 13 /* TemplateMiddle */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceBeforeTemplateMiddleAndTail = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([13 /* TemplateMiddle */, 14 /* TemplateTail */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); // These rules are higher in priority than user-configurable rules. this.HighPriorityCommonRules = [ @@ -39957,8 +40678,8 @@ var ts; this.NoSpaceBeforeOpenParenInFuncCall, this.SpaceBeforeBinaryKeywordOperator, this.SpaceAfterBinaryKeywordOperator, this.SpaceAfterVoidOperator, - this.SpaceBetweenAsyncAndFunctionKeyword, - this.SpaceBetweenTagAndTemplateString, + this.SpaceBetweenAsyncAndOpenParen, this.SpaceBetweenAsyncAndFunctionKeyword, + this.SpaceBetweenTagAndTemplateString, this.NoSpaceAfterTemplateHeadAndMiddle, this.NoSpaceBeforeTemplateMiddleAndTail, // TypeScript-specific rules this.NoSpaceAfterConstructor, this.NoSpaceAfterModuleImport, this.SpaceAfterCertainTypeScriptKeywords, this.SpaceBeforeCertainTypeScriptKeywords, @@ -40026,14 +40747,14 @@ var ts; this.NoSpaceAfterOpenBracket = new formatting.Rule(formatting.RuleDescriptor.create3(19 /* OpenBracketToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); this.NoSpaceBeforeCloseBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 20 /* CloseBracketToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); // Insert space after function keyword for anonymous functions - this.SpaceAfterAnonymousFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(85 /* FunctionKeyword */, 17 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2 /* Space */)); - this.NoSpaceAfterAnonymousFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(85 /* FunctionKeyword */, 17 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 8 /* Delete */)); + this.SpaceAfterAnonymousFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(87 /* FunctionKeyword */, 17 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2 /* Space */)); + this.NoSpaceAfterAnonymousFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(87 /* FunctionKeyword */, 17 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 8 /* Delete */)); } Rules.prototype.getRuleName = function (rule) { var o = this; - for (var name_30 in o) { - if (o[name_30] === rule) { - return name_30; + for (var name_31 in o) { + if (o[name_31] === rule) { + return name_31; } } throw new Error("Unknown rule"); @@ -40042,40 +40763,40 @@ var ts; /// Contexts /// Rules.IsForContext = function (context) { - return context.contextNode.kind === 197 /* ForStatement */; + return context.contextNode.kind === 199 /* ForStatement */; }; Rules.IsNotForContext = function (context) { return !Rules.IsForContext(context); }; Rules.IsBinaryOpContext = function (context) { switch (context.contextNode.kind) { - case 179 /* BinaryExpression */: - case 180 /* ConditionalExpression */: - case 187 /* AsExpression */: - case 148 /* TypePredicate */: - case 156 /* UnionType */: - case 157 /* IntersectionType */: + case 181 /* BinaryExpression */: + case 182 /* ConditionalExpression */: + case 189 /* AsExpression */: + case 150 /* TypePredicate */: + case 158 /* UnionType */: + case 159 /* IntersectionType */: return true; // equals in binding elements: function foo([[x, y] = [1, 2]]) - case 161 /* BindingElement */: + case 163 /* BindingElement */: // equals in type X = ... - case 214 /* TypeAliasDeclaration */: + case 216 /* TypeAliasDeclaration */: // equal in import a = module('a'); - case 219 /* ImportEqualsDeclaration */: + case 221 /* ImportEqualsDeclaration */: // equal in let a = 0; - case 209 /* VariableDeclaration */: + case 211 /* VariableDeclaration */: // equal in p = 0; - case 136 /* Parameter */: - case 245 /* EnumMember */: - case 139 /* PropertyDeclaration */: - case 138 /* PropertySignature */: - return context.currentTokenSpan.kind === 55 /* EqualsToken */ || context.nextTokenSpan.kind === 55 /* EqualsToken */; + case 138 /* Parameter */: + case 247 /* EnumMember */: + case 141 /* PropertyDeclaration */: + case 140 /* PropertySignature */: + return context.currentTokenSpan.kind === 56 /* EqualsToken */ || context.nextTokenSpan.kind === 56 /* EqualsToken */; // "in" keyword in for (let x in []) { } - case 198 /* ForInStatement */: - return context.currentTokenSpan.kind === 88 /* InKeyword */ || context.nextTokenSpan.kind === 88 /* InKeyword */; + case 200 /* ForInStatement */: + return context.currentTokenSpan.kind === 90 /* InKeyword */ || context.nextTokenSpan.kind === 90 /* InKeyword */; // Technically, "of" is not a binary operator, but format it the same way as "in" - case 199 /* ForOfStatement */: - return context.currentTokenSpan.kind === 132 /* OfKeyword */ || context.nextTokenSpan.kind === 132 /* OfKeyword */; + case 201 /* ForOfStatement */: + return context.currentTokenSpan.kind === 134 /* OfKeyword */ || context.nextTokenSpan.kind === 134 /* OfKeyword */; } return false; }; @@ -40083,7 +40804,7 @@ var ts; return !Rules.IsBinaryOpContext(context); }; Rules.IsConditionalOperatorContext = function (context) { - return context.contextNode.kind === 180 /* ConditionalExpression */; + return context.contextNode.kind === 182 /* ConditionalExpression */; }; Rules.IsSameLineTokenOrBeforeMultilineBlockContext = function (context) { //// This check is mainly used inside SpaceBeforeOpenBraceInControl and SpaceBeforeOpenBraceInFunction. @@ -40127,93 +40848,93 @@ var ts; return true; } switch (node.kind) { - case 190 /* Block */: - case 218 /* CaseBlock */: - case 163 /* ObjectLiteralExpression */: - case 217 /* ModuleBlock */: + case 192 /* Block */: + case 220 /* CaseBlock */: + case 165 /* ObjectLiteralExpression */: + case 219 /* ModuleBlock */: return true; } return false; }; Rules.IsFunctionDeclContext = function (context) { switch (context.contextNode.kind) { - case 211 /* FunctionDeclaration */: - case 141 /* MethodDeclaration */: - case 140 /* MethodSignature */: + case 213 /* FunctionDeclaration */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: //case SyntaxKind.MemberFunctionDeclaration: - case 143 /* GetAccessor */: - case 144 /* SetAccessor */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: ///case SyntaxKind.MethodSignature: - case 145 /* CallSignature */: - case 171 /* FunctionExpression */: - case 142 /* Constructor */: - case 172 /* ArrowFunction */: + case 147 /* CallSignature */: + case 173 /* FunctionExpression */: + case 144 /* Constructor */: + case 174 /* ArrowFunction */: //case SyntaxKind.ConstructorDeclaration: //case SyntaxKind.SimpleArrowFunctionExpression: //case SyntaxKind.ParenthesizedArrowFunctionExpression: - case 213 /* InterfaceDeclaration */: + case 215 /* InterfaceDeclaration */: return true; } return false; }; Rules.IsFunctionDeclarationOrFunctionExpressionContext = function (context) { - return context.contextNode.kind === 211 /* FunctionDeclaration */ || context.contextNode.kind === 171 /* FunctionExpression */; + return context.contextNode.kind === 213 /* FunctionDeclaration */ || context.contextNode.kind === 173 /* FunctionExpression */; }; Rules.IsTypeScriptDeclWithBlockContext = function (context) { return Rules.NodeIsTypeScriptDeclWithBlockContext(context.contextNode); }; Rules.NodeIsTypeScriptDeclWithBlockContext = function (node) { switch (node.kind) { - case 212 /* ClassDeclaration */: - case 184 /* ClassExpression */: - case 213 /* InterfaceDeclaration */: - case 215 /* EnumDeclaration */: - case 153 /* TypeLiteral */: - case 216 /* ModuleDeclaration */: + case 214 /* ClassDeclaration */: + case 186 /* ClassExpression */: + case 215 /* InterfaceDeclaration */: + case 217 /* EnumDeclaration */: + case 155 /* TypeLiteral */: + case 218 /* ModuleDeclaration */: return true; } return false; }; Rules.IsAfterCodeBlockContext = function (context) { switch (context.currentTokenParent.kind) { - case 212 /* ClassDeclaration */: - case 216 /* ModuleDeclaration */: - case 215 /* EnumDeclaration */: - case 190 /* Block */: - case 242 /* CatchClause */: - case 217 /* ModuleBlock */: - case 204 /* SwitchStatement */: + case 214 /* ClassDeclaration */: + case 218 /* ModuleDeclaration */: + case 217 /* EnumDeclaration */: + case 192 /* Block */: + case 244 /* CatchClause */: + case 219 /* ModuleBlock */: + case 206 /* SwitchStatement */: return true; } return false; }; Rules.IsControlDeclContext = function (context) { switch (context.contextNode.kind) { - case 194 /* IfStatement */: - case 204 /* SwitchStatement */: - case 197 /* ForStatement */: - case 198 /* ForInStatement */: - case 199 /* ForOfStatement */: - case 196 /* WhileStatement */: - case 207 /* TryStatement */: - case 195 /* DoStatement */: - case 203 /* WithStatement */: + case 196 /* IfStatement */: + case 206 /* SwitchStatement */: + case 199 /* ForStatement */: + case 200 /* ForInStatement */: + case 201 /* ForOfStatement */: + case 198 /* WhileStatement */: + case 209 /* TryStatement */: + case 197 /* DoStatement */: + case 205 /* WithStatement */: // TODO // case SyntaxKind.ElseClause: - case 242 /* CatchClause */: + case 244 /* CatchClause */: return true; default: return false; } }; Rules.IsObjectContext = function (context) { - return context.contextNode.kind === 163 /* ObjectLiteralExpression */; + return context.contextNode.kind === 165 /* ObjectLiteralExpression */; }; Rules.IsFunctionCallContext = function (context) { - return context.contextNode.kind === 166 /* CallExpression */; + return context.contextNode.kind === 168 /* CallExpression */; }; Rules.IsNewContext = function (context) { - return context.contextNode.kind === 167 /* NewExpression */; + return context.contextNode.kind === 169 /* NewExpression */; }; Rules.IsFunctionCallOrNewContext = function (context) { return Rules.IsFunctionCallContext(context) || Rules.IsNewContext(context); @@ -40221,6 +40942,9 @@ var ts; Rules.IsPreviousTokenNotComma = function (context) { return context.currentTokenSpan.kind !== 24 /* CommaToken */; }; + Rules.IsArrowFunctionContext = function (context) { + return context.contextNode.kind === 174 /* ArrowFunction */; + }; Rules.IsSameLineTokenContext = function (context) { return context.TokensAreOnSameLine(); }; @@ -40237,41 +40961,41 @@ var ts; while (ts.isExpression(node)) { node = node.parent; } - return node.kind === 137 /* Decorator */; + return node.kind === 139 /* Decorator */; }; Rules.IsStartOfVariableDeclarationList = function (context) { - return context.currentTokenParent.kind === 210 /* VariableDeclarationList */ && + return context.currentTokenParent.kind === 212 /* VariableDeclarationList */ && context.currentTokenParent.getStart(context.sourceFile) === context.currentTokenSpan.pos; }; Rules.IsNotFormatOnEnter = function (context) { return context.formattingRequestKind !== 2 /* FormatOnEnter */; }; Rules.IsModuleDeclContext = function (context) { - return context.contextNode.kind === 216 /* ModuleDeclaration */; + return context.contextNode.kind === 218 /* ModuleDeclaration */; }; Rules.IsObjectTypeContext = function (context) { - return context.contextNode.kind === 153 /* TypeLiteral */; // && context.contextNode.parent.kind !== SyntaxKind.InterfaceDeclaration; + return context.contextNode.kind === 155 /* TypeLiteral */; // && context.contextNode.parent.kind !== SyntaxKind.InterfaceDeclaration; }; Rules.IsTypeArgumentOrParameterOrAssertion = function (token, parent) { if (token.kind !== 25 /* LessThanToken */ && token.kind !== 27 /* GreaterThanToken */) { return false; } switch (parent.kind) { - case 149 /* TypeReference */: - case 169 /* TypeAssertionExpression */: - case 212 /* ClassDeclaration */: - case 184 /* ClassExpression */: - case 213 /* InterfaceDeclaration */: - case 211 /* FunctionDeclaration */: - case 171 /* FunctionExpression */: - case 172 /* ArrowFunction */: - case 141 /* MethodDeclaration */: - case 140 /* MethodSignature */: - case 145 /* CallSignature */: - case 146 /* ConstructSignature */: - case 166 /* CallExpression */: - case 167 /* NewExpression */: - case 186 /* ExpressionWithTypeArguments */: + case 151 /* TypeReference */: + case 171 /* TypeAssertionExpression */: + case 214 /* ClassDeclaration */: + case 186 /* ClassExpression */: + case 215 /* InterfaceDeclaration */: + case 213 /* FunctionDeclaration */: + case 173 /* FunctionExpression */: + case 174 /* ArrowFunction */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: + case 147 /* CallSignature */: + case 148 /* ConstructSignature */: + case 168 /* CallExpression */: + case 169 /* NewExpression */: + case 188 /* ExpressionWithTypeArguments */: return true; default: return false; @@ -40282,13 +41006,13 @@ var ts; Rules.IsTypeArgumentOrParameterOrAssertion(context.nextTokenSpan, context.nextTokenParent); }; Rules.IsTypeAssertionContext = function (context) { - return context.contextNode.kind === 169 /* TypeAssertionExpression */; + return context.contextNode.kind === 171 /* TypeAssertionExpression */; }; Rules.IsVoidOpContext = function (context) { - return context.currentTokenSpan.kind === 101 /* VoidKeyword */ && context.currentTokenParent.kind === 175 /* VoidExpression */; + return context.currentTokenSpan.kind === 103 /* VoidKeyword */ && context.currentTokenParent.kind === 177 /* VoidExpression */; }; Rules.IsYieldOrYieldStarWithOperand = function (context) { - return context.contextNode.kind === 182 /* YieldExpression */ && context.contextNode.expression !== undefined; + return context.contextNode.kind === 184 /* YieldExpression */ && context.contextNode.expression !== undefined; }; return Rules; })(); @@ -40312,7 +41036,7 @@ var ts; return result; }; RulesMap.prototype.Initialize = function (rules) { - this.mapRowLength = 132 /* LastToken */ + 1; + this.mapRowLength = 134 /* LastToken */ + 1; this.map = new Array(this.mapRowLength * this.mapRowLength); //new Array(this.mapRowLength * this.mapRowLength); // This array is used only during construction of the rulesbucket in the map var rulesBucketConstructionStateList = new Array(this.map.length); //new Array(this.map.length); @@ -40507,7 +41231,7 @@ var ts; } TokenAllAccess.prototype.GetTokens = function () { var result = []; - for (var token = 0 /* FirstToken */; token <= 132 /* LastToken */; token++) { + for (var token = 0 /* FirstToken */; token <= 134 /* LastToken */; token++) { result.push(token); } return result; @@ -40549,17 +41273,17 @@ var ts; }; TokenRange.Any = TokenRange.AllTokens(); TokenRange.AnyIncludingMultilineComments = TokenRange.FromTokens(TokenRange.Any.GetTokens().concat([3 /* MultiLineCommentTrivia */])); - TokenRange.Keywords = TokenRange.FromRange(68 /* FirstKeyword */, 132 /* LastKeyword */); - TokenRange.BinaryOperators = TokenRange.FromRange(25 /* FirstBinaryOperator */, 66 /* LastBinaryOperator */); - TokenRange.BinaryKeywordOperators = TokenRange.FromTokens([88 /* InKeyword */, 89 /* InstanceOfKeyword */, 132 /* OfKeyword */, 114 /* AsKeyword */, 122 /* IsKeyword */]); - TokenRange.UnaryPrefixOperators = TokenRange.FromTokens([40 /* PlusPlusToken */, 41 /* MinusMinusToken */, 49 /* TildeToken */, 48 /* ExclamationToken */]); - TokenRange.UnaryPrefixExpressions = TokenRange.FromTokens([8 /* NumericLiteral */, 67 /* Identifier */, 17 /* OpenParenToken */, 19 /* OpenBracketToken */, 15 /* OpenBraceToken */, 95 /* ThisKeyword */, 90 /* NewKeyword */]); - TokenRange.UnaryPreincrementExpressions = TokenRange.FromTokens([67 /* Identifier */, 17 /* OpenParenToken */, 95 /* ThisKeyword */, 90 /* NewKeyword */]); - TokenRange.UnaryPostincrementExpressions = TokenRange.FromTokens([67 /* Identifier */, 18 /* CloseParenToken */, 20 /* CloseBracketToken */, 90 /* NewKeyword */]); - TokenRange.UnaryPredecrementExpressions = TokenRange.FromTokens([67 /* Identifier */, 17 /* OpenParenToken */, 95 /* ThisKeyword */, 90 /* NewKeyword */]); - TokenRange.UnaryPostdecrementExpressions = TokenRange.FromTokens([67 /* Identifier */, 18 /* CloseParenToken */, 20 /* CloseBracketToken */, 90 /* NewKeyword */]); + TokenRange.Keywords = TokenRange.FromRange(70 /* FirstKeyword */, 134 /* LastKeyword */); + TokenRange.BinaryOperators = TokenRange.FromRange(25 /* FirstBinaryOperator */, 68 /* LastBinaryOperator */); + TokenRange.BinaryKeywordOperators = TokenRange.FromTokens([90 /* InKeyword */, 91 /* InstanceOfKeyword */, 134 /* OfKeyword */, 116 /* AsKeyword */, 124 /* IsKeyword */]); + TokenRange.UnaryPrefixOperators = TokenRange.FromTokens([41 /* PlusPlusToken */, 42 /* MinusMinusToken */, 50 /* TildeToken */, 49 /* ExclamationToken */]); + TokenRange.UnaryPrefixExpressions = TokenRange.FromTokens([8 /* NumericLiteral */, 69 /* Identifier */, 17 /* OpenParenToken */, 19 /* OpenBracketToken */, 15 /* OpenBraceToken */, 97 /* ThisKeyword */, 92 /* NewKeyword */]); + TokenRange.UnaryPreincrementExpressions = TokenRange.FromTokens([69 /* Identifier */, 17 /* OpenParenToken */, 97 /* ThisKeyword */, 92 /* NewKeyword */]); + TokenRange.UnaryPostincrementExpressions = TokenRange.FromTokens([69 /* Identifier */, 18 /* CloseParenToken */, 20 /* CloseBracketToken */, 92 /* NewKeyword */]); + TokenRange.UnaryPredecrementExpressions = TokenRange.FromTokens([69 /* Identifier */, 17 /* OpenParenToken */, 97 /* ThisKeyword */, 92 /* NewKeyword */]); + TokenRange.UnaryPostdecrementExpressions = TokenRange.FromTokens([69 /* Identifier */, 18 /* CloseParenToken */, 20 /* CloseBracketToken */, 92 /* NewKeyword */]); TokenRange.Comments = TokenRange.FromTokens([2 /* SingleLineCommentTrivia */, 3 /* MultiLineCommentTrivia */]); - TokenRange.TypeNames = TokenRange.FromTokens([67 /* Identifier */, 126 /* NumberKeyword */, 128 /* StringKeyword */, 118 /* BooleanKeyword */, 129 /* SymbolKeyword */, 101 /* VoidKeyword */, 115 /* AnyKeyword */]); + TokenRange.TypeNames = TokenRange.FromTokens([69 /* Identifier */, 128 /* NumberKeyword */, 130 /* StringKeyword */, 120 /* BooleanKeyword */, 131 /* SymbolKeyword */, 103 /* VoidKeyword */, 117 /* AnyKeyword */]); return TokenRange; })(); Shared.TokenRange = TokenRange; @@ -40773,17 +41497,17 @@ var ts; // i.e. parent is class declaration with the list of members and node is one of members. function isListElement(parent, node) { switch (parent.kind) { - case 212 /* ClassDeclaration */: - case 213 /* InterfaceDeclaration */: + case 214 /* ClassDeclaration */: + case 215 /* InterfaceDeclaration */: return ts.rangeContainsRange(parent.members, node); - case 216 /* ModuleDeclaration */: + case 218 /* ModuleDeclaration */: var body = parent.body; - return body && body.kind === 190 /* Block */ && ts.rangeContainsRange(body.statements, node); - case 246 /* SourceFile */: - case 190 /* Block */: - case 217 /* ModuleBlock */: + return body && body.kind === 192 /* Block */ && ts.rangeContainsRange(body.statements, node); + case 248 /* SourceFile */: + case 192 /* Block */: + case 219 /* ModuleBlock */: return ts.rangeContainsRange(parent.statements, node); - case 242 /* CatchClause */: + case 244 /* CatchClause */: return ts.rangeContainsRange(parent.block.statements, node); } return false; @@ -40956,9 +41680,9 @@ var ts; // - source file // - switch\default clauses if (isSomeBlock(parent.kind) || - parent.kind === 246 /* SourceFile */ || - parent.kind === 239 /* CaseClause */ || - parent.kind === 240 /* DefaultClause */) { + parent.kind === 248 /* SourceFile */ || + parent.kind === 241 /* CaseClause */ || + parent.kind === 242 /* DefaultClause */) { indentation = parentDynamicIndentation.getIndentation() + parentDynamicIndentation.getDelta(); } else { @@ -40994,19 +41718,19 @@ var ts; return node.modifiers[0].kind; } switch (node.kind) { - case 212 /* ClassDeclaration */: return 71 /* ClassKeyword */; - case 213 /* InterfaceDeclaration */: return 105 /* InterfaceKeyword */; - case 211 /* FunctionDeclaration */: return 85 /* FunctionKeyword */; - case 215 /* EnumDeclaration */: return 215 /* EnumDeclaration */; - case 143 /* GetAccessor */: return 121 /* GetKeyword */; - case 144 /* SetAccessor */: return 127 /* SetKeyword */; - case 141 /* MethodDeclaration */: + case 214 /* ClassDeclaration */: return 73 /* ClassKeyword */; + case 215 /* InterfaceDeclaration */: return 107 /* InterfaceKeyword */; + case 213 /* FunctionDeclaration */: return 87 /* FunctionKeyword */; + case 217 /* EnumDeclaration */: return 217 /* EnumDeclaration */; + case 145 /* GetAccessor */: return 123 /* GetKeyword */; + case 146 /* SetAccessor */: return 129 /* SetKeyword */; + case 143 /* MethodDeclaration */: if (node.asteriskToken) { return 37 /* AsteriskToken */; } // fall-through - case 139 /* PropertyDeclaration */: - case 136 /* Parameter */: + case 141 /* PropertyDeclaration */: + case 138 /* Parameter */: return node.name.kind; } } @@ -41040,9 +41764,9 @@ var ts; case 20 /* CloseBracketToken */: case 17 /* OpenParenToken */: case 18 /* CloseParenToken */: - case 78 /* ElseKeyword */: - case 102 /* WhileKeyword */: - case 54 /* AtToken */: + case 80 /* ElseKeyword */: + case 104 /* WhileKeyword */: + case 55 /* AtToken */: return indentation; default: // if token line equals to the line of containing node (this is a first token in the node) - use node indentation @@ -41142,7 +41866,7 @@ var ts; consumeTokenAndAdvanceScanner(tokenInfo, node, parentDynamicIndentation); return inheritedIndentation; } - var effectiveParentStartLine = child.kind === 137 /* Decorator */ ? childStartLine : undecoratedParentStartLine; + var effectiveParentStartLine = child.kind === 139 /* Decorator */ ? childStartLine : undecoratedParentStartLine; var childIndentation = computeIndentation(child, childStartLine, childIndentationAmount, node, parentDynamicIndentation, effectiveParentStartLine); processNode(child, childContextNode, childStartLine, undecoratedChildStartLine, childIndentation.indentation, childIndentation.delta); childContextNode = node; @@ -41399,8 +42123,8 @@ var ts; for (var line = line1; line < line2; ++line) { var lineStartPosition = ts.getStartPositionOfLine(line, sourceFile); var lineEndPosition = ts.getEndLinePosition(line, sourceFile); - // do not trim whitespaces in comments - if (range && ts.isComment(range.kind) && range.pos <= lineEndPosition && range.end > lineEndPosition) { + // do not trim whitespaces in comments or template expression + if (range && (ts.isComment(range.kind) || ts.isStringOrRegularExpressionOrTemplateLiteral(range.kind)) && range.pos <= lineEndPosition && range.end > lineEndPosition) { continue; } var pos = lineEndPosition; @@ -41466,20 +42190,20 @@ var ts; } function isSomeBlock(kind) { switch (kind) { - case 190 /* Block */: - case 217 /* ModuleBlock */: + case 192 /* Block */: + case 219 /* ModuleBlock */: return true; } return false; } function getOpenTokenForList(node, list) { switch (node.kind) { - case 142 /* Constructor */: - case 211 /* FunctionDeclaration */: - case 171 /* FunctionExpression */: - case 141 /* MethodDeclaration */: - case 140 /* MethodSignature */: - case 172 /* ArrowFunction */: + case 144 /* Constructor */: + case 213 /* FunctionDeclaration */: + case 173 /* FunctionExpression */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: + case 174 /* ArrowFunction */: if (node.typeParameters === list) { return 25 /* LessThanToken */; } @@ -41487,8 +42211,8 @@ var ts; return 17 /* OpenParenToken */; } break; - case 166 /* CallExpression */: - case 167 /* NewExpression */: + case 168 /* CallExpression */: + case 169 /* NewExpression */: if (node.typeArguments === list) { return 25 /* LessThanToken */; } @@ -41496,7 +42220,7 @@ var ts; return 17 /* OpenParenToken */; } break; - case 149 /* TypeReference */: + case 151 /* TypeReference */: if (node.typeArguments === list) { return 25 /* LessThanToken */; } @@ -41580,22 +42304,39 @@ var ts; if (position > sourceFile.text.length) { return 0; // past EOF } + // no indentation when the indent style is set to none, + // so we can return fast + if (options.IndentStyle === ts.IndentStyle.None) { + return 0; + } var precedingToken = ts.findPrecedingToken(position, sourceFile); if (!precedingToken) { return 0; } // no indentation in string \regex\template literals - var precedingTokenIsLiteral = precedingToken.kind === 9 /* StringLiteral */ || - precedingToken.kind === 10 /* RegularExpressionLiteral */ || - precedingToken.kind === 11 /* NoSubstitutionTemplateLiteral */ || - precedingToken.kind === 12 /* TemplateHead */ || - precedingToken.kind === 13 /* TemplateMiddle */ || - precedingToken.kind === 14 /* TemplateTail */; + var precedingTokenIsLiteral = ts.isStringOrRegularExpressionOrTemplateLiteral(precedingToken.kind); if (precedingTokenIsLiteral && precedingToken.getStart(sourceFile) <= position && precedingToken.end > position) { return 0; } var lineAtPosition = sourceFile.getLineAndCharacterOfPosition(position).line; - if (precedingToken.kind === 24 /* CommaToken */ && precedingToken.parent.kind !== 179 /* BinaryExpression */) { + // indentation is first non-whitespace character in a previous line + // for block indentation, we should look for a line which contains something that's not + // whitespace. + if (options.IndentStyle === ts.IndentStyle.Block) { + // move backwards until we find a line with a non-whitespace character, + // then find the first non-whitespace character for that line. + var current_1 = position; + while (current_1 > 0) { + var char = sourceFile.text.charCodeAt(current_1); + if (!ts.isWhiteSpace(char) && !ts.isLineBreak(char)) { + break; + } + current_1--; + } + var lineStart = ts.getLineStartPositionForPosition(current_1, sourceFile); + return SmartIndenter.findFirstNonWhitespaceColumn(lineStart, current_1, sourceFile, options); + } + if (precedingToken.kind === 24 /* CommaToken */ && precedingToken.parent.kind !== 181 /* BinaryExpression */) { // previous token is comma that separates items in list - find the previous item and try to derive indentation from it var actualIndentation = getActualIndentationForListItemBeforeComma(precedingToken, sourceFile, options); if (actualIndentation !== -1 /* Unknown */) { @@ -41714,7 +42455,7 @@ var ts; // - parent is SourceFile - by default immediate children of SourceFile are not indented except when user indents them manually // - parent and child are not on the same line var useActualIndentation = (ts.isDeclaration(current) || ts.isStatement(current)) && - (parent.kind === 246 /* SourceFile */ || !parentAndChildShareLine); + (parent.kind === 248 /* SourceFile */ || !parentAndChildShareLine); if (!useActualIndentation) { return -1 /* Unknown */; } @@ -41747,8 +42488,8 @@ var ts; return sourceFile.getLineAndCharacterOfPosition(n.getStart(sourceFile)); } function childStartsOnTheSameLineWithElseInIfStatement(parent, child, childStartLine, sourceFile) { - if (parent.kind === 194 /* IfStatement */ && parent.elseStatement === child) { - var elseKeyword = ts.findChildOfKind(parent, 78 /* ElseKeyword */, sourceFile); + if (parent.kind === 196 /* IfStatement */ && parent.elseStatement === child) { + var elseKeyword = ts.findChildOfKind(parent, 80 /* ElseKeyword */, sourceFile); ts.Debug.assert(elseKeyword !== undefined); var elseKeywordStartLine = getStartLineAndCharacterForNode(elseKeyword, sourceFile).line; return elseKeywordStartLine === childStartLine; @@ -41759,23 +42500,23 @@ var ts; function getContainingList(node, sourceFile) { if (node.parent) { switch (node.parent.kind) { - case 149 /* TypeReference */: + case 151 /* TypeReference */: if (node.parent.typeArguments && ts.rangeContainsStartEnd(node.parent.typeArguments, node.getStart(sourceFile), node.getEnd())) { return node.parent.typeArguments; } break; - case 163 /* ObjectLiteralExpression */: + case 165 /* ObjectLiteralExpression */: return node.parent.properties; - case 162 /* ArrayLiteralExpression */: + case 164 /* ArrayLiteralExpression */: return node.parent.elements; - case 211 /* FunctionDeclaration */: - case 171 /* FunctionExpression */: - case 172 /* ArrowFunction */: - case 141 /* MethodDeclaration */: - case 140 /* MethodSignature */: - case 145 /* CallSignature */: - case 146 /* ConstructSignature */: { + case 213 /* FunctionDeclaration */: + case 173 /* FunctionExpression */: + case 174 /* ArrowFunction */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: + case 147 /* CallSignature */: + case 148 /* ConstructSignature */: { var start = node.getStart(sourceFile); if (node.parent.typeParameters && ts.rangeContainsStartEnd(node.parent.typeParameters, start, node.getEnd())) { @@ -41786,8 +42527,8 @@ var ts; } break; } - case 167 /* NewExpression */: - case 166 /* CallExpression */: { + case 169 /* NewExpression */: + case 168 /* CallExpression */: { var start = node.getStart(sourceFile); if (node.parent.typeArguments && ts.rangeContainsStartEnd(node.parent.typeArguments, start, node.getEnd())) { @@ -41817,8 +42558,8 @@ var ts; if (node.kind === 18 /* CloseParenToken */) { return -1 /* Unknown */; } - if (node.parent && (node.parent.kind === 166 /* CallExpression */ || - node.parent.kind === 167 /* NewExpression */) && + if (node.parent && (node.parent.kind === 168 /* CallExpression */ || + node.parent.kind === 169 /* NewExpression */) && node.parent.expression !== node) { var fullCallOrNewExpression = node.parent.expression; var startingExpression = getStartingExpression(fullCallOrNewExpression); @@ -41836,10 +42577,10 @@ var ts; function getStartingExpression(node) { while (true) { switch (node.kind) { - case 166 /* CallExpression */: - case 167 /* NewExpression */: - case 164 /* PropertyAccessExpression */: - case 165 /* ElementAccessExpression */: + case 168 /* CallExpression */: + case 169 /* NewExpression */: + case 166 /* PropertyAccessExpression */: + case 167 /* ElementAccessExpression */: node = node.expression; break; default: @@ -41904,42 +42645,43 @@ var ts; SmartIndenter.findFirstNonWhitespaceColumn = findFirstNonWhitespaceColumn; function nodeContentIsAlwaysIndented(kind) { switch (kind) { - case 212 /* ClassDeclaration */: - case 184 /* ClassExpression */: - case 213 /* InterfaceDeclaration */: - case 215 /* EnumDeclaration */: - case 214 /* TypeAliasDeclaration */: - case 162 /* ArrayLiteralExpression */: - case 190 /* Block */: - case 217 /* ModuleBlock */: - case 163 /* ObjectLiteralExpression */: - case 153 /* TypeLiteral */: - case 155 /* TupleType */: - case 218 /* CaseBlock */: - case 240 /* DefaultClause */: - case 239 /* CaseClause */: - case 170 /* ParenthesizedExpression */: - case 164 /* PropertyAccessExpression */: - case 166 /* CallExpression */: - case 167 /* NewExpression */: - case 191 /* VariableStatement */: - case 209 /* VariableDeclaration */: - case 225 /* ExportAssignment */: - case 202 /* ReturnStatement */: - case 180 /* ConditionalExpression */: - case 160 /* ArrayBindingPattern */: - case 159 /* ObjectBindingPattern */: - case 231 /* JsxElement */: - case 232 /* JsxSelfClosingElement */: - case 140 /* MethodSignature */: - case 145 /* CallSignature */: - case 146 /* ConstructSignature */: - case 136 /* Parameter */: - case 150 /* FunctionType */: - case 151 /* ConstructorType */: - case 158 /* ParenthesizedType */: - case 168 /* TaggedTemplateExpression */: - case 176 /* AwaitExpression */: + case 195 /* ExpressionStatement */: + case 214 /* ClassDeclaration */: + case 186 /* ClassExpression */: + case 215 /* InterfaceDeclaration */: + case 217 /* EnumDeclaration */: + case 216 /* TypeAliasDeclaration */: + case 164 /* ArrayLiteralExpression */: + case 192 /* Block */: + case 219 /* ModuleBlock */: + case 165 /* ObjectLiteralExpression */: + case 155 /* TypeLiteral */: + case 157 /* TupleType */: + case 220 /* CaseBlock */: + case 242 /* DefaultClause */: + case 241 /* CaseClause */: + case 172 /* ParenthesizedExpression */: + case 166 /* PropertyAccessExpression */: + case 168 /* CallExpression */: + case 169 /* NewExpression */: + case 193 /* VariableStatement */: + case 211 /* VariableDeclaration */: + case 227 /* ExportAssignment */: + case 204 /* ReturnStatement */: + case 182 /* ConditionalExpression */: + case 162 /* ArrayBindingPattern */: + case 161 /* ObjectBindingPattern */: + case 233 /* JsxElement */: + case 234 /* JsxSelfClosingElement */: + case 142 /* MethodSignature */: + case 147 /* CallSignature */: + case 148 /* ConstructSignature */: + case 138 /* Parameter */: + case 152 /* FunctionType */: + case 153 /* ConstructorType */: + case 160 /* ParenthesizedType */: + case 170 /* TaggedTemplateExpression */: + case 178 /* AwaitExpression */: return true; } return false; @@ -41949,20 +42691,20 @@ var ts; return true; } switch (parent) { - case 195 /* DoStatement */: - case 196 /* WhileStatement */: - case 198 /* ForInStatement */: - case 199 /* ForOfStatement */: - case 197 /* ForStatement */: - case 194 /* IfStatement */: - case 211 /* FunctionDeclaration */: - case 171 /* FunctionExpression */: - case 141 /* MethodDeclaration */: - case 172 /* ArrowFunction */: - case 142 /* Constructor */: - case 143 /* GetAccessor */: - case 144 /* SetAccessor */: - return child !== 190 /* Block */; + case 197 /* DoStatement */: + case 198 /* WhileStatement */: + case 200 /* ForInStatement */: + case 201 /* ForOfStatement */: + case 199 /* ForStatement */: + case 196 /* IfStatement */: + case 213 /* FunctionDeclaration */: + case 173 /* FunctionExpression */: + case 143 /* MethodDeclaration */: + case 174 /* ArrowFunction */: + case 144 /* Constructor */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: + return child !== 192 /* Block */; default: return false; } @@ -42104,7 +42846,7 @@ var ts; return pos; }; NodeObject.prototype.createSyntaxList = function (nodes) { - var list = createNode(269 /* SyntaxList */, nodes.pos, nodes.end, 4096 /* Synthetic */, this); + var list = createNode(271 /* SyntaxList */, nodes.pos, nodes.end, 4096 /* Synthetic */, this); list._children = []; var pos = nodes.pos; for (var _i = 0; _i < nodes.length; _i++) { @@ -42123,7 +42865,7 @@ var ts; NodeObject.prototype.createChildren = function (sourceFile) { var _this = this; var children; - if (this.kind >= 133 /* FirstNode */) { + if (this.kind >= 135 /* FirstNode */) { scanner.setText((sourceFile || this.getSourceFile()).text); children = []; var pos = this.pos; @@ -42170,7 +42912,7 @@ var ts; return undefined; } var child = children[0]; - return child.kind < 133 /* FirstNode */ ? child : child.getFirstToken(sourceFile); + return child.kind < 135 /* FirstNode */ ? child : child.getFirstToken(sourceFile); }; NodeObject.prototype.getLastToken = function (sourceFile) { var children = this.getChildren(sourceFile); @@ -42178,7 +42920,7 @@ var ts; if (!child) { return undefined; } - return child.kind < 133 /* FirstNode */ ? child : child.getLastToken(sourceFile); + return child.kind < 135 /* FirstNode */ ? child : child.getLastToken(sourceFile); }; return NodeObject; })(); @@ -42227,7 +42969,7 @@ var ts; if (ts.indexOf(declarations, declaration) === indexOfDeclaration) { var sourceFileOfDeclaration = ts.getSourceFileOfNode(declaration); // If it is parameter - try and get the jsDoc comment with @param tag from function declaration's jsDoc comments - if (canUseParsedParamTagComments && declaration.kind === 136 /* Parameter */) { + if (canUseParsedParamTagComments && declaration.kind === 138 /* Parameter */) { ts.forEach(getJsDocCommentTextRange(declaration.parent, sourceFileOfDeclaration), function (jsDocCommentTextRange) { var cleanedParamJsDocComment = getCleanedParamJsDocComment(jsDocCommentTextRange.pos, jsDocCommentTextRange.end, sourceFileOfDeclaration); if (cleanedParamJsDocComment) { @@ -42236,15 +42978,15 @@ var ts; }); } // If this is left side of dotted module declaration, there is no doc comments associated with this node - if (declaration.kind === 216 /* ModuleDeclaration */ && declaration.body.kind === 216 /* ModuleDeclaration */) { + if (declaration.kind === 218 /* ModuleDeclaration */ && declaration.body.kind === 218 /* ModuleDeclaration */) { return; } // If this is dotted module name, get the doc comments from the parent - while (declaration.kind === 216 /* ModuleDeclaration */ && declaration.parent.kind === 216 /* ModuleDeclaration */) { + while (declaration.kind === 218 /* ModuleDeclaration */ && declaration.parent.kind === 218 /* ModuleDeclaration */) { declaration = declaration.parent; } // Get the cleaned js doc comment text from the declaration - ts.forEach(getJsDocCommentTextRange(declaration.kind === 209 /* VariableDeclaration */ ? declaration.parent.parent : declaration, sourceFileOfDeclaration), function (jsDocCommentTextRange) { + ts.forEach(getJsDocCommentTextRange(declaration.kind === 211 /* VariableDeclaration */ ? declaration.parent.parent : declaration, sourceFileOfDeclaration), function (jsDocCommentTextRange) { var cleanedJsDocComment = getCleanedJsDocComment(jsDocCommentTextRange.pos, jsDocCommentTextRange.end, sourceFileOfDeclaration); if (cleanedJsDocComment) { ts.addRange(jsDocCommentParts, cleanedJsDocComment); @@ -42588,9 +43330,9 @@ var ts; if (result_2 !== undefined) { return result_2; } - if (declaration.name.kind === 134 /* ComputedPropertyName */) { + if (declaration.name.kind === 136 /* ComputedPropertyName */) { var expr = declaration.name.expression; - if (expr.kind === 164 /* PropertyAccessExpression */) { + if (expr.kind === 166 /* PropertyAccessExpression */) { return expr.name.text; } return getTextOfIdentifierOrLiteral(expr); @@ -42600,7 +43342,7 @@ var ts; } function getTextOfIdentifierOrLiteral(node) { if (node) { - if (node.kind === 67 /* Identifier */ || + if (node.kind === 69 /* Identifier */ || node.kind === 9 /* StringLiteral */ || node.kind === 8 /* NumericLiteral */) { return node.text; @@ -42610,9 +43352,9 @@ var ts; } function visit(node) { switch (node.kind) { - case 211 /* FunctionDeclaration */: - case 141 /* MethodDeclaration */: - case 140 /* MethodSignature */: + case 213 /* FunctionDeclaration */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: var functionDeclaration = node; var declarationName = getDeclarationName(functionDeclaration); if (declarationName) { @@ -42632,60 +43374,60 @@ var ts; ts.forEachChild(node, visit); } break; - case 212 /* ClassDeclaration */: - case 213 /* InterfaceDeclaration */: - case 214 /* TypeAliasDeclaration */: - case 215 /* EnumDeclaration */: - case 216 /* ModuleDeclaration */: - case 219 /* ImportEqualsDeclaration */: - case 228 /* ExportSpecifier */: - case 224 /* ImportSpecifier */: - case 219 /* ImportEqualsDeclaration */: - case 221 /* ImportClause */: - case 222 /* NamespaceImport */: - case 143 /* GetAccessor */: - case 144 /* SetAccessor */: - case 153 /* TypeLiteral */: + case 214 /* ClassDeclaration */: + case 215 /* InterfaceDeclaration */: + case 216 /* TypeAliasDeclaration */: + case 217 /* EnumDeclaration */: + case 218 /* ModuleDeclaration */: + case 221 /* ImportEqualsDeclaration */: + case 230 /* ExportSpecifier */: + case 226 /* ImportSpecifier */: + case 221 /* ImportEqualsDeclaration */: + case 223 /* ImportClause */: + case 224 /* NamespaceImport */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: + case 155 /* TypeLiteral */: addDeclaration(node); // fall through - case 142 /* Constructor */: - case 191 /* VariableStatement */: - case 210 /* VariableDeclarationList */: - case 159 /* ObjectBindingPattern */: - case 160 /* ArrayBindingPattern */: - case 217 /* ModuleBlock */: + case 144 /* Constructor */: + case 193 /* VariableStatement */: + case 212 /* VariableDeclarationList */: + case 161 /* ObjectBindingPattern */: + case 162 /* ArrayBindingPattern */: + case 219 /* ModuleBlock */: ts.forEachChild(node, visit); break; - case 190 /* Block */: + case 192 /* Block */: if (ts.isFunctionBlock(node)) { ts.forEachChild(node, visit); } break; - case 136 /* Parameter */: + case 138 /* Parameter */: // Only consider properties defined as constructor parameters if (!(node.flags & 112 /* AccessibilityModifier */)) { break; } // fall through - case 209 /* VariableDeclaration */: - case 161 /* BindingElement */: + case 211 /* VariableDeclaration */: + case 163 /* BindingElement */: if (ts.isBindingPattern(node.name)) { ts.forEachChild(node.name, visit); break; } - case 245 /* EnumMember */: - case 139 /* PropertyDeclaration */: - case 138 /* PropertySignature */: + case 247 /* EnumMember */: + case 141 /* PropertyDeclaration */: + case 140 /* PropertySignature */: addDeclaration(node); break; - case 226 /* ExportDeclaration */: + case 228 /* ExportDeclaration */: // Handle named exports case e.g.: // export {a, b as B} from "mod"; if (node.exportClause) { ts.forEach(node.exportClause.elements, visit); } break; - case 220 /* ImportDeclaration */: + case 222 /* ImportDeclaration */: var importClause = node.importClause; if (importClause) { // Handle default import case e.g.: @@ -42697,7 +43439,7 @@ var ts; // import * as NS from "mod"; // import {a, b as B} from "mod"; if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 222 /* NamespaceImport */) { + if (importClause.namedBindings.kind === 224 /* NamespaceImport */) { addDeclaration(importClause.namedBindings); } else { @@ -42724,6 +43466,12 @@ var ts; HighlightSpanKind.reference = "reference"; HighlightSpanKind.writtenReference = "writtenReference"; })(HighlightSpanKind = ts.HighlightSpanKind || (ts.HighlightSpanKind = {})); + (function (IndentStyle) { + IndentStyle[IndentStyle["None"] = 0] = "None"; + IndentStyle[IndentStyle["Block"] = 1] = "Block"; + IndentStyle[IndentStyle["Smart"] = 2] = "Smart"; + })(ts.IndentStyle || (ts.IndentStyle = {})); + var IndentStyle = ts.IndentStyle; (function (SymbolDisplayPartKind) { SymbolDisplayPartKind[SymbolDisplayPartKind["aliasName"] = 0] = "aliasName"; SymbolDisplayPartKind[SymbolDisplayPartKind["className"] = 1] = "className"; @@ -42901,16 +43649,16 @@ var ts; } return ts.forEach(symbol.declarations, function (declaration) { // Function expressions are local - if (declaration.kind === 171 /* FunctionExpression */) { + if (declaration.kind === 173 /* FunctionExpression */) { return true; } - if (declaration.kind !== 209 /* VariableDeclaration */ && declaration.kind !== 211 /* FunctionDeclaration */) { + if (declaration.kind !== 211 /* VariableDeclaration */ && declaration.kind !== 213 /* FunctionDeclaration */) { return false; } // If the parent is not sourceFile or module block it is local variable for (var parent_8 = declaration.parent; !ts.isFunctionBlock(parent_8); parent_8 = parent_8.parent) { // Reached source file or module block - if (parent_8.kind === 246 /* SourceFile */ || parent_8.kind === 217 /* ModuleBlock */) { + if (parent_8.kind === 248 /* SourceFile */ || parent_8.kind === 219 /* ModuleBlock */) { return false; } } @@ -43047,8 +43795,8 @@ var ts; // We are not doing a full typecheck, we are not resolving the whole context, // so pass --noResolve to avoid reporting missing file errors. options.noResolve = true; - // Parse - var inputFileName = transpileOptions.fileName || "module.ts"; + // if jsx is specified then treat file as .tsx + var inputFileName = transpileOptions.fileName || (options.jsx ? "module.tsx" : "module.ts"); var sourceFile = ts.createSourceFile(inputFileName, input, options.target); if (transpileOptions.moduleName) { sourceFile.moduleName = transpileOptions.moduleName; @@ -43260,8 +44008,9 @@ var ts; }; } ts.createDocumentRegistry = createDocumentRegistry; - function preProcessFile(sourceText, readImportFiles) { + function preProcessFile(sourceText, readImportFiles, detectJavaScriptImports) { if (readImportFiles === void 0) { readImportFiles = true; } + if (detectJavaScriptImports === void 0) { detectJavaScriptImports = false; } var referencedFiles = []; var importedFiles = []; var ambientExternalModules; @@ -43295,9 +44044,207 @@ var ts; end: pos + importPath.length }); } - function processImport() { + /** + * Returns true if at least one token was consumed from the stream + */ + function tryConsumeDeclare() { + var token = scanner.getToken(); + if (token === 122 /* DeclareKeyword */) { + // declare module "mod" + token = scanner.scan(); + if (token === 125 /* ModuleKeyword */) { + token = scanner.scan(); + if (token === 9 /* StringLiteral */) { + recordAmbientExternalModule(); + } + } + return true; + } + return false; + } + /** + * Returns true if at least one token was consumed from the stream + */ + function tryConsumeImport() { + var token = scanner.getToken(); + if (token === 89 /* ImportKeyword */) { + token = scanner.scan(); + if (token === 9 /* StringLiteral */) { + // import "mod"; + recordModuleName(); + return true; + } + else { + if (token === 69 /* Identifier */ || ts.isKeyword(token)) { + token = scanner.scan(); + if (token === 133 /* FromKeyword */) { + token = scanner.scan(); + if (token === 9 /* StringLiteral */) { + // import d from "mod"; + recordModuleName(); + return true; + } + } + else if (token === 56 /* EqualsToken */) { + if (tryConsumeRequireCall(/* skipCurrentToken */ true)) { + return true; + } + } + else if (token === 24 /* CommaToken */) { + // consume comma and keep going + token = scanner.scan(); + } + else { + // unknown syntax + return true; + } + } + if (token === 15 /* OpenBraceToken */) { + token = scanner.scan(); + // consume "{ a as B, c, d as D}" clauses + // make sure that it stops on EOF + while (token !== 16 /* CloseBraceToken */ && token !== 1 /* EndOfFileToken */) { + token = scanner.scan(); + } + if (token === 16 /* CloseBraceToken */) { + token = scanner.scan(); + if (token === 133 /* FromKeyword */) { + token = scanner.scan(); + if (token === 9 /* StringLiteral */) { + // import {a as A} from "mod"; + // import d, {a, b as B} from "mod" + recordModuleName(); + } + } + } + } + else if (token === 37 /* AsteriskToken */) { + token = scanner.scan(); + if (token === 116 /* AsKeyword */) { + token = scanner.scan(); + if (token === 69 /* Identifier */ || ts.isKeyword(token)) { + token = scanner.scan(); + if (token === 133 /* FromKeyword */) { + token = scanner.scan(); + if (token === 9 /* StringLiteral */) { + // import * as NS from "mod" + // import d, * as NS from "mod" + recordModuleName(); + } + } + } + } + } + } + return true; + } + return false; + } + function tryConsumeExport() { + var token = scanner.getToken(); + if (token === 82 /* ExportKeyword */) { + token = scanner.scan(); + if (token === 15 /* OpenBraceToken */) { + token = scanner.scan(); + // consume "{ a as B, c, d as D}" clauses + // make sure it stops on EOF + while (token !== 16 /* CloseBraceToken */ && token !== 1 /* EndOfFileToken */) { + token = scanner.scan(); + } + if (token === 16 /* CloseBraceToken */) { + token = scanner.scan(); + if (token === 133 /* FromKeyword */) { + token = scanner.scan(); + if (token === 9 /* StringLiteral */) { + // export {a as A} from "mod"; + // export {a, b as B} from "mod" + recordModuleName(); + } + } + } + } + else if (token === 37 /* AsteriskToken */) { + token = scanner.scan(); + if (token === 133 /* FromKeyword */) { + token = scanner.scan(); + if (token === 9 /* StringLiteral */) { + // export * from "mod" + recordModuleName(); + } + } + } + else if (token === 89 /* ImportKeyword */) { + token = scanner.scan(); + if (token === 69 /* Identifier */ || ts.isKeyword(token)) { + token = scanner.scan(); + if (token === 56 /* EqualsToken */) { + if (tryConsumeRequireCall(/* skipCurrentToken */ true)) { + return true; + } + } + } + } + return true; + } + return false; + } + function tryConsumeRequireCall(skipCurrentToken) { + var token = skipCurrentToken ? scanner.scan() : scanner.getToken(); + if (token === 127 /* RequireKeyword */) { + token = scanner.scan(); + if (token === 17 /* OpenParenToken */) { + token = scanner.scan(); + if (token === 9 /* StringLiteral */) { + // require("mod"); + recordModuleName(); + } + } + return true; + } + return false; + } + function tryConsumeDefine() { + var token = scanner.getToken(); + if (token === 69 /* Identifier */ && scanner.getTokenValue() === "define") { + token = scanner.scan(); + if (token !== 17 /* OpenParenToken */) { + return true; + } + token = scanner.scan(); + if (token === 9 /* StringLiteral */) { + // looks like define ("modname", ... - skip string literal and comma + token = scanner.scan(); + if (token === 24 /* CommaToken */) { + token = scanner.scan(); + } + else { + // unexpected token + return true; + } + } + // should be start of dependency list + if (token !== 19 /* OpenBracketToken */) { + return true; + } + // skip open bracket + token = scanner.scan(); + var i = 0; + // scan until ']' or EOF + while (token !== 20 /* CloseBracketToken */ && token !== 1 /* EndOfFileToken */) { + // record string literals as module names + if (token === 9 /* StringLiteral */) { + recordModuleName(); + i++; + } + token = scanner.scan(); + } + return true; + } + return false; + } + function processImports() { scanner.setText(sourceText); - var token = scanner.scan(); + scanner.scan(); // Look for: // import "mod"; // import d from "mod" @@ -43309,152 +44256,26 @@ var ts; // export * from "mod" // export {a as b} from "mod" // export import i = require("mod") - while (token !== 1 /* EndOfFileToken */) { - if (token === 120 /* DeclareKeyword */) { - // declare module "mod" - token = scanner.scan(); - if (token === 123 /* ModuleKeyword */) { - token = scanner.scan(); - if (token === 9 /* StringLiteral */) { - recordAmbientExternalModule(); - continue; - } - } + // (for JavaScript files) require("mod") + while (true) { + if (scanner.getToken() === 1 /* EndOfFileToken */) { + break; } - else if (token === 87 /* ImportKeyword */) { - token = scanner.scan(); - if (token === 9 /* StringLiteral */) { - // import "mod"; - recordModuleName(); - continue; - } - else { - if (token === 67 /* Identifier */ || ts.isKeyword(token)) { - token = scanner.scan(); - if (token === 131 /* FromKeyword */) { - token = scanner.scan(); - if (token === 9 /* StringLiteral */) { - // import d from "mod"; - recordModuleName(); - continue; - } - } - else if (token === 55 /* EqualsToken */) { - token = scanner.scan(); - if (token === 125 /* RequireKeyword */) { - token = scanner.scan(); - if (token === 17 /* OpenParenToken */) { - token = scanner.scan(); - if (token === 9 /* StringLiteral */) { - // import i = require("mod"); - recordModuleName(); - continue; - } - } - } - } - else if (token === 24 /* CommaToken */) { - // consume comma and keep going - token = scanner.scan(); - } - else { - // unknown syntax - continue; - } - } - if (token === 15 /* OpenBraceToken */) { - token = scanner.scan(); - // consume "{ a as B, c, d as D}" clauses - while (token !== 16 /* CloseBraceToken */) { - token = scanner.scan(); - } - if (token === 16 /* CloseBraceToken */) { - token = scanner.scan(); - if (token === 131 /* FromKeyword */) { - token = scanner.scan(); - if (token === 9 /* StringLiteral */) { - // import {a as A} from "mod"; - // import d, {a, b as B} from "mod" - recordModuleName(); - } - } - } - } - else if (token === 37 /* AsteriskToken */) { - token = scanner.scan(); - if (token === 114 /* AsKeyword */) { - token = scanner.scan(); - if (token === 67 /* Identifier */ || ts.isKeyword(token)) { - token = scanner.scan(); - if (token === 131 /* FromKeyword */) { - token = scanner.scan(); - if (token === 9 /* StringLiteral */) { - // import * as NS from "mod" - // import d, * as NS from "mod" - recordModuleName(); - } - } - } - } - } - } + // check if at least one of alternative have moved scanner forward + if (tryConsumeDeclare() || + tryConsumeImport() || + tryConsumeExport() || + (detectJavaScriptImports && (tryConsumeRequireCall(/* skipCurrentToken */ false) || tryConsumeDefine()))) { + continue; } - else if (token === 80 /* ExportKeyword */) { - token = scanner.scan(); - if (token === 15 /* OpenBraceToken */) { - token = scanner.scan(); - // consume "{ a as B, c, d as D}" clauses - while (token !== 16 /* CloseBraceToken */) { - token = scanner.scan(); - } - if (token === 16 /* CloseBraceToken */) { - token = scanner.scan(); - if (token === 131 /* FromKeyword */) { - token = scanner.scan(); - if (token === 9 /* StringLiteral */) { - // export {a as A} from "mod"; - // export {a, b as B} from "mod" - recordModuleName(); - } - } - } - } - else if (token === 37 /* AsteriskToken */) { - token = scanner.scan(); - if (token === 131 /* FromKeyword */) { - token = scanner.scan(); - if (token === 9 /* StringLiteral */) { - // export * from "mod" - recordModuleName(); - } - } - } - else if (token === 87 /* ImportKeyword */) { - token = scanner.scan(); - if (token === 67 /* Identifier */ || ts.isKeyword(token)) { - token = scanner.scan(); - if (token === 55 /* EqualsToken */) { - token = scanner.scan(); - if (token === 125 /* RequireKeyword */) { - token = scanner.scan(); - if (token === 17 /* OpenParenToken */) { - token = scanner.scan(); - if (token === 9 /* StringLiteral */) { - // export import i = require("mod"); - recordModuleName(); - } - } - } - } - } - } + else { + scanner.scan(); } - token = scanner.scan(); } scanner.setText(undefined); } if (readImportFiles) { - processImport(); + processImports(); } processTripleSlashDirectives(); return { referencedFiles: referencedFiles, importedFiles: importedFiles, isLibFile: isNoDefaultLib, ambientExternalModules: ambientExternalModules }; @@ -43463,7 +44284,7 @@ var ts; /// Helpers function getTargetLabel(referenceNode, labelName) { while (referenceNode) { - if (referenceNode.kind === 205 /* LabeledStatement */ && referenceNode.label.text === labelName) { + if (referenceNode.kind === 207 /* LabeledStatement */ && referenceNode.label.text === labelName) { return referenceNode.label; } referenceNode = referenceNode.parent; @@ -43471,13 +44292,13 @@ var ts; return undefined; } function isJumpStatementTarget(node) { - return node.kind === 67 /* Identifier */ && - (node.parent.kind === 201 /* BreakStatement */ || node.parent.kind === 200 /* ContinueStatement */) && + return node.kind === 69 /* Identifier */ && + (node.parent.kind === 203 /* BreakStatement */ || node.parent.kind === 202 /* ContinueStatement */) && node.parent.label === node; } function isLabelOfLabeledStatement(node) { - return node.kind === 67 /* Identifier */ && - node.parent.kind === 205 /* LabeledStatement */ && + return node.kind === 69 /* Identifier */ && + node.parent.kind === 207 /* LabeledStatement */ && node.parent.label === node; } /** @@ -43485,7 +44306,7 @@ var ts; * Note: 'node' cannot be a SourceFile. */ function isLabeledBy(node, labelName) { - for (var owner = node.parent; owner.kind === 205 /* LabeledStatement */; owner = owner.parent) { + for (var owner = node.parent; owner.kind === 207 /* LabeledStatement */; owner = owner.parent) { if (owner.label.text === labelName) { return true; } @@ -43496,49 +44317,49 @@ var ts; return isLabelOfLabeledStatement(node) || isJumpStatementTarget(node); } function isRightSideOfQualifiedName(node) { - return node.parent.kind === 133 /* QualifiedName */ && node.parent.right === node; + return node.parent.kind === 135 /* QualifiedName */ && node.parent.right === node; } function isRightSideOfPropertyAccess(node) { - return node && node.parent && node.parent.kind === 164 /* PropertyAccessExpression */ && node.parent.name === node; + return node && node.parent && node.parent.kind === 166 /* PropertyAccessExpression */ && node.parent.name === node; } function isCallExpressionTarget(node) { if (isRightSideOfPropertyAccess(node)) { node = node.parent; } - return node && node.parent && node.parent.kind === 166 /* CallExpression */ && node.parent.expression === node; + return node && node.parent && node.parent.kind === 168 /* CallExpression */ && node.parent.expression === node; } function isNewExpressionTarget(node) { if (isRightSideOfPropertyAccess(node)) { node = node.parent; } - return node && node.parent && node.parent.kind === 167 /* NewExpression */ && node.parent.expression === node; + return node && node.parent && node.parent.kind === 169 /* NewExpression */ && node.parent.expression === node; } function isNameOfModuleDeclaration(node) { - return node.parent.kind === 216 /* ModuleDeclaration */ && node.parent.name === node; + return node.parent.kind === 218 /* ModuleDeclaration */ && node.parent.name === node; } function isNameOfFunctionDeclaration(node) { - return node.kind === 67 /* Identifier */ && + return node.kind === 69 /* Identifier */ && ts.isFunctionLike(node.parent) && node.parent.name === node; } /** Returns true if node is a name of an object literal property, e.g. "a" in x = { "a": 1 } */ function isNameOfPropertyAssignment(node) { - return (node.kind === 67 /* Identifier */ || node.kind === 9 /* StringLiteral */ || node.kind === 8 /* NumericLiteral */) && - (node.parent.kind === 243 /* PropertyAssignment */ || node.parent.kind === 244 /* ShorthandPropertyAssignment */) && node.parent.name === node; + return (node.kind === 69 /* Identifier */ || node.kind === 9 /* StringLiteral */ || node.kind === 8 /* NumericLiteral */) && + (node.parent.kind === 245 /* PropertyAssignment */ || node.parent.kind === 246 /* ShorthandPropertyAssignment */) && node.parent.name === node; } function isLiteralNameOfPropertyDeclarationOrIndexAccess(node) { if (node.kind === 9 /* StringLiteral */ || node.kind === 8 /* NumericLiteral */) { switch (node.parent.kind) { - case 139 /* PropertyDeclaration */: - case 138 /* PropertySignature */: - case 243 /* PropertyAssignment */: - case 245 /* EnumMember */: - case 141 /* MethodDeclaration */: - case 140 /* MethodSignature */: - case 143 /* GetAccessor */: - case 144 /* SetAccessor */: - case 216 /* ModuleDeclaration */: + case 141 /* PropertyDeclaration */: + case 140 /* PropertySignature */: + case 245 /* PropertyAssignment */: + case 247 /* EnumMember */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: + case 218 /* ModuleDeclaration */: return node.parent.name === node; - case 165 /* ElementAccessExpression */: + case 167 /* ElementAccessExpression */: return node.parent.argumentExpression === node; } } @@ -43597,7 +44418,7 @@ var ts; })(BreakContinueSearchType || (BreakContinueSearchType = {})); // A cache of completion entries for keywords, these do not change between sessions var keywordCompletions = []; - for (var i = 68 /* FirstKeyword */; i <= 132 /* LastKeyword */; i++) { + for (var i = 70 /* FirstKeyword */; i <= 134 /* LastKeyword */; i++) { keywordCompletions.push({ name: ts.tokenToString(i), kind: ScriptElementKind.keyword, @@ -43612,17 +44433,17 @@ var ts; return undefined; } switch (node.kind) { - case 246 /* SourceFile */: - case 141 /* MethodDeclaration */: - case 140 /* MethodSignature */: - case 211 /* FunctionDeclaration */: - case 171 /* FunctionExpression */: - case 143 /* GetAccessor */: - case 144 /* SetAccessor */: - case 212 /* ClassDeclaration */: - case 213 /* InterfaceDeclaration */: - case 215 /* EnumDeclaration */: - case 216 /* ModuleDeclaration */: + case 248 /* SourceFile */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: + case 213 /* FunctionDeclaration */: + case 173 /* FunctionExpression */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: + case 214 /* ClassDeclaration */: + case 215 /* InterfaceDeclaration */: + case 217 /* EnumDeclaration */: + case 218 /* ModuleDeclaration */: return node; } } @@ -43630,38 +44451,38 @@ var ts; ts.getContainerNode = getContainerNode; /* @internal */ function getNodeKind(node) { switch (node.kind) { - case 216 /* ModuleDeclaration */: return ScriptElementKind.moduleElement; - case 212 /* ClassDeclaration */: return ScriptElementKind.classElement; - case 213 /* InterfaceDeclaration */: return ScriptElementKind.interfaceElement; - case 214 /* TypeAliasDeclaration */: return ScriptElementKind.typeElement; - case 215 /* EnumDeclaration */: return ScriptElementKind.enumElement; - case 209 /* VariableDeclaration */: + case 218 /* ModuleDeclaration */: return ScriptElementKind.moduleElement; + case 214 /* ClassDeclaration */: return ScriptElementKind.classElement; + case 215 /* InterfaceDeclaration */: return ScriptElementKind.interfaceElement; + case 216 /* TypeAliasDeclaration */: return ScriptElementKind.typeElement; + case 217 /* EnumDeclaration */: return ScriptElementKind.enumElement; + case 211 /* VariableDeclaration */: return ts.isConst(node) ? ScriptElementKind.constElement : ts.isLet(node) ? ScriptElementKind.letElement : ScriptElementKind.variableElement; - case 211 /* FunctionDeclaration */: return ScriptElementKind.functionElement; - case 143 /* GetAccessor */: return ScriptElementKind.memberGetAccessorElement; - case 144 /* SetAccessor */: return ScriptElementKind.memberSetAccessorElement; - case 141 /* MethodDeclaration */: - case 140 /* MethodSignature */: + case 213 /* FunctionDeclaration */: return ScriptElementKind.functionElement; + case 145 /* GetAccessor */: return ScriptElementKind.memberGetAccessorElement; + case 146 /* SetAccessor */: return ScriptElementKind.memberSetAccessorElement; + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: return ScriptElementKind.memberFunctionElement; - case 139 /* PropertyDeclaration */: - case 138 /* PropertySignature */: + case 141 /* PropertyDeclaration */: + case 140 /* PropertySignature */: return ScriptElementKind.memberVariableElement; - case 147 /* IndexSignature */: return ScriptElementKind.indexSignatureElement; - case 146 /* ConstructSignature */: return ScriptElementKind.constructSignatureElement; - case 145 /* CallSignature */: return ScriptElementKind.callSignatureElement; - case 142 /* Constructor */: return ScriptElementKind.constructorImplementationElement; - case 135 /* TypeParameter */: return ScriptElementKind.typeParameterElement; - case 245 /* EnumMember */: return ScriptElementKind.variableElement; - case 136 /* Parameter */: return (node.flags & 112 /* AccessibilityModifier */) ? ScriptElementKind.memberVariableElement : ScriptElementKind.parameterElement; - case 219 /* ImportEqualsDeclaration */: - case 224 /* ImportSpecifier */: - case 221 /* ImportClause */: - case 228 /* ExportSpecifier */: - case 222 /* NamespaceImport */: + case 149 /* IndexSignature */: return ScriptElementKind.indexSignatureElement; + case 148 /* ConstructSignature */: return ScriptElementKind.constructSignatureElement; + case 147 /* CallSignature */: return ScriptElementKind.callSignatureElement; + case 144 /* Constructor */: return ScriptElementKind.constructorImplementationElement; + case 137 /* TypeParameter */: return ScriptElementKind.typeParameterElement; + case 247 /* EnumMember */: return ScriptElementKind.variableElement; + case 138 /* Parameter */: return (node.flags & 112 /* AccessibilityModifier */) ? ScriptElementKind.memberVariableElement : ScriptElementKind.parameterElement; + case 221 /* ImportEqualsDeclaration */: + case 226 /* ImportSpecifier */: + case 223 /* ImportClause */: + case 230 /* ExportSpecifier */: + case 224 /* NamespaceImport */: return ScriptElementKind.alias; } return ScriptElementKind.unknown; @@ -43885,7 +44706,7 @@ var ts; // For JavaScript files, we don't want to report the normal typescript semantic errors. // Instead, we just report errors for using TypeScript-only constructs from within a // JavaScript file. - if (ts.isJavaScript(fileName)) { + if (ts.isSourceFileJavaScript(targetSourceFile)) { return getJavaScriptSemanticDiagnostics(targetSourceFile); } // Only perform the action per file regardless of '-out' flag as LanguageServiceHost is expected to call this function per file. @@ -43907,44 +44728,44 @@ var ts; return false; } switch (node.kind) { - case 219 /* ImportEqualsDeclaration */: + case 221 /* ImportEqualsDeclaration */: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.import_can_only_be_used_in_a_ts_file)); return true; - case 225 /* ExportAssignment */: + case 227 /* ExportAssignment */: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.export_can_only_be_used_in_a_ts_file)); return true; - case 212 /* ClassDeclaration */: + case 214 /* ClassDeclaration */: var classDeclaration = node; if (checkModifiers(classDeclaration.modifiers) || checkTypeParameters(classDeclaration.typeParameters)) { return true; } break; - case 241 /* HeritageClause */: + case 243 /* HeritageClause */: var heritageClause = node; - if (heritageClause.token === 104 /* ImplementsKeyword */) { + if (heritageClause.token === 106 /* ImplementsKeyword */) { diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.implements_clauses_can_only_be_used_in_a_ts_file)); return true; } break; - case 213 /* InterfaceDeclaration */: + case 215 /* InterfaceDeclaration */: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.interface_declarations_can_only_be_used_in_a_ts_file)); return true; - case 216 /* ModuleDeclaration */: + case 218 /* ModuleDeclaration */: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.module_declarations_can_only_be_used_in_a_ts_file)); return true; - case 214 /* TypeAliasDeclaration */: + case 216 /* TypeAliasDeclaration */: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.type_aliases_can_only_be_used_in_a_ts_file)); return true; - case 141 /* MethodDeclaration */: - case 140 /* MethodSignature */: - case 142 /* Constructor */: - case 143 /* GetAccessor */: - case 144 /* SetAccessor */: - case 171 /* FunctionExpression */: - case 211 /* FunctionDeclaration */: - case 172 /* ArrowFunction */: - case 211 /* FunctionDeclaration */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: + case 144 /* Constructor */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: + case 173 /* FunctionExpression */: + case 213 /* FunctionDeclaration */: + case 174 /* ArrowFunction */: + case 213 /* FunctionDeclaration */: var functionDeclaration = node; if (checkModifiers(functionDeclaration.modifiers) || checkTypeParameters(functionDeclaration.typeParameters) || @@ -43952,20 +44773,20 @@ var ts; return true; } break; - case 191 /* VariableStatement */: + case 193 /* VariableStatement */: var variableStatement = node; if (checkModifiers(variableStatement.modifiers)) { return true; } break; - case 209 /* VariableDeclaration */: + case 211 /* VariableDeclaration */: var variableDeclaration = node; if (checkTypeAnnotation(variableDeclaration.type)) { return true; } break; - case 166 /* CallExpression */: - case 167 /* NewExpression */: + case 168 /* CallExpression */: + case 169 /* NewExpression */: var expression = node; if (expression.typeArguments && expression.typeArguments.length > 0) { var start = expression.typeArguments.pos; @@ -43973,7 +44794,7 @@ var ts; return true; } break; - case 136 /* Parameter */: + case 138 /* Parameter */: var parameter = node; if (parameter.modifiers) { var start = parameter.modifiers.pos; @@ -43989,17 +44810,17 @@ var ts; return true; } break; - case 139 /* PropertyDeclaration */: + case 141 /* PropertyDeclaration */: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.property_declarations_can_only_be_used_in_a_ts_file)); return true; - case 215 /* EnumDeclaration */: + case 217 /* EnumDeclaration */: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.enum_declarations_can_only_be_used_in_a_ts_file)); return true; - case 169 /* TypeAssertionExpression */: + case 171 /* TypeAssertionExpression */: var typeAssertionExpression = node; diagnostics.push(ts.createDiagnosticForNode(typeAssertionExpression.type, ts.Diagnostics.type_assertion_expressions_can_only_be_used_in_a_ts_file)); return true; - case 137 /* Decorator */: + case 139 /* Decorator */: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.decorators_can_only_be_used_in_a_ts_file)); return true; } @@ -44025,18 +44846,18 @@ var ts; for (var _i = 0; _i < modifiers.length; _i++) { var modifier = modifiers[_i]; switch (modifier.kind) { - case 110 /* PublicKeyword */: - case 108 /* PrivateKeyword */: - case 109 /* ProtectedKeyword */: - case 120 /* DeclareKeyword */: + case 112 /* PublicKeyword */: + case 110 /* PrivateKeyword */: + case 111 /* ProtectedKeyword */: + case 122 /* DeclareKeyword */: diagnostics.push(ts.createDiagnosticForNode(modifier, ts.Diagnostics._0_can_only_be_used_in_a_ts_file, ts.tokenToString(modifier.kind))); return true; // These are all legal modifiers. - case 111 /* StaticKeyword */: - case 80 /* ExportKeyword */: - case 72 /* ConstKeyword */: - case 75 /* DefaultKeyword */: - case 113 /* AbstractKeyword */: + case 113 /* StaticKeyword */: + case 82 /* ExportKeyword */: + case 74 /* ConstKeyword */: + case 77 /* DefaultKeyword */: + case 115 /* AbstractKeyword */: } } } @@ -44097,7 +44918,7 @@ var ts; var typeChecker = program.getTypeChecker(); var syntacticStart = new Date().getTime(); var sourceFile = getValidSourceFile(fileName); - var isJavaScriptFile = ts.isJavaScript(fileName); + var isJavaScriptFile = ts.isSourceFileJavaScript(sourceFile); var isJsDocTagName = false; var start = new Date().getTime(); var currentToken = ts.getTokenAtPosition(sourceFile, position); @@ -44122,9 +44943,9 @@ var ts; isJsDocTagName = true; } switch (tag.kind) { - case 267 /* JSDocTypeTag */: - case 265 /* JSDocParameterTag */: - case 266 /* JSDocReturnTag */: + case 269 /* JSDocTypeTag */: + case 267 /* JSDocParameterTag */: + case 268 /* JSDocReturnTag */: var tagWithExpression = tag; if (tagWithExpression.typeExpression) { insideJsDocTagExpression = tagWithExpression.typeExpression.pos < position && position < tagWithExpression.typeExpression.end; @@ -44161,6 +44982,7 @@ var ts; var node = currentToken; var isRightOfDot = false; var isRightOfOpenTag = false; + var isStartingCloseTag = false; var location = ts.getTouchingPropertyName(sourceFile, position); if (contextToken) { // Bail out if this is a known invalid completion location @@ -44170,11 +44992,11 @@ var ts; } var parent_9 = contextToken.parent, kind = contextToken.kind; if (kind === 21 /* DotToken */) { - if (parent_9.kind === 164 /* PropertyAccessExpression */) { + if (parent_9.kind === 166 /* PropertyAccessExpression */) { node = contextToken.parent.expression; isRightOfDot = true; } - else if (parent_9.kind === 133 /* QualifiedName */) { + else if (parent_9.kind === 135 /* QualifiedName */) { node = contextToken.parent.left; isRightOfDot = true; } @@ -44184,9 +45006,14 @@ var ts; return undefined; } } - else if (kind === 25 /* LessThanToken */ && sourceFile.languageVariant === 1 /* JSX */) { - isRightOfOpenTag = true; - location = contextToken; + else if (sourceFile.languageVariant === 1 /* JSX */) { + if (kind === 25 /* LessThanToken */) { + isRightOfOpenTag = true; + location = contextToken; + } + else if (kind === 39 /* SlashToken */ && contextToken.parent.kind === 237 /* JsxClosingElement */) { + isStartingCloseTag = true; + } } } var semanticStart = new Date().getTime(); @@ -44207,6 +45034,12 @@ var ts; isMemberCompletion = true; isNewIdentifierLocation = false; } + else if (isStartingCloseTag) { + var tagName = contextToken.parent.parent.openingElement.tagName; + symbols = [typeChecker.getSymbolAtLocation(tagName)]; + isMemberCompletion = true; + isNewIdentifierLocation = false; + } else { // For JavaScript or TypeScript, if we're not after a dot, then just try to get the // global symbols in scope. These results should be valid for either language as @@ -44221,7 +45054,7 @@ var ts; // Right of dot member completion list isMemberCompletion = true; isNewIdentifierLocation = false; - if (node.kind === 67 /* Identifier */ || node.kind === 133 /* QualifiedName */ || node.kind === 164 /* PropertyAccessExpression */) { + if (node.kind === 69 /* Identifier */ || node.kind === 135 /* QualifiedName */ || node.kind === 166 /* PropertyAccessExpression */) { var symbol = typeChecker.getSymbolAtLocation(node); // This is an alias, follow what it aliases if (symbol && symbol.flags & 8388608 /* Alias */) { @@ -44277,7 +45110,7 @@ var ts; } if (jsxContainer = tryGetContainingJsxElement(contextToken)) { var attrsType; - if ((jsxContainer.kind === 232 /* JsxSelfClosingElement */) || (jsxContainer.kind === 233 /* JsxOpeningElement */)) { + if ((jsxContainer.kind === 234 /* JsxSelfClosingElement */) || (jsxContainer.kind === 235 /* JsxOpeningElement */)) { // Cursor is inside a JSX self-closing element or opening element attrsType = typeChecker.getJsxElementAttributesType(jsxContainer); if (attrsType) { @@ -44343,49 +45176,64 @@ var ts; var start = new Date().getTime(); var result = isInStringOrRegularExpressionOrTemplateLiteral(contextToken) || isSolelyIdentifierDefinitionLocation(contextToken) || - isDotOfNumericLiteral(contextToken); + isDotOfNumericLiteral(contextToken) || + isInJsxText(contextToken); log("getCompletionsAtPosition: isCompletionListBlocker: " + (new Date().getTime() - start)); return result; } + function isInJsxText(contextToken) { + if (contextToken.kind === 236 /* JsxText */) { + return true; + } + if (contextToken.kind === 27 /* GreaterThanToken */ && contextToken.parent) { + if (contextToken.parent.kind === 235 /* JsxOpeningElement */) { + return true; + } + if (contextToken.parent.kind === 237 /* JsxClosingElement */ || contextToken.parent.kind === 234 /* JsxSelfClosingElement */) { + return contextToken.parent.parent && contextToken.parent.parent.kind === 233 /* JsxElement */; + } + } + return false; + } function isNewIdentifierDefinitionLocation(previousToken) { if (previousToken) { var containingNodeKind = previousToken.parent.kind; switch (previousToken.kind) { case 24 /* CommaToken */: - return containingNodeKind === 166 /* CallExpression */ // func( a, | - || containingNodeKind === 142 /* Constructor */ // constructor( a, | /* public, protected, private keywords are allowed here, so show completion */ - || containingNodeKind === 167 /* NewExpression */ // new C(a, | - || containingNodeKind === 162 /* ArrayLiteralExpression */ // [a, | - || containingNodeKind === 179 /* BinaryExpression */ // let x = (a, | - || containingNodeKind === 150 /* FunctionType */; // var x: (s: string, list| + return containingNodeKind === 168 /* CallExpression */ // func( a, | + || containingNodeKind === 144 /* Constructor */ // constructor( a, | /* public, protected, private keywords are allowed here, so show completion */ + || containingNodeKind === 169 /* NewExpression */ // new C(a, | + || containingNodeKind === 164 /* ArrayLiteralExpression */ // [a, | + || containingNodeKind === 181 /* BinaryExpression */ // let x = (a, | + || containingNodeKind === 152 /* FunctionType */; // var x: (s: string, list| case 17 /* OpenParenToken */: - return containingNodeKind === 166 /* CallExpression */ // func( | - || containingNodeKind === 142 /* Constructor */ // constructor( | - || containingNodeKind === 167 /* NewExpression */ // new C(a| - || containingNodeKind === 170 /* ParenthesizedExpression */ // let x = (a| - || containingNodeKind === 158 /* ParenthesizedType */; // function F(pred: (a| /* this can become an arrow function, where 'a' is the argument */ + return containingNodeKind === 168 /* CallExpression */ // func( | + || containingNodeKind === 144 /* Constructor */ // constructor( | + || containingNodeKind === 169 /* NewExpression */ // new C(a| + || containingNodeKind === 172 /* ParenthesizedExpression */ // let x = (a| + || containingNodeKind === 160 /* ParenthesizedType */; // function F(pred: (a| /* this can become an arrow function, where 'a' is the argument */ case 19 /* OpenBracketToken */: - return containingNodeKind === 162 /* ArrayLiteralExpression */ // [ | - || containingNodeKind === 147 /* IndexSignature */ // [ | : string ] - || containingNodeKind === 134 /* ComputedPropertyName */; // [ | /* this can become an index signature */ - case 123 /* ModuleKeyword */: // module | - case 124 /* NamespaceKeyword */: + return containingNodeKind === 164 /* ArrayLiteralExpression */ // [ | + || containingNodeKind === 149 /* IndexSignature */ // [ | : string ] + || containingNodeKind === 136 /* ComputedPropertyName */; // [ | /* this can become an index signature */ + case 125 /* ModuleKeyword */: // module | + case 126 /* NamespaceKeyword */: return true; case 21 /* DotToken */: - return containingNodeKind === 216 /* ModuleDeclaration */; // module A.| + return containingNodeKind === 218 /* ModuleDeclaration */; // module A.| case 15 /* OpenBraceToken */: - return containingNodeKind === 212 /* ClassDeclaration */; // class A{ | - case 55 /* EqualsToken */: - return containingNodeKind === 209 /* VariableDeclaration */ // let x = a| - || containingNodeKind === 179 /* BinaryExpression */; // x = a| + return containingNodeKind === 214 /* ClassDeclaration */; // class A{ | + case 56 /* EqualsToken */: + return containingNodeKind === 211 /* VariableDeclaration */ // let x = a| + || containingNodeKind === 181 /* BinaryExpression */; // x = a| case 12 /* TemplateHead */: - return containingNodeKind === 181 /* TemplateExpression */; // `aa ${| + return containingNodeKind === 183 /* TemplateExpression */; // `aa ${| case 13 /* TemplateMiddle */: - return containingNodeKind === 188 /* TemplateSpan */; // `aa ${10} dd ${| - case 110 /* PublicKeyword */: - case 108 /* PrivateKeyword */: - case 109 /* ProtectedKeyword */: - return containingNodeKind === 139 /* PropertyDeclaration */; // class A{ public | + return containingNodeKind === 190 /* TemplateSpan */; // `aa ${10} dd ${| + case 112 /* PublicKeyword */: + case 110 /* PrivateKeyword */: + case 111 /* ProtectedKeyword */: + return containingNodeKind === 141 /* PropertyDeclaration */; // class A{ public | } // Previous token may have been a keyword that was converted to an identifier. switch (previousToken.getText()) { @@ -44428,14 +45276,14 @@ var ts; isMemberCompletion = true; var typeForObject; var existingMembers; - if (objectLikeContainer.kind === 163 /* ObjectLiteralExpression */) { + if (objectLikeContainer.kind === 165 /* ObjectLiteralExpression */) { // We are completing on contextual types, but may also include properties // other than those within the declared type. isNewIdentifierLocation = true; typeForObject = typeChecker.getContextualType(objectLikeContainer); existingMembers = objectLikeContainer.properties; } - else if (objectLikeContainer.kind === 159 /* ObjectBindingPattern */) { + else if (objectLikeContainer.kind === 161 /* ObjectBindingPattern */) { // We are *only* completing on properties from the type being destructured. isNewIdentifierLocation = false; var rootDeclaration = ts.getRootDeclaration(objectLikeContainer.parent); @@ -44481,9 +45329,9 @@ var ts; * @returns true if 'symbols' was successfully populated; false otherwise. */ function tryGetImportOrExportClauseCompletionSymbols(namedImportsOrExports) { - var declarationKind = namedImportsOrExports.kind === 223 /* NamedImports */ ? - 220 /* ImportDeclaration */ : - 226 /* ExportDeclaration */; + var declarationKind = namedImportsOrExports.kind === 225 /* NamedImports */ ? + 222 /* ImportDeclaration */ : + 228 /* ExportDeclaration */; var importOrExportDeclaration = ts.getAncestor(namedImportsOrExports, declarationKind); var moduleSpecifier = importOrExportDeclaration.moduleSpecifier; if (!moduleSpecifier) { @@ -44509,7 +45357,7 @@ var ts; case 15 /* OpenBraceToken */: // let x = { | case 24 /* CommaToken */: var parent_10 = contextToken.parent; - if (parent_10 && (parent_10.kind === 163 /* ObjectLiteralExpression */ || parent_10.kind === 159 /* ObjectBindingPattern */)) { + if (parent_10 && (parent_10.kind === 165 /* ObjectLiteralExpression */ || parent_10.kind === 161 /* ObjectBindingPattern */)) { return parent_10; } break; @@ -44527,8 +45375,8 @@ var ts; case 15 /* OpenBraceToken */: // import { | case 24 /* CommaToken */: switch (contextToken.parent.kind) { - case 223 /* NamedImports */: - case 227 /* NamedExports */: + case 225 /* NamedImports */: + case 229 /* NamedExports */: return contextToken.parent; } } @@ -44540,30 +45388,33 @@ var ts; var parent_11 = contextToken.parent; switch (contextToken.kind) { case 26 /* LessThanSlashToken */: - case 38 /* SlashToken */: - case 67 /* Identifier */: - case 236 /* JsxAttribute */: - case 237 /* JsxSpreadAttribute */: - if (parent_11 && (parent_11.kind === 232 /* JsxSelfClosingElement */ || parent_11.kind === 233 /* JsxOpeningElement */)) { + case 39 /* SlashToken */: + case 69 /* Identifier */: + case 238 /* JsxAttribute */: + case 239 /* JsxSpreadAttribute */: + if (parent_11 && (parent_11.kind === 234 /* JsxSelfClosingElement */ || parent_11.kind === 235 /* JsxOpeningElement */)) { return parent_11; } + else if (parent_11.kind === 238 /* JsxAttribute */) { + return parent_11.parent; + } break; // The context token is the closing } or " of an attribute, which means // its parent is a JsxExpression, whose parent is a JsxAttribute, // whose parent is a JsxOpeningLikeElement case 9 /* StringLiteral */: - if (parent_11 && ((parent_11.kind === 236 /* JsxAttribute */) || (parent_11.kind === 237 /* JsxSpreadAttribute */))) { + if (parent_11 && ((parent_11.kind === 238 /* JsxAttribute */) || (parent_11.kind === 239 /* JsxSpreadAttribute */))) { return parent_11.parent; } break; case 16 /* CloseBraceToken */: if (parent_11 && - parent_11.kind === 238 /* JsxExpression */ && + parent_11.kind === 240 /* JsxExpression */ && parent_11.parent && - (parent_11.parent.kind === 236 /* JsxAttribute */)) { + (parent_11.parent.kind === 238 /* JsxAttribute */)) { return parent_11.parent.parent; } - if (parent_11 && parent_11.kind === 237 /* JsxSpreadAttribute */) { + if (parent_11 && parent_11.kind === 239 /* JsxSpreadAttribute */) { return parent_11.parent; } break; @@ -44573,16 +45424,16 @@ var ts; } function isFunction(kind) { switch (kind) { - case 171 /* FunctionExpression */: - case 172 /* ArrowFunction */: - case 211 /* FunctionDeclaration */: - case 141 /* MethodDeclaration */: - case 140 /* MethodSignature */: - case 143 /* GetAccessor */: - case 144 /* SetAccessor */: - case 145 /* CallSignature */: - case 146 /* ConstructSignature */: - case 147 /* IndexSignature */: + case 173 /* FunctionExpression */: + case 174 /* ArrowFunction */: + case 213 /* FunctionDeclaration */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: + case 147 /* CallSignature */: + case 148 /* ConstructSignature */: + case 149 /* IndexSignature */: return true; } return false; @@ -44594,78 +45445,84 @@ var ts; var containingNodeKind = contextToken.parent.kind; switch (contextToken.kind) { case 24 /* CommaToken */: - return containingNodeKind === 209 /* VariableDeclaration */ || - containingNodeKind === 210 /* VariableDeclarationList */ || - containingNodeKind === 191 /* VariableStatement */ || - containingNodeKind === 215 /* EnumDeclaration */ || + return containingNodeKind === 211 /* VariableDeclaration */ || + containingNodeKind === 212 /* VariableDeclarationList */ || + containingNodeKind === 193 /* VariableStatement */ || + containingNodeKind === 217 /* EnumDeclaration */ || isFunction(containingNodeKind) || - containingNodeKind === 212 /* ClassDeclaration */ || - containingNodeKind === 184 /* ClassExpression */ || - containingNodeKind === 213 /* InterfaceDeclaration */ || - containingNodeKind === 160 /* ArrayBindingPattern */ || - containingNodeKind === 214 /* TypeAliasDeclaration */; // type Map, K, | + containingNodeKind === 214 /* ClassDeclaration */ || + containingNodeKind === 186 /* ClassExpression */ || + containingNodeKind === 215 /* InterfaceDeclaration */ || + containingNodeKind === 162 /* ArrayBindingPattern */ || + containingNodeKind === 216 /* TypeAliasDeclaration */; // type Map, K, | case 21 /* DotToken */: - return containingNodeKind === 160 /* ArrayBindingPattern */; // var [.| - case 53 /* ColonToken */: - return containingNodeKind === 161 /* BindingElement */; // var {x :html| + return containingNodeKind === 162 /* ArrayBindingPattern */; // var [.| + case 54 /* ColonToken */: + return containingNodeKind === 163 /* BindingElement */; // var {x :html| case 19 /* OpenBracketToken */: - return containingNodeKind === 160 /* ArrayBindingPattern */; // var [x| + return containingNodeKind === 162 /* ArrayBindingPattern */; // var [x| case 17 /* OpenParenToken */: - return containingNodeKind === 242 /* CatchClause */ || + return containingNodeKind === 244 /* CatchClause */ || isFunction(containingNodeKind); case 15 /* OpenBraceToken */: - return containingNodeKind === 215 /* EnumDeclaration */ || - containingNodeKind === 213 /* InterfaceDeclaration */ || - containingNodeKind === 153 /* TypeLiteral */; // let x : { | + return containingNodeKind === 217 /* EnumDeclaration */ || + containingNodeKind === 215 /* InterfaceDeclaration */ || + containingNodeKind === 155 /* TypeLiteral */; // let x : { | case 23 /* SemicolonToken */: - return containingNodeKind === 138 /* PropertySignature */ && + return containingNodeKind === 140 /* PropertySignature */ && contextToken.parent && contextToken.parent.parent && - (contextToken.parent.parent.kind === 213 /* InterfaceDeclaration */ || - contextToken.parent.parent.kind === 153 /* TypeLiteral */); // let x : { a; | + (contextToken.parent.parent.kind === 215 /* InterfaceDeclaration */ || + contextToken.parent.parent.kind === 155 /* TypeLiteral */); // let x : { a; | case 25 /* LessThanToken */: - return containingNodeKind === 212 /* ClassDeclaration */ || - containingNodeKind === 184 /* ClassExpression */ || - containingNodeKind === 213 /* InterfaceDeclaration */ || - containingNodeKind === 214 /* TypeAliasDeclaration */ || + return containingNodeKind === 214 /* ClassDeclaration */ || + containingNodeKind === 186 /* ClassExpression */ || + containingNodeKind === 215 /* InterfaceDeclaration */ || + containingNodeKind === 216 /* TypeAliasDeclaration */ || isFunction(containingNodeKind); - case 111 /* StaticKeyword */: - return containingNodeKind === 139 /* PropertyDeclaration */; + case 113 /* StaticKeyword */: + return containingNodeKind === 141 /* PropertyDeclaration */; case 22 /* DotDotDotToken */: - return containingNodeKind === 136 /* Parameter */ || + return containingNodeKind === 138 /* Parameter */ || (contextToken.parent && contextToken.parent.parent && - contextToken.parent.parent.kind === 160 /* ArrayBindingPattern */); // var [...z| - case 110 /* PublicKeyword */: - case 108 /* PrivateKeyword */: - case 109 /* ProtectedKeyword */: - return containingNodeKind === 136 /* Parameter */; - case 114 /* AsKeyword */: - containingNodeKind === 224 /* ImportSpecifier */ || - containingNodeKind === 228 /* ExportSpecifier */ || - containingNodeKind === 222 /* NamespaceImport */; - case 71 /* ClassKeyword */: - case 79 /* EnumKeyword */: - case 105 /* InterfaceKeyword */: - case 85 /* FunctionKeyword */: - case 100 /* VarKeyword */: - case 121 /* GetKeyword */: - case 127 /* SetKeyword */: - case 87 /* ImportKeyword */: - case 106 /* LetKeyword */: - case 72 /* ConstKeyword */: - case 112 /* YieldKeyword */: - case 130 /* TypeKeyword */: + contextToken.parent.parent.kind === 162 /* ArrayBindingPattern */); // var [...z| + case 112 /* PublicKeyword */: + case 110 /* PrivateKeyword */: + case 111 /* ProtectedKeyword */: + return containingNodeKind === 138 /* Parameter */; + case 116 /* AsKeyword */: + return containingNodeKind === 226 /* ImportSpecifier */ || + containingNodeKind === 230 /* ExportSpecifier */ || + containingNodeKind === 224 /* NamespaceImport */; + case 73 /* ClassKeyword */: + case 81 /* EnumKeyword */: + case 107 /* InterfaceKeyword */: + case 87 /* FunctionKeyword */: + case 102 /* VarKeyword */: + case 123 /* GetKeyword */: + case 129 /* SetKeyword */: + case 89 /* ImportKeyword */: + case 108 /* LetKeyword */: + case 74 /* ConstKeyword */: + case 114 /* YieldKeyword */: + case 132 /* TypeKeyword */: return true; } // Previous token may have been a keyword that was converted to an identifier. switch (contextToken.getText()) { + case "abstract": + case "async": case "class": - case "interface": + case "const": + case "declare": case "enum": case "function": - case "var": - case "static": + case "interface": case "let": - case "const": + case "private": + case "protected": + case "public": + case "static": + case "var": case "yield": return true; } @@ -44695,8 +45552,8 @@ var ts; if (element.getStart() <= position && position <= element.getEnd()) { continue; } - var name_31 = element.propertyName || element.name; - exisingImportsOrExports[name_31.text] = true; + var name_32 = element.propertyName || element.name; + exisingImportsOrExports[name_32.text] = true; } if (ts.isEmpty(exisingImportsOrExports)) { return exportsOfModule; @@ -44717,9 +45574,9 @@ var ts; for (var _i = 0; _i < existingMembers.length; _i++) { var m = existingMembers[_i]; // Ignore omitted expressions for missing members - if (m.kind !== 243 /* PropertyAssignment */ && - m.kind !== 244 /* ShorthandPropertyAssignment */ && - m.kind !== 161 /* BindingElement */) { + if (m.kind !== 245 /* PropertyAssignment */ && + m.kind !== 246 /* ShorthandPropertyAssignment */ && + m.kind !== 163 /* BindingElement */) { continue; } // If this is the current item we are editing right now, do not filter it out @@ -44727,7 +45584,7 @@ var ts; continue; } var existingName = void 0; - if (m.kind === 161 /* BindingElement */ && m.propertyName) { + if (m.kind === 163 /* BindingElement */ && m.propertyName) { existingName = m.propertyName.text; } else { @@ -44754,7 +45611,7 @@ var ts; if (attr.getStart() <= position && position <= attr.getEnd()) { continue; } - if (attr.kind === 236 /* JsxAttribute */) { + if (attr.kind === 238 /* JsxAttribute */) { seenNames[attr.name.text] = true; } } @@ -44768,46 +45625,43 @@ var ts; return undefined; } var symbols = completionData.symbols, isMemberCompletion = completionData.isMemberCompletion, isNewIdentifierLocation = completionData.isNewIdentifierLocation, location = completionData.location, isRightOfDot = completionData.isRightOfDot, isJsDocTagName = completionData.isJsDocTagName; - var entries; if (isJsDocTagName) { // If the current position is a jsDoc tag name, only tag names should be provided for completion return { isMemberCompletion: false, isNewIdentifierLocation: false, entries: getAllJsDocCompletionEntries() }; } - if (isRightOfDot && ts.isJavaScript(fileName)) { - entries = getCompletionEntriesFromSymbols(symbols); - ts.addRange(entries, getJavaScriptCompletionEntries()); + var sourceFile = getValidSourceFile(fileName); + var entries = []; + if (isRightOfDot && ts.isSourceFileJavaScript(sourceFile)) { + var uniqueNames = getCompletionEntriesFromSymbols(symbols, entries); + ts.addRange(entries, getJavaScriptCompletionEntries(sourceFile, uniqueNames)); } else { if (!symbols || symbols.length === 0) { return undefined; } - entries = getCompletionEntriesFromSymbols(symbols); + getCompletionEntriesFromSymbols(symbols, entries); } // Add keywords if this is not a member completion list if (!isMemberCompletion && !isJsDocTagName) { ts.addRange(entries, keywordCompletions); } return { isMemberCompletion: isMemberCompletion, isNewIdentifierLocation: isNewIdentifierLocation, entries: entries }; - function getJavaScriptCompletionEntries() { + function getJavaScriptCompletionEntries(sourceFile, uniqueNames) { var entries = []; - var allNames = {}; var target = program.getCompilerOptions().target; - for (var _i = 0, _a = program.getSourceFiles(); _i < _a.length; _i++) { - var sourceFile = _a[_i]; - var nameTable = getNameTable(sourceFile); - for (var name_32 in nameTable) { - if (!allNames[name_32]) { - allNames[name_32] = name_32; - var displayName = getCompletionEntryDisplayName(name_32, target, /*performCharacterChecks:*/ true); - if (displayName) { - var entry = { - name: displayName, - kind: ScriptElementKind.warning, - kindModifiers: "", - sortText: "1" - }; - entries.push(entry); - } + var nameTable = getNameTable(sourceFile); + for (var name_33 in nameTable) { + if (!uniqueNames[name_33]) { + uniqueNames[name_33] = name_33; + var displayName = getCompletionEntryDisplayName(name_33, target, /*performCharacterChecks:*/ true); + if (displayName) { + var entry = { + name: displayName, + kind: ScriptElementKind.warning, + kindModifiers: "", + sortText: "1" + }; + entries.push(entry); } } } @@ -44845,25 +45699,24 @@ var ts; sortText: "0" }; } - function getCompletionEntriesFromSymbols(symbols) { + function getCompletionEntriesFromSymbols(symbols, entries) { var start = new Date().getTime(); - var entries = []; + var uniqueNames = {}; if (symbols) { - var nameToSymbol = {}; for (var _i = 0; _i < symbols.length; _i++) { var symbol = symbols[_i]; var entry = createCompletionEntry(symbol, location); if (entry) { var id = ts.escapeIdentifier(entry.name); - if (!ts.lookUp(nameToSymbol, id)) { + if (!ts.lookUp(uniqueNames, id)) { entries.push(entry); - nameToSymbol[id] = symbol; + uniqueNames[id] = id; } } } } log("getCompletionsAtPosition: getCompletionEntriesFromSymbols: " + (new Date().getTime() - start)); - return entries; + return uniqueNames; } } function getCompletionEntryDetails(fileName, position, entryName) { @@ -44906,7 +45759,7 @@ var ts; function getSymbolKind(symbol, location) { var flags = symbol.getFlags(); if (flags & 32 /* Class */) - return ts.getDeclarationOfKind(symbol, 184 /* ClassExpression */) ? + return ts.getDeclarationOfKind(symbol, 186 /* ClassExpression */) ? ScriptElementKind.localClassElement : ScriptElementKind.classElement; if (flags & 384 /* Enum */) return ScriptElementKind.enumElement; @@ -45008,7 +45861,7 @@ var ts; var signature; type = typeChecker.getTypeOfSymbolAtLocation(symbol, location); if (type) { - if (location.parent && location.parent.kind === 164 /* PropertyAccessExpression */) { + if (location.parent && location.parent.kind === 166 /* PropertyAccessExpression */) { var right = location.parent.name; // Either the location is on the right of a property access, or on the left and the right is missing if (right === location || (right && right.getFullWidth() === 0)) { @@ -45017,7 +45870,7 @@ var ts; } // try get the call/construct signature from the type if it matches var callExpression; - if (location.kind === 166 /* CallExpression */ || location.kind === 167 /* NewExpression */) { + if (location.kind === 168 /* CallExpression */ || location.kind === 169 /* NewExpression */) { callExpression = location; } else if (isCallExpressionTarget(location) || isNewExpressionTarget(location)) { @@ -45030,10 +45883,11 @@ var ts; // Use the first candidate: signature = candidateSignatures[0]; } - var useConstructSignatures = callExpression.kind === 167 /* NewExpression */ || callExpression.expression.kind === 93 /* SuperKeyword */; + var useConstructSignatures = callExpression.kind === 169 /* NewExpression */ || callExpression.expression.kind === 95 /* SuperKeyword */; var allSignatures = useConstructSignatures ? type.getConstructSignatures() : type.getCallSignatures(); - if (!ts.contains(allSignatures, signature.target || signature)) { - // Get the first signature if there + if (!ts.contains(allSignatures, signature.target) && !ts.contains(allSignatures, signature)) { + // Get the first signature if there is one -- allSignatures may contain + // either the original signature or its target, so check for either signature = allSignatures.length ? allSignatures[0] : undefined; } if (signature) { @@ -45047,7 +45901,7 @@ var ts; pushTypePart(symbolKind); displayParts.push(ts.spacePart()); if (useConstructSignatures) { - displayParts.push(ts.keywordPart(90 /* NewKeyword */)); + displayParts.push(ts.keywordPart(92 /* NewKeyword */)); displayParts.push(ts.spacePart()); } addFullSymbolName(symbol); @@ -45063,10 +45917,10 @@ var ts; case ScriptElementKind.parameterElement: case ScriptElementKind.localVariableElement: // If it is call or construct signature of lambda's write type name - displayParts.push(ts.punctuationPart(53 /* ColonToken */)); + displayParts.push(ts.punctuationPart(54 /* ColonToken */)); displayParts.push(ts.spacePart()); if (useConstructSignatures) { - displayParts.push(ts.keywordPart(90 /* NewKeyword */)); + displayParts.push(ts.keywordPart(92 /* NewKeyword */)); displayParts.push(ts.spacePart()); } if (!(type.flags & 65536 /* Anonymous */)) { @@ -45082,24 +45936,24 @@ var ts; } } else if ((isNameOfFunctionDeclaration(location) && !(symbol.flags & 98304 /* Accessor */)) || - (location.kind === 119 /* ConstructorKeyword */ && location.parent.kind === 142 /* Constructor */)) { + (location.kind === 121 /* ConstructorKeyword */ && location.parent.kind === 144 /* Constructor */)) { // get the signature from the declaration and write it var functionDeclaration = location.parent; - var allSignatures = functionDeclaration.kind === 142 /* Constructor */ ? type.getConstructSignatures() : type.getCallSignatures(); + var allSignatures = functionDeclaration.kind === 144 /* Constructor */ ? type.getConstructSignatures() : type.getCallSignatures(); if (!typeChecker.isImplementationOfOverload(functionDeclaration)) { signature = typeChecker.getSignatureFromDeclaration(functionDeclaration); } else { signature = allSignatures[0]; } - if (functionDeclaration.kind === 142 /* Constructor */) { + if (functionDeclaration.kind === 144 /* Constructor */) { // show (constructor) Type(...) signature symbolKind = ScriptElementKind.constructorImplementationElement; addPrefixForAnyFunctionOrVar(type.symbol, symbolKind); } else { // (function/method) symbol(..signature) - addPrefixForAnyFunctionOrVar(functionDeclaration.kind === 145 /* CallSignature */ && + addPrefixForAnyFunctionOrVar(functionDeclaration.kind === 147 /* CallSignature */ && !(type.symbol.flags & 2048 /* TypeLiteral */ || type.symbol.flags & 4096 /* ObjectLiteral */) ? type.symbol : symbol, symbolKind); } addSignatureDisplayParts(signature, allSignatures); @@ -45108,7 +45962,7 @@ var ts; } } if (symbolFlags & 32 /* Class */ && !hasAddedSymbolInfo) { - if (ts.getDeclarationOfKind(symbol, 184 /* ClassExpression */)) { + if (ts.getDeclarationOfKind(symbol, 186 /* ClassExpression */)) { // Special case for class expressions because we would like to indicate that // the class name is local to the class body (similar to function expression) // (local class) class @@ -45116,7 +45970,7 @@ var ts; } else { // Class declaration has name which is not local. - displayParts.push(ts.keywordPart(71 /* ClassKeyword */)); + displayParts.push(ts.keywordPart(73 /* ClassKeyword */)); } displayParts.push(ts.spacePart()); addFullSymbolName(symbol); @@ -45124,37 +45978,37 @@ var ts; } if ((symbolFlags & 64 /* Interface */) && (semanticMeaning & 2 /* Type */)) { addNewLineIfDisplayPartsExist(); - displayParts.push(ts.keywordPart(105 /* InterfaceKeyword */)); + displayParts.push(ts.keywordPart(107 /* InterfaceKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); writeTypeParametersOfSymbol(symbol, sourceFile); } if (symbolFlags & 524288 /* TypeAlias */) { addNewLineIfDisplayPartsExist(); - displayParts.push(ts.keywordPart(130 /* TypeKeyword */)); + displayParts.push(ts.keywordPart(132 /* TypeKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); writeTypeParametersOfSymbol(symbol, sourceFile); displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(55 /* EqualsToken */)); + displayParts.push(ts.operatorPart(56 /* EqualsToken */)); displayParts.push(ts.spacePart()); ts.addRange(displayParts, ts.typeToDisplayParts(typeChecker, typeChecker.getDeclaredTypeOfSymbol(symbol), enclosingDeclaration)); } if (symbolFlags & 384 /* Enum */) { addNewLineIfDisplayPartsExist(); if (ts.forEach(symbol.declarations, ts.isConstEnumDeclaration)) { - displayParts.push(ts.keywordPart(72 /* ConstKeyword */)); + displayParts.push(ts.keywordPart(74 /* ConstKeyword */)); displayParts.push(ts.spacePart()); } - displayParts.push(ts.keywordPart(79 /* EnumKeyword */)); + displayParts.push(ts.keywordPart(81 /* EnumKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); } if (symbolFlags & 1536 /* Module */) { addNewLineIfDisplayPartsExist(); - var declaration = ts.getDeclarationOfKind(symbol, 216 /* ModuleDeclaration */); - var isNamespace = declaration && declaration.name && declaration.name.kind === 67 /* Identifier */; - displayParts.push(ts.keywordPart(isNamespace ? 124 /* NamespaceKeyword */ : 123 /* ModuleKeyword */)); + var declaration = ts.getDeclarationOfKind(symbol, 218 /* ModuleDeclaration */); + var isNamespace = declaration && declaration.name && declaration.name.kind === 69 /* Identifier */; + displayParts.push(ts.keywordPart(isNamespace ? 126 /* NamespaceKeyword */ : 125 /* ModuleKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); } @@ -45166,7 +46020,7 @@ var ts; displayParts.push(ts.spacePart()); addFullSymbolName(symbol); displayParts.push(ts.spacePart()); - displayParts.push(ts.keywordPart(88 /* InKeyword */)); + displayParts.push(ts.keywordPart(90 /* InKeyword */)); displayParts.push(ts.spacePart()); if (symbol.parent) { // Class/Interface type parameter @@ -45177,13 +46031,13 @@ var ts; // Method/function type parameter var container = ts.getContainingFunction(location); if (container) { - var signatureDeclaration = ts.getDeclarationOfKind(symbol, 135 /* TypeParameter */).parent; + var signatureDeclaration = ts.getDeclarationOfKind(symbol, 137 /* TypeParameter */).parent; var signature = typeChecker.getSignatureFromDeclaration(signatureDeclaration); - if (signatureDeclaration.kind === 146 /* ConstructSignature */) { - displayParts.push(ts.keywordPart(90 /* NewKeyword */)); + if (signatureDeclaration.kind === 148 /* ConstructSignature */) { + displayParts.push(ts.keywordPart(92 /* NewKeyword */)); displayParts.push(ts.spacePart()); } - else if (signatureDeclaration.kind !== 145 /* CallSignature */ && signatureDeclaration.name) { + else if (signatureDeclaration.kind !== 147 /* CallSignature */ && signatureDeclaration.name) { addFullSymbolName(signatureDeclaration.symbol); } ts.addRange(displayParts, ts.signatureToDisplayParts(typeChecker, signature, sourceFile, 32 /* WriteTypeArgumentsOfSignature */)); @@ -45192,8 +46046,8 @@ var ts; // Type aliash type parameter // For example // type list = T[]; // Both T will go through same code path - var declaration = ts.getDeclarationOfKind(symbol, 135 /* TypeParameter */).parent; - displayParts.push(ts.keywordPart(130 /* TypeKeyword */)); + var declaration = ts.getDeclarationOfKind(symbol, 137 /* TypeParameter */).parent; + displayParts.push(ts.keywordPart(132 /* TypeKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(declaration.symbol); writeTypeParametersOfSymbol(declaration.symbol, sourceFile); @@ -45203,11 +46057,11 @@ var ts; if (symbolFlags & 8 /* EnumMember */) { addPrefixForAnyFunctionOrVar(symbol, "enum member"); var declaration = symbol.declarations[0]; - if (declaration.kind === 245 /* EnumMember */) { + if (declaration.kind === 247 /* EnumMember */) { var constantValue = typeChecker.getConstantValue(declaration); if (constantValue !== undefined) { displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(55 /* EqualsToken */)); + displayParts.push(ts.operatorPart(56 /* EqualsToken */)); displayParts.push(ts.spacePart()); displayParts.push(ts.displayPart(constantValue.toString(), SymbolDisplayPartKind.numericLiteral)); } @@ -45215,17 +46069,17 @@ var ts; } if (symbolFlags & 8388608 /* Alias */) { addNewLineIfDisplayPartsExist(); - displayParts.push(ts.keywordPart(87 /* ImportKeyword */)); + displayParts.push(ts.keywordPart(89 /* ImportKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); ts.forEach(symbol.declarations, function (declaration) { - if (declaration.kind === 219 /* ImportEqualsDeclaration */) { + if (declaration.kind === 221 /* ImportEqualsDeclaration */) { var importEqualsDeclaration = declaration; if (ts.isExternalModuleImportEqualsDeclaration(importEqualsDeclaration)) { displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(55 /* EqualsToken */)); + displayParts.push(ts.operatorPart(56 /* EqualsToken */)); displayParts.push(ts.spacePart()); - displayParts.push(ts.keywordPart(125 /* RequireKeyword */)); + displayParts.push(ts.keywordPart(127 /* RequireKeyword */)); displayParts.push(ts.punctuationPart(17 /* OpenParenToken */)); displayParts.push(ts.displayPart(ts.getTextOfNode(ts.getExternalModuleImportEqualsDeclarationExpression(importEqualsDeclaration)), SymbolDisplayPartKind.stringLiteral)); displayParts.push(ts.punctuationPart(18 /* CloseParenToken */)); @@ -45234,7 +46088,7 @@ var ts; var internalAliasSymbol = typeChecker.getSymbolAtLocation(importEqualsDeclaration.moduleReference); if (internalAliasSymbol) { displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(55 /* EqualsToken */)); + displayParts.push(ts.operatorPart(56 /* EqualsToken */)); displayParts.push(ts.spacePart()); addFullSymbolName(internalAliasSymbol, enclosingDeclaration); } @@ -45251,7 +46105,7 @@ var ts; if (symbolKind === ScriptElementKind.memberVariableElement || symbolFlags & 3 /* Variable */ || symbolKind === ScriptElementKind.localVariableElement) { - displayParts.push(ts.punctuationPart(53 /* ColonToken */)); + displayParts.push(ts.punctuationPart(54 /* ColonToken */)); displayParts.push(ts.spacePart()); // If the type is type parameter, format it specially if (type.symbol && type.symbol.flags & 262144 /* TypeParameter */) { @@ -45351,11 +46205,11 @@ var ts; if (!symbol) { // Try getting just type at this position and show switch (node.kind) { - case 67 /* Identifier */: - case 164 /* PropertyAccessExpression */: - case 133 /* QualifiedName */: - case 95 /* ThisKeyword */: - case 93 /* SuperKeyword */: + case 69 /* Identifier */: + case 166 /* PropertyAccessExpression */: + case 135 /* QualifiedName */: + case 97 /* ThisKeyword */: + case 95 /* SuperKeyword */: // For the identifiers/this/super etc get the type at position var type = typeChecker.getTypeAtLocation(node); if (type) { @@ -45408,7 +46262,7 @@ var ts; function tryAddConstructSignature(symbol, location, symbolKind, symbolName, containerName, result) { // Applicable only if we are in a new expression, or we are on a constructor declaration // and in either case the symbol has a construct signature definition, i.e. class - if (isNewExpressionTarget(location) || location.kind === 119 /* ConstructorKeyword */) { + if (isNewExpressionTarget(location) || location.kind === 121 /* ConstructorKeyword */) { if (symbol.flags & 32 /* Class */) { // Find the first class-like declaration and try to get the construct signature. for (var _i = 0, _a = symbol.getDeclarations(); _i < _a.length; _i++) { @@ -45433,8 +46287,8 @@ var ts; var declarations = []; var definition; ts.forEach(signatureDeclarations, function (d) { - if ((selectConstructors && d.kind === 142 /* Constructor */) || - (!selectConstructors && (d.kind === 211 /* FunctionDeclaration */ || d.kind === 141 /* MethodDeclaration */ || d.kind === 140 /* MethodSignature */))) { + if ((selectConstructors && d.kind === 144 /* Constructor */) || + (!selectConstructors && (d.kind === 213 /* FunctionDeclaration */ || d.kind === 143 /* MethodDeclaration */ || d.kind === 142 /* MethodSignature */))) { declarations.push(d); if (d.body) definition = d; @@ -45494,7 +46348,7 @@ var ts; // to jump to the implementation directly. if (symbol.flags & 8388608 /* Alias */) { var declaration = symbol.declarations[0]; - if (node.kind === 67 /* Identifier */ && node.parent === declaration) { + if (node.kind === 69 /* Identifier */ && node.parent === declaration) { symbol = typeChecker.getAliasedSymbol(symbol); } } @@ -45503,7 +46357,7 @@ var ts; // go to the declaration of the property name (in this case stay at the same position). However, if go-to-definition // is performed at the location of property access, we would like to go to definition of the property in the short-hand // assignment. This case and others are handled by the following code. - if (node.parent.kind === 244 /* ShorthandPropertyAssignment */) { + if (node.parent.kind === 246 /* ShorthandPropertyAssignment */) { var shorthandSymbol = typeChecker.getShorthandAssignmentValueSymbol(symbol.valueDeclaration); if (!shorthandSymbol) { return []; @@ -45577,9 +46431,9 @@ var ts; }; } function getSemanticDocumentHighlights(node) { - if (node.kind === 67 /* Identifier */ || - node.kind === 95 /* ThisKeyword */ || - node.kind === 93 /* SuperKeyword */ || + if (node.kind === 69 /* Identifier */ || + node.kind === 97 /* ThisKeyword */ || + node.kind === 95 /* SuperKeyword */ || isLiteralNameOfPropertyDeclarationOrIndexAccess(node) || isNameOfExternalModuleImportOrDeclaration(node)) { var referencedSymbols = getReferencedSymbolsForNode(node, sourceFilesToSearch, /*findInStrings:*/ false, /*findInComments:*/ false); @@ -45630,77 +46484,77 @@ var ts; function getHighlightSpans(node) { if (node) { switch (node.kind) { - case 86 /* IfKeyword */: - case 78 /* ElseKeyword */: - if (hasKind(node.parent, 194 /* IfStatement */)) { + case 88 /* IfKeyword */: + case 80 /* ElseKeyword */: + if (hasKind(node.parent, 196 /* IfStatement */)) { return getIfElseOccurrences(node.parent); } break; - case 92 /* ReturnKeyword */: - if (hasKind(node.parent, 202 /* ReturnStatement */)) { + case 94 /* ReturnKeyword */: + if (hasKind(node.parent, 204 /* ReturnStatement */)) { return getReturnOccurrences(node.parent); } break; - case 96 /* ThrowKeyword */: - if (hasKind(node.parent, 206 /* ThrowStatement */)) { + case 98 /* ThrowKeyword */: + if (hasKind(node.parent, 208 /* ThrowStatement */)) { return getThrowOccurrences(node.parent); } break; - case 70 /* CatchKeyword */: - if (hasKind(parent(parent(node)), 207 /* TryStatement */)) { + case 72 /* CatchKeyword */: + if (hasKind(parent(parent(node)), 209 /* TryStatement */)) { return getTryCatchFinallyOccurrences(node.parent.parent); } break; - case 98 /* TryKeyword */: - case 83 /* FinallyKeyword */: - if (hasKind(parent(node), 207 /* TryStatement */)) { + case 100 /* TryKeyword */: + case 85 /* FinallyKeyword */: + if (hasKind(parent(node), 209 /* TryStatement */)) { return getTryCatchFinallyOccurrences(node.parent); } break; - case 94 /* SwitchKeyword */: - if (hasKind(node.parent, 204 /* SwitchStatement */)) { + case 96 /* SwitchKeyword */: + if (hasKind(node.parent, 206 /* SwitchStatement */)) { return getSwitchCaseDefaultOccurrences(node.parent); } break; - case 69 /* CaseKeyword */: - case 75 /* DefaultKeyword */: - if (hasKind(parent(parent(parent(node))), 204 /* SwitchStatement */)) { + case 71 /* CaseKeyword */: + case 77 /* DefaultKeyword */: + if (hasKind(parent(parent(parent(node))), 206 /* SwitchStatement */)) { return getSwitchCaseDefaultOccurrences(node.parent.parent.parent); } break; - case 68 /* BreakKeyword */: - case 73 /* ContinueKeyword */: - if (hasKind(node.parent, 201 /* BreakStatement */) || hasKind(node.parent, 200 /* ContinueStatement */)) { + case 70 /* BreakKeyword */: + case 75 /* ContinueKeyword */: + if (hasKind(node.parent, 203 /* BreakStatement */) || hasKind(node.parent, 202 /* ContinueStatement */)) { return getBreakOrContinueStatementOccurrences(node.parent); } break; - case 84 /* ForKeyword */: - if (hasKind(node.parent, 197 /* ForStatement */) || - hasKind(node.parent, 198 /* ForInStatement */) || - hasKind(node.parent, 199 /* ForOfStatement */)) { + case 86 /* ForKeyword */: + if (hasKind(node.parent, 199 /* ForStatement */) || + hasKind(node.parent, 200 /* ForInStatement */) || + hasKind(node.parent, 201 /* ForOfStatement */)) { return getLoopBreakContinueOccurrences(node.parent); } break; - case 102 /* WhileKeyword */: - case 77 /* DoKeyword */: - if (hasKind(node.parent, 196 /* WhileStatement */) || hasKind(node.parent, 195 /* DoStatement */)) { + case 104 /* WhileKeyword */: + case 79 /* DoKeyword */: + if (hasKind(node.parent, 198 /* WhileStatement */) || hasKind(node.parent, 197 /* DoStatement */)) { return getLoopBreakContinueOccurrences(node.parent); } break; - case 119 /* ConstructorKeyword */: - if (hasKind(node.parent, 142 /* Constructor */)) { + case 121 /* ConstructorKeyword */: + if (hasKind(node.parent, 144 /* Constructor */)) { return getConstructorOccurrences(node.parent); } break; - case 121 /* GetKeyword */: - case 127 /* SetKeyword */: - if (hasKind(node.parent, 143 /* GetAccessor */) || hasKind(node.parent, 144 /* SetAccessor */)) { + case 123 /* GetKeyword */: + case 129 /* SetKeyword */: + if (hasKind(node.parent, 145 /* GetAccessor */) || hasKind(node.parent, 146 /* SetAccessor */)) { return getGetAndSetOccurrences(node.parent); } break; default: if (ts.isModifier(node.kind) && node.parent && - (ts.isDeclaration(node.parent) || node.parent.kind === 191 /* VariableStatement */)) { + (ts.isDeclaration(node.parent) || node.parent.kind === 193 /* VariableStatement */)) { return getModifierOccurrences(node.kind, node.parent); } } @@ -45716,10 +46570,10 @@ var ts; aggregate(node); return statementAccumulator; function aggregate(node) { - if (node.kind === 206 /* ThrowStatement */) { + if (node.kind === 208 /* ThrowStatement */) { statementAccumulator.push(node); } - else if (node.kind === 207 /* TryStatement */) { + else if (node.kind === 209 /* TryStatement */) { var tryStatement = node; if (tryStatement.catchClause) { aggregate(tryStatement.catchClause); @@ -45748,12 +46602,12 @@ var ts; var child = throwStatement; while (child.parent) { var parent_12 = child.parent; - if (ts.isFunctionBlock(parent_12) || parent_12.kind === 246 /* SourceFile */) { + if (ts.isFunctionBlock(parent_12) || parent_12.kind === 248 /* SourceFile */) { return parent_12; } // A throw-statement is only owned by a try-statement if the try-statement has // a catch clause, and if the throw-statement occurs within the try block. - if (parent_12.kind === 207 /* TryStatement */) { + if (parent_12.kind === 209 /* TryStatement */) { var tryStatement = parent_12; if (tryStatement.tryBlock === child && tryStatement.catchClause) { return child; @@ -45768,7 +46622,7 @@ var ts; aggregate(node); return statementAccumulator; function aggregate(node) { - if (node.kind === 201 /* BreakStatement */ || node.kind === 200 /* ContinueStatement */) { + if (node.kind === 203 /* BreakStatement */ || node.kind === 202 /* ContinueStatement */) { statementAccumulator.push(node); } else if (!ts.isFunctionLike(node)) { @@ -45784,16 +46638,16 @@ var ts; function getBreakOrContinueOwner(statement) { for (var node_2 = statement.parent; node_2; node_2 = node_2.parent) { switch (node_2.kind) { - case 204 /* SwitchStatement */: - if (statement.kind === 200 /* ContinueStatement */) { + case 206 /* SwitchStatement */: + if (statement.kind === 202 /* ContinueStatement */) { continue; } // Fall through. - case 197 /* ForStatement */: - case 198 /* ForInStatement */: - case 199 /* ForOfStatement */: - case 196 /* WhileStatement */: - case 195 /* DoStatement */: + case 199 /* ForStatement */: + case 200 /* ForInStatement */: + case 201 /* ForOfStatement */: + case 198 /* WhileStatement */: + case 197 /* DoStatement */: if (!statement.label || isLabeledBy(node_2, statement.label.text)) { return node_2; } @@ -45812,24 +46666,24 @@ var ts; var container = declaration.parent; // Make sure we only highlight the keyword when it makes sense to do so. if (ts.isAccessibilityModifier(modifier)) { - if (!(container.kind === 212 /* ClassDeclaration */ || - container.kind === 184 /* ClassExpression */ || - (declaration.kind === 136 /* Parameter */ && hasKind(container, 142 /* Constructor */)))) { + if (!(container.kind === 214 /* ClassDeclaration */ || + container.kind === 186 /* ClassExpression */ || + (declaration.kind === 138 /* Parameter */ && hasKind(container, 144 /* Constructor */)))) { return undefined; } } - else if (modifier === 111 /* StaticKeyword */) { - if (!(container.kind === 212 /* ClassDeclaration */ || container.kind === 184 /* ClassExpression */)) { + else if (modifier === 113 /* StaticKeyword */) { + if (!(container.kind === 214 /* ClassDeclaration */ || container.kind === 186 /* ClassExpression */)) { return undefined; } } - else if (modifier === 80 /* ExportKeyword */ || modifier === 120 /* DeclareKeyword */) { - if (!(container.kind === 217 /* ModuleBlock */ || container.kind === 246 /* SourceFile */)) { + else if (modifier === 82 /* ExportKeyword */ || modifier === 122 /* DeclareKeyword */) { + if (!(container.kind === 219 /* ModuleBlock */ || container.kind === 248 /* SourceFile */)) { return undefined; } } - else if (modifier === 113 /* AbstractKeyword */) { - if (!(container.kind === 212 /* ClassDeclaration */ || declaration.kind === 212 /* ClassDeclaration */)) { + else if (modifier === 115 /* AbstractKeyword */) { + if (!(container.kind === 214 /* ClassDeclaration */ || declaration.kind === 214 /* ClassDeclaration */)) { return undefined; } } @@ -45841,8 +46695,8 @@ var ts; var modifierFlag = getFlagFromModifier(modifier); var nodes; switch (container.kind) { - case 217 /* ModuleBlock */: - case 246 /* SourceFile */: + case 219 /* ModuleBlock */: + case 248 /* SourceFile */: // Container is either a class declaration or the declaration is a classDeclaration if (modifierFlag & 256 /* Abstract */) { nodes = declaration.members.concat(declaration); @@ -45851,17 +46705,17 @@ var ts; nodes = container.statements; } break; - case 142 /* Constructor */: + case 144 /* Constructor */: nodes = container.parameters.concat(container.parent.members); break; - case 212 /* ClassDeclaration */: - case 184 /* ClassExpression */: + case 214 /* ClassDeclaration */: + case 186 /* ClassExpression */: nodes = container.members; // If we're an accessibility modifier, we're in an instance member and should search // the constructor's parameter list for instance members as well. if (modifierFlag & 112 /* AccessibilityModifier */) { var constructor = ts.forEach(container.members, function (member) { - return member.kind === 142 /* Constructor */ && member; + return member.kind === 144 /* Constructor */ && member; }); if (constructor) { nodes = nodes.concat(constructor.parameters); @@ -45882,19 +46736,19 @@ var ts; return ts.map(keywords, getHighlightSpanForNode); function getFlagFromModifier(modifier) { switch (modifier) { - case 110 /* PublicKeyword */: + case 112 /* PublicKeyword */: return 16 /* Public */; - case 108 /* PrivateKeyword */: + case 110 /* PrivateKeyword */: return 32 /* Private */; - case 109 /* ProtectedKeyword */: + case 111 /* ProtectedKeyword */: return 64 /* Protected */; - case 111 /* StaticKeyword */: + case 113 /* StaticKeyword */: return 128 /* Static */; - case 80 /* ExportKeyword */: + case 82 /* ExportKeyword */: return 1 /* Export */; - case 120 /* DeclareKeyword */: + case 122 /* DeclareKeyword */: return 2 /* Ambient */; - case 113 /* AbstractKeyword */: + case 115 /* AbstractKeyword */: return 256 /* Abstract */; default: ts.Debug.fail(); @@ -45914,13 +46768,13 @@ var ts; } function getGetAndSetOccurrences(accessorDeclaration) { var keywords = []; - tryPushAccessorKeyword(accessorDeclaration.symbol, 143 /* GetAccessor */); - tryPushAccessorKeyword(accessorDeclaration.symbol, 144 /* SetAccessor */); + tryPushAccessorKeyword(accessorDeclaration.symbol, 145 /* GetAccessor */); + tryPushAccessorKeyword(accessorDeclaration.symbol, 146 /* SetAccessor */); return ts.map(keywords, getHighlightSpanForNode); function tryPushAccessorKeyword(accessorSymbol, accessorKind) { var accessor = ts.getDeclarationOfKind(accessorSymbol, accessorKind); if (accessor) { - ts.forEach(accessor.getChildren(), function (child) { return pushKeywordIf(keywords, child, 121 /* GetKeyword */, 127 /* SetKeyword */); }); + ts.forEach(accessor.getChildren(), function (child) { return pushKeywordIf(keywords, child, 123 /* GetKeyword */, 129 /* SetKeyword */); }); } } } @@ -45929,19 +46783,19 @@ var ts; var keywords = []; ts.forEach(declarations, function (declaration) { ts.forEach(declaration.getChildren(), function (token) { - return pushKeywordIf(keywords, token, 119 /* ConstructorKeyword */); + return pushKeywordIf(keywords, token, 121 /* ConstructorKeyword */); }); }); return ts.map(keywords, getHighlightSpanForNode); } function getLoopBreakContinueOccurrences(loopNode) { var keywords = []; - if (pushKeywordIf(keywords, loopNode.getFirstToken(), 84 /* ForKeyword */, 102 /* WhileKeyword */, 77 /* DoKeyword */)) { + if (pushKeywordIf(keywords, loopNode.getFirstToken(), 86 /* ForKeyword */, 104 /* WhileKeyword */, 79 /* DoKeyword */)) { // If we succeeded and got a do-while loop, then start looking for a 'while' keyword. - if (loopNode.kind === 195 /* DoStatement */) { + if (loopNode.kind === 197 /* DoStatement */) { var loopTokens = loopNode.getChildren(); for (var i = loopTokens.length - 1; i >= 0; i--) { - if (pushKeywordIf(keywords, loopTokens[i], 102 /* WhileKeyword */)) { + if (pushKeywordIf(keywords, loopTokens[i], 104 /* WhileKeyword */)) { break; } } @@ -45950,7 +46804,7 @@ var ts; var breaksAndContinues = aggregateAllBreakAndContinueStatements(loopNode.statement); ts.forEach(breaksAndContinues, function (statement) { if (ownsBreakOrContinueStatement(loopNode, statement)) { - pushKeywordIf(keywords, statement.getFirstToken(), 68 /* BreakKeyword */, 73 /* ContinueKeyword */); + pushKeywordIf(keywords, statement.getFirstToken(), 70 /* BreakKeyword */, 75 /* ContinueKeyword */); } }); return ts.map(keywords, getHighlightSpanForNode); @@ -45959,13 +46813,13 @@ var ts; var owner = getBreakOrContinueOwner(breakOrContinueStatement); if (owner) { switch (owner.kind) { - case 197 /* ForStatement */: - case 198 /* ForInStatement */: - case 199 /* ForOfStatement */: - case 195 /* DoStatement */: - case 196 /* WhileStatement */: + case 199 /* ForStatement */: + case 200 /* ForInStatement */: + case 201 /* ForOfStatement */: + case 197 /* DoStatement */: + case 198 /* WhileStatement */: return getLoopBreakContinueOccurrences(owner); - case 204 /* SwitchStatement */: + case 206 /* SwitchStatement */: return getSwitchCaseDefaultOccurrences(owner); } } @@ -45973,14 +46827,14 @@ var ts; } function getSwitchCaseDefaultOccurrences(switchStatement) { var keywords = []; - pushKeywordIf(keywords, switchStatement.getFirstToken(), 94 /* SwitchKeyword */); + pushKeywordIf(keywords, switchStatement.getFirstToken(), 96 /* SwitchKeyword */); // Go through each clause in the switch statement, collecting the 'case'/'default' keywords. ts.forEach(switchStatement.caseBlock.clauses, function (clause) { - pushKeywordIf(keywords, clause.getFirstToken(), 69 /* CaseKeyword */, 75 /* DefaultKeyword */); + pushKeywordIf(keywords, clause.getFirstToken(), 71 /* CaseKeyword */, 77 /* DefaultKeyword */); var breaksAndContinues = aggregateAllBreakAndContinueStatements(clause); ts.forEach(breaksAndContinues, function (statement) { if (ownsBreakOrContinueStatement(switchStatement, statement)) { - pushKeywordIf(keywords, statement.getFirstToken(), 68 /* BreakKeyword */); + pushKeywordIf(keywords, statement.getFirstToken(), 70 /* BreakKeyword */); } }); }); @@ -45988,13 +46842,13 @@ var ts; } function getTryCatchFinallyOccurrences(tryStatement) { var keywords = []; - pushKeywordIf(keywords, tryStatement.getFirstToken(), 98 /* TryKeyword */); + pushKeywordIf(keywords, tryStatement.getFirstToken(), 100 /* TryKeyword */); if (tryStatement.catchClause) { - pushKeywordIf(keywords, tryStatement.catchClause.getFirstToken(), 70 /* CatchKeyword */); + pushKeywordIf(keywords, tryStatement.catchClause.getFirstToken(), 72 /* CatchKeyword */); } if (tryStatement.finallyBlock) { - var finallyKeyword = ts.findChildOfKind(tryStatement, 83 /* FinallyKeyword */, sourceFile); - pushKeywordIf(keywords, finallyKeyword, 83 /* FinallyKeyword */); + var finallyKeyword = ts.findChildOfKind(tryStatement, 85 /* FinallyKeyword */, sourceFile); + pushKeywordIf(keywords, finallyKeyword, 85 /* FinallyKeyword */); } return ts.map(keywords, getHighlightSpanForNode); } @@ -46005,13 +46859,13 @@ var ts; } var keywords = []; ts.forEach(aggregateOwnedThrowStatements(owner), function (throwStatement) { - pushKeywordIf(keywords, throwStatement.getFirstToken(), 96 /* ThrowKeyword */); + pushKeywordIf(keywords, throwStatement.getFirstToken(), 98 /* ThrowKeyword */); }); // If the "owner" is a function, then we equate 'return' and 'throw' statements in their // ability to "jump out" of the function, and include occurrences for both. if (ts.isFunctionBlock(owner)) { ts.forEachReturnStatement(owner, function (returnStatement) { - pushKeywordIf(keywords, returnStatement.getFirstToken(), 92 /* ReturnKeyword */); + pushKeywordIf(keywords, returnStatement.getFirstToken(), 94 /* ReturnKeyword */); }); } return ts.map(keywords, getHighlightSpanForNode); @@ -46019,36 +46873,36 @@ var ts; function getReturnOccurrences(returnStatement) { var func = ts.getContainingFunction(returnStatement); // If we didn't find a containing function with a block body, bail out. - if (!(func && hasKind(func.body, 190 /* Block */))) { + if (!(func && hasKind(func.body, 192 /* Block */))) { return undefined; } var keywords = []; ts.forEachReturnStatement(func.body, function (returnStatement) { - pushKeywordIf(keywords, returnStatement.getFirstToken(), 92 /* ReturnKeyword */); + pushKeywordIf(keywords, returnStatement.getFirstToken(), 94 /* ReturnKeyword */); }); // Include 'throw' statements that do not occur within a try block. ts.forEach(aggregateOwnedThrowStatements(func.body), function (throwStatement) { - pushKeywordIf(keywords, throwStatement.getFirstToken(), 96 /* ThrowKeyword */); + pushKeywordIf(keywords, throwStatement.getFirstToken(), 98 /* ThrowKeyword */); }); return ts.map(keywords, getHighlightSpanForNode); } function getIfElseOccurrences(ifStatement) { var keywords = []; // Traverse upwards through all parent if-statements linked by their else-branches. - while (hasKind(ifStatement.parent, 194 /* IfStatement */) && ifStatement.parent.elseStatement === ifStatement) { + while (hasKind(ifStatement.parent, 196 /* IfStatement */) && ifStatement.parent.elseStatement === ifStatement) { ifStatement = ifStatement.parent; } // Now traverse back down through the else branches, aggregating if/else keywords of if-statements. while (ifStatement) { var children = ifStatement.getChildren(); - pushKeywordIf(keywords, children[0], 86 /* IfKeyword */); + pushKeywordIf(keywords, children[0], 88 /* IfKeyword */); // Generally the 'else' keyword is second-to-last, so we traverse backwards. for (var i = children.length - 1; i >= 0; i--) { - if (pushKeywordIf(keywords, children[i], 78 /* ElseKeyword */)) { + if (pushKeywordIf(keywords, children[i], 80 /* ElseKeyword */)) { break; } } - if (!hasKind(ifStatement.elseStatement, 194 /* IfStatement */)) { + if (!hasKind(ifStatement.elseStatement, 196 /* IfStatement */)) { break; } ifStatement = ifStatement.elseStatement; @@ -46057,7 +46911,7 @@ var ts; // We'd like to highlight else/ifs together if they are only separated by whitespace // (i.e. the keywords are separated by no comments, no newlines). for (var i = 0; i < keywords.length; i++) { - if (keywords[i].kind === 78 /* ElseKeyword */ && i < keywords.length - 1) { + if (keywords[i].kind === 80 /* ElseKeyword */ && i < keywords.length - 1) { var elseKeyword = keywords[i]; var ifKeyword = keywords[i + 1]; // this *should* always be an 'if' keyword. var shouldCombindElseAndIf = true; @@ -46139,7 +46993,7 @@ var ts; if (!node) { return undefined; } - if (node.kind !== 67 /* Identifier */ && + if (node.kind !== 69 /* Identifier */ && // TODO (drosen): This should be enabled in a later release - currently breaks rename. //node.kind !== SyntaxKind.ThisKeyword && //node.kind !== SyntaxKind.SuperKeyword && @@ -46147,7 +47001,7 @@ var ts; !isNameOfExternalModuleImportOrDeclaration(node)) { return undefined; } - ts.Debug.assert(node.kind === 67 /* Identifier */ || node.kind === 8 /* NumericLiteral */ || node.kind === 9 /* StringLiteral */); + ts.Debug.assert(node.kind === 69 /* Identifier */ || node.kind === 8 /* NumericLiteral */ || node.kind === 9 /* StringLiteral */); return getReferencedSymbolsForNode(node, program.getSourceFiles(), findInStrings, findInComments); } function getReferencedSymbolsForNode(node, sourceFiles, findInStrings, findInComments) { @@ -46165,10 +47019,10 @@ var ts; return getLabelReferencesInNode(node.parent, node); } } - if (node.kind === 95 /* ThisKeyword */) { + if (node.kind === 97 /* ThisKeyword */) { return getReferencesForThisKeyword(node, sourceFiles); } - if (node.kind === 93 /* SuperKeyword */) { + if (node.kind === 95 /* SuperKeyword */) { return getReferencesForSuperKeyword(node); } var symbol = typeChecker.getSymbolAtLocation(node); @@ -46228,7 +47082,7 @@ var ts; } function isImportOrExportSpecifierImportSymbol(symbol) { return (symbol.flags & 8388608 /* Alias */) && ts.forEach(symbol.declarations, function (declaration) { - return declaration.kind === 224 /* ImportSpecifier */ || declaration.kind === 228 /* ExportSpecifier */; + return declaration.kind === 226 /* ImportSpecifier */ || declaration.kind === 230 /* ExportSpecifier */; }); } function getInternedName(symbol, location, declarations) { @@ -46255,14 +47109,14 @@ var ts; // If this is the symbol of a named function expression or named class expression, // then named references are limited to its own scope. var valueDeclaration = symbol.valueDeclaration; - if (valueDeclaration && (valueDeclaration.kind === 171 /* FunctionExpression */ || valueDeclaration.kind === 184 /* ClassExpression */)) { + if (valueDeclaration && (valueDeclaration.kind === 173 /* FunctionExpression */ || valueDeclaration.kind === 186 /* ClassExpression */)) { return valueDeclaration; } // If this is private property or method, the scope is the containing class if (symbol.flags & (4 /* Property */ | 8192 /* Method */)) { var privateDeclaration = ts.forEach(symbol.getDeclarations(), function (d) { return (d.flags & 32 /* Private */) ? d : undefined; }); if (privateDeclaration) { - return ts.getAncestor(privateDeclaration, 212 /* ClassDeclaration */); + return ts.getAncestor(privateDeclaration, 214 /* ClassDeclaration */); } } // If the symbol is an import we would like to find it if we are looking for what it imports. @@ -46288,7 +47142,7 @@ var ts; // Different declarations have different containers, bail out return undefined; } - if (container.kind === 246 /* SourceFile */ && !ts.isExternalModule(container)) { + if (container.kind === 248 /* SourceFile */ && !ts.isExternalModule(container)) { // This is a global variable and not an external module, any declaration defined // within this scope is visible outside the file return undefined; @@ -46359,7 +47213,7 @@ var ts; if (node) { // Compare the length so we filter out strict superstrings of the symbol we are looking for switch (node.kind) { - case 67 /* Identifier */: + case 69 /* Identifier */: return node.getWidth() === searchSymbolName.length; case 9 /* StringLiteral */: if (isLiteralNameOfPropertyDeclarationOrIndexAccess(node) || @@ -46461,13 +47315,13 @@ var ts; // Whether 'super' occurs in a static context within a class. var staticFlag = 128 /* Static */; switch (searchSpaceNode.kind) { - case 139 /* PropertyDeclaration */: - case 138 /* PropertySignature */: - case 141 /* MethodDeclaration */: - case 140 /* MethodSignature */: - case 142 /* Constructor */: - case 143 /* GetAccessor */: - case 144 /* SetAccessor */: + case 141 /* PropertyDeclaration */: + case 140 /* PropertySignature */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: + case 144 /* Constructor */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: staticFlag &= searchSpaceNode.flags; searchSpaceNode = searchSpaceNode.parent; // re-assign to be the owning class break; @@ -46480,7 +47334,7 @@ var ts; ts.forEach(possiblePositions, function (position) { cancellationToken.throwIfCancellationRequested(); var node = ts.getTouchingWord(sourceFile, position); - if (!node || node.kind !== 93 /* SuperKeyword */) { + if (!node || node.kind !== 95 /* SuperKeyword */) { return; } var container = ts.getSuperContainer(node, /*includeFunctions*/ false); @@ -46499,27 +47353,27 @@ var ts; // Whether 'this' occurs in a static context within a class. var staticFlag = 128 /* Static */; switch (searchSpaceNode.kind) { - case 141 /* MethodDeclaration */: - case 140 /* MethodSignature */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: if (ts.isObjectLiteralMethod(searchSpaceNode)) { break; } // fall through - case 139 /* PropertyDeclaration */: - case 138 /* PropertySignature */: - case 142 /* Constructor */: - case 143 /* GetAccessor */: - case 144 /* SetAccessor */: + case 141 /* PropertyDeclaration */: + case 140 /* PropertySignature */: + case 144 /* Constructor */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: staticFlag &= searchSpaceNode.flags; searchSpaceNode = searchSpaceNode.parent; // re-assign to be the owning class break; - case 246 /* SourceFile */: + case 248 /* SourceFile */: if (ts.isExternalModule(searchSpaceNode)) { return undefined; } // Fall through - case 211 /* FunctionDeclaration */: - case 171 /* FunctionExpression */: + case 213 /* FunctionDeclaration */: + case 173 /* FunctionExpression */: break; // Computed properties in classes are not handled here because references to this are illegal, // so there is no point finding references to them. @@ -46528,7 +47382,7 @@ var ts; } var references = []; var possiblePositions; - if (searchSpaceNode.kind === 246 /* SourceFile */) { + if (searchSpaceNode.kind === 248 /* SourceFile */) { ts.forEach(sourceFiles, function (sourceFile) { possiblePositions = getPossibleSymbolReferencePositions(sourceFile, "this", sourceFile.getStart(), sourceFile.getEnd()); getThisReferencesInFile(sourceFile, sourceFile, possiblePositions, references); @@ -46554,33 +47408,33 @@ var ts; ts.forEach(possiblePositions, function (position) { cancellationToken.throwIfCancellationRequested(); var node = ts.getTouchingWord(sourceFile, position); - if (!node || node.kind !== 95 /* ThisKeyword */) { + if (!node || node.kind !== 97 /* ThisKeyword */) { return; } var container = ts.getThisContainer(node, /* includeArrowFunctions */ false); switch (searchSpaceNode.kind) { - case 171 /* FunctionExpression */: - case 211 /* FunctionDeclaration */: + case 173 /* FunctionExpression */: + case 213 /* FunctionDeclaration */: if (searchSpaceNode.symbol === container.symbol) { result.push(getReferenceEntryFromNode(node)); } break; - case 141 /* MethodDeclaration */: - case 140 /* MethodSignature */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: if (ts.isObjectLiteralMethod(searchSpaceNode) && searchSpaceNode.symbol === container.symbol) { result.push(getReferenceEntryFromNode(node)); } break; - case 184 /* ClassExpression */: - case 212 /* ClassDeclaration */: + case 186 /* ClassExpression */: + case 214 /* ClassDeclaration */: // Make sure the container belongs to the same class // and has the appropriate static modifier from the original container. if (container.parent && searchSpaceNode.symbol === container.parent.symbol && (container.flags & 128 /* Static */) === staticFlag) { result.push(getReferenceEntryFromNode(node)); } break; - case 246 /* SourceFile */: - if (container.kind === 246 /* SourceFile */ && !ts.isExternalModule(container)) { + case 248 /* SourceFile */: + if (container.kind === 248 /* SourceFile */ && !ts.isExternalModule(container)) { result.push(getReferenceEntryFromNode(node)); } break; @@ -46634,11 +47488,11 @@ var ts; function getPropertySymbolsFromBaseTypes(symbol, propertyName, result) { if (symbol && symbol.flags & (32 /* Class */ | 64 /* Interface */)) { ts.forEach(symbol.getDeclarations(), function (declaration) { - if (declaration.kind === 212 /* ClassDeclaration */) { + if (declaration.kind === 214 /* ClassDeclaration */) { getPropertySymbolFromTypeReference(ts.getClassExtendsHeritageClauseElement(declaration)); ts.forEach(ts.getClassImplementsHeritageClauseElements(declaration), getPropertySymbolFromTypeReference); } - else if (declaration.kind === 213 /* InterfaceDeclaration */) { + else if (declaration.kind === 215 /* InterfaceDeclaration */) { ts.forEach(ts.getInterfaceBaseTypeNodes(declaration), getPropertySymbolFromTypeReference); } }); @@ -46699,19 +47553,19 @@ var ts; if (isNameOfPropertyAssignment(node)) { var objectLiteral = node.parent.parent; var contextualType = typeChecker.getContextualType(objectLiteral); - var name_33 = node.text; + var name_34 = node.text; if (contextualType) { if (contextualType.flags & 16384 /* Union */) { // This is a union type, first see if the property we are looking for is a union property (i.e. exists in all types) // if not, search the constituent types for the property - var unionProperty = contextualType.getProperty(name_33); + var unionProperty = contextualType.getProperty(name_34); if (unionProperty) { return [unionProperty]; } else { var result_4 = []; ts.forEach(contextualType.types, function (t) { - var symbol = t.getProperty(name_33); + var symbol = t.getProperty(name_34); if (symbol) { result_4.push(symbol); } @@ -46720,7 +47574,7 @@ var ts; } } else { - var symbol_1 = contextualType.getProperty(name_33); + var symbol_1 = contextualType.getProperty(name_34); if (symbol_1) { return [symbol_1]; } @@ -46773,17 +47627,17 @@ var ts; } /** A node is considered a writeAccess iff it is a name of a declaration or a target of an assignment */ function isWriteAccess(node) { - if (node.kind === 67 /* Identifier */ && ts.isDeclarationName(node)) { + if (node.kind === 69 /* Identifier */ && ts.isDeclarationName(node)) { return true; } var parent = node.parent; if (parent) { - if (parent.kind === 178 /* PostfixUnaryExpression */ || parent.kind === 177 /* PrefixUnaryExpression */) { + if (parent.kind === 180 /* PostfixUnaryExpression */ || parent.kind === 179 /* PrefixUnaryExpression */) { return true; } - else if (parent.kind === 179 /* BinaryExpression */ && parent.left === node) { + else if (parent.kind === 181 /* BinaryExpression */ && parent.left === node) { var operator = parent.operatorToken.kind; - return 55 /* FirstAssignment */ <= operator && operator <= 66 /* LastAssignment */; + return 56 /* FirstAssignment */ <= operator && operator <= 68 /* LastAssignment */; } } return false; @@ -46815,33 +47669,33 @@ var ts; } function getMeaningFromDeclaration(node) { switch (node.kind) { - case 136 /* Parameter */: - case 209 /* VariableDeclaration */: - case 161 /* BindingElement */: - case 139 /* PropertyDeclaration */: - case 138 /* PropertySignature */: - case 243 /* PropertyAssignment */: - case 244 /* ShorthandPropertyAssignment */: - case 245 /* EnumMember */: - case 141 /* MethodDeclaration */: - case 140 /* MethodSignature */: - case 142 /* Constructor */: - case 143 /* GetAccessor */: - case 144 /* SetAccessor */: - case 211 /* FunctionDeclaration */: - case 171 /* FunctionExpression */: - case 172 /* ArrowFunction */: - case 242 /* CatchClause */: + case 138 /* Parameter */: + case 211 /* VariableDeclaration */: + case 163 /* BindingElement */: + case 141 /* PropertyDeclaration */: + case 140 /* PropertySignature */: + case 245 /* PropertyAssignment */: + case 246 /* ShorthandPropertyAssignment */: + case 247 /* EnumMember */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: + case 144 /* Constructor */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: + case 213 /* FunctionDeclaration */: + case 173 /* FunctionExpression */: + case 174 /* ArrowFunction */: + case 244 /* CatchClause */: return 1 /* Value */; - case 135 /* TypeParameter */: - case 213 /* InterfaceDeclaration */: - case 214 /* TypeAliasDeclaration */: - case 153 /* TypeLiteral */: + case 137 /* TypeParameter */: + case 215 /* InterfaceDeclaration */: + case 216 /* TypeAliasDeclaration */: + case 155 /* TypeLiteral */: return 2 /* Type */; - case 212 /* ClassDeclaration */: - case 215 /* EnumDeclaration */: + case 214 /* ClassDeclaration */: + case 217 /* EnumDeclaration */: return 1 /* Value */ | 2 /* Type */; - case 216 /* ModuleDeclaration */: + case 218 /* ModuleDeclaration */: if (node.name.kind === 9 /* StringLiteral */) { return 4 /* Namespace */ | 1 /* Value */; } @@ -46851,15 +47705,15 @@ var ts; else { return 4 /* Namespace */; } - case 223 /* NamedImports */: - case 224 /* ImportSpecifier */: - case 219 /* ImportEqualsDeclaration */: - case 220 /* ImportDeclaration */: - case 225 /* ExportAssignment */: - case 226 /* ExportDeclaration */: + case 225 /* NamedImports */: + case 226 /* ImportSpecifier */: + case 221 /* ImportEqualsDeclaration */: + case 222 /* ImportDeclaration */: + case 227 /* ExportAssignment */: + case 228 /* ExportDeclaration */: return 1 /* Value */ | 2 /* Type */ | 4 /* Namespace */; // An external module can be a Value - case 246 /* SourceFile */: + case 248 /* SourceFile */: return 4 /* Namespace */ | 1 /* Value */; } return 1 /* Value */ | 2 /* Type */ | 4 /* Namespace */; @@ -46869,8 +47723,9 @@ var ts; if (ts.isRightSideOfQualifiedNameOrPropertyAccess(node)) { node = node.parent; } - return node.parent.kind === 149 /* TypeReference */ || - (node.parent.kind === 186 /* ExpressionWithTypeArguments */ && !ts.isExpressionWithTypeArgumentsInClassExtendsClause(node.parent)); + return node.parent.kind === 151 /* TypeReference */ || + (node.parent.kind === 188 /* ExpressionWithTypeArguments */ && !ts.isExpressionWithTypeArgumentsInClassExtendsClause(node.parent)) || + node.kind === 97 /* ThisKeyword */ && !ts.isExpression(node); } function isNamespaceReference(node) { return isQualifiedNameNamespaceReference(node) || isPropertyAccessNamespaceReference(node); @@ -46878,50 +47733,50 @@ var ts; function isPropertyAccessNamespaceReference(node) { var root = node; var isLastClause = true; - if (root.parent.kind === 164 /* PropertyAccessExpression */) { - while (root.parent && root.parent.kind === 164 /* PropertyAccessExpression */) { + if (root.parent.kind === 166 /* PropertyAccessExpression */) { + while (root.parent && root.parent.kind === 166 /* PropertyAccessExpression */) { root = root.parent; } isLastClause = root.name === node; } - if (!isLastClause && root.parent.kind === 186 /* ExpressionWithTypeArguments */ && root.parent.parent.kind === 241 /* HeritageClause */) { + if (!isLastClause && root.parent.kind === 188 /* ExpressionWithTypeArguments */ && root.parent.parent.kind === 243 /* HeritageClause */) { var decl = root.parent.parent.parent; - return (decl.kind === 212 /* ClassDeclaration */ && root.parent.parent.token === 104 /* ImplementsKeyword */) || - (decl.kind === 213 /* InterfaceDeclaration */ && root.parent.parent.token === 81 /* ExtendsKeyword */); + return (decl.kind === 214 /* ClassDeclaration */ && root.parent.parent.token === 106 /* ImplementsKeyword */) || + (decl.kind === 215 /* InterfaceDeclaration */ && root.parent.parent.token === 83 /* ExtendsKeyword */); } return false; } function isQualifiedNameNamespaceReference(node) { var root = node; var isLastClause = true; - if (root.parent.kind === 133 /* QualifiedName */) { - while (root.parent && root.parent.kind === 133 /* QualifiedName */) { + if (root.parent.kind === 135 /* QualifiedName */) { + while (root.parent && root.parent.kind === 135 /* QualifiedName */) { root = root.parent; } isLastClause = root.right === node; } - return root.parent.kind === 149 /* TypeReference */ && !isLastClause; + return root.parent.kind === 151 /* TypeReference */ && !isLastClause; } function isInRightSideOfImport(node) { - while (node.parent.kind === 133 /* QualifiedName */) { + while (node.parent.kind === 135 /* QualifiedName */) { node = node.parent; } return ts.isInternalModuleImportEqualsDeclaration(node.parent) && node.parent.moduleReference === node; } function getMeaningFromRightHandSideOfImportEquals(node) { - ts.Debug.assert(node.kind === 67 /* Identifier */); + ts.Debug.assert(node.kind === 69 /* Identifier */); // import a = |b|; // Namespace // import a = |b.c|; // Value, type, namespace // import a = |b.c|.d; // Namespace - if (node.parent.kind === 133 /* QualifiedName */ && + if (node.parent.kind === 135 /* QualifiedName */ && node.parent.right === node && - node.parent.parent.kind === 219 /* ImportEqualsDeclaration */) { + node.parent.parent.kind === 221 /* ImportEqualsDeclaration */) { return 1 /* Value */ | 2 /* Type */ | 4 /* Namespace */; } return 4 /* Namespace */; } function getMeaningFromLocation(node) { - if (node.parent.kind === 225 /* ExportAssignment */) { + if (node.parent.kind === 227 /* ExportAssignment */) { return 1 /* Value */ | 2 /* Type */ | 4 /* Namespace */; } else if (isInRightSideOfImport(node)) { @@ -46961,15 +47816,15 @@ var ts; return; } switch (node.kind) { - case 164 /* PropertyAccessExpression */: - case 133 /* QualifiedName */: + case 166 /* PropertyAccessExpression */: + case 135 /* QualifiedName */: case 9 /* StringLiteral */: - case 82 /* FalseKeyword */: - case 97 /* TrueKeyword */: - case 91 /* NullKeyword */: - case 93 /* SuperKeyword */: - case 95 /* ThisKeyword */: - case 67 /* Identifier */: + case 84 /* FalseKeyword */: + case 99 /* TrueKeyword */: + case 93 /* NullKeyword */: + case 95 /* SuperKeyword */: + case 97 /* ThisKeyword */: + case 69 /* Identifier */: break; // Cant create the text span default: @@ -46985,7 +47840,7 @@ var ts; // If this is name of a module declarations, check if this is right side of dotted module name // If parent of the module declaration which is parent of this node is module declaration and its body is the module declaration that this node is name of // Then this name is name from dotted module - if (nodeForStartPos.parent.parent.kind === 216 /* ModuleDeclaration */ && + if (nodeForStartPos.parent.parent.kind === 218 /* ModuleDeclaration */ && nodeForStartPos.parent.parent.body === nodeForStartPos.parent) { // Use parent module declarations name for start pos nodeForStartPos = nodeForStartPos.parent.parent.name; @@ -47026,10 +47881,10 @@ var ts; // That means we're calling back into the host around every 1.2k of the file we process. // Lib.d.ts has similar numbers. switch (kind) { - case 216 /* ModuleDeclaration */: - case 212 /* ClassDeclaration */: - case 213 /* InterfaceDeclaration */: - case 211 /* FunctionDeclaration */: + case 218 /* ModuleDeclaration */: + case 214 /* ClassDeclaration */: + case 215 /* InterfaceDeclaration */: + case 213 /* FunctionDeclaration */: cancellationToken.throwIfCancellationRequested(); } } @@ -47083,7 +47938,7 @@ var ts; */ function hasValueSideModule(symbol) { return ts.forEach(symbol.declarations, function (declaration) { - return declaration.kind === 216 /* ModuleDeclaration */ && + return declaration.kind === 218 /* ModuleDeclaration */ && ts.getModuleInstanceState(declaration) === 1 /* Instantiated */; }); } @@ -47093,7 +47948,7 @@ var ts; if (node && ts.textSpanIntersectsWith(span, node.getFullStart(), node.getFullWidth())) { var kind = node.kind; checkForClassificationCancellation(kind); - if (kind === 67 /* Identifier */ && !ts.nodeIsMissing(node)) { + if (kind === 69 /* Identifier */ && !ts.nodeIsMissing(node)) { var identifier = node; // Only bother calling into the typechecker if this is an identifier that // could possibly resolve to a type name. This makes classification run @@ -47238,16 +48093,16 @@ var ts; pushClassification(tag.tagName.pos, tag.tagName.end - tag.tagName.pos, 18 /* docCommentTagName */); pos = tag.tagName.end; switch (tag.kind) { - case 265 /* JSDocParameterTag */: + case 267 /* JSDocParameterTag */: processJSDocParameterTag(tag); break; - case 268 /* JSDocTemplateTag */: + case 270 /* JSDocTemplateTag */: processJSDocTemplateTag(tag); break; - case 267 /* JSDocTypeTag */: + case 269 /* JSDocTypeTag */: processElement(tag.typeExpression); break; - case 266 /* JSDocReturnTag */: + case 268 /* JSDocReturnTag */: processElement(tag.typeExpression); break; } @@ -47336,18 +48191,18 @@ var ts; } if (ts.isPunctuation(tokenKind)) { if (token) { - if (tokenKind === 55 /* EqualsToken */) { + if (tokenKind === 56 /* EqualsToken */) { // the '=' in a variable declaration is special cased here. - if (token.parent.kind === 209 /* VariableDeclaration */ || - token.parent.kind === 139 /* PropertyDeclaration */ || - token.parent.kind === 136 /* Parameter */) { + if (token.parent.kind === 211 /* VariableDeclaration */ || + token.parent.kind === 141 /* PropertyDeclaration */ || + token.parent.kind === 138 /* Parameter */) { return 5 /* operator */; } } - if (token.parent.kind === 179 /* BinaryExpression */ || - token.parent.kind === 177 /* PrefixUnaryExpression */ || - token.parent.kind === 178 /* PostfixUnaryExpression */ || - token.parent.kind === 180 /* ConditionalExpression */) { + if (token.parent.kind === 181 /* BinaryExpression */ || + token.parent.kind === 179 /* PrefixUnaryExpression */ || + token.parent.kind === 180 /* PostfixUnaryExpression */ || + token.parent.kind === 182 /* ConditionalExpression */) { return 5 /* operator */; } } @@ -47367,35 +48222,35 @@ var ts; // TODO (drosen): we should *also* get another classification type for these literals. return 6 /* stringLiteral */; } - else if (tokenKind === 67 /* Identifier */) { + else if (tokenKind === 69 /* Identifier */) { if (token) { switch (token.parent.kind) { - case 212 /* ClassDeclaration */: + case 214 /* ClassDeclaration */: if (token.parent.name === token) { return 11 /* className */; } return; - case 135 /* TypeParameter */: + case 137 /* TypeParameter */: if (token.parent.name === token) { return 15 /* typeParameterName */; } return; - case 213 /* InterfaceDeclaration */: + case 215 /* InterfaceDeclaration */: if (token.parent.name === token) { return 13 /* interfaceName */; } return; - case 215 /* EnumDeclaration */: + case 217 /* EnumDeclaration */: if (token.parent.name === token) { return 12 /* enumName */; } return; - case 216 /* ModuleDeclaration */: + case 218 /* ModuleDeclaration */: if (token.parent.name === token) { return 14 /* moduleName */; } return; - case 136 /* Parameter */: + case 138 /* Parameter */: if (token.parent.name === token) { return 17 /* parameterName */; } @@ -47507,8 +48362,12 @@ var ts; * Checks if position points to a valid position to add JSDoc comments, and if so, * returns the appropriate template. Otherwise returns an empty string. * Valid positions are - * - outside of comments, statements, and expressions, and - * - preceding a function declaration. + * - outside of comments, statements, and expressions, and + * - preceding a: + * - function/constructor/method declaration + * - class declarations + * - variable statements + * - namespace declarations * * Hosts should ideally check that: * - The line is all whitespace up to 'position' before performing the insertion. @@ -47532,23 +48391,48 @@ var ts; return undefined; } // TODO: add support for: - // - methods - // - constructors - // - class decls - var containingFunction = ts.getAncestor(tokenAtPos, 211 /* FunctionDeclaration */); - if (!containingFunction || containingFunction.getStart() < position) { + // - enums/enum members + // - interfaces + // - property declarations + // - potentially property assignments + var commentOwner; + findOwner: for (commentOwner = tokenAtPos; commentOwner; commentOwner = commentOwner.parent) { + switch (commentOwner.kind) { + case 213 /* FunctionDeclaration */: + case 143 /* MethodDeclaration */: + case 144 /* Constructor */: + case 214 /* ClassDeclaration */: + case 193 /* VariableStatement */: + break findOwner; + case 248 /* SourceFile */: + return undefined; + case 218 /* ModuleDeclaration */: + // If in walking up the tree, we hit a a nested namespace declaration, + // then we must be somewhere within a dotted namespace name; however we don't + // want to give back a JSDoc template for the 'b' or 'c' in 'namespace a.b.c { }'. + if (commentOwner.parent.kind === 218 /* ModuleDeclaration */) { + return undefined; + } + break findOwner; + } + } + if (!commentOwner || commentOwner.getStart() < position) { return undefined; } - var parameters = containingFunction.parameters; + var parameters = getParametersForJsDocOwningNode(commentOwner); var posLineAndChar = sourceFile.getLineAndCharacterOfPosition(position); var lineStart = sourceFile.getLineStarts()[posLineAndChar.line]; var indentationStr = sourceFile.text.substr(lineStart, posLineAndChar.character); // TODO: call a helper method instead once PR #4133 gets merged in. var newLine = host.getNewLine ? host.getNewLine() : "\r\n"; - var docParams = parameters.reduce(function (prev, cur, index) { - return prev + - indentationStr + " * @param " + (cur.name.kind === 67 /* Identifier */ ? cur.name.text : "param" + index) + newLine; - }, ""); + var docParams = ""; + for (var i = 0, numParams = parameters.length; i < numParams; i++) { + var currentName = parameters[i].name; + var paramName = currentName.kind === 69 /* Identifier */ ? + currentName.text : + "param" + i; + docParams += indentationStr + " * @param " + paramName + newLine; + } // A doc comment consists of the following // * The opening comment line // * the first line (without a param) for the object's untagged info (this is also where the caret ends up) @@ -47564,6 +48448,46 @@ var ts; (tokenStart === position ? newLine + indentationStr : ""); return { newText: result, caretOffset: preamble.length }; } + function getParametersForJsDocOwningNode(commentOwner) { + if (ts.isFunctionLike(commentOwner)) { + return commentOwner.parameters; + } + if (commentOwner.kind === 193 /* VariableStatement */) { + var varStatement = commentOwner; + var varDeclarations = varStatement.declarationList.declarations; + if (varDeclarations.length === 1 && varDeclarations[0].initializer) { + return getParametersFromRightHandSideOfAssignment(varDeclarations[0].initializer); + } + } + return emptyArray; + } + /** + * Digs into an an initializer or RHS operand of an assignment operation + * to get the parameters of an apt signature corresponding to a + * function expression or a class expression. + * + * @param rightHandSide the expression which may contain an appropriate set of parameters + * @returns the parameters of a signature found on the RHS if one exists; otherwise 'emptyArray'. + */ + function getParametersFromRightHandSideOfAssignment(rightHandSide) { + while (rightHandSide.kind === 172 /* ParenthesizedExpression */) { + rightHandSide = rightHandSide.expression; + } + switch (rightHandSide.kind) { + case 173 /* FunctionExpression */: + case 174 /* ArrowFunction */: + return rightHandSide.parameters; + case 186 /* ClassExpression */: + for (var _i = 0, _a = rightHandSide.members; _i < _a.length; _i++) { + var member = _a[_i]; + if (member.kind === 144 /* Constructor */) { + return member.parameters; + } + } + break; + } + return emptyArray; + } function getTodoComments(fileName, descriptors) { // Note: while getting todo comments seems like a syntactic operation, we actually // treat it as a semantic operation here. This is because we expect our host to call @@ -47694,7 +48618,7 @@ var ts; var typeChecker = program.getTypeChecker(); var node = ts.getTouchingWord(sourceFile, position); // Can only rename an identifier. - if (node && node.kind === 67 /* Identifier */) { + if (node && node.kind === 69 /* Identifier */) { var symbol = typeChecker.getSymbolAtLocation(node); // Only allow a symbol to be renamed if it actually has at least one declaration. if (symbol) { @@ -47795,7 +48719,7 @@ var ts; sourceFile.nameTable = nameTable; function walk(node) { switch (node.kind) { - case 67 /* Identifier */: + case 69 /* Identifier */: nameTable[node.text] = node.text; break; case 9 /* StringLiteral */: @@ -47805,7 +48729,7 @@ var ts; // then we want 'something' to be in the name table. Similarly, if we have // "a['propname']" then we want to store "propname" in the name table. if (ts.isDeclarationName(node) || - node.parent.kind === 230 /* ExternalModuleReference */ || + node.parent.kind === 232 /* ExternalModuleReference */ || isArgumentOfElementAccessExpression(node)) { nameTable[node.text] = node.text; } @@ -47818,7 +48742,7 @@ var ts; function isArgumentOfElementAccessExpression(node) { return node && node.parent && - node.parent.kind === 165 /* ElementAccessExpression */ && + node.parent.kind === 167 /* ElementAccessExpression */ && node.parent.argumentExpression === node; } /// Classifier @@ -47829,18 +48753,18 @@ var ts; /// we have a series of divide operator. this list allows us to be more accurate by ruling out /// locations where a regexp cannot exist. var noRegexTable = []; - noRegexTable[67 /* Identifier */] = true; + noRegexTable[69 /* Identifier */] = true; noRegexTable[9 /* StringLiteral */] = true; noRegexTable[8 /* NumericLiteral */] = true; noRegexTable[10 /* RegularExpressionLiteral */] = true; - noRegexTable[95 /* ThisKeyword */] = true; - noRegexTable[40 /* PlusPlusToken */] = true; - noRegexTable[41 /* MinusMinusToken */] = true; + noRegexTable[97 /* ThisKeyword */] = true; + noRegexTable[41 /* PlusPlusToken */] = true; + noRegexTable[42 /* MinusMinusToken */] = true; noRegexTable[18 /* CloseParenToken */] = true; noRegexTable[20 /* CloseBracketToken */] = true; noRegexTable[16 /* CloseBraceToken */] = true; - noRegexTable[97 /* TrueKeyword */] = true; - noRegexTable[82 /* FalseKeyword */] = true; + noRegexTable[99 /* TrueKeyword */] = true; + noRegexTable[84 /* FalseKeyword */] = true; // Just a stack of TemplateHeads and OpenCurlyBraces, used to perform rudimentary (inexact) // classification on template strings. Because of the context free nature of templates, // the only precise way to classify a template portion would be by propagating the stack across @@ -47865,10 +48789,10 @@ var ts; /** Returns true if 'keyword2' can legally follow 'keyword1' in any language construct. */ function canFollow(keyword1, keyword2) { if (ts.isAccessibilityModifier(keyword1)) { - if (keyword2 === 121 /* GetKeyword */ || - keyword2 === 127 /* SetKeyword */ || - keyword2 === 119 /* ConstructorKeyword */ || - keyword2 === 111 /* StaticKeyword */) { + if (keyword2 === 123 /* GetKeyword */ || + keyword2 === 129 /* SetKeyword */ || + keyword2 === 121 /* ConstructorKeyword */ || + keyword2 === 113 /* StaticKeyword */) { // Allow things like "public get", "public constructor" and "public static". // These are all legal. return true; @@ -47998,22 +48922,22 @@ var ts; do { token = scanner.scan(); if (!ts.isTrivia(token)) { - if ((token === 38 /* SlashToken */ || token === 59 /* SlashEqualsToken */) && !noRegexTable[lastNonTriviaToken]) { + if ((token === 39 /* SlashToken */ || token === 61 /* SlashEqualsToken */) && !noRegexTable[lastNonTriviaToken]) { if (scanner.reScanSlashToken() === 10 /* RegularExpressionLiteral */) { token = 10 /* RegularExpressionLiteral */; } } else if (lastNonTriviaToken === 21 /* DotToken */ && isKeyword(token)) { - token = 67 /* Identifier */; + token = 69 /* Identifier */; } else if (isKeyword(lastNonTriviaToken) && isKeyword(token) && !canFollow(lastNonTriviaToken, token)) { // We have two keywords in a row. Only treat the second as a keyword if // it's a sequence that could legally occur in the language. Otherwise // treat it as an identifier. This way, if someone writes "private var" // we recognize that 'var' is actually an identifier here. - token = 67 /* Identifier */; + token = 69 /* Identifier */; } - else if (lastNonTriviaToken === 67 /* Identifier */ && + else if (lastNonTriviaToken === 69 /* Identifier */ && token === 25 /* LessThanToken */) { // Could be the start of something generic. Keep track of that by bumping // up the current count of generic contexts we may be in. @@ -48024,16 +48948,16 @@ var ts; // generic entity is complete. angleBracketStack--; } - else if (token === 115 /* AnyKeyword */ || - token === 128 /* StringKeyword */ || - token === 126 /* NumberKeyword */ || - token === 118 /* BooleanKeyword */ || - token === 129 /* SymbolKeyword */) { + else if (token === 117 /* AnyKeyword */ || + token === 130 /* StringKeyword */ || + token === 128 /* NumberKeyword */ || + token === 120 /* BooleanKeyword */ || + token === 131 /* SymbolKeyword */) { if (angleBracketStack > 0 && !syntacticClassifierAbsent) { // If it looks like we're could be in something generic, don't classify this // as a keyword. We may just get overwritten by the syntactic classifier, // causing a noisy experience for the user. - token = 67 /* Identifier */; + token = 69 /* Identifier */; } } else if (token === 12 /* TemplateHead */) { @@ -48145,40 +49069,41 @@ var ts; function isBinaryExpressionOperatorToken(token) { switch (token) { case 37 /* AsteriskToken */: - case 38 /* SlashToken */: - case 39 /* PercentToken */: + case 39 /* SlashToken */: + case 40 /* PercentToken */: case 35 /* PlusToken */: case 36 /* MinusToken */: - case 42 /* LessThanLessThanToken */: - case 43 /* GreaterThanGreaterThanToken */: - case 44 /* GreaterThanGreaterThanGreaterThanToken */: + case 43 /* LessThanLessThanToken */: + case 44 /* GreaterThanGreaterThanToken */: + case 45 /* GreaterThanGreaterThanGreaterThanToken */: case 25 /* LessThanToken */: case 27 /* GreaterThanToken */: case 28 /* LessThanEqualsToken */: case 29 /* GreaterThanEqualsToken */: - case 89 /* InstanceOfKeyword */: - case 88 /* InKeyword */: + case 91 /* InstanceOfKeyword */: + case 90 /* InKeyword */: + case 116 /* AsKeyword */: case 30 /* EqualsEqualsToken */: case 31 /* ExclamationEqualsToken */: case 32 /* EqualsEqualsEqualsToken */: case 33 /* ExclamationEqualsEqualsToken */: - case 45 /* AmpersandToken */: - case 47 /* CaretToken */: - case 46 /* BarToken */: - case 50 /* AmpersandAmpersandToken */: - case 51 /* BarBarToken */: - case 65 /* BarEqualsToken */: - case 64 /* AmpersandEqualsToken */: - case 66 /* CaretEqualsToken */: - case 61 /* LessThanLessThanEqualsToken */: - case 62 /* GreaterThanGreaterThanEqualsToken */: - case 63 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 56 /* PlusEqualsToken */: - case 57 /* MinusEqualsToken */: - case 58 /* AsteriskEqualsToken */: - case 59 /* SlashEqualsToken */: - case 60 /* PercentEqualsToken */: - case 55 /* EqualsToken */: + case 46 /* AmpersandToken */: + case 48 /* CaretToken */: + case 47 /* BarToken */: + case 51 /* AmpersandAmpersandToken */: + case 52 /* BarBarToken */: + case 67 /* BarEqualsToken */: + case 66 /* AmpersandEqualsToken */: + case 68 /* CaretEqualsToken */: + case 63 /* LessThanLessThanEqualsToken */: + case 64 /* GreaterThanGreaterThanEqualsToken */: + case 65 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + case 57 /* PlusEqualsToken */: + case 58 /* MinusEqualsToken */: + case 59 /* AsteriskEqualsToken */: + case 61 /* SlashEqualsToken */: + case 62 /* PercentEqualsToken */: + case 56 /* EqualsToken */: case 24 /* CommaToken */: return true; default: @@ -48189,17 +49114,17 @@ var ts; switch (token) { case 35 /* PlusToken */: case 36 /* MinusToken */: - case 49 /* TildeToken */: - case 48 /* ExclamationToken */: - case 40 /* PlusPlusToken */: - case 41 /* MinusMinusToken */: + case 50 /* TildeToken */: + case 49 /* ExclamationToken */: + case 41 /* PlusPlusToken */: + case 42 /* MinusMinusToken */: return true; default: return false; } } function isKeyword(token) { - return token >= 68 /* FirstKeyword */ && token <= 132 /* LastKeyword */; + return token >= 70 /* FirstKeyword */ && token <= 134 /* LastKeyword */; } function classFromKind(token) { if (isKeyword(token)) { @@ -48208,7 +49133,7 @@ var ts; else if (isBinaryExpressionOperatorToken(token) || isPrefixUnaryExpressionOperatorToken(token)) { return 5 /* operator */; } - else if (token >= 15 /* FirstPunctuation */ && token <= 66 /* LastPunctuation */) { + else if (token >= 15 /* FirstPunctuation */ && token <= 68 /* LastPunctuation */) { return 10 /* punctuation */; } switch (token) { @@ -48225,7 +49150,7 @@ var ts; case 5 /* WhitespaceTrivia */: case 4 /* NewLineTrivia */: return 8 /* whiteSpace */; - case 67 /* Identifier */: + case 69 /* Identifier */: default: if (ts.isTemplateLiteralKind(token)) { return 6 /* stringLiteral */; @@ -48257,7 +49182,7 @@ var ts; getNodeConstructor: function (kind) { function Node() { } - var proto = kind === 246 /* SourceFile */ ? new SourceFileObject() : new NodeObject(); + var proto = kind === 248 /* SourceFile */ ? new SourceFileObject() : new NodeObject(); proto.kind = kind; proto.pos = -1; proto.end = -1; @@ -48327,125 +49252,125 @@ var ts; function spanInNode(node) { if (node) { if (ts.isExpression(node)) { - if (node.parent.kind === 195 /* DoStatement */) { + if (node.parent.kind === 197 /* DoStatement */) { // Set span as if on while keyword return spanInPreviousNode(node); } - if (node.parent.kind === 197 /* ForStatement */) { + if (node.parent.kind === 199 /* ForStatement */) { // For now lets set the span on this expression, fix it later return textSpan(node); } - if (node.parent.kind === 179 /* BinaryExpression */ && node.parent.operatorToken.kind === 24 /* CommaToken */) { + if (node.parent.kind === 181 /* BinaryExpression */ && node.parent.operatorToken.kind === 24 /* CommaToken */) { // if this is comma expression, the breakpoint is possible in this expression return textSpan(node); } - if (node.parent.kind === 172 /* ArrowFunction */ && node.parent.body === node) { + if (node.parent.kind === 174 /* ArrowFunction */ && node.parent.body === node) { // If this is body of arrow function, it is allowed to have the breakpoint return textSpan(node); } } switch (node.kind) { - case 191 /* VariableStatement */: + case 193 /* VariableStatement */: // Span on first variable declaration return spanInVariableDeclaration(node.declarationList.declarations[0]); - case 209 /* VariableDeclaration */: - case 139 /* PropertyDeclaration */: - case 138 /* PropertySignature */: + case 211 /* VariableDeclaration */: + case 141 /* PropertyDeclaration */: + case 140 /* PropertySignature */: return spanInVariableDeclaration(node); - case 136 /* Parameter */: + case 138 /* Parameter */: return spanInParameterDeclaration(node); - case 211 /* FunctionDeclaration */: - case 141 /* MethodDeclaration */: - case 140 /* MethodSignature */: - case 143 /* GetAccessor */: - case 144 /* SetAccessor */: - case 142 /* Constructor */: - case 171 /* FunctionExpression */: - case 172 /* ArrowFunction */: + case 213 /* FunctionDeclaration */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: + case 144 /* Constructor */: + case 173 /* FunctionExpression */: + case 174 /* ArrowFunction */: return spanInFunctionDeclaration(node); - case 190 /* Block */: + case 192 /* Block */: if (ts.isFunctionBlock(node)) { return spanInFunctionBlock(node); } // Fall through - case 217 /* ModuleBlock */: + case 219 /* ModuleBlock */: return spanInBlock(node); - case 242 /* CatchClause */: + case 244 /* CatchClause */: return spanInBlock(node.block); - case 193 /* ExpressionStatement */: + case 195 /* ExpressionStatement */: // span on the expression return textSpan(node.expression); - case 202 /* ReturnStatement */: + case 204 /* ReturnStatement */: // span on return keyword and expression if present return textSpan(node.getChildAt(0), node.expression); - case 196 /* WhileStatement */: + case 198 /* WhileStatement */: // Span on while(...) return textSpan(node, ts.findNextToken(node.expression, node)); - case 195 /* DoStatement */: + case 197 /* DoStatement */: // span in statement of the do statement return spanInNode(node.statement); - case 208 /* DebuggerStatement */: + case 210 /* DebuggerStatement */: // span on debugger keyword return textSpan(node.getChildAt(0)); - case 194 /* IfStatement */: + case 196 /* IfStatement */: // set on if(..) span return textSpan(node, ts.findNextToken(node.expression, node)); - case 205 /* LabeledStatement */: + case 207 /* LabeledStatement */: // span in statement return spanInNode(node.statement); - case 201 /* BreakStatement */: - case 200 /* ContinueStatement */: + case 203 /* BreakStatement */: + case 202 /* ContinueStatement */: // On break or continue keyword and label if present return textSpan(node.getChildAt(0), node.label); - case 197 /* ForStatement */: + case 199 /* ForStatement */: return spanInForStatement(node); - case 198 /* ForInStatement */: - case 199 /* ForOfStatement */: + case 200 /* ForInStatement */: + case 201 /* ForOfStatement */: // span on for (a in ...) return textSpan(node, ts.findNextToken(node.expression, node)); - case 204 /* SwitchStatement */: + case 206 /* SwitchStatement */: // span on switch(...) return textSpan(node, ts.findNextToken(node.expression, node)); - case 239 /* CaseClause */: - case 240 /* DefaultClause */: + case 241 /* CaseClause */: + case 242 /* DefaultClause */: // span in first statement of the clause return spanInNode(node.statements[0]); - case 207 /* TryStatement */: + case 209 /* TryStatement */: // span in try block return spanInBlock(node.tryBlock); - case 206 /* ThrowStatement */: + case 208 /* ThrowStatement */: // span in throw ... return textSpan(node, node.expression); - case 225 /* ExportAssignment */: + case 227 /* ExportAssignment */: // span on export = id return textSpan(node, node.expression); - case 219 /* ImportEqualsDeclaration */: + case 221 /* ImportEqualsDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleReference); - case 220 /* ImportDeclaration */: + case 222 /* ImportDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleSpecifier); - case 226 /* ExportDeclaration */: + case 228 /* ExportDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleSpecifier); - case 216 /* ModuleDeclaration */: + case 218 /* ModuleDeclaration */: // span on complete module if it is instantiated if (ts.getModuleInstanceState(node) !== 1 /* Instantiated */) { return undefined; } - case 212 /* ClassDeclaration */: - case 215 /* EnumDeclaration */: - case 245 /* EnumMember */: - case 166 /* CallExpression */: - case 167 /* NewExpression */: + case 214 /* ClassDeclaration */: + case 217 /* EnumDeclaration */: + case 247 /* EnumMember */: + case 168 /* CallExpression */: + case 169 /* NewExpression */: // span on complete node return textSpan(node); - case 203 /* WithStatement */: + case 205 /* WithStatement */: // span in statement return spanInNode(node.statement); // No breakpoint in interface, type alias - case 213 /* InterfaceDeclaration */: - case 214 /* TypeAliasDeclaration */: + case 215 /* InterfaceDeclaration */: + case 216 /* TypeAliasDeclaration */: return undefined; // Tokens: case 23 /* SemicolonToken */: @@ -48461,25 +49386,25 @@ var ts; return spanInOpenParenToken(node); case 18 /* CloseParenToken */: return spanInCloseParenToken(node); - case 53 /* ColonToken */: + case 54 /* ColonToken */: return spanInColonToken(node); case 27 /* GreaterThanToken */: case 25 /* LessThanToken */: return spanInGreaterThanOrLessThanToken(node); // Keywords: - case 102 /* WhileKeyword */: + case 104 /* WhileKeyword */: return spanInWhileKeyword(node); - case 78 /* ElseKeyword */: - case 70 /* CatchKeyword */: - case 83 /* FinallyKeyword */: + case 80 /* ElseKeyword */: + case 72 /* CatchKeyword */: + case 85 /* FinallyKeyword */: return spanInNextNode(node); default: // If this is name of property assignment, set breakpoint in the initializer - if (node.parent.kind === 243 /* PropertyAssignment */ && node.parent.name === node) { + if (node.parent.kind === 245 /* PropertyAssignment */ && node.parent.name === node) { return spanInNode(node.parent.initializer); } // Breakpoint in type assertion goes to its operand - if (node.parent.kind === 169 /* TypeAssertionExpression */ && node.parent.type === node) { + if (node.parent.kind === 171 /* TypeAssertionExpression */ && node.parent.type === node) { return spanInNode(node.parent.expression); } // return type of function go to previous token @@ -48492,12 +49417,12 @@ var ts; } function spanInVariableDeclaration(variableDeclaration) { // If declaration of for in statement, just set the span in parent - if (variableDeclaration.parent.parent.kind === 198 /* ForInStatement */ || - variableDeclaration.parent.parent.kind === 199 /* ForOfStatement */) { + if (variableDeclaration.parent.parent.kind === 200 /* ForInStatement */ || + variableDeclaration.parent.parent.kind === 201 /* ForOfStatement */) { return spanInNode(variableDeclaration.parent.parent); } - var isParentVariableStatement = variableDeclaration.parent.parent.kind === 191 /* VariableStatement */; - var isDeclarationOfForStatement = variableDeclaration.parent.parent.kind === 197 /* ForStatement */ && ts.contains(variableDeclaration.parent.parent.initializer.declarations, variableDeclaration); + var isParentVariableStatement = variableDeclaration.parent.parent.kind === 193 /* VariableStatement */; + var isDeclarationOfForStatement = variableDeclaration.parent.parent.kind === 199 /* ForStatement */ && ts.contains(variableDeclaration.parent.parent.initializer.declarations, variableDeclaration); var declarations = isParentVariableStatement ? variableDeclaration.parent.parent.declarationList.declarations : isDeclarationOfForStatement @@ -48551,7 +49476,7 @@ var ts; } function canFunctionHaveSpanInWholeDeclaration(functionDeclaration) { return !!(functionDeclaration.flags & 1 /* Export */) || - (functionDeclaration.parent.kind === 212 /* ClassDeclaration */ && functionDeclaration.kind !== 142 /* Constructor */); + (functionDeclaration.parent.kind === 214 /* ClassDeclaration */ && functionDeclaration.kind !== 144 /* Constructor */); } function spanInFunctionDeclaration(functionDeclaration) { // No breakpoints in the function signature @@ -48574,18 +49499,18 @@ var ts; } function spanInBlock(block) { switch (block.parent.kind) { - case 216 /* ModuleDeclaration */: + case 218 /* ModuleDeclaration */: if (ts.getModuleInstanceState(block.parent) !== 1 /* Instantiated */) { return undefined; } // Set on parent if on same line otherwise on first statement - case 196 /* WhileStatement */: - case 194 /* IfStatement */: - case 198 /* ForInStatement */: - case 199 /* ForOfStatement */: + case 198 /* WhileStatement */: + case 196 /* IfStatement */: + case 200 /* ForInStatement */: + case 201 /* ForOfStatement */: return spanInNodeIfStartsOnSameLine(block.parent, block.statements[0]); // Set span on previous token if it starts on same line otherwise on the first statement of the block - case 197 /* ForStatement */: + case 199 /* ForStatement */: return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(block.pos, sourceFile, block.parent), block.statements[0]); } // Default action is to set on first statement @@ -48593,7 +49518,7 @@ var ts; } function spanInForStatement(forStatement) { if (forStatement.initializer) { - if (forStatement.initializer.kind === 210 /* VariableDeclarationList */) { + if (forStatement.initializer.kind === 212 /* VariableDeclarationList */) { var variableDeclarationList = forStatement.initializer; if (variableDeclarationList.declarations.length > 0) { return spanInNode(variableDeclarationList.declarations[0]); @@ -48613,13 +49538,13 @@ var ts; // Tokens: function spanInOpenBraceToken(node) { switch (node.parent.kind) { - case 215 /* EnumDeclaration */: + case 217 /* EnumDeclaration */: var enumDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), enumDeclaration.members.length ? enumDeclaration.members[0] : enumDeclaration.getLastToken(sourceFile)); - case 212 /* ClassDeclaration */: + case 214 /* ClassDeclaration */: var classDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), classDeclaration.members.length ? classDeclaration.members[0] : classDeclaration.getLastToken(sourceFile)); - case 218 /* CaseBlock */: + case 220 /* CaseBlock */: return spanInNodeIfStartsOnSameLine(node.parent.parent, node.parent.clauses[0]); } // Default to parent node @@ -48627,25 +49552,25 @@ var ts; } function spanInCloseBraceToken(node) { switch (node.parent.kind) { - case 217 /* ModuleBlock */: + case 219 /* ModuleBlock */: // If this is not instantiated module block no bp span if (ts.getModuleInstanceState(node.parent.parent) !== 1 /* Instantiated */) { return undefined; } - case 215 /* EnumDeclaration */: - case 212 /* ClassDeclaration */: + case 217 /* EnumDeclaration */: + case 214 /* ClassDeclaration */: // Span on close brace token return textSpan(node); - case 190 /* Block */: + case 192 /* Block */: if (ts.isFunctionBlock(node.parent)) { // Span on close brace token return textSpan(node); } // fall through. - case 242 /* CatchClause */: + case 244 /* CatchClause */: return spanInNode(ts.lastOrUndefined(node.parent.statements)); ; - case 218 /* CaseBlock */: + case 220 /* CaseBlock */: // breakpoint in last statement of the last clause var caseBlock = node.parent; var lastClause = ts.lastOrUndefined(caseBlock.clauses); @@ -48659,7 +49584,7 @@ var ts; } } function spanInOpenParenToken(node) { - if (node.parent.kind === 195 /* DoStatement */) { + if (node.parent.kind === 197 /* DoStatement */) { // Go to while keyword and do action instead return spanInPreviousNode(node); } @@ -48669,17 +49594,17 @@ var ts; function spanInCloseParenToken(node) { // Is this close paren token of parameter list, set span in previous token switch (node.parent.kind) { - case 171 /* FunctionExpression */: - case 211 /* FunctionDeclaration */: - case 172 /* ArrowFunction */: - case 141 /* MethodDeclaration */: - case 140 /* MethodSignature */: - case 143 /* GetAccessor */: - case 144 /* SetAccessor */: - case 142 /* Constructor */: - case 196 /* WhileStatement */: - case 195 /* DoStatement */: - case 197 /* ForStatement */: + case 173 /* FunctionExpression */: + case 213 /* FunctionDeclaration */: + case 174 /* ArrowFunction */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: + case 144 /* Constructor */: + case 198 /* WhileStatement */: + case 197 /* DoStatement */: + case 199 /* ForStatement */: return spanInPreviousNode(node); // Default to parent node default: @@ -48690,19 +49615,19 @@ var ts; } function spanInColonToken(node) { // Is this : specifying return annotation of the function declaration - if (ts.isFunctionLike(node.parent) || node.parent.kind === 243 /* PropertyAssignment */) { + if (ts.isFunctionLike(node.parent) || node.parent.kind === 245 /* PropertyAssignment */) { return spanInPreviousNode(node); } return spanInNode(node.parent); } function spanInGreaterThanOrLessThanToken(node) { - if (node.parent.kind === 169 /* TypeAssertionExpression */) { + if (node.parent.kind === 171 /* TypeAssertionExpression */) { return spanInNode(node.parent.expression); } return spanInNode(node.parent); } function spanInWhileKeyword(node) { - if (node.parent.kind === 195 /* DoStatement */) { + if (node.parent.kind === 197 /* DoStatement */) { // Set span on while expression return textSpan(node, ts.findNextToken(node.parent.expression, node.parent)); } @@ -49339,7 +50264,8 @@ var ts; }; CoreServicesShimObject.prototype.getPreProcessedFileInfo = function (fileName, sourceTextSnapshot) { return this.forwardJSONCall("getPreProcessedFileInfo('" + fileName + "')", function () { - var result = ts.preProcessFile(sourceTextSnapshot.getText(0, sourceTextSnapshot.getLength())); + // for now treat files as JavaScript + var result = ts.preProcessFile(sourceTextSnapshot.getText(0, sourceTextSnapshot.getLength()), /* readImportFiles */ true, /* detectJavaScriptImports */ true); var convertResult = { referencedFiles: [], importedFiles: [], diff --git a/lib/typescriptServices.d.ts b/lib/typescriptServices.d.ts index 761ce39d418..8e6c6a553a5 100644 --- a/lib/typescriptServices.d.ts +++ b/lib/typescriptServices.d.ts @@ -68,253 +68,255 @@ declare namespace ts { PlusToken = 35, MinusToken = 36, AsteriskToken = 37, - SlashToken = 38, - PercentToken = 39, - PlusPlusToken = 40, - MinusMinusToken = 41, - LessThanLessThanToken = 42, - GreaterThanGreaterThanToken = 43, - GreaterThanGreaterThanGreaterThanToken = 44, - AmpersandToken = 45, - BarToken = 46, - CaretToken = 47, - ExclamationToken = 48, - TildeToken = 49, - AmpersandAmpersandToken = 50, - BarBarToken = 51, - QuestionToken = 52, - ColonToken = 53, - AtToken = 54, - EqualsToken = 55, - PlusEqualsToken = 56, - MinusEqualsToken = 57, - AsteriskEqualsToken = 58, - SlashEqualsToken = 59, - PercentEqualsToken = 60, - LessThanLessThanEqualsToken = 61, - GreaterThanGreaterThanEqualsToken = 62, - GreaterThanGreaterThanGreaterThanEqualsToken = 63, - AmpersandEqualsToken = 64, - BarEqualsToken = 65, - CaretEqualsToken = 66, - Identifier = 67, - BreakKeyword = 68, - CaseKeyword = 69, - CatchKeyword = 70, - ClassKeyword = 71, - ConstKeyword = 72, - ContinueKeyword = 73, - DebuggerKeyword = 74, - DefaultKeyword = 75, - DeleteKeyword = 76, - DoKeyword = 77, - ElseKeyword = 78, - EnumKeyword = 79, - ExportKeyword = 80, - ExtendsKeyword = 81, - FalseKeyword = 82, - FinallyKeyword = 83, - ForKeyword = 84, - FunctionKeyword = 85, - IfKeyword = 86, - ImportKeyword = 87, - InKeyword = 88, - InstanceOfKeyword = 89, - NewKeyword = 90, - NullKeyword = 91, - ReturnKeyword = 92, - SuperKeyword = 93, - SwitchKeyword = 94, - ThisKeyword = 95, - ThrowKeyword = 96, - TrueKeyword = 97, - TryKeyword = 98, - TypeOfKeyword = 99, - VarKeyword = 100, - VoidKeyword = 101, - WhileKeyword = 102, - WithKeyword = 103, - ImplementsKeyword = 104, - InterfaceKeyword = 105, - LetKeyword = 106, - PackageKeyword = 107, - PrivateKeyword = 108, - ProtectedKeyword = 109, - PublicKeyword = 110, - StaticKeyword = 111, - YieldKeyword = 112, - AbstractKeyword = 113, - AsKeyword = 114, - AnyKeyword = 115, - AsyncKeyword = 116, - AwaitKeyword = 117, - BooleanKeyword = 118, - ConstructorKeyword = 119, - DeclareKeyword = 120, - GetKeyword = 121, - IsKeyword = 122, - ModuleKeyword = 123, - NamespaceKeyword = 124, - RequireKeyword = 125, - NumberKeyword = 126, - SetKeyword = 127, - StringKeyword = 128, - SymbolKeyword = 129, - TypeKeyword = 130, - FromKeyword = 131, - OfKeyword = 132, - QualifiedName = 133, - ComputedPropertyName = 134, - TypeParameter = 135, - Parameter = 136, - Decorator = 137, - PropertySignature = 138, - PropertyDeclaration = 139, - MethodSignature = 140, - MethodDeclaration = 141, - Constructor = 142, - GetAccessor = 143, - SetAccessor = 144, - CallSignature = 145, - ConstructSignature = 146, - IndexSignature = 147, - TypePredicate = 148, - TypeReference = 149, - FunctionType = 150, - ConstructorType = 151, - TypeQuery = 152, - TypeLiteral = 153, - ArrayType = 154, - TupleType = 155, - UnionType = 156, - IntersectionType = 157, - ParenthesizedType = 158, - ObjectBindingPattern = 159, - ArrayBindingPattern = 160, - BindingElement = 161, - ArrayLiteralExpression = 162, - ObjectLiteralExpression = 163, - PropertyAccessExpression = 164, - ElementAccessExpression = 165, - CallExpression = 166, - NewExpression = 167, - TaggedTemplateExpression = 168, - TypeAssertionExpression = 169, - ParenthesizedExpression = 170, - FunctionExpression = 171, - ArrowFunction = 172, - DeleteExpression = 173, - TypeOfExpression = 174, - VoidExpression = 175, - AwaitExpression = 176, - PrefixUnaryExpression = 177, - PostfixUnaryExpression = 178, - BinaryExpression = 179, - ConditionalExpression = 180, - TemplateExpression = 181, - YieldExpression = 182, - SpreadElementExpression = 183, - ClassExpression = 184, - OmittedExpression = 185, - ExpressionWithTypeArguments = 186, - AsExpression = 187, - TemplateSpan = 188, - SemicolonClassElement = 189, - Block = 190, - VariableStatement = 191, - EmptyStatement = 192, - ExpressionStatement = 193, - IfStatement = 194, - DoStatement = 195, - WhileStatement = 196, - ForStatement = 197, - ForInStatement = 198, - ForOfStatement = 199, - ContinueStatement = 200, - BreakStatement = 201, - ReturnStatement = 202, - WithStatement = 203, - SwitchStatement = 204, - LabeledStatement = 205, - ThrowStatement = 206, - TryStatement = 207, - DebuggerStatement = 208, - VariableDeclaration = 209, - VariableDeclarationList = 210, - FunctionDeclaration = 211, - ClassDeclaration = 212, - InterfaceDeclaration = 213, - TypeAliasDeclaration = 214, - EnumDeclaration = 215, - ModuleDeclaration = 216, - ModuleBlock = 217, - CaseBlock = 218, - ImportEqualsDeclaration = 219, - ImportDeclaration = 220, - ImportClause = 221, - NamespaceImport = 222, - NamedImports = 223, - ImportSpecifier = 224, - ExportAssignment = 225, - ExportDeclaration = 226, - NamedExports = 227, - ExportSpecifier = 228, - MissingDeclaration = 229, - ExternalModuleReference = 230, - JsxElement = 231, - JsxSelfClosingElement = 232, - JsxOpeningElement = 233, - JsxText = 234, - JsxClosingElement = 235, - JsxAttribute = 236, - JsxSpreadAttribute = 237, - JsxExpression = 238, - CaseClause = 239, - DefaultClause = 240, - HeritageClause = 241, - CatchClause = 242, - PropertyAssignment = 243, - ShorthandPropertyAssignment = 244, - EnumMember = 245, - SourceFile = 246, - JSDocTypeExpression = 247, - JSDocAllType = 248, - JSDocUnknownType = 249, - JSDocArrayType = 250, - JSDocUnionType = 251, - JSDocTupleType = 252, - JSDocNullableType = 253, - JSDocNonNullableType = 254, - JSDocRecordType = 255, - JSDocRecordMember = 256, - JSDocTypeReference = 257, - JSDocOptionalType = 258, - JSDocFunctionType = 259, - JSDocVariadicType = 260, - JSDocConstructorType = 261, - JSDocThisType = 262, - JSDocComment = 263, - JSDocTag = 264, - JSDocParameterTag = 265, - JSDocReturnTag = 266, - JSDocTypeTag = 267, - JSDocTemplateTag = 268, - SyntaxList = 269, - Count = 270, - FirstAssignment = 55, - LastAssignment = 66, - FirstReservedWord = 68, - LastReservedWord = 103, - FirstKeyword = 68, - LastKeyword = 132, - FirstFutureReservedWord = 104, - LastFutureReservedWord = 112, - FirstTypeNode = 149, - LastTypeNode = 158, + AsteriskAsteriskToken = 38, + SlashToken = 39, + PercentToken = 40, + PlusPlusToken = 41, + MinusMinusToken = 42, + LessThanLessThanToken = 43, + GreaterThanGreaterThanToken = 44, + GreaterThanGreaterThanGreaterThanToken = 45, + AmpersandToken = 46, + BarToken = 47, + CaretToken = 48, + ExclamationToken = 49, + TildeToken = 50, + AmpersandAmpersandToken = 51, + BarBarToken = 52, + QuestionToken = 53, + ColonToken = 54, + AtToken = 55, + EqualsToken = 56, + PlusEqualsToken = 57, + MinusEqualsToken = 58, + AsteriskEqualsToken = 59, + AsteriskAsteriskEqualsToken = 60, + SlashEqualsToken = 61, + PercentEqualsToken = 62, + LessThanLessThanEqualsToken = 63, + GreaterThanGreaterThanEqualsToken = 64, + GreaterThanGreaterThanGreaterThanEqualsToken = 65, + AmpersandEqualsToken = 66, + BarEqualsToken = 67, + CaretEqualsToken = 68, + Identifier = 69, + BreakKeyword = 70, + CaseKeyword = 71, + CatchKeyword = 72, + ClassKeyword = 73, + ConstKeyword = 74, + ContinueKeyword = 75, + DebuggerKeyword = 76, + DefaultKeyword = 77, + DeleteKeyword = 78, + DoKeyword = 79, + ElseKeyword = 80, + EnumKeyword = 81, + ExportKeyword = 82, + ExtendsKeyword = 83, + FalseKeyword = 84, + FinallyKeyword = 85, + ForKeyword = 86, + FunctionKeyword = 87, + IfKeyword = 88, + ImportKeyword = 89, + InKeyword = 90, + InstanceOfKeyword = 91, + NewKeyword = 92, + NullKeyword = 93, + ReturnKeyword = 94, + SuperKeyword = 95, + SwitchKeyword = 96, + ThisKeyword = 97, + ThrowKeyword = 98, + TrueKeyword = 99, + TryKeyword = 100, + TypeOfKeyword = 101, + VarKeyword = 102, + VoidKeyword = 103, + WhileKeyword = 104, + WithKeyword = 105, + ImplementsKeyword = 106, + InterfaceKeyword = 107, + LetKeyword = 108, + PackageKeyword = 109, + PrivateKeyword = 110, + ProtectedKeyword = 111, + PublicKeyword = 112, + StaticKeyword = 113, + YieldKeyword = 114, + AbstractKeyword = 115, + AsKeyword = 116, + AnyKeyword = 117, + AsyncKeyword = 118, + AwaitKeyword = 119, + BooleanKeyword = 120, + ConstructorKeyword = 121, + DeclareKeyword = 122, + GetKeyword = 123, + IsKeyword = 124, + ModuleKeyword = 125, + NamespaceKeyword = 126, + RequireKeyword = 127, + NumberKeyword = 128, + SetKeyword = 129, + StringKeyword = 130, + SymbolKeyword = 131, + TypeKeyword = 132, + FromKeyword = 133, + OfKeyword = 134, + QualifiedName = 135, + ComputedPropertyName = 136, + TypeParameter = 137, + Parameter = 138, + Decorator = 139, + PropertySignature = 140, + PropertyDeclaration = 141, + MethodSignature = 142, + MethodDeclaration = 143, + Constructor = 144, + GetAccessor = 145, + SetAccessor = 146, + CallSignature = 147, + ConstructSignature = 148, + IndexSignature = 149, + TypePredicate = 150, + TypeReference = 151, + FunctionType = 152, + ConstructorType = 153, + TypeQuery = 154, + TypeLiteral = 155, + ArrayType = 156, + TupleType = 157, + UnionType = 158, + IntersectionType = 159, + ParenthesizedType = 160, + ObjectBindingPattern = 161, + ArrayBindingPattern = 162, + BindingElement = 163, + ArrayLiteralExpression = 164, + ObjectLiteralExpression = 165, + PropertyAccessExpression = 166, + ElementAccessExpression = 167, + CallExpression = 168, + NewExpression = 169, + TaggedTemplateExpression = 170, + TypeAssertionExpression = 171, + ParenthesizedExpression = 172, + FunctionExpression = 173, + ArrowFunction = 174, + DeleteExpression = 175, + TypeOfExpression = 176, + VoidExpression = 177, + AwaitExpression = 178, + PrefixUnaryExpression = 179, + PostfixUnaryExpression = 180, + BinaryExpression = 181, + ConditionalExpression = 182, + TemplateExpression = 183, + YieldExpression = 184, + SpreadElementExpression = 185, + ClassExpression = 186, + OmittedExpression = 187, + ExpressionWithTypeArguments = 188, + AsExpression = 189, + TemplateSpan = 190, + SemicolonClassElement = 191, + Block = 192, + VariableStatement = 193, + EmptyStatement = 194, + ExpressionStatement = 195, + IfStatement = 196, + DoStatement = 197, + WhileStatement = 198, + ForStatement = 199, + ForInStatement = 200, + ForOfStatement = 201, + ContinueStatement = 202, + BreakStatement = 203, + ReturnStatement = 204, + WithStatement = 205, + SwitchStatement = 206, + LabeledStatement = 207, + ThrowStatement = 208, + TryStatement = 209, + DebuggerStatement = 210, + VariableDeclaration = 211, + VariableDeclarationList = 212, + FunctionDeclaration = 213, + ClassDeclaration = 214, + InterfaceDeclaration = 215, + TypeAliasDeclaration = 216, + EnumDeclaration = 217, + ModuleDeclaration = 218, + ModuleBlock = 219, + CaseBlock = 220, + ImportEqualsDeclaration = 221, + ImportDeclaration = 222, + ImportClause = 223, + NamespaceImport = 224, + NamedImports = 225, + ImportSpecifier = 226, + ExportAssignment = 227, + ExportDeclaration = 228, + NamedExports = 229, + ExportSpecifier = 230, + MissingDeclaration = 231, + ExternalModuleReference = 232, + JsxElement = 233, + JsxSelfClosingElement = 234, + JsxOpeningElement = 235, + JsxText = 236, + JsxClosingElement = 237, + JsxAttribute = 238, + JsxSpreadAttribute = 239, + JsxExpression = 240, + CaseClause = 241, + DefaultClause = 242, + HeritageClause = 243, + CatchClause = 244, + PropertyAssignment = 245, + ShorthandPropertyAssignment = 246, + EnumMember = 247, + SourceFile = 248, + JSDocTypeExpression = 249, + JSDocAllType = 250, + JSDocUnknownType = 251, + JSDocArrayType = 252, + JSDocUnionType = 253, + JSDocTupleType = 254, + JSDocNullableType = 255, + JSDocNonNullableType = 256, + JSDocRecordType = 257, + JSDocRecordMember = 258, + JSDocTypeReference = 259, + JSDocOptionalType = 260, + JSDocFunctionType = 261, + JSDocVariadicType = 262, + JSDocConstructorType = 263, + JSDocThisType = 264, + JSDocComment = 265, + JSDocTag = 266, + JSDocParameterTag = 267, + JSDocReturnTag = 268, + JSDocTypeTag = 269, + JSDocTemplateTag = 270, + SyntaxList = 271, + Count = 272, + FirstAssignment = 56, + LastAssignment = 68, + FirstReservedWord = 70, + LastReservedWord = 105, + FirstKeyword = 70, + LastKeyword = 134, + FirstFutureReservedWord = 106, + LastFutureReservedWord = 114, + FirstTypeNode = 151, + LastTypeNode = 160, FirstPunctuation = 15, - LastPunctuation = 66, + LastPunctuation = 68, FirstToken = 0, - LastToken = 132, + LastToken = 134, FirstTriviaToken = 2, LastTriviaToken = 7, FirstLiteralToken = 8, @@ -322,8 +324,8 @@ declare namespace ts { FirstTemplateToken = 11, LastTemplateToken = 14, FirstBinaryOperator = 25, - LastBinaryOperator = 66, - FirstNode = 133, + LastBinaryOperator = 68, + FirstNode = 135, } const enum NodeFlags { Export = 1, @@ -343,6 +345,7 @@ declare namespace ts { OctalLiteral = 65536, Namespace = 131072, ExportContext = 262144, + ContainsThis = 524288, Modifier = 2035, AccessibilityModifier = 112, BlockScoped = 49152, @@ -438,6 +441,8 @@ declare namespace ts { interface ShorthandPropertyAssignment extends ObjectLiteralElement { name: Identifier; questionToken?: Node; + equalsToken?: Node; + objectAssignmentInitializer?: Expression; } interface VariableLikeDeclaration extends Declaration { propertyName?: Identifier; @@ -530,18 +535,21 @@ declare namespace ts { interface UnaryExpression extends Expression { _unaryExpressionBrand: any; } - interface PrefixUnaryExpression extends UnaryExpression { + interface IncrementExpression extends UnaryExpression { + _incrementExpressionBrand: any; + } + interface PrefixUnaryExpression extends IncrementExpression { operator: SyntaxKind; operand: UnaryExpression; } - interface PostfixUnaryExpression extends PostfixExpression { + interface PostfixUnaryExpression extends IncrementExpression { operand: LeftHandSideExpression; operator: SyntaxKind; } interface PostfixExpression extends UnaryExpression { _postfixExpressionBrand: any; } - interface LeftHandSideExpression extends PostfixExpression { + interface LeftHandSideExpression extends IncrementExpression { _leftHandSideExpressionBrand: any; } interface MemberExpression extends LeftHandSideExpression { @@ -566,7 +574,7 @@ declare namespace ts { asteriskToken?: Node; expression?: Expression; } - interface BinaryExpression extends Expression { + interface BinaryExpression extends Expression, Declaration { left: Expression; operatorToken: Node; right: Expression; @@ -610,7 +618,7 @@ declare namespace ts { interface ObjectLiteralExpression extends PrimaryExpression, Declaration { properties: NodeArray; } - interface PropertyAccessExpression extends MemberExpression { + interface PropertyAccessExpression extends MemberExpression, Declaration { expression: LeftHandSideExpression; dotToken: Node; name: Identifier; @@ -1082,6 +1090,7 @@ declare namespace ts { decreaseIndent(): void; clear(): void; trackSymbol(symbol: Symbol, enclosingDeclaration?: Node, meaning?: SymbolFlags): void; + reportInaccessibleThisError(): void; } const enum TypeFormatFlags { None = 0, @@ -1202,6 +1211,7 @@ declare namespace ts { Instantiated = 131072, ObjectLiteral = 524288, ESSymbol = 16777216, + ThisType = 33554432, StringLike = 258, NumberLike = 132, ObjectType = 80896, @@ -1223,6 +1233,7 @@ declare namespace ts { typeParameters: TypeParameter[]; outerTypeParameters: TypeParameter[]; localTypeParameters: TypeParameter[]; + thisType: TypeParameter; } interface InterfaceTypeWithDeclaredMembers extends InterfaceType { declaredProperties: Symbol[]; @@ -1337,7 +1348,6 @@ declare namespace ts { watch?: boolean; isolatedModules?: boolean; experimentalDecorators?: boolean; - experimentalAsyncFunctions?: boolean; emitDecoratorMetadata?: boolean; moduleResolution?: ModuleResolutionKind; [option: string]: string | number | boolean; @@ -1348,6 +1358,7 @@ declare namespace ts { AMD = 2, UMD = 3, System = 4, + ES6 = 5, } const enum JsxEmit { None = 0, @@ -1417,7 +1428,7 @@ declare namespace ts { write(s: string): void; readFile(path: string, encoding?: string): string; writeFile(path: string, data: string, writeByteOrderMark?: boolean): void; - watchFile?(path: string, callback: (path: string) => void): FileWatcher; + watchFile?(path: string, callback: (path: string, removed: boolean) => void): FileWatcher; resolvePath(path: string): string; fileExists(path: string): boolean; directoryExists(path: string): boolean; @@ -1775,6 +1786,12 @@ declare namespace ts { TabSize: number; NewLineCharacter: string; ConvertTabsToSpaces: boolean; + IndentStyle: IndentStyle; + } + enum IndentStyle { + None = 0, + Block = 1, + Smart = 2, } interface FormatCodeOptions extends EditorOptions { InsertSpaceAfterCommaDelimiter: boolean; @@ -2132,7 +2149,7 @@ declare namespace ts { function updateLanguageServiceSourceFile(sourceFile: SourceFile, scriptSnapshot: IScriptSnapshot, version: string, textChangeRange: TextChangeRange, aggressiveChecks?: boolean): SourceFile; function createGetCanonicalFileName(useCaseSensitivefileNames: boolean): (fileName: string) => string; function createDocumentRegistry(useCaseSensitiveFileNames?: boolean): DocumentRegistry; - function preProcessFile(sourceText: string, readImportFiles?: boolean): PreProcessedFileInfo; + function preProcessFile(sourceText: string, readImportFiles?: boolean, detectJavaScriptImports?: boolean): PreProcessedFileInfo; function createLanguageService(host: LanguageServiceHost, documentRegistry?: DocumentRegistry): LanguageService; function createClassifier(): Classifier; /** diff --git a/lib/typescriptServices.js b/lib/typescriptServices.js index a1f9651570e..d261ce125fc 100644 --- a/lib/typescriptServices.js +++ b/lib/typescriptServices.js @@ -62,279 +62,281 @@ var ts; SyntaxKind[SyntaxKind["PlusToken"] = 35] = "PlusToken"; SyntaxKind[SyntaxKind["MinusToken"] = 36] = "MinusToken"; SyntaxKind[SyntaxKind["AsteriskToken"] = 37] = "AsteriskToken"; - SyntaxKind[SyntaxKind["SlashToken"] = 38] = "SlashToken"; - SyntaxKind[SyntaxKind["PercentToken"] = 39] = "PercentToken"; - SyntaxKind[SyntaxKind["PlusPlusToken"] = 40] = "PlusPlusToken"; - SyntaxKind[SyntaxKind["MinusMinusToken"] = 41] = "MinusMinusToken"; - SyntaxKind[SyntaxKind["LessThanLessThanToken"] = 42] = "LessThanLessThanToken"; - SyntaxKind[SyntaxKind["GreaterThanGreaterThanToken"] = 43] = "GreaterThanGreaterThanToken"; - SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanToken"] = 44] = "GreaterThanGreaterThanGreaterThanToken"; - SyntaxKind[SyntaxKind["AmpersandToken"] = 45] = "AmpersandToken"; - SyntaxKind[SyntaxKind["BarToken"] = 46] = "BarToken"; - SyntaxKind[SyntaxKind["CaretToken"] = 47] = "CaretToken"; - SyntaxKind[SyntaxKind["ExclamationToken"] = 48] = "ExclamationToken"; - SyntaxKind[SyntaxKind["TildeToken"] = 49] = "TildeToken"; - SyntaxKind[SyntaxKind["AmpersandAmpersandToken"] = 50] = "AmpersandAmpersandToken"; - SyntaxKind[SyntaxKind["BarBarToken"] = 51] = "BarBarToken"; - SyntaxKind[SyntaxKind["QuestionToken"] = 52] = "QuestionToken"; - SyntaxKind[SyntaxKind["ColonToken"] = 53] = "ColonToken"; - SyntaxKind[SyntaxKind["AtToken"] = 54] = "AtToken"; + SyntaxKind[SyntaxKind["AsteriskAsteriskToken"] = 38] = "AsteriskAsteriskToken"; + SyntaxKind[SyntaxKind["SlashToken"] = 39] = "SlashToken"; + SyntaxKind[SyntaxKind["PercentToken"] = 40] = "PercentToken"; + SyntaxKind[SyntaxKind["PlusPlusToken"] = 41] = "PlusPlusToken"; + SyntaxKind[SyntaxKind["MinusMinusToken"] = 42] = "MinusMinusToken"; + SyntaxKind[SyntaxKind["LessThanLessThanToken"] = 43] = "LessThanLessThanToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanToken"] = 44] = "GreaterThanGreaterThanToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanToken"] = 45] = "GreaterThanGreaterThanGreaterThanToken"; + SyntaxKind[SyntaxKind["AmpersandToken"] = 46] = "AmpersandToken"; + SyntaxKind[SyntaxKind["BarToken"] = 47] = "BarToken"; + SyntaxKind[SyntaxKind["CaretToken"] = 48] = "CaretToken"; + SyntaxKind[SyntaxKind["ExclamationToken"] = 49] = "ExclamationToken"; + SyntaxKind[SyntaxKind["TildeToken"] = 50] = "TildeToken"; + SyntaxKind[SyntaxKind["AmpersandAmpersandToken"] = 51] = "AmpersandAmpersandToken"; + SyntaxKind[SyntaxKind["BarBarToken"] = 52] = "BarBarToken"; + SyntaxKind[SyntaxKind["QuestionToken"] = 53] = "QuestionToken"; + SyntaxKind[SyntaxKind["ColonToken"] = 54] = "ColonToken"; + SyntaxKind[SyntaxKind["AtToken"] = 55] = "AtToken"; // Assignments - SyntaxKind[SyntaxKind["EqualsToken"] = 55] = "EqualsToken"; - SyntaxKind[SyntaxKind["PlusEqualsToken"] = 56] = "PlusEqualsToken"; - SyntaxKind[SyntaxKind["MinusEqualsToken"] = 57] = "MinusEqualsToken"; - SyntaxKind[SyntaxKind["AsteriskEqualsToken"] = 58] = "AsteriskEqualsToken"; - SyntaxKind[SyntaxKind["SlashEqualsToken"] = 59] = "SlashEqualsToken"; - SyntaxKind[SyntaxKind["PercentEqualsToken"] = 60] = "PercentEqualsToken"; - SyntaxKind[SyntaxKind["LessThanLessThanEqualsToken"] = 61] = "LessThanLessThanEqualsToken"; - SyntaxKind[SyntaxKind["GreaterThanGreaterThanEqualsToken"] = 62] = "GreaterThanGreaterThanEqualsToken"; - SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanEqualsToken"] = 63] = "GreaterThanGreaterThanGreaterThanEqualsToken"; - SyntaxKind[SyntaxKind["AmpersandEqualsToken"] = 64] = "AmpersandEqualsToken"; - SyntaxKind[SyntaxKind["BarEqualsToken"] = 65] = "BarEqualsToken"; - SyntaxKind[SyntaxKind["CaretEqualsToken"] = 66] = "CaretEqualsToken"; + SyntaxKind[SyntaxKind["EqualsToken"] = 56] = "EqualsToken"; + SyntaxKind[SyntaxKind["PlusEqualsToken"] = 57] = "PlusEqualsToken"; + SyntaxKind[SyntaxKind["MinusEqualsToken"] = 58] = "MinusEqualsToken"; + SyntaxKind[SyntaxKind["AsteriskEqualsToken"] = 59] = "AsteriskEqualsToken"; + SyntaxKind[SyntaxKind["AsteriskAsteriskEqualsToken"] = 60] = "AsteriskAsteriskEqualsToken"; + SyntaxKind[SyntaxKind["SlashEqualsToken"] = 61] = "SlashEqualsToken"; + SyntaxKind[SyntaxKind["PercentEqualsToken"] = 62] = "PercentEqualsToken"; + SyntaxKind[SyntaxKind["LessThanLessThanEqualsToken"] = 63] = "LessThanLessThanEqualsToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanEqualsToken"] = 64] = "GreaterThanGreaterThanEqualsToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanEqualsToken"] = 65] = "GreaterThanGreaterThanGreaterThanEqualsToken"; + SyntaxKind[SyntaxKind["AmpersandEqualsToken"] = 66] = "AmpersandEqualsToken"; + SyntaxKind[SyntaxKind["BarEqualsToken"] = 67] = "BarEqualsToken"; + SyntaxKind[SyntaxKind["CaretEqualsToken"] = 68] = "CaretEqualsToken"; // Identifiers - SyntaxKind[SyntaxKind["Identifier"] = 67] = "Identifier"; + SyntaxKind[SyntaxKind["Identifier"] = 69] = "Identifier"; // Reserved words - SyntaxKind[SyntaxKind["BreakKeyword"] = 68] = "BreakKeyword"; - SyntaxKind[SyntaxKind["CaseKeyword"] = 69] = "CaseKeyword"; - SyntaxKind[SyntaxKind["CatchKeyword"] = 70] = "CatchKeyword"; - SyntaxKind[SyntaxKind["ClassKeyword"] = 71] = "ClassKeyword"; - SyntaxKind[SyntaxKind["ConstKeyword"] = 72] = "ConstKeyword"; - SyntaxKind[SyntaxKind["ContinueKeyword"] = 73] = "ContinueKeyword"; - SyntaxKind[SyntaxKind["DebuggerKeyword"] = 74] = "DebuggerKeyword"; - SyntaxKind[SyntaxKind["DefaultKeyword"] = 75] = "DefaultKeyword"; - SyntaxKind[SyntaxKind["DeleteKeyword"] = 76] = "DeleteKeyword"; - SyntaxKind[SyntaxKind["DoKeyword"] = 77] = "DoKeyword"; - SyntaxKind[SyntaxKind["ElseKeyword"] = 78] = "ElseKeyword"; - SyntaxKind[SyntaxKind["EnumKeyword"] = 79] = "EnumKeyword"; - SyntaxKind[SyntaxKind["ExportKeyword"] = 80] = "ExportKeyword"; - SyntaxKind[SyntaxKind["ExtendsKeyword"] = 81] = "ExtendsKeyword"; - SyntaxKind[SyntaxKind["FalseKeyword"] = 82] = "FalseKeyword"; - SyntaxKind[SyntaxKind["FinallyKeyword"] = 83] = "FinallyKeyword"; - SyntaxKind[SyntaxKind["ForKeyword"] = 84] = "ForKeyword"; - SyntaxKind[SyntaxKind["FunctionKeyword"] = 85] = "FunctionKeyword"; - SyntaxKind[SyntaxKind["IfKeyword"] = 86] = "IfKeyword"; - SyntaxKind[SyntaxKind["ImportKeyword"] = 87] = "ImportKeyword"; - SyntaxKind[SyntaxKind["InKeyword"] = 88] = "InKeyword"; - SyntaxKind[SyntaxKind["InstanceOfKeyword"] = 89] = "InstanceOfKeyword"; - SyntaxKind[SyntaxKind["NewKeyword"] = 90] = "NewKeyword"; - SyntaxKind[SyntaxKind["NullKeyword"] = 91] = "NullKeyword"; - SyntaxKind[SyntaxKind["ReturnKeyword"] = 92] = "ReturnKeyword"; - SyntaxKind[SyntaxKind["SuperKeyword"] = 93] = "SuperKeyword"; - SyntaxKind[SyntaxKind["SwitchKeyword"] = 94] = "SwitchKeyword"; - SyntaxKind[SyntaxKind["ThisKeyword"] = 95] = "ThisKeyword"; - SyntaxKind[SyntaxKind["ThrowKeyword"] = 96] = "ThrowKeyword"; - SyntaxKind[SyntaxKind["TrueKeyword"] = 97] = "TrueKeyword"; - SyntaxKind[SyntaxKind["TryKeyword"] = 98] = "TryKeyword"; - SyntaxKind[SyntaxKind["TypeOfKeyword"] = 99] = "TypeOfKeyword"; - SyntaxKind[SyntaxKind["VarKeyword"] = 100] = "VarKeyword"; - SyntaxKind[SyntaxKind["VoidKeyword"] = 101] = "VoidKeyword"; - SyntaxKind[SyntaxKind["WhileKeyword"] = 102] = "WhileKeyword"; - SyntaxKind[SyntaxKind["WithKeyword"] = 103] = "WithKeyword"; + SyntaxKind[SyntaxKind["BreakKeyword"] = 70] = "BreakKeyword"; + SyntaxKind[SyntaxKind["CaseKeyword"] = 71] = "CaseKeyword"; + SyntaxKind[SyntaxKind["CatchKeyword"] = 72] = "CatchKeyword"; + SyntaxKind[SyntaxKind["ClassKeyword"] = 73] = "ClassKeyword"; + SyntaxKind[SyntaxKind["ConstKeyword"] = 74] = "ConstKeyword"; + SyntaxKind[SyntaxKind["ContinueKeyword"] = 75] = "ContinueKeyword"; + SyntaxKind[SyntaxKind["DebuggerKeyword"] = 76] = "DebuggerKeyword"; + SyntaxKind[SyntaxKind["DefaultKeyword"] = 77] = "DefaultKeyword"; + SyntaxKind[SyntaxKind["DeleteKeyword"] = 78] = "DeleteKeyword"; + SyntaxKind[SyntaxKind["DoKeyword"] = 79] = "DoKeyword"; + SyntaxKind[SyntaxKind["ElseKeyword"] = 80] = "ElseKeyword"; + SyntaxKind[SyntaxKind["EnumKeyword"] = 81] = "EnumKeyword"; + SyntaxKind[SyntaxKind["ExportKeyword"] = 82] = "ExportKeyword"; + SyntaxKind[SyntaxKind["ExtendsKeyword"] = 83] = "ExtendsKeyword"; + SyntaxKind[SyntaxKind["FalseKeyword"] = 84] = "FalseKeyword"; + SyntaxKind[SyntaxKind["FinallyKeyword"] = 85] = "FinallyKeyword"; + SyntaxKind[SyntaxKind["ForKeyword"] = 86] = "ForKeyword"; + SyntaxKind[SyntaxKind["FunctionKeyword"] = 87] = "FunctionKeyword"; + SyntaxKind[SyntaxKind["IfKeyword"] = 88] = "IfKeyword"; + SyntaxKind[SyntaxKind["ImportKeyword"] = 89] = "ImportKeyword"; + SyntaxKind[SyntaxKind["InKeyword"] = 90] = "InKeyword"; + SyntaxKind[SyntaxKind["InstanceOfKeyword"] = 91] = "InstanceOfKeyword"; + SyntaxKind[SyntaxKind["NewKeyword"] = 92] = "NewKeyword"; + SyntaxKind[SyntaxKind["NullKeyword"] = 93] = "NullKeyword"; + SyntaxKind[SyntaxKind["ReturnKeyword"] = 94] = "ReturnKeyword"; + SyntaxKind[SyntaxKind["SuperKeyword"] = 95] = "SuperKeyword"; + SyntaxKind[SyntaxKind["SwitchKeyword"] = 96] = "SwitchKeyword"; + SyntaxKind[SyntaxKind["ThisKeyword"] = 97] = "ThisKeyword"; + SyntaxKind[SyntaxKind["ThrowKeyword"] = 98] = "ThrowKeyword"; + SyntaxKind[SyntaxKind["TrueKeyword"] = 99] = "TrueKeyword"; + SyntaxKind[SyntaxKind["TryKeyword"] = 100] = "TryKeyword"; + SyntaxKind[SyntaxKind["TypeOfKeyword"] = 101] = "TypeOfKeyword"; + SyntaxKind[SyntaxKind["VarKeyword"] = 102] = "VarKeyword"; + SyntaxKind[SyntaxKind["VoidKeyword"] = 103] = "VoidKeyword"; + SyntaxKind[SyntaxKind["WhileKeyword"] = 104] = "WhileKeyword"; + SyntaxKind[SyntaxKind["WithKeyword"] = 105] = "WithKeyword"; // Strict mode reserved words - SyntaxKind[SyntaxKind["ImplementsKeyword"] = 104] = "ImplementsKeyword"; - SyntaxKind[SyntaxKind["InterfaceKeyword"] = 105] = "InterfaceKeyword"; - SyntaxKind[SyntaxKind["LetKeyword"] = 106] = "LetKeyword"; - SyntaxKind[SyntaxKind["PackageKeyword"] = 107] = "PackageKeyword"; - SyntaxKind[SyntaxKind["PrivateKeyword"] = 108] = "PrivateKeyword"; - SyntaxKind[SyntaxKind["ProtectedKeyword"] = 109] = "ProtectedKeyword"; - SyntaxKind[SyntaxKind["PublicKeyword"] = 110] = "PublicKeyword"; - SyntaxKind[SyntaxKind["StaticKeyword"] = 111] = "StaticKeyword"; - SyntaxKind[SyntaxKind["YieldKeyword"] = 112] = "YieldKeyword"; + SyntaxKind[SyntaxKind["ImplementsKeyword"] = 106] = "ImplementsKeyword"; + SyntaxKind[SyntaxKind["InterfaceKeyword"] = 107] = "InterfaceKeyword"; + SyntaxKind[SyntaxKind["LetKeyword"] = 108] = "LetKeyword"; + SyntaxKind[SyntaxKind["PackageKeyword"] = 109] = "PackageKeyword"; + SyntaxKind[SyntaxKind["PrivateKeyword"] = 110] = "PrivateKeyword"; + SyntaxKind[SyntaxKind["ProtectedKeyword"] = 111] = "ProtectedKeyword"; + SyntaxKind[SyntaxKind["PublicKeyword"] = 112] = "PublicKeyword"; + SyntaxKind[SyntaxKind["StaticKeyword"] = 113] = "StaticKeyword"; + SyntaxKind[SyntaxKind["YieldKeyword"] = 114] = "YieldKeyword"; // Contextual keywords - SyntaxKind[SyntaxKind["AbstractKeyword"] = 113] = "AbstractKeyword"; - SyntaxKind[SyntaxKind["AsKeyword"] = 114] = "AsKeyword"; - SyntaxKind[SyntaxKind["AnyKeyword"] = 115] = "AnyKeyword"; - SyntaxKind[SyntaxKind["AsyncKeyword"] = 116] = "AsyncKeyword"; - SyntaxKind[SyntaxKind["AwaitKeyword"] = 117] = "AwaitKeyword"; - SyntaxKind[SyntaxKind["BooleanKeyword"] = 118] = "BooleanKeyword"; - SyntaxKind[SyntaxKind["ConstructorKeyword"] = 119] = "ConstructorKeyword"; - SyntaxKind[SyntaxKind["DeclareKeyword"] = 120] = "DeclareKeyword"; - SyntaxKind[SyntaxKind["GetKeyword"] = 121] = "GetKeyword"; - SyntaxKind[SyntaxKind["IsKeyword"] = 122] = "IsKeyword"; - SyntaxKind[SyntaxKind["ModuleKeyword"] = 123] = "ModuleKeyword"; - SyntaxKind[SyntaxKind["NamespaceKeyword"] = 124] = "NamespaceKeyword"; - SyntaxKind[SyntaxKind["RequireKeyword"] = 125] = "RequireKeyword"; - SyntaxKind[SyntaxKind["NumberKeyword"] = 126] = "NumberKeyword"; - SyntaxKind[SyntaxKind["SetKeyword"] = 127] = "SetKeyword"; - SyntaxKind[SyntaxKind["StringKeyword"] = 128] = "StringKeyword"; - SyntaxKind[SyntaxKind["SymbolKeyword"] = 129] = "SymbolKeyword"; - SyntaxKind[SyntaxKind["TypeKeyword"] = 130] = "TypeKeyword"; - SyntaxKind[SyntaxKind["FromKeyword"] = 131] = "FromKeyword"; - SyntaxKind[SyntaxKind["OfKeyword"] = 132] = "OfKeyword"; + SyntaxKind[SyntaxKind["AbstractKeyword"] = 115] = "AbstractKeyword"; + SyntaxKind[SyntaxKind["AsKeyword"] = 116] = "AsKeyword"; + SyntaxKind[SyntaxKind["AnyKeyword"] = 117] = "AnyKeyword"; + SyntaxKind[SyntaxKind["AsyncKeyword"] = 118] = "AsyncKeyword"; + SyntaxKind[SyntaxKind["AwaitKeyword"] = 119] = "AwaitKeyword"; + SyntaxKind[SyntaxKind["BooleanKeyword"] = 120] = "BooleanKeyword"; + SyntaxKind[SyntaxKind["ConstructorKeyword"] = 121] = "ConstructorKeyword"; + SyntaxKind[SyntaxKind["DeclareKeyword"] = 122] = "DeclareKeyword"; + SyntaxKind[SyntaxKind["GetKeyword"] = 123] = "GetKeyword"; + SyntaxKind[SyntaxKind["IsKeyword"] = 124] = "IsKeyword"; + SyntaxKind[SyntaxKind["ModuleKeyword"] = 125] = "ModuleKeyword"; + SyntaxKind[SyntaxKind["NamespaceKeyword"] = 126] = "NamespaceKeyword"; + SyntaxKind[SyntaxKind["RequireKeyword"] = 127] = "RequireKeyword"; + SyntaxKind[SyntaxKind["NumberKeyword"] = 128] = "NumberKeyword"; + SyntaxKind[SyntaxKind["SetKeyword"] = 129] = "SetKeyword"; + SyntaxKind[SyntaxKind["StringKeyword"] = 130] = "StringKeyword"; + SyntaxKind[SyntaxKind["SymbolKeyword"] = 131] = "SymbolKeyword"; + SyntaxKind[SyntaxKind["TypeKeyword"] = 132] = "TypeKeyword"; + SyntaxKind[SyntaxKind["FromKeyword"] = 133] = "FromKeyword"; + SyntaxKind[SyntaxKind["OfKeyword"] = 134] = "OfKeyword"; // Parse tree nodes // Names - SyntaxKind[SyntaxKind["QualifiedName"] = 133] = "QualifiedName"; - SyntaxKind[SyntaxKind["ComputedPropertyName"] = 134] = "ComputedPropertyName"; + SyntaxKind[SyntaxKind["QualifiedName"] = 135] = "QualifiedName"; + SyntaxKind[SyntaxKind["ComputedPropertyName"] = 136] = "ComputedPropertyName"; // Signature elements - SyntaxKind[SyntaxKind["TypeParameter"] = 135] = "TypeParameter"; - SyntaxKind[SyntaxKind["Parameter"] = 136] = "Parameter"; - SyntaxKind[SyntaxKind["Decorator"] = 137] = "Decorator"; + SyntaxKind[SyntaxKind["TypeParameter"] = 137] = "TypeParameter"; + SyntaxKind[SyntaxKind["Parameter"] = 138] = "Parameter"; + SyntaxKind[SyntaxKind["Decorator"] = 139] = "Decorator"; // TypeMember - SyntaxKind[SyntaxKind["PropertySignature"] = 138] = "PropertySignature"; - SyntaxKind[SyntaxKind["PropertyDeclaration"] = 139] = "PropertyDeclaration"; - SyntaxKind[SyntaxKind["MethodSignature"] = 140] = "MethodSignature"; - SyntaxKind[SyntaxKind["MethodDeclaration"] = 141] = "MethodDeclaration"; - SyntaxKind[SyntaxKind["Constructor"] = 142] = "Constructor"; - SyntaxKind[SyntaxKind["GetAccessor"] = 143] = "GetAccessor"; - SyntaxKind[SyntaxKind["SetAccessor"] = 144] = "SetAccessor"; - SyntaxKind[SyntaxKind["CallSignature"] = 145] = "CallSignature"; - SyntaxKind[SyntaxKind["ConstructSignature"] = 146] = "ConstructSignature"; - SyntaxKind[SyntaxKind["IndexSignature"] = 147] = "IndexSignature"; + SyntaxKind[SyntaxKind["PropertySignature"] = 140] = "PropertySignature"; + SyntaxKind[SyntaxKind["PropertyDeclaration"] = 141] = "PropertyDeclaration"; + SyntaxKind[SyntaxKind["MethodSignature"] = 142] = "MethodSignature"; + SyntaxKind[SyntaxKind["MethodDeclaration"] = 143] = "MethodDeclaration"; + SyntaxKind[SyntaxKind["Constructor"] = 144] = "Constructor"; + SyntaxKind[SyntaxKind["GetAccessor"] = 145] = "GetAccessor"; + SyntaxKind[SyntaxKind["SetAccessor"] = 146] = "SetAccessor"; + SyntaxKind[SyntaxKind["CallSignature"] = 147] = "CallSignature"; + SyntaxKind[SyntaxKind["ConstructSignature"] = 148] = "ConstructSignature"; + SyntaxKind[SyntaxKind["IndexSignature"] = 149] = "IndexSignature"; // Type - SyntaxKind[SyntaxKind["TypePredicate"] = 148] = "TypePredicate"; - SyntaxKind[SyntaxKind["TypeReference"] = 149] = "TypeReference"; - SyntaxKind[SyntaxKind["FunctionType"] = 150] = "FunctionType"; - SyntaxKind[SyntaxKind["ConstructorType"] = 151] = "ConstructorType"; - SyntaxKind[SyntaxKind["TypeQuery"] = 152] = "TypeQuery"; - SyntaxKind[SyntaxKind["TypeLiteral"] = 153] = "TypeLiteral"; - SyntaxKind[SyntaxKind["ArrayType"] = 154] = "ArrayType"; - SyntaxKind[SyntaxKind["TupleType"] = 155] = "TupleType"; - SyntaxKind[SyntaxKind["UnionType"] = 156] = "UnionType"; - SyntaxKind[SyntaxKind["IntersectionType"] = 157] = "IntersectionType"; - SyntaxKind[SyntaxKind["ParenthesizedType"] = 158] = "ParenthesizedType"; + SyntaxKind[SyntaxKind["TypePredicate"] = 150] = "TypePredicate"; + SyntaxKind[SyntaxKind["TypeReference"] = 151] = "TypeReference"; + SyntaxKind[SyntaxKind["FunctionType"] = 152] = "FunctionType"; + SyntaxKind[SyntaxKind["ConstructorType"] = 153] = "ConstructorType"; + SyntaxKind[SyntaxKind["TypeQuery"] = 154] = "TypeQuery"; + SyntaxKind[SyntaxKind["TypeLiteral"] = 155] = "TypeLiteral"; + SyntaxKind[SyntaxKind["ArrayType"] = 156] = "ArrayType"; + SyntaxKind[SyntaxKind["TupleType"] = 157] = "TupleType"; + SyntaxKind[SyntaxKind["UnionType"] = 158] = "UnionType"; + SyntaxKind[SyntaxKind["IntersectionType"] = 159] = "IntersectionType"; + SyntaxKind[SyntaxKind["ParenthesizedType"] = 160] = "ParenthesizedType"; // Binding patterns - SyntaxKind[SyntaxKind["ObjectBindingPattern"] = 159] = "ObjectBindingPattern"; - SyntaxKind[SyntaxKind["ArrayBindingPattern"] = 160] = "ArrayBindingPattern"; - SyntaxKind[SyntaxKind["BindingElement"] = 161] = "BindingElement"; + SyntaxKind[SyntaxKind["ObjectBindingPattern"] = 161] = "ObjectBindingPattern"; + SyntaxKind[SyntaxKind["ArrayBindingPattern"] = 162] = "ArrayBindingPattern"; + SyntaxKind[SyntaxKind["BindingElement"] = 163] = "BindingElement"; // Expression - SyntaxKind[SyntaxKind["ArrayLiteralExpression"] = 162] = "ArrayLiteralExpression"; - SyntaxKind[SyntaxKind["ObjectLiteralExpression"] = 163] = "ObjectLiteralExpression"; - SyntaxKind[SyntaxKind["PropertyAccessExpression"] = 164] = "PropertyAccessExpression"; - SyntaxKind[SyntaxKind["ElementAccessExpression"] = 165] = "ElementAccessExpression"; - SyntaxKind[SyntaxKind["CallExpression"] = 166] = "CallExpression"; - SyntaxKind[SyntaxKind["NewExpression"] = 167] = "NewExpression"; - SyntaxKind[SyntaxKind["TaggedTemplateExpression"] = 168] = "TaggedTemplateExpression"; - SyntaxKind[SyntaxKind["TypeAssertionExpression"] = 169] = "TypeAssertionExpression"; - SyntaxKind[SyntaxKind["ParenthesizedExpression"] = 170] = "ParenthesizedExpression"; - SyntaxKind[SyntaxKind["FunctionExpression"] = 171] = "FunctionExpression"; - SyntaxKind[SyntaxKind["ArrowFunction"] = 172] = "ArrowFunction"; - SyntaxKind[SyntaxKind["DeleteExpression"] = 173] = "DeleteExpression"; - SyntaxKind[SyntaxKind["TypeOfExpression"] = 174] = "TypeOfExpression"; - SyntaxKind[SyntaxKind["VoidExpression"] = 175] = "VoidExpression"; - SyntaxKind[SyntaxKind["AwaitExpression"] = 176] = "AwaitExpression"; - SyntaxKind[SyntaxKind["PrefixUnaryExpression"] = 177] = "PrefixUnaryExpression"; - SyntaxKind[SyntaxKind["PostfixUnaryExpression"] = 178] = "PostfixUnaryExpression"; - SyntaxKind[SyntaxKind["BinaryExpression"] = 179] = "BinaryExpression"; - SyntaxKind[SyntaxKind["ConditionalExpression"] = 180] = "ConditionalExpression"; - SyntaxKind[SyntaxKind["TemplateExpression"] = 181] = "TemplateExpression"; - SyntaxKind[SyntaxKind["YieldExpression"] = 182] = "YieldExpression"; - SyntaxKind[SyntaxKind["SpreadElementExpression"] = 183] = "SpreadElementExpression"; - SyntaxKind[SyntaxKind["ClassExpression"] = 184] = "ClassExpression"; - SyntaxKind[SyntaxKind["OmittedExpression"] = 185] = "OmittedExpression"; - SyntaxKind[SyntaxKind["ExpressionWithTypeArguments"] = 186] = "ExpressionWithTypeArguments"; - SyntaxKind[SyntaxKind["AsExpression"] = 187] = "AsExpression"; + SyntaxKind[SyntaxKind["ArrayLiteralExpression"] = 164] = "ArrayLiteralExpression"; + SyntaxKind[SyntaxKind["ObjectLiteralExpression"] = 165] = "ObjectLiteralExpression"; + SyntaxKind[SyntaxKind["PropertyAccessExpression"] = 166] = "PropertyAccessExpression"; + SyntaxKind[SyntaxKind["ElementAccessExpression"] = 167] = "ElementAccessExpression"; + SyntaxKind[SyntaxKind["CallExpression"] = 168] = "CallExpression"; + SyntaxKind[SyntaxKind["NewExpression"] = 169] = "NewExpression"; + SyntaxKind[SyntaxKind["TaggedTemplateExpression"] = 170] = "TaggedTemplateExpression"; + SyntaxKind[SyntaxKind["TypeAssertionExpression"] = 171] = "TypeAssertionExpression"; + SyntaxKind[SyntaxKind["ParenthesizedExpression"] = 172] = "ParenthesizedExpression"; + SyntaxKind[SyntaxKind["FunctionExpression"] = 173] = "FunctionExpression"; + SyntaxKind[SyntaxKind["ArrowFunction"] = 174] = "ArrowFunction"; + SyntaxKind[SyntaxKind["DeleteExpression"] = 175] = "DeleteExpression"; + SyntaxKind[SyntaxKind["TypeOfExpression"] = 176] = "TypeOfExpression"; + SyntaxKind[SyntaxKind["VoidExpression"] = 177] = "VoidExpression"; + SyntaxKind[SyntaxKind["AwaitExpression"] = 178] = "AwaitExpression"; + SyntaxKind[SyntaxKind["PrefixUnaryExpression"] = 179] = "PrefixUnaryExpression"; + SyntaxKind[SyntaxKind["PostfixUnaryExpression"] = 180] = "PostfixUnaryExpression"; + SyntaxKind[SyntaxKind["BinaryExpression"] = 181] = "BinaryExpression"; + SyntaxKind[SyntaxKind["ConditionalExpression"] = 182] = "ConditionalExpression"; + SyntaxKind[SyntaxKind["TemplateExpression"] = 183] = "TemplateExpression"; + SyntaxKind[SyntaxKind["YieldExpression"] = 184] = "YieldExpression"; + SyntaxKind[SyntaxKind["SpreadElementExpression"] = 185] = "SpreadElementExpression"; + SyntaxKind[SyntaxKind["ClassExpression"] = 186] = "ClassExpression"; + SyntaxKind[SyntaxKind["OmittedExpression"] = 187] = "OmittedExpression"; + SyntaxKind[SyntaxKind["ExpressionWithTypeArguments"] = 188] = "ExpressionWithTypeArguments"; + SyntaxKind[SyntaxKind["AsExpression"] = 189] = "AsExpression"; // Misc - SyntaxKind[SyntaxKind["TemplateSpan"] = 188] = "TemplateSpan"; - SyntaxKind[SyntaxKind["SemicolonClassElement"] = 189] = "SemicolonClassElement"; + SyntaxKind[SyntaxKind["TemplateSpan"] = 190] = "TemplateSpan"; + SyntaxKind[SyntaxKind["SemicolonClassElement"] = 191] = "SemicolonClassElement"; // Element - SyntaxKind[SyntaxKind["Block"] = 190] = "Block"; - SyntaxKind[SyntaxKind["VariableStatement"] = 191] = "VariableStatement"; - SyntaxKind[SyntaxKind["EmptyStatement"] = 192] = "EmptyStatement"; - SyntaxKind[SyntaxKind["ExpressionStatement"] = 193] = "ExpressionStatement"; - SyntaxKind[SyntaxKind["IfStatement"] = 194] = "IfStatement"; - SyntaxKind[SyntaxKind["DoStatement"] = 195] = "DoStatement"; - SyntaxKind[SyntaxKind["WhileStatement"] = 196] = "WhileStatement"; - SyntaxKind[SyntaxKind["ForStatement"] = 197] = "ForStatement"; - SyntaxKind[SyntaxKind["ForInStatement"] = 198] = "ForInStatement"; - SyntaxKind[SyntaxKind["ForOfStatement"] = 199] = "ForOfStatement"; - SyntaxKind[SyntaxKind["ContinueStatement"] = 200] = "ContinueStatement"; - SyntaxKind[SyntaxKind["BreakStatement"] = 201] = "BreakStatement"; - SyntaxKind[SyntaxKind["ReturnStatement"] = 202] = "ReturnStatement"; - SyntaxKind[SyntaxKind["WithStatement"] = 203] = "WithStatement"; - SyntaxKind[SyntaxKind["SwitchStatement"] = 204] = "SwitchStatement"; - SyntaxKind[SyntaxKind["LabeledStatement"] = 205] = "LabeledStatement"; - SyntaxKind[SyntaxKind["ThrowStatement"] = 206] = "ThrowStatement"; - SyntaxKind[SyntaxKind["TryStatement"] = 207] = "TryStatement"; - SyntaxKind[SyntaxKind["DebuggerStatement"] = 208] = "DebuggerStatement"; - SyntaxKind[SyntaxKind["VariableDeclaration"] = 209] = "VariableDeclaration"; - SyntaxKind[SyntaxKind["VariableDeclarationList"] = 210] = "VariableDeclarationList"; - SyntaxKind[SyntaxKind["FunctionDeclaration"] = 211] = "FunctionDeclaration"; - SyntaxKind[SyntaxKind["ClassDeclaration"] = 212] = "ClassDeclaration"; - SyntaxKind[SyntaxKind["InterfaceDeclaration"] = 213] = "InterfaceDeclaration"; - SyntaxKind[SyntaxKind["TypeAliasDeclaration"] = 214] = "TypeAliasDeclaration"; - SyntaxKind[SyntaxKind["EnumDeclaration"] = 215] = "EnumDeclaration"; - SyntaxKind[SyntaxKind["ModuleDeclaration"] = 216] = "ModuleDeclaration"; - SyntaxKind[SyntaxKind["ModuleBlock"] = 217] = "ModuleBlock"; - SyntaxKind[SyntaxKind["CaseBlock"] = 218] = "CaseBlock"; - SyntaxKind[SyntaxKind["ImportEqualsDeclaration"] = 219] = "ImportEqualsDeclaration"; - SyntaxKind[SyntaxKind["ImportDeclaration"] = 220] = "ImportDeclaration"; - SyntaxKind[SyntaxKind["ImportClause"] = 221] = "ImportClause"; - SyntaxKind[SyntaxKind["NamespaceImport"] = 222] = "NamespaceImport"; - SyntaxKind[SyntaxKind["NamedImports"] = 223] = "NamedImports"; - SyntaxKind[SyntaxKind["ImportSpecifier"] = 224] = "ImportSpecifier"; - SyntaxKind[SyntaxKind["ExportAssignment"] = 225] = "ExportAssignment"; - SyntaxKind[SyntaxKind["ExportDeclaration"] = 226] = "ExportDeclaration"; - SyntaxKind[SyntaxKind["NamedExports"] = 227] = "NamedExports"; - SyntaxKind[SyntaxKind["ExportSpecifier"] = 228] = "ExportSpecifier"; - SyntaxKind[SyntaxKind["MissingDeclaration"] = 229] = "MissingDeclaration"; + SyntaxKind[SyntaxKind["Block"] = 192] = "Block"; + SyntaxKind[SyntaxKind["VariableStatement"] = 193] = "VariableStatement"; + SyntaxKind[SyntaxKind["EmptyStatement"] = 194] = "EmptyStatement"; + SyntaxKind[SyntaxKind["ExpressionStatement"] = 195] = "ExpressionStatement"; + SyntaxKind[SyntaxKind["IfStatement"] = 196] = "IfStatement"; + SyntaxKind[SyntaxKind["DoStatement"] = 197] = "DoStatement"; + SyntaxKind[SyntaxKind["WhileStatement"] = 198] = "WhileStatement"; + SyntaxKind[SyntaxKind["ForStatement"] = 199] = "ForStatement"; + SyntaxKind[SyntaxKind["ForInStatement"] = 200] = "ForInStatement"; + SyntaxKind[SyntaxKind["ForOfStatement"] = 201] = "ForOfStatement"; + SyntaxKind[SyntaxKind["ContinueStatement"] = 202] = "ContinueStatement"; + SyntaxKind[SyntaxKind["BreakStatement"] = 203] = "BreakStatement"; + SyntaxKind[SyntaxKind["ReturnStatement"] = 204] = "ReturnStatement"; + SyntaxKind[SyntaxKind["WithStatement"] = 205] = "WithStatement"; + SyntaxKind[SyntaxKind["SwitchStatement"] = 206] = "SwitchStatement"; + SyntaxKind[SyntaxKind["LabeledStatement"] = 207] = "LabeledStatement"; + SyntaxKind[SyntaxKind["ThrowStatement"] = 208] = "ThrowStatement"; + SyntaxKind[SyntaxKind["TryStatement"] = 209] = "TryStatement"; + SyntaxKind[SyntaxKind["DebuggerStatement"] = 210] = "DebuggerStatement"; + SyntaxKind[SyntaxKind["VariableDeclaration"] = 211] = "VariableDeclaration"; + SyntaxKind[SyntaxKind["VariableDeclarationList"] = 212] = "VariableDeclarationList"; + SyntaxKind[SyntaxKind["FunctionDeclaration"] = 213] = "FunctionDeclaration"; + SyntaxKind[SyntaxKind["ClassDeclaration"] = 214] = "ClassDeclaration"; + SyntaxKind[SyntaxKind["InterfaceDeclaration"] = 215] = "InterfaceDeclaration"; + SyntaxKind[SyntaxKind["TypeAliasDeclaration"] = 216] = "TypeAliasDeclaration"; + SyntaxKind[SyntaxKind["EnumDeclaration"] = 217] = "EnumDeclaration"; + SyntaxKind[SyntaxKind["ModuleDeclaration"] = 218] = "ModuleDeclaration"; + SyntaxKind[SyntaxKind["ModuleBlock"] = 219] = "ModuleBlock"; + SyntaxKind[SyntaxKind["CaseBlock"] = 220] = "CaseBlock"; + SyntaxKind[SyntaxKind["ImportEqualsDeclaration"] = 221] = "ImportEqualsDeclaration"; + SyntaxKind[SyntaxKind["ImportDeclaration"] = 222] = "ImportDeclaration"; + SyntaxKind[SyntaxKind["ImportClause"] = 223] = "ImportClause"; + SyntaxKind[SyntaxKind["NamespaceImport"] = 224] = "NamespaceImport"; + SyntaxKind[SyntaxKind["NamedImports"] = 225] = "NamedImports"; + SyntaxKind[SyntaxKind["ImportSpecifier"] = 226] = "ImportSpecifier"; + SyntaxKind[SyntaxKind["ExportAssignment"] = 227] = "ExportAssignment"; + SyntaxKind[SyntaxKind["ExportDeclaration"] = 228] = "ExportDeclaration"; + SyntaxKind[SyntaxKind["NamedExports"] = 229] = "NamedExports"; + SyntaxKind[SyntaxKind["ExportSpecifier"] = 230] = "ExportSpecifier"; + SyntaxKind[SyntaxKind["MissingDeclaration"] = 231] = "MissingDeclaration"; // Module references - SyntaxKind[SyntaxKind["ExternalModuleReference"] = 230] = "ExternalModuleReference"; + SyntaxKind[SyntaxKind["ExternalModuleReference"] = 232] = "ExternalModuleReference"; // JSX - SyntaxKind[SyntaxKind["JsxElement"] = 231] = "JsxElement"; - SyntaxKind[SyntaxKind["JsxSelfClosingElement"] = 232] = "JsxSelfClosingElement"; - SyntaxKind[SyntaxKind["JsxOpeningElement"] = 233] = "JsxOpeningElement"; - SyntaxKind[SyntaxKind["JsxText"] = 234] = "JsxText"; - SyntaxKind[SyntaxKind["JsxClosingElement"] = 235] = "JsxClosingElement"; - SyntaxKind[SyntaxKind["JsxAttribute"] = 236] = "JsxAttribute"; - SyntaxKind[SyntaxKind["JsxSpreadAttribute"] = 237] = "JsxSpreadAttribute"; - SyntaxKind[SyntaxKind["JsxExpression"] = 238] = "JsxExpression"; + SyntaxKind[SyntaxKind["JsxElement"] = 233] = "JsxElement"; + SyntaxKind[SyntaxKind["JsxSelfClosingElement"] = 234] = "JsxSelfClosingElement"; + SyntaxKind[SyntaxKind["JsxOpeningElement"] = 235] = "JsxOpeningElement"; + SyntaxKind[SyntaxKind["JsxText"] = 236] = "JsxText"; + SyntaxKind[SyntaxKind["JsxClosingElement"] = 237] = "JsxClosingElement"; + SyntaxKind[SyntaxKind["JsxAttribute"] = 238] = "JsxAttribute"; + SyntaxKind[SyntaxKind["JsxSpreadAttribute"] = 239] = "JsxSpreadAttribute"; + SyntaxKind[SyntaxKind["JsxExpression"] = 240] = "JsxExpression"; // Clauses - SyntaxKind[SyntaxKind["CaseClause"] = 239] = "CaseClause"; - SyntaxKind[SyntaxKind["DefaultClause"] = 240] = "DefaultClause"; - SyntaxKind[SyntaxKind["HeritageClause"] = 241] = "HeritageClause"; - SyntaxKind[SyntaxKind["CatchClause"] = 242] = "CatchClause"; + SyntaxKind[SyntaxKind["CaseClause"] = 241] = "CaseClause"; + SyntaxKind[SyntaxKind["DefaultClause"] = 242] = "DefaultClause"; + SyntaxKind[SyntaxKind["HeritageClause"] = 243] = "HeritageClause"; + SyntaxKind[SyntaxKind["CatchClause"] = 244] = "CatchClause"; // Property assignments - SyntaxKind[SyntaxKind["PropertyAssignment"] = 243] = "PropertyAssignment"; - SyntaxKind[SyntaxKind["ShorthandPropertyAssignment"] = 244] = "ShorthandPropertyAssignment"; + SyntaxKind[SyntaxKind["PropertyAssignment"] = 245] = "PropertyAssignment"; + SyntaxKind[SyntaxKind["ShorthandPropertyAssignment"] = 246] = "ShorthandPropertyAssignment"; // Enum - SyntaxKind[SyntaxKind["EnumMember"] = 245] = "EnumMember"; + SyntaxKind[SyntaxKind["EnumMember"] = 247] = "EnumMember"; // Top-level nodes - SyntaxKind[SyntaxKind["SourceFile"] = 246] = "SourceFile"; + SyntaxKind[SyntaxKind["SourceFile"] = 248] = "SourceFile"; // JSDoc nodes. - SyntaxKind[SyntaxKind["JSDocTypeExpression"] = 247] = "JSDocTypeExpression"; + SyntaxKind[SyntaxKind["JSDocTypeExpression"] = 249] = "JSDocTypeExpression"; // The * type. - SyntaxKind[SyntaxKind["JSDocAllType"] = 248] = "JSDocAllType"; + SyntaxKind[SyntaxKind["JSDocAllType"] = 250] = "JSDocAllType"; // The ? type. - SyntaxKind[SyntaxKind["JSDocUnknownType"] = 249] = "JSDocUnknownType"; - SyntaxKind[SyntaxKind["JSDocArrayType"] = 250] = "JSDocArrayType"; - SyntaxKind[SyntaxKind["JSDocUnionType"] = 251] = "JSDocUnionType"; - SyntaxKind[SyntaxKind["JSDocTupleType"] = 252] = "JSDocTupleType"; - SyntaxKind[SyntaxKind["JSDocNullableType"] = 253] = "JSDocNullableType"; - SyntaxKind[SyntaxKind["JSDocNonNullableType"] = 254] = "JSDocNonNullableType"; - SyntaxKind[SyntaxKind["JSDocRecordType"] = 255] = "JSDocRecordType"; - SyntaxKind[SyntaxKind["JSDocRecordMember"] = 256] = "JSDocRecordMember"; - SyntaxKind[SyntaxKind["JSDocTypeReference"] = 257] = "JSDocTypeReference"; - SyntaxKind[SyntaxKind["JSDocOptionalType"] = 258] = "JSDocOptionalType"; - SyntaxKind[SyntaxKind["JSDocFunctionType"] = 259] = "JSDocFunctionType"; - SyntaxKind[SyntaxKind["JSDocVariadicType"] = 260] = "JSDocVariadicType"; - SyntaxKind[SyntaxKind["JSDocConstructorType"] = 261] = "JSDocConstructorType"; - SyntaxKind[SyntaxKind["JSDocThisType"] = 262] = "JSDocThisType"; - SyntaxKind[SyntaxKind["JSDocComment"] = 263] = "JSDocComment"; - SyntaxKind[SyntaxKind["JSDocTag"] = 264] = "JSDocTag"; - SyntaxKind[SyntaxKind["JSDocParameterTag"] = 265] = "JSDocParameterTag"; - SyntaxKind[SyntaxKind["JSDocReturnTag"] = 266] = "JSDocReturnTag"; - SyntaxKind[SyntaxKind["JSDocTypeTag"] = 267] = "JSDocTypeTag"; - SyntaxKind[SyntaxKind["JSDocTemplateTag"] = 268] = "JSDocTemplateTag"; + SyntaxKind[SyntaxKind["JSDocUnknownType"] = 251] = "JSDocUnknownType"; + SyntaxKind[SyntaxKind["JSDocArrayType"] = 252] = "JSDocArrayType"; + SyntaxKind[SyntaxKind["JSDocUnionType"] = 253] = "JSDocUnionType"; + SyntaxKind[SyntaxKind["JSDocTupleType"] = 254] = "JSDocTupleType"; + SyntaxKind[SyntaxKind["JSDocNullableType"] = 255] = "JSDocNullableType"; + SyntaxKind[SyntaxKind["JSDocNonNullableType"] = 256] = "JSDocNonNullableType"; + SyntaxKind[SyntaxKind["JSDocRecordType"] = 257] = "JSDocRecordType"; + SyntaxKind[SyntaxKind["JSDocRecordMember"] = 258] = "JSDocRecordMember"; + SyntaxKind[SyntaxKind["JSDocTypeReference"] = 259] = "JSDocTypeReference"; + SyntaxKind[SyntaxKind["JSDocOptionalType"] = 260] = "JSDocOptionalType"; + SyntaxKind[SyntaxKind["JSDocFunctionType"] = 261] = "JSDocFunctionType"; + SyntaxKind[SyntaxKind["JSDocVariadicType"] = 262] = "JSDocVariadicType"; + SyntaxKind[SyntaxKind["JSDocConstructorType"] = 263] = "JSDocConstructorType"; + SyntaxKind[SyntaxKind["JSDocThisType"] = 264] = "JSDocThisType"; + SyntaxKind[SyntaxKind["JSDocComment"] = 265] = "JSDocComment"; + SyntaxKind[SyntaxKind["JSDocTag"] = 266] = "JSDocTag"; + SyntaxKind[SyntaxKind["JSDocParameterTag"] = 267] = "JSDocParameterTag"; + SyntaxKind[SyntaxKind["JSDocReturnTag"] = 268] = "JSDocReturnTag"; + SyntaxKind[SyntaxKind["JSDocTypeTag"] = 269] = "JSDocTypeTag"; + SyntaxKind[SyntaxKind["JSDocTemplateTag"] = 270] = "JSDocTemplateTag"; // Synthesized list - SyntaxKind[SyntaxKind["SyntaxList"] = 269] = "SyntaxList"; + SyntaxKind[SyntaxKind["SyntaxList"] = 271] = "SyntaxList"; // Enum value count - SyntaxKind[SyntaxKind["Count"] = 270] = "Count"; + SyntaxKind[SyntaxKind["Count"] = 272] = "Count"; // Markers - SyntaxKind[SyntaxKind["FirstAssignment"] = 55] = "FirstAssignment"; - SyntaxKind[SyntaxKind["LastAssignment"] = 66] = "LastAssignment"; - SyntaxKind[SyntaxKind["FirstReservedWord"] = 68] = "FirstReservedWord"; - SyntaxKind[SyntaxKind["LastReservedWord"] = 103] = "LastReservedWord"; - SyntaxKind[SyntaxKind["FirstKeyword"] = 68] = "FirstKeyword"; - SyntaxKind[SyntaxKind["LastKeyword"] = 132] = "LastKeyword"; - SyntaxKind[SyntaxKind["FirstFutureReservedWord"] = 104] = "FirstFutureReservedWord"; - SyntaxKind[SyntaxKind["LastFutureReservedWord"] = 112] = "LastFutureReservedWord"; - SyntaxKind[SyntaxKind["FirstTypeNode"] = 149] = "FirstTypeNode"; - SyntaxKind[SyntaxKind["LastTypeNode"] = 158] = "LastTypeNode"; + SyntaxKind[SyntaxKind["FirstAssignment"] = 56] = "FirstAssignment"; + SyntaxKind[SyntaxKind["LastAssignment"] = 68] = "LastAssignment"; + SyntaxKind[SyntaxKind["FirstReservedWord"] = 70] = "FirstReservedWord"; + SyntaxKind[SyntaxKind["LastReservedWord"] = 105] = "LastReservedWord"; + SyntaxKind[SyntaxKind["FirstKeyword"] = 70] = "FirstKeyword"; + SyntaxKind[SyntaxKind["LastKeyword"] = 134] = "LastKeyword"; + SyntaxKind[SyntaxKind["FirstFutureReservedWord"] = 106] = "FirstFutureReservedWord"; + SyntaxKind[SyntaxKind["LastFutureReservedWord"] = 114] = "LastFutureReservedWord"; + SyntaxKind[SyntaxKind["FirstTypeNode"] = 151] = "FirstTypeNode"; + SyntaxKind[SyntaxKind["LastTypeNode"] = 160] = "LastTypeNode"; SyntaxKind[SyntaxKind["FirstPunctuation"] = 15] = "FirstPunctuation"; - SyntaxKind[SyntaxKind["LastPunctuation"] = 66] = "LastPunctuation"; + SyntaxKind[SyntaxKind["LastPunctuation"] = 68] = "LastPunctuation"; SyntaxKind[SyntaxKind["FirstToken"] = 0] = "FirstToken"; - SyntaxKind[SyntaxKind["LastToken"] = 132] = "LastToken"; + SyntaxKind[SyntaxKind["LastToken"] = 134] = "LastToken"; SyntaxKind[SyntaxKind["FirstTriviaToken"] = 2] = "FirstTriviaToken"; SyntaxKind[SyntaxKind["LastTriviaToken"] = 7] = "LastTriviaToken"; SyntaxKind[SyntaxKind["FirstLiteralToken"] = 8] = "FirstLiteralToken"; @@ -342,8 +344,8 @@ var ts; SyntaxKind[SyntaxKind["FirstTemplateToken"] = 11] = "FirstTemplateToken"; SyntaxKind[SyntaxKind["LastTemplateToken"] = 14] = "LastTemplateToken"; SyntaxKind[SyntaxKind["FirstBinaryOperator"] = 25] = "FirstBinaryOperator"; - SyntaxKind[SyntaxKind["LastBinaryOperator"] = 66] = "LastBinaryOperator"; - SyntaxKind[SyntaxKind["FirstNode"] = 133] = "FirstNode"; + SyntaxKind[SyntaxKind["LastBinaryOperator"] = 68] = "LastBinaryOperator"; + SyntaxKind[SyntaxKind["FirstNode"] = 135] = "FirstNode"; })(ts.SyntaxKind || (ts.SyntaxKind = {})); var SyntaxKind = ts.SyntaxKind; (function (NodeFlags) { @@ -364,6 +366,7 @@ var ts; NodeFlags[NodeFlags["OctalLiteral"] = 65536] = "OctalLiteral"; NodeFlags[NodeFlags["Namespace"] = 131072] = "Namespace"; NodeFlags[NodeFlags["ExportContext"] = 262144] = "ExportContext"; + NodeFlags[NodeFlags["ContainsThis"] = 524288] = "ContainsThis"; NodeFlags[NodeFlags["Modifier"] = 2035] = "Modifier"; NodeFlags[NodeFlags["AccessibilityModifier"] = 112] = "AccessibilityModifier"; NodeFlags[NodeFlags["BlockScoped"] = 49152] = "BlockScoped"; @@ -613,6 +616,7 @@ var ts; /* @internal */ TypeFlags[TypeFlags["ContainsAnyFunctionType"] = 8388608] = "ContainsAnyFunctionType"; TypeFlags[TypeFlags["ESSymbol"] = 16777216] = "ESSymbol"; + TypeFlags[TypeFlags["ThisType"] = 33554432] = "ThisType"; /* @internal */ TypeFlags[TypeFlags["Intrinsic"] = 16777343] = "Intrinsic"; /* @internal */ @@ -655,6 +659,7 @@ var ts; ModuleKind[ModuleKind["AMD"] = 2] = "AMD"; ModuleKind[ModuleKind["UMD"] = 3] = "UMD"; ModuleKind[ModuleKind["System"] = 4] = "System"; + ModuleKind[ModuleKind["ES6"] = 5] = "ES6"; })(ts.ModuleKind || (ts.ModuleKind = {})); var ModuleKind = ts.ModuleKind; (function (JsxEmit) { @@ -1221,8 +1226,11 @@ var ts; } ts.chainDiagnosticMessages = chainDiagnosticMessages; function concatenateDiagnosticMessageChains(headChain, tailChain) { - Debug.assert(!headChain.next); - headChain.next = tailChain; + var lastChain = headChain; + while (lastChain.next) { + lastChain = lastChain.next; + } + lastChain.next = tailChain; return headChain; } ts.concatenateDiagnosticMessageChains = concatenateDiagnosticMessageChains; @@ -1496,6 +1504,7 @@ var ts; * List of supported extensions in order of file resolution precedence. */ ts.supportedExtensions = [".ts", ".tsx", ".d.ts"]; + ts.supportedJsExtensions = ts.supportedExtensions.concat(".js", ".jsx"); var extensionsToRemove = [".d.ts", ".ts", ".js", ".tsx", ".jsx"]; function removeFileExtension(path) { for (var _i = 0; _i < extensionsToRemove.length; _i++) { @@ -1819,10 +1828,15 @@ var ts; close: function () { _fs.unwatchFile(fileName, fileChanged); } }; function fileChanged(curr, prev) { + // mtime.getTime() equals 0 if file was removed + if (curr.mtime.getTime() === 0) { + callback(fileName, /* removed */ true); + return; + } if (+curr.mtime <= +prev.mtime) { return; } - callback(fileName); + callback(fileName, /* removed */ false); } }, resolvePath: function (path) { @@ -1925,7 +1939,7 @@ var ts; Enum_member_must_have_initializer: { code: 1061, category: ts.DiagnosticCategory.Error, key: "Enum member must have initializer." }, _0_is_referenced_directly_or_indirectly_in_the_fulfillment_callback_of_its_own_then_method: { code: 1062, category: ts.DiagnosticCategory.Error, key: "{0} is referenced directly or indirectly in the fulfillment callback of its own 'then' method." }, An_export_assignment_cannot_be_used_in_a_namespace: { code: 1063, category: ts.DiagnosticCategory.Error, key: "An export assignment cannot be used in a namespace." }, - Ambient_enum_elements_can_only_have_integer_literal_initializers: { code: 1066, category: ts.DiagnosticCategory.Error, key: "Ambient enum elements can only have integer literal initializers." }, + In_ambient_enum_declarations_member_initializer_must_be_constant_expression: { code: 1066, category: ts.DiagnosticCategory.Error, key: "In ambient enum declarations member initializer must be constant expression." }, Unexpected_token_A_constructor_method_accessor_or_property_was_expected: { code: 1068, category: ts.DiagnosticCategory.Error, key: "Unexpected token. A constructor, method, accessor, or property was expected." }, A_0_modifier_cannot_be_used_with_an_import_declaration: { code: 1079, category: ts.DiagnosticCategory.Error, key: "A '{0}' modifier cannot be used with an import declaration." }, Invalid_reference_directive_syntax: { code: 1084, category: ts.DiagnosticCategory.Error, key: "Invalid 'reference' directive syntax." }, @@ -2013,7 +2027,7 @@ var ts; Property_destructuring_pattern_expected: { code: 1180, category: ts.DiagnosticCategory.Error, key: "Property destructuring pattern expected." }, Array_element_destructuring_pattern_expected: { code: 1181, category: ts.DiagnosticCategory.Error, key: "Array element destructuring pattern expected." }, A_destructuring_declaration_must_have_an_initializer: { code: 1182, category: ts.DiagnosticCategory.Error, key: "A destructuring declaration must have an initializer." }, - An_implementation_cannot_be_declared_in_ambient_contexts: { code: 1184, category: ts.DiagnosticCategory.Error, key: "An implementation cannot be declared in ambient contexts." }, + An_implementation_cannot_be_declared_in_ambient_contexts: { code: 1183, category: ts.DiagnosticCategory.Error, key: "An implementation cannot be declared in ambient contexts." }, Modifiers_cannot_appear_here: { code: 1184, category: ts.DiagnosticCategory.Error, key: "Modifiers cannot appear here." }, Merge_conflict_marker_encountered: { code: 1185, category: ts.DiagnosticCategory.Error, key: "Merge conflict marker encountered." }, A_rest_element_cannot_have_an_initializer: { code: 1186, category: ts.DiagnosticCategory.Error, key: "A rest element cannot have an initializer." }, @@ -2031,10 +2045,9 @@ var ts; An_extended_Unicode_escape_value_must_be_between_0x0_and_0x10FFFF_inclusive: { code: 1198, category: ts.DiagnosticCategory.Error, key: "An extended Unicode escape value must be between 0x0 and 0x10FFFF inclusive." }, Unterminated_Unicode_escape_sequence: { code: 1199, category: ts.DiagnosticCategory.Error, key: "Unterminated Unicode escape sequence." }, Line_terminator_not_permitted_before_arrow: { code: 1200, category: ts.DiagnosticCategory.Error, key: "Line terminator not permitted before arrow." }, - Import_assignment_cannot_be_used_when_targeting_ECMAScript_6_or_higher_Consider_using_import_Asterisk_as_ns_from_mod_import_a_from_mod_or_import_d_from_mod_instead: { code: 1202, category: ts.DiagnosticCategory.Error, key: "Import assignment cannot be used when targeting ECMAScript 6 or higher. Consider using 'import * as ns from \"mod\"', 'import {a} from \"mod\"' or 'import d from \"mod\"' instead." }, - Export_assignment_cannot_be_used_when_targeting_ECMAScript_6_or_higher_Consider_using_export_default_instead: { code: 1203, category: ts.DiagnosticCategory.Error, key: "Export assignment cannot be used when targeting ECMAScript 6 or higher. Consider using 'export default' instead." }, - Cannot_compile_modules_into_commonjs_amd_system_or_umd_when_targeting_ES6_or_higher: { code: 1204, category: ts.DiagnosticCategory.Error, key: "Cannot compile modules into 'commonjs', 'amd', 'system' or 'umd' when targeting 'ES6' or higher." }, - Decorators_are_only_available_when_targeting_ECMAScript_5_and_higher: { code: 1205, category: ts.DiagnosticCategory.Error, key: "Decorators are only available when targeting ECMAScript 5 and higher." }, + Import_assignment_cannot_be_used_when_targeting_ECMAScript_6_modules_Consider_using_import_Asterisk_as_ns_from_mod_import_a_from_mod_import_d_from_mod_or_another_module_format_instead: { code: 1202, category: ts.DiagnosticCategory.Error, key: "Import assignment cannot be used when targeting ECMAScript 6 modules. Consider using 'import * as ns from \"mod\"', 'import {a} from \"mod\"', 'import d from \"mod\"', or another module format instead." }, + Export_assignment_cannot_be_used_when_targeting_ECMAScript_6_modules_Consider_using_export_default_or_another_module_format_instead: { code: 1203, category: ts.DiagnosticCategory.Error, key: "Export assignment cannot be used when targeting ECMAScript 6 modules. Consider using 'export default' or another module format instead." }, + Cannot_compile_modules_into_es6_when_targeting_ES5_or_lower: { code: 1204, category: ts.DiagnosticCategory.Error, key: "Cannot compile modules into 'es6' when targeting 'ES5' or lower." }, Decorators_are_not_valid_here: { code: 1206, category: ts.DiagnosticCategory.Error, key: "Decorators are not valid here." }, Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name: { code: 1207, category: ts.DiagnosticCategory.Error, key: "Decorators cannot be applied to multiple get/set accessors of the same name." }, Cannot_compile_namespaces_when_the_isolatedModules_flag_is_provided: { code: 1208, category: ts.DiagnosticCategory.Error, key: "Cannot compile namespaces when the '--isolatedModules' flag is provided." }, @@ -2063,10 +2076,6 @@ var ts; An_export_declaration_can_only_be_used_in_a_module: { code: 1233, category: ts.DiagnosticCategory.Error, key: "An export declaration can only be used in a module." }, An_ambient_module_declaration_is_only_allowed_at_the_top_level_in_a_file: { code: 1234, category: ts.DiagnosticCategory.Error, key: "An ambient module declaration is only allowed at the top level in a file." }, A_namespace_declaration_is_only_allowed_in_a_namespace_or_module: { code: 1235, category: ts.DiagnosticCategory.Error, key: "A namespace declaration is only allowed in a namespace or module." }, - Experimental_support_for_async_functions_is_a_feature_that_is_subject_to_change_in_a_future_release_Specify_experimentalAsyncFunctions_to_remove_this_warning: { code: 1236, category: ts.DiagnosticCategory.Error, key: "Experimental support for async functions is a feature that is subject to change in a future release. Specify '--experimentalAsyncFunctions' to remove this warning." }, - with_statements_are_not_allowed_in_an_async_function_block: { code: 1300, category: ts.DiagnosticCategory.Error, key: "'with' statements are not allowed in an async function block." }, - await_expression_is_only_allowed_within_an_async_function: { code: 1308, category: ts.DiagnosticCategory.Error, key: "'await' expression is only allowed within an async function." }, - Async_functions_are_only_available_when_targeting_ECMAScript_6_and_higher: { code: 1311, category: ts.DiagnosticCategory.Error, key: "Async functions are only available when targeting ECMAScript 6 and higher." }, The_return_type_of_a_property_decorator_function_must_be_either_void_or_any: { code: 1236, category: ts.DiagnosticCategory.Error, key: "The return type of a property decorator function must be either 'void' or 'any'." }, The_return_type_of_a_parameter_decorator_function_must_be_either_void_or_any: { code: 1237, category: ts.DiagnosticCategory.Error, key: "The return type of a parameter decorator function must be either 'void' or 'any'." }, Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression: { code: 1238, category: ts.DiagnosticCategory.Error, key: "Unable to resolve signature of class decorator when called as an expression." }, @@ -2077,6 +2086,10 @@ var ts; _0_modifier_cannot_be_used_with_1_modifier: { code: 1243, category: ts.DiagnosticCategory.Error, key: "'{0}' modifier cannot be used with '{1}' modifier." }, Abstract_methods_can_only_appear_within_an_abstract_class: { code: 1244, category: ts.DiagnosticCategory.Error, key: "Abstract methods can only appear within an abstract class." }, Method_0_cannot_have_an_implementation_because_it_is_marked_abstract: { code: 1245, category: ts.DiagnosticCategory.Error, key: "Method '{0}' cannot have an implementation because it is marked abstract." }, + with_statements_are_not_allowed_in_an_async_function_block: { code: 1300, category: ts.DiagnosticCategory.Error, key: "'with' statements are not allowed in an async function block." }, + await_expression_is_only_allowed_within_an_async_function: { code: 1308, category: ts.DiagnosticCategory.Error, key: "'await' expression is only allowed within an async function." }, + Async_functions_are_only_available_when_targeting_ECMAScript_6_and_higher: { code: 1311, category: ts.DiagnosticCategory.Error, key: "Async functions are only available when targeting ECMAScript 6 and higher." }, + can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment: { code: 1312, category: ts.DiagnosticCategory.Error, key: "'=' can only be used in an object literal property inside a destructuring assignment." }, Duplicate_identifier_0: { code: 2300, category: ts.DiagnosticCategory.Error, key: "Duplicate identifier '{0}'." }, Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor: { code: 2301, category: ts.DiagnosticCategory.Error, key: "Initializer of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor." }, Static_members_cannot_reference_class_type_parameters: { code: 2302, category: ts.DiagnosticCategory.Error, key: "Static members cannot reference class type parameters." }, @@ -2201,7 +2214,7 @@ var ts; In_an_enum_with_multiple_declarations_only_one_declaration_can_omit_an_initializer_for_its_first_enum_element: { code: 2432, category: ts.DiagnosticCategory.Error, key: "In an enum with multiple declarations, only one declaration can omit an initializer for its first enum element." }, A_namespace_declaration_cannot_be_in_a_different_file_from_a_class_or_function_with_which_it_is_merged: { code: 2433, category: ts.DiagnosticCategory.Error, key: "A namespace declaration cannot be in a different file from a class or function with which it is merged" }, A_namespace_declaration_cannot_be_located_prior_to_a_class_or_function_with_which_it_is_merged: { code: 2434, category: ts.DiagnosticCategory.Error, key: "A namespace declaration cannot be located prior to a class or function with which it is merged" }, - Ambient_modules_cannot_be_nested_in_other_modules: { code: 2435, category: ts.DiagnosticCategory.Error, key: "Ambient modules cannot be nested in other modules." }, + Ambient_modules_cannot_be_nested_in_other_modules_or_namespaces: { code: 2435, category: ts.DiagnosticCategory.Error, key: "Ambient modules cannot be nested in other modules or namespaces." }, Ambient_module_declaration_cannot_specify_relative_module_name: { code: 2436, category: ts.DiagnosticCategory.Error, key: "Ambient module declaration cannot specify relative module name." }, Module_0_is_hidden_by_a_local_declaration_with_the_same_name: { code: 2437, category: ts.DiagnosticCategory.Error, key: "Module '{0}' is hidden by a local declaration with the same name" }, Import_name_cannot_be_0: { code: 2438, category: ts.DiagnosticCategory.Error, key: "Import name cannot be '{0}'" }, @@ -2289,6 +2302,9 @@ var ts; yield_expressions_cannot_be_used_in_a_parameter_initializer: { code: 2523, category: ts.DiagnosticCategory.Error, key: "'yield' expressions cannot be used in a parameter initializer." }, await_expressions_cannot_be_used_in_a_parameter_initializer: { code: 2524, category: ts.DiagnosticCategory.Error, key: "'await' expressions cannot be used in a parameter initializer." }, Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value: { code: 2525, category: ts.DiagnosticCategory.Error, key: "Initializer provides no value for this binding element and the binding element has no default value." }, + A_this_type_is_available_only_in_a_non_static_member_of_a_class_or_interface: { code: 2526, category: ts.DiagnosticCategory.Error, key: "A 'this' type is available only in a non-static member of a class or interface." }, + The_inferred_type_of_0_references_an_inaccessible_this_type_A_type_annotation_is_necessary: { code: 2527, category: ts.DiagnosticCategory.Error, key: "The inferred type of '{0}' references an inaccessible 'this' type. A type annotation is necessary." }, + A_module_cannot_have_multiple_default_exports: { code: 2528, category: ts.DiagnosticCategory.Error, key: "A module cannot have multiple default exports." }, JSX_element_attributes_type_0_must_be_an_object_type: { code: 2600, category: ts.DiagnosticCategory.Error, key: "JSX element attributes type '{0}' must be an object type." }, The_return_type_of_a_JSX_element_constructor_must_return_an_object_type: { code: 2601, category: ts.DiagnosticCategory.Error, key: "The return type of a JSX element constructor must return an object type." }, JSX_element_implicitly_has_type_any_because_the_global_type_JSX_Element_does_not_exist: { code: 2602, category: ts.DiagnosticCategory.Error, key: "JSX element implicitly has type 'any' because the global type 'JSX.Element' does not exist." }, @@ -2389,7 +2405,7 @@ var ts; Option_inlineSources_can_only_be_used_when_either_option_inlineSourceMap_or_option_sourceMap_is_provided: { code: 5051, category: ts.DiagnosticCategory.Error, key: "Option 'inlineSources' can only be used when either option '--inlineSourceMap' or option '--sourceMap' is provided." }, Option_0_cannot_be_specified_without_specifying_option_1: { code: 5052, category: ts.DiagnosticCategory.Error, key: "Option '{0}' cannot be specified without specifying option '{1}'." }, Option_0_cannot_be_specified_with_option_1: { code: 5053, category: ts.DiagnosticCategory.Error, key: "Option '{0}' cannot be specified with option '{1}'." }, - A_tsconfig_json_file_is_already_defined_at_Colon_0: { code: 5053, category: ts.DiagnosticCategory.Error, key: "A 'tsconfig.json' file is already defined at: '{0}'." }, + A_tsconfig_json_file_is_already_defined_at_Colon_0: { code: 5054, category: ts.DiagnosticCategory.Error, key: "A 'tsconfig.json' file is already defined at: '{0}'." }, Concatenate_and_emit_output_to_single_file: { code: 6001, category: ts.DiagnosticCategory.Message, key: "Concatenate and emit output to single file." }, Generates_corresponding_d_ts_file: { code: 6002, category: ts.DiagnosticCategory.Message, key: "Generates corresponding '.d.ts' file." }, Specifies_the_location_where_debugger_should_locate_map_files_instead_of_generated_locations: { code: 6003, category: ts.DiagnosticCategory.Message, key: "Specifies the location where debugger should locate map files instead of generated locations." }, @@ -2401,7 +2417,7 @@ var ts; Do_not_emit_comments_to_output: { code: 6009, category: ts.DiagnosticCategory.Message, key: "Do not emit comments to output." }, Do_not_emit_outputs: { code: 6010, category: ts.DiagnosticCategory.Message, key: "Do not emit outputs." }, Specify_ECMAScript_target_version_Colon_ES3_default_ES5_or_ES6_experimental: { code: 6015, category: ts.DiagnosticCategory.Message, key: "Specify ECMAScript target version: 'ES3' (default), 'ES5', or 'ES6' (experimental)" }, - Specify_module_code_generation_Colon_commonjs_amd_system_or_umd: { code: 6016, category: ts.DiagnosticCategory.Message, key: "Specify module code generation: 'commonjs', 'amd', 'system' or 'umd'" }, + Specify_module_code_generation_Colon_commonjs_amd_system_umd_or_es6: { code: 6016, category: ts.DiagnosticCategory.Message, key: "Specify module code generation: 'commonjs', 'amd', 'system', 'umd' or 'es6'" }, Print_this_message: { code: 6017, category: ts.DiagnosticCategory.Message, key: "Print this message." }, Print_the_compiler_s_version: { code: 6019, category: ts.DiagnosticCategory.Message, key: "Print the compiler's version." }, Compile_the_project_in_the_given_directory: { code: 6020, category: ts.DiagnosticCategory.Message, key: "Compile the project in the given directory." }, @@ -2422,7 +2438,7 @@ var ts; Generates_corresponding_map_file: { code: 6043, category: ts.DiagnosticCategory.Message, key: "Generates corresponding '.map' file." }, Compiler_option_0_expects_an_argument: { code: 6044, category: ts.DiagnosticCategory.Error, key: "Compiler option '{0}' expects an argument." }, Unterminated_quoted_string_in_response_file_0: { code: 6045, category: ts.DiagnosticCategory.Error, key: "Unterminated quoted string in response file '{0}'." }, - Argument_for_module_option_must_be_commonjs_amd_system_or_umd: { code: 6046, category: ts.DiagnosticCategory.Error, key: "Argument for '--module' option must be 'commonjs', 'amd', 'system' or 'umd'." }, + Argument_for_module_option_must_be_commonjs_amd_system_umd_or_es6: { code: 6046, category: ts.DiagnosticCategory.Error, key: "Argument for '--module' option must be 'commonjs', 'amd', 'system', 'umd', or 'es6'." }, Argument_for_target_option_must_be_ES3_ES5_or_ES6: { code: 6047, category: ts.DiagnosticCategory.Error, key: "Argument for '--target' option must be 'ES3', 'ES5', or 'ES6'." }, Locale_must_be_of_the_form_language_or_language_territory_For_example_0_or_1: { code: 6048, category: ts.DiagnosticCategory.Error, key: "Locale must be of the form or -. For example '{0}' or '{1}'." }, Unsupported_locale_0: { code: 6049, category: ts.DiagnosticCategory.Error, key: "Unsupported locale '{0}'." }, @@ -2443,7 +2459,6 @@ var ts; Argument_for_jsx_must_be_preserve_or_react: { code: 6081, category: ts.DiagnosticCategory.Message, key: "Argument for '--jsx' must be 'preserve' or 'react'." }, Enables_experimental_support_for_ES7_decorators: { code: 6065, category: ts.DiagnosticCategory.Message, key: "Enables experimental support for ES7 decorators." }, Enables_experimental_support_for_emitting_type_metadata_for_decorators: { code: 6066, category: ts.DiagnosticCategory.Message, key: "Enables experimental support for emitting type metadata for decorators." }, - Option_experimentalAsyncFunctions_cannot_be_specified_when_targeting_ES5_or_lower: { code: 6067, category: ts.DiagnosticCategory.Message, key: "Option 'experimentalAsyncFunctions' cannot be specified when targeting ES5 or lower." }, Enables_experimental_support_for_ES7_async_functions: { code: 6068, category: ts.DiagnosticCategory.Message, key: "Enables experimental support for ES7 async functions." }, Specifies_module_resolution_strategy_Colon_node_Node_js_or_classic_TypeScript_pre_1_6: { code: 6069, category: ts.DiagnosticCategory.Message, key: "Specifies module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6)." }, Initializes_a_TypeScript_project_and_creates_a_tsconfig_json_file: { code: 6070, category: ts.DiagnosticCategory.Message, key: "Initializes a TypeScript project and creates a tsconfig.json file." }, @@ -2490,7 +2505,9 @@ var ts; Expected_corresponding_JSX_closing_tag_for_0: { code: 17002, category: ts.DiagnosticCategory.Error, key: "Expected corresponding JSX closing tag for '{0}'." }, JSX_attribute_expected: { code: 17003, category: ts.DiagnosticCategory.Error, key: "JSX attribute expected." }, Cannot_use_JSX_unless_the_jsx_flag_is_provided: { code: 17004, category: ts.DiagnosticCategory.Error, key: "Cannot use JSX unless the '--jsx' flag is provided." }, - A_constructor_cannot_contain_a_super_call_when_its_class_extends_null: { code: 17005, category: ts.DiagnosticCategory.Error, key: "A constructor cannot contain a 'super' call when its class extends 'null'" } + A_constructor_cannot_contain_a_super_call_when_its_class_extends_null: { code: 17005, category: ts.DiagnosticCategory.Error, key: "A constructor cannot contain a 'super' call when its class extends 'null'" }, + An_unary_expression_with_the_0_operator_is_not_allowed_in_the_left_hand_side_of_an_exponentiation_expression_Consider_enclosing_the_expression_in_parentheses: { code: 17006, category: ts.DiagnosticCategory.Error, key: "An unary expression with the '{0}' operator is not allowed in the left-hand side of an exponentiation expression. Consider enclosing the expression in parentheses." }, + A_type_assertion_expression_is_not_allowed_in_the_left_hand_side_of_an_exponentiation_expression_Consider_enclosing_the_expression_in_parentheses: { code: 17007, category: ts.DiagnosticCategory.Error, key: "A type assertion expression is not allowed in the left-hand side of an exponentiation expression. Consider enclosing the expression in parentheses." } }; })(ts || (ts = {})); /// @@ -2499,75 +2516,75 @@ var ts; (function (ts) { /* @internal */ function tokenIsIdentifierOrKeyword(token) { - return token >= 67 /* Identifier */; + return token >= 69 /* Identifier */; } ts.tokenIsIdentifierOrKeyword = tokenIsIdentifierOrKeyword; var textToToken = { - "abstract": 113 /* AbstractKeyword */, - "any": 115 /* AnyKeyword */, - "as": 114 /* AsKeyword */, - "boolean": 118 /* BooleanKeyword */, - "break": 68 /* BreakKeyword */, - "case": 69 /* CaseKeyword */, - "catch": 70 /* CatchKeyword */, - "class": 71 /* ClassKeyword */, - "continue": 73 /* ContinueKeyword */, - "const": 72 /* ConstKeyword */, - "constructor": 119 /* ConstructorKeyword */, - "debugger": 74 /* DebuggerKeyword */, - "declare": 120 /* DeclareKeyword */, - "default": 75 /* DefaultKeyword */, - "delete": 76 /* DeleteKeyword */, - "do": 77 /* DoKeyword */, - "else": 78 /* ElseKeyword */, - "enum": 79 /* EnumKeyword */, - "export": 80 /* ExportKeyword */, - "extends": 81 /* ExtendsKeyword */, - "false": 82 /* FalseKeyword */, - "finally": 83 /* FinallyKeyword */, - "for": 84 /* ForKeyword */, - "from": 131 /* FromKeyword */, - "function": 85 /* FunctionKeyword */, - "get": 121 /* GetKeyword */, - "if": 86 /* IfKeyword */, - "implements": 104 /* ImplementsKeyword */, - "import": 87 /* ImportKeyword */, - "in": 88 /* InKeyword */, - "instanceof": 89 /* InstanceOfKeyword */, - "interface": 105 /* InterfaceKeyword */, - "is": 122 /* IsKeyword */, - "let": 106 /* LetKeyword */, - "module": 123 /* ModuleKeyword */, - "namespace": 124 /* NamespaceKeyword */, - "new": 90 /* NewKeyword */, - "null": 91 /* NullKeyword */, - "number": 126 /* NumberKeyword */, - "package": 107 /* PackageKeyword */, - "private": 108 /* PrivateKeyword */, - "protected": 109 /* ProtectedKeyword */, - "public": 110 /* PublicKeyword */, - "require": 125 /* RequireKeyword */, - "return": 92 /* ReturnKeyword */, - "set": 127 /* SetKeyword */, - "static": 111 /* StaticKeyword */, - "string": 128 /* StringKeyword */, - "super": 93 /* SuperKeyword */, - "switch": 94 /* SwitchKeyword */, - "symbol": 129 /* SymbolKeyword */, - "this": 95 /* ThisKeyword */, - "throw": 96 /* ThrowKeyword */, - "true": 97 /* TrueKeyword */, - "try": 98 /* TryKeyword */, - "type": 130 /* TypeKeyword */, - "typeof": 99 /* TypeOfKeyword */, - "var": 100 /* VarKeyword */, - "void": 101 /* VoidKeyword */, - "while": 102 /* WhileKeyword */, - "with": 103 /* WithKeyword */, - "yield": 112 /* YieldKeyword */, - "async": 116 /* AsyncKeyword */, - "await": 117 /* AwaitKeyword */, - "of": 132 /* OfKeyword */, + "abstract": 115 /* AbstractKeyword */, + "any": 117 /* AnyKeyword */, + "as": 116 /* AsKeyword */, + "boolean": 120 /* BooleanKeyword */, + "break": 70 /* BreakKeyword */, + "case": 71 /* CaseKeyword */, + "catch": 72 /* CatchKeyword */, + "class": 73 /* ClassKeyword */, + "continue": 75 /* ContinueKeyword */, + "const": 74 /* ConstKeyword */, + "constructor": 121 /* ConstructorKeyword */, + "debugger": 76 /* DebuggerKeyword */, + "declare": 122 /* DeclareKeyword */, + "default": 77 /* DefaultKeyword */, + "delete": 78 /* DeleteKeyword */, + "do": 79 /* DoKeyword */, + "else": 80 /* ElseKeyword */, + "enum": 81 /* EnumKeyword */, + "export": 82 /* ExportKeyword */, + "extends": 83 /* ExtendsKeyword */, + "false": 84 /* FalseKeyword */, + "finally": 85 /* FinallyKeyword */, + "for": 86 /* ForKeyword */, + "from": 133 /* FromKeyword */, + "function": 87 /* FunctionKeyword */, + "get": 123 /* GetKeyword */, + "if": 88 /* IfKeyword */, + "implements": 106 /* ImplementsKeyword */, + "import": 89 /* ImportKeyword */, + "in": 90 /* InKeyword */, + "instanceof": 91 /* InstanceOfKeyword */, + "interface": 107 /* InterfaceKeyword */, + "is": 124 /* IsKeyword */, + "let": 108 /* LetKeyword */, + "module": 125 /* ModuleKeyword */, + "namespace": 126 /* NamespaceKeyword */, + "new": 92 /* NewKeyword */, + "null": 93 /* NullKeyword */, + "number": 128 /* NumberKeyword */, + "package": 109 /* PackageKeyword */, + "private": 110 /* PrivateKeyword */, + "protected": 111 /* ProtectedKeyword */, + "public": 112 /* PublicKeyword */, + "require": 127 /* RequireKeyword */, + "return": 94 /* ReturnKeyword */, + "set": 129 /* SetKeyword */, + "static": 113 /* StaticKeyword */, + "string": 130 /* StringKeyword */, + "super": 95 /* SuperKeyword */, + "switch": 96 /* SwitchKeyword */, + "symbol": 131 /* SymbolKeyword */, + "this": 97 /* ThisKeyword */, + "throw": 98 /* ThrowKeyword */, + "true": 99 /* TrueKeyword */, + "try": 100 /* TryKeyword */, + "type": 132 /* TypeKeyword */, + "typeof": 101 /* TypeOfKeyword */, + "var": 102 /* VarKeyword */, + "void": 103 /* VoidKeyword */, + "while": 104 /* WhileKeyword */, + "with": 105 /* WithKeyword */, + "yield": 114 /* YieldKeyword */, + "async": 118 /* AsyncKeyword */, + "await": 119 /* AwaitKeyword */, + "of": 134 /* OfKeyword */, "{": 15 /* OpenBraceToken */, "}": 16 /* CloseBraceToken */, "(": 17 /* OpenParenToken */, @@ -2589,37 +2606,39 @@ var ts; "=>": 34 /* EqualsGreaterThanToken */, "+": 35 /* PlusToken */, "-": 36 /* MinusToken */, + "**": 38 /* AsteriskAsteriskToken */, "*": 37 /* AsteriskToken */, - "/": 38 /* SlashToken */, - "%": 39 /* PercentToken */, - "++": 40 /* PlusPlusToken */, - "--": 41 /* MinusMinusToken */, - "<<": 42 /* LessThanLessThanToken */, + "/": 39 /* SlashToken */, + "%": 40 /* PercentToken */, + "++": 41 /* PlusPlusToken */, + "--": 42 /* MinusMinusToken */, + "<<": 43 /* LessThanLessThanToken */, ">": 43 /* GreaterThanGreaterThanToken */, - ">>>": 44 /* GreaterThanGreaterThanGreaterThanToken */, - "&": 45 /* AmpersandToken */, - "|": 46 /* BarToken */, - "^": 47 /* CaretToken */, - "!": 48 /* ExclamationToken */, - "~": 49 /* TildeToken */, - "&&": 50 /* AmpersandAmpersandToken */, - "||": 51 /* BarBarToken */, - "?": 52 /* QuestionToken */, - ":": 53 /* ColonToken */, - "=": 55 /* EqualsToken */, - "+=": 56 /* PlusEqualsToken */, - "-=": 57 /* MinusEqualsToken */, - "*=": 58 /* AsteriskEqualsToken */, - "/=": 59 /* SlashEqualsToken */, - "%=": 60 /* PercentEqualsToken */, - "<<=": 61 /* LessThanLessThanEqualsToken */, - ">>=": 62 /* GreaterThanGreaterThanEqualsToken */, - ">>>=": 63 /* GreaterThanGreaterThanGreaterThanEqualsToken */, - "&=": 64 /* AmpersandEqualsToken */, - "|=": 65 /* BarEqualsToken */, - "^=": 66 /* CaretEqualsToken */, - "@": 54 /* AtToken */ + ">>": 44 /* GreaterThanGreaterThanToken */, + ">>>": 45 /* GreaterThanGreaterThanGreaterThanToken */, + "&": 46 /* AmpersandToken */, + "|": 47 /* BarToken */, + "^": 48 /* CaretToken */, + "!": 49 /* ExclamationToken */, + "~": 50 /* TildeToken */, + "&&": 51 /* AmpersandAmpersandToken */, + "||": 52 /* BarBarToken */, + "?": 53 /* QuestionToken */, + ":": 54 /* ColonToken */, + "=": 56 /* EqualsToken */, + "+=": 57 /* PlusEqualsToken */, + "-=": 58 /* MinusEqualsToken */, + "*=": 59 /* AsteriskEqualsToken */, + "**=": 60 /* AsteriskAsteriskEqualsToken */, + "/=": 61 /* SlashEqualsToken */, + "%=": 62 /* PercentEqualsToken */, + "<<=": 63 /* LessThanLessThanEqualsToken */, + ">>=": 64 /* GreaterThanGreaterThanEqualsToken */, + ">>>=": 65 /* GreaterThanGreaterThanGreaterThanEqualsToken */, + "&=": 66 /* AmpersandEqualsToken */, + "|=": 67 /* BarEqualsToken */, + "^=": 68 /* CaretEqualsToken */, + "@": 55 /* AtToken */ }; /* As per ECMAScript Language Specification 3th Edition, Section 7.6: Identifiers @@ -3123,8 +3142,8 @@ var ts; getTokenValue: function () { return tokenValue; }, hasExtendedUnicodeEscape: function () { return hasExtendedUnicodeEscape; }, hasPrecedingLineBreak: function () { return precedingLineBreak; }, - isIdentifier: function () { return token === 67 /* Identifier */ || token > 103 /* LastReservedWord */; }, - isReservedWord: function () { return token >= 68 /* FirstReservedWord */ && token <= 103 /* LastReservedWord */; }, + isIdentifier: function () { return token === 69 /* Identifier */ || token > 105 /* LastReservedWord */; }, + isReservedWord: function () { return token >= 70 /* FirstReservedWord */ && token <= 105 /* LastReservedWord */; }, isUnterminated: function () { return tokenIsUnterminated; }, reScanGreaterToken: reScanGreaterToken, reScanSlashToken: reScanSlashToken, @@ -3146,16 +3165,6 @@ var ts; onError(message, length || 0); } } - function isIdentifierStart(ch) { - return ch >= 65 /* A */ && ch <= 90 /* Z */ || ch >= 97 /* a */ && ch <= 122 /* z */ || - ch === 36 /* $ */ || ch === 95 /* _ */ || - ch > 127 /* maxAsciiCharacter */ && isUnicodeIdentifierStart(ch, languageVersion); - } - function isIdentifierPart(ch) { - return ch >= 65 /* A */ && ch <= 90 /* Z */ || ch >= 97 /* a */ && ch <= 122 /* z */ || - ch >= 48 /* _0 */ && ch <= 57 /* _9 */ || ch === 36 /* $ */ || ch === 95 /* _ */ || - ch > 127 /* maxAsciiCharacter */ && isUnicodeIdentifierPart(ch, languageVersion); - } function scanNumber() { var start = pos; while (isDigit(text.charCodeAt(pos))) @@ -3438,12 +3447,12 @@ var ts; var start = pos; while (pos < end) { var ch = text.charCodeAt(pos); - if (isIdentifierPart(ch)) { + if (isIdentifierPart(ch, languageVersion)) { pos++; } else if (ch === 92 /* backslash */) { ch = peekUnicodeEscape(); - if (!(ch >= 0 && isIdentifierPart(ch))) { + if (!(ch >= 0 && isIdentifierPart(ch, languageVersion))) { break; } result += text.substring(start, pos); @@ -3468,7 +3477,7 @@ var ts; return token = textToToken[tokenValue]; } } - return token = 67 /* Identifier */; + return token = 69 /* Identifier */; } function scanBinaryOrOctalDigits(base) { ts.Debug.assert(base !== 2 || base !== 8, "Expected either base 2 or base 8"); @@ -3552,7 +3561,7 @@ var ts; } return pos += 2, token = 31 /* ExclamationEqualsToken */; } - return pos++, token = 48 /* ExclamationToken */; + return pos++, token = 49 /* ExclamationToken */; case 34 /* doubleQuote */: case 39 /* singleQuote */: tokenValue = scanString(); @@ -3561,42 +3570,48 @@ var ts; return token = scanTemplateAndSetTokenValue(); case 37 /* percent */: if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 60 /* PercentEqualsToken */; + return pos += 2, token = 62 /* PercentEqualsToken */; } - return pos++, token = 39 /* PercentToken */; + return pos++, token = 40 /* PercentToken */; case 38 /* ampersand */: if (text.charCodeAt(pos + 1) === 38 /* ampersand */) { - return pos += 2, token = 50 /* AmpersandAmpersandToken */; + return pos += 2, token = 51 /* AmpersandAmpersandToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 64 /* AmpersandEqualsToken */; + return pos += 2, token = 66 /* AmpersandEqualsToken */; } - return pos++, token = 45 /* AmpersandToken */; + return pos++, token = 46 /* AmpersandToken */; case 40 /* openParen */: return pos++, token = 17 /* OpenParenToken */; case 41 /* closeParen */: return pos++, token = 18 /* CloseParenToken */; case 42 /* asterisk */: if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 58 /* AsteriskEqualsToken */; + return pos += 2, token = 59 /* AsteriskEqualsToken */; + } + if (text.charCodeAt(pos + 1) === 42 /* asterisk */) { + if (text.charCodeAt(pos + 2) === 61 /* equals */) { + return pos += 3, token = 60 /* AsteriskAsteriskEqualsToken */; + } + return pos += 2, token = 38 /* AsteriskAsteriskToken */; } return pos++, token = 37 /* AsteriskToken */; case 43 /* plus */: if (text.charCodeAt(pos + 1) === 43 /* plus */) { - return pos += 2, token = 40 /* PlusPlusToken */; + return pos += 2, token = 41 /* PlusPlusToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 56 /* PlusEqualsToken */; + return pos += 2, token = 57 /* PlusEqualsToken */; } return pos++, token = 35 /* PlusToken */; case 44 /* comma */: return pos++, token = 24 /* CommaToken */; case 45 /* minus */: if (text.charCodeAt(pos + 1) === 45 /* minus */) { - return pos += 2, token = 41 /* MinusMinusToken */; + return pos += 2, token = 42 /* MinusMinusToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 57 /* MinusEqualsToken */; + return pos += 2, token = 58 /* MinusEqualsToken */; } return pos++, token = 36 /* MinusToken */; case 46 /* dot */: @@ -3653,9 +3668,9 @@ var ts; } } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 59 /* SlashEqualsToken */; + return pos += 2, token = 61 /* SlashEqualsToken */; } - return pos++, token = 38 /* SlashToken */; + return pos++, token = 39 /* SlashToken */; case 48 /* _0 */: if (pos + 2 < end && (text.charCodeAt(pos + 1) === 88 /* X */ || text.charCodeAt(pos + 1) === 120 /* x */)) { pos += 2; @@ -3707,7 +3722,7 @@ var ts; tokenValue = "" + scanNumber(); return token = 8 /* NumericLiteral */; case 58 /* colon */: - return pos++, token = 53 /* ColonToken */; + return pos++, token = 54 /* ColonToken */; case 59 /* semicolon */: return pos++, token = 23 /* SemicolonToken */; case 60 /* lessThan */: @@ -3722,14 +3737,16 @@ var ts; } if (text.charCodeAt(pos + 1) === 60 /* lessThan */) { if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 61 /* LessThanLessThanEqualsToken */; + return pos += 3, token = 63 /* LessThanLessThanEqualsToken */; } - return pos += 2, token = 42 /* LessThanLessThanToken */; + return pos += 2, token = 43 /* LessThanLessThanToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { return pos += 2, token = 28 /* LessThanEqualsToken */; } - if (text.charCodeAt(pos + 1) === 47 /* slash */ && languageVariant === 1 /* JSX */) { + if (languageVariant === 1 /* JSX */ && + text.charCodeAt(pos + 1) === 47 /* slash */ && + text.charCodeAt(pos + 2) !== 42 /* asterisk */) { return pos += 2, token = 26 /* LessThanSlashToken */; } return pos++, token = 25 /* LessThanToken */; @@ -3752,7 +3769,7 @@ var ts; if (text.charCodeAt(pos + 1) === 62 /* greaterThan */) { return pos += 2, token = 34 /* EqualsGreaterThanToken */; } - return pos++, token = 55 /* EqualsToken */; + return pos++, token = 56 /* EqualsToken */; case 62 /* greaterThan */: if (isConflictMarkerTrivia(text, pos)) { pos = scanConflictMarkerTrivia(text, pos, error); @@ -3765,35 +3782,35 @@ var ts; } return pos++, token = 27 /* GreaterThanToken */; case 63 /* question */: - return pos++, token = 52 /* QuestionToken */; + return pos++, token = 53 /* QuestionToken */; case 91 /* openBracket */: return pos++, token = 19 /* OpenBracketToken */; case 93 /* closeBracket */: return pos++, token = 20 /* CloseBracketToken */; case 94 /* caret */: if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 66 /* CaretEqualsToken */; + return pos += 2, token = 68 /* CaretEqualsToken */; } - return pos++, token = 47 /* CaretToken */; + return pos++, token = 48 /* CaretToken */; case 123 /* openBrace */: return pos++, token = 15 /* OpenBraceToken */; case 124 /* bar */: if (text.charCodeAt(pos + 1) === 124 /* bar */) { - return pos += 2, token = 51 /* BarBarToken */; + return pos += 2, token = 52 /* BarBarToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 65 /* BarEqualsToken */; + return pos += 2, token = 67 /* BarEqualsToken */; } - return pos++, token = 46 /* BarToken */; + return pos++, token = 47 /* BarToken */; case 125 /* closeBrace */: return pos++, token = 16 /* CloseBraceToken */; case 126 /* tilde */: - return pos++, token = 49 /* TildeToken */; + return pos++, token = 50 /* TildeToken */; case 64 /* at */: - return pos++, token = 54 /* AtToken */; + return pos++, token = 55 /* AtToken */; case 92 /* backslash */: var cookedChar = peekUnicodeEscape(); - if (cookedChar >= 0 && isIdentifierStart(cookedChar)) { + if (cookedChar >= 0 && isIdentifierStart(cookedChar, languageVersion)) { pos += 6; tokenValue = String.fromCharCode(cookedChar) + scanIdentifierParts(); return token = getIdentifierToken(); @@ -3801,9 +3818,9 @@ var ts; error(ts.Diagnostics.Invalid_character); return pos++, token = 0 /* Unknown */; default: - if (isIdentifierStart(ch)) { + if (isIdentifierStart(ch, languageVersion)) { pos++; - while (pos < end && isIdentifierPart(ch = text.charCodeAt(pos))) + while (pos < end && isIdentifierPart(ch = text.charCodeAt(pos), languageVersion)) pos++; tokenValue = text.substring(tokenPos, pos); if (ch === 92 /* backslash */) { @@ -3830,14 +3847,14 @@ var ts; if (text.charCodeAt(pos) === 62 /* greaterThan */) { if (text.charCodeAt(pos + 1) === 62 /* greaterThan */) { if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 63 /* GreaterThanGreaterThanGreaterThanEqualsToken */; + return pos += 3, token = 65 /* GreaterThanGreaterThanGreaterThanEqualsToken */; } - return pos += 2, token = 44 /* GreaterThanGreaterThanGreaterThanToken */; + return pos += 2, token = 45 /* GreaterThanGreaterThanGreaterThanToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 62 /* GreaterThanGreaterThanEqualsToken */; + return pos += 2, token = 64 /* GreaterThanGreaterThanEqualsToken */; } - return pos++, token = 43 /* GreaterThanGreaterThanToken */; + return pos++, token = 44 /* GreaterThanGreaterThanToken */; } if (text.charCodeAt(pos) === 61 /* equals */) { return pos++, token = 29 /* GreaterThanEqualsToken */; @@ -3846,7 +3863,7 @@ var ts; return token; } function reScanSlashToken() { - if (token === 38 /* SlashToken */ || token === 59 /* SlashEqualsToken */) { + if (token === 39 /* SlashToken */ || token === 61 /* SlashEqualsToken */) { var p = tokenPos + 1; var inEscape = false; var inCharacterClass = false; @@ -3886,7 +3903,7 @@ var ts; } p++; } - while (p < end && isIdentifierPart(text.charCodeAt(p))) { + while (p < end && isIdentifierPart(text.charCodeAt(p), languageVersion)) { p++; } pos = p; @@ -3932,7 +3949,7 @@ var ts; break; } } - return token = 234 /* JsxText */; + return token = 236 /* JsxText */; } // Scans a JSX identifier; these differ from normal identifiers in that // they allow dashes @@ -3941,7 +3958,7 @@ var ts; var firstCharPosition = pos; while (pos < end) { var ch = text.charCodeAt(pos); - if (ch === 45 /* minus */ || ((firstCharPosition === pos) ? isIdentifierStart(ch) : isIdentifierPart(ch))) { + if (ch === 45 /* minus */ || ((firstCharPosition === pos) ? isIdentifierStart(ch, languageVersion) : isIdentifierPart(ch, languageVersion))) { pos++; } else { @@ -4020,16 +4037,16 @@ var ts; function getModuleInstanceState(node) { // A module is uninstantiated if it contains only // 1. interface declarations, type alias declarations - if (node.kind === 213 /* InterfaceDeclaration */ || node.kind === 214 /* TypeAliasDeclaration */) { + if (node.kind === 215 /* InterfaceDeclaration */ || node.kind === 216 /* TypeAliasDeclaration */) { return 0 /* NonInstantiated */; } else if (ts.isConstEnumDeclaration(node)) { return 2 /* ConstEnumOnly */; } - else if ((node.kind === 220 /* ImportDeclaration */ || node.kind === 219 /* ImportEqualsDeclaration */) && !(node.flags & 1 /* Export */)) { + else if ((node.kind === 222 /* ImportDeclaration */ || node.kind === 221 /* ImportEqualsDeclaration */) && !(node.flags & 1 /* Export */)) { return 0 /* NonInstantiated */; } - else if (node.kind === 217 /* ModuleBlock */) { + else if (node.kind === 219 /* ModuleBlock */) { var state = 0 /* NonInstantiated */; ts.forEachChild(node, function (n) { switch (getModuleInstanceState(n)) { @@ -4048,7 +4065,7 @@ var ts; }); return state; } - else if (node.kind === 216 /* ModuleDeclaration */) { + else if (node.kind === 218 /* ModuleDeclaration */) { return getModuleInstanceState(node.body); } else { @@ -4088,6 +4105,8 @@ var ts; var container; var blockScopeContainer; var lastContainer; + var seenThisKeyword; + var isJavaScriptFile = ts.isSourceFileJavaScript(file); // If this file is an external module, then it is automatically in strict-mode according to // ES6. If it is not an external module, then we'll determine if it is in strict mode or // not depending on if we see "use strict" in certain places (or if we hit a class/namespace). @@ -4126,10 +4145,10 @@ var ts; // unless it is a well known Symbol. function getDeclarationName(node) { if (node.name) { - if (node.kind === 216 /* ModuleDeclaration */ && node.name.kind === 9 /* StringLiteral */) { + if (node.kind === 218 /* ModuleDeclaration */ && node.name.kind === 9 /* StringLiteral */) { return "\"" + node.name.text + "\""; } - if (node.name.kind === 134 /* ComputedPropertyName */) { + if (node.name.kind === 136 /* ComputedPropertyName */) { var nameExpression = node.name.expression; ts.Debug.assert(ts.isWellKnownSymbolSyntactically(nameExpression)); return ts.getPropertyNameForKnownSymbolName(nameExpression.name.text); @@ -4137,22 +4156,25 @@ var ts; return node.name.text; } switch (node.kind) { - case 142 /* Constructor */: + case 144 /* Constructor */: return "__constructor"; - case 150 /* FunctionType */: - case 145 /* CallSignature */: + case 152 /* FunctionType */: + case 147 /* CallSignature */: return "__call"; - case 151 /* ConstructorType */: - case 146 /* ConstructSignature */: + case 153 /* ConstructorType */: + case 148 /* ConstructSignature */: return "__new"; - case 147 /* IndexSignature */: + case 149 /* IndexSignature */: return "__index"; - case 226 /* ExportDeclaration */: + case 228 /* ExportDeclaration */: return "__export"; - case 225 /* ExportAssignment */: + case 227 /* ExportAssignment */: return node.isExportEquals ? "export=" : "default"; - case 211 /* FunctionDeclaration */: - case 212 /* ClassDeclaration */: + case 181 /* BinaryExpression */: + // Binary expression case is for JS module 'module.exports = expr' + return "export="; + case 213 /* FunctionDeclaration */: + case 214 /* ClassDeclaration */: return node.flags & 1024 /* Default */ ? "default" : undefined; } } @@ -4169,8 +4191,9 @@ var ts; */ function declareSymbol(symbolTable, parent, node, includes, excludes) { ts.Debug.assert(!ts.hasDynamicName(node)); + var isDefaultExport = node.flags & 1024 /* Default */; // The exported symbol for an export default function/class node is always named "default" - var name = node.flags & 1024 /* Default */ && parent ? "default" : getDeclarationName(node); + var name = isDefaultExport && parent ? "default" : getDeclarationName(node); var symbol; if (name !== undefined) { // Check and see if the symbol table already has a symbol with this name. If not, @@ -4206,6 +4229,11 @@ var ts; var message = symbol.flags & 2 /* BlockScopedVariable */ ? ts.Diagnostics.Cannot_redeclare_block_scoped_variable_0 : ts.Diagnostics.Duplicate_identifier_0; + ts.forEach(symbol.declarations, function (declaration) { + if (declaration.flags & 1024 /* Default */) { + message = ts.Diagnostics.A_module_cannot_have_multiple_default_exports; + } + }); ts.forEach(symbol.declarations, function (declaration) { file.bindDiagnostics.push(ts.createDiagnosticForNode(declaration.name || declaration, message, getDisplayName(declaration))); }); @@ -4223,7 +4251,7 @@ var ts; function declareModuleMember(node, symbolFlags, symbolExcludes) { var hasExportModifier = ts.getCombinedNodeFlags(node) & 1 /* Export */; if (symbolFlags & 8388608 /* Alias */) { - if (node.kind === 228 /* ExportSpecifier */ || (node.kind === 219 /* ImportEqualsDeclaration */ && hasExportModifier)) { + if (node.kind === 230 /* ExportSpecifier */ || (node.kind === 221 /* ImportEqualsDeclaration */ && hasExportModifier)) { return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); } else { @@ -4297,44 +4325,51 @@ var ts; blockScopeContainer = node; blockScopeContainer.locals = undefined; } - ts.forEachChild(node, bind); + if (node.kind === 215 /* InterfaceDeclaration */) { + seenThisKeyword = false; + ts.forEachChild(node, bind); + node.flags = seenThisKeyword ? node.flags | 524288 /* ContainsThis */ : node.flags & ~524288 /* ContainsThis */; + } + else { + ts.forEachChild(node, bind); + } container = saveContainer; parent = saveParent; blockScopeContainer = savedBlockScopeContainer; } function getContainerFlags(node) { switch (node.kind) { - case 184 /* ClassExpression */: - case 212 /* ClassDeclaration */: - case 213 /* InterfaceDeclaration */: - case 215 /* EnumDeclaration */: - case 153 /* TypeLiteral */: - case 163 /* ObjectLiteralExpression */: + case 186 /* ClassExpression */: + case 214 /* ClassDeclaration */: + case 215 /* InterfaceDeclaration */: + case 217 /* EnumDeclaration */: + case 155 /* TypeLiteral */: + case 165 /* ObjectLiteralExpression */: return 1 /* IsContainer */; - case 145 /* CallSignature */: - case 146 /* ConstructSignature */: - case 147 /* IndexSignature */: - case 141 /* MethodDeclaration */: - case 140 /* MethodSignature */: - case 211 /* FunctionDeclaration */: - case 142 /* Constructor */: - case 143 /* GetAccessor */: - case 144 /* SetAccessor */: - case 150 /* FunctionType */: - case 151 /* ConstructorType */: - case 171 /* FunctionExpression */: - case 172 /* ArrowFunction */: - case 216 /* ModuleDeclaration */: - case 246 /* SourceFile */: - case 214 /* TypeAliasDeclaration */: + case 147 /* CallSignature */: + case 148 /* ConstructSignature */: + case 149 /* IndexSignature */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: + case 213 /* FunctionDeclaration */: + case 144 /* Constructor */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: + case 152 /* FunctionType */: + case 153 /* ConstructorType */: + case 173 /* FunctionExpression */: + case 174 /* ArrowFunction */: + case 218 /* ModuleDeclaration */: + case 248 /* SourceFile */: + case 216 /* TypeAliasDeclaration */: return 5 /* IsContainerWithLocals */; - case 242 /* CatchClause */: - case 197 /* ForStatement */: - case 198 /* ForInStatement */: - case 199 /* ForOfStatement */: - case 218 /* CaseBlock */: + case 244 /* CatchClause */: + case 199 /* ForStatement */: + case 200 /* ForInStatement */: + case 201 /* ForOfStatement */: + case 220 /* CaseBlock */: return 2 /* IsBlockScopedContainer */; - case 190 /* Block */: + case 192 /* Block */: // do not treat blocks directly inside a function as a block-scoped-container. // Locals that reside in this block should go to the function locals. Othewise 'x' // would not appear to be a redeclaration of a block scoped local in the following @@ -4371,38 +4406,38 @@ var ts; // members are declared (for example, a member of a class will go into a specific // symbol table depending on if it is static or not). We defer to specialized // handlers to take care of declaring these child members. - case 216 /* ModuleDeclaration */: + case 218 /* ModuleDeclaration */: return declareModuleMember(node, symbolFlags, symbolExcludes); - case 246 /* SourceFile */: + case 248 /* SourceFile */: return declareSourceFileMember(node, symbolFlags, symbolExcludes); - case 184 /* ClassExpression */: - case 212 /* ClassDeclaration */: + case 186 /* ClassExpression */: + case 214 /* ClassDeclaration */: return declareClassMember(node, symbolFlags, symbolExcludes); - case 215 /* EnumDeclaration */: + case 217 /* EnumDeclaration */: return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); - case 153 /* TypeLiteral */: - case 163 /* ObjectLiteralExpression */: - case 213 /* InterfaceDeclaration */: + case 155 /* TypeLiteral */: + case 165 /* ObjectLiteralExpression */: + case 215 /* InterfaceDeclaration */: // Interface/Object-types always have their children added to the 'members' of // their container. They are only accessible through an instance of their // container, and are never in scope otherwise (even inside the body of the // object / type / interface declaring them). An exception is type parameters, // which are in scope without qualification (similar to 'locals'). return declareSymbol(container.symbol.members, container.symbol, node, symbolFlags, symbolExcludes); - case 150 /* FunctionType */: - case 151 /* ConstructorType */: - case 145 /* CallSignature */: - case 146 /* ConstructSignature */: - case 147 /* IndexSignature */: - case 141 /* MethodDeclaration */: - case 140 /* MethodSignature */: - case 142 /* Constructor */: - case 143 /* GetAccessor */: - case 144 /* SetAccessor */: - case 211 /* FunctionDeclaration */: - case 171 /* FunctionExpression */: - case 172 /* ArrowFunction */: - case 214 /* TypeAliasDeclaration */: + case 152 /* FunctionType */: + case 153 /* ConstructorType */: + case 147 /* CallSignature */: + case 148 /* ConstructSignature */: + case 149 /* IndexSignature */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: + case 144 /* Constructor */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: + case 213 /* FunctionDeclaration */: + case 173 /* FunctionExpression */: + case 174 /* ArrowFunction */: + case 216 /* TypeAliasDeclaration */: // All the children of these container types are never visible through another // symbol (i.e. through another symbol's 'exports' or 'members'). Instead, // they're only accessed 'lexically' (i.e. from code that exists underneath @@ -4432,11 +4467,11 @@ var ts; return false; } function hasExportDeclarations(node) { - var body = node.kind === 246 /* SourceFile */ ? node : node.body; - if (body.kind === 246 /* SourceFile */ || body.kind === 217 /* ModuleBlock */) { + var body = node.kind === 248 /* SourceFile */ ? node : node.body; + if (body.kind === 248 /* SourceFile */ || body.kind === 219 /* ModuleBlock */) { for (var _i = 0, _a = body.statements; _i < _a.length; _i++) { var stat = _a[_i]; - if (stat.kind === 226 /* ExportDeclaration */ || stat.kind === 225 /* ExportAssignment */) { + if (stat.kind === 228 /* ExportDeclaration */ || stat.kind === 227 /* ExportAssignment */) { return true; } } @@ -4508,7 +4543,7 @@ var ts; var seen = {}; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; - if (prop.name.kind !== 67 /* Identifier */) { + if (prop.name.kind !== 69 /* Identifier */) { continue; } var identifier = prop.name; @@ -4520,7 +4555,7 @@ var ts; // c.IsAccessorDescriptor(previous) is true and IsDataDescriptor(propId.descriptor) is true. // d.IsAccessorDescriptor(previous) is true and IsAccessorDescriptor(propId.descriptor) is true // and either both previous and propId.descriptor have[[Get]] fields or both previous and propId.descriptor have[[Set]] fields - var currentKind = prop.kind === 243 /* PropertyAssignment */ || prop.kind === 244 /* ShorthandPropertyAssignment */ || prop.kind === 141 /* MethodDeclaration */ + var currentKind = prop.kind === 245 /* PropertyAssignment */ || prop.kind === 246 /* ShorthandPropertyAssignment */ || prop.kind === 143 /* MethodDeclaration */ ? 1 /* Property */ : 2 /* Accessor */; var existingKind = seen[identifier.text]; @@ -4542,10 +4577,10 @@ var ts; } function bindBlockScopedDeclaration(node, symbolFlags, symbolExcludes) { switch (blockScopeContainer.kind) { - case 216 /* ModuleDeclaration */: + case 218 /* ModuleDeclaration */: declareModuleMember(node, symbolFlags, symbolExcludes); break; - case 246 /* SourceFile */: + case 248 /* SourceFile */: if (ts.isExternalModule(container)) { declareModuleMember(node, symbolFlags, symbolExcludes); break; @@ -4566,8 +4601,8 @@ var ts; // check for reserved words used as identifiers in strict mode code. function checkStrictModeIdentifier(node) { if (inStrictMode && - node.originalKeywordKind >= 104 /* FirstFutureReservedWord */ && - node.originalKeywordKind <= 112 /* LastFutureReservedWord */ && + node.originalKeywordKind >= 106 /* FirstFutureReservedWord */ && + node.originalKeywordKind <= 114 /* LastFutureReservedWord */ && !ts.isIdentifierName(node)) { // Report error only if there are no parse errors in file if (!file.parseDiagnostics.length) { @@ -4602,7 +4637,7 @@ var ts; } function checkStrictModeDeleteExpression(node) { // Grammar checking - if (inStrictMode && node.expression.kind === 67 /* Identifier */) { + if (inStrictMode && node.expression.kind === 69 /* Identifier */) { // When a delete operator occurs within strict mode code, a SyntaxError is thrown if its // UnaryExpression is a direct reference to a variable, function argument, or function name var span = ts.getErrorSpanForNode(file, node.expression); @@ -4610,11 +4645,11 @@ var ts; } } function isEvalOrArgumentsIdentifier(node) { - return node.kind === 67 /* Identifier */ && + return node.kind === 69 /* Identifier */ && (node.text === "eval" || node.text === "arguments"); } function checkStrictModeEvalOrArguments(contextNode, name) { - if (name && name.kind === 67 /* Identifier */) { + if (name && name.kind === 69 /* Identifier */) { var identifier = name; if (isEvalOrArgumentsIdentifier(identifier)) { // We check first if the name is inside class declaration or class expression; if so give explicit message @@ -4658,7 +4693,7 @@ var ts; function checkStrictModePrefixUnaryExpression(node) { // Grammar checking if (inStrictMode) { - if (node.operator === 40 /* PlusPlusToken */ || node.operator === 41 /* MinusMinusToken */) { + if (node.operator === 41 /* PlusPlusToken */ || node.operator === 42 /* MinusMinusToken */) { checkStrictModeEvalOrArguments(node, node.operand); } } @@ -4702,17 +4737,17 @@ var ts; } function updateStrictMode(node) { switch (node.kind) { - case 246 /* SourceFile */: - case 217 /* ModuleBlock */: + case 248 /* SourceFile */: + case 219 /* ModuleBlock */: updateStrictModeStatementList(node.statements); return; - case 190 /* Block */: + case 192 /* Block */: if (ts.isFunctionLike(node.parent)) { updateStrictModeStatementList(node.statements); } return; - case 212 /* ClassDeclaration */: - case 184 /* ClassExpression */: + case 214 /* ClassDeclaration */: + case 186 /* ClassExpression */: // All classes are automatically in strict mode in ES6. inStrictMode = true; return; @@ -4739,107 +4774,130 @@ var ts; } function bindWorker(node) { switch (node.kind) { - case 67 /* Identifier */: + /* Strict mode checks */ + case 69 /* Identifier */: return checkStrictModeIdentifier(node); - case 179 /* BinaryExpression */: + case 181 /* BinaryExpression */: + if (isJavaScriptFile) { + if (ts.isExportsPropertyAssignment(node)) { + bindExportsPropertyAssignment(node); + } + else if (ts.isModuleExportsAssignment(node)) { + bindModuleExportsAssignment(node); + } + } return checkStrictModeBinaryExpression(node); - case 242 /* CatchClause */: + case 244 /* CatchClause */: return checkStrictModeCatchClause(node); - case 173 /* DeleteExpression */: + case 175 /* DeleteExpression */: return checkStrictModeDeleteExpression(node); case 8 /* NumericLiteral */: return checkStrictModeNumericLiteral(node); - case 178 /* PostfixUnaryExpression */: + case 180 /* PostfixUnaryExpression */: return checkStrictModePostfixUnaryExpression(node); - case 177 /* PrefixUnaryExpression */: + case 179 /* PrefixUnaryExpression */: return checkStrictModePrefixUnaryExpression(node); - case 203 /* WithStatement */: + case 205 /* WithStatement */: return checkStrictModeWithStatement(node); - case 135 /* TypeParameter */: + case 97 /* ThisKeyword */: + seenThisKeyword = true; + return; + case 137 /* TypeParameter */: return declareSymbolAndAddToSymbolTable(node, 262144 /* TypeParameter */, 530912 /* TypeParameterExcludes */); - case 136 /* Parameter */: + case 138 /* Parameter */: return bindParameter(node); - case 209 /* VariableDeclaration */: - case 161 /* BindingElement */: + case 211 /* VariableDeclaration */: + case 163 /* BindingElement */: return bindVariableDeclarationOrBindingElement(node); - case 139 /* PropertyDeclaration */: - case 138 /* PropertySignature */: + case 141 /* PropertyDeclaration */: + case 140 /* PropertySignature */: return bindPropertyOrMethodOrAccessor(node, 4 /* Property */ | (node.questionToken ? 536870912 /* Optional */ : 0 /* None */), 107455 /* PropertyExcludes */); - case 243 /* PropertyAssignment */: - case 244 /* ShorthandPropertyAssignment */: + case 245 /* PropertyAssignment */: + case 246 /* ShorthandPropertyAssignment */: return bindPropertyOrMethodOrAccessor(node, 4 /* Property */, 107455 /* PropertyExcludes */); - case 245 /* EnumMember */: + case 247 /* EnumMember */: return bindPropertyOrMethodOrAccessor(node, 8 /* EnumMember */, 107455 /* EnumMemberExcludes */); - case 145 /* CallSignature */: - case 146 /* ConstructSignature */: - case 147 /* IndexSignature */: + case 147 /* CallSignature */: + case 148 /* ConstructSignature */: + case 149 /* IndexSignature */: return declareSymbolAndAddToSymbolTable(node, 131072 /* Signature */, 0 /* None */); - case 141 /* MethodDeclaration */: - case 140 /* MethodSignature */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: // If this is an ObjectLiteralExpression method, then it sits in the same space // as other properties in the object literal. So we use SymbolFlags.PropertyExcludes // so that it will conflict with any other object literal members with the same // name. return bindPropertyOrMethodOrAccessor(node, 8192 /* Method */ | (node.questionToken ? 536870912 /* Optional */ : 0 /* None */), ts.isObjectLiteralMethod(node) ? 107455 /* PropertyExcludes */ : 99263 /* MethodExcludes */); - case 211 /* FunctionDeclaration */: + case 213 /* FunctionDeclaration */: checkStrictModeFunctionName(node); return declareSymbolAndAddToSymbolTable(node, 16 /* Function */, 106927 /* FunctionExcludes */); - case 142 /* Constructor */: + case 144 /* Constructor */: return declareSymbolAndAddToSymbolTable(node, 16384 /* Constructor */, /*symbolExcludes:*/ 0 /* None */); - case 143 /* GetAccessor */: + case 145 /* GetAccessor */: return bindPropertyOrMethodOrAccessor(node, 32768 /* GetAccessor */, 41919 /* GetAccessorExcludes */); - case 144 /* SetAccessor */: + case 146 /* SetAccessor */: return bindPropertyOrMethodOrAccessor(node, 65536 /* SetAccessor */, 74687 /* SetAccessorExcludes */); - case 150 /* FunctionType */: - case 151 /* ConstructorType */: + case 152 /* FunctionType */: + case 153 /* ConstructorType */: return bindFunctionOrConstructorType(node); - case 153 /* TypeLiteral */: + case 155 /* TypeLiteral */: return bindAnonymousDeclaration(node, 2048 /* TypeLiteral */, "__type"); - case 163 /* ObjectLiteralExpression */: + case 165 /* ObjectLiteralExpression */: return bindObjectLiteralExpression(node); - case 171 /* FunctionExpression */: - case 172 /* ArrowFunction */: + case 173 /* FunctionExpression */: + case 174 /* ArrowFunction */: checkStrictModeFunctionName(node); var bindingName = node.name ? node.name.text : "__function"; return bindAnonymousDeclaration(node, 16 /* Function */, bindingName); - case 184 /* ClassExpression */: - case 212 /* ClassDeclaration */: + case 168 /* CallExpression */: + if (isJavaScriptFile) { + bindCallExpression(node); + } + break; + // Members of classes, interfaces, and modules + case 186 /* ClassExpression */: + case 214 /* ClassDeclaration */: return bindClassLikeDeclaration(node); - case 213 /* InterfaceDeclaration */: + case 215 /* InterfaceDeclaration */: return bindBlockScopedDeclaration(node, 64 /* Interface */, 792960 /* InterfaceExcludes */); - case 214 /* TypeAliasDeclaration */: + case 216 /* TypeAliasDeclaration */: return bindBlockScopedDeclaration(node, 524288 /* TypeAlias */, 793056 /* TypeAliasExcludes */); - case 215 /* EnumDeclaration */: + case 217 /* EnumDeclaration */: return bindEnumDeclaration(node); - case 216 /* ModuleDeclaration */: + case 218 /* ModuleDeclaration */: return bindModuleDeclaration(node); - case 219 /* ImportEqualsDeclaration */: - case 222 /* NamespaceImport */: - case 224 /* ImportSpecifier */: - case 228 /* ExportSpecifier */: + // Imports and exports + case 221 /* ImportEqualsDeclaration */: + case 224 /* NamespaceImport */: + case 226 /* ImportSpecifier */: + case 230 /* ExportSpecifier */: return declareSymbolAndAddToSymbolTable(node, 8388608 /* Alias */, 8388608 /* AliasExcludes */); - case 221 /* ImportClause */: + case 223 /* ImportClause */: return bindImportClause(node); - case 226 /* ExportDeclaration */: + case 228 /* ExportDeclaration */: return bindExportDeclaration(node); - case 225 /* ExportAssignment */: + case 227 /* ExportAssignment */: return bindExportAssignment(node); - case 246 /* SourceFile */: + case 248 /* SourceFile */: return bindSourceFileIfExternalModule(); } } function bindSourceFileIfExternalModule() { setExportContextFlag(file); if (ts.isExternalModule(file)) { - bindAnonymousDeclaration(file, 512 /* ValueModule */, "\"" + ts.removeFileExtension(file.fileName) + "\""); + bindSourceFileAsExternalModule(); } } + function bindSourceFileAsExternalModule() { + bindAnonymousDeclaration(file, 512 /* ValueModule */, "\"" + ts.removeFileExtension(file.fileName) + "\""); + } function bindExportAssignment(node) { + var boundExpression = node.kind === 227 /* ExportAssignment */ ? node.expression : node.right; if (!container.symbol || !container.symbol.exports) { // Export assignment in some sort of block construct bindAnonymousDeclaration(node, 8388608 /* Alias */, getDeclarationName(node)); } - else if (node.expression.kind === 67 /* Identifier */) { + else if (boundExpression.kind === 69 /* Identifier */) { // An export default clause with an identifier exports all meanings of that identifier declareSymbol(container.symbol.exports, container.symbol, node, 8388608 /* Alias */, 107455 /* PropertyExcludes */ | 8388608 /* AliasExcludes */); } @@ -4863,8 +4921,32 @@ var ts; declareSymbolAndAddToSymbolTable(node, 8388608 /* Alias */, 8388608 /* AliasExcludes */); } } + function setCommonJsModuleIndicator(node) { + if (!file.commonJsModuleIndicator) { + file.commonJsModuleIndicator = node; + bindSourceFileAsExternalModule(); + } + } + function bindExportsPropertyAssignment(node) { + // When we create a property via 'exports.foo = bar', the 'exports.foo' property access + // expression is the declaration + setCommonJsModuleIndicator(node); + declareSymbol(file.symbol.exports, file.symbol, node.left, 4 /* Property */ | 7340032 /* Export */, 0 /* None */); + } + function bindModuleExportsAssignment(node) { + // 'module.exports = expr' assignment + setCommonJsModuleIndicator(node); + bindExportAssignment(node); + } + function bindCallExpression(node) { + // We're only inspecting call expressions to detect CommonJS modules, so we can skip + // this check if we've already seen the module indicator + if (!file.commonJsModuleIndicator && ts.isRequireCall(node)) { + setCommonJsModuleIndicator(node); + } + } function bindClassLikeDeclaration(node) { - if (node.kind === 212 /* ClassDeclaration */) { + if (node.kind === 214 /* ClassDeclaration */) { bindBlockScopedDeclaration(node, 32 /* Class */, 899519 /* ClassExcludes */); } else { @@ -4940,7 +5022,7 @@ var ts; // If this is a property-parameter, then also declare the property symbol into the // containing class. if (node.flags & 112 /* AccessibilityModifier */ && - node.parent.kind === 142 /* Constructor */ && + node.parent.kind === 144 /* Constructor */ && ts.isClassLike(node.parent.parent)) { var classDeclaration = node.parent.parent; declareSymbol(classDeclaration.symbol.members, classDeclaration.symbol, node, 4 /* Property */, 107455 /* PropertyExcludes */); @@ -4992,7 +5074,8 @@ var ts; increaseIndent: function () { }, decreaseIndent: function () { }, clear: function () { return str = ""; }, - trackSymbol: function () { } + trackSymbol: function () { }, + reportInaccessibleThisError: function () { } }; } return stringWriters.pop(); @@ -5062,7 +5145,7 @@ var ts; } } function getSourceFileOfNode(node) { - while (node && node.kind !== 246 /* SourceFile */) { + while (node && node.kind !== 248 /* SourceFile */) { node = node.parent; } return node; @@ -5174,15 +5257,15 @@ var ts; return current; } switch (current.kind) { - case 246 /* SourceFile */: - case 218 /* CaseBlock */: - case 242 /* CatchClause */: - case 216 /* ModuleDeclaration */: - case 197 /* ForStatement */: - case 198 /* ForInStatement */: - case 199 /* ForOfStatement */: + case 248 /* SourceFile */: + case 220 /* CaseBlock */: + case 244 /* CatchClause */: + case 218 /* ModuleDeclaration */: + case 199 /* ForStatement */: + case 200 /* ForInStatement */: + case 201 /* ForOfStatement */: return current; - case 190 /* Block */: + case 192 /* Block */: // function block is not considered block-scope container // see comment in binder.ts: bind(...), case for SyntaxKind.Block if (!isFunctionLike(current.parent)) { @@ -5195,9 +5278,9 @@ var ts; ts.getEnclosingBlockScopeContainer = getEnclosingBlockScopeContainer; function isCatchClauseVariableDeclaration(declaration) { return declaration && - declaration.kind === 209 /* VariableDeclaration */ && + declaration.kind === 211 /* VariableDeclaration */ && declaration.parent && - declaration.parent.kind === 242 /* CatchClause */; + declaration.parent.kind === 244 /* CatchClause */; } ts.isCatchClauseVariableDeclaration = isCatchClauseVariableDeclaration; // Return display name of an identifier @@ -5236,7 +5319,7 @@ var ts; function getErrorSpanForNode(sourceFile, node) { var errorNode = node; switch (node.kind) { - case 246 /* SourceFile */: + case 248 /* SourceFile */: var pos_1 = ts.skipTrivia(sourceFile.text, 0, /*stopAfterLineBreak*/ false); if (pos_1 === sourceFile.text.length) { // file is empty - return span for the beginning of the file @@ -5245,16 +5328,16 @@ var ts; return getSpanOfTokenAtPosition(sourceFile, pos_1); // This list is a work in progress. Add missing node kinds to improve their error // spans. - case 209 /* VariableDeclaration */: - case 161 /* BindingElement */: - case 212 /* ClassDeclaration */: - case 184 /* ClassExpression */: - case 213 /* InterfaceDeclaration */: - case 216 /* ModuleDeclaration */: - case 215 /* EnumDeclaration */: - case 245 /* EnumMember */: - case 211 /* FunctionDeclaration */: - case 171 /* FunctionExpression */: + case 211 /* VariableDeclaration */: + case 163 /* BindingElement */: + case 214 /* ClassDeclaration */: + case 186 /* ClassExpression */: + case 215 /* InterfaceDeclaration */: + case 218 /* ModuleDeclaration */: + case 217 /* EnumDeclaration */: + case 247 /* EnumMember */: + case 213 /* FunctionDeclaration */: + case 173 /* FunctionExpression */: errorNode = node.name; break; } @@ -5273,16 +5356,20 @@ var ts; return file.externalModuleIndicator !== undefined; } ts.isExternalModule = isExternalModule; + function isExternalOrCommonJsModule(file) { + return (file.externalModuleIndicator || file.commonJsModuleIndicator) !== undefined; + } + ts.isExternalOrCommonJsModule = isExternalOrCommonJsModule; function isDeclarationFile(file) { return (file.flags & 8192 /* DeclarationFile */) !== 0; } ts.isDeclarationFile = isDeclarationFile; function isConstEnumDeclaration(node) { - return node.kind === 215 /* EnumDeclaration */ && isConst(node); + return node.kind === 217 /* EnumDeclaration */ && isConst(node); } ts.isConstEnumDeclaration = isConstEnumDeclaration; function walkUpBindingElementsAndPatterns(node) { - while (node && (node.kind === 161 /* BindingElement */ || isBindingPattern(node))) { + while (node && (node.kind === 163 /* BindingElement */ || isBindingPattern(node))) { node = node.parent; } return node; @@ -5297,14 +5384,14 @@ var ts; function getCombinedNodeFlags(node) { node = walkUpBindingElementsAndPatterns(node); var flags = node.flags; - if (node.kind === 209 /* VariableDeclaration */) { + if (node.kind === 211 /* VariableDeclaration */) { node = node.parent; } - if (node && node.kind === 210 /* VariableDeclarationList */) { + if (node && node.kind === 212 /* VariableDeclarationList */) { flags |= node.flags; node = node.parent; } - if (node && node.kind === 191 /* VariableStatement */) { + if (node && node.kind === 193 /* VariableStatement */) { flags |= node.flags; } return flags; @@ -5319,7 +5406,7 @@ var ts; } ts.isLet = isLet; function isPrologueDirective(node) { - return node.kind === 193 /* ExpressionStatement */ && node.expression.kind === 9 /* StringLiteral */; + return node.kind === 195 /* ExpressionStatement */ && node.expression.kind === 9 /* StringLiteral */; } ts.isPrologueDirective = isPrologueDirective; function getLeadingCommentRangesOfNode(node, sourceFileOfNode) { @@ -5327,7 +5414,7 @@ var ts; } ts.getLeadingCommentRangesOfNode = getLeadingCommentRangesOfNode; function getJsDocComments(node, sourceFileOfNode) { - var commentRanges = (node.kind === 136 /* Parameter */ || node.kind === 135 /* TypeParameter */) ? + var commentRanges = (node.kind === 138 /* Parameter */ || node.kind === 137 /* TypeParameter */) ? ts.concatenate(ts.getTrailingCommentRanges(sourceFileOfNode.text, node.pos), ts.getLeadingCommentRanges(sourceFileOfNode.text, node.pos)) : getLeadingCommentRangesOfNode(node, sourceFileOfNode); return ts.filter(commentRanges, isJsDocComment); @@ -5342,40 +5429,40 @@ var ts; ts.fullTripleSlashReferencePathRegEx = /^(\/\/\/\s*/; ts.fullTripleSlashAMDReferencePathRegEx = /^(\/\/\/\s*/; function isTypeNode(node) { - if (149 /* FirstTypeNode */ <= node.kind && node.kind <= 158 /* LastTypeNode */) { + if (151 /* FirstTypeNode */ <= node.kind && node.kind <= 160 /* LastTypeNode */) { return true; } switch (node.kind) { - case 115 /* AnyKeyword */: - case 126 /* NumberKeyword */: - case 128 /* StringKeyword */: - case 118 /* BooleanKeyword */: - case 129 /* SymbolKeyword */: + case 117 /* AnyKeyword */: + case 128 /* NumberKeyword */: + case 130 /* StringKeyword */: + case 120 /* BooleanKeyword */: + case 131 /* SymbolKeyword */: return true; - case 101 /* VoidKeyword */: - return node.parent.kind !== 175 /* VoidExpression */; + case 103 /* VoidKeyword */: + return node.parent.kind !== 177 /* VoidExpression */; case 9 /* StringLiteral */: // Specialized signatures can have string literals as their parameters' type names - return node.parent.kind === 136 /* Parameter */; - case 186 /* ExpressionWithTypeArguments */: + return node.parent.kind === 138 /* Parameter */; + case 188 /* ExpressionWithTypeArguments */: return !isExpressionWithTypeArgumentsInClassExtendsClause(node); // Identifiers and qualified names may be type nodes, depending on their context. Climb // above them to find the lowest container - case 67 /* Identifier */: + case 69 /* Identifier */: // If the identifier is the RHS of a qualified name, then it's a type iff its parent is. - if (node.parent.kind === 133 /* QualifiedName */ && node.parent.right === node) { + if (node.parent.kind === 135 /* QualifiedName */ && node.parent.right === node) { node = node.parent; } - else if (node.parent.kind === 164 /* PropertyAccessExpression */ && node.parent.name === node) { + else if (node.parent.kind === 166 /* PropertyAccessExpression */ && node.parent.name === node) { node = node.parent; } - // fall through - case 133 /* QualifiedName */: - case 164 /* PropertyAccessExpression */: // At this point, node is either a qualified name or an identifier - ts.Debug.assert(node.kind === 67 /* Identifier */ || node.kind === 133 /* QualifiedName */ || node.kind === 164 /* PropertyAccessExpression */, "'node' was expected to be a qualified name, identifier or property access in 'isTypeNode'."); + ts.Debug.assert(node.kind === 69 /* Identifier */ || node.kind === 135 /* QualifiedName */ || node.kind === 166 /* PropertyAccessExpression */, "'node' was expected to be a qualified name, identifier or property access in 'isTypeNode'."); + case 135 /* QualifiedName */: + case 166 /* PropertyAccessExpression */: + case 97 /* ThisKeyword */: var parent_1 = node.parent; - if (parent_1.kind === 152 /* TypeQuery */) { + if (parent_1.kind === 154 /* TypeQuery */) { return false; } // Do not recursively call isTypeNode on the parent. In the example: @@ -5384,38 +5471,38 @@ var ts; // // Calling isTypeNode would consider the qualified name A.B a type node. Only C or // A.B.C is a type node. - if (149 /* FirstTypeNode */ <= parent_1.kind && parent_1.kind <= 158 /* LastTypeNode */) { + if (151 /* FirstTypeNode */ <= parent_1.kind && parent_1.kind <= 160 /* LastTypeNode */) { return true; } switch (parent_1.kind) { - case 186 /* ExpressionWithTypeArguments */: + case 188 /* ExpressionWithTypeArguments */: return !isExpressionWithTypeArgumentsInClassExtendsClause(parent_1); - case 135 /* TypeParameter */: + case 137 /* TypeParameter */: return node === parent_1.constraint; - case 139 /* PropertyDeclaration */: - case 138 /* PropertySignature */: - case 136 /* Parameter */: - case 209 /* VariableDeclaration */: + case 141 /* PropertyDeclaration */: + case 140 /* PropertySignature */: + case 138 /* Parameter */: + case 211 /* VariableDeclaration */: return node === parent_1.type; - case 211 /* FunctionDeclaration */: - case 171 /* FunctionExpression */: - case 172 /* ArrowFunction */: - case 142 /* Constructor */: - case 141 /* MethodDeclaration */: - case 140 /* MethodSignature */: - case 143 /* GetAccessor */: - case 144 /* SetAccessor */: + case 213 /* FunctionDeclaration */: + case 173 /* FunctionExpression */: + case 174 /* ArrowFunction */: + case 144 /* Constructor */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: return node === parent_1.type; - case 145 /* CallSignature */: - case 146 /* ConstructSignature */: - case 147 /* IndexSignature */: + case 147 /* CallSignature */: + case 148 /* ConstructSignature */: + case 149 /* IndexSignature */: return node === parent_1.type; - case 169 /* TypeAssertionExpression */: + case 171 /* TypeAssertionExpression */: return node === parent_1.type; - case 166 /* CallExpression */: - case 167 /* NewExpression */: + case 168 /* CallExpression */: + case 169 /* NewExpression */: return parent_1.typeArguments && ts.indexOf(parent_1.typeArguments, node) >= 0; - case 168 /* TaggedTemplateExpression */: + case 170 /* TaggedTemplateExpression */: // TODO (drosen): TaggedTemplateExpressions may eventually support type arguments. return false; } @@ -5429,23 +5516,23 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 202 /* ReturnStatement */: + case 204 /* ReturnStatement */: return visitor(node); - case 218 /* CaseBlock */: - case 190 /* Block */: - case 194 /* IfStatement */: - case 195 /* DoStatement */: - case 196 /* WhileStatement */: - case 197 /* ForStatement */: - case 198 /* ForInStatement */: - case 199 /* ForOfStatement */: - case 203 /* WithStatement */: - case 204 /* SwitchStatement */: - case 239 /* CaseClause */: - case 240 /* DefaultClause */: - case 205 /* LabeledStatement */: - case 207 /* TryStatement */: - case 242 /* CatchClause */: + case 220 /* CaseBlock */: + case 192 /* Block */: + case 196 /* IfStatement */: + case 197 /* DoStatement */: + case 198 /* WhileStatement */: + case 199 /* ForStatement */: + case 200 /* ForInStatement */: + case 201 /* ForOfStatement */: + case 205 /* WithStatement */: + case 206 /* SwitchStatement */: + case 241 /* CaseClause */: + case 242 /* DefaultClause */: + case 207 /* LabeledStatement */: + case 209 /* TryStatement */: + case 244 /* CatchClause */: return ts.forEachChild(node, traverse); } } @@ -5455,18 +5542,18 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 182 /* YieldExpression */: + case 184 /* YieldExpression */: visitor(node); var operand = node.expression; if (operand) { traverse(operand); } - case 215 /* EnumDeclaration */: - case 213 /* InterfaceDeclaration */: - case 216 /* ModuleDeclaration */: - case 214 /* TypeAliasDeclaration */: - case 212 /* ClassDeclaration */: - case 184 /* ClassExpression */: + case 217 /* EnumDeclaration */: + case 215 /* InterfaceDeclaration */: + case 218 /* ModuleDeclaration */: + case 216 /* TypeAliasDeclaration */: + case 214 /* ClassDeclaration */: + case 186 /* ClassExpression */: // These are not allowed inside a generator now, but eventually they may be allowed // as local types. Regardless, any yield statements contained within them should be // skipped in this traversal. @@ -5474,7 +5561,7 @@ var ts; default: if (isFunctionLike(node)) { var name_5 = node.name; - if (name_5 && name_5.kind === 134 /* ComputedPropertyName */) { + if (name_5 && name_5.kind === 136 /* ComputedPropertyName */) { // Note that we will not include methods/accessors of a class because they would require // first descending into the class. This is by design. traverse(name_5.expression); @@ -5493,14 +5580,14 @@ var ts; function isVariableLike(node) { if (node) { switch (node.kind) { - case 161 /* BindingElement */: - case 245 /* EnumMember */: - case 136 /* Parameter */: - case 243 /* PropertyAssignment */: - case 139 /* PropertyDeclaration */: - case 138 /* PropertySignature */: - case 244 /* ShorthandPropertyAssignment */: - case 209 /* VariableDeclaration */: + case 163 /* BindingElement */: + case 247 /* EnumMember */: + case 138 /* Parameter */: + case 245 /* PropertyAssignment */: + case 141 /* PropertyDeclaration */: + case 140 /* PropertySignature */: + case 246 /* ShorthandPropertyAssignment */: + case 211 /* VariableDeclaration */: return true; } } @@ -5508,29 +5595,29 @@ var ts; } ts.isVariableLike = isVariableLike; function isAccessor(node) { - return node && (node.kind === 143 /* GetAccessor */ || node.kind === 144 /* SetAccessor */); + return node && (node.kind === 145 /* GetAccessor */ || node.kind === 146 /* SetAccessor */); } ts.isAccessor = isAccessor; function isClassLike(node) { - return node && (node.kind === 212 /* ClassDeclaration */ || node.kind === 184 /* ClassExpression */); + return node && (node.kind === 214 /* ClassDeclaration */ || node.kind === 186 /* ClassExpression */); } ts.isClassLike = isClassLike; function isFunctionLike(node) { if (node) { switch (node.kind) { - case 142 /* Constructor */: - case 171 /* FunctionExpression */: - case 211 /* FunctionDeclaration */: - case 172 /* ArrowFunction */: - case 141 /* MethodDeclaration */: - case 140 /* MethodSignature */: - case 143 /* GetAccessor */: - case 144 /* SetAccessor */: - case 145 /* CallSignature */: - case 146 /* ConstructSignature */: - case 147 /* IndexSignature */: - case 150 /* FunctionType */: - case 151 /* ConstructorType */: + case 144 /* Constructor */: + case 173 /* FunctionExpression */: + case 213 /* FunctionDeclaration */: + case 174 /* ArrowFunction */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: + case 147 /* CallSignature */: + case 148 /* ConstructSignature */: + case 149 /* IndexSignature */: + case 152 /* FunctionType */: + case 153 /* ConstructorType */: return true; } } @@ -5539,24 +5626,24 @@ var ts; ts.isFunctionLike = isFunctionLike; function introducesArgumentsExoticObject(node) { switch (node.kind) { - case 141 /* MethodDeclaration */: - case 140 /* MethodSignature */: - case 142 /* Constructor */: - case 143 /* GetAccessor */: - case 144 /* SetAccessor */: - case 211 /* FunctionDeclaration */: - case 171 /* FunctionExpression */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: + case 144 /* Constructor */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: + case 213 /* FunctionDeclaration */: + case 173 /* FunctionExpression */: return true; } return false; } ts.introducesArgumentsExoticObject = introducesArgumentsExoticObject; function isFunctionBlock(node) { - return node && node.kind === 190 /* Block */ && isFunctionLike(node.parent); + return node && node.kind === 192 /* Block */ && isFunctionLike(node.parent); } ts.isFunctionBlock = isFunctionBlock; function isObjectLiteralMethod(node) { - return node && node.kind === 141 /* MethodDeclaration */ && node.parent.kind === 163 /* ObjectLiteralExpression */; + return node && node.kind === 143 /* MethodDeclaration */ && node.parent.kind === 165 /* ObjectLiteralExpression */; } ts.isObjectLiteralMethod = isObjectLiteralMethod; function getContainingFunction(node) { @@ -5584,7 +5671,7 @@ var ts; return undefined; } switch (node.kind) { - case 134 /* ComputedPropertyName */: + case 136 /* ComputedPropertyName */: // If the grandparent node is an object literal (as opposed to a class), // then the computed property is not a 'this' container. // A computed property name in a class needs to be a this container @@ -5599,9 +5686,9 @@ var ts; // the *body* of the container. node = node.parent; break; - case 137 /* Decorator */: + case 139 /* Decorator */: // Decorators are always applied outside of the body of a class or method. - if (node.parent.kind === 136 /* Parameter */ && isClassElement(node.parent.parent)) { + if (node.parent.kind === 138 /* Parameter */ && isClassElement(node.parent.parent)) { // If the decorator's parent is a Parameter, we resolve the this container from // the grandparent class declaration. node = node.parent.parent; @@ -5612,23 +5699,26 @@ var ts; node = node.parent; } break; - case 172 /* ArrowFunction */: + case 174 /* ArrowFunction */: if (!includeArrowFunctions) { continue; } // Fall through - case 211 /* FunctionDeclaration */: - case 171 /* FunctionExpression */: - case 216 /* ModuleDeclaration */: - case 139 /* PropertyDeclaration */: - case 138 /* PropertySignature */: - case 141 /* MethodDeclaration */: - case 140 /* MethodSignature */: - case 142 /* Constructor */: - case 143 /* GetAccessor */: - case 144 /* SetAccessor */: - case 215 /* EnumDeclaration */: - case 246 /* SourceFile */: + case 213 /* FunctionDeclaration */: + case 173 /* FunctionExpression */: + case 218 /* ModuleDeclaration */: + case 141 /* PropertyDeclaration */: + case 140 /* PropertySignature */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: + case 144 /* Constructor */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: + case 147 /* CallSignature */: + case 148 /* ConstructSignature */: + case 149 /* IndexSignature */: + case 217 /* EnumDeclaration */: + case 248 /* SourceFile */: return node; } } @@ -5640,7 +5730,7 @@ var ts; if (!node) return node; switch (node.kind) { - case 134 /* ComputedPropertyName */: + case 136 /* ComputedPropertyName */: // If the grandparent node is an object literal (as opposed to a class), // then the computed property is not a 'super' container. // A computed property name in a class needs to be a super container @@ -5655,9 +5745,9 @@ var ts; // the *body* of the container. node = node.parent; break; - case 137 /* Decorator */: + case 139 /* Decorator */: // Decorators are always applied outside of the body of a class or method. - if (node.parent.kind === 136 /* Parameter */ && isClassElement(node.parent.parent)) { + if (node.parent.kind === 138 /* Parameter */ && isClassElement(node.parent.parent)) { // If the decorator's parent is a Parameter, we resolve the this container from // the grandparent class declaration. node = node.parent.parent; @@ -5668,19 +5758,19 @@ var ts; node = node.parent; } break; - case 211 /* FunctionDeclaration */: - case 171 /* FunctionExpression */: - case 172 /* ArrowFunction */: + case 213 /* FunctionDeclaration */: + case 173 /* FunctionExpression */: + case 174 /* ArrowFunction */: if (!includeFunctions) { continue; } - case 139 /* PropertyDeclaration */: - case 138 /* PropertySignature */: - case 141 /* MethodDeclaration */: - case 140 /* MethodSignature */: - case 142 /* Constructor */: - case 143 /* GetAccessor */: - case 144 /* SetAccessor */: + case 141 /* PropertyDeclaration */: + case 140 /* PropertySignature */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: + case 144 /* Constructor */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: return node; } } @@ -5689,12 +5779,12 @@ var ts; function getEntityNameFromTypeNode(node) { if (node) { switch (node.kind) { - case 149 /* TypeReference */: + case 151 /* TypeReference */: return node.typeName; - case 186 /* ExpressionWithTypeArguments */: + case 188 /* ExpressionWithTypeArguments */: return node.expression; - case 67 /* Identifier */: - case 133 /* QualifiedName */: + case 69 /* Identifier */: + case 135 /* QualifiedName */: return node; } } @@ -5702,7 +5792,7 @@ var ts; } ts.getEntityNameFromTypeNode = getEntityNameFromTypeNode; function getInvokedExpression(node) { - if (node.kind === 168 /* TaggedTemplateExpression */) { + if (node.kind === 170 /* TaggedTemplateExpression */) { return node.tag; } // Will either be a CallExpression, NewExpression, or Decorator. @@ -5711,44 +5801,44 @@ var ts; ts.getInvokedExpression = getInvokedExpression; function nodeCanBeDecorated(node) { switch (node.kind) { - case 212 /* ClassDeclaration */: + case 214 /* ClassDeclaration */: // classes are valid targets return true; - case 139 /* PropertyDeclaration */: + case 141 /* PropertyDeclaration */: // property declarations are valid if their parent is a class declaration. - return node.parent.kind === 212 /* ClassDeclaration */; - case 136 /* Parameter */: + return node.parent.kind === 214 /* ClassDeclaration */; + case 138 /* Parameter */: // if the parameter's parent has a body and its grandparent is a class declaration, this is a valid target; - return node.parent.body && node.parent.parent.kind === 212 /* ClassDeclaration */; - case 143 /* GetAccessor */: - case 144 /* SetAccessor */: - case 141 /* MethodDeclaration */: + return node.parent.body && node.parent.parent.kind === 214 /* ClassDeclaration */; + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: + case 143 /* MethodDeclaration */: // if this method has a body and its parent is a class declaration, this is a valid target. - return node.body && node.parent.kind === 212 /* ClassDeclaration */; + return node.body && node.parent.kind === 214 /* ClassDeclaration */; } return false; } ts.nodeCanBeDecorated = nodeCanBeDecorated; function nodeIsDecorated(node) { switch (node.kind) { - case 212 /* ClassDeclaration */: + case 214 /* ClassDeclaration */: if (node.decorators) { return true; } return false; - case 139 /* PropertyDeclaration */: - case 136 /* Parameter */: + case 141 /* PropertyDeclaration */: + case 138 /* Parameter */: if (node.decorators) { return true; } return false; - case 143 /* GetAccessor */: + case 145 /* GetAccessor */: if (node.body && node.decorators) { return true; } return false; - case 141 /* MethodDeclaration */: - case 144 /* SetAccessor */: + case 143 /* MethodDeclaration */: + case 146 /* SetAccessor */: if (node.body && node.decorators) { return true; } @@ -5759,10 +5849,10 @@ var ts; ts.nodeIsDecorated = nodeIsDecorated; function childIsDecorated(node) { switch (node.kind) { - case 212 /* ClassDeclaration */: + case 214 /* ClassDeclaration */: return ts.forEach(node.members, nodeOrChildIsDecorated); - case 141 /* MethodDeclaration */: - case 144 /* SetAccessor */: + case 143 /* MethodDeclaration */: + case 146 /* SetAccessor */: return ts.forEach(node.parameters, nodeIsDecorated); } return false; @@ -5772,96 +5862,106 @@ var ts; return nodeIsDecorated(node) || childIsDecorated(node); } ts.nodeOrChildIsDecorated = nodeOrChildIsDecorated; + function isPropertyAccessExpression(node) { + return node.kind === 166 /* PropertyAccessExpression */; + } + ts.isPropertyAccessExpression = isPropertyAccessExpression; + function isElementAccessExpression(node) { + return node.kind === 167 /* ElementAccessExpression */; + } + ts.isElementAccessExpression = isElementAccessExpression; function isExpression(node) { switch (node.kind) { - case 95 /* ThisKeyword */: - case 93 /* SuperKeyword */: - case 91 /* NullKeyword */: - case 97 /* TrueKeyword */: - case 82 /* FalseKeyword */: + case 95 /* SuperKeyword */: + case 93 /* NullKeyword */: + case 99 /* TrueKeyword */: + case 84 /* FalseKeyword */: case 10 /* RegularExpressionLiteral */: - case 162 /* ArrayLiteralExpression */: - case 163 /* ObjectLiteralExpression */: - case 164 /* PropertyAccessExpression */: - case 165 /* ElementAccessExpression */: - case 166 /* CallExpression */: - case 167 /* NewExpression */: - case 168 /* TaggedTemplateExpression */: - case 187 /* AsExpression */: - case 169 /* TypeAssertionExpression */: - case 170 /* ParenthesizedExpression */: - case 171 /* FunctionExpression */: - case 184 /* ClassExpression */: - case 172 /* ArrowFunction */: - case 175 /* VoidExpression */: - case 173 /* DeleteExpression */: - case 174 /* TypeOfExpression */: - case 177 /* PrefixUnaryExpression */: - case 178 /* PostfixUnaryExpression */: - case 179 /* BinaryExpression */: - case 180 /* ConditionalExpression */: - case 183 /* SpreadElementExpression */: - case 181 /* TemplateExpression */: + case 164 /* ArrayLiteralExpression */: + case 165 /* ObjectLiteralExpression */: + case 166 /* PropertyAccessExpression */: + case 167 /* ElementAccessExpression */: + case 168 /* CallExpression */: + case 169 /* NewExpression */: + case 170 /* TaggedTemplateExpression */: + case 189 /* AsExpression */: + case 171 /* TypeAssertionExpression */: + case 172 /* ParenthesizedExpression */: + case 173 /* FunctionExpression */: + case 186 /* ClassExpression */: + case 174 /* ArrowFunction */: + case 177 /* VoidExpression */: + case 175 /* DeleteExpression */: + case 176 /* TypeOfExpression */: + case 179 /* PrefixUnaryExpression */: + case 180 /* PostfixUnaryExpression */: + case 181 /* BinaryExpression */: + case 182 /* ConditionalExpression */: + case 185 /* SpreadElementExpression */: + case 183 /* TemplateExpression */: case 11 /* NoSubstitutionTemplateLiteral */: - case 185 /* OmittedExpression */: - case 231 /* JsxElement */: - case 232 /* JsxSelfClosingElement */: - case 182 /* YieldExpression */: + case 187 /* OmittedExpression */: + case 233 /* JsxElement */: + case 234 /* JsxSelfClosingElement */: + case 184 /* YieldExpression */: + case 178 /* AwaitExpression */: return true; - case 133 /* QualifiedName */: - while (node.parent.kind === 133 /* QualifiedName */) { + case 135 /* QualifiedName */: + while (node.parent.kind === 135 /* QualifiedName */) { node = node.parent; } - return node.parent.kind === 152 /* TypeQuery */; - case 67 /* Identifier */: - if (node.parent.kind === 152 /* TypeQuery */) { + return node.parent.kind === 154 /* TypeQuery */; + case 69 /* Identifier */: + if (node.parent.kind === 154 /* TypeQuery */) { return true; } // fall through case 8 /* NumericLiteral */: case 9 /* StringLiteral */: + case 97 /* ThisKeyword */: var parent_2 = node.parent; switch (parent_2.kind) { - case 209 /* VariableDeclaration */: - case 136 /* Parameter */: - case 139 /* PropertyDeclaration */: - case 138 /* PropertySignature */: - case 245 /* EnumMember */: - case 243 /* PropertyAssignment */: - case 161 /* BindingElement */: + case 211 /* VariableDeclaration */: + case 138 /* Parameter */: + case 141 /* PropertyDeclaration */: + case 140 /* PropertySignature */: + case 247 /* EnumMember */: + case 245 /* PropertyAssignment */: + case 163 /* BindingElement */: return parent_2.initializer === node; - case 193 /* ExpressionStatement */: - case 194 /* IfStatement */: - case 195 /* DoStatement */: - case 196 /* WhileStatement */: - case 202 /* ReturnStatement */: - case 203 /* WithStatement */: - case 204 /* SwitchStatement */: - case 239 /* CaseClause */: - case 206 /* ThrowStatement */: - case 204 /* SwitchStatement */: + case 195 /* ExpressionStatement */: + case 196 /* IfStatement */: + case 197 /* DoStatement */: + case 198 /* WhileStatement */: + case 204 /* ReturnStatement */: + case 205 /* WithStatement */: + case 206 /* SwitchStatement */: + case 241 /* CaseClause */: + case 208 /* ThrowStatement */: + case 206 /* SwitchStatement */: return parent_2.expression === node; - case 197 /* ForStatement */: + case 199 /* ForStatement */: var forStatement = parent_2; - return (forStatement.initializer === node && forStatement.initializer.kind !== 210 /* VariableDeclarationList */) || + return (forStatement.initializer === node && forStatement.initializer.kind !== 212 /* VariableDeclarationList */) || forStatement.condition === node || forStatement.incrementor === node; - case 198 /* ForInStatement */: - case 199 /* ForOfStatement */: + case 200 /* ForInStatement */: + case 201 /* ForOfStatement */: var forInStatement = parent_2; - return (forInStatement.initializer === node && forInStatement.initializer.kind !== 210 /* VariableDeclarationList */) || + return (forInStatement.initializer === node && forInStatement.initializer.kind !== 212 /* VariableDeclarationList */) || forInStatement.expression === node; - case 169 /* TypeAssertionExpression */: - case 187 /* AsExpression */: + case 171 /* TypeAssertionExpression */: + case 189 /* AsExpression */: return node === parent_2.expression; - case 188 /* TemplateSpan */: + case 190 /* TemplateSpan */: return node === parent_2.expression; - case 134 /* ComputedPropertyName */: + case 136 /* ComputedPropertyName */: return node === parent_2.expression; - case 137 /* Decorator */: - case 238 /* JsxExpression */: + case 139 /* Decorator */: + case 240 /* JsxExpression */: + case 239 /* JsxSpreadAttribute */: return true; - case 186 /* ExpressionWithTypeArguments */: + case 188 /* ExpressionWithTypeArguments */: return parent_2.expression === node && isExpressionWithTypeArgumentsInClassExtendsClause(parent_2); default: if (isExpression(parent_2)) { @@ -5872,6 +5972,12 @@ var ts; return false; } ts.isExpression = isExpression; + function isExternalModuleNameRelative(moduleName) { + // TypeScript 1.0 spec (April 2014): 11.2.1 + // An external module name is "relative" if the first term is "." or "..". + return moduleName.substr(0, 2) === "./" || moduleName.substr(0, 3) === "../" || moduleName.substr(0, 2) === ".\\" || moduleName.substr(0, 3) === "..\\"; + } + ts.isExternalModuleNameRelative = isExternalModuleNameRelative; function isInstantiatedModule(node, preserveConstEnums) { var moduleState = ts.getModuleInstanceState(node); return moduleState === 1 /* Instantiated */ || @@ -5879,7 +5985,7 @@ var ts; } ts.isInstantiatedModule = isInstantiatedModule; function isExternalModuleImportEqualsDeclaration(node) { - return node.kind === 219 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 230 /* ExternalModuleReference */; + return node.kind === 221 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 232 /* ExternalModuleReference */; } ts.isExternalModuleImportEqualsDeclaration = isExternalModuleImportEqualsDeclaration; function getExternalModuleImportEqualsDeclarationExpression(node) { @@ -5888,20 +5994,70 @@ var ts; } ts.getExternalModuleImportEqualsDeclarationExpression = getExternalModuleImportEqualsDeclarationExpression; function isInternalModuleImportEqualsDeclaration(node) { - return node.kind === 219 /* ImportEqualsDeclaration */ && node.moduleReference.kind !== 230 /* ExternalModuleReference */; + return node.kind === 221 /* ImportEqualsDeclaration */ && node.moduleReference.kind !== 232 /* ExternalModuleReference */; } ts.isInternalModuleImportEqualsDeclaration = isInternalModuleImportEqualsDeclaration; + function isSourceFileJavaScript(file) { + return isInJavaScriptFile(file); + } + ts.isSourceFileJavaScript = isSourceFileJavaScript; + function isInJavaScriptFile(node) { + return node && !!(node.parserContextFlags & 32 /* JavaScriptFile */); + } + ts.isInJavaScriptFile = isInJavaScriptFile; + /** + * Returns true if the node is a CallExpression to the identifier 'require' with + * exactly one argument. + * This function does not test if the node is in a JavaScript file or not. + */ + function isRequireCall(expression) { + // of the form 'require("name")' + return expression.kind === 168 /* CallExpression */ && + expression.expression.kind === 69 /* Identifier */ && + expression.expression.text === "require" && + expression.arguments.length === 1; + } + ts.isRequireCall = isRequireCall; + /** + * Returns true if the node is an assignment to a property on the identifier 'exports'. + * This function does not test if the node is in a JavaScript file or not. + */ + function isExportsPropertyAssignment(expression) { + // of the form 'exports.name = expr' where 'name' and 'expr' are arbitrary + return isInJavaScriptFile(expression) && + (expression.kind === 181 /* BinaryExpression */) && + (expression.operatorToken.kind === 56 /* EqualsToken */) && + (expression.left.kind === 166 /* PropertyAccessExpression */) && + (expression.left.expression.kind === 69 /* Identifier */) && + ((expression.left.expression).text === "exports"); + } + ts.isExportsPropertyAssignment = isExportsPropertyAssignment; + /** + * Returns true if the node is an assignment to the property access expression 'module.exports'. + * This function does not test if the node is in a JavaScript file or not. + */ + function isModuleExportsAssignment(expression) { + // of the form 'module.exports = expr' where 'expr' is arbitrary + return isInJavaScriptFile(expression) && + (expression.kind === 181 /* BinaryExpression */) && + (expression.operatorToken.kind === 56 /* EqualsToken */) && + (expression.left.kind === 166 /* PropertyAccessExpression */) && + (expression.left.expression.kind === 69 /* Identifier */) && + ((expression.left.expression).text === "module") && + (expression.left.name.text === "exports"); + } + ts.isModuleExportsAssignment = isModuleExportsAssignment; function getExternalModuleName(node) { - if (node.kind === 220 /* ImportDeclaration */) { + if (node.kind === 222 /* ImportDeclaration */) { return node.moduleSpecifier; } - if (node.kind === 219 /* ImportEqualsDeclaration */) { + if (node.kind === 221 /* ImportEqualsDeclaration */) { var reference = node.moduleReference; - if (reference.kind === 230 /* ExternalModuleReference */) { + if (reference.kind === 232 /* ExternalModuleReference */) { return reference.expression; } } - if (node.kind === 226 /* ExportDeclaration */) { + if (node.kind === 228 /* ExportDeclaration */) { return node.moduleSpecifier; } } @@ -5909,13 +6065,13 @@ var ts; function hasQuestionToken(node) { if (node) { switch (node.kind) { - case 136 /* Parameter */: - case 141 /* MethodDeclaration */: - case 140 /* MethodSignature */: - case 244 /* ShorthandPropertyAssignment */: - case 243 /* PropertyAssignment */: - case 139 /* PropertyDeclaration */: - case 138 /* PropertySignature */: + case 138 /* Parameter */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: + case 246 /* ShorthandPropertyAssignment */: + case 245 /* PropertyAssignment */: + case 141 /* PropertyDeclaration */: + case 140 /* PropertySignature */: return node.questionToken !== undefined; } } @@ -5923,9 +6079,9 @@ var ts; } ts.hasQuestionToken = hasQuestionToken; function isJSDocConstructSignature(node) { - return node.kind === 259 /* JSDocFunctionType */ && + return node.kind === 261 /* JSDocFunctionType */ && node.parameters.length > 0 && - node.parameters[0].type.kind === 261 /* JSDocConstructorType */; + node.parameters[0].type.kind === 263 /* JSDocConstructorType */; } ts.isJSDocConstructSignature = isJSDocConstructSignature; function getJSDocTag(node, kind) { @@ -5939,26 +6095,26 @@ var ts; } } function getJSDocTypeTag(node) { - return getJSDocTag(node, 267 /* JSDocTypeTag */); + return getJSDocTag(node, 269 /* JSDocTypeTag */); } ts.getJSDocTypeTag = getJSDocTypeTag; function getJSDocReturnTag(node) { - return getJSDocTag(node, 266 /* JSDocReturnTag */); + return getJSDocTag(node, 268 /* JSDocReturnTag */); } ts.getJSDocReturnTag = getJSDocReturnTag; function getJSDocTemplateTag(node) { - return getJSDocTag(node, 268 /* JSDocTemplateTag */); + return getJSDocTag(node, 270 /* JSDocTemplateTag */); } ts.getJSDocTemplateTag = getJSDocTemplateTag; function getCorrespondingJSDocParameterTag(parameter) { - if (parameter.name && parameter.name.kind === 67 /* Identifier */) { + if (parameter.name && parameter.name.kind === 69 /* Identifier */) { // If it's a parameter, see if the parent has a jsdoc comment with an @param // annotation. var parameterName = parameter.name.text; var docComment = parameter.parent.jsDocComment; if (docComment) { return ts.forEach(docComment.tags, function (t) { - if (t.kind === 265 /* JSDocParameterTag */) { + if (t.kind === 267 /* JSDocParameterTag */) { var parameterTag = t; var name_6 = parameterTag.preParameterName || parameterTag.postParameterName; if (name_6.text === parameterName) { @@ -5977,12 +6133,12 @@ var ts; function isRestParameter(node) { if (node) { if (node.parserContextFlags & 32 /* JavaScriptFile */) { - if (node.type && node.type.kind === 260 /* JSDocVariadicType */) { + if (node.type && node.type.kind === 262 /* JSDocVariadicType */) { return true; } var paramTag = getCorrespondingJSDocParameterTag(node); if (paramTag && paramTag.typeExpression) { - return paramTag.typeExpression.type.kind === 260 /* JSDocVariadicType */; + return paramTag.typeExpression.type.kind === 262 /* JSDocVariadicType */; } } return node.dotDotDotToken !== undefined; @@ -6003,7 +6159,7 @@ var ts; } ts.isTemplateLiteralKind = isTemplateLiteralKind; function isBindingPattern(node) { - return !!node && (node.kind === 160 /* ArrayBindingPattern */ || node.kind === 159 /* ObjectBindingPattern */); + return !!node && (node.kind === 162 /* ArrayBindingPattern */ || node.kind === 161 /* ObjectBindingPattern */); } ts.isBindingPattern = isBindingPattern; function isInAmbientContext(node) { @@ -6018,34 +6174,34 @@ var ts; ts.isInAmbientContext = isInAmbientContext; function isDeclaration(node) { switch (node.kind) { - case 172 /* ArrowFunction */: - case 161 /* BindingElement */: - case 212 /* ClassDeclaration */: - case 184 /* ClassExpression */: - case 142 /* Constructor */: - case 215 /* EnumDeclaration */: - case 245 /* EnumMember */: - case 228 /* ExportSpecifier */: - case 211 /* FunctionDeclaration */: - case 171 /* FunctionExpression */: - case 143 /* GetAccessor */: - case 221 /* ImportClause */: - case 219 /* ImportEqualsDeclaration */: - case 224 /* ImportSpecifier */: - case 213 /* InterfaceDeclaration */: - case 141 /* MethodDeclaration */: - case 140 /* MethodSignature */: - case 216 /* ModuleDeclaration */: - case 222 /* NamespaceImport */: - case 136 /* Parameter */: - case 243 /* PropertyAssignment */: - case 139 /* PropertyDeclaration */: - case 138 /* PropertySignature */: - case 144 /* SetAccessor */: - case 244 /* ShorthandPropertyAssignment */: - case 214 /* TypeAliasDeclaration */: - case 135 /* TypeParameter */: - case 209 /* VariableDeclaration */: + case 174 /* ArrowFunction */: + case 163 /* BindingElement */: + case 214 /* ClassDeclaration */: + case 186 /* ClassExpression */: + case 144 /* Constructor */: + case 217 /* EnumDeclaration */: + case 247 /* EnumMember */: + case 230 /* ExportSpecifier */: + case 213 /* FunctionDeclaration */: + case 173 /* FunctionExpression */: + case 145 /* GetAccessor */: + case 223 /* ImportClause */: + case 221 /* ImportEqualsDeclaration */: + case 226 /* ImportSpecifier */: + case 215 /* InterfaceDeclaration */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: + case 218 /* ModuleDeclaration */: + case 224 /* NamespaceImport */: + case 138 /* Parameter */: + case 245 /* PropertyAssignment */: + case 141 /* PropertyDeclaration */: + case 140 /* PropertySignature */: + case 146 /* SetAccessor */: + case 246 /* ShorthandPropertyAssignment */: + case 216 /* TypeAliasDeclaration */: + case 137 /* TypeParameter */: + case 211 /* VariableDeclaration */: return true; } return false; @@ -6053,25 +6209,25 @@ var ts; ts.isDeclaration = isDeclaration; function isStatement(n) { switch (n.kind) { - case 201 /* BreakStatement */: - case 200 /* ContinueStatement */: - case 208 /* DebuggerStatement */: - case 195 /* DoStatement */: - case 193 /* ExpressionStatement */: - case 192 /* EmptyStatement */: - case 198 /* ForInStatement */: - case 199 /* ForOfStatement */: - case 197 /* ForStatement */: - case 194 /* IfStatement */: - case 205 /* LabeledStatement */: - case 202 /* ReturnStatement */: - case 204 /* SwitchStatement */: - case 96 /* ThrowKeyword */: - case 207 /* TryStatement */: - case 191 /* VariableStatement */: - case 196 /* WhileStatement */: - case 203 /* WithStatement */: - case 225 /* ExportAssignment */: + case 203 /* BreakStatement */: + case 202 /* ContinueStatement */: + case 210 /* DebuggerStatement */: + case 197 /* DoStatement */: + case 195 /* ExpressionStatement */: + case 194 /* EmptyStatement */: + case 200 /* ForInStatement */: + case 201 /* ForOfStatement */: + case 199 /* ForStatement */: + case 196 /* IfStatement */: + case 207 /* LabeledStatement */: + case 204 /* ReturnStatement */: + case 206 /* SwitchStatement */: + case 98 /* ThrowKeyword */: + case 209 /* TryStatement */: + case 193 /* VariableStatement */: + case 198 /* WhileStatement */: + case 205 /* WithStatement */: + case 227 /* ExportAssignment */: return true; default: return false; @@ -6080,13 +6236,13 @@ var ts; ts.isStatement = isStatement; function isClassElement(n) { switch (n.kind) { - case 142 /* Constructor */: - case 139 /* PropertyDeclaration */: - case 141 /* MethodDeclaration */: - case 143 /* GetAccessor */: - case 144 /* SetAccessor */: - case 140 /* MethodSignature */: - case 147 /* IndexSignature */: + case 144 /* Constructor */: + case 141 /* PropertyDeclaration */: + case 143 /* MethodDeclaration */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: + case 142 /* MethodSignature */: + case 149 /* IndexSignature */: return true; default: return false; @@ -6095,11 +6251,11 @@ var ts; ts.isClassElement = isClassElement; // True if the given identifier, string literal, or number literal is the name of a declaration node function isDeclarationName(name) { - if (name.kind !== 67 /* Identifier */ && name.kind !== 9 /* StringLiteral */ && name.kind !== 8 /* NumericLiteral */) { + if (name.kind !== 69 /* Identifier */ && name.kind !== 9 /* StringLiteral */ && name.kind !== 8 /* NumericLiteral */) { return false; } var parent = name.parent; - if (parent.kind === 224 /* ImportSpecifier */ || parent.kind === 228 /* ExportSpecifier */) { + if (parent.kind === 226 /* ImportSpecifier */ || parent.kind === 230 /* ExportSpecifier */) { if (parent.propertyName) { return true; } @@ -6114,31 +6270,31 @@ var ts; function isIdentifierName(node) { var parent = node.parent; switch (parent.kind) { - case 139 /* PropertyDeclaration */: - case 138 /* PropertySignature */: - case 141 /* MethodDeclaration */: - case 140 /* MethodSignature */: - case 143 /* GetAccessor */: - case 144 /* SetAccessor */: - case 245 /* EnumMember */: - case 243 /* PropertyAssignment */: - case 164 /* PropertyAccessExpression */: + case 141 /* PropertyDeclaration */: + case 140 /* PropertySignature */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: + case 247 /* EnumMember */: + case 245 /* PropertyAssignment */: + case 166 /* PropertyAccessExpression */: // Name in member declaration or property name in property access return parent.name === node; - case 133 /* QualifiedName */: + case 135 /* QualifiedName */: // Name on right hand side of dot in a type query if (parent.right === node) { - while (parent.kind === 133 /* QualifiedName */) { + while (parent.kind === 135 /* QualifiedName */) { parent = parent.parent; } - return parent.kind === 152 /* TypeQuery */; + return parent.kind === 154 /* TypeQuery */; } return false; - case 161 /* BindingElement */: - case 224 /* ImportSpecifier */: + case 163 /* BindingElement */: + case 226 /* ImportSpecifier */: // Property name in binding element or import specifier return parent.propertyName === node; - case 228 /* ExportSpecifier */: + case 230 /* ExportSpecifier */: // Any name in an export specifier return true; } @@ -6154,26 +6310,26 @@ var ts; // export = ... // export default ... function isAliasSymbolDeclaration(node) { - return node.kind === 219 /* ImportEqualsDeclaration */ || - node.kind === 221 /* ImportClause */ && !!node.name || - node.kind === 222 /* NamespaceImport */ || - node.kind === 224 /* ImportSpecifier */ || - node.kind === 228 /* ExportSpecifier */ || - node.kind === 225 /* ExportAssignment */ && node.expression.kind === 67 /* Identifier */; + return node.kind === 221 /* ImportEqualsDeclaration */ || + node.kind === 223 /* ImportClause */ && !!node.name || + node.kind === 224 /* NamespaceImport */ || + node.kind === 226 /* ImportSpecifier */ || + node.kind === 230 /* ExportSpecifier */ || + node.kind === 227 /* ExportAssignment */ && node.expression.kind === 69 /* Identifier */; } ts.isAliasSymbolDeclaration = isAliasSymbolDeclaration; function getClassExtendsHeritageClauseElement(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 81 /* ExtendsKeyword */); + var heritageClause = getHeritageClause(node.heritageClauses, 83 /* ExtendsKeyword */); return heritageClause && heritageClause.types.length > 0 ? heritageClause.types[0] : undefined; } ts.getClassExtendsHeritageClauseElement = getClassExtendsHeritageClauseElement; function getClassImplementsHeritageClauseElements(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 104 /* ImplementsKeyword */); + var heritageClause = getHeritageClause(node.heritageClauses, 106 /* ImplementsKeyword */); return heritageClause ? heritageClause.types : undefined; } ts.getClassImplementsHeritageClauseElements = getClassImplementsHeritageClauseElements; function getInterfaceBaseTypeNodes(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 81 /* ExtendsKeyword */); + var heritageClause = getHeritageClause(node.heritageClauses, 83 /* ExtendsKeyword */); return heritageClause ? heritageClause.types : undefined; } ts.getInterfaceBaseTypeNodes = getInterfaceBaseTypeNodes; @@ -6242,7 +6398,7 @@ var ts; } ts.getFileReferenceFromReferencePath = getFileReferenceFromReferencePath; function isKeyword(token) { - return 68 /* FirstKeyword */ <= token && token <= 132 /* LastKeyword */; + return 70 /* FirstKeyword */ <= token && token <= 134 /* LastKeyword */; } ts.isKeyword = isKeyword; function isTrivia(token) { @@ -6262,7 +6418,7 @@ var ts; */ function hasDynamicName(declaration) { return declaration.name && - declaration.name.kind === 134 /* ComputedPropertyName */ && + declaration.name.kind === 136 /* ComputedPropertyName */ && !isWellKnownSymbolSyntactically(declaration.name.expression); } ts.hasDynamicName = hasDynamicName; @@ -6272,14 +6428,14 @@ var ts; * where Symbol is literally the word "Symbol", and name is any identifierName */ function isWellKnownSymbolSyntactically(node) { - return node.kind === 164 /* PropertyAccessExpression */ && isESSymbolIdentifier(node.expression); + return isPropertyAccessExpression(node) && isESSymbolIdentifier(node.expression); } ts.isWellKnownSymbolSyntactically = isWellKnownSymbolSyntactically; function getPropertyNameForPropertyNameNode(name) { - if (name.kind === 67 /* Identifier */ || name.kind === 9 /* StringLiteral */ || name.kind === 8 /* NumericLiteral */) { + if (name.kind === 69 /* Identifier */ || name.kind === 9 /* StringLiteral */ || name.kind === 8 /* NumericLiteral */) { return name.text; } - if (name.kind === 134 /* ComputedPropertyName */) { + if (name.kind === 136 /* ComputedPropertyName */) { var nameExpression = name.expression; if (isWellKnownSymbolSyntactically(nameExpression)) { var rightHandSideName = nameExpression.name.text; @@ -6297,21 +6453,21 @@ var ts; * Includes the word "Symbol" with unicode escapes */ function isESSymbolIdentifier(node) { - return node.kind === 67 /* Identifier */ && node.text === "Symbol"; + return node.kind === 69 /* Identifier */ && node.text === "Symbol"; } ts.isESSymbolIdentifier = isESSymbolIdentifier; function isModifier(token) { switch (token) { - case 113 /* AbstractKeyword */: - case 116 /* AsyncKeyword */: - case 72 /* ConstKeyword */: - case 120 /* DeclareKeyword */: - case 75 /* DefaultKeyword */: - case 80 /* ExportKeyword */: - case 110 /* PublicKeyword */: - case 108 /* PrivateKeyword */: - case 109 /* ProtectedKeyword */: - case 111 /* StaticKeyword */: + case 115 /* AbstractKeyword */: + case 118 /* AsyncKeyword */: + case 74 /* ConstKeyword */: + case 122 /* DeclareKeyword */: + case 77 /* DefaultKeyword */: + case 82 /* ExportKeyword */: + case 112 /* PublicKeyword */: + case 110 /* PrivateKeyword */: + case 111 /* ProtectedKeyword */: + case 113 /* StaticKeyword */: return true; } return false; @@ -6319,28 +6475,28 @@ var ts; ts.isModifier = isModifier; function isParameterDeclaration(node) { var root = getRootDeclaration(node); - return root.kind === 136 /* Parameter */; + return root.kind === 138 /* Parameter */; } ts.isParameterDeclaration = isParameterDeclaration; function getRootDeclaration(node) { - while (node.kind === 161 /* BindingElement */) { + while (node.kind === 163 /* BindingElement */) { node = node.parent.parent; } return node; } ts.getRootDeclaration = getRootDeclaration; function nodeStartsNewLexicalEnvironment(n) { - return isFunctionLike(n) || n.kind === 216 /* ModuleDeclaration */ || n.kind === 246 /* SourceFile */; + return isFunctionLike(n) || n.kind === 218 /* ModuleDeclaration */ || n.kind === 248 /* SourceFile */; } ts.nodeStartsNewLexicalEnvironment = nodeStartsNewLexicalEnvironment; function cloneEntityName(node) { - if (node.kind === 67 /* Identifier */) { - var clone_1 = createSynthesizedNode(67 /* Identifier */); + if (node.kind === 69 /* Identifier */) { + var clone_1 = createSynthesizedNode(69 /* Identifier */); clone_1.text = node.text; return clone_1; } else { - var clone_2 = createSynthesizedNode(133 /* QualifiedName */); + var clone_2 = createSynthesizedNode(135 /* QualifiedName */); clone_2.left = cloneEntityName(node.left); clone_2.left.parent = clone_2; clone_2.right = cloneEntityName(node.right); @@ -6595,7 +6751,7 @@ var ts; ts.getLineOfLocalPosition = getLineOfLocalPosition; function getFirstConstructorWithBody(node) { return ts.forEach(node.members, function (member) { - if (member.kind === 142 /* Constructor */ && nodeIsPresent(member.body)) { + if (member.kind === 144 /* Constructor */ && nodeIsPresent(member.body)) { return member; } }); @@ -6624,10 +6780,10 @@ var ts; var setAccessor; if (hasDynamicName(accessor)) { firstAccessor = accessor; - if (accessor.kind === 143 /* GetAccessor */) { + if (accessor.kind === 145 /* GetAccessor */) { getAccessor = accessor; } - else if (accessor.kind === 144 /* SetAccessor */) { + else if (accessor.kind === 146 /* SetAccessor */) { setAccessor = accessor; } else { @@ -6636,7 +6792,7 @@ var ts; } else { ts.forEach(declarations, function (member) { - if ((member.kind === 143 /* GetAccessor */ || member.kind === 144 /* SetAccessor */) + if ((member.kind === 145 /* GetAccessor */ || member.kind === 146 /* SetAccessor */) && (member.flags & 128 /* Static */) === (accessor.flags & 128 /* Static */)) { var memberName = getPropertyNameForPropertyNameNode(member.name); var accessorName = getPropertyNameForPropertyNameNode(accessor.name); @@ -6647,10 +6803,10 @@ var ts; else if (!secondAccessor) { secondAccessor = member; } - if (member.kind === 143 /* GetAccessor */ && !getAccessor) { + if (member.kind === 145 /* GetAccessor */ && !getAccessor) { getAccessor = member; } - if (member.kind === 144 /* SetAccessor */ && !setAccessor) { + if (member.kind === 146 /* SetAccessor */ && !setAccessor) { setAccessor = member; } } @@ -6783,16 +6939,16 @@ var ts; ts.writeCommentRange = writeCommentRange; function modifierToFlag(token) { switch (token) { - case 111 /* StaticKeyword */: return 128 /* Static */; - case 110 /* PublicKeyword */: return 16 /* Public */; - case 109 /* ProtectedKeyword */: return 64 /* Protected */; - case 108 /* PrivateKeyword */: return 32 /* Private */; - case 113 /* AbstractKeyword */: return 256 /* Abstract */; - case 80 /* ExportKeyword */: return 1 /* Export */; - case 120 /* DeclareKeyword */: return 2 /* Ambient */; - case 72 /* ConstKeyword */: return 32768 /* Const */; - case 75 /* DefaultKeyword */: return 1024 /* Default */; - case 116 /* AsyncKeyword */: return 512 /* Async */; + case 113 /* StaticKeyword */: return 128 /* Static */; + case 112 /* PublicKeyword */: return 16 /* Public */; + case 111 /* ProtectedKeyword */: return 64 /* Protected */; + case 110 /* PrivateKeyword */: return 32 /* Private */; + case 115 /* AbstractKeyword */: return 256 /* Abstract */; + case 82 /* ExportKeyword */: return 1 /* Export */; + case 122 /* DeclareKeyword */: return 2 /* Ambient */; + case 74 /* ConstKeyword */: return 32768 /* Const */; + case 77 /* DefaultKeyword */: return 1024 /* Default */; + case 118 /* AsyncKeyword */: return 512 /* Async */; } return 0; } @@ -6800,29 +6956,29 @@ var ts; function isLeftHandSideExpression(expr) { if (expr) { switch (expr.kind) { - case 164 /* PropertyAccessExpression */: - case 165 /* ElementAccessExpression */: - case 167 /* NewExpression */: - case 166 /* CallExpression */: - case 231 /* JsxElement */: - case 232 /* JsxSelfClosingElement */: - case 168 /* TaggedTemplateExpression */: - case 162 /* ArrayLiteralExpression */: - case 170 /* ParenthesizedExpression */: - case 163 /* ObjectLiteralExpression */: - case 184 /* ClassExpression */: - case 171 /* FunctionExpression */: - case 67 /* Identifier */: + case 166 /* PropertyAccessExpression */: + case 167 /* ElementAccessExpression */: + case 169 /* NewExpression */: + case 168 /* CallExpression */: + case 233 /* JsxElement */: + case 234 /* JsxSelfClosingElement */: + case 170 /* TaggedTemplateExpression */: + case 164 /* ArrayLiteralExpression */: + case 172 /* ParenthesizedExpression */: + case 165 /* ObjectLiteralExpression */: + case 186 /* ClassExpression */: + case 173 /* FunctionExpression */: + case 69 /* Identifier */: case 10 /* RegularExpressionLiteral */: case 8 /* NumericLiteral */: case 9 /* StringLiteral */: case 11 /* NoSubstitutionTemplateLiteral */: - case 181 /* TemplateExpression */: - case 82 /* FalseKeyword */: - case 91 /* NullKeyword */: - case 95 /* ThisKeyword */: - case 97 /* TrueKeyword */: - case 93 /* SuperKeyword */: + case 183 /* TemplateExpression */: + case 84 /* FalseKeyword */: + case 93 /* NullKeyword */: + case 97 /* ThisKeyword */: + case 99 /* TrueKeyword */: + case 95 /* SuperKeyword */: return true; } } @@ -6830,12 +6986,12 @@ var ts; } ts.isLeftHandSideExpression = isLeftHandSideExpression; function isAssignmentOperator(token) { - return token >= 55 /* FirstAssignment */ && token <= 66 /* LastAssignment */; + return token >= 56 /* FirstAssignment */ && token <= 68 /* LastAssignment */; } ts.isAssignmentOperator = isAssignmentOperator; function isExpressionWithTypeArgumentsInClassExtendsClause(node) { - return node.kind === 186 /* ExpressionWithTypeArguments */ && - node.parent.token === 81 /* ExtendsKeyword */ && + return node.kind === 188 /* ExpressionWithTypeArguments */ && + node.parent.token === 83 /* ExtendsKeyword */ && isClassLike(node.parent.parent); } ts.isExpressionWithTypeArgumentsInClassExtendsClause = isExpressionWithTypeArgumentsInClassExtendsClause; @@ -6846,10 +7002,10 @@ var ts; } ts.isSupportedExpressionWithTypeArguments = isSupportedExpressionWithTypeArguments; function isSupportedExpressionWithTypeArgumentsRest(node) { - if (node.kind === 67 /* Identifier */) { + if (node.kind === 69 /* Identifier */) { return true; } - else if (node.kind === 164 /* PropertyAccessExpression */) { + else if (isPropertyAccessExpression(node)) { return isSupportedExpressionWithTypeArgumentsRest(node.expression); } else { @@ -6857,16 +7013,16 @@ var ts; } } function isRightSideOfQualifiedNameOrPropertyAccess(node) { - return (node.parent.kind === 133 /* QualifiedName */ && node.parent.right === node) || - (node.parent.kind === 164 /* PropertyAccessExpression */ && node.parent.name === node); + return (node.parent.kind === 135 /* QualifiedName */ && node.parent.right === node) || + (node.parent.kind === 166 /* PropertyAccessExpression */ && node.parent.name === node); } ts.isRightSideOfQualifiedNameOrPropertyAccess = isRightSideOfQualifiedNameOrPropertyAccess; function isEmptyObjectLiteralOrArrayLiteral(expression) { var kind = expression.kind; - if (kind === 163 /* ObjectLiteralExpression */) { + if (kind === 165 /* ObjectLiteralExpression */) { return expression.properties.length === 0; } - if (kind === 162 /* ArrayLiteralExpression */) { + if (kind === 164 /* ArrayLiteralExpression */) { return expression.elements.length === 0; } return false; @@ -6876,12 +7032,12 @@ var ts; return symbol && symbol.valueDeclaration && (symbol.valueDeclaration.flags & 1024 /* Default */) ? symbol.valueDeclaration.localSymbol : undefined; } ts.getLocalSymbolForExportDefault = getLocalSymbolForExportDefault; - function isJavaScript(fileName) { - return ts.fileExtensionIs(fileName, ".js"); + function hasJavaScriptFileExtension(fileName) { + return ts.fileExtensionIs(fileName, ".js") || ts.fileExtensionIs(fileName, ".jsx"); } - ts.isJavaScript = isJavaScript; + ts.hasJavaScriptFileExtension = hasJavaScriptFileExtension; function isTsx(fileName) { - return ts.fileExtensionIs(fileName, ".tsx"); + return ts.fileExtensionIs(fileName, ".tsx") || ts.fileExtensionIs(fileName, ".jsx"); } ts.isTsx = isTsx; /** @@ -7178,9 +7334,9 @@ var ts; } ts.collapseTextChangeRangesAcrossMultipleVersions = collapseTextChangeRangesAcrossMultipleVersions; function getTypeParameterOwner(d) { - if (d && d.kind === 135 /* TypeParameter */) { + if (d && d.kind === 137 /* TypeParameter */) { for (var current = d; current; current = current.parent) { - if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 213 /* InterfaceDeclaration */) { + if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 215 /* InterfaceDeclaration */) { return current; } } @@ -7192,7 +7348,7 @@ var ts; /// var ts; (function (ts) { - var nodeConstructors = new Array(270 /* Count */); + var nodeConstructors = new Array(272 /* Count */); /* @internal */ ts.parseTime = 0; function getNodeConstructor(kind) { return nodeConstructors[kind] || (nodeConstructors[kind] = ts.objectAllocator.getNodeConstructor(kind)); @@ -7237,20 +7393,26 @@ var ts; var visitNodes = cbNodeArray ? visitNodeArray : visitEachNode; var cbNodes = cbNodeArray || cbNode; switch (node.kind) { - case 133 /* QualifiedName */: + case 135 /* QualifiedName */: return visitNode(cbNode, node.left) || visitNode(cbNode, node.right); - case 135 /* TypeParameter */: + case 137 /* TypeParameter */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.constraint) || visitNode(cbNode, node.expression); - case 136 /* Parameter */: - case 139 /* PropertyDeclaration */: - case 138 /* PropertySignature */: - case 243 /* PropertyAssignment */: - case 244 /* ShorthandPropertyAssignment */: - case 209 /* VariableDeclaration */: - case 161 /* BindingElement */: + case 246 /* ShorthandPropertyAssignment */: + return visitNodes(cbNodes, node.decorators) || + visitNodes(cbNodes, node.modifiers) || + visitNode(cbNode, node.name) || + visitNode(cbNode, node.questionToken) || + visitNode(cbNode, node.equalsToken) || + visitNode(cbNode, node.objectAssignmentInitializer); + case 138 /* Parameter */: + case 141 /* PropertyDeclaration */: + case 140 /* PropertySignature */: + case 245 /* PropertyAssignment */: + case 211 /* VariableDeclaration */: + case 163 /* BindingElement */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.propertyName) || @@ -7259,24 +7421,24 @@ var ts; visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 150 /* FunctionType */: - case 151 /* ConstructorType */: - case 145 /* CallSignature */: - case 146 /* ConstructSignature */: - case 147 /* IndexSignature */: + case 152 /* FunctionType */: + case 153 /* ConstructorType */: + case 147 /* CallSignature */: + case 148 /* ConstructSignature */: + case 149 /* IndexSignature */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNodes(cbNodes, node.typeParameters) || visitNodes(cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 141 /* MethodDeclaration */: - case 140 /* MethodSignature */: - case 142 /* Constructor */: - case 143 /* GetAccessor */: - case 144 /* SetAccessor */: - case 171 /* FunctionExpression */: - case 211 /* FunctionDeclaration */: - case 172 /* ArrowFunction */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: + case 144 /* Constructor */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: + case 173 /* FunctionExpression */: + case 213 /* FunctionDeclaration */: + case 174 /* ArrowFunction */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.asteriskToken) || @@ -7287,290 +7449,290 @@ var ts; visitNode(cbNode, node.type) || visitNode(cbNode, node.equalsGreaterThanToken) || visitNode(cbNode, node.body); - case 149 /* TypeReference */: + case 151 /* TypeReference */: return visitNode(cbNode, node.typeName) || visitNodes(cbNodes, node.typeArguments); - case 148 /* TypePredicate */: + case 150 /* TypePredicate */: return visitNode(cbNode, node.parameterName) || visitNode(cbNode, node.type); - case 152 /* TypeQuery */: + case 154 /* TypeQuery */: return visitNode(cbNode, node.exprName); - case 153 /* TypeLiteral */: + case 155 /* TypeLiteral */: return visitNodes(cbNodes, node.members); - case 154 /* ArrayType */: + case 156 /* ArrayType */: return visitNode(cbNode, node.elementType); - case 155 /* TupleType */: + case 157 /* TupleType */: return visitNodes(cbNodes, node.elementTypes); - case 156 /* UnionType */: - case 157 /* IntersectionType */: + case 158 /* UnionType */: + case 159 /* IntersectionType */: return visitNodes(cbNodes, node.types); - case 158 /* ParenthesizedType */: + case 160 /* ParenthesizedType */: return visitNode(cbNode, node.type); - case 159 /* ObjectBindingPattern */: - case 160 /* ArrayBindingPattern */: + case 161 /* ObjectBindingPattern */: + case 162 /* ArrayBindingPattern */: return visitNodes(cbNodes, node.elements); - case 162 /* ArrayLiteralExpression */: + case 164 /* ArrayLiteralExpression */: return visitNodes(cbNodes, node.elements); - case 163 /* ObjectLiteralExpression */: + case 165 /* ObjectLiteralExpression */: return visitNodes(cbNodes, node.properties); - case 164 /* PropertyAccessExpression */: + case 166 /* PropertyAccessExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.dotToken) || visitNode(cbNode, node.name); - case 165 /* ElementAccessExpression */: + case 167 /* ElementAccessExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.argumentExpression); - case 166 /* CallExpression */: - case 167 /* NewExpression */: + case 168 /* CallExpression */: + case 169 /* NewExpression */: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.typeArguments) || visitNodes(cbNodes, node.arguments); - case 168 /* TaggedTemplateExpression */: + case 170 /* TaggedTemplateExpression */: return visitNode(cbNode, node.tag) || visitNode(cbNode, node.template); - case 169 /* TypeAssertionExpression */: + case 171 /* TypeAssertionExpression */: return visitNode(cbNode, node.type) || visitNode(cbNode, node.expression); - case 170 /* ParenthesizedExpression */: + case 172 /* ParenthesizedExpression */: return visitNode(cbNode, node.expression); - case 173 /* DeleteExpression */: + case 175 /* DeleteExpression */: return visitNode(cbNode, node.expression); - case 174 /* TypeOfExpression */: + case 176 /* TypeOfExpression */: return visitNode(cbNode, node.expression); - case 175 /* VoidExpression */: + case 177 /* VoidExpression */: return visitNode(cbNode, node.expression); - case 177 /* PrefixUnaryExpression */: + case 179 /* PrefixUnaryExpression */: return visitNode(cbNode, node.operand); - case 182 /* YieldExpression */: + case 184 /* YieldExpression */: return visitNode(cbNode, node.asteriskToken) || visitNode(cbNode, node.expression); - case 176 /* AwaitExpression */: + case 178 /* AwaitExpression */: return visitNode(cbNode, node.expression); - case 178 /* PostfixUnaryExpression */: + case 180 /* PostfixUnaryExpression */: return visitNode(cbNode, node.operand); - case 179 /* BinaryExpression */: + case 181 /* BinaryExpression */: return visitNode(cbNode, node.left) || visitNode(cbNode, node.operatorToken) || visitNode(cbNode, node.right); - case 187 /* AsExpression */: + case 189 /* AsExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.type); - case 180 /* ConditionalExpression */: + case 182 /* ConditionalExpression */: return visitNode(cbNode, node.condition) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.whenTrue) || visitNode(cbNode, node.colonToken) || visitNode(cbNode, node.whenFalse); - case 183 /* SpreadElementExpression */: + case 185 /* SpreadElementExpression */: return visitNode(cbNode, node.expression); - case 190 /* Block */: - case 217 /* ModuleBlock */: + case 192 /* Block */: + case 219 /* ModuleBlock */: return visitNodes(cbNodes, node.statements); - case 246 /* SourceFile */: + case 248 /* SourceFile */: return visitNodes(cbNodes, node.statements) || visitNode(cbNode, node.endOfFileToken); - case 191 /* VariableStatement */: + case 193 /* VariableStatement */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.declarationList); - case 210 /* VariableDeclarationList */: + case 212 /* VariableDeclarationList */: return visitNodes(cbNodes, node.declarations); - case 193 /* ExpressionStatement */: + case 195 /* ExpressionStatement */: return visitNode(cbNode, node.expression); - case 194 /* IfStatement */: + case 196 /* IfStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.thenStatement) || visitNode(cbNode, node.elseStatement); - case 195 /* DoStatement */: + case 197 /* DoStatement */: return visitNode(cbNode, node.statement) || visitNode(cbNode, node.expression); - case 196 /* WhileStatement */: + case 198 /* WhileStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 197 /* ForStatement */: + case 199 /* ForStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.condition) || visitNode(cbNode, node.incrementor) || visitNode(cbNode, node.statement); - case 198 /* ForInStatement */: + case 200 /* ForInStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 199 /* ForOfStatement */: + case 201 /* ForOfStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 200 /* ContinueStatement */: - case 201 /* BreakStatement */: + case 202 /* ContinueStatement */: + case 203 /* BreakStatement */: return visitNode(cbNode, node.label); - case 202 /* ReturnStatement */: + case 204 /* ReturnStatement */: return visitNode(cbNode, node.expression); - case 203 /* WithStatement */: + case 205 /* WithStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 204 /* SwitchStatement */: + case 206 /* SwitchStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.caseBlock); - case 218 /* CaseBlock */: + case 220 /* CaseBlock */: return visitNodes(cbNodes, node.clauses); - case 239 /* CaseClause */: + case 241 /* CaseClause */: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.statements); - case 240 /* DefaultClause */: + case 242 /* DefaultClause */: return visitNodes(cbNodes, node.statements); - case 205 /* LabeledStatement */: + case 207 /* LabeledStatement */: return visitNode(cbNode, node.label) || visitNode(cbNode, node.statement); - case 206 /* ThrowStatement */: + case 208 /* ThrowStatement */: return visitNode(cbNode, node.expression); - case 207 /* TryStatement */: + case 209 /* TryStatement */: return visitNode(cbNode, node.tryBlock) || visitNode(cbNode, node.catchClause) || visitNode(cbNode, node.finallyBlock); - case 242 /* CatchClause */: + case 244 /* CatchClause */: return visitNode(cbNode, node.variableDeclaration) || visitNode(cbNode, node.block); - case 137 /* Decorator */: + case 139 /* Decorator */: return visitNode(cbNode, node.expression); - case 212 /* ClassDeclaration */: - case 184 /* ClassExpression */: + case 214 /* ClassDeclaration */: + case 186 /* ClassExpression */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNodes, node.typeParameters) || visitNodes(cbNodes, node.heritageClauses) || visitNodes(cbNodes, node.members); - case 213 /* InterfaceDeclaration */: + case 215 /* InterfaceDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNodes, node.typeParameters) || visitNodes(cbNodes, node.heritageClauses) || visitNodes(cbNodes, node.members); - case 214 /* TypeAliasDeclaration */: + case 216 /* TypeAliasDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNodes, node.typeParameters) || visitNode(cbNode, node.type); - case 215 /* EnumDeclaration */: + case 217 /* EnumDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNodes, node.members); - case 245 /* EnumMember */: + case 247 /* EnumMember */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 216 /* ModuleDeclaration */: + case 218 /* ModuleDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.body); - case 219 /* ImportEqualsDeclaration */: + case 221 /* ImportEqualsDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.moduleReference); - case 220 /* ImportDeclaration */: + case 222 /* ImportDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.importClause) || visitNode(cbNode, node.moduleSpecifier); - case 221 /* ImportClause */: + case 223 /* ImportClause */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.namedBindings); - case 222 /* NamespaceImport */: + case 224 /* NamespaceImport */: return visitNode(cbNode, node.name); - case 223 /* NamedImports */: - case 227 /* NamedExports */: + case 225 /* NamedImports */: + case 229 /* NamedExports */: return visitNodes(cbNodes, node.elements); - case 226 /* ExportDeclaration */: + case 228 /* ExportDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.exportClause) || visitNode(cbNode, node.moduleSpecifier); - case 224 /* ImportSpecifier */: - case 228 /* ExportSpecifier */: + case 226 /* ImportSpecifier */: + case 230 /* ExportSpecifier */: return visitNode(cbNode, node.propertyName) || visitNode(cbNode, node.name); - case 225 /* ExportAssignment */: + case 227 /* ExportAssignment */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.expression); - case 181 /* TemplateExpression */: + case 183 /* TemplateExpression */: return visitNode(cbNode, node.head) || visitNodes(cbNodes, node.templateSpans); - case 188 /* TemplateSpan */: + case 190 /* TemplateSpan */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.literal); - case 134 /* ComputedPropertyName */: + case 136 /* ComputedPropertyName */: return visitNode(cbNode, node.expression); - case 241 /* HeritageClause */: + case 243 /* HeritageClause */: return visitNodes(cbNodes, node.types); - case 186 /* ExpressionWithTypeArguments */: + case 188 /* ExpressionWithTypeArguments */: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.typeArguments); - case 230 /* ExternalModuleReference */: + case 232 /* ExternalModuleReference */: return visitNode(cbNode, node.expression); - case 229 /* MissingDeclaration */: + case 231 /* MissingDeclaration */: return visitNodes(cbNodes, node.decorators); - case 231 /* JsxElement */: + case 233 /* JsxElement */: return visitNode(cbNode, node.openingElement) || visitNodes(cbNodes, node.children) || visitNode(cbNode, node.closingElement); - case 232 /* JsxSelfClosingElement */: - case 233 /* JsxOpeningElement */: + case 234 /* JsxSelfClosingElement */: + case 235 /* JsxOpeningElement */: return visitNode(cbNode, node.tagName) || visitNodes(cbNodes, node.attributes); - case 236 /* JsxAttribute */: + case 238 /* JsxAttribute */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 237 /* JsxSpreadAttribute */: + case 239 /* JsxSpreadAttribute */: return visitNode(cbNode, node.expression); - case 238 /* JsxExpression */: + case 240 /* JsxExpression */: return visitNode(cbNode, node.expression); - case 235 /* JsxClosingElement */: + case 237 /* JsxClosingElement */: return visitNode(cbNode, node.tagName); - case 247 /* JSDocTypeExpression */: + case 249 /* JSDocTypeExpression */: return visitNode(cbNode, node.type); - case 251 /* JSDocUnionType */: + case 253 /* JSDocUnionType */: return visitNodes(cbNodes, node.types); - case 252 /* JSDocTupleType */: + case 254 /* JSDocTupleType */: return visitNodes(cbNodes, node.types); - case 250 /* JSDocArrayType */: + case 252 /* JSDocArrayType */: return visitNode(cbNode, node.elementType); - case 254 /* JSDocNonNullableType */: + case 256 /* JSDocNonNullableType */: return visitNode(cbNode, node.type); - case 253 /* JSDocNullableType */: + case 255 /* JSDocNullableType */: return visitNode(cbNode, node.type); - case 255 /* JSDocRecordType */: + case 257 /* JSDocRecordType */: return visitNodes(cbNodes, node.members); - case 257 /* JSDocTypeReference */: + case 259 /* JSDocTypeReference */: return visitNode(cbNode, node.name) || visitNodes(cbNodes, node.typeArguments); - case 258 /* JSDocOptionalType */: + case 260 /* JSDocOptionalType */: return visitNode(cbNode, node.type); - case 259 /* JSDocFunctionType */: + case 261 /* JSDocFunctionType */: return visitNodes(cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 260 /* JSDocVariadicType */: + case 262 /* JSDocVariadicType */: return visitNode(cbNode, node.type); - case 261 /* JSDocConstructorType */: + case 263 /* JSDocConstructorType */: return visitNode(cbNode, node.type); - case 262 /* JSDocThisType */: + case 264 /* JSDocThisType */: return visitNode(cbNode, node.type); - case 256 /* JSDocRecordMember */: + case 258 /* JSDocRecordMember */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.type); - case 263 /* JSDocComment */: + case 265 /* JSDocComment */: return visitNodes(cbNodes, node.tags); - case 265 /* JSDocParameterTag */: + case 267 /* JSDocParameterTag */: return visitNode(cbNode, node.preParameterName) || visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.postParameterName); - case 266 /* JSDocReturnTag */: + case 268 /* JSDocReturnTag */: return visitNode(cbNode, node.typeExpression); - case 267 /* JSDocTypeTag */: + case 269 /* JSDocTypeTag */: return visitNode(cbNode, node.typeExpression); - case 268 /* JSDocTemplateTag */: + case 270 /* JSDocTemplateTag */: return visitNodes(cbNodes, node.typeParameters); } } @@ -7701,13 +7863,14 @@ var ts; // attached to the EOF token. var parseErrorBeforeNextFinishedNode = false; function parseSourceFile(fileName, _sourceText, languageVersion, _syntaxCursor, setParentNodes) { - initializeState(fileName, _sourceText, languageVersion, _syntaxCursor); + var isJavaScriptFile = ts.hasJavaScriptFileExtension(fileName) || _sourceText.lastIndexOf("// @language=javascript", 0) === 0; + initializeState(fileName, _sourceText, languageVersion, isJavaScriptFile, _syntaxCursor); var result = parseSourceFileWorker(fileName, languageVersion, setParentNodes); clearState(); return result; } Parser.parseSourceFile = parseSourceFile; - function initializeState(fileName, _sourceText, languageVersion, _syntaxCursor) { + function initializeState(fileName, _sourceText, languageVersion, isJavaScriptFile, _syntaxCursor) { sourceText = _sourceText; syntaxCursor = _syntaxCursor; parseDiagnostics = []; @@ -7715,7 +7878,7 @@ var ts; identifiers = {}; identifierCount = 0; nodeCount = 0; - contextFlags = ts.isJavaScript(fileName) ? 32 /* JavaScriptFile */ : 0 /* None */; + contextFlags = isJavaScriptFile ? 32 /* JavaScriptFile */ : 0 /* None */; parseErrorBeforeNextFinishedNode = false; // Initialize and prime the scanner before parsing the source elements. scanner.setText(sourceText); @@ -7736,6 +7899,9 @@ var ts; } function parseSourceFileWorker(fileName, languageVersion, setParentNodes) { sourceFile = createSourceFile(fileName, languageVersion); + if (contextFlags & 32 /* JavaScriptFile */) { + sourceFile.parserContextFlags = 32 /* JavaScriptFile */; + } // Prime the scanner. token = nextToken(); processReferenceComments(sourceFile); @@ -7753,7 +7919,7 @@ var ts; // If this is a javascript file, proactively see if we can get JSDoc comments for // relevant nodes in the file. We'll use these to provide typing informaion if they're // available. - if (ts.isJavaScript(fileName)) { + if (ts.isSourceFileJavaScript(sourceFile)) { addJSDocComments(); } return sourceFile; @@ -7765,9 +7931,9 @@ var ts; // Add additional cases as necessary depending on how we see JSDoc comments used // in the wild. switch (node.kind) { - case 191 /* VariableStatement */: - case 211 /* FunctionDeclaration */: - case 136 /* Parameter */: + case 193 /* VariableStatement */: + case 213 /* FunctionDeclaration */: + case 138 /* Parameter */: addJSDocComment(node); } forEachChild(node, visit); @@ -7808,7 +7974,7 @@ var ts; } Parser.fixupParentReferences = fixupParentReferences; function createSourceFile(fileName, languageVersion) { - var sourceFile = createNode(246 /* SourceFile */, /*pos*/ 0); + var sourceFile = createNode(248 /* SourceFile */, /*pos*/ 0); sourceFile.pos = 0; sourceFile.end = sourceText.length; sourceFile.text = sourceText; @@ -7972,7 +8138,7 @@ var ts; var saveParseDiagnosticsLength = parseDiagnostics.length; var saveParseErrorBeforeNextFinishedNode = parseErrorBeforeNextFinishedNode; // Note: it is not actually necessary to save/restore the context flags here. That's - // because the saving/restorating of these flags happens naturally through the recursive + // because the saving/restoring of these flags happens naturally through the recursive // descent nature of our parser. However, we still store this here just so we can // assert that that invariant holds. var saveContextFlags = contextFlags; @@ -8007,20 +8173,20 @@ var ts; } // Ignore strict mode flag because we will report an error in type checker instead. function isIdentifier() { - if (token === 67 /* Identifier */) { + if (token === 69 /* Identifier */) { return true; } // If we have a 'yield' keyword, and we're in the [yield] context, then 'yield' is // considered a keyword and is not an identifier. - if (token === 112 /* YieldKeyword */ && inYieldContext()) { + if (token === 114 /* YieldKeyword */ && inYieldContext()) { return false; } // If we have a 'await' keyword, and we're in the [Await] context, then 'await' is // considered a keyword and is not an identifier. - if (token === 117 /* AwaitKeyword */ && inAwaitContext()) { + if (token === 119 /* AwaitKeyword */ && inAwaitContext()) { return false; } - return token > 103 /* LastReservedWord */; + return token > 105 /* LastReservedWord */; } function parseExpected(kind, diagnosticMessage, shouldAdvance) { if (shouldAdvance === void 0) { shouldAdvance = true; } @@ -8126,16 +8292,16 @@ var ts; function createIdentifier(isIdentifier, diagnosticMessage) { identifierCount++; if (isIdentifier) { - var node = createNode(67 /* Identifier */); + var node = createNode(69 /* Identifier */); // Store original token kind if it is not just an Identifier so we can report appropriate error later in type checker - if (token !== 67 /* Identifier */) { + if (token !== 69 /* Identifier */) { node.originalKeywordKind = token; } node.text = internIdentifier(scanner.getTokenValue()); nextToken(); return finishNode(node); } - return createMissingNode(67 /* Identifier */, /*reportAtCurrentPosition*/ false, diagnosticMessage || ts.Diagnostics.Identifier_expected); + return createMissingNode(69 /* Identifier */, /*reportAtCurrentPosition*/ false, diagnosticMessage || ts.Diagnostics.Identifier_expected); } function parseIdentifier(diagnosticMessage) { return createIdentifier(isIdentifier(), diagnosticMessage); @@ -8170,7 +8336,7 @@ var ts; // PropertyName [Yield]: // LiteralPropertyName // ComputedPropertyName[?Yield] - var node = createNode(134 /* ComputedPropertyName */); + var node = createNode(136 /* ComputedPropertyName */); parseExpected(19 /* OpenBracketToken */); // We parse any expression (including a comma expression). But the grammar // says that only an assignment expression is allowed, so the grammar checker @@ -8183,21 +8349,28 @@ var ts; return token === t && tryParse(nextTokenCanFollowModifier); } function nextTokenCanFollowModifier() { - if (token === 72 /* ConstKeyword */) { + if (token === 74 /* ConstKeyword */) { // 'const' is only a modifier if followed by 'enum'. - return nextToken() === 79 /* EnumKeyword */; + return nextToken() === 81 /* EnumKeyword */; } - if (token === 80 /* ExportKeyword */) { + if (token === 82 /* ExportKeyword */) { nextToken(); - if (token === 75 /* DefaultKeyword */) { + if (token === 77 /* DefaultKeyword */) { return lookAhead(nextTokenIsClassOrFunction); } return token !== 37 /* AsteriskToken */ && token !== 15 /* OpenBraceToken */ && canFollowModifier(); } - if (token === 75 /* DefaultKeyword */) { + if (token === 77 /* DefaultKeyword */) { return nextTokenIsClassOrFunction(); } + if (token === 113 /* StaticKeyword */) { + nextToken(); + return canFollowModifier(); + } nextToken(); + if (scanner.hasPrecedingLineBreak()) { + return false; + } return canFollowModifier(); } function parseAnyContextualModifier() { @@ -8211,7 +8384,7 @@ var ts; } function nextTokenIsClassOrFunction() { nextToken(); - return token === 71 /* ClassKeyword */ || token === 85 /* FunctionKeyword */; + return token === 73 /* ClassKeyword */ || token === 87 /* FunctionKeyword */; } // True if positioned at the start of a list element function isListElement(parsingContext, inErrorRecovery) { @@ -8231,7 +8404,7 @@ var ts; // outer module. We just want to consume and move on. return !(token === 23 /* SemicolonToken */ && inErrorRecovery) && isStartOfStatement(); case 2 /* SwitchClauses */: - return token === 69 /* CaseKeyword */ || token === 75 /* DefaultKeyword */; + return token === 71 /* CaseKeyword */ || token === 77 /* DefaultKeyword */; case 4 /* TypeMembers */: return isStartOfTypeMember(); case 5 /* ClassMembers */: @@ -8305,7 +8478,7 @@ var ts; // extends {} extends // extends {} implements var next = nextToken(); - return next === 24 /* CommaToken */ || next === 15 /* OpenBraceToken */ || next === 81 /* ExtendsKeyword */ || next === 104 /* ImplementsKeyword */; + return next === 24 /* CommaToken */ || next === 15 /* OpenBraceToken */ || next === 83 /* ExtendsKeyword */ || next === 106 /* ImplementsKeyword */; } return true; } @@ -8318,8 +8491,8 @@ var ts; return ts.tokenIsIdentifierOrKeyword(token); } function isHeritageClauseExtendsOrImplementsKeyword() { - if (token === 104 /* ImplementsKeyword */ || - token === 81 /* ExtendsKeyword */) { + if (token === 106 /* ImplementsKeyword */ || + token === 83 /* ExtendsKeyword */) { return lookAhead(nextTokenIsStartOfExpression); } return false; @@ -8345,14 +8518,14 @@ var ts; case 21 /* ImportOrExportSpecifiers */: return token === 16 /* CloseBraceToken */; case 3 /* SwitchClauseStatements */: - return token === 16 /* CloseBraceToken */ || token === 69 /* CaseKeyword */ || token === 75 /* DefaultKeyword */; + return token === 16 /* CloseBraceToken */ || token === 71 /* CaseKeyword */ || token === 77 /* DefaultKeyword */; case 7 /* HeritageClauseElement */: - return token === 15 /* OpenBraceToken */ || token === 81 /* ExtendsKeyword */ || token === 104 /* ImplementsKeyword */; + return token === 15 /* OpenBraceToken */ || token === 83 /* ExtendsKeyword */ || token === 106 /* ImplementsKeyword */; case 8 /* VariableDeclarations */: return isVariableDeclaratorListTerminator(); case 17 /* TypeParameters */: // Tokens other than '>' are here for better error recovery - return token === 27 /* GreaterThanToken */ || token === 17 /* OpenParenToken */ || token === 15 /* OpenBraceToken */ || token === 81 /* ExtendsKeyword */ || token === 104 /* ImplementsKeyword */; + return token === 27 /* GreaterThanToken */ || token === 17 /* OpenParenToken */ || token === 15 /* OpenBraceToken */ || token === 83 /* ExtendsKeyword */ || token === 106 /* ImplementsKeyword */; case 11 /* ArgumentExpressions */: // Tokens other than ')' are here for better error recovery return token === 18 /* CloseParenToken */ || token === 23 /* SemicolonToken */; @@ -8369,11 +8542,11 @@ var ts; case 20 /* HeritageClauses */: return token === 15 /* OpenBraceToken */ || token === 16 /* CloseBraceToken */; case 13 /* JsxAttributes */: - return token === 27 /* GreaterThanToken */ || token === 38 /* SlashToken */; + return token === 27 /* GreaterThanToken */ || token === 39 /* SlashToken */; case 14 /* JsxChildren */: return token === 25 /* LessThanToken */ && lookAhead(nextTokenIsSlash); case 22 /* JSDocFunctionParameters */: - return token === 18 /* CloseParenToken */ || token === 53 /* ColonToken */ || token === 16 /* CloseBraceToken */; + return token === 18 /* CloseParenToken */ || token === 54 /* ColonToken */ || token === 16 /* CloseBraceToken */; case 23 /* JSDocTypeArguments */: return token === 27 /* GreaterThanToken */ || token === 16 /* CloseBraceToken */; case 25 /* JSDocTupleTypes */: @@ -8561,20 +8734,20 @@ var ts; function isReusableClassMember(node) { if (node) { switch (node.kind) { - case 142 /* Constructor */: - case 147 /* IndexSignature */: - case 143 /* GetAccessor */: - case 144 /* SetAccessor */: - case 139 /* PropertyDeclaration */: - case 189 /* SemicolonClassElement */: + case 144 /* Constructor */: + case 149 /* IndexSignature */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: + case 141 /* PropertyDeclaration */: + case 191 /* SemicolonClassElement */: return true; - case 141 /* MethodDeclaration */: + case 143 /* MethodDeclaration */: // Method declarations are not necessarily reusable. An object-literal // may have a method calls "constructor(...)" and we must reparse that // into an actual .ConstructorDeclaration. var methodDeclaration = node; - var nameIsConstructor = methodDeclaration.name.kind === 67 /* Identifier */ && - methodDeclaration.name.originalKeywordKind === 119 /* ConstructorKeyword */; + var nameIsConstructor = methodDeclaration.name.kind === 69 /* Identifier */ && + methodDeclaration.name.originalKeywordKind === 121 /* ConstructorKeyword */; return !nameIsConstructor; } } @@ -8583,8 +8756,8 @@ var ts; function isReusableSwitchClause(node) { if (node) { switch (node.kind) { - case 239 /* CaseClause */: - case 240 /* DefaultClause */: + case 241 /* CaseClause */: + case 242 /* DefaultClause */: return true; } } @@ -8593,58 +8766,58 @@ var ts; function isReusableStatement(node) { if (node) { switch (node.kind) { - case 211 /* FunctionDeclaration */: - case 191 /* VariableStatement */: - case 190 /* Block */: - case 194 /* IfStatement */: - case 193 /* ExpressionStatement */: - case 206 /* ThrowStatement */: - case 202 /* ReturnStatement */: - case 204 /* SwitchStatement */: - case 201 /* BreakStatement */: - case 200 /* ContinueStatement */: - case 198 /* ForInStatement */: - case 199 /* ForOfStatement */: - case 197 /* ForStatement */: - case 196 /* WhileStatement */: - case 203 /* WithStatement */: - case 192 /* EmptyStatement */: - case 207 /* TryStatement */: - case 205 /* LabeledStatement */: - case 195 /* DoStatement */: - case 208 /* DebuggerStatement */: - case 220 /* ImportDeclaration */: - case 219 /* ImportEqualsDeclaration */: - case 226 /* ExportDeclaration */: - case 225 /* ExportAssignment */: - case 216 /* ModuleDeclaration */: - case 212 /* ClassDeclaration */: - case 213 /* InterfaceDeclaration */: - case 215 /* EnumDeclaration */: - case 214 /* TypeAliasDeclaration */: + case 213 /* FunctionDeclaration */: + case 193 /* VariableStatement */: + case 192 /* Block */: + case 196 /* IfStatement */: + case 195 /* ExpressionStatement */: + case 208 /* ThrowStatement */: + case 204 /* ReturnStatement */: + case 206 /* SwitchStatement */: + case 203 /* BreakStatement */: + case 202 /* ContinueStatement */: + case 200 /* ForInStatement */: + case 201 /* ForOfStatement */: + case 199 /* ForStatement */: + case 198 /* WhileStatement */: + case 205 /* WithStatement */: + case 194 /* EmptyStatement */: + case 209 /* TryStatement */: + case 207 /* LabeledStatement */: + case 197 /* DoStatement */: + case 210 /* DebuggerStatement */: + case 222 /* ImportDeclaration */: + case 221 /* ImportEqualsDeclaration */: + case 228 /* ExportDeclaration */: + case 227 /* ExportAssignment */: + case 218 /* ModuleDeclaration */: + case 214 /* ClassDeclaration */: + case 215 /* InterfaceDeclaration */: + case 217 /* EnumDeclaration */: + case 216 /* TypeAliasDeclaration */: return true; } } return false; } function isReusableEnumMember(node) { - return node.kind === 245 /* EnumMember */; + return node.kind === 247 /* EnumMember */; } function isReusableTypeMember(node) { if (node) { switch (node.kind) { - case 146 /* ConstructSignature */: - case 140 /* MethodSignature */: - case 147 /* IndexSignature */: - case 138 /* PropertySignature */: - case 145 /* CallSignature */: + case 148 /* ConstructSignature */: + case 142 /* MethodSignature */: + case 149 /* IndexSignature */: + case 140 /* PropertySignature */: + case 147 /* CallSignature */: return true; } } return false; } function isReusableVariableDeclaration(node) { - if (node.kind !== 209 /* VariableDeclaration */) { + if (node.kind !== 211 /* VariableDeclaration */) { return false; } // Very subtle incremental parsing bug. Consider the following code: @@ -8665,7 +8838,7 @@ var ts; return variableDeclarator.initializer === undefined; } function isReusableParameter(node) { - if (node.kind !== 136 /* Parameter */) { + if (node.kind !== 138 /* Parameter */) { return false; } // See the comment in isReusableVariableDeclaration for why we do this. @@ -8782,7 +8955,7 @@ var ts; function parseEntityName(allowReservedWords, diagnosticMessage) { var entity = parseIdentifier(diagnosticMessage); while (parseOptional(21 /* DotToken */)) { - var node = createNode(133 /* QualifiedName */, entity.pos); + var node = createNode(135 /* QualifiedName */, entity.pos); node.left = entity; node.right = parseRightSideOfDot(allowReservedWords); entity = finishNode(node); @@ -8815,13 +8988,13 @@ var ts; // Report that we need an identifier. However, report it right after the dot, // and not on the next token. This is because the next token might actually // be an identifier and the error would be quite confusing. - return createMissingNode(67 /* Identifier */, /*reportAtCurrentToken*/ true, ts.Diagnostics.Identifier_expected); + return createMissingNode(69 /* Identifier */, /*reportAtCurrentToken*/ true, ts.Diagnostics.Identifier_expected); } } return allowIdentifierNames ? parseIdentifierName() : parseIdentifier(); } function parseTemplateExpression() { - var template = createNode(181 /* TemplateExpression */); + var template = createNode(183 /* TemplateExpression */); template.head = parseLiteralNode(); ts.Debug.assert(template.head.kind === 12 /* TemplateHead */, "Template head has wrong token kind"); var templateSpans = []; @@ -8834,7 +9007,7 @@ var ts; return finishNode(template); } function parseTemplateSpan() { - var span = createNode(188 /* TemplateSpan */); + var span = createNode(190 /* TemplateSpan */); span.expression = allowInAnd(parseExpression); var literal; if (token === 16 /* CloseBraceToken */) { @@ -8876,14 +9049,14 @@ var ts; // TYPES function parseTypeReferenceOrTypePredicate() { var typeName = parseEntityName(/*allowReservedWords*/ false, ts.Diagnostics.Type_expected); - if (typeName.kind === 67 /* Identifier */ && token === 122 /* IsKeyword */ && !scanner.hasPrecedingLineBreak()) { + if (typeName.kind === 69 /* Identifier */ && token === 124 /* IsKeyword */ && !scanner.hasPrecedingLineBreak()) { nextToken(); - var node_1 = createNode(148 /* TypePredicate */, typeName.pos); + var node_1 = createNode(150 /* TypePredicate */, typeName.pos); node_1.parameterName = typeName; node_1.type = parseType(); return finishNode(node_1); } - var node = createNode(149 /* TypeReference */, typeName.pos); + var node = createNode(151 /* TypeReference */, typeName.pos); node.typeName = typeName; if (!scanner.hasPrecedingLineBreak() && token === 25 /* LessThanToken */) { node.typeArguments = parseBracketedList(18 /* TypeArguments */, parseType, 25 /* LessThanToken */, 27 /* GreaterThanToken */); @@ -8891,15 +9064,15 @@ var ts; return finishNode(node); } function parseTypeQuery() { - var node = createNode(152 /* TypeQuery */); - parseExpected(99 /* TypeOfKeyword */); + var node = createNode(154 /* TypeQuery */); + parseExpected(101 /* TypeOfKeyword */); node.exprName = parseEntityName(/*allowReservedWords*/ true); return finishNode(node); } function parseTypeParameter() { - var node = createNode(135 /* TypeParameter */); + var node = createNode(137 /* TypeParameter */); node.name = parseIdentifier(); - if (parseOptional(81 /* ExtendsKeyword */)) { + if (parseOptional(83 /* ExtendsKeyword */)) { // It's not uncommon for people to write improper constraints to a generic. If the // user writes a constraint that is an expression and not an actual type, then parse // it out as an expression (so we can recover well), but report that a type is needed @@ -8926,7 +9099,7 @@ var ts; } } function parseParameterType() { - if (parseOptional(53 /* ColonToken */)) { + if (parseOptional(54 /* ColonToken */)) { return token === 9 /* StringLiteral */ ? parseLiteralNode(/*internName*/ true) : parseType(); @@ -8934,7 +9107,7 @@ var ts; return undefined; } function isStartOfParameter() { - return token === 22 /* DotDotDotToken */ || isIdentifierOrPattern() || ts.isModifier(token) || token === 54 /* AtToken */; + return token === 22 /* DotDotDotToken */ || isIdentifierOrPattern() || ts.isModifier(token) || token === 55 /* AtToken */; } function setModifiers(node, modifiers) { if (modifiers) { @@ -8943,7 +9116,7 @@ var ts; } } function parseParameter() { - var node = createNode(136 /* Parameter */); + var node = createNode(138 /* Parameter */); node.decorators = parseDecorators(); setModifiers(node, parseModifiers()); node.dotDotDotToken = parseOptionalToken(22 /* DotDotDotToken */); @@ -8961,7 +9134,7 @@ var ts; // to avoid this we'll advance cursor to the next token. nextToken(); } - node.questionToken = parseOptionalToken(52 /* QuestionToken */); + node.questionToken = parseOptionalToken(53 /* QuestionToken */); node.type = parseParameterType(); node.initializer = parseBindingElementInitializer(/*inParameter*/ true); // Do not check for initializers in an ambient context for parameters. This is not @@ -9037,10 +9210,10 @@ var ts; } function parseSignatureMember(kind) { var node = createNode(kind); - if (kind === 146 /* ConstructSignature */) { - parseExpected(90 /* NewKeyword */); + if (kind === 148 /* ConstructSignature */) { + parseExpected(92 /* NewKeyword */); } - fillSignature(53 /* ColonToken */, /*yieldContext*/ false, /*awaitContext*/ false, /*requireCompleteParameterList*/ false, node); + fillSignature(54 /* ColonToken */, /*yieldContext*/ false, /*awaitContext*/ false, /*requireCompleteParameterList*/ false, node); parseTypeMemberSemicolon(); return finishNode(node); } @@ -9087,21 +9260,21 @@ var ts; // A colon signifies a well formed indexer // A comma should be a badly formed indexer because comma expressions are not allowed // in computed properties. - if (token === 53 /* ColonToken */ || token === 24 /* CommaToken */) { + if (token === 54 /* ColonToken */ || token === 24 /* CommaToken */) { return true; } // Question mark could be an indexer with an optional property, // or it could be a conditional expression in a computed property. - if (token !== 52 /* QuestionToken */) { + if (token !== 53 /* QuestionToken */) { return false; } // If any of the following tokens are after the question mark, it cannot // be a conditional expression, so treat it as an indexer. nextToken(); - return token === 53 /* ColonToken */ || token === 24 /* CommaToken */ || token === 20 /* CloseBracketToken */; + return token === 54 /* ColonToken */ || token === 24 /* CommaToken */ || token === 20 /* CloseBracketToken */; } function parseIndexSignatureDeclaration(fullStart, decorators, modifiers) { - var node = createNode(147 /* IndexSignature */, fullStart); + var node = createNode(149 /* IndexSignature */, fullStart); node.decorators = decorators; setModifiers(node, modifiers); node.parameters = parseBracketedList(16 /* Parameters */, parseParameter, 19 /* OpenBracketToken */, 20 /* CloseBracketToken */); @@ -9112,19 +9285,19 @@ var ts; function parsePropertyOrMethodSignature() { var fullStart = scanner.getStartPos(); var name = parsePropertyName(); - var questionToken = parseOptionalToken(52 /* QuestionToken */); + var questionToken = parseOptionalToken(53 /* QuestionToken */); if (token === 17 /* OpenParenToken */ || token === 25 /* LessThanToken */) { - var method = createNode(140 /* MethodSignature */, fullStart); + var method = createNode(142 /* MethodSignature */, fullStart); method.name = name; method.questionToken = questionToken; // Method signatues don't exist in expression contexts. So they have neither // [Yield] nor [Await] - fillSignature(53 /* ColonToken */, /*yieldContext*/ false, /*awaitContext*/ false, /*requireCompleteParameterList*/ false, method); + fillSignature(54 /* ColonToken */, /*yieldContext*/ false, /*awaitContext*/ false, /*requireCompleteParameterList*/ false, method); parseTypeMemberSemicolon(); return finishNode(method); } else { - var property = createNode(138 /* PropertySignature */, fullStart); + var property = createNode(140 /* PropertySignature */, fullStart); property.name = name; property.questionToken = questionToken; property.type = parseTypeAnnotation(); @@ -9158,23 +9331,23 @@ var ts; nextToken(); return token === 17 /* OpenParenToken */ || token === 25 /* LessThanToken */ || - token === 52 /* QuestionToken */ || - token === 53 /* ColonToken */ || + token === 53 /* QuestionToken */ || + token === 54 /* ColonToken */ || canParseSemicolon(); } function parseTypeMember() { switch (token) { case 17 /* OpenParenToken */: case 25 /* LessThanToken */: - return parseSignatureMember(145 /* CallSignature */); + return parseSignatureMember(147 /* CallSignature */); case 19 /* OpenBracketToken */: // Indexer or computed property return isIndexSignature() ? parseIndexSignatureDeclaration(scanner.getStartPos(), /*decorators*/ undefined, /*modifiers*/ undefined) : parsePropertyOrMethodSignature(); - case 90 /* NewKeyword */: + case 92 /* NewKeyword */: if (lookAhead(isStartOfConstructSignature)) { - return parseSignatureMember(146 /* ConstructSignature */); + return parseSignatureMember(148 /* ConstructSignature */); } // fall through. case 9 /* StringLiteral */: @@ -9211,7 +9384,7 @@ var ts; return token === 17 /* OpenParenToken */ || token === 25 /* LessThanToken */; } function parseTypeLiteral() { - var node = createNode(153 /* TypeLiteral */); + var node = createNode(155 /* TypeLiteral */); node.members = parseObjectTypeMembers(); return finishNode(node); } @@ -9227,12 +9400,12 @@ var ts; return members; } function parseTupleType() { - var node = createNode(155 /* TupleType */); + var node = createNode(157 /* TupleType */); node.elementTypes = parseBracketedList(19 /* TupleElementTypes */, parseType, 19 /* OpenBracketToken */, 20 /* CloseBracketToken */); return finishNode(node); } function parseParenthesizedType() { - var node = createNode(158 /* ParenthesizedType */); + var node = createNode(160 /* ParenthesizedType */); parseExpected(17 /* OpenParenToken */); node.type = parseType(); parseExpected(18 /* CloseParenToken */); @@ -9240,8 +9413,8 @@ var ts; } function parseFunctionOrConstructorType(kind) { var node = createNode(kind); - if (kind === 151 /* ConstructorType */) { - parseExpected(90 /* NewKeyword */); + if (kind === 153 /* ConstructorType */) { + parseExpected(92 /* NewKeyword */); } fillSignature(34 /* EqualsGreaterThanToken */, /*yieldContext*/ false, /*awaitContext*/ false, /*requireCompleteParameterList*/ false, node); return finishNode(node); @@ -9252,17 +9425,18 @@ var ts; } function parseNonArrayType() { switch (token) { - case 115 /* AnyKeyword */: - case 128 /* StringKeyword */: - case 126 /* NumberKeyword */: - case 118 /* BooleanKeyword */: - case 129 /* SymbolKeyword */: + case 117 /* AnyKeyword */: + case 130 /* StringKeyword */: + case 128 /* NumberKeyword */: + case 120 /* BooleanKeyword */: + case 131 /* SymbolKeyword */: // If these are followed by a dot, then parse these out as a dotted type reference instead. var node = tryParse(parseKeywordAndNoDot); return node || parseTypeReferenceOrTypePredicate(); - case 101 /* VoidKeyword */: + case 103 /* VoidKeyword */: + case 97 /* ThisKeyword */: return parseTokenNode(); - case 99 /* TypeOfKeyword */: + case 101 /* TypeOfKeyword */: return parseTypeQuery(); case 15 /* OpenBraceToken */: return parseTypeLiteral(); @@ -9276,17 +9450,18 @@ var ts; } function isStartOfType() { switch (token) { - case 115 /* AnyKeyword */: - case 128 /* StringKeyword */: - case 126 /* NumberKeyword */: - case 118 /* BooleanKeyword */: - case 129 /* SymbolKeyword */: - case 101 /* VoidKeyword */: - case 99 /* TypeOfKeyword */: + case 117 /* AnyKeyword */: + case 130 /* StringKeyword */: + case 128 /* NumberKeyword */: + case 120 /* BooleanKeyword */: + case 131 /* SymbolKeyword */: + case 103 /* VoidKeyword */: + case 97 /* ThisKeyword */: + case 101 /* TypeOfKeyword */: case 15 /* OpenBraceToken */: case 19 /* OpenBracketToken */: case 25 /* LessThanToken */: - case 90 /* NewKeyword */: + case 92 /* NewKeyword */: return true; case 17 /* OpenParenToken */: // Only consider '(' the start of a type if followed by ')', '...', an identifier, a modifier, @@ -9304,7 +9479,7 @@ var ts; var type = parseNonArrayType(); while (!scanner.hasPrecedingLineBreak() && parseOptional(19 /* OpenBracketToken */)) { parseExpected(20 /* CloseBracketToken */); - var node = createNode(154 /* ArrayType */, type.pos); + var node = createNode(156 /* ArrayType */, type.pos); node.elementType = type; type = finishNode(node); } @@ -9326,10 +9501,10 @@ var ts; return type; } function parseIntersectionTypeOrHigher() { - return parseUnionOrIntersectionType(157 /* IntersectionType */, parseArrayTypeOrHigher, 45 /* AmpersandToken */); + return parseUnionOrIntersectionType(159 /* IntersectionType */, parseArrayTypeOrHigher, 46 /* AmpersandToken */); } function parseUnionTypeOrHigher() { - return parseUnionOrIntersectionType(156 /* UnionType */, parseIntersectionTypeOrHigher, 46 /* BarToken */); + return parseUnionOrIntersectionType(158 /* UnionType */, parseIntersectionTypeOrHigher, 47 /* BarToken */); } function isStartOfFunctionType() { if (token === 25 /* LessThanToken */) { @@ -9346,8 +9521,8 @@ var ts; } if (isIdentifier() || ts.isModifier(token)) { nextToken(); - if (token === 53 /* ColonToken */ || token === 24 /* CommaToken */ || - token === 52 /* QuestionToken */ || token === 55 /* EqualsToken */ || + if (token === 54 /* ColonToken */ || token === 24 /* CommaToken */ || + token === 53 /* QuestionToken */ || token === 56 /* EqualsToken */ || isIdentifier() || ts.isModifier(token)) { // ( id : // ( id , @@ -9373,24 +9548,24 @@ var ts; } function parseTypeWorker() { if (isStartOfFunctionType()) { - return parseFunctionOrConstructorType(150 /* FunctionType */); + return parseFunctionOrConstructorType(152 /* FunctionType */); } - if (token === 90 /* NewKeyword */) { - return parseFunctionOrConstructorType(151 /* ConstructorType */); + if (token === 92 /* NewKeyword */) { + return parseFunctionOrConstructorType(153 /* ConstructorType */); } return parseUnionTypeOrHigher(); } function parseTypeAnnotation() { - return parseOptional(53 /* ColonToken */) ? parseType() : undefined; + return parseOptional(54 /* ColonToken */) ? parseType() : undefined; } // EXPRESSIONS function isStartOfLeftHandSideExpression() { switch (token) { - case 95 /* ThisKeyword */: - case 93 /* SuperKeyword */: - case 91 /* NullKeyword */: - case 97 /* TrueKeyword */: - case 82 /* FalseKeyword */: + case 97 /* ThisKeyword */: + case 95 /* SuperKeyword */: + case 93 /* NullKeyword */: + case 99 /* TrueKeyword */: + case 84 /* FalseKeyword */: case 8 /* NumericLiteral */: case 9 /* StringLiteral */: case 11 /* NoSubstitutionTemplateLiteral */: @@ -9398,12 +9573,12 @@ var ts; case 17 /* OpenParenToken */: case 19 /* OpenBracketToken */: case 15 /* OpenBraceToken */: - case 85 /* FunctionKeyword */: - case 71 /* ClassKeyword */: - case 90 /* NewKeyword */: - case 38 /* SlashToken */: - case 59 /* SlashEqualsToken */: - case 67 /* Identifier */: + case 87 /* FunctionKeyword */: + case 73 /* ClassKeyword */: + case 92 /* NewKeyword */: + case 39 /* SlashToken */: + case 61 /* SlashEqualsToken */: + case 69 /* Identifier */: return true; default: return isIdentifier(); @@ -9416,16 +9591,16 @@ var ts; switch (token) { case 35 /* PlusToken */: case 36 /* MinusToken */: - case 49 /* TildeToken */: - case 48 /* ExclamationToken */: - case 76 /* DeleteKeyword */: - case 99 /* TypeOfKeyword */: - case 101 /* VoidKeyword */: - case 40 /* PlusPlusToken */: - case 41 /* MinusMinusToken */: + case 50 /* TildeToken */: + case 49 /* ExclamationToken */: + case 78 /* DeleteKeyword */: + case 101 /* TypeOfKeyword */: + case 103 /* VoidKeyword */: + case 41 /* PlusPlusToken */: + case 42 /* MinusMinusToken */: case 25 /* LessThanToken */: - case 117 /* AwaitKeyword */: - case 112 /* YieldKeyword */: + case 119 /* AwaitKeyword */: + case 114 /* YieldKeyword */: // Yield/await always starts an expression. Either it is an identifier (in which case // it is definitely an expression). Or it's a keyword (either because we're in // a generator or async function, or in strict mode (or both)) and it started a yield or await expression. @@ -9444,9 +9619,9 @@ var ts; function isStartOfExpressionStatement() { // As per the grammar, none of '{' or 'function' or 'class' can start an expression statement. return token !== 15 /* OpenBraceToken */ && - token !== 85 /* FunctionKeyword */ && - token !== 71 /* ClassKeyword */ && - token !== 54 /* AtToken */ && + token !== 87 /* FunctionKeyword */ && + token !== 73 /* ClassKeyword */ && + token !== 55 /* AtToken */ && isStartOfExpression(); } function allowInAndParseExpression() { @@ -9472,7 +9647,7 @@ var ts; return expr; } function parseInitializer(inParameter) { - if (token !== 55 /* EqualsToken */) { + if (token !== 56 /* EqualsToken */) { // It's not uncommon during typing for the user to miss writing the '=' token. Check if // there is no newline after the last token and if we're on an expression. If so, parse // this as an equals-value clause with a missing equals. @@ -9489,7 +9664,7 @@ var ts; } // Initializer[In, Yield] : // = AssignmentExpression[?In, ?Yield] - parseExpected(55 /* EqualsToken */); + parseExpected(56 /* EqualsToken */); return parseAssignmentExpressionOrHigher(); } function parseAssignmentExpressionOrHigher() { @@ -9527,7 +9702,7 @@ var ts; // To avoid a look-ahead, we did not handle the case of an arrow function with a single un-parenthesized // parameter ('x => ...') above. We handle it here by checking if the parsed expression was a single // identifier and the current token is an arrow. - if (expr.kind === 67 /* Identifier */ && token === 34 /* EqualsGreaterThanToken */) { + if (expr.kind === 69 /* Identifier */ && token === 34 /* EqualsGreaterThanToken */) { return parseSimpleArrowFunctionExpression(expr); } // Now see if we might be in cases '2' or '3'. @@ -9543,7 +9718,7 @@ var ts; return parseConditionalExpressionRest(expr); } function isYieldExpression() { - if (token === 112 /* YieldKeyword */) { + if (token === 114 /* YieldKeyword */) { // If we have a 'yield' keyword, and htis is a context where yield expressions are // allowed, then definitely parse out a yield expression. if (inYieldContext()) { @@ -9572,7 +9747,7 @@ var ts; return !scanner.hasPrecedingLineBreak() && isIdentifier(); } function parseYieldExpression() { - var node = createNode(182 /* YieldExpression */); + var node = createNode(184 /* YieldExpression */); // YieldExpression[In] : // yield // yield [no LineTerminator here] [Lexical goal InputElementRegExp]AssignmentExpression[?In, Yield] @@ -9592,8 +9767,8 @@ var ts; } function parseSimpleArrowFunctionExpression(identifier) { ts.Debug.assert(token === 34 /* EqualsGreaterThanToken */, "parseSimpleArrowFunctionExpression should only have been called if we had a =>"); - var node = createNode(172 /* ArrowFunction */, identifier.pos); - var parameter = createNode(136 /* Parameter */, identifier.pos); + var node = createNode(174 /* ArrowFunction */, identifier.pos); + var parameter = createNode(138 /* Parameter */, identifier.pos); parameter.name = identifier; finishNode(parameter); node.parameters = [parameter]; @@ -9635,7 +9810,7 @@ var ts; // Unknown -> There *might* be a parenthesized arrow function here. // Speculatively look ahead to be sure, and rollback if not. function isParenthesizedArrowFunctionExpression() { - if (token === 17 /* OpenParenToken */ || token === 25 /* LessThanToken */ || token === 116 /* AsyncKeyword */) { + if (token === 17 /* OpenParenToken */ || token === 25 /* LessThanToken */ || token === 118 /* AsyncKeyword */) { return lookAhead(isParenthesizedArrowFunctionExpressionWorker); } if (token === 34 /* EqualsGreaterThanToken */) { @@ -9648,7 +9823,7 @@ var ts; return 0 /* False */; } function isParenthesizedArrowFunctionExpressionWorker() { - if (token === 116 /* AsyncKeyword */) { + if (token === 118 /* AsyncKeyword */) { nextToken(); if (scanner.hasPrecedingLineBreak()) { return 0 /* False */; @@ -9668,7 +9843,7 @@ var ts; var third = nextToken(); switch (third) { case 34 /* EqualsGreaterThanToken */: - case 53 /* ColonToken */: + case 54 /* ColonToken */: case 15 /* OpenBraceToken */: return 1 /* True */; default: @@ -9699,7 +9874,7 @@ var ts; } // If we have something like "(a:", then we must have a // type-annotated parameter in an arrow function expression. - if (nextToken() === 53 /* ColonToken */) { + if (nextToken() === 54 /* ColonToken */) { return 1 /* True */; } // This *could* be a parenthesized arrow function. @@ -9717,10 +9892,10 @@ var ts; if (sourceFile.languageVariant === 1 /* JSX */) { var isArrowFunctionInJsx = lookAhead(function () { var third = nextToken(); - if (third === 81 /* ExtendsKeyword */) { + if (third === 83 /* ExtendsKeyword */) { var fourth = nextToken(); switch (fourth) { - case 55 /* EqualsToken */: + case 56 /* EqualsToken */: case 27 /* GreaterThanToken */: return false; default: @@ -9745,7 +9920,7 @@ var ts; return parseParenthesizedArrowFunctionExpressionHead(/*allowAmbiguity*/ false); } function parseParenthesizedArrowFunctionExpressionHead(allowAmbiguity) { - var node = createNode(172 /* ArrowFunction */); + var node = createNode(174 /* ArrowFunction */); setModifiers(node, parseModifiersForArrowFunction()); var isAsync = !!(node.flags & 512 /* Async */); // Arrow functions are never generators. @@ -9755,7 +9930,7 @@ var ts; // a => (b => c) // And think that "(b =>" was actually a parenthesized arrow function with a missing // close paren. - fillSignature(53 /* ColonToken */, /*yieldContext*/ false, /*awaitContext*/ isAsync, /*requireCompleteParameterList*/ !allowAmbiguity, node); + fillSignature(54 /* ColonToken */, /*yieldContext*/ false, /*awaitContext*/ isAsync, /*requireCompleteParameterList*/ !allowAmbiguity, node); // If we couldn't get parameters, we definitely could not parse out an arrow function. if (!node.parameters) { return undefined; @@ -9779,8 +9954,8 @@ var ts; return parseFunctionBlock(/*allowYield*/ false, /*allowAwait*/ isAsync, /*ignoreMissingOpenBrace*/ false); } if (token !== 23 /* SemicolonToken */ && - token !== 85 /* FunctionKeyword */ && - token !== 71 /* ClassKeyword */ && + token !== 87 /* FunctionKeyword */ && + token !== 73 /* ClassKeyword */ && isStartOfStatement() && !isStartOfExpressionStatement()) { // Check if we got a plain statement (i.e. no expression-statements, no function/class expressions/declarations) @@ -9805,17 +9980,17 @@ var ts; } function parseConditionalExpressionRest(leftOperand) { // Note: we are passed in an expression which was produced from parseBinaryExpressionOrHigher. - var questionToken = parseOptionalToken(52 /* QuestionToken */); + var questionToken = parseOptionalToken(53 /* QuestionToken */); if (!questionToken) { return leftOperand; } // Note: we explicitly 'allowIn' in the whenTrue part of the condition expression, and // we do not that for the 'whenFalse' part. - var node = createNode(180 /* ConditionalExpression */, leftOperand.pos); + var node = createNode(182 /* ConditionalExpression */, leftOperand.pos); node.condition = leftOperand; node.questionToken = questionToken; node.whenTrue = doOutsideOfContext(disallowInAndDecoratorContext, parseAssignmentExpressionOrHigher); - node.colonToken = parseExpectedToken(53 /* ColonToken */, /*reportAtCurrentPosition*/ false, ts.Diagnostics._0_expected, ts.tokenToString(53 /* ColonToken */)); + node.colonToken = parseExpectedToken(54 /* ColonToken */, /*reportAtCurrentPosition*/ false, ts.Diagnostics._0_expected, ts.tokenToString(54 /* ColonToken */)); node.whenFalse = parseAssignmentExpressionOrHigher(); return finishNode(node); } @@ -9824,7 +9999,7 @@ var ts; return parseBinaryExpressionRest(precedence, leftOperand); } function isInOrOfKeyword(t) { - return t === 88 /* InKeyword */ || t === 132 /* OfKeyword */; + return t === 90 /* InKeyword */ || t === 134 /* OfKeyword */; } function parseBinaryExpressionRest(precedence, leftOperand) { while (true) { @@ -9833,13 +10008,36 @@ var ts; reScanGreaterToken(); var newPrecedence = getBinaryOperatorPrecedence(); // Check the precedence to see if we should "take" this operator - if (newPrecedence <= precedence) { + // - For left associative operator (all operator but **), consume the operator, + // recursively call the function below, and parse binaryExpression as a rightOperand + // of the caller if the new precendence of the operator is greater then or equal to the current precendence. + // For example: + // a - b - c; + // ^token; leftOperand = b. Return b to the caller as a rightOperand + // a * b - c + // ^token; leftOperand = b. Return b to the caller as a rightOperand + // a - b * c; + // ^token; leftOperand = b. Return b * c to the caller as a rightOperand + // - For right associative operator (**), consume the operator, recursively call the function + // and parse binaryExpression as a rightOperand of the caller if the new precendence of + // the operator is strictly grater than the current precendence + // For example: + // a ** b ** c; + // ^^token; leftOperand = b. Return b ** c to the caller as a rightOperand + // a - b ** c; + // ^^token; leftOperand = b. Return b ** c to the caller as a rightOperand + // a ** b - c + // ^token; leftOperand = b. Return b to the caller as a rightOperand + var consumeCurrentOperator = token === 38 /* AsteriskAsteriskToken */ ? + newPrecedence >= precedence : + newPrecedence > precedence; + if (!consumeCurrentOperator) { break; } - if (token === 88 /* InKeyword */ && inDisallowInContext()) { + if (token === 90 /* InKeyword */ && inDisallowInContext()) { break; } - if (token === 114 /* AsKeyword */) { + if (token === 116 /* AsKeyword */) { // Make sure we *do* perform ASI for constructs like this: // var x = foo // as (Bar) @@ -9860,22 +10058,22 @@ var ts; return leftOperand; } function isBinaryOperator() { - if (inDisallowInContext() && token === 88 /* InKeyword */) { + if (inDisallowInContext() && token === 90 /* InKeyword */) { return false; } return getBinaryOperatorPrecedence() > 0; } function getBinaryOperatorPrecedence() { switch (token) { - case 51 /* BarBarToken */: + case 52 /* BarBarToken */: return 1; - case 50 /* AmpersandAmpersandToken */: + case 51 /* AmpersandAmpersandToken */: return 2; - case 46 /* BarToken */: + case 47 /* BarToken */: return 3; - case 47 /* CaretToken */: + case 48 /* CaretToken */: return 4; - case 45 /* AmpersandToken */: + case 46 /* AmpersandToken */: return 5; case 30 /* EqualsEqualsToken */: case 31 /* ExclamationEqualsToken */: @@ -9886,66 +10084,68 @@ var ts; case 27 /* GreaterThanToken */: case 28 /* LessThanEqualsToken */: case 29 /* GreaterThanEqualsToken */: - case 89 /* InstanceOfKeyword */: - case 88 /* InKeyword */: - case 114 /* AsKeyword */: + case 91 /* InstanceOfKeyword */: + case 90 /* InKeyword */: + case 116 /* AsKeyword */: return 7; - case 42 /* LessThanLessThanToken */: - case 43 /* GreaterThanGreaterThanToken */: - case 44 /* GreaterThanGreaterThanGreaterThanToken */: + case 43 /* LessThanLessThanToken */: + case 44 /* GreaterThanGreaterThanToken */: + case 45 /* GreaterThanGreaterThanGreaterThanToken */: return 8; case 35 /* PlusToken */: case 36 /* MinusToken */: return 9; case 37 /* AsteriskToken */: - case 38 /* SlashToken */: - case 39 /* PercentToken */: + case 39 /* SlashToken */: + case 40 /* PercentToken */: return 10; + case 38 /* AsteriskAsteriskToken */: + return 11; } // -1 is lower than all other precedences. Returning it will cause binary expression // parsing to stop. return -1; } function makeBinaryExpression(left, operatorToken, right) { - var node = createNode(179 /* BinaryExpression */, left.pos); + var node = createNode(181 /* BinaryExpression */, left.pos); node.left = left; node.operatorToken = operatorToken; node.right = right; return finishNode(node); } function makeAsExpression(left, right) { - var node = createNode(187 /* AsExpression */, left.pos); + var node = createNode(189 /* AsExpression */, left.pos); node.expression = left; node.type = right; return finishNode(node); } function parsePrefixUnaryExpression() { - var node = createNode(177 /* PrefixUnaryExpression */); + var node = createNode(179 /* PrefixUnaryExpression */); node.operator = token; nextToken(); - node.operand = parseUnaryExpressionOrHigher(); + node.operand = parseSimpleUnaryExpression(); return finishNode(node); } function parseDeleteExpression() { - var node = createNode(173 /* DeleteExpression */); + var node = createNode(175 /* DeleteExpression */); nextToken(); - node.expression = parseUnaryExpressionOrHigher(); + node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function parseTypeOfExpression() { - var node = createNode(174 /* TypeOfExpression */); + var node = createNode(176 /* TypeOfExpression */); nextToken(); - node.expression = parseUnaryExpressionOrHigher(); + node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function parseVoidExpression() { - var node = createNode(175 /* VoidExpression */); + var node = createNode(177 /* VoidExpression */); nextToken(); - node.expression = parseUnaryExpressionOrHigher(); + node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function isAwaitExpression() { - if (token === 117 /* AwaitKeyword */) { + if (token === 119 /* AwaitKeyword */) { if (inAwaitContext()) { return true; } @@ -9955,46 +10155,137 @@ var ts; return false; } function parseAwaitExpression() { - var node = createNode(176 /* AwaitExpression */); + var node = createNode(178 /* AwaitExpression */); nextToken(); - node.expression = parseUnaryExpressionOrHigher(); + node.expression = parseSimpleUnaryExpression(); return finishNode(node); } + /** + * Parse ES7 unary expression and await expression + * + * ES7 UnaryExpression: + * 1) SimpleUnaryExpression[?yield] + * 2) IncrementExpression[?yield] ** UnaryExpression[?yield] + */ function parseUnaryExpressionOrHigher() { if (isAwaitExpression()) { return parseAwaitExpression(); } + if (isIncrementExpression()) { + var incrementExpression = parseIncrementExpression(); + return token === 38 /* AsteriskAsteriskToken */ ? + parseBinaryExpressionRest(getBinaryOperatorPrecedence(), incrementExpression) : + incrementExpression; + } + var unaryOperator = token; + var simpleUnaryExpression = parseSimpleUnaryExpression(); + if (token === 38 /* AsteriskAsteriskToken */) { + var diagnostic; + var start = ts.skipTrivia(sourceText, simpleUnaryExpression.pos); + if (simpleUnaryExpression.kind === 171 /* TypeAssertionExpression */) { + parseErrorAtPosition(start, simpleUnaryExpression.end - start, ts.Diagnostics.A_type_assertion_expression_is_not_allowed_in_the_left_hand_side_of_an_exponentiation_expression_Consider_enclosing_the_expression_in_parentheses); + } + else { + parseErrorAtPosition(start, simpleUnaryExpression.end - start, ts.Diagnostics.An_unary_expression_with_the_0_operator_is_not_allowed_in_the_left_hand_side_of_an_exponentiation_expression_Consider_enclosing_the_expression_in_parentheses, ts.tokenToString(unaryOperator)); + } + } + return simpleUnaryExpression; + } + /** + * Parse ES7 simple-unary expression or higher: + * + * ES7 SimpleUnaryExpression: + * 1) IncrementExpression[?yield] + * 2) delete UnaryExpression[?yield] + * 3) void UnaryExpression[?yield] + * 4) typeof UnaryExpression[?yield] + * 5) + UnaryExpression[?yield] + * 6) - UnaryExpression[?yield] + * 7) ~ UnaryExpression[?yield] + * 8) ! UnaryExpression[?yield] + */ + function parseSimpleUnaryExpression() { switch (token) { case 35 /* PlusToken */: case 36 /* MinusToken */: - case 49 /* TildeToken */: - case 48 /* ExclamationToken */: - case 40 /* PlusPlusToken */: - case 41 /* MinusMinusToken */: + case 50 /* TildeToken */: + case 49 /* ExclamationToken */: return parsePrefixUnaryExpression(); - case 76 /* DeleteKeyword */: + case 78 /* DeleteKeyword */: return parseDeleteExpression(); - case 99 /* TypeOfKeyword */: + case 101 /* TypeOfKeyword */: return parseTypeOfExpression(); - case 101 /* VoidKeyword */: + case 103 /* VoidKeyword */: return parseVoidExpression(); case 25 /* LessThanToken */: - if (sourceFile.languageVariant !== 1 /* JSX */) { - return parseTypeAssertion(); - } - if (lookAhead(nextTokenIsIdentifierOrKeyword)) { - return parseJsxElementOrSelfClosingElement(/*inExpressionContext*/ true); - } - // Fall through + // This is modified UnaryExpression grammar in TypeScript + // UnaryExpression (modified): + // < type > UnaryExpression + return parseTypeAssertion(); default: - return parsePostfixExpressionOrHigher(); + return parseIncrementExpression(); } } - function parsePostfixExpressionOrHigher() { + /** + * Check if the current token can possibly be an ES7 increment expression. + * + * ES7 IncrementExpression: + * LeftHandSideExpression[?Yield] + * LeftHandSideExpression[?Yield][no LineTerminator here]++ + * LeftHandSideExpression[?Yield][no LineTerminator here]-- + * ++LeftHandSideExpression[?Yield] + * --LeftHandSideExpression[?Yield] + */ + function isIncrementExpression() { + // This function is called inside parseUnaryExpression to decide + // whether to call parseSimpleUnaryExpression or call parseIncrmentExpression directly + switch (token) { + case 35 /* PlusToken */: + case 36 /* MinusToken */: + case 50 /* TildeToken */: + case 49 /* ExclamationToken */: + case 78 /* DeleteKeyword */: + case 101 /* TypeOfKeyword */: + case 103 /* VoidKeyword */: + return false; + case 25 /* LessThanToken */: + // If we are not in JSX context, we are parsing TypeAssertion which is an UnaryExpression + if (sourceFile.languageVariant !== 1 /* JSX */) { + return false; + } + // We are in JSX context and the token is part of JSXElement. + // Fall through + default: + return true; + } + } + /** + * Parse ES7 IncrementExpression. IncrementExpression is used instead of ES6's PostFixExpression. + * + * ES7 IncrementExpression[yield]: + * 1) LeftHandSideExpression[?yield] + * 2) LeftHandSideExpression[?yield] [[no LineTerminator here]]++ + * 3) LeftHandSideExpression[?yield] [[no LineTerminator here]]-- + * 4) ++LeftHandSideExpression[?yield] + * 5) --LeftHandSideExpression[?yield] + * In TypeScript (2), (3) are parsed as PostfixUnaryExpression. (4), (5) are parsed as PrefixUnaryExpression + */ + function parseIncrementExpression() { + if (token === 41 /* PlusPlusToken */ || token === 42 /* MinusMinusToken */) { + var node = createNode(179 /* PrefixUnaryExpression */); + node.operator = token; + nextToken(); + node.operand = parseLeftHandSideExpressionOrHigher(); + return finishNode(node); + } + else if (sourceFile.languageVariant === 1 /* JSX */ && token === 25 /* LessThanToken */ && lookAhead(nextTokenIsIdentifierOrKeyword)) { + // JSXElement is part of primaryExpression + return parseJsxElementOrSelfClosingElement(/*inExpressionContext*/ true); + } var expression = parseLeftHandSideExpressionOrHigher(); ts.Debug.assert(ts.isLeftHandSideExpression(expression)); - if ((token === 40 /* PlusPlusToken */ || token === 41 /* MinusMinusToken */) && !scanner.hasPrecedingLineBreak()) { - var node = createNode(178 /* PostfixUnaryExpression */, expression.pos); + if ((token === 41 /* PlusPlusToken */ || token === 42 /* MinusMinusToken */) && !scanner.hasPrecedingLineBreak()) { + var node = createNode(180 /* PostfixUnaryExpression */, expression.pos); node.operand = expression; node.operator = token; nextToken(); @@ -10033,7 +10324,7 @@ var ts; // the last two CallExpression productions. Or we have a MemberExpression which either // completes the LeftHandSideExpression, or starts the beginning of the first four // CallExpression productions. - var expression = token === 93 /* SuperKeyword */ + var expression = token === 95 /* SuperKeyword */ ? parseSuperExpression() : parseMemberExpressionOrHigher(); // Now, we *may* be complete. However, we might have consumed the start of a @@ -10098,7 +10389,7 @@ var ts; } // If we have seen "super" it must be followed by '(' or '.'. // If it wasn't then just try to parse out a '.' and report an error. - var node = createNode(164 /* PropertyAccessExpression */, expression.pos); + var node = createNode(166 /* PropertyAccessExpression */, expression.pos); node.expression = expression; node.dotToken = parseExpectedToken(21 /* DotToken */, /*reportAtCurrentPosition*/ false, ts.Diagnostics.super_must_be_followed_by_an_argument_list_or_member_access); node.name = parseRightSideOfDot(/*allowIdentifierNames*/ true); @@ -10106,27 +10397,27 @@ var ts; } function parseJsxElementOrSelfClosingElement(inExpressionContext) { var opening = parseJsxOpeningOrSelfClosingElement(inExpressionContext); - if (opening.kind === 233 /* JsxOpeningElement */) { - var node = createNode(231 /* JsxElement */, opening.pos); + if (opening.kind === 235 /* JsxOpeningElement */) { + var node = createNode(233 /* JsxElement */, opening.pos); node.openingElement = opening; node.children = parseJsxChildren(node.openingElement.tagName); node.closingElement = parseJsxClosingElement(inExpressionContext); return finishNode(node); } else { - ts.Debug.assert(opening.kind === 232 /* JsxSelfClosingElement */); + ts.Debug.assert(opening.kind === 234 /* JsxSelfClosingElement */); // Nothing else to do for self-closing elements return opening; } } function parseJsxText() { - var node = createNode(234 /* JsxText */, scanner.getStartPos()); + var node = createNode(236 /* JsxText */, scanner.getStartPos()); token = scanner.scanJsxToken(); return finishNode(node); } function parseJsxChild() { switch (token) { - case 234 /* JsxText */: + case 236 /* JsxText */: return parseJsxText(); case 15 /* OpenBraceToken */: return parseJsxExpression(/*inExpressionContext*/ false); @@ -10165,11 +10456,11 @@ var ts; // Closing tag, so scan the immediately-following text with the JSX scanning instead // of regular scanning to avoid treating illegal characters (e.g. '#') as immediate // scanning errors - node = createNode(233 /* JsxOpeningElement */, fullStart); + node = createNode(235 /* JsxOpeningElement */, fullStart); scanJsxText(); } else { - parseExpected(38 /* SlashToken */); + parseExpected(39 /* SlashToken */); if (inExpressionContext) { parseExpected(27 /* GreaterThanToken */); } @@ -10177,7 +10468,7 @@ var ts; parseExpected(27 /* GreaterThanToken */, /*diagnostic*/ undefined, /*advance*/ false); scanJsxText(); } - node = createNode(232 /* JsxSelfClosingElement */, fullStart); + node = createNode(234 /* JsxSelfClosingElement */, fullStart); } node.tagName = tagName; node.attributes = attributes; @@ -10188,7 +10479,7 @@ var ts; var elementName = parseIdentifierName(); while (parseOptional(21 /* DotToken */)) { scanJsxIdentifier(); - var node = createNode(133 /* QualifiedName */, elementName.pos); + var node = createNode(135 /* QualifiedName */, elementName.pos); node.left = elementName; node.right = parseIdentifierName(); elementName = finishNode(node); @@ -10196,7 +10487,7 @@ var ts; return elementName; } function parseJsxExpression(inExpressionContext) { - var node = createNode(238 /* JsxExpression */); + var node = createNode(240 /* JsxExpression */); parseExpected(15 /* OpenBraceToken */); if (token !== 16 /* CloseBraceToken */) { node.expression = parseExpression(); @@ -10215,9 +10506,9 @@ var ts; return parseJsxSpreadAttribute(); } scanJsxIdentifier(); - var node = createNode(236 /* JsxAttribute */); + var node = createNode(238 /* JsxAttribute */); node.name = parseIdentifierName(); - if (parseOptional(55 /* EqualsToken */)) { + if (parseOptional(56 /* EqualsToken */)) { switch (token) { case 9 /* StringLiteral */: node.initializer = parseLiteralNode(); @@ -10230,7 +10521,7 @@ var ts; return finishNode(node); } function parseJsxSpreadAttribute() { - var node = createNode(237 /* JsxSpreadAttribute */); + var node = createNode(239 /* JsxSpreadAttribute */); parseExpected(15 /* OpenBraceToken */); parseExpected(22 /* DotDotDotToken */); node.expression = parseExpression(); @@ -10238,7 +10529,7 @@ var ts; return finishNode(node); } function parseJsxClosingElement(inExpressionContext) { - var node = createNode(235 /* JsxClosingElement */); + var node = createNode(237 /* JsxClosingElement */); parseExpected(26 /* LessThanSlashToken */); node.tagName = parseJsxElementName(); if (inExpressionContext) { @@ -10251,18 +10542,18 @@ var ts; return finishNode(node); } function parseTypeAssertion() { - var node = createNode(169 /* TypeAssertionExpression */); + var node = createNode(171 /* TypeAssertionExpression */); parseExpected(25 /* LessThanToken */); node.type = parseType(); parseExpected(27 /* GreaterThanToken */); - node.expression = parseUnaryExpressionOrHigher(); + node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function parseMemberExpressionRest(expression) { while (true) { var dotToken = parseOptionalToken(21 /* DotToken */); if (dotToken) { - var propertyAccess = createNode(164 /* PropertyAccessExpression */, expression.pos); + var propertyAccess = createNode(166 /* PropertyAccessExpression */, expression.pos); propertyAccess.expression = expression; propertyAccess.dotToken = dotToken; propertyAccess.name = parseRightSideOfDot(/*allowIdentifierNames*/ true); @@ -10271,7 +10562,7 @@ var ts; } // when in the [Decorator] context, we do not parse ElementAccess as it could be part of a ComputedPropertyName if (!inDecoratorContext() && parseOptional(19 /* OpenBracketToken */)) { - var indexedAccess = createNode(165 /* ElementAccessExpression */, expression.pos); + var indexedAccess = createNode(167 /* ElementAccessExpression */, expression.pos); indexedAccess.expression = expression; // It's not uncommon for a user to write: "new Type[]". // Check for that common pattern and report a better error message. @@ -10287,7 +10578,7 @@ var ts; continue; } if (token === 11 /* NoSubstitutionTemplateLiteral */ || token === 12 /* TemplateHead */) { - var tagExpression = createNode(168 /* TaggedTemplateExpression */, expression.pos); + var tagExpression = createNode(170 /* TaggedTemplateExpression */, expression.pos); tagExpression.tag = expression; tagExpression.template = token === 11 /* NoSubstitutionTemplateLiteral */ ? parseLiteralNode() @@ -10310,7 +10601,7 @@ var ts; if (!typeArguments) { return expression; } - var callExpr = createNode(166 /* CallExpression */, expression.pos); + var callExpr = createNode(168 /* CallExpression */, expression.pos); callExpr.expression = expression; callExpr.typeArguments = typeArguments; callExpr.arguments = parseArgumentList(); @@ -10318,7 +10609,7 @@ var ts; continue; } else if (token === 17 /* OpenParenToken */) { - var callExpr = createNode(166 /* CallExpression */, expression.pos); + var callExpr = createNode(168 /* CallExpression */, expression.pos); callExpr.expression = expression; callExpr.arguments = parseArgumentList(); expression = finishNode(callExpr); @@ -10356,18 +10647,18 @@ var ts; case 21 /* DotToken */: // foo. case 18 /* CloseParenToken */: // foo) case 20 /* CloseBracketToken */: // foo] - case 53 /* ColonToken */: // foo: + case 54 /* ColonToken */: // foo: case 23 /* SemicolonToken */: // foo; - case 52 /* QuestionToken */: // foo? + case 53 /* QuestionToken */: // foo? case 30 /* EqualsEqualsToken */: // foo == case 32 /* EqualsEqualsEqualsToken */: // foo === case 31 /* ExclamationEqualsToken */: // foo != case 33 /* ExclamationEqualsEqualsToken */: // foo !== - case 50 /* AmpersandAmpersandToken */: // foo && - case 51 /* BarBarToken */: // foo || - case 47 /* CaretToken */: // foo ^ - case 45 /* AmpersandToken */: // foo & - case 46 /* BarToken */: // foo | + case 51 /* AmpersandAmpersandToken */: // foo && + case 52 /* BarBarToken */: // foo || + case 48 /* CaretToken */: // foo ^ + case 46 /* AmpersandToken */: // foo & + case 47 /* BarToken */: // foo | case 16 /* CloseBraceToken */: // foo } case 1 /* EndOfFileToken */: // these cases can't legally follow a type arg list. However, they're not legal @@ -10390,11 +10681,11 @@ var ts; case 9 /* StringLiteral */: case 11 /* NoSubstitutionTemplateLiteral */: return parseLiteralNode(); - case 95 /* ThisKeyword */: - case 93 /* SuperKeyword */: - case 91 /* NullKeyword */: - case 97 /* TrueKeyword */: - case 82 /* FalseKeyword */: + case 97 /* ThisKeyword */: + case 95 /* SuperKeyword */: + case 93 /* NullKeyword */: + case 99 /* TrueKeyword */: + case 84 /* FalseKeyword */: return parseTokenNode(); case 17 /* OpenParenToken */: return parseParenthesizedExpression(); @@ -10402,7 +10693,7 @@ var ts; return parseArrayLiteralExpression(); case 15 /* OpenBraceToken */: return parseObjectLiteralExpression(); - case 116 /* AsyncKeyword */: + case 118 /* AsyncKeyword */: // Async arrow functions are parsed earlier in parseAssignmentExpressionOrHigher. // If we encounter `async [no LineTerminator here] function` then this is an async // function; otherwise, its an identifier. @@ -10410,14 +10701,14 @@ var ts; break; } return parseFunctionExpression(); - case 71 /* ClassKeyword */: + case 73 /* ClassKeyword */: return parseClassExpression(); - case 85 /* FunctionKeyword */: + case 87 /* FunctionKeyword */: return parseFunctionExpression(); - case 90 /* NewKeyword */: + case 92 /* NewKeyword */: return parseNewExpression(); - case 38 /* SlashToken */: - case 59 /* SlashEqualsToken */: + case 39 /* SlashToken */: + case 61 /* SlashEqualsToken */: if (reScanSlashToken() === 10 /* RegularExpressionLiteral */) { return parseLiteralNode(); } @@ -10428,28 +10719,28 @@ var ts; return parseIdentifier(ts.Diagnostics.Expression_expected); } function parseParenthesizedExpression() { - var node = createNode(170 /* ParenthesizedExpression */); + var node = createNode(172 /* ParenthesizedExpression */); parseExpected(17 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); parseExpected(18 /* CloseParenToken */); return finishNode(node); } function parseSpreadElement() { - var node = createNode(183 /* SpreadElementExpression */); + var node = createNode(185 /* SpreadElementExpression */); parseExpected(22 /* DotDotDotToken */); node.expression = parseAssignmentExpressionOrHigher(); return finishNode(node); } function parseArgumentOrArrayLiteralElement() { return token === 22 /* DotDotDotToken */ ? parseSpreadElement() : - token === 24 /* CommaToken */ ? createNode(185 /* OmittedExpression */) : + token === 24 /* CommaToken */ ? createNode(187 /* OmittedExpression */) : parseAssignmentExpressionOrHigher(); } function parseArgumentExpression() { return doOutsideOfContext(disallowInAndDecoratorContext, parseArgumentOrArrayLiteralElement); } function parseArrayLiteralExpression() { - var node = createNode(162 /* ArrayLiteralExpression */); + var node = createNode(164 /* ArrayLiteralExpression */); parseExpected(19 /* OpenBracketToken */); if (scanner.hasPrecedingLineBreak()) node.flags |= 2048 /* MultiLine */; @@ -10458,11 +10749,11 @@ var ts; return finishNode(node); } function tryParseAccessorDeclaration(fullStart, decorators, modifiers) { - if (parseContextualModifier(121 /* GetKeyword */)) { - return parseAccessorDeclaration(143 /* GetAccessor */, fullStart, decorators, modifiers); + if (parseContextualModifier(123 /* GetKeyword */)) { + return parseAccessorDeclaration(145 /* GetAccessor */, fullStart, decorators, modifiers); } - else if (parseContextualModifier(127 /* SetKeyword */)) { - return parseAccessorDeclaration(144 /* SetAccessor */, fullStart, decorators, modifiers); + else if (parseContextualModifier(129 /* SetKeyword */)) { + return parseAccessorDeclaration(146 /* SetAccessor */, fullStart, decorators, modifiers); } return undefined; } @@ -10479,28 +10770,38 @@ var ts; var nameToken = token; var propertyName = parsePropertyName(); // Disallowing of optional property assignments happens in the grammar checker. - var questionToken = parseOptionalToken(52 /* QuestionToken */); + var questionToken = parseOptionalToken(53 /* QuestionToken */); if (asteriskToken || token === 17 /* OpenParenToken */ || token === 25 /* LessThanToken */) { return parseMethodDeclaration(fullStart, decorators, modifiers, asteriskToken, propertyName, questionToken); } - // Parse to check if it is short-hand property assignment or normal property assignment - if ((token === 24 /* CommaToken */ || token === 16 /* CloseBraceToken */) && tokenIsIdentifier) { - var shorthandDeclaration = createNode(244 /* ShorthandPropertyAssignment */, fullStart); + // check if it is short-hand property assignment or normal property assignment + // NOTE: if token is EqualsToken it is interpreted as CoverInitializedName production + // CoverInitializedName[Yield] : + // IdentifierReference[?Yield] Initializer[In, ?Yield] + // this is necessary because ObjectLiteral productions are also used to cover grammar for ObjectAssignmentPattern + var isShorthandPropertyAssignment = tokenIsIdentifier && (token === 24 /* CommaToken */ || token === 16 /* CloseBraceToken */ || token === 56 /* EqualsToken */); + if (isShorthandPropertyAssignment) { + var shorthandDeclaration = createNode(246 /* ShorthandPropertyAssignment */, fullStart); shorthandDeclaration.name = propertyName; shorthandDeclaration.questionToken = questionToken; + var equalsToken = parseOptionalToken(56 /* EqualsToken */); + if (equalsToken) { + shorthandDeclaration.equalsToken = equalsToken; + shorthandDeclaration.objectAssignmentInitializer = allowInAnd(parseAssignmentExpressionOrHigher); + } return finishNode(shorthandDeclaration); } else { - var propertyAssignment = createNode(243 /* PropertyAssignment */, fullStart); + var propertyAssignment = createNode(245 /* PropertyAssignment */, fullStart); propertyAssignment.name = propertyName; propertyAssignment.questionToken = questionToken; - parseExpected(53 /* ColonToken */); + parseExpected(54 /* ColonToken */); propertyAssignment.initializer = allowInAnd(parseAssignmentExpressionOrHigher); return finishNode(propertyAssignment); } } function parseObjectLiteralExpression() { - var node = createNode(163 /* ObjectLiteralExpression */); + var node = createNode(165 /* ObjectLiteralExpression */); parseExpected(15 /* OpenBraceToken */); if (scanner.hasPrecedingLineBreak()) { node.flags |= 2048 /* MultiLine */; @@ -10519,9 +10820,9 @@ var ts; if (saveDecoratorContext) { setDecoratorContext(false); } - var node = createNode(171 /* FunctionExpression */); + var node = createNode(173 /* FunctionExpression */); setModifiers(node, parseModifiers()); - parseExpected(85 /* FunctionKeyword */); + parseExpected(87 /* FunctionKeyword */); node.asteriskToken = parseOptionalToken(37 /* AsteriskToken */); var isGenerator = !!node.asteriskToken; var isAsync = !!(node.flags & 512 /* Async */); @@ -10530,7 +10831,7 @@ var ts; isGenerator ? doInYieldContext(parseOptionalIdentifier) : isAsync ? doInAwaitContext(parseOptionalIdentifier) : parseOptionalIdentifier(); - fillSignature(53 /* ColonToken */, /*yieldContext*/ isGenerator, /*awaitContext*/ isAsync, /*requireCompleteParameterList*/ false, node); + fillSignature(54 /* ColonToken */, /*yieldContext*/ isGenerator, /*awaitContext*/ isAsync, /*requireCompleteParameterList*/ false, node); node.body = parseFunctionBlock(/*allowYield*/ isGenerator, /*allowAwait*/ isAsync, /*ignoreMissingOpenBrace*/ false); if (saveDecoratorContext) { setDecoratorContext(true); @@ -10541,8 +10842,8 @@ var ts; return isIdentifier() ? parseIdentifier() : undefined; } function parseNewExpression() { - var node = createNode(167 /* NewExpression */); - parseExpected(90 /* NewKeyword */); + var node = createNode(169 /* NewExpression */); + parseExpected(92 /* NewKeyword */); node.expression = parseMemberExpressionOrHigher(); node.typeArguments = tryParse(parseTypeArgumentsInExpression); if (node.typeArguments || token === 17 /* OpenParenToken */) { @@ -10552,7 +10853,7 @@ var ts; } // STATEMENTS function parseBlock(ignoreMissingOpenBrace, diagnosticMessage) { - var node = createNode(190 /* Block */); + var node = createNode(192 /* Block */); if (parseExpected(15 /* OpenBraceToken */, diagnosticMessage) || ignoreMissingOpenBrace) { node.statements = parseList(1 /* BlockStatements */, parseStatement); parseExpected(16 /* CloseBraceToken */); @@ -10582,25 +10883,25 @@ var ts; return block; } function parseEmptyStatement() { - var node = createNode(192 /* EmptyStatement */); + var node = createNode(194 /* EmptyStatement */); parseExpected(23 /* SemicolonToken */); return finishNode(node); } function parseIfStatement() { - var node = createNode(194 /* IfStatement */); - parseExpected(86 /* IfKeyword */); + var node = createNode(196 /* IfStatement */); + parseExpected(88 /* IfKeyword */); parseExpected(17 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); parseExpected(18 /* CloseParenToken */); node.thenStatement = parseStatement(); - node.elseStatement = parseOptional(78 /* ElseKeyword */) ? parseStatement() : undefined; + node.elseStatement = parseOptional(80 /* ElseKeyword */) ? parseStatement() : undefined; return finishNode(node); } function parseDoStatement() { - var node = createNode(195 /* DoStatement */); - parseExpected(77 /* DoKeyword */); + var node = createNode(197 /* DoStatement */); + parseExpected(79 /* DoKeyword */); node.statement = parseStatement(); - parseExpected(102 /* WhileKeyword */); + parseExpected(104 /* WhileKeyword */); parseExpected(17 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); parseExpected(18 /* CloseParenToken */); @@ -10612,8 +10913,8 @@ var ts; return finishNode(node); } function parseWhileStatement() { - var node = createNode(196 /* WhileStatement */); - parseExpected(102 /* WhileKeyword */); + var node = createNode(198 /* WhileStatement */); + parseExpected(104 /* WhileKeyword */); parseExpected(17 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); parseExpected(18 /* CloseParenToken */); @@ -10622,11 +10923,11 @@ var ts; } function parseForOrForInOrForOfStatement() { var pos = getNodePos(); - parseExpected(84 /* ForKeyword */); + parseExpected(86 /* ForKeyword */); parseExpected(17 /* OpenParenToken */); var initializer = undefined; if (token !== 23 /* SemicolonToken */) { - if (token === 100 /* VarKeyword */ || token === 106 /* LetKeyword */ || token === 72 /* ConstKeyword */) { + if (token === 102 /* VarKeyword */ || token === 108 /* LetKeyword */ || token === 74 /* ConstKeyword */) { initializer = parseVariableDeclarationList(/*inForStatementInitializer*/ true); } else { @@ -10634,22 +10935,22 @@ var ts; } } var forOrForInOrForOfStatement; - if (parseOptional(88 /* InKeyword */)) { - var forInStatement = createNode(198 /* ForInStatement */, pos); + if (parseOptional(90 /* InKeyword */)) { + var forInStatement = createNode(200 /* ForInStatement */, pos); forInStatement.initializer = initializer; forInStatement.expression = allowInAnd(parseExpression); parseExpected(18 /* CloseParenToken */); forOrForInOrForOfStatement = forInStatement; } - else if (parseOptional(132 /* OfKeyword */)) { - var forOfStatement = createNode(199 /* ForOfStatement */, pos); + else if (parseOptional(134 /* OfKeyword */)) { + var forOfStatement = createNode(201 /* ForOfStatement */, pos); forOfStatement.initializer = initializer; forOfStatement.expression = allowInAnd(parseAssignmentExpressionOrHigher); parseExpected(18 /* CloseParenToken */); forOrForInOrForOfStatement = forOfStatement; } else { - var forStatement = createNode(197 /* ForStatement */, pos); + var forStatement = createNode(199 /* ForStatement */, pos); forStatement.initializer = initializer; parseExpected(23 /* SemicolonToken */); if (token !== 23 /* SemicolonToken */ && token !== 18 /* CloseParenToken */) { @@ -10667,7 +10968,7 @@ var ts; } function parseBreakOrContinueStatement(kind) { var node = createNode(kind); - parseExpected(kind === 201 /* BreakStatement */ ? 68 /* BreakKeyword */ : 73 /* ContinueKeyword */); + parseExpected(kind === 203 /* BreakStatement */ ? 70 /* BreakKeyword */ : 75 /* ContinueKeyword */); if (!canParseSemicolon()) { node.label = parseIdentifier(); } @@ -10675,8 +10976,8 @@ var ts; return finishNode(node); } function parseReturnStatement() { - var node = createNode(202 /* ReturnStatement */); - parseExpected(92 /* ReturnKeyword */); + var node = createNode(204 /* ReturnStatement */); + parseExpected(94 /* ReturnKeyword */); if (!canParseSemicolon()) { node.expression = allowInAnd(parseExpression); } @@ -10684,8 +10985,8 @@ var ts; return finishNode(node); } function parseWithStatement() { - var node = createNode(203 /* WithStatement */); - parseExpected(103 /* WithKeyword */); + var node = createNode(205 /* WithStatement */); + parseExpected(105 /* WithKeyword */); parseExpected(17 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); parseExpected(18 /* CloseParenToken */); @@ -10693,30 +10994,30 @@ var ts; return finishNode(node); } function parseCaseClause() { - var node = createNode(239 /* CaseClause */); - parseExpected(69 /* CaseKeyword */); + var node = createNode(241 /* CaseClause */); + parseExpected(71 /* CaseKeyword */); node.expression = allowInAnd(parseExpression); - parseExpected(53 /* ColonToken */); + parseExpected(54 /* ColonToken */); node.statements = parseList(3 /* SwitchClauseStatements */, parseStatement); return finishNode(node); } function parseDefaultClause() { - var node = createNode(240 /* DefaultClause */); - parseExpected(75 /* DefaultKeyword */); - parseExpected(53 /* ColonToken */); + var node = createNode(242 /* DefaultClause */); + parseExpected(77 /* DefaultKeyword */); + parseExpected(54 /* ColonToken */); node.statements = parseList(3 /* SwitchClauseStatements */, parseStatement); return finishNode(node); } function parseCaseOrDefaultClause() { - return token === 69 /* CaseKeyword */ ? parseCaseClause() : parseDefaultClause(); + return token === 71 /* CaseKeyword */ ? parseCaseClause() : parseDefaultClause(); } function parseSwitchStatement() { - var node = createNode(204 /* SwitchStatement */); - parseExpected(94 /* SwitchKeyword */); + var node = createNode(206 /* SwitchStatement */); + parseExpected(96 /* SwitchKeyword */); parseExpected(17 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); parseExpected(18 /* CloseParenToken */); - var caseBlock = createNode(218 /* CaseBlock */, scanner.getStartPos()); + var caseBlock = createNode(220 /* CaseBlock */, scanner.getStartPos()); parseExpected(15 /* OpenBraceToken */); caseBlock.clauses = parseList(2 /* SwitchClauses */, parseCaseOrDefaultClause); parseExpected(16 /* CloseBraceToken */); @@ -10731,29 +11032,29 @@ var ts; // directly as that might consume an expression on the following line. // We just return 'undefined' in that case. The actual error will be reported in the // grammar walker. - var node = createNode(206 /* ThrowStatement */); - parseExpected(96 /* ThrowKeyword */); + var node = createNode(208 /* ThrowStatement */); + parseExpected(98 /* ThrowKeyword */); node.expression = scanner.hasPrecedingLineBreak() ? undefined : allowInAnd(parseExpression); parseSemicolon(); return finishNode(node); } // TODO: Review for error recovery function parseTryStatement() { - var node = createNode(207 /* TryStatement */); - parseExpected(98 /* TryKeyword */); + var node = createNode(209 /* TryStatement */); + parseExpected(100 /* TryKeyword */); node.tryBlock = parseBlock(/*ignoreMissingOpenBrace*/ false); - node.catchClause = token === 70 /* CatchKeyword */ ? parseCatchClause() : undefined; + node.catchClause = token === 72 /* CatchKeyword */ ? parseCatchClause() : undefined; // If we don't have a catch clause, then we must have a finally clause. Try to parse // one out no matter what. - if (!node.catchClause || token === 83 /* FinallyKeyword */) { - parseExpected(83 /* FinallyKeyword */); + if (!node.catchClause || token === 85 /* FinallyKeyword */) { + parseExpected(85 /* FinallyKeyword */); node.finallyBlock = parseBlock(/*ignoreMissingOpenBrace*/ false); } return finishNode(node); } function parseCatchClause() { - var result = createNode(242 /* CatchClause */); - parseExpected(70 /* CatchKeyword */); + var result = createNode(244 /* CatchClause */); + parseExpected(72 /* CatchKeyword */); if (parseExpected(17 /* OpenParenToken */)) { result.variableDeclaration = parseVariableDeclaration(); } @@ -10762,8 +11063,8 @@ var ts; return finishNode(result); } function parseDebuggerStatement() { - var node = createNode(208 /* DebuggerStatement */); - parseExpected(74 /* DebuggerKeyword */); + var node = createNode(210 /* DebuggerStatement */); + parseExpected(76 /* DebuggerKeyword */); parseSemicolon(); return finishNode(node); } @@ -10773,14 +11074,14 @@ var ts; // a colon. var fullStart = scanner.getStartPos(); var expression = allowInAnd(parseExpression); - if (expression.kind === 67 /* Identifier */ && parseOptional(53 /* ColonToken */)) { - var labeledStatement = createNode(205 /* LabeledStatement */, fullStart); + if (expression.kind === 69 /* Identifier */ && parseOptional(54 /* ColonToken */)) { + var labeledStatement = createNode(207 /* LabeledStatement */, fullStart); labeledStatement.label = expression; labeledStatement.statement = parseStatement(); return finishNode(labeledStatement); } else { - var expressionStatement = createNode(193 /* ExpressionStatement */, fullStart); + var expressionStatement = createNode(195 /* ExpressionStatement */, fullStart); expressionStatement.expression = expression; parseSemicolon(); return finishNode(expressionStatement); @@ -10792,7 +11093,7 @@ var ts; } function nextTokenIsFunctionKeywordOnSameLine() { nextToken(); - return token === 85 /* FunctionKeyword */ && !scanner.hasPrecedingLineBreak(); + return token === 87 /* FunctionKeyword */ && !scanner.hasPrecedingLineBreak(); } function nextTokenIsIdentifierOrKeywordOrNumberOnSameLine() { nextToken(); @@ -10801,12 +11102,12 @@ var ts; function isDeclaration() { while (true) { switch (token) { - case 100 /* VarKeyword */: - case 106 /* LetKeyword */: - case 72 /* ConstKeyword */: - case 85 /* FunctionKeyword */: - case 71 /* ClassKeyword */: - case 79 /* EnumKeyword */: + case 102 /* VarKeyword */: + case 108 /* LetKeyword */: + case 74 /* ConstKeyword */: + case 87 /* FunctionKeyword */: + case 73 /* ClassKeyword */: + case 81 /* EnumKeyword */: return true; // 'declare', 'module', 'namespace', 'interface'* and 'type' are all legal JavaScript identifiers; // however, an identifier cannot be followed by another identifier on the same line. This is what we @@ -10829,36 +11130,36 @@ var ts; // I {} // // could be legal, it would add complexity for very little gain. - case 105 /* InterfaceKeyword */: - case 130 /* TypeKeyword */: + case 107 /* InterfaceKeyword */: + case 132 /* TypeKeyword */: return nextTokenIsIdentifierOnSameLine(); - case 123 /* ModuleKeyword */: - case 124 /* NamespaceKeyword */: + case 125 /* ModuleKeyword */: + case 126 /* NamespaceKeyword */: return nextTokenIsIdentifierOrStringLiteralOnSameLine(); - case 116 /* AsyncKeyword */: - case 120 /* DeclareKeyword */: + case 115 /* AbstractKeyword */: + case 118 /* AsyncKeyword */: + case 122 /* DeclareKeyword */: + case 110 /* PrivateKeyword */: + case 111 /* ProtectedKeyword */: + case 112 /* PublicKeyword */: nextToken(); // ASI takes effect for this modifier. if (scanner.hasPrecedingLineBreak()) { return false; } continue; - case 87 /* ImportKeyword */: + case 89 /* ImportKeyword */: nextToken(); return token === 9 /* StringLiteral */ || token === 37 /* AsteriskToken */ || token === 15 /* OpenBraceToken */ || ts.tokenIsIdentifierOrKeyword(token); - case 80 /* ExportKeyword */: + case 82 /* ExportKeyword */: nextToken(); - if (token === 55 /* EqualsToken */ || token === 37 /* AsteriskToken */ || - token === 15 /* OpenBraceToken */ || token === 75 /* DefaultKeyword */) { + if (token === 56 /* EqualsToken */ || token === 37 /* AsteriskToken */ || + token === 15 /* OpenBraceToken */ || token === 77 /* DefaultKeyword */) { return true; } continue; - case 110 /* PublicKeyword */: - case 108 /* PrivateKeyword */: - case 109 /* ProtectedKeyword */: - case 111 /* StaticKeyword */: - case 113 /* AbstractKeyword */: + case 113 /* StaticKeyword */: nextToken(); continue; default: @@ -10871,47 +11172,47 @@ var ts; } function isStartOfStatement() { switch (token) { - case 54 /* AtToken */: + case 55 /* AtToken */: case 23 /* SemicolonToken */: case 15 /* OpenBraceToken */: - case 100 /* VarKeyword */: - case 106 /* LetKeyword */: - case 85 /* FunctionKeyword */: - case 71 /* ClassKeyword */: - case 79 /* EnumKeyword */: - case 86 /* IfKeyword */: - case 77 /* DoKeyword */: - case 102 /* WhileKeyword */: - case 84 /* ForKeyword */: - case 73 /* ContinueKeyword */: - case 68 /* BreakKeyword */: - case 92 /* ReturnKeyword */: - case 103 /* WithKeyword */: - case 94 /* SwitchKeyword */: - case 96 /* ThrowKeyword */: - case 98 /* TryKeyword */: - case 74 /* DebuggerKeyword */: + case 102 /* VarKeyword */: + case 108 /* LetKeyword */: + case 87 /* FunctionKeyword */: + case 73 /* ClassKeyword */: + case 81 /* EnumKeyword */: + case 88 /* IfKeyword */: + case 79 /* DoKeyword */: + case 104 /* WhileKeyword */: + case 86 /* ForKeyword */: + case 75 /* ContinueKeyword */: + case 70 /* BreakKeyword */: + case 94 /* ReturnKeyword */: + case 105 /* WithKeyword */: + case 96 /* SwitchKeyword */: + case 98 /* ThrowKeyword */: + case 100 /* TryKeyword */: + case 76 /* DebuggerKeyword */: // 'catch' and 'finally' do not actually indicate that the code is part of a statement, // however, we say they are here so that we may gracefully parse them and error later. - case 70 /* CatchKeyword */: - case 83 /* FinallyKeyword */: + case 72 /* CatchKeyword */: + case 85 /* FinallyKeyword */: return true; - case 72 /* ConstKeyword */: - case 80 /* ExportKeyword */: - case 87 /* ImportKeyword */: + case 74 /* ConstKeyword */: + case 82 /* ExportKeyword */: + case 89 /* ImportKeyword */: return isStartOfDeclaration(); - case 116 /* AsyncKeyword */: - case 120 /* DeclareKeyword */: - case 105 /* InterfaceKeyword */: - case 123 /* ModuleKeyword */: - case 124 /* NamespaceKeyword */: - case 130 /* TypeKeyword */: + case 118 /* AsyncKeyword */: + case 122 /* DeclareKeyword */: + case 107 /* InterfaceKeyword */: + case 125 /* ModuleKeyword */: + case 126 /* NamespaceKeyword */: + case 132 /* TypeKeyword */: // When these don't start a declaration, they're an identifier in an expression statement return true; - case 110 /* PublicKeyword */: - case 108 /* PrivateKeyword */: - case 109 /* ProtectedKeyword */: - case 111 /* StaticKeyword */: + case 112 /* PublicKeyword */: + case 110 /* PrivateKeyword */: + case 111 /* ProtectedKeyword */: + case 113 /* StaticKeyword */: // When these don't start a declaration, they may be the start of a class member if an identifier // immediately follows. Otherwise they're an identifier in an expression statement. return isStartOfDeclaration() || !lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine); @@ -10934,61 +11235,61 @@ var ts; return parseEmptyStatement(); case 15 /* OpenBraceToken */: return parseBlock(/*ignoreMissingOpenBrace*/ false); - case 100 /* VarKeyword */: + case 102 /* VarKeyword */: return parseVariableStatement(scanner.getStartPos(), /*decorators*/ undefined, /*modifiers*/ undefined); - case 106 /* LetKeyword */: + case 108 /* LetKeyword */: if (isLetDeclaration()) { return parseVariableStatement(scanner.getStartPos(), /*decorators*/ undefined, /*modifiers*/ undefined); } break; - case 85 /* FunctionKeyword */: + case 87 /* FunctionKeyword */: return parseFunctionDeclaration(scanner.getStartPos(), /*decorators*/ undefined, /*modifiers*/ undefined); - case 71 /* ClassKeyword */: + case 73 /* ClassKeyword */: return parseClassDeclaration(scanner.getStartPos(), /*decorators*/ undefined, /*modifiers*/ undefined); - case 86 /* IfKeyword */: + case 88 /* IfKeyword */: return parseIfStatement(); - case 77 /* DoKeyword */: + case 79 /* DoKeyword */: return parseDoStatement(); - case 102 /* WhileKeyword */: + case 104 /* WhileKeyword */: return parseWhileStatement(); - case 84 /* ForKeyword */: + case 86 /* ForKeyword */: return parseForOrForInOrForOfStatement(); - case 73 /* ContinueKeyword */: - return parseBreakOrContinueStatement(200 /* ContinueStatement */); - case 68 /* BreakKeyword */: - return parseBreakOrContinueStatement(201 /* BreakStatement */); - case 92 /* ReturnKeyword */: + case 75 /* ContinueKeyword */: + return parseBreakOrContinueStatement(202 /* ContinueStatement */); + case 70 /* BreakKeyword */: + return parseBreakOrContinueStatement(203 /* BreakStatement */); + case 94 /* ReturnKeyword */: return parseReturnStatement(); - case 103 /* WithKeyword */: + case 105 /* WithKeyword */: return parseWithStatement(); - case 94 /* SwitchKeyword */: + case 96 /* SwitchKeyword */: return parseSwitchStatement(); - case 96 /* ThrowKeyword */: + case 98 /* ThrowKeyword */: return parseThrowStatement(); - case 98 /* TryKeyword */: + case 100 /* TryKeyword */: // Include 'catch' and 'finally' for error recovery. - case 70 /* CatchKeyword */: - case 83 /* FinallyKeyword */: + case 72 /* CatchKeyword */: + case 85 /* FinallyKeyword */: return parseTryStatement(); - case 74 /* DebuggerKeyword */: + case 76 /* DebuggerKeyword */: return parseDebuggerStatement(); - case 54 /* AtToken */: + case 55 /* AtToken */: return parseDeclaration(); - case 116 /* AsyncKeyword */: - case 105 /* InterfaceKeyword */: - case 130 /* TypeKeyword */: - case 123 /* ModuleKeyword */: - case 124 /* NamespaceKeyword */: - case 120 /* DeclareKeyword */: - case 72 /* ConstKeyword */: - case 79 /* EnumKeyword */: - case 80 /* ExportKeyword */: - case 87 /* ImportKeyword */: - case 108 /* PrivateKeyword */: - case 109 /* ProtectedKeyword */: - case 110 /* PublicKeyword */: - case 113 /* AbstractKeyword */: - case 111 /* StaticKeyword */: + case 118 /* AsyncKeyword */: + case 107 /* InterfaceKeyword */: + case 132 /* TypeKeyword */: + case 125 /* ModuleKeyword */: + case 126 /* NamespaceKeyword */: + case 122 /* DeclareKeyword */: + case 74 /* ConstKeyword */: + case 81 /* EnumKeyword */: + case 82 /* ExportKeyword */: + case 89 /* ImportKeyword */: + case 110 /* PrivateKeyword */: + case 111 /* ProtectedKeyword */: + case 112 /* PublicKeyword */: + case 115 /* AbstractKeyword */: + case 113 /* StaticKeyword */: if (isStartOfDeclaration()) { return parseDeclaration(); } @@ -11001,35 +11302,35 @@ var ts; var decorators = parseDecorators(); var modifiers = parseModifiers(); switch (token) { - case 100 /* VarKeyword */: - case 106 /* LetKeyword */: - case 72 /* ConstKeyword */: + case 102 /* VarKeyword */: + case 108 /* LetKeyword */: + case 74 /* ConstKeyword */: return parseVariableStatement(fullStart, decorators, modifiers); - case 85 /* FunctionKeyword */: + case 87 /* FunctionKeyword */: return parseFunctionDeclaration(fullStart, decorators, modifiers); - case 71 /* ClassKeyword */: + case 73 /* ClassKeyword */: return parseClassDeclaration(fullStart, decorators, modifiers); - case 105 /* InterfaceKeyword */: + case 107 /* InterfaceKeyword */: return parseInterfaceDeclaration(fullStart, decorators, modifiers); - case 130 /* TypeKeyword */: + case 132 /* TypeKeyword */: return parseTypeAliasDeclaration(fullStart, decorators, modifiers); - case 79 /* EnumKeyword */: + case 81 /* EnumKeyword */: return parseEnumDeclaration(fullStart, decorators, modifiers); - case 123 /* ModuleKeyword */: - case 124 /* NamespaceKeyword */: + case 125 /* ModuleKeyword */: + case 126 /* NamespaceKeyword */: return parseModuleDeclaration(fullStart, decorators, modifiers); - case 87 /* ImportKeyword */: + case 89 /* ImportKeyword */: return parseImportDeclarationOrImportEqualsDeclaration(fullStart, decorators, modifiers); - case 80 /* ExportKeyword */: + case 82 /* ExportKeyword */: nextToken(); - return token === 75 /* DefaultKeyword */ || token === 55 /* EqualsToken */ ? + return token === 77 /* DefaultKeyword */ || token === 56 /* EqualsToken */ ? parseExportAssignment(fullStart, decorators, modifiers) : parseExportDeclaration(fullStart, decorators, modifiers); default: if (decorators || modifiers) { // We reached this point because we encountered decorators and/or modifiers and assumed a declaration // would follow. For recovery and error reporting purposes, return an incomplete declaration. - var node = createMissingNode(229 /* MissingDeclaration */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); + var node = createMissingNode(231 /* MissingDeclaration */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); node.pos = fullStart; node.decorators = decorators; setModifiers(node, modifiers); @@ -11051,24 +11352,24 @@ var ts; // DECLARATIONS function parseArrayBindingElement() { if (token === 24 /* CommaToken */) { - return createNode(185 /* OmittedExpression */); + return createNode(187 /* OmittedExpression */); } - var node = createNode(161 /* BindingElement */); + var node = createNode(163 /* BindingElement */); node.dotDotDotToken = parseOptionalToken(22 /* DotDotDotToken */); node.name = parseIdentifierOrPattern(); node.initializer = parseBindingElementInitializer(/*inParameter*/ false); return finishNode(node); } function parseObjectBindingElement() { - var node = createNode(161 /* BindingElement */); + var node = createNode(163 /* BindingElement */); // TODO(andersh): Handle computed properties var tokenIsIdentifier = isIdentifier(); var propertyName = parsePropertyName(); - if (tokenIsIdentifier && token !== 53 /* ColonToken */) { + if (tokenIsIdentifier && token !== 54 /* ColonToken */) { node.name = propertyName; } else { - parseExpected(53 /* ColonToken */); + parseExpected(54 /* ColonToken */); node.propertyName = propertyName; node.name = parseIdentifierOrPattern(); } @@ -11076,14 +11377,14 @@ var ts; return finishNode(node); } function parseObjectBindingPattern() { - var node = createNode(159 /* ObjectBindingPattern */); + var node = createNode(161 /* ObjectBindingPattern */); parseExpected(15 /* OpenBraceToken */); node.elements = parseDelimitedList(9 /* ObjectBindingElements */, parseObjectBindingElement); parseExpected(16 /* CloseBraceToken */); return finishNode(node); } function parseArrayBindingPattern() { - var node = createNode(160 /* ArrayBindingPattern */); + var node = createNode(162 /* ArrayBindingPattern */); parseExpected(19 /* OpenBracketToken */); node.elements = parseDelimitedList(10 /* ArrayBindingElements */, parseArrayBindingElement); parseExpected(20 /* CloseBracketToken */); @@ -11102,7 +11403,7 @@ var ts; return parseIdentifier(); } function parseVariableDeclaration() { - var node = createNode(209 /* VariableDeclaration */); + var node = createNode(211 /* VariableDeclaration */); node.name = parseIdentifierOrPattern(); node.type = parseTypeAnnotation(); if (!isInOrOfKeyword(token)) { @@ -11111,14 +11412,14 @@ var ts; return finishNode(node); } function parseVariableDeclarationList(inForStatementInitializer) { - var node = createNode(210 /* VariableDeclarationList */); + var node = createNode(212 /* VariableDeclarationList */); switch (token) { - case 100 /* VarKeyword */: + case 102 /* VarKeyword */: break; - case 106 /* LetKeyword */: + case 108 /* LetKeyword */: node.flags |= 16384 /* Let */; break; - case 72 /* ConstKeyword */: + case 74 /* ConstKeyword */: node.flags |= 32768 /* Const */; break; default: @@ -11134,7 +11435,7 @@ var ts; // So we need to look ahead to determine if 'of' should be treated as a keyword in // this context. // The checker will then give an error that there is an empty declaration list. - if (token === 132 /* OfKeyword */ && lookAhead(canFollowContextualOfKeyword)) { + if (token === 134 /* OfKeyword */ && lookAhead(canFollowContextualOfKeyword)) { node.declarations = createMissingList(); } else { @@ -11149,7 +11450,7 @@ var ts; return nextTokenIsIdentifier() && nextToken() === 18 /* CloseParenToken */; } function parseVariableStatement(fullStart, decorators, modifiers) { - var node = createNode(191 /* VariableStatement */, fullStart); + var node = createNode(193 /* VariableStatement */, fullStart); node.decorators = decorators; setModifiers(node, modifiers); node.declarationList = parseVariableDeclarationList(/*inForStatementInitializer*/ false); @@ -11157,29 +11458,29 @@ var ts; return finishNode(node); } function parseFunctionDeclaration(fullStart, decorators, modifiers) { - var node = createNode(211 /* FunctionDeclaration */, fullStart); + var node = createNode(213 /* FunctionDeclaration */, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - parseExpected(85 /* FunctionKeyword */); + parseExpected(87 /* FunctionKeyword */); node.asteriskToken = parseOptionalToken(37 /* AsteriskToken */); node.name = node.flags & 1024 /* Default */ ? parseOptionalIdentifier() : parseIdentifier(); var isGenerator = !!node.asteriskToken; var isAsync = !!(node.flags & 512 /* Async */); - fillSignature(53 /* ColonToken */, /*yieldContext*/ isGenerator, /*awaitContext*/ isAsync, /*requireCompleteParameterList*/ false, node); + fillSignature(54 /* ColonToken */, /*yieldContext*/ isGenerator, /*awaitContext*/ isAsync, /*requireCompleteParameterList*/ false, node); node.body = parseFunctionBlockOrSemicolon(isGenerator, isAsync, ts.Diagnostics.or_expected); return finishNode(node); } function parseConstructorDeclaration(pos, decorators, modifiers) { - var node = createNode(142 /* Constructor */, pos); + var node = createNode(144 /* Constructor */, pos); node.decorators = decorators; setModifiers(node, modifiers); - parseExpected(119 /* ConstructorKeyword */); - fillSignature(53 /* ColonToken */, /*yieldContext*/ false, /*awaitContext*/ false, /*requireCompleteParameterList*/ false, node); + parseExpected(121 /* ConstructorKeyword */); + fillSignature(54 /* ColonToken */, /*yieldContext*/ false, /*awaitContext*/ false, /*requireCompleteParameterList*/ false, node); node.body = parseFunctionBlockOrSemicolon(/*isGenerator*/ false, /*isAsync*/ false, ts.Diagnostics.or_expected); return finishNode(node); } function parseMethodDeclaration(fullStart, decorators, modifiers, asteriskToken, name, questionToken, diagnosticMessage) { - var method = createNode(141 /* MethodDeclaration */, fullStart); + var method = createNode(143 /* MethodDeclaration */, fullStart); method.decorators = decorators; setModifiers(method, modifiers); method.asteriskToken = asteriskToken; @@ -11187,12 +11488,12 @@ var ts; method.questionToken = questionToken; var isGenerator = !!asteriskToken; var isAsync = !!(method.flags & 512 /* Async */); - fillSignature(53 /* ColonToken */, /*yieldContext*/ isGenerator, /*awaitContext*/ isAsync, /*requireCompleteParameterList*/ false, method); + fillSignature(54 /* ColonToken */, /*yieldContext*/ isGenerator, /*awaitContext*/ isAsync, /*requireCompleteParameterList*/ false, method); method.body = parseFunctionBlockOrSemicolon(isGenerator, isAsync, diagnosticMessage); return finishNode(method); } function parsePropertyDeclaration(fullStart, decorators, modifiers, name, questionToken) { - var property = createNode(139 /* PropertyDeclaration */, fullStart); + var property = createNode(141 /* PropertyDeclaration */, fullStart); property.decorators = decorators; setModifiers(property, modifiers); property.name = name; @@ -11218,7 +11519,7 @@ var ts; var name = parsePropertyName(); // Note: this is not legal as per the grammar. But we allow it in the parser and // report an error in the grammar checker. - var questionToken = parseOptionalToken(52 /* QuestionToken */); + var questionToken = parseOptionalToken(53 /* QuestionToken */); if (asteriskToken || token === 17 /* OpenParenToken */ || token === 25 /* LessThanToken */) { return parseMethodDeclaration(fullStart, decorators, modifiers, asteriskToken, name, questionToken, ts.Diagnostics.or_expected); } @@ -11234,16 +11535,16 @@ var ts; node.decorators = decorators; setModifiers(node, modifiers); node.name = parsePropertyName(); - fillSignature(53 /* ColonToken */, /*yieldContext*/ false, /*awaitContext*/ false, /*requireCompleteParameterList*/ false, node); + fillSignature(54 /* ColonToken */, /*yieldContext*/ false, /*awaitContext*/ false, /*requireCompleteParameterList*/ false, node); node.body = parseFunctionBlockOrSemicolon(/*isGenerator*/ false, /*isAsync*/ false); return finishNode(node); } function isClassMemberModifier(idToken) { switch (idToken) { - case 110 /* PublicKeyword */: - case 108 /* PrivateKeyword */: - case 109 /* ProtectedKeyword */: - case 111 /* StaticKeyword */: + case 112 /* PublicKeyword */: + case 110 /* PrivateKeyword */: + case 111 /* ProtectedKeyword */: + case 113 /* StaticKeyword */: return true; default: return false; @@ -11251,7 +11552,7 @@ var ts; } function isClassMemberStart() { var idToken; - if (token === 54 /* AtToken */) { + if (token === 55 /* AtToken */) { return true; } // Eat up all modifiers, but hold on to the last one in case it is actually an identifier. @@ -11284,7 +11585,7 @@ var ts; // If we were able to get any potential identifier... if (idToken !== undefined) { // If we have a non-keyword identifier, or if we have an accessor, then it's safe to parse. - if (!ts.isKeyword(idToken) || idToken === 127 /* SetKeyword */ || idToken === 121 /* GetKeyword */) { + if (!ts.isKeyword(idToken) || idToken === 129 /* SetKeyword */ || idToken === 123 /* GetKeyword */) { return true; } // If it *is* a keyword, but not an accessor, check a little farther along @@ -11292,9 +11593,9 @@ var ts; switch (token) { case 17 /* OpenParenToken */: // Method declaration case 25 /* LessThanToken */: // Generic Method declaration - case 53 /* ColonToken */: // Type Annotation for declaration - case 55 /* EqualsToken */: // Initializer for declaration - case 52 /* QuestionToken */: + case 54 /* ColonToken */: // Type Annotation for declaration + case 56 /* EqualsToken */: // Initializer for declaration + case 53 /* QuestionToken */: return true; default: // Covers @@ -11311,14 +11612,14 @@ var ts; var decorators; while (true) { var decoratorStart = getNodePos(); - if (!parseOptional(54 /* AtToken */)) { + if (!parseOptional(55 /* AtToken */)) { break; } if (!decorators) { decorators = []; decorators.pos = scanner.getStartPos(); } - var decorator = createNode(137 /* Decorator */, decoratorStart); + var decorator = createNode(139 /* Decorator */, decoratorStart); decorator.expression = doInDecoratorContext(parseLeftHandSideExpressionOrHigher); decorators.push(finishNode(decorator)); } @@ -11352,7 +11653,7 @@ var ts; function parseModifiersForArrowFunction() { var flags = 0; var modifiers; - if (token === 116 /* AsyncKeyword */) { + if (token === 118 /* AsyncKeyword */) { var modifierStart = scanner.getStartPos(); var modifierKind = token; nextToken(); @@ -11367,7 +11668,7 @@ var ts; } function parseClassElement() { if (token === 23 /* SemicolonToken */) { - var result = createNode(189 /* SemicolonClassElement */); + var result = createNode(191 /* SemicolonClassElement */); nextToken(); return finishNode(result); } @@ -11378,7 +11679,7 @@ var ts; if (accessor) { return accessor; } - if (token === 119 /* ConstructorKeyword */) { + if (token === 121 /* ConstructorKeyword */) { return parseConstructorDeclaration(fullStart, decorators, modifiers); } if (isIndexSignature()) { @@ -11395,7 +11696,7 @@ var ts; } if (decorators || modifiers) { // treat this as a property declaration with a missing name. - var name_7 = createMissingNode(67 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); + var name_7 = createMissingNode(69 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); return parsePropertyDeclaration(fullStart, decorators, modifiers, name_7, /*questionToken*/ undefined); } // 'isClassMemberStart' should have hinted not to attempt parsing. @@ -11405,17 +11706,17 @@ var ts; return parseClassDeclarationOrExpression( /*fullStart*/ scanner.getStartPos(), /*decorators*/ undefined, - /*modifiers*/ undefined, 184 /* ClassExpression */); + /*modifiers*/ undefined, 186 /* ClassExpression */); } function parseClassDeclaration(fullStart, decorators, modifiers) { - return parseClassDeclarationOrExpression(fullStart, decorators, modifiers, 212 /* ClassDeclaration */); + return parseClassDeclarationOrExpression(fullStart, decorators, modifiers, 214 /* ClassDeclaration */); } function parseClassDeclarationOrExpression(fullStart, decorators, modifiers, kind) { var node = createNode(kind, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - parseExpected(71 /* ClassKeyword */); - node.name = parseOptionalIdentifier(); + parseExpected(73 /* ClassKeyword */); + node.name = parseNameOfClassDeclarationOrExpression(); node.typeParameters = parseTypeParameters(); node.heritageClauses = parseHeritageClauses(/*isClassHeritageClause*/ true); if (parseExpected(15 /* OpenBraceToken */)) { @@ -11429,6 +11730,19 @@ var ts; } return finishNode(node); } + function parseNameOfClassDeclarationOrExpression() { + // implements is a future reserved word so + // 'class implements' might mean either + // - class expression with omitted name, 'implements' starts heritage clause + // - class with name 'implements' + // 'isImplementsClause' helps to disambiguate between these two cases + return isIdentifier() && !isImplementsClause() + ? parseIdentifier() + : undefined; + } + function isImplementsClause() { + return token === 106 /* ImplementsKeyword */ && lookAhead(nextTokenIsIdentifierOrKeyword); + } function parseHeritageClauses(isClassHeritageClause) { // ClassTail[Yield,Await] : (Modified) See 14.5 // ClassHeritage[?Yield,?Await]opt { ClassBody[?Yield,?Await]opt } @@ -11441,8 +11755,8 @@ var ts; return parseList(20 /* HeritageClauses */, parseHeritageClause); } function parseHeritageClause() { - if (token === 81 /* ExtendsKeyword */ || token === 104 /* ImplementsKeyword */) { - var node = createNode(241 /* HeritageClause */); + if (token === 83 /* ExtendsKeyword */ || token === 106 /* ImplementsKeyword */) { + var node = createNode(243 /* HeritageClause */); node.token = token; nextToken(); node.types = parseDelimitedList(7 /* HeritageClauseElement */, parseExpressionWithTypeArguments); @@ -11451,7 +11765,7 @@ var ts; return undefined; } function parseExpressionWithTypeArguments() { - var node = createNode(186 /* ExpressionWithTypeArguments */); + var node = createNode(188 /* ExpressionWithTypeArguments */); node.expression = parseLeftHandSideExpressionOrHigher(); if (token === 25 /* LessThanToken */) { node.typeArguments = parseBracketedList(18 /* TypeArguments */, parseType, 25 /* LessThanToken */, 27 /* GreaterThanToken */); @@ -11459,16 +11773,16 @@ var ts; return finishNode(node); } function isHeritageClause() { - return token === 81 /* ExtendsKeyword */ || token === 104 /* ImplementsKeyword */; + return token === 83 /* ExtendsKeyword */ || token === 106 /* ImplementsKeyword */; } function parseClassMembers() { return parseList(5 /* ClassMembers */, parseClassElement); } function parseInterfaceDeclaration(fullStart, decorators, modifiers) { - var node = createNode(213 /* InterfaceDeclaration */, fullStart); + var node = createNode(215 /* InterfaceDeclaration */, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - parseExpected(105 /* InterfaceKeyword */); + parseExpected(107 /* InterfaceKeyword */); node.name = parseIdentifier(); node.typeParameters = parseTypeParameters(); node.heritageClauses = parseHeritageClauses(/*isClassHeritageClause*/ false); @@ -11476,13 +11790,13 @@ var ts; return finishNode(node); } function parseTypeAliasDeclaration(fullStart, decorators, modifiers) { - var node = createNode(214 /* TypeAliasDeclaration */, fullStart); + var node = createNode(216 /* TypeAliasDeclaration */, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - parseExpected(130 /* TypeKeyword */); + parseExpected(132 /* TypeKeyword */); node.name = parseIdentifier(); node.typeParameters = parseTypeParameters(); - parseExpected(55 /* EqualsToken */); + parseExpected(56 /* EqualsToken */); node.type = parseType(); parseSemicolon(); return finishNode(node); @@ -11492,16 +11806,16 @@ var ts; // ConstantEnumMemberSection, which starts at the beginning of an enum declaration // or any time an integer literal initializer is encountered. function parseEnumMember() { - var node = createNode(245 /* EnumMember */, scanner.getStartPos()); + var node = createNode(247 /* EnumMember */, scanner.getStartPos()); node.name = parsePropertyName(); node.initializer = allowInAnd(parseNonParameterInitializer); return finishNode(node); } function parseEnumDeclaration(fullStart, decorators, modifiers) { - var node = createNode(215 /* EnumDeclaration */, fullStart); + var node = createNode(217 /* EnumDeclaration */, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - parseExpected(79 /* EnumKeyword */); + parseExpected(81 /* EnumKeyword */); node.name = parseIdentifier(); if (parseExpected(15 /* OpenBraceToken */)) { node.members = parseDelimitedList(6 /* EnumMembers */, parseEnumMember); @@ -11513,7 +11827,7 @@ var ts; return finishNode(node); } function parseModuleBlock() { - var node = createNode(217 /* ModuleBlock */, scanner.getStartPos()); + var node = createNode(219 /* ModuleBlock */, scanner.getStartPos()); if (parseExpected(15 /* OpenBraceToken */)) { node.statements = parseList(1 /* BlockStatements */, parseStatement); parseExpected(16 /* CloseBraceToken */); @@ -11524,7 +11838,7 @@ var ts; return finishNode(node); } function parseModuleOrNamespaceDeclaration(fullStart, decorators, modifiers, flags) { - var node = createNode(216 /* ModuleDeclaration */, fullStart); + var node = createNode(218 /* ModuleDeclaration */, fullStart); // If we are parsing a dotted namespace name, we want to // propagate the 'Namespace' flag across the names if set. var namespaceFlag = flags & 131072 /* Namespace */; @@ -11538,7 +11852,7 @@ var ts; return finishNode(node); } function parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers) { - var node = createNode(216 /* ModuleDeclaration */, fullStart); + var node = createNode(218 /* ModuleDeclaration */, fullStart); node.decorators = decorators; setModifiers(node, modifiers); node.name = parseLiteralNode(/*internName*/ true); @@ -11547,11 +11861,11 @@ var ts; } function parseModuleDeclaration(fullStart, decorators, modifiers) { var flags = modifiers ? modifiers.flags : 0; - if (parseOptional(124 /* NamespaceKeyword */)) { + if (parseOptional(126 /* NamespaceKeyword */)) { flags |= 131072 /* Namespace */; } else { - parseExpected(123 /* ModuleKeyword */); + parseExpected(125 /* ModuleKeyword */); if (token === 9 /* StringLiteral */) { return parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers); } @@ -11559,42 +11873,42 @@ var ts; return parseModuleOrNamespaceDeclaration(fullStart, decorators, modifiers, flags); } function isExternalModuleReference() { - return token === 125 /* RequireKeyword */ && + return token === 127 /* RequireKeyword */ && lookAhead(nextTokenIsOpenParen); } function nextTokenIsOpenParen() { return nextToken() === 17 /* OpenParenToken */; } function nextTokenIsSlash() { - return nextToken() === 38 /* SlashToken */; + return nextToken() === 39 /* SlashToken */; } function nextTokenIsCommaOrFromKeyword() { nextToken(); return token === 24 /* CommaToken */ || - token === 131 /* FromKeyword */; + token === 133 /* FromKeyword */; } function parseImportDeclarationOrImportEqualsDeclaration(fullStart, decorators, modifiers) { - parseExpected(87 /* ImportKeyword */); + parseExpected(89 /* ImportKeyword */); var afterImportPos = scanner.getStartPos(); var identifier; if (isIdentifier()) { identifier = parseIdentifier(); - if (token !== 24 /* CommaToken */ && token !== 131 /* FromKeyword */) { + if (token !== 24 /* CommaToken */ && token !== 133 /* FromKeyword */) { // ImportEquals declaration of type: // import x = require("mod"); or // import x = M.x; - var importEqualsDeclaration = createNode(219 /* ImportEqualsDeclaration */, fullStart); + var importEqualsDeclaration = createNode(221 /* ImportEqualsDeclaration */, fullStart); importEqualsDeclaration.decorators = decorators; setModifiers(importEqualsDeclaration, modifiers); importEqualsDeclaration.name = identifier; - parseExpected(55 /* EqualsToken */); + parseExpected(56 /* EqualsToken */); importEqualsDeclaration.moduleReference = parseModuleReference(); parseSemicolon(); return finishNode(importEqualsDeclaration); } } // Import statement - var importDeclaration = createNode(220 /* ImportDeclaration */, fullStart); + var importDeclaration = createNode(222 /* ImportDeclaration */, fullStart); importDeclaration.decorators = decorators; setModifiers(importDeclaration, modifiers); // ImportDeclaration: @@ -11604,7 +11918,7 @@ var ts; token === 37 /* AsteriskToken */ || token === 15 /* OpenBraceToken */) { importDeclaration.importClause = parseImportClause(identifier, afterImportPos); - parseExpected(131 /* FromKeyword */); + parseExpected(133 /* FromKeyword */); } importDeclaration.moduleSpecifier = parseModuleSpecifier(); parseSemicolon(); @@ -11617,7 +11931,7 @@ var ts; // NamedImports // ImportedDefaultBinding, NameSpaceImport // ImportedDefaultBinding, NamedImports - var importClause = createNode(221 /* ImportClause */, fullStart); + var importClause = createNode(223 /* ImportClause */, fullStart); if (identifier) { // ImportedDefaultBinding: // ImportedBinding @@ -11627,7 +11941,7 @@ var ts; // parse namespace or named imports if (!importClause.name || parseOptional(24 /* CommaToken */)) { - importClause.namedBindings = token === 37 /* AsteriskToken */ ? parseNamespaceImport() : parseNamedImportsOrExports(223 /* NamedImports */); + importClause.namedBindings = token === 37 /* AsteriskToken */ ? parseNamespaceImport() : parseNamedImportsOrExports(225 /* NamedImports */); } return finishNode(importClause); } @@ -11637,8 +11951,8 @@ var ts; : parseEntityName(/*allowReservedWords*/ false); } function parseExternalModuleReference() { - var node = createNode(230 /* ExternalModuleReference */); - parseExpected(125 /* RequireKeyword */); + var node = createNode(232 /* ExternalModuleReference */); + parseExpected(127 /* RequireKeyword */); parseExpected(17 /* OpenParenToken */); node.expression = parseModuleSpecifier(); parseExpected(18 /* CloseParenToken */); @@ -11659,9 +11973,9 @@ var ts; function parseNamespaceImport() { // NameSpaceImport: // * as ImportedBinding - var namespaceImport = createNode(222 /* NamespaceImport */); + var namespaceImport = createNode(224 /* NamespaceImport */); parseExpected(37 /* AsteriskToken */); - parseExpected(114 /* AsKeyword */); + parseExpected(116 /* AsKeyword */); namespaceImport.name = parseIdentifier(); return finishNode(namespaceImport); } @@ -11674,14 +11988,14 @@ var ts; // ImportsList: // ImportSpecifier // ImportsList, ImportSpecifier - node.elements = parseBracketedList(21 /* ImportOrExportSpecifiers */, kind === 223 /* NamedImports */ ? parseImportSpecifier : parseExportSpecifier, 15 /* OpenBraceToken */, 16 /* CloseBraceToken */); + node.elements = parseBracketedList(21 /* ImportOrExportSpecifiers */, kind === 225 /* NamedImports */ ? parseImportSpecifier : parseExportSpecifier, 15 /* OpenBraceToken */, 16 /* CloseBraceToken */); return finishNode(node); } function parseExportSpecifier() { - return parseImportOrExportSpecifier(228 /* ExportSpecifier */); + return parseImportOrExportSpecifier(230 /* ExportSpecifier */); } function parseImportSpecifier() { - return parseImportOrExportSpecifier(224 /* ImportSpecifier */); + return parseImportOrExportSpecifier(226 /* ImportSpecifier */); } function parseImportOrExportSpecifier(kind) { var node = createNode(kind); @@ -11695,9 +12009,9 @@ var ts; var checkIdentifierStart = scanner.getTokenPos(); var checkIdentifierEnd = scanner.getTextPos(); var identifierName = parseIdentifierName(); - if (token === 114 /* AsKeyword */) { + if (token === 116 /* AsKeyword */) { node.propertyName = identifierName; - parseExpected(114 /* AsKeyword */); + parseExpected(116 /* AsKeyword */); checkIdentifierIsKeyword = ts.isKeyword(token) && !isIdentifier(); checkIdentifierStart = scanner.getTokenPos(); checkIdentifierEnd = scanner.getTextPos(); @@ -11706,27 +12020,27 @@ var ts; else { node.name = identifierName; } - if (kind === 224 /* ImportSpecifier */ && checkIdentifierIsKeyword) { + if (kind === 226 /* ImportSpecifier */ && checkIdentifierIsKeyword) { // Report error identifier expected parseErrorAtPosition(checkIdentifierStart, checkIdentifierEnd - checkIdentifierStart, ts.Diagnostics.Identifier_expected); } return finishNode(node); } function parseExportDeclaration(fullStart, decorators, modifiers) { - var node = createNode(226 /* ExportDeclaration */, fullStart); + var node = createNode(228 /* ExportDeclaration */, fullStart); node.decorators = decorators; setModifiers(node, modifiers); if (parseOptional(37 /* AsteriskToken */)) { - parseExpected(131 /* FromKeyword */); + parseExpected(133 /* FromKeyword */); node.moduleSpecifier = parseModuleSpecifier(); } else { - node.exportClause = parseNamedImportsOrExports(227 /* NamedExports */); + node.exportClause = parseNamedImportsOrExports(229 /* NamedExports */); // It is not uncommon to accidentally omit the 'from' keyword. Additionally, in editing scenarios, // the 'from' keyword can be parsed as a named export when the export clause is unterminated (i.e. `export { from "moduleName";`) // If we don't have a 'from' keyword, see if we have a string literal such that ASI won't take effect. - if (token === 131 /* FromKeyword */ || (token === 9 /* StringLiteral */ && !scanner.hasPrecedingLineBreak())) { - parseExpected(131 /* FromKeyword */); + if (token === 133 /* FromKeyword */ || (token === 9 /* StringLiteral */ && !scanner.hasPrecedingLineBreak())) { + parseExpected(133 /* FromKeyword */); node.moduleSpecifier = parseModuleSpecifier(); } } @@ -11734,14 +12048,14 @@ var ts; return finishNode(node); } function parseExportAssignment(fullStart, decorators, modifiers) { - var node = createNode(225 /* ExportAssignment */, fullStart); + var node = createNode(227 /* ExportAssignment */, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - if (parseOptional(55 /* EqualsToken */)) { + if (parseOptional(56 /* EqualsToken */)) { node.isExportEquals = true; } else { - parseExpected(75 /* DefaultKeyword */); + parseExpected(77 /* DefaultKeyword */); } node.expression = parseAssignmentExpressionOrHigher(); parseSemicolon(); @@ -11807,10 +12121,10 @@ var ts; function setExternalModuleIndicator(sourceFile) { sourceFile.externalModuleIndicator = ts.forEach(sourceFile.statements, function (node) { return node.flags & 1 /* Export */ - || node.kind === 219 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 230 /* ExternalModuleReference */ - || node.kind === 220 /* ImportDeclaration */ - || node.kind === 225 /* ExportAssignment */ - || node.kind === 226 /* ExportDeclaration */ + || node.kind === 221 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 232 /* ExternalModuleReference */ + || node.kind === 222 /* ImportDeclaration */ + || node.kind === 227 /* ExportAssignment */ + || node.kind === 228 /* ExportDeclaration */ ? node : undefined; }); @@ -11856,22 +12170,22 @@ var ts; function isJSDocType() { switch (token) { case 37 /* AsteriskToken */: - case 52 /* QuestionToken */: + case 53 /* QuestionToken */: case 17 /* OpenParenToken */: case 19 /* OpenBracketToken */: - case 48 /* ExclamationToken */: + case 49 /* ExclamationToken */: case 15 /* OpenBraceToken */: - case 85 /* FunctionKeyword */: + case 87 /* FunctionKeyword */: case 22 /* DotDotDotToken */: - case 90 /* NewKeyword */: - case 95 /* ThisKeyword */: + case 92 /* NewKeyword */: + case 97 /* ThisKeyword */: return true; } return ts.tokenIsIdentifierOrKeyword(token); } JSDocParser.isJSDocType = isJSDocType; function parseJSDocTypeExpressionForTests(content, start, length) { - initializeState("file.js", content, 2 /* Latest */, /*_syntaxCursor:*/ undefined); + initializeState("file.js", content, 2 /* Latest */, /*isJavaScriptFile*/ true, /*_syntaxCursor:*/ undefined); var jsDocTypeExpression = parseJSDocTypeExpression(start, length); var diagnostics = parseDiagnostics; clearState(); @@ -11885,7 +12199,7 @@ var ts; scanner.setText(sourceText, start, length); // Prime the first token for us to start processing. token = nextToken(); - var result = createNode(247 /* JSDocTypeExpression */); + var result = createNode(249 /* JSDocTypeExpression */); parseExpected(15 /* OpenBraceToken */); result.type = parseJSDocTopLevelType(); parseExpected(16 /* CloseBraceToken */); @@ -11895,13 +12209,13 @@ var ts; JSDocParser.parseJSDocTypeExpression = parseJSDocTypeExpression; function parseJSDocTopLevelType() { var type = parseJSDocType(); - if (token === 46 /* BarToken */) { - var unionType = createNode(251 /* JSDocUnionType */, type.pos); + if (token === 47 /* BarToken */) { + var unionType = createNode(253 /* JSDocUnionType */, type.pos); unionType.types = parseJSDocTypeList(type); type = finishNode(unionType); } - if (token === 55 /* EqualsToken */) { - var optionalType = createNode(258 /* JSDocOptionalType */, type.pos); + if (token === 56 /* EqualsToken */) { + var optionalType = createNode(260 /* JSDocOptionalType */, type.pos); nextToken(); optionalType.type = type; type = finishNode(optionalType); @@ -11912,20 +12226,20 @@ var ts; var type = parseBasicTypeExpression(); while (true) { if (token === 19 /* OpenBracketToken */) { - var arrayType = createNode(250 /* JSDocArrayType */, type.pos); + var arrayType = createNode(252 /* JSDocArrayType */, type.pos); arrayType.elementType = type; nextToken(); parseExpected(20 /* CloseBracketToken */); type = finishNode(arrayType); } - else if (token === 52 /* QuestionToken */) { - var nullableType = createNode(253 /* JSDocNullableType */, type.pos); + else if (token === 53 /* QuestionToken */) { + var nullableType = createNode(255 /* JSDocNullableType */, type.pos); nullableType.type = type; nextToken(); type = finishNode(nullableType); } - else if (token === 48 /* ExclamationToken */) { - var nonNullableType = createNode(254 /* JSDocNonNullableType */, type.pos); + else if (token === 49 /* ExclamationToken */) { + var nonNullableType = createNode(256 /* JSDocNonNullableType */, type.pos); nonNullableType.type = type; nextToken(); type = finishNode(nonNullableType); @@ -11940,80 +12254,80 @@ var ts; switch (token) { case 37 /* AsteriskToken */: return parseJSDocAllType(); - case 52 /* QuestionToken */: + case 53 /* QuestionToken */: return parseJSDocUnknownOrNullableType(); case 17 /* OpenParenToken */: return parseJSDocUnionType(); case 19 /* OpenBracketToken */: return parseJSDocTupleType(); - case 48 /* ExclamationToken */: + case 49 /* ExclamationToken */: return parseJSDocNonNullableType(); case 15 /* OpenBraceToken */: return parseJSDocRecordType(); - case 85 /* FunctionKeyword */: + case 87 /* FunctionKeyword */: return parseJSDocFunctionType(); case 22 /* DotDotDotToken */: return parseJSDocVariadicType(); - case 90 /* NewKeyword */: + case 92 /* NewKeyword */: return parseJSDocConstructorType(); - case 95 /* ThisKeyword */: + case 97 /* ThisKeyword */: return parseJSDocThisType(); - case 115 /* AnyKeyword */: - case 128 /* StringKeyword */: - case 126 /* NumberKeyword */: - case 118 /* BooleanKeyword */: - case 129 /* SymbolKeyword */: - case 101 /* VoidKeyword */: + case 117 /* AnyKeyword */: + case 130 /* StringKeyword */: + case 128 /* NumberKeyword */: + case 120 /* BooleanKeyword */: + case 131 /* SymbolKeyword */: + case 103 /* VoidKeyword */: return parseTokenNode(); } return parseJSDocTypeReference(); } function parseJSDocThisType() { - var result = createNode(262 /* JSDocThisType */); + var result = createNode(264 /* JSDocThisType */); nextToken(); - parseExpected(53 /* ColonToken */); + parseExpected(54 /* ColonToken */); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocConstructorType() { - var result = createNode(261 /* JSDocConstructorType */); + var result = createNode(263 /* JSDocConstructorType */); nextToken(); - parseExpected(53 /* ColonToken */); + parseExpected(54 /* ColonToken */); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocVariadicType() { - var result = createNode(260 /* JSDocVariadicType */); + var result = createNode(262 /* JSDocVariadicType */); nextToken(); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocFunctionType() { - var result = createNode(259 /* JSDocFunctionType */); + var result = createNode(261 /* JSDocFunctionType */); nextToken(); parseExpected(17 /* OpenParenToken */); result.parameters = parseDelimitedList(22 /* JSDocFunctionParameters */, parseJSDocParameter); checkForTrailingComma(result.parameters); parseExpected(18 /* CloseParenToken */); - if (token === 53 /* ColonToken */) { + if (token === 54 /* ColonToken */) { nextToken(); result.type = parseJSDocType(); } return finishNode(result); } function parseJSDocParameter() { - var parameter = createNode(136 /* Parameter */); + var parameter = createNode(138 /* Parameter */); parameter.type = parseJSDocType(); return finishNode(parameter); } function parseJSDocOptionalType(type) { - var result = createNode(258 /* JSDocOptionalType */, type.pos); + var result = createNode(260 /* JSDocOptionalType */, type.pos); nextToken(); result.type = type; return finishNode(result); } function parseJSDocTypeReference() { - var result = createNode(257 /* JSDocTypeReference */); + var result = createNode(259 /* JSDocTypeReference */); result.name = parseSimplePropertyName(); while (parseOptional(21 /* DotToken */)) { if (token === 25 /* LessThanToken */) { @@ -12043,13 +12357,13 @@ var ts; } } function parseQualifiedName(left) { - var result = createNode(133 /* QualifiedName */, left.pos); + var result = createNode(135 /* QualifiedName */, left.pos); result.left = left; result.right = parseIdentifierName(); return finishNode(result); } function parseJSDocRecordType() { - var result = createNode(255 /* JSDocRecordType */); + var result = createNode(257 /* JSDocRecordType */); nextToken(); result.members = parseDelimitedList(24 /* JSDocRecordMembers */, parseJSDocRecordMember); checkForTrailingComma(result.members); @@ -12057,22 +12371,22 @@ var ts; return finishNode(result); } function parseJSDocRecordMember() { - var result = createNode(256 /* JSDocRecordMember */); + var result = createNode(258 /* JSDocRecordMember */); result.name = parseSimplePropertyName(); - if (token === 53 /* ColonToken */) { + if (token === 54 /* ColonToken */) { nextToken(); result.type = parseJSDocType(); } return finishNode(result); } function parseJSDocNonNullableType() { - var result = createNode(254 /* JSDocNonNullableType */); + var result = createNode(256 /* JSDocNonNullableType */); nextToken(); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocTupleType() { - var result = createNode(252 /* JSDocTupleType */); + var result = createNode(254 /* JSDocTupleType */); nextToken(); result.types = parseDelimitedList(25 /* JSDocTupleTypes */, parseJSDocType); checkForTrailingComma(result.types); @@ -12086,7 +12400,7 @@ var ts; } } function parseJSDocUnionType() { - var result = createNode(251 /* JSDocUnionType */); + var result = createNode(253 /* JSDocUnionType */); nextToken(); result.types = parseJSDocTypeList(parseJSDocType()); parseExpected(18 /* CloseParenToken */); @@ -12097,14 +12411,14 @@ var ts; var types = []; types.pos = firstType.pos; types.push(firstType); - while (parseOptional(46 /* BarToken */)) { + while (parseOptional(47 /* BarToken */)) { types.push(parseJSDocType()); } types.end = scanner.getStartPos(); return types; } function parseJSDocAllType() { - var result = createNode(248 /* JSDocAllType */); + var result = createNode(250 /* JSDocAllType */); nextToken(); return finishNode(result); } @@ -12125,19 +12439,19 @@ var ts; token === 16 /* CloseBraceToken */ || token === 18 /* CloseParenToken */ || token === 27 /* GreaterThanToken */ || - token === 55 /* EqualsToken */ || - token === 46 /* BarToken */) { - var result = createNode(249 /* JSDocUnknownType */, pos); + token === 56 /* EqualsToken */ || + token === 47 /* BarToken */) { + var result = createNode(251 /* JSDocUnknownType */, pos); return finishNode(result); } else { - var result = createNode(253 /* JSDocNullableType */, pos); + var result = createNode(255 /* JSDocNullableType */, pos); result.type = parseJSDocType(); return finishNode(result); } } function parseIsolatedJSDocComment(content, start, length) { - initializeState("file.js", content, 2 /* Latest */, /*_syntaxCursor:*/ undefined); + initializeState("file.js", content, 2 /* Latest */, /*isJavaScriptFile*/ true, /*_syntaxCursor:*/ undefined); var jsDocComment = parseJSDocComment(/*parent:*/ undefined, start, length); var diagnostics = parseDiagnostics; clearState(); @@ -12219,7 +12533,7 @@ var ts; if (!tags) { return undefined; } - var result = createNode(263 /* JSDocComment */, start); + var result = createNode(265 /* JSDocComment */, start); result.tags = tags; return finishNode(result, end); } @@ -12230,7 +12544,7 @@ var ts; } function parseTag() { ts.Debug.assert(content.charCodeAt(pos - 1) === 64 /* at */); - var atToken = createNode(54 /* AtToken */, pos - 1); + var atToken = createNode(55 /* AtToken */, pos - 1); atToken.end = pos; var tagName = scanIdentifier(); if (!tagName) { @@ -12256,7 +12570,7 @@ var ts; return undefined; } function handleUnknownTag(atToken, tagName) { - var result = createNode(264 /* JSDocTag */, atToken.pos); + var result = createNode(266 /* JSDocTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; return finishNode(result, pos); @@ -12307,7 +12621,7 @@ var ts; if (!typeExpression) { typeExpression = tryParseTypeExpression(); } - var result = createNode(265 /* JSDocParameterTag */, atToken.pos); + var result = createNode(267 /* JSDocParameterTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.preParameterName = preName; @@ -12317,27 +12631,27 @@ var ts; return finishNode(result, pos); } function handleReturnTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 266 /* JSDocReturnTag */; })) { + if (ts.forEach(tags, function (t) { return t.kind === 268 /* JSDocReturnTag */; })) { parseErrorAtPosition(tagName.pos, pos - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); } - var result = createNode(266 /* JSDocReturnTag */, atToken.pos); + var result = createNode(268 /* JSDocReturnTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeExpression = tryParseTypeExpression(); return finishNode(result, pos); } function handleTypeTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 267 /* JSDocTypeTag */; })) { + if (ts.forEach(tags, function (t) { return t.kind === 269 /* JSDocTypeTag */; })) { parseErrorAtPosition(tagName.pos, pos - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); } - var result = createNode(267 /* JSDocTypeTag */, atToken.pos); + var result = createNode(269 /* JSDocTypeTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeExpression = tryParseTypeExpression(); return finishNode(result, pos); } function handleTemplateTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 268 /* JSDocTemplateTag */; })) { + if (ts.forEach(tags, function (t) { return t.kind === 270 /* JSDocTemplateTag */; })) { parseErrorAtPosition(tagName.pos, pos - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); } var typeParameters = []; @@ -12350,7 +12664,7 @@ var ts; parseErrorAtPosition(startPos, 0, ts.Diagnostics.Identifier_expected); return undefined; } - var typeParameter = createNode(135 /* TypeParameter */, name_8.pos); + var typeParameter = createNode(137 /* TypeParameter */, name_8.pos); typeParameter.name = name_8; finishNode(typeParameter, pos); typeParameters.push(typeParameter); @@ -12361,7 +12675,7 @@ var ts; pos++; } typeParameters.end = pos; - var result = createNode(268 /* JSDocTemplateTag */, atToken.pos); + var result = createNode(270 /* JSDocTemplateTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeParameters = typeParameters; @@ -12382,7 +12696,7 @@ var ts; if (startPos === pos) { return undefined; } - var result = createNode(67 /* Identifier */, startPos); + var result = createNode(69 /* Identifier */, startPos); result.text = content.substring(startPos, pos); return finishNode(result, pos); } @@ -12505,7 +12819,7 @@ var ts; switch (node.kind) { case 9 /* StringLiteral */: case 8 /* NumericLiteral */: - case 67 /* Identifier */: + case 69 /* Identifier */: return true; } return false; @@ -12898,17 +13212,19 @@ var ts; var Type = ts.objectAllocator.getTypeConstructor(); var Signature = ts.objectAllocator.getSignatureConstructor(); var typeCount = 0; + var symbolCount = 0; var emptyArray = []; var emptySymbols = {}; var compilerOptions = host.getCompilerOptions(); var languageVersion = compilerOptions.target || 0 /* ES3 */; + var modulekind = compilerOptions.module ? compilerOptions.module : languageVersion === 2 /* ES6 */ ? 5 /* ES6 */ : 0 /* None */; var emitResolver = createResolver(); var undefinedSymbol = createSymbol(4 /* Property */ | 67108864 /* Transient */, "undefined"); var argumentsSymbol = createSymbol(4 /* Property */ | 67108864 /* Transient */, "arguments"); var checker = { getNodeCount: function () { return ts.sum(host.getSourceFiles(), "nodeCount"); }, getIdentifierCount: function () { return ts.sum(host.getSourceFiles(), "identifierCount"); }, - getSymbolCount: function () { return ts.sum(host.getSourceFiles(), "symbolCount"); }, + getSymbolCount: function () { return ts.sum(host.getSourceFiles(), "symbolCount") + symbolCount; }, getTypeCount: function () { return typeCount; }, isUndefinedSymbol: function (symbol) { return symbol === undefinedSymbol; }, isArgumentsSymbol: function (symbol) { return symbol === argumentsSymbol; }, @@ -12999,6 +13315,7 @@ var ts; var getInstantiatedGlobalPromiseLikeType; var getGlobalPromiseConstructorLikeType; var getGlobalThenableType; + var cjsRequireType; var tupleTypes = {}; var unionTypes = {}; var intersectionTypes = {}; @@ -13069,6 +13386,7 @@ var ts; diagnostics.add(diagnostic); } function createSymbol(flags, name) { + symbolCount++; return new Symbol(flags, name); } function getExcludedSymbolFlags(flags) { @@ -13198,10 +13516,10 @@ var ts; return nodeLinks[nodeId] || (nodeLinks[nodeId] = {}); } function getSourceFile(node) { - return ts.getAncestor(node, 246 /* SourceFile */); + return ts.getAncestor(node, 248 /* SourceFile */); } function isGlobalSourceFile(node) { - return node.kind === 246 /* SourceFile */ && !ts.isExternalModule(node); + return node.kind === 248 /* SourceFile */ && !ts.isExternalOrCommonJsModule(node); } function getSymbol(symbols, name, meaning) { if (meaning && ts.hasProperty(symbols, name)) { @@ -13220,18 +13538,62 @@ var ts; } // return undefined if we can't find a symbol. } - /** Returns true if node1 is defined before node 2**/ - function isDefinedBefore(node1, node2) { - var file1 = ts.getSourceFileOfNode(node1); - var file2 = ts.getSourceFileOfNode(node2); - if (file1 === file2) { - return node1.pos <= node2.pos; + function isBlockScopedNameDeclaredBeforeUse(declaration, usage) { + var declarationFile = ts.getSourceFileOfNode(declaration); + var useFile = ts.getSourceFileOfNode(usage); + if (declarationFile !== useFile) { + if (modulekind || (!compilerOptions.outFile && !compilerOptions.out)) { + // nodes are in different files and order cannot be determines + return true; + } + var sourceFiles = host.getSourceFiles(); + return ts.indexOf(sourceFiles, declarationFile) <= ts.indexOf(sourceFiles, useFile); } - if (!compilerOptions.outFile && !compilerOptions.out) { - return true; + if (declaration.pos <= usage.pos) { + // declaration is before usage + // still might be illegal if usage is in the initializer of the variable declaration + return declaration.kind !== 211 /* VariableDeclaration */ || + !isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage); + } + // declaration is after usage + // can be legal if usage is deferred (i.e. inside function or in initializer of instance property) + return isUsedInFunctionOrNonStaticProperty(declaration, usage); + function isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage) { + var container = ts.getEnclosingBlockScopeContainer(declaration); + if (declaration.parent.parent.kind === 193 /* VariableStatement */ || + declaration.parent.parent.kind === 199 /* ForStatement */) { + // variable statement/for statement case, + // use site should not be inside variable declaration (initializer of declaration or binding element) + return isSameScopeDescendentOf(usage, declaration, container); + } + else if (declaration.parent.parent.kind === 201 /* ForOfStatement */ || + declaration.parent.parent.kind === 200 /* ForInStatement */) { + // ForIn/ForOf case - use site should not be used in expression part + var expression = declaration.parent.parent.expression; + return isSameScopeDescendentOf(usage, expression, container); + } + } + function isUsedInFunctionOrNonStaticProperty(declaration, usage) { + var container = ts.getEnclosingBlockScopeContainer(declaration); + var current = usage; + while (current) { + if (current === container) { + return false; + } + if (ts.isFunctionLike(current)) { + return true; + } + var initializerOfNonStaticProperty = current.parent && + current.parent.kind === 141 /* PropertyDeclaration */ && + (current.parent.flags & 128 /* Static */) === 0 && + current.parent.initializer === current; + if (initializerOfNonStaticProperty) { + return true; + } + current = current.parent; + } + return false; } - var sourceFiles = host.getSourceFiles(); - return sourceFiles.indexOf(file1) <= sourceFiles.indexOf(file2); } // Resolve a given name for a given meaning at a given location. An error is reported if the name was not found and // the nameNotFoundMessage argument is not undefined. Returns the resolved symbol, or undefined if no symbol with @@ -13258,13 +13620,13 @@ var ts; } } switch (location.kind) { - case 246 /* SourceFile */: - if (!ts.isExternalModule(location)) + case 248 /* SourceFile */: + if (!ts.isExternalOrCommonJsModule(location)) break; - case 216 /* ModuleDeclaration */: + case 218 /* ModuleDeclaration */: var moduleExports = getSymbolOfNode(location).exports; - if (location.kind === 246 /* SourceFile */ || - (location.kind === 216 /* ModuleDeclaration */ && location.name.kind === 9 /* StringLiteral */)) { + if (location.kind === 248 /* SourceFile */ || + (location.kind === 218 /* ModuleDeclaration */ && location.name.kind === 9 /* StringLiteral */)) { // It's an external module. Because of module/namespace merging, a module's exports are in scope, // yet we never want to treat an export specifier as putting a member in scope. Therefore, // if the name we find is purely an export specifier, it is not actually considered in scope. @@ -13278,7 +13640,7 @@ var ts; // which is not the desired behavior. if (ts.hasProperty(moduleExports, name) && moduleExports[name].flags === 8388608 /* Alias */ && - ts.getDeclarationOfKind(moduleExports[name], 228 /* ExportSpecifier */)) { + ts.getDeclarationOfKind(moduleExports[name], 230 /* ExportSpecifier */)) { break; } result = moduleExports["default"]; @@ -13292,13 +13654,13 @@ var ts; break loop; } break; - case 215 /* EnumDeclaration */: + case 217 /* EnumDeclaration */: if (result = getSymbol(getSymbolOfNode(location).exports, name, meaning & 8 /* EnumMember */)) { break loop; } break; - case 139 /* PropertyDeclaration */: - case 138 /* PropertySignature */: + case 141 /* PropertyDeclaration */: + case 140 /* PropertySignature */: // TypeScript 1.0 spec (April 2014): 8.4.1 // Initializer expressions for instance member variables are evaluated in the scope // of the class constructor body but are not permitted to reference parameters or @@ -13315,9 +13677,9 @@ var ts; } } break; - case 212 /* ClassDeclaration */: - case 184 /* ClassExpression */: - case 213 /* InterfaceDeclaration */: + case 214 /* ClassDeclaration */: + case 186 /* ClassExpression */: + case 215 /* InterfaceDeclaration */: if (result = getSymbol(getSymbolOfNode(location).members, name, meaning & 793056 /* Type */)) { if (lastLocation && lastLocation.flags & 128 /* Static */) { // TypeScript 1.0 spec (April 2014): 3.4.1 @@ -13328,7 +13690,7 @@ var ts; } break loop; } - if (location.kind === 184 /* ClassExpression */ && meaning & 32 /* Class */) { + if (location.kind === 186 /* ClassExpression */ && meaning & 32 /* Class */) { var className = location.name; if (className && name === className.text) { result = location.symbol; @@ -13344,9 +13706,9 @@ var ts; // [foo()]() { } // <-- Reference to T from class's own computed property // } // - case 134 /* ComputedPropertyName */: + case 136 /* ComputedPropertyName */: grandparent = location.parent.parent; - if (ts.isClassLike(grandparent) || grandparent.kind === 213 /* InterfaceDeclaration */) { + if (ts.isClassLike(grandparent) || grandparent.kind === 215 /* InterfaceDeclaration */) { // A reference to this grandparent's type parameters would be an error if (result = getSymbol(getSymbolOfNode(grandparent).members, name, meaning & 793056 /* Type */)) { error(errorLocation, ts.Diagnostics.A_computed_property_name_cannot_reference_a_type_parameter_from_its_containing_type); @@ -13354,19 +13716,19 @@ var ts; } } break; - case 141 /* MethodDeclaration */: - case 140 /* MethodSignature */: - case 142 /* Constructor */: - case 143 /* GetAccessor */: - case 144 /* SetAccessor */: - case 211 /* FunctionDeclaration */: - case 172 /* ArrowFunction */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: + case 144 /* Constructor */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: + case 213 /* FunctionDeclaration */: + case 174 /* ArrowFunction */: if (meaning & 3 /* Variable */ && name === "arguments") { result = argumentsSymbol; break loop; } break; - case 171 /* FunctionExpression */: + case 173 /* FunctionExpression */: if (meaning & 3 /* Variable */ && name === "arguments") { result = argumentsSymbol; break loop; @@ -13379,7 +13741,7 @@ var ts; } } break; - case 137 /* Decorator */: + case 139 /* Decorator */: // Decorators are resolved at the class declaration. Resolving at the parameter // or member would result in looking up locals in the method. // @@ -13388,7 +13750,7 @@ var ts; // method(@y x, y) {} // <-- decorator y should be resolved at the class declaration, not the parameter. // } // - if (location.parent && location.parent.kind === 136 /* Parameter */) { + if (location.parent && location.parent.kind === 138 /* Parameter */) { location = location.parent; } // @@ -13434,8 +13796,11 @@ var ts; // block - scope variable and namespace module. However, only when we // try to resolve name in /*1*/ which is used in variable position, // we want to check for block- scoped - if (meaning & 2 /* BlockScopedVariable */ && result.flags & 2 /* BlockScopedVariable */) { - checkResolvedBlockScopedVariable(result, errorLocation); + if (meaning & 2 /* BlockScopedVariable */) { + var exportOrLocalSymbol = getExportSymbolOfValueSymbolIfExported(result); + if (exportOrLocalSymbol.flags & 2 /* BlockScopedVariable */) { + checkResolvedBlockScopedVariable(exportOrLocalSymbol, errorLocation); + } } } return result; @@ -13445,32 +13810,7 @@ var ts; // Block-scoped variables cannot be used before their definition var declaration = ts.forEach(result.declarations, function (d) { return ts.isBlockOrCatchScoped(d) ? d : undefined; }); ts.Debug.assert(declaration !== undefined, "Block-scoped variable declaration is undefined"); - // first check if usage is lexically located after the declaration - var isUsedBeforeDeclaration = !isDefinedBefore(declaration, errorLocation); - if (!isUsedBeforeDeclaration) { - // lexical check succeeded however code still can be illegal. - // - block scoped variables cannot be used in its initializers - // let x = x; // illegal but usage is lexically after definition - // - in ForIn/ForOf statements variable cannot be contained in expression part - // for (let x in x) - // for (let x of x) - // climb up to the variable declaration skipping binding patterns - var variableDeclaration = ts.getAncestor(declaration, 209 /* VariableDeclaration */); - var container = ts.getEnclosingBlockScopeContainer(variableDeclaration); - if (variableDeclaration.parent.parent.kind === 191 /* VariableStatement */ || - variableDeclaration.parent.parent.kind === 197 /* ForStatement */) { - // variable statement/for statement case, - // use site should not be inside variable declaration (initializer of declaration or binding element) - isUsedBeforeDeclaration = isSameScopeDescendentOf(errorLocation, variableDeclaration, container); - } - else if (variableDeclaration.parent.parent.kind === 199 /* ForOfStatement */ || - variableDeclaration.parent.parent.kind === 198 /* ForInStatement */) { - // ForIn/ForOf case - use site should not be used in expression part - var expression = variableDeclaration.parent.parent.expression; - isUsedBeforeDeclaration = isSameScopeDescendentOf(errorLocation, expression, container); - } - } - if (isUsedBeforeDeclaration) { + if (!isBlockScopedNameDeclaredBeforeUse(ts.getAncestor(declaration, 211 /* VariableDeclaration */), errorLocation)) { error(errorLocation, ts.Diagnostics.Block_scoped_variable_0_used_before_its_declaration, ts.declarationNameToString(declaration.name)); } } @@ -13491,10 +13831,10 @@ var ts; } function getAnyImportSyntax(node) { if (ts.isAliasSymbolDeclaration(node)) { - if (node.kind === 219 /* ImportEqualsDeclaration */) { + if (node.kind === 221 /* ImportEqualsDeclaration */) { return node; } - while (node && node.kind !== 220 /* ImportDeclaration */) { + while (node && node.kind !== 222 /* ImportDeclaration */) { node = node.parent; } return node; @@ -13504,7 +13844,7 @@ var ts; return ts.forEach(symbol.declarations, function (d) { return ts.isAliasSymbolDeclaration(d) ? d : undefined; }); } function getTargetOfImportEqualsDeclaration(node) { - if (node.moduleReference.kind === 230 /* ExternalModuleReference */) { + if (node.moduleReference.kind === 232 /* ExternalModuleReference */) { return resolveExternalModuleSymbol(resolveExternalModuleName(node, ts.getExternalModuleImportEqualsDeclarationExpression(node))); } return getSymbolOfPartOfRightHandSideOfImportEquals(node.moduleReference, node); @@ -13611,17 +13951,17 @@ var ts; } function getTargetOfAliasDeclaration(node) { switch (node.kind) { - case 219 /* ImportEqualsDeclaration */: + case 221 /* ImportEqualsDeclaration */: return getTargetOfImportEqualsDeclaration(node); - case 221 /* ImportClause */: + case 223 /* ImportClause */: return getTargetOfImportClause(node); - case 222 /* NamespaceImport */: + case 224 /* NamespaceImport */: return getTargetOfNamespaceImport(node); - case 224 /* ImportSpecifier */: + case 226 /* ImportSpecifier */: return getTargetOfImportSpecifier(node); - case 228 /* ExportSpecifier */: + case 230 /* ExportSpecifier */: return getTargetOfExportSpecifier(node); - case 225 /* ExportAssignment */: + case 227 /* ExportAssignment */: return getTargetOfExportAssignment(node); } } @@ -13666,11 +14006,11 @@ var ts; if (!links.referenced) { links.referenced = true; var node = getDeclarationOfAliasSymbol(symbol); - if (node.kind === 225 /* ExportAssignment */) { + if (node.kind === 227 /* ExportAssignment */) { // export default checkExpressionCached(node.expression); } - else if (node.kind === 228 /* ExportSpecifier */) { + else if (node.kind === 230 /* ExportSpecifier */) { // export { } or export { as foo } checkExpressionCached(node.propertyName || node.name); } @@ -13683,7 +14023,7 @@ var ts; // This function is only for imports with entity names function getSymbolOfPartOfRightHandSideOfImportEquals(entityName, importDeclaration) { if (!importDeclaration) { - importDeclaration = ts.getAncestor(entityName, 219 /* ImportEqualsDeclaration */); + importDeclaration = ts.getAncestor(entityName, 221 /* ImportEqualsDeclaration */); ts.Debug.assert(importDeclaration !== undefined); } // There are three things we might try to look for. In the following examples, @@ -13692,17 +14032,17 @@ var ts; // import a = |b|; // Namespace // import a = |b.c|; // Value, type, namespace // import a = |b.c|.d; // Namespace - if (entityName.kind === 67 /* Identifier */ && ts.isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { + if (entityName.kind === 69 /* Identifier */ && ts.isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { entityName = entityName.parent; } // Check for case 1 and 3 in the above example - if (entityName.kind === 67 /* Identifier */ || entityName.parent.kind === 133 /* QualifiedName */) { + if (entityName.kind === 69 /* Identifier */ || entityName.parent.kind === 135 /* QualifiedName */) { return resolveEntityName(entityName, 1536 /* Namespace */); } else { // Case 2 in above example // entityName.kind could be a QualifiedName or a Missing identifier - ts.Debug.assert(entityName.parent.kind === 219 /* ImportEqualsDeclaration */); + ts.Debug.assert(entityName.parent.kind === 221 /* ImportEqualsDeclaration */); return resolveEntityName(entityName, 107455 /* Value */ | 793056 /* Type */ | 1536 /* Namespace */); } } @@ -13715,16 +14055,16 @@ var ts; return undefined; } var symbol; - if (name.kind === 67 /* Identifier */) { + if (name.kind === 69 /* Identifier */) { var message = meaning === 1536 /* Namespace */ ? ts.Diagnostics.Cannot_find_namespace_0 : ts.Diagnostics.Cannot_find_name_0; symbol = resolveName(name, name.text, meaning, ignoreErrors ? undefined : message, name); if (!symbol) { return undefined; } } - else if (name.kind === 133 /* QualifiedName */ || name.kind === 164 /* PropertyAccessExpression */) { - var left = name.kind === 133 /* QualifiedName */ ? name.left : name.expression; - var right = name.kind === 133 /* QualifiedName */ ? name.right : name.name; + else if (name.kind === 135 /* QualifiedName */ || name.kind === 166 /* PropertyAccessExpression */) { + var left = name.kind === 135 /* QualifiedName */ ? name.left : name.expression; + var right = name.kind === 135 /* QualifiedName */ ? name.right : name.name; var namespace = resolveEntityName(left, 1536 /* Namespace */, ignoreErrors); if (!namespace || namespace === unknownSymbol || ts.nodeIsMissing(right)) { return undefined; @@ -13743,11 +14083,6 @@ var ts; ts.Debug.assert((symbol.flags & 16777216 /* Instantiated */) === 0, "Should never get an instantiated symbol here."); return symbol.flags & meaning ? symbol : resolveAlias(symbol); } - function isExternalModuleNameRelative(moduleName) { - // TypeScript 1.0 spec (April 2014): 11.2.1 - // An external module name is "relative" if the first term is "." or "..". - return moduleName.substr(0, 2) === "./" || moduleName.substr(0, 3) === "../" || moduleName.substr(0, 2) === ".\\" || moduleName.substr(0, 3) === "..\\"; - } function resolveExternalModuleName(location, moduleReferenceExpression) { if (moduleReferenceExpression.kind !== 9 /* StringLiteral */) { return; @@ -13760,7 +14095,10 @@ var ts; if (moduleName === undefined) { return; } - var isRelative = isExternalModuleNameRelative(moduleName); + if (moduleName.indexOf("!") >= 0) { + moduleName = moduleName.substr(0, moduleName.indexOf("!")); + } + var isRelative = ts.isExternalModuleNameRelative(moduleName); if (!isRelative) { var symbol = getSymbol(globals, "\"" + moduleName + "\"", 512 /* ValueModule */); if (symbol) { @@ -13876,7 +14214,7 @@ var ts; var members = node.members; for (var _i = 0; _i < members.length; _i++) { var member = members[_i]; - if (member.kind === 142 /* Constructor */ && ts.nodeIsPresent(member.body)) { + if (member.kind === 144 /* Constructor */ && ts.nodeIsPresent(member.body)) { return member; } } @@ -13946,17 +14284,17 @@ var ts; } } switch (location_1.kind) { - case 246 /* SourceFile */: - if (!ts.isExternalModule(location_1)) { + case 248 /* SourceFile */: + if (!ts.isExternalOrCommonJsModule(location_1)) { break; } - case 216 /* ModuleDeclaration */: + case 218 /* ModuleDeclaration */: if (result = callback(getSymbolOfNode(location_1).exports)) { return result; } break; - case 212 /* ClassDeclaration */: - case 213 /* InterfaceDeclaration */: + case 214 /* ClassDeclaration */: + case 215 /* InterfaceDeclaration */: if (result = callback(getSymbolOfNode(location_1).members)) { return result; } @@ -13997,7 +14335,7 @@ var ts; return ts.forEachValue(symbols, function (symbolFromSymbolTable) { if (symbolFromSymbolTable.flags & 8388608 /* Alias */ && symbolFromSymbolTable.name !== "export=" - && !ts.getDeclarationOfKind(symbolFromSymbolTable, 228 /* ExportSpecifier */)) { + && !ts.getDeclarationOfKind(symbolFromSymbolTable, 230 /* ExportSpecifier */)) { if (!useOnlyExternalAliasing || // Is this external alias, then use it to name ts.forEach(symbolFromSymbolTable.declarations, ts.isExternalModuleImportEqualsDeclaration)) { @@ -14034,7 +14372,7 @@ var ts; return true; } // Qualify if the symbol from symbol table has same meaning as expected - symbolFromSymbolTable = (symbolFromSymbolTable.flags & 8388608 /* Alias */ && !ts.getDeclarationOfKind(symbolFromSymbolTable, 228 /* ExportSpecifier */)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; + symbolFromSymbolTable = (symbolFromSymbolTable.flags & 8388608 /* Alias */ && !ts.getDeclarationOfKind(symbolFromSymbolTable, 230 /* ExportSpecifier */)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; if (symbolFromSymbolTable.flags & meaning) { qualify = true; return true; @@ -14107,8 +14445,8 @@ var ts; } } function hasExternalModuleSymbol(declaration) { - return (declaration.kind === 216 /* ModuleDeclaration */ && declaration.name.kind === 9 /* StringLiteral */) || - (declaration.kind === 246 /* SourceFile */ && ts.isExternalModule(declaration)); + return (declaration.kind === 218 /* ModuleDeclaration */ && declaration.name.kind === 9 /* StringLiteral */) || + (declaration.kind === 248 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); } function hasVisibleDeclarations(symbol) { var aliasesToMakeVisible; @@ -14144,12 +14482,12 @@ var ts; function isEntityNameVisible(entityName, enclosingDeclaration) { // get symbol of the first identifier of the entityName var meaning; - if (entityName.parent.kind === 152 /* TypeQuery */) { + if (entityName.parent.kind === 154 /* TypeQuery */) { // Typeof value meaning = 107455 /* Value */ | 1048576 /* ExportValue */; } - else if (entityName.kind === 133 /* QualifiedName */ || entityName.kind === 164 /* PropertyAccessExpression */ || - entityName.parent.kind === 219 /* ImportEqualsDeclaration */) { + else if (entityName.kind === 135 /* QualifiedName */ || entityName.kind === 166 /* PropertyAccessExpression */ || + entityName.parent.kind === 221 /* ImportEqualsDeclaration */) { // Left identifier from type reference or TypeAlias // Entity name of the import declaration meaning = 1536 /* Namespace */; @@ -14204,10 +14542,10 @@ var ts; function getTypeAliasForTypeLiteral(type) { if (type.symbol && type.symbol.flags & 2048 /* TypeLiteral */) { var node = type.symbol.declarations[0].parent; - while (node.kind === 158 /* ParenthesizedType */) { + while (node.kind === 160 /* ParenthesizedType */) { node = node.parent; } - if (node.kind === 214 /* TypeAliasDeclaration */) { + if (node.kind === 216 /* TypeAliasDeclaration */) { return getSymbolOfNode(node); } } @@ -14221,10 +14559,10 @@ var ts; return ts.declarationNameToString(declaration.name); } switch (declaration.kind) { - case 184 /* ClassExpression */: + case 186 /* ClassExpression */: return "(Anonymous class)"; - case 171 /* FunctionExpression */: - case 172 /* ArrowFunction */: + case 173 /* FunctionExpression */: + case 174 /* ArrowFunction */: return "(Anonymous function)"; } } @@ -14307,6 +14645,7 @@ var ts; } function buildTypeDisplay(type, writer, enclosingDeclaration, globalFlags, symbolStack) { var globalFlagsToPass = globalFlags & 16 /* WriteOwnNameForAnyLike */; + var inObjectTypeLiteral = false; return writeType(type, globalFlags); function writeType(type, flags) { // Write undefined/null type as any @@ -14316,6 +14655,12 @@ var ts; ? "any" : type.intrinsicName); } + else if (type.flags & 33554432 /* ThisType */) { + if (inObjectTypeLiteral) { + writer.reportInaccessibleThisError(); + } + writer.writeKeyword("this"); + } else if (type.flags & 4096 /* Reference */) { writeTypeReference(type, flags); } @@ -14357,11 +14702,10 @@ var ts; writeType(types[i], delimiter === 24 /* CommaToken */ ? 0 /* None */ : 64 /* InElementType */); } } - function writeSymbolTypeReference(symbol, typeArguments, pos, end) { - // Unnamed function expressions, arrow functions, and unnamed class expressions have reserved names that - // we don't want to display - if (!isReservedMemberName(symbol.name)) { - buildSymbolDisplay(symbol, writer, enclosingDeclaration, 793056 /* Type */); + function writeSymbolTypeReference(symbol, typeArguments, pos, end, flags) { + // Unnamed function expressions and arrow functions have reserved names that we don't want to display + if (symbol.flags & 32 /* Class */ || !isReservedMemberName(symbol.name)) { + buildSymbolDisplay(symbol, writer, enclosingDeclaration, 793056 /* Type */, 0 /* None */, flags); } if (pos < end) { writePunctuation(writer, 25 /* LessThanToken */); @@ -14375,7 +14719,7 @@ var ts; } } function writeTypeReference(type, flags) { - var typeArguments = type.typeArguments; + var typeArguments = type.typeArguments || emptyArray; if (type.target === globalArrayType && !(flags & 1 /* WriteArrayAsGenericType */)) { writeType(typeArguments[0], 64 /* InElementType */); writePunctuation(writer, 19 /* OpenBracketToken */); @@ -14399,12 +14743,13 @@ var ts; // When type parameters are their own type arguments for the whole group (i.e. we have // the default outer type arguments), we don't show the group. if (!ts.rangeEquals(outerTypeParameters, typeArguments, start, i)) { - writeSymbolTypeReference(parent_3, typeArguments, start, i); + writeSymbolTypeReference(parent_3, typeArguments, start, i, flags); writePunctuation(writer, 21 /* DotToken */); } } } - writeSymbolTypeReference(type.symbol, typeArguments, i, typeArguments.length); + var typeParameterCount = (type.target.typeParameters || emptyArray).length; + writeSymbolTypeReference(type.symbol, typeArguments, i, typeParameterCount, flags); } } function writeTupleType(type) { @@ -14416,7 +14761,7 @@ var ts; if (flags & 64 /* InElementType */) { writePunctuation(writer, 17 /* OpenParenToken */); } - writeTypeList(type.types, type.flags & 16384 /* Union */ ? 46 /* BarToken */ : 45 /* AmpersandToken */); + writeTypeList(type.types, type.flags & 16384 /* Union */ ? 47 /* BarToken */ : 46 /* AmpersandToken */); if (flags & 64 /* InElementType */) { writePunctuation(writer, 18 /* CloseParenToken */); } @@ -14440,7 +14785,7 @@ var ts; } else { // Recursive usage, use any - writeKeyword(writer, 115 /* AnyKeyword */); + writeKeyword(writer, 117 /* AnyKeyword */); } } else { @@ -14464,7 +14809,7 @@ var ts; var isNonLocalFunctionSymbol = !!(symbol.flags & 16 /* Function */) && (symbol.parent || ts.forEach(symbol.declarations, function (declaration) { - return declaration.parent.kind === 246 /* SourceFile */ || declaration.parent.kind === 217 /* ModuleBlock */; + return declaration.parent.kind === 248 /* SourceFile */ || declaration.parent.kind === 219 /* ModuleBlock */; })); if (isStaticMethodSymbol || isNonLocalFunctionSymbol) { // typeof is allowed only for static/non local functions @@ -14474,7 +14819,7 @@ var ts; } } function writeTypeofSymbol(type, typeFormatFlags) { - writeKeyword(writer, 99 /* TypeOfKeyword */); + writeKeyword(writer, 101 /* TypeOfKeyword */); writeSpace(writer); buildSymbolDisplay(type.symbol, writer, enclosingDeclaration, 107455 /* Value */, 0 /* None */, typeFormatFlags); } @@ -14510,7 +14855,7 @@ var ts; if (flags & 64 /* InElementType */) { writePunctuation(writer, 17 /* OpenParenToken */); } - writeKeyword(writer, 90 /* NewKeyword */); + writeKeyword(writer, 92 /* NewKeyword */); writeSpace(writer); buildSignatureDisplay(resolved.constructSignatures[0], writer, enclosingDeclaration, globalFlagsToPass | 8 /* WriteArrowStyleSignature */, symbolStack); if (flags & 64 /* InElementType */) { @@ -14519,6 +14864,8 @@ var ts; return; } } + var saveInObjectTypeLiteral = inObjectTypeLiteral; + inObjectTypeLiteral = true; writePunctuation(writer, 15 /* OpenBraceToken */); writer.writeLine(); writer.increaseIndent(); @@ -14530,7 +14877,7 @@ var ts; } for (var _b = 0, _c = resolved.constructSignatures; _b < _c.length; _b++) { var signature = _c[_b]; - writeKeyword(writer, 90 /* NewKeyword */); + writeKeyword(writer, 92 /* NewKeyword */); writeSpace(writer); buildSignatureDisplay(signature, writer, enclosingDeclaration, globalFlagsToPass, symbolStack); writePunctuation(writer, 23 /* SemicolonToken */); @@ -14540,11 +14887,11 @@ var ts; // [x: string]: writePunctuation(writer, 19 /* OpenBracketToken */); writer.writeParameter(getIndexerParameterName(resolved, 0 /* String */, /*fallbackName*/ "x")); - writePunctuation(writer, 53 /* ColonToken */); + writePunctuation(writer, 54 /* ColonToken */); writeSpace(writer); - writeKeyword(writer, 128 /* StringKeyword */); + writeKeyword(writer, 130 /* StringKeyword */); writePunctuation(writer, 20 /* CloseBracketToken */); - writePunctuation(writer, 53 /* ColonToken */); + writePunctuation(writer, 54 /* ColonToken */); writeSpace(writer); writeType(resolved.stringIndexType, 0 /* None */); writePunctuation(writer, 23 /* SemicolonToken */); @@ -14554,11 +14901,11 @@ var ts; // [x: number]: writePunctuation(writer, 19 /* OpenBracketToken */); writer.writeParameter(getIndexerParameterName(resolved, 1 /* Number */, /*fallbackName*/ "x")); - writePunctuation(writer, 53 /* ColonToken */); + writePunctuation(writer, 54 /* ColonToken */); writeSpace(writer); - writeKeyword(writer, 126 /* NumberKeyword */); + writeKeyword(writer, 128 /* NumberKeyword */); writePunctuation(writer, 20 /* CloseBracketToken */); - writePunctuation(writer, 53 /* ColonToken */); + writePunctuation(writer, 54 /* ColonToken */); writeSpace(writer); writeType(resolved.numberIndexType, 0 /* None */); writePunctuation(writer, 23 /* SemicolonToken */); @@ -14573,7 +14920,7 @@ var ts; var signature = signatures[_f]; buildSymbolDisplay(p, writer); if (p.flags & 536870912 /* Optional */) { - writePunctuation(writer, 52 /* QuestionToken */); + writePunctuation(writer, 53 /* QuestionToken */); } buildSignatureDisplay(signature, writer, enclosingDeclaration, globalFlagsToPass, symbolStack); writePunctuation(writer, 23 /* SemicolonToken */); @@ -14583,9 +14930,9 @@ var ts; else { buildSymbolDisplay(p, writer); if (p.flags & 536870912 /* Optional */) { - writePunctuation(writer, 52 /* QuestionToken */); + writePunctuation(writer, 53 /* QuestionToken */); } - writePunctuation(writer, 53 /* ColonToken */); + writePunctuation(writer, 54 /* ColonToken */); writeSpace(writer); writeType(t, 0 /* None */); writePunctuation(writer, 23 /* SemicolonToken */); @@ -14594,6 +14941,7 @@ var ts; } writer.decreaseIndent(); writePunctuation(writer, 16 /* CloseBraceToken */); + inObjectTypeLiteral = saveInObjectTypeLiteral; } } function buildTypeParameterDisplayFromSymbol(symbol, writer, enclosingDeclaraiton, flags) { @@ -14607,7 +14955,7 @@ var ts; var constraint = getConstraintOfTypeParameter(tp); if (constraint) { writeSpace(writer); - writeKeyword(writer, 81 /* ExtendsKeyword */); + writeKeyword(writer, 83 /* ExtendsKeyword */); writeSpace(writer); buildTypeDisplay(constraint, writer, enclosingDeclaration, flags, symbolStack); } @@ -14619,9 +14967,9 @@ var ts; } appendSymbolNameOnly(p, writer); if (isOptionalParameter(parameterNode)) { - writePunctuation(writer, 52 /* QuestionToken */); + writePunctuation(writer, 53 /* QuestionToken */); } - writePunctuation(writer, 53 /* ColonToken */); + writePunctuation(writer, 54 /* ColonToken */); writeSpace(writer); buildTypeDisplay(getTypeOfSymbol(p), writer, enclosingDeclaration, flags, symbolStack); } @@ -14668,14 +15016,14 @@ var ts; writePunctuation(writer, 34 /* EqualsGreaterThanToken */); } else { - writePunctuation(writer, 53 /* ColonToken */); + writePunctuation(writer, 54 /* ColonToken */); } writeSpace(writer); var returnType; if (signature.typePredicate) { writer.writeParameter(signature.typePredicate.parameterName); writeSpace(writer); - writeKeyword(writer, 122 /* IsKeyword */); + writeKeyword(writer, 124 /* IsKeyword */); writeSpace(writer); returnType = signature.typePredicate.type; } @@ -14711,13 +15059,13 @@ var ts; function isDeclarationVisible(node) { function getContainingExternalModule(node) { for (; node; node = node.parent) { - if (node.kind === 216 /* ModuleDeclaration */) { + if (node.kind === 218 /* ModuleDeclaration */) { if (node.name.kind === 9 /* StringLiteral */) { return node; } } - else if (node.kind === 246 /* SourceFile */) { - return ts.isExternalModule(node) ? node : undefined; + else if (node.kind === 248 /* SourceFile */) { + return ts.isExternalOrCommonJsModule(node) ? node : undefined; } } ts.Debug.fail("getContainingModule cant reach here"); @@ -14765,70 +15113,70 @@ var ts; } function determineIfDeclarationIsVisible() { switch (node.kind) { - case 161 /* BindingElement */: + case 163 /* BindingElement */: return isDeclarationVisible(node.parent.parent); - case 209 /* VariableDeclaration */: + case 211 /* VariableDeclaration */: if (ts.isBindingPattern(node.name) && !node.name.elements.length) { // If the binding pattern is empty, this variable declaration is not visible return false; } // Otherwise fall through - case 216 /* ModuleDeclaration */: - case 212 /* ClassDeclaration */: - case 213 /* InterfaceDeclaration */: - case 214 /* TypeAliasDeclaration */: - case 211 /* FunctionDeclaration */: - case 215 /* EnumDeclaration */: - case 219 /* ImportEqualsDeclaration */: + case 218 /* ModuleDeclaration */: + case 214 /* ClassDeclaration */: + case 215 /* InterfaceDeclaration */: + case 216 /* TypeAliasDeclaration */: + case 213 /* FunctionDeclaration */: + case 217 /* EnumDeclaration */: + case 221 /* ImportEqualsDeclaration */: var parent_4 = getDeclarationContainer(node); // If the node is not exported or it is not ambient module element (except import declaration) if (!(ts.getCombinedNodeFlags(node) & 1 /* Export */) && - !(node.kind !== 219 /* ImportEqualsDeclaration */ && parent_4.kind !== 246 /* SourceFile */ && ts.isInAmbientContext(parent_4))) { + !(node.kind !== 221 /* ImportEqualsDeclaration */ && parent_4.kind !== 248 /* SourceFile */ && ts.isInAmbientContext(parent_4))) { return isGlobalSourceFile(parent_4); } // Exported members/ambient module elements (exception import declaration) are visible if parent is visible return isDeclarationVisible(parent_4); - case 139 /* PropertyDeclaration */: - case 138 /* PropertySignature */: - case 143 /* GetAccessor */: - case 144 /* SetAccessor */: - case 141 /* MethodDeclaration */: - case 140 /* MethodSignature */: + case 141 /* PropertyDeclaration */: + case 140 /* PropertySignature */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: if (node.flags & (32 /* Private */ | 64 /* Protected */)) { // Private/protected properties/methods are not visible return false; } // Public properties/methods are visible if its parents are visible, so let it fall into next case statement - case 142 /* Constructor */: - case 146 /* ConstructSignature */: - case 145 /* CallSignature */: - case 147 /* IndexSignature */: - case 136 /* Parameter */: - case 217 /* ModuleBlock */: - case 150 /* FunctionType */: - case 151 /* ConstructorType */: - case 153 /* TypeLiteral */: - case 149 /* TypeReference */: - case 154 /* ArrayType */: - case 155 /* TupleType */: - case 156 /* UnionType */: - case 157 /* IntersectionType */: - case 158 /* ParenthesizedType */: + case 144 /* Constructor */: + case 148 /* ConstructSignature */: + case 147 /* CallSignature */: + case 149 /* IndexSignature */: + case 138 /* Parameter */: + case 219 /* ModuleBlock */: + case 152 /* FunctionType */: + case 153 /* ConstructorType */: + case 155 /* TypeLiteral */: + case 151 /* TypeReference */: + case 156 /* ArrayType */: + case 157 /* TupleType */: + case 158 /* UnionType */: + case 159 /* IntersectionType */: + case 160 /* ParenthesizedType */: return isDeclarationVisible(node.parent); // Default binding, import specifier and namespace import is visible // only on demand so by default it is not visible - case 221 /* ImportClause */: - case 222 /* NamespaceImport */: - case 224 /* ImportSpecifier */: + case 223 /* ImportClause */: + case 224 /* NamespaceImport */: + case 226 /* ImportSpecifier */: return false; // Type parameters are always visible - case 135 /* TypeParameter */: + case 137 /* TypeParameter */: // Source file is always visible - case 246 /* SourceFile */: + case 248 /* SourceFile */: return true; - // Export assignements do not create name bindings outside the module - case 225 /* ExportAssignment */: + // Export assignments do not create name bindings outside the module + case 227 /* ExportAssignment */: return false; default: ts.Debug.fail("isDeclarationVisible unknown: SyntaxKind: " + node.kind); @@ -14844,10 +15192,10 @@ var ts; } function collectLinkedAliases(node) { var exportSymbol; - if (node.parent && node.parent.kind === 225 /* ExportAssignment */) { + if (node.parent && node.parent.kind === 227 /* ExportAssignment */) { exportSymbol = resolveName(node.parent, node.text, 107455 /* Value */ | 793056 /* Type */ | 1536 /* Namespace */ | 8388608 /* Alias */, ts.Diagnostics.Cannot_find_name_0, node); } - else if (node.parent.kind === 228 /* ExportSpecifier */) { + else if (node.parent.kind === 230 /* ExportSpecifier */) { var exportSpecifier = node.parent; exportSymbol = exportSpecifier.parent.parent.moduleSpecifier ? getExternalModuleMember(exportSpecifier.parent.parent, exportSpecifier) : @@ -14939,7 +15287,7 @@ var ts; node = ts.getRootDeclaration(node); // Parent chain: // VaribleDeclaration -> VariableDeclarationList -> VariableStatement -> 'Declaration Container' - return node.kind === 209 /* VariableDeclaration */ ? node.parent.parent.parent : node.parent; + return node.kind === 211 /* VariableDeclaration */ ? node.parent.parent.parent : node.parent; } function getTypeOfPrototypeProperty(prototype) { // TypeScript 1.0 spec (April 2014): 8.4 @@ -14957,10 +15305,16 @@ var ts; function isTypeAny(type) { return type && (type.flags & 1 /* Any */) !== 0; } + // Return the type of a binding element parent. We check SymbolLinks first to see if a type has been + // assigned by contextual typing. + function getTypeForBindingElementParent(node) { + var symbol = getSymbolOfNode(node); + return symbol && getSymbolLinks(symbol).type || getTypeForVariableLikeDeclaration(node); + } // Return the inferred type for a binding element function getTypeForBindingElement(declaration) { var pattern = declaration.parent; - var parentType = getTypeForVariableLikeDeclaration(pattern.parent); + var parentType = getTypeForBindingElementParent(pattern.parent); // If parent has the unknown (error) type, then so does this binding element if (parentType === unknownType) { return unknownType; @@ -14975,7 +15329,7 @@ var ts; return parentType; } var type; - if (pattern.kind === 159 /* ObjectBindingPattern */) { + if (pattern.kind === 161 /* ObjectBindingPattern */) { // Use explicitly specified property name ({ p: xxx } form), or otherwise the implied name ({ p } form) var name_10 = declaration.propertyName || declaration.name; // Use type of the specified property, or otherwise, for a numeric name, the type of the numeric index signature, @@ -15019,10 +15373,10 @@ var ts; // Return the inferred type for a variable, parameter, or property declaration function getTypeForVariableLikeDeclaration(declaration) { // A variable declared in a for..in statement is always of type any - if (declaration.parent.parent.kind === 198 /* ForInStatement */) { + if (declaration.parent.parent.kind === 200 /* ForInStatement */) { return anyType; } - if (declaration.parent.parent.kind === 199 /* ForOfStatement */) { + if (declaration.parent.parent.kind === 201 /* ForOfStatement */) { // checkRightHandSideOfForOf will return undefined if the for-of expression type was // missing properties/signatures required to get its iteratedType (like // [Symbol.iterator] or next). This may be because we accessed properties from anyType, @@ -15036,11 +15390,11 @@ var ts; if (declaration.type) { return getTypeFromTypeNode(declaration.type); } - if (declaration.kind === 136 /* Parameter */) { + if (declaration.kind === 138 /* Parameter */) { var func = declaration.parent; // For a parameter of a set accessor, use the type of the get accessor if one is present - if (func.kind === 144 /* SetAccessor */ && !ts.hasDynamicName(func)) { - var getter = ts.getDeclarationOfKind(declaration.parent.symbol, 143 /* GetAccessor */); + if (func.kind === 146 /* SetAccessor */ && !ts.hasDynamicName(func)) { + var getter = ts.getDeclarationOfKind(declaration.parent.symbol, 145 /* GetAccessor */); if (getter) { return getReturnTypeOfSignature(getSignatureFromDeclaration(getter)); } @@ -15056,7 +15410,7 @@ var ts; return checkExpressionCached(declaration.initializer); } // If it is a short-hand property assignment, use the type of the identifier - if (declaration.kind === 244 /* ShorthandPropertyAssignment */) { + if (declaration.kind === 246 /* ShorthandPropertyAssignment */) { return checkIdentifier(declaration.name); } // If the declaration specifies a binding pattern, use the type implied by the binding pattern @@ -15102,7 +15456,7 @@ var ts; return languageVersion >= 2 /* ES6 */ ? createIterableType(anyType) : anyArrayType; } // If the pattern has at least one element, and no rest element, then it should imply a tuple type. - var elementTypes = ts.map(elements, function (e) { return e.kind === 185 /* OmittedExpression */ ? anyType : getTypeFromBindingElement(e, includePatternInType); }); + var elementTypes = ts.map(elements, function (e) { return e.kind === 187 /* OmittedExpression */ ? anyType : getTypeFromBindingElement(e, includePatternInType); }); if (includePatternInType) { var result = createNewTupleType(elementTypes); result.pattern = pattern; @@ -15118,7 +15472,7 @@ var ts; // parameter with no type annotation or initializer, the type implied by the binding pattern becomes the type of // the parameter. function getTypeFromBindingPattern(pattern, includePatternInType) { - return pattern.kind === 159 /* ObjectBindingPattern */ + return pattern.kind === 161 /* ObjectBindingPattern */ ? getTypeFromObjectBindingPattern(pattern, includePatternInType) : getTypeFromArrayBindingPattern(pattern, includePatternInType); } @@ -15140,14 +15494,14 @@ var ts; // During a normal type check we'll never get to here with a property assignment (the check of the containing // object literal uses a different path). We exclude widening only so that language services and type verification // tools see the actual type. - return declaration.kind !== 243 /* PropertyAssignment */ ? getWidenedType(type) : type; + return declaration.kind !== 245 /* PropertyAssignment */ ? getWidenedType(type) : type; } // Rest parameters default to type any[], other parameters default to type any type = declaration.dotDotDotToken ? anyArrayType : anyType; // Report implicit any errors unless this is a private property within an ambient declaration if (reportErrors && compilerOptions.noImplicitAny) { var root = ts.getRootDeclaration(declaration); - if (!isPrivateWithinAmbient(root) && !(root.kind === 136 /* Parameter */ && isPrivateWithinAmbient(root.parent))) { + if (!isPrivateWithinAmbient(root) && !(root.kind === 138 /* Parameter */ && isPrivateWithinAmbient(root.parent))) { reportImplicitAnyError(declaration, type); } } @@ -15162,13 +15516,21 @@ var ts; } // Handle catch clause variables var declaration = symbol.valueDeclaration; - if (declaration.parent.kind === 242 /* CatchClause */) { + if (declaration.parent.kind === 244 /* CatchClause */) { return links.type = anyType; } // Handle export default expressions - if (declaration.kind === 225 /* ExportAssignment */) { + if (declaration.kind === 227 /* ExportAssignment */) { return links.type = checkExpression(declaration.expression); } + // Handle module.exports = expr + if (declaration.kind === 181 /* BinaryExpression */) { + return links.type = checkExpression(declaration.right); + } + // Handle exports.p = expr + if (declaration.kind === 166 /* PropertyAccessExpression */) { + return checkExpressionCached(declaration.parent.right); + } // Handle variable, parameter or property if (!pushTypeResolution(symbol, 0 /* Type */)) { return unknownType; @@ -15194,7 +15556,7 @@ var ts; } function getAnnotatedAccessorType(accessor) { if (accessor) { - if (accessor.kind === 143 /* GetAccessor */) { + if (accessor.kind === 145 /* GetAccessor */) { return accessor.type && getTypeFromTypeNode(accessor.type); } else { @@ -15210,8 +15572,8 @@ var ts; if (!pushTypeResolution(symbol, 0 /* Type */)) { return unknownType; } - var getter = ts.getDeclarationOfKind(symbol, 143 /* GetAccessor */); - var setter = ts.getDeclarationOfKind(symbol, 144 /* SetAccessor */); + var getter = ts.getDeclarationOfKind(symbol, 145 /* GetAccessor */); + var setter = ts.getDeclarationOfKind(symbol, 146 /* SetAccessor */); var type; // First try to see if the user specified a return type on the get-accessor. var getterReturnType = getAnnotatedAccessorType(getter); @@ -15240,7 +15602,7 @@ var ts; if (!popTypeResolution()) { type = anyType; if (compilerOptions.noImplicitAny) { - var getter_1 = ts.getDeclarationOfKind(symbol, 143 /* GetAccessor */); + var getter_1 = ts.getDeclarationOfKind(symbol, 145 /* GetAccessor */); error(getter_1, ts.Diagnostics._0_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions, symbolToString(symbol)); } } @@ -15340,9 +15702,9 @@ var ts; if (!node) { return typeParameters; } - if (node.kind === 212 /* ClassDeclaration */ || node.kind === 184 /* ClassExpression */ || - node.kind === 211 /* FunctionDeclaration */ || node.kind === 171 /* FunctionExpression */ || - node.kind === 141 /* MethodDeclaration */ || node.kind === 172 /* ArrowFunction */) { + if (node.kind === 214 /* ClassDeclaration */ || node.kind === 186 /* ClassExpression */ || + node.kind === 213 /* FunctionDeclaration */ || node.kind === 173 /* FunctionExpression */ || + node.kind === 143 /* MethodDeclaration */ || node.kind === 174 /* ArrowFunction */) { var declarations = node.typeParameters; if (declarations) { return appendTypeParameters(appendOuterTypeParameters(typeParameters, node), declarations); @@ -15352,7 +15714,7 @@ var ts; } // The outer type parameters are those defined by enclosing generic classes, methods, or functions. function getOuterTypeParametersOfClassOrInterface(symbol) { - var declaration = symbol.flags & 32 /* Class */ ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 213 /* InterfaceDeclaration */); + var declaration = symbol.flags & 32 /* Class */ ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 215 /* InterfaceDeclaration */); return appendOuterTypeParameters(undefined, declaration); } // The local type parameters are the combined set of type parameters from all declarations of the class, @@ -15361,8 +15723,8 @@ var ts; var result; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var node = _a[_i]; - if (node.kind === 213 /* InterfaceDeclaration */ || node.kind === 212 /* ClassDeclaration */ || - node.kind === 184 /* ClassExpression */ || node.kind === 214 /* TypeAliasDeclaration */) { + if (node.kind === 215 /* InterfaceDeclaration */ || node.kind === 214 /* ClassDeclaration */ || + node.kind === 186 /* ClassExpression */ || node.kind === 216 /* TypeAliasDeclaration */) { var declaration = node; if (declaration.typeParameters) { result = appendTypeParameters(result, declaration.typeParameters); @@ -15482,7 +15844,7 @@ var ts; type.resolvedBaseTypes = []; for (var _i = 0, _a = type.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 213 /* InterfaceDeclaration */ && ts.getInterfaceBaseTypeNodes(declaration)) { + if (declaration.kind === 215 /* InterfaceDeclaration */ && ts.getInterfaceBaseTypeNodes(declaration)) { for (var _b = 0, _c = ts.getInterfaceBaseTypeNodes(declaration); _b < _c.length; _b++) { var node = _c[_b]; var baseType = getTypeFromTypeNode(node); @@ -15503,6 +15865,32 @@ var ts; } } } + // Returns true if the interface given by the symbol is free of "this" references. Specifically, the result is + // true if the interface itself contains no references to "this" in its body, if all base types are interfaces, + // and if none of the base interfaces have a "this" type. + function isIndependentInterface(symbol) { + for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { + var declaration = _a[_i]; + if (declaration.kind === 215 /* InterfaceDeclaration */) { + if (declaration.flags & 524288 /* ContainsThis */) { + return false; + } + var baseTypeNodes = ts.getInterfaceBaseTypeNodes(declaration); + if (baseTypeNodes) { + for (var _b = 0; _b < baseTypeNodes.length; _b++) { + var node = baseTypeNodes[_b]; + if (ts.isSupportedExpressionWithTypeArguments(node)) { + var baseSymbol = resolveEntityName(node.expression, 793056 /* Type */, /*ignoreErrors*/ true); + if (!baseSymbol || !(baseSymbol.flags & 64 /* Interface */) || getDeclaredTypeOfClassOrInterface(baseSymbol).thisType) { + return false; + } + } + } + } + } + } + return true; + } function getDeclaredTypeOfClassOrInterface(symbol) { var links = getSymbolLinks(symbol); if (!links.declaredType) { @@ -15510,7 +15898,12 @@ var ts; var type = links.declaredType = createObjectType(kind, symbol); var outerTypeParameters = getOuterTypeParametersOfClassOrInterface(symbol); var localTypeParameters = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol); - if (outerTypeParameters || localTypeParameters) { + // A class or interface is generic if it has type parameters or a "this" type. We always give classes a "this" type + // because it is not feasible to analyze all members to determine if the "this" type escapes the class (in particular, + // property types inferred from initializers and method return types inferred from return statements are very hard + // to exhaustively analyze). We give interfaces a "this" type if we can't definitely determine that they are free of + // "this" references. + if (outerTypeParameters || localTypeParameters || kind === 1024 /* Class */ || !isIndependentInterface(symbol)) { type.flags |= 4096 /* Reference */; type.typeParameters = ts.concatenate(outerTypeParameters, localTypeParameters); type.outerTypeParameters = outerTypeParameters; @@ -15519,6 +15912,9 @@ var ts; type.instantiations[getTypeListId(type.typeParameters)] = type; type.target = type; type.typeArguments = type.typeParameters; + type.thisType = createType(512 /* TypeParameter */ | 33554432 /* ThisType */); + type.thisType.symbol = symbol; + type.thisType.constraint = getTypeWithThisArgument(type); } } return links.declaredType; @@ -15531,7 +15927,7 @@ var ts; if (!pushTypeResolution(symbol, 2 /* DeclaredType */)) { return unknownType; } - var declaration = ts.getDeclarationOfKind(symbol, 214 /* TypeAliasDeclaration */); + var declaration = ts.getDeclarationOfKind(symbol, 216 /* TypeAliasDeclaration */); var type = getTypeFromTypeNode(declaration.type); if (popTypeResolution()) { links.typeParameters = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol); @@ -15564,7 +15960,7 @@ var ts; if (!links.declaredType) { var type = createType(512 /* TypeParameter */); type.symbol = symbol; - if (!ts.getDeclarationOfKind(symbol, 135 /* TypeParameter */).constraint) { + if (!ts.getDeclarationOfKind(symbol, 137 /* TypeParameter */).constraint) { type.constraint = noConstraintType; } links.declaredType = type; @@ -15597,6 +15993,79 @@ var ts; } return unknownType; } + // A type reference is considered independent if each type argument is considered independent. + function isIndependentTypeReference(node) { + if (node.typeArguments) { + for (var _i = 0, _a = node.typeArguments; _i < _a.length; _i++) { + var typeNode = _a[_i]; + if (!isIndependentType(typeNode)) { + return false; + } + } + } + return true; + } + // A type is considered independent if it the any, string, number, boolean, symbol, or void keyword, a string + // literal type, an array with an element type that is considered independent, or a type reference that is + // considered independent. + function isIndependentType(node) { + switch (node.kind) { + case 117 /* AnyKeyword */: + case 130 /* StringKeyword */: + case 128 /* NumberKeyword */: + case 120 /* BooleanKeyword */: + case 131 /* SymbolKeyword */: + case 103 /* VoidKeyword */: + case 9 /* StringLiteral */: + return true; + case 156 /* ArrayType */: + return isIndependentType(node.elementType); + case 151 /* TypeReference */: + return isIndependentTypeReference(node); + } + return false; + } + // A variable-like declaration is considered independent (free of this references) if it has a type annotation + // that specifies an independent type, or if it has no type annotation and no initializer (and thus of type any). + function isIndependentVariableLikeDeclaration(node) { + return node.type && isIndependentType(node.type) || !node.type && !node.initializer; + } + // A function-like declaration is considered independent (free of this references) if it has a return type + // annotation that is considered independent and if each parameter is considered independent. + function isIndependentFunctionLikeDeclaration(node) { + if (node.kind !== 144 /* Constructor */ && (!node.type || !isIndependentType(node.type))) { + return false; + } + for (var _i = 0, _a = node.parameters; _i < _a.length; _i++) { + var parameter = _a[_i]; + if (!isIndependentVariableLikeDeclaration(parameter)) { + return false; + } + } + return true; + } + // Returns true if the class or interface member given by the symbol is free of "this" references. The + // function may return false for symbols that are actually free of "this" references because it is not + // feasible to perform a complete analysis in all cases. In particular, property members with types + // inferred from their initializers and function members with inferred return types are convervatively + // assumed not to be free of "this" references. + function isIndependentMember(symbol) { + if (symbol.declarations && symbol.declarations.length === 1) { + var declaration = symbol.declarations[0]; + if (declaration) { + switch (declaration.kind) { + case 141 /* PropertyDeclaration */: + case 140 /* PropertySignature */: + return isIndependentVariableLikeDeclaration(declaration); + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: + case 144 /* Constructor */: + return isIndependentFunctionLikeDeclaration(declaration); + } + } + } + return false; + } function createSymbolTable(symbols) { var result = {}; for (var _i = 0; _i < symbols.length; _i++) { @@ -15605,11 +16074,13 @@ var ts; } return result; } - function createInstantiatedSymbolTable(symbols, mapper) { + // The mappingThisOnly flag indicates that the only type parameter being mapped is "this". When the flag is true, + // we check symbols to see if we can quickly conclude they are free of "this" references, thus needing no instantiation. + function createInstantiatedSymbolTable(symbols, mapper, mappingThisOnly) { var result = {}; for (var _i = 0; _i < symbols.length; _i++) { var symbol = symbols[_i]; - result[symbol.name] = instantiateSymbol(symbol, mapper); + result[symbol.name] = mappingThisOnly && isIndependentMember(symbol) ? symbol : instantiateSymbol(symbol, mapper); } return result; } @@ -15640,44 +16111,54 @@ var ts; } return type; } - function resolveClassOrInterfaceMembers(type) { - var target = resolveDeclaredMembers(type); - var members = target.symbol.members; - var callSignatures = target.declaredCallSignatures; - var constructSignatures = target.declaredConstructSignatures; - var stringIndexType = target.declaredStringIndexType; - var numberIndexType = target.declaredNumberIndexType; - var baseTypes = getBaseTypes(target); + function getTypeWithThisArgument(type, thisArgument) { + if (type.flags & 4096 /* Reference */) { + return createTypeReference(type.target, ts.concatenate(type.typeArguments, [thisArgument || type.target.thisType])); + } + return type; + } + function resolveObjectTypeMembers(type, source, typeParameters, typeArguments) { + var mapper = identityMapper; + var members = source.symbol.members; + var callSignatures = source.declaredCallSignatures; + var constructSignatures = source.declaredConstructSignatures; + var stringIndexType = source.declaredStringIndexType; + var numberIndexType = source.declaredNumberIndexType; + if (!ts.rangeEquals(typeParameters, typeArguments, 0, typeParameters.length)) { + mapper = createTypeMapper(typeParameters, typeArguments); + members = createInstantiatedSymbolTable(source.declaredProperties, mapper, /*mappingThisOnly*/ typeParameters.length === 1); + callSignatures = instantiateList(source.declaredCallSignatures, mapper, instantiateSignature); + constructSignatures = instantiateList(source.declaredConstructSignatures, mapper, instantiateSignature); + stringIndexType = instantiateType(source.declaredStringIndexType, mapper); + numberIndexType = instantiateType(source.declaredNumberIndexType, mapper); + } + var baseTypes = getBaseTypes(source); if (baseTypes.length) { - members = createSymbolTable(target.declaredProperties); + if (members === source.symbol.members) { + members = createSymbolTable(source.declaredProperties); + } + var thisArgument = ts.lastOrUndefined(typeArguments); for (var _i = 0; _i < baseTypes.length; _i++) { var baseType = baseTypes[_i]; - addInheritedMembers(members, getPropertiesOfObjectType(baseType)); - callSignatures = ts.concatenate(callSignatures, getSignaturesOfType(baseType, 0 /* Call */)); - constructSignatures = ts.concatenate(constructSignatures, getSignaturesOfType(baseType, 1 /* Construct */)); - stringIndexType = stringIndexType || getIndexTypeOfType(baseType, 0 /* String */); - numberIndexType = numberIndexType || getIndexTypeOfType(baseType, 1 /* Number */); + var instantiatedBaseType = thisArgument ? getTypeWithThisArgument(instantiateType(baseType, mapper), thisArgument) : baseType; + addInheritedMembers(members, getPropertiesOfObjectType(instantiatedBaseType)); + callSignatures = ts.concatenate(callSignatures, getSignaturesOfType(instantiatedBaseType, 0 /* Call */)); + constructSignatures = ts.concatenate(constructSignatures, getSignaturesOfType(instantiatedBaseType, 1 /* Construct */)); + stringIndexType = stringIndexType || getIndexTypeOfType(instantiatedBaseType, 0 /* String */); + numberIndexType = numberIndexType || getIndexTypeOfType(instantiatedBaseType, 1 /* Number */); } } setObjectTypeMembers(type, members, callSignatures, constructSignatures, stringIndexType, numberIndexType); } + function resolveClassOrInterfaceMembers(type) { + resolveObjectTypeMembers(type, resolveDeclaredMembers(type), emptyArray, emptyArray); + } function resolveTypeReferenceMembers(type) { - var target = resolveDeclaredMembers(type.target); - var mapper = createTypeMapper(target.typeParameters, type.typeArguments); - var members = createInstantiatedSymbolTable(target.declaredProperties, mapper); - var callSignatures = instantiateList(target.declaredCallSignatures, mapper, instantiateSignature); - var constructSignatures = instantiateList(target.declaredConstructSignatures, mapper, instantiateSignature); - var stringIndexType = target.declaredStringIndexType ? instantiateType(target.declaredStringIndexType, mapper) : undefined; - var numberIndexType = target.declaredNumberIndexType ? instantiateType(target.declaredNumberIndexType, mapper) : undefined; - ts.forEach(getBaseTypes(target), function (baseType) { - var instantiatedBaseType = instantiateType(baseType, mapper); - addInheritedMembers(members, getPropertiesOfObjectType(instantiatedBaseType)); - callSignatures = ts.concatenate(callSignatures, getSignaturesOfType(instantiatedBaseType, 0 /* Call */)); - constructSignatures = ts.concatenate(constructSignatures, getSignaturesOfType(instantiatedBaseType, 1 /* Construct */)); - stringIndexType = stringIndexType || getIndexTypeOfType(instantiatedBaseType, 0 /* String */); - numberIndexType = numberIndexType || getIndexTypeOfType(instantiatedBaseType, 1 /* Number */); - }); - setObjectTypeMembers(type, members, callSignatures, constructSignatures, stringIndexType, numberIndexType); + var source = resolveDeclaredMembers(type.target); + var typeParameters = ts.concatenate(source.typeParameters, [source.thisType]); + var typeArguments = type.typeArguments && type.typeArguments.length === typeParameters.length ? + type.typeArguments : ts.concatenate(type.typeArguments, [type]); + resolveObjectTypeMembers(type, source, typeParameters, typeArguments); } function createSignature(declaration, typeParameters, parameters, resolvedReturnType, typePredicate, minArgumentCount, hasRestParameter, hasStringLiterals) { var sig = new Signature(checker); @@ -15726,7 +16207,9 @@ var ts; return members; } function resolveTupleTypeMembers(type) { - var arrayType = resolveStructuredTypeMembers(createArrayType(getUnionType(type.elementTypes, /*noSubtypeReduction*/ true))); + var arrayElementType = getUnionType(type.elementTypes, /*noSubtypeReduction*/ true); + // Make the tuple type itself the 'this' type by including an extra type argument + var arrayType = resolveStructuredTypeMembers(createTypeFromGenericGlobalType(globalArrayType, [arrayElementType, type])); var members = createTupleTypeMemberSymbols(type.elementTypes); addInheritedMembers(members, arrayType.properties); setObjectTypeMembers(type, members, arrayType.callSignatures, arrayType.constructSignatures, arrayType.stringIndexType, arrayType.numberIndexType); @@ -15842,7 +16325,14 @@ var ts; var constructSignatures; var stringIndexType; var numberIndexType; - if (symbol.flags & 2048 /* TypeLiteral */) { + if (type.target) { + members = createInstantiatedSymbolTable(getPropertiesOfObjectType(type.target), type.mapper, /*mappingThisOnly*/ false); + callSignatures = instantiateList(getSignaturesOfType(type.target, 0 /* Call */), type.mapper, instantiateSignature); + constructSignatures = instantiateList(getSignaturesOfType(type.target, 1 /* Construct */), type.mapper, instantiateSignature); + stringIndexType = instantiateType(getIndexTypeOfType(type.target, 0 /* String */), type.mapper); + numberIndexType = instantiateType(getIndexTypeOfType(type.target, 1 /* Number */), type.mapper); + } + else if (symbol.flags & 2048 /* TypeLiteral */) { members = symbol.members; callSignatures = getSignaturesOfSymbol(members["__call"]); constructSignatures = getSignaturesOfSymbol(members["__new"]); @@ -15879,7 +16369,10 @@ var ts; } function resolveStructuredTypeMembers(type) { if (!type.members) { - if (type.flags & (1024 /* Class */ | 2048 /* Interface */)) { + if (type.flags & 4096 /* Reference */) { + resolveTypeReferenceMembers(type); + } + else if (type.flags & (1024 /* Class */ | 2048 /* Interface */)) { resolveClassOrInterfaceMembers(type); } else if (type.flags & 65536 /* Anonymous */) { @@ -15894,9 +16387,6 @@ var ts; else if (type.flags & 32768 /* Intersection */) { resolveIntersectionTypeMembers(type); } - else { - resolveTypeReferenceMembers(type); - } } return type; } @@ -16125,7 +16615,7 @@ var ts; function getSignatureFromDeclaration(declaration) { var links = getNodeLinks(declaration); if (!links.resolvedSignature) { - var classType = declaration.kind === 142 /* Constructor */ ? getDeclaredTypeOfClassOrInterface(declaration.parent.symbol) : undefined; + var classType = declaration.kind === 144 /* Constructor */ ? getDeclaredTypeOfClassOrInterface(declaration.parent.symbol) : undefined; var typeParameters = classType ? classType.localTypeParameters : declaration.typeParameters ? getTypeParametersFromDeclaration(declaration.typeParameters) : undefined; var parameters = []; @@ -16157,7 +16647,7 @@ var ts; } else if (declaration.type) { returnType = getTypeFromTypeNode(declaration.type); - if (declaration.type.kind === 148 /* TypePredicate */) { + if (declaration.type.kind === 150 /* TypePredicate */) { var typePredicateNode = declaration.type; typePredicate = { parameterName: typePredicateNode.parameterName ? typePredicateNode.parameterName.text : undefined, @@ -16169,8 +16659,8 @@ var ts; else { // TypeScript 1.0 spec (April 2014): // If only one accessor includes a type annotation, the other behaves as if it had the same type annotation. - if (declaration.kind === 143 /* GetAccessor */ && !ts.hasDynamicName(declaration)) { - var setter = ts.getDeclarationOfKind(declaration.symbol, 144 /* SetAccessor */); + if (declaration.kind === 145 /* GetAccessor */ && !ts.hasDynamicName(declaration)) { + var setter = ts.getDeclarationOfKind(declaration.symbol, 146 /* SetAccessor */); returnType = getAnnotatedAccessorType(setter); } if (!returnType && ts.nodeIsMissing(declaration.body)) { @@ -16188,19 +16678,19 @@ var ts; for (var i = 0, len = symbol.declarations.length; i < len; i++) { var node = symbol.declarations[i]; switch (node.kind) { - case 150 /* FunctionType */: - case 151 /* ConstructorType */: - case 211 /* FunctionDeclaration */: - case 141 /* MethodDeclaration */: - case 140 /* MethodSignature */: - case 142 /* Constructor */: - case 145 /* CallSignature */: - case 146 /* ConstructSignature */: - case 147 /* IndexSignature */: - case 143 /* GetAccessor */: - case 144 /* SetAccessor */: - case 171 /* FunctionExpression */: - case 172 /* ArrowFunction */: + case 152 /* FunctionType */: + case 153 /* ConstructorType */: + case 213 /* FunctionDeclaration */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: + case 144 /* Constructor */: + case 147 /* CallSignature */: + case 148 /* ConstructSignature */: + case 149 /* IndexSignature */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: + case 173 /* FunctionExpression */: + case 174 /* ArrowFunction */: // Don't include signature if node is the implementation of an overloaded function. A node is considered // an implementation node if it has a body and the previous node is of the same kind and immediately // precedes the implementation node (i.e. has the same parent and ends where the implementation starts). @@ -16215,6 +16705,16 @@ var ts; } return result; } + function resolveExternalModuleTypeByLiteral(name) { + var moduleSym = resolveExternalModuleName(name, name); + if (moduleSym) { + var resolvedModuleSymbol = resolveExternalModuleSymbol(moduleSym); + if (resolvedModuleSymbol) { + return getTypeOfSymbol(resolvedModuleSymbol); + } + } + return anyType; + } function getReturnTypeOfSignature(signature) { if (!signature.resolvedReturnType) { if (!pushTypeResolution(signature, 3 /* ResolvedReturnType */)) { @@ -16277,7 +16777,7 @@ var ts; // object type literal or interface (using the new keyword). Each way of declaring a constructor // will result in a different declaration kind. if (!signature.isolatedSignatureType) { - var isConstructor = signature.declaration.kind === 142 /* Constructor */ || signature.declaration.kind === 146 /* ConstructSignature */; + var isConstructor = signature.declaration.kind === 144 /* Constructor */ || signature.declaration.kind === 148 /* ConstructSignature */; var type = createObjectType(65536 /* Anonymous */ | 262144 /* FromSignature */); type.members = emptySymbols; type.properties = emptyArray; @@ -16291,7 +16791,7 @@ var ts; return symbol.members["__index"]; } function getIndexDeclarationOfSymbol(symbol, kind) { - var syntaxKind = kind === 1 /* Number */ ? 126 /* NumberKeyword */ : 128 /* StringKeyword */; + var syntaxKind = kind === 1 /* Number */ ? 128 /* NumberKeyword */ : 130 /* StringKeyword */; var indexSymbol = getIndexSymbol(symbol); if (indexSymbol) { for (var _i = 0, _a = indexSymbol.declarations; _i < _a.length; _i++) { @@ -16320,30 +16820,33 @@ var ts; type.constraint = targetConstraint ? instantiateType(targetConstraint, type.mapper) : noConstraintType; } else { - type.constraint = getTypeFromTypeNode(ts.getDeclarationOfKind(type.symbol, 135 /* TypeParameter */).constraint); + type.constraint = getTypeFromTypeNode(ts.getDeclarationOfKind(type.symbol, 137 /* TypeParameter */).constraint); } } return type.constraint === noConstraintType ? undefined : type.constraint; } function getParentSymbolOfTypeParameter(typeParameter) { - return getSymbolOfNode(ts.getDeclarationOfKind(typeParameter.symbol, 135 /* TypeParameter */).parent); + return getSymbolOfNode(ts.getDeclarationOfKind(typeParameter.symbol, 137 /* TypeParameter */).parent); } function getTypeListId(types) { - switch (types.length) { - case 1: - return "" + types[0].id; - case 2: - return types[0].id + "," + types[1].id; - default: - var result = ""; - for (var i = 0; i < types.length; i++) { - if (i > 0) { - result += ","; + if (types) { + switch (types.length) { + case 1: + return "" + types[0].id; + case 2: + return types[0].id + "," + types[1].id; + default: + var result = ""; + for (var i = 0; i < types.length; i++) { + if (i > 0) { + result += ","; + } + result += types[i].id; } - result += types[i].id; - } - return result; + return result; + } } + return ""; } // This function is used to propagate certain flags when creating new object type references and union types. // It is only necessary to do so if a constituent type might be the undefined type, the null type, the type @@ -16361,7 +16864,7 @@ var ts; var id = getTypeListId(typeArguments); var type = target.instantiations[id]; if (!type) { - var flags = 4096 /* Reference */ | getPropagatingFlagsOfTypes(typeArguments); + var flags = 4096 /* Reference */ | (typeArguments ? getPropagatingFlagsOfTypes(typeArguments) : 0); type = target.instantiations[id] = createObjectType(flags, target.symbol); type.target = target; type.typeArguments = typeArguments; @@ -16380,13 +16883,13 @@ var ts; currentNode = currentNode.parent; } // if last step was made from the type parameter this means that path has started somewhere in constraint which is illegal - links.isIllegalTypeReferenceInConstraint = currentNode.kind === 135 /* TypeParameter */; + links.isIllegalTypeReferenceInConstraint = currentNode.kind === 137 /* TypeParameter */; return links.isIllegalTypeReferenceInConstraint; } function checkTypeParameterHasIllegalReferencesInConstraint(typeParameter) { var typeParameterSymbol; function check(n) { - if (n.kind === 149 /* TypeReference */ && n.typeName.kind === 67 /* Identifier */) { + if (n.kind === 151 /* TypeReference */ && n.typeName.kind === 69 /* Identifier */) { var links = getNodeLinks(n); if (links.isIllegalTypeReferenceInConstraint === undefined) { var symbol = resolveName(typeParameter, n.typeName.text, 793056 /* Type */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined); @@ -16473,7 +16976,7 @@ var ts; var links = getNodeLinks(node); if (!links.resolvedType) { // We only support expressions that are simple qualified names. For other expressions this produces undefined. - var typeNameOrExpression = node.kind === 149 /* TypeReference */ ? node.typeName : + var typeNameOrExpression = node.kind === 151 /* TypeReference */ ? node.typeName : ts.isSupportedExpressionWithTypeArguments(node) ? node.expression : undefined; var symbol = typeNameOrExpression && resolveEntityName(typeNameOrExpression, 793056 /* Type */) || unknownSymbol; @@ -16505,9 +17008,9 @@ var ts; for (var _i = 0; _i < declarations.length; _i++) { var declaration = declarations[_i]; switch (declaration.kind) { - case 212 /* ClassDeclaration */: - case 213 /* InterfaceDeclaration */: - case 215 /* EnumDeclaration */: + case 214 /* ClassDeclaration */: + case 215 /* InterfaceDeclaration */: + case 217 /* EnumDeclaration */: return declaration; } } @@ -16548,10 +17051,13 @@ var ts; * getExportedTypeFromNamespace('JSX', 'Element') returns the JSX.Element type */ function getExportedTypeFromNamespace(namespace, name) { - var namespaceSymbol = getGlobalSymbol(namespace, 1536 /* Namespace */, /*diagnosticMessage*/ undefined); - var typeSymbol = namespaceSymbol && getSymbol(namespaceSymbol.exports, name, 793056 /* Type */); + var typeSymbol = getExportedSymbolFromNamespace(namespace, name); return typeSymbol && getDeclaredTypeOfSymbol(typeSymbol); } + function getExportedSymbolFromNamespace(namespace, name) { + var namespaceSymbol = getGlobalSymbol(namespace, 1536 /* Namespace */, /*diagnosticMessage*/ undefined); + return namespaceSymbol && getSymbol(namespaceSymbol.exports, name, 793056 /* Type */ | 107455 /* Value */); + } function getGlobalESSymbolConstructorSymbol() { return globalESSymbolConstructorSymbol || (globalESSymbolConstructorSymbol = getGlobalValueSymbol("Symbol")); } @@ -16567,17 +17073,17 @@ var ts; /** * Instantiates a global type that is generic with some element type, and returns that instantiation. */ - function createTypeFromGenericGlobalType(genericGlobalType, elementType) { - return genericGlobalType !== emptyGenericType ? createTypeReference(genericGlobalType, [elementType]) : emptyObjectType; + function createTypeFromGenericGlobalType(genericGlobalType, typeArguments) { + return genericGlobalType !== emptyGenericType ? createTypeReference(genericGlobalType, typeArguments) : emptyObjectType; } function createIterableType(elementType) { - return createTypeFromGenericGlobalType(globalIterableType, elementType); + return createTypeFromGenericGlobalType(globalIterableType, [elementType]); } function createIterableIteratorType(elementType) { - return createTypeFromGenericGlobalType(globalIterableIteratorType, elementType); + return createTypeFromGenericGlobalType(globalIterableIteratorType, [elementType]); } function createArrayType(elementType) { - return createTypeFromGenericGlobalType(globalArrayType, elementType); + return createTypeFromGenericGlobalType(globalArrayType, [elementType]); } function getTypeFromArrayTypeNode(node) { var links = getNodeLinks(node); @@ -16749,48 +17255,68 @@ var ts; } return links.resolvedType; } + function getThisType(node) { + var container = ts.getThisContainer(node, /*includeArrowFunctions*/ false); + var parent = container && container.parent; + if (parent && (ts.isClassLike(parent) || parent.kind === 215 /* InterfaceDeclaration */)) { + if (!(container.flags & 128 /* Static */)) { + return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(parent)).thisType; + } + } + error(node, ts.Diagnostics.A_this_type_is_available_only_in_a_non_static_member_of_a_class_or_interface); + return unknownType; + } + function getTypeFromThisTypeNode(node) { + var links = getNodeLinks(node); + if (!links.resolvedType) { + links.resolvedType = getThisType(node); + } + return links.resolvedType; + } function getTypeFromTypeNode(node) { switch (node.kind) { - case 115 /* AnyKeyword */: + case 117 /* AnyKeyword */: return anyType; - case 128 /* StringKeyword */: + case 130 /* StringKeyword */: return stringType; - case 126 /* NumberKeyword */: + case 128 /* NumberKeyword */: return numberType; - case 118 /* BooleanKeyword */: + case 120 /* BooleanKeyword */: return booleanType; - case 129 /* SymbolKeyword */: + case 131 /* SymbolKeyword */: return esSymbolType; - case 101 /* VoidKeyword */: + case 103 /* VoidKeyword */: return voidType; + case 97 /* ThisKeyword */: + return getTypeFromThisTypeNode(node); case 9 /* StringLiteral */: return getTypeFromStringLiteral(node); - case 149 /* TypeReference */: + case 151 /* TypeReference */: return getTypeFromTypeReference(node); - case 148 /* TypePredicate */: + case 150 /* TypePredicate */: return booleanType; - case 186 /* ExpressionWithTypeArguments */: + case 188 /* ExpressionWithTypeArguments */: return getTypeFromTypeReference(node); - case 152 /* TypeQuery */: + case 154 /* TypeQuery */: return getTypeFromTypeQueryNode(node); - case 154 /* ArrayType */: + case 156 /* ArrayType */: return getTypeFromArrayTypeNode(node); - case 155 /* TupleType */: + case 157 /* TupleType */: return getTypeFromTupleTypeNode(node); - case 156 /* UnionType */: + case 158 /* UnionType */: return getTypeFromUnionTypeNode(node); - case 157 /* IntersectionType */: + case 159 /* IntersectionType */: return getTypeFromIntersectionTypeNode(node); - case 158 /* ParenthesizedType */: + case 160 /* ParenthesizedType */: return getTypeFromTypeNode(node.type); - case 150 /* FunctionType */: - case 151 /* ConstructorType */: - case 153 /* TypeLiteral */: + case 152 /* FunctionType */: + case 153 /* ConstructorType */: + case 155 /* TypeLiteral */: return getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node); // This function assumes that an identifier or qualified name is a type expression // Callers should first ensure this by calling isTypeNode - case 67 /* Identifier */: - case 133 /* QualifiedName */: + case 69 /* Identifier */: + case 135 /* QualifiedName */: var symbol = getSymbolAtLocation(node); return symbol && getDeclaredTypeOfSymbol(symbol); default: @@ -16894,7 +17420,7 @@ var ts; type: instantiateType(signature.typePredicate.type, mapper) }; } - var result = createSignature(signature.declaration, freshTypeParameters, instantiateList(signature.parameters, mapper, instantiateSymbol), signature.resolvedReturnType ? instantiateType(signature.resolvedReturnType, mapper) : undefined, freshTypePredicate, signature.minArgumentCount, signature.hasRestParameter, signature.hasStringLiterals); + var result = createSignature(signature.declaration, freshTypeParameters, instantiateList(signature.parameters, mapper, instantiateSymbol), instantiateType(signature.resolvedReturnType, mapper), freshTypePredicate, signature.minArgumentCount, signature.hasRestParameter, signature.hasStringLiterals); result.target = signature; result.mapper = mapper; return result; @@ -16932,21 +17458,13 @@ var ts; } // Mark the anonymous type as instantiated such that our infinite instantiation detection logic can recognize it var result = createObjectType(65536 /* Anonymous */ | 131072 /* Instantiated */, type.symbol); - result.properties = instantiateList(getPropertiesOfObjectType(type), mapper, instantiateSymbol); - result.members = createSymbolTable(result.properties); - result.callSignatures = instantiateList(getSignaturesOfType(type, 0 /* Call */), mapper, instantiateSignature); - result.constructSignatures = instantiateList(getSignaturesOfType(type, 1 /* Construct */), mapper, instantiateSignature); - var stringIndexType = getIndexTypeOfType(type, 0 /* String */); - var numberIndexType = getIndexTypeOfType(type, 1 /* Number */); - if (stringIndexType) - result.stringIndexType = instantiateType(stringIndexType, mapper); - if (numberIndexType) - result.numberIndexType = instantiateType(numberIndexType, mapper); + result.target = type; + result.mapper = mapper; mapper.instantiations[type.id] = result; return result; } function instantiateType(type, mapper) { - if (mapper !== identityMapper) { + if (type && mapper !== identityMapper) { if (type.flags & 512 /* TypeParameter */) { return mapper(type); } @@ -16972,27 +17490,27 @@ var ts; // Returns true if the given expression contains (at any level of nesting) a function or arrow expression // that is subject to contextual typing. function isContextSensitive(node) { - ts.Debug.assert(node.kind !== 141 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 143 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); switch (node.kind) { - case 171 /* FunctionExpression */: - case 172 /* ArrowFunction */: + case 173 /* FunctionExpression */: + case 174 /* ArrowFunction */: return isContextSensitiveFunctionLikeDeclaration(node); - case 163 /* ObjectLiteralExpression */: + case 165 /* ObjectLiteralExpression */: return ts.forEach(node.properties, isContextSensitive); - case 162 /* ArrayLiteralExpression */: + case 164 /* ArrayLiteralExpression */: return ts.forEach(node.elements, isContextSensitive); - case 180 /* ConditionalExpression */: + case 182 /* ConditionalExpression */: return isContextSensitive(node.whenTrue) || isContextSensitive(node.whenFalse); - case 179 /* BinaryExpression */: - return node.operatorToken.kind === 51 /* BarBarToken */ && + case 181 /* BinaryExpression */: + return node.operatorToken.kind === 52 /* BarBarToken */ && (isContextSensitive(node.left) || isContextSensitive(node.right)); - case 243 /* PropertyAssignment */: + case 245 /* PropertyAssignment */: return isContextSensitive(node.initializer); - case 141 /* MethodDeclaration */: - case 140 /* MethodSignature */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: return isContextSensitiveFunctionLikeDeclaration(node); - case 170 /* ParenthesizedExpression */: + case 172 /* ParenthesizedExpression */: return isContextSensitive(node.expression); } return false; @@ -17176,7 +17694,7 @@ var ts; else { if (source.flags & 4096 /* Reference */ && target.flags & 4096 /* Reference */ && source.target === target.target) { // We have type references to same target type, see if relationship holds for all type arguments - if (result = typesRelatedTo(source.typeArguments, target.typeArguments, reportErrors)) { + if (result = typeArgumentsRelatedTo(source, target, reportErrors)) { return result; } } @@ -17205,7 +17723,7 @@ var ts; if (source.flags & 80896 /* ObjectType */ && target.flags & 80896 /* ObjectType */) { if (source.flags & 4096 /* Reference */ && target.flags & 4096 /* Reference */ && source.target === target.target) { // We have type references to same target type, see if all type arguments are identical - if (result = typesRelatedTo(source.typeArguments, target.typeArguments, /*reportErrors*/ false)) { + if (result = typeArgumentsRelatedTo(source, target, /*reportErrors*/ false)) { return result; } } @@ -17322,9 +17840,14 @@ var ts; } return result; } - function typesRelatedTo(sources, targets, reportErrors) { + function typeArgumentsRelatedTo(source, target, reportErrors) { + var sources = source.typeArguments || emptyArray; + var targets = target.typeArguments || emptyArray; + if (sources.length !== targets.length && relation === identityRelation) { + return 0 /* False */; + } var result = -1 /* True */; - for (var i = 0, len = sources.length; i < len; i++) { + for (var i = 0; i < targets.length; i++) { var related = isRelatedTo(sources[i], targets[i], reportErrors); if (!related) { return 0 /* False */; @@ -17542,7 +18065,7 @@ var ts; if (kind === 1 /* Construct */) { // Only want to compare the construct signatures for abstractness guarantees. // Because the "abstractness" of a class is the same across all construct signatures - // (internally we are checking the corresponding declaration), it is enough to perform + // (internally we are checking the corresponding declaration), it is enough to perform // the check and report an error once over all pairs of source and target construct signatures. // // sourceSig and targetSig are (possibly) undefined. @@ -18042,22 +18565,22 @@ var ts; var typeAsString = typeToString(getWidenedType(type)); var diagnostic; switch (declaration.kind) { - case 139 /* PropertyDeclaration */: - case 138 /* PropertySignature */: + case 141 /* PropertyDeclaration */: + case 140 /* PropertySignature */: diagnostic = ts.Diagnostics.Member_0_implicitly_has_an_1_type; break; - case 136 /* Parameter */: + case 138 /* Parameter */: diagnostic = declaration.dotDotDotToken ? ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type : ts.Diagnostics.Parameter_0_implicitly_has_an_1_type; break; - case 211 /* FunctionDeclaration */: - case 141 /* MethodDeclaration */: - case 140 /* MethodSignature */: - case 143 /* GetAccessor */: - case 144 /* SetAccessor */: - case 171 /* FunctionExpression */: - case 172 /* ArrowFunction */: + case 213 /* FunctionDeclaration */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: + case 173 /* FunctionExpression */: + case 174 /* ArrowFunction */: if (!declaration.name) { error(declaration, ts.Diagnostics.Function_expression_which_lacks_return_type_annotation_implicitly_has_an_0_return_type, typeAsString); return; @@ -18167,9 +18690,10 @@ var ts; } else if (source.flags & 4096 /* Reference */ && target.flags & 4096 /* Reference */ && source.target === target.target) { // If source and target are references to the same generic type, infer from type arguments - var sourceTypes = source.typeArguments; - var targetTypes = target.typeArguments; - for (var i = 0; i < sourceTypes.length; i++) { + var sourceTypes = source.typeArguments || emptyArray; + var targetTypes = target.typeArguments || emptyArray; + var count = sourceTypes.length < targetTypes.length ? sourceTypes.length : targetTypes.length; + for (var i = 0; i < count; i++) { inferFromTypes(sourceTypes[i], targetTypes[i]); } } @@ -18347,10 +18871,10 @@ var ts; // The expression is restricted to a single identifier or a sequence of identifiers separated by periods while (node) { switch (node.kind) { - case 152 /* TypeQuery */: + case 154 /* TypeQuery */: return true; - case 67 /* Identifier */: - case 133 /* QualifiedName */: + case 69 /* Identifier */: + case 135 /* QualifiedName */: node = node.parent; continue; default: @@ -18396,12 +18920,12 @@ var ts; } return links.assignmentChecks[symbol.id] = isAssignedIn(node); function isAssignedInBinaryExpression(node) { - if (node.operatorToken.kind >= 55 /* FirstAssignment */ && node.operatorToken.kind <= 66 /* LastAssignment */) { + if (node.operatorToken.kind >= 56 /* FirstAssignment */ && node.operatorToken.kind <= 68 /* LastAssignment */) { var n = node.left; - while (n.kind === 170 /* ParenthesizedExpression */) { + while (n.kind === 172 /* ParenthesizedExpression */) { n = n.expression; } - if (n.kind === 67 /* Identifier */ && getResolvedSymbol(n) === symbol) { + if (n.kind === 69 /* Identifier */ && getResolvedSymbol(n) === symbol) { return true; } } @@ -18415,55 +18939,55 @@ var ts; } function isAssignedIn(node) { switch (node.kind) { - case 179 /* BinaryExpression */: + case 181 /* BinaryExpression */: return isAssignedInBinaryExpression(node); - case 209 /* VariableDeclaration */: - case 161 /* BindingElement */: + case 211 /* VariableDeclaration */: + case 163 /* BindingElement */: return isAssignedInVariableDeclaration(node); - case 159 /* ObjectBindingPattern */: - case 160 /* ArrayBindingPattern */: - case 162 /* ArrayLiteralExpression */: - case 163 /* ObjectLiteralExpression */: - case 164 /* PropertyAccessExpression */: - case 165 /* ElementAccessExpression */: - case 166 /* CallExpression */: - case 167 /* NewExpression */: - case 169 /* TypeAssertionExpression */: - case 187 /* AsExpression */: - case 170 /* ParenthesizedExpression */: - case 177 /* PrefixUnaryExpression */: - case 173 /* DeleteExpression */: - case 176 /* AwaitExpression */: - case 174 /* TypeOfExpression */: - case 175 /* VoidExpression */: - case 178 /* PostfixUnaryExpression */: - case 182 /* YieldExpression */: - case 180 /* ConditionalExpression */: - case 183 /* SpreadElementExpression */: - case 190 /* Block */: - case 191 /* VariableStatement */: - case 193 /* ExpressionStatement */: - case 194 /* IfStatement */: - case 195 /* DoStatement */: - case 196 /* WhileStatement */: - case 197 /* ForStatement */: - case 198 /* ForInStatement */: - case 199 /* ForOfStatement */: - case 202 /* ReturnStatement */: - case 203 /* WithStatement */: - case 204 /* SwitchStatement */: - case 239 /* CaseClause */: - case 240 /* DefaultClause */: - case 205 /* LabeledStatement */: - case 206 /* ThrowStatement */: - case 207 /* TryStatement */: - case 242 /* CatchClause */: - case 231 /* JsxElement */: - case 232 /* JsxSelfClosingElement */: - case 236 /* JsxAttribute */: - case 237 /* JsxSpreadAttribute */: - case 233 /* JsxOpeningElement */: - case 238 /* JsxExpression */: + case 161 /* ObjectBindingPattern */: + case 162 /* ArrayBindingPattern */: + case 164 /* ArrayLiteralExpression */: + case 165 /* ObjectLiteralExpression */: + case 166 /* PropertyAccessExpression */: + case 167 /* ElementAccessExpression */: + case 168 /* CallExpression */: + case 169 /* NewExpression */: + case 171 /* TypeAssertionExpression */: + case 189 /* AsExpression */: + case 172 /* ParenthesizedExpression */: + case 179 /* PrefixUnaryExpression */: + case 175 /* DeleteExpression */: + case 178 /* AwaitExpression */: + case 176 /* TypeOfExpression */: + case 177 /* VoidExpression */: + case 180 /* PostfixUnaryExpression */: + case 184 /* YieldExpression */: + case 182 /* ConditionalExpression */: + case 185 /* SpreadElementExpression */: + case 192 /* Block */: + case 193 /* VariableStatement */: + case 195 /* ExpressionStatement */: + case 196 /* IfStatement */: + case 197 /* DoStatement */: + case 198 /* WhileStatement */: + case 199 /* ForStatement */: + case 200 /* ForInStatement */: + case 201 /* ForOfStatement */: + case 204 /* ReturnStatement */: + case 205 /* WithStatement */: + case 206 /* SwitchStatement */: + case 241 /* CaseClause */: + case 242 /* DefaultClause */: + case 207 /* LabeledStatement */: + case 208 /* ThrowStatement */: + case 209 /* TryStatement */: + case 244 /* CatchClause */: + case 233 /* JsxElement */: + case 234 /* JsxSelfClosingElement */: + case 238 /* JsxAttribute */: + case 239 /* JsxSpreadAttribute */: + case 235 /* JsxOpeningElement */: + case 240 /* JsxExpression */: return ts.forEachChild(node, isAssignedIn); } return false; @@ -18480,37 +19004,37 @@ var ts; node = node.parent; var narrowedType = type; switch (node.kind) { - case 194 /* IfStatement */: + case 196 /* IfStatement */: // In a branch of an if statement, narrow based on controlling expression if (child !== node.expression) { narrowedType = narrowType(type, node.expression, /*assumeTrue*/ child === node.thenStatement); } break; - case 180 /* ConditionalExpression */: + case 182 /* ConditionalExpression */: // In a branch of a conditional expression, narrow based on controlling condition if (child !== node.condition) { narrowedType = narrowType(type, node.condition, /*assumeTrue*/ child === node.whenTrue); } break; - case 179 /* BinaryExpression */: + case 181 /* BinaryExpression */: // In the right operand of an && or ||, narrow based on left operand if (child === node.right) { - if (node.operatorToken.kind === 50 /* AmpersandAmpersandToken */) { + if (node.operatorToken.kind === 51 /* AmpersandAmpersandToken */) { narrowedType = narrowType(type, node.left, /*assumeTrue*/ true); } - else if (node.operatorToken.kind === 51 /* BarBarToken */) { + else if (node.operatorToken.kind === 52 /* BarBarToken */) { narrowedType = narrowType(type, node.left, /*assumeTrue*/ false); } } break; - case 246 /* SourceFile */: - case 216 /* ModuleDeclaration */: - case 211 /* FunctionDeclaration */: - case 141 /* MethodDeclaration */: - case 140 /* MethodSignature */: - case 143 /* GetAccessor */: - case 144 /* SetAccessor */: - case 142 /* Constructor */: + case 248 /* SourceFile */: + case 218 /* ModuleDeclaration */: + case 213 /* FunctionDeclaration */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: + case 144 /* Constructor */: // Stop at the first containing function or module declaration break loop; } @@ -18527,12 +19051,12 @@ var ts; return type; function narrowTypeByEquality(type, expr, assumeTrue) { // Check that we have 'typeof ' on the left and string literal on the right - if (expr.left.kind !== 174 /* TypeOfExpression */ || expr.right.kind !== 9 /* StringLiteral */) { + if (expr.left.kind !== 176 /* TypeOfExpression */ || expr.right.kind !== 9 /* StringLiteral */) { return type; } var left = expr.left; var right = expr.right; - if (left.expression.kind !== 67 /* Identifier */ || getResolvedSymbol(left.expression) !== symbol) { + if (left.expression.kind !== 69 /* Identifier */ || getResolvedSymbol(left.expression) !== symbol) { return type; } var typeInfo = primitiveTypeInfo[right.text]; @@ -18592,7 +19116,7 @@ var ts; } function narrowTypeByInstanceof(type, expr, assumeTrue) { // Check that type is not any, assumed result is true, and we have variable symbol on the left - if (isTypeAny(type) || !assumeTrue || expr.left.kind !== 67 /* Identifier */ || getResolvedSymbol(expr.left) !== symbol) { + if (isTypeAny(type) || !assumeTrue || expr.left.kind !== 69 /* Identifier */ || getResolvedSymbol(expr.left) !== symbol) { return type; } // Check that right operand is a function type with a prototype property @@ -18664,27 +19188,27 @@ var ts; // will be a subtype or the same type as the argument. function narrowType(type, expr, assumeTrue) { switch (expr.kind) { - case 166 /* CallExpression */: + case 168 /* CallExpression */: return narrowTypeByTypePredicate(type, expr, assumeTrue); - case 170 /* ParenthesizedExpression */: + case 172 /* ParenthesizedExpression */: return narrowType(type, expr.expression, assumeTrue); - case 179 /* BinaryExpression */: + case 181 /* BinaryExpression */: var operator = expr.operatorToken.kind; if (operator === 32 /* EqualsEqualsEqualsToken */ || operator === 33 /* ExclamationEqualsEqualsToken */) { return narrowTypeByEquality(type, expr, assumeTrue); } - else if (operator === 50 /* AmpersandAmpersandToken */) { + else if (operator === 51 /* AmpersandAmpersandToken */) { return narrowTypeByAnd(type, expr, assumeTrue); } - else if (operator === 51 /* BarBarToken */) { + else if (operator === 52 /* BarBarToken */) { return narrowTypeByOr(type, expr, assumeTrue); } - else if (operator === 89 /* InstanceOfKeyword */) { + else if (operator === 91 /* InstanceOfKeyword */) { return narrowTypeByInstanceof(type, expr, assumeTrue); } break; - case 177 /* PrefixUnaryExpression */: - if (expr.operator === 48 /* ExclamationToken */) { + case 179 /* PrefixUnaryExpression */: + if (expr.operator === 49 /* ExclamationToken */) { return narrowType(type, expr.operand, !assumeTrue); } break; @@ -18702,7 +19226,7 @@ var ts; // can explicitly bound arguments objects if (symbol === argumentsSymbol) { var container = ts.getContainingFunction(node); - if (container.kind === 172 /* ArrowFunction */) { + if (container.kind === 174 /* ArrowFunction */) { if (languageVersion < 2 /* ES6 */) { error(node, ts.Diagnostics.The_arguments_object_cannot_be_referenced_in_an_arrow_function_in_ES3_and_ES5_Consider_using_a_standard_function_expression); } @@ -18733,7 +19257,7 @@ var ts; function checkBlockScopedBindingCapturedInLoop(node, symbol) { if (languageVersion >= 2 /* ES6 */ || (symbol.flags & 2 /* BlockScopedVariable */) === 0 || - symbol.valueDeclaration.parent.kind === 242 /* CatchClause */) { + symbol.valueDeclaration.parent.kind === 244 /* CatchClause */) { return; } // - check if binding is used in some function @@ -18742,12 +19266,12 @@ var ts; // nesting structure: // (variable declaration or binding element) -> variable declaration list -> container var container = symbol.valueDeclaration; - while (container.kind !== 210 /* VariableDeclarationList */) { + while (container.kind !== 212 /* VariableDeclarationList */) { container = container.parent; } // get the parent of variable declaration list container = container.parent; - if (container.kind === 191 /* VariableStatement */) { + if (container.kind === 193 /* VariableStatement */) { // if parent is variable statement - get its parent container = container.parent; } @@ -18767,7 +19291,7 @@ var ts; } function captureLexicalThis(node, container) { getNodeLinks(node).flags |= 2 /* LexicalThis */; - if (container.kind === 139 /* PropertyDeclaration */ || container.kind === 142 /* Constructor */) { + if (container.kind === 141 /* PropertyDeclaration */ || container.kind === 144 /* Constructor */) { var classNode = container.parent; getNodeLinks(classNode).flags |= 4 /* CaptureThis */; } @@ -18781,32 +19305,32 @@ var ts; var container = ts.getThisContainer(node, /* includeArrowFunctions */ true); var needToCaptureLexicalThis = false; // Now skip arrow functions to get the "real" owner of 'this'. - if (container.kind === 172 /* ArrowFunction */) { + if (container.kind === 174 /* ArrowFunction */) { container = ts.getThisContainer(container, /* includeArrowFunctions */ false); // When targeting es6, arrow function lexically bind "this" so we do not need to do the work of binding "this" in emitted code needToCaptureLexicalThis = (languageVersion < 2 /* ES6 */); } switch (container.kind) { - case 216 /* ModuleDeclaration */: + case 218 /* ModuleDeclaration */: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_module_or_namespace_body); // do not return here so in case if lexical this is captured - it will be reflected in flags on NodeLinks break; - case 215 /* EnumDeclaration */: + case 217 /* EnumDeclaration */: error(node, ts.Diagnostics.this_cannot_be_referenced_in_current_location); // do not return here so in case if lexical this is captured - it will be reflected in flags on NodeLinks break; - case 142 /* Constructor */: + case 144 /* Constructor */: if (isInConstructorArgumentInitializer(node, container)) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_constructor_arguments); } break; - case 139 /* PropertyDeclaration */: - case 138 /* PropertySignature */: + case 141 /* PropertyDeclaration */: + case 140 /* PropertySignature */: if (container.flags & 128 /* Static */) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_static_property_initializer); } break; - case 134 /* ComputedPropertyName */: + case 136 /* ComputedPropertyName */: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_computed_property_name); break; } @@ -18815,35 +19339,35 @@ var ts; } if (ts.isClassLike(container.parent)) { var symbol = getSymbolOfNode(container.parent); - return container.flags & 128 /* Static */ ? getTypeOfSymbol(symbol) : getDeclaredTypeOfSymbol(symbol); + return container.flags & 128 /* Static */ ? getTypeOfSymbol(symbol) : getDeclaredTypeOfSymbol(symbol).thisType; } return anyType; } function isInConstructorArgumentInitializer(node, constructorDecl) { for (var n = node; n && n !== constructorDecl; n = n.parent) { - if (n.kind === 136 /* Parameter */) { + if (n.kind === 138 /* Parameter */) { return true; } } return false; } function checkSuperExpression(node) { - var isCallExpression = node.parent.kind === 166 /* CallExpression */ && node.parent.expression === node; + var isCallExpression = node.parent.kind === 168 /* CallExpression */ && node.parent.expression === node; var classDeclaration = ts.getContainingClass(node); var classType = classDeclaration && getDeclaredTypeOfSymbol(getSymbolOfNode(classDeclaration)); var baseClassType = classType && getBaseTypes(classType)[0]; var container = ts.getSuperContainer(node, /*includeFunctions*/ true); var needToCaptureLexicalThis = false; if (!isCallExpression) { - // adjust the container reference in case if super is used inside arrow functions with arbitrary deep nesting - while (container && container.kind === 172 /* ArrowFunction */) { + // adjust the container reference in case if super is used inside arrow functions with arbitrary deep nesting + while (container && container.kind === 174 /* ArrowFunction */) { container = ts.getSuperContainer(container, /*includeFunctions*/ true); needToCaptureLexicalThis = languageVersion < 2 /* ES6 */; } } var canUseSuperExpression = isLegalUsageOfSuperExpression(container); var nodeCheckFlag = 0; - // always set NodeCheckFlags for 'super' expression node + // always set NodeCheckFlags for 'super' expression node if (canUseSuperExpression) { if ((container.flags & 128 /* Static */) || isCallExpression) { nodeCheckFlag = 512 /* SuperStatic */; @@ -18866,7 +19390,7 @@ var ts; return unknownType; } if (!canUseSuperExpression) { - if (container && container.kind === 134 /* ComputedPropertyName */) { + if (container && container.kind === 136 /* ComputedPropertyName */) { error(node, ts.Diagnostics.super_cannot_be_referenced_in_a_computed_property_name); } else if (isCallExpression) { @@ -18877,7 +19401,7 @@ var ts; } return unknownType; } - if (container.kind === 142 /* Constructor */ && isInConstructorArgumentInitializer(node, container)) { + if (container.kind === 144 /* Constructor */ && isInConstructorArgumentInitializer(node, container)) { // issue custom error message for super property access in constructor arguments (to be aligned with old compiler) error(node, ts.Diagnostics.super_cannot_be_referenced_in_constructor_arguments); return unknownType; @@ -18892,7 +19416,7 @@ var ts; if (isCallExpression) { // TS 1.0 SPEC (April 2014): 4.8.1 // Super calls are only permitted in constructors of derived classes - return container.kind === 142 /* Constructor */; + return container.kind === 144 /* Constructor */; } else { // TS 1.0 SPEC (April 2014) @@ -18902,19 +19426,19 @@ var ts; // topmost container must be something that is directly nested in the class declaration if (container && ts.isClassLike(container.parent)) { if (container.flags & 128 /* Static */) { - return container.kind === 141 /* MethodDeclaration */ || - container.kind === 140 /* MethodSignature */ || - container.kind === 143 /* GetAccessor */ || - container.kind === 144 /* SetAccessor */; + return container.kind === 143 /* MethodDeclaration */ || + container.kind === 142 /* MethodSignature */ || + container.kind === 145 /* GetAccessor */ || + container.kind === 146 /* SetAccessor */; } else { - return container.kind === 141 /* MethodDeclaration */ || - container.kind === 140 /* MethodSignature */ || - container.kind === 143 /* GetAccessor */ || - container.kind === 144 /* SetAccessor */ || - container.kind === 139 /* PropertyDeclaration */ || - container.kind === 138 /* PropertySignature */ || - container.kind === 142 /* Constructor */; + return container.kind === 143 /* MethodDeclaration */ || + container.kind === 142 /* MethodSignature */ || + container.kind === 145 /* GetAccessor */ || + container.kind === 146 /* SetAccessor */ || + container.kind === 141 /* PropertyDeclaration */ || + container.kind === 140 /* PropertySignature */ || + container.kind === 144 /* Constructor */; } } } @@ -18955,7 +19479,7 @@ var ts; if (declaration.type) { return getTypeFromTypeNode(declaration.type); } - if (declaration.kind === 136 /* Parameter */) { + if (declaration.kind === 138 /* Parameter */) { var type = getContextuallyTypedParameterType(declaration); if (type) { return type; @@ -18988,7 +19512,7 @@ var ts; } function isInParameterInitializerBeforeContainingFunction(node) { while (node.parent && !ts.isFunctionLike(node.parent)) { - if (node.parent.kind === 136 /* Parameter */ && node.parent.initializer === node) { + if (node.parent.kind === 138 /* Parameter */ && node.parent.initializer === node) { return true; } node = node.parent; @@ -18999,8 +19523,8 @@ var ts; // If the containing function has a return type annotation, is a constructor, or is a get accessor whose // corresponding set accessor has a type annotation, return statements in the function are contextually typed if (functionDecl.type || - functionDecl.kind === 142 /* Constructor */ || - functionDecl.kind === 143 /* GetAccessor */ && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(functionDecl.symbol, 144 /* SetAccessor */))) { + functionDecl.kind === 144 /* Constructor */ || + functionDecl.kind === 145 /* GetAccessor */ && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(functionDecl.symbol, 146 /* SetAccessor */))) { return getReturnTypeOfSignature(getSignatureFromDeclaration(functionDecl)); } // Otherwise, if the containing function is contextually typed by a function type with exactly one call signature @@ -19022,7 +19546,7 @@ var ts; return undefined; } function getContextualTypeForSubstitutionExpression(template, substitutionExpression) { - if (template.parent.kind === 168 /* TaggedTemplateExpression */) { + if (template.parent.kind === 170 /* TaggedTemplateExpression */) { return getContextualTypeForArgument(template.parent, substitutionExpression); } return undefined; @@ -19030,13 +19554,13 @@ var ts; function getContextualTypeForBinaryOperand(node) { var binaryExpression = node.parent; var operator = binaryExpression.operatorToken.kind; - if (operator >= 55 /* FirstAssignment */ && operator <= 66 /* LastAssignment */) { + if (operator >= 56 /* FirstAssignment */ && operator <= 68 /* LastAssignment */) { // In an assignment expression, the right operand is contextually typed by the type of the left operand. if (node === binaryExpression.right) { return checkExpression(binaryExpression.left); } } - else if (operator === 51 /* BarBarToken */) { + else if (operator === 52 /* BarBarToken */) { // When an || expression has a contextual type, the operands are contextually typed by that type. When an || // expression has no contextual type, the right operand is contextually typed by the type of the left operand. var type = getContextualType(binaryExpression); @@ -19143,7 +19667,7 @@ var ts; } function getContextualTypeForJsxExpression(expr) { // Contextual type only applies to JSX expressions that are in attribute assignments (not in 'Children' positions) - if (expr.parent.kind === 236 /* JsxAttribute */) { + if (expr.parent.kind === 238 /* JsxAttribute */) { var attrib = expr.parent; var attrsType = getJsxElementAttributesType(attrib.parent); if (!attrsType || isTypeAny(attrsType)) { @@ -19153,7 +19677,7 @@ var ts; return getTypeOfPropertyOfType(attrsType, attrib.name.text); } } - if (expr.kind === 237 /* JsxSpreadAttribute */) { + if (expr.kind === 239 /* JsxSpreadAttribute */) { return getJsxElementAttributesType(expr.parent); } return undefined; @@ -19174,38 +19698,38 @@ var ts; } var parent = node.parent; switch (parent.kind) { - case 209 /* VariableDeclaration */: - case 136 /* Parameter */: - case 139 /* PropertyDeclaration */: - case 138 /* PropertySignature */: - case 161 /* BindingElement */: + case 211 /* VariableDeclaration */: + case 138 /* Parameter */: + case 141 /* PropertyDeclaration */: + case 140 /* PropertySignature */: + case 163 /* BindingElement */: return getContextualTypeForInitializerExpression(node); - case 172 /* ArrowFunction */: - case 202 /* ReturnStatement */: + case 174 /* ArrowFunction */: + case 204 /* ReturnStatement */: return getContextualTypeForReturnExpression(node); - case 182 /* YieldExpression */: + case 184 /* YieldExpression */: return getContextualTypeForYieldOperand(parent); - case 166 /* CallExpression */: - case 167 /* NewExpression */: + case 168 /* CallExpression */: + case 169 /* NewExpression */: return getContextualTypeForArgument(parent, node); - case 169 /* TypeAssertionExpression */: - case 187 /* AsExpression */: + case 171 /* TypeAssertionExpression */: + case 189 /* AsExpression */: return getTypeFromTypeNode(parent.type); - case 179 /* BinaryExpression */: + case 181 /* BinaryExpression */: return getContextualTypeForBinaryOperand(node); - case 243 /* PropertyAssignment */: + case 245 /* PropertyAssignment */: return getContextualTypeForObjectLiteralElement(parent); - case 162 /* ArrayLiteralExpression */: + case 164 /* ArrayLiteralExpression */: return getContextualTypeForElementExpression(node); - case 180 /* ConditionalExpression */: + case 182 /* ConditionalExpression */: return getContextualTypeForConditionalOperand(node); - case 188 /* TemplateSpan */: - ts.Debug.assert(parent.parent.kind === 181 /* TemplateExpression */); + case 190 /* TemplateSpan */: + ts.Debug.assert(parent.parent.kind === 183 /* TemplateExpression */); return getContextualTypeForSubstitutionExpression(parent.parent, node); - case 170 /* ParenthesizedExpression */: + case 172 /* ParenthesizedExpression */: return getContextualType(parent); - case 238 /* JsxExpression */: - case 237 /* JsxSpreadAttribute */: + case 240 /* JsxExpression */: + case 239 /* JsxSpreadAttribute */: return getContextualTypeForJsxExpression(parent); } return undefined; @@ -19222,7 +19746,7 @@ var ts; } } function isFunctionExpressionOrArrowFunction(node) { - return node.kind === 171 /* FunctionExpression */ || node.kind === 172 /* ArrowFunction */; + return node.kind === 173 /* FunctionExpression */ || node.kind === 174 /* ArrowFunction */; } function getContextualSignatureForFunctionLikeDeclaration(node) { // Only function expressions, arrow functions, and object literal methods are contextually typed. @@ -19236,7 +19760,7 @@ var ts; // all identical ignoring their return type, the result is same signature but with return type as // union type of return types from these signatures function getContextualSignature(node) { - ts.Debug.assert(node.kind !== 141 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 143 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); var type = ts.isObjectLiteralMethod(node) ? getContextualTypeForObjectLiteralMethod(node) : getContextualType(node); @@ -19299,13 +19823,13 @@ var ts; // an assignment target. Examples include 'a = xxx', '{ p: a } = xxx', '[{ p: a}] = xxx'. function isAssignmentTarget(node) { var parent = node.parent; - if (parent.kind === 179 /* BinaryExpression */ && parent.operatorToken.kind === 55 /* EqualsToken */ && parent.left === node) { + if (parent.kind === 181 /* BinaryExpression */ && parent.operatorToken.kind === 56 /* EqualsToken */ && parent.left === node) { return true; } - if (parent.kind === 243 /* PropertyAssignment */) { + if (parent.kind === 245 /* PropertyAssignment */) { return isAssignmentTarget(parent.parent); } - if (parent.kind === 162 /* ArrayLiteralExpression */) { + if (parent.kind === 164 /* ArrayLiteralExpression */) { return isAssignmentTarget(parent); } return false; @@ -19321,8 +19845,8 @@ var ts; return checkIteratedTypeOrElementType(arrayOrIterableType, node.expression, /*allowStringInput*/ false); } function hasDefaultValue(node) { - return (node.kind === 161 /* BindingElement */ && !!node.initializer) || - (node.kind === 179 /* BinaryExpression */ && node.operatorToken.kind === 55 /* EqualsToken */); + return (node.kind === 163 /* BindingElement */ && !!node.initializer) || + (node.kind === 181 /* BinaryExpression */ && node.operatorToken.kind === 56 /* EqualsToken */); } function checkArrayLiteral(node, contextualMapper) { var elements = node.elements; @@ -19331,7 +19855,7 @@ var ts; var inDestructuringPattern = isAssignmentTarget(node); for (var _i = 0; _i < elements.length; _i++) { var e = elements[_i]; - if (inDestructuringPattern && e.kind === 183 /* SpreadElementExpression */) { + if (inDestructuringPattern && e.kind === 185 /* SpreadElementExpression */) { // Given the following situation: // var c: {}; // [...c] = ["", 0]; @@ -19355,7 +19879,7 @@ var ts; var type = checkExpression(e, contextualMapper); elementTypes.push(type); } - hasSpreadElement = hasSpreadElement || e.kind === 183 /* SpreadElementExpression */; + hasSpreadElement = hasSpreadElement || e.kind === 185 /* SpreadElementExpression */; } if (!hasSpreadElement) { // If array literal is actually a destructuring pattern, mark it as an implied type. We do this such @@ -19370,7 +19894,7 @@ var ts; var pattern = contextualType.pattern; // If array literal is contextually typed by a binding pattern or an assignment pattern, pad the resulting // tuple type with the corresponding binding or assignment element types to make the lengths equal. - if (pattern && (pattern.kind === 160 /* ArrayBindingPattern */ || pattern.kind === 162 /* ArrayLiteralExpression */)) { + if (pattern && (pattern.kind === 162 /* ArrayBindingPattern */ || pattern.kind === 164 /* ArrayLiteralExpression */)) { var patternElements = pattern.elements; for (var i = elementTypes.length; i < patternElements.length; i++) { var patternElement = patternElements[i]; @@ -19378,7 +19902,7 @@ var ts; elementTypes.push(contextualType.elementTypes[i]); } else { - if (patternElement.kind !== 185 /* OmittedExpression */) { + if (patternElement.kind !== 187 /* OmittedExpression */) { error(patternElement, ts.Diagnostics.Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value); } elementTypes.push(unknownType); @@ -19393,7 +19917,7 @@ var ts; return createArrayType(elementTypes.length ? getUnionType(elementTypes) : undefinedType); } function isNumericName(name) { - return name.kind === 134 /* ComputedPropertyName */ ? isNumericComputedName(name) : isNumericLiteralName(name.text); + return name.kind === 136 /* ComputedPropertyName */ ? isNumericComputedName(name) : isNumericLiteralName(name.text); } function isNumericComputedName(name) { // It seems odd to consider an expression of type Any to result in a numeric name, @@ -19443,30 +19967,30 @@ var ts; return links.resolvedType; } function checkObjectLiteral(node, contextualMapper) { + var inDestructuringPattern = isAssignmentTarget(node); // Grammar checking - checkGrammarObjectLiteralExpression(node); + checkGrammarObjectLiteralExpression(node, inDestructuringPattern); var propertiesTable = {}; var propertiesArray = []; var contextualType = getContextualType(node); var contextualTypeHasPattern = contextualType && contextualType.pattern && - (contextualType.pattern.kind === 159 /* ObjectBindingPattern */ || contextualType.pattern.kind === 163 /* ObjectLiteralExpression */); - var inDestructuringPattern = isAssignmentTarget(node); + (contextualType.pattern.kind === 161 /* ObjectBindingPattern */ || contextualType.pattern.kind === 165 /* ObjectLiteralExpression */); var typeFlags = 0; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var memberDecl = _a[_i]; var member = memberDecl.symbol; - if (memberDecl.kind === 243 /* PropertyAssignment */ || - memberDecl.kind === 244 /* ShorthandPropertyAssignment */ || + if (memberDecl.kind === 245 /* PropertyAssignment */ || + memberDecl.kind === 246 /* ShorthandPropertyAssignment */ || ts.isObjectLiteralMethod(memberDecl)) { var type = void 0; - if (memberDecl.kind === 243 /* PropertyAssignment */) { + if (memberDecl.kind === 245 /* PropertyAssignment */) { type = checkPropertyAssignment(memberDecl, contextualMapper); } - else if (memberDecl.kind === 141 /* MethodDeclaration */) { + else if (memberDecl.kind === 143 /* MethodDeclaration */) { type = checkObjectLiteralMethod(memberDecl, contextualMapper); } else { - ts.Debug.assert(memberDecl.kind === 244 /* ShorthandPropertyAssignment */); + ts.Debug.assert(memberDecl.kind === 246 /* ShorthandPropertyAssignment */); type = checkExpression(memberDecl.name, contextualMapper); } typeFlags |= type.flags; @@ -19474,7 +19998,9 @@ var ts; if (inDestructuringPattern) { // If object literal is an assignment pattern and if the assignment pattern specifies a default value // for the property, make the property optional. - if (memberDecl.kind === 243 /* PropertyAssignment */ && hasDefaultValue(memberDecl.initializer)) { + var isOptional = (memberDecl.kind === 245 /* PropertyAssignment */ && hasDefaultValue(memberDecl.initializer)) || + (memberDecl.kind === 246 /* ShorthandPropertyAssignment */ && memberDecl.objectAssignmentInitializer); + if (isOptional) { prop.flags |= 536870912 /* Optional */; } } @@ -19504,7 +20030,7 @@ var ts; // an ordinary function declaration(section 6.1) with no parameters. // A set accessor declaration is processed in the same manner // as an ordinary function declaration with a single parameter and a Void return type. - ts.Debug.assert(memberDecl.kind === 143 /* GetAccessor */ || memberDecl.kind === 144 /* SetAccessor */); + ts.Debug.assert(memberDecl.kind === 145 /* GetAccessor */ || memberDecl.kind === 146 /* SetAccessor */); checkAccessorDeclaration(memberDecl); } if (!ts.hasDynamicName(memberDecl)) { @@ -19566,7 +20092,7 @@ var ts; if (lhs.kind !== rhs.kind) { return false; } - if (lhs.kind === 67 /* Identifier */) { + if (lhs.kind === 69 /* Identifier */) { return lhs.text === rhs.text; } return lhs.right.text === rhs.right.text && @@ -19587,18 +20113,18 @@ var ts; for (var _i = 0, _a = node.children; _i < _a.length; _i++) { var child = _a[_i]; switch (child.kind) { - case 238 /* JsxExpression */: + case 240 /* JsxExpression */: checkJsxExpression(child); break; - case 231 /* JsxElement */: + case 233 /* JsxElement */: checkJsxElement(child); break; - case 232 /* JsxSelfClosingElement */: + case 234 /* JsxSelfClosingElement */: checkJsxSelfClosingElement(child); break; default: // No checks for JSX Text - ts.Debug.assert(child.kind === 234 /* JsxText */); + ts.Debug.assert(child.kind === 236 /* JsxText */); } } return jsxElementType || anyType; @@ -19614,7 +20140,7 @@ var ts; * Returns true iff React would emit this tag name as a string rather than an identifier or qualified name */ function isJsxIntrinsicIdentifier(tagName) { - if (tagName.kind === 133 /* QualifiedName */) { + if (tagName.kind === 135 /* QualifiedName */) { return false; } else { @@ -19733,12 +20259,14 @@ var ts; // Look up the value in the current scope if (valueSymbol && valueSymbol !== unknownSymbol) { links.jsxFlags |= 4 /* ClassElement */; - getSymbolLinks(valueSymbol).referenced = true; + if (valueSymbol.flags & 8388608 /* Alias */) { + markAliasSymbolAsReferenced(valueSymbol); + } } return valueSymbol || unknownSymbol; } function resolveJsxTagName(node) { - if (node.tagName.kind === 67 /* Identifier */) { + if (node.tagName.kind === 69 /* Identifier */) { var tag = node.tagName; var sym = getResolvedSymbol(tag); return sym.exportSymbol || sym; @@ -19923,11 +20451,11 @@ var ts; // thus should have their types ignored var sawSpreadedAny = false; for (var i = node.attributes.length - 1; i >= 0; i--) { - if (node.attributes[i].kind === 236 /* JsxAttribute */) { + if (node.attributes[i].kind === 238 /* JsxAttribute */) { checkJsxAttribute((node.attributes[i]), targetAttributesType, nameTable); } else { - ts.Debug.assert(node.attributes[i].kind === 237 /* JsxSpreadAttribute */); + ts.Debug.assert(node.attributes[i].kind === 239 /* JsxSpreadAttribute */); var spreadType = checkJsxSpreadAttribute((node.attributes[i]), targetAttributesType, nameTable); if (isTypeAny(spreadType)) { sawSpreadedAny = true; @@ -19957,7 +20485,7 @@ var ts; // If a symbol is a synthesized symbol with no value declaration, we assume it is a property. Example of this are the synthesized // '.prototype' property as well as synthesized tuple index properties. function getDeclarationKindFromSymbol(s) { - return s.valueDeclaration ? s.valueDeclaration.kind : 139 /* PropertyDeclaration */; + return s.valueDeclaration ? s.valueDeclaration.kind : 141 /* PropertyDeclaration */; } function getDeclarationFlagsFromSymbol(s) { return s.valueDeclaration ? ts.getCombinedNodeFlags(s.valueDeclaration) : s.flags & 134217728 /* Prototype */ ? 16 /* Public */ | 128 /* Static */ : 0; @@ -19973,8 +20501,8 @@ var ts; function checkClassPropertyAccess(node, left, type, prop) { var flags = getDeclarationFlagsFromSymbol(prop); var declaringClass = getDeclaredTypeOfSymbol(prop.parent); - if (left.kind === 93 /* SuperKeyword */) { - var errorNode = node.kind === 164 /* PropertyAccessExpression */ ? + if (left.kind === 95 /* SuperKeyword */) { + var errorNode = node.kind === 166 /* PropertyAccessExpression */ ? node.name : node.right; // TS 1.0 spec (April 2014): 4.8.2 @@ -19984,7 +20512,7 @@ var ts; // - In a static member function or static member accessor // where this references the constructor function object of a derived class, // a super property access is permitted and must specify a public static member function of the base class. - if (getDeclarationKindFromSymbol(prop) !== 141 /* MethodDeclaration */) { + if (getDeclarationKindFromSymbol(prop) !== 143 /* MethodDeclaration */) { // `prop` refers to a *property* declared in the super class // rather than a *method*, so it does not satisfy the above criteria. error(errorNode, ts.Diagnostics.Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword); @@ -20017,7 +20545,7 @@ var ts; } // Property is known to be protected at this point // All protected properties of a supertype are accessible in a super access - if (left.kind === 93 /* SuperKeyword */) { + if (left.kind === 95 /* SuperKeyword */) { return true; } // A protected property is accessible in the declaring class and classes derived from it @@ -20030,6 +20558,10 @@ var ts; return true; } // An instance property must be accessed through an instance of the enclosing class + if (type.flags & 33554432 /* ThisType */) { + // get the original type -- represented as the type constraint of the 'this' type + type = getConstraintOfTypeParameter(type); + } // TODO: why is the first part of this check here? if (!(getTargetType(type).flags & (1024 /* Class */ | 2048 /* Interface */) && hasBaseType(type, enclosingClass))) { error(node, ts.Diagnostics.Property_0_is_protected_and_only_accessible_through_an_instance_of_class_1, symbolToString(prop), typeToString(enclosingClass)); @@ -20056,18 +20588,18 @@ var ts; var prop = getPropertyOfType(apparentType, right.text); if (!prop) { if (right.text) { - error(right, ts.Diagnostics.Property_0_does_not_exist_on_type_1, ts.declarationNameToString(right), typeToString(type)); + error(right, ts.Diagnostics.Property_0_does_not_exist_on_type_1, ts.declarationNameToString(right), typeToString(type.flags & 33554432 /* ThisType */ ? apparentType : type)); } return unknownType; } getNodeLinks(node).resolvedSymbol = prop; if (prop.parent && prop.parent.flags & 32 /* Class */) { - checkClassPropertyAccess(node, left, type, prop); + checkClassPropertyAccess(node, left, apparentType, prop); } return getTypeOfSymbol(prop); } function isValidPropertyAccess(node, propertyName) { - var left = node.kind === 164 /* PropertyAccessExpression */ + var left = node.kind === 166 /* PropertyAccessExpression */ ? node.expression : node.left; var type = checkExpression(left); @@ -20083,7 +20615,7 @@ var ts; // Grammar checking if (!node.argumentExpression) { var sourceFile = getSourceFile(node); - if (node.parent.kind === 167 /* NewExpression */ && node.parent.expression === node) { + if (node.parent.kind === 169 /* NewExpression */ && node.parent.expression === node) { var start = ts.skipTrivia(sourceFile.text, node.expression.end); var end = node.end; grammarErrorAtPos(sourceFile, start, end - start, ts.Diagnostics.new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead); @@ -20155,6 +20687,7 @@ var ts; } /** * If indexArgumentExpression is a string literal or number literal, returns its text. + * If indexArgumentExpression is a constant value, returns its string value. * If indexArgumentExpression is a well known symbol, returns the property name corresponding * to this symbol, as long as it is a proper symbol reference. * Otherwise, returns undefined. @@ -20163,6 +20696,12 @@ var ts; if (indexArgumentExpression.kind === 9 /* StringLiteral */ || indexArgumentExpression.kind === 8 /* NumericLiteral */) { return indexArgumentExpression.text; } + if (indexArgumentExpression.kind === 167 /* ElementAccessExpression */ || indexArgumentExpression.kind === 166 /* PropertyAccessExpression */) { + var value = getConstantValue(indexArgumentExpression); + if (value !== undefined) { + return value.toString(); + } + } if (checkThatExpressionIsProperSymbolReference(indexArgumentExpression, indexArgumentType, /*reportError*/ false)) { var rightHandSideName = indexArgumentExpression.name.text; return ts.getPropertyNameForKnownSymbolName(rightHandSideName); @@ -20212,10 +20751,10 @@ var ts; return true; } function resolveUntypedCall(node) { - if (node.kind === 168 /* TaggedTemplateExpression */) { + if (node.kind === 170 /* TaggedTemplateExpression */) { checkExpression(node.template); } - else if (node.kind !== 137 /* Decorator */) { + else if (node.kind !== 139 /* Decorator */) { ts.forEach(node.arguments, function (argument) { checkExpression(argument); }); @@ -20281,7 +20820,7 @@ var ts; function getSpreadArgumentIndex(args) { for (var i = 0; i < args.length; i++) { var arg = args[i]; - if (arg && arg.kind === 183 /* SpreadElementExpression */) { + if (arg && arg.kind === 185 /* SpreadElementExpression */) { return i; } } @@ -20293,13 +20832,13 @@ var ts; var callIsIncomplete; // In incomplete call we want to be lenient when we have too few arguments var isDecorator; var spreadArgIndex = -1; - if (node.kind === 168 /* TaggedTemplateExpression */) { + if (node.kind === 170 /* TaggedTemplateExpression */) { var tagExpression = node; // Even if the call is incomplete, we'll have a missing expression as our last argument, // so we can say the count is just the arg list length adjustedArgCount = args.length; typeArguments = undefined; - if (tagExpression.template.kind === 181 /* TemplateExpression */) { + if (tagExpression.template.kind === 183 /* TemplateExpression */) { // If a tagged template expression lacks a tail literal, the call is incomplete. // Specifically, a template only can end in a TemplateTail or a Missing literal. var templateExpression = tagExpression.template; @@ -20316,7 +20855,7 @@ var ts; callIsIncomplete = !!templateLiteral.isUnterminated; } } - else if (node.kind === 137 /* Decorator */) { + else if (node.kind === 139 /* Decorator */) { isDecorator = true; typeArguments = undefined; adjustedArgCount = getEffectiveArgumentCount(node, /*args*/ undefined, signature); @@ -20325,7 +20864,7 @@ var ts; var callExpression = node; if (!callExpression.arguments) { // This only happens when we have something of the form: 'new C' - ts.Debug.assert(callExpression.kind === 167 /* NewExpression */); + ts.Debug.assert(callExpression.kind === 169 /* NewExpression */); return signature.minArgumentCount === 0; } // For IDE scenarios we may have an incomplete call, so a trailing comma is tantamount to adding another argument. @@ -20404,7 +20943,7 @@ var ts; for (var i = 0; i < argCount; i++) { var arg = getEffectiveArgument(node, args, i); // If the effective argument is 'undefined', then it is an argument that is present but is synthetic. - if (arg === undefined || arg.kind !== 185 /* OmittedExpression */) { + if (arg === undefined || arg.kind !== 187 /* OmittedExpression */) { var paramType = getTypeAtPosition(signature, i); var argType = getEffectiveArgumentType(node, i, arg); // If the effective argument type is 'undefined', there is no synthetic type @@ -20463,7 +21002,7 @@ var ts; for (var i = 0; i < argCount; i++) { var arg = getEffectiveArgument(node, args, i); // If the effective argument is 'undefined', then it is an argument that is present but is synthetic. - if (arg === undefined || arg.kind !== 185 /* OmittedExpression */) { + if (arg === undefined || arg.kind !== 187 /* OmittedExpression */) { // Check spread elements against rest type (from arity check we know spread argument corresponds to a rest parameter) var paramType = getTypeAtPosition(signature, i); var argType = getEffectiveArgumentType(node, i, arg); @@ -20495,16 +21034,16 @@ var ts; */ function getEffectiveCallArguments(node) { var args; - if (node.kind === 168 /* TaggedTemplateExpression */) { + if (node.kind === 170 /* TaggedTemplateExpression */) { var template = node.template; args = [undefined]; - if (template.kind === 181 /* TemplateExpression */) { + if (template.kind === 183 /* TemplateExpression */) { ts.forEach(template.templateSpans, function (span) { args.push(span.expression); }); } } - else if (node.kind === 137 /* Decorator */) { + else if (node.kind === 139 /* Decorator */) { // For a decorator, we return undefined as we will determine // the number and types of arguments for a decorator using // `getEffectiveArgumentCount` and `getEffectiveArgumentType` below. @@ -20529,25 +21068,29 @@ var ts; * Otherwise, the argument count is the length of the 'args' array. */ function getEffectiveArgumentCount(node, args, signature) { - if (node.kind === 137 /* Decorator */) { + if (node.kind === 139 /* Decorator */) { switch (node.parent.kind) { - case 212 /* ClassDeclaration */: - case 184 /* ClassExpression */: + case 214 /* ClassDeclaration */: + case 186 /* ClassExpression */: // A class decorator will have one argument (see `ClassDecorator` in core.d.ts) return 1; - case 139 /* PropertyDeclaration */: + case 141 /* PropertyDeclaration */: // A property declaration decorator will have two arguments (see // `PropertyDecorator` in core.d.ts) return 2; - case 141 /* MethodDeclaration */: - case 143 /* GetAccessor */: - case 144 /* SetAccessor */: + case 143 /* MethodDeclaration */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: // A method or accessor declaration decorator will have two or three arguments (see // `PropertyDecorator` and `MethodDecorator` in core.d.ts) + // If we are emitting decorators for ES3, we will only pass two arguments. + if (languageVersion === 0 /* ES3 */) { + return 2; + } // If the method decorator signature only accepts a target and a key, we will only // type check those arguments. return signature.parameters.length >= 3 ? 3 : 2; - case 136 /* Parameter */: + case 138 /* Parameter */: // A parameter declaration decorator will have three arguments (see // `ParameterDecorator` in core.d.ts) return 3; @@ -20572,25 +21115,25 @@ var ts; function getEffectiveDecoratorFirstArgumentType(node) { // The first argument to a decorator is its `target`. switch (node.kind) { - case 212 /* ClassDeclaration */: - case 184 /* ClassExpression */: + case 214 /* ClassDeclaration */: + case 186 /* ClassExpression */: // For a class decorator, the `target` is the type of the class (e.g. the // "static" or "constructor" side of the class) var classSymbol = getSymbolOfNode(node); return getTypeOfSymbol(classSymbol); - case 136 /* Parameter */: + case 138 /* Parameter */: // For a parameter decorator, the `target` is the parent type of the // parameter's containing method. node = node.parent; - if (node.kind === 142 /* Constructor */) { + if (node.kind === 144 /* Constructor */) { var classSymbol_1 = getSymbolOfNode(node); return getTypeOfSymbol(classSymbol_1); } // fall-through - case 139 /* PropertyDeclaration */: - case 141 /* MethodDeclaration */: - case 143 /* GetAccessor */: - case 144 /* SetAccessor */: + case 141 /* PropertyDeclaration */: + case 143 /* MethodDeclaration */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: // For a property or method decorator, the `target` is the // "static"-side type of the parent of the member if the member is // declared "static"; otherwise, it is the "instance"-side type of the @@ -20619,33 +21162,33 @@ var ts; function getEffectiveDecoratorSecondArgumentType(node) { // The second argument to a decorator is its `propertyKey` switch (node.kind) { - case 212 /* ClassDeclaration */: + case 214 /* ClassDeclaration */: ts.Debug.fail("Class decorators should not have a second synthetic argument."); return unknownType; - case 136 /* Parameter */: + case 138 /* Parameter */: node = node.parent; - if (node.kind === 142 /* Constructor */) { + if (node.kind === 144 /* Constructor */) { // For a constructor parameter decorator, the `propertyKey` will be `undefined`. return anyType; } // For a non-constructor parameter decorator, the `propertyKey` will be either // a string or a symbol, based on the name of the parameter's containing method. // fall-through - case 139 /* PropertyDeclaration */: - case 141 /* MethodDeclaration */: - case 143 /* GetAccessor */: - case 144 /* SetAccessor */: + case 141 /* PropertyDeclaration */: + case 143 /* MethodDeclaration */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: // The `propertyKey` for a property or method decorator will be a // string literal type if the member name is an identifier, number, or string; // otherwise, if the member name is a computed property name it will // be either string or symbol. var element = node; switch (element.name.kind) { - case 67 /* Identifier */: + case 69 /* Identifier */: case 8 /* NumericLiteral */: case 9 /* StringLiteral */: return getStringLiteralType(element.name); - case 134 /* ComputedPropertyName */: + case 136 /* ComputedPropertyName */: var nameType = checkComputedPropertyName(element.name); if (allConstituentTypesHaveKind(nameType, 16777216 /* ESSymbol */)) { return nameType; @@ -20673,18 +21216,18 @@ var ts; // The third argument to a decorator is either its `descriptor` for a method decorator // or its `parameterIndex` for a paramter decorator switch (node.kind) { - case 212 /* ClassDeclaration */: + case 214 /* ClassDeclaration */: ts.Debug.fail("Class decorators should not have a third synthetic argument."); return unknownType; - case 136 /* Parameter */: + case 138 /* Parameter */: // The `parameterIndex` for a parameter decorator is always a number return numberType; - case 139 /* PropertyDeclaration */: + case 141 /* PropertyDeclaration */: ts.Debug.fail("Property decorators should not have a third synthetic argument."); return unknownType; - case 141 /* MethodDeclaration */: - case 143 /* GetAccessor */: - case 144 /* SetAccessor */: + case 143 /* MethodDeclaration */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: // The `descriptor` for a method decorator will be a `TypedPropertyDescriptor` // for the type of the member. var propertyType = getTypeOfNode(node); @@ -20717,10 +21260,10 @@ var ts; // Decorators provide special arguments, a tagged template expression provides // a special first argument, and string literals get string literal types // unless we're reporting errors - if (node.kind === 137 /* Decorator */) { + if (node.kind === 139 /* Decorator */) { return getEffectiveDecoratorArgumentType(node, argIndex); } - else if (argIndex === 0 && node.kind === 168 /* TaggedTemplateExpression */) { + else if (argIndex === 0 && node.kind === 170 /* TaggedTemplateExpression */) { return globalTemplateStringsArrayType; } // This is not a synthetic argument, so we return 'undefined' @@ -20732,8 +21275,8 @@ var ts; */ function getEffectiveArgument(node, args, argIndex) { // For a decorator or the first argument of a tagged template expression we return undefined. - if (node.kind === 137 /* Decorator */ || - (argIndex === 0 && node.kind === 168 /* TaggedTemplateExpression */)) { + if (node.kind === 139 /* Decorator */ || + (argIndex === 0 && node.kind === 170 /* TaggedTemplateExpression */)) { return undefined; } return args[argIndex]; @@ -20742,11 +21285,11 @@ var ts; * Gets the error node to use when reporting errors for an effective argument. */ function getEffectiveArgumentErrorNode(node, argIndex, arg) { - if (node.kind === 137 /* Decorator */) { + if (node.kind === 139 /* Decorator */) { // For a decorator, we use the expression of the decorator for error reporting. return node.expression; } - else if (argIndex === 0 && node.kind === 168 /* TaggedTemplateExpression */) { + else if (argIndex === 0 && node.kind === 170 /* TaggedTemplateExpression */) { // For a the first argument of a tagged template expression, we use the template of the tag for error reporting. return node.template; } @@ -20755,13 +21298,13 @@ var ts; } } function resolveCall(node, signatures, candidatesOutArray, headMessage) { - var isTaggedTemplate = node.kind === 168 /* TaggedTemplateExpression */; - var isDecorator = node.kind === 137 /* Decorator */; + var isTaggedTemplate = node.kind === 170 /* TaggedTemplateExpression */; + var isDecorator = node.kind === 139 /* Decorator */; var typeArguments; if (!isTaggedTemplate && !isDecorator) { typeArguments = node.typeArguments; // We already perform checking on the type arguments on the class declaration itself. - if (node.expression.kind !== 93 /* SuperKeyword */) { + if (node.expression.kind !== 95 /* SuperKeyword */) { ts.forEach(typeArguments, checkSourceElement); } } @@ -20968,7 +21511,7 @@ var ts; } } function resolveCallExpression(node, candidatesOutArray) { - if (node.expression.kind === 93 /* SuperKeyword */) { + if (node.expression.kind === 95 /* SuperKeyword */) { var superType = checkSuperExpression(node.expression); if (superType !== unknownType) { // In super call, the candidate signatures are the matching arity signatures of the base constructor function instantiated @@ -21101,16 +21644,16 @@ var ts; */ function getDiagnosticHeadMessageForDecoratorResolution(node) { switch (node.parent.kind) { - case 212 /* ClassDeclaration */: - case 184 /* ClassExpression */: + case 214 /* ClassDeclaration */: + case 186 /* ClassExpression */: return ts.Diagnostics.Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression; - case 136 /* Parameter */: + case 138 /* Parameter */: return ts.Diagnostics.Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression; - case 139 /* PropertyDeclaration */: + case 141 /* PropertyDeclaration */: return ts.Diagnostics.Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression; - case 141 /* MethodDeclaration */: - case 143 /* GetAccessor */: - case 144 /* SetAccessor */: + case 143 /* MethodDeclaration */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: return ts.Diagnostics.Unable_to_resolve_signature_of_method_decorator_when_called_as_an_expression; } } @@ -21147,16 +21690,16 @@ var ts; // to correctly fill the candidatesOutArray. if (!links.resolvedSignature || candidatesOutArray) { links.resolvedSignature = anySignature; - if (node.kind === 166 /* CallExpression */) { + if (node.kind === 168 /* CallExpression */) { links.resolvedSignature = resolveCallExpression(node, candidatesOutArray); } - else if (node.kind === 167 /* NewExpression */) { + else if (node.kind === 169 /* NewExpression */) { links.resolvedSignature = resolveNewExpression(node, candidatesOutArray); } - else if (node.kind === 168 /* TaggedTemplateExpression */) { + else if (node.kind === 170 /* TaggedTemplateExpression */) { links.resolvedSignature = resolveTaggedTemplateExpression(node, candidatesOutArray); } - else if (node.kind === 137 /* Decorator */) { + else if (node.kind === 139 /* Decorator */) { links.resolvedSignature = resolveDecorator(node, candidatesOutArray); } else { @@ -21174,15 +21717,15 @@ var ts; // Grammar checking; stop grammar-checking if checkGrammarTypeArguments return true checkGrammarTypeArguments(node, node.typeArguments) || checkGrammarArguments(node, node.arguments); var signature = getResolvedSignature(node); - if (node.expression.kind === 93 /* SuperKeyword */) { + if (node.expression.kind === 95 /* SuperKeyword */) { return voidType; } - if (node.kind === 167 /* NewExpression */) { + if (node.kind === 169 /* NewExpression */) { var declaration = signature.declaration; if (declaration && - declaration.kind !== 142 /* Constructor */ && - declaration.kind !== 146 /* ConstructSignature */ && - declaration.kind !== 151 /* ConstructorType */) { + declaration.kind !== 144 /* Constructor */ && + declaration.kind !== 148 /* ConstructSignature */ && + declaration.kind !== 153 /* ConstructorType */) { // When resolved signature is a call signature (and not a construct signature) the result type is any if (compilerOptions.noImplicitAny) { error(node, ts.Diagnostics.new_expression_whose_target_lacks_a_construct_signature_implicitly_has_an_any_type); @@ -21190,6 +21733,10 @@ var ts; return anyType; } } + // In JavaScript files, calls to any identifier 'require' are treated as external module imports + if (ts.isInJavaScriptFile(node) && ts.isRequireCall(node)) { + return resolveExternalModuleTypeByLiteral(node.arguments[0]); + } return getReturnTypeOfSignature(signature); } function checkTaggedTemplateExpression(node) { @@ -21224,10 +21771,24 @@ var ts; assignTypeToParameterAndFixTypeParameters(parameter, contextualParameterType, mapper); } } + // When contextual typing assigns a type to a parameter that contains a binding pattern, we also need to push + // the destructured type into the contained binding elements. + function assignBindingElementTypes(node) { + if (ts.isBindingPattern(node.name)) { + for (var _i = 0, _a = node.name.elements; _i < _a.length; _i++) { + var element = _a[_i]; + if (element.kind !== 187 /* OmittedExpression */) { + getSymbolLinks(getSymbolOfNode(element)).type = getTypeForBindingElement(element); + assignBindingElementTypes(element); + } + } + } + } function assignTypeToParameterAndFixTypeParameters(parameter, contextualType, mapper) { var links = getSymbolLinks(parameter); if (!links.type) { links.type = instantiateType(contextualType, mapper); + assignBindingElementTypes(parameter.valueDeclaration); } else if (isInferentialContext(mapper)) { // Even if the parameter already has a type, it might be because it was given a type while @@ -21279,7 +21840,7 @@ var ts; } var isAsync = ts.isAsyncFunctionLike(func); var type; - if (func.body.kind !== 190 /* Block */) { + if (func.body.kind !== 192 /* Block */) { type = checkExpressionCached(func.body, contextualMapper); if (isAsync) { // From within an async function you can return either a non-promise value or a promise. Any @@ -21398,7 +21959,7 @@ var ts; }); } function bodyContainsSingleThrowStatement(body) { - return (body.statements.length === 1) && (body.statements[0].kind === 206 /* ThrowStatement */); + return (body.statements.length === 1) && (body.statements[0].kind === 208 /* ThrowStatement */); } // TypeScript Specification 1.0 (6.3) - July 2014 // An explicitly typed function whose return type isn't the Void or the Any type @@ -21413,7 +21974,7 @@ var ts; return; } // If all we have is a function signature, or an arrow function with an expression body, then there is nothing to check. - if (ts.nodeIsMissing(func.body) || func.body.kind !== 190 /* Block */) { + if (ts.nodeIsMissing(func.body) || func.body.kind !== 192 /* Block */) { return; } var bodyBlock = func.body; @@ -21431,10 +21992,10 @@ var ts; error(func.type, ts.Diagnostics.A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value_or_consist_of_a_single_throw_statement); } function checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper) { - ts.Debug.assert(node.kind !== 141 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 143 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); // Grammar checking var hasGrammarError = checkGrammarFunctionLikeDeclaration(node); - if (!hasGrammarError && node.kind === 171 /* FunctionExpression */) { + if (!hasGrammarError && node.kind === 173 /* FunctionExpression */) { checkGrammarForGenerator(node); } // The identityMapper object is used to indicate that function expressions are wildcards @@ -21477,14 +22038,14 @@ var ts; } } } - if (produceDiagnostics && node.kind !== 141 /* MethodDeclaration */ && node.kind !== 140 /* MethodSignature */) { + if (produceDiagnostics && node.kind !== 143 /* MethodDeclaration */ && node.kind !== 142 /* MethodSignature */) { checkCollisionWithCapturedSuperVariable(node, node.name); checkCollisionWithCapturedThisVariable(node, node.name); } return type; } function checkFunctionExpressionOrObjectLiteralMethodBody(node) { - ts.Debug.assert(node.kind !== 141 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 143 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); var isAsync = ts.isAsyncFunctionLike(node); if (isAsync) { emitAwaiter = true; @@ -21506,7 +22067,7 @@ var ts; // checkFunctionExpressionBodies). So it must be done now. getReturnTypeOfSignature(getSignatureFromDeclaration(node)); } - if (node.body.kind === 190 /* Block */) { + if (node.body.kind === 192 /* Block */) { checkSourceElement(node.body); } else { @@ -21552,24 +22113,24 @@ var ts; // and property accesses(section 4.10). // All other expression constructs described in this chapter are classified as values. switch (n.kind) { - case 67 /* Identifier */: { + case 69 /* Identifier */: { var symbol = findSymbol(n); // TypeScript 1.0 spec (April 2014): 4.3 // An identifier expression that references a variable or parameter is classified as a reference. // An identifier expression that references any other kind of entity is classified as a value(and therefore cannot be the target of an assignment). return !symbol || symbol === unknownSymbol || symbol === argumentsSymbol || (symbol.flags & 3 /* Variable */) !== 0; } - case 164 /* PropertyAccessExpression */: { + case 166 /* PropertyAccessExpression */: { var symbol = findSymbol(n); // TypeScript 1.0 spec (April 2014): 4.10 // A property access expression is always classified as a reference. // NOTE (not in spec): assignment to enum members should not be allowed return !symbol || symbol === unknownSymbol || (symbol.flags & ~8 /* EnumMember */) !== 0; } - case 165 /* ElementAccessExpression */: - // old compiler doesn't check indexed assess + case 167 /* ElementAccessExpression */: + // old compiler doesn't check indexed access return true; - case 170 /* ParenthesizedExpression */: + case 172 /* ParenthesizedExpression */: return isReferenceOrErrorExpression(n.expression); default: return false; @@ -21577,12 +22138,12 @@ var ts; } function isConstVariableReference(n) { switch (n.kind) { - case 67 /* Identifier */: - case 164 /* PropertyAccessExpression */: { + case 69 /* Identifier */: + case 166 /* PropertyAccessExpression */: { var symbol = findSymbol(n); return symbol && (symbol.flags & 3 /* Variable */) !== 0 && (getDeclarationFlagsFromSymbol(symbol) & 32768 /* Const */) !== 0; } - case 165 /* ElementAccessExpression */: { + case 167 /* ElementAccessExpression */: { var index = n.argumentExpression; var symbol = findSymbol(n.expression); if (symbol && index && index.kind === 9 /* StringLiteral */) { @@ -21592,7 +22153,7 @@ var ts; } return false; } - case 170 /* ParenthesizedExpression */: + case 172 /* ParenthesizedExpression */: return isConstVariableReference(n.expression); default: return false; @@ -21638,15 +22199,15 @@ var ts; switch (node.operator) { case 35 /* PlusToken */: case 36 /* MinusToken */: - case 49 /* TildeToken */: + case 50 /* TildeToken */: if (someConstituentTypeHasKind(operandType, 16777216 /* ESSymbol */)) { error(node.operand, ts.Diagnostics.The_0_operator_cannot_be_applied_to_type_symbol, ts.tokenToString(node.operator)); } return numberType; - case 48 /* ExclamationToken */: + case 49 /* ExclamationToken */: return booleanType; - case 40 /* PlusPlusToken */: - case 41 /* MinusMinusToken */: + case 41 /* PlusPlusToken */: + case 42 /* MinusMinusToken */: var ok = checkArithmeticOperandType(node.operand, operandType, ts.Diagnostics.An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type); if (ok) { // run check only if former checks succeeded to avoid reporting cascading errors @@ -21706,31 +22267,31 @@ var ts; function isConstEnumSymbol(symbol) { return (symbol.flags & 128 /* ConstEnum */) !== 0; } - function checkInstanceOfExpression(node, leftType, rightType) { + function checkInstanceOfExpression(left, right, leftType, rightType) { // TypeScript 1.0 spec (April 2014): 4.15.4 // The instanceof operator requires the left operand to be of type Any, an object type, or a type parameter type, // and the right operand to be of type Any or a subtype of the 'Function' interface type. // The result is always of the Boolean primitive type. // NOTE: do not raise error if leftType is unknown as related error was already reported if (allConstituentTypesHaveKind(leftType, 16777726 /* Primitive */)) { - error(node.left, ts.Diagnostics.The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_parameter); + error(left, ts.Diagnostics.The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_parameter); } // NOTE: do not raise error if right is unknown as related error was already reported if (!(isTypeAny(rightType) || isTypeSubtypeOf(rightType, globalFunctionType))) { - error(node.right, ts.Diagnostics.The_right_hand_side_of_an_instanceof_expression_must_be_of_type_any_or_of_a_type_assignable_to_the_Function_interface_type); + error(right, ts.Diagnostics.The_right_hand_side_of_an_instanceof_expression_must_be_of_type_any_or_of_a_type_assignable_to_the_Function_interface_type); } return booleanType; } - function checkInExpression(node, leftType, rightType) { + function checkInExpression(left, right, leftType, rightType) { // TypeScript 1.0 spec (April 2014): 4.15.5 // The in operator requires the left operand to be of type Any, the String primitive type, or the Number primitive type, // and the right operand to be of type Any, an object type, or a type parameter type. // The result is always of the Boolean primitive type. if (!isTypeAnyOrAllConstituentTypesHaveKind(leftType, 258 /* StringLike */ | 132 /* NumberLike */ | 16777216 /* ESSymbol */)) { - error(node.left, ts.Diagnostics.The_left_hand_side_of_an_in_expression_must_be_of_type_any_string_number_or_symbol); + error(left, ts.Diagnostics.The_left_hand_side_of_an_in_expression_must_be_of_type_any_string_number_or_symbol); } if (!isTypeAnyOrAllConstituentTypesHaveKind(rightType, 80896 /* ObjectType */ | 512 /* TypeParameter */)) { - error(node.right, ts.Diagnostics.The_right_hand_side_of_an_in_expression_must_be_of_type_any_an_object_type_or_a_type_parameter); + error(right, ts.Diagnostics.The_right_hand_side_of_an_in_expression_must_be_of_type_any_an_object_type_or_a_type_parameter); } return booleanType; } @@ -21738,7 +22299,7 @@ var ts; var properties = node.properties; for (var _i = 0; _i < properties.length; _i++) { var p = properties[_i]; - if (p.kind === 243 /* PropertyAssignment */ || p.kind === 244 /* ShorthandPropertyAssignment */) { + if (p.kind === 245 /* PropertyAssignment */ || p.kind === 246 /* ShorthandPropertyAssignment */) { // TODO(andersh): Computed property support var name_13 = p.name; var type = isTypeAny(sourceType) @@ -21747,7 +22308,12 @@ var ts; isNumericLiteralName(name_13.text) && getIndexTypeOfType(sourceType, 1 /* Number */) || getIndexTypeOfType(sourceType, 0 /* String */); if (type) { - checkDestructuringAssignment(p.initializer || name_13, type); + if (p.kind === 246 /* ShorthandPropertyAssignment */) { + checkDestructuringAssignment(p, type); + } + else { + checkDestructuringAssignment(p.initializer || name_13, type); + } } else { error(name_13, ts.Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(sourceType), ts.declarationNameToString(name_13)); @@ -21767,8 +22333,8 @@ var ts; var elements = node.elements; for (var i = 0; i < elements.length; i++) { var e = elements[i]; - if (e.kind !== 185 /* OmittedExpression */) { - if (e.kind !== 183 /* SpreadElementExpression */) { + if (e.kind !== 187 /* OmittedExpression */) { + if (e.kind !== 185 /* SpreadElementExpression */) { var propName = "" + i; var type = isTypeAny(sourceType) ? sourceType @@ -21793,7 +22359,7 @@ var ts; } else { var restExpression = e.expression; - if (restExpression.kind === 179 /* BinaryExpression */ && restExpression.operatorToken.kind === 55 /* EqualsToken */) { + if (restExpression.kind === 181 /* BinaryExpression */ && restExpression.operatorToken.kind === 56 /* EqualsToken */) { error(restExpression.operatorToken, ts.Diagnostics.A_rest_element_cannot_have_an_initializer); } else { @@ -21805,15 +22371,26 @@ var ts; } return sourceType; } - function checkDestructuringAssignment(target, sourceType, contextualMapper) { - if (target.kind === 179 /* BinaryExpression */ && target.operatorToken.kind === 55 /* EqualsToken */) { + function checkDestructuringAssignment(exprOrAssignment, sourceType, contextualMapper) { + var target; + if (exprOrAssignment.kind === 246 /* ShorthandPropertyAssignment */) { + var prop = exprOrAssignment; + if (prop.objectAssignmentInitializer) { + checkBinaryLikeExpression(prop.name, prop.equalsToken, prop.objectAssignmentInitializer, contextualMapper); + } + target = exprOrAssignment.name; + } + else { + target = exprOrAssignment; + } + if (target.kind === 181 /* BinaryExpression */ && target.operatorToken.kind === 56 /* EqualsToken */) { checkBinaryExpression(target, contextualMapper); target = target.left; } - if (target.kind === 163 /* ObjectLiteralExpression */) { + if (target.kind === 165 /* ObjectLiteralExpression */) { return checkObjectLiteralAssignment(target, sourceType, contextualMapper); } - if (target.kind === 162 /* ArrayLiteralExpression */) { + if (target.kind === 164 /* ArrayLiteralExpression */) { return checkArrayLiteralAssignment(target, sourceType, contextualMapper); } return checkReferenceAssignment(target, sourceType, contextualMapper); @@ -21826,34 +22403,39 @@ var ts; return sourceType; } function checkBinaryExpression(node, contextualMapper) { - var operator = node.operatorToken.kind; - if (operator === 55 /* EqualsToken */ && (node.left.kind === 163 /* ObjectLiteralExpression */ || node.left.kind === 162 /* ArrayLiteralExpression */)) { - return checkDestructuringAssignment(node.left, checkExpression(node.right, contextualMapper), contextualMapper); + return checkBinaryLikeExpression(node.left, node.operatorToken, node.right, contextualMapper, node); + } + function checkBinaryLikeExpression(left, operatorToken, right, contextualMapper, errorNode) { + var operator = operatorToken.kind; + if (operator === 56 /* EqualsToken */ && (left.kind === 165 /* ObjectLiteralExpression */ || left.kind === 164 /* ArrayLiteralExpression */)) { + return checkDestructuringAssignment(left, checkExpression(right, contextualMapper), contextualMapper); } - var leftType = checkExpression(node.left, contextualMapper); - var rightType = checkExpression(node.right, contextualMapper); + var leftType = checkExpression(left, contextualMapper); + var rightType = checkExpression(right, contextualMapper); switch (operator) { case 37 /* AsteriskToken */: - case 58 /* AsteriskEqualsToken */: - case 38 /* SlashToken */: - case 59 /* SlashEqualsToken */: - case 39 /* PercentToken */: - case 60 /* PercentEqualsToken */: + case 38 /* AsteriskAsteriskToken */: + case 59 /* AsteriskEqualsToken */: + case 60 /* AsteriskAsteriskEqualsToken */: + case 39 /* SlashToken */: + case 61 /* SlashEqualsToken */: + case 40 /* PercentToken */: + case 62 /* PercentEqualsToken */: case 36 /* MinusToken */: - case 57 /* MinusEqualsToken */: - case 42 /* LessThanLessThanToken */: - case 61 /* LessThanLessThanEqualsToken */: - case 43 /* GreaterThanGreaterThanToken */: - case 62 /* GreaterThanGreaterThanEqualsToken */: - case 44 /* GreaterThanGreaterThanGreaterThanToken */: - case 63 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 46 /* BarToken */: - case 65 /* BarEqualsToken */: - case 47 /* CaretToken */: - case 66 /* CaretEqualsToken */: - case 45 /* AmpersandToken */: - case 64 /* AmpersandEqualsToken */: - // TypeScript 1.0 spec (April 2014): 4.15.1 + case 58 /* MinusEqualsToken */: + case 43 /* LessThanLessThanToken */: + case 63 /* LessThanLessThanEqualsToken */: + case 44 /* GreaterThanGreaterThanToken */: + case 64 /* GreaterThanGreaterThanEqualsToken */: + case 45 /* GreaterThanGreaterThanGreaterThanToken */: + case 65 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + case 47 /* BarToken */: + case 67 /* BarEqualsToken */: + case 48 /* CaretToken */: + case 68 /* CaretEqualsToken */: + case 46 /* AmpersandToken */: + case 66 /* AmpersandEqualsToken */: + // TypeScript 1.0 spec (April 2014): 4.19.1 // These operators require their operands to be of type Any, the Number primitive type, // or an enum type. Operands of an enum type are treated // as having the primitive type Number. If one operand is the null or undefined value, @@ -21868,21 +22450,21 @@ var ts; // try and return them a helpful suggestion if ((leftType.flags & 8 /* Boolean */) && (rightType.flags & 8 /* Boolean */) && - (suggestedOperator = getSuggestedBooleanOperator(node.operatorToken.kind)) !== undefined) { - error(node, ts.Diagnostics.The_0_operator_is_not_allowed_for_boolean_types_Consider_using_1_instead, ts.tokenToString(node.operatorToken.kind), ts.tokenToString(suggestedOperator)); + (suggestedOperator = getSuggestedBooleanOperator(operatorToken.kind)) !== undefined) { + error(errorNode || operatorToken, ts.Diagnostics.The_0_operator_is_not_allowed_for_boolean_types_Consider_using_1_instead, ts.tokenToString(operatorToken.kind), ts.tokenToString(suggestedOperator)); } else { // otherwise just check each operand separately and report errors as normal - var leftOk = checkArithmeticOperandType(node.left, leftType, ts.Diagnostics.The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type); - var rightOk = checkArithmeticOperandType(node.right, rightType, ts.Diagnostics.The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type); + var leftOk = checkArithmeticOperandType(left, leftType, ts.Diagnostics.The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type); + var rightOk = checkArithmeticOperandType(right, rightType, ts.Diagnostics.The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type); if (leftOk && rightOk) { checkAssignmentOperator(numberType); } } return numberType; case 35 /* PlusToken */: - case 56 /* PlusEqualsToken */: - // TypeScript 1.0 spec (April 2014): 4.15.2 + case 57 /* PlusEqualsToken */: + // TypeScript 1.0 spec (April 2014): 4.19.2 // The binary + operator requires both operands to be of the Number primitive type or an enum type, // or at least one of the operands to be of type Any or the String primitive type. // If one operand is the null or undefined value, it is treated as having the type of the other operand. @@ -21915,7 +22497,7 @@ var ts; reportOperatorError(); return anyType; } - if (operator === 56 /* PlusEqualsToken */) { + if (operator === 57 /* PlusEqualsToken */) { checkAssignmentOperator(resultType); } return resultType; @@ -21935,15 +22517,15 @@ var ts; reportOperatorError(); } return booleanType; - case 89 /* InstanceOfKeyword */: - return checkInstanceOfExpression(node, leftType, rightType); - case 88 /* InKeyword */: - return checkInExpression(node, leftType, rightType); - case 50 /* AmpersandAmpersandToken */: + case 91 /* InstanceOfKeyword */: + return checkInstanceOfExpression(left, right, leftType, rightType); + case 90 /* InKeyword */: + return checkInExpression(left, right, leftType, rightType); + case 51 /* AmpersandAmpersandToken */: return rightType; - case 51 /* BarBarToken */: + case 52 /* BarBarToken */: return getUnionType([leftType, rightType]); - case 55 /* EqualsToken */: + case 56 /* EqualsToken */: checkAssignmentOperator(rightType); return getRegularTypeOfObjectLiteral(rightType); case 24 /* CommaToken */: @@ -21951,8 +22533,8 @@ var ts; } // Return true if there was no error, false if there was an error. function checkForDisallowedESSymbolOperand(operator) { - var offendingSymbolOperand = someConstituentTypeHasKind(leftType, 16777216 /* ESSymbol */) ? node.left : - someConstituentTypeHasKind(rightType, 16777216 /* ESSymbol */) ? node.right : + var offendingSymbolOperand = someConstituentTypeHasKind(leftType, 16777216 /* ESSymbol */) ? left : + someConstituentTypeHasKind(rightType, 16777216 /* ESSymbol */) ? right : undefined; if (offendingSymbolOperand) { error(offendingSymbolOperand, ts.Diagnostics.The_0_operator_cannot_be_applied_to_type_symbol, ts.tokenToString(operator)); @@ -21962,37 +22544,37 @@ var ts; } function getSuggestedBooleanOperator(operator) { switch (operator) { - case 46 /* BarToken */: - case 65 /* BarEqualsToken */: - return 51 /* BarBarToken */; - case 47 /* CaretToken */: - case 66 /* CaretEqualsToken */: + case 47 /* BarToken */: + case 67 /* BarEqualsToken */: + return 52 /* BarBarToken */; + case 48 /* CaretToken */: + case 68 /* CaretEqualsToken */: return 33 /* ExclamationEqualsEqualsToken */; - case 45 /* AmpersandToken */: - case 64 /* AmpersandEqualsToken */: - return 50 /* AmpersandAmpersandToken */; + case 46 /* AmpersandToken */: + case 66 /* AmpersandEqualsToken */: + return 51 /* AmpersandAmpersandToken */; default: return undefined; } } function checkAssignmentOperator(valueType) { - if (produceDiagnostics && operator >= 55 /* FirstAssignment */ && operator <= 66 /* LastAssignment */) { + if (produceDiagnostics && operator >= 56 /* FirstAssignment */ && operator <= 68 /* LastAssignment */) { // TypeScript 1.0 spec (April 2014): 4.17 // An assignment of the form // VarExpr = ValueExpr // requires VarExpr to be classified as a reference // A compound assignment furthermore requires VarExpr to be classified as a reference (section 4.1) // and the type of the non - compound operation to be assignable to the type of VarExpr. - var ok = checkReferenceExpression(node.left, ts.Diagnostics.Invalid_left_hand_side_of_assignment_expression, ts.Diagnostics.Left_hand_side_of_assignment_expression_cannot_be_a_constant); + var ok = checkReferenceExpression(left, ts.Diagnostics.Invalid_left_hand_side_of_assignment_expression, ts.Diagnostics.Left_hand_side_of_assignment_expression_cannot_be_a_constant); // Use default messages if (ok) { // to avoid cascading errors check assignability only if 'isReference' check succeeded and no errors were reported - checkTypeAssignableTo(valueType, leftType, node.left, /*headMessage*/ undefined); + checkTypeAssignableTo(valueType, leftType, left, /*headMessage*/ undefined); } } } function reportOperatorError() { - error(node, ts.Diagnostics.Operator_0_cannot_be_applied_to_types_1_and_2, ts.tokenToString(node.operatorToken.kind), typeToString(leftType), typeToString(rightType)); + error(errorNode || operatorToken, ts.Diagnostics.Operator_0_cannot_be_applied_to_types_1_and_2, ts.tokenToString(operatorToken.kind), typeToString(leftType), typeToString(rightType)); } } function isYieldExpressionInClass(node) { @@ -22083,7 +22665,7 @@ var ts; // Do not use hasDynamicName here, because that returns false for well known symbols. // We want to perform checkComputedPropertyName for all computed properties, including // well known symbols. - if (node.name.kind === 134 /* ComputedPropertyName */) { + if (node.name.kind === 136 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); } return checkExpression(node.initializer, contextualMapper); @@ -22094,7 +22676,7 @@ var ts; // Do not use hasDynamicName here, because that returns false for well known symbols. // We want to perform checkComputedPropertyName for all computed properties, including // well known symbols. - if (node.name.kind === 134 /* ComputedPropertyName */) { + if (node.name.kind === 136 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); } var uninstantiatedType = checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); @@ -22124,7 +22706,7 @@ var ts; // contextually typed function and arrow expressions in the initial phase. function checkExpression(node, contextualMapper) { var type; - if (node.kind === 133 /* QualifiedName */) { + if (node.kind === 135 /* QualifiedName */) { type = checkQualifiedName(node); } else { @@ -22136,9 +22718,9 @@ var ts; // - 'left' in property access // - 'object' in indexed access // - target in rhs of import statement - var ok = (node.parent.kind === 164 /* PropertyAccessExpression */ && node.parent.expression === node) || - (node.parent.kind === 165 /* ElementAccessExpression */ && node.parent.expression === node) || - ((node.kind === 67 /* Identifier */ || node.kind === 133 /* QualifiedName */) && isInRightSideOfImportOrExportAssignment(node)); + var ok = (node.parent.kind === 166 /* PropertyAccessExpression */ && node.parent.expression === node) || + (node.parent.kind === 167 /* ElementAccessExpression */ && node.parent.expression === node) || + ((node.kind === 69 /* Identifier */ || node.kind === 135 /* QualifiedName */) && isInRightSideOfImportOrExportAssignment(node)); if (!ok) { error(node, ts.Diagnostics.const_enums_can_only_be_used_in_property_or_index_access_expressions_or_the_right_hand_side_of_an_import_declaration_or_export_assignment); } @@ -22152,78 +22734,78 @@ var ts; } function checkExpressionWorker(node, contextualMapper) { switch (node.kind) { - case 67 /* Identifier */: + case 69 /* Identifier */: return checkIdentifier(node); - case 95 /* ThisKeyword */: + case 97 /* ThisKeyword */: return checkThisExpression(node); - case 93 /* SuperKeyword */: + case 95 /* SuperKeyword */: return checkSuperExpression(node); - case 91 /* NullKeyword */: + case 93 /* NullKeyword */: return nullType; - case 97 /* TrueKeyword */: - case 82 /* FalseKeyword */: + case 99 /* TrueKeyword */: + case 84 /* FalseKeyword */: return booleanType; case 8 /* NumericLiteral */: return checkNumericLiteral(node); - case 181 /* TemplateExpression */: + case 183 /* TemplateExpression */: return checkTemplateExpression(node); case 9 /* StringLiteral */: case 11 /* NoSubstitutionTemplateLiteral */: return stringType; case 10 /* RegularExpressionLiteral */: return globalRegExpType; - case 162 /* ArrayLiteralExpression */: + case 164 /* ArrayLiteralExpression */: return checkArrayLiteral(node, contextualMapper); - case 163 /* ObjectLiteralExpression */: + case 165 /* ObjectLiteralExpression */: return checkObjectLiteral(node, contextualMapper); - case 164 /* PropertyAccessExpression */: + case 166 /* PropertyAccessExpression */: return checkPropertyAccessExpression(node); - case 165 /* ElementAccessExpression */: + case 167 /* ElementAccessExpression */: return checkIndexedAccess(node); - case 166 /* CallExpression */: - case 167 /* NewExpression */: + case 168 /* CallExpression */: + case 169 /* NewExpression */: return checkCallExpression(node); - case 168 /* TaggedTemplateExpression */: + case 170 /* TaggedTemplateExpression */: return checkTaggedTemplateExpression(node); - case 170 /* ParenthesizedExpression */: + case 172 /* ParenthesizedExpression */: return checkExpression(node.expression, contextualMapper); - case 184 /* ClassExpression */: + case 186 /* ClassExpression */: return checkClassExpression(node); - case 171 /* FunctionExpression */: - case 172 /* ArrowFunction */: + case 173 /* FunctionExpression */: + case 174 /* ArrowFunction */: return checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); - case 174 /* TypeOfExpression */: + case 176 /* TypeOfExpression */: return checkTypeOfExpression(node); - case 169 /* TypeAssertionExpression */: - case 187 /* AsExpression */: + case 171 /* TypeAssertionExpression */: + case 189 /* AsExpression */: return checkAssertion(node); - case 173 /* DeleteExpression */: + case 175 /* DeleteExpression */: return checkDeleteExpression(node); - case 175 /* VoidExpression */: + case 177 /* VoidExpression */: return checkVoidExpression(node); - case 176 /* AwaitExpression */: + case 178 /* AwaitExpression */: return checkAwaitExpression(node); - case 177 /* PrefixUnaryExpression */: + case 179 /* PrefixUnaryExpression */: return checkPrefixUnaryExpression(node); - case 178 /* PostfixUnaryExpression */: + case 180 /* PostfixUnaryExpression */: return checkPostfixUnaryExpression(node); - case 179 /* BinaryExpression */: + case 181 /* BinaryExpression */: return checkBinaryExpression(node, contextualMapper); - case 180 /* ConditionalExpression */: + case 182 /* ConditionalExpression */: return checkConditionalExpression(node, contextualMapper); - case 183 /* SpreadElementExpression */: + case 185 /* SpreadElementExpression */: return checkSpreadElementExpression(node, contextualMapper); - case 185 /* OmittedExpression */: + case 187 /* OmittedExpression */: return undefinedType; - case 182 /* YieldExpression */: + case 184 /* YieldExpression */: return checkYieldExpression(node); - case 238 /* JsxExpression */: + case 240 /* JsxExpression */: return checkJsxExpression(node); - case 231 /* JsxElement */: + case 233 /* JsxElement */: return checkJsxElement(node); - case 232 /* JsxSelfClosingElement */: + case 234 /* JsxSelfClosingElement */: return checkJsxSelfClosingElement(node); - case 233 /* JsxOpeningElement */: + case 235 /* JsxOpeningElement */: ts.Debug.fail("Shouldn't ever directly check a JsxOpeningElement"); } return unknownType; @@ -22252,7 +22834,7 @@ var ts; var func = ts.getContainingFunction(node); if (node.flags & 112 /* AccessibilityModifier */) { func = ts.getContainingFunction(node); - if (!(func.kind === 142 /* Constructor */ && ts.nodeIsPresent(func.body))) { + if (!(func.kind === 144 /* Constructor */ && ts.nodeIsPresent(func.body))) { error(node, ts.Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation); } } @@ -22269,15 +22851,15 @@ var ts; if (!node.asteriskToken || !node.body) { return false; } - return node.kind === 141 /* MethodDeclaration */ || - node.kind === 211 /* FunctionDeclaration */ || - node.kind === 171 /* FunctionExpression */; + return node.kind === 143 /* MethodDeclaration */ || + node.kind === 213 /* FunctionDeclaration */ || + node.kind === 173 /* FunctionExpression */; } function getTypePredicateParameterIndex(parameterList, parameter) { if (parameterList) { for (var i = 0; i < parameterList.length; i++) { var param = parameterList[i]; - if (param.name.kind === 67 /* Identifier */ && + if (param.name.kind === 69 /* Identifier */ && param.name.text === parameter.text) { return i; } @@ -22287,31 +22869,31 @@ var ts; } function isInLegalTypePredicatePosition(node) { switch (node.parent.kind) { - case 172 /* ArrowFunction */: - case 145 /* CallSignature */: - case 211 /* FunctionDeclaration */: - case 171 /* FunctionExpression */: - case 150 /* FunctionType */: - case 141 /* MethodDeclaration */: - case 140 /* MethodSignature */: + case 174 /* ArrowFunction */: + case 147 /* CallSignature */: + case 213 /* FunctionDeclaration */: + case 173 /* FunctionExpression */: + case 152 /* FunctionType */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: return node === node.parent.type; } return false; } function checkSignatureDeclaration(node) { // Grammar checking - if (node.kind === 147 /* IndexSignature */) { + if (node.kind === 149 /* IndexSignature */) { checkGrammarIndexSignature(node); } - else if (node.kind === 150 /* FunctionType */ || node.kind === 211 /* FunctionDeclaration */ || node.kind === 151 /* ConstructorType */ || - node.kind === 145 /* CallSignature */ || node.kind === 142 /* Constructor */ || - node.kind === 146 /* ConstructSignature */) { + else if (node.kind === 152 /* FunctionType */ || node.kind === 213 /* FunctionDeclaration */ || node.kind === 153 /* ConstructorType */ || + node.kind === 147 /* CallSignature */ || node.kind === 144 /* Constructor */ || + node.kind === 148 /* ConstructSignature */) { checkGrammarFunctionLikeDeclaration(node); } checkTypeParameters(node.typeParameters); ts.forEach(node.parameters, checkParameter); if (node.type) { - if (node.type.kind === 148 /* TypePredicate */) { + if (node.type.kind === 150 /* TypePredicate */) { var typePredicate = getSignatureFromDeclaration(node).typePredicate; var typePredicateNode = node.type; if (isInLegalTypePredicatePosition(typePredicateNode)) { @@ -22330,19 +22912,19 @@ var ts; if (hasReportedError) { break; } - if (param.name.kind === 159 /* ObjectBindingPattern */ || - param.name.kind === 160 /* ArrayBindingPattern */) { + if (param.name.kind === 161 /* ObjectBindingPattern */ || + param.name.kind === 162 /* ArrayBindingPattern */) { (function checkBindingPattern(pattern) { for (var _i = 0, _a = pattern.elements; _i < _a.length; _i++) { var element = _a[_i]; - if (element.name.kind === 67 /* Identifier */ && + if (element.name.kind === 69 /* Identifier */ && element.name.text === typePredicate.parameterName) { error(typePredicateNode.parameterName, ts.Diagnostics.A_type_predicate_cannot_reference_element_0_in_a_binding_pattern, typePredicate.parameterName); hasReportedError = true; break; } - else if (element.name.kind === 160 /* ArrayBindingPattern */ || - element.name.kind === 159 /* ObjectBindingPattern */) { + else if (element.name.kind === 162 /* ArrayBindingPattern */ || + element.name.kind === 161 /* ObjectBindingPattern */) { checkBindingPattern(element.name); } } @@ -22366,10 +22948,10 @@ var ts; checkCollisionWithArgumentsInGeneratedCode(node); if (compilerOptions.noImplicitAny && !node.type) { switch (node.kind) { - case 146 /* ConstructSignature */: + case 148 /* ConstructSignature */: error(node, ts.Diagnostics.Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; - case 145 /* CallSignature */: + case 147 /* CallSignature */: error(node, ts.Diagnostics.Call_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; } @@ -22397,7 +22979,7 @@ var ts; checkSpecializedSignatureDeclaration(node); } function checkTypeForDuplicateIndexSignatures(node) { - if (node.kind === 213 /* InterfaceDeclaration */) { + if (node.kind === 215 /* InterfaceDeclaration */) { var nodeSymbol = getSymbolOfNode(node); // in case of merging interface declaration it is possible that we'll enter this check procedure several times for every declaration // to prevent this run check only for the first declaration of a given kind @@ -22417,7 +22999,7 @@ var ts; var declaration = decl; if (declaration.parameters.length === 1 && declaration.parameters[0].type) { switch (declaration.parameters[0].type.kind) { - case 128 /* StringKeyword */: + case 130 /* StringKeyword */: if (!seenStringIndexer) { seenStringIndexer = true; } @@ -22425,7 +23007,7 @@ var ts; error(declaration, ts.Diagnostics.Duplicate_string_index_signature); } break; - case 126 /* NumberKeyword */: + case 128 /* NumberKeyword */: if (!seenNumericIndexer) { seenNumericIndexer = true; } @@ -22474,7 +23056,7 @@ var ts; return; } function isSuperCallExpression(n) { - return n.kind === 166 /* CallExpression */ && n.expression.kind === 93 /* SuperKeyword */; + return n.kind === 168 /* CallExpression */ && n.expression.kind === 95 /* SuperKeyword */; } function containsSuperCallAsComputedPropertyName(n) { return n.name && containsSuperCall(n.name); @@ -22492,15 +23074,15 @@ var ts; return ts.forEachChild(n, containsSuperCall); } function markThisReferencesAsErrors(n) { - if (n.kind === 95 /* ThisKeyword */) { + if (n.kind === 97 /* ThisKeyword */) { error(n, ts.Diagnostics.this_cannot_be_referenced_in_current_location); } - else if (n.kind !== 171 /* FunctionExpression */ && n.kind !== 211 /* FunctionDeclaration */) { + else if (n.kind !== 173 /* FunctionExpression */ && n.kind !== 213 /* FunctionDeclaration */) { ts.forEachChild(n, markThisReferencesAsErrors); } } function isInstancePropertyWithInitializer(n) { - return n.kind === 139 /* PropertyDeclaration */ && + return n.kind === 141 /* PropertyDeclaration */ && !(n.flags & 128 /* Static */) && !!n.initializer; } @@ -22530,7 +23112,7 @@ var ts; var superCallStatement; for (var _i = 0; _i < statements.length; _i++) { var statement = statements[_i]; - if (statement.kind === 193 /* ExpressionStatement */ && isSuperCallExpression(statement.expression)) { + if (statement.kind === 195 /* ExpressionStatement */ && isSuperCallExpression(statement.expression)) { superCallStatement = statement; break; } @@ -22556,7 +23138,7 @@ var ts; if (produceDiagnostics) { // Grammar checking accessors checkGrammarFunctionLikeDeclaration(node) || checkGrammarAccessor(node) || checkGrammarComputedPropertyName(node.name); - if (node.kind === 143 /* GetAccessor */) { + if (node.kind === 145 /* GetAccessor */) { if (!ts.isInAmbientContext(node) && ts.nodeIsPresent(node.body) && !(bodyContainsAReturnStatement(node.body) || bodyContainsSingleThrowStatement(node.body))) { error(node.name, ts.Diagnostics.A_get_accessor_must_return_a_value_or_consist_of_a_single_throw_statement); } @@ -22564,7 +23146,7 @@ var ts; if (!ts.hasDynamicName(node)) { // TypeScript 1.0 spec (April 2014): 8.4.3 // Accessors for the same member name must specify the same accessibility. - var otherKind = node.kind === 143 /* GetAccessor */ ? 144 /* SetAccessor */ : 143 /* GetAccessor */; + var otherKind = node.kind === 145 /* GetAccessor */ ? 146 /* SetAccessor */ : 145 /* GetAccessor */; var otherAccessor = ts.getDeclarationOfKind(node.symbol, otherKind); if (otherAccessor) { if (((node.flags & 112 /* AccessibilityModifier */) !== (otherAccessor.flags & 112 /* AccessibilityModifier */))) { @@ -22660,9 +23242,9 @@ var ts; var signaturesToCheck; // Unnamed (call\construct) signatures in interfaces are inherited and not shadowed so examining just node symbol won't give complete answer. // Use declaring type to obtain full list of signatures. - if (!signatureDeclarationNode.name && signatureDeclarationNode.parent && signatureDeclarationNode.parent.kind === 213 /* InterfaceDeclaration */) { - ts.Debug.assert(signatureDeclarationNode.kind === 145 /* CallSignature */ || signatureDeclarationNode.kind === 146 /* ConstructSignature */); - var signatureKind = signatureDeclarationNode.kind === 145 /* CallSignature */ ? 0 /* Call */ : 1 /* Construct */; + if (!signatureDeclarationNode.name && signatureDeclarationNode.parent && signatureDeclarationNode.parent.kind === 215 /* InterfaceDeclaration */) { + ts.Debug.assert(signatureDeclarationNode.kind === 147 /* CallSignature */ || signatureDeclarationNode.kind === 148 /* ConstructSignature */); + var signatureKind = signatureDeclarationNode.kind === 147 /* CallSignature */ ? 0 /* Call */ : 1 /* Construct */; var containingSymbol = getSymbolOfNode(signatureDeclarationNode.parent); var containingType = getDeclaredTypeOfSymbol(containingSymbol); signaturesToCheck = getSignaturesOfType(containingType, signatureKind); @@ -22680,7 +23262,7 @@ var ts; } function getEffectiveDeclarationFlags(n, flagsToCheck) { var flags = ts.getCombinedNodeFlags(n); - if (n.parent.kind !== 213 /* InterfaceDeclaration */ && ts.isInAmbientContext(n)) { + if (n.parent.kind !== 215 /* InterfaceDeclaration */ && ts.isInAmbientContext(n)) { if (!(flags & 2 /* Ambient */)) { // It is nested in an ambient context, which means it is automatically exported flags |= 1 /* Export */; @@ -22766,7 +23348,7 @@ var ts; // TODO(jfreeman): These are methods, so handle computed name case if (node.name && subsequentNode.name && node.name.text === subsequentNode.name.text) { // the only situation when this is possible (same kind\same name but different symbol) - mixed static and instance class members - ts.Debug.assert(node.kind === 141 /* MethodDeclaration */ || node.kind === 140 /* MethodSignature */); + ts.Debug.assert(node.kind === 143 /* MethodDeclaration */ || node.kind === 142 /* MethodSignature */); ts.Debug.assert((node.flags & 128 /* Static */) !== (subsequentNode.flags & 128 /* Static */)); var diagnostic = node.flags & 128 /* Static */ ? ts.Diagnostics.Function_overload_must_be_static : ts.Diagnostics.Function_overload_must_not_be_static; error(errorNode_1, diagnostic); @@ -22802,7 +23384,7 @@ var ts; var current = declarations[_i]; var node = current; var inAmbientContext = ts.isInAmbientContext(node); - var inAmbientContextOrInterface = node.parent.kind === 213 /* InterfaceDeclaration */ || node.parent.kind === 153 /* TypeLiteral */ || inAmbientContext; + var inAmbientContextOrInterface = node.parent.kind === 215 /* InterfaceDeclaration */ || node.parent.kind === 155 /* TypeLiteral */ || inAmbientContext; if (inAmbientContextOrInterface) { // check if declarations are consecutive only if they are non-ambient // 1. ambient declarations can be interleaved @@ -22813,7 +23395,7 @@ var ts; // 2. mixing ambient and non-ambient declarations is a separate error that will be reported - do not want to report an extra one previousDeclaration = undefined; } - if (node.kind === 211 /* FunctionDeclaration */ || node.kind === 141 /* MethodDeclaration */ || node.kind === 140 /* MethodSignature */ || node.kind === 142 /* Constructor */) { + if (node.kind === 213 /* FunctionDeclaration */ || node.kind === 143 /* MethodDeclaration */ || node.kind === 142 /* MethodSignature */ || node.kind === 144 /* Constructor */) { var currentNodeFlags = getEffectiveDeclarationFlags(node, flagsToCheck); someNodeFlags |= currentNodeFlags; allNodeFlags &= currentNodeFlags; @@ -22953,16 +23535,16 @@ var ts; } function getDeclarationSpaces(d) { switch (d.kind) { - case 213 /* InterfaceDeclaration */: + case 215 /* InterfaceDeclaration */: return 2097152 /* ExportType */; - case 216 /* ModuleDeclaration */: + case 218 /* ModuleDeclaration */: return d.name.kind === 9 /* StringLiteral */ || ts.getModuleInstanceState(d) !== 0 /* NonInstantiated */ ? 4194304 /* ExportNamespace */ | 1048576 /* ExportValue */ : 4194304 /* ExportNamespace */; - case 212 /* ClassDeclaration */: - case 215 /* EnumDeclaration */: + case 214 /* ClassDeclaration */: + case 217 /* EnumDeclaration */: return 2097152 /* ExportType */ | 1048576 /* ExportValue */; - case 219 /* ImportEqualsDeclaration */: + case 221 /* ImportEqualsDeclaration */: var result = 0; var target = resolveAlias(getSymbolOfNode(d)); ts.forEach(target.declarations, function (d) { result |= getDeclarationSpaces(d); }); @@ -22973,7 +23555,8 @@ var ts; } } function checkNonThenableType(type, location, message) { - if (!(type.flags & 1 /* Any */) && isTypeAssignableTo(type, getGlobalThenableType())) { + type = getWidenedType(type); + if (!isTypeAny(type) && isTypeAssignableTo(type, getGlobalThenableType())) { if (location) { if (!message) { message = ts.Diagnostics.Operand_for_await_does_not_have_a_valid_callable_then_member; @@ -23206,22 +23789,22 @@ var ts; var headMessage = getDiagnosticHeadMessageForDecoratorResolution(node); var errorInfo; switch (node.parent.kind) { - case 212 /* ClassDeclaration */: + case 214 /* ClassDeclaration */: var classSymbol = getSymbolOfNode(node.parent); var classConstructorType = getTypeOfSymbol(classSymbol); expectedReturnType = getUnionType([classConstructorType, voidType]); break; - case 136 /* Parameter */: + case 138 /* Parameter */: expectedReturnType = voidType; errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.The_return_type_of_a_parameter_decorator_function_must_be_either_void_or_any); break; - case 139 /* PropertyDeclaration */: + case 141 /* PropertyDeclaration */: expectedReturnType = voidType; errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.The_return_type_of_a_property_decorator_function_must_be_either_void_or_any); break; - case 141 /* MethodDeclaration */: - case 143 /* GetAccessor */: - case 144 /* SetAccessor */: + case 143 /* MethodDeclaration */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: var methodType = getTypeOfNode(node.parent); var descriptorType = createTypedPropertyDescriptorType(methodType); expectedReturnType = getUnionType([descriptorType, voidType]); @@ -23234,9 +23817,9 @@ var ts; // When we are emitting type metadata for decorators, we need to try to check the type // as if it were an expression so that we can emit the type in a value position when we // serialize the type metadata. - if (node && node.kind === 149 /* TypeReference */) { + if (node && node.kind === 151 /* TypeReference */) { var root = getFirstIdentifier(node.typeName); - var meaning = root.parent.kind === 149 /* TypeReference */ ? 793056 /* Type */ : 1536 /* Namespace */; + var meaning = root.parent.kind === 151 /* TypeReference */ ? 793056 /* Type */ : 1536 /* Namespace */; // Resolve type so we know which symbol is referenced var rootSymbol = resolveName(root, root.text, meaning | 8388608 /* Alias */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined); // Resolved symbol is alias @@ -23255,19 +23838,19 @@ var ts; */ function checkTypeAnnotationAsExpression(node) { switch (node.kind) { - case 139 /* PropertyDeclaration */: + case 141 /* PropertyDeclaration */: checkTypeNodeAsExpression(node.type); break; - case 136 /* Parameter */: + case 138 /* Parameter */: checkTypeNodeAsExpression(node.type); break; - case 141 /* MethodDeclaration */: + case 143 /* MethodDeclaration */: checkTypeNodeAsExpression(node.type); break; - case 143 /* GetAccessor */: + case 145 /* GetAccessor */: checkTypeNodeAsExpression(node.type); break; - case 144 /* SetAccessor */: + case 146 /* SetAccessor */: checkTypeNodeAsExpression(ts.getSetAccessorTypeAnnotationNode(node)); break; } @@ -23296,25 +23879,25 @@ var ts; if (compilerOptions.emitDecoratorMetadata) { // we only need to perform these checks if we are emitting serialized type metadata for the target of a decorator. switch (node.kind) { - case 212 /* ClassDeclaration */: + case 214 /* ClassDeclaration */: var constructor = ts.getFirstConstructorWithBody(node); if (constructor) { checkParameterTypeAnnotationsAsExpressions(constructor); } break; - case 141 /* MethodDeclaration */: + case 143 /* MethodDeclaration */: checkParameterTypeAnnotationsAsExpressions(node); // fall-through - case 144 /* SetAccessor */: - case 143 /* GetAccessor */: - case 139 /* PropertyDeclaration */: - case 136 /* Parameter */: + case 146 /* SetAccessor */: + case 145 /* GetAccessor */: + case 141 /* PropertyDeclaration */: + case 138 /* Parameter */: checkTypeAnnotationAsExpression(node); break; } } emitDecorate = true; - if (node.kind === 136 /* Parameter */) { + if (node.kind === 138 /* Parameter */) { emitParam = true; } ts.forEach(node.decorators, checkDecorator); @@ -23332,15 +23915,12 @@ var ts; checkSignatureDeclaration(node); var isAsync = ts.isAsyncFunctionLike(node); if (isAsync) { - if (!compilerOptions.experimentalAsyncFunctions) { - error(node, ts.Diagnostics.Experimental_support_for_async_functions_is_a_feature_that_is_subject_to_change_in_a_future_release_Specify_experimentalAsyncFunctions_to_remove_this_warning); - } emitAwaiter = true; } // Do not use hasDynamicName here, because that returns false for well known symbols. // We want to perform checkComputedPropertyName for all computed properties, including // well known symbols. - if (node.name && node.name.kind === 134 /* ComputedPropertyName */) { + if (node.name && node.name.kind === 136 /* ComputedPropertyName */) { // This check will account for methods in class/interface declarations, // as well as accessors in classes/object literals checkComputedPropertyName(node.name); @@ -23389,11 +23969,11 @@ var ts; } function checkBlock(node) { // Grammar checking for SyntaxKind.Block - if (node.kind === 190 /* Block */) { + if (node.kind === 192 /* Block */) { checkGrammarStatementInAmbientContext(node); } ts.forEach(node.statements, checkSourceElement); - if (ts.isFunctionBlock(node) || node.kind === 217 /* ModuleBlock */) { + if (ts.isFunctionBlock(node) || node.kind === 219 /* ModuleBlock */) { checkFunctionAndClassExpressionBodies(node); } } @@ -23412,12 +23992,12 @@ var ts; if (!(identifier && identifier.text === name)) { return false; } - if (node.kind === 139 /* PropertyDeclaration */ || - node.kind === 138 /* PropertySignature */ || - node.kind === 141 /* MethodDeclaration */ || - node.kind === 140 /* MethodSignature */ || - node.kind === 143 /* GetAccessor */ || - node.kind === 144 /* SetAccessor */) { + if (node.kind === 141 /* PropertyDeclaration */ || + node.kind === 140 /* PropertySignature */ || + node.kind === 143 /* MethodDeclaration */ || + node.kind === 142 /* MethodSignature */ || + node.kind === 145 /* GetAccessor */ || + node.kind === 146 /* SetAccessor */) { // it is ok to have member named '_super' or '_this' - member access is always qualified return false; } @@ -23426,7 +24006,7 @@ var ts; return false; } var root = ts.getRootDeclaration(node); - if (root.kind === 136 /* Parameter */ && ts.nodeIsMissing(root.parent.body)) { + if (root.kind === 138 /* Parameter */ && ts.nodeIsMissing(root.parent.body)) { // just an overload - no codegen impact return false; } @@ -23442,7 +24022,7 @@ var ts; var current = node; while (current) { if (getNodeCheckFlags(current) & 4 /* CaptureThis */) { - var isDeclaration_1 = node.kind !== 67 /* Identifier */; + var isDeclaration_1 = node.kind !== 69 /* Identifier */; if (isDeclaration_1) { error(node.name, ts.Diagnostics.Duplicate_identifier_this_Compiler_uses_variable_declaration_this_to_capture_this_reference); } @@ -23465,7 +24045,7 @@ var ts; return; } if (ts.getClassExtendsHeritageClauseElement(enclosingClass)) { - var isDeclaration_2 = node.kind !== 67 /* Identifier */; + var isDeclaration_2 = node.kind !== 69 /* Identifier */; if (isDeclaration_2) { error(node, ts.Diagnostics.Duplicate_identifier_super_Compiler_uses_super_to_capture_base_class_reference); } @@ -23479,12 +24059,12 @@ var ts; return; } // Uninstantiated modules shouldnt do this check - if (node.kind === 216 /* ModuleDeclaration */ && ts.getModuleInstanceState(node) !== 1 /* Instantiated */) { + if (node.kind === 218 /* ModuleDeclaration */ && ts.getModuleInstanceState(node) !== 1 /* Instantiated */) { return; } // In case of variable declaration, node.parent is variable statement so look at the variable statement's parent var parent = getDeclarationContainer(node); - if (parent.kind === 246 /* SourceFile */ && ts.isExternalModule(parent)) { + if (parent.kind === 248 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent)) { // If the declaration happens to be in external module, report error that require and exports are reserved keywords error(name, ts.Diagnostics.Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module, ts.declarationNameToString(name), ts.declarationNameToString(name)); } @@ -23519,7 +24099,7 @@ var ts; // skip variable declarations that don't have initializers // NOTE: in ES6 spec initializer is required in variable declarations where name is binding pattern // so we'll always treat binding elements as initialized - if (node.kind === 209 /* VariableDeclaration */ && !node.initializer) { + if (node.kind === 211 /* VariableDeclaration */ && !node.initializer) { return; } var symbol = getSymbolOfNode(node); @@ -23529,17 +24109,17 @@ var ts; localDeclarationSymbol !== symbol && localDeclarationSymbol.flags & 2 /* BlockScopedVariable */) { if (getDeclarationFlagsFromSymbol(localDeclarationSymbol) & 49152 /* BlockScoped */) { - var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 210 /* VariableDeclarationList */); - var container = varDeclList.parent.kind === 191 /* VariableStatement */ && varDeclList.parent.parent + var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 212 /* VariableDeclarationList */); + var container = varDeclList.parent.kind === 193 /* VariableStatement */ && varDeclList.parent.parent ? varDeclList.parent.parent : undefined; // names of block-scoped and function scoped variables can collide only // if block scoped variable is defined in the function\module\source file scope (because of variable hoisting) var namesShareScope = container && - (container.kind === 190 /* Block */ && ts.isFunctionLike(container.parent) || - container.kind === 217 /* ModuleBlock */ || - container.kind === 216 /* ModuleDeclaration */ || - container.kind === 246 /* SourceFile */); + (container.kind === 192 /* Block */ && ts.isFunctionLike(container.parent) || + container.kind === 219 /* ModuleBlock */ || + container.kind === 218 /* ModuleDeclaration */ || + container.kind === 248 /* SourceFile */); // here we know that function scoped variable is shadowed by block scoped one // if they are defined in the same scope - binder has already reported redeclaration error // otherwise if variable has an initializer - show error that initialization will fail @@ -23554,18 +24134,18 @@ var ts; } // Check that a parameter initializer contains no references to parameters declared to the right of itself function checkParameterInitializer(node) { - if (ts.getRootDeclaration(node).kind !== 136 /* Parameter */) { + if (ts.getRootDeclaration(node).kind !== 138 /* Parameter */) { return; } var func = ts.getContainingFunction(node); visit(node.initializer); function visit(n) { - if (n.kind === 67 /* Identifier */) { + if (n.kind === 69 /* Identifier */) { var referencedSymbol = getNodeLinks(n).resolvedSymbol; // check FunctionLikeDeclaration.locals (stores parameters\function local variable) // if it contains entry with a specified name and if this entry matches the resolved symbol if (referencedSymbol && referencedSymbol !== unknownSymbol && getSymbol(func.locals, referencedSymbol.name, 107455 /* Value */) === referencedSymbol) { - if (referencedSymbol.valueDeclaration.kind === 136 /* Parameter */) { + if (referencedSymbol.valueDeclaration.kind === 138 /* Parameter */) { if (referencedSymbol.valueDeclaration === node) { error(n, ts.Diagnostics.Parameter_0_cannot_be_referenced_in_its_initializer, ts.declarationNameToString(node.name)); return; @@ -23591,7 +24171,7 @@ var ts; // Do not use hasDynamicName here, because that returns false for well known symbols. // We want to perform checkComputedPropertyName for all computed properties, including // well known symbols. - if (node.name.kind === 134 /* ComputedPropertyName */) { + if (node.name.kind === 136 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); if (node.initializer) { checkExpressionCached(node.initializer); @@ -23602,7 +24182,7 @@ var ts; ts.forEach(node.name.elements, checkSourceElement); } // For a parameter declaration with an initializer, error and exit if the containing function doesn't have a body - if (node.initializer && ts.getRootDeclaration(node).kind === 136 /* Parameter */ && ts.nodeIsMissing(ts.getContainingFunction(node).body)) { + if (node.initializer && ts.getRootDeclaration(node).kind === 138 /* Parameter */ && ts.nodeIsMissing(ts.getContainingFunction(node).body)) { error(node, ts.Diagnostics.A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation); return; } @@ -23634,10 +24214,10 @@ var ts; checkTypeAssignableTo(checkExpressionCached(node.initializer), declarationType, node, /*headMessage*/ undefined); } } - if (node.kind !== 139 /* PropertyDeclaration */ && node.kind !== 138 /* PropertySignature */) { + if (node.kind !== 141 /* PropertyDeclaration */ && node.kind !== 140 /* PropertySignature */) { // We know we don't have a binding pattern or computed name here checkExportsOnMergedDeclarations(node); - if (node.kind === 209 /* VariableDeclaration */ || node.kind === 161 /* BindingElement */) { + if (node.kind === 211 /* VariableDeclaration */ || node.kind === 163 /* BindingElement */) { checkVarDeclaredNamesNotShadowed(node); } checkCollisionWithCapturedSuperVariable(node, node.name); @@ -23660,7 +24240,7 @@ var ts; } function checkGrammarDisallowedModifiersOnObjectLiteralExpressionMethod(node) { // We only disallow modifier on a method declaration if it is a property of object-literal-expression - if (node.modifiers && node.parent.kind === 163 /* ObjectLiteralExpression */) { + if (node.modifiers && node.parent.kind === 165 /* ObjectLiteralExpression */) { if (ts.isAsyncFunctionLike(node)) { if (node.modifiers.length > 1) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); @@ -23698,12 +24278,12 @@ var ts; function checkForStatement(node) { // Grammar checking if (!checkGrammarStatementInAmbientContext(node)) { - if (node.initializer && node.initializer.kind === 210 /* VariableDeclarationList */) { + if (node.initializer && node.initializer.kind === 212 /* VariableDeclarationList */) { checkGrammarVariableDeclarationList(node.initializer); } } if (node.initializer) { - if (node.initializer.kind === 210 /* VariableDeclarationList */) { + if (node.initializer.kind === 212 /* VariableDeclarationList */) { ts.forEach(node.initializer.declarations, checkVariableDeclaration); } else { @@ -23723,14 +24303,14 @@ var ts; // via checkRightHandSideOfForOf. // If the LHS is an expression, check the LHS, as a destructuring assignment or as a reference. // Then check that the RHS is assignable to it. - if (node.initializer.kind === 210 /* VariableDeclarationList */) { + if (node.initializer.kind === 212 /* VariableDeclarationList */) { checkForInOrForOfVariableDeclaration(node); } else { var varExpr = node.initializer; var iteratedType = checkRightHandSideOfForOf(node.expression); // There may be a destructuring assignment on the left side - if (varExpr.kind === 162 /* ArrayLiteralExpression */ || varExpr.kind === 163 /* ObjectLiteralExpression */) { + if (varExpr.kind === 164 /* ArrayLiteralExpression */ || varExpr.kind === 165 /* ObjectLiteralExpression */) { // iteratedType may be undefined. In this case, we still want to check the structure of // varExpr, in particular making sure it's a valid LeftHandSideExpression. But we'd like // to short circuit the type relation checking as much as possible, so we pass the unknownType. @@ -23759,7 +24339,7 @@ var ts; // for (let VarDecl in Expr) Statement // VarDecl must be a variable declaration without a type annotation that declares a variable of type Any, // and Expr must be an expression of type Any, an object type, or a type parameter type. - if (node.initializer.kind === 210 /* VariableDeclarationList */) { + if (node.initializer.kind === 212 /* VariableDeclarationList */) { var variable = node.initializer.declarations[0]; if (variable && ts.isBindingPattern(variable.name)) { error(variable.name, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern); @@ -23773,7 +24353,7 @@ var ts; // and Expr must be an expression of type Any, an object type, or a type parameter type. var varExpr = node.initializer; var leftType = checkExpression(varExpr); - if (varExpr.kind === 162 /* ArrayLiteralExpression */ || varExpr.kind === 163 /* ObjectLiteralExpression */) { + if (varExpr.kind === 164 /* ArrayLiteralExpression */ || varExpr.kind === 165 /* ObjectLiteralExpression */) { error(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern); } else if (!isTypeAnyOrAllConstituentTypesHaveKind(leftType, 258 /* StringLike */)) { @@ -24012,7 +24592,7 @@ var ts; // TODO: Check that target label is valid } function isGetAccessorWithAnnotatatedSetAccessor(node) { - return !!(node.kind === 143 /* GetAccessor */ && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(node.symbol, 144 /* SetAccessor */))); + return !!(node.kind === 145 /* GetAccessor */ && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(node.symbol, 146 /* SetAccessor */))); } function checkReturnStatement(node) { // Grammar checking @@ -24035,10 +24615,10 @@ var ts; // for generators. return; } - if (func.kind === 144 /* SetAccessor */) { + if (func.kind === 146 /* SetAccessor */) { error(node.expression, ts.Diagnostics.Setters_cannot_return_a_value); } - else if (func.kind === 142 /* Constructor */) { + else if (func.kind === 144 /* Constructor */) { if (!isTypeAssignableTo(exprType, returnType)) { error(node.expression, ts.Diagnostics.Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class); } @@ -24047,7 +24627,12 @@ var ts; if (ts.isAsyncFunctionLike(func)) { var promisedType = getPromisedType(returnType); var awaitedType = checkAwaitedType(exprType, node.expression, ts.Diagnostics.Return_expression_in_async_function_does_not_have_a_valid_callable_then_member); - checkTypeAssignableTo(awaitedType, promisedType, node.expression); + if (promisedType) { + // If the function has a return type, but promisedType is + // undefined, an error will be reported in checkAsyncFunctionReturnType + // so we don't need to report one here. + checkTypeAssignableTo(awaitedType, promisedType, node.expression); + } } else { checkTypeAssignableTo(exprType, returnType, node.expression); @@ -24074,7 +24659,7 @@ var ts; var expressionType = checkExpression(node.expression); ts.forEach(node.caseBlock.clauses, function (clause) { // Grammar check for duplicate default clauses, skip if we already report duplicate default clause - if (clause.kind === 240 /* DefaultClause */ && !hasDuplicateDefaultClause) { + if (clause.kind === 242 /* DefaultClause */ && !hasDuplicateDefaultClause) { if (firstDefaultClause === undefined) { firstDefaultClause = clause; } @@ -24086,7 +24671,7 @@ var ts; hasDuplicateDefaultClause = true; } } - if (produceDiagnostics && clause.kind === 239 /* CaseClause */) { + if (produceDiagnostics && clause.kind === 241 /* CaseClause */) { var caseClause = clause; // TypeScript 1.0 spec (April 2014):5.9 // In a 'switch' statement, each 'case' expression must be of a type that is assignable to or from the type of the 'switch' expression. @@ -24107,7 +24692,7 @@ var ts; if (ts.isFunctionLike(current)) { break; } - if (current.kind === 205 /* LabeledStatement */ && current.label.text === node.label.text) { + if (current.kind === 207 /* LabeledStatement */ && current.label.text === node.label.text) { var sourceFile = ts.getSourceFileOfNode(node); grammarErrorOnNode(node.label, ts.Diagnostics.Duplicate_label_0, ts.getTextOfNodeFromSourceText(sourceFile.text, node.label)); break; @@ -24137,7 +24722,7 @@ var ts; if (catchClause) { // Grammar checking if (catchClause.variableDeclaration) { - if (catchClause.variableDeclaration.name.kind !== 67 /* Identifier */) { + if (catchClause.variableDeclaration.name.kind !== 69 /* Identifier */) { grammarErrorOnFirstToken(catchClause.variableDeclaration.name, ts.Diagnostics.Catch_clause_variable_name_must_be_an_identifier); } else if (catchClause.variableDeclaration.type) { @@ -24212,7 +24797,7 @@ var ts; // perform property check if property or indexer is declared in 'type' // this allows to rule out cases when both property and indexer are inherited from the base class var errorNode; - if (prop.valueDeclaration.name.kind === 134 /* ComputedPropertyName */ || prop.parent === containingType.symbol) { + if (prop.valueDeclaration.name.kind === 136 /* ComputedPropertyName */ || prop.parent === containingType.symbol) { errorNode = prop.valueDeclaration; } else if (indexDeclaration) { @@ -24289,6 +24874,7 @@ var ts; checkExportsOnMergedDeclarations(node); var symbol = getSymbolOfNode(node); var type = getDeclaredTypeOfSymbol(symbol); + var typeWithThis = getTypeWithThisArgument(type); var staticType = getTypeOfSymbol(symbol); var baseTypeNode = ts.getClassExtendsHeritageClauseElement(node); if (baseTypeNode) { @@ -24307,7 +24893,7 @@ var ts; } } } - checkTypeAssignableTo(type, baseType, node.name || node, ts.Diagnostics.Class_0_incorrectly_extends_base_class_1); + checkTypeAssignableTo(typeWithThis, getTypeWithThisArgument(baseType, type.thisType), node.name || node, ts.Diagnostics.Class_0_incorrectly_extends_base_class_1); checkTypeAssignableTo(staticType, getTypeWithoutSignatures(staticBaseType), node.name || node, ts.Diagnostics.Class_static_side_0_incorrectly_extends_base_class_static_side_1); if (!(staticBaseType.symbol && staticBaseType.symbol.flags & 32 /* Class */)) { // When the static base type is a "class-like" constructor function (but not actually a class), we verify @@ -24324,7 +24910,8 @@ var ts; } var implementedTypeNodes = ts.getClassImplementsHeritageClauseElements(node); if (implementedTypeNodes) { - ts.forEach(implementedTypeNodes, function (typeRefNode) { + for (var _b = 0; _b < implementedTypeNodes.length; _b++) { + var typeRefNode = implementedTypeNodes[_b]; if (!ts.isSupportedExpressionWithTypeArguments(typeRefNode)) { error(typeRefNode.expression, ts.Diagnostics.A_class_can_only_implement_an_identifier_Slashqualified_name_with_optional_type_arguments); } @@ -24334,14 +24921,14 @@ var ts; if (t !== unknownType) { var declaredType = (t.flags & 4096 /* Reference */) ? t.target : t; if (declaredType.flags & (1024 /* Class */ | 2048 /* Interface */)) { - checkTypeAssignableTo(type, t, node.name || node, ts.Diagnostics.Class_0_incorrectly_implements_interface_1); + checkTypeAssignableTo(typeWithThis, getTypeWithThisArgument(t, type.thisType), node.name || node, ts.Diagnostics.Class_0_incorrectly_implements_interface_1); } else { error(typeRefNode, ts.Diagnostics.A_class_may_only_implement_another_class_or_interface); } } } - }); + } } if (produceDiagnostics) { checkIndexConstraints(type); @@ -24392,7 +24979,7 @@ var ts; // If there is no declaration for the derived class (as in the case of class expressions), // then the class cannot be declared abstract. if (baseDeclarationFlags & 256 /* Abstract */ && (!derivedClassDecl || !(derivedClassDecl.flags & 256 /* Abstract */))) { - if (derivedClassDecl.kind === 184 /* ClassExpression */) { + if (derivedClassDecl.kind === 186 /* ClassExpression */) { error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1, symbolToString(baseProperty), typeToString(baseType)); } else { @@ -24440,7 +25027,7 @@ var ts; } } function isAccessor(kind) { - return kind === 143 /* GetAccessor */ || kind === 144 /* SetAccessor */; + return kind === 145 /* GetAccessor */ || kind === 146 /* SetAccessor */; } function areTypeParametersIdentical(list1, list2) { if (!list1 && !list2) { @@ -24480,7 +25067,7 @@ var ts; var ok = true; for (var _i = 0; _i < baseTypes.length; _i++) { var base = baseTypes[_i]; - var properties = getPropertiesOfObjectType(base); + var properties = getPropertiesOfObjectType(getTypeWithThisArgument(base, type.thisType)); for (var _a = 0; _a < properties.length; _a++) { var prop = properties[_a]; if (!ts.hasProperty(seen, prop.name)) { @@ -24510,7 +25097,7 @@ var ts; checkTypeNameIsReserved(node.name, ts.Diagnostics.Interface_name_cannot_be_0); checkExportsOnMergedDeclarations(node); var symbol = getSymbolOfNode(node); - var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 213 /* InterfaceDeclaration */); + var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 215 /* InterfaceDeclaration */); if (symbol.declarations.length > 1) { if (node !== firstInterfaceDecl && !areTypeParametersIdentical(firstInterfaceDecl.typeParameters, node.typeParameters)) { error(node.name, ts.Diagnostics.All_declarations_of_an_interface_must_have_identical_type_parameters); @@ -24519,19 +25106,21 @@ var ts; // Only check this symbol once if (node === firstInterfaceDecl) { var type = getDeclaredTypeOfSymbol(symbol); + var typeWithThis = getTypeWithThisArgument(type); // run subsequent checks only if first set succeeded if (checkInheritedPropertiesAreIdentical(type, node.name)) { - ts.forEach(getBaseTypes(type), function (baseType) { - checkTypeAssignableTo(type, baseType, node.name, ts.Diagnostics.Interface_0_incorrectly_extends_interface_1); - }); + for (var _i = 0, _a = getBaseTypes(type); _i < _a.length; _i++) { + var baseType = _a[_i]; + checkTypeAssignableTo(typeWithThis, getTypeWithThisArgument(baseType, type.thisType), node.name, ts.Diagnostics.Interface_0_incorrectly_extends_interface_1); + } checkIndexConstraints(type); } } // Interfaces cannot merge with non-ambient classes. if (symbol && symbol.declarations) { - for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { - var declaration = _a[_i]; - if (declaration.kind === 212 /* ClassDeclaration */ && !ts.isInAmbientContext(declaration)) { + for (var _b = 0, _c = symbol.declarations; _b < _c.length; _b++) { + var declaration = _c[_b]; + if (declaration.kind === 214 /* ClassDeclaration */ && !ts.isInAmbientContext(declaration)) { error(node, ts.Diagnostics.Only_an_ambient_class_can_be_merged_with_an_interface); break; } @@ -24560,24 +25149,38 @@ var ts; if (!(nodeLinks.flags & 8192 /* EnumValuesComputed */)) { var enumSymbol = getSymbolOfNode(node); var enumType = getDeclaredTypeOfSymbol(enumSymbol); - var autoValue = 0; + var autoValue = 0; // set to undefined when enum member is non-constant var ambient = ts.isInAmbientContext(node); var enumIsConst = ts.isConst(node); - ts.forEach(node.members, function (member) { - if (member.name.kind !== 134 /* ComputedPropertyName */ && isNumericLiteralName(member.name.text)) { + for (var _i = 0, _a = node.members; _i < _a.length; _i++) { + var member = _a[_i]; + if (member.name.kind === 136 /* ComputedPropertyName */) { + error(member.name, ts.Diagnostics.Computed_property_names_are_not_allowed_in_enums); + } + else if (isNumericLiteralName(member.name.text)) { error(member.name, ts.Diagnostics.An_enum_member_cannot_have_a_numeric_name); } + var previousEnumMemberIsNonConstant = autoValue === undefined; var initializer = member.initializer; if (initializer) { autoValue = computeConstantValueForEnumMemberInitializer(initializer, enumType, enumIsConst, ambient); } else if (ambient && !enumIsConst) { + // In ambient enum declarations that specify no const modifier, enum member declarations + // that omit a value are considered computed members (as opposed to having auto-incremented values assigned). autoValue = undefined; } + else if (previousEnumMemberIsNonConstant) { + // If the member declaration specifies no value, the member is considered a constant enum member. + // If the member is the first member in the enum declaration, it is assigned the value zero. + // Otherwise, it is assigned the value of the immediately preceding member plus one, + // and an error occurs if the immediately preceding member is not a constant enum member + error(member.name, ts.Diagnostics.Enum_member_must_have_initializer); + } if (autoValue !== undefined) { getNodeLinks(member).enumMemberValue = autoValue++; } - }); + } nodeLinks.flags |= 8192 /* EnumValuesComputed */; } function computeConstantValueForEnumMemberInitializer(initializer, enumType, enumIsConst, ambient) { @@ -24590,11 +25193,11 @@ var ts; if (enumIsConst) { error(initializer, ts.Diagnostics.In_const_enum_declarations_member_initializer_must_be_constant_expression); } - else if (!ambient) { + else if (ambient) { + error(initializer, ts.Diagnostics.In_ambient_enum_declarations_member_initializer_must_be_constant_expression); + } + else { // Only here do we need to check that the initializer is assignable to the enum type. - // If it is a constant value (not undefined), it is syntactically constrained to be a number. - // Also, we do not need to check this for ambients because there is already - // a syntax error if it is not a constant. checkTypeAssignableTo(checkExpression(initializer), enumType, initializer, /*headMessage*/ undefined); } } @@ -24610,7 +25213,7 @@ var ts; return value; function evalConstant(e) { switch (e.kind) { - case 177 /* PrefixUnaryExpression */: + case 179 /* PrefixUnaryExpression */: var value_1 = evalConstant(e.operand); if (value_1 === undefined) { return undefined; @@ -24618,10 +25221,10 @@ var ts; switch (e.operator) { case 35 /* PlusToken */: return value_1; case 36 /* MinusToken */: return -value_1; - case 49 /* TildeToken */: return ~value_1; + case 50 /* TildeToken */: return ~value_1; } return undefined; - case 179 /* BinaryExpression */: + case 181 /* BinaryExpression */: var left = evalConstant(e.left); if (left === undefined) { return undefined; @@ -24631,31 +25234,31 @@ var ts; return undefined; } switch (e.operatorToken.kind) { - case 46 /* BarToken */: return left | right; - case 45 /* AmpersandToken */: return left & right; - case 43 /* GreaterThanGreaterThanToken */: return left >> right; - case 44 /* GreaterThanGreaterThanGreaterThanToken */: return left >>> right; - case 42 /* LessThanLessThanToken */: return left << right; - case 47 /* CaretToken */: return left ^ right; + case 47 /* BarToken */: return left | right; + case 46 /* AmpersandToken */: return left & right; + case 44 /* GreaterThanGreaterThanToken */: return left >> right; + case 45 /* GreaterThanGreaterThanGreaterThanToken */: return left >>> right; + case 43 /* LessThanLessThanToken */: return left << right; + case 48 /* CaretToken */: return left ^ right; case 37 /* AsteriskToken */: return left * right; - case 38 /* SlashToken */: return left / right; + case 39 /* SlashToken */: return left / right; case 35 /* PlusToken */: return left + right; case 36 /* MinusToken */: return left - right; - case 39 /* PercentToken */: return left % right; + case 40 /* PercentToken */: return left % right; } return undefined; case 8 /* NumericLiteral */: return +e.text; - case 170 /* ParenthesizedExpression */: + case 172 /* ParenthesizedExpression */: return evalConstant(e.expression); - case 67 /* Identifier */: - case 165 /* ElementAccessExpression */: - case 164 /* PropertyAccessExpression */: + case 69 /* Identifier */: + case 167 /* ElementAccessExpression */: + case 166 /* PropertyAccessExpression */: var member = initializer.parent; var currentType = getTypeOfSymbol(getSymbolOfNode(member.parent)); var enumType_1; var propertyName; - if (e.kind === 67 /* Identifier */) { + if (e.kind === 69 /* Identifier */) { // unqualified names can refer to member that reside in different declaration of the enum so just doing name resolution won't work. // instead pick current enum type and later try to fetch member from the type enumType_1 = currentType; @@ -24663,7 +25266,7 @@ var ts; } else { var expression; - if (e.kind === 165 /* ElementAccessExpression */) { + if (e.kind === 167 /* ElementAccessExpression */) { if (e.argumentExpression === undefined || e.argumentExpression.kind !== 9 /* StringLiteral */) { return undefined; @@ -24678,10 +25281,10 @@ var ts; // expression part in ElementAccess\PropertyAccess should be either identifier or dottedName var current = expression; while (current) { - if (current.kind === 67 /* Identifier */) { + if (current.kind === 69 /* Identifier */) { break; } - else if (current.kind === 164 /* PropertyAccessExpression */) { + else if (current.kind === 166 /* PropertyAccessExpression */) { current = current.expression; } else { @@ -24707,7 +25310,7 @@ var ts; return undefined; } // illegal case: forward reference - if (!isDefinedBefore(propertyDecl, member)) { + if (!isBlockScopedNameDeclaredBeforeUse(propertyDecl, member)) { reportError = false; error(e, ts.Diagnostics.A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_enums); return undefined; @@ -24722,7 +25325,7 @@ var ts; return; } // Grammar checking - checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarEnumDeclaration(node); + checkGrammarDecorators(node) || checkGrammarModifiers(node); checkTypeNameIsReserved(node.name, ts.Diagnostics.Enum_name_cannot_be_0); checkCollisionWithCapturedThisVariable(node, node.name); checkCollisionWithRequireExportsInGeneratedCode(node, node.name); @@ -24752,7 +25355,7 @@ var ts; var seenEnumMissingInitialInitializer = false; ts.forEach(enumSymbol.declarations, function (declaration) { // return true if we hit a violation of the rule, false otherwise - if (declaration.kind !== 215 /* EnumDeclaration */) { + if (declaration.kind !== 217 /* EnumDeclaration */) { return false; } var enumDeclaration = declaration; @@ -24775,8 +25378,8 @@ var ts; var declarations = symbol.declarations; for (var _i = 0; _i < declarations.length; _i++) { var declaration = declarations[_i]; - if ((declaration.kind === 212 /* ClassDeclaration */ || - (declaration.kind === 211 /* FunctionDeclaration */ && ts.nodeIsPresent(declaration.body))) && + if ((declaration.kind === 214 /* ClassDeclaration */ || + (declaration.kind === 213 /* FunctionDeclaration */ && ts.nodeIsPresent(declaration.body))) && !ts.isInAmbientContext(declaration)) { return declaration; } @@ -24832,7 +25435,7 @@ var ts; } // if the module merges with a class declaration in the same lexical scope, // we need to track this to ensure the correct emit. - var mergedClass = ts.getDeclarationOfKind(symbol, 212 /* ClassDeclaration */); + var mergedClass = ts.getDeclarationOfKind(symbol, 214 /* ClassDeclaration */); if (mergedClass && inSameLexicalScope(node, mergedClass)) { getNodeLinks(node).flags |= 32768 /* LexicalModuleMergesWithClass */; @@ -24841,9 +25444,9 @@ var ts; // Checks for ambient external modules. if (isAmbientExternalModule) { if (!isGlobalSourceFile(node.parent)) { - error(node.name, ts.Diagnostics.Ambient_modules_cannot_be_nested_in_other_modules); + error(node.name, ts.Diagnostics.Ambient_modules_cannot_be_nested_in_other_modules_or_namespaces); } - if (isExternalModuleNameRelative(node.name.text)) { + if (ts.isExternalModuleNameRelative(node.name.text)) { error(node.name, ts.Diagnostics.Ambient_module_declaration_cannot_specify_relative_module_name); } } @@ -24852,17 +25455,17 @@ var ts; } function getFirstIdentifier(node) { while (true) { - if (node.kind === 133 /* QualifiedName */) { + if (node.kind === 135 /* QualifiedName */) { node = node.left; } - else if (node.kind === 164 /* PropertyAccessExpression */) { + else if (node.kind === 166 /* PropertyAccessExpression */) { node = node.expression; } else { break; } } - ts.Debug.assert(node.kind === 67 /* Identifier */); + ts.Debug.assert(node.kind === 69 /* Identifier */); return node; } function checkExternalImportOrExportDeclaration(node) { @@ -24871,14 +25474,14 @@ var ts; error(moduleName, ts.Diagnostics.String_literal_expected); return false; } - var inAmbientExternalModule = node.parent.kind === 217 /* ModuleBlock */ && node.parent.parent.name.kind === 9 /* StringLiteral */; - if (node.parent.kind !== 246 /* SourceFile */ && !inAmbientExternalModule) { - error(moduleName, node.kind === 226 /* ExportDeclaration */ ? + var inAmbientExternalModule = node.parent.kind === 219 /* ModuleBlock */ && node.parent.parent.name.kind === 9 /* StringLiteral */; + if (node.parent.kind !== 248 /* SourceFile */ && !inAmbientExternalModule) { + error(moduleName, node.kind === 228 /* ExportDeclaration */ ? ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace : ts.Diagnostics.Import_declarations_in_a_namespace_cannot_reference_a_module); return false; } - if (inAmbientExternalModule && isExternalModuleNameRelative(moduleName.text)) { + if (inAmbientExternalModule && ts.isExternalModuleNameRelative(moduleName.text)) { // TypeScript 1.0 spec (April 2013): 12.1.6 // An ExternalImportDeclaration in an AmbientExternalModuleDeclaration may reference // other external modules only through top - level external module names. @@ -24896,7 +25499,7 @@ var ts; (symbol.flags & 793056 /* Type */ ? 793056 /* Type */ : 0) | (symbol.flags & 1536 /* Namespace */ ? 1536 /* Namespace */ : 0); if (target.flags & excludedMeanings) { - var message = node.kind === 228 /* ExportSpecifier */ ? + var message = node.kind === 230 /* ExportSpecifier */ ? ts.Diagnostics.Export_declaration_conflicts_with_exported_declaration_of_0 : ts.Diagnostics.Import_declaration_conflicts_with_local_declaration_of_0; error(node, message, symbolToString(symbol)); @@ -24923,7 +25526,7 @@ var ts; checkImportBinding(importClause); } if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 222 /* NamespaceImport */) { + if (importClause.namedBindings.kind === 224 /* NamespaceImport */) { checkImportBinding(importClause.namedBindings); } else { @@ -24960,9 +25563,9 @@ var ts; } } else { - if (languageVersion >= 2 /* ES6 */ && !ts.isInAmbientContext(node)) { + if (modulekind === 5 /* ES6 */ && !ts.isInAmbientContext(node)) { // Import equals declaration is deprecated in es6 or above - grammarErrorOnNode(node, ts.Diagnostics.Import_assignment_cannot_be_used_when_targeting_ECMAScript_6_or_higher_Consider_using_import_Asterisk_as_ns_from_mod_import_a_from_mod_or_import_d_from_mod_instead); + grammarErrorOnNode(node, ts.Diagnostics.Import_assignment_cannot_be_used_when_targeting_ECMAScript_6_modules_Consider_using_import_Asterisk_as_ns_from_mod_import_a_from_mod_import_d_from_mod_or_another_module_format_instead); } } } @@ -24980,8 +25583,8 @@ var ts; // export { x, y } // export { x, y } from "foo" ts.forEach(node.exportClause.elements, checkExportSpecifier); - var inAmbientExternalModule = node.parent.kind === 217 /* ModuleBlock */ && node.parent.parent.name.kind === 9 /* StringLiteral */; - if (node.parent.kind !== 246 /* SourceFile */ && !inAmbientExternalModule) { + var inAmbientExternalModule = node.parent.kind === 219 /* ModuleBlock */ && node.parent.parent.name.kind === 9 /* StringLiteral */; + if (node.parent.kind !== 248 /* SourceFile */ && !inAmbientExternalModule) { error(node, ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace); } } @@ -24995,7 +25598,7 @@ var ts; } } function checkGrammarModuleElementContext(node, errorMessage) { - if (node.parent.kind !== 246 /* SourceFile */ && node.parent.kind !== 217 /* ModuleBlock */ && node.parent.kind !== 216 /* ModuleDeclaration */) { + if (node.parent.kind !== 248 /* SourceFile */ && node.parent.kind !== 219 /* ModuleBlock */ && node.parent.kind !== 218 /* ModuleDeclaration */) { return grammarErrorOnFirstToken(node, errorMessage); } } @@ -25010,8 +25613,8 @@ var ts; // If we hit an export assignment in an illegal context, just bail out to avoid cascading errors. return; } - var container = node.parent.kind === 246 /* SourceFile */ ? node.parent : node.parent.parent; - if (container.kind === 216 /* ModuleDeclaration */ && container.name.kind === 67 /* Identifier */) { + var container = node.parent.kind === 248 /* SourceFile */ ? node.parent : node.parent.parent; + if (container.kind === 218 /* ModuleDeclaration */ && container.name.kind === 69 /* Identifier */) { error(node, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_namespace); return; } @@ -25019,7 +25622,7 @@ var ts; if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && (node.flags & 2035 /* Modifier */)) { grammarErrorOnFirstToken(node, ts.Diagnostics.An_export_assignment_cannot_have_modifiers); } - if (node.expression.kind === 67 /* Identifier */) { + if (node.expression.kind === 69 /* Identifier */) { markExportAsReferenced(node); } else { @@ -25027,21 +25630,21 @@ var ts; } checkExternalModuleExports(container); if (node.isExportEquals && !ts.isInAmbientContext(node)) { - if (languageVersion >= 2 /* ES6 */) { - // export assignment is deprecated in es6 or above - grammarErrorOnNode(node, ts.Diagnostics.Export_assignment_cannot_be_used_when_targeting_ECMAScript_6_or_higher_Consider_using_export_default_instead); + if (modulekind === 5 /* ES6 */) { + // export assignment is not supported in es6 modules + grammarErrorOnNode(node, ts.Diagnostics.Export_assignment_cannot_be_used_when_targeting_ECMAScript_6_modules_Consider_using_export_default_or_another_module_format_instead); } - else if (compilerOptions.module === 4 /* System */) { + else if (modulekind === 4 /* System */) { // system modules does not support export assignment grammarErrorOnNode(node, ts.Diagnostics.Export_assignment_is_not_supported_when_module_flag_is_system); } } } function getModuleStatements(node) { - if (node.kind === 246 /* SourceFile */) { + if (node.kind === 248 /* SourceFile */) { return node.statements; } - if (node.kind === 216 /* ModuleDeclaration */ && node.body.kind === 217 /* ModuleBlock */) { + if (node.kind === 218 /* ModuleDeclaration */ && node.body.kind === 219 /* ModuleBlock */) { return node.body.statements; } return emptyArray; @@ -25080,118 +25683,118 @@ var ts; // Only bother checking on a few construct kinds. We don't want to be excessivly // hitting the cancellation token on every node we check. switch (kind) { - case 216 /* ModuleDeclaration */: - case 212 /* ClassDeclaration */: - case 213 /* InterfaceDeclaration */: - case 211 /* FunctionDeclaration */: + case 218 /* ModuleDeclaration */: + case 214 /* ClassDeclaration */: + case 215 /* InterfaceDeclaration */: + case 213 /* FunctionDeclaration */: cancellationToken.throwIfCancellationRequested(); } } switch (kind) { - case 135 /* TypeParameter */: + case 137 /* TypeParameter */: return checkTypeParameter(node); - case 136 /* Parameter */: + case 138 /* Parameter */: return checkParameter(node); - case 139 /* PropertyDeclaration */: - case 138 /* PropertySignature */: + case 141 /* PropertyDeclaration */: + case 140 /* PropertySignature */: return checkPropertyDeclaration(node); - case 150 /* FunctionType */: - case 151 /* ConstructorType */: - case 145 /* CallSignature */: - case 146 /* ConstructSignature */: + case 152 /* FunctionType */: + case 153 /* ConstructorType */: + case 147 /* CallSignature */: + case 148 /* ConstructSignature */: return checkSignatureDeclaration(node); - case 147 /* IndexSignature */: + case 149 /* IndexSignature */: return checkSignatureDeclaration(node); - case 141 /* MethodDeclaration */: - case 140 /* MethodSignature */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: return checkMethodDeclaration(node); - case 142 /* Constructor */: + case 144 /* Constructor */: return checkConstructorDeclaration(node); - case 143 /* GetAccessor */: - case 144 /* SetAccessor */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: return checkAccessorDeclaration(node); - case 149 /* TypeReference */: + case 151 /* TypeReference */: return checkTypeReferenceNode(node); - case 148 /* TypePredicate */: + case 150 /* TypePredicate */: return checkTypePredicate(node); - case 152 /* TypeQuery */: + case 154 /* TypeQuery */: return checkTypeQuery(node); - case 153 /* TypeLiteral */: + case 155 /* TypeLiteral */: return checkTypeLiteral(node); - case 154 /* ArrayType */: + case 156 /* ArrayType */: return checkArrayType(node); - case 155 /* TupleType */: + case 157 /* TupleType */: return checkTupleType(node); - case 156 /* UnionType */: - case 157 /* IntersectionType */: + case 158 /* UnionType */: + case 159 /* IntersectionType */: return checkUnionOrIntersectionType(node); - case 158 /* ParenthesizedType */: + case 160 /* ParenthesizedType */: return checkSourceElement(node.type); - case 211 /* FunctionDeclaration */: + case 213 /* FunctionDeclaration */: return checkFunctionDeclaration(node); - case 190 /* Block */: - case 217 /* ModuleBlock */: + case 192 /* Block */: + case 219 /* ModuleBlock */: return checkBlock(node); - case 191 /* VariableStatement */: + case 193 /* VariableStatement */: return checkVariableStatement(node); - case 193 /* ExpressionStatement */: + case 195 /* ExpressionStatement */: return checkExpressionStatement(node); - case 194 /* IfStatement */: + case 196 /* IfStatement */: return checkIfStatement(node); - case 195 /* DoStatement */: + case 197 /* DoStatement */: return checkDoStatement(node); - case 196 /* WhileStatement */: + case 198 /* WhileStatement */: return checkWhileStatement(node); - case 197 /* ForStatement */: + case 199 /* ForStatement */: return checkForStatement(node); - case 198 /* ForInStatement */: + case 200 /* ForInStatement */: return checkForInStatement(node); - case 199 /* ForOfStatement */: + case 201 /* ForOfStatement */: return checkForOfStatement(node); - case 200 /* ContinueStatement */: - case 201 /* BreakStatement */: + case 202 /* ContinueStatement */: + case 203 /* BreakStatement */: return checkBreakOrContinueStatement(node); - case 202 /* ReturnStatement */: + case 204 /* ReturnStatement */: return checkReturnStatement(node); - case 203 /* WithStatement */: + case 205 /* WithStatement */: return checkWithStatement(node); - case 204 /* SwitchStatement */: + case 206 /* SwitchStatement */: return checkSwitchStatement(node); - case 205 /* LabeledStatement */: + case 207 /* LabeledStatement */: return checkLabeledStatement(node); - case 206 /* ThrowStatement */: + case 208 /* ThrowStatement */: return checkThrowStatement(node); - case 207 /* TryStatement */: + case 209 /* TryStatement */: return checkTryStatement(node); - case 209 /* VariableDeclaration */: + case 211 /* VariableDeclaration */: return checkVariableDeclaration(node); - case 161 /* BindingElement */: + case 163 /* BindingElement */: return checkBindingElement(node); - case 212 /* ClassDeclaration */: + case 214 /* ClassDeclaration */: return checkClassDeclaration(node); - case 213 /* InterfaceDeclaration */: + case 215 /* InterfaceDeclaration */: return checkInterfaceDeclaration(node); - case 214 /* TypeAliasDeclaration */: + case 216 /* TypeAliasDeclaration */: return checkTypeAliasDeclaration(node); - case 215 /* EnumDeclaration */: + case 217 /* EnumDeclaration */: return checkEnumDeclaration(node); - case 216 /* ModuleDeclaration */: + case 218 /* ModuleDeclaration */: return checkModuleDeclaration(node); - case 220 /* ImportDeclaration */: + case 222 /* ImportDeclaration */: return checkImportDeclaration(node); - case 219 /* ImportEqualsDeclaration */: + case 221 /* ImportEqualsDeclaration */: return checkImportEqualsDeclaration(node); - case 226 /* ExportDeclaration */: + case 228 /* ExportDeclaration */: return checkExportDeclaration(node); - case 225 /* ExportAssignment */: + case 227 /* ExportAssignment */: return checkExportAssignment(node); - case 192 /* EmptyStatement */: + case 194 /* EmptyStatement */: checkGrammarStatementInAmbientContext(node); return; - case 208 /* DebuggerStatement */: + case 210 /* DebuggerStatement */: checkGrammarStatementInAmbientContext(node); return; - case 229 /* MissingDeclaration */: + case 231 /* MissingDeclaration */: return checkMissingDeclaration(node); } } @@ -25206,97 +25809,98 @@ var ts; // Delaying the type check of the body ensures foo has been assigned a type. function checkFunctionAndClassExpressionBodies(node) { switch (node.kind) { - case 171 /* FunctionExpression */: - case 172 /* ArrowFunction */: + case 173 /* FunctionExpression */: + case 174 /* ArrowFunction */: ts.forEach(node.parameters, checkFunctionAndClassExpressionBodies); checkFunctionExpressionOrObjectLiteralMethodBody(node); break; - case 184 /* ClassExpression */: + case 186 /* ClassExpression */: ts.forEach(node.members, checkSourceElement); + ts.forEachChild(node, checkFunctionAndClassExpressionBodies); break; - case 141 /* MethodDeclaration */: - case 140 /* MethodSignature */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: ts.forEach(node.decorators, checkFunctionAndClassExpressionBodies); ts.forEach(node.parameters, checkFunctionAndClassExpressionBodies); if (ts.isObjectLiteralMethod(node)) { checkFunctionExpressionOrObjectLiteralMethodBody(node); } break; - case 142 /* Constructor */: - case 143 /* GetAccessor */: - case 144 /* SetAccessor */: - case 211 /* FunctionDeclaration */: + case 144 /* Constructor */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: + case 213 /* FunctionDeclaration */: ts.forEach(node.parameters, checkFunctionAndClassExpressionBodies); break; - case 203 /* WithStatement */: + case 205 /* WithStatement */: checkFunctionAndClassExpressionBodies(node.expression); break; - case 137 /* Decorator */: - case 136 /* Parameter */: - case 139 /* PropertyDeclaration */: - case 138 /* PropertySignature */: - case 159 /* ObjectBindingPattern */: - case 160 /* ArrayBindingPattern */: - case 161 /* BindingElement */: - case 162 /* ArrayLiteralExpression */: - case 163 /* ObjectLiteralExpression */: - case 243 /* PropertyAssignment */: - case 164 /* PropertyAccessExpression */: - case 165 /* ElementAccessExpression */: - case 166 /* CallExpression */: - case 167 /* NewExpression */: - case 168 /* TaggedTemplateExpression */: - case 181 /* TemplateExpression */: - case 188 /* TemplateSpan */: - case 169 /* TypeAssertionExpression */: - case 187 /* AsExpression */: - case 170 /* ParenthesizedExpression */: - case 174 /* TypeOfExpression */: - case 175 /* VoidExpression */: - case 176 /* AwaitExpression */: - case 173 /* DeleteExpression */: - case 177 /* PrefixUnaryExpression */: - case 178 /* PostfixUnaryExpression */: - case 179 /* BinaryExpression */: - case 180 /* ConditionalExpression */: - case 183 /* SpreadElementExpression */: - case 182 /* YieldExpression */: - case 190 /* Block */: - case 217 /* ModuleBlock */: - case 191 /* VariableStatement */: - case 193 /* ExpressionStatement */: - case 194 /* IfStatement */: - case 195 /* DoStatement */: - case 196 /* WhileStatement */: - case 197 /* ForStatement */: - case 198 /* ForInStatement */: - case 199 /* ForOfStatement */: - case 200 /* ContinueStatement */: - case 201 /* BreakStatement */: - case 202 /* ReturnStatement */: - case 204 /* SwitchStatement */: - case 218 /* CaseBlock */: - case 239 /* CaseClause */: - case 240 /* DefaultClause */: - case 205 /* LabeledStatement */: - case 206 /* ThrowStatement */: - case 207 /* TryStatement */: - case 242 /* CatchClause */: - case 209 /* VariableDeclaration */: - case 210 /* VariableDeclarationList */: - case 212 /* ClassDeclaration */: - case 241 /* HeritageClause */: - case 186 /* ExpressionWithTypeArguments */: - case 215 /* EnumDeclaration */: - case 245 /* EnumMember */: - case 225 /* ExportAssignment */: - case 246 /* SourceFile */: - case 238 /* JsxExpression */: - case 231 /* JsxElement */: - case 232 /* JsxSelfClosingElement */: - case 236 /* JsxAttribute */: - case 237 /* JsxSpreadAttribute */: - case 233 /* JsxOpeningElement */: + case 139 /* Decorator */: + case 138 /* Parameter */: + case 141 /* PropertyDeclaration */: + case 140 /* PropertySignature */: + case 161 /* ObjectBindingPattern */: + case 162 /* ArrayBindingPattern */: + case 163 /* BindingElement */: + case 164 /* ArrayLiteralExpression */: + case 165 /* ObjectLiteralExpression */: + case 245 /* PropertyAssignment */: + case 166 /* PropertyAccessExpression */: + case 167 /* ElementAccessExpression */: + case 168 /* CallExpression */: + case 169 /* NewExpression */: + case 170 /* TaggedTemplateExpression */: + case 183 /* TemplateExpression */: + case 190 /* TemplateSpan */: + case 171 /* TypeAssertionExpression */: + case 189 /* AsExpression */: + case 172 /* ParenthesizedExpression */: + case 176 /* TypeOfExpression */: + case 177 /* VoidExpression */: + case 178 /* AwaitExpression */: + case 175 /* DeleteExpression */: + case 179 /* PrefixUnaryExpression */: + case 180 /* PostfixUnaryExpression */: + case 181 /* BinaryExpression */: + case 182 /* ConditionalExpression */: + case 185 /* SpreadElementExpression */: + case 184 /* YieldExpression */: + case 192 /* Block */: + case 219 /* ModuleBlock */: + case 193 /* VariableStatement */: + case 195 /* ExpressionStatement */: + case 196 /* IfStatement */: + case 197 /* DoStatement */: + case 198 /* WhileStatement */: + case 199 /* ForStatement */: + case 200 /* ForInStatement */: + case 201 /* ForOfStatement */: + case 202 /* ContinueStatement */: + case 203 /* BreakStatement */: + case 204 /* ReturnStatement */: + case 206 /* SwitchStatement */: + case 220 /* CaseBlock */: + case 241 /* CaseClause */: + case 242 /* DefaultClause */: + case 207 /* LabeledStatement */: + case 208 /* ThrowStatement */: + case 209 /* TryStatement */: + case 244 /* CatchClause */: + case 211 /* VariableDeclaration */: + case 212 /* VariableDeclarationList */: + case 214 /* ClassDeclaration */: + case 243 /* HeritageClause */: + case 188 /* ExpressionWithTypeArguments */: + case 217 /* EnumDeclaration */: + case 247 /* EnumMember */: + case 227 /* ExportAssignment */: + case 248 /* SourceFile */: + case 240 /* JsxExpression */: + case 233 /* JsxElement */: + case 234 /* JsxSelfClosingElement */: + case 238 /* JsxAttribute */: + case 239 /* JsxSpreadAttribute */: + case 235 /* JsxOpeningElement */: ts.forEachChild(node, checkFunctionAndClassExpressionBodies); break; } @@ -25323,7 +25927,7 @@ var ts; potentialThisCollisions.length = 0; ts.forEach(node.statements, checkSourceElement); checkFunctionAndClassExpressionBodies(node); - if (ts.isExternalModule(node)) { + if (ts.isExternalOrCommonJsModule(node)) { checkExternalModuleExports(node); } if (potentialThisCollisions.length) { @@ -25382,7 +25986,7 @@ var ts; function isInsideWithStatementBody(node) { if (node) { while (node.parent) { - if (node.parent.kind === 203 /* WithStatement */ && node.parent.statement === node) { + if (node.parent.kind === 205 /* WithStatement */ && node.parent.statement === node) { return true; } node = node.parent; @@ -25405,34 +26009,34 @@ var ts; copySymbols(location.locals, meaning); } switch (location.kind) { - case 246 /* SourceFile */: - if (!ts.isExternalModule(location)) { + case 248 /* SourceFile */: + if (!ts.isExternalOrCommonJsModule(location)) { break; } - case 216 /* ModuleDeclaration */: + case 218 /* ModuleDeclaration */: copySymbols(getSymbolOfNode(location).exports, meaning & 8914931 /* ModuleMember */); break; - case 215 /* EnumDeclaration */: + case 217 /* EnumDeclaration */: copySymbols(getSymbolOfNode(location).exports, meaning & 8 /* EnumMember */); break; - case 184 /* ClassExpression */: + case 186 /* ClassExpression */: var className = location.name; if (className) { copySymbol(location.symbol, meaning); } // fall through; this fall-through is necessary because we would like to handle // type parameter inside class expression similar to how we handle it in classDeclaration and interface Declaration - case 212 /* ClassDeclaration */: - case 213 /* InterfaceDeclaration */: + case 214 /* ClassDeclaration */: + case 215 /* InterfaceDeclaration */: // If we didn't come from static member of class or interface, - // add the type parameters into the symbol table + // add the type parameters into the symbol table // (type parameters of classDeclaration/classExpression and interface are in member property of the symbol. // Note: that the memberFlags come from previous iteration. if (!(memberFlags & 128 /* Static */)) { copySymbols(getSymbolOfNode(location).members, meaning & 793056 /* Type */); } break; - case 171 /* FunctionExpression */: + case 173 /* FunctionExpression */: var funcName = location.name; if (funcName) { copySymbol(location.symbol, meaning); @@ -25475,43 +26079,43 @@ var ts; } } function isTypeDeclarationName(name) { - return name.kind === 67 /* Identifier */ && + return name.kind === 69 /* Identifier */ && isTypeDeclaration(name.parent) && name.parent.name === name; } function isTypeDeclaration(node) { switch (node.kind) { - case 135 /* TypeParameter */: - case 212 /* ClassDeclaration */: - case 213 /* InterfaceDeclaration */: - case 214 /* TypeAliasDeclaration */: - case 215 /* EnumDeclaration */: + case 137 /* TypeParameter */: + case 214 /* ClassDeclaration */: + case 215 /* InterfaceDeclaration */: + case 216 /* TypeAliasDeclaration */: + case 217 /* EnumDeclaration */: return true; } } // True if the given identifier is part of a type reference function isTypeReferenceIdentifier(entityName) { var node = entityName; - while (node.parent && node.parent.kind === 133 /* QualifiedName */) { + while (node.parent && node.parent.kind === 135 /* QualifiedName */) { node = node.parent; } - return node.parent && node.parent.kind === 149 /* TypeReference */; + return node.parent && node.parent.kind === 151 /* TypeReference */; } function isHeritageClauseElementIdentifier(entityName) { var node = entityName; - while (node.parent && node.parent.kind === 164 /* PropertyAccessExpression */) { + while (node.parent && node.parent.kind === 166 /* PropertyAccessExpression */) { node = node.parent; } - return node.parent && node.parent.kind === 186 /* ExpressionWithTypeArguments */; + return node.parent && node.parent.kind === 188 /* ExpressionWithTypeArguments */; } function getLeftSideOfImportEqualsOrExportAssignment(nodeOnRightSide) { - while (nodeOnRightSide.parent.kind === 133 /* QualifiedName */) { + while (nodeOnRightSide.parent.kind === 135 /* QualifiedName */) { nodeOnRightSide = nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 219 /* ImportEqualsDeclaration */) { + if (nodeOnRightSide.parent.kind === 221 /* ImportEqualsDeclaration */) { return nodeOnRightSide.parent.moduleReference === nodeOnRightSide && nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 225 /* ExportAssignment */) { + if (nodeOnRightSide.parent.kind === 227 /* ExportAssignment */) { return nodeOnRightSide.parent.expression === nodeOnRightSide && nodeOnRightSide.parent; } return undefined; @@ -25523,11 +26127,11 @@ var ts; if (ts.isDeclarationName(entityName)) { return getSymbolOfNode(entityName.parent); } - if (entityName.parent.kind === 225 /* ExportAssignment */) { + if (entityName.parent.kind === 227 /* ExportAssignment */) { return resolveEntityName(entityName, /*all meanings*/ 107455 /* Value */ | 793056 /* Type */ | 1536 /* Namespace */ | 8388608 /* Alias */); } - if (entityName.kind !== 164 /* PropertyAccessExpression */) { + if (entityName.kind !== 166 /* PropertyAccessExpression */) { if (isInRightSideOfImportOrExportAssignment(entityName)) { // Since we already checked for ExportAssignment, this really could only be an Import return getSymbolOfPartOfRightHandSideOfImportEquals(entityName); @@ -25537,13 +26141,24 @@ var ts; entityName = entityName.parent; } if (isHeritageClauseElementIdentifier(entityName)) { - var meaning = entityName.parent.kind === 186 /* ExpressionWithTypeArguments */ ? 793056 /* Type */ : 1536 /* Namespace */; + var meaning = 0 /* None */; + // In an interface or class, we're definitely interested in a type. + if (entityName.parent.kind === 188 /* ExpressionWithTypeArguments */) { + meaning = 793056 /* Type */; + // In a class 'extends' clause we are also looking for a value. + if (ts.isExpressionWithTypeArgumentsInClassExtendsClause(entityName.parent)) { + meaning |= 107455 /* Value */; + } + } + else { + meaning = 1536 /* Namespace */; + } meaning |= 8388608 /* Alias */; return resolveEntityName(entityName, meaning); } - else if ((entityName.parent.kind === 233 /* JsxOpeningElement */) || - (entityName.parent.kind === 232 /* JsxSelfClosingElement */) || - (entityName.parent.kind === 235 /* JsxClosingElement */)) { + else if ((entityName.parent.kind === 235 /* JsxOpeningElement */) || + (entityName.parent.kind === 234 /* JsxSelfClosingElement */) || + (entityName.parent.kind === 237 /* JsxClosingElement */)) { return getJsxElementTagSymbol(entityName.parent); } else if (ts.isExpression(entityName)) { @@ -25551,20 +26166,20 @@ var ts; // Missing entity name. return undefined; } - if (entityName.kind === 67 /* Identifier */) { + if (entityName.kind === 69 /* Identifier */) { // Include aliases in the meaning, this ensures that we do not follow aliases to where they point and instead // return the alias symbol. var meaning = 107455 /* Value */ | 8388608 /* Alias */; return resolveEntityName(entityName, meaning); } - else if (entityName.kind === 164 /* PropertyAccessExpression */) { + else if (entityName.kind === 166 /* PropertyAccessExpression */) { var symbol = getNodeLinks(entityName).resolvedSymbol; if (!symbol) { checkPropertyAccessExpression(entityName); } return getNodeLinks(entityName).resolvedSymbol; } - else if (entityName.kind === 133 /* QualifiedName */) { + else if (entityName.kind === 135 /* QualifiedName */) { var symbol = getNodeLinks(entityName).resolvedSymbol; if (!symbol) { checkQualifiedName(entityName); @@ -25573,16 +26188,16 @@ var ts; } } else if (isTypeReferenceIdentifier(entityName)) { - var meaning = entityName.parent.kind === 149 /* TypeReference */ ? 793056 /* Type */ : 1536 /* Namespace */; + var meaning = entityName.parent.kind === 151 /* TypeReference */ ? 793056 /* Type */ : 1536 /* Namespace */; // Include aliases in the meaning, this ensures that we do not follow aliases to where they point and instead // return the alias symbol. meaning |= 8388608 /* Alias */; return resolveEntityName(entityName, meaning); } - else if (entityName.parent.kind === 236 /* JsxAttribute */) { + else if (entityName.parent.kind === 238 /* JsxAttribute */) { return getJsxAttributePropertySymbol(entityName.parent); } - if (entityName.parent.kind === 148 /* TypePredicate */) { + if (entityName.parent.kind === 150 /* TypePredicate */) { return resolveEntityName(entityName, /*meaning*/ 1 /* FunctionScopedVariable */); } // Do we want to return undefined here? @@ -25597,14 +26212,14 @@ var ts; // This is a declaration, call getSymbolOfNode return getSymbolOfNode(node.parent); } - if (node.kind === 67 /* Identifier */) { + if (node.kind === 69 /* Identifier */) { if (isInRightSideOfImportOrExportAssignment(node)) { - return node.parent.kind === 225 /* ExportAssignment */ + return node.parent.kind === 227 /* ExportAssignment */ ? getSymbolOfEntityNameOrPropertyAccessExpression(node) : getSymbolOfPartOfRightHandSideOfImportEquals(node); } - else if (node.parent.kind === 161 /* BindingElement */ && - node.parent.parent.kind === 159 /* ObjectBindingPattern */ && + else if (node.parent.kind === 163 /* BindingElement */ && + node.parent.parent.kind === 161 /* ObjectBindingPattern */ && node === node.parent.propertyName) { var typeOfPattern = getTypeOfNode(node.parent.parent); var propertyDeclaration = typeOfPattern && getPropertyOfType(typeOfPattern, node.text); @@ -25614,18 +26229,18 @@ var ts; } } switch (node.kind) { - case 67 /* Identifier */: - case 164 /* PropertyAccessExpression */: - case 133 /* QualifiedName */: + case 69 /* Identifier */: + case 166 /* PropertyAccessExpression */: + case 135 /* QualifiedName */: return getSymbolOfEntityNameOrPropertyAccessExpression(node); - case 95 /* ThisKeyword */: - case 93 /* SuperKeyword */: - var type = checkExpression(node); + case 97 /* ThisKeyword */: + case 95 /* SuperKeyword */: + var type = ts.isExpression(node) ? checkExpression(node) : getTypeFromTypeNode(node); return type.symbol; - case 119 /* ConstructorKeyword */: + case 121 /* ConstructorKeyword */: // constructor keyword for an overload, should take us to the definition if it exist var constructorDeclaration = node.parent; - if (constructorDeclaration && constructorDeclaration.kind === 142 /* Constructor */) { + if (constructorDeclaration && constructorDeclaration.kind === 144 /* Constructor */) { return constructorDeclaration.parent.symbol; } return undefined; @@ -25633,14 +26248,14 @@ var ts; // External module name in an import declaration if ((ts.isExternalModuleImportEqualsDeclaration(node.parent.parent) && ts.getExternalModuleImportEqualsDeclarationExpression(node.parent.parent) === node) || - ((node.parent.kind === 220 /* ImportDeclaration */ || node.parent.kind === 226 /* ExportDeclaration */) && + ((node.parent.kind === 222 /* ImportDeclaration */ || node.parent.kind === 228 /* ExportDeclaration */) && node.parent.moduleSpecifier === node)) { return resolveExternalModuleName(node, node); } // Fall through case 8 /* NumericLiteral */: // index access - if (node.parent.kind === 165 /* ElementAccessExpression */ && node.parent.argumentExpression === node) { + if (node.parent.kind === 167 /* ElementAccessExpression */ && node.parent.argumentExpression === node) { var objectType = checkExpression(node.parent.expression); if (objectType === unknownType) return undefined; @@ -25657,7 +26272,7 @@ var ts; // The function returns a value symbol of an identifier in the short-hand property assignment. // This is necessary as an identifier in short-hand property assignment can contains two meaning: // property name and property value. - if (location && location.kind === 244 /* ShorthandPropertyAssignment */) { + if (location && location.kind === 246 /* ShorthandPropertyAssignment */) { return resolveEntityName(location.name, 107455 /* Value */); } return undefined; @@ -25774,11 +26389,11 @@ var ts; } var parentSymbol = getParentOfSymbol(symbol); if (parentSymbol) { - if (parentSymbol.flags & 512 /* ValueModule */ && parentSymbol.valueDeclaration.kind === 246 /* SourceFile */) { + if (parentSymbol.flags & 512 /* ValueModule */ && parentSymbol.valueDeclaration.kind === 248 /* SourceFile */) { return parentSymbol.valueDeclaration; } for (var n = node.parent; n; n = n.parent) { - if ((n.kind === 216 /* ModuleDeclaration */ || n.kind === 215 /* EnumDeclaration */) && getSymbolOfNode(n) === parentSymbol) { + if ((n.kind === 218 /* ModuleDeclaration */ || n.kind === 217 /* EnumDeclaration */) && getSymbolOfNode(n) === parentSymbol) { return n; } } @@ -25793,11 +26408,11 @@ var ts; } function isStatementWithLocals(node) { switch (node.kind) { - case 190 /* Block */: - case 218 /* CaseBlock */: - case 197 /* ForStatement */: - case 198 /* ForInStatement */: - case 199 /* ForOfStatement */: + case 192 /* Block */: + case 220 /* CaseBlock */: + case 199 /* ForStatement */: + case 200 /* ForInStatement */: + case 201 /* ForOfStatement */: return true; } return false; @@ -25827,22 +26442,22 @@ var ts; } function isValueAliasDeclaration(node) { switch (node.kind) { - case 219 /* ImportEqualsDeclaration */: - case 221 /* ImportClause */: - case 222 /* NamespaceImport */: - case 224 /* ImportSpecifier */: - case 228 /* ExportSpecifier */: + case 221 /* ImportEqualsDeclaration */: + case 223 /* ImportClause */: + case 224 /* NamespaceImport */: + case 226 /* ImportSpecifier */: + case 230 /* ExportSpecifier */: return isAliasResolvedToValue(getSymbolOfNode(node)); - case 226 /* ExportDeclaration */: + case 228 /* ExportDeclaration */: var exportClause = node.exportClause; return exportClause && ts.forEach(exportClause.elements, isValueAliasDeclaration); - case 225 /* ExportAssignment */: - return node.expression && node.expression.kind === 67 /* Identifier */ ? isAliasResolvedToValue(getSymbolOfNode(node)) : true; + case 227 /* ExportAssignment */: + return node.expression && node.expression.kind === 69 /* Identifier */ ? isAliasResolvedToValue(getSymbolOfNode(node)) : true; } return false; } function isTopLevelValueImportEqualsWithEntityName(node) { - if (node.parent.kind !== 246 /* SourceFile */ || !ts.isInternalModuleImportEqualsDeclaration(node)) { + if (node.parent.kind !== 248 /* SourceFile */ || !ts.isInternalModuleImportEqualsDeclaration(node)) { // parent is not source file or it is not reference to internal module return false; } @@ -25904,7 +26519,7 @@ var ts; return getNodeLinks(node).enumMemberValue; } function getConstantValue(node) { - if (node.kind === 245 /* EnumMember */) { + if (node.kind === 247 /* EnumMember */) { return getEnumMemberValue(node); } var symbol = getNodeLinks(node).resolvedSymbol; @@ -25996,23 +26611,6 @@ var ts; var symbol = getReferencedValueSymbol(reference); return symbol && getExportSymbolOfValueSymbolIfExported(symbol).valueDeclaration; } - function getBlockScopedVariableId(n) { - ts.Debug.assert(!ts.nodeIsSynthesized(n)); - var isVariableDeclarationOrBindingElement = n.parent.kind === 161 /* BindingElement */ || (n.parent.kind === 209 /* VariableDeclaration */ && n.parent.name === n); - var symbol = (isVariableDeclarationOrBindingElement ? getSymbolOfNode(n.parent) : undefined) || - getNodeLinks(n).resolvedSymbol || - resolveName(n, n.text, 107455 /* Value */ | 8388608 /* Alias */, /*nodeNotFoundMessage*/ undefined, /*nameArg*/ undefined); - var isLetOrConst = symbol && - (symbol.flags & 2 /* BlockScopedVariable */) && - symbol.valueDeclaration.parent.kind !== 242 /* CatchClause */; - if (isLetOrConst) { - // side-effect of calling this method: - // assign id to symbol if it was not yet set - getSymbolLinks(symbol); - return symbol.id; - } - return undefined; - } function instantiateSingleCallFunctionType(functionType, typeArguments) { if (functionType === unknownType) { return unknownType; @@ -26044,7 +26642,6 @@ var ts; isEntityNameVisible: isEntityNameVisible, getConstantValue: getConstantValue, collectLinkedAliases: collectLinkedAliases, - getBlockScopedVariableId: getBlockScopedVariableId, getReferencedValueDeclaration: getReferencedValueDeclaration, getTypeReferenceSerializationKind: getTypeReferenceSerializationKind, isOptionalParameter: isOptionalParameter @@ -26057,11 +26654,10 @@ var ts; }); // Initialize global symbol table ts.forEach(host.getSourceFiles(), function (file) { - if (!ts.isExternalModule(file)) { + if (!ts.isExternalOrCommonJsModule(file)) { mergeSymbolTable(globals, file.locals); } }); - // Initialize special symbols getSymbolLinks(undefinedSymbol).type = undefinedType; getSymbolLinks(argumentsSymbol).type = getGlobalType("IArguments"); getSymbolLinks(unknownSymbol).type = unknownType; @@ -26087,6 +26683,7 @@ var ts; getGlobalPromiseConstructorSymbol = ts.memoize(function () { return getGlobalValueSymbol("Promise"); }); getGlobalPromiseConstructorLikeType = ts.memoize(function () { return getGlobalType("PromiseConstructorLike"); }); getGlobalThenableType = ts.memoize(createThenableType); + cjsRequireType = getExportedTypeFromNamespace("CommonJS", "Require"); // If we're in ES6 mode, load the TemplateStringsArray. // Otherwise, default to 'unknown' for the purposes of type checking in LS scenarios. if (languageVersion >= 2 /* ES6 */) { @@ -26136,10 +26733,7 @@ var ts; if (!ts.nodeCanBeDecorated(node)) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Decorators_are_not_valid_here); } - else if (languageVersion < 1 /* ES5 */) { - return grammarErrorOnFirstToken(node, ts.Diagnostics.Decorators_are_only_available_when_targeting_ECMAScript_5_and_higher); - } - else if (node.kind === 143 /* GetAccessor */ || node.kind === 144 /* SetAccessor */) { + else if (node.kind === 145 /* GetAccessor */ || node.kind === 146 /* SetAccessor */) { var accessors = ts.getAllAccessorDeclarations(node.parent.members, node); if (accessors.firstAccessor.decorators && node === accessors.secondAccessor) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name); @@ -26149,38 +26743,38 @@ var ts; } function checkGrammarModifiers(node) { switch (node.kind) { - case 143 /* GetAccessor */: - case 144 /* SetAccessor */: - case 142 /* Constructor */: - case 139 /* PropertyDeclaration */: - case 138 /* PropertySignature */: - case 141 /* MethodDeclaration */: - case 140 /* MethodSignature */: - case 147 /* IndexSignature */: - case 216 /* ModuleDeclaration */: - case 220 /* ImportDeclaration */: - case 219 /* ImportEqualsDeclaration */: - case 226 /* ExportDeclaration */: - case 225 /* ExportAssignment */: - case 136 /* Parameter */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: + case 144 /* Constructor */: + case 141 /* PropertyDeclaration */: + case 140 /* PropertySignature */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: + case 149 /* IndexSignature */: + case 218 /* ModuleDeclaration */: + case 222 /* ImportDeclaration */: + case 221 /* ImportEqualsDeclaration */: + case 228 /* ExportDeclaration */: + case 227 /* ExportAssignment */: + case 138 /* Parameter */: break; - case 211 /* FunctionDeclaration */: - if (node.modifiers && (node.modifiers.length > 1 || node.modifiers[0].kind !== 116 /* AsyncKeyword */) && - node.parent.kind !== 217 /* ModuleBlock */ && node.parent.kind !== 246 /* SourceFile */) { + case 213 /* FunctionDeclaration */: + if (node.modifiers && (node.modifiers.length > 1 || node.modifiers[0].kind !== 118 /* AsyncKeyword */) && + node.parent.kind !== 219 /* ModuleBlock */ && node.parent.kind !== 248 /* SourceFile */) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); } break; - case 212 /* ClassDeclaration */: - case 213 /* InterfaceDeclaration */: - case 191 /* VariableStatement */: - case 214 /* TypeAliasDeclaration */: - if (node.modifiers && node.parent.kind !== 217 /* ModuleBlock */ && node.parent.kind !== 246 /* SourceFile */) { + case 214 /* ClassDeclaration */: + case 215 /* InterfaceDeclaration */: + case 193 /* VariableStatement */: + case 216 /* TypeAliasDeclaration */: + if (node.modifiers && node.parent.kind !== 219 /* ModuleBlock */ && node.parent.kind !== 248 /* SourceFile */) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); } break; - case 215 /* EnumDeclaration */: - if (node.modifiers && (node.modifiers.length > 1 || node.modifiers[0].kind !== 72 /* ConstKeyword */) && - node.parent.kind !== 217 /* ModuleBlock */ && node.parent.kind !== 246 /* SourceFile */) { + case 217 /* EnumDeclaration */: + if (node.modifiers && (node.modifiers.length > 1 || node.modifiers[0].kind !== 74 /* ConstKeyword */) && + node.parent.kind !== 219 /* ModuleBlock */ && node.parent.kind !== 248 /* SourceFile */) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); } break; @@ -26195,14 +26789,14 @@ var ts; for (var _i = 0, _a = node.modifiers; _i < _a.length; _i++) { var modifier = _a[_i]; switch (modifier.kind) { - case 110 /* PublicKeyword */: - case 109 /* ProtectedKeyword */: - case 108 /* PrivateKeyword */: + case 112 /* PublicKeyword */: + case 111 /* ProtectedKeyword */: + case 110 /* PrivateKeyword */: var text = void 0; - if (modifier.kind === 110 /* PublicKeyword */) { + if (modifier.kind === 112 /* PublicKeyword */) { text = "public"; } - else if (modifier.kind === 109 /* ProtectedKeyword */) { + else if (modifier.kind === 111 /* ProtectedKeyword */) { text = "protected"; lastProtected = modifier; } @@ -26219,11 +26813,11 @@ var ts; else if (flags & 512 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "async"); } - else if (node.parent.kind === 217 /* ModuleBlock */ || node.parent.kind === 246 /* SourceFile */) { + else if (node.parent.kind === 219 /* ModuleBlock */ || node.parent.kind === 248 /* SourceFile */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_element, text); } else if (flags & 256 /* Abstract */) { - if (modifier.kind === 108 /* PrivateKeyword */) { + if (modifier.kind === 110 /* PrivateKeyword */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, text, "abstract"); } else { @@ -26232,17 +26826,17 @@ var ts; } flags |= ts.modifierToFlag(modifier.kind); break; - case 111 /* StaticKeyword */: + case 113 /* StaticKeyword */: if (flags & 128 /* Static */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "static"); } else if (flags & 512 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "static", "async"); } - else if (node.parent.kind === 217 /* ModuleBlock */ || node.parent.kind === 246 /* SourceFile */) { + else if (node.parent.kind === 219 /* ModuleBlock */ || node.parent.kind === 248 /* SourceFile */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_element, "static"); } - else if (node.kind === 136 /* Parameter */) { + else if (node.kind === 138 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "static"); } else if (flags & 256 /* Abstract */) { @@ -26251,7 +26845,7 @@ var ts; flags |= 128 /* Static */; lastStatic = modifier; break; - case 80 /* ExportKeyword */: + case 82 /* ExportKeyword */: if (flags & 1 /* Export */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "export"); } @@ -26264,42 +26858,42 @@ var ts; else if (flags & 512 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "async"); } - else if (node.parent.kind === 212 /* ClassDeclaration */) { + else if (node.parent.kind === 214 /* ClassDeclaration */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "export"); } - else if (node.kind === 136 /* Parameter */) { + else if (node.kind === 138 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "export"); } flags |= 1 /* Export */; break; - case 120 /* DeclareKeyword */: + case 122 /* DeclareKeyword */: if (flags & 2 /* Ambient */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "declare"); } else if (flags & 512 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); } - else if (node.parent.kind === 212 /* ClassDeclaration */) { + else if (node.parent.kind === 214 /* ClassDeclaration */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "declare"); } - else if (node.kind === 136 /* Parameter */) { + else if (node.kind === 138 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "declare"); } - else if (ts.isInAmbientContext(node.parent) && node.parent.kind === 217 /* ModuleBlock */) { + else if (ts.isInAmbientContext(node.parent) && node.parent.kind === 219 /* ModuleBlock */) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_declare_modifier_cannot_be_used_in_an_already_ambient_context); } flags |= 2 /* Ambient */; lastDeclare = modifier; break; - case 113 /* AbstractKeyword */: + case 115 /* AbstractKeyword */: if (flags & 256 /* Abstract */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "abstract"); } - if (node.kind !== 212 /* ClassDeclaration */) { - if (node.kind !== 141 /* MethodDeclaration */) { + if (node.kind !== 214 /* ClassDeclaration */) { + if (node.kind !== 143 /* MethodDeclaration */) { return grammarErrorOnNode(modifier, ts.Diagnostics.abstract_modifier_can_only_appear_on_a_class_or_method_declaration); } - if (!(node.parent.kind === 212 /* ClassDeclaration */ && node.parent.flags & 256 /* Abstract */)) { + if (!(node.parent.kind === 214 /* ClassDeclaration */ && node.parent.flags & 256 /* Abstract */)) { return grammarErrorOnNode(modifier, ts.Diagnostics.Abstract_methods_can_only_appear_within_an_abstract_class); } if (flags & 128 /* Static */) { @@ -26311,14 +26905,14 @@ var ts; } flags |= 256 /* Abstract */; break; - case 116 /* AsyncKeyword */: + case 118 /* AsyncKeyword */: if (flags & 512 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "async"); } else if (flags & 2 /* Ambient */ || ts.isInAmbientContext(node.parent)) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); } - else if (node.kind === 136 /* Parameter */) { + else if (node.kind === 138 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "async"); } flags |= 512 /* Async */; @@ -26326,7 +26920,7 @@ var ts; break; } } - if (node.kind === 142 /* Constructor */) { + if (node.kind === 144 /* Constructor */) { if (flags & 128 /* Static */) { return grammarErrorOnNode(lastStatic, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "static"); } @@ -26344,10 +26938,10 @@ var ts; } return; } - else if ((node.kind === 220 /* ImportDeclaration */ || node.kind === 219 /* ImportEqualsDeclaration */) && flags & 2 /* Ambient */) { + else if ((node.kind === 222 /* ImportDeclaration */ || node.kind === 221 /* ImportEqualsDeclaration */) && flags & 2 /* Ambient */) { return grammarErrorOnNode(lastDeclare, ts.Diagnostics.A_0_modifier_cannot_be_used_with_an_import_declaration, "declare"); } - else if (node.kind === 136 /* Parameter */ && (flags & 112 /* AccessibilityModifier */) && ts.isBindingPattern(node.name)) { + else if (node.kind === 138 /* Parameter */ && (flags & 112 /* AccessibilityModifier */) && ts.isBindingPattern(node.name)) { return grammarErrorOnNode(node, ts.Diagnostics.A_parameter_property_may_not_be_a_binding_pattern); } if (flags & 512 /* Async */) { @@ -26359,10 +26953,10 @@ var ts; return grammarErrorOnNode(asyncModifier, ts.Diagnostics.Async_functions_are_only_available_when_targeting_ECMAScript_6_and_higher); } switch (node.kind) { - case 141 /* MethodDeclaration */: - case 211 /* FunctionDeclaration */: - case 171 /* FunctionExpression */: - case 172 /* ArrowFunction */: + case 143 /* MethodDeclaration */: + case 213 /* FunctionDeclaration */: + case 173 /* FunctionExpression */: + case 174 /* ArrowFunction */: if (!node.asteriskToken) { return false; } @@ -26428,7 +27022,7 @@ var ts; checkGrammarParameterList(node.parameters) || checkGrammarArrowFunction(node, file); } function checkGrammarArrowFunction(node, file) { - if (node.kind === 172 /* ArrowFunction */) { + if (node.kind === 174 /* ArrowFunction */) { var arrowFunction = node; var startLine = ts.getLineAndCharacterOfPosition(file, arrowFunction.equalsGreaterThanToken.pos).line; var endLine = ts.getLineAndCharacterOfPosition(file, arrowFunction.equalsGreaterThanToken.end).line; @@ -26463,7 +27057,7 @@ var ts; if (!parameter.type) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_must_have_a_type_annotation); } - if (parameter.type.kind !== 128 /* StringKeyword */ && parameter.type.kind !== 126 /* NumberKeyword */) { + if (parameter.type.kind !== 130 /* StringKeyword */ && parameter.type.kind !== 128 /* NumberKeyword */) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_type_must_be_string_or_number); } if (!node.type) { @@ -26496,7 +27090,7 @@ var ts; var sourceFile = ts.getSourceFileOfNode(node); for (var _i = 0; _i < args.length; _i++) { var arg = args[_i]; - if (arg.kind === 185 /* OmittedExpression */) { + if (arg.kind === 187 /* OmittedExpression */) { return grammarErrorAtPos(sourceFile, arg.pos, 0, ts.Diagnostics.Argument_expression_expected); } } @@ -26523,7 +27117,7 @@ var ts; if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && node.heritageClauses) { for (var _i = 0, _a = node.heritageClauses; _i < _a.length; _i++) { var heritageClause = _a[_i]; - if (heritageClause.token === 81 /* ExtendsKeyword */) { + if (heritageClause.token === 83 /* ExtendsKeyword */) { if (seenExtendsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_already_seen); } @@ -26536,7 +27130,7 @@ var ts; seenExtendsClause = true; } else { - ts.Debug.assert(heritageClause.token === 104 /* ImplementsKeyword */); + ts.Debug.assert(heritageClause.token === 106 /* ImplementsKeyword */); if (seenImplementsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.implements_clause_already_seen); } @@ -26552,14 +27146,14 @@ var ts; if (node.heritageClauses) { for (var _i = 0, _a = node.heritageClauses; _i < _a.length; _i++) { var heritageClause = _a[_i]; - if (heritageClause.token === 81 /* ExtendsKeyword */) { + if (heritageClause.token === 83 /* ExtendsKeyword */) { if (seenExtendsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_already_seen); } seenExtendsClause = true; } else { - ts.Debug.assert(heritageClause.token === 104 /* ImplementsKeyword */); + ts.Debug.assert(heritageClause.token === 106 /* ImplementsKeyword */); return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.Interface_declaration_cannot_have_implements_clause); } // Grammar checking heritageClause inside class declaration @@ -26570,19 +27164,19 @@ var ts; } function checkGrammarComputedPropertyName(node) { // If node is not a computedPropertyName, just skip the grammar checking - if (node.kind !== 134 /* ComputedPropertyName */) { + if (node.kind !== 136 /* ComputedPropertyName */) { return false; } var computedPropertyName = node; - if (computedPropertyName.expression.kind === 179 /* BinaryExpression */ && computedPropertyName.expression.operatorToken.kind === 24 /* CommaToken */) { + if (computedPropertyName.expression.kind === 181 /* BinaryExpression */ && computedPropertyName.expression.operatorToken.kind === 24 /* CommaToken */) { return grammarErrorOnNode(computedPropertyName.expression, ts.Diagnostics.A_comma_expression_is_not_allowed_in_a_computed_property_name); } } function checkGrammarForGenerator(node) { if (node.asteriskToken) { - ts.Debug.assert(node.kind === 211 /* FunctionDeclaration */ || - node.kind === 171 /* FunctionExpression */ || - node.kind === 141 /* MethodDeclaration */); + ts.Debug.assert(node.kind === 213 /* FunctionDeclaration */ || + node.kind === 173 /* FunctionExpression */ || + node.kind === 143 /* MethodDeclaration */); if (ts.isInAmbientContext(node)) { return grammarErrorOnNode(node.asteriskToken, ts.Diagnostics.Generators_are_not_allowed_in_an_ambient_context); } @@ -26599,7 +27193,7 @@ var ts; return grammarErrorOnNode(questionToken, message); } } - function checkGrammarObjectLiteralExpression(node) { + function checkGrammarObjectLiteralExpression(node, inDestructuring) { var seen = {}; var Property = 1; var GetAccessor = 2; @@ -26608,12 +27202,17 @@ var ts; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; var name_16 = prop.name; - if (prop.kind === 185 /* OmittedExpression */ || - name_16.kind === 134 /* ComputedPropertyName */) { + if (prop.kind === 187 /* OmittedExpression */ || + name_16.kind === 136 /* ComputedPropertyName */) { // If the name is not a ComputedPropertyName, the grammar checking will skip it checkGrammarComputedPropertyName(name_16); continue; } + if (prop.kind === 246 /* ShorthandPropertyAssignment */ && !inDestructuring && prop.objectAssignmentInitializer) { + // having objectAssignmentInitializer is only valid in ObjectAssignmentPattern + // outside of destructuring it is a syntax error + return grammarErrorOnNode(prop.equalsToken, ts.Diagnostics.can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment); + } // ECMA-262 11.1.5 Object Initialiser // If previous is not undefined then throw a SyntaxError exception if any of the following conditions are true // a.This production is contained in strict code and IsDataDescriptor(previous) is true and @@ -26623,7 +27222,7 @@ var ts; // d.IsAccessorDescriptor(previous) is true and IsAccessorDescriptor(propId.descriptor) is true // and either both previous and propId.descriptor have[[Get]] fields or both previous and propId.descriptor have[[Set]] fields var currentKind = void 0; - if (prop.kind === 243 /* PropertyAssignment */ || prop.kind === 244 /* ShorthandPropertyAssignment */) { + if (prop.kind === 245 /* PropertyAssignment */ || prop.kind === 246 /* ShorthandPropertyAssignment */) { // Grammar checking for computedPropertName and shorthandPropertyAssignment checkGrammarForInvalidQuestionMark(prop, prop.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional); if (name_16.kind === 8 /* NumericLiteral */) { @@ -26631,13 +27230,13 @@ var ts; } currentKind = Property; } - else if (prop.kind === 141 /* MethodDeclaration */) { + else if (prop.kind === 143 /* MethodDeclaration */) { currentKind = Property; } - else if (prop.kind === 143 /* GetAccessor */) { + else if (prop.kind === 145 /* GetAccessor */) { currentKind = GetAccessor; } - else if (prop.kind === 144 /* SetAccessor */) { + else if (prop.kind === 146 /* SetAccessor */) { currentKind = SetAccesor; } else { @@ -26669,7 +27268,7 @@ var ts; var seen = {}; for (var _i = 0, _a = node.attributes; _i < _a.length; _i++) { var attr = _a[_i]; - if (attr.kind === 237 /* JsxSpreadAttribute */) { + if (attr.kind === 239 /* JsxSpreadAttribute */) { continue; } var jsxAttr = attr; @@ -26681,7 +27280,7 @@ var ts; return grammarErrorOnNode(name_17, ts.Diagnostics.JSX_elements_cannot_have_multiple_attributes_with_the_same_name); } var initializer = jsxAttr.initializer; - if (initializer && initializer.kind === 238 /* JsxExpression */ && !initializer.expression) { + if (initializer && initializer.kind === 240 /* JsxExpression */ && !initializer.expression) { return grammarErrorOnNode(jsxAttr.initializer, ts.Diagnostics.JSX_attributes_must_only_be_assigned_a_non_empty_expression); } } @@ -26690,24 +27289,24 @@ var ts; if (checkGrammarStatementInAmbientContext(forInOrOfStatement)) { return true; } - if (forInOrOfStatement.initializer.kind === 210 /* VariableDeclarationList */) { + if (forInOrOfStatement.initializer.kind === 212 /* VariableDeclarationList */) { var variableList = forInOrOfStatement.initializer; if (!checkGrammarVariableDeclarationList(variableList)) { if (variableList.declarations.length > 1) { - var diagnostic = forInOrOfStatement.kind === 198 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 200 /* ForInStatement */ ? ts.Diagnostics.Only_a_single_variable_declaration_is_allowed_in_a_for_in_statement : ts.Diagnostics.Only_a_single_variable_declaration_is_allowed_in_a_for_of_statement; return grammarErrorOnFirstToken(variableList.declarations[1], diagnostic); } var firstDeclaration = variableList.declarations[0]; if (firstDeclaration.initializer) { - var diagnostic = forInOrOfStatement.kind === 198 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 200 /* ForInStatement */ ? ts.Diagnostics.The_variable_declaration_of_a_for_in_statement_cannot_have_an_initializer : ts.Diagnostics.The_variable_declaration_of_a_for_of_statement_cannot_have_an_initializer; return grammarErrorOnNode(firstDeclaration.name, diagnostic); } if (firstDeclaration.type) { - var diagnostic = forInOrOfStatement.kind === 198 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 200 /* ForInStatement */ ? ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_use_a_type_annotation : ts.Diagnostics.The_left_hand_side_of_a_for_of_statement_cannot_use_a_type_annotation; return grammarErrorOnNode(firstDeclaration, diagnostic); @@ -26730,10 +27329,10 @@ var ts; else if (accessor.typeParameters) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.An_accessor_cannot_have_type_parameters); } - else if (kind === 143 /* GetAccessor */ && accessor.parameters.length) { + else if (kind === 145 /* GetAccessor */ && accessor.parameters.length) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_get_accessor_cannot_have_parameters); } - else if (kind === 144 /* SetAccessor */) { + else if (kind === 146 /* SetAccessor */) { if (accessor.type) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_set_accessor_cannot_have_a_return_type_annotation); } @@ -26758,7 +27357,7 @@ var ts; } } function checkGrammarForNonSymbolComputedProperty(node, message) { - if (node.kind === 134 /* ComputedPropertyName */ && !ts.isWellKnownSymbolSyntactically(node.expression)) { + if (node.kind === 136 /* ComputedPropertyName */ && !ts.isWellKnownSymbolSyntactically(node.expression)) { return grammarErrorOnNode(node, message); } } @@ -26768,7 +27367,7 @@ var ts; checkGrammarForGenerator(node)) { return true; } - if (node.parent.kind === 163 /* ObjectLiteralExpression */) { + if (node.parent.kind === 165 /* ObjectLiteralExpression */) { if (checkGrammarForInvalidQuestionMark(node, node.questionToken, ts.Diagnostics.A_class_member_cannot_be_declared_optional)) { return true; } @@ -26792,22 +27391,22 @@ var ts; return checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_method_overload_must_directly_refer_to_a_built_in_symbol); } } - else if (node.parent.kind === 213 /* InterfaceDeclaration */) { + else if (node.parent.kind === 215 /* InterfaceDeclaration */) { return checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_an_interface_must_directly_refer_to_a_built_in_symbol); } - else if (node.parent.kind === 153 /* TypeLiteral */) { + else if (node.parent.kind === 155 /* TypeLiteral */) { return checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_type_literal_must_directly_refer_to_a_built_in_symbol); } } function isIterationStatement(node, lookInLabeledStatements) { switch (node.kind) { - case 197 /* ForStatement */: - case 198 /* ForInStatement */: - case 199 /* ForOfStatement */: - case 195 /* DoStatement */: - case 196 /* WhileStatement */: + case 199 /* ForStatement */: + case 200 /* ForInStatement */: + case 201 /* ForOfStatement */: + case 197 /* DoStatement */: + case 198 /* WhileStatement */: return true; - case 205 /* LabeledStatement */: + case 207 /* LabeledStatement */: return lookInLabeledStatements && isIterationStatement(node.statement, lookInLabeledStatements); } return false; @@ -26819,11 +27418,11 @@ var ts; return grammarErrorOnNode(node, ts.Diagnostics.Jump_target_cannot_cross_function_boundary); } switch (current.kind) { - case 205 /* LabeledStatement */: + case 207 /* LabeledStatement */: if (node.label && current.label.text === node.label.text) { // found matching label - verify that label usage is correct // continue can only target labels that are on iteration statements - var isMisplacedContinueLabel = node.kind === 200 /* ContinueStatement */ + var isMisplacedContinueLabel = node.kind === 202 /* ContinueStatement */ && !isIterationStatement(current.statement, /*lookInLabeledStatement*/ true); if (isMisplacedContinueLabel) { return grammarErrorOnNode(node, ts.Diagnostics.A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement); @@ -26831,8 +27430,8 @@ var ts; return false; } break; - case 204 /* SwitchStatement */: - if (node.kind === 201 /* BreakStatement */ && !node.label) { + case 206 /* SwitchStatement */: + if (node.kind === 203 /* BreakStatement */ && !node.label) { // unlabeled break within switch statement - ok return false; } @@ -26847,13 +27446,13 @@ var ts; current = current.parent; } if (node.label) { - var message = node.kind === 201 /* BreakStatement */ + var message = node.kind === 203 /* BreakStatement */ ? ts.Diagnostics.A_break_statement_can_only_jump_to_a_label_of_an_enclosing_statement : ts.Diagnostics.A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement; return grammarErrorOnNode(node, message); } else { - var message = node.kind === 201 /* BreakStatement */ + var message = node.kind === 203 /* BreakStatement */ ? ts.Diagnostics.A_break_statement_can_only_be_used_within_an_enclosing_iteration_or_switch_statement : ts.Diagnostics.A_continue_statement_can_only_be_used_within_an_enclosing_iteration_statement; return grammarErrorOnNode(node, message); @@ -26865,7 +27464,7 @@ var ts; if (node !== ts.lastOrUndefined(elements)) { return grammarErrorOnNode(node, ts.Diagnostics.A_rest_element_must_be_last_in_an_array_destructuring_pattern); } - if (node.name.kind === 160 /* ArrayBindingPattern */ || node.name.kind === 159 /* ObjectBindingPattern */) { + if (node.name.kind === 162 /* ArrayBindingPattern */ || node.name.kind === 161 /* ObjectBindingPattern */) { return grammarErrorOnNode(node.name, ts.Diagnostics.A_rest_element_cannot_contain_a_binding_pattern); } if (node.initializer) { @@ -26875,7 +27474,7 @@ var ts; } } function checkGrammarVariableDeclaration(node) { - if (node.parent.parent.kind !== 198 /* ForInStatement */ && node.parent.parent.kind !== 199 /* ForOfStatement */) { + if (node.parent.parent.kind !== 200 /* ForInStatement */ && node.parent.parent.kind !== 201 /* ForOfStatement */) { if (ts.isInAmbientContext(node)) { if (node.initializer) { // Error on equals token which immediate precedes the initializer @@ -26902,7 +27501,7 @@ var ts; return checkLetConstNames && checkGrammarNameInLetOrConstDeclarations(node.name); } function checkGrammarNameInLetOrConstDeclarations(name) { - if (name.kind === 67 /* Identifier */) { + if (name.kind === 69 /* Identifier */) { if (name.text === "let") { return grammarErrorOnNode(name, ts.Diagnostics.let_is_not_allowed_to_be_used_as_a_name_in_let_or_const_declarations); } @@ -26911,7 +27510,7 @@ var ts; var elements = name.elements; for (var _i = 0; _i < elements.length; _i++) { var element = elements[_i]; - if (element.kind !== 185 /* OmittedExpression */) { + if (element.kind !== 187 /* OmittedExpression */) { checkGrammarNameInLetOrConstDeclarations(element.name); } } @@ -26928,15 +27527,15 @@ var ts; } function allowLetAndConstDeclarations(parent) { switch (parent.kind) { - case 194 /* IfStatement */: - case 195 /* DoStatement */: - case 196 /* WhileStatement */: - case 203 /* WithStatement */: - case 197 /* ForStatement */: - case 198 /* ForInStatement */: - case 199 /* ForOfStatement */: + case 196 /* IfStatement */: + case 197 /* DoStatement */: + case 198 /* WhileStatement */: + case 205 /* WithStatement */: + case 199 /* ForStatement */: + case 200 /* ForInStatement */: + case 201 /* ForOfStatement */: return false; - case 205 /* LabeledStatement */: + case 207 /* LabeledStatement */: return allowLetAndConstDeclarations(parent.parent); } return true; @@ -26952,7 +27551,7 @@ var ts; } } function isIntegerLiteral(expression) { - if (expression.kind === 177 /* PrefixUnaryExpression */) { + if (expression.kind === 179 /* PrefixUnaryExpression */) { var unaryExpression = expression; if (unaryExpression.operator === 35 /* PlusToken */ || unaryExpression.operator === 36 /* MinusToken */) { expression = unaryExpression.operand; @@ -26968,37 +27567,6 @@ var ts; } return false; } - function checkGrammarEnumDeclaration(enumDecl) { - var enumIsConst = (enumDecl.flags & 32768 /* Const */) !== 0; - var hasError = false; - // skip checks below for const enums - they allow arbitrary initializers as long as they can be evaluated to constant expressions. - // since all values are known in compile time - it is not necessary to check that constant enum section precedes computed enum members. - if (!enumIsConst) { - var inConstantEnumMemberSection = true; - var inAmbientContext = ts.isInAmbientContext(enumDecl); - for (var _i = 0, _a = enumDecl.members; _i < _a.length; _i++) { - var node = _a[_i]; - // Do not use hasDynamicName here, because that returns false for well known symbols. - // We want to perform checkComputedPropertyName for all computed properties, including - // well known symbols. - if (node.name.kind === 134 /* ComputedPropertyName */) { - hasError = grammarErrorOnNode(node.name, ts.Diagnostics.Computed_property_names_are_not_allowed_in_enums); - } - else if (inAmbientContext) { - if (node.initializer && !isIntegerLiteral(node.initializer)) { - hasError = grammarErrorOnNode(node.name, ts.Diagnostics.Ambient_enum_elements_can_only_have_integer_literal_initializers) || hasError; - } - } - else if (node.initializer) { - inConstantEnumMemberSection = isIntegerLiteral(node.initializer); - } - else if (!inConstantEnumMemberSection) { - hasError = grammarErrorOnNode(node.name, ts.Diagnostics.Enum_member_must_have_initializer) || hasError; - } - } - } - return hasError; - } function hasParseDiagnostics(sourceFile) { return sourceFile.parseDiagnostics.length > 0; } @@ -27024,7 +27592,7 @@ var ts; } } function isEvalOrArgumentsIdentifier(node) { - return node.kind === 67 /* Identifier */ && + return node.kind === 69 /* Identifier */ && (node.text === "eval" || node.text === "arguments"); } function checkGrammarConstructorTypeParameters(node) { @@ -27044,12 +27612,12 @@ var ts; return true; } } - else if (node.parent.kind === 213 /* InterfaceDeclaration */) { + else if (node.parent.kind === 215 /* InterfaceDeclaration */) { if (checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_an_interface_must_directly_refer_to_a_built_in_symbol)) { return true; } } - else if (node.parent.kind === 153 /* TypeLiteral */) { + else if (node.parent.kind === 155 /* TypeLiteral */) { if (checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_type_literal_must_directly_refer_to_a_built_in_symbol)) { return true; } @@ -27069,11 +27637,11 @@ var ts; // export_opt ExternalImportDeclaration // export_opt AmbientDeclaration // - if (node.kind === 213 /* InterfaceDeclaration */ || - node.kind === 220 /* ImportDeclaration */ || - node.kind === 219 /* ImportEqualsDeclaration */ || - node.kind === 226 /* ExportDeclaration */ || - node.kind === 225 /* ExportAssignment */ || + if (node.kind === 215 /* InterfaceDeclaration */ || + node.kind === 222 /* ImportDeclaration */ || + node.kind === 221 /* ImportEqualsDeclaration */ || + node.kind === 228 /* ExportDeclaration */ || + node.kind === 227 /* ExportAssignment */ || (node.flags & 2 /* Ambient */) || (node.flags & (1 /* Export */ | 1024 /* Default */))) { return false; @@ -27083,7 +27651,7 @@ var ts; function checkGrammarTopLevelElementsForRequiredDeclareModifier(file) { for (var _i = 0, _a = file.statements; _i < _a.length; _i++) { var decl = _a[_i]; - if (ts.isDeclaration(decl) || decl.kind === 191 /* VariableStatement */) { + if (ts.isDeclaration(decl) || decl.kind === 193 /* VariableStatement */) { if (checkGrammarTopLevelElementForRequiredDeclareModifier(decl)) { return true; } @@ -27109,7 +27677,7 @@ var ts; // to prevent noisyness. So use a bit on the block to indicate if // this has already been reported, and don't report if it has. // - if (node.parent.kind === 190 /* Block */ || node.parent.kind === 217 /* ModuleBlock */ || node.parent.kind === 246 /* SourceFile */) { + if (node.parent.kind === 192 /* Block */ || node.parent.kind === 219 /* ModuleBlock */ || node.parent.kind === 248 /* SourceFile */) { var links_1 = getNodeLinks(node.parent); // Check if the containing block ever report this error if (!links_1.hasReportedStatementInAmbientContext) { @@ -27160,6 +27728,7 @@ var ts; var enclosingDeclaration; var currentSourceFile; var reportedDeclarationError = false; + var errorNameNode; var emitJsDocComments = compilerOptions.removeComments ? function (declaration) { } : writeJsDocComments; var emit = compilerOptions.stripInternal ? stripInternal : emitNode; var moduleElementDeclarationEmitInfo = []; @@ -27191,7 +27760,7 @@ var ts; var oldWriter = writer; ts.forEach(moduleElementDeclarationEmitInfo, function (aliasEmitInfo) { if (aliasEmitInfo.isVisible) { - ts.Debug.assert(aliasEmitInfo.node.kind === 220 /* ImportDeclaration */); + ts.Debug.assert(aliasEmitInfo.node.kind === 222 /* ImportDeclaration */); createAndSetNewTextWriterWithSymbolWriter(); ts.Debug.assert(aliasEmitInfo.indent === 0); writeImportDeclaration(aliasEmitInfo.node); @@ -27245,6 +27814,7 @@ var ts; function createAndSetNewTextWriterWithSymbolWriter() { var writer = ts.createTextWriter(newLine); writer.trackSymbol = trackSymbol; + writer.reportInaccessibleThisError = reportInaccessibleThisError; writer.writeKeyword = writer.write; writer.writeOperator = writer.write; writer.writePunctuation = writer.write; @@ -27267,10 +27837,10 @@ var ts; var oldWriter = writer; ts.forEach(nodes, function (declaration) { var nodeToCheck; - if (declaration.kind === 209 /* VariableDeclaration */) { + if (declaration.kind === 211 /* VariableDeclaration */) { nodeToCheck = declaration.parent.parent; } - else if (declaration.kind === 223 /* NamedImports */ || declaration.kind === 224 /* ImportSpecifier */ || declaration.kind === 221 /* ImportClause */) { + else if (declaration.kind === 225 /* NamedImports */ || declaration.kind === 226 /* ImportSpecifier */ || declaration.kind === 223 /* ImportClause */) { ts.Debug.fail("We should be getting ImportDeclaration instead to write"); } else { @@ -27288,7 +27858,7 @@ var ts; // Writing of function bar would mark alias declaration foo as visible but we haven't yet visited that declaration so do nothing, // we would write alias foo declaration when we visit it since it would now be marked as visible if (moduleElementEmitInfo) { - if (moduleElementEmitInfo.node.kind === 220 /* ImportDeclaration */) { + if (moduleElementEmitInfo.node.kind === 222 /* ImportDeclaration */) { // we have to create asynchronous output only after we have collected complete information // because it is possible to enable multiple bindings as asynchronously visible moduleElementEmitInfo.isVisible = true; @@ -27298,12 +27868,12 @@ var ts; for (var declarationIndent = moduleElementEmitInfo.indent; declarationIndent; declarationIndent--) { increaseIndent(); } - if (nodeToCheck.kind === 216 /* ModuleDeclaration */) { + if (nodeToCheck.kind === 218 /* ModuleDeclaration */) { ts.Debug.assert(asynchronousSubModuleDeclarationEmitInfo === undefined); asynchronousSubModuleDeclarationEmitInfo = []; } writeModuleElement(nodeToCheck); - if (nodeToCheck.kind === 216 /* ModuleDeclaration */) { + if (nodeToCheck.kind === 218 /* ModuleDeclaration */) { moduleElementEmitInfo.subModuleElementDeclarationEmitInfo = asynchronousSubModuleDeclarationEmitInfo; asynchronousSubModuleDeclarationEmitInfo = undefined; } @@ -27337,6 +27907,11 @@ var ts; function trackSymbol(symbol, enclosingDeclaration, meaning) { handleSymbolAccessibilityError(resolver.isSymbolAccessible(symbol, enclosingDeclaration, meaning)); } + function reportInaccessibleThisError() { + if (errorNameNode) { + diagnostics.push(ts.createDiagnosticForNode(errorNameNode, ts.Diagnostics.The_inferred_type_of_0_references_an_inaccessible_this_type_A_type_annotation_is_necessary, ts.declarationNameToString(errorNameNode))); + } + } function writeTypeOfDeclaration(declaration, type, getSymbolAccessibilityDiagnostic) { writer.getSymbolAccessibilityDiagnostic = getSymbolAccessibilityDiagnostic; write(": "); @@ -27345,7 +27920,9 @@ var ts; emitType(type); } else { + errorNameNode = declaration.name; resolver.writeTypeOfDeclaration(declaration, enclosingDeclaration, 2 /* UseTypeOfFunction */, writer); + errorNameNode = undefined; } } function writeReturnTypeAtSignature(signature, getSymbolAccessibilityDiagnostic) { @@ -27356,7 +27933,9 @@ var ts; emitType(signature.type); } else { + errorNameNode = signature.name; resolver.writeReturnTypeOfSignatureDeclaration(signature, enclosingDeclaration, 2 /* UseTypeOfFunction */, writer); + errorNameNode = undefined; } } function emitLines(nodes) { @@ -27395,49 +27974,50 @@ var ts; } function emitType(type) { switch (type.kind) { - case 115 /* AnyKeyword */: - case 128 /* StringKeyword */: - case 126 /* NumberKeyword */: - case 118 /* BooleanKeyword */: - case 129 /* SymbolKeyword */: - case 101 /* VoidKeyword */: + case 117 /* AnyKeyword */: + case 130 /* StringKeyword */: + case 128 /* NumberKeyword */: + case 120 /* BooleanKeyword */: + case 131 /* SymbolKeyword */: + case 103 /* VoidKeyword */: + case 97 /* ThisKeyword */: case 9 /* StringLiteral */: return writeTextOfNode(currentSourceFile, type); - case 186 /* ExpressionWithTypeArguments */: + case 188 /* ExpressionWithTypeArguments */: return emitExpressionWithTypeArguments(type); - case 149 /* TypeReference */: + case 151 /* TypeReference */: return emitTypeReference(type); - case 152 /* TypeQuery */: + case 154 /* TypeQuery */: return emitTypeQuery(type); - case 154 /* ArrayType */: + case 156 /* ArrayType */: return emitArrayType(type); - case 155 /* TupleType */: + case 157 /* TupleType */: return emitTupleType(type); - case 156 /* UnionType */: + case 158 /* UnionType */: return emitUnionType(type); - case 157 /* IntersectionType */: + case 159 /* IntersectionType */: return emitIntersectionType(type); - case 158 /* ParenthesizedType */: + case 160 /* ParenthesizedType */: return emitParenType(type); - case 150 /* FunctionType */: - case 151 /* ConstructorType */: + case 152 /* FunctionType */: + case 153 /* ConstructorType */: return emitSignatureDeclarationWithJsDocComments(type); - case 153 /* TypeLiteral */: + case 155 /* TypeLiteral */: return emitTypeLiteral(type); - case 67 /* Identifier */: + case 69 /* Identifier */: return emitEntityName(type); - case 133 /* QualifiedName */: + case 135 /* QualifiedName */: return emitEntityName(type); - case 148 /* TypePredicate */: + case 150 /* TypePredicate */: return emitTypePredicate(type); } function writeEntityName(entityName) { - if (entityName.kind === 67 /* Identifier */) { + if (entityName.kind === 69 /* Identifier */) { writeTextOfNode(currentSourceFile, entityName); } else { - var left = entityName.kind === 133 /* QualifiedName */ ? entityName.left : entityName.expression; - var right = entityName.kind === 133 /* QualifiedName */ ? entityName.right : entityName.name; + var left = entityName.kind === 135 /* QualifiedName */ ? entityName.left : entityName.expression; + var right = entityName.kind === 135 /* QualifiedName */ ? entityName.right : entityName.name; writeEntityName(left); write("."); writeTextOfNode(currentSourceFile, right); @@ -27446,13 +28026,13 @@ var ts; function emitEntityName(entityName) { var visibilityResult = resolver.isEntityNameVisible(entityName, // Aliases can be written asynchronously so use correct enclosing declaration - entityName.parent.kind === 219 /* ImportEqualsDeclaration */ ? entityName.parent : enclosingDeclaration); + entityName.parent.kind === 221 /* ImportEqualsDeclaration */ ? entityName.parent : enclosingDeclaration); handleSymbolAccessibilityError(visibilityResult); writeEntityName(entityName); } function emitExpressionWithTypeArguments(node) { if (ts.isSupportedExpressionWithTypeArguments(node)) { - ts.Debug.assert(node.expression.kind === 67 /* Identifier */ || node.expression.kind === 164 /* PropertyAccessExpression */); + ts.Debug.assert(node.expression.kind === 69 /* Identifier */ || node.expression.kind === 166 /* PropertyAccessExpression */); emitEntityName(node.expression); if (node.typeArguments) { write("<"); @@ -27533,7 +28113,7 @@ var ts; } } function emitExportAssignment(node) { - if (node.expression.kind === 67 /* Identifier */) { + if (node.expression.kind === 69 /* Identifier */) { write(node.isExportEquals ? "export = " : "export default "); writeTextOfNode(currentSourceFile, node.expression); } @@ -27553,7 +28133,7 @@ var ts; write(";"); writeLine(); // Make all the declarations visible for the export name - if (node.expression.kind === 67 /* Identifier */) { + if (node.expression.kind === 69 /* Identifier */) { var nodes = resolver.collectLinkedAliases(node.expression); // write each of these declarations asynchronously writeAsynchronousModuleElements(nodes); @@ -27572,10 +28152,10 @@ var ts; if (isModuleElementVisible) { writeModuleElement(node); } - else if (node.kind === 219 /* ImportEqualsDeclaration */ || - (node.parent.kind === 246 /* SourceFile */ && ts.isExternalModule(currentSourceFile))) { + else if (node.kind === 221 /* ImportEqualsDeclaration */ || + (node.parent.kind === 248 /* SourceFile */ && ts.isExternalModule(currentSourceFile))) { var isVisible; - if (asynchronousSubModuleDeclarationEmitInfo && node.parent.kind !== 246 /* SourceFile */) { + if (asynchronousSubModuleDeclarationEmitInfo && node.parent.kind !== 248 /* SourceFile */) { // Import declaration of another module that is visited async so lets put it in right spot asynchronousSubModuleDeclarationEmitInfo.push({ node: node, @@ -27585,7 +28165,7 @@ var ts; }); } else { - if (node.kind === 220 /* ImportDeclaration */) { + if (node.kind === 222 /* ImportDeclaration */) { var importDeclaration = node; if (importDeclaration.importClause) { isVisible = (importDeclaration.importClause.name && resolver.isDeclarationVisible(importDeclaration.importClause)) || @@ -27603,23 +28183,23 @@ var ts; } function writeModuleElement(node) { switch (node.kind) { - case 211 /* FunctionDeclaration */: + case 213 /* FunctionDeclaration */: return writeFunctionDeclaration(node); - case 191 /* VariableStatement */: + case 193 /* VariableStatement */: return writeVariableStatement(node); - case 213 /* InterfaceDeclaration */: + case 215 /* InterfaceDeclaration */: return writeInterfaceDeclaration(node); - case 212 /* ClassDeclaration */: + case 214 /* ClassDeclaration */: return writeClassDeclaration(node); - case 214 /* TypeAliasDeclaration */: + case 216 /* TypeAliasDeclaration */: return writeTypeAliasDeclaration(node); - case 215 /* EnumDeclaration */: + case 217 /* EnumDeclaration */: return writeEnumDeclaration(node); - case 216 /* ModuleDeclaration */: + case 218 /* ModuleDeclaration */: return writeModuleDeclaration(node); - case 219 /* ImportEqualsDeclaration */: + case 221 /* ImportEqualsDeclaration */: return writeImportEqualsDeclaration(node); - case 220 /* ImportDeclaration */: + case 222 /* ImportDeclaration */: return writeImportDeclaration(node); default: ts.Debug.fail("Unknown symbol kind"); @@ -27635,7 +28215,7 @@ var ts; if (node.flags & 1024 /* Default */) { write("default "); } - else if (node.kind !== 213 /* InterfaceDeclaration */) { + else if (node.kind !== 215 /* InterfaceDeclaration */) { write("declare "); } } @@ -27684,7 +28264,7 @@ var ts; } function isVisibleNamedBinding(namedBindings) { if (namedBindings) { - if (namedBindings.kind === 222 /* NamespaceImport */) { + if (namedBindings.kind === 224 /* NamespaceImport */) { return resolver.isDeclarationVisible(namedBindings); } else { @@ -27712,7 +28292,7 @@ var ts; // If the default binding was emitted, write the separated write(", "); } - if (node.importClause.namedBindings.kind === 222 /* NamespaceImport */) { + if (node.importClause.namedBindings.kind === 224 /* NamespaceImport */) { write("* as "); writeTextOfNode(currentSourceFile, node.importClause.namedBindings.name); } @@ -27770,7 +28350,7 @@ var ts; write("module "); } writeTextOfNode(currentSourceFile, node.name); - while (node.body.kind !== 217 /* ModuleBlock */) { + while (node.body.kind !== 219 /* ModuleBlock */) { node = node.body; write("."); writeTextOfNode(currentSourceFile, node.name); @@ -27835,7 +28415,7 @@ var ts; writeLine(); } function isPrivateMethodTypeParameter(node) { - return node.parent.kind === 141 /* MethodDeclaration */ && (node.parent.flags & 32 /* Private */); + return node.parent.kind === 143 /* MethodDeclaration */ && (node.parent.flags & 32 /* Private */); } function emitTypeParameters(typeParameters) { function emitTypeParameter(node) { @@ -27846,15 +28426,15 @@ var ts; // If there is constraint present and this is not a type parameter of the private method emit the constraint if (node.constraint && !isPrivateMethodTypeParameter(node)) { write(" extends "); - if (node.parent.kind === 150 /* FunctionType */ || - node.parent.kind === 151 /* ConstructorType */ || - (node.parent.parent && node.parent.parent.kind === 153 /* TypeLiteral */)) { - ts.Debug.assert(node.parent.kind === 141 /* MethodDeclaration */ || - node.parent.kind === 140 /* MethodSignature */ || - node.parent.kind === 150 /* FunctionType */ || - node.parent.kind === 151 /* ConstructorType */ || - node.parent.kind === 145 /* CallSignature */ || - node.parent.kind === 146 /* ConstructSignature */); + if (node.parent.kind === 152 /* FunctionType */ || + node.parent.kind === 153 /* ConstructorType */ || + (node.parent.parent && node.parent.parent.kind === 155 /* TypeLiteral */)) { + ts.Debug.assert(node.parent.kind === 143 /* MethodDeclaration */ || + node.parent.kind === 142 /* MethodSignature */ || + node.parent.kind === 152 /* FunctionType */ || + node.parent.kind === 153 /* ConstructorType */ || + node.parent.kind === 147 /* CallSignature */ || + node.parent.kind === 148 /* ConstructSignature */); emitType(node.constraint); } else { @@ -27865,31 +28445,31 @@ var ts; // Type parameter constraints are named by user so we should always be able to name it var diagnosticMessage; switch (node.parent.kind) { - case 212 /* ClassDeclaration */: + case 214 /* ClassDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_class_has_or_is_using_private_name_1; break; - case 213 /* InterfaceDeclaration */: + case 215 /* InterfaceDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1; break; - case 146 /* ConstructSignature */: + case 148 /* ConstructSignature */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 145 /* CallSignature */: + case 147 /* CallSignature */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 141 /* MethodDeclaration */: - case 140 /* MethodSignature */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: if (node.parent.flags & 128 /* Static */) { diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.parent.kind === 212 /* ClassDeclaration */) { + else if (node.parent.parent.kind === 214 /* ClassDeclaration */) { diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_public_method_from_exported_class_has_or_is_using_private_name_1; } else { diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1; } break; - case 211 /* FunctionDeclaration */: + case 213 /* FunctionDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_function_has_or_is_using_private_name_1; break; default: @@ -27917,13 +28497,13 @@ var ts; if (ts.isSupportedExpressionWithTypeArguments(node)) { emitTypeWithNewGetSymbolAccessibilityDiagnostic(node, getHeritageClauseVisibilityError); } - else if (!isImplementsList && node.expression.kind === 91 /* NullKeyword */) { + else if (!isImplementsList && node.expression.kind === 93 /* NullKeyword */) { write("null"); } function getHeritageClauseVisibilityError(symbolAccesibilityResult) { var diagnosticMessage; // Heritage clause is written by user so it can always be named - if (node.parent.parent.kind === 212 /* ClassDeclaration */) { + if (node.parent.parent.kind === 214 /* ClassDeclaration */) { // Class or Interface implemented/extended is inaccessible diagnosticMessage = isImplementsList ? ts.Diagnostics.Implements_clause_of_exported_class_0_has_or_is_using_private_name_1 : @@ -28007,7 +28587,7 @@ var ts; function emitVariableDeclaration(node) { // If we are emitting property it isn't moduleElement and hence we already know it needs to be emitted // so there is no check needed to see if declaration is visible - if (node.kind !== 209 /* VariableDeclaration */ || resolver.isDeclarationVisible(node)) { + if (node.kind !== 211 /* VariableDeclaration */ || resolver.isDeclarationVisible(node)) { if (ts.isBindingPattern(node.name)) { emitBindingPattern(node.name); } @@ -28017,10 +28597,10 @@ var ts; // what we want, namely the name expression enclosed in brackets. writeTextOfNode(currentSourceFile, node.name); // If optional property emit ? - if ((node.kind === 139 /* PropertyDeclaration */ || node.kind === 138 /* PropertySignature */) && ts.hasQuestionToken(node)) { + if ((node.kind === 141 /* PropertyDeclaration */ || node.kind === 140 /* PropertySignature */) && ts.hasQuestionToken(node)) { write("?"); } - if ((node.kind === 139 /* PropertyDeclaration */ || node.kind === 138 /* PropertySignature */) && node.parent.kind === 153 /* TypeLiteral */) { + if ((node.kind === 141 /* PropertyDeclaration */ || node.kind === 140 /* PropertySignature */) && node.parent.kind === 155 /* TypeLiteral */) { emitTypeOfVariableDeclarationFromTypeLiteral(node); } else if (!(node.flags & 32 /* Private */)) { @@ -28029,14 +28609,14 @@ var ts; } } function getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccesibilityResult) { - if (node.kind === 209 /* VariableDeclaration */) { + if (node.kind === 211 /* VariableDeclaration */) { return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Exported_variable_0_has_or_is_using_private_name_1; } - else if (node.kind === 139 /* PropertyDeclaration */ || node.kind === 138 /* PropertySignature */) { + else if (node.kind === 141 /* PropertyDeclaration */ || node.kind === 140 /* PropertySignature */) { // TODO(jfreeman): Deal with computed properties in error reporting. if (node.flags & 128 /* Static */) { return symbolAccesibilityResult.errorModuleName ? @@ -28045,7 +28625,7 @@ var ts; ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.kind === 212 /* ClassDeclaration */) { + else if (node.parent.kind === 214 /* ClassDeclaration */) { return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -28077,7 +28657,7 @@ var ts; var elements = []; for (var _i = 0, _a = bindingPattern.elements; _i < _a.length; _i++) { var element = _a[_i]; - if (element.kind !== 185 /* OmittedExpression */) { + if (element.kind !== 187 /* OmittedExpression */) { elements.push(element); } } @@ -28147,7 +28727,7 @@ var ts; var type = getTypeAnnotationFromAccessor(node); if (!type) { // couldn't get type for the first accessor, try the another one - var anotherAccessor = node.kind === 143 /* GetAccessor */ ? accessors.setAccessor : accessors.getAccessor; + var anotherAccessor = node.kind === 145 /* GetAccessor */ ? accessors.setAccessor : accessors.getAccessor; type = getTypeAnnotationFromAccessor(anotherAccessor); if (type) { accessorWithTypeAnnotation = anotherAccessor; @@ -28160,7 +28740,7 @@ var ts; } function getTypeAnnotationFromAccessor(accessor) { if (accessor) { - return accessor.kind === 143 /* GetAccessor */ + return accessor.kind === 145 /* GetAccessor */ ? accessor.type // Getter - return type : accessor.parameters.length > 0 ? accessor.parameters[0].type // Setter parameter type @@ -28169,7 +28749,7 @@ var ts; } function getAccessorDeclarationTypeVisibilityError(symbolAccesibilityResult) { var diagnosticMessage; - if (accessorWithTypeAnnotation.kind === 144 /* SetAccessor */) { + if (accessorWithTypeAnnotation.kind === 146 /* SetAccessor */) { // Setters have to have type named and cannot infer it so, the type should always be named if (accessorWithTypeAnnotation.parent.flags & 128 /* Static */) { diagnosticMessage = symbolAccesibilityResult.errorModuleName ? @@ -28219,17 +28799,17 @@ var ts; // so no need to verify if the declaration is visible if (!resolver.isImplementationOfOverload(node)) { emitJsDocComments(node); - if (node.kind === 211 /* FunctionDeclaration */) { + if (node.kind === 213 /* FunctionDeclaration */) { emitModuleElementDeclarationFlags(node); } - else if (node.kind === 141 /* MethodDeclaration */) { + else if (node.kind === 143 /* MethodDeclaration */) { emitClassMemberDeclarationFlags(node); } - if (node.kind === 211 /* FunctionDeclaration */) { + if (node.kind === 213 /* FunctionDeclaration */) { write("function "); writeTextOfNode(currentSourceFile, node.name); } - else if (node.kind === 142 /* Constructor */) { + else if (node.kind === 144 /* Constructor */) { write("constructor"); } else { @@ -28247,11 +28827,11 @@ var ts; } function emitSignatureDeclaration(node) { // Construct signature or constructor type write new Signature - if (node.kind === 146 /* ConstructSignature */ || node.kind === 151 /* ConstructorType */) { + if (node.kind === 148 /* ConstructSignature */ || node.kind === 153 /* ConstructorType */) { write("new "); } emitTypeParameters(node.typeParameters); - if (node.kind === 147 /* IndexSignature */) { + if (node.kind === 149 /* IndexSignature */) { write("["); } else { @@ -28261,22 +28841,22 @@ var ts; enclosingDeclaration = node; // Parameters emitCommaList(node.parameters, emitParameterDeclaration); - if (node.kind === 147 /* IndexSignature */) { + if (node.kind === 149 /* IndexSignature */) { write("]"); } else { write(")"); } // If this is not a constructor and is not private, emit the return type - var isFunctionTypeOrConstructorType = node.kind === 150 /* FunctionType */ || node.kind === 151 /* ConstructorType */; - if (isFunctionTypeOrConstructorType || node.parent.kind === 153 /* TypeLiteral */) { + var isFunctionTypeOrConstructorType = node.kind === 152 /* FunctionType */ || node.kind === 153 /* ConstructorType */; + if (isFunctionTypeOrConstructorType || node.parent.kind === 155 /* TypeLiteral */) { // Emit type literal signature return type only if specified if (node.type) { write(isFunctionTypeOrConstructorType ? " => " : ": "); emitType(node.type); } } - else if (node.kind !== 142 /* Constructor */ && !(node.flags & 32 /* Private */)) { + else if (node.kind !== 144 /* Constructor */ && !(node.flags & 32 /* Private */)) { writeReturnTypeAtSignature(node, getReturnTypeVisibilityError); } enclosingDeclaration = prevEnclosingDeclaration; @@ -28287,26 +28867,26 @@ var ts; function getReturnTypeVisibilityError(symbolAccesibilityResult) { var diagnosticMessage; switch (node.kind) { - case 146 /* ConstructSignature */: + case 148 /* ConstructSignature */: // Interfaces cannot have return types that cannot be named diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_0; break; - case 145 /* CallSignature */: + case 147 /* CallSignature */: // Interfaces cannot have return types that cannot be named diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_call_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_call_signature_from_exported_interface_has_or_is_using_private_name_0; break; - case 147 /* IndexSignature */: + case 149 /* IndexSignature */: // Interfaces cannot have return types that cannot be named diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_index_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_index_signature_from_exported_interface_has_or_is_using_private_name_0; break; - case 141 /* MethodDeclaration */: - case 140 /* MethodSignature */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: if (node.flags & 128 /* Static */) { diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? @@ -28314,7 +28894,7 @@ var ts; ts.Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_private_name_0; } - else if (node.parent.kind === 212 /* ClassDeclaration */) { + else if (node.parent.kind === 214 /* ClassDeclaration */) { diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : @@ -28328,7 +28908,7 @@ var ts; ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0; } break; - case 211 /* FunctionDeclaration */: + case 213 /* FunctionDeclaration */: diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : @@ -28363,9 +28943,9 @@ var ts; write("?"); } decreaseIndent(); - if (node.parent.kind === 150 /* FunctionType */ || - node.parent.kind === 151 /* ConstructorType */ || - node.parent.parent.kind === 153 /* TypeLiteral */) { + if (node.parent.kind === 152 /* FunctionType */ || + node.parent.kind === 153 /* ConstructorType */ || + node.parent.parent.kind === 155 /* TypeLiteral */) { emitTypeOfVariableDeclarationFromTypeLiteral(node); } else if (!(node.parent.flags & 32 /* Private */)) { @@ -28381,24 +28961,24 @@ var ts; } function getParameterDeclarationTypeVisibilityDiagnosticMessage(symbolAccesibilityResult) { switch (node.parent.kind) { - case 142 /* Constructor */: + case 144 /* Constructor */: return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_private_name_1; - case 146 /* ConstructSignature */: + case 148 /* ConstructSignature */: // Interfaces cannot have parameter types that cannot be named return symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; - case 145 /* CallSignature */: + case 147 /* CallSignature */: // Interfaces cannot have parameter types that cannot be named return symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; - case 141 /* MethodDeclaration */: - case 140 /* MethodSignature */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: if (node.parent.flags & 128 /* Static */) { return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? @@ -28406,7 +28986,7 @@ var ts; ts.Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.parent.kind === 212 /* ClassDeclaration */) { + else if (node.parent.parent.kind === 214 /* ClassDeclaration */) { return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -28419,7 +28999,7 @@ var ts; ts.Diagnostics.Parameter_0_of_method_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1; } - case 211 /* FunctionDeclaration */: + case 213 /* FunctionDeclaration */: return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -28431,12 +29011,12 @@ var ts; } function emitBindingPattern(bindingPattern) { // We have to explicitly emit square bracket and bracket because these tokens are not store inside the node. - if (bindingPattern.kind === 159 /* ObjectBindingPattern */) { + if (bindingPattern.kind === 161 /* ObjectBindingPattern */) { write("{"); emitCommaList(bindingPattern.elements, emitBindingElement); write("}"); } - else if (bindingPattern.kind === 160 /* ArrayBindingPattern */) { + else if (bindingPattern.kind === 162 /* ArrayBindingPattern */) { write("["); var elements = bindingPattern.elements; emitCommaList(elements, emitBindingElement); @@ -28455,7 +29035,7 @@ var ts; typeName: bindingElement.name } : undefined; } - if (bindingElement.kind === 185 /* OmittedExpression */) { + if (bindingElement.kind === 187 /* OmittedExpression */) { // If bindingElement is an omittedExpression (i.e. containing elision), // we will emit blank space (although this may differ from users' original code, // it allows emitSeparatedList to write separator appropriately) @@ -28464,7 +29044,7 @@ var ts; // emit : function foo([ , x, , ]) {} write(" "); } - else if (bindingElement.kind === 161 /* BindingElement */) { + else if (bindingElement.kind === 163 /* BindingElement */) { if (bindingElement.propertyName) { // bindingElement has propertyName property in the following case: // { y: [a,b,c] ...} -> bindingPattern will have a property called propertyName for "y" @@ -28487,7 +29067,7 @@ var ts; emitBindingPattern(bindingElement.name); } else { - ts.Debug.assert(bindingElement.name.kind === 67 /* Identifier */); + ts.Debug.assert(bindingElement.name.kind === 69 /* Identifier */); // If the node is just an identifier, we will simply emit the text associated with the node's name // Example: // original: function foo({y = 10, x}) {} @@ -28503,40 +29083,40 @@ var ts; } function emitNode(node) { switch (node.kind) { - case 211 /* FunctionDeclaration */: - case 216 /* ModuleDeclaration */: - case 219 /* ImportEqualsDeclaration */: - case 213 /* InterfaceDeclaration */: - case 212 /* ClassDeclaration */: - case 214 /* TypeAliasDeclaration */: - case 215 /* EnumDeclaration */: + case 213 /* FunctionDeclaration */: + case 218 /* ModuleDeclaration */: + case 221 /* ImportEqualsDeclaration */: + case 215 /* InterfaceDeclaration */: + case 214 /* ClassDeclaration */: + case 216 /* TypeAliasDeclaration */: + case 217 /* EnumDeclaration */: return emitModuleElement(node, isModuleElementVisible(node)); - case 191 /* VariableStatement */: + case 193 /* VariableStatement */: return emitModuleElement(node, isVariableStatementVisible(node)); - case 220 /* ImportDeclaration */: + case 222 /* ImportDeclaration */: // Import declaration without import clause is visible, otherwise it is not visible return emitModuleElement(node, /*isModuleElementVisible*/ !node.importClause); - case 226 /* ExportDeclaration */: + case 228 /* ExportDeclaration */: return emitExportDeclaration(node); - case 142 /* Constructor */: - case 141 /* MethodDeclaration */: - case 140 /* MethodSignature */: + case 144 /* Constructor */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: return writeFunctionDeclaration(node); - case 146 /* ConstructSignature */: - case 145 /* CallSignature */: - case 147 /* IndexSignature */: + case 148 /* ConstructSignature */: + case 147 /* CallSignature */: + case 149 /* IndexSignature */: return emitSignatureDeclarationWithJsDocComments(node); - case 143 /* GetAccessor */: - case 144 /* SetAccessor */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: return emitAccessorDeclaration(node); - case 139 /* PropertyDeclaration */: - case 138 /* PropertySignature */: + case 141 /* PropertyDeclaration */: + case 140 /* PropertySignature */: return emitPropertyDeclaration(node); - case 245 /* EnumMember */: + case 247 /* EnumMember */: return emitEnumMemberDeclaration(node); - case 225 /* ExportAssignment */: + case 227 /* ExportAssignment */: return emitExportAssignment(node); - case 246 /* SourceFile */: + case 248 /* SourceFile */: return emitSourceFile(node); } } @@ -28587,6425 +29167,6 @@ var ts; return ts.isExternalModule(sourceFile) || ts.isDeclarationFile(sourceFile); } ts.isExternalModuleOrDeclarationFile = isExternalModuleOrDeclarationFile; - // Flags enum to track count of temp variables and a few dedicated names - var TempFlags; - (function (TempFlags) { - TempFlags[TempFlags["Auto"] = 0] = "Auto"; - TempFlags[TempFlags["CountMask"] = 268435455] = "CountMask"; - TempFlags[TempFlags["_i"] = 268435456] = "_i"; - })(TempFlags || (TempFlags = {})); - // 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) { - // emit output for the __extends helper function - var extendsHelper = "\nvar __extends = (this && this.__extends) || function (d, b) {\n for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];\n function __() { this.constructor = d; }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n};"; - // emit output for the __decorate helper function - var decorateHelper = "\nvar __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") return Reflect.decorate(decorators, target, key, desc);\n switch (arguments.length) {\n case 2: return decorators.reduceRight(function(o, d) { return (d && d(o)) || o; }, target);\n case 3: return decorators.reduceRight(function(o, d) { return (d && d(target, key)), void 0; }, void 0);\n case 4: return decorators.reduceRight(function(o, d) { return (d && d(target, key, o)) || o; }, desc);\n }\n};"; - // emit output for the __metadata helper function - var metadataHelper = "\nvar __metadata = (this && this.__metadata) || function (k, v) {\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(k, v);\n};"; - // emit output for the __param helper function - var paramHelper = "\nvar __param = (this && this.__param) || function (paramIndex, decorator) {\n return function (target, key) { decorator(target, key, paramIndex); }\n};"; - var awaiterHelper = "\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promise, generator) {\n return new Promise(function (resolve, reject) {\n generator = generator.call(thisArg, _arguments);\n function cast(value) { return value instanceof Promise && value.constructor === Promise ? value : new Promise(function (resolve) { resolve(value); }); }\n function onfulfill(value) { try { step(\"next\", value); } catch (e) { reject(e); } }\n function onreject(value) { try { step(\"throw\", value); } catch (e) { reject(e); } }\n function step(verb, value) {\n var result = generator[verb](value);\n result.done ? resolve(result.value) : cast(result.value).then(onfulfill, onreject);\n }\n step(\"next\", void 0);\n });\n};"; - var compilerOptions = host.getCompilerOptions(); - var languageVersion = compilerOptions.target || 0 /* ES3 */; - var sourceMapDataList = compilerOptions.sourceMap || compilerOptions.inlineSourceMap ? [] : undefined; - var diagnostics = []; - var newLine = host.getNewLine(); - var jsxDesugaring = host.getCompilerOptions().jsx !== 1 /* Preserve */; - var shouldEmitJsx = function (s) { return (s.languageVariant === 1 /* JSX */ && !jsxDesugaring); }; - if (targetSourceFile === undefined) { - ts.forEach(host.getSourceFiles(), function (sourceFile) { - if (ts.shouldEmitToOwnFile(sourceFile, compilerOptions)) { - var jsFilePath = ts.getOwnEmitOutputFilePath(sourceFile, host, shouldEmitJsx(sourceFile) ? ".jsx" : ".js"); - emitFile(jsFilePath, sourceFile); - } - }); - if (compilerOptions.outFile || compilerOptions.out) { - emitFile(compilerOptions.outFile || compilerOptions.out); - } - } - else { - // targetSourceFile is specified (e.g calling emitter from language service or calling getSemanticDiagnostic from language service) - if (ts.shouldEmitToOwnFile(targetSourceFile, compilerOptions)) { - var jsFilePath = ts.getOwnEmitOutputFilePath(targetSourceFile, host, shouldEmitJsx(targetSourceFile) ? ".jsx" : ".js"); - emitFile(jsFilePath, targetSourceFile); - } - else if (!ts.isDeclarationFile(targetSourceFile) && (compilerOptions.outFile || compilerOptions.out)) { - emitFile(compilerOptions.outFile || compilerOptions.out); - } - } - // Sort and make the unique list of diagnostics - diagnostics = ts.sortAndDeduplicateDiagnostics(diagnostics); - return { - emitSkipped: false, - diagnostics: diagnostics, - sourceMaps: sourceMapDataList - }; - function isNodeDescendentOf(node, ancestor) { - while (node) { - if (node === ancestor) - return true; - node = node.parent; - } - return false; - } - function isUniqueLocalName(name, container) { - for (var node = container; isNodeDescendentOf(node, container); node = node.nextContainer) { - if (node.locals && ts.hasProperty(node.locals, name)) { - // We conservatively include alias symbols to cover cases where they're emitted as locals - if (node.locals[name].flags & (107455 /* Value */ | 1048576 /* ExportValue */ | 8388608 /* Alias */)) { - return false; - } - } - } - return true; - } - function emitJavaScript(jsFilePath, root) { - var writer = ts.createTextWriter(newLine); - var write = writer.write, writeTextOfNode = writer.writeTextOfNode, writeLine = writer.writeLine, increaseIndent = writer.increaseIndent, decreaseIndent = writer.decreaseIndent; - var currentSourceFile; - // name of an exporter function if file is a System external module - // System.register([...], function () {...}) - // exporting in System modules looks like: - // export var x; ... x = 1 - // => - // var x;... exporter("x", x = 1) - var exportFunctionForFile; - var generatedNameSet = {}; - var nodeToGeneratedName = []; - var computedPropertyNamesToGeneratedNames; - var extendsEmitted = false; - var decorateEmitted = false; - var paramEmitted = false; - var awaiterEmitted = false; - var tempFlags = 0; - var tempVariables; - var tempParameters; - var externalImports; - var exportSpecifiers; - var exportEquals; - var hasExportStars; - /** Write emitted output to disk */ - var writeEmittedFiles = writeJavaScriptFile; - var detachedCommentsInfo; - var writeComment = ts.writeCommentRange; - /** Emit a node */ - var emit = emitNodeWithCommentsAndWithoutSourcemap; - /** Called just before starting emit of a node */ - var emitStart = function (node) { }; - /** Called once the emit of the node is done */ - var emitEnd = function (node) { }; - /** Emit the text for the given token that comes after startPos - * This by default writes the text provided with the given tokenKind - * but if optional emitFn callback is provided the text is emitted using the callback instead of default text - * @param tokenKind the kind of the token to search and emit - * @param startPos the position in the source to start searching for the token - * @param emitFn if given will be invoked to emit the text instead of actual token emit */ - var emitToken = emitTokenText; - /** Called to before starting the lexical scopes as in function/class in the emitted code because of node - * @param scopeDeclaration node that starts the lexical scope - * @param scopeName Optional name of this scope instead of deducing one from the declaration node */ - var scopeEmitStart = function (scopeDeclaration, scopeName) { }; - /** Called after coming out of the scope */ - var scopeEmitEnd = function () { }; - /** Sourcemap data that will get encoded */ - var sourceMapData; - /** If removeComments is true, no leading-comments needed to be emitted **/ - var emitLeadingCommentsOfPosition = compilerOptions.removeComments ? function (pos) { } : emitLeadingCommentsOfPositionWorker; - if (compilerOptions.sourceMap || compilerOptions.inlineSourceMap) { - initializeEmitterWithSourceMaps(); - } - if (root) { - // Do not call emit directly. It does not set the currentSourceFile. - emitSourceFile(root); - } - else { - ts.forEach(host.getSourceFiles(), function (sourceFile) { - if (!isExternalModuleOrDeclarationFile(sourceFile)) { - emitSourceFile(sourceFile); - } - }); - } - writeLine(); - writeEmittedFiles(writer.getText(), /*writeByteOrderMark*/ compilerOptions.emitBOM); - return; - function emitSourceFile(sourceFile) { - currentSourceFile = sourceFile; - exportFunctionForFile = undefined; - emit(sourceFile); - } - function isUniqueName(name) { - return !resolver.hasGlobalName(name) && - !ts.hasProperty(currentSourceFile.identifiers, name) && - !ts.hasProperty(generatedNameSet, name); - } - // Return the next available name in the pattern _a ... _z, _0, _1, ... - // TempFlags._i or TempFlags._n may be used to express a preference for that dedicated name. - // Note that names generated by makeTempVariableName and makeUniqueName will never conflict. - function makeTempVariableName(flags) { - if (flags && !(tempFlags & flags)) { - var name_19 = flags === 268435456 /* _i */ ? "_i" : "_n"; - if (isUniqueName(name_19)) { - tempFlags |= flags; - return name_19; - } - } - while (true) { - var count = tempFlags & 268435455 /* CountMask */; - tempFlags++; - // Skip over 'i' and 'n' - if (count !== 8 && count !== 13) { - var name_20 = count < 26 ? "_" + String.fromCharCode(97 /* a */ + count) : "_" + (count - 26); - if (isUniqueName(name_20)) { - return name_20; - } - } - } - } - // Generate a name that is unique within the current file and doesn't conflict with any names - // in global scope. The name is formed by adding an '_n' suffix to the specified base name, - // where n is a positive integer. Note that names generated by makeTempVariableName and - // makeUniqueName are guaranteed to never conflict. - function makeUniqueName(baseName) { - // Find the first unique 'name_n', where n is a positive number - if (baseName.charCodeAt(baseName.length - 1) !== 95 /* _ */) { - baseName += "_"; - } - var i = 1; - while (true) { - var generatedName = baseName + i; - if (isUniqueName(generatedName)) { - return generatedNameSet[generatedName] = generatedName; - } - i++; - } - } - function generateNameForModuleOrEnum(node) { - var name = node.name.text; - // Use module/enum name itself if it is unique, otherwise make a unique variation - return isUniqueLocalName(name, node) ? name : makeUniqueName(name); - } - function generateNameForImportOrExportDeclaration(node) { - var expr = ts.getExternalModuleName(node); - var baseName = expr.kind === 9 /* StringLiteral */ ? - ts.escapeIdentifier(ts.makeIdentifierFromModuleName(expr.text)) : "module"; - return makeUniqueName(baseName); - } - function generateNameForExportDefault() { - return makeUniqueName("default"); - } - function generateNameForClassExpression() { - return makeUniqueName("class"); - } - function generateNameForNode(node) { - switch (node.kind) { - case 67 /* Identifier */: - return makeUniqueName(node.text); - case 216 /* ModuleDeclaration */: - case 215 /* EnumDeclaration */: - return generateNameForModuleOrEnum(node); - case 220 /* ImportDeclaration */: - case 226 /* ExportDeclaration */: - return generateNameForImportOrExportDeclaration(node); - case 211 /* FunctionDeclaration */: - case 212 /* ClassDeclaration */: - case 225 /* ExportAssignment */: - return generateNameForExportDefault(); - case 184 /* ClassExpression */: - return generateNameForClassExpression(); - } - } - function getGeneratedNameForNode(node) { - var id = ts.getNodeId(node); - return nodeToGeneratedName[id] || (nodeToGeneratedName[id] = ts.unescapeIdentifier(generateNameForNode(node))); - } - function initializeEmitterWithSourceMaps() { - var sourceMapDir; // The directory in which sourcemap will be - // Current source map file and its index in the sources list - var sourceMapSourceIndex = -1; - // Names and its index map - var sourceMapNameIndexMap = {}; - var sourceMapNameIndices = []; - function getSourceMapNameIndex() { - return sourceMapNameIndices.length ? ts.lastOrUndefined(sourceMapNameIndices) : -1; - } - // Last recorded and encoded spans - var lastRecordedSourceMapSpan; - var lastEncodedSourceMapSpan = { - emittedLine: 1, - emittedColumn: 1, - sourceLine: 1, - sourceColumn: 1, - sourceIndex: 0 - }; - var lastEncodedNameIndex = 0; - // Encoding for sourcemap span - function encodeLastRecordedSourceMapSpan() { - if (!lastRecordedSourceMapSpan || lastRecordedSourceMapSpan === lastEncodedSourceMapSpan) { - return; - } - var prevEncodedEmittedColumn = lastEncodedSourceMapSpan.emittedColumn; - // Line/Comma delimiters - if (lastEncodedSourceMapSpan.emittedLine === lastRecordedSourceMapSpan.emittedLine) { - // Emit comma to separate the entry - if (sourceMapData.sourceMapMappings) { - sourceMapData.sourceMapMappings += ","; - } - } - else { - // Emit line delimiters - for (var encodedLine = lastEncodedSourceMapSpan.emittedLine; encodedLine < lastRecordedSourceMapSpan.emittedLine; encodedLine++) { - sourceMapData.sourceMapMappings += ";"; - } - prevEncodedEmittedColumn = 1; - } - // 1. Relative Column 0 based - sourceMapData.sourceMapMappings += base64VLQFormatEncode(lastRecordedSourceMapSpan.emittedColumn - prevEncodedEmittedColumn); - // 2. Relative sourceIndex - sourceMapData.sourceMapMappings += base64VLQFormatEncode(lastRecordedSourceMapSpan.sourceIndex - lastEncodedSourceMapSpan.sourceIndex); - // 3. Relative sourceLine 0 based - sourceMapData.sourceMapMappings += base64VLQFormatEncode(lastRecordedSourceMapSpan.sourceLine - lastEncodedSourceMapSpan.sourceLine); - // 4. Relative sourceColumn 0 based - sourceMapData.sourceMapMappings += base64VLQFormatEncode(lastRecordedSourceMapSpan.sourceColumn - lastEncodedSourceMapSpan.sourceColumn); - // 5. Relative namePosition 0 based - if (lastRecordedSourceMapSpan.nameIndex >= 0) { - sourceMapData.sourceMapMappings += base64VLQFormatEncode(lastRecordedSourceMapSpan.nameIndex - lastEncodedNameIndex); - lastEncodedNameIndex = lastRecordedSourceMapSpan.nameIndex; - } - lastEncodedSourceMapSpan = lastRecordedSourceMapSpan; - sourceMapData.sourceMapDecodedMappings.push(lastEncodedSourceMapSpan); - function base64VLQFormatEncode(inValue) { - function base64FormatEncode(inValue) { - if (inValue < 64) { - return "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(inValue); - } - throw TypeError(inValue + ": not a 64 based value"); - } - // Add a new least significant bit that has the sign of the value. - // if negative number the least significant bit that gets added to the number has value 1 - // else least significant bit value that gets added is 0 - // eg. -1 changes to binary : 01 [1] => 3 - // +1 changes to binary : 01 [0] => 2 - if (inValue < 0) { - inValue = ((-inValue) << 1) + 1; - } - else { - inValue = inValue << 1; - } - // Encode 5 bits at a time starting from least significant bits - var encodedStr = ""; - do { - var currentDigit = inValue & 31; // 11111 - inValue = inValue >> 5; - if (inValue > 0) { - // There are still more digits to decode, set the msb (6th bit) - currentDigit = currentDigit | 32; - } - encodedStr = encodedStr + base64FormatEncode(currentDigit); - } while (inValue > 0); - return encodedStr; - } - } - function recordSourceMapSpan(pos) { - var sourceLinePos = ts.getLineAndCharacterOfPosition(currentSourceFile, pos); - // Convert the location to be one-based. - sourceLinePos.line++; - sourceLinePos.character++; - var emittedLine = writer.getLine(); - var emittedColumn = writer.getColumn(); - // If this location wasn't recorded or the location in source is going backwards, record the span - if (!lastRecordedSourceMapSpan || - lastRecordedSourceMapSpan.emittedLine !== emittedLine || - lastRecordedSourceMapSpan.emittedColumn !== emittedColumn || - (lastRecordedSourceMapSpan.sourceIndex === sourceMapSourceIndex && - (lastRecordedSourceMapSpan.sourceLine > sourceLinePos.line || - (lastRecordedSourceMapSpan.sourceLine === sourceLinePos.line && lastRecordedSourceMapSpan.sourceColumn > sourceLinePos.character)))) { - // Encode the last recordedSpan before assigning new - encodeLastRecordedSourceMapSpan(); - // New span - lastRecordedSourceMapSpan = { - emittedLine: emittedLine, - emittedColumn: emittedColumn, - sourceLine: sourceLinePos.line, - sourceColumn: sourceLinePos.character, - nameIndex: getSourceMapNameIndex(), - sourceIndex: sourceMapSourceIndex - }; - } - 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; - } - } - function recordEmitNodeStartSpan(node) { - // Get the token pos after skipping to the token (ignoring the leading trivia) - recordSourceMapSpan(ts.skipTrivia(currentSourceFile.text, node.pos)); - } - function recordEmitNodeEndSpan(node) { - recordSourceMapSpan(node.end); - } - function writeTextWithSpanRecord(tokenKind, startPos, emitFn) { - var tokenStartPos = ts.skipTrivia(currentSourceFile.text, startPos); - recordSourceMapSpan(tokenStartPos); - var tokenEndPos = emitTokenText(tokenKind, tokenStartPos, emitFn); - recordSourceMapSpan(tokenEndPos); - return tokenEndPos; - } - function recordNewSourceFileStart(node) { - // Add the file to tsFilePaths - // If sourceroot option: Use the relative path corresponding to the common directory path - // otherwise source locations relative to map file location - var sourcesDirectoryPath = compilerOptions.sourceRoot ? host.getCommonSourceDirectory() : sourceMapDir; - sourceMapData.sourceMapSources.push(ts.getRelativePathToDirectoryOrUrl(sourcesDirectoryPath, node.fileName, host.getCurrentDirectory(), host.getCanonicalFileName, - /*isAbsolutePathAnUrl*/ true)); - sourceMapSourceIndex = sourceMapData.sourceMapSources.length - 1; - // The one that can be used from program to get the actual source file - sourceMapData.inputSourceFileNames.push(node.fileName); - if (compilerOptions.inlineSources) { - if (!sourceMapData.sourceMapSourcesContent) { - sourceMapData.sourceMapSourcesContent = []; - } - sourceMapData.sourceMapSourcesContent.push(node.text); - } - } - function recordScopeNameOfNode(node, scopeName) { - function recordScopeNameIndex(scopeNameIndex) { - sourceMapNameIndices.push(scopeNameIndex); - } - function recordScopeNameStart(scopeName) { - var scopeNameIndex = -1; - if (scopeName) { - var parentIndex = getSourceMapNameIndex(); - if (parentIndex !== -1) { - // Child scopes are always shown with a dot (even if they have no name), - // unless it is a computed property. Then it is shown with brackets, - // but the brackets are included in the name. - var name_21 = node.name; - if (!name_21 || name_21.kind !== 134 /* ComputedPropertyName */) { - scopeName = "." + scopeName; - } - scopeName = sourceMapData.sourceMapNames[parentIndex] + scopeName; - } - scopeNameIndex = ts.getProperty(sourceMapNameIndexMap, scopeName); - if (scopeNameIndex === undefined) { - scopeNameIndex = sourceMapData.sourceMapNames.length; - sourceMapData.sourceMapNames.push(scopeName); - sourceMapNameIndexMap[scopeName] = scopeNameIndex; - } - } - recordScopeNameIndex(scopeNameIndex); - } - if (scopeName) { - // The scope was already given a name use it - recordScopeNameStart(scopeName); - } - else if (node.kind === 211 /* FunctionDeclaration */ || - node.kind === 171 /* FunctionExpression */ || - node.kind === 141 /* MethodDeclaration */ || - node.kind === 140 /* MethodSignature */ || - node.kind === 143 /* GetAccessor */ || - node.kind === 144 /* SetAccessor */ || - node.kind === 216 /* ModuleDeclaration */ || - node.kind === 212 /* ClassDeclaration */ || - node.kind === 215 /* EnumDeclaration */) { - // Declaration and has associated name use it - if (node.name) { - var name_22 = node.name; - // For computed property names, the text will include the brackets - scopeName = name_22.kind === 134 /* ComputedPropertyName */ - ? ts.getTextOfNode(name_22) - : node.name.text; - } - recordScopeNameStart(scopeName); - } - else { - // Block just use the name from upper level scope - recordScopeNameIndex(getSourceMapNameIndex()); - } - } - function recordScopeNameEnd() { - sourceMapNameIndices.pop(); - } - ; - function writeCommentRangeWithMap(curentSourceFile, writer, comment, newLine) { - recordSourceMapSpan(comment.pos); - ts.writeCommentRange(currentSourceFile, writer, comment, newLine); - recordSourceMapSpan(comment.end); - } - function serializeSourceMapContents(version, file, sourceRoot, sources, names, mappings, sourcesContent) { - if (typeof JSON !== "undefined") { - var map_1 = { - version: version, - file: file, - sourceRoot: sourceRoot, - sources: sources, - names: names, - mappings: mappings - }; - if (sourcesContent !== undefined) { - map_1.sourcesContent = sourcesContent; - } - return JSON.stringify(map_1); - } - return "{\"version\":" + version + ",\"file\":\"" + ts.escapeString(file) + "\",\"sourceRoot\":\"" + ts.escapeString(sourceRoot) + "\",\"sources\":[" + serializeStringArray(sources) + "],\"names\":[" + serializeStringArray(names) + "],\"mappings\":\"" + ts.escapeString(mappings) + "\" " + (sourcesContent !== undefined ? ",\"sourcesContent\":[" + serializeStringArray(sourcesContent) + "]" : "") + "}"; - function serializeStringArray(list) { - var output = ""; - for (var i = 0, n = list.length; i < n; i++) { - if (i) { - output += ","; - } - output += "\"" + ts.escapeString(list[i]) + "\""; - } - return output; - } - } - function writeJavaScriptAndSourceMapFile(emitOutput, writeByteOrderMark) { - encodeLastRecordedSourceMapSpan(); - var sourceMapText = serializeSourceMapContents(3, sourceMapData.sourceMapFile, sourceMapData.sourceMapSourceRoot, sourceMapData.sourceMapSources, sourceMapData.sourceMapNames, sourceMapData.sourceMapMappings, sourceMapData.sourceMapSourcesContent); - sourceMapDataList.push(sourceMapData); - var sourceMapUrl; - if (compilerOptions.inlineSourceMap) { - // Encode the sourceMap into the sourceMap url - var base64SourceMapText = ts.convertToBase64(sourceMapText); - sourceMapUrl = "//# sourceMappingURL=data:application/json;base64," + base64SourceMapText; - } - else { - // Write source map file - ts.writeFile(host, diagnostics, sourceMapData.sourceMapFilePath, sourceMapText, /*writeByteOrderMark*/ false); - sourceMapUrl = "//# sourceMappingURL=" + sourceMapData.jsSourceMappingURL; - } - // Write sourcemap url to the js file and write the js file - writeJavaScriptFile(emitOutput + sourceMapUrl, writeByteOrderMark); - } - // Initialize source map data - var sourceMapJsFile = ts.getBaseFileName(ts.normalizeSlashes(jsFilePath)); - sourceMapData = { - sourceMapFilePath: jsFilePath + ".map", - jsSourceMappingURL: sourceMapJsFile + ".map", - sourceMapFile: sourceMapJsFile, - sourceMapSourceRoot: compilerOptions.sourceRoot || "", - sourceMapSources: [], - inputSourceFileNames: [], - sourceMapNames: [], - sourceMapMappings: "", - sourceMapSourcesContent: undefined, - sourceMapDecodedMappings: [] - }; - // Normalize source root and make sure it has trailing "/" so that it can be used to combine paths with the - // relative paths of the sources list in the sourcemap - sourceMapData.sourceMapSourceRoot = ts.normalizeSlashes(sourceMapData.sourceMapSourceRoot); - if (sourceMapData.sourceMapSourceRoot.length && sourceMapData.sourceMapSourceRoot.charCodeAt(sourceMapData.sourceMapSourceRoot.length - 1) !== 47 /* slash */) { - sourceMapData.sourceMapSourceRoot += ts.directorySeparator; - } - if (compilerOptions.mapRoot) { - sourceMapDir = ts.normalizeSlashes(compilerOptions.mapRoot); - if (root) { - // For modules or multiple emit files the mapRoot will have directory structure like the sources - // So if src\a.ts and src\lib\b.ts are compiled together user would be moving the maps into mapRoot\a.js.map and mapRoot\lib\b.js.map - sourceMapDir = ts.getDirectoryPath(ts.getSourceFilePathInNewDir(root, host, sourceMapDir)); - } - if (!ts.isRootedDiskPath(sourceMapDir) && !ts.isUrl(sourceMapDir)) { - // The relative paths are relative to the common directory - sourceMapDir = ts.combinePaths(host.getCommonSourceDirectory(), sourceMapDir); - sourceMapData.jsSourceMappingURL = ts.getRelativePathToDirectoryOrUrl(ts.getDirectoryPath(ts.normalizePath(jsFilePath)), // get the relative sourceMapDir path based on jsFilePath - ts.combinePaths(sourceMapDir, sourceMapData.jsSourceMappingURL), // this is where user expects to see sourceMap - host.getCurrentDirectory(), host.getCanonicalFileName, - /*isAbsolutePathAnUrl*/ true); - } - else { - sourceMapData.jsSourceMappingURL = ts.combinePaths(sourceMapDir, sourceMapData.jsSourceMappingURL); - } - } - else { - sourceMapDir = ts.getDirectoryPath(ts.normalizePath(jsFilePath)); - } - function emitNodeWithSourceMap(node) { - if (node) { - if (ts.nodeIsSynthesized(node)) { - return emitNodeWithoutSourceMap(node); - } - if (node.kind !== 246 /* SourceFile */) { - recordEmitNodeStartSpan(node); - emitNodeWithoutSourceMap(node); - recordEmitNodeEndSpan(node); - } - else { - recordNewSourceFileStart(node); - emitNodeWithoutSourceMap(node); - } - } - } - function emitNodeWithCommentsAndWithSourcemap(node) { - emitNodeConsideringCommentsOption(node, emitNodeWithSourceMap); - } - writeEmittedFiles = writeJavaScriptAndSourceMapFile; - emit = emitNodeWithCommentsAndWithSourcemap; - emitStart = recordEmitNodeStartSpan; - emitEnd = recordEmitNodeEndSpan; - emitToken = writeTextWithSpanRecord; - scopeEmitStart = recordScopeNameOfNode; - scopeEmitEnd = recordScopeNameEnd; - writeComment = writeCommentRangeWithMap; - } - function writeJavaScriptFile(emitOutput, writeByteOrderMark) { - ts.writeFile(host, diagnostics, jsFilePath, emitOutput, writeByteOrderMark); - } - // Create a temporary variable with a unique unused name. - function createTempVariable(flags) { - var result = ts.createSynthesizedNode(67 /* Identifier */); - result.text = makeTempVariableName(flags); - return result; - } - function recordTempDeclaration(name) { - if (!tempVariables) { - tempVariables = []; - } - tempVariables.push(name); - } - function createAndRecordTempVariable(flags) { - var temp = createTempVariable(flags); - recordTempDeclaration(temp); - return temp; - } - function emitTempDeclarations(newLine) { - if (tempVariables) { - if (newLine) { - writeLine(); - } - else { - write(" "); - } - write("var "); - emitCommaList(tempVariables); - write(";"); - } - } - function emitTokenText(tokenKind, startPos, emitFn) { - var tokenString = ts.tokenToString(tokenKind); - if (emitFn) { - emitFn(); - } - else { - write(tokenString); - } - return startPos + tokenString.length; - } - function emitOptional(prefix, node) { - if (node) { - write(prefix); - emit(node); - } - } - function emitParenthesizedIf(node, parenthesized) { - if (parenthesized) { - write("("); - } - emit(node); - if (parenthesized) { - write(")"); - } - } - function emitTrailingCommaIfPresent(nodeList) { - if (nodeList.hasTrailingComma) { - write(","); - } - } - function emitLinePreservingList(parent, nodes, allowTrailingComma, spacesBetweenBraces) { - ts.Debug.assert(nodes.length > 0); - increaseIndent(); - if (nodeStartPositionsAreOnSameLine(parent, nodes[0])) { - if (spacesBetweenBraces) { - write(" "); - } - } - else { - writeLine(); - } - for (var i = 0, n = nodes.length; i < n; i++) { - if (i) { - if (nodeEndIsOnSameLineAsNodeStart(nodes[i - 1], nodes[i])) { - write(", "); - } - else { - write(","); - writeLine(); - } - } - emit(nodes[i]); - } - if (nodes.hasTrailingComma && allowTrailingComma) { - write(","); - } - decreaseIndent(); - if (nodeEndPositionsAreOnSameLine(parent, ts.lastOrUndefined(nodes))) { - if (spacesBetweenBraces) { - write(" "); - } - } - else { - writeLine(); - } - } - function emitList(nodes, start, count, multiLine, trailingComma, leadingComma, noTrailingNewLine, emitNode) { - if (!emitNode) { - emitNode = emit; - } - for (var i = 0; i < count; i++) { - if (multiLine) { - if (i || leadingComma) { - write(","); - } - writeLine(); - } - else { - if (i || leadingComma) { - write(", "); - } - } - var node = nodes[start + i]; - // This emitting is to make sure we emit following comment properly - // ...(x, /*comment1*/ y)... - // ^ => node.pos - // "comment1" is not considered leading comment for "y" but rather - // considered as trailing comment of the previous node. - emitTrailingCommentsOfPosition(node.pos); - emitNode(node); - leadingComma = true; - } - if (trailingComma) { - write(","); - } - if (multiLine && !noTrailingNewLine) { - writeLine(); - } - return count; - } - function emitCommaList(nodes) { - if (nodes) { - emitList(nodes, 0, nodes.length, /*multiline*/ false, /*trailingComma*/ false); - } - } - function emitLines(nodes) { - emitLinesStartingAt(nodes, /*startIndex*/ 0); - } - function emitLinesStartingAt(nodes, startIndex) { - for (var i = startIndex; i < nodes.length; i++) { - writeLine(); - emit(nodes[i]); - } - } - function isBinaryOrOctalIntegerLiteral(node, text) { - if (node.kind === 8 /* NumericLiteral */ && text.length > 1) { - switch (text.charCodeAt(1)) { - case 98 /* b */: - case 66 /* B */: - case 111 /* o */: - case 79 /* O */: - return true; - } - } - return false; - } - function emitLiteral(node) { - var text = getLiteralText(node); - if ((compilerOptions.sourceMap || compilerOptions.inlineSourceMap) && (node.kind === 9 /* StringLiteral */ || ts.isTemplateLiteralKind(node.kind))) { - writer.writeLiteral(text); - } - else if (languageVersion < 2 /* ES6 */ && isBinaryOrOctalIntegerLiteral(node, text)) { - write(node.text); - } - else { - write(text); - } - } - function getLiteralText(node) { - // 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 */ && (ts.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 (node.parent) { - return ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, node); - } - // If we can't reach the original source text, use the canonical form if it's a number, - // or an escaped quoted form of the original text if it's string-like. - switch (node.kind) { - case 9 /* StringLiteral */: - return getQuotedEscapedLiteralText("\"", node.text, "\""); - case 11 /* NoSubstitutionTemplateLiteral */: - return getQuotedEscapedLiteralText("`", node.text, "`"); - case 12 /* TemplateHead */: - return getQuotedEscapedLiteralText("`", node.text, "${"); - case 13 /* TemplateMiddle */: - return getQuotedEscapedLiteralText("}", node.text, "${"); - case 14 /* TemplateTail */: - return getQuotedEscapedLiteralText("}", node.text, "`"); - case 8 /* NumericLiteral */: - return node.text; - } - ts.Debug.fail("Literal kind '" + node.kind + "' not accounted for."); - } - function getQuotedEscapedLiteralText(leftQuote, text, rightQuote) { - return leftQuote + ts.escapeNonAsciiCharacters(ts.escapeString(text)) + rightQuote; - } - function emitDownlevelRawTemplateLiteral(node) { - // 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"); - text = ts.escapeString(text); - write("\"" + text + "\""); - } - function emitDownlevelTaggedTemplateArray(node, literalEmitter) { - write("["); - if (node.template.kind === 11 /* NoSubstitutionTemplateLiteral */) { - literalEmitter(node.template); - } - else { - literalEmitter(node.template.head); - ts.forEach(node.template.templateSpans, function (child) { - write(", "); - literalEmitter(child.literal); - }); - } - write("]"); - } - function emitDownlevelTaggedTemplate(node) { - var tempVariable = createAndRecordTempVariable(0 /* Auto */); - write("("); - emit(tempVariable); - write(" = "); - emitDownlevelTaggedTemplateArray(node, emit); - write(", "); - emit(tempVariable); - write(".raw = "); - emitDownlevelTaggedTemplateArray(node, emitDownlevelRawTemplateLiteral); - write(", "); - emitParenthesizedIf(node.tag, needsParenthesisForPropertyAccessOrInvocation(node.tag)); - write("("); - emit(tempVariable); - // Now we emit the expressions - if (node.template.kind === 181 /* TemplateExpression */) { - ts.forEach(node.template.templateSpans, function (templateSpan) { - write(", "); - var needsParens = templateSpan.expression.kind === 179 /* BinaryExpression */ - && templateSpan.expression.operatorToken.kind === 24 /* CommaToken */; - emitParenthesizedIf(templateSpan.expression, needsParens); - }); - } - write("))"); - } - function emitTemplateExpression(node) { - // In ES6 mode and above, we can simply emit each portion of a template in order, but in - // ES3 & ES5 we must convert the template expression into a series of string concatenations. - if (languageVersion >= 2 /* ES6 */) { - ts.forEachChild(node, emit); - return; - } - var emitOuterParens = ts.isExpression(node.parent) - && templateNeedsParens(node, node.parent); - if (emitOuterParens) { - write("("); - } - var headEmitted = false; - if (shouldEmitTemplateHead()) { - emitLiteral(node.head); - headEmitted = true; - } - for (var i = 0, n = node.templateSpans.length; i < n; i++) { - var templateSpan = node.templateSpans[i]; - // Check if the expression has operands and binds its operands less closely than binary '+'. - // If it does, we need to wrap 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 needsParens = templateSpan.expression.kind !== 170 /* ParenthesizedExpression */ - && comparePrecedenceToBinaryPlus(templateSpan.expression) !== 1 /* GreaterThan */; - if (i > 0 || headEmitted) { - // If this is the first span and the head was not emitted, then this templateSpan's - // expression will be the first to be emitted. Don't emit the preceding ' + ' in that - // case. - write(" + "); - } - emitParenthesizedIf(templateSpan.expression, needsParens); - // 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 (templateSpan.literal.text.length !== 0) { - write(" + "); - emitLiteral(templateSpan.literal); - } - } - if (emitOuterParens) { - write(")"); - } - function shouldEmitTemplateHead() { - // If this expression has an empty head literal and the first template span has a non-empty - // literal, then emitting the empty head literal is not necessary. - // `${ foo } and ${ bar }` - // can be emitted as - // foo + " and " + bar - // This is because it is only required that one of the first two operands in the emit - // output must be a string literal, so that the other operand and all following operands - // are forced into strings. - // - // If the first template span has an empty literal, then the head must still be emitted. - // `${ foo }${ bar }` - // must still be emitted as - // "" + foo + bar - // 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; - } - function templateNeedsParens(template, parent) { - switch (parent.kind) { - case 166 /* CallExpression */: - case 167 /* NewExpression */: - return parent.expression === template; - case 168 /* TaggedTemplateExpression */: - case 170 /* ParenthesizedExpression */: - return false; - default: - return comparePrecedenceToBinaryPlus(parent) !== -1 /* LessThan */; - } - } - /** - * Returns whether the expression has lesser, greater, - * or equal precedence to the binary '+' operator - */ - function comparePrecedenceToBinaryPlus(expression) { - // All binary expressions have lower precedence than '+' apart from '*', '/', and '%' - // which have greater precedence and '-' which has equal precedence. - // All unary operators have a higher precedence apart from yield. - // Arrow functions and conditionals have a lower precedence, - // although we convert the former into regular function expressions in ES5 mode, - // and in ES6 mode this function won't get called anyway. - // - // TODO (drosen): Note that we need to account for the upcoming 'yield' and - // spread ('...') unary operators that are anticipated for ES6. - switch (expression.kind) { - case 179 /* BinaryExpression */: - switch (expression.operatorToken.kind) { - case 37 /* AsteriskToken */: - case 38 /* SlashToken */: - case 39 /* PercentToken */: - return 1 /* GreaterThan */; - case 35 /* PlusToken */: - case 36 /* MinusToken */: - return 0 /* EqualTo */; - default: - return -1 /* LessThan */; - } - case 182 /* YieldExpression */: - case 180 /* ConditionalExpression */: - return -1 /* LessThan */; - default: - return 1 /* GreaterThan */; - } - } - } - function emitTemplateSpan(span) { - emit(span.expression); - emit(span.literal); - } - function jsxEmitReact(node) { - /// Emit a tag name, which is either '"div"' for lower-cased names, or - /// 'Div' for upper-cased or dotted names - function emitTagName(name) { - if (name.kind === 67 /* Identifier */ && ts.isIntrinsicJsxName(name.text)) { - write("\""); - emit(name); - write("\""); - } - else { - emit(name); - } - } - /// Emit an attribute name, which is quoted if it needs to be quoted. Because - /// these emit into an object literal property name, we don't need to be worried - /// about keywords, just non-identifier characters - function emitAttributeName(name) { - if (/[A-Za-z_]+[\w*]/.test(name.text)) { - write("\""); - emit(name); - write("\""); - } - else { - emit(name); - } - } - /// Emit an name/value pair for an attribute (e.g. "x: 3") - function emitJsxAttribute(node) { - emitAttributeName(node.name); - write(": "); - if (node.initializer) { - emit(node.initializer); - } - else { - write("true"); - } - } - function emitJsxElement(openingNode, children) { - var syntheticReactRef = ts.createSynthesizedNode(67 /* Identifier */); - syntheticReactRef.text = 'React'; - syntheticReactRef.parent = openingNode; - // Call React.createElement(tag, ... - emitLeadingComments(openingNode); - emitExpressionIdentifier(syntheticReactRef); - write(".createElement("); - emitTagName(openingNode.tagName); - write(", "); - // Attribute list - if (openingNode.attributes.length === 0) { - // When there are no attributes, React wants "null" - write("null"); - } - else { - // Either emit one big object literal (no spread attribs), or - // a call to React.__spread - var attrs = openingNode.attributes; - if (ts.forEach(attrs, function (attr) { return attr.kind === 237 /* JsxSpreadAttribute */; })) { - emitExpressionIdentifier(syntheticReactRef); - write(".__spread("); - var haveOpenedObjectLiteral = false; - for (var i_1 = 0; i_1 < attrs.length; i_1++) { - if (attrs[i_1].kind === 237 /* JsxSpreadAttribute */) { - // If this is the first argument, we need to emit a {} as the first argument - if (i_1 === 0) { - write("{}, "); - } - if (haveOpenedObjectLiteral) { - write("}"); - haveOpenedObjectLiteral = false; - } - if (i_1 > 0) { - write(", "); - } - emit(attrs[i_1].expression); - } - else { - ts.Debug.assert(attrs[i_1].kind === 236 /* JsxAttribute */); - if (haveOpenedObjectLiteral) { - write(", "); - } - else { - haveOpenedObjectLiteral = true; - if (i_1 > 0) { - write(", "); - } - write("{"); - } - emitJsxAttribute(attrs[i_1]); - } - } - if (haveOpenedObjectLiteral) - write("}"); - write(")"); // closing paren to React.__spread( - } - else { - // One object literal with all the attributes in them - write("{"); - for (var i = 0; i < attrs.length; i++) { - if (i > 0) { - write(", "); - } - emitJsxAttribute(attrs[i]); - } - write("}"); - } - } - // Children - if (children) { - for (var i = 0; i < children.length; i++) { - // Don't emit empty expressions - if (children[i].kind === 238 /* JsxExpression */ && !(children[i].expression)) { - continue; - } - // Don't emit empty strings - if (children[i].kind === 234 /* JsxText */) { - var text = getTextToEmit(children[i]); - if (text !== undefined) { - write(", \""); - write(text); - write("\""); - } - } - else { - write(", "); - emit(children[i]); - } - } - } - // Closing paren - write(")"); // closes "React.createElement(" - emitTrailingComments(openingNode); - } - if (node.kind === 231 /* JsxElement */) { - emitJsxElement(node.openingElement, node.children); - } - else { - ts.Debug.assert(node.kind === 232 /* JsxSelfClosingElement */); - emitJsxElement(node); - } - } - function jsxEmitPreserve(node) { - function emitJsxAttribute(node) { - emit(node.name); - if (node.initializer) { - write("="); - emit(node.initializer); - } - } - function emitJsxSpreadAttribute(node) { - write("{..."); - emit(node.expression); - write("}"); - } - function emitAttributes(attribs) { - for (var i = 0, n = attribs.length; i < n; i++) { - if (i > 0) { - write(" "); - } - if (attribs[i].kind === 237 /* JsxSpreadAttribute */) { - emitJsxSpreadAttribute(attribs[i]); - } - else { - ts.Debug.assert(attribs[i].kind === 236 /* JsxAttribute */); - emitJsxAttribute(attribs[i]); - } - } - } - function emitJsxOpeningOrSelfClosingElement(node) { - write("<"); - emit(node.tagName); - if (node.attributes.length > 0 || (node.kind === 232 /* JsxSelfClosingElement */)) { - write(" "); - } - emitAttributes(node.attributes); - if (node.kind === 232 /* JsxSelfClosingElement */) { - write("/>"); - } - else { - write(">"); - } - } - function emitJsxClosingElement(node) { - write(""); - } - function emitJsxElement(node) { - emitJsxOpeningOrSelfClosingElement(node.openingElement); - for (var i = 0, n = node.children.length; i < n; i++) { - emit(node.children[i]); - } - emitJsxClosingElement(node.closingElement); - } - if (node.kind === 231 /* JsxElement */) { - emitJsxElement(node); - } - else { - ts.Debug.assert(node.kind === 232 /* JsxSelfClosingElement */); - emitJsxOpeningOrSelfClosingElement(node); - } - } - // This function specifically handles numeric/string literals for enum and accessor 'identifiers'. - // In a sense, it does not actually emit identifiers as much as it declares a name for a specific property. - // For example, this is utilized when feeding in a result to Object.defineProperty. - function emitExpressionForPropertyName(node) { - ts.Debug.assert(node.kind !== 161 /* BindingElement */); - if (node.kind === 9 /* StringLiteral */) { - emitLiteral(node); - } - else if (node.kind === 134 /* ComputedPropertyName */) { - // if this is a decorated computed property, we will need to capture the result - // of the property expression so that we can apply decorators later. This is to ensure - // we don't introduce unintended side effects: - // - // class C { - // [_a = x]() { } - // } - // - // The emit for the decorated computed property decorator is: - // - // Object.defineProperty(C.prototype, _a, __decorate([dec], C.prototype, _a, Object.getOwnPropertyDescriptor(C.prototype, _a))); - // - if (ts.nodeIsDecorated(node.parent)) { - if (!computedPropertyNamesToGeneratedNames) { - computedPropertyNamesToGeneratedNames = []; - } - var generatedName = computedPropertyNamesToGeneratedNames[ts.getNodeId(node)]; - if (generatedName) { - // we have already generated a variable for this node, write that value instead. - write(generatedName); - return; - } - generatedName = createAndRecordTempVariable(0 /* Auto */).text; - computedPropertyNamesToGeneratedNames[ts.getNodeId(node)] = generatedName; - write(generatedName); - write(" = "); - } - emit(node.expression); - } - else { - write("\""); - if (node.kind === 8 /* NumericLiteral */) { - write(node.text); - } - else { - writeTextOfNode(currentSourceFile, node); - } - write("\""); - } - } - function isExpressionIdentifier(node) { - var parent = node.parent; - switch (parent.kind) { - case 162 /* ArrayLiteralExpression */: - case 179 /* BinaryExpression */: - case 166 /* CallExpression */: - case 239 /* CaseClause */: - case 134 /* ComputedPropertyName */: - case 180 /* ConditionalExpression */: - case 137 /* Decorator */: - case 173 /* DeleteExpression */: - case 195 /* DoStatement */: - case 165 /* ElementAccessExpression */: - case 225 /* ExportAssignment */: - case 193 /* ExpressionStatement */: - case 186 /* ExpressionWithTypeArguments */: - case 197 /* ForStatement */: - case 198 /* ForInStatement */: - case 199 /* ForOfStatement */: - case 194 /* IfStatement */: - case 232 /* JsxSelfClosingElement */: - case 233 /* JsxOpeningElement */: - case 237 /* JsxSpreadAttribute */: - case 238 /* JsxExpression */: - case 167 /* NewExpression */: - case 170 /* ParenthesizedExpression */: - case 178 /* PostfixUnaryExpression */: - case 177 /* PrefixUnaryExpression */: - case 202 /* ReturnStatement */: - case 244 /* ShorthandPropertyAssignment */: - case 183 /* SpreadElementExpression */: - case 204 /* SwitchStatement */: - case 168 /* TaggedTemplateExpression */: - case 188 /* TemplateSpan */: - case 206 /* ThrowStatement */: - case 169 /* TypeAssertionExpression */: - case 174 /* TypeOfExpression */: - case 175 /* VoidExpression */: - case 196 /* WhileStatement */: - case 203 /* WithStatement */: - case 182 /* YieldExpression */: - return true; - case 161 /* BindingElement */: - case 245 /* EnumMember */: - case 136 /* Parameter */: - case 243 /* PropertyAssignment */: - case 139 /* PropertyDeclaration */: - case 209 /* VariableDeclaration */: - return parent.initializer === node; - case 164 /* PropertyAccessExpression */: - return parent.expression === node; - case 172 /* ArrowFunction */: - case 171 /* FunctionExpression */: - return parent.body === node; - case 219 /* ImportEqualsDeclaration */: - return parent.moduleReference === node; - case 133 /* QualifiedName */: - return parent.left === node; - } - return false; - } - function emitExpressionIdentifier(node) { - if (resolver.getNodeCheckFlags(node) & 2048 /* LexicalArguments */) { - write("_arguments"); - return; - } - var container = resolver.getReferencedExportContainer(node); - if (container) { - if (container.kind === 246 /* SourceFile */) { - // Identifier references module export - if (languageVersion < 2 /* ES6 */ && compilerOptions.module !== 4 /* System */) { - write("exports."); - } - } - else { - // Identifier references namespace export - write(getGeneratedNameForNode(container)); - write("."); - } - } - else if (languageVersion < 2 /* ES6 */) { - var declaration = resolver.getReferencedImportDeclaration(node); - if (declaration) { - if (declaration.kind === 221 /* ImportClause */) { - // Identifier references default import - write(getGeneratedNameForNode(declaration.parent)); - write(languageVersion === 0 /* ES3 */ ? "[\"default\"]" : ".default"); - return; - } - else if (declaration.kind === 224 /* ImportSpecifier */) { - // Identifier references named import - write(getGeneratedNameForNode(declaration.parent.parent.parent)); - var name = declaration.propertyName || declaration.name; - var identifier = ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, name); - if (languageVersion === 0 /* ES3 */ && identifier === "default") { - write("[\"default\"]"); - } - else { - write("."); - write(identifier); - } - return; - } - } - declaration = resolver.getReferencedNestedRedeclaration(node); - if (declaration) { - write(getGeneratedNameForNode(declaration.name)); - return; - } - } - if (ts.nodeIsSynthesized(node)) { - write(node.text); - } - else { - writeTextOfNode(currentSourceFile, node); - } - } - function isNameOfNestedRedeclaration(node) { - if (languageVersion < 2 /* ES6 */) { - var parent_6 = node.parent; - switch (parent_6.kind) { - case 161 /* BindingElement */: - case 212 /* ClassDeclaration */: - case 215 /* EnumDeclaration */: - case 209 /* VariableDeclaration */: - return parent_6.name === node && resolver.isNestedRedeclaration(parent_6); - } - } - return false; - } - function emitIdentifier(node) { - if (!node.parent) { - write(node.text); - } - else if (isExpressionIdentifier(node)) { - emitExpressionIdentifier(node); - } - else if (isNameOfNestedRedeclaration(node)) { - write(getGeneratedNameForNode(node)); - } - else if (ts.nodeIsSynthesized(node)) { - write(node.text); - } - else { - writeTextOfNode(currentSourceFile, node); - } - } - function emitThis(node) { - if (resolver.getNodeCheckFlags(node) & 2 /* LexicalThis */) { - write("_this"); - } - else { - write("this"); - } - } - function emitSuper(node) { - if (languageVersion >= 2 /* ES6 */) { - write("super"); - } - else { - var flags = resolver.getNodeCheckFlags(node); - if (flags & 256 /* SuperInstance */) { - write("_super.prototype"); - } - else { - write("_super"); - } - } - } - function emitObjectBindingPattern(node) { - write("{ "); - var elements = node.elements; - emitList(elements, 0, elements.length, /*multiLine*/ false, /*trailingComma*/ elements.hasTrailingComma); - write(" }"); - } - function emitArrayBindingPattern(node) { - write("["); - var elements = node.elements; - emitList(elements, 0, elements.length, /*multiLine*/ false, /*trailingComma*/ elements.hasTrailingComma); - write("]"); - } - function emitBindingElement(node) { - if (node.propertyName) { - emit(node.propertyName); - write(": "); - } - if (node.dotDotDotToken) { - write("..."); - } - if (ts.isBindingPattern(node.name)) { - emit(node.name); - } - else { - emitModuleMemberName(node); - } - emitOptional(" = ", node.initializer); - } - function emitSpreadElementExpression(node) { - write("..."); - emit(node.expression); - } - function emitYieldExpression(node) { - write(ts.tokenToString(112 /* YieldKeyword */)); - if (node.asteriskToken) { - write("*"); - } - if (node.expression) { - write(" "); - emit(node.expression); - } - } - function emitAwaitExpression(node) { - var needsParenthesis = needsParenthesisForAwaitExpressionAsYield(node); - if (needsParenthesis) { - write("("); - } - write(ts.tokenToString(112 /* YieldKeyword */)); - write(" "); - emit(node.expression); - if (needsParenthesis) { - write(")"); - } - } - function needsParenthesisForAwaitExpressionAsYield(node) { - if (node.parent.kind === 179 /* BinaryExpression */ && !ts.isAssignmentOperator(node.parent.operatorToken.kind)) { - return true; - } - else if (node.parent.kind === 180 /* ConditionalExpression */ && node.parent.condition === node) { - return true; - } - return false; - } - function needsParenthesisForPropertyAccessOrInvocation(node) { - switch (node.kind) { - case 67 /* Identifier */: - case 162 /* ArrayLiteralExpression */: - case 164 /* PropertyAccessExpression */: - case 165 /* ElementAccessExpression */: - case 166 /* CallExpression */: - case 170 /* ParenthesizedExpression */: - // This list is not exhaustive and only includes those cases that are relevant - // to the check in emitArrayLiteral. More cases can be added as needed. - return false; - } - return true; - } - function emitListWithSpread(elements, needsUniqueCopy, multiLine, trailingComma, useConcat) { - var pos = 0; - var group = 0; - var length = elements.length; - while (pos < length) { - // Emit using the pattern .concat(, , ...) - if (group === 1 && useConcat) { - write(".concat("); - } - else if (group > 0) { - write(", "); - } - var e = elements[pos]; - if (e.kind === 183 /* SpreadElementExpression */) { - e = e.expression; - emitParenthesizedIf(e, /*parenthesized*/ group === 0 && needsParenthesisForPropertyAccessOrInvocation(e)); - pos++; - if (pos === length && group === 0 && needsUniqueCopy && e.kind !== 162 /* ArrayLiteralExpression */) { - write(".slice()"); - } - } - else { - var i = pos; - while (i < length && elements[i].kind !== 183 /* SpreadElementExpression */) { - i++; - } - write("["); - if (multiLine) { - increaseIndent(); - } - emitList(elements, pos, i - pos, multiLine, trailingComma && i === length); - if (multiLine) { - decreaseIndent(); - } - write("]"); - pos = i; - } - group++; - } - if (group > 1) { - if (useConcat) { - write(")"); - } - } - } - function isSpreadElementExpression(node) { - return node.kind === 183 /* SpreadElementExpression */; - } - function emitArrayLiteral(node) { - var elements = node.elements; - if (elements.length === 0) { - write("[]"); - } - else if (languageVersion >= 2 /* ES6 */ || !ts.forEach(elements, isSpreadElementExpression)) { - write("["); - emitLinePreservingList(node, node.elements, elements.hasTrailingComma, /*spacesBetweenBraces:*/ false); - write("]"); - } - else { - emitListWithSpread(elements, /*needsUniqueCopy*/ true, /*multiLine*/ (node.flags & 2048 /* MultiLine */) !== 0, - /*trailingComma*/ elements.hasTrailingComma, /*useConcat*/ true); - } - } - function emitObjectLiteralBody(node, numElements) { - if (numElements === 0) { - write("{}"); - return; - } - write("{"); - if (numElements > 0) { - var properties = node.properties; - // If we are not doing a downlevel transformation for object literals, - // then try to preserve the original shape of the object literal. - // Otherwise just try to preserve the formatting. - if (numElements === properties.length) { - emitLinePreservingList(node, properties, /* allowTrailingComma */ languageVersion >= 1 /* ES5 */, /* spacesBetweenBraces */ true); - } - else { - var multiLine = (node.flags & 2048 /* MultiLine */) !== 0; - if (!multiLine) { - write(" "); - } - else { - increaseIndent(); - } - emitList(properties, 0, numElements, /*multiLine*/ multiLine, /*trailingComma*/ false); - if (!multiLine) { - write(" "); - } - else { - decreaseIndent(); - } - } - } - write("}"); - } - function emitDownlevelObjectLiteralWithComputedProperties(node, firstComputedPropertyIndex) { - var multiLine = (node.flags & 2048 /* MultiLine */) !== 0; - var properties = node.properties; - write("("); - if (multiLine) { - increaseIndent(); - } - // 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 tempVar = createAndRecordTempVariable(0 /* Auto */); - // Write out the first non-computed properties - // (or all properties if none of them are computed), - // then emit the rest through indexing on the temp variable. - emit(tempVar); - write(" = "); - emitObjectLiteralBody(node, firstComputedPropertyIndex); - for (var i = firstComputedPropertyIndex, n = properties.length; i < n; i++) { - writeComma(); - var property = properties[i]; - emitStart(property); - if (property.kind === 143 /* GetAccessor */ || property.kind === 144 /* SetAccessor */) { - // TODO (drosen): Reconcile with 'emitMemberFunctions'. - var accessors = ts.getAllAccessorDeclarations(node.properties, property); - if (property !== accessors.firstAccessor) { - continue; - } - write("Object.defineProperty("); - emit(tempVar); - write(", "); - emitStart(node.name); - emitExpressionForPropertyName(property.name); - emitEnd(property.name); - write(", {"); - increaseIndent(); - if (accessors.getAccessor) { - writeLine(); - emitLeadingComments(accessors.getAccessor); - write("get: "); - emitStart(accessors.getAccessor); - write("function "); - emitSignatureAndBody(accessors.getAccessor); - emitEnd(accessors.getAccessor); - emitTrailingComments(accessors.getAccessor); - write(","); - } - if (accessors.setAccessor) { - writeLine(); - emitLeadingComments(accessors.setAccessor); - write("set: "); - emitStart(accessors.setAccessor); - write("function "); - emitSignatureAndBody(accessors.setAccessor); - emitEnd(accessors.setAccessor); - emitTrailingComments(accessors.setAccessor); - write(","); - } - writeLine(); - write("enumerable: true,"); - writeLine(); - write("configurable: true"); - decreaseIndent(); - writeLine(); - write("})"); - emitEnd(property); - } - else { - emitLeadingComments(property); - emitStart(property.name); - emit(tempVar); - emitMemberAccessForPropertyName(property.name); - emitEnd(property.name); - write(" = "); - if (property.kind === 243 /* PropertyAssignment */) { - emit(property.initializer); - } - else if (property.kind === 244 /* ShorthandPropertyAssignment */) { - emitExpressionIdentifier(property.name); - } - else if (property.kind === 141 /* MethodDeclaration */) { - emitFunctionDeclaration(property); - } - else { - ts.Debug.fail("ObjectLiteralElement type not accounted for: " + property.kind); - } - } - emitEnd(property); - } - writeComma(); - emit(tempVar); - if (multiLine) { - decreaseIndent(); - writeLine(); - } - write(")"); - function writeComma() { - if (multiLine) { - write(","); - writeLine(); - } - else { - write(", "); - } - } - } - function emitObjectLiteral(node) { - var properties = node.properties; - if (languageVersion < 2 /* ES6 */) { - var numProperties = properties.length; - // Find the first computed property. - // Everything until that point can be emitted as part of the initial object literal. - var numInitialNonComputedProperties = numProperties; - for (var i = 0, n = properties.length; i < n; i++) { - if (properties[i].name.kind === 134 /* ComputedPropertyName */) { - numInitialNonComputedProperties = i; - break; - } - } - var hasComputedProperty = numInitialNonComputedProperties !== properties.length; - if (hasComputedProperty) { - emitDownlevelObjectLiteralWithComputedProperties(node, numInitialNonComputedProperties); - return; - } - } - // Ordinary case: either the object has no computed properties - // or we're compiling with an ES6+ target. - emitObjectLiteralBody(node, properties.length); - } - function createBinaryExpression(left, operator, right, startsOnNewLine) { - var result = ts.createSynthesizedNode(179 /* BinaryExpression */, startsOnNewLine); - result.operatorToken = ts.createSynthesizedNode(operator); - result.left = left; - result.right = right; - return result; - } - function createPropertyAccessExpression(expression, name) { - var result = ts.createSynthesizedNode(164 /* PropertyAccessExpression */); - result.expression = parenthesizeForAccess(expression); - result.dotToken = ts.createSynthesizedNode(21 /* DotToken */); - result.name = name; - return result; - } - function createElementAccessExpression(expression, argumentExpression) { - var result = ts.createSynthesizedNode(165 /* ElementAccessExpression */); - result.expression = parenthesizeForAccess(expression); - result.argumentExpression = argumentExpression; - return result; - } - function parenthesizeForAccess(expr) { - // When diagnosing whether the expression needs parentheses, the decision should be based - // on the innermost expression in a chain of nested type assertions. - while (expr.kind === 169 /* TypeAssertionExpression */ || expr.kind === 187 /* AsExpression */) { - expr = expr.expression; - } - // isLeftHandSideExpression is almost the correct criterion for when it is not necessary - // to parenthesize the expression before a dot. The known exceptions are: - // - // NewExpression: - // new C.x -> not the same as (new C).x - // NumberLiteral - // 1.x -> not the same as (1).x - // - if (ts.isLeftHandSideExpression(expr) && - expr.kind !== 167 /* NewExpression */ && - expr.kind !== 8 /* NumericLiteral */) { - return expr; - } - var node = ts.createSynthesizedNode(170 /* ParenthesizedExpression */); - node.expression = expr; - return node; - } - function emitComputedPropertyName(node) { - write("["); - emitExpressionForPropertyName(node); - write("]"); - } - function emitMethod(node) { - if (languageVersion >= 2 /* ES6 */ && node.asteriskToken) { - write("*"); - } - emit(node.name); - if (languageVersion < 2 /* ES6 */) { - write(": function "); - } - emitSignatureAndBody(node); - } - function emitPropertyAssignment(node) { - emit(node.name); - write(": "); - // This is to ensure that we emit comment in the following case: - // For example: - // obj = { - // id: /*comment1*/ ()=>void - // } - // "comment1" is not considered to be leading comment for node.initializer - // but rather a trailing comment on the previous node. - emitTrailingCommentsOfPosition(node.initializer.pos); - emit(node.initializer); - } - // Return true if identifier resolves to an exported member of a namespace - function isNamespaceExportReference(node) { - var container = resolver.getReferencedExportContainer(node); - return container && container.kind !== 246 /* SourceFile */; - } - function emitShorthandPropertyAssignment(node) { - // The name property of a short-hand property assignment is considered an expression position, so here - // we manually emit the identifier to avoid rewriting. - writeTextOfNode(currentSourceFile, node.name); - // If emitting pre-ES6 code, or if the name requires rewriting when resolved as an expression identifier, - // we emit a normal property assignment. For example: - // module m { - // export let y; - // } - // module m { - // let obj = { y }; - // } - // Here we need to emit obj = { y : m.y } regardless of the output target. - if (languageVersion < 2 /* ES6 */ || isNamespaceExportReference(node.name)) { - // Emit identifier as an identifier - write(": "); - emit(node.name); - } - } - function tryEmitConstantValue(node) { - var constantValue = tryGetConstEnumValue(node); - if (constantValue !== undefined) { - write(constantValue.toString()); - if (!compilerOptions.removeComments) { - var propertyName = node.kind === 164 /* PropertyAccessExpression */ ? ts.declarationNameToString(node.name) : ts.getTextOfNode(node.argumentExpression); - write(" /* " + propertyName + " */"); - } - return true; - } - return false; - } - function tryGetConstEnumValue(node) { - if (compilerOptions.isolatedModules) { - return undefined; - } - return node.kind === 164 /* PropertyAccessExpression */ || node.kind === 165 /* ElementAccessExpression */ - ? resolver.getConstantValue(node) - : undefined; - } - // Returns 'true' if the code was actually indented, false otherwise. - // If the code is not indented, an optional valueToWriteWhenNotIndenting will be - // emitted instead. - function indentIfOnDifferentLines(parent, node1, node2, valueToWriteWhenNotIndenting) { - var realNodesAreOnDifferentLines = !ts.nodeIsSynthesized(parent) && !nodeEndIsOnSameLineAsNodeStart(node1, node2); - // Always use a newline for synthesized code if the synthesizer desires it. - var synthesizedNodeIsOnDifferentLine = synthesizedNodeStartsOnNewLine(node2); - if (realNodesAreOnDifferentLines || synthesizedNodeIsOnDifferentLine) { - increaseIndent(); - writeLine(); - return true; - } - else { - if (valueToWriteWhenNotIndenting) { - write(valueToWriteWhenNotIndenting); - } - return false; - } - } - function emitPropertyAccess(node) { - if (tryEmitConstantValue(node)) { - return; - } - emit(node.expression); - var indentedBeforeDot = indentIfOnDifferentLines(node, node.expression, node.dotToken); - // 1 .toString is a valid property access, emit a space after the literal - // Also emit a space if expression is a integer const enum value - it will appear in generated code as numeric literal - var shouldEmitSpace; - if (!indentedBeforeDot) { - if (node.expression.kind === 8 /* NumericLiteral */) { - // check if numeric literal was originally written with a dot - var text = ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, node.expression); - shouldEmitSpace = text.indexOf(ts.tokenToString(21 /* DotToken */)) < 0; - } - else { - // check if constant enum value is integer - var constantValue = tryGetConstEnumValue(node.expression); - // isFinite handles cases when constantValue is undefined - shouldEmitSpace = isFinite(constantValue) && Math.floor(constantValue) === constantValue; - } - } - if (shouldEmitSpace) { - write(" ."); - } - else { - write("."); - } - var indentedAfterDot = indentIfOnDifferentLines(node, node.dotToken, node.name); - emit(node.name); - decreaseIndentIf(indentedBeforeDot, indentedAfterDot); - } - function emitQualifiedName(node) { - emit(node.left); - write("."); - emit(node.right); - } - function emitQualifiedNameAsExpression(node, useFallback) { - if (node.left.kind === 67 /* Identifier */) { - emitEntityNameAsExpression(node.left, useFallback); - } - else if (useFallback) { - var temp = createAndRecordTempVariable(0 /* Auto */); - write("("); - emitNodeWithoutSourceMap(temp); - write(" = "); - emitEntityNameAsExpression(node.left, /*useFallback*/ true); - write(") && "); - emitNodeWithoutSourceMap(temp); - } - else { - emitEntityNameAsExpression(node.left, /*useFallback*/ false); - } - write("."); - emit(node.right); - } - function emitEntityNameAsExpression(node, useFallback) { - switch (node.kind) { - case 67 /* Identifier */: - if (useFallback) { - write("typeof "); - emitExpressionIdentifier(node); - write(" !== 'undefined' && "); - } - emitExpressionIdentifier(node); - break; - case 133 /* QualifiedName */: - emitQualifiedNameAsExpression(node, useFallback); - break; - } - } - function emitIndexedAccess(node) { - if (tryEmitConstantValue(node)) { - return; - } - emit(node.expression); - write("["); - emit(node.argumentExpression); - write("]"); - } - function hasSpreadElement(elements) { - return ts.forEach(elements, function (e) { return e.kind === 183 /* SpreadElementExpression */; }); - } - function skipParentheses(node) { - while (node.kind === 170 /* ParenthesizedExpression */ || node.kind === 169 /* TypeAssertionExpression */ || node.kind === 187 /* AsExpression */) { - node = node.expression; - } - return node; - } - function emitCallTarget(node) { - if (node.kind === 67 /* Identifier */ || node.kind === 95 /* ThisKeyword */ || node.kind === 93 /* SuperKeyword */) { - emit(node); - return node; - } - var temp = createAndRecordTempVariable(0 /* Auto */); - write("("); - emit(temp); - write(" = "); - emit(node); - write(")"); - return temp; - } - function emitCallWithSpread(node) { - var target; - var expr = skipParentheses(node.expression); - if (expr.kind === 164 /* PropertyAccessExpression */) { - // Target will be emitted as "this" argument - target = emitCallTarget(expr.expression); - write("."); - emit(expr.name); - } - else if (expr.kind === 165 /* ElementAccessExpression */) { - // Target will be emitted as "this" argument - target = emitCallTarget(expr.expression); - write("["); - emit(expr.argumentExpression); - write("]"); - } - else if (expr.kind === 93 /* SuperKeyword */) { - target = expr; - write("_super"); - } - else { - emit(node.expression); - } - write(".apply("); - if (target) { - if (target.kind === 93 /* SuperKeyword */) { - // Calls of form super(...) and super.foo(...) - emitThis(target); - } - else { - // Calls of form obj.foo(...) - emit(target); - } - } - else { - // Calls of form foo(...) - write("void 0"); - } - write(", "); - emitListWithSpread(node.arguments, /*needsUniqueCopy*/ false, /*multiLine*/ false, /*trailingComma*/ false, /*useConcat*/ true); - write(")"); - } - function emitCallExpression(node) { - if (languageVersion < 2 /* ES6 */ && hasSpreadElement(node.arguments)) { - emitCallWithSpread(node); - return; - } - var superCall = false; - if (node.expression.kind === 93 /* SuperKeyword */) { - emitSuper(node.expression); - superCall = true; - } - else { - emit(node.expression); - superCall = node.expression.kind === 164 /* PropertyAccessExpression */ && node.expression.expression.kind === 93 /* SuperKeyword */; - } - if (superCall && languageVersion < 2 /* ES6 */) { - write(".call("); - emitThis(node.expression); - if (node.arguments.length) { - write(", "); - emitCommaList(node.arguments); - } - write(")"); - } - else { - write("("); - emitCommaList(node.arguments); - write(")"); - } - } - function emitNewExpression(node) { - write("new "); - // Spread operator logic is supported in new expressions in ES5 using a combination - // of Function.prototype.bind() and Function.prototype.apply(). - // - // Example: - // - // var args = [1, 2, 3, 4, 5]; - // new Array(...args); - // - // is compiled into the following ES5: - // - // var args = [1, 2, 3, 4, 5]; - // new (Array.bind.apply(Array, [void 0].concat(args))); - // - // The 'thisArg' to 'bind' is ignored when invoking the result of 'bind' with 'new', - // Thus, we set it to undefined ('void 0'). - if (languageVersion === 1 /* ES5 */ && - node.arguments && - hasSpreadElement(node.arguments)) { - write("("); - var target = emitCallTarget(node.expression); - write(".bind.apply("); - emit(target); - write(", [void 0].concat("); - emitListWithSpread(node.arguments, /*needsUniqueCopy*/ false, /*multiline*/ false, /*trailingComma*/ false, /*useConcat*/ false); - write(")))"); - write("()"); - } - else { - emit(node.expression); - if (node.arguments) { - write("("); - emitCommaList(node.arguments); - write(")"); - } - } - } - function emitTaggedTemplateExpression(node) { - if (languageVersion >= 2 /* ES6 */) { - emit(node.tag); - write(" "); - emit(node.template); - } - else { - emitDownlevelTaggedTemplate(node); - } - } - function emitParenExpression(node) { - // If the node is synthesized, it means the emitter put the parentheses there, - // not the user. If we didn't want them, the emitter would not have put them - // there. - if (!ts.nodeIsSynthesized(node) && node.parent.kind !== 172 /* ArrowFunction */) { - if (node.expression.kind === 169 /* TypeAssertionExpression */ || node.expression.kind === 187 /* AsExpression */) { - var operand = node.expression.expression; - // Make sure we consider all nested cast expressions, e.g.: - // (-A).x; - while (operand.kind === 169 /* TypeAssertionExpression */ || operand.kind === 187 /* AsExpression */) { - operand = operand.expression; - } - // We have an expression of the form: (SubExpr) - // Emitting this as (SubExpr) is really not desirable. We would like to emit the subexpr as is. - // Omitting the parentheses, however, could cause change in the semantics of the generated - // code if the casted expression has a lower precedence than the rest of the expression, e.g.: - // (new A).foo should be emitted as (new A).foo and not new A.foo - // (typeof A).toString() should be emitted as (typeof A).toString() and not typeof A.toString() - // new (A()) should be emitted as new (A()) and not new A() - // (function foo() { })() should be emitted as an IIF (function foo(){})() and not declaration function foo(){} () - if (operand.kind !== 177 /* PrefixUnaryExpression */ && - operand.kind !== 175 /* VoidExpression */ && - operand.kind !== 174 /* TypeOfExpression */ && - operand.kind !== 173 /* DeleteExpression */ && - operand.kind !== 178 /* PostfixUnaryExpression */ && - operand.kind !== 167 /* NewExpression */ && - !(operand.kind === 166 /* CallExpression */ && node.parent.kind === 167 /* NewExpression */) && - !(operand.kind === 171 /* FunctionExpression */ && node.parent.kind === 166 /* CallExpression */) && - !(operand.kind === 8 /* NumericLiteral */ && node.parent.kind === 164 /* PropertyAccessExpression */)) { - emit(operand); - return; - } - } - } - write("("); - emit(node.expression); - write(")"); - } - function emitDeleteExpression(node) { - write(ts.tokenToString(76 /* DeleteKeyword */)); - write(" "); - emit(node.expression); - } - function emitVoidExpression(node) { - write(ts.tokenToString(101 /* VoidKeyword */)); - write(" "); - emit(node.expression); - } - function emitTypeOfExpression(node) { - write(ts.tokenToString(99 /* TypeOfKeyword */)); - write(" "); - emit(node.expression); - } - function isNameOfExportedSourceLevelDeclarationInSystemExternalModule(node) { - if (!isCurrentFileSystemExternalModule() || node.kind !== 67 /* Identifier */ || ts.nodeIsSynthesized(node)) { - return false; - } - var isVariableDeclarationOrBindingElement = node.parent && (node.parent.kind === 209 /* VariableDeclaration */ || node.parent.kind === 161 /* BindingElement */); - var targetDeclaration = isVariableDeclarationOrBindingElement - ? node.parent - : resolver.getReferencedValueDeclaration(node); - return isSourceFileLevelDeclarationInSystemJsModule(targetDeclaration, /*isExported*/ true); - } - function emitPrefixUnaryExpression(node) { - var exportChanged = isNameOfExportedSourceLevelDeclarationInSystemExternalModule(node.operand); - if (exportChanged) { - // emit - // ++x - // as - // exports('x', ++x) - write(exportFunctionForFile + "(\""); - emitNodeWithoutSourceMap(node.operand); - write("\", "); - } - write(ts.tokenToString(node.operator)); - // In some cases, we need to emit a space between the operator and the operand. One obvious case - // is when the operator is an identifier, like delete or typeof. We also need to do this for plus - // and minus expressions in certain cases. Specifically, consider the following two cases (parens - // are just for clarity of exposition, and not part of the source code): - // - // (+(+1)) - // (+(++1)) - // - // We need to emit a space in both cases. In the first case, the absence of a space will make - // the resulting expression a prefix increment operation. And in the second, it will make the resulting - // expression a prefix increment whose operand is a plus expression - (++(+x)) - // The same is true of minus of course. - if (node.operand.kind === 177 /* PrefixUnaryExpression */) { - var operand = node.operand; - if (node.operator === 35 /* PlusToken */ && (operand.operator === 35 /* PlusToken */ || operand.operator === 40 /* PlusPlusToken */)) { - write(" "); - } - else if (node.operator === 36 /* MinusToken */ && (operand.operator === 36 /* MinusToken */ || operand.operator === 41 /* MinusMinusToken */)) { - write(" "); - } - } - emit(node.operand); - if (exportChanged) { - write(")"); - } - } - function emitPostfixUnaryExpression(node) { - var exportChanged = isNameOfExportedSourceLevelDeclarationInSystemExternalModule(node.operand); - if (exportChanged) { - // 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)' - write("(" + exportFunctionForFile + "(\""); - emitNodeWithoutSourceMap(node.operand); - write("\", "); - write(ts.tokenToString(node.operator)); - emit(node.operand); - if (node.operator === 40 /* PlusPlusToken */) { - write(") - 1)"); - } - else { - write(") + 1)"); - } - } - else { - emit(node.operand); - write(ts.tokenToString(node.operator)); - } - } - function shouldHoistDeclarationInSystemJsModule(node) { - return isSourceFileLevelDeclarationInSystemJsModule(node, /*isExported*/ false); - } - /* - * Checks if given node is a source file level declaration (not nested in module/function). - * If 'isExported' is true - then declaration must also be exported. - * This function is used in two cases: - * - check if node is a exported source file level value to determine - * if we should also export the value after its it changed - * - check if node is a source level declaration to emit it differently, - * i.e non-exported variable statement 'var x = 1' is hoisted so - * we we emit variable statement 'var' should be dropped. - */ - function isSourceFileLevelDeclarationInSystemJsModule(node, isExported) { - if (!node || languageVersion >= 2 /* ES6 */ || !isCurrentFileSystemExternalModule()) { - return false; - } - var current = node; - while (current) { - if (current.kind === 246 /* SourceFile */) { - return !isExported || ((ts.getCombinedNodeFlags(node) & 1 /* Export */) !== 0); - } - else if (ts.isFunctionLike(current) || current.kind === 217 /* ModuleBlock */) { - return false; - } - else { - current = current.parent; - } - } - } - function emitBinaryExpression(node) { - if (languageVersion < 2 /* ES6 */ && node.operatorToken.kind === 55 /* EqualsToken */ && - (node.left.kind === 163 /* ObjectLiteralExpression */ || node.left.kind === 162 /* ArrayLiteralExpression */)) { - emitDestructuring(node, node.parent.kind === 193 /* ExpressionStatement */); - } - else { - var exportChanged = node.operatorToken.kind >= 55 /* FirstAssignment */ && - node.operatorToken.kind <= 66 /* LastAssignment */ && - isNameOfExportedSourceLevelDeclarationInSystemExternalModule(node.left); - if (exportChanged) { - // emit assignment 'x y' as 'exports("x", x y)' - write(exportFunctionForFile + "(\""); - emitNodeWithoutSourceMap(node.left); - write("\", "); - } - emit(node.left); - var indentedBeforeOperator = indentIfOnDifferentLines(node, node.left, node.operatorToken, node.operatorToken.kind !== 24 /* CommaToken */ ? " " : undefined); - write(ts.tokenToString(node.operatorToken.kind)); - var indentedAfterOperator = indentIfOnDifferentLines(node, node.operatorToken, node.right, " "); - emit(node.right); - decreaseIndentIf(indentedBeforeOperator, indentedAfterOperator); - if (exportChanged) { - write(")"); - } - } - } - function synthesizedNodeStartsOnNewLine(node) { - return ts.nodeIsSynthesized(node) && node.startsOnNewLine; - } - function emitConditionalExpression(node) { - emit(node.condition); - var indentedBeforeQuestion = indentIfOnDifferentLines(node, node.condition, node.questionToken, " "); - write("?"); - var indentedAfterQuestion = indentIfOnDifferentLines(node, node.questionToken, node.whenTrue, " "); - emit(node.whenTrue); - decreaseIndentIf(indentedBeforeQuestion, indentedAfterQuestion); - var indentedBeforeColon = indentIfOnDifferentLines(node, node.whenTrue, node.colonToken, " "); - write(":"); - var indentedAfterColon = indentIfOnDifferentLines(node, node.colonToken, node.whenFalse, " "); - emit(node.whenFalse); - decreaseIndentIf(indentedBeforeColon, indentedAfterColon); - } - // Helper function to decrease the indent if we previously indented. Allows multiple - // previous indent values to be considered at a time. This also allows caller to just - // call this once, passing in all their appropriate indent values, instead of needing - // to call this helper function multiple times. - function decreaseIndentIf(value1, value2) { - if (value1) { - decreaseIndent(); - } - if (value2) { - decreaseIndent(); - } - } - function isSingleLineEmptyBlock(node) { - if (node && node.kind === 190 /* Block */) { - var block = node; - return block.statements.length === 0 && nodeEndIsOnSameLineAsNodeStart(block, block); - } - } - function emitBlock(node) { - if (isSingleLineEmptyBlock(node)) { - emitToken(15 /* OpenBraceToken */, node.pos); - write(" "); - emitToken(16 /* CloseBraceToken */, node.statements.end); - return; - } - emitToken(15 /* OpenBraceToken */, node.pos); - increaseIndent(); - scopeEmitStart(node.parent); - if (node.kind === 217 /* ModuleBlock */) { - ts.Debug.assert(node.parent.kind === 216 /* ModuleDeclaration */); - emitCaptureThisForNodeIfNecessary(node.parent); - } - emitLines(node.statements); - if (node.kind === 217 /* ModuleBlock */) { - emitTempDeclarations(/*newLine*/ true); - } - decreaseIndent(); - writeLine(); - emitToken(16 /* CloseBraceToken */, node.statements.end); - scopeEmitEnd(); - } - function emitEmbeddedStatement(node) { - if (node.kind === 190 /* Block */) { - write(" "); - emit(node); - } - else { - increaseIndent(); - writeLine(); - emit(node); - decreaseIndent(); - } - } - function emitExpressionStatement(node) { - emitParenthesizedIf(node.expression, /*parenthesized*/ node.expression.kind === 172 /* ArrowFunction */); - write(";"); - } - function emitIfStatement(node) { - var endPos = emitToken(86 /* IfKeyword */, node.pos); - write(" "); - endPos = emitToken(17 /* OpenParenToken */, endPos); - emit(node.expression); - emitToken(18 /* CloseParenToken */, node.expression.end); - emitEmbeddedStatement(node.thenStatement); - if (node.elseStatement) { - writeLine(); - emitToken(78 /* ElseKeyword */, node.thenStatement.end); - if (node.elseStatement.kind === 194 /* IfStatement */) { - write(" "); - emit(node.elseStatement); - } - else { - emitEmbeddedStatement(node.elseStatement); - } - } - } - function emitDoStatement(node) { - write("do"); - emitEmbeddedStatement(node.statement); - if (node.statement.kind === 190 /* Block */) { - write(" "); - } - else { - writeLine(); - } - write("while ("); - emit(node.expression); - write(");"); - } - function emitWhileStatement(node) { - write("while ("); - emit(node.expression); - write(")"); - emitEmbeddedStatement(node.statement); - } - /** - * Returns true if start of variable declaration list was emitted. - * Returns false if nothing was written - this can happen for source file level variable declarations - * in system modules where such variable declarations are hoisted. - */ - function tryEmitStartOfVariableDeclarationList(decl, startPos) { - if (shouldHoistVariable(decl, /*checkIfSourceFileLevelDecl*/ true)) { - // variables in variable declaration list were already hoisted - return false; - } - var tokenKind = 100 /* VarKeyword */; - if (decl && languageVersion >= 2 /* ES6 */) { - if (ts.isLet(decl)) { - tokenKind = 106 /* LetKeyword */; - } - else if (ts.isConst(decl)) { - tokenKind = 72 /* ConstKeyword */; - } - } - if (startPos !== undefined) { - emitToken(tokenKind, startPos); - write(" "); - } - else { - switch (tokenKind) { - case 100 /* VarKeyword */: - write("var "); - break; - case 106 /* LetKeyword */: - write("let "); - break; - case 72 /* ConstKeyword */: - write("const "); - break; - } - } - return true; - } - function emitVariableDeclarationListSkippingUninitializedEntries(list) { - var started = false; - for (var _a = 0, _b = list.declarations; _a < _b.length; _a++) { - var decl = _b[_a]; - if (!decl.initializer) { - continue; - } - if (!started) { - started = true; - } - else { - write(", "); - } - emit(decl); - } - return started; - } - function emitForStatement(node) { - var endPos = emitToken(84 /* ForKeyword */, node.pos); - write(" "); - endPos = emitToken(17 /* OpenParenToken */, endPos); - if (node.initializer && node.initializer.kind === 210 /* VariableDeclarationList */) { - var variableDeclarationList = node.initializer; - var startIsEmitted = tryEmitStartOfVariableDeclarationList(variableDeclarationList, endPos); - if (startIsEmitted) { - emitCommaList(variableDeclarationList.declarations); - } - else { - emitVariableDeclarationListSkippingUninitializedEntries(variableDeclarationList); - } - } - else if (node.initializer) { - emit(node.initializer); - } - write(";"); - emitOptional(" ", node.condition); - write(";"); - emitOptional(" ", node.incrementor); - write(")"); - emitEmbeddedStatement(node.statement); - } - function emitForInOrForOfStatement(node) { - if (languageVersion < 2 /* ES6 */ && node.kind === 199 /* ForOfStatement */) { - return emitDownLevelForOfStatement(node); - } - var endPos = emitToken(84 /* ForKeyword */, node.pos); - write(" "); - endPos = emitToken(17 /* OpenParenToken */, endPos); - if (node.initializer.kind === 210 /* VariableDeclarationList */) { - var variableDeclarationList = node.initializer; - if (variableDeclarationList.declarations.length >= 1) { - tryEmitStartOfVariableDeclarationList(variableDeclarationList, endPos); - emit(variableDeclarationList.declarations[0]); - } - } - else { - emit(node.initializer); - } - if (node.kind === 198 /* ForInStatement */) { - write(" in "); - } - else { - write(" of "); - } - emit(node.expression); - emitToken(18 /* CloseParenToken */, node.expression.end); - emitEmbeddedStatement(node.statement); - } - function emitDownLevelForOfStatement(node) { - // The following ES6 code: - // - // for (let v of expr) { } - // - // should be emitted as - // - // for (let _i = 0, _a = expr; _i < _a.length; _i++) { - // let v = _a[_i]; - // } - // - // where _a and _i are temps emitted to capture the RHS and the counter, - // respectively. - // When the left hand side is an expression instead of a let declaration, - // the "let v" is not emitted. - // When the left hand side is a let/const, the v is renamed if there is - // another v in scope. - // Note that all assignments to the LHS are emitted in the body, including - // all destructuring. - // Note also that because an extra statement is needed to assign to the LHS, - // for-of bodies are always emitted as blocks. - var endPos = emitToken(84 /* ForKeyword */, node.pos); - write(" "); - endPos = emitToken(17 /* OpenParenToken */, endPos); - // Do not emit the LHS let declaration yet, because it might contain destructuring. - // Do not call recordTempDeclaration because we are declaring the temps - // right here. Recording means they will be declared later. - // 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 rhsIsIdentifier = node.expression.kind === 67 /* Identifier */; - var counter = createTempVariable(268435456 /* _i */); - var rhsReference = rhsIsIdentifier ? node.expression : createTempVariable(0 /* Auto */); - // This is the let keyword for the counter and rhsReference. The let keyword for - // the LHS will be emitted inside the body. - emitStart(node.expression); - write("var "); - // _i = 0 - emitNodeWithoutSourceMap(counter); - write(" = 0"); - emitEnd(node.expression); - if (!rhsIsIdentifier) { - // , _a = expr - write(", "); - emitStart(node.expression); - emitNodeWithoutSourceMap(rhsReference); - write(" = "); - emitNodeWithoutSourceMap(node.expression); - emitEnd(node.expression); - } - write("; "); - // _i < _a.length; - emitStart(node.initializer); - emitNodeWithoutSourceMap(counter); - write(" < "); - emitNodeWithCommentsAndWithoutSourcemap(rhsReference); - write(".length"); - emitEnd(node.initializer); - write("; "); - // _i++) - emitStart(node.initializer); - emitNodeWithoutSourceMap(counter); - write("++"); - emitEnd(node.initializer); - emitToken(18 /* CloseParenToken */, node.expression.end); - // Body - write(" {"); - writeLine(); - increaseIndent(); - // Initialize LHS - // let v = _a[_i]; - var rhsIterationValue = createElementAccessExpression(rhsReference, counter); - emitStart(node.initializer); - if (node.initializer.kind === 210 /* VariableDeclarationList */) { - write("var "); - var variableDeclarationList = node.initializer; - if (variableDeclarationList.declarations.length > 0) { - var declaration = variableDeclarationList.declarations[0]; - if (ts.isBindingPattern(declaration.name)) { - // This works whether the declaration is a var, let, or const. - // It will use rhsIterationValue _a[_i] as the initializer. - emitDestructuring(declaration, /*isAssignmentExpressionStatement*/ false, rhsIterationValue); - } - else { - // The following call does not include the initializer, so we have - // to emit it separately. - emitNodeWithCommentsAndWithoutSourcemap(declaration); - write(" = "); - emitNodeWithoutSourceMap(rhsIterationValue); - } - } - else { - // It's an empty declaration list. This can only happen in an error case, if the user wrote - // for (let of []) {} - emitNodeWithoutSourceMap(createTempVariable(0 /* Auto */)); - write(" = "); - emitNodeWithoutSourceMap(rhsIterationValue); - } - } - else { - // Initializer is an expression. Emit the expression in the body, so that it's - // evaluated on every iteration. - var assignmentExpression = createBinaryExpression(node.initializer, 55 /* EqualsToken */, rhsIterationValue, /*startsOnNewLine*/ false); - if (node.initializer.kind === 162 /* ArrayLiteralExpression */ || node.initializer.kind === 163 /* ObjectLiteralExpression */) { - // This is a destructuring pattern, so call emitDestructuring instead of emit. Calling emit will not work, because it will cause - // the BinaryExpression to be passed in instead of the expression statement, which will cause emitDestructuring to crash. - emitDestructuring(assignmentExpression, /*isAssignmentExpressionStatement*/ true, /*value*/ undefined); - } - else { - emitNodeWithCommentsAndWithoutSourcemap(assignmentExpression); - } - } - emitEnd(node.initializer); - write(";"); - if (node.statement.kind === 190 /* Block */) { - emitLines(node.statement.statements); - } - else { - writeLine(); - emit(node.statement); - } - writeLine(); - decreaseIndent(); - write("}"); - } - function emitBreakOrContinueStatement(node) { - emitToken(node.kind === 201 /* BreakStatement */ ? 68 /* BreakKeyword */ : 73 /* ContinueKeyword */, node.pos); - emitOptional(" ", node.label); - write(";"); - } - function emitReturnStatement(node) { - emitToken(92 /* ReturnKeyword */, node.pos); - emitOptional(" ", node.expression); - write(";"); - } - function emitWithStatement(node) { - write("with ("); - emit(node.expression); - write(")"); - emitEmbeddedStatement(node.statement); - } - function emitSwitchStatement(node) { - var endPos = emitToken(94 /* SwitchKeyword */, node.pos); - write(" "); - emitToken(17 /* OpenParenToken */, endPos); - emit(node.expression); - endPos = emitToken(18 /* CloseParenToken */, node.expression.end); - write(" "); - emitCaseBlock(node.caseBlock, endPos); - } - function emitCaseBlock(node, startPos) { - emitToken(15 /* OpenBraceToken */, startPos); - increaseIndent(); - emitLines(node.clauses); - decreaseIndent(); - writeLine(); - emitToken(16 /* CloseBraceToken */, node.clauses.end); - } - function nodeStartPositionsAreOnSameLine(node1, node2) { - return ts.getLineOfLocalPosition(currentSourceFile, ts.skipTrivia(currentSourceFile.text, node1.pos)) === - ts.getLineOfLocalPosition(currentSourceFile, ts.skipTrivia(currentSourceFile.text, node2.pos)); - } - function nodeEndPositionsAreOnSameLine(node1, node2) { - return ts.getLineOfLocalPosition(currentSourceFile, node1.end) === - ts.getLineOfLocalPosition(currentSourceFile, node2.end); - } - function nodeEndIsOnSameLineAsNodeStart(node1, node2) { - return ts.getLineOfLocalPosition(currentSourceFile, node1.end) === - ts.getLineOfLocalPosition(currentSourceFile, ts.skipTrivia(currentSourceFile.text, node2.pos)); - } - function emitCaseOrDefaultClause(node) { - if (node.kind === 239 /* CaseClause */) { - write("case "); - emit(node.expression); - write(":"); - } - else { - write("default:"); - } - if (node.statements.length === 1 && nodeStartPositionsAreOnSameLine(node, node.statements[0])) { - write(" "); - emit(node.statements[0]); - } - else { - increaseIndent(); - emitLines(node.statements); - decreaseIndent(); - } - } - function emitThrowStatement(node) { - write("throw "); - emit(node.expression); - write(";"); - } - function emitTryStatement(node) { - write("try "); - emit(node.tryBlock); - emit(node.catchClause); - if (node.finallyBlock) { - writeLine(); - write("finally "); - emit(node.finallyBlock); - } - } - function emitCatchClause(node) { - writeLine(); - var endPos = emitToken(70 /* CatchKeyword */, node.pos); - write(" "); - emitToken(17 /* OpenParenToken */, endPos); - emit(node.variableDeclaration); - emitToken(18 /* CloseParenToken */, node.variableDeclaration ? node.variableDeclaration.end : endPos); - write(" "); - emitBlock(node.block); - } - function emitDebuggerStatement(node) { - emitToken(74 /* DebuggerKeyword */, node.pos); - write(";"); - } - function emitLabelledStatement(node) { - emit(node.label); - write(": "); - emit(node.statement); - } - function getContainingModule(node) { - do { - node = node.parent; - } while (node && node.kind !== 216 /* ModuleDeclaration */); - return node; - } - function emitContainingModuleName(node) { - var container = getContainingModule(node); - write(container ? getGeneratedNameForNode(container) : "exports"); - } - function emitModuleMemberName(node) { - emitStart(node.name); - if (ts.getCombinedNodeFlags(node) & 1 /* Export */) { - var container = getContainingModule(node); - if (container) { - write(getGeneratedNameForNode(container)); - write("."); - } - else if (languageVersion < 2 /* ES6 */ && compilerOptions.module !== 4 /* System */) { - write("exports."); - } - } - emitNodeWithCommentsAndWithoutSourcemap(node.name); - emitEnd(node.name); - } - function createVoidZero() { - var zero = ts.createSynthesizedNode(8 /* NumericLiteral */); - zero.text = "0"; - var result = ts.createSynthesizedNode(175 /* VoidExpression */); - result.expression = zero; - return result; - } - function emitEs6ExportDefaultCompat(node) { - if (node.parent.kind === 246 /* SourceFile */) { - ts.Debug.assert(!!(node.flags & 1024 /* Default */) || node.kind === 225 /* ExportAssignment */); - // only allow export default at a source file level - if (compilerOptions.module === 1 /* CommonJS */ || compilerOptions.module === 2 /* AMD */ || compilerOptions.module === 3 /* UMD */) { - if (!currentSourceFile.symbol.exports["___esModule"]) { - if (languageVersion === 1 /* ES5 */) { - // default value of configurable, enumerable, writable are `false`. - write("Object.defineProperty(exports, \"__esModule\", { value: true });"); - writeLine(); - } - else if (languageVersion === 0 /* ES3 */) { - write("exports.__esModule = true;"); - writeLine(); - } - } - } - } - } - function emitExportMemberAssignment(node) { - if (node.flags & 1 /* Export */) { - writeLine(); - emitStart(node); - // emit call to exporter only for top level nodes - if (compilerOptions.module === 4 /* System */ && node.parent === currentSourceFile) { - // emit export default as - // export("default", ) - write(exportFunctionForFile + "(\""); - if (node.flags & 1024 /* Default */) { - write("default"); - } - else { - emitNodeWithCommentsAndWithoutSourcemap(node.name); - } - write("\", "); - emitDeclarationName(node); - write(")"); - } - else { - if (node.flags & 1024 /* Default */) { - emitEs6ExportDefaultCompat(node); - if (languageVersion === 0 /* ES3 */) { - write("exports[\"default\"]"); - } - else { - write("exports.default"); - } - } - else { - emitModuleMemberName(node); - } - write(" = "); - emitDeclarationName(node); - } - emitEnd(node); - write(";"); - } - } - function emitExportMemberAssignments(name) { - if (compilerOptions.module === 4 /* System */) { - return; - } - if (!exportEquals && exportSpecifiers && ts.hasProperty(exportSpecifiers, name.text)) { - for (var _a = 0, _b = exportSpecifiers[name.text]; _a < _b.length; _a++) { - var specifier = _b[_a]; - writeLine(); - emitStart(specifier.name); - emitContainingModuleName(specifier); - write("."); - emitNodeWithCommentsAndWithoutSourcemap(specifier.name); - emitEnd(specifier.name); - write(" = "); - emitExpressionIdentifier(name); - write(";"); - } - } - } - function emitExportSpecifierInSystemModule(specifier) { - ts.Debug.assert(compilerOptions.module === 4 /* System */); - if (!resolver.getReferencedValueDeclaration(specifier.propertyName || specifier.name) && !resolver.isValueAliasDeclaration(specifier)) { - return; - } - writeLine(); - emitStart(specifier.name); - write(exportFunctionForFile + "(\""); - emitNodeWithCommentsAndWithoutSourcemap(specifier.name); - write("\", "); - emitExpressionIdentifier(specifier.propertyName || specifier.name); - write(")"); - emitEnd(specifier.name); - write(";"); - } - function emitDestructuring(root, isAssignmentExpressionStatement, value) { - var emitCount = 0; - // An exported declaration is actually emitted as an assignment (to a property on the module object), so - // temporary variables in an exported declaration need to have real declarations elsewhere - // Also temporary variables should be explicitly allocated for source level declarations when module target is system - // because actual variable declarations are hoisted - var canDefineTempVariablesInPlace = false; - if (root.kind === 209 /* VariableDeclaration */) { - var isExported = ts.getCombinedNodeFlags(root) & 1 /* Export */; - var isSourceLevelForSystemModuleKind = shouldHoistDeclarationInSystemJsModule(root); - canDefineTempVariablesInPlace = !isExported && !isSourceLevelForSystemModuleKind; - } - else if (root.kind === 136 /* Parameter */) { - canDefineTempVariablesInPlace = true; - } - if (root.kind === 179 /* BinaryExpression */) { - emitAssignmentExpression(root); - } - else { - ts.Debug.assert(!isAssignmentExpressionStatement); - emitBindingElement(root, value); - } - function emitAssignment(name, value) { - if (emitCount++) { - write(", "); - } - var isVariableDeclarationOrBindingElement = name.parent && (name.parent.kind === 209 /* VariableDeclaration */ || name.parent.kind === 161 /* BindingElement */); - var exportChanged = isNameOfExportedSourceLevelDeclarationInSystemExternalModule(name); - if (exportChanged) { - write(exportFunctionForFile + "(\""); - emitNodeWithCommentsAndWithoutSourcemap(name); - write("\", "); - } - if (isVariableDeclarationOrBindingElement) { - emitModuleMemberName(name.parent); - } - else { - emit(name); - } - write(" = "); - emit(value); - if (exportChanged) { - write(")"); - } - } - /** - * Ensures that there exists a declared identifier whose value holds the given expression. - * This function is useful to ensure that the expression's value can be read from in subsequent expressions. - * Unless 'reuseIdentifierExpressions' is false, 'expr' will be returned if it is just an identifier. - * - * @param expr the expression whose value needs to be bound. - * @param reuseIdentifierExpressions true if identifier expressions can simply be returned; - * false if it is necessary to always emit an identifier. - */ - function ensureIdentifier(expr, reuseIdentifierExpressions) { - if (expr.kind === 67 /* Identifier */ && reuseIdentifierExpressions) { - return expr; - } - var identifier = createTempVariable(0 /* Auto */); - if (!canDefineTempVariablesInPlace) { - recordTempDeclaration(identifier); - } - emitAssignment(identifier, expr); - return identifier; - } - function createDefaultValueCheck(value, defaultValue) { - // The value expression will be evaluated twice, so for anything but a simple identifier - // we need to generate a temporary variable - value = ensureIdentifier(value, /*reuseIdentifierExpressions*/ true); - // Return the expression 'value === void 0 ? defaultValue : value' - var equals = ts.createSynthesizedNode(179 /* BinaryExpression */); - equals.left = value; - equals.operatorToken = ts.createSynthesizedNode(32 /* EqualsEqualsEqualsToken */); - equals.right = createVoidZero(); - return createConditionalExpression(equals, defaultValue, value); - } - function createConditionalExpression(condition, whenTrue, whenFalse) { - var cond = ts.createSynthesizedNode(180 /* ConditionalExpression */); - cond.condition = condition; - cond.questionToken = ts.createSynthesizedNode(52 /* QuestionToken */); - cond.whenTrue = whenTrue; - cond.colonToken = ts.createSynthesizedNode(53 /* ColonToken */); - cond.whenFalse = whenFalse; - return cond; - } - function createNumericLiteral(value) { - var node = ts.createSynthesizedNode(8 /* NumericLiteral */); - node.text = "" + value; - return node; - } - function createPropertyAccessForDestructuringProperty(object, propName) { - // We create a synthetic copy of the identifier in order to avoid the rewriting that might - // otherwise occur when the identifier is emitted. - var syntheticName = ts.createSynthesizedNode(propName.kind); - syntheticName.text = propName.text; - if (syntheticName.kind !== 67 /* Identifier */) { - return createElementAccessExpression(object, syntheticName); - } - return createPropertyAccessExpression(object, syntheticName); - } - function createSliceCall(value, sliceIndex) { - var call = ts.createSynthesizedNode(166 /* CallExpression */); - var sliceIdentifier = ts.createSynthesizedNode(67 /* Identifier */); - sliceIdentifier.text = "slice"; - call.expression = createPropertyAccessExpression(value, sliceIdentifier); - call.arguments = ts.createSynthesizedNodeArray(); - call.arguments[0] = createNumericLiteral(sliceIndex); - return call; - } - function emitObjectLiteralAssignment(target, value) { - var properties = target.properties; - if (properties.length !== 1) { - // For anything but a single element destructuring we need to generate a temporary - // to ensure value is evaluated exactly once. - value = ensureIdentifier(value, /*reuseIdentifierExpressions*/ true); - } - for (var _a = 0; _a < properties.length; _a++) { - var p = properties[_a]; - if (p.kind === 243 /* PropertyAssignment */ || p.kind === 244 /* ShorthandPropertyAssignment */) { - var propName = p.name; - emitDestructuringAssignment(p.initializer || propName, createPropertyAccessForDestructuringProperty(value, propName)); - } - } - } - function emitArrayLiteralAssignment(target, value) { - var elements = target.elements; - if (elements.length !== 1) { - // For anything but a single element destructuring we need to generate a temporary - // to ensure value is evaluated exactly once. - value = ensureIdentifier(value, /*reuseIdentifierExpressions*/ true); - } - for (var i = 0; i < elements.length; i++) { - var e = elements[i]; - if (e.kind !== 185 /* OmittedExpression */) { - if (e.kind !== 183 /* SpreadElementExpression */) { - emitDestructuringAssignment(e, createElementAccessExpression(value, createNumericLiteral(i))); - } - else if (i === elements.length - 1) { - emitDestructuringAssignment(e.expression, createSliceCall(value, i)); - } - } - } - } - function emitDestructuringAssignment(target, value) { - if (target.kind === 179 /* BinaryExpression */ && target.operatorToken.kind === 55 /* EqualsToken */) { - value = createDefaultValueCheck(value, target.right); - target = target.left; - } - if (target.kind === 163 /* ObjectLiteralExpression */) { - emitObjectLiteralAssignment(target, value); - } - else if (target.kind === 162 /* ArrayLiteralExpression */) { - emitArrayLiteralAssignment(target, value); - } - else { - emitAssignment(target, value); - } - } - function emitAssignmentExpression(root) { - var target = root.left; - var value = root.right; - if (ts.isEmptyObjectLiteralOrArrayLiteral(target)) { - emit(value); - } - else if (isAssignmentExpressionStatement) { - emitDestructuringAssignment(target, value); - } - else { - if (root.parent.kind !== 170 /* ParenthesizedExpression */) { - write("("); - } - value = ensureIdentifier(value, /*reuseIdentifierExpressions*/ true); - emitDestructuringAssignment(target, value); - write(", "); - emit(value); - if (root.parent.kind !== 170 /* ParenthesizedExpression */) { - write(")"); - } - } - } - function emitBindingElement(target, value) { - if (target.initializer) { - // Combine value and initializer - value = value ? createDefaultValueCheck(value, target.initializer) : target.initializer; - } - else if (!value) { - // Use 'void 0' in absence of value and initializer - value = createVoidZero(); - } - if (ts.isBindingPattern(target.name)) { - var pattern = target.name; - var elements = pattern.elements; - var numElements = elements.length; - if (numElements !== 1) { - // For anything other than a single-element destructuring we need to generate a temporary - // to ensure value is evaluated exactly once. Additionally, if we have zero elements - // we need to emit *something* to ensure that in case a 'var' keyword was already emitted, - // so in that case, we'll intentionally create that temporary. - value = ensureIdentifier(value, /*reuseIdentifierExpressions*/ numElements !== 0); - } - for (var i = 0; i < numElements; i++) { - var element = elements[i]; - if (pattern.kind === 159 /* ObjectBindingPattern */) { - // Rewrite element to a declaration with an initializer that fetches property - var propName = element.propertyName || element.name; - emitBindingElement(element, createPropertyAccessForDestructuringProperty(value, propName)); - } - else if (element.kind !== 185 /* OmittedExpression */) { - if (!element.dotDotDotToken) { - // Rewrite element to a declaration that accesses array element at index i - emitBindingElement(element, createElementAccessExpression(value, createNumericLiteral(i))); - } - else if (i === numElements - 1) { - emitBindingElement(element, createSliceCall(value, i)); - } - } - } - } - else { - emitAssignment(target.name, value); - } - } - } - function emitVariableDeclaration(node) { - if (ts.isBindingPattern(node.name)) { - if (languageVersion < 2 /* ES6 */) { - emitDestructuring(node, /*isAssignmentExpressionStatement*/ false); - } - else { - emit(node.name); - emitOptional(" = ", node.initializer); - } - } - else { - var initializer = node.initializer; - if (!initializer && languageVersion < 2 /* ES6 */) { - // downlevel emit for non-initialized let bindings defined in loops - // for (...) { let x; } - // should be - // for (...) { var = void 0; } - // this is necessary to preserve ES6 semantic in scenarios like - // for (...) { let x; console.log(x); x = 1 } // assignment on one iteration should not affect other iterations - var isUninitializedLet = (resolver.getNodeCheckFlags(node) & 16384 /* BlockScopedBindingInLoop */) && - (getCombinedFlagsForIdentifier(node.name) & 16384 /* Let */); - // NOTE: default initialization should not be added to let bindings in for-in\for-of statements - if (isUninitializedLet && - node.parent.parent.kind !== 198 /* ForInStatement */ && - node.parent.parent.kind !== 199 /* ForOfStatement */) { - initializer = createVoidZero(); - } - } - var exportChanged = isNameOfExportedSourceLevelDeclarationInSystemExternalModule(node.name); - if (exportChanged) { - write(exportFunctionForFile + "(\""); - emitNodeWithCommentsAndWithoutSourcemap(node.name); - write("\", "); - } - emitModuleMemberName(node); - emitOptional(" = ", initializer); - if (exportChanged) { - write(")"); - } - } - } - function emitExportVariableAssignments(node) { - if (node.kind === 185 /* OmittedExpression */) { - return; - } - var name = node.name; - if (name.kind === 67 /* Identifier */) { - emitExportMemberAssignments(name); - } - else if (ts.isBindingPattern(name)) { - ts.forEach(name.elements, emitExportVariableAssignments); - } - } - function getCombinedFlagsForIdentifier(node) { - if (!node.parent || (node.parent.kind !== 209 /* VariableDeclaration */ && node.parent.kind !== 161 /* BindingElement */)) { - return 0; - } - return ts.getCombinedNodeFlags(node.parent); - } - function isES6ExportedDeclaration(node) { - return !!(node.flags & 1 /* Export */) && - languageVersion >= 2 /* ES6 */ && - node.parent.kind === 246 /* SourceFile */; - } - function emitVariableStatement(node) { - var startIsEmitted = false; - if (node.flags & 1 /* Export */) { - if (isES6ExportedDeclaration(node)) { - // Exported ES6 module member - write("export "); - startIsEmitted = tryEmitStartOfVariableDeclarationList(node.declarationList); - } - } - else { - startIsEmitted = tryEmitStartOfVariableDeclarationList(node.declarationList); - } - if (startIsEmitted) { - emitCommaList(node.declarationList.declarations); - write(";"); - } - else { - var atLeastOneItem = emitVariableDeclarationListSkippingUninitializedEntries(node.declarationList); - if (atLeastOneItem) { - write(";"); - } - } - if (languageVersion < 2 /* ES6 */ && node.parent === currentSourceFile) { - ts.forEach(node.declarationList.declarations, emitExportVariableAssignments); - } - } - function shouldEmitLeadingAndTrailingCommentsForVariableStatement(node) { - // If we're not exporting the variables, there's nothing special here. - // Always emit comments for these nodes. - if (!(node.flags & 1 /* Export */)) { - return true; - } - // If we are exporting, but it's a top-level ES6 module exports, - // we'll emit the declaration list verbatim, so emit comments too. - if (isES6ExportedDeclaration(node)) { - return true; - } - // Otherwise, only emit if we have at least one initializer present. - for (var _a = 0, _b = node.declarationList.declarations; _a < _b.length; _a++) { - var declaration = _b[_a]; - if (declaration.initializer) { - return true; - } - } - return false; - } - function emitParameter(node) { - if (languageVersion < 2 /* ES6 */) { - if (ts.isBindingPattern(node.name)) { - var name_23 = createTempVariable(0 /* Auto */); - if (!tempParameters) { - tempParameters = []; - } - tempParameters.push(name_23); - emit(name_23); - } - else { - emit(node.name); - } - } - else { - if (node.dotDotDotToken) { - write("..."); - } - emit(node.name); - emitOptional(" = ", node.initializer); - } - } - function emitDefaultValueAssignments(node) { - if (languageVersion < 2 /* ES6 */) { - var tempIndex = 0; - ts.forEach(node.parameters, function (parameter) { - // A rest parameter cannot have a binding pattern or an initializer, - // so let's just ignore it. - if (parameter.dotDotDotToken) { - return; - } - var paramName = parameter.name, initializer = parameter.initializer; - if (ts.isBindingPattern(paramName)) { - // 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. - var hasBindingElements = paramName.elements.length > 0; - if (hasBindingElements || initializer) { - writeLine(); - write("var "); - if (hasBindingElements) { - emitDestructuring(parameter, /*isAssignmentExpressionStatement*/ false, tempParameters[tempIndex]); - } - else { - emit(tempParameters[tempIndex]); - write(" = "); - emit(initializer); - } - write(";"); - tempIndex++; - } - } - else if (initializer) { - writeLine(); - emitStart(parameter); - write("if ("); - emitNodeWithoutSourceMap(paramName); - write(" === void 0)"); - emitEnd(parameter); - write(" { "); - emitStart(parameter); - emitNodeWithCommentsAndWithoutSourcemap(paramName); - write(" = "); - emitNodeWithCommentsAndWithoutSourcemap(initializer); - emitEnd(parameter); - write("; }"); - } - }); - } - } - function emitRestParameter(node) { - if (languageVersion < 2 /* ES6 */ && ts.hasRestParameter(node)) { - var restIndex = node.parameters.length - 1; - var restParam = node.parameters[restIndex]; - // A rest parameter cannot have a binding pattern, so let's just ignore it if it does. - if (ts.isBindingPattern(restParam.name)) { - return; - } - var tempName = createTempVariable(268435456 /* _i */).text; - writeLine(); - emitLeadingComments(restParam); - emitStart(restParam); - write("var "); - emitNodeWithCommentsAndWithoutSourcemap(restParam.name); - write(" = [];"); - emitEnd(restParam); - emitTrailingComments(restParam); - writeLine(); - write("for ("); - emitStart(restParam); - write("var " + tempName + " = " + restIndex + ";"); - emitEnd(restParam); - write(" "); - emitStart(restParam); - write(tempName + " < arguments.length;"); - emitEnd(restParam); - write(" "); - emitStart(restParam); - write(tempName + "++"); - emitEnd(restParam); - write(") {"); - increaseIndent(); - writeLine(); - emitStart(restParam); - emitNodeWithCommentsAndWithoutSourcemap(restParam.name); - write("[" + tempName + " - " + restIndex + "] = arguments[" + tempName + "];"); - emitEnd(restParam); - decreaseIndent(); - writeLine(); - write("}"); - } - } - function emitAccessor(node) { - write(node.kind === 143 /* GetAccessor */ ? "get " : "set "); - emit(node.name); - emitSignatureAndBody(node); - } - function shouldEmitAsArrowFunction(node) { - return node.kind === 172 /* ArrowFunction */ && languageVersion >= 2 /* ES6 */; - } - function emitDeclarationName(node) { - if (node.name) { - emitNodeWithCommentsAndWithoutSourcemap(node.name); - } - else { - write(getGeneratedNameForNode(node)); - } - } - function shouldEmitFunctionName(node) { - if (node.kind === 171 /* FunctionExpression */) { - // Emit name if one is present - return !!node.name; - } - if (node.kind === 211 /* FunctionDeclaration */) { - // Emit name if one is present, or emit generated name in down-level case (for export default case) - return !!node.name || languageVersion < 2 /* ES6 */; - } - } - function emitFunctionDeclaration(node) { - if (ts.nodeIsMissing(node.body)) { - return emitCommentsOnNotEmittedNode(node); - } - // TODO (yuisu) : we should not have special cases to condition emitting comments - // but have one place to fix check for these conditions. - if (node.kind !== 141 /* MethodDeclaration */ && node.kind !== 140 /* MethodSignature */ && - node.parent && node.parent.kind !== 243 /* PropertyAssignment */ && - node.parent.kind !== 166 /* CallExpression */) { - // 1. Methods will emit the comments as part of emitting method declaration - // 2. If the function is a property of object literal, emitting leading-comments - // is done by emitNodeWithoutSourceMap which then call this function. - // In particular, we would like to avoid emit comments twice in following case: - // For example: - // var obj = { - // id: - // /*comment*/ () => void - // } - // 3. If the function is an argument in call expression, emitting of comments will be - // taken care of in emit list of arguments inside of emitCallexpression - emitLeadingComments(node); - } - emitStart(node); - // For targeting below es6, emit functions-like declaration including arrow function using function keyword. - // When targeting ES6, emit arrow function natively in ES6 by omitting function keyword and using fat arrow instead - if (!shouldEmitAsArrowFunction(node)) { - if (isES6ExportedDeclaration(node)) { - write("export "); - if (node.flags & 1024 /* Default */) { - write("default "); - } - } - write("function"); - if (languageVersion >= 2 /* ES6 */ && node.asteriskToken) { - write("*"); - } - write(" "); - } - if (shouldEmitFunctionName(node)) { - emitDeclarationName(node); - } - emitSignatureAndBody(node); - if (languageVersion < 2 /* ES6 */ && node.kind === 211 /* FunctionDeclaration */ && node.parent === currentSourceFile && node.name) { - emitExportMemberAssignments(node.name); - } - emitEnd(node); - if (node.kind !== 141 /* MethodDeclaration */ && node.kind !== 140 /* MethodSignature */) { - emitTrailingComments(node); - } - } - function emitCaptureThisForNodeIfNecessary(node) { - if (resolver.getNodeCheckFlags(node) & 4 /* CaptureThis */) { - writeLine(); - emitStart(node); - write("var _this = this;"); - emitEnd(node); - } - } - function emitSignatureParameters(node) { - increaseIndent(); - write("("); - if (node) { - var parameters = node.parameters; - var omitCount = languageVersion < 2 /* ES6 */ && ts.hasRestParameter(node) ? 1 : 0; - emitList(parameters, 0, parameters.length - omitCount, /*multiLine*/ false, /*trailingComma*/ false); - } - write(")"); - decreaseIndent(); - } - function emitSignatureParametersForArrow(node) { - // Check whether the parameter list needs parentheses and preserve no-parenthesis - if (node.parameters.length === 1 && node.pos === node.parameters[0].pos) { - emit(node.parameters[0]); - return; - } - emitSignatureParameters(node); - } - function emitAsyncFunctionBodyForES6(node) { - var promiseConstructor = ts.getEntityNameFromTypeNode(node.type); - var isArrowFunction = node.kind === 172 /* ArrowFunction */; - var hasLexicalArguments = (resolver.getNodeCheckFlags(node) & 4096 /* CaptureArguments */) !== 0; - var args; - // 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. - // - // The emit for an async arrow without a lexical `arguments` binding might be: - // - // // input - // let a = async (b) => { await b; } - // - // // output - // let a = (b) => __awaiter(this, void 0, void 0, function* () { - // yield b; - // }); - // - // The emit for an async arrow with a lexical `arguments` binding might be: - // - // // input - // let a = async (b) => { await arguments[0]; } - // - // // output - // let a = (b) => __awaiter(this, arguments, void 0, function* (arguments) { - // yield arguments[0]; - // }); - // - // The emit for an async function expression without a lexical `arguments` binding - // might be: - // - // // input - // let a = async function (b) { - // await b; - // } - // - // // output - // let a = function (b) { - // return __awaiter(this, void 0, void 0, function* () { - // yield b; - // }); - // } - // - // The emit for an async function expression with a lexical `arguments` binding - // might be: - // - // // input - // let a = async function (b) { - // await arguments[0]; - // } - // - // // output - // let a = function (b) { - // return __awaiter(this, arguments, void 0, function* (_arguments) { - // yield _arguments[0]; - // }); - // } - // - // The emit for an async function expression with a lexical `arguments` binding - // and a return type annotation might be: - // - // // input - // let a = async function (b): MyPromise { - // await arguments[0]; - // } - // - // // output - // let a = function (b) { - // return __awaiter(this, arguments, MyPromise, function* (_arguments) { - // yield _arguments[0]; - // }); - // } - // - // If this is not an async arrow, emit the opening brace of the function body - // and the start of the return statement. - if (!isArrowFunction) { - write(" {"); - increaseIndent(); - writeLine(); - write("return"); - } - write(" __awaiter(this"); - if (hasLexicalArguments) { - write(", arguments"); - } - else { - write(", void 0"); - } - if (promiseConstructor) { - write(", "); - emitNodeWithoutSourceMap(promiseConstructor); - } - else { - write(", Promise"); - } - // Emit the call to __awaiter. - if (hasLexicalArguments) { - write(", function* (_arguments)"); - } - else { - write(", function* ()"); - } - // Emit the signature and body for the inner generator function. - emitFunctionBody(node); - write(")"); - // If this is not an async arrow, emit the closing brace of the outer function body. - if (!isArrowFunction) { - write(";"); - decreaseIndent(); - writeLine(); - write("}"); - } - } - function emitFunctionBody(node) { - if (!node.body) { - // There can be no body when there are parse errors. Just emit an empty block - // in that case. - write(" { }"); - } - else { - if (node.body.kind === 190 /* Block */) { - emitBlockFunctionBody(node, node.body); - } - else { - emitExpressionFunctionBody(node, node.body); - } - } - } - function emitSignatureAndBody(node) { - var saveTempFlags = tempFlags; - var saveTempVariables = tempVariables; - var saveTempParameters = tempParameters; - tempFlags = 0; - tempVariables = undefined; - tempParameters = undefined; - // When targeting ES6, emit arrow function natively in ES6 - if (shouldEmitAsArrowFunction(node)) { - emitSignatureParametersForArrow(node); - write(" =>"); - } - else { - emitSignatureParameters(node); - } - var isAsync = ts.isAsyncFunctionLike(node); - if (isAsync && languageVersion === 2 /* ES6 */) { - emitAsyncFunctionBodyForES6(node); - } - else { - emitFunctionBody(node); - } - if (!isES6ExportedDeclaration(node)) { - emitExportMemberAssignment(node); - } - tempFlags = saveTempFlags; - tempVariables = saveTempVariables; - tempParameters = saveTempParameters; - } - // Returns true if any preamble code was emitted. - function emitFunctionBodyPreamble(node) { - emitCaptureThisForNodeIfNecessary(node); - emitDefaultValueAssignments(node); - emitRestParameter(node); - } - function emitExpressionFunctionBody(node, body) { - if (languageVersion < 2 /* ES6 */ || node.flags & 512 /* Async */) { - emitDownLevelExpressionFunctionBody(node, body); - return; - } - // For es6 and higher we can emit the expression as is. However, in the case - // where the expression might end up looking like a block when emitted, we'll - // also wrap it in parentheses first. For example if you have: a => {} - // then we need to generate: a => ({}) - write(" "); - // Unwrap all type assertions. - var current = body; - while (current.kind === 169 /* TypeAssertionExpression */) { - current = current.expression; - } - emitParenthesizedIf(body, current.kind === 163 /* ObjectLiteralExpression */); - } - function emitDownLevelExpressionFunctionBody(node, body) { - write(" {"); - scopeEmitStart(node); - increaseIndent(); - var outPos = writer.getTextPos(); - emitDetachedComments(node.body); - emitFunctionBodyPreamble(node); - var preambleEmitted = writer.getTextPos() !== outPos; - decreaseIndent(); - // If we didn't have to emit any preamble code, then attempt to keep the arrow - // function on one line. - if (!preambleEmitted && nodeStartPositionsAreOnSameLine(node, body)) { - write(" "); - emitStart(body); - write("return "); - emit(body); - emitEnd(body); - write(";"); - emitTempDeclarations(/*newLine*/ false); - write(" "); - } - else { - increaseIndent(); - writeLine(); - emitLeadingComments(node.body); - write("return "); - emit(body); - write(";"); - emitTrailingComments(node.body); - emitTempDeclarations(/*newLine*/ true); - decreaseIndent(); - writeLine(); - } - emitStart(node.body); - write("}"); - emitEnd(node.body); - scopeEmitEnd(); - } - function emitBlockFunctionBody(node, body) { - write(" {"); - scopeEmitStart(node); - var initialTextPos = writer.getTextPos(); - increaseIndent(); - emitDetachedComments(body.statements); - // Emit all the directive prologues (like "use strict"). These have to come before - // any other preamble code we write (like parameter initializers). - var startIndex = emitDirectivePrologues(body.statements, /*startWithNewLine*/ true); - emitFunctionBodyPreamble(node); - decreaseIndent(); - var preambleEmitted = writer.getTextPos() !== initialTextPos; - if (!preambleEmitted && nodeEndIsOnSameLineAsNodeStart(body, body)) { - for (var _a = 0, _b = body.statements; _a < _b.length; _a++) { - var statement = _b[_a]; - write(" "); - emit(statement); - } - emitTempDeclarations(/*newLine*/ false); - write(" "); - emitLeadingCommentsOfPosition(body.statements.end); - } - else { - increaseIndent(); - emitLinesStartingAt(body.statements, startIndex); - emitTempDeclarations(/*newLine*/ true); - writeLine(); - emitLeadingCommentsOfPosition(body.statements.end); - decreaseIndent(); - } - emitToken(16 /* CloseBraceToken */, body.statements.end); - scopeEmitEnd(); - } - function findInitialSuperCall(ctor) { - if (ctor.body) { - var statement = ctor.body.statements[0]; - if (statement && statement.kind === 193 /* ExpressionStatement */) { - var expr = statement.expression; - if (expr && expr.kind === 166 /* CallExpression */) { - var func = expr.expression; - if (func && func.kind === 93 /* SuperKeyword */) { - return statement; - } - } - } - } - } - function emitParameterPropertyAssignments(node) { - ts.forEach(node.parameters, function (param) { - if (param.flags & 112 /* AccessibilityModifier */) { - writeLine(); - emitStart(param); - emitStart(param.name); - write("this."); - emitNodeWithoutSourceMap(param.name); - emitEnd(param.name); - write(" = "); - emit(param.name); - write(";"); - emitEnd(param); - } - }); - } - function emitMemberAccessForPropertyName(memberName) { - // This does not emit source map because it is emitted by caller as caller - // is aware how the property name changes to the property access - // eg. public x = 10; becomes this.x and static x = 10 becomes className.x - if (memberName.kind === 9 /* StringLiteral */ || memberName.kind === 8 /* NumericLiteral */) { - write("["); - emitNodeWithCommentsAndWithoutSourcemap(memberName); - write("]"); - } - else if (memberName.kind === 134 /* ComputedPropertyName */) { - emitComputedPropertyName(memberName); - } - else { - write("."); - emitNodeWithCommentsAndWithoutSourcemap(memberName); - } - } - function getInitializedProperties(node, isStatic) { - var properties = []; - for (var _a = 0, _b = node.members; _a < _b.length; _a++) { - var member = _b[_a]; - if (member.kind === 139 /* PropertyDeclaration */ && isStatic === ((member.flags & 128 /* Static */) !== 0) && member.initializer) { - properties.push(member); - } - } - return properties; - } - function emitPropertyDeclarations(node, properties) { - for (var _a = 0; _a < properties.length; _a++) { - var property = properties[_a]; - emitPropertyDeclaration(node, property); - } - } - function emitPropertyDeclaration(node, property, receiver, isExpression) { - writeLine(); - emitLeadingComments(property); - emitStart(property); - emitStart(property.name); - if (receiver) { - emit(receiver); - } - else { - if (property.flags & 128 /* Static */) { - emitDeclarationName(node); - } - else { - write("this"); - } - } - emitMemberAccessForPropertyName(property.name); - emitEnd(property.name); - write(" = "); - emit(property.initializer); - if (!isExpression) { - write(";"); - } - emitEnd(property); - emitTrailingComments(property); - } - function emitMemberFunctionsForES5AndLower(node) { - ts.forEach(node.members, function (member) { - if (member.kind === 189 /* SemicolonClassElement */) { - writeLine(); - write(";"); - } - else if (member.kind === 141 /* MethodDeclaration */ || node.kind === 140 /* MethodSignature */) { - if (!member.body) { - return emitCommentsOnNotEmittedNode(member); - } - writeLine(); - emitLeadingComments(member); - emitStart(member); - emitStart(member.name); - emitClassMemberPrefix(node, member); - emitMemberAccessForPropertyName(member.name); - emitEnd(member.name); - write(" = "); - emitFunctionDeclaration(member); - emitEnd(member); - write(";"); - emitTrailingComments(member); - } - else if (member.kind === 143 /* GetAccessor */ || member.kind === 144 /* SetAccessor */) { - var accessors = ts.getAllAccessorDeclarations(node.members, member); - if (member === accessors.firstAccessor) { - writeLine(); - emitStart(member); - write("Object.defineProperty("); - emitStart(member.name); - emitClassMemberPrefix(node, member); - write(", "); - emitExpressionForPropertyName(member.name); - emitEnd(member.name); - write(", {"); - increaseIndent(); - if (accessors.getAccessor) { - writeLine(); - emitLeadingComments(accessors.getAccessor); - write("get: "); - emitStart(accessors.getAccessor); - write("function "); - emitSignatureAndBody(accessors.getAccessor); - emitEnd(accessors.getAccessor); - emitTrailingComments(accessors.getAccessor); - write(","); - } - if (accessors.setAccessor) { - writeLine(); - emitLeadingComments(accessors.setAccessor); - write("set: "); - emitStart(accessors.setAccessor); - write("function "); - emitSignatureAndBody(accessors.setAccessor); - emitEnd(accessors.setAccessor); - emitTrailingComments(accessors.setAccessor); - write(","); - } - writeLine(); - write("enumerable: true,"); - writeLine(); - write("configurable: true"); - decreaseIndent(); - writeLine(); - write("});"); - emitEnd(member); - } - } - }); - } - function emitMemberFunctionsForES6AndHigher(node) { - for (var _a = 0, _b = node.members; _a < _b.length; _a++) { - var member = _b[_a]; - if ((member.kind === 141 /* MethodDeclaration */ || node.kind === 140 /* MethodSignature */) && !member.body) { - emitCommentsOnNotEmittedNode(member); - } - else if (member.kind === 141 /* MethodDeclaration */ || - member.kind === 143 /* GetAccessor */ || - member.kind === 144 /* SetAccessor */) { - writeLine(); - emitLeadingComments(member); - emitStart(member); - if (member.flags & 128 /* Static */) { - write("static "); - } - if (member.kind === 143 /* GetAccessor */) { - write("get "); - } - else if (member.kind === 144 /* SetAccessor */) { - write("set "); - } - if (member.asteriskToken) { - write("*"); - } - emit(member.name); - emitSignatureAndBody(member); - emitEnd(member); - emitTrailingComments(member); - } - else if (member.kind === 189 /* SemicolonClassElement */) { - writeLine(); - write(";"); - } - } - } - function emitConstructor(node, baseTypeElement) { - var saveTempFlags = tempFlags; - var saveTempVariables = tempVariables; - var saveTempParameters = tempParameters; - tempFlags = 0; - tempVariables = undefined; - tempParameters = undefined; - emitConstructorWorker(node, baseTypeElement); - tempFlags = saveTempFlags; - tempVariables = saveTempVariables; - tempParameters = saveTempParameters; - } - function emitConstructorWorker(node, baseTypeElement) { - // Check if we have property assignment inside class declaration. - // If there is property assignment, we need to emit constructor whether users define it or not - // If there is no property assignment, we can omit constructor if users do not define it - var hasInstancePropertyWithInitializer = false; - // Emit the constructor overload pinned comments - ts.forEach(node.members, function (member) { - if (member.kind === 142 /* Constructor */ && !member.body) { - emitCommentsOnNotEmittedNode(member); - } - // Check if there is any non-static property assignment - if (member.kind === 139 /* PropertyDeclaration */ && member.initializer && (member.flags & 128 /* Static */) === 0) { - hasInstancePropertyWithInitializer = true; - } - }); - var ctor = ts.getFirstConstructorWithBody(node); - // For target ES6 and above, if there is no user-defined constructor and there is no property assignment - // do not emit constructor in class declaration. - if (languageVersion >= 2 /* ES6 */ && !ctor && !hasInstancePropertyWithInitializer) { - return; - } - if (ctor) { - emitLeadingComments(ctor); - } - emitStart(ctor || node); - if (languageVersion < 2 /* ES6 */) { - write("function "); - emitDeclarationName(node); - emitSignatureParameters(ctor); - } - else { - write("constructor"); - if (ctor) { - emitSignatureParameters(ctor); - } - else { - // Based on EcmaScript6 section 14.5.14: Runtime Semantics: ClassDefinitionEvaluation. - // If constructor is empty, then, - // If ClassHeritageopt is present, then - // Let constructor be the result of parsing the String "constructor(... args){ super (...args);}" using the syntactic grammar with the goal symbol MethodDefinition. - // Else, - // Let constructor be the result of parsing the String "constructor( ){ }" using the syntactic grammar with the goal symbol MethodDefinition - if (baseTypeElement) { - write("(...args)"); - } - else { - write("()"); - } - } - } - var startIndex = 0; - write(" {"); - scopeEmitStart(node, "constructor"); - increaseIndent(); - if (ctor) { - // Emit all the directive prologues (like "use strict"). These have to come before - // any other preamble code we write (like parameter initializers). - startIndex = emitDirectivePrologues(ctor.body.statements, /*startWithNewLine*/ true); - emitDetachedComments(ctor.body.statements); - } - emitCaptureThisForNodeIfNecessary(node); - var superCall; - if (ctor) { - emitDefaultValueAssignments(ctor); - emitRestParameter(ctor); - if (baseTypeElement) { - superCall = findInitialSuperCall(ctor); - if (superCall) { - writeLine(); - emit(superCall); - } - } - emitParameterPropertyAssignments(ctor); - } - else { - if (baseTypeElement) { - writeLine(); - emitStart(baseTypeElement); - if (languageVersion < 2 /* ES6 */) { - write("_super.apply(this, arguments);"); - } - else { - write("super(...args);"); - } - emitEnd(baseTypeElement); - } - } - emitPropertyDeclarations(node, getInitializedProperties(node, /*static:*/ false)); - if (ctor) { - var statements = ctor.body.statements; - if (superCall) { - statements = statements.slice(1); - } - emitLinesStartingAt(statements, startIndex); - } - emitTempDeclarations(/*newLine*/ true); - writeLine(); - if (ctor) { - emitLeadingCommentsOfPosition(ctor.body.statements.end); - } - decreaseIndent(); - emitToken(16 /* CloseBraceToken */, ctor ? ctor.body.statements.end : node.members.end); - scopeEmitEnd(); - emitEnd(ctor || node); - if (ctor) { - emitTrailingComments(ctor); - } - } - function emitClassExpression(node) { - return emitClassLikeDeclaration(node); - } - function emitClassDeclaration(node) { - return emitClassLikeDeclaration(node); - } - function emitClassLikeDeclaration(node) { - if (languageVersion < 2 /* ES6 */) { - emitClassLikeDeclarationBelowES6(node); - } - else { - emitClassLikeDeclarationForES6AndHigher(node); - } - } - function emitClassLikeDeclarationForES6AndHigher(node) { - var thisNodeIsDecorated = ts.nodeIsDecorated(node); - if (node.kind === 212 /* ClassDeclaration */) { - if (thisNodeIsDecorated) { - // To preserve the correct runtime semantics when decorators are applied to the class, - // the emit needs to follow one of the following rules: - // - // * For a local class declaration: - // - // @dec class C { - // } - // - // The emit should be: - // - // let C = class { - // }; - // Object.defineProperty(C, "name", { value: "C", configurable: true }); - // C = __decorate([dec], C); - // - // * For an exported class declaration: - // - // @dec export class C { - // } - // - // The emit should be: - // - // export let C = class { - // }; - // Object.defineProperty(C, "name", { value: "C", configurable: true }); - // C = __decorate([dec], C); - // - // * For a default export of a class declaration with a name: - // - // @dec default export class C { - // } - // - // The emit should be: - // - // let C = class { - // } - // Object.defineProperty(C, "name", { value: "C", configurable: true }); - // C = __decorate([dec], C); - // export default C; - // - // * For a default export of a class declaration without a name: - // - // @dec default export class { - // } - // - // The emit should be: - // - // let _default = class { - // } - // _default = __decorate([dec], _default); - // export default _default; - // - if (isES6ExportedDeclaration(node) && !(node.flags & 1024 /* Default */)) { - write("export "); - } - write("let "); - emitDeclarationName(node); - write(" = "); - } - else if (isES6ExportedDeclaration(node)) { - write("export "); - if (node.flags & 1024 /* Default */) { - write("default "); - } - } - } - // If the class has static properties, and it's a class expression, then we'll need - // to specialize the emit a bit. for a class expression of the form: - // - // class C { static a = 1; static b = 2; ... } - // - // We'll emit: - // - // (_temp = class C { ... }, _temp.a = 1, _temp.b = 2, _temp) - // - // This keeps the expression as an expression, while ensuring that the static parts - // of it have been initialized by the time it is used. - var staticProperties = getInitializedProperties(node, /*static:*/ true); - var isClassExpressionWithStaticProperties = staticProperties.length > 0 && node.kind === 184 /* ClassExpression */; - var tempVariable; - if (isClassExpressionWithStaticProperties) { - tempVariable = createAndRecordTempVariable(0 /* Auto */); - write("("); - increaseIndent(); - emit(tempVariable); - write(" = "); - } - write("class"); - // check if this is an "export default class" as it may not have a name. Do not emit the name if the class is decorated. - if ((node.name || !(node.flags & 1024 /* Default */)) && !thisNodeIsDecorated) { - write(" "); - emitDeclarationName(node); - } - var baseTypeNode = ts.getClassExtendsHeritageClauseElement(node); - if (baseTypeNode) { - write(" extends "); - emit(baseTypeNode.expression); - } - write(" {"); - increaseIndent(); - scopeEmitStart(node); - writeLine(); - emitConstructor(node, baseTypeNode); - emitMemberFunctionsForES6AndHigher(node); - decreaseIndent(); - writeLine(); - emitToken(16 /* CloseBraceToken */, node.members.end); - scopeEmitEnd(); - // TODO(rbuckton): Need to go back to `let _a = class C {}` approach, removing the defineProperty call for now. - // For a decorated class, we need to assign its name (if it has one). This is because we emit - // the class as a class expression to avoid the double-binding of the identifier: - // - // let C = class { - // } - // Object.defineProperty(C, "name", { value: "C", configurable: true }); - // - if (thisNodeIsDecorated) { - write(";"); - } - // Emit static property assignment. Because classDeclaration is lexically evaluated, - // it is safe to emit static property assignment after classDeclaration - // From ES6 specification: - // 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 (isClassExpressionWithStaticProperties) { - for (var _a = 0; _a < staticProperties.length; _a++) { - var property = staticProperties[_a]; - write(","); - writeLine(); - emitPropertyDeclaration(node, property, /*receiver:*/ tempVariable, /*isExpression:*/ true); - } - write(","); - writeLine(); - emit(tempVariable); - decreaseIndent(); - write(")"); - } - else { - writeLine(); - emitPropertyDeclarations(node, staticProperties); - emitDecoratorsOfClass(node); - } - // If this is an exported class, but not on the top level (i.e. on an internal - // module), export it - if (!isES6ExportedDeclaration(node) && (node.flags & 1 /* Export */)) { - writeLine(); - emitStart(node); - emitModuleMemberName(node); - write(" = "); - emitDeclarationName(node); - emitEnd(node); - write(";"); - } - else if (isES6ExportedDeclaration(node) && (node.flags & 1024 /* Default */) && thisNodeIsDecorated) { - // if this is a top level default export of decorated class, write the export after the declaration. - writeLine(); - write("export default "); - emitDeclarationName(node); - write(";"); - } - } - function emitClassLikeDeclarationBelowES6(node) { - if (node.kind === 212 /* ClassDeclaration */) { - // source file level classes in system modules are hoisted so 'var's for them are already defined - if (!shouldHoistDeclarationInSystemJsModule(node)) { - write("var "); - } - emitDeclarationName(node); - write(" = "); - } - write("(function ("); - var baseTypeNode = ts.getClassExtendsHeritageClauseElement(node); - if (baseTypeNode) { - write("_super"); - } - write(") {"); - var saveTempFlags = tempFlags; - var saveTempVariables = tempVariables; - var saveTempParameters = tempParameters; - var saveComputedPropertyNamesToGeneratedNames = computedPropertyNamesToGeneratedNames; - tempFlags = 0; - tempVariables = undefined; - tempParameters = undefined; - computedPropertyNamesToGeneratedNames = undefined; - increaseIndent(); - scopeEmitStart(node); - if (baseTypeNode) { - writeLine(); - emitStart(baseTypeNode); - write("__extends("); - emitDeclarationName(node); - write(", _super);"); - emitEnd(baseTypeNode); - } - writeLine(); - emitConstructor(node, baseTypeNode); - emitMemberFunctionsForES5AndLower(node); - emitPropertyDeclarations(node, getInitializedProperties(node, /*static:*/ true)); - writeLine(); - emitDecoratorsOfClass(node); - writeLine(); - emitToken(16 /* CloseBraceToken */, node.members.end, function () { - write("return "); - emitDeclarationName(node); - }); - write(";"); - emitTempDeclarations(/*newLine*/ true); - tempFlags = saveTempFlags; - tempVariables = saveTempVariables; - tempParameters = saveTempParameters; - computedPropertyNamesToGeneratedNames = saveComputedPropertyNamesToGeneratedNames; - decreaseIndent(); - writeLine(); - emitToken(16 /* CloseBraceToken */, node.members.end); - scopeEmitEnd(); - emitStart(node); - write(")("); - if (baseTypeNode) { - emit(baseTypeNode.expression); - } - write(")"); - if (node.kind === 212 /* ClassDeclaration */) { - write(";"); - } - emitEnd(node); - if (node.kind === 212 /* ClassDeclaration */) { - emitExportMemberAssignment(node); - } - if (languageVersion < 2 /* ES6 */ && node.parent === currentSourceFile && node.name) { - emitExportMemberAssignments(node.name); - } - } - function emitClassMemberPrefix(node, member) { - emitDeclarationName(node); - if (!(member.flags & 128 /* Static */)) { - write(".prototype"); - } - } - function emitDecoratorsOfClass(node) { - emitDecoratorsOfMembers(node, /*staticFlag*/ 0); - emitDecoratorsOfMembers(node, 128 /* Static */); - emitDecoratorsOfConstructor(node); - } - function emitDecoratorsOfConstructor(node) { - var decorators = node.decorators; - var constructor = ts.getFirstConstructorWithBody(node); - var hasDecoratedParameters = constructor && ts.forEach(constructor.parameters, ts.nodeIsDecorated); - // skip decoration of the constructor if neither it nor its parameters are decorated - if (!decorators && !hasDecoratedParameters) { - return; - } - // Emit the call to __decorate. Given the class: - // - // @dec - // class C { - // } - // - // The emit for the class is: - // - // C = __decorate([dec], C); - // - writeLine(); - emitStart(node); - emitDeclarationName(node); - write(" = __decorate(["); - increaseIndent(); - writeLine(); - var decoratorCount = decorators ? decorators.length : 0; - var argumentsWritten = emitList(decorators, 0, decoratorCount, /*multiLine*/ true, /*trailingComma*/ false, /*leadingComma*/ false, /*noTrailingNewLine*/ true, function (decorator) { - emitStart(decorator); - emit(decorator.expression); - emitEnd(decorator); - }); - argumentsWritten += emitDecoratorsOfParameters(constructor, /*leadingComma*/ argumentsWritten > 0); - emitSerializedTypeMetadata(node, /*leadingComma*/ argumentsWritten >= 0); - decreaseIndent(); - writeLine(); - write("], "); - emitDeclarationName(node); - write(");"); - emitEnd(node); - writeLine(); - } - function emitDecoratorsOfMembers(node, staticFlag) { - for (var _a = 0, _b = node.members; _a < _b.length; _a++) { - var member = _b[_a]; - // only emit members in the correct group - if ((member.flags & 128 /* Static */) !== staticFlag) { - continue; - } - // skip members that cannot be decorated (such as the constructor) - if (!ts.nodeCanBeDecorated(member)) { - continue; - } - // skip a member if it or any of its parameters are not decorated - if (!ts.nodeOrChildIsDecorated(member)) { - continue; - } - // skip an accessor declaration if it is not the first accessor - var decorators = void 0; - var functionLikeMember = void 0; - if (ts.isAccessor(member)) { - var accessors = ts.getAllAccessorDeclarations(node.members, member); - if (member !== accessors.firstAccessor) { - continue; - } - // get the decorators from the first accessor with decorators - decorators = accessors.firstAccessor.decorators; - if (!decorators && accessors.secondAccessor) { - decorators = accessors.secondAccessor.decorators; - } - // we only decorate parameters of the set accessor - functionLikeMember = accessors.setAccessor; - } - else { - decorators = member.decorators; - // we only decorate the parameters here if this is a method - if (member.kind === 141 /* MethodDeclaration */) { - functionLikeMember = member; - } - } - // Emit the call to __decorate. Given the following: - // - // class C { - // @dec method(@dec2 x) {} - // @dec get accessor() {} - // @dec prop; - // } - // - // The emit for a method is: - // - // Object.defineProperty(C.prototype, "method", - // __decorate([ - // dec, - // __param(0, dec2), - // __metadata("design:type", Function), - // __metadata("design:paramtypes", [Object]), - // __metadata("design:returntype", void 0) - // ], C.prototype, "method", Object.getOwnPropertyDescriptor(C.prototype, "method"))); - // - // The emit for an accessor is: - // - // Object.defineProperty(C.prototype, "accessor", - // __decorate([ - // dec - // ], C.prototype, "accessor", Object.getOwnPropertyDescriptor(C.prototype, "accessor"))); - // - // The emit for a property is: - // - // __decorate([ - // dec - // ], C.prototype, "prop"); - // - writeLine(); - emitStart(member); - if (member.kind !== 139 /* PropertyDeclaration */) { - write("Object.defineProperty("); - emitStart(member.name); - emitClassMemberPrefix(node, member); - write(", "); - emitExpressionForPropertyName(member.name); - emitEnd(member.name); - write(","); - increaseIndent(); - writeLine(); - } - write("__decorate(["); - increaseIndent(); - writeLine(); - var decoratorCount = decorators ? decorators.length : 0; - var argumentsWritten = emitList(decorators, 0, decoratorCount, /*multiLine*/ true, /*trailingComma*/ false, /*leadingComma*/ false, /*noTrailingNewLine*/ true, function (decorator) { - emitStart(decorator); - emit(decorator.expression); - emitEnd(decorator); - }); - argumentsWritten += emitDecoratorsOfParameters(functionLikeMember, argumentsWritten > 0); - emitSerializedTypeMetadata(member, argumentsWritten > 0); - decreaseIndent(); - writeLine(); - write("], "); - emitStart(member.name); - emitClassMemberPrefix(node, member); - write(", "); - emitExpressionForPropertyName(member.name); - emitEnd(member.name); - if (member.kind !== 139 /* PropertyDeclaration */) { - write(", Object.getOwnPropertyDescriptor("); - emitStart(member.name); - emitClassMemberPrefix(node, member); - write(", "); - emitExpressionForPropertyName(member.name); - emitEnd(member.name); - write("))"); - decreaseIndent(); - } - write(");"); - emitEnd(member); - writeLine(); - } - } - function emitDecoratorsOfParameters(node, leadingComma) { - var argumentsWritten = 0; - if (node) { - var parameterIndex = 0; - for (var _a = 0, _b = node.parameters; _a < _b.length; _a++) { - var parameter = _b[_a]; - if (ts.nodeIsDecorated(parameter)) { - var decorators = parameter.decorators; - argumentsWritten += emitList(decorators, 0, decorators.length, /*multiLine*/ true, /*trailingComma*/ false, /*leadingComma*/ leadingComma, /*noTrailingNewLine*/ true, function (decorator) { - emitStart(decorator); - write("__param(" + parameterIndex + ", "); - emit(decorator.expression); - write(")"); - emitEnd(decorator); - }); - leadingComma = true; - } - ++parameterIndex; - } - } - return argumentsWritten; - } - function shouldEmitTypeMetadata(node) { - // This method determines whether to emit the "design:type" metadata based on the node's kind. - // The caller should have already tested whether the node has decorators and whether the emitDecoratorMetadata - // compiler option is set. - switch (node.kind) { - case 141 /* MethodDeclaration */: - case 143 /* GetAccessor */: - case 144 /* SetAccessor */: - case 139 /* PropertyDeclaration */: - return true; - } - return false; - } - function shouldEmitReturnTypeMetadata(node) { - // This method determines whether to emit the "design:returntype" metadata based on the node's kind. - // The caller should have already tested whether the node has decorators and whether the emitDecoratorMetadata - // compiler option is set. - switch (node.kind) { - case 141 /* MethodDeclaration */: - return true; - } - return false; - } - function shouldEmitParamTypesMetadata(node) { - // This method determines whether to emit the "design:paramtypes" metadata based on the node's kind. - // The caller should have already tested whether the node has decorators and whether the emitDecoratorMetadata - // compiler option is set. - switch (node.kind) { - case 212 /* ClassDeclaration */: - case 141 /* MethodDeclaration */: - case 144 /* SetAccessor */: - return true; - } - return false; - } - /** Serializes the type of a declaration to an appropriate JS constructor value. Used by the __metadata decorator for a class member. */ - function emitSerializedTypeOfNode(node) { - // serialization of the type of a declaration uses the following rules: - // - // * The serialized type of a ClassDeclaration is "Function" - // * The serialized type of a ParameterDeclaration is the serialized type of its type annotation. - // * The serialized type of a PropertyDeclaration is the serialized type of its type annotation. - // * The serialized type of an AccessorDeclaration is the serialized type of the return type annotation of its getter or parameter type annotation of its setter. - // * The serialized type of any other FunctionLikeDeclaration is "Function". - // * The serialized type of any other node is "void 0". - // - // For rules on serializing type annotations, see `serializeTypeNode`. - switch (node.kind) { - case 212 /* ClassDeclaration */: - write("Function"); - return; - case 139 /* PropertyDeclaration */: - emitSerializedTypeNode(node.type); - return; - case 136 /* Parameter */: - emitSerializedTypeNode(node.type); - return; - case 143 /* GetAccessor */: - emitSerializedTypeNode(node.type); - return; - case 144 /* SetAccessor */: - emitSerializedTypeNode(ts.getSetAccessorTypeAnnotationNode(node)); - return; - } - if (ts.isFunctionLike(node)) { - write("Function"); - return; - } - write("void 0"); - } - function emitSerializedTypeNode(node) { - if (node) { - switch (node.kind) { - case 101 /* VoidKeyword */: - write("void 0"); - return; - case 158 /* ParenthesizedType */: - emitSerializedTypeNode(node.type); - return; - case 150 /* FunctionType */: - case 151 /* ConstructorType */: - write("Function"); - return; - case 154 /* ArrayType */: - case 155 /* TupleType */: - write("Array"); - return; - case 148 /* TypePredicate */: - case 118 /* BooleanKeyword */: - write("Boolean"); - return; - case 128 /* StringKeyword */: - case 9 /* StringLiteral */: - write("String"); - return; - case 126 /* NumberKeyword */: - write("Number"); - return; - case 129 /* SymbolKeyword */: - write("Symbol"); - return; - case 149 /* TypeReference */: - emitSerializedTypeReferenceNode(node); - return; - case 152 /* TypeQuery */: - case 153 /* TypeLiteral */: - case 156 /* UnionType */: - case 157 /* IntersectionType */: - case 115 /* AnyKeyword */: - break; - default: - ts.Debug.fail("Cannot serialize unexpected type node."); - break; - } - } - write("Object"); - } - /** Serializes a TypeReferenceNode to an appropriate JS constructor value. Used by the __metadata decorator. */ - function emitSerializedTypeReferenceNode(node) { - var location = node.parent; - while (ts.isDeclaration(location) || ts.isTypeNode(location)) { - location = location.parent; - } - // Clone the type name and parent it to a location outside of the current declaration. - var typeName = ts.cloneEntityName(node.typeName); - typeName.parent = location; - var result = resolver.getTypeReferenceSerializationKind(typeName); - switch (result) { - case ts.TypeReferenceSerializationKind.Unknown: - var temp = createAndRecordTempVariable(0 /* Auto */); - write("(typeof ("); - emitNodeWithoutSourceMap(temp); - write(" = "); - emitEntityNameAsExpression(typeName, /*useFallback*/ true); - write(") === 'function' && "); - emitNodeWithoutSourceMap(temp); - write(") || Object"); - break; - case ts.TypeReferenceSerializationKind.TypeWithConstructSignatureAndValue: - emitEntityNameAsExpression(typeName, /*useFallback*/ false); - break; - case ts.TypeReferenceSerializationKind.VoidType: - write("void 0"); - break; - case ts.TypeReferenceSerializationKind.BooleanType: - write("Boolean"); - break; - case ts.TypeReferenceSerializationKind.NumberLikeType: - write("Number"); - break; - case ts.TypeReferenceSerializationKind.StringLikeType: - write("String"); - break; - case ts.TypeReferenceSerializationKind.ArrayLikeType: - write("Array"); - break; - case ts.TypeReferenceSerializationKind.ESSymbolType: - if (languageVersion < 2 /* ES6 */) { - write("typeof Symbol === 'function' ? Symbol : Object"); - } - else { - write("Symbol"); - } - break; - case ts.TypeReferenceSerializationKind.TypeWithCallSignature: - write("Function"); - break; - case ts.TypeReferenceSerializationKind.ObjectType: - write("Object"); - break; - } - } - /** Serializes the parameter types of a function or the constructor of a class. Used by the __metadata decorator for a method or set accessor. */ - function emitSerializedParameterTypesOfNode(node) { - // serialization of parameter types uses the following rules: - // - // * If the declaration is a class, the parameters of the first constructor with a body are used. - // * If the declaration is function-like and has a body, the parameters of the function are used. - // - // For the rules on serializing the type of each parameter declaration, see `serializeTypeOfDeclaration`. - if (node) { - var valueDeclaration; - if (node.kind === 212 /* ClassDeclaration */) { - valueDeclaration = ts.getFirstConstructorWithBody(node); - } - else if (ts.isFunctionLike(node) && ts.nodeIsPresent(node.body)) { - valueDeclaration = node; - } - if (valueDeclaration) { - var parameters = valueDeclaration.parameters; - var parameterCount = parameters.length; - if (parameterCount > 0) { - for (var i = 0; i < parameterCount; i++) { - if (i > 0) { - write(", "); - } - if (parameters[i].dotDotDotToken) { - var parameterType = parameters[i].type; - if (parameterType.kind === 154 /* ArrayType */) { - parameterType = parameterType.elementType; - } - else if (parameterType.kind === 149 /* TypeReference */ && parameterType.typeArguments && parameterType.typeArguments.length === 1) { - parameterType = parameterType.typeArguments[0]; - } - else { - parameterType = undefined; - } - emitSerializedTypeNode(parameterType); - } - else { - emitSerializedTypeOfNode(parameters[i]); - } - } - } - } - } - } - /** Serializes the return type of function. Used by the __metadata decorator for a method. */ - function emitSerializedReturnTypeOfNode(node) { - if (node && ts.isFunctionLike(node) && node.type) { - emitSerializedTypeNode(node.type); - return; - } - write("void 0"); - } - function emitSerializedTypeMetadata(node, writeComma) { - // This method emits the serialized type metadata for a decorator target. - // The caller should have already tested whether the node has decorators. - var argumentsWritten = 0; - if (compilerOptions.emitDecoratorMetadata) { - if (shouldEmitTypeMetadata(node)) { - if (writeComma) { - write(", "); - } - writeLine(); - write("__metadata('design:type', "); - emitSerializedTypeOfNode(node); - write(")"); - argumentsWritten++; - } - if (shouldEmitParamTypesMetadata(node)) { - if (writeComma || argumentsWritten) { - write(", "); - } - writeLine(); - write("__metadata('design:paramtypes', ["); - emitSerializedParameterTypesOfNode(node); - write("])"); - argumentsWritten++; - } - if (shouldEmitReturnTypeMetadata(node)) { - if (writeComma || argumentsWritten) { - write(", "); - } - writeLine(); - write("__metadata('design:returntype', "); - emitSerializedReturnTypeOfNode(node); - write(")"); - argumentsWritten++; - } - } - return argumentsWritten; - } - function emitInterfaceDeclaration(node) { - emitCommentsOnNotEmittedNode(node); - } - function shouldEmitEnumDeclaration(node) { - var isConstEnum = ts.isConst(node); - return !isConstEnum || compilerOptions.preserveConstEnums || compilerOptions.isolatedModules; - } - function emitEnumDeclaration(node) { - // const enums are completely erased during compilation. - if (!shouldEmitEnumDeclaration(node)) { - return; - } - if (!shouldHoistDeclarationInSystemJsModule(node)) { - // do not emit var if variable was already hoisted - if (!(node.flags & 1 /* Export */) || isES6ExportedDeclaration(node)) { - emitStart(node); - if (isES6ExportedDeclaration(node)) { - write("export "); - } - write("var "); - emit(node.name); - emitEnd(node); - write(";"); - } - } - writeLine(); - emitStart(node); - write("(function ("); - emitStart(node.name); - write(getGeneratedNameForNode(node)); - emitEnd(node.name); - write(") {"); - increaseIndent(); - scopeEmitStart(node); - emitLines(node.members); - decreaseIndent(); - writeLine(); - emitToken(16 /* CloseBraceToken */, node.members.end); - scopeEmitEnd(); - write(")("); - emitModuleMemberName(node); - write(" || ("); - emitModuleMemberName(node); - write(" = {}));"); - emitEnd(node); - if (!isES6ExportedDeclaration(node) && node.flags & 1 /* Export */ && !shouldHoistDeclarationInSystemJsModule(node)) { - // do not emit var if variable was already hoisted - writeLine(); - emitStart(node); - write("var "); - emit(node.name); - write(" = "); - emitModuleMemberName(node); - emitEnd(node); - write(";"); - } - if (languageVersion < 2 /* ES6 */ && node.parent === currentSourceFile) { - if (compilerOptions.module === 4 /* System */ && (node.flags & 1 /* Export */)) { - // write the call to exporter for enum - writeLine(); - write(exportFunctionForFile + "(\""); - emitDeclarationName(node); - write("\", "); - emitDeclarationName(node); - write(");"); - } - emitExportMemberAssignments(node.name); - } - } - function emitEnumMember(node) { - var enumParent = node.parent; - emitStart(node); - write(getGeneratedNameForNode(enumParent)); - write("["); - write(getGeneratedNameForNode(enumParent)); - write("["); - emitExpressionForPropertyName(node.name); - write("] = "); - writeEnumMemberDeclarationValue(node); - write("] = "); - emitExpressionForPropertyName(node.name); - emitEnd(node); - write(";"); - } - function writeEnumMemberDeclarationValue(member) { - var value = resolver.getConstantValue(member); - if (value !== undefined) { - write(value.toString()); - return; - } - else if (member.initializer) { - emit(member.initializer); - } - else { - write("undefined"); - } - } - function getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration) { - if (moduleDeclaration.body.kind === 216 /* ModuleDeclaration */) { - var recursiveInnerModule = getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration.body); - return recursiveInnerModule || moduleDeclaration.body; - } - } - function shouldEmitModuleDeclaration(node) { - return ts.isInstantiatedModule(node, compilerOptions.preserveConstEnums || compilerOptions.isolatedModules); - } - function isModuleMergedWithES6Class(node) { - return languageVersion === 2 /* ES6 */ && !!(resolver.getNodeCheckFlags(node) & 32768 /* LexicalModuleMergesWithClass */); - } - function emitModuleDeclaration(node) { - // Emit only if this module is non-ambient. - var shouldEmit = shouldEmitModuleDeclaration(node); - if (!shouldEmit) { - return emitCommentsOnNotEmittedNode(node); - } - var hoistedInDeclarationScope = shouldHoistDeclarationInSystemJsModule(node); - var emitVarForModule = !hoistedInDeclarationScope && !isModuleMergedWithES6Class(node); - if (emitVarForModule) { - emitStart(node); - if (isES6ExportedDeclaration(node)) { - write("export "); - } - write("var "); - emit(node.name); - write(";"); - emitEnd(node); - writeLine(); - } - emitStart(node); - write("(function ("); - emitStart(node.name); - write(getGeneratedNameForNode(node)); - emitEnd(node.name); - write(") "); - if (node.body.kind === 217 /* ModuleBlock */) { - var saveTempFlags = tempFlags; - var saveTempVariables = tempVariables; - tempFlags = 0; - tempVariables = undefined; - emit(node.body); - tempFlags = saveTempFlags; - tempVariables = saveTempVariables; - } - else { - write("{"); - increaseIndent(); - scopeEmitStart(node); - emitCaptureThisForNodeIfNecessary(node); - writeLine(); - emit(node.body); - decreaseIndent(); - writeLine(); - var moduleBlock = getInnerMostModuleDeclarationFromDottedModule(node).body; - emitToken(16 /* CloseBraceToken */, moduleBlock.statements.end); - scopeEmitEnd(); - } - write(")("); - // write moduleDecl = containingModule.m only if it is not exported es6 module member - if ((node.flags & 1 /* Export */) && !isES6ExportedDeclaration(node)) { - emit(node.name); - write(" = "); - } - emitModuleMemberName(node); - write(" || ("); - emitModuleMemberName(node); - write(" = {}));"); - emitEnd(node); - if (!isES6ExportedDeclaration(node) && node.name.kind === 67 /* Identifier */ && node.parent === currentSourceFile) { - if (compilerOptions.module === 4 /* System */ && (node.flags & 1 /* Export */)) { - writeLine(); - write(exportFunctionForFile + "(\""); - emitDeclarationName(node); - write("\", "); - emitDeclarationName(node); - write(");"); - } - emitExportMemberAssignments(node.name); - } - } - /* - * Some bundlers (SystemJS builder) sometimes want to rename dependencies. - * Here we check if alternative name was provided for a given moduleName and return it if possible. - */ - function tryRenameExternalModule(moduleName) { - if (currentSourceFile.renamedDependencies && ts.hasProperty(currentSourceFile.renamedDependencies, moduleName.text)) { - return "\"" + currentSourceFile.renamedDependencies[moduleName.text] + "\""; - } - return undefined; - } - function emitRequire(moduleName) { - if (moduleName.kind === 9 /* StringLiteral */) { - write("require("); - var text = tryRenameExternalModule(moduleName); - if (text) { - write(text); - } - else { - emitStart(moduleName); - emitLiteral(moduleName); - emitEnd(moduleName); - } - emitToken(18 /* CloseParenToken */, moduleName.end); - } - else { - write("require()"); - } - } - function getNamespaceDeclarationNode(node) { - if (node.kind === 219 /* ImportEqualsDeclaration */) { - return node; - } - var importClause = node.importClause; - if (importClause && importClause.namedBindings && importClause.namedBindings.kind === 222 /* NamespaceImport */) { - return importClause.namedBindings; - } - } - function isDefaultImport(node) { - return node.kind === 220 /* ImportDeclaration */ && node.importClause && !!node.importClause.name; - } - function emitExportImportAssignments(node) { - if (ts.isAliasSymbolDeclaration(node) && resolver.isValueAliasDeclaration(node)) { - emitExportMemberAssignments(node.name); - } - ts.forEachChild(node, emitExportImportAssignments); - } - function emitImportDeclaration(node) { - if (languageVersion < 2 /* ES6 */) { - return emitExternalImportDeclaration(node); - } - // ES6 import - if (node.importClause) { - var shouldEmitDefaultBindings = resolver.isReferencedAliasDeclaration(node.importClause); - var shouldEmitNamedBindings = node.importClause.namedBindings && resolver.isReferencedAliasDeclaration(node.importClause.namedBindings, /* checkChildren */ true); - if (shouldEmitDefaultBindings || shouldEmitNamedBindings) { - write("import "); - emitStart(node.importClause); - if (shouldEmitDefaultBindings) { - emit(node.importClause.name); - if (shouldEmitNamedBindings) { - write(", "); - } - } - if (shouldEmitNamedBindings) { - emitLeadingComments(node.importClause.namedBindings); - emitStart(node.importClause.namedBindings); - if (node.importClause.namedBindings.kind === 222 /* NamespaceImport */) { - write("* as "); - emit(node.importClause.namedBindings.name); - } - else { - write("{ "); - emitExportOrImportSpecifierList(node.importClause.namedBindings.elements, resolver.isReferencedAliasDeclaration); - write(" }"); - } - emitEnd(node.importClause.namedBindings); - emitTrailingComments(node.importClause.namedBindings); - } - emitEnd(node.importClause); - write(" from "); - emit(node.moduleSpecifier); - write(";"); - } - } - else { - write("import "); - emit(node.moduleSpecifier); - write(";"); - } - } - function emitExternalImportDeclaration(node) { - if (ts.contains(externalImports, node)) { - var isExportedImport = node.kind === 219 /* ImportEqualsDeclaration */ && (node.flags & 1 /* Export */) !== 0; - var namespaceDeclaration = getNamespaceDeclarationNode(node); - if (compilerOptions.module !== 2 /* AMD */) { - emitLeadingComments(node); - emitStart(node); - if (namespaceDeclaration && !isDefaultImport(node)) { - // import x = require("foo") - // import * as x from "foo" - if (!isExportedImport) - write("var "); - emitModuleMemberName(namespaceDeclaration); - write(" = "); - } - else { - // import "foo" - // import x from "foo" - // import { x, y } from "foo" - // import d, * as x from "foo" - // import d, { x, y } from "foo" - var isNakedImport = 220 /* ImportDeclaration */ && !node.importClause; - if (!isNakedImport) { - write("var "); - write(getGeneratedNameForNode(node)); - write(" = "); - } - } - emitRequire(ts.getExternalModuleName(node)); - if (namespaceDeclaration && isDefaultImport(node)) { - // import d, * as x from "foo" - write(", "); - emitModuleMemberName(namespaceDeclaration); - write(" = "); - write(getGeneratedNameForNode(node)); - } - write(";"); - emitEnd(node); - emitExportImportAssignments(node); - emitTrailingComments(node); - } - else { - if (isExportedImport) { - emitModuleMemberName(namespaceDeclaration); - write(" = "); - emit(namespaceDeclaration.name); - write(";"); - } - else if (namespaceDeclaration && isDefaultImport(node)) { - // import d, * as x from "foo" - write("var "); - emitModuleMemberName(namespaceDeclaration); - write(" = "); - write(getGeneratedNameForNode(node)); - write(";"); - } - emitExportImportAssignments(node); - } - } - } - function emitImportEqualsDeclaration(node) { - if (ts.isExternalModuleImportEqualsDeclaration(node)) { - emitExternalImportDeclaration(node); - return; - } - // preserve old compiler's behavior: emit 'var' for import declaration (even if we do not consider them referenced) when - // - current file is not external module - // - import declaration is top level and target is value imported by entity name - if (resolver.isReferencedAliasDeclaration(node) || - (!ts.isExternalModule(currentSourceFile) && resolver.isTopLevelValueImportEqualsWithEntityName(node))) { - emitLeadingComments(node); - emitStart(node); - // variable declaration for import-equals declaration can be hoisted in system modules - // in this case 'var' should be omitted and emit should contain only initialization - var variableDeclarationIsHoisted = shouldHoistVariable(node, /*checkIfSourceFileLevelDecl*/ true); - // is it top level export import v = a.b.c in system module? - // if yes - it needs to be rewritten as exporter('v', v = a.b.c) - var isExported = isSourceFileLevelDeclarationInSystemJsModule(node, /*isExported*/ true); - if (!variableDeclarationIsHoisted) { - ts.Debug.assert(!isExported); - if (isES6ExportedDeclaration(node)) { - write("export "); - write("var "); - } - else if (!(node.flags & 1 /* Export */)) { - write("var "); - } - } - if (isExported) { - write(exportFunctionForFile + "(\""); - emitNodeWithoutSourceMap(node.name); - write("\", "); - } - emitModuleMemberName(node); - write(" = "); - emit(node.moduleReference); - if (isExported) { - write(")"); - } - write(";"); - emitEnd(node); - emitExportImportAssignments(node); - emitTrailingComments(node); - } - } - function emitExportDeclaration(node) { - ts.Debug.assert(compilerOptions.module !== 4 /* System */); - if (languageVersion < 2 /* ES6 */) { - if (node.moduleSpecifier && (!node.exportClause || resolver.isValueAliasDeclaration(node))) { - emitStart(node); - var generatedName = getGeneratedNameForNode(node); - if (node.exportClause) { - // export { x, y, ... } from "foo" - if (compilerOptions.module !== 2 /* AMD */) { - write("var "); - write(generatedName); - write(" = "); - emitRequire(ts.getExternalModuleName(node)); - write(";"); - } - for (var _a = 0, _b = node.exportClause.elements; _a < _b.length; _a++) { - var specifier = _b[_a]; - if (resolver.isValueAliasDeclaration(specifier)) { - writeLine(); - emitStart(specifier); - emitContainingModuleName(specifier); - write("."); - emitNodeWithCommentsAndWithoutSourcemap(specifier.name); - write(" = "); - write(generatedName); - write("."); - emitNodeWithCommentsAndWithoutSourcemap(specifier.propertyName || specifier.name); - write(";"); - emitEnd(specifier); - } - } - } - else { - // export * from "foo" - writeLine(); - write("__export("); - if (compilerOptions.module !== 2 /* AMD */) { - emitRequire(ts.getExternalModuleName(node)); - } - else { - write(generatedName); - } - write(");"); - } - emitEnd(node); - } - } - else { - if (!node.exportClause || resolver.isValueAliasDeclaration(node)) { - write("export "); - if (node.exportClause) { - // export { x, y, ... } - write("{ "); - emitExportOrImportSpecifierList(node.exportClause.elements, resolver.isValueAliasDeclaration); - write(" }"); - } - else { - write("*"); - } - if (node.moduleSpecifier) { - write(" from "); - emit(node.moduleSpecifier); - } - write(";"); - } - } - } - function emitExportOrImportSpecifierList(specifiers, shouldEmit) { - ts.Debug.assert(languageVersion >= 2 /* ES6 */); - var needsComma = false; - for (var _a = 0; _a < specifiers.length; _a++) { - var specifier = specifiers[_a]; - if (shouldEmit(specifier)) { - if (needsComma) { - write(", "); - } - if (specifier.propertyName) { - emit(specifier.propertyName); - write(" as "); - } - emit(specifier.name); - needsComma = true; - } - } - } - function emitExportAssignment(node) { - if (!node.isExportEquals && resolver.isValueAliasDeclaration(node)) { - if (languageVersion >= 2 /* ES6 */) { - writeLine(); - emitStart(node); - write("export default "); - var expression = node.expression; - emit(expression); - if (expression.kind !== 211 /* FunctionDeclaration */ && - expression.kind !== 212 /* ClassDeclaration */) { - write(";"); - } - emitEnd(node); - } - else { - writeLine(); - emitStart(node); - if (compilerOptions.module === 4 /* System */) { - write(exportFunctionForFile + "(\"default\","); - emit(node.expression); - write(")"); - } - else { - emitEs6ExportDefaultCompat(node); - emitContainingModuleName(node); - if (languageVersion === 0 /* ES3 */) { - write("[\"default\"] = "); - } - else { - write(".default = "); - } - emit(node.expression); - } - write(";"); - emitEnd(node); - } - } - } - function collectExternalModuleInfo(sourceFile) { - externalImports = []; - exportSpecifiers = {}; - exportEquals = undefined; - hasExportStars = false; - for (var _a = 0, _b = sourceFile.statements; _a < _b.length; _a++) { - var node = _b[_a]; - switch (node.kind) { - case 220 /* 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); - } - break; - case 219 /* ImportEqualsDeclaration */: - if (node.moduleReference.kind === 230 /* ExternalModuleReference */ && resolver.isReferencedAliasDeclaration(node)) { - // import x = require("mod") where x is referenced - externalImports.push(node); - } - break; - case 226 /* ExportDeclaration */: - if (node.moduleSpecifier) { - if (!node.exportClause) { - // export * from "mod" - externalImports.push(node); - hasExportStars = true; - } - else if (resolver.isValueAliasDeclaration(node)) { - // export { x, y } from "mod" where at least one export is a value symbol - externalImports.push(node); - } - } - else { - // export { x, y } - for (var _c = 0, _d = node.exportClause.elements; _c < _d.length; _c++) { - var specifier = _d[_c]; - var name_24 = (specifier.propertyName || specifier.name).text; - (exportSpecifiers[name_24] || (exportSpecifiers[name_24] = [])).push(specifier); - } - } - break; - case 225 /* ExportAssignment */: - if (node.isExportEquals && !exportEquals) { - // export = x - exportEquals = node; - } - break; - } - } - } - function emitExportStarHelper() { - if (hasExportStars) { - writeLine(); - write("function __export(m) {"); - increaseIndent(); - writeLine(); - write("for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];"); - decreaseIndent(); - writeLine(); - write("}"); - } - } - function getLocalNameForExternalImport(node) { - var namespaceDeclaration = getNamespaceDeclarationNode(node); - if (namespaceDeclaration && !isDefaultImport(node)) { - return ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, namespaceDeclaration.name); - } - if (node.kind === 220 /* ImportDeclaration */ && node.importClause) { - return getGeneratedNameForNode(node); - } - if (node.kind === 226 /* ExportDeclaration */ && node.moduleSpecifier) { - return getGeneratedNameForNode(node); - } - } - function getExternalModuleNameText(importNode) { - var moduleName = ts.getExternalModuleName(importNode); - if (moduleName.kind === 9 /* StringLiteral */) { - return tryRenameExternalModule(moduleName) || getLiteralText(moduleName); - } - return undefined; - } - function emitVariableDeclarationsForImports() { - if (externalImports.length === 0) { - return; - } - writeLine(); - var started = false; - for (var _a = 0; _a < externalImports.length; _a++) { - var importNode = externalImports[_a]; - // do not create variable declaration for exports and imports that lack import clause - var skipNode = importNode.kind === 226 /* ExportDeclaration */ || - (importNode.kind === 220 /* ImportDeclaration */ && !importNode.importClause); - if (skipNode) { - continue; - } - if (!started) { - write("var "); - started = true; - } - else { - write(", "); - } - write(getLocalNameForExternalImport(importNode)); - } - if (started) { - write(";"); - } - } - function emitLocalStorageForExportedNamesIfNecessary(exportedDeclarations) { - // 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. - if (!hasExportStars) { - // local names set is needed only in presence of star exports - return undefined; - } - // local names set should only be added if we have anything exported - if (!exportedDeclarations && 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 _a = 0; _a < externalImports.length; _a++) { - var externalImport = externalImports[_a]; - if (externalImport.kind === 226 /* ExportDeclaration */ && externalImport.exportClause) { - hasExportDeclarationWithExportClause = true; - break; - } - } - if (!hasExportDeclarationWithExportClause) { - // we still need to emit exportStar helper - return emitExportStarFunction(/*localNames*/ undefined); - } - } - var exportedNamesStorageRef = makeUniqueName("exportedNames"); - writeLine(); - write("var " + exportedNamesStorageRef + " = {"); - increaseIndent(); - var started = false; - if (exportedDeclarations) { - for (var i = 0; i < exportedDeclarations.length; ++i) { - // write name of exported declaration, i.e 'export var x...' - writeExportedName(exportedDeclarations[i]); - } - } - if (exportSpecifiers) { - for (var n in exportSpecifiers) { - for (var _b = 0, _c = exportSpecifiers[n]; _b < _c.length; _b++) { - var specifier = _c[_b]; - // write name of export specified, i.e. 'export {x}' - writeExportedName(specifier.name); - } - } - } - for (var _d = 0; _d < externalImports.length; _d++) { - var externalImport = externalImports[_d]; - if (externalImport.kind !== 226 /* ExportDeclaration */) { - continue; - } - var exportDecl = externalImport; - if (!exportDecl.exportClause) { - // export * from ... - continue; - } - for (var _e = 0, _f = exportDecl.exportClause.elements; _e < _f.length; _e++) { - var element = _f[_e]; - // write name of indirectly exported entry, i.e. 'export {x} from ...' - writeExportedName(element.name || element.propertyName); - } - } - decreaseIndent(); - writeLine(); - write("};"); - return emitExportStarFunction(exportedNamesStorageRef); - function emitExportStarFunction(localNames) { - var exportStarFunction = makeUniqueName("exportStar"); - writeLine(); - // define an export star helper function - write("function " + exportStarFunction + "(m) {"); - increaseIndent(); - writeLine(); - write("var exports = {};"); - writeLine(); - write("for(var n in m) {"); - increaseIndent(); - writeLine(); - write("if (n !== \"default\""); - if (localNames) { - write("&& !" + localNames + ".hasOwnProperty(n)"); - } - write(") exports[n] = m[n];"); - decreaseIndent(); - writeLine(); - write("}"); - writeLine(); - write(exportFunctionForFile + "(exports);"); - decreaseIndent(); - writeLine(); - write("}"); - return exportStarFunction; - } - function writeExportedName(node) { - // do not record default exports - // they are local to module and never overwritten (explicitly skipped) by star export - if (node.kind !== 67 /* Identifier */ && node.flags & 1024 /* Default */) { - return; - } - if (started) { - write(","); - } - else { - started = true; - } - writeLine(); - write("'"); - if (node.kind === 67 /* Identifier */) { - emitNodeWithCommentsAndWithoutSourcemap(node); - } - else { - emitDeclarationName(node); - } - write("': true"); - } - } - function processTopLevelVariableAndFunctionDeclarations(node) { - // per ES6 spec: - // 15.2.1.16.4 ModuleDeclarationInstantiation() Concrete Method - // - var declarations are initialized to undefined - 14.a.ii - // - function/generator declarations are instantiated - 16.a.iv - // this means that after module is instantiated but before its evaluation - // exported functions are already accessible at import sites - // in theory we should hoist only exported functions and its dependencies - // in practice to simplify things we'll hoist all source level functions and variable declaration - // including variables declarations for module and class declarations - var hoistedVars; - var hoistedFunctionDeclarations; - var exportedDeclarations; - visit(node); - if (hoistedVars) { - writeLine(); - write("var "); - var seen = {}; - for (var i = 0; i < hoistedVars.length; ++i) { - var local = hoistedVars[i]; - var name_25 = local.kind === 67 /* Identifier */ - ? local - : local.name; - if (name_25) { - // do not emit duplicate entries (in case of declaration merging) in the list of hoisted variables - var text = ts.unescapeIdentifier(name_25.text); - if (ts.hasProperty(seen, text)) { - continue; - } - else { - seen[text] = text; - } - } - if (i !== 0) { - write(", "); - } - if (local.kind === 212 /* ClassDeclaration */ || local.kind === 216 /* ModuleDeclaration */ || local.kind === 215 /* EnumDeclaration */) { - emitDeclarationName(local); - } - else { - emit(local); - } - var flags = ts.getCombinedNodeFlags(local.kind === 67 /* Identifier */ ? local.parent : local); - if (flags & 1 /* Export */) { - if (!exportedDeclarations) { - exportedDeclarations = []; - } - exportedDeclarations.push(local); - } - } - write(";"); - } - if (hoistedFunctionDeclarations) { - for (var _a = 0; _a < hoistedFunctionDeclarations.length; _a++) { - var f = hoistedFunctionDeclarations[_a]; - writeLine(); - emit(f); - if (f.flags & 1 /* Export */) { - if (!exportedDeclarations) { - exportedDeclarations = []; - } - exportedDeclarations.push(f); - } - } - } - return exportedDeclarations; - function visit(node) { - if (node.flags & 2 /* Ambient */) { - return; - } - if (node.kind === 211 /* FunctionDeclaration */) { - if (!hoistedFunctionDeclarations) { - hoistedFunctionDeclarations = []; - } - hoistedFunctionDeclarations.push(node); - return; - } - if (node.kind === 212 /* ClassDeclaration */) { - if (!hoistedVars) { - hoistedVars = []; - } - hoistedVars.push(node); - return; - } - if (node.kind === 215 /* EnumDeclaration */) { - if (shouldEmitEnumDeclaration(node)) { - if (!hoistedVars) { - hoistedVars = []; - } - hoistedVars.push(node); - } - return; - } - if (node.kind === 216 /* ModuleDeclaration */) { - if (shouldEmitModuleDeclaration(node)) { - if (!hoistedVars) { - hoistedVars = []; - } - hoistedVars.push(node); - } - return; - } - if (node.kind === 209 /* VariableDeclaration */ || node.kind === 161 /* BindingElement */) { - if (shouldHoistVariable(node, /*checkIfSourceFileLevelDecl*/ false)) { - var name_26 = node.name; - if (name_26.kind === 67 /* Identifier */) { - if (!hoistedVars) { - hoistedVars = []; - } - hoistedVars.push(name_26); - } - else { - ts.forEachChild(name_26, visit); - } - } - return; - } - if (ts.isInternalModuleImportEqualsDeclaration(node) && resolver.isValueAliasDeclaration(node)) { - if (!hoistedVars) { - hoistedVars = []; - } - hoistedVars.push(node.name); - return; - } - if (ts.isBindingPattern(node)) { - ts.forEach(node.elements, visit); - return; - } - if (!ts.isDeclaration(node)) { - ts.forEachChild(node, visit); - } - } - } - function shouldHoistVariable(node, checkIfSourceFileLevelDecl) { - if (checkIfSourceFileLevelDecl && !shouldHoistDeclarationInSystemJsModule(node)) { - return false; - } - // hoist variable if - // - it is not block scoped - // - it is top level block scoped - // if block scoped variables are nested in some another block then - // no other functions can use them except ones that are defined at least in the same block - return (ts.getCombinedNodeFlags(node) & 49152 /* BlockScoped */) === 0 || - ts.getEnclosingBlockScopeContainer(node).kind === 246 /* SourceFile */; - } - function isCurrentFileSystemExternalModule() { - return compilerOptions.module === 4 /* System */ && ts.isExternalModule(currentSourceFile); - } - function emitSystemModuleBody(node, dependencyGroups, startIndex) { - // 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 file1; // local alias - // var y; - // function foo() { return y + file1.x(); } - // exports("foo", foo); - // return { - // setters: [ - // function(v) { file1 = v } - // ], - // execute(): function() { - // y = 1; - // console.log(y); - // } - // }; - // } - emitVariableDeclarationsForImports(); - writeLine(); - var exportedDeclarations = processTopLevelVariableAndFunctionDeclarations(node); - var exportStarFunction = emitLocalStorageForExportedNamesIfNecessary(exportedDeclarations); - writeLine(); - write("return {"); - increaseIndent(); - writeLine(); - emitSetters(exportStarFunction, dependencyGroups); - writeLine(); - emitExecute(node, startIndex); - decreaseIndent(); - writeLine(); - write("}"); // return - emitTempDeclarations(/*newLine*/ true); - } - function emitSetters(exportStarFunction, dependencyGroups) { - write("setters:["); - for (var i = 0; i < dependencyGroups.length; ++i) { - if (i !== 0) { - write(","); - } - writeLine(); - increaseIndent(); - var group = dependencyGroups[i]; - // derive a unique name for parameter from the first named entry in the group - var parameterName = makeUniqueName(ts.forEach(group, getLocalNameForExternalImport) || ""); - write("function (" + parameterName + ") {"); - increaseIndent(); - for (var _a = 0; _a < group.length; _a++) { - var entry = group[_a]; - var importVariableName = getLocalNameForExternalImport(entry) || ""; - switch (entry.kind) { - case 220 /* ImportDeclaration */: - if (!entry.importClause) { - // 'import "..."' case - // module is imported only for side-effects, no emit required - break; - } - // fall-through - case 219 /* ImportEqualsDeclaration */: - ts.Debug.assert(importVariableName !== ""); - writeLine(); - // save import into the local - write(importVariableName + " = " + parameterName + ";"); - writeLine(); - break; - case 226 /* ExportDeclaration */: - ts.Debug.assert(importVariableName !== ""); - if (entry.exportClause) { - // export {a, b as c} from 'foo' - // emit as: - // exports_({ - // "a": _["a"], - // "c": _["b"] - // }); - writeLine(); - write(exportFunctionForFile + "({"); - writeLine(); - increaseIndent(); - for (var i_2 = 0, len = entry.exportClause.elements.length; i_2 < len; ++i_2) { - if (i_2 !== 0) { - write(","); - writeLine(); - } - var e = entry.exportClause.elements[i_2]; - write("\""); - emitNodeWithCommentsAndWithoutSourcemap(e.name); - write("\": " + parameterName + "[\""); - emitNodeWithCommentsAndWithoutSourcemap(e.propertyName || e.name); - write("\"]"); - } - decreaseIndent(); - writeLine(); - write("});"); - } - else { - writeLine(); - // export * from 'foo' - // emit as: - // exportStar(_foo); - write(exportStarFunction + "(" + parameterName + ");"); - } - writeLine(); - break; - } - } - decreaseIndent(); - write("}"); - decreaseIndent(); - } - write("],"); - } - function emitExecute(node, startIndex) { - write("execute: function() {"); - increaseIndent(); - writeLine(); - for (var i = startIndex; i < node.statements.length; ++i) { - var statement = node.statements[i]; - switch (statement.kind) { - // - function declarations are not emitted because they were already hoisted - // - import declarations are not emitted since they are already handled in setters - // - export declarations with module specifiers are not emitted since they were already written in setters - // - export declarations without module specifiers are emitted preserving the order - case 211 /* FunctionDeclaration */: - case 220 /* ImportDeclaration */: - continue; - case 226 /* ExportDeclaration */: - if (!statement.moduleSpecifier) { - for (var _a = 0, _b = statement.exportClause.elements; _a < _b.length; _a++) { - var element = _b[_a]; - // write call to exporter function for every export specifier in exports list - emitExportSpecifierInSystemModule(element); - } - } - continue; - case 219 /* ImportEqualsDeclaration */: - if (!ts.isInternalModuleImportEqualsDeclaration(statement)) { - // - import equals declarations that import external modules are not emitted - continue; - } - // fall-though for import declarations that import internal modules - default: - writeLine(); - emit(statement); - } - } - decreaseIndent(); - writeLine(); - write("}"); // execute - } - function emitSystemModule(node, startIndex) { - collectExternalModuleInfo(node); - // System modules has the following shape - // System.register(['dep-1', ... 'dep-n'], function(exports) {/* module body function */}) - // 'exports' here is a function 'exports(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 'emitPostfixUnaryExpression' for more details - ts.Debug.assert(!exportFunctionForFile); - // make sure that name of 'exports' function does not conflict with existing identifiers - exportFunctionForFile = makeUniqueName("exports"); - writeLine(); - write("System.register("); - if (node.moduleName) { - write("\"" + node.moduleName + "\", "); - } - write("["); - var groupIndices = {}; - var dependencyGroups = []; - for (var i = 0; i < externalImports.length; ++i) { - var text = getExternalModuleNameText(externalImports[i]); - if (ts.hasProperty(groupIndices, text)) { - // deduplicate/group entries in dependency list by the dependency name - var groupIndex = groupIndices[text]; - dependencyGroups[groupIndex].push(externalImports[i]); - continue; - } - else { - groupIndices[text] = dependencyGroups.length; - dependencyGroups.push([externalImports[i]]); - } - if (i !== 0) { - write(", "); - } - write(text); - } - write("], function(" + exportFunctionForFile + ") {"); - writeLine(); - increaseIndent(); - emitEmitHelpers(node); - emitCaptureThisForNodeIfNecessary(node); - emitSystemModuleBody(node, dependencyGroups, startIndex); - decreaseIndent(); - writeLine(); - write("});"); - } - function emitAMDDependencies(node, includeNonAmdDependencies) { - // An AMD define function has the following shape: - // define(id?, dependencies?, factory); - // - // This has the shape of - // define(name, ["module1", "module2"], function (module1Alias) { - // The location of the alias in the parameter list in the factory function needs to - // match the position of the module name in the dependency list. - // - // To ensure this is true in cases of modules with no aliases, e.g.: - // `import "module"` or `` - // we need to add modules without alias names to the end of the dependencies list - // names of modules with corresponding parameter in the factory function - var aliasedModuleNames = []; - // names of modules with no corresponding parameters in factory function - var unaliasedModuleNames = []; - var importAliasNames = []; // names of the parameters in the factory function; these - // parameters need to match the indexes of the corresponding - // module names in aliasedModuleNames. - // Fill in amd-dependency tags - for (var _a = 0, _b = node.amdDependencies; _a < _b.length; _a++) { - var amdDependency = _b[_a]; - if (amdDependency.name) { - aliasedModuleNames.push("\"" + amdDependency.path + "\""); - importAliasNames.push(amdDependency.name); - } - else { - unaliasedModuleNames.push("\"" + amdDependency.path + "\""); - } - } - for (var _c = 0; _c < externalImports.length; _c++) { - var importNode = externalImports[_c]; - // Find the name of the external module - var externalModuleName = getExternalModuleNameText(importNode); - // Find the name of the module alias, if there is one - var importAliasName = getLocalNameForExternalImport(importNode); - if (includeNonAmdDependencies && importAliasName) { - aliasedModuleNames.push(externalModuleName); - importAliasNames.push(importAliasName); - } - else { - unaliasedModuleNames.push(externalModuleName); - } - } - write("[\"require\", \"exports\""); - if (aliasedModuleNames.length) { - write(", "); - write(aliasedModuleNames.join(", ")); - } - if (unaliasedModuleNames.length) { - write(", "); - write(unaliasedModuleNames.join(", ")); - } - write("], function (require, exports"); - if (importAliasNames.length) { - write(", "); - write(importAliasNames.join(", ")); - } - } - function emitAMDModule(node, startIndex) { - emitEmitHelpers(node); - collectExternalModuleInfo(node); - writeLine(); - write("define("); - if (node.moduleName) { - write("\"" + node.moduleName + "\", "); - } - emitAMDDependencies(node, /*includeNonAmdDependencies*/ true); - write(") {"); - increaseIndent(); - emitExportStarHelper(); - emitCaptureThisForNodeIfNecessary(node); - emitLinesStartingAt(node.statements, startIndex); - emitTempDeclarations(/*newLine*/ true); - emitExportEquals(/*emitAsReturn*/ true); - decreaseIndent(); - writeLine(); - write("});"); - } - function emitCommonJSModule(node, startIndex) { - emitEmitHelpers(node); - collectExternalModuleInfo(node); - emitExportStarHelper(); - emitCaptureThisForNodeIfNecessary(node); - emitLinesStartingAt(node.statements, startIndex); - emitTempDeclarations(/*newLine*/ true); - emitExportEquals(/*emitAsReturn*/ false); - } - function emitUMDModule(node, startIndex) { - emitEmitHelpers(node); - collectExternalModuleInfo(node); - // Module is detected first to support Browserify users that load into a browser with an AMD loader - writeLines("(function (deps, factory) {\n if (typeof module === 'object' && typeof module.exports === 'object') {\n var v = factory(require, exports); if (v !== undefined) module.exports = v;\n }\n else if (typeof define === 'function' && define.amd) {\n define(deps, factory);\n }\n})("); - emitAMDDependencies(node, false); - write(") {"); - increaseIndent(); - emitExportStarHelper(); - emitCaptureThisForNodeIfNecessary(node); - emitLinesStartingAt(node.statements, startIndex); - emitTempDeclarations(/*newLine*/ true); - emitExportEquals(/*emitAsReturn*/ true); - decreaseIndent(); - writeLine(); - write("});"); - } - function emitES6Module(node, startIndex) { - externalImports = undefined; - exportSpecifiers = undefined; - exportEquals = undefined; - hasExportStars = false; - emitEmitHelpers(node); - emitCaptureThisForNodeIfNecessary(node); - emitLinesStartingAt(node.statements, startIndex); - emitTempDeclarations(/*newLine*/ true); - // Emit exportDefault if it exists will happen as part - // or normal statement emit. - } - function emitExportEquals(emitAsReturn) { - if (exportEquals && resolver.isValueAliasDeclaration(exportEquals)) { - writeLine(); - emitStart(exportEquals); - write(emitAsReturn ? "return " : "module.exports = "); - emit(exportEquals.expression); - write(";"); - emitEnd(exportEquals); - } - } - function emitJsxElement(node) { - switch (compilerOptions.jsx) { - case 2 /* React */: - jsxEmitReact(node); - break; - case 1 /* Preserve */: - // Fall back to preserve if None was specified (we'll error earlier) - default: - jsxEmitPreserve(node); - break; - } - } - function trimReactWhitespaceAndApplyEntities(node) { - var result = undefined; - var text = ts.getTextOfNode(node, /*includeTrivia*/ true); - var firstNonWhitespace = 0; - var lastNonWhitespace = -1; - // JSX trims whitespace at the end and beginning of lines, except that the - // start/end of a tag is considered a start/end of a line only if that line is - // on the same line as the closing tag. See examples in tests/cases/conformance/jsx/tsxReactEmitWhitespace.tsx - for (var i = 0; i < text.length; i++) { - var c = text.charCodeAt(i); - if (ts.isLineBreak(c)) { - if (firstNonWhitespace !== -1 && (lastNonWhitespace - firstNonWhitespace + 1 > 0)) { - var part = text.substr(firstNonWhitespace, lastNonWhitespace - firstNonWhitespace + 1); - result = (result ? result + "\" + ' ' + \"" : "") + part; - } - firstNonWhitespace = -1; - } - else if (!ts.isWhiteSpace(c)) { - lastNonWhitespace = i; - if (firstNonWhitespace === -1) { - firstNonWhitespace = i; - } - } - } - if (firstNonWhitespace !== -1) { - var part = text.substr(firstNonWhitespace); - result = (result ? result + "\" + ' ' + \"" : "") + part; - } - if (result) { - // Replace entities like   - result = result.replace(/&(\w+);/g, function (s, m) { - if (entities[m] !== undefined) { - return String.fromCharCode(entities[m]); - } - else { - return s; - } - }); - } - return result; - } - function getTextToEmit(node) { - switch (compilerOptions.jsx) { - case 2 /* React */: - var text = trimReactWhitespaceAndApplyEntities(node); - if (text === undefined || text.length === 0) { - return undefined; - } - else { - return text; - } - case 1 /* Preserve */: - default: - return ts.getTextOfNode(node, /*includeTrivia*/ true); - } - } - function emitJsxText(node) { - switch (compilerOptions.jsx) { - case 2 /* React */: - write("\""); - write(trimReactWhitespaceAndApplyEntities(node)); - write("\""); - break; - case 1 /* Preserve */: - default: - writer.writeLiteral(ts.getTextOfNode(node, /*includeTrivia*/ true)); - break; - } - } - function emitJsxExpression(node) { - if (node.expression) { - switch (compilerOptions.jsx) { - case 1 /* Preserve */: - default: - write("{"); - emit(node.expression); - write("}"); - break; - case 2 /* React */: - emit(node.expression); - break; - } - } - } - function emitDirectivePrologues(statements, startWithNewLine) { - for (var i = 0; i < statements.length; ++i) { - if (ts.isPrologueDirective(statements[i])) { - if (startWithNewLine || i > 0) { - writeLine(); - } - emit(statements[i]); - } - else { - // return index of the first non prologue directive - return i; - } - } - return statements.length; - } - function writeLines(text) { - var lines = text.split(/\r\n|\r|\n/g); - for (var i = 0; i < lines.length; ++i) { - var line = lines[i]; - if (line.length) { - writeLine(); - write(line); - } - } - } - function emitEmitHelpers(node) { - // Only emit helpers if the user did not say otherwise. - if (!compilerOptions.noEmitHelpers) { - // Only Emit __extends function when target ES5. - // For target ES6 and above, we can emit classDeclaration as is. - if ((languageVersion < 2 /* ES6 */) && (!extendsEmitted && resolver.getNodeCheckFlags(node) & 8 /* EmitExtends */)) { - writeLines(extendsHelper); - extendsEmitted = true; - } - if (!decorateEmitted && resolver.getNodeCheckFlags(node) & 16 /* EmitDecorate */) { - writeLines(decorateHelper); - if (compilerOptions.emitDecoratorMetadata) { - writeLines(metadataHelper); - } - decorateEmitted = true; - } - if (!paramEmitted && resolver.getNodeCheckFlags(node) & 32 /* EmitParam */) { - writeLines(paramHelper); - paramEmitted = true; - } - if (!awaiterEmitted && resolver.getNodeCheckFlags(node) & 64 /* EmitAwaiter */) { - writeLines(awaiterHelper); - awaiterEmitted = true; - } - } - } - function emitSourceFileNode(node) { - // Start new file on new line - writeLine(); - emitShebang(); - emitDetachedComments(node); - // emit prologue directives prior to __extends - var startIndex = emitDirectivePrologues(node.statements, /*startWithNewLine*/ false); - if (ts.isExternalModule(node) || compilerOptions.isolatedModules) { - if (languageVersion >= 2 /* ES6 */) { - emitES6Module(node, startIndex); - } - else if (compilerOptions.module === 2 /* AMD */) { - emitAMDModule(node, startIndex); - } - else if (compilerOptions.module === 4 /* System */) { - emitSystemModule(node, startIndex); - } - else if (compilerOptions.module === 3 /* UMD */) { - emitUMDModule(node, startIndex); - } - else { - emitCommonJSModule(node, startIndex); - } - } - else { - externalImports = undefined; - exportSpecifiers = undefined; - exportEquals = undefined; - hasExportStars = false; - emitEmitHelpers(node); - emitCaptureThisForNodeIfNecessary(node); - emitLinesStartingAt(node.statements, startIndex); - emitTempDeclarations(/*newLine*/ true); - } - emitLeadingComments(node.endOfFileToken); - } - function emitNodeWithCommentsAndWithoutSourcemap(node) { - emitNodeConsideringCommentsOption(node, emitNodeWithoutSourceMap); - } - function emitNodeConsideringCommentsOption(node, emitNodeConsideringSourcemap) { - if (node) { - if (node.flags & 2 /* Ambient */) { - return emitCommentsOnNotEmittedNode(node); - } - if (isSpecializedCommentHandling(node)) { - // This is the node that will handle its own comments and sourcemap - return emitNodeWithoutSourceMap(node); - } - var emitComments_1 = shouldEmitLeadingAndTrailingComments(node); - if (emitComments_1) { - emitLeadingComments(node); - } - emitNodeConsideringSourcemap(node); - if (emitComments_1) { - emitTrailingComments(node); - } - } - } - function emitNodeWithoutSourceMap(node) { - if (node) { - emitJavaScriptWorker(node); - } - } - function isSpecializedCommentHandling(node) { - switch (node.kind) { - // All of these entities are emitted in a specialized fashion. As such, we allow - // the specialized methods for each to handle the comments on the nodes. - case 213 /* InterfaceDeclaration */: - case 211 /* FunctionDeclaration */: - case 220 /* ImportDeclaration */: - case 219 /* ImportEqualsDeclaration */: - case 214 /* TypeAliasDeclaration */: - case 225 /* ExportAssignment */: - return true; - } - } - function shouldEmitLeadingAndTrailingComments(node) { - switch (node.kind) { - case 191 /* VariableStatement */: - return shouldEmitLeadingAndTrailingCommentsForVariableStatement(node); - case 216 /* ModuleDeclaration */: - // Only emit the leading/trailing comments for a module if we're actually - // emitting the module as well. - return shouldEmitModuleDeclaration(node); - case 215 /* EnumDeclaration */: - // Only emit the leading/trailing comments for an enum if we're actually - // emitting the module as well. - return shouldEmitEnumDeclaration(node); - } - // If the node is emitted in specialized fashion, dont emit comments as this node will handle - // emitting comments when emitting itself - ts.Debug.assert(!isSpecializedCommentHandling(node)); - // If this is the expression body of an arrow function that we're down-leveling, - // then we don't want to emit comments when we emit the body. It will have already - // been taken care of when we emitted the 'return' statement for the function - // expression body. - if (node.kind !== 190 /* Block */ && - node.parent && - node.parent.kind === 172 /* ArrowFunction */ && - node.parent.body === node && - compilerOptions.target <= 1 /* ES5 */) { - return false; - } - // Emit comments for everything else. - return true; - } - function emitJavaScriptWorker(node) { - // Check if the node can be emitted regardless of the ScriptTarget - switch (node.kind) { - case 67 /* Identifier */: - return emitIdentifier(node); - case 136 /* Parameter */: - return emitParameter(node); - case 141 /* MethodDeclaration */: - case 140 /* MethodSignature */: - return emitMethod(node); - case 143 /* GetAccessor */: - case 144 /* SetAccessor */: - return emitAccessor(node); - case 95 /* ThisKeyword */: - return emitThis(node); - case 93 /* SuperKeyword */: - return emitSuper(node); - case 91 /* NullKeyword */: - return write("null"); - case 97 /* TrueKeyword */: - return write("true"); - case 82 /* FalseKeyword */: - return write("false"); - case 8 /* NumericLiteral */: - case 9 /* StringLiteral */: - case 10 /* RegularExpressionLiteral */: - case 11 /* NoSubstitutionTemplateLiteral */: - case 12 /* TemplateHead */: - case 13 /* TemplateMiddle */: - case 14 /* TemplateTail */: - return emitLiteral(node); - case 181 /* TemplateExpression */: - return emitTemplateExpression(node); - case 188 /* TemplateSpan */: - return emitTemplateSpan(node); - case 231 /* JsxElement */: - case 232 /* JsxSelfClosingElement */: - return emitJsxElement(node); - case 234 /* JsxText */: - return emitJsxText(node); - case 238 /* JsxExpression */: - return emitJsxExpression(node); - case 133 /* QualifiedName */: - return emitQualifiedName(node); - case 159 /* ObjectBindingPattern */: - return emitObjectBindingPattern(node); - case 160 /* ArrayBindingPattern */: - return emitArrayBindingPattern(node); - case 161 /* BindingElement */: - return emitBindingElement(node); - case 162 /* ArrayLiteralExpression */: - return emitArrayLiteral(node); - case 163 /* ObjectLiteralExpression */: - return emitObjectLiteral(node); - case 243 /* PropertyAssignment */: - return emitPropertyAssignment(node); - case 244 /* ShorthandPropertyAssignment */: - return emitShorthandPropertyAssignment(node); - case 134 /* ComputedPropertyName */: - return emitComputedPropertyName(node); - case 164 /* PropertyAccessExpression */: - return emitPropertyAccess(node); - case 165 /* ElementAccessExpression */: - return emitIndexedAccess(node); - case 166 /* CallExpression */: - return emitCallExpression(node); - case 167 /* NewExpression */: - return emitNewExpression(node); - case 168 /* TaggedTemplateExpression */: - return emitTaggedTemplateExpression(node); - case 169 /* TypeAssertionExpression */: - return emit(node.expression); - case 187 /* AsExpression */: - return emit(node.expression); - case 170 /* ParenthesizedExpression */: - return emitParenExpression(node); - case 211 /* FunctionDeclaration */: - case 171 /* FunctionExpression */: - case 172 /* ArrowFunction */: - return emitFunctionDeclaration(node); - case 173 /* DeleteExpression */: - return emitDeleteExpression(node); - case 174 /* TypeOfExpression */: - return emitTypeOfExpression(node); - case 175 /* VoidExpression */: - return emitVoidExpression(node); - case 176 /* AwaitExpression */: - return emitAwaitExpression(node); - case 177 /* PrefixUnaryExpression */: - return emitPrefixUnaryExpression(node); - case 178 /* PostfixUnaryExpression */: - return emitPostfixUnaryExpression(node); - case 179 /* BinaryExpression */: - return emitBinaryExpression(node); - case 180 /* ConditionalExpression */: - return emitConditionalExpression(node); - case 183 /* SpreadElementExpression */: - return emitSpreadElementExpression(node); - case 182 /* YieldExpression */: - return emitYieldExpression(node); - case 185 /* OmittedExpression */: - return; - case 190 /* Block */: - case 217 /* ModuleBlock */: - return emitBlock(node); - case 191 /* VariableStatement */: - return emitVariableStatement(node); - case 192 /* EmptyStatement */: - return write(";"); - case 193 /* ExpressionStatement */: - return emitExpressionStatement(node); - case 194 /* IfStatement */: - return emitIfStatement(node); - case 195 /* DoStatement */: - return emitDoStatement(node); - case 196 /* WhileStatement */: - return emitWhileStatement(node); - case 197 /* ForStatement */: - return emitForStatement(node); - case 199 /* ForOfStatement */: - case 198 /* ForInStatement */: - return emitForInOrForOfStatement(node); - case 200 /* ContinueStatement */: - case 201 /* BreakStatement */: - return emitBreakOrContinueStatement(node); - case 202 /* ReturnStatement */: - return emitReturnStatement(node); - case 203 /* WithStatement */: - return emitWithStatement(node); - case 204 /* SwitchStatement */: - return emitSwitchStatement(node); - case 239 /* CaseClause */: - case 240 /* DefaultClause */: - return emitCaseOrDefaultClause(node); - case 205 /* LabeledStatement */: - return emitLabelledStatement(node); - case 206 /* ThrowStatement */: - return emitThrowStatement(node); - case 207 /* TryStatement */: - return emitTryStatement(node); - case 242 /* CatchClause */: - return emitCatchClause(node); - case 208 /* DebuggerStatement */: - return emitDebuggerStatement(node); - case 209 /* VariableDeclaration */: - return emitVariableDeclaration(node); - case 184 /* ClassExpression */: - return emitClassExpression(node); - case 212 /* ClassDeclaration */: - return emitClassDeclaration(node); - case 213 /* InterfaceDeclaration */: - return emitInterfaceDeclaration(node); - case 215 /* EnumDeclaration */: - return emitEnumDeclaration(node); - case 245 /* EnumMember */: - return emitEnumMember(node); - case 216 /* ModuleDeclaration */: - return emitModuleDeclaration(node); - case 220 /* ImportDeclaration */: - return emitImportDeclaration(node); - case 219 /* ImportEqualsDeclaration */: - return emitImportEqualsDeclaration(node); - case 226 /* ExportDeclaration */: - return emitExportDeclaration(node); - case 225 /* ExportAssignment */: - return emitExportAssignment(node); - case 246 /* SourceFile */: - return emitSourceFileNode(node); - } - } - function hasDetachedComments(pos) { - return detachedCommentsInfo !== undefined && ts.lastOrUndefined(detachedCommentsInfo).nodePos === pos; - } - function getLeadingCommentsWithoutDetachedComments() { - // get the leading comments from detachedPos - var leadingComments = ts.getLeadingCommentRanges(currentSourceFile.text, ts.lastOrUndefined(detachedCommentsInfo).detachedCommentEndPos); - if (detachedCommentsInfo.length - 1) { - detachedCommentsInfo.pop(); - } - else { - detachedCommentsInfo = undefined; - } - return leadingComments; - } - function isPinnedComments(comment) { - return currentSourceFile.text.charCodeAt(comment.pos + 1) === 42 /* asterisk */ && - currentSourceFile.text.charCodeAt(comment.pos + 2) === 33 /* exclamation */; - } - /** - * Determine if the given comment is a triple-slash - * - * @return true if the comment is a triple-slash comment else false - **/ - function isTripleSlashComment(comment) { - // Verify this is /// comment, but do the regexp match only when we first can find /// in the comment text - // so that we don't end up computing comment string and doing match for all // comments - if (currentSourceFile.text.charCodeAt(comment.pos + 1) === 47 /* slash */ && - comment.pos + 2 < comment.end && - currentSourceFile.text.charCodeAt(comment.pos + 2) === 47 /* slash */) { - var textSubStr = currentSourceFile.text.substring(comment.pos, comment.end); - return textSubStr.match(ts.fullTripleSlashReferencePathRegEx) || - textSubStr.match(ts.fullTripleSlashAMDReferencePathRegEx) ? - true : false; - } - return false; - } - function getLeadingCommentsToEmit(node) { - // Emit the leading comments only if the parent's pos doesn't match because parent should take care of emitting these comments - if (node.parent) { - if (node.parent.kind === 246 /* SourceFile */ || node.pos !== node.parent.pos) { - if (hasDetachedComments(node.pos)) { - // get comments without detached comments - return getLeadingCommentsWithoutDetachedComments(); - } - else { - // get the leading comments from the node - return ts.getLeadingCommentRangesOfNode(node, currentSourceFile); - } - } - } - } - function getTrailingCommentsToEmit(node) { - // Emit the trailing comments only if the parent's pos doesn't match because parent should take care of emitting these comments - if (node.parent) { - if (node.parent.kind === 246 /* SourceFile */ || node.end !== node.parent.end) { - return ts.getTrailingCommentRanges(currentSourceFile.text, node.end); - } - } - } - /** - * Emit comments associated with node that will not be emitted into JS file - */ - function emitCommentsOnNotEmittedNode(node) { - emitLeadingCommentsWorker(node, /*isEmittedNode:*/ false); - } - function emitLeadingComments(node) { - return emitLeadingCommentsWorker(node, /*isEmittedNode:*/ true); - } - function emitLeadingCommentsWorker(node, isEmittedNode) { - if (compilerOptions.removeComments) { - return; - } - var leadingComments; - if (isEmittedNode) { - leadingComments = getLeadingCommentsToEmit(node); - } - else { - // If the node will not be emitted in JS, remove all the comments(normal, pinned and ///) associated with the node, - // unless it is a triple slash comment at the top of the file. - // For Example: - // /// - // declare var x; - // /// - // interface F {} - // The first /// will NOT be removed while the second one will be removed eventhough both node will not be emitted - if (node.pos === 0) { - leadingComments = ts.filter(getLeadingCommentsToEmit(node), isTripleSlashComment); - } - } - ts.emitNewLineBeforeLeadingComments(currentSourceFile, writer, node, leadingComments); - // Leading comments are emitted at /*leading comment1 */space/*leading comment*/space - ts.emitComments(currentSourceFile, writer, leadingComments, /*trailingSeparator:*/ true, newLine, writeComment); - } - function emitTrailingComments(node) { - if (compilerOptions.removeComments) { - return; - } - // Emit the trailing comments only if the parent's end doesn't match - var trailingComments = getTrailingCommentsToEmit(node); - // trailing comments are emitted at space/*trailing comment1 */space/*trailing comment*/ - ts.emitComments(currentSourceFile, writer, trailingComments, /*trailingSeparator*/ false, newLine, writeComment); - } - /** - * Emit trailing comments at the position. The term trailing comment is used here to describe following comment: - * x, /comment1/ y - * ^ => pos; the function will emit "comment1" in the emitJS - */ - function emitTrailingCommentsOfPosition(pos) { - if (compilerOptions.removeComments) { - return; - } - var trailingComments = ts.getTrailingCommentRanges(currentSourceFile.text, pos); - // trailing comments are emitted at space/*trailing comment1 */space/*trailing comment*/ - ts.emitComments(currentSourceFile, writer, trailingComments, /*trailingSeparator*/ true, newLine, writeComment); - } - function emitLeadingCommentsOfPositionWorker(pos) { - if (compilerOptions.removeComments) { - return; - } - var leadingComments; - if (hasDetachedComments(pos)) { - // get comments without detached comments - leadingComments = getLeadingCommentsWithoutDetachedComments(); - } - else { - // get the leading comments from the node - leadingComments = ts.getLeadingCommentRanges(currentSourceFile.text, pos); - } - ts.emitNewLineBeforeLeadingComments(currentSourceFile, writer, { pos: pos, end: pos }, leadingComments); - // Leading comments are emitted at /*leading comment1 */space/*leading comment*/space - ts.emitComments(currentSourceFile, writer, leadingComments, /*trailingSeparator*/ true, newLine, writeComment); - } - function emitDetachedComments(node) { - var leadingComments; - if (compilerOptions.removeComments) { - // removeComments is true, only reserve pinned comment at the top of file - // For example: - // /*! Pinned Comment */ - // - // var x = 10; - if (node.pos === 0) { - leadingComments = ts.filter(ts.getLeadingCommentRanges(currentSourceFile.text, node.pos), isPinnedComments); - } - } - else { - // removeComments is false, just get detached as normal and bypass the process to filter comment - leadingComments = ts.getLeadingCommentRanges(currentSourceFile.text, node.pos); - } - if (leadingComments) { - var detachedComments = []; - var lastComment; - ts.forEach(leadingComments, function (comment) { - if (lastComment) { - var lastCommentLine = ts.getLineOfLocalPosition(currentSourceFile, lastComment.end); - var commentLine = ts.getLineOfLocalPosition(currentSourceFile, comment.pos); - if (commentLine >= lastCommentLine + 2) { - // There was a blank line between the last comment and this comment. This - // comment is not part of the copyright comments. Return what we have so - // far. - return detachedComments; - } - } - detachedComments.push(comment); - lastComment = comment; - }); - if (detachedComments.length) { - // All comments look like they could have been part of the copyright header. Make - // sure there is at least one blank line between it and the node. If not, it's not - // a copyright header. - var lastCommentLine = ts.getLineOfLocalPosition(currentSourceFile, ts.lastOrUndefined(detachedComments).end); - var nodeLine = ts.getLineOfLocalPosition(currentSourceFile, ts.skipTrivia(currentSourceFile.text, node.pos)); - if (nodeLine >= lastCommentLine + 2) { - // Valid detachedComments - ts.emitNewLineBeforeLeadingComments(currentSourceFile, writer, node, leadingComments); - ts.emitComments(currentSourceFile, writer, detachedComments, /*trailingSeparator*/ true, newLine, writeComment); - var currentDetachedCommentInfo = { nodePos: node.pos, detachedCommentEndPos: ts.lastOrUndefined(detachedComments).end }; - if (detachedCommentsInfo) { - detachedCommentsInfo.push(currentDetachedCommentInfo); - } - else { - detachedCommentsInfo = [currentDetachedCommentInfo]; - } - } - } - } - } - function emitShebang() { - var shebang = ts.getShebang(currentSourceFile.text); - if (shebang) { - write(shebang); - } - } - } - function emitFile(jsFilePath, sourceFile) { - emitJavaScript(jsFilePath, sourceFile); - if (compilerOptions.declaration) { - ts.writeDeclarationFile(jsFilePath, sourceFile, host, resolver, diagnostics); - } - } - } - ts.emitFiles = emitFiles; var entities = { "quot": 0x0022, "amp": 0x0026, @@ -35261,6 +29422,6531 @@ var ts; "hearts": 0x2665, "diams": 0x2666 }; + // Flags enum to track count of temp variables and a few dedicated names + var TempFlags; + (function (TempFlags) { + TempFlags[TempFlags["Auto"] = 0] = "Auto"; + TempFlags[TempFlags["CountMask"] = 268435455] = "CountMask"; + TempFlags[TempFlags["_i"] = 268435456] = "_i"; + })(TempFlags || (TempFlags = {})); + // 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) { + // emit output for the __extends helper function + var extendsHelper = "\nvar __extends = (this && this.__extends) || function (d, b) {\n for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];\n function __() { this.constructor = d; }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n};"; + // emit output for the __decorate helper function + var decorateHelper = "\nvar __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\n return c > 3 && r && Object.defineProperty(target, key, r), r;\n};"; + // emit output for the __metadata helper function + var metadataHelper = "\nvar __metadata = (this && this.__metadata) || function (k, v) {\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(k, v);\n};"; + // emit output for the __param helper function + var paramHelper = "\nvar __param = (this && this.__param) || function (paramIndex, decorator) {\n return function (target, key) { decorator(target, key, paramIndex); }\n};"; + var awaiterHelper = "\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promise, generator) {\n return new Promise(function (resolve, reject) {\n generator = generator.call(thisArg, _arguments);\n function cast(value) { return value instanceof Promise && value.constructor === Promise ? value : new Promise(function (resolve) { resolve(value); }); }\n function onfulfill(value) { try { step(\"next\", value); } catch (e) { reject(e); } }\n function onreject(value) { try { step(\"throw\", value); } catch (e) { reject(e); } }\n function step(verb, value) {\n var result = generator[verb](value);\n result.done ? resolve(result.value) : cast(result.value).then(onfulfill, onreject);\n }\n step(\"next\", void 0);\n });\n};"; + var compilerOptions = host.getCompilerOptions(); + var languageVersion = compilerOptions.target || 0 /* ES3 */; + var modulekind = compilerOptions.module ? compilerOptions.module : languageVersion === 2 /* ES6 */ ? 5 /* ES6 */ : 0 /* None */; + var sourceMapDataList = compilerOptions.sourceMap || compilerOptions.inlineSourceMap ? [] : undefined; + var diagnostics = []; + var newLine = host.getNewLine(); + var jsxDesugaring = host.getCompilerOptions().jsx !== 1 /* Preserve */; + var shouldEmitJsx = function (s) { return (s.languageVariant === 1 /* JSX */ && !jsxDesugaring); }; + if (targetSourceFile === undefined) { + ts.forEach(host.getSourceFiles(), function (sourceFile) { + if (ts.shouldEmitToOwnFile(sourceFile, compilerOptions)) { + var jsFilePath = ts.getOwnEmitOutputFilePath(sourceFile, host, shouldEmitJsx(sourceFile) ? ".jsx" : ".js"); + emitFile(jsFilePath, sourceFile); + } + }); + if (compilerOptions.outFile || compilerOptions.out) { + emitFile(compilerOptions.outFile || compilerOptions.out); + } + } + else { + // targetSourceFile is specified (e.g calling emitter from language service or calling getSemanticDiagnostic from language service) + if (ts.shouldEmitToOwnFile(targetSourceFile, compilerOptions)) { + var jsFilePath = ts.getOwnEmitOutputFilePath(targetSourceFile, host, shouldEmitJsx(targetSourceFile) ? ".jsx" : ".js"); + emitFile(jsFilePath, targetSourceFile); + } + else if (!ts.isDeclarationFile(targetSourceFile) && (compilerOptions.outFile || compilerOptions.out)) { + emitFile(compilerOptions.outFile || compilerOptions.out); + } + } + // Sort and make the unique list of diagnostics + diagnostics = ts.sortAndDeduplicateDiagnostics(diagnostics); + return { + emitSkipped: false, + diagnostics: diagnostics, + sourceMaps: sourceMapDataList + }; + function isNodeDescendentOf(node, ancestor) { + while (node) { + if (node === ancestor) + return true; + node = node.parent; + } + return false; + } + function isUniqueLocalName(name, container) { + for (var node = container; isNodeDescendentOf(node, container); node = node.nextContainer) { + if (node.locals && ts.hasProperty(node.locals, name)) { + // We conservatively include alias symbols to cover cases where they're emitted as locals + if (node.locals[name].flags & (107455 /* Value */ | 1048576 /* ExportValue */ | 8388608 /* Alias */)) { + return false; + } + } + } + return true; + } + function emitJavaScript(jsFilePath, root) { + var writer = ts.createTextWriter(newLine); + var write = writer.write, writeTextOfNode = writer.writeTextOfNode, writeLine = writer.writeLine, increaseIndent = writer.increaseIndent, decreaseIndent = writer.decreaseIndent; + var currentSourceFile; + // name of an exporter function if file is a System external module + // System.register([...], function () {...}) + // exporting in System modules looks like: + // export var x; ... x = 1 + // => + // var x;... exporter("x", x = 1) + var exportFunctionForFile; + var generatedNameSet = {}; + var nodeToGeneratedName = []; + var computedPropertyNamesToGeneratedNames; + var extendsEmitted = false; + var decorateEmitted = false; + var paramEmitted = false; + var awaiterEmitted = false; + var tempFlags = 0; + var tempVariables; + var tempParameters; + var externalImports; + var exportSpecifiers; + var exportEquals; + var hasExportStars; + /** Write emitted output to disk */ + var writeEmittedFiles = writeJavaScriptFile; + var detachedCommentsInfo; + var writeComment = ts.writeCommentRange; + /** Emit a node */ + var emit = emitNodeWithCommentsAndWithoutSourcemap; + /** Called just before starting emit of a node */ + var emitStart = function (node) { }; + /** Called once the emit of the node is done */ + var emitEnd = function (node) { }; + /** Emit the text for the given token that comes after startPos + * This by default writes the text provided with the given tokenKind + * but if optional emitFn callback is provided the text is emitted using the callback instead of default text + * @param tokenKind the kind of the token to search and emit + * @param startPos the position in the source to start searching for the token + * @param emitFn if given will be invoked to emit the text instead of actual token emit */ + var emitToken = emitTokenText; + /** Called to before starting the lexical scopes as in function/class in the emitted code because of node + * @param scopeDeclaration node that starts the lexical scope + * @param scopeName Optional name of this scope instead of deducing one from the declaration node */ + var scopeEmitStart = function (scopeDeclaration, scopeName) { }; + /** Called after coming out of the scope */ + var scopeEmitEnd = function () { }; + /** Sourcemap data that will get encoded */ + var sourceMapData; + /** If removeComments is true, no leading-comments needed to be emitted **/ + var emitLeadingCommentsOfPosition = compilerOptions.removeComments ? function (pos) { } : emitLeadingCommentsOfPositionWorker; + var moduleEmitDelegates = (_a = {}, + _a[5 /* ES6 */] = emitES6Module, + _a[2 /* AMD */] = emitAMDModule, + _a[4 /* System */] = emitSystemModule, + _a[3 /* UMD */] = emitUMDModule, + _a[1 /* CommonJS */] = emitCommonJSModule, + _a + ); + if (compilerOptions.sourceMap || compilerOptions.inlineSourceMap) { + initializeEmitterWithSourceMaps(); + } + if (root) { + // Do not call emit directly. It does not set the currentSourceFile. + emitSourceFile(root); + } + else { + ts.forEach(host.getSourceFiles(), function (sourceFile) { + if (!isExternalModuleOrDeclarationFile(sourceFile)) { + emitSourceFile(sourceFile); + } + }); + } + writeLine(); + writeEmittedFiles(writer.getText(), /*writeByteOrderMark*/ compilerOptions.emitBOM); + return; + function emitSourceFile(sourceFile) { + currentSourceFile = sourceFile; + exportFunctionForFile = undefined; + emit(sourceFile); + } + function isUniqueName(name) { + return !resolver.hasGlobalName(name) && + !ts.hasProperty(currentSourceFile.identifiers, name) && + !ts.hasProperty(generatedNameSet, name); + } + // Return the next available name in the pattern _a ... _z, _0, _1, ... + // TempFlags._i or TempFlags._n may be used to express a preference for that dedicated name. + // Note that names generated by makeTempVariableName and makeUniqueName will never conflict. + function makeTempVariableName(flags) { + if (flags && !(tempFlags & flags)) { + var name_19 = flags === 268435456 /* _i */ ? "_i" : "_n"; + if (isUniqueName(name_19)) { + tempFlags |= flags; + return name_19; + } + } + while (true) { + var count = tempFlags & 268435455 /* CountMask */; + tempFlags++; + // Skip over 'i' and 'n' + if (count !== 8 && count !== 13) { + var name_20 = count < 26 ? "_" + String.fromCharCode(97 /* a */ + count) : "_" + (count - 26); + if (isUniqueName(name_20)) { + return name_20; + } + } + } + } + // Generate a name that is unique within the current file and doesn't conflict with any names + // in global scope. The name is formed by adding an '_n' suffix to the specified base name, + // where n is a positive integer. Note that names generated by makeTempVariableName and + // makeUniqueName are guaranteed to never conflict. + function makeUniqueName(baseName) { + // Find the first unique 'name_n', where n is a positive number + if (baseName.charCodeAt(baseName.length - 1) !== 95 /* _ */) { + baseName += "_"; + } + var i = 1; + while (true) { + var generatedName = baseName + i; + if (isUniqueName(generatedName)) { + return generatedNameSet[generatedName] = generatedName; + } + i++; + } + } + function generateNameForModuleOrEnum(node) { + var name = node.name.text; + // Use module/enum name itself if it is unique, otherwise make a unique variation + return isUniqueLocalName(name, node) ? name : makeUniqueName(name); + } + function generateNameForImportOrExportDeclaration(node) { + var expr = ts.getExternalModuleName(node); + var baseName = expr.kind === 9 /* StringLiteral */ ? + ts.escapeIdentifier(ts.makeIdentifierFromModuleName(expr.text)) : "module"; + return makeUniqueName(baseName); + } + function generateNameForExportDefault() { + return makeUniqueName("default"); + } + function generateNameForClassExpression() { + return makeUniqueName("class"); + } + function generateNameForNode(node) { + switch (node.kind) { + case 69 /* Identifier */: + return makeUniqueName(node.text); + case 218 /* ModuleDeclaration */: + case 217 /* EnumDeclaration */: + return generateNameForModuleOrEnum(node); + case 222 /* ImportDeclaration */: + case 228 /* ExportDeclaration */: + return generateNameForImportOrExportDeclaration(node); + case 213 /* FunctionDeclaration */: + case 214 /* ClassDeclaration */: + case 227 /* ExportAssignment */: + return generateNameForExportDefault(); + case 186 /* ClassExpression */: + return generateNameForClassExpression(); + } + } + function getGeneratedNameForNode(node) { + var id = ts.getNodeId(node); + return nodeToGeneratedName[id] || (nodeToGeneratedName[id] = ts.unescapeIdentifier(generateNameForNode(node))); + } + function initializeEmitterWithSourceMaps() { + var sourceMapDir; // The directory in which sourcemap will be + // Current source map file and its index in the sources list + var sourceMapSourceIndex = -1; + // Names and its index map + var sourceMapNameIndexMap = {}; + var sourceMapNameIndices = []; + function getSourceMapNameIndex() { + return sourceMapNameIndices.length ? ts.lastOrUndefined(sourceMapNameIndices) : -1; + } + // Last recorded and encoded spans + var lastRecordedSourceMapSpan; + var lastEncodedSourceMapSpan = { + emittedLine: 1, + emittedColumn: 1, + sourceLine: 1, + sourceColumn: 1, + sourceIndex: 0 + }; + var lastEncodedNameIndex = 0; + // Encoding for sourcemap span + function encodeLastRecordedSourceMapSpan() { + if (!lastRecordedSourceMapSpan || lastRecordedSourceMapSpan === lastEncodedSourceMapSpan) { + return; + } + var prevEncodedEmittedColumn = lastEncodedSourceMapSpan.emittedColumn; + // Line/Comma delimiters + if (lastEncodedSourceMapSpan.emittedLine === lastRecordedSourceMapSpan.emittedLine) { + // Emit comma to separate the entry + if (sourceMapData.sourceMapMappings) { + sourceMapData.sourceMapMappings += ","; + } + } + else { + // Emit line delimiters + for (var encodedLine = lastEncodedSourceMapSpan.emittedLine; encodedLine < lastRecordedSourceMapSpan.emittedLine; encodedLine++) { + sourceMapData.sourceMapMappings += ";"; + } + prevEncodedEmittedColumn = 1; + } + // 1. Relative Column 0 based + sourceMapData.sourceMapMappings += base64VLQFormatEncode(lastRecordedSourceMapSpan.emittedColumn - prevEncodedEmittedColumn); + // 2. Relative sourceIndex + sourceMapData.sourceMapMappings += base64VLQFormatEncode(lastRecordedSourceMapSpan.sourceIndex - lastEncodedSourceMapSpan.sourceIndex); + // 3. Relative sourceLine 0 based + sourceMapData.sourceMapMappings += base64VLQFormatEncode(lastRecordedSourceMapSpan.sourceLine - lastEncodedSourceMapSpan.sourceLine); + // 4. Relative sourceColumn 0 based + sourceMapData.sourceMapMappings += base64VLQFormatEncode(lastRecordedSourceMapSpan.sourceColumn - lastEncodedSourceMapSpan.sourceColumn); + // 5. Relative namePosition 0 based + if (lastRecordedSourceMapSpan.nameIndex >= 0) { + sourceMapData.sourceMapMappings += base64VLQFormatEncode(lastRecordedSourceMapSpan.nameIndex - lastEncodedNameIndex); + lastEncodedNameIndex = lastRecordedSourceMapSpan.nameIndex; + } + lastEncodedSourceMapSpan = lastRecordedSourceMapSpan; + sourceMapData.sourceMapDecodedMappings.push(lastEncodedSourceMapSpan); + function base64VLQFormatEncode(inValue) { + function base64FormatEncode(inValue) { + if (inValue < 64) { + return "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(inValue); + } + throw TypeError(inValue + ": not a 64 based value"); + } + // Add a new least significant bit that has the sign of the value. + // if negative number the least significant bit that gets added to the number has value 1 + // else least significant bit value that gets added is 0 + // eg. -1 changes to binary : 01 [1] => 3 + // +1 changes to binary : 01 [0] => 2 + if (inValue < 0) { + inValue = ((-inValue) << 1) + 1; + } + else { + inValue = inValue << 1; + } + // Encode 5 bits at a time starting from least significant bits + var encodedStr = ""; + do { + var currentDigit = inValue & 31; // 11111 + inValue = inValue >> 5; + if (inValue > 0) { + // There are still more digits to decode, set the msb (6th bit) + currentDigit = currentDigit | 32; + } + encodedStr = encodedStr + base64FormatEncode(currentDigit); + } while (inValue > 0); + return encodedStr; + } + } + function recordSourceMapSpan(pos) { + var sourceLinePos = ts.getLineAndCharacterOfPosition(currentSourceFile, pos); + // Convert the location to be one-based. + sourceLinePos.line++; + sourceLinePos.character++; + var emittedLine = writer.getLine(); + var emittedColumn = writer.getColumn(); + // If this location wasn't recorded or the location in source is going backwards, record the span + if (!lastRecordedSourceMapSpan || + lastRecordedSourceMapSpan.emittedLine !== emittedLine || + lastRecordedSourceMapSpan.emittedColumn !== emittedColumn || + (lastRecordedSourceMapSpan.sourceIndex === sourceMapSourceIndex && + (lastRecordedSourceMapSpan.sourceLine > sourceLinePos.line || + (lastRecordedSourceMapSpan.sourceLine === sourceLinePos.line && lastRecordedSourceMapSpan.sourceColumn > sourceLinePos.character)))) { + // Encode the last recordedSpan before assigning new + encodeLastRecordedSourceMapSpan(); + // New span + lastRecordedSourceMapSpan = { + emittedLine: emittedLine, + emittedColumn: emittedColumn, + sourceLine: sourceLinePos.line, + sourceColumn: sourceLinePos.character, + nameIndex: getSourceMapNameIndex(), + sourceIndex: sourceMapSourceIndex + }; + } + 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; + } + } + function recordEmitNodeStartSpan(node) { + // Get the token pos after skipping to the token (ignoring the leading trivia) + recordSourceMapSpan(ts.skipTrivia(currentSourceFile.text, node.pos)); + } + function recordEmitNodeEndSpan(node) { + recordSourceMapSpan(node.end); + } + function writeTextWithSpanRecord(tokenKind, startPos, emitFn) { + var tokenStartPos = ts.skipTrivia(currentSourceFile.text, startPos); + recordSourceMapSpan(tokenStartPos); + var tokenEndPos = emitTokenText(tokenKind, tokenStartPos, emitFn); + recordSourceMapSpan(tokenEndPos); + return tokenEndPos; + } + function recordNewSourceFileStart(node) { + // Add the file to tsFilePaths + // If sourceroot option: Use the relative path corresponding to the common directory path + // otherwise source locations relative to map file location + var sourcesDirectoryPath = compilerOptions.sourceRoot ? host.getCommonSourceDirectory() : sourceMapDir; + sourceMapData.sourceMapSources.push(ts.getRelativePathToDirectoryOrUrl(sourcesDirectoryPath, node.fileName, host.getCurrentDirectory(), host.getCanonicalFileName, + /*isAbsolutePathAnUrl*/ true)); + sourceMapSourceIndex = sourceMapData.sourceMapSources.length - 1; + // The one that can be used from program to get the actual source file + sourceMapData.inputSourceFileNames.push(node.fileName); + if (compilerOptions.inlineSources) { + if (!sourceMapData.sourceMapSourcesContent) { + sourceMapData.sourceMapSourcesContent = []; + } + sourceMapData.sourceMapSourcesContent.push(node.text); + } + } + function recordScopeNameOfNode(node, scopeName) { + function recordScopeNameIndex(scopeNameIndex) { + sourceMapNameIndices.push(scopeNameIndex); + } + function recordScopeNameStart(scopeName) { + var scopeNameIndex = -1; + if (scopeName) { + var parentIndex = getSourceMapNameIndex(); + if (parentIndex !== -1) { + // Child scopes are always shown with a dot (even if they have no name), + // unless it is a computed property. Then it is shown with brackets, + // but the brackets are included in the name. + var name_21 = node.name; + if (!name_21 || name_21.kind !== 136 /* ComputedPropertyName */) { + scopeName = "." + scopeName; + } + scopeName = sourceMapData.sourceMapNames[parentIndex] + scopeName; + } + scopeNameIndex = ts.getProperty(sourceMapNameIndexMap, scopeName); + if (scopeNameIndex === undefined) { + scopeNameIndex = sourceMapData.sourceMapNames.length; + sourceMapData.sourceMapNames.push(scopeName); + sourceMapNameIndexMap[scopeName] = scopeNameIndex; + } + } + recordScopeNameIndex(scopeNameIndex); + } + if (scopeName) { + // The scope was already given a name use it + recordScopeNameStart(scopeName); + } + else if (node.kind === 213 /* FunctionDeclaration */ || + node.kind === 173 /* FunctionExpression */ || + node.kind === 143 /* MethodDeclaration */ || + node.kind === 142 /* MethodSignature */ || + node.kind === 145 /* GetAccessor */ || + node.kind === 146 /* SetAccessor */ || + node.kind === 218 /* ModuleDeclaration */ || + node.kind === 214 /* ClassDeclaration */ || + node.kind === 217 /* EnumDeclaration */) { + // Declaration and has associated name use it + if (node.name) { + var name_22 = node.name; + // For computed property names, the text will include the brackets + scopeName = name_22.kind === 136 /* ComputedPropertyName */ + ? ts.getTextOfNode(name_22) + : node.name.text; + } + recordScopeNameStart(scopeName); + } + else { + // Block just use the name from upper level scope + recordScopeNameIndex(getSourceMapNameIndex()); + } + } + function recordScopeNameEnd() { + sourceMapNameIndices.pop(); + } + ; + function writeCommentRangeWithMap(curentSourceFile, writer, comment, newLine) { + recordSourceMapSpan(comment.pos); + ts.writeCommentRange(currentSourceFile, writer, comment, newLine); + recordSourceMapSpan(comment.end); + } + function serializeSourceMapContents(version, file, sourceRoot, sources, names, mappings, sourcesContent) { + if (typeof JSON !== "undefined") { + var map_1 = { + version: version, + file: file, + sourceRoot: sourceRoot, + sources: sources, + names: names, + mappings: mappings + }; + if (sourcesContent !== undefined) { + map_1.sourcesContent = sourcesContent; + } + return JSON.stringify(map_1); + } + return "{\"version\":" + version + ",\"file\":\"" + ts.escapeString(file) + "\",\"sourceRoot\":\"" + ts.escapeString(sourceRoot) + "\",\"sources\":[" + serializeStringArray(sources) + "],\"names\":[" + serializeStringArray(names) + "],\"mappings\":\"" + ts.escapeString(mappings) + "\" " + (sourcesContent !== undefined ? ",\"sourcesContent\":[" + serializeStringArray(sourcesContent) + "]" : "") + "}"; + function serializeStringArray(list) { + var output = ""; + for (var i = 0, n = list.length; i < n; i++) { + if (i) { + output += ","; + } + output += "\"" + ts.escapeString(list[i]) + "\""; + } + return output; + } + } + function writeJavaScriptAndSourceMapFile(emitOutput, writeByteOrderMark) { + encodeLastRecordedSourceMapSpan(); + var sourceMapText = serializeSourceMapContents(3, sourceMapData.sourceMapFile, sourceMapData.sourceMapSourceRoot, sourceMapData.sourceMapSources, sourceMapData.sourceMapNames, sourceMapData.sourceMapMappings, sourceMapData.sourceMapSourcesContent); + sourceMapDataList.push(sourceMapData); + var sourceMapUrl; + if (compilerOptions.inlineSourceMap) { + // Encode the sourceMap into the sourceMap url + var base64SourceMapText = ts.convertToBase64(sourceMapText); + sourceMapUrl = "//# sourceMappingURL=data:application/json;base64," + base64SourceMapText; + } + else { + // Write source map file + ts.writeFile(host, diagnostics, sourceMapData.sourceMapFilePath, sourceMapText, /*writeByteOrderMark*/ false); + sourceMapUrl = "//# sourceMappingURL=" + sourceMapData.jsSourceMappingURL; + } + // Write sourcemap url to the js file and write the js file + writeJavaScriptFile(emitOutput + sourceMapUrl, writeByteOrderMark); + } + // Initialize source map data + var sourceMapJsFile = ts.getBaseFileName(ts.normalizeSlashes(jsFilePath)); + sourceMapData = { + sourceMapFilePath: jsFilePath + ".map", + jsSourceMappingURL: sourceMapJsFile + ".map", + sourceMapFile: sourceMapJsFile, + sourceMapSourceRoot: compilerOptions.sourceRoot || "", + sourceMapSources: [], + inputSourceFileNames: [], + sourceMapNames: [], + sourceMapMappings: "", + sourceMapSourcesContent: undefined, + sourceMapDecodedMappings: [] + }; + // Normalize source root and make sure it has trailing "/" so that it can be used to combine paths with the + // relative paths of the sources list in the sourcemap + sourceMapData.sourceMapSourceRoot = ts.normalizeSlashes(sourceMapData.sourceMapSourceRoot); + if (sourceMapData.sourceMapSourceRoot.length && sourceMapData.sourceMapSourceRoot.charCodeAt(sourceMapData.sourceMapSourceRoot.length - 1) !== 47 /* slash */) { + sourceMapData.sourceMapSourceRoot += ts.directorySeparator; + } + if (compilerOptions.mapRoot) { + sourceMapDir = ts.normalizeSlashes(compilerOptions.mapRoot); + if (root) { + // For modules or multiple emit files the mapRoot will have directory structure like the sources + // So if src\a.ts and src\lib\b.ts are compiled together user would be moving the maps into mapRoot\a.js.map and mapRoot\lib\b.js.map + sourceMapDir = ts.getDirectoryPath(ts.getSourceFilePathInNewDir(root, host, sourceMapDir)); + } + if (!ts.isRootedDiskPath(sourceMapDir) && !ts.isUrl(sourceMapDir)) { + // The relative paths are relative to the common directory + sourceMapDir = ts.combinePaths(host.getCommonSourceDirectory(), sourceMapDir); + sourceMapData.jsSourceMappingURL = ts.getRelativePathToDirectoryOrUrl(ts.getDirectoryPath(ts.normalizePath(jsFilePath)), // get the relative sourceMapDir path based on jsFilePath + ts.combinePaths(sourceMapDir, sourceMapData.jsSourceMappingURL), // this is where user expects to see sourceMap + host.getCurrentDirectory(), host.getCanonicalFileName, + /*isAbsolutePathAnUrl*/ true); + } + else { + sourceMapData.jsSourceMappingURL = ts.combinePaths(sourceMapDir, sourceMapData.jsSourceMappingURL); + } + } + else { + sourceMapDir = ts.getDirectoryPath(ts.normalizePath(jsFilePath)); + } + function emitNodeWithSourceMap(node) { + if (node) { + if (ts.nodeIsSynthesized(node)) { + return emitNodeWithoutSourceMap(node); + } + if (node.kind !== 248 /* SourceFile */) { + recordEmitNodeStartSpan(node); + emitNodeWithoutSourceMap(node); + recordEmitNodeEndSpan(node); + } + else { + recordNewSourceFileStart(node); + emitNodeWithoutSourceMap(node); + } + } + } + function emitNodeWithCommentsAndWithSourcemap(node) { + emitNodeConsideringCommentsOption(node, emitNodeWithSourceMap); + } + writeEmittedFiles = writeJavaScriptAndSourceMapFile; + emit = emitNodeWithCommentsAndWithSourcemap; + emitStart = recordEmitNodeStartSpan; + emitEnd = recordEmitNodeEndSpan; + emitToken = writeTextWithSpanRecord; + scopeEmitStart = recordScopeNameOfNode; + scopeEmitEnd = recordScopeNameEnd; + writeComment = writeCommentRangeWithMap; + } + function writeJavaScriptFile(emitOutput, writeByteOrderMark) { + ts.writeFile(host, diagnostics, jsFilePath, emitOutput, writeByteOrderMark); + } + // Create a temporary variable with a unique unused name. + function createTempVariable(flags) { + var result = ts.createSynthesizedNode(69 /* Identifier */); + result.text = makeTempVariableName(flags); + return result; + } + function recordTempDeclaration(name) { + if (!tempVariables) { + tempVariables = []; + } + tempVariables.push(name); + } + function createAndRecordTempVariable(flags) { + var temp = createTempVariable(flags); + recordTempDeclaration(temp); + return temp; + } + function emitTempDeclarations(newLine) { + if (tempVariables) { + if (newLine) { + writeLine(); + } + else { + write(" "); + } + write("var "); + emitCommaList(tempVariables); + write(";"); + } + } + function emitTokenText(tokenKind, startPos, emitFn) { + var tokenString = ts.tokenToString(tokenKind); + if (emitFn) { + emitFn(); + } + else { + write(tokenString); + } + return startPos + tokenString.length; + } + function emitOptional(prefix, node) { + if (node) { + write(prefix); + emit(node); + } + } + function emitParenthesizedIf(node, parenthesized) { + if (parenthesized) { + write("("); + } + emit(node); + if (parenthesized) { + write(")"); + } + } + function emitTrailingCommaIfPresent(nodeList) { + if (nodeList.hasTrailingComma) { + write(","); + } + } + function emitLinePreservingList(parent, nodes, allowTrailingComma, spacesBetweenBraces) { + ts.Debug.assert(nodes.length > 0); + increaseIndent(); + if (nodeStartPositionsAreOnSameLine(parent, nodes[0])) { + if (spacesBetweenBraces) { + write(" "); + } + } + else { + writeLine(); + } + for (var i = 0, n = nodes.length; i < n; i++) { + if (i) { + if (nodeEndIsOnSameLineAsNodeStart(nodes[i - 1], nodes[i])) { + write(", "); + } + else { + write(","); + writeLine(); + } + } + emit(nodes[i]); + } + if (nodes.hasTrailingComma && allowTrailingComma) { + write(","); + } + decreaseIndent(); + if (nodeEndPositionsAreOnSameLine(parent, ts.lastOrUndefined(nodes))) { + if (spacesBetweenBraces) { + write(" "); + } + } + else { + writeLine(); + } + } + function emitList(nodes, start, count, multiLine, trailingComma, leadingComma, noTrailingNewLine, emitNode) { + if (!emitNode) { + emitNode = emit; + } + for (var i = 0; i < count; i++) { + if (multiLine) { + if (i || leadingComma) { + write(","); + } + writeLine(); + } + else { + if (i || leadingComma) { + write(", "); + } + } + var node = nodes[start + i]; + // This emitting is to make sure we emit following comment properly + // ...(x, /*comment1*/ y)... + // ^ => node.pos + // "comment1" is not considered leading comment for "y" but rather + // considered as trailing comment of the previous node. + emitTrailingCommentsOfPosition(node.pos); + emitNode(node); + leadingComma = true; + } + if (trailingComma) { + write(","); + } + if (multiLine && !noTrailingNewLine) { + writeLine(); + } + return count; + } + function emitCommaList(nodes) { + if (nodes) { + emitList(nodes, 0, nodes.length, /*multiline*/ false, /*trailingComma*/ false); + } + } + function emitLines(nodes) { + emitLinesStartingAt(nodes, /*startIndex*/ 0); + } + function emitLinesStartingAt(nodes, startIndex) { + for (var i = startIndex; i < nodes.length; i++) { + writeLine(); + emit(nodes[i]); + } + } + function isBinaryOrOctalIntegerLiteral(node, text) { + if (node.kind === 8 /* NumericLiteral */ && text.length > 1) { + switch (text.charCodeAt(1)) { + case 98 /* b */: + case 66 /* B */: + case 111 /* o */: + case 79 /* O */: + return true; + } + } + return false; + } + function emitLiteral(node) { + var text = getLiteralText(node); + if ((compilerOptions.sourceMap || compilerOptions.inlineSourceMap) && (node.kind === 9 /* StringLiteral */ || ts.isTemplateLiteralKind(node.kind))) { + writer.writeLiteral(text); + } + else if (languageVersion < 2 /* ES6 */ && isBinaryOrOctalIntegerLiteral(node, text)) { + write(node.text); + } + else { + write(text); + } + } + function getLiteralText(node) { + // 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 */ && (ts.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 (node.parent) { + return ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, node); + } + // If we can't reach the original source text, use the canonical form if it's a number, + // or an escaped quoted form of the original text if it's string-like. + switch (node.kind) { + case 9 /* StringLiteral */: + return getQuotedEscapedLiteralText("\"", node.text, "\""); + case 11 /* NoSubstitutionTemplateLiteral */: + return getQuotedEscapedLiteralText("`", node.text, "`"); + case 12 /* TemplateHead */: + return getQuotedEscapedLiteralText("`", node.text, "${"); + case 13 /* TemplateMiddle */: + return getQuotedEscapedLiteralText("}", node.text, "${"); + case 14 /* TemplateTail */: + return getQuotedEscapedLiteralText("}", node.text, "`"); + case 8 /* NumericLiteral */: + return node.text; + } + ts.Debug.fail("Literal kind '" + node.kind + "' not accounted for."); + } + function getQuotedEscapedLiteralText(leftQuote, text, rightQuote) { + return leftQuote + ts.escapeNonAsciiCharacters(ts.escapeString(text)) + rightQuote; + } + function emitDownlevelRawTemplateLiteral(node) { + // 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"); + text = ts.escapeString(text); + write("\"" + text + "\""); + } + function emitDownlevelTaggedTemplateArray(node, literalEmitter) { + write("["); + if (node.template.kind === 11 /* NoSubstitutionTemplateLiteral */) { + literalEmitter(node.template); + } + else { + literalEmitter(node.template.head); + ts.forEach(node.template.templateSpans, function (child) { + write(", "); + literalEmitter(child.literal); + }); + } + write("]"); + } + function emitDownlevelTaggedTemplate(node) { + var tempVariable = createAndRecordTempVariable(0 /* Auto */); + write("("); + emit(tempVariable); + write(" = "); + emitDownlevelTaggedTemplateArray(node, emit); + write(", "); + emit(tempVariable); + write(".raw = "); + emitDownlevelTaggedTemplateArray(node, emitDownlevelRawTemplateLiteral); + write(", "); + emitParenthesizedIf(node.tag, needsParenthesisForPropertyAccessOrInvocation(node.tag)); + write("("); + emit(tempVariable); + // Now we emit the expressions + if (node.template.kind === 183 /* TemplateExpression */) { + ts.forEach(node.template.templateSpans, function (templateSpan) { + write(", "); + var needsParens = templateSpan.expression.kind === 181 /* BinaryExpression */ + && templateSpan.expression.operatorToken.kind === 24 /* CommaToken */; + emitParenthesizedIf(templateSpan.expression, needsParens); + }); + } + write("))"); + } + function emitTemplateExpression(node) { + // In ES6 mode and above, we can simply emit each portion of a template in order, but in + // ES3 & ES5 we must convert the template expression into a series of string concatenations. + if (languageVersion >= 2 /* ES6 */) { + ts.forEachChild(node, emit); + return; + } + var emitOuterParens = ts.isExpression(node.parent) + && templateNeedsParens(node, node.parent); + if (emitOuterParens) { + write("("); + } + var headEmitted = false; + if (shouldEmitTemplateHead()) { + emitLiteral(node.head); + headEmitted = true; + } + for (var i = 0, n = node.templateSpans.length; i < n; i++) { + var templateSpan = node.templateSpans[i]; + // Check if the expression has operands and binds its operands less closely than binary '+'. + // If it does, we need to wrap 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 needsParens = templateSpan.expression.kind !== 172 /* ParenthesizedExpression */ + && comparePrecedenceToBinaryPlus(templateSpan.expression) !== 1 /* GreaterThan */; + if (i > 0 || headEmitted) { + // If this is the first span and the head was not emitted, then this templateSpan's + // expression will be the first to be emitted. Don't emit the preceding ' + ' in that + // case. + write(" + "); + } + emitParenthesizedIf(templateSpan.expression, needsParens); + // 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 (templateSpan.literal.text.length !== 0) { + write(" + "); + emitLiteral(templateSpan.literal); + } + } + if (emitOuterParens) { + write(")"); + } + function shouldEmitTemplateHead() { + // If this expression has an empty head literal and the first template span has a non-empty + // literal, then emitting the empty head literal is not necessary. + // `${ foo } and ${ bar }` + // can be emitted as + // foo + " and " + bar + // This is because it is only required that one of the first two operands in the emit + // output must be a string literal, so that the other operand and all following operands + // are forced into strings. + // + // If the first template span has an empty literal, then the head must still be emitted. + // `${ foo }${ bar }` + // must still be emitted as + // "" + foo + bar + // 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; + } + function templateNeedsParens(template, parent) { + switch (parent.kind) { + case 168 /* CallExpression */: + case 169 /* NewExpression */: + return parent.expression === template; + case 170 /* TaggedTemplateExpression */: + case 172 /* ParenthesizedExpression */: + return false; + default: + return comparePrecedenceToBinaryPlus(parent) !== -1 /* LessThan */; + } + } + /** + * Returns whether the expression has lesser, greater, + * or equal precedence to the binary '+' operator + */ + function comparePrecedenceToBinaryPlus(expression) { + // All binary expressions have lower precedence than '+' apart from '*', '/', and '%' + // which have greater precedence and '-' which has equal precedence. + // All unary operators have a higher precedence apart from yield. + // Arrow functions and conditionals have a lower precedence, + // although we convert the former into regular function expressions in ES5 mode, + // and in ES6 mode this function won't get called anyway. + // + // TODO (drosen): Note that we need to account for the upcoming 'yield' and + // spread ('...') unary operators that are anticipated for ES6. + switch (expression.kind) { + case 181 /* BinaryExpression */: + switch (expression.operatorToken.kind) { + case 37 /* AsteriskToken */: + case 39 /* SlashToken */: + case 40 /* PercentToken */: + return 1 /* GreaterThan */; + case 35 /* PlusToken */: + case 36 /* MinusToken */: + return 0 /* EqualTo */; + default: + return -1 /* LessThan */; + } + case 184 /* YieldExpression */: + case 182 /* ConditionalExpression */: + return -1 /* LessThan */; + default: + return 1 /* GreaterThan */; + } + } + } + function emitTemplateSpan(span) { + emit(span.expression); + emit(span.literal); + } + function jsxEmitReact(node) { + /// Emit a tag name, which is either '"div"' for lower-cased names, or + /// 'Div' for upper-cased or dotted names + function emitTagName(name) { + if (name.kind === 69 /* Identifier */ && ts.isIntrinsicJsxName(name.text)) { + write("\""); + emit(name); + write("\""); + } + else { + emit(name); + } + } + /// Emit an attribute name, which is quoted if it needs to be quoted. Because + /// these emit into an object literal property name, we don't need to be worried + /// about keywords, just non-identifier characters + function emitAttributeName(name) { + if (/[A-Za-z_]+[\w*]/.test(name.text)) { + write("\""); + emit(name); + write("\""); + } + else { + emit(name); + } + } + /// Emit an name/value pair for an attribute (e.g. "x: 3") + function emitJsxAttribute(node) { + emitAttributeName(node.name); + write(": "); + if (node.initializer) { + emit(node.initializer); + } + else { + write("true"); + } + } + function emitJsxElement(openingNode, children) { + var syntheticReactRef = ts.createSynthesizedNode(69 /* Identifier */); + syntheticReactRef.text = "React"; + syntheticReactRef.parent = openingNode; + // Call React.createElement(tag, ... + emitLeadingComments(openingNode); + emitExpressionIdentifier(syntheticReactRef); + write(".createElement("); + emitTagName(openingNode.tagName); + write(", "); + // Attribute list + if (openingNode.attributes.length === 0) { + // When there are no attributes, React wants "null" + write("null"); + } + else { + // Either emit one big object literal (no spread attribs), or + // a call to React.__spread + var attrs = openingNode.attributes; + if (ts.forEach(attrs, function (attr) { return attr.kind === 239 /* JsxSpreadAttribute */; })) { + emitExpressionIdentifier(syntheticReactRef); + write(".__spread("); + var haveOpenedObjectLiteral = false; + for (var i_1 = 0; i_1 < attrs.length; i_1++) { + if (attrs[i_1].kind === 239 /* JsxSpreadAttribute */) { + // If this is the first argument, we need to emit a {} as the first argument + if (i_1 === 0) { + write("{}, "); + } + if (haveOpenedObjectLiteral) { + write("}"); + haveOpenedObjectLiteral = false; + } + if (i_1 > 0) { + write(", "); + } + emit(attrs[i_1].expression); + } + else { + ts.Debug.assert(attrs[i_1].kind === 238 /* JsxAttribute */); + if (haveOpenedObjectLiteral) { + write(", "); + } + else { + haveOpenedObjectLiteral = true; + if (i_1 > 0) { + write(", "); + } + write("{"); + } + emitJsxAttribute(attrs[i_1]); + } + } + if (haveOpenedObjectLiteral) + write("}"); + write(")"); // closing paren to React.__spread( + } + else { + // One object literal with all the attributes in them + write("{"); + for (var i = 0; i < attrs.length; i++) { + if (i > 0) { + write(", "); + } + emitJsxAttribute(attrs[i]); + } + write("}"); + } + } + // Children + if (children) { + for (var i = 0; i < children.length; i++) { + // Don't emit empty expressions + if (children[i].kind === 240 /* JsxExpression */ && !(children[i].expression)) { + continue; + } + // Don't emit empty strings + if (children[i].kind === 236 /* JsxText */) { + var text = getTextToEmit(children[i]); + if (text !== undefined) { + write(", \""); + write(text); + write("\""); + } + } + else { + write(", "); + emit(children[i]); + } + } + } + // Closing paren + write(")"); // closes "React.createElement(" + emitTrailingComments(openingNode); + } + if (node.kind === 233 /* JsxElement */) { + emitJsxElement(node.openingElement, node.children); + } + else { + ts.Debug.assert(node.kind === 234 /* JsxSelfClosingElement */); + emitJsxElement(node); + } + } + function jsxEmitPreserve(node) { + function emitJsxAttribute(node) { + emit(node.name); + if (node.initializer) { + write("="); + emit(node.initializer); + } + } + function emitJsxSpreadAttribute(node) { + write("{..."); + emit(node.expression); + write("}"); + } + function emitAttributes(attribs) { + for (var i = 0, n = attribs.length; i < n; i++) { + if (i > 0) { + write(" "); + } + if (attribs[i].kind === 239 /* JsxSpreadAttribute */) { + emitJsxSpreadAttribute(attribs[i]); + } + else { + ts.Debug.assert(attribs[i].kind === 238 /* JsxAttribute */); + emitJsxAttribute(attribs[i]); + } + } + } + function emitJsxOpeningOrSelfClosingElement(node) { + write("<"); + emit(node.tagName); + if (node.attributes.length > 0 || (node.kind === 234 /* JsxSelfClosingElement */)) { + write(" "); + } + emitAttributes(node.attributes); + if (node.kind === 234 /* JsxSelfClosingElement */) { + write("/>"); + } + else { + write(">"); + } + } + function emitJsxClosingElement(node) { + write(""); + } + function emitJsxElement(node) { + emitJsxOpeningOrSelfClosingElement(node.openingElement); + for (var i = 0, n = node.children.length; i < n; i++) { + emit(node.children[i]); + } + emitJsxClosingElement(node.closingElement); + } + if (node.kind === 233 /* JsxElement */) { + emitJsxElement(node); + } + else { + ts.Debug.assert(node.kind === 234 /* JsxSelfClosingElement */); + emitJsxOpeningOrSelfClosingElement(node); + } + } + // This function specifically handles numeric/string literals for enum and accessor 'identifiers'. + // In a sense, it does not actually emit identifiers as much as it declares a name for a specific property. + // For example, this is utilized when feeding in a result to Object.defineProperty. + function emitExpressionForPropertyName(node) { + ts.Debug.assert(node.kind !== 163 /* BindingElement */); + if (node.kind === 9 /* StringLiteral */) { + emitLiteral(node); + } + else if (node.kind === 136 /* ComputedPropertyName */) { + // if this is a decorated computed property, we will need to capture the result + // of the property expression so that we can apply decorators later. This is to ensure + // we don't introduce unintended side effects: + // + // class C { + // [_a = x]() { } + // } + // + // The emit for the decorated computed property decorator is: + // + // __decorate([dec], C.prototype, _a, Object.getOwnPropertyDescriptor(C.prototype, _a)); + // + if (ts.nodeIsDecorated(node.parent)) { + if (!computedPropertyNamesToGeneratedNames) { + computedPropertyNamesToGeneratedNames = []; + } + var generatedName = computedPropertyNamesToGeneratedNames[ts.getNodeId(node)]; + if (generatedName) { + // we have already generated a variable for this node, write that value instead. + write(generatedName); + return; + } + generatedName = createAndRecordTempVariable(0 /* Auto */).text; + computedPropertyNamesToGeneratedNames[ts.getNodeId(node)] = generatedName; + write(generatedName); + write(" = "); + } + emit(node.expression); + } + else { + write("\""); + if (node.kind === 8 /* NumericLiteral */) { + write(node.text); + } + else { + writeTextOfNode(currentSourceFile, node); + } + write("\""); + } + } + function isExpressionIdentifier(node) { + var parent = node.parent; + switch (parent.kind) { + case 164 /* ArrayLiteralExpression */: + case 189 /* AsExpression */: + case 181 /* BinaryExpression */: + case 168 /* CallExpression */: + case 241 /* CaseClause */: + case 136 /* ComputedPropertyName */: + case 182 /* ConditionalExpression */: + case 139 /* Decorator */: + case 175 /* DeleteExpression */: + case 197 /* DoStatement */: + case 167 /* ElementAccessExpression */: + case 227 /* ExportAssignment */: + case 195 /* ExpressionStatement */: + case 188 /* ExpressionWithTypeArguments */: + case 199 /* ForStatement */: + case 200 /* ForInStatement */: + case 201 /* ForOfStatement */: + case 196 /* IfStatement */: + case 234 /* JsxSelfClosingElement */: + case 235 /* JsxOpeningElement */: + case 239 /* JsxSpreadAttribute */: + case 240 /* JsxExpression */: + case 169 /* NewExpression */: + case 172 /* ParenthesizedExpression */: + case 180 /* PostfixUnaryExpression */: + case 179 /* PrefixUnaryExpression */: + case 204 /* ReturnStatement */: + case 246 /* ShorthandPropertyAssignment */: + case 185 /* SpreadElementExpression */: + case 206 /* SwitchStatement */: + case 170 /* TaggedTemplateExpression */: + case 190 /* TemplateSpan */: + case 208 /* ThrowStatement */: + case 171 /* TypeAssertionExpression */: + case 176 /* TypeOfExpression */: + case 177 /* VoidExpression */: + case 198 /* WhileStatement */: + case 205 /* WithStatement */: + case 184 /* YieldExpression */: + return true; + case 163 /* BindingElement */: + case 247 /* EnumMember */: + case 138 /* Parameter */: + case 245 /* PropertyAssignment */: + case 141 /* PropertyDeclaration */: + case 211 /* VariableDeclaration */: + return parent.initializer === node; + case 166 /* PropertyAccessExpression */: + return parent.expression === node; + case 174 /* ArrowFunction */: + case 173 /* FunctionExpression */: + return parent.body === node; + case 221 /* ImportEqualsDeclaration */: + return parent.moduleReference === node; + case 135 /* QualifiedName */: + return parent.left === node; + } + return false; + } + function emitExpressionIdentifier(node) { + if (resolver.getNodeCheckFlags(node) & 2048 /* LexicalArguments */) { + write("_arguments"); + return; + } + var container = resolver.getReferencedExportContainer(node); + if (container) { + if (container.kind === 248 /* SourceFile */) { + // Identifier references module export + if (modulekind !== 5 /* ES6 */ && modulekind !== 4 /* System */) { + write("exports."); + } + } + else { + // Identifier references namespace export + write(getGeneratedNameForNode(container)); + write("."); + } + } + else if (modulekind !== 5 /* ES6 */) { + var declaration = resolver.getReferencedImportDeclaration(node); + if (declaration) { + if (declaration.kind === 223 /* ImportClause */) { + // Identifier references default import + write(getGeneratedNameForNode(declaration.parent)); + write(languageVersion === 0 /* ES3 */ ? "[\"default\"]" : ".default"); + return; + } + else if (declaration.kind === 226 /* ImportSpecifier */) { + // Identifier references named import + write(getGeneratedNameForNode(declaration.parent.parent.parent)); + var name_23 = declaration.propertyName || declaration.name; + var identifier = ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, name_23); + if (languageVersion === 0 /* ES3 */ && identifier === "default") { + write("[\"default\"]"); + } + else { + write("."); + write(identifier); + } + return; + } + } + declaration = resolver.getReferencedNestedRedeclaration(node); + if (declaration) { + write(getGeneratedNameForNode(declaration.name)); + return; + } + } + if (ts.nodeIsSynthesized(node)) { + write(node.text); + } + else { + writeTextOfNode(currentSourceFile, node); + } + } + function isNameOfNestedRedeclaration(node) { + if (languageVersion < 2 /* ES6 */) { + var parent_6 = node.parent; + switch (parent_6.kind) { + case 163 /* BindingElement */: + case 214 /* ClassDeclaration */: + case 217 /* EnumDeclaration */: + case 211 /* VariableDeclaration */: + return parent_6.name === node && resolver.isNestedRedeclaration(parent_6); + } + } + return false; + } + function emitIdentifier(node) { + if (!node.parent) { + write(node.text); + } + else if (isExpressionIdentifier(node)) { + emitExpressionIdentifier(node); + } + else if (isNameOfNestedRedeclaration(node)) { + write(getGeneratedNameForNode(node)); + } + else if (ts.nodeIsSynthesized(node)) { + write(node.text); + } + else { + writeTextOfNode(currentSourceFile, node); + } + } + function emitThis(node) { + if (resolver.getNodeCheckFlags(node) & 2 /* LexicalThis */) { + write("_this"); + } + else { + write("this"); + } + } + function emitSuper(node) { + if (languageVersion >= 2 /* ES6 */) { + write("super"); + } + else { + var flags = resolver.getNodeCheckFlags(node); + if (flags & 256 /* SuperInstance */) { + write("_super.prototype"); + } + else { + write("_super"); + } + } + } + function emitObjectBindingPattern(node) { + write("{ "); + var elements = node.elements; + emitList(elements, 0, elements.length, /*multiLine*/ false, /*trailingComma*/ elements.hasTrailingComma); + write(" }"); + } + function emitArrayBindingPattern(node) { + write("["); + var elements = node.elements; + emitList(elements, 0, elements.length, /*multiLine*/ false, /*trailingComma*/ elements.hasTrailingComma); + write("]"); + } + function emitBindingElement(node) { + if (node.propertyName) { + emit(node.propertyName); + write(": "); + } + if (node.dotDotDotToken) { + write("..."); + } + if (ts.isBindingPattern(node.name)) { + emit(node.name); + } + else { + emitModuleMemberName(node); + } + emitOptional(" = ", node.initializer); + } + function emitSpreadElementExpression(node) { + write("..."); + emit(node.expression); + } + function emitYieldExpression(node) { + write(ts.tokenToString(114 /* YieldKeyword */)); + if (node.asteriskToken) { + write("*"); + } + if (node.expression) { + write(" "); + emit(node.expression); + } + } + function emitAwaitExpression(node) { + var needsParenthesis = needsParenthesisForAwaitExpressionAsYield(node); + if (needsParenthesis) { + write("("); + } + write(ts.tokenToString(114 /* YieldKeyword */)); + write(" "); + emit(node.expression); + if (needsParenthesis) { + write(")"); + } + } + function needsParenthesisForAwaitExpressionAsYield(node) { + if (node.parent.kind === 181 /* BinaryExpression */ && !ts.isAssignmentOperator(node.parent.operatorToken.kind)) { + return true; + } + else if (node.parent.kind === 182 /* ConditionalExpression */ && node.parent.condition === node) { + return true; + } + return false; + } + function needsParenthesisForPropertyAccessOrInvocation(node) { + switch (node.kind) { + case 69 /* Identifier */: + case 164 /* ArrayLiteralExpression */: + case 166 /* PropertyAccessExpression */: + case 167 /* ElementAccessExpression */: + case 168 /* CallExpression */: + case 172 /* ParenthesizedExpression */: + // This list is not exhaustive and only includes those cases that are relevant + // to the check in emitArrayLiteral. More cases can be added as needed. + return false; + } + return true; + } + function emitListWithSpread(elements, needsUniqueCopy, multiLine, trailingComma, useConcat) { + var pos = 0; + var group = 0; + var length = elements.length; + while (pos < length) { + // Emit using the pattern .concat(, , ...) + if (group === 1 && useConcat) { + write(".concat("); + } + else if (group > 0) { + write(", "); + } + var e = elements[pos]; + if (e.kind === 185 /* SpreadElementExpression */) { + e = e.expression; + emitParenthesizedIf(e, /*parenthesized*/ group === 0 && needsParenthesisForPropertyAccessOrInvocation(e)); + pos++; + if (pos === length && group === 0 && needsUniqueCopy && e.kind !== 164 /* ArrayLiteralExpression */) { + write(".slice()"); + } + } + else { + var i = pos; + while (i < length && elements[i].kind !== 185 /* SpreadElementExpression */) { + i++; + } + write("["); + if (multiLine) { + increaseIndent(); + } + emitList(elements, pos, i - pos, multiLine, trailingComma && i === length); + if (multiLine) { + decreaseIndent(); + } + write("]"); + pos = i; + } + group++; + } + if (group > 1) { + if (useConcat) { + write(")"); + } + } + } + function isSpreadElementExpression(node) { + return node.kind === 185 /* SpreadElementExpression */; + } + function emitArrayLiteral(node) { + var elements = node.elements; + if (elements.length === 0) { + write("[]"); + } + else if (languageVersion >= 2 /* ES6 */ || !ts.forEach(elements, isSpreadElementExpression)) { + write("["); + emitLinePreservingList(node, node.elements, elements.hasTrailingComma, /*spacesBetweenBraces:*/ false); + write("]"); + } + else { + emitListWithSpread(elements, /*needsUniqueCopy*/ true, /*multiLine*/ (node.flags & 2048 /* MultiLine */) !== 0, + /*trailingComma*/ elements.hasTrailingComma, /*useConcat*/ true); + } + } + function emitObjectLiteralBody(node, numElements) { + if (numElements === 0) { + write("{}"); + return; + } + write("{"); + if (numElements > 0) { + var properties = node.properties; + // If we are not doing a downlevel transformation for object literals, + // then try to preserve the original shape of the object literal. + // Otherwise just try to preserve the formatting. + if (numElements === properties.length) { + emitLinePreservingList(node, properties, /* allowTrailingComma */ languageVersion >= 1 /* ES5 */, /* spacesBetweenBraces */ true); + } + else { + var multiLine = (node.flags & 2048 /* MultiLine */) !== 0; + if (!multiLine) { + write(" "); + } + else { + increaseIndent(); + } + emitList(properties, 0, numElements, /*multiLine*/ multiLine, /*trailingComma*/ false); + if (!multiLine) { + write(" "); + } + else { + decreaseIndent(); + } + } + } + write("}"); + } + function emitDownlevelObjectLiteralWithComputedProperties(node, firstComputedPropertyIndex) { + var multiLine = (node.flags & 2048 /* MultiLine */) !== 0; + var properties = node.properties; + write("("); + if (multiLine) { + increaseIndent(); + } + // 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 tempVar = createAndRecordTempVariable(0 /* Auto */); + // Write out the first non-computed properties + // (or all properties if none of them are computed), + // then emit the rest through indexing on the temp variable. + emit(tempVar); + write(" = "); + emitObjectLiteralBody(node, firstComputedPropertyIndex); + for (var i = firstComputedPropertyIndex, n = properties.length; i < n; i++) { + writeComma(); + var property = properties[i]; + emitStart(property); + if (property.kind === 145 /* GetAccessor */ || property.kind === 146 /* SetAccessor */) { + // TODO (drosen): Reconcile with 'emitMemberFunctions'. + var accessors = ts.getAllAccessorDeclarations(node.properties, property); + if (property !== accessors.firstAccessor) { + continue; + } + write("Object.defineProperty("); + emit(tempVar); + write(", "); + emitStart(node.name); + emitExpressionForPropertyName(property.name); + emitEnd(property.name); + write(", {"); + increaseIndent(); + if (accessors.getAccessor) { + writeLine(); + emitLeadingComments(accessors.getAccessor); + write("get: "); + emitStart(accessors.getAccessor); + write("function "); + emitSignatureAndBody(accessors.getAccessor); + emitEnd(accessors.getAccessor); + emitTrailingComments(accessors.getAccessor); + write(","); + } + if (accessors.setAccessor) { + writeLine(); + emitLeadingComments(accessors.setAccessor); + write("set: "); + emitStart(accessors.setAccessor); + write("function "); + emitSignatureAndBody(accessors.setAccessor); + emitEnd(accessors.setAccessor); + emitTrailingComments(accessors.setAccessor); + write(","); + } + writeLine(); + write("enumerable: true,"); + writeLine(); + write("configurable: true"); + decreaseIndent(); + writeLine(); + write("})"); + emitEnd(property); + } + else { + emitLeadingComments(property); + emitStart(property.name); + emit(tempVar); + emitMemberAccessForPropertyName(property.name); + emitEnd(property.name); + write(" = "); + if (property.kind === 245 /* PropertyAssignment */) { + emit(property.initializer); + } + else if (property.kind === 246 /* ShorthandPropertyAssignment */) { + emitExpressionIdentifier(property.name); + } + else if (property.kind === 143 /* MethodDeclaration */) { + emitFunctionDeclaration(property); + } + else { + ts.Debug.fail("ObjectLiteralElement type not accounted for: " + property.kind); + } + } + emitEnd(property); + } + writeComma(); + emit(tempVar); + if (multiLine) { + decreaseIndent(); + writeLine(); + } + write(")"); + function writeComma() { + if (multiLine) { + write(","); + writeLine(); + } + else { + write(", "); + } + } + } + function emitObjectLiteral(node) { + var properties = node.properties; + if (languageVersion < 2 /* ES6 */) { + var numProperties = properties.length; + // Find the first computed property. + // Everything until that point can be emitted as part of the initial object literal. + var numInitialNonComputedProperties = numProperties; + for (var i = 0, n = properties.length; i < n; i++) { + if (properties[i].name.kind === 136 /* ComputedPropertyName */) { + numInitialNonComputedProperties = i; + break; + } + } + var hasComputedProperty = numInitialNonComputedProperties !== properties.length; + if (hasComputedProperty) { + emitDownlevelObjectLiteralWithComputedProperties(node, numInitialNonComputedProperties); + return; + } + } + // Ordinary case: either the object has no computed properties + // or we're compiling with an ES6+ target. + emitObjectLiteralBody(node, properties.length); + } + function createBinaryExpression(left, operator, right, startsOnNewLine) { + var result = ts.createSynthesizedNode(181 /* BinaryExpression */, startsOnNewLine); + result.operatorToken = ts.createSynthesizedNode(operator); + result.left = left; + result.right = right; + return result; + } + function createPropertyAccessExpression(expression, name) { + var result = ts.createSynthesizedNode(166 /* PropertyAccessExpression */); + result.expression = parenthesizeForAccess(expression); + result.dotToken = ts.createSynthesizedNode(21 /* DotToken */); + result.name = name; + return result; + } + function createElementAccessExpression(expression, argumentExpression) { + var result = ts.createSynthesizedNode(167 /* ElementAccessExpression */); + result.expression = parenthesizeForAccess(expression); + result.argumentExpression = argumentExpression; + return result; + } + function parenthesizeForAccess(expr) { + // When diagnosing whether the expression needs parentheses, the decision should be based + // on the innermost expression in a chain of nested type assertions. + while (expr.kind === 171 /* TypeAssertionExpression */ || expr.kind === 189 /* AsExpression */) { + expr = expr.expression; + } + // isLeftHandSideExpression is almost the correct criterion for when it is not necessary + // to parenthesize the expression before a dot. The known exceptions are: + // + // NewExpression: + // new C.x -> not the same as (new C).x + // NumberLiteral + // 1.x -> not the same as (1).x + // + if (ts.isLeftHandSideExpression(expr) && + expr.kind !== 169 /* NewExpression */ && + expr.kind !== 8 /* NumericLiteral */) { + return expr; + } + var node = ts.createSynthesizedNode(172 /* ParenthesizedExpression */); + node.expression = expr; + return node; + } + function emitComputedPropertyName(node) { + write("["); + emitExpressionForPropertyName(node); + write("]"); + } + function emitMethod(node) { + if (languageVersion >= 2 /* ES6 */ && node.asteriskToken) { + write("*"); + } + emit(node.name); + if (languageVersion < 2 /* ES6 */) { + write(": function "); + } + emitSignatureAndBody(node); + } + function emitPropertyAssignment(node) { + emit(node.name); + write(": "); + // This is to ensure that we emit comment in the following case: + // For example: + // obj = { + // id: /*comment1*/ ()=>void + // } + // "comment1" is not considered to be leading comment for node.initializer + // but rather a trailing comment on the previous node. + emitTrailingCommentsOfPosition(node.initializer.pos); + emit(node.initializer); + } + // Return true if identifier resolves to an exported member of a namespace + function isNamespaceExportReference(node) { + var container = resolver.getReferencedExportContainer(node); + return container && container.kind !== 248 /* SourceFile */; + } + function emitShorthandPropertyAssignment(node) { + // The name property of a short-hand property assignment is considered an expression position, so here + // we manually emit the identifier to avoid rewriting. + writeTextOfNode(currentSourceFile, node.name); + // If emitting pre-ES6 code, or if the name requires rewriting when resolved as an expression identifier, + // we emit a normal property assignment. For example: + // module m { + // export let y; + // } + // module m { + // let obj = { y }; + // } + // Here we need to emit obj = { y : m.y } regardless of the output target. + if (languageVersion < 2 /* ES6 */ || isNamespaceExportReference(node.name)) { + // Emit identifier as an identifier + write(": "); + emit(node.name); + } + if (languageVersion >= 2 /* ES6 */ && node.objectAssignmentInitializer) { + write(" = "); + emit(node.objectAssignmentInitializer); + } + } + function tryEmitConstantValue(node) { + var constantValue = tryGetConstEnumValue(node); + if (constantValue !== undefined) { + write(constantValue.toString()); + if (!compilerOptions.removeComments) { + var propertyName = node.kind === 166 /* PropertyAccessExpression */ ? ts.declarationNameToString(node.name) : ts.getTextOfNode(node.argumentExpression); + write(" /* " + propertyName + " */"); + } + return true; + } + return false; + } + function tryGetConstEnumValue(node) { + if (compilerOptions.isolatedModules) { + return undefined; + } + return node.kind === 166 /* PropertyAccessExpression */ || node.kind === 167 /* ElementAccessExpression */ + ? resolver.getConstantValue(node) + : undefined; + } + // Returns 'true' if the code was actually indented, false otherwise. + // If the code is not indented, an optional valueToWriteWhenNotIndenting will be + // emitted instead. + function indentIfOnDifferentLines(parent, node1, node2, valueToWriteWhenNotIndenting) { + var realNodesAreOnDifferentLines = !ts.nodeIsSynthesized(parent) && !nodeEndIsOnSameLineAsNodeStart(node1, node2); + // Always use a newline for synthesized code if the synthesizer desires it. + var synthesizedNodeIsOnDifferentLine = synthesizedNodeStartsOnNewLine(node2); + if (realNodesAreOnDifferentLines || synthesizedNodeIsOnDifferentLine) { + increaseIndent(); + writeLine(); + return true; + } + else { + if (valueToWriteWhenNotIndenting) { + write(valueToWriteWhenNotIndenting); + } + return false; + } + } + function emitPropertyAccess(node) { + if (tryEmitConstantValue(node)) { + return; + } + emit(node.expression); + var indentedBeforeDot = indentIfOnDifferentLines(node, node.expression, node.dotToken); + // 1 .toString is a valid property access, emit a space after the literal + // Also emit a space if expression is a integer const enum value - it will appear in generated code as numeric literal + var shouldEmitSpace; + if (!indentedBeforeDot) { + if (node.expression.kind === 8 /* NumericLiteral */) { + // check if numeric literal was originally written with a dot + var text = ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, node.expression); + shouldEmitSpace = text.indexOf(ts.tokenToString(21 /* DotToken */)) < 0; + } + else { + // check if constant enum value is integer + var constantValue = tryGetConstEnumValue(node.expression); + // isFinite handles cases when constantValue is undefined + shouldEmitSpace = isFinite(constantValue) && Math.floor(constantValue) === constantValue; + } + } + if (shouldEmitSpace) { + write(" ."); + } + else { + write("."); + } + var indentedAfterDot = indentIfOnDifferentLines(node, node.dotToken, node.name); + emit(node.name); + decreaseIndentIf(indentedBeforeDot, indentedAfterDot); + } + function emitQualifiedName(node) { + emit(node.left); + write("."); + emit(node.right); + } + function emitQualifiedNameAsExpression(node, useFallback) { + if (node.left.kind === 69 /* Identifier */) { + emitEntityNameAsExpression(node.left, useFallback); + } + else if (useFallback) { + var temp = createAndRecordTempVariable(0 /* Auto */); + write("("); + emitNodeWithoutSourceMap(temp); + write(" = "); + emitEntityNameAsExpression(node.left, /*useFallback*/ true); + write(") && "); + emitNodeWithoutSourceMap(temp); + } + else { + emitEntityNameAsExpression(node.left, /*useFallback*/ false); + } + write("."); + emit(node.right); + } + function emitEntityNameAsExpression(node, useFallback) { + switch (node.kind) { + case 69 /* Identifier */: + if (useFallback) { + write("typeof "); + emitExpressionIdentifier(node); + write(" !== 'undefined' && "); + } + emitExpressionIdentifier(node); + break; + case 135 /* QualifiedName */: + emitQualifiedNameAsExpression(node, useFallback); + break; + } + } + function emitIndexedAccess(node) { + if (tryEmitConstantValue(node)) { + return; + } + emit(node.expression); + write("["); + emit(node.argumentExpression); + write("]"); + } + function hasSpreadElement(elements) { + return ts.forEach(elements, function (e) { return e.kind === 185 /* SpreadElementExpression */; }); + } + function skipParentheses(node) { + while (node.kind === 172 /* ParenthesizedExpression */ || node.kind === 171 /* TypeAssertionExpression */ || node.kind === 189 /* AsExpression */) { + node = node.expression; + } + return node; + } + function emitCallTarget(node) { + if (node.kind === 69 /* Identifier */ || node.kind === 97 /* ThisKeyword */ || node.kind === 95 /* SuperKeyword */) { + emit(node); + return node; + } + var temp = createAndRecordTempVariable(0 /* Auto */); + write("("); + emit(temp); + write(" = "); + emit(node); + write(")"); + return temp; + } + function emitCallWithSpread(node) { + var target; + var expr = skipParentheses(node.expression); + if (expr.kind === 166 /* PropertyAccessExpression */) { + // Target will be emitted as "this" argument + target = emitCallTarget(expr.expression); + write("."); + emit(expr.name); + } + else if (expr.kind === 167 /* ElementAccessExpression */) { + // Target will be emitted as "this" argument + target = emitCallTarget(expr.expression); + write("["); + emit(expr.argumentExpression); + write("]"); + } + else if (expr.kind === 95 /* SuperKeyword */) { + target = expr; + write("_super"); + } + else { + emit(node.expression); + } + write(".apply("); + if (target) { + if (target.kind === 95 /* SuperKeyword */) { + // Calls of form super(...) and super.foo(...) + emitThis(target); + } + else { + // Calls of form obj.foo(...) + emit(target); + } + } + else { + // Calls of form foo(...) + write("void 0"); + } + write(", "); + emitListWithSpread(node.arguments, /*needsUniqueCopy*/ false, /*multiLine*/ false, /*trailingComma*/ false, /*useConcat*/ true); + write(")"); + } + function emitCallExpression(node) { + if (languageVersion < 2 /* ES6 */ && hasSpreadElement(node.arguments)) { + emitCallWithSpread(node); + return; + } + var superCall = false; + if (node.expression.kind === 95 /* SuperKeyword */) { + emitSuper(node.expression); + superCall = true; + } + else { + emit(node.expression); + superCall = node.expression.kind === 166 /* PropertyAccessExpression */ && node.expression.expression.kind === 95 /* SuperKeyword */; + } + if (superCall && languageVersion < 2 /* ES6 */) { + write(".call("); + emitThis(node.expression); + if (node.arguments.length) { + write(", "); + emitCommaList(node.arguments); + } + write(")"); + } + else { + write("("); + emitCommaList(node.arguments); + write(")"); + } + } + function emitNewExpression(node) { + write("new "); + // Spread operator logic is supported in new expressions in ES5 using a combination + // of Function.prototype.bind() and Function.prototype.apply(). + // + // Example: + // + // var args = [1, 2, 3, 4, 5]; + // new Array(...args); + // + // is compiled into the following ES5: + // + // var args = [1, 2, 3, 4, 5]; + // new (Array.bind.apply(Array, [void 0].concat(args))); + // + // The 'thisArg' to 'bind' is ignored when invoking the result of 'bind' with 'new', + // Thus, we set it to undefined ('void 0'). + if (languageVersion === 1 /* ES5 */ && + node.arguments && + hasSpreadElement(node.arguments)) { + write("("); + var target = emitCallTarget(node.expression); + write(".bind.apply("); + emit(target); + write(", [void 0].concat("); + emitListWithSpread(node.arguments, /*needsUniqueCopy*/ false, /*multiline*/ false, /*trailingComma*/ false, /*useConcat*/ false); + write(")))"); + write("()"); + } + else { + emit(node.expression); + if (node.arguments) { + write("("); + emitCommaList(node.arguments); + write(")"); + } + } + } + function emitTaggedTemplateExpression(node) { + if (languageVersion >= 2 /* ES6 */) { + emit(node.tag); + write(" "); + emit(node.template); + } + else { + emitDownlevelTaggedTemplate(node); + } + } + function emitParenExpression(node) { + // If the node is synthesized, it means the emitter put the parentheses there, + // not the user. If we didn't want them, the emitter would not have put them + // there. + if (!ts.nodeIsSynthesized(node) && node.parent.kind !== 174 /* ArrowFunction */) { + if (node.expression.kind === 171 /* TypeAssertionExpression */ || node.expression.kind === 189 /* AsExpression */) { + var operand = node.expression.expression; + // Make sure we consider all nested cast expressions, e.g.: + // (-A).x; + while (operand.kind === 171 /* TypeAssertionExpression */ || operand.kind === 189 /* AsExpression */) { + operand = operand.expression; + } + // We have an expression of the form: (SubExpr) + // Emitting this as (SubExpr) is really not desirable. We would like to emit the subexpr as is. + // Omitting the parentheses, however, could cause change in the semantics of the generated + // code if the casted expression has a lower precedence than the rest of the expression, e.g.: + // (new A).foo should be emitted as (new A).foo and not new A.foo + // (typeof A).toString() should be emitted as (typeof A).toString() and not typeof A.toString() + // new (A()) should be emitted as new (A()) and not new A() + // (function foo() { })() should be emitted as an IIF (function foo(){})() and not declaration function foo(){} () + if (operand.kind !== 179 /* PrefixUnaryExpression */ && + operand.kind !== 177 /* VoidExpression */ && + operand.kind !== 176 /* TypeOfExpression */ && + operand.kind !== 175 /* DeleteExpression */ && + operand.kind !== 180 /* PostfixUnaryExpression */ && + operand.kind !== 169 /* NewExpression */ && + !(operand.kind === 168 /* CallExpression */ && node.parent.kind === 169 /* NewExpression */) && + !(operand.kind === 173 /* FunctionExpression */ && node.parent.kind === 168 /* CallExpression */) && + !(operand.kind === 8 /* NumericLiteral */ && node.parent.kind === 166 /* PropertyAccessExpression */)) { + emit(operand); + return; + } + } + } + write("("); + emit(node.expression); + write(")"); + } + function emitDeleteExpression(node) { + write(ts.tokenToString(78 /* DeleteKeyword */)); + write(" "); + emit(node.expression); + } + function emitVoidExpression(node) { + write(ts.tokenToString(103 /* VoidKeyword */)); + write(" "); + emit(node.expression); + } + function emitTypeOfExpression(node) { + write(ts.tokenToString(101 /* TypeOfKeyword */)); + write(" "); + emit(node.expression); + } + function isNameOfExportedSourceLevelDeclarationInSystemExternalModule(node) { + if (!isCurrentFileSystemExternalModule() || node.kind !== 69 /* Identifier */ || ts.nodeIsSynthesized(node)) { + return false; + } + var isVariableDeclarationOrBindingElement = node.parent && (node.parent.kind === 211 /* VariableDeclaration */ || node.parent.kind === 163 /* BindingElement */); + var targetDeclaration = isVariableDeclarationOrBindingElement + ? node.parent + : resolver.getReferencedValueDeclaration(node); + return isSourceFileLevelDeclarationInSystemJsModule(targetDeclaration, /*isExported*/ true); + } + function emitPrefixUnaryExpression(node) { + var exportChanged = isNameOfExportedSourceLevelDeclarationInSystemExternalModule(node.operand); + if (exportChanged) { + // emit + // ++x + // as + // exports('x', ++x) + write(exportFunctionForFile + "(\""); + emitNodeWithoutSourceMap(node.operand); + write("\", "); + } + write(ts.tokenToString(node.operator)); + // In some cases, we need to emit a space between the operator and the operand. One obvious case + // is when the operator is an identifier, like delete or typeof. We also need to do this for plus + // and minus expressions in certain cases. Specifically, consider the following two cases (parens + // are just for clarity of exposition, and not part of the source code): + // + // (+(+1)) + // (+(++1)) + // + // We need to emit a space in both cases. In the first case, the absence of a space will make + // the resulting expression a prefix increment operation. And in the second, it will make the resulting + // expression a prefix increment whose operand is a plus expression - (++(+x)) + // The same is true of minus of course. + if (node.operand.kind === 179 /* PrefixUnaryExpression */) { + var operand = node.operand; + if (node.operator === 35 /* PlusToken */ && (operand.operator === 35 /* PlusToken */ || operand.operator === 41 /* PlusPlusToken */)) { + write(" "); + } + else if (node.operator === 36 /* MinusToken */ && (operand.operator === 36 /* MinusToken */ || operand.operator === 42 /* MinusMinusToken */)) { + write(" "); + } + } + emit(node.operand); + if (exportChanged) { + write(")"); + } + } + function emitPostfixUnaryExpression(node) { + var exportChanged = isNameOfExportedSourceLevelDeclarationInSystemExternalModule(node.operand); + if (exportChanged) { + // 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)' + write("(" + exportFunctionForFile + "(\""); + emitNodeWithoutSourceMap(node.operand); + write("\", "); + write(ts.tokenToString(node.operator)); + emit(node.operand); + if (node.operator === 41 /* PlusPlusToken */) { + write(") - 1)"); + } + else { + write(") + 1)"); + } + } + else { + emit(node.operand); + write(ts.tokenToString(node.operator)); + } + } + function shouldHoistDeclarationInSystemJsModule(node) { + return isSourceFileLevelDeclarationInSystemJsModule(node, /*isExported*/ false); + } + /* + * Checks if given node is a source file level declaration (not nested in module/function). + * If 'isExported' is true - then declaration must also be exported. + * This function is used in two cases: + * - check if node is a exported source file level value to determine + * if we should also export the value after its it changed + * - check if node is a source level declaration to emit it differently, + * i.e non-exported variable statement 'var x = 1' is hoisted so + * we we emit variable statement 'var' should be dropped. + */ + function isSourceFileLevelDeclarationInSystemJsModule(node, isExported) { + if (!node || languageVersion >= 2 /* ES6 */ || !isCurrentFileSystemExternalModule()) { + return false; + } + var current = node; + while (current) { + if (current.kind === 248 /* SourceFile */) { + return !isExported || ((ts.getCombinedNodeFlags(node) & 1 /* Export */) !== 0); + } + else if (ts.isFunctionLike(current) || current.kind === 219 /* ModuleBlock */) { + return false; + } + else { + current = current.parent; + } + } + } + /** + * Emit ES7 exponentiation operator downlevel using Math.pow + * @param node a binary expression node containing exponentiationOperator (**, **=) + */ + function emitExponentiationOperator(node) { + var leftHandSideExpression = node.left; + if (node.operatorToken.kind === 60 /* AsteriskAsteriskEqualsToken */) { + var synthesizedLHS; + var shouldEmitParentheses = false; + if (ts.isElementAccessExpression(leftHandSideExpression)) { + shouldEmitParentheses = true; + write("("); + synthesizedLHS = ts.createSynthesizedNode(167 /* ElementAccessExpression */, /*startsOnNewLine*/ false); + var identifier = emitTempVariableAssignment(leftHandSideExpression.expression, /*canDefinedTempVariablesInPlaces*/ false, /*shouldEmitCommaBeforeAssignment*/ false); + synthesizedLHS.expression = identifier; + if (leftHandSideExpression.argumentExpression.kind !== 8 /* NumericLiteral */ && + leftHandSideExpression.argumentExpression.kind !== 9 /* StringLiteral */) { + var tempArgumentExpression = createAndRecordTempVariable(268435456 /* _i */); + synthesizedLHS.argumentExpression = tempArgumentExpression; + emitAssignment(tempArgumentExpression, leftHandSideExpression.argumentExpression, /*shouldEmitCommaBeforeAssignment*/ true); + } + else { + synthesizedLHS.argumentExpression = leftHandSideExpression.argumentExpression; + } + write(", "); + } + else if (ts.isPropertyAccessExpression(leftHandSideExpression)) { + shouldEmitParentheses = true; + write("("); + synthesizedLHS = ts.createSynthesizedNode(166 /* PropertyAccessExpression */, /*startsOnNewLine*/ false); + var identifier = emitTempVariableAssignment(leftHandSideExpression.expression, /*canDefinedTempVariablesInPlaces*/ false, /*shouldemitCommaBeforeAssignment*/ false); + synthesizedLHS.expression = identifier; + synthesizedLHS.dotToken = leftHandSideExpression.dotToken; + synthesizedLHS.name = leftHandSideExpression.name; + write(", "); + } + emit(synthesizedLHS || leftHandSideExpression); + write(" = "); + write("Math.pow("); + emit(synthesizedLHS || leftHandSideExpression); + write(", "); + emit(node.right); + write(")"); + if (shouldEmitParentheses) { + write(")"); + } + } + else { + write("Math.pow("); + emit(leftHandSideExpression); + write(", "); + emit(node.right); + write(")"); + } + } + function emitBinaryExpression(node) { + if (languageVersion < 2 /* ES6 */ && node.operatorToken.kind === 56 /* EqualsToken */ && + (node.left.kind === 165 /* ObjectLiteralExpression */ || node.left.kind === 164 /* ArrayLiteralExpression */)) { + emitDestructuring(node, node.parent.kind === 195 /* ExpressionStatement */); + } + else { + var exportChanged = node.operatorToken.kind >= 56 /* FirstAssignment */ && + node.operatorToken.kind <= 68 /* LastAssignment */ && + isNameOfExportedSourceLevelDeclarationInSystemExternalModule(node.left); + if (exportChanged) { + // emit assignment 'x y' as 'exports("x", x y)' + write(exportFunctionForFile + "(\""); + emitNodeWithoutSourceMap(node.left); + write("\", "); + } + if (node.operatorToken.kind === 38 /* AsteriskAsteriskToken */ || node.operatorToken.kind === 60 /* AsteriskAsteriskEqualsToken */) { + // Downleveled emit exponentiation operator using Math.pow + emitExponentiationOperator(node); + } + else { + emit(node.left); + // Add indentation before emit the operator if the operator is on different line + // For example: + // 3 + // + 2; + // emitted as + // 3 + // + 2; + var indentedBeforeOperator = indentIfOnDifferentLines(node, node.left, node.operatorToken, node.operatorToken.kind !== 24 /* CommaToken */ ? " " : undefined); + write(ts.tokenToString(node.operatorToken.kind)); + var indentedAfterOperator = indentIfOnDifferentLines(node, node.operatorToken, node.right, " "); + emit(node.right); + decreaseIndentIf(indentedBeforeOperator, indentedAfterOperator); + } + if (exportChanged) { + write(")"); + } + } + } + function synthesizedNodeStartsOnNewLine(node) { + return ts.nodeIsSynthesized(node) && node.startsOnNewLine; + } + function emitConditionalExpression(node) { + emit(node.condition); + var indentedBeforeQuestion = indentIfOnDifferentLines(node, node.condition, node.questionToken, " "); + write("?"); + var indentedAfterQuestion = indentIfOnDifferentLines(node, node.questionToken, node.whenTrue, " "); + emit(node.whenTrue); + decreaseIndentIf(indentedBeforeQuestion, indentedAfterQuestion); + var indentedBeforeColon = indentIfOnDifferentLines(node, node.whenTrue, node.colonToken, " "); + write(":"); + var indentedAfterColon = indentIfOnDifferentLines(node, node.colonToken, node.whenFalse, " "); + emit(node.whenFalse); + decreaseIndentIf(indentedBeforeColon, indentedAfterColon); + } + // Helper function to decrease the indent if we previously indented. Allows multiple + // previous indent values to be considered at a time. This also allows caller to just + // call this once, passing in all their appropriate indent values, instead of needing + // to call this helper function multiple times. + function decreaseIndentIf(value1, value2) { + if (value1) { + decreaseIndent(); + } + if (value2) { + decreaseIndent(); + } + } + function isSingleLineEmptyBlock(node) { + if (node && node.kind === 192 /* Block */) { + var block = node; + return block.statements.length === 0 && nodeEndIsOnSameLineAsNodeStart(block, block); + } + } + function emitBlock(node) { + if (isSingleLineEmptyBlock(node)) { + emitToken(15 /* OpenBraceToken */, node.pos); + write(" "); + emitToken(16 /* CloseBraceToken */, node.statements.end); + return; + } + emitToken(15 /* OpenBraceToken */, node.pos); + increaseIndent(); + scopeEmitStart(node.parent); + if (node.kind === 219 /* ModuleBlock */) { + ts.Debug.assert(node.parent.kind === 218 /* ModuleDeclaration */); + emitCaptureThisForNodeIfNecessary(node.parent); + } + emitLines(node.statements); + if (node.kind === 219 /* ModuleBlock */) { + emitTempDeclarations(/*newLine*/ true); + } + decreaseIndent(); + writeLine(); + emitToken(16 /* CloseBraceToken */, node.statements.end); + scopeEmitEnd(); + } + function emitEmbeddedStatement(node) { + if (node.kind === 192 /* Block */) { + write(" "); + emit(node); + } + else { + increaseIndent(); + writeLine(); + emit(node); + decreaseIndent(); + } + } + function emitExpressionStatement(node) { + emitParenthesizedIf(node.expression, /*parenthesized*/ node.expression.kind === 174 /* ArrowFunction */); + write(";"); + } + function emitIfStatement(node) { + var endPos = emitToken(88 /* IfKeyword */, node.pos); + write(" "); + endPos = emitToken(17 /* OpenParenToken */, endPos); + emit(node.expression); + emitToken(18 /* CloseParenToken */, node.expression.end); + emitEmbeddedStatement(node.thenStatement); + if (node.elseStatement) { + writeLine(); + emitToken(80 /* ElseKeyword */, node.thenStatement.end); + if (node.elseStatement.kind === 196 /* IfStatement */) { + write(" "); + emit(node.elseStatement); + } + else { + emitEmbeddedStatement(node.elseStatement); + } + } + } + function emitDoStatement(node) { + write("do"); + emitEmbeddedStatement(node.statement); + if (node.statement.kind === 192 /* Block */) { + write(" "); + } + else { + writeLine(); + } + write("while ("); + emit(node.expression); + write(");"); + } + function emitWhileStatement(node) { + write("while ("); + emit(node.expression); + write(")"); + emitEmbeddedStatement(node.statement); + } + /** + * Returns true if start of variable declaration list was emitted. + * Returns false if nothing was written - this can happen for source file level variable declarations + * in system modules where such variable declarations are hoisted. + */ + function tryEmitStartOfVariableDeclarationList(decl, startPos) { + if (shouldHoistVariable(decl, /*checkIfSourceFileLevelDecl*/ true)) { + // variables in variable declaration list were already hoisted + return false; + } + var tokenKind = 102 /* VarKeyword */; + if (decl && languageVersion >= 2 /* ES6 */) { + if (ts.isLet(decl)) { + tokenKind = 108 /* LetKeyword */; + } + else if (ts.isConst(decl)) { + tokenKind = 74 /* ConstKeyword */; + } + } + if (startPos !== undefined) { + emitToken(tokenKind, startPos); + write(" "); + } + else { + switch (tokenKind) { + case 102 /* VarKeyword */: + write("var "); + break; + case 108 /* LetKeyword */: + write("let "); + break; + case 74 /* ConstKeyword */: + write("const "); + break; + } + } + return true; + } + function emitVariableDeclarationListSkippingUninitializedEntries(list) { + var started = false; + for (var _a = 0, _b = list.declarations; _a < _b.length; _a++) { + var decl = _b[_a]; + if (!decl.initializer) { + continue; + } + if (!started) { + started = true; + } + else { + write(", "); + } + emit(decl); + } + return started; + } + function emitForStatement(node) { + var endPos = emitToken(86 /* ForKeyword */, node.pos); + write(" "); + endPos = emitToken(17 /* OpenParenToken */, endPos); + if (node.initializer && node.initializer.kind === 212 /* VariableDeclarationList */) { + var variableDeclarationList = node.initializer; + var startIsEmitted = tryEmitStartOfVariableDeclarationList(variableDeclarationList, endPos); + if (startIsEmitted) { + emitCommaList(variableDeclarationList.declarations); + } + else { + emitVariableDeclarationListSkippingUninitializedEntries(variableDeclarationList); + } + } + else if (node.initializer) { + emit(node.initializer); + } + write(";"); + emitOptional(" ", node.condition); + write(";"); + emitOptional(" ", node.incrementor); + write(")"); + emitEmbeddedStatement(node.statement); + } + function emitForInOrForOfStatement(node) { + if (languageVersion < 2 /* ES6 */ && node.kind === 201 /* ForOfStatement */) { + return emitDownLevelForOfStatement(node); + } + var endPos = emitToken(86 /* ForKeyword */, node.pos); + write(" "); + endPos = emitToken(17 /* OpenParenToken */, endPos); + if (node.initializer.kind === 212 /* VariableDeclarationList */) { + var variableDeclarationList = node.initializer; + if (variableDeclarationList.declarations.length >= 1) { + tryEmitStartOfVariableDeclarationList(variableDeclarationList, endPos); + emit(variableDeclarationList.declarations[0]); + } + } + else { + emit(node.initializer); + } + if (node.kind === 200 /* ForInStatement */) { + write(" in "); + } + else { + write(" of "); + } + emit(node.expression); + emitToken(18 /* CloseParenToken */, node.expression.end); + emitEmbeddedStatement(node.statement); + } + function emitDownLevelForOfStatement(node) { + // The following ES6 code: + // + // for (let v of expr) { } + // + // should be emitted as + // + // for (let _i = 0, _a = expr; _i < _a.length; _i++) { + // let v = _a[_i]; + // } + // + // where _a and _i are temps emitted to capture the RHS and the counter, + // respectively. + // When the left hand side is an expression instead of a let declaration, + // the "let v" is not emitted. + // When the left hand side is a let/const, the v is renamed if there is + // another v in scope. + // Note that all assignments to the LHS are emitted in the body, including + // all destructuring. + // Note also that because an extra statement is needed to assign to the LHS, + // for-of bodies are always emitted as blocks. + var endPos = emitToken(86 /* ForKeyword */, node.pos); + write(" "); + endPos = emitToken(17 /* OpenParenToken */, endPos); + // Do not emit the LHS let declaration yet, because it might contain destructuring. + // Do not call recordTempDeclaration because we are declaring the temps + // right here. Recording means they will be declared later. + // 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 rhsIsIdentifier = node.expression.kind === 69 /* Identifier */; + var counter = createTempVariable(268435456 /* _i */); + var rhsReference = rhsIsIdentifier ? node.expression : createTempVariable(0 /* Auto */); + // This is the let keyword for the counter and rhsReference. The let keyword for + // the LHS will be emitted inside the body. + emitStart(node.expression); + write("var "); + // _i = 0 + emitNodeWithoutSourceMap(counter); + write(" = 0"); + emitEnd(node.expression); + if (!rhsIsIdentifier) { + // , _a = expr + write(", "); + emitStart(node.expression); + emitNodeWithoutSourceMap(rhsReference); + write(" = "); + emitNodeWithoutSourceMap(node.expression); + emitEnd(node.expression); + } + write("; "); + // _i < _a.length; + emitStart(node.initializer); + emitNodeWithoutSourceMap(counter); + write(" < "); + emitNodeWithCommentsAndWithoutSourcemap(rhsReference); + write(".length"); + emitEnd(node.initializer); + write("; "); + // _i++) + emitStart(node.initializer); + emitNodeWithoutSourceMap(counter); + write("++"); + emitEnd(node.initializer); + emitToken(18 /* CloseParenToken */, node.expression.end); + // Body + write(" {"); + writeLine(); + increaseIndent(); + // Initialize LHS + // let v = _a[_i]; + var rhsIterationValue = createElementAccessExpression(rhsReference, counter); + emitStart(node.initializer); + if (node.initializer.kind === 212 /* VariableDeclarationList */) { + write("var "); + var variableDeclarationList = node.initializer; + if (variableDeclarationList.declarations.length > 0) { + var declaration = variableDeclarationList.declarations[0]; + if (ts.isBindingPattern(declaration.name)) { + // This works whether the declaration is a var, let, or const. + // It will use rhsIterationValue _a[_i] as the initializer. + emitDestructuring(declaration, /*isAssignmentExpressionStatement*/ false, rhsIterationValue); + } + else { + // The following call does not include the initializer, so we have + // to emit it separately. + emitNodeWithCommentsAndWithoutSourcemap(declaration); + write(" = "); + emitNodeWithoutSourceMap(rhsIterationValue); + } + } + else { + // It's an empty declaration list. This can only happen in an error case, if the user wrote + // for (let of []) {} + emitNodeWithoutSourceMap(createTempVariable(0 /* Auto */)); + write(" = "); + emitNodeWithoutSourceMap(rhsIterationValue); + } + } + else { + // Initializer is an expression. Emit the expression in the body, so that it's + // evaluated on every iteration. + var assignmentExpression = createBinaryExpression(node.initializer, 56 /* EqualsToken */, rhsIterationValue, /*startsOnNewLine*/ false); + if (node.initializer.kind === 164 /* ArrayLiteralExpression */ || node.initializer.kind === 165 /* ObjectLiteralExpression */) { + // This is a destructuring pattern, so call emitDestructuring instead of emit. Calling emit will not work, because it will cause + // the BinaryExpression to be passed in instead of the expression statement, which will cause emitDestructuring to crash. + emitDestructuring(assignmentExpression, /*isAssignmentExpressionStatement*/ true, /*value*/ undefined); + } + else { + emitNodeWithCommentsAndWithoutSourcemap(assignmentExpression); + } + } + emitEnd(node.initializer); + write(";"); + if (node.statement.kind === 192 /* Block */) { + emitLines(node.statement.statements); + } + else { + writeLine(); + emit(node.statement); + } + writeLine(); + decreaseIndent(); + write("}"); + } + function emitBreakOrContinueStatement(node) { + emitToken(node.kind === 203 /* BreakStatement */ ? 70 /* BreakKeyword */ : 75 /* ContinueKeyword */, node.pos); + emitOptional(" ", node.label); + write(";"); + } + function emitReturnStatement(node) { + emitToken(94 /* ReturnKeyword */, node.pos); + emitOptional(" ", node.expression); + write(";"); + } + function emitWithStatement(node) { + write("with ("); + emit(node.expression); + write(")"); + emitEmbeddedStatement(node.statement); + } + function emitSwitchStatement(node) { + var endPos = emitToken(96 /* SwitchKeyword */, node.pos); + write(" "); + emitToken(17 /* OpenParenToken */, endPos); + emit(node.expression); + endPos = emitToken(18 /* CloseParenToken */, node.expression.end); + write(" "); + emitCaseBlock(node.caseBlock, endPos); + } + function emitCaseBlock(node, startPos) { + emitToken(15 /* OpenBraceToken */, startPos); + increaseIndent(); + emitLines(node.clauses); + decreaseIndent(); + writeLine(); + emitToken(16 /* CloseBraceToken */, node.clauses.end); + } + function nodeStartPositionsAreOnSameLine(node1, node2) { + return ts.getLineOfLocalPosition(currentSourceFile, ts.skipTrivia(currentSourceFile.text, node1.pos)) === + ts.getLineOfLocalPosition(currentSourceFile, ts.skipTrivia(currentSourceFile.text, node2.pos)); + } + function nodeEndPositionsAreOnSameLine(node1, node2) { + return ts.getLineOfLocalPosition(currentSourceFile, node1.end) === + ts.getLineOfLocalPosition(currentSourceFile, node2.end); + } + function nodeEndIsOnSameLineAsNodeStart(node1, node2) { + return ts.getLineOfLocalPosition(currentSourceFile, node1.end) === + ts.getLineOfLocalPosition(currentSourceFile, ts.skipTrivia(currentSourceFile.text, node2.pos)); + } + function emitCaseOrDefaultClause(node) { + if (node.kind === 241 /* CaseClause */) { + write("case "); + emit(node.expression); + write(":"); + } + else { + write("default:"); + } + if (node.statements.length === 1 && nodeStartPositionsAreOnSameLine(node, node.statements[0])) { + write(" "); + emit(node.statements[0]); + } + else { + increaseIndent(); + emitLines(node.statements); + decreaseIndent(); + } + } + function emitThrowStatement(node) { + write("throw "); + emit(node.expression); + write(";"); + } + function emitTryStatement(node) { + write("try "); + emit(node.tryBlock); + emit(node.catchClause); + if (node.finallyBlock) { + writeLine(); + write("finally "); + emit(node.finallyBlock); + } + } + function emitCatchClause(node) { + writeLine(); + var endPos = emitToken(72 /* CatchKeyword */, node.pos); + write(" "); + emitToken(17 /* OpenParenToken */, endPos); + emit(node.variableDeclaration); + emitToken(18 /* CloseParenToken */, node.variableDeclaration ? node.variableDeclaration.end : endPos); + write(" "); + emitBlock(node.block); + } + function emitDebuggerStatement(node) { + emitToken(76 /* DebuggerKeyword */, node.pos); + write(";"); + } + function emitLabelledStatement(node) { + emit(node.label); + write(": "); + emit(node.statement); + } + function getContainingModule(node) { + do { + node = node.parent; + } while (node && node.kind !== 218 /* ModuleDeclaration */); + return node; + } + function emitContainingModuleName(node) { + var container = getContainingModule(node); + write(container ? getGeneratedNameForNode(container) : "exports"); + } + function emitModuleMemberName(node) { + emitStart(node.name); + if (ts.getCombinedNodeFlags(node) & 1 /* Export */) { + var container = getContainingModule(node); + if (container) { + write(getGeneratedNameForNode(container)); + write("."); + } + else if (modulekind !== 5 /* ES6 */ && modulekind !== 4 /* System */) { + write("exports."); + } + } + emitNodeWithCommentsAndWithoutSourcemap(node.name); + emitEnd(node.name); + } + function createVoidZero() { + var zero = ts.createSynthesizedNode(8 /* NumericLiteral */); + zero.text = "0"; + var result = ts.createSynthesizedNode(177 /* VoidExpression */); + result.expression = zero; + return result; + } + function emitEs6ExportDefaultCompat(node) { + if (node.parent.kind === 248 /* SourceFile */) { + ts.Debug.assert(!!(node.flags & 1024 /* Default */) || node.kind === 227 /* ExportAssignment */); + // only allow export default at a source file level + if (modulekind === 1 /* CommonJS */ || modulekind === 2 /* AMD */ || modulekind === 3 /* UMD */) { + if (!currentSourceFile.symbol.exports["___esModule"]) { + if (languageVersion === 1 /* ES5 */) { + // default value of configurable, enumerable, writable are `false`. + write("Object.defineProperty(exports, \"__esModule\", { value: true });"); + writeLine(); + } + else if (languageVersion === 0 /* ES3 */) { + write("exports.__esModule = true;"); + writeLine(); + } + } + } + } + } + function emitExportMemberAssignment(node) { + if (node.flags & 1 /* Export */) { + writeLine(); + emitStart(node); + // emit call to exporter only for top level nodes + if (modulekind === 4 /* System */ && node.parent === currentSourceFile) { + // emit export default as + // export("default", ) + write(exportFunctionForFile + "(\""); + if (node.flags & 1024 /* Default */) { + write("default"); + } + else { + emitNodeWithCommentsAndWithoutSourcemap(node.name); + } + write("\", "); + emitDeclarationName(node); + write(")"); + } + else { + if (node.flags & 1024 /* Default */) { + emitEs6ExportDefaultCompat(node); + if (languageVersion === 0 /* ES3 */) { + write("exports[\"default\"]"); + } + else { + write("exports.default"); + } + } + else { + emitModuleMemberName(node); + } + write(" = "); + emitDeclarationName(node); + } + emitEnd(node); + write(";"); + } + } + function emitExportMemberAssignments(name) { + if (modulekind === 4 /* System */) { + return; + } + if (!exportEquals && exportSpecifiers && ts.hasProperty(exportSpecifiers, name.text)) { + for (var _a = 0, _b = exportSpecifiers[name.text]; _a < _b.length; _a++) { + var specifier = _b[_a]; + writeLine(); + emitStart(specifier.name); + emitContainingModuleName(specifier); + write("."); + emitNodeWithCommentsAndWithoutSourcemap(specifier.name); + emitEnd(specifier.name); + write(" = "); + emitExpressionIdentifier(name); + write(";"); + } + } + } + function emitExportSpecifierInSystemModule(specifier) { + ts.Debug.assert(modulekind === 4 /* System */); + if (!resolver.getReferencedValueDeclaration(specifier.propertyName || specifier.name) && !resolver.isValueAliasDeclaration(specifier)) { + return; + } + writeLine(); + emitStart(specifier.name); + write(exportFunctionForFile + "(\""); + emitNodeWithCommentsAndWithoutSourcemap(specifier.name); + write("\", "); + emitExpressionIdentifier(specifier.propertyName || specifier.name); + write(")"); + emitEnd(specifier.name); + write(";"); + } + /** + * Emit an assignment to a given identifier, 'name', with a given expression, 'value'. + * @param name an identifier as a left-hand-side operand of the assignment + * @param value an expression as a right-hand-side operand of the assignment + * @param shouldEmitCommaBeforeAssignment a boolean indicating whether to prefix an assignment with comma + */ + function emitAssignment(name, value, shouldEmitCommaBeforeAssignment) { + if (shouldEmitCommaBeforeAssignment) { + write(", "); + } + var exportChanged = isNameOfExportedSourceLevelDeclarationInSystemExternalModule(name); + if (exportChanged) { + write(exportFunctionForFile + "(\""); + emitNodeWithCommentsAndWithoutSourcemap(name); + write("\", "); + } + var isVariableDeclarationOrBindingElement = name.parent && (name.parent.kind === 211 /* VariableDeclaration */ || name.parent.kind === 163 /* BindingElement */); + if (isVariableDeclarationOrBindingElement) { + emitModuleMemberName(name.parent); + } + else { + emit(name); + } + write(" = "); + emit(value); + if (exportChanged) { + write(")"); + } + } + /** + * Create temporary variable, emit an assignment of the variable the given expression + * @param expression an expression to assign to the newly created temporary variable + * @param canDefineTempVariablesInPlace a boolean indicating whether you can define the temporary variable at an assignment location + * @param shouldEmitCommaBeforeAssignment a boolean indicating whether an assignment should prefix with comma + */ + function emitTempVariableAssignment(expression, canDefineTempVariablesInPlace, shouldEmitCommaBeforeAssignment) { + var identifier = createTempVariable(0 /* Auto */); + if (!canDefineTempVariablesInPlace) { + recordTempDeclaration(identifier); + } + emitAssignment(identifier, expression, shouldEmitCommaBeforeAssignment); + return identifier; + } + function emitDestructuring(root, isAssignmentExpressionStatement, value) { + var emitCount = 0; + // An exported declaration is actually emitted as an assignment (to a property on the module object), so + // temporary variables in an exported declaration need to have real declarations elsewhere + // Also temporary variables should be explicitly allocated for source level declarations when module target is system + // because actual variable declarations are hoisted + var canDefineTempVariablesInPlace = false; + if (root.kind === 211 /* VariableDeclaration */) { + var isExported = ts.getCombinedNodeFlags(root) & 1 /* Export */; + var isSourceLevelForSystemModuleKind = shouldHoistDeclarationInSystemJsModule(root); + canDefineTempVariablesInPlace = !isExported && !isSourceLevelForSystemModuleKind; + } + else if (root.kind === 138 /* Parameter */) { + canDefineTempVariablesInPlace = true; + } + if (root.kind === 181 /* BinaryExpression */) { + emitAssignmentExpression(root); + } + else { + ts.Debug.assert(!isAssignmentExpressionStatement); + emitBindingElement(root, value); + } + /** + * Ensures that there exists a declared identifier whose value holds the given expression. + * This function is useful to ensure that the expression's value can be read from in subsequent expressions. + * Unless 'reuseIdentifierExpressions' is false, 'expr' will be returned if it is just an identifier. + * + * @param expr the expression whose value needs to be bound. + * @param reuseIdentifierExpressions true if identifier expressions can simply be returned; + * false if it is necessary to always emit an identifier. + */ + function ensureIdentifier(expr, reuseIdentifierExpressions) { + if (expr.kind === 69 /* Identifier */ && reuseIdentifierExpressions) { + return expr; + } + var identifier = emitTempVariableAssignment(expr, canDefineTempVariablesInPlace, emitCount > 0); + emitCount++; + return identifier; + } + function createDefaultValueCheck(value, defaultValue) { + // The value expression will be evaluated twice, so for anything but a simple identifier + // we need to generate a temporary variable + value = ensureIdentifier(value, /*reuseIdentifierExpressions*/ true); + // Return the expression 'value === void 0 ? defaultValue : value' + var equals = ts.createSynthesizedNode(181 /* BinaryExpression */); + equals.left = value; + equals.operatorToken = ts.createSynthesizedNode(32 /* EqualsEqualsEqualsToken */); + equals.right = createVoidZero(); + return createConditionalExpression(equals, defaultValue, value); + } + function createConditionalExpression(condition, whenTrue, whenFalse) { + var cond = ts.createSynthesizedNode(182 /* ConditionalExpression */); + cond.condition = condition; + cond.questionToken = ts.createSynthesizedNode(53 /* QuestionToken */); + cond.whenTrue = whenTrue; + cond.colonToken = ts.createSynthesizedNode(54 /* ColonToken */); + cond.whenFalse = whenFalse; + return cond; + } + function createNumericLiteral(value) { + var node = ts.createSynthesizedNode(8 /* NumericLiteral */); + node.text = "" + value; + return node; + } + function createPropertyAccessForDestructuringProperty(object, propName) { + // We create a synthetic copy of the identifier in order to avoid the rewriting that might + // otherwise occur when the identifier is emitted. + var syntheticName = ts.createSynthesizedNode(propName.kind); + syntheticName.text = propName.text; + if (syntheticName.kind !== 69 /* Identifier */) { + return createElementAccessExpression(object, syntheticName); + } + return createPropertyAccessExpression(object, syntheticName); + } + function createSliceCall(value, sliceIndex) { + var call = ts.createSynthesizedNode(168 /* CallExpression */); + var sliceIdentifier = ts.createSynthesizedNode(69 /* Identifier */); + sliceIdentifier.text = "slice"; + call.expression = createPropertyAccessExpression(value, sliceIdentifier); + call.arguments = ts.createSynthesizedNodeArray(); + call.arguments[0] = createNumericLiteral(sliceIndex); + return call; + } + function emitObjectLiteralAssignment(target, value) { + var properties = target.properties; + if (properties.length !== 1) { + // For anything but a single element destructuring we need to generate a temporary + // to ensure value is evaluated exactly once. + value = ensureIdentifier(value, /*reuseIdentifierExpressions*/ true); + } + for (var _a = 0; _a < properties.length; _a++) { + var p = properties[_a]; + if (p.kind === 245 /* PropertyAssignment */ || p.kind === 246 /* ShorthandPropertyAssignment */) { + var propName = p.name; + var target_1 = p.kind === 246 /* ShorthandPropertyAssignment */ ? p : p.initializer || propName; + emitDestructuringAssignment(target_1, createPropertyAccessForDestructuringProperty(value, propName)); + } + } + } + function emitArrayLiteralAssignment(target, value) { + var elements = target.elements; + if (elements.length !== 1) { + // For anything but a single element destructuring we need to generate a temporary + // to ensure value is evaluated exactly once. + value = ensureIdentifier(value, /*reuseIdentifierExpressions*/ true); + } + for (var i = 0; i < elements.length; i++) { + var e = elements[i]; + if (e.kind !== 187 /* OmittedExpression */) { + if (e.kind !== 185 /* SpreadElementExpression */) { + emitDestructuringAssignment(e, createElementAccessExpression(value, createNumericLiteral(i))); + } + else if (i === elements.length - 1) { + emitDestructuringAssignment(e.expression, createSliceCall(value, i)); + } + } + } + } + function emitDestructuringAssignment(target, value) { + if (target.kind === 246 /* ShorthandPropertyAssignment */) { + if (target.objectAssignmentInitializer) { + value = createDefaultValueCheck(value, target.objectAssignmentInitializer); + } + target = target.name; + } + else if (target.kind === 181 /* BinaryExpression */ && target.operatorToken.kind === 56 /* EqualsToken */) { + value = createDefaultValueCheck(value, target.right); + target = target.left; + } + if (target.kind === 165 /* ObjectLiteralExpression */) { + emitObjectLiteralAssignment(target, value); + } + else if (target.kind === 164 /* ArrayLiteralExpression */) { + emitArrayLiteralAssignment(target, value); + } + else { + emitAssignment(target, value, /*shouldEmitCommaBeforeAssignment*/ emitCount > 0); + emitCount++; + } + } + function emitAssignmentExpression(root) { + var target = root.left; + var value = root.right; + if (ts.isEmptyObjectLiteralOrArrayLiteral(target)) { + emit(value); + } + else if (isAssignmentExpressionStatement) { + emitDestructuringAssignment(target, value); + } + else { + if (root.parent.kind !== 172 /* ParenthesizedExpression */) { + write("("); + } + value = ensureIdentifier(value, /*reuseIdentifierExpressions*/ true); + emitDestructuringAssignment(target, value); + write(", "); + emit(value); + if (root.parent.kind !== 172 /* ParenthesizedExpression */) { + write(")"); + } + } + } + function emitBindingElement(target, value) { + if (target.initializer) { + // Combine value and initializer + value = value ? createDefaultValueCheck(value, target.initializer) : target.initializer; + } + else if (!value) { + // Use 'void 0' in absence of value and initializer + value = createVoidZero(); + } + if (ts.isBindingPattern(target.name)) { + var pattern = target.name; + var elements = pattern.elements; + var numElements = elements.length; + if (numElements !== 1) { + // For anything other than a single-element destructuring we need to generate a temporary + // to ensure value is evaluated exactly once. Additionally, if we have zero elements + // we need to emit *something* to ensure that in case a 'var' keyword was already emitted, + // so in that case, we'll intentionally create that temporary. + value = ensureIdentifier(value, /*reuseIdentifierExpressions*/ numElements !== 0); + } + for (var i = 0; i < numElements; i++) { + var element = elements[i]; + if (pattern.kind === 161 /* ObjectBindingPattern */) { + // Rewrite element to a declaration with an initializer that fetches property + var propName = element.propertyName || element.name; + emitBindingElement(element, createPropertyAccessForDestructuringProperty(value, propName)); + } + else if (element.kind !== 187 /* OmittedExpression */) { + if (!element.dotDotDotToken) { + // Rewrite element to a declaration that accesses array element at index i + emitBindingElement(element, createElementAccessExpression(value, createNumericLiteral(i))); + } + else if (i === numElements - 1) { + emitBindingElement(element, createSliceCall(value, i)); + } + } + } + } + else { + emitAssignment(target.name, value, /*shouldEmitCommaBeforeAssignment*/ emitCount > 0); + emitCount++; + } + } + } + function emitVariableDeclaration(node) { + if (ts.isBindingPattern(node.name)) { + if (languageVersion < 2 /* ES6 */) { + emitDestructuring(node, /*isAssignmentExpressionStatement*/ false); + } + else { + emit(node.name); + emitOptional(" = ", node.initializer); + } + } + else { + var initializer = node.initializer; + if (!initializer && languageVersion < 2 /* ES6 */) { + // downlevel emit for non-initialized let bindings defined in loops + // for (...) { let x; } + // should be + // for (...) { var = void 0; } + // this is necessary to preserve ES6 semantic in scenarios like + // for (...) { let x; console.log(x); x = 1 } // assignment on one iteration should not affect other iterations + var isUninitializedLet = (resolver.getNodeCheckFlags(node) & 16384 /* BlockScopedBindingInLoop */) && + (getCombinedFlagsForIdentifier(node.name) & 16384 /* Let */); + // NOTE: default initialization should not be added to let bindings in for-in\for-of statements + if (isUninitializedLet && + node.parent.parent.kind !== 200 /* ForInStatement */ && + node.parent.parent.kind !== 201 /* ForOfStatement */) { + initializer = createVoidZero(); + } + } + var exportChanged = isNameOfExportedSourceLevelDeclarationInSystemExternalModule(node.name); + if (exportChanged) { + write(exportFunctionForFile + "(\""); + emitNodeWithCommentsAndWithoutSourcemap(node.name); + write("\", "); + } + emitModuleMemberName(node); + emitOptional(" = ", initializer); + if (exportChanged) { + write(")"); + } + } + } + function emitExportVariableAssignments(node) { + if (node.kind === 187 /* OmittedExpression */) { + return; + } + var name = node.name; + if (name.kind === 69 /* Identifier */) { + emitExportMemberAssignments(name); + } + else if (ts.isBindingPattern(name)) { + ts.forEach(name.elements, emitExportVariableAssignments); + } + } + function getCombinedFlagsForIdentifier(node) { + if (!node.parent || (node.parent.kind !== 211 /* VariableDeclaration */ && node.parent.kind !== 163 /* BindingElement */)) { + return 0; + } + return ts.getCombinedNodeFlags(node.parent); + } + function isES6ExportedDeclaration(node) { + return !!(node.flags & 1 /* Export */) && + modulekind === 5 /* ES6 */ && + node.parent.kind === 248 /* SourceFile */; + } + function emitVariableStatement(node) { + var startIsEmitted = false; + if (node.flags & 1 /* Export */) { + if (isES6ExportedDeclaration(node)) { + // Exported ES6 module member + write("export "); + startIsEmitted = tryEmitStartOfVariableDeclarationList(node.declarationList); + } + } + else { + startIsEmitted = tryEmitStartOfVariableDeclarationList(node.declarationList); + } + if (startIsEmitted) { + emitCommaList(node.declarationList.declarations); + write(";"); + } + else { + var atLeastOneItem = emitVariableDeclarationListSkippingUninitializedEntries(node.declarationList); + if (atLeastOneItem) { + write(";"); + } + } + if (modulekind !== 5 /* ES6 */ && node.parent === currentSourceFile) { + ts.forEach(node.declarationList.declarations, emitExportVariableAssignments); + } + } + function shouldEmitLeadingAndTrailingCommentsForVariableStatement(node) { + // If we're not exporting the variables, there's nothing special here. + // Always emit comments for these nodes. + if (!(node.flags & 1 /* Export */)) { + return true; + } + // If we are exporting, but it's a top-level ES6 module exports, + // we'll emit the declaration list verbatim, so emit comments too. + if (isES6ExportedDeclaration(node)) { + return true; + } + // Otherwise, only emit if we have at least one initializer present. + for (var _a = 0, _b = node.declarationList.declarations; _a < _b.length; _a++) { + var declaration = _b[_a]; + if (declaration.initializer) { + return true; + } + } + return false; + } + function emitParameter(node) { + if (languageVersion < 2 /* ES6 */) { + if (ts.isBindingPattern(node.name)) { + var name_24 = createTempVariable(0 /* Auto */); + if (!tempParameters) { + tempParameters = []; + } + tempParameters.push(name_24); + emit(name_24); + } + else { + emit(node.name); + } + } + else { + if (node.dotDotDotToken) { + write("..."); + } + emit(node.name); + emitOptional(" = ", node.initializer); + } + } + function emitDefaultValueAssignments(node) { + if (languageVersion < 2 /* ES6 */) { + var tempIndex = 0; + ts.forEach(node.parameters, function (parameter) { + // A rest parameter cannot have a binding pattern or an initializer, + // so let's just ignore it. + if (parameter.dotDotDotToken) { + return; + } + var paramName = parameter.name, initializer = parameter.initializer; + if (ts.isBindingPattern(paramName)) { + // 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. + var hasBindingElements = paramName.elements.length > 0; + if (hasBindingElements || initializer) { + writeLine(); + write("var "); + if (hasBindingElements) { + emitDestructuring(parameter, /*isAssignmentExpressionStatement*/ false, tempParameters[tempIndex]); + } + else { + emit(tempParameters[tempIndex]); + write(" = "); + emit(initializer); + } + write(";"); + tempIndex++; + } + } + else if (initializer) { + writeLine(); + emitStart(parameter); + write("if ("); + emitNodeWithoutSourceMap(paramName); + write(" === void 0)"); + emitEnd(parameter); + write(" { "); + emitStart(parameter); + emitNodeWithCommentsAndWithoutSourcemap(paramName); + write(" = "); + emitNodeWithCommentsAndWithoutSourcemap(initializer); + emitEnd(parameter); + write("; }"); + } + }); + } + } + function emitRestParameter(node) { + if (languageVersion < 2 /* ES6 */ && ts.hasRestParameter(node)) { + var restIndex = node.parameters.length - 1; + var restParam = node.parameters[restIndex]; + // A rest parameter cannot have a binding pattern, so let's just ignore it if it does. + if (ts.isBindingPattern(restParam.name)) { + return; + } + var tempName = createTempVariable(268435456 /* _i */).text; + writeLine(); + emitLeadingComments(restParam); + emitStart(restParam); + write("var "); + emitNodeWithCommentsAndWithoutSourcemap(restParam.name); + write(" = [];"); + emitEnd(restParam); + emitTrailingComments(restParam); + writeLine(); + write("for ("); + emitStart(restParam); + write("var " + tempName + " = " + restIndex + ";"); + emitEnd(restParam); + write(" "); + emitStart(restParam); + write(tempName + " < arguments.length;"); + emitEnd(restParam); + write(" "); + emitStart(restParam); + write(tempName + "++"); + emitEnd(restParam); + write(") {"); + increaseIndent(); + writeLine(); + emitStart(restParam); + emitNodeWithCommentsAndWithoutSourcemap(restParam.name); + write("[" + tempName + " - " + restIndex + "] = arguments[" + tempName + "];"); + emitEnd(restParam); + decreaseIndent(); + writeLine(); + write("}"); + } + } + function emitAccessor(node) { + write(node.kind === 145 /* GetAccessor */ ? "get " : "set "); + emit(node.name); + emitSignatureAndBody(node); + } + function shouldEmitAsArrowFunction(node) { + return node.kind === 174 /* ArrowFunction */ && languageVersion >= 2 /* ES6 */; + } + function emitDeclarationName(node) { + if (node.name) { + emitNodeWithCommentsAndWithoutSourcemap(node.name); + } + else { + write(getGeneratedNameForNode(node)); + } + } + function shouldEmitFunctionName(node) { + if (node.kind === 173 /* FunctionExpression */) { + // Emit name if one is present + return !!node.name; + } + if (node.kind === 213 /* FunctionDeclaration */) { + // Emit name if one is present, or emit generated name in down-level case (for export default case) + return !!node.name || languageVersion < 2 /* ES6 */; + } + } + function emitFunctionDeclaration(node) { + if (ts.nodeIsMissing(node.body)) { + return emitCommentsOnNotEmittedNode(node); + } + // TODO (yuisu) : we should not have special cases to condition emitting comments + // but have one place to fix check for these conditions. + if (node.kind !== 143 /* MethodDeclaration */ && node.kind !== 142 /* MethodSignature */ && + node.parent && node.parent.kind !== 245 /* PropertyAssignment */ && + node.parent.kind !== 168 /* CallExpression */) { + // 1. Methods will emit the comments as part of emitting method declaration + // 2. If the function is a property of object literal, emitting leading-comments + // is done by emitNodeWithoutSourceMap which then call this function. + // In particular, we would like to avoid emit comments twice in following case: + // For example: + // var obj = { + // id: + // /*comment*/ () => void + // } + // 3. If the function is an argument in call expression, emitting of comments will be + // taken care of in emit list of arguments inside of emitCallexpression + emitLeadingComments(node); + } + emitStart(node); + // For targeting below es6, emit functions-like declaration including arrow function using function keyword. + // When targeting ES6, emit arrow function natively in ES6 by omitting function keyword and using fat arrow instead + if (!shouldEmitAsArrowFunction(node)) { + if (isES6ExportedDeclaration(node)) { + write("export "); + if (node.flags & 1024 /* Default */) { + write("default "); + } + } + write("function"); + if (languageVersion >= 2 /* ES6 */ && node.asteriskToken) { + write("*"); + } + write(" "); + } + if (shouldEmitFunctionName(node)) { + emitDeclarationName(node); + } + emitSignatureAndBody(node); + if (modulekind !== 5 /* ES6 */ && node.kind === 213 /* FunctionDeclaration */ && node.parent === currentSourceFile && node.name) { + emitExportMemberAssignments(node.name); + } + emitEnd(node); + if (node.kind !== 143 /* MethodDeclaration */ && node.kind !== 142 /* MethodSignature */) { + emitTrailingComments(node); + } + } + function emitCaptureThisForNodeIfNecessary(node) { + if (resolver.getNodeCheckFlags(node) & 4 /* CaptureThis */) { + writeLine(); + emitStart(node); + write("var _this = this;"); + emitEnd(node); + } + } + function emitSignatureParameters(node) { + increaseIndent(); + write("("); + if (node) { + var parameters = node.parameters; + var omitCount = languageVersion < 2 /* ES6 */ && ts.hasRestParameter(node) ? 1 : 0; + emitList(parameters, 0, parameters.length - omitCount, /*multiLine*/ false, /*trailingComma*/ false); + } + write(")"); + decreaseIndent(); + } + function emitSignatureParametersForArrow(node) { + // Check whether the parameter list needs parentheses and preserve no-parenthesis + if (node.parameters.length === 1 && node.pos === node.parameters[0].pos) { + emit(node.parameters[0]); + return; + } + emitSignatureParameters(node); + } + function emitAsyncFunctionBodyForES6(node) { + var promiseConstructor = ts.getEntityNameFromTypeNode(node.type); + var isArrowFunction = node.kind === 174 /* ArrowFunction */; + var hasLexicalArguments = (resolver.getNodeCheckFlags(node) & 4096 /* CaptureArguments */) !== 0; + var args; + // 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. + // + // The emit for an async arrow without a lexical `arguments` binding might be: + // + // // input + // let a = async (b) => { await b; } + // + // // output + // let a = (b) => __awaiter(this, void 0, void 0, function* () { + // yield b; + // }); + // + // The emit for an async arrow with a lexical `arguments` binding might be: + // + // // input + // let a = async (b) => { await arguments[0]; } + // + // // output + // let a = (b) => __awaiter(this, arguments, void 0, function* (arguments) { + // yield arguments[0]; + // }); + // + // The emit for an async function expression without a lexical `arguments` binding + // might be: + // + // // input + // let a = async function (b) { + // await b; + // } + // + // // output + // let a = function (b) { + // return __awaiter(this, void 0, void 0, function* () { + // yield b; + // }); + // } + // + // The emit for an async function expression with a lexical `arguments` binding + // might be: + // + // // input + // let a = async function (b) { + // await arguments[0]; + // } + // + // // output + // let a = function (b) { + // return __awaiter(this, arguments, void 0, function* (_arguments) { + // yield _arguments[0]; + // }); + // } + // + // The emit for an async function expression with a lexical `arguments` binding + // and a return type annotation might be: + // + // // input + // let a = async function (b): MyPromise { + // await arguments[0]; + // } + // + // // output + // let a = function (b) { + // return __awaiter(this, arguments, MyPromise, function* (_arguments) { + // yield _arguments[0]; + // }); + // } + // + // If this is not an async arrow, emit the opening brace of the function body + // and the start of the return statement. + if (!isArrowFunction) { + write(" {"); + increaseIndent(); + writeLine(); + write("return"); + } + write(" __awaiter(this"); + if (hasLexicalArguments) { + write(", arguments"); + } + else { + write(", void 0"); + } + if (promiseConstructor) { + write(", "); + emitNodeWithoutSourceMap(promiseConstructor); + } + else { + write(", Promise"); + } + // Emit the call to __awaiter. + if (hasLexicalArguments) { + write(", function* (_arguments)"); + } + else { + write(", function* ()"); + } + // Emit the signature and body for the inner generator function. + emitFunctionBody(node); + write(")"); + // If this is not an async arrow, emit the closing brace of the outer function body. + if (!isArrowFunction) { + write(";"); + decreaseIndent(); + writeLine(); + write("}"); + } + } + function emitFunctionBody(node) { + if (!node.body) { + // There can be no body when there are parse errors. Just emit an empty block + // in that case. + write(" { }"); + } + else { + if (node.body.kind === 192 /* Block */) { + emitBlockFunctionBody(node, node.body); + } + else { + emitExpressionFunctionBody(node, node.body); + } + } + } + function emitSignatureAndBody(node) { + var saveTempFlags = tempFlags; + var saveTempVariables = tempVariables; + var saveTempParameters = tempParameters; + tempFlags = 0; + tempVariables = undefined; + tempParameters = undefined; + // When targeting ES6, emit arrow function natively in ES6 + if (shouldEmitAsArrowFunction(node)) { + emitSignatureParametersForArrow(node); + write(" =>"); + } + else { + emitSignatureParameters(node); + } + var isAsync = ts.isAsyncFunctionLike(node); + if (isAsync && languageVersion === 2 /* ES6 */) { + emitAsyncFunctionBodyForES6(node); + } + else { + emitFunctionBody(node); + } + if (!isES6ExportedDeclaration(node)) { + emitExportMemberAssignment(node); + } + tempFlags = saveTempFlags; + tempVariables = saveTempVariables; + tempParameters = saveTempParameters; + } + // Returns true if any preamble code was emitted. + function emitFunctionBodyPreamble(node) { + emitCaptureThisForNodeIfNecessary(node); + emitDefaultValueAssignments(node); + emitRestParameter(node); + } + function emitExpressionFunctionBody(node, body) { + if (languageVersion < 2 /* ES6 */ || node.flags & 512 /* Async */) { + emitDownLevelExpressionFunctionBody(node, body); + return; + } + // For es6 and higher we can emit the expression as is. However, in the case + // where the expression might end up looking like a block when emitted, we'll + // also wrap it in parentheses first. For example if you have: a => {} + // then we need to generate: a => ({}) + write(" "); + // Unwrap all type assertions. + var current = body; + while (current.kind === 171 /* TypeAssertionExpression */) { + current = current.expression; + } + emitParenthesizedIf(body, current.kind === 165 /* ObjectLiteralExpression */); + } + function emitDownLevelExpressionFunctionBody(node, body) { + write(" {"); + scopeEmitStart(node); + increaseIndent(); + var outPos = writer.getTextPos(); + emitDetachedComments(node.body); + emitFunctionBodyPreamble(node); + var preambleEmitted = writer.getTextPos() !== outPos; + decreaseIndent(); + // If we didn't have to emit any preamble code, then attempt to keep the arrow + // function on one line. + if (!preambleEmitted && nodeStartPositionsAreOnSameLine(node, body)) { + write(" "); + emitStart(body); + write("return "); + emit(body); + emitEnd(body); + write(";"); + emitTempDeclarations(/*newLine*/ false); + write(" "); + } + else { + increaseIndent(); + writeLine(); + emitLeadingComments(node.body); + write("return "); + emit(body); + write(";"); + emitTrailingComments(node.body); + emitTempDeclarations(/*newLine*/ true); + decreaseIndent(); + writeLine(); + } + emitStart(node.body); + write("}"); + emitEnd(node.body); + scopeEmitEnd(); + } + function emitBlockFunctionBody(node, body) { + write(" {"); + scopeEmitStart(node); + var initialTextPos = writer.getTextPos(); + increaseIndent(); + emitDetachedComments(body.statements); + // Emit all the directive prologues (like "use strict"). These have to come before + // any other preamble code we write (like parameter initializers). + var startIndex = emitDirectivePrologues(body.statements, /*startWithNewLine*/ true); + emitFunctionBodyPreamble(node); + decreaseIndent(); + var preambleEmitted = writer.getTextPos() !== initialTextPos; + if (!preambleEmitted && nodeEndIsOnSameLineAsNodeStart(body, body)) { + for (var _a = 0, _b = body.statements; _a < _b.length; _a++) { + var statement = _b[_a]; + write(" "); + emit(statement); + } + emitTempDeclarations(/*newLine*/ false); + write(" "); + emitLeadingCommentsOfPosition(body.statements.end); + } + else { + increaseIndent(); + emitLinesStartingAt(body.statements, startIndex); + emitTempDeclarations(/*newLine*/ true); + writeLine(); + emitLeadingCommentsOfPosition(body.statements.end); + decreaseIndent(); + } + emitToken(16 /* CloseBraceToken */, body.statements.end); + scopeEmitEnd(); + } + function findInitialSuperCall(ctor) { + if (ctor.body) { + var statement = ctor.body.statements[0]; + if (statement && statement.kind === 195 /* ExpressionStatement */) { + var expr = statement.expression; + if (expr && expr.kind === 168 /* CallExpression */) { + var func = expr.expression; + if (func && func.kind === 95 /* SuperKeyword */) { + return statement; + } + } + } + } + } + function emitParameterPropertyAssignments(node) { + ts.forEach(node.parameters, function (param) { + if (param.flags & 112 /* AccessibilityModifier */) { + writeLine(); + emitStart(param); + emitStart(param.name); + write("this."); + emitNodeWithoutSourceMap(param.name); + emitEnd(param.name); + write(" = "); + emit(param.name); + write(";"); + emitEnd(param); + } + }); + } + function emitMemberAccessForPropertyName(memberName) { + // This does not emit source map because it is emitted by caller as caller + // is aware how the property name changes to the property access + // eg. public x = 10; becomes this.x and static x = 10 becomes className.x + if (memberName.kind === 9 /* StringLiteral */ || memberName.kind === 8 /* NumericLiteral */) { + write("["); + emitNodeWithCommentsAndWithoutSourcemap(memberName); + write("]"); + } + else if (memberName.kind === 136 /* ComputedPropertyName */) { + emitComputedPropertyName(memberName); + } + else { + write("."); + emitNodeWithCommentsAndWithoutSourcemap(memberName); + } + } + function getInitializedProperties(node, isStatic) { + var properties = []; + for (var _a = 0, _b = node.members; _a < _b.length; _a++) { + var member = _b[_a]; + if (member.kind === 141 /* PropertyDeclaration */ && isStatic === ((member.flags & 128 /* Static */) !== 0) && member.initializer) { + properties.push(member); + } + } + return properties; + } + function emitPropertyDeclarations(node, properties) { + for (var _a = 0; _a < properties.length; _a++) { + var property = properties[_a]; + emitPropertyDeclaration(node, property); + } + } + function emitPropertyDeclaration(node, property, receiver, isExpression) { + writeLine(); + emitLeadingComments(property); + emitStart(property); + emitStart(property.name); + if (receiver) { + emit(receiver); + } + else { + if (property.flags & 128 /* Static */) { + emitDeclarationName(node); + } + else { + write("this"); + } + } + emitMemberAccessForPropertyName(property.name); + emitEnd(property.name); + write(" = "); + emit(property.initializer); + if (!isExpression) { + write(";"); + } + emitEnd(property); + emitTrailingComments(property); + } + function emitMemberFunctionsForES5AndLower(node) { + ts.forEach(node.members, function (member) { + if (member.kind === 191 /* SemicolonClassElement */) { + writeLine(); + write(";"); + } + else if (member.kind === 143 /* MethodDeclaration */ || node.kind === 142 /* MethodSignature */) { + if (!member.body) { + return emitCommentsOnNotEmittedNode(member); + } + writeLine(); + emitLeadingComments(member); + emitStart(member); + emitStart(member.name); + emitClassMemberPrefix(node, member); + emitMemberAccessForPropertyName(member.name); + emitEnd(member.name); + write(" = "); + emitFunctionDeclaration(member); + emitEnd(member); + write(";"); + emitTrailingComments(member); + } + else if (member.kind === 145 /* GetAccessor */ || member.kind === 146 /* SetAccessor */) { + var accessors = ts.getAllAccessorDeclarations(node.members, member); + if (member === accessors.firstAccessor) { + writeLine(); + emitStart(member); + write("Object.defineProperty("); + emitStart(member.name); + emitClassMemberPrefix(node, member); + write(", "); + emitExpressionForPropertyName(member.name); + emitEnd(member.name); + write(", {"); + increaseIndent(); + if (accessors.getAccessor) { + writeLine(); + emitLeadingComments(accessors.getAccessor); + write("get: "); + emitStart(accessors.getAccessor); + write("function "); + emitSignatureAndBody(accessors.getAccessor); + emitEnd(accessors.getAccessor); + emitTrailingComments(accessors.getAccessor); + write(","); + } + if (accessors.setAccessor) { + writeLine(); + emitLeadingComments(accessors.setAccessor); + write("set: "); + emitStart(accessors.setAccessor); + write("function "); + emitSignatureAndBody(accessors.setAccessor); + emitEnd(accessors.setAccessor); + emitTrailingComments(accessors.setAccessor); + write(","); + } + writeLine(); + write("enumerable: true,"); + writeLine(); + write("configurable: true"); + decreaseIndent(); + writeLine(); + write("});"); + emitEnd(member); + } + } + }); + } + function emitMemberFunctionsForES6AndHigher(node) { + for (var _a = 0, _b = node.members; _a < _b.length; _a++) { + var member = _b[_a]; + if ((member.kind === 143 /* MethodDeclaration */ || node.kind === 142 /* MethodSignature */) && !member.body) { + emitCommentsOnNotEmittedNode(member); + } + else if (member.kind === 143 /* MethodDeclaration */ || + member.kind === 145 /* GetAccessor */ || + member.kind === 146 /* SetAccessor */) { + writeLine(); + emitLeadingComments(member); + emitStart(member); + if (member.flags & 128 /* Static */) { + write("static "); + } + if (member.kind === 145 /* GetAccessor */) { + write("get "); + } + else if (member.kind === 146 /* SetAccessor */) { + write("set "); + } + if (member.asteriskToken) { + write("*"); + } + emit(member.name); + emitSignatureAndBody(member); + emitEnd(member); + emitTrailingComments(member); + } + else if (member.kind === 191 /* SemicolonClassElement */) { + writeLine(); + write(";"); + } + } + } + function emitConstructor(node, baseTypeElement) { + var saveTempFlags = tempFlags; + var saveTempVariables = tempVariables; + var saveTempParameters = tempParameters; + tempFlags = 0; + tempVariables = undefined; + tempParameters = undefined; + emitConstructorWorker(node, baseTypeElement); + tempFlags = saveTempFlags; + tempVariables = saveTempVariables; + tempParameters = saveTempParameters; + } + function emitConstructorWorker(node, baseTypeElement) { + // Check if we have property assignment inside class declaration. + // If there is property assignment, we need to emit constructor whether users define it or not + // If there is no property assignment, we can omit constructor if users do not define it + var hasInstancePropertyWithInitializer = false; + // Emit the constructor overload pinned comments + ts.forEach(node.members, function (member) { + if (member.kind === 144 /* Constructor */ && !member.body) { + emitCommentsOnNotEmittedNode(member); + } + // Check if there is any non-static property assignment + if (member.kind === 141 /* PropertyDeclaration */ && member.initializer && (member.flags & 128 /* Static */) === 0) { + hasInstancePropertyWithInitializer = true; + } + }); + var ctor = ts.getFirstConstructorWithBody(node); + // For target ES6 and above, if there is no user-defined constructor and there is no property assignment + // do not emit constructor in class declaration. + if (languageVersion >= 2 /* ES6 */ && !ctor && !hasInstancePropertyWithInitializer) { + return; + } + if (ctor) { + emitLeadingComments(ctor); + } + emitStart(ctor || node); + if (languageVersion < 2 /* ES6 */) { + write("function "); + emitDeclarationName(node); + emitSignatureParameters(ctor); + } + else { + write("constructor"); + if (ctor) { + emitSignatureParameters(ctor); + } + else { + // Based on EcmaScript6 section 14.5.14: Runtime Semantics: ClassDefinitionEvaluation. + // If constructor is empty, then, + // If ClassHeritageopt is present, then + // Let constructor be the result of parsing the String "constructor(... args){ super (...args);}" using the syntactic grammar with the goal symbol MethodDefinition. + // Else, + // Let constructor be the result of parsing the String "constructor( ){ }" using the syntactic grammar with the goal symbol MethodDefinition + if (baseTypeElement) { + write("(...args)"); + } + else { + write("()"); + } + } + } + var startIndex = 0; + write(" {"); + scopeEmitStart(node, "constructor"); + increaseIndent(); + if (ctor) { + // Emit all the directive prologues (like "use strict"). These have to come before + // any other preamble code we write (like parameter initializers). + startIndex = emitDirectivePrologues(ctor.body.statements, /*startWithNewLine*/ true); + emitDetachedComments(ctor.body.statements); + } + emitCaptureThisForNodeIfNecessary(node); + var superCall; + if (ctor) { + emitDefaultValueAssignments(ctor); + emitRestParameter(ctor); + if (baseTypeElement) { + superCall = findInitialSuperCall(ctor); + if (superCall) { + writeLine(); + emit(superCall); + } + } + emitParameterPropertyAssignments(ctor); + } + else { + if (baseTypeElement) { + writeLine(); + emitStart(baseTypeElement); + if (languageVersion < 2 /* ES6 */) { + write("_super.apply(this, arguments);"); + } + else { + write("super(...args);"); + } + emitEnd(baseTypeElement); + } + } + emitPropertyDeclarations(node, getInitializedProperties(node, /*static:*/ false)); + if (ctor) { + var statements = ctor.body.statements; + if (superCall) { + statements = statements.slice(1); + } + emitLinesStartingAt(statements, startIndex); + } + emitTempDeclarations(/*newLine*/ true); + writeLine(); + if (ctor) { + emitLeadingCommentsOfPosition(ctor.body.statements.end); + } + decreaseIndent(); + emitToken(16 /* CloseBraceToken */, ctor ? ctor.body.statements.end : node.members.end); + scopeEmitEnd(); + emitEnd(ctor || node); + if (ctor) { + emitTrailingComments(ctor); + } + } + function emitClassExpression(node) { + return emitClassLikeDeclaration(node); + } + function emitClassDeclaration(node) { + return emitClassLikeDeclaration(node); + } + function emitClassLikeDeclaration(node) { + if (languageVersion < 2 /* ES6 */) { + emitClassLikeDeclarationBelowES6(node); + } + else { + emitClassLikeDeclarationForES6AndHigher(node); + } + if (modulekind !== 5 /* ES6 */ && node.parent === currentSourceFile && node.name) { + emitExportMemberAssignments(node.name); + } + } + function emitClassLikeDeclarationForES6AndHigher(node) { + var thisNodeIsDecorated = ts.nodeIsDecorated(node); + if (node.kind === 214 /* ClassDeclaration */) { + if (thisNodeIsDecorated) { + // To preserve the correct runtime semantics when decorators are applied to the class, + // the emit needs to follow one of the following rules: + // + // * For a local class declaration: + // + // @dec class C { + // } + // + // The emit should be: + // + // let C = class { + // }; + // C = __decorate([dec], C); + // + // * For an exported class declaration: + // + // @dec export class C { + // } + // + // The emit should be: + // + // export let C = class { + // }; + // C = __decorate([dec], C); + // + // * For a default export of a class declaration with a name: + // + // @dec default export class C { + // } + // + // The emit should be: + // + // let C = class { + // } + // C = __decorate([dec], C); + // export default C; + // + // * For a default export of a class declaration without a name: + // + // @dec default export class { + // } + // + // The emit should be: + // + // let _default = class { + // } + // _default = __decorate([dec], _default); + // export default _default; + // + if (isES6ExportedDeclaration(node) && !(node.flags & 1024 /* Default */)) { + write("export "); + } + write("let "); + emitDeclarationName(node); + write(" = "); + } + else if (isES6ExportedDeclaration(node)) { + write("export "); + if (node.flags & 1024 /* Default */) { + write("default "); + } + } + } + // If the class has static properties, and it's a class expression, then we'll need + // to specialize the emit a bit. for a class expression of the form: + // + // class C { static a = 1; static b = 2; ... } + // + // We'll emit: + // + // (_temp = class C { ... }, _temp.a = 1, _temp.b = 2, _temp) + // + // This keeps the expression as an expression, while ensuring that the static parts + // of it have been initialized by the time it is used. + var staticProperties = getInitializedProperties(node, /*static:*/ true); + var isClassExpressionWithStaticProperties = staticProperties.length > 0 && node.kind === 186 /* ClassExpression */; + var tempVariable; + if (isClassExpressionWithStaticProperties) { + tempVariable = createAndRecordTempVariable(0 /* Auto */); + write("("); + increaseIndent(); + emit(tempVariable); + write(" = "); + } + write("class"); + // emit name if + // - node has a name + // - this is default export with static initializers + if ((node.name || (node.flags & 1024 /* Default */ && staticProperties.length > 0)) && !thisNodeIsDecorated) { + write(" "); + emitDeclarationName(node); + } + var baseTypeNode = ts.getClassExtendsHeritageClauseElement(node); + if (baseTypeNode) { + write(" extends "); + emit(baseTypeNode.expression); + } + write(" {"); + increaseIndent(); + scopeEmitStart(node); + writeLine(); + emitConstructor(node, baseTypeNode); + emitMemberFunctionsForES6AndHigher(node); + decreaseIndent(); + writeLine(); + emitToken(16 /* CloseBraceToken */, node.members.end); + scopeEmitEnd(); + // TODO(rbuckton): Need to go back to `let _a = class C {}` approach, removing the defineProperty call for now. + // For a decorated class, we need to assign its name (if it has one). This is because we emit + // the class as a class expression to avoid the double-binding of the identifier: + // + // let C = class { + // } + // Object.defineProperty(C, "name", { value: "C", configurable: true }); + // + if (thisNodeIsDecorated) { + write(";"); + } + // Emit static property assignment. Because classDeclaration is lexically evaluated, + // it is safe to emit static property assignment after classDeclaration + // From ES6 specification: + // 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 (isClassExpressionWithStaticProperties) { + for (var _a = 0; _a < staticProperties.length; _a++) { + var property = staticProperties[_a]; + write(","); + writeLine(); + emitPropertyDeclaration(node, property, /*receiver:*/ tempVariable, /*isExpression:*/ true); + } + write(","); + writeLine(); + emit(tempVariable); + decreaseIndent(); + write(")"); + } + else { + writeLine(); + emitPropertyDeclarations(node, staticProperties); + emitDecoratorsOfClass(node); + } + // If this is an exported class, but not on the top level (i.e. on an internal + // module), export it + if (!isES6ExportedDeclaration(node) && (node.flags & 1 /* Export */)) { + writeLine(); + emitStart(node); + emitModuleMemberName(node); + write(" = "); + emitDeclarationName(node); + emitEnd(node); + write(";"); + } + else if (isES6ExportedDeclaration(node) && (node.flags & 1024 /* Default */) && thisNodeIsDecorated) { + // if this is a top level default export of decorated class, write the export after the declaration. + writeLine(); + write("export default "); + emitDeclarationName(node); + write(";"); + } + } + function emitClassLikeDeclarationBelowES6(node) { + if (node.kind === 214 /* ClassDeclaration */) { + // source file level classes in system modules are hoisted so 'var's for them are already defined + if (!shouldHoistDeclarationInSystemJsModule(node)) { + write("var "); + } + emitDeclarationName(node); + write(" = "); + } + write("(function ("); + var baseTypeNode = ts.getClassExtendsHeritageClauseElement(node); + if (baseTypeNode) { + write("_super"); + } + write(") {"); + var saveTempFlags = tempFlags; + var saveTempVariables = tempVariables; + var saveTempParameters = tempParameters; + var saveComputedPropertyNamesToGeneratedNames = computedPropertyNamesToGeneratedNames; + tempFlags = 0; + tempVariables = undefined; + tempParameters = undefined; + computedPropertyNamesToGeneratedNames = undefined; + increaseIndent(); + scopeEmitStart(node); + if (baseTypeNode) { + writeLine(); + emitStart(baseTypeNode); + write("__extends("); + emitDeclarationName(node); + write(", _super);"); + emitEnd(baseTypeNode); + } + writeLine(); + emitConstructor(node, baseTypeNode); + emitMemberFunctionsForES5AndLower(node); + emitPropertyDeclarations(node, getInitializedProperties(node, /*static:*/ true)); + writeLine(); + emitDecoratorsOfClass(node); + writeLine(); + emitToken(16 /* CloseBraceToken */, node.members.end, function () { + write("return "); + emitDeclarationName(node); + }); + write(";"); + emitTempDeclarations(/*newLine*/ true); + tempFlags = saveTempFlags; + tempVariables = saveTempVariables; + tempParameters = saveTempParameters; + computedPropertyNamesToGeneratedNames = saveComputedPropertyNamesToGeneratedNames; + decreaseIndent(); + writeLine(); + emitToken(16 /* CloseBraceToken */, node.members.end); + scopeEmitEnd(); + emitStart(node); + write(")("); + if (baseTypeNode) { + emit(baseTypeNode.expression); + } + write(")"); + if (node.kind === 214 /* ClassDeclaration */) { + write(";"); + } + emitEnd(node); + if (node.kind === 214 /* ClassDeclaration */) { + emitExportMemberAssignment(node); + } + } + function emitClassMemberPrefix(node, member) { + emitDeclarationName(node); + if (!(member.flags & 128 /* Static */)) { + write(".prototype"); + } + } + function emitDecoratorsOfClass(node) { + emitDecoratorsOfMembers(node, /*staticFlag*/ 0); + emitDecoratorsOfMembers(node, 128 /* Static */); + emitDecoratorsOfConstructor(node); + } + function emitDecoratorsOfConstructor(node) { + var decorators = node.decorators; + var constructor = ts.getFirstConstructorWithBody(node); + var hasDecoratedParameters = constructor && ts.forEach(constructor.parameters, ts.nodeIsDecorated); + // skip decoration of the constructor if neither it nor its parameters are decorated + if (!decorators && !hasDecoratedParameters) { + return; + } + // Emit the call to __decorate. Given the class: + // + // @dec + // class C { + // } + // + // The emit for the class is: + // + // C = __decorate([dec], C); + // + writeLine(); + emitStart(node); + emitDeclarationName(node); + write(" = __decorate(["); + increaseIndent(); + writeLine(); + var decoratorCount = decorators ? decorators.length : 0; + var argumentsWritten = emitList(decorators, 0, decoratorCount, /*multiLine*/ true, /*trailingComma*/ false, /*leadingComma*/ false, /*noTrailingNewLine*/ true, function (decorator) { + emitStart(decorator); + emit(decorator.expression); + emitEnd(decorator); + }); + argumentsWritten += emitDecoratorsOfParameters(constructor, /*leadingComma*/ argumentsWritten > 0); + emitSerializedTypeMetadata(node, /*leadingComma*/ argumentsWritten >= 0); + decreaseIndent(); + writeLine(); + write("], "); + emitDeclarationName(node); + write(");"); + emitEnd(node); + writeLine(); + } + function emitDecoratorsOfMembers(node, staticFlag) { + for (var _a = 0, _b = node.members; _a < _b.length; _a++) { + var member = _b[_a]; + // only emit members in the correct group + if ((member.flags & 128 /* Static */) !== staticFlag) { + continue; + } + // skip members that cannot be decorated (such as the constructor) + if (!ts.nodeCanBeDecorated(member)) { + continue; + } + // skip a member if it or any of its parameters are not decorated + if (!ts.nodeOrChildIsDecorated(member)) { + continue; + } + // skip an accessor declaration if it is not the first accessor + var decorators = void 0; + var functionLikeMember = void 0; + if (ts.isAccessor(member)) { + var accessors = ts.getAllAccessorDeclarations(node.members, member); + if (member !== accessors.firstAccessor) { + continue; + } + // get the decorators from the first accessor with decorators + decorators = accessors.firstAccessor.decorators; + if (!decorators && accessors.secondAccessor) { + decorators = accessors.secondAccessor.decorators; + } + // we only decorate parameters of the set accessor + functionLikeMember = accessors.setAccessor; + } + else { + decorators = member.decorators; + // we only decorate the parameters here if this is a method + if (member.kind === 143 /* MethodDeclaration */) { + functionLikeMember = member; + } + } + // Emit the call to __decorate. Given the following: + // + // class C { + // @dec method(@dec2 x) {} + // @dec get accessor() {} + // @dec prop; + // } + // + // The emit for a method is: + // + // __decorate([ + // dec, + // __param(0, dec2), + // __metadata("design:type", Function), + // __metadata("design:paramtypes", [Object]), + // __metadata("design:returntype", void 0) + // ], C.prototype, "method", undefined); + // + // The emit for an accessor is: + // + // __decorate([ + // dec + // ], C.prototype, "accessor", undefined); + // + // The emit for a property is: + // + // __decorate([ + // dec + // ], C.prototype, "prop"); + // + writeLine(); + emitStart(member); + write("__decorate(["); + increaseIndent(); + writeLine(); + var decoratorCount = decorators ? decorators.length : 0; + var argumentsWritten = emitList(decorators, 0, decoratorCount, /*multiLine*/ true, /*trailingComma*/ false, /*leadingComma*/ false, /*noTrailingNewLine*/ true, function (decorator) { + emitStart(decorator); + emit(decorator.expression); + emitEnd(decorator); + }); + argumentsWritten += emitDecoratorsOfParameters(functionLikeMember, argumentsWritten > 0); + emitSerializedTypeMetadata(member, argumentsWritten > 0); + decreaseIndent(); + writeLine(); + write("], "); + emitStart(member.name); + emitClassMemberPrefix(node, member); + write(", "); + emitExpressionForPropertyName(member.name); + emitEnd(member.name); + if (languageVersion > 0 /* ES3 */) { + if (member.kind !== 141 /* PropertyDeclaration */) { + // We emit `null` here to indicate to `__decorate` that it can invoke `Object.getOwnPropertyDescriptor` directly. + // We have this extra argument here so that we can inject an explicit property descriptor at a later date. + write(", null"); + } + else { + // We emit `void 0` here to indicate to `__decorate` that it can invoke `Object.defineProperty` directly, but that it + // should not invoke `Object.getOwnPropertyDescriptor`. + write(", void 0"); + } + } + write(");"); + emitEnd(member); + writeLine(); + } + } + function emitDecoratorsOfParameters(node, leadingComma) { + var argumentsWritten = 0; + if (node) { + var parameterIndex = 0; + for (var _a = 0, _b = node.parameters; _a < _b.length; _a++) { + var parameter = _b[_a]; + if (ts.nodeIsDecorated(parameter)) { + var decorators = parameter.decorators; + argumentsWritten += emitList(decorators, 0, decorators.length, /*multiLine*/ true, /*trailingComma*/ false, /*leadingComma*/ leadingComma, /*noTrailingNewLine*/ true, function (decorator) { + emitStart(decorator); + write("__param(" + parameterIndex + ", "); + emit(decorator.expression); + write(")"); + emitEnd(decorator); + }); + leadingComma = true; + } + ++parameterIndex; + } + } + return argumentsWritten; + } + function shouldEmitTypeMetadata(node) { + // This method determines whether to emit the "design:type" metadata based on the node's kind. + // The caller should have already tested whether the node has decorators and whether the emitDecoratorMetadata + // compiler option is set. + switch (node.kind) { + case 143 /* MethodDeclaration */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: + case 141 /* PropertyDeclaration */: + return true; + } + return false; + } + function shouldEmitReturnTypeMetadata(node) { + // This method determines whether to emit the "design:returntype" metadata based on the node's kind. + // The caller should have already tested whether the node has decorators and whether the emitDecoratorMetadata + // compiler option is set. + switch (node.kind) { + case 143 /* MethodDeclaration */: + return true; + } + return false; + } + function shouldEmitParamTypesMetadata(node) { + // This method determines whether to emit the "design:paramtypes" metadata based on the node's kind. + // The caller should have already tested whether the node has decorators and whether the emitDecoratorMetadata + // compiler option is set. + switch (node.kind) { + case 214 /* ClassDeclaration */: + case 143 /* MethodDeclaration */: + case 146 /* SetAccessor */: + return true; + } + return false; + } + /** Serializes the type of a declaration to an appropriate JS constructor value. Used by the __metadata decorator for a class member. */ + function emitSerializedTypeOfNode(node) { + // serialization of the type of a declaration uses the following rules: + // + // * The serialized type of a ClassDeclaration is "Function" + // * The serialized type of a ParameterDeclaration is the serialized type of its type annotation. + // * The serialized type of a PropertyDeclaration is the serialized type of its type annotation. + // * The serialized type of an AccessorDeclaration is the serialized type of the return type annotation of its getter or parameter type annotation of its setter. + // * The serialized type of any other FunctionLikeDeclaration is "Function". + // * The serialized type of any other node is "void 0". + // + // For rules on serializing type annotations, see `serializeTypeNode`. + switch (node.kind) { + case 214 /* ClassDeclaration */: + write("Function"); + return; + case 141 /* PropertyDeclaration */: + emitSerializedTypeNode(node.type); + return; + case 138 /* Parameter */: + emitSerializedTypeNode(node.type); + return; + case 145 /* GetAccessor */: + emitSerializedTypeNode(node.type); + return; + case 146 /* SetAccessor */: + emitSerializedTypeNode(ts.getSetAccessorTypeAnnotationNode(node)); + return; + } + if (ts.isFunctionLike(node)) { + write("Function"); + return; + } + write("void 0"); + } + function emitSerializedTypeNode(node) { + if (node) { + switch (node.kind) { + case 103 /* VoidKeyword */: + write("void 0"); + return; + case 160 /* ParenthesizedType */: + emitSerializedTypeNode(node.type); + return; + case 152 /* FunctionType */: + case 153 /* ConstructorType */: + write("Function"); + return; + case 156 /* ArrayType */: + case 157 /* TupleType */: + write("Array"); + return; + case 150 /* TypePredicate */: + case 120 /* BooleanKeyword */: + write("Boolean"); + return; + case 130 /* StringKeyword */: + case 9 /* StringLiteral */: + write("String"); + return; + case 128 /* NumberKeyword */: + write("Number"); + return; + case 131 /* SymbolKeyword */: + write("Symbol"); + return; + case 151 /* TypeReference */: + emitSerializedTypeReferenceNode(node); + return; + case 154 /* TypeQuery */: + case 155 /* TypeLiteral */: + case 158 /* UnionType */: + case 159 /* IntersectionType */: + case 117 /* AnyKeyword */: + break; + default: + ts.Debug.fail("Cannot serialize unexpected type node."); + break; + } + } + write("Object"); + } + /** Serializes a TypeReferenceNode to an appropriate JS constructor value. Used by the __metadata decorator. */ + function emitSerializedTypeReferenceNode(node) { + var location = node.parent; + while (ts.isDeclaration(location) || ts.isTypeNode(location)) { + location = location.parent; + } + // Clone the type name and parent it to a location outside of the current declaration. + var typeName = ts.cloneEntityName(node.typeName); + typeName.parent = location; + var result = resolver.getTypeReferenceSerializationKind(typeName); + switch (result) { + case ts.TypeReferenceSerializationKind.Unknown: + var temp = createAndRecordTempVariable(0 /* Auto */); + write("(typeof ("); + emitNodeWithoutSourceMap(temp); + write(" = "); + emitEntityNameAsExpression(typeName, /*useFallback*/ true); + write(") === 'function' && "); + emitNodeWithoutSourceMap(temp); + write(") || Object"); + break; + case ts.TypeReferenceSerializationKind.TypeWithConstructSignatureAndValue: + emitEntityNameAsExpression(typeName, /*useFallback*/ false); + break; + case ts.TypeReferenceSerializationKind.VoidType: + write("void 0"); + break; + case ts.TypeReferenceSerializationKind.BooleanType: + write("Boolean"); + break; + case ts.TypeReferenceSerializationKind.NumberLikeType: + write("Number"); + break; + case ts.TypeReferenceSerializationKind.StringLikeType: + write("String"); + break; + case ts.TypeReferenceSerializationKind.ArrayLikeType: + write("Array"); + break; + case ts.TypeReferenceSerializationKind.ESSymbolType: + if (languageVersion < 2 /* ES6 */) { + write("typeof Symbol === 'function' ? Symbol : Object"); + } + else { + write("Symbol"); + } + break; + case ts.TypeReferenceSerializationKind.TypeWithCallSignature: + write("Function"); + break; + case ts.TypeReferenceSerializationKind.ObjectType: + write("Object"); + break; + } + } + /** Serializes the parameter types of a function or the constructor of a class. Used by the __metadata decorator for a method or set accessor. */ + function emitSerializedParameterTypesOfNode(node) { + // serialization of parameter types uses the following rules: + // + // * If the declaration is a class, the parameters of the first constructor with a body are used. + // * If the declaration is function-like and has a body, the parameters of the function are used. + // + // For the rules on serializing the type of each parameter declaration, see `serializeTypeOfDeclaration`. + if (node) { + var valueDeclaration; + if (node.kind === 214 /* ClassDeclaration */) { + valueDeclaration = ts.getFirstConstructorWithBody(node); + } + else if (ts.isFunctionLike(node) && ts.nodeIsPresent(node.body)) { + valueDeclaration = node; + } + if (valueDeclaration) { + var parameters = valueDeclaration.parameters; + var parameterCount = parameters.length; + if (parameterCount > 0) { + for (var i = 0; i < parameterCount; i++) { + if (i > 0) { + write(", "); + } + if (parameters[i].dotDotDotToken) { + var parameterType = parameters[i].type; + if (parameterType.kind === 156 /* ArrayType */) { + parameterType = parameterType.elementType; + } + else if (parameterType.kind === 151 /* TypeReference */ && parameterType.typeArguments && parameterType.typeArguments.length === 1) { + parameterType = parameterType.typeArguments[0]; + } + else { + parameterType = undefined; + } + emitSerializedTypeNode(parameterType); + } + else { + emitSerializedTypeOfNode(parameters[i]); + } + } + } + } + } + } + /** Serializes the return type of function. Used by the __metadata decorator for a method. */ + function emitSerializedReturnTypeOfNode(node) { + if (node && ts.isFunctionLike(node) && node.type) { + emitSerializedTypeNode(node.type); + return; + } + write("void 0"); + } + function emitSerializedTypeMetadata(node, writeComma) { + // This method emits the serialized type metadata for a decorator target. + // The caller should have already tested whether the node has decorators. + var argumentsWritten = 0; + if (compilerOptions.emitDecoratorMetadata) { + if (shouldEmitTypeMetadata(node)) { + if (writeComma) { + write(", "); + } + writeLine(); + write("__metadata('design:type', "); + emitSerializedTypeOfNode(node); + write(")"); + argumentsWritten++; + } + if (shouldEmitParamTypesMetadata(node)) { + if (writeComma || argumentsWritten) { + write(", "); + } + writeLine(); + write("__metadata('design:paramtypes', ["); + emitSerializedParameterTypesOfNode(node); + write("])"); + argumentsWritten++; + } + if (shouldEmitReturnTypeMetadata(node)) { + if (writeComma || argumentsWritten) { + write(", "); + } + writeLine(); + write("__metadata('design:returntype', "); + emitSerializedReturnTypeOfNode(node); + write(")"); + argumentsWritten++; + } + } + return argumentsWritten; + } + function emitInterfaceDeclaration(node) { + emitCommentsOnNotEmittedNode(node); + } + function shouldEmitEnumDeclaration(node) { + var isConstEnum = ts.isConst(node); + return !isConstEnum || compilerOptions.preserveConstEnums || compilerOptions.isolatedModules; + } + function emitEnumDeclaration(node) { + // const enums are completely erased during compilation. + if (!shouldEmitEnumDeclaration(node)) { + return; + } + if (!shouldHoistDeclarationInSystemJsModule(node)) { + // do not emit var if variable was already hoisted + if (!(node.flags & 1 /* Export */) || isES6ExportedDeclaration(node)) { + emitStart(node); + if (isES6ExportedDeclaration(node)) { + write("export "); + } + write("var "); + emit(node.name); + emitEnd(node); + write(";"); + } + } + writeLine(); + emitStart(node); + write("(function ("); + emitStart(node.name); + write(getGeneratedNameForNode(node)); + emitEnd(node.name); + write(") {"); + increaseIndent(); + scopeEmitStart(node); + emitLines(node.members); + decreaseIndent(); + writeLine(); + emitToken(16 /* CloseBraceToken */, node.members.end); + scopeEmitEnd(); + write(")("); + emitModuleMemberName(node); + write(" || ("); + emitModuleMemberName(node); + write(" = {}));"); + emitEnd(node); + if (!isES6ExportedDeclaration(node) && node.flags & 1 /* Export */ && !shouldHoistDeclarationInSystemJsModule(node)) { + // do not emit var if variable was already hoisted + writeLine(); + emitStart(node); + write("var "); + emit(node.name); + write(" = "); + emitModuleMemberName(node); + emitEnd(node); + write(";"); + } + if (modulekind !== 5 /* ES6 */ && node.parent === currentSourceFile) { + if (modulekind === 4 /* System */ && (node.flags & 1 /* Export */)) { + // write the call to exporter for enum + writeLine(); + write(exportFunctionForFile + "(\""); + emitDeclarationName(node); + write("\", "); + emitDeclarationName(node); + write(");"); + } + emitExportMemberAssignments(node.name); + } + } + function emitEnumMember(node) { + var enumParent = node.parent; + emitStart(node); + write(getGeneratedNameForNode(enumParent)); + write("["); + write(getGeneratedNameForNode(enumParent)); + write("["); + emitExpressionForPropertyName(node.name); + write("] = "); + writeEnumMemberDeclarationValue(node); + write("] = "); + emitExpressionForPropertyName(node.name); + emitEnd(node); + write(";"); + } + function writeEnumMemberDeclarationValue(member) { + var value = resolver.getConstantValue(member); + if (value !== undefined) { + write(value.toString()); + return; + } + else if (member.initializer) { + emit(member.initializer); + } + else { + write("undefined"); + } + } + function getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration) { + if (moduleDeclaration.body.kind === 218 /* ModuleDeclaration */) { + var recursiveInnerModule = getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration.body); + return recursiveInnerModule || moduleDeclaration.body; + } + } + function shouldEmitModuleDeclaration(node) { + return ts.isInstantiatedModule(node, compilerOptions.preserveConstEnums || compilerOptions.isolatedModules); + } + function isModuleMergedWithES6Class(node) { + return languageVersion === 2 /* ES6 */ && !!(resolver.getNodeCheckFlags(node) & 32768 /* LexicalModuleMergesWithClass */); + } + function emitModuleDeclaration(node) { + // Emit only if this module is non-ambient. + var shouldEmit = shouldEmitModuleDeclaration(node); + if (!shouldEmit) { + return emitCommentsOnNotEmittedNode(node); + } + var hoistedInDeclarationScope = shouldHoistDeclarationInSystemJsModule(node); + var emitVarForModule = !hoistedInDeclarationScope && !isModuleMergedWithES6Class(node); + if (emitVarForModule) { + emitStart(node); + if (isES6ExportedDeclaration(node)) { + write("export "); + } + write("var "); + emit(node.name); + write(";"); + emitEnd(node); + writeLine(); + } + emitStart(node); + write("(function ("); + emitStart(node.name); + write(getGeneratedNameForNode(node)); + emitEnd(node.name); + write(") "); + if (node.body.kind === 219 /* ModuleBlock */) { + var saveTempFlags = tempFlags; + var saveTempVariables = tempVariables; + tempFlags = 0; + tempVariables = undefined; + emit(node.body); + tempFlags = saveTempFlags; + tempVariables = saveTempVariables; + } + else { + write("{"); + increaseIndent(); + scopeEmitStart(node); + emitCaptureThisForNodeIfNecessary(node); + writeLine(); + emit(node.body); + decreaseIndent(); + writeLine(); + var moduleBlock = getInnerMostModuleDeclarationFromDottedModule(node).body; + emitToken(16 /* CloseBraceToken */, moduleBlock.statements.end); + scopeEmitEnd(); + } + write(")("); + // write moduleDecl = containingModule.m only if it is not exported es6 module member + if ((node.flags & 1 /* Export */) && !isES6ExportedDeclaration(node)) { + emit(node.name); + write(" = "); + } + emitModuleMemberName(node); + write(" || ("); + emitModuleMemberName(node); + write(" = {}));"); + emitEnd(node); + if (!isES6ExportedDeclaration(node) && node.name.kind === 69 /* Identifier */ && node.parent === currentSourceFile) { + if (modulekind === 4 /* System */ && (node.flags & 1 /* Export */)) { + writeLine(); + write(exportFunctionForFile + "(\""); + emitDeclarationName(node); + write("\", "); + emitDeclarationName(node); + write(");"); + } + emitExportMemberAssignments(node.name); + } + } + /* + * Some bundlers (SystemJS builder) sometimes want to rename dependencies. + * Here we check if alternative name was provided for a given moduleName and return it if possible. + */ + function tryRenameExternalModule(moduleName) { + if (currentSourceFile.renamedDependencies && ts.hasProperty(currentSourceFile.renamedDependencies, moduleName.text)) { + return "\"" + currentSourceFile.renamedDependencies[moduleName.text] + "\""; + } + return undefined; + } + function emitRequire(moduleName) { + if (moduleName.kind === 9 /* StringLiteral */) { + write("require("); + var text = tryRenameExternalModule(moduleName); + if (text) { + write(text); + } + else { + emitStart(moduleName); + emitLiteral(moduleName); + emitEnd(moduleName); + } + emitToken(18 /* CloseParenToken */, moduleName.end); + } + else { + write("require()"); + } + } + function getNamespaceDeclarationNode(node) { + if (node.kind === 221 /* ImportEqualsDeclaration */) { + return node; + } + var importClause = node.importClause; + if (importClause && importClause.namedBindings && importClause.namedBindings.kind === 224 /* NamespaceImport */) { + return importClause.namedBindings; + } + } + function isDefaultImport(node) { + return node.kind === 222 /* ImportDeclaration */ && node.importClause && !!node.importClause.name; + } + function emitExportImportAssignments(node) { + if (ts.isAliasSymbolDeclaration(node) && resolver.isValueAliasDeclaration(node)) { + emitExportMemberAssignments(node.name); + } + ts.forEachChild(node, emitExportImportAssignments); + } + function emitImportDeclaration(node) { + if (modulekind !== 5 /* ES6 */) { + return emitExternalImportDeclaration(node); + } + // ES6 import + if (node.importClause) { + var shouldEmitDefaultBindings = resolver.isReferencedAliasDeclaration(node.importClause); + var shouldEmitNamedBindings = node.importClause.namedBindings && resolver.isReferencedAliasDeclaration(node.importClause.namedBindings, /* checkChildren */ true); + if (shouldEmitDefaultBindings || shouldEmitNamedBindings) { + write("import "); + emitStart(node.importClause); + if (shouldEmitDefaultBindings) { + emit(node.importClause.name); + if (shouldEmitNamedBindings) { + write(", "); + } + } + if (shouldEmitNamedBindings) { + emitLeadingComments(node.importClause.namedBindings); + emitStart(node.importClause.namedBindings); + if (node.importClause.namedBindings.kind === 224 /* NamespaceImport */) { + write("* as "); + emit(node.importClause.namedBindings.name); + } + else { + write("{ "); + emitExportOrImportSpecifierList(node.importClause.namedBindings.elements, resolver.isReferencedAliasDeclaration); + write(" }"); + } + emitEnd(node.importClause.namedBindings); + emitTrailingComments(node.importClause.namedBindings); + } + emitEnd(node.importClause); + write(" from "); + emit(node.moduleSpecifier); + write(";"); + } + } + else { + write("import "); + emit(node.moduleSpecifier); + write(";"); + } + } + function emitExternalImportDeclaration(node) { + if (ts.contains(externalImports, node)) { + var isExportedImport = node.kind === 221 /* ImportEqualsDeclaration */ && (node.flags & 1 /* Export */) !== 0; + var namespaceDeclaration = getNamespaceDeclarationNode(node); + if (modulekind !== 2 /* AMD */) { + emitLeadingComments(node); + emitStart(node); + if (namespaceDeclaration && !isDefaultImport(node)) { + // import x = require("foo") + // import * as x from "foo" + if (!isExportedImport) + write("var "); + emitModuleMemberName(namespaceDeclaration); + write(" = "); + } + else { + // import "foo" + // import x from "foo" + // import { x, y } from "foo" + // import d, * as x from "foo" + // import d, { x, y } from "foo" + var isNakedImport = 222 /* ImportDeclaration */ && !node.importClause; + if (!isNakedImport) { + write("var "); + write(getGeneratedNameForNode(node)); + write(" = "); + } + } + emitRequire(ts.getExternalModuleName(node)); + if (namespaceDeclaration && isDefaultImport(node)) { + // import d, * as x from "foo" + write(", "); + emitModuleMemberName(namespaceDeclaration); + write(" = "); + write(getGeneratedNameForNode(node)); + } + write(";"); + emitEnd(node); + emitExportImportAssignments(node); + emitTrailingComments(node); + } + else { + if (isExportedImport) { + emitModuleMemberName(namespaceDeclaration); + write(" = "); + emit(namespaceDeclaration.name); + write(";"); + } + else if (namespaceDeclaration && isDefaultImport(node)) { + // import d, * as x from "foo" + write("var "); + emitModuleMemberName(namespaceDeclaration); + write(" = "); + write(getGeneratedNameForNode(node)); + write(";"); + } + emitExportImportAssignments(node); + } + } + } + function emitImportEqualsDeclaration(node) { + if (ts.isExternalModuleImportEqualsDeclaration(node)) { + emitExternalImportDeclaration(node); + return; + } + // preserve old compiler's behavior: emit 'var' for import declaration (even if we do not consider them referenced) when + // - current file is not external module + // - import declaration is top level and target is value imported by entity name + if (resolver.isReferencedAliasDeclaration(node) || + (!ts.isExternalModule(currentSourceFile) && resolver.isTopLevelValueImportEqualsWithEntityName(node))) { + emitLeadingComments(node); + emitStart(node); + // variable declaration for import-equals declaration can be hoisted in system modules + // in this case 'var' should be omitted and emit should contain only initialization + var variableDeclarationIsHoisted = shouldHoistVariable(node, /*checkIfSourceFileLevelDecl*/ true); + // is it top level export import v = a.b.c in system module? + // if yes - it needs to be rewritten as exporter('v', v = a.b.c) + var isExported = isSourceFileLevelDeclarationInSystemJsModule(node, /*isExported*/ true); + if (!variableDeclarationIsHoisted) { + ts.Debug.assert(!isExported); + if (isES6ExportedDeclaration(node)) { + write("export "); + write("var "); + } + else if (!(node.flags & 1 /* Export */)) { + write("var "); + } + } + if (isExported) { + write(exportFunctionForFile + "(\""); + emitNodeWithoutSourceMap(node.name); + write("\", "); + } + emitModuleMemberName(node); + write(" = "); + emit(node.moduleReference); + if (isExported) { + write(")"); + } + write(";"); + emitEnd(node); + emitExportImportAssignments(node); + emitTrailingComments(node); + } + } + function emitExportDeclaration(node) { + ts.Debug.assert(modulekind !== 4 /* System */); + if (modulekind !== 5 /* ES6 */) { + if (node.moduleSpecifier && (!node.exportClause || resolver.isValueAliasDeclaration(node))) { + emitStart(node); + var generatedName = getGeneratedNameForNode(node); + if (node.exportClause) { + // export { x, y, ... } from "foo" + if (modulekind !== 2 /* AMD */) { + write("var "); + write(generatedName); + write(" = "); + emitRequire(ts.getExternalModuleName(node)); + write(";"); + } + for (var _a = 0, _b = node.exportClause.elements; _a < _b.length; _a++) { + var specifier = _b[_a]; + if (resolver.isValueAliasDeclaration(specifier)) { + writeLine(); + emitStart(specifier); + emitContainingModuleName(specifier); + write("."); + emitNodeWithCommentsAndWithoutSourcemap(specifier.name); + write(" = "); + write(generatedName); + write("."); + emitNodeWithCommentsAndWithoutSourcemap(specifier.propertyName || specifier.name); + write(";"); + emitEnd(specifier); + } + } + } + else { + // export * from "foo" + writeLine(); + write("__export("); + if (modulekind !== 2 /* AMD */) { + emitRequire(ts.getExternalModuleName(node)); + } + else { + write(generatedName); + } + write(");"); + } + emitEnd(node); + } + } + else { + if (!node.exportClause || resolver.isValueAliasDeclaration(node)) { + write("export "); + if (node.exportClause) { + // export { x, y, ... } + write("{ "); + emitExportOrImportSpecifierList(node.exportClause.elements, resolver.isValueAliasDeclaration); + write(" }"); + } + else { + write("*"); + } + if (node.moduleSpecifier) { + write(" from "); + emit(node.moduleSpecifier); + } + write(";"); + } + } + } + function emitExportOrImportSpecifierList(specifiers, shouldEmit) { + ts.Debug.assert(modulekind === 5 /* ES6 */); + var needsComma = false; + for (var _a = 0; _a < specifiers.length; _a++) { + var specifier = specifiers[_a]; + if (shouldEmit(specifier)) { + if (needsComma) { + write(", "); + } + if (specifier.propertyName) { + emit(specifier.propertyName); + write(" as "); + } + emit(specifier.name); + needsComma = true; + } + } + } + function emitExportAssignment(node) { + if (!node.isExportEquals && resolver.isValueAliasDeclaration(node)) { + if (modulekind === 5 /* ES6 */) { + writeLine(); + emitStart(node); + write("export default "); + var expression = node.expression; + emit(expression); + if (expression.kind !== 213 /* FunctionDeclaration */ && + expression.kind !== 214 /* ClassDeclaration */) { + write(";"); + } + emitEnd(node); + } + else { + writeLine(); + emitStart(node); + if (modulekind === 4 /* System */) { + write(exportFunctionForFile + "(\"default\","); + emit(node.expression); + write(")"); + } + else { + emitEs6ExportDefaultCompat(node); + emitContainingModuleName(node); + if (languageVersion === 0 /* ES3 */) { + write("[\"default\"] = "); + } + else { + write(".default = "); + } + emit(node.expression); + } + write(";"); + emitEnd(node); + } + } + } + function collectExternalModuleInfo(sourceFile) { + externalImports = []; + exportSpecifiers = {}; + exportEquals = undefined; + hasExportStars = false; + for (var _a = 0, _b = sourceFile.statements; _a < _b.length; _a++) { + var node = _b[_a]; + switch (node.kind) { + case 222 /* 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); + } + break; + case 221 /* ImportEqualsDeclaration */: + if (node.moduleReference.kind === 232 /* ExternalModuleReference */ && resolver.isReferencedAliasDeclaration(node)) { + // import x = require("mod") where x is referenced + externalImports.push(node); + } + break; + case 228 /* ExportDeclaration */: + if (node.moduleSpecifier) { + if (!node.exportClause) { + // export * from "mod" + externalImports.push(node); + hasExportStars = true; + } + else if (resolver.isValueAliasDeclaration(node)) { + // export { x, y } from "mod" where at least one export is a value symbol + externalImports.push(node); + } + } + else { + // export { x, y } + for (var _c = 0, _d = node.exportClause.elements; _c < _d.length; _c++) { + var specifier = _d[_c]; + var name_25 = (specifier.propertyName || specifier.name).text; + (exportSpecifiers[name_25] || (exportSpecifiers[name_25] = [])).push(specifier); + } + } + break; + case 227 /* ExportAssignment */: + if (node.isExportEquals && !exportEquals) { + // export = x + exportEquals = node; + } + break; + } + } + } + function emitExportStarHelper() { + if (hasExportStars) { + writeLine(); + write("function __export(m) {"); + increaseIndent(); + writeLine(); + write("for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];"); + decreaseIndent(); + writeLine(); + write("}"); + } + } + function getLocalNameForExternalImport(node) { + var namespaceDeclaration = getNamespaceDeclarationNode(node); + if (namespaceDeclaration && !isDefaultImport(node)) { + return ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, namespaceDeclaration.name); + } + if (node.kind === 222 /* ImportDeclaration */ && node.importClause) { + return getGeneratedNameForNode(node); + } + if (node.kind === 228 /* ExportDeclaration */ && node.moduleSpecifier) { + return getGeneratedNameForNode(node); + } + } + function getExternalModuleNameText(importNode) { + var moduleName = ts.getExternalModuleName(importNode); + if (moduleName.kind === 9 /* StringLiteral */) { + return tryRenameExternalModule(moduleName) || getLiteralText(moduleName); + } + return undefined; + } + function emitVariableDeclarationsForImports() { + if (externalImports.length === 0) { + return; + } + writeLine(); + var started = false; + for (var _a = 0; _a < externalImports.length; _a++) { + var importNode = externalImports[_a]; + // do not create variable declaration for exports and imports that lack import clause + var skipNode = importNode.kind === 228 /* ExportDeclaration */ || + (importNode.kind === 222 /* ImportDeclaration */ && !importNode.importClause); + if (skipNode) { + continue; + } + if (!started) { + write("var "); + started = true; + } + else { + write(", "); + } + write(getLocalNameForExternalImport(importNode)); + } + if (started) { + write(";"); + } + } + function emitLocalStorageForExportedNamesIfNecessary(exportedDeclarations) { + // 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. + if (!hasExportStars) { + // local names set is needed only in presence of star exports + return undefined; + } + // local names set should only be added if we have anything exported + if (!exportedDeclarations && 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 _a = 0; _a < externalImports.length; _a++) { + var externalImport = externalImports[_a]; + if (externalImport.kind === 228 /* ExportDeclaration */ && externalImport.exportClause) { + hasExportDeclarationWithExportClause = true; + break; + } + } + if (!hasExportDeclarationWithExportClause) { + // we still need to emit exportStar helper + return emitExportStarFunction(/*localNames*/ undefined); + } + } + var exportedNamesStorageRef = makeUniqueName("exportedNames"); + writeLine(); + write("var " + exportedNamesStorageRef + " = {"); + increaseIndent(); + var started = false; + if (exportedDeclarations) { + for (var i = 0; i < exportedDeclarations.length; ++i) { + // write name of exported declaration, i.e 'export var x...' + writeExportedName(exportedDeclarations[i]); + } + } + if (exportSpecifiers) { + for (var n in exportSpecifiers) { + for (var _b = 0, _c = exportSpecifiers[n]; _b < _c.length; _b++) { + var specifier = _c[_b]; + // write name of export specified, i.e. 'export {x}' + writeExportedName(specifier.name); + } + } + } + for (var _d = 0; _d < externalImports.length; _d++) { + var externalImport = externalImports[_d]; + if (externalImport.kind !== 228 /* ExportDeclaration */) { + continue; + } + var exportDecl = externalImport; + if (!exportDecl.exportClause) { + // export * from ... + continue; + } + for (var _e = 0, _f = exportDecl.exportClause.elements; _e < _f.length; _e++) { + var element = _f[_e]; + // write name of indirectly exported entry, i.e. 'export {x} from ...' + writeExportedName(element.name || element.propertyName); + } + } + decreaseIndent(); + writeLine(); + write("};"); + return emitExportStarFunction(exportedNamesStorageRef); + function emitExportStarFunction(localNames) { + var exportStarFunction = makeUniqueName("exportStar"); + writeLine(); + // define an export star helper function + write("function " + exportStarFunction + "(m) {"); + increaseIndent(); + writeLine(); + write("var exports = {};"); + writeLine(); + write("for(var n in m) {"); + increaseIndent(); + writeLine(); + write("if (n !== \"default\""); + if (localNames) { + write("&& !" + localNames + ".hasOwnProperty(n)"); + } + write(") exports[n] = m[n];"); + decreaseIndent(); + writeLine(); + write("}"); + writeLine(); + write(exportFunctionForFile + "(exports);"); + decreaseIndent(); + writeLine(); + write("}"); + return exportStarFunction; + } + function writeExportedName(node) { + // do not record default exports + // they are local to module and never overwritten (explicitly skipped) by star export + if (node.kind !== 69 /* Identifier */ && node.flags & 1024 /* Default */) { + return; + } + if (started) { + write(","); + } + else { + started = true; + } + writeLine(); + write("'"); + if (node.kind === 69 /* Identifier */) { + emitNodeWithCommentsAndWithoutSourcemap(node); + } + else { + emitDeclarationName(node); + } + write("': true"); + } + } + function processTopLevelVariableAndFunctionDeclarations(node) { + // per ES6 spec: + // 15.2.1.16.4 ModuleDeclarationInstantiation() Concrete Method + // - var declarations are initialized to undefined - 14.a.ii + // - function/generator declarations are instantiated - 16.a.iv + // this means that after module is instantiated but before its evaluation + // exported functions are already accessible at import sites + // in theory we should hoist only exported functions and its dependencies + // in practice to simplify things we'll hoist all source level functions and variable declaration + // including variables declarations for module and class declarations + var hoistedVars; + var hoistedFunctionDeclarations; + var exportedDeclarations; + visit(node); + if (hoistedVars) { + writeLine(); + write("var "); + var seen = {}; + for (var i = 0; i < hoistedVars.length; ++i) { + var local = hoistedVars[i]; + var name_26 = local.kind === 69 /* Identifier */ + ? local + : local.name; + if (name_26) { + // do not emit duplicate entries (in case of declaration merging) in the list of hoisted variables + var text = ts.unescapeIdentifier(name_26.text); + if (ts.hasProperty(seen, text)) { + continue; + } + else { + seen[text] = text; + } + } + if (i !== 0) { + write(", "); + } + if (local.kind === 214 /* ClassDeclaration */ || local.kind === 218 /* ModuleDeclaration */ || local.kind === 217 /* EnumDeclaration */) { + emitDeclarationName(local); + } + else { + emit(local); + } + var flags = ts.getCombinedNodeFlags(local.kind === 69 /* Identifier */ ? local.parent : local); + if (flags & 1 /* Export */) { + if (!exportedDeclarations) { + exportedDeclarations = []; + } + exportedDeclarations.push(local); + } + } + write(";"); + } + if (hoistedFunctionDeclarations) { + for (var _a = 0; _a < hoistedFunctionDeclarations.length; _a++) { + var f = hoistedFunctionDeclarations[_a]; + writeLine(); + emit(f); + if (f.flags & 1 /* Export */) { + if (!exportedDeclarations) { + exportedDeclarations = []; + } + exportedDeclarations.push(f); + } + } + } + return exportedDeclarations; + function visit(node) { + if (node.flags & 2 /* Ambient */) { + return; + } + if (node.kind === 213 /* FunctionDeclaration */) { + if (!hoistedFunctionDeclarations) { + hoistedFunctionDeclarations = []; + } + hoistedFunctionDeclarations.push(node); + return; + } + if (node.kind === 214 /* ClassDeclaration */) { + if (!hoistedVars) { + hoistedVars = []; + } + hoistedVars.push(node); + return; + } + if (node.kind === 217 /* EnumDeclaration */) { + if (shouldEmitEnumDeclaration(node)) { + if (!hoistedVars) { + hoistedVars = []; + } + hoistedVars.push(node); + } + return; + } + if (node.kind === 218 /* ModuleDeclaration */) { + if (shouldEmitModuleDeclaration(node)) { + if (!hoistedVars) { + hoistedVars = []; + } + hoistedVars.push(node); + } + return; + } + if (node.kind === 211 /* VariableDeclaration */ || node.kind === 163 /* BindingElement */) { + if (shouldHoistVariable(node, /*checkIfSourceFileLevelDecl*/ false)) { + var name_27 = node.name; + if (name_27.kind === 69 /* Identifier */) { + if (!hoistedVars) { + hoistedVars = []; + } + hoistedVars.push(name_27); + } + else { + ts.forEachChild(name_27, visit); + } + } + return; + } + if (ts.isInternalModuleImportEqualsDeclaration(node) && resolver.isValueAliasDeclaration(node)) { + if (!hoistedVars) { + hoistedVars = []; + } + hoistedVars.push(node.name); + return; + } + if (ts.isBindingPattern(node)) { + ts.forEach(node.elements, visit); + return; + } + if (!ts.isDeclaration(node)) { + ts.forEachChild(node, visit); + } + } + } + function shouldHoistVariable(node, checkIfSourceFileLevelDecl) { + if (checkIfSourceFileLevelDecl && !shouldHoistDeclarationInSystemJsModule(node)) { + return false; + } + // hoist variable if + // - it is not block scoped + // - it is top level block scoped + // if block scoped variables are nested in some another block then + // no other functions can use them except ones that are defined at least in the same block + return (ts.getCombinedNodeFlags(node) & 49152 /* BlockScoped */) === 0 || + ts.getEnclosingBlockScopeContainer(node).kind === 248 /* SourceFile */; + } + function isCurrentFileSystemExternalModule() { + return modulekind === 4 /* System */ && ts.isExternalModule(currentSourceFile); + } + function emitSystemModuleBody(node, dependencyGroups, startIndex) { + // 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 file1; // local alias + // var y; + // function foo() { return y + file1.x(); } + // exports("foo", foo); + // return { + // setters: [ + // function(v) { file1 = v } + // ], + // execute(): function() { + // y = 1; + // console.log(y); + // } + // }; + // } + emitVariableDeclarationsForImports(); + writeLine(); + var exportedDeclarations = processTopLevelVariableAndFunctionDeclarations(node); + var exportStarFunction = emitLocalStorageForExportedNamesIfNecessary(exportedDeclarations); + writeLine(); + write("return {"); + increaseIndent(); + writeLine(); + emitSetters(exportStarFunction, dependencyGroups); + writeLine(); + emitExecute(node, startIndex); + decreaseIndent(); + writeLine(); + write("}"); // return + emitTempDeclarations(/*newLine*/ true); + } + function emitSetters(exportStarFunction, dependencyGroups) { + write("setters:["); + for (var i = 0; i < dependencyGroups.length; ++i) { + if (i !== 0) { + write(","); + } + writeLine(); + increaseIndent(); + var group = dependencyGroups[i]; + // derive a unique name for parameter from the first named entry in the group + var parameterName = makeUniqueName(ts.forEach(group, getLocalNameForExternalImport) || ""); + write("function (" + parameterName + ") {"); + increaseIndent(); + for (var _a = 0; _a < group.length; _a++) { + var entry = group[_a]; + var importVariableName = getLocalNameForExternalImport(entry) || ""; + switch (entry.kind) { + case 222 /* ImportDeclaration */: + if (!entry.importClause) { + // 'import "..."' case + // module is imported only for side-effects, no emit required + break; + } + // fall-through + case 221 /* ImportEqualsDeclaration */: + ts.Debug.assert(importVariableName !== ""); + writeLine(); + // save import into the local + write(importVariableName + " = " + parameterName + ";"); + writeLine(); + break; + case 228 /* ExportDeclaration */: + ts.Debug.assert(importVariableName !== ""); + if (entry.exportClause) { + // export {a, b as c} from 'foo' + // emit as: + // exports_({ + // "a": _["a"], + // "c": _["b"] + // }); + writeLine(); + write(exportFunctionForFile + "({"); + writeLine(); + increaseIndent(); + for (var i_2 = 0, len = entry.exportClause.elements.length; i_2 < len; ++i_2) { + if (i_2 !== 0) { + write(","); + writeLine(); + } + var e = entry.exportClause.elements[i_2]; + write("\""); + emitNodeWithCommentsAndWithoutSourcemap(e.name); + write("\": " + parameterName + "[\""); + emitNodeWithCommentsAndWithoutSourcemap(e.propertyName || e.name); + write("\"]"); + } + decreaseIndent(); + writeLine(); + write("});"); + } + else { + writeLine(); + // export * from 'foo' + // emit as: + // exportStar(_foo); + write(exportStarFunction + "(" + parameterName + ");"); + } + writeLine(); + break; + } + } + decreaseIndent(); + write("}"); + decreaseIndent(); + } + write("],"); + } + function emitExecute(node, startIndex) { + write("execute: function() {"); + increaseIndent(); + writeLine(); + for (var i = startIndex; i < node.statements.length; ++i) { + var statement = node.statements[i]; + switch (statement.kind) { + // - function declarations are not emitted because they were already hoisted + // - import declarations are not emitted since they are already handled in setters + // - export declarations with module specifiers are not emitted since they were already written in setters + // - export declarations without module specifiers are emitted preserving the order + case 213 /* FunctionDeclaration */: + case 222 /* ImportDeclaration */: + continue; + case 228 /* ExportDeclaration */: + if (!statement.moduleSpecifier) { + for (var _a = 0, _b = statement.exportClause.elements; _a < _b.length; _a++) { + var element = _b[_a]; + // write call to exporter function for every export specifier in exports list + emitExportSpecifierInSystemModule(element); + } + } + continue; + case 221 /* ImportEqualsDeclaration */: + if (!ts.isInternalModuleImportEqualsDeclaration(statement)) { + // - import equals declarations that import external modules are not emitted + continue; + } + // fall-though for import declarations that import internal modules + default: + writeLine(); + emit(statement); + } + } + decreaseIndent(); + writeLine(); + write("}"); // execute + } + function emitSystemModule(node) { + collectExternalModuleInfo(node); + // System modules has the following shape + // System.register(['dep-1', ... 'dep-n'], function(exports) {/* module body function */}) + // 'exports' here is a function 'exports(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 'emitPostfixUnaryExpression' for more details + ts.Debug.assert(!exportFunctionForFile); + // make sure that name of 'exports' function does not conflict with existing identifiers + exportFunctionForFile = makeUniqueName("exports"); + writeLine(); + write("System.register("); + if (node.moduleName) { + write("\"" + node.moduleName + "\", "); + } + write("["); + var groupIndices = {}; + var dependencyGroups = []; + for (var i = 0; i < externalImports.length; ++i) { + var text = getExternalModuleNameText(externalImports[i]); + if (ts.hasProperty(groupIndices, text)) { + // deduplicate/group entries in dependency list by the dependency name + var groupIndex = groupIndices[text]; + dependencyGroups[groupIndex].push(externalImports[i]); + continue; + } + else { + groupIndices[text] = dependencyGroups.length; + dependencyGroups.push([externalImports[i]]); + } + if (i !== 0) { + write(", "); + } + write(text); + } + write("], function(" + exportFunctionForFile + ") {"); + writeLine(); + increaseIndent(); + var startIndex = emitDirectivePrologues(node.statements, /*startWithNewLine*/ true); + emitEmitHelpers(node); + emitCaptureThisForNodeIfNecessary(node); + emitSystemModuleBody(node, dependencyGroups, startIndex); + decreaseIndent(); + writeLine(); + write("});"); + } + function getAMDDependencyNames(node, includeNonAmdDependencies) { + // names of modules with corresponding parameter in the factory function + var aliasedModuleNames = []; + // names of modules with no corresponding parameters in factory function + var unaliasedModuleNames = []; + var importAliasNames = []; // names of the parameters in the factory function; these + // parameters need to match the indexes of the corresponding + // module names in aliasedModuleNames. + // Fill in amd-dependency tags + for (var _a = 0, _b = node.amdDependencies; _a < _b.length; _a++) { + var amdDependency = _b[_a]; + if (amdDependency.name) { + aliasedModuleNames.push("\"" + amdDependency.path + "\""); + importAliasNames.push(amdDependency.name); + } + else { + unaliasedModuleNames.push("\"" + amdDependency.path + "\""); + } + } + for (var _c = 0; _c < externalImports.length; _c++) { + var importNode = externalImports[_c]; + // Find the name of the external module + var externalModuleName = getExternalModuleNameText(importNode); + // Find the name of the module alias, if there is one + var importAliasName = getLocalNameForExternalImport(importNode); + if (includeNonAmdDependencies && importAliasName) { + aliasedModuleNames.push(externalModuleName); + importAliasNames.push(importAliasName); + } + else { + unaliasedModuleNames.push(externalModuleName); + } + } + return { aliasedModuleNames: aliasedModuleNames, unaliasedModuleNames: unaliasedModuleNames, importAliasNames: importAliasNames }; + } + function emitAMDDependencies(node, includeNonAmdDependencies) { + // An AMD define function has the following shape: + // define(id?, dependencies?, factory); + // + // This has the shape of + // define(name, ["module1", "module2"], function (module1Alias) { + // The location of the alias in the parameter list in the factory function needs to + // match the position of the module name in the dependency list. + // + // To ensure this is true in cases of modules with no aliases, e.g.: + // `import "module"` or `` + // we need to add modules without alias names to the end of the dependencies list + var dependencyNames = getAMDDependencyNames(node, includeNonAmdDependencies); + emitAMDDependencyList(dependencyNames); + write(", "); + emitAMDFactoryHeader(dependencyNames); + } + function emitAMDDependencyList(_a) { + var aliasedModuleNames = _a.aliasedModuleNames, unaliasedModuleNames = _a.unaliasedModuleNames; + write("[\"require\", \"exports\""); + if (aliasedModuleNames.length) { + write(", "); + write(aliasedModuleNames.join(", ")); + } + if (unaliasedModuleNames.length) { + write(", "); + write(unaliasedModuleNames.join(", ")); + } + write("]"); + } + function emitAMDFactoryHeader(_a) { + var importAliasNames = _a.importAliasNames; + write("function (require, exports"); + if (importAliasNames.length) { + write(", "); + write(importAliasNames.join(", ")); + } + write(") {"); + } + function emitAMDModule(node) { + emitEmitHelpers(node); + collectExternalModuleInfo(node); + writeLine(); + write("define("); + if (node.moduleName) { + write("\"" + node.moduleName + "\", "); + } + emitAMDDependencies(node, /*includeNonAmdDependencies*/ true); + increaseIndent(); + var startIndex = emitDirectivePrologues(node.statements, /*startWithNewLine*/ true); + emitExportStarHelper(); + emitCaptureThisForNodeIfNecessary(node); + emitLinesStartingAt(node.statements, startIndex); + emitTempDeclarations(/*newLine*/ true); + emitExportEquals(/*emitAsReturn*/ true); + decreaseIndent(); + writeLine(); + write("});"); + } + function emitCommonJSModule(node) { + var startIndex = emitDirectivePrologues(node.statements, /*startWithNewLine*/ false); + emitEmitHelpers(node); + collectExternalModuleInfo(node); + emitExportStarHelper(); + emitCaptureThisForNodeIfNecessary(node); + emitLinesStartingAt(node.statements, startIndex); + emitTempDeclarations(/*newLine*/ true); + emitExportEquals(/*emitAsReturn*/ false); + } + function emitUMDModule(node) { + emitEmitHelpers(node); + collectExternalModuleInfo(node); + var dependencyNames = getAMDDependencyNames(node, /*includeNonAmdDependencies*/ false); + // Module is detected first to support Browserify users that load into a browser with an AMD loader + writeLines("(function (factory) {\n if (typeof module === 'object' && typeof module.exports === 'object') {\n var v = factory(require, exports); if (v !== undefined) module.exports = v;\n }\n else if (typeof define === 'function' && define.amd) {\n define("); + emitAMDDependencyList(dependencyNames); + write(", factory);"); + writeLines(" }\n})("); + emitAMDFactoryHeader(dependencyNames); + increaseIndent(); + var startIndex = emitDirectivePrologues(node.statements, /*startWithNewLine*/ true); + emitExportStarHelper(); + emitCaptureThisForNodeIfNecessary(node); + emitLinesStartingAt(node.statements, startIndex); + emitTempDeclarations(/*newLine*/ true); + emitExportEquals(/*emitAsReturn*/ true); + decreaseIndent(); + writeLine(); + write("});"); + } + function emitES6Module(node) { + externalImports = undefined; + exportSpecifiers = undefined; + exportEquals = undefined; + hasExportStars = false; + var startIndex = emitDirectivePrologues(node.statements, /*startWithNewLine*/ false); + emitEmitHelpers(node); + emitCaptureThisForNodeIfNecessary(node); + emitLinesStartingAt(node.statements, startIndex); + emitTempDeclarations(/*newLine*/ true); + // Emit exportDefault if it exists will happen as part + // or normal statement emit. + } + function emitExportEquals(emitAsReturn) { + if (exportEquals && resolver.isValueAliasDeclaration(exportEquals)) { + writeLine(); + emitStart(exportEquals); + write(emitAsReturn ? "return " : "module.exports = "); + emit(exportEquals.expression); + write(";"); + emitEnd(exportEquals); + } + } + function emitJsxElement(node) { + switch (compilerOptions.jsx) { + case 2 /* React */: + jsxEmitReact(node); + break; + case 1 /* Preserve */: + // Fall back to preserve if None was specified (we'll error earlier) + default: + jsxEmitPreserve(node); + break; + } + } + function trimReactWhitespaceAndApplyEntities(node) { + var result = undefined; + var text = ts.getTextOfNode(node, /*includeTrivia*/ true); + var firstNonWhitespace = 0; + var lastNonWhitespace = -1; + // JSX trims whitespace at the end and beginning of lines, except that the + // start/end of a tag is considered a start/end of a line only if that line is + // on the same line as the closing tag. See examples in tests/cases/conformance/jsx/tsxReactEmitWhitespace.tsx + for (var i = 0; i < text.length; i++) { + var c = text.charCodeAt(i); + if (ts.isLineBreak(c)) { + if (firstNonWhitespace !== -1 && (lastNonWhitespace - firstNonWhitespace + 1 > 0)) { + var part = text.substr(firstNonWhitespace, lastNonWhitespace - firstNonWhitespace + 1); + result = (result ? result + "\" + ' ' + \"" : "") + ts.escapeString(part); + } + firstNonWhitespace = -1; + } + else if (!ts.isWhiteSpace(c)) { + lastNonWhitespace = i; + if (firstNonWhitespace === -1) { + firstNonWhitespace = i; + } + } + } + if (firstNonWhitespace !== -1) { + var part = text.substr(firstNonWhitespace); + result = (result ? result + "\" + ' ' + \"" : "") + ts.escapeString(part); + } + if (result) { + // Replace entities like   + result = result.replace(/&(\w+);/g, function (s, m) { + if (entities[m] !== undefined) { + return String.fromCharCode(entities[m]); + } + else { + return s; + } + }); + } + return result; + } + function getTextToEmit(node) { + switch (compilerOptions.jsx) { + case 2 /* React */: + var text = trimReactWhitespaceAndApplyEntities(node); + if (text === undefined || text.length === 0) { + return undefined; + } + else { + return text; + } + case 1 /* Preserve */: + default: + return ts.getTextOfNode(node, /*includeTrivia*/ true); + } + } + function emitJsxText(node) { + switch (compilerOptions.jsx) { + case 2 /* React */: + write("\""); + write(trimReactWhitespaceAndApplyEntities(node)); + write("\""); + break; + case 1 /* Preserve */: + default: + writer.writeLiteral(ts.getTextOfNode(node, /*includeTrivia*/ true)); + break; + } + } + function emitJsxExpression(node) { + if (node.expression) { + switch (compilerOptions.jsx) { + case 1 /* Preserve */: + default: + write("{"); + emit(node.expression); + write("}"); + break; + case 2 /* React */: + emit(node.expression); + break; + } + } + } + function emitDirectivePrologues(statements, startWithNewLine) { + for (var i = 0; i < statements.length; ++i) { + if (ts.isPrologueDirective(statements[i])) { + if (startWithNewLine || i > 0) { + writeLine(); + } + emit(statements[i]); + } + else { + // return index of the first non prologue directive + return i; + } + } + return statements.length; + } + function writeLines(text) { + var lines = text.split(/\r\n|\r|\n/g); + for (var i = 0; i < lines.length; ++i) { + var line = lines[i]; + if (line.length) { + writeLine(); + write(line); + } + } + } + function emitEmitHelpers(node) { + // Only emit helpers if the user did not say otherwise. + if (!compilerOptions.noEmitHelpers) { + // Only Emit __extends function when target ES5. + // For target ES6 and above, we can emit classDeclaration as is. + if ((languageVersion < 2 /* ES6 */) && (!extendsEmitted && resolver.getNodeCheckFlags(node) & 8 /* EmitExtends */)) { + writeLines(extendsHelper); + extendsEmitted = true; + } + if (!decorateEmitted && resolver.getNodeCheckFlags(node) & 16 /* EmitDecorate */) { + writeLines(decorateHelper); + if (compilerOptions.emitDecoratorMetadata) { + writeLines(metadataHelper); + } + decorateEmitted = true; + } + if (!paramEmitted && resolver.getNodeCheckFlags(node) & 32 /* EmitParam */) { + writeLines(paramHelper); + paramEmitted = true; + } + if (!awaiterEmitted && resolver.getNodeCheckFlags(node) & 64 /* EmitAwaiter */) { + writeLines(awaiterHelper); + awaiterEmitted = true; + } + } + } + function emitSourceFileNode(node) { + // Start new file on new line + writeLine(); + emitShebang(); + emitDetachedComments(node); + if (ts.isExternalModule(node) || compilerOptions.isolatedModules) { + var emitModule = moduleEmitDelegates[modulekind] || moduleEmitDelegates[1 /* CommonJS */]; + emitModule(node); + } + else { + // emit prologue directives prior to __extends + var startIndex = emitDirectivePrologues(node.statements, /*startWithNewLine*/ false); + externalImports = undefined; + exportSpecifiers = undefined; + exportEquals = undefined; + hasExportStars = false; + emitEmitHelpers(node); + emitCaptureThisForNodeIfNecessary(node); + emitLinesStartingAt(node.statements, startIndex); + emitTempDeclarations(/*newLine*/ true); + } + emitLeadingComments(node.endOfFileToken); + } + function emitNodeWithCommentsAndWithoutSourcemap(node) { + emitNodeConsideringCommentsOption(node, emitNodeWithoutSourceMap); + } + function emitNodeConsideringCommentsOption(node, emitNodeConsideringSourcemap) { + if (node) { + if (node.flags & 2 /* Ambient */) { + return emitCommentsOnNotEmittedNode(node); + } + if (isSpecializedCommentHandling(node)) { + // This is the node that will handle its own comments and sourcemap + return emitNodeWithoutSourceMap(node); + } + var emitComments_1 = shouldEmitLeadingAndTrailingComments(node); + if (emitComments_1) { + emitLeadingComments(node); + } + emitNodeConsideringSourcemap(node); + if (emitComments_1) { + emitTrailingComments(node); + } + } + } + function emitNodeWithoutSourceMap(node) { + if (node) { + emitJavaScriptWorker(node); + } + } + function isSpecializedCommentHandling(node) { + switch (node.kind) { + // All of these entities are emitted in a specialized fashion. As such, we allow + // the specialized methods for each to handle the comments on the nodes. + case 215 /* InterfaceDeclaration */: + case 213 /* FunctionDeclaration */: + case 222 /* ImportDeclaration */: + case 221 /* ImportEqualsDeclaration */: + case 216 /* TypeAliasDeclaration */: + case 227 /* ExportAssignment */: + return true; + } + } + function shouldEmitLeadingAndTrailingComments(node) { + switch (node.kind) { + case 193 /* VariableStatement */: + return shouldEmitLeadingAndTrailingCommentsForVariableStatement(node); + case 218 /* ModuleDeclaration */: + // Only emit the leading/trailing comments for a module if we're actually + // emitting the module as well. + return shouldEmitModuleDeclaration(node); + case 217 /* EnumDeclaration */: + // Only emit the leading/trailing comments for an enum if we're actually + // emitting the module as well. + return shouldEmitEnumDeclaration(node); + } + // If the node is emitted in specialized fashion, dont emit comments as this node will handle + // emitting comments when emitting itself + ts.Debug.assert(!isSpecializedCommentHandling(node)); + // If this is the expression body of an arrow function that we're down-leveling, + // then we don't want to emit comments when we emit the body. It will have already + // been taken care of when we emitted the 'return' statement for the function + // expression body. + if (node.kind !== 192 /* Block */ && + node.parent && + node.parent.kind === 174 /* ArrowFunction */ && + node.parent.body === node && + compilerOptions.target <= 1 /* ES5 */) { + return false; + } + // Emit comments for everything else. + return true; + } + function emitJavaScriptWorker(node) { + // Check if the node can be emitted regardless of the ScriptTarget + switch (node.kind) { + case 69 /* Identifier */: + return emitIdentifier(node); + case 138 /* Parameter */: + return emitParameter(node); + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: + return emitMethod(node); + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: + return emitAccessor(node); + case 97 /* ThisKeyword */: + return emitThis(node); + case 95 /* SuperKeyword */: + return emitSuper(node); + case 93 /* NullKeyword */: + return write("null"); + case 99 /* TrueKeyword */: + return write("true"); + case 84 /* FalseKeyword */: + return write("false"); + case 8 /* NumericLiteral */: + case 9 /* StringLiteral */: + case 10 /* RegularExpressionLiteral */: + case 11 /* NoSubstitutionTemplateLiteral */: + case 12 /* TemplateHead */: + case 13 /* TemplateMiddle */: + case 14 /* TemplateTail */: + return emitLiteral(node); + case 183 /* TemplateExpression */: + return emitTemplateExpression(node); + case 190 /* TemplateSpan */: + return emitTemplateSpan(node); + case 233 /* JsxElement */: + case 234 /* JsxSelfClosingElement */: + return emitJsxElement(node); + case 236 /* JsxText */: + return emitJsxText(node); + case 240 /* JsxExpression */: + return emitJsxExpression(node); + case 135 /* QualifiedName */: + return emitQualifiedName(node); + case 161 /* ObjectBindingPattern */: + return emitObjectBindingPattern(node); + case 162 /* ArrayBindingPattern */: + return emitArrayBindingPattern(node); + case 163 /* BindingElement */: + return emitBindingElement(node); + case 164 /* ArrayLiteralExpression */: + return emitArrayLiteral(node); + case 165 /* ObjectLiteralExpression */: + return emitObjectLiteral(node); + case 245 /* PropertyAssignment */: + return emitPropertyAssignment(node); + case 246 /* ShorthandPropertyAssignment */: + return emitShorthandPropertyAssignment(node); + case 136 /* ComputedPropertyName */: + return emitComputedPropertyName(node); + case 166 /* PropertyAccessExpression */: + return emitPropertyAccess(node); + case 167 /* ElementAccessExpression */: + return emitIndexedAccess(node); + case 168 /* CallExpression */: + return emitCallExpression(node); + case 169 /* NewExpression */: + return emitNewExpression(node); + case 170 /* TaggedTemplateExpression */: + return emitTaggedTemplateExpression(node); + case 171 /* TypeAssertionExpression */: + return emit(node.expression); + case 189 /* AsExpression */: + return emit(node.expression); + case 172 /* ParenthesizedExpression */: + return emitParenExpression(node); + case 213 /* FunctionDeclaration */: + case 173 /* FunctionExpression */: + case 174 /* ArrowFunction */: + return emitFunctionDeclaration(node); + case 175 /* DeleteExpression */: + return emitDeleteExpression(node); + case 176 /* TypeOfExpression */: + return emitTypeOfExpression(node); + case 177 /* VoidExpression */: + return emitVoidExpression(node); + case 178 /* AwaitExpression */: + return emitAwaitExpression(node); + case 179 /* PrefixUnaryExpression */: + return emitPrefixUnaryExpression(node); + case 180 /* PostfixUnaryExpression */: + return emitPostfixUnaryExpression(node); + case 181 /* BinaryExpression */: + return emitBinaryExpression(node); + case 182 /* ConditionalExpression */: + return emitConditionalExpression(node); + case 185 /* SpreadElementExpression */: + return emitSpreadElementExpression(node); + case 184 /* YieldExpression */: + return emitYieldExpression(node); + case 187 /* OmittedExpression */: + return; + case 192 /* Block */: + case 219 /* ModuleBlock */: + return emitBlock(node); + case 193 /* VariableStatement */: + return emitVariableStatement(node); + case 194 /* EmptyStatement */: + return write(";"); + case 195 /* ExpressionStatement */: + return emitExpressionStatement(node); + case 196 /* IfStatement */: + return emitIfStatement(node); + case 197 /* DoStatement */: + return emitDoStatement(node); + case 198 /* WhileStatement */: + return emitWhileStatement(node); + case 199 /* ForStatement */: + return emitForStatement(node); + case 201 /* ForOfStatement */: + case 200 /* ForInStatement */: + return emitForInOrForOfStatement(node); + case 202 /* ContinueStatement */: + case 203 /* BreakStatement */: + return emitBreakOrContinueStatement(node); + case 204 /* ReturnStatement */: + return emitReturnStatement(node); + case 205 /* WithStatement */: + return emitWithStatement(node); + case 206 /* SwitchStatement */: + return emitSwitchStatement(node); + case 241 /* CaseClause */: + case 242 /* DefaultClause */: + return emitCaseOrDefaultClause(node); + case 207 /* LabeledStatement */: + return emitLabelledStatement(node); + case 208 /* ThrowStatement */: + return emitThrowStatement(node); + case 209 /* TryStatement */: + return emitTryStatement(node); + case 244 /* CatchClause */: + return emitCatchClause(node); + case 210 /* DebuggerStatement */: + return emitDebuggerStatement(node); + case 211 /* VariableDeclaration */: + return emitVariableDeclaration(node); + case 186 /* ClassExpression */: + return emitClassExpression(node); + case 214 /* ClassDeclaration */: + return emitClassDeclaration(node); + case 215 /* InterfaceDeclaration */: + return emitInterfaceDeclaration(node); + case 217 /* EnumDeclaration */: + return emitEnumDeclaration(node); + case 247 /* EnumMember */: + return emitEnumMember(node); + case 218 /* ModuleDeclaration */: + return emitModuleDeclaration(node); + case 222 /* ImportDeclaration */: + return emitImportDeclaration(node); + case 221 /* ImportEqualsDeclaration */: + return emitImportEqualsDeclaration(node); + case 228 /* ExportDeclaration */: + return emitExportDeclaration(node); + case 227 /* ExportAssignment */: + return emitExportAssignment(node); + case 248 /* SourceFile */: + return emitSourceFileNode(node); + } + } + function hasDetachedComments(pos) { + return detachedCommentsInfo !== undefined && ts.lastOrUndefined(detachedCommentsInfo).nodePos === pos; + } + function getLeadingCommentsWithoutDetachedComments() { + // get the leading comments from detachedPos + var leadingComments = ts.getLeadingCommentRanges(currentSourceFile.text, ts.lastOrUndefined(detachedCommentsInfo).detachedCommentEndPos); + if (detachedCommentsInfo.length - 1) { + detachedCommentsInfo.pop(); + } + else { + detachedCommentsInfo = undefined; + } + return leadingComments; + } + function isPinnedComments(comment) { + return currentSourceFile.text.charCodeAt(comment.pos + 1) === 42 /* asterisk */ && + currentSourceFile.text.charCodeAt(comment.pos + 2) === 33 /* exclamation */; + } + /** + * Determine if the given comment is a triple-slash + * + * @return true if the comment is a triple-slash comment else false + **/ + function isTripleSlashComment(comment) { + // Verify this is /// comment, but do the regexp match only when we first can find /// in the comment text + // so that we don't end up computing comment string and doing match for all // comments + if (currentSourceFile.text.charCodeAt(comment.pos + 1) === 47 /* slash */ && + comment.pos + 2 < comment.end && + currentSourceFile.text.charCodeAt(comment.pos + 2) === 47 /* slash */) { + var textSubStr = currentSourceFile.text.substring(comment.pos, comment.end); + return textSubStr.match(ts.fullTripleSlashReferencePathRegEx) || + textSubStr.match(ts.fullTripleSlashAMDReferencePathRegEx) ? + true : false; + } + return false; + } + function getLeadingCommentsToEmit(node) { + // Emit the leading comments only if the parent's pos doesn't match because parent should take care of emitting these comments + if (node.parent) { + if (node.parent.kind === 248 /* SourceFile */ || node.pos !== node.parent.pos) { + if (hasDetachedComments(node.pos)) { + // get comments without detached comments + return getLeadingCommentsWithoutDetachedComments(); + } + else { + // get the leading comments from the node + return ts.getLeadingCommentRangesOfNode(node, currentSourceFile); + } + } + } + } + function getTrailingCommentsToEmit(node) { + // Emit the trailing comments only if the parent's pos doesn't match because parent should take care of emitting these comments + if (node.parent) { + if (node.parent.kind === 248 /* SourceFile */ || node.end !== node.parent.end) { + return ts.getTrailingCommentRanges(currentSourceFile.text, node.end); + } + } + } + /** + * Emit comments associated with node that will not be emitted into JS file + */ + function emitCommentsOnNotEmittedNode(node) { + emitLeadingCommentsWorker(node, /*isEmittedNode:*/ false); + } + function emitLeadingComments(node) { + return emitLeadingCommentsWorker(node, /*isEmittedNode:*/ true); + } + function emitLeadingCommentsWorker(node, isEmittedNode) { + if (compilerOptions.removeComments) { + return; + } + var leadingComments; + if (isEmittedNode) { + leadingComments = getLeadingCommentsToEmit(node); + } + else { + // If the node will not be emitted in JS, remove all the comments(normal, pinned and ///) associated with the node, + // unless it is a triple slash comment at the top of the file. + // For Example: + // /// + // declare var x; + // /// + // interface F {} + // The first /// will NOT be removed while the second one will be removed eventhough both node will not be emitted + if (node.pos === 0) { + leadingComments = ts.filter(getLeadingCommentsToEmit(node), isTripleSlashComment); + } + } + ts.emitNewLineBeforeLeadingComments(currentSourceFile, writer, node, leadingComments); + // Leading comments are emitted at /*leading comment1 */space/*leading comment*/space + ts.emitComments(currentSourceFile, writer, leadingComments, /*trailingSeparator:*/ true, newLine, writeComment); + } + function emitTrailingComments(node) { + if (compilerOptions.removeComments) { + return; + } + // Emit the trailing comments only if the parent's end doesn't match + var trailingComments = getTrailingCommentsToEmit(node); + // trailing comments are emitted at space/*trailing comment1 */space/*trailing comment*/ + ts.emitComments(currentSourceFile, writer, trailingComments, /*trailingSeparator*/ false, newLine, writeComment); + } + /** + * Emit trailing comments at the position. The term trailing comment is used here to describe following comment: + * x, /comment1/ y + * ^ => pos; the function will emit "comment1" in the emitJS + */ + function emitTrailingCommentsOfPosition(pos) { + if (compilerOptions.removeComments) { + return; + } + var trailingComments = ts.getTrailingCommentRanges(currentSourceFile.text, pos); + // trailing comments are emitted at space/*trailing comment1 */space/*trailing comment*/ + ts.emitComments(currentSourceFile, writer, trailingComments, /*trailingSeparator*/ true, newLine, writeComment); + } + function emitLeadingCommentsOfPositionWorker(pos) { + if (compilerOptions.removeComments) { + return; + } + var leadingComments; + if (hasDetachedComments(pos)) { + // get comments without detached comments + leadingComments = getLeadingCommentsWithoutDetachedComments(); + } + else { + // get the leading comments from the node + leadingComments = ts.getLeadingCommentRanges(currentSourceFile.text, pos); + } + ts.emitNewLineBeforeLeadingComments(currentSourceFile, writer, { pos: pos, end: pos }, leadingComments); + // Leading comments are emitted at /*leading comment1 */space/*leading comment*/space + ts.emitComments(currentSourceFile, writer, leadingComments, /*trailingSeparator*/ true, newLine, writeComment); + } + function emitDetachedComments(node) { + var leadingComments; + if (compilerOptions.removeComments) { + // removeComments is true, only reserve pinned comment at the top of file + // For example: + // /*! Pinned Comment */ + // + // var x = 10; + if (node.pos === 0) { + leadingComments = ts.filter(ts.getLeadingCommentRanges(currentSourceFile.text, node.pos), isPinnedComments); + } + } + else { + // removeComments is false, just get detached as normal and bypass the process to filter comment + leadingComments = ts.getLeadingCommentRanges(currentSourceFile.text, node.pos); + } + if (leadingComments) { + var detachedComments = []; + var lastComment; + ts.forEach(leadingComments, function (comment) { + if (lastComment) { + var lastCommentLine = ts.getLineOfLocalPosition(currentSourceFile, lastComment.end); + var commentLine = ts.getLineOfLocalPosition(currentSourceFile, comment.pos); + if (commentLine >= lastCommentLine + 2) { + // There was a blank line between the last comment and this comment. This + // comment is not part of the copyright comments. Return what we have so + // far. + return detachedComments; + } + } + detachedComments.push(comment); + lastComment = comment; + }); + if (detachedComments.length) { + // All comments look like they could have been part of the copyright header. Make + // sure there is at least one blank line between it and the node. If not, it's not + // a copyright header. + var lastCommentLine = ts.getLineOfLocalPosition(currentSourceFile, ts.lastOrUndefined(detachedComments).end); + var nodeLine = ts.getLineOfLocalPosition(currentSourceFile, ts.skipTrivia(currentSourceFile.text, node.pos)); + if (nodeLine >= lastCommentLine + 2) { + // Valid detachedComments + ts.emitNewLineBeforeLeadingComments(currentSourceFile, writer, node, leadingComments); + ts.emitComments(currentSourceFile, writer, detachedComments, /*trailingSeparator*/ true, newLine, writeComment); + var currentDetachedCommentInfo = { nodePos: node.pos, detachedCommentEndPos: ts.lastOrUndefined(detachedComments).end }; + if (detachedCommentsInfo) { + detachedCommentsInfo.push(currentDetachedCommentInfo); + } + else { + detachedCommentsInfo = [currentDetachedCommentInfo]; + } + } + } + } + } + function emitShebang() { + var shebang = ts.getShebang(currentSourceFile.text); + if (shebang) { + write(shebang); + } + } + var _a; + } + function emitFile(jsFilePath, sourceFile) { + emitJavaScript(jsFilePath, sourceFile); + if (compilerOptions.declaration) { + ts.writeDeclarationFile(jsFilePath, sourceFile, host, resolver, diagnostics); + } + } + } + ts.emitFiles = emitFiles; })(ts || (ts = {})); /// /// @@ -35311,11 +35997,11 @@ var ts; if (ts.getRootLength(moduleName) !== 0 || nameStartsWithDotSlashOrDotDotSlash(moduleName)) { var failedLookupLocations = []; var candidate = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName)); - var resolvedFileName = loadNodeModuleFromFile(candidate, /* loadOnlyDts */ false, failedLookupLocations, host); + var resolvedFileName = loadNodeModuleFromFile(candidate, failedLookupLocations, host); if (resolvedFileName) { return { resolvedModule: { resolvedFileName: resolvedFileName }, failedLookupLocations: failedLookupLocations }; } - resolvedFileName = loadNodeModuleFromDirectory(candidate, /* loadOnlyDts */ false, failedLookupLocations, host); + resolvedFileName = loadNodeModuleFromDirectory(candidate, failedLookupLocations, host); return resolvedFileName ? { resolvedModule: { resolvedFileName: resolvedFileName }, failedLookupLocations: failedLookupLocations } : { resolvedModule: undefined, failedLookupLocations: failedLookupLocations }; @@ -35325,13 +36011,8 @@ var ts; } } ts.nodeModuleNameResolver = nodeModuleNameResolver; - function loadNodeModuleFromFile(candidate, loadOnlyDts, failedLookupLocation, host) { - if (loadOnlyDts) { - return tryLoad(".d.ts"); - } - else { - return ts.forEach(ts.supportedExtensions, tryLoad); - } + function loadNodeModuleFromFile(candidate, failedLookupLocation, host) { + return ts.forEach(ts.supportedJsExtensions, tryLoad); function tryLoad(ext) { var fileName = ts.fileExtensionIs(candidate, ext) ? candidate : candidate + ext; if (host.fileExists(fileName)) { @@ -35343,7 +36024,7 @@ var ts; } } } - function loadNodeModuleFromDirectory(candidate, loadOnlyDts, failedLookupLocation, host) { + function loadNodeModuleFromDirectory(candidate, failedLookupLocation, host) { var packageJsonPath = ts.combinePaths(candidate, "package.json"); if (host.fileExists(packageJsonPath)) { var jsonContent; @@ -35356,7 +36037,7 @@ var ts; jsonContent = { typings: undefined }; } if (jsonContent.typings) { - var result = loadNodeModuleFromFile(ts.normalizePath(ts.combinePaths(candidate, jsonContent.typings)), loadOnlyDts, failedLookupLocation, host); + var result = loadNodeModuleFromFile(ts.normalizePath(ts.combinePaths(candidate, jsonContent.typings)), failedLookupLocation, host); if (result) { return result; } @@ -35366,7 +36047,7 @@ var ts; // record package json as one of failed lookup locations - in the future if this file will appear it will invalidate resolution results failedLookupLocation.push(packageJsonPath); } - return loadNodeModuleFromFile(ts.combinePaths(candidate, "index"), loadOnlyDts, failedLookupLocation, host); + return loadNodeModuleFromFile(ts.combinePaths(candidate, "index"), failedLookupLocation, host); } function loadModuleFromNodeModules(moduleName, directory, host) { var failedLookupLocations = []; @@ -35376,11 +36057,11 @@ var ts; if (baseName !== "node_modules") { var nodeModulesFolder = ts.combinePaths(directory, "node_modules"); var candidate = ts.normalizePath(ts.combinePaths(nodeModulesFolder, moduleName)); - var result = loadNodeModuleFromFile(candidate, /* loadOnlyDts */ true, failedLookupLocations, host); + var result = loadNodeModuleFromFile(candidate, failedLookupLocations, host); if (result) { return { resolvedModule: { resolvedFileName: result, isExternalLibraryImport: true }, failedLookupLocations: failedLookupLocations }; } - result = loadNodeModuleFromDirectory(candidate, /* loadOnlyDts */ true, failedLookupLocations, host); + result = loadNodeModuleFromDirectory(candidate, failedLookupLocations, host); if (result) { return { resolvedModule: { resolvedFileName: result, isExternalLibraryImport: true }, failedLookupLocations: failedLookupLocations }; } @@ -35399,16 +36080,17 @@ var ts; } function classicNameResolver(moduleName, containingFile, compilerOptions, host) { // module names that contain '!' are used to reference resources and are not resolved to actual files on disk - if (moduleName.indexOf('!') != -1) { + if (moduleName.indexOf("!") != -1) { return { resolvedModule: undefined, failedLookupLocations: [] }; } var searchPath = ts.getDirectoryPath(containingFile); var searchName; var failedLookupLocations = []; var referencedSourceFile; + var extensions = compilerOptions.allowNonTsExtensions ? ts.supportedJsExtensions : ts.supportedExtensions; while (true) { searchName = ts.normalizePath(ts.combinePaths(searchPath, moduleName)); - referencedSourceFile = ts.forEach(ts.supportedExtensions, function (extension) { + referencedSourceFile = ts.forEach(extensions, function (extension) { if (extension === ".tsx" && !compilerOptions.jsx) { // resolve .tsx files only if jsx support is enabled // 'logical not' handles both undefined and None cases @@ -35746,7 +36428,9 @@ var ts; return emitResult; } function getSourceFile(fileName) { - return filesByName.get(fileName); + // first try to use file name as is to find file + // then try to convert relative file name to absolute and use it to retrieve source file + return filesByName.get(fileName) || filesByName.get(ts.getNormalizedAbsolutePath(fileName, host.getCurrentDirectory())); } function getDiagnosticsHelper(sourceFile, getDiagnostics, cancellationToken) { if (sourceFile) { @@ -35842,13 +36526,18 @@ var ts; if (file.imports) { return; } + var isJavaScriptFile = ts.isSourceFileJavaScript(file); var imports; for (var _i = 0, _a = file.statements; _i < _a.length; _i++) { var node = _a[_i]; + collect(node, /* allowRelativeModuleNames */ true); + } + file.imports = imports || emptyArray; + function collect(node, allowRelativeModuleNames) { switch (node.kind) { - case 220 /* ImportDeclaration */: - case 219 /* ImportEqualsDeclaration */: - case 226 /* ExportDeclaration */: + case 222 /* ImportDeclaration */: + case 221 /* ImportEqualsDeclaration */: + case 228 /* ExportDeclaration */: var moduleNameExpr = ts.getExternalModuleName(node); if (!moduleNameExpr || moduleNameExpr.kind !== 9 /* StringLiteral */) { break; @@ -35856,9 +36545,24 @@ var ts; if (!moduleNameExpr.text) { break; } - (imports || (imports = [])).push(moduleNameExpr); + if (allowRelativeModuleNames || !ts.isExternalModuleNameRelative(moduleNameExpr.text)) { + (imports || (imports = [])).push(moduleNameExpr); + } break; - case 216 /* ModuleDeclaration */: + case 168 /* CallExpression */: + if (isJavaScriptFile && ts.isRequireCall(node)) { + var jsImports = node.arguments; + if (jsImports) { + imports = (imports || []); + for (var i = 0; i < jsImports.length; i++) { + if (jsImports[i].kind === 9 /* StringLiteral */) { + imports.push(jsImports[i]); + } + } + } + } + break; + case 218 /* ModuleDeclaration */: if (node.name.kind === 9 /* StringLiteral */ && (node.flags & 2 /* Ambient */ || ts.isDeclarationFile(file))) { // TypeScript 1.0 spec (April 2014): 12.1.6 // An AmbientExternalModuleDeclaration declares an external module. @@ -35866,22 +36570,18 @@ var ts; // The StringLiteral must specify a top - level external module name. // Relative external module names are not permitted ts.forEachChild(node.body, function (node) { - if (ts.isExternalModuleImportEqualsDeclaration(node) && - ts.getExternalModuleImportEqualsDeclarationExpression(node).kind === 9 /* StringLiteral */) { - var moduleName = ts.getExternalModuleImportEqualsDeclarationExpression(node); - // TypeScript 1.0 spec (April 2014): 12.1.6 - // An ExternalImportDeclaration in anAmbientExternalModuleDeclaration may reference other external modules - // only through top - level external module names. Relative external module names are not permitted. - if (moduleName) { - (imports || (imports = [])).push(moduleName); - } - } + // TypeScript 1.0 spec (April 2014): 12.1.6 + // An ExternalImportDeclaration in anAmbientExternalModuleDeclaration may reference other external modules + // only through top - level external module names. Relative external module names are not permitted. + collect(node, /* allowRelativeModuleNames */ false); }); } break; } + if (ts.isSourceFileJavaScript(file)) { + ts.forEachChild(node, function (node) { return collect(node, allowRelativeModuleNames); }); + } } - file.imports = imports || emptyArray; } function processSourceFile(fileName, isDefaultLib, refFile, refPos, refEnd) { var diagnosticArgument; @@ -35925,52 +36625,52 @@ var ts; } // Get source file from normalized fileName function findSourceFile(fileName, isDefaultLib, refFile, refPos, refEnd) { - var canonicalName = host.getCanonicalFileName(ts.normalizeSlashes(fileName)); - if (filesByName.contains(canonicalName)) { + if (filesByName.contains(fileName)) { // We've already looked for this file, use cached result - return getSourceFileFromCache(fileName, canonicalName, /*useAbsolutePath*/ false); + return getSourceFileFromCache(fileName, /*useAbsolutePath*/ false); } - else { - var normalizedAbsolutePath = ts.getNormalizedAbsolutePath(fileName, host.getCurrentDirectory()); - var canonicalAbsolutePath = host.getCanonicalFileName(normalizedAbsolutePath); - if (filesByName.contains(canonicalAbsolutePath)) { - return getSourceFileFromCache(normalizedAbsolutePath, canonicalAbsolutePath, /*useAbsolutePath*/ true); - } - // We haven't looked for this file, do so now and cache result - var file = host.getSourceFile(fileName, options.target, function (hostErrorMessage) { - if (refFile !== undefined && refPos !== undefined && refEnd !== undefined) { - fileProcessingDiagnostics.add(ts.createFileDiagnostic(refFile, refPos, refEnd - refPos, ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage)); - } - else { - fileProcessingDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage)); - } - }); - filesByName.set(canonicalName, file); - if (file) { - skipDefaultLib = skipDefaultLib || file.hasNoDefaultLib; - // Set the source file for normalized absolute path - filesByName.set(canonicalAbsolutePath, file); - var basePath = ts.getDirectoryPath(fileName); - if (!options.noResolve) { - processReferencedFiles(file, basePath); - } - // always process imported modules to record module name resolutions - processImportedModules(file, basePath); - if (isDefaultLib) { - file.isDefaultLib = true; - files.unshift(file); - } - else { - files.push(file); - } - } - return file; + var normalizedAbsolutePath = ts.getNormalizedAbsolutePath(fileName, host.getCurrentDirectory()); + if (filesByName.contains(normalizedAbsolutePath)) { + var file_1 = getSourceFileFromCache(normalizedAbsolutePath, /*useAbsolutePath*/ true); + // we don't have resolution for this relative file name but the match was found by absolute file name + // store resolution for relative name as well + filesByName.set(fileName, file_1); + return file_1; } - function getSourceFileFromCache(fileName, canonicalName, useAbsolutePath) { - var file = filesByName.get(canonicalName); + // We haven't looked for this file, do so now and cache result + var file = host.getSourceFile(fileName, options.target, function (hostErrorMessage) { + if (refFile !== undefined && refPos !== undefined && refEnd !== undefined) { + fileProcessingDiagnostics.add(ts.createFileDiagnostic(refFile, refPos, refEnd - refPos, ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage)); + } + else { + fileProcessingDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage)); + } + }); + filesByName.set(fileName, file); + if (file) { + skipDefaultLib = skipDefaultLib || file.hasNoDefaultLib; + // Set the source file for normalized absolute path + filesByName.set(normalizedAbsolutePath, file); + var basePath = ts.getDirectoryPath(fileName); + if (!options.noResolve) { + processReferencedFiles(file, basePath); + } + // always process imported modules to record module name resolutions + processImportedModules(file, basePath); + if (isDefaultLib) { + file.isDefaultLib = true; + files.unshift(file); + } + else { + files.push(file); + } + } + return file; + function getSourceFileFromCache(fileName, useAbsolutePath) { + var file = filesByName.get(fileName); if (file && host.useCaseSensitiveFileNames()) { var sourceFileName = useAbsolutePath ? ts.getNormalizedAbsolutePath(file.fileName, host.getCurrentDirectory()) : file.fileName; - if (canonicalName !== sourceFileName) { + if (ts.normalizeSlashes(fileName) !== ts.normalizeSlashes(sourceFileName)) { if (refFile !== undefined && refPos !== undefined && refEnd !== undefined) { fileProcessingDiagnostics.add(ts.createFileDiagnostic(refFile, refPos, refEnd - refPos, ts.Diagnostics.File_name_0_differs_from_already_included_file_name_1_only_in_casing, fileName, sourceFileName)); } @@ -36138,9 +36838,9 @@ var ts; var span = ts.getErrorSpanForNode(firstExternalModuleSourceFile, firstExternalModuleSourceFile.externalModuleIndicator); programDiagnostics.add(ts.createFileDiagnostic(firstExternalModuleSourceFile, span.start, span.length, ts.Diagnostics.Cannot_compile_modules_unless_the_module_flag_is_provided)); } - // Cannot specify module gen target when in es6 or above - if (options.module && languageVersion >= 2 /* ES6 */) { - programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_compile_modules_into_commonjs_amd_system_or_umd_when_targeting_ES6_or_higher)); + // Cannot specify module gen target of es6 when below es6 + if (options.module === 5 /* ES6 */ && languageVersion < 2 /* ES6 */) { + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_compile_modules_into_es6_when_targeting_ES5_or_lower)); } // there has to be common source directory if user specified --outdir || --sourceRoot // if user specified --mapRoot, there needs to be common source directory if there would be multiple files being emitted @@ -36181,10 +36881,6 @@ var ts; !options.experimentalDecorators) { programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "emitDecoratorMetadata", "experimentalDecorators")); } - if (options.experimentalAsyncFunctions && - options.target !== 2 /* ES6 */) { - programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_experimentalAsyncFunctions_cannot_be_specified_when_targeting_ES5_or_lower)); - } } } ts.createProgram = createProgram; @@ -36266,11 +36962,12 @@ var ts; "commonjs": 1 /* CommonJS */, "amd": 2 /* AMD */, "system": 4 /* System */, - "umd": 3 /* UMD */ + "umd": 3 /* UMD */, + "es6": 5 /* ES6 */ }, - description: ts.Diagnostics.Specify_module_code_generation_Colon_commonjs_amd_system_or_umd, + description: ts.Diagnostics.Specify_module_code_generation_Colon_commonjs_amd_system_umd_or_es6, paramType: ts.Diagnostics.KIND, - error: ts.Diagnostics.Argument_for_module_option_must_be_commonjs_amd_system_or_umd + error: ts.Diagnostics.Argument_for_module_option_must_be_commonjs_amd_system_umd_or_es6 }, { name: "newLine", @@ -36412,11 +37109,6 @@ var ts; type: "boolean", description: ts.Diagnostics.Watch_input_files }, - { - name: "experimentalAsyncFunctions", - type: "boolean", - description: ts.Diagnostics.Enables_experimental_support_for_ES7_async_functions - }, { name: "experimentalDecorators", type: "boolean", @@ -36622,6 +37314,9 @@ var ts; } if (opt.isFilePath) { value = ts.normalizePath(ts.combinePaths(basePath, value)); + if (value === "") { + value = "."; + } } options[opt.name] = value; } @@ -36650,20 +37345,20 @@ var ts; var exclude = json["exclude"] instanceof Array ? ts.map(json["exclude"], ts.normalizeSlashes) : undefined; var sysFiles = host.readDirectory(basePath, ".ts", exclude).concat(host.readDirectory(basePath, ".tsx", exclude)); for (var i = 0; i < sysFiles.length; i++) { - var name_27 = sysFiles[i]; - if (ts.fileExtensionIs(name_27, ".d.ts")) { - var baseName = name_27.substr(0, name_27.length - ".d.ts".length); + var name_28 = sysFiles[i]; + if (ts.fileExtensionIs(name_28, ".d.ts")) { + var baseName = name_28.substr(0, name_28.length - ".d.ts".length); if (!ts.contains(sysFiles, baseName + ".tsx") && !ts.contains(sysFiles, baseName + ".ts")) { - fileNames.push(name_27); + fileNames.push(name_28); } } - else if (ts.fileExtensionIs(name_27, ".ts")) { - if (!ts.contains(sysFiles, name_27 + "x")) { - fileNames.push(name_27); + else if (ts.fileExtensionIs(name_28, ".ts")) { + if (!ts.contains(sysFiles, name_28 + "x")) { + fileNames.push(name_28); } } else { - fileNames.push(name_27); + fileNames.push(name_28); } } } @@ -36744,7 +37439,7 @@ var ts; } } function autoCollapse(node) { - return ts.isFunctionBlock(node) && node.parent.kind !== 172 /* ArrowFunction */; + return ts.isFunctionBlock(node) && node.parent.kind !== 174 /* ArrowFunction */; } var depth = 0; var maxDepth = 20; @@ -36756,7 +37451,7 @@ var ts; addOutliningForLeadingCommentsForNode(n); } switch (n.kind) { - case 190 /* Block */: + case 192 /* Block */: if (!ts.isFunctionBlock(n)) { var parent_7 = n.parent; var openBrace = ts.findChildOfKind(n, 15 /* OpenBraceToken */, sourceFile); @@ -36764,18 +37459,18 @@ var ts; // Check if the block is standalone, or 'attached' to some parent statement. // If the latter, we want to collaps the block, but consider its hint span // to be the entire span of the parent. - if (parent_7.kind === 195 /* DoStatement */ || - parent_7.kind === 198 /* ForInStatement */ || - parent_7.kind === 199 /* ForOfStatement */ || - parent_7.kind === 197 /* ForStatement */ || - parent_7.kind === 194 /* IfStatement */ || - parent_7.kind === 196 /* WhileStatement */ || - parent_7.kind === 203 /* WithStatement */ || - parent_7.kind === 242 /* CatchClause */) { + if (parent_7.kind === 197 /* DoStatement */ || + parent_7.kind === 200 /* ForInStatement */ || + parent_7.kind === 201 /* ForOfStatement */ || + parent_7.kind === 199 /* ForStatement */ || + parent_7.kind === 196 /* IfStatement */ || + parent_7.kind === 198 /* WhileStatement */ || + parent_7.kind === 205 /* WithStatement */ || + parent_7.kind === 244 /* CatchClause */) { addOutliningSpan(parent_7, openBrace, closeBrace, autoCollapse(n)); break; } - if (parent_7.kind === 207 /* TryStatement */) { + if (parent_7.kind === 209 /* TryStatement */) { // Could be the try-block, or the finally-block. var tryStatement = parent_7; if (tryStatement.tryBlock === n) { @@ -36783,7 +37478,7 @@ var ts; break; } else if (tryStatement.finallyBlock === n) { - var finallyKeyword = ts.findChildOfKind(tryStatement, 83 /* FinallyKeyword */, sourceFile); + var finallyKeyword = ts.findChildOfKind(tryStatement, 85 /* FinallyKeyword */, sourceFile); if (finallyKeyword) { addOutliningSpan(finallyKeyword, openBrace, closeBrace, autoCollapse(n)); break; @@ -36802,23 +37497,23 @@ var ts; break; } // Fallthrough. - case 217 /* ModuleBlock */: { + case 219 /* ModuleBlock */: { var openBrace = ts.findChildOfKind(n, 15 /* OpenBraceToken */, sourceFile); var closeBrace = ts.findChildOfKind(n, 16 /* CloseBraceToken */, sourceFile); addOutliningSpan(n.parent, openBrace, closeBrace, autoCollapse(n)); break; } - case 212 /* ClassDeclaration */: - case 213 /* InterfaceDeclaration */: - case 215 /* EnumDeclaration */: - case 163 /* ObjectLiteralExpression */: - case 218 /* CaseBlock */: { + case 214 /* ClassDeclaration */: + case 215 /* InterfaceDeclaration */: + case 217 /* EnumDeclaration */: + case 165 /* ObjectLiteralExpression */: + case 220 /* CaseBlock */: { var openBrace = ts.findChildOfKind(n, 15 /* OpenBraceToken */, sourceFile); var closeBrace = ts.findChildOfKind(n, 16 /* CloseBraceToken */, sourceFile); addOutliningSpan(n, openBrace, closeBrace, autoCollapse(n)); break; } - case 162 /* ArrayLiteralExpression */: + case 164 /* ArrayLiteralExpression */: var openBracket = ts.findChildOfKind(n, 19 /* OpenBracketToken */, sourceFile); var closeBracket = ts.findChildOfKind(n, 20 /* CloseBracketToken */, sourceFile); addOutliningSpan(n, openBracket, closeBracket, autoCollapse(n)); @@ -36846,12 +37541,12 @@ var ts; ts.forEach(program.getSourceFiles(), function (sourceFile) { cancellationToken.throwIfCancellationRequested(); var nameToDeclarations = sourceFile.getNamedDeclarations(); - for (var name_28 in nameToDeclarations) { - var declarations = ts.getProperty(nameToDeclarations, name_28); + for (var name_29 in nameToDeclarations) { + var declarations = ts.getProperty(nameToDeclarations, name_29); if (declarations) { // First do a quick check to see if the name of the declaration matches the // last portion of the (possibly) dotted name they're searching for. - var matches = patternMatcher.getMatchesForLastSegmentOfPattern(name_28); + var matches = patternMatcher.getMatchesForLastSegmentOfPattern(name_29); if (!matches) { continue; } @@ -36864,14 +37559,14 @@ var ts; if (!containers) { return undefined; } - matches = patternMatcher.getMatches(containers, name_28); + matches = patternMatcher.getMatches(containers, name_29); if (!matches) { continue; } } var fileName = sourceFile.fileName; var matchKind = bestMatchKind(matches); - rawItems.push({ name: name_28, fileName: fileName, matchKind: matchKind, isCaseSensitive: allMatchesAreCaseSensitive(matches), declaration: declaration }); + rawItems.push({ name: name_29, fileName: fileName, matchKind: matchKind, isCaseSensitive: allMatchesAreCaseSensitive(matches), declaration: declaration }); } } } @@ -36895,7 +37590,7 @@ var ts; } function getTextOfIdentifierOrLiteral(node) { if (node) { - if (node.kind === 67 /* Identifier */ || + if (node.kind === 69 /* Identifier */ || node.kind === 9 /* StringLiteral */ || node.kind === 8 /* NumericLiteral */) { return node.text; @@ -36909,7 +37604,7 @@ var ts; if (text !== undefined) { containers.unshift(text); } - else if (declaration.name.kind === 134 /* ComputedPropertyName */) { + else if (declaration.name.kind === 136 /* ComputedPropertyName */) { return tryAddComputedPropertyName(declaration.name.expression, containers, /*includeLastPortion:*/ true); } else { @@ -36930,7 +37625,7 @@ var ts; } return true; } - if (expression.kind === 164 /* PropertyAccessExpression */) { + if (expression.kind === 166 /* PropertyAccessExpression */) { var propertyAccess = expression; if (includeLastPortion) { containers.unshift(propertyAccess.name.text); @@ -36943,7 +37638,7 @@ var ts; var containers = []; // First, if we started with a computed property name, then add all but the last // portion into the container array. - if (declaration.name.kind === 134 /* ComputedPropertyName */) { + if (declaration.name.kind === 136 /* ComputedPropertyName */) { if (!tryAddComputedPropertyName(declaration.name.expression, containers, /*includeLastPortion:*/ false)) { return undefined; } @@ -37019,17 +37714,17 @@ var ts; var current = node.parent; while (current) { switch (current.kind) { - case 216 /* ModuleDeclaration */: + case 218 /* ModuleDeclaration */: // If we have a module declared as A.B.C, it is more "intuitive" // to say it only has a single layer of depth do { current = current.parent; - } while (current.kind === 216 /* ModuleDeclaration */); + } while (current.kind === 218 /* ModuleDeclaration */); // fall through - case 212 /* ClassDeclaration */: - case 215 /* EnumDeclaration */: - case 213 /* InterfaceDeclaration */: - case 211 /* FunctionDeclaration */: + case 214 /* ClassDeclaration */: + case 217 /* EnumDeclaration */: + case 215 /* InterfaceDeclaration */: + case 213 /* FunctionDeclaration */: indent++; } current = current.parent; @@ -37040,21 +37735,21 @@ var ts; var childNodes = []; function visit(node) { switch (node.kind) { - case 191 /* VariableStatement */: + case 193 /* VariableStatement */: ts.forEach(node.declarationList.declarations, visit); break; - case 159 /* ObjectBindingPattern */: - case 160 /* ArrayBindingPattern */: + case 161 /* ObjectBindingPattern */: + case 162 /* ArrayBindingPattern */: ts.forEach(node.elements, visit); break; - case 226 /* ExportDeclaration */: + case 228 /* ExportDeclaration */: // Handle named exports case e.g.: // export {a, b as B} from "mod"; if (node.exportClause) { ts.forEach(node.exportClause.elements, visit); } break; - case 220 /* ImportDeclaration */: + case 222 /* ImportDeclaration */: var importClause = node.importClause; if (importClause) { // Handle default import case e.g.: @@ -37066,7 +37761,7 @@ var ts; // import * as NS from "mod"; // import {a, b as B} from "mod"; if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 222 /* NamespaceImport */) { + if (importClause.namedBindings.kind === 224 /* NamespaceImport */) { childNodes.push(importClause.namedBindings); } else { @@ -37075,21 +37770,21 @@ var ts; } } break; - case 161 /* BindingElement */: - case 209 /* VariableDeclaration */: + case 163 /* BindingElement */: + case 211 /* VariableDeclaration */: if (ts.isBindingPattern(node.name)) { visit(node.name); break; } // Fall through - case 212 /* ClassDeclaration */: - case 215 /* EnumDeclaration */: - case 213 /* InterfaceDeclaration */: - case 216 /* ModuleDeclaration */: - case 211 /* FunctionDeclaration */: - case 219 /* ImportEqualsDeclaration */: - case 224 /* ImportSpecifier */: - case 228 /* ExportSpecifier */: + case 214 /* ClassDeclaration */: + case 217 /* EnumDeclaration */: + case 215 /* InterfaceDeclaration */: + case 218 /* ModuleDeclaration */: + case 213 /* FunctionDeclaration */: + case 221 /* ImportEqualsDeclaration */: + case 226 /* ImportSpecifier */: + case 230 /* ExportSpecifier */: childNodes.push(node); break; } @@ -37137,17 +37832,17 @@ var ts; for (var _i = 0; _i < nodes.length; _i++) { var node = nodes[_i]; switch (node.kind) { - case 212 /* ClassDeclaration */: - case 215 /* EnumDeclaration */: - case 213 /* InterfaceDeclaration */: + case 214 /* ClassDeclaration */: + case 217 /* EnumDeclaration */: + case 215 /* InterfaceDeclaration */: topLevelNodes.push(node); break; - case 216 /* ModuleDeclaration */: + case 218 /* ModuleDeclaration */: var moduleDeclaration = node; topLevelNodes.push(node); addTopLevelNodes(getInnermostModule(moduleDeclaration).body.statements, topLevelNodes); break; - case 211 /* FunctionDeclaration */: + case 213 /* FunctionDeclaration */: var functionDeclaration = node; if (isTopLevelFunctionDeclaration(functionDeclaration)) { topLevelNodes.push(node); @@ -37158,12 +37853,12 @@ var ts; } } function isTopLevelFunctionDeclaration(functionDeclaration) { - if (functionDeclaration.kind === 211 /* FunctionDeclaration */) { + if (functionDeclaration.kind === 213 /* FunctionDeclaration */) { // A function declaration is 'top level' if it contains any function declarations // within it. - if (functionDeclaration.body && functionDeclaration.body.kind === 190 /* Block */) { + if (functionDeclaration.body && functionDeclaration.body.kind === 192 /* Block */) { // Proper function declarations can only have identifier names - if (ts.forEach(functionDeclaration.body.statements, function (s) { return s.kind === 211 /* FunctionDeclaration */ && !isEmpty(s.name.text); })) { + if (ts.forEach(functionDeclaration.body.statements, function (s) { return s.kind === 213 /* FunctionDeclaration */ && !isEmpty(s.name.text); })) { return true; } // Or if it is not parented by another function. i.e all functions @@ -37223,7 +37918,7 @@ var ts; } function createChildItem(node) { switch (node.kind) { - case 136 /* Parameter */: + case 138 /* Parameter */: if (ts.isBindingPattern(node.name)) { break; } @@ -37231,36 +37926,36 @@ var ts; return undefined; } return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberVariableElement); - case 141 /* MethodDeclaration */: - case 140 /* MethodSignature */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberFunctionElement); - case 143 /* GetAccessor */: + case 145 /* GetAccessor */: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberGetAccessorElement); - case 144 /* SetAccessor */: + case 146 /* SetAccessor */: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberSetAccessorElement); - case 147 /* IndexSignature */: + case 149 /* IndexSignature */: return createItem(node, "[]", ts.ScriptElementKind.indexSignatureElement); - case 245 /* EnumMember */: + case 247 /* EnumMember */: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberVariableElement); - case 145 /* CallSignature */: + case 147 /* CallSignature */: return createItem(node, "()", ts.ScriptElementKind.callSignatureElement); - case 146 /* ConstructSignature */: + case 148 /* ConstructSignature */: return createItem(node, "new()", ts.ScriptElementKind.constructSignatureElement); - case 139 /* PropertyDeclaration */: - case 138 /* PropertySignature */: + case 141 /* PropertyDeclaration */: + case 140 /* PropertySignature */: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberVariableElement); - case 211 /* FunctionDeclaration */: + case 213 /* FunctionDeclaration */: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.functionElement); - case 209 /* VariableDeclaration */: - case 161 /* BindingElement */: + case 211 /* VariableDeclaration */: + case 163 /* BindingElement */: var variableDeclarationNode; - var name_29; - if (node.kind === 161 /* BindingElement */) { - name_29 = node.name; + var name_30; + if (node.kind === 163 /* BindingElement */) { + name_30 = node.name; variableDeclarationNode = node; // binding elements are added only for variable declarations // bubble up to the containing variable declaration - while (variableDeclarationNode && variableDeclarationNode.kind !== 209 /* VariableDeclaration */) { + while (variableDeclarationNode && variableDeclarationNode.kind !== 211 /* VariableDeclaration */) { variableDeclarationNode = variableDeclarationNode.parent; } ts.Debug.assert(variableDeclarationNode !== undefined); @@ -37268,24 +37963,24 @@ var ts; else { ts.Debug.assert(!ts.isBindingPattern(node.name)); variableDeclarationNode = node; - name_29 = node.name; + name_30 = node.name; } if (ts.isConst(variableDeclarationNode)) { - return createItem(node, getTextOfNode(name_29), ts.ScriptElementKind.constElement); + return createItem(node, getTextOfNode(name_30), ts.ScriptElementKind.constElement); } else if (ts.isLet(variableDeclarationNode)) { - return createItem(node, getTextOfNode(name_29), ts.ScriptElementKind.letElement); + return createItem(node, getTextOfNode(name_30), ts.ScriptElementKind.letElement); } else { - return createItem(node, getTextOfNode(name_29), ts.ScriptElementKind.variableElement); + return createItem(node, getTextOfNode(name_30), ts.ScriptElementKind.variableElement); } - case 142 /* Constructor */: + case 144 /* Constructor */: return createItem(node, "constructor", ts.ScriptElementKind.constructorImplementationElement); - case 228 /* ExportSpecifier */: - case 224 /* ImportSpecifier */: - case 219 /* ImportEqualsDeclaration */: - case 221 /* ImportClause */: - case 222 /* NamespaceImport */: + case 230 /* ExportSpecifier */: + case 226 /* ImportSpecifier */: + case 221 /* ImportEqualsDeclaration */: + case 223 /* ImportClause */: + case 224 /* NamespaceImport */: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.alias); } return undefined; @@ -37315,17 +38010,17 @@ var ts; } function createTopLevelItem(node) { switch (node.kind) { - case 246 /* SourceFile */: + case 248 /* SourceFile */: return createSourceFileItem(node); - case 212 /* ClassDeclaration */: + case 214 /* ClassDeclaration */: return createClassItem(node); - case 215 /* EnumDeclaration */: + case 217 /* EnumDeclaration */: return createEnumItem(node); - case 213 /* InterfaceDeclaration */: + case 215 /* InterfaceDeclaration */: return createIterfaceItem(node); - case 216 /* ModuleDeclaration */: + case 218 /* ModuleDeclaration */: return createModuleItem(node); - case 211 /* FunctionDeclaration */: + case 213 /* FunctionDeclaration */: return createFunctionItem(node); } return undefined; @@ -37337,7 +38032,7 @@ var ts; // Otherwise, we need to aggregate each identifier to build up the qualified name. var result = []; result.push(moduleDeclaration.name.text); - while (moduleDeclaration.body && moduleDeclaration.body.kind === 216 /* ModuleDeclaration */) { + while (moduleDeclaration.body && moduleDeclaration.body.kind === 218 /* ModuleDeclaration */) { moduleDeclaration = moduleDeclaration.body; result.push(moduleDeclaration.name.text); } @@ -37349,7 +38044,7 @@ var ts; return getNavigationBarItem(moduleName, ts.ScriptElementKind.moduleElement, ts.getNodeModifiers(node), [getNodeSpan(node)], childItems, getIndent(node)); } function createFunctionItem(node) { - if (node.body && node.body.kind === 190 /* Block */) { + if (node.body && node.body.kind === 192 /* Block */) { var childItems = getItemsWorker(sortNodes(node.body.statements), createChildItem); return getNavigationBarItem(!node.name ? "default" : node.name.text, ts.ScriptElementKind.functionElement, ts.getNodeModifiers(node), [getNodeSpan(node)], childItems, getIndent(node)); } @@ -37370,7 +38065,7 @@ var ts; var childItems; if (node.members) { var constructor = ts.forEach(node.members, function (member) { - return member.kind === 142 /* Constructor */ && member; + return member.kind === 144 /* Constructor */ && member; }); // Add the constructor parameters in as children of the class (for property parameters). // Note that *all non-binding pattern named* parameters will be added to the nodes array, but parameters that @@ -37394,7 +38089,7 @@ var ts; } } function removeComputedProperties(node) { - return ts.filter(node.members, function (member) { return member.name === undefined || member.name.kind !== 134 /* ComputedPropertyName */; }); + return ts.filter(node.members, function (member) { return member.name === undefined || member.name.kind !== 136 /* ComputedPropertyName */; }); } /** * Like removeComputedProperties, but retains the properties with well known symbol names @@ -37403,13 +38098,13 @@ var ts; return ts.filter(node.members, function (member) { return !ts.hasDynamicName(member); }); } function getInnermostModule(node) { - while (node.body.kind === 216 /* ModuleDeclaration */) { + while (node.body.kind === 218 /* ModuleDeclaration */) { node = node.body; } return node; } function getNodeSpan(node) { - return node.kind === 246 /* SourceFile */ + return node.kind === 248 /* SourceFile */ ? ts.createTextSpanFromBounds(node.getFullStart(), node.getEnd()) : ts.createTextSpanFromBounds(node.getStart(), node.getEnd()); } @@ -38197,22 +38892,22 @@ var ts; if (!candidates.length) { // We didn't have any sig help items produced by the TS compiler. If this is a JS // file, then see if we can figure out anything better. - if (ts.isJavaScript(sourceFile.fileName)) { + if (ts.isSourceFileJavaScript(sourceFile)) { return createJavaScriptSignatureHelpItems(argumentInfo); } return undefined; } return createSignatureHelpItems(candidates, resolvedSignature, argumentInfo); function createJavaScriptSignatureHelpItems(argumentInfo) { - if (argumentInfo.invocation.kind !== 166 /* CallExpression */) { + if (argumentInfo.invocation.kind !== 168 /* CallExpression */) { return undefined; } // See if we can find some symbol with the call expression name that has call signatures. var callExpression = argumentInfo.invocation; var expression = callExpression.expression; - var name = expression.kind === 67 /* Identifier */ + var name = expression.kind === 69 /* Identifier */ ? expression - : expression.kind === 164 /* PropertyAccessExpression */ + : expression.kind === 166 /* PropertyAccessExpression */ ? expression.name : undefined; if (!name || !name.text) { @@ -38245,7 +38940,7 @@ var ts; * in the argument of an invocation; returns undefined otherwise. */ function getImmediatelyContainingArgumentInfo(node) { - if (node.parent.kind === 166 /* CallExpression */ || node.parent.kind === 167 /* NewExpression */) { + if (node.parent.kind === 168 /* CallExpression */ || node.parent.kind === 169 /* NewExpression */) { var callExpression = node.parent; // There are 3 cases to handle: // 1. The token introduces a list, and should begin a sig help session @@ -38298,25 +38993,25 @@ var ts; }; } } - else if (node.kind === 11 /* NoSubstitutionTemplateLiteral */ && node.parent.kind === 168 /* TaggedTemplateExpression */) { + else if (node.kind === 11 /* NoSubstitutionTemplateLiteral */ && node.parent.kind === 170 /* TaggedTemplateExpression */) { // Check if we're actually inside the template; // otherwise we'll fall out and return undefined. if (ts.isInsideTemplateLiteral(node, position)) { return getArgumentListInfoForTemplate(node.parent, /*argumentIndex*/ 0); } } - else if (node.kind === 12 /* TemplateHead */ && node.parent.parent.kind === 168 /* TaggedTemplateExpression */) { + else if (node.kind === 12 /* TemplateHead */ && node.parent.parent.kind === 170 /* TaggedTemplateExpression */) { var templateExpression = node.parent; var tagExpression = templateExpression.parent; - ts.Debug.assert(templateExpression.kind === 181 /* TemplateExpression */); + ts.Debug.assert(templateExpression.kind === 183 /* TemplateExpression */); var argumentIndex = ts.isInsideTemplateLiteral(node, position) ? 0 : 1; return getArgumentListInfoForTemplate(tagExpression, argumentIndex); } - else if (node.parent.kind === 188 /* TemplateSpan */ && node.parent.parent.parent.kind === 168 /* TaggedTemplateExpression */) { + else if (node.parent.kind === 190 /* TemplateSpan */ && node.parent.parent.parent.kind === 170 /* TaggedTemplateExpression */) { var templateSpan = node.parent; var templateExpression = templateSpan.parent; var tagExpression = templateExpression.parent; - ts.Debug.assert(templateExpression.kind === 181 /* TemplateExpression */); + ts.Debug.assert(templateExpression.kind === 183 /* TemplateExpression */); // If we're just after a template tail, don't show signature help. if (node.kind === 14 /* TemplateTail */ && !ts.isInsideTemplateLiteral(node, position)) { return undefined; @@ -38434,7 +39129,7 @@ var ts; // // This is because a Missing node has no width. However, what we actually want is to include trivia // leading up to the next token in case the user is about to type in a TemplateMiddle or TemplateTail. - if (template.kind === 181 /* TemplateExpression */) { + if (template.kind === 183 /* TemplateExpression */) { var lastSpan = ts.lastOrUndefined(template.templateSpans); if (lastSpan.literal.getFullWidth() === 0) { applicableSpanEnd = ts.skipTrivia(sourceFile.text, applicableSpanEnd, /*stopAfterLineBreak*/ false); @@ -38443,7 +39138,7 @@ var ts; return ts.createTextSpan(applicableSpanStart, applicableSpanEnd - applicableSpanStart); } function getContainingArgumentInfo(node) { - for (var n = node; n.kind !== 246 /* SourceFile */; n = n.parent) { + for (var n = node; n.kind !== 248 /* SourceFile */; n = n.parent) { if (ts.isFunctionBlock(n)) { return undefined; } @@ -38643,40 +39338,40 @@ var ts; return false; } switch (n.kind) { - case 212 /* ClassDeclaration */: - case 213 /* InterfaceDeclaration */: - case 215 /* EnumDeclaration */: - case 163 /* ObjectLiteralExpression */: - case 159 /* ObjectBindingPattern */: - case 153 /* TypeLiteral */: - case 190 /* Block */: - case 217 /* ModuleBlock */: - case 218 /* CaseBlock */: + case 214 /* ClassDeclaration */: + case 215 /* InterfaceDeclaration */: + case 217 /* EnumDeclaration */: + case 165 /* ObjectLiteralExpression */: + case 161 /* ObjectBindingPattern */: + case 155 /* TypeLiteral */: + case 192 /* Block */: + case 219 /* ModuleBlock */: + case 220 /* CaseBlock */: return nodeEndsWith(n, 16 /* CloseBraceToken */, sourceFile); - case 242 /* CatchClause */: + case 244 /* CatchClause */: return isCompletedNode(n.block, sourceFile); - case 167 /* NewExpression */: + case 169 /* NewExpression */: if (!n.arguments) { return true; } // fall through - case 166 /* CallExpression */: - case 170 /* ParenthesizedExpression */: - case 158 /* ParenthesizedType */: + case 168 /* CallExpression */: + case 172 /* ParenthesizedExpression */: + case 160 /* ParenthesizedType */: return nodeEndsWith(n, 18 /* CloseParenToken */, sourceFile); - case 150 /* FunctionType */: - case 151 /* ConstructorType */: + case 152 /* FunctionType */: + case 153 /* ConstructorType */: return isCompletedNode(n.type, sourceFile); - case 142 /* Constructor */: - case 143 /* GetAccessor */: - case 144 /* SetAccessor */: - case 211 /* FunctionDeclaration */: - case 171 /* FunctionExpression */: - case 141 /* MethodDeclaration */: - case 140 /* MethodSignature */: - case 146 /* ConstructSignature */: - case 145 /* CallSignature */: - case 172 /* ArrowFunction */: + case 144 /* Constructor */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: + case 213 /* FunctionDeclaration */: + case 173 /* FunctionExpression */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: + case 148 /* ConstructSignature */: + case 147 /* CallSignature */: + case 174 /* ArrowFunction */: if (n.body) { return isCompletedNode(n.body, sourceFile); } @@ -38686,63 +39381,64 @@ var ts; // Even though type parameters can be unclosed, we can get away with // having at least a closing paren. return hasChildOfKind(n, 18 /* CloseParenToken */, sourceFile); - case 216 /* ModuleDeclaration */: + case 218 /* ModuleDeclaration */: return n.body && isCompletedNode(n.body, sourceFile); - case 194 /* IfStatement */: + case 196 /* IfStatement */: if (n.elseStatement) { return isCompletedNode(n.elseStatement, sourceFile); } return isCompletedNode(n.thenStatement, sourceFile); - case 193 /* ExpressionStatement */: - return isCompletedNode(n.expression, sourceFile); - case 162 /* ArrayLiteralExpression */: - case 160 /* ArrayBindingPattern */: - case 165 /* ElementAccessExpression */: - case 134 /* ComputedPropertyName */: - case 155 /* TupleType */: + case 195 /* ExpressionStatement */: + return isCompletedNode(n.expression, sourceFile) || + hasChildOfKind(n, 23 /* SemicolonToken */); + case 164 /* ArrayLiteralExpression */: + case 162 /* ArrayBindingPattern */: + case 167 /* ElementAccessExpression */: + case 136 /* ComputedPropertyName */: + case 157 /* TupleType */: return nodeEndsWith(n, 20 /* CloseBracketToken */, sourceFile); - case 147 /* IndexSignature */: + case 149 /* IndexSignature */: if (n.type) { return isCompletedNode(n.type, sourceFile); } return hasChildOfKind(n, 20 /* CloseBracketToken */, sourceFile); - case 239 /* CaseClause */: - case 240 /* DefaultClause */: + case 241 /* CaseClause */: + case 242 /* DefaultClause */: // there is no such thing as terminator token for CaseClause/DefaultClause so for simplicitly always consider them non-completed return false; - case 197 /* ForStatement */: - case 198 /* ForInStatement */: - case 199 /* ForOfStatement */: - case 196 /* WhileStatement */: + case 199 /* ForStatement */: + case 200 /* ForInStatement */: + case 201 /* ForOfStatement */: + case 198 /* WhileStatement */: return isCompletedNode(n.statement, sourceFile); - case 195 /* DoStatement */: + case 197 /* DoStatement */: // rough approximation: if DoStatement has While keyword - then if node is completed is checking the presence of ')'; - var hasWhileKeyword = findChildOfKind(n, 102 /* WhileKeyword */, sourceFile); + var hasWhileKeyword = findChildOfKind(n, 104 /* WhileKeyword */, sourceFile); if (hasWhileKeyword) { return nodeEndsWith(n, 18 /* CloseParenToken */, sourceFile); } return isCompletedNode(n.statement, sourceFile); - case 152 /* TypeQuery */: + case 154 /* TypeQuery */: return isCompletedNode(n.exprName, sourceFile); - case 174 /* TypeOfExpression */: - case 173 /* DeleteExpression */: - case 175 /* VoidExpression */: - case 182 /* YieldExpression */: - case 183 /* SpreadElementExpression */: + case 176 /* TypeOfExpression */: + case 175 /* DeleteExpression */: + case 177 /* VoidExpression */: + case 184 /* YieldExpression */: + case 185 /* SpreadElementExpression */: var unaryWordExpression = n; return isCompletedNode(unaryWordExpression.expression, sourceFile); - case 168 /* TaggedTemplateExpression */: + case 170 /* TaggedTemplateExpression */: return isCompletedNode(n.template, sourceFile); - case 181 /* TemplateExpression */: + case 183 /* TemplateExpression */: var lastSpan = ts.lastOrUndefined(n.templateSpans); return isCompletedNode(lastSpan, sourceFile); - case 188 /* TemplateSpan */: + case 190 /* TemplateSpan */: return ts.nodeIsPresent(n.literal); - case 177 /* PrefixUnaryExpression */: + case 179 /* PrefixUnaryExpression */: return isCompletedNode(n.operand, sourceFile); - case 179 /* BinaryExpression */: + case 181 /* BinaryExpression */: return isCompletedNode(n.right, sourceFile); - case 180 /* ConditionalExpression */: + case 182 /* ConditionalExpression */: return isCompletedNode(n.whenFalse, sourceFile); default: return true; @@ -38798,7 +39494,7 @@ var ts; // for the position of the relevant node (or comma). var syntaxList = ts.forEach(node.parent.getChildren(), function (c) { // find syntax list that covers the span of the node - if (c.kind === 269 /* SyntaxList */ && c.pos <= node.pos && c.end >= node.end) { + if (c.kind === 271 /* SyntaxList */ && c.pos <= node.pos && c.end >= node.end) { return c; } }); @@ -38904,7 +39600,7 @@ var ts; function findPrecedingToken(position, sourceFile, startNode) { return find(startNode || sourceFile); function findRightmostToken(n) { - if (isToken(n) || n.kind === 234 /* JsxText */) { + if (isToken(n) || n.kind === 236 /* JsxText */) { return n; } var children = n.getChildren(); @@ -38912,7 +39608,7 @@ var ts; return candidate && findRightmostToken(candidate); } function find(n) { - if (isToken(n) || n.kind === 234 /* JsxText */) { + if (isToken(n) || n.kind === 236 /* JsxText */) { return n; } var children = n.getChildren(); @@ -38926,10 +39622,10 @@ var ts; // if no - position is in the node itself so we should recurse in it. // NOTE: JsxText is a weird kind of node that can contain only whitespaces (since they are not counted as trivia). // if this is the case - then we should assume that token in question is located in previous child. - if (position < child.end && (nodeHasTokens(child) || child.kind === 234 /* JsxText */)) { + if (position < child.end && (nodeHasTokens(child) || child.kind === 236 /* JsxText */)) { var start = child.getStart(sourceFile); var lookInPreviousChild = (start >= position) || - (child.kind === 234 /* JsxText */ && start === child.end); // whitespace only JsxText + (child.kind === 236 /* JsxText */ && start === child.end); // whitespace only JsxText if (lookInPreviousChild) { // actual start of the node is past the position - previous token should be at the end of previous child var candidate = findRightmostChildNodeWithTokens(children, /*exclusiveStartPosition*/ i); @@ -38941,7 +39637,7 @@ var ts; } } } - ts.Debug.assert(startNode !== undefined || n.kind === 246 /* SourceFile */); + ts.Debug.assert(startNode !== undefined || n.kind === 248 /* SourceFile */); // Here we know that none of child token nodes embrace the position, // the only known case is when position is at the end of the file. // Try to find the rightmost token in the file without filtering. @@ -39016,9 +39712,9 @@ var ts; var node = ts.getTokenAtPosition(sourceFile, position); if (isToken(node)) { switch (node.kind) { - case 100 /* VarKeyword */: - case 106 /* LetKeyword */: - case 72 /* ConstKeyword */: + case 102 /* VarKeyword */: + case 108 /* LetKeyword */: + case 74 /* ConstKeyword */: // if the current token is var, let or const, skip the VariableDeclarationList node = node.parent === undefined ? undefined : node.parent.parent; break; @@ -39067,21 +39763,21 @@ var ts; } ts.getNodeModifiers = getNodeModifiers; function getTypeArgumentOrTypeParameterList(node) { - if (node.kind === 149 /* TypeReference */ || node.kind === 166 /* CallExpression */) { + if (node.kind === 151 /* TypeReference */ || node.kind === 168 /* CallExpression */) { return node.typeArguments; } - if (ts.isFunctionLike(node) || node.kind === 212 /* ClassDeclaration */ || node.kind === 213 /* InterfaceDeclaration */) { + if (ts.isFunctionLike(node) || node.kind === 214 /* ClassDeclaration */ || node.kind === 215 /* InterfaceDeclaration */) { return node.typeParameters; } return undefined; } ts.getTypeArgumentOrTypeParameterList = getTypeArgumentOrTypeParameterList; function isToken(n) { - return n.kind >= 0 /* FirstToken */ && n.kind <= 132 /* LastToken */; + return n.kind >= 0 /* FirstToken */ && n.kind <= 134 /* LastToken */; } ts.isToken = isToken; function isWord(kind) { - return kind === 67 /* Identifier */ || ts.isKeyword(kind); + return kind === 69 /* Identifier */ || ts.isKeyword(kind); } ts.isWord = isWord; function isPropertyName(kind) { @@ -39091,8 +39787,17 @@ var ts; return kind === 2 /* SingleLineCommentTrivia */ || kind === 3 /* MultiLineCommentTrivia */; } ts.isComment = isComment; + function isStringOrRegularExpressionOrTemplateLiteral(kind) { + if (kind === 9 /* StringLiteral */ + || kind === 10 /* RegularExpressionLiteral */ + || ts.isTemplateLiteralKind(kind)) { + return true; + } + return false; + } + ts.isStringOrRegularExpressionOrTemplateLiteral = isStringOrRegularExpressionOrTemplateLiteral; function isPunctuation(kind) { - return 15 /* FirstPunctuation */ <= kind && kind <= 66 /* LastPunctuation */; + return 15 /* FirstPunctuation */ <= kind && kind <= 68 /* LastPunctuation */; } ts.isPunctuation = isPunctuation; function isInsideTemplateLiteral(node, position) { @@ -39102,9 +39807,9 @@ var ts; ts.isInsideTemplateLiteral = isInsideTemplateLiteral; function isAccessibilityModifier(kind) { switch (kind) { - case 110 /* PublicKeyword */: - case 108 /* PrivateKeyword */: - case 109 /* ProtectedKeyword */: + case 112 /* PublicKeyword */: + case 110 /* PrivateKeyword */: + case 111 /* ProtectedKeyword */: return true; } return false; @@ -39132,7 +39837,7 @@ var ts; var ts; (function (ts) { function isFirstDeclarationOfSymbolParameter(symbol) { - return symbol.declarations && symbol.declarations.length > 0 && symbol.declarations[0].kind === 136 /* Parameter */; + return symbol.declarations && symbol.declarations.length > 0 && symbol.declarations[0].kind === 138 /* Parameter */; } ts.isFirstDeclarationOfSymbolParameter = isFirstDeclarationOfSymbolParameter; var displayPartWriter = getDisplayPartWriter(); @@ -39154,7 +39859,8 @@ var ts; increaseIndent: function () { indent++; }, decreaseIndent: function () { indent--; }, clear: resetWriter, - trackSymbol: function () { } + trackSymbol: function () { }, + reportInaccessibleThisError: function () { } }; function writeIndent() { if (lineStart) { @@ -39319,7 +40025,7 @@ var ts; ts.getDeclaredName = getDeclaredName; function isImportOrExportSpecifierName(location) { return location.parent && - (location.parent.kind === 224 /* ImportSpecifier */ || location.parent.kind === 228 /* ExportSpecifier */) && + (location.parent.kind === 226 /* ImportSpecifier */ || location.parent.kind === 230 /* ExportSpecifier */) && location.parent.propertyName === location; } ts.isImportOrExportSpecifierName = isImportOrExportSpecifierName; @@ -39347,7 +40053,12 @@ var ts; (function (ts) { var formatting; (function (formatting) { - var scanner = ts.createScanner(2 /* Latest */, /*skipTrivia*/ false); + var standardScanner = ts.createScanner(2 /* Latest */, /*skipTrivia*/ false, 0 /* Standard */); + var jsxScanner = ts.createScanner(2 /* Latest */, /*skipTrivia*/ false, 1 /* JSX */); + /** + * Scanner that is currently used for formatting + */ + var scanner; var ScanAction; (function (ScanAction) { ScanAction[ScanAction["Scan"] = 0] = "Scan"; @@ -39357,6 +40068,8 @@ var ts; ScanAction[ScanAction["RescanJsxIdentifier"] = 4] = "RescanJsxIdentifier"; })(ScanAction || (ScanAction = {})); function getFormattingScanner(sourceFile, startPos, endPos) { + ts.Debug.assert(scanner === undefined); + scanner = sourceFile.languageVariant === 1 /* JSX */ ? jsxScanner : standardScanner; scanner.setText(sourceFile.text); scanner.setTextPos(startPos); var wasNewLine = true; @@ -39371,11 +40084,14 @@ var ts; isOnToken: isOnToken, lastTrailingTriviaWasNewLine: function () { return wasNewLine; }, close: function () { + ts.Debug.assert(scanner !== undefined); lastTokenInfo = undefined; scanner.setText(undefined); + scanner = undefined; } }; function advance() { + ts.Debug.assert(scanner !== undefined); lastTokenInfo = undefined; var isStarted = scanner.getStartPos() !== startPos; if (isStarted) { @@ -39419,10 +40135,10 @@ var ts; if (node) { switch (node.kind) { case 29 /* GreaterThanEqualsToken */: - case 62 /* GreaterThanGreaterThanEqualsToken */: - case 63 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 44 /* GreaterThanGreaterThanGreaterThanToken */: - case 43 /* GreaterThanGreaterThanToken */: + case 64 /* GreaterThanGreaterThanEqualsToken */: + case 65 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + case 45 /* GreaterThanGreaterThanGreaterThanToken */: + case 44 /* GreaterThanGreaterThanToken */: return true; } } @@ -39431,11 +40147,11 @@ var ts; function shouldRescanJsxIdentifier(node) { if (node.parent) { switch (node.parent.kind) { - case 236 /* JsxAttribute */: - case 233 /* JsxOpeningElement */: - case 235 /* JsxClosingElement */: - case 232 /* JsxSelfClosingElement */: - return node.kind === 67 /* Identifier */; + case 238 /* JsxAttribute */: + case 235 /* JsxOpeningElement */: + case 237 /* JsxClosingElement */: + case 234 /* JsxSelfClosingElement */: + return node.kind === 69 /* Identifier */; } } return false; @@ -39448,9 +40164,10 @@ var ts; container.kind === 14 /* TemplateTail */; } function startsWithSlashToken(t) { - return t === 38 /* SlashToken */ || t === 59 /* SlashEqualsToken */; + return t === 39 /* SlashToken */ || t === 61 /* SlashEqualsToken */; } function readTokenInfo(n) { + ts.Debug.assert(scanner !== undefined); if (!isOnToken()) { // scanner is not on the token (either advance was not called yet or scanner is already past the end position) return { @@ -39500,7 +40217,7 @@ var ts; currentToken = scanner.reScanTemplateToken(); lastScanAction = 3 /* RescanTemplateToken */; } - else if (expectedScanAction === 4 /* RescanJsxIdentifier */ && currentToken === 67 /* Identifier */) { + else if (expectedScanAction === 4 /* RescanJsxIdentifier */ && currentToken === 69 /* Identifier */) { currentToken = scanner.scanJsxIdentifier(); lastScanAction = 4 /* RescanJsxIdentifier */; } @@ -39544,6 +40261,7 @@ var ts; return fixTokenKind(lastTokenInfo, n); } function isOnToken() { + ts.Debug.assert(scanner !== undefined); var current = (lastTokenInfo && lastTokenInfo.token.kind) || scanner.getToken(); var startPos = (lastTokenInfo && lastTokenInfo.token.pos) || scanner.getStartPos(); return startPos < endPos && current !== 1 /* EndOfFileToken */ && !ts.isTrivia(current); @@ -39822,17 +40540,17 @@ var ts; this.IgnoreAfterLineComment = new formatting.Rule(formatting.RuleDescriptor.create3(2 /* SingleLineCommentTrivia */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create1(1 /* Ignore */)); // Space after keyword but not before ; or : or ? this.NoSpaceBeforeSemicolon = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 23 /* SemicolonToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); - this.NoSpaceBeforeColon = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 53 /* ColonToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 8 /* Delete */)); - this.NoSpaceBeforeQuestionMark = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 52 /* QuestionToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 8 /* Delete */)); - this.SpaceAfterColon = new formatting.Rule(formatting.RuleDescriptor.create3(53 /* ColonToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 2 /* Space */)); - this.SpaceAfterQuestionMarkInConditionalOperator = new formatting.Rule(formatting.RuleDescriptor.create3(52 /* QuestionToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsConditionalOperatorContext), 2 /* Space */)); - this.NoSpaceAfterQuestionMark = new formatting.Rule(formatting.RuleDescriptor.create3(52 /* QuestionToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceBeforeColon = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 54 /* ColonToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 8 /* Delete */)); + this.NoSpaceBeforeQuestionMark = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 53 /* QuestionToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 8 /* Delete */)); + this.SpaceAfterColon = new formatting.Rule(formatting.RuleDescriptor.create3(54 /* ColonToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 2 /* Space */)); + this.SpaceAfterQuestionMarkInConditionalOperator = new formatting.Rule(formatting.RuleDescriptor.create3(53 /* QuestionToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsConditionalOperatorContext), 2 /* Space */)); + this.NoSpaceAfterQuestionMark = new formatting.Rule(formatting.RuleDescriptor.create3(53 /* QuestionToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); this.SpaceAfterSemicolon = new formatting.Rule(formatting.RuleDescriptor.create3(23 /* SemicolonToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); // Space after }. this.SpaceAfterCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create3(16 /* CloseBraceToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsAfterCodeBlockContext), 2 /* Space */)); // Special case for (}, else) and (}, while) since else & while tokens are not part of the tree which makes SpaceAfterCloseBrace rule not applied - this.SpaceBetweenCloseBraceAndElse = new formatting.Rule(formatting.RuleDescriptor.create1(16 /* CloseBraceToken */, 78 /* ElseKeyword */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); - this.SpaceBetweenCloseBraceAndWhile = new formatting.Rule(formatting.RuleDescriptor.create1(16 /* CloseBraceToken */, 102 /* WhileKeyword */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); + this.SpaceBetweenCloseBraceAndElse = new formatting.Rule(formatting.RuleDescriptor.create1(16 /* CloseBraceToken */, 80 /* ElseKeyword */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); + this.SpaceBetweenCloseBraceAndWhile = new formatting.Rule(formatting.RuleDescriptor.create1(16 /* CloseBraceToken */, 104 /* WhileKeyword */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); this.NoSpaceAfterCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create3(16 /* CloseBraceToken */, formatting.Shared.TokenRange.FromTokens([18 /* CloseParenToken */, 20 /* CloseBracketToken */, 24 /* CommaToken */, 23 /* SemicolonToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); // No space for dot this.NoSpaceBeforeDot = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 21 /* DotToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); @@ -39844,10 +40562,10 @@ var ts; this.FunctionOpenBraceLeftTokenRange = formatting.Shared.TokenRange.AnyIncludingMultilineComments; this.SpaceBeforeOpenBraceInFunction = new formatting.Rule(formatting.RuleDescriptor.create2(this.FunctionOpenBraceLeftTokenRange, 15 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext, Rules.IsBeforeBlockContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), 2 /* Space */), 1 /* CanDeleteNewLines */); // Place a space before open brace in a TypeScript declaration that has braces as children (class, module, enum, etc) - this.TypeScriptOpenBraceLeftTokenRange = formatting.Shared.TokenRange.FromTokens([67 /* Identifier */, 3 /* MultiLineCommentTrivia */, 71 /* ClassKeyword */]); + this.TypeScriptOpenBraceLeftTokenRange = formatting.Shared.TokenRange.FromTokens([69 /* Identifier */, 3 /* MultiLineCommentTrivia */, 73 /* ClassKeyword */]); this.SpaceBeforeOpenBraceInTypeScriptDeclWithBlock = new formatting.Rule(formatting.RuleDescriptor.create2(this.TypeScriptOpenBraceLeftTokenRange, 15 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsTypeScriptDeclWithBlockContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), 2 /* Space */), 1 /* CanDeleteNewLines */); // Place a space before open brace in a control flow construct - this.ControlOpenBraceLeftTokenRange = formatting.Shared.TokenRange.FromTokens([18 /* CloseParenToken */, 3 /* MultiLineCommentTrivia */, 77 /* DoKeyword */, 98 /* TryKeyword */, 83 /* FinallyKeyword */, 78 /* ElseKeyword */]); + this.ControlOpenBraceLeftTokenRange = formatting.Shared.TokenRange.FromTokens([18 /* CloseParenToken */, 3 /* MultiLineCommentTrivia */, 79 /* DoKeyword */, 100 /* TryKeyword */, 85 /* FinallyKeyword */, 80 /* ElseKeyword */]); this.SpaceBeforeOpenBraceInControl = new formatting.Rule(formatting.RuleDescriptor.create2(this.ControlOpenBraceLeftTokenRange, 15 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsControlDeclContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), 2 /* Space */), 1 /* CanDeleteNewLines */); // Insert a space after { and before } in single-line contexts, but remove space from empty object literals {}. this.SpaceAfterOpenBrace = new formatting.Rule(formatting.RuleDescriptor.create3(15 /* OpenBraceToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSingleLineBlockContext), 2 /* Space */)); @@ -39861,55 +40579,55 @@ var ts; // Prefix operators generally shouldn't have a space between // them and their target unary expression. this.NoSpaceAfterUnaryPrefixOperator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.UnaryPrefixOperators, formatting.Shared.TokenRange.UnaryPrefixExpressions), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 8 /* Delete */)); - this.NoSpaceAfterUnaryPreincrementOperator = new formatting.Rule(formatting.RuleDescriptor.create3(40 /* PlusPlusToken */, formatting.Shared.TokenRange.UnaryPreincrementExpressions), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); - this.NoSpaceAfterUnaryPredecrementOperator = new formatting.Rule(formatting.RuleDescriptor.create3(41 /* MinusMinusToken */, formatting.Shared.TokenRange.UnaryPredecrementExpressions), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); - this.NoSpaceBeforeUnaryPostincrementOperator = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.UnaryPostincrementExpressions, 40 /* PlusPlusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); - this.NoSpaceBeforeUnaryPostdecrementOperator = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.UnaryPostdecrementExpressions, 41 /* MinusMinusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceAfterUnaryPreincrementOperator = new formatting.Rule(formatting.RuleDescriptor.create3(41 /* PlusPlusToken */, formatting.Shared.TokenRange.UnaryPreincrementExpressions), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceAfterUnaryPredecrementOperator = new formatting.Rule(formatting.RuleDescriptor.create3(42 /* MinusMinusToken */, formatting.Shared.TokenRange.UnaryPredecrementExpressions), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceBeforeUnaryPostincrementOperator = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.UnaryPostincrementExpressions, 41 /* PlusPlusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceBeforeUnaryPostdecrementOperator = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.UnaryPostdecrementExpressions, 42 /* MinusMinusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); // More unary operator special-casing. // DevDiv 181814: Be careful when removing leading whitespace // around unary operators. Examples: // 1 - -2 --X--> 1--2 // a + ++b --X--> a+++b - this.SpaceAfterPostincrementWhenFollowedByAdd = new formatting.Rule(formatting.RuleDescriptor.create1(40 /* PlusPlusToken */, 35 /* PlusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); + this.SpaceAfterPostincrementWhenFollowedByAdd = new formatting.Rule(formatting.RuleDescriptor.create1(41 /* PlusPlusToken */, 35 /* PlusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); this.SpaceAfterAddWhenFollowedByUnaryPlus = new formatting.Rule(formatting.RuleDescriptor.create1(35 /* PlusToken */, 35 /* PlusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); - this.SpaceAfterAddWhenFollowedByPreincrement = new formatting.Rule(formatting.RuleDescriptor.create1(35 /* PlusToken */, 40 /* PlusPlusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); - this.SpaceAfterPostdecrementWhenFollowedBySubtract = new formatting.Rule(formatting.RuleDescriptor.create1(41 /* MinusMinusToken */, 36 /* MinusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); + this.SpaceAfterAddWhenFollowedByPreincrement = new formatting.Rule(formatting.RuleDescriptor.create1(35 /* PlusToken */, 41 /* PlusPlusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); + this.SpaceAfterPostdecrementWhenFollowedBySubtract = new formatting.Rule(formatting.RuleDescriptor.create1(42 /* MinusMinusToken */, 36 /* MinusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); this.SpaceAfterSubtractWhenFollowedByUnaryMinus = new formatting.Rule(formatting.RuleDescriptor.create1(36 /* MinusToken */, 36 /* MinusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); - this.SpaceAfterSubtractWhenFollowedByPredecrement = new formatting.Rule(formatting.RuleDescriptor.create1(36 /* MinusToken */, 41 /* MinusMinusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); + this.SpaceAfterSubtractWhenFollowedByPredecrement = new formatting.Rule(formatting.RuleDescriptor.create1(36 /* MinusToken */, 42 /* MinusMinusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); this.NoSpaceBeforeComma = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 24 /* CommaToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); - this.SpaceAfterCertainKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([100 /* VarKeyword */, 96 /* ThrowKeyword */, 90 /* NewKeyword */, 76 /* DeleteKeyword */, 92 /* ReturnKeyword */, 99 /* TypeOfKeyword */, 117 /* AwaitKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); - this.SpaceAfterLetConstInVariableDeclaration = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([106 /* LetKeyword */, 72 /* ConstKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsStartOfVariableDeclarationList), 2 /* Space */)); + this.SpaceAfterCertainKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([102 /* VarKeyword */, 98 /* ThrowKeyword */, 92 /* NewKeyword */, 78 /* DeleteKeyword */, 94 /* ReturnKeyword */, 101 /* TypeOfKeyword */, 119 /* AwaitKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); + this.SpaceAfterLetConstInVariableDeclaration = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([108 /* LetKeyword */, 74 /* ConstKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsStartOfVariableDeclarationList), 2 /* Space */)); this.NoSpaceBeforeOpenParenInFuncCall = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 17 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsFunctionCallOrNewContext, Rules.IsPreviousTokenNotComma), 8 /* Delete */)); - this.SpaceAfterFunctionInFuncDecl = new formatting.Rule(formatting.RuleDescriptor.create3(85 /* FunctionKeyword */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2 /* Space */)); + this.SpaceAfterFunctionInFuncDecl = new formatting.Rule(formatting.RuleDescriptor.create3(87 /* FunctionKeyword */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2 /* Space */)); this.NoSpaceBeforeOpenParenInFuncDecl = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 17 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsFunctionDeclContext), 8 /* Delete */)); - this.SpaceAfterVoidOperator = new formatting.Rule(formatting.RuleDescriptor.create3(101 /* VoidKeyword */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsVoidOpContext), 2 /* Space */)); - this.NoSpaceBetweenReturnAndSemicolon = new formatting.Rule(formatting.RuleDescriptor.create1(92 /* ReturnKeyword */, 23 /* SemicolonToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.SpaceAfterVoidOperator = new formatting.Rule(formatting.RuleDescriptor.create3(103 /* VoidKeyword */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsVoidOpContext), 2 /* Space */)); + this.NoSpaceBetweenReturnAndSemicolon = new formatting.Rule(formatting.RuleDescriptor.create1(94 /* ReturnKeyword */, 23 /* SemicolonToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); // Add a space between statements. All keywords except (do,else,case) has open/close parens after them. // So, we have a rule to add a space for [),Any], [do,Any], [else,Any], and [case,Any] - this.SpaceBetweenStatements = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([18 /* CloseParenToken */, 77 /* DoKeyword */, 78 /* ElseKeyword */, 69 /* CaseKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotForContext), 2 /* Space */)); + this.SpaceBetweenStatements = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([18 /* CloseParenToken */, 79 /* DoKeyword */, 80 /* ElseKeyword */, 71 /* CaseKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotForContext), 2 /* Space */)); // This low-pri rule takes care of "try {" and "finally {" in case the rule SpaceBeforeOpenBraceInControl didn't execute on FormatOnEnter. - this.SpaceAfterTryFinally = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([98 /* TryKeyword */, 83 /* FinallyKeyword */]), 15 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); + this.SpaceAfterTryFinally = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([100 /* TryKeyword */, 85 /* FinallyKeyword */]), 15 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); // get x() {} // set x(val) {} - this.SpaceAfterGetSetInMember = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([121 /* GetKeyword */, 127 /* SetKeyword */]), 67 /* Identifier */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2 /* Space */)); + this.SpaceAfterGetSetInMember = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([123 /* GetKeyword */, 129 /* SetKeyword */]), 69 /* Identifier */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2 /* Space */)); // Special case for binary operators (that are keywords). For these we have to add a space and shouldn't follow any user options. this.SpaceBeforeBinaryKeywordOperator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.BinaryKeywordOperators), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); this.SpaceAfterBinaryKeywordOperator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.BinaryKeywordOperators, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); // TypeScript-specific higher priority rules // Treat constructor as an identifier in a function declaration, and remove spaces between constructor and following left parentheses - this.NoSpaceAfterConstructor = new formatting.Rule(formatting.RuleDescriptor.create1(119 /* ConstructorKeyword */, 17 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceAfterConstructor = new formatting.Rule(formatting.RuleDescriptor.create1(121 /* ConstructorKeyword */, 17 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); // Use of module as a function call. e.g.: import m2 = module("m2"); - this.NoSpaceAfterModuleImport = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([123 /* ModuleKeyword */, 125 /* RequireKeyword */]), 17 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceAfterModuleImport = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([125 /* ModuleKeyword */, 127 /* RequireKeyword */]), 17 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); // Add a space around certain TypeScript keywords - this.SpaceAfterCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([113 /* AbstractKeyword */, 71 /* ClassKeyword */, 120 /* DeclareKeyword */, 75 /* DefaultKeyword */, 79 /* EnumKeyword */, 80 /* ExportKeyword */, 81 /* ExtendsKeyword */, 121 /* GetKeyword */, 104 /* ImplementsKeyword */, 87 /* ImportKeyword */, 105 /* InterfaceKeyword */, 123 /* ModuleKeyword */, 124 /* NamespaceKeyword */, 108 /* PrivateKeyword */, 110 /* PublicKeyword */, 109 /* ProtectedKeyword */, 127 /* SetKeyword */, 111 /* StaticKeyword */, 130 /* TypeKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); - this.SpaceBeforeCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([81 /* ExtendsKeyword */, 104 /* ImplementsKeyword */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); + this.SpaceAfterCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([115 /* AbstractKeyword */, 73 /* ClassKeyword */, 122 /* DeclareKeyword */, 77 /* DefaultKeyword */, 81 /* EnumKeyword */, 82 /* ExportKeyword */, 83 /* ExtendsKeyword */, 123 /* GetKeyword */, 106 /* ImplementsKeyword */, 89 /* ImportKeyword */, 107 /* InterfaceKeyword */, 125 /* ModuleKeyword */, 126 /* NamespaceKeyword */, 110 /* PrivateKeyword */, 112 /* PublicKeyword */, 111 /* ProtectedKeyword */, 129 /* SetKeyword */, 113 /* StaticKeyword */, 132 /* TypeKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); + this.SpaceBeforeCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([83 /* ExtendsKeyword */, 106 /* ImplementsKeyword */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); // Treat string literals in module names as identifiers, and add a space between the literal and the opening Brace braces, e.g.: module "m2" { this.SpaceAfterModuleName = new formatting.Rule(formatting.RuleDescriptor.create1(9 /* StringLiteral */, 15 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsModuleDeclContext), 2 /* Space */)); // Lambda expressions this.SpaceAfterArrow = new formatting.Rule(formatting.RuleDescriptor.create3(34 /* EqualsGreaterThanToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); // Optional parameters and let args - this.NoSpaceAfterEllipsis = new formatting.Rule(formatting.RuleDescriptor.create1(22 /* DotDotDotToken */, 67 /* Identifier */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); - this.NoSpaceAfterOptionalParameters = new formatting.Rule(formatting.RuleDescriptor.create3(52 /* QuestionToken */, formatting.Shared.TokenRange.FromTokens([18 /* CloseParenToken */, 24 /* CommaToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 8 /* Delete */)); + this.NoSpaceAfterEllipsis = new formatting.Rule(formatting.RuleDescriptor.create1(22 /* DotDotDotToken */, 69 /* Identifier */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceAfterOptionalParameters = new formatting.Rule(formatting.RuleDescriptor.create3(53 /* QuestionToken */, formatting.Shared.TokenRange.FromTokens([18 /* CloseParenToken */, 24 /* CommaToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 8 /* Delete */)); // generics and type assertions this.NoSpaceBeforeOpenAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.TypeNames, 25 /* LessThanToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), 8 /* Delete */)); this.NoSpaceBetweenCloseParenAndAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create1(18 /* CloseParenToken */, 25 /* LessThanToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), 8 /* Delete */)); @@ -39920,17 +40638,20 @@ var ts; // Remove spaces in empty interface literals. e.g.: x: {} this.NoSpaceBetweenEmptyInterfaceBraceBrackets = new formatting.Rule(formatting.RuleDescriptor.create1(15 /* OpenBraceToken */, 16 /* CloseBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsObjectTypeContext), 8 /* Delete */)); // decorators - this.SpaceBeforeAt = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 54 /* AtToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); - this.NoSpaceAfterAt = new formatting.Rule(formatting.RuleDescriptor.create3(54 /* AtToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); - this.SpaceAfterDecorator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([113 /* AbstractKeyword */, 67 /* Identifier */, 80 /* ExportKeyword */, 75 /* DefaultKeyword */, 71 /* ClassKeyword */, 111 /* StaticKeyword */, 110 /* PublicKeyword */, 108 /* PrivateKeyword */, 109 /* ProtectedKeyword */, 121 /* GetKeyword */, 127 /* SetKeyword */, 19 /* OpenBracketToken */, 37 /* AsteriskToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsEndOfDecoratorContextOnSameLine), 2 /* Space */)); - this.NoSpaceBetweenFunctionKeywordAndStar = new formatting.Rule(formatting.RuleDescriptor.create1(85 /* FunctionKeyword */, 37 /* AsteriskToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclarationOrFunctionExpressionContext), 8 /* Delete */)); - this.SpaceAfterStarInGeneratorDeclaration = new formatting.Rule(formatting.RuleDescriptor.create3(37 /* AsteriskToken */, formatting.Shared.TokenRange.FromTokens([67 /* Identifier */, 17 /* OpenParenToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclarationOrFunctionExpressionContext), 2 /* Space */)); - this.NoSpaceBetweenYieldKeywordAndStar = new formatting.Rule(formatting.RuleDescriptor.create1(112 /* YieldKeyword */, 37 /* AsteriskToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsYieldOrYieldStarWithOperand), 8 /* Delete */)); - this.SpaceBetweenYieldOrYieldStarAndOperand = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([112 /* YieldKeyword */, 37 /* AsteriskToken */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsYieldOrYieldStarWithOperand), 2 /* Space */)); + this.SpaceBeforeAt = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 55 /* AtToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); + this.NoSpaceAfterAt = new formatting.Rule(formatting.RuleDescriptor.create3(55 /* AtToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.SpaceAfterDecorator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([115 /* AbstractKeyword */, 69 /* Identifier */, 82 /* ExportKeyword */, 77 /* DefaultKeyword */, 73 /* ClassKeyword */, 113 /* StaticKeyword */, 112 /* PublicKeyword */, 110 /* PrivateKeyword */, 111 /* ProtectedKeyword */, 123 /* GetKeyword */, 129 /* SetKeyword */, 19 /* OpenBracketToken */, 37 /* AsteriskToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsEndOfDecoratorContextOnSameLine), 2 /* Space */)); + this.NoSpaceBetweenFunctionKeywordAndStar = new formatting.Rule(formatting.RuleDescriptor.create1(87 /* FunctionKeyword */, 37 /* AsteriskToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclarationOrFunctionExpressionContext), 8 /* Delete */)); + this.SpaceAfterStarInGeneratorDeclaration = new formatting.Rule(formatting.RuleDescriptor.create3(37 /* AsteriskToken */, formatting.Shared.TokenRange.FromTokens([69 /* Identifier */, 17 /* OpenParenToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclarationOrFunctionExpressionContext), 2 /* Space */)); + this.NoSpaceBetweenYieldKeywordAndStar = new formatting.Rule(formatting.RuleDescriptor.create1(114 /* YieldKeyword */, 37 /* AsteriskToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsYieldOrYieldStarWithOperand), 8 /* Delete */)); + this.SpaceBetweenYieldOrYieldStarAndOperand = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([114 /* YieldKeyword */, 37 /* AsteriskToken */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsYieldOrYieldStarWithOperand), 2 /* Space */)); // Async-await - this.SpaceBetweenAsyncAndFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(116 /* AsyncKeyword */, 85 /* FunctionKeyword */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); + this.SpaceBetweenAsyncAndOpenParen = new formatting.Rule(formatting.RuleDescriptor.create1(118 /* AsyncKeyword */, 17 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsArrowFunctionContext, Rules.IsSameLineTokenContext), 2 /* Space */)); + this.SpaceBetweenAsyncAndFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(118 /* AsyncKeyword */, 87 /* FunctionKeyword */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); // template string - this.SpaceBetweenTagAndTemplateString = new formatting.Rule(formatting.RuleDescriptor.create3(67 /* Identifier */, formatting.Shared.TokenRange.FromTokens([11 /* NoSubstitutionTemplateLiteral */, 12 /* TemplateHead */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); + this.SpaceBetweenTagAndTemplateString = new formatting.Rule(formatting.RuleDescriptor.create3(69 /* Identifier */, formatting.Shared.TokenRange.FromTokens([11 /* NoSubstitutionTemplateLiteral */, 12 /* TemplateHead */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); + this.NoSpaceAfterTemplateHeadAndMiddle = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([12 /* TemplateHead */, 13 /* TemplateMiddle */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceBeforeTemplateMiddleAndTail = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([13 /* TemplateMiddle */, 14 /* TemplateTail */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); // These rules are higher in priority than user-configurable rules. this.HighPriorityCommonRules = [ @@ -39957,8 +40678,8 @@ var ts; this.NoSpaceBeforeOpenParenInFuncCall, this.SpaceBeforeBinaryKeywordOperator, this.SpaceAfterBinaryKeywordOperator, this.SpaceAfterVoidOperator, - this.SpaceBetweenAsyncAndFunctionKeyword, - this.SpaceBetweenTagAndTemplateString, + this.SpaceBetweenAsyncAndOpenParen, this.SpaceBetweenAsyncAndFunctionKeyword, + this.SpaceBetweenTagAndTemplateString, this.NoSpaceAfterTemplateHeadAndMiddle, this.NoSpaceBeforeTemplateMiddleAndTail, // TypeScript-specific rules this.NoSpaceAfterConstructor, this.NoSpaceAfterModuleImport, this.SpaceAfterCertainTypeScriptKeywords, this.SpaceBeforeCertainTypeScriptKeywords, @@ -40026,14 +40747,14 @@ var ts; this.NoSpaceAfterOpenBracket = new formatting.Rule(formatting.RuleDescriptor.create3(19 /* OpenBracketToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); this.NoSpaceBeforeCloseBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 20 /* CloseBracketToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); // Insert space after function keyword for anonymous functions - this.SpaceAfterAnonymousFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(85 /* FunctionKeyword */, 17 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2 /* Space */)); - this.NoSpaceAfterAnonymousFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(85 /* FunctionKeyword */, 17 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 8 /* Delete */)); + this.SpaceAfterAnonymousFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(87 /* FunctionKeyword */, 17 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2 /* Space */)); + this.NoSpaceAfterAnonymousFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(87 /* FunctionKeyword */, 17 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 8 /* Delete */)); } Rules.prototype.getRuleName = function (rule) { var o = this; - for (var name_30 in o) { - if (o[name_30] === rule) { - return name_30; + for (var name_31 in o) { + if (o[name_31] === rule) { + return name_31; } } throw new Error("Unknown rule"); @@ -40042,40 +40763,40 @@ var ts; /// Contexts /// Rules.IsForContext = function (context) { - return context.contextNode.kind === 197 /* ForStatement */; + return context.contextNode.kind === 199 /* ForStatement */; }; Rules.IsNotForContext = function (context) { return !Rules.IsForContext(context); }; Rules.IsBinaryOpContext = function (context) { switch (context.contextNode.kind) { - case 179 /* BinaryExpression */: - case 180 /* ConditionalExpression */: - case 187 /* AsExpression */: - case 148 /* TypePredicate */: - case 156 /* UnionType */: - case 157 /* IntersectionType */: + case 181 /* BinaryExpression */: + case 182 /* ConditionalExpression */: + case 189 /* AsExpression */: + case 150 /* TypePredicate */: + case 158 /* UnionType */: + case 159 /* IntersectionType */: return true; // equals in binding elements: function foo([[x, y] = [1, 2]]) - case 161 /* BindingElement */: + case 163 /* BindingElement */: // equals in type X = ... - case 214 /* TypeAliasDeclaration */: + case 216 /* TypeAliasDeclaration */: // equal in import a = module('a'); - case 219 /* ImportEqualsDeclaration */: + case 221 /* ImportEqualsDeclaration */: // equal in let a = 0; - case 209 /* VariableDeclaration */: + case 211 /* VariableDeclaration */: // equal in p = 0; - case 136 /* Parameter */: - case 245 /* EnumMember */: - case 139 /* PropertyDeclaration */: - case 138 /* PropertySignature */: - return context.currentTokenSpan.kind === 55 /* EqualsToken */ || context.nextTokenSpan.kind === 55 /* EqualsToken */; + case 138 /* Parameter */: + case 247 /* EnumMember */: + case 141 /* PropertyDeclaration */: + case 140 /* PropertySignature */: + return context.currentTokenSpan.kind === 56 /* EqualsToken */ || context.nextTokenSpan.kind === 56 /* EqualsToken */; // "in" keyword in for (let x in []) { } - case 198 /* ForInStatement */: - return context.currentTokenSpan.kind === 88 /* InKeyword */ || context.nextTokenSpan.kind === 88 /* InKeyword */; + case 200 /* ForInStatement */: + return context.currentTokenSpan.kind === 90 /* InKeyword */ || context.nextTokenSpan.kind === 90 /* InKeyword */; // Technically, "of" is not a binary operator, but format it the same way as "in" - case 199 /* ForOfStatement */: - return context.currentTokenSpan.kind === 132 /* OfKeyword */ || context.nextTokenSpan.kind === 132 /* OfKeyword */; + case 201 /* ForOfStatement */: + return context.currentTokenSpan.kind === 134 /* OfKeyword */ || context.nextTokenSpan.kind === 134 /* OfKeyword */; } return false; }; @@ -40083,7 +40804,7 @@ var ts; return !Rules.IsBinaryOpContext(context); }; Rules.IsConditionalOperatorContext = function (context) { - return context.contextNode.kind === 180 /* ConditionalExpression */; + return context.contextNode.kind === 182 /* ConditionalExpression */; }; Rules.IsSameLineTokenOrBeforeMultilineBlockContext = function (context) { //// This check is mainly used inside SpaceBeforeOpenBraceInControl and SpaceBeforeOpenBraceInFunction. @@ -40127,93 +40848,93 @@ var ts; return true; } switch (node.kind) { - case 190 /* Block */: - case 218 /* CaseBlock */: - case 163 /* ObjectLiteralExpression */: - case 217 /* ModuleBlock */: + case 192 /* Block */: + case 220 /* CaseBlock */: + case 165 /* ObjectLiteralExpression */: + case 219 /* ModuleBlock */: return true; } return false; }; Rules.IsFunctionDeclContext = function (context) { switch (context.contextNode.kind) { - case 211 /* FunctionDeclaration */: - case 141 /* MethodDeclaration */: - case 140 /* MethodSignature */: + case 213 /* FunctionDeclaration */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: //case SyntaxKind.MemberFunctionDeclaration: - case 143 /* GetAccessor */: - case 144 /* SetAccessor */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: ///case SyntaxKind.MethodSignature: - case 145 /* CallSignature */: - case 171 /* FunctionExpression */: - case 142 /* Constructor */: - case 172 /* ArrowFunction */: + case 147 /* CallSignature */: + case 173 /* FunctionExpression */: + case 144 /* Constructor */: + case 174 /* ArrowFunction */: //case SyntaxKind.ConstructorDeclaration: //case SyntaxKind.SimpleArrowFunctionExpression: //case SyntaxKind.ParenthesizedArrowFunctionExpression: - case 213 /* InterfaceDeclaration */: + case 215 /* InterfaceDeclaration */: return true; } return false; }; Rules.IsFunctionDeclarationOrFunctionExpressionContext = function (context) { - return context.contextNode.kind === 211 /* FunctionDeclaration */ || context.contextNode.kind === 171 /* FunctionExpression */; + return context.contextNode.kind === 213 /* FunctionDeclaration */ || context.contextNode.kind === 173 /* FunctionExpression */; }; Rules.IsTypeScriptDeclWithBlockContext = function (context) { return Rules.NodeIsTypeScriptDeclWithBlockContext(context.contextNode); }; Rules.NodeIsTypeScriptDeclWithBlockContext = function (node) { switch (node.kind) { - case 212 /* ClassDeclaration */: - case 184 /* ClassExpression */: - case 213 /* InterfaceDeclaration */: - case 215 /* EnumDeclaration */: - case 153 /* TypeLiteral */: - case 216 /* ModuleDeclaration */: + case 214 /* ClassDeclaration */: + case 186 /* ClassExpression */: + case 215 /* InterfaceDeclaration */: + case 217 /* EnumDeclaration */: + case 155 /* TypeLiteral */: + case 218 /* ModuleDeclaration */: return true; } return false; }; Rules.IsAfterCodeBlockContext = function (context) { switch (context.currentTokenParent.kind) { - case 212 /* ClassDeclaration */: - case 216 /* ModuleDeclaration */: - case 215 /* EnumDeclaration */: - case 190 /* Block */: - case 242 /* CatchClause */: - case 217 /* ModuleBlock */: - case 204 /* SwitchStatement */: + case 214 /* ClassDeclaration */: + case 218 /* ModuleDeclaration */: + case 217 /* EnumDeclaration */: + case 192 /* Block */: + case 244 /* CatchClause */: + case 219 /* ModuleBlock */: + case 206 /* SwitchStatement */: return true; } return false; }; Rules.IsControlDeclContext = function (context) { switch (context.contextNode.kind) { - case 194 /* IfStatement */: - case 204 /* SwitchStatement */: - case 197 /* ForStatement */: - case 198 /* ForInStatement */: - case 199 /* ForOfStatement */: - case 196 /* WhileStatement */: - case 207 /* TryStatement */: - case 195 /* DoStatement */: - case 203 /* WithStatement */: + case 196 /* IfStatement */: + case 206 /* SwitchStatement */: + case 199 /* ForStatement */: + case 200 /* ForInStatement */: + case 201 /* ForOfStatement */: + case 198 /* WhileStatement */: + case 209 /* TryStatement */: + case 197 /* DoStatement */: + case 205 /* WithStatement */: // TODO // case SyntaxKind.ElseClause: - case 242 /* CatchClause */: + case 244 /* CatchClause */: return true; default: return false; } }; Rules.IsObjectContext = function (context) { - return context.contextNode.kind === 163 /* ObjectLiteralExpression */; + return context.contextNode.kind === 165 /* ObjectLiteralExpression */; }; Rules.IsFunctionCallContext = function (context) { - return context.contextNode.kind === 166 /* CallExpression */; + return context.contextNode.kind === 168 /* CallExpression */; }; Rules.IsNewContext = function (context) { - return context.contextNode.kind === 167 /* NewExpression */; + return context.contextNode.kind === 169 /* NewExpression */; }; Rules.IsFunctionCallOrNewContext = function (context) { return Rules.IsFunctionCallContext(context) || Rules.IsNewContext(context); @@ -40221,6 +40942,9 @@ var ts; Rules.IsPreviousTokenNotComma = function (context) { return context.currentTokenSpan.kind !== 24 /* CommaToken */; }; + Rules.IsArrowFunctionContext = function (context) { + return context.contextNode.kind === 174 /* ArrowFunction */; + }; Rules.IsSameLineTokenContext = function (context) { return context.TokensAreOnSameLine(); }; @@ -40237,41 +40961,41 @@ var ts; while (ts.isExpression(node)) { node = node.parent; } - return node.kind === 137 /* Decorator */; + return node.kind === 139 /* Decorator */; }; Rules.IsStartOfVariableDeclarationList = function (context) { - return context.currentTokenParent.kind === 210 /* VariableDeclarationList */ && + return context.currentTokenParent.kind === 212 /* VariableDeclarationList */ && context.currentTokenParent.getStart(context.sourceFile) === context.currentTokenSpan.pos; }; Rules.IsNotFormatOnEnter = function (context) { return context.formattingRequestKind !== 2 /* FormatOnEnter */; }; Rules.IsModuleDeclContext = function (context) { - return context.contextNode.kind === 216 /* ModuleDeclaration */; + return context.contextNode.kind === 218 /* ModuleDeclaration */; }; Rules.IsObjectTypeContext = function (context) { - return context.contextNode.kind === 153 /* TypeLiteral */; // && context.contextNode.parent.kind !== SyntaxKind.InterfaceDeclaration; + return context.contextNode.kind === 155 /* TypeLiteral */; // && context.contextNode.parent.kind !== SyntaxKind.InterfaceDeclaration; }; Rules.IsTypeArgumentOrParameterOrAssertion = function (token, parent) { if (token.kind !== 25 /* LessThanToken */ && token.kind !== 27 /* GreaterThanToken */) { return false; } switch (parent.kind) { - case 149 /* TypeReference */: - case 169 /* TypeAssertionExpression */: - case 212 /* ClassDeclaration */: - case 184 /* ClassExpression */: - case 213 /* InterfaceDeclaration */: - case 211 /* FunctionDeclaration */: - case 171 /* FunctionExpression */: - case 172 /* ArrowFunction */: - case 141 /* MethodDeclaration */: - case 140 /* MethodSignature */: - case 145 /* CallSignature */: - case 146 /* ConstructSignature */: - case 166 /* CallExpression */: - case 167 /* NewExpression */: - case 186 /* ExpressionWithTypeArguments */: + case 151 /* TypeReference */: + case 171 /* TypeAssertionExpression */: + case 214 /* ClassDeclaration */: + case 186 /* ClassExpression */: + case 215 /* InterfaceDeclaration */: + case 213 /* FunctionDeclaration */: + case 173 /* FunctionExpression */: + case 174 /* ArrowFunction */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: + case 147 /* CallSignature */: + case 148 /* ConstructSignature */: + case 168 /* CallExpression */: + case 169 /* NewExpression */: + case 188 /* ExpressionWithTypeArguments */: return true; default: return false; @@ -40282,13 +41006,13 @@ var ts; Rules.IsTypeArgumentOrParameterOrAssertion(context.nextTokenSpan, context.nextTokenParent); }; Rules.IsTypeAssertionContext = function (context) { - return context.contextNode.kind === 169 /* TypeAssertionExpression */; + return context.contextNode.kind === 171 /* TypeAssertionExpression */; }; Rules.IsVoidOpContext = function (context) { - return context.currentTokenSpan.kind === 101 /* VoidKeyword */ && context.currentTokenParent.kind === 175 /* VoidExpression */; + return context.currentTokenSpan.kind === 103 /* VoidKeyword */ && context.currentTokenParent.kind === 177 /* VoidExpression */; }; Rules.IsYieldOrYieldStarWithOperand = function (context) { - return context.contextNode.kind === 182 /* YieldExpression */ && context.contextNode.expression !== undefined; + return context.contextNode.kind === 184 /* YieldExpression */ && context.contextNode.expression !== undefined; }; return Rules; })(); @@ -40312,7 +41036,7 @@ var ts; return result; }; RulesMap.prototype.Initialize = function (rules) { - this.mapRowLength = 132 /* LastToken */ + 1; + this.mapRowLength = 134 /* LastToken */ + 1; this.map = new Array(this.mapRowLength * this.mapRowLength); //new Array(this.mapRowLength * this.mapRowLength); // This array is used only during construction of the rulesbucket in the map var rulesBucketConstructionStateList = new Array(this.map.length); //new Array(this.map.length); @@ -40507,7 +41231,7 @@ var ts; } TokenAllAccess.prototype.GetTokens = function () { var result = []; - for (var token = 0 /* FirstToken */; token <= 132 /* LastToken */; token++) { + for (var token = 0 /* FirstToken */; token <= 134 /* LastToken */; token++) { result.push(token); } return result; @@ -40549,17 +41273,17 @@ var ts; }; TokenRange.Any = TokenRange.AllTokens(); TokenRange.AnyIncludingMultilineComments = TokenRange.FromTokens(TokenRange.Any.GetTokens().concat([3 /* MultiLineCommentTrivia */])); - TokenRange.Keywords = TokenRange.FromRange(68 /* FirstKeyword */, 132 /* LastKeyword */); - TokenRange.BinaryOperators = TokenRange.FromRange(25 /* FirstBinaryOperator */, 66 /* LastBinaryOperator */); - TokenRange.BinaryKeywordOperators = TokenRange.FromTokens([88 /* InKeyword */, 89 /* InstanceOfKeyword */, 132 /* OfKeyword */, 114 /* AsKeyword */, 122 /* IsKeyword */]); - TokenRange.UnaryPrefixOperators = TokenRange.FromTokens([40 /* PlusPlusToken */, 41 /* MinusMinusToken */, 49 /* TildeToken */, 48 /* ExclamationToken */]); - TokenRange.UnaryPrefixExpressions = TokenRange.FromTokens([8 /* NumericLiteral */, 67 /* Identifier */, 17 /* OpenParenToken */, 19 /* OpenBracketToken */, 15 /* OpenBraceToken */, 95 /* ThisKeyword */, 90 /* NewKeyword */]); - TokenRange.UnaryPreincrementExpressions = TokenRange.FromTokens([67 /* Identifier */, 17 /* OpenParenToken */, 95 /* ThisKeyword */, 90 /* NewKeyword */]); - TokenRange.UnaryPostincrementExpressions = TokenRange.FromTokens([67 /* Identifier */, 18 /* CloseParenToken */, 20 /* CloseBracketToken */, 90 /* NewKeyword */]); - TokenRange.UnaryPredecrementExpressions = TokenRange.FromTokens([67 /* Identifier */, 17 /* OpenParenToken */, 95 /* ThisKeyword */, 90 /* NewKeyword */]); - TokenRange.UnaryPostdecrementExpressions = TokenRange.FromTokens([67 /* Identifier */, 18 /* CloseParenToken */, 20 /* CloseBracketToken */, 90 /* NewKeyword */]); + TokenRange.Keywords = TokenRange.FromRange(70 /* FirstKeyword */, 134 /* LastKeyword */); + TokenRange.BinaryOperators = TokenRange.FromRange(25 /* FirstBinaryOperator */, 68 /* LastBinaryOperator */); + TokenRange.BinaryKeywordOperators = TokenRange.FromTokens([90 /* InKeyword */, 91 /* InstanceOfKeyword */, 134 /* OfKeyword */, 116 /* AsKeyword */, 124 /* IsKeyword */]); + TokenRange.UnaryPrefixOperators = TokenRange.FromTokens([41 /* PlusPlusToken */, 42 /* MinusMinusToken */, 50 /* TildeToken */, 49 /* ExclamationToken */]); + TokenRange.UnaryPrefixExpressions = TokenRange.FromTokens([8 /* NumericLiteral */, 69 /* Identifier */, 17 /* OpenParenToken */, 19 /* OpenBracketToken */, 15 /* OpenBraceToken */, 97 /* ThisKeyword */, 92 /* NewKeyword */]); + TokenRange.UnaryPreincrementExpressions = TokenRange.FromTokens([69 /* Identifier */, 17 /* OpenParenToken */, 97 /* ThisKeyword */, 92 /* NewKeyword */]); + TokenRange.UnaryPostincrementExpressions = TokenRange.FromTokens([69 /* Identifier */, 18 /* CloseParenToken */, 20 /* CloseBracketToken */, 92 /* NewKeyword */]); + TokenRange.UnaryPredecrementExpressions = TokenRange.FromTokens([69 /* Identifier */, 17 /* OpenParenToken */, 97 /* ThisKeyword */, 92 /* NewKeyword */]); + TokenRange.UnaryPostdecrementExpressions = TokenRange.FromTokens([69 /* Identifier */, 18 /* CloseParenToken */, 20 /* CloseBracketToken */, 92 /* NewKeyword */]); TokenRange.Comments = TokenRange.FromTokens([2 /* SingleLineCommentTrivia */, 3 /* MultiLineCommentTrivia */]); - TokenRange.TypeNames = TokenRange.FromTokens([67 /* Identifier */, 126 /* NumberKeyword */, 128 /* StringKeyword */, 118 /* BooleanKeyword */, 129 /* SymbolKeyword */, 101 /* VoidKeyword */, 115 /* AnyKeyword */]); + TokenRange.TypeNames = TokenRange.FromTokens([69 /* Identifier */, 128 /* NumberKeyword */, 130 /* StringKeyword */, 120 /* BooleanKeyword */, 131 /* SymbolKeyword */, 103 /* VoidKeyword */, 117 /* AnyKeyword */]); return TokenRange; })(); Shared.TokenRange = TokenRange; @@ -40773,17 +41497,17 @@ var ts; // i.e. parent is class declaration with the list of members and node is one of members. function isListElement(parent, node) { switch (parent.kind) { - case 212 /* ClassDeclaration */: - case 213 /* InterfaceDeclaration */: + case 214 /* ClassDeclaration */: + case 215 /* InterfaceDeclaration */: return ts.rangeContainsRange(parent.members, node); - case 216 /* ModuleDeclaration */: + case 218 /* ModuleDeclaration */: var body = parent.body; - return body && body.kind === 190 /* Block */ && ts.rangeContainsRange(body.statements, node); - case 246 /* SourceFile */: - case 190 /* Block */: - case 217 /* ModuleBlock */: + return body && body.kind === 192 /* Block */ && ts.rangeContainsRange(body.statements, node); + case 248 /* SourceFile */: + case 192 /* Block */: + case 219 /* ModuleBlock */: return ts.rangeContainsRange(parent.statements, node); - case 242 /* CatchClause */: + case 244 /* CatchClause */: return ts.rangeContainsRange(parent.block.statements, node); } return false; @@ -40956,9 +41680,9 @@ var ts; // - source file // - switch\default clauses if (isSomeBlock(parent.kind) || - parent.kind === 246 /* SourceFile */ || - parent.kind === 239 /* CaseClause */ || - parent.kind === 240 /* DefaultClause */) { + parent.kind === 248 /* SourceFile */ || + parent.kind === 241 /* CaseClause */ || + parent.kind === 242 /* DefaultClause */) { indentation = parentDynamicIndentation.getIndentation() + parentDynamicIndentation.getDelta(); } else { @@ -40994,19 +41718,19 @@ var ts; return node.modifiers[0].kind; } switch (node.kind) { - case 212 /* ClassDeclaration */: return 71 /* ClassKeyword */; - case 213 /* InterfaceDeclaration */: return 105 /* InterfaceKeyword */; - case 211 /* FunctionDeclaration */: return 85 /* FunctionKeyword */; - case 215 /* EnumDeclaration */: return 215 /* EnumDeclaration */; - case 143 /* GetAccessor */: return 121 /* GetKeyword */; - case 144 /* SetAccessor */: return 127 /* SetKeyword */; - case 141 /* MethodDeclaration */: + case 214 /* ClassDeclaration */: return 73 /* ClassKeyword */; + case 215 /* InterfaceDeclaration */: return 107 /* InterfaceKeyword */; + case 213 /* FunctionDeclaration */: return 87 /* FunctionKeyword */; + case 217 /* EnumDeclaration */: return 217 /* EnumDeclaration */; + case 145 /* GetAccessor */: return 123 /* GetKeyword */; + case 146 /* SetAccessor */: return 129 /* SetKeyword */; + case 143 /* MethodDeclaration */: if (node.asteriskToken) { return 37 /* AsteriskToken */; } // fall-through - case 139 /* PropertyDeclaration */: - case 136 /* Parameter */: + case 141 /* PropertyDeclaration */: + case 138 /* Parameter */: return node.name.kind; } } @@ -41040,9 +41764,9 @@ var ts; case 20 /* CloseBracketToken */: case 17 /* OpenParenToken */: case 18 /* CloseParenToken */: - case 78 /* ElseKeyword */: - case 102 /* WhileKeyword */: - case 54 /* AtToken */: + case 80 /* ElseKeyword */: + case 104 /* WhileKeyword */: + case 55 /* AtToken */: return indentation; default: // if token line equals to the line of containing node (this is a first token in the node) - use node indentation @@ -41142,7 +41866,7 @@ var ts; consumeTokenAndAdvanceScanner(tokenInfo, node, parentDynamicIndentation); return inheritedIndentation; } - var effectiveParentStartLine = child.kind === 137 /* Decorator */ ? childStartLine : undecoratedParentStartLine; + var effectiveParentStartLine = child.kind === 139 /* Decorator */ ? childStartLine : undecoratedParentStartLine; var childIndentation = computeIndentation(child, childStartLine, childIndentationAmount, node, parentDynamicIndentation, effectiveParentStartLine); processNode(child, childContextNode, childStartLine, undecoratedChildStartLine, childIndentation.indentation, childIndentation.delta); childContextNode = node; @@ -41399,8 +42123,8 @@ var ts; for (var line = line1; line < line2; ++line) { var lineStartPosition = ts.getStartPositionOfLine(line, sourceFile); var lineEndPosition = ts.getEndLinePosition(line, sourceFile); - // do not trim whitespaces in comments - if (range && ts.isComment(range.kind) && range.pos <= lineEndPosition && range.end > lineEndPosition) { + // do not trim whitespaces in comments or template expression + if (range && (ts.isComment(range.kind) || ts.isStringOrRegularExpressionOrTemplateLiteral(range.kind)) && range.pos <= lineEndPosition && range.end > lineEndPosition) { continue; } var pos = lineEndPosition; @@ -41466,20 +42190,20 @@ var ts; } function isSomeBlock(kind) { switch (kind) { - case 190 /* Block */: - case 217 /* ModuleBlock */: + case 192 /* Block */: + case 219 /* ModuleBlock */: return true; } return false; } function getOpenTokenForList(node, list) { switch (node.kind) { - case 142 /* Constructor */: - case 211 /* FunctionDeclaration */: - case 171 /* FunctionExpression */: - case 141 /* MethodDeclaration */: - case 140 /* MethodSignature */: - case 172 /* ArrowFunction */: + case 144 /* Constructor */: + case 213 /* FunctionDeclaration */: + case 173 /* FunctionExpression */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: + case 174 /* ArrowFunction */: if (node.typeParameters === list) { return 25 /* LessThanToken */; } @@ -41487,8 +42211,8 @@ var ts; return 17 /* OpenParenToken */; } break; - case 166 /* CallExpression */: - case 167 /* NewExpression */: + case 168 /* CallExpression */: + case 169 /* NewExpression */: if (node.typeArguments === list) { return 25 /* LessThanToken */; } @@ -41496,7 +42220,7 @@ var ts; return 17 /* OpenParenToken */; } break; - case 149 /* TypeReference */: + case 151 /* TypeReference */: if (node.typeArguments === list) { return 25 /* LessThanToken */; } @@ -41580,22 +42304,39 @@ var ts; if (position > sourceFile.text.length) { return 0; // past EOF } + // no indentation when the indent style is set to none, + // so we can return fast + if (options.IndentStyle === ts.IndentStyle.None) { + return 0; + } var precedingToken = ts.findPrecedingToken(position, sourceFile); if (!precedingToken) { return 0; } // no indentation in string \regex\template literals - var precedingTokenIsLiteral = precedingToken.kind === 9 /* StringLiteral */ || - precedingToken.kind === 10 /* RegularExpressionLiteral */ || - precedingToken.kind === 11 /* NoSubstitutionTemplateLiteral */ || - precedingToken.kind === 12 /* TemplateHead */ || - precedingToken.kind === 13 /* TemplateMiddle */ || - precedingToken.kind === 14 /* TemplateTail */; + var precedingTokenIsLiteral = ts.isStringOrRegularExpressionOrTemplateLiteral(precedingToken.kind); if (precedingTokenIsLiteral && precedingToken.getStart(sourceFile) <= position && precedingToken.end > position) { return 0; } var lineAtPosition = sourceFile.getLineAndCharacterOfPosition(position).line; - if (precedingToken.kind === 24 /* CommaToken */ && precedingToken.parent.kind !== 179 /* BinaryExpression */) { + // indentation is first non-whitespace character in a previous line + // for block indentation, we should look for a line which contains something that's not + // whitespace. + if (options.IndentStyle === ts.IndentStyle.Block) { + // move backwards until we find a line with a non-whitespace character, + // then find the first non-whitespace character for that line. + var current_1 = position; + while (current_1 > 0) { + var char = sourceFile.text.charCodeAt(current_1); + if (!ts.isWhiteSpace(char) && !ts.isLineBreak(char)) { + break; + } + current_1--; + } + var lineStart = ts.getLineStartPositionForPosition(current_1, sourceFile); + return SmartIndenter.findFirstNonWhitespaceColumn(lineStart, current_1, sourceFile, options); + } + if (precedingToken.kind === 24 /* CommaToken */ && precedingToken.parent.kind !== 181 /* BinaryExpression */) { // previous token is comma that separates items in list - find the previous item and try to derive indentation from it var actualIndentation = getActualIndentationForListItemBeforeComma(precedingToken, sourceFile, options); if (actualIndentation !== -1 /* Unknown */) { @@ -41714,7 +42455,7 @@ var ts; // - parent is SourceFile - by default immediate children of SourceFile are not indented except when user indents them manually // - parent and child are not on the same line var useActualIndentation = (ts.isDeclaration(current) || ts.isStatement(current)) && - (parent.kind === 246 /* SourceFile */ || !parentAndChildShareLine); + (parent.kind === 248 /* SourceFile */ || !parentAndChildShareLine); if (!useActualIndentation) { return -1 /* Unknown */; } @@ -41747,8 +42488,8 @@ var ts; return sourceFile.getLineAndCharacterOfPosition(n.getStart(sourceFile)); } function childStartsOnTheSameLineWithElseInIfStatement(parent, child, childStartLine, sourceFile) { - if (parent.kind === 194 /* IfStatement */ && parent.elseStatement === child) { - var elseKeyword = ts.findChildOfKind(parent, 78 /* ElseKeyword */, sourceFile); + if (parent.kind === 196 /* IfStatement */ && parent.elseStatement === child) { + var elseKeyword = ts.findChildOfKind(parent, 80 /* ElseKeyword */, sourceFile); ts.Debug.assert(elseKeyword !== undefined); var elseKeywordStartLine = getStartLineAndCharacterForNode(elseKeyword, sourceFile).line; return elseKeywordStartLine === childStartLine; @@ -41759,23 +42500,23 @@ var ts; function getContainingList(node, sourceFile) { if (node.parent) { switch (node.parent.kind) { - case 149 /* TypeReference */: + case 151 /* TypeReference */: if (node.parent.typeArguments && ts.rangeContainsStartEnd(node.parent.typeArguments, node.getStart(sourceFile), node.getEnd())) { return node.parent.typeArguments; } break; - case 163 /* ObjectLiteralExpression */: + case 165 /* ObjectLiteralExpression */: return node.parent.properties; - case 162 /* ArrayLiteralExpression */: + case 164 /* ArrayLiteralExpression */: return node.parent.elements; - case 211 /* FunctionDeclaration */: - case 171 /* FunctionExpression */: - case 172 /* ArrowFunction */: - case 141 /* MethodDeclaration */: - case 140 /* MethodSignature */: - case 145 /* CallSignature */: - case 146 /* ConstructSignature */: { + case 213 /* FunctionDeclaration */: + case 173 /* FunctionExpression */: + case 174 /* ArrowFunction */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: + case 147 /* CallSignature */: + case 148 /* ConstructSignature */: { var start = node.getStart(sourceFile); if (node.parent.typeParameters && ts.rangeContainsStartEnd(node.parent.typeParameters, start, node.getEnd())) { @@ -41786,8 +42527,8 @@ var ts; } break; } - case 167 /* NewExpression */: - case 166 /* CallExpression */: { + case 169 /* NewExpression */: + case 168 /* CallExpression */: { var start = node.getStart(sourceFile); if (node.parent.typeArguments && ts.rangeContainsStartEnd(node.parent.typeArguments, start, node.getEnd())) { @@ -41817,8 +42558,8 @@ var ts; if (node.kind === 18 /* CloseParenToken */) { return -1 /* Unknown */; } - if (node.parent && (node.parent.kind === 166 /* CallExpression */ || - node.parent.kind === 167 /* NewExpression */) && + if (node.parent && (node.parent.kind === 168 /* CallExpression */ || + node.parent.kind === 169 /* NewExpression */) && node.parent.expression !== node) { var fullCallOrNewExpression = node.parent.expression; var startingExpression = getStartingExpression(fullCallOrNewExpression); @@ -41836,10 +42577,10 @@ var ts; function getStartingExpression(node) { while (true) { switch (node.kind) { - case 166 /* CallExpression */: - case 167 /* NewExpression */: - case 164 /* PropertyAccessExpression */: - case 165 /* ElementAccessExpression */: + case 168 /* CallExpression */: + case 169 /* NewExpression */: + case 166 /* PropertyAccessExpression */: + case 167 /* ElementAccessExpression */: node = node.expression; break; default: @@ -41904,42 +42645,43 @@ var ts; SmartIndenter.findFirstNonWhitespaceColumn = findFirstNonWhitespaceColumn; function nodeContentIsAlwaysIndented(kind) { switch (kind) { - case 212 /* ClassDeclaration */: - case 184 /* ClassExpression */: - case 213 /* InterfaceDeclaration */: - case 215 /* EnumDeclaration */: - case 214 /* TypeAliasDeclaration */: - case 162 /* ArrayLiteralExpression */: - case 190 /* Block */: - case 217 /* ModuleBlock */: - case 163 /* ObjectLiteralExpression */: - case 153 /* TypeLiteral */: - case 155 /* TupleType */: - case 218 /* CaseBlock */: - case 240 /* DefaultClause */: - case 239 /* CaseClause */: - case 170 /* ParenthesizedExpression */: - case 164 /* PropertyAccessExpression */: - case 166 /* CallExpression */: - case 167 /* NewExpression */: - case 191 /* VariableStatement */: - case 209 /* VariableDeclaration */: - case 225 /* ExportAssignment */: - case 202 /* ReturnStatement */: - case 180 /* ConditionalExpression */: - case 160 /* ArrayBindingPattern */: - case 159 /* ObjectBindingPattern */: - case 231 /* JsxElement */: - case 232 /* JsxSelfClosingElement */: - case 140 /* MethodSignature */: - case 145 /* CallSignature */: - case 146 /* ConstructSignature */: - case 136 /* Parameter */: - case 150 /* FunctionType */: - case 151 /* ConstructorType */: - case 158 /* ParenthesizedType */: - case 168 /* TaggedTemplateExpression */: - case 176 /* AwaitExpression */: + case 195 /* ExpressionStatement */: + case 214 /* ClassDeclaration */: + case 186 /* ClassExpression */: + case 215 /* InterfaceDeclaration */: + case 217 /* EnumDeclaration */: + case 216 /* TypeAliasDeclaration */: + case 164 /* ArrayLiteralExpression */: + case 192 /* Block */: + case 219 /* ModuleBlock */: + case 165 /* ObjectLiteralExpression */: + case 155 /* TypeLiteral */: + case 157 /* TupleType */: + case 220 /* CaseBlock */: + case 242 /* DefaultClause */: + case 241 /* CaseClause */: + case 172 /* ParenthesizedExpression */: + case 166 /* PropertyAccessExpression */: + case 168 /* CallExpression */: + case 169 /* NewExpression */: + case 193 /* VariableStatement */: + case 211 /* VariableDeclaration */: + case 227 /* ExportAssignment */: + case 204 /* ReturnStatement */: + case 182 /* ConditionalExpression */: + case 162 /* ArrayBindingPattern */: + case 161 /* ObjectBindingPattern */: + case 233 /* JsxElement */: + case 234 /* JsxSelfClosingElement */: + case 142 /* MethodSignature */: + case 147 /* CallSignature */: + case 148 /* ConstructSignature */: + case 138 /* Parameter */: + case 152 /* FunctionType */: + case 153 /* ConstructorType */: + case 160 /* ParenthesizedType */: + case 170 /* TaggedTemplateExpression */: + case 178 /* AwaitExpression */: return true; } return false; @@ -41949,20 +42691,20 @@ var ts; return true; } switch (parent) { - case 195 /* DoStatement */: - case 196 /* WhileStatement */: - case 198 /* ForInStatement */: - case 199 /* ForOfStatement */: - case 197 /* ForStatement */: - case 194 /* IfStatement */: - case 211 /* FunctionDeclaration */: - case 171 /* FunctionExpression */: - case 141 /* MethodDeclaration */: - case 172 /* ArrowFunction */: - case 142 /* Constructor */: - case 143 /* GetAccessor */: - case 144 /* SetAccessor */: - return child !== 190 /* Block */; + case 197 /* DoStatement */: + case 198 /* WhileStatement */: + case 200 /* ForInStatement */: + case 201 /* ForOfStatement */: + case 199 /* ForStatement */: + case 196 /* IfStatement */: + case 213 /* FunctionDeclaration */: + case 173 /* FunctionExpression */: + case 143 /* MethodDeclaration */: + case 174 /* ArrowFunction */: + case 144 /* Constructor */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: + return child !== 192 /* Block */; default: return false; } @@ -42104,7 +42846,7 @@ var ts; return pos; }; NodeObject.prototype.createSyntaxList = function (nodes) { - var list = createNode(269 /* SyntaxList */, nodes.pos, nodes.end, 4096 /* Synthetic */, this); + var list = createNode(271 /* SyntaxList */, nodes.pos, nodes.end, 4096 /* Synthetic */, this); list._children = []; var pos = nodes.pos; for (var _i = 0; _i < nodes.length; _i++) { @@ -42123,7 +42865,7 @@ var ts; NodeObject.prototype.createChildren = function (sourceFile) { var _this = this; var children; - if (this.kind >= 133 /* FirstNode */) { + if (this.kind >= 135 /* FirstNode */) { scanner.setText((sourceFile || this.getSourceFile()).text); children = []; var pos = this.pos; @@ -42170,7 +42912,7 @@ var ts; return undefined; } var child = children[0]; - return child.kind < 133 /* FirstNode */ ? child : child.getFirstToken(sourceFile); + return child.kind < 135 /* FirstNode */ ? child : child.getFirstToken(sourceFile); }; NodeObject.prototype.getLastToken = function (sourceFile) { var children = this.getChildren(sourceFile); @@ -42178,7 +42920,7 @@ var ts; if (!child) { return undefined; } - return child.kind < 133 /* FirstNode */ ? child : child.getLastToken(sourceFile); + return child.kind < 135 /* FirstNode */ ? child : child.getLastToken(sourceFile); }; return NodeObject; })(); @@ -42227,7 +42969,7 @@ var ts; if (ts.indexOf(declarations, declaration) === indexOfDeclaration) { var sourceFileOfDeclaration = ts.getSourceFileOfNode(declaration); // If it is parameter - try and get the jsDoc comment with @param tag from function declaration's jsDoc comments - if (canUseParsedParamTagComments && declaration.kind === 136 /* Parameter */) { + if (canUseParsedParamTagComments && declaration.kind === 138 /* Parameter */) { ts.forEach(getJsDocCommentTextRange(declaration.parent, sourceFileOfDeclaration), function (jsDocCommentTextRange) { var cleanedParamJsDocComment = getCleanedParamJsDocComment(jsDocCommentTextRange.pos, jsDocCommentTextRange.end, sourceFileOfDeclaration); if (cleanedParamJsDocComment) { @@ -42236,15 +42978,15 @@ var ts; }); } // If this is left side of dotted module declaration, there is no doc comments associated with this node - if (declaration.kind === 216 /* ModuleDeclaration */ && declaration.body.kind === 216 /* ModuleDeclaration */) { + if (declaration.kind === 218 /* ModuleDeclaration */ && declaration.body.kind === 218 /* ModuleDeclaration */) { return; } // If this is dotted module name, get the doc comments from the parent - while (declaration.kind === 216 /* ModuleDeclaration */ && declaration.parent.kind === 216 /* ModuleDeclaration */) { + while (declaration.kind === 218 /* ModuleDeclaration */ && declaration.parent.kind === 218 /* ModuleDeclaration */) { declaration = declaration.parent; } // Get the cleaned js doc comment text from the declaration - ts.forEach(getJsDocCommentTextRange(declaration.kind === 209 /* VariableDeclaration */ ? declaration.parent.parent : declaration, sourceFileOfDeclaration), function (jsDocCommentTextRange) { + ts.forEach(getJsDocCommentTextRange(declaration.kind === 211 /* VariableDeclaration */ ? declaration.parent.parent : declaration, sourceFileOfDeclaration), function (jsDocCommentTextRange) { var cleanedJsDocComment = getCleanedJsDocComment(jsDocCommentTextRange.pos, jsDocCommentTextRange.end, sourceFileOfDeclaration); if (cleanedJsDocComment) { ts.addRange(jsDocCommentParts, cleanedJsDocComment); @@ -42588,9 +43330,9 @@ var ts; if (result_2 !== undefined) { return result_2; } - if (declaration.name.kind === 134 /* ComputedPropertyName */) { + if (declaration.name.kind === 136 /* ComputedPropertyName */) { var expr = declaration.name.expression; - if (expr.kind === 164 /* PropertyAccessExpression */) { + if (expr.kind === 166 /* PropertyAccessExpression */) { return expr.name.text; } return getTextOfIdentifierOrLiteral(expr); @@ -42600,7 +43342,7 @@ var ts; } function getTextOfIdentifierOrLiteral(node) { if (node) { - if (node.kind === 67 /* Identifier */ || + if (node.kind === 69 /* Identifier */ || node.kind === 9 /* StringLiteral */ || node.kind === 8 /* NumericLiteral */) { return node.text; @@ -42610,9 +43352,9 @@ var ts; } function visit(node) { switch (node.kind) { - case 211 /* FunctionDeclaration */: - case 141 /* MethodDeclaration */: - case 140 /* MethodSignature */: + case 213 /* FunctionDeclaration */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: var functionDeclaration = node; var declarationName = getDeclarationName(functionDeclaration); if (declarationName) { @@ -42632,60 +43374,60 @@ var ts; ts.forEachChild(node, visit); } break; - case 212 /* ClassDeclaration */: - case 213 /* InterfaceDeclaration */: - case 214 /* TypeAliasDeclaration */: - case 215 /* EnumDeclaration */: - case 216 /* ModuleDeclaration */: - case 219 /* ImportEqualsDeclaration */: - case 228 /* ExportSpecifier */: - case 224 /* ImportSpecifier */: - case 219 /* ImportEqualsDeclaration */: - case 221 /* ImportClause */: - case 222 /* NamespaceImport */: - case 143 /* GetAccessor */: - case 144 /* SetAccessor */: - case 153 /* TypeLiteral */: + case 214 /* ClassDeclaration */: + case 215 /* InterfaceDeclaration */: + case 216 /* TypeAliasDeclaration */: + case 217 /* EnumDeclaration */: + case 218 /* ModuleDeclaration */: + case 221 /* ImportEqualsDeclaration */: + case 230 /* ExportSpecifier */: + case 226 /* ImportSpecifier */: + case 221 /* ImportEqualsDeclaration */: + case 223 /* ImportClause */: + case 224 /* NamespaceImport */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: + case 155 /* TypeLiteral */: addDeclaration(node); // fall through - case 142 /* Constructor */: - case 191 /* VariableStatement */: - case 210 /* VariableDeclarationList */: - case 159 /* ObjectBindingPattern */: - case 160 /* ArrayBindingPattern */: - case 217 /* ModuleBlock */: + case 144 /* Constructor */: + case 193 /* VariableStatement */: + case 212 /* VariableDeclarationList */: + case 161 /* ObjectBindingPattern */: + case 162 /* ArrayBindingPattern */: + case 219 /* ModuleBlock */: ts.forEachChild(node, visit); break; - case 190 /* Block */: + case 192 /* Block */: if (ts.isFunctionBlock(node)) { ts.forEachChild(node, visit); } break; - case 136 /* Parameter */: + case 138 /* Parameter */: // Only consider properties defined as constructor parameters if (!(node.flags & 112 /* AccessibilityModifier */)) { break; } // fall through - case 209 /* VariableDeclaration */: - case 161 /* BindingElement */: + case 211 /* VariableDeclaration */: + case 163 /* BindingElement */: if (ts.isBindingPattern(node.name)) { ts.forEachChild(node.name, visit); break; } - case 245 /* EnumMember */: - case 139 /* PropertyDeclaration */: - case 138 /* PropertySignature */: + case 247 /* EnumMember */: + case 141 /* PropertyDeclaration */: + case 140 /* PropertySignature */: addDeclaration(node); break; - case 226 /* ExportDeclaration */: + case 228 /* ExportDeclaration */: // Handle named exports case e.g.: // export {a, b as B} from "mod"; if (node.exportClause) { ts.forEach(node.exportClause.elements, visit); } break; - case 220 /* ImportDeclaration */: + case 222 /* ImportDeclaration */: var importClause = node.importClause; if (importClause) { // Handle default import case e.g.: @@ -42697,7 +43439,7 @@ var ts; // import * as NS from "mod"; // import {a, b as B} from "mod"; if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 222 /* NamespaceImport */) { + if (importClause.namedBindings.kind === 224 /* NamespaceImport */) { addDeclaration(importClause.namedBindings); } else { @@ -42724,6 +43466,12 @@ var ts; HighlightSpanKind.reference = "reference"; HighlightSpanKind.writtenReference = "writtenReference"; })(HighlightSpanKind = ts.HighlightSpanKind || (ts.HighlightSpanKind = {})); + (function (IndentStyle) { + IndentStyle[IndentStyle["None"] = 0] = "None"; + IndentStyle[IndentStyle["Block"] = 1] = "Block"; + IndentStyle[IndentStyle["Smart"] = 2] = "Smart"; + })(ts.IndentStyle || (ts.IndentStyle = {})); + var IndentStyle = ts.IndentStyle; (function (SymbolDisplayPartKind) { SymbolDisplayPartKind[SymbolDisplayPartKind["aliasName"] = 0] = "aliasName"; SymbolDisplayPartKind[SymbolDisplayPartKind["className"] = 1] = "className"; @@ -42901,16 +43649,16 @@ var ts; } return ts.forEach(symbol.declarations, function (declaration) { // Function expressions are local - if (declaration.kind === 171 /* FunctionExpression */) { + if (declaration.kind === 173 /* FunctionExpression */) { return true; } - if (declaration.kind !== 209 /* VariableDeclaration */ && declaration.kind !== 211 /* FunctionDeclaration */) { + if (declaration.kind !== 211 /* VariableDeclaration */ && declaration.kind !== 213 /* FunctionDeclaration */) { return false; } // If the parent is not sourceFile or module block it is local variable for (var parent_8 = declaration.parent; !ts.isFunctionBlock(parent_8); parent_8 = parent_8.parent) { // Reached source file or module block - if (parent_8.kind === 246 /* SourceFile */ || parent_8.kind === 217 /* ModuleBlock */) { + if (parent_8.kind === 248 /* SourceFile */ || parent_8.kind === 219 /* ModuleBlock */) { return false; } } @@ -43047,8 +43795,8 @@ var ts; // We are not doing a full typecheck, we are not resolving the whole context, // so pass --noResolve to avoid reporting missing file errors. options.noResolve = true; - // Parse - var inputFileName = transpileOptions.fileName || "module.ts"; + // if jsx is specified then treat file as .tsx + var inputFileName = transpileOptions.fileName || (options.jsx ? "module.tsx" : "module.ts"); var sourceFile = ts.createSourceFile(inputFileName, input, options.target); if (transpileOptions.moduleName) { sourceFile.moduleName = transpileOptions.moduleName; @@ -43260,8 +44008,9 @@ var ts; }; } ts.createDocumentRegistry = createDocumentRegistry; - function preProcessFile(sourceText, readImportFiles) { + function preProcessFile(sourceText, readImportFiles, detectJavaScriptImports) { if (readImportFiles === void 0) { readImportFiles = true; } + if (detectJavaScriptImports === void 0) { detectJavaScriptImports = false; } var referencedFiles = []; var importedFiles = []; var ambientExternalModules; @@ -43295,9 +44044,207 @@ var ts; end: pos + importPath.length }); } - function processImport() { + /** + * Returns true if at least one token was consumed from the stream + */ + function tryConsumeDeclare() { + var token = scanner.getToken(); + if (token === 122 /* DeclareKeyword */) { + // declare module "mod" + token = scanner.scan(); + if (token === 125 /* ModuleKeyword */) { + token = scanner.scan(); + if (token === 9 /* StringLiteral */) { + recordAmbientExternalModule(); + } + } + return true; + } + return false; + } + /** + * Returns true if at least one token was consumed from the stream + */ + function tryConsumeImport() { + var token = scanner.getToken(); + if (token === 89 /* ImportKeyword */) { + token = scanner.scan(); + if (token === 9 /* StringLiteral */) { + // import "mod"; + recordModuleName(); + return true; + } + else { + if (token === 69 /* Identifier */ || ts.isKeyword(token)) { + token = scanner.scan(); + if (token === 133 /* FromKeyword */) { + token = scanner.scan(); + if (token === 9 /* StringLiteral */) { + // import d from "mod"; + recordModuleName(); + return true; + } + } + else if (token === 56 /* EqualsToken */) { + if (tryConsumeRequireCall(/* skipCurrentToken */ true)) { + return true; + } + } + else if (token === 24 /* CommaToken */) { + // consume comma and keep going + token = scanner.scan(); + } + else { + // unknown syntax + return true; + } + } + if (token === 15 /* OpenBraceToken */) { + token = scanner.scan(); + // consume "{ a as B, c, d as D}" clauses + // make sure that it stops on EOF + while (token !== 16 /* CloseBraceToken */ && token !== 1 /* EndOfFileToken */) { + token = scanner.scan(); + } + if (token === 16 /* CloseBraceToken */) { + token = scanner.scan(); + if (token === 133 /* FromKeyword */) { + token = scanner.scan(); + if (token === 9 /* StringLiteral */) { + // import {a as A} from "mod"; + // import d, {a, b as B} from "mod" + recordModuleName(); + } + } + } + } + else if (token === 37 /* AsteriskToken */) { + token = scanner.scan(); + if (token === 116 /* AsKeyword */) { + token = scanner.scan(); + if (token === 69 /* Identifier */ || ts.isKeyword(token)) { + token = scanner.scan(); + if (token === 133 /* FromKeyword */) { + token = scanner.scan(); + if (token === 9 /* StringLiteral */) { + // import * as NS from "mod" + // import d, * as NS from "mod" + recordModuleName(); + } + } + } + } + } + } + return true; + } + return false; + } + function tryConsumeExport() { + var token = scanner.getToken(); + if (token === 82 /* ExportKeyword */) { + token = scanner.scan(); + if (token === 15 /* OpenBraceToken */) { + token = scanner.scan(); + // consume "{ a as B, c, d as D}" clauses + // make sure it stops on EOF + while (token !== 16 /* CloseBraceToken */ && token !== 1 /* EndOfFileToken */) { + token = scanner.scan(); + } + if (token === 16 /* CloseBraceToken */) { + token = scanner.scan(); + if (token === 133 /* FromKeyword */) { + token = scanner.scan(); + if (token === 9 /* StringLiteral */) { + // export {a as A} from "mod"; + // export {a, b as B} from "mod" + recordModuleName(); + } + } + } + } + else if (token === 37 /* AsteriskToken */) { + token = scanner.scan(); + if (token === 133 /* FromKeyword */) { + token = scanner.scan(); + if (token === 9 /* StringLiteral */) { + // export * from "mod" + recordModuleName(); + } + } + } + else if (token === 89 /* ImportKeyword */) { + token = scanner.scan(); + if (token === 69 /* Identifier */ || ts.isKeyword(token)) { + token = scanner.scan(); + if (token === 56 /* EqualsToken */) { + if (tryConsumeRequireCall(/* skipCurrentToken */ true)) { + return true; + } + } + } + } + return true; + } + return false; + } + function tryConsumeRequireCall(skipCurrentToken) { + var token = skipCurrentToken ? scanner.scan() : scanner.getToken(); + if (token === 127 /* RequireKeyword */) { + token = scanner.scan(); + if (token === 17 /* OpenParenToken */) { + token = scanner.scan(); + if (token === 9 /* StringLiteral */) { + // require("mod"); + recordModuleName(); + } + } + return true; + } + return false; + } + function tryConsumeDefine() { + var token = scanner.getToken(); + if (token === 69 /* Identifier */ && scanner.getTokenValue() === "define") { + token = scanner.scan(); + if (token !== 17 /* OpenParenToken */) { + return true; + } + token = scanner.scan(); + if (token === 9 /* StringLiteral */) { + // looks like define ("modname", ... - skip string literal and comma + token = scanner.scan(); + if (token === 24 /* CommaToken */) { + token = scanner.scan(); + } + else { + // unexpected token + return true; + } + } + // should be start of dependency list + if (token !== 19 /* OpenBracketToken */) { + return true; + } + // skip open bracket + token = scanner.scan(); + var i = 0; + // scan until ']' or EOF + while (token !== 20 /* CloseBracketToken */ && token !== 1 /* EndOfFileToken */) { + // record string literals as module names + if (token === 9 /* StringLiteral */) { + recordModuleName(); + i++; + } + token = scanner.scan(); + } + return true; + } + return false; + } + function processImports() { scanner.setText(sourceText); - var token = scanner.scan(); + scanner.scan(); // Look for: // import "mod"; // import d from "mod" @@ -43309,152 +44256,26 @@ var ts; // export * from "mod" // export {a as b} from "mod" // export import i = require("mod") - while (token !== 1 /* EndOfFileToken */) { - if (token === 120 /* DeclareKeyword */) { - // declare module "mod" - token = scanner.scan(); - if (token === 123 /* ModuleKeyword */) { - token = scanner.scan(); - if (token === 9 /* StringLiteral */) { - recordAmbientExternalModule(); - continue; - } - } + // (for JavaScript files) require("mod") + while (true) { + if (scanner.getToken() === 1 /* EndOfFileToken */) { + break; } - else if (token === 87 /* ImportKeyword */) { - token = scanner.scan(); - if (token === 9 /* StringLiteral */) { - // import "mod"; - recordModuleName(); - continue; - } - else { - if (token === 67 /* Identifier */ || ts.isKeyword(token)) { - token = scanner.scan(); - if (token === 131 /* FromKeyword */) { - token = scanner.scan(); - if (token === 9 /* StringLiteral */) { - // import d from "mod"; - recordModuleName(); - continue; - } - } - else if (token === 55 /* EqualsToken */) { - token = scanner.scan(); - if (token === 125 /* RequireKeyword */) { - token = scanner.scan(); - if (token === 17 /* OpenParenToken */) { - token = scanner.scan(); - if (token === 9 /* StringLiteral */) { - // import i = require("mod"); - recordModuleName(); - continue; - } - } - } - } - else if (token === 24 /* CommaToken */) { - // consume comma and keep going - token = scanner.scan(); - } - else { - // unknown syntax - continue; - } - } - if (token === 15 /* OpenBraceToken */) { - token = scanner.scan(); - // consume "{ a as B, c, d as D}" clauses - while (token !== 16 /* CloseBraceToken */) { - token = scanner.scan(); - } - if (token === 16 /* CloseBraceToken */) { - token = scanner.scan(); - if (token === 131 /* FromKeyword */) { - token = scanner.scan(); - if (token === 9 /* StringLiteral */) { - // import {a as A} from "mod"; - // import d, {a, b as B} from "mod" - recordModuleName(); - } - } - } - } - else if (token === 37 /* AsteriskToken */) { - token = scanner.scan(); - if (token === 114 /* AsKeyword */) { - token = scanner.scan(); - if (token === 67 /* Identifier */ || ts.isKeyword(token)) { - token = scanner.scan(); - if (token === 131 /* FromKeyword */) { - token = scanner.scan(); - if (token === 9 /* StringLiteral */) { - // import * as NS from "mod" - // import d, * as NS from "mod" - recordModuleName(); - } - } - } - } - } - } + // check if at least one of alternative have moved scanner forward + if (tryConsumeDeclare() || + tryConsumeImport() || + tryConsumeExport() || + (detectJavaScriptImports && (tryConsumeRequireCall(/* skipCurrentToken */ false) || tryConsumeDefine()))) { + continue; } - else if (token === 80 /* ExportKeyword */) { - token = scanner.scan(); - if (token === 15 /* OpenBraceToken */) { - token = scanner.scan(); - // consume "{ a as B, c, d as D}" clauses - while (token !== 16 /* CloseBraceToken */) { - token = scanner.scan(); - } - if (token === 16 /* CloseBraceToken */) { - token = scanner.scan(); - if (token === 131 /* FromKeyword */) { - token = scanner.scan(); - if (token === 9 /* StringLiteral */) { - // export {a as A} from "mod"; - // export {a, b as B} from "mod" - recordModuleName(); - } - } - } - } - else if (token === 37 /* AsteriskToken */) { - token = scanner.scan(); - if (token === 131 /* FromKeyword */) { - token = scanner.scan(); - if (token === 9 /* StringLiteral */) { - // export * from "mod" - recordModuleName(); - } - } - } - else if (token === 87 /* ImportKeyword */) { - token = scanner.scan(); - if (token === 67 /* Identifier */ || ts.isKeyword(token)) { - token = scanner.scan(); - if (token === 55 /* EqualsToken */) { - token = scanner.scan(); - if (token === 125 /* RequireKeyword */) { - token = scanner.scan(); - if (token === 17 /* OpenParenToken */) { - token = scanner.scan(); - if (token === 9 /* StringLiteral */) { - // export import i = require("mod"); - recordModuleName(); - } - } - } - } - } - } + else { + scanner.scan(); } - token = scanner.scan(); } scanner.setText(undefined); } if (readImportFiles) { - processImport(); + processImports(); } processTripleSlashDirectives(); return { referencedFiles: referencedFiles, importedFiles: importedFiles, isLibFile: isNoDefaultLib, ambientExternalModules: ambientExternalModules }; @@ -43463,7 +44284,7 @@ var ts; /// Helpers function getTargetLabel(referenceNode, labelName) { while (referenceNode) { - if (referenceNode.kind === 205 /* LabeledStatement */ && referenceNode.label.text === labelName) { + if (referenceNode.kind === 207 /* LabeledStatement */ && referenceNode.label.text === labelName) { return referenceNode.label; } referenceNode = referenceNode.parent; @@ -43471,13 +44292,13 @@ var ts; return undefined; } function isJumpStatementTarget(node) { - return node.kind === 67 /* Identifier */ && - (node.parent.kind === 201 /* BreakStatement */ || node.parent.kind === 200 /* ContinueStatement */) && + return node.kind === 69 /* Identifier */ && + (node.parent.kind === 203 /* BreakStatement */ || node.parent.kind === 202 /* ContinueStatement */) && node.parent.label === node; } function isLabelOfLabeledStatement(node) { - return node.kind === 67 /* Identifier */ && - node.parent.kind === 205 /* LabeledStatement */ && + return node.kind === 69 /* Identifier */ && + node.parent.kind === 207 /* LabeledStatement */ && node.parent.label === node; } /** @@ -43485,7 +44306,7 @@ var ts; * Note: 'node' cannot be a SourceFile. */ function isLabeledBy(node, labelName) { - for (var owner = node.parent; owner.kind === 205 /* LabeledStatement */; owner = owner.parent) { + for (var owner = node.parent; owner.kind === 207 /* LabeledStatement */; owner = owner.parent) { if (owner.label.text === labelName) { return true; } @@ -43496,49 +44317,49 @@ var ts; return isLabelOfLabeledStatement(node) || isJumpStatementTarget(node); } function isRightSideOfQualifiedName(node) { - return node.parent.kind === 133 /* QualifiedName */ && node.parent.right === node; + return node.parent.kind === 135 /* QualifiedName */ && node.parent.right === node; } function isRightSideOfPropertyAccess(node) { - return node && node.parent && node.parent.kind === 164 /* PropertyAccessExpression */ && node.parent.name === node; + return node && node.parent && node.parent.kind === 166 /* PropertyAccessExpression */ && node.parent.name === node; } function isCallExpressionTarget(node) { if (isRightSideOfPropertyAccess(node)) { node = node.parent; } - return node && node.parent && node.parent.kind === 166 /* CallExpression */ && node.parent.expression === node; + return node && node.parent && node.parent.kind === 168 /* CallExpression */ && node.parent.expression === node; } function isNewExpressionTarget(node) { if (isRightSideOfPropertyAccess(node)) { node = node.parent; } - return node && node.parent && node.parent.kind === 167 /* NewExpression */ && node.parent.expression === node; + return node && node.parent && node.parent.kind === 169 /* NewExpression */ && node.parent.expression === node; } function isNameOfModuleDeclaration(node) { - return node.parent.kind === 216 /* ModuleDeclaration */ && node.parent.name === node; + return node.parent.kind === 218 /* ModuleDeclaration */ && node.parent.name === node; } function isNameOfFunctionDeclaration(node) { - return node.kind === 67 /* Identifier */ && + return node.kind === 69 /* Identifier */ && ts.isFunctionLike(node.parent) && node.parent.name === node; } /** Returns true if node is a name of an object literal property, e.g. "a" in x = { "a": 1 } */ function isNameOfPropertyAssignment(node) { - return (node.kind === 67 /* Identifier */ || node.kind === 9 /* StringLiteral */ || node.kind === 8 /* NumericLiteral */) && - (node.parent.kind === 243 /* PropertyAssignment */ || node.parent.kind === 244 /* ShorthandPropertyAssignment */) && node.parent.name === node; + return (node.kind === 69 /* Identifier */ || node.kind === 9 /* StringLiteral */ || node.kind === 8 /* NumericLiteral */) && + (node.parent.kind === 245 /* PropertyAssignment */ || node.parent.kind === 246 /* ShorthandPropertyAssignment */) && node.parent.name === node; } function isLiteralNameOfPropertyDeclarationOrIndexAccess(node) { if (node.kind === 9 /* StringLiteral */ || node.kind === 8 /* NumericLiteral */) { switch (node.parent.kind) { - case 139 /* PropertyDeclaration */: - case 138 /* PropertySignature */: - case 243 /* PropertyAssignment */: - case 245 /* EnumMember */: - case 141 /* MethodDeclaration */: - case 140 /* MethodSignature */: - case 143 /* GetAccessor */: - case 144 /* SetAccessor */: - case 216 /* ModuleDeclaration */: + case 141 /* PropertyDeclaration */: + case 140 /* PropertySignature */: + case 245 /* PropertyAssignment */: + case 247 /* EnumMember */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: + case 218 /* ModuleDeclaration */: return node.parent.name === node; - case 165 /* ElementAccessExpression */: + case 167 /* ElementAccessExpression */: return node.parent.argumentExpression === node; } } @@ -43597,7 +44418,7 @@ var ts; })(BreakContinueSearchType || (BreakContinueSearchType = {})); // A cache of completion entries for keywords, these do not change between sessions var keywordCompletions = []; - for (var i = 68 /* FirstKeyword */; i <= 132 /* LastKeyword */; i++) { + for (var i = 70 /* FirstKeyword */; i <= 134 /* LastKeyword */; i++) { keywordCompletions.push({ name: ts.tokenToString(i), kind: ScriptElementKind.keyword, @@ -43612,17 +44433,17 @@ var ts; return undefined; } switch (node.kind) { - case 246 /* SourceFile */: - case 141 /* MethodDeclaration */: - case 140 /* MethodSignature */: - case 211 /* FunctionDeclaration */: - case 171 /* FunctionExpression */: - case 143 /* GetAccessor */: - case 144 /* SetAccessor */: - case 212 /* ClassDeclaration */: - case 213 /* InterfaceDeclaration */: - case 215 /* EnumDeclaration */: - case 216 /* ModuleDeclaration */: + case 248 /* SourceFile */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: + case 213 /* FunctionDeclaration */: + case 173 /* FunctionExpression */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: + case 214 /* ClassDeclaration */: + case 215 /* InterfaceDeclaration */: + case 217 /* EnumDeclaration */: + case 218 /* ModuleDeclaration */: return node; } } @@ -43630,38 +44451,38 @@ var ts; ts.getContainerNode = getContainerNode; /* @internal */ function getNodeKind(node) { switch (node.kind) { - case 216 /* ModuleDeclaration */: return ScriptElementKind.moduleElement; - case 212 /* ClassDeclaration */: return ScriptElementKind.classElement; - case 213 /* InterfaceDeclaration */: return ScriptElementKind.interfaceElement; - case 214 /* TypeAliasDeclaration */: return ScriptElementKind.typeElement; - case 215 /* EnumDeclaration */: return ScriptElementKind.enumElement; - case 209 /* VariableDeclaration */: + case 218 /* ModuleDeclaration */: return ScriptElementKind.moduleElement; + case 214 /* ClassDeclaration */: return ScriptElementKind.classElement; + case 215 /* InterfaceDeclaration */: return ScriptElementKind.interfaceElement; + case 216 /* TypeAliasDeclaration */: return ScriptElementKind.typeElement; + case 217 /* EnumDeclaration */: return ScriptElementKind.enumElement; + case 211 /* VariableDeclaration */: return ts.isConst(node) ? ScriptElementKind.constElement : ts.isLet(node) ? ScriptElementKind.letElement : ScriptElementKind.variableElement; - case 211 /* FunctionDeclaration */: return ScriptElementKind.functionElement; - case 143 /* GetAccessor */: return ScriptElementKind.memberGetAccessorElement; - case 144 /* SetAccessor */: return ScriptElementKind.memberSetAccessorElement; - case 141 /* MethodDeclaration */: - case 140 /* MethodSignature */: + case 213 /* FunctionDeclaration */: return ScriptElementKind.functionElement; + case 145 /* GetAccessor */: return ScriptElementKind.memberGetAccessorElement; + case 146 /* SetAccessor */: return ScriptElementKind.memberSetAccessorElement; + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: return ScriptElementKind.memberFunctionElement; - case 139 /* PropertyDeclaration */: - case 138 /* PropertySignature */: + case 141 /* PropertyDeclaration */: + case 140 /* PropertySignature */: return ScriptElementKind.memberVariableElement; - case 147 /* IndexSignature */: return ScriptElementKind.indexSignatureElement; - case 146 /* ConstructSignature */: return ScriptElementKind.constructSignatureElement; - case 145 /* CallSignature */: return ScriptElementKind.callSignatureElement; - case 142 /* Constructor */: return ScriptElementKind.constructorImplementationElement; - case 135 /* TypeParameter */: return ScriptElementKind.typeParameterElement; - case 245 /* EnumMember */: return ScriptElementKind.variableElement; - case 136 /* Parameter */: return (node.flags & 112 /* AccessibilityModifier */) ? ScriptElementKind.memberVariableElement : ScriptElementKind.parameterElement; - case 219 /* ImportEqualsDeclaration */: - case 224 /* ImportSpecifier */: - case 221 /* ImportClause */: - case 228 /* ExportSpecifier */: - case 222 /* NamespaceImport */: + case 149 /* IndexSignature */: return ScriptElementKind.indexSignatureElement; + case 148 /* ConstructSignature */: return ScriptElementKind.constructSignatureElement; + case 147 /* CallSignature */: return ScriptElementKind.callSignatureElement; + case 144 /* Constructor */: return ScriptElementKind.constructorImplementationElement; + case 137 /* TypeParameter */: return ScriptElementKind.typeParameterElement; + case 247 /* EnumMember */: return ScriptElementKind.variableElement; + case 138 /* Parameter */: return (node.flags & 112 /* AccessibilityModifier */) ? ScriptElementKind.memberVariableElement : ScriptElementKind.parameterElement; + case 221 /* ImportEqualsDeclaration */: + case 226 /* ImportSpecifier */: + case 223 /* ImportClause */: + case 230 /* ExportSpecifier */: + case 224 /* NamespaceImport */: return ScriptElementKind.alias; } return ScriptElementKind.unknown; @@ -43885,7 +44706,7 @@ var ts; // For JavaScript files, we don't want to report the normal typescript semantic errors. // Instead, we just report errors for using TypeScript-only constructs from within a // JavaScript file. - if (ts.isJavaScript(fileName)) { + if (ts.isSourceFileJavaScript(targetSourceFile)) { return getJavaScriptSemanticDiagnostics(targetSourceFile); } // Only perform the action per file regardless of '-out' flag as LanguageServiceHost is expected to call this function per file. @@ -43907,44 +44728,44 @@ var ts; return false; } switch (node.kind) { - case 219 /* ImportEqualsDeclaration */: + case 221 /* ImportEqualsDeclaration */: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.import_can_only_be_used_in_a_ts_file)); return true; - case 225 /* ExportAssignment */: + case 227 /* ExportAssignment */: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.export_can_only_be_used_in_a_ts_file)); return true; - case 212 /* ClassDeclaration */: + case 214 /* ClassDeclaration */: var classDeclaration = node; if (checkModifiers(classDeclaration.modifiers) || checkTypeParameters(classDeclaration.typeParameters)) { return true; } break; - case 241 /* HeritageClause */: + case 243 /* HeritageClause */: var heritageClause = node; - if (heritageClause.token === 104 /* ImplementsKeyword */) { + if (heritageClause.token === 106 /* ImplementsKeyword */) { diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.implements_clauses_can_only_be_used_in_a_ts_file)); return true; } break; - case 213 /* InterfaceDeclaration */: + case 215 /* InterfaceDeclaration */: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.interface_declarations_can_only_be_used_in_a_ts_file)); return true; - case 216 /* ModuleDeclaration */: + case 218 /* ModuleDeclaration */: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.module_declarations_can_only_be_used_in_a_ts_file)); return true; - case 214 /* TypeAliasDeclaration */: + case 216 /* TypeAliasDeclaration */: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.type_aliases_can_only_be_used_in_a_ts_file)); return true; - case 141 /* MethodDeclaration */: - case 140 /* MethodSignature */: - case 142 /* Constructor */: - case 143 /* GetAccessor */: - case 144 /* SetAccessor */: - case 171 /* FunctionExpression */: - case 211 /* FunctionDeclaration */: - case 172 /* ArrowFunction */: - case 211 /* FunctionDeclaration */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: + case 144 /* Constructor */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: + case 173 /* FunctionExpression */: + case 213 /* FunctionDeclaration */: + case 174 /* ArrowFunction */: + case 213 /* FunctionDeclaration */: var functionDeclaration = node; if (checkModifiers(functionDeclaration.modifiers) || checkTypeParameters(functionDeclaration.typeParameters) || @@ -43952,20 +44773,20 @@ var ts; return true; } break; - case 191 /* VariableStatement */: + case 193 /* VariableStatement */: var variableStatement = node; if (checkModifiers(variableStatement.modifiers)) { return true; } break; - case 209 /* VariableDeclaration */: + case 211 /* VariableDeclaration */: var variableDeclaration = node; if (checkTypeAnnotation(variableDeclaration.type)) { return true; } break; - case 166 /* CallExpression */: - case 167 /* NewExpression */: + case 168 /* CallExpression */: + case 169 /* NewExpression */: var expression = node; if (expression.typeArguments && expression.typeArguments.length > 0) { var start = expression.typeArguments.pos; @@ -43973,7 +44794,7 @@ var ts; return true; } break; - case 136 /* Parameter */: + case 138 /* Parameter */: var parameter = node; if (parameter.modifiers) { var start = parameter.modifiers.pos; @@ -43989,17 +44810,17 @@ var ts; return true; } break; - case 139 /* PropertyDeclaration */: + case 141 /* PropertyDeclaration */: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.property_declarations_can_only_be_used_in_a_ts_file)); return true; - case 215 /* EnumDeclaration */: + case 217 /* EnumDeclaration */: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.enum_declarations_can_only_be_used_in_a_ts_file)); return true; - case 169 /* TypeAssertionExpression */: + case 171 /* TypeAssertionExpression */: var typeAssertionExpression = node; diagnostics.push(ts.createDiagnosticForNode(typeAssertionExpression.type, ts.Diagnostics.type_assertion_expressions_can_only_be_used_in_a_ts_file)); return true; - case 137 /* Decorator */: + case 139 /* Decorator */: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.decorators_can_only_be_used_in_a_ts_file)); return true; } @@ -44025,18 +44846,18 @@ var ts; for (var _i = 0; _i < modifiers.length; _i++) { var modifier = modifiers[_i]; switch (modifier.kind) { - case 110 /* PublicKeyword */: - case 108 /* PrivateKeyword */: - case 109 /* ProtectedKeyword */: - case 120 /* DeclareKeyword */: + case 112 /* PublicKeyword */: + case 110 /* PrivateKeyword */: + case 111 /* ProtectedKeyword */: + case 122 /* DeclareKeyword */: diagnostics.push(ts.createDiagnosticForNode(modifier, ts.Diagnostics._0_can_only_be_used_in_a_ts_file, ts.tokenToString(modifier.kind))); return true; // These are all legal modifiers. - case 111 /* StaticKeyword */: - case 80 /* ExportKeyword */: - case 72 /* ConstKeyword */: - case 75 /* DefaultKeyword */: - case 113 /* AbstractKeyword */: + case 113 /* StaticKeyword */: + case 82 /* ExportKeyword */: + case 74 /* ConstKeyword */: + case 77 /* DefaultKeyword */: + case 115 /* AbstractKeyword */: } } } @@ -44097,7 +44918,7 @@ var ts; var typeChecker = program.getTypeChecker(); var syntacticStart = new Date().getTime(); var sourceFile = getValidSourceFile(fileName); - var isJavaScriptFile = ts.isJavaScript(fileName); + var isJavaScriptFile = ts.isSourceFileJavaScript(sourceFile); var isJsDocTagName = false; var start = new Date().getTime(); var currentToken = ts.getTokenAtPosition(sourceFile, position); @@ -44122,9 +44943,9 @@ var ts; isJsDocTagName = true; } switch (tag.kind) { - case 267 /* JSDocTypeTag */: - case 265 /* JSDocParameterTag */: - case 266 /* JSDocReturnTag */: + case 269 /* JSDocTypeTag */: + case 267 /* JSDocParameterTag */: + case 268 /* JSDocReturnTag */: var tagWithExpression = tag; if (tagWithExpression.typeExpression) { insideJsDocTagExpression = tagWithExpression.typeExpression.pos < position && position < tagWithExpression.typeExpression.end; @@ -44161,6 +44982,7 @@ var ts; var node = currentToken; var isRightOfDot = false; var isRightOfOpenTag = false; + var isStartingCloseTag = false; var location = ts.getTouchingPropertyName(sourceFile, position); if (contextToken) { // Bail out if this is a known invalid completion location @@ -44170,11 +44992,11 @@ var ts; } var parent_9 = contextToken.parent, kind = contextToken.kind; if (kind === 21 /* DotToken */) { - if (parent_9.kind === 164 /* PropertyAccessExpression */) { + if (parent_9.kind === 166 /* PropertyAccessExpression */) { node = contextToken.parent.expression; isRightOfDot = true; } - else if (parent_9.kind === 133 /* QualifiedName */) { + else if (parent_9.kind === 135 /* QualifiedName */) { node = contextToken.parent.left; isRightOfDot = true; } @@ -44184,9 +45006,14 @@ var ts; return undefined; } } - else if (kind === 25 /* LessThanToken */ && sourceFile.languageVariant === 1 /* JSX */) { - isRightOfOpenTag = true; - location = contextToken; + else if (sourceFile.languageVariant === 1 /* JSX */) { + if (kind === 25 /* LessThanToken */) { + isRightOfOpenTag = true; + location = contextToken; + } + else if (kind === 39 /* SlashToken */ && contextToken.parent.kind === 237 /* JsxClosingElement */) { + isStartingCloseTag = true; + } } } var semanticStart = new Date().getTime(); @@ -44207,6 +45034,12 @@ var ts; isMemberCompletion = true; isNewIdentifierLocation = false; } + else if (isStartingCloseTag) { + var tagName = contextToken.parent.parent.openingElement.tagName; + symbols = [typeChecker.getSymbolAtLocation(tagName)]; + isMemberCompletion = true; + isNewIdentifierLocation = false; + } else { // For JavaScript or TypeScript, if we're not after a dot, then just try to get the // global symbols in scope. These results should be valid for either language as @@ -44221,7 +45054,7 @@ var ts; // Right of dot member completion list isMemberCompletion = true; isNewIdentifierLocation = false; - if (node.kind === 67 /* Identifier */ || node.kind === 133 /* QualifiedName */ || node.kind === 164 /* PropertyAccessExpression */) { + if (node.kind === 69 /* Identifier */ || node.kind === 135 /* QualifiedName */ || node.kind === 166 /* PropertyAccessExpression */) { var symbol = typeChecker.getSymbolAtLocation(node); // This is an alias, follow what it aliases if (symbol && symbol.flags & 8388608 /* Alias */) { @@ -44277,7 +45110,7 @@ var ts; } if (jsxContainer = tryGetContainingJsxElement(contextToken)) { var attrsType; - if ((jsxContainer.kind === 232 /* JsxSelfClosingElement */) || (jsxContainer.kind === 233 /* JsxOpeningElement */)) { + if ((jsxContainer.kind === 234 /* JsxSelfClosingElement */) || (jsxContainer.kind === 235 /* JsxOpeningElement */)) { // Cursor is inside a JSX self-closing element or opening element attrsType = typeChecker.getJsxElementAttributesType(jsxContainer); if (attrsType) { @@ -44343,49 +45176,64 @@ var ts; var start = new Date().getTime(); var result = isInStringOrRegularExpressionOrTemplateLiteral(contextToken) || isSolelyIdentifierDefinitionLocation(contextToken) || - isDotOfNumericLiteral(contextToken); + isDotOfNumericLiteral(contextToken) || + isInJsxText(contextToken); log("getCompletionsAtPosition: isCompletionListBlocker: " + (new Date().getTime() - start)); return result; } + function isInJsxText(contextToken) { + if (contextToken.kind === 236 /* JsxText */) { + return true; + } + if (contextToken.kind === 27 /* GreaterThanToken */ && contextToken.parent) { + if (contextToken.parent.kind === 235 /* JsxOpeningElement */) { + return true; + } + if (contextToken.parent.kind === 237 /* JsxClosingElement */ || contextToken.parent.kind === 234 /* JsxSelfClosingElement */) { + return contextToken.parent.parent && contextToken.parent.parent.kind === 233 /* JsxElement */; + } + } + return false; + } function isNewIdentifierDefinitionLocation(previousToken) { if (previousToken) { var containingNodeKind = previousToken.parent.kind; switch (previousToken.kind) { case 24 /* CommaToken */: - return containingNodeKind === 166 /* CallExpression */ // func( a, | - || containingNodeKind === 142 /* Constructor */ // constructor( a, | /* public, protected, private keywords are allowed here, so show completion */ - || containingNodeKind === 167 /* NewExpression */ // new C(a, | - || containingNodeKind === 162 /* ArrayLiteralExpression */ // [a, | - || containingNodeKind === 179 /* BinaryExpression */ // let x = (a, | - || containingNodeKind === 150 /* FunctionType */; // var x: (s: string, list| + return containingNodeKind === 168 /* CallExpression */ // func( a, | + || containingNodeKind === 144 /* Constructor */ // constructor( a, | /* public, protected, private keywords are allowed here, so show completion */ + || containingNodeKind === 169 /* NewExpression */ // new C(a, | + || containingNodeKind === 164 /* ArrayLiteralExpression */ // [a, | + || containingNodeKind === 181 /* BinaryExpression */ // let x = (a, | + || containingNodeKind === 152 /* FunctionType */; // var x: (s: string, list| case 17 /* OpenParenToken */: - return containingNodeKind === 166 /* CallExpression */ // func( | - || containingNodeKind === 142 /* Constructor */ // constructor( | - || containingNodeKind === 167 /* NewExpression */ // new C(a| - || containingNodeKind === 170 /* ParenthesizedExpression */ // let x = (a| - || containingNodeKind === 158 /* ParenthesizedType */; // function F(pred: (a| /* this can become an arrow function, where 'a' is the argument */ + return containingNodeKind === 168 /* CallExpression */ // func( | + || containingNodeKind === 144 /* Constructor */ // constructor( | + || containingNodeKind === 169 /* NewExpression */ // new C(a| + || containingNodeKind === 172 /* ParenthesizedExpression */ // let x = (a| + || containingNodeKind === 160 /* ParenthesizedType */; // function F(pred: (a| /* this can become an arrow function, where 'a' is the argument */ case 19 /* OpenBracketToken */: - return containingNodeKind === 162 /* ArrayLiteralExpression */ // [ | - || containingNodeKind === 147 /* IndexSignature */ // [ | : string ] - || containingNodeKind === 134 /* ComputedPropertyName */; // [ | /* this can become an index signature */ - case 123 /* ModuleKeyword */: // module | - case 124 /* NamespaceKeyword */: + return containingNodeKind === 164 /* ArrayLiteralExpression */ // [ | + || containingNodeKind === 149 /* IndexSignature */ // [ | : string ] + || containingNodeKind === 136 /* ComputedPropertyName */; // [ | /* this can become an index signature */ + case 125 /* ModuleKeyword */: // module | + case 126 /* NamespaceKeyword */: return true; case 21 /* DotToken */: - return containingNodeKind === 216 /* ModuleDeclaration */; // module A.| + return containingNodeKind === 218 /* ModuleDeclaration */; // module A.| case 15 /* OpenBraceToken */: - return containingNodeKind === 212 /* ClassDeclaration */; // class A{ | - case 55 /* EqualsToken */: - return containingNodeKind === 209 /* VariableDeclaration */ // let x = a| - || containingNodeKind === 179 /* BinaryExpression */; // x = a| + return containingNodeKind === 214 /* ClassDeclaration */; // class A{ | + case 56 /* EqualsToken */: + return containingNodeKind === 211 /* VariableDeclaration */ // let x = a| + || containingNodeKind === 181 /* BinaryExpression */; // x = a| case 12 /* TemplateHead */: - return containingNodeKind === 181 /* TemplateExpression */; // `aa ${| + return containingNodeKind === 183 /* TemplateExpression */; // `aa ${| case 13 /* TemplateMiddle */: - return containingNodeKind === 188 /* TemplateSpan */; // `aa ${10} dd ${| - case 110 /* PublicKeyword */: - case 108 /* PrivateKeyword */: - case 109 /* ProtectedKeyword */: - return containingNodeKind === 139 /* PropertyDeclaration */; // class A{ public | + return containingNodeKind === 190 /* TemplateSpan */; // `aa ${10} dd ${| + case 112 /* PublicKeyword */: + case 110 /* PrivateKeyword */: + case 111 /* ProtectedKeyword */: + return containingNodeKind === 141 /* PropertyDeclaration */; // class A{ public | } // Previous token may have been a keyword that was converted to an identifier. switch (previousToken.getText()) { @@ -44428,14 +45276,14 @@ var ts; isMemberCompletion = true; var typeForObject; var existingMembers; - if (objectLikeContainer.kind === 163 /* ObjectLiteralExpression */) { + if (objectLikeContainer.kind === 165 /* ObjectLiteralExpression */) { // We are completing on contextual types, but may also include properties // other than those within the declared type. isNewIdentifierLocation = true; typeForObject = typeChecker.getContextualType(objectLikeContainer); existingMembers = objectLikeContainer.properties; } - else if (objectLikeContainer.kind === 159 /* ObjectBindingPattern */) { + else if (objectLikeContainer.kind === 161 /* ObjectBindingPattern */) { // We are *only* completing on properties from the type being destructured. isNewIdentifierLocation = false; var rootDeclaration = ts.getRootDeclaration(objectLikeContainer.parent); @@ -44481,9 +45329,9 @@ var ts; * @returns true if 'symbols' was successfully populated; false otherwise. */ function tryGetImportOrExportClauseCompletionSymbols(namedImportsOrExports) { - var declarationKind = namedImportsOrExports.kind === 223 /* NamedImports */ ? - 220 /* ImportDeclaration */ : - 226 /* ExportDeclaration */; + var declarationKind = namedImportsOrExports.kind === 225 /* NamedImports */ ? + 222 /* ImportDeclaration */ : + 228 /* ExportDeclaration */; var importOrExportDeclaration = ts.getAncestor(namedImportsOrExports, declarationKind); var moduleSpecifier = importOrExportDeclaration.moduleSpecifier; if (!moduleSpecifier) { @@ -44509,7 +45357,7 @@ var ts; case 15 /* OpenBraceToken */: // let x = { | case 24 /* CommaToken */: var parent_10 = contextToken.parent; - if (parent_10 && (parent_10.kind === 163 /* ObjectLiteralExpression */ || parent_10.kind === 159 /* ObjectBindingPattern */)) { + if (parent_10 && (parent_10.kind === 165 /* ObjectLiteralExpression */ || parent_10.kind === 161 /* ObjectBindingPattern */)) { return parent_10; } break; @@ -44527,8 +45375,8 @@ var ts; case 15 /* OpenBraceToken */: // import { | case 24 /* CommaToken */: switch (contextToken.parent.kind) { - case 223 /* NamedImports */: - case 227 /* NamedExports */: + case 225 /* NamedImports */: + case 229 /* NamedExports */: return contextToken.parent; } } @@ -44540,30 +45388,33 @@ var ts; var parent_11 = contextToken.parent; switch (contextToken.kind) { case 26 /* LessThanSlashToken */: - case 38 /* SlashToken */: - case 67 /* Identifier */: - case 236 /* JsxAttribute */: - case 237 /* JsxSpreadAttribute */: - if (parent_11 && (parent_11.kind === 232 /* JsxSelfClosingElement */ || parent_11.kind === 233 /* JsxOpeningElement */)) { + case 39 /* SlashToken */: + case 69 /* Identifier */: + case 238 /* JsxAttribute */: + case 239 /* JsxSpreadAttribute */: + if (parent_11 && (parent_11.kind === 234 /* JsxSelfClosingElement */ || parent_11.kind === 235 /* JsxOpeningElement */)) { return parent_11; } + else if (parent_11.kind === 238 /* JsxAttribute */) { + return parent_11.parent; + } break; // The context token is the closing } or " of an attribute, which means // its parent is a JsxExpression, whose parent is a JsxAttribute, // whose parent is a JsxOpeningLikeElement case 9 /* StringLiteral */: - if (parent_11 && ((parent_11.kind === 236 /* JsxAttribute */) || (parent_11.kind === 237 /* JsxSpreadAttribute */))) { + if (parent_11 && ((parent_11.kind === 238 /* JsxAttribute */) || (parent_11.kind === 239 /* JsxSpreadAttribute */))) { return parent_11.parent; } break; case 16 /* CloseBraceToken */: if (parent_11 && - parent_11.kind === 238 /* JsxExpression */ && + parent_11.kind === 240 /* JsxExpression */ && parent_11.parent && - (parent_11.parent.kind === 236 /* JsxAttribute */)) { + (parent_11.parent.kind === 238 /* JsxAttribute */)) { return parent_11.parent.parent; } - if (parent_11 && parent_11.kind === 237 /* JsxSpreadAttribute */) { + if (parent_11 && parent_11.kind === 239 /* JsxSpreadAttribute */) { return parent_11.parent; } break; @@ -44573,16 +45424,16 @@ var ts; } function isFunction(kind) { switch (kind) { - case 171 /* FunctionExpression */: - case 172 /* ArrowFunction */: - case 211 /* FunctionDeclaration */: - case 141 /* MethodDeclaration */: - case 140 /* MethodSignature */: - case 143 /* GetAccessor */: - case 144 /* SetAccessor */: - case 145 /* CallSignature */: - case 146 /* ConstructSignature */: - case 147 /* IndexSignature */: + case 173 /* FunctionExpression */: + case 174 /* ArrowFunction */: + case 213 /* FunctionDeclaration */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: + case 147 /* CallSignature */: + case 148 /* ConstructSignature */: + case 149 /* IndexSignature */: return true; } return false; @@ -44594,78 +45445,84 @@ var ts; var containingNodeKind = contextToken.parent.kind; switch (contextToken.kind) { case 24 /* CommaToken */: - return containingNodeKind === 209 /* VariableDeclaration */ || - containingNodeKind === 210 /* VariableDeclarationList */ || - containingNodeKind === 191 /* VariableStatement */ || - containingNodeKind === 215 /* EnumDeclaration */ || + return containingNodeKind === 211 /* VariableDeclaration */ || + containingNodeKind === 212 /* VariableDeclarationList */ || + containingNodeKind === 193 /* VariableStatement */ || + containingNodeKind === 217 /* EnumDeclaration */ || isFunction(containingNodeKind) || - containingNodeKind === 212 /* ClassDeclaration */ || - containingNodeKind === 184 /* ClassExpression */ || - containingNodeKind === 213 /* InterfaceDeclaration */ || - containingNodeKind === 160 /* ArrayBindingPattern */ || - containingNodeKind === 214 /* TypeAliasDeclaration */; // type Map, K, | + containingNodeKind === 214 /* ClassDeclaration */ || + containingNodeKind === 186 /* ClassExpression */ || + containingNodeKind === 215 /* InterfaceDeclaration */ || + containingNodeKind === 162 /* ArrayBindingPattern */ || + containingNodeKind === 216 /* TypeAliasDeclaration */; // type Map, K, | case 21 /* DotToken */: - return containingNodeKind === 160 /* ArrayBindingPattern */; // var [.| - case 53 /* ColonToken */: - return containingNodeKind === 161 /* BindingElement */; // var {x :html| + return containingNodeKind === 162 /* ArrayBindingPattern */; // var [.| + case 54 /* ColonToken */: + return containingNodeKind === 163 /* BindingElement */; // var {x :html| case 19 /* OpenBracketToken */: - return containingNodeKind === 160 /* ArrayBindingPattern */; // var [x| + return containingNodeKind === 162 /* ArrayBindingPattern */; // var [x| case 17 /* OpenParenToken */: - return containingNodeKind === 242 /* CatchClause */ || + return containingNodeKind === 244 /* CatchClause */ || isFunction(containingNodeKind); case 15 /* OpenBraceToken */: - return containingNodeKind === 215 /* EnumDeclaration */ || - containingNodeKind === 213 /* InterfaceDeclaration */ || - containingNodeKind === 153 /* TypeLiteral */; // let x : { | + return containingNodeKind === 217 /* EnumDeclaration */ || + containingNodeKind === 215 /* InterfaceDeclaration */ || + containingNodeKind === 155 /* TypeLiteral */; // let x : { | case 23 /* SemicolonToken */: - return containingNodeKind === 138 /* PropertySignature */ && + return containingNodeKind === 140 /* PropertySignature */ && contextToken.parent && contextToken.parent.parent && - (contextToken.parent.parent.kind === 213 /* InterfaceDeclaration */ || - contextToken.parent.parent.kind === 153 /* TypeLiteral */); // let x : { a; | + (contextToken.parent.parent.kind === 215 /* InterfaceDeclaration */ || + contextToken.parent.parent.kind === 155 /* TypeLiteral */); // let x : { a; | case 25 /* LessThanToken */: - return containingNodeKind === 212 /* ClassDeclaration */ || - containingNodeKind === 184 /* ClassExpression */ || - containingNodeKind === 213 /* InterfaceDeclaration */ || - containingNodeKind === 214 /* TypeAliasDeclaration */ || + return containingNodeKind === 214 /* ClassDeclaration */ || + containingNodeKind === 186 /* ClassExpression */ || + containingNodeKind === 215 /* InterfaceDeclaration */ || + containingNodeKind === 216 /* TypeAliasDeclaration */ || isFunction(containingNodeKind); - case 111 /* StaticKeyword */: - return containingNodeKind === 139 /* PropertyDeclaration */; + case 113 /* StaticKeyword */: + return containingNodeKind === 141 /* PropertyDeclaration */; case 22 /* DotDotDotToken */: - return containingNodeKind === 136 /* Parameter */ || + return containingNodeKind === 138 /* Parameter */ || (contextToken.parent && contextToken.parent.parent && - contextToken.parent.parent.kind === 160 /* ArrayBindingPattern */); // var [...z| - case 110 /* PublicKeyword */: - case 108 /* PrivateKeyword */: - case 109 /* ProtectedKeyword */: - return containingNodeKind === 136 /* Parameter */; - case 114 /* AsKeyword */: - containingNodeKind === 224 /* ImportSpecifier */ || - containingNodeKind === 228 /* ExportSpecifier */ || - containingNodeKind === 222 /* NamespaceImport */; - case 71 /* ClassKeyword */: - case 79 /* EnumKeyword */: - case 105 /* InterfaceKeyword */: - case 85 /* FunctionKeyword */: - case 100 /* VarKeyword */: - case 121 /* GetKeyword */: - case 127 /* SetKeyword */: - case 87 /* ImportKeyword */: - case 106 /* LetKeyword */: - case 72 /* ConstKeyword */: - case 112 /* YieldKeyword */: - case 130 /* TypeKeyword */: + contextToken.parent.parent.kind === 162 /* ArrayBindingPattern */); // var [...z| + case 112 /* PublicKeyword */: + case 110 /* PrivateKeyword */: + case 111 /* ProtectedKeyword */: + return containingNodeKind === 138 /* Parameter */; + case 116 /* AsKeyword */: + return containingNodeKind === 226 /* ImportSpecifier */ || + containingNodeKind === 230 /* ExportSpecifier */ || + containingNodeKind === 224 /* NamespaceImport */; + case 73 /* ClassKeyword */: + case 81 /* EnumKeyword */: + case 107 /* InterfaceKeyword */: + case 87 /* FunctionKeyword */: + case 102 /* VarKeyword */: + case 123 /* GetKeyword */: + case 129 /* SetKeyword */: + case 89 /* ImportKeyword */: + case 108 /* LetKeyword */: + case 74 /* ConstKeyword */: + case 114 /* YieldKeyword */: + case 132 /* TypeKeyword */: return true; } // Previous token may have been a keyword that was converted to an identifier. switch (contextToken.getText()) { + case "abstract": + case "async": case "class": - case "interface": + case "const": + case "declare": case "enum": case "function": - case "var": - case "static": + case "interface": case "let": - case "const": + case "private": + case "protected": + case "public": + case "static": + case "var": case "yield": return true; } @@ -44695,8 +45552,8 @@ var ts; if (element.getStart() <= position && position <= element.getEnd()) { continue; } - var name_31 = element.propertyName || element.name; - exisingImportsOrExports[name_31.text] = true; + var name_32 = element.propertyName || element.name; + exisingImportsOrExports[name_32.text] = true; } if (ts.isEmpty(exisingImportsOrExports)) { return exportsOfModule; @@ -44717,9 +45574,9 @@ var ts; for (var _i = 0; _i < existingMembers.length; _i++) { var m = existingMembers[_i]; // Ignore omitted expressions for missing members - if (m.kind !== 243 /* PropertyAssignment */ && - m.kind !== 244 /* ShorthandPropertyAssignment */ && - m.kind !== 161 /* BindingElement */) { + if (m.kind !== 245 /* PropertyAssignment */ && + m.kind !== 246 /* ShorthandPropertyAssignment */ && + m.kind !== 163 /* BindingElement */) { continue; } // If this is the current item we are editing right now, do not filter it out @@ -44727,7 +45584,7 @@ var ts; continue; } var existingName = void 0; - if (m.kind === 161 /* BindingElement */ && m.propertyName) { + if (m.kind === 163 /* BindingElement */ && m.propertyName) { existingName = m.propertyName.text; } else { @@ -44754,7 +45611,7 @@ var ts; if (attr.getStart() <= position && position <= attr.getEnd()) { continue; } - if (attr.kind === 236 /* JsxAttribute */) { + if (attr.kind === 238 /* JsxAttribute */) { seenNames[attr.name.text] = true; } } @@ -44768,46 +45625,43 @@ var ts; return undefined; } var symbols = completionData.symbols, isMemberCompletion = completionData.isMemberCompletion, isNewIdentifierLocation = completionData.isNewIdentifierLocation, location = completionData.location, isRightOfDot = completionData.isRightOfDot, isJsDocTagName = completionData.isJsDocTagName; - var entries; if (isJsDocTagName) { // If the current position is a jsDoc tag name, only tag names should be provided for completion return { isMemberCompletion: false, isNewIdentifierLocation: false, entries: getAllJsDocCompletionEntries() }; } - if (isRightOfDot && ts.isJavaScript(fileName)) { - entries = getCompletionEntriesFromSymbols(symbols); - ts.addRange(entries, getJavaScriptCompletionEntries()); + var sourceFile = getValidSourceFile(fileName); + var entries = []; + if (isRightOfDot && ts.isSourceFileJavaScript(sourceFile)) { + var uniqueNames = getCompletionEntriesFromSymbols(symbols, entries); + ts.addRange(entries, getJavaScriptCompletionEntries(sourceFile, uniqueNames)); } else { if (!symbols || symbols.length === 0) { return undefined; } - entries = getCompletionEntriesFromSymbols(symbols); + getCompletionEntriesFromSymbols(symbols, entries); } // Add keywords if this is not a member completion list if (!isMemberCompletion && !isJsDocTagName) { ts.addRange(entries, keywordCompletions); } return { isMemberCompletion: isMemberCompletion, isNewIdentifierLocation: isNewIdentifierLocation, entries: entries }; - function getJavaScriptCompletionEntries() { + function getJavaScriptCompletionEntries(sourceFile, uniqueNames) { var entries = []; - var allNames = {}; var target = program.getCompilerOptions().target; - for (var _i = 0, _a = program.getSourceFiles(); _i < _a.length; _i++) { - var sourceFile = _a[_i]; - var nameTable = getNameTable(sourceFile); - for (var name_32 in nameTable) { - if (!allNames[name_32]) { - allNames[name_32] = name_32; - var displayName = getCompletionEntryDisplayName(name_32, target, /*performCharacterChecks:*/ true); - if (displayName) { - var entry = { - name: displayName, - kind: ScriptElementKind.warning, - kindModifiers: "", - sortText: "1" - }; - entries.push(entry); - } + var nameTable = getNameTable(sourceFile); + for (var name_33 in nameTable) { + if (!uniqueNames[name_33]) { + uniqueNames[name_33] = name_33; + var displayName = getCompletionEntryDisplayName(name_33, target, /*performCharacterChecks:*/ true); + if (displayName) { + var entry = { + name: displayName, + kind: ScriptElementKind.warning, + kindModifiers: "", + sortText: "1" + }; + entries.push(entry); } } } @@ -44845,25 +45699,24 @@ var ts; sortText: "0" }; } - function getCompletionEntriesFromSymbols(symbols) { + function getCompletionEntriesFromSymbols(symbols, entries) { var start = new Date().getTime(); - var entries = []; + var uniqueNames = {}; if (symbols) { - var nameToSymbol = {}; for (var _i = 0; _i < symbols.length; _i++) { var symbol = symbols[_i]; var entry = createCompletionEntry(symbol, location); if (entry) { var id = ts.escapeIdentifier(entry.name); - if (!ts.lookUp(nameToSymbol, id)) { + if (!ts.lookUp(uniqueNames, id)) { entries.push(entry); - nameToSymbol[id] = symbol; + uniqueNames[id] = id; } } } } log("getCompletionsAtPosition: getCompletionEntriesFromSymbols: " + (new Date().getTime() - start)); - return entries; + return uniqueNames; } } function getCompletionEntryDetails(fileName, position, entryName) { @@ -44906,7 +45759,7 @@ var ts; function getSymbolKind(symbol, location) { var flags = symbol.getFlags(); if (flags & 32 /* Class */) - return ts.getDeclarationOfKind(symbol, 184 /* ClassExpression */) ? + return ts.getDeclarationOfKind(symbol, 186 /* ClassExpression */) ? ScriptElementKind.localClassElement : ScriptElementKind.classElement; if (flags & 384 /* Enum */) return ScriptElementKind.enumElement; @@ -45008,7 +45861,7 @@ var ts; var signature; type = typeChecker.getTypeOfSymbolAtLocation(symbol, location); if (type) { - if (location.parent && location.parent.kind === 164 /* PropertyAccessExpression */) { + if (location.parent && location.parent.kind === 166 /* PropertyAccessExpression */) { var right = location.parent.name; // Either the location is on the right of a property access, or on the left and the right is missing if (right === location || (right && right.getFullWidth() === 0)) { @@ -45017,7 +45870,7 @@ var ts; } // try get the call/construct signature from the type if it matches var callExpression; - if (location.kind === 166 /* CallExpression */ || location.kind === 167 /* NewExpression */) { + if (location.kind === 168 /* CallExpression */ || location.kind === 169 /* NewExpression */) { callExpression = location; } else if (isCallExpressionTarget(location) || isNewExpressionTarget(location)) { @@ -45030,10 +45883,11 @@ var ts; // Use the first candidate: signature = candidateSignatures[0]; } - var useConstructSignatures = callExpression.kind === 167 /* NewExpression */ || callExpression.expression.kind === 93 /* SuperKeyword */; + var useConstructSignatures = callExpression.kind === 169 /* NewExpression */ || callExpression.expression.kind === 95 /* SuperKeyword */; var allSignatures = useConstructSignatures ? type.getConstructSignatures() : type.getCallSignatures(); - if (!ts.contains(allSignatures, signature.target || signature)) { - // Get the first signature if there + if (!ts.contains(allSignatures, signature.target) && !ts.contains(allSignatures, signature)) { + // Get the first signature if there is one -- allSignatures may contain + // either the original signature or its target, so check for either signature = allSignatures.length ? allSignatures[0] : undefined; } if (signature) { @@ -45047,7 +45901,7 @@ var ts; pushTypePart(symbolKind); displayParts.push(ts.spacePart()); if (useConstructSignatures) { - displayParts.push(ts.keywordPart(90 /* NewKeyword */)); + displayParts.push(ts.keywordPart(92 /* NewKeyword */)); displayParts.push(ts.spacePart()); } addFullSymbolName(symbol); @@ -45063,10 +45917,10 @@ var ts; case ScriptElementKind.parameterElement: case ScriptElementKind.localVariableElement: // If it is call or construct signature of lambda's write type name - displayParts.push(ts.punctuationPart(53 /* ColonToken */)); + displayParts.push(ts.punctuationPart(54 /* ColonToken */)); displayParts.push(ts.spacePart()); if (useConstructSignatures) { - displayParts.push(ts.keywordPart(90 /* NewKeyword */)); + displayParts.push(ts.keywordPart(92 /* NewKeyword */)); displayParts.push(ts.spacePart()); } if (!(type.flags & 65536 /* Anonymous */)) { @@ -45082,24 +45936,24 @@ var ts; } } else if ((isNameOfFunctionDeclaration(location) && !(symbol.flags & 98304 /* Accessor */)) || - (location.kind === 119 /* ConstructorKeyword */ && location.parent.kind === 142 /* Constructor */)) { + (location.kind === 121 /* ConstructorKeyword */ && location.parent.kind === 144 /* Constructor */)) { // get the signature from the declaration and write it var functionDeclaration = location.parent; - var allSignatures = functionDeclaration.kind === 142 /* Constructor */ ? type.getConstructSignatures() : type.getCallSignatures(); + var allSignatures = functionDeclaration.kind === 144 /* Constructor */ ? type.getConstructSignatures() : type.getCallSignatures(); if (!typeChecker.isImplementationOfOverload(functionDeclaration)) { signature = typeChecker.getSignatureFromDeclaration(functionDeclaration); } else { signature = allSignatures[0]; } - if (functionDeclaration.kind === 142 /* Constructor */) { + if (functionDeclaration.kind === 144 /* Constructor */) { // show (constructor) Type(...) signature symbolKind = ScriptElementKind.constructorImplementationElement; addPrefixForAnyFunctionOrVar(type.symbol, symbolKind); } else { // (function/method) symbol(..signature) - addPrefixForAnyFunctionOrVar(functionDeclaration.kind === 145 /* CallSignature */ && + addPrefixForAnyFunctionOrVar(functionDeclaration.kind === 147 /* CallSignature */ && !(type.symbol.flags & 2048 /* TypeLiteral */ || type.symbol.flags & 4096 /* ObjectLiteral */) ? type.symbol : symbol, symbolKind); } addSignatureDisplayParts(signature, allSignatures); @@ -45108,7 +45962,7 @@ var ts; } } if (symbolFlags & 32 /* Class */ && !hasAddedSymbolInfo) { - if (ts.getDeclarationOfKind(symbol, 184 /* ClassExpression */)) { + if (ts.getDeclarationOfKind(symbol, 186 /* ClassExpression */)) { // Special case for class expressions because we would like to indicate that // the class name is local to the class body (similar to function expression) // (local class) class @@ -45116,7 +45970,7 @@ var ts; } else { // Class declaration has name which is not local. - displayParts.push(ts.keywordPart(71 /* ClassKeyword */)); + displayParts.push(ts.keywordPart(73 /* ClassKeyword */)); } displayParts.push(ts.spacePart()); addFullSymbolName(symbol); @@ -45124,37 +45978,37 @@ var ts; } if ((symbolFlags & 64 /* Interface */) && (semanticMeaning & 2 /* Type */)) { addNewLineIfDisplayPartsExist(); - displayParts.push(ts.keywordPart(105 /* InterfaceKeyword */)); + displayParts.push(ts.keywordPart(107 /* InterfaceKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); writeTypeParametersOfSymbol(symbol, sourceFile); } if (symbolFlags & 524288 /* TypeAlias */) { addNewLineIfDisplayPartsExist(); - displayParts.push(ts.keywordPart(130 /* TypeKeyword */)); + displayParts.push(ts.keywordPart(132 /* TypeKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); writeTypeParametersOfSymbol(symbol, sourceFile); displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(55 /* EqualsToken */)); + displayParts.push(ts.operatorPart(56 /* EqualsToken */)); displayParts.push(ts.spacePart()); ts.addRange(displayParts, ts.typeToDisplayParts(typeChecker, typeChecker.getDeclaredTypeOfSymbol(symbol), enclosingDeclaration)); } if (symbolFlags & 384 /* Enum */) { addNewLineIfDisplayPartsExist(); if (ts.forEach(symbol.declarations, ts.isConstEnumDeclaration)) { - displayParts.push(ts.keywordPart(72 /* ConstKeyword */)); + displayParts.push(ts.keywordPart(74 /* ConstKeyword */)); displayParts.push(ts.spacePart()); } - displayParts.push(ts.keywordPart(79 /* EnumKeyword */)); + displayParts.push(ts.keywordPart(81 /* EnumKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); } if (symbolFlags & 1536 /* Module */) { addNewLineIfDisplayPartsExist(); - var declaration = ts.getDeclarationOfKind(symbol, 216 /* ModuleDeclaration */); - var isNamespace = declaration && declaration.name && declaration.name.kind === 67 /* Identifier */; - displayParts.push(ts.keywordPart(isNamespace ? 124 /* NamespaceKeyword */ : 123 /* ModuleKeyword */)); + var declaration = ts.getDeclarationOfKind(symbol, 218 /* ModuleDeclaration */); + var isNamespace = declaration && declaration.name && declaration.name.kind === 69 /* Identifier */; + displayParts.push(ts.keywordPart(isNamespace ? 126 /* NamespaceKeyword */ : 125 /* ModuleKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); } @@ -45166,7 +46020,7 @@ var ts; displayParts.push(ts.spacePart()); addFullSymbolName(symbol); displayParts.push(ts.spacePart()); - displayParts.push(ts.keywordPart(88 /* InKeyword */)); + displayParts.push(ts.keywordPart(90 /* InKeyword */)); displayParts.push(ts.spacePart()); if (symbol.parent) { // Class/Interface type parameter @@ -45177,13 +46031,13 @@ var ts; // Method/function type parameter var container = ts.getContainingFunction(location); if (container) { - var signatureDeclaration = ts.getDeclarationOfKind(symbol, 135 /* TypeParameter */).parent; + var signatureDeclaration = ts.getDeclarationOfKind(symbol, 137 /* TypeParameter */).parent; var signature = typeChecker.getSignatureFromDeclaration(signatureDeclaration); - if (signatureDeclaration.kind === 146 /* ConstructSignature */) { - displayParts.push(ts.keywordPart(90 /* NewKeyword */)); + if (signatureDeclaration.kind === 148 /* ConstructSignature */) { + displayParts.push(ts.keywordPart(92 /* NewKeyword */)); displayParts.push(ts.spacePart()); } - else if (signatureDeclaration.kind !== 145 /* CallSignature */ && signatureDeclaration.name) { + else if (signatureDeclaration.kind !== 147 /* CallSignature */ && signatureDeclaration.name) { addFullSymbolName(signatureDeclaration.symbol); } ts.addRange(displayParts, ts.signatureToDisplayParts(typeChecker, signature, sourceFile, 32 /* WriteTypeArgumentsOfSignature */)); @@ -45192,8 +46046,8 @@ var ts; // Type aliash type parameter // For example // type list = T[]; // Both T will go through same code path - var declaration = ts.getDeclarationOfKind(symbol, 135 /* TypeParameter */).parent; - displayParts.push(ts.keywordPart(130 /* TypeKeyword */)); + var declaration = ts.getDeclarationOfKind(symbol, 137 /* TypeParameter */).parent; + displayParts.push(ts.keywordPart(132 /* TypeKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(declaration.symbol); writeTypeParametersOfSymbol(declaration.symbol, sourceFile); @@ -45203,11 +46057,11 @@ var ts; if (symbolFlags & 8 /* EnumMember */) { addPrefixForAnyFunctionOrVar(symbol, "enum member"); var declaration = symbol.declarations[0]; - if (declaration.kind === 245 /* EnumMember */) { + if (declaration.kind === 247 /* EnumMember */) { var constantValue = typeChecker.getConstantValue(declaration); if (constantValue !== undefined) { displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(55 /* EqualsToken */)); + displayParts.push(ts.operatorPart(56 /* EqualsToken */)); displayParts.push(ts.spacePart()); displayParts.push(ts.displayPart(constantValue.toString(), SymbolDisplayPartKind.numericLiteral)); } @@ -45215,17 +46069,17 @@ var ts; } if (symbolFlags & 8388608 /* Alias */) { addNewLineIfDisplayPartsExist(); - displayParts.push(ts.keywordPart(87 /* ImportKeyword */)); + displayParts.push(ts.keywordPart(89 /* ImportKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); ts.forEach(symbol.declarations, function (declaration) { - if (declaration.kind === 219 /* ImportEqualsDeclaration */) { + if (declaration.kind === 221 /* ImportEqualsDeclaration */) { var importEqualsDeclaration = declaration; if (ts.isExternalModuleImportEqualsDeclaration(importEqualsDeclaration)) { displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(55 /* EqualsToken */)); + displayParts.push(ts.operatorPart(56 /* EqualsToken */)); displayParts.push(ts.spacePart()); - displayParts.push(ts.keywordPart(125 /* RequireKeyword */)); + displayParts.push(ts.keywordPart(127 /* RequireKeyword */)); displayParts.push(ts.punctuationPart(17 /* OpenParenToken */)); displayParts.push(ts.displayPart(ts.getTextOfNode(ts.getExternalModuleImportEqualsDeclarationExpression(importEqualsDeclaration)), SymbolDisplayPartKind.stringLiteral)); displayParts.push(ts.punctuationPart(18 /* CloseParenToken */)); @@ -45234,7 +46088,7 @@ var ts; var internalAliasSymbol = typeChecker.getSymbolAtLocation(importEqualsDeclaration.moduleReference); if (internalAliasSymbol) { displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(55 /* EqualsToken */)); + displayParts.push(ts.operatorPart(56 /* EqualsToken */)); displayParts.push(ts.spacePart()); addFullSymbolName(internalAliasSymbol, enclosingDeclaration); } @@ -45251,7 +46105,7 @@ var ts; if (symbolKind === ScriptElementKind.memberVariableElement || symbolFlags & 3 /* Variable */ || symbolKind === ScriptElementKind.localVariableElement) { - displayParts.push(ts.punctuationPart(53 /* ColonToken */)); + displayParts.push(ts.punctuationPart(54 /* ColonToken */)); displayParts.push(ts.spacePart()); // If the type is type parameter, format it specially if (type.symbol && type.symbol.flags & 262144 /* TypeParameter */) { @@ -45351,11 +46205,11 @@ var ts; if (!symbol) { // Try getting just type at this position and show switch (node.kind) { - case 67 /* Identifier */: - case 164 /* PropertyAccessExpression */: - case 133 /* QualifiedName */: - case 95 /* ThisKeyword */: - case 93 /* SuperKeyword */: + case 69 /* Identifier */: + case 166 /* PropertyAccessExpression */: + case 135 /* QualifiedName */: + case 97 /* ThisKeyword */: + case 95 /* SuperKeyword */: // For the identifiers/this/super etc get the type at position var type = typeChecker.getTypeAtLocation(node); if (type) { @@ -45408,7 +46262,7 @@ var ts; function tryAddConstructSignature(symbol, location, symbolKind, symbolName, containerName, result) { // Applicable only if we are in a new expression, or we are on a constructor declaration // and in either case the symbol has a construct signature definition, i.e. class - if (isNewExpressionTarget(location) || location.kind === 119 /* ConstructorKeyword */) { + if (isNewExpressionTarget(location) || location.kind === 121 /* ConstructorKeyword */) { if (symbol.flags & 32 /* Class */) { // Find the first class-like declaration and try to get the construct signature. for (var _i = 0, _a = symbol.getDeclarations(); _i < _a.length; _i++) { @@ -45433,8 +46287,8 @@ var ts; var declarations = []; var definition; ts.forEach(signatureDeclarations, function (d) { - if ((selectConstructors && d.kind === 142 /* Constructor */) || - (!selectConstructors && (d.kind === 211 /* FunctionDeclaration */ || d.kind === 141 /* MethodDeclaration */ || d.kind === 140 /* MethodSignature */))) { + if ((selectConstructors && d.kind === 144 /* Constructor */) || + (!selectConstructors && (d.kind === 213 /* FunctionDeclaration */ || d.kind === 143 /* MethodDeclaration */ || d.kind === 142 /* MethodSignature */))) { declarations.push(d); if (d.body) definition = d; @@ -45494,7 +46348,7 @@ var ts; // to jump to the implementation directly. if (symbol.flags & 8388608 /* Alias */) { var declaration = symbol.declarations[0]; - if (node.kind === 67 /* Identifier */ && node.parent === declaration) { + if (node.kind === 69 /* Identifier */ && node.parent === declaration) { symbol = typeChecker.getAliasedSymbol(symbol); } } @@ -45503,7 +46357,7 @@ var ts; // go to the declaration of the property name (in this case stay at the same position). However, if go-to-definition // is performed at the location of property access, we would like to go to definition of the property in the short-hand // assignment. This case and others are handled by the following code. - if (node.parent.kind === 244 /* ShorthandPropertyAssignment */) { + if (node.parent.kind === 246 /* ShorthandPropertyAssignment */) { var shorthandSymbol = typeChecker.getShorthandAssignmentValueSymbol(symbol.valueDeclaration); if (!shorthandSymbol) { return []; @@ -45577,9 +46431,9 @@ var ts; }; } function getSemanticDocumentHighlights(node) { - if (node.kind === 67 /* Identifier */ || - node.kind === 95 /* ThisKeyword */ || - node.kind === 93 /* SuperKeyword */ || + if (node.kind === 69 /* Identifier */ || + node.kind === 97 /* ThisKeyword */ || + node.kind === 95 /* SuperKeyword */ || isLiteralNameOfPropertyDeclarationOrIndexAccess(node) || isNameOfExternalModuleImportOrDeclaration(node)) { var referencedSymbols = getReferencedSymbolsForNode(node, sourceFilesToSearch, /*findInStrings:*/ false, /*findInComments:*/ false); @@ -45630,77 +46484,77 @@ var ts; function getHighlightSpans(node) { if (node) { switch (node.kind) { - case 86 /* IfKeyword */: - case 78 /* ElseKeyword */: - if (hasKind(node.parent, 194 /* IfStatement */)) { + case 88 /* IfKeyword */: + case 80 /* ElseKeyword */: + if (hasKind(node.parent, 196 /* IfStatement */)) { return getIfElseOccurrences(node.parent); } break; - case 92 /* ReturnKeyword */: - if (hasKind(node.parent, 202 /* ReturnStatement */)) { + case 94 /* ReturnKeyword */: + if (hasKind(node.parent, 204 /* ReturnStatement */)) { return getReturnOccurrences(node.parent); } break; - case 96 /* ThrowKeyword */: - if (hasKind(node.parent, 206 /* ThrowStatement */)) { + case 98 /* ThrowKeyword */: + if (hasKind(node.parent, 208 /* ThrowStatement */)) { return getThrowOccurrences(node.parent); } break; - case 70 /* CatchKeyword */: - if (hasKind(parent(parent(node)), 207 /* TryStatement */)) { + case 72 /* CatchKeyword */: + if (hasKind(parent(parent(node)), 209 /* TryStatement */)) { return getTryCatchFinallyOccurrences(node.parent.parent); } break; - case 98 /* TryKeyword */: - case 83 /* FinallyKeyword */: - if (hasKind(parent(node), 207 /* TryStatement */)) { + case 100 /* TryKeyword */: + case 85 /* FinallyKeyword */: + if (hasKind(parent(node), 209 /* TryStatement */)) { return getTryCatchFinallyOccurrences(node.parent); } break; - case 94 /* SwitchKeyword */: - if (hasKind(node.parent, 204 /* SwitchStatement */)) { + case 96 /* SwitchKeyword */: + if (hasKind(node.parent, 206 /* SwitchStatement */)) { return getSwitchCaseDefaultOccurrences(node.parent); } break; - case 69 /* CaseKeyword */: - case 75 /* DefaultKeyword */: - if (hasKind(parent(parent(parent(node))), 204 /* SwitchStatement */)) { + case 71 /* CaseKeyword */: + case 77 /* DefaultKeyword */: + if (hasKind(parent(parent(parent(node))), 206 /* SwitchStatement */)) { return getSwitchCaseDefaultOccurrences(node.parent.parent.parent); } break; - case 68 /* BreakKeyword */: - case 73 /* ContinueKeyword */: - if (hasKind(node.parent, 201 /* BreakStatement */) || hasKind(node.parent, 200 /* ContinueStatement */)) { + case 70 /* BreakKeyword */: + case 75 /* ContinueKeyword */: + if (hasKind(node.parent, 203 /* BreakStatement */) || hasKind(node.parent, 202 /* ContinueStatement */)) { return getBreakOrContinueStatementOccurrences(node.parent); } break; - case 84 /* ForKeyword */: - if (hasKind(node.parent, 197 /* ForStatement */) || - hasKind(node.parent, 198 /* ForInStatement */) || - hasKind(node.parent, 199 /* ForOfStatement */)) { + case 86 /* ForKeyword */: + if (hasKind(node.parent, 199 /* ForStatement */) || + hasKind(node.parent, 200 /* ForInStatement */) || + hasKind(node.parent, 201 /* ForOfStatement */)) { return getLoopBreakContinueOccurrences(node.parent); } break; - case 102 /* WhileKeyword */: - case 77 /* DoKeyword */: - if (hasKind(node.parent, 196 /* WhileStatement */) || hasKind(node.parent, 195 /* DoStatement */)) { + case 104 /* WhileKeyword */: + case 79 /* DoKeyword */: + if (hasKind(node.parent, 198 /* WhileStatement */) || hasKind(node.parent, 197 /* DoStatement */)) { return getLoopBreakContinueOccurrences(node.parent); } break; - case 119 /* ConstructorKeyword */: - if (hasKind(node.parent, 142 /* Constructor */)) { + case 121 /* ConstructorKeyword */: + if (hasKind(node.parent, 144 /* Constructor */)) { return getConstructorOccurrences(node.parent); } break; - case 121 /* GetKeyword */: - case 127 /* SetKeyword */: - if (hasKind(node.parent, 143 /* GetAccessor */) || hasKind(node.parent, 144 /* SetAccessor */)) { + case 123 /* GetKeyword */: + case 129 /* SetKeyword */: + if (hasKind(node.parent, 145 /* GetAccessor */) || hasKind(node.parent, 146 /* SetAccessor */)) { return getGetAndSetOccurrences(node.parent); } break; default: if (ts.isModifier(node.kind) && node.parent && - (ts.isDeclaration(node.parent) || node.parent.kind === 191 /* VariableStatement */)) { + (ts.isDeclaration(node.parent) || node.parent.kind === 193 /* VariableStatement */)) { return getModifierOccurrences(node.kind, node.parent); } } @@ -45716,10 +46570,10 @@ var ts; aggregate(node); return statementAccumulator; function aggregate(node) { - if (node.kind === 206 /* ThrowStatement */) { + if (node.kind === 208 /* ThrowStatement */) { statementAccumulator.push(node); } - else if (node.kind === 207 /* TryStatement */) { + else if (node.kind === 209 /* TryStatement */) { var tryStatement = node; if (tryStatement.catchClause) { aggregate(tryStatement.catchClause); @@ -45748,12 +46602,12 @@ var ts; var child = throwStatement; while (child.parent) { var parent_12 = child.parent; - if (ts.isFunctionBlock(parent_12) || parent_12.kind === 246 /* SourceFile */) { + if (ts.isFunctionBlock(parent_12) || parent_12.kind === 248 /* SourceFile */) { return parent_12; } // A throw-statement is only owned by a try-statement if the try-statement has // a catch clause, and if the throw-statement occurs within the try block. - if (parent_12.kind === 207 /* TryStatement */) { + if (parent_12.kind === 209 /* TryStatement */) { var tryStatement = parent_12; if (tryStatement.tryBlock === child && tryStatement.catchClause) { return child; @@ -45768,7 +46622,7 @@ var ts; aggregate(node); return statementAccumulator; function aggregate(node) { - if (node.kind === 201 /* BreakStatement */ || node.kind === 200 /* ContinueStatement */) { + if (node.kind === 203 /* BreakStatement */ || node.kind === 202 /* ContinueStatement */) { statementAccumulator.push(node); } else if (!ts.isFunctionLike(node)) { @@ -45784,16 +46638,16 @@ var ts; function getBreakOrContinueOwner(statement) { for (var node_2 = statement.parent; node_2; node_2 = node_2.parent) { switch (node_2.kind) { - case 204 /* SwitchStatement */: - if (statement.kind === 200 /* ContinueStatement */) { + case 206 /* SwitchStatement */: + if (statement.kind === 202 /* ContinueStatement */) { continue; } // Fall through. - case 197 /* ForStatement */: - case 198 /* ForInStatement */: - case 199 /* ForOfStatement */: - case 196 /* WhileStatement */: - case 195 /* DoStatement */: + case 199 /* ForStatement */: + case 200 /* ForInStatement */: + case 201 /* ForOfStatement */: + case 198 /* WhileStatement */: + case 197 /* DoStatement */: if (!statement.label || isLabeledBy(node_2, statement.label.text)) { return node_2; } @@ -45812,24 +46666,24 @@ var ts; var container = declaration.parent; // Make sure we only highlight the keyword when it makes sense to do so. if (ts.isAccessibilityModifier(modifier)) { - if (!(container.kind === 212 /* ClassDeclaration */ || - container.kind === 184 /* ClassExpression */ || - (declaration.kind === 136 /* Parameter */ && hasKind(container, 142 /* Constructor */)))) { + if (!(container.kind === 214 /* ClassDeclaration */ || + container.kind === 186 /* ClassExpression */ || + (declaration.kind === 138 /* Parameter */ && hasKind(container, 144 /* Constructor */)))) { return undefined; } } - else if (modifier === 111 /* StaticKeyword */) { - if (!(container.kind === 212 /* ClassDeclaration */ || container.kind === 184 /* ClassExpression */)) { + else if (modifier === 113 /* StaticKeyword */) { + if (!(container.kind === 214 /* ClassDeclaration */ || container.kind === 186 /* ClassExpression */)) { return undefined; } } - else if (modifier === 80 /* ExportKeyword */ || modifier === 120 /* DeclareKeyword */) { - if (!(container.kind === 217 /* ModuleBlock */ || container.kind === 246 /* SourceFile */)) { + else if (modifier === 82 /* ExportKeyword */ || modifier === 122 /* DeclareKeyword */) { + if (!(container.kind === 219 /* ModuleBlock */ || container.kind === 248 /* SourceFile */)) { return undefined; } } - else if (modifier === 113 /* AbstractKeyword */) { - if (!(container.kind === 212 /* ClassDeclaration */ || declaration.kind === 212 /* ClassDeclaration */)) { + else if (modifier === 115 /* AbstractKeyword */) { + if (!(container.kind === 214 /* ClassDeclaration */ || declaration.kind === 214 /* ClassDeclaration */)) { return undefined; } } @@ -45841,8 +46695,8 @@ var ts; var modifierFlag = getFlagFromModifier(modifier); var nodes; switch (container.kind) { - case 217 /* ModuleBlock */: - case 246 /* SourceFile */: + case 219 /* ModuleBlock */: + case 248 /* SourceFile */: // Container is either a class declaration or the declaration is a classDeclaration if (modifierFlag & 256 /* Abstract */) { nodes = declaration.members.concat(declaration); @@ -45851,17 +46705,17 @@ var ts; nodes = container.statements; } break; - case 142 /* Constructor */: + case 144 /* Constructor */: nodes = container.parameters.concat(container.parent.members); break; - case 212 /* ClassDeclaration */: - case 184 /* ClassExpression */: + case 214 /* ClassDeclaration */: + case 186 /* ClassExpression */: nodes = container.members; // If we're an accessibility modifier, we're in an instance member and should search // the constructor's parameter list for instance members as well. if (modifierFlag & 112 /* AccessibilityModifier */) { var constructor = ts.forEach(container.members, function (member) { - return member.kind === 142 /* Constructor */ && member; + return member.kind === 144 /* Constructor */ && member; }); if (constructor) { nodes = nodes.concat(constructor.parameters); @@ -45882,19 +46736,19 @@ var ts; return ts.map(keywords, getHighlightSpanForNode); function getFlagFromModifier(modifier) { switch (modifier) { - case 110 /* PublicKeyword */: + case 112 /* PublicKeyword */: return 16 /* Public */; - case 108 /* PrivateKeyword */: + case 110 /* PrivateKeyword */: return 32 /* Private */; - case 109 /* ProtectedKeyword */: + case 111 /* ProtectedKeyword */: return 64 /* Protected */; - case 111 /* StaticKeyword */: + case 113 /* StaticKeyword */: return 128 /* Static */; - case 80 /* ExportKeyword */: + case 82 /* ExportKeyword */: return 1 /* Export */; - case 120 /* DeclareKeyword */: + case 122 /* DeclareKeyword */: return 2 /* Ambient */; - case 113 /* AbstractKeyword */: + case 115 /* AbstractKeyword */: return 256 /* Abstract */; default: ts.Debug.fail(); @@ -45914,13 +46768,13 @@ var ts; } function getGetAndSetOccurrences(accessorDeclaration) { var keywords = []; - tryPushAccessorKeyword(accessorDeclaration.symbol, 143 /* GetAccessor */); - tryPushAccessorKeyword(accessorDeclaration.symbol, 144 /* SetAccessor */); + tryPushAccessorKeyword(accessorDeclaration.symbol, 145 /* GetAccessor */); + tryPushAccessorKeyword(accessorDeclaration.symbol, 146 /* SetAccessor */); return ts.map(keywords, getHighlightSpanForNode); function tryPushAccessorKeyword(accessorSymbol, accessorKind) { var accessor = ts.getDeclarationOfKind(accessorSymbol, accessorKind); if (accessor) { - ts.forEach(accessor.getChildren(), function (child) { return pushKeywordIf(keywords, child, 121 /* GetKeyword */, 127 /* SetKeyword */); }); + ts.forEach(accessor.getChildren(), function (child) { return pushKeywordIf(keywords, child, 123 /* GetKeyword */, 129 /* SetKeyword */); }); } } } @@ -45929,19 +46783,19 @@ var ts; var keywords = []; ts.forEach(declarations, function (declaration) { ts.forEach(declaration.getChildren(), function (token) { - return pushKeywordIf(keywords, token, 119 /* ConstructorKeyword */); + return pushKeywordIf(keywords, token, 121 /* ConstructorKeyword */); }); }); return ts.map(keywords, getHighlightSpanForNode); } function getLoopBreakContinueOccurrences(loopNode) { var keywords = []; - if (pushKeywordIf(keywords, loopNode.getFirstToken(), 84 /* ForKeyword */, 102 /* WhileKeyword */, 77 /* DoKeyword */)) { + if (pushKeywordIf(keywords, loopNode.getFirstToken(), 86 /* ForKeyword */, 104 /* WhileKeyword */, 79 /* DoKeyword */)) { // If we succeeded and got a do-while loop, then start looking for a 'while' keyword. - if (loopNode.kind === 195 /* DoStatement */) { + if (loopNode.kind === 197 /* DoStatement */) { var loopTokens = loopNode.getChildren(); for (var i = loopTokens.length - 1; i >= 0; i--) { - if (pushKeywordIf(keywords, loopTokens[i], 102 /* WhileKeyword */)) { + if (pushKeywordIf(keywords, loopTokens[i], 104 /* WhileKeyword */)) { break; } } @@ -45950,7 +46804,7 @@ var ts; var breaksAndContinues = aggregateAllBreakAndContinueStatements(loopNode.statement); ts.forEach(breaksAndContinues, function (statement) { if (ownsBreakOrContinueStatement(loopNode, statement)) { - pushKeywordIf(keywords, statement.getFirstToken(), 68 /* BreakKeyword */, 73 /* ContinueKeyword */); + pushKeywordIf(keywords, statement.getFirstToken(), 70 /* BreakKeyword */, 75 /* ContinueKeyword */); } }); return ts.map(keywords, getHighlightSpanForNode); @@ -45959,13 +46813,13 @@ var ts; var owner = getBreakOrContinueOwner(breakOrContinueStatement); if (owner) { switch (owner.kind) { - case 197 /* ForStatement */: - case 198 /* ForInStatement */: - case 199 /* ForOfStatement */: - case 195 /* DoStatement */: - case 196 /* WhileStatement */: + case 199 /* ForStatement */: + case 200 /* ForInStatement */: + case 201 /* ForOfStatement */: + case 197 /* DoStatement */: + case 198 /* WhileStatement */: return getLoopBreakContinueOccurrences(owner); - case 204 /* SwitchStatement */: + case 206 /* SwitchStatement */: return getSwitchCaseDefaultOccurrences(owner); } } @@ -45973,14 +46827,14 @@ var ts; } function getSwitchCaseDefaultOccurrences(switchStatement) { var keywords = []; - pushKeywordIf(keywords, switchStatement.getFirstToken(), 94 /* SwitchKeyword */); + pushKeywordIf(keywords, switchStatement.getFirstToken(), 96 /* SwitchKeyword */); // Go through each clause in the switch statement, collecting the 'case'/'default' keywords. ts.forEach(switchStatement.caseBlock.clauses, function (clause) { - pushKeywordIf(keywords, clause.getFirstToken(), 69 /* CaseKeyword */, 75 /* DefaultKeyword */); + pushKeywordIf(keywords, clause.getFirstToken(), 71 /* CaseKeyword */, 77 /* DefaultKeyword */); var breaksAndContinues = aggregateAllBreakAndContinueStatements(clause); ts.forEach(breaksAndContinues, function (statement) { if (ownsBreakOrContinueStatement(switchStatement, statement)) { - pushKeywordIf(keywords, statement.getFirstToken(), 68 /* BreakKeyword */); + pushKeywordIf(keywords, statement.getFirstToken(), 70 /* BreakKeyword */); } }); }); @@ -45988,13 +46842,13 @@ var ts; } function getTryCatchFinallyOccurrences(tryStatement) { var keywords = []; - pushKeywordIf(keywords, tryStatement.getFirstToken(), 98 /* TryKeyword */); + pushKeywordIf(keywords, tryStatement.getFirstToken(), 100 /* TryKeyword */); if (tryStatement.catchClause) { - pushKeywordIf(keywords, tryStatement.catchClause.getFirstToken(), 70 /* CatchKeyword */); + pushKeywordIf(keywords, tryStatement.catchClause.getFirstToken(), 72 /* CatchKeyword */); } if (tryStatement.finallyBlock) { - var finallyKeyword = ts.findChildOfKind(tryStatement, 83 /* FinallyKeyword */, sourceFile); - pushKeywordIf(keywords, finallyKeyword, 83 /* FinallyKeyword */); + var finallyKeyword = ts.findChildOfKind(tryStatement, 85 /* FinallyKeyword */, sourceFile); + pushKeywordIf(keywords, finallyKeyword, 85 /* FinallyKeyword */); } return ts.map(keywords, getHighlightSpanForNode); } @@ -46005,13 +46859,13 @@ var ts; } var keywords = []; ts.forEach(aggregateOwnedThrowStatements(owner), function (throwStatement) { - pushKeywordIf(keywords, throwStatement.getFirstToken(), 96 /* ThrowKeyword */); + pushKeywordIf(keywords, throwStatement.getFirstToken(), 98 /* ThrowKeyword */); }); // If the "owner" is a function, then we equate 'return' and 'throw' statements in their // ability to "jump out" of the function, and include occurrences for both. if (ts.isFunctionBlock(owner)) { ts.forEachReturnStatement(owner, function (returnStatement) { - pushKeywordIf(keywords, returnStatement.getFirstToken(), 92 /* ReturnKeyword */); + pushKeywordIf(keywords, returnStatement.getFirstToken(), 94 /* ReturnKeyword */); }); } return ts.map(keywords, getHighlightSpanForNode); @@ -46019,36 +46873,36 @@ var ts; function getReturnOccurrences(returnStatement) { var func = ts.getContainingFunction(returnStatement); // If we didn't find a containing function with a block body, bail out. - if (!(func && hasKind(func.body, 190 /* Block */))) { + if (!(func && hasKind(func.body, 192 /* Block */))) { return undefined; } var keywords = []; ts.forEachReturnStatement(func.body, function (returnStatement) { - pushKeywordIf(keywords, returnStatement.getFirstToken(), 92 /* ReturnKeyword */); + pushKeywordIf(keywords, returnStatement.getFirstToken(), 94 /* ReturnKeyword */); }); // Include 'throw' statements that do not occur within a try block. ts.forEach(aggregateOwnedThrowStatements(func.body), function (throwStatement) { - pushKeywordIf(keywords, throwStatement.getFirstToken(), 96 /* ThrowKeyword */); + pushKeywordIf(keywords, throwStatement.getFirstToken(), 98 /* ThrowKeyword */); }); return ts.map(keywords, getHighlightSpanForNode); } function getIfElseOccurrences(ifStatement) { var keywords = []; // Traverse upwards through all parent if-statements linked by their else-branches. - while (hasKind(ifStatement.parent, 194 /* IfStatement */) && ifStatement.parent.elseStatement === ifStatement) { + while (hasKind(ifStatement.parent, 196 /* IfStatement */) && ifStatement.parent.elseStatement === ifStatement) { ifStatement = ifStatement.parent; } // Now traverse back down through the else branches, aggregating if/else keywords of if-statements. while (ifStatement) { var children = ifStatement.getChildren(); - pushKeywordIf(keywords, children[0], 86 /* IfKeyword */); + pushKeywordIf(keywords, children[0], 88 /* IfKeyword */); // Generally the 'else' keyword is second-to-last, so we traverse backwards. for (var i = children.length - 1; i >= 0; i--) { - if (pushKeywordIf(keywords, children[i], 78 /* ElseKeyword */)) { + if (pushKeywordIf(keywords, children[i], 80 /* ElseKeyword */)) { break; } } - if (!hasKind(ifStatement.elseStatement, 194 /* IfStatement */)) { + if (!hasKind(ifStatement.elseStatement, 196 /* IfStatement */)) { break; } ifStatement = ifStatement.elseStatement; @@ -46057,7 +46911,7 @@ var ts; // We'd like to highlight else/ifs together if they are only separated by whitespace // (i.e. the keywords are separated by no comments, no newlines). for (var i = 0; i < keywords.length; i++) { - if (keywords[i].kind === 78 /* ElseKeyword */ && i < keywords.length - 1) { + if (keywords[i].kind === 80 /* ElseKeyword */ && i < keywords.length - 1) { var elseKeyword = keywords[i]; var ifKeyword = keywords[i + 1]; // this *should* always be an 'if' keyword. var shouldCombindElseAndIf = true; @@ -46139,7 +46993,7 @@ var ts; if (!node) { return undefined; } - if (node.kind !== 67 /* Identifier */ && + if (node.kind !== 69 /* Identifier */ && // TODO (drosen): This should be enabled in a later release - currently breaks rename. //node.kind !== SyntaxKind.ThisKeyword && //node.kind !== SyntaxKind.SuperKeyword && @@ -46147,7 +47001,7 @@ var ts; !isNameOfExternalModuleImportOrDeclaration(node)) { return undefined; } - ts.Debug.assert(node.kind === 67 /* Identifier */ || node.kind === 8 /* NumericLiteral */ || node.kind === 9 /* StringLiteral */); + ts.Debug.assert(node.kind === 69 /* Identifier */ || node.kind === 8 /* NumericLiteral */ || node.kind === 9 /* StringLiteral */); return getReferencedSymbolsForNode(node, program.getSourceFiles(), findInStrings, findInComments); } function getReferencedSymbolsForNode(node, sourceFiles, findInStrings, findInComments) { @@ -46165,10 +47019,10 @@ var ts; return getLabelReferencesInNode(node.parent, node); } } - if (node.kind === 95 /* ThisKeyword */) { + if (node.kind === 97 /* ThisKeyword */) { return getReferencesForThisKeyword(node, sourceFiles); } - if (node.kind === 93 /* SuperKeyword */) { + if (node.kind === 95 /* SuperKeyword */) { return getReferencesForSuperKeyword(node); } var symbol = typeChecker.getSymbolAtLocation(node); @@ -46228,7 +47082,7 @@ var ts; } function isImportOrExportSpecifierImportSymbol(symbol) { return (symbol.flags & 8388608 /* Alias */) && ts.forEach(symbol.declarations, function (declaration) { - return declaration.kind === 224 /* ImportSpecifier */ || declaration.kind === 228 /* ExportSpecifier */; + return declaration.kind === 226 /* ImportSpecifier */ || declaration.kind === 230 /* ExportSpecifier */; }); } function getInternedName(symbol, location, declarations) { @@ -46255,14 +47109,14 @@ var ts; // If this is the symbol of a named function expression or named class expression, // then named references are limited to its own scope. var valueDeclaration = symbol.valueDeclaration; - if (valueDeclaration && (valueDeclaration.kind === 171 /* FunctionExpression */ || valueDeclaration.kind === 184 /* ClassExpression */)) { + if (valueDeclaration && (valueDeclaration.kind === 173 /* FunctionExpression */ || valueDeclaration.kind === 186 /* ClassExpression */)) { return valueDeclaration; } // If this is private property or method, the scope is the containing class if (symbol.flags & (4 /* Property */ | 8192 /* Method */)) { var privateDeclaration = ts.forEach(symbol.getDeclarations(), function (d) { return (d.flags & 32 /* Private */) ? d : undefined; }); if (privateDeclaration) { - return ts.getAncestor(privateDeclaration, 212 /* ClassDeclaration */); + return ts.getAncestor(privateDeclaration, 214 /* ClassDeclaration */); } } // If the symbol is an import we would like to find it if we are looking for what it imports. @@ -46288,7 +47142,7 @@ var ts; // Different declarations have different containers, bail out return undefined; } - if (container.kind === 246 /* SourceFile */ && !ts.isExternalModule(container)) { + if (container.kind === 248 /* SourceFile */ && !ts.isExternalModule(container)) { // This is a global variable and not an external module, any declaration defined // within this scope is visible outside the file return undefined; @@ -46359,7 +47213,7 @@ var ts; if (node) { // Compare the length so we filter out strict superstrings of the symbol we are looking for switch (node.kind) { - case 67 /* Identifier */: + case 69 /* Identifier */: return node.getWidth() === searchSymbolName.length; case 9 /* StringLiteral */: if (isLiteralNameOfPropertyDeclarationOrIndexAccess(node) || @@ -46461,13 +47315,13 @@ var ts; // Whether 'super' occurs in a static context within a class. var staticFlag = 128 /* Static */; switch (searchSpaceNode.kind) { - case 139 /* PropertyDeclaration */: - case 138 /* PropertySignature */: - case 141 /* MethodDeclaration */: - case 140 /* MethodSignature */: - case 142 /* Constructor */: - case 143 /* GetAccessor */: - case 144 /* SetAccessor */: + case 141 /* PropertyDeclaration */: + case 140 /* PropertySignature */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: + case 144 /* Constructor */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: staticFlag &= searchSpaceNode.flags; searchSpaceNode = searchSpaceNode.parent; // re-assign to be the owning class break; @@ -46480,7 +47334,7 @@ var ts; ts.forEach(possiblePositions, function (position) { cancellationToken.throwIfCancellationRequested(); var node = ts.getTouchingWord(sourceFile, position); - if (!node || node.kind !== 93 /* SuperKeyword */) { + if (!node || node.kind !== 95 /* SuperKeyword */) { return; } var container = ts.getSuperContainer(node, /*includeFunctions*/ false); @@ -46499,27 +47353,27 @@ var ts; // Whether 'this' occurs in a static context within a class. var staticFlag = 128 /* Static */; switch (searchSpaceNode.kind) { - case 141 /* MethodDeclaration */: - case 140 /* MethodSignature */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: if (ts.isObjectLiteralMethod(searchSpaceNode)) { break; } // fall through - case 139 /* PropertyDeclaration */: - case 138 /* PropertySignature */: - case 142 /* Constructor */: - case 143 /* GetAccessor */: - case 144 /* SetAccessor */: + case 141 /* PropertyDeclaration */: + case 140 /* PropertySignature */: + case 144 /* Constructor */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: staticFlag &= searchSpaceNode.flags; searchSpaceNode = searchSpaceNode.parent; // re-assign to be the owning class break; - case 246 /* SourceFile */: + case 248 /* SourceFile */: if (ts.isExternalModule(searchSpaceNode)) { return undefined; } // Fall through - case 211 /* FunctionDeclaration */: - case 171 /* FunctionExpression */: + case 213 /* FunctionDeclaration */: + case 173 /* FunctionExpression */: break; // Computed properties in classes are not handled here because references to this are illegal, // so there is no point finding references to them. @@ -46528,7 +47382,7 @@ var ts; } var references = []; var possiblePositions; - if (searchSpaceNode.kind === 246 /* SourceFile */) { + if (searchSpaceNode.kind === 248 /* SourceFile */) { ts.forEach(sourceFiles, function (sourceFile) { possiblePositions = getPossibleSymbolReferencePositions(sourceFile, "this", sourceFile.getStart(), sourceFile.getEnd()); getThisReferencesInFile(sourceFile, sourceFile, possiblePositions, references); @@ -46554,33 +47408,33 @@ var ts; ts.forEach(possiblePositions, function (position) { cancellationToken.throwIfCancellationRequested(); var node = ts.getTouchingWord(sourceFile, position); - if (!node || node.kind !== 95 /* ThisKeyword */) { + if (!node || node.kind !== 97 /* ThisKeyword */) { return; } var container = ts.getThisContainer(node, /* includeArrowFunctions */ false); switch (searchSpaceNode.kind) { - case 171 /* FunctionExpression */: - case 211 /* FunctionDeclaration */: + case 173 /* FunctionExpression */: + case 213 /* FunctionDeclaration */: if (searchSpaceNode.symbol === container.symbol) { result.push(getReferenceEntryFromNode(node)); } break; - case 141 /* MethodDeclaration */: - case 140 /* MethodSignature */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: if (ts.isObjectLiteralMethod(searchSpaceNode) && searchSpaceNode.symbol === container.symbol) { result.push(getReferenceEntryFromNode(node)); } break; - case 184 /* ClassExpression */: - case 212 /* ClassDeclaration */: + case 186 /* ClassExpression */: + case 214 /* ClassDeclaration */: // Make sure the container belongs to the same class // and has the appropriate static modifier from the original container. if (container.parent && searchSpaceNode.symbol === container.parent.symbol && (container.flags & 128 /* Static */) === staticFlag) { result.push(getReferenceEntryFromNode(node)); } break; - case 246 /* SourceFile */: - if (container.kind === 246 /* SourceFile */ && !ts.isExternalModule(container)) { + case 248 /* SourceFile */: + if (container.kind === 248 /* SourceFile */ && !ts.isExternalModule(container)) { result.push(getReferenceEntryFromNode(node)); } break; @@ -46634,11 +47488,11 @@ var ts; function getPropertySymbolsFromBaseTypes(symbol, propertyName, result) { if (symbol && symbol.flags & (32 /* Class */ | 64 /* Interface */)) { ts.forEach(symbol.getDeclarations(), function (declaration) { - if (declaration.kind === 212 /* ClassDeclaration */) { + if (declaration.kind === 214 /* ClassDeclaration */) { getPropertySymbolFromTypeReference(ts.getClassExtendsHeritageClauseElement(declaration)); ts.forEach(ts.getClassImplementsHeritageClauseElements(declaration), getPropertySymbolFromTypeReference); } - else if (declaration.kind === 213 /* InterfaceDeclaration */) { + else if (declaration.kind === 215 /* InterfaceDeclaration */) { ts.forEach(ts.getInterfaceBaseTypeNodes(declaration), getPropertySymbolFromTypeReference); } }); @@ -46699,19 +47553,19 @@ var ts; if (isNameOfPropertyAssignment(node)) { var objectLiteral = node.parent.parent; var contextualType = typeChecker.getContextualType(objectLiteral); - var name_33 = node.text; + var name_34 = node.text; if (contextualType) { if (contextualType.flags & 16384 /* Union */) { // This is a union type, first see if the property we are looking for is a union property (i.e. exists in all types) // if not, search the constituent types for the property - var unionProperty = contextualType.getProperty(name_33); + var unionProperty = contextualType.getProperty(name_34); if (unionProperty) { return [unionProperty]; } else { var result_4 = []; ts.forEach(contextualType.types, function (t) { - var symbol = t.getProperty(name_33); + var symbol = t.getProperty(name_34); if (symbol) { result_4.push(symbol); } @@ -46720,7 +47574,7 @@ var ts; } } else { - var symbol_1 = contextualType.getProperty(name_33); + var symbol_1 = contextualType.getProperty(name_34); if (symbol_1) { return [symbol_1]; } @@ -46773,17 +47627,17 @@ var ts; } /** A node is considered a writeAccess iff it is a name of a declaration or a target of an assignment */ function isWriteAccess(node) { - if (node.kind === 67 /* Identifier */ && ts.isDeclarationName(node)) { + if (node.kind === 69 /* Identifier */ && ts.isDeclarationName(node)) { return true; } var parent = node.parent; if (parent) { - if (parent.kind === 178 /* PostfixUnaryExpression */ || parent.kind === 177 /* PrefixUnaryExpression */) { + if (parent.kind === 180 /* PostfixUnaryExpression */ || parent.kind === 179 /* PrefixUnaryExpression */) { return true; } - else if (parent.kind === 179 /* BinaryExpression */ && parent.left === node) { + else if (parent.kind === 181 /* BinaryExpression */ && parent.left === node) { var operator = parent.operatorToken.kind; - return 55 /* FirstAssignment */ <= operator && operator <= 66 /* LastAssignment */; + return 56 /* FirstAssignment */ <= operator && operator <= 68 /* LastAssignment */; } } return false; @@ -46815,33 +47669,33 @@ var ts; } function getMeaningFromDeclaration(node) { switch (node.kind) { - case 136 /* Parameter */: - case 209 /* VariableDeclaration */: - case 161 /* BindingElement */: - case 139 /* PropertyDeclaration */: - case 138 /* PropertySignature */: - case 243 /* PropertyAssignment */: - case 244 /* ShorthandPropertyAssignment */: - case 245 /* EnumMember */: - case 141 /* MethodDeclaration */: - case 140 /* MethodSignature */: - case 142 /* Constructor */: - case 143 /* GetAccessor */: - case 144 /* SetAccessor */: - case 211 /* FunctionDeclaration */: - case 171 /* FunctionExpression */: - case 172 /* ArrowFunction */: - case 242 /* CatchClause */: + case 138 /* Parameter */: + case 211 /* VariableDeclaration */: + case 163 /* BindingElement */: + case 141 /* PropertyDeclaration */: + case 140 /* PropertySignature */: + case 245 /* PropertyAssignment */: + case 246 /* ShorthandPropertyAssignment */: + case 247 /* EnumMember */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: + case 144 /* Constructor */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: + case 213 /* FunctionDeclaration */: + case 173 /* FunctionExpression */: + case 174 /* ArrowFunction */: + case 244 /* CatchClause */: return 1 /* Value */; - case 135 /* TypeParameter */: - case 213 /* InterfaceDeclaration */: - case 214 /* TypeAliasDeclaration */: - case 153 /* TypeLiteral */: + case 137 /* TypeParameter */: + case 215 /* InterfaceDeclaration */: + case 216 /* TypeAliasDeclaration */: + case 155 /* TypeLiteral */: return 2 /* Type */; - case 212 /* ClassDeclaration */: - case 215 /* EnumDeclaration */: + case 214 /* ClassDeclaration */: + case 217 /* EnumDeclaration */: return 1 /* Value */ | 2 /* Type */; - case 216 /* ModuleDeclaration */: + case 218 /* ModuleDeclaration */: if (node.name.kind === 9 /* StringLiteral */) { return 4 /* Namespace */ | 1 /* Value */; } @@ -46851,15 +47705,15 @@ var ts; else { return 4 /* Namespace */; } - case 223 /* NamedImports */: - case 224 /* ImportSpecifier */: - case 219 /* ImportEqualsDeclaration */: - case 220 /* ImportDeclaration */: - case 225 /* ExportAssignment */: - case 226 /* ExportDeclaration */: + case 225 /* NamedImports */: + case 226 /* ImportSpecifier */: + case 221 /* ImportEqualsDeclaration */: + case 222 /* ImportDeclaration */: + case 227 /* ExportAssignment */: + case 228 /* ExportDeclaration */: return 1 /* Value */ | 2 /* Type */ | 4 /* Namespace */; // An external module can be a Value - case 246 /* SourceFile */: + case 248 /* SourceFile */: return 4 /* Namespace */ | 1 /* Value */; } return 1 /* Value */ | 2 /* Type */ | 4 /* Namespace */; @@ -46869,8 +47723,9 @@ var ts; if (ts.isRightSideOfQualifiedNameOrPropertyAccess(node)) { node = node.parent; } - return node.parent.kind === 149 /* TypeReference */ || - (node.parent.kind === 186 /* ExpressionWithTypeArguments */ && !ts.isExpressionWithTypeArgumentsInClassExtendsClause(node.parent)); + return node.parent.kind === 151 /* TypeReference */ || + (node.parent.kind === 188 /* ExpressionWithTypeArguments */ && !ts.isExpressionWithTypeArgumentsInClassExtendsClause(node.parent)) || + node.kind === 97 /* ThisKeyword */ && !ts.isExpression(node); } function isNamespaceReference(node) { return isQualifiedNameNamespaceReference(node) || isPropertyAccessNamespaceReference(node); @@ -46878,50 +47733,50 @@ var ts; function isPropertyAccessNamespaceReference(node) { var root = node; var isLastClause = true; - if (root.parent.kind === 164 /* PropertyAccessExpression */) { - while (root.parent && root.parent.kind === 164 /* PropertyAccessExpression */) { + if (root.parent.kind === 166 /* PropertyAccessExpression */) { + while (root.parent && root.parent.kind === 166 /* PropertyAccessExpression */) { root = root.parent; } isLastClause = root.name === node; } - if (!isLastClause && root.parent.kind === 186 /* ExpressionWithTypeArguments */ && root.parent.parent.kind === 241 /* HeritageClause */) { + if (!isLastClause && root.parent.kind === 188 /* ExpressionWithTypeArguments */ && root.parent.parent.kind === 243 /* HeritageClause */) { var decl = root.parent.parent.parent; - return (decl.kind === 212 /* ClassDeclaration */ && root.parent.parent.token === 104 /* ImplementsKeyword */) || - (decl.kind === 213 /* InterfaceDeclaration */ && root.parent.parent.token === 81 /* ExtendsKeyword */); + return (decl.kind === 214 /* ClassDeclaration */ && root.parent.parent.token === 106 /* ImplementsKeyword */) || + (decl.kind === 215 /* InterfaceDeclaration */ && root.parent.parent.token === 83 /* ExtendsKeyword */); } return false; } function isQualifiedNameNamespaceReference(node) { var root = node; var isLastClause = true; - if (root.parent.kind === 133 /* QualifiedName */) { - while (root.parent && root.parent.kind === 133 /* QualifiedName */) { + if (root.parent.kind === 135 /* QualifiedName */) { + while (root.parent && root.parent.kind === 135 /* QualifiedName */) { root = root.parent; } isLastClause = root.right === node; } - return root.parent.kind === 149 /* TypeReference */ && !isLastClause; + return root.parent.kind === 151 /* TypeReference */ && !isLastClause; } function isInRightSideOfImport(node) { - while (node.parent.kind === 133 /* QualifiedName */) { + while (node.parent.kind === 135 /* QualifiedName */) { node = node.parent; } return ts.isInternalModuleImportEqualsDeclaration(node.parent) && node.parent.moduleReference === node; } function getMeaningFromRightHandSideOfImportEquals(node) { - ts.Debug.assert(node.kind === 67 /* Identifier */); + ts.Debug.assert(node.kind === 69 /* Identifier */); // import a = |b|; // Namespace // import a = |b.c|; // Value, type, namespace // import a = |b.c|.d; // Namespace - if (node.parent.kind === 133 /* QualifiedName */ && + if (node.parent.kind === 135 /* QualifiedName */ && node.parent.right === node && - node.parent.parent.kind === 219 /* ImportEqualsDeclaration */) { + node.parent.parent.kind === 221 /* ImportEqualsDeclaration */) { return 1 /* Value */ | 2 /* Type */ | 4 /* Namespace */; } return 4 /* Namespace */; } function getMeaningFromLocation(node) { - if (node.parent.kind === 225 /* ExportAssignment */) { + if (node.parent.kind === 227 /* ExportAssignment */) { return 1 /* Value */ | 2 /* Type */ | 4 /* Namespace */; } else if (isInRightSideOfImport(node)) { @@ -46961,15 +47816,15 @@ var ts; return; } switch (node.kind) { - case 164 /* PropertyAccessExpression */: - case 133 /* QualifiedName */: + case 166 /* PropertyAccessExpression */: + case 135 /* QualifiedName */: case 9 /* StringLiteral */: - case 82 /* FalseKeyword */: - case 97 /* TrueKeyword */: - case 91 /* NullKeyword */: - case 93 /* SuperKeyword */: - case 95 /* ThisKeyword */: - case 67 /* Identifier */: + case 84 /* FalseKeyword */: + case 99 /* TrueKeyword */: + case 93 /* NullKeyword */: + case 95 /* SuperKeyword */: + case 97 /* ThisKeyword */: + case 69 /* Identifier */: break; // Cant create the text span default: @@ -46985,7 +47840,7 @@ var ts; // If this is name of a module declarations, check if this is right side of dotted module name // If parent of the module declaration which is parent of this node is module declaration and its body is the module declaration that this node is name of // Then this name is name from dotted module - if (nodeForStartPos.parent.parent.kind === 216 /* ModuleDeclaration */ && + if (nodeForStartPos.parent.parent.kind === 218 /* ModuleDeclaration */ && nodeForStartPos.parent.parent.body === nodeForStartPos.parent) { // Use parent module declarations name for start pos nodeForStartPos = nodeForStartPos.parent.parent.name; @@ -47026,10 +47881,10 @@ var ts; // That means we're calling back into the host around every 1.2k of the file we process. // Lib.d.ts has similar numbers. switch (kind) { - case 216 /* ModuleDeclaration */: - case 212 /* ClassDeclaration */: - case 213 /* InterfaceDeclaration */: - case 211 /* FunctionDeclaration */: + case 218 /* ModuleDeclaration */: + case 214 /* ClassDeclaration */: + case 215 /* InterfaceDeclaration */: + case 213 /* FunctionDeclaration */: cancellationToken.throwIfCancellationRequested(); } } @@ -47083,7 +47938,7 @@ var ts; */ function hasValueSideModule(symbol) { return ts.forEach(symbol.declarations, function (declaration) { - return declaration.kind === 216 /* ModuleDeclaration */ && + return declaration.kind === 218 /* ModuleDeclaration */ && ts.getModuleInstanceState(declaration) === 1 /* Instantiated */; }); } @@ -47093,7 +47948,7 @@ var ts; if (node && ts.textSpanIntersectsWith(span, node.getFullStart(), node.getFullWidth())) { var kind = node.kind; checkForClassificationCancellation(kind); - if (kind === 67 /* Identifier */ && !ts.nodeIsMissing(node)) { + if (kind === 69 /* Identifier */ && !ts.nodeIsMissing(node)) { var identifier = node; // Only bother calling into the typechecker if this is an identifier that // could possibly resolve to a type name. This makes classification run @@ -47238,16 +48093,16 @@ var ts; pushClassification(tag.tagName.pos, tag.tagName.end - tag.tagName.pos, 18 /* docCommentTagName */); pos = tag.tagName.end; switch (tag.kind) { - case 265 /* JSDocParameterTag */: + case 267 /* JSDocParameterTag */: processJSDocParameterTag(tag); break; - case 268 /* JSDocTemplateTag */: + case 270 /* JSDocTemplateTag */: processJSDocTemplateTag(tag); break; - case 267 /* JSDocTypeTag */: + case 269 /* JSDocTypeTag */: processElement(tag.typeExpression); break; - case 266 /* JSDocReturnTag */: + case 268 /* JSDocReturnTag */: processElement(tag.typeExpression); break; } @@ -47336,18 +48191,18 @@ var ts; } if (ts.isPunctuation(tokenKind)) { if (token) { - if (tokenKind === 55 /* EqualsToken */) { + if (tokenKind === 56 /* EqualsToken */) { // the '=' in a variable declaration is special cased here. - if (token.parent.kind === 209 /* VariableDeclaration */ || - token.parent.kind === 139 /* PropertyDeclaration */ || - token.parent.kind === 136 /* Parameter */) { + if (token.parent.kind === 211 /* VariableDeclaration */ || + token.parent.kind === 141 /* PropertyDeclaration */ || + token.parent.kind === 138 /* Parameter */) { return 5 /* operator */; } } - if (token.parent.kind === 179 /* BinaryExpression */ || - token.parent.kind === 177 /* PrefixUnaryExpression */ || - token.parent.kind === 178 /* PostfixUnaryExpression */ || - token.parent.kind === 180 /* ConditionalExpression */) { + if (token.parent.kind === 181 /* BinaryExpression */ || + token.parent.kind === 179 /* PrefixUnaryExpression */ || + token.parent.kind === 180 /* PostfixUnaryExpression */ || + token.parent.kind === 182 /* ConditionalExpression */) { return 5 /* operator */; } } @@ -47367,35 +48222,35 @@ var ts; // TODO (drosen): we should *also* get another classification type for these literals. return 6 /* stringLiteral */; } - else if (tokenKind === 67 /* Identifier */) { + else if (tokenKind === 69 /* Identifier */) { if (token) { switch (token.parent.kind) { - case 212 /* ClassDeclaration */: + case 214 /* ClassDeclaration */: if (token.parent.name === token) { return 11 /* className */; } return; - case 135 /* TypeParameter */: + case 137 /* TypeParameter */: if (token.parent.name === token) { return 15 /* typeParameterName */; } return; - case 213 /* InterfaceDeclaration */: + case 215 /* InterfaceDeclaration */: if (token.parent.name === token) { return 13 /* interfaceName */; } return; - case 215 /* EnumDeclaration */: + case 217 /* EnumDeclaration */: if (token.parent.name === token) { return 12 /* enumName */; } return; - case 216 /* ModuleDeclaration */: + case 218 /* ModuleDeclaration */: if (token.parent.name === token) { return 14 /* moduleName */; } return; - case 136 /* Parameter */: + case 138 /* Parameter */: if (token.parent.name === token) { return 17 /* parameterName */; } @@ -47507,8 +48362,12 @@ var ts; * Checks if position points to a valid position to add JSDoc comments, and if so, * returns the appropriate template. Otherwise returns an empty string. * Valid positions are - * - outside of comments, statements, and expressions, and - * - preceding a function declaration. + * - outside of comments, statements, and expressions, and + * - preceding a: + * - function/constructor/method declaration + * - class declarations + * - variable statements + * - namespace declarations * * Hosts should ideally check that: * - The line is all whitespace up to 'position' before performing the insertion. @@ -47532,23 +48391,48 @@ var ts; return undefined; } // TODO: add support for: - // - methods - // - constructors - // - class decls - var containingFunction = ts.getAncestor(tokenAtPos, 211 /* FunctionDeclaration */); - if (!containingFunction || containingFunction.getStart() < position) { + // - enums/enum members + // - interfaces + // - property declarations + // - potentially property assignments + var commentOwner; + findOwner: for (commentOwner = tokenAtPos; commentOwner; commentOwner = commentOwner.parent) { + switch (commentOwner.kind) { + case 213 /* FunctionDeclaration */: + case 143 /* MethodDeclaration */: + case 144 /* Constructor */: + case 214 /* ClassDeclaration */: + case 193 /* VariableStatement */: + break findOwner; + case 248 /* SourceFile */: + return undefined; + case 218 /* ModuleDeclaration */: + // If in walking up the tree, we hit a a nested namespace declaration, + // then we must be somewhere within a dotted namespace name; however we don't + // want to give back a JSDoc template for the 'b' or 'c' in 'namespace a.b.c { }'. + if (commentOwner.parent.kind === 218 /* ModuleDeclaration */) { + return undefined; + } + break findOwner; + } + } + if (!commentOwner || commentOwner.getStart() < position) { return undefined; } - var parameters = containingFunction.parameters; + var parameters = getParametersForJsDocOwningNode(commentOwner); var posLineAndChar = sourceFile.getLineAndCharacterOfPosition(position); var lineStart = sourceFile.getLineStarts()[posLineAndChar.line]; var indentationStr = sourceFile.text.substr(lineStart, posLineAndChar.character); // TODO: call a helper method instead once PR #4133 gets merged in. var newLine = host.getNewLine ? host.getNewLine() : "\r\n"; - var docParams = parameters.reduce(function (prev, cur, index) { - return prev + - indentationStr + " * @param " + (cur.name.kind === 67 /* Identifier */ ? cur.name.text : "param" + index) + newLine; - }, ""); + var docParams = ""; + for (var i = 0, numParams = parameters.length; i < numParams; i++) { + var currentName = parameters[i].name; + var paramName = currentName.kind === 69 /* Identifier */ ? + currentName.text : + "param" + i; + docParams += indentationStr + " * @param " + paramName + newLine; + } // A doc comment consists of the following // * The opening comment line // * the first line (without a param) for the object's untagged info (this is also where the caret ends up) @@ -47564,6 +48448,46 @@ var ts; (tokenStart === position ? newLine + indentationStr : ""); return { newText: result, caretOffset: preamble.length }; } + function getParametersForJsDocOwningNode(commentOwner) { + if (ts.isFunctionLike(commentOwner)) { + return commentOwner.parameters; + } + if (commentOwner.kind === 193 /* VariableStatement */) { + var varStatement = commentOwner; + var varDeclarations = varStatement.declarationList.declarations; + if (varDeclarations.length === 1 && varDeclarations[0].initializer) { + return getParametersFromRightHandSideOfAssignment(varDeclarations[0].initializer); + } + } + return emptyArray; + } + /** + * Digs into an an initializer or RHS operand of an assignment operation + * to get the parameters of an apt signature corresponding to a + * function expression or a class expression. + * + * @param rightHandSide the expression which may contain an appropriate set of parameters + * @returns the parameters of a signature found on the RHS if one exists; otherwise 'emptyArray'. + */ + function getParametersFromRightHandSideOfAssignment(rightHandSide) { + while (rightHandSide.kind === 172 /* ParenthesizedExpression */) { + rightHandSide = rightHandSide.expression; + } + switch (rightHandSide.kind) { + case 173 /* FunctionExpression */: + case 174 /* ArrowFunction */: + return rightHandSide.parameters; + case 186 /* ClassExpression */: + for (var _i = 0, _a = rightHandSide.members; _i < _a.length; _i++) { + var member = _a[_i]; + if (member.kind === 144 /* Constructor */) { + return member.parameters; + } + } + break; + } + return emptyArray; + } function getTodoComments(fileName, descriptors) { // Note: while getting todo comments seems like a syntactic operation, we actually // treat it as a semantic operation here. This is because we expect our host to call @@ -47694,7 +48618,7 @@ var ts; var typeChecker = program.getTypeChecker(); var node = ts.getTouchingWord(sourceFile, position); // Can only rename an identifier. - if (node && node.kind === 67 /* Identifier */) { + if (node && node.kind === 69 /* Identifier */) { var symbol = typeChecker.getSymbolAtLocation(node); // Only allow a symbol to be renamed if it actually has at least one declaration. if (symbol) { @@ -47795,7 +48719,7 @@ var ts; sourceFile.nameTable = nameTable; function walk(node) { switch (node.kind) { - case 67 /* Identifier */: + case 69 /* Identifier */: nameTable[node.text] = node.text; break; case 9 /* StringLiteral */: @@ -47805,7 +48729,7 @@ var ts; // then we want 'something' to be in the name table. Similarly, if we have // "a['propname']" then we want to store "propname" in the name table. if (ts.isDeclarationName(node) || - node.parent.kind === 230 /* ExternalModuleReference */ || + node.parent.kind === 232 /* ExternalModuleReference */ || isArgumentOfElementAccessExpression(node)) { nameTable[node.text] = node.text; } @@ -47818,7 +48742,7 @@ var ts; function isArgumentOfElementAccessExpression(node) { return node && node.parent && - node.parent.kind === 165 /* ElementAccessExpression */ && + node.parent.kind === 167 /* ElementAccessExpression */ && node.parent.argumentExpression === node; } /// Classifier @@ -47829,18 +48753,18 @@ var ts; /// we have a series of divide operator. this list allows us to be more accurate by ruling out /// locations where a regexp cannot exist. var noRegexTable = []; - noRegexTable[67 /* Identifier */] = true; + noRegexTable[69 /* Identifier */] = true; noRegexTable[9 /* StringLiteral */] = true; noRegexTable[8 /* NumericLiteral */] = true; noRegexTable[10 /* RegularExpressionLiteral */] = true; - noRegexTable[95 /* ThisKeyword */] = true; - noRegexTable[40 /* PlusPlusToken */] = true; - noRegexTable[41 /* MinusMinusToken */] = true; + noRegexTable[97 /* ThisKeyword */] = true; + noRegexTable[41 /* PlusPlusToken */] = true; + noRegexTable[42 /* MinusMinusToken */] = true; noRegexTable[18 /* CloseParenToken */] = true; noRegexTable[20 /* CloseBracketToken */] = true; noRegexTable[16 /* CloseBraceToken */] = true; - noRegexTable[97 /* TrueKeyword */] = true; - noRegexTable[82 /* FalseKeyword */] = true; + noRegexTable[99 /* TrueKeyword */] = true; + noRegexTable[84 /* FalseKeyword */] = true; // Just a stack of TemplateHeads and OpenCurlyBraces, used to perform rudimentary (inexact) // classification on template strings. Because of the context free nature of templates, // the only precise way to classify a template portion would be by propagating the stack across @@ -47865,10 +48789,10 @@ var ts; /** Returns true if 'keyword2' can legally follow 'keyword1' in any language construct. */ function canFollow(keyword1, keyword2) { if (ts.isAccessibilityModifier(keyword1)) { - if (keyword2 === 121 /* GetKeyword */ || - keyword2 === 127 /* SetKeyword */ || - keyword2 === 119 /* ConstructorKeyword */ || - keyword2 === 111 /* StaticKeyword */) { + if (keyword2 === 123 /* GetKeyword */ || + keyword2 === 129 /* SetKeyword */ || + keyword2 === 121 /* ConstructorKeyword */ || + keyword2 === 113 /* StaticKeyword */) { // Allow things like "public get", "public constructor" and "public static". // These are all legal. return true; @@ -47998,22 +48922,22 @@ var ts; do { token = scanner.scan(); if (!ts.isTrivia(token)) { - if ((token === 38 /* SlashToken */ || token === 59 /* SlashEqualsToken */) && !noRegexTable[lastNonTriviaToken]) { + if ((token === 39 /* SlashToken */ || token === 61 /* SlashEqualsToken */) && !noRegexTable[lastNonTriviaToken]) { if (scanner.reScanSlashToken() === 10 /* RegularExpressionLiteral */) { token = 10 /* RegularExpressionLiteral */; } } else if (lastNonTriviaToken === 21 /* DotToken */ && isKeyword(token)) { - token = 67 /* Identifier */; + token = 69 /* Identifier */; } else if (isKeyword(lastNonTriviaToken) && isKeyword(token) && !canFollow(lastNonTriviaToken, token)) { // We have two keywords in a row. Only treat the second as a keyword if // it's a sequence that could legally occur in the language. Otherwise // treat it as an identifier. This way, if someone writes "private var" // we recognize that 'var' is actually an identifier here. - token = 67 /* Identifier */; + token = 69 /* Identifier */; } - else if (lastNonTriviaToken === 67 /* Identifier */ && + else if (lastNonTriviaToken === 69 /* Identifier */ && token === 25 /* LessThanToken */) { // Could be the start of something generic. Keep track of that by bumping // up the current count of generic contexts we may be in. @@ -48024,16 +48948,16 @@ var ts; // generic entity is complete. angleBracketStack--; } - else if (token === 115 /* AnyKeyword */ || - token === 128 /* StringKeyword */ || - token === 126 /* NumberKeyword */ || - token === 118 /* BooleanKeyword */ || - token === 129 /* SymbolKeyword */) { + else if (token === 117 /* AnyKeyword */ || + token === 130 /* StringKeyword */ || + token === 128 /* NumberKeyword */ || + token === 120 /* BooleanKeyword */ || + token === 131 /* SymbolKeyword */) { if (angleBracketStack > 0 && !syntacticClassifierAbsent) { // If it looks like we're could be in something generic, don't classify this // as a keyword. We may just get overwritten by the syntactic classifier, // causing a noisy experience for the user. - token = 67 /* Identifier */; + token = 69 /* Identifier */; } } else if (token === 12 /* TemplateHead */) { @@ -48145,40 +49069,41 @@ var ts; function isBinaryExpressionOperatorToken(token) { switch (token) { case 37 /* AsteriskToken */: - case 38 /* SlashToken */: - case 39 /* PercentToken */: + case 39 /* SlashToken */: + case 40 /* PercentToken */: case 35 /* PlusToken */: case 36 /* MinusToken */: - case 42 /* LessThanLessThanToken */: - case 43 /* GreaterThanGreaterThanToken */: - case 44 /* GreaterThanGreaterThanGreaterThanToken */: + case 43 /* LessThanLessThanToken */: + case 44 /* GreaterThanGreaterThanToken */: + case 45 /* GreaterThanGreaterThanGreaterThanToken */: case 25 /* LessThanToken */: case 27 /* GreaterThanToken */: case 28 /* LessThanEqualsToken */: case 29 /* GreaterThanEqualsToken */: - case 89 /* InstanceOfKeyword */: - case 88 /* InKeyword */: + case 91 /* InstanceOfKeyword */: + case 90 /* InKeyword */: + case 116 /* AsKeyword */: case 30 /* EqualsEqualsToken */: case 31 /* ExclamationEqualsToken */: case 32 /* EqualsEqualsEqualsToken */: case 33 /* ExclamationEqualsEqualsToken */: - case 45 /* AmpersandToken */: - case 47 /* CaretToken */: - case 46 /* BarToken */: - case 50 /* AmpersandAmpersandToken */: - case 51 /* BarBarToken */: - case 65 /* BarEqualsToken */: - case 64 /* AmpersandEqualsToken */: - case 66 /* CaretEqualsToken */: - case 61 /* LessThanLessThanEqualsToken */: - case 62 /* GreaterThanGreaterThanEqualsToken */: - case 63 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 56 /* PlusEqualsToken */: - case 57 /* MinusEqualsToken */: - case 58 /* AsteriskEqualsToken */: - case 59 /* SlashEqualsToken */: - case 60 /* PercentEqualsToken */: - case 55 /* EqualsToken */: + case 46 /* AmpersandToken */: + case 48 /* CaretToken */: + case 47 /* BarToken */: + case 51 /* AmpersandAmpersandToken */: + case 52 /* BarBarToken */: + case 67 /* BarEqualsToken */: + case 66 /* AmpersandEqualsToken */: + case 68 /* CaretEqualsToken */: + case 63 /* LessThanLessThanEqualsToken */: + case 64 /* GreaterThanGreaterThanEqualsToken */: + case 65 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + case 57 /* PlusEqualsToken */: + case 58 /* MinusEqualsToken */: + case 59 /* AsteriskEqualsToken */: + case 61 /* SlashEqualsToken */: + case 62 /* PercentEqualsToken */: + case 56 /* EqualsToken */: case 24 /* CommaToken */: return true; default: @@ -48189,17 +49114,17 @@ var ts; switch (token) { case 35 /* PlusToken */: case 36 /* MinusToken */: - case 49 /* TildeToken */: - case 48 /* ExclamationToken */: - case 40 /* PlusPlusToken */: - case 41 /* MinusMinusToken */: + case 50 /* TildeToken */: + case 49 /* ExclamationToken */: + case 41 /* PlusPlusToken */: + case 42 /* MinusMinusToken */: return true; default: return false; } } function isKeyword(token) { - return token >= 68 /* FirstKeyword */ && token <= 132 /* LastKeyword */; + return token >= 70 /* FirstKeyword */ && token <= 134 /* LastKeyword */; } function classFromKind(token) { if (isKeyword(token)) { @@ -48208,7 +49133,7 @@ var ts; else if (isBinaryExpressionOperatorToken(token) || isPrefixUnaryExpressionOperatorToken(token)) { return 5 /* operator */; } - else if (token >= 15 /* FirstPunctuation */ && token <= 66 /* LastPunctuation */) { + else if (token >= 15 /* FirstPunctuation */ && token <= 68 /* LastPunctuation */) { return 10 /* punctuation */; } switch (token) { @@ -48225,7 +49150,7 @@ var ts; case 5 /* WhitespaceTrivia */: case 4 /* NewLineTrivia */: return 8 /* whiteSpace */; - case 67 /* Identifier */: + case 69 /* Identifier */: default: if (ts.isTemplateLiteralKind(token)) { return 6 /* stringLiteral */; @@ -48257,7 +49182,7 @@ var ts; getNodeConstructor: function (kind) { function Node() { } - var proto = kind === 246 /* SourceFile */ ? new SourceFileObject() : new NodeObject(); + var proto = kind === 248 /* SourceFile */ ? new SourceFileObject() : new NodeObject(); proto.kind = kind; proto.pos = -1; proto.end = -1; @@ -48327,125 +49252,125 @@ var ts; function spanInNode(node) { if (node) { if (ts.isExpression(node)) { - if (node.parent.kind === 195 /* DoStatement */) { + if (node.parent.kind === 197 /* DoStatement */) { // Set span as if on while keyword return spanInPreviousNode(node); } - if (node.parent.kind === 197 /* ForStatement */) { + if (node.parent.kind === 199 /* ForStatement */) { // For now lets set the span on this expression, fix it later return textSpan(node); } - if (node.parent.kind === 179 /* BinaryExpression */ && node.parent.operatorToken.kind === 24 /* CommaToken */) { + if (node.parent.kind === 181 /* BinaryExpression */ && node.parent.operatorToken.kind === 24 /* CommaToken */) { // if this is comma expression, the breakpoint is possible in this expression return textSpan(node); } - if (node.parent.kind === 172 /* ArrowFunction */ && node.parent.body === node) { + if (node.parent.kind === 174 /* ArrowFunction */ && node.parent.body === node) { // If this is body of arrow function, it is allowed to have the breakpoint return textSpan(node); } } switch (node.kind) { - case 191 /* VariableStatement */: + case 193 /* VariableStatement */: // Span on first variable declaration return spanInVariableDeclaration(node.declarationList.declarations[0]); - case 209 /* VariableDeclaration */: - case 139 /* PropertyDeclaration */: - case 138 /* PropertySignature */: + case 211 /* VariableDeclaration */: + case 141 /* PropertyDeclaration */: + case 140 /* PropertySignature */: return spanInVariableDeclaration(node); - case 136 /* Parameter */: + case 138 /* Parameter */: return spanInParameterDeclaration(node); - case 211 /* FunctionDeclaration */: - case 141 /* MethodDeclaration */: - case 140 /* MethodSignature */: - case 143 /* GetAccessor */: - case 144 /* SetAccessor */: - case 142 /* Constructor */: - case 171 /* FunctionExpression */: - case 172 /* ArrowFunction */: + case 213 /* FunctionDeclaration */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: + case 144 /* Constructor */: + case 173 /* FunctionExpression */: + case 174 /* ArrowFunction */: return spanInFunctionDeclaration(node); - case 190 /* Block */: + case 192 /* Block */: if (ts.isFunctionBlock(node)) { return spanInFunctionBlock(node); } // Fall through - case 217 /* ModuleBlock */: + case 219 /* ModuleBlock */: return spanInBlock(node); - case 242 /* CatchClause */: + case 244 /* CatchClause */: return spanInBlock(node.block); - case 193 /* ExpressionStatement */: + case 195 /* ExpressionStatement */: // span on the expression return textSpan(node.expression); - case 202 /* ReturnStatement */: + case 204 /* ReturnStatement */: // span on return keyword and expression if present return textSpan(node.getChildAt(0), node.expression); - case 196 /* WhileStatement */: + case 198 /* WhileStatement */: // Span on while(...) return textSpan(node, ts.findNextToken(node.expression, node)); - case 195 /* DoStatement */: + case 197 /* DoStatement */: // span in statement of the do statement return spanInNode(node.statement); - case 208 /* DebuggerStatement */: + case 210 /* DebuggerStatement */: // span on debugger keyword return textSpan(node.getChildAt(0)); - case 194 /* IfStatement */: + case 196 /* IfStatement */: // set on if(..) span return textSpan(node, ts.findNextToken(node.expression, node)); - case 205 /* LabeledStatement */: + case 207 /* LabeledStatement */: // span in statement return spanInNode(node.statement); - case 201 /* BreakStatement */: - case 200 /* ContinueStatement */: + case 203 /* BreakStatement */: + case 202 /* ContinueStatement */: // On break or continue keyword and label if present return textSpan(node.getChildAt(0), node.label); - case 197 /* ForStatement */: + case 199 /* ForStatement */: return spanInForStatement(node); - case 198 /* ForInStatement */: - case 199 /* ForOfStatement */: + case 200 /* ForInStatement */: + case 201 /* ForOfStatement */: // span on for (a in ...) return textSpan(node, ts.findNextToken(node.expression, node)); - case 204 /* SwitchStatement */: + case 206 /* SwitchStatement */: // span on switch(...) return textSpan(node, ts.findNextToken(node.expression, node)); - case 239 /* CaseClause */: - case 240 /* DefaultClause */: + case 241 /* CaseClause */: + case 242 /* DefaultClause */: // span in first statement of the clause return spanInNode(node.statements[0]); - case 207 /* TryStatement */: + case 209 /* TryStatement */: // span in try block return spanInBlock(node.tryBlock); - case 206 /* ThrowStatement */: + case 208 /* ThrowStatement */: // span in throw ... return textSpan(node, node.expression); - case 225 /* ExportAssignment */: + case 227 /* ExportAssignment */: // span on export = id return textSpan(node, node.expression); - case 219 /* ImportEqualsDeclaration */: + case 221 /* ImportEqualsDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleReference); - case 220 /* ImportDeclaration */: + case 222 /* ImportDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleSpecifier); - case 226 /* ExportDeclaration */: + case 228 /* ExportDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleSpecifier); - case 216 /* ModuleDeclaration */: + case 218 /* ModuleDeclaration */: // span on complete module if it is instantiated if (ts.getModuleInstanceState(node) !== 1 /* Instantiated */) { return undefined; } - case 212 /* ClassDeclaration */: - case 215 /* EnumDeclaration */: - case 245 /* EnumMember */: - case 166 /* CallExpression */: - case 167 /* NewExpression */: + case 214 /* ClassDeclaration */: + case 217 /* EnumDeclaration */: + case 247 /* EnumMember */: + case 168 /* CallExpression */: + case 169 /* NewExpression */: // span on complete node return textSpan(node); - case 203 /* WithStatement */: + case 205 /* WithStatement */: // span in statement return spanInNode(node.statement); // No breakpoint in interface, type alias - case 213 /* InterfaceDeclaration */: - case 214 /* TypeAliasDeclaration */: + case 215 /* InterfaceDeclaration */: + case 216 /* TypeAliasDeclaration */: return undefined; // Tokens: case 23 /* SemicolonToken */: @@ -48461,25 +49386,25 @@ var ts; return spanInOpenParenToken(node); case 18 /* CloseParenToken */: return spanInCloseParenToken(node); - case 53 /* ColonToken */: + case 54 /* ColonToken */: return spanInColonToken(node); case 27 /* GreaterThanToken */: case 25 /* LessThanToken */: return spanInGreaterThanOrLessThanToken(node); // Keywords: - case 102 /* WhileKeyword */: + case 104 /* WhileKeyword */: return spanInWhileKeyword(node); - case 78 /* ElseKeyword */: - case 70 /* CatchKeyword */: - case 83 /* FinallyKeyword */: + case 80 /* ElseKeyword */: + case 72 /* CatchKeyword */: + case 85 /* FinallyKeyword */: return spanInNextNode(node); default: // If this is name of property assignment, set breakpoint in the initializer - if (node.parent.kind === 243 /* PropertyAssignment */ && node.parent.name === node) { + if (node.parent.kind === 245 /* PropertyAssignment */ && node.parent.name === node) { return spanInNode(node.parent.initializer); } // Breakpoint in type assertion goes to its operand - if (node.parent.kind === 169 /* TypeAssertionExpression */ && node.parent.type === node) { + if (node.parent.kind === 171 /* TypeAssertionExpression */ && node.parent.type === node) { return spanInNode(node.parent.expression); } // return type of function go to previous token @@ -48492,12 +49417,12 @@ var ts; } function spanInVariableDeclaration(variableDeclaration) { // If declaration of for in statement, just set the span in parent - if (variableDeclaration.parent.parent.kind === 198 /* ForInStatement */ || - variableDeclaration.parent.parent.kind === 199 /* ForOfStatement */) { + if (variableDeclaration.parent.parent.kind === 200 /* ForInStatement */ || + variableDeclaration.parent.parent.kind === 201 /* ForOfStatement */) { return spanInNode(variableDeclaration.parent.parent); } - var isParentVariableStatement = variableDeclaration.parent.parent.kind === 191 /* VariableStatement */; - var isDeclarationOfForStatement = variableDeclaration.parent.parent.kind === 197 /* ForStatement */ && ts.contains(variableDeclaration.parent.parent.initializer.declarations, variableDeclaration); + var isParentVariableStatement = variableDeclaration.parent.parent.kind === 193 /* VariableStatement */; + var isDeclarationOfForStatement = variableDeclaration.parent.parent.kind === 199 /* ForStatement */ && ts.contains(variableDeclaration.parent.parent.initializer.declarations, variableDeclaration); var declarations = isParentVariableStatement ? variableDeclaration.parent.parent.declarationList.declarations : isDeclarationOfForStatement @@ -48551,7 +49476,7 @@ var ts; } function canFunctionHaveSpanInWholeDeclaration(functionDeclaration) { return !!(functionDeclaration.flags & 1 /* Export */) || - (functionDeclaration.parent.kind === 212 /* ClassDeclaration */ && functionDeclaration.kind !== 142 /* Constructor */); + (functionDeclaration.parent.kind === 214 /* ClassDeclaration */ && functionDeclaration.kind !== 144 /* Constructor */); } function spanInFunctionDeclaration(functionDeclaration) { // No breakpoints in the function signature @@ -48574,18 +49499,18 @@ var ts; } function spanInBlock(block) { switch (block.parent.kind) { - case 216 /* ModuleDeclaration */: + case 218 /* ModuleDeclaration */: if (ts.getModuleInstanceState(block.parent) !== 1 /* Instantiated */) { return undefined; } // Set on parent if on same line otherwise on first statement - case 196 /* WhileStatement */: - case 194 /* IfStatement */: - case 198 /* ForInStatement */: - case 199 /* ForOfStatement */: + case 198 /* WhileStatement */: + case 196 /* IfStatement */: + case 200 /* ForInStatement */: + case 201 /* ForOfStatement */: return spanInNodeIfStartsOnSameLine(block.parent, block.statements[0]); // Set span on previous token if it starts on same line otherwise on the first statement of the block - case 197 /* ForStatement */: + case 199 /* ForStatement */: return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(block.pos, sourceFile, block.parent), block.statements[0]); } // Default action is to set on first statement @@ -48593,7 +49518,7 @@ var ts; } function spanInForStatement(forStatement) { if (forStatement.initializer) { - if (forStatement.initializer.kind === 210 /* VariableDeclarationList */) { + if (forStatement.initializer.kind === 212 /* VariableDeclarationList */) { var variableDeclarationList = forStatement.initializer; if (variableDeclarationList.declarations.length > 0) { return spanInNode(variableDeclarationList.declarations[0]); @@ -48613,13 +49538,13 @@ var ts; // Tokens: function spanInOpenBraceToken(node) { switch (node.parent.kind) { - case 215 /* EnumDeclaration */: + case 217 /* EnumDeclaration */: var enumDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), enumDeclaration.members.length ? enumDeclaration.members[0] : enumDeclaration.getLastToken(sourceFile)); - case 212 /* ClassDeclaration */: + case 214 /* ClassDeclaration */: var classDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), classDeclaration.members.length ? classDeclaration.members[0] : classDeclaration.getLastToken(sourceFile)); - case 218 /* CaseBlock */: + case 220 /* CaseBlock */: return spanInNodeIfStartsOnSameLine(node.parent.parent, node.parent.clauses[0]); } // Default to parent node @@ -48627,25 +49552,25 @@ var ts; } function spanInCloseBraceToken(node) { switch (node.parent.kind) { - case 217 /* ModuleBlock */: + case 219 /* ModuleBlock */: // If this is not instantiated module block no bp span if (ts.getModuleInstanceState(node.parent.parent) !== 1 /* Instantiated */) { return undefined; } - case 215 /* EnumDeclaration */: - case 212 /* ClassDeclaration */: + case 217 /* EnumDeclaration */: + case 214 /* ClassDeclaration */: // Span on close brace token return textSpan(node); - case 190 /* Block */: + case 192 /* Block */: if (ts.isFunctionBlock(node.parent)) { // Span on close brace token return textSpan(node); } // fall through. - case 242 /* CatchClause */: + case 244 /* CatchClause */: return spanInNode(ts.lastOrUndefined(node.parent.statements)); ; - case 218 /* CaseBlock */: + case 220 /* CaseBlock */: // breakpoint in last statement of the last clause var caseBlock = node.parent; var lastClause = ts.lastOrUndefined(caseBlock.clauses); @@ -48659,7 +49584,7 @@ var ts; } } function spanInOpenParenToken(node) { - if (node.parent.kind === 195 /* DoStatement */) { + if (node.parent.kind === 197 /* DoStatement */) { // Go to while keyword and do action instead return spanInPreviousNode(node); } @@ -48669,17 +49594,17 @@ var ts; function spanInCloseParenToken(node) { // Is this close paren token of parameter list, set span in previous token switch (node.parent.kind) { - case 171 /* FunctionExpression */: - case 211 /* FunctionDeclaration */: - case 172 /* ArrowFunction */: - case 141 /* MethodDeclaration */: - case 140 /* MethodSignature */: - case 143 /* GetAccessor */: - case 144 /* SetAccessor */: - case 142 /* Constructor */: - case 196 /* WhileStatement */: - case 195 /* DoStatement */: - case 197 /* ForStatement */: + case 173 /* FunctionExpression */: + case 213 /* FunctionDeclaration */: + case 174 /* ArrowFunction */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: + case 144 /* Constructor */: + case 198 /* WhileStatement */: + case 197 /* DoStatement */: + case 199 /* ForStatement */: return spanInPreviousNode(node); // Default to parent node default: @@ -48690,19 +49615,19 @@ var ts; } function spanInColonToken(node) { // Is this : specifying return annotation of the function declaration - if (ts.isFunctionLike(node.parent) || node.parent.kind === 243 /* PropertyAssignment */) { + if (ts.isFunctionLike(node.parent) || node.parent.kind === 245 /* PropertyAssignment */) { return spanInPreviousNode(node); } return spanInNode(node.parent); } function spanInGreaterThanOrLessThanToken(node) { - if (node.parent.kind === 169 /* TypeAssertionExpression */) { + if (node.parent.kind === 171 /* TypeAssertionExpression */) { return spanInNode(node.parent.expression); } return spanInNode(node.parent); } function spanInWhileKeyword(node) { - if (node.parent.kind === 195 /* DoStatement */) { + if (node.parent.kind === 197 /* DoStatement */) { // Set span on while expression return textSpan(node, ts.findNextToken(node.parent.expression, node.parent)); } @@ -49339,7 +50264,8 @@ var ts; }; CoreServicesShimObject.prototype.getPreProcessedFileInfo = function (fileName, sourceTextSnapshot) { return this.forwardJSONCall("getPreProcessedFileInfo('" + fileName + "')", function () { - var result = ts.preProcessFile(sourceTextSnapshot.getText(0, sourceTextSnapshot.getLength())); + // for now treat files as JavaScript + var result = ts.preProcessFile(sourceTextSnapshot.getText(0, sourceTextSnapshot.getLength()), /* readImportFiles */ true, /* detectJavaScriptImports */ true); var convertResult = { referencedFiles: [], importedFiles: [], From 7a4e995f018632044133b7c50f157276aac493bd Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Tue, 20 Oct 2015 15:14:18 -0700 Subject: [PATCH 074/227] feedback form pr --- Jakefile.js | 3 +- src/compiler/declarationEmitter.ts | 4 +- src/compiler/emitter.ts | 4 +- src/compiler/utilities.ts | 96 +++++++++++++++++------------- 4 files changed, 61 insertions(+), 46 deletions(-) diff --git a/Jakefile.js b/Jakefile.js index 505ccf99384..be80edb0a67 100644 --- a/Jakefile.js +++ b/Jakefile.js @@ -247,7 +247,8 @@ function compileFile(outFile, sources, prereqs, prefixes, useBuiltCompiler, noOu if (!noOutFile) { options += " --out " + outFile; - } else { + } + else { options += " --module commonjs" } diff --git a/src/compiler/declarationEmitter.ts b/src/compiler/declarationEmitter.ts index c3d611f131c..fb1ccf5714a 100644 --- a/src/compiler/declarationEmitter.ts +++ b/src/compiler/declarationEmitter.ts @@ -731,7 +731,7 @@ namespace ts { } let match: RegExpMatchArray; if ((!root) && node.moduleSpecifier.kind === SyntaxKind.StringLiteral && (match = getTextOfNode(node.moduleSpecifier).match(/('|")(\.\/|\.\.\/)/))) { - write(makeModulePathSemiabsolute(host, currentSourceFile, getTextOfNode(node.moduleSpecifier))); + write(makeModulePathSemiAbsolute(host, currentSourceFile, getTextOfNode(node.moduleSpecifier))); } else { writeTextOfNode(currentSourceFile, node.moduleSpecifier); @@ -773,7 +773,7 @@ namespace ts { write(" from "); let match: RegExpMatchArray; if ((!root) && node.moduleSpecifier.kind === SyntaxKind.StringLiteral && (match = getTextOfNode(node.moduleSpecifier).match(/('|")(\.\/|\.\.\/)/))) { - write(makeModulePathSemiabsolute(host, currentSourceFile, getTextOfNode(node.moduleSpecifier))); + write(makeModulePathSemiAbsolute(host, currentSourceFile, getTextOfNode(node.moduleSpecifier))); } else { writeTextOfNode(currentSourceFile, node.moduleSpecifier); diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index 71c4f11e8c9..d62cec73bd9 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -6766,7 +6766,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi } if (resolvePath) { - text = makeModulePathSemiabsolute(host, currentSourceFile, text); + text = makeModulePathSemiAbsolute(host, currentSourceFile, text); } write(text); } @@ -6813,7 +6813,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi let externalModuleName = getExternalModuleNameText(importNode); if (resolvePath) { - externalModuleName = makeModulePathSemiabsolute(host, currentSourceFile, externalModuleName); + externalModuleName = makeModulePathSemiAbsolute(host, currentSourceFile, externalModuleName); } // Find the name of the module alias, if there is one diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 7af0d0ea7e9..e3537ddffc9 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -1608,42 +1608,34 @@ namespace ts { } } + let baseCharsMap: Map = { + "\0": "\\0", + "\t": "\\t", + "\v": "\\v", + "\f": "\\f", + "\b": "\\b", + "\r": "\\r", + "\n": "\\n", + "\\": "\\\\", + "\u2028": "\\u2028", // lineSeparator + "\u2029": "\\u2029", // paragraphSeparator + "\u0085": "\\u0085" // nextLine + } + // This consists of the first 19 unprintable ASCII characters, canonical escapes, lineSeparator, // paragraphSeparator, and nextLine. The latter three are just desirable to suppress new lines in // the language service. These characters should be escaped when printing, and if any characters are added, // the map below must be updated. Note that this regexp *does not* include the 'delete' character. // There is no reason for this other than that JSON.stringify does not handle it either. let escapedCharsRegExp = /[\\\"\u0000-\u001f\t\v\f\b\r\n\u2028\u2029\u0085]/g; - let escapedCharsMap: Map = { - "\0": "\\0", - "\t": "\\t", - "\v": "\\v", - "\f": "\\f", - "\b": "\\b", - "\r": "\\r", - "\n": "\\n", - "\\": "\\\\", - "\"": "\\\"", - "\u2028": "\\u2028", // lineSeparator - "\u2029": "\\u2029", // paragraphSeparator - "\u0085": "\\u0085" // nextLine - }; + let escapedCharsMap: Map = extend(baseCharsMap, { + "\"": "\\\"" + }); let singleQuoteEscapedCharsRegExp = /[\\\'\u0000-\u001f\t\v\f\b\r\n\u2028\u2029\u0085]/g; - let singleQuoteEscapedCharsMap: Map = { - "\0": "\\0", - "\t": "\\t", - "\v": "\\v", - "\f": "\\f", - "\b": "\\b", - "\r": "\\r", - "\n": "\\n", - "\\": "\\\\", - "\'": "\\\'", - "\u2028": "\\u2028", // lineSeparator - "\u2029": "\\u2029", // paragraphSeparator - "\u0085": "\\u0085" // nextLine - }; + let singleQuoteEscapedCharsMap: Map = extend(baseCharsMap, { + "\'": "\\\'" + }); /** * Based heavily on the abstract 'Quote'/'QuoteJSONString' operation from ECMA-262 (24.3.2.2), @@ -1651,12 +1643,28 @@ namespace ts { * Note that this doesn't actually wrap the input in double quotes. */ export function escapeString(s: string): string { - return escapeStringByQuote(s, "\""); + return escapeStringByQuote(s, QuotationMark.Double); } - export function escapeStringByQuote(s: string, quotemark: string): string { - let regex = quotemark === "'" ? singleQuoteEscapedCharsRegExp : escapedCharsRegExp; - let replacementMap = quotemark === "'" ? singleQuoteEscapedCharsMap : escapedCharsMap; + export const enum QuotationMark { + Double, + Single + } + + export var QuotationMarkLookup: Map = { + [QuotationMark.Double]: "\"", + [QuotationMark.Single]: "'", + "\"": QuotationMark.Double.toString(), + "'": QuotationMark.Single.toString(), + }; + + /** + * A generalization of the escape function described by escapeString configuable to handle + * either single quotes or double quotes + */ + export function escapeStringByQuote(s: string, quoteMark: QuotationMark): string { + let regex = quoteMark === QuotationMark.Single ? singleQuoteEscapedCharsRegExp : escapedCharsRegExp; + let replacementMap = quoteMark === QuotationMark.Single ? singleQuoteEscapedCharsMap : escapedCharsMap; s = regex.test(s) ? s.replace(regex, getReplacement) : s; @@ -1667,8 +1675,12 @@ namespace ts { } } - export function quoteString(s: string, quotemark: string): string { - return quotemark + escapeStringByQuote(s, quotemark) + quotemark; + /** + * Quotes a given string akin to the abstract Quote operation from ECMA-262 (24.3.2.2) + * with the specified quotation mark + */ + export function quoteString(s: string, quotemark: QuotationMark): string { + return QuotationMarkLookup[quotemark] + escapeStringByQuote(s, quotemark) + QuotationMarkLookup[quotemark]; } export function isIntrinsicJsxName(name: string) { @@ -1784,22 +1796,24 @@ namespace ts { }; } - export function makeModulePathSemiabsolute(host: EmitHost, currentSourceFile: SourceFile, externalModuleName: string): string { - let quotemark = externalModuleName.charAt(0); + export function makeModulePathSemiAbsolute(host: EmitHost, currentSourceFile: SourceFile, externalModuleName: string): string { + let quotationMark = externalModuleName.charAt(0); let unquotedModuleName = externalModuleName.substring(1, externalModuleName.length - 1); let resolvedFileName = host.resolveModuleName(unquotedModuleName, currentSourceFile.fileName); if (resolvedFileName) { - let semiabsoluteName = resolveToSemiabsolutePath(host, resolvedFileName); - externalModuleName = quoteString(semiabsoluteName, quotemark); + let semiAbsoluteName = resolveToSemiabsolutePath(host, resolvedFileName); + externalModuleName = quoteString(semiAbsoluteName, parseInt(QuotationMarkLookup[quotationMark])); } return externalModuleName; } + /** + * Resolves a local path to a path which is absolute to the base of the emit + */ export function resolveToSemiabsolutePath(host: EmitHost, path: string): string { let dir = host.getCurrentDirectory(); - return removeFileExtension( - getRelativePathToDirectoryOrUrl(dir, path, dir, f => host.getCanonicalFileName(f), /*isAbsolutePathAnUrl*/false) - ); + let relativePath = getRelativePathToDirectoryOrUrl(dir, path, dir, f => host.getCanonicalFileName(f), /*isAbsolutePathAnUrl*/ false); + return removeFileExtension(relativePath); } export function getOwnEmitOutputFilePath(sourceFile: SourceFile, host: EmitHost, extension: string) { From 79cf984a83067e4e580927374e698c1b71793136 Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Tue, 20 Oct 2015 15:14:28 -0700 Subject: [PATCH 075/227] feedback form pr --- src/compiler/utilities.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index e3537ddffc9..cc7f1ce5d3e 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -1620,7 +1620,7 @@ namespace ts { "\u2028": "\\u2028", // lineSeparator "\u2029": "\\u2029", // paragraphSeparator "\u0085": "\\u0085" // nextLine - } + }; // This consists of the first 19 unprintable ASCII characters, canonical escapes, lineSeparator, // paragraphSeparator, and nextLine. The latter three are just desirable to suppress new lines in @@ -1650,7 +1650,7 @@ namespace ts { Double, Single } - + export var QuotationMarkLookup: Map = { [QuotationMark.Double]: "\"", [QuotationMark.Single]: "'", From d178945cd47fae104ba7b9718ed04766bfddab76 Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Tue, 20 Oct 2015 15:29:21 -0700 Subject: [PATCH 076/227] rename variable --- src/compiler/utilities.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index cc7f1ce5d3e..d95d53f97ef 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -1662,9 +1662,9 @@ namespace ts { * A generalization of the escape function described by escapeString configuable to handle * either single quotes or double quotes */ - export function escapeStringByQuote(s: string, quoteMark: QuotationMark): string { - let regex = quoteMark === QuotationMark.Single ? singleQuoteEscapedCharsRegExp : escapedCharsRegExp; - let replacementMap = quoteMark === QuotationMark.Single ? singleQuoteEscapedCharsMap : escapedCharsMap; + export function escapeStringByQuote(s: string, quotationMark: QuotationMark): string { + let regex = quotationMark === QuotationMark.Single ? singleQuoteEscapedCharsRegExp : escapedCharsRegExp; + let replacementMap = quotationMark === QuotationMark.Single ? singleQuoteEscapedCharsMap : escapedCharsMap; s = regex.test(s) ? s.replace(regex, getReplacement) : s; From 37bc2773a3a23d39b42a5c93d899662494f39277 Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Wed, 21 Oct 2015 15:27:33 -0700 Subject: [PATCH 077/227] feedback form pr --- src/compiler/checker.ts | 3 +- src/compiler/declarationEmitter.ts | 35 ++++++++------ src/compiler/emitter.ts | 18 ++++++-- src/compiler/program.ts | 52 ++++++++++----------- src/compiler/types.ts | 1 + src/compiler/utilities.ts | 74 +++++------------------------- src/harness/projectsRunner.ts | 2 +- 7 files changed, 75 insertions(+), 110 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 04cc9a2e426..de7f3e45346 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -14867,7 +14867,8 @@ namespace ts { collectLinkedAliases, getReferencedValueDeclaration, getTypeReferenceSerializationKind, - isOptionalParameter + isOptionalParameter, + getSymbolAtLocation }; } diff --git a/src/compiler/declarationEmitter.ts b/src/compiler/declarationEmitter.ts index fb1ccf5714a..82983dab394 100644 --- a/src/compiler/declarationEmitter.ts +++ b/src/compiler/declarationEmitter.ts @@ -729,17 +729,30 @@ namespace ts { } write(" from "); } - let match: RegExpMatchArray; - if ((!root) && node.moduleSpecifier.kind === SyntaxKind.StringLiteral && (match = getTextOfNode(node.moduleSpecifier).match(/('|")(\.\/|\.\.\/)/))) { - write(makeModulePathSemiAbsolute(host, currentSourceFile, getTextOfNode(node.moduleSpecifier))); - } - else { - writeTextOfNode(currentSourceFile, node.moduleSpecifier); - } + emitExternalModuleSpecifier(node.moduleSpecifier); write(";"); writer.writeLine(); } + function emitExternalModuleSpecifier(moduleSpecifier: Expression) { + Debug.assert(moduleSpecifier.kind === SyntaxKind.StringLiteral); + + if ((!root) && (compilerOptions.out || compilerOptions.outFile)) { + let moduleSymbol = resolver.getSymbolAtLocation(moduleSpecifier); + if (moduleSymbol && moduleSymbol.valueDeclaration && + moduleSymbol.valueDeclaration.kind === SyntaxKind.SourceFile && + !isDeclarationFile(moduleSymbol.valueDeclaration)) { + let nonRelativeModuleName = getExternalModuleNameFromPath(host, (moduleSymbol.valueDeclaration as SourceFile).fileName); + write("\""); + write(nonRelativeModuleName); + write("\""); + return; + } + } + + writeTextOfNode(currentSourceFile, moduleSpecifier); + } + function emitImportOrExportSpecifier(node: ImportOrExportSpecifier) { if (node.propertyName) { writeTextOfNode(currentSourceFile, node.propertyName); @@ -771,13 +784,7 @@ namespace ts { } if (node.moduleSpecifier) { write(" from "); - let match: RegExpMatchArray; - if ((!root) && node.moduleSpecifier.kind === SyntaxKind.StringLiteral && (match = getTextOfNode(node.moduleSpecifier).match(/('|")(\.\/|\.\.\/)/))) { - write(makeModulePathSemiAbsolute(host, currentSourceFile, getTextOfNode(node.moduleSpecifier))); - } - else { - writeTextOfNode(currentSourceFile, node.moduleSpecifier); - } + emitExternalModuleSpecifier(node.moduleSpecifier); } write(";"); writer.writeLine(); diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index d62cec73bd9..278bf026603 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -497,7 +497,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi function emitConcatenatedModule(sourceFile: SourceFile): void { currentSourceFile = sourceFile; exportFunctionForFile = undefined; - let canonicalName = resolveToSemiabsolutePath(host, sourceFile.fileName); + let canonicalName = getExternalModuleNameFromPath(host, sourceFile.fileName); sourceFile.moduleName = sourceFile.moduleName || canonicalName; emit(sourceFile); } @@ -6766,7 +6766,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi } if (resolvePath) { - text = makeModulePathSemiAbsolute(host, currentSourceFile, text); + text = `"${lookupSpecifierName(externalImports[i])}"`; } write(text); } @@ -6782,6 +6782,18 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi write("});"); } + function lookupSpecifierName(declaration: ImportEqualsDeclaration | ImportDeclaration | ExportDeclaration): string { + let specifier: Node; + if (declaration.kind === SyntaxKind.ImportEqualsDeclaration) { + specifier = (declaration as ImportEqualsDeclaration).moduleReference; + } + else { + specifier = (declaration as ImportDeclaration|ExportDeclaration).moduleSpecifier; + } + let moduleSymbol = resolver.getSymbolAtLocation(specifier); + return getExternalModuleNameFromPath(host, (moduleSymbol.valueDeclaration as SourceFile).fileName); + } + interface AMDDependencyNames { aliasedModuleNames: string[]; unaliasedModuleNames: string[]; @@ -6813,7 +6825,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi let externalModuleName = getExternalModuleNameText(importNode); if (resolvePath) { - externalModuleName = makeModulePathSemiAbsolute(host, currentSourceFile, externalModuleName); + externalModuleName = `"${lookupSpecifierName(importNode)}"`; } // Find the name of the module alias, if there is one diff --git a/src/compiler/program.ts b/src/compiler/program.ts index bf4acc92675..7d4a116eebc 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -372,29 +372,6 @@ namespace ts { } } - // there has to be common source directory if user specified --outdir || --sourceRoot - // if user specified --mapRoot, there needs to be common source directory if there would be multiple files being emitted - if (options.outDir || // there is --outDir specified - options.sourceRoot || // there is --sourceRoot specified - options.mapRoot) { // there is --mapRoot specified - - if (options.rootDir && checkSourceFilesBelongToPath(files, options.rootDir)) { - // If a rootDir is specified and is valid use it as the commonSourceDirectory - commonSourceDirectory = getNormalizedAbsolutePath(options.rootDir, host.getCurrentDirectory()); - } - else { - // Compute the commonSourceDirectory from the input files - commonSourceDirectory = computeCommonSourceDirectory(files); - } - - if (commonSourceDirectory && commonSourceDirectory[commonSourceDirectory.length - 1] !== directorySeparator) { - // Make sure directory path ends with directory separator so this string can directly - // used to replace with "" to get the relative path of the source file and the relative path doesn't - // start with / making it rooted path - commonSourceDirectory += directorySeparator; - } - } - verifyCompilerOptions(); // unconditionally set oldProgram to undefined to prevent it from being captured in closure @@ -540,12 +517,6 @@ namespace ts { getSourceFiles: program.getSourceFiles, writeFile: writeFileCallback || ( (fileName, data, writeByteOrderMark, onError) => host.writeFile(fileName, data, writeByteOrderMark, onError)), - resolveModuleName: (name: string, containingFile?: string) => { - let resolvedModule = resolveModuleNamesWorker([name], containingFile || "dummy.ts")[0]; - if (!resolvedModule) - return; - return resolvedModule.resolvedFileName; - }, }; } @@ -1063,6 +1034,29 @@ namespace ts { programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Only_amd_and_system_modules_are_supported_alongside_0, options.out ? "out" : "outFile")); } + // there has to be common source directory if user specified --outdir || --sourceRoot + // if user specified --mapRoot, there needs to be common source directory if there would be multiple files being emitted + if (options.outDir || // there is --outDir specified + options.sourceRoot || // there is --sourceRoot specified + options.mapRoot) { // there is --mapRoot specified + + if (options.rootDir && checkSourceFilesBelongToPath(files, options.rootDir)) { + // If a rootDir is specified and is valid use it as the commonSourceDirectory + commonSourceDirectory = getNormalizedAbsolutePath(options.rootDir, host.getCurrentDirectory()); + } + else { + // Compute the commonSourceDirectory from the input files + commonSourceDirectory = computeCommonSourceDirectory(files); + } + + if (commonSourceDirectory && commonSourceDirectory[commonSourceDirectory.length - 1] !== directorySeparator) { + // Make sure directory path ends with directory separator so this string can directly + // used to replace with "" to get the relative path of the source file and the relative path doesn't + // start with / making it rooted path + commonSourceDirectory += directorySeparator; + } + } + if (options.noEmit) { if (options.out) { programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_with_option_1, "noEmit", "out")); diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 2818ef04a48..fb6e237dd39 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -1611,6 +1611,7 @@ namespace ts { getReferencedValueDeclaration(reference: Identifier): Declaration; getTypeReferenceSerializationKind(typeName: EntityName): TypeReferenceSerializationKind; isOptionalParameter(node: ParameterDeclaration): boolean; + getSymbolAtLocation(node: Node): Symbol; } export const enum SymbolFlags { diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index d95d53f97ef..24916c2e106 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -40,7 +40,6 @@ namespace ts { getNewLine(): string; writeFile: WriteFileCallback; - resolveModuleName(path: string, containingFile?: string): string; } // Pool writers to avoid needing to allocate them for every symbol we write. @@ -1608,7 +1607,13 @@ namespace ts { } } - let baseCharsMap: Map = { + // This consists of the first 19 unprintable ASCII characters, canonical escapes, lineSeparator, + // paragraphSeparator, and nextLine. The latter three are just desirable to suppress new lines in + // the language service. These characters should be escaped when printing, and if any characters are added, + // the map below must be updated. Note that this regexp *does not* include the 'delete' character. + // There is no reason for this other than that JSON.stringify does not handle it either. + let escapedCharsRegExp = /[\\\"\u0000-\u001f\t\v\f\b\r\n\u2028\u2029\u0085]/g; + let escapedCharsMap: Map = { "\0": "\\0", "\t": "\\t", "\v": "\\v", @@ -1617,25 +1622,12 @@ namespace ts { "\r": "\\r", "\n": "\\n", "\\": "\\\\", + "\"": "\\\"", "\u2028": "\\u2028", // lineSeparator "\u2029": "\\u2029", // paragraphSeparator "\u0085": "\\u0085" // nextLine }; - // This consists of the first 19 unprintable ASCII characters, canonical escapes, lineSeparator, - // paragraphSeparator, and nextLine. The latter three are just desirable to suppress new lines in - // the language service. These characters should be escaped when printing, and if any characters are added, - // the map below must be updated. Note that this regexp *does not* include the 'delete' character. - // There is no reason for this other than that JSON.stringify does not handle it either. - let escapedCharsRegExp = /[\\\"\u0000-\u001f\t\v\f\b\r\n\u2028\u2029\u0085]/g; - let escapedCharsMap: Map = extend(baseCharsMap, { - "\"": "\\\"" - }); - - let singleQuoteEscapedCharsRegExp = /[\\\'\u0000-\u001f\t\v\f\b\r\n\u2028\u2029\u0085]/g; - let singleQuoteEscapedCharsMap: Map = extend(baseCharsMap, { - "\'": "\\\'" - }); /** * Based heavily on the abstract 'Quote'/'QuoteJSONString' operation from ECMA-262 (24.3.2.2), @@ -1643,46 +1635,15 @@ namespace ts { * Note that this doesn't actually wrap the input in double quotes. */ export function escapeString(s: string): string { - return escapeStringByQuote(s, QuotationMark.Double); - } - - export const enum QuotationMark { - Double, - Single - } - - export var QuotationMarkLookup: Map = { - [QuotationMark.Double]: "\"", - [QuotationMark.Single]: "'", - "\"": QuotationMark.Double.toString(), - "'": QuotationMark.Single.toString(), - }; - - /** - * A generalization of the escape function described by escapeString configuable to handle - * either single quotes or double quotes - */ - export function escapeStringByQuote(s: string, quotationMark: QuotationMark): string { - let regex = quotationMark === QuotationMark.Single ? singleQuoteEscapedCharsRegExp : escapedCharsRegExp; - let replacementMap = quotationMark === QuotationMark.Single ? singleQuoteEscapedCharsMap : escapedCharsMap; - - s = regex.test(s) ? s.replace(regex, getReplacement) : s; + s = escapedCharsRegExp.test(s) ? s.replace(escapedCharsRegExp, getReplacement) : s; return s; function getReplacement(c: string) { - return replacementMap[c] || get16BitUnicodeEscapeSequence(c.charCodeAt(0)); + return escapedCharsMap[c] || get16BitUnicodeEscapeSequence(c.charCodeAt(0)); } } - /** - * Quotes a given string akin to the abstract Quote operation from ECMA-262 (24.3.2.2) - * with the specified quotation mark - */ - export function quoteString(s: string, quotemark: QuotationMark): string { - return QuotationMarkLookup[quotemark] + escapeStringByQuote(s, quotemark) + QuotationMarkLookup[quotemark]; - } - export function isIntrinsicJsxName(name: string) { let ch = name.substr(0, 1); return ch.toLowerCase() === ch; @@ -1796,23 +1757,12 @@ namespace ts { }; } - export function makeModulePathSemiAbsolute(host: EmitHost, currentSourceFile: SourceFile, externalModuleName: string): string { - let quotationMark = externalModuleName.charAt(0); - let unquotedModuleName = externalModuleName.substring(1, externalModuleName.length - 1); - let resolvedFileName = host.resolveModuleName(unquotedModuleName, currentSourceFile.fileName); - if (resolvedFileName) { - let semiAbsoluteName = resolveToSemiabsolutePath(host, resolvedFileName); - externalModuleName = quoteString(semiAbsoluteName, parseInt(QuotationMarkLookup[quotationMark])); - } - return externalModuleName; - } - /** * Resolves a local path to a path which is absolute to the base of the emit */ - export function resolveToSemiabsolutePath(host: EmitHost, path: string): string { + export function getExternalModuleNameFromPath(host: EmitHost, fileName: string): string { let dir = host.getCurrentDirectory(); - let relativePath = getRelativePathToDirectoryOrUrl(dir, path, dir, f => host.getCanonicalFileName(f), /*isAbsolutePathAnUrl*/ false); + let relativePath = getRelativePathToDirectoryOrUrl(dir, fileName, dir, f => host.getCanonicalFileName(f), /*isAbsolutePathAnUrl*/ false); return removeFileExtension(relativePath); } diff --git a/src/harness/projectsRunner.ts b/src/harness/projectsRunner.ts index 862e446352d..18a8bc94c7b 100644 --- a/src/harness/projectsRunner.ts +++ b/src/harness/projectsRunner.ts @@ -366,7 +366,7 @@ class ProjectRunner extends RunnerBase { return resolutionInfo; } - it(name + ": " + moduleNameToString(moduleKind) , () => { + it(name + ": " + moduleNameToString(moduleKind), () => { // Compile using node compilerResult = batchCompilerProjectTestCase(moduleKind); }); From 3f52686974afd9e04a44a6e12702f4587b61c3c5 Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Wed, 21 Oct 2015 15:37:58 -0700 Subject: [PATCH 078/227] cleanup a bit, think toward the future --- src/compiler/declarationEmitter.ts | 17 +++++++++-------- src/compiler/emitter.ts | 16 +++++++++++++--- 2 files changed, 22 insertions(+), 11 deletions(-) diff --git a/src/compiler/declarationEmitter.ts b/src/compiler/declarationEmitter.ts index 82983dab394..57e9b47b379 100644 --- a/src/compiler/declarationEmitter.ts +++ b/src/compiler/declarationEmitter.ts @@ -739,14 +739,15 @@ namespace ts { if ((!root) && (compilerOptions.out || compilerOptions.outFile)) { let moduleSymbol = resolver.getSymbolAtLocation(moduleSpecifier); - if (moduleSymbol && moduleSymbol.valueDeclaration && - moduleSymbol.valueDeclaration.kind === SyntaxKind.SourceFile && - !isDeclarationFile(moduleSymbol.valueDeclaration)) { - let nonRelativeModuleName = getExternalModuleNameFromPath(host, (moduleSymbol.valueDeclaration as SourceFile).fileName); - write("\""); - write(nonRelativeModuleName); - write("\""); - return; + if (moduleSymbol) { + let moduleDeclaration = getDeclarationOfKind(moduleSymbol, SyntaxKind.SourceFile) as SourceFile; + if (moduleDeclaration && !isDeclarationFile(moduleDeclaration)) { + let nonRelativeModuleName = getExternalModuleNameFromPath(host, moduleDeclaration.fileName); + write("\""); + write(nonRelativeModuleName); + write("\""); + return; + } } } diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index 278bf026603..1e95c827221 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -6766,7 +6766,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi } if (resolvePath) { - text = `"${lookupSpecifierName(externalImports[i])}"`; + let name = lookupSpecifierName(externalImports[i]); + if (name) { + text = `"${name}"`; + } } write(text); } @@ -6791,7 +6794,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi specifier = (declaration as ImportDeclaration|ExportDeclaration).moduleSpecifier; } let moduleSymbol = resolver.getSymbolAtLocation(specifier); - return getExternalModuleNameFromPath(host, (moduleSymbol.valueDeclaration as SourceFile).fileName); + let moduleDeclaration = getDeclarationOfKind(moduleSymbol, SyntaxKind.SourceFile) as SourceFile; + if (!moduleDeclaration || isDeclarationFile(moduleDeclaration)) { + return; + } + return getExternalModuleNameFromPath(host, moduleDeclaration.fileName); } interface AMDDependencyNames { @@ -6825,7 +6832,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi let externalModuleName = getExternalModuleNameText(importNode); if (resolvePath) { - externalModuleName = `"${lookupSpecifierName(importNode)}"`; + let name = lookupSpecifierName(importNode); + if (name) { + externalModuleName = `"${name}"`; + } } // Find the name of the module alias, if there is one From 2fcdb0f70079c3338ebc5df8ef3aae53a54b6f43 Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Wed, 21 Oct 2015 15:53:59 -0700 Subject: [PATCH 079/227] bit more cleanup --- src/compiler/emitter.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index 1e95c827221..0f0cdc0e110 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -6794,6 +6794,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi specifier = (declaration as ImportDeclaration|ExportDeclaration).moduleSpecifier; } let moduleSymbol = resolver.getSymbolAtLocation(specifier); + if (!moduleSymbol) { + return; + } let moduleDeclaration = getDeclarationOfKind(moduleSymbol, SyntaxKind.SourceFile) as SourceFile; if (!moduleDeclaration || isDeclarationFile(moduleDeclaration)) { return; From d18facbdc1c88394400358b1a1e1793e99b1f70a Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Wed, 21 Oct 2015 15:54:35 -0700 Subject: [PATCH 080/227] fix lint --- src/compiler/emitter.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index 0f0cdc0e110..fca740c0333 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -6795,7 +6795,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi } let moduleSymbol = resolver.getSymbolAtLocation(specifier); if (!moduleSymbol) { - return; + return; } let moduleDeclaration = getDeclarationOfKind(moduleSymbol, SyntaxKind.SourceFile) as SourceFile; if (!moduleDeclaration || isDeclarationFile(moduleDeclaration)) { From 255cde582d4897bc03d83284192dcfd4f24a4163 Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Wed, 21 Oct 2015 16:15:53 -0700 Subject: [PATCH 081/227] remove assertion --- src/compiler/declarationEmitter.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/compiler/declarationEmitter.ts b/src/compiler/declarationEmitter.ts index 57e9b47b379..1a1f0c5f16e 100644 --- a/src/compiler/declarationEmitter.ts +++ b/src/compiler/declarationEmitter.ts @@ -735,9 +735,7 @@ namespace ts { } function emitExternalModuleSpecifier(moduleSpecifier: Expression) { - Debug.assert(moduleSpecifier.kind === SyntaxKind.StringLiteral); - - if ((!root) && (compilerOptions.out || compilerOptions.outFile)) { + if (moduleSpecifier.kind === SyntaxKind.StringLiteral && (!root) && (compilerOptions.out || compilerOptions.outFile)) { let moduleSymbol = resolver.getSymbolAtLocation(moduleSpecifier); if (moduleSymbol) { let moduleDeclaration = getDeclarationOfKind(moduleSymbol, SyntaxKind.SourceFile) as SourceFile; From c165be8b3a28bee144a35eb880fe0ba5dd49178d Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Wed, 21 Oct 2015 17:36:49 -0700 Subject: [PATCH 082/227] change triple-slash ref emit critaera, add a new tests and accept new baselines --- src/compiler/declarationEmitter.ts | 10 +- .../reference/outModuleTripleSlashRefs.js | 116 +++++ .../reference/outModuleTripleSlashRefs.js.map | 4 + .../outModuleTripleSlashRefs.sourcemap.txt | 424 ++++++++++++++++++ .../outModuleTripleSlashRefs.symbols | 50 +++ .../reference/outModuleTripleSlashRefs.types | 50 +++ .../amd/bin/test.d.ts | 1 - .../node/bin/test.d.ts | 1 - .../amd/bin/outAndOutDirFile.d.ts | 1 - .../node/bin/outAndOutDirFile.d.ts | 1 - .../amd/bin/test.d.ts | 1 - .../node/bin/test.d.ts | 1 - .../amd/bin/outAndOutDirFile.d.ts | 1 - .../node/bin/outAndOutDirFile.d.ts | 1 - .../amd/bin/test.d.ts | 1 - .../node/bin/test.d.ts | 1 - .../amd/bin/outAndOutDirFile.d.ts | 1 - .../node/bin/outAndOutDirFile.d.ts | 1 - .../amd/bin/test.d.ts | 1 - .../node/bin/test.d.ts | 1 - .../amd/bin/outAndOutDirFile.d.ts | 1 - .../node/bin/outAndOutDirFile.d.ts | 1 - .../amd/bin/test.d.ts | 1 - .../node/bin/test.d.ts | 1 - .../amd/bin/outAndOutDirFile.d.ts | 1 - .../node/bin/outAndOutDirFile.d.ts | 1 - .../amd/bin/test.d.ts | 1 - .../node/bin/test.d.ts | 1 - .../amd/bin/outAndOutDirFile.d.ts | 1 - .../node/bin/outAndOutDirFile.d.ts | 1 - .../amd/bin/test.d.ts | 1 - .../node/bin/test.d.ts | 1 - .../amd/bin/outAndOutDirFile.d.ts | 1 - .../node/bin/outAndOutDirFile.d.ts | 1 - .../amd/bin/test.d.ts | 1 - .../node/bin/test.d.ts | 1 - .../amd/bin/outAndOutDirFile.d.ts | 1 - .../node/bin/outAndOutDirFile.d.ts | 1 - .../amd/bin/test.d.ts | 1 - .../node/bin/test.d.ts | 1 - .../amd/bin/outAndOutDirFile.d.ts | 1 - .../node/bin/outAndOutDirFile.d.ts | 1 - .../compiler/outModuleTripleSlashRefs.ts | 33 ++ 43 files changed, 683 insertions(+), 40 deletions(-) create mode 100644 tests/baselines/reference/outModuleTripleSlashRefs.js create mode 100644 tests/baselines/reference/outModuleTripleSlashRefs.js.map create mode 100644 tests/baselines/reference/outModuleTripleSlashRefs.sourcemap.txt create mode 100644 tests/baselines/reference/outModuleTripleSlashRefs.symbols create mode 100644 tests/baselines/reference/outModuleTripleSlashRefs.types create mode 100644 tests/cases/compiler/outModuleTripleSlashRefs.ts diff --git a/src/compiler/declarationEmitter.ts b/src/compiler/declarationEmitter.ts index 1a1f0c5f16e..426000f6282 100644 --- a/src/compiler/declarationEmitter.ts +++ b/src/compiler/declarationEmitter.ts @@ -107,15 +107,14 @@ namespace ts { let emittedReferencedFiles: SourceFile[] = []; let prevModuleElementDeclarationEmitInfo: ModuleElementDeclarationEmitInfo[] = []; forEach(host.getSourceFiles(), sourceFile => { - if (!isExternalModuleOrDeclarationFile(sourceFile)) { - noDeclare = false; + if (!isDeclarationFile(sourceFile)) { // Check what references need to be added if (!compilerOptions.noResolve) { forEach(sourceFile.referencedFiles, fileReference => { let referencedFile = tryResolveScriptReference(host, sourceFile, fileReference); - // If the reference file is a declaration file or an external module, emit that reference - if (referencedFile && (isExternalModuleOrDeclarationFile(referencedFile) && + // If the reference file is a declaration file, emit that reference + if (referencedFile && (isDeclarationFile(referencedFile) && !contains(emittedReferencedFiles, referencedFile))) { // If the file reference was not already emitted writeReferencePath(referencedFile); @@ -123,7 +122,10 @@ namespace ts { } }); } + } + if (!isExternalModuleOrDeclarationFile(sourceFile)) { + noDeclare = false; emitSourceFile(sourceFile); } else if (isExternalModule(sourceFile)) { diff --git a/tests/baselines/reference/outModuleTripleSlashRefs.js b/tests/baselines/reference/outModuleTripleSlashRefs.js new file mode 100644 index 00000000000..dc0cdb22ddd --- /dev/null +++ b/tests/baselines/reference/outModuleTripleSlashRefs.js @@ -0,0 +1,116 @@ +//// [tests/cases/compiler/outModuleTripleSlashRefs.ts] //// + +//// [a.ts] + +/// +export class A { + member: typeof GlobalFoo; +} + +//// [b.ts] +/// +class Foo { + member: Bar; +} +declare var GlobalFoo: Foo; + +//// [c.d.ts] +/// +declare class Bar { + member: Baz; +} + +//// [d.d.ts] +declare class Baz { + member: number; +} + +//// [b.ts] +import {A} from "./ref/a"; +export class B extends A { } + + +//// [a.js] +define(["require", "exports"], function (require, exports) { + /// + var A = (function () { + function A() { + } + return A; + })(); + exports.A = A; +}); +//# sourceMappingURL=a.js.map//// [b.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 __()); +}; +define(["require", "exports", "./ref/a"], function (require, exports, a_1) { + var B = (function (_super) { + __extends(B, _super); + function B() { + _super.apply(this, arguments); + } + return B; + })(a_1.A); + exports.B = B; +}); +//# sourceMappingURL=b.js.map//// [all.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 Foo = (function () { + function Foo() { + } + return Foo; +})(); +define("tests/cases/compiler/ref/a", ["require", "exports"], function (require, exports) { + /// + var A = (function () { + function A() { + } + return A; + })(); + exports.A = A; +}); +define("tests/cases/compiler/b", ["require", "exports", "tests/cases/compiler/ref/a"], function (require, exports, a_1) { + var B = (function (_super) { + __extends(B, _super); + function B() { + _super.apply(this, arguments); + } + return B; + })(a_1.A); + exports.B = B; +}); +//# sourceMappingURL=all.js.map + +//// [a.d.ts] +/// +export declare class A { + member: typeof GlobalFoo; +} +//// [b.d.ts] +import { A } from "./ref/a"; +export declare class B extends A { +} +//// [all.d.ts] +/// +declare class Foo { + member: Bar; +} +declare var GlobalFoo: Foo; +declare module "tests/cases/compiler/ref/a" { + export class A { + member: typeof GlobalFoo; + } +} +declare module "tests/cases/compiler/b" { + import { A } from "tests/cases/compiler/ref/a"; + export class B extends A { + } +} diff --git a/tests/baselines/reference/outModuleTripleSlashRefs.js.map b/tests/baselines/reference/outModuleTripleSlashRefs.js.map new file mode 100644 index 00000000000..0eeee4a82d5 --- /dev/null +++ b/tests/baselines/reference/outModuleTripleSlashRefs.js.map @@ -0,0 +1,4 @@ +//// [a.js.map] +{"version":3,"file":"a.js","sourceRoot":"","sources":["a.ts"],"names":["A","A.constructor"],"mappings":";IACA,+BAA+B;IAC/B;QAAAA;QAEAC,CAACA;QAADD,QAACA;IAADA,CAACA,AAFD,IAEC;IAFY,SAAC,IAEb,CAAA"}//// [b.js.map] +{"version":3,"file":"b.js","sourceRoot":"","sources":["b.ts"],"names":["B","B.constructor"],"mappings":";;;;;;IACA;QAAuBA,qBAACA;QAAxBA;YAAuBC,8BAACA;QAAGA,CAACA;QAADD,QAACA;IAADA,CAACA,AAA5B,EAAuB,KAAC,EAAI;IAAf,SAAC,IAAc,CAAA"}//// [all.js.map] +{"version":3,"file":"all.js","sourceRoot":"","sources":["tests/cases/compiler/ref/b.ts","tests/cases/compiler/ref/a.ts","tests/cases/compiler/b.ts"],"names":["Foo","Foo.constructor","A","A.constructor","B","B.constructor"],"mappings":";;;;;AAAA,iCAAiC;AACjC;IAAAA;IAEAC,CAACA;IAADD,UAACA;AAADA,CAACA,AAFD,IAEC;;ICFD,+BAA+B;IAC/B;QAAAE;QAEAC,CAACA;QAADD,QAACA;IAADA,CAACA,AAFD,IAEC;IAFY,SAAC,IAEb,CAAA;;;ICHD;QAAuBE,qBAACA;QAAxBA;YAAuBC,8BAACA;QAAGA,CAACA;QAADD,QAACA;IAADA,CAACA,AAA5B,EAAuB,KAAC,EAAI;IAAf,SAAC,IAAc,CAAA"} \ No newline at end of file diff --git a/tests/baselines/reference/outModuleTripleSlashRefs.sourcemap.txt b/tests/baselines/reference/outModuleTripleSlashRefs.sourcemap.txt new file mode 100644 index 00000000000..6e9070cbe04 --- /dev/null +++ b/tests/baselines/reference/outModuleTripleSlashRefs.sourcemap.txt @@ -0,0 +1,424 @@ +=================================================================== +JsFile: a.js +mapUrl: a.js.map +sourceRoot: +sources: a.ts +=================================================================== +------------------------------------------------------------------- +emittedFile:tests/cases/compiler/ref/a.js +sourceFile:a.ts +------------------------------------------------------------------- +>>>define(["require", "exports"], function (require, exports) { +>>> /// +1 >^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +1 > + > +2 > /// +1 >Emitted(2, 5) Source(2, 1) + SourceIndex(0) +2 >Emitted(2, 36) Source(2, 32) + SourceIndex(0) +--- +>>> var A = (function () { +1 >^^^^ +2 > ^^^^^^^^^^^^^^^^^^^-> +1 > + > +1 >Emitted(3, 5) Source(3, 1) + SourceIndex(0) +--- +>>> function A() { +1->^^^^^^^^ +2 > ^^-> +1-> +1->Emitted(4, 9) Source(3, 1) + SourceIndex(0) name (A) +--- +>>> } +1->^^^^^^^^ +2 > ^ +3 > ^^^^^^^^^-> +1->export class A { + > member: typeof GlobalFoo; + > +2 > } +1->Emitted(5, 9) Source(5, 1) + SourceIndex(0) name (A.constructor) +2 >Emitted(5, 10) Source(5, 2) + SourceIndex(0) name (A.constructor) +--- +>>> return A; +1->^^^^^^^^ +2 > ^^^^^^^^ +1-> +2 > } +1->Emitted(6, 9) Source(5, 1) + SourceIndex(0) name (A) +2 >Emitted(6, 17) Source(5, 2) + SourceIndex(0) name (A) +--- +>>> })(); +1 >^^^^ +2 > ^ +3 > +4 > ^^^^ +5 > ^^^^^^^^^^-> +1 > +2 > } +3 > +4 > export class A { + > member: typeof GlobalFoo; + > } +1 >Emitted(7, 5) Source(5, 1) + SourceIndex(0) name (A) +2 >Emitted(7, 6) Source(5, 2) + SourceIndex(0) name (A) +3 >Emitted(7, 6) Source(3, 1) + SourceIndex(0) +4 >Emitted(7, 10) Source(5, 2) + SourceIndex(0) +--- +>>> exports.A = A; +1->^^^^ +2 > ^^^^^^^^^ +3 > ^^^^ +4 > ^ +1-> +2 > A +3 > { + > member: typeof GlobalFoo; + > } +4 > +1->Emitted(8, 5) Source(3, 14) + SourceIndex(0) +2 >Emitted(8, 14) Source(3, 15) + SourceIndex(0) +3 >Emitted(8, 18) Source(5, 2) + SourceIndex(0) +4 >Emitted(8, 19) Source(5, 2) + SourceIndex(0) +--- +>>>}); +>>>//# sourceMappingURL=a.js.map=================================================================== +JsFile: b.js +mapUrl: b.js.map +sourceRoot: +sources: b.ts +=================================================================== +------------------------------------------------------------------- +emittedFile:tests/cases/compiler/b.js +sourceFile:b.ts +------------------------------------------------------------------- +>>>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 __()); +>>>}; +>>>define(["require", "exports", "./ref/a"], function (require, exports, a_1) { +>>> var B = (function (_super) { +1 >^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^-> +1 >import {A} from "./ref/a"; + > +1 >Emitted(7, 5) Source(2, 1) + SourceIndex(0) +--- +>>> __extends(B, _super); +1->^^^^^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^^ +1->export class B extends +2 > A +1->Emitted(8, 9) Source(2, 24) + SourceIndex(0) name (B) +2 >Emitted(8, 30) Source(2, 25) + SourceIndex(0) name (B) +--- +>>> function B() { +1 >^^^^^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +1 > +1 >Emitted(9, 9) Source(2, 1) + SourceIndex(0) name (B) +--- +>>> _super.apply(this, arguments); +1->^^^^^^^^^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +1->export class B extends +2 > A +1->Emitted(10, 13) Source(2, 24) + SourceIndex(0) name (B.constructor) +2 >Emitted(10, 43) Source(2, 25) + SourceIndex(0) name (B.constructor) +--- +>>> } +1 >^^^^^^^^ +2 > ^ +3 > ^^^^^^^^^-> +1 > { +2 > } +1 >Emitted(11, 9) Source(2, 28) + SourceIndex(0) name (B.constructor) +2 >Emitted(11, 10) Source(2, 29) + SourceIndex(0) name (B.constructor) +--- +>>> return B; +1->^^^^^^^^ +2 > ^^^^^^^^ +1-> +2 > } +1->Emitted(12, 9) Source(2, 28) + SourceIndex(0) name (B) +2 >Emitted(12, 17) Source(2, 29) + SourceIndex(0) name (B) +--- +>>> })(a_1.A); +1 >^^^^ +2 > ^ +3 > +4 > ^^ +5 > ^^^^^ +6 > ^^ +7 > ^^^^^-> +1 > +2 > } +3 > +4 > export class B extends +5 > A +6 > { } +1 >Emitted(13, 5) Source(2, 28) + SourceIndex(0) name (B) +2 >Emitted(13, 6) Source(2, 29) + SourceIndex(0) name (B) +3 >Emitted(13, 6) Source(2, 1) + SourceIndex(0) +4 >Emitted(13, 8) Source(2, 24) + SourceIndex(0) +5 >Emitted(13, 13) Source(2, 25) + SourceIndex(0) +6 >Emitted(13, 15) Source(2, 29) + SourceIndex(0) +--- +>>> exports.B = B; +1->^^^^ +2 > ^^^^^^^^^ +3 > ^^^^ +4 > ^ +1-> +2 > B +3 > extends A { } +4 > +1->Emitted(14, 5) Source(2, 14) + SourceIndex(0) +2 >Emitted(14, 14) Source(2, 15) + SourceIndex(0) +3 >Emitted(14, 18) Source(2, 29) + SourceIndex(0) +4 >Emitted(14, 19) Source(2, 29) + SourceIndex(0) +--- +>>>}); +>>>//# sourceMappingURL=b.js.map=================================================================== +JsFile: all.js +mapUrl: all.js.map +sourceRoot: +sources: tests/cases/compiler/ref/b.ts,tests/cases/compiler/ref/a.ts,tests/cases/compiler/b.ts +=================================================================== +------------------------------------------------------------------- +emittedFile:all.js +sourceFile:tests/cases/compiler/ref/b.ts +------------------------------------------------------------------- +>>>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 __()); +>>>}; +>>>/// +1 > +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +1 > +2 >/// +1 >Emitted(6, 1) Source(1, 1) + SourceIndex(0) +2 >Emitted(6, 34) Source(1, 34) + SourceIndex(0) +--- +>>>var Foo = (function () { +1 > +2 >^^^^^^^^^^^^^^^^^^^^^-> +1 > + > +1 >Emitted(7, 1) Source(2, 1) + SourceIndex(0) +--- +>>> function Foo() { +1->^^^^ +2 > ^^-> +1-> +1->Emitted(8, 5) Source(2, 1) + SourceIndex(0) name (Foo) +--- +>>> } +1->^^^^ +2 > ^ +3 > ^^^^^^^^^^^-> +1->class Foo { + > member: Bar; + > +2 > } +1->Emitted(9, 5) Source(4, 1) + SourceIndex(0) name (Foo.constructor) +2 >Emitted(9, 6) Source(4, 2) + SourceIndex(0) name (Foo.constructor) +--- +>>> return Foo; +1->^^^^ +2 > ^^^^^^^^^^ +1-> +2 > } +1->Emitted(10, 5) Source(4, 1) + SourceIndex(0) name (Foo) +2 >Emitted(10, 15) Source(4, 2) + SourceIndex(0) name (Foo) +--- +>>>})(); +1 > +2 >^ +3 > +4 > ^^^^ +5 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +1 > +2 >} +3 > +4 > class Foo { + > member: Bar; + > } +1 >Emitted(11, 1) Source(4, 1) + SourceIndex(0) name (Foo) +2 >Emitted(11, 2) Source(4, 2) + SourceIndex(0) name (Foo) +3 >Emitted(11, 2) Source(2, 1) + SourceIndex(0) +4 >Emitted(11, 6) Source(4, 2) + SourceIndex(0) +--- +------------------------------------------------------------------- +emittedFile:all.js +sourceFile:tests/cases/compiler/ref/a.ts +------------------------------------------------------------------- +>>>define("tests/cases/compiler/ref/a", ["require", "exports"], function (require, exports) { +>>> /// +1->^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +1-> + > +2 > /// +1->Emitted(13, 5) Source(2, 1) + SourceIndex(1) +2 >Emitted(13, 36) Source(2, 32) + SourceIndex(1) +--- +>>> var A = (function () { +1 >^^^^ +2 > ^^^^^^^^^^^^^^^^^^^-> +1 > + > +1 >Emitted(14, 5) Source(3, 1) + SourceIndex(1) +--- +>>> function A() { +1->^^^^^^^^ +2 > ^^-> +1-> +1->Emitted(15, 9) Source(3, 1) + SourceIndex(1) name (A) +--- +>>> } +1->^^^^^^^^ +2 > ^ +3 > ^^^^^^^^^-> +1->export class A { + > member: typeof GlobalFoo; + > +2 > } +1->Emitted(16, 9) Source(5, 1) + SourceIndex(1) name (A.constructor) +2 >Emitted(16, 10) Source(5, 2) + SourceIndex(1) name (A.constructor) +--- +>>> return A; +1->^^^^^^^^ +2 > ^^^^^^^^ +1-> +2 > } +1->Emitted(17, 9) Source(5, 1) + SourceIndex(1) name (A) +2 >Emitted(17, 17) Source(5, 2) + SourceIndex(1) name (A) +--- +>>> })(); +1 >^^^^ +2 > ^ +3 > +4 > ^^^^ +5 > ^^^^^^^^^^-> +1 > +2 > } +3 > +4 > export class A { + > member: typeof GlobalFoo; + > } +1 >Emitted(18, 5) Source(5, 1) + SourceIndex(1) name (A) +2 >Emitted(18, 6) Source(5, 2) + SourceIndex(1) name (A) +3 >Emitted(18, 6) Source(3, 1) + SourceIndex(1) +4 >Emitted(18, 10) Source(5, 2) + SourceIndex(1) +--- +>>> exports.A = A; +1->^^^^ +2 > ^^^^^^^^^ +3 > ^^^^ +4 > ^ +1-> +2 > A +3 > { + > member: typeof GlobalFoo; + > } +4 > +1->Emitted(19, 5) Source(3, 14) + SourceIndex(1) +2 >Emitted(19, 14) Source(3, 15) + SourceIndex(1) +3 >Emitted(19, 18) Source(5, 2) + SourceIndex(1) +4 >Emitted(19, 19) Source(5, 2) + SourceIndex(1) +--- +------------------------------------------------------------------- +emittedFile:all.js +sourceFile:tests/cases/compiler/b.ts +------------------------------------------------------------------- +>>>}); +>>>define("tests/cases/compiler/b", ["require", "exports", "tests/cases/compiler/ref/a"], function (require, exports, a_1) { +>>> var B = (function (_super) { +1 >^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^-> +1 >import {A} from "./ref/a"; + > +1 >Emitted(22, 5) Source(2, 1) + SourceIndex(2) +--- +>>> __extends(B, _super); +1->^^^^^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^^ +1->export class B extends +2 > A +1->Emitted(23, 9) Source(2, 24) + SourceIndex(2) name (B) +2 >Emitted(23, 30) Source(2, 25) + SourceIndex(2) name (B) +--- +>>> function B() { +1 >^^^^^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +1 > +1 >Emitted(24, 9) Source(2, 1) + SourceIndex(2) name (B) +--- +>>> _super.apply(this, arguments); +1->^^^^^^^^^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +1->export class B extends +2 > A +1->Emitted(25, 13) Source(2, 24) + SourceIndex(2) name (B.constructor) +2 >Emitted(25, 43) Source(2, 25) + SourceIndex(2) name (B.constructor) +--- +>>> } +1 >^^^^^^^^ +2 > ^ +3 > ^^^^^^^^^-> +1 > { +2 > } +1 >Emitted(26, 9) Source(2, 28) + SourceIndex(2) name (B.constructor) +2 >Emitted(26, 10) Source(2, 29) + SourceIndex(2) name (B.constructor) +--- +>>> return B; +1->^^^^^^^^ +2 > ^^^^^^^^ +1-> +2 > } +1->Emitted(27, 9) Source(2, 28) + SourceIndex(2) name (B) +2 >Emitted(27, 17) Source(2, 29) + SourceIndex(2) name (B) +--- +>>> })(a_1.A); +1 >^^^^ +2 > ^ +3 > +4 > ^^ +5 > ^^^^^ +6 > ^^ +7 > ^^^^^-> +1 > +2 > } +3 > +4 > export class B extends +5 > A +6 > { } +1 >Emitted(28, 5) Source(2, 28) + SourceIndex(2) name (B) +2 >Emitted(28, 6) Source(2, 29) + SourceIndex(2) name (B) +3 >Emitted(28, 6) Source(2, 1) + SourceIndex(2) +4 >Emitted(28, 8) Source(2, 24) + SourceIndex(2) +5 >Emitted(28, 13) Source(2, 25) + SourceIndex(2) +6 >Emitted(28, 15) Source(2, 29) + SourceIndex(2) +--- +>>> exports.B = B; +1->^^^^ +2 > ^^^^^^^^^ +3 > ^^^^ +4 > ^ +1-> +2 > B +3 > extends A { } +4 > +1->Emitted(29, 5) Source(2, 14) + SourceIndex(2) +2 >Emitted(29, 14) Source(2, 15) + SourceIndex(2) +3 >Emitted(29, 18) Source(2, 29) + SourceIndex(2) +4 >Emitted(29, 19) Source(2, 29) + SourceIndex(2) +--- +>>>}); +>>>//# sourceMappingURL=all.js.map \ No newline at end of file diff --git a/tests/baselines/reference/outModuleTripleSlashRefs.symbols b/tests/baselines/reference/outModuleTripleSlashRefs.symbols new file mode 100644 index 00000000000..f8d550aedb6 --- /dev/null +++ b/tests/baselines/reference/outModuleTripleSlashRefs.symbols @@ -0,0 +1,50 @@ +=== tests/cases/compiler/ref/a.ts === + +/// +export class A { +>A : Symbol(A, Decl(a.ts, 0, 0)) + + member: typeof GlobalFoo; +>member : Symbol(member, Decl(a.ts, 2, 16)) +>GlobalFoo : Symbol(GlobalFoo, Decl(b.ts, 4, 11)) +} + +=== tests/cases/compiler/ref/b.ts === +/// +class Foo { +>Foo : Symbol(Foo, Decl(b.ts, 0, 0)) + + member: Bar; +>member : Symbol(member, Decl(b.ts, 1, 11)) +>Bar : Symbol(Bar, Decl(c.d.ts, 0, 0)) +} +declare var GlobalFoo: Foo; +>GlobalFoo : Symbol(GlobalFoo, Decl(b.ts, 4, 11)) +>Foo : Symbol(Foo, Decl(b.ts, 0, 0)) + +=== tests/cases/compiler/ref/c.d.ts === +/// +declare class Bar { +>Bar : Symbol(Bar, Decl(c.d.ts, 0, 0)) + + member: Baz; +>member : Symbol(member, Decl(c.d.ts, 1, 19)) +>Baz : Symbol(Baz, Decl(d.d.ts, 0, 0)) +} + +=== tests/cases/compiler/ref/d.d.ts === +declare class Baz { +>Baz : Symbol(Baz, Decl(d.d.ts, 0, 0)) + + member: number; +>member : Symbol(member, Decl(d.d.ts, 0, 19)) +} + +=== tests/cases/compiler/b.ts === +import {A} from "./ref/a"; +>A : Symbol(A, Decl(b.ts, 0, 8)) + +export class B extends A { } +>B : Symbol(B, Decl(b.ts, 0, 26)) +>A : Symbol(A, Decl(b.ts, 0, 8)) + diff --git a/tests/baselines/reference/outModuleTripleSlashRefs.types b/tests/baselines/reference/outModuleTripleSlashRefs.types new file mode 100644 index 00000000000..917704cce5a --- /dev/null +++ b/tests/baselines/reference/outModuleTripleSlashRefs.types @@ -0,0 +1,50 @@ +=== tests/cases/compiler/ref/a.ts === + +/// +export class A { +>A : A + + member: typeof GlobalFoo; +>member : Foo +>GlobalFoo : Foo +} + +=== tests/cases/compiler/ref/b.ts === +/// +class Foo { +>Foo : Foo + + member: Bar; +>member : Bar +>Bar : Bar +} +declare var GlobalFoo: Foo; +>GlobalFoo : Foo +>Foo : Foo + +=== tests/cases/compiler/ref/c.d.ts === +/// +declare class Bar { +>Bar : Bar + + member: Baz; +>member : Baz +>Baz : Baz +} + +=== tests/cases/compiler/ref/d.d.ts === +declare class Baz { +>Baz : Baz + + member: number; +>member : number +} + +=== tests/cases/compiler/b.ts === +import {A} from "./ref/a"; +>A : typeof A + +export class B extends A { } +>B : B +>A : A + diff --git a/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFile/amd/bin/test.d.ts b/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFile/amd/bin/test.d.ts index bc9ccf61daf..c3a64f5b6eb 100644 --- a/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFile/amd/bin/test.d.ts +++ b/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFile/amd/bin/test.d.ts @@ -1,4 +1,3 @@ -/// declare var m1_a1: number; declare class m1_c1 { m1_c1_p1: number; diff --git a/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFile/node/bin/test.d.ts b/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFile/node/bin/test.d.ts index bc9ccf61daf..c3a64f5b6eb 100644 --- a/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFile/node/bin/test.d.ts +++ b/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFile/node/bin/test.d.ts @@ -1,4 +1,3 @@ -/// declare var m1_a1: number; declare class m1_c1 { m1_c1_p1: number; diff --git a/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.d.ts b/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.d.ts index 375869ffc94..c3a64f5b6eb 100644 --- a/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.d.ts +++ b/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.d.ts @@ -1,4 +1,3 @@ -/// declare var m1_a1: number; declare class m1_c1 { m1_c1_p1: number; diff --git a/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.d.ts b/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.d.ts index 375869ffc94..c3a64f5b6eb 100644 --- a/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.d.ts +++ b/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.d.ts @@ -1,4 +1,3 @@ -/// declare var m1_a1: number; declare class m1_c1 { m1_c1_p1: number; diff --git a/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFile/amd/bin/test.d.ts b/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFile/amd/bin/test.d.ts index bc9ccf61daf..c3a64f5b6eb 100644 --- a/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFile/amd/bin/test.d.ts +++ b/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFile/amd/bin/test.d.ts @@ -1,4 +1,3 @@ -/// declare var m1_a1: number; declare class m1_c1 { m1_c1_p1: number; diff --git a/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFile/node/bin/test.d.ts b/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFile/node/bin/test.d.ts index bc9ccf61daf..c3a64f5b6eb 100644 --- a/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFile/node/bin/test.d.ts +++ b/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFile/node/bin/test.d.ts @@ -1,4 +1,3 @@ -/// declare var m1_a1: number; declare class m1_c1 { m1_c1_p1: number; diff --git a/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.d.ts b/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.d.ts index 375869ffc94..c3a64f5b6eb 100644 --- a/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.d.ts +++ b/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.d.ts @@ -1,4 +1,3 @@ -/// declare var m1_a1: number; declare class m1_c1 { m1_c1_p1: number; diff --git a/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.d.ts b/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.d.ts index 375869ffc94..c3a64f5b6eb 100644 --- a/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.d.ts +++ b/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.d.ts @@ -1,4 +1,3 @@ -/// declare var m1_a1: number; declare class m1_c1 { m1_c1_p1: number; diff --git a/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFile/amd/bin/test.d.ts b/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFile/amd/bin/test.d.ts index bc9ccf61daf..c3a64f5b6eb 100644 --- a/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFile/amd/bin/test.d.ts +++ b/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFile/amd/bin/test.d.ts @@ -1,4 +1,3 @@ -/// declare var m1_a1: number; declare class m1_c1 { m1_c1_p1: number; diff --git a/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFile/node/bin/test.d.ts b/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFile/node/bin/test.d.ts index bc9ccf61daf..c3a64f5b6eb 100644 --- a/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFile/node/bin/test.d.ts +++ b/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFile/node/bin/test.d.ts @@ -1,4 +1,3 @@ -/// declare var m1_a1: number; declare class m1_c1 { m1_c1_p1: number; diff --git a/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.d.ts b/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.d.ts index 375869ffc94..c3a64f5b6eb 100644 --- a/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.d.ts +++ b/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.d.ts @@ -1,4 +1,3 @@ -/// declare var m1_a1: number; declare class m1_c1 { m1_c1_p1: number; diff --git a/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.d.ts b/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.d.ts index 375869ffc94..c3a64f5b6eb 100644 --- a/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.d.ts +++ b/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.d.ts @@ -1,4 +1,3 @@ -/// declare var m1_a1: number; declare class m1_c1 { m1_c1_p1: number; diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFile/amd/bin/test.d.ts b/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFile/amd/bin/test.d.ts index bc9ccf61daf..c3a64f5b6eb 100644 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFile/amd/bin/test.d.ts +++ b/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFile/amd/bin/test.d.ts @@ -1,4 +1,3 @@ -/// declare var m1_a1: number; declare class m1_c1 { m1_c1_p1: number; diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFile/node/bin/test.d.ts b/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFile/node/bin/test.d.ts index bc9ccf61daf..c3a64f5b6eb 100644 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFile/node/bin/test.d.ts +++ b/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFile/node/bin/test.d.ts @@ -1,4 +1,3 @@ -/// declare var m1_a1: number; declare class m1_c1 { m1_c1_p1: number; diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.d.ts b/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.d.ts index 375869ffc94..c3a64f5b6eb 100644 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.d.ts +++ b/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.d.ts @@ -1,4 +1,3 @@ -/// declare var m1_a1: number; declare class m1_c1 { m1_c1_p1: number; diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.d.ts b/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.d.ts index 375869ffc94..c3a64f5b6eb 100644 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.d.ts +++ b/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.d.ts @@ -1,4 +1,3 @@ -/// declare var m1_a1: number; declare class m1_c1 { m1_c1_p1: number; diff --git a/tests/baselines/reference/project/outMixedSubfolderSpecifyOutputFile/amd/bin/test.d.ts b/tests/baselines/reference/project/outMixedSubfolderSpecifyOutputFile/amd/bin/test.d.ts index bc9ccf61daf..c3a64f5b6eb 100644 --- a/tests/baselines/reference/project/outMixedSubfolderSpecifyOutputFile/amd/bin/test.d.ts +++ b/tests/baselines/reference/project/outMixedSubfolderSpecifyOutputFile/amd/bin/test.d.ts @@ -1,4 +1,3 @@ -/// declare var m1_a1: number; declare class m1_c1 { m1_c1_p1: number; diff --git a/tests/baselines/reference/project/outMixedSubfolderSpecifyOutputFile/node/bin/test.d.ts b/tests/baselines/reference/project/outMixedSubfolderSpecifyOutputFile/node/bin/test.d.ts index bc9ccf61daf..c3a64f5b6eb 100644 --- a/tests/baselines/reference/project/outMixedSubfolderSpecifyOutputFile/node/bin/test.d.ts +++ b/tests/baselines/reference/project/outMixedSubfolderSpecifyOutputFile/node/bin/test.d.ts @@ -1,4 +1,3 @@ -/// declare var m1_a1: number; declare class m1_c1 { m1_c1_p1: number; diff --git a/tests/baselines/reference/project/outMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.d.ts b/tests/baselines/reference/project/outMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.d.ts index 375869ffc94..c3a64f5b6eb 100644 --- a/tests/baselines/reference/project/outMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.d.ts +++ b/tests/baselines/reference/project/outMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.d.ts @@ -1,4 +1,3 @@ -/// declare var m1_a1: number; declare class m1_c1 { m1_c1_p1: number; diff --git a/tests/baselines/reference/project/outMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.d.ts b/tests/baselines/reference/project/outMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.d.ts index 375869ffc94..c3a64f5b6eb 100644 --- a/tests/baselines/reference/project/outMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.d.ts +++ b/tests/baselines/reference/project/outMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.d.ts @@ -1,4 +1,3 @@ -/// declare var m1_a1: number; declare class m1_c1 { m1_c1_p1: number; diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFile/amd/bin/test.d.ts b/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFile/amd/bin/test.d.ts index bc9ccf61daf..c3a64f5b6eb 100644 --- a/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFile/amd/bin/test.d.ts +++ b/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFile/amd/bin/test.d.ts @@ -1,4 +1,3 @@ -/// declare var m1_a1: number; declare class m1_c1 { m1_c1_p1: number; diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFile/node/bin/test.d.ts b/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFile/node/bin/test.d.ts index bc9ccf61daf..c3a64f5b6eb 100644 --- a/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFile/node/bin/test.d.ts +++ b/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFile/node/bin/test.d.ts @@ -1,4 +1,3 @@ -/// declare var m1_a1: number; declare class m1_c1 { m1_c1_p1: number; diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.d.ts b/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.d.ts index 375869ffc94..c3a64f5b6eb 100644 --- a/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.d.ts +++ b/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.d.ts @@ -1,4 +1,3 @@ -/// declare var m1_a1: number; declare class m1_c1 { m1_c1_p1: number; diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.d.ts b/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.d.ts index 375869ffc94..c3a64f5b6eb 100644 --- a/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.d.ts +++ b/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.d.ts @@ -1,4 +1,3 @@ -/// declare var m1_a1: number; declare class m1_c1 { m1_c1_p1: number; diff --git a/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFile/amd/bin/test.d.ts b/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFile/amd/bin/test.d.ts index bc9ccf61daf..c3a64f5b6eb 100644 --- a/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFile/amd/bin/test.d.ts +++ b/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFile/amd/bin/test.d.ts @@ -1,4 +1,3 @@ -/// declare var m1_a1: number; declare class m1_c1 { m1_c1_p1: number; diff --git a/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFile/node/bin/test.d.ts b/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFile/node/bin/test.d.ts index bc9ccf61daf..c3a64f5b6eb 100644 --- a/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFile/node/bin/test.d.ts +++ b/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFile/node/bin/test.d.ts @@ -1,4 +1,3 @@ -/// declare var m1_a1: number; declare class m1_c1 { m1_c1_p1: number; diff --git a/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.d.ts b/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.d.ts index 375869ffc94..c3a64f5b6eb 100644 --- a/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.d.ts +++ b/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.d.ts @@ -1,4 +1,3 @@ -/// declare var m1_a1: number; declare class m1_c1 { m1_c1_p1: number; diff --git a/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.d.ts b/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.d.ts index 375869ffc94..c3a64f5b6eb 100644 --- a/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.d.ts +++ b/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.d.ts @@ -1,4 +1,3 @@ -/// declare var m1_a1: number; declare class m1_c1 { m1_c1_p1: number; diff --git a/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFile/amd/bin/test.d.ts b/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFile/amd/bin/test.d.ts index bc9ccf61daf..c3a64f5b6eb 100644 --- a/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFile/amd/bin/test.d.ts +++ b/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFile/amd/bin/test.d.ts @@ -1,4 +1,3 @@ -/// declare var m1_a1: number; declare class m1_c1 { m1_c1_p1: number; diff --git a/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFile/node/bin/test.d.ts b/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFile/node/bin/test.d.ts index bc9ccf61daf..c3a64f5b6eb 100644 --- a/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFile/node/bin/test.d.ts +++ b/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFile/node/bin/test.d.ts @@ -1,4 +1,3 @@ -/// declare var m1_a1: number; declare class m1_c1 { m1_c1_p1: number; diff --git a/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.d.ts b/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.d.ts index 375869ffc94..c3a64f5b6eb 100644 --- a/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.d.ts +++ b/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.d.ts @@ -1,4 +1,3 @@ -/// declare var m1_a1: number; declare class m1_c1 { m1_c1_p1: number; diff --git a/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.d.ts b/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.d.ts index 375869ffc94..c3a64f5b6eb 100644 --- a/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.d.ts +++ b/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.d.ts @@ -1,4 +1,3 @@ -/// declare var m1_a1: number; declare class m1_c1 { m1_c1_p1: number; diff --git a/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFile/amd/bin/test.d.ts b/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFile/amd/bin/test.d.ts index bc9ccf61daf..c3a64f5b6eb 100644 --- a/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFile/amd/bin/test.d.ts +++ b/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFile/amd/bin/test.d.ts @@ -1,4 +1,3 @@ -/// declare var m1_a1: number; declare class m1_c1 { m1_c1_p1: number; diff --git a/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFile/node/bin/test.d.ts b/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFile/node/bin/test.d.ts index bc9ccf61daf..c3a64f5b6eb 100644 --- a/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFile/node/bin/test.d.ts +++ b/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFile/node/bin/test.d.ts @@ -1,4 +1,3 @@ -/// declare var m1_a1: number; declare class m1_c1 { m1_c1_p1: number; diff --git a/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.d.ts b/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.d.ts index 375869ffc94..c3a64f5b6eb 100644 --- a/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.d.ts +++ b/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.d.ts @@ -1,4 +1,3 @@ -/// declare var m1_a1: number; declare class m1_c1 { m1_c1_p1: number; diff --git a/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.d.ts b/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.d.ts index 375869ffc94..c3a64f5b6eb 100644 --- a/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.d.ts +++ b/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.d.ts @@ -1,4 +1,3 @@ -/// declare var m1_a1: number; declare class m1_c1 { m1_c1_p1: number; diff --git a/tests/cases/compiler/outModuleTripleSlashRefs.ts b/tests/cases/compiler/outModuleTripleSlashRefs.ts new file mode 100644 index 00000000000..fdeb4f93453 --- /dev/null +++ b/tests/cases/compiler/outModuleTripleSlashRefs.ts @@ -0,0 +1,33 @@ +// @target: ES5 +// @sourcemap: true +// @declaration: true +// @module: amd +// @outFile: all.js + +// @Filename: ref/a.ts +/// +export class A { + member: typeof GlobalFoo; +} + +// @Filename: ref/b.ts +/// +class Foo { + member: Bar; +} +declare var GlobalFoo: Foo; + +// @Filename: ref/c.d.ts +/// +declare class Bar { + member: Baz; +} + +// @Filename: ref/d.d.ts +declare class Baz { + member: number; +} + +// @Filename: b.ts +import {A} from "./ref/a"; +export class B extends A { } From 2779352868f8c2806e056a582388cf1e2636aab9 Mon Sep 17 00:00:00 2001 From: Vladimir Matveev Date: Thu, 22 Oct 2015 08:58:20 -0700 Subject: [PATCH 083/227] make binder singleton, inline bindWithReachabilityChecks --- src/compiler/binder.ts | 86 +++++++++++++++++++++++++-------------- src/compiler/utilities.ts | 37 +++++++++-------- 2 files changed, 74 insertions(+), 49 deletions(-) diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index 8e764947ee8..9126bc465bd 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -92,13 +92,17 @@ namespace ts { IsContainerWithLocals = IsContainer | HasLocals } + const binder = createBinder(); + export function bindSourceFile(file: SourceFile, options: CompilerOptions) { let start = new Date().getTime(); - bindSourceFileWorker(file, options); + binder(file, options); bindTime += new Date().getTime() - start; } - function bindSourceFileWorker(file: SourceFile, options: CompilerOptions) { + function createBinder(): (file: SourceFile, options: CompilerOptions) => void { + let file: SourceFile; + let options: CompilerOptions; let parent: Node; let container: Node; let blockScopeContainer: Node; @@ -115,19 +119,37 @@ 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). - let inStrictMode = !!file.externalModuleIndicator; + let inStrictMode: boolean; let symbolCount = 0; - let Symbol = objectAllocator.getSymbolConstructor(); - let classifiableNames: Map = {}; + let Symbol: { new (flags: SymbolFlags, name: string): Symbol }; + let classifiableNames: Map; - if (!file.locals) { - bind(file); - file.symbolCount = symbolCount; - file.classifiableNames = classifiableNames; + function bindSourceFile(f: SourceFile, opts: CompilerOptions) { + file = f; + options = opts; + inStrictMode = !!file.externalModuleIndicator; + classifiableNames = {}; + Symbol = objectAllocator.getSymbolConstructor(); + + if (!file.locals) { + bind(file); + file.symbolCount = symbolCount; + file.classifiableNames = classifiableNames; + } + + parent = undefined; + container = undefined; + blockScopeContainer = undefined; + lastContainer = undefined; + seenThisKeyword = false; + hasExplicitReturn = false; + labelStack = undefined; + labelIndexMap = undefined; + implicitLabels = undefined; } - return; + return bindSourceFile; function createSymbol(flags: SymbolFlags, name: string): Symbol { symbolCount++; @@ -360,31 +382,23 @@ namespace ts { blockScopeContainer.locals = undefined; } - if (node.kind === SyntaxKind.InterfaceDeclaration) { - seenThisKeyword = false; - bindWithReachabilityChecks(node); - node.flags = seenThisKeyword ? node.flags | NodeFlags.ContainsThis : node.flags & ~NodeFlags.ContainsThis; - } - else { - bindWithReachabilityChecks(node); - } - - container = saveContainer; - parent = saveParent; - blockScopeContainer = savedBlockScopeContainer; - } - - function bindWithReachabilityChecks(node: Node): void { let savedReachabilityState: Reachability; let savedLabelStack: Reachability[]; let savedLabels: Map; let savedImplicitLabels: number[]; let savedHasExplicitReturn: boolean; - // reset all reachability check related flags on node (for incremental scenarios) - node.flags &= ~NodeFlags.ReachabilityCheckFlags; + const kind = node.kind; + let flags = node.flags; - let saveState = node.kind === SyntaxKind.SourceFile || node.kind === SyntaxKind.ModuleBlock || isFunctionLike(node); + // reset all reachability check related flags on node (for incremental scenarios) + flags &= ~NodeFlags.ReachabilityCheckFlags; + + if (kind === SyntaxKind.InterfaceDeclaration) { + seenThisKeyword = false; + } + + let saveState = kind === SyntaxKind.SourceFile || kind === SyntaxKind.ModuleBlock || isFunctionLikeKind(kind); if (saveState) { savedReachabilityState = currentReachabilityState; savedLabelStack = labelStack; @@ -399,13 +413,19 @@ namespace ts { bindReachableStatement(node); - if (currentReachabilityState === Reachability.Reachable && isFunctionLike(node) && nodeIsPresent((node).body)) { - node.flags |= NodeFlags.HasImplicitReturn; + if (currentReachabilityState === Reachability.Reachable && isFunctionLikeKind(kind) && nodeIsPresent((node).body)) { + flags |= NodeFlags.HasImplicitReturn; if (hasExplicitReturn) { - node.flags |= NodeFlags.HasExplicitReturn; + flags |= NodeFlags.HasExplicitReturn; } } + if (kind === SyntaxKind.InterfaceDeclaration) { + flags = seenThisKeyword ? flags | NodeFlags.ContainsThis : flags & ~NodeFlags.ContainsThis; + } + + node.flags = flags; + if (saveState) { hasExplicitReturn = savedHasExplicitReturn; currentReachabilityState = savedReachabilityState; @@ -413,6 +433,10 @@ namespace ts { labelIndexMap = savedLabels; implicitLabels = savedImplicitLabels; } + + container = saveContainer; + parent = saveParent; + blockScopeContainer = savedBlockScopeContainer; } /** diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 5cab42629e4..f506384c298 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -622,25 +622,26 @@ namespace ts { } export function isFunctionLike(node: Node): node is FunctionLikeDeclaration { - if (node) { - switch (node.kind) { - case SyntaxKind.Constructor: - case SyntaxKind.FunctionExpression: - case SyntaxKind.FunctionDeclaration: - case SyntaxKind.ArrowFunction: - case SyntaxKind.MethodDeclaration: - 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 true; - } + return node && isFunctionLikeKind(node.kind); + } + + export function isFunctionLikeKind(kind: SyntaxKind): boolean { + switch (kind) { + case SyntaxKind.Constructor: + case SyntaxKind.FunctionExpression: + case SyntaxKind.FunctionDeclaration: + case SyntaxKind.ArrowFunction: + case SyntaxKind.MethodDeclaration: + 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 true; } - return false; } export function introducesArgumentsExoticObject(node: Node) { From 7d09f268c40fb63b39d186718ddf2f5c804b9723 Mon Sep 17 00:00:00 2001 From: Vladimir Matveev Date: Thu, 22 Oct 2015 09:50:38 -0700 Subject: [PATCH 084/227] defer allocation of error message text in binder --- src/compiler/binder.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index 9126bc465bd..3d7d980706b 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -1410,9 +1410,16 @@ namespace ts { } function popImplicitLabel(implicitLabelIndex: number, outerState: Reachability): void { - Debug.assert(labelStack.length === implicitLabelIndex + 1, `Label stack: ${labelStack.length}, index:${implicitLabelIndex}`); + if (labelStack.length !== implicitLabelIndex + 1) { + Debug.assert(false, `Label stack: ${labelStack.length}, index:${implicitLabelIndex}`); + } + let i = implicitLabels.pop(); - Debug.assert(implicitLabelIndex === i, `i: ${i}, index: ${implicitLabelIndex}`); + + if (implicitLabelIndex !== i) { + Debug.assert(false, `i: ${i}, index: ${implicitLabelIndex}`); + } + setCurrentStateAtLabel(labelStack.pop(), outerState, /*name*/ undefined); } From abf270a9b4498e1f7d41fad503e3f606d043ff12 Mon Sep 17 00:00:00 2001 From: Vladimir Matveev Date: Thu, 22 Oct 2015 14:12:57 -0700 Subject: [PATCH 085/227] do not look into nested es6 exports / imports when collecting external modules --- src/compiler/program.ts | 87 ++++++++++++++++++--------------------- src/compiler/utilities.ts | 2 +- 2 files changed, 42 insertions(+), 47 deletions(-) diff --git a/src/compiler/program.ts b/src/compiler/program.ts index 13d939c8ac7..583db7850b9 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -689,61 +689,56 @@ namespace ts { let imports: LiteralExpression[]; for (let node of file.statements) { - collect(node, /* allowRelativeModuleNames */ true); + collect(node, /* allowRelativeModuleNames */ true, /* collectOnlyRequireCalls */ false); } file.imports = imports || emptyArray; - function collect(node: Node, allowRelativeModuleNames: boolean): void { - switch (node.kind) { - case SyntaxKind.ImportDeclaration: - case SyntaxKind.ImportEqualsDeclaration: - case SyntaxKind.ExportDeclaration: - let moduleNameExpr = getExternalModuleName(node); - if (!moduleNameExpr || moduleNameExpr.kind !== SyntaxKind.StringLiteral) { - break; - } - if (!(moduleNameExpr).text) { - break; - } + return; - if (allowRelativeModuleNames || !isExternalModuleNameRelative((moduleNameExpr).text)) { - (imports || (imports = [])).push(moduleNameExpr); - } - break; - case SyntaxKind.CallExpression: - if (isJavaScriptFile && isRequireCall(node)) { - - let jsImports = (node).arguments; - if (jsImports) { - imports = (imports || []); - for (var i = 0; i < jsImports.length; i++) { - if (jsImports[i].kind === SyntaxKind.StringLiteral) { - imports.push(jsImports[i]); - } - } + function collect(node: Node, allowRelativeModuleNames: boolean, collectOnlyRequireCalls: boolean): void { + if (!collectOnlyRequireCalls) { + switch (node.kind) { + case SyntaxKind.ImportDeclaration: + case SyntaxKind.ImportEqualsDeclaration: + case SyntaxKind.ExportDeclaration: + let moduleNameExpr = getExternalModuleName(node); + if (!moduleNameExpr || moduleNameExpr.kind !== SyntaxKind.StringLiteral) { + break; } - } - break; - case SyntaxKind.ModuleDeclaration: - if ((node).name.kind === SyntaxKind.StringLiteral && (node.flags & NodeFlags.Ambient || isDeclarationFile(file))) { - // TypeScript 1.0 spec (April 2014): 12.1.6 - // An AmbientExternalModuleDeclaration declares an external module. - // This type of declaration is permitted only in the global module. - // The StringLiteral must specify a top - level external module name. - // Relative external module names are not permitted - forEachChild((node).body, node => { + if (!(moduleNameExpr).text) { + break; + } + + if (allowRelativeModuleNames || !isExternalModuleNameRelative((moduleNameExpr).text)) { + (imports || (imports = [])).push(moduleNameExpr); + } + break; + case SyntaxKind.ModuleDeclaration: + if ((node).name.kind === SyntaxKind.StringLiteral && (node.flags & NodeFlags.Ambient || isDeclarationFile(file))) { // TypeScript 1.0 spec (April 2014): 12.1.6 - // An ExternalImportDeclaration in anAmbientExternalModuleDeclaration may reference other external modules - // only through top - level external module names. Relative external module names are not permitted. - collect(node, /* allowRelativeModuleNames */ false); - }); - } - break; + // An AmbientExternalModuleDeclaration declares an external module. + // This type of declaration is permitted only in the global module. + // The StringLiteral must specify a top - level external module name. + // Relative external module names are not permitted + forEachChild((node).body, node => { + // TypeScript 1.0 spec (April 2014): 12.1.6 + // An ExternalImportDeclaration in anAmbientExternalModuleDeclaration may reference other external modules + // only through top - level external module names. Relative external module names are not permitted. + collect(node, /* allowRelativeModuleNames */ false, collectOnlyRequireCalls); + }); + } + break; + } } - if (isSourceFileJavaScript(file)) { - forEachChild(node, node => collect(node, allowRelativeModuleNames)); + if (isJavaScriptFile) { + if (isRequireCall(node)) { + (imports || (imports = [])).push((node).arguments[0]); + } + else { + forEachChild(node, node => collect(node, allowRelativeModuleNames, /* collectOnlyRequireCalls */ true)); + } } } } diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 9eff4370ec2..5506a1d5e3d 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -1045,7 +1045,7 @@ namespace ts { /** * Returns true if the node is a CallExpression to the identifier 'require' with - * exactly one argument. + * exactly one string literal argument. * This function does not test if the node is in a JavaScript file or not. */ export function isRequireCall(expression: Node): expression is CallExpression { From 91eb758d5958eb0c3f19e3d2ce1a6a5923019699 Mon Sep 17 00:00:00 2001 From: Ryan Cavanaugh Date: Thu, 22 Oct 2015 15:39:01 -0700 Subject: [PATCH 086/227] CR feedback --- src/compiler/checker.ts | 12 ++---------- src/harness/harness.ts | 2 +- 2 files changed, 3 insertions(+), 11 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index ac5056bf769..c407ca0c183 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -160,8 +160,6 @@ namespace ts { let getGlobalPromiseConstructorLikeType: () => ObjectType; let getGlobalThenableType: () => ObjectType; - let cjsRequireType: Type; - let tupleTypes: Map = {}; let unionTypes: Map = {}; let intersectionTypes: Map = {}; @@ -4203,13 +4201,9 @@ namespace ts { * getExportedTypeFromNamespace('JSX', 'Element') returns the JSX.Element type */ function getExportedTypeFromNamespace(namespace: string, name: string): Type { - let typeSymbol = getExportedSymbolFromNamespace(namespace, name); - return typeSymbol && getDeclaredTypeOfSymbol(typeSymbol); - } - - function getExportedSymbolFromNamespace(namespace: string, name: string): Symbol { let namespaceSymbol = getGlobalSymbol(namespace, SymbolFlags.Namespace, /*diagnosticMessage*/ undefined); - return namespaceSymbol && getSymbol(namespaceSymbol.exports, name, SymbolFlags.Type | SymbolFlags.Value); + let typeSymbol = namespaceSymbol && getSymbol(namespaceSymbol.exports, name, SymbolFlags.Type); + return typeSymbol && getDeclaredTypeOfSymbol(typeSymbol); } function getGlobalESSymbolConstructorSymbol() { @@ -14938,8 +14932,6 @@ namespace ts { getGlobalPromiseConstructorLikeType = memoize(() => getGlobalType("PromiseConstructorLike")); getGlobalThenableType = memoize(createThenableType); - cjsRequireType = getExportedTypeFromNamespace("CommonJS", "Require"); - // If we're in ES6 mode, load the TemplateStringsArray. // Otherwise, default to 'unknown' for the purposes of type checking in LS scenarios. if (languageVersion >= ScriptTarget.ES6) { diff --git a/src/harness/harness.ts b/src/harness/harness.ts index 91897493fd9..a37b647a124 100644 --- a/src/harness/harness.ts +++ b/src/harness/harness.ts @@ -211,7 +211,7 @@ namespace Utils { return isNodeOrArray(v) ? serializeNode(v) : v; }, " "); - function getKindName(k: number|string): string { + function getKindName(k: number | string): string { if (typeof k === "string") { return k; } From f038a0f18c6a14b94272181ed2519dd1958a505c Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Fri, 23 Oct 2015 15:33:18 -0700 Subject: [PATCH 087/227] ignore names when checking type parameter equality --- src/compiler/checker.ts | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index b3fa607b0ea..6091b028443 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -5055,9 +5055,6 @@ namespace ts { } function typeParameterIdenticalTo(source: TypeParameter, target: TypeParameter): Ternary { - if (source.symbol.name !== target.symbol.name) { - return Ternary.False; - } // covers case when both type parameters does not have constraint (both equal to noConstraintType) if (source.constraint === target.constraint) { return Ternary.True; From 5e82f234ec28ebb87d467f2df1e6f8d93c5c0ef3 Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Fri, 23 Oct 2015 15:45:45 -0700 Subject: [PATCH 088/227] Add test of issue --- .../reference/typeParameterEquality.js | 11 ++++++++++ .../reference/typeParameterEquality.symbols | 19 ++++++++++++++++++ .../reference/typeParameterEquality.types | 20 +++++++++++++++++++ tests/cases/compiler/typeParameterEquality.ts | 5 +++++ 4 files changed, 55 insertions(+) create mode 100644 tests/baselines/reference/typeParameterEquality.js create mode 100644 tests/baselines/reference/typeParameterEquality.symbols create mode 100644 tests/baselines/reference/typeParameterEquality.types create mode 100644 tests/cases/compiler/typeParameterEquality.ts diff --git a/tests/baselines/reference/typeParameterEquality.js b/tests/baselines/reference/typeParameterEquality.js new file mode 100644 index 00000000000..b77e534b354 --- /dev/null +++ b/tests/baselines/reference/typeParameterEquality.js @@ -0,0 +1,11 @@ +//// [typeParameterEquality.ts] +class C { + get x(): (a: T) => T { return null; } + set x(p: (a: U) => U) {} +} + +//// [typeParameterEquality.js] +class C { + get x() { return null; } + set x(p) { } +} diff --git a/tests/baselines/reference/typeParameterEquality.symbols b/tests/baselines/reference/typeParameterEquality.symbols new file mode 100644 index 00000000000..562d6277d93 --- /dev/null +++ b/tests/baselines/reference/typeParameterEquality.symbols @@ -0,0 +1,19 @@ +=== tests/cases/compiler/typeParameterEquality.ts === +class C { +>C : Symbol(C, Decl(typeParameterEquality.ts, 0, 0)) + + get x(): (a: T) => T { return null; } +>x : Symbol(x, Decl(typeParameterEquality.ts, 0, 9), Decl(typeParameterEquality.ts, 1, 44)) +>T : Symbol(T, Decl(typeParameterEquality.ts, 1, 14)) +>a : Symbol(a, Decl(typeParameterEquality.ts, 1, 17)) +>T : Symbol(T, Decl(typeParameterEquality.ts, 1, 14)) +>T : Symbol(T, Decl(typeParameterEquality.ts, 1, 14)) + + set x(p: (a: U) => U) {} +>x : Symbol(x, Decl(typeParameterEquality.ts, 0, 9), Decl(typeParameterEquality.ts, 1, 44)) +>p : Symbol(p, Decl(typeParameterEquality.ts, 2, 10)) +>U : Symbol(U, Decl(typeParameterEquality.ts, 2, 14)) +>a : Symbol(a, Decl(typeParameterEquality.ts, 2, 17)) +>U : Symbol(U, Decl(typeParameterEquality.ts, 2, 14)) +>U : Symbol(U, Decl(typeParameterEquality.ts, 2, 14)) +} diff --git a/tests/baselines/reference/typeParameterEquality.types b/tests/baselines/reference/typeParameterEquality.types new file mode 100644 index 00000000000..2e51c3a51e6 --- /dev/null +++ b/tests/baselines/reference/typeParameterEquality.types @@ -0,0 +1,20 @@ +=== tests/cases/compiler/typeParameterEquality.ts === +class C { +>C : C + + get x(): (a: T) => T { return null; } +>x : (a: T) => T +>T : T +>a : T +>T : T +>T : T +>null : null + + set x(p: (a: U) => U) {} +>x : (a: T) => T +>p : (a: U) => U +>U : U +>a : U +>U : U +>U : U +} diff --git a/tests/cases/compiler/typeParameterEquality.ts b/tests/cases/compiler/typeParameterEquality.ts new file mode 100644 index 00000000000..aa136aa3655 --- /dev/null +++ b/tests/cases/compiler/typeParameterEquality.ts @@ -0,0 +1,5 @@ +// @target: es6 +class C { + get x(): (a: T) => T { return null; } + set x(p: (a: U) => U) {} +} \ No newline at end of file From 6618fd21bfe5e34a9d0014d5a60f8ef97e0b91c8 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Mon, 26 Oct 2015 15:42:02 -0700 Subject: [PATCH 089/227] Added tests for operations that use assignable to/from. --- .../stringLiteralCheckedInIf01.ts | 17 ++++++++++ .../stringLiteralCheckedInIf02.ts | 18 +++++++++++ .../stringLiteralMatchedInSwitch01.ts | 13 ++++++++ .../stringLiteralTypeAssertion01.ts | 31 +++++++++++++++++++ 4 files changed, 79 insertions(+) create mode 100644 tests/cases/conformance/types/stringLiteral/stringLiteralCheckedInIf01.ts create mode 100644 tests/cases/conformance/types/stringLiteral/stringLiteralCheckedInIf02.ts create mode 100644 tests/cases/conformance/types/stringLiteral/stringLiteralMatchedInSwitch01.ts create mode 100644 tests/cases/conformance/types/stringLiteral/stringLiteralTypeAssertion01.ts diff --git a/tests/cases/conformance/types/stringLiteral/stringLiteralCheckedInIf01.ts b/tests/cases/conformance/types/stringLiteral/stringLiteralCheckedInIf01.ts new file mode 100644 index 00000000000..093824acf0d --- /dev/null +++ b/tests/cases/conformance/types/stringLiteral/stringLiteralCheckedInIf01.ts @@ -0,0 +1,17 @@ + +type S = "a" | "b"; +type T = S[] | S; + +function f(foo: T) { + if (foo === "a") { + return foo; + } + else if (foo === "b") { + return foo; + } + else { + return (foo as S[])[0]; + } + + throw new Error("Unreachable code hit."); +} \ No newline at end of file diff --git a/tests/cases/conformance/types/stringLiteral/stringLiteralCheckedInIf02.ts b/tests/cases/conformance/types/stringLiteral/stringLiteralCheckedInIf02.ts new file mode 100644 index 00000000000..53d625f7200 --- /dev/null +++ b/tests/cases/conformance/types/stringLiteral/stringLiteralCheckedInIf02.ts @@ -0,0 +1,18 @@ + +type S = "a" | "b"; +type T = S[] | S; + +function isS(t: T): t is S { + return t === "a" || t === "b"; +} + +function f(foo: T) { + if (isS(foo)) { + return foo; + } + else { + return foo[0]; + } + + throw new Error("Unreachable code hit."); +} \ No newline at end of file diff --git a/tests/cases/conformance/types/stringLiteral/stringLiteralMatchedInSwitch01.ts b/tests/cases/conformance/types/stringLiteral/stringLiteralMatchedInSwitch01.ts new file mode 100644 index 00000000000..141f5d12795 --- /dev/null +++ b/tests/cases/conformance/types/stringLiteral/stringLiteralMatchedInSwitch01.ts @@ -0,0 +1,13 @@ + +type S = "a" | "b"; +type T = S[] | S; + +var foo: T; +switch (foo) { + case "a": + case "b": + break; + default: + foo = (foo as S[])[0]; + break; +} \ No newline at end of file diff --git a/tests/cases/conformance/types/stringLiteral/stringLiteralTypeAssertion01.ts b/tests/cases/conformance/types/stringLiteral/stringLiteralTypeAssertion01.ts new file mode 100644 index 00000000000..ec1f1e5eb56 --- /dev/null +++ b/tests/cases/conformance/types/stringLiteral/stringLiteralTypeAssertion01.ts @@ -0,0 +1,31 @@ + +type S = "a" | "b"; +type T = S[] | S; + +var s: S; +var t: T; +var str: string; + +//////////////// + +s = t; +s = t as S; + +s = str; +s = str as S; + +//////////////// + +t = s; +t = s as T; + +t = str; +t = str as T; + +//////////////// + +str = s; +str = s as string; + +str = t; +str = t as string; From 5e2314303f89ac4dae495700471c9f6d8f5f3303 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Mon, 26 Oct 2015 18:49:41 -0700 Subject: [PATCH 090/227] Accepted baselines. --- .../stringLiteralCheckedInIf01.errors.txt | 26 +++++++++ .../reference/stringLiteralCheckedInIf01.js | 32 +++++++++++ .../stringLiteralCheckedInIf02.errors.txt | 27 +++++++++ .../reference/stringLiteralCheckedInIf02.js | 33 +++++++++++ .../stringLiteralMatchedInSwitch01.errors.txt | 26 +++++++++ .../stringLiteralMatchedInSwitch01.js | 25 +++++++++ .../stringLiteralTypeAssertion01.errors.txt | 55 +++++++++++++++++++ .../reference/stringLiteralTypeAssertion01.js | 53 ++++++++++++++++++ 8 files changed, 277 insertions(+) create mode 100644 tests/baselines/reference/stringLiteralCheckedInIf01.errors.txt create mode 100644 tests/baselines/reference/stringLiteralCheckedInIf01.js create mode 100644 tests/baselines/reference/stringLiteralCheckedInIf02.errors.txt create mode 100644 tests/baselines/reference/stringLiteralCheckedInIf02.js create mode 100644 tests/baselines/reference/stringLiteralMatchedInSwitch01.errors.txt create mode 100644 tests/baselines/reference/stringLiteralMatchedInSwitch01.js create mode 100644 tests/baselines/reference/stringLiteralTypeAssertion01.errors.txt create mode 100644 tests/baselines/reference/stringLiteralTypeAssertion01.js diff --git a/tests/baselines/reference/stringLiteralCheckedInIf01.errors.txt b/tests/baselines/reference/stringLiteralCheckedInIf01.errors.txt new file mode 100644 index 00000000000..fb94cf6bc96 --- /dev/null +++ b/tests/baselines/reference/stringLiteralCheckedInIf01.errors.txt @@ -0,0 +1,26 @@ +tests/cases/conformance/types/stringLiteral/stringLiteralCheckedInIf01.ts(6,9): error TS2365: Operator '===' cannot be applied to types '("a" | "b")[] | "a" | "b"' and 'string'. +tests/cases/conformance/types/stringLiteral/stringLiteralCheckedInIf01.ts(9,14): error TS2365: Operator '===' cannot be applied to types '("a" | "b")[] | "a" | "b"' and 'string'. + + +==== tests/cases/conformance/types/stringLiteral/stringLiteralCheckedInIf01.ts (2 errors) ==== + + type S = "a" | "b"; + type T = S[] | S; + + function f(foo: T) { + if (foo === "a") { + ~~~~~~~~~~~ +!!! error TS2365: Operator '===' cannot be applied to types '("a" | "b")[] | "a" | "b"' and 'string'. + return foo; + } + else if (foo === "b") { + ~~~~~~~~~~~ +!!! error TS2365: Operator '===' cannot be applied to types '("a" | "b")[] | "a" | "b"' and 'string'. + return foo; + } + else { + return (foo as S[])[0]; + } + + throw new Error("Unreachable code hit."); + } \ No newline at end of file diff --git a/tests/baselines/reference/stringLiteralCheckedInIf01.js b/tests/baselines/reference/stringLiteralCheckedInIf01.js new file mode 100644 index 00000000000..227a243133c --- /dev/null +++ b/tests/baselines/reference/stringLiteralCheckedInIf01.js @@ -0,0 +1,32 @@ +//// [stringLiteralCheckedInIf01.ts] + +type S = "a" | "b"; +type T = S[] | S; + +function f(foo: T) { + if (foo === "a") { + return foo; + } + else if (foo === "b") { + return foo; + } + else { + return (foo as S[])[0]; + } + + throw new Error("Unreachable code hit."); +} + +//// [stringLiteralCheckedInIf01.js] +function f(foo) { + if (foo === "a") { + return foo; + } + else if (foo === "b") { + return foo; + } + else { + return foo[0]; + } + throw new Error("Unreachable code hit."); +} diff --git a/tests/baselines/reference/stringLiteralCheckedInIf02.errors.txt b/tests/baselines/reference/stringLiteralCheckedInIf02.errors.txt new file mode 100644 index 00000000000..ced5adf6263 --- /dev/null +++ b/tests/baselines/reference/stringLiteralCheckedInIf02.errors.txt @@ -0,0 +1,27 @@ +tests/cases/conformance/types/stringLiteral/stringLiteralCheckedInIf02.ts(6,12): error TS2365: Operator '===' cannot be applied to types '("a" | "b")[] | "a" | "b"' and 'string'. +tests/cases/conformance/types/stringLiteral/stringLiteralCheckedInIf02.ts(6,25): error TS2365: Operator '===' cannot be applied to types '("a" | "b")[] | "a" | "b"' and 'string'. + + +==== tests/cases/conformance/types/stringLiteral/stringLiteralCheckedInIf02.ts (2 errors) ==== + + type S = "a" | "b"; + type T = S[] | S; + + function isS(t: T): t is S { + return t === "a" || t === "b"; + ~~~~~~~~~ +!!! error TS2365: Operator '===' cannot be applied to types '("a" | "b")[] | "a" | "b"' and 'string'. + ~~~~~~~~~ +!!! error TS2365: Operator '===' cannot be applied to types '("a" | "b")[] | "a" | "b"' and 'string'. + } + + function f(foo: T) { + if (isS(foo)) { + return foo; + } + else { + return foo[0]; + } + + throw new Error("Unreachable code hit."); + } \ No newline at end of file diff --git a/tests/baselines/reference/stringLiteralCheckedInIf02.js b/tests/baselines/reference/stringLiteralCheckedInIf02.js new file mode 100644 index 00000000000..b0b3a64116b --- /dev/null +++ b/tests/baselines/reference/stringLiteralCheckedInIf02.js @@ -0,0 +1,33 @@ +//// [stringLiteralCheckedInIf02.ts] + +type S = "a" | "b"; +type T = S[] | S; + +function isS(t: T): t is S { + return t === "a" || t === "b"; +} + +function f(foo: T) { + if (isS(foo)) { + return foo; + } + else { + return foo[0]; + } + + throw new Error("Unreachable code hit."); +} + +//// [stringLiteralCheckedInIf02.js] +function isS(t) { + return t === "a" || t === "b"; +} +function f(foo) { + if (isS(foo)) { + return foo; + } + else { + return foo[0]; + } + throw new Error("Unreachable code hit."); +} diff --git a/tests/baselines/reference/stringLiteralMatchedInSwitch01.errors.txt b/tests/baselines/reference/stringLiteralMatchedInSwitch01.errors.txt new file mode 100644 index 00000000000..17e690715a1 --- /dev/null +++ b/tests/baselines/reference/stringLiteralMatchedInSwitch01.errors.txt @@ -0,0 +1,26 @@ +tests/cases/conformance/types/stringLiteral/stringLiteralMatchedInSwitch01.ts(7,10): error TS2322: Type 'string' is not assignable to type '("a" | "b")[] | "a" | "b"'. + Type 'string' is not assignable to type '"b"'. +tests/cases/conformance/types/stringLiteral/stringLiteralMatchedInSwitch01.ts(8,10): error TS2322: Type 'string' is not assignable to type '("a" | "b")[] | "a" | "b"'. + Type 'string' is not assignable to type '"b"'. + + +==== tests/cases/conformance/types/stringLiteral/stringLiteralMatchedInSwitch01.ts (2 errors) ==== + + type S = "a" | "b"; + type T = S[] | S; + + var foo: T; + switch (foo) { + case "a": + ~~~ +!!! error TS2322: Type 'string' is not assignable to type '("a" | "b")[] | "a" | "b"'. +!!! error TS2322: Type 'string' is not assignable to type '"b"'. + case "b": + ~~~ +!!! error TS2322: Type 'string' is not assignable to type '("a" | "b")[] | "a" | "b"'. +!!! error TS2322: Type 'string' is not assignable to type '"b"'. + break; + default: + foo = (foo as S[])[0]; + break; + } \ No newline at end of file diff --git a/tests/baselines/reference/stringLiteralMatchedInSwitch01.js b/tests/baselines/reference/stringLiteralMatchedInSwitch01.js new file mode 100644 index 00000000000..b9b24cf0c66 --- /dev/null +++ b/tests/baselines/reference/stringLiteralMatchedInSwitch01.js @@ -0,0 +1,25 @@ +//// [stringLiteralMatchedInSwitch01.ts] + +type S = "a" | "b"; +type T = S[] | S; + +var foo: T; +switch (foo) { + case "a": + case "b": + break; + default: + foo = (foo as S[])[0]; + break; +} + +//// [stringLiteralMatchedInSwitch01.js] +var foo; +switch (foo) { + case "a": + case "b": + break; + default: + foo = foo[0]; + break; +} diff --git a/tests/baselines/reference/stringLiteralTypeAssertion01.errors.txt b/tests/baselines/reference/stringLiteralTypeAssertion01.errors.txt new file mode 100644 index 00000000000..867ad80ee7f --- /dev/null +++ b/tests/baselines/reference/stringLiteralTypeAssertion01.errors.txt @@ -0,0 +1,55 @@ +tests/cases/conformance/types/stringLiteral/stringLiteralTypeAssertion01.ts(22,5): error TS2352: Neither type 'string' nor type '("a" | "b")[] | "a" | "b"' is assignable to the other. + Type 'string' is not assignable to type '"b"'. +tests/cases/conformance/types/stringLiteral/stringLiteralTypeAssertion01.ts(23,5): error TS2352: Neither type 'string' nor type '("a" | "b")[] | "a" | "b"' is assignable to the other. + Type 'string' is not assignable to type '"b"'. +tests/cases/conformance/types/stringLiteral/stringLiteralTypeAssertion01.ts(30,7): error TS2352: Neither type '("a" | "b")[] | "a" | "b"' nor type 'string' is assignable to the other. + Type '("a" | "b")[]' is not assignable to type 'string'. +tests/cases/conformance/types/stringLiteral/stringLiteralTypeAssertion01.ts(31,7): error TS2352: Neither type '("a" | "b")[] | "a" | "b"' nor type 'string' is assignable to the other. + Type '("a" | "b")[]' is not assignable to type 'string'. + + +==== tests/cases/conformance/types/stringLiteral/stringLiteralTypeAssertion01.ts (4 errors) ==== + + type S = "a" | "b"; + type T = S[] | S; + + var s: S; + var t: T; + var str: string; + + //////////////// + + s = t; + s = t as S; + + s = str; + s = str as S; + + //////////////// + + t = s; + t = s as T; + + t = str; + ~~~~~~ +!!! error TS2352: Neither type 'string' nor type '("a" | "b")[] | "a" | "b"' is assignable to the other. +!!! error TS2352: Type 'string' is not assignable to type '"b"'. + t = str as T; + ~~~~~~~~ +!!! error TS2352: Neither type 'string' nor type '("a" | "b")[] | "a" | "b"' is assignable to the other. +!!! error TS2352: Type 'string' is not assignable to type '"b"'. + + //////////////// + + str = s; + str = s as string; + + str = t; + ~~~~~~~~~ +!!! error TS2352: Neither type '("a" | "b")[] | "a" | "b"' nor type 'string' is assignable to the other. +!!! error TS2352: Type '("a" | "b")[]' is not assignable to type 'string'. + str = t as string; + ~~~~~~~~~~~ +!!! error TS2352: Neither type '("a" | "b")[] | "a" | "b"' nor type 'string' is assignable to the other. +!!! error TS2352: Type '("a" | "b")[]' is not assignable to type 'string'. + \ No newline at end of file diff --git a/tests/baselines/reference/stringLiteralTypeAssertion01.js b/tests/baselines/reference/stringLiteralTypeAssertion01.js new file mode 100644 index 00000000000..7877004cf01 --- /dev/null +++ b/tests/baselines/reference/stringLiteralTypeAssertion01.js @@ -0,0 +1,53 @@ +//// [stringLiteralTypeAssertion01.ts] + +type S = "a" | "b"; +type T = S[] | S; + +var s: S; +var t: T; +var str: string; + +//////////////// + +s = t; +s = t as S; + +s = str; +s = str as S; + +//////////////// + +t = s; +t = s as T; + +t = str; +t = str as T; + +//////////////// + +str = s; +str = s as string; + +str = t; +str = t as string; + + +//// [stringLiteralTypeAssertion01.js] +var s; +var t; +var str; +//////////////// +s = t; +s = t; +s = str; +s = str; +//////////////// +t = s; +t = s; +t = str; +t = str; +//////////////// +str = s; +str = s; +str = t; +str = t; From 46141f52137bcdc7c3fa5a551b8d1abc9cec4846 Mon Sep 17 00:00:00 2001 From: Yui T Date: Tue, 27 Oct 2015 13:20:12 -0700 Subject: [PATCH 091/227] Copy generated diagnostic messages json from src/compiler to built/local --- Jakefile.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Jakefile.js b/Jakefile.js index 23720a2e7c2..7444f72a2dc 100644 --- a/Jakefile.js +++ b/Jakefile.js @@ -320,6 +320,8 @@ var processDiagnosticMessagesJs = path.join(scriptsDirectory, "processDiagnostic var processDiagnosticMessagesTs = path.join(scriptsDirectory, "processDiagnosticMessages.ts"); var diagnosticMessagesJson = path.join(compilerDirectory, "diagnosticMessages.json"); var diagnosticInfoMapTs = path.join(compilerDirectory, "diagnosticInformationMap.generated.ts"); +var generatedDiagnosticMessagesJSON = path.join(compilerDirectory, "diagnosticMessages.generated.json"); +var builtGeneratedDiagnosticMessagesJSON = path.join(builtLocalDirectory, "diagnosticMessages.generated.json"); file(processDiagnosticMessagesTs); @@ -343,6 +345,7 @@ file(diagnosticInfoMapTs, [processDiagnosticMessagesJs, diagnosticMessagesJson], process.stderr.write(error); }); ex.addListener("cmdEnd", function() { + jake.cpR(generatedDiagnosticMessagesJSON, builtGeneratedDiagnosticMessagesJSON) complete(); }); ex.run(); From f5d4aa7d9c0a3fbe5c731e0b4288839538541e5d Mon Sep 17 00:00:00 2001 From: Vladimir Matveev Date: Tue, 27 Oct 2015 11:52:57 -0700 Subject: [PATCH 092/227] addressed PR feedback (change command line flag description), added tests --- src/compiler/commandLineParser.ts | 2 +- src/compiler/diagnosticMessages.json | 3 +-- tests/cases/unittests/moduleResolution.ts | 25 +++++++++++++++++++++++ 3 files changed, 27 insertions(+), 3 deletions(-) diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index 1d4ad8ae4df..90373b1a947 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -251,7 +251,7 @@ namespace ts { { name: "forceConsistentCasingInFileNames", type: "boolean", - description: Diagnostics.Raise_error_if_two_file_names_in_program_differ_only_in_case + description: Diagnostics.Disallow_inconsistently_cased_references_to_the_same_file }, ]; diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 7202713cbe1..edfe1fc577c 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -2298,11 +2298,10 @@ "category": "Message", "code": 6072 }, - "Raise error if two file names in program differ only in case.": { + "Disallow inconsistently-cased references to the same file.": { "category": "Message", "code": 6073 }, - "Variable '{0}' implicitly has an '{1}' type.": { "category": "Error", "code": 7005 diff --git a/tests/cases/unittests/moduleResolution.ts b/tests/cases/unittests/moduleResolution.ts index 0758fe7cfd5..a76428a62a1 100644 --- a/tests/cases/unittests/moduleResolution.ts +++ b/tests/cases/unittests/moduleResolution.ts @@ -254,6 +254,14 @@ export = C; }; test(files, "/parent/app",["myapp.ts"], 2, []); }); + + it("should find file referenced via absolute and relative names", () => { + const files: Map = { + "/a/b/c.ts": `/// `, + "/a/b/b.ts": "var x" + }; + test(files, "/a/b", ["c.ts", "/a/b/b.ts"], 2, []); + }); }); describe("Files with different casing", () => { @@ -320,6 +328,14 @@ export = C; test(files, { module: ts.ModuleKind.AMD, forceConsistentCasingInFileNames: true }, "/a/b", /* useCaseSensitiveFileNames */ false, ["c.ts", "d.ts"], [1149]); }); + it("should fail when two files used in program differ only in casing (imports, relative module names)", () => { + const files: Map = { + "moduleA.ts": `import {x} from "./ModuleB"`, + "moduleB.ts": "export var x" + }; + test(files, { module: ts.ModuleKind.CommonJS, forceConsistentCasingInFileNames: true }, "", /* useCaseSensitiveFileNames */ false, ["moduleA.ts", "moduleB.ts"], [1149]); + }); + it("should fail when two files exist on disk that differs only in casing", () => { const files: Map = { "/a/b/c.ts": `import {x} from "D"`, @@ -328,5 +344,14 @@ export = C; }; test(files, { module: ts.ModuleKind.AMD }, "/a/b", /* useCaseSensitiveFileNames */ true, ["c.ts", "d.ts"], [1149]); }); + + it("should fail when module name in 'require' calls has inconsistent casing", () => { + const files: Map = { + "moduleA.ts": `import a = require("./ModuleC")`, + "moduleB.ts": `import a = require("./moduleC")`, + "moduleC.ts": "export var x" + }; + test(files, { module: ts.ModuleKind.CommonJS, forceConsistentCasingInFileNames: true }, "", /* useCaseSensitiveFileNames */ false, ["moduleA.ts", "moduleB.ts", "moduleC.ts"], [1149, 1149]); + }) }); } \ No newline at end of file From d07a2774a31414b617560280e1613361d595d8ca Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Tue, 27 Oct 2015 13:48:37 -0700 Subject: [PATCH 093/227] const enum fixing in postprocess step --- Jakefile.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Jakefile.js b/Jakefile.js index 23720a2e7c2..bff7c118697 100644 --- a/Jakefile.js +++ b/Jakefile.js @@ -444,6 +444,8 @@ compileFile(servicesFile, servicesSources,[builtLocalDirectory, copyright].conca // Stanalone/web definition file using global 'ts' namespace jake.cpR(standaloneDefinitionsFile, nodeDefinitionsFile, {silent: true}); var definitionFileContents = fs.readFileSync(nodeDefinitionsFile).toString(); + definitionFileContents = definitionFileContents.replace(/^(\s*)(export )?const enum (\S+) {(\s*)$/gm, '$1$2enum $3 {$4'); + fs.writeFileSync(standaloneDefinitionsFile, definitionFileContents); // Official node package definition file, pointed to by 'typings' in package.json // Created by appending 'export = ts;' at the end of the standalone file to turn it into an external module From a5c9a2d263ec902e0c4952221005c6f63b74c118 Mon Sep 17 00:00:00 2001 From: Yui T Date: Tue, 27 Oct 2015 14:16:05 -0700 Subject: [PATCH 094/227] Include the built into local task --- Jakefile.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/Jakefile.js b/Jakefile.js index 7444f72a2dc..9156fe4109d 100644 --- a/Jakefile.js +++ b/Jakefile.js @@ -345,12 +345,17 @@ file(diagnosticInfoMapTs, [processDiagnosticMessagesJs, diagnosticMessagesJson], process.stderr.write(error); }); ex.addListener("cmdEnd", function() { - jake.cpR(generatedDiagnosticMessagesJSON, builtGeneratedDiagnosticMessagesJSON) complete(); }); ex.run(); }, {async: true}); +file(builtGeneratedDiagnosticMessagesJSON,[generatedDiagnosticMessagesJSON], function() { + if (fs.existsSync(builtLocalDirectory)) { + jake.cpR(generatedDiagnosticMessagesJSON, builtGeneratedDiagnosticMessagesJSON); + } +}, {async: true}); + desc("Generates a diagnostic file in TypeScript based on an input JSON file"); task("generate-diagnostics", [diagnosticInfoMapTs]); @@ -479,7 +484,7 @@ task("lssl", [lsslFile]); // Local target to build the compiler and services desc("Builds the full compiler and services"); -task("local", ["generate-diagnostics", "lib", tscFile, servicesFile, nodeDefinitionsFile, serverFile]); +task("local", ["generate-diagnostics", "lib", tscFile, servicesFile, nodeDefinitionsFile, serverFile, builtGeneratedDiagnosticMessagesJSON]); // Local target to build only tsc.js desc("Builds only the compiler"); From e2000ab4fb46cbdb3c2170e8c74e8eede8219a3c Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Tue, 27 Oct 2015 15:36:32 -0700 Subject: [PATCH 095/227] Add diagnosticMessages.generated.json to gitignore Before we accidentally commit it. --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 8d05f8f3337..c027f5873c8 100644 --- a/.gitignore +++ b/.gitignore @@ -31,6 +31,7 @@ scripts/processDiagnosticMessages.js scripts/importDefinitelyTypedTests/importDefinitelyTypedTests.js src/harness/*.js src/compiler/diagnosticInformationMap.generated.ts +src/compiler/diagnosticMessages.generated.json rwc-report.html *.swp build.json From b0764582ced07415b42a800d707158c6be5d5c11 Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Tue, 27 Oct 2015 16:24:19 -0700 Subject: [PATCH 096/227] accept api test baslines --- .../baselines/reference/APISample_compile.js | 2 +- tests/baselines/reference/APISample_linter.js | 24 +++++++++---------- .../reference/APISample_transform.js | 2 +- .../baselines/reference/APISample_watcher.js | 2 +- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/tests/baselines/reference/APISample_compile.js b/tests/baselines/reference/APISample_compile.js index f30bd2c21a9..694730e61c4 100644 --- a/tests/baselines/reference/APISample_compile.js +++ b/tests/baselines/reference/APISample_compile.js @@ -57,5 +57,5 @@ function compile(fileNames, options) { exports.compile = compile; compile(process.argv.slice(2), { noEmitOnError: true, noImplicitAny: true, - target: 1 /* ES5 */, module: 1 /* CommonJS */ + target: ts.ScriptTarget.ES5, module: ts.ModuleKind.CommonJS }); diff --git a/tests/baselines/reference/APISample_linter.js b/tests/baselines/reference/APISample_linter.js index aeff3a327f5..b7b2a93ba87 100644 --- a/tests/baselines/reference/APISample_linter.js +++ b/tests/baselines/reference/APISample_linter.js @@ -75,28 +75,28 @@ function delint(sourceFile) { delintNode(sourceFile); function delintNode(node) { switch (node.kind) { - case 199 /* ForStatement */: - case 200 /* ForInStatement */: - case 198 /* WhileStatement */: - case 197 /* DoStatement */: - if (node.statement.kind !== 192 /* Block */) { + case ts.SyntaxKind.ForStatement: + case ts.SyntaxKind.ForInStatement: + case ts.SyntaxKind.WhileStatement: + case ts.SyntaxKind.DoStatement: + if (node.statement.kind !== ts.SyntaxKind.Block) { report(node, "A looping statement's contents should be wrapped in a block body."); } break; - case 196 /* IfStatement */: + case ts.SyntaxKind.IfStatement: var ifStatement = node; - if (ifStatement.thenStatement.kind !== 192 /* Block */) { + if (ifStatement.thenStatement.kind !== ts.SyntaxKind.Block) { report(ifStatement.thenStatement, "An if statement's contents should be wrapped in a block body."); } if (ifStatement.elseStatement && - ifStatement.elseStatement.kind !== 192 /* Block */ && - ifStatement.elseStatement.kind !== 196 /* IfStatement */) { + ifStatement.elseStatement.kind !== ts.SyntaxKind.Block && + ifStatement.elseStatement.kind !== ts.SyntaxKind.IfStatement) { report(ifStatement.elseStatement, "An else statement's contents should be wrapped in a block body."); } break; - case 181 /* BinaryExpression */: + case ts.SyntaxKind.BinaryExpression: var op = node.operatorToken.kind; - if (op === 30 /* EqualsEqualsToken */ || op == 31 /* ExclamationEqualsToken */) { + if (op === ts.SyntaxKind.EqualsEqualsToken || op == ts.SyntaxKind.ExclamationEqualsToken) { report(node, "Use '===' and '!=='."); } break; @@ -112,7 +112,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(), 2 /* ES6 */, /*setParentNodes */ true); + var sourceFile = ts.createSourceFile(fileName, readFileSync(fileName).toString(), ts.ScriptTarget.ES6, /*setParentNodes */ true); // delint it delint(sourceFile); }); diff --git a/tests/baselines/reference/APISample_transform.js b/tests/baselines/reference/APISample_transform.js index a7f83f19b5e..0f22b8486dc 100644 --- a/tests/baselines/reference/APISample_transform.js +++ b/tests/baselines/reference/APISample_transform.js @@ -24,5 +24,5 @@ console.log(JSON.stringify(result)); */ var ts = require("typescript"); var source = "let x: string = 'string'"; -var result = ts.transpile(source, { module: 1 /* CommonJS */ }); +var result = ts.transpile(source, { module: ts.ModuleKind.CommonJS }); console.log(JSON.stringify(result)); diff --git a/tests/baselines/reference/APISample_watcher.js b/tests/baselines/reference/APISample_watcher.js index e2ab4e135dd..0b31ca3c7bf 100644 --- a/tests/baselines/reference/APISample_watcher.js +++ b/tests/baselines/reference/APISample_watcher.js @@ -181,4 +181,4 @@ function watch(rootFileNames, options) { var currentDirectoryFiles = fs.readdirSync(process.cwd()). filter(function (fileName) { return fileName.length >= 3 && fileName.substr(fileName.length - 3, 3) === ".ts"; }); // Start the watcher -watch(currentDirectoryFiles, { module: 1 /* CommonJS */ }); +watch(currentDirectoryFiles, { module: ts.ModuleKind.CommonJS }); From 96504fa604cc5bc8c2e587449100773310d7c478 Mon Sep 17 00:00:00 2001 From: Ron Buckton Date: Wed, 28 Oct 2015 00:09:50 -0700 Subject: [PATCH 097/227] Use resolvedSymbol instead of mergedSymbol. Fixes #5333. --- src/compiler/checker.ts | 11 +++++++---- .../asyncFunctionDeclaration15_es6.errors.txt | 4 ++-- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 5370e7c4f02..18c035412ed 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -11631,17 +11631,20 @@ namespace ts { // // When we get the type of the `Promise` symbol here, we get the type of the static // side of the `Promise` class, which would be `{ new (...): Promise }`. - + let promiseType = getTypeFromTypeNode(node.type); if (promiseType === unknownType && compilerOptions.isolatedModules) { // If we are compiling with isolatedModules, we may not be able to resolve the // type as a value. As such, we will just return unknownType; return unknownType; } - - let promiseConstructor = getMergedSymbol(promiseType.symbol); + + let promiseConstructor = getNodeLinks(node.type).resolvedSymbol; if (!promiseConstructor || !symbolIsValue(promiseConstructor)) { - error(node, Diagnostics.Type_0_is_not_a_valid_async_function_return_type, typeToString(promiseType)); + let typeName = promiseConstructor + ? symbolToString(promiseConstructor) + : typeToString(promiseType); + error(node, Diagnostics.Type_0_is_not_a_valid_async_function_return_type, typeName); return unknownType; } diff --git a/tests/baselines/reference/asyncFunctionDeclaration15_es6.errors.txt b/tests/baselines/reference/asyncFunctionDeclaration15_es6.errors.txt index 8c029eaaaf4..bc1ef24127a 100644 --- a/tests/baselines/reference/asyncFunctionDeclaration15_es6.errors.txt +++ b/tests/baselines/reference/asyncFunctionDeclaration15_es6.errors.txt @@ -1,7 +1,7 @@ tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration15_es6.ts(6,16): error TS1055: Type '{}' is not a valid async function return type. tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration15_es6.ts(7,16): error TS1055: Type 'any' is not a valid async function return type. tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration15_es6.ts(8,16): error TS1055: Type 'number' is not a valid async function return type. -tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration15_es6.ts(9,16): error TS1055: Type 'PromiseLike' is not a valid async function return type. +tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration15_es6.ts(9,16): error TS1055: Type 'PromiseLike' is not a valid async function return type. tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration15_es6.ts(10,16): error TS1055: Type 'typeof Thenable' is not a valid async function return type. Type 'Thenable' is not assignable to type 'PromiseLike'. Types of property 'then' are incompatible. @@ -28,7 +28,7 @@ tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration1 !!! error TS1055: Type 'number' is not a valid async function return type. async function fn5(): PromiseLike { } // error ~~~ -!!! error TS1055: Type 'PromiseLike' is not a valid async function return type. +!!! error TS1055: Type 'PromiseLike' is not a valid async function return type. async function fn6(): Thenable { } // error ~~~ !!! error TS1055: Type 'typeof Thenable' is not a valid async function return type. From 1e2108854b960c4fc671cb705d01057d237285c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20V=C5=A1eti=C4=8Dka?= Date: Fri, 23 Oct 2015 08:36:36 +0200 Subject: [PATCH 098/227] Add warning message empty THEN clause --- src/compiler/checker.ts | 5 ++++ src/compiler/diagnosticMessages.json | 6 ++++- .../reference/emptyThenWarning.errors.txt | 15 ++++++++++++ tests/baselines/reference/emptyThenWarning.js | 17 ++++++++++++++ .../reference/emptyThenWithoutWarning.js | 16 +++++++++++++ .../reference/emptyThenWithoutWarning.symbols | 13 +++++++++++ .../reference/emptyThenWithoutWarning.types | 23 +++++++++++++++++++ tests/cases/compiler/emptyThenWarning.ts | 6 +++++ .../cases/compiler/emptyThenWithoutWarning.ts | 7 ++++++ 9 files changed, 107 insertions(+), 1 deletion(-) create mode 100644 tests/baselines/reference/emptyThenWarning.errors.txt create mode 100644 tests/baselines/reference/emptyThenWarning.js create mode 100644 tests/baselines/reference/emptyThenWithoutWarning.js create mode 100644 tests/baselines/reference/emptyThenWithoutWarning.symbols create mode 100644 tests/baselines/reference/emptyThenWithoutWarning.types create mode 100644 tests/cases/compiler/emptyThenWarning.ts create mode 100644 tests/cases/compiler/emptyThenWithoutWarning.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 5370e7c4f02..d626b20e3ea 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -12227,6 +12227,11 @@ namespace ts { checkExpression(node.expression); checkSourceElement(node.thenStatement); + + if (node.thenStatement.kind === SyntaxKind.EmptyStatement) { + error(node.thenStatement, Diagnostics.The_body_of_an_if_statement_cannot_be_the_empty_statement); + } + checkSourceElement(node.elseStatement); } diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index da83628c706..4b4b3ab204d 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -799,7 +799,11 @@ "'=' can only be used in an object literal property inside a destructuring assignment.": { "category": "Error", "code": 1312 - }, + }, + "The body of an 'if' statement cannot be the empty statement.": { + "category": "Error", + "code": 1313 + }, "Duplicate identifier '{0}'.": { "category": "Error", "code": 2300 diff --git a/tests/baselines/reference/emptyThenWarning.errors.txt b/tests/baselines/reference/emptyThenWarning.errors.txt new file mode 100644 index 00000000000..a4f91261865 --- /dev/null +++ b/tests/baselines/reference/emptyThenWarning.errors.txt @@ -0,0 +1,15 @@ +tests/cases/compiler/emptyThenWarning.ts(1,6): error TS1313: The body of an 'if' statement cannot be the empty statement. +tests/cases/compiler/emptyThenWarning.ts(4,19): error TS1313: The body of an 'if' statement cannot be the empty statement. + + +==== tests/cases/compiler/emptyThenWarning.ts (2 errors) ==== + if(1); + ~ +!!! error TS1313: The body of an 'if' statement cannot be the empty statement. + + let x = 0; + if (true === true); { + ~ +!!! error TS1313: The body of an 'if' statement cannot be the empty statement. + x = 1; + } \ No newline at end of file diff --git a/tests/baselines/reference/emptyThenWarning.js b/tests/baselines/reference/emptyThenWarning.js new file mode 100644 index 00000000000..c7959d03d57 --- /dev/null +++ b/tests/baselines/reference/emptyThenWarning.js @@ -0,0 +1,17 @@ +//// [emptyThenWarning.ts] +if(1); + +let x = 0; +if (true === true); { + x = 1; +} + +//// [emptyThenWarning.js] +if (1) + ; +var x = 0; +if (true === true) + ; +{ + x = 1; +} diff --git a/tests/baselines/reference/emptyThenWithoutWarning.js b/tests/baselines/reference/emptyThenWithoutWarning.js new file mode 100644 index 00000000000..107531fe1e3 --- /dev/null +++ b/tests/baselines/reference/emptyThenWithoutWarning.js @@ -0,0 +1,16 @@ +//// [emptyThenWithoutWarning.ts] +let a = 4; + +if(a === 1 || a === 2 || a === 3) { +} +else { + let message = "Ooops"; +} + +//// [emptyThenWithoutWarning.js] +var a = 4; +if (a === 1 || a === 2 || a === 3) { +} +else { + var message = "Ooops"; +} diff --git a/tests/baselines/reference/emptyThenWithoutWarning.symbols b/tests/baselines/reference/emptyThenWithoutWarning.symbols new file mode 100644 index 00000000000..d707e7bc89c --- /dev/null +++ b/tests/baselines/reference/emptyThenWithoutWarning.symbols @@ -0,0 +1,13 @@ +=== tests/cases/compiler/emptyThenWithoutWarning.ts === +let a = 4; +>a : Symbol(a, Decl(emptyThenWithoutWarning.ts, 0, 3)) + +if(a === 1 || a === 2 || a === 3) { +>a : Symbol(a, Decl(emptyThenWithoutWarning.ts, 0, 3)) +>a : Symbol(a, Decl(emptyThenWithoutWarning.ts, 0, 3)) +>a : Symbol(a, Decl(emptyThenWithoutWarning.ts, 0, 3)) +} +else { + let message = "Ooops"; +>message : Symbol(message, Decl(emptyThenWithoutWarning.ts, 5, 7)) +} diff --git a/tests/baselines/reference/emptyThenWithoutWarning.types b/tests/baselines/reference/emptyThenWithoutWarning.types new file mode 100644 index 00000000000..2dca4059669 --- /dev/null +++ b/tests/baselines/reference/emptyThenWithoutWarning.types @@ -0,0 +1,23 @@ +=== tests/cases/compiler/emptyThenWithoutWarning.ts === +let a = 4; +>a : number +>4 : number + +if(a === 1 || a === 2 || a === 3) { +>a === 1 || a === 2 || a === 3 : boolean +>a === 1 || a === 2 : boolean +>a === 1 : boolean +>a : number +>1 : number +>a === 2 : boolean +>a : number +>2 : number +>a === 3 : boolean +>a : number +>3 : number +} +else { + let message = "Ooops"; +>message : string +>"Ooops" : string +} diff --git a/tests/cases/compiler/emptyThenWarning.ts b/tests/cases/compiler/emptyThenWarning.ts new file mode 100644 index 00000000000..4811c0b4400 --- /dev/null +++ b/tests/cases/compiler/emptyThenWarning.ts @@ -0,0 +1,6 @@ +if(1); + +let x = 0; +if (true === true); { + x = 1; +} \ No newline at end of file diff --git a/tests/cases/compiler/emptyThenWithoutWarning.ts b/tests/cases/compiler/emptyThenWithoutWarning.ts new file mode 100644 index 00000000000..c35b9b3181d --- /dev/null +++ b/tests/cases/compiler/emptyThenWithoutWarning.ts @@ -0,0 +1,7 @@ +let a = 4; + +if(a === 1 || a === 2 || a === 3) { +} +else { + let message = "Ooops"; +} \ No newline at end of file From 4bbb7d29c34715905187eb1314771fed5dc235c0 Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Wed, 28 Oct 2015 11:40:33 -0700 Subject: [PATCH 099/227] Remove async from builtGeneratedDiagnosticMessagesJSON task --- Jakefile.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jakefile.js b/Jakefile.js index 9156fe4109d..a602a2c459f 100644 --- a/Jakefile.js +++ b/Jakefile.js @@ -354,7 +354,7 @@ file(builtGeneratedDiagnosticMessagesJSON,[generatedDiagnosticMessagesJSON], fun if (fs.existsSync(builtLocalDirectory)) { jake.cpR(generatedDiagnosticMessagesJSON, builtGeneratedDiagnosticMessagesJSON); } -}, {async: true}); +}); desc("Generates a diagnostic file in TypeScript based on an input JSON file"); task("generate-diagnostics", [diagnosticInfoMapTs]); From 0aef9440f28609ead886a1745f52d2a517326fde Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Wed, 28 Oct 2015 11:41:27 -0700 Subject: [PATCH 100/227] Update LKG --- lib/lib.d.ts | 66 +- lib/lib.dom.d.ts | 66 +- lib/lib.es6.d.ts | 66 +- lib/lib.webworker.d.ts | 4 +- lib/tsc.js | 63663 ++++++++++----------- lib/tsserver.js | 90309 ++++++++++++++--------------- lib/typescript.d.ts | 4312 +- lib/typescript.js | 101111 +++++++++++++++++---------------- lib/typescriptServices.d.ts | 4312 +- lib/typescriptServices.js | 101111 +++++++++++++++++---------------- 10 files changed, 183448 insertions(+), 181572 deletions(-) diff --git a/lib/lib.d.ts b/lib/lib.d.ts index 4fe0d9cf547..fd4c05da220 100644 --- a/lib/lib.d.ts +++ b/lib/lib.d.ts @@ -6234,6 +6234,68 @@ interface Document extends Node, GlobalEventHandlers, NodeSelector, DocumentEven createElement(tagName: "x-ms-webview"): MSHTMLWebViewElement; createElement(tagName: "xmp"): HTMLBlockElement; createElement(tagName: string): HTMLElement; + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "a"): SVGAElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "circle"): SVGCircleElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "clipPath"): SVGClipPathElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "componentTransferFunction"): SVGComponentTransferFunctionElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "defs"): SVGDefsElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "desc"): SVGDescElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "ellipse"): SVGEllipseElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "feBlend"): SVGFEBlendElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "feColorMatrix"): SVGFEColorMatrixElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "feComponentTransfer"): SVGFEComponentTransferElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "feComposite"): SVGFECompositeElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "feConvolveMatrix"): SVGFEConvolveMatrixElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "feDiffuseLighting"): SVGFEDiffuseLightingElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "feDisplacementMap"): SVGFEDisplacementMapElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "feDistantLight"): SVGFEDistantLightElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "feFlood"): SVGFEFloodElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "feFuncA"): SVGFEFuncAElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "feFuncB"): SVGFEFuncBElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "feFuncG"): SVGFEFuncGElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "feFuncR"): SVGFEFuncRElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "feGaussianBlur"): SVGFEGaussianBlurElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "feImage"): SVGFEImageElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "feMerge"): SVGFEMergeElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "feMergeNode"): SVGFEMergeNodeElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "feMorphology"): SVGFEMorphologyElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "feOffset"): SVGFEOffsetElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "fePointLight"): SVGFEPointLightElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "feSpecularLighting"): SVGFESpecularLightingElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "feSpotLight"): SVGFESpotLightElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "feTile"): SVGFETileElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "feTurbulence"): SVGFETurbulenceElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "filter"): SVGFilterElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "foreignObject"): SVGForeignObjectElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "g"): SVGGElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "image"): SVGImageElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "gradient"): SVGGradientElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "line"): SVGLineElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "linearGradient"): SVGLinearGradientElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "marker"): SVGMarkerElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "mask"): SVGMaskElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "path"): SVGPathElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "metadata"): SVGMetadataElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "pattern"): SVGPatternElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "polygon"): SVGPolygonElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "polyline"): SVGPolylineElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "radialGradient"): SVGRadialGradientElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "rect"): SVGRectElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "svg"): SVGSVGElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "script"): SVGScriptElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "stop"): SVGStopElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "style"): SVGStyleElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "switch"): SVGSwitchElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "symbol"): SVGSymbolElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "tspan"): SVGTSpanElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "textContent"): SVGTextContentElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "text"): SVGTextElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "textPath"): SVGTextPathElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "textPositioning"): SVGTextPositioningElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "title"): SVGTitleElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "use"): SVGUseElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "view"): SVGViewElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: string): SVGElement createElementNS(namespaceURI: string, qualifiedName: string): Element; createExpression(expression: string, resolver: XPathNSResolver): XPathExpression; createNSResolver(nodeResolver: Node): XPathNSResolver; @@ -11055,14 +11117,12 @@ interface ImageData { width: number; } -interface ImageDataConstructor { +declare var ImageData: { prototype: ImageData; new(width: number, height: number): ImageData; new(array: Uint8ClampedArray, width: number, height: number): ImageData; } -declare var ImageData: ImageDataConstructor; - interface KeyboardEvent extends UIEvent { altKey: boolean; char: string; diff --git a/lib/lib.dom.d.ts b/lib/lib.dom.d.ts index 41d569ba9f7..69014415c15 100644 --- a/lib/lib.dom.d.ts +++ b/lib/lib.dom.d.ts @@ -2410,6 +2410,68 @@ interface Document extends Node, GlobalEventHandlers, NodeSelector, DocumentEven createElement(tagName: "x-ms-webview"): MSHTMLWebViewElement; createElement(tagName: "xmp"): HTMLBlockElement; createElement(tagName: string): HTMLElement; + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "a"): SVGAElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "circle"): SVGCircleElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "clipPath"): SVGClipPathElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "componentTransferFunction"): SVGComponentTransferFunctionElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "defs"): SVGDefsElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "desc"): SVGDescElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "ellipse"): SVGEllipseElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "feBlend"): SVGFEBlendElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "feColorMatrix"): SVGFEColorMatrixElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "feComponentTransfer"): SVGFEComponentTransferElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "feComposite"): SVGFECompositeElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "feConvolveMatrix"): SVGFEConvolveMatrixElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "feDiffuseLighting"): SVGFEDiffuseLightingElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "feDisplacementMap"): SVGFEDisplacementMapElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "feDistantLight"): SVGFEDistantLightElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "feFlood"): SVGFEFloodElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "feFuncA"): SVGFEFuncAElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "feFuncB"): SVGFEFuncBElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "feFuncG"): SVGFEFuncGElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "feFuncR"): SVGFEFuncRElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "feGaussianBlur"): SVGFEGaussianBlurElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "feImage"): SVGFEImageElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "feMerge"): SVGFEMergeElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "feMergeNode"): SVGFEMergeNodeElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "feMorphology"): SVGFEMorphologyElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "feOffset"): SVGFEOffsetElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "fePointLight"): SVGFEPointLightElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "feSpecularLighting"): SVGFESpecularLightingElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "feSpotLight"): SVGFESpotLightElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "feTile"): SVGFETileElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "feTurbulence"): SVGFETurbulenceElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "filter"): SVGFilterElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "foreignObject"): SVGForeignObjectElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "g"): SVGGElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "image"): SVGImageElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "gradient"): SVGGradientElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "line"): SVGLineElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "linearGradient"): SVGLinearGradientElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "marker"): SVGMarkerElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "mask"): SVGMaskElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "path"): SVGPathElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "metadata"): SVGMetadataElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "pattern"): SVGPatternElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "polygon"): SVGPolygonElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "polyline"): SVGPolylineElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "radialGradient"): SVGRadialGradientElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "rect"): SVGRectElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "svg"): SVGSVGElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "script"): SVGScriptElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "stop"): SVGStopElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "style"): SVGStyleElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "switch"): SVGSwitchElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "symbol"): SVGSymbolElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "tspan"): SVGTSpanElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "textContent"): SVGTextContentElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "text"): SVGTextElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "textPath"): SVGTextPathElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "textPositioning"): SVGTextPositioningElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "title"): SVGTitleElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "use"): SVGUseElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "view"): SVGViewElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: string): SVGElement createElementNS(namespaceURI: string, qualifiedName: string): Element; createExpression(expression: string, resolver: XPathNSResolver): XPathExpression; createNSResolver(nodeResolver: Node): XPathNSResolver; @@ -7231,14 +7293,12 @@ interface ImageData { width: number; } -interface ImageDataConstructor { +declare var ImageData: { prototype: ImageData; new(width: number, height: number): ImageData; new(array: Uint8ClampedArray, width: number, height: number): ImageData; } -declare var ImageData: ImageDataConstructor; - interface KeyboardEvent extends UIEvent { altKey: boolean; char: string; diff --git a/lib/lib.es6.d.ts b/lib/lib.es6.d.ts index df08155af04..564c302031d 100644 --- a/lib/lib.es6.d.ts +++ b/lib/lib.es6.d.ts @@ -7549,6 +7549,68 @@ interface Document extends Node, GlobalEventHandlers, NodeSelector, DocumentEven createElement(tagName: "x-ms-webview"): MSHTMLWebViewElement; createElement(tagName: "xmp"): HTMLBlockElement; createElement(tagName: string): HTMLElement; + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "a"): SVGAElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "circle"): SVGCircleElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "clipPath"): SVGClipPathElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "componentTransferFunction"): SVGComponentTransferFunctionElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "defs"): SVGDefsElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "desc"): SVGDescElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "ellipse"): SVGEllipseElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "feBlend"): SVGFEBlendElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "feColorMatrix"): SVGFEColorMatrixElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "feComponentTransfer"): SVGFEComponentTransferElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "feComposite"): SVGFECompositeElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "feConvolveMatrix"): SVGFEConvolveMatrixElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "feDiffuseLighting"): SVGFEDiffuseLightingElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "feDisplacementMap"): SVGFEDisplacementMapElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "feDistantLight"): SVGFEDistantLightElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "feFlood"): SVGFEFloodElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "feFuncA"): SVGFEFuncAElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "feFuncB"): SVGFEFuncBElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "feFuncG"): SVGFEFuncGElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "feFuncR"): SVGFEFuncRElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "feGaussianBlur"): SVGFEGaussianBlurElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "feImage"): SVGFEImageElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "feMerge"): SVGFEMergeElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "feMergeNode"): SVGFEMergeNodeElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "feMorphology"): SVGFEMorphologyElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "feOffset"): SVGFEOffsetElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "fePointLight"): SVGFEPointLightElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "feSpecularLighting"): SVGFESpecularLightingElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "feSpotLight"): SVGFESpotLightElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "feTile"): SVGFETileElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "feTurbulence"): SVGFETurbulenceElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "filter"): SVGFilterElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "foreignObject"): SVGForeignObjectElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "g"): SVGGElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "image"): SVGImageElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "gradient"): SVGGradientElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "line"): SVGLineElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "linearGradient"): SVGLinearGradientElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "marker"): SVGMarkerElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "mask"): SVGMaskElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "path"): SVGPathElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "metadata"): SVGMetadataElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "pattern"): SVGPatternElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "polygon"): SVGPolygonElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "polyline"): SVGPolylineElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "radialGradient"): SVGRadialGradientElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "rect"): SVGRectElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "svg"): SVGSVGElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "script"): SVGScriptElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "stop"): SVGStopElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "style"): SVGStyleElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "switch"): SVGSwitchElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "symbol"): SVGSymbolElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "tspan"): SVGTSpanElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "textContent"): SVGTextContentElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "text"): SVGTextElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "textPath"): SVGTextPathElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "textPositioning"): SVGTextPositioningElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "title"): SVGTitleElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "use"): SVGUseElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "view"): SVGViewElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: string): SVGElement createElementNS(namespaceURI: string, qualifiedName: string): Element; createExpression(expression: string, resolver: XPathNSResolver): XPathExpression; createNSResolver(nodeResolver: Node): XPathNSResolver; @@ -12370,14 +12432,12 @@ interface ImageData { width: number; } -interface ImageDataConstructor { +declare var ImageData: { prototype: ImageData; new(width: number, height: number): ImageData; new(array: Uint8ClampedArray, width: number, height: number): ImageData; } -declare var ImageData: ImageDataConstructor; - interface KeyboardEvent extends UIEvent { altKey: boolean; char: string; diff --git a/lib/lib.webworker.d.ts b/lib/lib.webworker.d.ts index 7995a03a40f..7ce06a6b4ac 100644 --- a/lib/lib.webworker.d.ts +++ b/lib/lib.webworker.d.ts @@ -682,14 +682,12 @@ interface ImageData { width: number; } -interface ImageDataConstructor { +declare var ImageData: { prototype: ImageData; new(width: number, height: number): ImageData; new(array: Uint8ClampedArray, width: number, height: number): ImageData; } -declare var ImageData: ImageDataConstructor; - interface MSApp { clearTemporaryWebDataAsync(): MSAppAsyncOperation; createBlobFromRandomAccessStream(type: string, seeker: any): Blob; diff --git a/lib/tsc.js b/lib/tsc.js index 04d88a4035e..511fc67c0aa 100644 --- a/lib/tsc.js +++ b/lib/tsc.js @@ -13,31638 +13,32031 @@ See the Apache Version 2.0 License for specific language governing permissions and limitations under the License. ***************************************************************************** */ -var ts; -(function (ts) { - var OperationCanceledException = (function () { - function OperationCanceledException() { - } - return OperationCanceledException; - })(); - ts.OperationCanceledException = OperationCanceledException; - (function (ExitStatus) { - ExitStatus[ExitStatus["Success"] = 0] = "Success"; - ExitStatus[ExitStatus["DiagnosticsPresent_OutputsSkipped"] = 1] = "DiagnosticsPresent_OutputsSkipped"; - ExitStatus[ExitStatus["DiagnosticsPresent_OutputsGenerated"] = 2] = "DiagnosticsPresent_OutputsGenerated"; - })(ts.ExitStatus || (ts.ExitStatus = {})); - var ExitStatus = ts.ExitStatus; - (function (TypeReferenceSerializationKind) { - TypeReferenceSerializationKind[TypeReferenceSerializationKind["Unknown"] = 0] = "Unknown"; - TypeReferenceSerializationKind[TypeReferenceSerializationKind["TypeWithConstructSignatureAndValue"] = 1] = "TypeWithConstructSignatureAndValue"; - TypeReferenceSerializationKind[TypeReferenceSerializationKind["VoidType"] = 2] = "VoidType"; - TypeReferenceSerializationKind[TypeReferenceSerializationKind["NumberLikeType"] = 3] = "NumberLikeType"; - TypeReferenceSerializationKind[TypeReferenceSerializationKind["StringLikeType"] = 4] = "StringLikeType"; - TypeReferenceSerializationKind[TypeReferenceSerializationKind["BooleanType"] = 5] = "BooleanType"; - TypeReferenceSerializationKind[TypeReferenceSerializationKind["ArrayLikeType"] = 6] = "ArrayLikeType"; - TypeReferenceSerializationKind[TypeReferenceSerializationKind["ESSymbolType"] = 7] = "ESSymbolType"; - TypeReferenceSerializationKind[TypeReferenceSerializationKind["TypeWithCallSignature"] = 8] = "TypeWithCallSignature"; - TypeReferenceSerializationKind[TypeReferenceSerializationKind["ObjectType"] = 9] = "ObjectType"; - })(ts.TypeReferenceSerializationKind || (ts.TypeReferenceSerializationKind = {})); - var TypeReferenceSerializationKind = ts.TypeReferenceSerializationKind; - (function (DiagnosticCategory) { - DiagnosticCategory[DiagnosticCategory["Warning"] = 0] = "Warning"; - DiagnosticCategory[DiagnosticCategory["Error"] = 1] = "Error"; - DiagnosticCategory[DiagnosticCategory["Message"] = 2] = "Message"; - })(ts.DiagnosticCategory || (ts.DiagnosticCategory = {})); - var DiagnosticCategory = ts.DiagnosticCategory; -})(ts || (ts = {})); -var ts; -(function (ts) { - function createFileMap(getCanonicalFileName) { - var files = {}; - return { - get: get, - set: set, - contains: contains, - remove: remove, - clear: clear, - forEachValue: forEachValueInMap - }; - function set(fileName, value) { - files[normalizeKey(fileName)] = value; - } - function get(fileName) { - return files[normalizeKey(fileName)]; - } - function contains(fileName) { - return hasProperty(files, normalizeKey(fileName)); - } - function remove(fileName) { - var key = normalizeKey(fileName); - delete files[key]; - } - function forEachValueInMap(f) { - forEachValue(files, f); - } - function normalizeKey(key) { - return getCanonicalFileName(normalizeSlashes(key)); - } - function clear() { - files = {}; - } - } - ts.createFileMap = createFileMap; - function forEach(array, callback) { - if (array) { - for (var i = 0, len = array.length; i < len; i++) { - var result = callback(array[i], i); - if (result) { - return result; - } - } - } - return undefined; - } - ts.forEach = forEach; - function contains(array, value) { - if (array) { - for (var _i = 0; _i < array.length; _i++) { - var v = array[_i]; - if (v === value) { - return true; - } - } - } - return false; - } - ts.contains = contains; - function indexOf(array, value) { - if (array) { - for (var i = 0, len = array.length; i < len; i++) { - if (array[i] === value) { - return i; - } - } - } - return -1; - } - ts.indexOf = indexOf; - function countWhere(array, predicate) { - var count = 0; - if (array) { - for (var _i = 0; _i < array.length; _i++) { - var v = array[_i]; - if (predicate(v)) { - count++; - } - } - } - return count; - } - ts.countWhere = countWhere; - function filter(array, f) { - var result; - if (array) { - result = []; - for (var _i = 0; _i < array.length; _i++) { - var item = array[_i]; - if (f(item)) { - result.push(item); - } - } - } - return result; - } - ts.filter = filter; - function map(array, f) { - var result; - if (array) { - result = []; - for (var _i = 0; _i < array.length; _i++) { - var v = array[_i]; - result.push(f(v)); - } - } - return result; - } - ts.map = map; - function concatenate(array1, array2) { - if (!array2 || !array2.length) - return array1; - if (!array1 || !array1.length) - return array2; - return array1.concat(array2); - } - ts.concatenate = concatenate; - function deduplicate(array) { - var result; - if (array) { - result = []; - for (var _i = 0; _i < array.length; _i++) { - var item = array[_i]; - if (!contains(result, item)) { - result.push(item); - } - } - } - return result; - } - ts.deduplicate = deduplicate; - function sum(array, prop) { - var result = 0; - for (var _i = 0; _i < array.length; _i++) { - var v = array[_i]; - result += v[prop]; - } - return result; - } - ts.sum = sum; - function addRange(to, from) { - if (to && from) { - for (var _i = 0; _i < from.length; _i++) { - var v = from[_i]; - to.push(v); - } - } - } - ts.addRange = addRange; - function rangeEquals(array1, array2, pos, end) { - while (pos < end) { - if (array1[pos] !== array2[pos]) { - return false; - } - pos++; - } - return true; - } - ts.rangeEquals = rangeEquals; - function lastOrUndefined(array) { - if (array.length === 0) { - return undefined; - } - return array[array.length - 1]; - } - ts.lastOrUndefined = lastOrUndefined; - function binarySearch(array, value) { - var low = 0; - var high = array.length - 1; - while (low <= high) { - var middle = low + ((high - low) >> 1); - var midValue = array[middle]; - if (midValue === value) { - return middle; - } - else if (midValue > value) { - high = middle - 1; - } - else { - low = middle + 1; - } - } - return ~low; - } - ts.binarySearch = binarySearch; - function reduceLeft(array, f, initial) { - if (array) { - var count = array.length; - if (count > 0) { - var pos = 0; - var result = arguments.length <= 2 ? array[pos++] : initial; - while (pos < count) { - result = f(result, array[pos++]); - } - return result; - } - } - return initial; - } - ts.reduceLeft = reduceLeft; - function reduceRight(array, f, initial) { - if (array) { - var pos = array.length - 1; - if (pos >= 0) { - var result = arguments.length <= 2 ? array[pos--] : initial; - while (pos >= 0) { - result = f(result, array[pos--]); - } - return result; - } - } - return initial; - } - ts.reduceRight = reduceRight; - var hasOwnProperty = Object.prototype.hasOwnProperty; - function hasProperty(map, key) { - return hasOwnProperty.call(map, key); - } - ts.hasProperty = hasProperty; - function getProperty(map, key) { - return hasOwnProperty.call(map, key) ? map[key] : undefined; - } - ts.getProperty = getProperty; - function isEmpty(map) { - for (var id in map) { - if (hasProperty(map, id)) { - return false; - } - } - return true; - } - ts.isEmpty = isEmpty; - function clone(object) { - var result = {}; - for (var id in object) { - result[id] = object[id]; - } - return result; - } - ts.clone = clone; - function extend(first, second) { - var result = {}; - for (var id in first) { - result[id] = first[id]; - } - for (var id in second) { - if (!hasProperty(result, id)) { - result[id] = second[id]; - } - } - return result; - } - ts.extend = extend; - function forEachValue(map, callback) { - var result; - for (var id in map) { - if (result = callback(map[id])) - break; - } - return result; - } - ts.forEachValue = forEachValue; - function forEachKey(map, callback) { - var result; - for (var id in map) { - if (result = callback(id)) - break; - } - return result; - } - ts.forEachKey = forEachKey; - function lookUp(map, key) { - return hasProperty(map, key) ? map[key] : undefined; - } - ts.lookUp = lookUp; - function copyMap(source, target) { - for (var p in source) { - target[p] = source[p]; - } - } - ts.copyMap = copyMap; - function arrayToMap(array, makeKey) { - var result = {}; - forEach(array, function (value) { - result[makeKey(value)] = value; - }); - return result; - } - ts.arrayToMap = arrayToMap; - function memoize(callback) { - var value; - return function () { - if (callback) { - value = callback(); - callback = undefined; - } - return value; - }; - } - ts.memoize = memoize; - function formatStringFromArgs(text, args, baseIndex) { - baseIndex = baseIndex || 0; - return text.replace(/{(\d+)}/g, function (match, index) { return args[+index + baseIndex]; }); - } - ts.localizedDiagnosticMessages = undefined; - function getLocaleSpecificMessage(message) { - return ts.localizedDiagnosticMessages && ts.localizedDiagnosticMessages[message] - ? ts.localizedDiagnosticMessages[message] - : message; - } - ts.getLocaleSpecificMessage = getLocaleSpecificMessage; - function createFileDiagnostic(file, start, length, message) { - var end = start + length; - Debug.assert(start >= 0, "start must be non-negative, is " + start); - Debug.assert(length >= 0, "length must be non-negative, is " + length); - if (file) { - Debug.assert(start <= file.text.length, "start must be within the bounds of the file. " + start + " > " + file.text.length); - Debug.assert(end <= file.text.length, "end must be the bounds of the file. " + end + " > " + file.text.length); - } - var text = getLocaleSpecificMessage(message.key); - if (arguments.length > 4) { - text = formatStringFromArgs(text, arguments, 4); - } - return { - file: file, - start: start, - length: length, - messageText: text, - category: message.category, - code: message.code - }; - } - ts.createFileDiagnostic = createFileDiagnostic; - function createCompilerDiagnostic(message) { - var text = getLocaleSpecificMessage(message.key); - if (arguments.length > 1) { - text = formatStringFromArgs(text, arguments, 1); - } - return { - file: undefined, - start: undefined, - length: undefined, - messageText: text, - category: message.category, - code: message.code - }; - } - ts.createCompilerDiagnostic = createCompilerDiagnostic; - function chainDiagnosticMessages(details, message) { - var text = getLocaleSpecificMessage(message.key); - if (arguments.length > 2) { - text = formatStringFromArgs(text, arguments, 2); - } - return { - messageText: text, - category: message.category, - code: message.code, - next: details - }; - } - ts.chainDiagnosticMessages = chainDiagnosticMessages; - function concatenateDiagnosticMessageChains(headChain, tailChain) { - var lastChain = headChain; - while (lastChain.next) { - lastChain = lastChain.next; - } - lastChain.next = tailChain; - return headChain; - } - ts.concatenateDiagnosticMessageChains = concatenateDiagnosticMessageChains; - function compareValues(a, b) { - if (a === b) - return 0; - if (a === undefined) - return -1; - if (b === undefined) - return 1; - return a < b ? -1 : 1; - } - ts.compareValues = compareValues; - function getDiagnosticFileName(diagnostic) { - return diagnostic.file ? diagnostic.file.fileName : undefined; - } - function compareDiagnostics(d1, d2) { - return compareValues(getDiagnosticFileName(d1), getDiagnosticFileName(d2)) || - compareValues(d1.start, d2.start) || - compareValues(d1.length, d2.length) || - compareValues(d1.code, d2.code) || - compareMessageText(d1.messageText, d2.messageText) || - 0; - } - ts.compareDiagnostics = compareDiagnostics; - function compareMessageText(text1, text2) { - while (text1 && text2) { - var string1 = typeof text1 === "string" ? text1 : text1.messageText; - var string2 = typeof text2 === "string" ? text2 : text2.messageText; - var res = compareValues(string1, string2); - if (res) { - return res; - } - text1 = typeof text1 === "string" ? undefined : text1.next; - text2 = typeof text2 === "string" ? undefined : text2.next; - } - if (!text1 && !text2) { - return 0; - } - return text1 ? 1 : -1; - } - function sortAndDeduplicateDiagnostics(diagnostics) { - return deduplicateSortedDiagnostics(diagnostics.sort(compareDiagnostics)); - } - ts.sortAndDeduplicateDiagnostics = sortAndDeduplicateDiagnostics; - function deduplicateSortedDiagnostics(diagnostics) { - if (diagnostics.length < 2) { - return diagnostics; - } - var newDiagnostics = [diagnostics[0]]; - var previousDiagnostic = diagnostics[0]; - for (var i = 1; i < diagnostics.length; i++) { - var currentDiagnostic = diagnostics[i]; - var isDupe = compareDiagnostics(currentDiagnostic, previousDiagnostic) === 0; - if (!isDupe) { - newDiagnostics.push(currentDiagnostic); - previousDiagnostic = currentDiagnostic; - } - } - return newDiagnostics; - } - ts.deduplicateSortedDiagnostics = deduplicateSortedDiagnostics; - function normalizeSlashes(path) { - return path.replace(/\\/g, "/"); - } - ts.normalizeSlashes = normalizeSlashes; - function getRootLength(path) { - if (path.charCodeAt(0) === 47) { - if (path.charCodeAt(1) !== 47) - return 1; - var p1 = path.indexOf("/", 2); - if (p1 < 0) - return 2; - var p2 = path.indexOf("/", p1 + 1); - if (p2 < 0) - return p1 + 1; - return p2 + 1; - } - if (path.charCodeAt(1) === 58) { - if (path.charCodeAt(2) === 47) - return 3; - return 2; - } - if (path.lastIndexOf("file:///", 0) === 0) { - return "file:///".length; - } - var idx = path.indexOf("://"); - if (idx !== -1) { - return idx + "://".length; - } - return 0; - } - ts.getRootLength = getRootLength; - ts.directorySeparator = "/"; - function getNormalizedParts(normalizedSlashedPath, rootLength) { - var parts = normalizedSlashedPath.substr(rootLength).split(ts.directorySeparator); - var normalized = []; - for (var _i = 0; _i < parts.length; _i++) { - var part = parts[_i]; - if (part !== ".") { - if (part === ".." && normalized.length > 0 && lastOrUndefined(normalized) !== "..") { - normalized.pop(); - } - else { - if (part) { - normalized.push(part); - } - } - } - } - return normalized; - } - function normalizePath(path) { - path = normalizeSlashes(path); - var rootLength = getRootLength(path); - var normalized = getNormalizedParts(path, rootLength); - return path.substr(0, rootLength) + normalized.join(ts.directorySeparator); - } - ts.normalizePath = normalizePath; - function getDirectoryPath(path) { - return path.substr(0, Math.max(getRootLength(path), path.lastIndexOf(ts.directorySeparator))); - } - ts.getDirectoryPath = getDirectoryPath; - function isUrl(path) { - return path && !isRootedDiskPath(path) && path.indexOf("://") !== -1; - } - ts.isUrl = isUrl; - function isRootedDiskPath(path) { - return getRootLength(path) !== 0; - } - ts.isRootedDiskPath = isRootedDiskPath; - function normalizedPathComponents(path, rootLength) { - var normalizedParts = getNormalizedParts(path, rootLength); - return [path.substr(0, rootLength)].concat(normalizedParts); - } - function getNormalizedPathComponents(path, currentDirectory) { - path = normalizeSlashes(path); - var rootLength = getRootLength(path); - if (rootLength === 0) { - path = combinePaths(normalizeSlashes(currentDirectory), path); - rootLength = getRootLength(path); - } - return normalizedPathComponents(path, rootLength); - } - ts.getNormalizedPathComponents = getNormalizedPathComponents; - function getNormalizedAbsolutePath(fileName, currentDirectory) { - return getNormalizedPathFromPathComponents(getNormalizedPathComponents(fileName, currentDirectory)); - } - ts.getNormalizedAbsolutePath = getNormalizedAbsolutePath; - function getNormalizedPathFromPathComponents(pathComponents) { - if (pathComponents && pathComponents.length) { - return pathComponents[0] + pathComponents.slice(1).join(ts.directorySeparator); - } - } - ts.getNormalizedPathFromPathComponents = getNormalizedPathFromPathComponents; - function getNormalizedPathComponentsOfUrl(url) { - var urlLength = url.length; - var rootLength = url.indexOf("://") + "://".length; - while (rootLength < urlLength) { - if (url.charCodeAt(rootLength) === 47) { - rootLength++; - } - else { - break; - } - } - if (rootLength === urlLength) { - return [url]; - } - var indexOfNextSlash = url.indexOf(ts.directorySeparator, rootLength); - if (indexOfNextSlash !== -1) { - rootLength = indexOfNextSlash + 1; - return normalizedPathComponents(url, rootLength); - } - else { - return [url + ts.directorySeparator]; - } - } - function getNormalizedPathOrUrlComponents(pathOrUrl, currentDirectory) { - if (isUrl(pathOrUrl)) { - return getNormalizedPathComponentsOfUrl(pathOrUrl); - } - else { - return getNormalizedPathComponents(pathOrUrl, currentDirectory); - } - } - function getRelativePathToDirectoryOrUrl(directoryPathOrUrl, relativeOrAbsolutePath, currentDirectory, getCanonicalFileName, isAbsolutePathAnUrl) { - var pathComponents = getNormalizedPathOrUrlComponents(relativeOrAbsolutePath, currentDirectory); - var directoryComponents = getNormalizedPathOrUrlComponents(directoryPathOrUrl, currentDirectory); - if (directoryComponents.length > 1 && lastOrUndefined(directoryComponents) === "") { - directoryComponents.length--; - } - for (var joinStartIndex = 0; joinStartIndex < pathComponents.length && joinStartIndex < directoryComponents.length; joinStartIndex++) { - if (getCanonicalFileName(directoryComponents[joinStartIndex]) !== getCanonicalFileName(pathComponents[joinStartIndex])) { - break; - } - } - if (joinStartIndex) { - var relativePath = ""; - var relativePathComponents = pathComponents.slice(joinStartIndex, pathComponents.length); - for (; joinStartIndex < directoryComponents.length; joinStartIndex++) { - if (directoryComponents[joinStartIndex] !== "") { - relativePath = relativePath + ".." + ts.directorySeparator; - } - } - return relativePath + relativePathComponents.join(ts.directorySeparator); - } - var absolutePath = getNormalizedPathFromPathComponents(pathComponents); - if (isAbsolutePathAnUrl && isRootedDiskPath(absolutePath)) { - absolutePath = "file:///" + absolutePath; - } - return absolutePath; - } - ts.getRelativePathToDirectoryOrUrl = getRelativePathToDirectoryOrUrl; - function getBaseFileName(path) { - if (!path) { - return undefined; - } - var i = path.lastIndexOf(ts.directorySeparator); - return i < 0 ? path : path.substring(i + 1); - } - ts.getBaseFileName = getBaseFileName; - function combinePaths(path1, path2) { - if (!(path1 && path1.length)) - return path2; - if (!(path2 && path2.length)) - return path1; - if (getRootLength(path2) !== 0) - return path2; - if (path1.charAt(path1.length - 1) === ts.directorySeparator) - return path1 + path2; - return path1 + ts.directorySeparator + path2; - } - ts.combinePaths = combinePaths; - function fileExtensionIs(path, extension) { - var pathLen = path.length; - var extLen = extension.length; - return pathLen > extLen && path.substr(pathLen - extLen, extLen) === extension; - } - ts.fileExtensionIs = fileExtensionIs; - ts.supportedExtensions = [".ts", ".tsx", ".d.ts"]; - ts.moduleFileExtensions = ts.supportedExtensions; - function isSupportedSourceFileName(fileName) { - if (!fileName) { - return false; - } - for (var _i = 0; _i < ts.supportedExtensions.length; _i++) { - var extension = ts.supportedExtensions[_i]; - if (fileExtensionIs(fileName, extension)) { - return true; - } - } - return false; - } - ts.isSupportedSourceFileName = isSupportedSourceFileName; - var extensionsToRemove = [".d.ts", ".ts", ".js", ".tsx", ".jsx"]; - function removeFileExtension(path) { - for (var _i = 0; _i < extensionsToRemove.length; _i++) { - var ext = extensionsToRemove[_i]; - if (fileExtensionIs(path, ext)) { - return path.substr(0, path.length - ext.length); - } - } - return path; - } - ts.removeFileExtension = removeFileExtension; - var backslashOrDoubleQuote = /[\"\\]/g; - var escapedCharsRegExp = /[\u0000-\u001f\t\v\f\b\r\n\u2028\u2029\u0085]/g; - var escapedCharsMap = { - "\0": "\\0", - "\t": "\\t", - "\v": "\\v", - "\f": "\\f", - "\b": "\\b", - "\r": "\\r", - "\n": "\\n", - "\\": "\\\\", - "\"": "\\\"", - "\u2028": "\\u2028", - "\u2029": "\\u2029", - "\u0085": "\\u0085" - }; - function Symbol(flags, name) { - this.flags = flags; - this.name = name; - this.declarations = undefined; - } - function Type(checker, flags) { - this.flags = flags; - } - function Signature(checker) { - } - ts.objectAllocator = { - getNodeConstructor: function (kind) { - function Node(pos, end) { - this.pos = pos; - this.end = end; - this.flags = 0; - this.parent = undefined; - } - Node.prototype = { kind: kind }; - return Node; - }, - getSymbolConstructor: function () { return Symbol; }, - getTypeConstructor: function () { return Type; }, - getSignatureConstructor: function () { return Signature; } - }; - var Debug; - (function (Debug) { - var currentAssertionLevel = 0; - function shouldAssert(level) { - return currentAssertionLevel >= level; - } - Debug.shouldAssert = shouldAssert; - function assert(expression, message, verboseDebugInfo) { - if (!expression) { - var verboseDebugString = ""; - if (verboseDebugInfo) { - verboseDebugString = "\r\nVerbose Debug Information: " + verboseDebugInfo(); - } - throw new Error("Debug Failure. False expression: " + (message || "") + verboseDebugString); - } - } - Debug.assert = assert; - function fail(message) { - Debug.assert(false, message); - } - Debug.fail = fail; - })(Debug = ts.Debug || (ts.Debug = {})); - function copyListRemovingItem(item, list) { - var copiedList = []; - for (var _i = 0; _i < list.length; _i++) { - var e = list[_i]; - if (e !== item) { - copiedList.push(e); - } - } - return copiedList; - } - ts.copyListRemovingItem = copyListRemovingItem; -})(ts || (ts = {})); -var ts; -(function (ts) { - ts.sys = (function () { - function getWScriptSystem() { - var fso = new ActiveXObject("Scripting.FileSystemObject"); - var fileStream = new ActiveXObject("ADODB.Stream"); - fileStream.Type = 2; - var binaryStream = new ActiveXObject("ADODB.Stream"); - binaryStream.Type = 1; - var args = []; - for (var i = 0; i < WScript.Arguments.length; i++) { - args[i] = WScript.Arguments.Item(i); - } - function readFile(fileName, encoding) { - if (!fso.FileExists(fileName)) { - return undefined; - } - fileStream.Open(); - try { - if (encoding) { - fileStream.Charset = encoding; - fileStream.LoadFromFile(fileName); - } - else { - fileStream.Charset = "x-ansi"; - fileStream.LoadFromFile(fileName); - var bom = fileStream.ReadText(2) || ""; - fileStream.Position = 0; - fileStream.Charset = bom.length >= 2 && (bom.charCodeAt(0) === 0xFF && bom.charCodeAt(1) === 0xFE || bom.charCodeAt(0) === 0xFE && bom.charCodeAt(1) === 0xFF) ? "unicode" : "utf-8"; - } - return fileStream.ReadText(); - } - catch (e) { - throw e; - } - finally { - fileStream.Close(); - } - } - function writeFile(fileName, data, writeByteOrderMark) { - fileStream.Open(); - binaryStream.Open(); - try { - fileStream.Charset = "utf-8"; - fileStream.WriteText(data); - if (writeByteOrderMark) { - fileStream.Position = 0; - } - else { - fileStream.Position = 3; - } - fileStream.CopyTo(binaryStream); - binaryStream.SaveToFile(fileName, 2); - } - finally { - binaryStream.Close(); - fileStream.Close(); - } - } - function getCanonicalPath(path) { - return path.toLowerCase(); - } - function getNames(collection) { - var result = []; - for (var e = new Enumerator(collection); !e.atEnd(); e.moveNext()) { - result.push(e.item().Name); - } - return result.sort(); - } - function readDirectory(path, extension, exclude) { - var result = []; - exclude = ts.map(exclude, function (s) { return getCanonicalPath(ts.combinePaths(path, s)); }); - visitDirectory(path); - return result; - function visitDirectory(path) { - var folder = fso.GetFolder(path || "."); - var files = getNames(folder.files); - for (var _i = 0; _i < files.length; _i++) { - var current = files[_i]; - var name_1 = ts.combinePaths(path, current); - if ((!extension || ts.fileExtensionIs(name_1, extension)) && !ts.contains(exclude, getCanonicalPath(name_1))) { - result.push(name_1); - } - } - var subfolders = getNames(folder.subfolders); - for (var _a = 0; _a < subfolders.length; _a++) { - var current = subfolders[_a]; - var name_2 = ts.combinePaths(path, current); - if (!ts.contains(exclude, getCanonicalPath(name_2))) { - visitDirectory(name_2); - } - } - } - } - return { - args: args, - newLine: "\r\n", - useCaseSensitiveFileNames: false, - write: function (s) { - WScript.StdOut.Write(s); - }, - readFile: readFile, - writeFile: writeFile, - resolvePath: function (path) { - return fso.GetAbsolutePathName(path); - }, - fileExists: function (path) { - return fso.FileExists(path); - }, - directoryExists: function (path) { - return fso.FolderExists(path); - }, - createDirectory: function (directoryName) { - if (!this.directoryExists(directoryName)) { - fso.CreateFolder(directoryName); - } - }, - getExecutingFilePath: function () { - return WScript.ScriptFullName; - }, - getCurrentDirectory: function () { - return new ActiveXObject("WScript.Shell").CurrentDirectory; - }, - readDirectory: readDirectory, - exit: function (exitCode) { - try { - WScript.Quit(exitCode); - } - catch (e) { - } - } - }; - } - function getNodeSystem() { - var _fs = require("fs"); - var _path = require("path"); - var _os = require("os"); - function createWatchedFileSet(interval, chunkSize) { - if (interval === void 0) { interval = 2500; } - if (chunkSize === void 0) { chunkSize = 30; } - var watchedFiles = []; - var nextFileToCheck = 0; - var watchTimer; - function getModifiedTime(fileName) { - return _fs.statSync(fileName).mtime; - } - function poll(checkedIndex) { - var watchedFile = watchedFiles[checkedIndex]; - if (!watchedFile) { - return; - } - _fs.stat(watchedFile.fileName, function (err, stats) { - if (err) { - watchedFile.callback(watchedFile.fileName); - } - else if (watchedFile.mtime.getTime() !== stats.mtime.getTime()) { - watchedFile.mtime = getModifiedTime(watchedFile.fileName); - watchedFile.callback(watchedFile.fileName, watchedFile.mtime.getTime() === 0); - } - }); - } - function startWatchTimer() { - watchTimer = setInterval(function () { - var count = 0; - var nextToCheck = nextFileToCheck; - var firstCheck = -1; - while ((count < chunkSize) && (nextToCheck !== firstCheck)) { - poll(nextToCheck); - if (firstCheck < 0) { - firstCheck = nextToCheck; - } - nextToCheck++; - if (nextToCheck === watchedFiles.length) { - nextToCheck = 0; - } - count++; - } - nextFileToCheck = nextToCheck; - }, interval); - } - function addFile(fileName, callback) { - var file = { - fileName: fileName, - callback: callback, - mtime: getModifiedTime(fileName) - }; - watchedFiles.push(file); - if (watchedFiles.length === 1) { - startWatchTimer(); - } - return file; - } - function removeFile(file) { - watchedFiles = ts.copyListRemovingItem(file, watchedFiles); - } - return { - getModifiedTime: getModifiedTime, - poll: poll, - startWatchTimer: startWatchTimer, - addFile: addFile, - removeFile: removeFile - }; - } - var watchedFileSet = createWatchedFileSet(); - function isNode4OrLater() { - return parseInt(process.version.charAt(1)) >= 4; - } - var platform = _os.platform(); - var useCaseSensitiveFileNames = platform !== "win32" && platform !== "win64" && platform !== "darwin"; - function readFile(fileName, encoding) { - if (!_fs.existsSync(fileName)) { - return undefined; - } - var buffer = _fs.readFileSync(fileName); - var len = buffer.length; - if (len >= 2 && buffer[0] === 0xFE && buffer[1] === 0xFF) { - len &= ~1; - for (var i = 0; i < len; i += 2) { - var temp = buffer[i]; - buffer[i] = buffer[i + 1]; - buffer[i + 1] = temp; - } - return buffer.toString("utf16le", 2); - } - if (len >= 2 && buffer[0] === 0xFF && buffer[1] === 0xFE) { - return buffer.toString("utf16le", 2); - } - if (len >= 3 && buffer[0] === 0xEF && buffer[1] === 0xBB && buffer[2] === 0xBF) { - return buffer.toString("utf8", 3); - } - return buffer.toString("utf8"); - } - function writeFile(fileName, data, writeByteOrderMark) { - if (writeByteOrderMark) { - data = "\uFEFF" + data; - } - _fs.writeFileSync(fileName, data, "utf8"); - } - function getCanonicalPath(path) { - return useCaseSensitiveFileNames ? path.toLowerCase() : path; - } - function readDirectory(path, extension, exclude) { - var result = []; - exclude = ts.map(exclude, function (s) { return getCanonicalPath(ts.combinePaths(path, s)); }); - visitDirectory(path); - return result; - function visitDirectory(path) { - var files = _fs.readdirSync(path || ".").sort(); - var directories = []; - for (var _i = 0; _i < files.length; _i++) { - var current = files[_i]; - var name_3 = ts.combinePaths(path, current); - if (!ts.contains(exclude, getCanonicalPath(name_3))) { - var stat = _fs.statSync(name_3); - if (stat.isFile()) { - if (!extension || ts.fileExtensionIs(name_3, extension)) { - result.push(name_3); - } - } - else if (stat.isDirectory()) { - directories.push(name_3); - } - } - } - for (var _a = 0; _a < directories.length; _a++) { - var current = directories[_a]; - visitDirectory(current); - } - } - } - return { - args: process.argv.slice(2), - newLine: _os.EOL, - useCaseSensitiveFileNames: useCaseSensitiveFileNames, - write: function (s) { - var buffer = new Buffer(s, "utf8"); - var offset = 0; - var toWrite = buffer.length; - var written = 0; - while ((written = _fs.writeSync(1, buffer, offset, toWrite)) < toWrite) { - offset += written; - toWrite -= written; - } - }, - readFile: readFile, - writeFile: writeFile, - watchFile: function (fileName, callback) { - if (isNode4OrLater()) { - return _fs.watch(fileName, function (eventName, relativeFileName) { return callback(fileName); }); - } - var watchedFile = watchedFileSet.addFile(fileName, callback); - return { - close: function () { return watchedFileSet.removeFile(watchedFile); } - }; - }, - watchDirectory: function (path, callback, recursive) { - return _fs.watch(path, { persistent: true, recursive: !!recursive }, function (eventName, relativeFileName) { - if (eventName === "rename") { - callback(!relativeFileName ? relativeFileName : ts.normalizePath(ts.combinePaths(path, relativeFileName))); - } - ; - }); - }, - resolvePath: function (path) { - return _path.resolve(path); - }, - fileExists: function (path) { - return _fs.existsSync(path); - }, - directoryExists: function (path) { - return _fs.existsSync(path) && _fs.statSync(path).isDirectory(); - }, - createDirectory: function (directoryName) { - if (!this.directoryExists(directoryName)) { - _fs.mkdirSync(directoryName); - } - }, - getExecutingFilePath: function () { - return __filename; - }, - getCurrentDirectory: function () { - return process.cwd(); - }, - readDirectory: readDirectory, - getMemoryUsage: function () { - if (global.gc) { - global.gc(); - } - return process.memoryUsage().heapUsed; - }, - exit: function (exitCode) { - process.exit(exitCode); - } - }; - } - if (typeof WScript !== "undefined" && typeof ActiveXObject === "function") { - return getWScriptSystem(); - } - else if (typeof process !== "undefined" && process.nextTick && !process.browser && typeof require !== "undefined") { - return getNodeSystem(); - } - else { - return undefined; - } - })(); -})(ts || (ts = {})); -var ts; -(function (ts) { - ts.Diagnostics = { - Unterminated_string_literal: { code: 1002, category: ts.DiagnosticCategory.Error, key: "Unterminated string literal." }, - Identifier_expected: { code: 1003, category: ts.DiagnosticCategory.Error, key: "Identifier expected." }, - _0_expected: { code: 1005, category: ts.DiagnosticCategory.Error, key: "'{0}' expected." }, - A_file_cannot_have_a_reference_to_itself: { code: 1006, category: ts.DiagnosticCategory.Error, key: "A file cannot have a reference to itself." }, - Trailing_comma_not_allowed: { code: 1009, category: ts.DiagnosticCategory.Error, key: "Trailing comma not allowed." }, - Asterisk_Slash_expected: { code: 1010, category: ts.DiagnosticCategory.Error, key: "'*/' expected." }, - Unexpected_token: { code: 1012, category: ts.DiagnosticCategory.Error, key: "Unexpected token." }, - A_rest_parameter_must_be_last_in_a_parameter_list: { code: 1014, category: ts.DiagnosticCategory.Error, key: "A rest parameter must be last in a parameter list." }, - Parameter_cannot_have_question_mark_and_initializer: { code: 1015, category: ts.DiagnosticCategory.Error, key: "Parameter cannot have question mark and initializer." }, - A_required_parameter_cannot_follow_an_optional_parameter: { code: 1016, category: ts.DiagnosticCategory.Error, key: "A required parameter cannot follow an optional parameter." }, - An_index_signature_cannot_have_a_rest_parameter: { code: 1017, category: ts.DiagnosticCategory.Error, key: "An index signature cannot have a rest parameter." }, - An_index_signature_parameter_cannot_have_an_accessibility_modifier: { code: 1018, category: ts.DiagnosticCategory.Error, key: "An index signature parameter cannot have an accessibility modifier." }, - An_index_signature_parameter_cannot_have_a_question_mark: { code: 1019, category: ts.DiagnosticCategory.Error, key: "An index signature parameter cannot have a question mark." }, - An_index_signature_parameter_cannot_have_an_initializer: { code: 1020, category: ts.DiagnosticCategory.Error, key: "An index signature parameter cannot have an initializer." }, - An_index_signature_must_have_a_type_annotation: { code: 1021, category: ts.DiagnosticCategory.Error, key: "An index signature must have a type annotation." }, - An_index_signature_parameter_must_have_a_type_annotation: { code: 1022, category: ts.DiagnosticCategory.Error, key: "An index signature parameter must have a type annotation." }, - An_index_signature_parameter_type_must_be_string_or_number: { code: 1023, category: ts.DiagnosticCategory.Error, key: "An index signature parameter type must be 'string' or 'number'." }, - Accessibility_modifier_already_seen: { code: 1028, category: ts.DiagnosticCategory.Error, key: "Accessibility modifier already seen." }, - _0_modifier_must_precede_1_modifier: { code: 1029, category: ts.DiagnosticCategory.Error, key: "'{0}' modifier must precede '{1}' modifier." }, - _0_modifier_already_seen: { code: 1030, category: ts.DiagnosticCategory.Error, key: "'{0}' modifier already seen." }, - _0_modifier_cannot_appear_on_a_class_element: { code: 1031, category: ts.DiagnosticCategory.Error, key: "'{0}' modifier cannot appear on a class element." }, - super_must_be_followed_by_an_argument_list_or_member_access: { code: 1034, category: ts.DiagnosticCategory.Error, key: "'super' must be followed by an argument list or member access." }, - Only_ambient_modules_can_use_quoted_names: { code: 1035, category: ts.DiagnosticCategory.Error, key: "Only ambient modules can use quoted names." }, - Statements_are_not_allowed_in_ambient_contexts: { code: 1036, category: ts.DiagnosticCategory.Error, key: "Statements are not allowed in ambient contexts." }, - A_declare_modifier_cannot_be_used_in_an_already_ambient_context: { code: 1038, category: ts.DiagnosticCategory.Error, key: "A 'declare' modifier cannot be used in an already ambient context." }, - Initializers_are_not_allowed_in_ambient_contexts: { code: 1039, category: ts.DiagnosticCategory.Error, key: "Initializers are not allowed in ambient contexts." }, - _0_modifier_cannot_be_used_in_an_ambient_context: { code: 1040, category: ts.DiagnosticCategory.Error, key: "'{0}' modifier cannot be used in an ambient context." }, - _0_modifier_cannot_be_used_with_a_class_declaration: { code: 1041, category: ts.DiagnosticCategory.Error, key: "'{0}' modifier cannot be used with a class declaration." }, - _0_modifier_cannot_be_used_here: { code: 1042, category: ts.DiagnosticCategory.Error, key: "'{0}' modifier cannot be used here." }, - _0_modifier_cannot_appear_on_a_data_property: { code: 1043, category: ts.DiagnosticCategory.Error, key: "'{0}' modifier cannot appear on a data property." }, - _0_modifier_cannot_appear_on_a_module_element: { code: 1044, category: ts.DiagnosticCategory.Error, key: "'{0}' modifier cannot appear on a module element." }, - A_0_modifier_cannot_be_used_with_an_interface_declaration: { code: 1045, category: ts.DiagnosticCategory.Error, key: "A '{0}' modifier cannot be used with an interface declaration." }, - A_declare_modifier_is_required_for_a_top_level_declaration_in_a_d_ts_file: { code: 1046, category: ts.DiagnosticCategory.Error, key: "A 'declare' modifier is required for a top level declaration in a .d.ts file." }, - A_rest_parameter_cannot_be_optional: { code: 1047, category: ts.DiagnosticCategory.Error, key: "A rest parameter cannot be optional." }, - A_rest_parameter_cannot_have_an_initializer: { code: 1048, category: ts.DiagnosticCategory.Error, key: "A rest parameter cannot have an initializer." }, - A_set_accessor_must_have_exactly_one_parameter: { code: 1049, category: ts.DiagnosticCategory.Error, key: "A 'set' accessor must have exactly one parameter." }, - A_set_accessor_cannot_have_an_optional_parameter: { code: 1051, category: ts.DiagnosticCategory.Error, key: "A 'set' accessor cannot have an optional parameter." }, - A_set_accessor_parameter_cannot_have_an_initializer: { code: 1052, category: ts.DiagnosticCategory.Error, key: "A 'set' accessor parameter cannot have an initializer." }, - A_set_accessor_cannot_have_rest_parameter: { code: 1053, category: ts.DiagnosticCategory.Error, key: "A 'set' accessor cannot have rest parameter." }, - A_get_accessor_cannot_have_parameters: { code: 1054, category: ts.DiagnosticCategory.Error, key: "A 'get' accessor cannot have parameters." }, - Type_0_is_not_a_valid_async_function_return_type: { code: 1055, category: ts.DiagnosticCategory.Error, key: "Type '{0}' is not a valid async function return type." }, - Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher: { code: 1056, category: ts.DiagnosticCategory.Error, key: "Accessors are only available when targeting ECMAScript 5 and higher." }, - An_async_function_or_method_must_have_a_valid_awaitable_return_type: { code: 1057, category: ts.DiagnosticCategory.Error, key: "An async function or method must have a valid awaitable return type." }, - Operand_for_await_does_not_have_a_valid_callable_then_member: { code: 1058, category: ts.DiagnosticCategory.Error, key: "Operand for 'await' does not have a valid callable 'then' member." }, - Return_expression_in_async_function_does_not_have_a_valid_callable_then_member: { code: 1059, category: ts.DiagnosticCategory.Error, key: "Return expression in async function does not have a valid callable 'then' member." }, - Expression_body_for_async_arrow_function_does_not_have_a_valid_callable_then_member: { code: 1060, category: ts.DiagnosticCategory.Error, key: "Expression body for async arrow function does not have a valid callable 'then' member." }, - Enum_member_must_have_initializer: { code: 1061, category: ts.DiagnosticCategory.Error, key: "Enum member must have initializer." }, - _0_is_referenced_directly_or_indirectly_in_the_fulfillment_callback_of_its_own_then_method: { code: 1062, category: ts.DiagnosticCategory.Error, key: "{0} is referenced directly or indirectly in the fulfillment callback of its own 'then' method." }, - An_export_assignment_cannot_be_used_in_a_namespace: { code: 1063, category: ts.DiagnosticCategory.Error, key: "An export assignment cannot be used in a namespace." }, - In_ambient_enum_declarations_member_initializer_must_be_constant_expression: { code: 1066, category: ts.DiagnosticCategory.Error, key: "In ambient enum declarations member initializer must be constant expression." }, - Unexpected_token_A_constructor_method_accessor_or_property_was_expected: { code: 1068, category: ts.DiagnosticCategory.Error, key: "Unexpected token. A constructor, method, accessor, or property was expected." }, - A_0_modifier_cannot_be_used_with_an_import_declaration: { code: 1079, category: ts.DiagnosticCategory.Error, key: "A '{0}' modifier cannot be used with an import declaration." }, - Invalid_reference_directive_syntax: { code: 1084, category: ts.DiagnosticCategory.Error, key: "Invalid 'reference' directive syntax." }, - Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher: { code: 1085, category: ts.DiagnosticCategory.Error, key: "Octal literals are not available when targeting ECMAScript 5 and higher." }, - An_accessor_cannot_be_declared_in_an_ambient_context: { code: 1086, category: ts.DiagnosticCategory.Error, key: "An accessor cannot be declared in an ambient context." }, - _0_modifier_cannot_appear_on_a_constructor_declaration: { code: 1089, category: ts.DiagnosticCategory.Error, key: "'{0}' modifier cannot appear on a constructor declaration." }, - _0_modifier_cannot_appear_on_a_parameter: { code: 1090, category: ts.DiagnosticCategory.Error, key: "'{0}' modifier cannot appear on a parameter." }, - Only_a_single_variable_declaration_is_allowed_in_a_for_in_statement: { code: 1091, category: ts.DiagnosticCategory.Error, key: "Only a single variable declaration is allowed in a 'for...in' statement." }, - Type_parameters_cannot_appear_on_a_constructor_declaration: { code: 1092, category: ts.DiagnosticCategory.Error, key: "Type parameters cannot appear on a constructor declaration." }, - Type_annotation_cannot_appear_on_a_constructor_declaration: { code: 1093, category: ts.DiagnosticCategory.Error, key: "Type annotation cannot appear on a constructor declaration." }, - An_accessor_cannot_have_type_parameters: { code: 1094, category: ts.DiagnosticCategory.Error, key: "An accessor cannot have type parameters." }, - A_set_accessor_cannot_have_a_return_type_annotation: { code: 1095, category: ts.DiagnosticCategory.Error, key: "A 'set' accessor cannot have a return type annotation." }, - An_index_signature_must_have_exactly_one_parameter: { code: 1096, category: ts.DiagnosticCategory.Error, key: "An index signature must have exactly one parameter." }, - _0_list_cannot_be_empty: { code: 1097, category: ts.DiagnosticCategory.Error, key: "'{0}' list cannot be empty." }, - Type_parameter_list_cannot_be_empty: { code: 1098, category: ts.DiagnosticCategory.Error, key: "Type parameter list cannot be empty." }, - Type_argument_list_cannot_be_empty: { code: 1099, category: ts.DiagnosticCategory.Error, key: "Type argument list cannot be empty." }, - Invalid_use_of_0_in_strict_mode: { code: 1100, category: ts.DiagnosticCategory.Error, key: "Invalid use of '{0}' in strict mode." }, - with_statements_are_not_allowed_in_strict_mode: { code: 1101, category: ts.DiagnosticCategory.Error, key: "'with' statements are not allowed in strict mode." }, - delete_cannot_be_called_on_an_identifier_in_strict_mode: { code: 1102, category: ts.DiagnosticCategory.Error, key: "'delete' cannot be called on an identifier in strict mode." }, - A_continue_statement_can_only_be_used_within_an_enclosing_iteration_statement: { code: 1104, category: ts.DiagnosticCategory.Error, key: "A 'continue' statement can only be used within an enclosing iteration statement." }, - A_break_statement_can_only_be_used_within_an_enclosing_iteration_or_switch_statement: { code: 1105, category: ts.DiagnosticCategory.Error, key: "A 'break' statement can only be used within an enclosing iteration or switch statement." }, - Jump_target_cannot_cross_function_boundary: { code: 1107, category: ts.DiagnosticCategory.Error, key: "Jump target cannot cross function boundary." }, - A_return_statement_can_only_be_used_within_a_function_body: { code: 1108, category: ts.DiagnosticCategory.Error, key: "A 'return' statement can only be used within a function body." }, - Expression_expected: { code: 1109, category: ts.DiagnosticCategory.Error, key: "Expression expected." }, - Type_expected: { code: 1110, category: ts.DiagnosticCategory.Error, key: "Type expected." }, - A_class_member_cannot_be_declared_optional: { code: 1112, category: ts.DiagnosticCategory.Error, key: "A class member cannot be declared optional." }, - A_default_clause_cannot_appear_more_than_once_in_a_switch_statement: { code: 1113, category: ts.DiagnosticCategory.Error, key: "A 'default' clause cannot appear more than once in a 'switch' statement." }, - Duplicate_label_0: { code: 1114, category: ts.DiagnosticCategory.Error, key: "Duplicate label '{0}'" }, - A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement: { code: 1115, category: ts.DiagnosticCategory.Error, key: "A 'continue' statement can only jump to a label of an enclosing iteration statement." }, - A_break_statement_can_only_jump_to_a_label_of_an_enclosing_statement: { code: 1116, category: ts.DiagnosticCategory.Error, key: "A 'break' statement can only jump to a label of an enclosing statement." }, - An_object_literal_cannot_have_multiple_properties_with_the_same_name_in_strict_mode: { code: 1117, category: ts.DiagnosticCategory.Error, key: "An object literal cannot have multiple properties with the same name in strict mode." }, - An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name: { code: 1118, category: ts.DiagnosticCategory.Error, key: "An object literal cannot have multiple get/set accessors with the same name." }, - An_object_literal_cannot_have_property_and_accessor_with_the_same_name: { code: 1119, category: ts.DiagnosticCategory.Error, key: "An object literal cannot have property and accessor with the same name." }, - An_export_assignment_cannot_have_modifiers: { code: 1120, category: ts.DiagnosticCategory.Error, key: "An export assignment cannot have modifiers." }, - Octal_literals_are_not_allowed_in_strict_mode: { code: 1121, category: ts.DiagnosticCategory.Error, key: "Octal literals are not allowed in strict mode." }, - A_tuple_type_element_list_cannot_be_empty: { code: 1122, category: ts.DiagnosticCategory.Error, key: "A tuple type element list cannot be empty." }, - Variable_declaration_list_cannot_be_empty: { code: 1123, category: ts.DiagnosticCategory.Error, key: "Variable declaration list cannot be empty." }, - Digit_expected: { code: 1124, category: ts.DiagnosticCategory.Error, key: "Digit expected." }, - Hexadecimal_digit_expected: { code: 1125, category: ts.DiagnosticCategory.Error, key: "Hexadecimal digit expected." }, - Unexpected_end_of_text: { code: 1126, category: ts.DiagnosticCategory.Error, key: "Unexpected end of text." }, - Invalid_character: { code: 1127, category: ts.DiagnosticCategory.Error, key: "Invalid character." }, - Declaration_or_statement_expected: { code: 1128, category: ts.DiagnosticCategory.Error, key: "Declaration or statement expected." }, - Statement_expected: { code: 1129, category: ts.DiagnosticCategory.Error, key: "Statement expected." }, - case_or_default_expected: { code: 1130, category: ts.DiagnosticCategory.Error, key: "'case' or 'default' expected." }, - Property_or_signature_expected: { code: 1131, category: ts.DiagnosticCategory.Error, key: "Property or signature expected." }, - Enum_member_expected: { code: 1132, category: ts.DiagnosticCategory.Error, key: "Enum member expected." }, - Variable_declaration_expected: { code: 1134, category: ts.DiagnosticCategory.Error, key: "Variable declaration expected." }, - Argument_expression_expected: { code: 1135, category: ts.DiagnosticCategory.Error, key: "Argument expression expected." }, - Property_assignment_expected: { code: 1136, category: ts.DiagnosticCategory.Error, key: "Property assignment expected." }, - Expression_or_comma_expected: { code: 1137, category: ts.DiagnosticCategory.Error, key: "Expression or comma expected." }, - Parameter_declaration_expected: { code: 1138, category: ts.DiagnosticCategory.Error, key: "Parameter declaration expected." }, - Type_parameter_declaration_expected: { code: 1139, category: ts.DiagnosticCategory.Error, key: "Type parameter declaration expected." }, - Type_argument_expected: { code: 1140, category: ts.DiagnosticCategory.Error, key: "Type argument expected." }, - String_literal_expected: { code: 1141, category: ts.DiagnosticCategory.Error, key: "String literal expected." }, - Line_break_not_permitted_here: { code: 1142, category: ts.DiagnosticCategory.Error, key: "Line break not permitted here." }, - or_expected: { code: 1144, category: ts.DiagnosticCategory.Error, key: "'{' or ';' expected." }, - Modifiers_not_permitted_on_index_signature_members: { code: 1145, category: ts.DiagnosticCategory.Error, key: "Modifiers not permitted on index signature members." }, - Declaration_expected: { code: 1146, category: ts.DiagnosticCategory.Error, key: "Declaration expected." }, - Import_declarations_in_a_namespace_cannot_reference_a_module: { code: 1147, category: ts.DiagnosticCategory.Error, key: "Import declarations in a namespace cannot reference a module." }, - Cannot_compile_modules_unless_the_module_flag_is_provided: { code: 1148, category: ts.DiagnosticCategory.Error, key: "Cannot compile modules unless the '--module' flag is provided." }, - File_name_0_differs_from_already_included_file_name_1_only_in_casing: { code: 1149, category: ts.DiagnosticCategory.Error, key: "File name '{0}' differs from already included file name '{1}' only in casing" }, - new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead: { code: 1150, category: ts.DiagnosticCategory.Error, key: "'new T[]' cannot be used to create an array. Use 'new Array()' instead." }, - const_declarations_must_be_initialized: { code: 1155, category: ts.DiagnosticCategory.Error, key: "'const' declarations must be initialized" }, - const_declarations_can_only_be_declared_inside_a_block: { code: 1156, category: ts.DiagnosticCategory.Error, key: "'const' declarations can only be declared inside a block." }, - let_declarations_can_only_be_declared_inside_a_block: { code: 1157, category: ts.DiagnosticCategory.Error, key: "'let' declarations can only be declared inside a block." }, - Unterminated_template_literal: { code: 1160, category: ts.DiagnosticCategory.Error, key: "Unterminated template literal." }, - Unterminated_regular_expression_literal: { code: 1161, category: ts.DiagnosticCategory.Error, key: "Unterminated regular expression literal." }, - An_object_member_cannot_be_declared_optional: { code: 1162, category: ts.DiagnosticCategory.Error, key: "An object member cannot be declared optional." }, - A_yield_expression_is_only_allowed_in_a_generator_body: { code: 1163, category: ts.DiagnosticCategory.Error, key: "A 'yield' expression is only allowed in a generator body." }, - Computed_property_names_are_not_allowed_in_enums: { code: 1164, category: ts.DiagnosticCategory.Error, key: "Computed property names are not allowed in enums." }, - A_computed_property_name_in_an_ambient_context_must_directly_refer_to_a_built_in_symbol: { code: 1165, category: ts.DiagnosticCategory.Error, key: "A computed property name in an ambient context must directly refer to a built-in symbol." }, - A_computed_property_name_in_a_class_property_declaration_must_directly_refer_to_a_built_in_symbol: { code: 1166, category: ts.DiagnosticCategory.Error, key: "A computed property name in a class property declaration must directly refer to a built-in symbol." }, - A_computed_property_name_in_a_method_overload_must_directly_refer_to_a_built_in_symbol: { code: 1168, category: ts.DiagnosticCategory.Error, key: "A computed property name in a method overload must directly refer to a built-in symbol." }, - A_computed_property_name_in_an_interface_must_directly_refer_to_a_built_in_symbol: { code: 1169, category: ts.DiagnosticCategory.Error, key: "A computed property name in an interface must directly refer to a built-in symbol." }, - A_computed_property_name_in_a_type_literal_must_directly_refer_to_a_built_in_symbol: { code: 1170, category: ts.DiagnosticCategory.Error, key: "A computed property name in a type literal must directly refer to a built-in symbol." }, - A_comma_expression_is_not_allowed_in_a_computed_property_name: { code: 1171, category: ts.DiagnosticCategory.Error, key: "A comma expression is not allowed in a computed property name." }, - extends_clause_already_seen: { code: 1172, category: ts.DiagnosticCategory.Error, key: "'extends' clause already seen." }, - extends_clause_must_precede_implements_clause: { code: 1173, category: ts.DiagnosticCategory.Error, key: "'extends' clause must precede 'implements' clause." }, - Classes_can_only_extend_a_single_class: { code: 1174, category: ts.DiagnosticCategory.Error, key: "Classes can only extend a single class." }, - implements_clause_already_seen: { code: 1175, category: ts.DiagnosticCategory.Error, key: "'implements' clause already seen." }, - Interface_declaration_cannot_have_implements_clause: { code: 1176, category: ts.DiagnosticCategory.Error, key: "Interface declaration cannot have 'implements' clause." }, - Binary_digit_expected: { code: 1177, category: ts.DiagnosticCategory.Error, key: "Binary digit expected." }, - Octal_digit_expected: { code: 1178, category: ts.DiagnosticCategory.Error, key: "Octal digit expected." }, - Unexpected_token_expected: { code: 1179, category: ts.DiagnosticCategory.Error, key: "Unexpected token. '{' expected." }, - Property_destructuring_pattern_expected: { code: 1180, category: ts.DiagnosticCategory.Error, key: "Property destructuring pattern expected." }, - Array_element_destructuring_pattern_expected: { code: 1181, category: ts.DiagnosticCategory.Error, key: "Array element destructuring pattern expected." }, - A_destructuring_declaration_must_have_an_initializer: { code: 1182, category: ts.DiagnosticCategory.Error, key: "A destructuring declaration must have an initializer." }, - An_implementation_cannot_be_declared_in_ambient_contexts: { code: 1183, category: ts.DiagnosticCategory.Error, key: "An implementation cannot be declared in ambient contexts." }, - Modifiers_cannot_appear_here: { code: 1184, category: ts.DiagnosticCategory.Error, key: "Modifiers cannot appear here." }, - Merge_conflict_marker_encountered: { code: 1185, category: ts.DiagnosticCategory.Error, key: "Merge conflict marker encountered." }, - A_rest_element_cannot_have_an_initializer: { code: 1186, category: ts.DiagnosticCategory.Error, key: "A rest element cannot have an initializer." }, - A_parameter_property_may_not_be_a_binding_pattern: { code: 1187, category: ts.DiagnosticCategory.Error, key: "A parameter property may not be a binding pattern." }, - Only_a_single_variable_declaration_is_allowed_in_a_for_of_statement: { code: 1188, category: ts.DiagnosticCategory.Error, key: "Only a single variable declaration is allowed in a 'for...of' statement." }, - The_variable_declaration_of_a_for_in_statement_cannot_have_an_initializer: { code: 1189, category: ts.DiagnosticCategory.Error, key: "The variable declaration of a 'for...in' statement cannot have an initializer." }, - The_variable_declaration_of_a_for_of_statement_cannot_have_an_initializer: { code: 1190, category: ts.DiagnosticCategory.Error, key: "The variable declaration of a 'for...of' statement cannot have an initializer." }, - An_import_declaration_cannot_have_modifiers: { code: 1191, category: ts.DiagnosticCategory.Error, key: "An import declaration cannot have modifiers." }, - Module_0_has_no_default_export: { code: 1192, category: ts.DiagnosticCategory.Error, key: "Module '{0}' has no default export." }, - An_export_declaration_cannot_have_modifiers: { code: 1193, category: ts.DiagnosticCategory.Error, key: "An export declaration cannot have modifiers." }, - Export_declarations_are_not_permitted_in_a_namespace: { code: 1194, category: ts.DiagnosticCategory.Error, key: "Export declarations are not permitted in a namespace." }, - Catch_clause_variable_name_must_be_an_identifier: { code: 1195, category: ts.DiagnosticCategory.Error, key: "Catch clause variable name must be an identifier." }, - Catch_clause_variable_cannot_have_a_type_annotation: { code: 1196, category: ts.DiagnosticCategory.Error, key: "Catch clause variable cannot have a type annotation." }, - Catch_clause_variable_cannot_have_an_initializer: { code: 1197, category: ts.DiagnosticCategory.Error, key: "Catch clause variable cannot have an initializer." }, - An_extended_Unicode_escape_value_must_be_between_0x0_and_0x10FFFF_inclusive: { code: 1198, category: ts.DiagnosticCategory.Error, key: "An extended Unicode escape value must be between 0x0 and 0x10FFFF inclusive." }, - Unterminated_Unicode_escape_sequence: { code: 1199, category: ts.DiagnosticCategory.Error, key: "Unterminated Unicode escape sequence." }, - Line_terminator_not_permitted_before_arrow: { code: 1200, category: ts.DiagnosticCategory.Error, key: "Line terminator not permitted before arrow." }, - Import_assignment_cannot_be_used_when_targeting_ECMAScript_6_modules_Consider_using_import_Asterisk_as_ns_from_mod_import_a_from_mod_import_d_from_mod_or_another_module_format_instead: { code: 1202, category: ts.DiagnosticCategory.Error, key: "Import assignment cannot be used when targeting ECMAScript 6 modules. Consider using 'import * as ns from \"mod\"', 'import {a} from \"mod\"', 'import d from \"mod\"', or another module format instead." }, - Export_assignment_cannot_be_used_when_targeting_ECMAScript_6_modules_Consider_using_export_default_or_another_module_format_instead: { code: 1203, category: ts.DiagnosticCategory.Error, key: "Export assignment cannot be used when targeting ECMAScript 6 modules. Consider using 'export default' or another module format instead." }, - Cannot_compile_modules_into_es2015_when_targeting_ES5_or_lower: { code: 1204, category: ts.DiagnosticCategory.Error, key: "Cannot compile modules into 'es2015' when targeting 'ES5' or lower." }, - Decorators_are_not_valid_here: { code: 1206, category: ts.DiagnosticCategory.Error, key: "Decorators are not valid here." }, - Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name: { code: 1207, category: ts.DiagnosticCategory.Error, key: "Decorators cannot be applied to multiple get/set accessors of the same name." }, - Cannot_compile_namespaces_when_the_isolatedModules_flag_is_provided: { code: 1208, category: ts.DiagnosticCategory.Error, key: "Cannot compile namespaces when the '--isolatedModules' flag is provided." }, - Ambient_const_enums_are_not_allowed_when_the_isolatedModules_flag_is_provided: { code: 1209, category: ts.DiagnosticCategory.Error, key: "Ambient const enums are not allowed when the '--isolatedModules' flag is provided." }, - Invalid_use_of_0_Class_definitions_are_automatically_in_strict_mode: { code: 1210, category: ts.DiagnosticCategory.Error, key: "Invalid use of '{0}'. Class definitions are automatically in strict mode." }, - A_class_declaration_without_the_default_modifier_must_have_a_name: { code: 1211, category: ts.DiagnosticCategory.Error, key: "A class declaration without the 'default' modifier must have a name" }, - Identifier_expected_0_is_a_reserved_word_in_strict_mode: { code: 1212, category: ts.DiagnosticCategory.Error, key: "Identifier expected. '{0}' is a reserved word in strict mode" }, - Identifier_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_strict_mode: { code: 1213, category: ts.DiagnosticCategory.Error, key: "Identifier expected. '{0}' is a reserved word in strict mode. Class definitions are automatically in strict mode." }, - Identifier_expected_0_is_a_reserved_word_in_strict_mode_Modules_are_automatically_in_strict_mode: { code: 1214, category: ts.DiagnosticCategory.Error, key: "Identifier expected. '{0}' is a reserved word in strict mode. Modules are automatically in strict mode." }, - Invalid_use_of_0_Modules_are_automatically_in_strict_mode: { code: 1215, category: ts.DiagnosticCategory.Error, key: "Invalid use of '{0}'. Modules are automatically in strict mode." }, - Export_assignment_is_not_supported_when_module_flag_is_system: { code: 1218, category: ts.DiagnosticCategory.Error, key: "Export assignment is not supported when '--module' flag is 'system'." }, - Experimental_support_for_decorators_is_a_feature_that_is_subject_to_change_in_a_future_release_Specify_experimentalDecorators_to_remove_this_warning: { code: 1219, category: ts.DiagnosticCategory.Error, key: "Experimental support for decorators is a feature that is subject to change in a future release. Specify '--experimentalDecorators' to remove this warning." }, - Generators_are_only_available_when_targeting_ECMAScript_6_or_higher: { code: 1220, category: ts.DiagnosticCategory.Error, key: "Generators are only available when targeting ECMAScript 6 or higher." }, - Generators_are_not_allowed_in_an_ambient_context: { code: 1221, category: ts.DiagnosticCategory.Error, key: "Generators are not allowed in an ambient context." }, - An_overload_signature_cannot_be_declared_as_a_generator: { code: 1222, category: ts.DiagnosticCategory.Error, key: "An overload signature cannot be declared as a generator." }, - _0_tag_already_specified: { code: 1223, category: ts.DiagnosticCategory.Error, key: "'{0}' tag already specified." }, - Signature_0_must_have_a_type_predicate: { code: 1224, category: ts.DiagnosticCategory.Error, key: "Signature '{0}' must have a type predicate." }, - Cannot_find_parameter_0: { code: 1225, category: ts.DiagnosticCategory.Error, key: "Cannot find parameter '{0}'." }, - Type_predicate_0_is_not_assignable_to_1: { code: 1226, category: ts.DiagnosticCategory.Error, key: "Type predicate '{0}' is not assignable to '{1}'." }, - Parameter_0_is_not_in_the_same_position_as_parameter_1: { code: 1227, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' is not in the same position as parameter '{1}'." }, - A_type_predicate_is_only_allowed_in_return_type_position_for_functions_and_methods: { code: 1228, category: ts.DiagnosticCategory.Error, key: "A type predicate is only allowed in return type position for functions and methods." }, - A_type_predicate_cannot_reference_a_rest_parameter: { code: 1229, category: ts.DiagnosticCategory.Error, key: "A type predicate cannot reference a rest parameter." }, - A_type_predicate_cannot_reference_element_0_in_a_binding_pattern: { code: 1230, category: ts.DiagnosticCategory.Error, key: "A type predicate cannot reference element '{0}' in a binding pattern." }, - An_export_assignment_can_only_be_used_in_a_module: { code: 1231, category: ts.DiagnosticCategory.Error, key: "An export assignment can only be used in a module." }, - An_import_declaration_can_only_be_used_in_a_namespace_or_module: { code: 1232, category: ts.DiagnosticCategory.Error, key: "An import declaration can only be used in a namespace or module." }, - An_export_declaration_can_only_be_used_in_a_module: { code: 1233, category: ts.DiagnosticCategory.Error, key: "An export declaration can only be used in a module." }, - An_ambient_module_declaration_is_only_allowed_at_the_top_level_in_a_file: { code: 1234, category: ts.DiagnosticCategory.Error, key: "An ambient module declaration is only allowed at the top level in a file." }, - A_namespace_declaration_is_only_allowed_in_a_namespace_or_module: { code: 1235, category: ts.DiagnosticCategory.Error, key: "A namespace declaration is only allowed in a namespace or module." }, - The_return_type_of_a_property_decorator_function_must_be_either_void_or_any: { code: 1236, category: ts.DiagnosticCategory.Error, key: "The return type of a property decorator function must be either 'void' or 'any'." }, - The_return_type_of_a_parameter_decorator_function_must_be_either_void_or_any: { code: 1237, category: ts.DiagnosticCategory.Error, key: "The return type of a parameter decorator function must be either 'void' or 'any'." }, - Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression: { code: 1238, category: ts.DiagnosticCategory.Error, key: "Unable to resolve signature of class decorator when called as an expression." }, - Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression: { code: 1239, category: ts.DiagnosticCategory.Error, key: "Unable to resolve signature of parameter decorator when called as an expression." }, - Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression: { code: 1240, category: ts.DiagnosticCategory.Error, key: "Unable to resolve signature of property decorator when called as an expression." }, - Unable_to_resolve_signature_of_method_decorator_when_called_as_an_expression: { code: 1241, category: ts.DiagnosticCategory.Error, key: "Unable to resolve signature of method decorator when called as an expression." }, - abstract_modifier_can_only_appear_on_a_class_or_method_declaration: { code: 1242, category: ts.DiagnosticCategory.Error, key: "'abstract' modifier can only appear on a class or method declaration." }, - _0_modifier_cannot_be_used_with_1_modifier: { code: 1243, category: ts.DiagnosticCategory.Error, key: "'{0}' modifier cannot be used with '{1}' modifier." }, - Abstract_methods_can_only_appear_within_an_abstract_class: { code: 1244, category: ts.DiagnosticCategory.Error, key: "Abstract methods can only appear within an abstract class." }, - Method_0_cannot_have_an_implementation_because_it_is_marked_abstract: { code: 1245, category: ts.DiagnosticCategory.Error, key: "Method '{0}' cannot have an implementation because it is marked abstract." }, - with_statements_are_not_allowed_in_an_async_function_block: { code: 1300, category: ts.DiagnosticCategory.Error, key: "'with' statements are not allowed in an async function block." }, - await_expression_is_only_allowed_within_an_async_function: { code: 1308, category: ts.DiagnosticCategory.Error, key: "'await' expression is only allowed within an async function." }, - Async_functions_are_only_available_when_targeting_ECMAScript_6_and_higher: { code: 1311, category: ts.DiagnosticCategory.Error, key: "Async functions are only available when targeting ECMAScript 6 and higher." }, - can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment: { code: 1312, category: ts.DiagnosticCategory.Error, key: "'=' can only be used in an object literal property inside a destructuring assignment." }, - Duplicate_identifier_0: { code: 2300, category: ts.DiagnosticCategory.Error, key: "Duplicate identifier '{0}'." }, - Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor: { code: 2301, category: ts.DiagnosticCategory.Error, key: "Initializer of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor." }, - Static_members_cannot_reference_class_type_parameters: { code: 2302, category: ts.DiagnosticCategory.Error, key: "Static members cannot reference class type parameters." }, - Circular_definition_of_import_alias_0: { code: 2303, category: ts.DiagnosticCategory.Error, key: "Circular definition of import alias '{0}'." }, - Cannot_find_name_0: { code: 2304, category: ts.DiagnosticCategory.Error, key: "Cannot find name '{0}'." }, - Module_0_has_no_exported_member_1: { code: 2305, category: ts.DiagnosticCategory.Error, key: "Module '{0}' has no exported member '{1}'." }, - File_0_is_not_a_module: { code: 2306, category: ts.DiagnosticCategory.Error, key: "File '{0}' is not a module." }, - Cannot_find_module_0: { code: 2307, category: ts.DiagnosticCategory.Error, key: "Cannot find module '{0}'." }, - An_export_assignment_cannot_be_used_in_a_module_with_other_exported_elements: { code: 2309, category: ts.DiagnosticCategory.Error, key: "An export assignment cannot be used in a module with other exported elements." }, - Type_0_recursively_references_itself_as_a_base_type: { code: 2310, category: ts.DiagnosticCategory.Error, key: "Type '{0}' recursively references itself as a base type." }, - A_class_may_only_extend_another_class: { code: 2311, category: ts.DiagnosticCategory.Error, key: "A class may only extend another class." }, - An_interface_may_only_extend_a_class_or_another_interface: { code: 2312, category: ts.DiagnosticCategory.Error, key: "An interface may only extend a class or another interface." }, - Constraint_of_a_type_parameter_cannot_reference_any_type_parameter_from_the_same_type_parameter_list: { code: 2313, category: ts.DiagnosticCategory.Error, key: "Constraint of a type parameter cannot reference any type parameter from the same type parameter list." }, - Generic_type_0_requires_1_type_argument_s: { code: 2314, category: ts.DiagnosticCategory.Error, key: "Generic type '{0}' requires {1} type argument(s)." }, - Type_0_is_not_generic: { code: 2315, category: ts.DiagnosticCategory.Error, key: "Type '{0}' is not generic." }, - Global_type_0_must_be_a_class_or_interface_type: { code: 2316, category: ts.DiagnosticCategory.Error, key: "Global type '{0}' must be a class or interface type." }, - Global_type_0_must_have_1_type_parameter_s: { code: 2317, category: ts.DiagnosticCategory.Error, key: "Global type '{0}' must have {1} type parameter(s)." }, - Cannot_find_global_type_0: { code: 2318, category: ts.DiagnosticCategory.Error, key: "Cannot find global type '{0}'." }, - Named_property_0_of_types_1_and_2_are_not_identical: { code: 2319, category: ts.DiagnosticCategory.Error, key: "Named property '{0}' of types '{1}' and '{2}' are not identical." }, - Interface_0_cannot_simultaneously_extend_types_1_and_2: { code: 2320, category: ts.DiagnosticCategory.Error, key: "Interface '{0}' cannot simultaneously extend types '{1}' and '{2}'." }, - Excessive_stack_depth_comparing_types_0_and_1: { code: 2321, category: ts.DiagnosticCategory.Error, key: "Excessive stack depth comparing types '{0}' and '{1}'." }, - Type_0_is_not_assignable_to_type_1: { code: 2322, category: ts.DiagnosticCategory.Error, key: "Type '{0}' is not assignable to type '{1}'." }, - Property_0_is_missing_in_type_1: { code: 2324, category: ts.DiagnosticCategory.Error, key: "Property '{0}' is missing in type '{1}'." }, - Property_0_is_private_in_type_1_but_not_in_type_2: { code: 2325, category: ts.DiagnosticCategory.Error, key: "Property '{0}' is private in type '{1}' but not in type '{2}'." }, - Types_of_property_0_are_incompatible: { code: 2326, category: ts.DiagnosticCategory.Error, key: "Types of property '{0}' are incompatible." }, - Property_0_is_optional_in_type_1_but_required_in_type_2: { code: 2327, category: ts.DiagnosticCategory.Error, key: "Property '{0}' is optional in type '{1}' but required in type '{2}'." }, - Types_of_parameters_0_and_1_are_incompatible: { code: 2328, category: ts.DiagnosticCategory.Error, key: "Types of parameters '{0}' and '{1}' are incompatible." }, - Index_signature_is_missing_in_type_0: { code: 2329, category: ts.DiagnosticCategory.Error, key: "Index signature is missing in type '{0}'." }, - Index_signatures_are_incompatible: { code: 2330, category: ts.DiagnosticCategory.Error, key: "Index signatures are incompatible." }, - this_cannot_be_referenced_in_a_module_or_namespace_body: { code: 2331, category: ts.DiagnosticCategory.Error, key: "'this' cannot be referenced in a module or namespace body." }, - this_cannot_be_referenced_in_current_location: { code: 2332, category: ts.DiagnosticCategory.Error, key: "'this' cannot be referenced in current location." }, - this_cannot_be_referenced_in_constructor_arguments: { code: 2333, category: ts.DiagnosticCategory.Error, key: "'this' cannot be referenced in constructor arguments." }, - this_cannot_be_referenced_in_a_static_property_initializer: { code: 2334, category: ts.DiagnosticCategory.Error, key: "'this' cannot be referenced in a static property initializer." }, - super_can_only_be_referenced_in_a_derived_class: { code: 2335, category: ts.DiagnosticCategory.Error, key: "'super' can only be referenced in a derived class." }, - super_cannot_be_referenced_in_constructor_arguments: { code: 2336, category: ts.DiagnosticCategory.Error, key: "'super' cannot be referenced in constructor arguments." }, - Super_calls_are_not_permitted_outside_constructors_or_in_nested_functions_inside_constructors: { code: 2337, category: ts.DiagnosticCategory.Error, key: "Super calls are not permitted outside constructors or in nested functions inside constructors." }, - super_property_access_is_permitted_only_in_a_constructor_member_function_or_member_accessor_of_a_derived_class: { code: 2338, category: ts.DiagnosticCategory.Error, key: "'super' property access is permitted only in a constructor, member function, or member accessor of a derived class." }, - Property_0_does_not_exist_on_type_1: { code: 2339, category: ts.DiagnosticCategory.Error, key: "Property '{0}' does not exist on type '{1}'." }, - Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword: { code: 2340, category: ts.DiagnosticCategory.Error, key: "Only public and protected methods of the base class are accessible via the 'super' keyword." }, - Property_0_is_private_and_only_accessible_within_class_1: { code: 2341, category: ts.DiagnosticCategory.Error, key: "Property '{0}' is private and only accessible within class '{1}'." }, - An_index_expression_argument_must_be_of_type_string_number_symbol_or_any: { code: 2342, category: ts.DiagnosticCategory.Error, key: "An index expression argument must be of type 'string', 'number', 'symbol', or 'any'." }, - Type_0_does_not_satisfy_the_constraint_1: { code: 2344, category: ts.DiagnosticCategory.Error, key: "Type '{0}' does not satisfy the constraint '{1}'." }, - Argument_of_type_0_is_not_assignable_to_parameter_of_type_1: { code: 2345, category: ts.DiagnosticCategory.Error, key: "Argument of type '{0}' is not assignable to parameter of type '{1}'." }, - Supplied_parameters_do_not_match_any_signature_of_call_target: { code: 2346, category: ts.DiagnosticCategory.Error, key: "Supplied parameters do not match any signature of call target." }, - Untyped_function_calls_may_not_accept_type_arguments: { code: 2347, category: ts.DiagnosticCategory.Error, key: "Untyped function calls may not accept type arguments." }, - Value_of_type_0_is_not_callable_Did_you_mean_to_include_new: { code: 2348, category: ts.DiagnosticCategory.Error, key: "Value of type '{0}' is not callable. Did you mean to include 'new'?" }, - Cannot_invoke_an_expression_whose_type_lacks_a_call_signature: { code: 2349, category: ts.DiagnosticCategory.Error, key: "Cannot invoke an expression whose type lacks a call signature." }, - Only_a_void_function_can_be_called_with_the_new_keyword: { code: 2350, category: ts.DiagnosticCategory.Error, key: "Only a void function can be called with the 'new' keyword." }, - Cannot_use_new_with_an_expression_whose_type_lacks_a_call_or_construct_signature: { code: 2351, category: ts.DiagnosticCategory.Error, key: "Cannot use 'new' with an expression whose type lacks a call or construct signature." }, - Neither_type_0_nor_type_1_is_assignable_to_the_other: { code: 2352, category: ts.DiagnosticCategory.Error, key: "Neither type '{0}' nor type '{1}' is assignable to the other." }, - Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1: { code: 2353, category: ts.DiagnosticCategory.Error, key: "Object literal may only specify known properties, and '{0}' does not exist in type '{1}'." }, - No_best_common_type_exists_among_return_expressions: { code: 2354, category: ts.DiagnosticCategory.Error, key: "No best common type exists among return expressions." }, - A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value_or_consist_of_a_single_throw_statement: { code: 2355, category: ts.DiagnosticCategory.Error, key: "A function whose declared type is neither 'void' nor 'any' must return a value or consist of a single 'throw' statement." }, - An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type: { code: 2356, category: ts.DiagnosticCategory.Error, key: "An arithmetic operand must be of type 'any', 'number' or an enum type." }, - The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_property_or_indexer: { code: 2357, category: ts.DiagnosticCategory.Error, key: "The operand of an increment or decrement operator must be a variable, property or indexer." }, - The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_parameter: { code: 2358, category: ts.DiagnosticCategory.Error, key: "The left-hand side of an 'instanceof' expression must be of type 'any', an object type or a type parameter." }, - The_right_hand_side_of_an_instanceof_expression_must_be_of_type_any_or_of_a_type_assignable_to_the_Function_interface_type: { code: 2359, category: ts.DiagnosticCategory.Error, key: "The right-hand side of an 'instanceof' expression must be of type 'any' or of a type assignable to the 'Function' interface type." }, - The_left_hand_side_of_an_in_expression_must_be_of_type_any_string_number_or_symbol: { code: 2360, category: ts.DiagnosticCategory.Error, key: "The left-hand side of an 'in' expression must be of type 'any', 'string', 'number', or 'symbol'." }, - The_right_hand_side_of_an_in_expression_must_be_of_type_any_an_object_type_or_a_type_parameter: { code: 2361, category: ts.DiagnosticCategory.Error, key: "The right-hand side of an 'in' expression must be of type 'any', an object type or a type parameter" }, - The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type: { code: 2362, category: ts.DiagnosticCategory.Error, key: "The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type." }, - The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type: { code: 2363, category: ts.DiagnosticCategory.Error, key: "The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type." }, - Invalid_left_hand_side_of_assignment_expression: { code: 2364, category: ts.DiagnosticCategory.Error, key: "Invalid left-hand side of assignment expression." }, - Operator_0_cannot_be_applied_to_types_1_and_2: { code: 2365, category: ts.DiagnosticCategory.Error, key: "Operator '{0}' cannot be applied to types '{1}' and '{2}'." }, - Type_parameter_name_cannot_be_0: { code: 2368, category: ts.DiagnosticCategory.Error, key: "Type parameter name cannot be '{0}'" }, - A_parameter_property_is_only_allowed_in_a_constructor_implementation: { code: 2369, category: ts.DiagnosticCategory.Error, key: "A parameter property is only allowed in a constructor implementation." }, - A_rest_parameter_must_be_of_an_array_type: { code: 2370, category: ts.DiagnosticCategory.Error, key: "A rest parameter must be of an array type." }, - A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation: { code: 2371, category: ts.DiagnosticCategory.Error, key: "A parameter initializer is only allowed in a function or constructor implementation." }, - Parameter_0_cannot_be_referenced_in_its_initializer: { code: 2372, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' cannot be referenced in its initializer." }, - Initializer_of_parameter_0_cannot_reference_identifier_1_declared_after_it: { code: 2373, category: ts.DiagnosticCategory.Error, key: "Initializer of parameter '{0}' cannot reference identifier '{1}' declared after it." }, - Duplicate_string_index_signature: { code: 2374, category: ts.DiagnosticCategory.Error, key: "Duplicate string index signature." }, - Duplicate_number_index_signature: { code: 2375, category: ts.DiagnosticCategory.Error, key: "Duplicate number index signature." }, - A_super_call_must_be_the_first_statement_in_the_constructor_when_a_class_contains_initialized_properties_or_has_parameter_properties: { code: 2376, category: ts.DiagnosticCategory.Error, key: "A 'super' call must be the first statement in the constructor when a class contains initialized properties or has parameter properties." }, - Constructors_for_derived_classes_must_contain_a_super_call: { code: 2377, category: ts.DiagnosticCategory.Error, key: "Constructors for derived classes must contain a 'super' call." }, - A_get_accessor_must_return_a_value_or_consist_of_a_single_throw_statement: { code: 2378, category: ts.DiagnosticCategory.Error, key: "A 'get' accessor must return a value or consist of a single 'throw' statement." }, - Getter_and_setter_accessors_do_not_agree_in_visibility: { code: 2379, category: ts.DiagnosticCategory.Error, key: "Getter and setter accessors do not agree in visibility." }, - get_and_set_accessor_must_have_the_same_type: { code: 2380, category: ts.DiagnosticCategory.Error, key: "'get' and 'set' accessor must have the same type." }, - A_signature_with_an_implementation_cannot_use_a_string_literal_type: { code: 2381, category: ts.DiagnosticCategory.Error, key: "A signature with an implementation cannot use a string literal type." }, - Specialized_overload_signature_is_not_assignable_to_any_non_specialized_signature: { code: 2382, category: ts.DiagnosticCategory.Error, key: "Specialized overload signature is not assignable to any non-specialized signature." }, - Overload_signatures_must_all_be_exported_or_not_exported: { code: 2383, category: ts.DiagnosticCategory.Error, key: "Overload signatures must all be exported or not exported." }, - Overload_signatures_must_all_be_ambient_or_non_ambient: { code: 2384, category: ts.DiagnosticCategory.Error, key: "Overload signatures must all be ambient or non-ambient." }, - Overload_signatures_must_all_be_public_private_or_protected: { code: 2385, category: ts.DiagnosticCategory.Error, key: "Overload signatures must all be public, private or protected." }, - Overload_signatures_must_all_be_optional_or_required: { code: 2386, category: ts.DiagnosticCategory.Error, key: "Overload signatures must all be optional or required." }, - Function_overload_must_be_static: { code: 2387, category: ts.DiagnosticCategory.Error, key: "Function overload must be static." }, - Function_overload_must_not_be_static: { code: 2388, category: ts.DiagnosticCategory.Error, key: "Function overload must not be static." }, - Function_implementation_name_must_be_0: { code: 2389, category: ts.DiagnosticCategory.Error, key: "Function implementation name must be '{0}'." }, - Constructor_implementation_is_missing: { code: 2390, category: ts.DiagnosticCategory.Error, key: "Constructor implementation is missing." }, - Function_implementation_is_missing_or_not_immediately_following_the_declaration: { code: 2391, category: ts.DiagnosticCategory.Error, key: "Function implementation is missing or not immediately following the declaration." }, - Multiple_constructor_implementations_are_not_allowed: { code: 2392, category: ts.DiagnosticCategory.Error, key: "Multiple constructor implementations are not allowed." }, - Duplicate_function_implementation: { code: 2393, category: ts.DiagnosticCategory.Error, key: "Duplicate function implementation." }, - Overload_signature_is_not_compatible_with_function_implementation: { code: 2394, category: ts.DiagnosticCategory.Error, key: "Overload signature is not compatible with function implementation." }, - Individual_declarations_in_merged_declaration_0_must_be_all_exported_or_all_local: { code: 2395, category: ts.DiagnosticCategory.Error, key: "Individual declarations in merged declaration '{0}' must be all exported or all local." }, - Duplicate_identifier_arguments_Compiler_uses_arguments_to_initialize_rest_parameters: { code: 2396, category: ts.DiagnosticCategory.Error, key: "Duplicate identifier 'arguments'. Compiler uses 'arguments' to initialize rest parameters." }, - Duplicate_identifier_this_Compiler_uses_variable_declaration_this_to_capture_this_reference: { code: 2399, category: ts.DiagnosticCategory.Error, key: "Duplicate identifier '_this'. Compiler uses variable declaration '_this' to capture 'this' reference." }, - Expression_resolves_to_variable_declaration_this_that_compiler_uses_to_capture_this_reference: { code: 2400, category: ts.DiagnosticCategory.Error, key: "Expression resolves to variable declaration '_this' that compiler uses to capture 'this' reference." }, - Duplicate_identifier_super_Compiler_uses_super_to_capture_base_class_reference: { code: 2401, category: ts.DiagnosticCategory.Error, key: "Duplicate identifier '_super'. Compiler uses '_super' to capture base class reference." }, - Expression_resolves_to_super_that_compiler_uses_to_capture_base_class_reference: { code: 2402, category: ts.DiagnosticCategory.Error, key: "Expression resolves to '_super' that compiler uses to capture base class reference." }, - Subsequent_variable_declarations_must_have_the_same_type_Variable_0_must_be_of_type_1_but_here_has_type_2: { code: 2403, category: ts.DiagnosticCategory.Error, key: "Subsequent variable declarations must have the same type. Variable '{0}' must be of type '{1}', but here has type '{2}'." }, - The_left_hand_side_of_a_for_in_statement_cannot_use_a_type_annotation: { code: 2404, category: ts.DiagnosticCategory.Error, key: "The left-hand side of a 'for...in' statement cannot use a type annotation." }, - The_left_hand_side_of_a_for_in_statement_must_be_of_type_string_or_any: { code: 2405, category: ts.DiagnosticCategory.Error, key: "The left-hand side of a 'for...in' statement must be of type 'string' or 'any'." }, - Invalid_left_hand_side_in_for_in_statement: { code: 2406, category: ts.DiagnosticCategory.Error, key: "Invalid left-hand side in 'for...in' statement." }, - The_right_hand_side_of_a_for_in_statement_must_be_of_type_any_an_object_type_or_a_type_parameter: { code: 2407, category: ts.DiagnosticCategory.Error, key: "The right-hand side of a 'for...in' statement must be of type 'any', an object type or a type parameter." }, - Setters_cannot_return_a_value: { code: 2408, category: ts.DiagnosticCategory.Error, key: "Setters cannot return a value." }, - Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class: { code: 2409, category: ts.DiagnosticCategory.Error, key: "Return type of constructor signature must be assignable to the instance type of the class" }, - All_symbols_within_a_with_block_will_be_resolved_to_any: { code: 2410, category: ts.DiagnosticCategory.Error, key: "All symbols within a 'with' block will be resolved to 'any'." }, - Property_0_of_type_1_is_not_assignable_to_string_index_type_2: { code: 2411, category: ts.DiagnosticCategory.Error, key: "Property '{0}' of type '{1}' is not assignable to string index type '{2}'." }, - Property_0_of_type_1_is_not_assignable_to_numeric_index_type_2: { code: 2412, category: ts.DiagnosticCategory.Error, key: "Property '{0}' of type '{1}' is not assignable to numeric index type '{2}'." }, - Numeric_index_type_0_is_not_assignable_to_string_index_type_1: { code: 2413, category: ts.DiagnosticCategory.Error, key: "Numeric index type '{0}' is not assignable to string index type '{1}'." }, - Class_name_cannot_be_0: { code: 2414, category: ts.DiagnosticCategory.Error, key: "Class name cannot be '{0}'" }, - Class_0_incorrectly_extends_base_class_1: { code: 2415, category: ts.DiagnosticCategory.Error, key: "Class '{0}' incorrectly extends base class '{1}'." }, - Class_static_side_0_incorrectly_extends_base_class_static_side_1: { code: 2417, category: ts.DiagnosticCategory.Error, key: "Class static side '{0}' incorrectly extends base class static side '{1}'." }, - Type_name_0_in_extends_clause_does_not_reference_constructor_function_for_0: { code: 2419, category: ts.DiagnosticCategory.Error, key: "Type name '{0}' in extends clause does not reference constructor function for '{0}'." }, - Class_0_incorrectly_implements_interface_1: { code: 2420, category: ts.DiagnosticCategory.Error, key: "Class '{0}' incorrectly implements interface '{1}'." }, - A_class_may_only_implement_another_class_or_interface: { code: 2422, category: ts.DiagnosticCategory.Error, key: "A class may only implement another class or interface." }, - Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_accessor: { code: 2423, category: ts.DiagnosticCategory.Error, key: "Class '{0}' defines instance member function '{1}', but extended class '{2}' defines it as instance member accessor." }, - Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_property: { code: 2424, category: ts.DiagnosticCategory.Error, key: "Class '{0}' defines instance member function '{1}', but extended class '{2}' defines it as instance member property." }, - Class_0_defines_instance_member_property_1_but_extended_class_2_defines_it_as_instance_member_function: { code: 2425, category: ts.DiagnosticCategory.Error, key: "Class '{0}' defines instance member property '{1}', but extended class '{2}' defines it as instance member function." }, - Class_0_defines_instance_member_accessor_1_but_extended_class_2_defines_it_as_instance_member_function: { code: 2426, category: ts.DiagnosticCategory.Error, key: "Class '{0}' defines instance member accessor '{1}', but extended class '{2}' defines it as instance member function." }, - Interface_name_cannot_be_0: { code: 2427, category: ts.DiagnosticCategory.Error, key: "Interface name cannot be '{0}'" }, - All_declarations_of_an_interface_must_have_identical_type_parameters: { code: 2428, category: ts.DiagnosticCategory.Error, key: "All declarations of an interface must have identical type parameters." }, - Interface_0_incorrectly_extends_interface_1: { code: 2430, category: ts.DiagnosticCategory.Error, key: "Interface '{0}' incorrectly extends interface '{1}'." }, - Enum_name_cannot_be_0: { code: 2431, category: ts.DiagnosticCategory.Error, key: "Enum name cannot be '{0}'" }, - In_an_enum_with_multiple_declarations_only_one_declaration_can_omit_an_initializer_for_its_first_enum_element: { code: 2432, category: ts.DiagnosticCategory.Error, key: "In an enum with multiple declarations, only one declaration can omit an initializer for its first enum element." }, - A_namespace_declaration_cannot_be_in_a_different_file_from_a_class_or_function_with_which_it_is_merged: { code: 2433, category: ts.DiagnosticCategory.Error, key: "A namespace declaration cannot be in a different file from a class or function with which it is merged" }, - A_namespace_declaration_cannot_be_located_prior_to_a_class_or_function_with_which_it_is_merged: { code: 2434, category: ts.DiagnosticCategory.Error, key: "A namespace declaration cannot be located prior to a class or function with which it is merged" }, - Ambient_modules_cannot_be_nested_in_other_modules_or_namespaces: { code: 2435, category: ts.DiagnosticCategory.Error, key: "Ambient modules cannot be nested in other modules or namespaces." }, - Ambient_module_declaration_cannot_specify_relative_module_name: { code: 2436, category: ts.DiagnosticCategory.Error, key: "Ambient module declaration cannot specify relative module name." }, - Module_0_is_hidden_by_a_local_declaration_with_the_same_name: { code: 2437, category: ts.DiagnosticCategory.Error, key: "Module '{0}' is hidden by a local declaration with the same name" }, - Import_name_cannot_be_0: { code: 2438, category: ts.DiagnosticCategory.Error, key: "Import name cannot be '{0}'" }, - Import_or_export_declaration_in_an_ambient_module_declaration_cannot_reference_module_through_relative_module_name: { code: 2439, category: ts.DiagnosticCategory.Error, key: "Import or export declaration in an ambient module declaration cannot reference module through relative module name." }, - Import_declaration_conflicts_with_local_declaration_of_0: { code: 2440, category: ts.DiagnosticCategory.Error, key: "Import declaration conflicts with local declaration of '{0}'" }, - Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module: { code: 2441, category: ts.DiagnosticCategory.Error, key: "Duplicate identifier '{0}'. Compiler reserves name '{1}' in top level scope of a module." }, - Types_have_separate_declarations_of_a_private_property_0: { code: 2442, category: ts.DiagnosticCategory.Error, key: "Types have separate declarations of a private property '{0}'." }, - Property_0_is_protected_but_type_1_is_not_a_class_derived_from_2: { code: 2443, category: ts.DiagnosticCategory.Error, key: "Property '{0}' is protected but type '{1}' is not a class derived from '{2}'." }, - Property_0_is_protected_in_type_1_but_public_in_type_2: { code: 2444, category: ts.DiagnosticCategory.Error, key: "Property '{0}' is protected in type '{1}' but public in type '{2}'." }, - Property_0_is_protected_and_only_accessible_within_class_1_and_its_subclasses: { code: 2445, category: ts.DiagnosticCategory.Error, key: "Property '{0}' is protected and only accessible within class '{1}' and its subclasses." }, - Property_0_is_protected_and_only_accessible_through_an_instance_of_class_1: { code: 2446, category: ts.DiagnosticCategory.Error, key: "Property '{0}' is protected and only accessible through an instance of class '{1}'." }, - The_0_operator_is_not_allowed_for_boolean_types_Consider_using_1_instead: { code: 2447, category: ts.DiagnosticCategory.Error, key: "The '{0}' operator is not allowed for boolean types. Consider using '{1}' instead." }, - Block_scoped_variable_0_used_before_its_declaration: { code: 2448, category: ts.DiagnosticCategory.Error, key: "Block-scoped variable '{0}' used before its declaration." }, - The_operand_of_an_increment_or_decrement_operator_cannot_be_a_constant: { code: 2449, category: ts.DiagnosticCategory.Error, key: "The operand of an increment or decrement operator cannot be a constant." }, - Left_hand_side_of_assignment_expression_cannot_be_a_constant: { code: 2450, category: ts.DiagnosticCategory.Error, key: "Left-hand side of assignment expression cannot be a constant." }, - Cannot_redeclare_block_scoped_variable_0: { code: 2451, category: ts.DiagnosticCategory.Error, key: "Cannot redeclare block-scoped variable '{0}'." }, - An_enum_member_cannot_have_a_numeric_name: { code: 2452, category: ts.DiagnosticCategory.Error, key: "An enum member cannot have a numeric name." }, - The_type_argument_for_type_parameter_0_cannot_be_inferred_from_the_usage_Consider_specifying_the_type_arguments_explicitly: { code: 2453, category: ts.DiagnosticCategory.Error, key: "The type argument for type parameter '{0}' cannot be inferred from the usage. Consider specifying the type arguments explicitly." }, - Type_argument_candidate_1_is_not_a_valid_type_argument_because_it_is_not_a_supertype_of_candidate_0: { code: 2455, category: ts.DiagnosticCategory.Error, key: "Type argument candidate '{1}' is not a valid type argument because it is not a supertype of candidate '{0}'." }, - Type_alias_0_circularly_references_itself: { code: 2456, category: ts.DiagnosticCategory.Error, key: "Type alias '{0}' circularly references itself." }, - Type_alias_name_cannot_be_0: { code: 2457, category: ts.DiagnosticCategory.Error, key: "Type alias name cannot be '{0}'" }, - An_AMD_module_cannot_have_multiple_name_assignments: { code: 2458, category: ts.DiagnosticCategory.Error, key: "An AMD module cannot have multiple name assignments." }, - Type_0_has_no_property_1_and_no_string_index_signature: { code: 2459, category: ts.DiagnosticCategory.Error, key: "Type '{0}' has no property '{1}' and no string index signature." }, - Type_0_has_no_property_1: { code: 2460, category: ts.DiagnosticCategory.Error, key: "Type '{0}' has no property '{1}'." }, - Type_0_is_not_an_array_type: { code: 2461, category: ts.DiagnosticCategory.Error, key: "Type '{0}' is not an array type." }, - A_rest_element_must_be_last_in_an_array_destructuring_pattern: { code: 2462, category: ts.DiagnosticCategory.Error, key: "A rest element must be last in an array destructuring pattern" }, - A_binding_pattern_parameter_cannot_be_optional_in_an_implementation_signature: { code: 2463, category: ts.DiagnosticCategory.Error, key: "A binding pattern parameter cannot be optional in an implementation signature." }, - A_computed_property_name_must_be_of_type_string_number_symbol_or_any: { code: 2464, category: ts.DiagnosticCategory.Error, key: "A computed property name must be of type 'string', 'number', 'symbol', or 'any'." }, - this_cannot_be_referenced_in_a_computed_property_name: { code: 2465, category: ts.DiagnosticCategory.Error, key: "'this' cannot be referenced in a computed property name." }, - super_cannot_be_referenced_in_a_computed_property_name: { code: 2466, category: ts.DiagnosticCategory.Error, key: "'super' cannot be referenced in a computed property name." }, - A_computed_property_name_cannot_reference_a_type_parameter_from_its_containing_type: { code: 2467, category: ts.DiagnosticCategory.Error, key: "A computed property name cannot reference a type parameter from its containing type." }, - Cannot_find_global_value_0: { code: 2468, category: ts.DiagnosticCategory.Error, key: "Cannot find global value '{0}'." }, - The_0_operator_cannot_be_applied_to_type_symbol: { code: 2469, category: ts.DiagnosticCategory.Error, key: "The '{0}' operator cannot be applied to type 'symbol'." }, - Symbol_reference_does_not_refer_to_the_global_Symbol_constructor_object: { code: 2470, category: ts.DiagnosticCategory.Error, key: "'Symbol' reference does not refer to the global Symbol constructor object." }, - A_computed_property_name_of_the_form_0_must_be_of_type_symbol: { code: 2471, category: ts.DiagnosticCategory.Error, key: "A computed property name of the form '{0}' must be of type 'symbol'." }, - Spread_operator_in_new_expressions_is_only_available_when_targeting_ECMAScript_5_and_higher: { code: 2472, category: ts.DiagnosticCategory.Error, key: "Spread operator in 'new' expressions is only available when targeting ECMAScript 5 and higher." }, - Enum_declarations_must_all_be_const_or_non_const: { code: 2473, category: ts.DiagnosticCategory.Error, key: "Enum declarations must all be const or non-const." }, - In_const_enum_declarations_member_initializer_must_be_constant_expression: { code: 2474, category: ts.DiagnosticCategory.Error, key: "In 'const' enum declarations member initializer must be constant expression." }, - const_enums_can_only_be_used_in_property_or_index_access_expressions_or_the_right_hand_side_of_an_import_declaration_or_export_assignment: { code: 2475, category: ts.DiagnosticCategory.Error, key: "'const' enums can only be used in property or index access expressions or the right hand side of an import declaration or export assignment." }, - A_const_enum_member_can_only_be_accessed_using_a_string_literal: { code: 2476, category: ts.DiagnosticCategory.Error, key: "A const enum member can only be accessed using a string literal." }, - const_enum_member_initializer_was_evaluated_to_a_non_finite_value: { code: 2477, category: ts.DiagnosticCategory.Error, key: "'const' enum member initializer was evaluated to a non-finite value." }, - const_enum_member_initializer_was_evaluated_to_disallowed_value_NaN: { code: 2478, category: ts.DiagnosticCategory.Error, key: "'const' enum member initializer was evaluated to disallowed value 'NaN'." }, - Property_0_does_not_exist_on_const_enum_1: { code: 2479, category: ts.DiagnosticCategory.Error, key: "Property '{0}' does not exist on 'const' enum '{1}'." }, - let_is_not_allowed_to_be_used_as_a_name_in_let_or_const_declarations: { code: 2480, category: ts.DiagnosticCategory.Error, key: "'let' is not allowed to be used as a name in 'let' or 'const' declarations." }, - Cannot_initialize_outer_scoped_variable_0_in_the_same_scope_as_block_scoped_declaration_1: { code: 2481, category: ts.DiagnosticCategory.Error, key: "Cannot initialize outer scoped variable '{0}' in the same scope as block scoped declaration '{1}'." }, - The_left_hand_side_of_a_for_of_statement_cannot_use_a_type_annotation: { code: 2483, category: ts.DiagnosticCategory.Error, key: "The left-hand side of a 'for...of' statement cannot use a type annotation." }, - Export_declaration_conflicts_with_exported_declaration_of_0: { code: 2484, category: ts.DiagnosticCategory.Error, key: "Export declaration conflicts with exported declaration of '{0}'" }, - The_left_hand_side_of_a_for_of_statement_cannot_be_a_previously_defined_constant: { code: 2485, category: ts.DiagnosticCategory.Error, key: "The left-hand side of a 'for...of' statement cannot be a previously defined constant." }, - The_left_hand_side_of_a_for_in_statement_cannot_be_a_previously_defined_constant: { code: 2486, category: ts.DiagnosticCategory.Error, key: "The left-hand side of a 'for...in' statement cannot be a previously defined constant." }, - Invalid_left_hand_side_in_for_of_statement: { code: 2487, category: ts.DiagnosticCategory.Error, key: "Invalid left-hand side in 'for...of' statement." }, - Type_must_have_a_Symbol_iterator_method_that_returns_an_iterator: { code: 2488, category: ts.DiagnosticCategory.Error, key: "Type must have a '[Symbol.iterator]()' method that returns an iterator." }, - An_iterator_must_have_a_next_method: { code: 2489, category: ts.DiagnosticCategory.Error, key: "An iterator must have a 'next()' method." }, - The_type_returned_by_the_next_method_of_an_iterator_must_have_a_value_property: { code: 2490, category: ts.DiagnosticCategory.Error, key: "The type returned by the 'next()' method of an iterator must have a 'value' property." }, - The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern: { code: 2491, category: ts.DiagnosticCategory.Error, key: "The left-hand side of a 'for...in' statement cannot be a destructuring pattern." }, - Cannot_redeclare_identifier_0_in_catch_clause: { code: 2492, category: ts.DiagnosticCategory.Error, key: "Cannot redeclare identifier '{0}' in catch clause" }, - Tuple_type_0_with_length_1_cannot_be_assigned_to_tuple_with_length_2: { code: 2493, category: ts.DiagnosticCategory.Error, key: "Tuple type '{0}' with length '{1}' cannot be assigned to tuple with length '{2}'." }, - Using_a_string_in_a_for_of_statement_is_only_supported_in_ECMAScript_5_and_higher: { code: 2494, category: ts.DiagnosticCategory.Error, key: "Using a string in a 'for...of' statement is only supported in ECMAScript 5 and higher." }, - Type_0_is_not_an_array_type_or_a_string_type: { code: 2495, category: ts.DiagnosticCategory.Error, key: "Type '{0}' is not an array type or a string type." }, - The_arguments_object_cannot_be_referenced_in_an_arrow_function_in_ES3_and_ES5_Consider_using_a_standard_function_expression: { code: 2496, category: ts.DiagnosticCategory.Error, key: "The 'arguments' object cannot be referenced in an arrow function in ES3 and ES5. Consider using a standard function expression." }, - Module_0_resolves_to_a_non_module_entity_and_cannot_be_imported_using_this_construct: { code: 2497, category: ts.DiagnosticCategory.Error, key: "Module '{0}' resolves to a non-module entity and cannot be imported using this construct." }, - Module_0_uses_export_and_cannot_be_used_with_export_Asterisk: { code: 2498, category: ts.DiagnosticCategory.Error, key: "Module '{0}' uses 'export =' and cannot be used with 'export *'." }, - An_interface_can_only_extend_an_identifier_Slashqualified_name_with_optional_type_arguments: { code: 2499, category: ts.DiagnosticCategory.Error, key: "An interface can only extend an identifier/qualified-name with optional type arguments." }, - A_class_can_only_implement_an_identifier_Slashqualified_name_with_optional_type_arguments: { code: 2500, category: ts.DiagnosticCategory.Error, key: "A class can only implement an identifier/qualified-name with optional type arguments." }, - A_rest_element_cannot_contain_a_binding_pattern: { code: 2501, category: ts.DiagnosticCategory.Error, key: "A rest element cannot contain a binding pattern." }, - _0_is_referenced_directly_or_indirectly_in_its_own_type_annotation: { code: 2502, category: ts.DiagnosticCategory.Error, key: "'{0}' is referenced directly or indirectly in its own type annotation." }, - Cannot_find_namespace_0: { code: 2503, category: ts.DiagnosticCategory.Error, key: "Cannot find namespace '{0}'." }, - No_best_common_type_exists_among_yield_expressions: { code: 2504, category: ts.DiagnosticCategory.Error, key: "No best common type exists among yield expressions." }, - A_generator_cannot_have_a_void_type_annotation: { code: 2505, category: ts.DiagnosticCategory.Error, key: "A generator cannot have a 'void' type annotation." }, - _0_is_referenced_directly_or_indirectly_in_its_own_base_expression: { code: 2506, category: ts.DiagnosticCategory.Error, key: "'{0}' is referenced directly or indirectly in its own base expression." }, - Type_0_is_not_a_constructor_function_type: { code: 2507, category: ts.DiagnosticCategory.Error, key: "Type '{0}' is not a constructor function type." }, - No_base_constructor_has_the_specified_number_of_type_arguments: { code: 2508, category: ts.DiagnosticCategory.Error, key: "No base constructor has the specified number of type arguments." }, - Base_constructor_return_type_0_is_not_a_class_or_interface_type: { code: 2509, category: ts.DiagnosticCategory.Error, key: "Base constructor return type '{0}' is not a class or interface type." }, - Base_constructors_must_all_have_the_same_return_type: { code: 2510, category: ts.DiagnosticCategory.Error, key: "Base constructors must all have the same return type." }, - Cannot_create_an_instance_of_the_abstract_class_0: { code: 2511, category: ts.DiagnosticCategory.Error, key: "Cannot create an instance of the abstract class '{0}'." }, - Overload_signatures_must_all_be_abstract_or_not_abstract: { code: 2512, category: ts.DiagnosticCategory.Error, key: "Overload signatures must all be abstract or not abstract." }, - Abstract_method_0_in_class_1_cannot_be_accessed_via_super_expression: { code: 2513, category: ts.DiagnosticCategory.Error, key: "Abstract method '{0}' in class '{1}' cannot be accessed via super expression." }, - Classes_containing_abstract_methods_must_be_marked_abstract: { code: 2514, category: ts.DiagnosticCategory.Error, key: "Classes containing abstract methods must be marked abstract." }, - Non_abstract_class_0_does_not_implement_inherited_abstract_member_1_from_class_2: { code: 2515, category: ts.DiagnosticCategory.Error, key: "Non-abstract class '{0}' does not implement inherited abstract member '{1}' from class '{2}'." }, - All_declarations_of_an_abstract_method_must_be_consecutive: { code: 2516, category: ts.DiagnosticCategory.Error, key: "All declarations of an abstract method must be consecutive." }, - Cannot_assign_an_abstract_constructor_type_to_a_non_abstract_constructor_type: { code: 2517, category: ts.DiagnosticCategory.Error, key: "Cannot assign an abstract constructor type to a non-abstract constructor type." }, - Duplicate_identifier_0_Compiler_uses_declaration_1_to_support_async_functions: { code: 2520, category: ts.DiagnosticCategory.Error, key: "Duplicate identifier '{0}'. Compiler uses declaration '{1}' to support async functions." }, - Expression_resolves_to_variable_declaration_0_that_compiler_uses_to_support_async_functions: { code: 2521, category: ts.DiagnosticCategory.Error, key: "Expression resolves to variable declaration '{0}' that compiler uses to support async functions." }, - The_arguments_object_cannot_be_referenced_in_an_async_arrow_function_Consider_using_a_standard_async_function_expression: { code: 2522, category: ts.DiagnosticCategory.Error, key: "The 'arguments' object cannot be referenced in an async arrow function. Consider using a standard async function expression." }, - yield_expressions_cannot_be_used_in_a_parameter_initializer: { code: 2523, category: ts.DiagnosticCategory.Error, key: "'yield' expressions cannot be used in a parameter initializer." }, - await_expressions_cannot_be_used_in_a_parameter_initializer: { code: 2524, category: ts.DiagnosticCategory.Error, key: "'await' expressions cannot be used in a parameter initializer." }, - Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value: { code: 2525, category: ts.DiagnosticCategory.Error, key: "Initializer provides no value for this binding element and the binding element has no default value." }, - A_this_type_is_available_only_in_a_non_static_member_of_a_class_or_interface: { code: 2526, category: ts.DiagnosticCategory.Error, key: "A 'this' type is available only in a non-static member of a class or interface." }, - The_inferred_type_of_0_references_an_inaccessible_this_type_A_type_annotation_is_necessary: { code: 2527, category: ts.DiagnosticCategory.Error, key: "The inferred type of '{0}' references an inaccessible 'this' type. A type annotation is necessary." }, - A_module_cannot_have_multiple_default_exports: { code: 2528, category: ts.DiagnosticCategory.Error, key: "A module cannot have multiple default exports." }, - JSX_element_attributes_type_0_must_be_an_object_type: { code: 2600, category: ts.DiagnosticCategory.Error, key: "JSX element attributes type '{0}' must be an object type." }, - The_return_type_of_a_JSX_element_constructor_must_return_an_object_type: { code: 2601, category: ts.DiagnosticCategory.Error, key: "The return type of a JSX element constructor must return an object type." }, - JSX_element_implicitly_has_type_any_because_the_global_type_JSX_Element_does_not_exist: { code: 2602, category: ts.DiagnosticCategory.Error, key: "JSX element implicitly has type 'any' because the global type 'JSX.Element' does not exist." }, - Property_0_in_type_1_is_not_assignable_to_type_2: { code: 2603, category: ts.DiagnosticCategory.Error, key: "Property '{0}' in type '{1}' is not assignable to type '{2}'" }, - JSX_element_type_0_does_not_have_any_construct_or_call_signatures: { code: 2604, category: ts.DiagnosticCategory.Error, key: "JSX element type '{0}' does not have any construct or call signatures." }, - JSX_element_type_0_is_not_a_constructor_function_for_JSX_elements: { code: 2605, category: ts.DiagnosticCategory.Error, key: "JSX element type '{0}' is not a constructor function for JSX elements." }, - Property_0_of_JSX_spread_attribute_is_not_assignable_to_target_property: { code: 2606, category: ts.DiagnosticCategory.Error, key: "Property '{0}' of JSX spread attribute is not assignable to target property." }, - JSX_element_class_does_not_support_attributes_because_it_does_not_have_a_0_property: { code: 2607, category: ts.DiagnosticCategory.Error, key: "JSX element class does not support attributes because it does not have a '{0}' property" }, - The_global_type_JSX_0_may_not_have_more_than_one_property: { code: 2608, category: ts.DiagnosticCategory.Error, key: "The global type 'JSX.{0}' may not have more than one property" }, - Cannot_emit_namespaced_JSX_elements_in_React: { code: 2650, category: ts.DiagnosticCategory.Error, key: "Cannot emit namespaced JSX elements in React" }, - A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_enums: { code: 2651, category: ts.DiagnosticCategory.Error, key: "A member initializer in a enum declaration cannot reference members declared after it, including members defined in other enums." }, - Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_default_0_declaration_instead: { code: 2652, category: ts.DiagnosticCategory.Error, key: "Merged declaration '{0}' cannot include a default export declaration. Consider adding a separate 'export default {0}' declaration instead." }, - Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1: { code: 2653, category: ts.DiagnosticCategory.Error, key: "Non-abstract class expression does not implement inherited abstract member '{0}' from class '{1}'." }, - Exported_external_package_typings_file_cannot_contain_tripleslash_references_Please_contact_the_package_author_to_update_the_package_definition: { code: 2654, category: ts.DiagnosticCategory.Error, key: "Exported external package typings file cannot contain tripleslash references. Please contact the package author to update the package definition." }, - Exported_external_package_typings_can_only_be_in_d_ts_files_Please_contact_the_package_author_to_update_the_package_definition: { code: 2655, category: ts.DiagnosticCategory.Error, key: "Exported external package typings can only be in '.d.ts' files. Please contact the package author to update the package definition." }, - Exported_external_package_typings_file_0_is_not_a_module_Please_contact_the_package_author_to_update_the_package_definition: { code: 2656, category: ts.DiagnosticCategory.Error, key: "Exported external package typings file '{0}' is not a module. Please contact the package author to update the package definition." }, - JSX_expressions_must_have_one_parent_element: { code: 2657, category: ts.DiagnosticCategory.Error, key: "JSX expressions must have one parent element" }, - Import_declaration_0_is_using_private_name_1: { code: 4000, category: ts.DiagnosticCategory.Error, key: "Import declaration '{0}' is using private name '{1}'." }, - Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: { code: 4002, category: ts.DiagnosticCategory.Error, key: "Type parameter '{0}' of exported class has or is using private name '{1}'." }, - Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1: { code: 4004, category: ts.DiagnosticCategory.Error, key: "Type parameter '{0}' of exported interface has or is using private name '{1}'." }, - Type_parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1: { code: 4006, category: ts.DiagnosticCategory.Error, key: "Type parameter '{0}' of constructor signature from exported interface has or is using private name '{1}'." }, - Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1: { code: 4008, category: ts.DiagnosticCategory.Error, key: "Type parameter '{0}' of call signature from exported interface has or is using private name '{1}'." }, - Type_parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1: { code: 4010, category: ts.DiagnosticCategory.Error, key: "Type parameter '{0}' of public static method from exported class has or is using private name '{1}'." }, - Type_parameter_0_of_public_method_from_exported_class_has_or_is_using_private_name_1: { code: 4012, category: ts.DiagnosticCategory.Error, key: "Type parameter '{0}' of public method from exported class has or is using private name '{1}'." }, - Type_parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1: { code: 4014, category: ts.DiagnosticCategory.Error, key: "Type parameter '{0}' of method from exported interface has or is using private name '{1}'." }, - Type_parameter_0_of_exported_function_has_or_is_using_private_name_1: { code: 4016, category: ts.DiagnosticCategory.Error, key: "Type parameter '{0}' of exported function has or is using private name '{1}'." }, - Implements_clause_of_exported_class_0_has_or_is_using_private_name_1: { code: 4019, category: ts.DiagnosticCategory.Error, key: "Implements clause of exported class '{0}' has or is using private name '{1}'." }, - Extends_clause_of_exported_class_0_has_or_is_using_private_name_1: { code: 4020, category: ts.DiagnosticCategory.Error, key: "Extends clause of exported class '{0}' has or is using private name '{1}'." }, - Extends_clause_of_exported_interface_0_has_or_is_using_private_name_1: { code: 4022, category: ts.DiagnosticCategory.Error, key: "Extends clause of exported interface '{0}' has or is using private name '{1}'." }, - Exported_variable_0_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: { code: 4023, category: ts.DiagnosticCategory.Error, key: "Exported variable '{0}' has or is using name '{1}' from external module {2} but cannot be named." }, - Exported_variable_0_has_or_is_using_name_1_from_private_module_2: { code: 4024, category: ts.DiagnosticCategory.Error, key: "Exported variable '{0}' has or is using name '{1}' from private module '{2}'." }, - Exported_variable_0_has_or_is_using_private_name_1: { code: 4025, category: ts.DiagnosticCategory.Error, key: "Exported variable '{0}' has or is using private name '{1}'." }, - Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: { code: 4026, category: ts.DiagnosticCategory.Error, key: "Public static property '{0}' of exported class has or is using name '{1}' from external module {2} but cannot be named." }, - Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2: { code: 4027, category: ts.DiagnosticCategory.Error, key: "Public static property '{0}' of exported class has or is using name '{1}' from private module '{2}'." }, - Public_static_property_0_of_exported_class_has_or_is_using_private_name_1: { code: 4028, category: ts.DiagnosticCategory.Error, key: "Public static property '{0}' of exported class has or is using private name '{1}'." }, - Public_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: { code: 4029, category: ts.DiagnosticCategory.Error, key: "Public property '{0}' of exported class has or is using name '{1}' from external module {2} but cannot be named." }, - Public_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2: { code: 4030, category: ts.DiagnosticCategory.Error, key: "Public property '{0}' of exported class has or is using name '{1}' from private module '{2}'." }, - Public_property_0_of_exported_class_has_or_is_using_private_name_1: { code: 4031, category: ts.DiagnosticCategory.Error, key: "Public property '{0}' of exported class has or is using private name '{1}'." }, - Property_0_of_exported_interface_has_or_is_using_name_1_from_private_module_2: { code: 4032, category: ts.DiagnosticCategory.Error, key: "Property '{0}' of exported interface has or is using name '{1}' from private module '{2}'." }, - Property_0_of_exported_interface_has_or_is_using_private_name_1: { code: 4033, category: ts.DiagnosticCategory.Error, key: "Property '{0}' of exported interface has or is using private name '{1}'." }, - Parameter_0_of_public_static_property_setter_from_exported_class_has_or_is_using_name_1_from_private_module_2: { code: 4034, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' of public static property setter from exported class has or is using name '{1}' from private module '{2}'." }, - Parameter_0_of_public_static_property_setter_from_exported_class_has_or_is_using_private_name_1: { code: 4035, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' of public static property setter from exported class has or is using private name '{1}'." }, - Parameter_0_of_public_property_setter_from_exported_class_has_or_is_using_name_1_from_private_module_2: { code: 4036, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' of public property setter from exported class has or is using name '{1}' from private module '{2}'." }, - Parameter_0_of_public_property_setter_from_exported_class_has_or_is_using_private_name_1: { code: 4037, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' of public property setter from exported class has or is using private name '{1}'." }, - Return_type_of_public_static_property_getter_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named: { code: 4038, category: ts.DiagnosticCategory.Error, key: "Return type of public static property getter from exported class has or is using name '{0}' from external module {1} but cannot be named." }, - Return_type_of_public_static_property_getter_from_exported_class_has_or_is_using_name_0_from_private_module_1: { code: 4039, category: ts.DiagnosticCategory.Error, key: "Return type of public static property getter from exported class has or is using name '{0}' from private module '{1}'." }, - Return_type_of_public_static_property_getter_from_exported_class_has_or_is_using_private_name_0: { code: 4040, category: ts.DiagnosticCategory.Error, key: "Return type of public static property getter from exported class has or is using private name '{0}'." }, - Return_type_of_public_property_getter_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named: { code: 4041, category: ts.DiagnosticCategory.Error, key: "Return type of public property getter from exported class has or is using name '{0}' from external module {1} but cannot be named." }, - Return_type_of_public_property_getter_from_exported_class_has_or_is_using_name_0_from_private_module_1: { code: 4042, category: ts.DiagnosticCategory.Error, key: "Return type of public property getter from exported class has or is using name '{0}' from private module '{1}'." }, - Return_type_of_public_property_getter_from_exported_class_has_or_is_using_private_name_0: { code: 4043, category: ts.DiagnosticCategory.Error, key: "Return type of public property getter from exported class has or is using private name '{0}'." }, - Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1: { code: 4044, category: ts.DiagnosticCategory.Error, key: "Return type of constructor signature from exported interface has or is using name '{0}' from private module '{1}'." }, - Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_0: { code: 4045, category: ts.DiagnosticCategory.Error, key: "Return type of constructor signature from exported interface has or is using private name '{0}'." }, - Return_type_of_call_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1: { code: 4046, category: ts.DiagnosticCategory.Error, key: "Return type of call signature from exported interface has or is using name '{0}' from private module '{1}'." }, - Return_type_of_call_signature_from_exported_interface_has_or_is_using_private_name_0: { code: 4047, category: ts.DiagnosticCategory.Error, key: "Return type of call signature from exported interface has or is using private name '{0}'." }, - Return_type_of_index_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1: { code: 4048, category: ts.DiagnosticCategory.Error, key: "Return type of index signature from exported interface has or is using name '{0}' from private module '{1}'." }, - Return_type_of_index_signature_from_exported_interface_has_or_is_using_private_name_0: { code: 4049, category: ts.DiagnosticCategory.Error, key: "Return type of index signature from exported interface has or is using private name '{0}'." }, - Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named: { code: 4050, category: ts.DiagnosticCategory.Error, key: "Return type of public static method from exported class has or is using name '{0}' from external module {1} but cannot be named." }, - Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_private_module_1: { code: 4051, category: ts.DiagnosticCategory.Error, key: "Return type of public static method from exported class has or is using name '{0}' from private module '{1}'." }, - Return_type_of_public_static_method_from_exported_class_has_or_is_using_private_name_0: { code: 4052, category: ts.DiagnosticCategory.Error, key: "Return type of public static method from exported class has or is using private name '{0}'." }, - Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named: { code: 4053, category: ts.DiagnosticCategory.Error, key: "Return type of public method from exported class has or is using name '{0}' from external module {1} but cannot be named." }, - Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_private_module_1: { code: 4054, category: ts.DiagnosticCategory.Error, key: "Return type of public method from exported class has or is using name '{0}' from private module '{1}'." }, - Return_type_of_public_method_from_exported_class_has_or_is_using_private_name_0: { code: 4055, category: ts.DiagnosticCategory.Error, key: "Return type of public method from exported class has or is using private name '{0}'." }, - Return_type_of_method_from_exported_interface_has_or_is_using_name_0_from_private_module_1: { code: 4056, category: ts.DiagnosticCategory.Error, key: "Return type of method from exported interface has or is using name '{0}' from private module '{1}'." }, - Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0: { code: 4057, category: ts.DiagnosticCategory.Error, key: "Return type of method from exported interface has or is using private name '{0}'." }, - Return_type_of_exported_function_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named: { code: 4058, category: ts.DiagnosticCategory.Error, key: "Return type of exported function has or is using name '{0}' from external module {1} but cannot be named." }, - Return_type_of_exported_function_has_or_is_using_name_0_from_private_module_1: { code: 4059, category: ts.DiagnosticCategory.Error, key: "Return type of exported function has or is using name '{0}' from private module '{1}'." }, - Return_type_of_exported_function_has_or_is_using_private_name_0: { code: 4060, category: ts.DiagnosticCategory.Error, key: "Return type of exported function has or is using private name '{0}'." }, - Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: { code: 4061, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' of constructor from exported class has or is using name '{1}' from external module {2} but cannot be named." }, - Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_private_module_2: { code: 4062, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' of constructor from exported class has or is using name '{1}' from private module '{2}'." }, - Parameter_0_of_constructor_from_exported_class_has_or_is_using_private_name_1: { code: 4063, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' of constructor from exported class has or is using private name '{1}'." }, - Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2: { code: 4064, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' of constructor signature from exported interface has or is using name '{1}' from private module '{2}'." }, - Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1: { code: 4065, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' of constructor signature from exported interface has or is using private name '{1}'." }, - Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2: { code: 4066, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' of call signature from exported interface has or is using name '{1}' from private module '{2}'." }, - Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1: { code: 4067, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' of call signature from exported interface has or is using private name '{1}'." }, - Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: { code: 4068, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' of public static method from exported class has or is using name '{1}' from external module {2} but cannot be named." }, - Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_private_module_2: { code: 4069, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' of public static method from exported class has or is using name '{1}' from private module '{2}'." }, - Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1: { code: 4070, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' of public static method from exported class has or is using private name '{1}'." }, - Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: { code: 4071, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' of public method from exported class has or is using name '{1}' from external module {2} but cannot be named." }, - Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_private_module_2: { code: 4072, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' of public method from exported class has or is using name '{1}' from private module '{2}'." }, - Parameter_0_of_public_method_from_exported_class_has_or_is_using_private_name_1: { code: 4073, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' of public method from exported class has or is using private name '{1}'." }, - Parameter_0_of_method_from_exported_interface_has_or_is_using_name_1_from_private_module_2: { code: 4074, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' of method from exported interface has or is using name '{1}' from private module '{2}'." }, - Parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1: { code: 4075, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' of method from exported interface has or is using private name '{1}'." }, - Parameter_0_of_exported_function_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: { code: 4076, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' of exported function has or is using name '{1}' from external module {2} but cannot be named." }, - Parameter_0_of_exported_function_has_or_is_using_name_1_from_private_module_2: { code: 4077, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' of exported function has or is using name '{1}' from private module '{2}'." }, - Parameter_0_of_exported_function_has_or_is_using_private_name_1: { code: 4078, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' of exported function has or is using private name '{1}'." }, - Exported_type_alias_0_has_or_is_using_private_name_1: { code: 4081, category: ts.DiagnosticCategory.Error, key: "Exported type alias '{0}' has or is using private name '{1}'." }, - Default_export_of_the_module_has_or_is_using_private_name_0: { code: 4082, category: ts.DiagnosticCategory.Error, key: "Default export of the module has or is using private name '{0}'." }, - Loop_contains_block_scoped_variable_0_referenced_by_a_function_in_the_loop_This_is_only_supported_in_ECMAScript_6_or_higher: { code: 4091, category: ts.DiagnosticCategory.Error, key: "Loop contains block-scoped variable '{0}' referenced by a function in the loop. This is only supported in ECMAScript 6 or higher." }, - The_current_host_does_not_support_the_0_option: { code: 5001, category: ts.DiagnosticCategory.Error, key: "The current host does not support the '{0}' option." }, - Cannot_find_the_common_subdirectory_path_for_the_input_files: { code: 5009, category: ts.DiagnosticCategory.Error, key: "Cannot find the common subdirectory path for the input files." }, - Cannot_read_file_0_Colon_1: { code: 5012, category: ts.DiagnosticCategory.Error, key: "Cannot read file '{0}': {1}" }, - Unsupported_file_encoding: { code: 5013, category: ts.DiagnosticCategory.Error, key: "Unsupported file encoding." }, - Failed_to_parse_file_0_Colon_1: { code: 5014, category: ts.DiagnosticCategory.Error, key: "Failed to parse file '{0}': {1}." }, - Unknown_compiler_option_0: { code: 5023, category: ts.DiagnosticCategory.Error, key: "Unknown compiler option '{0}'." }, - Compiler_option_0_requires_a_value_of_type_1: { code: 5024, category: ts.DiagnosticCategory.Error, key: "Compiler option '{0}' requires a value of type {1}." }, - Could_not_write_file_0_Colon_1: { code: 5033, category: ts.DiagnosticCategory.Error, key: "Could not write file '{0}': {1}" }, - Option_project_cannot_be_mixed_with_source_files_on_a_command_line: { code: 5042, category: ts.DiagnosticCategory.Error, key: "Option 'project' cannot be mixed with source files on a command line." }, - Option_isolatedModules_can_only_be_used_when_either_option_module_is_provided_or_option_target_is_ES2015_or_higher: { code: 5047, category: ts.DiagnosticCategory.Error, key: "Option 'isolatedModules' can only be used when either option '--module' is provided or option 'target' is 'ES2015' or higher." }, - Option_inlineSources_can_only_be_used_when_either_option_inlineSourceMap_or_option_sourceMap_is_provided: { code: 5051, category: ts.DiagnosticCategory.Error, key: "Option 'inlineSources' can only be used when either option '--inlineSourceMap' or option '--sourceMap' is provided." }, - Option_0_cannot_be_specified_without_specifying_option_1: { code: 5052, category: ts.DiagnosticCategory.Error, key: "Option '{0}' cannot be specified without specifying option '{1}'." }, - Option_0_cannot_be_specified_with_option_1: { code: 5053, category: ts.DiagnosticCategory.Error, key: "Option '{0}' cannot be specified with option '{1}'." }, - A_tsconfig_json_file_is_already_defined_at_Colon_0: { code: 5054, category: ts.DiagnosticCategory.Error, key: "A 'tsconfig.json' file is already defined at: '{0}'." }, - Concatenate_and_emit_output_to_single_file: { code: 6001, category: ts.DiagnosticCategory.Message, key: "Concatenate and emit output to single file." }, - Generates_corresponding_d_ts_file: { code: 6002, category: ts.DiagnosticCategory.Message, key: "Generates corresponding '.d.ts' file." }, - Specifies_the_location_where_debugger_should_locate_map_files_instead_of_generated_locations: { code: 6003, category: ts.DiagnosticCategory.Message, key: "Specifies the location where debugger should locate map files instead of generated locations." }, - Specifies_the_location_where_debugger_should_locate_TypeScript_files_instead_of_source_locations: { code: 6004, category: ts.DiagnosticCategory.Message, key: "Specifies the location where debugger should locate TypeScript files instead of source locations." }, - Watch_input_files: { code: 6005, category: ts.DiagnosticCategory.Message, key: "Watch input files." }, - Redirect_output_structure_to_the_directory: { code: 6006, category: ts.DiagnosticCategory.Message, key: "Redirect output structure to the directory." }, - Do_not_erase_const_enum_declarations_in_generated_code: { code: 6007, category: ts.DiagnosticCategory.Message, key: "Do not erase const enum declarations in generated code." }, - Do_not_emit_outputs_if_any_errors_were_reported: { code: 6008, category: ts.DiagnosticCategory.Message, key: "Do not emit outputs if any errors were reported." }, - Do_not_emit_comments_to_output: { code: 6009, category: ts.DiagnosticCategory.Message, key: "Do not emit comments to output." }, - Do_not_emit_outputs: { code: 6010, category: ts.DiagnosticCategory.Message, key: "Do not emit outputs." }, - Specify_ECMAScript_target_version_Colon_ES3_default_ES5_or_ES2015_experimental: { code: 6015, category: ts.DiagnosticCategory.Message, key: "Specify ECMAScript target version: 'ES3' (default), 'ES5', or 'ES2015' (experimental)" }, - Specify_module_code_generation_Colon_commonjs_amd_system_umd_or_es2015: { code: 6016, category: ts.DiagnosticCategory.Message, key: "Specify module code generation: 'commonjs', 'amd', 'system', 'umd' or 'es2015'" }, - Print_this_message: { code: 6017, category: ts.DiagnosticCategory.Message, key: "Print this message." }, - Print_the_compiler_s_version: { code: 6019, category: ts.DiagnosticCategory.Message, key: "Print the compiler's version." }, - Compile_the_project_in_the_given_directory: { code: 6020, category: ts.DiagnosticCategory.Message, key: "Compile the project in the given directory." }, - Syntax_Colon_0: { code: 6023, category: ts.DiagnosticCategory.Message, key: "Syntax: {0}" }, - options: { code: 6024, category: ts.DiagnosticCategory.Message, key: "options" }, - file: { code: 6025, category: ts.DiagnosticCategory.Message, key: "file" }, - Examples_Colon_0: { code: 6026, category: ts.DiagnosticCategory.Message, key: "Examples: {0}" }, - Options_Colon: { code: 6027, category: ts.DiagnosticCategory.Message, key: "Options:" }, - Version_0: { code: 6029, category: ts.DiagnosticCategory.Message, key: "Version {0}" }, - Insert_command_line_options_and_files_from_a_file: { code: 6030, category: ts.DiagnosticCategory.Message, key: "Insert command line options and files from a file." }, - File_change_detected_Starting_incremental_compilation: { code: 6032, category: ts.DiagnosticCategory.Message, key: "File change detected. Starting incremental compilation..." }, - KIND: { code: 6034, category: ts.DiagnosticCategory.Message, key: "KIND" }, - FILE: { code: 6035, category: ts.DiagnosticCategory.Message, key: "FILE" }, - VERSION: { code: 6036, category: ts.DiagnosticCategory.Message, key: "VERSION" }, - LOCATION: { code: 6037, category: ts.DiagnosticCategory.Message, key: "LOCATION" }, - DIRECTORY: { code: 6038, category: ts.DiagnosticCategory.Message, key: "DIRECTORY" }, - Compilation_complete_Watching_for_file_changes: { code: 6042, category: ts.DiagnosticCategory.Message, key: "Compilation complete. Watching for file changes." }, - Generates_corresponding_map_file: { code: 6043, category: ts.DiagnosticCategory.Message, key: "Generates corresponding '.map' file." }, - Compiler_option_0_expects_an_argument: { code: 6044, category: ts.DiagnosticCategory.Error, key: "Compiler option '{0}' expects an argument." }, - Unterminated_quoted_string_in_response_file_0: { code: 6045, category: ts.DiagnosticCategory.Error, key: "Unterminated quoted string in response file '{0}'." }, - Argument_for_module_option_must_be_commonjs_amd_system_umd_or_es2015: { code: 6046, category: ts.DiagnosticCategory.Error, key: "Argument for '--module' option must be 'commonjs', 'amd', 'system', 'umd', or 'es2015'." }, - Argument_for_target_option_must_be_ES3_ES5_or_ES2015: { code: 6047, category: ts.DiagnosticCategory.Error, key: "Argument for '--target' option must be 'ES3', 'ES5', or 'ES2015'." }, - Locale_must_be_of_the_form_language_or_language_territory_For_example_0_or_1: { code: 6048, category: ts.DiagnosticCategory.Error, key: "Locale must be of the form or -. For example '{0}' or '{1}'." }, - Unsupported_locale_0: { code: 6049, category: ts.DiagnosticCategory.Error, key: "Unsupported locale '{0}'." }, - Unable_to_open_file_0: { code: 6050, category: ts.DiagnosticCategory.Error, key: "Unable to open file '{0}'." }, - Corrupted_locale_file_0: { code: 6051, category: ts.DiagnosticCategory.Error, key: "Corrupted locale file {0}." }, - Raise_error_on_expressions_and_declarations_with_an_implied_any_type: { code: 6052, category: ts.DiagnosticCategory.Message, key: "Raise error on expressions and declarations with an implied 'any' type." }, - File_0_not_found: { code: 6053, category: ts.DiagnosticCategory.Error, key: "File '{0}' not found." }, - File_0_has_unsupported_extension_The_only_supported_extensions_are_1: { code: 6054, category: ts.DiagnosticCategory.Error, key: "File '{0}' has unsupported extension. The only supported extensions are {1}." }, - Suppress_noImplicitAny_errors_for_indexing_objects_lacking_index_signatures: { code: 6055, category: ts.DiagnosticCategory.Message, key: "Suppress noImplicitAny errors for indexing objects lacking index signatures." }, - Do_not_emit_declarations_for_code_that_has_an_internal_annotation: { code: 6056, category: ts.DiagnosticCategory.Message, key: "Do not emit declarations for code that has an '@internal' annotation." }, - Specifies_the_root_directory_of_input_files_Use_to_control_the_output_directory_structure_with_outDir: { code: 6058, category: ts.DiagnosticCategory.Message, key: "Specifies the root directory of input files. Use to control the output directory structure with --outDir." }, - File_0_is_not_under_rootDir_1_rootDir_is_expected_to_contain_all_source_files: { code: 6059, category: ts.DiagnosticCategory.Error, key: "File '{0}' is not under 'rootDir' '{1}'. 'rootDir' is expected to contain all source files." }, - Specifies_the_end_of_line_sequence_to_be_used_when_emitting_files_Colon_CRLF_dos_or_LF_unix: { code: 6060, category: ts.DiagnosticCategory.Message, key: "Specifies the end of line sequence to be used when emitting files: 'CRLF' (dos) or 'LF' (unix)." }, - NEWLINE: { code: 6061, category: ts.DiagnosticCategory.Message, key: "NEWLINE" }, - Argument_for_newLine_option_must_be_CRLF_or_LF: { code: 6062, category: ts.DiagnosticCategory.Error, key: "Argument for '--newLine' option must be 'CRLF' or 'LF'." }, - Argument_for_moduleResolution_option_must_be_node_or_classic: { code: 6063, category: ts.DiagnosticCategory.Error, key: "Argument for '--moduleResolution' option must be 'node' or 'classic'." }, - Specify_JSX_code_generation_Colon_preserve_or_react: { code: 6080, category: ts.DiagnosticCategory.Message, key: "Specify JSX code generation: 'preserve' or 'react'" }, - Argument_for_jsx_must_be_preserve_or_react: { code: 6081, category: ts.DiagnosticCategory.Message, key: "Argument for '--jsx' must be 'preserve' or 'react'." }, - Enables_experimental_support_for_ES7_decorators: { code: 6065, category: ts.DiagnosticCategory.Message, key: "Enables experimental support for ES7 decorators." }, - Enables_experimental_support_for_emitting_type_metadata_for_decorators: { code: 6066, category: ts.DiagnosticCategory.Message, key: "Enables experimental support for emitting type metadata for decorators." }, - Enables_experimental_support_for_ES7_async_functions: { code: 6068, category: ts.DiagnosticCategory.Message, key: "Enables experimental support for ES7 async functions." }, - Specifies_module_resolution_strategy_Colon_node_Node_js_or_classic_TypeScript_pre_1_6: { code: 6069, category: ts.DiagnosticCategory.Message, key: "Specifies module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6)." }, - Initializes_a_TypeScript_project_and_creates_a_tsconfig_json_file: { code: 6070, category: ts.DiagnosticCategory.Message, key: "Initializes a TypeScript project and creates a tsconfig.json file." }, - Successfully_created_a_tsconfig_json_file: { code: 6071, category: ts.DiagnosticCategory.Message, key: "Successfully created a tsconfig.json file." }, - Suppress_excess_property_checks_for_object_literals: { code: 6072, category: ts.DiagnosticCategory.Message, key: "Suppress excess property checks for object literals." }, - Variable_0_implicitly_has_an_1_type: { code: 7005, category: ts.DiagnosticCategory.Error, key: "Variable '{0}' implicitly has an '{1}' type." }, - Parameter_0_implicitly_has_an_1_type: { code: 7006, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' implicitly has an '{1}' type." }, - Member_0_implicitly_has_an_1_type: { code: 7008, category: ts.DiagnosticCategory.Error, key: "Member '{0}' implicitly has an '{1}' type." }, - new_expression_whose_target_lacks_a_construct_signature_implicitly_has_an_any_type: { code: 7009, category: ts.DiagnosticCategory.Error, key: "'new' expression, whose target lacks a construct signature, implicitly has an 'any' type." }, - _0_which_lacks_return_type_annotation_implicitly_has_an_1_return_type: { code: 7010, category: ts.DiagnosticCategory.Error, key: "'{0}', which lacks return-type annotation, implicitly has an '{1}' return type." }, - Function_expression_which_lacks_return_type_annotation_implicitly_has_an_0_return_type: { code: 7011, category: ts.DiagnosticCategory.Error, key: "Function expression, which lacks return-type annotation, implicitly has an '{0}' return type." }, - Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type: { code: 7013, category: ts.DiagnosticCategory.Error, key: "Construct signature, which lacks return-type annotation, implicitly has an 'any' return type." }, - Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_type_annotation: { code: 7016, category: ts.DiagnosticCategory.Error, key: "Property '{0}' implicitly has type 'any', because its 'set' accessor lacks a type annotation." }, - Index_signature_of_object_type_implicitly_has_an_any_type: { code: 7017, category: ts.DiagnosticCategory.Error, key: "Index signature of object type implicitly has an 'any' type." }, - Object_literal_s_property_0_implicitly_has_an_1_type: { code: 7018, category: ts.DiagnosticCategory.Error, key: "Object literal's property '{0}' implicitly has an '{1}' type." }, - Rest_parameter_0_implicitly_has_an_any_type: { code: 7019, category: ts.DiagnosticCategory.Error, key: "Rest parameter '{0}' implicitly has an 'any[]' type." }, - Call_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type: { code: 7020, category: ts.DiagnosticCategory.Error, key: "Call signature, which lacks return-type annotation, implicitly has an 'any' return type." }, - _0_implicitly_has_type_any_because_it_does_not_have_a_type_annotation_and_is_referenced_directly_or_indirectly_in_its_own_initializer: { code: 7022, category: ts.DiagnosticCategory.Error, key: "'{0}' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer." }, - _0_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions: { code: 7023, category: ts.DiagnosticCategory.Error, key: "'{0}' implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions." }, - Function_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions: { code: 7024, category: ts.DiagnosticCategory.Error, key: "Function implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions." }, - Generator_implicitly_has_type_0_because_it_does_not_yield_any_values_Consider_supplying_a_return_type: { code: 7025, category: ts.DiagnosticCategory.Error, key: "Generator implicitly has type '{0}' because it does not yield any values. Consider supplying a return type." }, - JSX_element_implicitly_has_type_any_because_no_interface_JSX_0_exists: { code: 7026, category: ts.DiagnosticCategory.Error, key: "JSX element implicitly has type 'any' because no interface 'JSX.{0}' exists" }, - You_cannot_rename_this_element: { code: 8000, category: ts.DiagnosticCategory.Error, key: "You cannot rename this element." }, - You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library: { code: 8001, category: ts.DiagnosticCategory.Error, key: "You cannot rename elements that are defined in the standard TypeScript library." }, - 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." }, - export_can_only_be_used_in_a_ts_file: { code: 8003, category: ts.DiagnosticCategory.Error, key: "'export=' can only be used in a .ts file." }, - type_parameter_declarations_can_only_be_used_in_a_ts_file: { code: 8004, category: ts.DiagnosticCategory.Error, key: "'type parameter declarations' can only be used in a .ts file." }, - implements_clauses_can_only_be_used_in_a_ts_file: { code: 8005, category: ts.DiagnosticCategory.Error, key: "'implements clauses' can only be used in a .ts file." }, - interface_declarations_can_only_be_used_in_a_ts_file: { code: 8006, category: ts.DiagnosticCategory.Error, key: "'interface declarations' can only be used in a .ts file." }, - module_declarations_can_only_be_used_in_a_ts_file: { code: 8007, category: ts.DiagnosticCategory.Error, key: "'module declarations' can only be used in a .ts file." }, - type_aliases_can_only_be_used_in_a_ts_file: { code: 8008, category: ts.DiagnosticCategory.Error, key: "'type aliases' can only be used in a .ts file." }, - _0_can_only_be_used_in_a_ts_file: { code: 8009, category: ts.DiagnosticCategory.Error, key: "'{0}' can only be used in a .ts file." }, - types_can_only_be_used_in_a_ts_file: { code: 8010, category: ts.DiagnosticCategory.Error, key: "'types' can only be used in a .ts file." }, - type_arguments_can_only_be_used_in_a_ts_file: { code: 8011, category: ts.DiagnosticCategory.Error, key: "'type arguments' can only be used in a .ts file." }, - parameter_modifiers_can_only_be_used_in_a_ts_file: { code: 8012, category: ts.DiagnosticCategory.Error, key: "'parameter modifiers' can only be used in a .ts file." }, - property_declarations_can_only_be_used_in_a_ts_file: { code: 8014, category: ts.DiagnosticCategory.Error, key: "'property declarations' can only be used in a .ts file." }, - enum_declarations_can_only_be_used_in_a_ts_file: { code: 8015, category: ts.DiagnosticCategory.Error, key: "'enum declarations' can only be used in a .ts file." }, - type_assertion_expressions_can_only_be_used_in_a_ts_file: { code: 8016, category: ts.DiagnosticCategory.Error, key: "'type assertion expressions' can only be used in a .ts file." }, - decorators_can_only_be_used_in_a_ts_file: { code: 8017, category: ts.DiagnosticCategory.Error, key: "'decorators' can only be used in a .ts file." }, - Only_identifiers_Slashqualified_names_with_optional_type_arguments_are_currently_supported_in_a_class_extends_clauses: { code: 9002, category: ts.DiagnosticCategory.Error, key: "Only identifiers/qualified-names with optional type arguments are currently supported in a class 'extends' clauses." }, - class_expressions_are_not_currently_supported: { code: 9003, category: ts.DiagnosticCategory.Error, key: "'class' expressions are not currently supported." }, - JSX_attributes_must_only_be_assigned_a_non_empty_expression: { code: 17000, category: ts.DiagnosticCategory.Error, key: "JSX attributes must only be assigned a non-empty 'expression'." }, - JSX_elements_cannot_have_multiple_attributes_with_the_same_name: { code: 17001, category: ts.DiagnosticCategory.Error, key: "JSX elements cannot have multiple attributes with the same name." }, - Expected_corresponding_JSX_closing_tag_for_0: { code: 17002, category: ts.DiagnosticCategory.Error, key: "Expected corresponding JSX closing tag for '{0}'." }, - JSX_attribute_expected: { code: 17003, category: ts.DiagnosticCategory.Error, key: "JSX attribute expected." }, - Cannot_use_JSX_unless_the_jsx_flag_is_provided: { code: 17004, category: ts.DiagnosticCategory.Error, key: "Cannot use JSX unless the '--jsx' flag is provided." }, - A_constructor_cannot_contain_a_super_call_when_its_class_extends_null: { code: 17005, category: ts.DiagnosticCategory.Error, key: "A constructor cannot contain a 'super' call when its class extends 'null'" }, - An_unary_expression_with_the_0_operator_is_not_allowed_in_the_left_hand_side_of_an_exponentiation_expression_Consider_enclosing_the_expression_in_parentheses: { code: 17006, category: ts.DiagnosticCategory.Error, key: "An unary expression with the '{0}' operator is not allowed in the left-hand side of an exponentiation expression. Consider enclosing the expression in parentheses." }, - A_type_assertion_expression_is_not_allowed_in_the_left_hand_side_of_an_exponentiation_expression_Consider_enclosing_the_expression_in_parentheses: { code: 17007, category: ts.DiagnosticCategory.Error, key: "A type assertion expression is not allowed in the left-hand side of an exponentiation expression. Consider enclosing the expression in parentheses." } - }; -})(ts || (ts = {})); -var ts; -(function (ts) { - function tokenIsIdentifierOrKeyword(token) { - return token >= 69; - } - ts.tokenIsIdentifierOrKeyword = tokenIsIdentifierOrKeyword; - var textToToken = { - "abstract": 115, - "any": 117, - "as": 116, - "boolean": 120, - "break": 70, - "case": 71, - "catch": 72, - "class": 73, - "continue": 75, - "const": 74, - "constructor": 121, - "debugger": 76, - "declare": 122, - "default": 77, - "delete": 78, - "do": 79, - "else": 80, - "enum": 81, - "export": 82, - "extends": 83, - "false": 84, - "finally": 85, - "for": 86, - "from": 133, - "function": 87, - "get": 123, - "if": 88, - "implements": 106, - "import": 89, - "in": 90, - "instanceof": 91, - "interface": 107, - "is": 124, - "let": 108, - "module": 125, - "namespace": 126, - "new": 92, - "null": 93, - "number": 128, - "package": 109, - "private": 110, - "protected": 111, - "public": 112, - "require": 127, - "return": 94, - "set": 129, - "static": 113, - "string": 130, - "super": 95, - "switch": 96, - "symbol": 131, - "this": 97, - "throw": 98, - "true": 99, - "try": 100, - "type": 132, - "typeof": 101, - "var": 102, - "void": 103, - "while": 104, - "with": 105, - "yield": 114, - "async": 118, - "await": 119, - "of": 134, - "{": 15, - "}": 16, - "(": 17, - ")": 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) { - if (source.hasOwnProperty(name_4)) { - 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++); - 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 ch === 32 || - ch === 9 || - ch === 11 || - ch === 12 || - ch === 160 || - ch === 133 || - ch === 5760 || - ch >= 8192 && ch <= 8203 || - ch === 8239 || - ch === 8287 || - ch === 12288 || - ch === 65279; - } - ts.isWhiteSpace = isWhiteSpace; - function isLineBreak(ch) { - return ch === 10 || - ch === 13 || - ch === 8232 || - ch === 8233; - } - 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) { - 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 (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) || isLineBreak(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 getCommentRanges(text, pos, trailing) { - var result; - var collecting = trailing || pos === 0; - while (true) { - var ch = text.charCodeAt(pos); - switch (ch) { - case 13: - if (text.charCodeAt(pos + 1) === 10) { - pos++; - } - case 10: - pos++; - if (trailing) { - return result; - } - collecting = true; - if (result && result.length) { - ts.lastOrUndefined(result).hasTrailingNewLine = 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 (!result) { - result = []; - } - result.push({ pos: startPos, end: pos, hasTrailingNewLine: hasTrailingNewLine, kind: kind }); - } - continue; - } - break; - default: - if (ch > 127 && (isWhiteSpace(ch) || isLineBreak(ch))) { - if (result && result.length && isLineBreak(ch)) { - ts.lastOrUndefined(result).hasTrailingNewLine = true; - } - pos++; - continue; - } - break; - } - return result; - } - } - function getLeadingCommentRanges(text, pos) { - return getCommentRanges(text, pos, false); - } - ts.getLeadingCommentRanges = getLeadingCommentRanges; - function getTrailingCommentRanges(text, pos) { - return getCommentRanges(text, pos, true); - } - 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 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, - reScanJsxToken: reScanJsxToken, - scanJsxToken: scanJsxToken, - scan: scan, - setText: setText, - setScriptTarget: setScriptTarget, - setLanguageVariant: setLanguageVariant, - setOnError: setOnError, - setTextPos: setTextPos, - tryScan: tryScan, - lookAhead: lookAhead - }; - 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() { - var quote = text.charCodeAt(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) { - 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++); - 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 && isWhiteSpace(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; - } - return pos++, 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; - } - return pos++, 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; - } - return pos++, token = 46; - case 40: - return pos++, token = 17; - case 41: - return pos++, token = 18; - case 42: - if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 59; - } - if (text.charCodeAt(pos + 1) === 42) { - if (text.charCodeAt(pos + 2) === 61) { - return pos += 3, token = 60; - } - return pos += 2, token = 38; - } - return pos++, token = 37; - case 43: - if (text.charCodeAt(pos + 1) === 43) { - return pos += 2, token = 41; - } - if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 57; - } - return pos++, token = 35; - case 44: - return pos++, token = 24; - case 45: - if (text.charCodeAt(pos + 1) === 45) { - return pos += 2, token = 42; - } - if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 58; - } - return pos++, 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; - } - return pos++, 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; - } - return pos++, 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: - return pos++, token = 54; - case 59: - return pos++, 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; - } - return pos++, 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; - } - return pos++, token = 56; - case 62: - if (isConflictMarkerTrivia(text, pos)) { - pos = scanConflictMarkerTrivia(text, pos, error); - if (skipTrivia) { - continue; - } - else { - return token = 7; - } - } - return pos++, token = 27; - case 63: - return pos++, token = 53; - case 91: - return pos++, token = 19; - case 93: - return pos++, token = 20; - case 94: - if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 68; - } - return pos++, token = 48; - case 123: - return pos++, 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; - } - return pos++, token = 47; - case 125: - return pos++, token = 16; - case 126: - return pos++, token = 50; - case 64: - return pos++, 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); - return pos++, 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 (isWhiteSpace(ch)) { - pos++; - continue; - } - else if (isLineBreak(ch)) { - precedingLineBreak = true; - pos++; - continue; - } - error(ts.Diagnostics.Invalid_character); - return pos++, 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; - } - return pos++, token = 44; - } - if (text.charCodeAt(pos) === 61) { - return pos++, 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 = 236; - } - 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 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 lookAhead(callback) { - return speculationHelper(callback, true); - } - function tryScan(callback) { - return speculationHelper(callback, false); - } - 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.bindTime = 0; - function getModuleInstanceState(node) { - if (node.kind === 215 || node.kind === 216) { - return 0; - } - else if (ts.isConstEnumDeclaration(node)) { - return 2; - } - else if ((node.kind === 222 || node.kind === 221) && !(node.flags & 1)) { - return 0; - } - else if (node.kind === 219) { - var state = 0; - ts.forEachChild(node, function (n) { - switch (getModuleInstanceState(n)) { - case 0: - return false; - case 2: - state = 2; - return false; - case 1: - state = 1; - return true; - } - }); - return state; - } - else if (node.kind === 218) { - return getModuleInstanceState(node.body); - } - else { - return 1; - } - } - ts.getModuleInstanceState = getModuleInstanceState; - function bindSourceFile(file) { - var start = new Date().getTime(); - bindSourceFileWorker(file); - ts.bindTime += new Date().getTime() - start; - } - ts.bindSourceFile = bindSourceFile; - function bindSourceFileWorker(file) { - var parent; - var container; - var blockScopeContainer; - var lastContainer; - var seenThisKeyword; - var inStrictMode = !!file.externalModuleIndicator; - var symbolCount = 0; - var Symbol = ts.objectAllocator.getSymbolConstructor(); - var classifiableNames = {}; - if (!file.locals) { - bind(file); - file.symbolCount = symbolCount; - file.classifiableNames = classifiableNames; - } - return; - function createSymbol(flags, name) { - symbolCount++; - return new Symbol(flags, name); - } - function addDeclarationToSymbol(symbol, node, symbolFlags) { - symbol.flags |= symbolFlags; - node.symbol = symbol; - if (!symbol.declarations) { - symbol.declarations = []; - } - symbol.declarations.push(node); - if (symbolFlags & 1952 && !symbol.exports) { - symbol.exports = {}; - } - if (symbolFlags & 6240 && !symbol.members) { - symbol.members = {}; - } - if (symbolFlags & 107455 && !symbol.valueDeclaration) { - symbol.valueDeclaration = node; - } - } - function getDeclarationName(node) { - if (node.name) { - if (node.kind === 218 && node.name.kind === 9) { - return "\"" + node.name.text + "\""; - } - if (node.name.kind === 136) { - var nameExpression = node.name.expression; - ts.Debug.assert(ts.isWellKnownSymbolSyntactically(nameExpression)); - return ts.getPropertyNameForKnownSymbolName(nameExpression.name.text); - } - return node.name.text; - } - switch (node.kind) { - case 144: - return "__constructor"; - case 152: - case 147: - return "__call"; - case 153: - case 148: - return "__new"; - case 149: - return "__index"; - case 228: - return "__export"; - case 227: - return node.isExportEquals ? "export=" : "default"; - case 213: - case 214: - return node.flags & 1024 ? "default" : undefined; - } - } - function getDisplayName(node) { - return node.name ? ts.declarationNameToString(node.name) : getDeclarationName(node); - } - function declareSymbol(symbolTable, parent, node, includes, excludes) { - ts.Debug.assert(!ts.hasDynamicName(node)); - var isDefaultExport = node.flags & 1024; - var name = isDefaultExport && parent ? "default" : getDeclarationName(node); - var symbol; - if (name !== undefined) { - symbol = ts.hasProperty(symbolTable, name) - ? symbolTable[name] - : (symbolTable[name] = createSymbol(0, name)); - if (name && (includes & 788448)) { - classifiableNames[name] = name; - } - if (symbol.flags & excludes) { - if (node.name) { - node.name.parent = node; - } - var message = symbol.flags & 2 - ? ts.Diagnostics.Cannot_redeclare_block_scoped_variable_0 - : ts.Diagnostics.Duplicate_identifier_0; - ts.forEach(symbol.declarations, function (declaration) { - if (declaration.flags & 1024) { - message = ts.Diagnostics.A_module_cannot_have_multiple_default_exports; - } - }); - ts.forEach(symbol.declarations, function (declaration) { - file.bindDiagnostics.push(ts.createDiagnosticForNode(declaration.name || declaration, message, getDisplayName(declaration))); - }); - file.bindDiagnostics.push(ts.createDiagnosticForNode(node.name || node, message, getDisplayName(node))); - symbol = createSymbol(0, name); - } - } - else { - symbol = createSymbol(0, "__missing"); - } - addDeclarationToSymbol(symbol, node, includes); - symbol.parent = parent; - return symbol; - } - function declareModuleMember(node, symbolFlags, symbolExcludes) { - var hasExportModifier = ts.getCombinedNodeFlags(node) & 1; - if (symbolFlags & 8388608) { - if (node.kind === 230 || (node.kind === 221 && hasExportModifier)) { - return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); - } - else { - return declareSymbol(container.locals, undefined, node, symbolFlags, symbolExcludes); - } - } - else { - if (hasExportModifier || container.flags & 262144) { - var exportKind = (symbolFlags & 107455 ? 1048576 : 0) | - (symbolFlags & 793056 ? 2097152 : 0) | - (symbolFlags & 1536 ? 4194304 : 0); - var 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); - } - } - } - function bindChildren(node) { - var saveParent = parent; - var saveContainer = container; - var savedBlockScopeContainer = blockScopeContainer; - parent = node; - var containerFlags = getContainerFlags(node); - if (containerFlags & 1) { - container = blockScopeContainer = node; - if (containerFlags & 4) { - container.locals = {}; - } - addToContainerChain(container); - } - else if (containerFlags & 2) { - blockScopeContainer = node; - blockScopeContainer.locals = undefined; - } - if (node.kind === 215) { - seenThisKeyword = false; - ts.forEachChild(node, bind); - node.flags = seenThisKeyword ? node.flags | 524288 : node.flags & ~524288; - } - else { - ts.forEachChild(node, bind); - } - container = saveContainer; - parent = saveParent; - blockScopeContainer = savedBlockScopeContainer; - } - function getContainerFlags(node) { - switch (node.kind) { - case 186: - case 214: - case 215: - case 217: - case 155: - case 165: - return 1; - case 147: - case 148: - case 149: - case 143: - case 142: - case 213: - case 144: - case 145: - case 146: - case 152: - case 153: - case 173: - case 174: - case 218: - case 248: - case 216: - return 5; - case 244: - case 199: - case 200: - case 201: - case 220: - return 2; - case 192: - return ts.isFunctionLike(node.parent) ? 0 : 2; - } - return 0; - } - function addToContainerChain(next) { - if (lastContainer) { - lastContainer.nextContainer = next; - } - lastContainer = next; - } - function declareSymbolAndAddToSymbolTable(node, symbolFlags, symbolExcludes) { - declareSymbolAndAddToSymbolTableWorker(node, symbolFlags, symbolExcludes); - } - function declareSymbolAndAddToSymbolTableWorker(node, symbolFlags, symbolExcludes) { - switch (container.kind) { - case 218: - return declareModuleMember(node, symbolFlags, symbolExcludes); - case 248: - return declareSourceFileMember(node, symbolFlags, symbolExcludes); - case 186: - case 214: - return declareClassMember(node, symbolFlags, symbolExcludes); - case 217: - return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); - case 155: - case 165: - case 215: - return declareSymbol(container.symbol.members, container.symbol, node, symbolFlags, symbolExcludes); - case 152: - case 153: - case 147: - case 148: - case 149: - case 143: - case 142: - case 144: - case 145: - case 146: - case 213: - case 173: - case 174: - case 216: - return declareSymbol(container.locals, undefined, node, symbolFlags, symbolExcludes); - } - } - function declareClassMember(node, symbolFlags, symbolExcludes) { - return node.flags & 128 - ? declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes) - : declareSymbol(container.symbol.members, container.symbol, node, symbolFlags, symbolExcludes); - } - function declareSourceFileMember(node, symbolFlags, symbolExcludes) { - return ts.isExternalModule(file) - ? declareModuleMember(node, symbolFlags, symbolExcludes) - : declareSymbol(file.locals, undefined, node, symbolFlags, symbolExcludes); - } - function isAmbientContext(node) { - while (node) { - if (node.flags & 2) { - return true; - } - node = node.parent; - } - return false; - } - function hasExportDeclarations(node) { - var body = node.kind === 248 ? node : node.body; - if (body.kind === 248 || body.kind === 219) { - for (var _i = 0, _a = body.statements; _i < _a.length; _i++) { - var stat = _a[_i]; - if (stat.kind === 228 || stat.kind === 227) { - return true; - } - } - } - return false; - } - function setExportContextFlag(node) { - if (isAmbientContext(node) && !hasExportDeclarations(node)) { - node.flags |= 262144; - } - else { - node.flags &= ~262144; - } - } - function bindModuleDeclaration(node) { - setExportContextFlag(node); - if (node.name.kind === 9) { - declareSymbolAndAddToSymbolTable(node, 512, 106639); - } - else { - var state = getModuleInstanceState(node); - if (state === 0) { - declareSymbolAndAddToSymbolTable(node, 1024, 0); - } - else { - declareSymbolAndAddToSymbolTable(node, 512, 106639); - if (node.symbol.flags & (16 | 32 | 256)) { - node.symbol.constEnumOnlyModule = false; - } - else { - var currentModuleIsConstEnumOnly = state === 2; - if (node.symbol.constEnumOnlyModule === undefined) { - node.symbol.constEnumOnlyModule = currentModuleIsConstEnumOnly; - } - else { - node.symbol.constEnumOnlyModule = node.symbol.constEnumOnlyModule && currentModuleIsConstEnumOnly; - } - } - } - } - } - function bindFunctionOrConstructorType(node) { - var symbol = createSymbol(131072, getDeclarationName(node)); - addDeclarationToSymbol(symbol, node, 131072); - var typeLiteralSymbol = createSymbol(2048, "__type"); - addDeclarationToSymbol(typeLiteralSymbol, node, 2048); - typeLiteralSymbol.members = (_a = {}, _a[symbol.name] = symbol, _a); - var _a; - } - function bindObjectLiteralExpression(node) { - if (inStrictMode) { - var seen = {}; - for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { - var prop = _a[_i]; - if (prop.name.kind !== 69) { - continue; - } - var identifier = prop.name; - var currentKind = prop.kind === 245 || prop.kind === 246 || prop.kind === 143 - ? 1 - : 2; - var existingKind = seen[identifier.text]; - if (!existingKind) { - seen[identifier.text] = currentKind; - continue; - } - if (currentKind === 1 && existingKind === 1) { - var span = ts.getErrorSpanForNode(file, identifier); - file.bindDiagnostics.push(ts.createFileDiagnostic(file, span.start, span.length, ts.Diagnostics.An_object_literal_cannot_have_multiple_properties_with_the_same_name_in_strict_mode)); - } - } - } - return bindAnonymousDeclaration(node, 4096, "__object"); - } - function bindAnonymousDeclaration(node, symbolFlags, name) { - var symbol = createSymbol(symbolFlags, name); - addDeclarationToSymbol(symbol, node, symbolFlags); - } - function bindBlockScopedDeclaration(node, symbolFlags, symbolExcludes) { - switch (blockScopeContainer.kind) { - case 218: - declareModuleMember(node, symbolFlags, symbolExcludes); - break; - case 248: - if (ts.isExternalModule(container)) { - declareModuleMember(node, symbolFlags, symbolExcludes); - break; - } - default: - if (!blockScopeContainer.locals) { - blockScopeContainer.locals = {}; - addToContainerChain(blockScopeContainer); - } - declareSymbol(blockScopeContainer.locals, undefined, node, symbolFlags, symbolExcludes); - } - } - function bindBlockScopedVariableDeclaration(node) { - bindBlockScopedDeclaration(node, 2, 107455); - } - function checkStrictModeIdentifier(node) { - if (inStrictMode && - node.originalKeywordKind >= 106 && - node.originalKeywordKind <= 114 && - !ts.isIdentifierName(node)) { - if (!file.parseDiagnostics.length) { - file.bindDiagnostics.push(ts.createDiagnosticForNode(node, getStrictModeIdentifierMessage(node), ts.declarationNameToString(node))); - } - } - } - function getStrictModeIdentifierMessage(node) { - if (ts.getContainingClass(node)) { - return ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_strict_mode; - } - if (file.externalModuleIndicator) { - return ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode_Modules_are_automatically_in_strict_mode; - } - return ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode; - } - function checkStrictModeBinaryExpression(node) { - if (inStrictMode && ts.isLeftHandSideExpression(node.left) && ts.isAssignmentOperator(node.operatorToken.kind)) { - checkStrictModeEvalOrArguments(node, node.left); - } - } - function checkStrictModeCatchClause(node) { - if (inStrictMode && node.variableDeclaration) { - checkStrictModeEvalOrArguments(node, node.variableDeclaration.name); - } - } - function checkStrictModeDeleteExpression(node) { - if (inStrictMode && node.expression.kind === 69) { - var span = ts.getErrorSpanForNode(file, node.expression); - file.bindDiagnostics.push(ts.createFileDiagnostic(file, span.start, span.length, ts.Diagnostics.delete_cannot_be_called_on_an_identifier_in_strict_mode)); - } - } - function isEvalOrArgumentsIdentifier(node) { - return node.kind === 69 && - (node.text === "eval" || node.text === "arguments"); - } - function checkStrictModeEvalOrArguments(contextNode, name) { - if (name && name.kind === 69) { - var identifier = name; - if (isEvalOrArgumentsIdentifier(identifier)) { - var span = ts.getErrorSpanForNode(file, name); - file.bindDiagnostics.push(ts.createFileDiagnostic(file, span.start, span.length, getStrictModeEvalOrArgumentsMessage(contextNode), identifier.text)); - } - } - } - function getStrictModeEvalOrArgumentsMessage(node) { - if (ts.getContainingClass(node)) { - return ts.Diagnostics.Invalid_use_of_0_Class_definitions_are_automatically_in_strict_mode; - } - if (file.externalModuleIndicator) { - return ts.Diagnostics.Invalid_use_of_0_Modules_are_automatically_in_strict_mode; - } - return ts.Diagnostics.Invalid_use_of_0_in_strict_mode; - } - function checkStrictModeFunctionName(node) { - if (inStrictMode) { - checkStrictModeEvalOrArguments(node, node.name); - } - } - function checkStrictModeNumericLiteral(node) { - if (inStrictMode && node.flags & 65536) { - file.bindDiagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.Octal_literals_are_not_allowed_in_strict_mode)); - } - } - function checkStrictModePostfixUnaryExpression(node) { - if (inStrictMode) { - checkStrictModeEvalOrArguments(node, node.operand); - } - } - function checkStrictModePrefixUnaryExpression(node) { - if (inStrictMode) { - if (node.operator === 41 || node.operator === 42) { - checkStrictModeEvalOrArguments(node, node.operand); - } - } - } - function checkStrictModeWithStatement(node) { - if (inStrictMode) { - grammarErrorOnFirstToken(node, ts.Diagnostics.with_statements_are_not_allowed_in_strict_mode); - } - } - function grammarErrorOnFirstToken(node, message, arg0, arg1, arg2) { - var span = ts.getSpanOfTokenAtPosition(file, node.pos); - file.bindDiagnostics.push(ts.createFileDiagnostic(file, span.start, span.length, message, arg0, arg1, arg2)); - } - function getDestructuringParameterName(node) { - return "__" + ts.indexOf(node.parent.parameters, node); - } - function bind(node) { - node.parent = parent; - var savedInStrictMode = inStrictMode; - if (!savedInStrictMode) { - updateStrictMode(node); - } - bindWorker(node); - bindChildren(node); - inStrictMode = savedInStrictMode; - } - function updateStrictMode(node) { - switch (node.kind) { - case 248: - case 219: - updateStrictModeStatementList(node.statements); - return; - case 192: - if (ts.isFunctionLike(node.parent)) { - updateStrictModeStatementList(node.statements); - } - return; - case 214: - case 186: - inStrictMode = true; - return; - } - } - function updateStrictModeStatementList(statements) { - for (var _i = 0; _i < statements.length; _i++) { - var statement = statements[_i]; - if (!ts.isPrologueDirective(statement)) { - return; - } - if (isUseStrictPrologueDirective(statement)) { - inStrictMode = true; - return; - } - } - } - function isUseStrictPrologueDirective(node) { - var nodeText = ts.getTextOfNodeFromSourceText(file.text, node.expression); - return nodeText === "\"use strict\"" || nodeText === "'use strict'"; - } - function bindWorker(node) { - switch (node.kind) { - case 69: - return checkStrictModeIdentifier(node); - case 181: - return checkStrictModeBinaryExpression(node); - case 244: - return checkStrictModeCatchClause(node); - case 175: - return checkStrictModeDeleteExpression(node); - case 8: - return checkStrictModeNumericLiteral(node); - case 180: - return checkStrictModePostfixUnaryExpression(node); - case 179: - return checkStrictModePrefixUnaryExpression(node); - case 205: - return checkStrictModeWithStatement(node); - case 97: - seenThisKeyword = true; - return; - case 137: - return declareSymbolAndAddToSymbolTable(node, 262144, 530912); - case 138: - return bindParameter(node); - case 211: - case 163: - return bindVariableDeclarationOrBindingElement(node); - case 141: - case 140: - return bindPropertyOrMethodOrAccessor(node, 4 | (node.questionToken ? 536870912 : 0), 107455); - case 245: - case 246: - return bindPropertyOrMethodOrAccessor(node, 4, 107455); - case 247: - return bindPropertyOrMethodOrAccessor(node, 8, 107455); - case 147: - case 148: - case 149: - return declareSymbolAndAddToSymbolTable(node, 131072, 0); - case 143: - case 142: - return bindPropertyOrMethodOrAccessor(node, 8192 | (node.questionToken ? 536870912 : 0), ts.isObjectLiteralMethod(node) ? 107455 : 99263); - case 213: - checkStrictModeFunctionName(node); - return declareSymbolAndAddToSymbolTable(node, 16, 106927); - case 144: - return declareSymbolAndAddToSymbolTable(node, 16384, 0); - case 145: - return bindPropertyOrMethodOrAccessor(node, 32768, 41919); - case 146: - return bindPropertyOrMethodOrAccessor(node, 65536, 74687); - case 152: - case 153: - return bindFunctionOrConstructorType(node); - case 155: - return bindAnonymousDeclaration(node, 2048, "__type"); - case 165: - return bindObjectLiteralExpression(node); - case 173: - case 174: - checkStrictModeFunctionName(node); - var bindingName = node.name ? node.name.text : "__function"; - return bindAnonymousDeclaration(node, 16, bindingName); - case 186: - case 214: - return bindClassLikeDeclaration(node); - case 215: - return bindBlockScopedDeclaration(node, 64, 792960); - case 216: - return bindBlockScopedDeclaration(node, 524288, 793056); - case 217: - return bindEnumDeclaration(node); - case 218: - return bindModuleDeclaration(node); - case 221: - case 224: - case 226: - case 230: - return declareSymbolAndAddToSymbolTable(node, 8388608, 8388608); - case 223: - return bindImportClause(node); - case 228: - return bindExportDeclaration(node); - case 227: - return bindExportAssignment(node); - case 248: - return bindSourceFileIfExternalModule(); - } - } - function bindSourceFileIfExternalModule() { - setExportContextFlag(file); - if (ts.isExternalModule(file)) { - bindAnonymousDeclaration(file, 512, "\"" + ts.removeFileExtension(file.fileName) + "\""); - } - } - function bindExportAssignment(node) { - if (!container.symbol || !container.symbol.exports) { - bindAnonymousDeclaration(node, 8388608, getDeclarationName(node)); - } - else if (node.expression.kind === 69) { - declareSymbol(container.symbol.exports, container.symbol, node, 8388608, 107455 | 8388608); - } - else { - declareSymbol(container.symbol.exports, container.symbol, node, 4, 107455 | 8388608); - } - } - function bindExportDeclaration(node) { - if (!container.symbol || !container.symbol.exports) { - bindAnonymousDeclaration(node, 1073741824, getDeclarationName(node)); - } - else if (!node.exportClause) { - declareSymbol(container.symbol.exports, container.symbol, node, 1073741824, 0); - } - } - function bindImportClause(node) { - if (node.name) { - declareSymbolAndAddToSymbolTable(node, 8388608, 8388608); - } - } - function bindClassLikeDeclaration(node) { - if (node.kind === 214) { - bindBlockScopedDeclaration(node, 32, 899519); - } - else { - var bindingName = node.name ? node.name.text : "__class"; - bindAnonymousDeclaration(node, 32, bindingName); - if (node.name) { - classifiableNames[node.name.text] = node.name.text; - } - } - var symbol = node.symbol; - var prototypeSymbol = createSymbol(4 | 134217728, "prototype"); - if (ts.hasProperty(symbol.exports, prototypeSymbol.name)) { - if (node.name) { - node.name.parent = node; - } - file.bindDiagnostics.push(ts.createDiagnosticForNode(symbol.exports[prototypeSymbol.name].declarations[0], ts.Diagnostics.Duplicate_identifier_0, prototypeSymbol.name)); - } - symbol.exports[prototypeSymbol.name] = prototypeSymbol; - prototypeSymbol.parent = symbol; - } - function bindEnumDeclaration(node) { - return ts.isConst(node) - ? bindBlockScopedDeclaration(node, 128, 899967) - : bindBlockScopedDeclaration(node, 256, 899327); - } - function bindVariableDeclarationOrBindingElement(node) { - if (inStrictMode) { - checkStrictModeEvalOrArguments(node, node.name); - } - if (!ts.isBindingPattern(node.name)) { - if (ts.isBlockOrCatchScoped(node)) { - bindBlockScopedVariableDeclaration(node); - } - else if (ts.isParameterDeclaration(node)) { - declareSymbolAndAddToSymbolTable(node, 1, 107455); - } - else { - declareSymbolAndAddToSymbolTable(node, 1, 107454); - } - } - } - function bindParameter(node) { - if (inStrictMode) { - checkStrictModeEvalOrArguments(node, node.name); - } - if (ts.isBindingPattern(node.name)) { - bindAnonymousDeclaration(node, 1, getDestructuringParameterName(node)); - } - else { - declareSymbolAndAddToSymbolTable(node, 1, 107455); - } - if (node.flags & 112 && - node.parent.kind === 144 && - ts.isClassLike(node.parent.parent)) { - var classDeclaration = node.parent.parent; - declareSymbol(classDeclaration.symbol.members, classDeclaration.symbol, node, 4, 107455); - } - } - function bindPropertyOrMethodOrAccessor(node, symbolFlags, symbolExcludes) { - return ts.hasDynamicName(node) - ? bindAnonymousDeclaration(node, symbolFlags, "__computed") - : declareSymbolAndAddToSymbolTable(node, symbolFlags, symbolExcludes); - } - } -})(ts || (ts = {})); -var ts; -(function (ts) { - function getDeclarationOfKind(symbol, kind) { - var declarations = symbol.declarations; - if (declarations) { - for (var _i = 0; _i < declarations.length; _i++) { - var declaration = declarations[_i]; - if (declaration.kind === kind) { - return declaration; - } - } - } - return undefined; - } - ts.getDeclarationOfKind = getDeclarationOfKind; - var stringWriters = []; - function getSingleLineStringWriter() { - if (stringWriters.length === 0) { - var str = ""; - var writeText = function (text) { return str += text; }; - return { - string: function () { return str; }, - writeKeyword: writeText, - writeOperator: writeText, - writePunctuation: writeText, - writeSpace: writeText, - writeStringLiteral: writeText, - writeParameter: writeText, - writeSymbol: writeText, - writeLine: function () { return str += " "; }, - increaseIndent: function () { }, - decreaseIndent: function () { }, - clear: function () { return str = ""; }, - trackSymbol: function () { }, - reportInaccessibleThisError: function () { } - }; - } - return stringWriters.pop(); - } - ts.getSingleLineStringWriter = getSingleLineStringWriter; - function releaseStringWriter(writer) { - writer.clear(); - stringWriters.push(writer); - } - ts.releaseStringWriter = releaseStringWriter; - function getFullWidth(node) { - return node.end - node.pos; - } - ts.getFullWidth = getFullWidth; - function arrayIsEqualTo(array1, array2, equaler) { - if (!array1 || !array2) { - return array1 === array2; - } - if (array1.length !== array2.length) { - return false; - } - for (var i = 0; i < array1.length; ++i) { - var equals = equaler ? equaler(array1[i], array2[i]) : array1[i] === array2[i]; - if (!equals) { - return false; - } - } - return true; - } - ts.arrayIsEqualTo = arrayIsEqualTo; - function hasResolvedModule(sourceFile, moduleNameText) { - return sourceFile.resolvedModules && ts.hasProperty(sourceFile.resolvedModules, moduleNameText); - } - ts.hasResolvedModule = hasResolvedModule; - function getResolvedModule(sourceFile, moduleNameText) { - return hasResolvedModule(sourceFile, moduleNameText) ? sourceFile.resolvedModules[moduleNameText] : undefined; - } - ts.getResolvedModule = getResolvedModule; - function setResolvedModule(sourceFile, moduleNameText, resolvedModule) { - if (!sourceFile.resolvedModules) { - sourceFile.resolvedModules = {}; - } - sourceFile.resolvedModules[moduleNameText] = resolvedModule; - } - ts.setResolvedModule = setResolvedModule; - function containsParseError(node) { - aggregateChildData(node); - return (node.parserContextFlags & 64) !== 0; - } - ts.containsParseError = containsParseError; - function aggregateChildData(node) { - if (!(node.parserContextFlags & 128)) { - var thisNodeOrAnySubNodesHasError = ((node.parserContextFlags & 16) !== 0) || - ts.forEachChild(node, containsParseError); - if (thisNodeOrAnySubNodesHasError) { - node.parserContextFlags |= 64; - } - node.parserContextFlags |= 128; - } - } - function getSourceFileOfNode(node) { - while (node && node.kind !== 248) { - node = node.parent; - } - return node; - } - ts.getSourceFileOfNode = getSourceFileOfNode; - function getStartPositionOfLine(line, sourceFile) { - ts.Debug.assert(line >= 0); - return ts.getLineStarts(sourceFile)[line]; - } - ts.getStartPositionOfLine = getStartPositionOfLine; - function nodePosToString(node) { - var file = getSourceFileOfNode(node); - var loc = ts.getLineAndCharacterOfPosition(file, node.pos); - return file.fileName + "(" + (loc.line + 1) + "," + (loc.character + 1) + ")"; - } - ts.nodePosToString = nodePosToString; - function getStartPosOfNode(node) { - return node.pos; - } - ts.getStartPosOfNode = getStartPosOfNode; - function nodeIsMissing(node) { - if (!node) { - return true; - } - return node.pos === node.end && node.pos >= 0 && node.kind !== 1; - } - ts.nodeIsMissing = nodeIsMissing; - function nodeIsPresent(node) { - return !nodeIsMissing(node); - } - ts.nodeIsPresent = nodeIsPresent; - function getTokenPosOfNode(node, sourceFile) { - if (nodeIsMissing(node)) { - return node.pos; - } - return ts.skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.pos); - } - ts.getTokenPosOfNode = getTokenPosOfNode; - function getNonDecoratorTokenPosOfNode(node, sourceFile) { - if (nodeIsMissing(node) || !node.decorators) { - return getTokenPosOfNode(node, sourceFile); - } - return ts.skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.decorators.end); - } - ts.getNonDecoratorTokenPosOfNode = getNonDecoratorTokenPosOfNode; - function getSourceTextOfNodeFromSourceFile(sourceFile, node, includeTrivia) { - if (includeTrivia === void 0) { includeTrivia = false; } - if (nodeIsMissing(node)) { - return ""; - } - var text = sourceFile.text; - return text.substring(includeTrivia ? node.pos : ts.skipTrivia(text, node.pos), node.end); - } - ts.getSourceTextOfNodeFromSourceFile = getSourceTextOfNodeFromSourceFile; - function getTextOfNodeFromSourceText(sourceText, node) { - if (nodeIsMissing(node)) { - return ""; - } - return sourceText.substring(ts.skipTrivia(sourceText, node.pos), node.end); - } - ts.getTextOfNodeFromSourceText = getTextOfNodeFromSourceText; - function getTextOfNode(node, includeTrivia) { - if (includeTrivia === void 0) { includeTrivia = false; } - return getSourceTextOfNodeFromSourceFile(getSourceFileOfNode(node), node, includeTrivia); - } - ts.getTextOfNode = getTextOfNode; - function escapeIdentifier(identifier) { - return identifier.length >= 2 && identifier.charCodeAt(0) === 95 && identifier.charCodeAt(1) === 95 ? "_" + identifier : identifier; - } - ts.escapeIdentifier = escapeIdentifier; - function unescapeIdentifier(identifier) { - return identifier.length >= 3 && identifier.charCodeAt(0) === 95 && identifier.charCodeAt(1) === 95 && identifier.charCodeAt(2) === 95 ? identifier.substr(1) : identifier; - } - ts.unescapeIdentifier = unescapeIdentifier; - function makeIdentifierFromModuleName(moduleName) { - return ts.getBaseFileName(moduleName).replace(/^(\d)/, "_$1").replace(/\W/g, "_"); - } - ts.makeIdentifierFromModuleName = makeIdentifierFromModuleName; - function isBlockOrCatchScoped(declaration) { - return (getCombinedNodeFlags(declaration) & 49152) !== 0 || - isCatchClauseVariableDeclaration(declaration); - } - ts.isBlockOrCatchScoped = isBlockOrCatchScoped; - function getEnclosingBlockScopeContainer(node) { - var current = node.parent; - while (current) { - if (isFunctionLike(current)) { - return current; - } - switch (current.kind) { - case 248: - case 220: - case 244: - case 218: - case 199: - case 200: - case 201: - return current; - case 192: - if (!isFunctionLike(current.parent)) { - return current; - } - } - current = current.parent; - } - } - ts.getEnclosingBlockScopeContainer = getEnclosingBlockScopeContainer; - function isCatchClauseVariableDeclaration(declaration) { - return declaration && - declaration.kind === 211 && - declaration.parent && - declaration.parent.kind === 244; - } - ts.isCatchClauseVariableDeclaration = isCatchClauseVariableDeclaration; - function declarationNameToString(name) { - return getFullWidth(name) === 0 ? "(Missing)" : getTextOfNode(name); - } - ts.declarationNameToString = declarationNameToString; - function createDiagnosticForNode(node, message, arg0, arg1, arg2) { - var sourceFile = getSourceFileOfNode(node); - var span = getErrorSpanForNode(sourceFile, node); - return ts.createFileDiagnostic(sourceFile, span.start, span.length, message, arg0, arg1, arg2); - } - ts.createDiagnosticForNode = createDiagnosticForNode; - function createDiagnosticForNodeFromMessageChain(node, messageChain) { - var sourceFile = getSourceFileOfNode(node); - var span = getErrorSpanForNode(sourceFile, node); - return { - file: sourceFile, - start: span.start, - length: span.length, - code: messageChain.code, - category: messageChain.category, - messageText: messageChain.next ? messageChain : messageChain.messageText - }; - } - ts.createDiagnosticForNodeFromMessageChain = createDiagnosticForNodeFromMessageChain; - function getSpanOfTokenAtPosition(sourceFile, pos) { - var scanner = ts.createScanner(sourceFile.languageVersion, true, sourceFile.languageVariant, sourceFile.text, undefined, pos); - scanner.scan(); - var start = scanner.getTokenPos(); - return ts.createTextSpanFromBounds(start, scanner.getTextPos()); - } - ts.getSpanOfTokenAtPosition = getSpanOfTokenAtPosition; - function getErrorSpanForNode(sourceFile, node) { - var errorNode = node; - switch (node.kind) { - case 248: - var pos_1 = ts.skipTrivia(sourceFile.text, 0, false); - if (pos_1 === sourceFile.text.length) { - return ts.createTextSpan(0, 0); - } - return getSpanOfTokenAtPosition(sourceFile, pos_1); - case 211: - case 163: - case 214: - case 186: - case 215: - case 218: - case 217: - case 247: - case 213: - case 173: - errorNode = node.name; - break; - } - if (errorNode === undefined) { - return getSpanOfTokenAtPosition(sourceFile, node.pos); - } - var pos = nodeIsMissing(errorNode) - ? errorNode.pos - : ts.skipTrivia(sourceFile.text, errorNode.pos); - return ts.createTextSpanFromBounds(pos, errorNode.end); - } - ts.getErrorSpanForNode = getErrorSpanForNode; - function isExternalModule(file) { - return file.externalModuleIndicator !== undefined; - } - ts.isExternalModule = isExternalModule; - function isDeclarationFile(file) { - return (file.flags & 8192) !== 0; - } - ts.isDeclarationFile = isDeclarationFile; - function isConstEnumDeclaration(node) { - return node.kind === 217 && isConst(node); - } - ts.isConstEnumDeclaration = isConstEnumDeclaration; - function walkUpBindingElementsAndPatterns(node) { - while (node && (node.kind === 163 || isBindingPattern(node))) { - node = node.parent; - } - return node; - } - function getCombinedNodeFlags(node) { - node = walkUpBindingElementsAndPatterns(node); - var flags = node.flags; - if (node.kind === 211) { - node = node.parent; - } - if (node && node.kind === 212) { - flags |= node.flags; - node = node.parent; - } - if (node && node.kind === 193) { - flags |= node.flags; - } - return flags; - } - ts.getCombinedNodeFlags = getCombinedNodeFlags; - function isConst(node) { - return !!(getCombinedNodeFlags(node) & 32768); - } - ts.isConst = isConst; - function isLet(node) { - return !!(getCombinedNodeFlags(node) & 16384); - } - ts.isLet = isLet; - function isPrologueDirective(node) { - return node.kind === 195 && node.expression.kind === 9; - } - ts.isPrologueDirective = isPrologueDirective; - function getLeadingCommentRangesOfNode(node, sourceFileOfNode) { - return ts.getLeadingCommentRanges(sourceFileOfNode.text, node.pos); - } - ts.getLeadingCommentRangesOfNode = getLeadingCommentRangesOfNode; - function getJsDocComments(node, sourceFileOfNode) { - var commentRanges = (node.kind === 138 || node.kind === 137) ? - ts.concatenate(ts.getTrailingCommentRanges(sourceFileOfNode.text, node.pos), ts.getLeadingCommentRanges(sourceFileOfNode.text, node.pos)) : - getLeadingCommentRangesOfNode(node, sourceFileOfNode); - return ts.filter(commentRanges, isJsDocComment); - function isJsDocComment(comment) { - return sourceFileOfNode.text.charCodeAt(comment.pos + 1) === 42 && - sourceFileOfNode.text.charCodeAt(comment.pos + 2) === 42 && - sourceFileOfNode.text.charCodeAt(comment.pos + 3) !== 47; - } - } - ts.getJsDocComments = getJsDocComments; - ts.fullTripleSlashReferencePathRegEx = /^(\/\/\/\s*/; - ts.fullTripleSlashAMDReferencePathRegEx = /^(\/\/\/\s*/; - function isTypeNode(node) { - if (151 <= node.kind && node.kind <= 160) { - return true; - } - switch (node.kind) { - case 117: - case 128: - case 130: - case 120: - case 131: - return true; - case 103: - return node.parent.kind !== 177; - case 9: - return node.parent.kind === 138; - case 188: - return !isExpressionWithTypeArgumentsInClassExtendsClause(node); - case 69: - if (node.parent.kind === 135 && node.parent.right === node) { - node = node.parent; - } - else if (node.parent.kind === 166 && node.parent.name === node) { - node = node.parent; - } - ts.Debug.assert(node.kind === 69 || node.kind === 135 || node.kind === 166, "'node' was expected to be a qualified name, identifier or property access in 'isTypeNode'."); - case 135: - case 166: - case 97: - var parent_1 = node.parent; - if (parent_1.kind === 154) { - return false; - } - if (151 <= parent_1.kind && parent_1.kind <= 160) { - return true; - } - switch (parent_1.kind) { - case 188: - return !isExpressionWithTypeArgumentsInClassExtendsClause(parent_1); - case 137: - return node === parent_1.constraint; - case 141: - case 140: - case 138: - case 211: - return node === parent_1.type; - case 213: - case 173: - case 174: - case 144: - case 143: - case 142: - case 145: - case 146: - return node === parent_1.type; - case 147: - case 148: - case 149: - return node === parent_1.type; - case 171: - return node === parent_1.type; - case 168: - case 169: - return parent_1.typeArguments && ts.indexOf(parent_1.typeArguments, node) >= 0; - case 170: - return false; - } - } - return false; - } - ts.isTypeNode = isTypeNode; - function forEachReturnStatement(body, visitor) { - return traverse(body); - function traverse(node) { - switch (node.kind) { - case 204: - return visitor(node); - case 220: - case 192: - case 196: - case 197: - case 198: - case 199: - case 200: - case 201: - case 205: - case 206: - case 241: - case 242: - case 207: - case 209: - case 244: - return ts.forEachChild(node, traverse); - } - } - } - ts.forEachReturnStatement = forEachReturnStatement; - function forEachYieldExpression(body, visitor) { - return traverse(body); - function traverse(node) { - switch (node.kind) { - case 184: - visitor(node); - var operand = node.expression; - if (operand) { - traverse(operand); - } - case 217: - case 215: - case 218: - case 216: - case 214: - case 186: - return; - default: - if (isFunctionLike(node)) { - var name_5 = node.name; - if (name_5 && name_5.kind === 136) { - traverse(name_5.expression); - return; - } - } - else if (!isTypeNode(node)) { - ts.forEachChild(node, traverse); - } - } - } - } - ts.forEachYieldExpression = forEachYieldExpression; - function isVariableLike(node) { - if (node) { - switch (node.kind) { - case 163: - case 247: - case 138: - case 245: - case 141: - case 140: - case 246: - case 211: - return true; - } - } - return false; - } - ts.isVariableLike = isVariableLike; - function isAccessor(node) { - return node && (node.kind === 145 || node.kind === 146); - } - ts.isAccessor = isAccessor; - function isClassLike(node) { - return node && (node.kind === 214 || node.kind === 186); - } - ts.isClassLike = isClassLike; - function isFunctionLike(node) { - if (node) { - switch (node.kind) { - case 144: - case 173: - case 213: - case 174: - case 143: - case 142: - case 145: - case 146: - case 147: - case 148: - case 149: - case 152: - case 153: - return true; - } - } - return false; - } - ts.isFunctionLike = isFunctionLike; - function introducesArgumentsExoticObject(node) { - switch (node.kind) { - case 143: - case 142: - case 144: - case 145: - case 146: - case 213: - case 173: - return true; - } - return false; - } - ts.introducesArgumentsExoticObject = introducesArgumentsExoticObject; - function isFunctionBlock(node) { - return node && node.kind === 192 && isFunctionLike(node.parent); - } - ts.isFunctionBlock = isFunctionBlock; - function isObjectLiteralMethod(node) { - return node && node.kind === 143 && node.parent.kind === 165; - } - ts.isObjectLiteralMethod = isObjectLiteralMethod; - function getContainingFunction(node) { - while (true) { - node = node.parent; - if (!node || isFunctionLike(node)) { - return node; - } - } - } - ts.getContainingFunction = getContainingFunction; - function getContainingClass(node) { - while (true) { - node = node.parent; - if (!node || isClassLike(node)) { - return node; - } - } - } - ts.getContainingClass = getContainingClass; - function getThisContainer(node, includeArrowFunctions) { - while (true) { - node = node.parent; - if (!node) { - return undefined; - } - switch (node.kind) { - case 136: - if (isClassLike(node.parent.parent)) { - return node; - } - node = node.parent; - break; - case 139: - if (node.parent.kind === 138 && isClassElement(node.parent.parent)) { - node = node.parent.parent; - } - else if (isClassElement(node.parent)) { - node = node.parent; - } - break; - case 174: - if (!includeArrowFunctions) { - continue; - } - case 213: - case 173: - case 218: - case 141: - case 140: - case 143: - case 142: - case 144: - case 145: - case 146: - case 147: - case 148: - case 149: - case 217: - case 248: - return node; - } - } - } - ts.getThisContainer = getThisContainer; - function getSuperContainer(node, includeFunctions) { - while (true) { - node = node.parent; - if (!node) - return node; - switch (node.kind) { - case 136: - if (isClassLike(node.parent.parent)) { - return node; - } - node = node.parent; - break; - case 139: - if (node.parent.kind === 138 && isClassElement(node.parent.parent)) { - node = node.parent.parent; - } - else if (isClassElement(node.parent)) { - node = node.parent; - } - break; - case 213: - case 173: - case 174: - if (!includeFunctions) { - continue; - } - case 141: - case 140: - case 143: - case 142: - case 144: - case 145: - case 146: - return node; - } - } - } - ts.getSuperContainer = getSuperContainer; - function getEntityNameFromTypeNode(node) { - if (node) { - switch (node.kind) { - case 151: - return node.typeName; - case 188: - return node.expression; - case 69: - case 135: - return node; - } - } - return undefined; - } - ts.getEntityNameFromTypeNode = getEntityNameFromTypeNode; - function getInvokedExpression(node) { - if (node.kind === 170) { - return node.tag; - } - return node.expression; - } - ts.getInvokedExpression = getInvokedExpression; - function nodeCanBeDecorated(node) { - switch (node.kind) { - case 214: - return true; - case 141: - return node.parent.kind === 214; - case 138: - return node.parent.body && node.parent.parent.kind === 214; - case 145: - case 146: - case 143: - return node.body && node.parent.kind === 214; - } - return false; - } - ts.nodeCanBeDecorated = nodeCanBeDecorated; - function nodeIsDecorated(node) { - switch (node.kind) { - case 214: - if (node.decorators) { - return true; - } - return false; - case 141: - case 138: - if (node.decorators) { - return true; - } - return false; - case 145: - if (node.body && node.decorators) { - return true; - } - return false; - case 143: - case 146: - if (node.body && node.decorators) { - return true; - } - return false; - } - return false; - } - ts.nodeIsDecorated = nodeIsDecorated; - function childIsDecorated(node) { - switch (node.kind) { - case 214: - return ts.forEach(node.members, nodeOrChildIsDecorated); - case 143: - case 146: - return ts.forEach(node.parameters, nodeIsDecorated); - } - return false; - } - ts.childIsDecorated = childIsDecorated; - function nodeOrChildIsDecorated(node) { - return nodeIsDecorated(node) || childIsDecorated(node); - } - ts.nodeOrChildIsDecorated = nodeOrChildIsDecorated; - function isPropertyAccessExpression(node) { - return node.kind === 166; - } - ts.isPropertyAccessExpression = isPropertyAccessExpression; - function isElementAccessExpression(node) { - return node.kind === 167; - } - ts.isElementAccessExpression = isElementAccessExpression; - function isExpression(node) { - switch (node.kind) { - case 95: - case 93: - case 99: - case 84: - case 10: - case 164: - case 165: - case 166: - case 167: - case 168: - case 169: - case 170: - case 189: - case 171: - case 172: - case 173: - case 186: - case 174: - case 177: - case 175: - case 176: - case 179: - case 180: - case 181: - case 182: - case 185: - case 183: - case 11: - case 187: - case 233: - case 234: - case 184: - case 178: - return true; - case 135: - while (node.parent.kind === 135) { - node = node.parent; - } - return node.parent.kind === 154; - case 69: - if (node.parent.kind === 154) { - return true; - } - case 8: - case 9: - case 97: - var parent_2 = node.parent; - switch (parent_2.kind) { - case 211: - case 138: - case 141: - case 140: - case 247: - case 245: - case 163: - return parent_2.initializer === node; - case 195: - case 196: - case 197: - case 198: - case 204: - case 205: - case 206: - case 241: - case 208: - case 206: - return parent_2.expression === node; - case 199: - var forStatement = parent_2; - return (forStatement.initializer === node && forStatement.initializer.kind !== 212) || - forStatement.condition === node || - forStatement.incrementor === node; - case 200: - case 201: - var forInStatement = parent_2; - return (forInStatement.initializer === node && forInStatement.initializer.kind !== 212) || - forInStatement.expression === node; - case 171: - case 189: - return node === parent_2.expression; - case 190: - return node === parent_2.expression; - case 136: - return node === parent_2.expression; - case 139: - case 240: - case 239: - return true; - case 188: - return parent_2.expression === node && isExpressionWithTypeArgumentsInClassExtendsClause(parent_2); - default: - if (isExpression(parent_2)) { - return true; - } - } - } - return false; - } - ts.isExpression = isExpression; - function isExternalModuleNameRelative(moduleName) { - return moduleName.substr(0, 2) === "./" || moduleName.substr(0, 3) === "../" || moduleName.substr(0, 2) === ".\\" || moduleName.substr(0, 3) === "..\\"; - } - ts.isExternalModuleNameRelative = isExternalModuleNameRelative; - function isInstantiatedModule(node, preserveConstEnums) { - var moduleState = ts.getModuleInstanceState(node); - return moduleState === 1 || - (preserveConstEnums && moduleState === 2); - } - ts.isInstantiatedModule = isInstantiatedModule; - function isExternalModuleImportEqualsDeclaration(node) { - return node.kind === 221 && node.moduleReference.kind === 232; - } - ts.isExternalModuleImportEqualsDeclaration = isExternalModuleImportEqualsDeclaration; - function getExternalModuleImportEqualsDeclarationExpression(node) { - ts.Debug.assert(isExternalModuleImportEqualsDeclaration(node)); - return node.moduleReference.expression; - } - ts.getExternalModuleImportEqualsDeclarationExpression = getExternalModuleImportEqualsDeclarationExpression; - function isInternalModuleImportEqualsDeclaration(node) { - return node.kind === 221 && node.moduleReference.kind !== 232; - } - ts.isInternalModuleImportEqualsDeclaration = isInternalModuleImportEqualsDeclaration; - function getExternalModuleName(node) { - if (node.kind === 222) { - return node.moduleSpecifier; - } - if (node.kind === 221) { - var reference = node.moduleReference; - if (reference.kind === 232) { - return reference.expression; - } - } - if (node.kind === 228) { - return node.moduleSpecifier; - } - } - ts.getExternalModuleName = getExternalModuleName; - function hasQuestionToken(node) { - if (node) { - switch (node.kind) { - case 138: - case 143: - case 142: - case 246: - case 245: - case 141: - case 140: - return node.questionToken !== undefined; - } - } - return false; - } - ts.hasQuestionToken = hasQuestionToken; - function isJSDocConstructSignature(node) { - return node.kind === 261 && - node.parameters.length > 0 && - node.parameters[0].type.kind === 263; - } - ts.isJSDocConstructSignature = isJSDocConstructSignature; - function getJSDocTag(node, kind) { - if (node && node.jsDocComment) { - for (var _i = 0, _a = node.jsDocComment.tags; _i < _a.length; _i++) { - var tag = _a[_i]; - if (tag.kind === kind) { - return tag; - } - } - } - } - function getJSDocTypeTag(node) { - return getJSDocTag(node, 269); - } - ts.getJSDocTypeTag = getJSDocTypeTag; - function getJSDocReturnTag(node) { - return getJSDocTag(node, 268); - } - ts.getJSDocReturnTag = getJSDocReturnTag; - function getJSDocTemplateTag(node) { - return getJSDocTag(node, 270); - } - ts.getJSDocTemplateTag = getJSDocTemplateTag; - function getCorrespondingJSDocParameterTag(parameter) { - if (parameter.name && parameter.name.kind === 69) { - var parameterName = parameter.name.text; - var docComment = parameter.parent.jsDocComment; - if (docComment) { - return ts.forEach(docComment.tags, function (t) { - if (t.kind === 267) { - var parameterTag = t; - var name_6 = parameterTag.preParameterName || parameterTag.postParameterName; - if (name_6.text === parameterName) { - return t; - } - } - }); - } - } - } - ts.getCorrespondingJSDocParameterTag = getCorrespondingJSDocParameterTag; - function hasRestParameter(s) { - return isRestParameter(ts.lastOrUndefined(s.parameters)); - } - ts.hasRestParameter = hasRestParameter; - function isRestParameter(node) { - if (node) { - if (node.parserContextFlags & 32) { - if (node.type && node.type.kind === 262) { - return true; - } - var paramTag = getCorrespondingJSDocParameterTag(node); - if (paramTag && paramTag.typeExpression) { - return paramTag.typeExpression.type.kind === 262; - } - } - return node.dotDotDotToken !== undefined; - } - return false; - } - ts.isRestParameter = isRestParameter; - function isLiteralKind(kind) { - return 8 <= kind && kind <= 11; - } - ts.isLiteralKind = isLiteralKind; - function isTextualLiteralKind(kind) { - return kind === 9 || kind === 11; - } - ts.isTextualLiteralKind = isTextualLiteralKind; - function isTemplateLiteralKind(kind) { - return 11 <= kind && kind <= 14; - } - ts.isTemplateLiteralKind = isTemplateLiteralKind; - function isBindingPattern(node) { - return !!node && (node.kind === 162 || node.kind === 161); - } - ts.isBindingPattern = isBindingPattern; - function isInAmbientContext(node) { - while (node) { - if (node.flags & (2 | 8192)) { - return true; - } - node = node.parent; - } - return false; - } - ts.isInAmbientContext = isInAmbientContext; - function isDeclaration(node) { - switch (node.kind) { - case 174: - case 163: - case 214: - case 186: - case 144: - case 217: - case 247: - case 230: - case 213: - case 173: - case 145: - case 223: - case 221: - case 226: - case 215: - case 143: - case 142: - case 218: - case 224: - case 138: - case 245: - case 141: - case 140: - case 146: - case 246: - case 216: - case 137: - case 211: - return true; - } - return false; - } - ts.isDeclaration = isDeclaration; - function isStatement(n) { - switch (n.kind) { - case 203: - case 202: - case 210: - case 197: - case 195: - case 194: - case 200: - case 201: - case 199: - case 196: - case 207: - case 204: - case 206: - case 98: - case 209: - case 193: - case 198: - case 205: - case 227: - return true; - default: - return false; - } - } - ts.isStatement = isStatement; - function isClassElement(n) { - switch (n.kind) { - case 144: - case 141: - case 143: - case 145: - case 146: - case 142: - case 149: - return true; - default: - return false; - } - } - ts.isClassElement = isClassElement; - function isDeclarationName(name) { - if (name.kind !== 69 && name.kind !== 9 && name.kind !== 8) { - return false; - } - var parent = name.parent; - if (parent.kind === 226 || parent.kind === 230) { - if (parent.propertyName) { - return true; - } - } - if (isDeclaration(parent)) { - return parent.name === name; - } - return false; - } - ts.isDeclarationName = isDeclarationName; - function isIdentifierName(node) { - var parent = node.parent; - switch (parent.kind) { - case 141: - case 140: - case 143: - case 142: - case 145: - case 146: - case 247: - case 245: - case 166: - return parent.name === node; - case 135: - if (parent.right === node) { - while (parent.kind === 135) { - parent = parent.parent; - } - return parent.kind === 154; - } - return false; - case 163: - case 226: - return parent.propertyName === node; - case 230: - return true; - } - return false; - } - ts.isIdentifierName = isIdentifierName; - function isAliasSymbolDeclaration(node) { - return node.kind === 221 || - node.kind === 223 && !!node.name || - node.kind === 224 || - node.kind === 226 || - node.kind === 230 || - node.kind === 227 && node.expression.kind === 69; - } - ts.isAliasSymbolDeclaration = isAliasSymbolDeclaration; - function getClassExtendsHeritageClauseElement(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 83); - return heritageClause && heritageClause.types.length > 0 ? heritageClause.types[0] : undefined; - } - ts.getClassExtendsHeritageClauseElement = getClassExtendsHeritageClauseElement; - function getClassImplementsHeritageClauseElements(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 106); - return heritageClause ? heritageClause.types : undefined; - } - ts.getClassImplementsHeritageClauseElements = getClassImplementsHeritageClauseElements; - function getInterfaceBaseTypeNodes(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 83); - return heritageClause ? heritageClause.types : undefined; - } - ts.getInterfaceBaseTypeNodes = getInterfaceBaseTypeNodes; - function getHeritageClause(clauses, kind) { - if (clauses) { - for (var _i = 0; _i < clauses.length; _i++) { - var clause = clauses[_i]; - if (clause.token === kind) { - return clause; - } - } - } - return undefined; - } - ts.getHeritageClause = getHeritageClause; - function tryResolveScriptReference(host, sourceFile, reference) { - if (!host.getCompilerOptions().noResolve) { - var referenceFileName = ts.isRootedDiskPath(reference.fileName) ? reference.fileName : ts.combinePaths(ts.getDirectoryPath(sourceFile.fileName), reference.fileName); - referenceFileName = ts.getNormalizedAbsolutePath(referenceFileName, host.getCurrentDirectory()); - return host.getSourceFile(referenceFileName); - } - } - ts.tryResolveScriptReference = tryResolveScriptReference; - function getAncestor(node, kind) { - while (node) { - if (node.kind === kind) { - return node; - } - node = node.parent; - } - return undefined; - } - ts.getAncestor = getAncestor; - function getFileReferenceFromReferencePath(comment, commentRange) { - var simpleReferenceRegEx = /^\/\/\/\s*/gim; - if (simpleReferenceRegEx.exec(comment)) { - if (isNoDefaultLibRegEx.exec(comment)) { - return { - isNoDefaultLib: true - }; - } - else { - var matchResult = ts.fullTripleSlashReferencePathRegEx.exec(comment); - if (matchResult) { - var start = commentRange.pos; - var end = commentRange.end; - return { - fileReference: { - pos: start, - end: end, - fileName: matchResult[3] - }, - isNoDefaultLib: false - }; - } - else { - return { - diagnosticMessage: ts.Diagnostics.Invalid_reference_directive_syntax, - isNoDefaultLib: false - }; - } - } - } - return undefined; - } - ts.getFileReferenceFromReferencePath = getFileReferenceFromReferencePath; - function isKeyword(token) { - return 70 <= token && token <= 134; - } - ts.isKeyword = isKeyword; - function isTrivia(token) { - return 2 <= token && token <= 7; - } - ts.isTrivia = isTrivia; - function isAsyncFunctionLike(node) { - return isFunctionLike(node) && (node.flags & 512) !== 0 && !isAccessor(node); - } - ts.isAsyncFunctionLike = isAsyncFunctionLike; - function hasDynamicName(declaration) { - return declaration.name && - declaration.name.kind === 136 && - !isWellKnownSymbolSyntactically(declaration.name.expression); - } - ts.hasDynamicName = hasDynamicName; - function isWellKnownSymbolSyntactically(node) { - return isPropertyAccessExpression(node) && isESSymbolIdentifier(node.expression); - } - ts.isWellKnownSymbolSyntactically = isWellKnownSymbolSyntactically; - function getPropertyNameForPropertyNameNode(name) { - if (name.kind === 69 || name.kind === 9 || name.kind === 8) { - return name.text; - } - if (name.kind === 136) { - var nameExpression = name.expression; - if (isWellKnownSymbolSyntactically(nameExpression)) { - var rightHandSideName = nameExpression.name.text; - return getPropertyNameForKnownSymbolName(rightHandSideName); - } - } - return undefined; - } - ts.getPropertyNameForPropertyNameNode = getPropertyNameForPropertyNameNode; - function getPropertyNameForKnownSymbolName(symbolName) { - return "__@" + symbolName; - } - ts.getPropertyNameForKnownSymbolName = getPropertyNameForKnownSymbolName; - function isESSymbolIdentifier(node) { - return node.kind === 69 && node.text === "Symbol"; - } - ts.isESSymbolIdentifier = isESSymbolIdentifier; - function isModifier(token) { - switch (token) { - case 115: - case 118: - case 74: - case 122: - case 77: - case 82: - case 112: - case 110: - case 111: - case 113: - return true; - } - return false; - } - ts.isModifier = isModifier; - function isParameterDeclaration(node) { - var root = getRootDeclaration(node); - return root.kind === 138; - } - ts.isParameterDeclaration = isParameterDeclaration; - function getRootDeclaration(node) { - while (node.kind === 163) { - node = node.parent.parent; - } - return node; - } - ts.getRootDeclaration = getRootDeclaration; - function nodeStartsNewLexicalEnvironment(n) { - return isFunctionLike(n) || n.kind === 218 || n.kind === 248; - } - ts.nodeStartsNewLexicalEnvironment = nodeStartsNewLexicalEnvironment; - function cloneEntityName(node) { - if (node.kind === 69) { - var clone_1 = createSynthesizedNode(69); - clone_1.text = node.text; - return clone_1; - } - else { - var clone_2 = createSynthesizedNode(135); - clone_2.left = cloneEntityName(node.left); - clone_2.left.parent = clone_2; - clone_2.right = cloneEntityName(node.right); - clone_2.right.parent = clone_2; - return clone_2; - } - } - ts.cloneEntityName = cloneEntityName; - function nodeIsSynthesized(node) { - return node.pos === -1; - } - ts.nodeIsSynthesized = nodeIsSynthesized; - function createSynthesizedNode(kind, startsOnNewLine) { - var node = ts.createNode(kind, -1, -1); - node.startsOnNewLine = startsOnNewLine; - return node; - } - ts.createSynthesizedNode = createSynthesizedNode; - function createSynthesizedNodeArray() { - var array = []; - array.pos = -1; - array.end = -1; - return array; - } - ts.createSynthesizedNodeArray = createSynthesizedNodeArray; - function createDiagnosticCollection() { - var nonFileDiagnostics = []; - var fileDiagnostics = {}; - var diagnosticsModified = false; - var modificationCount = 0; - return { - add: add, - getGlobalDiagnostics: getGlobalDiagnostics, - getDiagnostics: getDiagnostics, - getModificationCount: getModificationCount, - reattachFileDiagnostics: reattachFileDiagnostics - }; - function getModificationCount() { - return modificationCount; - } - function reattachFileDiagnostics(newFile) { - if (!ts.hasProperty(fileDiagnostics, newFile.fileName)) { - return; - } - for (var _i = 0, _a = fileDiagnostics[newFile.fileName]; _i < _a.length; _i++) { - var diagnostic = _a[_i]; - diagnostic.file = newFile; - } - } - function add(diagnostic) { - var diagnostics; - if (diagnostic.file) { - diagnostics = fileDiagnostics[diagnostic.file.fileName]; - if (!diagnostics) { - diagnostics = []; - fileDiagnostics[diagnostic.file.fileName] = diagnostics; - } - } - else { - diagnostics = nonFileDiagnostics; - } - diagnostics.push(diagnostic); - diagnosticsModified = true; - modificationCount++; - } - function getGlobalDiagnostics() { - sortAndDeduplicate(); - return nonFileDiagnostics; - } - function getDiagnostics(fileName) { - sortAndDeduplicate(); - if (fileName) { - return fileDiagnostics[fileName] || []; - } - var allDiagnostics = []; - function pushDiagnostic(d) { - allDiagnostics.push(d); - } - ts.forEach(nonFileDiagnostics, pushDiagnostic); - for (var key in fileDiagnostics) { - if (ts.hasProperty(fileDiagnostics, key)) { - ts.forEach(fileDiagnostics[key], pushDiagnostic); - } - } - return ts.sortAndDeduplicateDiagnostics(allDiagnostics); - } - function sortAndDeduplicate() { - if (!diagnosticsModified) { - return; - } - diagnosticsModified = false; - nonFileDiagnostics = ts.sortAndDeduplicateDiagnostics(nonFileDiagnostics); - for (var key in fileDiagnostics) { - if (ts.hasProperty(fileDiagnostics, key)) { - fileDiagnostics[key] = ts.sortAndDeduplicateDiagnostics(fileDiagnostics[key]); - } - } - } - } - ts.createDiagnosticCollection = createDiagnosticCollection; - var escapedCharsRegExp = /[\\\"\u0000-\u001f\t\v\f\b\r\n\u2028\u2029\u0085]/g; - var escapedCharsMap = { - "\0": "\\0", - "\t": "\\t", - "\v": "\\v", - "\f": "\\f", - "\b": "\\b", - "\r": "\\r", - "\n": "\\n", - "\\": "\\\\", - "\"": "\\\"", - "\u2028": "\\u2028", - "\u2029": "\\u2029", - "\u0085": "\\u0085" - }; - function escapeString(s) { - s = escapedCharsRegExp.test(s) ? s.replace(escapedCharsRegExp, getReplacement) : s; - return s; - function getReplacement(c) { - return escapedCharsMap[c] || get16BitUnicodeEscapeSequence(c.charCodeAt(0)); - } - } - ts.escapeString = escapeString; - function isIntrinsicJsxName(name) { - var ch = name.substr(0, 1); - return ch.toLowerCase() === ch; - } - ts.isIntrinsicJsxName = isIntrinsicJsxName; - function get16BitUnicodeEscapeSequence(charCode) { - var hexCharCode = charCode.toString(16).toUpperCase(); - var paddedHexCode = ("0000" + hexCharCode).slice(-4); - return "\\u" + paddedHexCode; - } - var nonAsciiCharacters = /[^\u0000-\u007F]/g; - function escapeNonAsciiCharacters(s) { - return nonAsciiCharacters.test(s) ? - s.replace(nonAsciiCharacters, function (c) { return get16BitUnicodeEscapeSequence(c.charCodeAt(0)); }) : - s; - } - ts.escapeNonAsciiCharacters = escapeNonAsciiCharacters; - var indentStrings = ["", " "]; - function getIndentString(level) { - if (indentStrings[level] === undefined) { - indentStrings[level] = getIndentString(level - 1) + indentStrings[1]; - } - return indentStrings[level]; - } - ts.getIndentString = getIndentString; - function getIndentSize() { - return indentStrings[1].length; - } - ts.getIndentSize = getIndentSize; - function createTextWriter(newLine) { - var output = ""; - var indent = 0; - var lineStart = true; - var lineCount = 0; - var linePos = 0; - function write(s) { - if (s && s.length) { - if (lineStart) { - output += getIndentString(indent); - lineStart = false; - } - output += s; - } - } - function rawWrite(s) { - if (s !== undefined) { - if (lineStart) { - lineStart = false; - } - output += s; - } - } - function writeLiteral(s) { - if (s && s.length) { - write(s); - var lineStartsOfS = ts.computeLineStarts(s); - if (lineStartsOfS.length > 1) { - lineCount = lineCount + lineStartsOfS.length - 1; - linePos = output.length - s.length + ts.lastOrUndefined(lineStartsOfS); - } - } - } - function writeLine() { - if (!lineStart) { - output += newLine; - lineCount++; - linePos = output.length; - lineStart = true; - } - } - function writeTextOfNode(sourceFile, node) { - write(getSourceTextOfNodeFromSourceFile(sourceFile, node)); - } - return { - write: write, - rawWrite: rawWrite, - writeTextOfNode: writeTextOfNode, - writeLiteral: writeLiteral, - writeLine: writeLine, - increaseIndent: function () { return indent++; }, - decreaseIndent: function () { return indent--; }, - getIndent: function () { return indent; }, - getTextPos: function () { return output.length; }, - getLine: function () { return lineCount + 1; }, - getColumn: function () { return lineStart ? indent * getIndentSize() + 1 : output.length - linePos + 1; }, - getText: function () { return output; } - }; - } - ts.createTextWriter = createTextWriter; - function getOwnEmitOutputFilePath(sourceFile, host, extension) { - var compilerOptions = host.getCompilerOptions(); - var emitOutputFilePathWithoutExtension; - if (compilerOptions.outDir) { - emitOutputFilePathWithoutExtension = ts.removeFileExtension(getSourceFilePathInNewDir(sourceFile, host, compilerOptions.outDir)); - } - else { - emitOutputFilePathWithoutExtension = ts.removeFileExtension(sourceFile.fileName); - } - return emitOutputFilePathWithoutExtension + extension; - } - ts.getOwnEmitOutputFilePath = getOwnEmitOutputFilePath; - function getSourceFilePathInNewDir(sourceFile, host, newDirPath) { - var sourceFilePath = ts.getNormalizedAbsolutePath(sourceFile.fileName, host.getCurrentDirectory()); - sourceFilePath = sourceFilePath.replace(host.getCommonSourceDirectory(), ""); - return ts.combinePaths(newDirPath, sourceFilePath); - } - ts.getSourceFilePathInNewDir = getSourceFilePathInNewDir; - function writeFile(host, diagnostics, fileName, data, writeByteOrderMark) { - host.writeFile(fileName, data, writeByteOrderMark, function (hostErrorMessage) { - diagnostics.push(ts.createCompilerDiagnostic(ts.Diagnostics.Could_not_write_file_0_Colon_1, fileName, hostErrorMessage)); - }); - } - ts.writeFile = writeFile; - function getLineOfLocalPosition(currentSourceFile, pos) { - return ts.getLineAndCharacterOfPosition(currentSourceFile, pos).line; - } - ts.getLineOfLocalPosition = getLineOfLocalPosition; - function getFirstConstructorWithBody(node) { - return ts.forEach(node.members, function (member) { - if (member.kind === 144 && nodeIsPresent(member.body)) { - return member; - } - }); - } - ts.getFirstConstructorWithBody = getFirstConstructorWithBody; - function getSetAccessorTypeAnnotationNode(accessor) { - return accessor && accessor.parameters.length > 0 && accessor.parameters[0].type; - } - ts.getSetAccessorTypeAnnotationNode = getSetAccessorTypeAnnotationNode; - function shouldEmitToOwnFile(sourceFile, compilerOptions) { - if (!isDeclarationFile(sourceFile)) { - if ((isExternalModule(sourceFile) || !(compilerOptions.outFile || compilerOptions.out))) { - return compilerOptions.isolatedModules || !ts.fileExtensionIs(sourceFile.fileName, ".js"); - } - return false; - } - return false; - } - ts.shouldEmitToOwnFile = shouldEmitToOwnFile; - function getAllAccessorDeclarations(declarations, accessor) { - var firstAccessor; - var secondAccessor; - var getAccessor; - var setAccessor; - if (hasDynamicName(accessor)) { - firstAccessor = accessor; - if (accessor.kind === 145) { - getAccessor = accessor; - } - else if (accessor.kind === 146) { - setAccessor = accessor; - } - else { - ts.Debug.fail("Accessor has wrong kind"); - } - } - else { - ts.forEach(declarations, function (member) { - if ((member.kind === 145 || member.kind === 146) - && (member.flags & 128) === (accessor.flags & 128)) { - var memberName = getPropertyNameForPropertyNameNode(member.name); - var accessorName = getPropertyNameForPropertyNameNode(accessor.name); - if (memberName === accessorName) { - if (!firstAccessor) { - firstAccessor = member; - } - else if (!secondAccessor) { - secondAccessor = member; - } - if (member.kind === 145 && !getAccessor) { - getAccessor = member; - } - if (member.kind === 146 && !setAccessor) { - setAccessor = member; - } - } - } - }); - } - return { - firstAccessor: firstAccessor, - secondAccessor: secondAccessor, - getAccessor: getAccessor, - setAccessor: setAccessor - }; - } - ts.getAllAccessorDeclarations = getAllAccessorDeclarations; - function emitNewLineBeforeLeadingComments(currentSourceFile, writer, node, leadingComments) { - if (leadingComments && leadingComments.length && node.pos !== leadingComments[0].pos && - getLineOfLocalPosition(currentSourceFile, node.pos) !== getLineOfLocalPosition(currentSourceFile, leadingComments[0].pos)) { - writer.writeLine(); - } - } - ts.emitNewLineBeforeLeadingComments = emitNewLineBeforeLeadingComments; - function emitComments(currentSourceFile, writer, comments, trailingSeparator, newLine, writeComment) { - var emitLeadingSpace = !trailingSeparator; - ts.forEach(comments, function (comment) { - if (emitLeadingSpace) { - writer.write(" "); - emitLeadingSpace = false; - } - writeComment(currentSourceFile, writer, comment, newLine); - if (comment.hasTrailingNewLine) { - writer.writeLine(); - } - else if (trailingSeparator) { - writer.write(" "); - } - else { - emitLeadingSpace = true; - } - }); - } - ts.emitComments = emitComments; - function writeCommentRange(currentSourceFile, writer, comment, newLine) { - if (currentSourceFile.text.charCodeAt(comment.pos + 1) === 42) { - var firstCommentLineAndCharacter = ts.getLineAndCharacterOfPosition(currentSourceFile, comment.pos); - var lineCount = ts.getLineStarts(currentSourceFile).length; - var firstCommentLineIndent; - for (var pos = comment.pos, currentLine = firstCommentLineAndCharacter.line; pos < comment.end; currentLine++) { - var nextLineStart = (currentLine + 1) === lineCount - ? currentSourceFile.text.length + 1 - : getStartPositionOfLine(currentLine + 1, currentSourceFile); - if (pos !== comment.pos) { - if (firstCommentLineIndent === undefined) { - firstCommentLineIndent = calculateIndent(getStartPositionOfLine(firstCommentLineAndCharacter.line, currentSourceFile), comment.pos); - } - var currentWriterIndentSpacing = writer.getIndent() * getIndentSize(); - var spacesToEmit = currentWriterIndentSpacing - firstCommentLineIndent + calculateIndent(pos, nextLineStart); - if (spacesToEmit > 0) { - var numberOfSingleSpacesToEmit = spacesToEmit % getIndentSize(); - var indentSizeSpaceString = getIndentString((spacesToEmit - numberOfSingleSpacesToEmit) / getIndentSize()); - writer.rawWrite(indentSizeSpaceString); - while (numberOfSingleSpacesToEmit) { - writer.rawWrite(" "); - numberOfSingleSpacesToEmit--; - } - } - else { - writer.rawWrite(""); - } - } - writeTrimmedCurrentLine(pos, nextLineStart); - pos = nextLineStart; - } - } - else { - writer.write(currentSourceFile.text.substring(comment.pos, comment.end)); - } - function writeTrimmedCurrentLine(pos, nextLineStart) { - var end = Math.min(comment.end, nextLineStart - 1); - var currentLineText = currentSourceFile.text.substring(pos, end).replace(/^\s+|\s+$/g, ""); - if (currentLineText) { - writer.write(currentLineText); - if (end !== comment.end) { - writer.writeLine(); - } - } - else { - writer.writeLiteral(newLine); - } - } - function calculateIndent(pos, end) { - var currentLineIndent = 0; - for (; pos < end && ts.isWhiteSpace(currentSourceFile.text.charCodeAt(pos)); pos++) { - if (currentSourceFile.text.charCodeAt(pos) === 9) { - currentLineIndent += getIndentSize() - (currentLineIndent % getIndentSize()); - } - else { - currentLineIndent++; - } - } - return currentLineIndent; - } - } - ts.writeCommentRange = writeCommentRange; - function modifierToFlag(token) { - switch (token) { - case 113: return 128; - case 112: return 16; - case 111: return 64; - case 110: return 32; - case 115: return 256; - case 82: return 1; - case 122: return 2; - case 74: return 32768; - case 77: return 1024; - case 118: return 512; - } - return 0; - } - ts.modifierToFlag = modifierToFlag; - function isLeftHandSideExpression(expr) { - if (expr) { - switch (expr.kind) { - case 166: - case 167: - case 169: - case 168: - case 233: - case 234: - case 170: - case 164: - case 172: - case 165: - case 186: - case 173: - case 69: - case 10: - case 8: - case 9: - case 11: - case 183: - case 84: - case 93: - case 97: - case 99: - case 95: - return true; - } - } - return false; - } - ts.isLeftHandSideExpression = isLeftHandSideExpression; - function isAssignmentOperator(token) { - return token >= 56 && token <= 68; - } - ts.isAssignmentOperator = isAssignmentOperator; - function isExpressionWithTypeArgumentsInClassExtendsClause(node) { - return node.kind === 188 && - node.parent.token === 83 && - isClassLike(node.parent.parent); - } - ts.isExpressionWithTypeArgumentsInClassExtendsClause = isExpressionWithTypeArgumentsInClassExtendsClause; - function isSupportedExpressionWithTypeArguments(node) { - return isSupportedExpressionWithTypeArgumentsRest(node.expression); - } - ts.isSupportedExpressionWithTypeArguments = isSupportedExpressionWithTypeArguments; - function isSupportedExpressionWithTypeArgumentsRest(node) { - if (node.kind === 69) { - return true; - } - else if (isPropertyAccessExpression(node)) { - return isSupportedExpressionWithTypeArgumentsRest(node.expression); - } - else { - return false; - } - } - function isRightSideOfQualifiedNameOrPropertyAccess(node) { - return (node.parent.kind === 135 && node.parent.right === node) || - (node.parent.kind === 166 && node.parent.name === node); - } - ts.isRightSideOfQualifiedNameOrPropertyAccess = isRightSideOfQualifiedNameOrPropertyAccess; - function isEmptyObjectLiteralOrArrayLiteral(expression) { - var kind = expression.kind; - if (kind === 165) { - return expression.properties.length === 0; - } - if (kind === 164) { - return expression.elements.length === 0; - } - return false; - } - ts.isEmptyObjectLiteralOrArrayLiteral = isEmptyObjectLiteralOrArrayLiteral; - function getLocalSymbolForExportDefault(symbol) { - return symbol && symbol.valueDeclaration && (symbol.valueDeclaration.flags & 1024) ? symbol.valueDeclaration.localSymbol : undefined; - } - ts.getLocalSymbolForExportDefault = getLocalSymbolForExportDefault; - function isJavaScript(fileName) { - return ts.fileExtensionIs(fileName, ".js"); - } - ts.isJavaScript = isJavaScript; - function isTsx(fileName) { - return ts.fileExtensionIs(fileName, ".tsx"); - } - ts.isTsx = isTsx; - function getExpandedCharCodes(input) { - var output = []; - var length = input.length; - for (var i = 0; i < length; i++) { - var charCode = input.charCodeAt(i); - if (charCode < 0x80) { - output.push(charCode); - } - else if (charCode < 0x800) { - output.push((charCode >> 6) | 192); - output.push((charCode & 63) | 128); - } - else if (charCode < 0x10000) { - output.push((charCode >> 12) | 224); - output.push(((charCode >> 6) & 63) | 128); - output.push((charCode & 63) | 128); - } - else if (charCode < 0x20000) { - output.push((charCode >> 18) | 240); - output.push(((charCode >> 12) & 63) | 128); - output.push(((charCode >> 6) & 63) | 128); - output.push((charCode & 63) | 128); - } - else { - ts.Debug.assert(false, "Unexpected code point"); - } - } - return output; - } - var base64Digits = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="; - function convertToBase64(input) { - var result = ""; - var charCodes = getExpandedCharCodes(input); - var i = 0; - var length = charCodes.length; - var byte1, byte2, byte3, byte4; - while (i < length) { - byte1 = charCodes[i] >> 2; - byte2 = (charCodes[i] & 3) << 4 | charCodes[i + 1] >> 4; - byte3 = (charCodes[i + 1] & 15) << 2 | charCodes[i + 2] >> 6; - byte4 = charCodes[i + 2] & 63; - if (i + 1 >= length) { - byte3 = byte4 = 64; - } - else if (i + 2 >= length) { - byte4 = 64; - } - result += base64Digits.charAt(byte1) + base64Digits.charAt(byte2) + base64Digits.charAt(byte3) + base64Digits.charAt(byte4); - i += 3; - } - return result; - } - ts.convertToBase64 = convertToBase64; - var carriageReturnLineFeed = "\r\n"; - var lineFeed = "\n"; - function getNewLineCharacter(options) { - if (options.newLine === 0) { - return carriageReturnLineFeed; - } - else if (options.newLine === 1) { - return lineFeed; - } - else if (ts.sys) { - return ts.sys.newLine; - } - return carriageReturnLineFeed; - } - ts.getNewLineCharacter = getNewLineCharacter; -})(ts || (ts = {})); -var ts; -(function (ts) { - function getDefaultLibFileName(options) { - return options.target === 2 ? "lib.es6.d.ts" : "lib.d.ts"; - } - ts.getDefaultLibFileName = getDefaultLibFileName; - function textSpanEnd(span) { - return span.start + span.length; - } - ts.textSpanEnd = textSpanEnd; - function textSpanIsEmpty(span) { - return span.length === 0; - } - ts.textSpanIsEmpty = textSpanIsEmpty; - function textSpanContainsPosition(span, position) { - return position >= span.start && position < textSpanEnd(span); - } - ts.textSpanContainsPosition = textSpanContainsPosition; - function textSpanContainsTextSpan(span, other) { - return other.start >= span.start && textSpanEnd(other) <= textSpanEnd(span); - } - ts.textSpanContainsTextSpan = textSpanContainsTextSpan; - function textSpanOverlapsWith(span, other) { - var overlapStart = Math.max(span.start, other.start); - var overlapEnd = Math.min(textSpanEnd(span), textSpanEnd(other)); - return overlapStart < overlapEnd; - } - ts.textSpanOverlapsWith = textSpanOverlapsWith; - function textSpanOverlap(span1, span2) { - var overlapStart = Math.max(span1.start, span2.start); - var overlapEnd = Math.min(textSpanEnd(span1), textSpanEnd(span2)); - if (overlapStart < overlapEnd) { - return createTextSpanFromBounds(overlapStart, overlapEnd); - } - return undefined; - } - ts.textSpanOverlap = textSpanOverlap; - function textSpanIntersectsWithTextSpan(span, other) { - return other.start <= textSpanEnd(span) && textSpanEnd(other) >= span.start; - } - ts.textSpanIntersectsWithTextSpan = textSpanIntersectsWithTextSpan; - function textSpanIntersectsWith(span, start, length) { - var end = start + length; - return start <= textSpanEnd(span) && end >= span.start; - } - ts.textSpanIntersectsWith = textSpanIntersectsWith; - function decodedTextSpanIntersectsWith(start1, length1, start2, length2) { - var end1 = start1 + length1; - var end2 = start2 + length2; - return start2 <= end1 && end2 >= start1; - } - ts.decodedTextSpanIntersectsWith = decodedTextSpanIntersectsWith; - function textSpanIntersectsWithPosition(span, position) { - return position <= textSpanEnd(span) && position >= span.start; - } - ts.textSpanIntersectsWithPosition = textSpanIntersectsWithPosition; - function textSpanIntersection(span1, span2) { - var intersectStart = Math.max(span1.start, span2.start); - var intersectEnd = Math.min(textSpanEnd(span1), textSpanEnd(span2)); - if (intersectStart <= intersectEnd) { - return createTextSpanFromBounds(intersectStart, intersectEnd); - } - return undefined; - } - ts.textSpanIntersection = textSpanIntersection; - function createTextSpan(start, length) { - if (start < 0) { - throw new Error("start < 0"); - } - if (length < 0) { - throw new Error("length < 0"); - } - return { start: start, length: length }; - } - ts.createTextSpan = createTextSpan; - function createTextSpanFromBounds(start, end) { - return createTextSpan(start, end - start); - } - ts.createTextSpanFromBounds = createTextSpanFromBounds; - function textChangeRangeNewSpan(range) { - return createTextSpan(range.span.start, range.newLength); - } - ts.textChangeRangeNewSpan = textChangeRangeNewSpan; - function textChangeRangeIsUnchanged(range) { - return textSpanIsEmpty(range.span) && range.newLength === 0; - } - ts.textChangeRangeIsUnchanged = textChangeRangeIsUnchanged; - function createTextChangeRange(span, newLength) { - if (newLength < 0) { - throw new Error("newLength < 0"); - } - return { span: span, newLength: newLength }; - } - ts.createTextChangeRange = createTextChangeRange; - ts.unchangedTextChangeRange = createTextChangeRange(createTextSpan(0, 0), 0); - function collapseTextChangeRangesAcrossMultipleVersions(changes) { - if (changes.length === 0) { - return ts.unchangedTextChangeRange; - } - if (changes.length === 1) { - return changes[0]; - } - var change0 = changes[0]; - var oldStartN = change0.span.start; - var oldEndN = textSpanEnd(change0.span); - var newEndN = oldStartN + change0.newLength; - for (var i = 1; i < changes.length; i++) { - var nextChange = changes[i]; - var oldStart1 = oldStartN; - var oldEnd1 = oldEndN; - var newEnd1 = newEndN; - var oldStart2 = nextChange.span.start; - var oldEnd2 = textSpanEnd(nextChange.span); - var newEnd2 = oldStart2 + nextChange.newLength; - oldStartN = Math.min(oldStart1, oldStart2); - oldEndN = Math.max(oldEnd1, oldEnd1 + (oldEnd2 - newEnd1)); - newEndN = Math.max(newEnd2, newEnd2 + (newEnd1 - oldEnd2)); - } - return createTextChangeRange(createTextSpanFromBounds(oldStartN, oldEndN), newEndN - oldStartN); - } - ts.collapseTextChangeRangesAcrossMultipleVersions = collapseTextChangeRangesAcrossMultipleVersions; - function getTypeParameterOwner(d) { - if (d && d.kind === 137) { - for (var current = d; current; current = current.parent) { - if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 215) { - return current; - } - } - } - } - ts.getTypeParameterOwner = getTypeParameterOwner; -})(ts || (ts = {})); -var ts; -(function (ts) { - var nodeConstructors = new Array(272); - ts.parseTime = 0; - function getNodeConstructor(kind) { - return nodeConstructors[kind] || (nodeConstructors[kind] = ts.objectAllocator.getNodeConstructor(kind)); - } - ts.getNodeConstructor = getNodeConstructor; - function createNode(kind, pos, end) { - return new (getNodeConstructor(kind))(pos, end); - } - ts.createNode = createNode; - function visitNode(cbNode, node) { - if (node) { - return cbNode(node); - } - } - function visitNodeArray(cbNodes, nodes) { - if (nodes) { - return cbNodes(nodes); - } - } - function visitEachNode(cbNode, nodes) { - if (nodes) { - for (var _i = 0; _i < nodes.length; _i++) { - var node = nodes[_i]; - var result = cbNode(node); - if (result) { - return result; - } - } - } - } - function forEachChild(node, cbNode, cbNodeArray) { - if (!node) { - return; - } - var visitNodes = cbNodeArray ? visitNodeArray : visitEachNode; - var cbNodes = cbNodeArray || cbNode; - switch (node.kind) { - case 135: - return visitNode(cbNode, node.left) || - visitNode(cbNode, node.right); - case 137: - return visitNode(cbNode, node.name) || - visitNode(cbNode, node.constraint) || - visitNode(cbNode, node.expression); - case 246: - return visitNodes(cbNodes, node.decorators) || - visitNodes(cbNodes, node.modifiers) || - visitNode(cbNode, node.name) || - visitNode(cbNode, node.questionToken) || - visitNode(cbNode, node.equalsToken) || - visitNode(cbNode, node.objectAssignmentInitializer); - case 138: - case 141: - case 140: - case 245: - case 211: - case 163: - return visitNodes(cbNodes, node.decorators) || - visitNodes(cbNodes, node.modifiers) || - visitNode(cbNode, node.propertyName) || - visitNode(cbNode, node.dotDotDotToken) || - visitNode(cbNode, node.name) || - visitNode(cbNode, node.questionToken) || - visitNode(cbNode, node.type) || - visitNode(cbNode, node.initializer); - case 152: - case 153: - case 147: - case 148: - case 149: - return visitNodes(cbNodes, node.decorators) || - visitNodes(cbNodes, node.modifiers) || - visitNodes(cbNodes, node.typeParameters) || - visitNodes(cbNodes, node.parameters) || - visitNode(cbNode, node.type); - case 143: - case 142: - case 144: - case 145: - case 146: - case 173: - case 213: - case 174: - return visitNodes(cbNodes, node.decorators) || - visitNodes(cbNodes, node.modifiers) || - visitNode(cbNode, node.asteriskToken) || - visitNode(cbNode, node.name) || - visitNode(cbNode, node.questionToken) || - visitNodes(cbNodes, node.typeParameters) || - visitNodes(cbNodes, node.parameters) || - visitNode(cbNode, node.type) || - visitNode(cbNode, node.equalsGreaterThanToken) || - visitNode(cbNode, node.body); - case 151: - return visitNode(cbNode, node.typeName) || - visitNodes(cbNodes, node.typeArguments); - case 150: - return visitNode(cbNode, node.parameterName) || - visitNode(cbNode, node.type); - case 154: - return visitNode(cbNode, node.exprName); - case 155: - return visitNodes(cbNodes, node.members); - case 156: - return visitNode(cbNode, node.elementType); - case 157: - return visitNodes(cbNodes, node.elementTypes); - case 158: - case 159: - return visitNodes(cbNodes, node.types); - case 160: - return visitNode(cbNode, node.type); - case 161: - case 162: - return visitNodes(cbNodes, node.elements); - case 164: - return visitNodes(cbNodes, node.elements); - case 165: - return visitNodes(cbNodes, node.properties); - case 166: - return visitNode(cbNode, node.expression) || - visitNode(cbNode, node.dotToken) || - visitNode(cbNode, node.name); - case 167: - return visitNode(cbNode, node.expression) || - visitNode(cbNode, node.argumentExpression); - case 168: - case 169: - return visitNode(cbNode, node.expression) || - visitNodes(cbNodes, node.typeArguments) || - visitNodes(cbNodes, node.arguments); - case 170: - return visitNode(cbNode, node.tag) || - visitNode(cbNode, node.template); - case 171: - return visitNode(cbNode, node.type) || - visitNode(cbNode, node.expression); - case 172: - return visitNode(cbNode, node.expression); - case 175: - return visitNode(cbNode, node.expression); - case 176: - return visitNode(cbNode, node.expression); - case 177: - return visitNode(cbNode, node.expression); - case 179: - return visitNode(cbNode, node.operand); - case 184: - return visitNode(cbNode, node.asteriskToken) || - visitNode(cbNode, node.expression); - case 178: - return visitNode(cbNode, node.expression); - case 180: - return visitNode(cbNode, node.operand); - case 181: - return visitNode(cbNode, node.left) || - visitNode(cbNode, node.operatorToken) || - visitNode(cbNode, node.right); - case 189: - return visitNode(cbNode, node.expression) || - visitNode(cbNode, node.type); - case 182: - return visitNode(cbNode, node.condition) || - visitNode(cbNode, node.questionToken) || - visitNode(cbNode, node.whenTrue) || - visitNode(cbNode, node.colonToken) || - visitNode(cbNode, node.whenFalse); - case 185: - return visitNode(cbNode, node.expression); - case 192: - case 219: - return visitNodes(cbNodes, node.statements); - case 248: - return visitNodes(cbNodes, node.statements) || - visitNode(cbNode, node.endOfFileToken); - case 193: - return visitNodes(cbNodes, node.decorators) || - visitNodes(cbNodes, node.modifiers) || - visitNode(cbNode, node.declarationList); - case 212: - return visitNodes(cbNodes, node.declarations); - case 195: - return visitNode(cbNode, node.expression); - case 196: - return visitNode(cbNode, node.expression) || - visitNode(cbNode, node.thenStatement) || - visitNode(cbNode, node.elseStatement); - case 197: - return visitNode(cbNode, node.statement) || - visitNode(cbNode, node.expression); - case 198: - return visitNode(cbNode, node.expression) || - visitNode(cbNode, node.statement); - case 199: - return visitNode(cbNode, node.initializer) || - visitNode(cbNode, node.condition) || - visitNode(cbNode, node.incrementor) || - visitNode(cbNode, node.statement); - case 200: - return visitNode(cbNode, node.initializer) || - visitNode(cbNode, node.expression) || - visitNode(cbNode, node.statement); - case 201: - return visitNode(cbNode, node.initializer) || - visitNode(cbNode, node.expression) || - visitNode(cbNode, node.statement); - case 202: - case 203: - return visitNode(cbNode, node.label); - case 204: - return visitNode(cbNode, node.expression); - case 205: - return visitNode(cbNode, node.expression) || - visitNode(cbNode, node.statement); - case 206: - return visitNode(cbNode, node.expression) || - visitNode(cbNode, node.caseBlock); - case 220: - return visitNodes(cbNodes, node.clauses); - case 241: - return visitNode(cbNode, node.expression) || - visitNodes(cbNodes, node.statements); - case 242: - return visitNodes(cbNodes, node.statements); - case 207: - return visitNode(cbNode, node.label) || - visitNode(cbNode, node.statement); - case 208: - return visitNode(cbNode, node.expression); - case 209: - return visitNode(cbNode, node.tryBlock) || - visitNode(cbNode, node.catchClause) || - visitNode(cbNode, node.finallyBlock); - case 244: - return visitNode(cbNode, node.variableDeclaration) || - visitNode(cbNode, node.block); - case 139: - return visitNode(cbNode, node.expression); - case 214: - case 186: - return visitNodes(cbNodes, node.decorators) || - visitNodes(cbNodes, node.modifiers) || - visitNode(cbNode, node.name) || - visitNodes(cbNodes, node.typeParameters) || - visitNodes(cbNodes, node.heritageClauses) || - visitNodes(cbNodes, node.members); - case 215: - return visitNodes(cbNodes, node.decorators) || - visitNodes(cbNodes, node.modifiers) || - visitNode(cbNode, node.name) || - visitNodes(cbNodes, node.typeParameters) || - visitNodes(cbNodes, node.heritageClauses) || - visitNodes(cbNodes, node.members); - case 216: - return visitNodes(cbNodes, node.decorators) || - visitNodes(cbNodes, node.modifiers) || - visitNode(cbNode, node.name) || - visitNodes(cbNodes, node.typeParameters) || - visitNode(cbNode, node.type); - case 217: - return visitNodes(cbNodes, node.decorators) || - visitNodes(cbNodes, node.modifiers) || - visitNode(cbNode, node.name) || - visitNodes(cbNodes, node.members); - case 247: - return visitNode(cbNode, node.name) || - visitNode(cbNode, node.initializer); - case 218: - return visitNodes(cbNodes, node.decorators) || - visitNodes(cbNodes, node.modifiers) || - visitNode(cbNode, node.name) || - visitNode(cbNode, node.body); - case 221: - return visitNodes(cbNodes, node.decorators) || - visitNodes(cbNodes, node.modifiers) || - visitNode(cbNode, node.name) || - visitNode(cbNode, node.moduleReference); - case 222: - return visitNodes(cbNodes, node.decorators) || - visitNodes(cbNodes, node.modifiers) || - visitNode(cbNode, node.importClause) || - visitNode(cbNode, node.moduleSpecifier); - case 223: - return visitNode(cbNode, node.name) || - visitNode(cbNode, node.namedBindings); - case 224: - return visitNode(cbNode, node.name); - case 225: - case 229: - return visitNodes(cbNodes, node.elements); - case 228: - return visitNodes(cbNodes, node.decorators) || - visitNodes(cbNodes, node.modifiers) || - visitNode(cbNode, node.exportClause) || - visitNode(cbNode, node.moduleSpecifier); - case 226: - case 230: - return visitNode(cbNode, node.propertyName) || - visitNode(cbNode, node.name); - case 227: - return visitNodes(cbNodes, node.decorators) || - visitNodes(cbNodes, node.modifiers) || - visitNode(cbNode, node.expression); - case 183: - return visitNode(cbNode, node.head) || visitNodes(cbNodes, node.templateSpans); - case 190: - return visitNode(cbNode, node.expression) || visitNode(cbNode, node.literal); - case 136: - return visitNode(cbNode, node.expression); - case 243: - return visitNodes(cbNodes, node.types); - case 188: - return visitNode(cbNode, node.expression) || - visitNodes(cbNodes, node.typeArguments); - case 232: - return visitNode(cbNode, node.expression); - case 231: - return visitNodes(cbNodes, node.decorators); - case 233: - return visitNode(cbNode, node.openingElement) || - visitNodes(cbNodes, node.children) || - visitNode(cbNode, node.closingElement); - case 234: - case 235: - return visitNode(cbNode, node.tagName) || - visitNodes(cbNodes, node.attributes); - case 238: - return visitNode(cbNode, node.name) || - visitNode(cbNode, node.initializer); - case 239: - return visitNode(cbNode, node.expression); - case 240: - return visitNode(cbNode, node.expression); - case 237: - return visitNode(cbNode, node.tagName); - case 249: - return visitNode(cbNode, node.type); - case 253: - return visitNodes(cbNodes, node.types); - case 254: - return visitNodes(cbNodes, node.types); - case 252: - return visitNode(cbNode, node.elementType); - case 256: - return visitNode(cbNode, node.type); - case 255: - return visitNode(cbNode, node.type); - case 257: - return visitNodes(cbNodes, node.members); - case 259: - return visitNode(cbNode, node.name) || - visitNodes(cbNodes, node.typeArguments); - case 260: - return visitNode(cbNode, node.type); - case 261: - return visitNodes(cbNodes, node.parameters) || - visitNode(cbNode, node.type); - case 262: - return visitNode(cbNode, node.type); - case 263: - return visitNode(cbNode, node.type); - case 264: - return visitNode(cbNode, node.type); - case 258: - return visitNode(cbNode, node.name) || - visitNode(cbNode, node.type); - case 265: - return visitNodes(cbNodes, node.tags); - case 267: - return visitNode(cbNode, node.preParameterName) || - visitNode(cbNode, node.typeExpression) || - visitNode(cbNode, node.postParameterName); - case 268: - return visitNode(cbNode, node.typeExpression); - case 269: - return visitNode(cbNode, node.typeExpression); - case 270: - return visitNodes(cbNodes, node.typeParameters); - } - } - ts.forEachChild = forEachChild; - function createSourceFile(fileName, sourceText, languageVersion, setParentNodes) { - if (setParentNodes === void 0) { setParentNodes = false; } - var start = new Date().getTime(); - var result = Parser.parseSourceFile(fileName, sourceText, languageVersion, undefined, setParentNodes); - ts.parseTime += new Date().getTime() - start; - return result; - } - ts.createSourceFile = createSourceFile; - function updateSourceFile(sourceFile, newText, textChangeRange, aggressiveChecks) { - return IncrementalParser.updateSourceFile(sourceFile, newText, textChangeRange, aggressiveChecks); - } - ts.updateSourceFile = updateSourceFile; - function parseIsolatedJSDocComment(content, start, length) { - return Parser.JSDocParser.parseIsolatedJSDocComment(content, start, length); - } - ts.parseIsolatedJSDocComment = parseIsolatedJSDocComment; - function parseJSDocTypeExpressionForTests(content, start, length) { - return Parser.JSDocParser.parseJSDocTypeExpressionForTests(content, start, length); - } - ts.parseJSDocTypeExpressionForTests = parseJSDocTypeExpressionForTests; - var Parser; - (function (Parser) { - var scanner = ts.createScanner(2, true); - var disallowInAndDecoratorContext = 1 | 4; - var sourceFile; - var parseDiagnostics; - var syntaxCursor; - var token; - var sourceText; - var nodeCount; - var identifiers; - var identifierCount; - var parsingContext; - var contextFlags; - var parseErrorBeforeNextFinishedNode = false; - function parseSourceFile(fileName, _sourceText, languageVersion, _syntaxCursor, setParentNodes) { - initializeState(fileName, _sourceText, languageVersion, _syntaxCursor); - var result = parseSourceFileWorker(fileName, languageVersion, setParentNodes); - clearState(); - return result; - } - Parser.parseSourceFile = parseSourceFile; - function initializeState(fileName, _sourceText, languageVersion, _syntaxCursor) { - sourceText = _sourceText; - syntaxCursor = _syntaxCursor; - parseDiagnostics = []; - parsingContext = 0; - identifiers = {}; - identifierCount = 0; - nodeCount = 0; - contextFlags = ts.isJavaScript(fileName) ? 32 : 0; - parseErrorBeforeNextFinishedNode = false; - scanner.setText(sourceText); - scanner.setOnError(scanError); - scanner.setScriptTarget(languageVersion); - scanner.setLanguageVariant(ts.isTsx(fileName) ? 1 : 0); - } - function clearState() { - scanner.setText(""); - scanner.setOnError(undefined); - parseDiagnostics = undefined; - sourceFile = undefined; - identifiers = undefined; - syntaxCursor = undefined; - sourceText = undefined; - } - function parseSourceFileWorker(fileName, languageVersion, setParentNodes) { - sourceFile = createSourceFile(fileName, languageVersion); - token = nextToken(); - processReferenceComments(sourceFile); - sourceFile.statements = parseList(0, parseStatement); - ts.Debug.assert(token === 1); - sourceFile.endOfFileToken = parseTokenNode(); - setExternalModuleIndicator(sourceFile); - sourceFile.nodeCount = nodeCount; - sourceFile.identifierCount = identifierCount; - sourceFile.identifiers = identifiers; - sourceFile.parseDiagnostics = parseDiagnostics; - if (setParentNodes) { - fixupParentReferences(sourceFile); - } - if (ts.isJavaScript(fileName)) { - addJSDocComments(); - } - return sourceFile; - } - function addJSDocComments() { - forEachChild(sourceFile, visit); - return; - function visit(node) { - switch (node.kind) { - case 193: - case 213: - case 138: - addJSDocComment(node); - } - forEachChild(node, visit); - } - } - function addJSDocComment(node) { - var comments = ts.getLeadingCommentRangesOfNode(node, sourceFile); - if (comments) { - for (var _i = 0; _i < comments.length; _i++) { - var comment = comments[_i]; - var jsDocComment = JSDocParser.parseJSDocComment(node, comment.pos, comment.end - comment.pos); - if (jsDocComment) { - node.jsDocComment = jsDocComment; - } - } - } - } - function fixupParentReferences(sourceFile) { - var parent = sourceFile; - forEachChild(sourceFile, visitNode); - return; - function visitNode(n) { - if (n.parent !== parent) { - n.parent = parent; - var saveParent = parent; - parent = n; - forEachChild(n, visitNode); - parent = saveParent; - } - } - } - Parser.fixupParentReferences = fixupParentReferences; - function createSourceFile(fileName, languageVersion) { - var sourceFile = createNode(248, 0); - sourceFile.pos = 0; - sourceFile.end = sourceText.length; - sourceFile.text = sourceText; - sourceFile.bindDiagnostics = []; - sourceFile.languageVersion = languageVersion; - sourceFile.fileName = ts.normalizePath(fileName); - sourceFile.flags = ts.fileExtensionIs(sourceFile.fileName, ".d.ts") ? 8192 : 0; - sourceFile.languageVariant = ts.isTsx(sourceFile.fileName) ? 1 : 0; - return sourceFile; - } - function setContextFlag(val, flag) { - if (val) { - contextFlags |= flag; - } - else { - contextFlags &= ~flag; - } - } - function setDisallowInContext(val) { - setContextFlag(val, 1); - } - function setYieldContext(val) { - setContextFlag(val, 2); - } - function setDecoratorContext(val) { - setContextFlag(val, 4); - } - function setAwaitContext(val) { - setContextFlag(val, 8); - } - function doOutsideOfContext(context, func) { - var contextFlagsToClear = context & contextFlags; - if (contextFlagsToClear) { - setContextFlag(false, contextFlagsToClear); - var result = func(); - setContextFlag(true, contextFlagsToClear); - return result; - } - return func(); - } - function doInsideOfContext(context, func) { - var contextFlagsToSet = context & ~contextFlags; - if (contextFlagsToSet) { - setContextFlag(true, contextFlagsToSet); - var result = func(); - setContextFlag(false, contextFlagsToSet); - return result; - } - return func(); - } - function allowInAnd(func) { - return doOutsideOfContext(1, func); - } - function disallowInAnd(func) { - return doInsideOfContext(1, func); - } - function doInYieldContext(func) { - return doInsideOfContext(2, func); - } - function doOutsideOfYieldContext(func) { - return doOutsideOfContext(2, func); - } - function doInDecoratorContext(func) { - return doInsideOfContext(4, func); - } - function doInAwaitContext(func) { - return doInsideOfContext(8, func); - } - function doOutsideOfAwaitContext(func) { - return doOutsideOfContext(8, func); - } - function doInYieldAndAwaitContext(func) { - return doInsideOfContext(2 | 8, func); - } - function doOutsideOfYieldAndAwaitContext(func) { - return doOutsideOfContext(2 | 8, func); - } - function inContext(flags) { - return (contextFlags & flags) !== 0; - } - function inYieldContext() { - return inContext(2); - } - function inDisallowInContext() { - return inContext(1); - } - function inDecoratorContext() { - return inContext(4); - } - function inAwaitContext() { - return inContext(8); - } - function parseErrorAtCurrentToken(message, arg0) { - var start = scanner.getTokenPos(); - var length = scanner.getTextPos() - start; - parseErrorAtPosition(start, length, message, arg0); - } - function parseErrorAtPosition(start, length, message, arg0) { - var lastError = ts.lastOrUndefined(parseDiagnostics); - if (!lastError || start !== lastError.start) { - parseDiagnostics.push(ts.createFileDiagnostic(sourceFile, start, length, message, arg0)); - } - parseErrorBeforeNextFinishedNode = true; - } - function scanError(message, length) { - var pos = scanner.getTextPos(); - parseErrorAtPosition(pos, length || 0, message); - } - function getNodePos() { - return scanner.getStartPos(); - } - function getNodeEnd() { - return scanner.getStartPos(); - } - function nextToken() { - return token = scanner.scan(); - } - function getTokenPos(pos) { - return ts.skipTrivia(sourceText, pos); - } - function reScanGreaterToken() { - return token = scanner.reScanGreaterToken(); - } - function reScanSlashToken() { - return token = scanner.reScanSlashToken(); - } - function reScanTemplateToken() { - return token = scanner.reScanTemplateToken(); - } - function scanJsxIdentifier() { - return token = scanner.scanJsxIdentifier(); - } - function scanJsxText() { - return token = scanner.scanJsxToken(); - } - function speculationHelper(callback, isLookAhead) { - var saveToken = token; - var saveParseDiagnosticsLength = parseDiagnostics.length; - var saveParseErrorBeforeNextFinishedNode = parseErrorBeforeNextFinishedNode; - var saveContextFlags = contextFlags; - var result = isLookAhead - ? scanner.lookAhead(callback) - : scanner.tryScan(callback); - ts.Debug.assert(saveContextFlags === contextFlags); - if (!result || isLookAhead) { - token = saveToken; - parseDiagnostics.length = saveParseDiagnosticsLength; - parseErrorBeforeNextFinishedNode = saveParseErrorBeforeNextFinishedNode; - } - return result; - } - function lookAhead(callback) { - return speculationHelper(callback, true); - } - function tryParse(callback) { - return speculationHelper(callback, false); - } - function isIdentifier() { - if (token === 69) { - return true; - } - if (token === 114 && inYieldContext()) { - return false; - } - if (token === 119 && inAwaitContext()) { - return false; - } - return token > 105; - } - function parseExpected(kind, diagnosticMessage, shouldAdvance) { - if (shouldAdvance === void 0) { shouldAdvance = true; } - if (token === kind) { - if (shouldAdvance) { - nextToken(); - } - return true; - } - if (diagnosticMessage) { - parseErrorAtCurrentToken(diagnosticMessage); - } - else { - parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(kind)); - } - return false; - } - function parseOptional(t) { - if (token === t) { - nextToken(); - return true; - } - return false; - } - function parseOptionalToken(t) { - if (token === t) { - return parseTokenNode(); - } - return undefined; - } - function parseExpectedToken(t, reportAtCurrentPosition, diagnosticMessage, arg0) { - return parseOptionalToken(t) || - createMissingNode(t, reportAtCurrentPosition, diagnosticMessage, arg0); - } - function parseTokenNode() { - var node = createNode(token); - nextToken(); - return finishNode(node); - } - function canParseSemicolon() { - if (token === 23) { - return true; - } - return token === 16 || token === 1 || scanner.hasPrecedingLineBreak(); - } - function parseSemicolon() { - if (canParseSemicolon()) { - if (token === 23) { - nextToken(); - } - return true; - } - else { - return parseExpected(23); - } - } - function createNode(kind, pos) { - nodeCount++; - if (!(pos >= 0)) { - pos = scanner.getStartPos(); - } - return new (nodeConstructors[kind] || (nodeConstructors[kind] = ts.objectAllocator.getNodeConstructor(kind)))(pos, pos); - } - function finishNode(node, end) { - node.end = end === undefined ? scanner.getStartPos() : end; - if (contextFlags) { - node.parserContextFlags = contextFlags; - } - if (parseErrorBeforeNextFinishedNode) { - parseErrorBeforeNextFinishedNode = false; - node.parserContextFlags |= 16; - } - return node; - } - function createMissingNode(kind, reportAtCurrentPosition, diagnosticMessage, arg0) { - if (reportAtCurrentPosition) { - parseErrorAtPosition(scanner.getStartPos(), 0, diagnosticMessage, arg0); - } - else { - parseErrorAtCurrentToken(diagnosticMessage, arg0); - } - var result = createNode(kind, scanner.getStartPos()); - result.text = ""; - return finishNode(result); - } - function internIdentifier(text) { - text = ts.escapeIdentifier(text); - return ts.hasProperty(identifiers, text) ? identifiers[text] : (identifiers[text] = text); - } - function createIdentifier(isIdentifier, diagnosticMessage) { - identifierCount++; - if (isIdentifier) { - var node = createNode(69); - if (token !== 69) { - node.originalKeywordKind = token; - } - node.text = internIdentifier(scanner.getTokenValue()); - nextToken(); - return finishNode(node); - } - return createMissingNode(69, false, diagnosticMessage || ts.Diagnostics.Identifier_expected); - } - function parseIdentifier(diagnosticMessage) { - return createIdentifier(isIdentifier(), diagnosticMessage); - } - function parseIdentifierName() { - return createIdentifier(ts.tokenIsIdentifierOrKeyword(token)); - } - function isLiteralPropertyName() { - return ts.tokenIsIdentifierOrKeyword(token) || - token === 9 || - token === 8; - } - function parsePropertyNameWorker(allowComputedPropertyNames) { - if (token === 9 || token === 8) { - return parseLiteralNode(true); - } - if (allowComputedPropertyNames && token === 19) { - return parseComputedPropertyName(); - } - return parseIdentifierName(); - } - function parsePropertyName() { - return parsePropertyNameWorker(true); - } - function parseSimplePropertyName() { - return parsePropertyNameWorker(false); - } - function isSimplePropertyName() { - return token === 9 || token === 8 || ts.tokenIsIdentifierOrKeyword(token); - } - function parseComputedPropertyName() { - var node = createNode(136); - parseExpected(19); - node.expression = allowInAnd(parseExpression); - parseExpected(20); - return finishNode(node); - } - function parseContextualModifier(t) { - return token === t && tryParse(nextTokenCanFollowModifier); - } - function nextTokenCanFollowModifier() { - if (token === 74) { - return nextToken() === 81; - } - if (token === 82) { - nextToken(); - if (token === 77) { - return lookAhead(nextTokenIsClassOrFunction); - } - return token !== 37 && token !== 15 && canFollowModifier(); - } - if (token === 77) { - return nextTokenIsClassOrFunction(); - } - if (token === 113) { - nextToken(); - return canFollowModifier(); - } - nextToken(); - if (scanner.hasPrecedingLineBreak()) { - return false; - } - return canFollowModifier(); - } - function parseAnyContextualModifier() { - return ts.isModifier(token) && tryParse(nextTokenCanFollowModifier); - } - function canFollowModifier() { - return token === 19 - || token === 15 - || token === 37 - || isLiteralPropertyName(); - } - function nextTokenIsClassOrFunction() { - nextToken(); - return token === 73 || token === 87; - } - function isListElement(parsingContext, inErrorRecovery) { - var node = currentNode(parsingContext); - if (node) { - return true; - } - switch (parsingContext) { - case 0: - case 1: - case 3: - return !(token === 23 && inErrorRecovery) && isStartOfStatement(); - case 2: - return token === 71 || token === 77; - case 4: - return isStartOfTypeMember(); - case 5: - return lookAhead(isClassMemberStart) || (token === 23 && !inErrorRecovery); - case 6: - return token === 19 || isLiteralPropertyName(); - case 12: - return token === 19 || token === 37 || isLiteralPropertyName(); - case 9: - return isLiteralPropertyName(); - case 7: - if (token === 15) { - return lookAhead(isValidHeritageClauseObjectLiteral); - } - if (!inErrorRecovery) { - return isStartOfLeftHandSideExpression() && !isHeritageClauseExtendsOrImplementsKeyword(); - } - else { - return isIdentifier() && !isHeritageClauseExtendsOrImplementsKeyword(); - } - case 8: - return isIdentifierOrPattern(); - case 10: - return token === 24 || token === 22 || isIdentifierOrPattern(); - case 17: - return isIdentifier(); - case 11: - case 15: - return token === 24 || token === 22 || isStartOfExpression(); - case 16: - return isStartOfParameter(); - case 18: - case 19: - return token === 24 || isStartOfType(); - case 20: - return isHeritageClause(); - case 21: - return ts.tokenIsIdentifierOrKeyword(token); - case 13: - return ts.tokenIsIdentifierOrKeyword(token) || token === 15; - case 14: - return true; - case 22: - case 23: - case 25: - return JSDocParser.isJSDocType(); - case 24: - return isSimplePropertyName(); - } - ts.Debug.fail("Non-exhaustive case in 'isListElement'."); - } - function isValidHeritageClauseObjectLiteral() { - ts.Debug.assert(token === 15); - if (nextToken() === 16) { - var next = nextToken(); - return next === 24 || next === 15 || next === 83 || next === 106; - } - return true; - } - function nextTokenIsIdentifier() { - nextToken(); - return isIdentifier(); - } - function nextTokenIsIdentifierOrKeyword() { - nextToken(); - return ts.tokenIsIdentifierOrKeyword(token); - } - function isHeritageClauseExtendsOrImplementsKeyword() { - if (token === 106 || - token === 83) { - return lookAhead(nextTokenIsStartOfExpression); - } - return false; - } - function nextTokenIsStartOfExpression() { - nextToken(); - return isStartOfExpression(); - } - function isListTerminator(kind) { - if (token === 1) { - return true; - } - switch (kind) { - case 1: - case 2: - case 4: - case 5: - case 6: - case 12: - case 9: - case 21: - return token === 16; - case 3: - return token === 16 || token === 71 || token === 77; - case 7: - return token === 15 || token === 83 || token === 106; - case 8: - return isVariableDeclaratorListTerminator(); - case 17: - return token === 27 || token === 17 || token === 15 || token === 83 || token === 106; - case 11: - return token === 18 || token === 23; - case 15: - case 19: - case 10: - return token === 20; - case 16: - return token === 18 || token === 20; - case 18: - return token === 27 || token === 17; - case 20: - return token === 15 || token === 16; - case 13: - return token === 27 || token === 39; - case 14: - return token === 25 && lookAhead(nextTokenIsSlash); - case 22: - return token === 18 || token === 54 || token === 16; - case 23: - return token === 27 || token === 16; - case 25: - return token === 20 || token === 16; - case 24: - return token === 16; - } - } - function isVariableDeclaratorListTerminator() { - if (canParseSemicolon()) { - return true; - } - if (isInOrOfKeyword(token)) { - return true; - } - if (token === 34) { - return true; - } - return false; - } - function isInSomeParsingContext() { - for (var kind = 0; kind < 26; kind++) { - if (parsingContext & (1 << kind)) { - if (isListElement(kind, true) || isListTerminator(kind)) { - return true; - } - } - } - return false; - } - function parseList(kind, parseElement) { - var saveParsingContext = parsingContext; - parsingContext |= 1 << kind; - var result = []; - result.pos = getNodePos(); - while (!isListTerminator(kind)) { - if (isListElement(kind, false)) { - var element = parseListElement(kind, parseElement); - result.push(element); - continue; - } - if (abortParsingListOrMoveToNextToken(kind)) { - break; - } - } - result.end = getNodeEnd(); - parsingContext = saveParsingContext; - return result; - } - function parseListElement(parsingContext, parseElement) { - var node = currentNode(parsingContext); - if (node) { - return consumeNode(node); - } - return parseElement(); - } - function currentNode(parsingContext) { - if (parseErrorBeforeNextFinishedNode) { - return undefined; - } - if (!syntaxCursor) { - return undefined; - } - var node = syntaxCursor.currentNode(scanner.getStartPos()); - if (ts.nodeIsMissing(node)) { - return undefined; - } - if (node.intersectsChange) { - return undefined; - } - if (ts.containsParseError(node)) { - return undefined; - } - var nodeContextFlags = node.parserContextFlags & 31; - if (nodeContextFlags !== contextFlags) { - return undefined; - } - if (!canReuseNode(node, parsingContext)) { - return undefined; - } - return node; - } - function consumeNode(node) { - scanner.setTextPos(node.end); - nextToken(); - return node; - } - function canReuseNode(node, parsingContext) { - switch (parsingContext) { - case 5: - return isReusableClassMember(node); - case 2: - return isReusableSwitchClause(node); - case 0: - case 1: - case 3: - return isReusableStatement(node); - case 6: - return isReusableEnumMember(node); - case 4: - return isReusableTypeMember(node); - case 8: - return isReusableVariableDeclaration(node); - case 16: - return isReusableParameter(node); - case 20: - case 17: - case 19: - case 18: - case 11: - case 12: - case 7: - case 13: - case 14: - } - return false; - } - function isReusableClassMember(node) { - if (node) { - switch (node.kind) { - case 144: - case 149: - case 145: - case 146: - case 141: - case 191: - return true; - case 143: - var methodDeclaration = node; - var nameIsConstructor = methodDeclaration.name.kind === 69 && - methodDeclaration.name.originalKeywordKind === 121; - return !nameIsConstructor; - } - } - return false; - } - function isReusableSwitchClause(node) { - if (node) { - switch (node.kind) { - case 241: - case 242: - return true; - } - } - return false; - } - function isReusableStatement(node) { - if (node) { - switch (node.kind) { - case 213: - case 193: - case 192: - case 196: - case 195: - case 208: - case 204: - case 206: - case 203: - case 202: - case 200: - case 201: - case 199: - case 198: - case 205: - case 194: - case 209: - case 207: - case 197: - case 210: - case 222: - case 221: - case 228: - case 227: - case 218: - case 214: - case 215: - case 217: - case 216: - return true; - } - } - return false; - } - function isReusableEnumMember(node) { - return node.kind === 247; - } - function isReusableTypeMember(node) { - if (node) { - switch (node.kind) { - case 148: - case 142: - case 149: - case 140: - case 147: - return true; - } - } - return false; - } - function isReusableVariableDeclaration(node) { - if (node.kind !== 211) { - return false; - } - var variableDeclarator = node; - return variableDeclarator.initializer === undefined; - } - function isReusableParameter(node) { - if (node.kind !== 138) { - return false; - } - var parameter = node; - return parameter.initializer === undefined; - } - function abortParsingListOrMoveToNextToken(kind) { - parseErrorAtCurrentToken(parsingContextErrors(kind)); - if (isInSomeParsingContext()) { - return true; - } - nextToken(); - return false; - } - function parsingContextErrors(context) { - switch (context) { - case 0: return ts.Diagnostics.Declaration_or_statement_expected; - case 1: return ts.Diagnostics.Declaration_or_statement_expected; - case 2: return ts.Diagnostics.case_or_default_expected; - case 3: return ts.Diagnostics.Statement_expected; - case 4: return ts.Diagnostics.Property_or_signature_expected; - case 5: return ts.Diagnostics.Unexpected_token_A_constructor_method_accessor_or_property_was_expected; - case 6: return ts.Diagnostics.Enum_member_expected; - case 7: return ts.Diagnostics.Expression_expected; - case 8: return ts.Diagnostics.Variable_declaration_expected; - case 9: return ts.Diagnostics.Property_destructuring_pattern_expected; - case 10: return ts.Diagnostics.Array_element_destructuring_pattern_expected; - case 11: return ts.Diagnostics.Argument_expression_expected; - case 12: return ts.Diagnostics.Property_assignment_expected; - case 15: return ts.Diagnostics.Expression_or_comma_expected; - case 16: return ts.Diagnostics.Parameter_declaration_expected; - case 17: return ts.Diagnostics.Type_parameter_declaration_expected; - case 18: return ts.Diagnostics.Type_argument_expected; - case 19: return ts.Diagnostics.Type_expected; - case 20: return ts.Diagnostics.Unexpected_token_expected; - case 21: return ts.Diagnostics.Identifier_expected; - case 13: return ts.Diagnostics.Identifier_expected; - case 14: return ts.Diagnostics.Identifier_expected; - case 22: return ts.Diagnostics.Parameter_declaration_expected; - case 23: return ts.Diagnostics.Type_argument_expected; - case 25: return ts.Diagnostics.Type_expected; - case 24: return ts.Diagnostics.Property_assignment_expected; - } - } - ; - function parseDelimitedList(kind, parseElement, considerSemicolonAsDelimeter) { - var saveParsingContext = parsingContext; - parsingContext |= 1 << kind; - var result = []; - result.pos = getNodePos(); - var commaStart = -1; - while (true) { - if (isListElement(kind, false)) { - result.push(parseListElement(kind, parseElement)); - commaStart = scanner.getTokenPos(); - if (parseOptional(24)) { - continue; - } - commaStart = -1; - if (isListTerminator(kind)) { - break; - } - parseExpected(24); - if (considerSemicolonAsDelimeter && token === 23 && !scanner.hasPrecedingLineBreak()) { - nextToken(); - } - continue; - } - if (isListTerminator(kind)) { - break; - } - if (abortParsingListOrMoveToNextToken(kind)) { - break; - } - } - if (commaStart >= 0) { - result.hasTrailingComma = true; - } - result.end = getNodeEnd(); - parsingContext = saveParsingContext; - return result; - } - function createMissingList() { - var pos = getNodePos(); - var result = []; - result.pos = pos; - result.end = pos; - return result; - } - function parseBracketedList(kind, parseElement, open, close) { - if (parseExpected(open)) { - var result = parseDelimitedList(kind, parseElement); - parseExpected(close); - return result; - } - return createMissingList(); - } - function parseEntityName(allowReservedWords, diagnosticMessage) { - var entity = parseIdentifier(diagnosticMessage); - while (parseOptional(21)) { - var node = createNode(135, entity.pos); - node.left = entity; - node.right = parseRightSideOfDot(allowReservedWords); - entity = finishNode(node); - } - return entity; - } - function parseRightSideOfDot(allowIdentifierNames) { - if (scanner.hasPrecedingLineBreak() && ts.tokenIsIdentifierOrKeyword(token)) { - var matchesPattern = lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine); - if (matchesPattern) { - return createMissingNode(69, true, ts.Diagnostics.Identifier_expected); - } - } - return allowIdentifierNames ? parseIdentifierName() : parseIdentifier(); - } - function parseTemplateExpression() { - var template = createNode(183); - template.head = parseLiteralNode(); - ts.Debug.assert(template.head.kind === 12, "Template head has wrong token kind"); - var templateSpans = []; - templateSpans.pos = getNodePos(); - do { - templateSpans.push(parseTemplateSpan()); - } while (ts.lastOrUndefined(templateSpans).literal.kind === 13); - templateSpans.end = getNodeEnd(); - template.templateSpans = templateSpans; - return finishNode(template); - } - function parseTemplateSpan() { - var span = createNode(190); - span.expression = allowInAnd(parseExpression); - var literal; - if (token === 16) { - reScanTemplateToken(); - literal = parseLiteralNode(); - } - else { - literal = parseExpectedToken(14, false, ts.Diagnostics._0_expected, ts.tokenToString(16)); - } - span.literal = literal; - return finishNode(span); - } - function parseLiteralNode(internName) { - var node = createNode(token); - var text = scanner.getTokenValue(); - node.text = internName ? internIdentifier(text) : text; - if (scanner.hasExtendedUnicodeEscape()) { - node.hasExtendedUnicodeEscape = true; - } - if (scanner.isUnterminated()) { - node.isUnterminated = true; - } - var tokenPos = scanner.getTokenPos(); - nextToken(); - finishNode(node); - if (node.kind === 8 - && sourceText.charCodeAt(tokenPos) === 48 - && ts.isOctalDigit(sourceText.charCodeAt(tokenPos + 1))) { - node.flags |= 65536; - } - return node; - } - function parseTypeReferenceOrTypePredicate() { - var typeName = parseEntityName(false, ts.Diagnostics.Type_expected); - if (typeName.kind === 69 && token === 124 && !scanner.hasPrecedingLineBreak()) { - nextToken(); - var node_1 = createNode(150, typeName.pos); - node_1.parameterName = typeName; - node_1.type = parseType(); - return finishNode(node_1); - } - var node = createNode(151, typeName.pos); - node.typeName = typeName; - if (!scanner.hasPrecedingLineBreak() && token === 25) { - node.typeArguments = parseBracketedList(18, parseType, 25, 27); - } - return finishNode(node); - } - function parseTypeQuery() { - var node = createNode(154); - parseExpected(101); - node.exprName = parseEntityName(true); - return finishNode(node); - } - function parseTypeParameter() { - var node = createNode(137); - node.name = parseIdentifier(); - if (parseOptional(83)) { - if (isStartOfType() || !isStartOfExpression()) { - node.constraint = parseType(); - } - else { - node.expression = parseUnaryExpressionOrHigher(); - } - } - return finishNode(node); - } - function parseTypeParameters() { - if (token === 25) { - return parseBracketedList(17, parseTypeParameter, 25, 27); - } - } - function parseParameterType() { - if (parseOptional(54)) { - return token === 9 - ? parseLiteralNode(true) - : parseType(); - } - return undefined; - } - function isStartOfParameter() { - return token === 22 || isIdentifierOrPattern() || ts.isModifier(token) || token === 55; - } - function setModifiers(node, modifiers) { - if (modifiers) { - node.flags |= modifiers.flags; - node.modifiers = modifiers; - } - } - function parseParameter() { - var node = createNode(138); - node.decorators = parseDecorators(); - setModifiers(node, parseModifiers()); - node.dotDotDotToken = parseOptionalToken(22); - node.name = parseIdentifierOrPattern(); - if (ts.getFullWidth(node.name) === 0 && node.flags === 0 && ts.isModifier(token)) { - nextToken(); - } - node.questionToken = parseOptionalToken(53); - node.type = parseParameterType(); - node.initializer = parseBindingElementInitializer(true); - return finishNode(node); - } - function parseBindingElementInitializer(inParameter) { - return inParameter ? parseParameterInitializer() : parseNonParameterInitializer(); - } - function parseParameterInitializer() { - return parseInitializer(true); - } - function fillSignature(returnToken, yieldContext, awaitContext, requireCompleteParameterList, signature) { - var returnTokenRequired = returnToken === 34; - signature.typeParameters = parseTypeParameters(); - signature.parameters = parseParameterList(yieldContext, awaitContext, requireCompleteParameterList); - if (returnTokenRequired) { - parseExpected(returnToken); - signature.type = parseType(); - } - else if (parseOptional(returnToken)) { - signature.type = parseType(); - } - } - function parseParameterList(yieldContext, awaitContext, requireCompleteParameterList) { - if (parseExpected(17)) { - var savedYieldContext = inYieldContext(); - var savedAwaitContext = inAwaitContext(); - setYieldContext(yieldContext); - setAwaitContext(awaitContext); - var result = parseDelimitedList(16, parseParameter); - setYieldContext(savedYieldContext); - setAwaitContext(savedAwaitContext); - if (!parseExpected(18) && requireCompleteParameterList) { - return undefined; - } - return result; - } - return requireCompleteParameterList ? undefined : createMissingList(); - } - function parseTypeMemberSemicolon() { - if (parseOptional(24)) { - return; - } - parseSemicolon(); - } - function parseSignatureMember(kind) { - var node = createNode(kind); - if (kind === 148) { - parseExpected(92); - } - fillSignature(54, false, false, false, node); - parseTypeMemberSemicolon(); - return finishNode(node); - } - function isIndexSignature() { - if (token !== 19) { - return false; - } - return lookAhead(isUnambiguouslyIndexSignature); - } - function isUnambiguouslyIndexSignature() { - nextToken(); - if (token === 22 || token === 20) { - return true; - } - if (ts.isModifier(token)) { - nextToken(); - if (isIdentifier()) { - return true; - } - } - else if (!isIdentifier()) { - return false; - } - else { - nextToken(); - } - if (token === 54 || token === 24) { - return true; - } - if (token !== 53) { - return false; - } - nextToken(); - return token === 54 || token === 24 || token === 20; - } - function parseIndexSignatureDeclaration(fullStart, decorators, modifiers) { - var node = createNode(149, fullStart); - node.decorators = decorators; - setModifiers(node, modifiers); - node.parameters = parseBracketedList(16, parseParameter, 19, 20); - node.type = parseTypeAnnotation(); - parseTypeMemberSemicolon(); - return finishNode(node); - } - function parsePropertyOrMethodSignature() { - var fullStart = scanner.getStartPos(); - var name = parsePropertyName(); - var questionToken = parseOptionalToken(53); - if (token === 17 || token === 25) { - var method = createNode(142, fullStart); - method.name = name; - method.questionToken = questionToken; - fillSignature(54, false, false, false, method); - parseTypeMemberSemicolon(); - return finishNode(method); - } - else { - var property = createNode(140, fullStart); - property.name = name; - property.questionToken = questionToken; - property.type = parseTypeAnnotation(); - parseTypeMemberSemicolon(); - return finishNode(property); - } - } - function isStartOfTypeMember() { - switch (token) { - case 17: - case 25: - case 19: - return true; - default: - if (ts.isModifier(token)) { - var result = lookAhead(isStartOfIndexSignatureDeclaration); - if (result) { - return result; - } - } - return isLiteralPropertyName() && lookAhead(isTypeMemberWithLiteralPropertyName); - } - } - function isStartOfIndexSignatureDeclaration() { - while (ts.isModifier(token)) { - nextToken(); - } - return isIndexSignature(); - } - function isTypeMemberWithLiteralPropertyName() { - nextToken(); - return token === 17 || - token === 25 || - token === 53 || - token === 54 || - canParseSemicolon(); - } - function parseTypeMember() { - switch (token) { - case 17: - case 25: - return parseSignatureMember(147); - case 19: - return isIndexSignature() - ? parseIndexSignatureDeclaration(scanner.getStartPos(), undefined, undefined) - : parsePropertyOrMethodSignature(); - case 92: - if (lookAhead(isStartOfConstructSignature)) { - return parseSignatureMember(148); - } - case 9: - case 8: - return parsePropertyOrMethodSignature(); - default: - if (ts.isModifier(token)) { - var result = tryParse(parseIndexSignatureWithModifiers); - if (result) { - return result; - } - } - if (ts.tokenIsIdentifierOrKeyword(token)) { - return parsePropertyOrMethodSignature(); - } - } - } - function parseIndexSignatureWithModifiers() { - var fullStart = scanner.getStartPos(); - var decorators = parseDecorators(); - var modifiers = parseModifiers(); - return isIndexSignature() - ? parseIndexSignatureDeclaration(fullStart, decorators, modifiers) - : undefined; - } - function isStartOfConstructSignature() { - nextToken(); - return token === 17 || token === 25; - } - function parseTypeLiteral() { - var node = createNode(155); - node.members = parseObjectTypeMembers(); - return finishNode(node); - } - function parseObjectTypeMembers() { - var members; - if (parseExpected(15)) { - members = parseList(4, parseTypeMember); - parseExpected(16); - } - else { - members = createMissingList(); - } - return members; - } - function parseTupleType() { - var node = createNode(157); - node.elementTypes = parseBracketedList(19, parseType, 19, 20); - return finishNode(node); - } - function parseParenthesizedType() { - var node = createNode(160); - parseExpected(17); - node.type = parseType(); - parseExpected(18); - return finishNode(node); - } - function parseFunctionOrConstructorType(kind) { - var node = createNode(kind); - if (kind === 153) { - parseExpected(92); - } - fillSignature(34, false, false, false, node); - return finishNode(node); - } - function parseKeywordAndNoDot() { - var node = parseTokenNode(); - return token === 21 ? undefined : node; - } - function parseNonArrayType() { - switch (token) { - case 117: - case 130: - case 128: - case 120: - case 131: - var node = tryParse(parseKeywordAndNoDot); - return node || parseTypeReferenceOrTypePredicate(); - case 103: - case 97: - return parseTokenNode(); - case 101: - return parseTypeQuery(); - case 15: - return parseTypeLiteral(); - case 19: - return parseTupleType(); - case 17: - return parseParenthesizedType(); - default: - return parseTypeReferenceOrTypePredicate(); - } - } - function isStartOfType() { - switch (token) { - case 117: - case 130: - case 128: - case 120: - case 131: - case 103: - case 97: - case 101: - case 15: - case 19: - case 25: - case 92: - return true; - case 17: - return lookAhead(isStartOfParenthesizedOrFunctionType); - default: - return isIdentifier(); - } - } - function isStartOfParenthesizedOrFunctionType() { - nextToken(); - return token === 18 || isStartOfParameter() || isStartOfType(); - } - function parseArrayTypeOrHigher() { - var type = parseNonArrayType(); - while (!scanner.hasPrecedingLineBreak() && parseOptional(19)) { - parseExpected(20); - var node = createNode(156, type.pos); - node.elementType = type; - type = finishNode(node); - } - return type; - } - function parseUnionOrIntersectionType(kind, parseConstituentType, operator) { - var type = parseConstituentType(); - if (token === operator) { - var types = [type]; - types.pos = type.pos; - while (parseOptional(operator)) { - types.push(parseConstituentType()); - } - types.end = getNodeEnd(); - var node = createNode(kind, type.pos); - node.types = types; - type = finishNode(node); - } - return type; - } - function parseIntersectionTypeOrHigher() { - return parseUnionOrIntersectionType(159, parseArrayTypeOrHigher, 46); - } - function parseUnionTypeOrHigher() { - return parseUnionOrIntersectionType(158, parseIntersectionTypeOrHigher, 47); - } - function isStartOfFunctionType() { - if (token === 25) { - return true; - } - return token === 17 && lookAhead(isUnambiguouslyStartOfFunctionType); - } - function isUnambiguouslyStartOfFunctionType() { - nextToken(); - if (token === 18 || token === 22) { - return true; - } - if (isIdentifier() || ts.isModifier(token)) { - nextToken(); - if (token === 54 || token === 24 || - token === 53 || token === 56 || - isIdentifier() || ts.isModifier(token)) { - return true; - } - if (token === 18) { - nextToken(); - if (token === 34) { - return true; - } - } - } - return false; - } - function parseType() { - return doOutsideOfContext(10, parseTypeWorker); - } - function parseTypeWorker() { - if (isStartOfFunctionType()) { - return parseFunctionOrConstructorType(152); - } - if (token === 92) { - return parseFunctionOrConstructorType(153); - } - return parseUnionTypeOrHigher(); - } - function parseTypeAnnotation() { - return parseOptional(54) ? parseType() : undefined; - } - function isStartOfLeftHandSideExpression() { - switch (token) { - case 97: - case 95: - case 93: - case 99: - case 84: - 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: - return true; - default: - return isIdentifier(); - } - } - function isStartOfExpression() { - if (isStartOfLeftHandSideExpression()) { - return true; - } - switch (token) { - case 35: - case 36: - case 50: - case 49: - case 78: - case 101: - case 103: - case 41: - case 42: - case 25: - case 119: - case 114: - return true; - default: - if (isBinaryOperator()) { - return true; - } - return isIdentifier(); - } - } - function isStartOfExpressionStatement() { - return token !== 15 && - token !== 87 && - token !== 73 && - token !== 55 && - isStartOfExpression(); - } - function allowInAndParseExpression() { - return allowInAnd(parseExpression); - } - function parseExpression() { - var saveDecoratorContext = inDecoratorContext(); - if (saveDecoratorContext) { - setDecoratorContext(false); - } - var expr = parseAssignmentExpressionOrHigher(); - var operatorToken; - while ((operatorToken = parseOptionalToken(24))) { - expr = makeBinaryExpression(expr, operatorToken, parseAssignmentExpressionOrHigher()); - } - if (saveDecoratorContext) { - setDecoratorContext(true); - } - return expr; - } - function parseInitializer(inParameter) { - if (token !== 56) { - if (scanner.hasPrecedingLineBreak() || (inParameter && token === 15) || !isStartOfExpression()) { - return undefined; - } - } - parseExpected(56); - return parseAssignmentExpressionOrHigher(); - } - function parseAssignmentExpressionOrHigher() { - if (isYieldExpression()) { - return parseYieldExpression(); - } - var arrowExpression = tryParseParenthesizedArrowFunctionExpression(); - if (arrowExpression) { - return arrowExpression; - } - var expr = parseBinaryExpressionOrHigher(0); - if (expr.kind === 69 && token === 34) { - return parseSimpleArrowFunctionExpression(expr); - } - if (ts.isLeftHandSideExpression(expr) && ts.isAssignmentOperator(reScanGreaterToken())) { - return makeBinaryExpression(expr, parseTokenNode(), parseAssignmentExpressionOrHigher()); - } - return parseConditionalExpressionRest(expr); - } - function isYieldExpression() { - if (token === 114) { - if (inYieldContext()) { - return true; - } - return lookAhead(nextTokenIsIdentifierOrKeywordOrNumberOnSameLine); - } - return false; - } - function nextTokenIsIdentifierOnSameLine() { - nextToken(); - return !scanner.hasPrecedingLineBreak() && isIdentifier(); - } - function parseYieldExpression() { - var node = createNode(184); - nextToken(); - if (!scanner.hasPrecedingLineBreak() && - (token === 37 || isStartOfExpression())) { - node.asteriskToken = parseOptionalToken(37); - node.expression = parseAssignmentExpressionOrHigher(); - return finishNode(node); - } - else { - return finishNode(node); - } - } - function parseSimpleArrowFunctionExpression(identifier) { - ts.Debug.assert(token === 34, "parseSimpleArrowFunctionExpression should only have been called if we had a =>"); - var node = createNode(174, identifier.pos); - var parameter = createNode(138, identifier.pos); - parameter.name = identifier; - finishNode(parameter); - node.parameters = [parameter]; - node.parameters.pos = parameter.pos; - node.parameters.end = parameter.end; - node.equalsGreaterThanToken = parseExpectedToken(34, false, ts.Diagnostics._0_expected, "=>"); - node.body = parseArrowFunctionExpressionBody(false); - return finishNode(node); - } - function tryParseParenthesizedArrowFunctionExpression() { - var triState = isParenthesizedArrowFunctionExpression(); - if (triState === 0) { - return undefined; - } - var arrowFunction = triState === 1 - ? parseParenthesizedArrowFunctionExpressionHead(true) - : tryParse(parsePossibleParenthesizedArrowFunctionExpressionHead); - if (!arrowFunction) { - return undefined; - } - var isAsync = !!(arrowFunction.flags & 512); - var lastToken = token; - arrowFunction.equalsGreaterThanToken = parseExpectedToken(34, false, ts.Diagnostics._0_expected, "=>"); - arrowFunction.body = (lastToken === 34 || lastToken === 15) - ? parseArrowFunctionExpressionBody(isAsync) - : parseIdentifier(); - return finishNode(arrowFunction); - } - function isParenthesizedArrowFunctionExpression() { - if (token === 17 || token === 25 || token === 118) { - return lookAhead(isParenthesizedArrowFunctionExpressionWorker); - } - if (token === 34) { - return 1; - } - return 0; - } - function isParenthesizedArrowFunctionExpressionWorker() { - if (token === 118) { - nextToken(); - if (scanner.hasPrecedingLineBreak()) { - return 0; - } - if (token !== 17 && token !== 25) { - return 0; - } - } - var first = token; - var second = nextToken(); - if (first === 17) { - if (second === 18) { - var third = nextToken(); - switch (third) { - case 34: - case 54: - case 15: - return 1; - default: - return 0; - } - } - if (second === 19 || second === 15) { - return 2; - } - if (second === 22) { - return 1; - } - if (!isIdentifier()) { - return 0; - } - if (nextToken() === 54) { - return 1; - } - return 2; - } - else { - ts.Debug.assert(first === 25); - if (!isIdentifier()) { - return 0; - } - if (sourceFile.languageVariant === 1) { - var isArrowFunctionInJsx = lookAhead(function () { - var third = nextToken(); - if (third === 83) { - var fourth = nextToken(); - switch (fourth) { - case 56: - case 27: - return false; - default: - return true; - } - } - else if (third === 24) { - return true; - } - return false; - }); - if (isArrowFunctionInJsx) { - return 1; - } - return 0; - } - return 2; - } - } - function parsePossibleParenthesizedArrowFunctionExpressionHead() { - return parseParenthesizedArrowFunctionExpressionHead(false); - } - function parseParenthesizedArrowFunctionExpressionHead(allowAmbiguity) { - var node = createNode(174); - setModifiers(node, parseModifiersForArrowFunction()); - var isAsync = !!(node.flags & 512); - fillSignature(54, false, isAsync, !allowAmbiguity, node); - if (!node.parameters) { - return undefined; - } - if (!allowAmbiguity && token !== 34 && token !== 15) { - return undefined; - } - return node; - } - function parseArrowFunctionExpressionBody(isAsync) { - if (token === 15) { - return parseFunctionBlock(false, isAsync, false); - } - if (token !== 23 && - token !== 87 && - token !== 73 && - isStartOfStatement() && - !isStartOfExpressionStatement()) { - return parseFunctionBlock(false, isAsync, true); - } - return isAsync - ? doInAwaitContext(parseAssignmentExpressionOrHigher) - : doOutsideOfAwaitContext(parseAssignmentExpressionOrHigher); - } - function parseConditionalExpressionRest(leftOperand) { - var questionToken = parseOptionalToken(53); - if (!questionToken) { - return leftOperand; - } - var node = createNode(182, 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.whenFalse = parseAssignmentExpressionOrHigher(); - return finishNode(node); - } - function parseBinaryExpressionOrHigher(precedence) { - var leftOperand = parseUnaryExpressionOrHigher(); - return parseBinaryExpressionRest(precedence, leftOperand); - } - function isInOrOfKeyword(t) { - return t === 90 || t === 134; - } - function parseBinaryExpressionRest(precedence, leftOperand) { - while (true) { - reScanGreaterToken(); - var newPrecedence = getBinaryOperatorPrecedence(); - var consumeCurrentOperator = token === 38 ? - newPrecedence >= precedence : - newPrecedence > precedence; - if (!consumeCurrentOperator) { - break; - } - if (token === 90 && inDisallowInContext()) { - break; - } - if (token === 116) { - if (scanner.hasPrecedingLineBreak()) { - break; - } - else { - nextToken(); - leftOperand = makeAsExpression(leftOperand, parseType()); - } - } - else { - leftOperand = makeBinaryExpression(leftOperand, parseTokenNode(), parseBinaryExpressionOrHigher(newPrecedence)); - } - } - return leftOperand; - } - function isBinaryOperator() { - if (inDisallowInContext() && token === 90) { - return false; - } - return getBinaryOperatorPrecedence() > 0; - } - function getBinaryOperatorPrecedence() { - switch (token) { - case 52: - return 1; - case 51: - return 2; - case 47: - return 3; - case 48: - return 4; - case 46: - return 5; - case 30: - case 31: - case 32: - case 33: - return 6; - case 25: - case 27: - case 28: - case 29: - case 91: - case 90: - case 116: - return 7; - case 43: - case 44: - case 45: - return 8; - case 35: - case 36: - return 9; - case 37: - case 39: - case 40: - return 10; - case 38: - return 11; - } - return -1; - } - function makeBinaryExpression(left, operatorToken, right) { - var node = createNode(181, left.pos); - node.left = left; - node.operatorToken = operatorToken; - node.right = right; - return finishNode(node); - } - function makeAsExpression(left, right) { - var node = createNode(189, left.pos); - node.expression = left; - node.type = right; - return finishNode(node); - } - function parsePrefixUnaryExpression() { - var node = createNode(179); - node.operator = token; - nextToken(); - node.operand = parseSimpleUnaryExpression(); - return finishNode(node); - } - function parseDeleteExpression() { - var node = createNode(175); - nextToken(); - node.expression = parseSimpleUnaryExpression(); - return finishNode(node); - } - function parseTypeOfExpression() { - var node = createNode(176); - nextToken(); - node.expression = parseSimpleUnaryExpression(); - return finishNode(node); - } - function parseVoidExpression() { - var node = createNode(177); - nextToken(); - node.expression = parseSimpleUnaryExpression(); - return finishNode(node); - } - function isAwaitExpression() { - if (token === 119) { - if (inAwaitContext()) { - return true; - } - return lookAhead(nextTokenIsIdentifierOnSameLine); - } - return false; - } - function parseAwaitExpression() { - var node = createNode(178); - nextToken(); - node.expression = parseSimpleUnaryExpression(); - return finishNode(node); - } - function parseUnaryExpressionOrHigher() { - if (isAwaitExpression()) { - return parseAwaitExpression(); - } - if (isIncrementExpression()) { - var incrementExpression = parseIncrementExpression(); - return token === 38 ? - parseBinaryExpressionRest(getBinaryOperatorPrecedence(), incrementExpression) : - incrementExpression; - } - var unaryOperator = token; - var simpleUnaryExpression = parseSimpleUnaryExpression(); - if (token === 38) { - var diagnostic; - var start = ts.skipTrivia(sourceText, simpleUnaryExpression.pos); - if (simpleUnaryExpression.kind === 171) { - parseErrorAtPosition(start, simpleUnaryExpression.end - start, ts.Diagnostics.A_type_assertion_expression_is_not_allowed_in_the_left_hand_side_of_an_exponentiation_expression_Consider_enclosing_the_expression_in_parentheses); - } - else { - parseErrorAtPosition(start, simpleUnaryExpression.end - start, ts.Diagnostics.An_unary_expression_with_the_0_operator_is_not_allowed_in_the_left_hand_side_of_an_exponentiation_expression_Consider_enclosing_the_expression_in_parentheses, ts.tokenToString(unaryOperator)); - } - } - return simpleUnaryExpression; - } - function parseSimpleUnaryExpression() { - switch (token) { - case 35: - case 36: - case 50: - case 49: - return parsePrefixUnaryExpression(); - case 78: - return parseDeleteExpression(); - case 101: - return parseTypeOfExpression(); - case 103: - return parseVoidExpression(); - case 25: - return parseTypeAssertion(); - default: - return parseIncrementExpression(); - } - } - function isIncrementExpression() { - switch (token) { - case 35: - case 36: - case 50: - case 49: - case 78: - case 101: - case 103: - return false; - case 25: - if (sourceFile.languageVariant !== 1) { - return false; - } - default: - return true; - } - } - function parseIncrementExpression() { - if (token === 41 || token === 42) { - var node = createNode(179); - node.operator = token; - nextToken(); - node.operand = parseLeftHandSideExpressionOrHigher(); - return finishNode(node); - } - else if (sourceFile.languageVariant === 1 && token === 25 && lookAhead(nextTokenIsIdentifierOrKeyword)) { - return parseJsxElementOrSelfClosingElement(true); - } - var expression = parseLeftHandSideExpressionOrHigher(); - ts.Debug.assert(ts.isLeftHandSideExpression(expression)); - if ((token === 41 || token === 42) && !scanner.hasPrecedingLineBreak()) { - var node = createNode(180, expression.pos); - node.operand = expression; - node.operator = token; - nextToken(); - return finishNode(node); - } - return expression; - } - function parseLeftHandSideExpressionOrHigher() { - var expression = token === 95 - ? parseSuperExpression() - : parseMemberExpressionOrHigher(); - return parseCallExpressionRest(expression); - } - function parseMemberExpressionOrHigher() { - var expression = parsePrimaryExpression(); - return parseMemberExpressionRest(expression); - } - function parseSuperExpression() { - var expression = parseTokenNode(); - if (token === 17 || token === 21 || token === 19) { - return expression; - } - var node = createNode(166, expression.pos); - node.expression = expression; - node.dotToken = parseExpectedToken(21, false, ts.Diagnostics.super_must_be_followed_by_an_argument_list_or_member_access); - node.name = parseRightSideOfDot(true); - return finishNode(node); - } - function parseJsxElementOrSelfClosingElement(inExpressionContext) { - var opening = parseJsxOpeningOrSelfClosingElement(inExpressionContext); - var result; - if (opening.kind === 235) { - var node = createNode(233, opening.pos); - node.openingElement = opening; - node.children = parseJsxChildren(node.openingElement.tagName); - node.closingElement = parseJsxClosingElement(inExpressionContext); - result = finishNode(node); - } - else { - ts.Debug.assert(opening.kind === 234); - result = opening; - } - if (inExpressionContext && token === 25) { - var invalidElement = tryParse(function () { return parseJsxElementOrSelfClosingElement(true); }); - if (invalidElement) { - parseErrorAtCurrentToken(ts.Diagnostics.JSX_expressions_must_have_one_parent_element); - var badNode = createNode(181, result.pos); - badNode.end = invalidElement.end; - badNode.left = result; - badNode.right = invalidElement; - badNode.operatorToken = createMissingNode(24, false, undefined); - badNode.operatorToken.pos = badNode.operatorToken.end = badNode.right.pos; - return badNode; - } - } - return result; - } - function parseJsxText() { - var node = createNode(236, scanner.getStartPos()); - token = scanner.scanJsxToken(); - return finishNode(node); - } - function parseJsxChild() { - switch (token) { - case 236: - return parseJsxText(); - case 15: - return parseJsxExpression(false); - case 25: - return parseJsxElementOrSelfClosingElement(false); - } - ts.Debug.fail("Unknown JSX child kind " + token); - } - function parseJsxChildren(openingTagName) { - var result = []; - result.pos = scanner.getStartPos(); - var saveParsingContext = parsingContext; - parsingContext |= 1 << 14; - while (true) { - token = scanner.reScanJsxToken(); - if (token === 26) { - break; - } - else if (token === 1) { - parseErrorAtCurrentToken(ts.Diagnostics.Expected_corresponding_JSX_closing_tag_for_0, ts.getTextOfNodeFromSourceText(sourceText, openingTagName)); - break; - } - result.push(parseJsxChild()); - } - result.end = scanner.getTokenPos(); - parsingContext = saveParsingContext; - return result; - } - function parseJsxOpeningOrSelfClosingElement(inExpressionContext) { - var fullStart = scanner.getStartPos(); - parseExpected(25); - var tagName = parseJsxElementName(); - var attributes = parseList(13, parseJsxAttribute); - var node; - if (token === 27) { - node = createNode(235, fullStart); - scanJsxText(); - } - else { - parseExpected(39); - if (inExpressionContext) { - parseExpected(27); - } - else { - parseExpected(27, undefined, false); - scanJsxText(); - } - node = createNode(234, fullStart); - } - node.tagName = tagName; - node.attributes = attributes; - return finishNode(node); - } - function parseJsxElementName() { - scanJsxIdentifier(); - var elementName = parseIdentifierName(); - while (parseOptional(21)) { - scanJsxIdentifier(); - var node = createNode(135, elementName.pos); - node.left = elementName; - node.right = parseIdentifierName(); - elementName = finishNode(node); - } - return elementName; - } - function parseJsxExpression(inExpressionContext) { - var node = createNode(240); - parseExpected(15); - if (token !== 16) { - node.expression = parseExpression(); - } - if (inExpressionContext) { - parseExpected(16); - } - else { - parseExpected(16, undefined, false); - scanJsxText(); - } - return finishNode(node); - } - function parseJsxAttribute() { - if (token === 15) { - return parseJsxSpreadAttribute(); - } - scanJsxIdentifier(); - var node = createNode(238); - node.name = parseIdentifierName(); - if (parseOptional(56)) { - switch (token) { - case 9: - node.initializer = parseLiteralNode(); - break; - default: - node.initializer = parseJsxExpression(true); - break; - } - } - return finishNode(node); - } - function parseJsxSpreadAttribute() { - var node = createNode(239); - parseExpected(15); - parseExpected(22); - node.expression = parseExpression(); - parseExpected(16); - return finishNode(node); - } - function parseJsxClosingElement(inExpressionContext) { - var node = createNode(237); - parseExpected(26); - node.tagName = parseJsxElementName(); - if (inExpressionContext) { - parseExpected(27); - } - else { - parseExpected(27, undefined, false); - scanJsxText(); - } - return finishNode(node); - } - function parseTypeAssertion() { - var node = createNode(171); - parseExpected(25); - node.type = parseType(); - parseExpected(27); - node.expression = parseSimpleUnaryExpression(); - return finishNode(node); - } - function parseMemberExpressionRest(expression) { - while (true) { - var dotToken = parseOptionalToken(21); - if (dotToken) { - var propertyAccess = createNode(166, expression.pos); - propertyAccess.expression = expression; - propertyAccess.dotToken = dotToken; - propertyAccess.name = parseRightSideOfDot(true); - expression = finishNode(propertyAccess); - continue; - } - if (!inDecoratorContext() && parseOptional(19)) { - var indexedAccess = createNode(167, expression.pos); - indexedAccess.expression = expression; - if (token !== 20) { - indexedAccess.argumentExpression = allowInAnd(parseExpression); - if (indexedAccess.argumentExpression.kind === 9 || indexedAccess.argumentExpression.kind === 8) { - var literal = indexedAccess.argumentExpression; - literal.text = internIdentifier(literal.text); - } - } - parseExpected(20); - expression = finishNode(indexedAccess); - continue; - } - if (token === 11 || token === 12) { - var tagExpression = createNode(170, expression.pos); - tagExpression.tag = expression; - tagExpression.template = token === 11 - ? parseLiteralNode() - : parseTemplateExpression(); - expression = finishNode(tagExpression); - continue; - } - return expression; - } - } - function parseCallExpressionRest(expression) { - while (true) { - expression = parseMemberExpressionRest(expression); - if (token === 25) { - var typeArguments = tryParse(parseTypeArgumentsInExpression); - if (!typeArguments) { - return expression; - } - var callExpr = createNode(168, expression.pos); - callExpr.expression = expression; - callExpr.typeArguments = typeArguments; - callExpr.arguments = parseArgumentList(); - expression = finishNode(callExpr); - continue; - } - else if (token === 17) { - var callExpr = createNode(168, expression.pos); - callExpr.expression = expression; - callExpr.arguments = parseArgumentList(); - expression = finishNode(callExpr); - continue; - } - return expression; - } - } - function parseArgumentList() { - parseExpected(17); - var result = parseDelimitedList(11, parseArgumentExpression); - parseExpected(18); - return result; - } - function parseTypeArgumentsInExpression() { - if (!parseOptional(25)) { - return undefined; - } - var typeArguments = parseDelimitedList(18, parseType); - if (!parseExpected(27)) { - return undefined; - } - return typeArguments && canFollowTypeArgumentsInExpression() - ? typeArguments - : undefined; - } - function canFollowTypeArgumentsInExpression() { - switch (token) { - case 17: - case 21: - case 18: - case 20: - case 54: - case 23: - case 53: - case 30: - case 32: - case 31: - case 33: - case 51: - case 52: - case 48: - case 46: - case 47: - case 16: - case 1: - return true; - case 24: - case 15: - default: - return false; - } - } - function parsePrimaryExpression() { - switch (token) { - case 8: - case 9: - case 11: - return parseLiteralNode(); - case 97: - case 95: - case 93: - case 99: - case 84: - return parseTokenNode(); - case 17: - return parseParenthesizedExpression(); - case 19: - return parseArrayLiteralExpression(); - case 15: - return parseObjectLiteralExpression(); - case 118: - if (!lookAhead(nextTokenIsFunctionKeywordOnSameLine)) { - break; - } - return parseFunctionExpression(); - case 73: - return parseClassExpression(); - case 87: - return parseFunctionExpression(); - case 92: - return parseNewExpression(); - case 39: - case 61: - if (reScanSlashToken() === 10) { - return parseLiteralNode(); - } - break; - case 12: - return parseTemplateExpression(); - } - return parseIdentifier(ts.Diagnostics.Expression_expected); - } - function parseParenthesizedExpression() { - var node = createNode(172); - parseExpected(17); - node.expression = allowInAnd(parseExpression); - parseExpected(18); - return finishNode(node); - } - function parseSpreadElement() { - var node = createNode(185); - parseExpected(22); - node.expression = parseAssignmentExpressionOrHigher(); - return finishNode(node); - } - function parseArgumentOrArrayLiteralElement() { - return token === 22 ? parseSpreadElement() : - token === 24 ? createNode(187) : - parseAssignmentExpressionOrHigher(); - } - function parseArgumentExpression() { - return doOutsideOfContext(disallowInAndDecoratorContext, parseArgumentOrArrayLiteralElement); - } - function parseArrayLiteralExpression() { - var node = createNode(164); - parseExpected(19); - if (scanner.hasPrecedingLineBreak()) - node.flags |= 2048; - node.elements = parseDelimitedList(15, parseArgumentOrArrayLiteralElement); - parseExpected(20); - return finishNode(node); - } - function tryParseAccessorDeclaration(fullStart, decorators, modifiers) { - if (parseContextualModifier(123)) { - return parseAccessorDeclaration(145, fullStart, decorators, modifiers); - } - else if (parseContextualModifier(129)) { - return parseAccessorDeclaration(146, fullStart, decorators, modifiers); - } - return undefined; - } - function parseObjectLiteralElement() { - var fullStart = scanner.getStartPos(); - var decorators = parseDecorators(); - var modifiers = parseModifiers(); - var accessor = tryParseAccessorDeclaration(fullStart, decorators, modifiers); - if (accessor) { - return accessor; - } - var asteriskToken = parseOptionalToken(37); - var tokenIsIdentifier = isIdentifier(); - var nameToken = token; - var propertyName = parsePropertyName(); - var questionToken = parseOptionalToken(53); - if (asteriskToken || token === 17 || token === 25) { - return parseMethodDeclaration(fullStart, decorators, modifiers, asteriskToken, propertyName, questionToken); - } - var isShorthandPropertyAssignment = tokenIsIdentifier && (token === 24 || token === 16 || token === 56); - if (isShorthandPropertyAssignment) { - var shorthandDeclaration = createNode(246, fullStart); - shorthandDeclaration.name = propertyName; - shorthandDeclaration.questionToken = questionToken; - var equalsToken = parseOptionalToken(56); - if (equalsToken) { - shorthandDeclaration.equalsToken = equalsToken; - shorthandDeclaration.objectAssignmentInitializer = allowInAnd(parseAssignmentExpressionOrHigher); - } - return finishNode(shorthandDeclaration); - } - else { - var propertyAssignment = createNode(245, fullStart); - propertyAssignment.name = propertyName; - propertyAssignment.questionToken = questionToken; - parseExpected(54); - propertyAssignment.initializer = allowInAnd(parseAssignmentExpressionOrHigher); - return finishNode(propertyAssignment); - } - } - function parseObjectLiteralExpression() { - var node = createNode(165); - parseExpected(15); - if (scanner.hasPrecedingLineBreak()) { - node.flags |= 2048; - } - node.properties = parseDelimitedList(12, parseObjectLiteralElement, true); - parseExpected(16); - return finishNode(node); - } - function parseFunctionExpression() { - var saveDecoratorContext = inDecoratorContext(); - if (saveDecoratorContext) { - setDecoratorContext(false); - } - var node = createNode(173); - setModifiers(node, parseModifiers()); - parseExpected(87); - node.asteriskToken = parseOptionalToken(37); - var isGenerator = !!node.asteriskToken; - var isAsync = !!(node.flags & 512); - node.name = - isGenerator && isAsync ? doInYieldAndAwaitContext(parseOptionalIdentifier) : - isGenerator ? doInYieldContext(parseOptionalIdentifier) : - isAsync ? doInAwaitContext(parseOptionalIdentifier) : - parseOptionalIdentifier(); - fillSignature(54, isGenerator, isAsync, false, node); - node.body = parseFunctionBlock(isGenerator, isAsync, false); - if (saveDecoratorContext) { - setDecoratorContext(true); - } - return finishNode(node); - } - function parseOptionalIdentifier() { - return isIdentifier() ? parseIdentifier() : undefined; - } - function parseNewExpression() { - var node = createNode(169); - parseExpected(92); - node.expression = parseMemberExpressionOrHigher(); - node.typeArguments = tryParse(parseTypeArgumentsInExpression); - if (node.typeArguments || token === 17) { - node.arguments = parseArgumentList(); - } - return finishNode(node); - } - function parseBlock(ignoreMissingOpenBrace, diagnosticMessage) { - var node = createNode(192); - if (parseExpected(15, diagnosticMessage) || ignoreMissingOpenBrace) { - node.statements = parseList(1, parseStatement); - parseExpected(16); - } - else { - node.statements = createMissingList(); - } - return finishNode(node); - } - function parseFunctionBlock(allowYield, allowAwait, ignoreMissingOpenBrace, diagnosticMessage) { - var savedYieldContext = inYieldContext(); - setYieldContext(allowYield); - var savedAwaitContext = inAwaitContext(); - setAwaitContext(allowAwait); - var saveDecoratorContext = inDecoratorContext(); - if (saveDecoratorContext) { - setDecoratorContext(false); - } - var block = parseBlock(ignoreMissingOpenBrace, diagnosticMessage); - if (saveDecoratorContext) { - setDecoratorContext(true); - } - setYieldContext(savedYieldContext); - setAwaitContext(savedAwaitContext); - return block; - } - function parseEmptyStatement() { - var node = createNode(194); - parseExpected(23); - return finishNode(node); - } - function parseIfStatement() { - var node = createNode(196); - parseExpected(88); - parseExpected(17); - node.expression = allowInAnd(parseExpression); - parseExpected(18); - node.thenStatement = parseStatement(); - node.elseStatement = parseOptional(80) ? parseStatement() : undefined; - return finishNode(node); - } - function parseDoStatement() { - var node = createNode(197); - parseExpected(79); - node.statement = parseStatement(); - parseExpected(104); - parseExpected(17); - node.expression = allowInAnd(parseExpression); - parseExpected(18); - parseOptional(23); - return finishNode(node); - } - function parseWhileStatement() { - var node = createNode(198); - parseExpected(104); - parseExpected(17); - node.expression = allowInAnd(parseExpression); - parseExpected(18); - node.statement = parseStatement(); - return finishNode(node); - } - function parseForOrForInOrForOfStatement() { - var pos = getNodePos(); - parseExpected(86); - parseExpected(17); - var initializer = undefined; - if (token !== 23) { - if (token === 102 || token === 108 || token === 74) { - initializer = parseVariableDeclarationList(true); - } - else { - initializer = disallowInAnd(parseExpression); - } - } - var forOrForInOrForOfStatement; - if (parseOptional(90)) { - var forInStatement = createNode(200, pos); - forInStatement.initializer = initializer; - forInStatement.expression = allowInAnd(parseExpression); - parseExpected(18); - forOrForInOrForOfStatement = forInStatement; - } - else if (parseOptional(134)) { - var forOfStatement = createNode(201, pos); - forOfStatement.initializer = initializer; - forOfStatement.expression = allowInAnd(parseAssignmentExpressionOrHigher); - parseExpected(18); - forOrForInOrForOfStatement = forOfStatement; - } - else { - var forStatement = createNode(199, pos); - forStatement.initializer = initializer; - parseExpected(23); - if (token !== 23 && token !== 18) { - forStatement.condition = allowInAnd(parseExpression); - } - parseExpected(23); - if (token !== 18) { - forStatement.incrementor = allowInAnd(parseExpression); - } - parseExpected(18); - forOrForInOrForOfStatement = forStatement; - } - forOrForInOrForOfStatement.statement = parseStatement(); - return finishNode(forOrForInOrForOfStatement); - } - function parseBreakOrContinueStatement(kind) { - var node = createNode(kind); - parseExpected(kind === 203 ? 70 : 75); - if (!canParseSemicolon()) { - node.label = parseIdentifier(); - } - parseSemicolon(); - return finishNode(node); - } - function parseReturnStatement() { - var node = createNode(204); - parseExpected(94); - if (!canParseSemicolon()) { - node.expression = allowInAnd(parseExpression); - } - parseSemicolon(); - return finishNode(node); - } - function parseWithStatement() { - var node = createNode(205); - parseExpected(105); - parseExpected(17); - node.expression = allowInAnd(parseExpression); - parseExpected(18); - node.statement = parseStatement(); - return finishNode(node); - } - function parseCaseClause() { - var node = createNode(241); - parseExpected(71); - node.expression = allowInAnd(parseExpression); - parseExpected(54); - node.statements = parseList(3, parseStatement); - return finishNode(node); - } - function parseDefaultClause() { - var node = createNode(242); - parseExpected(77); - parseExpected(54); - node.statements = parseList(3, parseStatement); - return finishNode(node); - } - function parseCaseOrDefaultClause() { - return token === 71 ? parseCaseClause() : parseDefaultClause(); - } - function parseSwitchStatement() { - var node = createNode(206); - parseExpected(96); - parseExpected(17); - node.expression = allowInAnd(parseExpression); - parseExpected(18); - var caseBlock = createNode(220, scanner.getStartPos()); - parseExpected(15); - caseBlock.clauses = parseList(2, parseCaseOrDefaultClause); - parseExpected(16); - node.caseBlock = finishNode(caseBlock); - return finishNode(node); - } - function parseThrowStatement() { - var node = createNode(208); - parseExpected(98); - node.expression = scanner.hasPrecedingLineBreak() ? undefined : allowInAnd(parseExpression); - parseSemicolon(); - return finishNode(node); - } - function parseTryStatement() { - var node = createNode(209); - parseExpected(100); - node.tryBlock = parseBlock(false); - node.catchClause = token === 72 ? parseCatchClause() : undefined; - if (!node.catchClause || token === 85) { - parseExpected(85); - node.finallyBlock = parseBlock(false); - } - return finishNode(node); - } - function parseCatchClause() { - var result = createNode(244); - parseExpected(72); - if (parseExpected(17)) { - result.variableDeclaration = parseVariableDeclaration(); - } - parseExpected(18); - result.block = parseBlock(false); - return finishNode(result); - } - function parseDebuggerStatement() { - var node = createNode(210); - parseExpected(76); - parseSemicolon(); - return finishNode(node); - } - function parseExpressionOrLabeledStatement() { - var fullStart = scanner.getStartPos(); - var expression = allowInAnd(parseExpression); - if (expression.kind === 69 && parseOptional(54)) { - var labeledStatement = createNode(207, fullStart); - labeledStatement.label = expression; - labeledStatement.statement = parseStatement(); - return finishNode(labeledStatement); - } - else { - var expressionStatement = createNode(195, fullStart); - expressionStatement.expression = expression; - parseSemicolon(); - return finishNode(expressionStatement); - } - } - function nextTokenIsIdentifierOrKeywordOnSameLine() { - nextToken(); - return ts.tokenIsIdentifierOrKeyword(token) && !scanner.hasPrecedingLineBreak(); - } - function nextTokenIsFunctionKeywordOnSameLine() { - nextToken(); - return token === 87 && !scanner.hasPrecedingLineBreak(); - } - function nextTokenIsIdentifierOrKeywordOrNumberOnSameLine() { - nextToken(); - return (ts.tokenIsIdentifierOrKeyword(token) || token === 8) && !scanner.hasPrecedingLineBreak(); - } - function isDeclaration() { - while (true) { - switch (token) { - case 102: - case 108: - case 74: - case 87: - case 73: - case 81: - return true; - case 107: - case 132: - return nextTokenIsIdentifierOnSameLine(); - case 125: - case 126: - return nextTokenIsIdentifierOrStringLiteralOnSameLine(); - case 115: - case 118: - case 122: - case 110: - case 111: - case 112: - nextToken(); - if (scanner.hasPrecedingLineBreak()) { - return false; - } - continue; - case 89: - nextToken(); - return token === 9 || token === 37 || - token === 15 || ts.tokenIsIdentifierOrKeyword(token); - case 82: - nextToken(); - if (token === 56 || token === 37 || - token === 15 || token === 77) { - return true; - } - continue; - case 113: - nextToken(); - continue; - default: - return false; - } - } - } - function isStartOfDeclaration() { - return lookAhead(isDeclaration); - } - function isStartOfStatement() { - switch (token) { - case 55: - case 23: - case 15: - case 102: - case 108: - case 87: - case 73: - case 81: - 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: - return isStartOfDeclaration(); - case 118: - case 122: - case 107: - case 125: - case 126: - case 132: - return true; - case 112: - case 110: - case 111: - case 113: - return isStartOfDeclaration() || !lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine); - default: - return isStartOfExpression(); - } - } - function nextTokenIsIdentifierOrStartOfDestructuring() { - nextToken(); - return isIdentifier() || token === 15 || token === 19; - } - function isLetDeclaration() { - return lookAhead(nextTokenIsIdentifierOrStartOfDestructuring); - } - function parseStatement() { - switch (token) { - case 23: - return parseEmptyStatement(); - case 15: - return parseBlock(false); - case 102: - return parseVariableStatement(scanner.getStartPos(), undefined, undefined); - case 108: - 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(202); - case 70: - return parseBreakOrContinueStatement(203); - 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 132: - case 125: - case 126: - case 122: - case 74: - case 81: - case 82: - case 89: - case 110: - case 111: - case 112: - case 115: - case 113: - if (isStartOfDeclaration()) { - return parseDeclaration(); - } - break; - } - return parseExpressionOrLabeledStatement(); - } - function parseDeclaration() { - var fullStart = getNodePos(); - var decorators = parseDecorators(); - var modifiers = parseModifiers(); - switch (token) { - case 102: - case 108: - case 74: - return parseVariableStatement(fullStart, decorators, modifiers); - case 87: - return parseFunctionDeclaration(fullStart, decorators, modifiers); - case 73: - return parseClassDeclaration(fullStart, decorators, modifiers); - case 107: - return parseInterfaceDeclaration(fullStart, decorators, modifiers); - case 132: - return parseTypeAliasDeclaration(fullStart, decorators, modifiers); - case 81: - return parseEnumDeclaration(fullStart, decorators, modifiers); - case 125: - case 126: - return parseModuleDeclaration(fullStart, decorators, modifiers); - case 89: - return parseImportDeclarationOrImportEqualsDeclaration(fullStart, decorators, modifiers); - case 82: - nextToken(); - return token === 77 || token === 56 ? - parseExportAssignment(fullStart, decorators, modifiers) : - parseExportDeclaration(fullStart, decorators, modifiers); - default: - if (decorators || modifiers) { - var node = createMissingNode(231, true, ts.Diagnostics.Declaration_expected); - node.pos = fullStart; - node.decorators = decorators; - setModifiers(node, modifiers); - return finishNode(node); - } - } - } - function nextTokenIsIdentifierOrStringLiteralOnSameLine() { - nextToken(); - return !scanner.hasPrecedingLineBreak() && (isIdentifier() || token === 9); - } - function parseFunctionBlockOrSemicolon(isGenerator, isAsync, diagnosticMessage) { - if (token !== 15 && canParseSemicolon()) { - parseSemicolon(); - return; - } - return parseFunctionBlock(isGenerator, isAsync, false, diagnosticMessage); - } - function parseArrayBindingElement() { - if (token === 24) { - return createNode(187); - } - var node = createNode(163); - node.dotDotDotToken = parseOptionalToken(22); - node.name = parseIdentifierOrPattern(); - node.initializer = parseBindingElementInitializer(false); - return finishNode(node); - } - function parseObjectBindingElement() { - var node = createNode(163); - var tokenIsIdentifier = isIdentifier(); - var propertyName = parsePropertyName(); - if (tokenIsIdentifier && token !== 54) { - node.name = propertyName; - } - else { - parseExpected(54); - node.propertyName = propertyName; - node.name = parseIdentifierOrPattern(); - } - node.initializer = parseBindingElementInitializer(false); - return finishNode(node); - } - function parseObjectBindingPattern() { - var node = createNode(161); - parseExpected(15); - node.elements = parseDelimitedList(9, parseObjectBindingElement); - parseExpected(16); - return finishNode(node); - } - function parseArrayBindingPattern() { - var node = createNode(162); - parseExpected(19); - node.elements = parseDelimitedList(10, parseArrayBindingElement); - parseExpected(20); - return finishNode(node); - } - function isIdentifierOrPattern() { - return token === 15 || token === 19 || isIdentifier(); - } - function parseIdentifierOrPattern() { - if (token === 19) { - return parseArrayBindingPattern(); - } - if (token === 15) { - return parseObjectBindingPattern(); - } - return parseIdentifier(); - } - function parseVariableDeclaration() { - var node = createNode(211); - node.name = parseIdentifierOrPattern(); - node.type = parseTypeAnnotation(); - if (!isInOrOfKeyword(token)) { - node.initializer = parseInitializer(false); - } - return finishNode(node); - } - function parseVariableDeclarationList(inForStatementInitializer) { - var node = createNode(212); - switch (token) { - case 102: - break; - case 108: - node.flags |= 16384; - break; - case 74: - node.flags |= 32768; - break; - default: - ts.Debug.fail(); - } - nextToken(); - if (token === 134 && lookAhead(canFollowContextualOfKeyword)) { - node.declarations = createMissingList(); - } - else { - var savedDisallowIn = inDisallowInContext(); - setDisallowInContext(inForStatementInitializer); - node.declarations = parseDelimitedList(8, parseVariableDeclaration); - setDisallowInContext(savedDisallowIn); - } - return finishNode(node); - } - function canFollowContextualOfKeyword() { - return nextTokenIsIdentifier() && nextToken() === 18; - } - function parseVariableStatement(fullStart, decorators, modifiers) { - var node = createNode(193, fullStart); - node.decorators = decorators; - setModifiers(node, modifiers); - node.declarationList = parseVariableDeclarationList(false); - parseSemicolon(); - return finishNode(node); - } - function parseFunctionDeclaration(fullStart, decorators, modifiers) { - var node = createNode(213, fullStart); - node.decorators = decorators; - setModifiers(node, modifiers); - parseExpected(87); - node.asteriskToken = parseOptionalToken(37); - node.name = node.flags & 1024 ? parseOptionalIdentifier() : parseIdentifier(); - var isGenerator = !!node.asteriskToken; - var isAsync = !!(node.flags & 512); - fillSignature(54, isGenerator, isAsync, false, node); - node.body = parseFunctionBlockOrSemicolon(isGenerator, isAsync, ts.Diagnostics.or_expected); - return finishNode(node); - } - function parseConstructorDeclaration(pos, decorators, modifiers) { - var node = createNode(144, pos); - node.decorators = decorators; - setModifiers(node, modifiers); - parseExpected(121); - fillSignature(54, false, false, false, node); - node.body = parseFunctionBlockOrSemicolon(false, false, ts.Diagnostics.or_expected); - return finishNode(node); - } - function parseMethodDeclaration(fullStart, decorators, modifiers, asteriskToken, name, questionToken, diagnosticMessage) { - var method = createNode(143, fullStart); - method.decorators = decorators; - setModifiers(method, modifiers); - method.asteriskToken = asteriskToken; - method.name = name; - method.questionToken = questionToken; - var isGenerator = !!asteriskToken; - var isAsync = !!(method.flags & 512); - fillSignature(54, isGenerator, isAsync, false, method); - method.body = parseFunctionBlockOrSemicolon(isGenerator, isAsync, diagnosticMessage); - return finishNode(method); - } - function parsePropertyDeclaration(fullStart, decorators, modifiers, name, questionToken) { - var property = createNode(141, fullStart); - property.decorators = decorators; - setModifiers(property, modifiers); - property.name = name; - property.questionToken = questionToken; - property.type = parseTypeAnnotation(); - property.initializer = modifiers && modifiers.flags & 128 - ? allowInAnd(parseNonParameterInitializer) - : doOutsideOfContext(2 | 1, parseNonParameterInitializer); - parseSemicolon(); - return finishNode(property); - } - function parsePropertyOrMethodDeclaration(fullStart, decorators, modifiers) { - var asteriskToken = parseOptionalToken(37); - var name = parsePropertyName(); - var questionToken = parseOptionalToken(53); - if (asteriskToken || token === 17 || token === 25) { - return parseMethodDeclaration(fullStart, decorators, modifiers, asteriskToken, name, questionToken, ts.Diagnostics.or_expected); - } - else { - return parsePropertyDeclaration(fullStart, decorators, modifiers, name, questionToken); - } - } - function parseNonParameterInitializer() { - return parseInitializer(false); - } - function parseAccessorDeclaration(kind, fullStart, decorators, modifiers) { - var node = createNode(kind, fullStart); - node.decorators = decorators; - setModifiers(node, modifiers); - node.name = parsePropertyName(); - fillSignature(54, false, false, false, node); - node.body = parseFunctionBlockOrSemicolon(false, false); - return finishNode(node); - } - function isClassMemberModifier(idToken) { - switch (idToken) { - case 112: - case 110: - case 111: - case 113: - return true; - default: - return false; - } - } - function isClassMemberStart() { - var idToken; - if (token === 55) { - return true; - } - while (ts.isModifier(token)) { - idToken = token; - if (isClassMemberModifier(idToken)) { - return true; - } - nextToken(); - } - if (token === 37) { - return true; - } - if (isLiteralPropertyName()) { - idToken = token; - nextToken(); - } - if (token === 19) { - return true; - } - if (idToken !== undefined) { - if (!ts.isKeyword(idToken) || idToken === 129 || idToken === 123) { - return true; - } - switch (token) { - case 17: - case 25: - case 54: - case 56: - case 53: - return true; - default: - return canParseSemicolon(); - } - } - return false; - } - function parseDecorators() { - var decorators; - while (true) { - var decoratorStart = getNodePos(); - if (!parseOptional(55)) { - break; - } - if (!decorators) { - decorators = []; - decorators.pos = scanner.getStartPos(); - } - var decorator = createNode(139, decoratorStart); - decorator.expression = doInDecoratorContext(parseLeftHandSideExpressionOrHigher); - decorators.push(finishNode(decorator)); - } - if (decorators) { - decorators.end = getNodeEnd(); - } - return decorators; - } - function parseModifiers() { - var flags = 0; - var modifiers; - while (true) { - var modifierStart = scanner.getStartPos(); - var modifierKind = token; - if (!parseAnyContextualModifier()) { - break; - } - if (!modifiers) { - modifiers = []; - modifiers.pos = modifierStart; - } - flags |= ts.modifierToFlag(modifierKind); - modifiers.push(finishNode(createNode(modifierKind, modifierStart))); - } - if (modifiers) { - modifiers.flags = flags; - modifiers.end = scanner.getStartPos(); - } - return modifiers; - } - function parseModifiersForArrowFunction() { - var flags = 0; - var modifiers; - if (token === 118) { - var modifierStart = scanner.getStartPos(); - var modifierKind = token; - nextToken(); - modifiers = []; - modifiers.pos = modifierStart; - flags |= ts.modifierToFlag(modifierKind); - modifiers.push(finishNode(createNode(modifierKind, modifierStart))); - modifiers.flags = flags; - modifiers.end = scanner.getStartPos(); - } - return modifiers; - } - function parseClassElement() { - if (token === 23) { - var result = createNode(191); - nextToken(); - return finishNode(result); - } - var fullStart = getNodePos(); - var decorators = parseDecorators(); - var modifiers = parseModifiers(); - var accessor = tryParseAccessorDeclaration(fullStart, decorators, modifiers); - if (accessor) { - return accessor; - } - if (token === 121) { - return parseConstructorDeclaration(fullStart, decorators, modifiers); - } - if (isIndexSignature()) { - return parseIndexSignatureDeclaration(fullStart, decorators, modifiers); - } - if (ts.tokenIsIdentifierOrKeyword(token) || - token === 9 || - token === 8 || - token === 37 || - token === 19) { - return parsePropertyOrMethodDeclaration(fullStart, decorators, modifiers); - } - if (decorators || modifiers) { - var name_7 = createMissingNode(69, true, ts.Diagnostics.Declaration_expected); - return parsePropertyDeclaration(fullStart, decorators, modifiers, name_7, undefined); - } - ts.Debug.fail("Should not have attempted to parse class member declaration."); - } - function parseClassExpression() { - return parseClassDeclarationOrExpression(scanner.getStartPos(), undefined, undefined, 186); - } - function parseClassDeclaration(fullStart, decorators, modifiers) { - return parseClassDeclarationOrExpression(fullStart, decorators, modifiers, 214); - } - function parseClassDeclarationOrExpression(fullStart, decorators, modifiers, kind) { - var node = createNode(kind, fullStart); - node.decorators = decorators; - setModifiers(node, modifiers); - parseExpected(73); - node.name = parseNameOfClassDeclarationOrExpression(); - node.typeParameters = parseTypeParameters(); - node.heritageClauses = parseHeritageClauses(true); - if (parseExpected(15)) { - node.members = parseClassMembers(); - parseExpected(16); - } - else { - node.members = createMissingList(); - } - return finishNode(node); - } - function parseNameOfClassDeclarationOrExpression() { - return isIdentifier() && !isImplementsClause() - ? parseIdentifier() - : undefined; - } - function isImplementsClause() { - return token === 106 && lookAhead(nextTokenIsIdentifierOrKeyword); - } - function parseHeritageClauses(isClassHeritageClause) { - if (isHeritageClause()) { - return parseList(20, parseHeritageClause); - } - return undefined; - } - function parseHeritageClausesWorker() { - return parseList(20, parseHeritageClause); - } - function parseHeritageClause() { - if (token === 83 || token === 106) { - var node = createNode(243); - node.token = token; - nextToken(); - node.types = parseDelimitedList(7, parseExpressionWithTypeArguments); - return finishNode(node); - } - return undefined; - } - function parseExpressionWithTypeArguments() { - var node = createNode(188); - node.expression = parseLeftHandSideExpressionOrHigher(); - if (token === 25) { - node.typeArguments = parseBracketedList(18, parseType, 25, 27); - } - return finishNode(node); - } - function isHeritageClause() { - return token === 83 || token === 106; - } - function parseClassMembers() { - return parseList(5, parseClassElement); - } - function parseInterfaceDeclaration(fullStart, decorators, modifiers) { - var node = createNode(215, fullStart); - node.decorators = decorators; - setModifiers(node, modifiers); - parseExpected(107); - node.name = parseIdentifier(); - node.typeParameters = parseTypeParameters(); - node.heritageClauses = parseHeritageClauses(false); - node.members = parseObjectTypeMembers(); - return finishNode(node); - } - function parseTypeAliasDeclaration(fullStart, decorators, modifiers) { - var node = createNode(216, fullStart); - node.decorators = decorators; - setModifiers(node, modifiers); - parseExpected(132); - node.name = parseIdentifier(); - node.typeParameters = parseTypeParameters(); - parseExpected(56); - node.type = parseType(); - parseSemicolon(); - return finishNode(node); - } - function parseEnumMember() { - var node = createNode(247, scanner.getStartPos()); - node.name = parsePropertyName(); - node.initializer = allowInAnd(parseNonParameterInitializer); - return finishNode(node); - } - function parseEnumDeclaration(fullStart, decorators, modifiers) { - var node = createNode(217, fullStart); - node.decorators = decorators; - setModifiers(node, modifiers); - parseExpected(81); - node.name = parseIdentifier(); - if (parseExpected(15)) { - node.members = parseDelimitedList(6, parseEnumMember); - parseExpected(16); - } - else { - node.members = createMissingList(); - } - return finishNode(node); - } - function parseModuleBlock() { - var node = createNode(219, scanner.getStartPos()); - if (parseExpected(15)) { - node.statements = parseList(1, parseStatement); - parseExpected(16); - } - else { - node.statements = createMissingList(); - } - return finishNode(node); - } - function parseModuleOrNamespaceDeclaration(fullStart, decorators, modifiers, flags) { - var node = createNode(218, fullStart); - var namespaceFlag = flags & 131072; - node.decorators = decorators; - setModifiers(node, modifiers); - node.flags |= flags; - node.name = parseIdentifier(); - node.body = parseOptional(21) - ? parseModuleOrNamespaceDeclaration(getNodePos(), undefined, undefined, 1 | namespaceFlag) - : parseModuleBlock(); - return finishNode(node); - } - function parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers) { - var node = createNode(218, fullStart); - node.decorators = decorators; - setModifiers(node, modifiers); - node.name = parseLiteralNode(true); - node.body = parseModuleBlock(); - return finishNode(node); - } - function parseModuleDeclaration(fullStart, decorators, modifiers) { - var flags = modifiers ? modifiers.flags : 0; - if (parseOptional(126)) { - flags |= 131072; - } - else { - parseExpected(125); - if (token === 9) { - return parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers); - } - } - return parseModuleOrNamespaceDeclaration(fullStart, decorators, modifiers, flags); - } - function isExternalModuleReference() { - return token === 127 && - lookAhead(nextTokenIsOpenParen); - } - function nextTokenIsOpenParen() { - return nextToken() === 17; - } - function nextTokenIsSlash() { - return nextToken() === 39; - } - function nextTokenIsCommaOrFromKeyword() { - nextToken(); - return token === 24 || - token === 133; - } - function parseImportDeclarationOrImportEqualsDeclaration(fullStart, decorators, modifiers) { - parseExpected(89); - var afterImportPos = scanner.getStartPos(); - var identifier; - if (isIdentifier()) { - identifier = parseIdentifier(); - if (token !== 24 && token !== 133) { - var importEqualsDeclaration = createNode(221, fullStart); - importEqualsDeclaration.decorators = decorators; - setModifiers(importEqualsDeclaration, modifiers); - importEqualsDeclaration.name = identifier; - parseExpected(56); - importEqualsDeclaration.moduleReference = parseModuleReference(); - parseSemicolon(); - return finishNode(importEqualsDeclaration); - } - } - var importDeclaration = createNode(222, fullStart); - importDeclaration.decorators = decorators; - setModifiers(importDeclaration, modifiers); - if (identifier || - token === 37 || - token === 15) { - importDeclaration.importClause = parseImportClause(identifier, afterImportPos); - parseExpected(133); - } - importDeclaration.moduleSpecifier = parseModuleSpecifier(); - parseSemicolon(); - return finishNode(importDeclaration); - } - function parseImportClause(identifier, fullStart) { - var importClause = createNode(223, fullStart); - if (identifier) { - importClause.name = identifier; - } - if (!importClause.name || - parseOptional(24)) { - importClause.namedBindings = token === 37 ? parseNamespaceImport() : parseNamedImportsOrExports(225); - } - return finishNode(importClause); - } - function parseModuleReference() { - return isExternalModuleReference() - ? parseExternalModuleReference() - : parseEntityName(false); - } - function parseExternalModuleReference() { - var node = createNode(232); - parseExpected(127); - parseExpected(17); - node.expression = parseModuleSpecifier(); - parseExpected(18); - return finishNode(node); - } - function parseModuleSpecifier() { - var result = parseExpression(); - if (result.kind === 9) { - internIdentifier(result.text); - } - return result; - } - function parseNamespaceImport() { - var namespaceImport = createNode(224); - parseExpected(37); - parseExpected(116); - namespaceImport.name = parseIdentifier(); - return finishNode(namespaceImport); - } - function parseNamedImportsOrExports(kind) { - var node = createNode(kind); - node.elements = parseBracketedList(21, kind === 225 ? parseImportSpecifier : parseExportSpecifier, 15, 16); - return finishNode(node); - } - function parseExportSpecifier() { - return parseImportOrExportSpecifier(230); - } - function parseImportSpecifier() { - return parseImportOrExportSpecifier(226); - } - function parseImportOrExportSpecifier(kind) { - var node = createNode(kind); - var checkIdentifierIsKeyword = ts.isKeyword(token) && !isIdentifier(); - var checkIdentifierStart = scanner.getTokenPos(); - var checkIdentifierEnd = scanner.getTextPos(); - var identifierName = parseIdentifierName(); - if (token === 116) { - node.propertyName = identifierName; - parseExpected(116); - checkIdentifierIsKeyword = ts.isKeyword(token) && !isIdentifier(); - checkIdentifierStart = scanner.getTokenPos(); - checkIdentifierEnd = scanner.getTextPos(); - node.name = parseIdentifierName(); - } - else { - node.name = identifierName; - } - if (kind === 226 && checkIdentifierIsKeyword) { - parseErrorAtPosition(checkIdentifierStart, checkIdentifierEnd - checkIdentifierStart, ts.Diagnostics.Identifier_expected); - } - return finishNode(node); - } - function parseExportDeclaration(fullStart, decorators, modifiers) { - var node = createNode(228, fullStart); - node.decorators = decorators; - setModifiers(node, modifiers); - if (parseOptional(37)) { - parseExpected(133); - node.moduleSpecifier = parseModuleSpecifier(); - } - else { - node.exportClause = parseNamedImportsOrExports(229); - if (token === 133 || (token === 9 && !scanner.hasPrecedingLineBreak())) { - parseExpected(133); - node.moduleSpecifier = parseModuleSpecifier(); - } - } - parseSemicolon(); - return finishNode(node); - } - function parseExportAssignment(fullStart, decorators, modifiers) { - var node = createNode(227, fullStart); - node.decorators = decorators; - setModifiers(node, modifiers); - if (parseOptional(56)) { - node.isExportEquals = true; - } - else { - parseExpected(77); - } - node.expression = parseAssignmentExpressionOrHigher(); - parseSemicolon(); - return finishNode(node); - } - function processReferenceComments(sourceFile) { - var triviaScanner = ts.createScanner(sourceFile.languageVersion, false, 0, sourceText); - var referencedFiles = []; - var amdDependencies = []; - var amdModuleName; - while (true) { - var kind = triviaScanner.scan(); - if (kind === 5 || kind === 4 || kind === 3) { - continue; - } - if (kind !== 2) { - break; - } - var range = { pos: triviaScanner.getTokenPos(), end: triviaScanner.getTextPos(), kind: triviaScanner.getToken() }; - var comment = sourceText.substring(range.pos, range.end); - var referencePathMatchResult = ts.getFileReferenceFromReferencePath(comment, range); - if (referencePathMatchResult) { - var fileReference = referencePathMatchResult.fileReference; - sourceFile.hasNoDefaultLib = referencePathMatchResult.isNoDefaultLib; - var diagnosticMessage = referencePathMatchResult.diagnosticMessage; - if (fileReference) { - referencedFiles.push(fileReference); - } - if (diagnosticMessage) { - parseDiagnostics.push(ts.createFileDiagnostic(sourceFile, range.pos, range.end - range.pos, diagnosticMessage)); - } - } - else { - var amdModuleNameRegEx = /^\/\/\/\s*".length; - return parseErrorAtPosition(start, end - start, ts.Diagnostics.Type_argument_list_cannot_be_empty); - } - } - function parseQualifiedName(left) { - var result = createNode(135, left.pos); - result.left = left; - result.right = parseIdentifierName(); - return finishNode(result); - } - function parseJSDocRecordType() { - var result = createNode(257); - nextToken(); - result.members = parseDelimitedList(24, parseJSDocRecordMember); - checkForTrailingComma(result.members); - parseExpected(16); - return finishNode(result); - } - function parseJSDocRecordMember() { - var result = createNode(258); - result.name = parseSimplePropertyName(); - if (token === 54) { - nextToken(); - result.type = parseJSDocType(); - } - return finishNode(result); - } - function parseJSDocNonNullableType() { - var result = createNode(256); - nextToken(); - result.type = parseJSDocType(); - return finishNode(result); - } - function parseJSDocTupleType() { - var result = createNode(254); - nextToken(); - result.types = parseDelimitedList(25, parseJSDocType); - checkForTrailingComma(result.types); - parseExpected(20); - return finishNode(result); - } - function checkForTrailingComma(list) { - if (parseDiagnostics.length === 0 && list.hasTrailingComma) { - var start = list.end - ",".length; - parseErrorAtPosition(start, ",".length, ts.Diagnostics.Trailing_comma_not_allowed); - } - } - function parseJSDocUnionType() { - var result = createNode(253); - nextToken(); - result.types = parseJSDocTypeList(parseJSDocType()); - parseExpected(18); - return finishNode(result); - } - function parseJSDocTypeList(firstType) { - ts.Debug.assert(!!firstType); - var types = []; - types.pos = firstType.pos; - types.push(firstType); - while (parseOptional(47)) { - types.push(parseJSDocType()); - } - types.end = scanner.getStartPos(); - return types; - } - function parseJSDocAllType() { - var result = createNode(250); - nextToken(); - return finishNode(result); - } - function parseJSDocUnknownOrNullableType() { - var pos = scanner.getStartPos(); - nextToken(); - if (token === 24 || - token === 16 || - token === 18 || - token === 27 || - token === 56 || - token === 47) { - var result = createNode(251, pos); - return finishNode(result); - } - else { - var result = createNode(255, pos); - result.type = parseJSDocType(); - return finishNode(result); - } - } - function parseIsolatedJSDocComment(content, start, length) { - initializeState("file.js", content, 2, undefined); - var jsDocComment = parseJSDocComment(undefined, start, length); - var diagnostics = parseDiagnostics; - clearState(); - return jsDocComment ? { jsDocComment: jsDocComment, diagnostics: diagnostics } : undefined; - } - JSDocParser.parseIsolatedJSDocComment = parseIsolatedJSDocComment; - function parseJSDocComment(parent, start, length) { - var comment = parseJSDocCommentWorker(start, length); - if (comment) { - fixupParentReferences(comment); - comment.parent = parent; - } - return comment; - } - JSDocParser.parseJSDocComment = parseJSDocComment; - function parseJSDocCommentWorker(start, length) { - var content = sourceText; - start = start || 0; - var end = length === undefined ? content.length : start + length; - length = end - start; - ts.Debug.assert(start >= 0); - ts.Debug.assert(start <= end); - ts.Debug.assert(end <= content.length); - var tags; - var pos; - if (length >= "/** */".length) { - if (content.charCodeAt(start) === 47 && - content.charCodeAt(start + 1) === 42 && - content.charCodeAt(start + 2) === 42 && - content.charCodeAt(start + 3) !== 42) { - var canParseTag = true; - var seenAsterisk = true; - for (pos = start + "/**".length; pos < end;) { - var ch = content.charCodeAt(pos); - pos++; - if (ch === 64 && canParseTag) { - parseTag(); - canParseTag = false; - continue; - } - if (ts.isLineBreak(ch)) { - canParseTag = true; - seenAsterisk = false; - continue; - } - if (ts.isWhiteSpace(ch)) { - continue; - } - if (ch === 42) { - if (seenAsterisk) { - canParseTag = false; - } - seenAsterisk = true; - continue; - } - canParseTag = false; - } - } - } - return createJSDocComment(); - function createJSDocComment() { - if (!tags) { - return undefined; - } - var result = createNode(265, start); - result.tags = tags; - return finishNode(result, end); - } - function skipWhitespace() { - while (pos < end && ts.isWhiteSpace(content.charCodeAt(pos))) { - pos++; - } - } - function parseTag() { - ts.Debug.assert(content.charCodeAt(pos - 1) === 64); - var atToken = createNode(55, pos - 1); - atToken.end = pos; - var tagName = scanIdentifier(); - if (!tagName) { - return; - } - var tag = handleTag(atToken, tagName) || handleUnknownTag(atToken, tagName); - addTag(tag); - } - function handleTag(atToken, tagName) { - if (tagName) { - switch (tagName.text) { - case "param": - return handleParamTag(atToken, tagName); - case "return": - case "returns": - return handleReturnTag(atToken, tagName); - case "template": - return handleTemplateTag(atToken, tagName); - case "type": - return handleTypeTag(atToken, tagName); - } - } - return undefined; - } - function handleUnknownTag(atToken, tagName) { - var result = createNode(266, atToken.pos); - result.atToken = atToken; - result.tagName = tagName; - return finishNode(result, pos); - } - function addTag(tag) { - if (tag) { - if (!tags) { - tags = []; - tags.pos = tag.pos; - } - tags.push(tag); - tags.end = tag.end; - } - } - function tryParseTypeExpression() { - skipWhitespace(); - if (content.charCodeAt(pos) !== 123) { - return undefined; - } - var typeExpression = parseJSDocTypeExpression(pos, end - pos); - pos = typeExpression.end; - return typeExpression; - } - function handleParamTag(atToken, tagName) { - var typeExpression = tryParseTypeExpression(); - skipWhitespace(); - var name; - var isBracketed; - if (content.charCodeAt(pos) === 91) { - pos++; - skipWhitespace(); - name = scanIdentifier(); - isBracketed = true; - } - else { - name = scanIdentifier(); - } - if (!name) { - parseErrorAtPosition(pos, 0, ts.Diagnostics.Identifier_expected); - } - var preName, postName; - if (typeExpression) { - postName = name; - } - else { - preName = name; - } - if (!typeExpression) { - typeExpression = tryParseTypeExpression(); - } - var result = createNode(267, atToken.pos); - result.atToken = atToken; - result.tagName = tagName; - result.preParameterName = preName; - result.typeExpression = typeExpression; - result.postParameterName = postName; - result.isBracketed = isBracketed; - return finishNode(result, pos); - } - function handleReturnTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 268; })) { - parseErrorAtPosition(tagName.pos, pos - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); - } - var result = createNode(268, atToken.pos); - result.atToken = atToken; - result.tagName = tagName; - result.typeExpression = tryParseTypeExpression(); - return finishNode(result, pos); - } - function handleTypeTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 269; })) { - parseErrorAtPosition(tagName.pos, pos - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); - } - var result = createNode(269, atToken.pos); - result.atToken = atToken; - result.tagName = tagName; - result.typeExpression = tryParseTypeExpression(); - return finishNode(result, pos); - } - function handleTemplateTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 270; })) { - parseErrorAtPosition(tagName.pos, pos - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); - } - var typeParameters = []; - typeParameters.pos = pos; - while (true) { - skipWhitespace(); - var startPos = pos; - var name_8 = scanIdentifier(); - if (!name_8) { - parseErrorAtPosition(startPos, 0, ts.Diagnostics.Identifier_expected); - return undefined; - } - var typeParameter = createNode(137, name_8.pos); - typeParameter.name = name_8; - finishNode(typeParameter, pos); - typeParameters.push(typeParameter); - skipWhitespace(); - if (content.charCodeAt(pos) !== 44) { - break; - } - pos++; - } - typeParameters.end = pos; - var result = createNode(270, atToken.pos); - result.atToken = atToken; - result.tagName = tagName; - result.typeParameters = typeParameters; - return finishNode(result, pos); - } - function scanIdentifier() { - var startPos = pos; - for (; pos < end; pos++) { - var ch = content.charCodeAt(pos); - if (pos === startPos && ts.isIdentifierStart(ch, 2)) { - continue; - } - else if (pos > startPos && ts.isIdentifierPart(ch, 2)) { - continue; - } - break; - } - if (startPos === pos) { - return undefined; - } - var result = createNode(69, startPos); - result.text = content.substring(startPos, pos); - return finishNode(result, pos); - } - } - JSDocParser.parseJSDocCommentWorker = parseJSDocCommentWorker; - })(JSDocParser = Parser.JSDocParser || (Parser.JSDocParser = {})); - })(Parser || (Parser = {})); - var IncrementalParser; - (function (IncrementalParser) { - function updateSourceFile(sourceFile, newText, textChangeRange, aggressiveChecks) { - aggressiveChecks = aggressiveChecks || ts.Debug.shouldAssert(2); - checkChangeRange(sourceFile, newText, textChangeRange, aggressiveChecks); - if (ts.textChangeRangeIsUnchanged(textChangeRange)) { - return sourceFile; - } - if (sourceFile.statements.length === 0) { - return Parser.parseSourceFile(sourceFile.fileName, newText, sourceFile.languageVersion, undefined, true); - } - var incrementalSourceFile = sourceFile; - ts.Debug.assert(!incrementalSourceFile.hasBeenIncrementallyParsed); - incrementalSourceFile.hasBeenIncrementallyParsed = true; - var oldText = sourceFile.text; - var syntaxCursor = createSyntaxCursor(sourceFile); - var changeRange = extendToAffectedRange(sourceFile, textChangeRange); - checkChangeRange(sourceFile, newText, changeRange, aggressiveChecks); - ts.Debug.assert(changeRange.span.start <= textChangeRange.span.start); - ts.Debug.assert(ts.textSpanEnd(changeRange.span) === ts.textSpanEnd(textChangeRange.span)); - ts.Debug.assert(ts.textSpanEnd(ts.textChangeRangeNewSpan(changeRange)) === ts.textSpanEnd(ts.textChangeRangeNewSpan(textChangeRange))); - var delta = ts.textChangeRangeNewSpan(changeRange).length - changeRange.span.length; - updateTokenPositionsAndMarkElements(incrementalSourceFile, changeRange.span.start, ts.textSpanEnd(changeRange.span), ts.textSpanEnd(ts.textChangeRangeNewSpan(changeRange)), delta, oldText, newText, aggressiveChecks); - var result = Parser.parseSourceFile(sourceFile.fileName, newText, sourceFile.languageVersion, syntaxCursor, true); - return result; - } - IncrementalParser.updateSourceFile = updateSourceFile; - function moveElementEntirelyPastChangeRange(element, isArray, delta, oldText, newText, aggressiveChecks) { - if (isArray) { - visitArray(element); - } - else { - visitNode(element); - } - return; - function visitNode(node) { - var text = ""; - if (aggressiveChecks && shouldCheckNode(node)) { - text = oldText.substring(node.pos, node.end); - } - if (node._children) { - node._children = undefined; - } - if (node.jsDocComment) { - node.jsDocComment = undefined; - } - node.pos += delta; - node.end += delta; - if (aggressiveChecks && shouldCheckNode(node)) { - ts.Debug.assert(text === newText.substring(node.pos, node.end)); - } - forEachChild(node, visitNode, visitArray); - checkNodePositions(node, aggressiveChecks); - } - function visitArray(array) { - array._children = undefined; - array.pos += delta; - array.end += delta; - for (var _i = 0; _i < array.length; _i++) { - var node = array[_i]; - visitNode(node); - } - } - } - function shouldCheckNode(node) { - switch (node.kind) { - case 9: - case 8: - case 69: - return true; - } - return false; - } - function adjustIntersectingElement(element, changeStart, changeRangeOldEnd, changeRangeNewEnd, delta) { - ts.Debug.assert(element.end >= changeStart, "Adjusting an element that was entirely before the change range"); - ts.Debug.assert(element.pos <= changeRangeOldEnd, "Adjusting an element that was entirely after the change range"); - ts.Debug.assert(element.pos <= element.end); - element.pos = Math.min(element.pos, changeRangeNewEnd); - if (element.end >= changeRangeOldEnd) { - element.end += delta; - } - else { - element.end = Math.min(element.end, changeRangeNewEnd); - } - ts.Debug.assert(element.pos <= element.end); - if (element.parent) { - ts.Debug.assert(element.pos >= element.parent.pos); - ts.Debug.assert(element.end <= element.parent.end); - } - } - function checkNodePositions(node, aggressiveChecks) { - if (aggressiveChecks) { - var pos = node.pos; - forEachChild(node, function (child) { - ts.Debug.assert(child.pos >= pos); - pos = child.end; - }); - ts.Debug.assert(pos <= node.end); - } - } - function updateTokenPositionsAndMarkElements(sourceFile, changeStart, changeRangeOldEnd, changeRangeNewEnd, delta, oldText, newText, aggressiveChecks) { - visitNode(sourceFile); - return; - function visitNode(child) { - ts.Debug.assert(child.pos <= child.end); - if (child.pos > changeRangeOldEnd) { - moveElementEntirelyPastChangeRange(child, false, delta, oldText, newText, aggressiveChecks); - return; - } - var fullEnd = child.end; - if (fullEnd >= changeStart) { - child.intersectsChange = true; - child._children = undefined; - adjustIntersectingElement(child, changeStart, changeRangeOldEnd, changeRangeNewEnd, delta); - forEachChild(child, visitNode, visitArray); - checkNodePositions(child, aggressiveChecks); - return; - } - ts.Debug.assert(fullEnd < changeStart); - } - function visitArray(array) { - ts.Debug.assert(array.pos <= array.end); - if (array.pos > changeRangeOldEnd) { - moveElementEntirelyPastChangeRange(array, true, delta, oldText, newText, aggressiveChecks); - return; - } - var fullEnd = array.end; - if (fullEnd >= changeStart) { - array.intersectsChange = true; - array._children = undefined; - adjustIntersectingElement(array, changeStart, changeRangeOldEnd, changeRangeNewEnd, delta); - for (var _i = 0; _i < array.length; _i++) { - var node = array[_i]; - visitNode(node); - } - return; - } - ts.Debug.assert(fullEnd < changeStart); - } - } - function extendToAffectedRange(sourceFile, changeRange) { - var maxLookahead = 1; - var start = changeRange.span.start; - for (var i = 0; start > 0 && i <= maxLookahead; i++) { - var nearestNode = findNearestNodeStartingBeforeOrAtPosition(sourceFile, start); - ts.Debug.assert(nearestNode.pos <= start); - var position = nearestNode.pos; - start = Math.max(0, position - 1); - } - var finalSpan = ts.createTextSpanFromBounds(start, ts.textSpanEnd(changeRange.span)); - var finalLength = changeRange.newLength + (changeRange.span.start - start); - return ts.createTextChangeRange(finalSpan, finalLength); - } - function findNearestNodeStartingBeforeOrAtPosition(sourceFile, position) { - var bestResult = sourceFile; - var lastNodeEntirelyBeforePosition; - forEachChild(sourceFile, visit); - if (lastNodeEntirelyBeforePosition) { - var lastChildOfLastEntireNodeBeforePosition = getLastChild(lastNodeEntirelyBeforePosition); - if (lastChildOfLastEntireNodeBeforePosition.pos > bestResult.pos) { - bestResult = lastChildOfLastEntireNodeBeforePosition; - } - } - return bestResult; - function getLastChild(node) { - while (true) { - var lastChild = getLastChildWorker(node); - if (lastChild) { - node = lastChild; - } - else { - return node; - } - } - } - function getLastChildWorker(node) { - var last = undefined; - forEachChild(node, function (child) { - if (ts.nodeIsPresent(child)) { - last = child; - } - }); - return last; - } - function visit(child) { - if (ts.nodeIsMissing(child)) { - return; - } - if (child.pos <= position) { - if (child.pos >= bestResult.pos) { - bestResult = child; - } - if (position < child.end) { - forEachChild(child, visit); - return true; - } - else { - ts.Debug.assert(child.end <= position); - lastNodeEntirelyBeforePosition = child; - } - } - else { - ts.Debug.assert(child.pos > position); - return true; - } - } - } - function checkChangeRange(sourceFile, newText, textChangeRange, aggressiveChecks) { - var oldText = sourceFile.text; - if (textChangeRange) { - ts.Debug.assert((oldText.length - textChangeRange.span.length + textChangeRange.newLength) === newText.length); - if (aggressiveChecks || ts.Debug.shouldAssert(3)) { - var oldTextPrefix = oldText.substr(0, textChangeRange.span.start); - var newTextPrefix = newText.substr(0, textChangeRange.span.start); - ts.Debug.assert(oldTextPrefix === newTextPrefix); - var oldTextSuffix = oldText.substring(ts.textSpanEnd(textChangeRange.span), oldText.length); - var newTextSuffix = newText.substring(ts.textSpanEnd(ts.textChangeRangeNewSpan(textChangeRange)), newText.length); - ts.Debug.assert(oldTextSuffix === newTextSuffix); - } - } - } - function createSyntaxCursor(sourceFile) { - var currentArray = sourceFile.statements; - var currentArrayIndex = 0; - ts.Debug.assert(currentArrayIndex < currentArray.length); - var current = currentArray[currentArrayIndex]; - var lastQueriedPosition = -1; - return { - currentNode: function (position) { - if (position !== lastQueriedPosition) { - if (current && current.end === position && currentArrayIndex < (currentArray.length - 1)) { - currentArrayIndex++; - current = currentArray[currentArrayIndex]; - } - if (!current || current.pos !== position) { - findHighestListElementThatStartsAtPosition(position); - } - } - lastQueriedPosition = position; - ts.Debug.assert(!current || current.pos === position); - return current; - } - }; - function findHighestListElementThatStartsAtPosition(position) { - currentArray = undefined; - currentArrayIndex = -1; - current = undefined; - forEachChild(sourceFile, visitNode, visitArray); - return; - function visitNode(node) { - if (position >= node.pos && position < node.end) { - forEachChild(node, visitNode, visitArray); - return true; - } - return false; - } - function visitArray(array) { - if (position >= array.pos && position < array.end) { - for (var i = 0, n = array.length; i < n; i++) { - var child = array[i]; - if (child) { - if (child.pos === position) { - currentArray = array; - currentArrayIndex = i; - current = child; - return true; - } - else { - if (child.pos < position && position < child.end) { - forEachChild(child, visitNode, visitArray); - return true; - } - } - } - } - } - return false; - } - } - } - })(IncrementalParser || (IncrementalParser = {})); -})(ts || (ts = {})); -var ts; -(function (ts) { - var nextSymbolId = 1; - var nextNodeId = 1; - var nextMergeId = 1; - function getNodeId(node) { - if (!node.id) - node.id = nextNodeId++; - return node.id; - } - ts.getNodeId = getNodeId; - ts.checkTime = 0; - function getSymbolId(symbol) { - if (!symbol.id) { - symbol.id = nextSymbolId++; - } - return symbol.id; - } - ts.getSymbolId = getSymbolId; - function createTypeChecker(host, produceDiagnostics) { - var cancellationToken; - var Symbol = ts.objectAllocator.getSymbolConstructor(); - var Type = ts.objectAllocator.getTypeConstructor(); - var Signature = ts.objectAllocator.getSignatureConstructor(); - var typeCount = 0; - var symbolCount = 0; - var emptyArray = []; - var emptySymbols = {}; - var compilerOptions = host.getCompilerOptions(); - var languageVersion = compilerOptions.target || 0; - var modulekind = compilerOptions.module ? compilerOptions.module : languageVersion === 2 ? 5 : 0; - var emitResolver = createResolver(); - var undefinedSymbol = createSymbol(4 | 67108864, "undefined"); - var argumentsSymbol = createSymbol(4 | 67108864, "arguments"); - var checker = { - getNodeCount: function () { return ts.sum(host.getSourceFiles(), "nodeCount"); }, - getIdentifierCount: function () { return ts.sum(host.getSourceFiles(), "identifierCount"); }, - getSymbolCount: function () { return ts.sum(host.getSourceFiles(), "symbolCount") + symbolCount; }, - getTypeCount: function () { return typeCount; }, - isUndefinedSymbol: function (symbol) { return symbol === undefinedSymbol; }, - isArgumentsSymbol: function (symbol) { return symbol === argumentsSymbol; }, - getDiagnostics: getDiagnostics, - getGlobalDiagnostics: getGlobalDiagnostics, - getTypeOfSymbolAtLocation: getNarrowedTypeOfSymbol, - getDeclaredTypeOfSymbol: getDeclaredTypeOfSymbol, - getPropertiesOfType: getPropertiesOfType, - getPropertyOfType: getPropertyOfType, - getSignaturesOfType: getSignaturesOfType, - getIndexTypeOfType: getIndexTypeOfType, - getBaseTypes: getBaseTypes, - getReturnTypeOfSignature: getReturnTypeOfSignature, - getSymbolsInScope: getSymbolsInScope, - getSymbolAtLocation: getSymbolAtLocation, - getShorthandAssignmentValueSymbol: getShorthandAssignmentValueSymbol, - getTypeAtLocation: getTypeOfNode, - typeToString: typeToString, - getSymbolDisplayBuilder: getSymbolDisplayBuilder, - symbolToString: symbolToString, - getAugmentedPropertiesOfType: getAugmentedPropertiesOfType, - getRootSymbols: getRootSymbols, - getContextualType: getContextualType, - getFullyQualifiedName: getFullyQualifiedName, - getResolvedSignature: getResolvedSignature, - getConstantValue: getConstantValue, - isValidPropertyAccess: isValidPropertyAccess, - getSignatureFromDeclaration: getSignatureFromDeclaration, - isImplementationOfOverload: isImplementationOfOverload, - getAliasedSymbol: resolveAlias, - getEmitResolver: getEmitResolver, - getExportsOfModule: getExportsOfModuleAsArray, - getJsxElementAttributesType: getJsxElementAttributesType, - getJsxIntrinsicTagNames: getJsxIntrinsicTagNames, - isOptionalParameter: isOptionalParameter - }; - var unknownSymbol = createSymbol(4 | 67108864, "unknown"); - var resolvingSymbol = createSymbol(67108864, "__resolving__"); - var anyType = createIntrinsicType(1, "any"); - var stringType = createIntrinsicType(2, "string"); - var numberType = createIntrinsicType(4, "number"); - var booleanType = createIntrinsicType(8, "boolean"); - var esSymbolType = createIntrinsicType(16777216, "symbol"); - var voidType = createIntrinsicType(16, "void"); - var undefinedType = createIntrinsicType(32 | 2097152, "undefined"); - var nullType = createIntrinsicType(64 | 2097152, "null"); - var unknownType = createIntrinsicType(1, "unknown"); - var circularType = createIntrinsicType(1, "__circular__"); - var emptyObjectType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); - var emptyGenericType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); - emptyGenericType.instantiations = {}; - var anyFunctionType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); - anyFunctionType.flags |= 8388608; - var noConstraintType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); - var anySignature = createSignature(undefined, undefined, emptyArray, anyType, undefined, 0, false, false); - var unknownSignature = createSignature(undefined, undefined, emptyArray, unknownType, undefined, 0, false, false); - var globals = {}; - var globalESSymbolConstructorSymbol; - var getGlobalPromiseConstructorSymbol; - var globalObjectType; - var globalFunctionType; - var globalArrayType; - var globalStringType; - var globalNumberType; - var globalBooleanType; - var globalRegExpType; - var globalTemplateStringsArrayType; - var globalESSymbolType; - var jsxElementType; - var jsxIntrinsicElementsType; - var globalIterableType; - var globalIteratorType; - var globalIterableIteratorType; - var anyArrayType; - var getGlobalClassDecoratorType; - var getGlobalParameterDecoratorType; - var getGlobalPropertyDecoratorType; - var getGlobalMethodDecoratorType; - var getGlobalTypedPropertyDescriptorType; - var getGlobalPromiseType; - var tryGetGlobalPromiseType; - var getGlobalPromiseLikeType; - var getInstantiatedGlobalPromiseLikeType; - var getGlobalPromiseConstructorLikeType; - var getGlobalThenableType; - var tupleTypes = {}; - var unionTypes = {}; - var intersectionTypes = {}; - var stringLiteralTypes = {}; - var emitExtends = false; - var emitDecorate = false; - var emitParam = false; - var emitAwaiter = false; - var emitGenerator = false; - var resolutionTargets = []; - var resolutionResults = []; - var resolutionPropertyNames = []; - var mergedSymbols = []; - var symbolLinks = []; - var nodeLinks = []; - var potentialThisCollisions = []; - var awaitedTypeStack = []; - var diagnostics = ts.createDiagnosticCollection(); - var primitiveTypeInfo = { - "string": { - type: stringType, - flags: 258 - }, - "number": { - type: numberType, - flags: 132 - }, - "boolean": { - type: booleanType, - flags: 8 - }, - "symbol": { - type: esSymbolType, - flags: 16777216 - } - }; - var JsxNames = { - JSX: "JSX", - IntrinsicElements: "IntrinsicElements", - ElementClass: "ElementClass", - ElementAttributesPropertyNameContainer: "ElementAttributesProperty", - Element: "Element" - }; - var subtypeRelation = {}; - var assignableRelation = {}; - var identityRelation = {}; - var _displayBuilder; - initializeTypeChecker(); - return checker; - function getEmitResolver(sourceFile, cancellationToken) { - getDiagnostics(sourceFile, cancellationToken); - return emitResolver; - } - function error(location, message, arg0, arg1, arg2) { - var diagnostic = location - ? ts.createDiagnosticForNode(location, message, arg0, arg1, arg2) - : ts.createCompilerDiagnostic(message, arg0, arg1, arg2); - diagnostics.add(diagnostic); - } - function createSymbol(flags, name) { - symbolCount++; - return new Symbol(flags, name); - } - function getExcludedSymbolFlags(flags) { - var result = 0; - if (flags & 2) - result |= 107455; - if (flags & 1) - result |= 107454; - if (flags & 4) - result |= 107455; - if (flags & 8) - result |= 107455; - if (flags & 16) - result |= 106927; - if (flags & 32) - result |= 899519; - if (flags & 64) - result |= 792960; - if (flags & 256) - result |= 899327; - if (flags & 128) - result |= 899967; - if (flags & 512) - result |= 106639; - if (flags & 8192) - result |= 99263; - if (flags & 32768) - result |= 41919; - if (flags & 65536) - result |= 74687; - if (flags & 262144) - result |= 530912; - if (flags & 524288) - result |= 793056; - if (flags & 8388608) - result |= 8388608; - return result; - } - function recordMergedSymbol(target, source) { - if (!source.mergeId) - source.mergeId = nextMergeId++; - mergedSymbols[source.mergeId] = target; - } - function cloneSymbol(symbol) { - var result = createSymbol(symbol.flags | 33554432, symbol.name); - result.declarations = symbol.declarations.slice(0); - result.parent = symbol.parent; - if (symbol.valueDeclaration) - result.valueDeclaration = symbol.valueDeclaration; - if (symbol.constEnumOnlyModule) - result.constEnumOnlyModule = true; - if (symbol.members) - result.members = cloneSymbolTable(symbol.members); - if (symbol.exports) - result.exports = cloneSymbolTable(symbol.exports); - recordMergedSymbol(result, symbol); - return result; - } - function mergeSymbol(target, source) { - if (!(target.flags & getExcludedSymbolFlags(source.flags))) { - if (source.flags & 512 && target.flags & 512 && target.constEnumOnlyModule && !source.constEnumOnlyModule) { - target.constEnumOnlyModule = false; - } - target.flags |= source.flags; - if (!target.valueDeclaration && source.valueDeclaration) - target.valueDeclaration = source.valueDeclaration; - ts.forEach(source.declarations, function (node) { - target.declarations.push(node); - }); - if (source.members) { - if (!target.members) - target.members = {}; - mergeSymbolTable(target.members, source.members); - } - if (source.exports) { - if (!target.exports) - target.exports = {}; - mergeSymbolTable(target.exports, source.exports); - } - recordMergedSymbol(target, source); - } - else { - var message = target.flags & 2 || source.flags & 2 - ? ts.Diagnostics.Cannot_redeclare_block_scoped_variable_0 : ts.Diagnostics.Duplicate_identifier_0; - ts.forEach(source.declarations, function (node) { - error(node.name ? node.name : node, message, symbolToString(source)); - }); - ts.forEach(target.declarations, function (node) { - error(node.name ? node.name : node, message, symbolToString(source)); - }); - } - } - function cloneSymbolTable(symbolTable) { - var result = {}; - for (var id in symbolTable) { - if (ts.hasProperty(symbolTable, id)) { - result[id] = symbolTable[id]; - } - } - return result; - } - function mergeSymbolTable(target, source) { - for (var id in source) { - if (ts.hasProperty(source, id)) { - if (!ts.hasProperty(target, id)) { - target[id] = source[id]; - } - else { - var symbol = target[id]; - if (!(symbol.flags & 33554432)) { - target[id] = symbol = cloneSymbol(symbol); - } - mergeSymbol(symbol, source[id]); - } - } - } - } - function getSymbolLinks(symbol) { - if (symbol.flags & 67108864) - return symbol; - var id = getSymbolId(symbol); - return symbolLinks[id] || (symbolLinks[id] = {}); - } - function getNodeLinks(node) { - var nodeId = getNodeId(node); - return nodeLinks[nodeId] || (nodeLinks[nodeId] = {}); - } - function getSourceFile(node) { - return ts.getAncestor(node, 248); - } - function isGlobalSourceFile(node) { - return node.kind === 248 && !ts.isExternalModule(node); - } - function getSymbol(symbols, name, meaning) { - if (meaning && ts.hasProperty(symbols, name)) { - var symbol = symbols[name]; - ts.Debug.assert((symbol.flags & 16777216) === 0, "Should never get an instantiated symbol here."); - if (symbol.flags & meaning) { - return symbol; - } - if (symbol.flags & 8388608) { - var target = resolveAlias(symbol); - if (target === unknownSymbol || target.flags & meaning) { - return symbol; - } - } - } - } - function isBlockScopedNameDeclaredBeforeUse(declaration, usage) { - var declarationFile = ts.getSourceFileOfNode(declaration); - var useFile = ts.getSourceFileOfNode(usage); - if (declarationFile !== useFile) { - if (modulekind || (!compilerOptions.outFile && !compilerOptions.out)) { - return true; - } - var sourceFiles = host.getSourceFiles(); - return ts.indexOf(sourceFiles, declarationFile) <= ts.indexOf(sourceFiles, useFile); - } - if (declaration.pos <= usage.pos) { - return declaration.kind !== 211 || - !isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage); - } - return isUsedInFunctionOrNonStaticProperty(declaration, usage); - function isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage) { - var container = ts.getEnclosingBlockScopeContainer(declaration); - if (declaration.parent.parent.kind === 193 || - declaration.parent.parent.kind === 199) { - return isSameScopeDescendentOf(usage, declaration, container); - } - else if (declaration.parent.parent.kind === 201 || - declaration.parent.parent.kind === 200) { - var expression = declaration.parent.parent.expression; - return isSameScopeDescendentOf(usage, expression, container); - } - } - function isUsedInFunctionOrNonStaticProperty(declaration, usage) { - var container = ts.getEnclosingBlockScopeContainer(declaration); - var current = usage; - while (current) { - if (current === container) { - return false; - } - if (ts.isFunctionLike(current)) { - return true; - } - var initializerOfNonStaticProperty = current.parent && - current.parent.kind === 141 && - (current.parent.flags & 128) === 0 && - current.parent.initializer === current; - if (initializerOfNonStaticProperty) { - return true; - } - current = current.parent; - } - return false; - } - } - function resolveName(location, name, meaning, nameNotFoundMessage, nameArg) { - var result; - var lastLocation; - var propertyWithInvalidInitializer; - var errorLocation = location; - var grandparent; - loop: while (location) { - if (location.locals && !isGlobalSourceFile(location)) { - if (result = getSymbol(location.locals, name, meaning)) { - if (!(meaning & 793056) || - !(result.flags & (793056 & ~262144)) || - !ts.isFunctionLike(location) || - lastLocation === location.body) { - break loop; - } - result = undefined; - } - } - switch (location.kind) { - case 248: - if (!ts.isExternalModule(location)) - break; - case 218: - var moduleExports = getSymbolOfNode(location).exports; - if (location.kind === 248 || - (location.kind === 218 && location.name.kind === 9)) { - if (ts.hasProperty(moduleExports, name) && - moduleExports[name].flags === 8388608 && - ts.getDeclarationOfKind(moduleExports[name], 230)) { - break; - } - result = moduleExports["default"]; - var localSymbol = ts.getLocalSymbolForExportDefault(result); - if (result && localSymbol && (result.flags & meaning) && localSymbol.name === name) { - break loop; - } - result = undefined; - } - if (result = getSymbol(moduleExports, name, meaning & 8914931)) { - break loop; - } - break; - case 217: - if (result = getSymbol(getSymbolOfNode(location).exports, name, meaning & 8)) { - break loop; - } - break; - case 141: - case 140: - if (ts.isClassLike(location.parent) && !(location.flags & 128)) { - var ctor = findConstructorDeclaration(location.parent); - if (ctor && ctor.locals) { - if (getSymbol(ctor.locals, name, meaning & 107455)) { - propertyWithInvalidInitializer = location; - } - } - } - break; - case 214: - case 186: - case 215: - if (result = getSymbol(getSymbolOfNode(location).members, name, meaning & 793056)) { - if (lastLocation && lastLocation.flags & 128) { - error(errorLocation, ts.Diagnostics.Static_members_cannot_reference_class_type_parameters); - return undefined; - } - break loop; - } - if (location.kind === 186 && meaning & 32) { - var className = location.name; - if (className && name === className.text) { - result = location.symbol; - break loop; - } - } - break; - case 136: - grandparent = location.parent.parent; - if (ts.isClassLike(grandparent) || grandparent.kind === 215) { - if (result = getSymbol(getSymbolOfNode(grandparent).members, name, meaning & 793056)) { - error(errorLocation, ts.Diagnostics.A_computed_property_name_cannot_reference_a_type_parameter_from_its_containing_type); - return undefined; - } - } - break; - case 143: - case 142: - case 144: - case 145: - case 146: - case 213: - case 174: - if (meaning & 3 && name === "arguments") { - result = argumentsSymbol; - break loop; - } - break; - case 173: - if (meaning & 3 && name === "arguments") { - result = argumentsSymbol; - break loop; - } - if (meaning & 16) { - var functionName = location.name; - if (functionName && name === functionName.text) { - result = location.symbol; - break loop; - } - } - break; - case 139: - if (location.parent && location.parent.kind === 138) { - location = location.parent; - } - if (location.parent && ts.isClassElement(location.parent)) { - location = location.parent; - } - break; - } - lastLocation = location; - location = location.parent; - } - if (!result) { - result = getSymbol(globals, name, meaning); - } - if (!result) { - if (nameNotFoundMessage) { - error(errorLocation, nameNotFoundMessage, typeof nameArg === "string" ? nameArg : ts.declarationNameToString(nameArg)); - } - return undefined; - } - if (nameNotFoundMessage) { - if (propertyWithInvalidInitializer) { - var propertyName = propertyWithInvalidInitializer.name; - error(errorLocation, ts.Diagnostics.Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor, ts.declarationNameToString(propertyName), typeof nameArg === "string" ? nameArg : ts.declarationNameToString(nameArg)); - return undefined; - } - if (meaning & 2) { - var exportOrLocalSymbol = getExportSymbolOfValueSymbolIfExported(result); - if (exportOrLocalSymbol.flags & 2) { - checkResolvedBlockScopedVariable(exportOrLocalSymbol, errorLocation); - } - } - } - return result; - } - function checkResolvedBlockScopedVariable(result, errorLocation) { - 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 (!isBlockScopedNameDeclaredBeforeUse(ts.getAncestor(declaration, 211), errorLocation)) { - error(errorLocation, ts.Diagnostics.Block_scoped_variable_0_used_before_its_declaration, ts.declarationNameToString(declaration.name)); - } - } - function isSameScopeDescendentOf(initial, parent, stopAt) { - if (!parent) { - return false; - } - for (var current = initial; current && current !== stopAt && !ts.isFunctionLike(current); current = current.parent) { - if (current === parent) { - return true; - } - } - return false; - } - function getAnyImportSyntax(node) { - if (ts.isAliasSymbolDeclaration(node)) { - if (node.kind === 221) { - return node; - } - while (node && node.kind !== 222) { - node = node.parent; - } - return node; - } - } - function getDeclarationOfAliasSymbol(symbol) { - return ts.forEach(symbol.declarations, function (d) { return ts.isAliasSymbolDeclaration(d) ? d : undefined; }); - } - function getTargetOfImportEqualsDeclaration(node) { - if (node.moduleReference.kind === 232) { - return resolveExternalModuleSymbol(resolveExternalModuleName(node, ts.getExternalModuleImportEqualsDeclarationExpression(node))); - } - return getSymbolOfPartOfRightHandSideOfImportEquals(node.moduleReference, node); - } - function getTargetOfImportClause(node) { - var moduleSymbol = resolveExternalModuleName(node, node.parent.moduleSpecifier); - if (moduleSymbol) { - var exportDefaultSymbol = resolveSymbol(moduleSymbol.exports["default"]); - if (!exportDefaultSymbol) { - error(node.name, ts.Diagnostics.Module_0_has_no_default_export, symbolToString(moduleSymbol)); - } - return exportDefaultSymbol; - } - } - function getTargetOfNamespaceImport(node) { - var moduleSpecifier = node.parent.parent.moduleSpecifier; - return resolveESModuleSymbol(resolveExternalModuleName(node, moduleSpecifier), moduleSpecifier); - } - function getMemberOfModuleVariable(moduleSymbol, name) { - if (moduleSymbol.flags & 3) { - var typeAnnotation = moduleSymbol.valueDeclaration.type; - if (typeAnnotation) { - return getPropertyOfType(getTypeFromTypeNode(typeAnnotation), name); - } - } - } - function combineValueAndTypeSymbols(valueSymbol, typeSymbol) { - if (valueSymbol.flags & (793056 | 1536)) { - return valueSymbol; - } - var result = createSymbol(valueSymbol.flags | typeSymbol.flags, valueSymbol.name); - result.declarations = ts.concatenate(valueSymbol.declarations, typeSymbol.declarations); - result.parent = valueSymbol.parent || typeSymbol.parent; - if (valueSymbol.valueDeclaration) - result.valueDeclaration = valueSymbol.valueDeclaration; - if (typeSymbol.members) - result.members = typeSymbol.members; - if (valueSymbol.exports) - result.exports = valueSymbol.exports; - return result; - } - function getExportOfModule(symbol, name) { - if (symbol.flags & 1536) { - var exports = getExportsOfSymbol(symbol); - if (ts.hasProperty(exports, name)) { - return resolveSymbol(exports[name]); - } - } - } - function getPropertyOfVariable(symbol, name) { - if (symbol.flags & 3) { - var typeAnnotation = symbol.valueDeclaration.type; - if (typeAnnotation) { - return resolveSymbol(getPropertyOfType(getTypeFromTypeNode(typeAnnotation), name)); - } - } - } - function getExternalModuleMember(node, specifier) { - var moduleSymbol = resolveExternalModuleName(node, node.moduleSpecifier); - var targetSymbol = resolveESModuleSymbol(moduleSymbol, node.moduleSpecifier); - if (targetSymbol) { - var name_9 = specifier.propertyName || specifier.name; - if (name_9.text) { - var symbolFromModule = getExportOfModule(targetSymbol, name_9.text); - var symbolFromVariable = getPropertyOfVariable(targetSymbol, name_9.text); - var symbol = symbolFromModule && symbolFromVariable ? - combineValueAndTypeSymbols(symbolFromVariable, symbolFromModule) : - symbolFromModule || symbolFromVariable; - if (!symbol) { - error(name_9, ts.Diagnostics.Module_0_has_no_exported_member_1, getFullyQualifiedName(moduleSymbol), ts.declarationNameToString(name_9)); - } - return symbol; - } - } - } - function getTargetOfImportSpecifier(node) { - return getExternalModuleMember(node.parent.parent.parent, node); - } - function getTargetOfExportSpecifier(node) { - return node.parent.parent.moduleSpecifier ? - getExternalModuleMember(node.parent.parent, node) : - resolveEntityName(node.propertyName || node.name, 107455 | 793056 | 1536); - } - function getTargetOfExportAssignment(node) { - return resolveEntityName(node.expression, 107455 | 793056 | 1536); - } - function getTargetOfAliasDeclaration(node) { - switch (node.kind) { - case 221: - return getTargetOfImportEqualsDeclaration(node); - case 223: - return getTargetOfImportClause(node); - case 224: - return getTargetOfNamespaceImport(node); - case 226: - return getTargetOfImportSpecifier(node); - case 230: - return getTargetOfExportSpecifier(node); - case 227: - return getTargetOfExportAssignment(node); - } - } - function resolveSymbol(symbol) { - return symbol && symbol.flags & 8388608 && !(symbol.flags & (107455 | 793056 | 1536)) ? resolveAlias(symbol) : symbol; - } - function resolveAlias(symbol) { - ts.Debug.assert((symbol.flags & 8388608) !== 0, "Should only get Alias here."); - var links = getSymbolLinks(symbol); - if (!links.target) { - links.target = resolvingSymbol; - var node = getDeclarationOfAliasSymbol(symbol); - var target = getTargetOfAliasDeclaration(node); - if (links.target === resolvingSymbol) { - links.target = target || unknownSymbol; - } - else { - error(node, ts.Diagnostics.Circular_definition_of_import_alias_0, symbolToString(symbol)); - } - } - else if (links.target === resolvingSymbol) { - links.target = unknownSymbol; - } - return links.target; - } - function markExportAsReferenced(node) { - var symbol = getSymbolOfNode(node); - var target = resolveAlias(symbol); - if (target) { - var markAlias = (target === unknownSymbol && compilerOptions.isolatedModules) || - (target !== unknownSymbol && (target.flags & 107455) && !isConstEnumOrConstEnumOnlyModule(target)); - if (markAlias) { - markAliasSymbolAsReferenced(symbol); - } - } - } - function markAliasSymbolAsReferenced(symbol) { - var links = getSymbolLinks(symbol); - if (!links.referenced) { - links.referenced = true; - var node = getDeclarationOfAliasSymbol(symbol); - if (node.kind === 227) { - checkExpressionCached(node.expression); - } - else if (node.kind === 230) { - checkExpressionCached(node.propertyName || node.name); - } - else if (ts.isInternalModuleImportEqualsDeclaration(node)) { - checkExpressionCached(node.moduleReference); - } - } - } - function getSymbolOfPartOfRightHandSideOfImportEquals(entityName, importDeclaration) { - if (!importDeclaration) { - importDeclaration = ts.getAncestor(entityName, 221); - ts.Debug.assert(importDeclaration !== undefined); - } - if (entityName.kind === 69 && ts.isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { - entityName = entityName.parent; - } - if (entityName.kind === 69 || entityName.parent.kind === 135) { - return resolveEntityName(entityName, 1536); - } - else { - ts.Debug.assert(entityName.parent.kind === 221); - return resolveEntityName(entityName, 107455 | 793056 | 1536); - } - } - function getFullyQualifiedName(symbol) { - return symbol.parent ? getFullyQualifiedName(symbol.parent) + "." + symbolToString(symbol) : symbolToString(symbol); - } - function resolveEntityName(name, meaning, ignoreErrors) { - if (ts.nodeIsMissing(name)) { - return undefined; - } - var symbol; - if (name.kind === 69) { - var message = meaning === 1536 ? ts.Diagnostics.Cannot_find_namespace_0 : ts.Diagnostics.Cannot_find_name_0; - symbol = resolveName(name, name.text, meaning, ignoreErrors ? undefined : message, name); - if (!symbol) { - return undefined; - } - } - else if (name.kind === 135 || name.kind === 166) { - var left = name.kind === 135 ? name.left : name.expression; - var right = name.kind === 135 ? name.right : name.name; - var namespace = resolveEntityName(left, 1536, ignoreErrors); - if (!namespace || namespace === unknownSymbol || ts.nodeIsMissing(right)) { - return undefined; - } - symbol = getSymbol(getExportsOfSymbol(namespace), right.text, meaning); - if (!symbol) { - if (!ignoreErrors) { - error(right, ts.Diagnostics.Module_0_has_no_exported_member_1, getFullyQualifiedName(namespace), ts.declarationNameToString(right)); - } - return undefined; - } - } - else { - ts.Debug.fail("Unknown entity name kind."); - } - ts.Debug.assert((symbol.flags & 16777216) === 0, "Should never get an instantiated symbol here."); - return symbol.flags & meaning ? symbol : resolveAlias(symbol); - } - function resolveExternalModuleName(location, moduleReferenceExpression) { - if (moduleReferenceExpression.kind !== 9) { - return; - } - var moduleReferenceLiteral = moduleReferenceExpression; - var searchPath = ts.getDirectoryPath(getSourceFile(location).fileName); - var moduleName = ts.escapeIdentifier(moduleReferenceLiteral.text); - if (moduleName === undefined) { - return; - } - var isRelative = ts.isExternalModuleNameRelative(moduleName); - if (!isRelative) { - var symbol = getSymbol(globals, "\"" + moduleName + "\"", 512); - if (symbol) { - return symbol; - } - } - var resolvedModule = ts.getResolvedModule(getSourceFile(location), moduleReferenceLiteral.text); - var sourceFile = resolvedModule && host.getSourceFile(resolvedModule.resolvedFileName); - if (sourceFile) { - if (sourceFile.symbol) { - return sourceFile.symbol; - } - error(moduleReferenceLiteral, ts.Diagnostics.File_0_is_not_a_module, sourceFile.fileName); - return; - } - error(moduleReferenceLiteral, ts.Diagnostics.Cannot_find_module_0, moduleName); - } - function resolveExternalModuleSymbol(moduleSymbol) { - return moduleSymbol && resolveSymbol(moduleSymbol.exports["export="]) || moduleSymbol; - } - function resolveESModuleSymbol(moduleSymbol, moduleReferenceExpression) { - var symbol = resolveExternalModuleSymbol(moduleSymbol); - if (symbol && !(symbol.flags & (1536 | 3))) { - error(moduleReferenceExpression, ts.Diagnostics.Module_0_resolves_to_a_non_module_entity_and_cannot_be_imported_using_this_construct, symbolToString(moduleSymbol)); - symbol = undefined; - } - return symbol; - } - function getExportAssignmentSymbol(moduleSymbol) { - return moduleSymbol.exports["export="]; - } - function getExportsOfModuleAsArray(moduleSymbol) { - return symbolsToArray(getExportsOfModule(moduleSymbol)); - } - function getExportsOfSymbol(symbol) { - return symbol.flags & 1536 ? getExportsOfModule(symbol) : symbol.exports || emptySymbols; - } - function getExportsOfModule(moduleSymbol) { - var links = getSymbolLinks(moduleSymbol); - return links.resolvedExports || (links.resolvedExports = getExportsForModule(moduleSymbol)); - } - function extendExportSymbols(target, source) { - for (var id in source) { - if (id !== "default" && !ts.hasProperty(target, id)) { - target[id] = source[id]; - } - } - } - function getExportsForModule(moduleSymbol) { - var result; - var visitedSymbols = []; - visit(moduleSymbol); - return result || moduleSymbol.exports; - function visit(symbol) { - if (symbol && symbol.flags & 1952 && !ts.contains(visitedSymbols, symbol)) { - visitedSymbols.push(symbol); - if (symbol !== moduleSymbol) { - if (!result) { - result = cloneSymbolTable(moduleSymbol.exports); - } - extendExportSymbols(result, symbol.exports); - } - var exportStars = symbol.exports["__export"]; - if (exportStars) { - for (var _i = 0, _a = exportStars.declarations; _i < _a.length; _i++) { - var node = _a[_i]; - visit(resolveExternalModuleName(node, node.moduleSpecifier)); - } - } - } - } - } - function getMergedSymbol(symbol) { - var merged; - return symbol && symbol.mergeId && (merged = mergedSymbols[symbol.mergeId]) ? merged : symbol; - } - function getSymbolOfNode(node) { - return getMergedSymbol(node.symbol); - } - function getParentOfSymbol(symbol) { - return getMergedSymbol(symbol.parent); - } - function getExportSymbolOfValueSymbolIfExported(symbol) { - return symbol && (symbol.flags & 1048576) !== 0 - ? getMergedSymbol(symbol.exportSymbol) - : symbol; - } - function symbolIsValue(symbol) { - if (symbol.flags & 16777216) { - return symbolIsValue(getSymbolLinks(symbol).target); - } - if (symbol.flags & 107455) { - return true; - } - if (symbol.flags & 8388608) { - return (resolveAlias(symbol).flags & 107455) !== 0; - } - return false; - } - function findConstructorDeclaration(node) { - var members = node.members; - for (var _i = 0; _i < members.length; _i++) { - var member = members[_i]; - if (member.kind === 144 && ts.nodeIsPresent(member.body)) { - return member; - } - } - } - function createType(flags) { - var result = new Type(checker, flags); - result.id = typeCount++; - return result; - } - function createIntrinsicType(kind, intrinsicName) { - var type = createType(kind); - type.intrinsicName = intrinsicName; - return type; - } - function createObjectType(kind, symbol) { - var type = createType(kind); - type.symbol = symbol; - return type; - } - function isReservedMemberName(name) { - return name.charCodeAt(0) === 95 && - name.charCodeAt(1) === 95 && - name.charCodeAt(2) !== 95 && - name.charCodeAt(2) !== 64; - } - function getNamedMembers(members) { - var result; - for (var id in members) { - if (ts.hasProperty(members, id)) { - if (!isReservedMemberName(id)) { - if (!result) - result = []; - var symbol = members[id]; - if (symbolIsValue(symbol)) { - result.push(symbol); - } - } - } - } - return result || emptyArray; - } - function setObjectTypeMembers(type, members, callSignatures, constructSignatures, stringIndexType, numberIndexType) { - type.members = members; - type.properties = getNamedMembers(members); - type.callSignatures = callSignatures; - type.constructSignatures = constructSignatures; - if (stringIndexType) - type.stringIndexType = stringIndexType; - if (numberIndexType) - type.numberIndexType = numberIndexType; - return type; - } - function createAnonymousType(symbol, members, callSignatures, constructSignatures, stringIndexType, numberIndexType) { - return setObjectTypeMembers(createObjectType(65536, symbol), members, callSignatures, constructSignatures, stringIndexType, numberIndexType); - } - function forEachSymbolTableInScope(enclosingDeclaration, callback) { - var result; - for (var location_1 = enclosingDeclaration; location_1; location_1 = location_1.parent) { - if (location_1.locals && !isGlobalSourceFile(location_1)) { - if (result = callback(location_1.locals)) { - return result; - } - } - switch (location_1.kind) { - case 248: - if (!ts.isExternalModule(location_1)) { - break; - } - case 218: - if (result = callback(getSymbolOfNode(location_1).exports)) { - return result; - } - break; - case 214: - case 215: - if (result = callback(getSymbolOfNode(location_1).members)) { - return result; - } - break; - } - } - return callback(globals); - } - function getQualifiedLeftMeaning(rightMeaning) { - return rightMeaning === 107455 ? 107455 : 1536; - } - function getAccessibleSymbolChain(symbol, enclosingDeclaration, meaning, useOnlyExternalAliasing) { - function getAccessibleSymbolChainFromSymbolTable(symbols) { - function canQualifySymbol(symbolFromSymbolTable, meaning) { - if (!needsQualification(symbolFromSymbolTable, enclosingDeclaration, meaning)) { - return true; - } - var accessibleParent = getAccessibleSymbolChain(symbolFromSymbolTable.parent, enclosingDeclaration, getQualifiedLeftMeaning(meaning), useOnlyExternalAliasing); - return !!accessibleParent; - } - function isAccessible(symbolFromSymbolTable, resolvedAliasSymbol) { - if (symbol === (resolvedAliasSymbol || symbolFromSymbolTable)) { - return !ts.forEach(symbolFromSymbolTable.declarations, hasExternalModuleSymbol) && - canQualifySymbol(symbolFromSymbolTable, meaning); - } - } - if (isAccessible(ts.lookUp(symbols, symbol.name))) { - return [symbol]; - } - return ts.forEachValue(symbols, function (symbolFromSymbolTable) { - if (symbolFromSymbolTable.flags & 8388608 - && symbolFromSymbolTable.name !== "export=" - && !ts.getDeclarationOfKind(symbolFromSymbolTable, 230)) { - if (!useOnlyExternalAliasing || - ts.forEach(symbolFromSymbolTable.declarations, ts.isExternalModuleImportEqualsDeclaration)) { - var resolvedImportedSymbol = resolveAlias(symbolFromSymbolTable); - if (isAccessible(symbolFromSymbolTable, resolveAlias(symbolFromSymbolTable))) { - return [symbolFromSymbolTable]; - } - var accessibleSymbolsFromExports = resolvedImportedSymbol.exports ? getAccessibleSymbolChainFromSymbolTable(resolvedImportedSymbol.exports) : undefined; - if (accessibleSymbolsFromExports && canQualifySymbol(symbolFromSymbolTable, getQualifiedLeftMeaning(meaning))) { - return [symbolFromSymbolTable].concat(accessibleSymbolsFromExports); - } - } - } - }); - } - if (symbol) { - return forEachSymbolTableInScope(enclosingDeclaration, getAccessibleSymbolChainFromSymbolTable); - } - } - function needsQualification(symbol, enclosingDeclaration, meaning) { - var qualify = false; - forEachSymbolTableInScope(enclosingDeclaration, function (symbolTable) { - if (!ts.hasProperty(symbolTable, symbol.name)) { - return false; - } - var symbolFromSymbolTable = symbolTable[symbol.name]; - if (symbolFromSymbolTable === symbol) { - return true; - } - symbolFromSymbolTable = (symbolFromSymbolTable.flags & 8388608 && !ts.getDeclarationOfKind(symbolFromSymbolTable, 230)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; - if (symbolFromSymbolTable.flags & meaning) { - qualify = true; - return true; - } - return false; - }); - return qualify; - } - function isSymbolAccessible(symbol, enclosingDeclaration, meaning) { - if (symbol && enclosingDeclaration && !(symbol.flags & 262144)) { - var initialSymbol = symbol; - var meaningToLook = meaning; - while (symbol) { - var accessibleSymbolChain = getAccessibleSymbolChain(symbol, enclosingDeclaration, meaningToLook, false); - if (accessibleSymbolChain) { - var hasAccessibleDeclarations = hasVisibleDeclarations(accessibleSymbolChain[0]); - if (!hasAccessibleDeclarations) { - return { - accessibility: 1, - errorSymbolName: symbolToString(initialSymbol, enclosingDeclaration, meaning), - errorModuleName: symbol !== initialSymbol ? symbolToString(symbol, enclosingDeclaration, 1536) : undefined - }; - } - return hasAccessibleDeclarations; - } - meaningToLook = getQualifiedLeftMeaning(meaning); - symbol = getParentOfSymbol(symbol); - } - var symbolExternalModule = ts.forEach(initialSymbol.declarations, getExternalModuleContainer); - if (symbolExternalModule) { - var enclosingExternalModule = getExternalModuleContainer(enclosingDeclaration); - if (symbolExternalModule !== enclosingExternalModule) { - return { - accessibility: 2, - errorSymbolName: symbolToString(initialSymbol, enclosingDeclaration, meaning), - errorModuleName: symbolToString(symbolExternalModule) - }; - } - } - return { - accessibility: 1, - errorSymbolName: symbolToString(initialSymbol, enclosingDeclaration, meaning) - }; - } - return { accessibility: 0 }; - function getExternalModuleContainer(declaration) { - for (; declaration; declaration = declaration.parent) { - if (hasExternalModuleSymbol(declaration)) { - return getSymbolOfNode(declaration); - } - } - } - } - function hasExternalModuleSymbol(declaration) { - return (declaration.kind === 218 && declaration.name.kind === 9) || - (declaration.kind === 248 && ts.isExternalModule(declaration)); - } - function hasVisibleDeclarations(symbol) { - var aliasesToMakeVisible; - if (ts.forEach(symbol.declarations, function (declaration) { return !getIsDeclarationVisible(declaration); })) { - return undefined; - } - return { accessibility: 0, aliasesToMakeVisible: aliasesToMakeVisible }; - function getIsDeclarationVisible(declaration) { - if (!isDeclarationVisible(declaration)) { - var anyImportSyntax = getAnyImportSyntax(declaration); - if (anyImportSyntax && - !(anyImportSyntax.flags & 1) && - isDeclarationVisible(anyImportSyntax.parent)) { - getNodeLinks(declaration).isVisible = true; - if (aliasesToMakeVisible) { - if (!ts.contains(aliasesToMakeVisible, anyImportSyntax)) { - aliasesToMakeVisible.push(anyImportSyntax); - } - } - else { - aliasesToMakeVisible = [anyImportSyntax]; - } - return true; - } - return false; - } - return true; - } - } - function isEntityNameVisible(entityName, enclosingDeclaration) { - var meaning; - if (entityName.parent.kind === 154) { - meaning = 107455 | 1048576; - } - else if (entityName.kind === 135 || entityName.kind === 166 || - entityName.parent.kind === 221) { - meaning = 1536; - } - else { - meaning = 793056; - } - var firstIdentifier = getFirstIdentifier(entityName); - var symbol = resolveName(enclosingDeclaration, firstIdentifier.text, meaning, undefined, undefined); - return (symbol && hasVisibleDeclarations(symbol)) || { - accessibility: 1, - errorSymbolName: ts.getTextOfNode(firstIdentifier), - errorNode: firstIdentifier - }; - } - function writeKeyword(writer, kind) { - writer.writeKeyword(ts.tokenToString(kind)); - } - function writePunctuation(writer, kind) { - writer.writePunctuation(ts.tokenToString(kind)); - } - function writeSpace(writer) { - writer.writeSpace(" "); - } - function symbolToString(symbol, enclosingDeclaration, meaning) { - var writer = ts.getSingleLineStringWriter(); - getSymbolDisplayBuilder().buildSymbolDisplay(symbol, writer, enclosingDeclaration, meaning); - var result = writer.string(); - ts.releaseStringWriter(writer); - return result; - } - function signatureToString(signature, enclosingDeclaration, flags) { - var writer = ts.getSingleLineStringWriter(); - getSymbolDisplayBuilder().buildSignatureDisplay(signature, writer, enclosingDeclaration, flags); - var result = writer.string(); - ts.releaseStringWriter(writer); - return result; - } - function typeToString(type, enclosingDeclaration, flags) { - var writer = ts.getSingleLineStringWriter(); - getSymbolDisplayBuilder().buildTypeDisplay(type, writer, enclosingDeclaration, flags); - var result = writer.string(); - ts.releaseStringWriter(writer); - var maxLength = compilerOptions.noErrorTruncation || flags & 4 ? undefined : 100; - if (maxLength && result.length >= maxLength) { - result = result.substr(0, maxLength - "...".length) + "..."; - } - return result; - } - function getTypeAliasForTypeLiteral(type) { - if (type.symbol && type.symbol.flags & 2048) { - var node = type.symbol.declarations[0].parent; - while (node.kind === 160) { - node = node.parent; - } - if (node.kind === 216) { - return getSymbolOfNode(node); - } - } - return undefined; - } - function getSymbolDisplayBuilder() { - function getNameOfSymbol(symbol) { - if (symbol.declarations && symbol.declarations.length) { - var declaration = symbol.declarations[0]; - if (declaration.name) { - return ts.declarationNameToString(declaration.name); - } - switch (declaration.kind) { - case 186: - return "(Anonymous class)"; - case 173: - case 174: - return "(Anonymous function)"; - } - } - return symbol.name; - } - function appendSymbolNameOnly(symbol, writer) { - writer.writeSymbol(getNameOfSymbol(symbol), symbol); - } - function buildSymbolDisplay(symbol, writer, enclosingDeclaration, meaning, flags, typeFlags) { - var parentSymbol; - function appendParentTypeArgumentsAndSymbolName(symbol) { - if (parentSymbol) { - if (flags & 1) { - if (symbol.flags & 16777216) { - buildDisplayForTypeArgumentsAndDelimiters(getTypeParametersOfClassOrInterface(parentSymbol), symbol.mapper, writer, enclosingDeclaration); - } - else { - buildTypeParameterDisplayFromSymbol(parentSymbol, writer, enclosingDeclaration); - } - } - writePunctuation(writer, 21); - } - parentSymbol = symbol; - appendSymbolNameOnly(symbol, writer); - } - writer.trackSymbol(symbol, enclosingDeclaration, meaning); - function walkSymbol(symbol, meaning) { - if (symbol) { - var accessibleSymbolChain = getAccessibleSymbolChain(symbol, enclosingDeclaration, meaning, !!(flags & 2)); - if (!accessibleSymbolChain || - needsQualification(accessibleSymbolChain[0], enclosingDeclaration, accessibleSymbolChain.length === 1 ? meaning : getQualifiedLeftMeaning(meaning))) { - walkSymbol(getParentOfSymbol(accessibleSymbolChain ? accessibleSymbolChain[0] : symbol), getQualifiedLeftMeaning(meaning)); - } - if (accessibleSymbolChain) { - for (var _i = 0; _i < accessibleSymbolChain.length; _i++) { - var accessibleSymbol = accessibleSymbolChain[_i]; - appendParentTypeArgumentsAndSymbolName(accessibleSymbol); - } - } - else { - if (!parentSymbol && ts.forEach(symbol.declarations, hasExternalModuleSymbol)) { - return; - } - if (symbol.flags & 2048 || symbol.flags & 4096) { - return; - } - appendParentTypeArgumentsAndSymbolName(symbol); - } - } - } - var isTypeParameter = symbol.flags & 262144; - var typeFormatFlag = 128 & typeFlags; - if (!isTypeParameter && (enclosingDeclaration || typeFormatFlag)) { - walkSymbol(symbol, meaning); - return; - } - return appendParentTypeArgumentsAndSymbolName(symbol); - } - function buildTypeDisplay(type, writer, enclosingDeclaration, globalFlags, symbolStack) { - var globalFlagsToPass = globalFlags & 16; - var inObjectTypeLiteral = false; - return writeType(type, globalFlags); - function writeType(type, flags) { - if (type.flags & 16777343) { - writer.writeKeyword(!(globalFlags & 16) && isTypeAny(type) - ? "any" - : type.intrinsicName); - } - else if (type.flags & 33554432) { - if (inObjectTypeLiteral) { - writer.reportInaccessibleThisError(); - } - writer.writeKeyword("this"); - } - else if (type.flags & 4096) { - writeTypeReference(type, flags); - } - else if (type.flags & (1024 | 2048 | 128 | 512)) { - buildSymbolDisplay(type.symbol, writer, enclosingDeclaration, 793056, 0, flags); - } - else if (type.flags & 8192) { - writeTupleType(type); - } - else if (type.flags & 49152) { - writeUnionOrIntersectionType(type, flags); - } - else if (type.flags & 65536) { - writeAnonymousType(type, flags); - } - else if (type.flags & 256) { - writer.writeStringLiteral(type.text); - } - else { - writePunctuation(writer, 15); - writeSpace(writer); - writePunctuation(writer, 22); - writeSpace(writer); - writePunctuation(writer, 16); - } - } - function writeTypeList(types, delimiter) { - for (var i = 0; i < types.length; i++) { - if (i > 0) { - if (delimiter !== 24) { - writeSpace(writer); - } - writePunctuation(writer, delimiter); - writeSpace(writer); - } - writeType(types[i], delimiter === 24 ? 0 : 64); - } - } - function writeSymbolTypeReference(symbol, typeArguments, pos, end, flags) { - if (symbol.flags & 32 || !isReservedMemberName(symbol.name)) { - buildSymbolDisplay(symbol, writer, enclosingDeclaration, 793056, 0, flags); - } - if (pos < end) { - writePunctuation(writer, 25); - writeType(typeArguments[pos++], 0); - while (pos < end) { - writePunctuation(writer, 24); - writeSpace(writer); - writeType(typeArguments[pos++], 0); - } - writePunctuation(writer, 27); - } - } - 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); - } - else { - var outerTypeParameters = type.target.outerTypeParameters; - var i = 0; - if (outerTypeParameters) { - var length_1 = outerTypeParameters.length; - while (i < length_1) { - var start = i; - var parent_3 = getParentSymbolOfTypeParameter(outerTypeParameters[i]); - do { - i++; - } while (i < length_1 && getParentSymbolOfTypeParameter(outerTypeParameters[i]) === parent_3); - if (!ts.rangeEquals(outerTypeParameters, typeArguments, start, i)) { - writeSymbolTypeReference(parent_3, typeArguments, start, i, flags); - writePunctuation(writer, 21); - } - } - } - var typeParameterCount = (type.target.typeParameters || emptyArray).length; - writeSymbolTypeReference(type.symbol, typeArguments, i, typeParameterCount, flags); - } - } - function writeTupleType(type) { - writePunctuation(writer, 19); - writeTypeList(type.elementTypes, 24); - writePunctuation(writer, 20); - } - function writeUnionOrIntersectionType(type, flags) { - if (flags & 64) { - writePunctuation(writer, 17); - } - writeTypeList(type.types, type.flags & 16384 ? 47 : 46); - if (flags & 64) { - writePunctuation(writer, 18); - } - } - function writeAnonymousType(type, flags) { - var symbol = type.symbol; - if (symbol) { - if (symbol.flags & (32 | 384 | 512)) { - writeTypeofSymbol(type, flags); - } - else if (shouldWriteTypeOfFunctionSymbol()) { - writeTypeofSymbol(type, flags); - } - else if (ts.contains(symbolStack, symbol)) { - var typeAlias = getTypeAliasForTypeLiteral(type); - if (typeAlias) { - buildSymbolDisplay(typeAlias, writer, enclosingDeclaration, 793056, 0, flags); - } - else { - writeKeyword(writer, 117); - } - } - else { - if (!symbolStack) { - symbolStack = []; - } - symbolStack.push(symbol); - writeLiteralType(type, flags); - symbolStack.pop(); - } - } - else { - writeLiteralType(type, flags); - } - function shouldWriteTypeOfFunctionSymbol() { - var isStaticMethodSymbol = !!(symbol.flags & 8192 && - ts.forEach(symbol.declarations, function (declaration) { return declaration.flags & 128; })); - var isNonLocalFunctionSymbol = !!(symbol.flags & 16) && - (symbol.parent || - ts.forEach(symbol.declarations, function (declaration) { - return declaration.parent.kind === 248 || declaration.parent.kind === 219; - })); - if (isStaticMethodSymbol || isNonLocalFunctionSymbol) { - return !!(flags & 2) || - (ts.contains(symbolStack, symbol)); - } - } - } - function writeTypeofSymbol(type, typeFormatFlags) { - writeKeyword(writer, 101); - writeSpace(writer); - buildSymbolDisplay(type.symbol, writer, enclosingDeclaration, 107455, 0, typeFormatFlags); - } - function getIndexerParameterName(type, indexKind, fallbackName) { - var declaration = getIndexDeclarationOfSymbol(type.symbol, indexKind); - if (!declaration) { - return fallbackName; - } - ts.Debug.assert(declaration.parameters.length !== 0); - return ts.declarationNameToString(declaration.parameters[0].name); - } - function writeLiteralType(type, flags) { - var resolved = resolveStructuredTypeMembers(type); - if (!resolved.properties.length && !resolved.stringIndexType && !resolved.numberIndexType) { - if (!resolved.callSignatures.length && !resolved.constructSignatures.length) { - writePunctuation(writer, 15); - writePunctuation(writer, 16); - return; - } - if (resolved.callSignatures.length === 1 && !resolved.constructSignatures.length) { - if (flags & 64) { - writePunctuation(writer, 17); - } - buildSignatureDisplay(resolved.callSignatures[0], writer, enclosingDeclaration, globalFlagsToPass | 8, symbolStack); - if (flags & 64) { - writePunctuation(writer, 18); - } - return; - } - if (resolved.constructSignatures.length === 1 && !resolved.callSignatures.length) { - if (flags & 64) { - writePunctuation(writer, 17); - } - writeKeyword(writer, 92); - writeSpace(writer); - buildSignatureDisplay(resolved.constructSignatures[0], writer, enclosingDeclaration, globalFlagsToPass | 8, symbolStack); - if (flags & 64) { - writePunctuation(writer, 18); - } - return; - } - } - var saveInObjectTypeLiteral = inObjectTypeLiteral; - inObjectTypeLiteral = true; - writePunctuation(writer, 15); - writer.writeLine(); - writer.increaseIndent(); - for (var _i = 0, _a = resolved.callSignatures; _i < _a.length; _i++) { - var signature = _a[_i]; - buildSignatureDisplay(signature, writer, enclosingDeclaration, globalFlagsToPass, symbolStack); - writePunctuation(writer, 23); - writer.writeLine(); - } - for (var _b = 0, _c = resolved.constructSignatures; _b < _c.length; _b++) { - var signature = _c[_b]; - writeKeyword(writer, 92); - writeSpace(writer); - buildSignatureDisplay(signature, writer, enclosingDeclaration, globalFlagsToPass, symbolStack); - writePunctuation(writer, 23); - writer.writeLine(); - } - if (resolved.stringIndexType) { - writePunctuation(writer, 19); - writer.writeParameter(getIndexerParameterName(resolved, 0, "x")); - writePunctuation(writer, 54); - writeSpace(writer); - writeKeyword(writer, 130); - writePunctuation(writer, 20); - writePunctuation(writer, 54); - writeSpace(writer); - writeType(resolved.stringIndexType, 0); - writePunctuation(writer, 23); - writer.writeLine(); - } - if (resolved.numberIndexType) { - writePunctuation(writer, 19); - writer.writeParameter(getIndexerParameterName(resolved, 1, "x")); - writePunctuation(writer, 54); - writeSpace(writer); - writeKeyword(writer, 128); - writePunctuation(writer, 20); - writePunctuation(writer, 54); - writeSpace(writer); - writeType(resolved.numberIndexType, 0); - writePunctuation(writer, 23); - writer.writeLine(); - } - for (var _d = 0, _e = resolved.properties; _d < _e.length; _d++) { - var p = _e[_d]; - var t = getTypeOfSymbol(p); - if (p.flags & (16 | 8192) && !getPropertiesOfObjectType(t).length) { - var signatures = getSignaturesOfType(t, 0); - for (var _f = 0; _f < signatures.length; _f++) { - var signature = signatures[_f]; - buildSymbolDisplay(p, writer); - if (p.flags & 536870912) { - writePunctuation(writer, 53); - } - buildSignatureDisplay(signature, writer, enclosingDeclaration, globalFlagsToPass, symbolStack); - writePunctuation(writer, 23); - writer.writeLine(); - } - } - else { - buildSymbolDisplay(p, writer); - if (p.flags & 536870912) { - writePunctuation(writer, 53); - } - writePunctuation(writer, 54); - writeSpace(writer); - writeType(t, 0); - writePunctuation(writer, 23); - writer.writeLine(); - } - } - writer.decreaseIndent(); - writePunctuation(writer, 16); - inObjectTypeLiteral = saveInObjectTypeLiteral; - } - } - function buildTypeParameterDisplayFromSymbol(symbol, writer, enclosingDeclaraiton, flags) { - var targetSymbol = getTargetSymbol(symbol); - if (targetSymbol.flags & 32 || targetSymbol.flags & 64 || targetSymbol.flags & 524288) { - buildDisplayForTypeParametersAndDelimiters(getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol), writer, enclosingDeclaraiton, flags); - } - } - function buildTypeParameterDisplay(tp, writer, enclosingDeclaration, flags, symbolStack) { - appendSymbolNameOnly(tp.symbol, writer); - var constraint = getConstraintOfTypeParameter(tp); - if (constraint) { - writeSpace(writer); - writeKeyword(writer, 83); - writeSpace(writer); - buildTypeDisplay(constraint, writer, enclosingDeclaration, flags, symbolStack); - } - } - function buildParameterDisplay(p, writer, enclosingDeclaration, flags, symbolStack) { - var parameterNode = p.valueDeclaration; - if (ts.isRestParameter(parameterNode)) { - writePunctuation(writer, 22); - } - appendSymbolNameOnly(p, writer); - if (isOptionalParameter(parameterNode)) { - writePunctuation(writer, 53); - } - writePunctuation(writer, 54); - writeSpace(writer); - buildTypeDisplay(getTypeOfSymbol(p), writer, enclosingDeclaration, flags, symbolStack); - } - function buildDisplayForTypeParametersAndDelimiters(typeParameters, writer, enclosingDeclaration, flags, symbolStack) { - if (typeParameters && typeParameters.length) { - writePunctuation(writer, 25); - for (var i = 0; i < typeParameters.length; i++) { - if (i > 0) { - writePunctuation(writer, 24); - writeSpace(writer); - } - buildTypeParameterDisplay(typeParameters[i], writer, enclosingDeclaration, flags, symbolStack); - } - writePunctuation(writer, 27); - } - } - function buildDisplayForTypeArgumentsAndDelimiters(typeParameters, mapper, writer, enclosingDeclaration, flags, symbolStack) { - if (typeParameters && typeParameters.length) { - writePunctuation(writer, 25); - for (var i = 0; i < typeParameters.length; i++) { - if (i > 0) { - writePunctuation(writer, 24); - writeSpace(writer); - } - buildTypeDisplay(mapper(typeParameters[i]), writer, enclosingDeclaration, 0); - } - writePunctuation(writer, 27); - } - } - function buildDisplayForParametersAndDelimiters(parameters, writer, enclosingDeclaration, flags, symbolStack) { - writePunctuation(writer, 17); - for (var i = 0; i < parameters.length; i++) { - if (i > 0) { - writePunctuation(writer, 24); - writeSpace(writer); - } - buildParameterDisplay(parameters[i], writer, enclosingDeclaration, flags, symbolStack); - } - writePunctuation(writer, 18); - } - function buildReturnTypeDisplay(signature, writer, enclosingDeclaration, flags, symbolStack) { - if (flags & 8) { - writeSpace(writer); - writePunctuation(writer, 34); - } - else { - writePunctuation(writer, 54); - } - writeSpace(writer); - var returnType; - if (signature.typePredicate) { - writer.writeParameter(signature.typePredicate.parameterName); - writeSpace(writer); - writeKeyword(writer, 124); - writeSpace(writer); - returnType = signature.typePredicate.type; - } - else { - returnType = getReturnTypeOfSignature(signature); - } - buildTypeDisplay(returnType, writer, enclosingDeclaration, flags, symbolStack); - } - function buildSignatureDisplay(signature, writer, enclosingDeclaration, flags, symbolStack) { - if (signature.target && (flags & 32)) { - buildDisplayForTypeArgumentsAndDelimiters(signature.target.typeParameters, signature.mapper, writer, enclosingDeclaration); - } - else { - buildDisplayForTypeParametersAndDelimiters(signature.typeParameters, writer, enclosingDeclaration, flags, symbolStack); - } - buildDisplayForParametersAndDelimiters(signature.parameters, writer, enclosingDeclaration, flags, symbolStack); - buildReturnTypeDisplay(signature, writer, enclosingDeclaration, flags, symbolStack); - } - return _displayBuilder || (_displayBuilder = { - buildSymbolDisplay: buildSymbolDisplay, - buildTypeDisplay: buildTypeDisplay, - buildTypeParameterDisplay: buildTypeParameterDisplay, - buildParameterDisplay: buildParameterDisplay, - buildDisplayForParametersAndDelimiters: buildDisplayForParametersAndDelimiters, - buildDisplayForTypeParametersAndDelimiters: buildDisplayForTypeParametersAndDelimiters, - buildTypeParameterDisplayFromSymbol: buildTypeParameterDisplayFromSymbol, - buildSignatureDisplay: buildSignatureDisplay, - buildReturnTypeDisplay: buildReturnTypeDisplay - }); - } - function isDeclarationVisible(node) { - function getContainingExternalModule(node) { - for (; node; node = node.parent) { - if (node.kind === 218) { - if (node.name.kind === 9) { - return node; - } - } - else if (node.kind === 248) { - return ts.isExternalModule(node) ? node : undefined; - } - } - ts.Debug.fail("getContainingModule cant reach here"); - } - function isUsedInExportAssignment(node) { - var externalModule = getContainingExternalModule(node); - var exportAssignmentSymbol; - var resolvedExportSymbol; - if (externalModule) { - var externalModuleSymbol = getSymbolOfNode(externalModule); - exportAssignmentSymbol = getExportAssignmentSymbol(externalModuleSymbol); - var symbolOfNode = getSymbolOfNode(node); - if (isSymbolUsedInExportAssignment(symbolOfNode)) { - return true; - } - if (symbolOfNode.flags & 8388608) { - return isSymbolUsedInExportAssignment(resolveAlias(symbolOfNode)); - } - } - function isSymbolUsedInExportAssignment(symbol) { - if (exportAssignmentSymbol === symbol) { - return true; - } - if (exportAssignmentSymbol && !!(exportAssignmentSymbol.flags & 8388608)) { - resolvedExportSymbol = resolvedExportSymbol || resolveAlias(exportAssignmentSymbol); - if (resolvedExportSymbol === symbol) { - return true; - } - return ts.forEach(resolvedExportSymbol.declarations, function (current) { - while (current) { - if (current === node) { - return true; - } - current = current.parent; - } - }); - } - } - } - function determineIfDeclarationIsVisible() { - switch (node.kind) { - case 163: - return isDeclarationVisible(node.parent.parent); - case 211: - if (ts.isBindingPattern(node.name) && - !node.name.elements.length) { - return false; - } - case 218: - case 214: - case 215: - case 216: - case 213: - case 217: - case 221: - var parent_4 = getDeclarationContainer(node); - if (!(ts.getCombinedNodeFlags(node) & 1) && - !(node.kind !== 221 && parent_4.kind !== 248 && ts.isInAmbientContext(parent_4))) { - return isGlobalSourceFile(parent_4); - } - return isDeclarationVisible(parent_4); - case 141: - case 140: - case 145: - case 146: - case 143: - case 142: - if (node.flags & (32 | 64)) { - return false; - } - case 144: - case 148: - case 147: - case 149: - case 138: - case 219: - case 152: - case 153: - case 155: - case 151: - case 156: - case 157: - case 158: - case 159: - case 160: - return isDeclarationVisible(node.parent); - case 223: - case 224: - case 226: - return false; - case 137: - case 248: - return true; - case 227: - return false; - default: - ts.Debug.fail("isDeclarationVisible unknown: SyntaxKind: " + node.kind); - } - } - if (node) { - var links = getNodeLinks(node); - if (links.isVisible === undefined) { - links.isVisible = !!determineIfDeclarationIsVisible(); - } - return links.isVisible; - } - } - function collectLinkedAliases(node) { - var exportSymbol; - if (node.parent && node.parent.kind === 227) { - exportSymbol = resolveName(node.parent, node.text, 107455 | 793056 | 1536 | 8388608, ts.Diagnostics.Cannot_find_name_0, node); - } - else if (node.parent.kind === 230) { - var exportSpecifier = node.parent; - exportSymbol = exportSpecifier.parent.parent.moduleSpecifier ? - getExternalModuleMember(exportSpecifier.parent.parent, exportSpecifier) : - resolveEntityName(exportSpecifier.propertyName || exportSpecifier.name, 107455 | 793056 | 1536 | 8388608); - } - var result = []; - if (exportSymbol) { - buildVisibleNodeList(exportSymbol.declarations); - } - return result; - function buildVisibleNodeList(declarations) { - ts.forEach(declarations, function (declaration) { - getNodeLinks(declaration).isVisible = true; - var resultNode = getAnyImportSyntax(declaration) || declaration; - if (!ts.contains(result, resultNode)) { - result.push(resultNode); - } - if (ts.isInternalModuleImportEqualsDeclaration(declaration)) { - var internalModuleReference = declaration.moduleReference; - var firstIdentifier = getFirstIdentifier(internalModuleReference); - var importSymbol = resolveName(declaration, firstIdentifier.text, 107455 | 793056 | 1536, ts.Diagnostics.Cannot_find_name_0, firstIdentifier); - buildVisibleNodeList(importSymbol.declarations); - } - }); - } - } - function pushTypeResolution(target, propertyName) { - var resolutionCycleStartIndex = findResolutionCycleStartIndex(target, propertyName); - if (resolutionCycleStartIndex >= 0) { - var length_2 = resolutionTargets.length; - for (var i = resolutionCycleStartIndex; i < length_2; i++) { - resolutionResults[i] = false; - } - return false; - } - resolutionTargets.push(target); - resolutionResults.push(true); - resolutionPropertyNames.push(propertyName); - return true; - } - function findResolutionCycleStartIndex(target, propertyName) { - for (var i = resolutionTargets.length - 1; i >= 0; i--) { - if (hasType(resolutionTargets[i], resolutionPropertyNames[i])) { - return -1; - } - if (resolutionTargets[i] === target && resolutionPropertyNames[i] === propertyName) { - return i; - } - } - return -1; - } - function hasType(target, propertyName) { - if (propertyName === 0) { - return getSymbolLinks(target).type; - } - if (propertyName === 2) { - return getSymbolLinks(target).declaredType; - } - if (propertyName === 1) { - ts.Debug.assert(!!(target.flags & 1024)); - return target.resolvedBaseConstructorType; - } - if (propertyName === 3) { - return target.resolvedReturnType; - } - ts.Debug.fail("Unhandled TypeSystemPropertyName " + propertyName); - } - function popTypeResolution() { - resolutionTargets.pop(); - resolutionPropertyNames.pop(); - return resolutionResults.pop(); - } - function getDeclarationContainer(node) { - node = ts.getRootDeclaration(node); - return node.kind === 211 ? node.parent.parent.parent : node.parent; - } - function getTypeOfPrototypeProperty(prototype) { - var classType = getDeclaredTypeOfSymbol(prototype.parent); - return classType.typeParameters ? createTypeReference(classType, ts.map(classType.typeParameters, function (_) { return anyType; })) : classType; - } - function getTypeOfPropertyOfType(type, name) { - var prop = getPropertyOfType(type, name); - return prop ? getTypeOfSymbol(prop) : undefined; - } - function isTypeAny(type) { - return type && (type.flags & 1) !== 0; - } - function getTypeForBindingElementParent(node) { - var symbol = getSymbolOfNode(node); - return symbol && getSymbolLinks(symbol).type || getTypeForVariableLikeDeclaration(node); - } - function getTypeForBindingElement(declaration) { - var pattern = declaration.parent; - var parentType = getTypeForBindingElementParent(pattern.parent); - if (parentType === unknownType) { - return unknownType; - } - if (!parentType || isTypeAny(parentType)) { - if (declaration.initializer) { - return checkExpressionCached(declaration.initializer); - } - return parentType; - } - var type; - if (pattern.kind === 161) { - var name_10 = declaration.propertyName || declaration.name; - type = getTypeOfPropertyOfType(parentType, name_10.text) || - isNumericLiteralName(name_10.text) && getIndexTypeOfType(parentType, 1) || - getIndexTypeOfType(parentType, 0); - if (!type) { - error(name_10, ts.Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(parentType), ts.declarationNameToString(name_10)); - return unknownType; - } - } - else { - var elementType = checkIteratedTypeOrElementType(parentType, pattern, false); - if (!declaration.dotDotDotToken) { - var propName = "" + ts.indexOf(pattern.elements, declaration); - type = isTupleLikeType(parentType) - ? getTypeOfPropertyOfType(parentType, propName) - : elementType; - if (!type) { - if (isTupleType(parentType)) { - error(declaration, ts.Diagnostics.Tuple_type_0_with_length_1_cannot_be_assigned_to_tuple_with_length_2, typeToString(parentType), parentType.elementTypes.length, pattern.elements.length); - } - else { - error(declaration, ts.Diagnostics.Type_0_has_no_property_1, typeToString(parentType), propName); - } - return unknownType; - } - } - else { - type = createArrayType(elementType); - } - } - return type; - } - function getTypeForVariableLikeDeclaration(declaration) { - if (declaration.parent.parent.kind === 200) { - return anyType; - } - if (declaration.parent.parent.kind === 201) { - return checkRightHandSideOfForOf(declaration.parent.parent.expression) || anyType; - } - if (ts.isBindingPattern(declaration.parent)) { - return getTypeForBindingElement(declaration); - } - if (declaration.type) { - return getTypeFromTypeNode(declaration.type); - } - if (declaration.kind === 138) { - var func = declaration.parent; - if (func.kind === 146 && !ts.hasDynamicName(func)) { - var getter = ts.getDeclarationOfKind(declaration.parent.symbol, 145); - if (getter) { - return getReturnTypeOfSignature(getSignatureFromDeclaration(getter)); - } - } - var type = getContextuallyTypedParameterType(declaration); - if (type) { - return type; - } - } - if (declaration.initializer) { - return checkExpressionCached(declaration.initializer); - } - if (declaration.kind === 246) { - return checkIdentifier(declaration.name); - } - if (ts.isBindingPattern(declaration.name)) { - return getTypeFromBindingPattern(declaration.name, false); - } - return undefined; - } - function getTypeFromBindingElement(element, includePatternInType) { - if (element.initializer) { - return getWidenedType(checkExpressionCached(element.initializer)); - } - if (ts.isBindingPattern(element.name)) { - return getTypeFromBindingPattern(element.name, includePatternInType); - } - return anyType; - } - function getTypeFromObjectBindingPattern(pattern, includePatternInType) { - var members = {}; - ts.forEach(pattern.elements, function (e) { - var flags = 4 | 67108864 | (e.initializer ? 536870912 : 0); - var name = e.propertyName || e.name; - var symbol = createSymbol(flags, name.text); - symbol.type = getTypeFromBindingElement(e, includePatternInType); - symbol.bindingElement = e; - members[symbol.name] = symbol; - }); - var result = createAnonymousType(undefined, members, emptyArray, emptyArray, undefined, undefined); - if (includePatternInType) { - result.pattern = pattern; - } - return result; - } - function getTypeFromArrayBindingPattern(pattern, includePatternInType) { - var elements = pattern.elements; - if (elements.length === 0 || elements[elements.length - 1].dotDotDotToken) { - return languageVersion >= 2 ? createIterableType(anyType) : anyArrayType; - } - var elementTypes = ts.map(elements, function (e) { return e.kind === 187 ? anyType : getTypeFromBindingElement(e, includePatternInType); }); - if (includePatternInType) { - var result = createNewTupleType(elementTypes); - result.pattern = pattern; - return result; - } - return createTupleType(elementTypes); - } - function getTypeFromBindingPattern(pattern, includePatternInType) { - return pattern.kind === 161 - ? getTypeFromObjectBindingPattern(pattern, includePatternInType) - : getTypeFromArrayBindingPattern(pattern, includePatternInType); - } - function getWidenedTypeForVariableLikeDeclaration(declaration, reportErrors) { - var type = getTypeForVariableLikeDeclaration(declaration); - if (type) { - if (reportErrors) { - reportErrorsFromWidening(declaration, type); - } - return declaration.kind !== 245 ? getWidenedType(type) : type; - } - type = declaration.dotDotDotToken ? anyArrayType : anyType; - if (reportErrors && compilerOptions.noImplicitAny) { - var root = ts.getRootDeclaration(declaration); - if (!isPrivateWithinAmbient(root) && !(root.kind === 138 && isPrivateWithinAmbient(root.parent))) { - reportImplicitAnyError(declaration, type); - } - } - return type; - } - function getTypeOfVariableOrParameterOrProperty(symbol) { - var links = getSymbolLinks(symbol); - if (!links.type) { - if (symbol.flags & 134217728) { - return links.type = getTypeOfPrototypeProperty(symbol); - } - var declaration = symbol.valueDeclaration; - if (declaration.parent.kind === 244) { - return links.type = anyType; - } - if (declaration.kind === 227) { - return links.type = checkExpression(declaration.expression); - } - if (!pushTypeResolution(symbol, 0)) { - return unknownType; - } - var type = getWidenedTypeForVariableLikeDeclaration(declaration, true); - if (!popTypeResolution()) { - if (symbol.valueDeclaration.type) { - type = unknownType; - error(symbol.valueDeclaration, ts.Diagnostics._0_is_referenced_directly_or_indirectly_in_its_own_type_annotation, symbolToString(symbol)); - } - else { - type = anyType; - if (compilerOptions.noImplicitAny) { - error(symbol.valueDeclaration, ts.Diagnostics._0_implicitly_has_type_any_because_it_does_not_have_a_type_annotation_and_is_referenced_directly_or_indirectly_in_its_own_initializer, symbolToString(symbol)); - } - } - } - links.type = type; - } - return links.type; - } - function getAnnotatedAccessorType(accessor) { - if (accessor) { - if (accessor.kind === 145) { - return accessor.type && getTypeFromTypeNode(accessor.type); - } - else { - var setterTypeAnnotation = ts.getSetAccessorTypeAnnotationNode(accessor); - return setterTypeAnnotation && getTypeFromTypeNode(setterTypeAnnotation); - } - } - return undefined; - } - function getTypeOfAccessors(symbol) { - var links = getSymbolLinks(symbol); - if (!links.type) { - if (!pushTypeResolution(symbol, 0)) { - return unknownType; - } - var getter = ts.getDeclarationOfKind(symbol, 145); - var setter = ts.getDeclarationOfKind(symbol, 146); - var type; - var getterReturnType = getAnnotatedAccessorType(getter); - if (getterReturnType) { - type = getterReturnType; - } - else { - var setterParameterType = getAnnotatedAccessorType(setter); - if (setterParameterType) { - type = setterParameterType; - } - else { - if (getter && getter.body) { - type = getReturnTypeFromBody(getter); - } - else { - if (compilerOptions.noImplicitAny) { - error(setter, ts.Diagnostics.Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_type_annotation, symbolToString(symbol)); - } - type = anyType; - } - } - } - if (!popTypeResolution()) { - type = anyType; - if (compilerOptions.noImplicitAny) { - var getter_1 = ts.getDeclarationOfKind(symbol, 145); - error(getter_1, ts.Diagnostics._0_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions, symbolToString(symbol)); - } - } - links.type = type; - } - return links.type; - } - function getTypeOfFuncClassEnumModule(symbol) { - var links = getSymbolLinks(symbol); - if (!links.type) { - links.type = createObjectType(65536, symbol); - } - return links.type; - } - function getTypeOfEnumMember(symbol) { - var links = getSymbolLinks(symbol); - if (!links.type) { - links.type = getDeclaredTypeOfEnum(getParentOfSymbol(symbol)); - } - return links.type; - } - function getTypeOfAlias(symbol) { - var links = getSymbolLinks(symbol); - if (!links.type) { - var targetSymbol = resolveAlias(symbol); - links.type = targetSymbol.flags & 107455 - ? getTypeOfSymbol(targetSymbol) - : unknownType; - } - return links.type; - } - function getTypeOfInstantiatedSymbol(symbol) { - var links = getSymbolLinks(symbol); - if (!links.type) { - links.type = instantiateType(getTypeOfSymbol(links.target), links.mapper); - } - return links.type; - } - function getTypeOfSymbol(symbol) { - if (symbol.flags & 16777216) { - return getTypeOfInstantiatedSymbol(symbol); - } - if (symbol.flags & (3 | 4)) { - return getTypeOfVariableOrParameterOrProperty(symbol); - } - if (symbol.flags & (16 | 8192 | 32 | 384 | 512)) { - return getTypeOfFuncClassEnumModule(symbol); - } - if (symbol.flags & 8) { - return getTypeOfEnumMember(symbol); - } - if (symbol.flags & 98304) { - return getTypeOfAccessors(symbol); - } - if (symbol.flags & 8388608) { - return getTypeOfAlias(symbol); - } - return unknownType; - } - function getTargetType(type) { - return type.flags & 4096 ? type.target : type; - } - function hasBaseType(type, checkBase) { - return check(type); - function check(type) { - var target = getTargetType(type); - return target === checkBase || ts.forEach(getBaseTypes(target), check); - } - } - function appendTypeParameters(typeParameters, declarations) { - for (var _i = 0; _i < declarations.length; _i++) { - var declaration = declarations[_i]; - var tp = getDeclaredTypeOfTypeParameter(getSymbolOfNode(declaration)); - if (!typeParameters) { - typeParameters = [tp]; - } - else if (!ts.contains(typeParameters, tp)) { - typeParameters.push(tp); - } - } - return typeParameters; - } - function appendOuterTypeParameters(typeParameters, node) { - while (true) { - node = node.parent; - if (!node) { - return typeParameters; - } - if (node.kind === 214 || node.kind === 186 || - node.kind === 213 || node.kind === 173 || - node.kind === 143 || node.kind === 174) { - var declarations = node.typeParameters; - if (declarations) { - return appendTypeParameters(appendOuterTypeParameters(typeParameters, node), declarations); - } - } - } - } - function getOuterTypeParametersOfClassOrInterface(symbol) { - var declaration = symbol.flags & 32 ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 215); - return appendOuterTypeParameters(undefined, declaration); - } - function getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol) { - var result; - for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { - var node = _a[_i]; - if (node.kind === 215 || node.kind === 214 || - node.kind === 186 || node.kind === 216) { - var declaration = node; - if (declaration.typeParameters) { - result = appendTypeParameters(result, declaration.typeParameters); - } - } - } - return result; - } - function getTypeParametersOfClassOrInterface(symbol) { - return ts.concatenate(getOuterTypeParametersOfClassOrInterface(symbol), getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol)); - } - function isConstructorType(type) { - return type.flags & 80896 && getSignaturesOfType(type, 1).length > 0; - } - function getBaseTypeNodeOfClass(type) { - return ts.getClassExtendsHeritageClauseElement(type.symbol.valueDeclaration); - } - function getConstructorsForTypeArguments(type, typeArgumentNodes) { - var typeArgCount = typeArgumentNodes ? typeArgumentNodes.length : 0; - return ts.filter(getSignaturesOfType(type, 1), function (sig) { return (sig.typeParameters ? sig.typeParameters.length : 0) === typeArgCount; }); - } - function getInstantiatedConstructorsForTypeArguments(type, typeArgumentNodes) { - var signatures = getConstructorsForTypeArguments(type, typeArgumentNodes); - if (typeArgumentNodes) { - var typeArguments = ts.map(typeArgumentNodes, getTypeFromTypeNode); - signatures = ts.map(signatures, function (sig) { return getSignatureInstantiation(sig, typeArguments); }); - } - return signatures; - } - function getBaseConstructorTypeOfClass(type) { - if (!type.resolvedBaseConstructorType) { - var baseTypeNode = getBaseTypeNodeOfClass(type); - if (!baseTypeNode) { - return type.resolvedBaseConstructorType = undefinedType; - } - if (!pushTypeResolution(type, 1)) { - return unknownType; - } - var baseConstructorType = checkExpression(baseTypeNode.expression); - if (baseConstructorType.flags & 80896) { - resolveStructuredTypeMembers(baseConstructorType); - } - if (!popTypeResolution()) { - error(type.symbol.valueDeclaration, ts.Diagnostics._0_is_referenced_directly_or_indirectly_in_its_own_base_expression, symbolToString(type.symbol)); - return type.resolvedBaseConstructorType = unknownType; - } - if (baseConstructorType !== unknownType && baseConstructorType !== nullType && !isConstructorType(baseConstructorType)) { - error(baseTypeNode.expression, ts.Diagnostics.Type_0_is_not_a_constructor_function_type, typeToString(baseConstructorType)); - return type.resolvedBaseConstructorType = unknownType; - } - type.resolvedBaseConstructorType = baseConstructorType; - } - return type.resolvedBaseConstructorType; - } - function hasClassBaseType(type) { - return !!ts.forEach(getBaseTypes(type), function (t) { return !!(t.symbol.flags & 32); }); - } - function getBaseTypes(type) { - var isClass = type.symbol.flags & 32; - var isInterface = type.symbol.flags & 64; - if (!type.resolvedBaseTypes) { - if (!isClass && !isInterface) { - ts.Debug.fail("type must be class or interface"); - } - if (isClass) { - resolveBaseTypesOfClass(type); - } - if (isInterface) { - resolveBaseTypesOfInterface(type); - } - } - return type.resolvedBaseTypes; - } - function resolveBaseTypesOfClass(type) { - type.resolvedBaseTypes = type.resolvedBaseTypes || emptyArray; - var baseContructorType = getBaseConstructorTypeOfClass(type); - if (!(baseContructorType.flags & 80896)) { - return; - } - var baseTypeNode = getBaseTypeNodeOfClass(type); - var baseType; - if (baseContructorType.symbol && baseContructorType.symbol.flags & 32) { - baseType = getTypeFromClassOrInterfaceReference(baseTypeNode, baseContructorType.symbol); - } - else { - var constructors = getInstantiatedConstructorsForTypeArguments(baseContructorType, baseTypeNode.typeArguments); - if (!constructors.length) { - error(baseTypeNode.expression, ts.Diagnostics.No_base_constructor_has_the_specified_number_of_type_arguments); - return; - } - baseType = getReturnTypeOfSignature(constructors[0]); - } - if (baseType === unknownType) { - return; - } - if (!(getTargetType(baseType).flags & (1024 | 2048))) { - error(baseTypeNode.expression, ts.Diagnostics.Base_constructor_return_type_0_is_not_a_class_or_interface_type, typeToString(baseType)); - return; - } - if (type === baseType || hasBaseType(baseType, type)) { - error(type.symbol.valueDeclaration, ts.Diagnostics.Type_0_recursively_references_itself_as_a_base_type, typeToString(type, undefined, 1)); - return; - } - if (type.resolvedBaseTypes === emptyArray) { - type.resolvedBaseTypes = [baseType]; - } - else { - type.resolvedBaseTypes.push(baseType); - } - } - function resolveBaseTypesOfInterface(type) { - type.resolvedBaseTypes = type.resolvedBaseTypes || emptyArray; - for (var _i = 0, _a = type.symbol.declarations; _i < _a.length; _i++) { - var declaration = _a[_i]; - if (declaration.kind === 215 && ts.getInterfaceBaseTypeNodes(declaration)) { - for (var _b = 0, _c = ts.getInterfaceBaseTypeNodes(declaration); _b < _c.length; _b++) { - var node = _c[_b]; - var baseType = getTypeFromTypeNode(node); - if (baseType !== unknownType) { - if (getTargetType(baseType).flags & (1024 | 2048)) { - if (type !== baseType && !hasBaseType(baseType, type)) { - if (type.resolvedBaseTypes === emptyArray) { - type.resolvedBaseTypes = [baseType]; - } - else { - type.resolvedBaseTypes.push(baseType); - } - } - else { - error(declaration, ts.Diagnostics.Type_0_recursively_references_itself_as_a_base_type, typeToString(type, undefined, 1)); - } - } - else { - error(node, ts.Diagnostics.An_interface_may_only_extend_a_class_or_another_interface); - } - } - } - } - } - } - function isIndependentInterface(symbol) { - for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { - var declaration = _a[_i]; - if (declaration.kind === 215) { - if (declaration.flags & 524288) { - return false; - } - var baseTypeNodes = ts.getInterfaceBaseTypeNodes(declaration); - if (baseTypeNodes) { - for (var _b = 0; _b < baseTypeNodes.length; _b++) { - var node = baseTypeNodes[_b]; - if (ts.isSupportedExpressionWithTypeArguments(node)) { - var baseSymbol = resolveEntityName(node.expression, 793056, true); - if (!baseSymbol || !(baseSymbol.flags & 64) || getDeclaredTypeOfClassOrInterface(baseSymbol).thisType) { - return false; - } - } - } - } - } - } - return true; - } - function getDeclaredTypeOfClassOrInterface(symbol) { - var links = getSymbolLinks(symbol); - if (!links.declaredType) { - var kind = symbol.flags & 32 ? 1024 : 2048; - var type = links.declaredType = createObjectType(kind, symbol); - var outerTypeParameters = getOuterTypeParametersOfClassOrInterface(symbol); - var localTypeParameters = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol); - if (outerTypeParameters || localTypeParameters || kind === 1024 || !isIndependentInterface(symbol)) { - type.flags |= 4096; - type.typeParameters = ts.concatenate(outerTypeParameters, localTypeParameters); - type.outerTypeParameters = outerTypeParameters; - type.localTypeParameters = localTypeParameters; - type.instantiations = {}; - type.instantiations[getTypeListId(type.typeParameters)] = type; - type.target = type; - type.typeArguments = type.typeParameters; - type.thisType = createType(512 | 33554432); - type.thisType.symbol = symbol; - type.thisType.constraint = getTypeWithThisArgument(type); - } - } - return links.declaredType; - } - function getDeclaredTypeOfTypeAlias(symbol) { - var links = getSymbolLinks(symbol); - if (!links.declaredType) { - if (!pushTypeResolution(symbol, 2)) { - return unknownType; - } - var declaration = ts.getDeclarationOfKind(symbol, 216); - var type = getTypeFromTypeNode(declaration.type); - if (popTypeResolution()) { - links.typeParameters = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol); - if (links.typeParameters) { - links.instantiations = {}; - links.instantiations[getTypeListId(links.typeParameters)] = type; - } - } - else { - type = unknownType; - error(declaration.name, ts.Diagnostics.Type_alias_0_circularly_references_itself, symbolToString(symbol)); - } - links.declaredType = type; - } - return links.declaredType; - } - function getDeclaredTypeOfEnum(symbol) { - var links = getSymbolLinks(symbol); - if (!links.declaredType) { - var type = createType(128); - type.symbol = symbol; - links.declaredType = type; - } - return links.declaredType; - } - function getDeclaredTypeOfTypeParameter(symbol) { - var links = getSymbolLinks(symbol); - if (!links.declaredType) { - var type = createType(512); - type.symbol = symbol; - if (!ts.getDeclarationOfKind(symbol, 137).constraint) { - type.constraint = noConstraintType; - } - links.declaredType = type; - } - return links.declaredType; - } - function getDeclaredTypeOfAlias(symbol) { - var links = getSymbolLinks(symbol); - if (!links.declaredType) { - links.declaredType = getDeclaredTypeOfSymbol(resolveAlias(symbol)); - } - return links.declaredType; - } - function getDeclaredTypeOfSymbol(symbol) { - ts.Debug.assert((symbol.flags & 16777216) === 0); - if (symbol.flags & (32 | 64)) { - return getDeclaredTypeOfClassOrInterface(symbol); - } - if (symbol.flags & 524288) { - return getDeclaredTypeOfTypeAlias(symbol); - } - if (symbol.flags & 384) { - return getDeclaredTypeOfEnum(symbol); - } - if (symbol.flags & 262144) { - return getDeclaredTypeOfTypeParameter(symbol); - } - if (symbol.flags & 8388608) { - return getDeclaredTypeOfAlias(symbol); - } - return unknownType; - } - function isIndependentTypeReference(node) { - if (node.typeArguments) { - for (var _i = 0, _a = node.typeArguments; _i < _a.length; _i++) { - var typeNode = _a[_i]; - if (!isIndependentType(typeNode)) { - return false; - } - } - } - return true; - } - function isIndependentType(node) { - switch (node.kind) { - case 117: - case 130: - case 128: - case 120: - case 131: - case 103: - case 9: - return true; - case 156: - return isIndependentType(node.elementType); - case 151: - return isIndependentTypeReference(node); - } - return false; - } - function isIndependentVariableLikeDeclaration(node) { - return node.type && isIndependentType(node.type) || !node.type && !node.initializer; - } - function isIndependentFunctionLikeDeclaration(node) { - if (node.kind !== 144 && (!node.type || !isIndependentType(node.type))) { - return false; - } - for (var _i = 0, _a = node.parameters; _i < _a.length; _i++) { - var parameter = _a[_i]; - if (!isIndependentVariableLikeDeclaration(parameter)) { - return false; - } - } - return true; - } - function isIndependentMember(symbol) { - if (symbol.declarations && symbol.declarations.length === 1) { - var declaration = symbol.declarations[0]; - if (declaration) { - switch (declaration.kind) { - case 141: - case 140: - return isIndependentVariableLikeDeclaration(declaration); - case 143: - case 142: - case 144: - return isIndependentFunctionLikeDeclaration(declaration); - } - } - } - return false; - } - function createSymbolTable(symbols) { - var result = {}; - for (var _i = 0; _i < symbols.length; _i++) { - var symbol = symbols[_i]; - result[symbol.name] = symbol; - } - return result; - } - function createInstantiatedSymbolTable(symbols, mapper, mappingThisOnly) { - var result = {}; - for (var _i = 0; _i < symbols.length; _i++) { - var symbol = symbols[_i]; - result[symbol.name] = mappingThisOnly && isIndependentMember(symbol) ? symbol : instantiateSymbol(symbol, mapper); - } - return result; - } - function addInheritedMembers(symbols, baseSymbols) { - for (var _i = 0; _i < baseSymbols.length; _i++) { - var s = baseSymbols[_i]; - if (!ts.hasProperty(symbols, s.name)) { - symbols[s.name] = s; - } - } - } - function addInheritedSignatures(signatures, baseSignatures) { - if (baseSignatures) { - for (var _i = 0; _i < baseSignatures.length; _i++) { - var signature = baseSignatures[_i]; - signatures.push(signature); - } - } - } - function resolveDeclaredMembers(type) { - if (!type.declaredProperties) { - var symbol = type.symbol; - type.declaredProperties = getNamedMembers(symbol.members); - type.declaredCallSignatures = getSignaturesOfSymbol(symbol.members["__call"]); - type.declaredConstructSignatures = getSignaturesOfSymbol(symbol.members["__new"]); - type.declaredStringIndexType = getIndexTypeOfSymbol(symbol, 0); - type.declaredNumberIndexType = getIndexTypeOfSymbol(symbol, 1); - } - return type; - } - function getTypeWithThisArgument(type, thisArgument) { - if (type.flags & 4096) { - return createTypeReference(type.target, ts.concatenate(type.typeArguments, [thisArgument || type.target.thisType])); - } - return type; - } - function resolveObjectTypeMembers(type, source, typeParameters, typeArguments) { - var mapper = identityMapper; - var members = source.symbol.members; - var callSignatures = source.declaredCallSignatures; - var constructSignatures = source.declaredConstructSignatures; - var stringIndexType = source.declaredStringIndexType; - var numberIndexType = source.declaredNumberIndexType; - if (!ts.rangeEquals(typeParameters, typeArguments, 0, typeParameters.length)) { - mapper = createTypeMapper(typeParameters, typeArguments); - members = createInstantiatedSymbolTable(source.declaredProperties, mapper, typeParameters.length === 1); - callSignatures = instantiateList(source.declaredCallSignatures, mapper, instantiateSignature); - constructSignatures = instantiateList(source.declaredConstructSignatures, mapper, instantiateSignature); - stringIndexType = instantiateType(source.declaredStringIndexType, mapper); - numberIndexType = instantiateType(source.declaredNumberIndexType, mapper); - } - var baseTypes = getBaseTypes(source); - if (baseTypes.length) { - if (members === source.symbol.members) { - members = createSymbolTable(source.declaredProperties); - } - var thisArgument = ts.lastOrUndefined(typeArguments); - for (var _i = 0; _i < baseTypes.length; _i++) { - var baseType = baseTypes[_i]; - var instantiatedBaseType = thisArgument ? getTypeWithThisArgument(instantiateType(baseType, mapper), thisArgument) : baseType; - addInheritedMembers(members, getPropertiesOfObjectType(instantiatedBaseType)); - callSignatures = ts.concatenate(callSignatures, getSignaturesOfType(instantiatedBaseType, 0)); - constructSignatures = ts.concatenate(constructSignatures, getSignaturesOfType(instantiatedBaseType, 1)); - stringIndexType = stringIndexType || getIndexTypeOfType(instantiatedBaseType, 0); - numberIndexType = numberIndexType || getIndexTypeOfType(instantiatedBaseType, 1); - } - } - setObjectTypeMembers(type, members, callSignatures, constructSignatures, stringIndexType, numberIndexType); - } - function resolveClassOrInterfaceMembers(type) { - resolveObjectTypeMembers(type, resolveDeclaredMembers(type), emptyArray, emptyArray); - } - function resolveTypeReferenceMembers(type) { - var source = resolveDeclaredMembers(type.target); - var typeParameters = ts.concatenate(source.typeParameters, [source.thisType]); - var typeArguments = type.typeArguments && type.typeArguments.length === typeParameters.length ? - type.typeArguments : ts.concatenate(type.typeArguments, [type]); - resolveObjectTypeMembers(type, source, typeParameters, typeArguments); - } - function createSignature(declaration, typeParameters, parameters, resolvedReturnType, typePredicate, minArgumentCount, hasRestParameter, hasStringLiterals) { - var sig = new Signature(checker); - sig.declaration = declaration; - sig.typeParameters = typeParameters; - sig.parameters = parameters; - sig.resolvedReturnType = resolvedReturnType; - sig.typePredicate = typePredicate; - sig.minArgumentCount = minArgumentCount; - sig.hasRestParameter = hasRestParameter; - sig.hasStringLiterals = hasStringLiterals; - return sig; - } - function cloneSignature(sig) { - return createSignature(sig.declaration, sig.typeParameters, sig.parameters, sig.resolvedReturnType, sig.typePredicate, sig.minArgumentCount, sig.hasRestParameter, sig.hasStringLiterals); - } - function getDefaultConstructSignatures(classType) { - if (!hasClassBaseType(classType)) { - return [createSignature(undefined, classType.localTypeParameters, emptyArray, classType, undefined, 0, false, false)]; - } - var baseConstructorType = getBaseConstructorTypeOfClass(classType); - var baseSignatures = getSignaturesOfType(baseConstructorType, 1); - var baseTypeNode = getBaseTypeNodeOfClass(classType); - var typeArguments = ts.map(baseTypeNode.typeArguments, getTypeFromTypeNode); - var typeArgCount = typeArguments ? typeArguments.length : 0; - var result = []; - for (var _i = 0; _i < baseSignatures.length; _i++) { - var baseSig = baseSignatures[_i]; - var typeParamCount = baseSig.typeParameters ? baseSig.typeParameters.length : 0; - if (typeParamCount === typeArgCount) { - var sig = typeParamCount ? getSignatureInstantiation(baseSig, typeArguments) : cloneSignature(baseSig); - sig.typeParameters = classType.localTypeParameters; - sig.resolvedReturnType = classType; - result.push(sig); - } - } - return result; - } - function createTupleTypeMemberSymbols(memberTypes) { - var members = {}; - for (var i = 0; i < memberTypes.length; i++) { - var symbol = createSymbol(4 | 67108864, "" + i); - symbol.type = memberTypes[i]; - members[i] = symbol; - } - return members; - } - function resolveTupleTypeMembers(type) { - var arrayElementType = getUnionType(type.elementTypes, true); - var arrayType = resolveStructuredTypeMembers(createTypeFromGenericGlobalType(globalArrayType, [arrayElementType, type])); - var members = createTupleTypeMemberSymbols(type.elementTypes); - addInheritedMembers(members, arrayType.properties); - setObjectTypeMembers(type, members, arrayType.callSignatures, arrayType.constructSignatures, arrayType.stringIndexType, arrayType.numberIndexType); - } - function findMatchingSignature(signatureList, signature, partialMatch, ignoreReturnTypes) { - for (var _i = 0; _i < signatureList.length; _i++) { - var s = signatureList[_i]; - if (compareSignatures(s, signature, partialMatch, ignoreReturnTypes, compareTypes)) { - return s; - } - } - } - function findMatchingSignatures(signatureLists, signature, listIndex) { - if (signature.typeParameters) { - if (listIndex > 0) { - return undefined; - } - for (var i = 1; i < signatureLists.length; i++) { - if (!findMatchingSignature(signatureLists[i], signature, false, false)) { - return undefined; - } - } - return [signature]; - } - var result = undefined; - for (var i = 0; i < signatureLists.length; i++) { - var match = i === listIndex ? signature : findMatchingSignature(signatureLists[i], signature, true, true); - if (!match) { - return undefined; - } - if (!ts.contains(result, match)) { - (result || (result = [])).push(match); - } - } - return result; - } - function getUnionSignatures(types, kind) { - var signatureLists = ts.map(types, function (t) { return getSignaturesOfType(t, kind); }); - var result = undefined; - for (var i = 0; i < signatureLists.length; i++) { - for (var _i = 0, _a = signatureLists[i]; _i < _a.length; _i++) { - var signature = _a[_i]; - if (!result || !findMatchingSignature(result, signature, false, true)) { - var unionSignatures = findMatchingSignatures(signatureLists, signature, i); - if (unionSignatures) { - var s = signature; - if (unionSignatures.length > 1) { - s = cloneSignature(signature); - s.resolvedReturnType = undefined; - s.unionSignatures = unionSignatures; - } - (result || (result = [])).push(s); - } - } - } - } - return result || emptyArray; - } - function getUnionIndexType(types, kind) { - var indexTypes = []; - for (var _i = 0; _i < types.length; _i++) { - var type = types[_i]; - var indexType = getIndexTypeOfType(type, kind); - if (!indexType) { - return undefined; - } - indexTypes.push(indexType); - } - return getUnionType(indexTypes); - } - function resolveUnionTypeMembers(type) { - var callSignatures = getUnionSignatures(type.types, 0); - var constructSignatures = getUnionSignatures(type.types, 1); - var stringIndexType = getUnionIndexType(type.types, 0); - var numberIndexType = getUnionIndexType(type.types, 1); - setObjectTypeMembers(type, emptySymbols, callSignatures, constructSignatures, stringIndexType, numberIndexType); - } - function intersectTypes(type1, type2) { - return !type1 ? type2 : !type2 ? type1 : getIntersectionType([type1, type2]); - } - function resolveIntersectionTypeMembers(type) { - var callSignatures = emptyArray; - var constructSignatures = emptyArray; - var stringIndexType = undefined; - var numberIndexType = undefined; - for (var _i = 0, _a = type.types; _i < _a.length; _i++) { - var t = _a[_i]; - callSignatures = ts.concatenate(callSignatures, getSignaturesOfType(t, 0)); - constructSignatures = ts.concatenate(constructSignatures, getSignaturesOfType(t, 1)); - stringIndexType = intersectTypes(stringIndexType, getIndexTypeOfType(t, 0)); - numberIndexType = intersectTypes(numberIndexType, getIndexTypeOfType(t, 1)); - } - setObjectTypeMembers(type, emptySymbols, callSignatures, constructSignatures, stringIndexType, numberIndexType); - } - function resolveAnonymousTypeMembers(type) { - var symbol = type.symbol; - var members; - var callSignatures; - var constructSignatures; - var stringIndexType; - var numberIndexType; - if (type.target) { - members = createInstantiatedSymbolTable(getPropertiesOfObjectType(type.target), type.mapper, false); - callSignatures = instantiateList(getSignaturesOfType(type.target, 0), type.mapper, instantiateSignature); - constructSignatures = instantiateList(getSignaturesOfType(type.target, 1), type.mapper, instantiateSignature); - stringIndexType = instantiateType(getIndexTypeOfType(type.target, 0), type.mapper); - numberIndexType = instantiateType(getIndexTypeOfType(type.target, 1), type.mapper); - } - else if (symbol.flags & 2048) { - members = symbol.members; - callSignatures = getSignaturesOfSymbol(members["__call"]); - constructSignatures = getSignaturesOfSymbol(members["__new"]); - stringIndexType = getIndexTypeOfSymbol(symbol, 0); - numberIndexType = getIndexTypeOfSymbol(symbol, 1); - } - else { - members = emptySymbols; - callSignatures = emptyArray; - constructSignatures = emptyArray; - if (symbol.flags & 1952) { - members = getExportsOfSymbol(symbol); - } - if (symbol.flags & (16 | 8192)) { - callSignatures = getSignaturesOfSymbol(symbol); - } - if (symbol.flags & 32) { - var classType = getDeclaredTypeOfClassOrInterface(symbol); - constructSignatures = getSignaturesOfSymbol(symbol.members["__constructor"]); - if (!constructSignatures.length) { - constructSignatures = getDefaultConstructSignatures(classType); - } - var baseConstructorType = getBaseConstructorTypeOfClass(classType); - if (baseConstructorType.flags & 80896) { - members = createSymbolTable(getNamedMembers(members)); - addInheritedMembers(members, getPropertiesOfObjectType(baseConstructorType)); - } - } - stringIndexType = undefined; - numberIndexType = (symbol.flags & 384) ? stringType : undefined; - } - setObjectTypeMembers(type, members, callSignatures, constructSignatures, stringIndexType, numberIndexType); - } - function resolveStructuredTypeMembers(type) { - if (!type.members) { - if (type.flags & 4096) { - resolveTypeReferenceMembers(type); - } - else if (type.flags & (1024 | 2048)) { - resolveClassOrInterfaceMembers(type); - } - else if (type.flags & 65536) { - resolveAnonymousTypeMembers(type); - } - else if (type.flags & 8192) { - resolveTupleTypeMembers(type); - } - else if (type.flags & 16384) { - resolveUnionTypeMembers(type); - } - else if (type.flags & 32768) { - resolveIntersectionTypeMembers(type); - } - } - return type; - } - function getPropertiesOfObjectType(type) { - if (type.flags & 80896) { - return resolveStructuredTypeMembers(type).properties; - } - return emptyArray; - } - function getPropertyOfObjectType(type, name) { - if (type.flags & 80896) { - var resolved = resolveStructuredTypeMembers(type); - if (ts.hasProperty(resolved.members, name)) { - var symbol = resolved.members[name]; - if (symbolIsValue(symbol)) { - return symbol; - } - } - } - } - function getPropertiesOfUnionOrIntersectionType(type) { - for (var _i = 0, _a = type.types; _i < _a.length; _i++) { - var current = _a[_i]; - for (var _b = 0, _c = getPropertiesOfType(current); _b < _c.length; _b++) { - var prop = _c[_b]; - getPropertyOfUnionOrIntersectionType(type, prop.name); - } - if (type.flags & 16384) { - break; - } - } - return type.resolvedProperties ? symbolsToArray(type.resolvedProperties) : emptyArray; - } - function getPropertiesOfType(type) { - type = getApparentType(type); - return type.flags & 49152 ? getPropertiesOfUnionOrIntersectionType(type) : getPropertiesOfObjectType(type); - } - function getApparentType(type) { - if (type.flags & 512) { - do { - type = getConstraintOfTypeParameter(type); - } while (type && type.flags & 512); - if (!type) { - type = emptyObjectType; - } - } - if (type.flags & 258) { - type = globalStringType; - } - else if (type.flags & 132) { - type = globalNumberType; - } - else if (type.flags & 8) { - type = globalBooleanType; - } - else if (type.flags & 16777216) { - type = globalESSymbolType; - } - return type; - } - function createUnionOrIntersectionProperty(containingType, name) { - var types = containingType.types; - var props; - for (var _i = 0; _i < types.length; _i++) { - var current = types[_i]; - var type = getApparentType(current); - if (type !== unknownType) { - var prop = getPropertyOfType(type, name); - if (prop && !(getDeclarationFlagsFromSymbol(prop) & (32 | 64))) { - if (!props) { - props = [prop]; - } - else if (!ts.contains(props, prop)) { - props.push(prop); - } - } - else if (containingType.flags & 16384) { - return undefined; - } - } - } - if (!props) { - return undefined; - } - if (props.length === 1) { - return props[0]; - } - var propTypes = []; - var declarations = []; - for (var _a = 0; _a < props.length; _a++) { - var prop = props[_a]; - if (prop.declarations) { - ts.addRange(declarations, prop.declarations); - } - propTypes.push(getTypeOfSymbol(prop)); - } - var result = createSymbol(4 | 67108864 | 268435456, name); - result.containingType = containingType; - result.declarations = declarations; - result.type = containingType.flags & 16384 ? getUnionType(propTypes) : getIntersectionType(propTypes); - return result; - } - function getPropertyOfUnionOrIntersectionType(type, name) { - var properties = type.resolvedProperties || (type.resolvedProperties = {}); - if (ts.hasProperty(properties, name)) { - return properties[name]; - } - var property = createUnionOrIntersectionProperty(type, name); - if (property) { - properties[name] = property; - } - return property; - } - function getPropertyOfType(type, name) { - type = getApparentType(type); - if (type.flags & 80896) { - var resolved = resolveStructuredTypeMembers(type); - if (ts.hasProperty(resolved.members, name)) { - var symbol = resolved.members[name]; - if (symbolIsValue(symbol)) { - return symbol; - } - } - if (resolved === anyFunctionType || resolved.callSignatures.length || resolved.constructSignatures.length) { - var symbol = getPropertyOfObjectType(globalFunctionType, name); - if (symbol) { - return symbol; - } - } - return getPropertyOfObjectType(globalObjectType, name); - } - if (type.flags & 49152) { - return getPropertyOfUnionOrIntersectionType(type, name); - } - return undefined; - } - function getSignaturesOfStructuredType(type, kind) { - if (type.flags & 130048) { - var resolved = resolveStructuredTypeMembers(type); - return kind === 0 ? resolved.callSignatures : resolved.constructSignatures; - } - return emptyArray; - } - function getSignaturesOfType(type, kind) { - return getSignaturesOfStructuredType(getApparentType(type), kind); - } - function typeHasConstructSignatures(type) { - var apparentType = getApparentType(type); - if (apparentType.flags & (80896 | 16384)) { - var resolved = resolveStructuredTypeMembers(type); - return resolved.constructSignatures.length > 0; - } - return false; - } - function typeHasCallOrConstructSignatures(type) { - var apparentType = getApparentType(type); - if (apparentType.flags & 130048) { - var resolved = resolveStructuredTypeMembers(type); - return resolved.callSignatures.length > 0 || resolved.constructSignatures.length > 0; - } - return false; - } - function getIndexTypeOfStructuredType(type, kind) { - if (type.flags & 130048) { - var resolved = resolveStructuredTypeMembers(type); - return kind === 0 ? resolved.stringIndexType : resolved.numberIndexType; - } - } - function getIndexTypeOfType(type, kind) { - return getIndexTypeOfStructuredType(getApparentType(type), kind); - } - function getTypeParametersFromDeclaration(typeParameterDeclarations) { - var result = []; - ts.forEach(typeParameterDeclarations, function (node) { - var tp = getDeclaredTypeOfTypeParameter(node.symbol); - if (!ts.contains(result, tp)) { - result.push(tp); - } - }); - return result; - } - function symbolsToArray(symbols) { - var result = []; - for (var id in symbols) { - if (!isReservedMemberName(id)) { - result.push(symbols[id]); - } - } - return result; - } - function isOptionalParameter(node) { - if (ts.hasQuestionToken(node)) { - return true; - } - if (node.initializer) { - var signatureDeclaration = node.parent; - var signature = getSignatureFromDeclaration(signatureDeclaration); - var parameterIndex = signatureDeclaration.parameters.indexOf(node); - ts.Debug.assert(parameterIndex >= 0); - return parameterIndex >= signature.minArgumentCount; - } - return false; - } - function getSignatureFromDeclaration(declaration) { - var links = getNodeLinks(declaration); - if (!links.resolvedSignature) { - var classType = declaration.kind === 144 ? - getDeclaredTypeOfClassOrInterface(getMergedSymbol(declaration.parent.symbol)) - : undefined; - var typeParameters = classType ? classType.localTypeParameters : - declaration.typeParameters ? getTypeParametersFromDeclaration(declaration.typeParameters) : undefined; - var parameters = []; - var hasStringLiterals = false; - var minArgumentCount = -1; - for (var i = 0, n = declaration.parameters.length; i < n; i++) { - var param = declaration.parameters[i]; - parameters.push(param.symbol); - if (param.type && param.type.kind === 9) { - hasStringLiterals = true; - } - if (param.initializer || param.questionToken || param.dotDotDotToken) { - if (minArgumentCount < 0) { - minArgumentCount = i; - } - } - else { - minArgumentCount = -1; - } - } - if (minArgumentCount < 0) { - minArgumentCount = declaration.parameters.length; - } - var returnType; - var typePredicate; - if (classType) { - returnType = classType; - } - else if (declaration.type) { - returnType = getTypeFromTypeNode(declaration.type); - if (declaration.type.kind === 150) { - var typePredicateNode = declaration.type; - typePredicate = { - parameterName: typePredicateNode.parameterName ? typePredicateNode.parameterName.text : undefined, - parameterIndex: typePredicateNode.parameterName ? getTypePredicateParameterIndex(declaration.parameters, typePredicateNode.parameterName) : undefined, - type: getTypeFromTypeNode(typePredicateNode.type) - }; - } - } - else { - if (declaration.kind === 145 && !ts.hasDynamicName(declaration)) { - var setter = ts.getDeclarationOfKind(declaration.symbol, 146); - returnType = getAnnotatedAccessorType(setter); - } - if (!returnType && ts.nodeIsMissing(declaration.body)) { - returnType = anyType; - } - } - links.resolvedSignature = createSignature(declaration, typeParameters, parameters, returnType, typePredicate, minArgumentCount, ts.hasRestParameter(declaration), hasStringLiterals); - } - return links.resolvedSignature; - } - function getSignaturesOfSymbol(symbol) { - if (!symbol) - return emptyArray; - var result = []; - for (var i = 0, len = symbol.declarations.length; i < len; i++) { - var node = symbol.declarations[i]; - switch (node.kind) { - case 152: - case 153: - case 213: - case 143: - case 142: - case 144: - case 147: - case 148: - case 149: - case 145: - case 146: - case 173: - case 174: - if (i > 0 && node.body) { - var previous = symbol.declarations[i - 1]; - if (node.parent === previous.parent && node.kind === previous.kind && node.pos === previous.end) { - break; - } - } - result.push(getSignatureFromDeclaration(node)); - } - } - return result; - } - function getReturnTypeOfSignature(signature) { - if (!signature.resolvedReturnType) { - if (!pushTypeResolution(signature, 3)) { - return unknownType; - } - var type; - if (signature.target) { - type = instantiateType(getReturnTypeOfSignature(signature.target), signature.mapper); - } - else if (signature.unionSignatures) { - type = getUnionType(ts.map(signature.unionSignatures, getReturnTypeOfSignature)); - } - else { - type = getReturnTypeFromBody(signature.declaration); - } - if (!popTypeResolution()) { - type = anyType; - if (compilerOptions.noImplicitAny) { - var declaration = signature.declaration; - if (declaration.name) { - error(declaration.name, 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, ts.declarationNameToString(declaration.name)); - } - else { - error(declaration, ts.Diagnostics.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); - } - } - } - signature.resolvedReturnType = type; - } - return signature.resolvedReturnType; - } - function getRestTypeOfSignature(signature) { - if (signature.hasRestParameter) { - var type = getTypeOfSymbol(ts.lastOrUndefined(signature.parameters)); - if (type.flags & 4096 && type.target === globalArrayType) { - return type.typeArguments[0]; - } - } - return anyType; - } - function getSignatureInstantiation(signature, typeArguments) { - return instantiateSignature(signature, createTypeMapper(signature.typeParameters, typeArguments), true); - } - function getErasedSignature(signature) { - if (!signature.typeParameters) - return signature; - if (!signature.erasedSignatureCache) { - if (signature.target) { - signature.erasedSignatureCache = instantiateSignature(getErasedSignature(signature.target), signature.mapper); - } - else { - signature.erasedSignatureCache = instantiateSignature(signature, createTypeEraser(signature.typeParameters), true); - } - } - return signature.erasedSignatureCache; - } - function getOrCreateTypeFromSignature(signature) { - if (!signature.isolatedSignatureType) { - var isConstructor = signature.declaration.kind === 144 || signature.declaration.kind === 148; - var type = createObjectType(65536 | 262144); - type.members = emptySymbols; - type.properties = emptyArray; - type.callSignatures = !isConstructor ? [signature] : emptyArray; - type.constructSignatures = isConstructor ? [signature] : emptyArray; - signature.isolatedSignatureType = type; - } - return signature.isolatedSignatureType; - } - function getIndexSymbol(symbol) { - return symbol.members["__index"]; - } - function getIndexDeclarationOfSymbol(symbol, kind) { - var syntaxKind = kind === 1 ? 128 : 130; - var indexSymbol = getIndexSymbol(symbol); - if (indexSymbol) { - for (var _i = 0, _a = indexSymbol.declarations; _i < _a.length; _i++) { - var decl = _a[_i]; - var node = decl; - if (node.parameters.length === 1) { - var parameter = node.parameters[0]; - if (parameter && parameter.type && parameter.type.kind === syntaxKind) { - return node; - } - } - } - } - return undefined; - } - function getIndexTypeOfSymbol(symbol, kind) { - var declaration = getIndexDeclarationOfSymbol(symbol, kind); - return declaration - ? declaration.type ? getTypeFromTypeNode(declaration.type) : anyType - : undefined; - } - function getConstraintOfTypeParameter(type) { - if (!type.constraint) { - if (type.target) { - var targetConstraint = getConstraintOfTypeParameter(type.target); - type.constraint = targetConstraint ? instantiateType(targetConstraint, type.mapper) : noConstraintType; - } - else { - type.constraint = getTypeFromTypeNode(ts.getDeclarationOfKind(type.symbol, 137).constraint); - } - } - return type.constraint === noConstraintType ? undefined : type.constraint; - } - function getParentSymbolOfTypeParameter(typeParameter) { - return getSymbolOfNode(ts.getDeclarationOfKind(typeParameter.symbol, 137).parent); - } - function getTypeListId(types) { - if (types) { - switch (types.length) { - case 1: - return "" + types[0].id; - case 2: - return types[0].id + "," + types[1].id; - default: - var result = ""; - for (var i = 0; i < types.length; i++) { - if (i > 0) { - result += ","; - } - result += types[i].id; - } - return result; - } - } - return ""; - } - function getPropagatingFlagsOfTypes(types) { - var result = 0; - for (var _i = 0; _i < types.length; _i++) { - var type = types[_i]; - result |= type.flags; - } - return result & 14680064; - } - function createTypeReference(target, typeArguments) { - var id = getTypeListId(typeArguments); - var type = target.instantiations[id]; - if (!type) { - var flags = 4096 | (typeArguments ? getPropagatingFlagsOfTypes(typeArguments) : 0); - type = target.instantiations[id] = createObjectType(flags, target.symbol); - type.target = target; - type.typeArguments = typeArguments; - } - return type; - } - function isTypeParameterReferenceIllegalInConstraint(typeReferenceNode, typeParameterSymbol) { - var links = getNodeLinks(typeReferenceNode); - if (links.isIllegalTypeReferenceInConstraint !== undefined) { - return links.isIllegalTypeReferenceInConstraint; - } - var currentNode = typeReferenceNode; - while (!ts.forEach(typeParameterSymbol.declarations, function (d) { return d.parent === currentNode.parent; })) { - currentNode = currentNode.parent; - } - links.isIllegalTypeReferenceInConstraint = currentNode.kind === 137; - return links.isIllegalTypeReferenceInConstraint; - } - function checkTypeParameterHasIllegalReferencesInConstraint(typeParameter) { - var typeParameterSymbol; - function check(n) { - if (n.kind === 151 && n.typeName.kind === 69) { - var links = getNodeLinks(n); - if (links.isIllegalTypeReferenceInConstraint === undefined) { - var symbol = resolveName(typeParameter, n.typeName.text, 793056, undefined, undefined); - if (symbol && (symbol.flags & 262144)) { - links.isIllegalTypeReferenceInConstraint = ts.forEach(symbol.declarations, function (d) { return d.parent === typeParameter.parent; }); - } - } - if (links.isIllegalTypeReferenceInConstraint) { - error(typeParameter, ts.Diagnostics.Constraint_of_a_type_parameter_cannot_reference_any_type_parameter_from_the_same_type_parameter_list); - } - } - ts.forEachChild(n, check); - } - if (typeParameter.constraint) { - typeParameterSymbol = getSymbolOfNode(typeParameter); - check(typeParameter.constraint); - } - } - function getTypeFromClassOrInterfaceReference(node, symbol) { - var type = getDeclaredTypeOfSymbol(symbol); - var typeParameters = type.localTypeParameters; - if (typeParameters) { - if (!node.typeArguments || node.typeArguments.length !== typeParameters.length) { - error(node, ts.Diagnostics.Generic_type_0_requires_1_type_argument_s, typeToString(type, undefined, 1), typeParameters.length); - return unknownType; - } - return createTypeReference(type, ts.concatenate(type.outerTypeParameters, ts.map(node.typeArguments, getTypeFromTypeNode))); - } - if (node.typeArguments) { - error(node, ts.Diagnostics.Type_0_is_not_generic, typeToString(type)); - return unknownType; - } - return type; - } - function getTypeFromTypeAliasReference(node, symbol) { - var type = getDeclaredTypeOfSymbol(symbol); - var links = getSymbolLinks(symbol); - var typeParameters = links.typeParameters; - if (typeParameters) { - if (!node.typeArguments || node.typeArguments.length !== typeParameters.length) { - error(node, ts.Diagnostics.Generic_type_0_requires_1_type_argument_s, symbolToString(symbol), typeParameters.length); - return unknownType; - } - var typeArguments = ts.map(node.typeArguments, getTypeFromTypeNode); - var id = getTypeListId(typeArguments); - return links.instantiations[id] || (links.instantiations[id] = instantiateType(type, createTypeMapper(typeParameters, typeArguments))); - } - if (node.typeArguments) { - error(node, ts.Diagnostics.Type_0_is_not_generic, symbolToString(symbol)); - return unknownType; - } - return type; - } - function getTypeFromNonGenericTypeReference(node, symbol) { - if (symbol.flags & 262144 && isTypeParameterReferenceIllegalInConstraint(node, symbol)) { - return unknownType; - } - if (node.typeArguments) { - error(node, ts.Diagnostics.Type_0_is_not_generic, symbolToString(symbol)); - return unknownType; - } - return getDeclaredTypeOfSymbol(symbol); - } - function getTypeFromTypeReference(node) { - var links = getNodeLinks(node); - if (!links.resolvedType) { - var typeNameOrExpression = node.kind === 151 ? node.typeName : - ts.isSupportedExpressionWithTypeArguments(node) ? node.expression : - undefined; - var symbol = typeNameOrExpression && resolveEntityName(typeNameOrExpression, 793056) || unknownSymbol; - var type = symbol === unknownSymbol ? unknownType : - symbol.flags & (32 | 64) ? getTypeFromClassOrInterfaceReference(node, symbol) : - symbol.flags & 524288 ? getTypeFromTypeAliasReference(node, symbol) : - getTypeFromNonGenericTypeReference(node, symbol); - links.resolvedSymbol = symbol; - links.resolvedType = type; - } - return links.resolvedType; - } - function getTypeFromTypeQueryNode(node) { - var links = getNodeLinks(node); - if (!links.resolvedType) { - links.resolvedType = getWidenedType(checkExpression(node.exprName)); - } - return links.resolvedType; - } - function getTypeOfGlobalSymbol(symbol, arity) { - function getTypeDeclaration(symbol) { - var declarations = symbol.declarations; - for (var _i = 0; _i < declarations.length; _i++) { - var declaration = declarations[_i]; - switch (declaration.kind) { - case 214: - case 215: - case 217: - return declaration; - } - } - } - if (!symbol) { - return arity ? emptyGenericType : emptyObjectType; - } - var type = getDeclaredTypeOfSymbol(symbol); - if (!(type.flags & 80896)) { - error(getTypeDeclaration(symbol), ts.Diagnostics.Global_type_0_must_be_a_class_or_interface_type, symbol.name); - return arity ? emptyGenericType : emptyObjectType; - } - if ((type.typeParameters ? type.typeParameters.length : 0) !== arity) { - error(getTypeDeclaration(symbol), ts.Diagnostics.Global_type_0_must_have_1_type_parameter_s, symbol.name, arity); - return arity ? emptyGenericType : emptyObjectType; - } - return type; - } - function getGlobalValueSymbol(name) { - return getGlobalSymbol(name, 107455, ts.Diagnostics.Cannot_find_global_value_0); - } - function getGlobalTypeSymbol(name) { - return getGlobalSymbol(name, 793056, ts.Diagnostics.Cannot_find_global_type_0); - } - function getGlobalSymbol(name, meaning, diagnostic) { - return resolveName(undefined, name, meaning, diagnostic, name); - } - function getGlobalType(name, arity) { - if (arity === void 0) { arity = 0; } - return getTypeOfGlobalSymbol(getGlobalTypeSymbol(name), arity); - } - function tryGetGlobalType(name, arity) { - if (arity === void 0) { arity = 0; } - return getTypeOfGlobalSymbol(getGlobalSymbol(name, 793056, undefined), arity); - } - function getExportedTypeFromNamespace(namespace, name) { - var namespaceSymbol = getGlobalSymbol(namespace, 1536, undefined); - var typeSymbol = namespaceSymbol && getSymbol(namespaceSymbol.exports, name, 793056); - return typeSymbol && getDeclaredTypeOfSymbol(typeSymbol); - } - function getGlobalESSymbolConstructorSymbol() { - return globalESSymbolConstructorSymbol || (globalESSymbolConstructorSymbol = getGlobalValueSymbol("Symbol")); - } - function createTypedPropertyDescriptorType(propertyType) { - var globalTypedPropertyDescriptorType = getGlobalTypedPropertyDescriptorType(); - return globalTypedPropertyDescriptorType !== emptyGenericType - ? createTypeReference(globalTypedPropertyDescriptorType, [propertyType]) - : emptyObjectType; - } - function createTypeFromGenericGlobalType(genericGlobalType, typeArguments) { - return genericGlobalType !== emptyGenericType ? createTypeReference(genericGlobalType, typeArguments) : emptyObjectType; - } - function createIterableType(elementType) { - return createTypeFromGenericGlobalType(globalIterableType, [elementType]); - } - function createIterableIteratorType(elementType) { - return createTypeFromGenericGlobalType(globalIterableIteratorType, [elementType]); - } - function createArrayType(elementType) { - return createTypeFromGenericGlobalType(globalArrayType, [elementType]); - } - function getTypeFromArrayTypeNode(node) { - var links = getNodeLinks(node); - if (!links.resolvedType) { - links.resolvedType = createArrayType(getTypeFromTypeNode(node.elementType)); - } - return links.resolvedType; - } - function createTupleType(elementTypes) { - var id = getTypeListId(elementTypes); - return tupleTypes[id] || (tupleTypes[id] = createNewTupleType(elementTypes)); - } - function createNewTupleType(elementTypes) { - var type = createObjectType(8192 | getPropagatingFlagsOfTypes(elementTypes)); - type.elementTypes = elementTypes; - return type; - } - function getTypeFromTupleTypeNode(node) { - var links = getNodeLinks(node); - if (!links.resolvedType) { - links.resolvedType = createTupleType(ts.map(node.elementTypes, getTypeFromTypeNode)); - } - return links.resolvedType; - } - function addTypeToSet(typeSet, type, typeSetKind) { - if (type.flags & typeSetKind) { - addTypesToSet(typeSet, type.types, typeSetKind); - } - else if (!ts.contains(typeSet, type)) { - typeSet.push(type); - } - } - function addTypesToSet(typeSet, types, typeSetKind) { - for (var _i = 0; _i < types.length; _i++) { - var type = types[_i]; - addTypeToSet(typeSet, type, typeSetKind); - } - } - function isSubtypeOfAny(candidate, types) { - for (var i = 0, len = types.length; i < len; i++) { - if (candidate !== types[i] && isTypeSubtypeOf(candidate, types[i])) { - return true; - } - } - return false; - } - function removeSubtypes(types) { - var i = types.length; - while (i > 0) { - i--; - if (isSubtypeOfAny(types[i], types)) { - types.splice(i, 1); - } - } - } - function containsTypeAny(types) { - for (var _i = 0; _i < types.length; _i++) { - var type = types[_i]; - if (isTypeAny(type)) { - return true; - } - } - return false; - } - function removeAllButLast(types, typeToRemove) { - var i = types.length; - while (i > 0 && types.length > 1) { - i--; - if (types[i] === typeToRemove) { - types.splice(i, 1); - } - } - } - function getUnionType(types, noSubtypeReduction) { - if (types.length === 0) { - return emptyObjectType; - } - var typeSet = []; - addTypesToSet(typeSet, types, 16384); - if (containsTypeAny(typeSet)) { - return anyType; - } - if (noSubtypeReduction) { - removeAllButLast(typeSet, undefinedType); - removeAllButLast(typeSet, nullType); - } - else { - removeSubtypes(typeSet); - } - if (typeSet.length === 1) { - return typeSet[0]; - } - var id = getTypeListId(typeSet); - var type = unionTypes[id]; - if (!type) { - type = unionTypes[id] = createObjectType(16384 | getPropagatingFlagsOfTypes(typeSet)); - type.types = typeSet; - } - return type; - } - function getTypeFromUnionTypeNode(node) { - var links = getNodeLinks(node); - if (!links.resolvedType) { - links.resolvedType = getUnionType(ts.map(node.types, getTypeFromTypeNode), true); - } - return links.resolvedType; - } - function getIntersectionType(types) { - if (types.length === 0) { - return emptyObjectType; - } - var typeSet = []; - addTypesToSet(typeSet, types, 32768); - if (containsTypeAny(typeSet)) { - return anyType; - } - if (typeSet.length === 1) { - return typeSet[0]; - } - var id = getTypeListId(typeSet); - var type = intersectionTypes[id]; - if (!type) { - type = intersectionTypes[id] = createObjectType(32768 | getPropagatingFlagsOfTypes(typeSet)); - type.types = typeSet; - } - return type; - } - function getTypeFromIntersectionTypeNode(node) { - var links = getNodeLinks(node); - if (!links.resolvedType) { - links.resolvedType = getIntersectionType(ts.map(node.types, getTypeFromTypeNode)); - } - return links.resolvedType; - } - function getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node) { - var links = getNodeLinks(node); - if (!links.resolvedType) { - links.resolvedType = createObjectType(65536, node.symbol); - } - return links.resolvedType; - } - function getStringLiteralType(node) { - if (ts.hasProperty(stringLiteralTypes, node.text)) { - return stringLiteralTypes[node.text]; - } - var type = stringLiteralTypes[node.text] = createType(256); - type.text = ts.getTextOfNode(node); - return type; - } - function getTypeFromStringLiteral(node) { - var links = getNodeLinks(node); - if (!links.resolvedType) { - links.resolvedType = getStringLiteralType(node); - } - return links.resolvedType; - } - function getThisType(node) { - var container = ts.getThisContainer(node, false); - var parent = container && container.parent; - if (parent && (ts.isClassLike(parent) || parent.kind === 215)) { - if (!(container.flags & 128)) { - return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(parent)).thisType; - } - } - error(node, ts.Diagnostics.A_this_type_is_available_only_in_a_non_static_member_of_a_class_or_interface); - return unknownType; - } - function getTypeFromThisTypeNode(node) { - var links = getNodeLinks(node); - if (!links.resolvedType) { - links.resolvedType = getThisType(node); - } - return links.resolvedType; - } - function getTypeFromTypeNode(node) { - switch (node.kind) { - case 117: - return anyType; - case 130: - return stringType; - case 128: - return numberType; - case 120: - return booleanType; - case 131: - return esSymbolType; - case 103: - return voidType; - case 97: - return getTypeFromThisTypeNode(node); - case 9: - return getTypeFromStringLiteral(node); - case 151: - return getTypeFromTypeReference(node); - case 150: - return booleanType; - case 188: - return getTypeFromTypeReference(node); - case 154: - return getTypeFromTypeQueryNode(node); - case 156: - return getTypeFromArrayTypeNode(node); - case 157: - return getTypeFromTupleTypeNode(node); - case 158: - return getTypeFromUnionTypeNode(node); - case 159: - return getTypeFromIntersectionTypeNode(node); - case 160: - return getTypeFromTypeNode(node.type); - case 152: - case 153: - case 155: - return getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node); - case 69: - case 135: - var symbol = getSymbolAtLocation(node); - return symbol && getDeclaredTypeOfSymbol(symbol); - default: - return unknownType; - } - } - function instantiateList(items, mapper, instantiator) { - if (items && items.length) { - var result = []; - for (var _i = 0; _i < items.length; _i++) { - var v = items[_i]; - result.push(instantiator(v, mapper)); - } - return result; - } - return items; - } - function createUnaryTypeMapper(source, target) { - return function (t) { return t === source ? target : t; }; - } - function createBinaryTypeMapper(source1, target1, source2, target2) { - return function (t) { return t === source1 ? target1 : t === source2 ? target2 : t; }; - } - function createTypeMapper(sources, targets) { - switch (sources.length) { - case 1: return createUnaryTypeMapper(sources[0], targets[0]); - case 2: return createBinaryTypeMapper(sources[0], targets[0], sources[1], targets[1]); - } - return function (t) { - for (var i = 0; i < sources.length; i++) { - if (t === sources[i]) { - return targets[i]; - } - } - return t; - }; - } - function createUnaryTypeEraser(source) { - return function (t) { return t === source ? anyType : t; }; - } - function createBinaryTypeEraser(source1, source2) { - return function (t) { return t === source1 || t === source2 ? anyType : t; }; - } - function createTypeEraser(sources) { - switch (sources.length) { - case 1: return createUnaryTypeEraser(sources[0]); - case 2: return createBinaryTypeEraser(sources[0], sources[1]); - } - return function (t) { - for (var _i = 0; _i < sources.length; _i++) { - var source = sources[_i]; - if (t === source) { - return anyType; - } - } - return t; - }; - } - function createInferenceMapper(context) { - var mapper = function (t) { - for (var i = 0; i < context.typeParameters.length; i++) { - if (t === context.typeParameters[i]) { - context.inferences[i].isFixed = true; - return getInferredType(context, i); - } - } - return t; - }; - mapper.context = context; - return mapper; - } - function identityMapper(type) { - return type; - } - function combineTypeMappers(mapper1, mapper2) { - return function (t) { return instantiateType(mapper1(t), mapper2); }; - } - function instantiateTypeParameter(typeParameter, mapper) { - var result = createType(512); - result.symbol = typeParameter.symbol; - if (typeParameter.constraint) { - result.constraint = instantiateType(typeParameter.constraint, mapper); - } - else { - result.target = typeParameter; - result.mapper = mapper; - } - return result; - } - function instantiateSignature(signature, mapper, eraseTypeParameters) { - var freshTypeParameters; - var freshTypePredicate; - if (signature.typeParameters && !eraseTypeParameters) { - freshTypeParameters = instantiateList(signature.typeParameters, mapper, instantiateTypeParameter); - mapper = combineTypeMappers(createTypeMapper(signature.typeParameters, freshTypeParameters), mapper); - } - if (signature.typePredicate) { - freshTypePredicate = { - parameterName: signature.typePredicate.parameterName, - parameterIndex: signature.typePredicate.parameterIndex, - type: instantiateType(signature.typePredicate.type, mapper) - }; - } - var result = createSignature(signature.declaration, freshTypeParameters, instantiateList(signature.parameters, mapper, instantiateSymbol), instantiateType(signature.resolvedReturnType, mapper), freshTypePredicate, signature.minArgumentCount, signature.hasRestParameter, signature.hasStringLiterals); - result.target = signature; - result.mapper = mapper; - return result; - } - function instantiateSymbol(symbol, mapper) { - if (symbol.flags & 16777216) { - var links = getSymbolLinks(symbol); - symbol = links.target; - mapper = combineTypeMappers(links.mapper, mapper); - } - var result = createSymbol(16777216 | 67108864 | symbol.flags, symbol.name); - result.declarations = symbol.declarations; - result.parent = symbol.parent; - result.target = symbol; - result.mapper = mapper; - if (symbol.valueDeclaration) { - result.valueDeclaration = symbol.valueDeclaration; - } - return result; - } - function instantiateAnonymousType(type, mapper) { - if (mapper.instantiations) { - var cachedType = mapper.instantiations[type.id]; - if (cachedType) { - return cachedType; - } - } - else { - mapper.instantiations = []; - } - var result = createObjectType(65536 | 131072, type.symbol); - result.target = type; - result.mapper = mapper; - mapper.instantiations[type.id] = result; - return result; - } - function instantiateType(type, mapper) { - if (type && mapper !== identityMapper) { - if (type.flags & 512) { - return mapper(type); - } - if (type.flags & 65536) { - return type.symbol && type.symbol.flags & (16 | 8192 | 32 | 2048 | 4096) ? - instantiateAnonymousType(type, mapper) : type; - } - if (type.flags & 4096) { - return createTypeReference(type.target, instantiateList(type.typeArguments, mapper, instantiateType)); - } - if (type.flags & 8192) { - return createTupleType(instantiateList(type.elementTypes, mapper, instantiateType)); - } - if (type.flags & 16384) { - return getUnionType(instantiateList(type.types, mapper, instantiateType), true); - } - if (type.flags & 32768) { - return getIntersectionType(instantiateList(type.types, mapper, instantiateType)); - } - } - return type; - } - function isContextSensitive(node) { - ts.Debug.assert(node.kind !== 143 || ts.isObjectLiteralMethod(node)); - switch (node.kind) { - case 173: - case 174: - return isContextSensitiveFunctionLikeDeclaration(node); - case 165: - return ts.forEach(node.properties, isContextSensitive); - case 164: - return ts.forEach(node.elements, isContextSensitive); - case 182: - return isContextSensitive(node.whenTrue) || - isContextSensitive(node.whenFalse); - case 181: - return node.operatorToken.kind === 52 && - (isContextSensitive(node.left) || isContextSensitive(node.right)); - case 245: - return isContextSensitive(node.initializer); - case 143: - case 142: - return isContextSensitiveFunctionLikeDeclaration(node); - case 172: - return isContextSensitive(node.expression); - } - return false; - } - function isContextSensitiveFunctionLikeDeclaration(node) { - return !node.typeParameters && node.parameters.length && !ts.forEach(node.parameters, function (p) { return p.type; }); - } - function getTypeWithoutSignatures(type) { - if (type.flags & 80896) { - var resolved = resolveStructuredTypeMembers(type); - if (resolved.constructSignatures.length) { - var result = createObjectType(65536, type.symbol); - result.members = resolved.members; - result.properties = resolved.properties; - result.callSignatures = emptyArray; - result.constructSignatures = emptyArray; - type = result; - } - } - return type; - } - function isTypeIdenticalTo(source, target) { - return checkTypeRelatedTo(source, target, identityRelation, undefined); - } - function compareTypes(source, target) { - return checkTypeRelatedTo(source, target, identityRelation, undefined) ? -1 : 0; - } - function isTypeSubtypeOf(source, target) { - return checkTypeSubtypeOf(source, target, undefined); - } - function isTypeAssignableTo(source, target) { - return checkTypeAssignableTo(source, target, undefined); - } - function checkTypeSubtypeOf(source, target, errorNode, headMessage, containingMessageChain) { - return checkTypeRelatedTo(source, target, subtypeRelation, errorNode, headMessage, containingMessageChain); - } - function checkTypeAssignableTo(source, target, errorNode, headMessage, containingMessageChain) { - return checkTypeRelatedTo(source, target, assignableRelation, errorNode, headMessage, containingMessageChain); - } - function isSignatureAssignableTo(source, target) { - var sourceType = getOrCreateTypeFromSignature(source); - var targetType = getOrCreateTypeFromSignature(target); - return checkTypeRelatedTo(sourceType, targetType, assignableRelation, undefined); - } - function checkTypeRelatedTo(source, target, relation, errorNode, headMessage, containingMessageChain) { - var errorInfo; - var sourceStack; - var targetStack; - var maybeStack; - var expandingFlags; - var depth = 0; - var overflow = false; - var elaborateErrors = false; - ts.Debug.assert(relation !== identityRelation || !errorNode, "no error reporting in identity checking"); - var result = isRelatedTo(source, target, errorNode !== undefined, headMessage); - if (overflow) { - error(errorNode, ts.Diagnostics.Excessive_stack_depth_comparing_types_0_and_1, typeToString(source), typeToString(target)); - } - else if (errorInfo) { - if (errorInfo.next === undefined) { - errorInfo = undefined; - elaborateErrors = true; - isRelatedTo(source, target, errorNode !== undefined, headMessage); - } - if (containingMessageChain) { - errorInfo = ts.concatenateDiagnosticMessageChains(containingMessageChain, errorInfo); - } - diagnostics.add(ts.createDiagnosticForNodeFromMessageChain(errorNode, errorInfo)); - } - return result !== 0; - function reportError(message, arg0, arg1, arg2) { - errorInfo = ts.chainDiagnosticMessages(errorInfo, message, arg0, arg1, arg2); - } - function reportRelationError(message, source, target) { - var sourceType = typeToString(source); - var targetType = typeToString(target); - if (sourceType === targetType) { - sourceType = typeToString(source, undefined, 128); - targetType = typeToString(target, undefined, 128); - } - reportError(message || ts.Diagnostics.Type_0_is_not_assignable_to_type_1, sourceType, targetType); - } - function isRelatedTo(source, target, reportErrors, headMessage) { - var result; - if (source === target) - return -1; - if (relation === identityRelation) { - return isIdenticalTo(source, target); - } - if (isTypeAny(target)) - return -1; - if (source === undefinedType) - return -1; - if (source === nullType && target !== undefinedType) - return -1; - if (source.flags & 128 && target === numberType) - return -1; - if (source.flags & 256 && target === stringType) - return -1; - if (relation === assignableRelation) { - if (isTypeAny(source)) - return -1; - if (source === numberType && target.flags & 128) - return -1; - } - if (source.flags & 1048576) { - if (hasExcessProperties(source, target, reportErrors)) { - if (reportErrors) { - reportRelationError(headMessage, source, target); - } - return 0; - } - if (target.flags & 49152) { - source = getRegularTypeOfObjectLiteral(source); - } - } - var saveErrorInfo = errorInfo; - if (source.flags & 16384) { - if (result = eachTypeRelatedToType(source, target, reportErrors)) { - return result; - } - } - else if (target.flags & 32768) { - if (result = typeRelatedToEachType(source, target, reportErrors)) { - return result; - } - } - else { - if (source.flags & 32768) { - if (result = someTypeRelatedToType(source, target, reportErrors && !(target.flags & 16384))) { - return result; - } - } - if (target.flags & 16384) { - if (result = typeRelatedToSomeType(source, target, reportErrors)) { - return result; - } - } - } - if (source.flags & 512) { - var constraint = getConstraintOfTypeParameter(source); - if (!constraint || constraint.flags & 1) { - constraint = emptyObjectType; - } - var reportConstraintErrors = reportErrors && constraint !== emptyObjectType; - if (result = isRelatedTo(constraint, target, reportConstraintErrors)) { - errorInfo = saveErrorInfo; - return result; - } - } - else { - if (source.flags & 4096 && target.flags & 4096 && source.target === target.target) { - if (result = typeArgumentsRelatedTo(source, target, reportErrors)) { - return result; - } - } - var apparentType = getApparentType(source); - if (apparentType.flags & (80896 | 32768) && target.flags & 80896) { - var reportStructuralErrors = reportErrors && errorInfo === saveErrorInfo; - if (result = objectTypeRelatedTo(apparentType, source, target, reportStructuralErrors)) { - errorInfo = saveErrorInfo; - return result; - } - } - } - if (reportErrors) { - reportRelationError(headMessage, source, target); - } - return 0; - } - function isIdenticalTo(source, target) { - var result; - if (source.flags & 80896 && target.flags & 80896) { - if (source.flags & 4096 && target.flags & 4096 && source.target === target.target) { - if (result = typeArgumentsRelatedTo(source, target, false)) { - return result; - } - } - return objectTypeRelatedTo(source, source, target, false); - } - if (source.flags & 512 && target.flags & 512) { - return typeParameterIdenticalTo(source, target); - } - if (source.flags & 16384 && target.flags & 16384 || - source.flags & 32768 && target.flags & 32768) { - if (result = eachTypeRelatedToSomeType(source, target)) { - if (result &= eachTypeRelatedToSomeType(target, source)) { - return result; - } - } - } - return 0; - } - function isKnownProperty(type, name) { - if (type.flags & 80896) { - var resolved = resolveStructuredTypeMembers(type); - if (relation === assignableRelation && (type === globalObjectType || resolved.properties.length === 0) || - resolved.stringIndexType || resolved.numberIndexType || getPropertyOfType(type, name)) { - return true; - } - } - else if (type.flags & 49152) { - for (var _i = 0, _a = type.types; _i < _a.length; _i++) { - var t = _a[_i]; - if (isKnownProperty(t, name)) { - return true; - } - } - } - return false; - } - function hasExcessProperties(source, target, reportErrors) { - if (someConstituentTypeHasKind(target, 80896)) { - for (var _i = 0, _a = getPropertiesOfObjectType(source); _i < _a.length; _i++) { - var prop = _a[_i]; - if (!isKnownProperty(target, prop.name)) { - if (reportErrors) { - errorNode = prop.valueDeclaration; - reportError(ts.Diagnostics.Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1, symbolToString(prop), typeToString(target)); - } - return true; - } - } - } - return false; - } - function eachTypeRelatedToSomeType(source, target) { - var result = -1; - var sourceTypes = source.types; - for (var _i = 0; _i < sourceTypes.length; _i++) { - var sourceType = sourceTypes[_i]; - var related = typeRelatedToSomeType(sourceType, target, false); - if (!related) { - return 0; - } - result &= related; - } - return result; - } - function typeRelatedToSomeType(source, target, reportErrors) { - var targetTypes = target.types; - for (var i = 0, len = targetTypes.length; i < len; i++) { - var related = isRelatedTo(source, targetTypes[i], reportErrors && i === len - 1); - if (related) { - return related; - } - } - return 0; - } - function typeRelatedToEachType(source, target, reportErrors) { - var result = -1; - var targetTypes = target.types; - for (var _i = 0; _i < targetTypes.length; _i++) { - var targetType = targetTypes[_i]; - var related = isRelatedTo(source, targetType, reportErrors); - if (!related) { - return 0; - } - result &= related; - } - return result; - } - function someTypeRelatedToType(source, target, reportErrors) { - var sourceTypes = source.types; - for (var i = 0, len = sourceTypes.length; i < len; i++) { - var related = isRelatedTo(sourceTypes[i], target, reportErrors && i === len - 1); - if (related) { - return related; - } - } - return 0; - } - function eachTypeRelatedToType(source, target, reportErrors) { - var result = -1; - var sourceTypes = source.types; - for (var _i = 0; _i < sourceTypes.length; _i++) { - var sourceType = sourceTypes[_i]; - var related = isRelatedTo(sourceType, target, reportErrors); - if (!related) { - return 0; - } - result &= related; - } - return result; - } - function typeArgumentsRelatedTo(source, target, reportErrors) { - var sources = source.typeArguments || emptyArray; - var targets = target.typeArguments || emptyArray; - if (sources.length !== targets.length && relation === identityRelation) { - return 0; - } - var result = -1; - for (var i = 0; i < targets.length; i++) { - var related = isRelatedTo(sources[i], targets[i], reportErrors); - if (!related) { - return 0; - } - result &= related; - } - return result; - } - function typeParameterIdenticalTo(source, target) { - if (source.symbol.name !== target.symbol.name) { - return 0; - } - if (source.constraint === target.constraint) { - return -1; - } - if (source.constraint === noConstraintType || target.constraint === noConstraintType) { - return 0; - } - return isIdenticalTo(source.constraint, target.constraint); - } - function objectTypeRelatedTo(apparentSource, originalSource, target, reportErrors) { - if (overflow) { - return 0; - } - var id = relation !== identityRelation || apparentSource.id < target.id ? apparentSource.id + "," + target.id : target.id + "," + apparentSource.id; - var related = relation[id]; - if (related !== undefined) { - if (!elaborateErrors || (related === 3)) { - return related === 1 ? -1 : 0; - } - } - if (depth > 0) { - for (var i = 0; i < depth; i++) { - if (maybeStack[i][id]) { - return 1; - } - } - if (depth === 100) { - overflow = true; - return 0; - } - } - else { - sourceStack = []; - targetStack = []; - maybeStack = []; - expandingFlags = 0; - } - sourceStack[depth] = apparentSource; - targetStack[depth] = target; - maybeStack[depth] = {}; - maybeStack[depth][id] = 1; - depth++; - var saveExpandingFlags = expandingFlags; - if (!(expandingFlags & 1) && isDeeplyNestedGeneric(apparentSource, sourceStack, depth)) - expandingFlags |= 1; - if (!(expandingFlags & 2) && isDeeplyNestedGeneric(target, targetStack, depth)) - expandingFlags |= 2; - var result; - if (expandingFlags === 3) { - result = 1; - } - else { - result = propertiesRelatedTo(apparentSource, target, reportErrors); - if (result) { - result &= signaturesRelatedTo(apparentSource, target, 0, reportErrors); - if (result) { - result &= signaturesRelatedTo(apparentSource, target, 1, reportErrors); - if (result) { - result &= stringIndexTypesRelatedTo(apparentSource, originalSource, target, reportErrors); - if (result) { - result &= numberIndexTypesRelatedTo(apparentSource, originalSource, target, reportErrors); - } - } - } - } - } - expandingFlags = saveExpandingFlags; - depth--; - if (result) { - var maybeCache = maybeStack[depth]; - var destinationCache = (result === -1 || depth === 0) ? relation : maybeStack[depth - 1]; - ts.copyMap(maybeCache, destinationCache); - } - else { - relation[id] = reportErrors ? 3 : 2; - } - return result; - } - function propertiesRelatedTo(source, target, reportErrors) { - if (relation === identityRelation) { - return propertiesIdenticalTo(source, target); - } - var result = -1; - var properties = getPropertiesOfObjectType(target); - var requireOptionalProperties = relation === subtypeRelation && !(source.flags & 524288); - for (var _i = 0; _i < properties.length; _i++) { - var targetProp = properties[_i]; - var sourceProp = getPropertyOfType(source, targetProp.name); - if (sourceProp !== targetProp) { - if (!sourceProp) { - if (!(targetProp.flags & 536870912) || requireOptionalProperties) { - if (reportErrors) { - reportError(ts.Diagnostics.Property_0_is_missing_in_type_1, symbolToString(targetProp), typeToString(source)); - } - return 0; - } - } - else if (!(targetProp.flags & 134217728)) { - var sourcePropFlags = getDeclarationFlagsFromSymbol(sourceProp); - var targetPropFlags = getDeclarationFlagsFromSymbol(targetProp); - if (sourcePropFlags & 32 || targetPropFlags & 32) { - if (sourceProp.valueDeclaration !== targetProp.valueDeclaration) { - if (reportErrors) { - if (sourcePropFlags & 32 && targetPropFlags & 32) { - reportError(ts.Diagnostics.Types_have_separate_declarations_of_a_private_property_0, symbolToString(targetProp)); - } - else { - reportError(ts.Diagnostics.Property_0_is_private_in_type_1_but_not_in_type_2, symbolToString(targetProp), typeToString(sourcePropFlags & 32 ? source : target), typeToString(sourcePropFlags & 32 ? target : source)); - } - } - return 0; - } - } - else if (targetPropFlags & 64) { - var sourceDeclaredInClass = sourceProp.parent && sourceProp.parent.flags & 32; - var sourceClass = sourceDeclaredInClass ? getDeclaredTypeOfSymbol(sourceProp.parent) : undefined; - var targetClass = getDeclaredTypeOfSymbol(targetProp.parent); - if (!sourceClass || !hasBaseType(sourceClass, targetClass)) { - if (reportErrors) { - reportError(ts.Diagnostics.Property_0_is_protected_but_type_1_is_not_a_class_derived_from_2, symbolToString(targetProp), typeToString(sourceClass || source), typeToString(targetClass)); - } - return 0; - } - } - else if (sourcePropFlags & 64) { - if (reportErrors) { - reportError(ts.Diagnostics.Property_0_is_protected_in_type_1_but_public_in_type_2, symbolToString(targetProp), typeToString(source), typeToString(target)); - } - return 0; - } - var related = isRelatedTo(getTypeOfSymbol(sourceProp), getTypeOfSymbol(targetProp), reportErrors); - if (!related) { - if (reportErrors) { - reportError(ts.Diagnostics.Types_of_property_0_are_incompatible, symbolToString(targetProp)); - } - return 0; - } - result &= related; - if (sourceProp.flags & 536870912 && !(targetProp.flags & 536870912)) { - if (reportErrors) { - reportError(ts.Diagnostics.Property_0_is_optional_in_type_1_but_required_in_type_2, symbolToString(targetProp), typeToString(source), typeToString(target)); - } - return 0; - } - } - } - } - return result; - } - function propertiesIdenticalTo(source, target) { - if (!(source.flags & 80896 && target.flags & 80896)) { - return 0; - } - var sourceProperties = getPropertiesOfObjectType(source); - var targetProperties = getPropertiesOfObjectType(target); - if (sourceProperties.length !== targetProperties.length) { - return 0; - } - var result = -1; - for (var _i = 0; _i < sourceProperties.length; _i++) { - var sourceProp = sourceProperties[_i]; - var targetProp = getPropertyOfObjectType(target, sourceProp.name); - if (!targetProp) { - return 0; - } - var related = compareProperties(sourceProp, targetProp, isRelatedTo); - if (!related) { - return 0; - } - result &= related; - } - return result; - } - function signaturesRelatedTo(source, target, kind, reportErrors) { - if (relation === identityRelation) { - return signaturesIdenticalTo(source, target, kind); - } - if (target === anyFunctionType || source === anyFunctionType) { - return -1; - } - var sourceSignatures = getSignaturesOfType(source, kind); - var targetSignatures = getSignaturesOfType(target, kind); - var result = -1; - var saveErrorInfo = errorInfo; - if (kind === 1) { - var sourceSig = sourceSignatures[0]; - var targetSig = targetSignatures[0]; - result &= abstractSignatureRelatedTo(source, sourceSig, target, targetSig); - if (result !== -1) { - return result; - } - } - outer: for (var _i = 0; _i < targetSignatures.length; _i++) { - var t = targetSignatures[_i]; - if (!t.hasStringLiterals || target.flags & 262144) { - var localErrors = reportErrors; - var checkedAbstractAssignability = false; - for (var _a = 0; _a < sourceSignatures.length; _a++) { - var s = sourceSignatures[_a]; - if (!s.hasStringLiterals || source.flags & 262144) { - var related = signatureRelatedTo(s, t, localErrors); - if (related) { - result &= related; - errorInfo = saveErrorInfo; - continue outer; - } - localErrors = false; - } - } - return 0; - } - } - return result; - function abstractSignatureRelatedTo(source, sourceSig, target, targetSig) { - if (sourceSig && targetSig) { - var sourceDecl = source.symbol && getClassLikeDeclarationOfSymbol(source.symbol); - var targetDecl = target.symbol && getClassLikeDeclarationOfSymbol(target.symbol); - if (!sourceDecl) { - return -1; - } - var sourceErasedSignature = getErasedSignature(sourceSig); - var targetErasedSignature = getErasedSignature(targetSig); - var sourceReturnType = sourceErasedSignature && getReturnTypeOfSignature(sourceErasedSignature); - var targetReturnType = targetErasedSignature && getReturnTypeOfSignature(targetErasedSignature); - var sourceReturnDecl = sourceReturnType && sourceReturnType.symbol && getClassLikeDeclarationOfSymbol(sourceReturnType.symbol); - var targetReturnDecl = targetReturnType && targetReturnType.symbol && getClassLikeDeclarationOfSymbol(targetReturnType.symbol); - var sourceIsAbstract = sourceReturnDecl && sourceReturnDecl.flags & 256; - var targetIsAbstract = targetReturnDecl && targetReturnDecl.flags & 256; - if (sourceIsAbstract && !(targetIsAbstract && targetDecl)) { - if (reportErrors) { - reportError(ts.Diagnostics.Cannot_assign_an_abstract_constructor_type_to_a_non_abstract_constructor_type); - } - return 0; - } - } - return -1; - } - } - function signatureRelatedTo(source, target, reportErrors) { - if (source === target) { - return -1; - } - if (!target.hasRestParameter && source.minArgumentCount > target.parameters.length) { - return 0; - } - var sourceMax = source.parameters.length; - var targetMax = target.parameters.length; - var checkCount; - if (source.hasRestParameter && target.hasRestParameter) { - checkCount = sourceMax > targetMax ? sourceMax : targetMax; - sourceMax--; - targetMax--; - } - else if (source.hasRestParameter) { - sourceMax--; - checkCount = targetMax; - } - else if (target.hasRestParameter) { - targetMax--; - checkCount = sourceMax; - } - else { - checkCount = sourceMax < targetMax ? sourceMax : targetMax; - } - source = getErasedSignature(source); - target = getErasedSignature(target); - var result = -1; - for (var i = 0; i < checkCount; i++) { - var s = i < sourceMax ? getTypeOfSymbol(source.parameters[i]) : getRestTypeOfSignature(source); - var t = i < targetMax ? getTypeOfSymbol(target.parameters[i]) : getRestTypeOfSignature(target); - var saveErrorInfo = errorInfo; - var related = isRelatedTo(s, t, reportErrors); - if (!related) { - related = isRelatedTo(t, s, false); - if (!related) { - if (reportErrors) { - reportError(ts.Diagnostics.Types_of_parameters_0_and_1_are_incompatible, source.parameters[i < sourceMax ? i : sourceMax].name, target.parameters[i < targetMax ? i : targetMax].name); - } - return 0; - } - errorInfo = saveErrorInfo; - } - result &= related; - } - if (source.typePredicate && target.typePredicate) { - var hasDifferentParameterIndex = source.typePredicate.parameterIndex !== target.typePredicate.parameterIndex; - var hasDifferentTypes; - if (hasDifferentParameterIndex || - (hasDifferentTypes = !isTypeIdenticalTo(source.typePredicate.type, target.typePredicate.type))) { - if (reportErrors) { - var sourceParamText = source.typePredicate.parameterName; - var targetParamText = target.typePredicate.parameterName; - var sourceTypeText = typeToString(source.typePredicate.type); - var targetTypeText = typeToString(target.typePredicate.type); - if (hasDifferentParameterIndex) { - reportError(ts.Diagnostics.Parameter_0_is_not_in_the_same_position_as_parameter_1, sourceParamText, targetParamText); - } - else if (hasDifferentTypes) { - reportError(ts.Diagnostics.Type_0_is_not_assignable_to_type_1, sourceTypeText, targetTypeText); - } - reportError(ts.Diagnostics.Type_predicate_0_is_not_assignable_to_1, sourceParamText + " is " + sourceTypeText, targetParamText + " is " + targetTypeText); - } - return 0; - } - } - else if (!source.typePredicate && target.typePredicate) { - if (reportErrors) { - reportError(ts.Diagnostics.Signature_0_must_have_a_type_predicate, signatureToString(source)); - } - return 0; - } - var targetReturnType = getReturnTypeOfSignature(target); - if (targetReturnType === voidType) - return result; - var sourceReturnType = getReturnTypeOfSignature(source); - return result & isRelatedTo(sourceReturnType, targetReturnType, reportErrors); - } - function signaturesIdenticalTo(source, target, kind) { - var sourceSignatures = getSignaturesOfType(source, kind); - var targetSignatures = getSignaturesOfType(target, kind); - if (sourceSignatures.length !== targetSignatures.length) { - return 0; - } - var result = -1; - for (var i = 0, len = sourceSignatures.length; i < len; ++i) { - var related = compareSignatures(sourceSignatures[i], targetSignatures[i], false, false, isRelatedTo); - if (!related) { - return 0; - } - result &= related; - } - return result; - } - function stringIndexTypesRelatedTo(source, originalSource, target, reportErrors) { - if (relation === identityRelation) { - return indexTypesIdenticalTo(0, source, target); - } - var targetType = getIndexTypeOfType(target, 0); - if (targetType) { - if ((targetType.flags & 1) && !(originalSource.flags & 16777726)) { - return -1; - } - var sourceType = getIndexTypeOfType(source, 0); - if (!sourceType) { - if (reportErrors) { - reportError(ts.Diagnostics.Index_signature_is_missing_in_type_0, typeToString(source)); - } - return 0; - } - var related = isRelatedTo(sourceType, targetType, reportErrors); - if (!related) { - if (reportErrors) { - reportError(ts.Diagnostics.Index_signatures_are_incompatible); - } - return 0; - } - return related; - } - return -1; - } - function numberIndexTypesRelatedTo(source, originalSource, target, reportErrors) { - if (relation === identityRelation) { - return indexTypesIdenticalTo(1, source, target); - } - var targetType = getIndexTypeOfType(target, 1); - if (targetType) { - if ((targetType.flags & 1) && !(originalSource.flags & 16777726)) { - return -1; - } - var sourceStringType = getIndexTypeOfType(source, 0); - var sourceNumberType = getIndexTypeOfType(source, 1); - if (!(sourceStringType || sourceNumberType)) { - if (reportErrors) { - reportError(ts.Diagnostics.Index_signature_is_missing_in_type_0, typeToString(source)); - } - return 0; - } - var related; - if (sourceStringType && sourceNumberType) { - related = isRelatedTo(sourceStringType, targetType, false) || isRelatedTo(sourceNumberType, targetType, reportErrors); - } - else { - related = isRelatedTo(sourceStringType || sourceNumberType, targetType, reportErrors); - } - if (!related) { - if (reportErrors) { - reportError(ts.Diagnostics.Index_signatures_are_incompatible); - } - return 0; - } - return related; - } - return -1; - } - function indexTypesIdenticalTo(indexKind, source, target) { - var targetType = getIndexTypeOfType(target, indexKind); - var sourceType = getIndexTypeOfType(source, indexKind); - if (!sourceType && !targetType) { - return -1; - } - if (sourceType && targetType) { - return isRelatedTo(sourceType, targetType); - } - return 0; - } - } - function isDeeplyNestedGeneric(type, stack, depth) { - if (type.flags & (4096 | 131072) && depth >= 5) { - var symbol = type.symbol; - var count = 0; - for (var i = 0; i < depth; i++) { - var t = stack[i]; - if (t.flags & (4096 | 131072) && t.symbol === symbol) { - count++; - if (count >= 5) - return true; - } - } - } - return false; - } - function isPropertyIdenticalTo(sourceProp, targetProp) { - return compareProperties(sourceProp, targetProp, compareTypes) !== 0; - } - function compareProperties(sourceProp, targetProp, compareTypes) { - if (sourceProp === targetProp) { - return -1; - } - var sourcePropAccessibility = getDeclarationFlagsFromSymbol(sourceProp) & (32 | 64); - var targetPropAccessibility = getDeclarationFlagsFromSymbol(targetProp) & (32 | 64); - if (sourcePropAccessibility !== targetPropAccessibility) { - return 0; - } - if (sourcePropAccessibility) { - if (getTargetSymbol(sourceProp) !== getTargetSymbol(targetProp)) { - return 0; - } - } - else { - if ((sourceProp.flags & 536870912) !== (targetProp.flags & 536870912)) { - return 0; - } - } - return compareTypes(getTypeOfSymbol(sourceProp), getTypeOfSymbol(targetProp)); - } - function compareSignatures(source, target, partialMatch, ignoreReturnTypes, compareTypes) { - if (source === target) { - return -1; - } - if (source.parameters.length !== target.parameters.length || - source.minArgumentCount !== target.minArgumentCount || - source.hasRestParameter !== target.hasRestParameter) { - if (!partialMatch || - source.parameters.length < target.parameters.length && !source.hasRestParameter || - source.minArgumentCount > target.minArgumentCount) { - return 0; - } - } - var result = -1; - if (source.typeParameters && target.typeParameters) { - if (source.typeParameters.length !== target.typeParameters.length) { - return 0; - } - for (var i = 0, len = source.typeParameters.length; i < len; ++i) { - var related = compareTypes(source.typeParameters[i], target.typeParameters[i]); - if (!related) { - return 0; - } - result &= related; - } - } - else if (source.typeParameters || target.typeParameters) { - return 0; - } - source = getErasedSignature(source); - target = getErasedSignature(target); - var targetLen = target.parameters.length; - for (var i = 0; i < targetLen; i++) { - var s = isRestParameterIndex(source, i) ? getRestTypeOfSignature(source) : getTypeOfSymbol(source.parameters[i]); - var t = isRestParameterIndex(target, i) ? getRestTypeOfSignature(target) : getTypeOfSymbol(target.parameters[i]); - var related = compareTypes(s, t); - if (!related) { - return 0; - } - result &= related; - } - if (!ignoreReturnTypes) { - result &= compareTypes(getReturnTypeOfSignature(source), getReturnTypeOfSignature(target)); - } - return result; - } - function isRestParameterIndex(signature, parameterIndex) { - return signature.hasRestParameter && parameterIndex >= signature.parameters.length - 1; - } - function isSupertypeOfEach(candidate, types) { - for (var _i = 0; _i < types.length; _i++) { - var type = types[_i]; - if (candidate !== type && !isTypeSubtypeOf(type, candidate)) - return false; - } - return true; - } - function getCommonSupertype(types) { - return ts.forEach(types, function (t) { return isSupertypeOfEach(t, types) ? t : undefined; }); - } - function reportNoCommonSupertypeError(types, errorLocation, errorMessageChainHead) { - var bestSupertype; - var bestSupertypeDownfallType; - var bestSupertypeScore = 0; - for (var i = 0; i < types.length; i++) { - var score = 0; - var downfallType = undefined; - for (var j = 0; j < types.length; j++) { - if (isTypeSubtypeOf(types[j], types[i])) { - score++; - } - else if (!downfallType) { - downfallType = types[j]; - } - } - ts.Debug.assert(!!downfallType, "If there is no common supertype, each type should have a downfallType"); - if (score > bestSupertypeScore) { - bestSupertype = types[i]; - bestSupertypeDownfallType = downfallType; - bestSupertypeScore = score; - } - if (bestSupertypeScore === types.length - 1) { - break; - } - } - checkTypeSubtypeOf(bestSupertypeDownfallType, bestSupertype, errorLocation, ts.Diagnostics.Type_argument_candidate_1_is_not_a_valid_type_argument_because_it_is_not_a_supertype_of_candidate_0, errorMessageChainHead); - } - function isArrayType(type) { - return type.flags & 4096 && type.target === globalArrayType; - } - function isArrayLikeType(type) { - return !(type.flags & (32 | 64)) && isTypeAssignableTo(type, anyArrayType); - } - function isTupleLikeType(type) { - return !!getPropertyOfType(type, "0"); - } - function isTupleType(type) { - return !!(type.flags & 8192); - } - function getRegularTypeOfObjectLiteral(type) { - if (type.flags & 1048576) { - var regularType = type.regularType; - if (!regularType) { - regularType = createType(type.flags & ~1048576); - regularType.symbol = type.symbol; - regularType.members = type.members; - regularType.properties = type.properties; - regularType.callSignatures = type.callSignatures; - regularType.constructSignatures = type.constructSignatures; - regularType.stringIndexType = type.stringIndexType; - regularType.numberIndexType = type.numberIndexType; - type.regularType = regularType; - } - return regularType; - } - return type; - } - function getWidenedTypeOfObjectLiteral(type) { - var properties = getPropertiesOfObjectType(type); - var members = {}; - ts.forEach(properties, function (p) { - var propType = getTypeOfSymbol(p); - var widenedType = getWidenedType(propType); - if (propType !== widenedType) { - var symbol = createSymbol(p.flags | 67108864, p.name); - symbol.declarations = p.declarations; - symbol.parent = p.parent; - symbol.type = widenedType; - symbol.target = p; - if (p.valueDeclaration) - symbol.valueDeclaration = p.valueDeclaration; - p = symbol; - } - members[p.name] = p; - }); - var stringIndexType = getIndexTypeOfType(type, 0); - var numberIndexType = getIndexTypeOfType(type, 1); - if (stringIndexType) - stringIndexType = getWidenedType(stringIndexType); - if (numberIndexType) - numberIndexType = getWidenedType(numberIndexType); - return createAnonymousType(type.symbol, members, emptyArray, emptyArray, stringIndexType, numberIndexType); - } - function getWidenedType(type) { - if (type.flags & 6291456) { - if (type.flags & (32 | 64)) { - return anyType; - } - if (type.flags & 524288) { - return getWidenedTypeOfObjectLiteral(type); - } - if (type.flags & 16384) { - return getUnionType(ts.map(type.types, getWidenedType), true); - } - if (isArrayType(type)) { - return createArrayType(getWidenedType(type.typeArguments[0])); - } - if (isTupleType(type)) { - return createTupleType(ts.map(type.elementTypes, getWidenedType)); - } - } - return type; - } - function reportWideningErrorsInType(type) { - var errorReported = false; - if (type.flags & 16384) { - for (var _i = 0, _a = type.types; _i < _a.length; _i++) { - var t = _a[_i]; - if (reportWideningErrorsInType(t)) { - errorReported = true; - } - } - } - if (isArrayType(type)) { - return reportWideningErrorsInType(type.typeArguments[0]); - } - if (isTupleType(type)) { - for (var _b = 0, _c = type.elementTypes; _b < _c.length; _b++) { - var t = _c[_b]; - if (reportWideningErrorsInType(t)) { - errorReported = true; - } - } - } - if (type.flags & 524288) { - for (var _d = 0, _e = getPropertiesOfObjectType(type); _d < _e.length; _d++) { - var p = _e[_d]; - var t = getTypeOfSymbol(p); - if (t.flags & 2097152) { - if (!reportWideningErrorsInType(t)) { - error(p.valueDeclaration, ts.Diagnostics.Object_literal_s_property_0_implicitly_has_an_1_type, p.name, typeToString(getWidenedType(t))); - } - errorReported = true; - } - } - } - return errorReported; - } - function reportImplicitAnyError(declaration, type) { - var typeAsString = typeToString(getWidenedType(type)); - var diagnostic; - switch (declaration.kind) { - case 141: - case 140: - diagnostic = ts.Diagnostics.Member_0_implicitly_has_an_1_type; - break; - case 138: - diagnostic = declaration.dotDotDotToken ? - ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type : - ts.Diagnostics.Parameter_0_implicitly_has_an_1_type; - break; - case 213: - case 143: - case 142: - case 145: - case 146: - case 173: - case 174: - if (!declaration.name) { - error(declaration, ts.Diagnostics.Function_expression_which_lacks_return_type_annotation_implicitly_has_an_0_return_type, typeAsString); - return; - } - diagnostic = ts.Diagnostics._0_which_lacks_return_type_annotation_implicitly_has_an_1_return_type; - break; - default: - diagnostic = ts.Diagnostics.Variable_0_implicitly_has_an_1_type; - } - error(declaration, diagnostic, ts.declarationNameToString(declaration.name), typeAsString); - } - function reportErrorsFromWidening(declaration, type) { - if (produceDiagnostics && compilerOptions.noImplicitAny && type.flags & 2097152) { - if (!reportWideningErrorsInType(type)) { - reportImplicitAnyError(declaration, type); - } - } - } - function forEachMatchingParameterType(source, target, callback) { - var sourceMax = source.parameters.length; - var targetMax = target.parameters.length; - var count; - if (source.hasRestParameter && target.hasRestParameter) { - count = sourceMax > targetMax ? sourceMax : targetMax; - sourceMax--; - targetMax--; - } - else if (source.hasRestParameter) { - sourceMax--; - count = targetMax; - } - else if (target.hasRestParameter) { - targetMax--; - count = sourceMax; - } - else { - count = sourceMax < targetMax ? sourceMax : targetMax; - } - for (var i = 0; i < count; i++) { - var s = i < sourceMax ? getTypeOfSymbol(source.parameters[i]) : getRestTypeOfSignature(source); - var t = i < targetMax ? getTypeOfSymbol(target.parameters[i]) : getRestTypeOfSignature(target); - callback(s, t); - } - } - function createInferenceContext(typeParameters, inferUnionTypes) { - var inferences = []; - for (var _i = 0; _i < typeParameters.length; _i++) { - var unused = typeParameters[_i]; - inferences.push({ - primary: undefined, secondary: undefined, isFixed: false - }); - } - return { - typeParameters: typeParameters, - inferUnionTypes: inferUnionTypes, - inferences: inferences, - inferredTypes: new Array(typeParameters.length) - }; - } - function inferTypes(context, source, target) { - var sourceStack; - var targetStack; - var depth = 0; - var inferiority = 0; - inferFromTypes(source, target); - function isInProcess(source, target) { - for (var i = 0; i < depth; i++) { - if (source === sourceStack[i] && target === targetStack[i]) { - return true; - } - } - return false; - } - function inferFromTypes(source, target) { - if (target.flags & 512) { - if (source.flags & 8388608) { - return; - } - var typeParameters = context.typeParameters; - for (var i = 0; i < typeParameters.length; i++) { - if (target === typeParameters[i]) { - var inferences = context.inferences[i]; - if (!inferences.isFixed) { - var candidates = inferiority ? - inferences.secondary || (inferences.secondary = []) : - inferences.primary || (inferences.primary = []); - if (!ts.contains(candidates, source)) { - candidates.push(source); - } - } - return; - } - } - } - else if (source.flags & 4096 && target.flags & 4096 && source.target === target.target) { - var sourceTypes = source.typeArguments || emptyArray; - var targetTypes = target.typeArguments || emptyArray; - var count = sourceTypes.length < targetTypes.length ? sourceTypes.length : targetTypes.length; - for (var i = 0; i < count; i++) { - inferFromTypes(sourceTypes[i], targetTypes[i]); - } - } - else if (source.flags & 8192 && target.flags & 8192 && source.elementTypes.length === target.elementTypes.length) { - var sourceTypes = source.elementTypes; - var targetTypes = target.elementTypes; - for (var i = 0; i < sourceTypes.length; i++) { - inferFromTypes(sourceTypes[i], targetTypes[i]); - } - } - else if (target.flags & 49152) { - var targetTypes = target.types; - var typeParameterCount = 0; - var typeParameter; - for (var _i = 0; _i < targetTypes.length; _i++) { - var t = targetTypes[_i]; - if (t.flags & 512 && ts.contains(context.typeParameters, t)) { - typeParameter = t; - typeParameterCount++; - } - else { - inferFromTypes(source, t); - } - } - if (target.flags & 16384 && typeParameterCount === 1) { - inferiority++; - inferFromTypes(source, typeParameter); - inferiority--; - } - } - else if (source.flags & 49152) { - var sourceTypes = source.types; - for (var _a = 0; _a < sourceTypes.length; _a++) { - var sourceType = sourceTypes[_a]; - inferFromTypes(sourceType, target); - } - } - else { - source = getApparentType(source); - if (source.flags & 80896 && (target.flags & (4096 | 8192) || - (target.flags & 65536) && target.symbol && target.symbol.flags & (8192 | 2048 | 32))) { - if (isInProcess(source, target)) { - return; - } - if (isDeeplyNestedGeneric(source, sourceStack, depth) && isDeeplyNestedGeneric(target, targetStack, depth)) { - return; - } - if (depth === 0) { - sourceStack = []; - targetStack = []; - } - sourceStack[depth] = source; - targetStack[depth] = target; - depth++; - inferFromProperties(source, target); - inferFromSignatures(source, target, 0); - inferFromSignatures(source, target, 1); - inferFromIndexTypes(source, target, 0, 0); - inferFromIndexTypes(source, target, 1, 1); - inferFromIndexTypes(source, target, 0, 1); - depth--; - } - } - } - function inferFromProperties(source, target) { - var properties = getPropertiesOfObjectType(target); - for (var _i = 0; _i < properties.length; _i++) { - var targetProp = properties[_i]; - var sourceProp = getPropertyOfObjectType(source, targetProp.name); - if (sourceProp) { - inferFromTypes(getTypeOfSymbol(sourceProp), getTypeOfSymbol(targetProp)); - } - } - } - function inferFromSignatures(source, target, kind) { - var sourceSignatures = getSignaturesOfType(source, kind); - var targetSignatures = getSignaturesOfType(target, kind); - var sourceLen = sourceSignatures.length; - var targetLen = targetSignatures.length; - var len = sourceLen < targetLen ? sourceLen : targetLen; - for (var i = 0; i < len; i++) { - inferFromSignature(getErasedSignature(sourceSignatures[sourceLen - len + i]), getErasedSignature(targetSignatures[targetLen - len + i])); - } - } - function inferFromSignature(source, target) { - forEachMatchingParameterType(source, target, inferFromTypes); - if (source.typePredicate && target.typePredicate) { - if (target.typePredicate.parameterIndex === source.typePredicate.parameterIndex) { - inferFromTypes(source.typePredicate.type, target.typePredicate.type); - } - } - else { - inferFromTypes(getReturnTypeOfSignature(source), getReturnTypeOfSignature(target)); - } - } - function inferFromIndexTypes(source, target, sourceKind, targetKind) { - var targetIndexType = getIndexTypeOfType(target, targetKind); - if (targetIndexType) { - var sourceIndexType = getIndexTypeOfType(source, sourceKind); - if (sourceIndexType) { - inferFromTypes(sourceIndexType, targetIndexType); - } - } - } - } - function getInferenceCandidates(context, index) { - var inferences = context.inferences[index]; - return inferences.primary || inferences.secondary || emptyArray; - } - function getInferredType(context, index) { - var inferredType = context.inferredTypes[index]; - var inferenceSucceeded; - if (!inferredType) { - var inferences = getInferenceCandidates(context, index); - if (inferences.length) { - var unionOrSuperType = context.inferUnionTypes ? getUnionType(inferences) : getCommonSupertype(inferences); - inferredType = unionOrSuperType ? getWidenedType(unionOrSuperType) : unknownType; - inferenceSucceeded = !!unionOrSuperType; - } - else { - inferredType = emptyObjectType; - inferenceSucceeded = true; - } - if (inferenceSucceeded) { - var constraint = getConstraintOfTypeParameter(context.typeParameters[index]); - inferredType = constraint && !isTypeAssignableTo(inferredType, constraint) ? constraint : inferredType; - } - else if (context.failedTypeParameterIndex === undefined || context.failedTypeParameterIndex > index) { - context.failedTypeParameterIndex = index; - } - context.inferredTypes[index] = inferredType; - } - return inferredType; - } - function getInferredTypes(context) { - for (var i = 0; i < context.inferredTypes.length; i++) { - getInferredType(context, i); - } - return context.inferredTypes; - } - function hasAncestor(node, kind) { - return ts.getAncestor(node, kind) !== undefined; - } - function getResolvedSymbol(node) { - var links = getNodeLinks(node); - if (!links.resolvedSymbol) { - links.resolvedSymbol = (!ts.nodeIsMissing(node) && resolveName(node, node.text, 107455 | 1048576, ts.Diagnostics.Cannot_find_name_0, node)) || unknownSymbol; - } - return links.resolvedSymbol; - } - function isInTypeQuery(node) { - while (node) { - switch (node.kind) { - case 154: - return true; - case 69: - case 135: - node = node.parent; - continue; - default: - return false; - } - } - ts.Debug.fail("should not get here"); - } - function removeTypesFromUnionType(type, typeKind, isOfTypeKind, allowEmptyUnionResult) { - if (type.flags & 16384) { - var types = type.types; - if (ts.forEach(types, function (t) { return !!(t.flags & typeKind) === isOfTypeKind; })) { - var narrowedType = getUnionType(ts.filter(types, function (t) { return !(t.flags & typeKind) === isOfTypeKind; })); - if (allowEmptyUnionResult || narrowedType !== emptyObjectType) { - return narrowedType; - } - } - } - else if (allowEmptyUnionResult && !!(type.flags & typeKind) === isOfTypeKind) { - return getUnionType(emptyArray); - } - return type; - } - function hasInitializer(node) { - return !!(node.initializer || ts.isBindingPattern(node.parent) && hasInitializer(node.parent.parent)); - } - function isVariableAssignedWithin(symbol, node) { - var links = getNodeLinks(node); - if (links.assignmentChecks) { - var cachedResult = links.assignmentChecks[symbol.id]; - if (cachedResult !== undefined) { - return cachedResult; - } - } - else { - links.assignmentChecks = {}; - } - return links.assignmentChecks[symbol.id] = isAssignedIn(node); - function isAssignedInBinaryExpression(node) { - if (node.operatorToken.kind >= 56 && node.operatorToken.kind <= 68) { - var n = node.left; - while (n.kind === 172) { - n = n.expression; - } - if (n.kind === 69 && getResolvedSymbol(n) === symbol) { - return true; - } - } - return ts.forEachChild(node, isAssignedIn); - } - function isAssignedInVariableDeclaration(node) { - if (!ts.isBindingPattern(node.name) && getSymbolOfNode(node) === symbol && hasInitializer(node)) { - return true; - } - return ts.forEachChild(node, isAssignedIn); - } - function isAssignedIn(node) { - switch (node.kind) { - case 181: - return isAssignedInBinaryExpression(node); - case 211: - case 163: - return isAssignedInVariableDeclaration(node); - case 161: - case 162: - case 164: - case 165: - case 166: - case 167: - case 168: - case 169: - case 171: - case 189: - case 172: - case 179: - case 175: - case 178: - case 176: - case 177: - case 180: - case 184: - case 182: - case 185: - case 192: - case 193: - case 195: - case 196: - case 197: - case 198: - case 199: - case 200: - case 201: - case 204: - case 205: - case 206: - case 241: - case 242: - case 207: - case 208: - case 209: - case 244: - case 233: - case 234: - case 238: - case 239: - case 235: - case 240: - return ts.forEachChild(node, isAssignedIn); - } - return false; - } - } - function getNarrowedTypeOfSymbol(symbol, node) { - var type = getTypeOfSymbol(symbol); - if (node && symbol.flags & 3) { - if (isTypeAny(type) || type.flags & (80896 | 16384 | 512)) { - loop: while (node.parent) { - var child = node; - node = node.parent; - var narrowedType = type; - switch (node.kind) { - case 196: - if (child !== node.expression) { - narrowedType = narrowType(type, node.expression, child === node.thenStatement); - } - break; - case 182: - if (child !== node.condition) { - narrowedType = narrowType(type, node.condition, child === node.whenTrue); - } - break; - case 181: - if (child === node.right) { - if (node.operatorToken.kind === 51) { - narrowedType = narrowType(type, node.left, true); - } - else if (node.operatorToken.kind === 52) { - narrowedType = narrowType(type, node.left, false); - } - } - break; - case 248: - case 218: - case 213: - case 143: - case 142: - case 145: - case 146: - case 144: - break loop; - } - if (narrowedType !== type) { - if (isVariableAssignedWithin(symbol, node)) { - break; - } - type = narrowedType; - } - } - } - } - return type; - function narrowTypeByEquality(type, expr, assumeTrue) { - if (expr.left.kind !== 176 || expr.right.kind !== 9) { - return type; - } - var left = expr.left; - var right = expr.right; - if (left.expression.kind !== 69 || getResolvedSymbol(left.expression) !== symbol) { - return type; - } - var typeInfo = primitiveTypeInfo[right.text]; - if (expr.operatorToken.kind === 33) { - assumeTrue = !assumeTrue; - } - if (assumeTrue) { - if (!typeInfo) { - return removeTypesFromUnionType(type, 258 | 132 | 8 | 16777216, true, false); - } - if (isTypeSubtypeOf(typeInfo.type, type)) { - return typeInfo.type; - } - return removeTypesFromUnionType(type, typeInfo.flags, false, false); - } - else { - if (typeInfo) { - return removeTypesFromUnionType(type, typeInfo.flags, true, false); - } - return type; - } - } - function narrowTypeByAnd(type, expr, assumeTrue) { - if (assumeTrue) { - return narrowType(narrowType(type, expr.left, true), expr.right, true); - } - else { - return getUnionType([ - narrowType(type, expr.left, false), - narrowType(narrowType(type, expr.left, true), expr.right, false) - ]); - } - } - function narrowTypeByOr(type, expr, assumeTrue) { - if (assumeTrue) { - return getUnionType([ - narrowType(type, expr.left, true), - narrowType(narrowType(type, expr.left, false), expr.right, true) - ]); - } - else { - return narrowType(narrowType(type, expr.left, false), expr.right, false); - } - } - function narrowTypeByInstanceof(type, expr, assumeTrue) { - if (isTypeAny(type) || !assumeTrue || expr.left.kind !== 69 || getResolvedSymbol(expr.left) !== symbol) { - return type; - } - var rightType = checkExpression(expr.right); - if (!isTypeSubtypeOf(rightType, globalFunctionType)) { - return type; - } - var targetType; - var prototypeProperty = getPropertyOfType(rightType, "prototype"); - if (prototypeProperty) { - var prototypePropertyType = getTypeOfSymbol(prototypeProperty); - if (!isTypeAny(prototypePropertyType)) { - targetType = prototypePropertyType; - } - } - if (!targetType) { - var constructSignatures; - if (rightType.flags & 2048) { - constructSignatures = resolveDeclaredMembers(rightType).declaredConstructSignatures; - } - else if (rightType.flags & 65536) { - constructSignatures = getSignaturesOfType(rightType, 1); - } - if (constructSignatures && constructSignatures.length) { - targetType = getUnionType(ts.map(constructSignatures, function (signature) { return getReturnTypeOfSignature(getErasedSignature(signature)); })); - } - } - if (targetType) { - return getNarrowedType(type, targetType); - } - return type; - } - function getNarrowedType(originalType, narrowedTypeCandidate) { - if (originalType.flags & 16384) { - var assignableConstituents = ts.filter(originalType.types, function (t) { return isTypeAssignableTo(t, narrowedTypeCandidate); }); - if (assignableConstituents.length) { - return getUnionType(assignableConstituents); - } - } - if (isTypeAssignableTo(narrowedTypeCandidate, originalType)) { - return narrowedTypeCandidate; - } - return originalType; - } - function narrowTypeByTypePredicate(type, expr, assumeTrue) { - if (type.flags & 1) { - return type; - } - var signature = getResolvedSignature(expr); - if (signature.typePredicate && - expr.arguments[signature.typePredicate.parameterIndex] && - getSymbolAtLocation(expr.arguments[signature.typePredicate.parameterIndex]) === symbol) { - if (!assumeTrue) { - if (type.flags & 16384) { - return getUnionType(ts.filter(type.types, function (t) { return !isTypeSubtypeOf(t, signature.typePredicate.type); })); - } - return type; - } - return getNarrowedType(type, signature.typePredicate.type); - } - return type; - } - function narrowType(type, expr, assumeTrue) { - switch (expr.kind) { - case 168: - return narrowTypeByTypePredicate(type, expr, assumeTrue); - case 172: - return narrowType(type, expr.expression, assumeTrue); - case 181: - var operator = expr.operatorToken.kind; - if (operator === 32 || operator === 33) { - return narrowTypeByEquality(type, expr, assumeTrue); - } - else if (operator === 51) { - return narrowTypeByAnd(type, expr, assumeTrue); - } - else if (operator === 52) { - return narrowTypeByOr(type, expr, assumeTrue); - } - else if (operator === 91) { - return narrowTypeByInstanceof(type, expr, assumeTrue); - } - break; - case 179: - if (expr.operator === 49) { - return narrowType(type, expr.operand, !assumeTrue); - } - break; - } - return type; - } - } - function checkIdentifier(node) { - var symbol = getResolvedSymbol(node); - if (symbol === argumentsSymbol) { - var container = ts.getContainingFunction(node); - if (container.kind === 174) { - if (languageVersion < 2) { - error(node, ts.Diagnostics.The_arguments_object_cannot_be_referenced_in_an_arrow_function_in_ES3_and_ES5_Consider_using_a_standard_function_expression); - } - } - if (node.parserContextFlags & 8) { - getNodeLinks(container).flags |= 4096; - getNodeLinks(node).flags |= 2048; - } - } - if (symbol.flags & 8388608 && !isInTypeQuery(node) && !isConstEnumOrConstEnumOnlyModule(resolveAlias(symbol))) { - markAliasSymbolAsReferenced(symbol); - } - checkCollisionWithCapturedSuperVariable(node, node); - checkCollisionWithCapturedThisVariable(node, node); - checkBlockScopedBindingCapturedInLoop(node, symbol); - return getNarrowedTypeOfSymbol(getExportSymbolOfValueSymbolIfExported(symbol), node); - } - function isInsideFunction(node, threshold) { - var current = node; - while (current && current !== threshold) { - if (ts.isFunctionLike(current)) { - return true; - } - current = current.parent; - } - return false; - } - function checkBlockScopedBindingCapturedInLoop(node, symbol) { - if (languageVersion >= 2 || - (symbol.flags & 2) === 0 || - symbol.valueDeclaration.parent.kind === 244) { - return; - } - var container = symbol.valueDeclaration; - while (container.kind !== 212) { - container = container.parent; - } - container = container.parent; - if (container.kind === 193) { - container = container.parent; - } - var inFunction = isInsideFunction(node.parent, container); - var current = container; - while (current && !ts.nodeStartsNewLexicalEnvironment(current)) { - if (isIterationStatement(current, false)) { - if (inFunction) { - grammarErrorOnFirstToken(current, ts.Diagnostics.Loop_contains_block_scoped_variable_0_referenced_by_a_function_in_the_loop_This_is_only_supported_in_ECMAScript_6_or_higher, ts.declarationNameToString(node)); - } - getNodeLinks(symbol.valueDeclaration).flags |= 16384; - break; - } - current = current.parent; - } - } - function captureLexicalThis(node, container) { - getNodeLinks(node).flags |= 2; - if (container.kind === 141 || container.kind === 144) { - var classNode = container.parent; - getNodeLinks(classNode).flags |= 4; - } - else { - getNodeLinks(container).flags |= 4; - } - } - function checkThisExpression(node) { - var container = ts.getThisContainer(node, true); - var needToCaptureLexicalThis = false; - if (container.kind === 174) { - container = ts.getThisContainer(container, false); - needToCaptureLexicalThis = (languageVersion < 2); - } - switch (container.kind) { - case 218: - error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_module_or_namespace_body); - break; - case 217: - error(node, ts.Diagnostics.this_cannot_be_referenced_in_current_location); - break; - case 144: - if (isInConstructorArgumentInitializer(node, container)) { - error(node, ts.Diagnostics.this_cannot_be_referenced_in_constructor_arguments); - } - break; - case 141: - case 140: - if (container.flags & 128) { - error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_static_property_initializer); - } - break; - case 136: - error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_computed_property_name); - break; - } - if (needToCaptureLexicalThis) { - captureLexicalThis(node, container); - } - if (ts.isClassLike(container.parent)) { - var symbol = getSymbolOfNode(container.parent); - return container.flags & 128 ? getTypeOfSymbol(symbol) : getDeclaredTypeOfSymbol(symbol).thisType; - } - return anyType; - } - function isInConstructorArgumentInitializer(node, constructorDecl) { - for (var n = node; n && n !== constructorDecl; n = n.parent) { - if (n.kind === 138) { - return true; - } - } - return false; - } - function checkSuperExpression(node) { - var isCallExpression = node.parent.kind === 168 && node.parent.expression === node; - var classDeclaration = ts.getContainingClass(node); - var classType = classDeclaration && getDeclaredTypeOfSymbol(getSymbolOfNode(classDeclaration)); - var baseClassType = classType && getBaseTypes(classType)[0]; - var container = ts.getSuperContainer(node, true); - var needToCaptureLexicalThis = false; - if (!isCallExpression) { - while (container && container.kind === 174) { - container = ts.getSuperContainer(container, true); - needToCaptureLexicalThis = languageVersion < 2; - } - } - var canUseSuperExpression = isLegalUsageOfSuperExpression(container); - var nodeCheckFlag = 0; - if (canUseSuperExpression) { - if ((container.flags & 128) || isCallExpression) { - nodeCheckFlag = 512; - } - else { - nodeCheckFlag = 256; - } - getNodeLinks(node).flags |= nodeCheckFlag; - if (needToCaptureLexicalThis) { - captureLexicalThis(node.parent, container); - } - } - if (!baseClassType) { - if (!classDeclaration || !ts.getClassExtendsHeritageClauseElement(classDeclaration)) { - error(node, ts.Diagnostics.super_can_only_be_referenced_in_a_derived_class); - } - return unknownType; - } - if (!canUseSuperExpression) { - if (container && container.kind === 136) { - 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 { - error(node, ts.Diagnostics.super_property_access_is_permitted_only_in_a_constructor_member_function_or_member_accessor_of_a_derived_class); - } - return unknownType; - } - if (container.kind === 144 && isInConstructorArgumentInitializer(node, container)) { - error(node, ts.Diagnostics.super_cannot_be_referenced_in_constructor_arguments); - return unknownType; - } - return nodeCheckFlag === 512 - ? getBaseConstructorTypeOfClass(classType) - : baseClassType; - function isLegalUsageOfSuperExpression(container) { - if (!container) { - return false; - } - if (isCallExpression) { - return container.kind === 144; - } - else { - if (container && ts.isClassLike(container.parent)) { - if (container.flags & 128) { - return container.kind === 143 || - container.kind === 142 || - container.kind === 145 || - container.kind === 146; - } - else { - return container.kind === 143 || - container.kind === 142 || - container.kind === 145 || - container.kind === 146 || - container.kind === 141 || - container.kind === 140 || - container.kind === 144; - } - } - } - return false; - } - } - function getContextuallyTypedParameterType(parameter) { - var func = parameter.parent; - if (isFunctionExpressionOrArrowFunction(func) || ts.isObjectLiteralMethod(func)) { - if (isContextSensitive(func)) { - var contextualSignature = getContextualSignature(func); - if (contextualSignature) { - var funcHasRestParameters = ts.hasRestParameter(func); - var len = func.parameters.length - (funcHasRestParameters ? 1 : 0); - var indexOfParameter = ts.indexOf(func.parameters, parameter); - if (indexOfParameter < len) { - return getTypeAtPosition(contextualSignature, indexOfParameter); - } - if (funcHasRestParameters && - indexOfParameter === (func.parameters.length - 1) && - isRestParameterIndex(contextualSignature, func.parameters.length - 1)) { - return getTypeOfSymbol(ts.lastOrUndefined(contextualSignature.parameters)); - } - } - } - } - return undefined; - } - function getContextualTypeForInitializerExpression(node) { - var declaration = node.parent; - if (node === declaration.initializer) { - if (declaration.type) { - return getTypeFromTypeNode(declaration.type); - } - if (declaration.kind === 138) { - var type = getContextuallyTypedParameterType(declaration); - if (type) { - return type; - } - } - if (ts.isBindingPattern(declaration.name)) { - return getTypeFromBindingPattern(declaration.name, true); - } - } - return undefined; - } - function getContextualTypeForReturnExpression(node) { - var func = ts.getContainingFunction(node); - if (func && !func.asteriskToken) { - return getContextualReturnType(func); - } - return undefined; - } - function getContextualTypeForYieldOperand(node) { - var func = ts.getContainingFunction(node); - if (func) { - var contextualReturnType = getContextualReturnType(func); - if (contextualReturnType) { - return node.asteriskToken - ? contextualReturnType - : getElementTypeOfIterableIterator(contextualReturnType); - } - } - return undefined; - } - function isInParameterInitializerBeforeContainingFunction(node) { - while (node.parent && !ts.isFunctionLike(node.parent)) { - if (node.parent.kind === 138 && node.parent.initializer === node) { - return true; - } - node = node.parent; - } - return false; - } - function getContextualReturnType(functionDecl) { - if (functionDecl.type || - functionDecl.kind === 144 || - functionDecl.kind === 145 && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(functionDecl.symbol, 146))) { - return getReturnTypeOfSignature(getSignatureFromDeclaration(functionDecl)); - } - var signature = getContextualSignatureForFunctionLikeDeclaration(functionDecl); - if (signature) { - return getReturnTypeOfSignature(signature); - } - return undefined; - } - function getContextualTypeForArgument(callTarget, arg) { - var args = getEffectiveCallArguments(callTarget); - var argIndex = ts.indexOf(args, arg); - if (argIndex >= 0) { - var signature = getResolvedSignature(callTarget); - return getTypeAtPosition(signature, argIndex); - } - return undefined; - } - function getContextualTypeForSubstitutionExpression(template, substitutionExpression) { - if (template.parent.kind === 170) { - return getContextualTypeForArgument(template.parent, substitutionExpression); - } - return undefined; - } - function getContextualTypeForBinaryOperand(node) { - var binaryExpression = node.parent; - var operator = binaryExpression.operatorToken.kind; - if (operator >= 56 && operator <= 68) { - if (node === binaryExpression.right) { - return checkExpression(binaryExpression.left); - } - } - else if (operator === 52) { - var type = getContextualType(binaryExpression); - if (!type && node === binaryExpression.right) { - type = checkExpression(binaryExpression.left); - } - return type; - } - return undefined; - } - function applyToContextualType(type, mapper) { - if (!(type.flags & 16384)) { - return mapper(type); - } - var types = type.types; - var mappedType; - var mappedTypes; - for (var _i = 0; _i < types.length; _i++) { - var current = types[_i]; - var t = mapper(current); - if (t) { - if (!mappedType) { - mappedType = t; - } - else if (!mappedTypes) { - mappedTypes = [mappedType, t]; - } - else { - mappedTypes.push(t); - } - } - } - return mappedTypes ? getUnionType(mappedTypes) : mappedType; - } - function getTypeOfPropertyOfContextualType(type, name) { - return applyToContextualType(type, function (t) { - var prop = t.flags & 130048 ? getPropertyOfType(t, name) : undefined; - return prop ? getTypeOfSymbol(prop) : undefined; - }); - } - function getIndexTypeOfContextualType(type, kind) { - return applyToContextualType(type, function (t) { return getIndexTypeOfStructuredType(t, kind); }); - } - function contextualTypeIsTupleLikeType(type) { - return !!(type.flags & 16384 ? ts.forEach(type.types, isTupleLikeType) : isTupleLikeType(type)); - } - function contextualTypeHasIndexSignature(type, kind) { - return !!(type.flags & 16384 ? ts.forEach(type.types, function (t) { return getIndexTypeOfStructuredType(t, kind); }) : getIndexTypeOfStructuredType(type, kind)); - } - function getContextualTypeForObjectLiteralMethod(node) { - ts.Debug.assert(ts.isObjectLiteralMethod(node)); - if (isInsideWithStatementBody(node)) { - return undefined; - } - return getContextualTypeForObjectLiteralElement(node); - } - function getContextualTypeForObjectLiteralElement(element) { - var objectLiteral = element.parent; - var type = getContextualType(objectLiteral); - if (type) { - if (!ts.hasDynamicName(element)) { - var symbolName = getSymbolOfNode(element).name; - var propertyType = getTypeOfPropertyOfContextualType(type, symbolName); - if (propertyType) { - return propertyType; - } - } - return isNumericName(element.name) && getIndexTypeOfContextualType(type, 1) || - getIndexTypeOfContextualType(type, 0); - } - return undefined; - } - function getContextualTypeForElementExpression(node) { - var arrayLiteral = node.parent; - var type = getContextualType(arrayLiteral); - if (type) { - var index = ts.indexOf(arrayLiteral.elements, node); - return getTypeOfPropertyOfContextualType(type, "" + index) - || getIndexTypeOfContextualType(type, 1) - || (languageVersion >= 2 ? getElementTypeOfIterable(type, undefined) : undefined); - } - return undefined; - } - function getContextualTypeForConditionalOperand(node) { - var conditional = node.parent; - return node === conditional.whenTrue || node === conditional.whenFalse ? getContextualType(conditional) : undefined; - } - function getContextualTypeForJsxExpression(expr) { - if (expr.parent.kind === 238) { - var attrib = expr.parent; - var attrsType = getJsxElementAttributesType(attrib.parent); - if (!attrsType || isTypeAny(attrsType)) { - return undefined; - } - else { - return getTypeOfPropertyOfType(attrsType, attrib.name.text); - } - } - if (expr.kind === 239) { - return getJsxElementAttributesType(expr.parent); - } - return undefined; - } - function getContextualType(node) { - var type = getContextualTypeWorker(node); - return type && getApparentType(type); - } - function getContextualTypeWorker(node) { - if (isInsideWithStatementBody(node)) { - return undefined; - } - if (node.contextualType) { - return node.contextualType; - } - var parent = node.parent; - switch (parent.kind) { - case 211: - case 138: - case 141: - case 140: - case 163: - return getContextualTypeForInitializerExpression(node); - case 174: - case 204: - return getContextualTypeForReturnExpression(node); - case 184: - return getContextualTypeForYieldOperand(parent); - case 168: - case 169: - return getContextualTypeForArgument(parent, node); - case 171: - case 189: - return getTypeFromTypeNode(parent.type); - case 181: - return getContextualTypeForBinaryOperand(node); - case 245: - return getContextualTypeForObjectLiteralElement(parent); - case 164: - return getContextualTypeForElementExpression(node); - case 182: - return getContextualTypeForConditionalOperand(node); - case 190: - ts.Debug.assert(parent.parent.kind === 183); - return getContextualTypeForSubstitutionExpression(parent.parent, node); - case 172: - return getContextualType(parent); - case 240: - case 239: - return getContextualTypeForJsxExpression(parent); - } - return undefined; - } - function getNonGenericSignature(type) { - var signatures = getSignaturesOfStructuredType(type, 0); - if (signatures.length === 1) { - var signature = signatures[0]; - if (!signature.typeParameters) { - return signature; - } - } - } - function isFunctionExpressionOrArrowFunction(node) { - return node.kind === 173 || node.kind === 174; - } - function getContextualSignatureForFunctionLikeDeclaration(node) { - return isFunctionExpressionOrArrowFunction(node) || ts.isObjectLiteralMethod(node) - ? getContextualSignature(node) - : undefined; - } - function getContextualSignature(node) { - ts.Debug.assert(node.kind !== 143 || ts.isObjectLiteralMethod(node)); - var type = ts.isObjectLiteralMethod(node) - ? getContextualTypeForObjectLiteralMethod(node) - : getContextualType(node); - if (!type) { - return undefined; - } - if (!(type.flags & 16384)) { - return getNonGenericSignature(type); - } - var signatureList; - var types = type.types; - for (var _i = 0; _i < types.length; _i++) { - var current = types[_i]; - var signature = getNonGenericSignature(current); - if (signature) { - if (!signatureList) { - signatureList = [signature]; - } - else if (!compareSignatures(signatureList[0], signature, false, true, compareTypes)) { - return undefined; - } - else { - signatureList.push(signature); - } - } - } - var result; - if (signatureList) { - result = cloneSignature(signatureList[0]); - result.resolvedReturnType = undefined; - result.unionSignatures = signatureList; - } - return result; - } - function isInferentialContext(mapper) { - return mapper && mapper.context; - } - function isAssignmentTarget(node) { - var parent = node.parent; - if (parent.kind === 181 && parent.operatorToken.kind === 56 && parent.left === node) { - return true; - } - if (parent.kind === 245) { - return isAssignmentTarget(parent.parent); - } - if (parent.kind === 164) { - return isAssignmentTarget(parent); - } - return false; - } - function checkSpreadElementExpression(node, contextualMapper) { - var arrayOrIterableType = checkExpressionCached(node.expression, contextualMapper); - return checkIteratedTypeOrElementType(arrayOrIterableType, node.expression, false); - } - function hasDefaultValue(node) { - return (node.kind === 163 && !!node.initializer) || - (node.kind === 181 && node.operatorToken.kind === 56); - } - function checkArrayLiteral(node, contextualMapper) { - var elements = node.elements; - var hasSpreadElement = false; - var elementTypes = []; - var inDestructuringPattern = isAssignmentTarget(node); - for (var _i = 0; _i < elements.length; _i++) { - var e = elements[_i]; - if (inDestructuringPattern && e.kind === 185) { - var restArrayType = checkExpression(e.expression, contextualMapper); - var restElementType = getIndexTypeOfType(restArrayType, 1) || - (languageVersion >= 2 ? getElementTypeOfIterable(restArrayType, undefined) : undefined); - if (restElementType) { - elementTypes.push(restElementType); - } - } - else { - var type = checkExpression(e, contextualMapper); - elementTypes.push(type); - } - hasSpreadElement = hasSpreadElement || e.kind === 185; - } - if (!hasSpreadElement) { - if (inDestructuringPattern && elementTypes.length) { - var type = createNewTupleType(elementTypes); - type.pattern = node; - return type; - } - var contextualType = getContextualType(node); - if (contextualType && contextualTypeIsTupleLikeType(contextualType)) { - var pattern = contextualType.pattern; - if (pattern && (pattern.kind === 162 || pattern.kind === 164)) { - var patternElements = pattern.elements; - for (var i = elementTypes.length; i < patternElements.length; i++) { - var patternElement = patternElements[i]; - if (hasDefaultValue(patternElement)) { - elementTypes.push(contextualType.elementTypes[i]); - } - else { - if (patternElement.kind !== 187) { - error(patternElement, ts.Diagnostics.Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value); - } - elementTypes.push(unknownType); - } - } - } - if (elementTypes.length) { - return createTupleType(elementTypes); - } - } - } - return createArrayType(elementTypes.length ? getUnionType(elementTypes) : undefinedType); - } - function isNumericName(name) { - return name.kind === 136 ? isNumericComputedName(name) : isNumericLiteralName(name.text); - } - function isNumericComputedName(name) { - return isTypeAnyOrAllConstituentTypesHaveKind(checkComputedPropertyName(name), 132); - } - function isTypeAnyOrAllConstituentTypesHaveKind(type, kind) { - return isTypeAny(type) || allConstituentTypesHaveKind(type, kind); - } - function isNumericLiteralName(name) { - return (+name).toString() === name; - } - function checkComputedPropertyName(node) { - var links = getNodeLinks(node.expression); - if (!links.resolvedType) { - links.resolvedType = checkExpression(node.expression); - if (!isTypeAnyOrAllConstituentTypesHaveKind(links.resolvedType, 132 | 258 | 16777216)) { - error(node, ts.Diagnostics.A_computed_property_name_must_be_of_type_string_number_symbol_or_any); - } - else { - checkThatExpressionIsProperSymbolReference(node.expression, links.resolvedType, true); - } - } - return links.resolvedType; - } - function checkObjectLiteral(node, contextualMapper) { - var inDestructuringPattern = isAssignmentTarget(node); - checkGrammarObjectLiteralExpression(node, inDestructuringPattern); - var propertiesTable = {}; - var propertiesArray = []; - var contextualType = getContextualType(node); - var contextualTypeHasPattern = contextualType && contextualType.pattern && - (contextualType.pattern.kind === 161 || contextualType.pattern.kind === 165); - var typeFlags = 0; - for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { - var memberDecl = _a[_i]; - var member = memberDecl.symbol; - if (memberDecl.kind === 245 || - memberDecl.kind === 246 || - ts.isObjectLiteralMethod(memberDecl)) { - var type = void 0; - if (memberDecl.kind === 245) { - type = checkPropertyAssignment(memberDecl, contextualMapper); - } - else if (memberDecl.kind === 143) { - type = checkObjectLiteralMethod(memberDecl, contextualMapper); - } - else { - ts.Debug.assert(memberDecl.kind === 246); - type = checkExpression(memberDecl.name, contextualMapper); - } - typeFlags |= type.flags; - var prop = createSymbol(4 | 67108864 | member.flags, member.name); - if (inDestructuringPattern) { - var isOptional = (memberDecl.kind === 245 && hasDefaultValue(memberDecl.initializer)) || - (memberDecl.kind === 246 && memberDecl.objectAssignmentInitializer); - if (isOptional) { - prop.flags |= 536870912; - } - } - else if (contextualTypeHasPattern) { - var impliedProp = getPropertyOfType(contextualType, member.name); - if (impliedProp) { - prop.flags |= impliedProp.flags & 536870912; - } - else if (!compilerOptions.suppressExcessPropertyErrors) { - error(memberDecl.name, ts.Diagnostics.Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1, symbolToString(member), typeToString(contextualType)); - } - } - prop.declarations = member.declarations; - prop.parent = member.parent; - if (member.valueDeclaration) { - prop.valueDeclaration = member.valueDeclaration; - } - prop.type = type; - prop.target = member; - member = prop; - } - else { - ts.Debug.assert(memberDecl.kind === 145 || memberDecl.kind === 146); - checkAccessorDeclaration(memberDecl); - } - if (!ts.hasDynamicName(memberDecl)) { - propertiesTable[member.name] = member; - } - propertiesArray.push(member); - } - if (contextualTypeHasPattern) { - for (var _b = 0, _c = getPropertiesOfType(contextualType); _b < _c.length; _b++) { - var prop = _c[_b]; - if (!ts.hasProperty(propertiesTable, prop.name)) { - if (!(prop.flags & 536870912)) { - error(prop.valueDeclaration || prop.bindingElement, ts.Diagnostics.Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value); - } - propertiesTable[prop.name] = prop; - propertiesArray.push(prop); - } - } - } - var stringIndexType = getIndexType(0); - var numberIndexType = getIndexType(1); - var result = createAnonymousType(node.symbol, propertiesTable, emptyArray, emptyArray, stringIndexType, numberIndexType); - var freshObjectLiteralFlag = compilerOptions.suppressExcessPropertyErrors ? 0 : 1048576; - result.flags |= 524288 | 4194304 | freshObjectLiteralFlag | (typeFlags & 14680064); - if (inDestructuringPattern) { - result.pattern = node; - } - return result; - function getIndexType(kind) { - if (contextualType && contextualTypeHasIndexSignature(contextualType, kind)) { - var propTypes = []; - for (var i = 0; i < propertiesArray.length; i++) { - var propertyDecl = node.properties[i]; - if (kind === 0 || isNumericName(propertyDecl.name)) { - var type = getTypeOfSymbol(propertiesArray[i]); - if (!ts.contains(propTypes, type)) { - propTypes.push(type); - } - } - } - var result_1 = propTypes.length ? getUnionType(propTypes) : undefinedType; - typeFlags |= result_1.flags; - return result_1; - } - return undefined; - } - } - function checkJsxSelfClosingElement(node) { - checkJsxOpeningLikeElement(node); - return jsxElementType || anyType; - } - function tagNamesAreEquivalent(lhs, rhs) { - if (lhs.kind !== rhs.kind) { - return false; - } - if (lhs.kind === 69) { - return lhs.text === rhs.text; - } - return lhs.right.text === rhs.right.text && - tagNamesAreEquivalent(lhs.left, rhs.left); - } - function checkJsxElement(node) { - checkJsxOpeningLikeElement(node.openingElement); - if (!tagNamesAreEquivalent(node.openingElement.tagName, node.closingElement.tagName)) { - error(node.closingElement, ts.Diagnostics.Expected_corresponding_JSX_closing_tag_for_0, ts.getTextOfNode(node.openingElement.tagName)); - } - else { - getJsxElementTagSymbol(node.closingElement); - } - for (var _i = 0, _a = node.children; _i < _a.length; _i++) { - var child = _a[_i]; - switch (child.kind) { - case 240: - checkJsxExpression(child); - break; - case 233: - checkJsxElement(child); - break; - case 234: - checkJsxSelfClosingElement(child); - break; - } - } - return jsxElementType || anyType; - } - function isUnhyphenatedJsxName(name) { - return name.indexOf("-") < 0; - } - function isJsxIntrinsicIdentifier(tagName) { - if (tagName.kind === 135) { - return false; - } - else { - return ts.isIntrinsicJsxName(tagName.text); - } - } - function checkJsxAttribute(node, elementAttributesType, nameTable) { - var correspondingPropType = undefined; - if (elementAttributesType === emptyObjectType && isUnhyphenatedJsxName(node.name.text)) { - error(node.parent, ts.Diagnostics.JSX_element_class_does_not_support_attributes_because_it_does_not_have_a_0_property, getJsxElementPropertiesName()); - } - else if (elementAttributesType && !isTypeAny(elementAttributesType)) { - var correspondingPropSymbol = getPropertyOfType(elementAttributesType, node.name.text); - correspondingPropType = correspondingPropSymbol && getTypeOfSymbol(correspondingPropSymbol); - if (isUnhyphenatedJsxName(node.name.text)) { - var indexerType = getIndexTypeOfType(elementAttributesType, 0); - if (indexerType) { - correspondingPropType = indexerType; - } - else { - if (!correspondingPropType) { - error(node.name, ts.Diagnostics.Property_0_does_not_exist_on_type_1, node.name.text, typeToString(elementAttributesType)); - return unknownType; - } - } - } - } - var exprType; - if (node.initializer) { - exprType = checkExpression(node.initializer); - } - else { - exprType = booleanType; - } - if (correspondingPropType) { - checkTypeAssignableTo(exprType, correspondingPropType, node); - } - nameTable[node.name.text] = true; - return exprType; - } - function checkJsxSpreadAttribute(node, elementAttributesType, nameTable) { - var type = checkExpression(node.expression); - var props = getPropertiesOfType(type); - for (var _i = 0; _i < props.length; _i++) { - var prop = props[_i]; - if (!nameTable[prop.name]) { - var targetPropSym = getPropertyOfType(elementAttributesType, prop.name); - if (targetPropSym) { - var msg = ts.chainDiagnosticMessages(undefined, ts.Diagnostics.Property_0_of_JSX_spread_attribute_is_not_assignable_to_target_property, prop.name); - checkTypeAssignableTo(getTypeOfSymbol(prop), getTypeOfSymbol(targetPropSym), node, undefined, msg); - } - nameTable[prop.name] = true; - } - } - return type; - } - function getJsxIntrinsicElementsType() { - if (!jsxIntrinsicElementsType) { - jsxIntrinsicElementsType = getExportedTypeFromNamespace(JsxNames.JSX, JsxNames.IntrinsicElements) || unknownType; - } - return jsxIntrinsicElementsType; - } - function getJsxElementTagSymbol(node) { - var flags = 8; - var links = getNodeLinks(node); - if (!links.resolvedSymbol) { - if (isJsxIntrinsicIdentifier(node.tagName)) { - links.resolvedSymbol = lookupIntrinsicTag(node); - } - else { - links.resolvedSymbol = lookupClassTag(node); - } - } - return links.resolvedSymbol; - function lookupIntrinsicTag(node) { - var intrinsicElementsType = getJsxIntrinsicElementsType(); - if (intrinsicElementsType !== unknownType) { - var intrinsicProp = getPropertyOfType(intrinsicElementsType, node.tagName.text); - if (intrinsicProp) { - links.jsxFlags |= 1; - return intrinsicProp; - } - var indexSignatureType = getIndexTypeOfType(intrinsicElementsType, 0); - if (indexSignatureType) { - links.jsxFlags |= 2; - return intrinsicElementsType.symbol; - } - error(node, ts.Diagnostics.Property_0_does_not_exist_on_type_1, node.tagName.text, "JSX." + JsxNames.IntrinsicElements); - return unknownSymbol; - } - else { - if (compilerOptions.noImplicitAny) { - error(node, ts.Diagnostics.JSX_element_implicitly_has_type_any_because_no_interface_JSX_0_exists, JsxNames.IntrinsicElements); - } - } - } - function lookupClassTag(node) { - var valueSymbol = resolveJsxTagName(node); - if (valueSymbol && valueSymbol !== unknownSymbol) { - links.jsxFlags |= 4; - if (valueSymbol.flags & 8388608) { - markAliasSymbolAsReferenced(valueSymbol); - } - } - return valueSymbol || unknownSymbol; - } - function resolveJsxTagName(node) { - if (node.tagName.kind === 69) { - var tag = node.tagName; - var sym = getResolvedSymbol(tag); - return sym.exportSymbol || sym; - } - else { - return checkQualifiedName(node.tagName).symbol; - } - } - } - function getJsxElementInstanceType(node) { - ts.Debug.assert(!!(getNodeLinks(node).jsxFlags & 4), "Should not call getJsxElementInstanceType on non-class Element"); - var classSymbol = getJsxElementTagSymbol(node); - if (classSymbol === unknownSymbol) { - return anyType; - } - var valueType = getTypeOfSymbol(classSymbol); - if (isTypeAny(valueType)) { - return anyType; - } - var signatures = getSignaturesOfType(valueType, 1); - if (signatures.length === 0) { - signatures = getSignaturesOfType(valueType, 0); - if (signatures.length === 0) { - error(node.tagName, ts.Diagnostics.JSX_element_type_0_does_not_have_any_construct_or_call_signatures, ts.getTextOfNode(node.tagName)); - return unknownType; - } - } - var returnType = getUnionType(signatures.map(getReturnTypeOfSignature)); - var elemClassType = getJsxGlobalElementClassType(); - if (elemClassType) { - checkTypeRelatedTo(returnType, elemClassType, assignableRelation, node, ts.Diagnostics.JSX_element_type_0_is_not_a_constructor_function_for_JSX_elements); - } - return returnType; - } - function getJsxElementPropertiesName() { - var jsxNamespace = getGlobalSymbol(JsxNames.JSX, 1536, undefined); - var attribsPropTypeSym = jsxNamespace && getSymbol(jsxNamespace.exports, JsxNames.ElementAttributesPropertyNameContainer, 793056); - var attribPropType = attribsPropTypeSym && getDeclaredTypeOfSymbol(attribsPropTypeSym); - var attribProperties = attribPropType && getPropertiesOfType(attribPropType); - if (attribProperties) { - if (attribProperties.length === 0) { - return ""; - } - else if (attribProperties.length === 1) { - return attribProperties[0].name; - } - else { - error(attribsPropTypeSym.declarations[0], ts.Diagnostics.The_global_type_JSX_0_may_not_have_more_than_one_property, JsxNames.ElementAttributesPropertyNameContainer); - return undefined; - } - } - else { - return undefined; - } - } - function getJsxElementAttributesType(node) { - var links = getNodeLinks(node); - if (!links.resolvedJsxType) { - var sym = getJsxElementTagSymbol(node); - if (links.jsxFlags & 4) { - var elemInstanceType = getJsxElementInstanceType(node); - if (isTypeAny(elemInstanceType)) { - return links.resolvedJsxType = elemInstanceType; - } - var propsName = getJsxElementPropertiesName(); - if (propsName === undefined) { - return links.resolvedJsxType = anyType; - } - else if (propsName === "") { - return links.resolvedJsxType = elemInstanceType; - } - else { - var attributesType = getTypeOfPropertyOfType(elemInstanceType, propsName); - if (!attributesType) { - return links.resolvedJsxType = emptyObjectType; - } - else if (isTypeAny(attributesType) || (attributesType === unknownType)) { - return links.resolvedJsxType = attributesType; - } - else if (!(attributesType.flags & 80896)) { - error(node.tagName, ts.Diagnostics.JSX_element_attributes_type_0_must_be_an_object_type, typeToString(attributesType)); - return links.resolvedJsxType = anyType; - } - else { - return links.resolvedJsxType = attributesType; - } - } - } - else if (links.jsxFlags & 1) { - return links.resolvedJsxType = getTypeOfSymbol(sym); - } - else if (links.jsxFlags & 2) { - return links.resolvedJsxType = getIndexTypeOfSymbol(sym, 0); - } - else { - return links.resolvedJsxType = anyType; - } - } - return links.resolvedJsxType; - } - function getJsxAttributePropertySymbol(attrib) { - var attributesType = getJsxElementAttributesType(attrib.parent); - var prop = getPropertyOfType(attributesType, attrib.name.text); - return prop || unknownSymbol; - } - var jsxElementClassType = undefined; - function getJsxGlobalElementClassType() { - if (!jsxElementClassType) { - jsxElementClassType = getExportedTypeFromNamespace(JsxNames.JSX, JsxNames.ElementClass); - } - return jsxElementClassType; - } - function getJsxIntrinsicTagNames() { - var intrinsics = getJsxIntrinsicElementsType(); - return intrinsics ? getPropertiesOfType(intrinsics) : emptyArray; - } - function checkJsxPreconditions(errorNode) { - if ((compilerOptions.jsx || 0) === 0) { - error(errorNode, ts.Diagnostics.Cannot_use_JSX_unless_the_jsx_flag_is_provided); - } - if (jsxElementType === undefined) { - if (compilerOptions.noImplicitAny) { - error(errorNode, ts.Diagnostics.JSX_element_implicitly_has_type_any_because_the_global_type_JSX_Element_does_not_exist); - } - } - } - function checkJsxOpeningLikeElement(node) { - checkGrammarJsxElement(node); - checkJsxPreconditions(node); - if (compilerOptions.jsx === 2) { - var reactSym = resolveName(node.tagName, "React", 107455, ts.Diagnostics.Cannot_find_name_0, "React"); - if (reactSym) { - getSymbolLinks(reactSym).referenced = true; - } - } - var targetAttributesType = getJsxElementAttributesType(node); - var nameTable = {}; - var sawSpreadedAny = false; - for (var i = node.attributes.length - 1; i >= 0; i--) { - if (node.attributes[i].kind === 238) { - checkJsxAttribute((node.attributes[i]), targetAttributesType, nameTable); - } - else { - ts.Debug.assert(node.attributes[i].kind === 239); - var spreadType = checkJsxSpreadAttribute((node.attributes[i]), targetAttributesType, nameTable); - if (isTypeAny(spreadType)) { - sawSpreadedAny = true; - } - } - } - if (targetAttributesType && !sawSpreadedAny) { - var targetProperties = getPropertiesOfType(targetAttributesType); - for (var i = 0; i < targetProperties.length; i++) { - if (!(targetProperties[i].flags & 536870912) && - nameTable[targetProperties[i].name] === undefined) { - error(node, ts.Diagnostics.Property_0_is_missing_in_type_1, targetProperties[i].name, typeToString(targetAttributesType)); - } - } - } - } - function checkJsxExpression(node) { - if (node.expression) { - return checkExpression(node.expression); - } - else { - return unknownType; - } - } - function getDeclarationKindFromSymbol(s) { - return s.valueDeclaration ? s.valueDeclaration.kind : 141; - } - function getDeclarationFlagsFromSymbol(s) { - return s.valueDeclaration ? ts.getCombinedNodeFlags(s.valueDeclaration) : s.flags & 134217728 ? 16 | 128 : 0; - } - function checkClassPropertyAccess(node, left, type, prop) { - var flags = getDeclarationFlagsFromSymbol(prop); - var declaringClass = getDeclaredTypeOfSymbol(prop.parent); - if (left.kind === 95) { - var errorNode = node.kind === 166 ? - node.name : - node.right; - if (getDeclarationKindFromSymbol(prop) !== 143) { - error(errorNode, ts.Diagnostics.Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword); - return false; - } - if (flags & 256) { - error(errorNode, ts.Diagnostics.Abstract_method_0_in_class_1_cannot_be_accessed_via_super_expression, symbolToString(prop), typeToString(declaringClass)); - return false; - } - } - if (!(flags & (32 | 64))) { - return true; - } - var enclosingClassDeclaration = ts.getContainingClass(node); - var enclosingClass = enclosingClassDeclaration ? getDeclaredTypeOfSymbol(getSymbolOfNode(enclosingClassDeclaration)) : undefined; - if (flags & 32) { - if (declaringClass !== enclosingClass) { - error(node, ts.Diagnostics.Property_0_is_private_and_only_accessible_within_class_1, symbolToString(prop), typeToString(declaringClass)); - return false; - } - return true; - } - if (left.kind === 95) { - return true; - } - if (!enclosingClass || !hasBaseType(enclosingClass, declaringClass)) { - error(node, ts.Diagnostics.Property_0_is_protected_and_only_accessible_within_class_1_and_its_subclasses, symbolToString(prop), typeToString(declaringClass)); - return false; - } - if (flags & 128) { - return true; - } - if (type.flags & 33554432) { - type = getConstraintOfTypeParameter(type); - } - if (!(getTargetType(type).flags & (1024 | 2048) && hasBaseType(type, enclosingClass))) { - error(node, ts.Diagnostics.Property_0_is_protected_and_only_accessible_through_an_instance_of_class_1, symbolToString(prop), typeToString(enclosingClass)); - return false; - } - return true; - } - function checkPropertyAccessExpression(node) { - return checkPropertyAccessExpressionOrQualifiedName(node, node.expression, node.name); - } - function checkQualifiedName(node) { - return checkPropertyAccessExpressionOrQualifiedName(node, node.left, node.right); - } - function checkPropertyAccessExpressionOrQualifiedName(node, left, right) { - var type = checkExpression(left); - if (isTypeAny(type)) { - return type; - } - var apparentType = getApparentType(getWidenedType(type)); - if (apparentType === unknownType) { - return unknownType; - } - var prop = getPropertyOfType(apparentType, right.text); - if (!prop) { - if (right.text) { - error(right, ts.Diagnostics.Property_0_does_not_exist_on_type_1, ts.declarationNameToString(right), typeToString(type.flags & 33554432 ? apparentType : type)); - } - return unknownType; - } - getNodeLinks(node).resolvedSymbol = prop; - if (prop.parent && prop.parent.flags & 32) { - checkClassPropertyAccess(node, left, apparentType, prop); - } - return getTypeOfSymbol(prop); - } - function isValidPropertyAccess(node, propertyName) { - var left = node.kind === 166 - ? node.expression - : node.left; - var type = checkExpression(left); - if (type !== unknownType && !isTypeAny(type)) { - var prop = getPropertyOfType(getWidenedType(type), propertyName); - if (prop && prop.parent && prop.parent.flags & 32) { - return checkClassPropertyAccess(node, left, type, prop); - } - } - return true; - } - function checkIndexedAccess(node) { - if (!node.argumentExpression) { - var sourceFile = getSourceFile(node); - if (node.parent.kind === 169 && node.parent.expression === node) { - var start = ts.skipTrivia(sourceFile.text, node.expression.end); - var end = node.end; - grammarErrorAtPos(sourceFile, start, end - start, ts.Diagnostics.new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead); - } - else { - var start = node.end - "]".length; - var end = node.end; - grammarErrorAtPos(sourceFile, start, end - start, ts.Diagnostics.Expression_expected); - } - } - var objectType = getApparentType(checkExpression(node.expression)); - var indexType = node.argumentExpression ? checkExpression(node.argumentExpression) : unknownType; - if (objectType === unknownType) { - return unknownType; - } - var isConstEnum = isConstEnumObjectType(objectType); - if (isConstEnum && - (!node.argumentExpression || node.argumentExpression.kind !== 9)) { - error(node.argumentExpression, ts.Diagnostics.A_const_enum_member_can_only_be_accessed_using_a_string_literal); - return unknownType; - } - if (node.argumentExpression) { - var name_11 = getPropertyNameForIndexedAccess(node.argumentExpression, indexType); - if (name_11 !== undefined) { - var prop = getPropertyOfType(objectType, name_11); - 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_11, symbolToString(objectType.symbol)); - return unknownType; - } - } - } - if (isTypeAnyOrAllConstituentTypesHaveKind(indexType, 258 | 132 | 16777216)) { - if (isTypeAnyOrAllConstituentTypesHaveKind(indexType, 132)) { - var numberIndexType = getIndexTypeOfType(objectType, 1); - if (numberIndexType) { - return numberIndexType; - } - } - var stringIndexType = getIndexTypeOfType(objectType, 0); - if (stringIndexType) { - return stringIndexType; - } - if (compilerOptions.noImplicitAny && !compilerOptions.suppressImplicitAnyIndexErrors && !isTypeAny(objectType)) { - error(node, ts.Diagnostics.Index_signature_of_object_type_implicitly_has_an_any_type); - } - return anyType; - } - error(node, ts.Diagnostics.An_index_expression_argument_must_be_of_type_string_number_symbol_or_any); - return unknownType; - } - function getPropertyNameForIndexedAccess(indexArgumentExpression, indexArgumentType) { - if (indexArgumentExpression.kind === 9 || indexArgumentExpression.kind === 8) { - return indexArgumentExpression.text; - } - if (indexArgumentExpression.kind === 167 || indexArgumentExpression.kind === 166) { - var value = getConstantValue(indexArgumentExpression); - if (value !== undefined) { - return value.toString(); - } - } - if (checkThatExpressionIsProperSymbolReference(indexArgumentExpression, indexArgumentType, false)) { - var rightHandSideName = indexArgumentExpression.name.text; - return ts.getPropertyNameForKnownSymbolName(rightHandSideName); - } - return undefined; - } - function checkThatExpressionIsProperSymbolReference(expression, expressionType, reportError) { - if (expressionType === unknownType) { - return false; - } - if (!ts.isWellKnownSymbolSyntactically(expression)) { - return false; - } - if ((expressionType.flags & 16777216) === 0) { - if (reportError) { - error(expression, ts.Diagnostics.A_computed_property_name_of_the_form_0_must_be_of_type_symbol, ts.getTextOfNode(expression)); - } - return false; - } - var leftHandSide = expression.expression; - var leftHandSideSymbol = getResolvedSymbol(leftHandSide); - if (!leftHandSideSymbol) { - return false; - } - var globalESSymbol = getGlobalESSymbolConstructorSymbol(); - if (!globalESSymbol) { - return false; - } - if (leftHandSideSymbol !== globalESSymbol) { - if (reportError) { - error(leftHandSide, ts.Diagnostics.Symbol_reference_does_not_refer_to_the_global_Symbol_constructor_object); - } - return false; - } - return true; - } - function resolveUntypedCall(node) { - if (node.kind === 170) { - checkExpression(node.template); - } - else if (node.kind !== 139) { - ts.forEach(node.arguments, function (argument) { - checkExpression(argument); - }); - } - return anySignature; - } - function resolveErrorCall(node) { - resolveUntypedCall(node); - return unknownSignature; - } - function reorderCandidates(signatures, result) { - var lastParent; - var lastSymbol; - var cutoffIndex = 0; - var index; - var specializedIndex = -1; - var spliceIndex; - ts.Debug.assert(!result.length); - for (var _i = 0; _i < signatures.length; _i++) { - var signature = signatures[_i]; - var symbol = signature.declaration && getSymbolOfNode(signature.declaration); - var parent_5 = signature.declaration && signature.declaration.parent; - if (!lastSymbol || symbol === lastSymbol) { - if (lastParent && parent_5 === lastParent) { - index++; - } - else { - lastParent = parent_5; - index = cutoffIndex; - } - } - else { - index = cutoffIndex = result.length; - lastParent = parent_5; - } - lastSymbol = symbol; - if (signature.hasStringLiterals) { - specializedIndex++; - spliceIndex = specializedIndex; - cutoffIndex++; - } - else { - spliceIndex = index; - } - result.splice(spliceIndex, 0, signature); - } - } - function getSpreadArgumentIndex(args) { - for (var i = 0; i < args.length; i++) { - var arg = args[i]; - if (arg && arg.kind === 185) { - return i; - } - } - return -1; - } - function hasCorrectArity(node, args, signature) { - var adjustedArgCount; - var typeArguments; - var callIsIncomplete; - var isDecorator; - var spreadArgIndex = -1; - if (node.kind === 170) { - var tagExpression = node; - adjustedArgCount = args.length; - typeArguments = undefined; - if (tagExpression.template.kind === 183) { - var templateExpression = tagExpression.template; - var lastSpan = ts.lastOrUndefined(templateExpression.templateSpans); - ts.Debug.assert(lastSpan !== undefined); - callIsIncomplete = ts.nodeIsMissing(lastSpan.literal) || !!lastSpan.literal.isUnterminated; - } - else { - var templateLiteral = tagExpression.template; - ts.Debug.assert(templateLiteral.kind === 11); - callIsIncomplete = !!templateLiteral.isUnterminated; - } - } - else if (node.kind === 139) { - isDecorator = true; - typeArguments = undefined; - adjustedArgCount = getEffectiveArgumentCount(node, undefined, signature); - } - else { - var callExpression = node; - if (!callExpression.arguments) { - ts.Debug.assert(callExpression.kind === 169); - return signature.minArgumentCount === 0; - } - adjustedArgCount = callExpression.arguments.hasTrailingComma ? args.length + 1 : args.length; - callIsIncomplete = callExpression.arguments.end === callExpression.end; - typeArguments = callExpression.typeArguments; - spreadArgIndex = getSpreadArgumentIndex(args); - } - var hasRightNumberOfTypeArgs = !typeArguments || - (signature.typeParameters && typeArguments.length === signature.typeParameters.length); - if (!hasRightNumberOfTypeArgs) { - return false; - } - if (spreadArgIndex >= 0) { - return isRestParameterIndex(signature, spreadArgIndex); - } - if (!signature.hasRestParameter && adjustedArgCount > signature.parameters.length) { - return false; - } - var hasEnoughArguments = adjustedArgCount >= signature.minArgumentCount; - return callIsIncomplete || hasEnoughArguments; - } - function getSingleCallSignature(type) { - if (type.flags & 80896) { - var resolved = resolveStructuredTypeMembers(type); - if (resolved.callSignatures.length === 1 && resolved.constructSignatures.length === 0 && - resolved.properties.length === 0 && !resolved.stringIndexType && !resolved.numberIndexType) { - return resolved.callSignatures[0]; - } - } - return undefined; - } - function instantiateSignatureInContextOf(signature, contextualSignature, contextualMapper) { - var context = createInferenceContext(signature.typeParameters, true); - forEachMatchingParameterType(contextualSignature, signature, function (source, target) { - inferTypes(context, instantiateType(source, contextualMapper), target); - }); - return getSignatureInstantiation(signature, getInferredTypes(context)); - } - function inferTypeArguments(node, signature, args, excludeArgument, context) { - var typeParameters = signature.typeParameters; - var inferenceMapper = createInferenceMapper(context); - for (var i = 0; i < typeParameters.length; i++) { - if (!context.inferences[i].isFixed) { - context.inferredTypes[i] = undefined; - } - } - if (context.failedTypeParameterIndex !== undefined && !context.inferences[context.failedTypeParameterIndex].isFixed) { - context.failedTypeParameterIndex = undefined; - } - var argCount = getEffectiveArgumentCount(node, args, signature); - for (var i = 0; i < argCount; i++) { - var arg = getEffectiveArgument(node, args, i); - if (arg === undefined || arg.kind !== 187) { - var paramType = getTypeAtPosition(signature, i); - var argType = getEffectiveArgumentType(node, i, arg); - if (argType === undefined) { - var mapper = excludeArgument && excludeArgument[i] !== undefined ? identityMapper : inferenceMapper; - argType = checkExpressionWithContextualType(arg, paramType, mapper); - } - inferTypes(context, argType, paramType); - } - } - if (excludeArgument) { - for (var i = 0; i < argCount; i++) { - if (excludeArgument[i] === false) { - var arg = args[i]; - var paramType = getTypeAtPosition(signature, i); - inferTypes(context, checkExpressionWithContextualType(arg, paramType, inferenceMapper), paramType); - } - } - } - getInferredTypes(context); - } - function checkTypeArguments(signature, typeArguments, typeArgumentResultTypes, reportErrors, headMessage) { - var typeParameters = signature.typeParameters; - var typeArgumentsAreAssignable = true; - for (var i = 0; i < typeParameters.length; i++) { - var typeArgNode = typeArguments[i]; - var typeArgument = getTypeFromTypeNode(typeArgNode); - typeArgumentResultTypes[i] = typeArgument; - if (typeArgumentsAreAssignable) { - var constraint = getConstraintOfTypeParameter(typeParameters[i]); - if (constraint) { - var errorInfo = void 0; - var typeArgumentHeadMessage = ts.Diagnostics.Type_0_does_not_satisfy_the_constraint_1; - if (reportErrors && headMessage) { - errorInfo = ts.chainDiagnosticMessages(errorInfo, typeArgumentHeadMessage); - typeArgumentHeadMessage = headMessage; - } - typeArgumentsAreAssignable = checkTypeAssignableTo(typeArgument, constraint, reportErrors ? typeArgNode : undefined, typeArgumentHeadMessage, errorInfo); - } - } - } - return typeArgumentsAreAssignable; - } - function checkApplicableSignature(node, args, signature, relation, excludeArgument, reportErrors) { - var argCount = getEffectiveArgumentCount(node, args, signature); - for (var i = 0; i < argCount; i++) { - var arg = getEffectiveArgument(node, args, i); - if (arg === undefined || arg.kind !== 187) { - var paramType = getTypeAtPosition(signature, i); - var argType = getEffectiveArgumentType(node, i, arg); - if (argType === undefined) { - argType = arg.kind === 9 && !reportErrors - ? getStringLiteralType(arg) - : checkExpressionWithContextualType(arg, paramType, excludeArgument && excludeArgument[i] ? identityMapper : undefined); - } - var errorNode = reportErrors ? getEffectiveArgumentErrorNode(node, i, arg) : undefined; - var headMessage = ts.Diagnostics.Argument_of_type_0_is_not_assignable_to_parameter_of_type_1; - if (!checkTypeRelatedTo(argType, paramType, relation, errorNode, headMessage)) { - return false; - } - } - } - return true; - } - function getEffectiveCallArguments(node) { - var args; - if (node.kind === 170) { - var template = node.template; - args = [undefined]; - if (template.kind === 183) { - ts.forEach(template.templateSpans, function (span) { - args.push(span.expression); - }); - } - } - else if (node.kind === 139) { - return undefined; - } - else { - args = node.arguments || emptyArray; - } - return args; - } - function getEffectiveArgumentCount(node, args, signature) { - if (node.kind === 139) { - switch (node.parent.kind) { - case 214: - case 186: - return 1; - case 141: - return 2; - case 143: - case 145: - case 146: - if (languageVersion === 0) { - return 2; - } - return signature.parameters.length >= 3 ? 3 : 2; - case 138: - return 3; - } - } - else { - return args.length; - } - } - function getEffectiveDecoratorFirstArgumentType(node) { - if (node.kind === 214) { - var classSymbol = getSymbolOfNode(node); - return getTypeOfSymbol(classSymbol); - } - if (node.kind === 138) { - node = node.parent; - if (node.kind === 144) { - var classSymbol = getSymbolOfNode(node); - return getTypeOfSymbol(classSymbol); - } - } - if (node.kind === 141 || - node.kind === 143 || - node.kind === 145 || - node.kind === 146) { - return getParentTypeOfClassElement(node); - } - ts.Debug.fail("Unsupported decorator target."); - return unknownType; - } - function getEffectiveDecoratorSecondArgumentType(node) { - if (node.kind === 214) { - ts.Debug.fail("Class decorators should not have a second synthetic argument."); - return unknownType; - } - if (node.kind === 138) { - node = node.parent; - if (node.kind === 144) { - return anyType; - } - } - if (node.kind === 141 || - node.kind === 143 || - node.kind === 145 || - node.kind === 146) { - var element = node; - switch (element.name.kind) { - case 69: - case 8: - case 9: - return getStringLiteralType(element.name); - case 136: - var nameType = checkComputedPropertyName(element.name); - if (allConstituentTypesHaveKind(nameType, 16777216)) { - return nameType; - } - else { - return stringType; - } - default: - ts.Debug.fail("Unsupported property name."); - return unknownType; - } - } - ts.Debug.fail("Unsupported decorator target."); - return unknownType; - } - function getEffectiveDecoratorThirdArgumentType(node) { - if (node.kind === 214) { - ts.Debug.fail("Class decorators should not have a third synthetic argument."); - return unknownType; - } - if (node.kind === 138) { - return numberType; - } - if (node.kind === 141) { - ts.Debug.fail("Property decorators should not have a third synthetic argument."); - return unknownType; - } - if (node.kind === 143 || - node.kind === 145 || - node.kind === 146) { - var propertyType = getTypeOfNode(node); - return createTypedPropertyDescriptorType(propertyType); - } - ts.Debug.fail("Unsupported decorator target."); - return unknownType; - } - function getEffectiveDecoratorArgumentType(node, argIndex) { - if (argIndex === 0) { - return getEffectiveDecoratorFirstArgumentType(node.parent); - } - else if (argIndex === 1) { - return getEffectiveDecoratorSecondArgumentType(node.parent); - } - else if (argIndex === 2) { - return getEffectiveDecoratorThirdArgumentType(node.parent); - } - ts.Debug.fail("Decorators should not have a fourth synthetic argument."); - return unknownType; - } - function getEffectiveArgumentType(node, argIndex, arg) { - if (node.kind === 139) { - return getEffectiveDecoratorArgumentType(node, argIndex); - } - else if (argIndex === 0 && node.kind === 170) { - return globalTemplateStringsArrayType; - } - return undefined; - } - function getEffectiveArgument(node, args, argIndex) { - if (node.kind === 139 || - (argIndex === 0 && node.kind === 170)) { - return undefined; - } - return args[argIndex]; - } - function getEffectiveArgumentErrorNode(node, argIndex, arg) { - if (node.kind === 139) { - return node.expression; - } - else if (argIndex === 0 && node.kind === 170) { - return node.template; - } - else { - return arg; - } - } - function resolveCall(node, signatures, candidatesOutArray, headMessage) { - var isTaggedTemplate = node.kind === 170; - var isDecorator = node.kind === 139; - var typeArguments; - if (!isTaggedTemplate && !isDecorator) { - typeArguments = node.typeArguments; - if (node.expression.kind !== 95) { - ts.forEach(typeArguments, checkSourceElement); - } - } - var candidates = candidatesOutArray || []; - reorderCandidates(signatures, candidates); - if (!candidates.length) { - reportError(ts.Diagnostics.Supplied_parameters_do_not_match_any_signature_of_call_target); - return resolveErrorCall(node); - } - var args = getEffectiveCallArguments(node); - var excludeArgument; - if (!isDecorator) { - for (var i = isTaggedTemplate ? 1 : 0; i < args.length; i++) { - if (isContextSensitive(args[i])) { - if (!excludeArgument) { - excludeArgument = new Array(args.length); - } - excludeArgument[i] = true; - } - } - } - var candidateForArgumentError; - var candidateForTypeArgumentError; - var resultOfFailedInference; - var result; - if (candidates.length > 1) { - result = chooseOverload(candidates, subtypeRelation); - } - if (!result) { - candidateForArgumentError = undefined; - candidateForTypeArgumentError = undefined; - resultOfFailedInference = undefined; - result = chooseOverload(candidates, assignableRelation); - } - if (result) { - return result; - } - if (candidateForArgumentError) { - checkApplicableSignature(node, args, candidateForArgumentError, assignableRelation, undefined, true); - } - else if (candidateForTypeArgumentError) { - if (!isTaggedTemplate && !isDecorator && typeArguments) { - checkTypeArguments(candidateForTypeArgumentError, node.typeArguments, [], true, headMessage); - } - else { - ts.Debug.assert(resultOfFailedInference.failedTypeParameterIndex >= 0); - var failedTypeParameter = candidateForTypeArgumentError.typeParameters[resultOfFailedInference.failedTypeParameterIndex]; - var inferenceCandidates = getInferenceCandidates(resultOfFailedInference, resultOfFailedInference.failedTypeParameterIndex); - var diagnosticChainHead = ts.chainDiagnosticMessages(undefined, ts.Diagnostics.The_type_argument_for_type_parameter_0_cannot_be_inferred_from_the_usage_Consider_specifying_the_type_arguments_explicitly, typeToString(failedTypeParameter)); - if (headMessage) { - diagnosticChainHead = ts.chainDiagnosticMessages(diagnosticChainHead, headMessage); - } - reportNoCommonSupertypeError(inferenceCandidates, node.expression || node.tag, diagnosticChainHead); - } - } - else { - reportError(ts.Diagnostics.Supplied_parameters_do_not_match_any_signature_of_call_target); - } - if (!produceDiagnostics) { - for (var _i = 0; _i < candidates.length; _i++) { - var candidate = candidates[_i]; - if (hasCorrectArity(node, args, candidate)) { - if (candidate.typeParameters && typeArguments) { - candidate = getSignatureInstantiation(candidate, ts.map(typeArguments, getTypeFromTypeNode)); - } - return candidate; - } - } - } - return resolveErrorCall(node); - function reportError(message, arg0, arg1, arg2) { - var errorInfo; - errorInfo = ts.chainDiagnosticMessages(errorInfo, message, arg0, arg1, arg2); - if (headMessage) { - errorInfo = ts.chainDiagnosticMessages(errorInfo, headMessage); - } - diagnostics.add(ts.createDiagnosticForNodeFromMessageChain(node, errorInfo)); - } - function chooseOverload(candidates, relation) { - for (var _i = 0; _i < candidates.length; _i++) { - var originalCandidate = candidates[_i]; - if (!hasCorrectArity(node, args, originalCandidate)) { - continue; - } - var candidate = void 0; - var typeArgumentsAreValid = void 0; - var inferenceContext = originalCandidate.typeParameters - ? createInferenceContext(originalCandidate.typeParameters, false) - : undefined; - while (true) { - candidate = originalCandidate; - if (candidate.typeParameters) { - var typeArgumentTypes = void 0; - if (typeArguments) { - typeArgumentTypes = new Array(candidate.typeParameters.length); - typeArgumentsAreValid = checkTypeArguments(candidate, typeArguments, typeArgumentTypes, false); - } - else { - inferTypeArguments(node, candidate, args, excludeArgument, inferenceContext); - typeArgumentsAreValid = inferenceContext.failedTypeParameterIndex === undefined; - typeArgumentTypes = inferenceContext.inferredTypes; - } - if (!typeArgumentsAreValid) { - break; - } - candidate = getSignatureInstantiation(candidate, typeArgumentTypes); - } - if (!checkApplicableSignature(node, args, candidate, relation, excludeArgument, false)) { - break; - } - var index = excludeArgument ? ts.indexOf(excludeArgument, true) : -1; - if (index < 0) { - return candidate; - } - excludeArgument[index] = false; - } - if (originalCandidate.typeParameters) { - var instantiatedCandidate = candidate; - if (typeArgumentsAreValid) { - candidateForArgumentError = instantiatedCandidate; - } - else { - candidateForTypeArgumentError = originalCandidate; - if (!typeArguments) { - resultOfFailedInference = inferenceContext; - } - } - } - else { - ts.Debug.assert(originalCandidate === candidate); - candidateForArgumentError = originalCandidate; - } - } - return undefined; - } - } - function resolveCallExpression(node, candidatesOutArray) { - if (node.expression.kind === 95) { - var superType = checkSuperExpression(node.expression); - if (superType !== unknownType) { - var baseTypeNode = ts.getClassExtendsHeritageClauseElement(ts.getContainingClass(node)); - var baseConstructors = getInstantiatedConstructorsForTypeArguments(superType, baseTypeNode.typeArguments); - return resolveCall(node, baseConstructors, candidatesOutArray); - } - return resolveUntypedCall(node); - } - var funcType = checkExpression(node.expression); - var apparentType = getApparentType(funcType); - if (apparentType === unknownType) { - return resolveErrorCall(node); - } - var callSignatures = getSignaturesOfType(apparentType, 0); - var constructSignatures = getSignaturesOfType(apparentType, 1); - if (isTypeAny(funcType) || (!callSignatures.length && !constructSignatures.length && !(funcType.flags & 16384) && isTypeAssignableTo(funcType, globalFunctionType))) { - if (funcType !== unknownType && node.typeArguments) { - error(node, ts.Diagnostics.Untyped_function_calls_may_not_accept_type_arguments); - } - return resolveUntypedCall(node); - } - if (!callSignatures.length) { - if (constructSignatures.length) { - error(node, ts.Diagnostics.Value_of_type_0_is_not_callable_Did_you_mean_to_include_new, typeToString(funcType)); - } - else { - error(node, ts.Diagnostics.Cannot_invoke_an_expression_whose_type_lacks_a_call_signature); - } - return resolveErrorCall(node); - } - return resolveCall(node, callSignatures, candidatesOutArray); - } - function resolveNewExpression(node, candidatesOutArray) { - if (node.arguments && languageVersion < 1) { - var spreadIndex = getSpreadArgumentIndex(node.arguments); - if (spreadIndex >= 0) { - error(node.arguments[spreadIndex], ts.Diagnostics.Spread_operator_in_new_expressions_is_only_available_when_targeting_ECMAScript_5_and_higher); - } - } - var expressionType = checkExpression(node.expression); - expressionType = getApparentType(expressionType); - if (expressionType === unknownType) { - return resolveErrorCall(node); - } - var valueDecl = expressionType.symbol && getClassLikeDeclarationOfSymbol(expressionType.symbol); - if (valueDecl && valueDecl.flags & 256) { - error(node, ts.Diagnostics.Cannot_create_an_instance_of_the_abstract_class_0, ts.declarationNameToString(valueDecl.name)); - return resolveErrorCall(node); - } - if (isTypeAny(expressionType)) { - if (node.typeArguments) { - error(node, ts.Diagnostics.Untyped_function_calls_may_not_accept_type_arguments); - } - return resolveUntypedCall(node); - } - var constructSignatures = getSignaturesOfType(expressionType, 1); - if (constructSignatures.length) { - return resolveCall(node, constructSignatures, candidatesOutArray); - } - var callSignatures = getSignaturesOfType(expressionType, 0); - if (callSignatures.length) { - var signature = resolveCall(node, callSignatures, candidatesOutArray); - if (getReturnTypeOfSignature(signature) !== voidType) { - error(node, ts.Diagnostics.Only_a_void_function_can_be_called_with_the_new_keyword); - } - return signature; - } - error(node, ts.Diagnostics.Cannot_use_new_with_an_expression_whose_type_lacks_a_call_or_construct_signature); - return resolveErrorCall(node); - } - function resolveTaggedTemplateExpression(node, candidatesOutArray) { - var tagType = checkExpression(node.tag); - var apparentType = getApparentType(tagType); - if (apparentType === unknownType) { - return resolveErrorCall(node); - } - var callSignatures = getSignaturesOfType(apparentType, 0); - if (isTypeAny(tagType) || (!callSignatures.length && !(tagType.flags & 16384) && isTypeAssignableTo(tagType, globalFunctionType))) { - return resolveUntypedCall(node); - } - if (!callSignatures.length) { - error(node, ts.Diagnostics.Cannot_invoke_an_expression_whose_type_lacks_a_call_signature); - return resolveErrorCall(node); - } - return resolveCall(node, callSignatures, candidatesOutArray); - } - function getDiagnosticHeadMessageForDecoratorResolution(node) { - switch (node.parent.kind) { - case 214: - case 186: - return ts.Diagnostics.Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression; - case 138: - return ts.Diagnostics.Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression; - case 141: - return ts.Diagnostics.Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression; - case 143: - case 145: - case 146: - return ts.Diagnostics.Unable_to_resolve_signature_of_method_decorator_when_called_as_an_expression; - } - } - function resolveDecorator(node, candidatesOutArray) { - var funcType = checkExpression(node.expression); - var apparentType = getApparentType(funcType); - if (apparentType === unknownType) { - return resolveErrorCall(node); - } - var callSignatures = getSignaturesOfType(apparentType, 0); - if (funcType === anyType || (!callSignatures.length && !(funcType.flags & 16384) && isTypeAssignableTo(funcType, globalFunctionType))) { - return resolveUntypedCall(node); - } - var headMessage = getDiagnosticHeadMessageForDecoratorResolution(node); - if (!callSignatures.length) { - var errorInfo; - errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.Cannot_invoke_an_expression_whose_type_lacks_a_call_signature); - errorInfo = ts.chainDiagnosticMessages(errorInfo, headMessage); - diagnostics.add(ts.createDiagnosticForNodeFromMessageChain(node, errorInfo)); - return resolveErrorCall(node); - } - return resolveCall(node, callSignatures, candidatesOutArray, headMessage); - } - function getResolvedSignature(node, candidatesOutArray) { - var links = getNodeLinks(node); - if (!links.resolvedSignature || candidatesOutArray) { - links.resolvedSignature = anySignature; - if (node.kind === 168) { - links.resolvedSignature = resolveCallExpression(node, candidatesOutArray); - } - else if (node.kind === 169) { - links.resolvedSignature = resolveNewExpression(node, candidatesOutArray); - } - else if (node.kind === 170) { - links.resolvedSignature = resolveTaggedTemplateExpression(node, candidatesOutArray); - } - else if (node.kind === 139) { - links.resolvedSignature = resolveDecorator(node, candidatesOutArray); - } - else { - ts.Debug.fail("Branch in 'getResolvedSignature' should be unreachable."); - } - } - return links.resolvedSignature; - } - function checkCallExpression(node) { - checkGrammarTypeArguments(node, node.typeArguments) || checkGrammarArguments(node, node.arguments); - var signature = getResolvedSignature(node); - if (node.expression.kind === 95) { - return voidType; - } - if (node.kind === 169) { - var declaration = signature.declaration; - if (declaration && - declaration.kind !== 144 && - declaration.kind !== 148 && - declaration.kind !== 153) { - if (compilerOptions.noImplicitAny) { - error(node, ts.Diagnostics.new_expression_whose_target_lacks_a_construct_signature_implicitly_has_an_any_type); - } - return anyType; - } - } - return getReturnTypeOfSignature(signature); - } - function checkTaggedTemplateExpression(node) { - return getReturnTypeOfSignature(getResolvedSignature(node)); - } - function checkAssertion(node) { - var exprType = getRegularTypeOfObjectLiteral(checkExpression(node.expression)); - var targetType = getTypeFromTypeNode(node.type); - if (produceDiagnostics && targetType !== unknownType) { - var widenedType = getWidenedType(exprType); - if (!(isTypeAssignableTo(targetType, widenedType))) { - checkTypeAssignableTo(exprType, targetType, node, ts.Diagnostics.Neither_type_0_nor_type_1_is_assignable_to_the_other); - } - } - return targetType; - } - function getTypeAtPosition(signature, pos) { - return signature.hasRestParameter ? - pos < signature.parameters.length - 1 ? getTypeOfSymbol(signature.parameters[pos]) : getRestTypeOfSignature(signature) : - pos < signature.parameters.length ? getTypeOfSymbol(signature.parameters[pos]) : anyType; - } - function assignContextualParameterTypes(signature, context, mapper) { - var len = signature.parameters.length - (signature.hasRestParameter ? 1 : 0); - for (var i = 0; i < len; i++) { - var parameter = signature.parameters[i]; - 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); - } - } - function assignBindingElementTypes(node) { - if (ts.isBindingPattern(node.name)) { - for (var _i = 0, _a = node.name.elements; _i < _a.length; _i++) { - var element = _a[_i]; - if (element.kind !== 187) { - getSymbolLinks(getSymbolOfNode(element)).type = getTypeForBindingElement(element); - assignBindingElementTypes(element); - } - } - } - } - function assignTypeToParameterAndFixTypeParameters(parameter, contextualType, mapper) { - var links = getSymbolLinks(parameter); - if (!links.type) { - links.type = instantiateType(contextualType, mapper); - assignBindingElementTypes(parameter.valueDeclaration); - } - else if (isInferentialContext(mapper)) { - inferTypes(mapper.context, links.type, instantiateType(contextualType, mapper)); - } - } - function createPromiseType(promisedType) { - var globalPromiseType = getGlobalPromiseType(); - if (globalPromiseType !== emptyGenericType) { - promisedType = getAwaitedType(promisedType); - return createTypeReference(globalPromiseType, [promisedType]); - } - return emptyObjectType; - } - function getReturnTypeFromBody(func, contextualMapper) { - var contextualSignature = getContextualSignatureForFunctionLikeDeclaration(func); - if (!func.body) { - return unknownType; - } - var isAsync = ts.isAsyncFunctionLike(func); - var type; - if (func.body.kind !== 192) { - type = checkExpressionCached(func.body, contextualMapper); - if (isAsync) { - type = checkAwaitedType(type, func, ts.Diagnostics.Return_expression_in_async_function_does_not_have_a_valid_callable_then_member); - } - } - else { - var types; - var funcIsGenerator = !!func.asteriskToken; - if (funcIsGenerator) { - types = checkAndAggregateYieldOperandTypes(func.body, contextualMapper); - if (types.length === 0) { - var iterableIteratorAny = createIterableIteratorType(anyType); - if (compilerOptions.noImplicitAny) { - error(func.asteriskToken, ts.Diagnostics.Generator_implicitly_has_type_0_because_it_does_not_yield_any_values_Consider_supplying_a_return_type, typeToString(iterableIteratorAny)); - } - return iterableIteratorAny; - } - } - else { - types = checkAndAggregateReturnExpressionTypes(func.body, contextualMapper, isAsync); - if (types.length === 0) { - if (isAsync) { - var promiseType = createPromiseType(voidType); - if (promiseType === emptyObjectType) { - error(func, ts.Diagnostics.An_async_function_or_method_must_have_a_valid_awaitable_return_type); - return unknownType; - } - return promiseType; - } - else { - return voidType; - } - } - } - type = contextualSignature ? getUnionType(types) : getCommonSupertype(types); - if (!type) { - if (funcIsGenerator) { - error(func, ts.Diagnostics.No_best_common_type_exists_among_yield_expressions); - return createIterableIteratorType(unknownType); - } - else { - error(func, ts.Diagnostics.No_best_common_type_exists_among_return_expressions); - return unknownType; - } - } - if (funcIsGenerator) { - type = createIterableIteratorType(type); - } - } - if (!contextualSignature) { - reportErrorsFromWidening(func, type); - } - var widenedType = getWidenedType(type); - if (isAsync) { - var promiseType = createPromiseType(widenedType); - if (promiseType === emptyObjectType) { - error(func, ts.Diagnostics.An_async_function_or_method_must_have_a_valid_awaitable_return_type); - return unknownType; - } - return promiseType; - } - else { - return widenedType; - } - } - function checkAndAggregateYieldOperandTypes(body, contextualMapper) { - var aggregatedTypes = []; - ts.forEachYieldExpression(body, function (yieldExpression) { - var expr = yieldExpression.expression; - if (expr) { - var type = checkExpressionCached(expr, contextualMapper); - if (yieldExpression.asteriskToken) { - type = checkElementTypeOfIterable(type, yieldExpression.expression); - } - if (!ts.contains(aggregatedTypes, type)) { - aggregatedTypes.push(type); - } - } - }); - return aggregatedTypes; - } - function checkAndAggregateReturnExpressionTypes(body, contextualMapper, isAsync) { - var aggregatedTypes = []; - ts.forEachReturnStatement(body, function (returnStatement) { - var expr = returnStatement.expression; - if (expr) { - var type = checkExpressionCached(expr, contextualMapper); - if (isAsync) { - type = checkAwaitedType(type, body.parent, ts.Diagnostics.Return_expression_in_async_function_does_not_have_a_valid_callable_then_member); - } - if (!ts.contains(aggregatedTypes, type)) { - aggregatedTypes.push(type); - } - } - }); - return aggregatedTypes; - } - function bodyContainsAReturnStatement(funcBody) { - return ts.forEachReturnStatement(funcBody, function (returnStatement) { - return true; - }); - } - function bodyContainsSingleThrowStatement(body) { - return (body.statements.length === 1) && (body.statements[0].kind === 208); - } - function checkIfNonVoidFunctionHasReturnExpressionsOrSingleThrowStatment(func, returnType) { - if (!produceDiagnostics) { - return; - } - if (returnType === voidType || isTypeAny(returnType)) { - return; - } - if (ts.nodeIsMissing(func.body) || func.body.kind !== 192) { - return; - } - var bodyBlock = func.body; - if (bodyContainsAReturnStatement(bodyBlock)) { - return; - } - if (bodyContainsSingleThrowStatement(bodyBlock)) { - return; - } - error(func.type, ts.Diagnostics.A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value_or_consist_of_a_single_throw_statement); - } - function checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper) { - ts.Debug.assert(node.kind !== 143 || ts.isObjectLiteralMethod(node)); - var hasGrammarError = checkGrammarFunctionLikeDeclaration(node); - if (!hasGrammarError && node.kind === 173) { - checkGrammarForGenerator(node); - } - if (contextualMapper === identityMapper && isContextSensitive(node)) { - return anyFunctionType; - } - var isAsync = ts.isAsyncFunctionLike(node); - if (isAsync) { - emitAwaiter = true; - } - var links = getNodeLinks(node); - var type = getTypeOfSymbol(node.symbol); - var contextSensitive = isContextSensitive(node); - var mightFixTypeParameters = contextSensitive && isInferentialContext(contextualMapper); - if (mightFixTypeParameters || !(links.flags & 1024)) { - var contextualSignature = getContextualSignature(node); - var contextChecked = !!(links.flags & 1024); - if (mightFixTypeParameters || !contextChecked) { - links.flags |= 1024; - if (contextualSignature) { - var signature = getSignaturesOfType(type, 0)[0]; - if (contextSensitive) { - assignContextualParameterTypes(signature, contextualSignature, contextualMapper || identityMapper); - } - if (mightFixTypeParameters || !node.type && !signature.resolvedReturnType) { - var returnType = getReturnTypeFromBody(node, contextualMapper); - if (!signature.resolvedReturnType) { - signature.resolvedReturnType = returnType; - } - } - } - if (!contextChecked) { - checkSignatureDeclaration(node); - } - } - } - if (produceDiagnostics && node.kind !== 143 && node.kind !== 142) { - checkCollisionWithCapturedSuperVariable(node, node.name); - checkCollisionWithCapturedThisVariable(node, node.name); - } - return type; - } - function checkFunctionExpressionOrObjectLiteralMethodBody(node) { - ts.Debug.assert(node.kind !== 143 || ts.isObjectLiteralMethod(node)); - var isAsync = ts.isAsyncFunctionLike(node); - if (isAsync) { - emitAwaiter = true; - } - var returnType = node.type && getTypeFromTypeNode(node.type); - var promisedType; - if (returnType && isAsync) { - promisedType = checkAsyncFunctionReturnType(node); - } - if (returnType && !node.asteriskToken) { - checkIfNonVoidFunctionHasReturnExpressionsOrSingleThrowStatment(node, isAsync ? promisedType : returnType); - } - if (node.body) { - if (!node.type) { - getReturnTypeOfSignature(getSignatureFromDeclaration(node)); - } - if (node.body.kind === 192) { - checkSourceElement(node.body); - } - else { - var exprType = checkExpression(node.body); - if (returnType) { - if (isAsync) { - var awaitedType = checkAwaitedType(exprType, node.body, ts.Diagnostics.Expression_body_for_async_arrow_function_does_not_have_a_valid_callable_then_member); - checkTypeAssignableTo(awaitedType, promisedType, node.body); - } - else { - checkTypeAssignableTo(exprType, returnType, node.body); - } - } - checkFunctionAndClassExpressionBodies(node.body); - } - } - } - function checkArithmeticOperandType(operand, type, diagnostic) { - if (!isTypeAnyOrAllConstituentTypesHaveKind(type, 132)) { - error(operand, diagnostic); - return false; - } - return true; - } - function checkReferenceExpression(n, invalidReferenceMessage, constantVariableMessage) { - function findSymbol(n) { - var symbol = getNodeLinks(n).resolvedSymbol; - return symbol && getExportSymbolOfValueSymbolIfExported(symbol); - } - function isReferenceOrErrorExpression(n) { - switch (n.kind) { - case 69: { - var symbol = findSymbol(n); - return !symbol || symbol === unknownSymbol || symbol === argumentsSymbol || (symbol.flags & 3) !== 0; - } - case 166: { - var symbol = findSymbol(n); - return !symbol || symbol === unknownSymbol || (symbol.flags & ~8) !== 0; - } - case 167: - return true; - case 172: - return isReferenceOrErrorExpression(n.expression); - default: - return false; - } - } - function isConstVariableReference(n) { - switch (n.kind) { - case 69: - case 166: { - var symbol = findSymbol(n); - return symbol && (symbol.flags & 3) !== 0 && (getDeclarationFlagsFromSymbol(symbol) & 32768) !== 0; - } - case 167: { - var index = n.argumentExpression; - var symbol = findSymbol(n.expression); - if (symbol && index && index.kind === 9) { - var name_12 = index.text; - var prop = getPropertyOfType(getTypeOfSymbol(symbol), name_12); - return prop && (prop.flags & 3) !== 0 && (getDeclarationFlagsFromSymbol(prop) & 32768) !== 0; - } - return false; - } - case 172: - return isConstVariableReference(n.expression); - default: - return false; - } - } - if (!isReferenceOrErrorExpression(n)) { - error(n, invalidReferenceMessage); - return false; - } - if (isConstVariableReference(n)) { - error(n, constantVariableMessage); - return false; - } - return true; - } - function checkDeleteExpression(node) { - checkExpression(node.expression); - return booleanType; - } - function checkTypeOfExpression(node) { - checkExpression(node.expression); - return stringType; - } - function checkVoidExpression(node) { - checkExpression(node.expression); - return undefinedType; - } - function checkAwaitExpression(node) { - if (produceDiagnostics) { - if (!(node.parserContextFlags & 8)) { - grammarErrorOnFirstToken(node, ts.Diagnostics.await_expression_is_only_allowed_within_an_async_function); - } - if (isInParameterInitializerBeforeContainingFunction(node)) { - error(node, ts.Diagnostics.await_expressions_cannot_be_used_in_a_parameter_initializer); - } - } - var operandType = checkExpression(node.expression); - return checkAwaitedType(operandType, node); - } - function checkPrefixUnaryExpression(node) { - var operandType = checkExpression(node.operand); - switch (node.operator) { - case 35: - case 36: - case 50: - if (someConstituentTypeHasKind(operandType, 16777216)) { - error(node.operand, ts.Diagnostics.The_0_operator_cannot_be_applied_to_type_symbol, ts.tokenToString(node.operator)); - } - return numberType; - case 49: - return booleanType; - case 41: - case 42: - var ok = checkArithmeticOperandType(node.operand, operandType, ts.Diagnostics.An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type); - if (ok) { - checkReferenceExpression(node.operand, ts.Diagnostics.The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_property_or_indexer, ts.Diagnostics.The_operand_of_an_increment_or_decrement_operator_cannot_be_a_constant); - } - return numberType; - } - return unknownType; - } - function checkPostfixUnaryExpression(node) { - var operandType = checkExpression(node.operand); - var ok = checkArithmeticOperandType(node.operand, operandType, ts.Diagnostics.An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type); - if (ok) { - checkReferenceExpression(node.operand, ts.Diagnostics.The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_property_or_indexer, ts.Diagnostics.The_operand_of_an_increment_or_decrement_operator_cannot_be_a_constant); - } - return numberType; - } - function someConstituentTypeHasKind(type, kind) { - if (type.flags & kind) { - return true; - } - if (type.flags & 49152) { - var types = type.types; - for (var _i = 0; _i < types.length; _i++) { - var current = types[_i]; - if (current.flags & kind) { - return true; - } - } - return false; - } - return false; - } - function allConstituentTypesHaveKind(type, kind) { - if (type.flags & kind) { - return true; - } - if (type.flags & 49152) { - var types = type.types; - for (var _i = 0; _i < types.length; _i++) { - var current = types[_i]; - if (!(current.flags & kind)) { - return false; - } - } - return true; - } - return false; - } - function isConstEnumObjectType(type) { - return type.flags & (80896 | 65536) && type.symbol && isConstEnumSymbol(type.symbol); - } - function isConstEnumSymbol(symbol) { - return (symbol.flags & 128) !== 0; - } - function checkInstanceOfExpression(left, right, leftType, rightType) { - if (allConstituentTypesHaveKind(leftType, 16777726)) { - error(left, ts.Diagnostics.The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_parameter); - } - if (!(isTypeAny(rightType) || isTypeSubtypeOf(rightType, globalFunctionType))) { - error(right, ts.Diagnostics.The_right_hand_side_of_an_instanceof_expression_must_be_of_type_any_or_of_a_type_assignable_to_the_Function_interface_type); - } - return booleanType; - } - function checkInExpression(left, right, leftType, rightType) { - if (!isTypeAnyOrAllConstituentTypesHaveKind(leftType, 258 | 132 | 16777216)) { - error(left, ts.Diagnostics.The_left_hand_side_of_an_in_expression_must_be_of_type_any_string_number_or_symbol); - } - if (!isTypeAnyOrAllConstituentTypesHaveKind(rightType, 80896 | 512)) { - error(right, ts.Diagnostics.The_right_hand_side_of_an_in_expression_must_be_of_type_any_an_object_type_or_a_type_parameter); - } - return booleanType; - } - function checkObjectLiteralAssignment(node, sourceType, contextualMapper) { - var properties = node.properties; - for (var _i = 0; _i < properties.length; _i++) { - var p = properties[_i]; - if (p.kind === 245 || p.kind === 246) { - var name_13 = p.name; - var type = isTypeAny(sourceType) - ? sourceType - : getTypeOfPropertyOfType(sourceType, name_13.text) || - isNumericLiteralName(name_13.text) && getIndexTypeOfType(sourceType, 1) || - getIndexTypeOfType(sourceType, 0); - if (type) { - if (p.kind === 246) { - checkDestructuringAssignment(p, type); - } - else { - checkDestructuringAssignment(p.initializer || name_13, type); - } - } - else { - error(name_13, ts.Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(sourceType), ts.declarationNameToString(name_13)); - } - } - else { - error(p, ts.Diagnostics.Property_assignment_expected); - } - } - return sourceType; - } - function checkArrayLiteralAssignment(node, sourceType, contextualMapper) { - var elementType = checkIteratedTypeOrElementType(sourceType, node, false) || unknownType; - var elements = node.elements; - for (var i = 0; i < elements.length; i++) { - var e = elements[i]; - if (e.kind !== 187) { - if (e.kind !== 185) { - var propName = "" + i; - var type = isTypeAny(sourceType) - ? sourceType - : isTupleLikeType(sourceType) - ? getTypeOfPropertyOfType(sourceType, propName) - : elementType; - if (type) { - checkDestructuringAssignment(e, type, contextualMapper); - } - else { - if (isTupleType(sourceType)) { - error(e, ts.Diagnostics.Tuple_type_0_with_length_1_cannot_be_assigned_to_tuple_with_length_2, typeToString(sourceType), sourceType.elementTypes.length, elements.length); - } - else { - error(e, ts.Diagnostics.Type_0_has_no_property_1, typeToString(sourceType), propName); - } - } - } - else { - if (i < elements.length - 1) { - error(e, ts.Diagnostics.A_rest_element_must_be_last_in_an_array_destructuring_pattern); - } - else { - var restExpression = e.expression; - if (restExpression.kind === 181 && restExpression.operatorToken.kind === 56) { - error(restExpression.operatorToken, ts.Diagnostics.A_rest_element_cannot_have_an_initializer); - } - else { - checkDestructuringAssignment(restExpression, createArrayType(elementType), contextualMapper); - } - } - } - } - } - return sourceType; - } - function checkDestructuringAssignment(exprOrAssignment, sourceType, contextualMapper) { - var target; - if (exprOrAssignment.kind === 246) { - var prop = exprOrAssignment; - if (prop.objectAssignmentInitializer) { - checkBinaryLikeExpression(prop.name, prop.equalsToken, prop.objectAssignmentInitializer, contextualMapper); - } - target = exprOrAssignment.name; - } - else { - target = exprOrAssignment; - } - if (target.kind === 181 && target.operatorToken.kind === 56) { - checkBinaryExpression(target, contextualMapper); - target = target.left; - } - if (target.kind === 165) { - return checkObjectLiteralAssignment(target, sourceType, contextualMapper); - } - if (target.kind === 164) { - return checkArrayLiteralAssignment(target, sourceType, contextualMapper); - } - return checkReferenceAssignment(target, sourceType, contextualMapper); - } - function checkReferenceAssignment(target, sourceType, contextualMapper) { - var targetType = checkExpression(target, contextualMapper); - if (checkReferenceExpression(target, ts.Diagnostics.Invalid_left_hand_side_of_assignment_expression, ts.Diagnostics.Left_hand_side_of_assignment_expression_cannot_be_a_constant)) { - checkTypeAssignableTo(sourceType, targetType, target, undefined); - } - return sourceType; - } - function checkBinaryExpression(node, contextualMapper) { - return checkBinaryLikeExpression(node.left, node.operatorToken, node.right, contextualMapper, node); - } - function checkBinaryLikeExpression(left, operatorToken, right, contextualMapper, errorNode) { - var operator = operatorToken.kind; - if (operator === 56 && (left.kind === 165 || left.kind === 164)) { - return checkDestructuringAssignment(left, checkExpression(right, contextualMapper), contextualMapper); - } - var leftType = checkExpression(left, contextualMapper); - var rightType = checkExpression(right, contextualMapper); - switch (operator) { - case 37: - case 38: - case 59: - case 60: - case 39: - case 61: - case 40: - case 62: - case 36: - case 58: - case 43: - case 63: - case 44: - case 64: - case 45: - case 65: - case 47: - case 67: - case 48: - case 68: - case 46: - case 66: - if (leftType.flags & (32 | 64)) - leftType = rightType; - if (rightType.flags & (32 | 64)) - rightType = leftType; - var suggestedOperator; - if ((leftType.flags & 8) && - (rightType.flags & 8) && - (suggestedOperator = getSuggestedBooleanOperator(operatorToken.kind)) !== undefined) { - error(errorNode || operatorToken, ts.Diagnostics.The_0_operator_is_not_allowed_for_boolean_types_Consider_using_1_instead, ts.tokenToString(operatorToken.kind), ts.tokenToString(suggestedOperator)); - } - else { - var leftOk = checkArithmeticOperandType(left, leftType, ts.Diagnostics.The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type); - var rightOk = checkArithmeticOperandType(right, rightType, ts.Diagnostics.The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type); - if (leftOk && rightOk) { - checkAssignmentOperator(numberType); - } - } - return numberType; - case 35: - case 57: - if (leftType.flags & (32 | 64)) - leftType = rightType; - if (rightType.flags & (32 | 64)) - rightType = leftType; - var resultType; - if (allConstituentTypesHaveKind(leftType, 132) && allConstituentTypesHaveKind(rightType, 132)) { - resultType = numberType; - } - else { - if (allConstituentTypesHaveKind(leftType, 258) || allConstituentTypesHaveKind(rightType, 258)) { - resultType = stringType; - } - else if (isTypeAny(leftType) || isTypeAny(rightType)) { - resultType = leftType === unknownType || rightType === unknownType ? unknownType : anyType; - } - if (resultType && !checkForDisallowedESSymbolOperand(operator)) { - return resultType; - } - } - if (!resultType) { - reportOperatorError(); - return anyType; - } - if (operator === 57) { - checkAssignmentOperator(resultType); - } - return resultType; - case 25: - case 27: - case 28: - case 29: - if (!checkForDisallowedESSymbolOperand(operator)) { - return booleanType; - } - case 30: - case 31: - case 32: - case 33: - if (!isTypeAssignableTo(leftType, rightType) && !isTypeAssignableTo(rightType, leftType)) { - reportOperatorError(); - } - return booleanType; - case 91: - return checkInstanceOfExpression(left, right, leftType, rightType); - case 90: - return checkInExpression(left, right, leftType, rightType); - case 51: - return rightType; - case 52: - return getUnionType([leftType, rightType]); - case 56: - checkAssignmentOperator(rightType); - return getRegularTypeOfObjectLiteral(rightType); - case 24: - return rightType; - } - function checkForDisallowedESSymbolOperand(operator) { - var offendingSymbolOperand = someConstituentTypeHasKind(leftType, 16777216) ? left : - someConstituentTypeHasKind(rightType, 16777216) ? right : - undefined; - if (offendingSymbolOperand) { - error(offendingSymbolOperand, ts.Diagnostics.The_0_operator_cannot_be_applied_to_type_symbol, ts.tokenToString(operator)); - return false; - } - return true; - } - function getSuggestedBooleanOperator(operator) { - switch (operator) { - 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) { - var ok = checkReferenceExpression(left, ts.Diagnostics.Invalid_left_hand_side_of_assignment_expression, ts.Diagnostics.Left_hand_side_of_assignment_expression_cannot_be_a_constant); - if (ok) { - checkTypeAssignableTo(valueType, leftType, left, undefined); - } - } - } - function reportOperatorError() { - error(errorNode || operatorToken, ts.Diagnostics.Operator_0_cannot_be_applied_to_types_1_and_2, ts.tokenToString(operatorToken.kind), typeToString(leftType), typeToString(rightType)); - } - } - function isYieldExpressionInClass(node) { - var current = node; - var parent = node.parent; - while (parent) { - if (ts.isFunctionLike(parent) && current === parent.body) { - return false; - } - else if (ts.isClassLike(current)) { - return true; - } - current = parent; - parent = parent.parent; - } - return false; - } - function checkYieldExpression(node) { - if (produceDiagnostics) { - if (!(node.parserContextFlags & 2) || isYieldExpressionInClass(node)) { - grammarErrorOnFirstToken(node, ts.Diagnostics.A_yield_expression_is_only_allowed_in_a_generator_body); - } - if (isInParameterInitializerBeforeContainingFunction(node)) { - error(node, ts.Diagnostics.yield_expressions_cannot_be_used_in_a_parameter_initializer); - } - } - if (node.expression) { - var func = ts.getContainingFunction(node); - if (func && func.asteriskToken) { - var expressionType = checkExpressionCached(node.expression, undefined); - var expressionElementType; - var nodeIsYieldStar = !!node.asteriskToken; - if (nodeIsYieldStar) { - expressionElementType = checkElementTypeOfIterable(expressionType, node.expression); - } - if (func.type) { - var signatureElementType = getElementTypeOfIterableIterator(getTypeFromTypeNode(func.type)) || anyType; - if (nodeIsYieldStar) { - checkTypeAssignableTo(expressionElementType, signatureElementType, node.expression, undefined); - } - else { - checkTypeAssignableTo(expressionType, signatureElementType, node.expression, undefined); - } - } - } - } - return anyType; - } - function checkConditionalExpression(node, contextualMapper) { - checkExpression(node.condition); - var type1 = checkExpression(node.whenTrue, contextualMapper); - var type2 = checkExpression(node.whenFalse, contextualMapper); - return getUnionType([type1, type2]); - } - function checkTemplateExpression(node) { - ts.forEach(node.templateSpans, function (templateSpan) { - checkExpression(templateSpan.expression); - }); - return stringType; - } - function checkExpressionWithContextualType(node, contextualType, contextualMapper) { - var saveContextualType = node.contextualType; - node.contextualType = contextualType; - var result = checkExpression(node, contextualMapper); - node.contextualType = saveContextualType; - return result; - } - function checkExpressionCached(node, contextualMapper) { - var links = getNodeLinks(node); - if (!links.resolvedType) { - links.resolvedType = checkExpression(node, contextualMapper); - } - return links.resolvedType; - } - function checkPropertyAssignment(node, contextualMapper) { - if (node.name.kind === 136) { - checkComputedPropertyName(node.name); - } - return checkExpression(node.initializer, contextualMapper); - } - function checkObjectLiteralMethod(node, contextualMapper) { - checkGrammarMethod(node); - if (node.name.kind === 136) { - checkComputedPropertyName(node.name); - } - var uninstantiatedType = checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); - return instantiateTypeWithSingleGenericCallSignature(node, uninstantiatedType, contextualMapper); - } - function instantiateTypeWithSingleGenericCallSignature(node, type, contextualMapper) { - if (isInferentialContext(contextualMapper)) { - var signature = getSingleCallSignature(type); - if (signature && signature.typeParameters) { - var contextualType = getContextualType(node); - if (contextualType) { - var contextualSignature = getSingleCallSignature(contextualType); - if (contextualSignature && !contextualSignature.typeParameters) { - return getOrCreateTypeFromSignature(instantiateSignatureInContextOf(signature, contextualSignature, contextualMapper)); - } - } - } - } - return type; - } - function checkExpression(node, contextualMapper) { - var type; - if (node.kind === 135) { - type = checkQualifiedName(node); - } - else { - var uninstantiatedType = checkExpressionWorker(node, contextualMapper); - type = instantiateTypeWithSingleGenericCallSignature(node, uninstantiatedType, contextualMapper); - } - if (isConstEnumObjectType(type)) { - var ok = (node.parent.kind === 166 && node.parent.expression === node) || - (node.parent.kind === 167 && node.parent.expression === node) || - ((node.kind === 69 || node.kind === 135) && isInRightSideOfImportOrExportAssignment(node)); - if (!ok) { - error(node, ts.Diagnostics.const_enums_can_only_be_used_in_property_or_index_access_expressions_or_the_right_hand_side_of_an_import_declaration_or_export_assignment); - } - } - return type; - } - function checkNumericLiteral(node) { - checkGrammarNumericLiteral(node); - return numberType; - } - function checkExpressionWorker(node, contextualMapper) { - switch (node.kind) { - case 69: - return checkIdentifier(node); - case 97: - return checkThisExpression(node); - case 95: - return checkSuperExpression(node); - case 93: - return nullType; - case 99: - case 84: - return booleanType; - case 8: - return checkNumericLiteral(node); - case 183: - return checkTemplateExpression(node); - case 9: - case 11: - return stringType; - case 10: - return globalRegExpType; - case 164: - return checkArrayLiteral(node, contextualMapper); - case 165: - return checkObjectLiteral(node, contextualMapper); - case 166: - return checkPropertyAccessExpression(node); - case 167: - return checkIndexedAccess(node); - case 168: - case 169: - return checkCallExpression(node); - case 170: - return checkTaggedTemplateExpression(node); - case 172: - return checkExpression(node.expression, contextualMapper); - case 186: - return checkClassExpression(node); - case 173: - case 174: - return checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); - case 176: - return checkTypeOfExpression(node); - case 171: - case 189: - return checkAssertion(node); - case 175: - return checkDeleteExpression(node); - case 177: - return checkVoidExpression(node); - case 178: - return checkAwaitExpression(node); - case 179: - return checkPrefixUnaryExpression(node); - case 180: - return checkPostfixUnaryExpression(node); - case 181: - return checkBinaryExpression(node, contextualMapper); - case 182: - return checkConditionalExpression(node, contextualMapper); - case 185: - return checkSpreadElementExpression(node, contextualMapper); - case 187: - return undefinedType; - case 184: - return checkYieldExpression(node); - case 240: - return checkJsxExpression(node); - case 233: - return checkJsxElement(node); - case 234: - return checkJsxSelfClosingElement(node); - case 235: - ts.Debug.fail("Shouldn't ever directly check a JsxOpeningElement"); - } - return unknownType; - } - function checkTypeParameter(node) { - if (node.expression) { - grammarErrorOnFirstToken(node.expression, ts.Diagnostics.Type_expected); - } - checkSourceElement(node.constraint); - if (produceDiagnostics) { - checkTypeParameterHasIllegalReferencesInConstraint(node); - checkTypeNameIsReserved(node.name, ts.Diagnostics.Type_parameter_name_cannot_be_0); - } - } - function checkParameter(node) { - checkGrammarDecorators(node) || checkGrammarModifiers(node); - checkVariableLikeDeclaration(node); - var func = ts.getContainingFunction(node); - if (node.flags & 112) { - func = ts.getContainingFunction(node); - if (!(func.kind === 144 && ts.nodeIsPresent(func.body))) { - error(node, ts.Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation); - } - } - if (node.questionToken && ts.isBindingPattern(node.name) && func.body) { - error(node, ts.Diagnostics.A_binding_pattern_parameter_cannot_be_optional_in_an_implementation_signature); - } - if (node.dotDotDotToken && !ts.isBindingPattern(node.name) && !isArrayType(getTypeOfSymbol(node.symbol))) { - error(node, ts.Diagnostics.A_rest_parameter_must_be_of_an_array_type); - } - } - function isSyntacticallyValidGenerator(node) { - if (!node.asteriskToken || !node.body) { - return false; - } - return node.kind === 143 || - node.kind === 213 || - node.kind === 173; - } - function getTypePredicateParameterIndex(parameterList, parameter) { - if (parameterList) { - for (var i = 0; i < parameterList.length; i++) { - var param = parameterList[i]; - if (param.name.kind === 69 && - param.name.text === parameter.text) { - return i; - } - } - } - return -1; - } - function isInLegalTypePredicatePosition(node) { - switch (node.parent.kind) { - case 174: - case 147: - case 213: - case 173: - case 152: - case 143: - case 142: - return node === node.parent.type; - } - return false; - } - function checkSignatureDeclaration(node) { - if (node.kind === 149) { - checkGrammarIndexSignature(node); - } - else if (node.kind === 152 || node.kind === 213 || node.kind === 153 || - node.kind === 147 || node.kind === 144 || - node.kind === 148) { - checkGrammarFunctionLikeDeclaration(node); - } - checkTypeParameters(node.typeParameters); - ts.forEach(node.parameters, checkParameter); - if (node.type) { - if (node.type.kind === 150) { - var typePredicate = getSignatureFromDeclaration(node).typePredicate; - var typePredicateNode = node.type; - if (isInLegalTypePredicatePosition(typePredicateNode)) { - if (typePredicate.parameterIndex >= 0) { - if (node.parameters[typePredicate.parameterIndex].dotDotDotToken) { - error(typePredicateNode.parameterName, ts.Diagnostics.A_type_predicate_cannot_reference_a_rest_parameter); - } - else { - checkTypeAssignableTo(typePredicate.type, getTypeOfNode(node.parameters[typePredicate.parameterIndex]), typePredicateNode.type); - } - } - else if (typePredicateNode.parameterName) { - var hasReportedError = false; - for (var _i = 0, _a = node.parameters; _i < _a.length; _i++) { - var param = _a[_i]; - if (hasReportedError) { - break; - } - if (param.name.kind === 161 || - param.name.kind === 162) { - (function checkBindingPattern(pattern) { - for (var _i = 0, _a = pattern.elements; _i < _a.length; _i++) { - var element = _a[_i]; - if (element.name.kind === 69 && - element.name.text === typePredicate.parameterName) { - error(typePredicateNode.parameterName, ts.Diagnostics.A_type_predicate_cannot_reference_element_0_in_a_binding_pattern, typePredicate.parameterName); - hasReportedError = true; - break; - } - else if (element.name.kind === 162 || - element.name.kind === 161) { - checkBindingPattern(element.name); - } - } - })(param.name); - } - } - if (!hasReportedError) { - error(typePredicateNode.parameterName, ts.Diagnostics.Cannot_find_parameter_0, typePredicate.parameterName); - } - } - } - else { - error(typePredicateNode, ts.Diagnostics.A_type_predicate_is_only_allowed_in_return_type_position_for_functions_and_methods); - } - } - else { - checkSourceElement(node.type); - } - } - if (produceDiagnostics) { - checkCollisionWithArgumentsInGeneratedCode(node); - if (compilerOptions.noImplicitAny && !node.type) { - switch (node.kind) { - case 148: - error(node, ts.Diagnostics.Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); - break; - case 147: - error(node, ts.Diagnostics.Call_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); - break; - } - } - if (node.type) { - if (languageVersion >= 2 && isSyntacticallyValidGenerator(node)) { - var returnType = getTypeFromTypeNode(node.type); - if (returnType === voidType) { - error(node.type, ts.Diagnostics.A_generator_cannot_have_a_void_type_annotation); - } - else { - var generatorElementType = getElementTypeOfIterableIterator(returnType) || anyType; - var iterableIteratorInstantiation = createIterableIteratorType(generatorElementType); - checkTypeAssignableTo(iterableIteratorInstantiation, returnType, node.type); - } - } - } - } - checkSpecializedSignatureDeclaration(node); - } - function checkTypeForDuplicateIndexSignatures(node) { - if (node.kind === 215) { - var nodeSymbol = getSymbolOfNode(node); - if (nodeSymbol.declarations.length > 0 && nodeSymbol.declarations[0] !== node) { - return; - } - } - var indexSymbol = getIndexSymbol(getSymbolOfNode(node)); - if (indexSymbol) { - var seenNumericIndexer = false; - var seenStringIndexer = false; - for (var _i = 0, _a = indexSymbol.declarations; _i < _a.length; _i++) { - var decl = _a[_i]; - var declaration = decl; - if (declaration.parameters.length === 1 && declaration.parameters[0].type) { - switch (declaration.parameters[0].type.kind) { - case 130: - if (!seenStringIndexer) { - seenStringIndexer = true; - } - else { - error(declaration, ts.Diagnostics.Duplicate_string_index_signature); - } - break; - case 128: - if (!seenNumericIndexer) { - seenNumericIndexer = true; - } - else { - error(declaration, ts.Diagnostics.Duplicate_number_index_signature); - } - break; - } - } - } - } - } - function checkPropertyDeclaration(node) { - checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarProperty(node) || checkGrammarComputedPropertyName(node.name); - checkVariableLikeDeclaration(node); - } - function checkMethodDeclaration(node) { - checkGrammarMethod(node) || checkGrammarComputedPropertyName(node.name); - checkFunctionLikeDeclaration(node); - if (node.flags & 256 && node.body) { - error(node, ts.Diagnostics.Method_0_cannot_have_an_implementation_because_it_is_marked_abstract, ts.declarationNameToString(node.name)); - } - } - function checkConstructorDeclaration(node) { - checkSignatureDeclaration(node); - checkGrammarConstructorTypeParameters(node) || checkGrammarConstructorTypeAnnotation(node); - checkSourceElement(node.body); - var symbol = getSymbolOfNode(node); - var firstDeclaration = ts.getDeclarationOfKind(symbol, node.kind); - if (node === firstDeclaration) { - checkFunctionOrConstructorSymbol(symbol); - } - if (ts.nodeIsMissing(node.body)) { - return; - } - if (!produceDiagnostics) { - return; - } - function isSuperCallExpression(n) { - return n.kind === 168 && n.expression.kind === 95; - } - function containsSuperCallAsComputedPropertyName(n) { - return n.name && containsSuperCall(n.name); - } - function containsSuperCall(n) { - if (isSuperCallExpression(n)) { - return true; - } - else if (ts.isFunctionLike(n)) { - return false; - } - else if (ts.isClassLike(n)) { - return ts.forEach(n.members, containsSuperCallAsComputedPropertyName); - } - return ts.forEachChild(n, containsSuperCall); - } - function markThisReferencesAsErrors(n) { - if (n.kind === 97) { - error(n, ts.Diagnostics.this_cannot_be_referenced_in_current_location); - } - else if (n.kind !== 173 && n.kind !== 213) { - ts.forEachChild(n, markThisReferencesAsErrors); - } - } - function isInstancePropertyWithInitializer(n) { - return n.kind === 141 && - !(n.flags & 128) && - !!n.initializer; - } - var containingClassDecl = node.parent; - if (ts.getClassExtendsHeritageClauseElement(containingClassDecl)) { - var containingClassSymbol = getSymbolOfNode(containingClassDecl); - var containingClassInstanceType = getDeclaredTypeOfSymbol(containingClassSymbol); - var baseConstructorType = getBaseConstructorTypeOfClass(containingClassInstanceType); - if (containsSuperCall(node.body)) { - if (baseConstructorType === nullType) { - error(node, ts.Diagnostics.A_constructor_cannot_contain_a_super_call_when_its_class_extends_null); - } - var superCallShouldBeFirst = ts.forEach(node.parent.members, isInstancePropertyWithInitializer) || - ts.forEach(node.parameters, function (p) { return p.flags & (16 | 32 | 64); }); - if (superCallShouldBeFirst) { - var statements = node.body.statements; - var superCallStatement; - for (var _i = 0; _i < statements.length; _i++) { - var statement = statements[_i]; - if (statement.kind === 195 && isSuperCallExpression(statement.expression)) { - superCallStatement = statement; - break; - } - if (!ts.isPrologueDirective(statement)) { - break; - } - } - if (!superCallStatement) { - error(node, ts.Diagnostics.A_super_call_must_be_the_first_statement_in_the_constructor_when_a_class_contains_initialized_properties_or_has_parameter_properties); - } - else { - markThisReferencesAsErrors(superCallStatement.expression); - } - } - } - else if (baseConstructorType !== nullType) { - error(node, ts.Diagnostics.Constructors_for_derived_classes_must_contain_a_super_call); - } - } - } - function checkAccessorDeclaration(node) { - if (produceDiagnostics) { - checkGrammarFunctionLikeDeclaration(node) || checkGrammarAccessor(node) || checkGrammarComputedPropertyName(node.name); - if (node.kind === 145) { - if (!ts.isInAmbientContext(node) && ts.nodeIsPresent(node.body) && !(bodyContainsAReturnStatement(node.body) || bodyContainsSingleThrowStatement(node.body))) { - error(node.name, ts.Diagnostics.A_get_accessor_must_return_a_value_or_consist_of_a_single_throw_statement); - } - } - if (!ts.hasDynamicName(node)) { - var otherKind = node.kind === 145 ? 146 : 145; - var otherAccessor = ts.getDeclarationOfKind(node.symbol, otherKind); - if (otherAccessor) { - if (((node.flags & 112) !== (otherAccessor.flags & 112))) { - error(node.name, ts.Diagnostics.Getter_and_setter_accessors_do_not_agree_in_visibility); - } - var currentAccessorType = getAnnotatedAccessorType(node); - var otherAccessorType = getAnnotatedAccessorType(otherAccessor); - if (currentAccessorType && otherAccessorType) { - if (!isTypeIdenticalTo(currentAccessorType, otherAccessorType)) { - error(node, ts.Diagnostics.get_and_set_accessor_must_have_the_same_type); - } - } - } - } - getTypeOfAccessors(getSymbolOfNode(node)); - } - checkFunctionLikeDeclaration(node); - } - function checkMissingDeclaration(node) { - checkDecorators(node); - } - function checkTypeArgumentConstraints(typeParameters, typeArguments) { - var result = true; - for (var i = 0; i < typeParameters.length; i++) { - var constraint = getConstraintOfTypeParameter(typeParameters[i]); - if (constraint) { - var typeArgument = typeArguments[i]; - result = result && checkTypeAssignableTo(getTypeFromTypeNode(typeArgument), constraint, typeArgument, ts.Diagnostics.Type_0_does_not_satisfy_the_constraint_1); - } - } - return result; - } - function checkTypeReferenceNode(node) { - checkGrammarTypeArguments(node, node.typeArguments); - var type = getTypeFromTypeReference(node); - if (type !== unknownType && node.typeArguments) { - ts.forEach(node.typeArguments, checkSourceElement); - if (produceDiagnostics) { - var symbol = getNodeLinks(node).resolvedSymbol; - var typeParameters = symbol.flags & 524288 ? getSymbolLinks(symbol).typeParameters : type.target.localTypeParameters; - checkTypeArgumentConstraints(typeParameters, node.typeArguments); - } - } - } - function checkTypeQuery(node) { - getTypeFromTypeQueryNode(node); - } - function checkTypeLiteral(node) { - ts.forEach(node.members, checkSourceElement); - if (produceDiagnostics) { - var type = getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node); - checkIndexConstraints(type); - checkTypeForDuplicateIndexSignatures(node); - } - } - function checkArrayType(node) { - checkSourceElement(node.elementType); - } - function checkTupleType(node) { - var hasErrorFromDisallowedTrailingComma = checkGrammarForDisallowedTrailingComma(node.elementTypes); - if (!hasErrorFromDisallowedTrailingComma && node.elementTypes.length === 0) { - grammarErrorOnNode(node, ts.Diagnostics.A_tuple_type_element_list_cannot_be_empty); - } - ts.forEach(node.elementTypes, checkSourceElement); - } - function checkUnionOrIntersectionType(node) { - ts.forEach(node.types, checkSourceElement); - } - function isPrivateWithinAmbient(node) { - return (node.flags & 32) && ts.isInAmbientContext(node); - } - function checkSpecializedSignatureDeclaration(signatureDeclarationNode) { - if (!produceDiagnostics) { - return; - } - var signature = getSignatureFromDeclaration(signatureDeclarationNode); - if (!signature.hasStringLiterals) { - return; - } - if (ts.nodeIsPresent(signatureDeclarationNode.body)) { - error(signatureDeclarationNode, ts.Diagnostics.A_signature_with_an_implementation_cannot_use_a_string_literal_type); - return; - } - var signaturesToCheck; - if (!signatureDeclarationNode.name && signatureDeclarationNode.parent && signatureDeclarationNode.parent.kind === 215) { - ts.Debug.assert(signatureDeclarationNode.kind === 147 || signatureDeclarationNode.kind === 148); - var signatureKind = signatureDeclarationNode.kind === 147 ? 0 : 1; - var containingSymbol = getSymbolOfNode(signatureDeclarationNode.parent); - var containingType = getDeclaredTypeOfSymbol(containingSymbol); - signaturesToCheck = getSignaturesOfType(containingType, signatureKind); - } - else { - signaturesToCheck = getSignaturesOfSymbol(getSymbolOfNode(signatureDeclarationNode)); - } - for (var _i = 0; _i < signaturesToCheck.length; _i++) { - var otherSignature = signaturesToCheck[_i]; - if (!otherSignature.hasStringLiterals && isSignatureAssignableTo(signature, otherSignature)) { - return; - } - } - error(signatureDeclarationNode, ts.Diagnostics.Specialized_overload_signature_is_not_assignable_to_any_non_specialized_signature); - } - function getEffectiveDeclarationFlags(n, flagsToCheck) { - var flags = ts.getCombinedNodeFlags(n); - if (n.parent.kind !== 215 && - n.parent.kind !== 214 && - n.parent.kind !== 186 && - ts.isInAmbientContext(n)) { - if (!(flags & 2)) { - flags |= 1; - } - flags |= 2; - } - return flags & flagsToCheck; - } - function checkFunctionOrConstructorSymbol(symbol) { - if (!produceDiagnostics) { - return; - } - function getCanonicalOverload(overloads, implementation) { - var implementationSharesContainerWithFirstOverload = implementation !== undefined && implementation.parent === overloads[0].parent; - return implementationSharesContainerWithFirstOverload ? implementation : overloads[0]; - } - function checkFlagAgreementBetweenOverloads(overloads, implementation, flagsToCheck, someOverloadFlags, allOverloadFlags) { - var someButNotAllOverloadFlags = someOverloadFlags ^ allOverloadFlags; - if (someButNotAllOverloadFlags !== 0) { - var canonicalFlags = getEffectiveDeclarationFlags(getCanonicalOverload(overloads, implementation), flagsToCheck); - ts.forEach(overloads, function (o) { - var deviation = getEffectiveDeclarationFlags(o, flagsToCheck) ^ canonicalFlags; - if (deviation & 1) { - error(o.name, ts.Diagnostics.Overload_signatures_must_all_be_exported_or_not_exported); - } - else if (deviation & 2) { - error(o.name, ts.Diagnostics.Overload_signatures_must_all_be_ambient_or_non_ambient); - } - else if (deviation & (32 | 64)) { - error(o.name, ts.Diagnostics.Overload_signatures_must_all_be_public_private_or_protected); - } - else if (deviation & 256) { - error(o.name, ts.Diagnostics.Overload_signatures_must_all_be_abstract_or_not_abstract); - } - }); - } - } - function checkQuestionTokenAgreementBetweenOverloads(overloads, implementation, someHaveQuestionToken, allHaveQuestionToken) { - if (someHaveQuestionToken !== allHaveQuestionToken) { - var canonicalHasQuestionToken = ts.hasQuestionToken(getCanonicalOverload(overloads, implementation)); - ts.forEach(overloads, function (o) { - var deviation = ts.hasQuestionToken(o) !== canonicalHasQuestionToken; - if (deviation) { - error(o.name, ts.Diagnostics.Overload_signatures_must_all_be_optional_or_required); - } - }); - } - } - var flagsToCheck = 1 | 2 | 32 | 64 | 256; - var someNodeFlags = 0; - var allNodeFlags = flagsToCheck; - var someHaveQuestionToken = false; - var allHaveQuestionToken = true; - var hasOverloads = false; - var bodyDeclaration; - var lastSeenNonAmbientDeclaration; - var previousDeclaration; - var declarations = symbol.declarations; - var isConstructor = (symbol.flags & 16384) !== 0; - function reportImplementationExpectedError(node) { - if (node.name && ts.nodeIsMissing(node.name)) { - return; - } - var seen = false; - var subsequentNode = ts.forEachChild(node.parent, function (c) { - if (seen) { - return c; - } - else { - seen = c === node; - } - }); - if (subsequentNode) { - if (subsequentNode.kind === node.kind) { - var errorNode_1 = subsequentNode.name || subsequentNode; - if (node.name && subsequentNode.name && node.name.text === subsequentNode.name.text) { - ts.Debug.assert(node.kind === 143 || node.kind === 142); - ts.Debug.assert((node.flags & 128) !== (subsequentNode.flags & 128)); - var diagnostic = node.flags & 128 ? ts.Diagnostics.Function_overload_must_be_static : ts.Diagnostics.Function_overload_must_not_be_static; - error(errorNode_1, diagnostic); - return; - } - else if (ts.nodeIsPresent(subsequentNode.body)) { - error(errorNode_1, ts.Diagnostics.Function_implementation_name_must_be_0, ts.declarationNameToString(node.name)); - return; - } - } - } - var errorNode = node.name || node; - if (isConstructor) { - error(errorNode, ts.Diagnostics.Constructor_implementation_is_missing); - } - else { - if (node.flags & 256) { - error(errorNode, ts.Diagnostics.All_declarations_of_an_abstract_method_must_be_consecutive); - } - else { - error(errorNode, ts.Diagnostics.Function_implementation_is_missing_or_not_immediately_following_the_declaration); - } - } - } - var isExportSymbolInsideModule = symbol.parent && symbol.parent.flags & 1536; - var duplicateFunctionDeclaration = false; - var multipleConstructorImplementation = false; - for (var _i = 0; _i < declarations.length; _i++) { - var current = declarations[_i]; - var node = current; - var inAmbientContext = ts.isInAmbientContext(node); - var inAmbientContextOrInterface = node.parent.kind === 215 || node.parent.kind === 155 || inAmbientContext; - if (inAmbientContextOrInterface) { - previousDeclaration = undefined; - } - if (node.kind === 213 || node.kind === 143 || node.kind === 142 || node.kind === 144) { - var currentNodeFlags = getEffectiveDeclarationFlags(node, flagsToCheck); - someNodeFlags |= currentNodeFlags; - allNodeFlags &= currentNodeFlags; - someHaveQuestionToken = someHaveQuestionToken || ts.hasQuestionToken(node); - allHaveQuestionToken = allHaveQuestionToken && ts.hasQuestionToken(node); - if (ts.nodeIsPresent(node.body) && bodyDeclaration) { - if (isConstructor) { - multipleConstructorImplementation = true; - } - else { - duplicateFunctionDeclaration = true; - } - } - else if (!isExportSymbolInsideModule && previousDeclaration && previousDeclaration.parent === node.parent && previousDeclaration.end !== node.pos) { - reportImplementationExpectedError(previousDeclaration); - } - if (ts.nodeIsPresent(node.body)) { - if (!bodyDeclaration) { - bodyDeclaration = node; - } - } - else { - hasOverloads = true; - } - previousDeclaration = node; - if (!inAmbientContextOrInterface) { - lastSeenNonAmbientDeclaration = node; - } - } - } - if (multipleConstructorImplementation) { - ts.forEach(declarations, function (declaration) { - error(declaration, ts.Diagnostics.Multiple_constructor_implementations_are_not_allowed); - }); - } - if (duplicateFunctionDeclaration) { - ts.forEach(declarations, function (declaration) { - error(declaration.name, ts.Diagnostics.Duplicate_function_implementation); - }); - } - if (!isExportSymbolInsideModule && lastSeenNonAmbientDeclaration && !lastSeenNonAmbientDeclaration.body && - !(lastSeenNonAmbientDeclaration.flags & 256)) { - reportImplementationExpectedError(lastSeenNonAmbientDeclaration); - } - if (hasOverloads) { - checkFlagAgreementBetweenOverloads(declarations, bodyDeclaration, flagsToCheck, someNodeFlags, allNodeFlags); - checkQuestionTokenAgreementBetweenOverloads(declarations, bodyDeclaration, someHaveQuestionToken, allHaveQuestionToken); - if (bodyDeclaration) { - var signatures = getSignaturesOfSymbol(symbol); - var bodySignature = getSignatureFromDeclaration(bodyDeclaration); - if (!bodySignature.hasStringLiterals) { - for (var _a = 0; _a < signatures.length; _a++) { - var signature = signatures[_a]; - if (!signature.hasStringLiterals && !isSignatureAssignableTo(bodySignature, signature)) { - error(signature.declaration, ts.Diagnostics.Overload_signature_is_not_compatible_with_function_implementation); - break; - } - } - } - } - } - } - function checkExportsOnMergedDeclarations(node) { - if (!produceDiagnostics) { - return; - } - var symbol = node.localSymbol; - if (!symbol) { - symbol = getSymbolOfNode(node); - if (!(symbol.flags & 7340032)) { - return; - } - } - if (ts.getDeclarationOfKind(symbol, node.kind) !== node) { - return; - } - var exportedDeclarationSpaces = 0; - var nonExportedDeclarationSpaces = 0; - var defaultExportedDeclarationSpaces = 0; - for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { - var d = _a[_i]; - var declarationSpaces = getDeclarationSpaces(d); - var effectiveDeclarationFlags = getEffectiveDeclarationFlags(d, 1 | 1024); - if (effectiveDeclarationFlags & 1) { - if (effectiveDeclarationFlags & 1024) { - defaultExportedDeclarationSpaces |= declarationSpaces; - } - else { - exportedDeclarationSpaces |= declarationSpaces; - } - } - else { - nonExportedDeclarationSpaces |= declarationSpaces; - } - } - var nonDefaultExportedDeclarationSpaces = exportedDeclarationSpaces | nonExportedDeclarationSpaces; - var commonDeclarationSpacesForExportsAndLocals = exportedDeclarationSpaces & nonExportedDeclarationSpaces; - var commonDeclarationSpacesForDefaultAndNonDefault = defaultExportedDeclarationSpaces & nonDefaultExportedDeclarationSpaces; - if (commonDeclarationSpacesForExportsAndLocals || commonDeclarationSpacesForDefaultAndNonDefault) { - for (var _b = 0, _c = symbol.declarations; _b < _c.length; _b++) { - var d = _c[_b]; - var declarationSpaces = getDeclarationSpaces(d); - if (declarationSpaces & commonDeclarationSpacesForDefaultAndNonDefault) { - error(d.name, ts.Diagnostics.Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_default_0_declaration_instead, ts.declarationNameToString(d.name)); - } - else if (declarationSpaces & commonDeclarationSpacesForExportsAndLocals) { - error(d.name, ts.Diagnostics.Individual_declarations_in_merged_declaration_0_must_be_all_exported_or_all_local, ts.declarationNameToString(d.name)); - } - } - } - function getDeclarationSpaces(d) { - switch (d.kind) { - case 215: - return 2097152; - case 218: - return d.name.kind === 9 || ts.getModuleInstanceState(d) !== 0 - ? 4194304 | 1048576 - : 4194304; - case 214: - case 217: - return 2097152 | 1048576; - case 221: - var result = 0; - var target = resolveAlias(getSymbolOfNode(d)); - ts.forEach(target.declarations, function (d) { result |= getDeclarationSpaces(d); }); - return result; - default: - return 1048576; - } - } - } - function checkNonThenableType(type, location, message) { - type = getWidenedType(type); - if (!isTypeAny(type) && isTypeAssignableTo(type, getGlobalThenableType())) { - if (location) { - if (!message) { - message = ts.Diagnostics.Operand_for_await_does_not_have_a_valid_callable_then_member; - } - error(location, message); - } - return unknownType; - } - return type; - } - function getPromisedType(promise) { - if (promise.flags & 1) { - return undefined; - } - if ((promise.flags & 4096) && promise.target === tryGetGlobalPromiseType()) { - return promise.typeArguments[0]; - } - var globalPromiseLikeType = getInstantiatedGlobalPromiseLikeType(); - if (globalPromiseLikeType === emptyObjectType || !isTypeAssignableTo(promise, globalPromiseLikeType)) { - return undefined; - } - var thenFunction = getTypeOfPropertyOfType(promise, "then"); - if (thenFunction && (thenFunction.flags & 1)) { - return undefined; - } - var thenSignatures = thenFunction ? getSignaturesOfType(thenFunction, 0) : emptyArray; - if (thenSignatures.length === 0) { - return undefined; - } - var onfulfilledParameterType = getUnionType(ts.map(thenSignatures, getTypeOfFirstParameterOfSignature)); - if (onfulfilledParameterType.flags & 1) { - return undefined; - } - var onfulfilledParameterSignatures = getSignaturesOfType(onfulfilledParameterType, 0); - if (onfulfilledParameterSignatures.length === 0) { - return undefined; - } - var valueParameterType = getUnionType(ts.map(onfulfilledParameterSignatures, getTypeOfFirstParameterOfSignature)); - return valueParameterType; - } - function getTypeOfFirstParameterOfSignature(signature) { - return getTypeAtPosition(signature, 0); - } - function getAwaitedType(type) { - return checkAwaitedType(type, undefined, undefined); - } - function checkAwaitedType(type, location, message) { - return checkAwaitedTypeWorker(type); - function checkAwaitedTypeWorker(type) { - if (type.flags & 16384) { - var types = []; - for (var _i = 0, _a = type.types; _i < _a.length; _i++) { - var constituentType = _a[_i]; - types.push(checkAwaitedTypeWorker(constituentType)); - } - return getUnionType(types); - } - else { - var promisedType = getPromisedType(type); - if (promisedType === undefined) { - return checkNonThenableType(type, location, message); - } - else { - if (type.id === promisedType.id || awaitedTypeStack.indexOf(promisedType.id) >= 0) { - if (location) { - error(location, ts.Diagnostics._0_is_referenced_directly_or_indirectly_in_the_fulfillment_callback_of_its_own_then_method, symbolToString(type.symbol)); - } - return unknownType; - } - awaitedTypeStack.push(type.id); - var awaitedType = checkAwaitedTypeWorker(promisedType); - awaitedTypeStack.pop(); - return awaitedType; - } - } - } - } - function checkAsyncFunctionReturnType(node) { - var globalPromiseConstructorLikeType = getGlobalPromiseConstructorLikeType(); - if (globalPromiseConstructorLikeType === emptyObjectType) { - return unknownType; - } - var promiseType = getTypeFromTypeNode(node.type); - if (promiseType === unknownType && compilerOptions.isolatedModules) { - return unknownType; - } - var promiseConstructor = getMergedSymbol(promiseType.symbol); - if (!promiseConstructor || !symbolIsValue(promiseConstructor)) { - error(node, ts.Diagnostics.Type_0_is_not_a_valid_async_function_return_type, typeToString(promiseType)); - return unknownType; - } - var promiseConstructorType = getTypeOfSymbol(promiseConstructor); - if (!checkTypeAssignableTo(promiseConstructorType, globalPromiseConstructorLikeType, node, ts.Diagnostics.Type_0_is_not_a_valid_async_function_return_type)) { - return unknownType; - } - var promiseName = ts.getEntityNameFromTypeNode(node.type); - var root = getFirstIdentifier(promiseName); - var rootSymbol = getSymbol(node.locals, root.text, 107455); - if (rootSymbol) { - error(rootSymbol.valueDeclaration, ts.Diagnostics.Duplicate_identifier_0_Compiler_uses_declaration_1_to_support_async_functions, root.text, getFullyQualifiedName(promiseConstructor)); - return unknownType; - } - return checkAwaitedType(promiseType, node, ts.Diagnostics.An_async_function_or_method_must_have_a_valid_awaitable_return_type); - } - function checkDecorator(node) { - var signature = getResolvedSignature(node); - var returnType = getReturnTypeOfSignature(signature); - if (returnType.flags & 1) { - return; - } - var expectedReturnType; - var headMessage = getDiagnosticHeadMessageForDecoratorResolution(node); - var errorInfo; - switch (node.parent.kind) { - case 214: - var classSymbol = getSymbolOfNode(node.parent); - var classConstructorType = getTypeOfSymbol(classSymbol); - expectedReturnType = getUnionType([classConstructorType, voidType]); - break; - case 138: - expectedReturnType = voidType; - errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.The_return_type_of_a_parameter_decorator_function_must_be_either_void_or_any); - break; - case 141: - expectedReturnType = voidType; - errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.The_return_type_of_a_property_decorator_function_must_be_either_void_or_any); - break; - case 143: - case 145: - case 146: - var methodType = getTypeOfNode(node.parent); - var descriptorType = createTypedPropertyDescriptorType(methodType); - expectedReturnType = getUnionType([descriptorType, voidType]); - break; - } - checkTypeAssignableTo(returnType, expectedReturnType, node, headMessage, errorInfo); - } - function checkTypeNodeAsExpression(node) { - if (node && node.kind === 151) { - var root = getFirstIdentifier(node.typeName); - var meaning = root.parent.kind === 151 ? 793056 : 1536; - var rootSymbol = resolveName(root, root.text, meaning | 8388608, undefined, undefined); - if (rootSymbol && rootSymbol.flags & 8388608) { - var aliasTarget = resolveAlias(rootSymbol); - if (aliasTarget.flags & 107455 && !isConstEnumOrConstEnumOnlyModule(resolveAlias(rootSymbol))) { - markAliasSymbolAsReferenced(rootSymbol); - } - } - } - } - function checkTypeAnnotationAsExpression(node) { - switch (node.kind) { - case 141: - checkTypeNodeAsExpression(node.type); - break; - case 138: - checkTypeNodeAsExpression(node.type); - break; - case 143: - checkTypeNodeAsExpression(node.type); - break; - case 145: - checkTypeNodeAsExpression(node.type); - break; - case 146: - checkTypeNodeAsExpression(ts.getSetAccessorTypeAnnotationNode(node)); - break; - } - } - function checkParameterTypeAnnotationsAsExpressions(node) { - for (var _i = 0, _a = node.parameters; _i < _a.length; _i++) { - var parameter = _a[_i]; - checkTypeAnnotationAsExpression(parameter); - } - } - function checkDecorators(node) { - if (!node.decorators) { - return; - } - if (!ts.nodeCanBeDecorated(node)) { - return; - } - if (!compilerOptions.experimentalDecorators) { - error(node, ts.Diagnostics.Experimental_support_for_decorators_is_a_feature_that_is_subject_to_change_in_a_future_release_Specify_experimentalDecorators_to_remove_this_warning); - } - if (compilerOptions.emitDecoratorMetadata) { - switch (node.kind) { - case 214: - var constructor = ts.getFirstConstructorWithBody(node); - if (constructor) { - checkParameterTypeAnnotationsAsExpressions(constructor); - } - break; - case 143: - checkParameterTypeAnnotationsAsExpressions(node); - case 146: - case 145: - case 141: - case 138: - checkTypeAnnotationAsExpression(node); - break; - } - } - emitDecorate = true; - if (node.kind === 138) { - emitParam = true; - } - ts.forEach(node.decorators, checkDecorator); - } - function checkFunctionDeclaration(node) { - if (produceDiagnostics) { - checkFunctionLikeDeclaration(node) || checkGrammarForGenerator(node); - checkCollisionWithCapturedSuperVariable(node, node.name); - checkCollisionWithCapturedThisVariable(node, node.name); - checkCollisionWithRequireExportsInGeneratedCode(node, node.name); - } - } - function checkFunctionLikeDeclaration(node) { - checkDecorators(node); - checkSignatureDeclaration(node); - var isAsync = ts.isAsyncFunctionLike(node); - if (isAsync) { - emitAwaiter = true; - } - if (node.name && node.name.kind === 136) { - checkComputedPropertyName(node.name); - } - if (!ts.hasDynamicName(node)) { - var symbol = getSymbolOfNode(node); - var localSymbol = node.localSymbol || symbol; - var firstDeclaration = ts.getDeclarationOfKind(localSymbol, node.kind); - if (node === firstDeclaration) { - checkFunctionOrConstructorSymbol(localSymbol); - } - if (symbol.parent) { - if (ts.getDeclarationOfKind(symbol, node.kind) === node) { - checkFunctionOrConstructorSymbol(symbol); - } - } - } - checkSourceElement(node.body); - if (node.type && !isAccessor(node.kind) && !node.asteriskToken) { - var returnType = getTypeFromTypeNode(node.type); - var promisedType; - if (isAsync) { - promisedType = checkAsyncFunctionReturnType(node); - } - checkIfNonVoidFunctionHasReturnExpressionsOrSingleThrowStatment(node, isAsync ? promisedType : returnType); - } - if (produceDiagnostics && !node.type) { - if (compilerOptions.noImplicitAny && ts.nodeIsMissing(node.body) && !isPrivateWithinAmbient(node)) { - reportImplicitAnyError(node, anyType); - } - if (node.asteriskToken && ts.nodeIsPresent(node.body)) { - getReturnTypeOfSignature(getSignatureFromDeclaration(node)); - } - } - } - function checkBlock(node) { - if (node.kind === 192) { - checkGrammarStatementInAmbientContext(node); - } - ts.forEach(node.statements, checkSourceElement); - if (ts.isFunctionBlock(node) || node.kind === 219) { - checkFunctionAndClassExpressionBodies(node); - } - } - function checkCollisionWithArgumentsInGeneratedCode(node) { - if (!ts.hasRestParameter(node) || ts.isInAmbientContext(node) || ts.nodeIsMissing(node.body)) { - return; - } - ts.forEach(node.parameters, function (p) { - if (p.name && !ts.isBindingPattern(p.name) && p.name.text === argumentsSymbol.name) { - error(p, ts.Diagnostics.Duplicate_identifier_arguments_Compiler_uses_arguments_to_initialize_rest_parameters); - } - }); - } - function needCollisionCheckForIdentifier(node, identifier, name) { - if (!(identifier && identifier.text === name)) { - return false; - } - if (node.kind === 141 || - node.kind === 140 || - node.kind === 143 || - node.kind === 142 || - node.kind === 145 || - node.kind === 146) { - return false; - } - if (ts.isInAmbientContext(node)) { - return false; - } - var root = ts.getRootDeclaration(node); - if (root.kind === 138 && ts.nodeIsMissing(root.parent.body)) { - return false; - } - return true; - } - function checkCollisionWithCapturedThisVariable(node, name) { - if (needCollisionCheckForIdentifier(node, name, "_this")) { - potentialThisCollisions.push(node); - } - } - function checkIfThisIsCapturedInEnclosingScope(node) { - var current = node; - while (current) { - if (getNodeCheckFlags(current) & 4) { - var isDeclaration_1 = node.kind !== 69; - if (isDeclaration_1) { - error(node.name, ts.Diagnostics.Duplicate_identifier_this_Compiler_uses_variable_declaration_this_to_capture_this_reference); - } - else { - error(node, ts.Diagnostics.Expression_resolves_to_variable_declaration_this_that_compiler_uses_to_capture_this_reference); - } - return; - } - current = current.parent; - } - } - function checkCollisionWithCapturedSuperVariable(node, name) { - if (!needCollisionCheckForIdentifier(node, name, "_super")) { - return; - } - var enclosingClass = ts.getContainingClass(node); - if (!enclosingClass || ts.isInAmbientContext(enclosingClass)) { - return; - } - if (ts.getClassExtendsHeritageClauseElement(enclosingClass)) { - var isDeclaration_2 = node.kind !== 69; - if (isDeclaration_2) { - error(node, ts.Diagnostics.Duplicate_identifier_super_Compiler_uses_super_to_capture_base_class_reference); - } - else { - error(node, ts.Diagnostics.Expression_resolves_to_super_that_compiler_uses_to_capture_base_class_reference); - } - } - } - function checkCollisionWithRequireExportsInGeneratedCode(node, name) { - if (!needCollisionCheckForIdentifier(node, name, "require") && !needCollisionCheckForIdentifier(node, name, "exports")) { - return; - } - if (node.kind === 218 && ts.getModuleInstanceState(node) !== 1) { - return; - } - var parent = getDeclarationContainer(node); - if (parent.kind === 248 && ts.isExternalModule(parent)) { - error(name, ts.Diagnostics.Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module, ts.declarationNameToString(name), ts.declarationNameToString(name)); - } - } - function checkVarDeclaredNamesNotShadowed(node) { - if ((ts.getCombinedNodeFlags(node) & 49152) !== 0 || ts.isParameterDeclaration(node)) { - return; - } - if (node.kind === 211 && !node.initializer) { - return; - } - var symbol = getSymbolOfNode(node); - if (symbol.flags & 1) { - var localDeclarationSymbol = resolveName(node, node.name.text, 3, undefined, undefined); - if (localDeclarationSymbol && - localDeclarationSymbol !== symbol && - localDeclarationSymbol.flags & 2) { - if (getDeclarationFlagsFromSymbol(localDeclarationSymbol) & 49152) { - var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 212); - var container = varDeclList.parent.kind === 193 && varDeclList.parent.parent - ? varDeclList.parent.parent - : undefined; - var namesShareScope = container && - (container.kind === 192 && ts.isFunctionLike(container.parent) || - container.kind === 219 || - container.kind === 218 || - container.kind === 248); - if (!namesShareScope) { - var name_14 = symbolToString(localDeclarationSymbol); - error(node, ts.Diagnostics.Cannot_initialize_outer_scoped_variable_0_in_the_same_scope_as_block_scoped_declaration_1, name_14, name_14); - } - } - } - } - } - function checkParameterInitializer(node) { - if (ts.getRootDeclaration(node).kind !== 138) { - return; - } - var func = ts.getContainingFunction(node); - visit(node.initializer); - function visit(n) { - if (n.kind === 69) { - var referencedSymbol = getNodeLinks(n).resolvedSymbol; - if (referencedSymbol && referencedSymbol !== unknownSymbol && getSymbol(func.locals, referencedSymbol.name, 107455) === referencedSymbol) { - if (referencedSymbol.valueDeclaration.kind === 138) { - if (referencedSymbol.valueDeclaration === node) { - error(n, ts.Diagnostics.Parameter_0_cannot_be_referenced_in_its_initializer, ts.declarationNameToString(node.name)); - return; - } - if (referencedSymbol.valueDeclaration.pos < node.pos) { - return; - } - } - error(n, ts.Diagnostics.Initializer_of_parameter_0_cannot_reference_identifier_1_declared_after_it, ts.declarationNameToString(node.name), ts.declarationNameToString(n)); - } - } - else { - ts.forEachChild(n, visit); - } - } - } - function checkVariableLikeDeclaration(node) { - checkDecorators(node); - checkSourceElement(node.type); - if (node.name.kind === 136) { - checkComputedPropertyName(node.name); - if (node.initializer) { - checkExpressionCached(node.initializer); - } - } - if (ts.isBindingPattern(node.name)) { - ts.forEach(node.name.elements, checkSourceElement); - } - if (node.initializer && ts.getRootDeclaration(node).kind === 138 && ts.nodeIsMissing(ts.getContainingFunction(node).body)) { - error(node, ts.Diagnostics.A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation); - return; - } - if (ts.isBindingPattern(node.name)) { - if (node.initializer) { - checkTypeAssignableTo(checkExpressionCached(node.initializer), getWidenedTypeForVariableLikeDeclaration(node), node, undefined); - checkParameterInitializer(node); - } - return; - } - var symbol = getSymbolOfNode(node); - var type = getTypeOfVariableOrParameterOrProperty(symbol); - if (node === symbol.valueDeclaration) { - if (node.initializer) { - checkTypeAssignableTo(checkExpressionCached(node.initializer), type, node, undefined); - checkParameterInitializer(node); - } - } - else { - var declarationType = 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)); - } - if (node.initializer) { - checkTypeAssignableTo(checkExpressionCached(node.initializer), declarationType, node, undefined); - } - } - if (node.kind !== 141 && node.kind !== 140) { - checkExportsOnMergedDeclarations(node); - if (node.kind === 211 || node.kind === 163) { - checkVarDeclaredNamesNotShadowed(node); - } - checkCollisionWithCapturedSuperVariable(node, node.name); - checkCollisionWithCapturedThisVariable(node, node.name); - checkCollisionWithRequireExportsInGeneratedCode(node, node.name); - } - } - function checkVariableDeclaration(node) { - checkGrammarVariableDeclaration(node); - return checkVariableLikeDeclaration(node); - } - function checkBindingElement(node) { - checkGrammarBindingElement(node); - return checkVariableLikeDeclaration(node); - } - function checkVariableStatement(node) { - checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarVariableDeclarationList(node.declarationList) || checkGrammarForDisallowedLetOrConstStatement(node); - ts.forEach(node.declarationList.declarations, checkSourceElement); - } - function checkGrammarDisallowedModifiersOnObjectLiteralExpressionMethod(node) { - if (node.modifiers && node.parent.kind === 165) { - if (ts.isAsyncFunctionLike(node)) { - if (node.modifiers.length > 1) { - return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); - } - } - else { - return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); - } - } - } - function checkExpressionStatement(node) { - checkGrammarStatementInAmbientContext(node); - checkExpression(node.expression); - } - function checkIfStatement(node) { - checkGrammarStatementInAmbientContext(node); - checkExpression(node.expression); - checkSourceElement(node.thenStatement); - checkSourceElement(node.elseStatement); - } - function checkDoStatement(node) { - checkGrammarStatementInAmbientContext(node); - checkSourceElement(node.statement); - checkExpression(node.expression); - } - function checkWhileStatement(node) { - checkGrammarStatementInAmbientContext(node); - checkExpression(node.expression); - checkSourceElement(node.statement); - } - function checkForStatement(node) { - if (!checkGrammarStatementInAmbientContext(node)) { - if (node.initializer && node.initializer.kind === 212) { - checkGrammarVariableDeclarationList(node.initializer); - } - } - if (node.initializer) { - if (node.initializer.kind === 212) { - ts.forEach(node.initializer.declarations, checkVariableDeclaration); - } - else { - checkExpression(node.initializer); - } - } - if (node.condition) - checkExpression(node.condition); - if (node.incrementor) - checkExpression(node.incrementor); - checkSourceElement(node.statement); - } - function checkForOfStatement(node) { - checkGrammarForInOrForOfStatement(node); - if (node.initializer.kind === 212) { - checkForInOrForOfVariableDeclaration(node); - } - else { - var varExpr = node.initializer; - var iteratedType = checkRightHandSideOfForOf(node.expression); - if (varExpr.kind === 164 || varExpr.kind === 165) { - checkDestructuringAssignment(varExpr, iteratedType || unknownType); - } - else { - var leftType = checkExpression(varExpr); - checkReferenceExpression(varExpr, ts.Diagnostics.Invalid_left_hand_side_in_for_of_statement, ts.Diagnostics.The_left_hand_side_of_a_for_of_statement_cannot_be_a_previously_defined_constant); - if (iteratedType) { - checkTypeAssignableTo(iteratedType, leftType, varExpr, undefined); - } - } - } - checkSourceElement(node.statement); - } - function checkForInStatement(node) { - checkGrammarForInOrForOfStatement(node); - if (node.initializer.kind === 212) { - var variable = node.initializer.declarations[0]; - if (variable && ts.isBindingPattern(variable.name)) { - error(variable.name, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern); - } - checkForInOrForOfVariableDeclaration(node); - } - else { - var varExpr = node.initializer; - var leftType = checkExpression(varExpr); - if (varExpr.kind === 164 || varExpr.kind === 165) { - error(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern); - } - else if (!isTypeAnyOrAllConstituentTypesHaveKind(leftType, 258)) { - error(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_must_be_of_type_string_or_any); - } - else { - checkReferenceExpression(varExpr, ts.Diagnostics.Invalid_left_hand_side_in_for_in_statement, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_previously_defined_constant); - } - } - var rightType = checkExpression(node.expression); - if (!isTypeAnyOrAllConstituentTypesHaveKind(rightType, 80896 | 512)) { - error(node.expression, ts.Diagnostics.The_right_hand_side_of_a_for_in_statement_must_be_of_type_any_an_object_type_or_a_type_parameter); - } - checkSourceElement(node.statement); - } - function checkForInOrForOfVariableDeclaration(iterationStatement) { - var variableDeclarationList = iterationStatement.initializer; - if (variableDeclarationList.declarations.length >= 1) { - var decl = variableDeclarationList.declarations[0]; - checkVariableDeclaration(decl); - } - } - function checkRightHandSideOfForOf(rhsExpression) { - var expressionType = getTypeOfExpression(rhsExpression); - return checkIteratedTypeOrElementType(expressionType, rhsExpression, true); - } - function checkIteratedTypeOrElementType(inputType, errorNode, allowStringInput) { - if (isTypeAny(inputType)) { - return inputType; - } - if (languageVersion >= 2) { - return checkElementTypeOfIterable(inputType, errorNode); - } - if (allowStringInput) { - return checkElementTypeOfArrayOrString(inputType, errorNode); - } - if (isArrayLikeType(inputType)) { - var indexType = getIndexTypeOfType(inputType, 1); - if (indexType) { - return indexType; - } - } - error(errorNode, ts.Diagnostics.Type_0_is_not_an_array_type, typeToString(inputType)); - return unknownType; - } - function checkElementTypeOfIterable(iterable, errorNode) { - var elementType = getElementTypeOfIterable(iterable, errorNode); - if (errorNode && elementType) { - checkTypeAssignableTo(iterable, createIterableType(elementType), errorNode); - } - return elementType || anyType; - } - function getElementTypeOfIterable(type, errorNode) { - if (isTypeAny(type)) { - return undefined; - } - var typeAsIterable = type; - if (!typeAsIterable.iterableElementType) { - if ((type.flags & 4096) && type.target === globalIterableType) { - typeAsIterable.iterableElementType = type.typeArguments[0]; - } - else { - var iteratorFunction = getTypeOfPropertyOfType(type, ts.getPropertyNameForKnownSymbolName("iterator")); - if (isTypeAny(iteratorFunction)) { - return undefined; - } - var iteratorFunctionSignatures = iteratorFunction ? getSignaturesOfType(iteratorFunction, 0) : emptyArray; - if (iteratorFunctionSignatures.length === 0) { - if (errorNode) { - error(errorNode, ts.Diagnostics.Type_must_have_a_Symbol_iterator_method_that_returns_an_iterator); - } - return undefined; - } - typeAsIterable.iterableElementType = getElementTypeOfIterator(getUnionType(ts.map(iteratorFunctionSignatures, getReturnTypeOfSignature)), errorNode); - } - } - return typeAsIterable.iterableElementType; - } - function getElementTypeOfIterator(type, errorNode) { - if (isTypeAny(type)) { - return undefined; - } - var typeAsIterator = type; - if (!typeAsIterator.iteratorElementType) { - if ((type.flags & 4096) && type.target === globalIteratorType) { - typeAsIterator.iteratorElementType = type.typeArguments[0]; - } - else { - var iteratorNextFunction = getTypeOfPropertyOfType(type, "next"); - if (isTypeAny(iteratorNextFunction)) { - return undefined; - } - var iteratorNextFunctionSignatures = iteratorNextFunction ? getSignaturesOfType(iteratorNextFunction, 0) : emptyArray; - if (iteratorNextFunctionSignatures.length === 0) { - if (errorNode) { - error(errorNode, ts.Diagnostics.An_iterator_must_have_a_next_method); - } - return undefined; - } - var iteratorNextResult = getUnionType(ts.map(iteratorNextFunctionSignatures, getReturnTypeOfSignature)); - if (isTypeAny(iteratorNextResult)) { - return undefined; - } - var iteratorNextValue = getTypeOfPropertyOfType(iteratorNextResult, "value"); - if (!iteratorNextValue) { - if (errorNode) { - error(errorNode, ts.Diagnostics.The_type_returned_by_the_next_method_of_an_iterator_must_have_a_value_property); - } - return undefined; - } - typeAsIterator.iteratorElementType = iteratorNextValue; - } - } - return typeAsIterator.iteratorElementType; - } - function getElementTypeOfIterableIterator(type) { - if (isTypeAny(type)) { - return undefined; - } - if ((type.flags & 4096) && type.target === globalIterableIteratorType) { - return type.typeArguments[0]; - } - return getElementTypeOfIterable(type, undefined) || - getElementTypeOfIterator(type, undefined); - } - function checkElementTypeOfArrayOrString(arrayOrStringType, errorNode) { - ts.Debug.assert(languageVersion < 2); - var arrayType = removeTypesFromUnionType(arrayOrStringType, 258, true, true); - var hasStringConstituent = arrayOrStringType !== arrayType; - var reportedError = false; - if (hasStringConstituent) { - if (languageVersion < 1) { - error(errorNode, ts.Diagnostics.Using_a_string_in_a_for_of_statement_is_only_supported_in_ECMAScript_5_and_higher); - reportedError = true; - } - if (arrayType === emptyObjectType) { - return stringType; - } - } - if (!isArrayLikeType(arrayType)) { - if (!reportedError) { - var diagnostic = hasStringConstituent - ? ts.Diagnostics.Type_0_is_not_an_array_type - : ts.Diagnostics.Type_0_is_not_an_array_type_or_a_string_type; - error(errorNode, diagnostic, typeToString(arrayType)); - } - return hasStringConstituent ? stringType : unknownType; - } - var arrayElementType = getIndexTypeOfType(arrayType, 1) || unknownType; - if (hasStringConstituent) { - if (arrayElementType.flags & 258) { - return stringType; - } - return getUnionType([arrayElementType, stringType]); - } - return arrayElementType; - } - function checkBreakOrContinueStatement(node) { - checkGrammarStatementInAmbientContext(node) || checkGrammarBreakOrContinueStatement(node); - } - function isGetAccessorWithAnnotatatedSetAccessor(node) { - return !!(node.kind === 145 && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(node.symbol, 146))); - } - function checkReturnStatement(node) { - if (!checkGrammarStatementInAmbientContext(node)) { - var functionBlock = ts.getContainingFunction(node); - if (!functionBlock) { - grammarErrorOnFirstToken(node, ts.Diagnostics.A_return_statement_can_only_be_used_within_a_function_body); - } - } - if (node.expression) { - var func = ts.getContainingFunction(node); - if (func) { - var signature = getSignatureFromDeclaration(func); - var returnType = getReturnTypeOfSignature(signature); - var exprType = checkExpressionCached(node.expression); - if (func.asteriskToken) { - return; - } - if (func.kind === 146) { - error(node.expression, ts.Diagnostics.Setters_cannot_return_a_value); - } - else if (func.kind === 144) { - if (!isTypeAssignableTo(exprType, returnType)) { - error(node.expression, ts.Diagnostics.Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class); - } - } - else if (func.type || isGetAccessorWithAnnotatatedSetAccessor(func) || signature.typePredicate) { - if (ts.isAsyncFunctionLike(func)) { - var promisedType = getPromisedType(returnType); - var awaitedType = checkAwaitedType(exprType, node.expression, ts.Diagnostics.Return_expression_in_async_function_does_not_have_a_valid_callable_then_member); - if (promisedType) { - checkTypeAssignableTo(awaitedType, promisedType, node.expression); - } - } - else { - checkTypeAssignableTo(exprType, returnType, node.expression); - } - } - } - } - } - function checkWithStatement(node) { - if (!checkGrammarStatementInAmbientContext(node)) { - if (node.parserContextFlags & 8) { - grammarErrorOnFirstToken(node, ts.Diagnostics.with_statements_are_not_allowed_in_an_async_function_block); - } - } - checkExpression(node.expression); - error(node.expression, ts.Diagnostics.All_symbols_within_a_with_block_will_be_resolved_to_any); - } - function checkSwitchStatement(node) { - checkGrammarStatementInAmbientContext(node); - var firstDefaultClause; - var hasDuplicateDefaultClause = false; - var expressionType = checkExpression(node.expression); - ts.forEach(node.caseBlock.clauses, function (clause) { - if (clause.kind === 242 && !hasDuplicateDefaultClause) { - if (firstDefaultClause === undefined) { - firstDefaultClause = clause; - } - else { - var sourceFile = ts.getSourceFileOfNode(node); - var start = ts.skipTrivia(sourceFile.text, clause.pos); - var end = clause.statements.length > 0 ? clause.statements[0].pos : clause.end; - grammarErrorAtPos(sourceFile, start, end - start, ts.Diagnostics.A_default_clause_cannot_appear_more_than_once_in_a_switch_statement); - hasDuplicateDefaultClause = true; - } - } - if (produceDiagnostics && clause.kind === 241) { - var caseClause = clause; - var caseType = checkExpression(caseClause.expression); - if (!isTypeAssignableTo(expressionType, caseType)) { - checkTypeAssignableTo(caseType, expressionType, caseClause.expression, undefined); - } - } - ts.forEach(clause.statements, checkSourceElement); - }); - } - function checkLabeledStatement(node) { - if (!checkGrammarStatementInAmbientContext(node)) { - var current = node.parent; - while (current) { - if (ts.isFunctionLike(current)) { - break; - } - if (current.kind === 207 && current.label.text === node.label.text) { - var sourceFile = ts.getSourceFileOfNode(node); - grammarErrorOnNode(node.label, ts.Diagnostics.Duplicate_label_0, ts.getTextOfNodeFromSourceText(sourceFile.text, node.label)); - break; - } - current = current.parent; - } - } - checkSourceElement(node.statement); - } - function checkThrowStatement(node) { - if (!checkGrammarStatementInAmbientContext(node)) { - if (node.expression === undefined) { - grammarErrorAfterFirstToken(node, ts.Diagnostics.Line_break_not_permitted_here); - } - } - if (node.expression) { - checkExpression(node.expression); - } - } - function checkTryStatement(node) { - checkGrammarStatementInAmbientContext(node); - checkBlock(node.tryBlock); - var catchClause = node.catchClause; - if (catchClause) { - if (catchClause.variableDeclaration) { - if (catchClause.variableDeclaration.name.kind !== 69) { - grammarErrorOnFirstToken(catchClause.variableDeclaration.name, ts.Diagnostics.Catch_clause_variable_name_must_be_an_identifier); - } - else if (catchClause.variableDeclaration.type) { - grammarErrorOnFirstToken(catchClause.variableDeclaration.type, ts.Diagnostics.Catch_clause_variable_cannot_have_a_type_annotation); - } - else if (catchClause.variableDeclaration.initializer) { - grammarErrorOnFirstToken(catchClause.variableDeclaration.initializer, ts.Diagnostics.Catch_clause_variable_cannot_have_an_initializer); - } - else { - var identifierName = catchClause.variableDeclaration.name.text; - var locals = catchClause.block.locals; - if (locals && ts.hasProperty(locals, identifierName)) { - var localSymbol = locals[identifierName]; - if (localSymbol && (localSymbol.flags & 2) !== 0) { - grammarErrorOnNode(localSymbol.valueDeclaration, ts.Diagnostics.Cannot_redeclare_identifier_0_in_catch_clause, identifierName); - } - } - } - } - checkBlock(catchClause.block); - } - if (node.finallyBlock) { - checkBlock(node.finallyBlock); - } - } - function checkIndexConstraints(type) { - var declaredNumberIndexer = getIndexDeclarationOfSymbol(type.symbol, 1); - var declaredStringIndexer = getIndexDeclarationOfSymbol(type.symbol, 0); - var stringIndexType = getIndexTypeOfType(type, 0); - var numberIndexType = getIndexTypeOfType(type, 1); - if (stringIndexType || numberIndexType) { - ts.forEach(getPropertiesOfObjectType(type), function (prop) { - var propType = getTypeOfSymbol(prop); - checkIndexConstraintForProperty(prop, propType, type, declaredStringIndexer, stringIndexType, 0); - checkIndexConstraintForProperty(prop, propType, type, declaredNumberIndexer, numberIndexType, 1); - }); - if (type.flags & 1024 && ts.isClassLike(type.symbol.valueDeclaration)) { - var classDeclaration = type.symbol.valueDeclaration; - for (var _i = 0, _a = classDeclaration.members; _i < _a.length; _i++) { - var member = _a[_i]; - if (!(member.flags & 128) && ts.hasDynamicName(member)) { - var propType = getTypeOfSymbol(member.symbol); - checkIndexConstraintForProperty(member.symbol, propType, type, declaredStringIndexer, stringIndexType, 0); - checkIndexConstraintForProperty(member.symbol, propType, type, declaredNumberIndexer, numberIndexType, 1); - } - } - } - } - var errorNode; - if (stringIndexType && numberIndexType) { - errorNode = declaredNumberIndexer || declaredStringIndexer; - if (!errorNode && (type.flags & 2048)) { - var someBaseTypeHasBothIndexers = ts.forEach(getBaseTypes(type), function (base) { return getIndexTypeOfType(base, 0) && getIndexTypeOfType(base, 1); }); - errorNode = someBaseTypeHasBothIndexers ? undefined : type.symbol.declarations[0]; - } - } - if (errorNode && !isTypeAssignableTo(numberIndexType, stringIndexType)) { - error(errorNode, ts.Diagnostics.Numeric_index_type_0_is_not_assignable_to_string_index_type_1, typeToString(numberIndexType), typeToString(stringIndexType)); - } - function checkIndexConstraintForProperty(prop, propertyType, containingType, indexDeclaration, indexType, indexKind) { - if (!indexType) { - return; - } - if (indexKind === 1 && !isNumericName(prop.valueDeclaration.name)) { - return; - } - var errorNode; - if (prop.valueDeclaration.name.kind === 136 || prop.parent === containingType.symbol) { - errorNode = prop.valueDeclaration; - } - else if (indexDeclaration) { - errorNode = indexDeclaration; - } - else if (containingType.flags & 2048) { - var someBaseClassHasBothPropertyAndIndexer = ts.forEach(getBaseTypes(containingType), function (base) { return getPropertyOfObjectType(base, prop.name) && getIndexTypeOfType(base, indexKind); }); - errorNode = someBaseClassHasBothPropertyAndIndexer ? undefined : containingType.symbol.declarations[0]; - } - if (errorNode && !isTypeAssignableTo(propertyType, indexType)) { - var errorMessage = indexKind === 0 - ? ts.Diagnostics.Property_0_of_type_1_is_not_assignable_to_string_index_type_2 - : ts.Diagnostics.Property_0_of_type_1_is_not_assignable_to_numeric_index_type_2; - error(errorNode, errorMessage, symbolToString(prop), typeToString(propertyType), typeToString(indexType)); - } - } - } - function checkTypeNameIsReserved(name, message) { - switch (name.text) { - case "any": - case "number": - case "boolean": - case "string": - case "symbol": - case "void": - error(name, message, name.text); - } - } - function checkTypeParameters(typeParameterDeclarations) { - if (typeParameterDeclarations) { - for (var i = 0, n = typeParameterDeclarations.length; i < n; i++) { - var node = typeParameterDeclarations[i]; - checkTypeParameter(node); - if (produceDiagnostics) { - for (var j = 0; j < i; j++) { - if (typeParameterDeclarations[j].symbol === node.symbol) { - error(node.name, ts.Diagnostics.Duplicate_identifier_0, ts.declarationNameToString(node.name)); - } - } - } - } - } - } - function checkClassExpression(node) { - checkClassLikeDeclaration(node); - return getTypeOfSymbol(getSymbolOfNode(node)); - } - function checkClassDeclaration(node) { - if (!node.name && !(node.flags & 1024)) { - grammarErrorOnFirstToken(node, ts.Diagnostics.A_class_declaration_without_the_default_modifier_must_have_a_name); - } - checkClassLikeDeclaration(node); - ts.forEach(node.members, checkSourceElement); - } - function checkClassLikeDeclaration(node) { - checkGrammarClassDeclarationHeritageClauses(node); - checkDecorators(node); - if (node.name) { - checkTypeNameIsReserved(node.name, ts.Diagnostics.Class_name_cannot_be_0); - checkCollisionWithCapturedThisVariable(node, node.name); - checkCollisionWithRequireExportsInGeneratedCode(node, node.name); - } - checkTypeParameters(node.typeParameters); - checkExportsOnMergedDeclarations(node); - var symbol = getSymbolOfNode(node); - var type = getDeclaredTypeOfSymbol(symbol); - var typeWithThis = getTypeWithThisArgument(type); - var staticType = getTypeOfSymbol(symbol); - var baseTypeNode = ts.getClassExtendsHeritageClauseElement(node); - if (baseTypeNode) { - emitExtends = emitExtends || !ts.isInAmbientContext(node); - var baseTypes = getBaseTypes(type); - if (baseTypes.length && produceDiagnostics) { - var baseType = baseTypes[0]; - var staticBaseType = getBaseConstructorTypeOfClass(type); - checkSourceElement(baseTypeNode.expression); - if (baseTypeNode.typeArguments) { - ts.forEach(baseTypeNode.typeArguments, checkSourceElement); - for (var _i = 0, _a = getConstructorsForTypeArguments(staticBaseType, baseTypeNode.typeArguments); _i < _a.length; _i++) { - var constructor = _a[_i]; - if (!checkTypeArgumentConstraints(constructor.typeParameters, baseTypeNode.typeArguments)) { - break; - } - } - } - checkTypeAssignableTo(typeWithThis, getTypeWithThisArgument(baseType, type.thisType), node.name || node, ts.Diagnostics.Class_0_incorrectly_extends_base_class_1); - checkTypeAssignableTo(staticType, getTypeWithoutSignatures(staticBaseType), node.name || node, ts.Diagnostics.Class_static_side_0_incorrectly_extends_base_class_static_side_1); - if (!(staticBaseType.symbol && staticBaseType.symbol.flags & 32)) { - var constructors = getInstantiatedConstructorsForTypeArguments(staticBaseType, baseTypeNode.typeArguments); - if (ts.forEach(constructors, function (sig) { return getReturnTypeOfSignature(sig) !== baseType; })) { - error(baseTypeNode.expression, ts.Diagnostics.Base_constructors_must_all_have_the_same_return_type); - } - } - checkKindsOfPropertyMemberOverrides(type, baseType); - } - } - var implementedTypeNodes = ts.getClassImplementsHeritageClauseElements(node); - if (implementedTypeNodes) { - for (var _b = 0; _b < implementedTypeNodes.length; _b++) { - var typeRefNode = implementedTypeNodes[_b]; - if (!ts.isSupportedExpressionWithTypeArguments(typeRefNode)) { - error(typeRefNode.expression, ts.Diagnostics.A_class_can_only_implement_an_identifier_Slashqualified_name_with_optional_type_arguments); - } - checkTypeReferenceNode(typeRefNode); - if (produceDiagnostics) { - var t = getTypeFromTypeNode(typeRefNode); - if (t !== unknownType) { - var declaredType = (t.flags & 4096) ? t.target : t; - if (declaredType.flags & (1024 | 2048)) { - checkTypeAssignableTo(typeWithThis, getTypeWithThisArgument(t, type.thisType), node.name || node, ts.Diagnostics.Class_0_incorrectly_implements_interface_1); - } - else { - error(typeRefNode, ts.Diagnostics.A_class_may_only_implement_another_class_or_interface); - } - } - } - } - } - if (produceDiagnostics) { - checkIndexConstraints(type); - checkTypeForDuplicateIndexSignatures(node); - } - } - function getTargetSymbol(s) { - return s.flags & 16777216 ? getSymbolLinks(s).target : s; - } - function getClassLikeDeclarationOfSymbol(symbol) { - return ts.forEach(symbol.declarations, function (d) { return ts.isClassLike(d) ? d : undefined; }); - } - function checkKindsOfPropertyMemberOverrides(type, baseType) { - var baseProperties = getPropertiesOfObjectType(baseType); - for (var _i = 0; _i < baseProperties.length; _i++) { - var baseProperty = baseProperties[_i]; - var base = getTargetSymbol(baseProperty); - if (base.flags & 134217728) { - continue; - } - var derived = getTargetSymbol(getPropertyOfObjectType(type, base.name)); - var baseDeclarationFlags = getDeclarationFlagsFromSymbol(base); - ts.Debug.assert(!!derived, "derived should point to something, even if it is the base class' declaration."); - if (derived) { - if (derived === base) { - var derivedClassDecl = getClassLikeDeclarationOfSymbol(type.symbol); - if (baseDeclarationFlags & 256 && (!derivedClassDecl || !(derivedClassDecl.flags & 256))) { - if (derivedClassDecl.kind === 186) { - error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1, symbolToString(baseProperty), typeToString(baseType)); - } - else { - error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_0_does_not_implement_inherited_abstract_member_1_from_class_2, typeToString(type), symbolToString(baseProperty), typeToString(baseType)); - } - } - } - else { - var derivedDeclarationFlags = getDeclarationFlagsFromSymbol(derived); - if ((baseDeclarationFlags & 32) || (derivedDeclarationFlags & 32)) { - continue; - } - if ((baseDeclarationFlags & 128) !== (derivedDeclarationFlags & 128)) { - continue; - } - if ((base.flags & derived.flags & 8192) || ((base.flags & 98308) && (derived.flags & 98308))) { - continue; - } - var errorMessage = void 0; - if (base.flags & 8192) { - if (derived.flags & 98304) { - errorMessage = ts.Diagnostics.Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_accessor; - } - else { - ts.Debug.assert((derived.flags & 4) !== 0); - errorMessage = ts.Diagnostics.Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_property; - } - } - else if (base.flags & 4) { - ts.Debug.assert((derived.flags & 8192) !== 0); - errorMessage = ts.Diagnostics.Class_0_defines_instance_member_property_1_but_extended_class_2_defines_it_as_instance_member_function; - } - else { - ts.Debug.assert((base.flags & 98304) !== 0); - ts.Debug.assert((derived.flags & 8192) !== 0); - errorMessage = ts.Diagnostics.Class_0_defines_instance_member_accessor_1_but_extended_class_2_defines_it_as_instance_member_function; - } - error(derived.valueDeclaration.name, errorMessage, typeToString(baseType), symbolToString(base), typeToString(type)); - } - } - } - } - function isAccessor(kind) { - return kind === 145 || kind === 146; - } - function areTypeParametersIdentical(list1, list2) { - if (!list1 && !list2) { - return true; - } - if (!list1 || !list2 || list1.length !== list2.length) { - return false; - } - for (var i = 0, len = list1.length; i < len; i++) { - var tp1 = list1[i]; - var tp2 = list2[i]; - if (tp1.name.text !== tp2.name.text) { - return false; - } - if (!tp1.constraint && !tp2.constraint) { - continue; - } - if (!tp1.constraint || !tp2.constraint) { - return false; - } - if (!isTypeIdenticalTo(getTypeFromTypeNode(tp1.constraint), getTypeFromTypeNode(tp2.constraint))) { - return false; - } - } - return true; - } - function checkInheritedPropertiesAreIdentical(type, typeNode) { - var baseTypes = getBaseTypes(type); - if (baseTypes.length < 2) { - return true; - } - var seen = {}; - ts.forEach(resolveDeclaredMembers(type).declaredProperties, function (p) { seen[p.name] = { prop: p, containingType: type }; }); - var ok = true; - for (var _i = 0; _i < baseTypes.length; _i++) { - var base = baseTypes[_i]; - var properties = getPropertiesOfObjectType(getTypeWithThisArgument(base, type.thisType)); - for (var _a = 0; _a < properties.length; _a++) { - var prop = properties[_a]; - if (!ts.hasProperty(seen, prop.name)) { - seen[prop.name] = { prop: prop, containingType: base }; - } - else { - var existing = seen[prop.name]; - var isInheritedProperty = existing.containingType !== type; - if (isInheritedProperty && !isPropertyIdenticalTo(existing.prop, prop)) { - ok = false; - var typeName1 = typeToString(existing.containingType); - var typeName2 = typeToString(base); - var errorInfo = ts.chainDiagnosticMessages(undefined, ts.Diagnostics.Named_property_0_of_types_1_and_2_are_not_identical, symbolToString(prop), typeName1, typeName2); - errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.Interface_0_cannot_simultaneously_extend_types_1_and_2, typeToString(type), typeName1, typeName2); - diagnostics.add(ts.createDiagnosticForNodeFromMessageChain(typeNode, errorInfo)); - } - } - } - } - return ok; - } - function checkInterfaceDeclaration(node) { - checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarInterfaceDeclaration(node); - checkTypeParameters(node.typeParameters); - if (produceDiagnostics) { - checkTypeNameIsReserved(node.name, ts.Diagnostics.Interface_name_cannot_be_0); - checkExportsOnMergedDeclarations(node); - var symbol = getSymbolOfNode(node); - var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 215); - if (symbol.declarations.length > 1) { - if (node !== firstInterfaceDecl && !areTypeParametersIdentical(firstInterfaceDecl.typeParameters, node.typeParameters)) { - error(node.name, ts.Diagnostics.All_declarations_of_an_interface_must_have_identical_type_parameters); - } - } - if (node === firstInterfaceDecl) { - var type = getDeclaredTypeOfSymbol(symbol); - var typeWithThis = getTypeWithThisArgument(type); - if (checkInheritedPropertiesAreIdentical(type, node.name)) { - for (var _i = 0, _a = getBaseTypes(type); _i < _a.length; _i++) { - var baseType = _a[_i]; - checkTypeAssignableTo(typeWithThis, getTypeWithThisArgument(baseType, type.thisType), node.name, ts.Diagnostics.Interface_0_incorrectly_extends_interface_1); - } - checkIndexConstraints(type); - } - } - } - ts.forEach(ts.getInterfaceBaseTypeNodes(node), function (heritageElement) { - if (!ts.isSupportedExpressionWithTypeArguments(heritageElement)) { - error(heritageElement.expression, ts.Diagnostics.An_interface_can_only_extend_an_identifier_Slashqualified_name_with_optional_type_arguments); - } - checkTypeReferenceNode(heritageElement); - }); - ts.forEach(node.members, checkSourceElement); - if (produceDiagnostics) { - checkTypeForDuplicateIndexSignatures(node); - } - } - function checkTypeAliasDeclaration(node) { - checkGrammarDecorators(node) || checkGrammarModifiers(node); - checkTypeNameIsReserved(node.name, ts.Diagnostics.Type_alias_name_cannot_be_0); - checkSourceElement(node.type); - } - function computeEnumMemberValues(node) { - var nodeLinks = getNodeLinks(node); - if (!(nodeLinks.flags & 8192)) { - var enumSymbol = getSymbolOfNode(node); - var enumType = getDeclaredTypeOfSymbol(enumSymbol); - var autoValue = 0; - var ambient = ts.isInAmbientContext(node); - var enumIsConst = ts.isConst(node); - for (var _i = 0, _a = node.members; _i < _a.length; _i++) { - var member = _a[_i]; - if (member.name.kind === 136) { - error(member.name, ts.Diagnostics.Computed_property_names_are_not_allowed_in_enums); - } - else if (isNumericLiteralName(member.name.text)) { - error(member.name, ts.Diagnostics.An_enum_member_cannot_have_a_numeric_name); - } - var previousEnumMemberIsNonConstant = autoValue === undefined; - var initializer = member.initializer; - if (initializer) { - autoValue = computeConstantValueForEnumMemberInitializer(initializer, enumType, enumIsConst, ambient); - } - else if (ambient && !enumIsConst) { - autoValue = undefined; - } - else if (previousEnumMemberIsNonConstant) { - error(member.name, ts.Diagnostics.Enum_member_must_have_initializer); - } - if (autoValue !== undefined) { - getNodeLinks(member).enumMemberValue = autoValue++; - } - } - nodeLinks.flags |= 8192; - } - function computeConstantValueForEnumMemberInitializer(initializer, enumType, enumIsConst, ambient) { - var reportError = true; - var value = evalConstant(initializer); - if (reportError) { - if (value === undefined) { - if (enumIsConst) { - error(initializer, ts.Diagnostics.In_const_enum_declarations_member_initializer_must_be_constant_expression); - } - else if (ambient) { - error(initializer, ts.Diagnostics.In_ambient_enum_declarations_member_initializer_must_be_constant_expression); - } - else { - checkTypeAssignableTo(checkExpression(initializer), enumType, initializer, undefined); - } - } - else if (enumIsConst) { - if (isNaN(value)) { - error(initializer, ts.Diagnostics.const_enum_member_initializer_was_evaluated_to_disallowed_value_NaN); - } - else if (!isFinite(value)) { - error(initializer, ts.Diagnostics.const_enum_member_initializer_was_evaluated_to_a_non_finite_value); - } - } - } - return value; - function evalConstant(e) { - switch (e.kind) { - case 179: - 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; - } - return undefined; - case 181: - var left = evalConstant(e.left); - if (left === undefined) { - return undefined; - } - var right = evalConstant(e.right); - if (right === undefined) { - 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; - } - return undefined; - case 8: - return +e.text; - case 172: - return evalConstant(e.expression); - case 69: - case 167: - case 166: - var member = initializer.parent; - var currentType = getTypeOfSymbol(getSymbolOfNode(member.parent)); - var enumType_1; - var propertyName; - if (e.kind === 69) { - enumType_1 = currentType; - propertyName = e.text; - } - else { - var expression; - if (e.kind === 167) { - if (e.argumentExpression === undefined || - e.argumentExpression.kind !== 9) { - return undefined; - } - expression = e.expression; - propertyName = e.argumentExpression.text; - } - else { - expression = e.expression; - propertyName = e.name.text; - } - var current = expression; - while (current) { - if (current.kind === 69) { - break; - } - else if (current.kind === 166) { - current = current.expression; - } - else { - return undefined; - } - } - enumType_1 = checkExpression(expression); - if (!(enumType_1.symbol && (enumType_1.symbol.flags & 384))) { - return undefined; - } - } - if (propertyName === undefined) { - return undefined; - } - var property = getPropertyOfObjectType(enumType_1, propertyName); - if (!property || !(property.flags & 8)) { - return undefined; - } - var propertyDecl = property.valueDeclaration; - if (member === propertyDecl) { - return undefined; - } - if (!isBlockScopedNameDeclaredBeforeUse(propertyDecl, member)) { - reportError = false; - error(e, ts.Diagnostics.A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_enums); - return undefined; - } - return getNodeLinks(propertyDecl).enumMemberValue; - } - } - } - } - function checkEnumDeclaration(node) { - if (!produceDiagnostics) { - return; - } - checkGrammarDecorators(node) || checkGrammarModifiers(node); - checkTypeNameIsReserved(node.name, ts.Diagnostics.Enum_name_cannot_be_0); - checkCollisionWithCapturedThisVariable(node, node.name); - checkCollisionWithRequireExportsInGeneratedCode(node, node.name); - checkExportsOnMergedDeclarations(node); - computeEnumMemberValues(node); - var enumIsConst = ts.isConst(node); - if (compilerOptions.isolatedModules && enumIsConst && ts.isInAmbientContext(node)) { - error(node.name, ts.Diagnostics.Ambient_const_enums_are_not_allowed_when_the_isolatedModules_flag_is_provided); - } - var enumSymbol = getSymbolOfNode(node); - var firstDeclaration = ts.getDeclarationOfKind(enumSymbol, node.kind); - if (node === firstDeclaration) { - if (enumSymbol.declarations.length > 1) { - ts.forEach(enumSymbol.declarations, function (decl) { - if (ts.isConstEnumDeclaration(decl) !== enumIsConst) { - error(decl.name, ts.Diagnostics.Enum_declarations_must_all_be_const_or_non_const); - } - }); - } - var seenEnumMissingInitialInitializer = false; - ts.forEach(enumSymbol.declarations, function (declaration) { - if (declaration.kind !== 217) { - return false; - } - var enumDeclaration = declaration; - if (!enumDeclaration.members.length) { - return false; - } - var firstEnumMember = enumDeclaration.members[0]; - if (!firstEnumMember.initializer) { - if (seenEnumMissingInitialInitializer) { - error(firstEnumMember.name, ts.Diagnostics.In_an_enum_with_multiple_declarations_only_one_declaration_can_omit_an_initializer_for_its_first_enum_element); - } - else { - seenEnumMissingInitialInitializer = true; - } - } - }); - } - } - function getFirstNonAmbientClassOrFunctionDeclaration(symbol) { - var declarations = symbol.declarations; - for (var _i = 0; _i < declarations.length; _i++) { - var declaration = declarations[_i]; - if ((declaration.kind === 214 || - (declaration.kind === 213 && ts.nodeIsPresent(declaration.body))) && - !ts.isInAmbientContext(declaration)) { - return declaration; - } - } - return undefined; - } - function inSameLexicalScope(node1, node2) { - var container1 = ts.getEnclosingBlockScopeContainer(node1); - var container2 = ts.getEnclosingBlockScopeContainer(node2); - if (isGlobalSourceFile(container1)) { - return isGlobalSourceFile(container2); - } - else if (isGlobalSourceFile(container2)) { - return false; - } - else { - return container1 === container2; - } - } - function checkModuleDeclaration(node) { - if (produceDiagnostics) { - var isAmbientExternalModule = node.name.kind === 9; - var contextErrorMessage = isAmbientExternalModule - ? ts.Diagnostics.An_ambient_module_declaration_is_only_allowed_at_the_top_level_in_a_file - : ts.Diagnostics.A_namespace_declaration_is_only_allowed_in_a_namespace_or_module; - if (checkGrammarModuleElementContext(node, contextErrorMessage)) { - return; - } - if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node)) { - if (!ts.isInAmbientContext(node) && node.name.kind === 9) { - grammarErrorOnNode(node.name, ts.Diagnostics.Only_ambient_modules_can_use_quoted_names); - } - } - checkCollisionWithCapturedThisVariable(node, node.name); - checkCollisionWithRequireExportsInGeneratedCode(node, node.name); - checkExportsOnMergedDeclarations(node); - var symbol = getSymbolOfNode(node); - if (symbol.flags & 512 - && symbol.declarations.length > 1 - && !ts.isInAmbientContext(node) - && ts.isInstantiatedModule(node, compilerOptions.preserveConstEnums || compilerOptions.isolatedModules)) { - var firstNonAmbientClassOrFunc = getFirstNonAmbientClassOrFunctionDeclaration(symbol); - if (firstNonAmbientClassOrFunc) { - if (ts.getSourceFileOfNode(node) !== ts.getSourceFileOfNode(firstNonAmbientClassOrFunc)) { - error(node.name, ts.Diagnostics.A_namespace_declaration_cannot_be_in_a_different_file_from_a_class_or_function_with_which_it_is_merged); - } - else if (node.pos < firstNonAmbientClassOrFunc.pos) { - 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, 214); - if (mergedClass && - inSameLexicalScope(node, mergedClass)) { - getNodeLinks(node).flags |= 32768; - } - } - if (isAmbientExternalModule) { - if (!isGlobalSourceFile(node.parent)) { - error(node.name, ts.Diagnostics.Ambient_modules_cannot_be_nested_in_other_modules_or_namespaces); - } - if (ts.isExternalModuleNameRelative(node.name.text)) { - error(node.name, ts.Diagnostics.Ambient_module_declaration_cannot_specify_relative_module_name); - } - } - } - checkSourceElement(node.body); - } - function getFirstIdentifier(node) { - while (true) { - if (node.kind === 135) { - node = node.left; - } - else if (node.kind === 166) { - node = node.expression; - } - else { - break; - } - } - ts.Debug.assert(node.kind === 69); - return node; - } - function checkExternalImportOrExportDeclaration(node) { - var moduleName = ts.getExternalModuleName(node); - if (!ts.nodeIsMissing(moduleName) && moduleName.kind !== 9) { - error(moduleName, ts.Diagnostics.String_literal_expected); - return false; - } - var inAmbientExternalModule = node.parent.kind === 219 && node.parent.parent.name.kind === 9; - if (node.parent.kind !== 248 && !inAmbientExternalModule) { - error(moduleName, node.kind === 228 ? - ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace : - ts.Diagnostics.Import_declarations_in_a_namespace_cannot_reference_a_module); - return false; - } - if (inAmbientExternalModule && ts.isExternalModuleNameRelative(moduleName.text)) { - error(node, ts.Diagnostics.Import_or_export_declaration_in_an_ambient_module_declaration_cannot_reference_module_through_relative_module_name); - return false; - } - return true; - } - function checkAliasSymbol(node) { - var symbol = getSymbolOfNode(node); - var target = resolveAlias(symbol); - if (target !== unknownSymbol) { - var excludedMeanings = (symbol.flags & 107455 ? 107455 : 0) | - (symbol.flags & 793056 ? 793056 : 0) | - (symbol.flags & 1536 ? 1536 : 0); - if (target.flags & excludedMeanings) { - var message = node.kind === 230 ? - ts.Diagnostics.Export_declaration_conflicts_with_exported_declaration_of_0 : - ts.Diagnostics.Import_declaration_conflicts_with_local_declaration_of_0; - error(node, message, symbolToString(symbol)); - } - } - } - function checkImportBinding(node) { - checkCollisionWithCapturedThisVariable(node, node.name); - checkCollisionWithRequireExportsInGeneratedCode(node, node.name); - checkAliasSymbol(node); - } - function checkImportDeclaration(node) { - if (checkGrammarModuleElementContext(node, ts.Diagnostics.An_import_declaration_can_only_be_used_in_a_namespace_or_module)) { - return; - } - if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && (node.flags & 2035)) { - grammarErrorOnFirstToken(node, ts.Diagnostics.An_import_declaration_cannot_have_modifiers); - } - if (checkExternalImportOrExportDeclaration(node)) { - var importClause = node.importClause; - if (importClause) { - if (importClause.name) { - checkImportBinding(importClause); - } - if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 224) { - checkImportBinding(importClause.namedBindings); - } - else { - ts.forEach(importClause.namedBindings.elements, checkImportBinding); - } - } - } - } - } - function checkImportEqualsDeclaration(node) { - if (checkGrammarModuleElementContext(node, ts.Diagnostics.An_import_declaration_can_only_be_used_in_a_namespace_or_module)) { - return; - } - checkGrammarDecorators(node) || checkGrammarModifiers(node); - if (ts.isInternalModuleImportEqualsDeclaration(node) || checkExternalImportOrExportDeclaration(node)) { - checkImportBinding(node); - if (node.flags & 1) { - markExportAsReferenced(node); - } - if (ts.isInternalModuleImportEqualsDeclaration(node)) { - var target = resolveAlias(getSymbolOfNode(node)); - if (target !== unknownSymbol) { - if (target.flags & 107455) { - var moduleName = getFirstIdentifier(node.moduleReference); - if (!(resolveEntityName(moduleName, 107455 | 1536).flags & 1536)) { - error(moduleName, ts.Diagnostics.Module_0_is_hidden_by_a_local_declaration_with_the_same_name, ts.declarationNameToString(moduleName)); - } - } - if (target.flags & 793056) { - checkTypeNameIsReserved(node.name, ts.Diagnostics.Import_name_cannot_be_0); - } - } - } - else { - if (modulekind === 5 && !ts.isInAmbientContext(node)) { - grammarErrorOnNode(node, ts.Diagnostics.Import_assignment_cannot_be_used_when_targeting_ECMAScript_6_modules_Consider_using_import_Asterisk_as_ns_from_mod_import_a_from_mod_import_d_from_mod_or_another_module_format_instead); - } - } - } - } - function checkExportDeclaration(node) { - if (checkGrammarModuleElementContext(node, ts.Diagnostics.An_export_declaration_can_only_be_used_in_a_module)) { - return; - } - if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && (node.flags & 2035)) { - grammarErrorOnFirstToken(node, ts.Diagnostics.An_export_declaration_cannot_have_modifiers); - } - if (!node.moduleSpecifier || checkExternalImportOrExportDeclaration(node)) { - if (node.exportClause) { - ts.forEach(node.exportClause.elements, checkExportSpecifier); - var inAmbientExternalModule = node.parent.kind === 219 && node.parent.parent.name.kind === 9; - if (node.parent.kind !== 248 && !inAmbientExternalModule) { - error(node, ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace); - } - } - else { - var moduleSymbol = resolveExternalModuleName(node, node.moduleSpecifier); - if (moduleSymbol && moduleSymbol.exports["export="]) { - error(node.moduleSpecifier, ts.Diagnostics.Module_0_uses_export_and_cannot_be_used_with_export_Asterisk, symbolToString(moduleSymbol)); - } - } - } - } - function checkGrammarModuleElementContext(node, errorMessage) { - if (node.parent.kind !== 248 && node.parent.kind !== 219 && node.parent.kind !== 218) { - return grammarErrorOnFirstToken(node, errorMessage); - } - } - function checkExportSpecifier(node) { - checkAliasSymbol(node); - if (!node.parent.parent.moduleSpecifier) { - markExportAsReferenced(node); - } - } - function checkExportAssignment(node) { - if (checkGrammarModuleElementContext(node, ts.Diagnostics.An_export_assignment_can_only_be_used_in_a_module)) { - return; - } - var container = node.parent.kind === 248 ? node.parent : node.parent.parent; - if (container.kind === 218 && container.name.kind === 69) { - error(node, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_namespace); - return; - } - if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && (node.flags & 2035)) { - grammarErrorOnFirstToken(node, ts.Diagnostics.An_export_assignment_cannot_have_modifiers); - } - if (node.expression.kind === 69) { - markExportAsReferenced(node); - } - else { - checkExpressionCached(node.expression); - } - checkExternalModuleExports(container); - if (node.isExportEquals && !ts.isInAmbientContext(node)) { - if (modulekind === 5) { - grammarErrorOnNode(node, ts.Diagnostics.Export_assignment_cannot_be_used_when_targeting_ECMAScript_6_modules_Consider_using_export_default_or_another_module_format_instead); - } - else if (modulekind === 4) { - grammarErrorOnNode(node, ts.Diagnostics.Export_assignment_is_not_supported_when_module_flag_is_system); - } - } - } - function getModuleStatements(node) { - if (node.kind === 248) { - return node.statements; - } - if (node.kind === 218 && node.body.kind === 219) { - return node.body.statements; - } - return emptyArray; - } - function hasExportedMembers(moduleSymbol) { - for (var id in moduleSymbol.exports) { - if (id !== "export=") { - return true; - } - } - return false; - } - function checkExternalModuleExports(node) { - var moduleSymbol = getSymbolOfNode(node); - var links = getSymbolLinks(moduleSymbol); - if (!links.exportsChecked) { - var exportEqualsSymbol = moduleSymbol.exports["export="]; - if (exportEqualsSymbol && hasExportedMembers(moduleSymbol)) { - var declaration = getDeclarationOfAliasSymbol(exportEqualsSymbol) || exportEqualsSymbol.valueDeclaration; - error(declaration, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_module_with_other_exported_elements); - } - links.exportsChecked = true; - } - } - function checkTypePredicate(node) { - if (!isInLegalTypePredicatePosition(node)) { - error(node, ts.Diagnostics.A_type_predicate_is_only_allowed_in_return_type_position_for_functions_and_methods); - } - } - function checkSourceElement(node) { - if (!node) { - return; - } - var kind = node.kind; - if (cancellationToken) { - switch (kind) { - case 218: - case 214: - case 215: - case 213: - cancellationToken.throwIfCancellationRequested(); - } - } - switch (kind) { - case 137: - return checkTypeParameter(node); - case 138: - return checkParameter(node); - case 141: - case 140: - return checkPropertyDeclaration(node); - case 152: - case 153: - case 147: - case 148: - return checkSignatureDeclaration(node); - case 149: - return checkSignatureDeclaration(node); - case 143: - case 142: - return checkMethodDeclaration(node); - case 144: - return checkConstructorDeclaration(node); - case 145: - case 146: - return checkAccessorDeclaration(node); - case 151: - return checkTypeReferenceNode(node); - case 150: - return checkTypePredicate(node); - case 154: - return checkTypeQuery(node); - case 155: - return checkTypeLiteral(node); - case 156: - return checkArrayType(node); - case 157: - return checkTupleType(node); - case 158: - case 159: - return checkUnionOrIntersectionType(node); - case 160: - return checkSourceElement(node.type); - case 213: - return checkFunctionDeclaration(node); - case 192: - case 219: - return checkBlock(node); - case 193: - return checkVariableStatement(node); - case 195: - return checkExpressionStatement(node); - case 196: - return checkIfStatement(node); - case 197: - return checkDoStatement(node); - case 198: - return checkWhileStatement(node); - case 199: - return checkForStatement(node); - case 200: - return checkForInStatement(node); - case 201: - return checkForOfStatement(node); - case 202: - case 203: - return checkBreakOrContinueStatement(node); - case 204: - return checkReturnStatement(node); - case 205: - return checkWithStatement(node); - case 206: - return checkSwitchStatement(node); - case 207: - return checkLabeledStatement(node); - case 208: - return checkThrowStatement(node); - case 209: - return checkTryStatement(node); - case 211: - return checkVariableDeclaration(node); - case 163: - return checkBindingElement(node); - case 214: - return checkClassDeclaration(node); - case 215: - return checkInterfaceDeclaration(node); - case 216: - return checkTypeAliasDeclaration(node); - case 217: - return checkEnumDeclaration(node); - case 218: - return checkModuleDeclaration(node); - case 222: - return checkImportDeclaration(node); - case 221: - return checkImportEqualsDeclaration(node); - case 228: - return checkExportDeclaration(node); - case 227: - return checkExportAssignment(node); - case 194: - checkGrammarStatementInAmbientContext(node); - return; - case 210: - checkGrammarStatementInAmbientContext(node); - return; - case 231: - return checkMissingDeclaration(node); - } - } - function checkFunctionAndClassExpressionBodies(node) { - switch (node.kind) { - case 173: - case 174: - ts.forEach(node.parameters, checkFunctionAndClassExpressionBodies); - checkFunctionExpressionOrObjectLiteralMethodBody(node); - break; - case 186: - ts.forEach(node.members, checkSourceElement); - ts.forEachChild(node, checkFunctionAndClassExpressionBodies); - break; - case 143: - case 142: - ts.forEach(node.decorators, checkFunctionAndClassExpressionBodies); - ts.forEach(node.parameters, checkFunctionAndClassExpressionBodies); - if (ts.isObjectLiteralMethod(node)) { - checkFunctionExpressionOrObjectLiteralMethodBody(node); - } - break; - case 144: - case 145: - case 146: - case 213: - ts.forEach(node.parameters, checkFunctionAndClassExpressionBodies); - break; - case 205: - checkFunctionAndClassExpressionBodies(node.expression); - break; - case 139: - case 138: - case 141: - case 140: - case 161: - case 162: - case 163: - case 164: - case 165: - case 245: - case 166: - case 167: - case 168: - case 169: - case 170: - case 183: - case 190: - case 171: - case 189: - case 172: - case 176: - case 177: - case 178: - case 175: - case 179: - case 180: - case 181: - case 182: - case 185: - case 184: - case 192: - case 219: - case 193: - case 195: - case 196: - case 197: - case 198: - case 199: - case 200: - case 201: - case 202: - case 203: - case 204: - case 206: - case 220: - case 241: - case 242: - case 207: - case 208: - case 209: - case 244: - case 211: - case 212: - case 214: - case 243: - case 188: - case 217: - case 247: - case 227: - case 248: - case 240: - case 233: - case 234: - case 238: - case 239: - case 235: - ts.forEachChild(node, checkFunctionAndClassExpressionBodies); - break; - } - } - function checkSourceFile(node) { - var start = new Date().getTime(); - checkSourceFileWorker(node); - ts.checkTime += new Date().getTime() - start; - } - function checkSourceFileWorker(node) { - var links = getNodeLinks(node); - if (!(links.flags & 1)) { - if (node.isDefaultLib && compilerOptions.skipDefaultLibCheck) { - return; - } - checkGrammarSourceFile(node); - emitExtends = false; - emitDecorate = false; - emitParam = false; - potentialThisCollisions.length = 0; - ts.forEach(node.statements, checkSourceElement); - checkFunctionAndClassExpressionBodies(node); - if (ts.isExternalModule(node)) { - checkExternalModuleExports(node); - } - if (potentialThisCollisions.length) { - ts.forEach(potentialThisCollisions, checkIfThisIsCapturedInEnclosingScope); - potentialThisCollisions.length = 0; - } - if (emitExtends) { - links.flags |= 8; - } - if (emitDecorate) { - links.flags |= 16; - } - if (emitParam) { - links.flags |= 32; - } - if (emitAwaiter) { - links.flags |= 64; - } - if (emitGenerator || (emitAwaiter && languageVersion < 2)) { - links.flags |= 128; - } - links.flags |= 1; - } - } - function getDiagnostics(sourceFile, ct) { - try { - cancellationToken = ct; - return getDiagnosticsWorker(sourceFile); - } - finally { - cancellationToken = undefined; - } - } - function getDiagnosticsWorker(sourceFile) { - throwIfNonDiagnosticsProducing(); - if (sourceFile) { - checkSourceFile(sourceFile); - return diagnostics.getDiagnostics(sourceFile.fileName); - } - ts.forEach(host.getSourceFiles(), checkSourceFile); - return diagnostics.getDiagnostics(); - } - function getGlobalDiagnostics() { - throwIfNonDiagnosticsProducing(); - return diagnostics.getGlobalDiagnostics(); - } - function throwIfNonDiagnosticsProducing() { - if (!produceDiagnostics) { - throw new Error("Trying to get diagnostics from a type checker that does not produce them."); - } - } - function isInsideWithStatementBody(node) { - if (node) { - while (node.parent) { - if (node.parent.kind === 205 && node.parent.statement === node) { - return true; - } - node = node.parent; - } - } - return false; - } - function getSymbolsInScope(location, meaning) { - var symbols = {}; - var memberFlags = 0; - if (isInsideWithStatementBody(location)) { - return []; - } - populateSymbols(); - return symbolsToArray(symbols); - function populateSymbols() { - while (location) { - if (location.locals && !isGlobalSourceFile(location)) { - copySymbols(location.locals, meaning); - } - switch (location.kind) { - case 248: - if (!ts.isExternalModule(location)) { - break; - } - case 218: - copySymbols(getSymbolOfNode(location).exports, meaning & 8914931); - break; - case 217: - copySymbols(getSymbolOfNode(location).exports, meaning & 8); - break; - case 186: - var className = location.name; - if (className) { - copySymbol(location.symbol, meaning); - } - case 214: - case 215: - if (!(memberFlags & 128)) { - copySymbols(getSymbolOfNode(location).members, meaning & 793056); - } - break; - case 173: - var funcName = location.name; - if (funcName) { - copySymbol(location.symbol, meaning); - } - break; - } - if (ts.introducesArgumentsExoticObject(location)) { - copySymbol(argumentsSymbol, meaning); - } - memberFlags = location.flags; - location = location.parent; - } - copySymbols(globals, meaning); - } - function copySymbol(symbol, meaning) { - if (symbol.flags & meaning) { - var id = symbol.name; - if (!ts.hasProperty(symbols, id)) { - symbols[id] = symbol; - } - } - } - function copySymbols(source, meaning) { - if (meaning) { - for (var id in source) { - var symbol = source[id]; - copySymbol(symbol, meaning); - } - } - } - } - function isTypeDeclarationName(name) { - return name.kind === 69 && - isTypeDeclaration(name.parent) && - name.parent.name === name; - } - function isTypeDeclaration(node) { - switch (node.kind) { - case 137: - case 214: - case 215: - case 216: - case 217: - return true; - } - } - function isTypeReferenceIdentifier(entityName) { - var node = entityName; - while (node.parent && node.parent.kind === 135) { - node = node.parent; - } - return node.parent && node.parent.kind === 151; - } - function isHeritageClauseElementIdentifier(entityName) { - var node = entityName; - while (node.parent && node.parent.kind === 166) { - node = node.parent; - } - return node.parent && node.parent.kind === 188; - } - function getLeftSideOfImportEqualsOrExportAssignment(nodeOnRightSide) { - while (nodeOnRightSide.parent.kind === 135) { - nodeOnRightSide = nodeOnRightSide.parent; - } - if (nodeOnRightSide.parent.kind === 221) { - return nodeOnRightSide.parent.moduleReference === nodeOnRightSide && nodeOnRightSide.parent; - } - if (nodeOnRightSide.parent.kind === 227) { - return nodeOnRightSide.parent.expression === nodeOnRightSide && nodeOnRightSide.parent; - } - return undefined; - } - function isInRightSideOfImportOrExportAssignment(node) { - return getLeftSideOfImportEqualsOrExportAssignment(node) !== undefined; - } - function getSymbolOfEntityNameOrPropertyAccessExpression(entityName) { - if (ts.isDeclarationName(entityName)) { - return getSymbolOfNode(entityName.parent); - } - if (entityName.parent.kind === 227) { - return resolveEntityName(entityName, 107455 | 793056 | 1536 | 8388608); - } - if (entityName.kind !== 166) { - if (isInRightSideOfImportOrExportAssignment(entityName)) { - return getSymbolOfPartOfRightHandSideOfImportEquals(entityName); - } - } - if (ts.isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { - entityName = entityName.parent; - } - if (isHeritageClauseElementIdentifier(entityName)) { - var meaning = 0; - if (entityName.parent.kind === 188) { - meaning = 793056; - if (ts.isExpressionWithTypeArgumentsInClassExtendsClause(entityName.parent)) { - meaning |= 107455; - } - } - else { - meaning = 1536; - } - meaning |= 8388608; - return resolveEntityName(entityName, meaning); - } - else if ((entityName.parent.kind === 235) || - (entityName.parent.kind === 234) || - (entityName.parent.kind === 237)) { - return getJsxElementTagSymbol(entityName.parent); - } - else if (ts.isExpression(entityName)) { - if (ts.nodeIsMissing(entityName)) { - return undefined; - } - if (entityName.kind === 69) { - var meaning = 107455 | 8388608; - return resolveEntityName(entityName, meaning); - } - else if (entityName.kind === 166) { - var symbol = getNodeLinks(entityName).resolvedSymbol; - if (!symbol) { - checkPropertyAccessExpression(entityName); - } - return getNodeLinks(entityName).resolvedSymbol; - } - else if (entityName.kind === 135) { - var symbol = getNodeLinks(entityName).resolvedSymbol; - if (!symbol) { - checkQualifiedName(entityName); - } - return getNodeLinks(entityName).resolvedSymbol; - } - } - else if (isTypeReferenceIdentifier(entityName)) { - var meaning = entityName.parent.kind === 151 ? 793056 : 1536; - meaning |= 8388608; - return resolveEntityName(entityName, meaning); - } - else if (entityName.parent.kind === 238) { - return getJsxAttributePropertySymbol(entityName.parent); - } - if (entityName.parent.kind === 150) { - return resolveEntityName(entityName, 1); - } - return undefined; - } - function getSymbolAtLocation(node) { - if (isInsideWithStatementBody(node)) { - return undefined; - } - if (ts.isDeclarationName(node)) { - return getSymbolOfNode(node.parent); - } - if (node.kind === 69) { - if (isInRightSideOfImportOrExportAssignment(node)) { - return node.parent.kind === 227 - ? getSymbolOfEntityNameOrPropertyAccessExpression(node) - : getSymbolOfPartOfRightHandSideOfImportEquals(node); - } - else if (node.parent.kind === 163 && - node.parent.parent.kind === 161 && - node === node.parent.propertyName) { - var typeOfPattern = getTypeOfNode(node.parent.parent); - var propertyDeclaration = typeOfPattern && getPropertyOfType(typeOfPattern, node.text); - if (propertyDeclaration) { - return propertyDeclaration; - } - } - } - switch (node.kind) { - case 69: - case 166: - case 135: - return getSymbolOfEntityNameOrPropertyAccessExpression(node); - case 97: - case 95: - var type = ts.isExpression(node) ? checkExpression(node) : getTypeFromTypeNode(node); - return type.symbol; - case 121: - var constructorDeclaration = node.parent; - if (constructorDeclaration && constructorDeclaration.kind === 144) { - return constructorDeclaration.parent.symbol; - } - return undefined; - case 9: - if ((ts.isExternalModuleImportEqualsDeclaration(node.parent.parent) && - ts.getExternalModuleImportEqualsDeclarationExpression(node.parent.parent) === node) || - ((node.parent.kind === 222 || node.parent.kind === 228) && - node.parent.moduleSpecifier === node)) { - return resolveExternalModuleName(node, node); - } - case 8: - if (node.parent.kind === 167 && node.parent.argumentExpression === node) { - var objectType = checkExpression(node.parent.expression); - if (objectType === unknownType) - return undefined; - var apparentType = getApparentType(objectType); - if (apparentType === unknownType) - return undefined; - return getPropertyOfType(apparentType, node.text); - } - break; - } - return undefined; - } - function getShorthandAssignmentValueSymbol(location) { - if (location && location.kind === 246) { - return resolveEntityName(location.name, 107455); - } - return undefined; - } - function getTypeOfNode(node) { - if (isInsideWithStatementBody(node)) { - return unknownType; - } - if (ts.isTypeNode(node)) { - return getTypeFromTypeNode(node); - } - if (ts.isExpression(node)) { - return getTypeOfExpression(node); - } - if (ts.isExpressionWithTypeArgumentsInClassExtendsClause(node)) { - return getBaseTypes(getDeclaredTypeOfSymbol(getSymbolOfNode(node.parent.parent)))[0]; - } - if (isTypeDeclaration(node)) { - var symbol = getSymbolOfNode(node); - return getDeclaredTypeOfSymbol(symbol); - } - if (isTypeDeclarationName(node)) { - var symbol = getSymbolAtLocation(node); - return symbol && getDeclaredTypeOfSymbol(symbol); - } - if (ts.isDeclaration(node)) { - var symbol = getSymbolOfNode(node); - return getTypeOfSymbol(symbol); - } - if (ts.isDeclarationName(node)) { - var symbol = getSymbolAtLocation(node); - return symbol && getTypeOfSymbol(symbol); - } - if (ts.isBindingPattern(node)) { - return getTypeForVariableLikeDeclaration(node.parent); - } - if (isInRightSideOfImportOrExportAssignment(node)) { - var symbol = getSymbolAtLocation(node); - var declaredType = symbol && getDeclaredTypeOfSymbol(symbol); - return declaredType !== unknownType ? declaredType : getTypeOfSymbol(symbol); - } - return unknownType; - } - function getTypeOfExpression(expr) { - if (ts.isRightSideOfQualifiedNameOrPropertyAccess(expr)) { - expr = expr.parent; - } - return checkExpression(expr); - } - function getParentTypeOfClassElement(node) { - var classSymbol = getSymbolOfNode(node.parent); - return node.flags & 128 - ? getTypeOfSymbol(classSymbol) - : getDeclaredTypeOfSymbol(classSymbol); - } - function getAugmentedPropertiesOfType(type) { - type = getApparentType(type); - var propsByName = createSymbolTable(getPropertiesOfType(type)); - if (getSignaturesOfType(type, 0).length || getSignaturesOfType(type, 1).length) { - ts.forEach(getPropertiesOfType(globalFunctionType), function (p) { - if (!ts.hasProperty(propsByName, p.name)) { - propsByName[p.name] = p; - } - }); - } - return getNamedMembers(propsByName); - } - function getRootSymbols(symbol) { - if (symbol.flags & 268435456) { - var symbols = []; - var name_15 = symbol.name; - ts.forEach(getSymbolLinks(symbol).containingType.types, function (t) { - var symbol = getPropertyOfType(t, name_15); - if (symbol) { - symbols.push(symbol); - } - }); - return symbols; - } - else if (symbol.flags & 67108864) { - var target = getSymbolLinks(symbol).target; - if (target) { - return [target]; - } - } - return [symbol]; - } - function getReferencedExportContainer(node) { - var symbol = getReferencedValueSymbol(node); - if (symbol) { - if (symbol.flags & 1048576) { - var exportSymbol = getMergedSymbol(symbol.exportSymbol); - if (exportSymbol.flags & 944) { - return undefined; - } - symbol = exportSymbol; - } - var parentSymbol = getParentOfSymbol(symbol); - if (parentSymbol) { - if (parentSymbol.flags & 512 && parentSymbol.valueDeclaration.kind === 248) { - return parentSymbol.valueDeclaration; - } - for (var n = node.parent; n; n = n.parent) { - if ((n.kind === 218 || n.kind === 217) && getSymbolOfNode(n) === parentSymbol) { - return n; - } - } - } - } - } - function getReferencedImportDeclaration(node) { - var symbol = getReferencedValueSymbol(node); - return symbol && symbol.flags & 8388608 ? getDeclarationOfAliasSymbol(symbol) : undefined; - } - function isStatementWithLocals(node) { - switch (node.kind) { - case 192: - case 220: - case 199: - case 200: - case 201: - return true; - } - return false; - } - function isNestedRedeclarationSymbol(symbol) { - if (symbol.flags & 418) { - var links = getSymbolLinks(symbol); - if (links.isNestedRedeclaration === undefined) { - var container = ts.getEnclosingBlockScopeContainer(symbol.valueDeclaration); - links.isNestedRedeclaration = isStatementWithLocals(container) && - !!resolveName(container.parent, symbol.name, 107455, undefined, undefined); - } - return links.isNestedRedeclaration; - } - return false; - } - function getReferencedNestedRedeclaration(node) { - var symbol = getReferencedValueSymbol(node); - return symbol && isNestedRedeclarationSymbol(symbol) ? symbol.valueDeclaration : undefined; - } - function isNestedRedeclaration(node) { - return isNestedRedeclarationSymbol(getSymbolOfNode(node)); - } - function isValueAliasDeclaration(node) { - switch (node.kind) { - case 221: - case 223: - case 224: - case 226: - case 230: - return isAliasResolvedToValue(getSymbolOfNode(node)); - case 228: - var exportClause = node.exportClause; - return exportClause && ts.forEach(exportClause.elements, isValueAliasDeclaration); - case 227: - return node.expression && node.expression.kind === 69 ? isAliasResolvedToValue(getSymbolOfNode(node)) : true; - } - return false; - } - function isTopLevelValueImportEqualsWithEntityName(node) { - if (node.parent.kind !== 248 || !ts.isInternalModuleImportEqualsDeclaration(node)) { - return false; - } - var isValue = isAliasResolvedToValue(getSymbolOfNode(node)); - return isValue && node.moduleReference && !ts.nodeIsMissing(node.moduleReference); - } - function isAliasResolvedToValue(symbol) { - var target = resolveAlias(symbol); - if (target === unknownSymbol && compilerOptions.isolatedModules) { - return true; - } - return target !== unknownSymbol && - target && - target.flags & 107455 && - (compilerOptions.preserveConstEnums || !isConstEnumOrConstEnumOnlyModule(target)); - } - function isConstEnumOrConstEnumOnlyModule(s) { - return isConstEnumSymbol(s) || s.constEnumOnlyModule; - } - function isReferencedAliasDeclaration(node, checkChildren) { - if (ts.isAliasSymbolDeclaration(node)) { - var symbol = getSymbolOfNode(node); - if (getSymbolLinks(symbol).referenced) { - return true; - } - } - if (checkChildren) { - return ts.forEachChild(node, function (node) { return isReferencedAliasDeclaration(node, checkChildren); }); - } - return false; - } - function isImplementationOfOverload(node) { - if (ts.nodeIsPresent(node.body)) { - var symbol = getSymbolOfNode(node); - var signaturesOfSymbol = getSignaturesOfSymbol(symbol); - return signaturesOfSymbol.length > 1 || - (signaturesOfSymbol.length === 1 && signaturesOfSymbol[0].declaration !== node); - } - return false; - } - function getNodeCheckFlags(node) { - return getNodeLinks(node).flags; - } - function getEnumMemberValue(node) { - computeEnumMemberValues(node.parent); - return getNodeLinks(node).enumMemberValue; - } - function getConstantValue(node) { - if (node.kind === 247) { - return getEnumMemberValue(node); - } - var symbol = getNodeLinks(node).resolvedSymbol; - if (symbol && (symbol.flags & 8)) { - if (ts.isConstEnumDeclaration(symbol.valueDeclaration.parent)) { - return getEnumMemberValue(symbol.valueDeclaration); - } - } - return undefined; - } - function isFunctionType(type) { - return type.flags & 80896 && getSignaturesOfType(type, 0).length > 0; - } - function getTypeReferenceSerializationKind(typeName) { - var valueSymbol = resolveEntityName(typeName, 107455, true); - var constructorType = valueSymbol ? getTypeOfSymbol(valueSymbol) : undefined; - if (constructorType && isConstructorType(constructorType)) { - return ts.TypeReferenceSerializationKind.TypeWithConstructSignatureAndValue; - } - var typeSymbol = resolveEntityName(typeName, 793056, true); - if (!typeSymbol) { - return ts.TypeReferenceSerializationKind.ObjectType; - } - var type = getDeclaredTypeOfSymbol(typeSymbol); - if (type === unknownType) { - return ts.TypeReferenceSerializationKind.Unknown; - } - else if (type.flags & 1) { - return ts.TypeReferenceSerializationKind.ObjectType; - } - else if (allConstituentTypesHaveKind(type, 16)) { - return ts.TypeReferenceSerializationKind.VoidType; - } - else if (allConstituentTypesHaveKind(type, 8)) { - return ts.TypeReferenceSerializationKind.BooleanType; - } - else if (allConstituentTypesHaveKind(type, 132)) { - return ts.TypeReferenceSerializationKind.NumberLikeType; - } - else if (allConstituentTypesHaveKind(type, 258)) { - return ts.TypeReferenceSerializationKind.StringLikeType; - } - else if (allConstituentTypesHaveKind(type, 8192)) { - return ts.TypeReferenceSerializationKind.ArrayLikeType; - } - else if (allConstituentTypesHaveKind(type, 16777216)) { - return ts.TypeReferenceSerializationKind.ESSymbolType; - } - else if (isFunctionType(type)) { - return ts.TypeReferenceSerializationKind.TypeWithCallSignature; - } - else if (isArrayType(type)) { - return ts.TypeReferenceSerializationKind.ArrayLikeType; - } - else { - return ts.TypeReferenceSerializationKind.ObjectType; - } - } - function writeTypeOfDeclaration(declaration, enclosingDeclaration, flags, writer) { - var symbol = getSymbolOfNode(declaration); - var type = symbol && !(symbol.flags & (2048 | 131072)) - ? getTypeOfSymbol(symbol) - : unknownType; - getSymbolDisplayBuilder().buildTypeDisplay(type, writer, enclosingDeclaration, flags); - } - function writeReturnTypeOfSignatureDeclaration(signatureDeclaration, enclosingDeclaration, flags, writer) { - var signature = getSignatureFromDeclaration(signatureDeclaration); - getSymbolDisplayBuilder().buildTypeDisplay(getReturnTypeOfSignature(signature), writer, enclosingDeclaration, flags); - } - function writeTypeOfExpression(expr, enclosingDeclaration, flags, writer) { - var type = getTypeOfExpression(expr); - getSymbolDisplayBuilder().buildTypeDisplay(type, writer, enclosingDeclaration, flags); - } - function hasGlobalName(name) { - return ts.hasProperty(globals, name); - } - function getReferencedValueSymbol(reference) { - return getNodeLinks(reference).resolvedSymbol || - resolveName(reference, reference.text, 107455 | 1048576 | 8388608, undefined, undefined); - } - function getReferencedValueDeclaration(reference) { - ts.Debug.assert(!ts.nodeIsSynthesized(reference)); - var symbol = getReferencedValueSymbol(reference); - return symbol && getExportSymbolOfValueSymbolIfExported(symbol).valueDeclaration; - } - function instantiateSingleCallFunctionType(functionType, typeArguments) { - if (functionType === unknownType) { - return unknownType; - } - var signature = getSingleCallSignature(functionType); - if (!signature) { - return unknownType; - } - var instantiatedSignature = getSignatureInstantiation(signature, typeArguments); - return getOrCreateTypeFromSignature(instantiatedSignature); - } - function createResolver() { - return { - getReferencedExportContainer: getReferencedExportContainer, - getReferencedImportDeclaration: getReferencedImportDeclaration, - getReferencedNestedRedeclaration: getReferencedNestedRedeclaration, - isNestedRedeclaration: isNestedRedeclaration, - isValueAliasDeclaration: isValueAliasDeclaration, - hasGlobalName: hasGlobalName, - isReferencedAliasDeclaration: isReferencedAliasDeclaration, - getNodeCheckFlags: getNodeCheckFlags, - isTopLevelValueImportEqualsWithEntityName: isTopLevelValueImportEqualsWithEntityName, - isDeclarationVisible: isDeclarationVisible, - isImplementationOfOverload: isImplementationOfOverload, - writeTypeOfDeclaration: writeTypeOfDeclaration, - writeReturnTypeOfSignatureDeclaration: writeReturnTypeOfSignatureDeclaration, - writeTypeOfExpression: writeTypeOfExpression, - isSymbolAccessible: isSymbolAccessible, - isEntityNameVisible: isEntityNameVisible, - getConstantValue: getConstantValue, - collectLinkedAliases: collectLinkedAliases, - getReferencedValueDeclaration: getReferencedValueDeclaration, - getTypeReferenceSerializationKind: getTypeReferenceSerializationKind, - isOptionalParameter: isOptionalParameter - }; - } - function initializeTypeChecker() { - ts.forEach(host.getSourceFiles(), function (file) { - ts.bindSourceFile(file); - }); - ts.forEach(host.getSourceFiles(), function (file) { - if (!ts.isExternalModule(file)) { - mergeSymbolTable(globals, file.locals); - } - }); - getSymbolLinks(undefinedSymbol).type = undefinedType; - getSymbolLinks(argumentsSymbol).type = getGlobalType("IArguments"); - getSymbolLinks(unknownSymbol).type = unknownType; - globals[undefinedSymbol.name] = undefinedSymbol; - globalArrayType = getGlobalType("Array", 1); - globalObjectType = getGlobalType("Object"); - globalFunctionType = getGlobalType("Function"); - globalStringType = getGlobalType("String"); - globalNumberType = getGlobalType("Number"); - globalBooleanType = getGlobalType("Boolean"); - globalRegExpType = getGlobalType("RegExp"); - jsxElementType = getExportedTypeFromNamespace("JSX", JsxNames.Element); - getGlobalClassDecoratorType = ts.memoize(function () { return getGlobalType("ClassDecorator"); }); - getGlobalPropertyDecoratorType = ts.memoize(function () { return getGlobalType("PropertyDecorator"); }); - getGlobalMethodDecoratorType = ts.memoize(function () { return getGlobalType("MethodDecorator"); }); - getGlobalParameterDecoratorType = ts.memoize(function () { return getGlobalType("ParameterDecorator"); }); - getGlobalTypedPropertyDescriptorType = ts.memoize(function () { return getGlobalType("TypedPropertyDescriptor", 1); }); - getGlobalPromiseType = ts.memoize(function () { return getGlobalType("Promise", 1); }); - tryGetGlobalPromiseType = ts.memoize(function () { return getGlobalSymbol("Promise", 793056, undefined) && getGlobalPromiseType(); }); - getGlobalPromiseLikeType = ts.memoize(function () { return getGlobalType("PromiseLike", 1); }); - getInstantiatedGlobalPromiseLikeType = ts.memoize(createInstantiatedPromiseLikeType); - getGlobalPromiseConstructorSymbol = ts.memoize(function () { return getGlobalValueSymbol("Promise"); }); - getGlobalPromiseConstructorLikeType = ts.memoize(function () { return getGlobalType("PromiseConstructorLike"); }); - getGlobalThenableType = ts.memoize(createThenableType); - if (languageVersion >= 2) { - globalTemplateStringsArrayType = getGlobalType("TemplateStringsArray"); - globalESSymbolType = getGlobalType("Symbol"); - globalESSymbolConstructorSymbol = getGlobalValueSymbol("Symbol"); - globalIterableType = getGlobalType("Iterable", 1); - globalIteratorType = getGlobalType("Iterator", 1); - globalIterableIteratorType = getGlobalType("IterableIterator", 1); - } - else { - globalTemplateStringsArrayType = unknownType; - globalESSymbolType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); - globalESSymbolConstructorSymbol = undefined; - globalIterableType = emptyGenericType; - globalIteratorType = emptyGenericType; - globalIterableIteratorType = emptyGenericType; - } - anyArrayType = createArrayType(anyType); - } - function createInstantiatedPromiseLikeType() { - var promiseLikeType = getGlobalPromiseLikeType(); - if (promiseLikeType !== emptyGenericType) { - return createTypeReference(promiseLikeType, [anyType]); - } - return emptyObjectType; - } - function createThenableType() { - var thenPropertySymbol = createSymbol(67108864 | 4, "then"); - getSymbolLinks(thenPropertySymbol).type = globalFunctionType; - var thenableType = createObjectType(65536); - thenableType.properties = [thenPropertySymbol]; - thenableType.members = createSymbolTable(thenableType.properties); - thenableType.callSignatures = []; - thenableType.constructSignatures = []; - return thenableType; - } - function checkGrammarDecorators(node) { - if (!node.decorators) { - return false; - } - if (!ts.nodeCanBeDecorated(node)) { - return grammarErrorOnFirstToken(node, ts.Diagnostics.Decorators_are_not_valid_here); - } - else if (node.kind === 145 || node.kind === 146) { - var accessors = ts.getAllAccessorDeclarations(node.parent.members, node); - if (accessors.firstAccessor.decorators && node === accessors.secondAccessor) { - return grammarErrorOnFirstToken(node, ts.Diagnostics.Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name); - } - } - return false; - } - function checkGrammarModifiers(node) { - switch (node.kind) { - case 145: - case 146: - case 144: - case 141: - case 140: - case 143: - case 142: - case 149: - case 218: - case 222: - case 221: - case 228: - case 227: - case 138: - break; - case 213: - if (node.modifiers && (node.modifiers.length > 1 || node.modifiers[0].kind !== 118) && - node.parent.kind !== 219 && node.parent.kind !== 248) { - return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); - } - break; - case 214: - case 215: - case 193: - case 216: - if (node.modifiers && node.parent.kind !== 219 && node.parent.kind !== 248) { - return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); - } - break; - case 217: - if (node.modifiers && (node.modifiers.length > 1 || node.modifiers[0].kind !== 74) && - node.parent.kind !== 219 && node.parent.kind !== 248) { - return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); - } - break; - default: - return false; - } - if (!node.modifiers) { - return; - } - var lastStatic, lastPrivate, lastProtected, lastDeclare, lastAsync; - var flags = 0; - for (var _i = 0, _a = node.modifiers; _i < _a.length; _i++) { - var modifier = _a[_i]; - switch (modifier.kind) { - case 112: - case 111: - case 110: - var text = void 0; - if (modifier.kind === 112) { - text = "public"; - } - else if (modifier.kind === 111) { - text = "protected"; - lastProtected = modifier; - } - else { - text = "private"; - lastPrivate = modifier; - } - if (flags & 112) { - return grammarErrorOnNode(modifier, ts.Diagnostics.Accessibility_modifier_already_seen); - } - else if (flags & 128) { - return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "static"); - } - else if (flags & 512) { - return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "async"); - } - else if (node.parent.kind === 219 || node.parent.kind === 248) { - return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_element, text); - } - else if (flags & 256) { - if (modifier.kind === 110) { - return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, text, "abstract"); - } - else { - return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "abstract"); - } - } - flags |= ts.modifierToFlag(modifier.kind); - break; - case 113: - if (flags & 128) { - return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "static"); - } - else if (flags & 512) { - return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "static", "async"); - } - else if (node.parent.kind === 219 || node.parent.kind === 248) { - return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_element, "static"); - } - else if (node.kind === 138) { - return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "static"); - } - else if (flags & 256) { - return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "static", "abstract"); - } - flags |= 128; - lastStatic = modifier; - break; - case 82: - if (flags & 1) { - return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "export"); - } - else if (flags & 2) { - return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "declare"); - } - else if (flags & 256) { - return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "abstract"); - } - else if (flags & 512) { - return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "async"); - } - else if (node.parent.kind === 214) { - return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "export"); - } - else if (node.kind === 138) { - return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "export"); - } - flags |= 1; - break; - case 122: - if (flags & 2) { - return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "declare"); - } - else if (flags & 512) { - return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); - } - else if (node.parent.kind === 214) { - return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "declare"); - } - else if (node.kind === 138) { - return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "declare"); - } - else if (ts.isInAmbientContext(node.parent) && node.parent.kind === 219) { - return grammarErrorOnNode(modifier, ts.Diagnostics.A_declare_modifier_cannot_be_used_in_an_already_ambient_context); - } - flags |= 2; - lastDeclare = modifier; - break; - case 115: - if (flags & 256) { - return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "abstract"); - } - if (node.kind !== 214) { - if (node.kind !== 143) { - return grammarErrorOnNode(modifier, ts.Diagnostics.abstract_modifier_can_only_appear_on_a_class_or_method_declaration); - } - if (!(node.parent.kind === 214 && node.parent.flags & 256)) { - return grammarErrorOnNode(modifier, ts.Diagnostics.Abstract_methods_can_only_appear_within_an_abstract_class); - } - if (flags & 128) { - return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "static", "abstract"); - } - if (flags & 32) { - return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "private", "abstract"); - } - } - flags |= 256; - break; - case 118: - if (flags & 512) { - return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "async"); - } - else if (flags & 2 || ts.isInAmbientContext(node.parent)) { - return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); - } - else if (node.kind === 138) { - return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "async"); - } - flags |= 512; - lastAsync = modifier; - break; - } - } - if (node.kind === 144) { - if (flags & 128) { - return grammarErrorOnNode(lastStatic, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "static"); - } - if (flags & 256) { - return grammarErrorOnNode(lastStatic, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "abstract"); - } - else if (flags & 64) { - return grammarErrorOnNode(lastProtected, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "protected"); - } - else if (flags & 32) { - return grammarErrorOnNode(lastPrivate, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "private"); - } - else if (flags & 512) { - return grammarErrorOnNode(lastAsync, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "async"); - } - return; - } - else if ((node.kind === 222 || node.kind === 221) && flags & 2) { - return grammarErrorOnNode(lastDeclare, ts.Diagnostics.A_0_modifier_cannot_be_used_with_an_import_declaration, "declare"); - } - else if (node.kind === 138 && (flags & 112) && ts.isBindingPattern(node.name)) { - return grammarErrorOnNode(node, ts.Diagnostics.A_parameter_property_may_not_be_a_binding_pattern); - } - if (flags & 512) { - return checkGrammarAsyncModifier(node, lastAsync); - } - } - function checkGrammarAsyncModifier(node, asyncModifier) { - if (languageVersion < 2) { - return grammarErrorOnNode(asyncModifier, ts.Diagnostics.Async_functions_are_only_available_when_targeting_ECMAScript_6_and_higher); - } - switch (node.kind) { - case 143: - case 213: - case 173: - case 174: - if (!node.asteriskToken) { - return false; - } - break; - } - return grammarErrorOnNode(asyncModifier, ts.Diagnostics._0_modifier_cannot_be_used_here, "async"); - } - function checkGrammarForDisallowedTrailingComma(list) { - if (list && list.hasTrailingComma) { - var start = list.end - ",".length; - var end = list.end; - var sourceFile = ts.getSourceFileOfNode(list[0]); - return grammarErrorAtPos(sourceFile, start, end - start, ts.Diagnostics.Trailing_comma_not_allowed); - } - } - function checkGrammarTypeParameterList(node, typeParameters, file) { - if (checkGrammarForDisallowedTrailingComma(typeParameters)) { - return true; - } - if (typeParameters && typeParameters.length === 0) { - var start = typeParameters.pos - "<".length; - var end = ts.skipTrivia(file.text, typeParameters.end) + ">".length; - return grammarErrorAtPos(file, start, end - start, ts.Diagnostics.Type_parameter_list_cannot_be_empty); - } - } - function checkGrammarParameterList(parameters) { - if (checkGrammarForDisallowedTrailingComma(parameters)) { - return true; - } - var seenOptionalParameter = false; - var parameterCount = parameters.length; - for (var i = 0; i < parameterCount; i++) { - var parameter = parameters[i]; - if (parameter.dotDotDotToken) { - if (i !== (parameterCount - 1)) { - return grammarErrorOnNode(parameter.dotDotDotToken, ts.Diagnostics.A_rest_parameter_must_be_last_in_a_parameter_list); - } - if (ts.isBindingPattern(parameter.name)) { - return grammarErrorOnNode(parameter.name, ts.Diagnostics.A_rest_element_cannot_contain_a_binding_pattern); - } - if (parameter.questionToken) { - return grammarErrorOnNode(parameter.questionToken, ts.Diagnostics.A_rest_parameter_cannot_be_optional); - } - if (parameter.initializer) { - return grammarErrorOnNode(parameter.name, ts.Diagnostics.A_rest_parameter_cannot_have_an_initializer); - } - } - else if (parameter.questionToken) { - seenOptionalParameter = true; - if (parameter.initializer) { - return grammarErrorOnNode(parameter.name, ts.Diagnostics.Parameter_cannot_have_question_mark_and_initializer); - } - } - else if (seenOptionalParameter && !parameter.initializer) { - return grammarErrorOnNode(parameter.name, ts.Diagnostics.A_required_parameter_cannot_follow_an_optional_parameter); - } - } - } - function checkGrammarFunctionLikeDeclaration(node) { - var file = ts.getSourceFileOfNode(node); - return checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarTypeParameterList(node, node.typeParameters, file) || - checkGrammarParameterList(node.parameters) || checkGrammarArrowFunction(node, file); - } - function checkGrammarArrowFunction(node, file) { - if (node.kind === 174) { - var arrowFunction = node; - var startLine = ts.getLineAndCharacterOfPosition(file, arrowFunction.equalsGreaterThanToken.pos).line; - var endLine = ts.getLineAndCharacterOfPosition(file, arrowFunction.equalsGreaterThanToken.end).line; - if (startLine !== endLine) { - return grammarErrorOnNode(arrowFunction.equalsGreaterThanToken, ts.Diagnostics.Line_terminator_not_permitted_before_arrow); - } - } - return false; - } - function checkGrammarIndexSignatureParameters(node) { - var parameter = node.parameters[0]; - if (node.parameters.length !== 1) { - if (parameter) { - return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_must_have_exactly_one_parameter); - } - else { - return grammarErrorOnNode(node, ts.Diagnostics.An_index_signature_must_have_exactly_one_parameter); - } - } - if (parameter.dotDotDotToken) { - return grammarErrorOnNode(parameter.dotDotDotToken, ts.Diagnostics.An_index_signature_cannot_have_a_rest_parameter); - } - if (parameter.flags & 2035) { - return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_cannot_have_an_accessibility_modifier); - } - if (parameter.questionToken) { - return grammarErrorOnNode(parameter.questionToken, ts.Diagnostics.An_index_signature_parameter_cannot_have_a_question_mark); - } - if (parameter.initializer) { - return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_cannot_have_an_initializer); - } - if (!parameter.type) { - return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_must_have_a_type_annotation); - } - if (parameter.type.kind !== 130 && parameter.type.kind !== 128) { - return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_type_must_be_string_or_number); - } - if (!node.type) { - return grammarErrorOnNode(node, ts.Diagnostics.An_index_signature_must_have_a_type_annotation); - } - } - function checkGrammarForIndexSignatureModifier(node) { - if (node.flags & 2035) { - grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_not_permitted_on_index_signature_members); - } - } - function checkGrammarIndexSignature(node) { - return checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarIndexSignatureParameters(node) || checkGrammarForIndexSignatureModifier(node); - } - function checkGrammarForAtLeastOneTypeArgument(node, typeArguments) { - if (typeArguments && typeArguments.length === 0) { - var sourceFile = ts.getSourceFileOfNode(node); - var start = typeArguments.pos - "<".length; - var end = ts.skipTrivia(sourceFile.text, typeArguments.end) + ">".length; - return grammarErrorAtPos(sourceFile, start, end - start, ts.Diagnostics.Type_argument_list_cannot_be_empty); - } - } - function checkGrammarTypeArguments(node, typeArguments) { - return checkGrammarForDisallowedTrailingComma(typeArguments) || - checkGrammarForAtLeastOneTypeArgument(node, typeArguments); - } - function checkGrammarForOmittedArgument(node, args) { - if (args) { - var sourceFile = ts.getSourceFileOfNode(node); - for (var _i = 0; _i < args.length; _i++) { - var arg = args[_i]; - if (arg.kind === 187) { - return grammarErrorAtPos(sourceFile, arg.pos, 0, ts.Diagnostics.Argument_expression_expected); - } - } - } - } - function checkGrammarArguments(node, args) { - return checkGrammarForDisallowedTrailingComma(args) || - checkGrammarForOmittedArgument(node, args); - } - function checkGrammarHeritageClause(node) { - var types = node.types; - if (checkGrammarForDisallowedTrailingComma(types)) { - return true; - } - if (types && types.length === 0) { - var listType = ts.tokenToString(node.token); - var sourceFile = ts.getSourceFileOfNode(node); - return grammarErrorAtPos(sourceFile, types.pos, 0, ts.Diagnostics._0_list_cannot_be_empty, listType); - } - } - function checkGrammarClassDeclarationHeritageClauses(node) { - var seenExtendsClause = false; - var seenImplementsClause = false; - 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 (seenExtendsClause) { - return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_already_seen); - } - if (seenImplementsClause) { - return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_must_precede_implements_clause); - } - if (heritageClause.types.length > 1) { - return grammarErrorOnFirstToken(heritageClause.types[1], ts.Diagnostics.Classes_can_only_extend_a_single_class); - } - seenExtendsClause = true; - } - else { - ts.Debug.assert(heritageClause.token === 106); - if (seenImplementsClause) { - return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.implements_clause_already_seen); - } - seenImplementsClause = true; - } - checkGrammarHeritageClause(heritageClause); - } - } - } - function checkGrammarInterfaceDeclaration(node) { - var seenExtendsClause = false; - if (node.heritageClauses) { - for (var _i = 0, _a = node.heritageClauses; _i < _a.length; _i++) { - var heritageClause = _a[_i]; - if (heritageClause.token === 83) { - if (seenExtendsClause) { - return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_already_seen); - } - seenExtendsClause = true; - } - else { - ts.Debug.assert(heritageClause.token === 106); - return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.Interface_declaration_cannot_have_implements_clause); - } - checkGrammarHeritageClause(heritageClause); - } - } - return false; - } - function checkGrammarComputedPropertyName(node) { - if (node.kind !== 136) { - return false; - } - var computedPropertyName = node; - if (computedPropertyName.expression.kind === 181 && computedPropertyName.expression.operatorToken.kind === 24) { - return grammarErrorOnNode(computedPropertyName.expression, ts.Diagnostics.A_comma_expression_is_not_allowed_in_a_computed_property_name); - } - } - function checkGrammarForGenerator(node) { - if (node.asteriskToken) { - ts.Debug.assert(node.kind === 213 || - node.kind === 173 || - node.kind === 143); - if (ts.isInAmbientContext(node)) { - return grammarErrorOnNode(node.asteriskToken, ts.Diagnostics.Generators_are_not_allowed_in_an_ambient_context); - } - if (!node.body) { - return grammarErrorOnNode(node.asteriskToken, ts.Diagnostics.An_overload_signature_cannot_be_declared_as_a_generator); - } - if (languageVersion < 2) { - return grammarErrorOnNode(node.asteriskToken, ts.Diagnostics.Generators_are_only_available_when_targeting_ECMAScript_6_or_higher); - } - } - } - function checkGrammarForInvalidQuestionMark(node, questionToken, message) { - if (questionToken) { - return grammarErrorOnNode(questionToken, message); - } - } - function checkGrammarObjectLiteralExpression(node, inDestructuring) { - var seen = {}; - var Property = 1; - var GetAccessor = 2; - var SetAccesor = 4; - var GetOrSetAccessor = GetAccessor | SetAccesor; - for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { - var prop = _a[_i]; - var name_16 = prop.name; - if (prop.kind === 187 || - name_16.kind === 136) { - checkGrammarComputedPropertyName(name_16); - continue; - } - if (prop.kind === 246 && !inDestructuring && prop.objectAssignmentInitializer) { - return grammarErrorOnNode(prop.equalsToken, ts.Diagnostics.can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment); - } - var currentKind = void 0; - if (prop.kind === 245 || prop.kind === 246) { - checkGrammarForInvalidQuestionMark(prop, prop.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional); - if (name_16.kind === 8) { - checkGrammarNumericLiteral(name_16); - } - currentKind = Property; - } - else if (prop.kind === 143) { - currentKind = Property; - } - else if (prop.kind === 145) { - currentKind = GetAccessor; - } - else if (prop.kind === 146) { - currentKind = SetAccesor; - } - else { - ts.Debug.fail("Unexpected syntax kind:" + prop.kind); - } - if (!ts.hasProperty(seen, name_16.text)) { - seen[name_16.text] = currentKind; - } - else { - var existingKind = seen[name_16.text]; - if (currentKind === Property && existingKind === Property) { - continue; - } - else if ((currentKind & GetOrSetAccessor) && (existingKind & GetOrSetAccessor)) { - if (existingKind !== GetOrSetAccessor && currentKind !== existingKind) { - seen[name_16.text] = currentKind | existingKind; - } - else { - return grammarErrorOnNode(name_16, ts.Diagnostics.An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name); - } - } - else { - return grammarErrorOnNode(name_16, ts.Diagnostics.An_object_literal_cannot_have_property_and_accessor_with_the_same_name); - } - } - } - } - function checkGrammarJsxElement(node) { - var seen = {}; - for (var _i = 0, _a = node.attributes; _i < _a.length; _i++) { - var attr = _a[_i]; - if (attr.kind === 239) { - continue; - } - var jsxAttr = attr; - var name_17 = jsxAttr.name; - if (!ts.hasProperty(seen, name_17.text)) { - seen[name_17.text] = true; - } - else { - return grammarErrorOnNode(name_17, ts.Diagnostics.JSX_elements_cannot_have_multiple_attributes_with_the_same_name); - } - var initializer = jsxAttr.initializer; - if (initializer && initializer.kind === 240 && !initializer.expression) { - return grammarErrorOnNode(jsxAttr.initializer, ts.Diagnostics.JSX_attributes_must_only_be_assigned_a_non_empty_expression); - } - } - } - function checkGrammarForInOrForOfStatement(forInOrOfStatement) { - if (checkGrammarStatementInAmbientContext(forInOrOfStatement)) { - return true; - } - if (forInOrOfStatement.initializer.kind === 212) { - var variableList = forInOrOfStatement.initializer; - if (!checkGrammarVariableDeclarationList(variableList)) { - if (variableList.declarations.length > 1) { - var diagnostic = forInOrOfStatement.kind === 200 - ? ts.Diagnostics.Only_a_single_variable_declaration_is_allowed_in_a_for_in_statement - : ts.Diagnostics.Only_a_single_variable_declaration_is_allowed_in_a_for_of_statement; - return grammarErrorOnFirstToken(variableList.declarations[1], diagnostic); - } - var firstDeclaration = variableList.declarations[0]; - if (firstDeclaration.initializer) { - var diagnostic = forInOrOfStatement.kind === 200 - ? ts.Diagnostics.The_variable_declaration_of_a_for_in_statement_cannot_have_an_initializer - : ts.Diagnostics.The_variable_declaration_of_a_for_of_statement_cannot_have_an_initializer; - return grammarErrorOnNode(firstDeclaration.name, diagnostic); - } - if (firstDeclaration.type) { - var diagnostic = forInOrOfStatement.kind === 200 - ? ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_use_a_type_annotation - : ts.Diagnostics.The_left_hand_side_of_a_for_of_statement_cannot_use_a_type_annotation; - return grammarErrorOnNode(firstDeclaration, diagnostic); - } - } - } - return false; - } - function checkGrammarAccessor(accessor) { - var kind = accessor.kind; - if (languageVersion < 1) { - return grammarErrorOnNode(accessor.name, ts.Diagnostics.Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher); - } - else if (ts.isInAmbientContext(accessor)) { - return grammarErrorOnNode(accessor.name, ts.Diagnostics.An_accessor_cannot_be_declared_in_an_ambient_context); - } - else if (accessor.body === undefined) { - return grammarErrorAtPos(ts.getSourceFileOfNode(accessor), accessor.end - 1, ";".length, ts.Diagnostics._0_expected, "{"); - } - else if (accessor.typeParameters) { - return grammarErrorOnNode(accessor.name, ts.Diagnostics.An_accessor_cannot_have_type_parameters); - } - else if (kind === 145 && accessor.parameters.length) { - return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_get_accessor_cannot_have_parameters); - } - else if (kind === 146) { - if (accessor.type) { - return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_set_accessor_cannot_have_a_return_type_annotation); - } - else if (accessor.parameters.length !== 1) { - return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_set_accessor_must_have_exactly_one_parameter); - } - else { - var parameter = accessor.parameters[0]; - if (parameter.dotDotDotToken) { - return grammarErrorOnNode(parameter.dotDotDotToken, ts.Diagnostics.A_set_accessor_cannot_have_rest_parameter); - } - else if (parameter.flags & 2035) { - return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation); - } - else if (parameter.questionToken) { - return grammarErrorOnNode(parameter.questionToken, ts.Diagnostics.A_set_accessor_cannot_have_an_optional_parameter); - } - else if (parameter.initializer) { - return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_set_accessor_parameter_cannot_have_an_initializer); - } - } - } - } - function checkGrammarForNonSymbolComputedProperty(node, message) { - if (node.kind === 136 && !ts.isWellKnownSymbolSyntactically(node.expression)) { - return grammarErrorOnNode(node, message); - } - } - function checkGrammarMethod(node) { - if (checkGrammarDisallowedModifiersOnObjectLiteralExpressionMethod(node) || - checkGrammarFunctionLikeDeclaration(node) || - checkGrammarForGenerator(node)) { - return true; - } - if (node.parent.kind === 165) { - if (checkGrammarForInvalidQuestionMark(node, node.questionToken, ts.Diagnostics.A_class_member_cannot_be_declared_optional)) { - return true; - } - else if (node.body === undefined) { - return grammarErrorAtPos(getSourceFile(node), node.end - 1, ";".length, ts.Diagnostics._0_expected, "{"); - } - } - if (ts.isClassLike(node.parent)) { - if (checkGrammarForInvalidQuestionMark(node, node.questionToken, ts.Diagnostics.A_class_member_cannot_be_declared_optional)) { - return true; - } - if (ts.isInAmbientContext(node)) { - return checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_an_ambient_context_must_directly_refer_to_a_built_in_symbol); - } - else if (!node.body) { - 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 === 215) { - return checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_an_interface_must_directly_refer_to_a_built_in_symbol); - } - else if (node.parent.kind === 155) { - return checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_type_literal_must_directly_refer_to_a_built_in_symbol); - } - } - function isIterationStatement(node, lookInLabeledStatements) { - switch (node.kind) { - case 199: - case 200: - case 201: - case 197: - case 198: - return true; - case 207: - return lookInLabeledStatements && isIterationStatement(node.statement, lookInLabeledStatements); - } - return false; - } - function checkGrammarBreakOrContinueStatement(node) { - var current = node; - while (current) { - if (ts.isFunctionLike(current)) { - return grammarErrorOnNode(node, ts.Diagnostics.Jump_target_cannot_cross_function_boundary); - } - switch (current.kind) { - case 207: - if (node.label && current.label.text === node.label.text) { - var isMisplacedContinueLabel = node.kind === 202 - && !isIterationStatement(current.statement, true); - if (isMisplacedContinueLabel) { - return grammarErrorOnNode(node, ts.Diagnostics.A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement); - } - return false; - } - break; - case 206: - if (node.kind === 203 && !node.label) { - return false; - } - break; - default: - if (isIterationStatement(current, false) && !node.label) { - return false; - } - break; - } - current = current.parent; - } - if (node.label) { - var message = node.kind === 203 - ? ts.Diagnostics.A_break_statement_can_only_jump_to_a_label_of_an_enclosing_statement - : ts.Diagnostics.A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement; - return grammarErrorOnNode(node, message); - } - else { - var message = node.kind === 203 - ? ts.Diagnostics.A_break_statement_can_only_be_used_within_an_enclosing_iteration_or_switch_statement - : ts.Diagnostics.A_continue_statement_can_only_be_used_within_an_enclosing_iteration_statement; - return grammarErrorOnNode(node, message); - } - } - function checkGrammarBindingElement(node) { - if (node.dotDotDotToken) { - var elements = node.parent.elements; - 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 === 162 || node.name.kind === 161) { - return grammarErrorOnNode(node.name, ts.Diagnostics.A_rest_element_cannot_contain_a_binding_pattern); - } - if (node.initializer) { - return grammarErrorAtPos(ts.getSourceFileOfNode(node), node.initializer.pos - 1, 1, ts.Diagnostics.A_rest_element_cannot_have_an_initializer); - } - } - } - function checkGrammarVariableDeclaration(node) { - if (node.parent.parent.kind !== 200 && node.parent.parent.kind !== 201) { - if (ts.isInAmbientContext(node)) { - if (node.initializer) { - var equalsTokenLength = "=".length; - return grammarErrorAtPos(ts.getSourceFileOfNode(node), node.initializer.pos - equalsTokenLength, equalsTokenLength, ts.Diagnostics.Initializers_are_not_allowed_in_ambient_contexts); - } - } - else if (!node.initializer) { - if (ts.isBindingPattern(node.name) && !ts.isBindingPattern(node.parent)) { - return grammarErrorOnNode(node, ts.Diagnostics.A_destructuring_declaration_must_have_an_initializer); - } - if (ts.isConst(node)) { - return grammarErrorOnNode(node, ts.Diagnostics.const_declarations_must_be_initialized); - } - } - } - var checkLetConstNames = languageVersion >= 2 && (ts.isLet(node) || ts.isConst(node)); - return checkLetConstNames && checkGrammarNameInLetOrConstDeclarations(node.name); - } - function checkGrammarNameInLetOrConstDeclarations(name) { - if (name.kind === 69) { - if (name.text === "let") { - return grammarErrorOnNode(name, ts.Diagnostics.let_is_not_allowed_to_be_used_as_a_name_in_let_or_const_declarations); - } - } - else { - var elements = name.elements; - for (var _i = 0; _i < elements.length; _i++) { - var element = elements[_i]; - if (element.kind !== 187) { - checkGrammarNameInLetOrConstDeclarations(element.name); - } - } - } - } - function checkGrammarVariableDeclarationList(declarationList) { - var declarations = declarationList.declarations; - if (checkGrammarForDisallowedTrailingComma(declarationList.declarations)) { - return true; - } - if (!declarationList.declarations.length) { - return grammarErrorAtPos(ts.getSourceFileOfNode(declarationList), declarations.pos, declarations.end - declarations.pos, ts.Diagnostics.Variable_declaration_list_cannot_be_empty); - } - } - function allowLetAndConstDeclarations(parent) { - switch (parent.kind) { - case 196: - case 197: - case 198: - case 205: - case 199: - case 200: - case 201: - return false; - case 207: - return allowLetAndConstDeclarations(parent.parent); - } - return true; - } - function checkGrammarForDisallowedLetOrConstStatement(node) { - if (!allowLetAndConstDeclarations(node.parent)) { - if (ts.isLet(node.declarationList)) { - return grammarErrorOnNode(node, ts.Diagnostics.let_declarations_can_only_be_declared_inside_a_block); - } - else if (ts.isConst(node.declarationList)) { - return grammarErrorOnNode(node, ts.Diagnostics.const_declarations_can_only_be_declared_inside_a_block); - } - } - } - function isIntegerLiteral(expression) { - if (expression.kind === 179) { - var unaryExpression = expression; - if (unaryExpression.operator === 35 || unaryExpression.operator === 36) { - expression = unaryExpression.operand; - } - } - if (expression.kind === 8) { - return /^[0-9]+([eE]\+?[0-9]+)?$/.test(expression.text); - } - return false; - } - function hasParseDiagnostics(sourceFile) { - return sourceFile.parseDiagnostics.length > 0; - } - function grammarErrorOnFirstToken(node, message, arg0, arg1, arg2) { - var sourceFile = ts.getSourceFileOfNode(node); - if (!hasParseDiagnostics(sourceFile)) { - var span = ts.getSpanOfTokenAtPosition(sourceFile, node.pos); - diagnostics.add(ts.createFileDiagnostic(sourceFile, span.start, span.length, message, arg0, arg1, arg2)); - return true; - } - } - function grammarErrorAtPos(sourceFile, start, length, message, arg0, arg1, arg2) { - if (!hasParseDiagnostics(sourceFile)) { - diagnostics.add(ts.createFileDiagnostic(sourceFile, start, length, message, arg0, arg1, arg2)); - return true; - } - } - function grammarErrorOnNode(node, message, arg0, arg1, arg2) { - var sourceFile = ts.getSourceFileOfNode(node); - if (!hasParseDiagnostics(sourceFile)) { - diagnostics.add(ts.createDiagnosticForNode(node, message, arg0, arg1, arg2)); - return true; - } - } - function isEvalOrArgumentsIdentifier(node) { - return node.kind === 69 && - (node.text === "eval" || node.text === "arguments"); - } - function checkGrammarConstructorTypeParameters(node) { - if (node.typeParameters) { - return grammarErrorAtPos(ts.getSourceFileOfNode(node), node.typeParameters.pos, node.typeParameters.end - node.typeParameters.pos, ts.Diagnostics.Type_parameters_cannot_appear_on_a_constructor_declaration); - } - } - function checkGrammarConstructorTypeAnnotation(node) { - if (node.type) { - return grammarErrorOnNode(node.type, ts.Diagnostics.Type_annotation_cannot_appear_on_a_constructor_declaration); - } - } - function checkGrammarProperty(node) { - if (ts.isClassLike(node.parent)) { - if (checkGrammarForInvalidQuestionMark(node, node.questionToken, ts.Diagnostics.A_class_member_cannot_be_declared_optional) || - checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_class_property_declaration_must_directly_refer_to_a_built_in_symbol)) { - return true; - } - } - else if (node.parent.kind === 215) { - if (checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_an_interface_must_directly_refer_to_a_built_in_symbol)) { - return true; - } - } - else if (node.parent.kind === 155) { - if (checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_type_literal_must_directly_refer_to_a_built_in_symbol)) { - return true; - } - } - if (ts.isInAmbientContext(node) && node.initializer) { - return grammarErrorOnFirstToken(node.initializer, ts.Diagnostics.Initializers_are_not_allowed_in_ambient_contexts); - } - } - function checkGrammarTopLevelElementForRequiredDeclareModifier(node) { - if (node.kind === 215 || - node.kind === 222 || - node.kind === 221 || - node.kind === 228 || - node.kind === 227 || - (node.flags & 2) || - (node.flags & (1 | 1024))) { - return false; - } - return grammarErrorOnFirstToken(node, ts.Diagnostics.A_declare_modifier_is_required_for_a_top_level_declaration_in_a_d_ts_file); - } - function checkGrammarTopLevelElementsForRequiredDeclareModifier(file) { - for (var _i = 0, _a = file.statements; _i < _a.length; _i++) { - var decl = _a[_i]; - if (ts.isDeclaration(decl) || decl.kind === 193) { - if (checkGrammarTopLevelElementForRequiredDeclareModifier(decl)) { - return true; - } - } - } - } - function checkGrammarSourceFile(node) { - return ts.isInAmbientContext(node) && checkGrammarTopLevelElementsForRequiredDeclareModifier(node); - } - function checkGrammarStatementInAmbientContext(node) { - if (ts.isInAmbientContext(node)) { - if (isAccessor(node.parent.kind)) { - return getNodeLinks(node).hasReportedStatementInAmbientContext = true; - } - var links = getNodeLinks(node); - 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 === 192 || node.parent.kind === 219 || node.parent.kind === 248) { - var links_1 = getNodeLinks(node.parent); - if (!links_1.hasReportedStatementInAmbientContext) { - return links_1.hasReportedStatementInAmbientContext = grammarErrorOnFirstToken(node, ts.Diagnostics.Statements_are_not_allowed_in_ambient_contexts); - } - } - else { - } - } - } - function checkGrammarNumericLiteral(node) { - if (node.flags & 65536 && languageVersion >= 1) { - return grammarErrorOnNode(node, ts.Diagnostics.Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher); - } - } - function grammarErrorAfterFirstToken(node, message, arg0, arg1, arg2) { - var sourceFile = ts.getSourceFileOfNode(node); - if (!hasParseDiagnostics(sourceFile)) { - var span = ts.getSpanOfTokenAtPosition(sourceFile, node.pos); - diagnostics.add(ts.createFileDiagnostic(sourceFile, ts.textSpanEnd(span), 0, message, arg0, arg1, arg2)); - return true; - } - } - } - ts.createTypeChecker = createTypeChecker; -})(ts || (ts = {})); -var ts; -(function (ts) { - function getDeclarationDiagnostics(host, resolver, targetSourceFile) { - var diagnostics = []; - var jsFilePath = ts.getOwnEmitOutputFilePath(targetSourceFile, host, ".js"); - emitDeclarations(host, resolver, diagnostics, jsFilePath, targetSourceFile); - return diagnostics; - } - ts.getDeclarationDiagnostics = getDeclarationDiagnostics; - function emitDeclarations(host, resolver, diagnostics, jsFilePath, root) { - var newLine = host.getNewLine(); - var compilerOptions = host.getCompilerOptions(); - var write; - var writeLine; - var increaseIndent; - var decreaseIndent; - var writeTextOfNode; - var writer = createAndSetNewTextWriterWithSymbolWriter(); - var enclosingDeclaration; - var currentSourceFile; - var reportedDeclarationError = false; - var errorNameNode; - var emitJsDocComments = compilerOptions.removeComments ? function (declaration) { } : writeJsDocComments; - var emit = compilerOptions.stripInternal ? stripInternal : emitNode; - var moduleElementDeclarationEmitInfo = []; - var asynchronousSubModuleDeclarationEmitInfo; - var referencePathsOutput = ""; - if (root) { - if (!compilerOptions.noResolve) { - var addedGlobalFileReference = false; - ts.forEach(root.referencedFiles, function (fileReference) { - var referencedFile = ts.tryResolveScriptReference(host, root, fileReference); - if (referencedFile && ((referencedFile.flags & 8192) || - ts.shouldEmitToOwnFile(referencedFile, compilerOptions) || - !addedGlobalFileReference)) { - writeReferencePath(referencedFile); - if (!ts.isExternalModuleOrDeclarationFile(referencedFile)) { - addedGlobalFileReference = true; - } - } - }); - } - emitSourceFile(root); - if (moduleElementDeclarationEmitInfo.length) { - var oldWriter = writer; - ts.forEach(moduleElementDeclarationEmitInfo, function (aliasEmitInfo) { - if (aliasEmitInfo.isVisible) { - ts.Debug.assert(aliasEmitInfo.node.kind === 222); - createAndSetNewTextWriterWithSymbolWriter(); - ts.Debug.assert(aliasEmitInfo.indent === 0); - writeImportDeclaration(aliasEmitInfo.node); - aliasEmitInfo.asynchronousOutput = writer.getText(); - } - }); - setWriter(oldWriter); - } - } - else { - var emittedReferencedFiles = []; - ts.forEach(host.getSourceFiles(), function (sourceFile) { - if (!ts.isExternalModuleOrDeclarationFile(sourceFile)) { - if (!compilerOptions.noResolve) { - ts.forEach(sourceFile.referencedFiles, function (fileReference) { - var referencedFile = ts.tryResolveScriptReference(host, sourceFile, fileReference); - if (referencedFile && (ts.isExternalModuleOrDeclarationFile(referencedFile) && - !ts.contains(emittedReferencedFiles, referencedFile))) { - writeReferencePath(referencedFile); - emittedReferencedFiles.push(referencedFile); - } - }); - } - emitSourceFile(sourceFile); - } - }); - } - return { - reportedDeclarationError: reportedDeclarationError, - moduleElementDeclarationEmitInfo: moduleElementDeclarationEmitInfo, - synchronousDeclarationOutput: writer.getText(), - referencePathsOutput: referencePathsOutput - }; - function hasInternalAnnotation(range) { - var text = currentSourceFile.text; - var comment = text.substring(range.pos, range.end); - return comment.indexOf("@internal") >= 0; - } - function stripInternal(node) { - if (node) { - var leadingCommentRanges = ts.getLeadingCommentRanges(currentSourceFile.text, node.pos); - if (ts.forEach(leadingCommentRanges, hasInternalAnnotation)) { - return; - } - emitNode(node); - } - } - function createAndSetNewTextWriterWithSymbolWriter() { - var writer = ts.createTextWriter(newLine); - writer.trackSymbol = trackSymbol; - writer.reportInaccessibleThisError = reportInaccessibleThisError; - writer.writeKeyword = writer.write; - writer.writeOperator = writer.write; - writer.writePunctuation = writer.write; - writer.writeSpace = writer.write; - writer.writeStringLiteral = writer.writeLiteral; - writer.writeParameter = writer.write; - writer.writeSymbol = writer.write; - setWriter(writer); - return writer; - } - function setWriter(newWriter) { - writer = newWriter; - write = newWriter.write; - writeTextOfNode = newWriter.writeTextOfNode; - writeLine = newWriter.writeLine; - increaseIndent = newWriter.increaseIndent; - decreaseIndent = newWriter.decreaseIndent; - } - function writeAsynchronousModuleElements(nodes) { - var oldWriter = writer; - ts.forEach(nodes, function (declaration) { - var nodeToCheck; - if (declaration.kind === 211) { - nodeToCheck = declaration.parent.parent; - } - else if (declaration.kind === 225 || declaration.kind === 226 || declaration.kind === 223) { - ts.Debug.fail("We should be getting ImportDeclaration instead to write"); - } - else { - nodeToCheck = declaration; - } - var moduleElementEmitInfo = ts.forEach(moduleElementDeclarationEmitInfo, function (declEmitInfo) { return declEmitInfo.node === nodeToCheck ? declEmitInfo : undefined; }); - if (!moduleElementEmitInfo && asynchronousSubModuleDeclarationEmitInfo) { - moduleElementEmitInfo = ts.forEach(asynchronousSubModuleDeclarationEmitInfo, function (declEmitInfo) { return declEmitInfo.node === nodeToCheck ? declEmitInfo : undefined; }); - } - if (moduleElementEmitInfo) { - if (moduleElementEmitInfo.node.kind === 222) { - moduleElementEmitInfo.isVisible = true; - } - else { - createAndSetNewTextWriterWithSymbolWriter(); - for (var declarationIndent = moduleElementEmitInfo.indent; declarationIndent; declarationIndent--) { - increaseIndent(); - } - if (nodeToCheck.kind === 218) { - ts.Debug.assert(asynchronousSubModuleDeclarationEmitInfo === undefined); - asynchronousSubModuleDeclarationEmitInfo = []; - } - writeModuleElement(nodeToCheck); - if (nodeToCheck.kind === 218) { - moduleElementEmitInfo.subModuleElementDeclarationEmitInfo = asynchronousSubModuleDeclarationEmitInfo; - asynchronousSubModuleDeclarationEmitInfo = undefined; - } - moduleElementEmitInfo.asynchronousOutput = writer.getText(); - } - } - }); - setWriter(oldWriter); - } - function handleSymbolAccessibilityError(symbolAccesibilityResult) { - if (symbolAccesibilityResult.accessibility === 0) { - if (symbolAccesibilityResult && symbolAccesibilityResult.aliasesToMakeVisible) { - writeAsynchronousModuleElements(symbolAccesibilityResult.aliasesToMakeVisible); - } - } - else { - reportedDeclarationError = true; - var errorInfo = writer.getSymbolAccessibilityDiagnostic(symbolAccesibilityResult); - if (errorInfo) { - if (errorInfo.typeName) { - diagnostics.push(ts.createDiagnosticForNode(symbolAccesibilityResult.errorNode || errorInfo.errorNode, errorInfo.diagnosticMessage, ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, errorInfo.typeName), symbolAccesibilityResult.errorSymbolName, symbolAccesibilityResult.errorModuleName)); - } - else { - diagnostics.push(ts.createDiagnosticForNode(symbolAccesibilityResult.errorNode || errorInfo.errorNode, errorInfo.diagnosticMessage, symbolAccesibilityResult.errorSymbolName, symbolAccesibilityResult.errorModuleName)); - } - } - } - } - function trackSymbol(symbol, enclosingDeclaration, meaning) { - handleSymbolAccessibilityError(resolver.isSymbolAccessible(symbol, enclosingDeclaration, meaning)); - } - function reportInaccessibleThisError() { - if (errorNameNode) { - diagnostics.push(ts.createDiagnosticForNode(errorNameNode, ts.Diagnostics.The_inferred_type_of_0_references_an_inaccessible_this_type_A_type_annotation_is_necessary, ts.declarationNameToString(errorNameNode))); - } - } - function writeTypeOfDeclaration(declaration, type, getSymbolAccessibilityDiagnostic) { - writer.getSymbolAccessibilityDiagnostic = getSymbolAccessibilityDiagnostic; - write(": "); - if (type) { - emitType(type); - } - else { - errorNameNode = declaration.name; - resolver.writeTypeOfDeclaration(declaration, enclosingDeclaration, 2, writer); - errorNameNode = undefined; - } - } - function writeReturnTypeAtSignature(signature, getSymbolAccessibilityDiagnostic) { - writer.getSymbolAccessibilityDiagnostic = getSymbolAccessibilityDiagnostic; - write(": "); - if (signature.type) { - emitType(signature.type); - } - else { - errorNameNode = signature.name; - resolver.writeReturnTypeOfSignatureDeclaration(signature, enclosingDeclaration, 2, writer); - errorNameNode = undefined; - } - } - function emitLines(nodes) { - for (var _i = 0; _i < nodes.length; _i++) { - var node = nodes[_i]; - emit(node); - } - } - function emitSeparatedList(nodes, separator, eachNodeEmitFn, canEmitFn) { - var currentWriterPos = writer.getTextPos(); - for (var _i = 0; _i < nodes.length; _i++) { - var node = nodes[_i]; - if (!canEmitFn || canEmitFn(node)) { - if (currentWriterPos !== writer.getTextPos()) { - write(separator); - } - currentWriterPos = writer.getTextPos(); - eachNodeEmitFn(node); - } - } - } - function emitCommaList(nodes, eachNodeEmitFn, canEmitFn) { - emitSeparatedList(nodes, ", ", eachNodeEmitFn, canEmitFn); - } - function writeJsDocComments(declaration) { - if (declaration) { - var jsDocComments = ts.getJsDocComments(declaration, currentSourceFile); - ts.emitNewLineBeforeLeadingComments(currentSourceFile, writer, declaration, jsDocComments); - ts.emitComments(currentSourceFile, writer, jsDocComments, true, newLine, ts.writeCommentRange); - } - } - function emitTypeWithNewGetSymbolAccessibilityDiagnostic(type, getSymbolAccessibilityDiagnostic) { - writer.getSymbolAccessibilityDiagnostic = getSymbolAccessibilityDiagnostic; - emitType(type); - } - function emitType(type) { - switch (type.kind) { - case 117: - case 130: - case 128: - case 120: - case 131: - case 103: - case 97: - case 9: - return writeTextOfNode(currentSourceFile, type); - case 188: - return emitExpressionWithTypeArguments(type); - case 151: - return emitTypeReference(type); - case 154: - return emitTypeQuery(type); - case 156: - return emitArrayType(type); - case 157: - return emitTupleType(type); - case 158: - return emitUnionType(type); - case 159: - return emitIntersectionType(type); - case 160: - return emitParenType(type); - case 152: - case 153: - return emitSignatureDeclarationWithJsDocComments(type); - case 155: - return emitTypeLiteral(type); - case 69: - return emitEntityName(type); - case 135: - return emitEntityName(type); - case 150: - return emitTypePredicate(type); - } - function writeEntityName(entityName) { - if (entityName.kind === 69) { - writeTextOfNode(currentSourceFile, entityName); - } - else { - var left = entityName.kind === 135 ? entityName.left : entityName.expression; - var right = entityName.kind === 135 ? entityName.right : entityName.name; - writeEntityName(left); - write("."); - writeTextOfNode(currentSourceFile, right); - } - } - function emitEntityName(entityName) { - var visibilityResult = resolver.isEntityNameVisible(entityName, entityName.parent.kind === 221 ? entityName.parent : enclosingDeclaration); - handleSymbolAccessibilityError(visibilityResult); - writeEntityName(entityName); - } - function emitExpressionWithTypeArguments(node) { - if (ts.isSupportedExpressionWithTypeArguments(node)) { - ts.Debug.assert(node.expression.kind === 69 || node.expression.kind === 166); - emitEntityName(node.expression); - if (node.typeArguments) { - write("<"); - emitCommaList(node.typeArguments, emitType); - write(">"); - } - } - } - function emitTypeReference(type) { - emitEntityName(type.typeName); - if (type.typeArguments) { - write("<"); - emitCommaList(type.typeArguments, emitType); - write(">"); - } - } - function emitTypePredicate(type) { - writeTextOfNode(currentSourceFile, type.parameterName); - write(" is "); - emitType(type.type); - } - function emitTypeQuery(type) { - write("typeof "); - emitEntityName(type.exprName); - } - function emitArrayType(type) { - emitType(type.elementType); - write("[]"); - } - function emitTupleType(type) { - write("["); - emitCommaList(type.elementTypes, emitType); - write("]"); - } - function emitUnionType(type) { - emitSeparatedList(type.types, " | ", emitType); - } - function emitIntersectionType(type) { - emitSeparatedList(type.types, " & ", emitType); - } - function emitParenType(type) { - write("("); - emitType(type.type); - write(")"); - } - function emitTypeLiteral(type) { - write("{"); - if (type.members.length) { - writeLine(); - increaseIndent(); - emitLines(type.members); - decreaseIndent(); - } - write("}"); - } - } - function emitSourceFile(node) { - currentSourceFile = node; - enclosingDeclaration = node; - emitLines(node.statements); - } - function getExportDefaultTempVariableName() { - var baseName = "_default"; - if (!ts.hasProperty(currentSourceFile.identifiers, baseName)) { - return baseName; - } - var count = 0; - while (true) { - var name_18 = baseName + "_" + (++count); - if (!ts.hasProperty(currentSourceFile.identifiers, name_18)) { - return name_18; - } - } - } - function emitExportAssignment(node) { - if (node.expression.kind === 69) { - write(node.isExportEquals ? "export = " : "export default "); - writeTextOfNode(currentSourceFile, node.expression); - } - else { - var tempVarName = getExportDefaultTempVariableName(); - write("declare var "); - write(tempVarName); - write(": "); - writer.getSymbolAccessibilityDiagnostic = getDefaultExportAccessibilityDiagnostic; - resolver.writeTypeOfExpression(node.expression, enclosingDeclaration, 2, writer); - write(";"); - writeLine(); - write(node.isExportEquals ? "export = " : "export default "); - write(tempVarName); - } - write(";"); - writeLine(); - if (node.expression.kind === 69) { - var nodes = resolver.collectLinkedAliases(node.expression); - writeAsynchronousModuleElements(nodes); - } - function getDefaultExportAccessibilityDiagnostic(diagnostic) { - return { - diagnosticMessage: ts.Diagnostics.Default_export_of_the_module_has_or_is_using_private_name_0, - errorNode: node - }; - } - } - function isModuleElementVisible(node) { - return resolver.isDeclarationVisible(node); - } - function emitModuleElement(node, isModuleElementVisible) { - if (isModuleElementVisible) { - writeModuleElement(node); - } - else if (node.kind === 221 || - (node.parent.kind === 248 && ts.isExternalModule(currentSourceFile))) { - var isVisible; - if (asynchronousSubModuleDeclarationEmitInfo && node.parent.kind !== 248) { - asynchronousSubModuleDeclarationEmitInfo.push({ - node: node, - outputPos: writer.getTextPos(), - indent: writer.getIndent(), - isVisible: isVisible - }); - } - else { - if (node.kind === 222) { - var importDeclaration = node; - if (importDeclaration.importClause) { - isVisible = (importDeclaration.importClause.name && resolver.isDeclarationVisible(importDeclaration.importClause)) || - isVisibleNamedBinding(importDeclaration.importClause.namedBindings); - } - } - moduleElementDeclarationEmitInfo.push({ - node: node, - outputPos: writer.getTextPos(), - indent: writer.getIndent(), - isVisible: isVisible - }); - } - } - } - function writeModuleElement(node) { - switch (node.kind) { - case 213: - return writeFunctionDeclaration(node); - case 193: - return writeVariableStatement(node); - case 215: - return writeInterfaceDeclaration(node); - case 214: - return writeClassDeclaration(node); - case 216: - return writeTypeAliasDeclaration(node); - case 217: - return writeEnumDeclaration(node); - case 218: - return writeModuleDeclaration(node); - case 221: - return writeImportEqualsDeclaration(node); - case 222: - return writeImportDeclaration(node); - default: - ts.Debug.fail("Unknown symbol kind"); - } - } - function emitModuleElementDeclarationFlags(node) { - if (node.parent === currentSourceFile) { - if (node.flags & 1) { - write("export "); - } - if (node.flags & 1024) { - write("default "); - } - else if (node.kind !== 215) { - write("declare "); - } - } - } - function emitClassMemberDeclarationFlags(node) { - if (node.flags & 32) { - write("private "); - } - else if (node.flags & 64) { - write("protected "); - } - if (node.flags & 128) { - write("static "); - } - if (node.flags & 256) { - write("abstract "); - } - } - function writeImportEqualsDeclaration(node) { - emitJsDocComments(node); - if (node.flags & 1) { - write("export "); - } - write("import "); - writeTextOfNode(currentSourceFile, node.name); - write(" = "); - if (ts.isInternalModuleImportEqualsDeclaration(node)) { - emitTypeWithNewGetSymbolAccessibilityDiagnostic(node.moduleReference, getImportEntityNameVisibilityError); - write(";"); - } - else { - write("require("); - writeTextOfNode(currentSourceFile, ts.getExternalModuleImportEqualsDeclarationExpression(node)); - write(");"); - } - writer.writeLine(); - function getImportEntityNameVisibilityError(symbolAccesibilityResult) { - return { - diagnosticMessage: ts.Diagnostics.Import_declaration_0_is_using_private_name_1, - errorNode: node, - typeName: node.name - }; - } - } - function isVisibleNamedBinding(namedBindings) { - if (namedBindings) { - if (namedBindings.kind === 224) { - return resolver.isDeclarationVisible(namedBindings); - } - else { - return ts.forEach(namedBindings.elements, function (namedImport) { return resolver.isDeclarationVisible(namedImport); }); - } - } - } - function writeImportDeclaration(node) { - if (!node.importClause && !(node.flags & 1)) { - return; - } - emitJsDocComments(node); - if (node.flags & 1) { - write("export "); - } - write("import "); - if (node.importClause) { - var currentWriterPos = writer.getTextPos(); - if (node.importClause.name && resolver.isDeclarationVisible(node.importClause)) { - writeTextOfNode(currentSourceFile, node.importClause.name); - } - if (node.importClause.namedBindings && isVisibleNamedBinding(node.importClause.namedBindings)) { - if (currentWriterPos !== writer.getTextPos()) { - write(", "); - } - if (node.importClause.namedBindings.kind === 224) { - write("* as "); - writeTextOfNode(currentSourceFile, node.importClause.namedBindings.name); - } - else { - write("{ "); - emitCommaList(node.importClause.namedBindings.elements, emitImportOrExportSpecifier, resolver.isDeclarationVisible); - write(" }"); - } - } - write(" from "); - } - writeTextOfNode(currentSourceFile, node.moduleSpecifier); - write(";"); - writer.writeLine(); - } - function emitImportOrExportSpecifier(node) { - if (node.propertyName) { - writeTextOfNode(currentSourceFile, node.propertyName); - write(" as "); - } - writeTextOfNode(currentSourceFile, node.name); - } - function emitExportSpecifier(node) { - emitImportOrExportSpecifier(node); - var nodes = resolver.collectLinkedAliases(node.propertyName || node.name); - writeAsynchronousModuleElements(nodes); - } - function emitExportDeclaration(node) { - emitJsDocComments(node); - write("export "); - if (node.exportClause) { - write("{ "); - emitCommaList(node.exportClause.elements, emitExportSpecifier); - write(" }"); - } - else { - write("*"); - } - if (node.moduleSpecifier) { - write(" from "); - writeTextOfNode(currentSourceFile, node.moduleSpecifier); - } - write(";"); - writer.writeLine(); - } - function writeModuleDeclaration(node) { - emitJsDocComments(node); - emitModuleElementDeclarationFlags(node); - if (node.flags & 131072) { - write("namespace "); - } - else { - write("module "); - } - writeTextOfNode(currentSourceFile, node.name); - while (node.body.kind !== 219) { - node = node.body; - write("."); - writeTextOfNode(currentSourceFile, node.name); - } - var prevEnclosingDeclaration = enclosingDeclaration; - enclosingDeclaration = node; - write(" {"); - writeLine(); - increaseIndent(); - emitLines(node.body.statements); - decreaseIndent(); - write("}"); - writeLine(); - enclosingDeclaration = prevEnclosingDeclaration; - } - function writeTypeAliasDeclaration(node) { - var prevEnclosingDeclaration = enclosingDeclaration; - enclosingDeclaration = node; - emitJsDocComments(node); - emitModuleElementDeclarationFlags(node); - write("type "); - writeTextOfNode(currentSourceFile, node.name); - emitTypeParameters(node.typeParameters); - write(" = "); - emitTypeWithNewGetSymbolAccessibilityDiagnostic(node.type, getTypeAliasDeclarationVisibilityError); - write(";"); - writeLine(); - enclosingDeclaration = prevEnclosingDeclaration; - function getTypeAliasDeclarationVisibilityError(symbolAccesibilityResult) { - return { - diagnosticMessage: ts.Diagnostics.Exported_type_alias_0_has_or_is_using_private_name_1, - errorNode: node.type, - typeName: node.name - }; - } - } - function writeEnumDeclaration(node) { - emitJsDocComments(node); - emitModuleElementDeclarationFlags(node); - if (ts.isConst(node)) { - write("const "); - } - write("enum "); - writeTextOfNode(currentSourceFile, node.name); - write(" {"); - writeLine(); - increaseIndent(); - emitLines(node.members); - decreaseIndent(); - write("}"); - writeLine(); - } - function emitEnumMemberDeclaration(node) { - emitJsDocComments(node); - writeTextOfNode(currentSourceFile, node.name); - var enumMemberValue = resolver.getConstantValue(node); - if (enumMemberValue !== undefined) { - write(" = "); - write(enumMemberValue.toString()); - } - write(","); - writeLine(); - } - function isPrivateMethodTypeParameter(node) { - return node.parent.kind === 143 && (node.parent.flags & 32); - } - function emitTypeParameters(typeParameters) { - function emitTypeParameter(node) { - increaseIndent(); - emitJsDocComments(node); - decreaseIndent(); - writeTextOfNode(currentSourceFile, node.name); - if (node.constraint && !isPrivateMethodTypeParameter(node)) { - write(" extends "); - if (node.parent.kind === 152 || - node.parent.kind === 153 || - (node.parent.parent && node.parent.parent.kind === 155)) { - ts.Debug.assert(node.parent.kind === 143 || - node.parent.kind === 142 || - node.parent.kind === 152 || - node.parent.kind === 153 || - node.parent.kind === 147 || - node.parent.kind === 148); - emitType(node.constraint); - } - else { - emitTypeWithNewGetSymbolAccessibilityDiagnostic(node.constraint, getTypeParameterConstraintVisibilityError); - } - } - function getTypeParameterConstraintVisibilityError(symbolAccesibilityResult) { - var diagnosticMessage; - switch (node.parent.kind) { - case 214: - diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_class_has_or_is_using_private_name_1; - break; - case 215: - diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1; - break; - case 148: - diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; - break; - case 147: - diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; - break; - case 143: - case 142: - if (node.parent.flags & 128) { - diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1; - } - else if (node.parent.parent.kind === 214) { - diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_public_method_from_exported_class_has_or_is_using_private_name_1; - } - else { - diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1; - } - break; - case 213: - diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_function_has_or_is_using_private_name_1; - break; - default: - ts.Debug.fail("This is unknown parent for type parameter: " + node.parent.kind); - } - return { - diagnosticMessage: diagnosticMessage, - errorNode: node, - typeName: node.name - }; - } - } - if (typeParameters) { - write("<"); - emitCommaList(typeParameters, emitTypeParameter); - write(">"); - } - } - function emitHeritageClause(typeReferences, isImplementsList) { - if (typeReferences) { - write(isImplementsList ? " implements " : " extends "); - emitCommaList(typeReferences, emitTypeOfTypeReference); - } - function emitTypeOfTypeReference(node) { - if (ts.isSupportedExpressionWithTypeArguments(node)) { - emitTypeWithNewGetSymbolAccessibilityDiagnostic(node, getHeritageClauseVisibilityError); - } - else if (!isImplementsList && node.expression.kind === 93) { - write("null"); - } - function getHeritageClauseVisibilityError(symbolAccesibilityResult) { - var diagnosticMessage; - if (node.parent.parent.kind === 214) { - diagnosticMessage = isImplementsList ? - ts.Diagnostics.Implements_clause_of_exported_class_0_has_or_is_using_private_name_1 : - ts.Diagnostics.Extends_clause_of_exported_class_0_has_or_is_using_private_name_1; - } - else { - diagnosticMessage = ts.Diagnostics.Extends_clause_of_exported_interface_0_has_or_is_using_private_name_1; - } - return { - diagnosticMessage: diagnosticMessage, - errorNode: node, - typeName: node.parent.parent.name - }; - } - } - } - function writeClassDeclaration(node) { - function emitParameterProperties(constructorDeclaration) { - if (constructorDeclaration) { - ts.forEach(constructorDeclaration.parameters, function (param) { - if (param.flags & 112) { - emitPropertyDeclaration(param); - } - }); - } - } - emitJsDocComments(node); - emitModuleElementDeclarationFlags(node); - if (node.flags & 256) { - write("abstract "); - } - write("class "); - writeTextOfNode(currentSourceFile, node.name); - var prevEnclosingDeclaration = enclosingDeclaration; - enclosingDeclaration = node; - emitTypeParameters(node.typeParameters); - var baseTypeNode = ts.getClassExtendsHeritageClauseElement(node); - if (baseTypeNode) { - emitHeritageClause([baseTypeNode], false); - } - emitHeritageClause(ts.getClassImplementsHeritageClauseElements(node), true); - write(" {"); - writeLine(); - increaseIndent(); - emitParameterProperties(ts.getFirstConstructorWithBody(node)); - emitLines(node.members); - decreaseIndent(); - write("}"); - writeLine(); - enclosingDeclaration = prevEnclosingDeclaration; - } - function writeInterfaceDeclaration(node) { - emitJsDocComments(node); - emitModuleElementDeclarationFlags(node); - write("interface "); - writeTextOfNode(currentSourceFile, node.name); - var prevEnclosingDeclaration = enclosingDeclaration; - enclosingDeclaration = node; - emitTypeParameters(node.typeParameters); - emitHeritageClause(ts.getInterfaceBaseTypeNodes(node), false); - write(" {"); - writeLine(); - increaseIndent(); - emitLines(node.members); - decreaseIndent(); - write("}"); - writeLine(); - enclosingDeclaration = prevEnclosingDeclaration; - } - function emitPropertyDeclaration(node) { - if (ts.hasDynamicName(node)) { - return; - } - emitJsDocComments(node); - emitClassMemberDeclarationFlags(node); - emitVariableDeclaration(node); - write(";"); - writeLine(); - } - function emitVariableDeclaration(node) { - if (node.kind !== 211 || resolver.isDeclarationVisible(node)) { - if (ts.isBindingPattern(node.name)) { - emitBindingPattern(node.name); - } - else { - writeTextOfNode(currentSourceFile, node.name); - if ((node.kind === 141 || node.kind === 140) && ts.hasQuestionToken(node)) { - write("?"); - } - if ((node.kind === 141 || node.kind === 140) && node.parent.kind === 155) { - emitTypeOfVariableDeclarationFromTypeLiteral(node); - } - else if (!(node.flags & 32)) { - writeTypeOfDeclaration(node, node.type, getVariableDeclarationTypeVisibilityError); - } - } - } - function getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccesibilityResult) { - if (node.kind === 211) { - return symbolAccesibilityResult.errorModuleName ? - symbolAccesibilityResult.accessibility === 2 ? - ts.Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : - ts.Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_private_module_2 : - ts.Diagnostics.Exported_variable_0_has_or_is_using_private_name_1; - } - else if (node.kind === 141 || node.kind === 140) { - if (node.flags & 128) { - return symbolAccesibilityResult.errorModuleName ? - symbolAccesibilityResult.accessibility === 2 ? - ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : - ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : - ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_private_name_1; - } - else if (node.parent.kind === 214) { - return symbolAccesibilityResult.errorModuleName ? - symbolAccesibilityResult.accessibility === 2 ? - ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : - ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : - ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_private_name_1; - } - else { - return symbolAccesibilityResult.errorModuleName ? - ts.Diagnostics.Property_0_of_exported_interface_has_or_is_using_name_1_from_private_module_2 : - ts.Diagnostics.Property_0_of_exported_interface_has_or_is_using_private_name_1; - } - } - } - function getVariableDeclarationTypeVisibilityError(symbolAccesibilityResult) { - var diagnosticMessage = getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccesibilityResult); - return diagnosticMessage !== undefined ? { - diagnosticMessage: diagnosticMessage, - errorNode: node, - typeName: node.name - } : undefined; - } - function emitBindingPattern(bindingPattern) { - var elements = []; - for (var _i = 0, _a = bindingPattern.elements; _i < _a.length; _i++) { - var element = _a[_i]; - if (element.kind !== 187) { - elements.push(element); - } - } - emitCommaList(elements, emitBindingElement); - } - function emitBindingElement(bindingElement) { - function getBindingElementTypeVisibilityError(symbolAccesibilityResult) { - var diagnosticMessage = getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccesibilityResult); - return diagnosticMessage !== undefined ? { - diagnosticMessage: diagnosticMessage, - errorNode: bindingElement, - typeName: bindingElement.name - } : undefined; - } - if (bindingElement.name) { - if (ts.isBindingPattern(bindingElement.name)) { - emitBindingPattern(bindingElement.name); - } - else { - writeTextOfNode(currentSourceFile, bindingElement.name); - writeTypeOfDeclaration(bindingElement, undefined, getBindingElementTypeVisibilityError); - } - } - } - } - function emitTypeOfVariableDeclarationFromTypeLiteral(node) { - if (node.type) { - write(": "); - emitType(node.type); - } - } - function isVariableStatementVisible(node) { - return ts.forEach(node.declarationList.declarations, function (varDeclaration) { return resolver.isDeclarationVisible(varDeclaration); }); - } - function writeVariableStatement(node) { - emitJsDocComments(node); - emitModuleElementDeclarationFlags(node); - if (ts.isLet(node.declarationList)) { - write("let "); - } - else if (ts.isConst(node.declarationList)) { - write("const "); - } - else { - write("var "); - } - emitCommaList(node.declarationList.declarations, emitVariableDeclaration, resolver.isDeclarationVisible); - write(";"); - writeLine(); - } - function emitAccessorDeclaration(node) { - if (ts.hasDynamicName(node)) { - return; - } - var accessors = ts.getAllAccessorDeclarations(node.parent.members, node); - var accessorWithTypeAnnotation; - if (node === accessors.firstAccessor) { - emitJsDocComments(accessors.getAccessor); - emitJsDocComments(accessors.setAccessor); - emitClassMemberDeclarationFlags(node); - writeTextOfNode(currentSourceFile, node.name); - if (!(node.flags & 32)) { - accessorWithTypeAnnotation = node; - var type = getTypeAnnotationFromAccessor(node); - if (!type) { - var anotherAccessor = node.kind === 145 ? accessors.setAccessor : accessors.getAccessor; - type = getTypeAnnotationFromAccessor(anotherAccessor); - if (type) { - accessorWithTypeAnnotation = anotherAccessor; - } - } - writeTypeOfDeclaration(node, type, getAccessorDeclarationTypeVisibilityError); - } - write(";"); - writeLine(); - } - function getTypeAnnotationFromAccessor(accessor) { - if (accessor) { - return accessor.kind === 145 - ? accessor.type - : accessor.parameters.length > 0 - ? accessor.parameters[0].type - : undefined; - } - } - function getAccessorDeclarationTypeVisibilityError(symbolAccesibilityResult) { - var diagnosticMessage; - if (accessorWithTypeAnnotation.kind === 146) { - if (accessorWithTypeAnnotation.parent.flags & 128) { - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? - ts.Diagnostics.Parameter_0_of_public_static_property_setter_from_exported_class_has_or_is_using_name_1_from_private_module_2 : - ts.Diagnostics.Parameter_0_of_public_static_property_setter_from_exported_class_has_or_is_using_private_name_1; - } - else { - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? - ts.Diagnostics.Parameter_0_of_public_property_setter_from_exported_class_has_or_is_using_name_1_from_private_module_2 : - ts.Diagnostics.Parameter_0_of_public_property_setter_from_exported_class_has_or_is_using_private_name_1; - } - return { - diagnosticMessage: diagnosticMessage, - errorNode: accessorWithTypeAnnotation.parameters[0], - typeName: accessorWithTypeAnnotation.name - }; - } - else { - if (accessorWithTypeAnnotation.flags & 128) { - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? - symbolAccesibilityResult.accessibility === 2 ? - ts.Diagnostics.Return_type_of_public_static_property_getter_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : - ts.Diagnostics.Return_type_of_public_static_property_getter_from_exported_class_has_or_is_using_name_0_from_private_module_1 : - ts.Diagnostics.Return_type_of_public_static_property_getter_from_exported_class_has_or_is_using_private_name_0; - } - else { - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? - symbolAccesibilityResult.accessibility === 2 ? - ts.Diagnostics.Return_type_of_public_property_getter_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : - ts.Diagnostics.Return_type_of_public_property_getter_from_exported_class_has_or_is_using_name_0_from_private_module_1 : - ts.Diagnostics.Return_type_of_public_property_getter_from_exported_class_has_or_is_using_private_name_0; - } - return { - diagnosticMessage: diagnosticMessage, - errorNode: accessorWithTypeAnnotation.name, - typeName: undefined - }; - } - } - } - function writeFunctionDeclaration(node) { - if (ts.hasDynamicName(node)) { - return; - } - if (!resolver.isImplementationOfOverload(node)) { - emitJsDocComments(node); - if (node.kind === 213) { - emitModuleElementDeclarationFlags(node); - } - else if (node.kind === 143) { - emitClassMemberDeclarationFlags(node); - } - if (node.kind === 213) { - write("function "); - writeTextOfNode(currentSourceFile, node.name); - } - else if (node.kind === 144) { - write("constructor"); - } - else { - writeTextOfNode(currentSourceFile, node.name); - if (ts.hasQuestionToken(node)) { - write("?"); - } - } - emitSignatureDeclaration(node); - } - } - function emitSignatureDeclarationWithJsDocComments(node) { - emitJsDocComments(node); - emitSignatureDeclaration(node); - } - function emitSignatureDeclaration(node) { - if (node.kind === 148 || node.kind === 153) { - write("new "); - } - emitTypeParameters(node.typeParameters); - if (node.kind === 149) { - write("["); - } - else { - write("("); - } - var prevEnclosingDeclaration = enclosingDeclaration; - enclosingDeclaration = node; - emitCommaList(node.parameters, emitParameterDeclaration); - if (node.kind === 149) { - write("]"); - } - else { - write(")"); - } - var isFunctionTypeOrConstructorType = node.kind === 152 || node.kind === 153; - if (isFunctionTypeOrConstructorType || node.parent.kind === 155) { - if (node.type) { - write(isFunctionTypeOrConstructorType ? " => " : ": "); - emitType(node.type); - } - } - else if (node.kind !== 144 && !(node.flags & 32)) { - writeReturnTypeAtSignature(node, getReturnTypeVisibilityError); - } - enclosingDeclaration = prevEnclosingDeclaration; - if (!isFunctionTypeOrConstructorType) { - write(";"); - writeLine(); - } - function getReturnTypeVisibilityError(symbolAccesibilityResult) { - var diagnosticMessage; - switch (node.kind) { - case 148: - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? - ts.Diagnostics.Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : - ts.Diagnostics.Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_0; - break; - case 147: - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? - ts.Diagnostics.Return_type_of_call_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : - ts.Diagnostics.Return_type_of_call_signature_from_exported_interface_has_or_is_using_private_name_0; - break; - case 149: - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? - ts.Diagnostics.Return_type_of_index_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : - ts.Diagnostics.Return_type_of_index_signature_from_exported_interface_has_or_is_using_private_name_0; - break; - case 143: - case 142: - if (node.flags & 128) { - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? - symbolAccesibilityResult.accessibility === 2 ? - ts.Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : - 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 === 214) { - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? - symbolAccesibilityResult.accessibility === 2 ? - ts.Diagnostics.Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : - ts.Diagnostics.Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_private_module_1 : - ts.Diagnostics.Return_type_of_public_method_from_exported_class_has_or_is_using_private_name_0; - } - else { - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? - ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : - ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0; - } - break; - case 213: - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? - symbolAccesibilityResult.accessibility === 2 ? - ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : - ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_name_0_from_private_module_1 : - ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_private_name_0; - break; - default: - ts.Debug.fail("This is unknown kind for signature: " + node.kind); - } - return { - diagnosticMessage: diagnosticMessage, - errorNode: node.name || node - }; - } - } - function emitParameterDeclaration(node) { - increaseIndent(); - emitJsDocComments(node); - if (node.dotDotDotToken) { - write("..."); - } - if (ts.isBindingPattern(node.name)) { - emitBindingPattern(node.name); - } - else { - writeTextOfNode(currentSourceFile, node.name); - } - if (resolver.isOptionalParameter(node)) { - write("?"); - } - decreaseIndent(); - if (node.parent.kind === 152 || - node.parent.kind === 153 || - node.parent.parent.kind === 155) { - emitTypeOfVariableDeclarationFromTypeLiteral(node); - } - else if (!(node.parent.flags & 32)) { - writeTypeOfDeclaration(node, node.type, getParameterDeclarationTypeVisibilityError); - } - function getParameterDeclarationTypeVisibilityError(symbolAccesibilityResult) { - var diagnosticMessage = getParameterDeclarationTypeVisibilityDiagnosticMessage(symbolAccesibilityResult); - return diagnosticMessage !== undefined ? { - diagnosticMessage: diagnosticMessage, - errorNode: node, - typeName: node.name - } : undefined; - } - function getParameterDeclarationTypeVisibilityDiagnosticMessage(symbolAccesibilityResult) { - switch (node.parent.kind) { - case 144: - return symbolAccesibilityResult.errorModuleName ? - symbolAccesibilityResult.accessibility === 2 ? - ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : - ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_private_module_2 : - ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_private_name_1; - case 148: - return symbolAccesibilityResult.errorModuleName ? - ts.Diagnostics.Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : - ts.Diagnostics.Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; - case 147: - return symbolAccesibilityResult.errorModuleName ? - ts.Diagnostics.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : - ts.Diagnostics.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; - case 143: - case 142: - if (node.parent.flags & 128) { - return symbolAccesibilityResult.errorModuleName ? - symbolAccesibilityResult.accessibility === 2 ? - ts.Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : - 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 === 214) { - return symbolAccesibilityResult.errorModuleName ? - symbolAccesibilityResult.accessibility === 2 ? - ts.Diagnostics.Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : - ts.Diagnostics.Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_private_module_2 : - ts.Diagnostics.Parameter_0_of_public_method_from_exported_class_has_or_is_using_private_name_1; - } - else { - return symbolAccesibilityResult.errorModuleName ? - 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 213: - return symbolAccesibilityResult.errorModuleName ? - symbolAccesibilityResult.accessibility === 2 ? - ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : - ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_name_1_from_private_module_2 : - ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_private_name_1; - default: - ts.Debug.fail("This is unknown parent for parameter: " + node.parent.kind); - } - } - function emitBindingPattern(bindingPattern) { - if (bindingPattern.kind === 161) { - write("{"); - emitCommaList(bindingPattern.elements, emitBindingElement); - write("}"); - } - else if (bindingPattern.kind === 162) { - write("["); - var elements = bindingPattern.elements; - emitCommaList(elements, emitBindingElement); - if (elements && elements.hasTrailingComma) { - write(", "); - } - write("]"); - } - } - function emitBindingElement(bindingElement) { - function getBindingElementTypeVisibilityError(symbolAccesibilityResult) { - var diagnosticMessage = getParameterDeclarationTypeVisibilityDiagnosticMessage(symbolAccesibilityResult); - return diagnosticMessage !== undefined ? { - diagnosticMessage: diagnosticMessage, - errorNode: bindingElement, - typeName: bindingElement.name - } : undefined; - } - if (bindingElement.kind === 187) { - write(" "); - } - else if (bindingElement.kind === 163) { - if (bindingElement.propertyName) { - writeTextOfNode(currentSourceFile, bindingElement.propertyName); - write(": "); - } - if (bindingElement.name) { - if (ts.isBindingPattern(bindingElement.name)) { - emitBindingPattern(bindingElement.name); - } - else { - ts.Debug.assert(bindingElement.name.kind === 69); - if (bindingElement.dotDotDotToken) { - write("..."); - } - writeTextOfNode(currentSourceFile, bindingElement.name); - } - } - } - } - } - function emitNode(node) { - switch (node.kind) { - case 213: - case 218: - case 221: - case 215: - case 214: - case 216: - case 217: - return emitModuleElement(node, isModuleElementVisible(node)); - case 193: - return emitModuleElement(node, isVariableStatementVisible(node)); - case 222: - return emitModuleElement(node, !node.importClause); - case 228: - return emitExportDeclaration(node); - case 144: - case 143: - case 142: - return writeFunctionDeclaration(node); - case 148: - case 147: - case 149: - return emitSignatureDeclarationWithJsDocComments(node); - case 145: - case 146: - return emitAccessorDeclaration(node); - case 141: - case 140: - return emitPropertyDeclaration(node); - case 247: - return emitEnumMemberDeclaration(node); - case 227: - return emitExportAssignment(node); - case 248: - return emitSourceFile(node); - } - } - function writeReferencePath(referencedFile) { - var declFileName = referencedFile.flags & 8192 - ? referencedFile.fileName - : ts.shouldEmitToOwnFile(referencedFile, compilerOptions) - ? ts.getOwnEmitOutputFilePath(referencedFile, host, ".d.ts") - : ts.removeFileExtension(compilerOptions.outFile || compilerOptions.out) + ".d.ts"; - declFileName = ts.getRelativePathToDirectoryOrUrl(ts.getDirectoryPath(ts.normalizeSlashes(jsFilePath)), declFileName, host.getCurrentDirectory(), host.getCanonicalFileName, false); - referencePathsOutput += "/// " + newLine; - } - } - function writeDeclarationFile(jsFilePath, sourceFile, host, resolver, diagnostics) { - var emitDeclarationResult = emitDeclarations(host, resolver, diagnostics, jsFilePath, sourceFile); - if (!emitDeclarationResult.reportedDeclarationError) { - var declarationOutput = emitDeclarationResult.referencePathsOutput - + getDeclarationOutput(emitDeclarationResult.synchronousDeclarationOutput, emitDeclarationResult.moduleElementDeclarationEmitInfo); - ts.writeFile(host, diagnostics, ts.removeFileExtension(jsFilePath) + ".d.ts", declarationOutput, host.getCompilerOptions().emitBOM); - } - function getDeclarationOutput(synchronousDeclarationOutput, moduleElementDeclarationEmitInfo) { - var appliedSyncOutputPos = 0; - var declarationOutput = ""; - ts.forEach(moduleElementDeclarationEmitInfo, function (aliasEmitInfo) { - if (aliasEmitInfo.asynchronousOutput) { - declarationOutput += synchronousDeclarationOutput.substring(appliedSyncOutputPos, aliasEmitInfo.outputPos); - declarationOutput += getDeclarationOutput(aliasEmitInfo.asynchronousOutput, aliasEmitInfo.subModuleElementDeclarationEmitInfo); - appliedSyncOutputPos = aliasEmitInfo.outputPos; - } - }); - declarationOutput += synchronousDeclarationOutput.substring(appliedSyncOutputPos); - return declarationOutput; - } - } - ts.writeDeclarationFile = writeDeclarationFile; -})(ts || (ts = {})); -var ts; -(function (ts) { - function isExternalModuleOrDeclarationFile(sourceFile) { - return ts.isExternalModule(sourceFile) || ts.isDeclarationFile(sourceFile); - } - ts.isExternalModuleOrDeclarationFile = isExternalModuleOrDeclarationFile; - var entities = { - "quot": 0x0022, - "amp": 0x0026, - "apos": 0x0027, - "lt": 0x003C, - "gt": 0x003E, - "nbsp": 0x00A0, - "iexcl": 0x00A1, - "cent": 0x00A2, - "pound": 0x00A3, - "curren": 0x00A4, - "yen": 0x00A5, - "brvbar": 0x00A6, - "sect": 0x00A7, - "uml": 0x00A8, - "copy": 0x00A9, - "ordf": 0x00AA, - "laquo": 0x00AB, - "not": 0x00AC, - "shy": 0x00AD, - "reg": 0x00AE, - "macr": 0x00AF, - "deg": 0x00B0, - "plusmn": 0x00B1, - "sup2": 0x00B2, - "sup3": 0x00B3, - "acute": 0x00B4, - "micro": 0x00B5, - "para": 0x00B6, - "middot": 0x00B7, - "cedil": 0x00B8, - "sup1": 0x00B9, - "ordm": 0x00BA, - "raquo": 0x00BB, - "frac14": 0x00BC, - "frac12": 0x00BD, - "frac34": 0x00BE, - "iquest": 0x00BF, - "Agrave": 0x00C0, - "Aacute": 0x00C1, - "Acirc": 0x00C2, - "Atilde": 0x00C3, - "Auml": 0x00C4, - "Aring": 0x00C5, - "AElig": 0x00C6, - "Ccedil": 0x00C7, - "Egrave": 0x00C8, - "Eacute": 0x00C9, - "Ecirc": 0x00CA, - "Euml": 0x00CB, - "Igrave": 0x00CC, - "Iacute": 0x00CD, - "Icirc": 0x00CE, - "Iuml": 0x00CF, - "ETH": 0x00D0, - "Ntilde": 0x00D1, - "Ograve": 0x00D2, - "Oacute": 0x00D3, - "Ocirc": 0x00D4, - "Otilde": 0x00D5, - "Ouml": 0x00D6, - "times": 0x00D7, - "Oslash": 0x00D8, - "Ugrave": 0x00D9, - "Uacute": 0x00DA, - "Ucirc": 0x00DB, - "Uuml": 0x00DC, - "Yacute": 0x00DD, - "THORN": 0x00DE, - "szlig": 0x00DF, - "agrave": 0x00E0, - "aacute": 0x00E1, - "acirc": 0x00E2, - "atilde": 0x00E3, - "auml": 0x00E4, - "aring": 0x00E5, - "aelig": 0x00E6, - "ccedil": 0x00E7, - "egrave": 0x00E8, - "eacute": 0x00E9, - "ecirc": 0x00EA, - "euml": 0x00EB, - "igrave": 0x00EC, - "iacute": 0x00ED, - "icirc": 0x00EE, - "iuml": 0x00EF, - "eth": 0x00F0, - "ntilde": 0x00F1, - "ograve": 0x00F2, - "oacute": 0x00F3, - "ocirc": 0x00F4, - "otilde": 0x00F5, - "ouml": 0x00F6, - "divide": 0x00F7, - "oslash": 0x00F8, - "ugrave": 0x00F9, - "uacute": 0x00FA, - "ucirc": 0x00FB, - "uuml": 0x00FC, - "yacute": 0x00FD, - "thorn": 0x00FE, - "yuml": 0x00FF, - "OElig": 0x0152, - "oelig": 0x0153, - "Scaron": 0x0160, - "scaron": 0x0161, - "Yuml": 0x0178, - "fnof": 0x0192, - "circ": 0x02C6, - "tilde": 0x02DC, - "Alpha": 0x0391, - "Beta": 0x0392, - "Gamma": 0x0393, - "Delta": 0x0394, - "Epsilon": 0x0395, - "Zeta": 0x0396, - "Eta": 0x0397, - "Theta": 0x0398, - "Iota": 0x0399, - "Kappa": 0x039A, - "Lambda": 0x039B, - "Mu": 0x039C, - "Nu": 0x039D, - "Xi": 0x039E, - "Omicron": 0x039F, - "Pi": 0x03A0, - "Rho": 0x03A1, - "Sigma": 0x03A3, - "Tau": 0x03A4, - "Upsilon": 0x03A5, - "Phi": 0x03A6, - "Chi": 0x03A7, - "Psi": 0x03A8, - "Omega": 0x03A9, - "alpha": 0x03B1, - "beta": 0x03B2, - "gamma": 0x03B3, - "delta": 0x03B4, - "epsilon": 0x03B5, - "zeta": 0x03B6, - "eta": 0x03B7, - "theta": 0x03B8, - "iota": 0x03B9, - "kappa": 0x03BA, - "lambda": 0x03BB, - "mu": 0x03BC, - "nu": 0x03BD, - "xi": 0x03BE, - "omicron": 0x03BF, - "pi": 0x03C0, - "rho": 0x03C1, - "sigmaf": 0x03C2, - "sigma": 0x03C3, - "tau": 0x03C4, - "upsilon": 0x03C5, - "phi": 0x03C6, - "chi": 0x03C7, - "psi": 0x03C8, - "omega": 0x03C9, - "thetasym": 0x03D1, - "upsih": 0x03D2, - "piv": 0x03D6, - "ensp": 0x2002, - "emsp": 0x2003, - "thinsp": 0x2009, - "zwnj": 0x200C, - "zwj": 0x200D, - "lrm": 0x200E, - "rlm": 0x200F, - "ndash": 0x2013, - "mdash": 0x2014, - "lsquo": 0x2018, - "rsquo": 0x2019, - "sbquo": 0x201A, - "ldquo": 0x201C, - "rdquo": 0x201D, - "bdquo": 0x201E, - "dagger": 0x2020, - "Dagger": 0x2021, - "bull": 0x2022, - "hellip": 0x2026, - "permil": 0x2030, - "prime": 0x2032, - "Prime": 0x2033, - "lsaquo": 0x2039, - "rsaquo": 0x203A, - "oline": 0x203E, - "frasl": 0x2044, - "euro": 0x20AC, - "image": 0x2111, - "weierp": 0x2118, - "real": 0x211C, - "trade": 0x2122, - "alefsym": 0x2135, - "larr": 0x2190, - "uarr": 0x2191, - "rarr": 0x2192, - "darr": 0x2193, - "harr": 0x2194, - "crarr": 0x21B5, - "lArr": 0x21D0, - "uArr": 0x21D1, - "rArr": 0x21D2, - "dArr": 0x21D3, - "hArr": 0x21D4, - "forall": 0x2200, - "part": 0x2202, - "exist": 0x2203, - "empty": 0x2205, - "nabla": 0x2207, - "isin": 0x2208, - "notin": 0x2209, - "ni": 0x220B, - "prod": 0x220F, - "sum": 0x2211, - "minus": 0x2212, - "lowast": 0x2217, - "radic": 0x221A, - "prop": 0x221D, - "infin": 0x221E, - "ang": 0x2220, - "and": 0x2227, - "or": 0x2228, - "cap": 0x2229, - "cup": 0x222A, - "int": 0x222B, - "there4": 0x2234, - "sim": 0x223C, - "cong": 0x2245, - "asymp": 0x2248, - "ne": 0x2260, - "equiv": 0x2261, - "le": 0x2264, - "ge": 0x2265, - "sub": 0x2282, - "sup": 0x2283, - "nsub": 0x2284, - "sube": 0x2286, - "supe": 0x2287, - "oplus": 0x2295, - "otimes": 0x2297, - "perp": 0x22A5, - "sdot": 0x22C5, - "lceil": 0x2308, - "rceil": 0x2309, - "lfloor": 0x230A, - "rfloor": 0x230B, - "lang": 0x2329, - "rang": 0x232A, - "loz": 0x25CA, - "spades": 0x2660, - "clubs": 0x2663, - "hearts": 0x2665, - "diams": 0x2666 - }; - function emitFiles(resolver, host, targetSourceFile) { - var extendsHelper = "\nvar __extends = (this && this.__extends) || function (d, b) {\n for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];\n function __() { this.constructor = d; }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n};"; - var decorateHelper = "\nvar __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\n return c > 3 && r && Object.defineProperty(target, key, r), r;\n};"; - var metadataHelper = "\nvar __metadata = (this && this.__metadata) || function (k, v) {\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(k, v);\n};"; - var paramHelper = "\nvar __param = (this && this.__param) || function (paramIndex, decorator) {\n return function (target, key) { decorator(target, key, paramIndex); }\n};"; - var awaiterHelper = "\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promise, generator) {\n return new Promise(function (resolve, reject) {\n generator = generator.call(thisArg, _arguments);\n function cast(value) { return value instanceof Promise && value.constructor === Promise ? value : new Promise(function (resolve) { resolve(value); }); }\n function onfulfill(value) { try { step(\"next\", value); } catch (e) { reject(e); } }\n function onreject(value) { try { step(\"throw\", value); } catch (e) { reject(e); } }\n function step(verb, value) {\n var result = generator[verb](value);\n result.done ? resolve(result.value) : cast(result.value).then(onfulfill, onreject);\n }\n step(\"next\", void 0);\n });\n};"; - var compilerOptions = host.getCompilerOptions(); - var languageVersion = compilerOptions.target || 0; - var modulekind = compilerOptions.module ? compilerOptions.module : languageVersion === 2 ? 5 : 0; - var sourceMapDataList = compilerOptions.sourceMap || compilerOptions.inlineSourceMap ? [] : undefined; - var diagnostics = []; - var newLine = host.getNewLine(); - var jsxDesugaring = host.getCompilerOptions().jsx !== 1; - var shouldEmitJsx = function (s) { return (s.languageVariant === 1 && !jsxDesugaring); }; - if (targetSourceFile === undefined) { - ts.forEach(host.getSourceFiles(), function (sourceFile) { - if (ts.shouldEmitToOwnFile(sourceFile, compilerOptions)) { - var jsFilePath = ts.getOwnEmitOutputFilePath(sourceFile, host, shouldEmitJsx(sourceFile) ? ".jsx" : ".js"); - emitFile(jsFilePath, sourceFile); - } - }); - if (compilerOptions.outFile || compilerOptions.out) { - emitFile(compilerOptions.outFile || compilerOptions.out); - } - } - else { - if (ts.shouldEmitToOwnFile(targetSourceFile, compilerOptions)) { - var jsFilePath = ts.getOwnEmitOutputFilePath(targetSourceFile, host, shouldEmitJsx(targetSourceFile) ? ".jsx" : ".js"); - emitFile(jsFilePath, targetSourceFile); - } - else if (!ts.isDeclarationFile(targetSourceFile) && (compilerOptions.outFile || compilerOptions.out)) { - emitFile(compilerOptions.outFile || compilerOptions.out); - } - } - diagnostics = ts.sortAndDeduplicateDiagnostics(diagnostics); - return { - emitSkipped: false, - diagnostics: diagnostics, - sourceMaps: sourceMapDataList - }; - function isNodeDescendentOf(node, ancestor) { - while (node) { - if (node === ancestor) - return true; - node = node.parent; - } - return false; - } - function isUniqueLocalName(name, container) { - for (var node = container; isNodeDescendentOf(node, container); node = node.nextContainer) { - if (node.locals && ts.hasProperty(node.locals, name)) { - if (node.locals[name].flags & (107455 | 1048576 | 8388608)) { - return false; - } - } - } - return true; - } - function emitJavaScript(jsFilePath, root) { - var writer = ts.createTextWriter(newLine); - var write = writer.write, writeTextOfNode = writer.writeTextOfNode, writeLine = writer.writeLine, increaseIndent = writer.increaseIndent, decreaseIndent = writer.decreaseIndent; - var currentSourceFile; - var exportFunctionForFile; - var generatedNameSet = {}; - var nodeToGeneratedName = []; - var computedPropertyNamesToGeneratedNames; - var extendsEmitted = false; - var decorateEmitted = false; - var paramEmitted = false; - var awaiterEmitted = false; - var tempFlags = 0; - var tempVariables; - var tempParameters; - var externalImports; - var exportSpecifiers; - var exportEquals; - var hasExportStars; - var writeEmittedFiles = writeJavaScriptFile; - var detachedCommentsInfo; - var writeComment = ts.writeCommentRange; - var emit = emitNodeWithCommentsAndWithoutSourcemap; - var emitStart = function (node) { }; - var emitEnd = function (node) { }; - var emitToken = emitTokenText; - var scopeEmitStart = function (scopeDeclaration, scopeName) { }; - var scopeEmitEnd = function () { }; - var sourceMapData; - var emitLeadingCommentsOfPosition = compilerOptions.removeComments ? function (pos) { } : emitLeadingCommentsOfPositionWorker; - var moduleEmitDelegates = (_a = {}, - _a[5] = emitES6Module, - _a[2] = emitAMDModule, - _a[4] = emitSystemModule, - _a[3] = emitUMDModule, - _a[1] = emitCommonJSModule, - _a - ); - if (compilerOptions.sourceMap || compilerOptions.inlineSourceMap) { - initializeEmitterWithSourceMaps(); - } - if (root) { - emitSourceFile(root); - } - else { - ts.forEach(host.getSourceFiles(), function (sourceFile) { - if (!isExternalModuleOrDeclarationFile(sourceFile)) { - emitSourceFile(sourceFile); - } - }); - } - writeLine(); - writeEmittedFiles(writer.getText(), compilerOptions.emitBOM); - return; - function emitSourceFile(sourceFile) { - currentSourceFile = sourceFile; - exportFunctionForFile = undefined; - emit(sourceFile); - } - function isUniqueName(name) { - return !resolver.hasGlobalName(name) && - !ts.hasProperty(currentSourceFile.identifiers, name) && - !ts.hasProperty(generatedNameSet, name); - } - function makeTempVariableName(flags) { - if (flags && !(tempFlags & flags)) { - var name_19 = flags === 268435456 ? "_i" : "_n"; - if (isUniqueName(name_19)) { - tempFlags |= flags; - return name_19; - } - } - while (true) { - var count = tempFlags & 268435455; - tempFlags++; - if (count !== 8 && count !== 13) { - var name_20 = count < 26 ? "_" + String.fromCharCode(97 + count) : "_" + (count - 26); - if (isUniqueName(name_20)) { - return name_20; - } - } - } - } - function makeUniqueName(baseName) { - if (baseName.charCodeAt(baseName.length - 1) !== 95) { - baseName += "_"; - } - var i = 1; - while (true) { - var generatedName = baseName + i; - if (isUniqueName(generatedName)) { - return generatedNameSet[generatedName] = generatedName; - } - i++; - } - } - function generateNameForModuleOrEnum(node) { - var name = node.name.text; - return isUniqueLocalName(name, node) ? name : makeUniqueName(name); - } - function generateNameForImportOrExportDeclaration(node) { - var expr = ts.getExternalModuleName(node); - var baseName = expr.kind === 9 ? - ts.escapeIdentifier(ts.makeIdentifierFromModuleName(expr.text)) : "module"; - return makeUniqueName(baseName); - } - function generateNameForExportDefault() { - return makeUniqueName("default"); - } - function generateNameForClassExpression() { - return makeUniqueName("class"); - } - function generateNameForNode(node) { - switch (node.kind) { - case 69: - return makeUniqueName(node.text); - case 218: - case 217: - return generateNameForModuleOrEnum(node); - case 222: - case 228: - return generateNameForImportOrExportDeclaration(node); - case 213: - case 214: - case 227: - return generateNameForExportDefault(); - case 186: - return generateNameForClassExpression(); - } - } - function getGeneratedNameForNode(node) { - var id = ts.getNodeId(node); - return nodeToGeneratedName[id] || (nodeToGeneratedName[id] = ts.unescapeIdentifier(generateNameForNode(node))); - } - function initializeEmitterWithSourceMaps() { - var sourceMapDir; - var sourceMapSourceIndex = -1; - var sourceMapNameIndexMap = {}; - var sourceMapNameIndices = []; - function getSourceMapNameIndex() { - return sourceMapNameIndices.length ? ts.lastOrUndefined(sourceMapNameIndices) : -1; - } - var lastRecordedSourceMapSpan; - var lastEncodedSourceMapSpan = { - emittedLine: 1, - emittedColumn: 1, - sourceLine: 1, - sourceColumn: 1, - sourceIndex: 0 - }; - var lastEncodedNameIndex = 0; - function encodeLastRecordedSourceMapSpan() { - if (!lastRecordedSourceMapSpan || lastRecordedSourceMapSpan === lastEncodedSourceMapSpan) { - return; - } - var prevEncodedEmittedColumn = lastEncodedSourceMapSpan.emittedColumn; - if (lastEncodedSourceMapSpan.emittedLine === lastRecordedSourceMapSpan.emittedLine) { - if (sourceMapData.sourceMapMappings) { - sourceMapData.sourceMapMappings += ","; - } - } - else { - for (var encodedLine = lastEncodedSourceMapSpan.emittedLine; encodedLine < lastRecordedSourceMapSpan.emittedLine; encodedLine++) { - sourceMapData.sourceMapMappings += ";"; - } - prevEncodedEmittedColumn = 1; - } - sourceMapData.sourceMapMappings += base64VLQFormatEncode(lastRecordedSourceMapSpan.emittedColumn - prevEncodedEmittedColumn); - sourceMapData.sourceMapMappings += base64VLQFormatEncode(lastRecordedSourceMapSpan.sourceIndex - lastEncodedSourceMapSpan.sourceIndex); - sourceMapData.sourceMapMappings += base64VLQFormatEncode(lastRecordedSourceMapSpan.sourceLine - lastEncodedSourceMapSpan.sourceLine); - sourceMapData.sourceMapMappings += base64VLQFormatEncode(lastRecordedSourceMapSpan.sourceColumn - lastEncodedSourceMapSpan.sourceColumn); - if (lastRecordedSourceMapSpan.nameIndex >= 0) { - sourceMapData.sourceMapMappings += base64VLQFormatEncode(lastRecordedSourceMapSpan.nameIndex - lastEncodedNameIndex); - lastEncodedNameIndex = lastRecordedSourceMapSpan.nameIndex; - } - lastEncodedSourceMapSpan = lastRecordedSourceMapSpan; - sourceMapData.sourceMapDecodedMappings.push(lastEncodedSourceMapSpan); - function base64VLQFormatEncode(inValue) { - function base64FormatEncode(inValue) { - if (inValue < 64) { - return "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(inValue); - } - throw TypeError(inValue + ": not a 64 based value"); - } - if (inValue < 0) { - inValue = ((-inValue) << 1) + 1; - } - else { - inValue = inValue << 1; - } - var encodedStr = ""; - do { - var currentDigit = inValue & 31; - inValue = inValue >> 5; - if (inValue > 0) { - currentDigit = currentDigit | 32; - } - encodedStr = encodedStr + base64FormatEncode(currentDigit); - } while (inValue > 0); - return encodedStr; - } - } - function recordSourceMapSpan(pos) { - var sourceLinePos = ts.getLineAndCharacterOfPosition(currentSourceFile, pos); - sourceLinePos.line++; - sourceLinePos.character++; - var emittedLine = writer.getLine(); - var emittedColumn = writer.getColumn(); - if (!lastRecordedSourceMapSpan || - lastRecordedSourceMapSpan.emittedLine !== emittedLine || - lastRecordedSourceMapSpan.emittedColumn !== emittedColumn || - (lastRecordedSourceMapSpan.sourceIndex === sourceMapSourceIndex && - (lastRecordedSourceMapSpan.sourceLine > sourceLinePos.line || - (lastRecordedSourceMapSpan.sourceLine === sourceLinePos.line && lastRecordedSourceMapSpan.sourceColumn > sourceLinePos.character)))) { - encodeLastRecordedSourceMapSpan(); - lastRecordedSourceMapSpan = { - emittedLine: emittedLine, - emittedColumn: emittedColumn, - sourceLine: sourceLinePos.line, - sourceColumn: sourceLinePos.character, - nameIndex: getSourceMapNameIndex(), - sourceIndex: sourceMapSourceIndex - }; - } - else { - lastRecordedSourceMapSpan.sourceLine = sourceLinePos.line; - lastRecordedSourceMapSpan.sourceColumn = sourceLinePos.character; - lastRecordedSourceMapSpan.sourceIndex = sourceMapSourceIndex; - } - } - function recordEmitNodeStartSpan(node) { - recordSourceMapSpan(ts.skipTrivia(currentSourceFile.text, node.pos)); - } - function recordEmitNodeEndSpan(node) { - recordSourceMapSpan(node.end); - } - function writeTextWithSpanRecord(tokenKind, startPos, emitFn) { - var tokenStartPos = ts.skipTrivia(currentSourceFile.text, startPos); - recordSourceMapSpan(tokenStartPos); - var tokenEndPos = emitTokenText(tokenKind, tokenStartPos, emitFn); - recordSourceMapSpan(tokenEndPos); - return tokenEndPos; - } - function recordNewSourceFileStart(node) { - var sourcesDirectoryPath = compilerOptions.sourceRoot ? host.getCommonSourceDirectory() : sourceMapDir; - sourceMapData.sourceMapSources.push(ts.getRelativePathToDirectoryOrUrl(sourcesDirectoryPath, node.fileName, host.getCurrentDirectory(), host.getCanonicalFileName, true)); - sourceMapSourceIndex = sourceMapData.sourceMapSources.length - 1; - sourceMapData.inputSourceFileNames.push(node.fileName); - if (compilerOptions.inlineSources) { - if (!sourceMapData.sourceMapSourcesContent) { - sourceMapData.sourceMapSourcesContent = []; - } - sourceMapData.sourceMapSourcesContent.push(node.text); - } - } - function recordScopeNameOfNode(node, scopeName) { - function recordScopeNameIndex(scopeNameIndex) { - sourceMapNameIndices.push(scopeNameIndex); - } - function recordScopeNameStart(scopeName) { - var scopeNameIndex = -1; - if (scopeName) { - var parentIndex = getSourceMapNameIndex(); - if (parentIndex !== -1) { - var name_21 = node.name; - if (!name_21 || name_21.kind !== 136) { - scopeName = "." + scopeName; - } - scopeName = sourceMapData.sourceMapNames[parentIndex] + scopeName; - } - scopeNameIndex = ts.getProperty(sourceMapNameIndexMap, scopeName); - if (scopeNameIndex === undefined) { - scopeNameIndex = sourceMapData.sourceMapNames.length; - sourceMapData.sourceMapNames.push(scopeName); - sourceMapNameIndexMap[scopeName] = scopeNameIndex; - } - } - recordScopeNameIndex(scopeNameIndex); - } - if (scopeName) { - recordScopeNameStart(scopeName); - } - else if (node.kind === 213 || - node.kind === 173 || - node.kind === 143 || - node.kind === 142 || - node.kind === 145 || - node.kind === 146 || - node.kind === 218 || - node.kind === 214 || - node.kind === 217) { - if (node.name) { - var name_22 = node.name; - scopeName = name_22.kind === 136 - ? ts.getTextOfNode(name_22) - : node.name.text; - } - recordScopeNameStart(scopeName); - } - else { - recordScopeNameIndex(getSourceMapNameIndex()); - } - } - function recordScopeNameEnd() { - sourceMapNameIndices.pop(); - } - ; - function writeCommentRangeWithMap(curentSourceFile, writer, comment, newLine) { - recordSourceMapSpan(comment.pos); - ts.writeCommentRange(currentSourceFile, writer, comment, newLine); - recordSourceMapSpan(comment.end); - } - function serializeSourceMapContents(version, file, sourceRoot, sources, names, mappings, sourcesContent) { - if (typeof JSON !== "undefined") { - var map_1 = { - version: version, - file: file, - sourceRoot: sourceRoot, - sources: sources, - names: names, - mappings: mappings - }; - if (sourcesContent !== undefined) { - map_1.sourcesContent = sourcesContent; - } - return JSON.stringify(map_1); - } - return "{\"version\":" + version + ",\"file\":\"" + ts.escapeString(file) + "\",\"sourceRoot\":\"" + ts.escapeString(sourceRoot) + "\",\"sources\":[" + serializeStringArray(sources) + "],\"names\":[" + serializeStringArray(names) + "],\"mappings\":\"" + ts.escapeString(mappings) + "\" " + (sourcesContent !== undefined ? ",\"sourcesContent\":[" + serializeStringArray(sourcesContent) + "]" : "") + "}"; - function serializeStringArray(list) { - var output = ""; - for (var i = 0, n = list.length; i < n; i++) { - if (i) { - output += ","; - } - output += "\"" + ts.escapeString(list[i]) + "\""; - } - return output; - } - } - function writeJavaScriptAndSourceMapFile(emitOutput, writeByteOrderMark) { - encodeLastRecordedSourceMapSpan(); - var sourceMapText = serializeSourceMapContents(3, sourceMapData.sourceMapFile, sourceMapData.sourceMapSourceRoot, sourceMapData.sourceMapSources, sourceMapData.sourceMapNames, sourceMapData.sourceMapMappings, sourceMapData.sourceMapSourcesContent); - sourceMapDataList.push(sourceMapData); - var sourceMapUrl; - if (compilerOptions.inlineSourceMap) { - var base64SourceMapText = ts.convertToBase64(sourceMapText); - sourceMapUrl = "//# sourceMappingURL=data:application/json;base64," + base64SourceMapText; - } - else { - ts.writeFile(host, diagnostics, sourceMapData.sourceMapFilePath, sourceMapText, false); - sourceMapUrl = "//# sourceMappingURL=" + sourceMapData.jsSourceMappingURL; - } - writeJavaScriptFile(emitOutput + sourceMapUrl, writeByteOrderMark); - } - var sourceMapJsFile = ts.getBaseFileName(ts.normalizeSlashes(jsFilePath)); - sourceMapData = { - sourceMapFilePath: jsFilePath + ".map", - jsSourceMappingURL: sourceMapJsFile + ".map", - sourceMapFile: sourceMapJsFile, - sourceMapSourceRoot: compilerOptions.sourceRoot || "", - sourceMapSources: [], - inputSourceFileNames: [], - sourceMapNames: [], - sourceMapMappings: "", - sourceMapSourcesContent: undefined, - sourceMapDecodedMappings: [] - }; - sourceMapData.sourceMapSourceRoot = ts.normalizeSlashes(sourceMapData.sourceMapSourceRoot); - if (sourceMapData.sourceMapSourceRoot.length && sourceMapData.sourceMapSourceRoot.charCodeAt(sourceMapData.sourceMapSourceRoot.length - 1) !== 47) { - sourceMapData.sourceMapSourceRoot += ts.directorySeparator; - } - if (compilerOptions.mapRoot) { - sourceMapDir = ts.normalizeSlashes(compilerOptions.mapRoot); - if (root) { - sourceMapDir = ts.getDirectoryPath(ts.getSourceFilePathInNewDir(root, host, sourceMapDir)); - } - if (!ts.isRootedDiskPath(sourceMapDir) && !ts.isUrl(sourceMapDir)) { - sourceMapDir = ts.combinePaths(host.getCommonSourceDirectory(), sourceMapDir); - sourceMapData.jsSourceMappingURL = ts.getRelativePathToDirectoryOrUrl(ts.getDirectoryPath(ts.normalizePath(jsFilePath)), ts.combinePaths(sourceMapDir, sourceMapData.jsSourceMappingURL), host.getCurrentDirectory(), host.getCanonicalFileName, true); - } - else { - sourceMapData.jsSourceMappingURL = ts.combinePaths(sourceMapDir, sourceMapData.jsSourceMappingURL); - } - } - else { - sourceMapDir = ts.getDirectoryPath(ts.normalizePath(jsFilePath)); - } - function emitNodeWithSourceMap(node) { - if (node) { - if (ts.nodeIsSynthesized(node)) { - return emitNodeWithoutSourceMap(node); - } - if (node.kind !== 248) { - recordEmitNodeStartSpan(node); - emitNodeWithoutSourceMap(node); - recordEmitNodeEndSpan(node); - } - else { - recordNewSourceFileStart(node); - emitNodeWithoutSourceMap(node); - } - } - } - function emitNodeWithCommentsAndWithSourcemap(node) { - emitNodeConsideringCommentsOption(node, emitNodeWithSourceMap); - } - writeEmittedFiles = writeJavaScriptAndSourceMapFile; - emit = emitNodeWithCommentsAndWithSourcemap; - emitStart = recordEmitNodeStartSpan; - emitEnd = recordEmitNodeEndSpan; - emitToken = writeTextWithSpanRecord; - scopeEmitStart = recordScopeNameOfNode; - scopeEmitEnd = recordScopeNameEnd; - writeComment = writeCommentRangeWithMap; - } - function writeJavaScriptFile(emitOutput, writeByteOrderMark) { - ts.writeFile(host, diagnostics, jsFilePath, emitOutput, writeByteOrderMark); - } - function createTempVariable(flags) { - var result = ts.createSynthesizedNode(69); - result.text = makeTempVariableName(flags); - return result; - } - function recordTempDeclaration(name) { - if (!tempVariables) { - tempVariables = []; - } - tempVariables.push(name); - } - function createAndRecordTempVariable(flags) { - var temp = createTempVariable(flags); - recordTempDeclaration(temp); - return temp; - } - function emitTempDeclarations(newLine) { - if (tempVariables) { - if (newLine) { - writeLine(); - } - else { - write(" "); - } - write("var "); - emitCommaList(tempVariables); - write(";"); - } - } - function emitTokenText(tokenKind, startPos, emitFn) { - var tokenString = ts.tokenToString(tokenKind); - if (emitFn) { - emitFn(); - } - else { - write(tokenString); - } - return startPos + tokenString.length; - } - function emitOptional(prefix, node) { - if (node) { - write(prefix); - emit(node); - } - } - function emitParenthesizedIf(node, parenthesized) { - if (parenthesized) { - write("("); - } - emit(node); - if (parenthesized) { - write(")"); - } - } - function emitTrailingCommaIfPresent(nodeList) { - if (nodeList.hasTrailingComma) { - write(","); - } - } - function emitLinePreservingList(parent, nodes, allowTrailingComma, spacesBetweenBraces) { - ts.Debug.assert(nodes.length > 0); - increaseIndent(); - if (nodeStartPositionsAreOnSameLine(parent, nodes[0])) { - if (spacesBetweenBraces) { - write(" "); - } - } - else { - writeLine(); - } - for (var i = 0, n = nodes.length; i < n; i++) { - if (i) { - if (nodeEndIsOnSameLineAsNodeStart(nodes[i - 1], nodes[i])) { - write(", "); - } - else { - write(","); - writeLine(); - } - } - emit(nodes[i]); - } - if (nodes.hasTrailingComma && allowTrailingComma) { - write(","); - } - decreaseIndent(); - if (nodeEndPositionsAreOnSameLine(parent, ts.lastOrUndefined(nodes))) { - if (spacesBetweenBraces) { - write(" "); - } - } - else { - writeLine(); - } - } - function emitList(nodes, start, count, multiLine, trailingComma, leadingComma, noTrailingNewLine, emitNode) { - if (!emitNode) { - emitNode = emit; - } - for (var i = 0; i < count; i++) { - if (multiLine) { - if (i || leadingComma) { - write(","); - } - writeLine(); - } - else { - if (i || leadingComma) { - write(", "); - } - } - var node = nodes[start + i]; - emitTrailingCommentsOfPosition(node.pos); - emitNode(node); - leadingComma = true; - } - if (trailingComma) { - write(","); - } - if (multiLine && !noTrailingNewLine) { - writeLine(); - } - return count; - } - function emitCommaList(nodes) { - if (nodes) { - emitList(nodes, 0, nodes.length, false, false); - } - } - function emitLines(nodes) { - emitLinesStartingAt(nodes, 0); - } - function emitLinesStartingAt(nodes, startIndex) { - for (var i = startIndex; i < nodes.length; i++) { - writeLine(); - emit(nodes[i]); - } - } - function isBinaryOrOctalIntegerLiteral(node, text) { - if (node.kind === 8 && text.length > 1) { - switch (text.charCodeAt(1)) { - case 98: - case 66: - case 111: - case 79: - return true; - } - } - return false; - } - function emitLiteral(node) { - var text = getLiteralText(node); - if ((compilerOptions.sourceMap || compilerOptions.inlineSourceMap) && (node.kind === 9 || ts.isTemplateLiteralKind(node.kind))) { - writer.writeLiteral(text); - } - else if (languageVersion < 2 && isBinaryOrOctalIntegerLiteral(node, text)) { - write(node.text); - } - else { - write(text); - } - } - function getLiteralText(node) { - if (languageVersion < 2 && (ts.isTemplateLiteralKind(node.kind) || node.hasExtendedUnicodeEscape)) { - return getQuotedEscapedLiteralText("\"", node.text, "\""); - } - if (node.parent) { - return ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, node); - } - switch (node.kind) { - case 9: - return getQuotedEscapedLiteralText("\"", node.text, "\""); - case 11: - return getQuotedEscapedLiteralText("`", node.text, "`"); - case 12: - return getQuotedEscapedLiteralText("`", node.text, "${"); - case 13: - return getQuotedEscapedLiteralText("}", node.text, "${"); - case 14: - return getQuotedEscapedLiteralText("}", node.text, "`"); - case 8: - return node.text; - } - ts.Debug.fail("Literal kind '" + node.kind + "' not accounted for."); - } - function getQuotedEscapedLiteralText(leftQuote, text, rightQuote) { - return leftQuote + ts.escapeNonAsciiCharacters(ts.escapeString(text)) + rightQuote; - } - function emitDownlevelRawTemplateLiteral(node) { - var text = ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, node); - var isLast = node.kind === 11 || node.kind === 14; - text = text.substring(1, text.length - (isLast ? 1 : 2)); - text = text.replace(/\r\n?/g, "\n"); - text = ts.escapeString(text); - write("\"" + text + "\""); - } - function emitDownlevelTaggedTemplateArray(node, literalEmitter) { - write("["); - if (node.template.kind === 11) { - literalEmitter(node.template); - } - else { - literalEmitter(node.template.head); - ts.forEach(node.template.templateSpans, function (child) { - write(", "); - literalEmitter(child.literal); - }); - } - write("]"); - } - function emitDownlevelTaggedTemplate(node) { - var tempVariable = createAndRecordTempVariable(0); - write("("); - emit(tempVariable); - write(" = "); - emitDownlevelTaggedTemplateArray(node, emit); - write(", "); - emit(tempVariable); - write(".raw = "); - emitDownlevelTaggedTemplateArray(node, emitDownlevelRawTemplateLiteral); - write(", "); - emitParenthesizedIf(node.tag, needsParenthesisForPropertyAccessOrInvocation(node.tag)); - write("("); - emit(tempVariable); - if (node.template.kind === 183) { - ts.forEach(node.template.templateSpans, function (templateSpan) { - write(", "); - var needsParens = templateSpan.expression.kind === 181 - && templateSpan.expression.operatorToken.kind === 24; - emitParenthesizedIf(templateSpan.expression, needsParens); - }); - } - write("))"); - } - function emitTemplateExpression(node) { - if (languageVersion >= 2) { - ts.forEachChild(node, emit); - return; - } - var emitOuterParens = ts.isExpression(node.parent) - && templateNeedsParens(node, node.parent); - if (emitOuterParens) { - write("("); - } - var headEmitted = false; - if (shouldEmitTemplateHead()) { - emitLiteral(node.head); - headEmitted = true; - } - for (var i = 0, n = node.templateSpans.length; i < n; i++) { - var templateSpan = node.templateSpans[i]; - var needsParens = templateSpan.expression.kind !== 172 - && comparePrecedenceToBinaryPlus(templateSpan.expression) !== 1; - if (i > 0 || headEmitted) { - write(" + "); - } - emitParenthesizedIf(templateSpan.expression, needsParens); - if (templateSpan.literal.text.length !== 0) { - write(" + "); - emitLiteral(templateSpan.literal); - } - } - if (emitOuterParens) { - write(")"); - } - function shouldEmitTemplateHead() { - ts.Debug.assert(node.templateSpans.length !== 0); - return node.head.text.length !== 0 || node.templateSpans[0].literal.text.length === 0; - } - function templateNeedsParens(template, parent) { - switch (parent.kind) { - case 168: - case 169: - return parent.expression === template; - case 170: - case 172: - return false; - default: - return comparePrecedenceToBinaryPlus(parent) !== -1; - } - } - function comparePrecedenceToBinaryPlus(expression) { - switch (expression.kind) { - case 181: - switch (expression.operatorToken.kind) { - case 37: - case 39: - case 40: - return 1; - case 35: - case 36: - return 0; - default: - return -1; - } - case 184: - case 182: - return -1; - default: - return 1; - } - } - } - function emitTemplateSpan(span) { - emit(span.expression); - emit(span.literal); - } - function jsxEmitReact(node) { - function emitTagName(name) { - if (name.kind === 69 && ts.isIntrinsicJsxName(name.text)) { - write("\""); - emit(name); - write("\""); - } - else { - emit(name); - } - } - function emitAttributeName(name) { - if (/[A-Za-z_]+[\w*]/.test(name.text)) { - write("\""); - emit(name); - write("\""); - } - else { - emit(name); - } - } - function emitJsxAttribute(node) { - emitAttributeName(node.name); - write(": "); - if (node.initializer) { - emit(node.initializer); - } - else { - write("true"); - } - } - function emitJsxElement(openingNode, children) { - var syntheticReactRef = ts.createSynthesizedNode(69); - syntheticReactRef.text = "React"; - syntheticReactRef.parent = openingNode; - emitLeadingComments(openingNode); - emitExpressionIdentifier(syntheticReactRef); - write(".createElement("); - emitTagName(openingNode.tagName); - write(", "); - if (openingNode.attributes.length === 0) { - write("null"); - } - else { - var attrs = openingNode.attributes; - if (ts.forEach(attrs, function (attr) { return attr.kind === 239; })) { - emitExpressionIdentifier(syntheticReactRef); - write(".__spread("); - var haveOpenedObjectLiteral = false; - for (var i_1 = 0; i_1 < attrs.length; i_1++) { - if (attrs[i_1].kind === 239) { - if (i_1 === 0) { - write("{}, "); - } - if (haveOpenedObjectLiteral) { - write("}"); - haveOpenedObjectLiteral = false; - } - if (i_1 > 0) { - write(", "); - } - emit(attrs[i_1].expression); - } - else { - ts.Debug.assert(attrs[i_1].kind === 238); - if (haveOpenedObjectLiteral) { - write(", "); - } - else { - haveOpenedObjectLiteral = true; - if (i_1 > 0) { - write(", "); - } - write("{"); - } - emitJsxAttribute(attrs[i_1]); - } - } - if (haveOpenedObjectLiteral) - write("}"); - write(")"); - } - else { - write("{"); - for (var i = 0; i < attrs.length; i++) { - if (i > 0) { - write(", "); - } - emitJsxAttribute(attrs[i]); - } - write("}"); - } - } - if (children) { - for (var i = 0; i < children.length; i++) { - if (children[i].kind === 240 && !(children[i].expression)) { - continue; - } - if (children[i].kind === 236) { - var text = getTextToEmit(children[i]); - if (text !== undefined) { - write(", \""); - write(text); - write("\""); - } - } - else { - write(", "); - emit(children[i]); - } - } - } - write(")"); - emitTrailingComments(openingNode); - } - if (node.kind === 233) { - emitJsxElement(node.openingElement, node.children); - } - else { - ts.Debug.assert(node.kind === 234); - emitJsxElement(node); - } - } - function jsxEmitPreserve(node) { - function emitJsxAttribute(node) { - emit(node.name); - if (node.initializer) { - write("="); - emit(node.initializer); - } - } - function emitJsxSpreadAttribute(node) { - write("{..."); - emit(node.expression); - write("}"); - } - function emitAttributes(attribs) { - for (var i = 0, n = attribs.length; i < n; i++) { - if (i > 0) { - write(" "); - } - if (attribs[i].kind === 239) { - emitJsxSpreadAttribute(attribs[i]); - } - else { - ts.Debug.assert(attribs[i].kind === 238); - emitJsxAttribute(attribs[i]); - } - } - } - function emitJsxOpeningOrSelfClosingElement(node) { - write("<"); - emit(node.tagName); - if (node.attributes.length > 0 || (node.kind === 234)) { - write(" "); - } - emitAttributes(node.attributes); - if (node.kind === 234) { - write("/>"); - } - else { - write(">"); - } - } - function emitJsxClosingElement(node) { - write(""); - } - function emitJsxElement(node) { - emitJsxOpeningOrSelfClosingElement(node.openingElement); - for (var i = 0, n = node.children.length; i < n; i++) { - emit(node.children[i]); - } - emitJsxClosingElement(node.closingElement); - } - if (node.kind === 233) { - emitJsxElement(node); - } - else { - ts.Debug.assert(node.kind === 234); - emitJsxOpeningOrSelfClosingElement(node); - } - } - function emitExpressionForPropertyName(node) { - ts.Debug.assert(node.kind !== 163); - if (node.kind === 9) { - emitLiteral(node); - } - else if (node.kind === 136) { - if (ts.nodeIsDecorated(node.parent)) { - if (!computedPropertyNamesToGeneratedNames) { - computedPropertyNamesToGeneratedNames = []; - } - var generatedName = computedPropertyNamesToGeneratedNames[ts.getNodeId(node)]; - if (generatedName) { - write(generatedName); - return; - } - generatedName = createAndRecordTempVariable(0).text; - computedPropertyNamesToGeneratedNames[ts.getNodeId(node)] = generatedName; - write(generatedName); - write(" = "); - } - emit(node.expression); - } - else { - write("\""); - if (node.kind === 8) { - write(node.text); - } - else { - writeTextOfNode(currentSourceFile, node); - } - write("\""); - } - } - function isExpressionIdentifier(node) { - var parent = node.parent; - switch (parent.kind) { - case 164: - case 189: - case 181: - case 168: - case 241: - case 136: - case 182: - case 139: - case 175: - case 197: - case 167: - case 227: - case 195: - case 188: - case 199: - case 200: - case 201: - case 196: - case 234: - case 235: - case 239: - case 240: - case 169: - case 172: - case 180: - case 179: - case 204: - case 246: - case 185: - case 206: - case 170: - case 190: - case 208: - case 171: - case 176: - case 177: - case 198: - case 205: - case 184: - return true; - case 163: - case 247: - case 138: - case 245: - case 141: - case 211: - return parent.initializer === node; - case 166: - return parent.expression === node; - case 174: - case 173: - return parent.body === node; - case 221: - return parent.moduleReference === node; - case 135: - return parent.left === node; - } - return false; - } - function emitExpressionIdentifier(node) { - if (resolver.getNodeCheckFlags(node) & 2048) { - write("_arguments"); - return; - } - var container = resolver.getReferencedExportContainer(node); - if (container) { - if (container.kind === 248) { - if (modulekind !== 5 && modulekind !== 4) { - write("exports."); - } - } - else { - write(getGeneratedNameForNode(container)); - write("."); - } - } - else { - if (modulekind !== 5) { - var declaration = resolver.getReferencedImportDeclaration(node); - if (declaration) { - if (declaration.kind === 223) { - write(getGeneratedNameForNode(declaration.parent)); - write(languageVersion === 0 ? "[\"default\"]" : ".default"); - return; - } - else if (declaration.kind === 226) { - write(getGeneratedNameForNode(declaration.parent.parent.parent)); - var name_23 = declaration.propertyName || declaration.name; - var identifier = ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, name_23); - if (languageVersion === 0 && identifier === "default") { - write("[\"default\"]"); - } - else { - write("."); - write(identifier); - } - return; - } - } - } - if (languageVersion !== 2) { - var declaration = resolver.getReferencedNestedRedeclaration(node); - if (declaration) { - write(getGeneratedNameForNode(declaration.name)); - return; - } - } - } - if (ts.nodeIsSynthesized(node)) { - write(node.text); - } - else { - writeTextOfNode(currentSourceFile, node); - } - } - function isNameOfNestedRedeclaration(node) { - if (languageVersion < 2) { - var parent_6 = node.parent; - switch (parent_6.kind) { - case 163: - case 214: - case 217: - case 211: - return parent_6.name === node && resolver.isNestedRedeclaration(parent_6); - } - } - return false; - } - function emitIdentifier(node) { - if (!node.parent) { - write(node.text); - } - else if (isExpressionIdentifier(node)) { - emitExpressionIdentifier(node); - } - else if (isNameOfNestedRedeclaration(node)) { - write(getGeneratedNameForNode(node)); - } - else if (ts.nodeIsSynthesized(node)) { - write(node.text); - } - else { - writeTextOfNode(currentSourceFile, node); - } - } - function emitThis(node) { - if (resolver.getNodeCheckFlags(node) & 2) { - write("_this"); - } - else { - write("this"); - } - } - function emitSuper(node) { - if (languageVersion >= 2) { - write("super"); - } - else { - var flags = resolver.getNodeCheckFlags(node); - if (flags & 256) { - write("_super.prototype"); - } - else { - write("_super"); - } - } - } - function emitObjectBindingPattern(node) { - write("{ "); - var elements = node.elements; - emitList(elements, 0, elements.length, false, elements.hasTrailingComma); - write(" }"); - } - function emitArrayBindingPattern(node) { - write("["); - var elements = node.elements; - emitList(elements, 0, elements.length, false, elements.hasTrailingComma); - write("]"); - } - function emitBindingElement(node) { - if (node.propertyName) { - emit(node.propertyName); - write(": "); - } - if (node.dotDotDotToken) { - write("..."); - } - if (ts.isBindingPattern(node.name)) { - emit(node.name); - } - else { - emitModuleMemberName(node); - } - emitOptional(" = ", node.initializer); - } - function emitSpreadElementExpression(node) { - write("..."); - emit(node.expression); - } - function emitYieldExpression(node) { - write(ts.tokenToString(114)); - if (node.asteriskToken) { - write("*"); - } - if (node.expression) { - write(" "); - emit(node.expression); - } - } - function emitAwaitExpression(node) { - var needsParenthesis = needsParenthesisForAwaitExpressionAsYield(node); - if (needsParenthesis) { - write("("); - } - write(ts.tokenToString(114)); - write(" "); - emit(node.expression); - if (needsParenthesis) { - write(")"); - } - } - function needsParenthesisForAwaitExpressionAsYield(node) { - if (node.parent.kind === 181 && !ts.isAssignmentOperator(node.parent.operatorToken.kind)) { - return true; - } - else if (node.parent.kind === 182 && node.parent.condition === node) { - return true; - } - return false; - } - function needsParenthesisForPropertyAccessOrInvocation(node) { - switch (node.kind) { - case 69: - case 164: - case 166: - case 167: - case 168: - case 172: - return false; - } - return true; - } - function emitListWithSpread(elements, needsUniqueCopy, multiLine, trailingComma, useConcat) { - var pos = 0; - var group = 0; - var length = elements.length; - while (pos < length) { - if (group === 1 && useConcat) { - write(".concat("); - } - else if (group > 0) { - write(", "); - } - var e = elements[pos]; - if (e.kind === 185) { - e = e.expression; - emitParenthesizedIf(e, group === 0 && needsParenthesisForPropertyAccessOrInvocation(e)); - pos++; - if (pos === length && group === 0 && needsUniqueCopy && e.kind !== 164) { - write(".slice()"); - } - } - else { - var i = pos; - while (i < length && elements[i].kind !== 185) { - i++; - } - write("["); - if (multiLine) { - increaseIndent(); - } - emitList(elements, pos, i - pos, multiLine, trailingComma && i === length); - if (multiLine) { - decreaseIndent(); - } - write("]"); - pos = i; - } - group++; - } - if (group > 1) { - if (useConcat) { - write(")"); - } - } - } - function isSpreadElementExpression(node) { - return node.kind === 185; - } - function emitArrayLiteral(node) { - var elements = node.elements; - if (elements.length === 0) { - write("[]"); - } - else if (languageVersion >= 2 || !ts.forEach(elements, isSpreadElementExpression)) { - write("["); - emitLinePreservingList(node, node.elements, elements.hasTrailingComma, false); - write("]"); - } - else { - emitListWithSpread(elements, true, (node.flags & 2048) !== 0, elements.hasTrailingComma, true); - } - } - function emitObjectLiteralBody(node, numElements) { - if (numElements === 0) { - write("{}"); - return; - } - write("{"); - if (numElements > 0) { - var properties = node.properties; - if (numElements === properties.length) { - emitLinePreservingList(node, properties, languageVersion >= 1, true); - } - else { - var multiLine = (node.flags & 2048) !== 0; - if (!multiLine) { - write(" "); - } - else { - increaseIndent(); - } - emitList(properties, 0, numElements, multiLine, false); - if (!multiLine) { - write(" "); - } - else { - decreaseIndent(); - } - } - } - write("}"); - } - function emitDownlevelObjectLiteralWithComputedProperties(node, firstComputedPropertyIndex) { - var multiLine = (node.flags & 2048) !== 0; - var properties = node.properties; - write("("); - if (multiLine) { - increaseIndent(); - } - var tempVar = createAndRecordTempVariable(0); - emit(tempVar); - write(" = "); - emitObjectLiteralBody(node, firstComputedPropertyIndex); - for (var i = firstComputedPropertyIndex, n = properties.length; i < n; i++) { - writeComma(); - var property = properties[i]; - emitStart(property); - if (property.kind === 145 || property.kind === 146) { - var accessors = ts.getAllAccessorDeclarations(node.properties, property); - if (property !== accessors.firstAccessor) { - continue; - } - write("Object.defineProperty("); - emit(tempVar); - write(", "); - emitStart(node.name); - emitExpressionForPropertyName(property.name); - emitEnd(property.name); - write(", {"); - increaseIndent(); - if (accessors.getAccessor) { - writeLine(); - emitLeadingComments(accessors.getAccessor); - write("get: "); - emitStart(accessors.getAccessor); - write("function "); - emitSignatureAndBody(accessors.getAccessor); - emitEnd(accessors.getAccessor); - emitTrailingComments(accessors.getAccessor); - write(","); - } - if (accessors.setAccessor) { - writeLine(); - emitLeadingComments(accessors.setAccessor); - write("set: "); - emitStart(accessors.setAccessor); - write("function "); - emitSignatureAndBody(accessors.setAccessor); - emitEnd(accessors.setAccessor); - emitTrailingComments(accessors.setAccessor); - write(","); - } - writeLine(); - write("enumerable: true,"); - writeLine(); - write("configurable: true"); - decreaseIndent(); - writeLine(); - write("})"); - emitEnd(property); - } - else { - emitLeadingComments(property); - emitStart(property.name); - emit(tempVar); - emitMemberAccessForPropertyName(property.name); - emitEnd(property.name); - write(" = "); - if (property.kind === 245) { - emit(property.initializer); - } - else if (property.kind === 246) { - emitExpressionIdentifier(property.name); - } - else if (property.kind === 143) { - emitFunctionDeclaration(property); - } - else { - ts.Debug.fail("ObjectLiteralElement type not accounted for: " + property.kind); - } - } - emitEnd(property); - } - writeComma(); - emit(tempVar); - if (multiLine) { - decreaseIndent(); - writeLine(); - } - write(")"); - function writeComma() { - if (multiLine) { - write(","); - writeLine(); - } - else { - write(", "); - } - } - } - function emitObjectLiteral(node) { - var properties = node.properties; - if (languageVersion < 2) { - var numProperties = properties.length; - var numInitialNonComputedProperties = numProperties; - for (var i = 0, n = properties.length; i < n; i++) { - if (properties[i].name.kind === 136) { - numInitialNonComputedProperties = i; - break; - } - } - var hasComputedProperty = numInitialNonComputedProperties !== properties.length; - if (hasComputedProperty) { - emitDownlevelObjectLiteralWithComputedProperties(node, numInitialNonComputedProperties); - return; - } - } - emitObjectLiteralBody(node, properties.length); - } - function createBinaryExpression(left, operator, right, startsOnNewLine) { - var result = ts.createSynthesizedNode(181, startsOnNewLine); - result.operatorToken = ts.createSynthesizedNode(operator); - result.left = left; - result.right = right; - return result; - } - function createPropertyAccessExpression(expression, name) { - var result = ts.createSynthesizedNode(166); - result.expression = parenthesizeForAccess(expression); - result.dotToken = ts.createSynthesizedNode(21); - result.name = name; - return result; - } - function createElementAccessExpression(expression, argumentExpression) { - var result = ts.createSynthesizedNode(167); - result.expression = parenthesizeForAccess(expression); - result.argumentExpression = argumentExpression; - return result; - } - function parenthesizeForAccess(expr) { - while (expr.kind === 171 || expr.kind === 189) { - expr = expr.expression; - } - if (ts.isLeftHandSideExpression(expr) && - expr.kind !== 169 && - expr.kind !== 8) { - return expr; - } - var node = ts.createSynthesizedNode(172); - node.expression = expr; - return node; - } - function emitComputedPropertyName(node) { - write("["); - emitExpressionForPropertyName(node); - write("]"); - } - function emitMethod(node) { - if (languageVersion >= 2 && node.asteriskToken) { - write("*"); - } - emit(node.name); - if (languageVersion < 2) { - write(": function "); - } - emitSignatureAndBody(node); - } - function emitPropertyAssignment(node) { - emit(node.name); - write(": "); - emitTrailingCommentsOfPosition(node.initializer.pos); - emit(node.initializer); - } - function isNamespaceExportReference(node) { - var container = resolver.getReferencedExportContainer(node); - return container && container.kind !== 248; - } - function emitShorthandPropertyAssignment(node) { - writeTextOfNode(currentSourceFile, node.name); - if (languageVersion < 2 || isNamespaceExportReference(node.name)) { - write(": "); - emit(node.name); - } - if (languageVersion >= 2 && node.objectAssignmentInitializer) { - write(" = "); - emit(node.objectAssignmentInitializer); - } - } - function tryEmitConstantValue(node) { - var constantValue = tryGetConstEnumValue(node); - if (constantValue !== undefined) { - write(constantValue.toString()); - if (!compilerOptions.removeComments) { - var propertyName = node.kind === 166 ? ts.declarationNameToString(node.name) : ts.getTextOfNode(node.argumentExpression); - write(" /* " + propertyName + " */"); - } - return true; - } - return false; - } - function tryGetConstEnumValue(node) { - if (compilerOptions.isolatedModules) { - return undefined; - } - return node.kind === 166 || node.kind === 167 - ? resolver.getConstantValue(node) - : undefined; - } - function indentIfOnDifferentLines(parent, node1, node2, valueToWriteWhenNotIndenting) { - var realNodesAreOnDifferentLines = !ts.nodeIsSynthesized(parent) && !nodeEndIsOnSameLineAsNodeStart(node1, node2); - var synthesizedNodeIsOnDifferentLine = synthesizedNodeStartsOnNewLine(node2); - if (realNodesAreOnDifferentLines || synthesizedNodeIsOnDifferentLine) { - increaseIndent(); - writeLine(); - return true; - } - else { - if (valueToWriteWhenNotIndenting) { - write(valueToWriteWhenNotIndenting); - } - return false; - } - } - function emitPropertyAccess(node) { - if (tryEmitConstantValue(node)) { - return; - } - emit(node.expression); - var indentedBeforeDot = indentIfOnDifferentLines(node, node.expression, node.dotToken); - var shouldEmitSpace; - if (!indentedBeforeDot) { - if (node.expression.kind === 8) { - var text = ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, node.expression); - shouldEmitSpace = text.indexOf(ts.tokenToString(21)) < 0; - } - else { - var constantValue = tryGetConstEnumValue(node.expression); - shouldEmitSpace = isFinite(constantValue) && Math.floor(constantValue) === constantValue; - } - } - if (shouldEmitSpace) { - write(" ."); - } - else { - write("."); - } - var indentedAfterDot = indentIfOnDifferentLines(node, node.dotToken, node.name); - emit(node.name); - decreaseIndentIf(indentedBeforeDot, indentedAfterDot); - } - function emitQualifiedName(node) { - emit(node.left); - write("."); - emit(node.right); - } - function emitQualifiedNameAsExpression(node, useFallback) { - if (node.left.kind === 69) { - emitEntityNameAsExpression(node.left, useFallback); - } - else if (useFallback) { - var temp = createAndRecordTempVariable(0); - write("("); - emitNodeWithoutSourceMap(temp); - write(" = "); - emitEntityNameAsExpression(node.left, true); - write(") && "); - emitNodeWithoutSourceMap(temp); - } - else { - emitEntityNameAsExpression(node.left, false); - } - write("."); - emit(node.right); - } - function emitEntityNameAsExpression(node, useFallback) { - switch (node.kind) { - case 69: - if (useFallback) { - write("typeof "); - emitExpressionIdentifier(node); - write(" !== 'undefined' && "); - } - emitExpressionIdentifier(node); - break; - case 135: - emitQualifiedNameAsExpression(node, useFallback); - break; - } - } - function emitIndexedAccess(node) { - if (tryEmitConstantValue(node)) { - return; - } - emit(node.expression); - write("["); - emit(node.argumentExpression); - write("]"); - } - function hasSpreadElement(elements) { - return ts.forEach(elements, function (e) { return e.kind === 185; }); - } - function skipParentheses(node) { - while (node.kind === 172 || node.kind === 171 || node.kind === 189) { - node = node.expression; - } - return node; - } - function emitCallTarget(node) { - if (node.kind === 69 || node.kind === 97 || node.kind === 95) { - emit(node); - return node; - } - var temp = createAndRecordTempVariable(0); - write("("); - emit(temp); - write(" = "); - emit(node); - write(")"); - return temp; - } - function emitCallWithSpread(node) { - var target; - var expr = skipParentheses(node.expression); - if (expr.kind === 166) { - target = emitCallTarget(expr.expression); - write("."); - emit(expr.name); - } - else if (expr.kind === 167) { - target = emitCallTarget(expr.expression); - write("["); - emit(expr.argumentExpression); - write("]"); - } - else if (expr.kind === 95) { - target = expr; - write("_super"); - } - else { - emit(node.expression); - } - write(".apply("); - if (target) { - if (target.kind === 95) { - emitThis(target); - } - else { - emit(target); - } - } - else { - write("void 0"); - } - write(", "); - emitListWithSpread(node.arguments, false, false, false, true); - write(")"); - } - function emitCallExpression(node) { - if (languageVersion < 2 && hasSpreadElement(node.arguments)) { - emitCallWithSpread(node); - return; - } - var superCall = false; - if (node.expression.kind === 95) { - emitSuper(node.expression); - superCall = true; - } - else { - emit(node.expression); - superCall = node.expression.kind === 166 && node.expression.expression.kind === 95; - } - if (superCall && languageVersion < 2) { - write(".call("); - emitThis(node.expression); - if (node.arguments.length) { - write(", "); - emitCommaList(node.arguments); - } - write(")"); - } - else { - write("("); - emitCommaList(node.arguments); - write(")"); - } - } - function emitNewExpression(node) { - write("new "); - if (languageVersion === 1 && - node.arguments && - hasSpreadElement(node.arguments)) { - write("("); - var target = emitCallTarget(node.expression); - write(".bind.apply("); - emit(target); - write(", [void 0].concat("); - emitListWithSpread(node.arguments, false, false, false, false); - write(")))"); - write("()"); - } - else { - emit(node.expression); - if (node.arguments) { - write("("); - emitCommaList(node.arguments); - write(")"); - } - } - } - function emitTaggedTemplateExpression(node) { - if (languageVersion >= 2) { - emit(node.tag); - write(" "); - emit(node.template); - } - else { - emitDownlevelTaggedTemplate(node); - } - } - function emitParenExpression(node) { - if (!ts.nodeIsSynthesized(node) && node.parent.kind !== 174) { - if (node.expression.kind === 171 || node.expression.kind === 189) { - var operand = node.expression.expression; - while (operand.kind === 171 || operand.kind === 189) { - operand = operand.expression; - } - if (operand.kind !== 179 && - operand.kind !== 177 && - operand.kind !== 176 && - operand.kind !== 175 && - operand.kind !== 180 && - operand.kind !== 169 && - !(operand.kind === 168 && node.parent.kind === 169) && - !(operand.kind === 173 && node.parent.kind === 168) && - !(operand.kind === 8 && node.parent.kind === 166)) { - emit(operand); - return; - } - } - } - write("("); - emit(node.expression); - write(")"); - } - function emitDeleteExpression(node) { - write(ts.tokenToString(78)); - write(" "); - emit(node.expression); - } - function emitVoidExpression(node) { - write(ts.tokenToString(103)); - write(" "); - emit(node.expression); - } - function emitTypeOfExpression(node) { - write(ts.tokenToString(101)); - write(" "); - emit(node.expression); - } - function isNameOfExportedSourceLevelDeclarationInSystemExternalModule(node) { - if (!isCurrentFileSystemExternalModule() || node.kind !== 69 || ts.nodeIsSynthesized(node)) { - return false; - } - var isVariableDeclarationOrBindingElement = node.parent && (node.parent.kind === 211 || node.parent.kind === 163); - var targetDeclaration = isVariableDeclarationOrBindingElement - ? node.parent - : resolver.getReferencedValueDeclaration(node); - return isSourceFileLevelDeclarationInSystemJsModule(targetDeclaration, true); - } - function emitPrefixUnaryExpression(node) { - var exportChanged = isNameOfExportedSourceLevelDeclarationInSystemExternalModule(node.operand); - if (exportChanged) { - write(exportFunctionForFile + "(\""); - emitNodeWithoutSourceMap(node.operand); - write("\", "); - } - write(ts.tokenToString(node.operator)); - if (node.operand.kind === 179) { - var operand = node.operand; - if (node.operator === 35 && (operand.operator === 35 || operand.operator === 41)) { - write(" "); - } - else if (node.operator === 36 && (operand.operator === 36 || operand.operator === 42)) { - write(" "); - } - } - emit(node.operand); - if (exportChanged) { - write(")"); - } - } - function emitPostfixUnaryExpression(node) { - var exportChanged = isNameOfExportedSourceLevelDeclarationInSystemExternalModule(node.operand); - if (exportChanged) { - write("(" + exportFunctionForFile + "(\""); - emitNodeWithoutSourceMap(node.operand); - write("\", "); - write(ts.tokenToString(node.operator)); - emit(node.operand); - if (node.operator === 41) { - write(") - 1)"); - } - else { - write(") + 1)"); - } - } - else { - emit(node.operand); - write(ts.tokenToString(node.operator)); - } - } - function shouldHoistDeclarationInSystemJsModule(node) { - return isSourceFileLevelDeclarationInSystemJsModule(node, false); - } - function isSourceFileLevelDeclarationInSystemJsModule(node, isExported) { - if (!node || !isCurrentFileSystemExternalModule()) { - return false; - } - var current = node; - while (current) { - if (current.kind === 248) { - return !isExported || ((ts.getCombinedNodeFlags(node) & 1) !== 0); - } - else if (ts.isFunctionLike(current) || current.kind === 219) { - return false; - } - else { - current = current.parent; - } - } - } - function emitExponentiationOperator(node) { - var leftHandSideExpression = node.left; - if (node.operatorToken.kind === 60) { - var synthesizedLHS; - var shouldEmitParentheses = false; - if (ts.isElementAccessExpression(leftHandSideExpression)) { - shouldEmitParentheses = true; - write("("); - synthesizedLHS = ts.createSynthesizedNode(167, false); - var identifier = emitTempVariableAssignment(leftHandSideExpression.expression, false, false); - synthesizedLHS.expression = identifier; - if (leftHandSideExpression.argumentExpression.kind !== 8 && - leftHandSideExpression.argumentExpression.kind !== 9) { - var tempArgumentExpression = createAndRecordTempVariable(268435456); - synthesizedLHS.argumentExpression = tempArgumentExpression; - emitAssignment(tempArgumentExpression, leftHandSideExpression.argumentExpression, true); - } - else { - synthesizedLHS.argumentExpression = leftHandSideExpression.argumentExpression; - } - write(", "); - } - else if (ts.isPropertyAccessExpression(leftHandSideExpression)) { - shouldEmitParentheses = true; - write("("); - synthesizedLHS = ts.createSynthesizedNode(166, false); - var identifier = emitTempVariableAssignment(leftHandSideExpression.expression, false, false); - synthesizedLHS.expression = identifier; - synthesizedLHS.dotToken = leftHandSideExpression.dotToken; - synthesizedLHS.name = leftHandSideExpression.name; - write(", "); - } - emit(synthesizedLHS || leftHandSideExpression); - write(" = "); - write("Math.pow("); - emit(synthesizedLHS || leftHandSideExpression); - write(", "); - emit(node.right); - write(")"); - if (shouldEmitParentheses) { - write(")"); - } - } - else { - write("Math.pow("); - emit(leftHandSideExpression); - write(", "); - emit(node.right); - write(")"); - } - } - function emitBinaryExpression(node) { - if (languageVersion < 2 && node.operatorToken.kind === 56 && - (node.left.kind === 165 || node.left.kind === 164)) { - emitDestructuring(node, node.parent.kind === 195); - } - else { - var exportChanged = node.operatorToken.kind >= 56 && - node.operatorToken.kind <= 68 && - isNameOfExportedSourceLevelDeclarationInSystemExternalModule(node.left); - if (exportChanged) { - write(exportFunctionForFile + "(\""); - emitNodeWithoutSourceMap(node.left); - write("\", "); - } - if (node.operatorToken.kind === 38 || node.operatorToken.kind === 60) { - emitExponentiationOperator(node); - } - else { - emit(node.left); - var indentedBeforeOperator = indentIfOnDifferentLines(node, node.left, node.operatorToken, node.operatorToken.kind !== 24 ? " " : undefined); - write(ts.tokenToString(node.operatorToken.kind)); - var indentedAfterOperator = indentIfOnDifferentLines(node, node.operatorToken, node.right, " "); - emit(node.right); - decreaseIndentIf(indentedBeforeOperator, indentedAfterOperator); - } - if (exportChanged) { - write(")"); - } - } - } - function synthesizedNodeStartsOnNewLine(node) { - return ts.nodeIsSynthesized(node) && node.startsOnNewLine; - } - function emitConditionalExpression(node) { - emit(node.condition); - var indentedBeforeQuestion = indentIfOnDifferentLines(node, node.condition, node.questionToken, " "); - write("?"); - var indentedAfterQuestion = indentIfOnDifferentLines(node, node.questionToken, node.whenTrue, " "); - emit(node.whenTrue); - decreaseIndentIf(indentedBeforeQuestion, indentedAfterQuestion); - var indentedBeforeColon = indentIfOnDifferentLines(node, node.whenTrue, node.colonToken, " "); - write(":"); - var indentedAfterColon = indentIfOnDifferentLines(node, node.colonToken, node.whenFalse, " "); - emit(node.whenFalse); - decreaseIndentIf(indentedBeforeColon, indentedAfterColon); - } - function decreaseIndentIf(value1, value2) { - if (value1) { - decreaseIndent(); - } - if (value2) { - decreaseIndent(); - } - } - function isSingleLineEmptyBlock(node) { - if (node && node.kind === 192) { - var block = node; - return block.statements.length === 0 && nodeEndIsOnSameLineAsNodeStart(block, block); - } - } - function emitBlock(node) { - if (isSingleLineEmptyBlock(node)) { - emitToken(15, node.pos); - write(" "); - emitToken(16, node.statements.end); - return; - } - emitToken(15, node.pos); - increaseIndent(); - scopeEmitStart(node.parent); - if (node.kind === 219) { - ts.Debug.assert(node.parent.kind === 218); - emitCaptureThisForNodeIfNecessary(node.parent); - } - emitLines(node.statements); - if (node.kind === 219) { - emitTempDeclarations(true); - } - decreaseIndent(); - writeLine(); - emitToken(16, node.statements.end); - scopeEmitEnd(); - } - function emitEmbeddedStatement(node) { - if (node.kind === 192) { - write(" "); - emit(node); - } - else { - increaseIndent(); - writeLine(); - emit(node); - decreaseIndent(); - } - } - function emitExpressionStatement(node) { - emitParenthesizedIf(node.expression, node.expression.kind === 174); - write(";"); - } - function emitIfStatement(node) { - var endPos = emitToken(88, node.pos); - write(" "); - endPos = emitToken(17, endPos); - emit(node.expression); - emitToken(18, node.expression.end); - emitEmbeddedStatement(node.thenStatement); - if (node.elseStatement) { - writeLine(); - emitToken(80, node.thenStatement.end); - if (node.elseStatement.kind === 196) { - write(" "); - emit(node.elseStatement); - } - else { - emitEmbeddedStatement(node.elseStatement); - } - } - } - function emitDoStatement(node) { - write("do"); - emitEmbeddedStatement(node.statement); - if (node.statement.kind === 192) { - write(" "); - } - else { - writeLine(); - } - write("while ("); - emit(node.expression); - write(");"); - } - function emitWhileStatement(node) { - write("while ("); - emit(node.expression); - write(")"); - emitEmbeddedStatement(node.statement); - } - function tryEmitStartOfVariableDeclarationList(decl, startPos) { - if (shouldHoistVariable(decl, true)) { - return false; - } - var tokenKind = 102; - if (decl && languageVersion >= 2) { - if (ts.isLet(decl)) { - tokenKind = 108; - } - else if (ts.isConst(decl)) { - tokenKind = 74; - } - } - if (startPos !== undefined) { - emitToken(tokenKind, startPos); - write(" "); - } - else { - switch (tokenKind) { - case 102: - write("var "); - break; - case 108: - write("let "); - break; - case 74: - write("const "); - break; - } - } - return true; - } - function emitVariableDeclarationListSkippingUninitializedEntries(list) { - var started = false; - for (var _a = 0, _b = list.declarations; _a < _b.length; _a++) { - var decl = _b[_a]; - if (!decl.initializer) { - continue; - } - if (!started) { - started = true; - } - else { - write(", "); - } - emit(decl); - } - return started; - } - function emitForStatement(node) { - var endPos = emitToken(86, node.pos); - write(" "); - endPos = emitToken(17, endPos); - if (node.initializer && node.initializer.kind === 212) { - var variableDeclarationList = node.initializer; - var startIsEmitted = tryEmitStartOfVariableDeclarationList(variableDeclarationList, endPos); - if (startIsEmitted) { - emitCommaList(variableDeclarationList.declarations); - } - else { - emitVariableDeclarationListSkippingUninitializedEntries(variableDeclarationList); - } - } - else if (node.initializer) { - emit(node.initializer); - } - write(";"); - emitOptional(" ", node.condition); - write(";"); - emitOptional(" ", node.incrementor); - write(")"); - emitEmbeddedStatement(node.statement); - } - function emitForInOrForOfStatement(node) { - if (languageVersion < 2 && node.kind === 201) { - return emitDownLevelForOfStatement(node); - } - var endPos = emitToken(86, node.pos); - write(" "); - endPos = emitToken(17, endPos); - if (node.initializer.kind === 212) { - var variableDeclarationList = node.initializer; - if (variableDeclarationList.declarations.length >= 1) { - tryEmitStartOfVariableDeclarationList(variableDeclarationList, endPos); - emit(variableDeclarationList.declarations[0]); - } - } - else { - emit(node.initializer); - } - if (node.kind === 200) { - write(" in "); - } - else { - write(" of "); - } - emit(node.expression); - emitToken(18, node.expression.end); - emitEmbeddedStatement(node.statement); - } - function emitDownLevelForOfStatement(node) { - var endPos = emitToken(86, node.pos); - write(" "); - endPos = emitToken(17, endPos); - var rhsIsIdentifier = node.expression.kind === 69; - var counter = createTempVariable(268435456); - var rhsReference = rhsIsIdentifier ? node.expression : createTempVariable(0); - emitStart(node.expression); - write("var "); - emitNodeWithoutSourceMap(counter); - write(" = 0"); - emitEnd(node.expression); - if (!rhsIsIdentifier) { - write(", "); - emitStart(node.expression); - emitNodeWithoutSourceMap(rhsReference); - write(" = "); - emitNodeWithoutSourceMap(node.expression); - emitEnd(node.expression); - } - write("; "); - emitStart(node.initializer); - emitNodeWithoutSourceMap(counter); - write(" < "); - emitNodeWithCommentsAndWithoutSourcemap(rhsReference); - write(".length"); - emitEnd(node.initializer); - write("; "); - emitStart(node.initializer); - emitNodeWithoutSourceMap(counter); - write("++"); - emitEnd(node.initializer); - emitToken(18, node.expression.end); - write(" {"); - writeLine(); - increaseIndent(); - var rhsIterationValue = createElementAccessExpression(rhsReference, counter); - emitStart(node.initializer); - if (node.initializer.kind === 212) { - write("var "); - var variableDeclarationList = node.initializer; - if (variableDeclarationList.declarations.length > 0) { - var declaration = variableDeclarationList.declarations[0]; - if (ts.isBindingPattern(declaration.name)) { - emitDestructuring(declaration, false, rhsIterationValue); - } - else { - emitNodeWithCommentsAndWithoutSourcemap(declaration); - write(" = "); - emitNodeWithoutSourceMap(rhsIterationValue); - } - } - else { - emitNodeWithoutSourceMap(createTempVariable(0)); - write(" = "); - emitNodeWithoutSourceMap(rhsIterationValue); - } - } - else { - var assignmentExpression = createBinaryExpression(node.initializer, 56, rhsIterationValue, false); - if (node.initializer.kind === 164 || node.initializer.kind === 165) { - emitDestructuring(assignmentExpression, true, undefined); - } - else { - emitNodeWithCommentsAndWithoutSourcemap(assignmentExpression); - } - } - emitEnd(node.initializer); - write(";"); - if (node.statement.kind === 192) { - emitLines(node.statement.statements); - } - else { - writeLine(); - emit(node.statement); - } - writeLine(); - decreaseIndent(); - write("}"); - } - function emitBreakOrContinueStatement(node) { - emitToken(node.kind === 203 ? 70 : 75, node.pos); - emitOptional(" ", node.label); - write(";"); - } - function emitReturnStatement(node) { - emitToken(94, node.pos); - emitOptional(" ", node.expression); - write(";"); - } - function emitWithStatement(node) { - write("with ("); - emit(node.expression); - write(")"); - emitEmbeddedStatement(node.statement); - } - function emitSwitchStatement(node) { - var endPos = emitToken(96, node.pos); - write(" "); - emitToken(17, endPos); - emit(node.expression); - endPos = emitToken(18, node.expression.end); - write(" "); - emitCaseBlock(node.caseBlock, endPos); - } - function emitCaseBlock(node, startPos) { - emitToken(15, startPos); - increaseIndent(); - emitLines(node.clauses); - decreaseIndent(); - writeLine(); - emitToken(16, node.clauses.end); - } - function nodeStartPositionsAreOnSameLine(node1, node2) { - return ts.getLineOfLocalPosition(currentSourceFile, ts.skipTrivia(currentSourceFile.text, node1.pos)) === - ts.getLineOfLocalPosition(currentSourceFile, ts.skipTrivia(currentSourceFile.text, node2.pos)); - } - function nodeEndPositionsAreOnSameLine(node1, node2) { - return ts.getLineOfLocalPosition(currentSourceFile, node1.end) === - ts.getLineOfLocalPosition(currentSourceFile, node2.end); - } - function nodeEndIsOnSameLineAsNodeStart(node1, node2) { - return ts.getLineOfLocalPosition(currentSourceFile, node1.end) === - ts.getLineOfLocalPosition(currentSourceFile, ts.skipTrivia(currentSourceFile.text, node2.pos)); - } - function emitCaseOrDefaultClause(node) { - if (node.kind === 241) { - write("case "); - emit(node.expression); - write(":"); - } - else { - write("default:"); - } - if (node.statements.length === 1 && nodeStartPositionsAreOnSameLine(node, node.statements[0])) { - write(" "); - emit(node.statements[0]); - } - else { - increaseIndent(); - emitLines(node.statements); - decreaseIndent(); - } - } - function emitThrowStatement(node) { - write("throw "); - emit(node.expression); - write(";"); - } - function emitTryStatement(node) { - write("try "); - emit(node.tryBlock); - emit(node.catchClause); - if (node.finallyBlock) { - writeLine(); - write("finally "); - emit(node.finallyBlock); - } - } - function emitCatchClause(node) { - writeLine(); - var endPos = emitToken(72, node.pos); - write(" "); - emitToken(17, endPos); - emit(node.variableDeclaration); - emitToken(18, node.variableDeclaration ? node.variableDeclaration.end : endPos); - write(" "); - emitBlock(node.block); - } - function emitDebuggerStatement(node) { - emitToken(76, node.pos); - write(";"); - } - function emitLabelledStatement(node) { - emit(node.label); - write(": "); - emit(node.statement); - } - function getContainingModule(node) { - do { - node = node.parent; - } while (node && node.kind !== 218); - return node; - } - function emitContainingModuleName(node) { - var container = getContainingModule(node); - write(container ? getGeneratedNameForNode(container) : "exports"); - } - function emitModuleMemberName(node) { - emitStart(node.name); - if (ts.getCombinedNodeFlags(node) & 1) { - var container = getContainingModule(node); - if (container) { - write(getGeneratedNameForNode(container)); - write("."); - } - else if (modulekind !== 5 && modulekind !== 4) { - write("exports."); - } - } - emitNodeWithCommentsAndWithoutSourcemap(node.name); - emitEnd(node.name); - } - function createVoidZero() { - var zero = ts.createSynthesizedNode(8); - zero.text = "0"; - var result = ts.createSynthesizedNode(177); - result.expression = zero; - return result; - } - function emitEs6ExportDefaultCompat(node) { - if (node.parent.kind === 248) { - ts.Debug.assert(!!(node.flags & 1024) || node.kind === 227); - if (modulekind === 1 || modulekind === 2 || modulekind === 3) { - if (!currentSourceFile.symbol.exports["___esModule"]) { - if (languageVersion === 1) { - write("Object.defineProperty(exports, \"__esModule\", { value: true });"); - writeLine(); - } - else if (languageVersion === 0) { - write("exports.__esModule = true;"); - writeLine(); - } - } - } - } - } - function emitExportMemberAssignment(node) { - if (node.flags & 1) { - writeLine(); - emitStart(node); - if (modulekind === 4 && node.parent === currentSourceFile) { - write(exportFunctionForFile + "(\""); - if (node.flags & 1024) { - write("default"); - } - else { - emitNodeWithCommentsAndWithoutSourcemap(node.name); - } - write("\", "); - emitDeclarationName(node); - write(")"); - } - else { - if (node.flags & 1024) { - emitEs6ExportDefaultCompat(node); - if (languageVersion === 0) { - write("exports[\"default\"]"); - } - else { - write("exports.default"); - } - } - else { - emitModuleMemberName(node); - } - write(" = "); - emitDeclarationName(node); - } - emitEnd(node); - write(";"); - } - } - function emitExportMemberAssignments(name) { - if (modulekind === 4) { - return; - } - if (!exportEquals && exportSpecifiers && ts.hasProperty(exportSpecifiers, name.text)) { - for (var _a = 0, _b = exportSpecifiers[name.text]; _a < _b.length; _a++) { - var specifier = _b[_a]; - writeLine(); - emitStart(specifier.name); - emitContainingModuleName(specifier); - write("."); - emitNodeWithCommentsAndWithoutSourcemap(specifier.name); - emitEnd(specifier.name); - write(" = "); - emitExpressionIdentifier(name); - write(";"); - } - } - } - function emitExportSpecifierInSystemModule(specifier) { - ts.Debug.assert(modulekind === 4); - if (!resolver.getReferencedValueDeclaration(specifier.propertyName || specifier.name) && !resolver.isValueAliasDeclaration(specifier)) { - return; - } - writeLine(); - emitStart(specifier.name); - write(exportFunctionForFile + "(\""); - emitNodeWithCommentsAndWithoutSourcemap(specifier.name); - write("\", "); - emitExpressionIdentifier(specifier.propertyName || specifier.name); - write(")"); - emitEnd(specifier.name); - write(";"); - } - function emitAssignment(name, value, shouldEmitCommaBeforeAssignment) { - if (shouldEmitCommaBeforeAssignment) { - write(", "); - } - var exportChanged = isNameOfExportedSourceLevelDeclarationInSystemExternalModule(name); - if (exportChanged) { - write(exportFunctionForFile + "(\""); - emitNodeWithCommentsAndWithoutSourcemap(name); - write("\", "); - } - var isVariableDeclarationOrBindingElement = name.parent && (name.parent.kind === 211 || name.parent.kind === 163); - if (isVariableDeclarationOrBindingElement) { - emitModuleMemberName(name.parent); - } - else { - emit(name); - } - write(" = "); - emit(value); - if (exportChanged) { - write(")"); - } - } - function emitTempVariableAssignment(expression, canDefineTempVariablesInPlace, shouldEmitCommaBeforeAssignment) { - var identifier = createTempVariable(0); - if (!canDefineTempVariablesInPlace) { - recordTempDeclaration(identifier); - } - emitAssignment(identifier, expression, shouldEmitCommaBeforeAssignment); - return identifier; - } - function emitDestructuring(root, isAssignmentExpressionStatement, value) { - var emitCount = 0; - var canDefineTempVariablesInPlace = false; - if (root.kind === 211) { - var isExported = ts.getCombinedNodeFlags(root) & 1; - var isSourceLevelForSystemModuleKind = shouldHoistDeclarationInSystemJsModule(root); - canDefineTempVariablesInPlace = !isExported && !isSourceLevelForSystemModuleKind; - } - else if (root.kind === 138) { - canDefineTempVariablesInPlace = true; - } - if (root.kind === 181) { - emitAssignmentExpression(root); - } - else { - ts.Debug.assert(!isAssignmentExpressionStatement); - emitBindingElement(root, value); - } - function ensureIdentifier(expr, reuseIdentifierExpressions) { - if (expr.kind === 69 && reuseIdentifierExpressions) { - return expr; - } - var identifier = emitTempVariableAssignment(expr, canDefineTempVariablesInPlace, emitCount > 0); - emitCount++; - return identifier; - } - function createDefaultValueCheck(value, defaultValue) { - value = ensureIdentifier(value, true); - var equals = ts.createSynthesizedNode(181); - equals.left = value; - equals.operatorToken = ts.createSynthesizedNode(32); - equals.right = createVoidZero(); - return createConditionalExpression(equals, defaultValue, value); - } - function createConditionalExpression(condition, whenTrue, whenFalse) { - var cond = ts.createSynthesizedNode(182); - cond.condition = condition; - cond.questionToken = ts.createSynthesizedNode(53); - cond.whenTrue = whenTrue; - cond.colonToken = ts.createSynthesizedNode(54); - cond.whenFalse = whenFalse; - return cond; - } - function createNumericLiteral(value) { - var node = ts.createSynthesizedNode(8); - node.text = "" + value; - return node; - } - function createPropertyAccessForDestructuringProperty(object, propName) { - var syntheticName = ts.createSynthesizedNode(propName.kind); - syntheticName.text = propName.text; - if (syntheticName.kind !== 69) { - return createElementAccessExpression(object, syntheticName); - } - return createPropertyAccessExpression(object, syntheticName); - } - function createSliceCall(value, sliceIndex) { - var call = ts.createSynthesizedNode(168); - var sliceIdentifier = ts.createSynthesizedNode(69); - sliceIdentifier.text = "slice"; - call.expression = createPropertyAccessExpression(value, sliceIdentifier); - call.arguments = ts.createSynthesizedNodeArray(); - call.arguments[0] = createNumericLiteral(sliceIndex); - return call; - } - function emitObjectLiteralAssignment(target, value) { - var properties = target.properties; - if (properties.length !== 1) { - value = ensureIdentifier(value, true); - } - for (var _a = 0; _a < properties.length; _a++) { - var p = properties[_a]; - if (p.kind === 245 || p.kind === 246) { - var propName = p.name; - var target_1 = p.kind === 246 ? p : p.initializer || propName; - emitDestructuringAssignment(target_1, createPropertyAccessForDestructuringProperty(value, propName)); - } - } - } - function emitArrayLiteralAssignment(target, value) { - var elements = target.elements; - if (elements.length !== 1) { - value = ensureIdentifier(value, true); - } - for (var i = 0; i < elements.length; i++) { - var e = elements[i]; - if (e.kind !== 187) { - if (e.kind !== 185) { - emitDestructuringAssignment(e, createElementAccessExpression(value, createNumericLiteral(i))); - } - else if (i === elements.length - 1) { - emitDestructuringAssignment(e.expression, createSliceCall(value, i)); - } - } - } - } - function emitDestructuringAssignment(target, value) { - if (target.kind === 246) { - if (target.objectAssignmentInitializer) { - value = createDefaultValueCheck(value, target.objectAssignmentInitializer); - } - target = target.name; - } - else if (target.kind === 181 && target.operatorToken.kind === 56) { - value = createDefaultValueCheck(value, target.right); - target = target.left; - } - if (target.kind === 165) { - emitObjectLiteralAssignment(target, value); - } - else if (target.kind === 164) { - emitArrayLiteralAssignment(target, value); - } - else { - emitAssignment(target, value, emitCount > 0); - emitCount++; - } - } - function emitAssignmentExpression(root) { - var target = root.left; - var value = root.right; - if (ts.isEmptyObjectLiteralOrArrayLiteral(target)) { - emit(value); - } - else if (isAssignmentExpressionStatement) { - emitDestructuringAssignment(target, value); - } - else { - if (root.parent.kind !== 172) { - write("("); - } - value = ensureIdentifier(value, true); - emitDestructuringAssignment(target, value); - write(", "); - emit(value); - if (root.parent.kind !== 172) { - write(")"); - } - } - } - function emitBindingElement(target, value) { - if (target.initializer) { - value = value ? createDefaultValueCheck(value, target.initializer) : target.initializer; - } - else if (!value) { - value = createVoidZero(); - } - if (ts.isBindingPattern(target.name)) { - var pattern = target.name; - var elements = pattern.elements; - var numElements = elements.length; - if (numElements !== 1) { - value = ensureIdentifier(value, numElements !== 0); - } - for (var i = 0; i < numElements; i++) { - var element = elements[i]; - if (pattern.kind === 161) { - var propName = element.propertyName || element.name; - emitBindingElement(element, createPropertyAccessForDestructuringProperty(value, propName)); - } - else if (element.kind !== 187) { - if (!element.dotDotDotToken) { - emitBindingElement(element, createElementAccessExpression(value, createNumericLiteral(i))); - } - else if (i === numElements - 1) { - emitBindingElement(element, createSliceCall(value, i)); - } - } - } - } - else { - emitAssignment(target.name, value, emitCount > 0); - emitCount++; - } - } - } - function emitVariableDeclaration(node) { - if (ts.isBindingPattern(node.name)) { - if (languageVersion < 2) { - emitDestructuring(node, false); - } - else { - emit(node.name); - emitOptional(" = ", node.initializer); - } - } - else { - var initializer = node.initializer; - if (!initializer && languageVersion < 2) { - var isUninitializedLet = (resolver.getNodeCheckFlags(node) & 16384) && - (getCombinedFlagsForIdentifier(node.name) & 16384); - if (isUninitializedLet && - node.parent.parent.kind !== 200 && - node.parent.parent.kind !== 201) { - initializer = createVoidZero(); - } - } - var exportChanged = isNameOfExportedSourceLevelDeclarationInSystemExternalModule(node.name); - if (exportChanged) { - write(exportFunctionForFile + "(\""); - emitNodeWithCommentsAndWithoutSourcemap(node.name); - write("\", "); - } - emitModuleMemberName(node); - emitOptional(" = ", initializer); - if (exportChanged) { - write(")"); - } - } - } - function emitExportVariableAssignments(node) { - if (node.kind === 187) { - return; - } - var name = node.name; - if (name.kind === 69) { - emitExportMemberAssignments(name); - } - else if (ts.isBindingPattern(name)) { - ts.forEach(name.elements, emitExportVariableAssignments); - } - } - function getCombinedFlagsForIdentifier(node) { - if (!node.parent || (node.parent.kind !== 211 && node.parent.kind !== 163)) { - return 0; - } - return ts.getCombinedNodeFlags(node.parent); - } - function isES6ExportedDeclaration(node) { - return !!(node.flags & 1) && - modulekind === 5 && - node.parent.kind === 248; - } - function emitVariableStatement(node) { - var startIsEmitted = false; - if (node.flags & 1) { - if (isES6ExportedDeclaration(node)) { - write("export "); - startIsEmitted = tryEmitStartOfVariableDeclarationList(node.declarationList); - } - } - else { - startIsEmitted = tryEmitStartOfVariableDeclarationList(node.declarationList); - } - if (startIsEmitted) { - emitCommaList(node.declarationList.declarations); - write(";"); - } - else { - var atLeastOneItem = emitVariableDeclarationListSkippingUninitializedEntries(node.declarationList); - if (atLeastOneItem) { - write(";"); - } - } - if (modulekind !== 5 && node.parent === currentSourceFile) { - ts.forEach(node.declarationList.declarations, emitExportVariableAssignments); - } - } - function shouldEmitLeadingAndTrailingCommentsForVariableStatement(node) { - if (!(node.flags & 1)) { - return true; - } - if (isES6ExportedDeclaration(node)) { - return true; - } - for (var _a = 0, _b = node.declarationList.declarations; _a < _b.length; _a++) { - var declaration = _b[_a]; - if (declaration.initializer) { - return true; - } - } - return false; - } - function emitParameter(node) { - if (languageVersion < 2) { - if (ts.isBindingPattern(node.name)) { - var name_24 = createTempVariable(0); - if (!tempParameters) { - tempParameters = []; - } - tempParameters.push(name_24); - emit(name_24); - } - else { - emit(node.name); - } - } - else { - if (node.dotDotDotToken) { - write("..."); - } - emit(node.name); - emitOptional(" = ", node.initializer); - } - } - function emitDefaultValueAssignments(node) { - if (languageVersion < 2) { - var tempIndex = 0; - ts.forEach(node.parameters, function (parameter) { - if (parameter.dotDotDotToken) { - return; - } - var paramName = parameter.name, initializer = parameter.initializer; - if (ts.isBindingPattern(paramName)) { - var hasBindingElements = paramName.elements.length > 0; - if (hasBindingElements || initializer) { - writeLine(); - write("var "); - if (hasBindingElements) { - emitDestructuring(parameter, false, tempParameters[tempIndex]); - } - else { - emit(tempParameters[tempIndex]); - write(" = "); - emit(initializer); - } - write(";"); - tempIndex++; - } - } - else if (initializer) { - writeLine(); - emitStart(parameter); - write("if ("); - emitNodeWithoutSourceMap(paramName); - write(" === void 0)"); - emitEnd(parameter); - write(" { "); - emitStart(parameter); - emitNodeWithCommentsAndWithoutSourcemap(paramName); - write(" = "); - emitNodeWithCommentsAndWithoutSourcemap(initializer); - emitEnd(parameter); - write("; }"); - } - }); - } - } - function emitRestParameter(node) { - if (languageVersion < 2 && ts.hasRestParameter(node)) { - var restIndex = node.parameters.length - 1; - var restParam = node.parameters[restIndex]; - if (ts.isBindingPattern(restParam.name)) { - return; - } - var tempName = createTempVariable(268435456).text; - writeLine(); - emitLeadingComments(restParam); - emitStart(restParam); - write("var "); - emitNodeWithCommentsAndWithoutSourcemap(restParam.name); - write(" = [];"); - emitEnd(restParam); - emitTrailingComments(restParam); - writeLine(); - write("for ("); - emitStart(restParam); - write("var " + tempName + " = " + restIndex + ";"); - emitEnd(restParam); - write(" "); - emitStart(restParam); - write(tempName + " < arguments.length;"); - emitEnd(restParam); - write(" "); - emitStart(restParam); - write(tempName + "++"); - emitEnd(restParam); - write(") {"); - increaseIndent(); - writeLine(); - emitStart(restParam); - emitNodeWithCommentsAndWithoutSourcemap(restParam.name); - write("[" + tempName + " - " + restIndex + "] = arguments[" + tempName + "];"); - emitEnd(restParam); - decreaseIndent(); - writeLine(); - write("}"); - } - } - function emitAccessor(node) { - write(node.kind === 145 ? "get " : "set "); - emit(node.name); - emitSignatureAndBody(node); - } - function shouldEmitAsArrowFunction(node) { - return node.kind === 174 && languageVersion >= 2; - } - function emitDeclarationName(node) { - if (node.name) { - emitNodeWithCommentsAndWithoutSourcemap(node.name); - } - else { - write(getGeneratedNameForNode(node)); - } - } - function shouldEmitFunctionName(node) { - if (node.kind === 173) { - return !!node.name; - } - if (node.kind === 213) { - return !!node.name || languageVersion < 2; - } - } - function emitFunctionDeclaration(node) { - if (ts.nodeIsMissing(node.body)) { - return emitCommentsOnNotEmittedNode(node); - } - if (node.kind !== 143 && node.kind !== 142 && - node.parent && node.parent.kind !== 245 && - node.parent.kind !== 168) { - emitLeadingComments(node); - } - emitStart(node); - if (!shouldEmitAsArrowFunction(node)) { - if (isES6ExportedDeclaration(node)) { - write("export "); - if (node.flags & 1024) { - write("default "); - } - } - write("function"); - if (languageVersion >= 2 && node.asteriskToken) { - write("*"); - } - write(" "); - } - if (shouldEmitFunctionName(node)) { - emitDeclarationName(node); - } - emitSignatureAndBody(node); - if (modulekind !== 5 && node.kind === 213 && node.parent === currentSourceFile && node.name) { - emitExportMemberAssignments(node.name); - } - emitEnd(node); - if (node.kind !== 143 && node.kind !== 142) { - emitTrailingComments(node); - } - } - function emitCaptureThisForNodeIfNecessary(node) { - if (resolver.getNodeCheckFlags(node) & 4) { - writeLine(); - emitStart(node); - write("var _this = this;"); - emitEnd(node); - } - } - function emitSignatureParameters(node) { - increaseIndent(); - write("("); - if (node) { - var parameters = node.parameters; - var omitCount = languageVersion < 2 && ts.hasRestParameter(node) ? 1 : 0; - emitList(parameters, 0, parameters.length - omitCount, false, false); - } - write(")"); - decreaseIndent(); - } - function emitSignatureParametersForArrow(node) { - if (node.parameters.length === 1 && node.pos === node.parameters[0].pos) { - emit(node.parameters[0]); - return; - } - emitSignatureParameters(node); - } - function emitAsyncFunctionBodyForES6(node) { - var promiseConstructor = ts.getEntityNameFromTypeNode(node.type); - var isArrowFunction = node.kind === 174; - var hasLexicalArguments = (resolver.getNodeCheckFlags(node) & 4096) !== 0; - var args; - if (!isArrowFunction) { - write(" {"); - increaseIndent(); - writeLine(); - write("return"); - } - write(" __awaiter(this"); - if (hasLexicalArguments) { - write(", arguments"); - } - else { - write(", void 0"); - } - if (promiseConstructor) { - write(", "); - emitNodeWithoutSourceMap(promiseConstructor); - } - else { - write(", Promise"); - } - if (hasLexicalArguments) { - write(", function* (_arguments)"); - } - else { - write(", function* ()"); - } - emitFunctionBody(node); - write(")"); - if (!isArrowFunction) { - write(";"); - decreaseIndent(); - writeLine(); - write("}"); - } - } - function emitFunctionBody(node) { - if (!node.body) { - write(" { }"); - } - else { - if (node.body.kind === 192) { - emitBlockFunctionBody(node, node.body); - } - else { - emitExpressionFunctionBody(node, node.body); - } - } - } - function emitSignatureAndBody(node) { - var saveTempFlags = tempFlags; - var saveTempVariables = tempVariables; - var saveTempParameters = tempParameters; - tempFlags = 0; - tempVariables = undefined; - tempParameters = undefined; - if (shouldEmitAsArrowFunction(node)) { - emitSignatureParametersForArrow(node); - write(" =>"); - } - else { - emitSignatureParameters(node); - } - var isAsync = ts.isAsyncFunctionLike(node); - if (isAsync && languageVersion === 2) { - emitAsyncFunctionBodyForES6(node); - } - else { - emitFunctionBody(node); - } - if (!isES6ExportedDeclaration(node)) { - emitExportMemberAssignment(node); - } - tempFlags = saveTempFlags; - tempVariables = saveTempVariables; - tempParameters = saveTempParameters; - } - function emitFunctionBodyPreamble(node) { - emitCaptureThisForNodeIfNecessary(node); - emitDefaultValueAssignments(node); - emitRestParameter(node); - } - function emitExpressionFunctionBody(node, body) { - if (languageVersion < 2 || node.flags & 512) { - emitDownLevelExpressionFunctionBody(node, body); - return; - } - write(" "); - var current = body; - while (current.kind === 171) { - current = current.expression; - } - emitParenthesizedIf(body, current.kind === 165); - } - function emitDownLevelExpressionFunctionBody(node, body) { - write(" {"); - scopeEmitStart(node); - increaseIndent(); - var outPos = writer.getTextPos(); - emitDetachedComments(node.body); - emitFunctionBodyPreamble(node); - var preambleEmitted = writer.getTextPos() !== outPos; - decreaseIndent(); - if (!preambleEmitted && nodeStartPositionsAreOnSameLine(node, body)) { - write(" "); - emitStart(body); - write("return "); - emit(body); - emitEnd(body); - write(";"); - emitTempDeclarations(false); - write(" "); - } - else { - increaseIndent(); - writeLine(); - emitLeadingComments(node.body); - write("return "); - emit(body); - write(";"); - emitTrailingComments(node.body); - emitTempDeclarations(true); - decreaseIndent(); - writeLine(); - } - emitStart(node.body); - write("}"); - emitEnd(node.body); - scopeEmitEnd(); - } - function emitBlockFunctionBody(node, body) { - write(" {"); - scopeEmitStart(node); - var initialTextPos = writer.getTextPos(); - increaseIndent(); - emitDetachedComments(body.statements); - var startIndex = emitDirectivePrologues(body.statements, true); - emitFunctionBodyPreamble(node); - decreaseIndent(); - var preambleEmitted = writer.getTextPos() !== initialTextPos; - if (!preambleEmitted && nodeEndIsOnSameLineAsNodeStart(body, body)) { - for (var _a = 0, _b = body.statements; _a < _b.length; _a++) { - var statement = _b[_a]; - write(" "); - emit(statement); - } - emitTempDeclarations(false); - write(" "); - emitLeadingCommentsOfPosition(body.statements.end); - } - else { - increaseIndent(); - emitLinesStartingAt(body.statements, startIndex); - emitTempDeclarations(true); - writeLine(); - emitLeadingCommentsOfPosition(body.statements.end); - decreaseIndent(); - } - emitToken(16, body.statements.end); - scopeEmitEnd(); - } - function findInitialSuperCall(ctor) { - if (ctor.body) { - var statement = ctor.body.statements[0]; - if (statement && statement.kind === 195) { - var expr = statement.expression; - if (expr && expr.kind === 168) { - var func = expr.expression; - if (func && func.kind === 95) { - return statement; - } - } - } - } - } - function emitParameterPropertyAssignments(node) { - ts.forEach(node.parameters, function (param) { - if (param.flags & 112) { - writeLine(); - emitStart(param); - emitStart(param.name); - write("this."); - emitNodeWithoutSourceMap(param.name); - emitEnd(param.name); - write(" = "); - emit(param.name); - write(";"); - emitEnd(param); - } - }); - } - function emitMemberAccessForPropertyName(memberName) { - if (memberName.kind === 9 || memberName.kind === 8) { - write("["); - emitNodeWithCommentsAndWithoutSourcemap(memberName); - write("]"); - } - else if (memberName.kind === 136) { - emitComputedPropertyName(memberName); - } - else { - write("."); - emitNodeWithCommentsAndWithoutSourcemap(memberName); - } - } - function getInitializedProperties(node, isStatic) { - var properties = []; - for (var _a = 0, _b = node.members; _a < _b.length; _a++) { - var member = _b[_a]; - if (member.kind === 141 && isStatic === ((member.flags & 128) !== 0) && member.initializer) { - properties.push(member); - } - } - return properties; - } - function emitPropertyDeclarations(node, properties) { - for (var _a = 0; _a < properties.length; _a++) { - var property = properties[_a]; - emitPropertyDeclaration(node, property); - } - } - function emitPropertyDeclaration(node, property, receiver, isExpression) { - writeLine(); - emitLeadingComments(property); - emitStart(property); - emitStart(property.name); - if (receiver) { - emit(receiver); - } - else { - if (property.flags & 128) { - emitDeclarationName(node); - } - else { - write("this"); - } - } - emitMemberAccessForPropertyName(property.name); - emitEnd(property.name); - write(" = "); - emit(property.initializer); - if (!isExpression) { - write(";"); - } - emitEnd(property); - emitTrailingComments(property); - } - function emitMemberFunctionsForES5AndLower(node) { - ts.forEach(node.members, function (member) { - if (member.kind === 191) { - writeLine(); - write(";"); - } - else if (member.kind === 143 || node.kind === 142) { - if (!member.body) { - return emitCommentsOnNotEmittedNode(member); - } - writeLine(); - emitLeadingComments(member); - emitStart(member); - emitStart(member.name); - emitClassMemberPrefix(node, member); - emitMemberAccessForPropertyName(member.name); - emitEnd(member.name); - write(" = "); - emitFunctionDeclaration(member); - emitEnd(member); - write(";"); - emitTrailingComments(member); - } - else if (member.kind === 145 || member.kind === 146) { - var accessors = ts.getAllAccessorDeclarations(node.members, member); - if (member === accessors.firstAccessor) { - writeLine(); - emitStart(member); - write("Object.defineProperty("); - emitStart(member.name); - emitClassMemberPrefix(node, member); - write(", "); - emitExpressionForPropertyName(member.name); - emitEnd(member.name); - write(", {"); - increaseIndent(); - if (accessors.getAccessor) { - writeLine(); - emitLeadingComments(accessors.getAccessor); - write("get: "); - emitStart(accessors.getAccessor); - write("function "); - emitSignatureAndBody(accessors.getAccessor); - emitEnd(accessors.getAccessor); - emitTrailingComments(accessors.getAccessor); - write(","); - } - if (accessors.setAccessor) { - writeLine(); - emitLeadingComments(accessors.setAccessor); - write("set: "); - emitStart(accessors.setAccessor); - write("function "); - emitSignatureAndBody(accessors.setAccessor); - emitEnd(accessors.setAccessor); - emitTrailingComments(accessors.setAccessor); - write(","); - } - writeLine(); - write("enumerable: true,"); - writeLine(); - write("configurable: true"); - decreaseIndent(); - writeLine(); - write("});"); - emitEnd(member); - } - } - }); - } - function emitMemberFunctionsForES6AndHigher(node) { - for (var _a = 0, _b = node.members; _a < _b.length; _a++) { - var member = _b[_a]; - if ((member.kind === 143 || node.kind === 142) && !member.body) { - emitCommentsOnNotEmittedNode(member); - } - else if (member.kind === 143 || - member.kind === 145 || - member.kind === 146) { - writeLine(); - emitLeadingComments(member); - emitStart(member); - if (member.flags & 128) { - write("static "); - } - if (member.kind === 145) { - write("get "); - } - else if (member.kind === 146) { - write("set "); - } - if (member.asteriskToken) { - write("*"); - } - emit(member.name); - emitSignatureAndBody(member); - emitEnd(member); - emitTrailingComments(member); - } - else if (member.kind === 191) { - writeLine(); - write(";"); - } - } - } - function emitConstructor(node, baseTypeElement) { - var saveTempFlags = tempFlags; - var saveTempVariables = tempVariables; - var saveTempParameters = tempParameters; - tempFlags = 0; - tempVariables = undefined; - tempParameters = undefined; - emitConstructorWorker(node, baseTypeElement); - tempFlags = saveTempFlags; - tempVariables = saveTempVariables; - tempParameters = saveTempParameters; - } - function emitConstructorWorker(node, baseTypeElement) { - var hasInstancePropertyWithInitializer = false; - ts.forEach(node.members, function (member) { - if (member.kind === 144 && !member.body) { - emitCommentsOnNotEmittedNode(member); - } - if (member.kind === 141 && member.initializer && (member.flags & 128) === 0) { - hasInstancePropertyWithInitializer = true; - } - }); - var ctor = ts.getFirstConstructorWithBody(node); - if (languageVersion >= 2 && !ctor && !hasInstancePropertyWithInitializer) { - return; - } - if (ctor) { - emitLeadingComments(ctor); - } - emitStart(ctor || node); - if (languageVersion < 2) { - write("function "); - emitDeclarationName(node); - emitSignatureParameters(ctor); - } - else { - write("constructor"); - if (ctor) { - emitSignatureParameters(ctor); - } - else { - if (baseTypeElement) { - write("(...args)"); - } - else { - write("()"); - } - } - } - var startIndex = 0; - write(" {"); - scopeEmitStart(node, "constructor"); - increaseIndent(); - if (ctor) { - startIndex = emitDirectivePrologues(ctor.body.statements, true); - emitDetachedComments(ctor.body.statements); - } - emitCaptureThisForNodeIfNecessary(node); - var superCall; - if (ctor) { - emitDefaultValueAssignments(ctor); - emitRestParameter(ctor); - if (baseTypeElement) { - superCall = findInitialSuperCall(ctor); - if (superCall) { - writeLine(); - emit(superCall); - } - } - emitParameterPropertyAssignments(ctor); - } - else { - if (baseTypeElement) { - writeLine(); - emitStart(baseTypeElement); - if (languageVersion < 2) { - write("_super.apply(this, arguments);"); - } - else { - write("super(...args);"); - } - emitEnd(baseTypeElement); - } - } - emitPropertyDeclarations(node, getInitializedProperties(node, false)); - if (ctor) { - var statements = ctor.body.statements; - if (superCall) { - statements = statements.slice(1); - } - emitLinesStartingAt(statements, startIndex); - } - emitTempDeclarations(true); - writeLine(); - if (ctor) { - emitLeadingCommentsOfPosition(ctor.body.statements.end); - } - decreaseIndent(); - emitToken(16, ctor ? ctor.body.statements.end : node.members.end); - scopeEmitEnd(); - emitEnd(ctor || node); - if (ctor) { - emitTrailingComments(ctor); - } - } - function emitClassExpression(node) { - return emitClassLikeDeclaration(node); - } - function emitClassDeclaration(node) { - return emitClassLikeDeclaration(node); - } - function emitClassLikeDeclaration(node) { - if (languageVersion < 2) { - emitClassLikeDeclarationBelowES6(node); - } - else { - emitClassLikeDeclarationForES6AndHigher(node); - } - if (modulekind !== 5 && node.parent === currentSourceFile && node.name) { - emitExportMemberAssignments(node.name); - } - } - function emitClassLikeDeclarationForES6AndHigher(node) { - var thisNodeIsDecorated = ts.nodeIsDecorated(node); - if (node.kind === 214) { - if (thisNodeIsDecorated) { - if (isES6ExportedDeclaration(node) && !(node.flags & 1024)) { - write("export "); - } - write("let "); - emitDeclarationName(node); - write(" = "); - } - else if (isES6ExportedDeclaration(node)) { - write("export "); - if (node.flags & 1024) { - write("default "); - } - } - } - var staticProperties = getInitializedProperties(node, true); - var isClassExpressionWithStaticProperties = staticProperties.length > 0 && node.kind === 186; - var tempVariable; - if (isClassExpressionWithStaticProperties) { - tempVariable = createAndRecordTempVariable(0); - write("("); - increaseIndent(); - emit(tempVariable); - write(" = "); - } - write("class"); - if ((node.name || (node.flags & 1024 && staticProperties.length > 0)) && !thisNodeIsDecorated) { - write(" "); - emitDeclarationName(node); - } - var baseTypeNode = ts.getClassExtendsHeritageClauseElement(node); - if (baseTypeNode) { - write(" extends "); - emit(baseTypeNode.expression); - } - write(" {"); - increaseIndent(); - scopeEmitStart(node); - writeLine(); - emitConstructor(node, baseTypeNode); - emitMemberFunctionsForES6AndHigher(node); - decreaseIndent(); - writeLine(); - emitToken(16, node.members.end); - scopeEmitEnd(); - if (thisNodeIsDecorated) { - write(";"); - } - if (isClassExpressionWithStaticProperties) { - for (var _a = 0; _a < staticProperties.length; _a++) { - var property = staticProperties[_a]; - write(","); - writeLine(); - emitPropertyDeclaration(node, property, tempVariable, true); - } - write(","); - writeLine(); - emit(tempVariable); - decreaseIndent(); - write(")"); - } - else { - writeLine(); - emitPropertyDeclarations(node, staticProperties); - emitDecoratorsOfClass(node); - } - if (!isES6ExportedDeclaration(node) && (node.flags & 1)) { - writeLine(); - emitStart(node); - emitModuleMemberName(node); - write(" = "); - emitDeclarationName(node); - emitEnd(node); - write(";"); - } - else if (isES6ExportedDeclaration(node) && (node.flags & 1024) && thisNodeIsDecorated) { - writeLine(); - write("export default "); - emitDeclarationName(node); - write(";"); - } - } - function emitClassLikeDeclarationBelowES6(node) { - if (node.kind === 214) { - if (!shouldHoistDeclarationInSystemJsModule(node)) { - write("var "); - } - emitDeclarationName(node); - write(" = "); - } - write("(function ("); - var baseTypeNode = ts.getClassExtendsHeritageClauseElement(node); - if (baseTypeNode) { - write("_super"); - } - write(") {"); - var saveTempFlags = tempFlags; - var saveTempVariables = tempVariables; - var saveTempParameters = tempParameters; - var saveComputedPropertyNamesToGeneratedNames = computedPropertyNamesToGeneratedNames; - tempFlags = 0; - tempVariables = undefined; - tempParameters = undefined; - computedPropertyNamesToGeneratedNames = undefined; - increaseIndent(); - scopeEmitStart(node); - if (baseTypeNode) { - writeLine(); - emitStart(baseTypeNode); - write("__extends("); - emitDeclarationName(node); - write(", _super);"); - emitEnd(baseTypeNode); - } - writeLine(); - emitConstructor(node, baseTypeNode); - emitMemberFunctionsForES5AndLower(node); - emitPropertyDeclarations(node, getInitializedProperties(node, true)); - writeLine(); - emitDecoratorsOfClass(node); - writeLine(); - emitToken(16, node.members.end, function () { - write("return "); - emitDeclarationName(node); - }); - write(";"); - emitTempDeclarations(true); - tempFlags = saveTempFlags; - tempVariables = saveTempVariables; - tempParameters = saveTempParameters; - computedPropertyNamesToGeneratedNames = saveComputedPropertyNamesToGeneratedNames; - decreaseIndent(); - writeLine(); - emitToken(16, node.members.end); - scopeEmitEnd(); - emitStart(node); - write(")("); - if (baseTypeNode) { - emit(baseTypeNode.expression); - } - write(")"); - if (node.kind === 214) { - write(";"); - } - emitEnd(node); - if (node.kind === 214) { - emitExportMemberAssignment(node); - } - } - function emitClassMemberPrefix(node, member) { - emitDeclarationName(node); - if (!(member.flags & 128)) { - write(".prototype"); - } - } - function emitDecoratorsOfClass(node) { - emitDecoratorsOfMembers(node, 0); - emitDecoratorsOfMembers(node, 128); - emitDecoratorsOfConstructor(node); - } - function emitDecoratorsOfConstructor(node) { - var decorators = node.decorators; - var constructor = ts.getFirstConstructorWithBody(node); - var hasDecoratedParameters = constructor && ts.forEach(constructor.parameters, ts.nodeIsDecorated); - if (!decorators && !hasDecoratedParameters) { - return; - } - writeLine(); - emitStart(node); - emitDeclarationName(node); - write(" = __decorate(["); - increaseIndent(); - writeLine(); - var decoratorCount = decorators ? decorators.length : 0; - var argumentsWritten = emitList(decorators, 0, decoratorCount, true, false, false, true, function (decorator) { - emitStart(decorator); - emit(decorator.expression); - emitEnd(decorator); - }); - argumentsWritten += emitDecoratorsOfParameters(constructor, argumentsWritten > 0); - emitSerializedTypeMetadata(node, argumentsWritten >= 0); - decreaseIndent(); - writeLine(); - write("], "); - emitDeclarationName(node); - write(");"); - emitEnd(node); - writeLine(); - } - function emitDecoratorsOfMembers(node, staticFlag) { - for (var _a = 0, _b = node.members; _a < _b.length; _a++) { - var member = _b[_a]; - if ((member.flags & 128) !== staticFlag) { - continue; - } - if (!ts.nodeCanBeDecorated(member)) { - continue; - } - if (!ts.nodeOrChildIsDecorated(member)) { - continue; - } - var decorators = void 0; - var functionLikeMember = void 0; - if (ts.isAccessor(member)) { - var accessors = ts.getAllAccessorDeclarations(node.members, member); - if (member !== accessors.firstAccessor) { - continue; - } - decorators = accessors.firstAccessor.decorators; - if (!decorators && accessors.secondAccessor) { - decorators = accessors.secondAccessor.decorators; - } - functionLikeMember = accessors.setAccessor; - } - else { - decorators = member.decorators; - if (member.kind === 143) { - functionLikeMember = member; - } - } - writeLine(); - emitStart(member); - write("__decorate(["); - increaseIndent(); - writeLine(); - var decoratorCount = decorators ? decorators.length : 0; - var argumentsWritten = emitList(decorators, 0, decoratorCount, true, false, false, true, function (decorator) { - emitStart(decorator); - emit(decorator.expression); - emitEnd(decorator); - }); - argumentsWritten += emitDecoratorsOfParameters(functionLikeMember, argumentsWritten > 0); - emitSerializedTypeMetadata(member, argumentsWritten > 0); - decreaseIndent(); - writeLine(); - write("], "); - emitStart(member.name); - emitClassMemberPrefix(node, member); - write(", "); - emitExpressionForPropertyName(member.name); - emitEnd(member.name); - if (languageVersion > 0) { - if (member.kind !== 141) { - write(", null"); - } - else { - write(", void 0"); - } - } - write(");"); - emitEnd(member); - writeLine(); - } - } - function emitDecoratorsOfParameters(node, leadingComma) { - var argumentsWritten = 0; - if (node) { - var parameterIndex = 0; - for (var _a = 0, _b = node.parameters; _a < _b.length; _a++) { - var parameter = _b[_a]; - if (ts.nodeIsDecorated(parameter)) { - var decorators = parameter.decorators; - argumentsWritten += emitList(decorators, 0, decorators.length, true, false, leadingComma, true, function (decorator) { - emitStart(decorator); - write("__param(" + parameterIndex + ", "); - emit(decorator.expression); - write(")"); - emitEnd(decorator); - }); - leadingComma = true; - } - ++parameterIndex; - } - } - return argumentsWritten; - } - function shouldEmitTypeMetadata(node) { - switch (node.kind) { - case 143: - case 145: - case 146: - case 141: - return true; - } - return false; - } - function shouldEmitReturnTypeMetadata(node) { - switch (node.kind) { - case 143: - return true; - } - return false; - } - function shouldEmitParamTypesMetadata(node) { - switch (node.kind) { - case 214: - case 143: - case 146: - return true; - } - return false; - } - function emitSerializedTypeOfNode(node) { - switch (node.kind) { - case 214: - write("Function"); - return; - case 141: - emitSerializedTypeNode(node.type); - return; - case 138: - emitSerializedTypeNode(node.type); - return; - case 145: - emitSerializedTypeNode(node.type); - return; - case 146: - emitSerializedTypeNode(ts.getSetAccessorTypeAnnotationNode(node)); - return; - } - if (ts.isFunctionLike(node)) { - write("Function"); - return; - } - write("void 0"); - } - function emitSerializedTypeNode(node) { - if (node) { - switch (node.kind) { - case 103: - write("void 0"); - return; - case 160: - emitSerializedTypeNode(node.type); - return; - case 152: - case 153: - write("Function"); - return; - case 156: - case 157: - write("Array"); - return; - case 150: - case 120: - write("Boolean"); - return; - case 130: - case 9: - write("String"); - return; - case 128: - write("Number"); - return; - case 131: - write("Symbol"); - return; - case 151: - emitSerializedTypeReferenceNode(node); - return; - case 154: - case 155: - case 158: - case 159: - case 117: - break; - default: - ts.Debug.fail("Cannot serialize unexpected type node."); - break; - } - } - write("Object"); - } - function emitSerializedTypeReferenceNode(node) { - var location = node.parent; - while (ts.isDeclaration(location) || ts.isTypeNode(location)) { - location = location.parent; - } - var typeName = ts.cloneEntityName(node.typeName); - typeName.parent = location; - var result = resolver.getTypeReferenceSerializationKind(typeName); - switch (result) { - case ts.TypeReferenceSerializationKind.Unknown: - var temp = createAndRecordTempVariable(0); - write("(typeof ("); - emitNodeWithoutSourceMap(temp); - write(" = "); - emitEntityNameAsExpression(typeName, true); - write(") === 'function' && "); - emitNodeWithoutSourceMap(temp); - write(") || Object"); - break; - case ts.TypeReferenceSerializationKind.TypeWithConstructSignatureAndValue: - emitEntityNameAsExpression(typeName, false); - break; - case ts.TypeReferenceSerializationKind.VoidType: - write("void 0"); - break; - case ts.TypeReferenceSerializationKind.BooleanType: - write("Boolean"); - break; - case ts.TypeReferenceSerializationKind.NumberLikeType: - write("Number"); - break; - case ts.TypeReferenceSerializationKind.StringLikeType: - write("String"); - break; - case ts.TypeReferenceSerializationKind.ArrayLikeType: - write("Array"); - break; - case ts.TypeReferenceSerializationKind.ESSymbolType: - if (languageVersion < 2) { - write("typeof Symbol === 'function' ? Symbol : Object"); - } - else { - write("Symbol"); - } - break; - case ts.TypeReferenceSerializationKind.TypeWithCallSignature: - write("Function"); - break; - case ts.TypeReferenceSerializationKind.ObjectType: - write("Object"); - break; - } - } - function emitSerializedParameterTypesOfNode(node) { - if (node) { - var valueDeclaration; - if (node.kind === 214) { - valueDeclaration = ts.getFirstConstructorWithBody(node); - } - else if (ts.isFunctionLike(node) && ts.nodeIsPresent(node.body)) { - valueDeclaration = node; - } - if (valueDeclaration) { - var parameters = valueDeclaration.parameters; - var parameterCount = parameters.length; - if (parameterCount > 0) { - for (var i = 0; i < parameterCount; i++) { - if (i > 0) { - write(", "); - } - if (parameters[i].dotDotDotToken) { - var parameterType = parameters[i].type; - if (parameterType.kind === 156) { - parameterType = parameterType.elementType; - } - else if (parameterType.kind === 151 && parameterType.typeArguments && parameterType.typeArguments.length === 1) { - parameterType = parameterType.typeArguments[0]; - } - else { - parameterType = undefined; - } - emitSerializedTypeNode(parameterType); - } - else { - emitSerializedTypeOfNode(parameters[i]); - } - } - } - } - } - } - function emitSerializedReturnTypeOfNode(node) { - if (node && ts.isFunctionLike(node) && node.type) { - emitSerializedTypeNode(node.type); - return; - } - write("void 0"); - } - function emitSerializedTypeMetadata(node, writeComma) { - var argumentsWritten = 0; - if (compilerOptions.emitDecoratorMetadata) { - if (shouldEmitTypeMetadata(node)) { - if (writeComma) { - write(", "); - } - writeLine(); - write("__metadata('design:type', "); - emitSerializedTypeOfNode(node); - write(")"); - argumentsWritten++; - } - if (shouldEmitParamTypesMetadata(node)) { - if (writeComma || argumentsWritten) { - write(", "); - } - writeLine(); - write("__metadata('design:paramtypes', ["); - emitSerializedParameterTypesOfNode(node); - write("])"); - argumentsWritten++; - } - if (shouldEmitReturnTypeMetadata(node)) { - if (writeComma || argumentsWritten) { - write(", "); - } - writeLine(); - write("__metadata('design:returntype', "); - emitSerializedReturnTypeOfNode(node); - write(")"); - argumentsWritten++; - } - } - return argumentsWritten; - } - function emitInterfaceDeclaration(node) { - emitCommentsOnNotEmittedNode(node); - } - function shouldEmitEnumDeclaration(node) { - var isConstEnum = ts.isConst(node); - return !isConstEnum || compilerOptions.preserveConstEnums || compilerOptions.isolatedModules; - } - function emitEnumDeclaration(node) { - if (!shouldEmitEnumDeclaration(node)) { - return; - } - if (!shouldHoistDeclarationInSystemJsModule(node)) { - if (!(node.flags & 1) || isES6ExportedDeclaration(node)) { - emitStart(node); - if (isES6ExportedDeclaration(node)) { - write("export "); - } - write("var "); - emit(node.name); - emitEnd(node); - write(";"); - } - } - writeLine(); - emitStart(node); - write("(function ("); - emitStart(node.name); - write(getGeneratedNameForNode(node)); - emitEnd(node.name); - write(") {"); - increaseIndent(); - scopeEmitStart(node); - emitLines(node.members); - decreaseIndent(); - writeLine(); - emitToken(16, node.members.end); - scopeEmitEnd(); - write(")("); - emitModuleMemberName(node); - write(" || ("); - emitModuleMemberName(node); - write(" = {}));"); - emitEnd(node); - if (!isES6ExportedDeclaration(node) && node.flags & 1 && !shouldHoistDeclarationInSystemJsModule(node)) { - writeLine(); - emitStart(node); - write("var "); - emit(node.name); - write(" = "); - emitModuleMemberName(node); - emitEnd(node); - write(";"); - } - if (modulekind !== 5 && node.parent === currentSourceFile) { - if (modulekind === 4 && (node.flags & 1)) { - writeLine(); - write(exportFunctionForFile + "(\""); - emitDeclarationName(node); - write("\", "); - emitDeclarationName(node); - write(");"); - } - emitExportMemberAssignments(node.name); - } - } - function emitEnumMember(node) { - var enumParent = node.parent; - emitStart(node); - write(getGeneratedNameForNode(enumParent)); - write("["); - write(getGeneratedNameForNode(enumParent)); - write("["); - emitExpressionForPropertyName(node.name); - write("] = "); - writeEnumMemberDeclarationValue(node); - write("] = "); - emitExpressionForPropertyName(node.name); - emitEnd(node); - write(";"); - } - function writeEnumMemberDeclarationValue(member) { - var value = resolver.getConstantValue(member); - if (value !== undefined) { - write(value.toString()); - return; - } - else if (member.initializer) { - emit(member.initializer); - } - else { - write("undefined"); - } - } - function getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration) { - if (moduleDeclaration.body.kind === 218) { - var recursiveInnerModule = getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration.body); - return recursiveInnerModule || moduleDeclaration.body; - } - } - function shouldEmitModuleDeclaration(node) { - return ts.isInstantiatedModule(node, compilerOptions.preserveConstEnums || compilerOptions.isolatedModules); - } - function isModuleMergedWithES6Class(node) { - return languageVersion === 2 && !!(resolver.getNodeCheckFlags(node) & 32768); - } - function emitModuleDeclaration(node) { - var shouldEmit = shouldEmitModuleDeclaration(node); - if (!shouldEmit) { - return emitCommentsOnNotEmittedNode(node); - } - var hoistedInDeclarationScope = shouldHoistDeclarationInSystemJsModule(node); - var emitVarForModule = !hoistedInDeclarationScope && !isModuleMergedWithES6Class(node); - if (emitVarForModule) { - emitStart(node); - if (isES6ExportedDeclaration(node)) { - write("export "); - } - write("var "); - emit(node.name); - write(";"); - emitEnd(node); - writeLine(); - } - emitStart(node); - write("(function ("); - emitStart(node.name); - write(getGeneratedNameForNode(node)); - emitEnd(node.name); - write(") "); - if (node.body.kind === 219) { - var saveTempFlags = tempFlags; - var saveTempVariables = tempVariables; - tempFlags = 0; - tempVariables = undefined; - emit(node.body); - tempFlags = saveTempFlags; - tempVariables = saveTempVariables; - } - else { - write("{"); - increaseIndent(); - scopeEmitStart(node); - emitCaptureThisForNodeIfNecessary(node); - writeLine(); - emit(node.body); - decreaseIndent(); - writeLine(); - var moduleBlock = getInnerMostModuleDeclarationFromDottedModule(node).body; - emitToken(16, moduleBlock.statements.end); - scopeEmitEnd(); - } - write(")("); - if ((node.flags & 1) && !isES6ExportedDeclaration(node)) { - emit(node.name); - write(" = "); - } - emitModuleMemberName(node); - write(" || ("); - emitModuleMemberName(node); - write(" = {}));"); - emitEnd(node); - if (!isES6ExportedDeclaration(node) && node.name.kind === 69 && node.parent === currentSourceFile) { - if (modulekind === 4 && (node.flags & 1)) { - writeLine(); - write(exportFunctionForFile + "(\""); - emitDeclarationName(node); - write("\", "); - emitDeclarationName(node); - write(");"); - } - emitExportMemberAssignments(node.name); - } - } - function tryRenameExternalModule(moduleName) { - if (currentSourceFile.renamedDependencies && ts.hasProperty(currentSourceFile.renamedDependencies, moduleName.text)) { - return "\"" + currentSourceFile.renamedDependencies[moduleName.text] + "\""; - } - return undefined; - } - function emitRequire(moduleName) { - if (moduleName.kind === 9) { - write("require("); - var text = tryRenameExternalModule(moduleName); - if (text) { - write(text); - } - else { - emitStart(moduleName); - emitLiteral(moduleName); - emitEnd(moduleName); - } - emitToken(18, moduleName.end); - } - else { - write("require()"); - } - } - function getNamespaceDeclarationNode(node) { - if (node.kind === 221) { - return node; - } - var importClause = node.importClause; - if (importClause && importClause.namedBindings && importClause.namedBindings.kind === 224) { - return importClause.namedBindings; - } - } - function isDefaultImport(node) { - return node.kind === 222 && node.importClause && !!node.importClause.name; - } - function emitExportImportAssignments(node) { - if (ts.isAliasSymbolDeclaration(node) && resolver.isValueAliasDeclaration(node)) { - emitExportMemberAssignments(node.name); - } - ts.forEachChild(node, emitExportImportAssignments); - } - function emitImportDeclaration(node) { - if (modulekind !== 5) { - return emitExternalImportDeclaration(node); - } - if (node.importClause) { - var shouldEmitDefaultBindings = resolver.isReferencedAliasDeclaration(node.importClause); - var shouldEmitNamedBindings = node.importClause.namedBindings && resolver.isReferencedAliasDeclaration(node.importClause.namedBindings, true); - if (shouldEmitDefaultBindings || shouldEmitNamedBindings) { - write("import "); - emitStart(node.importClause); - if (shouldEmitDefaultBindings) { - emit(node.importClause.name); - if (shouldEmitNamedBindings) { - write(", "); - } - } - if (shouldEmitNamedBindings) { - emitLeadingComments(node.importClause.namedBindings); - emitStart(node.importClause.namedBindings); - if (node.importClause.namedBindings.kind === 224) { - write("* as "); - emit(node.importClause.namedBindings.name); - } - else { - write("{ "); - emitExportOrImportSpecifierList(node.importClause.namedBindings.elements, resolver.isReferencedAliasDeclaration); - write(" }"); - } - emitEnd(node.importClause.namedBindings); - emitTrailingComments(node.importClause.namedBindings); - } - emitEnd(node.importClause); - write(" from "); - emit(node.moduleSpecifier); - write(";"); - } - } - else { - write("import "); - emit(node.moduleSpecifier); - write(";"); - } - } - function emitExternalImportDeclaration(node) { - if (ts.contains(externalImports, node)) { - var isExportedImport = node.kind === 221 && (node.flags & 1) !== 0; - var namespaceDeclaration = getNamespaceDeclarationNode(node); - if (modulekind !== 2) { - emitLeadingComments(node); - emitStart(node); - if (namespaceDeclaration && !isDefaultImport(node)) { - if (!isExportedImport) - write("var "); - emitModuleMemberName(namespaceDeclaration); - write(" = "); - } - else { - var isNakedImport = 222 && !node.importClause; - if (!isNakedImport) { - write("var "); - write(getGeneratedNameForNode(node)); - write(" = "); - } - } - emitRequire(ts.getExternalModuleName(node)); - if (namespaceDeclaration && isDefaultImport(node)) { - write(", "); - emitModuleMemberName(namespaceDeclaration); - write(" = "); - write(getGeneratedNameForNode(node)); - } - write(";"); - emitEnd(node); - emitExportImportAssignments(node); - emitTrailingComments(node); - } - else { - if (isExportedImport) { - emitModuleMemberName(namespaceDeclaration); - write(" = "); - emit(namespaceDeclaration.name); - write(";"); - } - else if (namespaceDeclaration && isDefaultImport(node)) { - write("var "); - emitModuleMemberName(namespaceDeclaration); - write(" = "); - write(getGeneratedNameForNode(node)); - write(";"); - } - emitExportImportAssignments(node); - } - } - } - function emitImportEqualsDeclaration(node) { - if (ts.isExternalModuleImportEqualsDeclaration(node)) { - emitExternalImportDeclaration(node); - return; - } - if (resolver.isReferencedAliasDeclaration(node) || - (!ts.isExternalModule(currentSourceFile) && resolver.isTopLevelValueImportEqualsWithEntityName(node))) { - emitLeadingComments(node); - emitStart(node); - var variableDeclarationIsHoisted = shouldHoistVariable(node, true); - var isExported = isSourceFileLevelDeclarationInSystemJsModule(node, true); - if (!variableDeclarationIsHoisted) { - ts.Debug.assert(!isExported); - if (isES6ExportedDeclaration(node)) { - write("export "); - write("var "); - } - else if (!(node.flags & 1)) { - write("var "); - } - } - if (isExported) { - write(exportFunctionForFile + "(\""); - emitNodeWithoutSourceMap(node.name); - write("\", "); - } - emitModuleMemberName(node); - write(" = "); - emit(node.moduleReference); - if (isExported) { - write(")"); - } - write(";"); - emitEnd(node); - emitExportImportAssignments(node); - emitTrailingComments(node); - } - } - function emitExportDeclaration(node) { - ts.Debug.assert(modulekind !== 4); - if (modulekind !== 5) { - if (node.moduleSpecifier && (!node.exportClause || resolver.isValueAliasDeclaration(node))) { - emitStart(node); - var generatedName = getGeneratedNameForNode(node); - if (node.exportClause) { - if (modulekind !== 2) { - write("var "); - write(generatedName); - write(" = "); - emitRequire(ts.getExternalModuleName(node)); - write(";"); - } - for (var _a = 0, _b = node.exportClause.elements; _a < _b.length; _a++) { - var specifier = _b[_a]; - if (resolver.isValueAliasDeclaration(specifier)) { - writeLine(); - emitStart(specifier); - emitContainingModuleName(specifier); - write("."); - emitNodeWithCommentsAndWithoutSourcemap(specifier.name); - write(" = "); - write(generatedName); - write("."); - emitNodeWithCommentsAndWithoutSourcemap(specifier.propertyName || specifier.name); - write(";"); - emitEnd(specifier); - } - } - } - else { - writeLine(); - write("__export("); - if (modulekind !== 2) { - emitRequire(ts.getExternalModuleName(node)); - } - else { - write(generatedName); - } - write(");"); - } - emitEnd(node); - } - } - else { - if (!node.exportClause || resolver.isValueAliasDeclaration(node)) { - write("export "); - if (node.exportClause) { - write("{ "); - emitExportOrImportSpecifierList(node.exportClause.elements, resolver.isValueAliasDeclaration); - write(" }"); - } - else { - write("*"); - } - if (node.moduleSpecifier) { - write(" from "); - emit(node.moduleSpecifier); - } - write(";"); - } - } - } - function emitExportOrImportSpecifierList(specifiers, shouldEmit) { - ts.Debug.assert(modulekind === 5); - var needsComma = false; - for (var _a = 0; _a < specifiers.length; _a++) { - var specifier = specifiers[_a]; - if (shouldEmit(specifier)) { - if (needsComma) { - write(", "); - } - if (specifier.propertyName) { - emit(specifier.propertyName); - write(" as "); - } - emit(specifier.name); - needsComma = true; - } - } - } - function emitExportAssignment(node) { - if (!node.isExportEquals && resolver.isValueAliasDeclaration(node)) { - if (modulekind === 5) { - writeLine(); - emitStart(node); - write("export default "); - var expression = node.expression; - emit(expression); - if (expression.kind !== 213 && - expression.kind !== 214) { - write(";"); - } - emitEnd(node); - } - else { - writeLine(); - emitStart(node); - if (modulekind === 4) { - write(exportFunctionForFile + "(\"default\","); - emit(node.expression); - write(")"); - } - else { - emitEs6ExportDefaultCompat(node); - emitContainingModuleName(node); - if (languageVersion === 0) { - write("[\"default\"] = "); - } - else { - write(".default = "); - } - emit(node.expression); - } - write(";"); - emitEnd(node); - } - } - } - function collectExternalModuleInfo(sourceFile) { - externalImports = []; - exportSpecifiers = {}; - exportEquals = undefined; - hasExportStars = false; - for (var _a = 0, _b = sourceFile.statements; _a < _b.length; _a++) { - var node = _b[_a]; - switch (node.kind) { - case 222: - if (!node.importClause || - resolver.isReferencedAliasDeclaration(node.importClause, true)) { - externalImports.push(node); - } - break; - case 221: - if (node.moduleReference.kind === 232 && resolver.isReferencedAliasDeclaration(node)) { - externalImports.push(node); - } - break; - case 228: - if (node.moduleSpecifier) { - if (!node.exportClause) { - externalImports.push(node); - hasExportStars = true; - } - else if (resolver.isValueAliasDeclaration(node)) { - externalImports.push(node); - } - } - else { - for (var _c = 0, _d = node.exportClause.elements; _c < _d.length; _c++) { - var specifier = _d[_c]; - var name_25 = (specifier.propertyName || specifier.name).text; - (exportSpecifiers[name_25] || (exportSpecifiers[name_25] = [])).push(specifier); - } - } - break; - case 227: - if (node.isExportEquals && !exportEquals) { - exportEquals = node; - } - break; - } - } - } - function emitExportStarHelper() { - if (hasExportStars) { - writeLine(); - write("function __export(m) {"); - increaseIndent(); - writeLine(); - write("for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];"); - decreaseIndent(); - writeLine(); - write("}"); - } - } - function getLocalNameForExternalImport(node) { - var namespaceDeclaration = getNamespaceDeclarationNode(node); - if (namespaceDeclaration && !isDefaultImport(node)) { - return ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, namespaceDeclaration.name); - } - if (node.kind === 222 && node.importClause) { - return getGeneratedNameForNode(node); - } - if (node.kind === 228 && node.moduleSpecifier) { - return getGeneratedNameForNode(node); - } - } - function getExternalModuleNameText(importNode) { - var moduleName = ts.getExternalModuleName(importNode); - if (moduleName.kind === 9) { - return tryRenameExternalModule(moduleName) || getLiteralText(moduleName); - } - return undefined; - } - function emitVariableDeclarationsForImports() { - if (externalImports.length === 0) { - return; - } - writeLine(); - var started = false; - for (var _a = 0; _a < externalImports.length; _a++) { - var importNode = externalImports[_a]; - var skipNode = importNode.kind === 228 || - (importNode.kind === 222 && !importNode.importClause); - if (skipNode) { - continue; - } - if (!started) { - write("var "); - started = true; - } - else { - write(", "); - } - write(getLocalNameForExternalImport(importNode)); - } - if (started) { - write(";"); - } - } - function emitLocalStorageForExportedNamesIfNecessary(exportedDeclarations) { - if (!hasExportStars) { - return undefined; - } - if (!exportedDeclarations && ts.isEmpty(exportSpecifiers)) { - var hasExportDeclarationWithExportClause = false; - for (var _a = 0; _a < externalImports.length; _a++) { - var externalImport = externalImports[_a]; - if (externalImport.kind === 228 && externalImport.exportClause) { - hasExportDeclarationWithExportClause = true; - break; - } - } - if (!hasExportDeclarationWithExportClause) { - return emitExportStarFunction(undefined); - } - } - var exportedNamesStorageRef = makeUniqueName("exportedNames"); - writeLine(); - write("var " + exportedNamesStorageRef + " = {"); - increaseIndent(); - var started = false; - if (exportedDeclarations) { - for (var i = 0; i < exportedDeclarations.length; ++i) { - writeExportedName(exportedDeclarations[i]); - } - } - if (exportSpecifiers) { - for (var n in exportSpecifiers) { - for (var _b = 0, _c = exportSpecifiers[n]; _b < _c.length; _b++) { - var specifier = _c[_b]; - writeExportedName(specifier.name); - } - } - } - for (var _d = 0; _d < externalImports.length; _d++) { - var externalImport = externalImports[_d]; - if (externalImport.kind !== 228) { - continue; - } - var exportDecl = externalImport; - if (!exportDecl.exportClause) { - continue; - } - for (var _e = 0, _f = exportDecl.exportClause.elements; _e < _f.length; _e++) { - var element = _f[_e]; - writeExportedName(element.name || element.propertyName); - } - } - decreaseIndent(); - writeLine(); - write("};"); - return emitExportStarFunction(exportedNamesStorageRef); - function emitExportStarFunction(localNames) { - var exportStarFunction = makeUniqueName("exportStar"); - writeLine(); - write("function " + exportStarFunction + "(m) {"); - increaseIndent(); - writeLine(); - write("var exports = {};"); - writeLine(); - write("for(var n in m) {"); - increaseIndent(); - writeLine(); - write("if (n !== \"default\""); - if (localNames) { - write("&& !" + localNames + ".hasOwnProperty(n)"); - } - write(") exports[n] = m[n];"); - decreaseIndent(); - writeLine(); - write("}"); - writeLine(); - write(exportFunctionForFile + "(exports);"); - decreaseIndent(); - writeLine(); - write("}"); - return exportStarFunction; - } - function writeExportedName(node) { - if (node.kind !== 69 && node.flags & 1024) { - return; - } - if (started) { - write(","); - } - else { - started = true; - } - writeLine(); - write("'"); - if (node.kind === 69) { - emitNodeWithCommentsAndWithoutSourcemap(node); - } - else { - emitDeclarationName(node); - } - write("': true"); - } - } - function processTopLevelVariableAndFunctionDeclarations(node) { - var hoistedVars; - var hoistedFunctionDeclarations; - var exportedDeclarations; - visit(node); - if (hoistedVars) { - writeLine(); - write("var "); - var seen = {}; - for (var i = 0; i < hoistedVars.length; ++i) { - var local = hoistedVars[i]; - var name_26 = local.kind === 69 - ? local - : local.name; - if (name_26) { - var text = ts.unescapeIdentifier(name_26.text); - if (ts.hasProperty(seen, text)) { - continue; - } - else { - seen[text] = text; - } - } - if (i !== 0) { - write(", "); - } - if (local.kind === 214 || local.kind === 218 || local.kind === 217) { - emitDeclarationName(local); - } - else { - emit(local); - } - var flags = ts.getCombinedNodeFlags(local.kind === 69 ? local.parent : local); - if (flags & 1) { - if (!exportedDeclarations) { - exportedDeclarations = []; - } - exportedDeclarations.push(local); - } - } - write(";"); - } - if (hoistedFunctionDeclarations) { - for (var _a = 0; _a < hoistedFunctionDeclarations.length; _a++) { - var f = hoistedFunctionDeclarations[_a]; - writeLine(); - emit(f); - if (f.flags & 1) { - if (!exportedDeclarations) { - exportedDeclarations = []; - } - exportedDeclarations.push(f); - } - } - } - return exportedDeclarations; - function visit(node) { - if (node.flags & 2) { - return; - } - if (node.kind === 213) { - if (!hoistedFunctionDeclarations) { - hoistedFunctionDeclarations = []; - } - hoistedFunctionDeclarations.push(node); - return; - } - if (node.kind === 214) { - if (!hoistedVars) { - hoistedVars = []; - } - hoistedVars.push(node); - return; - } - if (node.kind === 217) { - if (shouldEmitEnumDeclaration(node)) { - if (!hoistedVars) { - hoistedVars = []; - } - hoistedVars.push(node); - } - return; - } - if (node.kind === 218) { - if (shouldEmitModuleDeclaration(node)) { - if (!hoistedVars) { - hoistedVars = []; - } - hoistedVars.push(node); - } - return; - } - if (node.kind === 211 || node.kind === 163) { - if (shouldHoistVariable(node, false)) { - var name_27 = node.name; - if (name_27.kind === 69) { - if (!hoistedVars) { - hoistedVars = []; - } - hoistedVars.push(name_27); - } - else { - ts.forEachChild(name_27, visit); - } - } - return; - } - if (ts.isInternalModuleImportEqualsDeclaration(node) && resolver.isValueAliasDeclaration(node)) { - if (!hoistedVars) { - hoistedVars = []; - } - hoistedVars.push(node.name); - return; - } - if (ts.isBindingPattern(node)) { - ts.forEach(node.elements, visit); - return; - } - if (!ts.isDeclaration(node)) { - ts.forEachChild(node, visit); - } - } - } - function shouldHoistVariable(node, checkIfSourceFileLevelDecl) { - if (checkIfSourceFileLevelDecl && !shouldHoistDeclarationInSystemJsModule(node)) { - return false; - } - return (ts.getCombinedNodeFlags(node) & 49152) === 0 || - ts.getEnclosingBlockScopeContainer(node).kind === 248; - } - function isCurrentFileSystemExternalModule() { - return modulekind === 4 && ts.isExternalModule(currentSourceFile); - } - function emitSystemModuleBody(node, dependencyGroups, startIndex) { - emitVariableDeclarationsForImports(); - writeLine(); - var exportedDeclarations = processTopLevelVariableAndFunctionDeclarations(node); - var exportStarFunction = emitLocalStorageForExportedNamesIfNecessary(exportedDeclarations); - writeLine(); - write("return {"); - increaseIndent(); - writeLine(); - emitSetters(exportStarFunction, dependencyGroups); - writeLine(); - emitExecute(node, startIndex); - decreaseIndent(); - writeLine(); - write("}"); - emitTempDeclarations(true); - } - function emitSetters(exportStarFunction, dependencyGroups) { - write("setters:["); - for (var i = 0; i < dependencyGroups.length; ++i) { - if (i !== 0) { - write(","); - } - writeLine(); - increaseIndent(); - var group = dependencyGroups[i]; - var parameterName = makeUniqueName(ts.forEach(group, getLocalNameForExternalImport) || ""); - write("function (" + parameterName + ") {"); - increaseIndent(); - for (var _a = 0; _a < group.length; _a++) { - var entry = group[_a]; - var importVariableName = getLocalNameForExternalImport(entry) || ""; - switch (entry.kind) { - case 222: - if (!entry.importClause) { - break; - } - case 221: - ts.Debug.assert(importVariableName !== ""); - writeLine(); - write(importVariableName + " = " + parameterName + ";"); - writeLine(); - break; - case 228: - ts.Debug.assert(importVariableName !== ""); - if (entry.exportClause) { - writeLine(); - write(exportFunctionForFile + "({"); - writeLine(); - increaseIndent(); - for (var i_2 = 0, len = entry.exportClause.elements.length; i_2 < len; ++i_2) { - if (i_2 !== 0) { - write(","); - writeLine(); - } - var e = entry.exportClause.elements[i_2]; - write("\""); - emitNodeWithCommentsAndWithoutSourcemap(e.name); - write("\": " + parameterName + "[\""); - emitNodeWithCommentsAndWithoutSourcemap(e.propertyName || e.name); - write("\"]"); - } - decreaseIndent(); - writeLine(); - write("});"); - } - else { - writeLine(); - write(exportStarFunction + "(" + parameterName + ");"); - } - writeLine(); - break; - } - } - decreaseIndent(); - write("}"); - decreaseIndent(); - } - write("],"); - } - function emitExecute(node, startIndex) { - write("execute: function() {"); - increaseIndent(); - writeLine(); - for (var i = startIndex; i < node.statements.length; ++i) { - var statement = node.statements[i]; - switch (statement.kind) { - case 213: - case 222: - continue; - case 228: - if (!statement.moduleSpecifier) { - for (var _a = 0, _b = statement.exportClause.elements; _a < _b.length; _a++) { - var element = _b[_a]; - emitExportSpecifierInSystemModule(element); - } - } - continue; - case 221: - if (!ts.isInternalModuleImportEqualsDeclaration(statement)) { - continue; - } - default: - writeLine(); - emit(statement); - } - } - decreaseIndent(); - writeLine(); - write("}"); - } - function emitSystemModule(node) { - collectExternalModuleInfo(node); - ts.Debug.assert(!exportFunctionForFile); - exportFunctionForFile = makeUniqueName("exports"); - writeLine(); - write("System.register("); - if (node.moduleName) { - write("\"" + node.moduleName + "\", "); - } - write("["); - var groupIndices = {}; - var dependencyGroups = []; - for (var i = 0; i < externalImports.length; ++i) { - var text = getExternalModuleNameText(externalImports[i]); - if (ts.hasProperty(groupIndices, text)) { - var groupIndex = groupIndices[text]; - dependencyGroups[groupIndex].push(externalImports[i]); - continue; - } - else { - groupIndices[text] = dependencyGroups.length; - dependencyGroups.push([externalImports[i]]); - } - if (i !== 0) { - write(", "); - } - write(text); - } - write("], function(" + exportFunctionForFile + ") {"); - writeLine(); - increaseIndent(); - var startIndex = emitDirectivePrologues(node.statements, true); - emitEmitHelpers(node); - emitCaptureThisForNodeIfNecessary(node); - emitSystemModuleBody(node, dependencyGroups, startIndex); - decreaseIndent(); - writeLine(); - write("});"); - } - function getAMDDependencyNames(node, includeNonAmdDependencies) { - var aliasedModuleNames = []; - var unaliasedModuleNames = []; - var importAliasNames = []; - for (var _a = 0, _b = node.amdDependencies; _a < _b.length; _a++) { - var amdDependency = _b[_a]; - if (amdDependency.name) { - aliasedModuleNames.push("\"" + amdDependency.path + "\""); - importAliasNames.push(amdDependency.name); - } - else { - unaliasedModuleNames.push("\"" + amdDependency.path + "\""); - } - } - for (var _c = 0; _c < externalImports.length; _c++) { - var importNode = externalImports[_c]; - var externalModuleName = getExternalModuleNameText(importNode); - var importAliasName = getLocalNameForExternalImport(importNode); - if (includeNonAmdDependencies && importAliasName) { - aliasedModuleNames.push(externalModuleName); - importAliasNames.push(importAliasName); - } - else { - unaliasedModuleNames.push(externalModuleName); - } - } - return { aliasedModuleNames: aliasedModuleNames, unaliasedModuleNames: unaliasedModuleNames, importAliasNames: importAliasNames }; - } - function emitAMDDependencies(node, includeNonAmdDependencies) { - var dependencyNames = getAMDDependencyNames(node, includeNonAmdDependencies); - emitAMDDependencyList(dependencyNames); - write(", "); - emitAMDFactoryHeader(dependencyNames); - } - function emitAMDDependencyList(_a) { - var aliasedModuleNames = _a.aliasedModuleNames, unaliasedModuleNames = _a.unaliasedModuleNames; - write("[\"require\", \"exports\""); - if (aliasedModuleNames.length) { - write(", "); - write(aliasedModuleNames.join(", ")); - } - if (unaliasedModuleNames.length) { - write(", "); - write(unaliasedModuleNames.join(", ")); - } - write("]"); - } - function emitAMDFactoryHeader(_a) { - var importAliasNames = _a.importAliasNames; - write("function (require, exports"); - if (importAliasNames.length) { - write(", "); - write(importAliasNames.join(", ")); - } - write(") {"); - } - function emitAMDModule(node) { - emitEmitHelpers(node); - collectExternalModuleInfo(node); - writeLine(); - write("define("); - if (node.moduleName) { - write("\"" + node.moduleName + "\", "); - } - emitAMDDependencies(node, true); - increaseIndent(); - var startIndex = emitDirectivePrologues(node.statements, true); - emitExportStarHelper(); - emitCaptureThisForNodeIfNecessary(node); - emitLinesStartingAt(node.statements, startIndex); - emitTempDeclarations(true); - emitExportEquals(true); - decreaseIndent(); - writeLine(); - write("});"); - } - function emitCommonJSModule(node) { - var startIndex = emitDirectivePrologues(node.statements, false); - emitEmitHelpers(node); - collectExternalModuleInfo(node); - emitExportStarHelper(); - emitCaptureThisForNodeIfNecessary(node); - emitLinesStartingAt(node.statements, startIndex); - emitTempDeclarations(true); - emitExportEquals(false); - } - function emitUMDModule(node) { - emitEmitHelpers(node); - collectExternalModuleInfo(node); - var dependencyNames = getAMDDependencyNames(node, false); - writeLines("(function (factory) {\n if (typeof module === 'object' && typeof module.exports === 'object') {\n var v = factory(require, exports); if (v !== undefined) module.exports = v;\n }\n else if (typeof define === 'function' && define.amd) {\n define("); - emitAMDDependencyList(dependencyNames); - write(", factory);"); - writeLines(" }\n})("); - emitAMDFactoryHeader(dependencyNames); - increaseIndent(); - var startIndex = emitDirectivePrologues(node.statements, true); - emitExportStarHelper(); - emitCaptureThisForNodeIfNecessary(node); - emitLinesStartingAt(node.statements, startIndex); - emitTempDeclarations(true); - emitExportEquals(true); - decreaseIndent(); - writeLine(); - write("});"); - } - function emitES6Module(node) { - externalImports = undefined; - exportSpecifiers = undefined; - exportEquals = undefined; - hasExportStars = false; - var startIndex = emitDirectivePrologues(node.statements, false); - emitEmitHelpers(node); - emitCaptureThisForNodeIfNecessary(node); - emitLinesStartingAt(node.statements, startIndex); - emitTempDeclarations(true); - } - function emitExportEquals(emitAsReturn) { - if (exportEquals && resolver.isValueAliasDeclaration(exportEquals)) { - writeLine(); - emitStart(exportEquals); - write(emitAsReturn ? "return " : "module.exports = "); - emit(exportEquals.expression); - write(";"); - emitEnd(exportEquals); - } - } - function emitJsxElement(node) { - switch (compilerOptions.jsx) { - case 2: - jsxEmitReact(node); - break; - case 1: - default: - jsxEmitPreserve(node); - break; - } - } - function trimReactWhitespaceAndApplyEntities(node) { - var result = undefined; - var text = ts.getTextOfNode(node, true); - var firstNonWhitespace = 0; - var lastNonWhitespace = -1; - for (var i = 0; i < text.length; i++) { - var c = text.charCodeAt(i); - if (ts.isLineBreak(c)) { - if (firstNonWhitespace !== -1 && (lastNonWhitespace - firstNonWhitespace + 1 > 0)) { - var part = text.substr(firstNonWhitespace, lastNonWhitespace - firstNonWhitespace + 1); - result = (result ? result + "\" + ' ' + \"" : "") + ts.escapeString(part); - } - firstNonWhitespace = -1; - } - else if (!ts.isWhiteSpace(c)) { - lastNonWhitespace = i; - if (firstNonWhitespace === -1) { - firstNonWhitespace = i; - } - } - } - if (firstNonWhitespace !== -1) { - var part = text.substr(firstNonWhitespace); - result = (result ? result + "\" + ' ' + \"" : "") + ts.escapeString(part); - } - if (result) { - result = result.replace(/&(\w+);/g, function (s, m) { - if (entities[m] !== undefined) { - return String.fromCharCode(entities[m]); - } - else { - return s; - } - }); - } - return result; - } - function getTextToEmit(node) { - switch (compilerOptions.jsx) { - case 2: - var text = trimReactWhitespaceAndApplyEntities(node); - if (text === undefined || text.length === 0) { - return undefined; - } - else { - return text; - } - case 1: - default: - return ts.getTextOfNode(node, true); - } - } - function emitJsxText(node) { - switch (compilerOptions.jsx) { - case 2: - write("\""); - write(trimReactWhitespaceAndApplyEntities(node)); - write("\""); - break; - case 1: - default: - writer.writeLiteral(ts.getTextOfNode(node, true)); - break; - } - } - function emitJsxExpression(node) { - if (node.expression) { - switch (compilerOptions.jsx) { - case 1: - default: - write("{"); - emit(node.expression); - write("}"); - break; - case 2: - emit(node.expression); - break; - } - } - } - function emitDirectivePrologues(statements, startWithNewLine) { - for (var i = 0; i < statements.length; ++i) { - if (ts.isPrologueDirective(statements[i])) { - if (startWithNewLine || i > 0) { - writeLine(); - } - emit(statements[i]); - } - else { - return i; - } - } - return statements.length; - } - function writeLines(text) { - var lines = text.split(/\r\n|\r|\n/g); - for (var i = 0; i < lines.length; ++i) { - var line = lines[i]; - if (line.length) { - writeLine(); - write(line); - } - } - } - function emitEmitHelpers(node) { - if (!compilerOptions.noEmitHelpers) { - if ((languageVersion < 2) && (!extendsEmitted && resolver.getNodeCheckFlags(node) & 8)) { - writeLines(extendsHelper); - extendsEmitted = true; - } - if (!decorateEmitted && resolver.getNodeCheckFlags(node) & 16) { - writeLines(decorateHelper); - if (compilerOptions.emitDecoratorMetadata) { - writeLines(metadataHelper); - } - decorateEmitted = true; - } - if (!paramEmitted && resolver.getNodeCheckFlags(node) & 32) { - writeLines(paramHelper); - paramEmitted = true; - } - if (!awaiterEmitted && resolver.getNodeCheckFlags(node) & 64) { - writeLines(awaiterHelper); - awaiterEmitted = true; - } - } - } - function emitSourceFileNode(node) { - writeLine(); - emitShebang(); - emitDetachedComments(node); - if (ts.isExternalModule(node) || compilerOptions.isolatedModules) { - var emitModule = moduleEmitDelegates[modulekind] || moduleEmitDelegates[1]; - emitModule(node); - } - else { - var startIndex = emitDirectivePrologues(node.statements, false); - externalImports = undefined; - exportSpecifiers = undefined; - exportEquals = undefined; - hasExportStars = false; - emitEmitHelpers(node); - emitCaptureThisForNodeIfNecessary(node); - emitLinesStartingAt(node.statements, startIndex); - emitTempDeclarations(true); - } - emitLeadingComments(node.endOfFileToken); - } - function emitNodeWithCommentsAndWithoutSourcemap(node) { - emitNodeConsideringCommentsOption(node, emitNodeWithoutSourceMap); - } - function emitNodeConsideringCommentsOption(node, emitNodeConsideringSourcemap) { - if (node) { - if (node.flags & 2) { - return emitCommentsOnNotEmittedNode(node); - } - if (isSpecializedCommentHandling(node)) { - return emitNodeWithoutSourceMap(node); - } - var emitComments_1 = shouldEmitLeadingAndTrailingComments(node); - if (emitComments_1) { - emitLeadingComments(node); - } - emitNodeConsideringSourcemap(node); - if (emitComments_1) { - emitTrailingComments(node); - } - } - } - function emitNodeWithoutSourceMap(node) { - if (node) { - emitJavaScriptWorker(node); - } - } - function isSpecializedCommentHandling(node) { - switch (node.kind) { - case 215: - case 213: - case 222: - case 221: - case 216: - case 227: - return true; - } - } - function shouldEmitLeadingAndTrailingComments(node) { - switch (node.kind) { - case 193: - return shouldEmitLeadingAndTrailingCommentsForVariableStatement(node); - case 218: - return shouldEmitModuleDeclaration(node); - case 217: - return shouldEmitEnumDeclaration(node); - } - ts.Debug.assert(!isSpecializedCommentHandling(node)); - if (node.kind !== 192 && - node.parent && - node.parent.kind === 174 && - node.parent.body === node && - compilerOptions.target <= 1) { - return false; - } - return true; - } - function emitJavaScriptWorker(node) { - switch (node.kind) { - case 69: - return emitIdentifier(node); - case 138: - return emitParameter(node); - case 143: - case 142: - return emitMethod(node); - case 145: - case 146: - return emitAccessor(node); - case 97: - return emitThis(node); - case 95: - return emitSuper(node); - case 93: - return write("null"); - case 99: - return write("true"); - case 84: - return write("false"); - case 8: - case 9: - case 10: - case 11: - case 12: - case 13: - case 14: - return emitLiteral(node); - case 183: - return emitTemplateExpression(node); - case 190: - return emitTemplateSpan(node); - case 233: - case 234: - return emitJsxElement(node); - case 236: - return emitJsxText(node); - case 240: - return emitJsxExpression(node); - case 135: - return emitQualifiedName(node); - case 161: - return emitObjectBindingPattern(node); - case 162: - return emitArrayBindingPattern(node); - case 163: - return emitBindingElement(node); - case 164: - return emitArrayLiteral(node); - case 165: - return emitObjectLiteral(node); - case 245: - return emitPropertyAssignment(node); - case 246: - return emitShorthandPropertyAssignment(node); - case 136: - return emitComputedPropertyName(node); - case 166: - return emitPropertyAccess(node); - case 167: - return emitIndexedAccess(node); - case 168: - return emitCallExpression(node); - case 169: - return emitNewExpression(node); - case 170: - return emitTaggedTemplateExpression(node); - case 171: - return emit(node.expression); - case 189: - return emit(node.expression); - case 172: - return emitParenExpression(node); - case 213: - case 173: - case 174: - return emitFunctionDeclaration(node); - case 175: - return emitDeleteExpression(node); - case 176: - return emitTypeOfExpression(node); - case 177: - return emitVoidExpression(node); - case 178: - return emitAwaitExpression(node); - case 179: - return emitPrefixUnaryExpression(node); - case 180: - return emitPostfixUnaryExpression(node); - case 181: - return emitBinaryExpression(node); - case 182: - return emitConditionalExpression(node); - case 185: - return emitSpreadElementExpression(node); - case 184: - return emitYieldExpression(node); - case 187: - return; - case 192: - case 219: - return emitBlock(node); - case 193: - return emitVariableStatement(node); - case 194: - return write(";"); - case 195: - return emitExpressionStatement(node); - case 196: - return emitIfStatement(node); - case 197: - return emitDoStatement(node); - case 198: - return emitWhileStatement(node); - case 199: - return emitForStatement(node); - case 201: - case 200: - return emitForInOrForOfStatement(node); - case 202: - case 203: - return emitBreakOrContinueStatement(node); - case 204: - return emitReturnStatement(node); - case 205: - return emitWithStatement(node); - case 206: - return emitSwitchStatement(node); - case 241: - case 242: - return emitCaseOrDefaultClause(node); - case 207: - return emitLabelledStatement(node); - case 208: - return emitThrowStatement(node); - case 209: - return emitTryStatement(node); - case 244: - return emitCatchClause(node); - case 210: - return emitDebuggerStatement(node); - case 211: - return emitVariableDeclaration(node); - case 186: - return emitClassExpression(node); - case 214: - return emitClassDeclaration(node); - case 215: - return emitInterfaceDeclaration(node); - case 217: - return emitEnumDeclaration(node); - case 247: - return emitEnumMember(node); - case 218: - return emitModuleDeclaration(node); - case 222: - return emitImportDeclaration(node); - case 221: - return emitImportEqualsDeclaration(node); - case 228: - return emitExportDeclaration(node); - case 227: - return emitExportAssignment(node); - case 248: - return emitSourceFileNode(node); - } - } - function hasDetachedComments(pos) { - return detachedCommentsInfo !== undefined && ts.lastOrUndefined(detachedCommentsInfo).nodePos === pos; - } - function getLeadingCommentsWithoutDetachedComments() { - var leadingComments = ts.getLeadingCommentRanges(currentSourceFile.text, ts.lastOrUndefined(detachedCommentsInfo).detachedCommentEndPos); - if (detachedCommentsInfo.length - 1) { - detachedCommentsInfo.pop(); - } - else { - detachedCommentsInfo = undefined; - } - return leadingComments; - } - function isPinnedComments(comment) { - return currentSourceFile.text.charCodeAt(comment.pos + 1) === 42 && - currentSourceFile.text.charCodeAt(comment.pos + 2) === 33; - } - function isTripleSlashComment(comment) { - if (currentSourceFile.text.charCodeAt(comment.pos + 1) === 47 && - comment.pos + 2 < comment.end && - currentSourceFile.text.charCodeAt(comment.pos + 2) === 47) { - var textSubStr = currentSourceFile.text.substring(comment.pos, comment.end); - return textSubStr.match(ts.fullTripleSlashReferencePathRegEx) || - textSubStr.match(ts.fullTripleSlashAMDReferencePathRegEx) ? - true : false; - } - return false; - } - function getLeadingCommentsToEmit(node) { - if (node.parent) { - if (node.parent.kind === 248 || node.pos !== node.parent.pos) { - if (hasDetachedComments(node.pos)) { - return getLeadingCommentsWithoutDetachedComments(); - } - else { - return ts.getLeadingCommentRangesOfNode(node, currentSourceFile); - } - } - } - } - function getTrailingCommentsToEmit(node) { - if (node.parent) { - if (node.parent.kind === 248 || node.end !== node.parent.end) { - return ts.getTrailingCommentRanges(currentSourceFile.text, node.end); - } - } - } - function emitCommentsOnNotEmittedNode(node) { - emitLeadingCommentsWorker(node, false); - } - function emitLeadingComments(node) { - return emitLeadingCommentsWorker(node, true); - } - function emitLeadingCommentsWorker(node, isEmittedNode) { - if (compilerOptions.removeComments) { - return; - } - var leadingComments; - if (isEmittedNode) { - leadingComments = getLeadingCommentsToEmit(node); - } - else { - if (node.pos === 0) { - leadingComments = ts.filter(getLeadingCommentsToEmit(node), isTripleSlashComment); - } - } - ts.emitNewLineBeforeLeadingComments(currentSourceFile, writer, node, leadingComments); - ts.emitComments(currentSourceFile, writer, leadingComments, true, newLine, writeComment); - } - function emitTrailingComments(node) { - if (compilerOptions.removeComments) { - return; - } - var trailingComments = getTrailingCommentsToEmit(node); - ts.emitComments(currentSourceFile, writer, trailingComments, false, newLine, writeComment); - } - function emitTrailingCommentsOfPosition(pos) { - if (compilerOptions.removeComments) { - return; - } - var trailingComments = ts.getTrailingCommentRanges(currentSourceFile.text, pos); - ts.emitComments(currentSourceFile, writer, trailingComments, true, newLine, writeComment); - } - function emitLeadingCommentsOfPositionWorker(pos) { - if (compilerOptions.removeComments) { - return; - } - var leadingComments; - if (hasDetachedComments(pos)) { - leadingComments = getLeadingCommentsWithoutDetachedComments(); - } - else { - leadingComments = ts.getLeadingCommentRanges(currentSourceFile.text, pos); - } - ts.emitNewLineBeforeLeadingComments(currentSourceFile, writer, { pos: pos, end: pos }, leadingComments); - ts.emitComments(currentSourceFile, writer, leadingComments, true, newLine, writeComment); - } - function emitDetachedComments(node) { - var leadingComments; - if (compilerOptions.removeComments) { - if (node.pos === 0) { - leadingComments = ts.filter(ts.getLeadingCommentRanges(currentSourceFile.text, node.pos), isPinnedComments); - } - } - else { - leadingComments = ts.getLeadingCommentRanges(currentSourceFile.text, node.pos); - } - if (leadingComments) { - var detachedComments = []; - var lastComment; - ts.forEach(leadingComments, function (comment) { - if (lastComment) { - var lastCommentLine = ts.getLineOfLocalPosition(currentSourceFile, lastComment.end); - var commentLine = ts.getLineOfLocalPosition(currentSourceFile, comment.pos); - if (commentLine >= lastCommentLine + 2) { - return detachedComments; - } - } - detachedComments.push(comment); - lastComment = comment; - }); - if (detachedComments.length) { - var lastCommentLine = ts.getLineOfLocalPosition(currentSourceFile, ts.lastOrUndefined(detachedComments).end); - var nodeLine = ts.getLineOfLocalPosition(currentSourceFile, ts.skipTrivia(currentSourceFile.text, node.pos)); - if (nodeLine >= lastCommentLine + 2) { - ts.emitNewLineBeforeLeadingComments(currentSourceFile, writer, node, leadingComments); - ts.emitComments(currentSourceFile, writer, detachedComments, true, newLine, writeComment); - var currentDetachedCommentInfo = { nodePos: node.pos, detachedCommentEndPos: ts.lastOrUndefined(detachedComments).end }; - if (detachedCommentsInfo) { - detachedCommentsInfo.push(currentDetachedCommentInfo); - } - else { - detachedCommentsInfo = [currentDetachedCommentInfo]; - } - } - } - } - } - function emitShebang() { - var shebang = ts.getShebang(currentSourceFile.text); - if (shebang) { - write(shebang); - } - } - var _a; - } - function emitFile(jsFilePath, sourceFile) { - emitJavaScript(jsFilePath, sourceFile); - if (compilerOptions.declaration) { - ts.writeDeclarationFile(jsFilePath, sourceFile, host, resolver, diagnostics); - } - } - } - ts.emitFiles = emitFiles; -})(ts || (ts = {})); -var ts; -(function (ts) { - ts.programTime = 0; - ts.emitTime = 0; - ts.ioReadTime = 0; - ts.ioWriteTime = 0; - var emptyArray = []; - ts.version = "1.8.0"; - function findConfigFile(searchPath) { - var fileName = "tsconfig.json"; - while (true) { - if (ts.sys.fileExists(fileName)) { - return fileName; - } - var parentPath = ts.getDirectoryPath(searchPath); - if (parentPath === searchPath) { - break; - } - searchPath = parentPath; - fileName = "../" + fileName; - } - return undefined; - } - ts.findConfigFile = findConfigFile; - function resolveTripleslashReference(moduleName, containingFile) { - var basePath = ts.getDirectoryPath(containingFile); - var referencedFileName = ts.isRootedDiskPath(moduleName) ? moduleName : ts.combinePaths(basePath, moduleName); - return ts.normalizePath(referencedFileName); - } - ts.resolveTripleslashReference = resolveTripleslashReference; - function resolveModuleName(moduleName, containingFile, compilerOptions, host) { - var moduleResolution = compilerOptions.moduleResolution !== undefined - ? compilerOptions.moduleResolution - : compilerOptions.module === 1 ? 2 : 1; - switch (moduleResolution) { - case 2: return nodeModuleNameResolver(moduleName, containingFile, host); - case 1: return classicNameResolver(moduleName, containingFile, compilerOptions, host); - } - } - ts.resolveModuleName = resolveModuleName; - function nodeModuleNameResolver(moduleName, containingFile, host) { - var containingDirectory = ts.getDirectoryPath(containingFile); - if (ts.getRootLength(moduleName) !== 0 || nameStartsWithDotSlashOrDotDotSlash(moduleName)) { - var failedLookupLocations = []; - var candidate = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName)); - var resolvedFileName = loadNodeModuleFromFile(candidate, failedLookupLocations, host); - if (resolvedFileName) { - return { resolvedModule: { resolvedFileName: resolvedFileName }, failedLookupLocations: failedLookupLocations }; - } - resolvedFileName = loadNodeModuleFromDirectory(candidate, failedLookupLocations, host); - return resolvedFileName - ? { resolvedModule: { resolvedFileName: resolvedFileName }, failedLookupLocations: failedLookupLocations } - : { resolvedModule: undefined, failedLookupLocations: failedLookupLocations }; - } - else { - return loadModuleFromNodeModules(moduleName, containingDirectory, host); - } - } - ts.nodeModuleNameResolver = nodeModuleNameResolver; - function loadNodeModuleFromFile(candidate, failedLookupLocation, host) { - return ts.forEach(ts.moduleFileExtensions, tryLoad); - function tryLoad(ext) { - var fileName = ts.fileExtensionIs(candidate, ext) ? candidate : candidate + ext; - if (host.fileExists(fileName)) { - return fileName; - } - else { - failedLookupLocation.push(fileName); - return undefined; - } - } - } - function loadNodeModuleFromDirectory(candidate, failedLookupLocation, host) { - var packageJsonPath = ts.combinePaths(candidate, "package.json"); - if (host.fileExists(packageJsonPath)) { - var jsonContent; - try { - var jsonText = host.readFile(packageJsonPath); - jsonContent = jsonText ? JSON.parse(jsonText) : { typings: undefined }; - } - catch (e) { - jsonContent = { typings: undefined }; - } - if (jsonContent.typings) { - var result = loadNodeModuleFromFile(ts.normalizePath(ts.combinePaths(candidate, jsonContent.typings)), failedLookupLocation, host); - if (result) { - return result; - } - } - } - else { - failedLookupLocation.push(packageJsonPath); - } - return loadNodeModuleFromFile(ts.combinePaths(candidate, "index"), failedLookupLocation, host); - } - function loadModuleFromNodeModules(moduleName, directory, host) { - var failedLookupLocations = []; - directory = ts.normalizeSlashes(directory); - while (true) { - var baseName = ts.getBaseFileName(directory); - if (baseName !== "node_modules") { - var nodeModulesFolder = ts.combinePaths(directory, "node_modules"); - var candidate = ts.normalizePath(ts.combinePaths(nodeModulesFolder, moduleName)); - var result = loadNodeModuleFromFile(candidate, failedLookupLocations, host); - if (result) { - return { resolvedModule: { resolvedFileName: result, isExternalLibraryImport: true }, failedLookupLocations: failedLookupLocations }; - } - result = loadNodeModuleFromDirectory(candidate, failedLookupLocations, host); - if (result) { - return { resolvedModule: { resolvedFileName: result, isExternalLibraryImport: true }, failedLookupLocations: failedLookupLocations }; - } - } - var parentPath = ts.getDirectoryPath(directory); - if (parentPath === directory) { - break; - } - directory = parentPath; - } - return { resolvedModule: undefined, failedLookupLocations: failedLookupLocations }; - } - function nameStartsWithDotSlashOrDotDotSlash(name) { - var i = name.lastIndexOf("./", 1); - return i === 0 || (i === 1 && name.charCodeAt(0) === 46); - } - function classicNameResolver(moduleName, containingFile, compilerOptions, host) { - if (moduleName.indexOf("!") != -1) { - return { resolvedModule: undefined, failedLookupLocations: [] }; - } - var searchPath = ts.getDirectoryPath(containingFile); - var searchName; - var failedLookupLocations = []; - var referencedSourceFile; - while (true) { - searchName = ts.normalizePath(ts.combinePaths(searchPath, moduleName)); - referencedSourceFile = ts.forEach(ts.supportedExtensions, function (extension) { - if (extension === ".tsx" && !compilerOptions.jsx) { - return undefined; - } - var candidate = searchName + extension; - if (host.fileExists(candidate)) { - return candidate; - } - else { - failedLookupLocations.push(candidate); - } - }); - if (referencedSourceFile) { - break; - } - var parentPath = ts.getDirectoryPath(searchPath); - if (parentPath === searchPath) { - break; - } - searchPath = parentPath; - } - return referencedSourceFile - ? { resolvedModule: { resolvedFileName: referencedSourceFile }, failedLookupLocations: failedLookupLocations } - : { resolvedModule: undefined, failedLookupLocations: failedLookupLocations }; - } - ts.classicNameResolver = classicNameResolver; - ts.defaultInitCompilerOptions = { - module: 1, - target: 0, - noImplicitAny: false, - outDir: "built", - rootDir: ".", - sourceMap: false - }; - function createCompilerHost(options, setParentNodes) { - var currentDirectory; - var existingDirectories = {}; - function getCanonicalFileName(fileName) { - return ts.sys.useCaseSensitiveFileNames ? fileName : fileName.toLowerCase(); - } - var unsupportedFileEncodingErrorCode = -2147024809; - function getSourceFile(fileName, languageVersion, onError) { - var text; - try { - var start = new Date().getTime(); - text = ts.sys.readFile(fileName, options.charset); - ts.ioReadTime += new Date().getTime() - start; - } - catch (e) { - if (onError) { - onError(e.number === unsupportedFileEncodingErrorCode - ? ts.createCompilerDiagnostic(ts.Diagnostics.Unsupported_file_encoding).messageText - : e.message); - } - text = ""; - } - return text !== undefined ? ts.createSourceFile(fileName, text, languageVersion, setParentNodes) : undefined; - } - function directoryExists(directoryPath) { - if (ts.hasProperty(existingDirectories, directoryPath)) { - return true; - } - if (ts.sys.directoryExists(directoryPath)) { - existingDirectories[directoryPath] = true; - return true; - } - return false; - } - function ensureDirectoriesExist(directoryPath) { - if (directoryPath.length > ts.getRootLength(directoryPath) && !directoryExists(directoryPath)) { - var parentDirectory = ts.getDirectoryPath(directoryPath); - ensureDirectoriesExist(parentDirectory); - ts.sys.createDirectory(directoryPath); - } - } - function writeFile(fileName, data, writeByteOrderMark, onError) { - try { - var start = new Date().getTime(); - ensureDirectoriesExist(ts.getDirectoryPath(ts.normalizePath(fileName))); - ts.sys.writeFile(fileName, data, writeByteOrderMark); - ts.ioWriteTime += new Date().getTime() - start; - } - catch (e) { - if (onError) { - onError(e.message); - } - } - } - var newLine = ts.getNewLineCharacter(options); - return { - getSourceFile: getSourceFile, - getDefaultLibFileName: function (options) { return ts.combinePaths(ts.getDirectoryPath(ts.normalizePath(ts.sys.getExecutingFilePath())), ts.getDefaultLibFileName(options)); }, - writeFile: writeFile, - getCurrentDirectory: function () { return currentDirectory || (currentDirectory = ts.sys.getCurrentDirectory()); }, - useCaseSensitiveFileNames: function () { return ts.sys.useCaseSensitiveFileNames; }, - getCanonicalFileName: getCanonicalFileName, - getNewLine: function () { return newLine; }, - fileExists: function (fileName) { return ts.sys.fileExists(fileName); }, - readFile: function (fileName) { return ts.sys.readFile(fileName); } - }; - } - ts.createCompilerHost = createCompilerHost; - function getPreEmitDiagnostics(program, sourceFile, cancellationToken) { - var diagnostics = program.getOptionsDiagnostics(cancellationToken).concat(program.getSyntacticDiagnostics(sourceFile, cancellationToken), program.getGlobalDiagnostics(cancellationToken), program.getSemanticDiagnostics(sourceFile, cancellationToken)); - if (program.getCompilerOptions().declaration) { - diagnostics.concat(program.getDeclarationDiagnostics(sourceFile, cancellationToken)); - } - return ts.sortAndDeduplicateDiagnostics(diagnostics); - } - ts.getPreEmitDiagnostics = getPreEmitDiagnostics; - function flattenDiagnosticMessageText(messageText, newLine) { - if (typeof messageText === "string") { - return messageText; - } - else { - var diagnosticChain = messageText; - var result = ""; - var indent = 0; - while (diagnosticChain) { - if (indent) { - result += newLine; - for (var i = 0; i < indent; i++) { - result += " "; - } - } - result += diagnosticChain.messageText; - indent++; - diagnosticChain = diagnosticChain.next; - } - return result; - } - } - ts.flattenDiagnosticMessageText = flattenDiagnosticMessageText; - function createProgram(rootNames, options, host, oldProgram) { - var program; - var files = []; - var fileProcessingDiagnostics = ts.createDiagnosticCollection(); - var programDiagnostics = ts.createDiagnosticCollection(); - var commonSourceDirectory; - var diagnosticsProducingTypeChecker; - var noDiagnosticsTypeChecker; - var classifiableNames; - var skipDefaultLib = options.noLib; - var start = new Date().getTime(); - host = host || createCompilerHost(options); - var resolveModuleNamesWorker = host.resolveModuleNames - ? (function (moduleNames, containingFile) { return host.resolveModuleNames(moduleNames, containingFile); }) - : (function (moduleNames, containingFile) { return ts.map(moduleNames, function (moduleName) { return resolveModuleName(moduleName, containingFile, options, host).resolvedModule; }); }); - var filesByName = ts.createFileMap(function (fileName) { return host.getCanonicalFileName(fileName); }); - if (oldProgram) { - var oldOptions = oldProgram.getCompilerOptions(); - if ((oldOptions.module !== options.module) || - (oldOptions.noResolve !== options.noResolve) || - (oldOptions.target !== options.target) || - (oldOptions.noLib !== options.noLib) || - (oldOptions.jsx !== options.jsx)) { - oldProgram = undefined; - } - } - if (!tryReuseStructureFromOldProgram()) { - ts.forEach(rootNames, function (name) { return processRootFile(name, false); }); - if (!skipDefaultLib) { - processRootFile(host.getDefaultLibFileName(options), true); - } - } - verifyCompilerOptions(); - oldProgram = undefined; - ts.programTime += new Date().getTime() - start; - program = { - getRootFileNames: function () { return rootNames; }, - getSourceFile: getSourceFile, - getSourceFiles: function () { return files; }, - getCompilerOptions: function () { return options; }, - getSyntacticDiagnostics: getSyntacticDiagnostics, - getOptionsDiagnostics: getOptionsDiagnostics, - getGlobalDiagnostics: getGlobalDiagnostics, - getSemanticDiagnostics: getSemanticDiagnostics, - getDeclarationDiagnostics: getDeclarationDiagnostics, - getTypeChecker: getTypeChecker, - getClassifiableNames: getClassifiableNames, - getDiagnosticsProducingTypeChecker: getDiagnosticsProducingTypeChecker, - getCommonSourceDirectory: function () { return commonSourceDirectory; }, - emit: emit, - getCurrentDirectory: function () { return host.getCurrentDirectory(); }, - getNodeCount: function () { return getDiagnosticsProducingTypeChecker().getNodeCount(); }, - getIdentifierCount: function () { return getDiagnosticsProducingTypeChecker().getIdentifierCount(); }, - getSymbolCount: function () { return getDiagnosticsProducingTypeChecker().getSymbolCount(); }, - getTypeCount: function () { return getDiagnosticsProducingTypeChecker().getTypeCount(); }, - getFileProcessingDiagnostics: function () { return fileProcessingDiagnostics; } - }; - return program; - function getClassifiableNames() { - if (!classifiableNames) { - getTypeChecker(); - classifiableNames = {}; - for (var _i = 0; _i < files.length; _i++) { - var sourceFile = files[_i]; - ts.copyMap(sourceFile.classifiableNames, classifiableNames); - } - } - return classifiableNames; - } - function tryReuseStructureFromOldProgram() { - if (!oldProgram) { - return false; - } - ts.Debug.assert(!oldProgram.structureIsReused); - var oldRootNames = oldProgram.getRootFileNames(); - if (!ts.arrayIsEqualTo(oldRootNames, rootNames)) { - return false; - } - var newSourceFiles = []; - var modifiedSourceFiles = []; - for (var _i = 0, _a = oldProgram.getSourceFiles(); _i < _a.length; _i++) { - var oldSourceFile = _a[_i]; - var newSourceFile = host.getSourceFile(oldSourceFile.fileName, options.target); - if (!newSourceFile) { - return false; - } - if (oldSourceFile !== newSourceFile) { - if (oldSourceFile.hasNoDefaultLib !== newSourceFile.hasNoDefaultLib) { - return false; - } - if (!ts.arrayIsEqualTo(oldSourceFile.referencedFiles, newSourceFile.referencedFiles, fileReferenceIsEqualTo)) { - return false; - } - collectExternalModuleReferences(newSourceFile); - if (!ts.arrayIsEqualTo(oldSourceFile.imports, newSourceFile.imports, moduleNameIsEqualTo)) { - return false; - } - if (resolveModuleNamesWorker) { - var moduleNames = ts.map(newSourceFile.imports, function (name) { return name.text; }); - var resolutions = resolveModuleNamesWorker(moduleNames, newSourceFile.fileName); - for (var i = 0; i < moduleNames.length; ++i) { - var newResolution = resolutions[i]; - var oldResolution = ts.getResolvedModule(oldSourceFile, moduleNames[i]); - var resolutionChanged = oldResolution - ? !newResolution || - oldResolution.resolvedFileName !== newResolution.resolvedFileName || - !!oldResolution.isExternalLibraryImport !== !!newResolution.isExternalLibraryImport - : newResolution; - if (resolutionChanged) { - return false; - } - } - } - newSourceFile.resolvedModules = oldSourceFile.resolvedModules; - modifiedSourceFiles.push(newSourceFile); - } - else { - newSourceFile = oldSourceFile; - } - newSourceFiles.push(newSourceFile); - } - for (var _b = 0; _b < newSourceFiles.length; _b++) { - var file = newSourceFiles[_b]; - filesByName.set(file.fileName, file); - } - files = newSourceFiles; - fileProcessingDiagnostics = oldProgram.getFileProcessingDiagnostics(); - for (var _c = 0; _c < modifiedSourceFiles.length; _c++) { - var modifiedFile = modifiedSourceFiles[_c]; - fileProcessingDiagnostics.reattachFileDiagnostics(modifiedFile); - } - oldProgram.structureIsReused = true; - return true; - } - function getEmitHost(writeFileCallback) { - return { - getCanonicalFileName: function (fileName) { return host.getCanonicalFileName(fileName); }, - getCommonSourceDirectory: program.getCommonSourceDirectory, - getCompilerOptions: program.getCompilerOptions, - getCurrentDirectory: function () { return host.getCurrentDirectory(); }, - getNewLine: function () { return host.getNewLine(); }, - getSourceFile: program.getSourceFile, - getSourceFiles: program.getSourceFiles, - writeFile: writeFileCallback || (function (fileName, data, writeByteOrderMark, onError) { return host.writeFile(fileName, data, writeByteOrderMark, onError); }) - }; - } - function getDiagnosticsProducingTypeChecker() { - return diagnosticsProducingTypeChecker || (diagnosticsProducingTypeChecker = ts.createTypeChecker(program, true)); - } - function getTypeChecker() { - return noDiagnosticsTypeChecker || (noDiagnosticsTypeChecker = ts.createTypeChecker(program, false)); - } - function emit(sourceFile, writeFileCallback, cancellationToken) { - var _this = this; - return runWithCancellationToken(function () { return emitWorker(_this, sourceFile, writeFileCallback, cancellationToken); }); - } - function emitWorker(program, sourceFile, writeFileCallback, cancellationToken) { - if (options.noEmitOnError && getPreEmitDiagnostics(program, undefined, cancellationToken).length > 0) { - return { diagnostics: [], sourceMaps: undefined, emitSkipped: true }; - } - var emitResolver = getDiagnosticsProducingTypeChecker().getEmitResolver((options.outFile || options.out) ? undefined : sourceFile); - var start = new Date().getTime(); - var emitResult = ts.emitFiles(emitResolver, getEmitHost(writeFileCallback), sourceFile); - ts.emitTime += new Date().getTime() - start; - return emitResult; - } - function getSourceFile(fileName) { - return filesByName.get(fileName) || filesByName.get(ts.getNormalizedAbsolutePath(fileName, host.getCurrentDirectory())); - } - function getDiagnosticsHelper(sourceFile, getDiagnostics, cancellationToken) { - if (sourceFile) { - return getDiagnostics(sourceFile, cancellationToken); - } - var allDiagnostics = []; - ts.forEach(program.getSourceFiles(), function (sourceFile) { - if (cancellationToken) { - cancellationToken.throwIfCancellationRequested(); - } - ts.addRange(allDiagnostics, getDiagnostics(sourceFile, cancellationToken)); - }); - return ts.sortAndDeduplicateDiagnostics(allDiagnostics); - } - function getSyntacticDiagnostics(sourceFile, cancellationToken) { - return getDiagnosticsHelper(sourceFile, getSyntacticDiagnosticsForFile, cancellationToken); - } - function getSemanticDiagnostics(sourceFile, cancellationToken) { - return getDiagnosticsHelper(sourceFile, getSemanticDiagnosticsForFile, cancellationToken); - } - function getDeclarationDiagnostics(sourceFile, cancellationToken) { - return getDiagnosticsHelper(sourceFile, getDeclarationDiagnosticsForFile, cancellationToken); - } - function getSyntacticDiagnosticsForFile(sourceFile, cancellationToken) { - return sourceFile.parseDiagnostics; - } - function runWithCancellationToken(func) { - try { - return func(); - } - catch (e) { - if (e instanceof ts.OperationCanceledException) { - noDiagnosticsTypeChecker = undefined; - diagnosticsProducingTypeChecker = undefined; - } - throw e; - } - } - function getSemanticDiagnosticsForFile(sourceFile, cancellationToken) { - return runWithCancellationToken(function () { - var typeChecker = getDiagnosticsProducingTypeChecker(); - ts.Debug.assert(!!sourceFile.bindDiagnostics); - var bindDiagnostics = sourceFile.bindDiagnostics; - var checkDiagnostics = typeChecker.getDiagnostics(sourceFile, cancellationToken); - var fileProcessingDiagnosticsInFile = fileProcessingDiagnostics.getDiagnostics(sourceFile.fileName); - var programDiagnosticsInFile = programDiagnostics.getDiagnostics(sourceFile.fileName); - return bindDiagnostics.concat(checkDiagnostics).concat(fileProcessingDiagnosticsInFile).concat(programDiagnosticsInFile); - }); - } - function getDeclarationDiagnosticsForFile(sourceFile, cancellationToken) { - return runWithCancellationToken(function () { - if (!ts.isDeclarationFile(sourceFile)) { - var resolver = getDiagnosticsProducingTypeChecker().getEmitResolver(sourceFile, cancellationToken); - var writeFile_1 = function () { }; - return ts.getDeclarationDiagnostics(getEmitHost(writeFile_1), resolver, sourceFile); - } - }); - } - function getOptionsDiagnostics() { - var allDiagnostics = []; - ts.addRange(allDiagnostics, fileProcessingDiagnostics.getGlobalDiagnostics()); - ts.addRange(allDiagnostics, programDiagnostics.getGlobalDiagnostics()); - return ts.sortAndDeduplicateDiagnostics(allDiagnostics); - } - function getGlobalDiagnostics() { - var allDiagnostics = []; - ts.addRange(allDiagnostics, getDiagnosticsProducingTypeChecker().getGlobalDiagnostics()); - return ts.sortAndDeduplicateDiagnostics(allDiagnostics); - } - function hasExtension(fileName) { - return ts.getBaseFileName(fileName).indexOf(".") >= 0; - } - function processRootFile(fileName, isDefaultLib) { - processSourceFile(ts.normalizePath(fileName), isDefaultLib); - } - function fileReferenceIsEqualTo(a, b) { - return a.fileName === b.fileName; - } - function moduleNameIsEqualTo(a, b) { - return a.text === b.text; - } - function collectExternalModuleReferences(file) { - if (file.imports) { - return; - } - var imports; - for (var _i = 0, _a = file.statements; _i < _a.length; _i++) { - var node = _a[_i]; - collect(node, true); - } - file.imports = imports || emptyArray; - function collect(node, allowRelativeModuleNames) { - switch (node.kind) { - case 222: - case 221: - case 228: - var moduleNameExpr = ts.getExternalModuleName(node); - if (!moduleNameExpr || moduleNameExpr.kind !== 9) { - break; - } - if (!moduleNameExpr.text) { - break; - } - if (allowRelativeModuleNames || !ts.isExternalModuleNameRelative(moduleNameExpr.text)) { - (imports || (imports = [])).push(moduleNameExpr); - } - break; - case 218: - if (node.name.kind === 9 && (node.flags & 2 || ts.isDeclarationFile(file))) { - ts.forEachChild(node.body, function (node) { - collect(node, false); - }); - } - break; - } - } - } - function processSourceFile(fileName, isDefaultLib, refFile, refPos, refEnd) { - var diagnosticArgument; - var diagnostic; - if (hasExtension(fileName)) { - if (!options.allowNonTsExtensions && !ts.forEach(ts.supportedExtensions, function (extension) { return ts.fileExtensionIs(host.getCanonicalFileName(fileName), extension); })) { - diagnostic = ts.Diagnostics.File_0_has_unsupported_extension_The_only_supported_extensions_are_1; - diagnosticArgument = [fileName, "'" + ts.supportedExtensions.join("', '") + "'"]; - } - else if (!findSourceFile(fileName, isDefaultLib, refFile, refPos, refEnd)) { - diagnostic = ts.Diagnostics.File_0_not_found; - diagnosticArgument = [fileName]; - } - else if (refFile && host.getCanonicalFileName(fileName) === host.getCanonicalFileName(refFile.fileName)) { - diagnostic = ts.Diagnostics.A_file_cannot_have_a_reference_to_itself; - diagnosticArgument = [fileName]; - } - } - else { - var nonTsFile = options.allowNonTsExtensions && findSourceFile(fileName, isDefaultLib, refFile, refPos, refEnd); - if (!nonTsFile) { - if (options.allowNonTsExtensions) { - diagnostic = ts.Diagnostics.File_0_not_found; - diagnosticArgument = [fileName]; - } - else if (!ts.forEach(ts.supportedExtensions, function (extension) { return findSourceFile(fileName + extension, isDefaultLib, refFile, refPos, refEnd); })) { - diagnostic = ts.Diagnostics.File_0_not_found; - fileName += ".ts"; - diagnosticArgument = [fileName]; - } - } - } - if (diagnostic) { - if (refFile !== undefined && refEnd !== undefined && refPos !== undefined) { - fileProcessingDiagnostics.add(ts.createFileDiagnostic.apply(void 0, [refFile, refPos, refEnd - refPos, diagnostic].concat(diagnosticArgument))); - } - else { - fileProcessingDiagnostics.add(ts.createCompilerDiagnostic.apply(void 0, [diagnostic].concat(diagnosticArgument))); - } - } - } - function findSourceFile(fileName, isDefaultLib, refFile, refPos, refEnd) { - if (filesByName.contains(fileName)) { - return getSourceFileFromCache(fileName, false); - } - var normalizedAbsolutePath = ts.getNormalizedAbsolutePath(fileName, host.getCurrentDirectory()); - if (filesByName.contains(normalizedAbsolutePath)) { - var file_1 = getSourceFileFromCache(normalizedAbsolutePath, true); - filesByName.set(fileName, file_1); - return file_1; - } - var file = host.getSourceFile(fileName, options.target, function (hostErrorMessage) { - if (refFile !== undefined && refPos !== undefined && refEnd !== undefined) { - fileProcessingDiagnostics.add(ts.createFileDiagnostic(refFile, refPos, refEnd - refPos, ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage)); - } - else { - fileProcessingDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage)); - } - }); - filesByName.set(fileName, file); - if (file) { - skipDefaultLib = skipDefaultLib || file.hasNoDefaultLib; - filesByName.set(normalizedAbsolutePath, file); - var basePath = ts.getDirectoryPath(fileName); - if (!options.noResolve) { - processReferencedFiles(file, basePath); - } - processImportedModules(file, basePath); - if (isDefaultLib) { - file.isDefaultLib = true; - files.unshift(file); - } - else { - files.push(file); - } - } - return file; - function getSourceFileFromCache(fileName, useAbsolutePath) { - var file = filesByName.get(fileName); - if (file && host.useCaseSensitiveFileNames()) { - var sourceFileName = useAbsolutePath ? ts.getNormalizedAbsolutePath(file.fileName, host.getCurrentDirectory()) : file.fileName; - if (ts.normalizeSlashes(fileName) !== ts.normalizeSlashes(sourceFileName)) { - if (refFile !== undefined && refPos !== undefined && refEnd !== undefined) { - fileProcessingDiagnostics.add(ts.createFileDiagnostic(refFile, refPos, refEnd - refPos, ts.Diagnostics.File_name_0_differs_from_already_included_file_name_1_only_in_casing, fileName, sourceFileName)); - } - else { - fileProcessingDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.File_name_0_differs_from_already_included_file_name_1_only_in_casing, fileName, sourceFileName)); - } - } - } - return file; - } - } - function processReferencedFiles(file, basePath) { - ts.forEach(file.referencedFiles, function (ref) { - var referencedFileName = resolveTripleslashReference(ref.fileName, file.fileName); - processSourceFile(referencedFileName, false, file, ref.pos, ref.end); - }); - } - function processImportedModules(file, basePath) { - collectExternalModuleReferences(file); - if (file.imports.length) { - file.resolvedModules = {}; - var moduleNames = ts.map(file.imports, function (name) { return name.text; }); - var resolutions = resolveModuleNamesWorker(moduleNames, file.fileName); - for (var i = 0; i < file.imports.length; ++i) { - var resolution = resolutions[i]; - ts.setResolvedModule(file, moduleNames[i], resolution); - if (resolution && !options.noResolve) { - var importedFile = findModuleSourceFile(resolution.resolvedFileName, file.imports[i]); - if (importedFile && resolution.isExternalLibraryImport) { - if (!ts.isExternalModule(importedFile)) { - var start_2 = ts.getTokenPosOfNode(file.imports[i], file); - fileProcessingDiagnostics.add(ts.createFileDiagnostic(file, start_2, file.imports[i].end - start_2, ts.Diagnostics.Exported_external_package_typings_file_0_is_not_a_module_Please_contact_the_package_author_to_update_the_package_definition, importedFile.fileName)); - } - else if (!ts.fileExtensionIs(importedFile.fileName, ".d.ts")) { - var start_3 = ts.getTokenPosOfNode(file.imports[i], file); - fileProcessingDiagnostics.add(ts.createFileDiagnostic(file, start_3, file.imports[i].end - start_3, ts.Diagnostics.Exported_external_package_typings_can_only_be_in_d_ts_files_Please_contact_the_package_author_to_update_the_package_definition)); - } - else if (importedFile.referencedFiles.length) { - var firstRef = importedFile.referencedFiles[0]; - fileProcessingDiagnostics.add(ts.createFileDiagnostic(importedFile, firstRef.pos, firstRef.end - firstRef.pos, ts.Diagnostics.Exported_external_package_typings_file_cannot_contain_tripleslash_references_Please_contact_the_package_author_to_update_the_package_definition)); - } - } - } - } - } - else { - file.resolvedModules = undefined; - } - return; - function findModuleSourceFile(fileName, nameLiteral) { - return findSourceFile(fileName, false, file, ts.skipTrivia(file.text, nameLiteral.pos), nameLiteral.end); - } - } - function computeCommonSourceDirectory(sourceFiles) { - var commonPathComponents; - var currentDirectory = host.getCurrentDirectory(); - ts.forEach(files, function (sourceFile) { - if (ts.isDeclarationFile(sourceFile)) { - return; - } - var sourcePathComponents = ts.getNormalizedPathComponents(sourceFile.fileName, currentDirectory); - sourcePathComponents.pop(); - if (!commonPathComponents) { - commonPathComponents = sourcePathComponents; - return; - } - for (var i = 0, n = Math.min(commonPathComponents.length, sourcePathComponents.length); i < n; i++) { - if (commonPathComponents[i] !== sourcePathComponents[i]) { - if (i === 0) { - programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_find_the_common_subdirectory_path_for_the_input_files)); - return; - } - commonPathComponents.length = i; - break; - } - } - if (sourcePathComponents.length < commonPathComponents.length) { - commonPathComponents.length = sourcePathComponents.length; - } - }); - return ts.getNormalizedPathFromPathComponents(commonPathComponents); - } - function checkSourceFilesBelongToPath(sourceFiles, rootDirectory) { - var allFilesBelongToPath = true; - if (sourceFiles) { - var currentDirectory = host.getCurrentDirectory(); - var absoluteRootDirectoryPath = host.getCanonicalFileName(ts.getNormalizedAbsolutePath(rootDirectory, currentDirectory)); - for (var _i = 0; _i < sourceFiles.length; _i++) { - var sourceFile = sourceFiles[_i]; - if (!ts.isDeclarationFile(sourceFile)) { - var absoluteSourceFilePath = host.getCanonicalFileName(ts.getNormalizedAbsolutePath(sourceFile.fileName, currentDirectory)); - if (absoluteSourceFilePath.indexOf(absoluteRootDirectoryPath) !== 0) { - programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.File_0_is_not_under_rootDir_1_rootDir_is_expected_to_contain_all_source_files, sourceFile.fileName, options.rootDir)); - allFilesBelongToPath = false; - } - } - } - } - return allFilesBelongToPath; - } - function verifyCompilerOptions() { - if (options.isolatedModules) { - if (options.declaration) { - programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "declaration", "isolatedModules")); - } - if (options.noEmitOnError) { - programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "noEmitOnError", "isolatedModules")); - } - if (options.out) { - programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "out", "isolatedModules")); - } - if (options.outFile) { - programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "outFile", "isolatedModules")); - } - } - if (options.inlineSourceMap) { - if (options.sourceMap) { - programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "sourceMap", "inlineSourceMap")); - } - if (options.mapRoot) { - programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "mapRoot", "inlineSourceMap")); - } - if (options.sourceRoot) { - programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "sourceRoot", "inlineSourceMap")); - } - } - if (options.inlineSources) { - if (!options.sourceMap && !options.inlineSourceMap) { - programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_inlineSources_can_only_be_used_when_either_option_inlineSourceMap_or_option_sourceMap_is_provided)); - } - } - if (options.out && options.outFile) { - programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "out", "outFile")); - } - if (!options.sourceMap && (options.mapRoot || options.sourceRoot)) { - if (options.mapRoot) { - programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "mapRoot", "sourceMap")); - } - if (options.sourceRoot) { - programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "sourceRoot", "sourceMap")); - } - return; - } - var languageVersion = options.target || 0; - var outFile = options.outFile || options.out; - var firstExternalModuleSourceFile = ts.forEach(files, function (f) { return ts.isExternalModule(f) ? f : undefined; }); - if (options.isolatedModules) { - if (!options.module && languageVersion < 2) { - 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; }); - if (firstNonExternalModuleSourceFile) { - var span = ts.getErrorSpanForNode(firstNonExternalModuleSourceFile, firstNonExternalModuleSourceFile); - programDiagnostics.add(ts.createFileDiagnostic(firstNonExternalModuleSourceFile, span.start, span.length, ts.Diagnostics.Cannot_compile_namespaces_when_the_isolatedModules_flag_is_provided)); - } - } - else if (firstExternalModuleSourceFile && languageVersion < 2 && !options.module) { - var span = ts.getErrorSpanForNode(firstExternalModuleSourceFile, firstExternalModuleSourceFile.externalModuleIndicator); - programDiagnostics.add(ts.createFileDiagnostic(firstExternalModuleSourceFile, span.start, span.length, ts.Diagnostics.Cannot_compile_modules_unless_the_module_flag_is_provided)); - } - if (options.module === 5 && languageVersion < 2) { - programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_compile_modules_into_es2015_when_targeting_ES5_or_lower)); - } - if (options.outDir || - options.sourceRoot || - (options.mapRoot && - (!outFile || firstExternalModuleSourceFile !== undefined))) { - if (options.rootDir && checkSourceFilesBelongToPath(files, options.rootDir)) { - commonSourceDirectory = ts.getNormalizedAbsolutePath(options.rootDir, host.getCurrentDirectory()); - } - else { - commonSourceDirectory = computeCommonSourceDirectory(files); - } - if (commonSourceDirectory && commonSourceDirectory[commonSourceDirectory.length - 1] !== ts.directorySeparator) { - commonSourceDirectory += ts.directorySeparator; - } - } - if (options.noEmit) { - if (options.out) { - programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "noEmit", "out")); - } - if (options.outFile) { - programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "noEmit", "outFile")); - } - if (options.outDir) { - programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "noEmit", "outDir")); - } - if (options.declaration) { - programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "noEmit", "declaration")); - } - } - if (options.emitDecoratorMetadata && - !options.experimentalDecorators) { - programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "emitDecoratorMetadata", "experimentalDecorators")); - } - } - } - ts.createProgram = createProgram; -})(ts || (ts = {})); -var ts; -(function (ts) { - ts.optionDeclarations = [ - { - name: "charset", - type: "string" - }, - { - name: "declaration", - shortName: "d", - type: "boolean", - description: ts.Diagnostics.Generates_corresponding_d_ts_file - }, - { - name: "diagnostics", - type: "boolean" - }, - { - name: "emitBOM", - type: "boolean" - }, - { - name: "help", - shortName: "h", - type: "boolean", - description: ts.Diagnostics.Print_this_message - }, - { - 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: { - "preserve": 1, - "react": 2 - }, - paramType: ts.Diagnostics.KIND, - description: ts.Diagnostics.Specify_JSX_code_generation_Colon_preserve_or_react, - error: ts.Diagnostics.Argument_for_jsx_must_be_preserve_or_react - }, - { - name: "listFiles", - type: "boolean" - }, - { - name: "locale", - type: "string" - }, - { - name: "mapRoot", - type: "string", - isFilePath: true, - description: ts.Diagnostics.Specifies_the_location_where_debugger_should_locate_map_files_instead_of_generated_locations, - paramType: ts.Diagnostics.LOCATION - }, - { - name: "module", - shortName: "m", - type: { - "commonjs": 1, - "amd": 2, - "system": 4, - "umd": 3, - "es6": 5, - "es2015": 5 - }, - description: ts.Diagnostics.Specify_module_code_generation_Colon_commonjs_amd_system_umd_or_es2015, - paramType: ts.Diagnostics.KIND, - error: ts.Diagnostics.Argument_for_module_option_must_be_commonjs_amd_system_umd_or_es2015 - }, - { - name: "newLine", - type: { - "crlf": 0, - "lf": 1 - }, - description: ts.Diagnostics.Specifies_the_end_of_line_sequence_to_be_used_when_emitting_files_Colon_CRLF_dos_or_LF_unix, - paramType: ts.Diagnostics.NEWLINE, - error: ts.Diagnostics.Argument_for_newLine_option_must_be_CRLF_or_LF - }, - { - 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: "noImplicitAny", - type: "boolean", - description: ts.Diagnostics.Raise_error_on_expressions_and_declarations_with_an_implied_any_type - }, - { - name: "noLib", - type: "boolean" - }, - { - name: "noResolve", - type: "boolean" - }, - { - name: "skipDefaultLibCheck", - type: "boolean" - }, - { - 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: "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, - description: ts.Diagnostics.Specifies_the_root_directory_of_input_files_Use_to_control_the_output_directory_structure_with_outDir, - paramType: ts.Diagnostics.LOCATION - }, - { - name: "isolatedModules", - type: "boolean" - }, - { - name: "sourceMap", - type: "boolean", - description: ts.Diagnostics.Generates_corresponding_map_file - }, - { - name: "sourceRoot", - type: "string", - isFilePath: true, - description: ts.Diagnostics.Specifies_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: { - "es3": 0, - "es5": 1, - "es6": 2, - "es2015": 2 - }, - description: ts.Diagnostics.Specify_ECMAScript_target_version_Colon_ES3_default_ES5_or_ES2015_experimental, - paramType: ts.Diagnostics.VERSION, - error: ts.Diagnostics.Argument_for_target_option_must_be_ES3_ES5_or_ES2015 - }, - { - 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: { - "node": 2, - "classic": 1 - }, - description: ts.Diagnostics.Specifies_module_resolution_strategy_Colon_node_Node_js_or_classic_TypeScript_pre_1_6, - error: ts.Diagnostics.Argument_for_moduleResolution_option_must_be_node_or_classic - } - ]; - var optionNameMapCache; - function getOptionNameMap() { - if (optionNameMapCache) { - return optionNameMapCache; - } - var optionNameMap = {}; - var shortOptionNames = {}; - 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 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++]; - 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 (ts.hasProperty(shortOptionNames, s)) { - s = shortOptionNames[s]; - } - if (ts.hasProperty(optionNameMap, s)) { - var opt = optionNameMap[s]; - 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++]); - break; - case "boolean": - options[opt.name] = true; - break; - case "string": - options[opt.name] = args[i++] || ""; - break; - default: - var map_2 = opt.type; - var key = (args[i++] || "").toLowerCase(); - if (ts.hasProperty(map_2, key)) { - options[opt.name] = map_2[key]; - } - else { - errors.push(ts.createCompilerDiagnostic(opt.error)); - } - } - } - 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) { - try { - return { config: /\S/.test(jsonText) ? JSON.parse(jsonText) : {} }; - } - catch (e) { - return { error: ts.createCompilerDiagnostic(ts.Diagnostics.Failed_to_parse_file_0_Colon_1, fileName, e.message) }; - } - } - ts.parseConfigFileTextToJson = parseConfigFileTextToJson; - function parseJsonConfigFileContent(json, host, basePath) { - var _a = convertCompilerOptionsFromJson(json["compilerOptions"], basePath), options = _a.options, errors = _a.errors; - return { - options: options, - fileNames: getFileNames(), - errors: errors - }; - function getFileNames() { - var fileNames = []; - if (ts.hasProperty(json, "files")) { - if (json["files"] instanceof Array) { - fileNames = ts.map(json["files"], function (s) { return ts.combinePaths(basePath, s); }); - } - else { - errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Compiler_option_0_requires_a_value_of_type_1, "files", "Array")); - } - } - else { - var exclude = json["exclude"] instanceof Array ? ts.map(json["exclude"], ts.normalizeSlashes) : undefined; - var sysFiles = host.readDirectory(basePath, ".ts", exclude).concat(host.readDirectory(basePath, ".tsx", exclude)); - for (var i = 0; i < sysFiles.length; i++) { - var name_28 = sysFiles[i]; - if (ts.fileExtensionIs(name_28, ".d.ts")) { - var baseName = name_28.substr(0, name_28.length - ".d.ts".length); - if (!ts.contains(sysFiles, baseName + ".tsx") && !ts.contains(sysFiles, baseName + ".ts")) { - fileNames.push(name_28); - } - } - else if (ts.fileExtensionIs(name_28, ".ts")) { - if (!ts.contains(sysFiles, name_28 + "x")) { - fileNames.push(name_28); - } - } - else { - fileNames.push(name_28); - } - } - } - return fileNames; - } - } - ts.parseJsonConfigFileContent = parseJsonConfigFileContent; - function convertCompilerOptionsFromJson(jsonOptions, basePath) { - var options = {}; - var errors = []; - if (!jsonOptions) { - return { options: options, errors: errors }; - } - var optionNameMap = ts.arrayToMap(ts.optionDeclarations, function (opt) { return opt.name; }); - for (var id in jsonOptions) { - if (ts.hasProperty(optionNameMap, id)) { - var opt = optionNameMap[id]; - var optType = opt.type; - var value = jsonOptions[id]; - var expectedType = typeof optType === "string" ? optType : "string"; - if (typeof value === expectedType) { - if (typeof optType !== "string") { - var key = value.toLowerCase(); - if (ts.hasProperty(optType, key)) { - value = optType[key]; - } - else { - errors.push(ts.createCompilerDiagnostic(opt.error)); - value = 0; - } - } - if (opt.isFilePath) { - value = ts.normalizePath(ts.combinePaths(basePath, value)); - if (value === "") { - value = "."; - } - } - options[opt.name] = value; - } - else { - errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Compiler_option_0_requires_a_value_of_type_1, id, expectedType)); - } - } - else { - errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Unknown_compiler_option_0, id)); - } - } - return { options: options, errors: errors }; - } - ts.convertCompilerOptionsFromJson = convertCompilerOptionsFromJson; -})(ts || (ts = {})); -var ts; -(function (ts) { - function validateLocaleAndSetLanguage(locale, errors) { - var matchResult = /^([a-z]+)([_\-]([a-z]+))?$/.exec(locale.toLowerCase()); - if (!matchResult) { - errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Locale_must_be_of_the_form_language_or_language_territory_For_example_0_or_1, "en", "ja-jp")); - return false; - } - var language = matchResult[1]; - var territory = matchResult[3]; - if (!trySetLanguageAndTerritory(language, territory, errors) && - !trySetLanguageAndTerritory(language, undefined, errors)) { - errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Unsupported_locale_0, locale)); - return false; - } - return true; - } - function trySetLanguageAndTerritory(language, territory, errors) { - var compilerFilePath = ts.normalizePath(ts.sys.getExecutingFilePath()); - var containingDirectoryPath = ts.getDirectoryPath(compilerFilePath); - var filePath = ts.combinePaths(containingDirectoryPath, language); - if (territory) { - filePath = filePath + "-" + territory; - } - filePath = ts.sys.resolvePath(ts.combinePaths(filePath, "diagnosticMessages.generated.json")); - if (!ts.sys.fileExists(filePath)) { - return false; - } - var fileContents = ""; - try { - fileContents = ts.sys.readFile(filePath); - } - catch (e) { - errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Unable_to_open_file_0, filePath)); - return false; - } - try { - ts.localizedDiagnosticMessages = JSON.parse(fileContents); - } - catch (e) { - errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Corrupted_locale_file_0, filePath)); - return false; - } - return true; - } - function countLines(program) { - var count = 0; - ts.forEach(program.getSourceFiles(), function (file) { - count += ts.getLineStarts(file).length; - }); - return count; - } - function getDiagnosticText(message) { - var args = []; - for (var _i = 1; _i < arguments.length; _i++) { - args[_i - 1] = arguments[_i]; - } - var diagnostic = ts.createCompilerDiagnostic.apply(undefined, arguments); - return diagnostic.messageText; - } - function reportDiagnostic(diagnostic) { - var output = ""; - if (diagnostic.file) { - var loc = ts.getLineAndCharacterOfPosition(diagnostic.file, diagnostic.start); - output += diagnostic.file.fileName + "(" + (loc.line + 1) + "," + (loc.character + 1) + "): "; - } - var category = ts.DiagnosticCategory[diagnostic.category].toLowerCase(); - output += category + " TS" + diagnostic.code + ": " + ts.flattenDiagnosticMessageText(diagnostic.messageText, ts.sys.newLine) + ts.sys.newLine; - ts.sys.write(output); - } - function reportDiagnostics(diagnostics) { - for (var i = 0; i < diagnostics.length; i++) { - reportDiagnostic(diagnostics[i]); - } - } - function reportWatchDiagnostic(diagnostic) { - var output = new Date().toLocaleTimeString() + " - "; - if (diagnostic.file) { - var loc = ts.getLineAndCharacterOfPosition(diagnostic.file, diagnostic.start); - output += diagnostic.file.fileName + "(" + (loc.line + 1) + "," + (loc.character + 1) + "): "; - } - output += "" + ts.flattenDiagnosticMessageText(diagnostic.messageText, ts.sys.newLine) + ts.sys.newLine; - ts.sys.write(output); - } - function padLeft(s, length) { - while (s.length < length) { - s = " " + s; - } - return s; - } - function padRight(s, length) { - while (s.length < length) { - s = s + " "; - } - return s; - } - function reportStatisticalValue(name, value) { - ts.sys.write(padRight(name + ":", 12) + padLeft(value.toString(), 10) + ts.sys.newLine); - } - function reportCountStatistic(name, count) { - reportStatisticalValue(name, "" + count); - } - function reportTimeStatistic(name, time) { - reportStatisticalValue(name, (time / 1000).toFixed(2) + "s"); - } - function isJSONSupported() { - return typeof JSON === "object" && typeof JSON.parse === "function"; - } - function executeCommandLine(args) { - var commandLine = ts.parseCommandLine(args); - var configFileName; - var cachedConfigFileText; - var configFileWatcher; - var directoryWatcher; - var cachedProgram; - var rootFileNames; - var compilerOptions; - var compilerHost; - var hostGetSourceFile; - var timerHandleForRecompilation; - var timerHandleForDirectoryChanges; - var cachedExistingFiles; - var hostFileExists; - if (commandLine.options.locale) { - if (!isJSONSupported()) { - reportDiagnostic(ts.createCompilerDiagnostic(ts.Diagnostics.The_current_host_does_not_support_the_0_option, "--locale")); - return ts.sys.exit(ts.ExitStatus.DiagnosticsPresent_OutputsSkipped); - } - validateLocaleAndSetLanguage(commandLine.options.locale, commandLine.errors); - } - if (commandLine.errors.length > 0) { - reportDiagnostics(commandLine.errors); - return ts.sys.exit(ts.ExitStatus.DiagnosticsPresent_OutputsSkipped); - } - if (commandLine.options.init) { - writeConfigFile(commandLine.options, commandLine.fileNames); - return ts.sys.exit(ts.ExitStatus.Success); - } - if (commandLine.options.version) { - reportDiagnostic(ts.createCompilerDiagnostic(ts.Diagnostics.Version_0, ts.version)); - return ts.sys.exit(ts.ExitStatus.Success); - } - if (commandLine.options.help) { - printVersion(); - printHelp(); - return ts.sys.exit(ts.ExitStatus.Success); - } - if (commandLine.options.project) { - if (!isJSONSupported()) { - reportDiagnostic(ts.createCompilerDiagnostic(ts.Diagnostics.The_current_host_does_not_support_the_0_option, "--project")); - return ts.sys.exit(ts.ExitStatus.DiagnosticsPresent_OutputsSkipped); - } - configFileName = ts.normalizePath(ts.combinePaths(commandLine.options.project, "tsconfig.json")); - if (commandLine.fileNames.length !== 0) { - reportDiagnostic(ts.createCompilerDiagnostic(ts.Diagnostics.Option_project_cannot_be_mixed_with_source_files_on_a_command_line)); - return ts.sys.exit(ts.ExitStatus.DiagnosticsPresent_OutputsSkipped); - } - } - else if (commandLine.fileNames.length === 0 && isJSONSupported()) { - var searchPath = ts.normalizePath(ts.sys.getCurrentDirectory()); - configFileName = ts.findConfigFile(searchPath); - } - if (commandLine.fileNames.length === 0 && !configFileName) { - printVersion(); - printHelp(); - return ts.sys.exit(ts.ExitStatus.Success); - } - if (commandLine.options.watch && commandLine.options.hasOwnProperty("watch")) { - if (!ts.sys.watchFile) { - reportDiagnostic(ts.createCompilerDiagnostic(ts.Diagnostics.The_current_host_does_not_support_the_0_option, "--watch")); - return ts.sys.exit(ts.ExitStatus.DiagnosticsPresent_OutputsSkipped); - } - if (configFileName) { - configFileWatcher = ts.sys.watchFile(configFileName, configFileChanged); - } - if (ts.sys.watchDirectory && configFileName) { - var directory = ts.getDirectoryPath(configFileName); - directoryWatcher = ts.sys.watchDirectory(directory == "" ? "." : directory, watchedDirectoryChanged, true); - } - } - performCompilation(); - function parseConfigFile() { - if (!cachedConfigFileText) { - try { - cachedConfigFileText = ts.sys.readFile(configFileName); - } - catch (e) { - var error = ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_read_file_0_Colon_1, configFileName, e.message); - reportWatchDiagnostic(error); - ts.sys.exit(ts.ExitStatus.DiagnosticsPresent_OutputsSkipped); - return; - } - } - var result = ts.parseConfigFileTextToJson(configFileName, cachedConfigFileText); - var configObject = result.config; - var configParseResult = ts.parseJsonConfigFileContent(configObject, ts.sys, ts.getDirectoryPath(configFileName)); - if (configParseResult.errors.length > 0) { - reportDiagnostics(configParseResult.errors); - ts.sys.exit(ts.ExitStatus.DiagnosticsPresent_OutputsSkipped); - return; - } - return configParseResult; - } - function performCompilation() { - if (!cachedProgram) { - if (configFileName) { - var configParseResult = parseConfigFile(); - rootFileNames = configParseResult.fileNames; - compilerOptions = ts.extend(commandLine.options, configParseResult.options); - } - else { - rootFileNames = commandLine.fileNames; - compilerOptions = commandLine.options; - } - compilerHost = ts.createCompilerHost(compilerOptions); - hostGetSourceFile = compilerHost.getSourceFile; - compilerHost.getSourceFile = getSourceFile; - hostFileExists = compilerHost.fileExists; - compilerHost.fileExists = cachedFileExists; - } - cachedExistingFiles = {}; - var compileResult = compile(rootFileNames, compilerOptions, compilerHost); - if (!compilerOptions.watch) { - return ts.sys.exit(compileResult.exitStatus); - } - setCachedProgram(compileResult.program); - reportWatchDiagnostic(ts.createCompilerDiagnostic(ts.Diagnostics.Compilation_complete_Watching_for_file_changes)); - } - function cachedFileExists(fileName) { - if (ts.hasProperty(cachedExistingFiles, fileName)) { - return cachedExistingFiles[fileName]; - } - return cachedExistingFiles[fileName] = hostFileExists(fileName); - } - function getSourceFile(fileName, languageVersion, onError) { - if (cachedProgram) { - var sourceFile_1 = cachedProgram.getSourceFile(fileName); - if (sourceFile_1 && sourceFile_1.fileWatcher) { - return sourceFile_1; - } - } - var sourceFile = hostGetSourceFile(fileName, languageVersion, onError); - if (sourceFile && compilerOptions.watch) { - sourceFile.fileWatcher = ts.sys.watchFile(sourceFile.fileName, function (fileName, removed) { return sourceFileChanged(sourceFile, removed); }); - } - return sourceFile; - } - function setCachedProgram(program) { - if (cachedProgram) { - var newSourceFiles = program ? program.getSourceFiles() : undefined; - ts.forEach(cachedProgram.getSourceFiles(), function (sourceFile) { - if (!(newSourceFiles && ts.contains(newSourceFiles, sourceFile))) { - if (sourceFile.fileWatcher) { - sourceFile.fileWatcher.close(); - sourceFile.fileWatcher = undefined; - } - } - }); - } - cachedProgram = program; - } - function sourceFileChanged(sourceFile, removed) { - sourceFile.fileWatcher.close(); - sourceFile.fileWatcher = undefined; - if (removed) { - var index = rootFileNames.indexOf(sourceFile.fileName); - if (index >= 0) { - rootFileNames.splice(index, 1); - } - } - startTimerForRecompilation(); - } - function configFileChanged() { - setCachedProgram(undefined); - cachedConfigFileText = undefined; - startTimerForRecompilation(); - } - function watchedDirectoryChanged(fileName) { - if (fileName && !ts.isSupportedSourceFileName(fileName)) { - return; - } - startTimerForHandlingDirectoryChanges(); - } - function startTimerForHandlingDirectoryChanges() { - if (timerHandleForDirectoryChanges) { - clearTimeout(timerHandleForDirectoryChanges); - } - timerHandleForDirectoryChanges = setTimeout(directoryChangeHandler, 250); - } - function directoryChangeHandler() { - var parsedCommandLine = parseConfigFile(); - var newFileNames = ts.map(parsedCommandLine.fileNames, compilerHost.getCanonicalFileName); - var canonicalRootFileNames = ts.map(rootFileNames, compilerHost.getCanonicalFileName); - if (!ts.arrayIsEqualTo(newFileNames && newFileNames.sort(), canonicalRootFileNames && canonicalRootFileNames.sort())) { - setCachedProgram(undefined); - startTimerForRecompilation(); - } - } - function startTimerForRecompilation() { - if (timerHandleForRecompilation) { - clearTimeout(timerHandleForRecompilation); - } - timerHandleForRecompilation = setTimeout(recompile, 250); - } - function recompile() { - timerHandleForRecompilation = undefined; - reportWatchDiagnostic(ts.createCompilerDiagnostic(ts.Diagnostics.File_change_detected_Starting_incremental_compilation)); - performCompilation(); - } - } - ts.executeCommandLine = executeCommandLine; - function compile(fileNames, compilerOptions, compilerHost) { - ts.ioReadTime = 0; - ts.ioWriteTime = 0; - ts.programTime = 0; - ts.bindTime = 0; - ts.checkTime = 0; - ts.emitTime = 0; - var program = ts.createProgram(fileNames, compilerOptions, compilerHost); - var exitStatus = compileProgram(); - if (compilerOptions.listFiles) { - ts.forEach(program.getSourceFiles(), function (file) { - ts.sys.write(file.fileName + ts.sys.newLine); - }); - } - if (compilerOptions.diagnostics) { - var memoryUsed = ts.sys.getMemoryUsage ? ts.sys.getMemoryUsage() : -1; - reportCountStatistic("Files", program.getSourceFiles().length); - reportCountStatistic("Lines", countLines(program)); - reportCountStatistic("Nodes", program.getNodeCount()); - reportCountStatistic("Identifiers", program.getIdentifierCount()); - reportCountStatistic("Symbols", program.getSymbolCount()); - reportCountStatistic("Types", program.getTypeCount()); - if (memoryUsed >= 0) { - reportStatisticalValue("Memory used", Math.round(memoryUsed / 1000) + "K"); - } - reportTimeStatistic("I/O read", ts.ioReadTime); - reportTimeStatistic("I/O write", ts.ioWriteTime); - reportTimeStatistic("Parse time", ts.programTime); - reportTimeStatistic("Bind time", ts.bindTime); - reportTimeStatistic("Check time", ts.checkTime); - reportTimeStatistic("Emit time", ts.emitTime); - reportTimeStatistic("Total time", ts.programTime + ts.bindTime + ts.checkTime + ts.emitTime); - } - return { program: program, exitStatus: exitStatus }; - function compileProgram() { - var diagnostics; - diagnostics = program.getSyntacticDiagnostics(); - if (diagnostics.length === 0) { - diagnostics = program.getOptionsDiagnostics().concat(program.getGlobalDiagnostics()); - if (diagnostics.length === 0) { - diagnostics = program.getSemanticDiagnostics(); - } - } - reportDiagnostics(diagnostics); - if (compilerOptions.noEmit) { - return diagnostics.length - ? ts.ExitStatus.DiagnosticsPresent_OutputsSkipped - : ts.ExitStatus.Success; - } - var emitOutput = program.emit(); - reportDiagnostics(emitOutput.diagnostics); - if (emitOutput.emitSkipped) { - return ts.ExitStatus.DiagnosticsPresent_OutputsSkipped; - } - if (diagnostics.length > 0 || emitOutput.diagnostics.length > 0) { - return ts.ExitStatus.DiagnosticsPresent_OutputsGenerated; - } - return ts.ExitStatus.Success; - } - } - function printVersion() { - ts.sys.write(getDiagnosticText(ts.Diagnostics.Version_0, ts.version) + ts.sys.newLine); - } - function printHelp() { - var output = ""; - var syntaxLength = getDiagnosticText(ts.Diagnostics.Syntax_Colon_0, "").length; - var examplesLength = getDiagnosticText(ts.Diagnostics.Examples_Colon_0, "").length; - var marginLength = Math.max(syntaxLength, examplesLength); - var syntax = makePadding(marginLength - syntaxLength); - syntax += "tsc [" + getDiagnosticText(ts.Diagnostics.options) + "] [" + getDiagnosticText(ts.Diagnostics.file) + " ...]"; - output += getDiagnosticText(ts.Diagnostics.Syntax_Colon_0, syntax); - output += ts.sys.newLine + ts.sys.newLine; - var padding = makePadding(marginLength); - output += getDiagnosticText(ts.Diagnostics.Examples_Colon_0, makePadding(marginLength - examplesLength) + "tsc hello.ts") + ts.sys.newLine; - output += padding + "tsc --out file.js file.ts" + ts.sys.newLine; - output += padding + "tsc @args.txt" + ts.sys.newLine; - output += ts.sys.newLine; - output += getDiagnosticText(ts.Diagnostics.Options_Colon) + ts.sys.newLine; - var optsList = ts.filter(ts.optionDeclarations.slice(), function (v) { return !v.experimental; }); - optsList.sort(function (a, b) { return ts.compareValues(a.name.toLowerCase(), b.name.toLowerCase()); }); - marginLength = 0; - var usageColumn = []; - var descriptionColumn = []; - for (var i = 0; i < optsList.length; i++) { - var option = optsList[i]; - if (!option.description) { - continue; - } - var usageText_1 = " "; - if (option.shortName) { - usageText_1 += "-" + option.shortName; - usageText_1 += getParamType(option); - usageText_1 += ", "; - } - usageText_1 += "--" + option.name; - usageText_1 += getParamType(option); - usageColumn.push(usageText_1); - descriptionColumn.push(getDiagnosticText(option.description)); - marginLength = Math.max(usageText_1.length, marginLength); - } - var usageText = " @<" + getDiagnosticText(ts.Diagnostics.file) + ">"; - usageColumn.push(usageText); - descriptionColumn.push(getDiagnosticText(ts.Diagnostics.Insert_command_line_options_and_files_from_a_file)); - marginLength = Math.max(usageText.length, marginLength); - for (var i = 0; i < usageColumn.length; i++) { - var usage = usageColumn[i]; - var description = descriptionColumn[i]; - output += usage + makePadding(marginLength - usage.length + 2) + description + ts.sys.newLine; - } - ts.sys.write(output); - return; - function getParamType(option) { - if (option.paramType !== undefined) { - return " " + getDiagnosticText(option.paramType); - } - return ""; - } - function makePadding(paddingLength) { - return Array(paddingLength + 1).join(" "); - } - } - function writeConfigFile(options, fileNames) { - var currentDirectory = ts.sys.getCurrentDirectory(); - var file = ts.normalizePath(ts.combinePaths(currentDirectory, "tsconfig.json")); - if (ts.sys.fileExists(file)) { - reportDiagnostic(ts.createCompilerDiagnostic(ts.Diagnostics.A_tsconfig_json_file_is_already_defined_at_Colon_0, file)); - } - else { - var compilerOptions = ts.extend(options, ts.defaultInitCompilerOptions); - var configurations = { - compilerOptions: serializeCompilerOptions(compilerOptions), - exclude: ["node_modules"] - }; - if (fileNames && fileNames.length) { - configurations.files = fileNames; - } - ts.sys.writeFile(file, JSON.stringify(configurations, undefined, 4)); - reportDiagnostic(ts.createCompilerDiagnostic(ts.Diagnostics.Successfully_created_a_tsconfig_json_file)); - } - return; - function serializeCompilerOptions(options) { - var result = {}; - var optionsNameMap = ts.getOptionNameMap().optionNameMap; - for (var name_29 in options) { - if (ts.hasProperty(options, name_29)) { - var value = options[name_29]; - switch (name_29) { - case "init": - case "watch": - case "version": - case "help": - case "project": - break; - default: - var optionDefinition = optionsNameMap[name_29.toLowerCase()]; - if (optionDefinition) { - if (typeof optionDefinition.type === "string") { - result[name_29] = value; - } - else { - var typeMap = optionDefinition.type; - for (var key in typeMap) { - if (ts.hasProperty(typeMap, key)) { - if (typeMap[key] === value) - result[name_29] = key; - } - } - } - } - break; - } - } - } - return result; - } - } -})(ts || (ts = {})); -ts.executeCommandLine(ts.sys.args); +var ts; +(function (ts) { + var OperationCanceledException = (function () { + function OperationCanceledException() { + } + return OperationCanceledException; + })(); + ts.OperationCanceledException = OperationCanceledException; + (function (ExitStatus) { + ExitStatus[ExitStatus["Success"] = 0] = "Success"; + ExitStatus[ExitStatus["DiagnosticsPresent_OutputsSkipped"] = 1] = "DiagnosticsPresent_OutputsSkipped"; + ExitStatus[ExitStatus["DiagnosticsPresent_OutputsGenerated"] = 2] = "DiagnosticsPresent_OutputsGenerated"; + })(ts.ExitStatus || (ts.ExitStatus = {})); + var ExitStatus = ts.ExitStatus; + (function (TypeReferenceSerializationKind) { + TypeReferenceSerializationKind[TypeReferenceSerializationKind["Unknown"] = 0] = "Unknown"; + TypeReferenceSerializationKind[TypeReferenceSerializationKind["TypeWithConstructSignatureAndValue"] = 1] = "TypeWithConstructSignatureAndValue"; + TypeReferenceSerializationKind[TypeReferenceSerializationKind["VoidType"] = 2] = "VoidType"; + TypeReferenceSerializationKind[TypeReferenceSerializationKind["NumberLikeType"] = 3] = "NumberLikeType"; + TypeReferenceSerializationKind[TypeReferenceSerializationKind["StringLikeType"] = 4] = "StringLikeType"; + TypeReferenceSerializationKind[TypeReferenceSerializationKind["BooleanType"] = 5] = "BooleanType"; + TypeReferenceSerializationKind[TypeReferenceSerializationKind["ArrayLikeType"] = 6] = "ArrayLikeType"; + TypeReferenceSerializationKind[TypeReferenceSerializationKind["ESSymbolType"] = 7] = "ESSymbolType"; + TypeReferenceSerializationKind[TypeReferenceSerializationKind["TypeWithCallSignature"] = 8] = "TypeWithCallSignature"; + TypeReferenceSerializationKind[TypeReferenceSerializationKind["ObjectType"] = 9] = "ObjectType"; + })(ts.TypeReferenceSerializationKind || (ts.TypeReferenceSerializationKind = {})); + var TypeReferenceSerializationKind = ts.TypeReferenceSerializationKind; + (function (DiagnosticCategory) { + DiagnosticCategory[DiagnosticCategory["Warning"] = 0] = "Warning"; + DiagnosticCategory[DiagnosticCategory["Error"] = 1] = "Error"; + DiagnosticCategory[DiagnosticCategory["Message"] = 2] = "Message"; + })(ts.DiagnosticCategory || (ts.DiagnosticCategory = {})); + var DiagnosticCategory = ts.DiagnosticCategory; +})(ts || (ts = {})); +var ts; +(function (ts) { + function createFileMap(getCanonicalFileName) { + var files = {}; + return { + get: get, + set: set, + contains: contains, + remove: remove, + clear: clear, + forEachValue: forEachValueInMap + }; + function set(fileName, value) { + files[normalizeKey(fileName)] = value; + } + function get(fileName) { + return files[normalizeKey(fileName)]; + } + function contains(fileName) { + return hasProperty(files, normalizeKey(fileName)); + } + function remove(fileName) { + var key = normalizeKey(fileName); + delete files[key]; + } + function forEachValueInMap(f) { + forEachValue(files, f); + } + function normalizeKey(key) { + return getCanonicalFileName(normalizeSlashes(key)); + } + function clear() { + files = {}; + } + } + ts.createFileMap = createFileMap; + function forEach(array, callback) { + if (array) { + for (var i = 0, len = array.length; i < len; i++) { + var result = callback(array[i], i); + if (result) { + return result; + } + } + } + return undefined; + } + ts.forEach = forEach; + function contains(array, value) { + if (array) { + for (var _i = 0; _i < array.length; _i++) { + var v = array[_i]; + if (v === value) { + return true; + } + } + } + return false; + } + ts.contains = contains; + function indexOf(array, value) { + if (array) { + for (var i = 0, len = array.length; i < len; i++) { + if (array[i] === value) { + return i; + } + } + } + return -1; + } + ts.indexOf = indexOf; + function countWhere(array, predicate) { + var count = 0; + if (array) { + for (var _i = 0; _i < array.length; _i++) { + var v = array[_i]; + if (predicate(v)) { + count++; + } + } + } + return count; + } + ts.countWhere = countWhere; + function filter(array, f) { + var result; + if (array) { + result = []; + for (var _i = 0; _i < array.length; _i++) { + var item = array[_i]; + if (f(item)) { + result.push(item); + } + } + } + return result; + } + ts.filter = filter; + function map(array, f) { + var result; + if (array) { + result = []; + for (var _i = 0; _i < array.length; _i++) { + var v = array[_i]; + result.push(f(v)); + } + } + return result; + } + ts.map = map; + function concatenate(array1, array2) { + if (!array2 || !array2.length) + return array1; + if (!array1 || !array1.length) + return array2; + return array1.concat(array2); + } + ts.concatenate = concatenate; + function deduplicate(array) { + var result; + if (array) { + result = []; + for (var _i = 0; _i < array.length; _i++) { + var item = array[_i]; + if (!contains(result, item)) { + result.push(item); + } + } + } + return result; + } + ts.deduplicate = deduplicate; + function sum(array, prop) { + var result = 0; + for (var _i = 0; _i < array.length; _i++) { + var v = array[_i]; + result += v[prop]; + } + return result; + } + ts.sum = sum; + function addRange(to, from) { + if (to && from) { + for (var _i = 0; _i < from.length; _i++) { + var v = from[_i]; + to.push(v); + } + } + } + ts.addRange = addRange; + function rangeEquals(array1, array2, pos, end) { + while (pos < end) { + if (array1[pos] !== array2[pos]) { + return false; + } + pos++; + } + return true; + } + ts.rangeEquals = rangeEquals; + function lastOrUndefined(array) { + if (array.length === 0) { + return undefined; + } + return array[array.length - 1]; + } + ts.lastOrUndefined = lastOrUndefined; + function binarySearch(array, value) { + var low = 0; + var high = array.length - 1; + while (low <= high) { + var middle = low + ((high - low) >> 1); + var midValue = array[middle]; + if (midValue === value) { + return middle; + } + else if (midValue > value) { + high = middle - 1; + } + else { + low = middle + 1; + } + } + return ~low; + } + ts.binarySearch = binarySearch; + function reduceLeft(array, f, initial) { + if (array) { + var count = array.length; + if (count > 0) { + var pos = 0; + var result = arguments.length <= 2 ? array[pos++] : initial; + while (pos < count) { + result = f(result, array[pos++]); + } + return result; + } + } + return initial; + } + ts.reduceLeft = reduceLeft; + function reduceRight(array, f, initial) { + if (array) { + var pos = array.length - 1; + if (pos >= 0) { + var result = arguments.length <= 2 ? array[pos--] : initial; + while (pos >= 0) { + result = f(result, array[pos--]); + } + return result; + } + } + return initial; + } + ts.reduceRight = reduceRight; + var hasOwnProperty = Object.prototype.hasOwnProperty; + function hasProperty(map, key) { + return hasOwnProperty.call(map, key); + } + ts.hasProperty = hasProperty; + function getProperty(map, key) { + return hasOwnProperty.call(map, key) ? map[key] : undefined; + } + ts.getProperty = getProperty; + function isEmpty(map) { + for (var id in map) { + if (hasProperty(map, id)) { + return false; + } + } + return true; + } + ts.isEmpty = isEmpty; + function clone(object) { + var result = {}; + for (var id in object) { + result[id] = object[id]; + } + return result; + } + ts.clone = clone; + function extend(first, second) { + var result = {}; + for (var id in first) { + result[id] = first[id]; + } + for (var id in second) { + if (!hasProperty(result, id)) { + result[id] = second[id]; + } + } + return result; + } + ts.extend = extend; + function forEachValue(map, callback) { + var result; + for (var id in map) { + if (result = callback(map[id])) + break; + } + return result; + } + ts.forEachValue = forEachValue; + function forEachKey(map, callback) { + var result; + for (var id in map) { + if (result = callback(id)) + break; + } + return result; + } + ts.forEachKey = forEachKey; + function lookUp(map, key) { + return hasProperty(map, key) ? map[key] : undefined; + } + ts.lookUp = lookUp; + function copyMap(source, target) { + for (var p in source) { + target[p] = source[p]; + } + } + ts.copyMap = copyMap; + function arrayToMap(array, makeKey) { + var result = {}; + forEach(array, function (value) { + result[makeKey(value)] = value; + }); + return result; + } + ts.arrayToMap = arrayToMap; + function memoize(callback) { + var value; + return function () { + if (callback) { + value = callback(); + callback = undefined; + } + return value; + }; + } + ts.memoize = memoize; + function formatStringFromArgs(text, args, baseIndex) { + baseIndex = baseIndex || 0; + return text.replace(/{(\d+)}/g, function (match, index) { return args[+index + baseIndex]; }); + } + ts.localizedDiagnosticMessages = undefined; + function getLocaleSpecificMessage(message) { + return ts.localizedDiagnosticMessages && ts.localizedDiagnosticMessages[message.key] + ? ts.localizedDiagnosticMessages[message.key] + : message.message; + } + ts.getLocaleSpecificMessage = getLocaleSpecificMessage; + function createFileDiagnostic(file, start, length, message) { + var end = start + length; + Debug.assert(start >= 0, "start must be non-negative, is " + start); + Debug.assert(length >= 0, "length must be non-negative, is " + length); + if (file) { + Debug.assert(start <= file.text.length, "start must be within the bounds of the file. " + start + " > " + file.text.length); + Debug.assert(end <= file.text.length, "end must be the bounds of the file. " + end + " > " + file.text.length); + } + var text = getLocaleSpecificMessage(message); + if (arguments.length > 4) { + text = formatStringFromArgs(text, arguments, 4); + } + return { + file: file, + start: start, + length: length, + messageText: text, + category: message.category, + code: message.code + }; + } + ts.createFileDiagnostic = createFileDiagnostic; + function createCompilerDiagnostic(message) { + var text = getLocaleSpecificMessage(message); + if (arguments.length > 1) { + text = formatStringFromArgs(text, arguments, 1); + } + return { + file: undefined, + start: undefined, + length: undefined, + messageText: text, + category: message.category, + code: message.code + }; + } + ts.createCompilerDiagnostic = createCompilerDiagnostic; + function chainDiagnosticMessages(details, message) { + var text = getLocaleSpecificMessage(message); + if (arguments.length > 2) { + text = formatStringFromArgs(text, arguments, 2); + } + return { + messageText: text, + category: message.category, + code: message.code, + next: details + }; + } + ts.chainDiagnosticMessages = chainDiagnosticMessages; + function concatenateDiagnosticMessageChains(headChain, tailChain) { + var lastChain = headChain; + while (lastChain.next) { + lastChain = lastChain.next; + } + lastChain.next = tailChain; + return headChain; + } + ts.concatenateDiagnosticMessageChains = concatenateDiagnosticMessageChains; + function compareValues(a, b) { + if (a === b) + return 0; + if (a === undefined) + return -1; + if (b === undefined) + return 1; + return a < b ? -1 : 1; + } + ts.compareValues = compareValues; + function getDiagnosticFileName(diagnostic) { + return diagnostic.file ? diagnostic.file.fileName : undefined; + } + function compareDiagnostics(d1, d2) { + return compareValues(getDiagnosticFileName(d1), getDiagnosticFileName(d2)) || + compareValues(d1.start, d2.start) || + compareValues(d1.length, d2.length) || + compareValues(d1.code, d2.code) || + compareMessageText(d1.messageText, d2.messageText) || + 0; + } + ts.compareDiagnostics = compareDiagnostics; + function compareMessageText(text1, text2) { + while (text1 && text2) { + var string1 = typeof text1 === "string" ? text1 : text1.messageText; + var string2 = typeof text2 === "string" ? text2 : text2.messageText; + var res = compareValues(string1, string2); + if (res) { + return res; + } + text1 = typeof text1 === "string" ? undefined : text1.next; + text2 = typeof text2 === "string" ? undefined : text2.next; + } + if (!text1 && !text2) { + return 0; + } + return text1 ? 1 : -1; + } + function sortAndDeduplicateDiagnostics(diagnostics) { + return deduplicateSortedDiagnostics(diagnostics.sort(compareDiagnostics)); + } + ts.sortAndDeduplicateDiagnostics = sortAndDeduplicateDiagnostics; + function deduplicateSortedDiagnostics(diagnostics) { + if (diagnostics.length < 2) { + return diagnostics; + } + var newDiagnostics = [diagnostics[0]]; + var previousDiagnostic = diagnostics[0]; + for (var i = 1; i < diagnostics.length; i++) { + var currentDiagnostic = diagnostics[i]; + var isDupe = compareDiagnostics(currentDiagnostic, previousDiagnostic) === 0; + if (!isDupe) { + newDiagnostics.push(currentDiagnostic); + previousDiagnostic = currentDiagnostic; + } + } + return newDiagnostics; + } + ts.deduplicateSortedDiagnostics = deduplicateSortedDiagnostics; + function normalizeSlashes(path) { + return path.replace(/\\/g, "/"); + } + ts.normalizeSlashes = normalizeSlashes; + function getRootLength(path) { + if (path.charCodeAt(0) === 47) { + if (path.charCodeAt(1) !== 47) + return 1; + var p1 = path.indexOf("/", 2); + if (p1 < 0) + return 2; + var p2 = path.indexOf("/", p1 + 1); + if (p2 < 0) + return p1 + 1; + return p2 + 1; + } + if (path.charCodeAt(1) === 58) { + if (path.charCodeAt(2) === 47) + return 3; + return 2; + } + if (path.lastIndexOf("file:///", 0) === 0) { + return "file:///".length; + } + var idx = path.indexOf("://"); + if (idx !== -1) { + return idx + "://".length; + } + return 0; + } + ts.getRootLength = getRootLength; + ts.directorySeparator = "/"; + function getNormalizedParts(normalizedSlashedPath, rootLength) { + var parts = normalizedSlashedPath.substr(rootLength).split(ts.directorySeparator); + var normalized = []; + for (var _i = 0; _i < parts.length; _i++) { + var part = parts[_i]; + if (part !== ".") { + if (part === ".." && normalized.length > 0 && lastOrUndefined(normalized) !== "..") { + normalized.pop(); + } + else { + if (part) { + normalized.push(part); + } + } + } + } + return normalized; + } + function normalizePath(path) { + path = normalizeSlashes(path); + var rootLength = getRootLength(path); + var normalized = getNormalizedParts(path, rootLength); + return path.substr(0, rootLength) + normalized.join(ts.directorySeparator); + } + ts.normalizePath = normalizePath; + function getDirectoryPath(path) { + return path.substr(0, Math.max(getRootLength(path), path.lastIndexOf(ts.directorySeparator))); + } + ts.getDirectoryPath = getDirectoryPath; + function isUrl(path) { + return path && !isRootedDiskPath(path) && path.indexOf("://") !== -1; + } + ts.isUrl = isUrl; + function isRootedDiskPath(path) { + return getRootLength(path) !== 0; + } + ts.isRootedDiskPath = isRootedDiskPath; + function normalizedPathComponents(path, rootLength) { + var normalizedParts = getNormalizedParts(path, rootLength); + return [path.substr(0, rootLength)].concat(normalizedParts); + } + function getNormalizedPathComponents(path, currentDirectory) { + path = normalizeSlashes(path); + var rootLength = getRootLength(path); + if (rootLength === 0) { + path = combinePaths(normalizeSlashes(currentDirectory), path); + rootLength = getRootLength(path); + } + return normalizedPathComponents(path, rootLength); + } + ts.getNormalizedPathComponents = getNormalizedPathComponents; + function getNormalizedAbsolutePath(fileName, currentDirectory) { + return getNormalizedPathFromPathComponents(getNormalizedPathComponents(fileName, currentDirectory)); + } + ts.getNormalizedAbsolutePath = getNormalizedAbsolutePath; + function getNormalizedPathFromPathComponents(pathComponents) { + if (pathComponents && pathComponents.length) { + return pathComponents[0] + pathComponents.slice(1).join(ts.directorySeparator); + } + } + ts.getNormalizedPathFromPathComponents = getNormalizedPathFromPathComponents; + function getNormalizedPathComponentsOfUrl(url) { + var urlLength = url.length; + var rootLength = url.indexOf("://") + "://".length; + while (rootLength < urlLength) { + if (url.charCodeAt(rootLength) === 47) { + rootLength++; + } + else { + break; + } + } + if (rootLength === urlLength) { + return [url]; + } + var indexOfNextSlash = url.indexOf(ts.directorySeparator, rootLength); + if (indexOfNextSlash !== -1) { + rootLength = indexOfNextSlash + 1; + return normalizedPathComponents(url, rootLength); + } + else { + return [url + ts.directorySeparator]; + } + } + function getNormalizedPathOrUrlComponents(pathOrUrl, currentDirectory) { + if (isUrl(pathOrUrl)) { + return getNormalizedPathComponentsOfUrl(pathOrUrl); + } + else { + return getNormalizedPathComponents(pathOrUrl, currentDirectory); + } + } + function getRelativePathToDirectoryOrUrl(directoryPathOrUrl, relativeOrAbsolutePath, currentDirectory, getCanonicalFileName, isAbsolutePathAnUrl) { + var pathComponents = getNormalizedPathOrUrlComponents(relativeOrAbsolutePath, currentDirectory); + var directoryComponents = getNormalizedPathOrUrlComponents(directoryPathOrUrl, currentDirectory); + if (directoryComponents.length > 1 && lastOrUndefined(directoryComponents) === "") { + directoryComponents.length--; + } + for (var joinStartIndex = 0; joinStartIndex < pathComponents.length && joinStartIndex < directoryComponents.length; joinStartIndex++) { + if (getCanonicalFileName(directoryComponents[joinStartIndex]) !== getCanonicalFileName(pathComponents[joinStartIndex])) { + break; + } + } + if (joinStartIndex) { + var relativePath = ""; + var relativePathComponents = pathComponents.slice(joinStartIndex, pathComponents.length); + for (; joinStartIndex < directoryComponents.length; joinStartIndex++) { + if (directoryComponents[joinStartIndex] !== "") { + relativePath = relativePath + ".." + ts.directorySeparator; + } + } + return relativePath + relativePathComponents.join(ts.directorySeparator); + } + var absolutePath = getNormalizedPathFromPathComponents(pathComponents); + if (isAbsolutePathAnUrl && isRootedDiskPath(absolutePath)) { + absolutePath = "file:///" + absolutePath; + } + return absolutePath; + } + ts.getRelativePathToDirectoryOrUrl = getRelativePathToDirectoryOrUrl; + function getBaseFileName(path) { + if (!path) { + return undefined; + } + var i = path.lastIndexOf(ts.directorySeparator); + return i < 0 ? path : path.substring(i + 1); + } + ts.getBaseFileName = getBaseFileName; + function combinePaths(path1, path2) { + if (!(path1 && path1.length)) + return path2; + if (!(path2 && path2.length)) + return path1; + if (getRootLength(path2) !== 0) + return path2; + if (path1.charAt(path1.length - 1) === ts.directorySeparator) + return path1 + path2; + return path1 + ts.directorySeparator + path2; + } + ts.combinePaths = combinePaths; + function fileExtensionIs(path, extension) { + var pathLen = path.length; + var extLen = extension.length; + return pathLen > extLen && path.substr(pathLen - extLen, extLen) === extension; + } + ts.fileExtensionIs = fileExtensionIs; + ts.supportedExtensions = [".ts", ".tsx", ".d.ts"]; + ts.moduleFileExtensions = ts.supportedExtensions; + function isSupportedSourceFileName(fileName) { + if (!fileName) { + return false; + } + for (var _i = 0; _i < ts.supportedExtensions.length; _i++) { + var extension = ts.supportedExtensions[_i]; + if (fileExtensionIs(fileName, extension)) { + return true; + } + } + return false; + } + ts.isSupportedSourceFileName = isSupportedSourceFileName; + var extensionsToRemove = [".d.ts", ".ts", ".js", ".tsx", ".jsx"]; + function removeFileExtension(path) { + for (var _i = 0; _i < extensionsToRemove.length; _i++) { + var ext = extensionsToRemove[_i]; + if (fileExtensionIs(path, ext)) { + return path.substr(0, path.length - ext.length); + } + } + return path; + } + ts.removeFileExtension = removeFileExtension; + var backslashOrDoubleQuote = /[\"\\]/g; + var escapedCharsRegExp = /[\u0000-\u001f\t\v\f\b\r\n\u2028\u2029\u0085]/g; + var escapedCharsMap = { + "\0": "\\0", + "\t": "\\t", + "\v": "\\v", + "\f": "\\f", + "\b": "\\b", + "\r": "\\r", + "\n": "\\n", + "\\": "\\\\", + "\"": "\\\"", + "\u2028": "\\u2028", + "\u2029": "\\u2029", + "\u0085": "\\u0085" + }; + function Symbol(flags, name) { + this.flags = flags; + this.name = name; + this.declarations = undefined; + } + function Type(checker, flags) { + this.flags = flags; + } + function Signature(checker) { + } + ts.objectAllocator = { + getNodeConstructor: function (kind) { + function Node(pos, end) { + this.pos = pos; + this.end = end; + this.flags = 0; + this.parent = undefined; + } + Node.prototype = { kind: kind }; + return Node; + }, + getSymbolConstructor: function () { return Symbol; }, + getTypeConstructor: function () { return Type; }, + getSignatureConstructor: function () { return Signature; } + }; + var Debug; + (function (Debug) { + var currentAssertionLevel = 0; + function shouldAssert(level) { + return currentAssertionLevel >= level; + } + Debug.shouldAssert = shouldAssert; + function assert(expression, message, verboseDebugInfo) { + if (!expression) { + var verboseDebugString = ""; + if (verboseDebugInfo) { + verboseDebugString = "\r\nVerbose Debug Information: " + verboseDebugInfo(); + } + debugger; + throw new Error("Debug Failure. False expression: " + (message || "") + verboseDebugString); + } + } + Debug.assert = assert; + function fail(message) { + Debug.assert(false, message); + } + Debug.fail = fail; + })(Debug = ts.Debug || (ts.Debug = {})); + function copyListRemovingItem(item, list) { + var copiedList = []; + for (var _i = 0; _i < list.length; _i++) { + var e = list[_i]; + if (e !== item) { + copiedList.push(e); + } + } + return copiedList; + } + ts.copyListRemovingItem = copyListRemovingItem; +})(ts || (ts = {})); +var ts; +(function (ts) { + ts.sys = (function () { + function getWScriptSystem() { + var fso = new ActiveXObject("Scripting.FileSystemObject"); + var fileStream = new ActiveXObject("ADODB.Stream"); + fileStream.Type = 2; + var binaryStream = new ActiveXObject("ADODB.Stream"); + binaryStream.Type = 1; + var args = []; + for (var i = 0; i < WScript.Arguments.length; i++) { + args[i] = WScript.Arguments.Item(i); + } + function readFile(fileName, encoding) { + if (!fso.FileExists(fileName)) { + return undefined; + } + fileStream.Open(); + try { + if (encoding) { + fileStream.Charset = encoding; + fileStream.LoadFromFile(fileName); + } + else { + fileStream.Charset = "x-ansi"; + fileStream.LoadFromFile(fileName); + var bom = fileStream.ReadText(2) || ""; + fileStream.Position = 0; + fileStream.Charset = bom.length >= 2 && (bom.charCodeAt(0) === 0xFF && bom.charCodeAt(1) === 0xFE || bom.charCodeAt(0) === 0xFE && bom.charCodeAt(1) === 0xFF) ? "unicode" : "utf-8"; + } + return fileStream.ReadText(); + } + catch (e) { + throw e; + } + finally { + fileStream.Close(); + } + } + function writeFile(fileName, data, writeByteOrderMark) { + fileStream.Open(); + binaryStream.Open(); + try { + fileStream.Charset = "utf-8"; + fileStream.WriteText(data); + if (writeByteOrderMark) { + fileStream.Position = 0; + } + else { + fileStream.Position = 3; + } + fileStream.CopyTo(binaryStream); + binaryStream.SaveToFile(fileName, 2); + } + finally { + binaryStream.Close(); + fileStream.Close(); + } + } + function getCanonicalPath(path) { + return path.toLowerCase(); + } + function getNames(collection) { + var result = []; + for (var e = new Enumerator(collection); !e.atEnd(); e.moveNext()) { + result.push(e.item().Name); + } + return result.sort(); + } + function readDirectory(path, extension, exclude) { + var result = []; + exclude = ts.map(exclude, function (s) { return getCanonicalPath(ts.combinePaths(path, s)); }); + visitDirectory(path); + return result; + function visitDirectory(path) { + var folder = fso.GetFolder(path || "."); + var files = getNames(folder.files); + for (var _i = 0; _i < files.length; _i++) { + var current = files[_i]; + var name_1 = ts.combinePaths(path, current); + if ((!extension || ts.fileExtensionIs(name_1, extension)) && !ts.contains(exclude, getCanonicalPath(name_1))) { + result.push(name_1); + } + } + var subfolders = getNames(folder.subfolders); + for (var _a = 0; _a < subfolders.length; _a++) { + var current = subfolders[_a]; + var name_2 = ts.combinePaths(path, current); + if (!ts.contains(exclude, getCanonicalPath(name_2))) { + visitDirectory(name_2); + } + } + } + } + return { + args: args, + newLine: "\r\n", + useCaseSensitiveFileNames: false, + write: function (s) { + WScript.StdOut.Write(s); + }, + readFile: readFile, + writeFile: writeFile, + resolvePath: function (path) { + return fso.GetAbsolutePathName(path); + }, + fileExists: function (path) { + return fso.FileExists(path); + }, + directoryExists: function (path) { + return fso.FolderExists(path); + }, + createDirectory: function (directoryName) { + if (!this.directoryExists(directoryName)) { + fso.CreateFolder(directoryName); + } + }, + getExecutingFilePath: function () { + return WScript.ScriptFullName; + }, + getCurrentDirectory: function () { + return new ActiveXObject("WScript.Shell").CurrentDirectory; + }, + readDirectory: readDirectory, + exit: function (exitCode) { + try { + WScript.Quit(exitCode); + } + catch (e) { + } + } + }; + } + function getNodeSystem() { + var _fs = require("fs"); + var _path = require("path"); + var _os = require("os"); + function createWatchedFileSet(interval, chunkSize) { + if (interval === void 0) { interval = 2500; } + if (chunkSize === void 0) { chunkSize = 30; } + var watchedFiles = []; + var nextFileToCheck = 0; + var watchTimer; + function getModifiedTime(fileName) { + return _fs.statSync(fileName).mtime; + } + function poll(checkedIndex) { + var watchedFile = watchedFiles[checkedIndex]; + if (!watchedFile) { + return; + } + _fs.stat(watchedFile.fileName, function (err, stats) { + if (err) { + watchedFile.callback(watchedFile.fileName); + } + else if (watchedFile.mtime.getTime() !== stats.mtime.getTime()) { + watchedFile.mtime = getModifiedTime(watchedFile.fileName); + watchedFile.callback(watchedFile.fileName, watchedFile.mtime.getTime() === 0); + } + }); + } + function startWatchTimer() { + watchTimer = setInterval(function () { + var count = 0; + var nextToCheck = nextFileToCheck; + var firstCheck = -1; + while ((count < chunkSize) && (nextToCheck !== firstCheck)) { + poll(nextToCheck); + if (firstCheck < 0) { + firstCheck = nextToCheck; + } + nextToCheck++; + if (nextToCheck === watchedFiles.length) { + nextToCheck = 0; + } + count++; + } + nextFileToCheck = nextToCheck; + }, interval); + } + function addFile(fileName, callback) { + var file = { + fileName: fileName, + callback: callback, + mtime: getModifiedTime(fileName) + }; + watchedFiles.push(file); + if (watchedFiles.length === 1) { + startWatchTimer(); + } + return file; + } + function removeFile(file) { + watchedFiles = ts.copyListRemovingItem(file, watchedFiles); + } + return { + getModifiedTime: getModifiedTime, + poll: poll, + startWatchTimer: startWatchTimer, + addFile: addFile, + removeFile: removeFile + }; + } + var watchedFileSet = createWatchedFileSet(); + function isNode4OrLater() { + return parseInt(process.version.charAt(1)) >= 4; + } + var platform = _os.platform(); + var useCaseSensitiveFileNames = platform !== "win32" && platform !== "win64" && platform !== "darwin"; + function readFile(fileName, encoding) { + if (!_fs.existsSync(fileName)) { + return undefined; + } + var buffer = _fs.readFileSync(fileName); + var len = buffer.length; + if (len >= 2 && buffer[0] === 0xFE && buffer[1] === 0xFF) { + len &= ~1; + for (var i = 0; i < len; i += 2) { + var temp = buffer[i]; + buffer[i] = buffer[i + 1]; + buffer[i + 1] = temp; + } + return buffer.toString("utf16le", 2); + } + if (len >= 2 && buffer[0] === 0xFF && buffer[1] === 0xFE) { + return buffer.toString("utf16le", 2); + } + if (len >= 3 && buffer[0] === 0xEF && buffer[1] === 0xBB && buffer[2] === 0xBF) { + return buffer.toString("utf8", 3); + } + return buffer.toString("utf8"); + } + function writeFile(fileName, data, writeByteOrderMark) { + if (writeByteOrderMark) { + data = "\uFEFF" + data; + } + _fs.writeFileSync(fileName, data, "utf8"); + } + function getCanonicalPath(path) { + return useCaseSensitiveFileNames ? path.toLowerCase() : path; + } + function readDirectory(path, extension, exclude) { + var result = []; + exclude = ts.map(exclude, function (s) { return getCanonicalPath(ts.combinePaths(path, s)); }); + visitDirectory(path); + return result; + function visitDirectory(path) { + var files = _fs.readdirSync(path || ".").sort(); + var directories = []; + for (var _i = 0; _i < files.length; _i++) { + var current = files[_i]; + var name_3 = ts.combinePaths(path, current); + if (!ts.contains(exclude, getCanonicalPath(name_3))) { + var stat = _fs.statSync(name_3); + if (stat.isFile()) { + if (!extension || ts.fileExtensionIs(name_3, extension)) { + result.push(name_3); + } + } + else if (stat.isDirectory()) { + directories.push(name_3); + } + } + } + for (var _a = 0; _a < directories.length; _a++) { + var current = directories[_a]; + visitDirectory(current); + } + } + } + return { + args: process.argv.slice(2), + newLine: _os.EOL, + useCaseSensitiveFileNames: useCaseSensitiveFileNames, + write: function (s) { + var buffer = new Buffer(s, "utf8"); + var offset = 0; + var toWrite = buffer.length; + var written = 0; + while ((written = _fs.writeSync(1, buffer, offset, toWrite)) < toWrite) { + offset += written; + toWrite -= written; + } + }, + readFile: readFile, + writeFile: writeFile, + watchFile: function (fileName, callback) { + if (isNode4OrLater()) { + return _fs.watch(fileName, function (eventName, relativeFileName) { return callback(fileName); }); + } + var watchedFile = watchedFileSet.addFile(fileName, callback); + return { + close: function () { return watchedFileSet.removeFile(watchedFile); } + }; + }, + watchDirectory: function (path, callback, recursive) { + return _fs.watch(path, { persistent: true, recursive: !!recursive }, function (eventName, relativeFileName) { + if (eventName === "rename") { + callback(!relativeFileName ? relativeFileName : ts.normalizePath(ts.combinePaths(path, relativeFileName))); + } + ; + }); + }, + resolvePath: function (path) { + return _path.resolve(path); + }, + fileExists: function (path) { + return _fs.existsSync(path); + }, + directoryExists: function (path) { + return _fs.existsSync(path) && _fs.statSync(path).isDirectory(); + }, + createDirectory: function (directoryName) { + if (!this.directoryExists(directoryName)) { + _fs.mkdirSync(directoryName); + } + }, + getExecutingFilePath: function () { + return __filename; + }, + getCurrentDirectory: function () { + return process.cwd(); + }, + readDirectory: readDirectory, + getMemoryUsage: function () { + if (global.gc) { + global.gc(); + } + return process.memoryUsage().heapUsed; + }, + exit: function (exitCode) { + process.exit(exitCode); + } + }; + } + if (typeof WScript !== "undefined" && typeof ActiveXObject === "function") { + return getWScriptSystem(); + } + else if (typeof process !== "undefined" && process.nextTick && !process.browser && typeof require !== "undefined") { + return getNodeSystem(); + } + else { + return undefined; + } + })(); +})(ts || (ts = {})); +var ts; +(function (ts) { + ts.Diagnostics = { + Unterminated_string_literal: { code: 1002, category: ts.DiagnosticCategory.Error, key: "Unterminated_string_literal_1002", message: "Unterminated string literal." }, + Identifier_expected: { code: 1003, category: ts.DiagnosticCategory.Error, key: "Identifier_expected_1003", message: "Identifier expected." }, + _0_expected: { code: 1005, category: ts.DiagnosticCategory.Error, key: "_0_expected_1005", message: "'{0}' expected." }, + A_file_cannot_have_a_reference_to_itself: { code: 1006, category: ts.DiagnosticCategory.Error, key: "A_file_cannot_have_a_reference_to_itself_1006", message: "A file cannot have a reference to itself." }, + Trailing_comma_not_allowed: { code: 1009, category: ts.DiagnosticCategory.Error, key: "Trailing_comma_not_allowed_1009", message: "Trailing comma not allowed." }, + Asterisk_Slash_expected: { code: 1010, category: ts.DiagnosticCategory.Error, key: "Asterisk_Slash_expected_1010", message: "'*/' expected." }, + Unexpected_token: { code: 1012, category: ts.DiagnosticCategory.Error, key: "Unexpected_token_1012", message: "Unexpected token." }, + A_rest_parameter_must_be_last_in_a_parameter_list: { code: 1014, category: ts.DiagnosticCategory.Error, key: "A_rest_parameter_must_be_last_in_a_parameter_list_1014", message: "A rest parameter must be last in a parameter list." }, + Parameter_cannot_have_question_mark_and_initializer: { code: 1015, category: ts.DiagnosticCategory.Error, key: "Parameter_cannot_have_question_mark_and_initializer_1015", message: "Parameter cannot have question mark and initializer." }, + A_required_parameter_cannot_follow_an_optional_parameter: { code: 1016, category: ts.DiagnosticCategory.Error, key: "A_required_parameter_cannot_follow_an_optional_parameter_1016", message: "A required parameter cannot follow an optional parameter." }, + An_index_signature_cannot_have_a_rest_parameter: { code: 1017, category: ts.DiagnosticCategory.Error, key: "An_index_signature_cannot_have_a_rest_parameter_1017", message: "An index signature cannot have a rest parameter." }, + An_index_signature_parameter_cannot_have_an_accessibility_modifier: { code: 1018, category: ts.DiagnosticCategory.Error, key: "An_index_signature_parameter_cannot_have_an_accessibility_modifier_1018", message: "An index signature parameter cannot have an accessibility modifier." }, + An_index_signature_parameter_cannot_have_a_question_mark: { code: 1019, category: ts.DiagnosticCategory.Error, key: "An_index_signature_parameter_cannot_have_a_question_mark_1019", message: "An index signature parameter cannot have a question mark." }, + An_index_signature_parameter_cannot_have_an_initializer: { code: 1020, category: ts.DiagnosticCategory.Error, key: "An_index_signature_parameter_cannot_have_an_initializer_1020", message: "An index signature parameter cannot have an initializer." }, + An_index_signature_must_have_a_type_annotation: { code: 1021, category: ts.DiagnosticCategory.Error, key: "An_index_signature_must_have_a_type_annotation_1021", message: "An index signature must have a type annotation." }, + An_index_signature_parameter_must_have_a_type_annotation: { code: 1022, category: ts.DiagnosticCategory.Error, key: "An_index_signature_parameter_must_have_a_type_annotation_1022", message: "An index signature parameter must have a type annotation." }, + An_index_signature_parameter_type_must_be_string_or_number: { code: 1023, category: ts.DiagnosticCategory.Error, key: "An_index_signature_parameter_type_must_be_string_or_number_1023", message: "An index signature parameter type must be 'string' or 'number'." }, + Accessibility_modifier_already_seen: { code: 1028, category: ts.DiagnosticCategory.Error, key: "Accessibility_modifier_already_seen_1028", message: "Accessibility modifier already seen." }, + _0_modifier_must_precede_1_modifier: { code: 1029, category: ts.DiagnosticCategory.Error, key: "_0_modifier_must_precede_1_modifier_1029", message: "'{0}' modifier must precede '{1}' modifier." }, + _0_modifier_already_seen: { code: 1030, category: ts.DiagnosticCategory.Error, key: "_0_modifier_already_seen_1030", message: "'{0}' modifier already seen." }, + _0_modifier_cannot_appear_on_a_class_element: { code: 1031, category: ts.DiagnosticCategory.Error, key: "_0_modifier_cannot_appear_on_a_class_element_1031", message: "'{0}' modifier cannot appear on a class element." }, + super_must_be_followed_by_an_argument_list_or_member_access: { code: 1034, category: ts.DiagnosticCategory.Error, key: "super_must_be_followed_by_an_argument_list_or_member_access_1034", message: "'super' must be followed by an argument list or member access." }, + Only_ambient_modules_can_use_quoted_names: { code: 1035, category: ts.DiagnosticCategory.Error, key: "Only_ambient_modules_can_use_quoted_names_1035", message: "Only ambient modules can use quoted names." }, + Statements_are_not_allowed_in_ambient_contexts: { code: 1036, category: ts.DiagnosticCategory.Error, key: "Statements_are_not_allowed_in_ambient_contexts_1036", message: "Statements are not allowed in ambient contexts." }, + A_declare_modifier_cannot_be_used_in_an_already_ambient_context: { code: 1038, category: ts.DiagnosticCategory.Error, key: "A_declare_modifier_cannot_be_used_in_an_already_ambient_context_1038", message: "A 'declare' modifier cannot be used in an already ambient context." }, + Initializers_are_not_allowed_in_ambient_contexts: { code: 1039, category: ts.DiagnosticCategory.Error, key: "Initializers_are_not_allowed_in_ambient_contexts_1039", message: "Initializers are not allowed in ambient contexts." }, + _0_modifier_cannot_be_used_in_an_ambient_context: { code: 1040, category: ts.DiagnosticCategory.Error, key: "_0_modifier_cannot_be_used_in_an_ambient_context_1040", message: "'{0}' modifier cannot be used in an ambient context." }, + _0_modifier_cannot_be_used_with_a_class_declaration: { code: 1041, category: ts.DiagnosticCategory.Error, key: "_0_modifier_cannot_be_used_with_a_class_declaration_1041", message: "'{0}' modifier cannot be used with a class declaration." }, + _0_modifier_cannot_be_used_here: { code: 1042, category: ts.DiagnosticCategory.Error, key: "_0_modifier_cannot_be_used_here_1042", message: "'{0}' modifier cannot be used here." }, + _0_modifier_cannot_appear_on_a_data_property: { code: 1043, category: ts.DiagnosticCategory.Error, key: "_0_modifier_cannot_appear_on_a_data_property_1043", message: "'{0}' modifier cannot appear on a data property." }, + _0_modifier_cannot_appear_on_a_module_element: { code: 1044, category: ts.DiagnosticCategory.Error, key: "_0_modifier_cannot_appear_on_a_module_element_1044", message: "'{0}' modifier cannot appear on a module element." }, + A_0_modifier_cannot_be_used_with_an_interface_declaration: { code: 1045, category: ts.DiagnosticCategory.Error, key: "A_0_modifier_cannot_be_used_with_an_interface_declaration_1045", message: "A '{0}' modifier cannot be used with an interface declaration." }, + A_declare_modifier_is_required_for_a_top_level_declaration_in_a_d_ts_file: { code: 1046, category: ts.DiagnosticCategory.Error, key: "A_declare_modifier_is_required_for_a_top_level_declaration_in_a_d_ts_file_1046", message: "A 'declare' modifier is required for a top level declaration in a .d.ts file." }, + A_rest_parameter_cannot_be_optional: { code: 1047, category: ts.DiagnosticCategory.Error, key: "A_rest_parameter_cannot_be_optional_1047", message: "A rest parameter cannot be optional." }, + A_rest_parameter_cannot_have_an_initializer: { code: 1048, category: ts.DiagnosticCategory.Error, key: "A_rest_parameter_cannot_have_an_initializer_1048", message: "A rest parameter cannot have an initializer." }, + A_set_accessor_must_have_exactly_one_parameter: { code: 1049, category: ts.DiagnosticCategory.Error, key: "A_set_accessor_must_have_exactly_one_parameter_1049", message: "A 'set' accessor must have exactly one parameter." }, + A_set_accessor_cannot_have_an_optional_parameter: { code: 1051, category: ts.DiagnosticCategory.Error, key: "A_set_accessor_cannot_have_an_optional_parameter_1051", message: "A 'set' accessor cannot have an optional parameter." }, + A_set_accessor_parameter_cannot_have_an_initializer: { code: 1052, category: ts.DiagnosticCategory.Error, key: "A_set_accessor_parameter_cannot_have_an_initializer_1052", message: "A 'set' accessor parameter cannot have an initializer." }, + A_set_accessor_cannot_have_rest_parameter: { code: 1053, category: ts.DiagnosticCategory.Error, key: "A_set_accessor_cannot_have_rest_parameter_1053", message: "A 'set' accessor cannot have rest parameter." }, + A_get_accessor_cannot_have_parameters: { code: 1054, category: ts.DiagnosticCategory.Error, key: "A_get_accessor_cannot_have_parameters_1054", message: "A 'get' accessor cannot have parameters." }, + Type_0_is_not_a_valid_async_function_return_type: { code: 1055, category: ts.DiagnosticCategory.Error, key: "Type_0_is_not_a_valid_async_function_return_type_1055", message: "Type '{0}' is not a valid async function return type." }, + Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher: { code: 1056, category: ts.DiagnosticCategory.Error, key: "Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher_1056", message: "Accessors are only available when targeting ECMAScript 5 and higher." }, + An_async_function_or_method_must_have_a_valid_awaitable_return_type: { code: 1057, category: ts.DiagnosticCategory.Error, key: "An_async_function_or_method_must_have_a_valid_awaitable_return_type_1057", message: "An async function or method must have a valid awaitable return type." }, + Operand_for_await_does_not_have_a_valid_callable_then_member: { code: 1058, category: ts.DiagnosticCategory.Error, key: "Operand_for_await_does_not_have_a_valid_callable_then_member_1058", message: "Operand for 'await' does not have a valid callable 'then' member." }, + Return_expression_in_async_function_does_not_have_a_valid_callable_then_member: { code: 1059, category: ts.DiagnosticCategory.Error, key: "Return_expression_in_async_function_does_not_have_a_valid_callable_then_member_1059", message: "Return expression in async function does not have a valid callable 'then' member." }, + Expression_body_for_async_arrow_function_does_not_have_a_valid_callable_then_member: { code: 1060, category: ts.DiagnosticCategory.Error, key: "Expression_body_for_async_arrow_function_does_not_have_a_valid_callable_then_member_1060", message: "Expression body for async arrow function does not have a valid callable 'then' member." }, + Enum_member_must_have_initializer: { code: 1061, category: ts.DiagnosticCategory.Error, key: "Enum_member_must_have_initializer_1061", message: "Enum member must have initializer." }, + _0_is_referenced_directly_or_indirectly_in_the_fulfillment_callback_of_its_own_then_method: { code: 1062, category: ts.DiagnosticCategory.Error, key: "_0_is_referenced_directly_or_indirectly_in_the_fulfillment_callback_of_its_own_then_method_1062", message: "{0} is referenced directly or indirectly in the fulfillment callback of its own 'then' method." }, + An_export_assignment_cannot_be_used_in_a_namespace: { code: 1063, category: ts.DiagnosticCategory.Error, key: "An_export_assignment_cannot_be_used_in_a_namespace_1063", message: "An export assignment cannot be used in a namespace." }, + In_ambient_enum_declarations_member_initializer_must_be_constant_expression: { code: 1066, category: ts.DiagnosticCategory.Error, key: "In_ambient_enum_declarations_member_initializer_must_be_constant_expression_1066", message: "In ambient enum declarations member initializer must be constant expression." }, + Unexpected_token_A_constructor_method_accessor_or_property_was_expected: { code: 1068, category: ts.DiagnosticCategory.Error, key: "Unexpected_token_A_constructor_method_accessor_or_property_was_expected_1068", message: "Unexpected token. A constructor, method, accessor, or property was expected." }, + A_0_modifier_cannot_be_used_with_an_import_declaration: { code: 1079, category: ts.DiagnosticCategory.Error, key: "A_0_modifier_cannot_be_used_with_an_import_declaration_1079", message: "A '{0}' modifier cannot be used with an import declaration." }, + Invalid_reference_directive_syntax: { code: 1084, category: ts.DiagnosticCategory.Error, key: "Invalid_reference_directive_syntax_1084", message: "Invalid 'reference' directive syntax." }, + Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher: { code: 1085, category: ts.DiagnosticCategory.Error, key: "Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher_1085", message: "Octal literals are not available when targeting ECMAScript 5 and higher." }, + An_accessor_cannot_be_declared_in_an_ambient_context: { code: 1086, category: ts.DiagnosticCategory.Error, key: "An_accessor_cannot_be_declared_in_an_ambient_context_1086", message: "An accessor cannot be declared in an ambient context." }, + _0_modifier_cannot_appear_on_a_constructor_declaration: { code: 1089, category: ts.DiagnosticCategory.Error, key: "_0_modifier_cannot_appear_on_a_constructor_declaration_1089", message: "'{0}' modifier cannot appear on a constructor declaration." }, + _0_modifier_cannot_appear_on_a_parameter: { code: 1090, category: ts.DiagnosticCategory.Error, key: "_0_modifier_cannot_appear_on_a_parameter_1090", message: "'{0}' modifier cannot appear on a parameter." }, + Only_a_single_variable_declaration_is_allowed_in_a_for_in_statement: { code: 1091, category: ts.DiagnosticCategory.Error, key: "Only_a_single_variable_declaration_is_allowed_in_a_for_in_statement_1091", message: "Only a single variable declaration is allowed in a 'for...in' statement." }, + Type_parameters_cannot_appear_on_a_constructor_declaration: { code: 1092, category: ts.DiagnosticCategory.Error, key: "Type_parameters_cannot_appear_on_a_constructor_declaration_1092", message: "Type parameters cannot appear on a constructor declaration." }, + Type_annotation_cannot_appear_on_a_constructor_declaration: { code: 1093, category: ts.DiagnosticCategory.Error, key: "Type_annotation_cannot_appear_on_a_constructor_declaration_1093", message: "Type annotation cannot appear on a constructor declaration." }, + An_accessor_cannot_have_type_parameters: { code: 1094, category: ts.DiagnosticCategory.Error, key: "An_accessor_cannot_have_type_parameters_1094", message: "An accessor cannot have type parameters." }, + A_set_accessor_cannot_have_a_return_type_annotation: { code: 1095, category: ts.DiagnosticCategory.Error, key: "A_set_accessor_cannot_have_a_return_type_annotation_1095", message: "A 'set' accessor cannot have a return type annotation." }, + An_index_signature_must_have_exactly_one_parameter: { code: 1096, category: ts.DiagnosticCategory.Error, key: "An_index_signature_must_have_exactly_one_parameter_1096", message: "An index signature must have exactly one parameter." }, + _0_list_cannot_be_empty: { code: 1097, category: ts.DiagnosticCategory.Error, key: "_0_list_cannot_be_empty_1097", message: "'{0}' list cannot be empty." }, + Type_parameter_list_cannot_be_empty: { code: 1098, category: ts.DiagnosticCategory.Error, key: "Type_parameter_list_cannot_be_empty_1098", message: "Type parameter list cannot be empty." }, + Type_argument_list_cannot_be_empty: { code: 1099, category: ts.DiagnosticCategory.Error, key: "Type_argument_list_cannot_be_empty_1099", message: "Type argument list cannot be empty." }, + Invalid_use_of_0_in_strict_mode: { code: 1100, category: ts.DiagnosticCategory.Error, key: "Invalid_use_of_0_in_strict_mode_1100", message: "Invalid use of '{0}' in strict mode." }, + with_statements_are_not_allowed_in_strict_mode: { code: 1101, category: ts.DiagnosticCategory.Error, key: "with_statements_are_not_allowed_in_strict_mode_1101", message: "'with' statements are not allowed in strict mode." }, + delete_cannot_be_called_on_an_identifier_in_strict_mode: { code: 1102, category: ts.DiagnosticCategory.Error, key: "delete_cannot_be_called_on_an_identifier_in_strict_mode_1102", message: "'delete' cannot be called on an identifier in strict mode." }, + A_continue_statement_can_only_be_used_within_an_enclosing_iteration_statement: { code: 1104, category: ts.DiagnosticCategory.Error, key: "A_continue_statement_can_only_be_used_within_an_enclosing_iteration_statement_1104", message: "A 'continue' statement can only be used within an enclosing iteration statement." }, + A_break_statement_can_only_be_used_within_an_enclosing_iteration_or_switch_statement: { code: 1105, category: ts.DiagnosticCategory.Error, key: "A_break_statement_can_only_be_used_within_an_enclosing_iteration_or_switch_statement_1105", message: "A 'break' statement can only be used within an enclosing iteration or switch statement." }, + Jump_target_cannot_cross_function_boundary: { code: 1107, category: ts.DiagnosticCategory.Error, key: "Jump_target_cannot_cross_function_boundary_1107", message: "Jump target cannot cross function boundary." }, + A_return_statement_can_only_be_used_within_a_function_body: { code: 1108, category: ts.DiagnosticCategory.Error, key: "A_return_statement_can_only_be_used_within_a_function_body_1108", message: "A 'return' statement can only be used within a function body." }, + Expression_expected: { code: 1109, category: ts.DiagnosticCategory.Error, key: "Expression_expected_1109", message: "Expression expected." }, + Type_expected: { code: 1110, category: ts.DiagnosticCategory.Error, key: "Type_expected_1110", message: "Type expected." }, + A_class_member_cannot_be_declared_optional: { code: 1112, category: ts.DiagnosticCategory.Error, key: "A_class_member_cannot_be_declared_optional_1112", message: "A class member cannot be declared optional." }, + A_default_clause_cannot_appear_more_than_once_in_a_switch_statement: { code: 1113, category: ts.DiagnosticCategory.Error, key: "A_default_clause_cannot_appear_more_than_once_in_a_switch_statement_1113", message: "A 'default' clause cannot appear more than once in a 'switch' statement." }, + Duplicate_label_0: { code: 1114, category: ts.DiagnosticCategory.Error, key: "Duplicate_label_0_1114", message: "Duplicate label '{0}'" }, + A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement: { code: 1115, category: ts.DiagnosticCategory.Error, key: "A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement_1115", message: "A 'continue' statement can only jump to a label of an enclosing iteration statement." }, + A_break_statement_can_only_jump_to_a_label_of_an_enclosing_statement: { code: 1116, category: ts.DiagnosticCategory.Error, key: "A_break_statement_can_only_jump_to_a_label_of_an_enclosing_statement_1116", message: "A 'break' statement can only jump to a label of an enclosing statement." }, + An_object_literal_cannot_have_multiple_properties_with_the_same_name_in_strict_mode: { code: 1117, category: ts.DiagnosticCategory.Error, key: "An_object_literal_cannot_have_multiple_properties_with_the_same_name_in_strict_mode_1117", message: "An object literal cannot have multiple properties with the same name in strict mode." }, + An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name: { code: 1118, category: ts.DiagnosticCategory.Error, key: "An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name_1118", message: "An object literal cannot have multiple get/set accessors with the same name." }, + An_object_literal_cannot_have_property_and_accessor_with_the_same_name: { code: 1119, category: ts.DiagnosticCategory.Error, key: "An_object_literal_cannot_have_property_and_accessor_with_the_same_name_1119", message: "An object literal cannot have property and accessor with the same name." }, + An_export_assignment_cannot_have_modifiers: { code: 1120, category: ts.DiagnosticCategory.Error, key: "An_export_assignment_cannot_have_modifiers_1120", message: "An export assignment cannot have modifiers." }, + Octal_literals_are_not_allowed_in_strict_mode: { code: 1121, category: ts.DiagnosticCategory.Error, key: "Octal_literals_are_not_allowed_in_strict_mode_1121", message: "Octal literals are not allowed in strict mode." }, + A_tuple_type_element_list_cannot_be_empty: { code: 1122, category: ts.DiagnosticCategory.Error, key: "A_tuple_type_element_list_cannot_be_empty_1122", message: "A tuple type element list cannot be empty." }, + Variable_declaration_list_cannot_be_empty: { code: 1123, category: ts.DiagnosticCategory.Error, key: "Variable_declaration_list_cannot_be_empty_1123", message: "Variable declaration list cannot be empty." }, + Digit_expected: { code: 1124, category: ts.DiagnosticCategory.Error, key: "Digit_expected_1124", message: "Digit expected." }, + Hexadecimal_digit_expected: { code: 1125, category: ts.DiagnosticCategory.Error, key: "Hexadecimal_digit_expected_1125", message: "Hexadecimal digit expected." }, + Unexpected_end_of_text: { code: 1126, category: ts.DiagnosticCategory.Error, key: "Unexpected_end_of_text_1126", message: "Unexpected end of text." }, + Invalid_character: { code: 1127, category: ts.DiagnosticCategory.Error, key: "Invalid_character_1127", message: "Invalid character." }, + Declaration_or_statement_expected: { code: 1128, category: ts.DiagnosticCategory.Error, key: "Declaration_or_statement_expected_1128", message: "Declaration or statement expected." }, + Statement_expected: { code: 1129, category: ts.DiagnosticCategory.Error, key: "Statement_expected_1129", message: "Statement expected." }, + case_or_default_expected: { code: 1130, category: ts.DiagnosticCategory.Error, key: "case_or_default_expected_1130", message: "'case' or 'default' expected." }, + Property_or_signature_expected: { code: 1131, category: ts.DiagnosticCategory.Error, key: "Property_or_signature_expected_1131", message: "Property or signature expected." }, + Enum_member_expected: { code: 1132, category: ts.DiagnosticCategory.Error, key: "Enum_member_expected_1132", message: "Enum member expected." }, + Variable_declaration_expected: { code: 1134, category: ts.DiagnosticCategory.Error, key: "Variable_declaration_expected_1134", message: "Variable declaration expected." }, + Argument_expression_expected: { code: 1135, category: ts.DiagnosticCategory.Error, key: "Argument_expression_expected_1135", message: "Argument expression expected." }, + Property_assignment_expected: { code: 1136, category: ts.DiagnosticCategory.Error, key: "Property_assignment_expected_1136", message: "Property assignment expected." }, + Expression_or_comma_expected: { code: 1137, category: ts.DiagnosticCategory.Error, key: "Expression_or_comma_expected_1137", message: "Expression or comma expected." }, + Parameter_declaration_expected: { code: 1138, category: ts.DiagnosticCategory.Error, key: "Parameter_declaration_expected_1138", message: "Parameter declaration expected." }, + Type_parameter_declaration_expected: { code: 1139, category: ts.DiagnosticCategory.Error, key: "Type_parameter_declaration_expected_1139", message: "Type parameter declaration expected." }, + Type_argument_expected: { code: 1140, category: ts.DiagnosticCategory.Error, key: "Type_argument_expected_1140", message: "Type argument expected." }, + String_literal_expected: { code: 1141, category: ts.DiagnosticCategory.Error, key: "String_literal_expected_1141", message: "String literal expected." }, + Line_break_not_permitted_here: { code: 1142, category: ts.DiagnosticCategory.Error, key: "Line_break_not_permitted_here_1142", message: "Line break not permitted here." }, + or_expected: { code: 1144, category: ts.DiagnosticCategory.Error, key: "or_expected_1144", message: "'{' or ';' expected." }, + Modifiers_not_permitted_on_index_signature_members: { code: 1145, category: ts.DiagnosticCategory.Error, key: "Modifiers_not_permitted_on_index_signature_members_1145", message: "Modifiers not permitted on index signature members." }, + Declaration_expected: { code: 1146, category: ts.DiagnosticCategory.Error, key: "Declaration_expected_1146", message: "Declaration expected." }, + Import_declarations_in_a_namespace_cannot_reference_a_module: { code: 1147, category: ts.DiagnosticCategory.Error, key: "Import_declarations_in_a_namespace_cannot_reference_a_module_1147", message: "Import declarations in a namespace cannot reference a module." }, + Cannot_compile_modules_unless_the_module_flag_is_provided: { code: 1148, category: ts.DiagnosticCategory.Error, key: "Cannot_compile_modules_unless_the_module_flag_is_provided_1148", message: "Cannot compile modules unless the '--module' flag is provided." }, + File_name_0_differs_from_already_included_file_name_1_only_in_casing: { code: 1149, category: ts.DiagnosticCategory.Error, key: "File_name_0_differs_from_already_included_file_name_1_only_in_casing_1149", message: "File name '{0}' differs from already included file name '{1}' only in casing" }, + new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead: { code: 1150, category: ts.DiagnosticCategory.Error, key: "new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead_1150", message: "'new T[]' cannot be used to create an array. Use 'new Array()' instead." }, + const_declarations_must_be_initialized: { code: 1155, category: ts.DiagnosticCategory.Error, key: "const_declarations_must_be_initialized_1155", message: "'const' declarations must be initialized" }, + const_declarations_can_only_be_declared_inside_a_block: { code: 1156, category: ts.DiagnosticCategory.Error, key: "const_declarations_can_only_be_declared_inside_a_block_1156", message: "'const' declarations can only be declared inside a block." }, + let_declarations_can_only_be_declared_inside_a_block: { code: 1157, category: ts.DiagnosticCategory.Error, key: "let_declarations_can_only_be_declared_inside_a_block_1157", message: "'let' declarations can only be declared inside a block." }, + Unterminated_template_literal: { code: 1160, category: ts.DiagnosticCategory.Error, key: "Unterminated_template_literal_1160", message: "Unterminated template literal." }, + Unterminated_regular_expression_literal: { code: 1161, category: ts.DiagnosticCategory.Error, key: "Unterminated_regular_expression_literal_1161", message: "Unterminated regular expression literal." }, + An_object_member_cannot_be_declared_optional: { code: 1162, category: ts.DiagnosticCategory.Error, key: "An_object_member_cannot_be_declared_optional_1162", message: "An object member cannot be declared optional." }, + A_yield_expression_is_only_allowed_in_a_generator_body: { code: 1163, category: ts.DiagnosticCategory.Error, key: "A_yield_expression_is_only_allowed_in_a_generator_body_1163", message: "A 'yield' expression is only allowed in a generator body." }, + Computed_property_names_are_not_allowed_in_enums: { code: 1164, category: ts.DiagnosticCategory.Error, key: "Computed_property_names_are_not_allowed_in_enums_1164", message: "Computed property names are not allowed in enums." }, + A_computed_property_name_in_an_ambient_context_must_directly_refer_to_a_built_in_symbol: { code: 1165, category: ts.DiagnosticCategory.Error, key: "A_computed_property_name_in_an_ambient_context_must_directly_refer_to_a_built_in_symbol_1165", message: "A computed property name in an ambient context must directly refer to a built-in symbol." }, + A_computed_property_name_in_a_class_property_declaration_must_directly_refer_to_a_built_in_symbol: { code: 1166, category: ts.DiagnosticCategory.Error, key: "A_computed_property_name_in_a_class_property_declaration_must_directly_refer_to_a_built_in_symbol_1166", message: "A computed property name in a class property declaration must directly refer to a built-in symbol." }, + A_computed_property_name_in_a_method_overload_must_directly_refer_to_a_built_in_symbol: { code: 1168, category: ts.DiagnosticCategory.Error, key: "A_computed_property_name_in_a_method_overload_must_directly_refer_to_a_built_in_symbol_1168", message: "A computed property name in a method overload must directly refer to a built-in symbol." }, + A_computed_property_name_in_an_interface_must_directly_refer_to_a_built_in_symbol: { code: 1169, category: ts.DiagnosticCategory.Error, key: "A_computed_property_name_in_an_interface_must_directly_refer_to_a_built_in_symbol_1169", message: "A computed property name in an interface must directly refer to a built-in symbol." }, + A_computed_property_name_in_a_type_literal_must_directly_refer_to_a_built_in_symbol: { code: 1170, category: ts.DiagnosticCategory.Error, key: "A_computed_property_name_in_a_type_literal_must_directly_refer_to_a_built_in_symbol_1170", message: "A computed property name in a type literal must directly refer to a built-in symbol." }, + A_comma_expression_is_not_allowed_in_a_computed_property_name: { code: 1171, category: ts.DiagnosticCategory.Error, key: "A_comma_expression_is_not_allowed_in_a_computed_property_name_1171", message: "A comma expression is not allowed in a computed property name." }, + extends_clause_already_seen: { code: 1172, category: ts.DiagnosticCategory.Error, key: "extends_clause_already_seen_1172", message: "'extends' clause already seen." }, + extends_clause_must_precede_implements_clause: { code: 1173, category: ts.DiagnosticCategory.Error, key: "extends_clause_must_precede_implements_clause_1173", message: "'extends' clause must precede 'implements' clause." }, + Classes_can_only_extend_a_single_class: { code: 1174, category: ts.DiagnosticCategory.Error, key: "Classes_can_only_extend_a_single_class_1174", message: "Classes can only extend a single class." }, + implements_clause_already_seen: { code: 1175, category: ts.DiagnosticCategory.Error, key: "implements_clause_already_seen_1175", message: "'implements' clause already seen." }, + Interface_declaration_cannot_have_implements_clause: { code: 1176, category: ts.DiagnosticCategory.Error, key: "Interface_declaration_cannot_have_implements_clause_1176", message: "Interface declaration cannot have 'implements' clause." }, + Binary_digit_expected: { code: 1177, category: ts.DiagnosticCategory.Error, key: "Binary_digit_expected_1177", message: "Binary digit expected." }, + Octal_digit_expected: { code: 1178, category: ts.DiagnosticCategory.Error, key: "Octal_digit_expected_1178", message: "Octal digit expected." }, + Unexpected_token_expected: { code: 1179, category: ts.DiagnosticCategory.Error, key: "Unexpected_token_expected_1179", message: "Unexpected token. '{' expected." }, + Property_destructuring_pattern_expected: { code: 1180, category: ts.DiagnosticCategory.Error, key: "Property_destructuring_pattern_expected_1180", message: "Property destructuring pattern expected." }, + Array_element_destructuring_pattern_expected: { code: 1181, category: ts.DiagnosticCategory.Error, key: "Array_element_destructuring_pattern_expected_1181", message: "Array element destructuring pattern expected." }, + A_destructuring_declaration_must_have_an_initializer: { code: 1182, category: ts.DiagnosticCategory.Error, key: "A_destructuring_declaration_must_have_an_initializer_1182", message: "A destructuring declaration must have an initializer." }, + An_implementation_cannot_be_declared_in_ambient_contexts: { code: 1183, category: ts.DiagnosticCategory.Error, key: "An_implementation_cannot_be_declared_in_ambient_contexts_1183", message: "An implementation cannot be declared in ambient contexts." }, + Modifiers_cannot_appear_here: { code: 1184, category: ts.DiagnosticCategory.Error, key: "Modifiers_cannot_appear_here_1184", message: "Modifiers cannot appear here." }, + Merge_conflict_marker_encountered: { code: 1185, category: ts.DiagnosticCategory.Error, key: "Merge_conflict_marker_encountered_1185", message: "Merge conflict marker encountered." }, + A_rest_element_cannot_have_an_initializer: { code: 1186, category: ts.DiagnosticCategory.Error, key: "A_rest_element_cannot_have_an_initializer_1186", message: "A rest element cannot have an initializer." }, + A_parameter_property_may_not_be_a_binding_pattern: { code: 1187, category: ts.DiagnosticCategory.Error, key: "A_parameter_property_may_not_be_a_binding_pattern_1187", message: "A parameter property may not be a binding pattern." }, + Only_a_single_variable_declaration_is_allowed_in_a_for_of_statement: { code: 1188, category: ts.DiagnosticCategory.Error, key: "Only_a_single_variable_declaration_is_allowed_in_a_for_of_statement_1188", message: "Only a single variable declaration is allowed in a 'for...of' statement." }, + The_variable_declaration_of_a_for_in_statement_cannot_have_an_initializer: { code: 1189, category: ts.DiagnosticCategory.Error, key: "The_variable_declaration_of_a_for_in_statement_cannot_have_an_initializer_1189", message: "The variable declaration of a 'for...in' statement cannot have an initializer." }, + The_variable_declaration_of_a_for_of_statement_cannot_have_an_initializer: { code: 1190, category: ts.DiagnosticCategory.Error, key: "The_variable_declaration_of_a_for_of_statement_cannot_have_an_initializer_1190", message: "The variable declaration of a 'for...of' statement cannot have an initializer." }, + An_import_declaration_cannot_have_modifiers: { code: 1191, category: ts.DiagnosticCategory.Error, key: "An_import_declaration_cannot_have_modifiers_1191", message: "An import declaration cannot have modifiers." }, + Module_0_has_no_default_export: { code: 1192, category: ts.DiagnosticCategory.Error, key: "Module_0_has_no_default_export_1192", message: "Module '{0}' has no default export." }, + An_export_declaration_cannot_have_modifiers: { code: 1193, category: ts.DiagnosticCategory.Error, key: "An_export_declaration_cannot_have_modifiers_1193", message: "An export declaration cannot have modifiers." }, + Export_declarations_are_not_permitted_in_a_namespace: { code: 1194, category: ts.DiagnosticCategory.Error, key: "Export_declarations_are_not_permitted_in_a_namespace_1194", message: "Export declarations are not permitted in a namespace." }, + Catch_clause_variable_name_must_be_an_identifier: { code: 1195, category: ts.DiagnosticCategory.Error, key: "Catch_clause_variable_name_must_be_an_identifier_1195", message: "Catch clause variable name must be an identifier." }, + Catch_clause_variable_cannot_have_a_type_annotation: { code: 1196, category: ts.DiagnosticCategory.Error, key: "Catch_clause_variable_cannot_have_a_type_annotation_1196", message: "Catch clause variable cannot have a type annotation." }, + Catch_clause_variable_cannot_have_an_initializer: { code: 1197, category: ts.DiagnosticCategory.Error, key: "Catch_clause_variable_cannot_have_an_initializer_1197", message: "Catch clause variable cannot have an initializer." }, + An_extended_Unicode_escape_value_must_be_between_0x0_and_0x10FFFF_inclusive: { code: 1198, category: ts.DiagnosticCategory.Error, key: "An_extended_Unicode_escape_value_must_be_between_0x0_and_0x10FFFF_inclusive_1198", message: "An extended Unicode escape value must be between 0x0 and 0x10FFFF inclusive." }, + Unterminated_Unicode_escape_sequence: { code: 1199, category: ts.DiagnosticCategory.Error, key: "Unterminated_Unicode_escape_sequence_1199", message: "Unterminated Unicode escape sequence." }, + Line_terminator_not_permitted_before_arrow: { code: 1200, category: ts.DiagnosticCategory.Error, key: "Line_terminator_not_permitted_before_arrow_1200", message: "Line terminator not permitted before arrow." }, + Import_assignment_cannot_be_used_when_targeting_ECMAScript_6_modules_Consider_using_import_Asterisk_as_ns_from_mod_import_a_from_mod_import_d_from_mod_or_another_module_format_instead: { code: 1202, category: ts.DiagnosticCategory.Error, key: "Import_assignment_cannot_be_used_when_targeting_ECMAScript_6_modules_Consider_using_import_Asterisk__1202", message: "Import assignment cannot be used when targeting ECMAScript 6 modules. Consider using 'import * as ns from \"mod\"', 'import {a} from \"mod\"', 'import d from \"mod\"', or another module format instead." }, + Export_assignment_cannot_be_used_when_targeting_ECMAScript_6_modules_Consider_using_export_default_or_another_module_format_instead: { code: 1203, category: ts.DiagnosticCategory.Error, key: "Export_assignment_cannot_be_used_when_targeting_ECMAScript_6_modules_Consider_using_export_default_o_1203", message: "Export assignment cannot be used when targeting ECMAScript 6 modules. Consider using 'export default' or another module format instead." }, + Cannot_compile_modules_into_es2015_when_targeting_ES5_or_lower: { code: 1204, category: ts.DiagnosticCategory.Error, key: "Cannot_compile_modules_into_es2015_when_targeting_ES5_or_lower_1204", message: "Cannot compile modules into 'es2015' when targeting 'ES5' or lower." }, + Decorators_are_not_valid_here: { code: 1206, category: ts.DiagnosticCategory.Error, key: "Decorators_are_not_valid_here_1206", message: "Decorators are not valid here." }, + Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name: { code: 1207, category: ts.DiagnosticCategory.Error, key: "Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name_1207", message: "Decorators cannot be applied to multiple get/set accessors of the same name." }, + Cannot_compile_namespaces_when_the_isolatedModules_flag_is_provided: { code: 1208, category: ts.DiagnosticCategory.Error, key: "Cannot_compile_namespaces_when_the_isolatedModules_flag_is_provided_1208", message: "Cannot compile namespaces when the '--isolatedModules' flag is provided." }, + Ambient_const_enums_are_not_allowed_when_the_isolatedModules_flag_is_provided: { code: 1209, category: ts.DiagnosticCategory.Error, key: "Ambient_const_enums_are_not_allowed_when_the_isolatedModules_flag_is_provided_1209", message: "Ambient const enums are not allowed when the '--isolatedModules' flag is provided." }, + Invalid_use_of_0_Class_definitions_are_automatically_in_strict_mode: { code: 1210, category: ts.DiagnosticCategory.Error, key: "Invalid_use_of_0_Class_definitions_are_automatically_in_strict_mode_1210", message: "Invalid use of '{0}'. Class definitions are automatically in strict mode." }, + A_class_declaration_without_the_default_modifier_must_have_a_name: { code: 1211, category: ts.DiagnosticCategory.Error, key: "A_class_declaration_without_the_default_modifier_must_have_a_name_1211", message: "A class declaration without the 'default' modifier must have a name" }, + Identifier_expected_0_is_a_reserved_word_in_strict_mode: { code: 1212, category: ts.DiagnosticCategory.Error, key: "Identifier_expected_0_is_a_reserved_word_in_strict_mode_1212", message: "Identifier expected. '{0}' is a reserved word in strict mode" }, + Identifier_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_strict_mode: { code: 1213, category: ts.DiagnosticCategory.Error, key: "Identifier_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_stric_1213", message: "Identifier expected. '{0}' is a reserved word in strict mode. Class definitions are automatically in strict mode." }, + Identifier_expected_0_is_a_reserved_word_in_strict_mode_Modules_are_automatically_in_strict_mode: { code: 1214, category: ts.DiagnosticCategory.Error, key: "Identifier_expected_0_is_a_reserved_word_in_strict_mode_Modules_are_automatically_in_strict_mode_1214", message: "Identifier expected. '{0}' is a reserved word in strict mode. Modules are automatically in strict mode." }, + Invalid_use_of_0_Modules_are_automatically_in_strict_mode: { code: 1215, category: ts.DiagnosticCategory.Error, key: "Invalid_use_of_0_Modules_are_automatically_in_strict_mode_1215", message: "Invalid use of '{0}'. Modules are automatically in strict mode." }, + Export_assignment_is_not_supported_when_module_flag_is_system: { code: 1218, category: ts.DiagnosticCategory.Error, key: "Export_assignment_is_not_supported_when_module_flag_is_system_1218", message: "Export assignment is not supported when '--module' flag is 'system'." }, + Experimental_support_for_decorators_is_a_feature_that_is_subject_to_change_in_a_future_release_Specify_experimentalDecorators_to_remove_this_warning: { code: 1219, category: ts.DiagnosticCategory.Error, key: "Experimental_support_for_decorators_is_a_feature_that_is_subject_to_change_in_a_future_release_Speci_1219", message: "Experimental support for decorators is a feature that is subject to change in a future release. Specify '--experimentalDecorators' to remove this warning." }, + Generators_are_only_available_when_targeting_ECMAScript_6_or_higher: { code: 1220, category: ts.DiagnosticCategory.Error, key: "Generators_are_only_available_when_targeting_ECMAScript_6_or_higher_1220", message: "Generators are only available when targeting ECMAScript 6 or higher." }, + Generators_are_not_allowed_in_an_ambient_context: { code: 1221, category: ts.DiagnosticCategory.Error, key: "Generators_are_not_allowed_in_an_ambient_context_1221", message: "Generators are not allowed in an ambient context." }, + An_overload_signature_cannot_be_declared_as_a_generator: { code: 1222, category: ts.DiagnosticCategory.Error, key: "An_overload_signature_cannot_be_declared_as_a_generator_1222", message: "An overload signature cannot be declared as a generator." }, + _0_tag_already_specified: { code: 1223, category: ts.DiagnosticCategory.Error, key: "_0_tag_already_specified_1223", message: "'{0}' tag already specified." }, + Signature_0_must_have_a_type_predicate: { code: 1224, category: ts.DiagnosticCategory.Error, key: "Signature_0_must_have_a_type_predicate_1224", message: "Signature '{0}' must have a type predicate." }, + Cannot_find_parameter_0: { code: 1225, category: ts.DiagnosticCategory.Error, key: "Cannot_find_parameter_0_1225", message: "Cannot find parameter '{0}'." }, + Type_predicate_0_is_not_assignable_to_1: { code: 1226, category: ts.DiagnosticCategory.Error, key: "Type_predicate_0_is_not_assignable_to_1_1226", message: "Type predicate '{0}' is not assignable to '{1}'." }, + Parameter_0_is_not_in_the_same_position_as_parameter_1: { code: 1227, category: ts.DiagnosticCategory.Error, key: "Parameter_0_is_not_in_the_same_position_as_parameter_1_1227", message: "Parameter '{0}' is not in the same position as parameter '{1}'." }, + A_type_predicate_is_only_allowed_in_return_type_position_for_functions_and_methods: { code: 1228, category: ts.DiagnosticCategory.Error, key: "A_type_predicate_is_only_allowed_in_return_type_position_for_functions_and_methods_1228", message: "A type predicate is only allowed in return type position for functions and methods." }, + A_type_predicate_cannot_reference_a_rest_parameter: { code: 1229, category: ts.DiagnosticCategory.Error, key: "A_type_predicate_cannot_reference_a_rest_parameter_1229", message: "A type predicate cannot reference a rest parameter." }, + A_type_predicate_cannot_reference_element_0_in_a_binding_pattern: { code: 1230, category: ts.DiagnosticCategory.Error, key: "A_type_predicate_cannot_reference_element_0_in_a_binding_pattern_1230", message: "A type predicate cannot reference element '{0}' in a binding pattern." }, + An_export_assignment_can_only_be_used_in_a_module: { code: 1231, category: ts.DiagnosticCategory.Error, key: "An_export_assignment_can_only_be_used_in_a_module_1231", message: "An export assignment can only be used in a module." }, + An_import_declaration_can_only_be_used_in_a_namespace_or_module: { code: 1232, category: ts.DiagnosticCategory.Error, key: "An_import_declaration_can_only_be_used_in_a_namespace_or_module_1232", message: "An import declaration can only be used in a namespace or module." }, + An_export_declaration_can_only_be_used_in_a_module: { code: 1233, category: ts.DiagnosticCategory.Error, key: "An_export_declaration_can_only_be_used_in_a_module_1233", message: "An export declaration can only be used in a module." }, + An_ambient_module_declaration_is_only_allowed_at_the_top_level_in_a_file: { code: 1234, category: ts.DiagnosticCategory.Error, key: "An_ambient_module_declaration_is_only_allowed_at_the_top_level_in_a_file_1234", message: "An ambient module declaration is only allowed at the top level in a file." }, + A_namespace_declaration_is_only_allowed_in_a_namespace_or_module: { code: 1235, category: ts.DiagnosticCategory.Error, key: "A_namespace_declaration_is_only_allowed_in_a_namespace_or_module_1235", message: "A namespace declaration is only allowed in a namespace or module." }, + The_return_type_of_a_property_decorator_function_must_be_either_void_or_any: { code: 1236, category: ts.DiagnosticCategory.Error, key: "The_return_type_of_a_property_decorator_function_must_be_either_void_or_any_1236", message: "The return type of a property decorator function must be either 'void' or 'any'." }, + The_return_type_of_a_parameter_decorator_function_must_be_either_void_or_any: { code: 1237, category: ts.DiagnosticCategory.Error, key: "The_return_type_of_a_parameter_decorator_function_must_be_either_void_or_any_1237", message: "The return type of a parameter decorator function must be either 'void' or 'any'." }, + Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression: { code: 1238, category: ts.DiagnosticCategory.Error, key: "Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression_1238", message: "Unable to resolve signature of class decorator when called as an expression." }, + Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression: { code: 1239, category: ts.DiagnosticCategory.Error, key: "Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression_1239", message: "Unable to resolve signature of parameter decorator when called as an expression." }, + Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression: { code: 1240, category: ts.DiagnosticCategory.Error, key: "Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression_1240", message: "Unable to resolve signature of property decorator when called as an expression." }, + Unable_to_resolve_signature_of_method_decorator_when_called_as_an_expression: { code: 1241, category: ts.DiagnosticCategory.Error, key: "Unable_to_resolve_signature_of_method_decorator_when_called_as_an_expression_1241", message: "Unable to resolve signature of method decorator when called as an expression." }, + abstract_modifier_can_only_appear_on_a_class_or_method_declaration: { code: 1242, category: ts.DiagnosticCategory.Error, key: "abstract_modifier_can_only_appear_on_a_class_or_method_declaration_1242", message: "'abstract' modifier can only appear on a class or method declaration." }, + _0_modifier_cannot_be_used_with_1_modifier: { code: 1243, category: ts.DiagnosticCategory.Error, key: "_0_modifier_cannot_be_used_with_1_modifier_1243", message: "'{0}' modifier cannot be used with '{1}' modifier." }, + Abstract_methods_can_only_appear_within_an_abstract_class: { code: 1244, category: ts.DiagnosticCategory.Error, key: "Abstract_methods_can_only_appear_within_an_abstract_class_1244", message: "Abstract methods can only appear within an abstract class." }, + Method_0_cannot_have_an_implementation_because_it_is_marked_abstract: { code: 1245, category: ts.DiagnosticCategory.Error, key: "Method_0_cannot_have_an_implementation_because_it_is_marked_abstract_1245", message: "Method '{0}' cannot have an implementation because it is marked abstract." }, + with_statements_are_not_allowed_in_an_async_function_block: { code: 1300, category: ts.DiagnosticCategory.Error, key: "with_statements_are_not_allowed_in_an_async_function_block_1300", message: "'with' statements are not allowed in an async function block." }, + await_expression_is_only_allowed_within_an_async_function: { code: 1308, category: ts.DiagnosticCategory.Error, key: "await_expression_is_only_allowed_within_an_async_function_1308", message: "'await' expression is only allowed within an async function." }, + Async_functions_are_only_available_when_targeting_ECMAScript_6_and_higher: { code: 1311, category: ts.DiagnosticCategory.Error, key: "Async_functions_are_only_available_when_targeting_ECMAScript_6_and_higher_1311", message: "Async functions are only available when targeting ECMAScript 6 and higher." }, + can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment: { code: 1312, category: ts.DiagnosticCategory.Error, key: "can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment_1312", message: "'=' can only be used in an object literal property inside a destructuring assignment." }, + Duplicate_identifier_0: { code: 2300, category: ts.DiagnosticCategory.Error, key: "Duplicate_identifier_0_2300", message: "Duplicate identifier '{0}'." }, + Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor: { code: 2301, category: ts.DiagnosticCategory.Error, key: "Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor_2301", message: "Initializer of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor." }, + Static_members_cannot_reference_class_type_parameters: { code: 2302, category: ts.DiagnosticCategory.Error, key: "Static_members_cannot_reference_class_type_parameters_2302", message: "Static members cannot reference class type parameters." }, + Circular_definition_of_import_alias_0: { code: 2303, category: ts.DiagnosticCategory.Error, key: "Circular_definition_of_import_alias_0_2303", message: "Circular definition of import alias '{0}'." }, + Cannot_find_name_0: { code: 2304, category: ts.DiagnosticCategory.Error, key: "Cannot_find_name_0_2304", message: "Cannot find name '{0}'." }, + Module_0_has_no_exported_member_1: { code: 2305, category: ts.DiagnosticCategory.Error, key: "Module_0_has_no_exported_member_1_2305", message: "Module '{0}' has no exported member '{1}'." }, + File_0_is_not_a_module: { code: 2306, category: ts.DiagnosticCategory.Error, key: "File_0_is_not_a_module_2306", message: "File '{0}' is not a module." }, + Cannot_find_module_0: { code: 2307, category: ts.DiagnosticCategory.Error, key: "Cannot_find_module_0_2307", message: "Cannot find module '{0}'." }, + An_export_assignment_cannot_be_used_in_a_module_with_other_exported_elements: { code: 2309, category: ts.DiagnosticCategory.Error, key: "An_export_assignment_cannot_be_used_in_a_module_with_other_exported_elements_2309", message: "An export assignment cannot be used in a module with other exported elements." }, + Type_0_recursively_references_itself_as_a_base_type: { code: 2310, category: ts.DiagnosticCategory.Error, key: "Type_0_recursively_references_itself_as_a_base_type_2310", message: "Type '{0}' recursively references itself as a base type." }, + A_class_may_only_extend_another_class: { code: 2311, category: ts.DiagnosticCategory.Error, key: "A_class_may_only_extend_another_class_2311", message: "A class may only extend another class." }, + An_interface_may_only_extend_a_class_or_another_interface: { code: 2312, category: ts.DiagnosticCategory.Error, key: "An_interface_may_only_extend_a_class_or_another_interface_2312", message: "An interface may only extend a class or another interface." }, + Constraint_of_a_type_parameter_cannot_reference_any_type_parameter_from_the_same_type_parameter_list: { code: 2313, category: ts.DiagnosticCategory.Error, key: "Constraint_of_a_type_parameter_cannot_reference_any_type_parameter_from_the_same_type_parameter_list_2313", message: "Constraint of a type parameter cannot reference any type parameter from the same type parameter list." }, + Generic_type_0_requires_1_type_argument_s: { code: 2314, category: ts.DiagnosticCategory.Error, key: "Generic_type_0_requires_1_type_argument_s_2314", message: "Generic type '{0}' requires {1} type argument(s)." }, + Type_0_is_not_generic: { code: 2315, category: ts.DiagnosticCategory.Error, key: "Type_0_is_not_generic_2315", message: "Type '{0}' is not generic." }, + Global_type_0_must_be_a_class_or_interface_type: { code: 2316, category: ts.DiagnosticCategory.Error, key: "Global_type_0_must_be_a_class_or_interface_type_2316", message: "Global type '{0}' must be a class or interface type." }, + Global_type_0_must_have_1_type_parameter_s: { code: 2317, category: ts.DiagnosticCategory.Error, key: "Global_type_0_must_have_1_type_parameter_s_2317", message: "Global type '{0}' must have {1} type parameter(s)." }, + Cannot_find_global_type_0: { code: 2318, category: ts.DiagnosticCategory.Error, key: "Cannot_find_global_type_0_2318", message: "Cannot find global type '{0}'." }, + Named_property_0_of_types_1_and_2_are_not_identical: { code: 2319, category: ts.DiagnosticCategory.Error, key: "Named_property_0_of_types_1_and_2_are_not_identical_2319", message: "Named property '{0}' of types '{1}' and '{2}' are not identical." }, + Interface_0_cannot_simultaneously_extend_types_1_and_2: { code: 2320, category: ts.DiagnosticCategory.Error, key: "Interface_0_cannot_simultaneously_extend_types_1_and_2_2320", message: "Interface '{0}' cannot simultaneously extend types '{1}' and '{2}'." }, + Excessive_stack_depth_comparing_types_0_and_1: { code: 2321, category: ts.DiagnosticCategory.Error, key: "Excessive_stack_depth_comparing_types_0_and_1_2321", message: "Excessive stack depth comparing types '{0}' and '{1}'." }, + Type_0_is_not_assignable_to_type_1: { code: 2322, category: ts.DiagnosticCategory.Error, key: "Type_0_is_not_assignable_to_type_1_2322", message: "Type '{0}' is not assignable to type '{1}'." }, + Property_0_is_missing_in_type_1: { code: 2324, category: ts.DiagnosticCategory.Error, key: "Property_0_is_missing_in_type_1_2324", message: "Property '{0}' is missing in type '{1}'." }, + Property_0_is_private_in_type_1_but_not_in_type_2: { code: 2325, category: ts.DiagnosticCategory.Error, key: "Property_0_is_private_in_type_1_but_not_in_type_2_2325", message: "Property '{0}' is private in type '{1}' but not in type '{2}'." }, + Types_of_property_0_are_incompatible: { code: 2326, category: ts.DiagnosticCategory.Error, key: "Types_of_property_0_are_incompatible_2326", message: "Types of property '{0}' are incompatible." }, + Property_0_is_optional_in_type_1_but_required_in_type_2: { code: 2327, category: ts.DiagnosticCategory.Error, key: "Property_0_is_optional_in_type_1_but_required_in_type_2_2327", message: "Property '{0}' is optional in type '{1}' but required in type '{2}'." }, + Types_of_parameters_0_and_1_are_incompatible: { code: 2328, category: ts.DiagnosticCategory.Error, key: "Types_of_parameters_0_and_1_are_incompatible_2328", message: "Types of parameters '{0}' and '{1}' are incompatible." }, + Index_signature_is_missing_in_type_0: { code: 2329, category: ts.DiagnosticCategory.Error, key: "Index_signature_is_missing_in_type_0_2329", message: "Index signature is missing in type '{0}'." }, + Index_signatures_are_incompatible: { code: 2330, category: ts.DiagnosticCategory.Error, key: "Index_signatures_are_incompatible_2330", message: "Index signatures are incompatible." }, + this_cannot_be_referenced_in_a_module_or_namespace_body: { code: 2331, category: ts.DiagnosticCategory.Error, key: "this_cannot_be_referenced_in_a_module_or_namespace_body_2331", message: "'this' cannot be referenced in a module or namespace body." }, + this_cannot_be_referenced_in_current_location: { code: 2332, category: ts.DiagnosticCategory.Error, key: "this_cannot_be_referenced_in_current_location_2332", message: "'this' cannot be referenced in current location." }, + this_cannot_be_referenced_in_constructor_arguments: { code: 2333, category: ts.DiagnosticCategory.Error, key: "this_cannot_be_referenced_in_constructor_arguments_2333", message: "'this' cannot be referenced in constructor arguments." }, + this_cannot_be_referenced_in_a_static_property_initializer: { code: 2334, category: ts.DiagnosticCategory.Error, key: "this_cannot_be_referenced_in_a_static_property_initializer_2334", message: "'this' cannot be referenced in a static property initializer." }, + super_can_only_be_referenced_in_a_derived_class: { code: 2335, category: ts.DiagnosticCategory.Error, key: "super_can_only_be_referenced_in_a_derived_class_2335", message: "'super' can only be referenced in a derived class." }, + super_cannot_be_referenced_in_constructor_arguments: { code: 2336, category: ts.DiagnosticCategory.Error, key: "super_cannot_be_referenced_in_constructor_arguments_2336", message: "'super' cannot be referenced in constructor arguments." }, + Super_calls_are_not_permitted_outside_constructors_or_in_nested_functions_inside_constructors: { code: 2337, category: ts.DiagnosticCategory.Error, key: "Super_calls_are_not_permitted_outside_constructors_or_in_nested_functions_inside_constructors_2337", message: "Super calls are not permitted outside constructors or in nested functions inside constructors." }, + super_property_access_is_permitted_only_in_a_constructor_member_function_or_member_accessor_of_a_derived_class: { code: 2338, category: ts.DiagnosticCategory.Error, key: "super_property_access_is_permitted_only_in_a_constructor_member_function_or_member_accessor_of_a_der_2338", message: "'super' property access is permitted only in a constructor, member function, or member accessor of a derived class." }, + Property_0_does_not_exist_on_type_1: { code: 2339, category: ts.DiagnosticCategory.Error, key: "Property_0_does_not_exist_on_type_1_2339", message: "Property '{0}' does not exist on type '{1}'." }, + Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword: { code: 2340, category: ts.DiagnosticCategory.Error, key: "Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword_2340", message: "Only public and protected methods of the base class are accessible via the 'super' keyword." }, + Property_0_is_private_and_only_accessible_within_class_1: { code: 2341, category: ts.DiagnosticCategory.Error, key: "Property_0_is_private_and_only_accessible_within_class_1_2341", message: "Property '{0}' is private and only accessible within class '{1}'." }, + An_index_expression_argument_must_be_of_type_string_number_symbol_or_any: { code: 2342, category: ts.DiagnosticCategory.Error, key: "An_index_expression_argument_must_be_of_type_string_number_symbol_or_any_2342", message: "An index expression argument must be of type 'string', 'number', 'symbol', or 'any'." }, + Type_0_does_not_satisfy_the_constraint_1: { code: 2344, category: ts.DiagnosticCategory.Error, key: "Type_0_does_not_satisfy_the_constraint_1_2344", message: "Type '{0}' does not satisfy the constraint '{1}'." }, + Argument_of_type_0_is_not_assignable_to_parameter_of_type_1: { code: 2345, category: ts.DiagnosticCategory.Error, key: "Argument_of_type_0_is_not_assignable_to_parameter_of_type_1_2345", message: "Argument of type '{0}' is not assignable to parameter of type '{1}'." }, + Supplied_parameters_do_not_match_any_signature_of_call_target: { code: 2346, category: ts.DiagnosticCategory.Error, key: "Supplied_parameters_do_not_match_any_signature_of_call_target_2346", message: "Supplied parameters do not match any signature of call target." }, + Untyped_function_calls_may_not_accept_type_arguments: { code: 2347, category: ts.DiagnosticCategory.Error, key: "Untyped_function_calls_may_not_accept_type_arguments_2347", message: "Untyped function calls may not accept type arguments." }, + Value_of_type_0_is_not_callable_Did_you_mean_to_include_new: { code: 2348, category: ts.DiagnosticCategory.Error, key: "Value_of_type_0_is_not_callable_Did_you_mean_to_include_new_2348", message: "Value of type '{0}' is not callable. Did you mean to include 'new'?" }, + Cannot_invoke_an_expression_whose_type_lacks_a_call_signature: { code: 2349, category: ts.DiagnosticCategory.Error, key: "Cannot_invoke_an_expression_whose_type_lacks_a_call_signature_2349", message: "Cannot invoke an expression whose type lacks a call signature." }, + Only_a_void_function_can_be_called_with_the_new_keyword: { code: 2350, category: ts.DiagnosticCategory.Error, key: "Only_a_void_function_can_be_called_with_the_new_keyword_2350", message: "Only a void function can be called with the 'new' keyword." }, + Cannot_use_new_with_an_expression_whose_type_lacks_a_call_or_construct_signature: { code: 2351, category: ts.DiagnosticCategory.Error, key: "Cannot_use_new_with_an_expression_whose_type_lacks_a_call_or_construct_signature_2351", message: "Cannot use 'new' with an expression whose type lacks a call or construct signature." }, + Neither_type_0_nor_type_1_is_assignable_to_the_other: { code: 2352, category: ts.DiagnosticCategory.Error, key: "Neither_type_0_nor_type_1_is_assignable_to_the_other_2352", message: "Neither type '{0}' nor type '{1}' is assignable to the other." }, + Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1: { code: 2353, category: ts.DiagnosticCategory.Error, key: "Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1_2353", message: "Object literal may only specify known properties, and '{0}' does not exist in type '{1}'." }, + No_best_common_type_exists_among_return_expressions: { code: 2354, category: ts.DiagnosticCategory.Error, key: "No_best_common_type_exists_among_return_expressions_2354", message: "No best common type exists among return expressions." }, + A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value_or_consist_of_a_single_throw_statement: { code: 2355, category: ts.DiagnosticCategory.Error, key: "A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value_or_consist_of_a_single_th_2355", message: "A function whose declared type is neither 'void' nor 'any' must return a value or consist of a single 'throw' statement." }, + An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type: { code: 2356, category: ts.DiagnosticCategory.Error, key: "An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type_2356", message: "An arithmetic operand must be of type 'any', 'number' or an enum type." }, + The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_property_or_indexer: { code: 2357, category: ts.DiagnosticCategory.Error, key: "The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_property_or_indexer_2357", message: "The operand of an increment or decrement operator must be a variable, property or indexer." }, + The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_parameter: { code: 2358, category: ts.DiagnosticCategory.Error, key: "The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_paramete_2358", message: "The left-hand side of an 'instanceof' expression must be of type 'any', an object type or a type parameter." }, + The_right_hand_side_of_an_instanceof_expression_must_be_of_type_any_or_of_a_type_assignable_to_the_Function_interface_type: { code: 2359, category: ts.DiagnosticCategory.Error, key: "The_right_hand_side_of_an_instanceof_expression_must_be_of_type_any_or_of_a_type_assignable_to_the_F_2359", message: "The right-hand side of an 'instanceof' expression must be of type 'any' or of a type assignable to the 'Function' interface type." }, + The_left_hand_side_of_an_in_expression_must_be_of_type_any_string_number_or_symbol: { code: 2360, category: ts.DiagnosticCategory.Error, key: "The_left_hand_side_of_an_in_expression_must_be_of_type_any_string_number_or_symbol_2360", message: "The left-hand side of an 'in' expression must be of type 'any', 'string', 'number', or 'symbol'." }, + The_right_hand_side_of_an_in_expression_must_be_of_type_any_an_object_type_or_a_type_parameter: { code: 2361, category: ts.DiagnosticCategory.Error, key: "The_right_hand_side_of_an_in_expression_must_be_of_type_any_an_object_type_or_a_type_parameter_2361", message: "The right-hand side of an 'in' expression must be of type 'any', an object type or a type parameter" }, + The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type: { code: 2362, category: ts.DiagnosticCategory.Error, key: "The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type_2362", message: "The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type." }, + The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type: { code: 2363, category: ts.DiagnosticCategory.Error, key: "The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type_2363", message: "The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type." }, + Invalid_left_hand_side_of_assignment_expression: { code: 2364, category: ts.DiagnosticCategory.Error, key: "Invalid_left_hand_side_of_assignment_expression_2364", message: "Invalid left-hand side of assignment expression." }, + Operator_0_cannot_be_applied_to_types_1_and_2: { code: 2365, category: ts.DiagnosticCategory.Error, key: "Operator_0_cannot_be_applied_to_types_1_and_2_2365", message: "Operator '{0}' cannot be applied to types '{1}' and '{2}'." }, + Type_parameter_name_cannot_be_0: { code: 2368, category: ts.DiagnosticCategory.Error, key: "Type_parameter_name_cannot_be_0_2368", message: "Type parameter name cannot be '{0}'" }, + A_parameter_property_is_only_allowed_in_a_constructor_implementation: { code: 2369, category: ts.DiagnosticCategory.Error, key: "A_parameter_property_is_only_allowed_in_a_constructor_implementation_2369", message: "A parameter property is only allowed in a constructor implementation." }, + A_rest_parameter_must_be_of_an_array_type: { code: 2370, category: ts.DiagnosticCategory.Error, key: "A_rest_parameter_must_be_of_an_array_type_2370", message: "A rest parameter must be of an array type." }, + A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation: { code: 2371, category: ts.DiagnosticCategory.Error, key: "A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation_2371", message: "A parameter initializer is only allowed in a function or constructor implementation." }, + Parameter_0_cannot_be_referenced_in_its_initializer: { code: 2372, category: ts.DiagnosticCategory.Error, key: "Parameter_0_cannot_be_referenced_in_its_initializer_2372", message: "Parameter '{0}' cannot be referenced in its initializer." }, + Initializer_of_parameter_0_cannot_reference_identifier_1_declared_after_it: { code: 2373, category: ts.DiagnosticCategory.Error, key: "Initializer_of_parameter_0_cannot_reference_identifier_1_declared_after_it_2373", message: "Initializer of parameter '{0}' cannot reference identifier '{1}' declared after it." }, + Duplicate_string_index_signature: { code: 2374, category: ts.DiagnosticCategory.Error, key: "Duplicate_string_index_signature_2374", message: "Duplicate string index signature." }, + Duplicate_number_index_signature: { code: 2375, category: ts.DiagnosticCategory.Error, key: "Duplicate_number_index_signature_2375", message: "Duplicate number index signature." }, + A_super_call_must_be_the_first_statement_in_the_constructor_when_a_class_contains_initialized_properties_or_has_parameter_properties: { code: 2376, category: ts.DiagnosticCategory.Error, key: "A_super_call_must_be_the_first_statement_in_the_constructor_when_a_class_contains_initialized_proper_2376", message: "A 'super' call must be the first statement in the constructor when a class contains initialized properties or has parameter properties." }, + Constructors_for_derived_classes_must_contain_a_super_call: { code: 2377, category: ts.DiagnosticCategory.Error, key: "Constructors_for_derived_classes_must_contain_a_super_call_2377", message: "Constructors for derived classes must contain a 'super' call." }, + A_get_accessor_must_return_a_value_or_consist_of_a_single_throw_statement: { code: 2378, category: ts.DiagnosticCategory.Error, key: "A_get_accessor_must_return_a_value_or_consist_of_a_single_throw_statement_2378", message: "A 'get' accessor must return a value or consist of a single 'throw' statement." }, + Getter_and_setter_accessors_do_not_agree_in_visibility: { code: 2379, category: ts.DiagnosticCategory.Error, key: "Getter_and_setter_accessors_do_not_agree_in_visibility_2379", message: "Getter and setter accessors do not agree in visibility." }, + get_and_set_accessor_must_have_the_same_type: { code: 2380, category: ts.DiagnosticCategory.Error, key: "get_and_set_accessor_must_have_the_same_type_2380", message: "'get' and 'set' accessor must have the same type." }, + A_signature_with_an_implementation_cannot_use_a_string_literal_type: { code: 2381, category: ts.DiagnosticCategory.Error, key: "A_signature_with_an_implementation_cannot_use_a_string_literal_type_2381", message: "A signature with an implementation cannot use a string literal type." }, + Specialized_overload_signature_is_not_assignable_to_any_non_specialized_signature: { code: 2382, category: ts.DiagnosticCategory.Error, key: "Specialized_overload_signature_is_not_assignable_to_any_non_specialized_signature_2382", message: "Specialized overload signature is not assignable to any non-specialized signature." }, + Overload_signatures_must_all_be_exported_or_not_exported: { code: 2383, category: ts.DiagnosticCategory.Error, key: "Overload_signatures_must_all_be_exported_or_not_exported_2383", message: "Overload signatures must all be exported or not exported." }, + Overload_signatures_must_all_be_ambient_or_non_ambient: { code: 2384, category: ts.DiagnosticCategory.Error, key: "Overload_signatures_must_all_be_ambient_or_non_ambient_2384", message: "Overload signatures must all be ambient or non-ambient." }, + Overload_signatures_must_all_be_public_private_or_protected: { code: 2385, category: ts.DiagnosticCategory.Error, key: "Overload_signatures_must_all_be_public_private_or_protected_2385", message: "Overload signatures must all be public, private or protected." }, + Overload_signatures_must_all_be_optional_or_required: { code: 2386, category: ts.DiagnosticCategory.Error, key: "Overload_signatures_must_all_be_optional_or_required_2386", message: "Overload signatures must all be optional or required." }, + Function_overload_must_be_static: { code: 2387, category: ts.DiagnosticCategory.Error, key: "Function_overload_must_be_static_2387", message: "Function overload must be static." }, + Function_overload_must_not_be_static: { code: 2388, category: ts.DiagnosticCategory.Error, key: "Function_overload_must_not_be_static_2388", message: "Function overload must not be static." }, + Function_implementation_name_must_be_0: { code: 2389, category: ts.DiagnosticCategory.Error, key: "Function_implementation_name_must_be_0_2389", message: "Function implementation name must be '{0}'." }, + Constructor_implementation_is_missing: { code: 2390, category: ts.DiagnosticCategory.Error, key: "Constructor_implementation_is_missing_2390", message: "Constructor implementation is missing." }, + Function_implementation_is_missing_or_not_immediately_following_the_declaration: { code: 2391, category: ts.DiagnosticCategory.Error, key: "Function_implementation_is_missing_or_not_immediately_following_the_declaration_2391", message: "Function implementation is missing or not immediately following the declaration." }, + Multiple_constructor_implementations_are_not_allowed: { code: 2392, category: ts.DiagnosticCategory.Error, key: "Multiple_constructor_implementations_are_not_allowed_2392", message: "Multiple constructor implementations are not allowed." }, + Duplicate_function_implementation: { code: 2393, category: ts.DiagnosticCategory.Error, key: "Duplicate_function_implementation_2393", message: "Duplicate function implementation." }, + Overload_signature_is_not_compatible_with_function_implementation: { code: 2394, category: ts.DiagnosticCategory.Error, key: "Overload_signature_is_not_compatible_with_function_implementation_2394", message: "Overload signature is not compatible with function implementation." }, + Individual_declarations_in_merged_declaration_0_must_be_all_exported_or_all_local: { code: 2395, category: ts.DiagnosticCategory.Error, key: "Individual_declarations_in_merged_declaration_0_must_be_all_exported_or_all_local_2395", message: "Individual declarations in merged declaration '{0}' must be all exported or all local." }, + Duplicate_identifier_arguments_Compiler_uses_arguments_to_initialize_rest_parameters: { code: 2396, category: ts.DiagnosticCategory.Error, key: "Duplicate_identifier_arguments_Compiler_uses_arguments_to_initialize_rest_parameters_2396", message: "Duplicate identifier 'arguments'. Compiler uses 'arguments' to initialize rest parameters." }, + Duplicate_identifier_this_Compiler_uses_variable_declaration_this_to_capture_this_reference: { code: 2399, category: ts.DiagnosticCategory.Error, key: "Duplicate_identifier_this_Compiler_uses_variable_declaration_this_to_capture_this_reference_2399", message: "Duplicate identifier '_this'. Compiler uses variable declaration '_this' to capture 'this' reference." }, + Expression_resolves_to_variable_declaration_this_that_compiler_uses_to_capture_this_reference: { code: 2400, category: ts.DiagnosticCategory.Error, key: "Expression_resolves_to_variable_declaration_this_that_compiler_uses_to_capture_this_reference_2400", message: "Expression resolves to variable declaration '_this' that compiler uses to capture 'this' reference." }, + Duplicate_identifier_super_Compiler_uses_super_to_capture_base_class_reference: { code: 2401, category: ts.DiagnosticCategory.Error, key: "Duplicate_identifier_super_Compiler_uses_super_to_capture_base_class_reference_2401", message: "Duplicate identifier '_super'. Compiler uses '_super' to capture base class reference." }, + Expression_resolves_to_super_that_compiler_uses_to_capture_base_class_reference: { code: 2402, category: ts.DiagnosticCategory.Error, key: "Expression_resolves_to_super_that_compiler_uses_to_capture_base_class_reference_2402", message: "Expression resolves to '_super' that compiler uses to capture base class reference." }, + Subsequent_variable_declarations_must_have_the_same_type_Variable_0_must_be_of_type_1_but_here_has_type_2: { code: 2403, category: ts.DiagnosticCategory.Error, key: "Subsequent_variable_declarations_must_have_the_same_type_Variable_0_must_be_of_type_1_but_here_has_t_2403", message: "Subsequent variable declarations must have the same type. Variable '{0}' must be of type '{1}', but here has type '{2}'." }, + The_left_hand_side_of_a_for_in_statement_cannot_use_a_type_annotation: { code: 2404, category: ts.DiagnosticCategory.Error, key: "The_left_hand_side_of_a_for_in_statement_cannot_use_a_type_annotation_2404", message: "The left-hand side of a 'for...in' statement cannot use a type annotation." }, + The_left_hand_side_of_a_for_in_statement_must_be_of_type_string_or_any: { code: 2405, category: ts.DiagnosticCategory.Error, key: "The_left_hand_side_of_a_for_in_statement_must_be_of_type_string_or_any_2405", message: "The left-hand side of a 'for...in' statement must be of type 'string' or 'any'." }, + Invalid_left_hand_side_in_for_in_statement: { code: 2406, category: ts.DiagnosticCategory.Error, key: "Invalid_left_hand_side_in_for_in_statement_2406", message: "Invalid left-hand side in 'for...in' statement." }, + The_right_hand_side_of_a_for_in_statement_must_be_of_type_any_an_object_type_or_a_type_parameter: { code: 2407, category: ts.DiagnosticCategory.Error, key: "The_right_hand_side_of_a_for_in_statement_must_be_of_type_any_an_object_type_or_a_type_parameter_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'." }, + 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}'." }, + Class_name_cannot_be_0: { code: 2414, category: ts.DiagnosticCategory.Error, key: "Class_name_cannot_be_0_2414", message: "Class name cannot be '{0}'" }, + Class_0_incorrectly_extends_base_class_1: { code: 2415, category: ts.DiagnosticCategory.Error, key: "Class_0_incorrectly_extends_base_class_1_2415", message: "Class '{0}' incorrectly extends base class '{1}'." }, + Class_static_side_0_incorrectly_extends_base_class_static_side_1: { code: 2417, category: ts.DiagnosticCategory.Error, key: "Class_static_side_0_incorrectly_extends_base_class_static_side_1_2417", message: "Class static side '{0}' incorrectly extends base class static side '{1}'." }, + Type_name_0_in_extends_clause_does_not_reference_constructor_function_for_0: { code: 2419, category: ts.DiagnosticCategory.Error, key: "Type_name_0_in_extends_clause_does_not_reference_constructor_function_for_0_2419", message: "Type name '{0}' in extends clause does not reference constructor function for '{0}'." }, + Class_0_incorrectly_implements_interface_1: { code: 2420, category: ts.DiagnosticCategory.Error, key: "Class_0_incorrectly_implements_interface_1_2420", message: "Class '{0}' incorrectly implements interface '{1}'." }, + A_class_may_only_implement_another_class_or_interface: { code: 2422, category: ts.DiagnosticCategory.Error, key: "A_class_may_only_implement_another_class_or_interface_2422", message: "A class may only implement another class or interface." }, + Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_accessor: { code: 2423, category: ts.DiagnosticCategory.Error, key: "Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_access_2423", message: "Class '{0}' defines instance member function '{1}', but extended class '{2}' defines it as instance member accessor." }, + Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_property: { code: 2424, category: ts.DiagnosticCategory.Error, key: "Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_proper_2424", message: "Class '{0}' defines instance member function '{1}', but extended class '{2}' defines it as instance member property." }, + Class_0_defines_instance_member_property_1_but_extended_class_2_defines_it_as_instance_member_function: { code: 2425, category: ts.DiagnosticCategory.Error, key: "Class_0_defines_instance_member_property_1_but_extended_class_2_defines_it_as_instance_member_functi_2425", message: "Class '{0}' defines instance member property '{1}', but extended class '{2}' defines it as instance member function." }, + Class_0_defines_instance_member_accessor_1_but_extended_class_2_defines_it_as_instance_member_function: { code: 2426, category: ts.DiagnosticCategory.Error, key: "Class_0_defines_instance_member_accessor_1_but_extended_class_2_defines_it_as_instance_member_functi_2426", message: "Class '{0}' defines instance member accessor '{1}', but extended class '{2}' defines it as instance member function." }, + Interface_name_cannot_be_0: { code: 2427, category: ts.DiagnosticCategory.Error, key: "Interface_name_cannot_be_0_2427", message: "Interface name cannot be '{0}'" }, + All_declarations_of_an_interface_must_have_identical_type_parameters: { code: 2428, category: ts.DiagnosticCategory.Error, key: "All_declarations_of_an_interface_must_have_identical_type_parameters_2428", message: "All declarations of an interface must have identical type parameters." }, + Interface_0_incorrectly_extends_interface_1: { code: 2430, category: ts.DiagnosticCategory.Error, key: "Interface_0_incorrectly_extends_interface_1_2430", message: "Interface '{0}' incorrectly extends interface '{1}'." }, + Enum_name_cannot_be_0: { code: 2431, category: ts.DiagnosticCategory.Error, key: "Enum_name_cannot_be_0_2431", message: "Enum name cannot be '{0}'" }, + In_an_enum_with_multiple_declarations_only_one_declaration_can_omit_an_initializer_for_its_first_enum_element: { code: 2432, category: ts.DiagnosticCategory.Error, key: "In_an_enum_with_multiple_declarations_only_one_declaration_can_omit_an_initializer_for_its_first_enu_2432", message: "In an enum with multiple declarations, only one declaration can omit an initializer for its first enum element." }, + A_namespace_declaration_cannot_be_in_a_different_file_from_a_class_or_function_with_which_it_is_merged: { code: 2433, category: ts.DiagnosticCategory.Error, key: "A_namespace_declaration_cannot_be_in_a_different_file_from_a_class_or_function_with_which_it_is_merg_2433", message: "A namespace declaration cannot be in a different file from a class or function with which it is merged" }, + A_namespace_declaration_cannot_be_located_prior_to_a_class_or_function_with_which_it_is_merged: { code: 2434, category: ts.DiagnosticCategory.Error, key: "A_namespace_declaration_cannot_be_located_prior_to_a_class_or_function_with_which_it_is_merged_2434", message: "A namespace declaration cannot be located prior to a class or function with which it is merged" }, + Ambient_modules_cannot_be_nested_in_other_modules_or_namespaces: { code: 2435, category: ts.DiagnosticCategory.Error, key: "Ambient_modules_cannot_be_nested_in_other_modules_or_namespaces_2435", message: "Ambient modules cannot be nested in other modules or namespaces." }, + Ambient_module_declaration_cannot_specify_relative_module_name: { code: 2436, category: ts.DiagnosticCategory.Error, key: "Ambient_module_declaration_cannot_specify_relative_module_name_2436", message: "Ambient module declaration cannot specify relative module name." }, + Module_0_is_hidden_by_a_local_declaration_with_the_same_name: { code: 2437, category: ts.DiagnosticCategory.Error, key: "Module_0_is_hidden_by_a_local_declaration_with_the_same_name_2437", message: "Module '{0}' is hidden by a local declaration with the same name" }, + Import_name_cannot_be_0: { code: 2438, category: ts.DiagnosticCategory.Error, key: "Import_name_cannot_be_0_2438", message: "Import name cannot be '{0}'" }, + Import_or_export_declaration_in_an_ambient_module_declaration_cannot_reference_module_through_relative_module_name: { code: 2439, category: ts.DiagnosticCategory.Error, key: "Import_or_export_declaration_in_an_ambient_module_declaration_cannot_reference_module_through_relati_2439", message: "Import or export declaration in an ambient module declaration cannot reference module through relative module name." }, + Import_declaration_conflicts_with_local_declaration_of_0: { code: 2440, category: ts.DiagnosticCategory.Error, key: "Import_declaration_conflicts_with_local_declaration_of_0_2440", message: "Import declaration conflicts with local declaration of '{0}'" }, + Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module: { code: 2441, category: ts.DiagnosticCategory.Error, key: "Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module_2441", message: "Duplicate identifier '{0}'. Compiler reserves name '{1}' in top level scope of a module." }, + Types_have_separate_declarations_of_a_private_property_0: { code: 2442, category: ts.DiagnosticCategory.Error, key: "Types_have_separate_declarations_of_a_private_property_0_2442", message: "Types have separate declarations of a private property '{0}'." }, + Property_0_is_protected_but_type_1_is_not_a_class_derived_from_2: { code: 2443, category: ts.DiagnosticCategory.Error, key: "Property_0_is_protected_but_type_1_is_not_a_class_derived_from_2_2443", message: "Property '{0}' is protected but type '{1}' is not a class derived from '{2}'." }, + Property_0_is_protected_in_type_1_but_public_in_type_2: { code: 2444, category: ts.DiagnosticCategory.Error, key: "Property_0_is_protected_in_type_1_but_public_in_type_2_2444", message: "Property '{0}' is protected in type '{1}' but public in type '{2}'." }, + Property_0_is_protected_and_only_accessible_within_class_1_and_its_subclasses: { code: 2445, category: ts.DiagnosticCategory.Error, key: "Property_0_is_protected_and_only_accessible_within_class_1_and_its_subclasses_2445", message: "Property '{0}' is protected and only accessible within class '{1}' and its subclasses." }, + Property_0_is_protected_and_only_accessible_through_an_instance_of_class_1: { code: 2446, category: ts.DiagnosticCategory.Error, key: "Property_0_is_protected_and_only_accessible_through_an_instance_of_class_1_2446", message: "Property '{0}' is protected and only accessible through an instance of class '{1}'." }, + The_0_operator_is_not_allowed_for_boolean_types_Consider_using_1_instead: { code: 2447, category: ts.DiagnosticCategory.Error, key: "The_0_operator_is_not_allowed_for_boolean_types_Consider_using_1_instead_2447", message: "The '{0}' operator is not allowed for boolean types. Consider using '{1}' instead." }, + Block_scoped_variable_0_used_before_its_declaration: { code: 2448, category: ts.DiagnosticCategory.Error, key: "Block_scoped_variable_0_used_before_its_declaration_2448", message: "Block-scoped variable '{0}' used before its declaration." }, + The_operand_of_an_increment_or_decrement_operator_cannot_be_a_constant: { code: 2449, category: ts.DiagnosticCategory.Error, key: "The_operand_of_an_increment_or_decrement_operator_cannot_be_a_constant_2449", message: "The operand of an increment or decrement operator cannot be a constant." }, + Left_hand_side_of_assignment_expression_cannot_be_a_constant: { code: 2450, category: ts.DiagnosticCategory.Error, key: "Left_hand_side_of_assignment_expression_cannot_be_a_constant_2450", message: "Left-hand side of assignment expression cannot be a constant." }, + Cannot_redeclare_block_scoped_variable_0: { code: 2451, category: ts.DiagnosticCategory.Error, key: "Cannot_redeclare_block_scoped_variable_0_2451", message: "Cannot redeclare block-scoped variable '{0}'." }, + An_enum_member_cannot_have_a_numeric_name: { code: 2452, category: ts.DiagnosticCategory.Error, key: "An_enum_member_cannot_have_a_numeric_name_2452", message: "An enum member cannot have a numeric name." }, + The_type_argument_for_type_parameter_0_cannot_be_inferred_from_the_usage_Consider_specifying_the_type_arguments_explicitly: { code: 2453, category: ts.DiagnosticCategory.Error, key: "The_type_argument_for_type_parameter_0_cannot_be_inferred_from_the_usage_Consider_specifying_the_typ_2453", message: "The type argument for type parameter '{0}' cannot be inferred from the usage. Consider specifying the type arguments explicitly." }, + Type_argument_candidate_1_is_not_a_valid_type_argument_because_it_is_not_a_supertype_of_candidate_0: { code: 2455, category: ts.DiagnosticCategory.Error, key: "Type_argument_candidate_1_is_not_a_valid_type_argument_because_it_is_not_a_supertype_of_candidate_0_2455", message: "Type argument candidate '{1}' is not a valid type argument because it is not a supertype of candidate '{0}'." }, + Type_alias_0_circularly_references_itself: { code: 2456, category: ts.DiagnosticCategory.Error, key: "Type_alias_0_circularly_references_itself_2456", message: "Type alias '{0}' circularly references itself." }, + Type_alias_name_cannot_be_0: { code: 2457, category: ts.DiagnosticCategory.Error, key: "Type_alias_name_cannot_be_0_2457", message: "Type alias name cannot be '{0}'" }, + An_AMD_module_cannot_have_multiple_name_assignments: { code: 2458, category: ts.DiagnosticCategory.Error, key: "An_AMD_module_cannot_have_multiple_name_assignments_2458", message: "An AMD module cannot have multiple name assignments." }, + Type_0_has_no_property_1_and_no_string_index_signature: { code: 2459, category: ts.DiagnosticCategory.Error, key: "Type_0_has_no_property_1_and_no_string_index_signature_2459", message: "Type '{0}' has no property '{1}' and no string index signature." }, + Type_0_has_no_property_1: { code: 2460, category: ts.DiagnosticCategory.Error, key: "Type_0_has_no_property_1_2460", message: "Type '{0}' has no property '{1}'." }, + Type_0_is_not_an_array_type: { code: 2461, category: ts.DiagnosticCategory.Error, key: "Type_0_is_not_an_array_type_2461", message: "Type '{0}' is not an array type." }, + A_rest_element_must_be_last_in_an_array_destructuring_pattern: { code: 2462, category: ts.DiagnosticCategory.Error, key: "A_rest_element_must_be_last_in_an_array_destructuring_pattern_2462", message: "A rest element must be last in an array destructuring pattern" }, + A_binding_pattern_parameter_cannot_be_optional_in_an_implementation_signature: { code: 2463, category: ts.DiagnosticCategory.Error, key: "A_binding_pattern_parameter_cannot_be_optional_in_an_implementation_signature_2463", message: "A binding pattern parameter cannot be optional in an implementation signature." }, + A_computed_property_name_must_be_of_type_string_number_symbol_or_any: { code: 2464, category: ts.DiagnosticCategory.Error, key: "A_computed_property_name_must_be_of_type_string_number_symbol_or_any_2464", message: "A computed property name must be of type 'string', 'number', 'symbol', or 'any'." }, + this_cannot_be_referenced_in_a_computed_property_name: { code: 2465, category: ts.DiagnosticCategory.Error, key: "this_cannot_be_referenced_in_a_computed_property_name_2465", message: "'this' cannot be referenced in a computed property name." }, + super_cannot_be_referenced_in_a_computed_property_name: { code: 2466, category: ts.DiagnosticCategory.Error, key: "super_cannot_be_referenced_in_a_computed_property_name_2466", message: "'super' cannot be referenced in a computed property name." }, + A_computed_property_name_cannot_reference_a_type_parameter_from_its_containing_type: { code: 2467, category: ts.DiagnosticCategory.Error, key: "A_computed_property_name_cannot_reference_a_type_parameter_from_its_containing_type_2467", message: "A computed property name cannot reference a type parameter from its containing type." }, + Cannot_find_global_value_0: { code: 2468, category: ts.DiagnosticCategory.Error, key: "Cannot_find_global_value_0_2468", message: "Cannot find global value '{0}'." }, + The_0_operator_cannot_be_applied_to_type_symbol: { code: 2469, category: ts.DiagnosticCategory.Error, key: "The_0_operator_cannot_be_applied_to_type_symbol_2469", message: "The '{0}' operator cannot be applied to type 'symbol'." }, + Symbol_reference_does_not_refer_to_the_global_Symbol_constructor_object: { code: 2470, category: ts.DiagnosticCategory.Error, key: "Symbol_reference_does_not_refer_to_the_global_Symbol_constructor_object_2470", message: "'Symbol' reference does not refer to the global Symbol constructor object." }, + A_computed_property_name_of_the_form_0_must_be_of_type_symbol: { code: 2471, category: ts.DiagnosticCategory.Error, key: "A_computed_property_name_of_the_form_0_must_be_of_type_symbol_2471", message: "A computed property name of the form '{0}' must be of type 'symbol'." }, + Spread_operator_in_new_expressions_is_only_available_when_targeting_ECMAScript_5_and_higher: { code: 2472, category: ts.DiagnosticCategory.Error, key: "Spread_operator_in_new_expressions_is_only_available_when_targeting_ECMAScript_5_and_higher_2472", message: "Spread operator in 'new' expressions is only available when targeting ECMAScript 5 and higher." }, + Enum_declarations_must_all_be_const_or_non_const: { code: 2473, category: ts.DiagnosticCategory.Error, key: "Enum_declarations_must_all_be_const_or_non_const_2473", message: "Enum declarations must all be const or non-const." }, + In_const_enum_declarations_member_initializer_must_be_constant_expression: { code: 2474, category: ts.DiagnosticCategory.Error, key: "In_const_enum_declarations_member_initializer_must_be_constant_expression_2474", message: "In 'const' enum declarations member initializer must be constant expression." }, + const_enums_can_only_be_used_in_property_or_index_access_expressions_or_the_right_hand_side_of_an_import_declaration_or_export_assignment: { code: 2475, category: ts.DiagnosticCategory.Error, key: "const_enums_can_only_be_used_in_property_or_index_access_expressions_or_the_right_hand_side_of_an_im_2475", message: "'const' enums can only be used in property or index access expressions or the right hand side of an import declaration or export assignment." }, + A_const_enum_member_can_only_be_accessed_using_a_string_literal: { code: 2476, category: ts.DiagnosticCategory.Error, key: "A_const_enum_member_can_only_be_accessed_using_a_string_literal_2476", message: "A const enum member can only be accessed using a string literal." }, + const_enum_member_initializer_was_evaluated_to_a_non_finite_value: { code: 2477, category: ts.DiagnosticCategory.Error, key: "const_enum_member_initializer_was_evaluated_to_a_non_finite_value_2477", message: "'const' enum member initializer was evaluated to a non-finite value." }, + const_enum_member_initializer_was_evaluated_to_disallowed_value_NaN: { code: 2478, category: ts.DiagnosticCategory.Error, key: "const_enum_member_initializer_was_evaluated_to_disallowed_value_NaN_2478", message: "'const' enum member initializer was evaluated to disallowed value 'NaN'." }, + Property_0_does_not_exist_on_const_enum_1: { code: 2479, category: ts.DiagnosticCategory.Error, key: "Property_0_does_not_exist_on_const_enum_1_2479", message: "Property '{0}' does not exist on 'const' enum '{1}'." }, + let_is_not_allowed_to_be_used_as_a_name_in_let_or_const_declarations: { code: 2480, category: ts.DiagnosticCategory.Error, key: "let_is_not_allowed_to_be_used_as_a_name_in_let_or_const_declarations_2480", message: "'let' is not allowed to be used as a name in 'let' or 'const' declarations." }, + Cannot_initialize_outer_scoped_variable_0_in_the_same_scope_as_block_scoped_declaration_1: { code: 2481, category: ts.DiagnosticCategory.Error, key: "Cannot_initialize_outer_scoped_variable_0_in_the_same_scope_as_block_scoped_declaration_1_2481", message: "Cannot initialize outer scoped variable '{0}' in the same scope as block scoped declaration '{1}'." }, + The_left_hand_side_of_a_for_of_statement_cannot_use_a_type_annotation: { code: 2483, category: ts.DiagnosticCategory.Error, key: "The_left_hand_side_of_a_for_of_statement_cannot_use_a_type_annotation_2483", message: "The left-hand side of a 'for...of' statement cannot use a type annotation." }, + Export_declaration_conflicts_with_exported_declaration_of_0: { code: 2484, category: ts.DiagnosticCategory.Error, key: "Export_declaration_conflicts_with_exported_declaration_of_0_2484", message: "Export declaration conflicts with exported declaration of '{0}'" }, + The_left_hand_side_of_a_for_of_statement_cannot_be_a_previously_defined_constant: { code: 2485, category: ts.DiagnosticCategory.Error, key: "The_left_hand_side_of_a_for_of_statement_cannot_be_a_previously_defined_constant_2485", message: "The left-hand side of a 'for...of' statement cannot be a previously defined constant." }, + The_left_hand_side_of_a_for_in_statement_cannot_be_a_previously_defined_constant: { code: 2486, category: ts.DiagnosticCategory.Error, key: "The_left_hand_side_of_a_for_in_statement_cannot_be_a_previously_defined_constant_2486", message: "The left-hand side of a 'for...in' statement cannot be a previously defined constant." }, + Invalid_left_hand_side_in_for_of_statement: { code: 2487, category: ts.DiagnosticCategory.Error, key: "Invalid_left_hand_side_in_for_of_statement_2487", message: "Invalid left-hand side in 'for...of' statement." }, + Type_must_have_a_Symbol_iterator_method_that_returns_an_iterator: { code: 2488, category: ts.DiagnosticCategory.Error, key: "Type_must_have_a_Symbol_iterator_method_that_returns_an_iterator_2488", message: "Type must have a '[Symbol.iterator]()' method that returns an iterator." }, + An_iterator_must_have_a_next_method: { code: 2489, category: ts.DiagnosticCategory.Error, key: "An_iterator_must_have_a_next_method_2489", message: "An iterator must have a 'next()' method." }, + The_type_returned_by_the_next_method_of_an_iterator_must_have_a_value_property: { code: 2490, category: ts.DiagnosticCategory.Error, key: "The_type_returned_by_the_next_method_of_an_iterator_must_have_a_value_property_2490", message: "The type returned by the 'next()' method of an iterator must have a 'value' property." }, + The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern: { code: 2491, category: ts.DiagnosticCategory.Error, key: "The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern_2491", message: "The left-hand side of a 'for...in' statement cannot be a destructuring pattern." }, + Cannot_redeclare_identifier_0_in_catch_clause: { code: 2492, category: ts.DiagnosticCategory.Error, key: "Cannot_redeclare_identifier_0_in_catch_clause_2492", message: "Cannot redeclare identifier '{0}' in catch clause" }, + Tuple_type_0_with_length_1_cannot_be_assigned_to_tuple_with_length_2: { code: 2493, category: ts.DiagnosticCategory.Error, key: "Tuple_type_0_with_length_1_cannot_be_assigned_to_tuple_with_length_2_2493", message: "Tuple type '{0}' with length '{1}' cannot be assigned to tuple with length '{2}'." }, + Using_a_string_in_a_for_of_statement_is_only_supported_in_ECMAScript_5_and_higher: { code: 2494, category: ts.DiagnosticCategory.Error, key: "Using_a_string_in_a_for_of_statement_is_only_supported_in_ECMAScript_5_and_higher_2494", message: "Using a string in a 'for...of' statement is only supported in ECMAScript 5 and higher." }, + Type_0_is_not_an_array_type_or_a_string_type: { code: 2495, category: ts.DiagnosticCategory.Error, key: "Type_0_is_not_an_array_type_or_a_string_type_2495", message: "Type '{0}' is not an array type or a string type." }, + The_arguments_object_cannot_be_referenced_in_an_arrow_function_in_ES3_and_ES5_Consider_using_a_standard_function_expression: { code: 2496, category: ts.DiagnosticCategory.Error, key: "The_arguments_object_cannot_be_referenced_in_an_arrow_function_in_ES3_and_ES5_Consider_using_a_stand_2496", message: "The 'arguments' object cannot be referenced in an arrow function in ES3 and ES5. Consider using a standard function expression." }, + Module_0_resolves_to_a_non_module_entity_and_cannot_be_imported_using_this_construct: { code: 2497, category: ts.DiagnosticCategory.Error, key: "Module_0_resolves_to_a_non_module_entity_and_cannot_be_imported_using_this_construct_2497", message: "Module '{0}' resolves to a non-module entity and cannot be imported using this construct." }, + Module_0_uses_export_and_cannot_be_used_with_export_Asterisk: { code: 2498, category: ts.DiagnosticCategory.Error, key: "Module_0_uses_export_and_cannot_be_used_with_export_Asterisk_2498", message: "Module '{0}' uses 'export =' and cannot be used with 'export *'." }, + An_interface_can_only_extend_an_identifier_Slashqualified_name_with_optional_type_arguments: { code: 2499, category: ts.DiagnosticCategory.Error, key: "An_interface_can_only_extend_an_identifier_Slashqualified_name_with_optional_type_arguments_2499", message: "An interface can only extend an identifier/qualified-name with optional type arguments." }, + A_class_can_only_implement_an_identifier_Slashqualified_name_with_optional_type_arguments: { code: 2500, category: ts.DiagnosticCategory.Error, key: "A_class_can_only_implement_an_identifier_Slashqualified_name_with_optional_type_arguments_2500", message: "A class can only implement an identifier/qualified-name with optional type arguments." }, + A_rest_element_cannot_contain_a_binding_pattern: { code: 2501, category: ts.DiagnosticCategory.Error, key: "A_rest_element_cannot_contain_a_binding_pattern_2501", message: "A rest element cannot contain a binding pattern." }, + _0_is_referenced_directly_or_indirectly_in_its_own_type_annotation: { code: 2502, category: ts.DiagnosticCategory.Error, key: "_0_is_referenced_directly_or_indirectly_in_its_own_type_annotation_2502", message: "'{0}' is referenced directly or indirectly in its own type annotation." }, + Cannot_find_namespace_0: { code: 2503, category: ts.DiagnosticCategory.Error, key: "Cannot_find_namespace_0_2503", message: "Cannot find namespace '{0}'." }, + No_best_common_type_exists_among_yield_expressions: { code: 2504, category: ts.DiagnosticCategory.Error, key: "No_best_common_type_exists_among_yield_expressions_2504", message: "No best common type exists among yield expressions." }, + A_generator_cannot_have_a_void_type_annotation: { code: 2505, category: ts.DiagnosticCategory.Error, key: "A_generator_cannot_have_a_void_type_annotation_2505", message: "A generator cannot have a 'void' type annotation." }, + _0_is_referenced_directly_or_indirectly_in_its_own_base_expression: { code: 2506, category: ts.DiagnosticCategory.Error, key: "_0_is_referenced_directly_or_indirectly_in_its_own_base_expression_2506", message: "'{0}' is referenced directly or indirectly in its own base expression." }, + Type_0_is_not_a_constructor_function_type: { code: 2507, category: ts.DiagnosticCategory.Error, key: "Type_0_is_not_a_constructor_function_type_2507", message: "Type '{0}' is not a constructor function type." }, + No_base_constructor_has_the_specified_number_of_type_arguments: { code: 2508, category: ts.DiagnosticCategory.Error, key: "No_base_constructor_has_the_specified_number_of_type_arguments_2508", message: "No base constructor has the specified number of type arguments." }, + Base_constructor_return_type_0_is_not_a_class_or_interface_type: { code: 2509, category: ts.DiagnosticCategory.Error, key: "Base_constructor_return_type_0_is_not_a_class_or_interface_type_2509", message: "Base constructor return type '{0}' is not a class or interface type." }, + Base_constructors_must_all_have_the_same_return_type: { code: 2510, category: ts.DiagnosticCategory.Error, key: "Base_constructors_must_all_have_the_same_return_type_2510", message: "Base constructors must all have the same return type." }, + Cannot_create_an_instance_of_the_abstract_class_0: { code: 2511, category: ts.DiagnosticCategory.Error, key: "Cannot_create_an_instance_of_the_abstract_class_0_2511", message: "Cannot create an instance of the abstract class '{0}'." }, + Overload_signatures_must_all_be_abstract_or_not_abstract: { code: 2512, category: ts.DiagnosticCategory.Error, key: "Overload_signatures_must_all_be_abstract_or_not_abstract_2512", message: "Overload signatures must all be abstract or not abstract." }, + Abstract_method_0_in_class_1_cannot_be_accessed_via_super_expression: { code: 2513, category: ts.DiagnosticCategory.Error, key: "Abstract_method_0_in_class_1_cannot_be_accessed_via_super_expression_2513", message: "Abstract method '{0}' in class '{1}' cannot be accessed via super expression." }, + Classes_containing_abstract_methods_must_be_marked_abstract: { code: 2514, category: ts.DiagnosticCategory.Error, key: "Classes_containing_abstract_methods_must_be_marked_abstract_2514", message: "Classes containing abstract methods must be marked abstract." }, + Non_abstract_class_0_does_not_implement_inherited_abstract_member_1_from_class_2: { code: 2515, category: ts.DiagnosticCategory.Error, key: "Non_abstract_class_0_does_not_implement_inherited_abstract_member_1_from_class_2_2515", message: "Non-abstract class '{0}' does not implement inherited abstract member '{1}' from class '{2}'." }, + All_declarations_of_an_abstract_method_must_be_consecutive: { code: 2516, category: ts.DiagnosticCategory.Error, key: "All_declarations_of_an_abstract_method_must_be_consecutive_2516", message: "All declarations of an abstract method must be consecutive." }, + Cannot_assign_an_abstract_constructor_type_to_a_non_abstract_constructor_type: { code: 2517, category: ts.DiagnosticCategory.Error, key: "Cannot_assign_an_abstract_constructor_type_to_a_non_abstract_constructor_type_2517", message: "Cannot assign an abstract constructor type to a non-abstract constructor type." }, + Duplicate_identifier_0_Compiler_uses_declaration_1_to_support_async_functions: { code: 2520, category: ts.DiagnosticCategory.Error, key: "Duplicate_identifier_0_Compiler_uses_declaration_1_to_support_async_functions_2520", message: "Duplicate identifier '{0}'. Compiler uses declaration '{1}' to support async functions." }, + Expression_resolves_to_variable_declaration_0_that_compiler_uses_to_support_async_functions: { code: 2521, category: ts.DiagnosticCategory.Error, key: "Expression_resolves_to_variable_declaration_0_that_compiler_uses_to_support_async_functions_2521", message: "Expression resolves to variable declaration '{0}' that compiler uses to support async functions." }, + The_arguments_object_cannot_be_referenced_in_an_async_arrow_function_Consider_using_a_standard_async_function_expression: { code: 2522, category: ts.DiagnosticCategory.Error, key: "The_arguments_object_cannot_be_referenced_in_an_async_arrow_function_Consider_using_a_standard_async_2522", message: "The 'arguments' object cannot be referenced in an async arrow function. Consider using a standard async function expression." }, + yield_expressions_cannot_be_used_in_a_parameter_initializer: { code: 2523, category: ts.DiagnosticCategory.Error, key: "yield_expressions_cannot_be_used_in_a_parameter_initializer_2523", message: "'yield' expressions cannot be used in a parameter initializer." }, + await_expressions_cannot_be_used_in_a_parameter_initializer: { code: 2524, category: ts.DiagnosticCategory.Error, key: "await_expressions_cannot_be_used_in_a_parameter_initializer_2524", message: "'await' expressions cannot be used in a parameter initializer." }, + Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value: { code: 2525, category: ts.DiagnosticCategory.Error, key: "Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value_2525", message: "Initializer provides no value for this binding element and the binding element has no default value." }, + A_this_type_is_available_only_in_a_non_static_member_of_a_class_or_interface: { code: 2526, category: ts.DiagnosticCategory.Error, key: "A_this_type_is_available_only_in_a_non_static_member_of_a_class_or_interface_2526", message: "A 'this' type is available only in a non-static member of a class or interface." }, + The_inferred_type_of_0_references_an_inaccessible_this_type_A_type_annotation_is_necessary: { code: 2527, category: ts.DiagnosticCategory.Error, key: "The_inferred_type_of_0_references_an_inaccessible_this_type_A_type_annotation_is_necessary_2527", message: "The inferred type of '{0}' references an inaccessible 'this' type. A type annotation is necessary." }, + A_module_cannot_have_multiple_default_exports: { code: 2528, category: ts.DiagnosticCategory.Error, key: "A_module_cannot_have_multiple_default_exports_2528", message: "A module cannot have multiple default exports." }, + JSX_element_attributes_type_0_must_be_an_object_type: { code: 2600, category: ts.DiagnosticCategory.Error, key: "JSX_element_attributes_type_0_must_be_an_object_type_2600", message: "JSX element attributes type '{0}' must be an object type." }, + The_return_type_of_a_JSX_element_constructor_must_return_an_object_type: { code: 2601, category: ts.DiagnosticCategory.Error, key: "The_return_type_of_a_JSX_element_constructor_must_return_an_object_type_2601", message: "The return type of a JSX element constructor must return an object type." }, + JSX_element_implicitly_has_type_any_because_the_global_type_JSX_Element_does_not_exist: { code: 2602, category: ts.DiagnosticCategory.Error, key: "JSX_element_implicitly_has_type_any_because_the_global_type_JSX_Element_does_not_exist_2602", message: "JSX element implicitly has type 'any' because the global type 'JSX.Element' does not exist." }, + Property_0_in_type_1_is_not_assignable_to_type_2: { code: 2603, category: ts.DiagnosticCategory.Error, key: "Property_0_in_type_1_is_not_assignable_to_type_2_2603", message: "Property '{0}' in type '{1}' is not assignable to type '{2}'" }, + JSX_element_type_0_does_not_have_any_construct_or_call_signatures: { code: 2604, category: ts.DiagnosticCategory.Error, key: "JSX_element_type_0_does_not_have_any_construct_or_call_signatures_2604", message: "JSX element type '{0}' does not have any construct or call signatures." }, + JSX_element_type_0_is_not_a_constructor_function_for_JSX_elements: { code: 2605, category: ts.DiagnosticCategory.Error, key: "JSX_element_type_0_is_not_a_constructor_function_for_JSX_elements_2605", message: "JSX element type '{0}' is not a constructor function for JSX elements." }, + Property_0_of_JSX_spread_attribute_is_not_assignable_to_target_property: { code: 2606, category: ts.DiagnosticCategory.Error, key: "Property_0_of_JSX_spread_attribute_is_not_assignable_to_target_property_2606", message: "Property '{0}' of JSX spread attribute is not assignable to target property." }, + JSX_element_class_does_not_support_attributes_because_it_does_not_have_a_0_property: { code: 2607, category: ts.DiagnosticCategory.Error, key: "JSX_element_class_does_not_support_attributes_because_it_does_not_have_a_0_property_2607", message: "JSX element class does not support attributes because it does not have a '{0}' property" }, + The_global_type_JSX_0_may_not_have_more_than_one_property: { code: 2608, category: ts.DiagnosticCategory.Error, key: "The_global_type_JSX_0_may_not_have_more_than_one_property_2608", message: "The global type 'JSX.{0}' may not have more than one property" }, + Cannot_emit_namespaced_JSX_elements_in_React: { code: 2650, category: ts.DiagnosticCategory.Error, key: "Cannot_emit_namespaced_JSX_elements_in_React_2650", message: "Cannot emit namespaced JSX elements in React" }, + A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_enums: { code: 2651, category: ts.DiagnosticCategory.Error, key: "A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_memb_2651", message: "A member initializer in a enum declaration cannot reference members declared after it, including members defined in other enums." }, + Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_default_0_declaration_instead: { code: 2652, category: ts.DiagnosticCategory.Error, key: "Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_d_2652", message: "Merged declaration '{0}' cannot include a default export declaration. Consider adding a separate 'export default {0}' declaration instead." }, + Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1: { code: 2653, category: ts.DiagnosticCategory.Error, key: "Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1_2653", message: "Non-abstract class expression does not implement inherited abstract member '{0}' from class '{1}'." }, + Exported_external_package_typings_file_cannot_contain_tripleslash_references_Please_contact_the_package_author_to_update_the_package_definition: { code: 2654, category: ts.DiagnosticCategory.Error, key: "Exported_external_package_typings_file_cannot_contain_tripleslash_references_Please_contact_the_pack_2654", message: "Exported external package typings file cannot contain tripleslash references. Please contact the package author to update the package definition." }, + Exported_external_package_typings_file_0_is_not_a_module_Please_contact_the_package_author_to_update_the_package_definition: { code: 2656, category: ts.DiagnosticCategory.Error, key: "Exported_external_package_typings_file_0_is_not_a_module_Please_contact_the_package_author_to_update_2656", message: "Exported external package typings file '{0}' is not a module. Please contact the package author to update the package definition." }, + JSX_expressions_must_have_one_parent_element: { code: 2657, category: ts.DiagnosticCategory.Error, key: "JSX_expressions_must_have_one_parent_element_2657", message: "JSX expressions must have one parent element" }, + Import_declaration_0_is_using_private_name_1: { code: 4000, category: ts.DiagnosticCategory.Error, key: "Import_declaration_0_is_using_private_name_1_4000", message: "Import declaration '{0}' is using private name '{1}'." }, + Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: { code: 4002, category: ts.DiagnosticCategory.Error, key: "Type_parameter_0_of_exported_class_has_or_is_using_private_name_1_4002", message: "Type parameter '{0}' of exported class has or is using private name '{1}'." }, + Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1: { code: 4004, category: ts.DiagnosticCategory.Error, key: "Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1_4004", message: "Type parameter '{0}' of exported interface has or is using private name '{1}'." }, + Type_parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1: { code: 4006, category: ts.DiagnosticCategory.Error, key: "Type_parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1_4006", message: "Type parameter '{0}' of constructor signature from exported interface has or is using private name '{1}'." }, + Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1: { code: 4008, category: ts.DiagnosticCategory.Error, key: "Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1_4008", message: "Type parameter '{0}' of call signature from exported interface has or is using private name '{1}'." }, + Type_parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1: { code: 4010, category: ts.DiagnosticCategory.Error, key: "Type_parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1_4010", message: "Type parameter '{0}' of public static method from exported class has or is using private name '{1}'." }, + Type_parameter_0_of_public_method_from_exported_class_has_or_is_using_private_name_1: { code: 4012, category: ts.DiagnosticCategory.Error, key: "Type_parameter_0_of_public_method_from_exported_class_has_or_is_using_private_name_1_4012", message: "Type parameter '{0}' of public method from exported class has or is using private name '{1}'." }, + Type_parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1: { code: 4014, category: ts.DiagnosticCategory.Error, key: "Type_parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1_4014", message: "Type parameter '{0}' of method from exported interface has or is using private name '{1}'." }, + Type_parameter_0_of_exported_function_has_or_is_using_private_name_1: { code: 4016, category: ts.DiagnosticCategory.Error, key: "Type_parameter_0_of_exported_function_has_or_is_using_private_name_1_4016", message: "Type parameter '{0}' of exported function has or is using private name '{1}'." }, + Implements_clause_of_exported_class_0_has_or_is_using_private_name_1: { code: 4019, category: ts.DiagnosticCategory.Error, key: "Implements_clause_of_exported_class_0_has_or_is_using_private_name_1_4019", message: "Implements clause of exported class '{0}' has or is using private name '{1}'." }, + Extends_clause_of_exported_class_0_has_or_is_using_private_name_1: { code: 4020, category: ts.DiagnosticCategory.Error, key: "Extends_clause_of_exported_class_0_has_or_is_using_private_name_1_4020", message: "Extends clause of exported class '{0}' has or is using private name '{1}'." }, + Extends_clause_of_exported_interface_0_has_or_is_using_private_name_1: { code: 4022, category: ts.DiagnosticCategory.Error, key: "Extends_clause_of_exported_interface_0_has_or_is_using_private_name_1_4022", message: "Extends clause of exported interface '{0}' has or is using private name '{1}'." }, + Exported_variable_0_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: { code: 4023, category: ts.DiagnosticCategory.Error, key: "Exported_variable_0_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named_4023", message: "Exported variable '{0}' has or is using name '{1}' from external module {2} but cannot be named." }, + Exported_variable_0_has_or_is_using_name_1_from_private_module_2: { code: 4024, category: ts.DiagnosticCategory.Error, key: "Exported_variable_0_has_or_is_using_name_1_from_private_module_2_4024", message: "Exported variable '{0}' has or is using name '{1}' from private module '{2}'." }, + Exported_variable_0_has_or_is_using_private_name_1: { code: 4025, category: ts.DiagnosticCategory.Error, key: "Exported_variable_0_has_or_is_using_private_name_1_4025", message: "Exported variable '{0}' has or is using private name '{1}'." }, + Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: { code: 4026, category: ts.DiagnosticCategory.Error, key: "Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot__4026", message: "Public static property '{0}' of exported class has or is using name '{1}' from external module {2} but cannot be named." }, + Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2: { code: 4027, category: ts.DiagnosticCategory.Error, key: "Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2_4027", message: "Public static property '{0}' of exported class has or is using name '{1}' from private module '{2}'." }, + Public_static_property_0_of_exported_class_has_or_is_using_private_name_1: { code: 4028, category: ts.DiagnosticCategory.Error, key: "Public_static_property_0_of_exported_class_has_or_is_using_private_name_1_4028", message: "Public static property '{0}' of exported class has or is using private name '{1}'." }, + Public_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: { code: 4029, category: ts.DiagnosticCategory.Error, key: "Public_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_name_4029", message: "Public property '{0}' of exported class has or is using name '{1}' from external module {2} but cannot be named." }, + Public_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2: { code: 4030, category: ts.DiagnosticCategory.Error, key: "Public_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2_4030", message: "Public property '{0}' of exported class has or is using name '{1}' from private module '{2}'." }, + Public_property_0_of_exported_class_has_or_is_using_private_name_1: { code: 4031, category: ts.DiagnosticCategory.Error, key: "Public_property_0_of_exported_class_has_or_is_using_private_name_1_4031", message: "Public property '{0}' of exported class has or is using private name '{1}'." }, + Property_0_of_exported_interface_has_or_is_using_name_1_from_private_module_2: { code: 4032, category: ts.DiagnosticCategory.Error, key: "Property_0_of_exported_interface_has_or_is_using_name_1_from_private_module_2_4032", message: "Property '{0}' of exported interface has or is using name '{1}' from private module '{2}'." }, + Property_0_of_exported_interface_has_or_is_using_private_name_1: { code: 4033, category: ts.DiagnosticCategory.Error, key: "Property_0_of_exported_interface_has_or_is_using_private_name_1_4033", message: "Property '{0}' of exported interface has or is using private name '{1}'." }, + Parameter_0_of_public_static_property_setter_from_exported_class_has_or_is_using_name_1_from_private_module_2: { code: 4034, category: ts.DiagnosticCategory.Error, key: "Parameter_0_of_public_static_property_setter_from_exported_class_has_or_is_using_name_1_from_private_4034", message: "Parameter '{0}' of public static property setter from exported class has or is using name '{1}' from private module '{2}'." }, + Parameter_0_of_public_static_property_setter_from_exported_class_has_or_is_using_private_name_1: { code: 4035, category: ts.DiagnosticCategory.Error, key: "Parameter_0_of_public_static_property_setter_from_exported_class_has_or_is_using_private_name_1_4035", message: "Parameter '{0}' of public static property setter from exported class has or is using private name '{1}'." }, + Parameter_0_of_public_property_setter_from_exported_class_has_or_is_using_name_1_from_private_module_2: { code: 4036, category: ts.DiagnosticCategory.Error, key: "Parameter_0_of_public_property_setter_from_exported_class_has_or_is_using_name_1_from_private_module_4036", message: "Parameter '{0}' of public property setter from exported class has or is using name '{1}' from private module '{2}'." }, + Parameter_0_of_public_property_setter_from_exported_class_has_or_is_using_private_name_1: { code: 4037, category: ts.DiagnosticCategory.Error, key: "Parameter_0_of_public_property_setter_from_exported_class_has_or_is_using_private_name_1_4037", message: "Parameter '{0}' of public property setter from exported class has or is using private name '{1}'." }, + Return_type_of_public_static_property_getter_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named: { code: 4038, category: ts.DiagnosticCategory.Error, key: "Return_type_of_public_static_property_getter_from_exported_class_has_or_is_using_name_0_from_externa_4038", message: "Return type of public static property getter from exported class has or is using name '{0}' from external module {1} but cannot be named." }, + Return_type_of_public_static_property_getter_from_exported_class_has_or_is_using_name_0_from_private_module_1: { code: 4039, category: ts.DiagnosticCategory.Error, key: "Return_type_of_public_static_property_getter_from_exported_class_has_or_is_using_name_0_from_private_4039", message: "Return type of public static property getter from exported class has or is using name '{0}' from private module '{1}'." }, + Return_type_of_public_static_property_getter_from_exported_class_has_or_is_using_private_name_0: { code: 4040, category: ts.DiagnosticCategory.Error, key: "Return_type_of_public_static_property_getter_from_exported_class_has_or_is_using_private_name_0_4040", message: "Return type of public static property getter from exported class has or is using private name '{0}'." }, + Return_type_of_public_property_getter_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named: { code: 4041, category: ts.DiagnosticCategory.Error, key: "Return_type_of_public_property_getter_from_exported_class_has_or_is_using_name_0_from_external_modul_4041", message: "Return type of public property getter from exported class has or is using name '{0}' from external module {1} but cannot be named." }, + Return_type_of_public_property_getter_from_exported_class_has_or_is_using_name_0_from_private_module_1: { code: 4042, category: ts.DiagnosticCategory.Error, key: "Return_type_of_public_property_getter_from_exported_class_has_or_is_using_name_0_from_private_module_4042", message: "Return type of public property getter from exported class has or is using name '{0}' from private module '{1}'." }, + Return_type_of_public_property_getter_from_exported_class_has_or_is_using_private_name_0: { code: 4043, category: ts.DiagnosticCategory.Error, key: "Return_type_of_public_property_getter_from_exported_class_has_or_is_using_private_name_0_4043", message: "Return type of public property getter from exported class has or is using private name '{0}'." }, + Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1: { code: 4044, category: ts.DiagnosticCategory.Error, key: "Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_name_0_from_private_mod_4044", message: "Return type of constructor signature from exported interface has or is using name '{0}' from private module '{1}'." }, + Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_0: { code: 4045, category: ts.DiagnosticCategory.Error, key: "Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_0_4045", message: "Return type of constructor signature from exported interface has or is using private name '{0}'." }, + Return_type_of_call_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1: { code: 4046, category: ts.DiagnosticCategory.Error, key: "Return_type_of_call_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1_4046", message: "Return type of call signature from exported interface has or is using name '{0}' from private module '{1}'." }, + Return_type_of_call_signature_from_exported_interface_has_or_is_using_private_name_0: { code: 4047, category: ts.DiagnosticCategory.Error, key: "Return_type_of_call_signature_from_exported_interface_has_or_is_using_private_name_0_4047", message: "Return type of call signature from exported interface has or is using private name '{0}'." }, + Return_type_of_index_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1: { code: 4048, category: ts.DiagnosticCategory.Error, key: "Return_type_of_index_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1_4048", message: "Return type of index signature from exported interface has or is using name '{0}' from private module '{1}'." }, + Return_type_of_index_signature_from_exported_interface_has_or_is_using_private_name_0: { code: 4049, category: ts.DiagnosticCategory.Error, key: "Return_type_of_index_signature_from_exported_interface_has_or_is_using_private_name_0_4049", message: "Return type of index signature from exported interface has or is using private name '{0}'." }, + Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named: { code: 4050, category: ts.DiagnosticCategory.Error, key: "Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_external_module__4050", message: "Return type of public static method from exported class has or is using name '{0}' from external module {1} but cannot be named." }, + Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_private_module_1: { code: 4051, category: ts.DiagnosticCategory.Error, key: "Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_private_module_1_4051", message: "Return type of public static method from exported class has or is using name '{0}' from private module '{1}'." }, + Return_type_of_public_static_method_from_exported_class_has_or_is_using_private_name_0: { code: 4052, category: ts.DiagnosticCategory.Error, key: "Return_type_of_public_static_method_from_exported_class_has_or_is_using_private_name_0_4052", message: "Return type of public static method from exported class has or is using private name '{0}'." }, + Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named: { code: 4053, category: ts.DiagnosticCategory.Error, key: "Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_c_4053", message: "Return type of public method from exported class has or is using name '{0}' from external module {1} but cannot be named." }, + Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_private_module_1: { code: 4054, category: ts.DiagnosticCategory.Error, key: "Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_private_module_1_4054", message: "Return type of public method from exported class has or is using name '{0}' from private module '{1}'." }, + Return_type_of_public_method_from_exported_class_has_or_is_using_private_name_0: { code: 4055, category: ts.DiagnosticCategory.Error, key: "Return_type_of_public_method_from_exported_class_has_or_is_using_private_name_0_4055", message: "Return type of public method from exported class has or is using private name '{0}'." }, + Return_type_of_method_from_exported_interface_has_or_is_using_name_0_from_private_module_1: { code: 4056, category: ts.DiagnosticCategory.Error, key: "Return_type_of_method_from_exported_interface_has_or_is_using_name_0_from_private_module_1_4056", message: "Return type of method from exported interface has or is using name '{0}' from private module '{1}'." }, + Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0: { code: 4057, category: ts.DiagnosticCategory.Error, key: "Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0_4057", message: "Return type of method from exported interface has or is using private name '{0}'." }, + Return_type_of_exported_function_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named: { code: 4058, category: ts.DiagnosticCategory.Error, key: "Return_type_of_exported_function_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named_4058", message: "Return type of exported function has or is using name '{0}' from external module {1} but cannot be named." }, + Return_type_of_exported_function_has_or_is_using_name_0_from_private_module_1: { code: 4059, category: ts.DiagnosticCategory.Error, key: "Return_type_of_exported_function_has_or_is_using_name_0_from_private_module_1_4059", message: "Return type of exported function has or is using name '{0}' from private module '{1}'." }, + Return_type_of_exported_function_has_or_is_using_private_name_0: { code: 4060, category: ts.DiagnosticCategory.Error, key: "Return_type_of_exported_function_has_or_is_using_private_name_0_4060", message: "Return type of exported function has or is using private name '{0}'." }, + Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: { code: 4061, category: ts.DiagnosticCategory.Error, key: "Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_can_4061", message: "Parameter '{0}' of constructor from exported class has or is using name '{1}' from external module {2} but cannot be named." }, + Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_private_module_2: { code: 4062, category: ts.DiagnosticCategory.Error, key: "Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_private_module_2_4062", message: "Parameter '{0}' of constructor from exported class has or is using name '{1}' from private module '{2}'." }, + Parameter_0_of_constructor_from_exported_class_has_or_is_using_private_name_1: { code: 4063, category: ts.DiagnosticCategory.Error, key: "Parameter_0_of_constructor_from_exported_class_has_or_is_using_private_name_1_4063", message: "Parameter '{0}' of constructor from exported class has or is using private name '{1}'." }, + Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2: { code: 4064, category: ts.DiagnosticCategory.Error, key: "Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_name_1_from_private_mod_4064", message: "Parameter '{0}' of constructor signature from exported interface has or is using name '{1}' from private module '{2}'." }, + Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1: { code: 4065, category: ts.DiagnosticCategory.Error, key: "Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1_4065", message: "Parameter '{0}' of constructor signature from exported interface has or is using private name '{1}'." }, + Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2: { code: 4066, category: ts.DiagnosticCategory.Error, key: "Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2_4066", message: "Parameter '{0}' of call signature from exported interface has or is using name '{1}' from private module '{2}'." }, + Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1: { code: 4067, category: ts.DiagnosticCategory.Error, key: "Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1_4067", message: "Parameter '{0}' of call signature from exported interface has or is using private name '{1}'." }, + Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: { code: 4068, category: ts.DiagnosticCategory.Error, key: "Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_external_module__4068", message: "Parameter '{0}' of public static method from exported class has or is using name '{1}' from external module {2} but cannot be named." }, + Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_private_module_2: { code: 4069, category: ts.DiagnosticCategory.Error, key: "Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_private_module_2_4069", message: "Parameter '{0}' of public static method from exported class has or is using name '{1}' from private module '{2}'." }, + Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1: { code: 4070, category: ts.DiagnosticCategory.Error, key: "Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1_4070", message: "Parameter '{0}' of public static method from exported class has or is using private name '{1}'." }, + Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: { code: 4071, category: ts.DiagnosticCategory.Error, key: "Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_c_4071", message: "Parameter '{0}' of public method from exported class has or is using name '{1}' from external module {2} but cannot be named." }, + Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_private_module_2: { code: 4072, category: ts.DiagnosticCategory.Error, key: "Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_private_module_2_4072", message: "Parameter '{0}' of public method from exported class has or is using name '{1}' from private module '{2}'." }, + Parameter_0_of_public_method_from_exported_class_has_or_is_using_private_name_1: { code: 4073, category: ts.DiagnosticCategory.Error, key: "Parameter_0_of_public_method_from_exported_class_has_or_is_using_private_name_1_4073", message: "Parameter '{0}' of public method from exported class has or is using private name '{1}'." }, + Parameter_0_of_method_from_exported_interface_has_or_is_using_name_1_from_private_module_2: { code: 4074, category: ts.DiagnosticCategory.Error, key: "Parameter_0_of_method_from_exported_interface_has_or_is_using_name_1_from_private_module_2_4074", message: "Parameter '{0}' of method from exported interface has or is using name '{1}' from private module '{2}'." }, + Parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1: { code: 4075, category: ts.DiagnosticCategory.Error, key: "Parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1_4075", message: "Parameter '{0}' of method from exported interface has or is using private name '{1}'." }, + Parameter_0_of_exported_function_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: { code: 4076, category: ts.DiagnosticCategory.Error, key: "Parameter_0_of_exported_function_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named_4076", message: "Parameter '{0}' of exported function has or is using name '{1}' from external module {2} but cannot be named." }, + Parameter_0_of_exported_function_has_or_is_using_name_1_from_private_module_2: { code: 4077, category: ts.DiagnosticCategory.Error, key: "Parameter_0_of_exported_function_has_or_is_using_name_1_from_private_module_2_4077", message: "Parameter '{0}' of exported function has or is using name '{1}' from private module '{2}'." }, + Parameter_0_of_exported_function_has_or_is_using_private_name_1: { code: 4078, category: ts.DiagnosticCategory.Error, key: "Parameter_0_of_exported_function_has_or_is_using_private_name_1_4078", message: "Parameter '{0}' of exported function has or is using private name '{1}'." }, + Exported_type_alias_0_has_or_is_using_private_name_1: { code: 4081, category: ts.DiagnosticCategory.Error, key: "Exported_type_alias_0_has_or_is_using_private_name_1_4081", message: "Exported type alias '{0}' has or is using private name '{1}'." }, + Default_export_of_the_module_has_or_is_using_private_name_0: { code: 4082, category: ts.DiagnosticCategory.Error, key: "Default_export_of_the_module_has_or_is_using_private_name_0_4082", message: "Default export of the module has or is using private name '{0}'." }, + The_current_host_does_not_support_the_0_option: { code: 5001, category: ts.DiagnosticCategory.Error, key: "The_current_host_does_not_support_the_0_option_5001", message: "The current host does not support the '{0}' option." }, + Cannot_find_the_common_subdirectory_path_for_the_input_files: { code: 5009, category: ts.DiagnosticCategory.Error, key: "Cannot_find_the_common_subdirectory_path_for_the_input_files_5009", message: "Cannot find the common subdirectory path for the input files." }, + Cannot_read_file_0_Colon_1: { code: 5012, category: ts.DiagnosticCategory.Error, key: "Cannot_read_file_0_Colon_1_5012", message: "Cannot read file '{0}': {1}" }, + Unsupported_file_encoding: { code: 5013, category: ts.DiagnosticCategory.Error, key: "Unsupported_file_encoding_5013", message: "Unsupported file encoding." }, + Failed_to_parse_file_0_Colon_1: { code: 5014, category: ts.DiagnosticCategory.Error, key: "Failed_to_parse_file_0_Colon_1_5014", message: "Failed to parse file '{0}': {1}." }, + Unknown_compiler_option_0: { code: 5023, category: ts.DiagnosticCategory.Error, key: "Unknown_compiler_option_0_5023", message: "Unknown compiler option '{0}'." }, + Compiler_option_0_requires_a_value_of_type_1: { code: 5024, category: ts.DiagnosticCategory.Error, key: "Compiler_option_0_requires_a_value_of_type_1_5024", message: "Compiler option '{0}' requires a value of type {1}." }, + Could_not_write_file_0_Colon_1: { code: 5033, category: ts.DiagnosticCategory.Error, key: "Could_not_write_file_0_Colon_1_5033", message: "Could not write file '{0}': {1}" }, + Option_project_cannot_be_mixed_with_source_files_on_a_command_line: { code: 5042, category: ts.DiagnosticCategory.Error, key: "Option_project_cannot_be_mixed_with_source_files_on_a_command_line_5042", message: "Option 'project' cannot be mixed with source files on a command line." }, + Option_isolatedModules_can_only_be_used_when_either_option_module_is_provided_or_option_target_is_ES2015_or_higher: { code: 5047, category: ts.DiagnosticCategory.Error, key: "Option_isolatedModules_can_only_be_used_when_either_option_module_is_provided_or_option_target_is_ES_5047", message: "Option 'isolatedModules' can only be used when either option '--module' is provided or option 'target' is 'ES2015' or higher." }, + Option_inlineSources_can_only_be_used_when_either_option_inlineSourceMap_or_option_sourceMap_is_provided: { code: 5051, category: ts.DiagnosticCategory.Error, key: "Option_inlineSources_can_only_be_used_when_either_option_inlineSourceMap_or_option_sourceMap_is_prov_5051", message: "Option 'inlineSources' can only be used when either option '--inlineSourceMap' or option '--sourceMap' is provided." }, + Option_0_cannot_be_specified_without_specifying_option_1: { code: 5052, category: ts.DiagnosticCategory.Error, key: "Option_0_cannot_be_specified_without_specifying_option_1_5052", message: "Option '{0}' cannot be specified without specifying option '{1}'." }, + Option_0_cannot_be_specified_with_option_1: { code: 5053, category: ts.DiagnosticCategory.Error, key: "Option_0_cannot_be_specified_with_option_1_5053", message: "Option '{0}' cannot be specified with option '{1}'." }, + A_tsconfig_json_file_is_already_defined_at_Colon_0: { code: 5054, category: ts.DiagnosticCategory.Error, key: "A_tsconfig_json_file_is_already_defined_at_Colon_0_5054", message: "A 'tsconfig.json' file is already defined at: '{0}'." }, + Concatenate_and_emit_output_to_single_file: { code: 6001, category: ts.DiagnosticCategory.Message, key: "Concatenate_and_emit_output_to_single_file_6001", message: "Concatenate and emit output to single file." }, + Generates_corresponding_d_ts_file: { code: 6002, category: ts.DiagnosticCategory.Message, key: "Generates_corresponding_d_ts_file_6002", message: "Generates corresponding '.d.ts' file." }, + Specifies_the_location_where_debugger_should_locate_map_files_instead_of_generated_locations: { code: 6003, category: ts.DiagnosticCategory.Message, key: "Specifies_the_location_where_debugger_should_locate_map_files_instead_of_generated_locations_6003", message: "Specifies the location where debugger should locate map files instead of generated locations." }, + Specifies_the_location_where_debugger_should_locate_TypeScript_files_instead_of_source_locations: { code: 6004, category: ts.DiagnosticCategory.Message, key: "Specifies_the_location_where_debugger_should_locate_TypeScript_files_instead_of_source_locations_6004", message: "Specifies the location where debugger should locate TypeScript files instead of source locations." }, + Watch_input_files: { code: 6005, category: ts.DiagnosticCategory.Message, key: "Watch_input_files_6005", message: "Watch input files." }, + Redirect_output_structure_to_the_directory: { code: 6006, category: ts.DiagnosticCategory.Message, key: "Redirect_output_structure_to_the_directory_6006", message: "Redirect output structure to the directory." }, + Do_not_erase_const_enum_declarations_in_generated_code: { code: 6007, category: ts.DiagnosticCategory.Message, key: "Do_not_erase_const_enum_declarations_in_generated_code_6007", message: "Do not erase const enum declarations in generated code." }, + Do_not_emit_outputs_if_any_errors_were_reported: { code: 6008, category: ts.DiagnosticCategory.Message, key: "Do_not_emit_outputs_if_any_errors_were_reported_6008", message: "Do not emit outputs if any errors were reported." }, + Do_not_emit_comments_to_output: { code: 6009, category: ts.DiagnosticCategory.Message, key: "Do_not_emit_comments_to_output_6009", message: "Do not emit comments to output." }, + Do_not_emit_outputs: { code: 6010, category: ts.DiagnosticCategory.Message, key: "Do_not_emit_outputs_6010", message: "Do not emit outputs." }, + Specify_ECMAScript_target_version_Colon_ES3_default_ES5_or_ES2015_experimental: { code: 6015, category: ts.DiagnosticCategory.Message, key: "Specify_ECMAScript_target_version_Colon_ES3_default_ES5_or_ES2015_experimental_6015", message: "Specify ECMAScript target version: 'ES3' (default), 'ES5', or 'ES2015' (experimental)" }, + Specify_module_code_generation_Colon_commonjs_amd_system_umd_or_es2015: { code: 6016, category: ts.DiagnosticCategory.Message, key: "Specify_module_code_generation_Colon_commonjs_amd_system_umd_or_es2015_6016", message: "Specify module code generation: 'commonjs', 'amd', 'system', 'umd' or 'es2015'" }, + Print_this_message: { code: 6017, category: ts.DiagnosticCategory.Message, key: "Print_this_message_6017", message: "Print this message." }, + Print_the_compiler_s_version: { code: 6019, category: ts.DiagnosticCategory.Message, key: "Print_the_compiler_s_version_6019", message: "Print the compiler's version." }, + Compile_the_project_in_the_given_directory: { code: 6020, category: ts.DiagnosticCategory.Message, key: "Compile_the_project_in_the_given_directory_6020", message: "Compile the project in the given directory." }, + Syntax_Colon_0: { code: 6023, category: ts.DiagnosticCategory.Message, key: "Syntax_Colon_0_6023", message: "Syntax: {0}" }, + options: { code: 6024, category: ts.DiagnosticCategory.Message, key: "options_6024", message: "options" }, + file: { code: 6025, category: ts.DiagnosticCategory.Message, key: "file_6025", message: "file" }, + Examples_Colon_0: { code: 6026, category: ts.DiagnosticCategory.Message, key: "Examples_Colon_0_6026", message: "Examples: {0}" }, + Options_Colon: { code: 6027, category: ts.DiagnosticCategory.Message, key: "Options_Colon_6027", message: "Options:" }, + Version_0: { code: 6029, category: ts.DiagnosticCategory.Message, key: "Version_0_6029", message: "Version {0}" }, + Insert_command_line_options_and_files_from_a_file: { code: 6030, category: ts.DiagnosticCategory.Message, key: "Insert_command_line_options_and_files_from_a_file_6030", message: "Insert command line options and files from a file." }, + File_change_detected_Starting_incremental_compilation: { code: 6032, category: ts.DiagnosticCategory.Message, key: "File_change_detected_Starting_incremental_compilation_6032", message: "File change detected. Starting incremental compilation..." }, + KIND: { code: 6034, category: ts.DiagnosticCategory.Message, key: "KIND_6034", message: "KIND" }, + FILE: { code: 6035, category: ts.DiagnosticCategory.Message, key: "FILE_6035", message: "FILE" }, + VERSION: { code: 6036, category: ts.DiagnosticCategory.Message, key: "VERSION_6036", message: "VERSION" }, + LOCATION: { code: 6037, category: ts.DiagnosticCategory.Message, key: "LOCATION_6037", message: "LOCATION" }, + DIRECTORY: { code: 6038, category: ts.DiagnosticCategory.Message, key: "DIRECTORY_6038", message: "DIRECTORY" }, + Compilation_complete_Watching_for_file_changes: { code: 6042, category: ts.DiagnosticCategory.Message, key: "Compilation_complete_Watching_for_file_changes_6042", message: "Compilation complete. Watching for file changes." }, + Generates_corresponding_map_file: { code: 6043, category: ts.DiagnosticCategory.Message, key: "Generates_corresponding_map_file_6043", message: "Generates corresponding '.map' file." }, + Compiler_option_0_expects_an_argument: { code: 6044, category: ts.DiagnosticCategory.Error, key: "Compiler_option_0_expects_an_argument_6044", message: "Compiler option '{0}' expects an argument." }, + Unterminated_quoted_string_in_response_file_0: { code: 6045, category: ts.DiagnosticCategory.Error, key: "Unterminated_quoted_string_in_response_file_0_6045", message: "Unterminated quoted string in response file '{0}'." }, + Argument_for_module_option_must_be_commonjs_amd_system_umd_or_es2015: { code: 6046, category: ts.DiagnosticCategory.Error, key: "Argument_for_module_option_must_be_commonjs_amd_system_umd_or_es2015_6046", message: "Argument for '--module' option must be 'commonjs', 'amd', 'system', 'umd', or 'es2015'." }, + Argument_for_target_option_must_be_ES3_ES5_or_ES2015: { code: 6047, category: ts.DiagnosticCategory.Error, key: "Argument_for_target_option_must_be_ES3_ES5_or_ES2015_6047", message: "Argument for '--target' option must be 'ES3', 'ES5', or 'ES2015'." }, + Locale_must_be_of_the_form_language_or_language_territory_For_example_0_or_1: { code: 6048, category: ts.DiagnosticCategory.Error, key: "Locale_must_be_of_the_form_language_or_language_territory_For_example_0_or_1_6048", message: "Locale must be of the form or -. For example '{0}' or '{1}'." }, + Unsupported_locale_0: { code: 6049, category: ts.DiagnosticCategory.Error, key: "Unsupported_locale_0_6049", message: "Unsupported locale '{0}'." }, + Unable_to_open_file_0: { code: 6050, category: ts.DiagnosticCategory.Error, key: "Unable_to_open_file_0_6050", message: "Unable to open file '{0}'." }, + Corrupted_locale_file_0: { code: 6051, category: ts.DiagnosticCategory.Error, key: "Corrupted_locale_file_0_6051", message: "Corrupted locale file {0}." }, + Raise_error_on_expressions_and_declarations_with_an_implied_any_type: { code: 6052, category: ts.DiagnosticCategory.Message, key: "Raise_error_on_expressions_and_declarations_with_an_implied_any_type_6052", message: "Raise error on expressions and declarations with an implied 'any' type." }, + File_0_not_found: { code: 6053, category: ts.DiagnosticCategory.Error, key: "File_0_not_found_6053", message: "File '{0}' not found." }, + File_0_has_unsupported_extension_The_only_supported_extensions_are_1: { code: 6054, category: ts.DiagnosticCategory.Error, key: "File_0_has_unsupported_extension_The_only_supported_extensions_are_1_6054", message: "File '{0}' has unsupported extension. The only supported extensions are {1}." }, + Suppress_noImplicitAny_errors_for_indexing_objects_lacking_index_signatures: { code: 6055, category: ts.DiagnosticCategory.Message, key: "Suppress_noImplicitAny_errors_for_indexing_objects_lacking_index_signatures_6055", message: "Suppress noImplicitAny errors for indexing objects lacking index signatures." }, + Do_not_emit_declarations_for_code_that_has_an_internal_annotation: { code: 6056, category: ts.DiagnosticCategory.Message, key: "Do_not_emit_declarations_for_code_that_has_an_internal_annotation_6056", message: "Do not emit declarations for code that has an '@internal' annotation." }, + Specifies_the_root_directory_of_input_files_Use_to_control_the_output_directory_structure_with_outDir: { code: 6058, category: ts.DiagnosticCategory.Message, key: "Specifies_the_root_directory_of_input_files_Use_to_control_the_output_directory_structure_with_outDi_6058", message: "Specifies the root directory of input files. Use to control the output directory structure with --outDir." }, + File_0_is_not_under_rootDir_1_rootDir_is_expected_to_contain_all_source_files: { code: 6059, category: ts.DiagnosticCategory.Error, key: "File_0_is_not_under_rootDir_1_rootDir_is_expected_to_contain_all_source_files_6059", message: "File '{0}' is not under 'rootDir' '{1}'. 'rootDir' is expected to contain all source files." }, + Specifies_the_end_of_line_sequence_to_be_used_when_emitting_files_Colon_CRLF_dos_or_LF_unix: { code: 6060, category: ts.DiagnosticCategory.Message, key: "Specifies_the_end_of_line_sequence_to_be_used_when_emitting_files_Colon_CRLF_dos_or_LF_unix_6060", message: "Specifies the end of line sequence to be used when emitting files: 'CRLF' (dos) or 'LF' (unix)." }, + NEWLINE: { code: 6061, category: ts.DiagnosticCategory.Message, key: "NEWLINE_6061", message: "NEWLINE" }, + Argument_for_newLine_option_must_be_CRLF_or_LF: { code: 6062, category: ts.DiagnosticCategory.Error, key: "Argument_for_newLine_option_must_be_CRLF_or_LF_6062", message: "Argument for '--newLine' option must be 'CRLF' or 'LF'." }, + Argument_for_moduleResolution_option_must_be_node_or_classic: { code: 6063, category: ts.DiagnosticCategory.Error, key: "Argument_for_moduleResolution_option_must_be_node_or_classic_6063", message: "Argument for '--moduleResolution' option must be 'node' or 'classic'." }, + Specify_JSX_code_generation_Colon_preserve_or_react: { code: 6080, category: ts.DiagnosticCategory.Message, key: "Specify_JSX_code_generation_Colon_preserve_or_react_6080", message: "Specify JSX code generation: 'preserve' or 'react'" }, + Argument_for_jsx_must_be_preserve_or_react: { code: 6081, category: ts.DiagnosticCategory.Message, key: "Argument_for_jsx_must_be_preserve_or_react_6081", message: "Argument for '--jsx' must be 'preserve' or 'react'." }, + Enables_experimental_support_for_ES7_decorators: { code: 6065, category: ts.DiagnosticCategory.Message, key: "Enables_experimental_support_for_ES7_decorators_6065", message: "Enables experimental support for ES7 decorators." }, + Enables_experimental_support_for_emitting_type_metadata_for_decorators: { code: 6066, category: ts.DiagnosticCategory.Message, key: "Enables_experimental_support_for_emitting_type_metadata_for_decorators_6066", message: "Enables experimental support for emitting type metadata for decorators." }, + Enables_experimental_support_for_ES7_async_functions: { code: 6068, category: ts.DiagnosticCategory.Message, key: "Enables_experimental_support_for_ES7_async_functions_6068", message: "Enables experimental support for ES7 async functions." }, + Specifies_module_resolution_strategy_Colon_node_Node_js_or_classic_TypeScript_pre_1_6: { code: 6069, category: ts.DiagnosticCategory.Message, key: "Specifies_module_resolution_strategy_Colon_node_Node_js_or_classic_TypeScript_pre_1_6_6069", message: "Specifies module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6)." }, + Initializes_a_TypeScript_project_and_creates_a_tsconfig_json_file: { code: 6070, category: ts.DiagnosticCategory.Message, key: "Initializes_a_TypeScript_project_and_creates_a_tsconfig_json_file_6070", message: "Initializes a TypeScript project and creates a tsconfig.json file." }, + Successfully_created_a_tsconfig_json_file: { code: 6071, category: ts.DiagnosticCategory.Message, key: "Successfully_created_a_tsconfig_json_file_6071", message: "Successfully created a tsconfig.json file." }, + Suppress_excess_property_checks_for_object_literals: { code: 6072, category: ts.DiagnosticCategory.Message, key: "Suppress_excess_property_checks_for_object_literals_6072", message: "Suppress excess property checks for object literals." }, + Disallow_inconsistently_cased_references_to_the_same_file: { code: 6073, category: ts.DiagnosticCategory.Message, key: "Disallow_inconsistently_cased_references_to_the_same_file_6073", message: "Disallow inconsistently-cased references to the same 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." }, + new_expression_whose_target_lacks_a_construct_signature_implicitly_has_an_any_type: { code: 7009, category: ts.DiagnosticCategory.Error, key: "new_expression_whose_target_lacks_a_construct_signature_implicitly_has_an_any_type_7009", message: "'new' expression, whose target lacks a construct signature, implicitly has an 'any' type." }, + _0_which_lacks_return_type_annotation_implicitly_has_an_1_return_type: { code: 7010, category: ts.DiagnosticCategory.Error, key: "_0_which_lacks_return_type_annotation_implicitly_has_an_1_return_type_7010", message: "'{0}', which lacks return-type annotation, implicitly has an '{1}' return type." }, + Function_expression_which_lacks_return_type_annotation_implicitly_has_an_0_return_type: { code: 7011, category: ts.DiagnosticCategory.Error, key: "Function_expression_which_lacks_return_type_annotation_implicitly_has_an_0_return_type_7011", message: "Function expression, which lacks return-type annotation, implicitly has an '{0}' return type." }, + Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type: { code: 7013, category: ts.DiagnosticCategory.Error, key: "Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type_7013", message: "Construct signature, which lacks return-type annotation, implicitly has an 'any' return type." }, + Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_type_annotation: { code: 7016, category: ts.DiagnosticCategory.Error, key: "Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_type_annotation_7016", message: "Property '{0}' implicitly has type 'any', because its 'set' accessor lacks a type annotation." }, + Index_signature_of_object_type_implicitly_has_an_any_type: { code: 7017, category: ts.DiagnosticCategory.Error, key: "Index_signature_of_object_type_implicitly_has_an_any_type_7017", message: "Index signature of object type implicitly has an 'any' type." }, + Object_literal_s_property_0_implicitly_has_an_1_type: { code: 7018, category: ts.DiagnosticCategory.Error, key: "Object_literal_s_property_0_implicitly_has_an_1_type_7018", message: "Object literal's property '{0}' implicitly has an '{1}' type." }, + Rest_parameter_0_implicitly_has_an_any_type: { code: 7019, category: ts.DiagnosticCategory.Error, key: "Rest_parameter_0_implicitly_has_an_any_type_7019", message: "Rest parameter '{0}' implicitly has an 'any[]' type." }, + Call_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type: { code: 7020, category: ts.DiagnosticCategory.Error, key: "Call_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type_7020", message: "Call signature, which lacks return-type annotation, implicitly has an 'any' return type." }, + _0_implicitly_has_type_any_because_it_does_not_have_a_type_annotation_and_is_referenced_directly_or_indirectly_in_its_own_initializer: { code: 7022, category: ts.DiagnosticCategory.Error, key: "_0_implicitly_has_type_any_because_it_does_not_have_a_type_annotation_and_is_referenced_directly_or__7022", message: "'{0}' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer." }, + _0_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions: { code: 7023, category: ts.DiagnosticCategory.Error, key: "_0_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_reference_7023", message: "'{0}' implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions." }, + Function_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions: { code: 7024, category: ts.DiagnosticCategory.Error, key: "Function_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_ref_7024", message: "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." }, + Generator_implicitly_has_type_0_because_it_does_not_yield_any_values_Consider_supplying_a_return_type: { code: 7025, category: ts.DiagnosticCategory.Error, key: "Generator_implicitly_has_type_0_because_it_does_not_yield_any_values_Consider_supplying_a_return_typ_7025", message: "Generator implicitly has type '{0}' because it does not yield any values. Consider supplying a return type." }, + JSX_element_implicitly_has_type_any_because_no_interface_JSX_0_exists: { code: 7026, category: ts.DiagnosticCategory.Error, key: "JSX_element_implicitly_has_type_any_because_no_interface_JSX_0_exists_7026", message: "JSX element implicitly has type 'any' because no interface 'JSX.{0}' exists" }, + 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." }, + export_can_only_be_used_in_a_ts_file: { code: 8003, category: ts.DiagnosticCategory.Error, key: "export_can_only_be_used_in_a_ts_file_8003", message: "'export=' can only be used in a .ts file." }, + type_parameter_declarations_can_only_be_used_in_a_ts_file: { code: 8004, category: ts.DiagnosticCategory.Error, key: "type_parameter_declarations_can_only_be_used_in_a_ts_file_8004", message: "'type parameter declarations' can only be used in a .ts file." }, + implements_clauses_can_only_be_used_in_a_ts_file: { code: 8005, category: ts.DiagnosticCategory.Error, key: "implements_clauses_can_only_be_used_in_a_ts_file_8005", message: "'implements clauses' can only be used in a .ts file." }, + interface_declarations_can_only_be_used_in_a_ts_file: { code: 8006, category: ts.DiagnosticCategory.Error, key: "interface_declarations_can_only_be_used_in_a_ts_file_8006", message: "'interface declarations' can only be used in a .ts file." }, + module_declarations_can_only_be_used_in_a_ts_file: { code: 8007, category: ts.DiagnosticCategory.Error, key: "module_declarations_can_only_be_used_in_a_ts_file_8007", message: "'module declarations' can only be used in a .ts file." }, + type_aliases_can_only_be_used_in_a_ts_file: { code: 8008, category: ts.DiagnosticCategory.Error, key: "type_aliases_can_only_be_used_in_a_ts_file_8008", message: "'type aliases' can only be used in a .ts file." }, + _0_can_only_be_used_in_a_ts_file: { code: 8009, category: ts.DiagnosticCategory.Error, key: "_0_can_only_be_used_in_a_ts_file_8009", message: "'{0}' can only be used in a .ts file." }, + types_can_only_be_used_in_a_ts_file: { code: 8010, category: ts.DiagnosticCategory.Error, key: "types_can_only_be_used_in_a_ts_file_8010", message: "'types' can only be used in a .ts file." }, + type_arguments_can_only_be_used_in_a_ts_file: { code: 8011, category: ts.DiagnosticCategory.Error, key: "type_arguments_can_only_be_used_in_a_ts_file_8011", message: "'type arguments' can only be used in a .ts file." }, + parameter_modifiers_can_only_be_used_in_a_ts_file: { code: 8012, category: ts.DiagnosticCategory.Error, key: "parameter_modifiers_can_only_be_used_in_a_ts_file_8012", message: "'parameter modifiers' can only be used in a .ts file." }, + property_declarations_can_only_be_used_in_a_ts_file: { code: 8014, category: ts.DiagnosticCategory.Error, key: "property_declarations_can_only_be_used_in_a_ts_file_8014", message: "'property declarations' can only be used in a .ts file." }, + enum_declarations_can_only_be_used_in_a_ts_file: { code: 8015, category: ts.DiagnosticCategory.Error, key: "enum_declarations_can_only_be_used_in_a_ts_file_8015", message: "'enum declarations' can only be used in a .ts file." }, + type_assertion_expressions_can_only_be_used_in_a_ts_file: { code: 8016, category: ts.DiagnosticCategory.Error, key: "type_assertion_expressions_can_only_be_used_in_a_ts_file_8016", message: "'type assertion expressions' can only be used in a .ts file." }, + decorators_can_only_be_used_in_a_ts_file: { code: 8017, category: ts.DiagnosticCategory.Error, key: "decorators_can_only_be_used_in_a_ts_file_8017", message: "'decorators' can only be used in a .ts file." }, + Only_identifiers_Slashqualified_names_with_optional_type_arguments_are_currently_supported_in_a_class_extends_clauses: { code: 9002, category: ts.DiagnosticCategory.Error, key: "Only_identifiers_Slashqualified_names_with_optional_type_arguments_are_currently_supported_in_a_clas_9002", message: "Only identifiers/qualified-names with optional type arguments are currently supported in a class 'extends' clauses." }, + class_expressions_are_not_currently_supported: { code: 9003, category: ts.DiagnosticCategory.Error, key: "class_expressions_are_not_currently_supported_9003", message: "'class' expressions are not currently supported." }, + JSX_attributes_must_only_be_assigned_a_non_empty_expression: { code: 17000, category: ts.DiagnosticCategory.Error, key: "JSX_attributes_must_only_be_assigned_a_non_empty_expression_17000", message: "JSX attributes must only be assigned a non-empty 'expression'." }, + JSX_elements_cannot_have_multiple_attributes_with_the_same_name: { code: 17001, category: ts.DiagnosticCategory.Error, key: "JSX_elements_cannot_have_multiple_attributes_with_the_same_name_17001", message: "JSX elements cannot have multiple attributes with the same name." }, + Expected_corresponding_JSX_closing_tag_for_0: { code: 17002, category: ts.DiagnosticCategory.Error, key: "Expected_corresponding_JSX_closing_tag_for_0_17002", message: "Expected corresponding JSX closing tag for '{0}'." }, + JSX_attribute_expected: { code: 17003, category: ts.DiagnosticCategory.Error, key: "JSX_attribute_expected_17003", message: "JSX attribute expected." }, + Cannot_use_JSX_unless_the_jsx_flag_is_provided: { code: 17004, category: ts.DiagnosticCategory.Error, key: "Cannot_use_JSX_unless_the_jsx_flag_is_provided_17004", message: "Cannot use JSX unless the '--jsx' flag is provided." }, + A_constructor_cannot_contain_a_super_call_when_its_class_extends_null: { code: 17005, category: ts.DiagnosticCategory.Error, key: "A_constructor_cannot_contain_a_super_call_when_its_class_extends_null_17005", message: "A constructor cannot contain a 'super' call when its class extends 'null'" }, + An_unary_expression_with_the_0_operator_is_not_allowed_in_the_left_hand_side_of_an_exponentiation_expression_Consider_enclosing_the_expression_in_parentheses: { code: 17006, category: ts.DiagnosticCategory.Error, key: "An_unary_expression_with_the_0_operator_is_not_allowed_in_the_left_hand_side_of_an_exponentiation_ex_17006", message: "An unary expression with the '{0}' operator is not allowed in the left-hand side of an exponentiation expression. Consider enclosing the expression in parentheses." }, + A_type_assertion_expression_is_not_allowed_in_the_left_hand_side_of_an_exponentiation_expression_Consider_enclosing_the_expression_in_parentheses: { code: 17007, category: ts.DiagnosticCategory.Error, key: "A_type_assertion_expression_is_not_allowed_in_the_left_hand_side_of_an_exponentiation_expression_Con_17007", message: "A type assertion expression is not allowed in the left-hand side of an exponentiation expression. Consider enclosing the expression in parentheses." } + }; +})(ts || (ts = {})); +var ts; +(function (ts) { + function tokenIsIdentifierOrKeyword(token) { + return token >= 69; + } + ts.tokenIsIdentifierOrKeyword = tokenIsIdentifierOrKeyword; + var textToToken = { + "abstract": 115, + "any": 117, + "as": 116, + "boolean": 120, + "break": 70, + "case": 71, + "catch": 72, + "class": 73, + "continue": 75, + "const": 74, + "constructor": 121, + "debugger": 76, + "declare": 122, + "default": 77, + "delete": 78, + "do": 79, + "else": 80, + "enum": 81, + "export": 82, + "extends": 83, + "false": 84, + "finally": 85, + "for": 86, + "from": 133, + "function": 87, + "get": 123, + "if": 88, + "implements": 106, + "import": 89, + "in": 90, + "instanceof": 91, + "interface": 107, + "is": 124, + "let": 108, + "module": 125, + "namespace": 126, + "new": 92, + "null": 93, + "number": 128, + "package": 109, + "private": 110, + "protected": 111, + "public": 112, + "require": 127, + "return": 94, + "set": 129, + "static": 113, + "string": 130, + "super": 95, + "switch": 96, + "symbol": 131, + "this": 97, + "throw": 98, + "true": 99, + "try": 100, + "type": 132, + "typeof": 101, + "var": 102, + "void": 103, + "while": 104, + "with": 105, + "yield": 114, + "async": 118, + "await": 119, + "of": 134, + "{": 15, + "}": 16, + "(": 17, + ")": 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) { + if (source.hasOwnProperty(name_4)) { + 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++); + 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 ch === 32 || + ch === 9 || + ch === 11 || + ch === 12 || + ch === 160 || + ch === 133 || + ch === 5760 || + ch >= 8192 && ch <= 8203 || + ch === 8239 || + ch === 8287 || + ch === 12288 || + ch === 65279; + } + ts.isWhiteSpace = isWhiteSpace; + function isLineBreak(ch) { + return ch === 10 || + ch === 13 || + ch === 8232 || + ch === 8233; + } + 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) { + 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 (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) || isLineBreak(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 getCommentRanges(text, pos, trailing) { + var result; + var collecting = trailing || pos === 0; + while (true) { + var ch = text.charCodeAt(pos); + switch (ch) { + case 13: + if (text.charCodeAt(pos + 1) === 10) { + pos++; + } + case 10: + pos++; + if (trailing) { + return result; + } + collecting = true; + if (result && result.length) { + ts.lastOrUndefined(result).hasTrailingNewLine = 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 (!result) { + result = []; + } + result.push({ pos: startPos, end: pos, hasTrailingNewLine: hasTrailingNewLine, kind: kind }); + } + continue; + } + break; + default: + if (ch > 127 && (isWhiteSpace(ch) || isLineBreak(ch))) { + if (result && result.length && isLineBreak(ch)) { + ts.lastOrUndefined(result).hasTrailingNewLine = true; + } + pos++; + continue; + } + break; + } + return result; + } + } + function getLeadingCommentRanges(text, pos) { + return getCommentRanges(text, pos, false); + } + ts.getLeadingCommentRanges = getLeadingCommentRanges; + function getTrailingCommentRanges(text, pos) { + return getCommentRanges(text, pos, true); + } + 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 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, + reScanJsxToken: reScanJsxToken, + scanJsxToken: scanJsxToken, + scan: scan, + setText: setText, + setScriptTarget: setScriptTarget, + setLanguageVariant: setLanguageVariant, + setOnError: setOnError, + setTextPos: setTextPos, + tryScan: tryScan, + lookAhead: lookAhead + }; + 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() { + var quote = text.charCodeAt(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) { + 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++); + 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 && isWhiteSpace(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; + } + return pos++, 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; + } + return pos++, 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; + } + return pos++, token = 46; + case 40: + return pos++, token = 17; + case 41: + return pos++, token = 18; + case 42: + if (text.charCodeAt(pos + 1) === 61) { + return pos += 2, token = 59; + } + if (text.charCodeAt(pos + 1) === 42) { + if (text.charCodeAt(pos + 2) === 61) { + return pos += 3, token = 60; + } + return pos += 2, token = 38; + } + return pos++, token = 37; + case 43: + if (text.charCodeAt(pos + 1) === 43) { + return pos += 2, token = 41; + } + if (text.charCodeAt(pos + 1) === 61) { + return pos += 2, token = 57; + } + return pos++, token = 35; + case 44: + return pos++, token = 24; + case 45: + if (text.charCodeAt(pos + 1) === 45) { + return pos += 2, token = 42; + } + if (text.charCodeAt(pos + 1) === 61) { + return pos += 2, token = 58; + } + return pos++, 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; + } + return pos++, 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; + } + return pos++, 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: + return pos++, token = 54; + case 59: + return pos++, 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; + } + return pos++, 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; + } + return pos++, token = 56; + case 62: + if (isConflictMarkerTrivia(text, pos)) { + pos = scanConflictMarkerTrivia(text, pos, error); + if (skipTrivia) { + continue; + } + else { + return token = 7; + } + } + return pos++, token = 27; + case 63: + return pos++, token = 53; + case 91: + return pos++, token = 19; + case 93: + return pos++, token = 20; + case 94: + if (text.charCodeAt(pos + 1) === 61) { + return pos += 2, token = 68; + } + return pos++, token = 48; + case 123: + return pos++, 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; + } + return pos++, token = 47; + case 125: + return pos++, token = 16; + case 126: + return pos++, token = 50; + case 64: + return pos++, 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); + return pos++, 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 (isWhiteSpace(ch)) { + pos++; + continue; + } + else if (isLineBreak(ch)) { + precedingLineBreak = true; + pos++; + continue; + } + error(ts.Diagnostics.Invalid_character); + return pos++, 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; + } + return pos++, token = 44; + } + if (text.charCodeAt(pos) === 61) { + return pos++, 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 = 236; + } + 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 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 lookAhead(callback) { + return speculationHelper(callback, true); + } + function tryScan(callback) { + return speculationHelper(callback, false); + } + 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.bindTime = 0; + function getModuleInstanceState(node) { + if (node.kind === 215 || node.kind === 216) { + return 0; + } + else if (ts.isConstEnumDeclaration(node)) { + return 2; + } + else if ((node.kind === 222 || node.kind === 221) && !(node.flags & 1)) { + return 0; + } + else if (node.kind === 219) { + var state = 0; + ts.forEachChild(node, function (n) { + switch (getModuleInstanceState(n)) { + case 0: + return false; + case 2: + state = 2; + return false; + case 1: + state = 1; + return true; + } + }); + return state; + } + else if (node.kind === 218) { + return getModuleInstanceState(node.body); + } + else { + return 1; + } + } + ts.getModuleInstanceState = getModuleInstanceState; + function bindSourceFile(file) { + var start = new Date().getTime(); + bindSourceFileWorker(file); + ts.bindTime += new Date().getTime() - start; + } + ts.bindSourceFile = bindSourceFile; + function bindSourceFileWorker(file) { + var parent; + var container; + var blockScopeContainer; + var lastContainer; + var seenThisKeyword; + var inStrictMode = !!file.externalModuleIndicator; + var symbolCount = 0; + var Symbol = ts.objectAllocator.getSymbolConstructor(); + var classifiableNames = {}; + if (!file.locals) { + bind(file); + file.symbolCount = symbolCount; + file.classifiableNames = classifiableNames; + } + return; + function createSymbol(flags, name) { + symbolCount++; + return new Symbol(flags, name); + } + function addDeclarationToSymbol(symbol, node, symbolFlags) { + symbol.flags |= symbolFlags; + node.symbol = symbol; + if (!symbol.declarations) { + symbol.declarations = []; + } + symbol.declarations.push(node); + if (symbolFlags & 1952 && !symbol.exports) { + symbol.exports = {}; + } + if (symbolFlags & 6240 && !symbol.members) { + symbol.members = {}; + } + if (symbolFlags & 107455 && !symbol.valueDeclaration) { + symbol.valueDeclaration = node; + } + } + function getDeclarationName(node) { + if (node.name) { + if (node.kind === 218 && node.name.kind === 9) { + return "\"" + node.name.text + "\""; + } + if (node.name.kind === 136) { + var nameExpression = node.name.expression; + ts.Debug.assert(ts.isWellKnownSymbolSyntactically(nameExpression)); + return ts.getPropertyNameForKnownSymbolName(nameExpression.name.text); + } + return node.name.text; + } + switch (node.kind) { + case 144: + return "__constructor"; + case 152: + case 147: + return "__call"; + case 153: + case 148: + return "__new"; + case 149: + return "__index"; + case 228: + return "__export"; + case 227: + return node.isExportEquals ? "export=" : "default"; + case 213: + case 214: + return node.flags & 1024 ? "default" : undefined; + } + } + function getDisplayName(node) { + return node.name ? ts.declarationNameToString(node.name) : getDeclarationName(node); + } + function declareSymbol(symbolTable, parent, node, includes, excludes) { + ts.Debug.assert(!ts.hasDynamicName(node)); + var isDefaultExport = node.flags & 1024; + var name = isDefaultExport && parent ? "default" : getDeclarationName(node); + var symbol; + if (name !== undefined) { + symbol = ts.hasProperty(symbolTable, name) + ? symbolTable[name] + : (symbolTable[name] = createSymbol(0, name)); + if (name && (includes & 788448)) { + classifiableNames[name] = name; + } + if (symbol.flags & excludes) { + if (node.name) { + node.name.parent = node; + } + var message = symbol.flags & 2 + ? ts.Diagnostics.Cannot_redeclare_block_scoped_variable_0 + : ts.Diagnostics.Duplicate_identifier_0; + ts.forEach(symbol.declarations, function (declaration) { + if (declaration.flags & 1024) { + message = ts.Diagnostics.A_module_cannot_have_multiple_default_exports; + } + }); + ts.forEach(symbol.declarations, function (declaration) { + file.bindDiagnostics.push(ts.createDiagnosticForNode(declaration.name || declaration, message, getDisplayName(declaration))); + }); + file.bindDiagnostics.push(ts.createDiagnosticForNode(node.name || node, message, getDisplayName(node))); + symbol = createSymbol(0, name); + } + } + else { + symbol = createSymbol(0, "__missing"); + } + addDeclarationToSymbol(symbol, node, includes); + symbol.parent = parent; + return symbol; + } + function declareModuleMember(node, symbolFlags, symbolExcludes) { + var hasExportModifier = ts.getCombinedNodeFlags(node) & 1; + if (symbolFlags & 8388608) { + if (node.kind === 230 || (node.kind === 221 && hasExportModifier)) { + return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); + } + else { + return declareSymbol(container.locals, undefined, node, symbolFlags, symbolExcludes); + } + } + else { + if (hasExportModifier || container.flags & 262144) { + var exportKind = (symbolFlags & 107455 ? 1048576 : 0) | + (symbolFlags & 793056 ? 2097152 : 0) | + (symbolFlags & 1536 ? 4194304 : 0); + var 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); + } + } + } + function bindChildren(node) { + var saveParent = parent; + var saveContainer = container; + var savedBlockScopeContainer = blockScopeContainer; + parent = node; + var containerFlags = getContainerFlags(node); + if (containerFlags & 1) { + container = blockScopeContainer = node; + if (containerFlags & 4) { + container.locals = {}; + } + addToContainerChain(container); + } + else if (containerFlags & 2) { + blockScopeContainer = node; + blockScopeContainer.locals = undefined; + } + if (node.kind === 215) { + seenThisKeyword = false; + ts.forEachChild(node, bind); + node.flags = seenThisKeyword ? node.flags | 524288 : node.flags & ~524288; + } + else { + ts.forEachChild(node, bind); + } + container = saveContainer; + parent = saveParent; + blockScopeContainer = savedBlockScopeContainer; + } + function getContainerFlags(node) { + switch (node.kind) { + case 186: + case 214: + case 215: + case 217: + case 155: + case 165: + return 1; + case 147: + case 148: + case 149: + case 143: + case 142: + case 213: + case 144: + case 145: + case 146: + case 152: + case 153: + case 173: + case 174: + case 218: + case 248: + case 216: + return 5; + case 244: + case 199: + case 200: + case 201: + case 220: + return 2; + case 192: + return ts.isFunctionLike(node.parent) ? 0 : 2; + } + return 0; + } + function addToContainerChain(next) { + if (lastContainer) { + lastContainer.nextContainer = next; + } + lastContainer = next; + } + function declareSymbolAndAddToSymbolTable(node, symbolFlags, symbolExcludes) { + declareSymbolAndAddToSymbolTableWorker(node, symbolFlags, symbolExcludes); + } + function declareSymbolAndAddToSymbolTableWorker(node, symbolFlags, symbolExcludes) { + switch (container.kind) { + case 218: + return declareModuleMember(node, symbolFlags, symbolExcludes); + case 248: + return declareSourceFileMember(node, symbolFlags, symbolExcludes); + case 186: + case 214: + return declareClassMember(node, symbolFlags, symbolExcludes); + case 217: + return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); + case 155: + case 165: + case 215: + return declareSymbol(container.symbol.members, container.symbol, node, symbolFlags, symbolExcludes); + case 152: + case 153: + case 147: + case 148: + case 149: + case 143: + case 142: + case 144: + case 145: + case 146: + case 213: + case 173: + case 174: + case 216: + return declareSymbol(container.locals, undefined, node, symbolFlags, symbolExcludes); + } + } + function declareClassMember(node, symbolFlags, symbolExcludes) { + return node.flags & 128 + ? declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes) + : declareSymbol(container.symbol.members, container.symbol, node, symbolFlags, symbolExcludes); + } + function declareSourceFileMember(node, symbolFlags, symbolExcludes) { + return ts.isExternalModule(file) + ? declareModuleMember(node, symbolFlags, symbolExcludes) + : declareSymbol(file.locals, undefined, node, symbolFlags, symbolExcludes); + } + function isAmbientContext(node) { + while (node) { + if (node.flags & 2) { + return true; + } + node = node.parent; + } + return false; + } + function hasExportDeclarations(node) { + var body = node.kind === 248 ? node : node.body; + if (body.kind === 248 || body.kind === 219) { + for (var _i = 0, _a = body.statements; _i < _a.length; _i++) { + var stat = _a[_i]; + if (stat.kind === 228 || stat.kind === 227) { + return true; + } + } + } + return false; + } + function setExportContextFlag(node) { + if (isAmbientContext(node) && !hasExportDeclarations(node)) { + node.flags |= 262144; + } + else { + node.flags &= ~262144; + } + } + function bindModuleDeclaration(node) { + setExportContextFlag(node); + if (node.name.kind === 9) { + declareSymbolAndAddToSymbolTable(node, 512, 106639); + } + else { + var state = getModuleInstanceState(node); + if (state === 0) { + declareSymbolAndAddToSymbolTable(node, 1024, 0); + } + else { + declareSymbolAndAddToSymbolTable(node, 512, 106639); + if (node.symbol.flags & (16 | 32 | 256)) { + node.symbol.constEnumOnlyModule = false; + } + else { + var currentModuleIsConstEnumOnly = state === 2; + if (node.symbol.constEnumOnlyModule === undefined) { + node.symbol.constEnumOnlyModule = currentModuleIsConstEnumOnly; + } + else { + node.symbol.constEnumOnlyModule = node.symbol.constEnumOnlyModule && currentModuleIsConstEnumOnly; + } + } + } + } + } + function bindFunctionOrConstructorType(node) { + var symbol = createSymbol(131072, getDeclarationName(node)); + addDeclarationToSymbol(symbol, node, 131072); + var typeLiteralSymbol = createSymbol(2048, "__type"); + addDeclarationToSymbol(typeLiteralSymbol, node, 2048); + typeLiteralSymbol.members = (_a = {}, _a[symbol.name] = symbol, _a); + var _a; + } + function bindObjectLiteralExpression(node) { + if (inStrictMode) { + var seen = {}; + for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { + var prop = _a[_i]; + if (prop.name.kind !== 69) { + continue; + } + var identifier = prop.name; + var currentKind = prop.kind === 245 || prop.kind === 246 || prop.kind === 143 + ? 1 + : 2; + var existingKind = seen[identifier.text]; + if (!existingKind) { + seen[identifier.text] = currentKind; + continue; + } + if (currentKind === 1 && existingKind === 1) { + var span = ts.getErrorSpanForNode(file, identifier); + file.bindDiagnostics.push(ts.createFileDiagnostic(file, span.start, span.length, ts.Diagnostics.An_object_literal_cannot_have_multiple_properties_with_the_same_name_in_strict_mode)); + } + } + } + return bindAnonymousDeclaration(node, 4096, "__object"); + } + function bindAnonymousDeclaration(node, symbolFlags, name) { + var symbol = createSymbol(symbolFlags, name); + addDeclarationToSymbol(symbol, node, symbolFlags); + } + function bindBlockScopedDeclaration(node, symbolFlags, symbolExcludes) { + switch (blockScopeContainer.kind) { + case 218: + declareModuleMember(node, symbolFlags, symbolExcludes); + break; + case 248: + if (ts.isExternalModule(container)) { + declareModuleMember(node, symbolFlags, symbolExcludes); + break; + } + default: + if (!blockScopeContainer.locals) { + blockScopeContainer.locals = {}; + addToContainerChain(blockScopeContainer); + } + declareSymbol(blockScopeContainer.locals, undefined, node, symbolFlags, symbolExcludes); + } + } + function bindBlockScopedVariableDeclaration(node) { + bindBlockScopedDeclaration(node, 2, 107455); + } + function checkStrictModeIdentifier(node) { + if (inStrictMode && + node.originalKeywordKind >= 106 && + node.originalKeywordKind <= 114 && + !ts.isIdentifierName(node)) { + if (!file.parseDiagnostics.length) { + file.bindDiagnostics.push(ts.createDiagnosticForNode(node, getStrictModeIdentifierMessage(node), ts.declarationNameToString(node))); + } + } + } + function getStrictModeIdentifierMessage(node) { + if (ts.getContainingClass(node)) { + return ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_strict_mode; + } + if (file.externalModuleIndicator) { + return ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode_Modules_are_automatically_in_strict_mode; + } + return ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode; + } + function checkStrictModeBinaryExpression(node) { + if (inStrictMode && ts.isLeftHandSideExpression(node.left) && ts.isAssignmentOperator(node.operatorToken.kind)) { + checkStrictModeEvalOrArguments(node, node.left); + } + } + function checkStrictModeCatchClause(node) { + if (inStrictMode && node.variableDeclaration) { + checkStrictModeEvalOrArguments(node, node.variableDeclaration.name); + } + } + function checkStrictModeDeleteExpression(node) { + if (inStrictMode && node.expression.kind === 69) { + var span = ts.getErrorSpanForNode(file, node.expression); + file.bindDiagnostics.push(ts.createFileDiagnostic(file, span.start, span.length, ts.Diagnostics.delete_cannot_be_called_on_an_identifier_in_strict_mode)); + } + } + function isEvalOrArgumentsIdentifier(node) { + return node.kind === 69 && + (node.text === "eval" || node.text === "arguments"); + } + function checkStrictModeEvalOrArguments(contextNode, name) { + if (name && name.kind === 69) { + var identifier = name; + if (isEvalOrArgumentsIdentifier(identifier)) { + var span = ts.getErrorSpanForNode(file, name); + file.bindDiagnostics.push(ts.createFileDiagnostic(file, span.start, span.length, getStrictModeEvalOrArgumentsMessage(contextNode), identifier.text)); + } + } + } + function getStrictModeEvalOrArgumentsMessage(node) { + if (ts.getContainingClass(node)) { + return ts.Diagnostics.Invalid_use_of_0_Class_definitions_are_automatically_in_strict_mode; + } + if (file.externalModuleIndicator) { + return ts.Diagnostics.Invalid_use_of_0_Modules_are_automatically_in_strict_mode; + } + return ts.Diagnostics.Invalid_use_of_0_in_strict_mode; + } + function checkStrictModeFunctionName(node) { + if (inStrictMode) { + checkStrictModeEvalOrArguments(node, node.name); + } + } + function checkStrictModeNumericLiteral(node) { + if (inStrictMode && node.flags & 65536) { + file.bindDiagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.Octal_literals_are_not_allowed_in_strict_mode)); + } + } + function checkStrictModePostfixUnaryExpression(node) { + if (inStrictMode) { + checkStrictModeEvalOrArguments(node, node.operand); + } + } + function checkStrictModePrefixUnaryExpression(node) { + if (inStrictMode) { + if (node.operator === 41 || node.operator === 42) { + checkStrictModeEvalOrArguments(node, node.operand); + } + } + } + function checkStrictModeWithStatement(node) { + if (inStrictMode) { + grammarErrorOnFirstToken(node, ts.Diagnostics.with_statements_are_not_allowed_in_strict_mode); + } + } + function grammarErrorOnFirstToken(node, message, arg0, arg1, arg2) { + var span = ts.getSpanOfTokenAtPosition(file, node.pos); + file.bindDiagnostics.push(ts.createFileDiagnostic(file, span.start, span.length, message, arg0, arg1, arg2)); + } + function getDestructuringParameterName(node) { + return "__" + ts.indexOf(node.parent.parameters, node); + } + function bind(node) { + node.parent = parent; + var savedInStrictMode = inStrictMode; + if (!savedInStrictMode) { + updateStrictMode(node); + } + bindWorker(node); + bindChildren(node); + inStrictMode = savedInStrictMode; + } + function updateStrictMode(node) { + switch (node.kind) { + case 248: + case 219: + updateStrictModeStatementList(node.statements); + return; + case 192: + if (ts.isFunctionLike(node.parent)) { + updateStrictModeStatementList(node.statements); + } + return; + case 214: + case 186: + inStrictMode = true; + return; + } + } + function updateStrictModeStatementList(statements) { + for (var _i = 0; _i < statements.length; _i++) { + var statement = statements[_i]; + if (!ts.isPrologueDirective(statement)) { + return; + } + if (isUseStrictPrologueDirective(statement)) { + inStrictMode = true; + return; + } + } + } + function isUseStrictPrologueDirective(node) { + var nodeText = ts.getTextOfNodeFromSourceText(file.text, node.expression); + return nodeText === "\"use strict\"" || nodeText === "'use strict'"; + } + function bindWorker(node) { + switch (node.kind) { + case 69: + return checkStrictModeIdentifier(node); + case 181: + return checkStrictModeBinaryExpression(node); + case 244: + return checkStrictModeCatchClause(node); + case 175: + return checkStrictModeDeleteExpression(node); + case 8: + return checkStrictModeNumericLiteral(node); + case 180: + return checkStrictModePostfixUnaryExpression(node); + case 179: + return checkStrictModePrefixUnaryExpression(node); + case 205: + return checkStrictModeWithStatement(node); + case 97: + seenThisKeyword = true; + return; + case 137: + return declareSymbolAndAddToSymbolTable(node, 262144, 530912); + case 138: + return bindParameter(node); + case 211: + case 163: + return bindVariableDeclarationOrBindingElement(node); + case 141: + case 140: + return bindPropertyOrMethodOrAccessor(node, 4 | (node.questionToken ? 536870912 : 0), 107455); + case 245: + case 246: + return bindPropertyOrMethodOrAccessor(node, 4, 107455); + case 247: + return bindPropertyOrMethodOrAccessor(node, 8, 107455); + case 147: + case 148: + case 149: + return declareSymbolAndAddToSymbolTable(node, 131072, 0); + case 143: + case 142: + return bindPropertyOrMethodOrAccessor(node, 8192 | (node.questionToken ? 536870912 : 0), ts.isObjectLiteralMethod(node) ? 107455 : 99263); + case 213: + checkStrictModeFunctionName(node); + return declareSymbolAndAddToSymbolTable(node, 16, 106927); + case 144: + return declareSymbolAndAddToSymbolTable(node, 16384, 0); + case 145: + return bindPropertyOrMethodOrAccessor(node, 32768, 41919); + case 146: + return bindPropertyOrMethodOrAccessor(node, 65536, 74687); + case 152: + case 153: + return bindFunctionOrConstructorType(node); + case 155: + return bindAnonymousDeclaration(node, 2048, "__type"); + case 165: + return bindObjectLiteralExpression(node); + case 173: + case 174: + checkStrictModeFunctionName(node); + var bindingName = node.name ? node.name.text : "__function"; + return bindAnonymousDeclaration(node, 16, bindingName); + case 186: + case 214: + return bindClassLikeDeclaration(node); + case 215: + return bindBlockScopedDeclaration(node, 64, 792960); + case 216: + return bindBlockScopedDeclaration(node, 524288, 793056); + case 217: + return bindEnumDeclaration(node); + case 218: + return bindModuleDeclaration(node); + case 221: + case 224: + case 226: + case 230: + return declareSymbolAndAddToSymbolTable(node, 8388608, 8388608); + case 223: + return bindImportClause(node); + case 228: + return bindExportDeclaration(node); + case 227: + return bindExportAssignment(node); + case 248: + return bindSourceFileIfExternalModule(); + } + } + function bindSourceFileIfExternalModule() { + setExportContextFlag(file); + if (ts.isExternalModule(file)) { + bindAnonymousDeclaration(file, 512, "\"" + ts.removeFileExtension(file.fileName) + "\""); + } + } + function bindExportAssignment(node) { + if (!container.symbol || !container.symbol.exports) { + bindAnonymousDeclaration(node, 8388608, getDeclarationName(node)); + } + else if (node.expression.kind === 69) { + declareSymbol(container.symbol.exports, container.symbol, node, 8388608, 107455 | 8388608); + } + else { + declareSymbol(container.symbol.exports, container.symbol, node, 4, 107455 | 8388608); + } + } + function bindExportDeclaration(node) { + if (!container.symbol || !container.symbol.exports) { + bindAnonymousDeclaration(node, 1073741824, getDeclarationName(node)); + } + else if (!node.exportClause) { + declareSymbol(container.symbol.exports, container.symbol, node, 1073741824, 0); + } + } + function bindImportClause(node) { + if (node.name) { + declareSymbolAndAddToSymbolTable(node, 8388608, 8388608); + } + } + function bindClassLikeDeclaration(node) { + if (node.kind === 214) { + bindBlockScopedDeclaration(node, 32, 899519); + } + else { + var bindingName = node.name ? node.name.text : "__class"; + bindAnonymousDeclaration(node, 32, bindingName); + if (node.name) { + classifiableNames[node.name.text] = node.name.text; + } + } + var symbol = node.symbol; + var prototypeSymbol = createSymbol(4 | 134217728, "prototype"); + if (ts.hasProperty(symbol.exports, prototypeSymbol.name)) { + if (node.name) { + node.name.parent = node; + } + file.bindDiagnostics.push(ts.createDiagnosticForNode(symbol.exports[prototypeSymbol.name].declarations[0], ts.Diagnostics.Duplicate_identifier_0, prototypeSymbol.name)); + } + symbol.exports[prototypeSymbol.name] = prototypeSymbol; + prototypeSymbol.parent = symbol; + } + function bindEnumDeclaration(node) { + return ts.isConst(node) + ? bindBlockScopedDeclaration(node, 128, 899967) + : bindBlockScopedDeclaration(node, 256, 899327); + } + function bindVariableDeclarationOrBindingElement(node) { + if (inStrictMode) { + checkStrictModeEvalOrArguments(node, node.name); + } + if (!ts.isBindingPattern(node.name)) { + if (ts.isBlockOrCatchScoped(node)) { + bindBlockScopedVariableDeclaration(node); + } + else if (ts.isParameterDeclaration(node)) { + declareSymbolAndAddToSymbolTable(node, 1, 107455); + } + else { + declareSymbolAndAddToSymbolTable(node, 1, 107454); + } + } + } + function bindParameter(node) { + if (inStrictMode) { + checkStrictModeEvalOrArguments(node, node.name); + } + if (ts.isBindingPattern(node.name)) { + bindAnonymousDeclaration(node, 1, getDestructuringParameterName(node)); + } + else { + declareSymbolAndAddToSymbolTable(node, 1, 107455); + } + if (node.flags & 112 && + node.parent.kind === 144 && + ts.isClassLike(node.parent.parent)) { + var classDeclaration = node.parent.parent; + declareSymbol(classDeclaration.symbol.members, classDeclaration.symbol, node, 4, 107455); + } + } + function bindPropertyOrMethodOrAccessor(node, symbolFlags, symbolExcludes) { + return ts.hasDynamicName(node) + ? bindAnonymousDeclaration(node, symbolFlags, "__computed") + : declareSymbolAndAddToSymbolTable(node, symbolFlags, symbolExcludes); + } + } +})(ts || (ts = {})); +var ts; +(function (ts) { + function getDeclarationOfKind(symbol, kind) { + var declarations = symbol.declarations; + if (declarations) { + for (var _i = 0; _i < declarations.length; _i++) { + var declaration = declarations[_i]; + if (declaration.kind === kind) { + return declaration; + } + } + } + return undefined; + } + ts.getDeclarationOfKind = getDeclarationOfKind; + var stringWriters = []; + function getSingleLineStringWriter() { + if (stringWriters.length === 0) { + var str = ""; + var writeText = function (text) { return str += text; }; + return { + string: function () { return str; }, + writeKeyword: writeText, + writeOperator: writeText, + writePunctuation: writeText, + writeSpace: writeText, + writeStringLiteral: writeText, + writeParameter: writeText, + writeSymbol: writeText, + writeLine: function () { return str += " "; }, + increaseIndent: function () { }, + decreaseIndent: function () { }, + clear: function () { return str = ""; }, + trackSymbol: function () { }, + reportInaccessibleThisError: function () { } + }; + } + return stringWriters.pop(); + } + ts.getSingleLineStringWriter = getSingleLineStringWriter; + function releaseStringWriter(writer) { + writer.clear(); + stringWriters.push(writer); + } + ts.releaseStringWriter = releaseStringWriter; + function getFullWidth(node) { + return node.end - node.pos; + } + ts.getFullWidth = getFullWidth; + function arrayIsEqualTo(array1, array2, equaler) { + if (!array1 || !array2) { + return array1 === array2; + } + if (array1.length !== array2.length) { + return false; + } + for (var i = 0; i < array1.length; ++i) { + var equals = equaler ? equaler(array1[i], array2[i]) : array1[i] === array2[i]; + if (!equals) { + return false; + } + } + return true; + } + ts.arrayIsEqualTo = arrayIsEqualTo; + function hasResolvedModule(sourceFile, moduleNameText) { + return sourceFile.resolvedModules && ts.hasProperty(sourceFile.resolvedModules, moduleNameText); + } + ts.hasResolvedModule = hasResolvedModule; + function getResolvedModule(sourceFile, moduleNameText) { + return hasResolvedModule(sourceFile, moduleNameText) ? sourceFile.resolvedModules[moduleNameText] : undefined; + } + ts.getResolvedModule = getResolvedModule; + function setResolvedModule(sourceFile, moduleNameText, resolvedModule) { + if (!sourceFile.resolvedModules) { + sourceFile.resolvedModules = {}; + } + sourceFile.resolvedModules[moduleNameText] = resolvedModule; + } + ts.setResolvedModule = setResolvedModule; + function containsParseError(node) { + aggregateChildData(node); + return (node.parserContextFlags & 64) !== 0; + } + ts.containsParseError = containsParseError; + function aggregateChildData(node) { + if (!(node.parserContextFlags & 128)) { + var thisNodeOrAnySubNodesHasError = ((node.parserContextFlags & 16) !== 0) || + ts.forEachChild(node, containsParseError); + if (thisNodeOrAnySubNodesHasError) { + node.parserContextFlags |= 64; + } + node.parserContextFlags |= 128; + } + } + function getSourceFileOfNode(node) { + while (node && node.kind !== 248) { + node = node.parent; + } + return node; + } + ts.getSourceFileOfNode = getSourceFileOfNode; + function getStartPositionOfLine(line, sourceFile) { + ts.Debug.assert(line >= 0); + return ts.getLineStarts(sourceFile)[line]; + } + ts.getStartPositionOfLine = getStartPositionOfLine; + function nodePosToString(node) { + var file = getSourceFileOfNode(node); + var loc = ts.getLineAndCharacterOfPosition(file, node.pos); + return file.fileName + "(" + (loc.line + 1) + "," + (loc.character + 1) + ")"; + } + ts.nodePosToString = nodePosToString; + function getStartPosOfNode(node) { + return node.pos; + } + ts.getStartPosOfNode = getStartPosOfNode; + function nodeIsMissing(node) { + if (!node) { + return true; + } + return node.pos === node.end && node.pos >= 0 && node.kind !== 1; + } + ts.nodeIsMissing = nodeIsMissing; + function nodeIsPresent(node) { + return !nodeIsMissing(node); + } + ts.nodeIsPresent = nodeIsPresent; + function getTokenPosOfNode(node, sourceFile) { + if (nodeIsMissing(node)) { + return node.pos; + } + return ts.skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.pos); + } + ts.getTokenPosOfNode = getTokenPosOfNode; + function getNonDecoratorTokenPosOfNode(node, sourceFile) { + if (nodeIsMissing(node) || !node.decorators) { + return getTokenPosOfNode(node, sourceFile); + } + return ts.skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.decorators.end); + } + ts.getNonDecoratorTokenPosOfNode = getNonDecoratorTokenPosOfNode; + function getSourceTextOfNodeFromSourceFile(sourceFile, node, includeTrivia) { + if (includeTrivia === void 0) { includeTrivia = false; } + if (nodeIsMissing(node)) { + return ""; + } + var text = sourceFile.text; + return text.substring(includeTrivia ? node.pos : ts.skipTrivia(text, node.pos), node.end); + } + ts.getSourceTextOfNodeFromSourceFile = getSourceTextOfNodeFromSourceFile; + function getTextOfNodeFromSourceText(sourceText, node) { + if (nodeIsMissing(node)) { + return ""; + } + return sourceText.substring(ts.skipTrivia(sourceText, node.pos), node.end); + } + ts.getTextOfNodeFromSourceText = getTextOfNodeFromSourceText; + function getTextOfNode(node, includeTrivia) { + if (includeTrivia === void 0) { includeTrivia = false; } + return getSourceTextOfNodeFromSourceFile(getSourceFileOfNode(node), node, includeTrivia); + } + ts.getTextOfNode = getTextOfNode; + function escapeIdentifier(identifier) { + return identifier.length >= 2 && identifier.charCodeAt(0) === 95 && identifier.charCodeAt(1) === 95 ? "_" + identifier : identifier; + } + ts.escapeIdentifier = escapeIdentifier; + function unescapeIdentifier(identifier) { + return identifier.length >= 3 && identifier.charCodeAt(0) === 95 && identifier.charCodeAt(1) === 95 && identifier.charCodeAt(2) === 95 ? identifier.substr(1) : identifier; + } + ts.unescapeIdentifier = unescapeIdentifier; + function makeIdentifierFromModuleName(moduleName) { + return ts.getBaseFileName(moduleName).replace(/^(\d)/, "_$1").replace(/\W/g, "_"); + } + ts.makeIdentifierFromModuleName = makeIdentifierFromModuleName; + function isBlockOrCatchScoped(declaration) { + return (getCombinedNodeFlags(declaration) & 49152) !== 0 || + isCatchClauseVariableDeclaration(declaration); + } + ts.isBlockOrCatchScoped = isBlockOrCatchScoped; + function getEnclosingBlockScopeContainer(node) { + var current = node.parent; + while (current) { + if (isFunctionLike(current)) { + return current; + } + switch (current.kind) { + case 248: + case 220: + case 244: + case 218: + case 199: + case 200: + case 201: + return current; + case 192: + if (!isFunctionLike(current.parent)) { + return current; + } + } + current = current.parent; + } + } + ts.getEnclosingBlockScopeContainer = getEnclosingBlockScopeContainer; + function isCatchClauseVariableDeclaration(declaration) { + return declaration && + declaration.kind === 211 && + declaration.parent && + declaration.parent.kind === 244; + } + ts.isCatchClauseVariableDeclaration = isCatchClauseVariableDeclaration; + function declarationNameToString(name) { + return getFullWidth(name) === 0 ? "(Missing)" : getTextOfNode(name); + } + ts.declarationNameToString = declarationNameToString; + function createDiagnosticForNode(node, message, arg0, arg1, arg2) { + var sourceFile = getSourceFileOfNode(node); + var span = getErrorSpanForNode(sourceFile, node); + return ts.createFileDiagnostic(sourceFile, span.start, span.length, message, arg0, arg1, arg2); + } + ts.createDiagnosticForNode = createDiagnosticForNode; + function createDiagnosticForNodeFromMessageChain(node, messageChain) { + var sourceFile = getSourceFileOfNode(node); + var span = getErrorSpanForNode(sourceFile, node); + return { + file: sourceFile, + start: span.start, + length: span.length, + code: messageChain.code, + category: messageChain.category, + messageText: messageChain.next ? messageChain : messageChain.messageText + }; + } + ts.createDiagnosticForNodeFromMessageChain = createDiagnosticForNodeFromMessageChain; + function getSpanOfTokenAtPosition(sourceFile, pos) { + var scanner = ts.createScanner(sourceFile.languageVersion, true, sourceFile.languageVariant, sourceFile.text, undefined, pos); + scanner.scan(); + var start = scanner.getTokenPos(); + return ts.createTextSpanFromBounds(start, scanner.getTextPos()); + } + ts.getSpanOfTokenAtPosition = getSpanOfTokenAtPosition; + function getErrorSpanForNode(sourceFile, node) { + var errorNode = node; + switch (node.kind) { + case 248: + var pos_1 = ts.skipTrivia(sourceFile.text, 0, false); + if (pos_1 === sourceFile.text.length) { + return ts.createTextSpan(0, 0); + } + return getSpanOfTokenAtPosition(sourceFile, pos_1); + case 211: + case 163: + case 214: + case 186: + case 215: + case 218: + case 217: + case 247: + case 213: + case 173: + errorNode = node.name; + break; + } + if (errorNode === undefined) { + return getSpanOfTokenAtPosition(sourceFile, node.pos); + } + var pos = nodeIsMissing(errorNode) + ? errorNode.pos + : ts.skipTrivia(sourceFile.text, errorNode.pos); + return ts.createTextSpanFromBounds(pos, errorNode.end); + } + ts.getErrorSpanForNode = getErrorSpanForNode; + function isExternalModule(file) { + return file.externalModuleIndicator !== undefined; + } + ts.isExternalModule = isExternalModule; + function isDeclarationFile(file) { + return (file.flags & 8192) !== 0; + } + ts.isDeclarationFile = isDeclarationFile; + function isConstEnumDeclaration(node) { + return node.kind === 217 && isConst(node); + } + ts.isConstEnumDeclaration = isConstEnumDeclaration; + function walkUpBindingElementsAndPatterns(node) { + while (node && (node.kind === 163 || isBindingPattern(node))) { + node = node.parent; + } + return node; + } + function getCombinedNodeFlags(node) { + node = walkUpBindingElementsAndPatterns(node); + var flags = node.flags; + if (node.kind === 211) { + node = node.parent; + } + if (node && node.kind === 212) { + flags |= node.flags; + node = node.parent; + } + if (node && node.kind === 193) { + flags |= node.flags; + } + return flags; + } + ts.getCombinedNodeFlags = getCombinedNodeFlags; + function isConst(node) { + return !!(getCombinedNodeFlags(node) & 32768); + } + ts.isConst = isConst; + function isLet(node) { + return !!(getCombinedNodeFlags(node) & 16384); + } + ts.isLet = isLet; + function isPrologueDirective(node) { + return node.kind === 195 && node.expression.kind === 9; + } + ts.isPrologueDirective = isPrologueDirective; + function getLeadingCommentRangesOfNode(node, sourceFileOfNode) { + return ts.getLeadingCommentRanges(sourceFileOfNode.text, node.pos); + } + ts.getLeadingCommentRangesOfNode = getLeadingCommentRangesOfNode; + function getJsDocComments(node, sourceFileOfNode) { + var commentRanges = (node.kind === 138 || node.kind === 137) ? + ts.concatenate(ts.getTrailingCommentRanges(sourceFileOfNode.text, node.pos), ts.getLeadingCommentRanges(sourceFileOfNode.text, node.pos)) : + getLeadingCommentRangesOfNode(node, sourceFileOfNode); + return ts.filter(commentRanges, isJsDocComment); + function isJsDocComment(comment) { + return sourceFileOfNode.text.charCodeAt(comment.pos + 1) === 42 && + sourceFileOfNode.text.charCodeAt(comment.pos + 2) === 42 && + sourceFileOfNode.text.charCodeAt(comment.pos + 3) !== 47; + } + } + ts.getJsDocComments = getJsDocComments; + ts.fullTripleSlashReferencePathRegEx = /^(\/\/\/\s*/; + ts.fullTripleSlashAMDReferencePathRegEx = /^(\/\/\/\s*/; + function isTypeNode(node) { + if (151 <= node.kind && node.kind <= 160) { + return true; + } + switch (node.kind) { + case 117: + case 128: + case 130: + case 120: + case 131: + return true; + case 103: + return node.parent.kind !== 177; + case 9: + return node.parent.kind === 138; + case 188: + return !isExpressionWithTypeArgumentsInClassExtendsClause(node); + case 69: + if (node.parent.kind === 135 && node.parent.right === node) { + node = node.parent; + } + else if (node.parent.kind === 166 && node.parent.name === node) { + node = node.parent; + } + ts.Debug.assert(node.kind === 69 || node.kind === 135 || node.kind === 166, "'node' was expected to be a qualified name, identifier or property access in 'isTypeNode'."); + case 135: + case 166: + case 97: + var parent_1 = node.parent; + if (parent_1.kind === 154) { + return false; + } + if (151 <= parent_1.kind && parent_1.kind <= 160) { + return true; + } + switch (parent_1.kind) { + case 188: + return !isExpressionWithTypeArgumentsInClassExtendsClause(parent_1); + case 137: + return node === parent_1.constraint; + case 141: + case 140: + case 138: + case 211: + return node === parent_1.type; + case 213: + case 173: + case 174: + case 144: + case 143: + case 142: + case 145: + case 146: + return node === parent_1.type; + case 147: + case 148: + case 149: + return node === parent_1.type; + case 171: + return node === parent_1.type; + case 168: + case 169: + return parent_1.typeArguments && ts.indexOf(parent_1.typeArguments, node) >= 0; + case 170: + return false; + } + } + return false; + } + ts.isTypeNode = isTypeNode; + function forEachReturnStatement(body, visitor) { + return traverse(body); + function traverse(node) { + switch (node.kind) { + case 204: + return visitor(node); + case 220: + case 192: + case 196: + case 197: + case 198: + case 199: + case 200: + case 201: + case 205: + case 206: + case 241: + case 242: + case 207: + case 209: + case 244: + return ts.forEachChild(node, traverse); + } + } + } + ts.forEachReturnStatement = forEachReturnStatement; + function forEachYieldExpression(body, visitor) { + return traverse(body); + function traverse(node) { + switch (node.kind) { + case 184: + visitor(node); + var operand = node.expression; + if (operand) { + traverse(operand); + } + case 217: + case 215: + case 218: + case 216: + case 214: + case 186: + return; + default: + if (isFunctionLike(node)) { + var name_5 = node.name; + if (name_5 && name_5.kind === 136) { + traverse(name_5.expression); + return; + } + } + else if (!isTypeNode(node)) { + ts.forEachChild(node, traverse); + } + } + } + } + ts.forEachYieldExpression = forEachYieldExpression; + function isVariableLike(node) { + if (node) { + switch (node.kind) { + case 163: + case 247: + case 138: + case 245: + case 141: + case 140: + case 246: + case 211: + return true; + } + } + return false; + } + ts.isVariableLike = isVariableLike; + function isAccessor(node) { + return node && (node.kind === 145 || node.kind === 146); + } + ts.isAccessor = isAccessor; + function isClassLike(node) { + return node && (node.kind === 214 || node.kind === 186); + } + ts.isClassLike = isClassLike; + function isFunctionLike(node) { + if (node) { + switch (node.kind) { + case 144: + case 173: + case 213: + case 174: + case 143: + case 142: + case 145: + case 146: + case 147: + case 148: + case 149: + case 152: + case 153: + return true; + } + } + return false; + } + ts.isFunctionLike = isFunctionLike; + function introducesArgumentsExoticObject(node) { + switch (node.kind) { + case 143: + case 142: + case 144: + case 145: + case 146: + case 213: + case 173: + return true; + } + return false; + } + ts.introducesArgumentsExoticObject = introducesArgumentsExoticObject; + function isIterationStatement(node, lookInLabeledStatements) { + switch (node.kind) { + case 199: + case 200: + case 201: + case 197: + case 198: + return true; + case 207: + return lookInLabeledStatements && isIterationStatement(node.statement, lookInLabeledStatements); + } + return false; + } + ts.isIterationStatement = isIterationStatement; + function isFunctionBlock(node) { + return node && node.kind === 192 && isFunctionLike(node.parent); + } + ts.isFunctionBlock = isFunctionBlock; + function isObjectLiteralMethod(node) { + return node && node.kind === 143 && node.parent.kind === 165; + } + ts.isObjectLiteralMethod = isObjectLiteralMethod; + function getContainingFunction(node) { + while (true) { + node = node.parent; + if (!node || isFunctionLike(node)) { + return node; + } + } + } + ts.getContainingFunction = getContainingFunction; + function getContainingClass(node) { + while (true) { + node = node.parent; + if (!node || isClassLike(node)) { + return node; + } + } + } + ts.getContainingClass = getContainingClass; + function getThisContainer(node, includeArrowFunctions) { + while (true) { + node = node.parent; + if (!node) { + return undefined; + } + switch (node.kind) { + case 136: + if (isClassLike(node.parent.parent)) { + return node; + } + node = node.parent; + break; + case 139: + if (node.parent.kind === 138 && isClassElement(node.parent.parent)) { + node = node.parent.parent; + } + else if (isClassElement(node.parent)) { + node = node.parent; + } + break; + case 174: + if (!includeArrowFunctions) { + continue; + } + case 213: + case 173: + case 218: + case 141: + case 140: + case 143: + case 142: + case 144: + case 145: + case 146: + case 147: + case 148: + case 149: + case 217: + case 248: + return node; + } + } + } + ts.getThisContainer = getThisContainer; + function getSuperContainer(node, includeFunctions) { + while (true) { + node = node.parent; + if (!node) + return node; + switch (node.kind) { + case 136: + if (isClassLike(node.parent.parent)) { + return node; + } + node = node.parent; + break; + case 139: + if (node.parent.kind === 138 && isClassElement(node.parent.parent)) { + node = node.parent.parent; + } + else if (isClassElement(node.parent)) { + node = node.parent; + } + break; + case 213: + case 173: + case 174: + if (!includeFunctions) { + continue; + } + case 141: + case 140: + case 143: + case 142: + case 144: + case 145: + case 146: + return node; + } + } + } + ts.getSuperContainer = getSuperContainer; + function getEntityNameFromTypeNode(node) { + if (node) { + switch (node.kind) { + case 151: + return node.typeName; + case 188: + return node.expression; + case 69: + case 135: + return node; + } + } + return undefined; + } + ts.getEntityNameFromTypeNode = getEntityNameFromTypeNode; + function getInvokedExpression(node) { + if (node.kind === 170) { + return node.tag; + } + return node.expression; + } + ts.getInvokedExpression = getInvokedExpression; + function nodeCanBeDecorated(node) { + switch (node.kind) { + case 214: + return true; + case 141: + return node.parent.kind === 214; + case 138: + return node.parent.body && node.parent.parent.kind === 214; + case 145: + case 146: + case 143: + return node.body && node.parent.kind === 214; + } + return false; + } + ts.nodeCanBeDecorated = nodeCanBeDecorated; + function nodeIsDecorated(node) { + switch (node.kind) { + case 214: + if (node.decorators) { + return true; + } + return false; + case 141: + case 138: + if (node.decorators) { + return true; + } + return false; + case 145: + if (node.body && node.decorators) { + return true; + } + return false; + case 143: + case 146: + if (node.body && node.decorators) { + return true; + } + return false; + } + return false; + } + ts.nodeIsDecorated = nodeIsDecorated; + function childIsDecorated(node) { + switch (node.kind) { + case 214: + return ts.forEach(node.members, nodeOrChildIsDecorated); + case 143: + case 146: + return ts.forEach(node.parameters, nodeIsDecorated); + } + return false; + } + ts.childIsDecorated = childIsDecorated; + function nodeOrChildIsDecorated(node) { + return nodeIsDecorated(node) || childIsDecorated(node); + } + ts.nodeOrChildIsDecorated = nodeOrChildIsDecorated; + function isPropertyAccessExpression(node) { + return node.kind === 166; + } + ts.isPropertyAccessExpression = isPropertyAccessExpression; + function isElementAccessExpression(node) { + return node.kind === 167; + } + ts.isElementAccessExpression = isElementAccessExpression; + function isExpression(node) { + switch (node.kind) { + case 95: + case 93: + case 99: + case 84: + case 10: + case 164: + case 165: + case 166: + case 167: + case 168: + case 169: + case 170: + case 189: + case 171: + case 172: + case 173: + case 186: + case 174: + case 177: + case 175: + case 176: + case 179: + case 180: + case 181: + case 182: + case 185: + case 183: + case 11: + case 187: + case 233: + case 234: + case 184: + case 178: + return true; + case 135: + while (node.parent.kind === 135) { + node = node.parent; + } + return node.parent.kind === 154; + case 69: + if (node.parent.kind === 154) { + return true; + } + case 8: + case 9: + case 97: + var parent_2 = node.parent; + switch (parent_2.kind) { + case 211: + case 138: + case 141: + case 140: + case 247: + case 245: + case 163: + return parent_2.initializer === node; + case 195: + case 196: + case 197: + case 198: + case 204: + case 205: + case 206: + case 241: + case 208: + case 206: + return parent_2.expression === node; + case 199: + var forStatement = parent_2; + return (forStatement.initializer === node && forStatement.initializer.kind !== 212) || + forStatement.condition === node || + forStatement.incrementor === node; + case 200: + case 201: + var forInStatement = parent_2; + return (forInStatement.initializer === node && forInStatement.initializer.kind !== 212) || + forInStatement.expression === node; + case 171: + case 189: + return node === parent_2.expression; + case 190: + return node === parent_2.expression; + case 136: + return node === parent_2.expression; + case 139: + case 240: + case 239: + return true; + case 188: + return parent_2.expression === node && isExpressionWithTypeArgumentsInClassExtendsClause(parent_2); + default: + if (isExpression(parent_2)) { + return true; + } + } + } + return false; + } + ts.isExpression = isExpression; + function isExternalModuleNameRelative(moduleName) { + return moduleName.substr(0, 2) === "./" || moduleName.substr(0, 3) === "../" || moduleName.substr(0, 2) === ".\\" || moduleName.substr(0, 3) === "..\\"; + } + ts.isExternalModuleNameRelative = isExternalModuleNameRelative; + function isInstantiatedModule(node, preserveConstEnums) { + var moduleState = ts.getModuleInstanceState(node); + return moduleState === 1 || + (preserveConstEnums && moduleState === 2); + } + ts.isInstantiatedModule = isInstantiatedModule; + function isExternalModuleImportEqualsDeclaration(node) { + return node.kind === 221 && node.moduleReference.kind === 232; + } + ts.isExternalModuleImportEqualsDeclaration = isExternalModuleImportEqualsDeclaration; + function getExternalModuleImportEqualsDeclarationExpression(node) { + ts.Debug.assert(isExternalModuleImportEqualsDeclaration(node)); + return node.moduleReference.expression; + } + ts.getExternalModuleImportEqualsDeclarationExpression = getExternalModuleImportEqualsDeclarationExpression; + function isInternalModuleImportEqualsDeclaration(node) { + return node.kind === 221 && node.moduleReference.kind !== 232; + } + ts.isInternalModuleImportEqualsDeclaration = isInternalModuleImportEqualsDeclaration; + function getExternalModuleName(node) { + if (node.kind === 222) { + return node.moduleSpecifier; + } + if (node.kind === 221) { + var reference = node.moduleReference; + if (reference.kind === 232) { + return reference.expression; + } + } + if (node.kind === 228) { + return node.moduleSpecifier; + } + } + ts.getExternalModuleName = getExternalModuleName; + function hasQuestionToken(node) { + if (node) { + switch (node.kind) { + case 138: + case 143: + case 142: + case 246: + case 245: + case 141: + case 140: + return node.questionToken !== undefined; + } + } + return false; + } + ts.hasQuestionToken = hasQuestionToken; + function isJSDocConstructSignature(node) { + return node.kind === 261 && + node.parameters.length > 0 && + node.parameters[0].type.kind === 263; + } + ts.isJSDocConstructSignature = isJSDocConstructSignature; + function getJSDocTag(node, kind) { + if (node && node.jsDocComment) { + for (var _i = 0, _a = node.jsDocComment.tags; _i < _a.length; _i++) { + var tag = _a[_i]; + if (tag.kind === kind) { + return tag; + } + } + } + } + function getJSDocTypeTag(node) { + return getJSDocTag(node, 269); + } + ts.getJSDocTypeTag = getJSDocTypeTag; + function getJSDocReturnTag(node) { + return getJSDocTag(node, 268); + } + ts.getJSDocReturnTag = getJSDocReturnTag; + function getJSDocTemplateTag(node) { + return getJSDocTag(node, 270); + } + ts.getJSDocTemplateTag = getJSDocTemplateTag; + function getCorrespondingJSDocParameterTag(parameter) { + if (parameter.name && parameter.name.kind === 69) { + var parameterName = parameter.name.text; + var docComment = parameter.parent.jsDocComment; + if (docComment) { + return ts.forEach(docComment.tags, function (t) { + if (t.kind === 267) { + var parameterTag = t; + var name_6 = parameterTag.preParameterName || parameterTag.postParameterName; + if (name_6.text === parameterName) { + return t; + } + } + }); + } + } + } + ts.getCorrespondingJSDocParameterTag = getCorrespondingJSDocParameterTag; + function hasRestParameter(s) { + return isRestParameter(ts.lastOrUndefined(s.parameters)); + } + ts.hasRestParameter = hasRestParameter; + function isRestParameter(node) { + if (node) { + if (node.parserContextFlags & 32) { + if (node.type && node.type.kind === 262) { + return true; + } + var paramTag = getCorrespondingJSDocParameterTag(node); + if (paramTag && paramTag.typeExpression) { + return paramTag.typeExpression.type.kind === 262; + } + } + return node.dotDotDotToken !== undefined; + } + return false; + } + ts.isRestParameter = isRestParameter; + function isLiteralKind(kind) { + return 8 <= kind && kind <= 11; + } + ts.isLiteralKind = isLiteralKind; + function isTextualLiteralKind(kind) { + return kind === 9 || kind === 11; + } + ts.isTextualLiteralKind = isTextualLiteralKind; + function isTemplateLiteralKind(kind) { + return 11 <= kind && kind <= 14; + } + ts.isTemplateLiteralKind = isTemplateLiteralKind; + function isBindingPattern(node) { + return !!node && (node.kind === 162 || node.kind === 161); + } + ts.isBindingPattern = isBindingPattern; + function isInAmbientContext(node) { + while (node) { + if (node.flags & (2 | 8192)) { + return true; + } + node = node.parent; + } + return false; + } + ts.isInAmbientContext = isInAmbientContext; + function isDeclaration(node) { + switch (node.kind) { + case 174: + case 163: + case 214: + case 186: + case 144: + case 217: + case 247: + case 230: + case 213: + case 173: + case 145: + case 223: + case 221: + case 226: + case 215: + case 143: + case 142: + case 218: + case 224: + case 138: + case 245: + case 141: + case 140: + case 146: + case 246: + case 216: + case 137: + case 211: + return true; + } + return false; + } + ts.isDeclaration = isDeclaration; + function isStatement(n) { + switch (n.kind) { + case 203: + case 202: + case 210: + case 197: + case 195: + case 194: + case 200: + case 201: + case 199: + case 196: + case 207: + case 204: + case 206: + case 98: + case 209: + case 193: + case 198: + case 205: + case 227: + return true; + default: + return false; + } + } + ts.isStatement = isStatement; + function isClassElement(n) { + switch (n.kind) { + case 144: + case 141: + case 143: + case 145: + case 146: + case 142: + case 149: + return true; + default: + return false; + } + } + ts.isClassElement = isClassElement; + function isDeclarationName(name) { + if (name.kind !== 69 && name.kind !== 9 && name.kind !== 8) { + return false; + } + var parent = name.parent; + if (parent.kind === 226 || parent.kind === 230) { + if (parent.propertyName) { + return true; + } + } + if (isDeclaration(parent)) { + return parent.name === name; + } + return false; + } + ts.isDeclarationName = isDeclarationName; + function isIdentifierName(node) { + var parent = node.parent; + switch (parent.kind) { + case 141: + case 140: + case 143: + case 142: + case 145: + case 146: + case 247: + case 245: + case 166: + return parent.name === node; + case 135: + if (parent.right === node) { + while (parent.kind === 135) { + parent = parent.parent; + } + return parent.kind === 154; + } + return false; + case 163: + case 226: + return parent.propertyName === node; + case 230: + return true; + } + return false; + } + ts.isIdentifierName = isIdentifierName; + function isAliasSymbolDeclaration(node) { + return node.kind === 221 || + node.kind === 223 && !!node.name || + node.kind === 224 || + node.kind === 226 || + node.kind === 230 || + node.kind === 227 && node.expression.kind === 69; + } + ts.isAliasSymbolDeclaration = isAliasSymbolDeclaration; + function getClassExtendsHeritageClauseElement(node) { + var heritageClause = getHeritageClause(node.heritageClauses, 83); + return heritageClause && heritageClause.types.length > 0 ? heritageClause.types[0] : undefined; + } + ts.getClassExtendsHeritageClauseElement = getClassExtendsHeritageClauseElement; + function getClassImplementsHeritageClauseElements(node) { + var heritageClause = getHeritageClause(node.heritageClauses, 106); + return heritageClause ? heritageClause.types : undefined; + } + ts.getClassImplementsHeritageClauseElements = getClassImplementsHeritageClauseElements; + function getInterfaceBaseTypeNodes(node) { + var heritageClause = getHeritageClause(node.heritageClauses, 83); + return heritageClause ? heritageClause.types : undefined; + } + ts.getInterfaceBaseTypeNodes = getInterfaceBaseTypeNodes; + function getHeritageClause(clauses, kind) { + if (clauses) { + for (var _i = 0; _i < clauses.length; _i++) { + var clause = clauses[_i]; + if (clause.token === kind) { + return clause; + } + } + } + return undefined; + } + ts.getHeritageClause = getHeritageClause; + function tryResolveScriptReference(host, sourceFile, reference) { + if (!host.getCompilerOptions().noResolve) { + var referenceFileName = ts.isRootedDiskPath(reference.fileName) ? reference.fileName : ts.combinePaths(ts.getDirectoryPath(sourceFile.fileName), reference.fileName); + referenceFileName = ts.getNormalizedAbsolutePath(referenceFileName, host.getCurrentDirectory()); + return host.getSourceFile(referenceFileName); + } + } + ts.tryResolveScriptReference = tryResolveScriptReference; + function getAncestor(node, kind) { + while (node) { + if (node.kind === kind) { + return node; + } + node = node.parent; + } + return undefined; + } + ts.getAncestor = getAncestor; + function getFileReferenceFromReferencePath(comment, commentRange) { + var simpleReferenceRegEx = /^\/\/\/\s*/gim; + if (simpleReferenceRegEx.exec(comment)) { + if (isNoDefaultLibRegEx.exec(comment)) { + return { + isNoDefaultLib: true + }; + } + else { + var matchResult = ts.fullTripleSlashReferencePathRegEx.exec(comment); + if (matchResult) { + var start = commentRange.pos; + var end = commentRange.end; + return { + fileReference: { + pos: start, + end: end, + fileName: matchResult[3] + }, + isNoDefaultLib: false + }; + } + else { + return { + diagnosticMessage: ts.Diagnostics.Invalid_reference_directive_syntax, + isNoDefaultLib: false + }; + } + } + } + return undefined; + } + ts.getFileReferenceFromReferencePath = getFileReferenceFromReferencePath; + function isKeyword(token) { + return 70 <= token && token <= 134; + } + ts.isKeyword = isKeyword; + function isTrivia(token) { + return 2 <= token && token <= 7; + } + ts.isTrivia = isTrivia; + function isAsyncFunctionLike(node) { + return isFunctionLike(node) && (node.flags & 512) !== 0 && !isAccessor(node); + } + ts.isAsyncFunctionLike = isAsyncFunctionLike; + function hasDynamicName(declaration) { + return declaration.name && + declaration.name.kind === 136 && + !isWellKnownSymbolSyntactically(declaration.name.expression); + } + ts.hasDynamicName = hasDynamicName; + function isWellKnownSymbolSyntactically(node) { + return isPropertyAccessExpression(node) && isESSymbolIdentifier(node.expression); + } + ts.isWellKnownSymbolSyntactically = isWellKnownSymbolSyntactically; + function getPropertyNameForPropertyNameNode(name) { + if (name.kind === 69 || name.kind === 9 || name.kind === 8) { + return name.text; + } + if (name.kind === 136) { + var nameExpression = name.expression; + if (isWellKnownSymbolSyntactically(nameExpression)) { + var rightHandSideName = nameExpression.name.text; + return getPropertyNameForKnownSymbolName(rightHandSideName); + } + } + return undefined; + } + ts.getPropertyNameForPropertyNameNode = getPropertyNameForPropertyNameNode; + function getPropertyNameForKnownSymbolName(symbolName) { + return "__@" + symbolName; + } + ts.getPropertyNameForKnownSymbolName = getPropertyNameForKnownSymbolName; + function isESSymbolIdentifier(node) { + return node.kind === 69 && node.text === "Symbol"; + } + ts.isESSymbolIdentifier = isESSymbolIdentifier; + function isModifier(token) { + switch (token) { + case 115: + case 118: + case 74: + case 122: + case 77: + case 82: + case 112: + case 110: + case 111: + case 113: + return true; + } + return false; + } + ts.isModifier = isModifier; + function isParameterDeclaration(node) { + var root = getRootDeclaration(node); + return root.kind === 138; + } + ts.isParameterDeclaration = isParameterDeclaration; + function getRootDeclaration(node) { + while (node.kind === 163) { + node = node.parent.parent; + } + return node; + } + ts.getRootDeclaration = getRootDeclaration; + function nodeStartsNewLexicalEnvironment(n) { + return isFunctionLike(n) || n.kind === 218 || n.kind === 248; + } + ts.nodeStartsNewLexicalEnvironment = nodeStartsNewLexicalEnvironment; + function cloneEntityName(node) { + if (node.kind === 69) { + var clone_1 = createSynthesizedNode(69); + clone_1.text = node.text; + return clone_1; + } + else { + var clone_2 = createSynthesizedNode(135); + clone_2.left = cloneEntityName(node.left); + clone_2.left.parent = clone_2; + clone_2.right = cloneEntityName(node.right); + clone_2.right.parent = clone_2; + return clone_2; + } + } + ts.cloneEntityName = cloneEntityName; + function nodeIsSynthesized(node) { + return node.pos === -1; + } + ts.nodeIsSynthesized = nodeIsSynthesized; + function createSynthesizedNode(kind, startsOnNewLine) { + var node = ts.createNode(kind, -1, -1); + node.startsOnNewLine = startsOnNewLine; + return node; + } + ts.createSynthesizedNode = createSynthesizedNode; + function createSynthesizedNodeArray() { + var array = []; + array.pos = -1; + array.end = -1; + return array; + } + ts.createSynthesizedNodeArray = createSynthesizedNodeArray; + function createDiagnosticCollection() { + var nonFileDiagnostics = []; + var fileDiagnostics = {}; + var diagnosticsModified = false; + var modificationCount = 0; + return { + add: add, + getGlobalDiagnostics: getGlobalDiagnostics, + getDiagnostics: getDiagnostics, + getModificationCount: getModificationCount, + reattachFileDiagnostics: reattachFileDiagnostics + }; + function getModificationCount() { + return modificationCount; + } + function reattachFileDiagnostics(newFile) { + if (!ts.hasProperty(fileDiagnostics, newFile.fileName)) { + return; + } + for (var _i = 0, _a = fileDiagnostics[newFile.fileName]; _i < _a.length; _i++) { + var diagnostic = _a[_i]; + diagnostic.file = newFile; + } + } + function add(diagnostic) { + var diagnostics; + if (diagnostic.file) { + diagnostics = fileDiagnostics[diagnostic.file.fileName]; + if (!diagnostics) { + diagnostics = []; + fileDiagnostics[diagnostic.file.fileName] = diagnostics; + } + } + else { + diagnostics = nonFileDiagnostics; + } + diagnostics.push(diagnostic); + diagnosticsModified = true; + modificationCount++; + } + function getGlobalDiagnostics() { + sortAndDeduplicate(); + return nonFileDiagnostics; + } + function getDiagnostics(fileName) { + sortAndDeduplicate(); + if (fileName) { + return fileDiagnostics[fileName] || []; + } + var allDiagnostics = []; + function pushDiagnostic(d) { + allDiagnostics.push(d); + } + ts.forEach(nonFileDiagnostics, pushDiagnostic); + for (var key in fileDiagnostics) { + if (ts.hasProperty(fileDiagnostics, key)) { + ts.forEach(fileDiagnostics[key], pushDiagnostic); + } + } + return ts.sortAndDeduplicateDiagnostics(allDiagnostics); + } + function sortAndDeduplicate() { + if (!diagnosticsModified) { + return; + } + diagnosticsModified = false; + nonFileDiagnostics = ts.sortAndDeduplicateDiagnostics(nonFileDiagnostics); + for (var key in fileDiagnostics) { + if (ts.hasProperty(fileDiagnostics, key)) { + fileDiagnostics[key] = ts.sortAndDeduplicateDiagnostics(fileDiagnostics[key]); + } + } + } + } + ts.createDiagnosticCollection = createDiagnosticCollection; + var escapedCharsRegExp = /[\\\"\u0000-\u001f\t\v\f\b\r\n\u2028\u2029\u0085]/g; + var escapedCharsMap = { + "\0": "\\0", + "\t": "\\t", + "\v": "\\v", + "\f": "\\f", + "\b": "\\b", + "\r": "\\r", + "\n": "\\n", + "\\": "\\\\", + "\"": "\\\"", + "\u2028": "\\u2028", + "\u2029": "\\u2029", + "\u0085": "\\u0085" + }; + function escapeString(s) { + s = escapedCharsRegExp.test(s) ? s.replace(escapedCharsRegExp, getReplacement) : s; + return s; + function getReplacement(c) { + return escapedCharsMap[c] || get16BitUnicodeEscapeSequence(c.charCodeAt(0)); + } + } + ts.escapeString = escapeString; + function isIntrinsicJsxName(name) { + var ch = name.substr(0, 1); + return ch.toLowerCase() === ch; + } + ts.isIntrinsicJsxName = isIntrinsicJsxName; + function get16BitUnicodeEscapeSequence(charCode) { + var hexCharCode = charCode.toString(16).toUpperCase(); + var paddedHexCode = ("0000" + hexCharCode).slice(-4); + return "\\u" + paddedHexCode; + } + var nonAsciiCharacters = /[^\u0000-\u007F]/g; + function escapeNonAsciiCharacters(s) { + return nonAsciiCharacters.test(s) ? + s.replace(nonAsciiCharacters, function (c) { return get16BitUnicodeEscapeSequence(c.charCodeAt(0)); }) : + s; + } + ts.escapeNonAsciiCharacters = escapeNonAsciiCharacters; + var indentStrings = ["", " "]; + function getIndentString(level) { + if (indentStrings[level] === undefined) { + indentStrings[level] = getIndentString(level - 1) + indentStrings[1]; + } + return indentStrings[level]; + } + ts.getIndentString = getIndentString; + function getIndentSize() { + return indentStrings[1].length; + } + ts.getIndentSize = getIndentSize; + function createTextWriter(newLine) { + var output = ""; + var indent = 0; + var lineStart = true; + var lineCount = 0; + var linePos = 0; + function write(s) { + if (s && s.length) { + if (lineStart) { + output += getIndentString(indent); + lineStart = false; + } + output += s; + } + } + function rawWrite(s) { + if (s !== undefined) { + if (lineStart) { + lineStart = false; + } + output += s; + } + } + function writeLiteral(s) { + if (s && s.length) { + write(s); + var lineStartsOfS = ts.computeLineStarts(s); + if (lineStartsOfS.length > 1) { + lineCount = lineCount + lineStartsOfS.length - 1; + linePos = output.length - s.length + ts.lastOrUndefined(lineStartsOfS); + } + } + } + function writeLine() { + if (!lineStart) { + output += newLine; + lineCount++; + linePos = output.length; + lineStart = true; + } + } + function writeTextOfNode(sourceFile, node) { + write(getSourceTextOfNodeFromSourceFile(sourceFile, node)); + } + return { + write: write, + rawWrite: rawWrite, + writeTextOfNode: writeTextOfNode, + writeLiteral: writeLiteral, + writeLine: writeLine, + increaseIndent: function () { return indent++; }, + decreaseIndent: function () { return indent--; }, + getIndent: function () { return indent; }, + getTextPos: function () { return output.length; }, + getLine: function () { return lineCount + 1; }, + getColumn: function () { return lineStart ? indent * getIndentSize() + 1 : output.length - linePos + 1; }, + getText: function () { return output; } + }; + } + ts.createTextWriter = createTextWriter; + function getOwnEmitOutputFilePath(sourceFile, host, extension) { + var compilerOptions = host.getCompilerOptions(); + var emitOutputFilePathWithoutExtension; + if (compilerOptions.outDir) { + emitOutputFilePathWithoutExtension = ts.removeFileExtension(getSourceFilePathInNewDir(sourceFile, host, compilerOptions.outDir)); + } + else { + emitOutputFilePathWithoutExtension = ts.removeFileExtension(sourceFile.fileName); + } + return emitOutputFilePathWithoutExtension + extension; + } + ts.getOwnEmitOutputFilePath = getOwnEmitOutputFilePath; + function getSourceFilePathInNewDir(sourceFile, host, newDirPath) { + var sourceFilePath = ts.getNormalizedAbsolutePath(sourceFile.fileName, host.getCurrentDirectory()); + sourceFilePath = sourceFilePath.replace(host.getCommonSourceDirectory(), ""); + return ts.combinePaths(newDirPath, sourceFilePath); + } + ts.getSourceFilePathInNewDir = getSourceFilePathInNewDir; + function writeFile(host, diagnostics, fileName, data, writeByteOrderMark) { + host.writeFile(fileName, data, writeByteOrderMark, function (hostErrorMessage) { + diagnostics.push(ts.createCompilerDiagnostic(ts.Diagnostics.Could_not_write_file_0_Colon_1, fileName, hostErrorMessage)); + }); + } + ts.writeFile = writeFile; + function getLineOfLocalPosition(currentSourceFile, pos) { + return ts.getLineAndCharacterOfPosition(currentSourceFile, pos).line; + } + ts.getLineOfLocalPosition = getLineOfLocalPosition; + function getFirstConstructorWithBody(node) { + return ts.forEach(node.members, function (member) { + if (member.kind === 144 && nodeIsPresent(member.body)) { + return member; + } + }); + } + ts.getFirstConstructorWithBody = getFirstConstructorWithBody; + function getSetAccessorTypeAnnotationNode(accessor) { + return accessor && accessor.parameters.length > 0 && accessor.parameters[0].type; + } + ts.getSetAccessorTypeAnnotationNode = getSetAccessorTypeAnnotationNode; + function shouldEmitToOwnFile(sourceFile, compilerOptions) { + if (!isDeclarationFile(sourceFile)) { + if ((isExternalModule(sourceFile) || !(compilerOptions.outFile || compilerOptions.out))) { + return compilerOptions.isolatedModules || !ts.fileExtensionIs(sourceFile.fileName, ".js"); + } + return false; + } + return false; + } + ts.shouldEmitToOwnFile = shouldEmitToOwnFile; + function getAllAccessorDeclarations(declarations, accessor) { + var firstAccessor; + var secondAccessor; + var getAccessor; + var setAccessor; + if (hasDynamicName(accessor)) { + firstAccessor = accessor; + if (accessor.kind === 145) { + getAccessor = accessor; + } + else if (accessor.kind === 146) { + setAccessor = accessor; + } + else { + ts.Debug.fail("Accessor has wrong kind"); + } + } + else { + ts.forEach(declarations, function (member) { + if ((member.kind === 145 || member.kind === 146) + && (member.flags & 128) === (accessor.flags & 128)) { + var memberName = getPropertyNameForPropertyNameNode(member.name); + var accessorName = getPropertyNameForPropertyNameNode(accessor.name); + if (memberName === accessorName) { + if (!firstAccessor) { + firstAccessor = member; + } + else if (!secondAccessor) { + secondAccessor = member; + } + if (member.kind === 145 && !getAccessor) { + getAccessor = member; + } + if (member.kind === 146 && !setAccessor) { + setAccessor = member; + } + } + } + }); + } + return { + firstAccessor: firstAccessor, + secondAccessor: secondAccessor, + getAccessor: getAccessor, + setAccessor: setAccessor + }; + } + ts.getAllAccessorDeclarations = getAllAccessorDeclarations; + function emitNewLineBeforeLeadingComments(currentSourceFile, writer, node, leadingComments) { + if (leadingComments && leadingComments.length && node.pos !== leadingComments[0].pos && + getLineOfLocalPosition(currentSourceFile, node.pos) !== getLineOfLocalPosition(currentSourceFile, leadingComments[0].pos)) { + writer.writeLine(); + } + } + ts.emitNewLineBeforeLeadingComments = emitNewLineBeforeLeadingComments; + function emitComments(currentSourceFile, writer, comments, trailingSeparator, newLine, writeComment) { + var emitLeadingSpace = !trailingSeparator; + ts.forEach(comments, function (comment) { + if (emitLeadingSpace) { + writer.write(" "); + emitLeadingSpace = false; + } + writeComment(currentSourceFile, writer, comment, newLine); + if (comment.hasTrailingNewLine) { + writer.writeLine(); + } + else if (trailingSeparator) { + writer.write(" "); + } + else { + emitLeadingSpace = true; + } + }); + } + ts.emitComments = emitComments; + function writeCommentRange(currentSourceFile, writer, comment, newLine) { + if (currentSourceFile.text.charCodeAt(comment.pos + 1) === 42) { + var firstCommentLineAndCharacter = ts.getLineAndCharacterOfPosition(currentSourceFile, comment.pos); + var lineCount = ts.getLineStarts(currentSourceFile).length; + var firstCommentLineIndent; + for (var pos = comment.pos, currentLine = firstCommentLineAndCharacter.line; pos < comment.end; currentLine++) { + var nextLineStart = (currentLine + 1) === lineCount + ? currentSourceFile.text.length + 1 + : getStartPositionOfLine(currentLine + 1, currentSourceFile); + if (pos !== comment.pos) { + if (firstCommentLineIndent === undefined) { + firstCommentLineIndent = calculateIndent(getStartPositionOfLine(firstCommentLineAndCharacter.line, currentSourceFile), comment.pos); + } + var currentWriterIndentSpacing = writer.getIndent() * getIndentSize(); + var spacesToEmit = currentWriterIndentSpacing - firstCommentLineIndent + calculateIndent(pos, nextLineStart); + if (spacesToEmit > 0) { + var numberOfSingleSpacesToEmit = spacesToEmit % getIndentSize(); + var indentSizeSpaceString = getIndentString((spacesToEmit - numberOfSingleSpacesToEmit) / getIndentSize()); + writer.rawWrite(indentSizeSpaceString); + while (numberOfSingleSpacesToEmit) { + writer.rawWrite(" "); + numberOfSingleSpacesToEmit--; + } + } + else { + writer.rawWrite(""); + } + } + writeTrimmedCurrentLine(pos, nextLineStart); + pos = nextLineStart; + } + } + else { + writer.write(currentSourceFile.text.substring(comment.pos, comment.end)); + } + function writeTrimmedCurrentLine(pos, nextLineStart) { + var end = Math.min(comment.end, nextLineStart - 1); + var currentLineText = currentSourceFile.text.substring(pos, end).replace(/^\s+|\s+$/g, ""); + if (currentLineText) { + writer.write(currentLineText); + if (end !== comment.end) { + writer.writeLine(); + } + } + else { + writer.writeLiteral(newLine); + } + } + function calculateIndent(pos, end) { + var currentLineIndent = 0; + for (; pos < end && ts.isWhiteSpace(currentSourceFile.text.charCodeAt(pos)); pos++) { + if (currentSourceFile.text.charCodeAt(pos) === 9) { + currentLineIndent += getIndentSize() - (currentLineIndent % getIndentSize()); + } + else { + currentLineIndent++; + } + } + return currentLineIndent; + } + } + ts.writeCommentRange = writeCommentRange; + function modifierToFlag(token) { + switch (token) { + case 113: return 128; + case 112: return 16; + case 111: return 64; + case 110: return 32; + case 115: return 256; + case 82: return 1; + case 122: return 2; + case 74: return 32768; + case 77: return 1024; + case 118: return 512; + } + return 0; + } + ts.modifierToFlag = modifierToFlag; + function isLeftHandSideExpression(expr) { + if (expr) { + switch (expr.kind) { + case 166: + case 167: + case 169: + case 168: + case 233: + case 234: + case 170: + case 164: + case 172: + case 165: + case 186: + case 173: + case 69: + case 10: + case 8: + case 9: + case 11: + case 183: + case 84: + case 93: + case 97: + case 99: + case 95: + return true; + } + } + return false; + } + ts.isLeftHandSideExpression = isLeftHandSideExpression; + function isAssignmentOperator(token) { + return token >= 56 && token <= 68; + } + ts.isAssignmentOperator = isAssignmentOperator; + function isExpressionWithTypeArgumentsInClassExtendsClause(node) { + return node.kind === 188 && + node.parent.token === 83 && + isClassLike(node.parent.parent); + } + ts.isExpressionWithTypeArgumentsInClassExtendsClause = isExpressionWithTypeArgumentsInClassExtendsClause; + function isSupportedExpressionWithTypeArguments(node) { + return isSupportedExpressionWithTypeArgumentsRest(node.expression); + } + ts.isSupportedExpressionWithTypeArguments = isSupportedExpressionWithTypeArguments; + function isSupportedExpressionWithTypeArgumentsRest(node) { + if (node.kind === 69) { + return true; + } + else if (isPropertyAccessExpression(node)) { + return isSupportedExpressionWithTypeArgumentsRest(node.expression); + } + else { + return false; + } + } + function isRightSideOfQualifiedNameOrPropertyAccess(node) { + return (node.parent.kind === 135 && node.parent.right === node) || + (node.parent.kind === 166 && node.parent.name === node); + } + ts.isRightSideOfQualifiedNameOrPropertyAccess = isRightSideOfQualifiedNameOrPropertyAccess; + function isEmptyObjectLiteralOrArrayLiteral(expression) { + var kind = expression.kind; + if (kind === 165) { + return expression.properties.length === 0; + } + if (kind === 164) { + return expression.elements.length === 0; + } + return false; + } + ts.isEmptyObjectLiteralOrArrayLiteral = isEmptyObjectLiteralOrArrayLiteral; + function getLocalSymbolForExportDefault(symbol) { + return symbol && symbol.valueDeclaration && (symbol.valueDeclaration.flags & 1024) ? symbol.valueDeclaration.localSymbol : undefined; + } + ts.getLocalSymbolForExportDefault = getLocalSymbolForExportDefault; + function isJavaScript(fileName) { + return ts.fileExtensionIs(fileName, ".js"); + } + ts.isJavaScript = isJavaScript; + function isTsx(fileName) { + return ts.fileExtensionIs(fileName, ".tsx"); + } + ts.isTsx = isTsx; + function getExpandedCharCodes(input) { + var output = []; + var length = input.length; + for (var i = 0; i < length; i++) { + var charCode = input.charCodeAt(i); + if (charCode < 0x80) { + output.push(charCode); + } + else if (charCode < 0x800) { + output.push((charCode >> 6) | 192); + output.push((charCode & 63) | 128); + } + else if (charCode < 0x10000) { + output.push((charCode >> 12) | 224); + output.push(((charCode >> 6) & 63) | 128); + output.push((charCode & 63) | 128); + } + else if (charCode < 0x20000) { + output.push((charCode >> 18) | 240); + output.push(((charCode >> 12) & 63) | 128); + output.push(((charCode >> 6) & 63) | 128); + output.push((charCode & 63) | 128); + } + else { + ts.Debug.assert(false, "Unexpected code point"); + } + } + return output; + } + var base64Digits = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="; + function convertToBase64(input) { + var result = ""; + var charCodes = getExpandedCharCodes(input); + var i = 0; + var length = charCodes.length; + var byte1, byte2, byte3, byte4; + while (i < length) { + byte1 = charCodes[i] >> 2; + byte2 = (charCodes[i] & 3) << 4 | charCodes[i + 1] >> 4; + byte3 = (charCodes[i + 1] & 15) << 2 | charCodes[i + 2] >> 6; + byte4 = charCodes[i + 2] & 63; + if (i + 1 >= length) { + byte3 = byte4 = 64; + } + else if (i + 2 >= length) { + byte4 = 64; + } + result += base64Digits.charAt(byte1) + base64Digits.charAt(byte2) + base64Digits.charAt(byte3) + base64Digits.charAt(byte4); + i += 3; + } + return result; + } + ts.convertToBase64 = convertToBase64; + var carriageReturnLineFeed = "\r\n"; + var lineFeed = "\n"; + function getNewLineCharacter(options) { + if (options.newLine === 0) { + return carriageReturnLineFeed; + } + else if (options.newLine === 1) { + return lineFeed; + } + else if (ts.sys) { + return ts.sys.newLine; + } + return carriageReturnLineFeed; + } + ts.getNewLineCharacter = getNewLineCharacter; +})(ts || (ts = {})); +var ts; +(function (ts) { + function getDefaultLibFileName(options) { + return options.target === 2 ? "lib.es6.d.ts" : "lib.d.ts"; + } + ts.getDefaultLibFileName = getDefaultLibFileName; + function textSpanEnd(span) { + return span.start + span.length; + } + ts.textSpanEnd = textSpanEnd; + function textSpanIsEmpty(span) { + return span.length === 0; + } + ts.textSpanIsEmpty = textSpanIsEmpty; + function textSpanContainsPosition(span, position) { + return position >= span.start && position < textSpanEnd(span); + } + ts.textSpanContainsPosition = textSpanContainsPosition; + function textSpanContainsTextSpan(span, other) { + return other.start >= span.start && textSpanEnd(other) <= textSpanEnd(span); + } + ts.textSpanContainsTextSpan = textSpanContainsTextSpan; + function textSpanOverlapsWith(span, other) { + var overlapStart = Math.max(span.start, other.start); + var overlapEnd = Math.min(textSpanEnd(span), textSpanEnd(other)); + return overlapStart < overlapEnd; + } + ts.textSpanOverlapsWith = textSpanOverlapsWith; + function textSpanOverlap(span1, span2) { + var overlapStart = Math.max(span1.start, span2.start); + var overlapEnd = Math.min(textSpanEnd(span1), textSpanEnd(span2)); + if (overlapStart < overlapEnd) { + return createTextSpanFromBounds(overlapStart, overlapEnd); + } + return undefined; + } + ts.textSpanOverlap = textSpanOverlap; + function textSpanIntersectsWithTextSpan(span, other) { + return other.start <= textSpanEnd(span) && textSpanEnd(other) >= span.start; + } + ts.textSpanIntersectsWithTextSpan = textSpanIntersectsWithTextSpan; + function textSpanIntersectsWith(span, start, length) { + var end = start + length; + return start <= textSpanEnd(span) && end >= span.start; + } + ts.textSpanIntersectsWith = textSpanIntersectsWith; + function decodedTextSpanIntersectsWith(start1, length1, start2, length2) { + var end1 = start1 + length1; + var end2 = start2 + length2; + return start2 <= end1 && end2 >= start1; + } + ts.decodedTextSpanIntersectsWith = decodedTextSpanIntersectsWith; + function textSpanIntersectsWithPosition(span, position) { + return position <= textSpanEnd(span) && position >= span.start; + } + ts.textSpanIntersectsWithPosition = textSpanIntersectsWithPosition; + function textSpanIntersection(span1, span2) { + var intersectStart = Math.max(span1.start, span2.start); + var intersectEnd = Math.min(textSpanEnd(span1), textSpanEnd(span2)); + if (intersectStart <= intersectEnd) { + return createTextSpanFromBounds(intersectStart, intersectEnd); + } + return undefined; + } + ts.textSpanIntersection = textSpanIntersection; + function createTextSpan(start, length) { + if (start < 0) { + throw new Error("start < 0"); + } + if (length < 0) { + throw new Error("length < 0"); + } + return { start: start, length: length }; + } + ts.createTextSpan = createTextSpan; + function createTextSpanFromBounds(start, end) { + return createTextSpan(start, end - start); + } + ts.createTextSpanFromBounds = createTextSpanFromBounds; + function textChangeRangeNewSpan(range) { + return createTextSpan(range.span.start, range.newLength); + } + ts.textChangeRangeNewSpan = textChangeRangeNewSpan; + function textChangeRangeIsUnchanged(range) { + return textSpanIsEmpty(range.span) && range.newLength === 0; + } + ts.textChangeRangeIsUnchanged = textChangeRangeIsUnchanged; + function createTextChangeRange(span, newLength) { + if (newLength < 0) { + throw new Error("newLength < 0"); + } + return { span: span, newLength: newLength }; + } + ts.createTextChangeRange = createTextChangeRange; + ts.unchangedTextChangeRange = createTextChangeRange(createTextSpan(0, 0), 0); + function collapseTextChangeRangesAcrossMultipleVersions(changes) { + if (changes.length === 0) { + return ts.unchangedTextChangeRange; + } + if (changes.length === 1) { + return changes[0]; + } + var change0 = changes[0]; + var oldStartN = change0.span.start; + var oldEndN = textSpanEnd(change0.span); + var newEndN = oldStartN + change0.newLength; + for (var i = 1; i < changes.length; i++) { + var nextChange = changes[i]; + var oldStart1 = oldStartN; + var oldEnd1 = oldEndN; + var newEnd1 = newEndN; + var oldStart2 = nextChange.span.start; + var oldEnd2 = textSpanEnd(nextChange.span); + var newEnd2 = oldStart2 + nextChange.newLength; + oldStartN = Math.min(oldStart1, oldStart2); + oldEndN = Math.max(oldEnd1, oldEnd1 + (oldEnd2 - newEnd1)); + newEndN = Math.max(newEnd2, newEnd2 + (newEnd1 - oldEnd2)); + } + return createTextChangeRange(createTextSpanFromBounds(oldStartN, oldEndN), newEndN - oldStartN); + } + ts.collapseTextChangeRangesAcrossMultipleVersions = collapseTextChangeRangesAcrossMultipleVersions; + function getTypeParameterOwner(d) { + if (d && d.kind === 137) { + for (var current = d; current; current = current.parent) { + if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 215) { + return current; + } + } + } + } + ts.getTypeParameterOwner = getTypeParameterOwner; +})(ts || (ts = {})); +var ts; +(function (ts) { + var nodeConstructors = new Array(272); + ts.parseTime = 0; + function getNodeConstructor(kind) { + return nodeConstructors[kind] || (nodeConstructors[kind] = ts.objectAllocator.getNodeConstructor(kind)); + } + ts.getNodeConstructor = getNodeConstructor; + function createNode(kind, pos, end) { + return new (getNodeConstructor(kind))(pos, end); + } + ts.createNode = createNode; + function visitNode(cbNode, node) { + if (node) { + return cbNode(node); + } + } + function visitNodeArray(cbNodes, nodes) { + if (nodes) { + return cbNodes(nodes); + } + } + function visitEachNode(cbNode, nodes) { + if (nodes) { + for (var _i = 0; _i < nodes.length; _i++) { + var node = nodes[_i]; + var result = cbNode(node); + if (result) { + return result; + } + } + } + } + function forEachChild(node, cbNode, cbNodeArray) { + if (!node) { + return; + } + var visitNodes = cbNodeArray ? visitNodeArray : visitEachNode; + var cbNodes = cbNodeArray || cbNode; + switch (node.kind) { + case 135: + return visitNode(cbNode, node.left) || + visitNode(cbNode, node.right); + case 137: + return visitNode(cbNode, node.name) || + visitNode(cbNode, node.constraint) || + visitNode(cbNode, node.expression); + case 246: + return visitNodes(cbNodes, node.decorators) || + visitNodes(cbNodes, node.modifiers) || + visitNode(cbNode, node.name) || + visitNode(cbNode, node.questionToken) || + visitNode(cbNode, node.equalsToken) || + visitNode(cbNode, node.objectAssignmentInitializer); + case 138: + case 141: + case 140: + case 245: + case 211: + case 163: + return visitNodes(cbNodes, node.decorators) || + visitNodes(cbNodes, node.modifiers) || + visitNode(cbNode, node.propertyName) || + visitNode(cbNode, node.dotDotDotToken) || + visitNode(cbNode, node.name) || + visitNode(cbNode, node.questionToken) || + visitNode(cbNode, node.type) || + visitNode(cbNode, node.initializer); + case 152: + case 153: + case 147: + case 148: + case 149: + return visitNodes(cbNodes, node.decorators) || + visitNodes(cbNodes, node.modifiers) || + visitNodes(cbNodes, node.typeParameters) || + visitNodes(cbNodes, node.parameters) || + visitNode(cbNode, node.type); + case 143: + case 142: + case 144: + case 145: + case 146: + case 173: + case 213: + case 174: + return visitNodes(cbNodes, node.decorators) || + visitNodes(cbNodes, node.modifiers) || + visitNode(cbNode, node.asteriskToken) || + visitNode(cbNode, node.name) || + visitNode(cbNode, node.questionToken) || + visitNodes(cbNodes, node.typeParameters) || + visitNodes(cbNodes, node.parameters) || + visitNode(cbNode, node.type) || + visitNode(cbNode, node.equalsGreaterThanToken) || + visitNode(cbNode, node.body); + case 151: + return visitNode(cbNode, node.typeName) || + visitNodes(cbNodes, node.typeArguments); + case 150: + return visitNode(cbNode, node.parameterName) || + visitNode(cbNode, node.type); + case 154: + return visitNode(cbNode, node.exprName); + case 155: + return visitNodes(cbNodes, node.members); + case 156: + return visitNode(cbNode, node.elementType); + case 157: + return visitNodes(cbNodes, node.elementTypes); + case 158: + case 159: + return visitNodes(cbNodes, node.types); + case 160: + return visitNode(cbNode, node.type); + case 161: + case 162: + return visitNodes(cbNodes, node.elements); + case 164: + return visitNodes(cbNodes, node.elements); + case 165: + return visitNodes(cbNodes, node.properties); + case 166: + return visitNode(cbNode, node.expression) || + visitNode(cbNode, node.dotToken) || + visitNode(cbNode, node.name); + case 167: + return visitNode(cbNode, node.expression) || + visitNode(cbNode, node.argumentExpression); + case 168: + case 169: + return visitNode(cbNode, node.expression) || + visitNodes(cbNodes, node.typeArguments) || + visitNodes(cbNodes, node.arguments); + case 170: + return visitNode(cbNode, node.tag) || + visitNode(cbNode, node.template); + case 171: + return visitNode(cbNode, node.type) || + visitNode(cbNode, node.expression); + case 172: + return visitNode(cbNode, node.expression); + case 175: + return visitNode(cbNode, node.expression); + case 176: + return visitNode(cbNode, node.expression); + case 177: + return visitNode(cbNode, node.expression); + case 179: + return visitNode(cbNode, node.operand); + case 184: + return visitNode(cbNode, node.asteriskToken) || + visitNode(cbNode, node.expression); + case 178: + return visitNode(cbNode, node.expression); + case 180: + return visitNode(cbNode, node.operand); + case 181: + return visitNode(cbNode, node.left) || + visitNode(cbNode, node.operatorToken) || + visitNode(cbNode, node.right); + case 189: + return visitNode(cbNode, node.expression) || + visitNode(cbNode, node.type); + case 182: + return visitNode(cbNode, node.condition) || + visitNode(cbNode, node.questionToken) || + visitNode(cbNode, node.whenTrue) || + visitNode(cbNode, node.colonToken) || + visitNode(cbNode, node.whenFalse); + case 185: + return visitNode(cbNode, node.expression); + case 192: + case 219: + return visitNodes(cbNodes, node.statements); + case 248: + return visitNodes(cbNodes, node.statements) || + visitNode(cbNode, node.endOfFileToken); + case 193: + return visitNodes(cbNodes, node.decorators) || + visitNodes(cbNodes, node.modifiers) || + visitNode(cbNode, node.declarationList); + case 212: + return visitNodes(cbNodes, node.declarations); + case 195: + return visitNode(cbNode, node.expression); + case 196: + return visitNode(cbNode, node.expression) || + visitNode(cbNode, node.thenStatement) || + visitNode(cbNode, node.elseStatement); + case 197: + return visitNode(cbNode, node.statement) || + visitNode(cbNode, node.expression); + case 198: + return visitNode(cbNode, node.expression) || + visitNode(cbNode, node.statement); + case 199: + return visitNode(cbNode, node.initializer) || + visitNode(cbNode, node.condition) || + visitNode(cbNode, node.incrementor) || + visitNode(cbNode, node.statement); + case 200: + return visitNode(cbNode, node.initializer) || + visitNode(cbNode, node.expression) || + visitNode(cbNode, node.statement); + case 201: + return visitNode(cbNode, node.initializer) || + visitNode(cbNode, node.expression) || + visitNode(cbNode, node.statement); + case 202: + case 203: + return visitNode(cbNode, node.label); + case 204: + return visitNode(cbNode, node.expression); + case 205: + return visitNode(cbNode, node.expression) || + visitNode(cbNode, node.statement); + case 206: + return visitNode(cbNode, node.expression) || + visitNode(cbNode, node.caseBlock); + case 220: + return visitNodes(cbNodes, node.clauses); + case 241: + return visitNode(cbNode, node.expression) || + visitNodes(cbNodes, node.statements); + case 242: + return visitNodes(cbNodes, node.statements); + case 207: + return visitNode(cbNode, node.label) || + visitNode(cbNode, node.statement); + case 208: + return visitNode(cbNode, node.expression); + case 209: + return visitNode(cbNode, node.tryBlock) || + visitNode(cbNode, node.catchClause) || + visitNode(cbNode, node.finallyBlock); + case 244: + return visitNode(cbNode, node.variableDeclaration) || + visitNode(cbNode, node.block); + case 139: + return visitNode(cbNode, node.expression); + case 214: + case 186: + return visitNodes(cbNodes, node.decorators) || + visitNodes(cbNodes, node.modifiers) || + visitNode(cbNode, node.name) || + visitNodes(cbNodes, node.typeParameters) || + visitNodes(cbNodes, node.heritageClauses) || + visitNodes(cbNodes, node.members); + case 215: + return visitNodes(cbNodes, node.decorators) || + visitNodes(cbNodes, node.modifiers) || + visitNode(cbNode, node.name) || + visitNodes(cbNodes, node.typeParameters) || + visitNodes(cbNodes, node.heritageClauses) || + visitNodes(cbNodes, node.members); + case 216: + return visitNodes(cbNodes, node.decorators) || + visitNodes(cbNodes, node.modifiers) || + visitNode(cbNode, node.name) || + visitNodes(cbNodes, node.typeParameters) || + visitNode(cbNode, node.type); + case 217: + return visitNodes(cbNodes, node.decorators) || + visitNodes(cbNodes, node.modifiers) || + visitNode(cbNode, node.name) || + visitNodes(cbNodes, node.members); + case 247: + return visitNode(cbNode, node.name) || + visitNode(cbNode, node.initializer); + case 218: + return visitNodes(cbNodes, node.decorators) || + visitNodes(cbNodes, node.modifiers) || + visitNode(cbNode, node.name) || + visitNode(cbNode, node.body); + case 221: + return visitNodes(cbNodes, node.decorators) || + visitNodes(cbNodes, node.modifiers) || + visitNode(cbNode, node.name) || + visitNode(cbNode, node.moduleReference); + case 222: + return visitNodes(cbNodes, node.decorators) || + visitNodes(cbNodes, node.modifiers) || + visitNode(cbNode, node.importClause) || + visitNode(cbNode, node.moduleSpecifier); + case 223: + return visitNode(cbNode, node.name) || + visitNode(cbNode, node.namedBindings); + case 224: + return visitNode(cbNode, node.name); + case 225: + case 229: + return visitNodes(cbNodes, node.elements); + case 228: + return visitNodes(cbNodes, node.decorators) || + visitNodes(cbNodes, node.modifiers) || + visitNode(cbNode, node.exportClause) || + visitNode(cbNode, node.moduleSpecifier); + case 226: + case 230: + return visitNode(cbNode, node.propertyName) || + visitNode(cbNode, node.name); + case 227: + return visitNodes(cbNodes, node.decorators) || + visitNodes(cbNodes, node.modifiers) || + visitNode(cbNode, node.expression); + case 183: + return visitNode(cbNode, node.head) || visitNodes(cbNodes, node.templateSpans); + case 190: + return visitNode(cbNode, node.expression) || visitNode(cbNode, node.literal); + case 136: + return visitNode(cbNode, node.expression); + case 243: + return visitNodes(cbNodes, node.types); + case 188: + return visitNode(cbNode, node.expression) || + visitNodes(cbNodes, node.typeArguments); + case 232: + return visitNode(cbNode, node.expression); + case 231: + return visitNodes(cbNodes, node.decorators); + case 233: + return visitNode(cbNode, node.openingElement) || + visitNodes(cbNodes, node.children) || + visitNode(cbNode, node.closingElement); + case 234: + case 235: + return visitNode(cbNode, node.tagName) || + visitNodes(cbNodes, node.attributes); + case 238: + return visitNode(cbNode, node.name) || + visitNode(cbNode, node.initializer); + case 239: + return visitNode(cbNode, node.expression); + case 240: + return visitNode(cbNode, node.expression); + case 237: + return visitNode(cbNode, node.tagName); + case 249: + return visitNode(cbNode, node.type); + case 253: + return visitNodes(cbNodes, node.types); + case 254: + return visitNodes(cbNodes, node.types); + case 252: + return visitNode(cbNode, node.elementType); + case 256: + return visitNode(cbNode, node.type); + case 255: + return visitNode(cbNode, node.type); + case 257: + return visitNodes(cbNodes, node.members); + case 259: + return visitNode(cbNode, node.name) || + visitNodes(cbNodes, node.typeArguments); + case 260: + return visitNode(cbNode, node.type); + case 261: + return visitNodes(cbNodes, node.parameters) || + visitNode(cbNode, node.type); + case 262: + return visitNode(cbNode, node.type); + case 263: + return visitNode(cbNode, node.type); + case 264: + return visitNode(cbNode, node.type); + case 258: + return visitNode(cbNode, node.name) || + visitNode(cbNode, node.type); + case 265: + return visitNodes(cbNodes, node.tags); + case 267: + return visitNode(cbNode, node.preParameterName) || + visitNode(cbNode, node.typeExpression) || + visitNode(cbNode, node.postParameterName); + case 268: + return visitNode(cbNode, node.typeExpression); + case 269: + return visitNode(cbNode, node.typeExpression); + case 270: + return visitNodes(cbNodes, node.typeParameters); + } + } + ts.forEachChild = forEachChild; + function createSourceFile(fileName, sourceText, languageVersion, setParentNodes) { + if (setParentNodes === void 0) { setParentNodes = false; } + var start = new Date().getTime(); + var result = Parser.parseSourceFile(fileName, sourceText, languageVersion, undefined, setParentNodes); + ts.parseTime += new Date().getTime() - start; + return result; + } + ts.createSourceFile = createSourceFile; + function updateSourceFile(sourceFile, newText, textChangeRange, aggressiveChecks) { + return IncrementalParser.updateSourceFile(sourceFile, newText, textChangeRange, aggressiveChecks); + } + ts.updateSourceFile = updateSourceFile; + function parseIsolatedJSDocComment(content, start, length) { + return Parser.JSDocParser.parseIsolatedJSDocComment(content, start, length); + } + ts.parseIsolatedJSDocComment = parseIsolatedJSDocComment; + function parseJSDocTypeExpressionForTests(content, start, length) { + return Parser.JSDocParser.parseJSDocTypeExpressionForTests(content, start, length); + } + ts.parseJSDocTypeExpressionForTests = parseJSDocTypeExpressionForTests; + var Parser; + (function (Parser) { + var scanner = ts.createScanner(2, true); + var disallowInAndDecoratorContext = 1 | 4; + var sourceFile; + var parseDiagnostics; + var syntaxCursor; + var token; + var sourceText; + var nodeCount; + var identifiers; + var identifierCount; + var parsingContext; + var contextFlags; + var parseErrorBeforeNextFinishedNode = false; + function parseSourceFile(fileName, _sourceText, languageVersion, _syntaxCursor, setParentNodes) { + initializeState(fileName, _sourceText, languageVersion, _syntaxCursor); + var result = parseSourceFileWorker(fileName, languageVersion, setParentNodes); + clearState(); + return result; + } + Parser.parseSourceFile = parseSourceFile; + function initializeState(fileName, _sourceText, languageVersion, _syntaxCursor) { + sourceText = _sourceText; + syntaxCursor = _syntaxCursor; + parseDiagnostics = []; + parsingContext = 0; + identifiers = {}; + identifierCount = 0; + nodeCount = 0; + contextFlags = ts.isJavaScript(fileName) ? 32 : 0; + parseErrorBeforeNextFinishedNode = false; + scanner.setText(sourceText); + scanner.setOnError(scanError); + scanner.setScriptTarget(languageVersion); + scanner.setLanguageVariant(ts.isTsx(fileName) ? 1 : 0); + } + function clearState() { + scanner.setText(""); + scanner.setOnError(undefined); + parseDiagnostics = undefined; + sourceFile = undefined; + identifiers = undefined; + syntaxCursor = undefined; + sourceText = undefined; + } + function parseSourceFileWorker(fileName, languageVersion, setParentNodes) { + sourceFile = createSourceFile(fileName, languageVersion); + token = nextToken(); + processReferenceComments(sourceFile); + sourceFile.statements = parseList(0, parseStatement); + ts.Debug.assert(token === 1); + sourceFile.endOfFileToken = parseTokenNode(); + setExternalModuleIndicator(sourceFile); + sourceFile.nodeCount = nodeCount; + sourceFile.identifierCount = identifierCount; + sourceFile.identifiers = identifiers; + sourceFile.parseDiagnostics = parseDiagnostics; + if (setParentNodes) { + fixupParentReferences(sourceFile); + } + if (ts.isJavaScript(fileName)) { + addJSDocComments(); + } + return sourceFile; + } + function addJSDocComments() { + forEachChild(sourceFile, visit); + return; + function visit(node) { + switch (node.kind) { + case 193: + case 213: + case 138: + addJSDocComment(node); + } + forEachChild(node, visit); + } + } + function addJSDocComment(node) { + var comments = ts.getLeadingCommentRangesOfNode(node, sourceFile); + if (comments) { + for (var _i = 0; _i < comments.length; _i++) { + var comment = comments[_i]; + var jsDocComment = JSDocParser.parseJSDocComment(node, comment.pos, comment.end - comment.pos); + if (jsDocComment) { + node.jsDocComment = jsDocComment; + } + } + } + } + function fixupParentReferences(sourceFile) { + var parent = sourceFile; + forEachChild(sourceFile, visitNode); + return; + function visitNode(n) { + if (n.parent !== parent) { + n.parent = parent; + var saveParent = parent; + parent = n; + forEachChild(n, visitNode); + parent = saveParent; + } + } + } + Parser.fixupParentReferences = fixupParentReferences; + function createSourceFile(fileName, languageVersion) { + var sourceFile = createNode(248, 0); + sourceFile.pos = 0; + sourceFile.end = sourceText.length; + sourceFile.text = sourceText; + sourceFile.bindDiagnostics = []; + sourceFile.languageVersion = languageVersion; + sourceFile.fileName = ts.normalizePath(fileName); + sourceFile.flags = ts.fileExtensionIs(sourceFile.fileName, ".d.ts") ? 8192 : 0; + sourceFile.languageVariant = ts.isTsx(sourceFile.fileName) ? 1 : 0; + return sourceFile; + } + function setContextFlag(val, flag) { + if (val) { + contextFlags |= flag; + } + else { + contextFlags &= ~flag; + } + } + function setDisallowInContext(val) { + setContextFlag(val, 1); + } + function setYieldContext(val) { + setContextFlag(val, 2); + } + function setDecoratorContext(val) { + setContextFlag(val, 4); + } + function setAwaitContext(val) { + setContextFlag(val, 8); + } + function doOutsideOfContext(context, func) { + var contextFlagsToClear = context & contextFlags; + if (contextFlagsToClear) { + setContextFlag(false, contextFlagsToClear); + var result = func(); + setContextFlag(true, contextFlagsToClear); + return result; + } + return func(); + } + function doInsideOfContext(context, func) { + var contextFlagsToSet = context & ~contextFlags; + if (contextFlagsToSet) { + setContextFlag(true, contextFlagsToSet); + var result = func(); + setContextFlag(false, contextFlagsToSet); + return result; + } + return func(); + } + function allowInAnd(func) { + return doOutsideOfContext(1, func); + } + function disallowInAnd(func) { + return doInsideOfContext(1, func); + } + function doInYieldContext(func) { + return doInsideOfContext(2, func); + } + function doOutsideOfYieldContext(func) { + return doOutsideOfContext(2, func); + } + function doInDecoratorContext(func) { + return doInsideOfContext(4, func); + } + function doInAwaitContext(func) { + return doInsideOfContext(8, func); + } + function doOutsideOfAwaitContext(func) { + return doOutsideOfContext(8, func); + } + function doInYieldAndAwaitContext(func) { + return doInsideOfContext(2 | 8, func); + } + function doOutsideOfYieldAndAwaitContext(func) { + return doOutsideOfContext(2 | 8, func); + } + function inContext(flags) { + return (contextFlags & flags) !== 0; + } + function inYieldContext() { + return inContext(2); + } + function inDisallowInContext() { + return inContext(1); + } + function inDecoratorContext() { + return inContext(4); + } + function inAwaitContext() { + return inContext(8); + } + function parseErrorAtCurrentToken(message, arg0) { + var start = scanner.getTokenPos(); + var length = scanner.getTextPos() - start; + parseErrorAtPosition(start, length, message, arg0); + } + function parseErrorAtPosition(start, length, message, arg0) { + var lastError = ts.lastOrUndefined(parseDiagnostics); + if (!lastError || start !== lastError.start) { + parseDiagnostics.push(ts.createFileDiagnostic(sourceFile, start, length, message, arg0)); + } + parseErrorBeforeNextFinishedNode = true; + } + function scanError(message, length) { + var pos = scanner.getTextPos(); + parseErrorAtPosition(pos, length || 0, message); + } + function getNodePos() { + return scanner.getStartPos(); + } + function getNodeEnd() { + return scanner.getStartPos(); + } + function nextToken() { + return token = scanner.scan(); + } + function getTokenPos(pos) { + return ts.skipTrivia(sourceText, pos); + } + function reScanGreaterToken() { + return token = scanner.reScanGreaterToken(); + } + function reScanSlashToken() { + return token = scanner.reScanSlashToken(); + } + function reScanTemplateToken() { + return token = scanner.reScanTemplateToken(); + } + function scanJsxIdentifier() { + return token = scanner.scanJsxIdentifier(); + } + function scanJsxText() { + return token = scanner.scanJsxToken(); + } + function speculationHelper(callback, isLookAhead) { + var saveToken = token; + var saveParseDiagnosticsLength = parseDiagnostics.length; + var saveParseErrorBeforeNextFinishedNode = parseErrorBeforeNextFinishedNode; + var saveContextFlags = contextFlags; + var result = isLookAhead + ? scanner.lookAhead(callback) + : scanner.tryScan(callback); + ts.Debug.assert(saveContextFlags === contextFlags); + if (!result || isLookAhead) { + token = saveToken; + parseDiagnostics.length = saveParseDiagnosticsLength; + parseErrorBeforeNextFinishedNode = saveParseErrorBeforeNextFinishedNode; + } + return result; + } + function lookAhead(callback) { + return speculationHelper(callback, true); + } + function tryParse(callback) { + return speculationHelper(callback, false); + } + function isIdentifier() { + if (token === 69) { + return true; + } + if (token === 114 && inYieldContext()) { + return false; + } + if (token === 119 && inAwaitContext()) { + return false; + } + return token > 105; + } + function parseExpected(kind, diagnosticMessage, shouldAdvance) { + if (shouldAdvance === void 0) { shouldAdvance = true; } + if (token === kind) { + if (shouldAdvance) { + nextToken(); + } + return true; + } + if (diagnosticMessage) { + parseErrorAtCurrentToken(diagnosticMessage); + } + else { + parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(kind)); + } + return false; + } + function parseOptional(t) { + if (token === t) { + nextToken(); + return true; + } + return false; + } + function parseOptionalToken(t) { + if (token === t) { + return parseTokenNode(); + } + return undefined; + } + function parseExpectedToken(t, reportAtCurrentPosition, diagnosticMessage, arg0) { + return parseOptionalToken(t) || + createMissingNode(t, reportAtCurrentPosition, diagnosticMessage, arg0); + } + function parseTokenNode() { + var node = createNode(token); + nextToken(); + return finishNode(node); + } + function canParseSemicolon() { + if (token === 23) { + return true; + } + return token === 16 || token === 1 || scanner.hasPrecedingLineBreak(); + } + function parseSemicolon() { + if (canParseSemicolon()) { + if (token === 23) { + nextToken(); + } + return true; + } + else { + return parseExpected(23); + } + } + function createNode(kind, pos) { + nodeCount++; + if (!(pos >= 0)) { + pos = scanner.getStartPos(); + } + return new (nodeConstructors[kind] || (nodeConstructors[kind] = ts.objectAllocator.getNodeConstructor(kind)))(pos, pos); + } + function finishNode(node, end) { + node.end = end === undefined ? scanner.getStartPos() : end; + if (contextFlags) { + node.parserContextFlags = contextFlags; + } + if (parseErrorBeforeNextFinishedNode) { + parseErrorBeforeNextFinishedNode = false; + node.parserContextFlags |= 16; + } + return node; + } + function createMissingNode(kind, reportAtCurrentPosition, diagnosticMessage, arg0) { + if (reportAtCurrentPosition) { + parseErrorAtPosition(scanner.getStartPos(), 0, diagnosticMessage, arg0); + } + else { + parseErrorAtCurrentToken(diagnosticMessage, arg0); + } + var result = createNode(kind, scanner.getStartPos()); + result.text = ""; + return finishNode(result); + } + function internIdentifier(text) { + text = ts.escapeIdentifier(text); + return ts.hasProperty(identifiers, text) ? identifiers[text] : (identifiers[text] = text); + } + function createIdentifier(isIdentifier, diagnosticMessage) { + identifierCount++; + if (isIdentifier) { + var node = createNode(69); + if (token !== 69) { + node.originalKeywordKind = token; + } + node.text = internIdentifier(scanner.getTokenValue()); + nextToken(); + return finishNode(node); + } + return createMissingNode(69, false, diagnosticMessage || ts.Diagnostics.Identifier_expected); + } + function parseIdentifier(diagnosticMessage) { + return createIdentifier(isIdentifier(), diagnosticMessage); + } + function parseIdentifierName() { + return createIdentifier(ts.tokenIsIdentifierOrKeyword(token)); + } + function isLiteralPropertyName() { + return ts.tokenIsIdentifierOrKeyword(token) || + token === 9 || + token === 8; + } + function parsePropertyNameWorker(allowComputedPropertyNames) { + if (token === 9 || token === 8) { + return parseLiteralNode(true); + } + if (allowComputedPropertyNames && token === 19) { + return parseComputedPropertyName(); + } + return parseIdentifierName(); + } + function parsePropertyName() { + return parsePropertyNameWorker(true); + } + function parseSimplePropertyName() { + return parsePropertyNameWorker(false); + } + function isSimplePropertyName() { + return token === 9 || token === 8 || ts.tokenIsIdentifierOrKeyword(token); + } + function parseComputedPropertyName() { + var node = createNode(136); + parseExpected(19); + node.expression = allowInAnd(parseExpression); + parseExpected(20); + return finishNode(node); + } + function parseContextualModifier(t) { + return token === t && tryParse(nextTokenCanFollowModifier); + } + function nextTokenCanFollowModifier() { + if (token === 74) { + return nextToken() === 81; + } + if (token === 82) { + nextToken(); + if (token === 77) { + return lookAhead(nextTokenIsClassOrFunction); + } + return token !== 37 && token !== 15 && canFollowModifier(); + } + if (token === 77) { + return nextTokenIsClassOrFunction(); + } + if (token === 113) { + nextToken(); + return canFollowModifier(); + } + nextToken(); + if (scanner.hasPrecedingLineBreak()) { + return false; + } + return canFollowModifier(); + } + function parseAnyContextualModifier() { + return ts.isModifier(token) && tryParse(nextTokenCanFollowModifier); + } + function canFollowModifier() { + return token === 19 + || token === 15 + || token === 37 + || isLiteralPropertyName(); + } + function nextTokenIsClassOrFunction() { + nextToken(); + return token === 73 || token === 87; + } + function isListElement(parsingContext, inErrorRecovery) { + var node = currentNode(parsingContext); + if (node) { + return true; + } + switch (parsingContext) { + case 0: + case 1: + case 3: + return !(token === 23 && inErrorRecovery) && isStartOfStatement(); + case 2: + return token === 71 || token === 77; + case 4: + return isStartOfTypeMember(); + case 5: + return lookAhead(isClassMemberStart) || (token === 23 && !inErrorRecovery); + case 6: + return token === 19 || isLiteralPropertyName(); + case 12: + return token === 19 || token === 37 || isLiteralPropertyName(); + case 9: + return isLiteralPropertyName(); + case 7: + if (token === 15) { + return lookAhead(isValidHeritageClauseObjectLiteral); + } + if (!inErrorRecovery) { + return isStartOfLeftHandSideExpression() && !isHeritageClauseExtendsOrImplementsKeyword(); + } + else { + return isIdentifier() && !isHeritageClauseExtendsOrImplementsKeyword(); + } + case 8: + return isIdentifierOrPattern(); + case 10: + return token === 24 || token === 22 || isIdentifierOrPattern(); + case 17: + return isIdentifier(); + case 11: + case 15: + return token === 24 || token === 22 || isStartOfExpression(); + case 16: + return isStartOfParameter(); + case 18: + case 19: + return token === 24 || isStartOfType(); + case 20: + return isHeritageClause(); + case 21: + return ts.tokenIsIdentifierOrKeyword(token); + case 13: + return ts.tokenIsIdentifierOrKeyword(token) || token === 15; + case 14: + return true; + case 22: + case 23: + case 25: + return JSDocParser.isJSDocType(); + case 24: + return isSimplePropertyName(); + } + ts.Debug.fail("Non-exhaustive case in 'isListElement'."); + } + function isValidHeritageClauseObjectLiteral() { + ts.Debug.assert(token === 15); + if (nextToken() === 16) { + var next = nextToken(); + return next === 24 || next === 15 || next === 83 || next === 106; + } + return true; + } + function nextTokenIsIdentifier() { + nextToken(); + return isIdentifier(); + } + function nextTokenIsIdentifierOrKeyword() { + nextToken(); + return ts.tokenIsIdentifierOrKeyword(token); + } + function isHeritageClauseExtendsOrImplementsKeyword() { + if (token === 106 || + token === 83) { + return lookAhead(nextTokenIsStartOfExpression); + } + return false; + } + function nextTokenIsStartOfExpression() { + nextToken(); + return isStartOfExpression(); + } + function isListTerminator(kind) { + if (token === 1) { + return true; + } + switch (kind) { + case 1: + case 2: + case 4: + case 5: + case 6: + case 12: + case 9: + case 21: + return token === 16; + case 3: + return token === 16 || token === 71 || token === 77; + case 7: + return token === 15 || token === 83 || token === 106; + case 8: + return isVariableDeclaratorListTerminator(); + case 17: + return token === 27 || token === 17 || token === 15 || token === 83 || token === 106; + case 11: + return token === 18 || token === 23; + case 15: + case 19: + case 10: + return token === 20; + case 16: + return token === 18 || token === 20; + case 18: + return token === 27 || token === 17; + case 20: + return token === 15 || token === 16; + case 13: + return token === 27 || token === 39; + case 14: + return token === 25 && lookAhead(nextTokenIsSlash); + case 22: + return token === 18 || token === 54 || token === 16; + case 23: + return token === 27 || token === 16; + case 25: + return token === 20 || token === 16; + case 24: + return token === 16; + } + } + function isVariableDeclaratorListTerminator() { + if (canParseSemicolon()) { + return true; + } + if (isInOrOfKeyword(token)) { + return true; + } + if (token === 34) { + return true; + } + return false; + } + function isInSomeParsingContext() { + for (var kind = 0; kind < 26; kind++) { + if (parsingContext & (1 << kind)) { + if (isListElement(kind, true) || isListTerminator(kind)) { + return true; + } + } + } + return false; + } + function parseList(kind, parseElement) { + var saveParsingContext = parsingContext; + parsingContext |= 1 << kind; + var result = []; + result.pos = getNodePos(); + while (!isListTerminator(kind)) { + if (isListElement(kind, false)) { + var element = parseListElement(kind, parseElement); + result.push(element); + continue; + } + if (abortParsingListOrMoveToNextToken(kind)) { + break; + } + } + result.end = getNodeEnd(); + parsingContext = saveParsingContext; + return result; + } + function parseListElement(parsingContext, parseElement) { + var node = currentNode(parsingContext); + if (node) { + return consumeNode(node); + } + return parseElement(); + } + function currentNode(parsingContext) { + if (parseErrorBeforeNextFinishedNode) { + return undefined; + } + if (!syntaxCursor) { + return undefined; + } + var node = syntaxCursor.currentNode(scanner.getStartPos()); + if (ts.nodeIsMissing(node)) { + return undefined; + } + if (node.intersectsChange) { + return undefined; + } + if (ts.containsParseError(node)) { + return undefined; + } + var nodeContextFlags = node.parserContextFlags & 31; + if (nodeContextFlags !== contextFlags) { + return undefined; + } + if (!canReuseNode(node, parsingContext)) { + return undefined; + } + return node; + } + function consumeNode(node) { + scanner.setTextPos(node.end); + nextToken(); + return node; + } + function canReuseNode(node, parsingContext) { + switch (parsingContext) { + case 5: + return isReusableClassMember(node); + case 2: + return isReusableSwitchClause(node); + case 0: + case 1: + case 3: + return isReusableStatement(node); + case 6: + return isReusableEnumMember(node); + case 4: + return isReusableTypeMember(node); + case 8: + return isReusableVariableDeclaration(node); + case 16: + return isReusableParameter(node); + case 20: + case 17: + case 19: + case 18: + case 11: + case 12: + case 7: + case 13: + case 14: + } + return false; + } + function isReusableClassMember(node) { + if (node) { + switch (node.kind) { + case 144: + case 149: + case 145: + case 146: + case 141: + case 191: + return true; + case 143: + var methodDeclaration = node; + var nameIsConstructor = methodDeclaration.name.kind === 69 && + methodDeclaration.name.originalKeywordKind === 121; + return !nameIsConstructor; + } + } + return false; + } + function isReusableSwitchClause(node) { + if (node) { + switch (node.kind) { + case 241: + case 242: + return true; + } + } + return false; + } + function isReusableStatement(node) { + if (node) { + switch (node.kind) { + case 213: + case 193: + case 192: + case 196: + case 195: + case 208: + case 204: + case 206: + case 203: + case 202: + case 200: + case 201: + case 199: + case 198: + case 205: + case 194: + case 209: + case 207: + case 197: + case 210: + case 222: + case 221: + case 228: + case 227: + case 218: + case 214: + case 215: + case 217: + case 216: + return true; + } + } + return false; + } + function isReusableEnumMember(node) { + return node.kind === 247; + } + function isReusableTypeMember(node) { + if (node) { + switch (node.kind) { + case 148: + case 142: + case 149: + case 140: + case 147: + return true; + } + } + return false; + } + function isReusableVariableDeclaration(node) { + if (node.kind !== 211) { + return false; + } + var variableDeclarator = node; + return variableDeclarator.initializer === undefined; + } + function isReusableParameter(node) { + if (node.kind !== 138) { + return false; + } + var parameter = node; + return parameter.initializer === undefined; + } + function abortParsingListOrMoveToNextToken(kind) { + parseErrorAtCurrentToken(parsingContextErrors(kind)); + if (isInSomeParsingContext()) { + return true; + } + nextToken(); + return false; + } + function parsingContextErrors(context) { + switch (context) { + case 0: return ts.Diagnostics.Declaration_or_statement_expected; + case 1: return ts.Diagnostics.Declaration_or_statement_expected; + case 2: return ts.Diagnostics.case_or_default_expected; + case 3: return ts.Diagnostics.Statement_expected; + case 4: return ts.Diagnostics.Property_or_signature_expected; + case 5: return ts.Diagnostics.Unexpected_token_A_constructor_method_accessor_or_property_was_expected; + case 6: return ts.Diagnostics.Enum_member_expected; + case 7: return ts.Diagnostics.Expression_expected; + case 8: return ts.Diagnostics.Variable_declaration_expected; + case 9: return ts.Diagnostics.Property_destructuring_pattern_expected; + case 10: return ts.Diagnostics.Array_element_destructuring_pattern_expected; + case 11: return ts.Diagnostics.Argument_expression_expected; + case 12: return ts.Diagnostics.Property_assignment_expected; + case 15: return ts.Diagnostics.Expression_or_comma_expected; + case 16: return ts.Diagnostics.Parameter_declaration_expected; + case 17: return ts.Diagnostics.Type_parameter_declaration_expected; + case 18: return ts.Diagnostics.Type_argument_expected; + case 19: return ts.Diagnostics.Type_expected; + case 20: return ts.Diagnostics.Unexpected_token_expected; + case 21: return ts.Diagnostics.Identifier_expected; + case 13: return ts.Diagnostics.Identifier_expected; + case 14: return ts.Diagnostics.Identifier_expected; + case 22: return ts.Diagnostics.Parameter_declaration_expected; + case 23: return ts.Diagnostics.Type_argument_expected; + case 25: return ts.Diagnostics.Type_expected; + case 24: return ts.Diagnostics.Property_assignment_expected; + } + } + ; + function parseDelimitedList(kind, parseElement, considerSemicolonAsDelimeter) { + var saveParsingContext = parsingContext; + parsingContext |= 1 << kind; + var result = []; + result.pos = getNodePos(); + var commaStart = -1; + while (true) { + if (isListElement(kind, false)) { + result.push(parseListElement(kind, parseElement)); + commaStart = scanner.getTokenPos(); + if (parseOptional(24)) { + continue; + } + commaStart = -1; + if (isListTerminator(kind)) { + break; + } + parseExpected(24); + if (considerSemicolonAsDelimeter && token === 23 && !scanner.hasPrecedingLineBreak()) { + nextToken(); + } + continue; + } + if (isListTerminator(kind)) { + break; + } + if (abortParsingListOrMoveToNextToken(kind)) { + break; + } + } + if (commaStart >= 0) { + result.hasTrailingComma = true; + } + result.end = getNodeEnd(); + parsingContext = saveParsingContext; + return result; + } + function createMissingList() { + var pos = getNodePos(); + var result = []; + result.pos = pos; + result.end = pos; + return result; + } + function parseBracketedList(kind, parseElement, open, close) { + if (parseExpected(open)) { + var result = parseDelimitedList(kind, parseElement); + parseExpected(close); + return result; + } + return createMissingList(); + } + function parseEntityName(allowReservedWords, diagnosticMessage) { + var entity = parseIdentifier(diagnosticMessage); + while (parseOptional(21)) { + var node = createNode(135, entity.pos); + node.left = entity; + node.right = parseRightSideOfDot(allowReservedWords); + entity = finishNode(node); + } + return entity; + } + function parseRightSideOfDot(allowIdentifierNames) { + if (scanner.hasPrecedingLineBreak() && ts.tokenIsIdentifierOrKeyword(token)) { + var matchesPattern = lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine); + if (matchesPattern) { + return createMissingNode(69, true, ts.Diagnostics.Identifier_expected); + } + } + return allowIdentifierNames ? parseIdentifierName() : parseIdentifier(); + } + function parseTemplateExpression() { + var template = createNode(183); + template.head = parseLiteralNode(); + ts.Debug.assert(template.head.kind === 12, "Template head has wrong token kind"); + var templateSpans = []; + templateSpans.pos = getNodePos(); + do { + templateSpans.push(parseTemplateSpan()); + } while (ts.lastOrUndefined(templateSpans).literal.kind === 13); + templateSpans.end = getNodeEnd(); + template.templateSpans = templateSpans; + return finishNode(template); + } + function parseTemplateSpan() { + var span = createNode(190); + span.expression = allowInAnd(parseExpression); + var literal; + if (token === 16) { + reScanTemplateToken(); + literal = parseLiteralNode(); + } + else { + literal = parseExpectedToken(14, false, ts.Diagnostics._0_expected, ts.tokenToString(16)); + } + span.literal = literal; + return finishNode(span); + } + function parseLiteralNode(internName) { + var node = createNode(token); + var text = scanner.getTokenValue(); + node.text = internName ? internIdentifier(text) : text; + if (scanner.hasExtendedUnicodeEscape()) { + node.hasExtendedUnicodeEscape = true; + } + if (scanner.isUnterminated()) { + node.isUnterminated = true; + } + var tokenPos = scanner.getTokenPos(); + nextToken(); + finishNode(node); + if (node.kind === 8 + && sourceText.charCodeAt(tokenPos) === 48 + && ts.isOctalDigit(sourceText.charCodeAt(tokenPos + 1))) { + node.flags |= 65536; + } + return node; + } + function parseTypeReferenceOrTypePredicate() { + var typeName = parseEntityName(false, ts.Diagnostics.Type_expected); + if (typeName.kind === 69 && token === 124 && !scanner.hasPrecedingLineBreak()) { + nextToken(); + var node_1 = createNode(150, typeName.pos); + node_1.parameterName = typeName; + node_1.type = parseType(); + return finishNode(node_1); + } + var node = createNode(151, typeName.pos); + node.typeName = typeName; + if (!scanner.hasPrecedingLineBreak() && token === 25) { + node.typeArguments = parseBracketedList(18, parseType, 25, 27); + } + return finishNode(node); + } + function parseTypeQuery() { + var node = createNode(154); + parseExpected(101); + node.exprName = parseEntityName(true); + return finishNode(node); + } + function parseTypeParameter() { + var node = createNode(137); + node.name = parseIdentifier(); + if (parseOptional(83)) { + if (isStartOfType() || !isStartOfExpression()) { + node.constraint = parseType(); + } + else { + node.expression = parseUnaryExpressionOrHigher(); + } + } + return finishNode(node); + } + function parseTypeParameters() { + if (token === 25) { + return parseBracketedList(17, parseTypeParameter, 25, 27); + } + } + function parseParameterType() { + if (parseOptional(54)) { + return token === 9 + ? parseLiteralNode(true) + : parseType(); + } + return undefined; + } + function isStartOfParameter() { + return token === 22 || isIdentifierOrPattern() || ts.isModifier(token) || token === 55; + } + function setModifiers(node, modifiers) { + if (modifiers) { + node.flags |= modifiers.flags; + node.modifiers = modifiers; + } + } + function parseParameter() { + var node = createNode(138); + node.decorators = parseDecorators(); + setModifiers(node, parseModifiers()); + node.dotDotDotToken = parseOptionalToken(22); + node.name = parseIdentifierOrPattern(); + if (ts.getFullWidth(node.name) === 0 && node.flags === 0 && ts.isModifier(token)) { + nextToken(); + } + node.questionToken = parseOptionalToken(53); + node.type = parseParameterType(); + node.initializer = parseBindingElementInitializer(true); + return finishNode(node); + } + function parseBindingElementInitializer(inParameter) { + return inParameter ? parseParameterInitializer() : parseNonParameterInitializer(); + } + function parseParameterInitializer() { + return parseInitializer(true); + } + function fillSignature(returnToken, yieldContext, awaitContext, requireCompleteParameterList, signature) { + var returnTokenRequired = returnToken === 34; + signature.typeParameters = parseTypeParameters(); + signature.parameters = parseParameterList(yieldContext, awaitContext, requireCompleteParameterList); + if (returnTokenRequired) { + parseExpected(returnToken); + signature.type = parseType(); + } + else if (parseOptional(returnToken)) { + signature.type = parseType(); + } + } + function parseParameterList(yieldContext, awaitContext, requireCompleteParameterList) { + if (parseExpected(17)) { + var savedYieldContext = inYieldContext(); + var savedAwaitContext = inAwaitContext(); + setYieldContext(yieldContext); + setAwaitContext(awaitContext); + var result = parseDelimitedList(16, parseParameter); + setYieldContext(savedYieldContext); + setAwaitContext(savedAwaitContext); + if (!parseExpected(18) && requireCompleteParameterList) { + return undefined; + } + return result; + } + return requireCompleteParameterList ? undefined : createMissingList(); + } + function parseTypeMemberSemicolon() { + if (parseOptional(24)) { + return; + } + parseSemicolon(); + } + function parseSignatureMember(kind) { + var node = createNode(kind); + if (kind === 148) { + parseExpected(92); + } + fillSignature(54, false, false, false, node); + parseTypeMemberSemicolon(); + return finishNode(node); + } + function isIndexSignature() { + if (token !== 19) { + return false; + } + return lookAhead(isUnambiguouslyIndexSignature); + } + function isUnambiguouslyIndexSignature() { + nextToken(); + if (token === 22 || token === 20) { + return true; + } + if (ts.isModifier(token)) { + nextToken(); + if (isIdentifier()) { + return true; + } + } + else if (!isIdentifier()) { + return false; + } + else { + nextToken(); + } + if (token === 54 || token === 24) { + return true; + } + if (token !== 53) { + return false; + } + nextToken(); + return token === 54 || token === 24 || token === 20; + } + function parseIndexSignatureDeclaration(fullStart, decorators, modifiers) { + var node = createNode(149, fullStart); + node.decorators = decorators; + setModifiers(node, modifiers); + node.parameters = parseBracketedList(16, parseParameter, 19, 20); + node.type = parseTypeAnnotation(); + parseTypeMemberSemicolon(); + return finishNode(node); + } + function parsePropertyOrMethodSignature() { + var fullStart = scanner.getStartPos(); + var name = parsePropertyName(); + var questionToken = parseOptionalToken(53); + if (token === 17 || token === 25) { + var method = createNode(142, fullStart); + method.name = name; + method.questionToken = questionToken; + fillSignature(54, false, false, false, method); + parseTypeMemberSemicolon(); + return finishNode(method); + } + else { + var property = createNode(140, fullStart); + property.name = name; + property.questionToken = questionToken; + property.type = parseTypeAnnotation(); + parseTypeMemberSemicolon(); + return finishNode(property); + } + } + function isStartOfTypeMember() { + switch (token) { + case 17: + case 25: + case 19: + return true; + default: + if (ts.isModifier(token)) { + var result = lookAhead(isStartOfIndexSignatureDeclaration); + if (result) { + return result; + } + } + return isLiteralPropertyName() && lookAhead(isTypeMemberWithLiteralPropertyName); + } + } + function isStartOfIndexSignatureDeclaration() { + while (ts.isModifier(token)) { + nextToken(); + } + return isIndexSignature(); + } + function isTypeMemberWithLiteralPropertyName() { + nextToken(); + return token === 17 || + token === 25 || + token === 53 || + token === 54 || + canParseSemicolon(); + } + function parseTypeMember() { + switch (token) { + case 17: + case 25: + return parseSignatureMember(147); + case 19: + return isIndexSignature() + ? parseIndexSignatureDeclaration(scanner.getStartPos(), undefined, undefined) + : parsePropertyOrMethodSignature(); + case 92: + if (lookAhead(isStartOfConstructSignature)) { + return parseSignatureMember(148); + } + case 9: + case 8: + return parsePropertyOrMethodSignature(); + default: + if (ts.isModifier(token)) { + var result = tryParse(parseIndexSignatureWithModifiers); + if (result) { + return result; + } + } + if (ts.tokenIsIdentifierOrKeyword(token)) { + return parsePropertyOrMethodSignature(); + } + } + } + function parseIndexSignatureWithModifiers() { + var fullStart = scanner.getStartPos(); + var decorators = parseDecorators(); + var modifiers = parseModifiers(); + return isIndexSignature() + ? parseIndexSignatureDeclaration(fullStart, decorators, modifiers) + : undefined; + } + function isStartOfConstructSignature() { + nextToken(); + return token === 17 || token === 25; + } + function parseTypeLiteral() { + var node = createNode(155); + node.members = parseObjectTypeMembers(); + return finishNode(node); + } + function parseObjectTypeMembers() { + var members; + if (parseExpected(15)) { + members = parseList(4, parseTypeMember); + parseExpected(16); + } + else { + members = createMissingList(); + } + return members; + } + function parseTupleType() { + var node = createNode(157); + node.elementTypes = parseBracketedList(19, parseType, 19, 20); + return finishNode(node); + } + function parseParenthesizedType() { + var node = createNode(160); + parseExpected(17); + node.type = parseType(); + parseExpected(18); + return finishNode(node); + } + function parseFunctionOrConstructorType(kind) { + var node = createNode(kind); + if (kind === 153) { + parseExpected(92); + } + fillSignature(34, false, false, false, node); + return finishNode(node); + } + function parseKeywordAndNoDot() { + var node = parseTokenNode(); + return token === 21 ? undefined : node; + } + function parseNonArrayType() { + switch (token) { + case 117: + case 130: + case 128: + case 120: + case 131: + var node = tryParse(parseKeywordAndNoDot); + return node || parseTypeReferenceOrTypePredicate(); + case 103: + case 97: + return parseTokenNode(); + case 101: + return parseTypeQuery(); + case 15: + return parseTypeLiteral(); + case 19: + return parseTupleType(); + case 17: + return parseParenthesizedType(); + default: + return parseTypeReferenceOrTypePredicate(); + } + } + function isStartOfType() { + switch (token) { + case 117: + case 130: + case 128: + case 120: + case 131: + case 103: + case 97: + case 101: + case 15: + case 19: + case 25: + case 92: + return true; + case 17: + return lookAhead(isStartOfParenthesizedOrFunctionType); + default: + return isIdentifier(); + } + } + function isStartOfParenthesizedOrFunctionType() { + nextToken(); + return token === 18 || isStartOfParameter() || isStartOfType(); + } + function parseArrayTypeOrHigher() { + var type = parseNonArrayType(); + while (!scanner.hasPrecedingLineBreak() && parseOptional(19)) { + parseExpected(20); + var node = createNode(156, type.pos); + node.elementType = type; + type = finishNode(node); + } + return type; + } + function parseUnionOrIntersectionType(kind, parseConstituentType, operator) { + var type = parseConstituentType(); + if (token === operator) { + var types = [type]; + types.pos = type.pos; + while (parseOptional(operator)) { + types.push(parseConstituentType()); + } + types.end = getNodeEnd(); + var node = createNode(kind, type.pos); + node.types = types; + type = finishNode(node); + } + return type; + } + function parseIntersectionTypeOrHigher() { + return parseUnionOrIntersectionType(159, parseArrayTypeOrHigher, 46); + } + function parseUnionTypeOrHigher() { + return parseUnionOrIntersectionType(158, parseIntersectionTypeOrHigher, 47); + } + function isStartOfFunctionType() { + if (token === 25) { + return true; + } + return token === 17 && lookAhead(isUnambiguouslyStartOfFunctionType); + } + function isUnambiguouslyStartOfFunctionType() { + nextToken(); + if (token === 18 || token === 22) { + return true; + } + if (isIdentifier() || ts.isModifier(token)) { + nextToken(); + if (token === 54 || token === 24 || + token === 53 || token === 56 || + isIdentifier() || ts.isModifier(token)) { + return true; + } + if (token === 18) { + nextToken(); + if (token === 34) { + return true; + } + } + } + return false; + } + function parseType() { + return doOutsideOfContext(10, parseTypeWorker); + } + function parseTypeWorker() { + if (isStartOfFunctionType()) { + return parseFunctionOrConstructorType(152); + } + if (token === 92) { + return parseFunctionOrConstructorType(153); + } + return parseUnionTypeOrHigher(); + } + function parseTypeAnnotation() { + return parseOptional(54) ? parseType() : undefined; + } + function isStartOfLeftHandSideExpression() { + switch (token) { + case 97: + case 95: + case 93: + case 99: + case 84: + 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: + return true; + default: + return isIdentifier(); + } + } + function isStartOfExpression() { + if (isStartOfLeftHandSideExpression()) { + return true; + } + switch (token) { + case 35: + case 36: + case 50: + case 49: + case 78: + case 101: + case 103: + case 41: + case 42: + case 25: + case 119: + case 114: + return true; + default: + if (isBinaryOperator()) { + return true; + } + return isIdentifier(); + } + } + function isStartOfExpressionStatement() { + return token !== 15 && + token !== 87 && + token !== 73 && + token !== 55 && + isStartOfExpression(); + } + function allowInAndParseExpression() { + return allowInAnd(parseExpression); + } + function parseExpression() { + var saveDecoratorContext = inDecoratorContext(); + if (saveDecoratorContext) { + setDecoratorContext(false); + } + var expr = parseAssignmentExpressionOrHigher(); + var operatorToken; + while ((operatorToken = parseOptionalToken(24))) { + expr = makeBinaryExpression(expr, operatorToken, parseAssignmentExpressionOrHigher()); + } + if (saveDecoratorContext) { + setDecoratorContext(true); + } + return expr; + } + function parseInitializer(inParameter) { + if (token !== 56) { + if (scanner.hasPrecedingLineBreak() || (inParameter && token === 15) || !isStartOfExpression()) { + return undefined; + } + } + parseExpected(56); + return parseAssignmentExpressionOrHigher(); + } + function parseAssignmentExpressionOrHigher() { + if (isYieldExpression()) { + return parseYieldExpression(); + } + var arrowExpression = tryParseParenthesizedArrowFunctionExpression(); + if (arrowExpression) { + return arrowExpression; + } + var expr = parseBinaryExpressionOrHigher(0); + if (expr.kind === 69 && token === 34) { + return parseSimpleArrowFunctionExpression(expr); + } + if (ts.isLeftHandSideExpression(expr) && ts.isAssignmentOperator(reScanGreaterToken())) { + return makeBinaryExpression(expr, parseTokenNode(), parseAssignmentExpressionOrHigher()); + } + return parseConditionalExpressionRest(expr); + } + function isYieldExpression() { + if (token === 114) { + if (inYieldContext()) { + return true; + } + return lookAhead(nextTokenIsIdentifierOrKeywordOrNumberOnSameLine); + } + return false; + } + function nextTokenIsIdentifierOnSameLine() { + nextToken(); + return !scanner.hasPrecedingLineBreak() && isIdentifier(); + } + function parseYieldExpression() { + var node = createNode(184); + nextToken(); + if (!scanner.hasPrecedingLineBreak() && + (token === 37 || isStartOfExpression())) { + node.asteriskToken = parseOptionalToken(37); + node.expression = parseAssignmentExpressionOrHigher(); + return finishNode(node); + } + else { + return finishNode(node); + } + } + function parseSimpleArrowFunctionExpression(identifier) { + ts.Debug.assert(token === 34, "parseSimpleArrowFunctionExpression should only have been called if we had a =>"); + var node = createNode(174, identifier.pos); + var parameter = createNode(138, identifier.pos); + parameter.name = identifier; + finishNode(parameter); + node.parameters = [parameter]; + node.parameters.pos = parameter.pos; + node.parameters.end = parameter.end; + node.equalsGreaterThanToken = parseExpectedToken(34, false, ts.Diagnostics._0_expected, "=>"); + node.body = parseArrowFunctionExpressionBody(false); + return finishNode(node); + } + function tryParseParenthesizedArrowFunctionExpression() { + var triState = isParenthesizedArrowFunctionExpression(); + if (triState === 0) { + return undefined; + } + var arrowFunction = triState === 1 + ? parseParenthesizedArrowFunctionExpressionHead(true) + : tryParse(parsePossibleParenthesizedArrowFunctionExpressionHead); + if (!arrowFunction) { + return undefined; + } + var isAsync = !!(arrowFunction.flags & 512); + var lastToken = token; + arrowFunction.equalsGreaterThanToken = parseExpectedToken(34, false, ts.Diagnostics._0_expected, "=>"); + arrowFunction.body = (lastToken === 34 || lastToken === 15) + ? parseArrowFunctionExpressionBody(isAsync) + : parseIdentifier(); + return finishNode(arrowFunction); + } + function isParenthesizedArrowFunctionExpression() { + if (token === 17 || token === 25 || token === 118) { + return lookAhead(isParenthesizedArrowFunctionExpressionWorker); + } + if (token === 34) { + return 1; + } + return 0; + } + function isParenthesizedArrowFunctionExpressionWorker() { + if (token === 118) { + nextToken(); + if (scanner.hasPrecedingLineBreak()) { + return 0; + } + if (token !== 17 && token !== 25) { + return 0; + } + } + var first = token; + var second = nextToken(); + if (first === 17) { + if (second === 18) { + var third = nextToken(); + switch (third) { + case 34: + case 54: + case 15: + return 1; + default: + return 0; + } + } + if (second === 19 || second === 15) { + return 2; + } + if (second === 22) { + return 1; + } + if (!isIdentifier()) { + return 0; + } + if (nextToken() === 54) { + return 1; + } + return 2; + } + else { + ts.Debug.assert(first === 25); + if (!isIdentifier()) { + return 0; + } + if (sourceFile.languageVariant === 1) { + var isArrowFunctionInJsx = lookAhead(function () { + var third = nextToken(); + if (third === 83) { + var fourth = nextToken(); + switch (fourth) { + case 56: + case 27: + return false; + default: + return true; + } + } + else if (third === 24) { + return true; + } + return false; + }); + if (isArrowFunctionInJsx) { + return 1; + } + return 0; + } + return 2; + } + } + function parsePossibleParenthesizedArrowFunctionExpressionHead() { + return parseParenthesizedArrowFunctionExpressionHead(false); + } + function parseParenthesizedArrowFunctionExpressionHead(allowAmbiguity) { + var node = createNode(174); + setModifiers(node, parseModifiersForArrowFunction()); + var isAsync = !!(node.flags & 512); + fillSignature(54, false, isAsync, !allowAmbiguity, node); + if (!node.parameters) { + return undefined; + } + if (!allowAmbiguity && token !== 34 && token !== 15) { + return undefined; + } + return node; + } + function parseArrowFunctionExpressionBody(isAsync) { + if (token === 15) { + return parseFunctionBlock(false, isAsync, false); + } + if (token !== 23 && + token !== 87 && + token !== 73 && + isStartOfStatement() && + !isStartOfExpressionStatement()) { + return parseFunctionBlock(false, isAsync, true); + } + return isAsync + ? doInAwaitContext(parseAssignmentExpressionOrHigher) + : doOutsideOfAwaitContext(parseAssignmentExpressionOrHigher); + } + function parseConditionalExpressionRest(leftOperand) { + var questionToken = parseOptionalToken(53); + if (!questionToken) { + return leftOperand; + } + var node = createNode(182, 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.whenFalse = parseAssignmentExpressionOrHigher(); + return finishNode(node); + } + function parseBinaryExpressionOrHigher(precedence) { + var leftOperand = parseUnaryExpressionOrHigher(); + return parseBinaryExpressionRest(precedence, leftOperand); + } + function isInOrOfKeyword(t) { + return t === 90 || t === 134; + } + function parseBinaryExpressionRest(precedence, leftOperand) { + while (true) { + reScanGreaterToken(); + var newPrecedence = getBinaryOperatorPrecedence(); + var consumeCurrentOperator = token === 38 ? + newPrecedence >= precedence : + newPrecedence > precedence; + if (!consumeCurrentOperator) { + break; + } + if (token === 90 && inDisallowInContext()) { + break; + } + if (token === 116) { + if (scanner.hasPrecedingLineBreak()) { + break; + } + else { + nextToken(); + leftOperand = makeAsExpression(leftOperand, parseType()); + } + } + else { + leftOperand = makeBinaryExpression(leftOperand, parseTokenNode(), parseBinaryExpressionOrHigher(newPrecedence)); + } + } + return leftOperand; + } + function isBinaryOperator() { + if (inDisallowInContext() && token === 90) { + return false; + } + return getBinaryOperatorPrecedence() > 0; + } + function getBinaryOperatorPrecedence() { + switch (token) { + case 52: + return 1; + case 51: + return 2; + case 47: + return 3; + case 48: + return 4; + case 46: + return 5; + case 30: + case 31: + case 32: + case 33: + return 6; + case 25: + case 27: + case 28: + case 29: + case 91: + case 90: + case 116: + return 7; + case 43: + case 44: + case 45: + return 8; + case 35: + case 36: + return 9; + case 37: + case 39: + case 40: + return 10; + case 38: + return 11; + } + return -1; + } + function makeBinaryExpression(left, operatorToken, right) { + var node = createNode(181, left.pos); + node.left = left; + node.operatorToken = operatorToken; + node.right = right; + return finishNode(node); + } + function makeAsExpression(left, right) { + var node = createNode(189, left.pos); + node.expression = left; + node.type = right; + return finishNode(node); + } + function parsePrefixUnaryExpression() { + var node = createNode(179); + node.operator = token; + nextToken(); + node.operand = parseSimpleUnaryExpression(); + return finishNode(node); + } + function parseDeleteExpression() { + var node = createNode(175); + nextToken(); + node.expression = parseSimpleUnaryExpression(); + return finishNode(node); + } + function parseTypeOfExpression() { + var node = createNode(176); + nextToken(); + node.expression = parseSimpleUnaryExpression(); + return finishNode(node); + } + function parseVoidExpression() { + var node = createNode(177); + nextToken(); + node.expression = parseSimpleUnaryExpression(); + return finishNode(node); + } + function isAwaitExpression() { + if (token === 119) { + if (inAwaitContext()) { + return true; + } + return lookAhead(nextTokenIsIdentifierOnSameLine); + } + return false; + } + function parseAwaitExpression() { + var node = createNode(178); + nextToken(); + node.expression = parseSimpleUnaryExpression(); + return finishNode(node); + } + function parseUnaryExpressionOrHigher() { + if (isAwaitExpression()) { + return parseAwaitExpression(); + } + if (isIncrementExpression()) { + var incrementExpression = parseIncrementExpression(); + return token === 38 ? + parseBinaryExpressionRest(getBinaryOperatorPrecedence(), incrementExpression) : + incrementExpression; + } + var unaryOperator = token; + var simpleUnaryExpression = parseSimpleUnaryExpression(); + if (token === 38) { + var diagnostic; + var start = ts.skipTrivia(sourceText, simpleUnaryExpression.pos); + if (simpleUnaryExpression.kind === 171) { + parseErrorAtPosition(start, simpleUnaryExpression.end - start, ts.Diagnostics.A_type_assertion_expression_is_not_allowed_in_the_left_hand_side_of_an_exponentiation_expression_Consider_enclosing_the_expression_in_parentheses); + } + else { + parseErrorAtPosition(start, simpleUnaryExpression.end - start, ts.Diagnostics.An_unary_expression_with_the_0_operator_is_not_allowed_in_the_left_hand_side_of_an_exponentiation_expression_Consider_enclosing_the_expression_in_parentheses, ts.tokenToString(unaryOperator)); + } + } + return simpleUnaryExpression; + } + function parseSimpleUnaryExpression() { + switch (token) { + case 35: + case 36: + case 50: + case 49: + return parsePrefixUnaryExpression(); + case 78: + return parseDeleteExpression(); + case 101: + return parseTypeOfExpression(); + case 103: + return parseVoidExpression(); + case 25: + return parseTypeAssertion(); + default: + return parseIncrementExpression(); + } + } + function isIncrementExpression() { + switch (token) { + case 35: + case 36: + case 50: + case 49: + case 78: + case 101: + case 103: + return false; + case 25: + if (sourceFile.languageVariant !== 1) { + return false; + } + default: + return true; + } + } + function parseIncrementExpression() { + if (token === 41 || token === 42) { + var node = createNode(179); + node.operator = token; + nextToken(); + node.operand = parseLeftHandSideExpressionOrHigher(); + return finishNode(node); + } + else if (sourceFile.languageVariant === 1 && token === 25 && lookAhead(nextTokenIsIdentifierOrKeyword)) { + return parseJsxElementOrSelfClosingElement(true); + } + var expression = parseLeftHandSideExpressionOrHigher(); + ts.Debug.assert(ts.isLeftHandSideExpression(expression)); + if ((token === 41 || token === 42) && !scanner.hasPrecedingLineBreak()) { + var node = createNode(180, expression.pos); + node.operand = expression; + node.operator = token; + nextToken(); + return finishNode(node); + } + return expression; + } + function parseLeftHandSideExpressionOrHigher() { + var expression = token === 95 + ? parseSuperExpression() + : parseMemberExpressionOrHigher(); + return parseCallExpressionRest(expression); + } + function parseMemberExpressionOrHigher() { + var expression = parsePrimaryExpression(); + return parseMemberExpressionRest(expression); + } + function parseSuperExpression() { + var expression = parseTokenNode(); + if (token === 17 || token === 21 || token === 19) { + return expression; + } + var node = createNode(166, expression.pos); + node.expression = expression; + node.dotToken = parseExpectedToken(21, false, ts.Diagnostics.super_must_be_followed_by_an_argument_list_or_member_access); + node.name = parseRightSideOfDot(true); + return finishNode(node); + } + function parseJsxElementOrSelfClosingElement(inExpressionContext) { + var opening = parseJsxOpeningOrSelfClosingElement(inExpressionContext); + var result; + if (opening.kind === 235) { + var node = createNode(233, opening.pos); + node.openingElement = opening; + node.children = parseJsxChildren(node.openingElement.tagName); + node.closingElement = parseJsxClosingElement(inExpressionContext); + result = finishNode(node); + } + else { + ts.Debug.assert(opening.kind === 234); + result = opening; + } + if (inExpressionContext && token === 25) { + var invalidElement = tryParse(function () { return parseJsxElementOrSelfClosingElement(true); }); + if (invalidElement) { + parseErrorAtCurrentToken(ts.Diagnostics.JSX_expressions_must_have_one_parent_element); + var badNode = createNode(181, result.pos); + badNode.end = invalidElement.end; + badNode.left = result; + badNode.right = invalidElement; + badNode.operatorToken = createMissingNode(24, false, undefined); + badNode.operatorToken.pos = badNode.operatorToken.end = badNode.right.pos; + return badNode; + } + } + return result; + } + function parseJsxText() { + var node = createNode(236, scanner.getStartPos()); + token = scanner.scanJsxToken(); + return finishNode(node); + } + function parseJsxChild() { + switch (token) { + case 236: + return parseJsxText(); + case 15: + return parseJsxExpression(false); + case 25: + return parseJsxElementOrSelfClosingElement(false); + } + ts.Debug.fail("Unknown JSX child kind " + token); + } + function parseJsxChildren(openingTagName) { + var result = []; + result.pos = scanner.getStartPos(); + var saveParsingContext = parsingContext; + parsingContext |= 1 << 14; + while (true) { + token = scanner.reScanJsxToken(); + if (token === 26) { + break; + } + else if (token === 1) { + parseErrorAtCurrentToken(ts.Diagnostics.Expected_corresponding_JSX_closing_tag_for_0, ts.getTextOfNodeFromSourceText(sourceText, openingTagName)); + break; + } + result.push(parseJsxChild()); + } + result.end = scanner.getTokenPos(); + parsingContext = saveParsingContext; + return result; + } + function parseJsxOpeningOrSelfClosingElement(inExpressionContext) { + var fullStart = scanner.getStartPos(); + parseExpected(25); + var tagName = parseJsxElementName(); + var attributes = parseList(13, parseJsxAttribute); + var node; + if (token === 27) { + node = createNode(235, fullStart); + scanJsxText(); + } + else { + parseExpected(39); + if (inExpressionContext) { + parseExpected(27); + } + else { + parseExpected(27, undefined, false); + scanJsxText(); + } + node = createNode(234, fullStart); + } + node.tagName = tagName; + node.attributes = attributes; + return finishNode(node); + } + function parseJsxElementName() { + scanJsxIdentifier(); + var elementName = parseIdentifierName(); + while (parseOptional(21)) { + scanJsxIdentifier(); + var node = createNode(135, elementName.pos); + node.left = elementName; + node.right = parseIdentifierName(); + elementName = finishNode(node); + } + return elementName; + } + function parseJsxExpression(inExpressionContext) { + var node = createNode(240); + parseExpected(15); + if (token !== 16) { + node.expression = parseExpression(); + } + if (inExpressionContext) { + parseExpected(16); + } + else { + parseExpected(16, undefined, false); + scanJsxText(); + } + return finishNode(node); + } + function parseJsxAttribute() { + if (token === 15) { + return parseJsxSpreadAttribute(); + } + scanJsxIdentifier(); + var node = createNode(238); + node.name = parseIdentifierName(); + if (parseOptional(56)) { + switch (token) { + case 9: + node.initializer = parseLiteralNode(); + break; + default: + node.initializer = parseJsxExpression(true); + break; + } + } + return finishNode(node); + } + function parseJsxSpreadAttribute() { + var node = createNode(239); + parseExpected(15); + parseExpected(22); + node.expression = parseExpression(); + parseExpected(16); + return finishNode(node); + } + function parseJsxClosingElement(inExpressionContext) { + var node = createNode(237); + parseExpected(26); + node.tagName = parseJsxElementName(); + if (inExpressionContext) { + parseExpected(27); + } + else { + parseExpected(27, undefined, false); + scanJsxText(); + } + return finishNode(node); + } + function parseTypeAssertion() { + var node = createNode(171); + parseExpected(25); + node.type = parseType(); + parseExpected(27); + node.expression = parseSimpleUnaryExpression(); + return finishNode(node); + } + function parseMemberExpressionRest(expression) { + while (true) { + var dotToken = parseOptionalToken(21); + if (dotToken) { + var propertyAccess = createNode(166, expression.pos); + propertyAccess.expression = expression; + propertyAccess.dotToken = dotToken; + propertyAccess.name = parseRightSideOfDot(true); + expression = finishNode(propertyAccess); + continue; + } + if (!inDecoratorContext() && parseOptional(19)) { + var indexedAccess = createNode(167, expression.pos); + indexedAccess.expression = expression; + if (token !== 20) { + indexedAccess.argumentExpression = allowInAnd(parseExpression); + if (indexedAccess.argumentExpression.kind === 9 || indexedAccess.argumentExpression.kind === 8) { + var literal = indexedAccess.argumentExpression; + literal.text = internIdentifier(literal.text); + } + } + parseExpected(20); + expression = finishNode(indexedAccess); + continue; + } + if (token === 11 || token === 12) { + var tagExpression = createNode(170, expression.pos); + tagExpression.tag = expression; + tagExpression.template = token === 11 + ? parseLiteralNode() + : parseTemplateExpression(); + expression = finishNode(tagExpression); + continue; + } + return expression; + } + } + function parseCallExpressionRest(expression) { + while (true) { + expression = parseMemberExpressionRest(expression); + if (token === 25) { + var typeArguments = tryParse(parseTypeArgumentsInExpression); + if (!typeArguments) { + return expression; + } + var callExpr = createNode(168, expression.pos); + callExpr.expression = expression; + callExpr.typeArguments = typeArguments; + callExpr.arguments = parseArgumentList(); + expression = finishNode(callExpr); + continue; + } + else if (token === 17) { + var callExpr = createNode(168, expression.pos); + callExpr.expression = expression; + callExpr.arguments = parseArgumentList(); + expression = finishNode(callExpr); + continue; + } + return expression; + } + } + function parseArgumentList() { + parseExpected(17); + var result = parseDelimitedList(11, parseArgumentExpression); + parseExpected(18); + return result; + } + function parseTypeArgumentsInExpression() { + if (!parseOptional(25)) { + return undefined; + } + var typeArguments = parseDelimitedList(18, parseType); + if (!parseExpected(27)) { + return undefined; + } + return typeArguments && canFollowTypeArgumentsInExpression() + ? typeArguments + : undefined; + } + function canFollowTypeArgumentsInExpression() { + switch (token) { + case 17: + case 21: + case 18: + case 20: + case 54: + case 23: + case 53: + case 30: + case 32: + case 31: + case 33: + case 51: + case 52: + case 48: + case 46: + case 47: + case 16: + case 1: + return true; + case 24: + case 15: + default: + return false; + } + } + function parsePrimaryExpression() { + switch (token) { + case 8: + case 9: + case 11: + return parseLiteralNode(); + case 97: + case 95: + case 93: + case 99: + case 84: + return parseTokenNode(); + case 17: + return parseParenthesizedExpression(); + case 19: + return parseArrayLiteralExpression(); + case 15: + return parseObjectLiteralExpression(); + case 118: + if (!lookAhead(nextTokenIsFunctionKeywordOnSameLine)) { + break; + } + return parseFunctionExpression(); + case 73: + return parseClassExpression(); + case 87: + return parseFunctionExpression(); + case 92: + return parseNewExpression(); + case 39: + case 61: + if (reScanSlashToken() === 10) { + return parseLiteralNode(); + } + break; + case 12: + return parseTemplateExpression(); + } + return parseIdentifier(ts.Diagnostics.Expression_expected); + } + function parseParenthesizedExpression() { + var node = createNode(172); + parseExpected(17); + node.expression = allowInAnd(parseExpression); + parseExpected(18); + return finishNode(node); + } + function parseSpreadElement() { + var node = createNode(185); + parseExpected(22); + node.expression = parseAssignmentExpressionOrHigher(); + return finishNode(node); + } + function parseArgumentOrArrayLiteralElement() { + return token === 22 ? parseSpreadElement() : + token === 24 ? createNode(187) : + parseAssignmentExpressionOrHigher(); + } + function parseArgumentExpression() { + return doOutsideOfContext(disallowInAndDecoratorContext, parseArgumentOrArrayLiteralElement); + } + function parseArrayLiteralExpression() { + var node = createNode(164); + parseExpected(19); + if (scanner.hasPrecedingLineBreak()) + node.flags |= 2048; + node.elements = parseDelimitedList(15, parseArgumentOrArrayLiteralElement); + parseExpected(20); + return finishNode(node); + } + function tryParseAccessorDeclaration(fullStart, decorators, modifiers) { + if (parseContextualModifier(123)) { + return parseAccessorDeclaration(145, fullStart, decorators, modifiers); + } + else if (parseContextualModifier(129)) { + return parseAccessorDeclaration(146, fullStart, decorators, modifiers); + } + return undefined; + } + function parseObjectLiteralElement() { + var fullStart = scanner.getStartPos(); + var decorators = parseDecorators(); + var modifiers = parseModifiers(); + var accessor = tryParseAccessorDeclaration(fullStart, decorators, modifiers); + if (accessor) { + return accessor; + } + var asteriskToken = parseOptionalToken(37); + var tokenIsIdentifier = isIdentifier(); + var nameToken = token; + var propertyName = parsePropertyName(); + var questionToken = parseOptionalToken(53); + if (asteriskToken || token === 17 || token === 25) { + return parseMethodDeclaration(fullStart, decorators, modifiers, asteriskToken, propertyName, questionToken); + } + var isShorthandPropertyAssignment = tokenIsIdentifier && (token === 24 || token === 16 || token === 56); + if (isShorthandPropertyAssignment) { + var shorthandDeclaration = createNode(246, fullStart); + shorthandDeclaration.name = propertyName; + shorthandDeclaration.questionToken = questionToken; + var equalsToken = parseOptionalToken(56); + if (equalsToken) { + shorthandDeclaration.equalsToken = equalsToken; + shorthandDeclaration.objectAssignmentInitializer = allowInAnd(parseAssignmentExpressionOrHigher); + } + return finishNode(shorthandDeclaration); + } + else { + var propertyAssignment = createNode(245, fullStart); + propertyAssignment.name = propertyName; + propertyAssignment.questionToken = questionToken; + parseExpected(54); + propertyAssignment.initializer = allowInAnd(parseAssignmentExpressionOrHigher); + return finishNode(propertyAssignment); + } + } + function parseObjectLiteralExpression() { + var node = createNode(165); + parseExpected(15); + if (scanner.hasPrecedingLineBreak()) { + node.flags |= 2048; + } + node.properties = parseDelimitedList(12, parseObjectLiteralElement, true); + parseExpected(16); + return finishNode(node); + } + function parseFunctionExpression() { + var saveDecoratorContext = inDecoratorContext(); + if (saveDecoratorContext) { + setDecoratorContext(false); + } + var node = createNode(173); + setModifiers(node, parseModifiers()); + parseExpected(87); + node.asteriskToken = parseOptionalToken(37); + var isGenerator = !!node.asteriskToken; + var isAsync = !!(node.flags & 512); + node.name = + isGenerator && isAsync ? doInYieldAndAwaitContext(parseOptionalIdentifier) : + isGenerator ? doInYieldContext(parseOptionalIdentifier) : + isAsync ? doInAwaitContext(parseOptionalIdentifier) : + parseOptionalIdentifier(); + fillSignature(54, isGenerator, isAsync, false, node); + node.body = parseFunctionBlock(isGenerator, isAsync, false); + if (saveDecoratorContext) { + setDecoratorContext(true); + } + return finishNode(node); + } + function parseOptionalIdentifier() { + return isIdentifier() ? parseIdentifier() : undefined; + } + function parseNewExpression() { + var node = createNode(169); + parseExpected(92); + node.expression = parseMemberExpressionOrHigher(); + node.typeArguments = tryParse(parseTypeArgumentsInExpression); + if (node.typeArguments || token === 17) { + node.arguments = parseArgumentList(); + } + return finishNode(node); + } + function parseBlock(ignoreMissingOpenBrace, diagnosticMessage) { + var node = createNode(192); + if (parseExpected(15, diagnosticMessage) || ignoreMissingOpenBrace) { + node.statements = parseList(1, parseStatement); + parseExpected(16); + } + else { + node.statements = createMissingList(); + } + return finishNode(node); + } + function parseFunctionBlock(allowYield, allowAwait, ignoreMissingOpenBrace, diagnosticMessage) { + var savedYieldContext = inYieldContext(); + setYieldContext(allowYield); + var savedAwaitContext = inAwaitContext(); + setAwaitContext(allowAwait); + var saveDecoratorContext = inDecoratorContext(); + if (saveDecoratorContext) { + setDecoratorContext(false); + } + var block = parseBlock(ignoreMissingOpenBrace, diagnosticMessage); + if (saveDecoratorContext) { + setDecoratorContext(true); + } + setYieldContext(savedYieldContext); + setAwaitContext(savedAwaitContext); + return block; + } + function parseEmptyStatement() { + var node = createNode(194); + parseExpected(23); + return finishNode(node); + } + function parseIfStatement() { + var node = createNode(196); + parseExpected(88); + parseExpected(17); + node.expression = allowInAnd(parseExpression); + parseExpected(18); + node.thenStatement = parseStatement(); + node.elseStatement = parseOptional(80) ? parseStatement() : undefined; + return finishNode(node); + } + function parseDoStatement() { + var node = createNode(197); + parseExpected(79); + node.statement = parseStatement(); + parseExpected(104); + parseExpected(17); + node.expression = allowInAnd(parseExpression); + parseExpected(18); + parseOptional(23); + return finishNode(node); + } + function parseWhileStatement() { + var node = createNode(198); + parseExpected(104); + parseExpected(17); + node.expression = allowInAnd(parseExpression); + parseExpected(18); + node.statement = parseStatement(); + return finishNode(node); + } + function parseForOrForInOrForOfStatement() { + var pos = getNodePos(); + parseExpected(86); + parseExpected(17); + var initializer = undefined; + if (token !== 23) { + if (token === 102 || token === 108 || token === 74) { + initializer = parseVariableDeclarationList(true); + } + else { + initializer = disallowInAnd(parseExpression); + } + } + var forOrForInOrForOfStatement; + if (parseOptional(90)) { + var forInStatement = createNode(200, pos); + forInStatement.initializer = initializer; + forInStatement.expression = allowInAnd(parseExpression); + parseExpected(18); + forOrForInOrForOfStatement = forInStatement; + } + else if (parseOptional(134)) { + var forOfStatement = createNode(201, pos); + forOfStatement.initializer = initializer; + forOfStatement.expression = allowInAnd(parseAssignmentExpressionOrHigher); + parseExpected(18); + forOrForInOrForOfStatement = forOfStatement; + } + else { + var forStatement = createNode(199, pos); + forStatement.initializer = initializer; + parseExpected(23); + if (token !== 23 && token !== 18) { + forStatement.condition = allowInAnd(parseExpression); + } + parseExpected(23); + if (token !== 18) { + forStatement.incrementor = allowInAnd(parseExpression); + } + parseExpected(18); + forOrForInOrForOfStatement = forStatement; + } + forOrForInOrForOfStatement.statement = parseStatement(); + return finishNode(forOrForInOrForOfStatement); + } + function parseBreakOrContinueStatement(kind) { + var node = createNode(kind); + parseExpected(kind === 203 ? 70 : 75); + if (!canParseSemicolon()) { + node.label = parseIdentifier(); + } + parseSemicolon(); + return finishNode(node); + } + function parseReturnStatement() { + var node = createNode(204); + parseExpected(94); + if (!canParseSemicolon()) { + node.expression = allowInAnd(parseExpression); + } + parseSemicolon(); + return finishNode(node); + } + function parseWithStatement() { + var node = createNode(205); + parseExpected(105); + parseExpected(17); + node.expression = allowInAnd(parseExpression); + parseExpected(18); + node.statement = parseStatement(); + return finishNode(node); + } + function parseCaseClause() { + var node = createNode(241); + parseExpected(71); + node.expression = allowInAnd(parseExpression); + parseExpected(54); + node.statements = parseList(3, parseStatement); + return finishNode(node); + } + function parseDefaultClause() { + var node = createNode(242); + parseExpected(77); + parseExpected(54); + node.statements = parseList(3, parseStatement); + return finishNode(node); + } + function parseCaseOrDefaultClause() { + return token === 71 ? parseCaseClause() : parseDefaultClause(); + } + function parseSwitchStatement() { + var node = createNode(206); + parseExpected(96); + parseExpected(17); + node.expression = allowInAnd(parseExpression); + parseExpected(18); + var caseBlock = createNode(220, scanner.getStartPos()); + parseExpected(15); + caseBlock.clauses = parseList(2, parseCaseOrDefaultClause); + parseExpected(16); + node.caseBlock = finishNode(caseBlock); + return finishNode(node); + } + function parseThrowStatement() { + var node = createNode(208); + parseExpected(98); + node.expression = scanner.hasPrecedingLineBreak() ? undefined : allowInAnd(parseExpression); + parseSemicolon(); + return finishNode(node); + } + function parseTryStatement() { + var node = createNode(209); + parseExpected(100); + node.tryBlock = parseBlock(false); + node.catchClause = token === 72 ? parseCatchClause() : undefined; + if (!node.catchClause || token === 85) { + parseExpected(85); + node.finallyBlock = parseBlock(false); + } + return finishNode(node); + } + function parseCatchClause() { + var result = createNode(244); + parseExpected(72); + if (parseExpected(17)) { + result.variableDeclaration = parseVariableDeclaration(); + } + parseExpected(18); + result.block = parseBlock(false); + return finishNode(result); + } + function parseDebuggerStatement() { + var node = createNode(210); + parseExpected(76); + parseSemicolon(); + return finishNode(node); + } + function parseExpressionOrLabeledStatement() { + var fullStart = scanner.getStartPos(); + var expression = allowInAnd(parseExpression); + if (expression.kind === 69 && parseOptional(54)) { + var labeledStatement = createNode(207, fullStart); + labeledStatement.label = expression; + labeledStatement.statement = parseStatement(); + return finishNode(labeledStatement); + } + else { + var expressionStatement = createNode(195, fullStart); + expressionStatement.expression = expression; + parseSemicolon(); + return finishNode(expressionStatement); + } + } + function nextTokenIsIdentifierOrKeywordOnSameLine() { + nextToken(); + return ts.tokenIsIdentifierOrKeyword(token) && !scanner.hasPrecedingLineBreak(); + } + function nextTokenIsFunctionKeywordOnSameLine() { + nextToken(); + return token === 87 && !scanner.hasPrecedingLineBreak(); + } + function nextTokenIsIdentifierOrKeywordOrNumberOnSameLine() { + nextToken(); + return (ts.tokenIsIdentifierOrKeyword(token) || token === 8) && !scanner.hasPrecedingLineBreak(); + } + function isDeclaration() { + while (true) { + switch (token) { + case 102: + case 108: + case 74: + case 87: + case 73: + case 81: + return true; + case 107: + case 132: + return nextTokenIsIdentifierOnSameLine(); + case 125: + case 126: + return nextTokenIsIdentifierOrStringLiteralOnSameLine(); + case 115: + case 118: + case 122: + case 110: + case 111: + case 112: + nextToken(); + if (scanner.hasPrecedingLineBreak()) { + return false; + } + continue; + case 89: + nextToken(); + return token === 9 || token === 37 || + token === 15 || ts.tokenIsIdentifierOrKeyword(token); + case 82: + nextToken(); + if (token === 56 || token === 37 || + token === 15 || token === 77) { + return true; + } + continue; + case 113: + nextToken(); + continue; + default: + return false; + } + } + } + function isStartOfDeclaration() { + return lookAhead(isDeclaration); + } + function isStartOfStatement() { + switch (token) { + case 55: + case 23: + case 15: + case 102: + case 108: + case 87: + case 73: + case 81: + 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: + return isStartOfDeclaration(); + case 118: + case 122: + case 107: + case 125: + case 126: + case 132: + return true; + case 112: + case 110: + case 111: + case 113: + return isStartOfDeclaration() || !lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine); + default: + return isStartOfExpression(); + } + } + function nextTokenIsIdentifierOrStartOfDestructuring() { + nextToken(); + return isIdentifier() || token === 15 || token === 19; + } + function isLetDeclaration() { + return lookAhead(nextTokenIsIdentifierOrStartOfDestructuring); + } + function parseStatement() { + switch (token) { + case 23: + return parseEmptyStatement(); + case 15: + return parseBlock(false); + case 102: + return parseVariableStatement(scanner.getStartPos(), undefined, undefined); + case 108: + 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(202); + case 70: + return parseBreakOrContinueStatement(203); + 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 132: + case 125: + case 126: + case 122: + case 74: + case 81: + case 82: + case 89: + case 110: + case 111: + case 112: + case 115: + case 113: + if (isStartOfDeclaration()) { + return parseDeclaration(); + } + break; + } + return parseExpressionOrLabeledStatement(); + } + function parseDeclaration() { + var fullStart = getNodePos(); + var decorators = parseDecorators(); + var modifiers = parseModifiers(); + switch (token) { + case 102: + case 108: + case 74: + return parseVariableStatement(fullStart, decorators, modifiers); + case 87: + return parseFunctionDeclaration(fullStart, decorators, modifiers); + case 73: + return parseClassDeclaration(fullStart, decorators, modifiers); + case 107: + return parseInterfaceDeclaration(fullStart, decorators, modifiers); + case 132: + return parseTypeAliasDeclaration(fullStart, decorators, modifiers); + case 81: + return parseEnumDeclaration(fullStart, decorators, modifiers); + case 125: + case 126: + return parseModuleDeclaration(fullStart, decorators, modifiers); + case 89: + return parseImportDeclarationOrImportEqualsDeclaration(fullStart, decorators, modifiers); + case 82: + nextToken(); + return token === 77 || token === 56 ? + parseExportAssignment(fullStart, decorators, modifiers) : + parseExportDeclaration(fullStart, decorators, modifiers); + default: + if (decorators || modifiers) { + var node = createMissingNode(231, true, ts.Diagnostics.Declaration_expected); + node.pos = fullStart; + node.decorators = decorators; + setModifiers(node, modifiers); + return finishNode(node); + } + } + } + function nextTokenIsIdentifierOrStringLiteralOnSameLine() { + nextToken(); + return !scanner.hasPrecedingLineBreak() && (isIdentifier() || token === 9); + } + function parseFunctionBlockOrSemicolon(isGenerator, isAsync, diagnosticMessage) { + if (token !== 15 && canParseSemicolon()) { + parseSemicolon(); + return; + } + return parseFunctionBlock(isGenerator, isAsync, false, diagnosticMessage); + } + function parseArrayBindingElement() { + if (token === 24) { + return createNode(187); + } + var node = createNode(163); + node.dotDotDotToken = parseOptionalToken(22); + node.name = parseIdentifierOrPattern(); + node.initializer = parseBindingElementInitializer(false); + return finishNode(node); + } + function parseObjectBindingElement() { + var node = createNode(163); + var tokenIsIdentifier = isIdentifier(); + var propertyName = parsePropertyName(); + if (tokenIsIdentifier && token !== 54) { + node.name = propertyName; + } + else { + parseExpected(54); + node.propertyName = propertyName; + node.name = parseIdentifierOrPattern(); + } + node.initializer = parseBindingElementInitializer(false); + return finishNode(node); + } + function parseObjectBindingPattern() { + var node = createNode(161); + parseExpected(15); + node.elements = parseDelimitedList(9, parseObjectBindingElement); + parseExpected(16); + return finishNode(node); + } + function parseArrayBindingPattern() { + var node = createNode(162); + parseExpected(19); + node.elements = parseDelimitedList(10, parseArrayBindingElement); + parseExpected(20); + return finishNode(node); + } + function isIdentifierOrPattern() { + return token === 15 || token === 19 || isIdentifier(); + } + function parseIdentifierOrPattern() { + if (token === 19) { + return parseArrayBindingPattern(); + } + if (token === 15) { + return parseObjectBindingPattern(); + } + return parseIdentifier(); + } + function parseVariableDeclaration() { + var node = createNode(211); + node.name = parseIdentifierOrPattern(); + node.type = parseTypeAnnotation(); + if (!isInOrOfKeyword(token)) { + node.initializer = parseInitializer(false); + } + return finishNode(node); + } + function parseVariableDeclarationList(inForStatementInitializer) { + var node = createNode(212); + switch (token) { + case 102: + break; + case 108: + node.flags |= 16384; + break; + case 74: + node.flags |= 32768; + break; + default: + ts.Debug.fail(); + } + nextToken(); + if (token === 134 && lookAhead(canFollowContextualOfKeyword)) { + node.declarations = createMissingList(); + } + else { + var savedDisallowIn = inDisallowInContext(); + setDisallowInContext(inForStatementInitializer); + node.declarations = parseDelimitedList(8, parseVariableDeclaration); + setDisallowInContext(savedDisallowIn); + } + return finishNode(node); + } + function canFollowContextualOfKeyword() { + return nextTokenIsIdentifier() && nextToken() === 18; + } + function parseVariableStatement(fullStart, decorators, modifiers) { + var node = createNode(193, fullStart); + node.decorators = decorators; + setModifiers(node, modifiers); + node.declarationList = parseVariableDeclarationList(false); + parseSemicolon(); + return finishNode(node); + } + function parseFunctionDeclaration(fullStart, decorators, modifiers) { + var node = createNode(213, fullStart); + node.decorators = decorators; + setModifiers(node, modifiers); + parseExpected(87); + node.asteriskToken = parseOptionalToken(37); + node.name = node.flags & 1024 ? parseOptionalIdentifier() : parseIdentifier(); + var isGenerator = !!node.asteriskToken; + var isAsync = !!(node.flags & 512); + fillSignature(54, isGenerator, isAsync, false, node); + node.body = parseFunctionBlockOrSemicolon(isGenerator, isAsync, ts.Diagnostics.or_expected); + return finishNode(node); + } + function parseConstructorDeclaration(pos, decorators, modifiers) { + var node = createNode(144, pos); + node.decorators = decorators; + setModifiers(node, modifiers); + parseExpected(121); + fillSignature(54, false, false, false, node); + node.body = parseFunctionBlockOrSemicolon(false, false, ts.Diagnostics.or_expected); + return finishNode(node); + } + function parseMethodDeclaration(fullStart, decorators, modifiers, asteriskToken, name, questionToken, diagnosticMessage) { + var method = createNode(143, fullStart); + method.decorators = decorators; + setModifiers(method, modifiers); + method.asteriskToken = asteriskToken; + method.name = name; + method.questionToken = questionToken; + var isGenerator = !!asteriskToken; + var isAsync = !!(method.flags & 512); + fillSignature(54, isGenerator, isAsync, false, method); + method.body = parseFunctionBlockOrSemicolon(isGenerator, isAsync, diagnosticMessage); + return finishNode(method); + } + function parsePropertyDeclaration(fullStart, decorators, modifiers, name, questionToken) { + var property = createNode(141, fullStart); + property.decorators = decorators; + setModifiers(property, modifiers); + property.name = name; + property.questionToken = questionToken; + property.type = parseTypeAnnotation(); + property.initializer = modifiers && modifiers.flags & 128 + ? allowInAnd(parseNonParameterInitializer) + : doOutsideOfContext(2 | 1, parseNonParameterInitializer); + parseSemicolon(); + return finishNode(property); + } + function parsePropertyOrMethodDeclaration(fullStart, decorators, modifiers) { + var asteriskToken = parseOptionalToken(37); + var name = parsePropertyName(); + var questionToken = parseOptionalToken(53); + if (asteriskToken || token === 17 || token === 25) { + return parseMethodDeclaration(fullStart, decorators, modifiers, asteriskToken, name, questionToken, ts.Diagnostics.or_expected); + } + else { + return parsePropertyDeclaration(fullStart, decorators, modifiers, name, questionToken); + } + } + function parseNonParameterInitializer() { + return parseInitializer(false); + } + function parseAccessorDeclaration(kind, fullStart, decorators, modifiers) { + var node = createNode(kind, fullStart); + node.decorators = decorators; + setModifiers(node, modifiers); + node.name = parsePropertyName(); + fillSignature(54, false, false, false, node); + node.body = parseFunctionBlockOrSemicolon(false, false); + return finishNode(node); + } + function isClassMemberModifier(idToken) { + switch (idToken) { + case 112: + case 110: + case 111: + case 113: + return true; + default: + return false; + } + } + function isClassMemberStart() { + var idToken; + if (token === 55) { + return true; + } + while (ts.isModifier(token)) { + idToken = token; + if (isClassMemberModifier(idToken)) { + return true; + } + nextToken(); + } + if (token === 37) { + return true; + } + if (isLiteralPropertyName()) { + idToken = token; + nextToken(); + } + if (token === 19) { + return true; + } + if (idToken !== undefined) { + if (!ts.isKeyword(idToken) || idToken === 129 || idToken === 123) { + return true; + } + switch (token) { + case 17: + case 25: + case 54: + case 56: + case 53: + return true; + default: + return canParseSemicolon(); + } + } + return false; + } + function parseDecorators() { + var decorators; + while (true) { + var decoratorStart = getNodePos(); + if (!parseOptional(55)) { + break; + } + if (!decorators) { + decorators = []; + decorators.pos = scanner.getStartPos(); + } + var decorator = createNode(139, decoratorStart); + decorator.expression = doInDecoratorContext(parseLeftHandSideExpressionOrHigher); + decorators.push(finishNode(decorator)); + } + if (decorators) { + decorators.end = getNodeEnd(); + } + return decorators; + } + function parseModifiers() { + var flags = 0; + var modifiers; + while (true) { + var modifierStart = scanner.getStartPos(); + var modifierKind = token; + if (!parseAnyContextualModifier()) { + break; + } + if (!modifiers) { + modifiers = []; + modifiers.pos = modifierStart; + } + flags |= ts.modifierToFlag(modifierKind); + modifiers.push(finishNode(createNode(modifierKind, modifierStart))); + } + if (modifiers) { + modifiers.flags = flags; + modifiers.end = scanner.getStartPos(); + } + return modifiers; + } + function parseModifiersForArrowFunction() { + var flags = 0; + var modifiers; + if (token === 118) { + var modifierStart = scanner.getStartPos(); + var modifierKind = token; + nextToken(); + modifiers = []; + modifiers.pos = modifierStart; + flags |= ts.modifierToFlag(modifierKind); + modifiers.push(finishNode(createNode(modifierKind, modifierStart))); + modifiers.flags = flags; + modifiers.end = scanner.getStartPos(); + } + return modifiers; + } + function parseClassElement() { + if (token === 23) { + var result = createNode(191); + nextToken(); + return finishNode(result); + } + var fullStart = getNodePos(); + var decorators = parseDecorators(); + var modifiers = parseModifiers(); + var accessor = tryParseAccessorDeclaration(fullStart, decorators, modifiers); + if (accessor) { + return accessor; + } + if (token === 121) { + return parseConstructorDeclaration(fullStart, decorators, modifiers); + } + if (isIndexSignature()) { + return parseIndexSignatureDeclaration(fullStart, decorators, modifiers); + } + if (ts.tokenIsIdentifierOrKeyword(token) || + token === 9 || + token === 8 || + token === 37 || + token === 19) { + return parsePropertyOrMethodDeclaration(fullStart, decorators, modifiers); + } + if (decorators || modifiers) { + var name_7 = createMissingNode(69, true, ts.Diagnostics.Declaration_expected); + return parsePropertyDeclaration(fullStart, decorators, modifiers, name_7, undefined); + } + ts.Debug.fail("Should not have attempted to parse class member declaration."); + } + function parseClassExpression() { + return parseClassDeclarationOrExpression(scanner.getStartPos(), undefined, undefined, 186); + } + function parseClassDeclaration(fullStart, decorators, modifiers) { + return parseClassDeclarationOrExpression(fullStart, decorators, modifiers, 214); + } + function parseClassDeclarationOrExpression(fullStart, decorators, modifiers, kind) { + var node = createNode(kind, fullStart); + node.decorators = decorators; + setModifiers(node, modifiers); + parseExpected(73); + node.name = parseNameOfClassDeclarationOrExpression(); + node.typeParameters = parseTypeParameters(); + node.heritageClauses = parseHeritageClauses(true); + if (parseExpected(15)) { + node.members = parseClassMembers(); + parseExpected(16); + } + else { + node.members = createMissingList(); + } + return finishNode(node); + } + function parseNameOfClassDeclarationOrExpression() { + return isIdentifier() && !isImplementsClause() + ? parseIdentifier() + : undefined; + } + function isImplementsClause() { + return token === 106 && lookAhead(nextTokenIsIdentifierOrKeyword); + } + function parseHeritageClauses(isClassHeritageClause) { + if (isHeritageClause()) { + return parseList(20, parseHeritageClause); + } + return undefined; + } + function parseHeritageClausesWorker() { + return parseList(20, parseHeritageClause); + } + function parseHeritageClause() { + if (token === 83 || token === 106) { + var node = createNode(243); + node.token = token; + nextToken(); + node.types = parseDelimitedList(7, parseExpressionWithTypeArguments); + return finishNode(node); + } + return undefined; + } + function parseExpressionWithTypeArguments() { + var node = createNode(188); + node.expression = parseLeftHandSideExpressionOrHigher(); + if (token === 25) { + node.typeArguments = parseBracketedList(18, parseType, 25, 27); + } + return finishNode(node); + } + function isHeritageClause() { + return token === 83 || token === 106; + } + function parseClassMembers() { + return parseList(5, parseClassElement); + } + function parseInterfaceDeclaration(fullStart, decorators, modifiers) { + var node = createNode(215, fullStart); + node.decorators = decorators; + setModifiers(node, modifiers); + parseExpected(107); + node.name = parseIdentifier(); + node.typeParameters = parseTypeParameters(); + node.heritageClauses = parseHeritageClauses(false); + node.members = parseObjectTypeMembers(); + return finishNode(node); + } + function parseTypeAliasDeclaration(fullStart, decorators, modifiers) { + var node = createNode(216, fullStart); + node.decorators = decorators; + setModifiers(node, modifiers); + parseExpected(132); + node.name = parseIdentifier(); + node.typeParameters = parseTypeParameters(); + parseExpected(56); + node.type = parseType(); + parseSemicolon(); + return finishNode(node); + } + function parseEnumMember() { + var node = createNode(247, scanner.getStartPos()); + node.name = parsePropertyName(); + node.initializer = allowInAnd(parseNonParameterInitializer); + return finishNode(node); + } + function parseEnumDeclaration(fullStart, decorators, modifiers) { + var node = createNode(217, fullStart); + node.decorators = decorators; + setModifiers(node, modifiers); + parseExpected(81); + node.name = parseIdentifier(); + if (parseExpected(15)) { + node.members = parseDelimitedList(6, parseEnumMember); + parseExpected(16); + } + else { + node.members = createMissingList(); + } + return finishNode(node); + } + function parseModuleBlock() { + var node = createNode(219, scanner.getStartPos()); + if (parseExpected(15)) { + node.statements = parseList(1, parseStatement); + parseExpected(16); + } + else { + node.statements = createMissingList(); + } + return finishNode(node); + } + function parseModuleOrNamespaceDeclaration(fullStart, decorators, modifiers, flags) { + var node = createNode(218, fullStart); + var namespaceFlag = flags & 131072; + node.decorators = decorators; + setModifiers(node, modifiers); + node.flags |= flags; + node.name = parseIdentifier(); + node.body = parseOptional(21) + ? parseModuleOrNamespaceDeclaration(getNodePos(), undefined, undefined, 1 | namespaceFlag) + : parseModuleBlock(); + return finishNode(node); + } + function parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers) { + var node = createNode(218, fullStart); + node.decorators = decorators; + setModifiers(node, modifiers); + node.name = parseLiteralNode(true); + node.body = parseModuleBlock(); + return finishNode(node); + } + function parseModuleDeclaration(fullStart, decorators, modifiers) { + var flags = modifiers ? modifiers.flags : 0; + if (parseOptional(126)) { + flags |= 131072; + } + else { + parseExpected(125); + if (token === 9) { + return parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers); + } + } + return parseModuleOrNamespaceDeclaration(fullStart, decorators, modifiers, flags); + } + function isExternalModuleReference() { + return token === 127 && + lookAhead(nextTokenIsOpenParen); + } + function nextTokenIsOpenParen() { + return nextToken() === 17; + } + function nextTokenIsSlash() { + return nextToken() === 39; + } + function nextTokenIsCommaOrFromKeyword() { + nextToken(); + return token === 24 || + token === 133; + } + function parseImportDeclarationOrImportEqualsDeclaration(fullStart, decorators, modifiers) { + parseExpected(89); + var afterImportPos = scanner.getStartPos(); + var identifier; + if (isIdentifier()) { + identifier = parseIdentifier(); + if (token !== 24 && token !== 133) { + var importEqualsDeclaration = createNode(221, fullStart); + importEqualsDeclaration.decorators = decorators; + setModifiers(importEqualsDeclaration, modifiers); + importEqualsDeclaration.name = identifier; + parseExpected(56); + importEqualsDeclaration.moduleReference = parseModuleReference(); + parseSemicolon(); + return finishNode(importEqualsDeclaration); + } + } + var importDeclaration = createNode(222, fullStart); + importDeclaration.decorators = decorators; + setModifiers(importDeclaration, modifiers); + if (identifier || + token === 37 || + token === 15) { + importDeclaration.importClause = parseImportClause(identifier, afterImportPos); + parseExpected(133); + } + importDeclaration.moduleSpecifier = parseModuleSpecifier(); + parseSemicolon(); + return finishNode(importDeclaration); + } + function parseImportClause(identifier, fullStart) { + var importClause = createNode(223, fullStart); + if (identifier) { + importClause.name = identifier; + } + if (!importClause.name || + parseOptional(24)) { + importClause.namedBindings = token === 37 ? parseNamespaceImport() : parseNamedImportsOrExports(225); + } + return finishNode(importClause); + } + function parseModuleReference() { + return isExternalModuleReference() + ? parseExternalModuleReference() + : parseEntityName(false); + } + function parseExternalModuleReference() { + var node = createNode(232); + parseExpected(127); + parseExpected(17); + node.expression = parseModuleSpecifier(); + parseExpected(18); + return finishNode(node); + } + function parseModuleSpecifier() { + var result = parseExpression(); + if (result.kind === 9) { + internIdentifier(result.text); + } + return result; + } + function parseNamespaceImport() { + var namespaceImport = createNode(224); + parseExpected(37); + parseExpected(116); + namespaceImport.name = parseIdentifier(); + return finishNode(namespaceImport); + } + function parseNamedImportsOrExports(kind) { + var node = createNode(kind); + node.elements = parseBracketedList(21, kind === 225 ? parseImportSpecifier : parseExportSpecifier, 15, 16); + return finishNode(node); + } + function parseExportSpecifier() { + return parseImportOrExportSpecifier(230); + } + function parseImportSpecifier() { + return parseImportOrExportSpecifier(226); + } + function parseImportOrExportSpecifier(kind) { + var node = createNode(kind); + var checkIdentifierIsKeyword = ts.isKeyword(token) && !isIdentifier(); + var checkIdentifierStart = scanner.getTokenPos(); + var checkIdentifierEnd = scanner.getTextPos(); + var identifierName = parseIdentifierName(); + if (token === 116) { + node.propertyName = identifierName; + parseExpected(116); + checkIdentifierIsKeyword = ts.isKeyword(token) && !isIdentifier(); + checkIdentifierStart = scanner.getTokenPos(); + checkIdentifierEnd = scanner.getTextPos(); + node.name = parseIdentifierName(); + } + else { + node.name = identifierName; + } + if (kind === 226 && checkIdentifierIsKeyword) { + parseErrorAtPosition(checkIdentifierStart, checkIdentifierEnd - checkIdentifierStart, ts.Diagnostics.Identifier_expected); + } + return finishNode(node); + } + function parseExportDeclaration(fullStart, decorators, modifiers) { + var node = createNode(228, fullStart); + node.decorators = decorators; + setModifiers(node, modifiers); + if (parseOptional(37)) { + parseExpected(133); + node.moduleSpecifier = parseModuleSpecifier(); + } + else { + node.exportClause = parseNamedImportsOrExports(229); + if (token === 133 || (token === 9 && !scanner.hasPrecedingLineBreak())) { + parseExpected(133); + node.moduleSpecifier = parseModuleSpecifier(); + } + } + parseSemicolon(); + return finishNode(node); + } + function parseExportAssignment(fullStart, decorators, modifiers) { + var node = createNode(227, fullStart); + node.decorators = decorators; + setModifiers(node, modifiers); + if (parseOptional(56)) { + node.isExportEquals = true; + } + else { + parseExpected(77); + } + node.expression = parseAssignmentExpressionOrHigher(); + parseSemicolon(); + return finishNode(node); + } + function processReferenceComments(sourceFile) { + var triviaScanner = ts.createScanner(sourceFile.languageVersion, false, 0, sourceText); + var referencedFiles = []; + var amdDependencies = []; + var amdModuleName; + while (true) { + var kind = triviaScanner.scan(); + if (kind === 5 || kind === 4 || kind === 3) { + continue; + } + if (kind !== 2) { + break; + } + var range = { pos: triviaScanner.getTokenPos(), end: triviaScanner.getTextPos(), kind: triviaScanner.getToken() }; + var comment = sourceText.substring(range.pos, range.end); + var referencePathMatchResult = ts.getFileReferenceFromReferencePath(comment, range); + if (referencePathMatchResult) { + var fileReference = referencePathMatchResult.fileReference; + sourceFile.hasNoDefaultLib = referencePathMatchResult.isNoDefaultLib; + var diagnosticMessage = referencePathMatchResult.diagnosticMessage; + if (fileReference) { + referencedFiles.push(fileReference); + } + if (diagnosticMessage) { + parseDiagnostics.push(ts.createFileDiagnostic(sourceFile, range.pos, range.end - range.pos, diagnosticMessage)); + } + } + else { + var amdModuleNameRegEx = /^\/\/\/\s*".length; + return parseErrorAtPosition(start, end - start, ts.Diagnostics.Type_argument_list_cannot_be_empty); + } + } + function parseQualifiedName(left) { + var result = createNode(135, left.pos); + result.left = left; + result.right = parseIdentifierName(); + return finishNode(result); + } + function parseJSDocRecordType() { + var result = createNode(257); + nextToken(); + result.members = parseDelimitedList(24, parseJSDocRecordMember); + checkForTrailingComma(result.members); + parseExpected(16); + return finishNode(result); + } + function parseJSDocRecordMember() { + var result = createNode(258); + result.name = parseSimplePropertyName(); + if (token === 54) { + nextToken(); + result.type = parseJSDocType(); + } + return finishNode(result); + } + function parseJSDocNonNullableType() { + var result = createNode(256); + nextToken(); + result.type = parseJSDocType(); + return finishNode(result); + } + function parseJSDocTupleType() { + var result = createNode(254); + nextToken(); + result.types = parseDelimitedList(25, parseJSDocType); + checkForTrailingComma(result.types); + parseExpected(20); + return finishNode(result); + } + function checkForTrailingComma(list) { + if (parseDiagnostics.length === 0 && list.hasTrailingComma) { + var start = list.end - ",".length; + parseErrorAtPosition(start, ",".length, ts.Diagnostics.Trailing_comma_not_allowed); + } + } + function parseJSDocUnionType() { + var result = createNode(253); + nextToken(); + result.types = parseJSDocTypeList(parseJSDocType()); + parseExpected(18); + return finishNode(result); + } + function parseJSDocTypeList(firstType) { + ts.Debug.assert(!!firstType); + var types = []; + types.pos = firstType.pos; + types.push(firstType); + while (parseOptional(47)) { + types.push(parseJSDocType()); + } + types.end = scanner.getStartPos(); + return types; + } + function parseJSDocAllType() { + var result = createNode(250); + nextToken(); + return finishNode(result); + } + function parseJSDocUnknownOrNullableType() { + var pos = scanner.getStartPos(); + nextToken(); + if (token === 24 || + token === 16 || + token === 18 || + token === 27 || + token === 56 || + token === 47) { + var result = createNode(251, pos); + return finishNode(result); + } + else { + var result = createNode(255, pos); + result.type = parseJSDocType(); + return finishNode(result); + } + } + function parseIsolatedJSDocComment(content, start, length) { + initializeState("file.js", content, 2, undefined); + var jsDocComment = parseJSDocComment(undefined, start, length); + var diagnostics = parseDiagnostics; + clearState(); + return jsDocComment ? { jsDocComment: jsDocComment, diagnostics: diagnostics } : undefined; + } + JSDocParser.parseIsolatedJSDocComment = parseIsolatedJSDocComment; + function parseJSDocComment(parent, start, length) { + var comment = parseJSDocCommentWorker(start, length); + if (comment) { + fixupParentReferences(comment); + comment.parent = parent; + } + return comment; + } + JSDocParser.parseJSDocComment = parseJSDocComment; + function parseJSDocCommentWorker(start, length) { + var content = sourceText; + start = start || 0; + var end = length === undefined ? content.length : start + length; + length = end - start; + ts.Debug.assert(start >= 0); + ts.Debug.assert(start <= end); + ts.Debug.assert(end <= content.length); + var tags; + var pos; + if (length >= "/** */".length) { + if (content.charCodeAt(start) === 47 && + content.charCodeAt(start + 1) === 42 && + content.charCodeAt(start + 2) === 42 && + content.charCodeAt(start + 3) !== 42) { + var canParseTag = true; + var seenAsterisk = true; + for (pos = start + "/**".length; pos < end;) { + var ch = content.charCodeAt(pos); + pos++; + if (ch === 64 && canParseTag) { + parseTag(); + canParseTag = false; + continue; + } + if (ts.isLineBreak(ch)) { + canParseTag = true; + seenAsterisk = false; + continue; + } + if (ts.isWhiteSpace(ch)) { + continue; + } + if (ch === 42) { + if (seenAsterisk) { + canParseTag = false; + } + seenAsterisk = true; + continue; + } + canParseTag = false; + } + } + } + return createJSDocComment(); + function createJSDocComment() { + if (!tags) { + return undefined; + } + var result = createNode(265, start); + result.tags = tags; + return finishNode(result, end); + } + function skipWhitespace() { + while (pos < end && ts.isWhiteSpace(content.charCodeAt(pos))) { + pos++; + } + } + function parseTag() { + ts.Debug.assert(content.charCodeAt(pos - 1) === 64); + var atToken = createNode(55, pos - 1); + atToken.end = pos; + var tagName = scanIdentifier(); + if (!tagName) { + return; + } + var tag = handleTag(atToken, tagName) || handleUnknownTag(atToken, tagName); + addTag(tag); + } + function handleTag(atToken, tagName) { + if (tagName) { + switch (tagName.text) { + case "param": + return handleParamTag(atToken, tagName); + case "return": + case "returns": + return handleReturnTag(atToken, tagName); + case "template": + return handleTemplateTag(atToken, tagName); + case "type": + return handleTypeTag(atToken, tagName); + } + } + return undefined; + } + function handleUnknownTag(atToken, tagName) { + var result = createNode(266, atToken.pos); + result.atToken = atToken; + result.tagName = tagName; + return finishNode(result, pos); + } + function addTag(tag) { + if (tag) { + if (!tags) { + tags = []; + tags.pos = tag.pos; + } + tags.push(tag); + tags.end = tag.end; + } + } + function tryParseTypeExpression() { + skipWhitespace(); + if (content.charCodeAt(pos) !== 123) { + return undefined; + } + var typeExpression = parseJSDocTypeExpression(pos, end - pos); + pos = typeExpression.end; + return typeExpression; + } + function handleParamTag(atToken, tagName) { + var typeExpression = tryParseTypeExpression(); + skipWhitespace(); + var name; + var isBracketed; + if (content.charCodeAt(pos) === 91) { + pos++; + skipWhitespace(); + name = scanIdentifier(); + isBracketed = true; + } + else { + name = scanIdentifier(); + } + if (!name) { + parseErrorAtPosition(pos, 0, ts.Diagnostics.Identifier_expected); + } + var preName, postName; + if (typeExpression) { + postName = name; + } + else { + preName = name; + } + if (!typeExpression) { + typeExpression = tryParseTypeExpression(); + } + var result = createNode(267, atToken.pos); + result.atToken = atToken; + result.tagName = tagName; + result.preParameterName = preName; + result.typeExpression = typeExpression; + result.postParameterName = postName; + result.isBracketed = isBracketed; + return finishNode(result, pos); + } + function handleReturnTag(atToken, tagName) { + if (ts.forEach(tags, function (t) { return t.kind === 268; })) { + parseErrorAtPosition(tagName.pos, pos - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); + } + var result = createNode(268, atToken.pos); + result.atToken = atToken; + result.tagName = tagName; + result.typeExpression = tryParseTypeExpression(); + return finishNode(result, pos); + } + function handleTypeTag(atToken, tagName) { + if (ts.forEach(tags, function (t) { return t.kind === 269; })) { + parseErrorAtPosition(tagName.pos, pos - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); + } + var result = createNode(269, atToken.pos); + result.atToken = atToken; + result.tagName = tagName; + result.typeExpression = tryParseTypeExpression(); + return finishNode(result, pos); + } + function handleTemplateTag(atToken, tagName) { + if (ts.forEach(tags, function (t) { return t.kind === 270; })) { + parseErrorAtPosition(tagName.pos, pos - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); + } + var typeParameters = []; + typeParameters.pos = pos; + while (true) { + skipWhitespace(); + var startPos = pos; + var name_8 = scanIdentifier(); + if (!name_8) { + parseErrorAtPosition(startPos, 0, ts.Diagnostics.Identifier_expected); + return undefined; + } + var typeParameter = createNode(137, name_8.pos); + typeParameter.name = name_8; + finishNode(typeParameter, pos); + typeParameters.push(typeParameter); + skipWhitespace(); + if (content.charCodeAt(pos) !== 44) { + break; + } + pos++; + } + typeParameters.end = pos; + var result = createNode(270, atToken.pos); + result.atToken = atToken; + result.tagName = tagName; + result.typeParameters = typeParameters; + return finishNode(result, pos); + } + function scanIdentifier() { + var startPos = pos; + for (; pos < end; pos++) { + var ch = content.charCodeAt(pos); + if (pos === startPos && ts.isIdentifierStart(ch, 2)) { + continue; + } + else if (pos > startPos && ts.isIdentifierPart(ch, 2)) { + continue; + } + break; + } + if (startPos === pos) { + return undefined; + } + var result = createNode(69, startPos); + result.text = content.substring(startPos, pos); + return finishNode(result, pos); + } + } + JSDocParser.parseJSDocCommentWorker = parseJSDocCommentWorker; + })(JSDocParser = Parser.JSDocParser || (Parser.JSDocParser = {})); + })(Parser || (Parser = {})); + var IncrementalParser; + (function (IncrementalParser) { + function updateSourceFile(sourceFile, newText, textChangeRange, aggressiveChecks) { + aggressiveChecks = aggressiveChecks || ts.Debug.shouldAssert(2); + checkChangeRange(sourceFile, newText, textChangeRange, aggressiveChecks); + if (ts.textChangeRangeIsUnchanged(textChangeRange)) { + return sourceFile; + } + if (sourceFile.statements.length === 0) { + return Parser.parseSourceFile(sourceFile.fileName, newText, sourceFile.languageVersion, undefined, true); + } + var incrementalSourceFile = sourceFile; + ts.Debug.assert(!incrementalSourceFile.hasBeenIncrementallyParsed); + incrementalSourceFile.hasBeenIncrementallyParsed = true; + var oldText = sourceFile.text; + var syntaxCursor = createSyntaxCursor(sourceFile); + var changeRange = extendToAffectedRange(sourceFile, textChangeRange); + checkChangeRange(sourceFile, newText, changeRange, aggressiveChecks); + ts.Debug.assert(changeRange.span.start <= textChangeRange.span.start); + ts.Debug.assert(ts.textSpanEnd(changeRange.span) === ts.textSpanEnd(textChangeRange.span)); + ts.Debug.assert(ts.textSpanEnd(ts.textChangeRangeNewSpan(changeRange)) === ts.textSpanEnd(ts.textChangeRangeNewSpan(textChangeRange))); + var delta = ts.textChangeRangeNewSpan(changeRange).length - changeRange.span.length; + updateTokenPositionsAndMarkElements(incrementalSourceFile, changeRange.span.start, ts.textSpanEnd(changeRange.span), ts.textSpanEnd(ts.textChangeRangeNewSpan(changeRange)), delta, oldText, newText, aggressiveChecks); + var result = Parser.parseSourceFile(sourceFile.fileName, newText, sourceFile.languageVersion, syntaxCursor, true); + return result; + } + IncrementalParser.updateSourceFile = updateSourceFile; + function moveElementEntirelyPastChangeRange(element, isArray, delta, oldText, newText, aggressiveChecks) { + if (isArray) { + visitArray(element); + } + else { + visitNode(element); + } + return; + function visitNode(node) { + var text = ""; + if (aggressiveChecks && shouldCheckNode(node)) { + text = oldText.substring(node.pos, node.end); + } + if (node._children) { + node._children = undefined; + } + if (node.jsDocComment) { + node.jsDocComment = undefined; + } + node.pos += delta; + node.end += delta; + if (aggressiveChecks && shouldCheckNode(node)) { + ts.Debug.assert(text === newText.substring(node.pos, node.end)); + } + forEachChild(node, visitNode, visitArray); + checkNodePositions(node, aggressiveChecks); + } + function visitArray(array) { + array._children = undefined; + array.pos += delta; + array.end += delta; + for (var _i = 0; _i < array.length; _i++) { + var node = array[_i]; + visitNode(node); + } + } + } + function shouldCheckNode(node) { + switch (node.kind) { + case 9: + case 8: + case 69: + return true; + } + return false; + } + function adjustIntersectingElement(element, changeStart, changeRangeOldEnd, changeRangeNewEnd, delta) { + ts.Debug.assert(element.end >= changeStart, "Adjusting an element that was entirely before the change range"); + ts.Debug.assert(element.pos <= changeRangeOldEnd, "Adjusting an element that was entirely after the change range"); + ts.Debug.assert(element.pos <= element.end); + element.pos = Math.min(element.pos, changeRangeNewEnd); + if (element.end >= changeRangeOldEnd) { + element.end += delta; + } + else { + element.end = Math.min(element.end, changeRangeNewEnd); + } + ts.Debug.assert(element.pos <= element.end); + if (element.parent) { + ts.Debug.assert(element.pos >= element.parent.pos); + ts.Debug.assert(element.end <= element.parent.end); + } + } + function checkNodePositions(node, aggressiveChecks) { + if (aggressiveChecks) { + var pos = node.pos; + forEachChild(node, function (child) { + ts.Debug.assert(child.pos >= pos); + pos = child.end; + }); + ts.Debug.assert(pos <= node.end); + } + } + function updateTokenPositionsAndMarkElements(sourceFile, changeStart, changeRangeOldEnd, changeRangeNewEnd, delta, oldText, newText, aggressiveChecks) { + visitNode(sourceFile); + return; + function visitNode(child) { + ts.Debug.assert(child.pos <= child.end); + if (child.pos > changeRangeOldEnd) { + moveElementEntirelyPastChangeRange(child, false, delta, oldText, newText, aggressiveChecks); + return; + } + var fullEnd = child.end; + if (fullEnd >= changeStart) { + child.intersectsChange = true; + child._children = undefined; + adjustIntersectingElement(child, changeStart, changeRangeOldEnd, changeRangeNewEnd, delta); + forEachChild(child, visitNode, visitArray); + checkNodePositions(child, aggressiveChecks); + return; + } + ts.Debug.assert(fullEnd < changeStart); + } + function visitArray(array) { + ts.Debug.assert(array.pos <= array.end); + if (array.pos > changeRangeOldEnd) { + moveElementEntirelyPastChangeRange(array, true, delta, oldText, newText, aggressiveChecks); + return; + } + var fullEnd = array.end; + if (fullEnd >= changeStart) { + array.intersectsChange = true; + array._children = undefined; + adjustIntersectingElement(array, changeStart, changeRangeOldEnd, changeRangeNewEnd, delta); + for (var _i = 0; _i < array.length; _i++) { + var node = array[_i]; + visitNode(node); + } + return; + } + ts.Debug.assert(fullEnd < changeStart); + } + } + function extendToAffectedRange(sourceFile, changeRange) { + var maxLookahead = 1; + var start = changeRange.span.start; + for (var i = 0; start > 0 && i <= maxLookahead; i++) { + var nearestNode = findNearestNodeStartingBeforeOrAtPosition(sourceFile, start); + ts.Debug.assert(nearestNode.pos <= start); + var position = nearestNode.pos; + start = Math.max(0, position - 1); + } + var finalSpan = ts.createTextSpanFromBounds(start, ts.textSpanEnd(changeRange.span)); + var finalLength = changeRange.newLength + (changeRange.span.start - start); + return ts.createTextChangeRange(finalSpan, finalLength); + } + function findNearestNodeStartingBeforeOrAtPosition(sourceFile, position) { + var bestResult = sourceFile; + var lastNodeEntirelyBeforePosition; + forEachChild(sourceFile, visit); + if (lastNodeEntirelyBeforePosition) { + var lastChildOfLastEntireNodeBeforePosition = getLastChild(lastNodeEntirelyBeforePosition); + if (lastChildOfLastEntireNodeBeforePosition.pos > bestResult.pos) { + bestResult = lastChildOfLastEntireNodeBeforePosition; + } + } + return bestResult; + function getLastChild(node) { + while (true) { + var lastChild = getLastChildWorker(node); + if (lastChild) { + node = lastChild; + } + else { + return node; + } + } + } + function getLastChildWorker(node) { + var last = undefined; + forEachChild(node, function (child) { + if (ts.nodeIsPresent(child)) { + last = child; + } + }); + return last; + } + function visit(child) { + if (ts.nodeIsMissing(child)) { + return; + } + if (child.pos <= position) { + if (child.pos >= bestResult.pos) { + bestResult = child; + } + if (position < child.end) { + forEachChild(child, visit); + return true; + } + else { + ts.Debug.assert(child.end <= position); + lastNodeEntirelyBeforePosition = child; + } + } + else { + ts.Debug.assert(child.pos > position); + return true; + } + } + } + function checkChangeRange(sourceFile, newText, textChangeRange, aggressiveChecks) { + var oldText = sourceFile.text; + if (textChangeRange) { + ts.Debug.assert((oldText.length - textChangeRange.span.length + textChangeRange.newLength) === newText.length); + if (aggressiveChecks || ts.Debug.shouldAssert(3)) { + var oldTextPrefix = oldText.substr(0, textChangeRange.span.start); + var newTextPrefix = newText.substr(0, textChangeRange.span.start); + ts.Debug.assert(oldTextPrefix === newTextPrefix); + var oldTextSuffix = oldText.substring(ts.textSpanEnd(textChangeRange.span), oldText.length); + var newTextSuffix = newText.substring(ts.textSpanEnd(ts.textChangeRangeNewSpan(textChangeRange)), newText.length); + ts.Debug.assert(oldTextSuffix === newTextSuffix); + } + } + } + function createSyntaxCursor(sourceFile) { + var currentArray = sourceFile.statements; + var currentArrayIndex = 0; + ts.Debug.assert(currentArrayIndex < currentArray.length); + var current = currentArray[currentArrayIndex]; + var lastQueriedPosition = -1; + return { + currentNode: function (position) { + if (position !== lastQueriedPosition) { + if (current && current.end === position && currentArrayIndex < (currentArray.length - 1)) { + currentArrayIndex++; + current = currentArray[currentArrayIndex]; + } + if (!current || current.pos !== position) { + findHighestListElementThatStartsAtPosition(position); + } + } + lastQueriedPosition = position; + ts.Debug.assert(!current || current.pos === position); + return current; + } + }; + function findHighestListElementThatStartsAtPosition(position) { + currentArray = undefined; + currentArrayIndex = -1; + current = undefined; + forEachChild(sourceFile, visitNode, visitArray); + return; + function visitNode(node) { + if (position >= node.pos && position < node.end) { + forEachChild(node, visitNode, visitArray); + return true; + } + return false; + } + function visitArray(array) { + if (position >= array.pos && position < array.end) { + for (var i = 0, n = array.length; i < n; i++) { + var child = array[i]; + if (child) { + if (child.pos === position) { + currentArray = array; + currentArrayIndex = i; + current = child; + return true; + } + else { + if (child.pos < position && position < child.end) { + forEachChild(child, visitNode, visitArray); + return true; + } + } + } + } + } + return false; + } + } + } + })(IncrementalParser || (IncrementalParser = {})); +})(ts || (ts = {})); +var ts; +(function (ts) { + var nextSymbolId = 1; + var nextNodeId = 1; + var nextMergeId = 1; + function getNodeId(node) { + if (!node.id) + node.id = nextNodeId++; + return node.id; + } + ts.getNodeId = getNodeId; + ts.checkTime = 0; + function getSymbolId(symbol) { + if (!symbol.id) { + symbol.id = nextSymbolId++; + } + return symbol.id; + } + ts.getSymbolId = getSymbolId; + function createTypeChecker(host, produceDiagnostics) { + var cancellationToken; + var Symbol = ts.objectAllocator.getSymbolConstructor(); + var Type = ts.objectAllocator.getTypeConstructor(); + var Signature = ts.objectAllocator.getSignatureConstructor(); + var typeCount = 0; + var symbolCount = 0; + var emptyArray = []; + var emptySymbols = {}; + var compilerOptions = host.getCompilerOptions(); + var languageVersion = compilerOptions.target || 0; + var modulekind = compilerOptions.module ? compilerOptions.module : languageVersion === 2 ? 5 : 0; + var emitResolver = createResolver(); + var undefinedSymbol = createSymbol(4 | 67108864, "undefined"); + var argumentsSymbol = createSymbol(4 | 67108864, "arguments"); + var checker = { + getNodeCount: function () { return ts.sum(host.getSourceFiles(), "nodeCount"); }, + getIdentifierCount: function () { return ts.sum(host.getSourceFiles(), "identifierCount"); }, + getSymbolCount: function () { return ts.sum(host.getSourceFiles(), "symbolCount") + symbolCount; }, + getTypeCount: function () { return typeCount; }, + isUndefinedSymbol: function (symbol) { return symbol === undefinedSymbol; }, + isArgumentsSymbol: function (symbol) { return symbol === argumentsSymbol; }, + getDiagnostics: getDiagnostics, + getGlobalDiagnostics: getGlobalDiagnostics, + getTypeOfSymbolAtLocation: getNarrowedTypeOfSymbol, + getDeclaredTypeOfSymbol: getDeclaredTypeOfSymbol, + getPropertiesOfType: getPropertiesOfType, + getPropertyOfType: getPropertyOfType, + getSignaturesOfType: getSignaturesOfType, + getIndexTypeOfType: getIndexTypeOfType, + getBaseTypes: getBaseTypes, + getReturnTypeOfSignature: getReturnTypeOfSignature, + getSymbolsInScope: getSymbolsInScope, + getSymbolAtLocation: getSymbolAtLocation, + getShorthandAssignmentValueSymbol: getShorthandAssignmentValueSymbol, + getTypeAtLocation: getTypeOfNode, + typeToString: typeToString, + getSymbolDisplayBuilder: getSymbolDisplayBuilder, + symbolToString: symbolToString, + getAugmentedPropertiesOfType: getAugmentedPropertiesOfType, + getRootSymbols: getRootSymbols, + getContextualType: getContextualType, + getFullyQualifiedName: getFullyQualifiedName, + getResolvedSignature: getResolvedSignature, + getConstantValue: getConstantValue, + isValidPropertyAccess: isValidPropertyAccess, + getSignatureFromDeclaration: getSignatureFromDeclaration, + isImplementationOfOverload: isImplementationOfOverload, + getAliasedSymbol: resolveAlias, + getEmitResolver: getEmitResolver, + getExportsOfModule: getExportsOfModuleAsArray, + getJsxElementAttributesType: getJsxElementAttributesType, + getJsxIntrinsicTagNames: getJsxIntrinsicTagNames, + isOptionalParameter: isOptionalParameter + }; + var unknownSymbol = createSymbol(4 | 67108864, "unknown"); + var resolvingSymbol = createSymbol(67108864, "__resolving__"); + var anyType = createIntrinsicType(1, "any"); + var stringType = createIntrinsicType(2, "string"); + var numberType = createIntrinsicType(4, "number"); + var booleanType = createIntrinsicType(8, "boolean"); + var esSymbolType = createIntrinsicType(16777216, "symbol"); + var voidType = createIntrinsicType(16, "void"); + var undefinedType = createIntrinsicType(32 | 2097152, "undefined"); + var nullType = createIntrinsicType(64 | 2097152, "null"); + var unknownType = createIntrinsicType(1, "unknown"); + var circularType = createIntrinsicType(1, "__circular__"); + var emptyObjectType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); + var emptyGenericType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); + emptyGenericType.instantiations = {}; + var anyFunctionType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); + anyFunctionType.flags |= 8388608; + var noConstraintType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); + var anySignature = createSignature(undefined, undefined, emptyArray, anyType, undefined, 0, false, false); + var unknownSignature = createSignature(undefined, undefined, emptyArray, unknownType, undefined, 0, false, false); + var globals = {}; + var globalESSymbolConstructorSymbol; + var getGlobalPromiseConstructorSymbol; + var globalObjectType; + var globalFunctionType; + var globalArrayType; + var globalStringType; + var globalNumberType; + var globalBooleanType; + var globalRegExpType; + var globalTemplateStringsArrayType; + var globalESSymbolType; + var jsxElementType; + var jsxIntrinsicElementsType; + var globalIterableType; + var globalIteratorType; + var globalIterableIteratorType; + var anyArrayType; + var getGlobalClassDecoratorType; + var getGlobalParameterDecoratorType; + var getGlobalPropertyDecoratorType; + var getGlobalMethodDecoratorType; + var getGlobalTypedPropertyDescriptorType; + var getGlobalPromiseType; + var tryGetGlobalPromiseType; + var getGlobalPromiseLikeType; + var getInstantiatedGlobalPromiseLikeType; + var getGlobalPromiseConstructorLikeType; + var getGlobalThenableType; + var tupleTypes = {}; + var unionTypes = {}; + var intersectionTypes = {}; + var stringLiteralTypes = {}; + var emitExtends = false; + var emitDecorate = false; + var emitParam = false; + var emitAwaiter = false; + var emitGenerator = false; + var resolutionTargets = []; + var resolutionResults = []; + var resolutionPropertyNames = []; + var mergedSymbols = []; + var symbolLinks = []; + var nodeLinks = []; + var potentialThisCollisions = []; + var awaitedTypeStack = []; + var diagnostics = ts.createDiagnosticCollection(); + var primitiveTypeInfo = { + "string": { + type: stringType, + flags: 258 + }, + "number": { + type: numberType, + flags: 132 + }, + "boolean": { + type: booleanType, + flags: 8 + }, + "symbol": { + type: esSymbolType, + flags: 16777216 + } + }; + var JsxNames = { + JSX: "JSX", + IntrinsicElements: "IntrinsicElements", + ElementClass: "ElementClass", + ElementAttributesPropertyNameContainer: "ElementAttributesProperty", + Element: "Element" + }; + var subtypeRelation = {}; + var assignableRelation = {}; + var identityRelation = {}; + var _displayBuilder; + initializeTypeChecker(); + return checker; + function getEmitResolver(sourceFile, cancellationToken) { + getDiagnostics(sourceFile, cancellationToken); + return emitResolver; + } + function error(location, message, arg0, arg1, arg2) { + var diagnostic = location + ? ts.createDiagnosticForNode(location, message, arg0, arg1, arg2) + : ts.createCompilerDiagnostic(message, arg0, arg1, arg2); + diagnostics.add(diagnostic); + } + function createSymbol(flags, name) { + symbolCount++; + return new Symbol(flags, name); + } + function getExcludedSymbolFlags(flags) { + var result = 0; + if (flags & 2) + result |= 107455; + if (flags & 1) + result |= 107454; + if (flags & 4) + result |= 107455; + if (flags & 8) + result |= 107455; + if (flags & 16) + result |= 106927; + if (flags & 32) + result |= 899519; + if (flags & 64) + result |= 792960; + if (flags & 256) + result |= 899327; + if (flags & 128) + result |= 899967; + if (flags & 512) + result |= 106639; + if (flags & 8192) + result |= 99263; + if (flags & 32768) + result |= 41919; + if (flags & 65536) + result |= 74687; + if (flags & 262144) + result |= 530912; + if (flags & 524288) + result |= 793056; + if (flags & 8388608) + result |= 8388608; + return result; + } + function recordMergedSymbol(target, source) { + if (!source.mergeId) + source.mergeId = nextMergeId++; + mergedSymbols[source.mergeId] = target; + } + function cloneSymbol(symbol) { + var result = createSymbol(symbol.flags | 33554432, symbol.name); + result.declarations = symbol.declarations.slice(0); + result.parent = symbol.parent; + if (symbol.valueDeclaration) + result.valueDeclaration = symbol.valueDeclaration; + if (symbol.constEnumOnlyModule) + result.constEnumOnlyModule = true; + if (symbol.members) + result.members = cloneSymbolTable(symbol.members); + if (symbol.exports) + result.exports = cloneSymbolTable(symbol.exports); + recordMergedSymbol(result, symbol); + return result; + } + function mergeSymbol(target, source) { + if (!(target.flags & getExcludedSymbolFlags(source.flags))) { + if (source.flags & 512 && target.flags & 512 && target.constEnumOnlyModule && !source.constEnumOnlyModule) { + target.constEnumOnlyModule = false; + } + target.flags |= source.flags; + if (!target.valueDeclaration && source.valueDeclaration) + target.valueDeclaration = source.valueDeclaration; + ts.forEach(source.declarations, function (node) { + target.declarations.push(node); + }); + if (source.members) { + if (!target.members) + target.members = {}; + mergeSymbolTable(target.members, source.members); + } + if (source.exports) { + if (!target.exports) + target.exports = {}; + mergeSymbolTable(target.exports, source.exports); + } + recordMergedSymbol(target, source); + } + else { + var message = target.flags & 2 || source.flags & 2 + ? ts.Diagnostics.Cannot_redeclare_block_scoped_variable_0 : ts.Diagnostics.Duplicate_identifier_0; + ts.forEach(source.declarations, function (node) { + error(node.name ? node.name : node, message, symbolToString(source)); + }); + ts.forEach(target.declarations, function (node) { + error(node.name ? node.name : node, message, symbolToString(source)); + }); + } + } + function cloneSymbolTable(symbolTable) { + var result = {}; + for (var id in symbolTable) { + if (ts.hasProperty(symbolTable, id)) { + result[id] = symbolTable[id]; + } + } + return result; + } + function mergeSymbolTable(target, source) { + for (var id in source) { + if (ts.hasProperty(source, id)) { + if (!ts.hasProperty(target, id)) { + target[id] = source[id]; + } + else { + var symbol = target[id]; + if (!(symbol.flags & 33554432)) { + target[id] = symbol = cloneSymbol(symbol); + } + mergeSymbol(symbol, source[id]); + } + } + } + } + function getSymbolLinks(symbol) { + if (symbol.flags & 67108864) + return symbol; + var id = getSymbolId(symbol); + return symbolLinks[id] || (symbolLinks[id] = {}); + } + function getNodeLinks(node) { + var nodeId = getNodeId(node); + return nodeLinks[nodeId] || (nodeLinks[nodeId] = {}); + } + function getSourceFile(node) { + return ts.getAncestor(node, 248); + } + function isGlobalSourceFile(node) { + return node.kind === 248 && !ts.isExternalModule(node); + } + function getSymbol(symbols, name, meaning) { + if (meaning && ts.hasProperty(symbols, name)) { + var symbol = symbols[name]; + ts.Debug.assert((symbol.flags & 16777216) === 0, "Should never get an instantiated symbol here."); + if (symbol.flags & meaning) { + return symbol; + } + if (symbol.flags & 8388608) { + var target = resolveAlias(symbol); + if (target === unknownSymbol || target.flags & meaning) { + return symbol; + } + } + } + } + function isBlockScopedNameDeclaredBeforeUse(declaration, usage) { + var declarationFile = ts.getSourceFileOfNode(declaration); + var useFile = ts.getSourceFileOfNode(usage); + if (declarationFile !== useFile) { + if (modulekind || (!compilerOptions.outFile && !compilerOptions.out)) { + return true; + } + var sourceFiles = host.getSourceFiles(); + return ts.indexOf(sourceFiles, declarationFile) <= ts.indexOf(sourceFiles, useFile); + } + if (declaration.pos <= usage.pos) { + return declaration.kind !== 211 || + !isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage); + } + return isUsedInFunctionOrNonStaticProperty(declaration, usage); + function isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage) { + var container = ts.getEnclosingBlockScopeContainer(declaration); + if (declaration.parent.parent.kind === 193 || + declaration.parent.parent.kind === 199) { + return isSameScopeDescendentOf(usage, declaration, container); + } + else if (declaration.parent.parent.kind === 201 || + declaration.parent.parent.kind === 200) { + var expression = declaration.parent.parent.expression; + return isSameScopeDescendentOf(usage, expression, container); + } + } + function isUsedInFunctionOrNonStaticProperty(declaration, usage) { + var container = ts.getEnclosingBlockScopeContainer(declaration); + var current = usage; + while (current) { + if (current === container) { + return false; + } + if (ts.isFunctionLike(current)) { + return true; + } + var initializerOfNonStaticProperty = current.parent && + current.parent.kind === 141 && + (current.parent.flags & 128) === 0 && + current.parent.initializer === current; + if (initializerOfNonStaticProperty) { + return true; + } + current = current.parent; + } + return false; + } + } + function resolveName(location, name, meaning, nameNotFoundMessage, nameArg) { + var result; + var lastLocation; + var propertyWithInvalidInitializer; + var errorLocation = location; + var grandparent; + loop: while (location) { + if (location.locals && !isGlobalSourceFile(location)) { + if (result = getSymbol(location.locals, name, meaning)) { + if (!(meaning & 793056) || + !(result.flags & (793056 & ~262144)) || + !ts.isFunctionLike(location) || + lastLocation === location.body) { + break loop; + } + result = undefined; + } + } + switch (location.kind) { + case 248: + if (!ts.isExternalModule(location)) + break; + case 218: + var moduleExports = getSymbolOfNode(location).exports; + if (location.kind === 248 || + (location.kind === 218 && location.name.kind === 9)) { + if (ts.hasProperty(moduleExports, name) && + moduleExports[name].flags === 8388608 && + ts.getDeclarationOfKind(moduleExports[name], 230)) { + break; + } + result = moduleExports["default"]; + var localSymbol = ts.getLocalSymbolForExportDefault(result); + if (result && localSymbol && (result.flags & meaning) && localSymbol.name === name) { + break loop; + } + result = undefined; + } + if (result = getSymbol(moduleExports, name, meaning & 8914931)) { + break loop; + } + break; + case 217: + if (result = getSymbol(getSymbolOfNode(location).exports, name, meaning & 8)) { + break loop; + } + break; + case 141: + case 140: + if (ts.isClassLike(location.parent) && !(location.flags & 128)) { + var ctor = findConstructorDeclaration(location.parent); + if (ctor && ctor.locals) { + if (getSymbol(ctor.locals, name, meaning & 107455)) { + propertyWithInvalidInitializer = location; + } + } + } + break; + case 214: + case 186: + case 215: + if (result = getSymbol(getSymbolOfNode(location).members, name, meaning & 793056)) { + if (lastLocation && lastLocation.flags & 128) { + error(errorLocation, ts.Diagnostics.Static_members_cannot_reference_class_type_parameters); + return undefined; + } + break loop; + } + if (location.kind === 186 && meaning & 32) { + var className = location.name; + if (className && name === className.text) { + result = location.symbol; + break loop; + } + } + break; + case 136: + grandparent = location.parent.parent; + if (ts.isClassLike(grandparent) || grandparent.kind === 215) { + if (result = getSymbol(getSymbolOfNode(grandparent).members, name, meaning & 793056)) { + error(errorLocation, ts.Diagnostics.A_computed_property_name_cannot_reference_a_type_parameter_from_its_containing_type); + return undefined; + } + } + break; + case 143: + case 142: + case 144: + case 145: + case 146: + case 213: + case 174: + if (meaning & 3 && name === "arguments") { + result = argumentsSymbol; + break loop; + } + break; + case 173: + if (meaning & 3 && name === "arguments") { + result = argumentsSymbol; + break loop; + } + if (meaning & 16) { + var functionName = location.name; + if (functionName && name === functionName.text) { + result = location.symbol; + break loop; + } + } + break; + case 139: + if (location.parent && location.parent.kind === 138) { + location = location.parent; + } + if (location.parent && ts.isClassElement(location.parent)) { + location = location.parent; + } + break; + } + lastLocation = location; + location = location.parent; + } + if (!result) { + result = getSymbol(globals, name, meaning); + } + if (!result) { + if (nameNotFoundMessage) { + error(errorLocation, nameNotFoundMessage, typeof nameArg === "string" ? nameArg : ts.declarationNameToString(nameArg)); + } + return undefined; + } + if (nameNotFoundMessage) { + if (propertyWithInvalidInitializer) { + var propertyName = propertyWithInvalidInitializer.name; + error(errorLocation, ts.Diagnostics.Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor, ts.declarationNameToString(propertyName), typeof nameArg === "string" ? nameArg : ts.declarationNameToString(nameArg)); + return undefined; + } + if (meaning & 2) { + var exportOrLocalSymbol = getExportSymbolOfValueSymbolIfExported(result); + if (exportOrLocalSymbol.flags & 2) { + checkResolvedBlockScopedVariable(exportOrLocalSymbol, errorLocation); + } + } + } + return result; + } + function checkResolvedBlockScopedVariable(result, errorLocation) { + 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 (!isBlockScopedNameDeclaredBeforeUse(ts.getAncestor(declaration, 211), errorLocation)) { + error(errorLocation, ts.Diagnostics.Block_scoped_variable_0_used_before_its_declaration, ts.declarationNameToString(declaration.name)); + } + } + function isSameScopeDescendentOf(initial, parent, stopAt) { + if (!parent) { + return false; + } + for (var current = initial; current && current !== stopAt && !ts.isFunctionLike(current); current = current.parent) { + if (current === parent) { + return true; + } + } + return false; + } + function getAnyImportSyntax(node) { + if (ts.isAliasSymbolDeclaration(node)) { + if (node.kind === 221) { + return node; + } + while (node && node.kind !== 222) { + node = node.parent; + } + return node; + } + } + function getDeclarationOfAliasSymbol(symbol) { + return ts.forEach(symbol.declarations, function (d) { return ts.isAliasSymbolDeclaration(d) ? d : undefined; }); + } + function getTargetOfImportEqualsDeclaration(node) { + if (node.moduleReference.kind === 232) { + return resolveExternalModuleSymbol(resolveExternalModuleName(node, ts.getExternalModuleImportEqualsDeclarationExpression(node))); + } + return getSymbolOfPartOfRightHandSideOfImportEquals(node.moduleReference, node); + } + function getTargetOfImportClause(node) { + var moduleSymbol = resolveExternalModuleName(node, node.parent.moduleSpecifier); + if (moduleSymbol) { + var exportDefaultSymbol = resolveSymbol(moduleSymbol.exports["default"]); + if (!exportDefaultSymbol) { + error(node.name, ts.Diagnostics.Module_0_has_no_default_export, symbolToString(moduleSymbol)); + } + return exportDefaultSymbol; + } + } + function getTargetOfNamespaceImport(node) { + var moduleSpecifier = node.parent.parent.moduleSpecifier; + return resolveESModuleSymbol(resolveExternalModuleName(node, moduleSpecifier), moduleSpecifier); + } + function getMemberOfModuleVariable(moduleSymbol, name) { + if (moduleSymbol.flags & 3) { + var typeAnnotation = moduleSymbol.valueDeclaration.type; + if (typeAnnotation) { + return getPropertyOfType(getTypeFromTypeNode(typeAnnotation), name); + } + } + } + function combineValueAndTypeSymbols(valueSymbol, typeSymbol) { + if (valueSymbol.flags & (793056 | 1536)) { + return valueSymbol; + } + var result = createSymbol(valueSymbol.flags | typeSymbol.flags, valueSymbol.name); + result.declarations = ts.concatenate(valueSymbol.declarations, typeSymbol.declarations); + result.parent = valueSymbol.parent || typeSymbol.parent; + if (valueSymbol.valueDeclaration) + result.valueDeclaration = valueSymbol.valueDeclaration; + if (typeSymbol.members) + result.members = typeSymbol.members; + if (valueSymbol.exports) + result.exports = valueSymbol.exports; + return result; + } + function getExportOfModule(symbol, name) { + if (symbol.flags & 1536) { + var exports = getExportsOfSymbol(symbol); + if (ts.hasProperty(exports, name)) { + return resolveSymbol(exports[name]); + } + } + } + function getPropertyOfVariable(symbol, name) { + if (symbol.flags & 3) { + var typeAnnotation = symbol.valueDeclaration.type; + if (typeAnnotation) { + return resolveSymbol(getPropertyOfType(getTypeFromTypeNode(typeAnnotation), name)); + } + } + } + function getExternalModuleMember(node, specifier) { + var moduleSymbol = resolveExternalModuleName(node, node.moduleSpecifier); + var targetSymbol = resolveESModuleSymbol(moduleSymbol, node.moduleSpecifier); + if (targetSymbol) { + var name_9 = specifier.propertyName || specifier.name; + if (name_9.text) { + var symbolFromModule = getExportOfModule(targetSymbol, name_9.text); + var symbolFromVariable = getPropertyOfVariable(targetSymbol, name_9.text); + var symbol = symbolFromModule && symbolFromVariable ? + combineValueAndTypeSymbols(symbolFromVariable, symbolFromModule) : + symbolFromModule || symbolFromVariable; + if (!symbol) { + error(name_9, ts.Diagnostics.Module_0_has_no_exported_member_1, getFullyQualifiedName(moduleSymbol), ts.declarationNameToString(name_9)); + } + return symbol; + } + } + } + function getTargetOfImportSpecifier(node) { + return getExternalModuleMember(node.parent.parent.parent, node); + } + function getTargetOfExportSpecifier(node) { + return node.parent.parent.moduleSpecifier ? + getExternalModuleMember(node.parent.parent, node) : + resolveEntityName(node.propertyName || node.name, 107455 | 793056 | 1536); + } + function getTargetOfExportAssignment(node) { + return resolveEntityName(node.expression, 107455 | 793056 | 1536); + } + function getTargetOfAliasDeclaration(node) { + switch (node.kind) { + case 221: + return getTargetOfImportEqualsDeclaration(node); + case 223: + return getTargetOfImportClause(node); + case 224: + return getTargetOfNamespaceImport(node); + case 226: + return getTargetOfImportSpecifier(node); + case 230: + return getTargetOfExportSpecifier(node); + case 227: + return getTargetOfExportAssignment(node); + } + } + function resolveSymbol(symbol) { + return symbol && symbol.flags & 8388608 && !(symbol.flags & (107455 | 793056 | 1536)) ? resolveAlias(symbol) : symbol; + } + function resolveAlias(symbol) { + ts.Debug.assert((symbol.flags & 8388608) !== 0, "Should only get Alias here."); + var links = getSymbolLinks(symbol); + if (!links.target) { + links.target = resolvingSymbol; + var node = getDeclarationOfAliasSymbol(symbol); + var target = getTargetOfAliasDeclaration(node); + if (links.target === resolvingSymbol) { + links.target = target || unknownSymbol; + } + else { + error(node, ts.Diagnostics.Circular_definition_of_import_alias_0, symbolToString(symbol)); + } + } + else if (links.target === resolvingSymbol) { + links.target = unknownSymbol; + } + return links.target; + } + function markExportAsReferenced(node) { + var symbol = getSymbolOfNode(node); + var target = resolveAlias(symbol); + if (target) { + var markAlias = (target === unknownSymbol && compilerOptions.isolatedModules) || + (target !== unknownSymbol && (target.flags & 107455) && !isConstEnumOrConstEnumOnlyModule(target)); + if (markAlias) { + markAliasSymbolAsReferenced(symbol); + } + } + } + function markAliasSymbolAsReferenced(symbol) { + var links = getSymbolLinks(symbol); + if (!links.referenced) { + links.referenced = true; + var node = getDeclarationOfAliasSymbol(symbol); + if (node.kind === 227) { + checkExpressionCached(node.expression); + } + else if (node.kind === 230) { + checkExpressionCached(node.propertyName || node.name); + } + else if (ts.isInternalModuleImportEqualsDeclaration(node)) { + checkExpressionCached(node.moduleReference); + } + } + } + function getSymbolOfPartOfRightHandSideOfImportEquals(entityName, importDeclaration) { + if (!importDeclaration) { + importDeclaration = ts.getAncestor(entityName, 221); + ts.Debug.assert(importDeclaration !== undefined); + } + if (entityName.kind === 69 && ts.isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { + entityName = entityName.parent; + } + if (entityName.kind === 69 || entityName.parent.kind === 135) { + return resolveEntityName(entityName, 1536); + } + else { + ts.Debug.assert(entityName.parent.kind === 221); + return resolveEntityName(entityName, 107455 | 793056 | 1536); + } + } + function getFullyQualifiedName(symbol) { + return symbol.parent ? getFullyQualifiedName(symbol.parent) + "." + symbolToString(symbol) : symbolToString(symbol); + } + function resolveEntityName(name, meaning, ignoreErrors) { + if (ts.nodeIsMissing(name)) { + return undefined; + } + var symbol; + if (name.kind === 69) { + var message = meaning === 1536 ? ts.Diagnostics.Cannot_find_namespace_0 : ts.Diagnostics.Cannot_find_name_0; + symbol = resolveName(name, name.text, meaning, ignoreErrors ? undefined : message, name); + if (!symbol) { + return undefined; + } + } + else if (name.kind === 135 || name.kind === 166) { + var left = name.kind === 135 ? name.left : name.expression; + var right = name.kind === 135 ? name.right : name.name; + var namespace = resolveEntityName(left, 1536, ignoreErrors); + if (!namespace || namespace === unknownSymbol || ts.nodeIsMissing(right)) { + return undefined; + } + symbol = getSymbol(getExportsOfSymbol(namespace), right.text, meaning); + if (!symbol) { + if (!ignoreErrors) { + error(right, ts.Diagnostics.Module_0_has_no_exported_member_1, getFullyQualifiedName(namespace), ts.declarationNameToString(right)); + } + return undefined; + } + } + else { + ts.Debug.fail("Unknown entity name kind."); + } + ts.Debug.assert((symbol.flags & 16777216) === 0, "Should never get an instantiated symbol here."); + return symbol.flags & meaning ? symbol : resolveAlias(symbol); + } + function resolveExternalModuleName(location, moduleReferenceExpression) { + if (moduleReferenceExpression.kind !== 9) { + return; + } + var moduleReferenceLiteral = moduleReferenceExpression; + var searchPath = ts.getDirectoryPath(getSourceFile(location).fileName); + var moduleName = ts.escapeIdentifier(moduleReferenceLiteral.text); + if (moduleName === undefined) { + return; + } + var isRelative = ts.isExternalModuleNameRelative(moduleName); + if (!isRelative) { + var symbol = getSymbol(globals, "\"" + moduleName + "\"", 512); + if (symbol) { + return symbol; + } + } + var resolvedModule = ts.getResolvedModule(getSourceFile(location), moduleReferenceLiteral.text); + var sourceFile = resolvedModule && host.getSourceFile(resolvedModule.resolvedFileName); + if (sourceFile) { + if (sourceFile.symbol) { + return sourceFile.symbol; + } + error(moduleReferenceLiteral, ts.Diagnostics.File_0_is_not_a_module, sourceFile.fileName); + return; + } + error(moduleReferenceLiteral, ts.Diagnostics.Cannot_find_module_0, moduleName); + } + function resolveExternalModuleSymbol(moduleSymbol) { + return moduleSymbol && resolveSymbol(moduleSymbol.exports["export="]) || moduleSymbol; + } + function resolveESModuleSymbol(moduleSymbol, moduleReferenceExpression) { + var symbol = resolveExternalModuleSymbol(moduleSymbol); + if (symbol && !(symbol.flags & (1536 | 3))) { + error(moduleReferenceExpression, ts.Diagnostics.Module_0_resolves_to_a_non_module_entity_and_cannot_be_imported_using_this_construct, symbolToString(moduleSymbol)); + symbol = undefined; + } + return symbol; + } + function getExportAssignmentSymbol(moduleSymbol) { + return moduleSymbol.exports["export="]; + } + function getExportsOfModuleAsArray(moduleSymbol) { + return symbolsToArray(getExportsOfModule(moduleSymbol)); + } + function getExportsOfSymbol(symbol) { + return symbol.flags & 1536 ? getExportsOfModule(symbol) : symbol.exports || emptySymbols; + } + function getExportsOfModule(moduleSymbol) { + var links = getSymbolLinks(moduleSymbol); + return links.resolvedExports || (links.resolvedExports = getExportsForModule(moduleSymbol)); + } + function extendExportSymbols(target, source) { + for (var id in source) { + if (id !== "default" && !ts.hasProperty(target, id)) { + target[id] = source[id]; + } + } + } + function getExportsForModule(moduleSymbol) { + var result; + var visitedSymbols = []; + visit(moduleSymbol); + return result || moduleSymbol.exports; + function visit(symbol) { + if (symbol && symbol.flags & 1952 && !ts.contains(visitedSymbols, symbol)) { + visitedSymbols.push(symbol); + if (symbol !== moduleSymbol) { + if (!result) { + result = cloneSymbolTable(moduleSymbol.exports); + } + extendExportSymbols(result, symbol.exports); + } + var exportStars = symbol.exports["__export"]; + if (exportStars) { + for (var _i = 0, _a = exportStars.declarations; _i < _a.length; _i++) { + var node = _a[_i]; + visit(resolveExternalModuleName(node, node.moduleSpecifier)); + } + } + } + } + } + function getMergedSymbol(symbol) { + var merged; + return symbol && symbol.mergeId && (merged = mergedSymbols[symbol.mergeId]) ? merged : symbol; + } + function getSymbolOfNode(node) { + return getMergedSymbol(node.symbol); + } + function getParentOfSymbol(symbol) { + return getMergedSymbol(symbol.parent); + } + function getExportSymbolOfValueSymbolIfExported(symbol) { + return symbol && (symbol.flags & 1048576) !== 0 + ? getMergedSymbol(symbol.exportSymbol) + : symbol; + } + function symbolIsValue(symbol) { + if (symbol.flags & 16777216) { + return symbolIsValue(getSymbolLinks(symbol).target); + } + if (symbol.flags & 107455) { + return true; + } + if (symbol.flags & 8388608) { + return (resolveAlias(symbol).flags & 107455) !== 0; + } + return false; + } + function findConstructorDeclaration(node) { + var members = node.members; + for (var _i = 0; _i < members.length; _i++) { + var member = members[_i]; + if (member.kind === 144 && ts.nodeIsPresent(member.body)) { + return member; + } + } + } + function createType(flags) { + var result = new Type(checker, flags); + result.id = typeCount++; + return result; + } + function createIntrinsicType(kind, intrinsicName) { + var type = createType(kind); + type.intrinsicName = intrinsicName; + return type; + } + function createObjectType(kind, symbol) { + var type = createType(kind); + type.symbol = symbol; + return type; + } + function isReservedMemberName(name) { + return name.charCodeAt(0) === 95 && + name.charCodeAt(1) === 95 && + name.charCodeAt(2) !== 95 && + name.charCodeAt(2) !== 64; + } + function getNamedMembers(members) { + var result; + for (var id in members) { + if (ts.hasProperty(members, id)) { + if (!isReservedMemberName(id)) { + if (!result) + result = []; + var symbol = members[id]; + if (symbolIsValue(symbol)) { + result.push(symbol); + } + } + } + } + return result || emptyArray; + } + function setObjectTypeMembers(type, members, callSignatures, constructSignatures, stringIndexType, numberIndexType) { + type.members = members; + type.properties = getNamedMembers(members); + type.callSignatures = callSignatures; + type.constructSignatures = constructSignatures; + if (stringIndexType) + type.stringIndexType = stringIndexType; + if (numberIndexType) + type.numberIndexType = numberIndexType; + return type; + } + function createAnonymousType(symbol, members, callSignatures, constructSignatures, stringIndexType, numberIndexType) { + return setObjectTypeMembers(createObjectType(65536, symbol), members, callSignatures, constructSignatures, stringIndexType, numberIndexType); + } + function forEachSymbolTableInScope(enclosingDeclaration, callback) { + var result; + for (var location_1 = enclosingDeclaration; location_1; location_1 = location_1.parent) { + if (location_1.locals && !isGlobalSourceFile(location_1)) { + if (result = callback(location_1.locals)) { + return result; + } + } + switch (location_1.kind) { + case 248: + if (!ts.isExternalModule(location_1)) { + break; + } + case 218: + if (result = callback(getSymbolOfNode(location_1).exports)) { + return result; + } + break; + case 214: + case 215: + if (result = callback(getSymbolOfNode(location_1).members)) { + return result; + } + break; + } + } + return callback(globals); + } + function getQualifiedLeftMeaning(rightMeaning) { + return rightMeaning === 107455 ? 107455 : 1536; + } + function getAccessibleSymbolChain(symbol, enclosingDeclaration, meaning, useOnlyExternalAliasing) { + function getAccessibleSymbolChainFromSymbolTable(symbols) { + function canQualifySymbol(symbolFromSymbolTable, meaning) { + if (!needsQualification(symbolFromSymbolTable, enclosingDeclaration, meaning)) { + return true; + } + var accessibleParent = getAccessibleSymbolChain(symbolFromSymbolTable.parent, enclosingDeclaration, getQualifiedLeftMeaning(meaning), useOnlyExternalAliasing); + return !!accessibleParent; + } + function isAccessible(symbolFromSymbolTable, resolvedAliasSymbol) { + if (symbol === (resolvedAliasSymbol || symbolFromSymbolTable)) { + return !ts.forEach(symbolFromSymbolTable.declarations, hasExternalModuleSymbol) && + canQualifySymbol(symbolFromSymbolTable, meaning); + } + } + if (isAccessible(ts.lookUp(symbols, symbol.name))) { + return [symbol]; + } + return ts.forEachValue(symbols, function (symbolFromSymbolTable) { + if (symbolFromSymbolTable.flags & 8388608 + && symbolFromSymbolTable.name !== "export=" + && !ts.getDeclarationOfKind(symbolFromSymbolTable, 230)) { + if (!useOnlyExternalAliasing || + ts.forEach(symbolFromSymbolTable.declarations, ts.isExternalModuleImportEqualsDeclaration)) { + var resolvedImportedSymbol = resolveAlias(symbolFromSymbolTable); + if (isAccessible(symbolFromSymbolTable, resolveAlias(symbolFromSymbolTable))) { + return [symbolFromSymbolTable]; + } + var accessibleSymbolsFromExports = resolvedImportedSymbol.exports ? getAccessibleSymbolChainFromSymbolTable(resolvedImportedSymbol.exports) : undefined; + if (accessibleSymbolsFromExports && canQualifySymbol(symbolFromSymbolTable, getQualifiedLeftMeaning(meaning))) { + return [symbolFromSymbolTable].concat(accessibleSymbolsFromExports); + } + } + } + }); + } + if (symbol) { + return forEachSymbolTableInScope(enclosingDeclaration, getAccessibleSymbolChainFromSymbolTable); + } + } + function needsQualification(symbol, enclosingDeclaration, meaning) { + var qualify = false; + forEachSymbolTableInScope(enclosingDeclaration, function (symbolTable) { + if (!ts.hasProperty(symbolTable, symbol.name)) { + return false; + } + var symbolFromSymbolTable = symbolTable[symbol.name]; + if (symbolFromSymbolTable === symbol) { + return true; + } + symbolFromSymbolTable = (symbolFromSymbolTable.flags & 8388608 && !ts.getDeclarationOfKind(symbolFromSymbolTable, 230)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; + if (symbolFromSymbolTable.flags & meaning) { + qualify = true; + return true; + } + return false; + }); + return qualify; + } + function isSymbolAccessible(symbol, enclosingDeclaration, meaning) { + if (symbol && enclosingDeclaration && !(symbol.flags & 262144)) { + var initialSymbol = symbol; + var meaningToLook = meaning; + while (symbol) { + var accessibleSymbolChain = getAccessibleSymbolChain(symbol, enclosingDeclaration, meaningToLook, false); + if (accessibleSymbolChain) { + var hasAccessibleDeclarations = hasVisibleDeclarations(accessibleSymbolChain[0]); + if (!hasAccessibleDeclarations) { + return { + accessibility: 1, + errorSymbolName: symbolToString(initialSymbol, enclosingDeclaration, meaning), + errorModuleName: symbol !== initialSymbol ? symbolToString(symbol, enclosingDeclaration, 1536) : undefined + }; + } + return hasAccessibleDeclarations; + } + meaningToLook = getQualifiedLeftMeaning(meaning); + symbol = getParentOfSymbol(symbol); + } + var symbolExternalModule = ts.forEach(initialSymbol.declarations, getExternalModuleContainer); + if (symbolExternalModule) { + var enclosingExternalModule = getExternalModuleContainer(enclosingDeclaration); + if (symbolExternalModule !== enclosingExternalModule) { + return { + accessibility: 2, + errorSymbolName: symbolToString(initialSymbol, enclosingDeclaration, meaning), + errorModuleName: symbolToString(symbolExternalModule) + }; + } + } + return { + accessibility: 1, + errorSymbolName: symbolToString(initialSymbol, enclosingDeclaration, meaning) + }; + } + return { accessibility: 0 }; + function getExternalModuleContainer(declaration) { + for (; declaration; declaration = declaration.parent) { + if (hasExternalModuleSymbol(declaration)) { + return getSymbolOfNode(declaration); + } + } + } + } + function hasExternalModuleSymbol(declaration) { + return (declaration.kind === 218 && declaration.name.kind === 9) || + (declaration.kind === 248 && ts.isExternalModule(declaration)); + } + function hasVisibleDeclarations(symbol) { + var aliasesToMakeVisible; + if (ts.forEach(symbol.declarations, function (declaration) { return !getIsDeclarationVisible(declaration); })) { + return undefined; + } + return { accessibility: 0, aliasesToMakeVisible: aliasesToMakeVisible }; + function getIsDeclarationVisible(declaration) { + if (!isDeclarationVisible(declaration)) { + var anyImportSyntax = getAnyImportSyntax(declaration); + if (anyImportSyntax && + !(anyImportSyntax.flags & 1) && + isDeclarationVisible(anyImportSyntax.parent)) { + getNodeLinks(declaration).isVisible = true; + if (aliasesToMakeVisible) { + if (!ts.contains(aliasesToMakeVisible, anyImportSyntax)) { + aliasesToMakeVisible.push(anyImportSyntax); + } + } + else { + aliasesToMakeVisible = [anyImportSyntax]; + } + return true; + } + return false; + } + return true; + } + } + function isEntityNameVisible(entityName, enclosingDeclaration) { + var meaning; + if (entityName.parent.kind === 154) { + meaning = 107455 | 1048576; + } + else if (entityName.kind === 135 || entityName.kind === 166 || + entityName.parent.kind === 221) { + meaning = 1536; + } + else { + meaning = 793056; + } + var firstIdentifier = getFirstIdentifier(entityName); + var symbol = resolveName(enclosingDeclaration, firstIdentifier.text, meaning, undefined, undefined); + return (symbol && hasVisibleDeclarations(symbol)) || { + accessibility: 1, + errorSymbolName: ts.getTextOfNode(firstIdentifier), + errorNode: firstIdentifier + }; + } + function writeKeyword(writer, kind) { + writer.writeKeyword(ts.tokenToString(kind)); + } + function writePunctuation(writer, kind) { + writer.writePunctuation(ts.tokenToString(kind)); + } + function writeSpace(writer) { + writer.writeSpace(" "); + } + function symbolToString(symbol, enclosingDeclaration, meaning) { + var writer = ts.getSingleLineStringWriter(); + getSymbolDisplayBuilder().buildSymbolDisplay(symbol, writer, enclosingDeclaration, meaning); + var result = writer.string(); + ts.releaseStringWriter(writer); + return result; + } + function signatureToString(signature, enclosingDeclaration, flags) { + var writer = ts.getSingleLineStringWriter(); + getSymbolDisplayBuilder().buildSignatureDisplay(signature, writer, enclosingDeclaration, flags); + var result = writer.string(); + ts.releaseStringWriter(writer); + return result; + } + function typeToString(type, enclosingDeclaration, flags) { + var writer = ts.getSingleLineStringWriter(); + getSymbolDisplayBuilder().buildTypeDisplay(type, writer, enclosingDeclaration, flags); + var result = writer.string(); + ts.releaseStringWriter(writer); + var maxLength = compilerOptions.noErrorTruncation || flags & 4 ? undefined : 100; + if (maxLength && result.length >= maxLength) { + result = result.substr(0, maxLength - "...".length) + "..."; + } + return result; + } + function getTypeAliasForTypeLiteral(type) { + if (type.symbol && type.symbol.flags & 2048) { + var node = type.symbol.declarations[0].parent; + while (node.kind === 160) { + node = node.parent; + } + if (node.kind === 216) { + return getSymbolOfNode(node); + } + } + return undefined; + } + function getSymbolDisplayBuilder() { + function getNameOfSymbol(symbol) { + if (symbol.declarations && symbol.declarations.length) { + var declaration = symbol.declarations[0]; + if (declaration.name) { + return ts.declarationNameToString(declaration.name); + } + switch (declaration.kind) { + case 186: + return "(Anonymous class)"; + case 173: + case 174: + return "(Anonymous function)"; + } + } + return symbol.name; + } + function appendSymbolNameOnly(symbol, writer) { + writer.writeSymbol(getNameOfSymbol(symbol), symbol); + } + function buildSymbolDisplay(symbol, writer, enclosingDeclaration, meaning, flags, typeFlags) { + var parentSymbol; + function appendParentTypeArgumentsAndSymbolName(symbol) { + if (parentSymbol) { + if (flags & 1) { + if (symbol.flags & 16777216) { + buildDisplayForTypeArgumentsAndDelimiters(getTypeParametersOfClassOrInterface(parentSymbol), symbol.mapper, writer, enclosingDeclaration); + } + else { + buildTypeParameterDisplayFromSymbol(parentSymbol, writer, enclosingDeclaration); + } + } + writePunctuation(writer, 21); + } + parentSymbol = symbol; + appendSymbolNameOnly(symbol, writer); + } + writer.trackSymbol(symbol, enclosingDeclaration, meaning); + function walkSymbol(symbol, meaning) { + if (symbol) { + var accessibleSymbolChain = getAccessibleSymbolChain(symbol, enclosingDeclaration, meaning, !!(flags & 2)); + if (!accessibleSymbolChain || + needsQualification(accessibleSymbolChain[0], enclosingDeclaration, accessibleSymbolChain.length === 1 ? meaning : getQualifiedLeftMeaning(meaning))) { + walkSymbol(getParentOfSymbol(accessibleSymbolChain ? accessibleSymbolChain[0] : symbol), getQualifiedLeftMeaning(meaning)); + } + if (accessibleSymbolChain) { + for (var _i = 0; _i < accessibleSymbolChain.length; _i++) { + var accessibleSymbol = accessibleSymbolChain[_i]; + appendParentTypeArgumentsAndSymbolName(accessibleSymbol); + } + } + else { + if (!parentSymbol && ts.forEach(symbol.declarations, hasExternalModuleSymbol)) { + return; + } + if (symbol.flags & 2048 || symbol.flags & 4096) { + return; + } + appendParentTypeArgumentsAndSymbolName(symbol); + } + } + } + var isTypeParameter = symbol.flags & 262144; + var typeFormatFlag = 128 & typeFlags; + if (!isTypeParameter && (enclosingDeclaration || typeFormatFlag)) { + walkSymbol(symbol, meaning); + return; + } + return appendParentTypeArgumentsAndSymbolName(symbol); + } + function buildTypeDisplay(type, writer, enclosingDeclaration, globalFlags, symbolStack) { + var globalFlagsToPass = globalFlags & 16; + var inObjectTypeLiteral = false; + return writeType(type, globalFlags); + function writeType(type, flags) { + if (type.flags & 16777343) { + writer.writeKeyword(!(globalFlags & 16) && isTypeAny(type) + ? "any" + : type.intrinsicName); + } + else if (type.flags & 33554432) { + if (inObjectTypeLiteral) { + writer.reportInaccessibleThisError(); + } + writer.writeKeyword("this"); + } + else if (type.flags & 4096) { + writeTypeReference(type, flags); + } + else if (type.flags & (1024 | 2048 | 128 | 512)) { + buildSymbolDisplay(type.symbol, writer, enclosingDeclaration, 793056, 0, flags); + } + else if (type.flags & 8192) { + writeTupleType(type); + } + else if (type.flags & 49152) { + writeUnionOrIntersectionType(type, flags); + } + else if (type.flags & 65536) { + writeAnonymousType(type, flags); + } + else if (type.flags & 256) { + writer.writeStringLiteral(type.text); + } + else { + writePunctuation(writer, 15); + writeSpace(writer); + writePunctuation(writer, 22); + writeSpace(writer); + writePunctuation(writer, 16); + } + } + function writeTypeList(types, delimiter) { + for (var i = 0; i < types.length; i++) { + if (i > 0) { + if (delimiter !== 24) { + writeSpace(writer); + } + writePunctuation(writer, delimiter); + writeSpace(writer); + } + writeType(types[i], delimiter === 24 ? 0 : 64); + } + } + function writeSymbolTypeReference(symbol, typeArguments, pos, end, flags) { + if (symbol.flags & 32 || !isReservedMemberName(symbol.name)) { + buildSymbolDisplay(symbol, writer, enclosingDeclaration, 793056, 0, flags); + } + if (pos < end) { + writePunctuation(writer, 25); + writeType(typeArguments[pos++], 0); + while (pos < end) { + writePunctuation(writer, 24); + writeSpace(writer); + writeType(typeArguments[pos++], 0); + } + writePunctuation(writer, 27); + } + } + 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); + } + else { + var outerTypeParameters = type.target.outerTypeParameters; + var i = 0; + if (outerTypeParameters) { + var length_1 = outerTypeParameters.length; + while (i < length_1) { + var start = i; + var parent_3 = getParentSymbolOfTypeParameter(outerTypeParameters[i]); + do { + i++; + } while (i < length_1 && getParentSymbolOfTypeParameter(outerTypeParameters[i]) === parent_3); + if (!ts.rangeEquals(outerTypeParameters, typeArguments, start, i)) { + writeSymbolTypeReference(parent_3, typeArguments, start, i, flags); + writePunctuation(writer, 21); + } + } + } + var typeParameterCount = (type.target.typeParameters || emptyArray).length; + writeSymbolTypeReference(type.symbol, typeArguments, i, typeParameterCount, flags); + } + } + function writeTupleType(type) { + writePunctuation(writer, 19); + writeTypeList(type.elementTypes, 24); + writePunctuation(writer, 20); + } + function writeUnionOrIntersectionType(type, flags) { + if (flags & 64) { + writePunctuation(writer, 17); + } + writeTypeList(type.types, type.flags & 16384 ? 47 : 46); + if (flags & 64) { + writePunctuation(writer, 18); + } + } + function writeAnonymousType(type, flags) { + var symbol = type.symbol; + if (symbol) { + if (symbol.flags & (32 | 384 | 512)) { + writeTypeofSymbol(type, flags); + } + else if (shouldWriteTypeOfFunctionSymbol()) { + writeTypeofSymbol(type, flags); + } + else if (ts.contains(symbolStack, symbol)) { + var typeAlias = getTypeAliasForTypeLiteral(type); + if (typeAlias) { + buildSymbolDisplay(typeAlias, writer, enclosingDeclaration, 793056, 0, flags); + } + else { + writeKeyword(writer, 117); + } + } + else { + if (!symbolStack) { + symbolStack = []; + } + symbolStack.push(symbol); + writeLiteralType(type, flags); + symbolStack.pop(); + } + } + else { + writeLiteralType(type, flags); + } + function shouldWriteTypeOfFunctionSymbol() { + var isStaticMethodSymbol = !!(symbol.flags & 8192 && + ts.forEach(symbol.declarations, function (declaration) { return declaration.flags & 128; })); + var isNonLocalFunctionSymbol = !!(symbol.flags & 16) && + (symbol.parent || + ts.forEach(symbol.declarations, function (declaration) { + return declaration.parent.kind === 248 || declaration.parent.kind === 219; + })); + if (isStaticMethodSymbol || isNonLocalFunctionSymbol) { + return !!(flags & 2) || + (ts.contains(symbolStack, symbol)); + } + } + } + function writeTypeofSymbol(type, typeFormatFlags) { + writeKeyword(writer, 101); + writeSpace(writer); + buildSymbolDisplay(type.symbol, writer, enclosingDeclaration, 107455, 0, typeFormatFlags); + } + function getIndexerParameterName(type, indexKind, fallbackName) { + var declaration = getIndexDeclarationOfSymbol(type.symbol, indexKind); + if (!declaration) { + return fallbackName; + } + ts.Debug.assert(declaration.parameters.length !== 0); + return ts.declarationNameToString(declaration.parameters[0].name); + } + function writeLiteralType(type, flags) { + var resolved = resolveStructuredTypeMembers(type); + if (!resolved.properties.length && !resolved.stringIndexType && !resolved.numberIndexType) { + if (!resolved.callSignatures.length && !resolved.constructSignatures.length) { + writePunctuation(writer, 15); + writePunctuation(writer, 16); + return; + } + if (resolved.callSignatures.length === 1 && !resolved.constructSignatures.length) { + if (flags & 64) { + writePunctuation(writer, 17); + } + buildSignatureDisplay(resolved.callSignatures[0], writer, enclosingDeclaration, globalFlagsToPass | 8, symbolStack); + if (flags & 64) { + writePunctuation(writer, 18); + } + return; + } + if (resolved.constructSignatures.length === 1 && !resolved.callSignatures.length) { + if (flags & 64) { + writePunctuation(writer, 17); + } + writeKeyword(writer, 92); + writeSpace(writer); + buildSignatureDisplay(resolved.constructSignatures[0], writer, enclosingDeclaration, globalFlagsToPass | 8, symbolStack); + if (flags & 64) { + writePunctuation(writer, 18); + } + return; + } + } + var saveInObjectTypeLiteral = inObjectTypeLiteral; + inObjectTypeLiteral = true; + writePunctuation(writer, 15); + writer.writeLine(); + writer.increaseIndent(); + for (var _i = 0, _a = resolved.callSignatures; _i < _a.length; _i++) { + var signature = _a[_i]; + buildSignatureDisplay(signature, writer, enclosingDeclaration, globalFlagsToPass, symbolStack); + writePunctuation(writer, 23); + writer.writeLine(); + } + for (var _b = 0, _c = resolved.constructSignatures; _b < _c.length; _b++) { + var signature = _c[_b]; + writeKeyword(writer, 92); + writeSpace(writer); + buildSignatureDisplay(signature, writer, enclosingDeclaration, globalFlagsToPass, symbolStack); + writePunctuation(writer, 23); + writer.writeLine(); + } + if (resolved.stringIndexType) { + writePunctuation(writer, 19); + writer.writeParameter(getIndexerParameterName(resolved, 0, "x")); + writePunctuation(writer, 54); + writeSpace(writer); + writeKeyword(writer, 130); + writePunctuation(writer, 20); + writePunctuation(writer, 54); + writeSpace(writer); + writeType(resolved.stringIndexType, 0); + writePunctuation(writer, 23); + writer.writeLine(); + } + if (resolved.numberIndexType) { + writePunctuation(writer, 19); + writer.writeParameter(getIndexerParameterName(resolved, 1, "x")); + writePunctuation(writer, 54); + writeSpace(writer); + writeKeyword(writer, 128); + writePunctuation(writer, 20); + writePunctuation(writer, 54); + writeSpace(writer); + writeType(resolved.numberIndexType, 0); + writePunctuation(writer, 23); + writer.writeLine(); + } + for (var _d = 0, _e = resolved.properties; _d < _e.length; _d++) { + var p = _e[_d]; + var t = getTypeOfSymbol(p); + if (p.flags & (16 | 8192) && !getPropertiesOfObjectType(t).length) { + var signatures = getSignaturesOfType(t, 0); + for (var _f = 0; _f < signatures.length; _f++) { + var signature = signatures[_f]; + buildSymbolDisplay(p, writer); + if (p.flags & 536870912) { + writePunctuation(writer, 53); + } + buildSignatureDisplay(signature, writer, enclosingDeclaration, globalFlagsToPass, symbolStack); + writePunctuation(writer, 23); + writer.writeLine(); + } + } + else { + buildSymbolDisplay(p, writer); + if (p.flags & 536870912) { + writePunctuation(writer, 53); + } + writePunctuation(writer, 54); + writeSpace(writer); + writeType(t, 0); + writePunctuation(writer, 23); + writer.writeLine(); + } + } + writer.decreaseIndent(); + writePunctuation(writer, 16); + inObjectTypeLiteral = saveInObjectTypeLiteral; + } + } + function buildTypeParameterDisplayFromSymbol(symbol, writer, enclosingDeclaraiton, flags) { + var targetSymbol = getTargetSymbol(symbol); + if (targetSymbol.flags & 32 || targetSymbol.flags & 64 || targetSymbol.flags & 524288) { + buildDisplayForTypeParametersAndDelimiters(getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol), writer, enclosingDeclaraiton, flags); + } + } + function buildTypeParameterDisplay(tp, writer, enclosingDeclaration, flags, symbolStack) { + appendSymbolNameOnly(tp.symbol, writer); + var constraint = getConstraintOfTypeParameter(tp); + if (constraint) { + writeSpace(writer); + writeKeyword(writer, 83); + writeSpace(writer); + buildTypeDisplay(constraint, writer, enclosingDeclaration, flags, symbolStack); + } + } + function buildParameterDisplay(p, writer, enclosingDeclaration, flags, symbolStack) { + var parameterNode = p.valueDeclaration; + if (ts.isRestParameter(parameterNode)) { + writePunctuation(writer, 22); + } + appendSymbolNameOnly(p, writer); + if (isOptionalParameter(parameterNode)) { + writePunctuation(writer, 53); + } + writePunctuation(writer, 54); + writeSpace(writer); + buildTypeDisplay(getTypeOfSymbol(p), writer, enclosingDeclaration, flags, symbolStack); + } + function buildDisplayForTypeParametersAndDelimiters(typeParameters, writer, enclosingDeclaration, flags, symbolStack) { + if (typeParameters && typeParameters.length) { + writePunctuation(writer, 25); + for (var i = 0; i < typeParameters.length; i++) { + if (i > 0) { + writePunctuation(writer, 24); + writeSpace(writer); + } + buildTypeParameterDisplay(typeParameters[i], writer, enclosingDeclaration, flags, symbolStack); + } + writePunctuation(writer, 27); + } + } + function buildDisplayForTypeArgumentsAndDelimiters(typeParameters, mapper, writer, enclosingDeclaration, flags, symbolStack) { + if (typeParameters && typeParameters.length) { + writePunctuation(writer, 25); + for (var i = 0; i < typeParameters.length; i++) { + if (i > 0) { + writePunctuation(writer, 24); + writeSpace(writer); + } + buildTypeDisplay(mapper(typeParameters[i]), writer, enclosingDeclaration, 0); + } + writePunctuation(writer, 27); + } + } + function buildDisplayForParametersAndDelimiters(parameters, writer, enclosingDeclaration, flags, symbolStack) { + writePunctuation(writer, 17); + for (var i = 0; i < parameters.length; i++) { + if (i > 0) { + writePunctuation(writer, 24); + writeSpace(writer); + } + buildParameterDisplay(parameters[i], writer, enclosingDeclaration, flags, symbolStack); + } + writePunctuation(writer, 18); + } + function buildReturnTypeDisplay(signature, writer, enclosingDeclaration, flags, symbolStack) { + if (flags & 8) { + writeSpace(writer); + writePunctuation(writer, 34); + } + else { + writePunctuation(writer, 54); + } + writeSpace(writer); + var returnType; + if (signature.typePredicate) { + writer.writeParameter(signature.typePredicate.parameterName); + writeSpace(writer); + writeKeyword(writer, 124); + writeSpace(writer); + returnType = signature.typePredicate.type; + } + else { + returnType = getReturnTypeOfSignature(signature); + } + buildTypeDisplay(returnType, writer, enclosingDeclaration, flags, symbolStack); + } + function buildSignatureDisplay(signature, writer, enclosingDeclaration, flags, symbolStack) { + if (signature.target && (flags & 32)) { + buildDisplayForTypeArgumentsAndDelimiters(signature.target.typeParameters, signature.mapper, writer, enclosingDeclaration); + } + else { + buildDisplayForTypeParametersAndDelimiters(signature.typeParameters, writer, enclosingDeclaration, flags, symbolStack); + } + buildDisplayForParametersAndDelimiters(signature.parameters, writer, enclosingDeclaration, flags, symbolStack); + buildReturnTypeDisplay(signature, writer, enclosingDeclaration, flags, symbolStack); + } + return _displayBuilder || (_displayBuilder = { + buildSymbolDisplay: buildSymbolDisplay, + buildTypeDisplay: buildTypeDisplay, + buildTypeParameterDisplay: buildTypeParameterDisplay, + buildParameterDisplay: buildParameterDisplay, + buildDisplayForParametersAndDelimiters: buildDisplayForParametersAndDelimiters, + buildDisplayForTypeParametersAndDelimiters: buildDisplayForTypeParametersAndDelimiters, + buildTypeParameterDisplayFromSymbol: buildTypeParameterDisplayFromSymbol, + buildSignatureDisplay: buildSignatureDisplay, + buildReturnTypeDisplay: buildReturnTypeDisplay + }); + } + function isDeclarationVisible(node) { + function getContainingExternalModule(node) { + for (; node; node = node.parent) { + if (node.kind === 218) { + if (node.name.kind === 9) { + return node; + } + } + else if (node.kind === 248) { + return ts.isExternalModule(node) ? node : undefined; + } + } + ts.Debug.fail("getContainingModule cant reach here"); + } + function isUsedInExportAssignment(node) { + var externalModule = getContainingExternalModule(node); + var exportAssignmentSymbol; + var resolvedExportSymbol; + if (externalModule) { + var externalModuleSymbol = getSymbolOfNode(externalModule); + exportAssignmentSymbol = getExportAssignmentSymbol(externalModuleSymbol); + var symbolOfNode = getSymbolOfNode(node); + if (isSymbolUsedInExportAssignment(symbolOfNode)) { + return true; + } + if (symbolOfNode.flags & 8388608) { + return isSymbolUsedInExportAssignment(resolveAlias(symbolOfNode)); + } + } + function isSymbolUsedInExportAssignment(symbol) { + if (exportAssignmentSymbol === symbol) { + return true; + } + if (exportAssignmentSymbol && !!(exportAssignmentSymbol.flags & 8388608)) { + resolvedExportSymbol = resolvedExportSymbol || resolveAlias(exportAssignmentSymbol); + if (resolvedExportSymbol === symbol) { + return true; + } + return ts.forEach(resolvedExportSymbol.declarations, function (current) { + while (current) { + if (current === node) { + return true; + } + current = current.parent; + } + }); + } + } + } + function determineIfDeclarationIsVisible() { + switch (node.kind) { + case 163: + return isDeclarationVisible(node.parent.parent); + case 211: + if (ts.isBindingPattern(node.name) && + !node.name.elements.length) { + return false; + } + case 218: + case 214: + case 215: + case 216: + case 213: + case 217: + case 221: + var parent_4 = getDeclarationContainer(node); + if (!(ts.getCombinedNodeFlags(node) & 1) && + !(node.kind !== 221 && parent_4.kind !== 248 && ts.isInAmbientContext(parent_4))) { + return isGlobalSourceFile(parent_4); + } + return isDeclarationVisible(parent_4); + case 141: + case 140: + case 145: + case 146: + case 143: + case 142: + if (node.flags & (32 | 64)) { + return false; + } + case 144: + case 148: + case 147: + case 149: + case 138: + case 219: + case 152: + case 153: + case 155: + case 151: + case 156: + case 157: + case 158: + case 159: + case 160: + return isDeclarationVisible(node.parent); + case 223: + case 224: + case 226: + return false; + case 137: + case 248: + return true; + case 227: + return false; + default: + ts.Debug.fail("isDeclarationVisible unknown: SyntaxKind: " + node.kind); + } + } + if (node) { + var links = getNodeLinks(node); + if (links.isVisible === undefined) { + links.isVisible = !!determineIfDeclarationIsVisible(); + } + return links.isVisible; + } + } + function collectLinkedAliases(node) { + var exportSymbol; + if (node.parent && node.parent.kind === 227) { + exportSymbol = resolveName(node.parent, node.text, 107455 | 793056 | 1536 | 8388608, ts.Diagnostics.Cannot_find_name_0, node); + } + else if (node.parent.kind === 230) { + var exportSpecifier = node.parent; + exportSymbol = exportSpecifier.parent.parent.moduleSpecifier ? + getExternalModuleMember(exportSpecifier.parent.parent, exportSpecifier) : + resolveEntityName(exportSpecifier.propertyName || exportSpecifier.name, 107455 | 793056 | 1536 | 8388608); + } + var result = []; + if (exportSymbol) { + buildVisibleNodeList(exportSymbol.declarations); + } + return result; + function buildVisibleNodeList(declarations) { + ts.forEach(declarations, function (declaration) { + getNodeLinks(declaration).isVisible = true; + var resultNode = getAnyImportSyntax(declaration) || declaration; + if (!ts.contains(result, resultNode)) { + result.push(resultNode); + } + if (ts.isInternalModuleImportEqualsDeclaration(declaration)) { + var internalModuleReference = declaration.moduleReference; + var firstIdentifier = getFirstIdentifier(internalModuleReference); + var importSymbol = resolveName(declaration, firstIdentifier.text, 107455 | 793056 | 1536, ts.Diagnostics.Cannot_find_name_0, firstIdentifier); + buildVisibleNodeList(importSymbol.declarations); + } + }); + } + } + function pushTypeResolution(target, propertyName) { + var resolutionCycleStartIndex = findResolutionCycleStartIndex(target, propertyName); + if (resolutionCycleStartIndex >= 0) { + var length_2 = resolutionTargets.length; + for (var i = resolutionCycleStartIndex; i < length_2; i++) { + resolutionResults[i] = false; + } + return false; + } + resolutionTargets.push(target); + resolutionResults.push(true); + resolutionPropertyNames.push(propertyName); + return true; + } + function findResolutionCycleStartIndex(target, propertyName) { + for (var i = resolutionTargets.length - 1; i >= 0; i--) { + if (hasType(resolutionTargets[i], resolutionPropertyNames[i])) { + return -1; + } + if (resolutionTargets[i] === target && resolutionPropertyNames[i] === propertyName) { + return i; + } + } + return -1; + } + function hasType(target, propertyName) { + if (propertyName === 0) { + return getSymbolLinks(target).type; + } + if (propertyName === 2) { + return getSymbolLinks(target).declaredType; + } + if (propertyName === 1) { + ts.Debug.assert(!!(target.flags & 1024)); + return target.resolvedBaseConstructorType; + } + if (propertyName === 3) { + return target.resolvedReturnType; + } + ts.Debug.fail("Unhandled TypeSystemPropertyName " + propertyName); + } + function popTypeResolution() { + resolutionTargets.pop(); + resolutionPropertyNames.pop(); + return resolutionResults.pop(); + } + function getDeclarationContainer(node) { + node = ts.getRootDeclaration(node); + return node.kind === 211 ? node.parent.parent.parent : node.parent; + } + function getTypeOfPrototypeProperty(prototype) { + var classType = getDeclaredTypeOfSymbol(prototype.parent); + return classType.typeParameters ? createTypeReference(classType, ts.map(classType.typeParameters, function (_) { return anyType; })) : classType; + } + function getTypeOfPropertyOfType(type, name) { + var prop = getPropertyOfType(type, name); + return prop ? getTypeOfSymbol(prop) : undefined; + } + function isTypeAny(type) { + return type && (type.flags & 1) !== 0; + } + function getTypeForBindingElementParent(node) { + var symbol = getSymbolOfNode(node); + return symbol && getSymbolLinks(symbol).type || getTypeForVariableLikeDeclaration(node); + } + function getTypeForBindingElement(declaration) { + var pattern = declaration.parent; + var parentType = getTypeForBindingElementParent(pattern.parent); + if (parentType === unknownType) { + return unknownType; + } + if (!parentType || isTypeAny(parentType)) { + if (declaration.initializer) { + return checkExpressionCached(declaration.initializer); + } + return parentType; + } + var type; + if (pattern.kind === 161) { + var name_10 = declaration.propertyName || declaration.name; + type = getTypeOfPropertyOfType(parentType, name_10.text) || + isNumericLiteralName(name_10.text) && getIndexTypeOfType(parentType, 1) || + getIndexTypeOfType(parentType, 0); + if (!type) { + error(name_10, ts.Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(parentType), ts.declarationNameToString(name_10)); + return unknownType; + } + } + else { + var elementType = checkIteratedTypeOrElementType(parentType, pattern, false); + if (!declaration.dotDotDotToken) { + var propName = "" + ts.indexOf(pattern.elements, declaration); + type = isTupleLikeType(parentType) + ? getTypeOfPropertyOfType(parentType, propName) + : elementType; + if (!type) { + if (isTupleType(parentType)) { + error(declaration, ts.Diagnostics.Tuple_type_0_with_length_1_cannot_be_assigned_to_tuple_with_length_2, typeToString(parentType), parentType.elementTypes.length, pattern.elements.length); + } + else { + error(declaration, ts.Diagnostics.Type_0_has_no_property_1, typeToString(parentType), propName); + } + return unknownType; + } + } + else { + type = createArrayType(elementType); + } + } + return type; + } + function getTypeForVariableLikeDeclaration(declaration) { + if (declaration.parent.parent.kind === 200) { + return anyType; + } + if (declaration.parent.parent.kind === 201) { + return checkRightHandSideOfForOf(declaration.parent.parent.expression) || anyType; + } + if (ts.isBindingPattern(declaration.parent)) { + return getTypeForBindingElement(declaration); + } + if (declaration.type) { + return getTypeFromTypeNode(declaration.type); + } + if (declaration.kind === 138) { + var func = declaration.parent; + if (func.kind === 146 && !ts.hasDynamicName(func)) { + var getter = ts.getDeclarationOfKind(declaration.parent.symbol, 145); + if (getter) { + return getReturnTypeOfSignature(getSignatureFromDeclaration(getter)); + } + } + var type = getContextuallyTypedParameterType(declaration); + if (type) { + return type; + } + } + if (declaration.initializer) { + return checkExpressionCached(declaration.initializer); + } + if (declaration.kind === 246) { + return checkIdentifier(declaration.name); + } + if (ts.isBindingPattern(declaration.name)) { + return getTypeFromBindingPattern(declaration.name, false); + } + return undefined; + } + function getTypeFromBindingElement(element, includePatternInType) { + if (element.initializer) { + return getWidenedType(checkExpressionCached(element.initializer)); + } + if (ts.isBindingPattern(element.name)) { + return getTypeFromBindingPattern(element.name, includePatternInType); + } + return anyType; + } + function getTypeFromObjectBindingPattern(pattern, includePatternInType) { + var members = {}; + ts.forEach(pattern.elements, function (e) { + var flags = 4 | 67108864 | (e.initializer ? 536870912 : 0); + var name = e.propertyName || e.name; + var symbol = createSymbol(flags, name.text); + symbol.type = getTypeFromBindingElement(e, includePatternInType); + symbol.bindingElement = e; + members[symbol.name] = symbol; + }); + var result = createAnonymousType(undefined, members, emptyArray, emptyArray, undefined, undefined); + if (includePatternInType) { + result.pattern = pattern; + } + return result; + } + function getTypeFromArrayBindingPattern(pattern, includePatternInType) { + var elements = pattern.elements; + if (elements.length === 0 || elements[elements.length - 1].dotDotDotToken) { + return languageVersion >= 2 ? createIterableType(anyType) : anyArrayType; + } + var elementTypes = ts.map(elements, function (e) { return e.kind === 187 ? anyType : getTypeFromBindingElement(e, includePatternInType); }); + if (includePatternInType) { + var result = createNewTupleType(elementTypes); + result.pattern = pattern; + return result; + } + return createTupleType(elementTypes); + } + function getTypeFromBindingPattern(pattern, includePatternInType) { + return pattern.kind === 161 + ? getTypeFromObjectBindingPattern(pattern, includePatternInType) + : getTypeFromArrayBindingPattern(pattern, includePatternInType); + } + function getWidenedTypeForVariableLikeDeclaration(declaration, reportErrors) { + var type = getTypeForVariableLikeDeclaration(declaration); + if (type) { + if (reportErrors) { + reportErrorsFromWidening(declaration, type); + } + return declaration.kind !== 245 ? getWidenedType(type) : type; + } + type = declaration.dotDotDotToken ? anyArrayType : anyType; + if (reportErrors && compilerOptions.noImplicitAny) { + var root = ts.getRootDeclaration(declaration); + if (!isPrivateWithinAmbient(root) && !(root.kind === 138 && isPrivateWithinAmbient(root.parent))) { + reportImplicitAnyError(declaration, type); + } + } + return type; + } + function getTypeOfVariableOrParameterOrProperty(symbol) { + var links = getSymbolLinks(symbol); + if (!links.type) { + if (symbol.flags & 134217728) { + return links.type = getTypeOfPrototypeProperty(symbol); + } + var declaration = symbol.valueDeclaration; + if (declaration.parent.kind === 244) { + return links.type = anyType; + } + if (declaration.kind === 227) { + return links.type = checkExpression(declaration.expression); + } + if (!pushTypeResolution(symbol, 0)) { + return unknownType; + } + var type = getWidenedTypeForVariableLikeDeclaration(declaration, true); + if (!popTypeResolution()) { + if (symbol.valueDeclaration.type) { + type = unknownType; + error(symbol.valueDeclaration, ts.Diagnostics._0_is_referenced_directly_or_indirectly_in_its_own_type_annotation, symbolToString(symbol)); + } + else { + type = anyType; + if (compilerOptions.noImplicitAny) { + error(symbol.valueDeclaration, ts.Diagnostics._0_implicitly_has_type_any_because_it_does_not_have_a_type_annotation_and_is_referenced_directly_or_indirectly_in_its_own_initializer, symbolToString(symbol)); + } + } + } + links.type = type; + } + return links.type; + } + function getAnnotatedAccessorType(accessor) { + if (accessor) { + if (accessor.kind === 145) { + return accessor.type && getTypeFromTypeNode(accessor.type); + } + else { + var setterTypeAnnotation = ts.getSetAccessorTypeAnnotationNode(accessor); + return setterTypeAnnotation && getTypeFromTypeNode(setterTypeAnnotation); + } + } + return undefined; + } + function getTypeOfAccessors(symbol) { + var links = getSymbolLinks(symbol); + if (!links.type) { + if (!pushTypeResolution(symbol, 0)) { + return unknownType; + } + var getter = ts.getDeclarationOfKind(symbol, 145); + var setter = ts.getDeclarationOfKind(symbol, 146); + var type; + var getterReturnType = getAnnotatedAccessorType(getter); + if (getterReturnType) { + type = getterReturnType; + } + else { + var setterParameterType = getAnnotatedAccessorType(setter); + if (setterParameterType) { + type = setterParameterType; + } + else { + if (getter && getter.body) { + type = getReturnTypeFromBody(getter); + } + else { + if (compilerOptions.noImplicitAny) { + error(setter, ts.Diagnostics.Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_type_annotation, symbolToString(symbol)); + } + type = anyType; + } + } + } + if (!popTypeResolution()) { + type = anyType; + if (compilerOptions.noImplicitAny) { + var getter_1 = ts.getDeclarationOfKind(symbol, 145); + error(getter_1, ts.Diagnostics._0_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions, symbolToString(symbol)); + } + } + links.type = type; + } + return links.type; + } + function getTypeOfFuncClassEnumModule(symbol) { + var links = getSymbolLinks(symbol); + if (!links.type) { + links.type = createObjectType(65536, symbol); + } + return links.type; + } + function getTypeOfEnumMember(symbol) { + var links = getSymbolLinks(symbol); + if (!links.type) { + links.type = getDeclaredTypeOfEnum(getParentOfSymbol(symbol)); + } + return links.type; + } + function getTypeOfAlias(symbol) { + var links = getSymbolLinks(symbol); + if (!links.type) { + var targetSymbol = resolveAlias(symbol); + links.type = targetSymbol.flags & 107455 + ? getTypeOfSymbol(targetSymbol) + : unknownType; + } + return links.type; + } + function getTypeOfInstantiatedSymbol(symbol) { + var links = getSymbolLinks(symbol); + if (!links.type) { + links.type = instantiateType(getTypeOfSymbol(links.target), links.mapper); + } + return links.type; + } + function getTypeOfSymbol(symbol) { + if (symbol.flags & 16777216) { + return getTypeOfInstantiatedSymbol(symbol); + } + if (symbol.flags & (3 | 4)) { + return getTypeOfVariableOrParameterOrProperty(symbol); + } + if (symbol.flags & (16 | 8192 | 32 | 384 | 512)) { + return getTypeOfFuncClassEnumModule(symbol); + } + if (symbol.flags & 8) { + return getTypeOfEnumMember(symbol); + } + if (symbol.flags & 98304) { + return getTypeOfAccessors(symbol); + } + if (symbol.flags & 8388608) { + return getTypeOfAlias(symbol); + } + return unknownType; + } + function getTargetType(type) { + return type.flags & 4096 ? type.target : type; + } + function hasBaseType(type, checkBase) { + return check(type); + function check(type) { + var target = getTargetType(type); + return target === checkBase || ts.forEach(getBaseTypes(target), check); + } + } + function appendTypeParameters(typeParameters, declarations) { + for (var _i = 0; _i < declarations.length; _i++) { + var declaration = declarations[_i]; + var tp = getDeclaredTypeOfTypeParameter(getSymbolOfNode(declaration)); + if (!typeParameters) { + typeParameters = [tp]; + } + else if (!ts.contains(typeParameters, tp)) { + typeParameters.push(tp); + } + } + return typeParameters; + } + function appendOuterTypeParameters(typeParameters, node) { + while (true) { + node = node.parent; + if (!node) { + return typeParameters; + } + if (node.kind === 214 || node.kind === 186 || + node.kind === 213 || node.kind === 173 || + node.kind === 143 || node.kind === 174) { + var declarations = node.typeParameters; + if (declarations) { + return appendTypeParameters(appendOuterTypeParameters(typeParameters, node), declarations); + } + } + } + } + function getOuterTypeParametersOfClassOrInterface(symbol) { + var declaration = symbol.flags & 32 ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 215); + return appendOuterTypeParameters(undefined, declaration); + } + function getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol) { + var result; + for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { + var node = _a[_i]; + if (node.kind === 215 || node.kind === 214 || + node.kind === 186 || node.kind === 216) { + var declaration = node; + if (declaration.typeParameters) { + result = appendTypeParameters(result, declaration.typeParameters); + } + } + } + return result; + } + function getTypeParametersOfClassOrInterface(symbol) { + return ts.concatenate(getOuterTypeParametersOfClassOrInterface(symbol), getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol)); + } + function isConstructorType(type) { + return type.flags & 80896 && getSignaturesOfType(type, 1).length > 0; + } + function getBaseTypeNodeOfClass(type) { + return ts.getClassExtendsHeritageClauseElement(type.symbol.valueDeclaration); + } + function getConstructorsForTypeArguments(type, typeArgumentNodes) { + var typeArgCount = typeArgumentNodes ? typeArgumentNodes.length : 0; + return ts.filter(getSignaturesOfType(type, 1), function (sig) { return (sig.typeParameters ? sig.typeParameters.length : 0) === typeArgCount; }); + } + function getInstantiatedConstructorsForTypeArguments(type, typeArgumentNodes) { + var signatures = getConstructorsForTypeArguments(type, typeArgumentNodes); + if (typeArgumentNodes) { + var typeArguments = ts.map(typeArgumentNodes, getTypeFromTypeNode); + signatures = ts.map(signatures, function (sig) { return getSignatureInstantiation(sig, typeArguments); }); + } + return signatures; + } + function getBaseConstructorTypeOfClass(type) { + if (!type.resolvedBaseConstructorType) { + var baseTypeNode = getBaseTypeNodeOfClass(type); + if (!baseTypeNode) { + return type.resolvedBaseConstructorType = undefinedType; + } + if (!pushTypeResolution(type, 1)) { + return unknownType; + } + var baseConstructorType = checkExpression(baseTypeNode.expression); + if (baseConstructorType.flags & 80896) { + resolveStructuredTypeMembers(baseConstructorType); + } + if (!popTypeResolution()) { + error(type.symbol.valueDeclaration, ts.Diagnostics._0_is_referenced_directly_or_indirectly_in_its_own_base_expression, symbolToString(type.symbol)); + return type.resolvedBaseConstructorType = unknownType; + } + if (baseConstructorType !== unknownType && baseConstructorType !== nullType && !isConstructorType(baseConstructorType)) { + error(baseTypeNode.expression, ts.Diagnostics.Type_0_is_not_a_constructor_function_type, typeToString(baseConstructorType)); + return type.resolvedBaseConstructorType = unknownType; + } + type.resolvedBaseConstructorType = baseConstructorType; + } + return type.resolvedBaseConstructorType; + } + function hasClassBaseType(type) { + return !!ts.forEach(getBaseTypes(type), function (t) { return !!(t.symbol.flags & 32); }); + } + function getBaseTypes(type) { + var isClass = type.symbol.flags & 32; + var isInterface = type.symbol.flags & 64; + if (!type.resolvedBaseTypes) { + if (!isClass && !isInterface) { + ts.Debug.fail("type must be class or interface"); + } + if (isClass) { + resolveBaseTypesOfClass(type); + } + if (isInterface) { + resolveBaseTypesOfInterface(type); + } + } + return type.resolvedBaseTypes; + } + function resolveBaseTypesOfClass(type) { + type.resolvedBaseTypes = type.resolvedBaseTypes || emptyArray; + var baseContructorType = getBaseConstructorTypeOfClass(type); + if (!(baseContructorType.flags & 80896)) { + return; + } + var baseTypeNode = getBaseTypeNodeOfClass(type); + var baseType; + if (baseContructorType.symbol && baseContructorType.symbol.flags & 32) { + baseType = getTypeFromClassOrInterfaceReference(baseTypeNode, baseContructorType.symbol); + } + else { + var constructors = getInstantiatedConstructorsForTypeArguments(baseContructorType, baseTypeNode.typeArguments); + if (!constructors.length) { + error(baseTypeNode.expression, ts.Diagnostics.No_base_constructor_has_the_specified_number_of_type_arguments); + return; + } + baseType = getReturnTypeOfSignature(constructors[0]); + } + if (baseType === unknownType) { + return; + } + if (!(getTargetType(baseType).flags & (1024 | 2048))) { + error(baseTypeNode.expression, ts.Diagnostics.Base_constructor_return_type_0_is_not_a_class_or_interface_type, typeToString(baseType)); + return; + } + if (type === baseType || hasBaseType(baseType, type)) { + error(type.symbol.valueDeclaration, ts.Diagnostics.Type_0_recursively_references_itself_as_a_base_type, typeToString(type, undefined, 1)); + return; + } + if (type.resolvedBaseTypes === emptyArray) { + type.resolvedBaseTypes = [baseType]; + } + else { + type.resolvedBaseTypes.push(baseType); + } + } + function resolveBaseTypesOfInterface(type) { + type.resolvedBaseTypes = type.resolvedBaseTypes || emptyArray; + for (var _i = 0, _a = type.symbol.declarations; _i < _a.length; _i++) { + var declaration = _a[_i]; + if (declaration.kind === 215 && ts.getInterfaceBaseTypeNodes(declaration)) { + for (var _b = 0, _c = ts.getInterfaceBaseTypeNodes(declaration); _b < _c.length; _b++) { + var node = _c[_b]; + var baseType = getTypeFromTypeNode(node); + if (baseType !== unknownType) { + if (getTargetType(baseType).flags & (1024 | 2048)) { + if (type !== baseType && !hasBaseType(baseType, type)) { + if (type.resolvedBaseTypes === emptyArray) { + type.resolvedBaseTypes = [baseType]; + } + else { + type.resolvedBaseTypes.push(baseType); + } + } + else { + error(declaration, ts.Diagnostics.Type_0_recursively_references_itself_as_a_base_type, typeToString(type, undefined, 1)); + } + } + else { + error(node, ts.Diagnostics.An_interface_may_only_extend_a_class_or_another_interface); + } + } + } + } + } + } + function isIndependentInterface(symbol) { + for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { + var declaration = _a[_i]; + if (declaration.kind === 215) { + if (declaration.flags & 524288) { + return false; + } + var baseTypeNodes = ts.getInterfaceBaseTypeNodes(declaration); + if (baseTypeNodes) { + for (var _b = 0; _b < baseTypeNodes.length; _b++) { + var node = baseTypeNodes[_b]; + if (ts.isSupportedExpressionWithTypeArguments(node)) { + var baseSymbol = resolveEntityName(node.expression, 793056, true); + if (!baseSymbol || !(baseSymbol.flags & 64) || getDeclaredTypeOfClassOrInterface(baseSymbol).thisType) { + return false; + } + } + } + } + } + } + return true; + } + function getDeclaredTypeOfClassOrInterface(symbol) { + var links = getSymbolLinks(symbol); + if (!links.declaredType) { + var kind = symbol.flags & 32 ? 1024 : 2048; + var type = links.declaredType = createObjectType(kind, symbol); + var outerTypeParameters = getOuterTypeParametersOfClassOrInterface(symbol); + var localTypeParameters = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol); + if (outerTypeParameters || localTypeParameters || kind === 1024 || !isIndependentInterface(symbol)) { + type.flags |= 4096; + type.typeParameters = ts.concatenate(outerTypeParameters, localTypeParameters); + type.outerTypeParameters = outerTypeParameters; + type.localTypeParameters = localTypeParameters; + type.instantiations = {}; + type.instantiations[getTypeListId(type.typeParameters)] = type; + type.target = type; + type.typeArguments = type.typeParameters; + type.thisType = createType(512 | 33554432); + type.thisType.symbol = symbol; + type.thisType.constraint = getTypeWithThisArgument(type); + } + } + return links.declaredType; + } + function getDeclaredTypeOfTypeAlias(symbol) { + var links = getSymbolLinks(symbol); + if (!links.declaredType) { + if (!pushTypeResolution(symbol, 2)) { + return unknownType; + } + var declaration = ts.getDeclarationOfKind(symbol, 216); + var type = getTypeFromTypeNode(declaration.type); + if (popTypeResolution()) { + links.typeParameters = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol); + if (links.typeParameters) { + links.instantiations = {}; + links.instantiations[getTypeListId(links.typeParameters)] = type; + } + } + else { + type = unknownType; + error(declaration.name, ts.Diagnostics.Type_alias_0_circularly_references_itself, symbolToString(symbol)); + } + links.declaredType = type; + } + return links.declaredType; + } + function getDeclaredTypeOfEnum(symbol) { + var links = getSymbolLinks(symbol); + if (!links.declaredType) { + var type = createType(128); + type.symbol = symbol; + links.declaredType = type; + } + return links.declaredType; + } + function getDeclaredTypeOfTypeParameter(symbol) { + var links = getSymbolLinks(symbol); + if (!links.declaredType) { + var type = createType(512); + type.symbol = symbol; + if (!ts.getDeclarationOfKind(symbol, 137).constraint) { + type.constraint = noConstraintType; + } + links.declaredType = type; + } + return links.declaredType; + } + function getDeclaredTypeOfAlias(symbol) { + var links = getSymbolLinks(symbol); + if (!links.declaredType) { + links.declaredType = getDeclaredTypeOfSymbol(resolveAlias(symbol)); + } + return links.declaredType; + } + function getDeclaredTypeOfSymbol(symbol) { + ts.Debug.assert((symbol.flags & 16777216) === 0); + if (symbol.flags & (32 | 64)) { + return getDeclaredTypeOfClassOrInterface(symbol); + } + if (symbol.flags & 524288) { + return getDeclaredTypeOfTypeAlias(symbol); + } + if (symbol.flags & 384) { + return getDeclaredTypeOfEnum(symbol); + } + if (symbol.flags & 262144) { + return getDeclaredTypeOfTypeParameter(symbol); + } + if (symbol.flags & 8388608) { + return getDeclaredTypeOfAlias(symbol); + } + return unknownType; + } + function isIndependentTypeReference(node) { + if (node.typeArguments) { + for (var _i = 0, _a = node.typeArguments; _i < _a.length; _i++) { + var typeNode = _a[_i]; + if (!isIndependentType(typeNode)) { + return false; + } + } + } + return true; + } + function isIndependentType(node) { + switch (node.kind) { + case 117: + case 130: + case 128: + case 120: + case 131: + case 103: + case 9: + return true; + case 156: + return isIndependentType(node.elementType); + case 151: + return isIndependentTypeReference(node); + } + return false; + } + function isIndependentVariableLikeDeclaration(node) { + return node.type && isIndependentType(node.type) || !node.type && !node.initializer; + } + function isIndependentFunctionLikeDeclaration(node) { + if (node.kind !== 144 && (!node.type || !isIndependentType(node.type))) { + return false; + } + for (var _i = 0, _a = node.parameters; _i < _a.length; _i++) { + var parameter = _a[_i]; + if (!isIndependentVariableLikeDeclaration(parameter)) { + return false; + } + } + return true; + } + function isIndependentMember(symbol) { + if (symbol.declarations && symbol.declarations.length === 1) { + var declaration = symbol.declarations[0]; + if (declaration) { + switch (declaration.kind) { + case 141: + case 140: + return isIndependentVariableLikeDeclaration(declaration); + case 143: + case 142: + case 144: + return isIndependentFunctionLikeDeclaration(declaration); + } + } + } + return false; + } + function createSymbolTable(symbols) { + var result = {}; + for (var _i = 0; _i < symbols.length; _i++) { + var symbol = symbols[_i]; + result[symbol.name] = symbol; + } + return result; + } + function createInstantiatedSymbolTable(symbols, mapper, mappingThisOnly) { + var result = {}; + for (var _i = 0; _i < symbols.length; _i++) { + var symbol = symbols[_i]; + result[symbol.name] = mappingThisOnly && isIndependentMember(symbol) ? symbol : instantiateSymbol(symbol, mapper); + } + return result; + } + function addInheritedMembers(symbols, baseSymbols) { + for (var _i = 0; _i < baseSymbols.length; _i++) { + var s = baseSymbols[_i]; + if (!ts.hasProperty(symbols, s.name)) { + symbols[s.name] = s; + } + } + } + function addInheritedSignatures(signatures, baseSignatures) { + if (baseSignatures) { + for (var _i = 0; _i < baseSignatures.length; _i++) { + var signature = baseSignatures[_i]; + signatures.push(signature); + } + } + } + function resolveDeclaredMembers(type) { + if (!type.declaredProperties) { + var symbol = type.symbol; + type.declaredProperties = getNamedMembers(symbol.members); + type.declaredCallSignatures = getSignaturesOfSymbol(symbol.members["__call"]); + type.declaredConstructSignatures = getSignaturesOfSymbol(symbol.members["__new"]); + type.declaredStringIndexType = getIndexTypeOfSymbol(symbol, 0); + type.declaredNumberIndexType = getIndexTypeOfSymbol(symbol, 1); + } + return type; + } + function getTypeWithThisArgument(type, thisArgument) { + if (type.flags & 4096) { + return createTypeReference(type.target, ts.concatenate(type.typeArguments, [thisArgument || type.target.thisType])); + } + return type; + } + function resolveObjectTypeMembers(type, source, typeParameters, typeArguments) { + var mapper = identityMapper; + var members = source.symbol.members; + var callSignatures = source.declaredCallSignatures; + var constructSignatures = source.declaredConstructSignatures; + var stringIndexType = source.declaredStringIndexType; + var numberIndexType = source.declaredNumberIndexType; + if (!ts.rangeEquals(typeParameters, typeArguments, 0, typeParameters.length)) { + mapper = createTypeMapper(typeParameters, typeArguments); + members = createInstantiatedSymbolTable(source.declaredProperties, mapper, typeParameters.length === 1); + callSignatures = instantiateList(source.declaredCallSignatures, mapper, instantiateSignature); + constructSignatures = instantiateList(source.declaredConstructSignatures, mapper, instantiateSignature); + stringIndexType = instantiateType(source.declaredStringIndexType, mapper); + numberIndexType = instantiateType(source.declaredNumberIndexType, mapper); + } + var baseTypes = getBaseTypes(source); + if (baseTypes.length) { + if (members === source.symbol.members) { + members = createSymbolTable(source.declaredProperties); + } + var thisArgument = ts.lastOrUndefined(typeArguments); + for (var _i = 0; _i < baseTypes.length; _i++) { + var baseType = baseTypes[_i]; + var instantiatedBaseType = thisArgument ? getTypeWithThisArgument(instantiateType(baseType, mapper), thisArgument) : baseType; + addInheritedMembers(members, getPropertiesOfObjectType(instantiatedBaseType)); + callSignatures = ts.concatenate(callSignatures, getSignaturesOfType(instantiatedBaseType, 0)); + constructSignatures = ts.concatenate(constructSignatures, getSignaturesOfType(instantiatedBaseType, 1)); + stringIndexType = stringIndexType || getIndexTypeOfType(instantiatedBaseType, 0); + numberIndexType = numberIndexType || getIndexTypeOfType(instantiatedBaseType, 1); + } + } + setObjectTypeMembers(type, members, callSignatures, constructSignatures, stringIndexType, numberIndexType); + } + function resolveClassOrInterfaceMembers(type) { + resolveObjectTypeMembers(type, resolveDeclaredMembers(type), emptyArray, emptyArray); + } + function resolveTypeReferenceMembers(type) { + var source = resolveDeclaredMembers(type.target); + var typeParameters = ts.concatenate(source.typeParameters, [source.thisType]); + var typeArguments = type.typeArguments && type.typeArguments.length === typeParameters.length ? + type.typeArguments : ts.concatenate(type.typeArguments, [type]); + resolveObjectTypeMembers(type, source, typeParameters, typeArguments); + } + function createSignature(declaration, typeParameters, parameters, resolvedReturnType, typePredicate, minArgumentCount, hasRestParameter, hasStringLiterals) { + var sig = new Signature(checker); + sig.declaration = declaration; + sig.typeParameters = typeParameters; + sig.parameters = parameters; + sig.resolvedReturnType = resolvedReturnType; + sig.typePredicate = typePredicate; + sig.minArgumentCount = minArgumentCount; + sig.hasRestParameter = hasRestParameter; + sig.hasStringLiterals = hasStringLiterals; + return sig; + } + function cloneSignature(sig) { + return createSignature(sig.declaration, sig.typeParameters, sig.parameters, sig.resolvedReturnType, sig.typePredicate, sig.minArgumentCount, sig.hasRestParameter, sig.hasStringLiterals); + } + function getDefaultConstructSignatures(classType) { + if (!hasClassBaseType(classType)) { + return [createSignature(undefined, classType.localTypeParameters, emptyArray, classType, undefined, 0, false, false)]; + } + var baseConstructorType = getBaseConstructorTypeOfClass(classType); + var baseSignatures = getSignaturesOfType(baseConstructorType, 1); + var baseTypeNode = getBaseTypeNodeOfClass(classType); + var typeArguments = ts.map(baseTypeNode.typeArguments, getTypeFromTypeNode); + var typeArgCount = typeArguments ? typeArguments.length : 0; + var result = []; + for (var _i = 0; _i < baseSignatures.length; _i++) { + var baseSig = baseSignatures[_i]; + var typeParamCount = baseSig.typeParameters ? baseSig.typeParameters.length : 0; + if (typeParamCount === typeArgCount) { + var sig = typeParamCount ? getSignatureInstantiation(baseSig, typeArguments) : cloneSignature(baseSig); + sig.typeParameters = classType.localTypeParameters; + sig.resolvedReturnType = classType; + result.push(sig); + } + } + return result; + } + function createTupleTypeMemberSymbols(memberTypes) { + var members = {}; + for (var i = 0; i < memberTypes.length; i++) { + var symbol = createSymbol(4 | 67108864, "" + i); + symbol.type = memberTypes[i]; + members[i] = symbol; + } + return members; + } + function resolveTupleTypeMembers(type) { + var arrayElementType = getUnionType(type.elementTypes, true); + var arrayType = resolveStructuredTypeMembers(createTypeFromGenericGlobalType(globalArrayType, [arrayElementType, type])); + var members = createTupleTypeMemberSymbols(type.elementTypes); + addInheritedMembers(members, arrayType.properties); + setObjectTypeMembers(type, members, arrayType.callSignatures, arrayType.constructSignatures, arrayType.stringIndexType, arrayType.numberIndexType); + } + function findMatchingSignature(signatureList, signature, partialMatch, ignoreReturnTypes) { + for (var _i = 0; _i < signatureList.length; _i++) { + var s = signatureList[_i]; + if (compareSignatures(s, signature, partialMatch, ignoreReturnTypes, compareTypes)) { + return s; + } + } + } + function findMatchingSignatures(signatureLists, signature, listIndex) { + if (signature.typeParameters) { + if (listIndex > 0) { + return undefined; + } + for (var i = 1; i < signatureLists.length; i++) { + if (!findMatchingSignature(signatureLists[i], signature, false, false)) { + return undefined; + } + } + return [signature]; + } + var result = undefined; + for (var i = 0; i < signatureLists.length; i++) { + var match = i === listIndex ? signature : findMatchingSignature(signatureLists[i], signature, true, true); + if (!match) { + return undefined; + } + if (!ts.contains(result, match)) { + (result || (result = [])).push(match); + } + } + return result; + } + function getUnionSignatures(types, kind) { + var signatureLists = ts.map(types, function (t) { return getSignaturesOfType(t, kind); }); + var result = undefined; + for (var i = 0; i < signatureLists.length; i++) { + for (var _i = 0, _a = signatureLists[i]; _i < _a.length; _i++) { + var signature = _a[_i]; + if (!result || !findMatchingSignature(result, signature, false, true)) { + var unionSignatures = findMatchingSignatures(signatureLists, signature, i); + if (unionSignatures) { + var s = signature; + if (unionSignatures.length > 1) { + s = cloneSignature(signature); + s.resolvedReturnType = undefined; + s.unionSignatures = unionSignatures; + } + (result || (result = [])).push(s); + } + } + } + } + return result || emptyArray; + } + function getUnionIndexType(types, kind) { + var indexTypes = []; + for (var _i = 0; _i < types.length; _i++) { + var type = types[_i]; + var indexType = getIndexTypeOfType(type, kind); + if (!indexType) { + return undefined; + } + indexTypes.push(indexType); + } + return getUnionType(indexTypes); + } + function resolveUnionTypeMembers(type) { + var callSignatures = getUnionSignatures(type.types, 0); + var constructSignatures = getUnionSignatures(type.types, 1); + var stringIndexType = getUnionIndexType(type.types, 0); + var numberIndexType = getUnionIndexType(type.types, 1); + setObjectTypeMembers(type, emptySymbols, callSignatures, constructSignatures, stringIndexType, numberIndexType); + } + function intersectTypes(type1, type2) { + return !type1 ? type2 : !type2 ? type1 : getIntersectionType([type1, type2]); + } + function resolveIntersectionTypeMembers(type) { + var callSignatures = emptyArray; + var constructSignatures = emptyArray; + var stringIndexType = undefined; + var numberIndexType = undefined; + for (var _i = 0, _a = type.types; _i < _a.length; _i++) { + var t = _a[_i]; + callSignatures = ts.concatenate(callSignatures, getSignaturesOfType(t, 0)); + constructSignatures = ts.concatenate(constructSignatures, getSignaturesOfType(t, 1)); + stringIndexType = intersectTypes(stringIndexType, getIndexTypeOfType(t, 0)); + numberIndexType = intersectTypes(numberIndexType, getIndexTypeOfType(t, 1)); + } + setObjectTypeMembers(type, emptySymbols, callSignatures, constructSignatures, stringIndexType, numberIndexType); + } + function resolveAnonymousTypeMembers(type) { + var symbol = type.symbol; + var members; + var callSignatures; + var constructSignatures; + var stringIndexType; + var numberIndexType; + if (type.target) { + members = createInstantiatedSymbolTable(getPropertiesOfObjectType(type.target), type.mapper, false); + callSignatures = instantiateList(getSignaturesOfType(type.target, 0), type.mapper, instantiateSignature); + constructSignatures = instantiateList(getSignaturesOfType(type.target, 1), type.mapper, instantiateSignature); + stringIndexType = instantiateType(getIndexTypeOfType(type.target, 0), type.mapper); + numberIndexType = instantiateType(getIndexTypeOfType(type.target, 1), type.mapper); + } + else if (symbol.flags & 2048) { + members = symbol.members; + callSignatures = getSignaturesOfSymbol(members["__call"]); + constructSignatures = getSignaturesOfSymbol(members["__new"]); + stringIndexType = getIndexTypeOfSymbol(symbol, 0); + numberIndexType = getIndexTypeOfSymbol(symbol, 1); + } + else { + members = emptySymbols; + callSignatures = emptyArray; + constructSignatures = emptyArray; + if (symbol.flags & 1952) { + members = getExportsOfSymbol(symbol); + } + if (symbol.flags & (16 | 8192)) { + callSignatures = getSignaturesOfSymbol(symbol); + } + if (symbol.flags & 32) { + var classType = getDeclaredTypeOfClassOrInterface(symbol); + constructSignatures = getSignaturesOfSymbol(symbol.members["__constructor"]); + if (!constructSignatures.length) { + constructSignatures = getDefaultConstructSignatures(classType); + } + var baseConstructorType = getBaseConstructorTypeOfClass(classType); + if (baseConstructorType.flags & 80896) { + members = createSymbolTable(getNamedMembers(members)); + addInheritedMembers(members, getPropertiesOfObjectType(baseConstructorType)); + } + } + stringIndexType = undefined; + numberIndexType = (symbol.flags & 384) ? stringType : undefined; + } + setObjectTypeMembers(type, members, callSignatures, constructSignatures, stringIndexType, numberIndexType); + } + function resolveStructuredTypeMembers(type) { + if (!type.members) { + if (type.flags & 4096) { + resolveTypeReferenceMembers(type); + } + else if (type.flags & (1024 | 2048)) { + resolveClassOrInterfaceMembers(type); + } + else if (type.flags & 65536) { + resolveAnonymousTypeMembers(type); + } + else if (type.flags & 8192) { + resolveTupleTypeMembers(type); + } + else if (type.flags & 16384) { + resolveUnionTypeMembers(type); + } + else if (type.flags & 32768) { + resolveIntersectionTypeMembers(type); + } + } + return type; + } + function getPropertiesOfObjectType(type) { + if (type.flags & 80896) { + return resolveStructuredTypeMembers(type).properties; + } + return emptyArray; + } + function getPropertyOfObjectType(type, name) { + if (type.flags & 80896) { + var resolved = resolveStructuredTypeMembers(type); + if (ts.hasProperty(resolved.members, name)) { + var symbol = resolved.members[name]; + if (symbolIsValue(symbol)) { + return symbol; + } + } + } + } + function getPropertiesOfUnionOrIntersectionType(type) { + for (var _i = 0, _a = type.types; _i < _a.length; _i++) { + var current = _a[_i]; + for (var _b = 0, _c = getPropertiesOfType(current); _b < _c.length; _b++) { + var prop = _c[_b]; + getPropertyOfUnionOrIntersectionType(type, prop.name); + } + if (type.flags & 16384) { + break; + } + } + return type.resolvedProperties ? symbolsToArray(type.resolvedProperties) : emptyArray; + } + function getPropertiesOfType(type) { + type = getApparentType(type); + return type.flags & 49152 ? getPropertiesOfUnionOrIntersectionType(type) : getPropertiesOfObjectType(type); + } + function getApparentType(type) { + if (type.flags & 512) { + do { + type = getConstraintOfTypeParameter(type); + } while (type && type.flags & 512); + if (!type) { + type = emptyObjectType; + } + } + if (type.flags & 258) { + type = globalStringType; + } + else if (type.flags & 132) { + type = globalNumberType; + } + else if (type.flags & 8) { + type = globalBooleanType; + } + else if (type.flags & 16777216) { + type = globalESSymbolType; + } + return type; + } + function createUnionOrIntersectionProperty(containingType, name) { + var types = containingType.types; + var props; + for (var _i = 0; _i < types.length; _i++) { + var current = types[_i]; + var type = getApparentType(current); + if (type !== unknownType) { + var prop = getPropertyOfType(type, name); + if (prop && !(getDeclarationFlagsFromSymbol(prop) & (32 | 64))) { + if (!props) { + props = [prop]; + } + else if (!ts.contains(props, prop)) { + props.push(prop); + } + } + else if (containingType.flags & 16384) { + return undefined; + } + } + } + if (!props) { + return undefined; + } + if (props.length === 1) { + return props[0]; + } + var propTypes = []; + var declarations = []; + for (var _a = 0; _a < props.length; _a++) { + var prop = props[_a]; + if (prop.declarations) { + ts.addRange(declarations, prop.declarations); + } + propTypes.push(getTypeOfSymbol(prop)); + } + var result = createSymbol(4 | 67108864 | 268435456, name); + result.containingType = containingType; + result.declarations = declarations; + result.type = containingType.flags & 16384 ? getUnionType(propTypes) : getIntersectionType(propTypes); + return result; + } + function getPropertyOfUnionOrIntersectionType(type, name) { + var properties = type.resolvedProperties || (type.resolvedProperties = {}); + if (ts.hasProperty(properties, name)) { + return properties[name]; + } + var property = createUnionOrIntersectionProperty(type, name); + if (property) { + properties[name] = property; + } + return property; + } + function getPropertyOfType(type, name) { + type = getApparentType(type); + if (type.flags & 80896) { + var resolved = resolveStructuredTypeMembers(type); + if (ts.hasProperty(resolved.members, name)) { + var symbol = resolved.members[name]; + if (symbolIsValue(symbol)) { + return symbol; + } + } + if (resolved === anyFunctionType || resolved.callSignatures.length || resolved.constructSignatures.length) { + var symbol = getPropertyOfObjectType(globalFunctionType, name); + if (symbol) { + return symbol; + } + } + return getPropertyOfObjectType(globalObjectType, name); + } + if (type.flags & 49152) { + return getPropertyOfUnionOrIntersectionType(type, name); + } + return undefined; + } + function getSignaturesOfStructuredType(type, kind) { + if (type.flags & 130048) { + var resolved = resolveStructuredTypeMembers(type); + return kind === 0 ? resolved.callSignatures : resolved.constructSignatures; + } + return emptyArray; + } + function getSignaturesOfType(type, kind) { + return getSignaturesOfStructuredType(getApparentType(type), kind); + } + function typeHasConstructSignatures(type) { + var apparentType = getApparentType(type); + if (apparentType.flags & (80896 | 16384)) { + var resolved = resolveStructuredTypeMembers(type); + return resolved.constructSignatures.length > 0; + } + return false; + } + function typeHasCallOrConstructSignatures(type) { + var apparentType = getApparentType(type); + if (apparentType.flags & 130048) { + var resolved = resolveStructuredTypeMembers(type); + return resolved.callSignatures.length > 0 || resolved.constructSignatures.length > 0; + } + return false; + } + function getIndexTypeOfStructuredType(type, kind) { + if (type.flags & 130048) { + var resolved = resolveStructuredTypeMembers(type); + return kind === 0 ? resolved.stringIndexType : resolved.numberIndexType; + } + } + function getIndexTypeOfType(type, kind) { + return getIndexTypeOfStructuredType(getApparentType(type), kind); + } + function getTypeParametersFromDeclaration(typeParameterDeclarations) { + var result = []; + ts.forEach(typeParameterDeclarations, function (node) { + var tp = getDeclaredTypeOfTypeParameter(node.symbol); + if (!ts.contains(result, tp)) { + result.push(tp); + } + }); + return result; + } + function symbolsToArray(symbols) { + var result = []; + for (var id in symbols) { + if (!isReservedMemberName(id)) { + result.push(symbols[id]); + } + } + return result; + } + function isOptionalParameter(node) { + if (ts.hasQuestionToken(node)) { + return true; + } + if (node.initializer) { + var signatureDeclaration = node.parent; + var signature = getSignatureFromDeclaration(signatureDeclaration); + var parameterIndex = signatureDeclaration.parameters.indexOf(node); + ts.Debug.assert(parameterIndex >= 0); + return parameterIndex >= signature.minArgumentCount; + } + return false; + } + function getSignatureFromDeclaration(declaration) { + var links = getNodeLinks(declaration); + if (!links.resolvedSignature) { + var classType = declaration.kind === 144 ? + getDeclaredTypeOfClassOrInterface(getMergedSymbol(declaration.parent.symbol)) + : undefined; + var typeParameters = classType ? classType.localTypeParameters : + declaration.typeParameters ? getTypeParametersFromDeclaration(declaration.typeParameters) : undefined; + var parameters = []; + var hasStringLiterals = false; + var minArgumentCount = -1; + for (var i = 0, n = declaration.parameters.length; i < n; i++) { + var param = declaration.parameters[i]; + parameters.push(param.symbol); + if (param.type && param.type.kind === 9) { + hasStringLiterals = true; + } + if (param.initializer || param.questionToken || param.dotDotDotToken) { + if (minArgumentCount < 0) { + minArgumentCount = i; + } + } + else { + minArgumentCount = -1; + } + } + if (minArgumentCount < 0) { + minArgumentCount = declaration.parameters.length; + } + var returnType; + var typePredicate; + if (classType) { + returnType = classType; + } + else if (declaration.type) { + returnType = getTypeFromTypeNode(declaration.type); + if (declaration.type.kind === 150) { + var typePredicateNode = declaration.type; + typePredicate = { + parameterName: typePredicateNode.parameterName ? typePredicateNode.parameterName.text : undefined, + parameterIndex: typePredicateNode.parameterName ? getTypePredicateParameterIndex(declaration.parameters, typePredicateNode.parameterName) : undefined, + type: getTypeFromTypeNode(typePredicateNode.type) + }; + } + } + else { + if (declaration.kind === 145 && !ts.hasDynamicName(declaration)) { + var setter = ts.getDeclarationOfKind(declaration.symbol, 146); + returnType = getAnnotatedAccessorType(setter); + } + if (!returnType && ts.nodeIsMissing(declaration.body)) { + returnType = anyType; + } + } + links.resolvedSignature = createSignature(declaration, typeParameters, parameters, returnType, typePredicate, minArgumentCount, ts.hasRestParameter(declaration), hasStringLiterals); + } + return links.resolvedSignature; + } + function getSignaturesOfSymbol(symbol) { + if (!symbol) + return emptyArray; + var result = []; + for (var i = 0, len = symbol.declarations.length; i < len; i++) { + var node = symbol.declarations[i]; + switch (node.kind) { + case 152: + case 153: + case 213: + case 143: + case 142: + case 144: + case 147: + case 148: + case 149: + case 145: + case 146: + case 173: + case 174: + if (i > 0 && node.body) { + var previous = symbol.declarations[i - 1]; + if (node.parent === previous.parent && node.kind === previous.kind && node.pos === previous.end) { + break; + } + } + result.push(getSignatureFromDeclaration(node)); + } + } + return result; + } + function getReturnTypeOfSignature(signature) { + if (!signature.resolvedReturnType) { + if (!pushTypeResolution(signature, 3)) { + return unknownType; + } + var type; + if (signature.target) { + type = instantiateType(getReturnTypeOfSignature(signature.target), signature.mapper); + } + else if (signature.unionSignatures) { + type = getUnionType(ts.map(signature.unionSignatures, getReturnTypeOfSignature)); + } + else { + type = getReturnTypeFromBody(signature.declaration); + } + if (!popTypeResolution()) { + type = anyType; + if (compilerOptions.noImplicitAny) { + var declaration = signature.declaration; + if (declaration.name) { + error(declaration.name, 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, ts.declarationNameToString(declaration.name)); + } + else { + error(declaration, ts.Diagnostics.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); + } + } + } + signature.resolvedReturnType = type; + } + return signature.resolvedReturnType; + } + function getRestTypeOfSignature(signature) { + if (signature.hasRestParameter) { + var type = getTypeOfSymbol(ts.lastOrUndefined(signature.parameters)); + if (type.flags & 4096 && type.target === globalArrayType) { + return type.typeArguments[0]; + } + } + return anyType; + } + function getSignatureInstantiation(signature, typeArguments) { + return instantiateSignature(signature, createTypeMapper(signature.typeParameters, typeArguments), true); + } + function getErasedSignature(signature) { + if (!signature.typeParameters) + return signature; + if (!signature.erasedSignatureCache) { + if (signature.target) { + signature.erasedSignatureCache = instantiateSignature(getErasedSignature(signature.target), signature.mapper); + } + else { + signature.erasedSignatureCache = instantiateSignature(signature, createTypeEraser(signature.typeParameters), true); + } + } + return signature.erasedSignatureCache; + } + function getOrCreateTypeFromSignature(signature) { + if (!signature.isolatedSignatureType) { + var isConstructor = signature.declaration.kind === 144 || signature.declaration.kind === 148; + var type = createObjectType(65536 | 262144); + type.members = emptySymbols; + type.properties = emptyArray; + type.callSignatures = !isConstructor ? [signature] : emptyArray; + type.constructSignatures = isConstructor ? [signature] : emptyArray; + signature.isolatedSignatureType = type; + } + return signature.isolatedSignatureType; + } + function getIndexSymbol(symbol) { + return symbol.members["__index"]; + } + function getIndexDeclarationOfSymbol(symbol, kind) { + var syntaxKind = kind === 1 ? 128 : 130; + var indexSymbol = getIndexSymbol(symbol); + if (indexSymbol) { + for (var _i = 0, _a = indexSymbol.declarations; _i < _a.length; _i++) { + var decl = _a[_i]; + var node = decl; + if (node.parameters.length === 1) { + var parameter = node.parameters[0]; + if (parameter && parameter.type && parameter.type.kind === syntaxKind) { + return node; + } + } + } + } + return undefined; + } + function getIndexTypeOfSymbol(symbol, kind) { + var declaration = getIndexDeclarationOfSymbol(symbol, kind); + return declaration + ? declaration.type ? getTypeFromTypeNode(declaration.type) : anyType + : undefined; + } + function getConstraintOfTypeParameter(type) { + if (!type.constraint) { + if (type.target) { + var targetConstraint = getConstraintOfTypeParameter(type.target); + type.constraint = targetConstraint ? instantiateType(targetConstraint, type.mapper) : noConstraintType; + } + else { + type.constraint = getTypeFromTypeNode(ts.getDeclarationOfKind(type.symbol, 137).constraint); + } + } + return type.constraint === noConstraintType ? undefined : type.constraint; + } + function getParentSymbolOfTypeParameter(typeParameter) { + return getSymbolOfNode(ts.getDeclarationOfKind(typeParameter.symbol, 137).parent); + } + function getTypeListId(types) { + if (types) { + switch (types.length) { + case 1: + return "" + types[0].id; + case 2: + return types[0].id + "," + types[1].id; + default: + var result = ""; + for (var i = 0; i < types.length; i++) { + if (i > 0) { + result += ","; + } + result += types[i].id; + } + return result; + } + } + return ""; + } + function getPropagatingFlagsOfTypes(types) { + var result = 0; + for (var _i = 0; _i < types.length; _i++) { + var type = types[_i]; + result |= type.flags; + } + return result & 14680064; + } + function createTypeReference(target, typeArguments) { + var id = getTypeListId(typeArguments); + var type = target.instantiations[id]; + if (!type) { + var flags = 4096 | (typeArguments ? getPropagatingFlagsOfTypes(typeArguments) : 0); + type = target.instantiations[id] = createObjectType(flags, target.symbol); + type.target = target; + type.typeArguments = typeArguments; + } + return type; + } + function isTypeParameterReferenceIllegalInConstraint(typeReferenceNode, typeParameterSymbol) { + var links = getNodeLinks(typeReferenceNode); + if (links.isIllegalTypeReferenceInConstraint !== undefined) { + return links.isIllegalTypeReferenceInConstraint; + } + var currentNode = typeReferenceNode; + while (!ts.forEach(typeParameterSymbol.declarations, function (d) { return d.parent === currentNode.parent; })) { + currentNode = currentNode.parent; + } + links.isIllegalTypeReferenceInConstraint = currentNode.kind === 137; + return links.isIllegalTypeReferenceInConstraint; + } + function checkTypeParameterHasIllegalReferencesInConstraint(typeParameter) { + var typeParameterSymbol; + function check(n) { + if (n.kind === 151 && n.typeName.kind === 69) { + var links = getNodeLinks(n); + if (links.isIllegalTypeReferenceInConstraint === undefined) { + var symbol = resolveName(typeParameter, n.typeName.text, 793056, undefined, undefined); + if (symbol && (symbol.flags & 262144)) { + links.isIllegalTypeReferenceInConstraint = ts.forEach(symbol.declarations, function (d) { return d.parent === typeParameter.parent; }); + } + } + if (links.isIllegalTypeReferenceInConstraint) { + error(typeParameter, ts.Diagnostics.Constraint_of_a_type_parameter_cannot_reference_any_type_parameter_from_the_same_type_parameter_list); + } + } + ts.forEachChild(n, check); + } + if (typeParameter.constraint) { + typeParameterSymbol = getSymbolOfNode(typeParameter); + check(typeParameter.constraint); + } + } + function getTypeFromClassOrInterfaceReference(node, symbol) { + var type = getDeclaredTypeOfSymbol(symbol); + var typeParameters = type.localTypeParameters; + if (typeParameters) { + if (!node.typeArguments || node.typeArguments.length !== typeParameters.length) { + error(node, ts.Diagnostics.Generic_type_0_requires_1_type_argument_s, typeToString(type, undefined, 1), typeParameters.length); + return unknownType; + } + return createTypeReference(type, ts.concatenate(type.outerTypeParameters, ts.map(node.typeArguments, getTypeFromTypeNode))); + } + if (node.typeArguments) { + error(node, ts.Diagnostics.Type_0_is_not_generic, typeToString(type)); + return unknownType; + } + return type; + } + function getTypeFromTypeAliasReference(node, symbol) { + var type = getDeclaredTypeOfSymbol(symbol); + var links = getSymbolLinks(symbol); + var typeParameters = links.typeParameters; + if (typeParameters) { + if (!node.typeArguments || node.typeArguments.length !== typeParameters.length) { + error(node, ts.Diagnostics.Generic_type_0_requires_1_type_argument_s, symbolToString(symbol), typeParameters.length); + return unknownType; + } + var typeArguments = ts.map(node.typeArguments, getTypeFromTypeNode); + var id = getTypeListId(typeArguments); + return links.instantiations[id] || (links.instantiations[id] = instantiateType(type, createTypeMapper(typeParameters, typeArguments))); + } + if (node.typeArguments) { + error(node, ts.Diagnostics.Type_0_is_not_generic, symbolToString(symbol)); + return unknownType; + } + return type; + } + function getTypeFromNonGenericTypeReference(node, symbol) { + if (symbol.flags & 262144 && isTypeParameterReferenceIllegalInConstraint(node, symbol)) { + return unknownType; + } + if (node.typeArguments) { + error(node, ts.Diagnostics.Type_0_is_not_generic, symbolToString(symbol)); + return unknownType; + } + return getDeclaredTypeOfSymbol(symbol); + } + function getTypeFromTypeReference(node) { + var links = getNodeLinks(node); + if (!links.resolvedType) { + var typeNameOrExpression = node.kind === 151 ? node.typeName : + ts.isSupportedExpressionWithTypeArguments(node) ? node.expression : + undefined; + var symbol = typeNameOrExpression && resolveEntityName(typeNameOrExpression, 793056) || unknownSymbol; + var type = symbol === unknownSymbol ? unknownType : + symbol.flags & (32 | 64) ? getTypeFromClassOrInterfaceReference(node, symbol) : + symbol.flags & 524288 ? getTypeFromTypeAliasReference(node, symbol) : + getTypeFromNonGenericTypeReference(node, symbol); + links.resolvedSymbol = symbol; + links.resolvedType = type; + } + return links.resolvedType; + } + function getTypeFromTypeQueryNode(node) { + var links = getNodeLinks(node); + if (!links.resolvedType) { + links.resolvedType = getWidenedType(checkExpression(node.exprName)); + } + return links.resolvedType; + } + function getTypeOfGlobalSymbol(symbol, arity) { + function getTypeDeclaration(symbol) { + var declarations = symbol.declarations; + for (var _i = 0; _i < declarations.length; _i++) { + var declaration = declarations[_i]; + switch (declaration.kind) { + case 214: + case 215: + case 217: + return declaration; + } + } + } + if (!symbol) { + return arity ? emptyGenericType : emptyObjectType; + } + var type = getDeclaredTypeOfSymbol(symbol); + if (!(type.flags & 80896)) { + error(getTypeDeclaration(symbol), ts.Diagnostics.Global_type_0_must_be_a_class_or_interface_type, symbol.name); + return arity ? emptyGenericType : emptyObjectType; + } + if ((type.typeParameters ? type.typeParameters.length : 0) !== arity) { + error(getTypeDeclaration(symbol), ts.Diagnostics.Global_type_0_must_have_1_type_parameter_s, symbol.name, arity); + return arity ? emptyGenericType : emptyObjectType; + } + return type; + } + function getGlobalValueSymbol(name) { + return getGlobalSymbol(name, 107455, ts.Diagnostics.Cannot_find_global_value_0); + } + function getGlobalTypeSymbol(name) { + return getGlobalSymbol(name, 793056, ts.Diagnostics.Cannot_find_global_type_0); + } + function getGlobalSymbol(name, meaning, diagnostic) { + return resolveName(undefined, name, meaning, diagnostic, name); + } + function getGlobalType(name, arity) { + if (arity === void 0) { arity = 0; } + return getTypeOfGlobalSymbol(getGlobalTypeSymbol(name), arity); + } + function tryGetGlobalType(name, arity) { + if (arity === void 0) { arity = 0; } + return getTypeOfGlobalSymbol(getGlobalSymbol(name, 793056, undefined), arity); + } + function getExportedTypeFromNamespace(namespace, name) { + var namespaceSymbol = getGlobalSymbol(namespace, 1536, undefined); + var typeSymbol = namespaceSymbol && getSymbol(namespaceSymbol.exports, name, 793056); + return typeSymbol && getDeclaredTypeOfSymbol(typeSymbol); + } + function getGlobalESSymbolConstructorSymbol() { + return globalESSymbolConstructorSymbol || (globalESSymbolConstructorSymbol = getGlobalValueSymbol("Symbol")); + } + function createTypedPropertyDescriptorType(propertyType) { + var globalTypedPropertyDescriptorType = getGlobalTypedPropertyDescriptorType(); + return globalTypedPropertyDescriptorType !== emptyGenericType + ? createTypeReference(globalTypedPropertyDescriptorType, [propertyType]) + : emptyObjectType; + } + function createTypeFromGenericGlobalType(genericGlobalType, typeArguments) { + return genericGlobalType !== emptyGenericType ? createTypeReference(genericGlobalType, typeArguments) : emptyObjectType; + } + function createIterableType(elementType) { + return createTypeFromGenericGlobalType(globalIterableType, [elementType]); + } + function createIterableIteratorType(elementType) { + return createTypeFromGenericGlobalType(globalIterableIteratorType, [elementType]); + } + function createArrayType(elementType) { + return createTypeFromGenericGlobalType(globalArrayType, [elementType]); + } + function getTypeFromArrayTypeNode(node) { + var links = getNodeLinks(node); + if (!links.resolvedType) { + links.resolvedType = createArrayType(getTypeFromTypeNode(node.elementType)); + } + return links.resolvedType; + } + function createTupleType(elementTypes) { + var id = getTypeListId(elementTypes); + return tupleTypes[id] || (tupleTypes[id] = createNewTupleType(elementTypes)); + } + function createNewTupleType(elementTypes) { + var type = createObjectType(8192 | getPropagatingFlagsOfTypes(elementTypes)); + type.elementTypes = elementTypes; + return type; + } + function getTypeFromTupleTypeNode(node) { + var links = getNodeLinks(node); + if (!links.resolvedType) { + links.resolvedType = createTupleType(ts.map(node.elementTypes, getTypeFromTypeNode)); + } + return links.resolvedType; + } + function addTypeToSet(typeSet, type, typeSetKind) { + if (type.flags & typeSetKind) { + addTypesToSet(typeSet, type.types, typeSetKind); + } + else if (!ts.contains(typeSet, type)) { + typeSet.push(type); + } + } + function addTypesToSet(typeSet, types, typeSetKind) { + for (var _i = 0; _i < types.length; _i++) { + var type = types[_i]; + addTypeToSet(typeSet, type, typeSetKind); + } + } + function isSubtypeOfAny(candidate, types) { + for (var i = 0, len = types.length; i < len; i++) { + if (candidate !== types[i] && isTypeSubtypeOf(candidate, types[i])) { + return true; + } + } + return false; + } + function removeSubtypes(types) { + var i = types.length; + while (i > 0) { + i--; + if (isSubtypeOfAny(types[i], types)) { + types.splice(i, 1); + } + } + } + function containsTypeAny(types) { + for (var _i = 0; _i < types.length; _i++) { + var type = types[_i]; + if (isTypeAny(type)) { + return true; + } + } + return false; + } + function removeAllButLast(types, typeToRemove) { + var i = types.length; + while (i > 0 && types.length > 1) { + i--; + if (types[i] === typeToRemove) { + types.splice(i, 1); + } + } + } + function getUnionType(types, noSubtypeReduction) { + if (types.length === 0) { + return emptyObjectType; + } + var typeSet = []; + addTypesToSet(typeSet, types, 16384); + if (containsTypeAny(typeSet)) { + return anyType; + } + if (noSubtypeReduction) { + removeAllButLast(typeSet, undefinedType); + removeAllButLast(typeSet, nullType); + } + else { + removeSubtypes(typeSet); + } + if (typeSet.length === 1) { + return typeSet[0]; + } + var id = getTypeListId(typeSet); + var type = unionTypes[id]; + if (!type) { + type = unionTypes[id] = createObjectType(16384 | getPropagatingFlagsOfTypes(typeSet)); + type.types = typeSet; + } + return type; + } + function getTypeFromUnionTypeNode(node) { + var links = getNodeLinks(node); + if (!links.resolvedType) { + links.resolvedType = getUnionType(ts.map(node.types, getTypeFromTypeNode), true); + } + return links.resolvedType; + } + function getIntersectionType(types) { + if (types.length === 0) { + return emptyObjectType; + } + var typeSet = []; + addTypesToSet(typeSet, types, 32768); + if (containsTypeAny(typeSet)) { + return anyType; + } + if (typeSet.length === 1) { + return typeSet[0]; + } + var id = getTypeListId(typeSet); + var type = intersectionTypes[id]; + if (!type) { + type = intersectionTypes[id] = createObjectType(32768 | getPropagatingFlagsOfTypes(typeSet)); + type.types = typeSet; + } + return type; + } + function getTypeFromIntersectionTypeNode(node) { + var links = getNodeLinks(node); + if (!links.resolvedType) { + links.resolvedType = getIntersectionType(ts.map(node.types, getTypeFromTypeNode)); + } + return links.resolvedType; + } + function getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node) { + var links = getNodeLinks(node); + if (!links.resolvedType) { + links.resolvedType = createObjectType(65536, node.symbol); + } + return links.resolvedType; + } + function getStringLiteralType(node) { + if (ts.hasProperty(stringLiteralTypes, node.text)) { + return stringLiteralTypes[node.text]; + } + var type = stringLiteralTypes[node.text] = createType(256); + type.text = ts.getTextOfNode(node); + return type; + } + function getTypeFromStringLiteral(node) { + var links = getNodeLinks(node); + if (!links.resolvedType) { + links.resolvedType = getStringLiteralType(node); + } + return links.resolvedType; + } + function getThisType(node) { + var container = ts.getThisContainer(node, false); + var parent = container && container.parent; + if (parent && (ts.isClassLike(parent) || parent.kind === 215)) { + if (!(container.flags & 128)) { + return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(parent)).thisType; + } + } + error(node, ts.Diagnostics.A_this_type_is_available_only_in_a_non_static_member_of_a_class_or_interface); + return unknownType; + } + function getTypeFromThisTypeNode(node) { + var links = getNodeLinks(node); + if (!links.resolvedType) { + links.resolvedType = getThisType(node); + } + return links.resolvedType; + } + function getTypeFromTypeNode(node) { + switch (node.kind) { + case 117: + return anyType; + case 130: + return stringType; + case 128: + return numberType; + case 120: + return booleanType; + case 131: + return esSymbolType; + case 103: + return voidType; + case 97: + return getTypeFromThisTypeNode(node); + case 9: + return getTypeFromStringLiteral(node); + case 151: + return getTypeFromTypeReference(node); + case 150: + return booleanType; + case 188: + return getTypeFromTypeReference(node); + case 154: + return getTypeFromTypeQueryNode(node); + case 156: + return getTypeFromArrayTypeNode(node); + case 157: + return getTypeFromTupleTypeNode(node); + case 158: + return getTypeFromUnionTypeNode(node); + case 159: + return getTypeFromIntersectionTypeNode(node); + case 160: + return getTypeFromTypeNode(node.type); + case 152: + case 153: + case 155: + return getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node); + case 69: + case 135: + var symbol = getSymbolAtLocation(node); + return symbol && getDeclaredTypeOfSymbol(symbol); + default: + return unknownType; + } + } + function instantiateList(items, mapper, instantiator) { + if (items && items.length) { + var result = []; + for (var _i = 0; _i < items.length; _i++) { + var v = items[_i]; + result.push(instantiator(v, mapper)); + } + return result; + } + return items; + } + function createUnaryTypeMapper(source, target) { + return function (t) { return t === source ? target : t; }; + } + function createBinaryTypeMapper(source1, target1, source2, target2) { + return function (t) { return t === source1 ? target1 : t === source2 ? target2 : t; }; + } + function createTypeMapper(sources, targets) { + switch (sources.length) { + case 1: return createUnaryTypeMapper(sources[0], targets[0]); + case 2: return createBinaryTypeMapper(sources[0], targets[0], sources[1], targets[1]); + } + return function (t) { + for (var i = 0; i < sources.length; i++) { + if (t === sources[i]) { + return targets[i]; + } + } + return t; + }; + } + function createUnaryTypeEraser(source) { + return function (t) { return t === source ? anyType : t; }; + } + function createBinaryTypeEraser(source1, source2) { + return function (t) { return t === source1 || t === source2 ? anyType : t; }; + } + function createTypeEraser(sources) { + switch (sources.length) { + case 1: return createUnaryTypeEraser(sources[0]); + case 2: return createBinaryTypeEraser(sources[0], sources[1]); + } + return function (t) { + for (var _i = 0; _i < sources.length; _i++) { + var source = sources[_i]; + if (t === source) { + return anyType; + } + } + return t; + }; + } + function createInferenceMapper(context) { + var mapper = function (t) { + for (var i = 0; i < context.typeParameters.length; i++) { + if (t === context.typeParameters[i]) { + context.inferences[i].isFixed = true; + return getInferredType(context, i); + } + } + return t; + }; + mapper.context = context; + return mapper; + } + function identityMapper(type) { + return type; + } + function combineTypeMappers(mapper1, mapper2) { + return function (t) { return instantiateType(mapper1(t), mapper2); }; + } + function instantiateTypeParameter(typeParameter, mapper) { + var result = createType(512); + result.symbol = typeParameter.symbol; + if (typeParameter.constraint) { + result.constraint = instantiateType(typeParameter.constraint, mapper); + } + else { + result.target = typeParameter; + result.mapper = mapper; + } + return result; + } + function instantiateSignature(signature, mapper, eraseTypeParameters) { + var freshTypeParameters; + var freshTypePredicate; + if (signature.typeParameters && !eraseTypeParameters) { + freshTypeParameters = instantiateList(signature.typeParameters, mapper, instantiateTypeParameter); + mapper = combineTypeMappers(createTypeMapper(signature.typeParameters, freshTypeParameters), mapper); + } + if (signature.typePredicate) { + freshTypePredicate = { + parameterName: signature.typePredicate.parameterName, + parameterIndex: signature.typePredicate.parameterIndex, + type: instantiateType(signature.typePredicate.type, mapper) + }; + } + var result = createSignature(signature.declaration, freshTypeParameters, instantiateList(signature.parameters, mapper, instantiateSymbol), instantiateType(signature.resolvedReturnType, mapper), freshTypePredicate, signature.minArgumentCount, signature.hasRestParameter, signature.hasStringLiterals); + result.target = signature; + result.mapper = mapper; + return result; + } + function instantiateSymbol(symbol, mapper) { + if (symbol.flags & 16777216) { + var links = getSymbolLinks(symbol); + symbol = links.target; + mapper = combineTypeMappers(links.mapper, mapper); + } + var result = createSymbol(16777216 | 67108864 | symbol.flags, symbol.name); + result.declarations = symbol.declarations; + result.parent = symbol.parent; + result.target = symbol; + result.mapper = mapper; + if (symbol.valueDeclaration) { + result.valueDeclaration = symbol.valueDeclaration; + } + return result; + } + function instantiateAnonymousType(type, mapper) { + if (mapper.instantiations) { + var cachedType = mapper.instantiations[type.id]; + if (cachedType) { + return cachedType; + } + } + else { + mapper.instantiations = []; + } + var result = createObjectType(65536 | 131072, type.symbol); + result.target = type; + result.mapper = mapper; + mapper.instantiations[type.id] = result; + return result; + } + function instantiateType(type, mapper) { + if (type && mapper !== identityMapper) { + if (type.flags & 512) { + return mapper(type); + } + if (type.flags & 65536) { + return type.symbol && type.symbol.flags & (16 | 8192 | 32 | 2048 | 4096) ? + instantiateAnonymousType(type, mapper) : type; + } + if (type.flags & 4096) { + return createTypeReference(type.target, instantiateList(type.typeArguments, mapper, instantiateType)); + } + if (type.flags & 8192) { + return createTupleType(instantiateList(type.elementTypes, mapper, instantiateType)); + } + if (type.flags & 16384) { + return getUnionType(instantiateList(type.types, mapper, instantiateType), true); + } + if (type.flags & 32768) { + return getIntersectionType(instantiateList(type.types, mapper, instantiateType)); + } + } + return type; + } + function isContextSensitive(node) { + ts.Debug.assert(node.kind !== 143 || ts.isObjectLiteralMethod(node)); + switch (node.kind) { + case 173: + case 174: + return isContextSensitiveFunctionLikeDeclaration(node); + case 165: + return ts.forEach(node.properties, isContextSensitive); + case 164: + return ts.forEach(node.elements, isContextSensitive); + case 182: + return isContextSensitive(node.whenTrue) || + isContextSensitive(node.whenFalse); + case 181: + return node.operatorToken.kind === 52 && + (isContextSensitive(node.left) || isContextSensitive(node.right)); + case 245: + return isContextSensitive(node.initializer); + case 143: + case 142: + return isContextSensitiveFunctionLikeDeclaration(node); + case 172: + return isContextSensitive(node.expression); + } + return false; + } + function isContextSensitiveFunctionLikeDeclaration(node) { + return !node.typeParameters && node.parameters.length && !ts.forEach(node.parameters, function (p) { return p.type; }); + } + function getTypeWithoutSignatures(type) { + if (type.flags & 80896) { + var resolved = resolveStructuredTypeMembers(type); + if (resolved.constructSignatures.length) { + var result = createObjectType(65536, type.symbol); + result.members = resolved.members; + result.properties = resolved.properties; + result.callSignatures = emptyArray; + result.constructSignatures = emptyArray; + type = result; + } + } + return type; + } + function isTypeIdenticalTo(source, target) { + return checkTypeRelatedTo(source, target, identityRelation, undefined); + } + function compareTypes(source, target) { + return checkTypeRelatedTo(source, target, identityRelation, undefined) ? -1 : 0; + } + function isTypeSubtypeOf(source, target) { + return checkTypeSubtypeOf(source, target, undefined); + } + function isTypeAssignableTo(source, target) { + return checkTypeAssignableTo(source, target, undefined); + } + function checkTypeSubtypeOf(source, target, errorNode, headMessage, containingMessageChain) { + return checkTypeRelatedTo(source, target, subtypeRelation, errorNode, headMessage, containingMessageChain); + } + function checkTypeAssignableTo(source, target, errorNode, headMessage, containingMessageChain) { + return checkTypeRelatedTo(source, target, assignableRelation, errorNode, headMessage, containingMessageChain); + } + function isSignatureAssignableTo(source, target) { + var sourceType = getOrCreateTypeFromSignature(source); + var targetType = getOrCreateTypeFromSignature(target); + return checkTypeRelatedTo(sourceType, targetType, assignableRelation, undefined); + } + function checkTypeRelatedTo(source, target, relation, errorNode, headMessage, containingMessageChain) { + var errorInfo; + var sourceStack; + var targetStack; + var maybeStack; + var expandingFlags; + var depth = 0; + var overflow = false; + var elaborateErrors = false; + ts.Debug.assert(relation !== identityRelation || !errorNode, "no error reporting in identity checking"); + var result = isRelatedTo(source, target, errorNode !== undefined, headMessage); + if (overflow) { + error(errorNode, ts.Diagnostics.Excessive_stack_depth_comparing_types_0_and_1, typeToString(source), typeToString(target)); + } + else if (errorInfo) { + if (errorInfo.next === undefined) { + errorInfo = undefined; + elaborateErrors = true; + isRelatedTo(source, target, errorNode !== undefined, headMessage); + } + if (containingMessageChain) { + errorInfo = ts.concatenateDiagnosticMessageChains(containingMessageChain, errorInfo); + } + diagnostics.add(ts.createDiagnosticForNodeFromMessageChain(errorNode, errorInfo)); + } + return result !== 0; + function reportError(message, arg0, arg1, arg2) { + errorInfo = ts.chainDiagnosticMessages(errorInfo, message, arg0, arg1, arg2); + } + function reportRelationError(message, source, target) { + var sourceType = typeToString(source); + var targetType = typeToString(target); + if (sourceType === targetType) { + sourceType = typeToString(source, undefined, 128); + targetType = typeToString(target, undefined, 128); + } + reportError(message || ts.Diagnostics.Type_0_is_not_assignable_to_type_1, sourceType, targetType); + } + function isRelatedTo(source, target, reportErrors, headMessage) { + var result; + if (source === target) + return -1; + if (relation === identityRelation) { + return isIdenticalTo(source, target); + } + if (isTypeAny(target)) + return -1; + if (source === undefinedType) + return -1; + if (source === nullType && target !== undefinedType) + return -1; + if (source.flags & 128 && target === numberType) + return -1; + if (source.flags & 256 && target === stringType) + return -1; + if (relation === assignableRelation) { + if (isTypeAny(source)) + return -1; + if (source === numberType && target.flags & 128) + return -1; + } + if (source.flags & 1048576) { + if (hasExcessProperties(source, target, reportErrors)) { + if (reportErrors) { + reportRelationError(headMessage, source, target); + } + return 0; + } + if (target.flags & 49152) { + source = getRegularTypeOfObjectLiteral(source); + } + } + var saveErrorInfo = errorInfo; + if (source.flags & 16384) { + if (result = eachTypeRelatedToType(source, target, reportErrors)) { + return result; + } + } + else if (target.flags & 32768) { + if (result = typeRelatedToEachType(source, target, reportErrors)) { + return result; + } + } + else { + if (source.flags & 32768) { + if (result = someTypeRelatedToType(source, target, reportErrors && !(target.flags & 16384))) { + return result; + } + } + if (target.flags & 16384) { + if (result = typeRelatedToSomeType(source, target, reportErrors)) { + return result; + } + } + } + if (source.flags & 512) { + var constraint = getConstraintOfTypeParameter(source); + if (!constraint || constraint.flags & 1) { + constraint = emptyObjectType; + } + var reportConstraintErrors = reportErrors && constraint !== emptyObjectType; + if (result = isRelatedTo(constraint, target, reportConstraintErrors)) { + errorInfo = saveErrorInfo; + return result; + } + } + else { + if (source.flags & 4096 && target.flags & 4096 && source.target === target.target) { + if (result = typeArgumentsRelatedTo(source, target, reportErrors)) { + return result; + } + } + var apparentType = getApparentType(source); + if (apparentType.flags & (80896 | 32768) && target.flags & 80896) { + var reportStructuralErrors = reportErrors && errorInfo === saveErrorInfo; + if (result = objectTypeRelatedTo(apparentType, source, target, reportStructuralErrors)) { + errorInfo = saveErrorInfo; + return result; + } + } + } + if (reportErrors) { + reportRelationError(headMessage, source, target); + } + return 0; + } + function isIdenticalTo(source, target) { + var result; + if (source.flags & 80896 && target.flags & 80896) { + if (source.flags & 4096 && target.flags & 4096 && source.target === target.target) { + if (result = typeArgumentsRelatedTo(source, target, false)) { + return result; + } + } + return objectTypeRelatedTo(source, source, target, false); + } + if (source.flags & 512 && target.flags & 512) { + return typeParameterIdenticalTo(source, target); + } + if (source.flags & 16384 && target.flags & 16384 || + source.flags & 32768 && target.flags & 32768) { + if (result = eachTypeRelatedToSomeType(source, target)) { + if (result &= eachTypeRelatedToSomeType(target, source)) { + return result; + } + } + } + return 0; + } + function isKnownProperty(type, name) { + if (type.flags & 80896) { + var resolved = resolveStructuredTypeMembers(type); + if (relation === assignableRelation && (type === globalObjectType || resolved.properties.length === 0) || + resolved.stringIndexType || resolved.numberIndexType || getPropertyOfType(type, name)) { + return true; + } + } + else if (type.flags & 49152) { + for (var _i = 0, _a = type.types; _i < _a.length; _i++) { + var t = _a[_i]; + if (isKnownProperty(t, name)) { + return true; + } + } + } + return false; + } + function hasExcessProperties(source, target, reportErrors) { + if (someConstituentTypeHasKind(target, 80896)) { + for (var _i = 0, _a = getPropertiesOfObjectType(source); _i < _a.length; _i++) { + var prop = _a[_i]; + if (!isKnownProperty(target, prop.name)) { + if (reportErrors) { + errorNode = prop.valueDeclaration; + reportError(ts.Diagnostics.Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1, symbolToString(prop), typeToString(target)); + } + return true; + } + } + } + return false; + } + function eachTypeRelatedToSomeType(source, target) { + var result = -1; + var sourceTypes = source.types; + for (var _i = 0; _i < sourceTypes.length; _i++) { + var sourceType = sourceTypes[_i]; + var related = typeRelatedToSomeType(sourceType, target, false); + if (!related) { + return 0; + } + result &= related; + } + return result; + } + function typeRelatedToSomeType(source, target, reportErrors) { + var targetTypes = target.types; + for (var i = 0, len = targetTypes.length; i < len; i++) { + var related = isRelatedTo(source, targetTypes[i], reportErrors && i === len - 1); + if (related) { + return related; + } + } + return 0; + } + function typeRelatedToEachType(source, target, reportErrors) { + var result = -1; + var targetTypes = target.types; + for (var _i = 0; _i < targetTypes.length; _i++) { + var targetType = targetTypes[_i]; + var related = isRelatedTo(source, targetType, reportErrors); + if (!related) { + return 0; + } + result &= related; + } + return result; + } + function someTypeRelatedToType(source, target, reportErrors) { + var sourceTypes = source.types; + for (var i = 0, len = sourceTypes.length; i < len; i++) { + var related = isRelatedTo(sourceTypes[i], target, reportErrors && i === len - 1); + if (related) { + return related; + } + } + return 0; + } + function eachTypeRelatedToType(source, target, reportErrors) { + var result = -1; + var sourceTypes = source.types; + for (var _i = 0; _i < sourceTypes.length; _i++) { + var sourceType = sourceTypes[_i]; + var related = isRelatedTo(sourceType, target, reportErrors); + if (!related) { + return 0; + } + result &= related; + } + return result; + } + function typeArgumentsRelatedTo(source, target, reportErrors) { + var sources = source.typeArguments || emptyArray; + var targets = target.typeArguments || emptyArray; + if (sources.length !== targets.length && relation === identityRelation) { + return 0; + } + var result = -1; + for (var i = 0; i < targets.length; i++) { + var related = isRelatedTo(sources[i], targets[i], reportErrors); + if (!related) { + return 0; + } + result &= related; + } + return result; + } + function typeParameterIdenticalTo(source, target) { + if (source.symbol.name !== target.symbol.name) { + return 0; + } + if (source.constraint === target.constraint) { + return -1; + } + if (source.constraint === noConstraintType || target.constraint === noConstraintType) { + return 0; + } + return isIdenticalTo(source.constraint, target.constraint); + } + function objectTypeRelatedTo(apparentSource, originalSource, target, reportErrors) { + if (overflow) { + return 0; + } + var id = relation !== identityRelation || apparentSource.id < target.id ? apparentSource.id + "," + target.id : target.id + "," + apparentSource.id; + var related = relation[id]; + if (related !== undefined) { + if (!elaborateErrors || (related === 3)) { + return related === 1 ? -1 : 0; + } + } + if (depth > 0) { + for (var i = 0; i < depth; i++) { + if (maybeStack[i][id]) { + return 1; + } + } + if (depth === 100) { + overflow = true; + return 0; + } + } + else { + sourceStack = []; + targetStack = []; + maybeStack = []; + expandingFlags = 0; + } + sourceStack[depth] = apparentSource; + targetStack[depth] = target; + maybeStack[depth] = {}; + maybeStack[depth][id] = 1; + depth++; + var saveExpandingFlags = expandingFlags; + if (!(expandingFlags & 1) && isDeeplyNestedGeneric(apparentSource, sourceStack, depth)) + expandingFlags |= 1; + if (!(expandingFlags & 2) && isDeeplyNestedGeneric(target, targetStack, depth)) + expandingFlags |= 2; + var result; + if (expandingFlags === 3) { + result = 1; + } + else { + result = propertiesRelatedTo(apparentSource, target, reportErrors); + if (result) { + result &= signaturesRelatedTo(apparentSource, target, 0, reportErrors); + if (result) { + result &= signaturesRelatedTo(apparentSource, target, 1, reportErrors); + if (result) { + result &= stringIndexTypesRelatedTo(apparentSource, originalSource, target, reportErrors); + if (result) { + result &= numberIndexTypesRelatedTo(apparentSource, originalSource, target, reportErrors); + } + } + } + } + } + expandingFlags = saveExpandingFlags; + depth--; + if (result) { + var maybeCache = maybeStack[depth]; + var destinationCache = (result === -1 || depth === 0) ? relation : maybeStack[depth - 1]; + ts.copyMap(maybeCache, destinationCache); + } + else { + relation[id] = reportErrors ? 3 : 2; + } + return result; + } + function propertiesRelatedTo(source, target, reportErrors) { + if (relation === identityRelation) { + return propertiesIdenticalTo(source, target); + } + var result = -1; + var properties = getPropertiesOfObjectType(target); + var requireOptionalProperties = relation === subtypeRelation && !(source.flags & 524288); + for (var _i = 0; _i < properties.length; _i++) { + var targetProp = properties[_i]; + var sourceProp = getPropertyOfType(source, targetProp.name); + if (sourceProp !== targetProp) { + if (!sourceProp) { + if (!(targetProp.flags & 536870912) || requireOptionalProperties) { + if (reportErrors) { + reportError(ts.Diagnostics.Property_0_is_missing_in_type_1, symbolToString(targetProp), typeToString(source)); + } + return 0; + } + } + else if (!(targetProp.flags & 134217728)) { + var sourcePropFlags = getDeclarationFlagsFromSymbol(sourceProp); + var targetPropFlags = getDeclarationFlagsFromSymbol(targetProp); + if (sourcePropFlags & 32 || targetPropFlags & 32) { + if (sourceProp.valueDeclaration !== targetProp.valueDeclaration) { + if (reportErrors) { + if (sourcePropFlags & 32 && targetPropFlags & 32) { + reportError(ts.Diagnostics.Types_have_separate_declarations_of_a_private_property_0, symbolToString(targetProp)); + } + else { + reportError(ts.Diagnostics.Property_0_is_private_in_type_1_but_not_in_type_2, symbolToString(targetProp), typeToString(sourcePropFlags & 32 ? source : target), typeToString(sourcePropFlags & 32 ? target : source)); + } + } + return 0; + } + } + else if (targetPropFlags & 64) { + var sourceDeclaredInClass = sourceProp.parent && sourceProp.parent.flags & 32; + var sourceClass = sourceDeclaredInClass ? getDeclaredTypeOfSymbol(sourceProp.parent) : undefined; + var targetClass = getDeclaredTypeOfSymbol(targetProp.parent); + if (!sourceClass || !hasBaseType(sourceClass, targetClass)) { + if (reportErrors) { + reportError(ts.Diagnostics.Property_0_is_protected_but_type_1_is_not_a_class_derived_from_2, symbolToString(targetProp), typeToString(sourceClass || source), typeToString(targetClass)); + } + return 0; + } + } + else if (sourcePropFlags & 64) { + if (reportErrors) { + reportError(ts.Diagnostics.Property_0_is_protected_in_type_1_but_public_in_type_2, symbolToString(targetProp), typeToString(source), typeToString(target)); + } + return 0; + } + var related = isRelatedTo(getTypeOfSymbol(sourceProp), getTypeOfSymbol(targetProp), reportErrors); + if (!related) { + if (reportErrors) { + reportError(ts.Diagnostics.Types_of_property_0_are_incompatible, symbolToString(targetProp)); + } + return 0; + } + result &= related; + if (sourceProp.flags & 536870912 && !(targetProp.flags & 536870912)) { + if (reportErrors) { + reportError(ts.Diagnostics.Property_0_is_optional_in_type_1_but_required_in_type_2, symbolToString(targetProp), typeToString(source), typeToString(target)); + } + return 0; + } + } + } + } + return result; + } + function propertiesIdenticalTo(source, target) { + if (!(source.flags & 80896 && target.flags & 80896)) { + return 0; + } + var sourceProperties = getPropertiesOfObjectType(source); + var targetProperties = getPropertiesOfObjectType(target); + if (sourceProperties.length !== targetProperties.length) { + return 0; + } + var result = -1; + for (var _i = 0; _i < sourceProperties.length; _i++) { + var sourceProp = sourceProperties[_i]; + var targetProp = getPropertyOfObjectType(target, sourceProp.name); + if (!targetProp) { + return 0; + } + var related = compareProperties(sourceProp, targetProp, isRelatedTo); + if (!related) { + return 0; + } + result &= related; + } + return result; + } + function signaturesRelatedTo(source, target, kind, reportErrors) { + if (relation === identityRelation) { + return signaturesIdenticalTo(source, target, kind); + } + if (target === anyFunctionType || source === anyFunctionType) { + return -1; + } + var sourceSignatures = getSignaturesOfType(source, kind); + var targetSignatures = getSignaturesOfType(target, kind); + var result = -1; + var saveErrorInfo = errorInfo; + if (kind === 1) { + var sourceSig = sourceSignatures[0]; + var targetSig = targetSignatures[0]; + result &= abstractSignatureRelatedTo(source, sourceSig, target, targetSig); + if (result !== -1) { + return result; + } + } + outer: for (var _i = 0; _i < targetSignatures.length; _i++) { + var t = targetSignatures[_i]; + if (!t.hasStringLiterals || target.flags & 262144) { + var localErrors = reportErrors; + var checkedAbstractAssignability = false; + for (var _a = 0; _a < sourceSignatures.length; _a++) { + var s = sourceSignatures[_a]; + if (!s.hasStringLiterals || source.flags & 262144) { + var related = signatureRelatedTo(s, t, localErrors); + if (related) { + result &= related; + errorInfo = saveErrorInfo; + continue outer; + } + localErrors = false; + } + } + return 0; + } + } + return result; + function abstractSignatureRelatedTo(source, sourceSig, target, targetSig) { + if (sourceSig && targetSig) { + var sourceDecl = source.symbol && getClassLikeDeclarationOfSymbol(source.symbol); + var targetDecl = target.symbol && getClassLikeDeclarationOfSymbol(target.symbol); + if (!sourceDecl) { + return -1; + } + var sourceErasedSignature = getErasedSignature(sourceSig); + var targetErasedSignature = getErasedSignature(targetSig); + var sourceReturnType = sourceErasedSignature && getReturnTypeOfSignature(sourceErasedSignature); + var targetReturnType = targetErasedSignature && getReturnTypeOfSignature(targetErasedSignature); + var sourceReturnDecl = sourceReturnType && sourceReturnType.symbol && getClassLikeDeclarationOfSymbol(sourceReturnType.symbol); + var targetReturnDecl = targetReturnType && targetReturnType.symbol && getClassLikeDeclarationOfSymbol(targetReturnType.symbol); + var sourceIsAbstract = sourceReturnDecl && sourceReturnDecl.flags & 256; + var targetIsAbstract = targetReturnDecl && targetReturnDecl.flags & 256; + if (sourceIsAbstract && !(targetIsAbstract && targetDecl)) { + if (reportErrors) { + reportError(ts.Diagnostics.Cannot_assign_an_abstract_constructor_type_to_a_non_abstract_constructor_type); + } + return 0; + } + } + return -1; + } + } + function signatureRelatedTo(source, target, reportErrors) { + if (source === target) { + return -1; + } + if (!target.hasRestParameter && source.minArgumentCount > target.parameters.length) { + return 0; + } + var sourceMax = source.parameters.length; + var targetMax = target.parameters.length; + var checkCount; + if (source.hasRestParameter && target.hasRestParameter) { + checkCount = sourceMax > targetMax ? sourceMax : targetMax; + sourceMax--; + targetMax--; + } + else if (source.hasRestParameter) { + sourceMax--; + checkCount = targetMax; + } + else if (target.hasRestParameter) { + targetMax--; + checkCount = sourceMax; + } + else { + checkCount = sourceMax < targetMax ? sourceMax : targetMax; + } + source = getErasedSignature(source); + target = getErasedSignature(target); + var result = -1; + for (var i = 0; i < checkCount; i++) { + var s = i < sourceMax ? getTypeOfSymbol(source.parameters[i]) : getRestTypeOfSignature(source); + var t = i < targetMax ? getTypeOfSymbol(target.parameters[i]) : getRestTypeOfSignature(target); + var saveErrorInfo = errorInfo; + var related = isRelatedTo(s, t, reportErrors); + if (!related) { + related = isRelatedTo(t, s, false); + if (!related) { + if (reportErrors) { + reportError(ts.Diagnostics.Types_of_parameters_0_and_1_are_incompatible, source.parameters[i < sourceMax ? i : sourceMax].name, target.parameters[i < targetMax ? i : targetMax].name); + } + return 0; + } + errorInfo = saveErrorInfo; + } + result &= related; + } + if (source.typePredicate && target.typePredicate) { + var hasDifferentParameterIndex = source.typePredicate.parameterIndex !== target.typePredicate.parameterIndex; + var hasDifferentTypes; + if (hasDifferentParameterIndex || + (hasDifferentTypes = !isTypeIdenticalTo(source.typePredicate.type, target.typePredicate.type))) { + if (reportErrors) { + var sourceParamText = source.typePredicate.parameterName; + var targetParamText = target.typePredicate.parameterName; + var sourceTypeText = typeToString(source.typePredicate.type); + var targetTypeText = typeToString(target.typePredicate.type); + if (hasDifferentParameterIndex) { + reportError(ts.Diagnostics.Parameter_0_is_not_in_the_same_position_as_parameter_1, sourceParamText, targetParamText); + } + else if (hasDifferentTypes) { + reportError(ts.Diagnostics.Type_0_is_not_assignable_to_type_1, sourceTypeText, targetTypeText); + } + reportError(ts.Diagnostics.Type_predicate_0_is_not_assignable_to_1, sourceParamText + " is " + sourceTypeText, targetParamText + " is " + targetTypeText); + } + return 0; + } + } + else if (!source.typePredicate && target.typePredicate) { + if (reportErrors) { + reportError(ts.Diagnostics.Signature_0_must_have_a_type_predicate, signatureToString(source)); + } + return 0; + } + var targetReturnType = getReturnTypeOfSignature(target); + if (targetReturnType === voidType) + return result; + var sourceReturnType = getReturnTypeOfSignature(source); + return result & isRelatedTo(sourceReturnType, targetReturnType, reportErrors); + } + function signaturesIdenticalTo(source, target, kind) { + var sourceSignatures = getSignaturesOfType(source, kind); + var targetSignatures = getSignaturesOfType(target, kind); + if (sourceSignatures.length !== targetSignatures.length) { + return 0; + } + var result = -1; + for (var i = 0, len = sourceSignatures.length; i < len; ++i) { + var related = compareSignatures(sourceSignatures[i], targetSignatures[i], false, false, isRelatedTo); + if (!related) { + return 0; + } + result &= related; + } + return result; + } + function stringIndexTypesRelatedTo(source, originalSource, target, reportErrors) { + if (relation === identityRelation) { + return indexTypesIdenticalTo(0, source, target); + } + var targetType = getIndexTypeOfType(target, 0); + if (targetType) { + if ((targetType.flags & 1) && !(originalSource.flags & 16777726)) { + return -1; + } + var sourceType = getIndexTypeOfType(source, 0); + if (!sourceType) { + if (reportErrors) { + reportError(ts.Diagnostics.Index_signature_is_missing_in_type_0, typeToString(source)); + } + return 0; + } + var related = isRelatedTo(sourceType, targetType, reportErrors); + if (!related) { + if (reportErrors) { + reportError(ts.Diagnostics.Index_signatures_are_incompatible); + } + return 0; + } + return related; + } + return -1; + } + function numberIndexTypesRelatedTo(source, originalSource, target, reportErrors) { + if (relation === identityRelation) { + return indexTypesIdenticalTo(1, source, target); + } + var targetType = getIndexTypeOfType(target, 1); + if (targetType) { + if ((targetType.flags & 1) && !(originalSource.flags & 16777726)) { + return -1; + } + var sourceStringType = getIndexTypeOfType(source, 0); + var sourceNumberType = getIndexTypeOfType(source, 1); + if (!(sourceStringType || sourceNumberType)) { + if (reportErrors) { + reportError(ts.Diagnostics.Index_signature_is_missing_in_type_0, typeToString(source)); + } + return 0; + } + var related; + if (sourceStringType && sourceNumberType) { + related = isRelatedTo(sourceStringType, targetType, false) || isRelatedTo(sourceNumberType, targetType, reportErrors); + } + else { + related = isRelatedTo(sourceStringType || sourceNumberType, targetType, reportErrors); + } + if (!related) { + if (reportErrors) { + reportError(ts.Diagnostics.Index_signatures_are_incompatible); + } + return 0; + } + return related; + } + return -1; + } + function indexTypesIdenticalTo(indexKind, source, target) { + var targetType = getIndexTypeOfType(target, indexKind); + var sourceType = getIndexTypeOfType(source, indexKind); + if (!sourceType && !targetType) { + return -1; + } + if (sourceType && targetType) { + return isRelatedTo(sourceType, targetType); + } + return 0; + } + } + function isDeeplyNestedGeneric(type, stack, depth) { + if (type.flags & (4096 | 131072) && depth >= 5) { + var symbol = type.symbol; + var count = 0; + for (var i = 0; i < depth; i++) { + var t = stack[i]; + if (t.flags & (4096 | 131072) && t.symbol === symbol) { + count++; + if (count >= 5) + return true; + } + } + } + return false; + } + function isPropertyIdenticalTo(sourceProp, targetProp) { + return compareProperties(sourceProp, targetProp, compareTypes) !== 0; + } + function compareProperties(sourceProp, targetProp, compareTypes) { + if (sourceProp === targetProp) { + return -1; + } + var sourcePropAccessibility = getDeclarationFlagsFromSymbol(sourceProp) & (32 | 64); + var targetPropAccessibility = getDeclarationFlagsFromSymbol(targetProp) & (32 | 64); + if (sourcePropAccessibility !== targetPropAccessibility) { + return 0; + } + if (sourcePropAccessibility) { + if (getTargetSymbol(sourceProp) !== getTargetSymbol(targetProp)) { + return 0; + } + } + else { + if ((sourceProp.flags & 536870912) !== (targetProp.flags & 536870912)) { + return 0; + } + } + return compareTypes(getTypeOfSymbol(sourceProp), getTypeOfSymbol(targetProp)); + } + function compareSignatures(source, target, partialMatch, ignoreReturnTypes, compareTypes) { + if (source === target) { + return -1; + } + if (source.parameters.length !== target.parameters.length || + source.minArgumentCount !== target.minArgumentCount || + source.hasRestParameter !== target.hasRestParameter) { + if (!partialMatch || + source.parameters.length < target.parameters.length && !source.hasRestParameter || + source.minArgumentCount > target.minArgumentCount) { + return 0; + } + } + var result = -1; + if (source.typeParameters && target.typeParameters) { + if (source.typeParameters.length !== target.typeParameters.length) { + return 0; + } + for (var i = 0, len = source.typeParameters.length; i < len; ++i) { + var related = compareTypes(source.typeParameters[i], target.typeParameters[i]); + if (!related) { + return 0; + } + result &= related; + } + } + else if (source.typeParameters || target.typeParameters) { + return 0; + } + source = getErasedSignature(source); + target = getErasedSignature(target); + var targetLen = target.parameters.length; + for (var i = 0; i < targetLen; i++) { + var s = isRestParameterIndex(source, i) ? getRestTypeOfSignature(source) : getTypeOfSymbol(source.parameters[i]); + var t = isRestParameterIndex(target, i) ? getRestTypeOfSignature(target) : getTypeOfSymbol(target.parameters[i]); + var related = compareTypes(s, t); + if (!related) { + return 0; + } + result &= related; + } + if (!ignoreReturnTypes) { + result &= compareTypes(getReturnTypeOfSignature(source), getReturnTypeOfSignature(target)); + } + return result; + } + function isRestParameterIndex(signature, parameterIndex) { + return signature.hasRestParameter && parameterIndex >= signature.parameters.length - 1; + } + function isSupertypeOfEach(candidate, types) { + for (var _i = 0; _i < types.length; _i++) { + var type = types[_i]; + if (candidate !== type && !isTypeSubtypeOf(type, candidate)) + return false; + } + return true; + } + function getCommonSupertype(types) { + return ts.forEach(types, function (t) { return isSupertypeOfEach(t, types) ? t : undefined; }); + } + function reportNoCommonSupertypeError(types, errorLocation, errorMessageChainHead) { + var bestSupertype; + var bestSupertypeDownfallType; + var bestSupertypeScore = 0; + for (var i = 0; i < types.length; i++) { + var score = 0; + var downfallType = undefined; + for (var j = 0; j < types.length; j++) { + if (isTypeSubtypeOf(types[j], types[i])) { + score++; + } + else if (!downfallType) { + downfallType = types[j]; + } + } + ts.Debug.assert(!!downfallType, "If there is no common supertype, each type should have a downfallType"); + if (score > bestSupertypeScore) { + bestSupertype = types[i]; + bestSupertypeDownfallType = downfallType; + bestSupertypeScore = score; + } + if (bestSupertypeScore === types.length - 1) { + break; + } + } + checkTypeSubtypeOf(bestSupertypeDownfallType, bestSupertype, errorLocation, ts.Diagnostics.Type_argument_candidate_1_is_not_a_valid_type_argument_because_it_is_not_a_supertype_of_candidate_0, errorMessageChainHead); + } + function isArrayType(type) { + return type.flags & 4096 && type.target === globalArrayType; + } + function isArrayLikeType(type) { + return !(type.flags & (32 | 64)) && isTypeAssignableTo(type, anyArrayType); + } + function isTupleLikeType(type) { + return !!getPropertyOfType(type, "0"); + } + function isTupleType(type) { + return !!(type.flags & 8192); + } + function getRegularTypeOfObjectLiteral(type) { + if (type.flags & 1048576) { + var regularType = type.regularType; + if (!regularType) { + regularType = createType(type.flags & ~1048576); + regularType.symbol = type.symbol; + regularType.members = type.members; + regularType.properties = type.properties; + regularType.callSignatures = type.callSignatures; + regularType.constructSignatures = type.constructSignatures; + regularType.stringIndexType = type.stringIndexType; + regularType.numberIndexType = type.numberIndexType; + type.regularType = regularType; + } + return regularType; + } + return type; + } + function getWidenedTypeOfObjectLiteral(type) { + var properties = getPropertiesOfObjectType(type); + var members = {}; + ts.forEach(properties, function (p) { + var propType = getTypeOfSymbol(p); + var widenedType = getWidenedType(propType); + if (propType !== widenedType) { + var symbol = createSymbol(p.flags | 67108864, p.name); + symbol.declarations = p.declarations; + symbol.parent = p.parent; + symbol.type = widenedType; + symbol.target = p; + if (p.valueDeclaration) + symbol.valueDeclaration = p.valueDeclaration; + p = symbol; + } + members[p.name] = p; + }); + var stringIndexType = getIndexTypeOfType(type, 0); + var numberIndexType = getIndexTypeOfType(type, 1); + if (stringIndexType) + stringIndexType = getWidenedType(stringIndexType); + if (numberIndexType) + numberIndexType = getWidenedType(numberIndexType); + return createAnonymousType(type.symbol, members, emptyArray, emptyArray, stringIndexType, numberIndexType); + } + function getWidenedType(type) { + if (type.flags & 6291456) { + if (type.flags & (32 | 64)) { + return anyType; + } + if (type.flags & 524288) { + return getWidenedTypeOfObjectLiteral(type); + } + if (type.flags & 16384) { + return getUnionType(ts.map(type.types, getWidenedType), true); + } + if (isArrayType(type)) { + return createArrayType(getWidenedType(type.typeArguments[0])); + } + if (isTupleType(type)) { + return createTupleType(ts.map(type.elementTypes, getWidenedType)); + } + } + return type; + } + function reportWideningErrorsInType(type) { + var errorReported = false; + if (type.flags & 16384) { + for (var _i = 0, _a = type.types; _i < _a.length; _i++) { + var t = _a[_i]; + if (reportWideningErrorsInType(t)) { + errorReported = true; + } + } + } + if (isArrayType(type)) { + return reportWideningErrorsInType(type.typeArguments[0]); + } + if (isTupleType(type)) { + for (var _b = 0, _c = type.elementTypes; _b < _c.length; _b++) { + var t = _c[_b]; + if (reportWideningErrorsInType(t)) { + errorReported = true; + } + } + } + if (type.flags & 524288) { + for (var _d = 0, _e = getPropertiesOfObjectType(type); _d < _e.length; _d++) { + var p = _e[_d]; + var t = getTypeOfSymbol(p); + if (t.flags & 2097152) { + if (!reportWideningErrorsInType(t)) { + error(p.valueDeclaration, ts.Diagnostics.Object_literal_s_property_0_implicitly_has_an_1_type, p.name, typeToString(getWidenedType(t))); + } + errorReported = true; + } + } + } + return errorReported; + } + function reportImplicitAnyError(declaration, type) { + var typeAsString = typeToString(getWidenedType(type)); + var diagnostic; + switch (declaration.kind) { + case 141: + case 140: + diagnostic = ts.Diagnostics.Member_0_implicitly_has_an_1_type; + break; + case 138: + diagnostic = declaration.dotDotDotToken ? + ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type : + ts.Diagnostics.Parameter_0_implicitly_has_an_1_type; + break; + case 213: + case 143: + case 142: + case 145: + case 146: + case 173: + case 174: + if (!declaration.name) { + error(declaration, ts.Diagnostics.Function_expression_which_lacks_return_type_annotation_implicitly_has_an_0_return_type, typeAsString); + return; + } + diagnostic = ts.Diagnostics._0_which_lacks_return_type_annotation_implicitly_has_an_1_return_type; + break; + default: + diagnostic = ts.Diagnostics.Variable_0_implicitly_has_an_1_type; + } + error(declaration, diagnostic, ts.declarationNameToString(declaration.name), typeAsString); + } + function reportErrorsFromWidening(declaration, type) { + if (produceDiagnostics && compilerOptions.noImplicitAny && type.flags & 2097152) { + if (!reportWideningErrorsInType(type)) { + reportImplicitAnyError(declaration, type); + } + } + } + function forEachMatchingParameterType(source, target, callback) { + var sourceMax = source.parameters.length; + var targetMax = target.parameters.length; + var count; + if (source.hasRestParameter && target.hasRestParameter) { + count = sourceMax > targetMax ? sourceMax : targetMax; + sourceMax--; + targetMax--; + } + else if (source.hasRestParameter) { + sourceMax--; + count = targetMax; + } + else if (target.hasRestParameter) { + targetMax--; + count = sourceMax; + } + else { + count = sourceMax < targetMax ? sourceMax : targetMax; + } + for (var i = 0; i < count; i++) { + var s = i < sourceMax ? getTypeOfSymbol(source.parameters[i]) : getRestTypeOfSignature(source); + var t = i < targetMax ? getTypeOfSymbol(target.parameters[i]) : getRestTypeOfSignature(target); + callback(s, t); + } + } + function createInferenceContext(typeParameters, inferUnionTypes) { + var inferences = []; + for (var _i = 0; _i < typeParameters.length; _i++) { + var unused = typeParameters[_i]; + inferences.push({ + primary: undefined, secondary: undefined, isFixed: false + }); + } + return { + typeParameters: typeParameters, + inferUnionTypes: inferUnionTypes, + inferences: inferences, + inferredTypes: new Array(typeParameters.length) + }; + } + function inferTypes(context, source, target) { + var sourceStack; + var targetStack; + var depth = 0; + var inferiority = 0; + inferFromTypes(source, target); + function isInProcess(source, target) { + for (var i = 0; i < depth; i++) { + if (source === sourceStack[i] && target === targetStack[i]) { + return true; + } + } + return false; + } + function inferFromTypes(source, target) { + if (target.flags & 512) { + if (source.flags & 8388608) { + return; + } + var typeParameters = context.typeParameters; + for (var i = 0; i < typeParameters.length; i++) { + if (target === typeParameters[i]) { + var inferences = context.inferences[i]; + if (!inferences.isFixed) { + var candidates = inferiority ? + inferences.secondary || (inferences.secondary = []) : + inferences.primary || (inferences.primary = []); + if (!ts.contains(candidates, source)) { + candidates.push(source); + } + } + return; + } + } + } + else if (source.flags & 4096 && target.flags & 4096 && source.target === target.target) { + var sourceTypes = source.typeArguments || emptyArray; + var targetTypes = target.typeArguments || emptyArray; + var count = sourceTypes.length < targetTypes.length ? sourceTypes.length : targetTypes.length; + for (var i = 0; i < count; i++) { + inferFromTypes(sourceTypes[i], targetTypes[i]); + } + } + else if (source.flags & 8192 && target.flags & 8192 && source.elementTypes.length === target.elementTypes.length) { + var sourceTypes = source.elementTypes; + var targetTypes = target.elementTypes; + for (var i = 0; i < sourceTypes.length; i++) { + inferFromTypes(sourceTypes[i], targetTypes[i]); + } + } + else if (target.flags & 49152) { + var targetTypes = target.types; + var typeParameterCount = 0; + var typeParameter; + for (var _i = 0; _i < targetTypes.length; _i++) { + var t = targetTypes[_i]; + if (t.flags & 512 && ts.contains(context.typeParameters, t)) { + typeParameter = t; + typeParameterCount++; + } + else { + inferFromTypes(source, t); + } + } + if (target.flags & 16384 && typeParameterCount === 1) { + inferiority++; + inferFromTypes(source, typeParameter); + inferiority--; + } + } + else if (source.flags & 49152) { + var sourceTypes = source.types; + for (var _a = 0; _a < sourceTypes.length; _a++) { + var sourceType = sourceTypes[_a]; + inferFromTypes(sourceType, target); + } + } + else { + source = getApparentType(source); + if (source.flags & 80896 && (target.flags & (4096 | 8192) || + (target.flags & 65536) && target.symbol && target.symbol.flags & (8192 | 2048 | 32))) { + if (isInProcess(source, target)) { + return; + } + if (isDeeplyNestedGeneric(source, sourceStack, depth) && isDeeplyNestedGeneric(target, targetStack, depth)) { + return; + } + if (depth === 0) { + sourceStack = []; + targetStack = []; + } + sourceStack[depth] = source; + targetStack[depth] = target; + depth++; + inferFromProperties(source, target); + inferFromSignatures(source, target, 0); + inferFromSignatures(source, target, 1); + inferFromIndexTypes(source, target, 0, 0); + inferFromIndexTypes(source, target, 1, 1); + inferFromIndexTypes(source, target, 0, 1); + depth--; + } + } + } + function inferFromProperties(source, target) { + var properties = getPropertiesOfObjectType(target); + for (var _i = 0; _i < properties.length; _i++) { + var targetProp = properties[_i]; + var sourceProp = getPropertyOfObjectType(source, targetProp.name); + if (sourceProp) { + inferFromTypes(getTypeOfSymbol(sourceProp), getTypeOfSymbol(targetProp)); + } + } + } + function inferFromSignatures(source, target, kind) { + var sourceSignatures = getSignaturesOfType(source, kind); + var targetSignatures = getSignaturesOfType(target, kind); + var sourceLen = sourceSignatures.length; + var targetLen = targetSignatures.length; + var len = sourceLen < targetLen ? sourceLen : targetLen; + for (var i = 0; i < len; i++) { + inferFromSignature(getErasedSignature(sourceSignatures[sourceLen - len + i]), getErasedSignature(targetSignatures[targetLen - len + i])); + } + } + function inferFromSignature(source, target) { + forEachMatchingParameterType(source, target, inferFromTypes); + if (source.typePredicate && target.typePredicate) { + if (target.typePredicate.parameterIndex === source.typePredicate.parameterIndex) { + inferFromTypes(source.typePredicate.type, target.typePredicate.type); + } + } + else { + inferFromTypes(getReturnTypeOfSignature(source), getReturnTypeOfSignature(target)); + } + } + function inferFromIndexTypes(source, target, sourceKind, targetKind) { + var targetIndexType = getIndexTypeOfType(target, targetKind); + if (targetIndexType) { + var sourceIndexType = getIndexTypeOfType(source, sourceKind); + if (sourceIndexType) { + inferFromTypes(sourceIndexType, targetIndexType); + } + } + } + } + function getInferenceCandidates(context, index) { + var inferences = context.inferences[index]; + return inferences.primary || inferences.secondary || emptyArray; + } + function getInferredType(context, index) { + var inferredType = context.inferredTypes[index]; + var inferenceSucceeded; + if (!inferredType) { + var inferences = getInferenceCandidates(context, index); + if (inferences.length) { + var unionOrSuperType = context.inferUnionTypes ? getUnionType(inferences) : getCommonSupertype(inferences); + inferredType = unionOrSuperType ? getWidenedType(unionOrSuperType) : unknownType; + inferenceSucceeded = !!unionOrSuperType; + } + else { + inferredType = emptyObjectType; + inferenceSucceeded = true; + } + if (inferenceSucceeded) { + var constraint = getConstraintOfTypeParameter(context.typeParameters[index]); + inferredType = constraint && !isTypeAssignableTo(inferredType, constraint) ? constraint : inferredType; + } + else if (context.failedTypeParameterIndex === undefined || context.failedTypeParameterIndex > index) { + context.failedTypeParameterIndex = index; + } + context.inferredTypes[index] = inferredType; + } + return inferredType; + } + function getInferredTypes(context) { + for (var i = 0; i < context.inferredTypes.length; i++) { + getInferredType(context, i); + } + return context.inferredTypes; + } + function hasAncestor(node, kind) { + return ts.getAncestor(node, kind) !== undefined; + } + function getResolvedSymbol(node) { + var links = getNodeLinks(node); + if (!links.resolvedSymbol) { + links.resolvedSymbol = (!ts.nodeIsMissing(node) && resolveName(node, node.text, 107455 | 1048576, ts.Diagnostics.Cannot_find_name_0, node)) || unknownSymbol; + } + return links.resolvedSymbol; + } + function isInTypeQuery(node) { + while (node) { + switch (node.kind) { + case 154: + return true; + case 69: + case 135: + node = node.parent; + continue; + default: + return false; + } + } + ts.Debug.fail("should not get here"); + } + function removeTypesFromUnionType(type, typeKind, isOfTypeKind, allowEmptyUnionResult) { + if (type.flags & 16384) { + var types = type.types; + if (ts.forEach(types, function (t) { return !!(t.flags & typeKind) === isOfTypeKind; })) { + var narrowedType = getUnionType(ts.filter(types, function (t) { return !(t.flags & typeKind) === isOfTypeKind; })); + if (allowEmptyUnionResult || narrowedType !== emptyObjectType) { + return narrowedType; + } + } + } + else if (allowEmptyUnionResult && !!(type.flags & typeKind) === isOfTypeKind) { + return getUnionType(emptyArray); + } + return type; + } + function hasInitializer(node) { + return !!(node.initializer || ts.isBindingPattern(node.parent) && hasInitializer(node.parent.parent)); + } + function isVariableAssignedWithin(symbol, node) { + var links = getNodeLinks(node); + if (links.assignmentChecks) { + var cachedResult = links.assignmentChecks[symbol.id]; + if (cachedResult !== undefined) { + return cachedResult; + } + } + else { + links.assignmentChecks = {}; + } + return links.assignmentChecks[symbol.id] = isAssignedIn(node); + function isAssignedInBinaryExpression(node) { + if (node.operatorToken.kind >= 56 && node.operatorToken.kind <= 68) { + var n = node.left; + while (n.kind === 172) { + n = n.expression; + } + if (n.kind === 69 && getResolvedSymbol(n) === symbol) { + return true; + } + } + return ts.forEachChild(node, isAssignedIn); + } + function isAssignedInVariableDeclaration(node) { + if (!ts.isBindingPattern(node.name) && getSymbolOfNode(node) === symbol && hasInitializer(node)) { + return true; + } + return ts.forEachChild(node, isAssignedIn); + } + function isAssignedIn(node) { + switch (node.kind) { + case 181: + return isAssignedInBinaryExpression(node); + case 211: + case 163: + return isAssignedInVariableDeclaration(node); + case 161: + case 162: + case 164: + case 165: + case 166: + case 167: + case 168: + case 169: + case 171: + case 189: + case 172: + case 179: + case 175: + case 178: + case 176: + case 177: + case 180: + case 184: + case 182: + case 185: + case 192: + case 193: + case 195: + case 196: + case 197: + case 198: + case 199: + case 200: + case 201: + case 204: + case 205: + case 206: + case 241: + case 242: + case 207: + case 208: + case 209: + case 244: + case 233: + case 234: + case 238: + case 239: + case 235: + case 240: + return ts.forEachChild(node, isAssignedIn); + } + return false; + } + } + function getNarrowedTypeOfSymbol(symbol, node) { + var type = getTypeOfSymbol(symbol); + if (node && symbol.flags & 3) { + if (isTypeAny(type) || type.flags & (80896 | 16384 | 512)) { + loop: while (node.parent) { + var child = node; + node = node.parent; + var narrowedType = type; + switch (node.kind) { + case 196: + if (child !== node.expression) { + narrowedType = narrowType(type, node.expression, child === node.thenStatement); + } + break; + case 182: + if (child !== node.condition) { + narrowedType = narrowType(type, node.condition, child === node.whenTrue); + } + break; + case 181: + if (child === node.right) { + if (node.operatorToken.kind === 51) { + narrowedType = narrowType(type, node.left, true); + } + else if (node.operatorToken.kind === 52) { + narrowedType = narrowType(type, node.left, false); + } + } + break; + case 248: + case 218: + case 213: + case 143: + case 142: + case 145: + case 146: + case 144: + break loop; + } + if (narrowedType !== type) { + if (isVariableAssignedWithin(symbol, node)) { + break; + } + type = narrowedType; + } + } + } + } + return type; + function narrowTypeByEquality(type, expr, assumeTrue) { + if (expr.left.kind !== 176 || expr.right.kind !== 9) { + return type; + } + var left = expr.left; + var right = expr.right; + if (left.expression.kind !== 69 || getResolvedSymbol(left.expression) !== symbol) { + return type; + } + var typeInfo = primitiveTypeInfo[right.text]; + if (expr.operatorToken.kind === 33) { + assumeTrue = !assumeTrue; + } + if (assumeTrue) { + if (!typeInfo) { + return removeTypesFromUnionType(type, 258 | 132 | 8 | 16777216, true, false); + } + if (isTypeSubtypeOf(typeInfo.type, type)) { + return typeInfo.type; + } + return removeTypesFromUnionType(type, typeInfo.flags, false, false); + } + else { + if (typeInfo) { + return removeTypesFromUnionType(type, typeInfo.flags, true, false); + } + return type; + } + } + function narrowTypeByAnd(type, expr, assumeTrue) { + if (assumeTrue) { + return narrowType(narrowType(type, expr.left, true), expr.right, true); + } + else { + return getUnionType([ + narrowType(type, expr.left, false), + narrowType(narrowType(type, expr.left, true), expr.right, false) + ]); + } + } + function narrowTypeByOr(type, expr, assumeTrue) { + if (assumeTrue) { + return getUnionType([ + narrowType(type, expr.left, true), + narrowType(narrowType(type, expr.left, false), expr.right, true) + ]); + } + else { + return narrowType(narrowType(type, expr.left, false), expr.right, false); + } + } + function narrowTypeByInstanceof(type, expr, assumeTrue) { + if (isTypeAny(type) || !assumeTrue || expr.left.kind !== 69 || getResolvedSymbol(expr.left) !== symbol) { + return type; + } + var rightType = checkExpression(expr.right); + if (!isTypeSubtypeOf(rightType, globalFunctionType)) { + return type; + } + var targetType; + var prototypeProperty = getPropertyOfType(rightType, "prototype"); + if (prototypeProperty) { + var prototypePropertyType = getTypeOfSymbol(prototypeProperty); + if (!isTypeAny(prototypePropertyType)) { + targetType = prototypePropertyType; + } + } + if (!targetType) { + var constructSignatures; + if (rightType.flags & 2048) { + constructSignatures = resolveDeclaredMembers(rightType).declaredConstructSignatures; + } + else if (rightType.flags & 65536) { + constructSignatures = getSignaturesOfType(rightType, 1); + } + if (constructSignatures && constructSignatures.length) { + targetType = getUnionType(ts.map(constructSignatures, function (signature) { return getReturnTypeOfSignature(getErasedSignature(signature)); })); + } + } + if (targetType) { + return getNarrowedType(type, targetType); + } + return type; + } + function getNarrowedType(originalType, narrowedTypeCandidate) { + if (originalType.flags & 16384) { + var assignableConstituents = ts.filter(originalType.types, function (t) { return isTypeAssignableTo(t, narrowedTypeCandidate); }); + if (assignableConstituents.length) { + return getUnionType(assignableConstituents); + } + } + if (isTypeAssignableTo(narrowedTypeCandidate, originalType)) { + return narrowedTypeCandidate; + } + return originalType; + } + function narrowTypeByTypePredicate(type, expr, assumeTrue) { + if (type.flags & 1) { + return type; + } + var signature = getResolvedSignature(expr); + if (signature.typePredicate && + expr.arguments[signature.typePredicate.parameterIndex] && + getSymbolAtLocation(expr.arguments[signature.typePredicate.parameterIndex]) === symbol) { + if (!assumeTrue) { + if (type.flags & 16384) { + return getUnionType(ts.filter(type.types, function (t) { return !isTypeSubtypeOf(t, signature.typePredicate.type); })); + } + return type; + } + return getNarrowedType(type, signature.typePredicate.type); + } + return type; + } + function narrowType(type, expr, assumeTrue) { + switch (expr.kind) { + case 168: + return narrowTypeByTypePredicate(type, expr, assumeTrue); + case 172: + return narrowType(type, expr.expression, assumeTrue); + case 181: + var operator = expr.operatorToken.kind; + if (operator === 32 || operator === 33) { + return narrowTypeByEquality(type, expr, assumeTrue); + } + else if (operator === 51) { + return narrowTypeByAnd(type, expr, assumeTrue); + } + else if (operator === 52) { + return narrowTypeByOr(type, expr, assumeTrue); + } + else if (operator === 91) { + return narrowTypeByInstanceof(type, expr, assumeTrue); + } + break; + case 179: + if (expr.operator === 49) { + return narrowType(type, expr.operand, !assumeTrue); + } + break; + } + return type; + } + } + function checkIdentifier(node) { + var symbol = getResolvedSymbol(node); + if (symbol === argumentsSymbol) { + var container = ts.getContainingFunction(node); + if (container.kind === 174) { + if (languageVersion < 2) { + error(node, ts.Diagnostics.The_arguments_object_cannot_be_referenced_in_an_arrow_function_in_ES3_and_ES5_Consider_using_a_standard_function_expression); + } + } + if (node.parserContextFlags & 8) { + getNodeLinks(container).flags |= 4096; + getNodeLinks(node).flags |= 2048; + } + } + if (symbol.flags & 8388608 && !isInTypeQuery(node) && !isConstEnumOrConstEnumOnlyModule(resolveAlias(symbol))) { + markAliasSymbolAsReferenced(symbol); + } + checkCollisionWithCapturedSuperVariable(node, node); + checkCollisionWithCapturedThisVariable(node, node); + checkBlockScopedBindingCapturedInLoop(node, symbol); + return getNarrowedTypeOfSymbol(getExportSymbolOfValueSymbolIfExported(symbol), node); + } + function isInsideFunction(node, threshold) { + var current = node; + while (current && current !== threshold) { + if (ts.isFunctionLike(current)) { + return true; + } + current = current.parent; + } + return false; + } + function checkBlockScopedBindingCapturedInLoop(node, symbol) { + if (languageVersion >= 2 || + (symbol.flags & (2 | 32)) === 0 || + symbol.valueDeclaration.parent.kind === 244) { + return; + } + var container; + if (symbol.flags & 32) { + container = getClassLikeDeclarationOfSymbol(symbol).parent; + } + else { + container = symbol.valueDeclaration; + while (container.kind !== 212) { + container = container.parent; + } + container = container.parent; + if (container.kind === 193) { + container = container.parent; + } + } + var inFunction = isInsideFunction(node.parent, container); + var current = container; + while (current && !ts.nodeStartsNewLexicalEnvironment(current)) { + if (ts.isIterationStatement(current, false)) { + if (inFunction) { + getNodeLinks(current).flags |= 65536; + } + getNodeLinks(symbol.valueDeclaration).flags |= 16384; + break; + } + current = current.parent; + } + } + function captureLexicalThis(node, container) { + getNodeLinks(node).flags |= 2; + if (container.kind === 141 || container.kind === 144) { + var classNode = container.parent; + getNodeLinks(classNode).flags |= 4; + } + else { + getNodeLinks(container).flags |= 4; + } + } + function checkThisExpression(node) { + var container = ts.getThisContainer(node, true); + var needToCaptureLexicalThis = false; + if (container.kind === 174) { + container = ts.getThisContainer(container, false); + needToCaptureLexicalThis = (languageVersion < 2); + } + switch (container.kind) { + case 218: + error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_module_or_namespace_body); + break; + case 217: + error(node, ts.Diagnostics.this_cannot_be_referenced_in_current_location); + break; + case 144: + if (isInConstructorArgumentInitializer(node, container)) { + error(node, ts.Diagnostics.this_cannot_be_referenced_in_constructor_arguments); + } + break; + case 141: + case 140: + if (container.flags & 128) { + error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_static_property_initializer); + } + break; + case 136: + error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_computed_property_name); + break; + } + if (needToCaptureLexicalThis) { + captureLexicalThis(node, container); + } + if (ts.isClassLike(container.parent)) { + var symbol = getSymbolOfNode(container.parent); + return container.flags & 128 ? getTypeOfSymbol(symbol) : getDeclaredTypeOfSymbol(symbol).thisType; + } + return anyType; + } + function isInConstructorArgumentInitializer(node, constructorDecl) { + for (var n = node; n && n !== constructorDecl; n = n.parent) { + if (n.kind === 138) { + return true; + } + } + return false; + } + function checkSuperExpression(node) { + var isCallExpression = node.parent.kind === 168 && node.parent.expression === node; + var classDeclaration = ts.getContainingClass(node); + var classType = classDeclaration && getDeclaredTypeOfSymbol(getSymbolOfNode(classDeclaration)); + var baseClassType = classType && getBaseTypes(classType)[0]; + var container = ts.getSuperContainer(node, true); + var needToCaptureLexicalThis = false; + if (!isCallExpression) { + while (container && container.kind === 174) { + container = ts.getSuperContainer(container, true); + needToCaptureLexicalThis = languageVersion < 2; + } + } + var canUseSuperExpression = isLegalUsageOfSuperExpression(container); + var nodeCheckFlag = 0; + if (canUseSuperExpression) { + if ((container.flags & 128) || isCallExpression) { + nodeCheckFlag = 512; + } + else { + nodeCheckFlag = 256; + } + getNodeLinks(node).flags |= nodeCheckFlag; + if (needToCaptureLexicalThis) { + captureLexicalThis(node.parent, container); + } + } + if (!baseClassType) { + if (!classDeclaration || !ts.getClassExtendsHeritageClauseElement(classDeclaration)) { + error(node, ts.Diagnostics.super_can_only_be_referenced_in_a_derived_class); + } + return unknownType; + } + if (!canUseSuperExpression) { + if (container && container.kind === 136) { + 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 { + error(node, ts.Diagnostics.super_property_access_is_permitted_only_in_a_constructor_member_function_or_member_accessor_of_a_derived_class); + } + return unknownType; + } + if (container.kind === 144 && isInConstructorArgumentInitializer(node, container)) { + error(node, ts.Diagnostics.super_cannot_be_referenced_in_constructor_arguments); + return unknownType; + } + return nodeCheckFlag === 512 + ? getBaseConstructorTypeOfClass(classType) + : baseClassType; + function isLegalUsageOfSuperExpression(container) { + if (!container) { + return false; + } + if (isCallExpression) { + return container.kind === 144; + } + else { + if (container && ts.isClassLike(container.parent)) { + if (container.flags & 128) { + return container.kind === 143 || + container.kind === 142 || + container.kind === 145 || + container.kind === 146; + } + else { + return container.kind === 143 || + container.kind === 142 || + container.kind === 145 || + container.kind === 146 || + container.kind === 141 || + container.kind === 140 || + container.kind === 144; + } + } + } + return false; + } + } + function getContextuallyTypedParameterType(parameter) { + var func = parameter.parent; + if (isFunctionExpressionOrArrowFunction(func) || ts.isObjectLiteralMethod(func)) { + if (isContextSensitive(func)) { + var contextualSignature = getContextualSignature(func); + if (contextualSignature) { + var funcHasRestParameters = ts.hasRestParameter(func); + var len = func.parameters.length - (funcHasRestParameters ? 1 : 0); + var indexOfParameter = ts.indexOf(func.parameters, parameter); + if (indexOfParameter < len) { + return getTypeAtPosition(contextualSignature, indexOfParameter); + } + if (funcHasRestParameters && + indexOfParameter === (func.parameters.length - 1) && + isRestParameterIndex(contextualSignature, func.parameters.length - 1)) { + return getTypeOfSymbol(ts.lastOrUndefined(contextualSignature.parameters)); + } + } + } + } + return undefined; + } + function getContextualTypeForInitializerExpression(node) { + var declaration = node.parent; + if (node === declaration.initializer) { + if (declaration.type) { + return getTypeFromTypeNode(declaration.type); + } + if (declaration.kind === 138) { + var type = getContextuallyTypedParameterType(declaration); + if (type) { + return type; + } + } + if (ts.isBindingPattern(declaration.name)) { + return getTypeFromBindingPattern(declaration.name, true); + } + } + return undefined; + } + function getContextualTypeForReturnExpression(node) { + var func = ts.getContainingFunction(node); + if (func && !func.asteriskToken) { + return getContextualReturnType(func); + } + return undefined; + } + function getContextualTypeForYieldOperand(node) { + var func = ts.getContainingFunction(node); + if (func) { + var contextualReturnType = getContextualReturnType(func); + if (contextualReturnType) { + return node.asteriskToken + ? contextualReturnType + : getElementTypeOfIterableIterator(contextualReturnType); + } + } + return undefined; + } + function isInParameterInitializerBeforeContainingFunction(node) { + while (node.parent && !ts.isFunctionLike(node.parent)) { + if (node.parent.kind === 138 && node.parent.initializer === node) { + return true; + } + node = node.parent; + } + return false; + } + function getContextualReturnType(functionDecl) { + if (functionDecl.type || + functionDecl.kind === 144 || + functionDecl.kind === 145 && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(functionDecl.symbol, 146))) { + return getReturnTypeOfSignature(getSignatureFromDeclaration(functionDecl)); + } + var signature = getContextualSignatureForFunctionLikeDeclaration(functionDecl); + if (signature) { + return getReturnTypeOfSignature(signature); + } + return undefined; + } + function getContextualTypeForArgument(callTarget, arg) { + var args = getEffectiveCallArguments(callTarget); + var argIndex = ts.indexOf(args, arg); + if (argIndex >= 0) { + var signature = getResolvedSignature(callTarget); + return getTypeAtPosition(signature, argIndex); + } + return undefined; + } + function getContextualTypeForSubstitutionExpression(template, substitutionExpression) { + if (template.parent.kind === 170) { + return getContextualTypeForArgument(template.parent, substitutionExpression); + } + return undefined; + } + function getContextualTypeForBinaryOperand(node) { + var binaryExpression = node.parent; + var operator = binaryExpression.operatorToken.kind; + if (operator >= 56 && operator <= 68) { + if (node === binaryExpression.right) { + return checkExpression(binaryExpression.left); + } + } + else if (operator === 52) { + var type = getContextualType(binaryExpression); + if (!type && node === binaryExpression.right) { + type = checkExpression(binaryExpression.left); + } + return type; + } + return undefined; + } + function applyToContextualType(type, mapper) { + if (!(type.flags & 16384)) { + return mapper(type); + } + var types = type.types; + var mappedType; + var mappedTypes; + for (var _i = 0; _i < types.length; _i++) { + var current = types[_i]; + var t = mapper(current); + if (t) { + if (!mappedType) { + mappedType = t; + } + else if (!mappedTypes) { + mappedTypes = [mappedType, t]; + } + else { + mappedTypes.push(t); + } + } + } + return mappedTypes ? getUnionType(mappedTypes) : mappedType; + } + function getTypeOfPropertyOfContextualType(type, name) { + return applyToContextualType(type, function (t) { + var prop = t.flags & 130048 ? getPropertyOfType(t, name) : undefined; + return prop ? getTypeOfSymbol(prop) : undefined; + }); + } + function getIndexTypeOfContextualType(type, kind) { + return applyToContextualType(type, function (t) { return getIndexTypeOfStructuredType(t, kind); }); + } + function contextualTypeIsTupleLikeType(type) { + return !!(type.flags & 16384 ? ts.forEach(type.types, isTupleLikeType) : isTupleLikeType(type)); + } + function contextualTypeHasIndexSignature(type, kind) { + return !!(type.flags & 16384 ? ts.forEach(type.types, function (t) { return getIndexTypeOfStructuredType(t, kind); }) : getIndexTypeOfStructuredType(type, kind)); + } + function getContextualTypeForObjectLiteralMethod(node) { + ts.Debug.assert(ts.isObjectLiteralMethod(node)); + if (isInsideWithStatementBody(node)) { + return undefined; + } + return getContextualTypeForObjectLiteralElement(node); + } + function getContextualTypeForObjectLiteralElement(element) { + var objectLiteral = element.parent; + var type = getContextualType(objectLiteral); + if (type) { + if (!ts.hasDynamicName(element)) { + var symbolName = getSymbolOfNode(element).name; + var propertyType = getTypeOfPropertyOfContextualType(type, symbolName); + if (propertyType) { + return propertyType; + } + } + return isNumericName(element.name) && getIndexTypeOfContextualType(type, 1) || + getIndexTypeOfContextualType(type, 0); + } + return undefined; + } + function getContextualTypeForElementExpression(node) { + var arrayLiteral = node.parent; + var type = getContextualType(arrayLiteral); + if (type) { + var index = ts.indexOf(arrayLiteral.elements, node); + return getTypeOfPropertyOfContextualType(type, "" + index) + || getIndexTypeOfContextualType(type, 1) + || (languageVersion >= 2 ? getElementTypeOfIterable(type, undefined) : undefined); + } + return undefined; + } + function getContextualTypeForConditionalOperand(node) { + var conditional = node.parent; + return node === conditional.whenTrue || node === conditional.whenFalse ? getContextualType(conditional) : undefined; + } + function getContextualTypeForJsxExpression(expr) { + if (expr.parent.kind === 238) { + var attrib = expr.parent; + var attrsType = getJsxElementAttributesType(attrib.parent); + if (!attrsType || isTypeAny(attrsType)) { + return undefined; + } + else { + return getTypeOfPropertyOfType(attrsType, attrib.name.text); + } + } + if (expr.kind === 239) { + return getJsxElementAttributesType(expr.parent); + } + return undefined; + } + function getContextualType(node) { + var type = getContextualTypeWorker(node); + return type && getApparentType(type); + } + function getContextualTypeWorker(node) { + if (isInsideWithStatementBody(node)) { + return undefined; + } + if (node.contextualType) { + return node.contextualType; + } + var parent = node.parent; + switch (parent.kind) { + case 211: + case 138: + case 141: + case 140: + case 163: + return getContextualTypeForInitializerExpression(node); + case 174: + case 204: + return getContextualTypeForReturnExpression(node); + case 184: + return getContextualTypeForYieldOperand(parent); + case 168: + case 169: + return getContextualTypeForArgument(parent, node); + case 171: + case 189: + return getTypeFromTypeNode(parent.type); + case 181: + return getContextualTypeForBinaryOperand(node); + case 245: + return getContextualTypeForObjectLiteralElement(parent); + case 164: + return getContextualTypeForElementExpression(node); + case 182: + return getContextualTypeForConditionalOperand(node); + case 190: + ts.Debug.assert(parent.parent.kind === 183); + return getContextualTypeForSubstitutionExpression(parent.parent, node); + case 172: + return getContextualType(parent); + case 240: + case 239: + return getContextualTypeForJsxExpression(parent); + } + return undefined; + } + function getNonGenericSignature(type) { + var signatures = getSignaturesOfStructuredType(type, 0); + if (signatures.length === 1) { + var signature = signatures[0]; + if (!signature.typeParameters) { + return signature; + } + } + } + function isFunctionExpressionOrArrowFunction(node) { + return node.kind === 173 || node.kind === 174; + } + function getContextualSignatureForFunctionLikeDeclaration(node) { + return isFunctionExpressionOrArrowFunction(node) || ts.isObjectLiteralMethod(node) + ? getContextualSignature(node) + : undefined; + } + function getContextualSignature(node) { + ts.Debug.assert(node.kind !== 143 || ts.isObjectLiteralMethod(node)); + var type = ts.isObjectLiteralMethod(node) + ? getContextualTypeForObjectLiteralMethod(node) + : getContextualType(node); + if (!type) { + return undefined; + } + if (!(type.flags & 16384)) { + return getNonGenericSignature(type); + } + var signatureList; + var types = type.types; + for (var _i = 0; _i < types.length; _i++) { + var current = types[_i]; + var signature = getNonGenericSignature(current); + if (signature) { + if (!signatureList) { + signatureList = [signature]; + } + else if (!compareSignatures(signatureList[0], signature, false, true, compareTypes)) { + return undefined; + } + else { + signatureList.push(signature); + } + } + } + var result; + if (signatureList) { + result = cloneSignature(signatureList[0]); + result.resolvedReturnType = undefined; + result.unionSignatures = signatureList; + } + return result; + } + function isInferentialContext(mapper) { + return mapper && mapper.context; + } + function isAssignmentTarget(node) { + var parent = node.parent; + if (parent.kind === 181 && parent.operatorToken.kind === 56 && parent.left === node) { + return true; + } + if (parent.kind === 245) { + return isAssignmentTarget(parent.parent); + } + if (parent.kind === 164) { + return isAssignmentTarget(parent); + } + return false; + } + function checkSpreadElementExpression(node, contextualMapper) { + var arrayOrIterableType = checkExpressionCached(node.expression, contextualMapper); + return checkIteratedTypeOrElementType(arrayOrIterableType, node.expression, false); + } + function hasDefaultValue(node) { + return (node.kind === 163 && !!node.initializer) || + (node.kind === 181 && node.operatorToken.kind === 56); + } + function checkArrayLiteral(node, contextualMapper) { + var elements = node.elements; + var hasSpreadElement = false; + var elementTypes = []; + var inDestructuringPattern = isAssignmentTarget(node); + for (var _i = 0; _i < elements.length; _i++) { + var e = elements[_i]; + if (inDestructuringPattern && e.kind === 185) { + var restArrayType = checkExpression(e.expression, contextualMapper); + var restElementType = getIndexTypeOfType(restArrayType, 1) || + (languageVersion >= 2 ? getElementTypeOfIterable(restArrayType, undefined) : undefined); + if (restElementType) { + elementTypes.push(restElementType); + } + } + else { + var type = checkExpression(e, contextualMapper); + elementTypes.push(type); + } + hasSpreadElement = hasSpreadElement || e.kind === 185; + } + if (!hasSpreadElement) { + if (inDestructuringPattern && elementTypes.length) { + var type = createNewTupleType(elementTypes); + type.pattern = node; + return type; + } + var contextualType = getContextualType(node); + if (contextualType && contextualTypeIsTupleLikeType(contextualType)) { + var pattern = contextualType.pattern; + if (pattern && (pattern.kind === 162 || pattern.kind === 164)) { + var patternElements = pattern.elements; + for (var i = elementTypes.length; i < patternElements.length; i++) { + var patternElement = patternElements[i]; + if (hasDefaultValue(patternElement)) { + elementTypes.push(contextualType.elementTypes[i]); + } + else { + if (patternElement.kind !== 187) { + error(patternElement, ts.Diagnostics.Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value); + } + elementTypes.push(unknownType); + } + } + } + if (elementTypes.length) { + return createTupleType(elementTypes); + } + } + } + return createArrayType(elementTypes.length ? getUnionType(elementTypes) : undefinedType); + } + function isNumericName(name) { + return name.kind === 136 ? isNumericComputedName(name) : isNumericLiteralName(name.text); + } + function isNumericComputedName(name) { + return isTypeAnyOrAllConstituentTypesHaveKind(checkComputedPropertyName(name), 132); + } + function isTypeAnyOrAllConstituentTypesHaveKind(type, kind) { + return isTypeAny(type) || allConstituentTypesHaveKind(type, kind); + } + function isNumericLiteralName(name) { + return (+name).toString() === name; + } + function checkComputedPropertyName(node) { + var links = getNodeLinks(node.expression); + if (!links.resolvedType) { + links.resolvedType = checkExpression(node.expression); + if (!isTypeAnyOrAllConstituentTypesHaveKind(links.resolvedType, 132 | 258 | 16777216)) { + error(node, ts.Diagnostics.A_computed_property_name_must_be_of_type_string_number_symbol_or_any); + } + else { + checkThatExpressionIsProperSymbolReference(node.expression, links.resolvedType, true); + } + } + return links.resolvedType; + } + function checkObjectLiteral(node, contextualMapper) { + var inDestructuringPattern = isAssignmentTarget(node); + checkGrammarObjectLiteralExpression(node, inDestructuringPattern); + var propertiesTable = {}; + var propertiesArray = []; + var contextualType = getContextualType(node); + var contextualTypeHasPattern = contextualType && contextualType.pattern && + (contextualType.pattern.kind === 161 || contextualType.pattern.kind === 165); + var typeFlags = 0; + for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { + var memberDecl = _a[_i]; + var member = memberDecl.symbol; + if (memberDecl.kind === 245 || + memberDecl.kind === 246 || + ts.isObjectLiteralMethod(memberDecl)) { + var type = void 0; + if (memberDecl.kind === 245) { + type = checkPropertyAssignment(memberDecl, contextualMapper); + } + else if (memberDecl.kind === 143) { + type = checkObjectLiteralMethod(memberDecl, contextualMapper); + } + else { + ts.Debug.assert(memberDecl.kind === 246); + type = checkExpression(memberDecl.name, contextualMapper); + } + typeFlags |= type.flags; + var prop = createSymbol(4 | 67108864 | member.flags, member.name); + if (inDestructuringPattern) { + var isOptional = (memberDecl.kind === 245 && hasDefaultValue(memberDecl.initializer)) || + (memberDecl.kind === 246 && memberDecl.objectAssignmentInitializer); + if (isOptional) { + prop.flags |= 536870912; + } + } + else if (contextualTypeHasPattern) { + var impliedProp = getPropertyOfType(contextualType, member.name); + if (impliedProp) { + prop.flags |= impliedProp.flags & 536870912; + } + else if (!compilerOptions.suppressExcessPropertyErrors) { + error(memberDecl.name, ts.Diagnostics.Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1, symbolToString(member), typeToString(contextualType)); + } + } + prop.declarations = member.declarations; + prop.parent = member.parent; + if (member.valueDeclaration) { + prop.valueDeclaration = member.valueDeclaration; + } + prop.type = type; + prop.target = member; + member = prop; + } + else { + ts.Debug.assert(memberDecl.kind === 145 || memberDecl.kind === 146); + checkAccessorDeclaration(memberDecl); + } + if (!ts.hasDynamicName(memberDecl)) { + propertiesTable[member.name] = member; + } + propertiesArray.push(member); + } + if (contextualTypeHasPattern) { + for (var _b = 0, _c = getPropertiesOfType(contextualType); _b < _c.length; _b++) { + var prop = _c[_b]; + if (!ts.hasProperty(propertiesTable, prop.name)) { + if (!(prop.flags & 536870912)) { + error(prop.valueDeclaration || prop.bindingElement, ts.Diagnostics.Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value); + } + propertiesTable[prop.name] = prop; + propertiesArray.push(prop); + } + } + } + var stringIndexType = getIndexType(0); + var numberIndexType = getIndexType(1); + var result = createAnonymousType(node.symbol, propertiesTable, emptyArray, emptyArray, stringIndexType, numberIndexType); + var freshObjectLiteralFlag = compilerOptions.suppressExcessPropertyErrors ? 0 : 1048576; + result.flags |= 524288 | 4194304 | freshObjectLiteralFlag | (typeFlags & 14680064); + if (inDestructuringPattern) { + result.pattern = node; + } + return result; + function getIndexType(kind) { + if (contextualType && contextualTypeHasIndexSignature(contextualType, kind)) { + var propTypes = []; + for (var i = 0; i < propertiesArray.length; i++) { + var propertyDecl = node.properties[i]; + if (kind === 0 || isNumericName(propertyDecl.name)) { + var type = getTypeOfSymbol(propertiesArray[i]); + if (!ts.contains(propTypes, type)) { + propTypes.push(type); + } + } + } + var result_1 = propTypes.length ? getUnionType(propTypes) : undefinedType; + typeFlags |= result_1.flags; + return result_1; + } + return undefined; + } + } + function checkJsxSelfClosingElement(node) { + checkJsxOpeningLikeElement(node); + return jsxElementType || anyType; + } + function tagNamesAreEquivalent(lhs, rhs) { + if (lhs.kind !== rhs.kind) { + return false; + } + if (lhs.kind === 69) { + return lhs.text === rhs.text; + } + return lhs.right.text === rhs.right.text && + tagNamesAreEquivalent(lhs.left, rhs.left); + } + function checkJsxElement(node) { + checkJsxOpeningLikeElement(node.openingElement); + if (!tagNamesAreEquivalent(node.openingElement.tagName, node.closingElement.tagName)) { + error(node.closingElement, ts.Diagnostics.Expected_corresponding_JSX_closing_tag_for_0, ts.getTextOfNode(node.openingElement.tagName)); + } + else { + getJsxElementTagSymbol(node.closingElement); + } + for (var _i = 0, _a = node.children; _i < _a.length; _i++) { + var child = _a[_i]; + switch (child.kind) { + case 240: + checkJsxExpression(child); + break; + case 233: + checkJsxElement(child); + break; + case 234: + checkJsxSelfClosingElement(child); + break; + } + } + return jsxElementType || anyType; + } + function isUnhyphenatedJsxName(name) { + return name.indexOf("-") < 0; + } + function isJsxIntrinsicIdentifier(tagName) { + if (tagName.kind === 135) { + return false; + } + else { + return ts.isIntrinsicJsxName(tagName.text); + } + } + function checkJsxAttribute(node, elementAttributesType, nameTable) { + var correspondingPropType = undefined; + if (elementAttributesType === emptyObjectType && isUnhyphenatedJsxName(node.name.text)) { + error(node.parent, ts.Diagnostics.JSX_element_class_does_not_support_attributes_because_it_does_not_have_a_0_property, getJsxElementPropertiesName()); + } + else if (elementAttributesType && !isTypeAny(elementAttributesType)) { + var correspondingPropSymbol = getPropertyOfType(elementAttributesType, node.name.text); + correspondingPropType = correspondingPropSymbol && getTypeOfSymbol(correspondingPropSymbol); + if (isUnhyphenatedJsxName(node.name.text)) { + var indexerType = getIndexTypeOfType(elementAttributesType, 0); + if (indexerType) { + correspondingPropType = indexerType; + } + else { + if (!correspondingPropType) { + error(node.name, ts.Diagnostics.Property_0_does_not_exist_on_type_1, node.name.text, typeToString(elementAttributesType)); + return unknownType; + } + } + } + } + var exprType; + if (node.initializer) { + exprType = checkExpression(node.initializer); + } + else { + exprType = booleanType; + } + if (correspondingPropType) { + checkTypeAssignableTo(exprType, correspondingPropType, node); + } + nameTable[node.name.text] = true; + return exprType; + } + function checkJsxSpreadAttribute(node, elementAttributesType, nameTable) { + var type = checkExpression(node.expression); + var props = getPropertiesOfType(type); + for (var _i = 0; _i < props.length; _i++) { + var prop = props[_i]; + if (!nameTable[prop.name]) { + var targetPropSym = getPropertyOfType(elementAttributesType, prop.name); + if (targetPropSym) { + var msg = ts.chainDiagnosticMessages(undefined, ts.Diagnostics.Property_0_of_JSX_spread_attribute_is_not_assignable_to_target_property, prop.name); + checkTypeAssignableTo(getTypeOfSymbol(prop), getTypeOfSymbol(targetPropSym), node, undefined, msg); + } + nameTable[prop.name] = true; + } + } + return type; + } + function getJsxIntrinsicElementsType() { + if (!jsxIntrinsicElementsType) { + jsxIntrinsicElementsType = getExportedTypeFromNamespace(JsxNames.JSX, JsxNames.IntrinsicElements) || unknownType; + } + return jsxIntrinsicElementsType; + } + function getJsxElementTagSymbol(node) { + var flags = 8; + var links = getNodeLinks(node); + if (!links.resolvedSymbol) { + if (isJsxIntrinsicIdentifier(node.tagName)) { + links.resolvedSymbol = lookupIntrinsicTag(node); + } + else { + links.resolvedSymbol = lookupClassTag(node); + } + } + return links.resolvedSymbol; + function lookupIntrinsicTag(node) { + var intrinsicElementsType = getJsxIntrinsicElementsType(); + if (intrinsicElementsType !== unknownType) { + var intrinsicProp = getPropertyOfType(intrinsicElementsType, node.tagName.text); + if (intrinsicProp) { + links.jsxFlags |= 1; + return intrinsicProp; + } + var indexSignatureType = getIndexTypeOfType(intrinsicElementsType, 0); + if (indexSignatureType) { + links.jsxFlags |= 2; + return intrinsicElementsType.symbol; + } + error(node, ts.Diagnostics.Property_0_does_not_exist_on_type_1, node.tagName.text, "JSX." + JsxNames.IntrinsicElements); + return unknownSymbol; + } + else { + if (compilerOptions.noImplicitAny) { + error(node, ts.Diagnostics.JSX_element_implicitly_has_type_any_because_no_interface_JSX_0_exists, JsxNames.IntrinsicElements); + } + } + } + function lookupClassTag(node) { + var valueSymbol = resolveJsxTagName(node); + if (valueSymbol && valueSymbol !== unknownSymbol) { + links.jsxFlags |= 4; + if (valueSymbol.flags & 8388608) { + markAliasSymbolAsReferenced(valueSymbol); + } + } + return valueSymbol || unknownSymbol; + } + function resolveJsxTagName(node) { + if (node.tagName.kind === 69) { + var tag = node.tagName; + var sym = getResolvedSymbol(tag); + return sym.exportSymbol || sym; + } + else { + return checkQualifiedName(node.tagName).symbol; + } + } + } + function getJsxElementInstanceType(node) { + ts.Debug.assert(!!(getNodeLinks(node).jsxFlags & 4), "Should not call getJsxElementInstanceType on non-class Element"); + var classSymbol = getJsxElementTagSymbol(node); + if (classSymbol === unknownSymbol) { + return anyType; + } + var valueType = getTypeOfSymbol(classSymbol); + if (isTypeAny(valueType)) { + return anyType; + } + var signatures = getSignaturesOfType(valueType, 1); + if (signatures.length === 0) { + signatures = getSignaturesOfType(valueType, 0); + if (signatures.length === 0) { + error(node.tagName, ts.Diagnostics.JSX_element_type_0_does_not_have_any_construct_or_call_signatures, ts.getTextOfNode(node.tagName)); + return unknownType; + } + } + var returnType = getUnionType(signatures.map(getReturnTypeOfSignature)); + var elemClassType = getJsxGlobalElementClassType(); + if (elemClassType) { + checkTypeRelatedTo(returnType, elemClassType, assignableRelation, node, ts.Diagnostics.JSX_element_type_0_is_not_a_constructor_function_for_JSX_elements); + } + return returnType; + } + function getJsxElementPropertiesName() { + var jsxNamespace = getGlobalSymbol(JsxNames.JSX, 1536, undefined); + var attribsPropTypeSym = jsxNamespace && getSymbol(jsxNamespace.exports, JsxNames.ElementAttributesPropertyNameContainer, 793056); + var attribPropType = attribsPropTypeSym && getDeclaredTypeOfSymbol(attribsPropTypeSym); + var attribProperties = attribPropType && getPropertiesOfType(attribPropType); + if (attribProperties) { + if (attribProperties.length === 0) { + return ""; + } + else if (attribProperties.length === 1) { + return attribProperties[0].name; + } + else { + error(attribsPropTypeSym.declarations[0], ts.Diagnostics.The_global_type_JSX_0_may_not_have_more_than_one_property, JsxNames.ElementAttributesPropertyNameContainer); + return undefined; + } + } + else { + return undefined; + } + } + function getJsxElementAttributesType(node) { + var links = getNodeLinks(node); + if (!links.resolvedJsxType) { + var sym = getJsxElementTagSymbol(node); + if (links.jsxFlags & 4) { + var elemInstanceType = getJsxElementInstanceType(node); + if (isTypeAny(elemInstanceType)) { + return links.resolvedJsxType = elemInstanceType; + } + var propsName = getJsxElementPropertiesName(); + if (propsName === undefined) { + return links.resolvedJsxType = anyType; + } + else if (propsName === "") { + return links.resolvedJsxType = elemInstanceType; + } + else { + var attributesType = getTypeOfPropertyOfType(elemInstanceType, propsName); + if (!attributesType) { + return links.resolvedJsxType = emptyObjectType; + } + else if (isTypeAny(attributesType) || (attributesType === unknownType)) { + return links.resolvedJsxType = attributesType; + } + else if (!(attributesType.flags & 80896)) { + error(node.tagName, ts.Diagnostics.JSX_element_attributes_type_0_must_be_an_object_type, typeToString(attributesType)); + return links.resolvedJsxType = anyType; + } + else { + return links.resolvedJsxType = attributesType; + } + } + } + else if (links.jsxFlags & 1) { + return links.resolvedJsxType = getTypeOfSymbol(sym); + } + else if (links.jsxFlags & 2) { + return links.resolvedJsxType = getIndexTypeOfSymbol(sym, 0); + } + else { + return links.resolvedJsxType = anyType; + } + } + return links.resolvedJsxType; + } + function getJsxAttributePropertySymbol(attrib) { + var attributesType = getJsxElementAttributesType(attrib.parent); + var prop = getPropertyOfType(attributesType, attrib.name.text); + return prop || unknownSymbol; + } + var jsxElementClassType = undefined; + function getJsxGlobalElementClassType() { + if (!jsxElementClassType) { + jsxElementClassType = getExportedTypeFromNamespace(JsxNames.JSX, JsxNames.ElementClass); + } + return jsxElementClassType; + } + function getJsxIntrinsicTagNames() { + var intrinsics = getJsxIntrinsicElementsType(); + return intrinsics ? getPropertiesOfType(intrinsics) : emptyArray; + } + function checkJsxPreconditions(errorNode) { + if ((compilerOptions.jsx || 0) === 0) { + error(errorNode, ts.Diagnostics.Cannot_use_JSX_unless_the_jsx_flag_is_provided); + } + if (jsxElementType === undefined) { + if (compilerOptions.noImplicitAny) { + error(errorNode, ts.Diagnostics.JSX_element_implicitly_has_type_any_because_the_global_type_JSX_Element_does_not_exist); + } + } + } + function checkJsxOpeningLikeElement(node) { + checkGrammarJsxElement(node); + checkJsxPreconditions(node); + if (compilerOptions.jsx === 2) { + var reactSym = resolveName(node.tagName, "React", 107455, ts.Diagnostics.Cannot_find_name_0, "React"); + if (reactSym) { + getSymbolLinks(reactSym).referenced = true; + } + } + var targetAttributesType = getJsxElementAttributesType(node); + var nameTable = {}; + var sawSpreadedAny = false; + for (var i = node.attributes.length - 1; i >= 0; i--) { + if (node.attributes[i].kind === 238) { + checkJsxAttribute((node.attributes[i]), targetAttributesType, nameTable); + } + else { + ts.Debug.assert(node.attributes[i].kind === 239); + var spreadType = checkJsxSpreadAttribute((node.attributes[i]), targetAttributesType, nameTable); + if (isTypeAny(spreadType)) { + sawSpreadedAny = true; + } + } + } + if (targetAttributesType && !sawSpreadedAny) { + var targetProperties = getPropertiesOfType(targetAttributesType); + for (var i = 0; i < targetProperties.length; i++) { + if (!(targetProperties[i].flags & 536870912) && + nameTable[targetProperties[i].name] === undefined) { + error(node, ts.Diagnostics.Property_0_is_missing_in_type_1, targetProperties[i].name, typeToString(targetAttributesType)); + } + } + } + } + function checkJsxExpression(node) { + if (node.expression) { + return checkExpression(node.expression); + } + else { + return unknownType; + } + } + function getDeclarationKindFromSymbol(s) { + return s.valueDeclaration ? s.valueDeclaration.kind : 141; + } + function getDeclarationFlagsFromSymbol(s) { + return s.valueDeclaration ? ts.getCombinedNodeFlags(s.valueDeclaration) : s.flags & 134217728 ? 16 | 128 : 0; + } + function checkClassPropertyAccess(node, left, type, prop) { + var flags = getDeclarationFlagsFromSymbol(prop); + var declaringClass = getDeclaredTypeOfSymbol(prop.parent); + if (left.kind === 95) { + var errorNode = node.kind === 166 ? + node.name : + node.right; + if (getDeclarationKindFromSymbol(prop) !== 143) { + error(errorNode, ts.Diagnostics.Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword); + return false; + } + if (flags & 256) { + error(errorNode, ts.Diagnostics.Abstract_method_0_in_class_1_cannot_be_accessed_via_super_expression, symbolToString(prop), typeToString(declaringClass)); + return false; + } + } + if (!(flags & (32 | 64))) { + return true; + } + var enclosingClassDeclaration = ts.getContainingClass(node); + var enclosingClass = enclosingClassDeclaration ? getDeclaredTypeOfSymbol(getSymbolOfNode(enclosingClassDeclaration)) : undefined; + if (flags & 32) { + if (declaringClass !== enclosingClass) { + error(node, ts.Diagnostics.Property_0_is_private_and_only_accessible_within_class_1, symbolToString(prop), typeToString(declaringClass)); + return false; + } + return true; + } + if (left.kind === 95) { + return true; + } + if (!enclosingClass || !hasBaseType(enclosingClass, declaringClass)) { + error(node, ts.Diagnostics.Property_0_is_protected_and_only_accessible_within_class_1_and_its_subclasses, symbolToString(prop), typeToString(declaringClass)); + return false; + } + if (flags & 128) { + return true; + } + if (type.flags & 33554432) { + type = getConstraintOfTypeParameter(type); + } + if (!(getTargetType(type).flags & (1024 | 2048) && hasBaseType(type, enclosingClass))) { + error(node, ts.Diagnostics.Property_0_is_protected_and_only_accessible_through_an_instance_of_class_1, symbolToString(prop), typeToString(enclosingClass)); + return false; + } + return true; + } + function checkPropertyAccessExpression(node) { + return checkPropertyAccessExpressionOrQualifiedName(node, node.expression, node.name); + } + function checkQualifiedName(node) { + return checkPropertyAccessExpressionOrQualifiedName(node, node.left, node.right); + } + function checkPropertyAccessExpressionOrQualifiedName(node, left, right) { + var type = checkExpression(left); + if (isTypeAny(type)) { + return type; + } + var apparentType = getApparentType(getWidenedType(type)); + if (apparentType === unknownType) { + return unknownType; + } + var prop = getPropertyOfType(apparentType, right.text); + if (!prop) { + if (right.text) { + error(right, ts.Diagnostics.Property_0_does_not_exist_on_type_1, ts.declarationNameToString(right), typeToString(type.flags & 33554432 ? apparentType : type)); + } + return unknownType; + } + getNodeLinks(node).resolvedSymbol = prop; + if (prop.parent && prop.parent.flags & 32) { + checkClassPropertyAccess(node, left, apparentType, prop); + } + return getTypeOfSymbol(prop); + } + function isValidPropertyAccess(node, propertyName) { + var left = node.kind === 166 + ? node.expression + : node.left; + var type = checkExpression(left); + if (type !== unknownType && !isTypeAny(type)) { + var prop = getPropertyOfType(getWidenedType(type), propertyName); + if (prop && prop.parent && prop.parent.flags & 32) { + return checkClassPropertyAccess(node, left, type, prop); + } + } + return true; + } + function checkIndexedAccess(node) { + if (!node.argumentExpression) { + var sourceFile = getSourceFile(node); + if (node.parent.kind === 169 && node.parent.expression === node) { + var start = ts.skipTrivia(sourceFile.text, node.expression.end); + var end = node.end; + grammarErrorAtPos(sourceFile, start, end - start, ts.Diagnostics.new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead); + } + else { + var start = node.end - "]".length; + var end = node.end; + grammarErrorAtPos(sourceFile, start, end - start, ts.Diagnostics.Expression_expected); + } + } + var objectType = getApparentType(checkExpression(node.expression)); + var indexType = node.argumentExpression ? checkExpression(node.argumentExpression) : unknownType; + if (objectType === unknownType) { + return unknownType; + } + var isConstEnum = isConstEnumObjectType(objectType); + if (isConstEnum && + (!node.argumentExpression || node.argumentExpression.kind !== 9)) { + error(node.argumentExpression, ts.Diagnostics.A_const_enum_member_can_only_be_accessed_using_a_string_literal); + return unknownType; + } + if (node.argumentExpression) { + var name_11 = getPropertyNameForIndexedAccess(node.argumentExpression, indexType); + if (name_11 !== undefined) { + var prop = getPropertyOfType(objectType, name_11); + 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_11, symbolToString(objectType.symbol)); + return unknownType; + } + } + } + if (isTypeAnyOrAllConstituentTypesHaveKind(indexType, 258 | 132 | 16777216)) { + if (isTypeAnyOrAllConstituentTypesHaveKind(indexType, 132)) { + var numberIndexType = getIndexTypeOfType(objectType, 1); + if (numberIndexType) { + return numberIndexType; + } + } + var stringIndexType = getIndexTypeOfType(objectType, 0); + if (stringIndexType) { + return stringIndexType; + } + if (compilerOptions.noImplicitAny && !compilerOptions.suppressImplicitAnyIndexErrors && !isTypeAny(objectType)) { + error(node, ts.Diagnostics.Index_signature_of_object_type_implicitly_has_an_any_type); + } + return anyType; + } + error(node, ts.Diagnostics.An_index_expression_argument_must_be_of_type_string_number_symbol_or_any); + return unknownType; + } + function getPropertyNameForIndexedAccess(indexArgumentExpression, indexArgumentType) { + if (indexArgumentExpression.kind === 9 || indexArgumentExpression.kind === 8) { + return indexArgumentExpression.text; + } + if (indexArgumentExpression.kind === 167 || indexArgumentExpression.kind === 166) { + var value = getConstantValue(indexArgumentExpression); + if (value !== undefined) { + return value.toString(); + } + } + if (checkThatExpressionIsProperSymbolReference(indexArgumentExpression, indexArgumentType, false)) { + var rightHandSideName = indexArgumentExpression.name.text; + return ts.getPropertyNameForKnownSymbolName(rightHandSideName); + } + return undefined; + } + function checkThatExpressionIsProperSymbolReference(expression, expressionType, reportError) { + if (expressionType === unknownType) { + return false; + } + if (!ts.isWellKnownSymbolSyntactically(expression)) { + return false; + } + if ((expressionType.flags & 16777216) === 0) { + if (reportError) { + error(expression, ts.Diagnostics.A_computed_property_name_of_the_form_0_must_be_of_type_symbol, ts.getTextOfNode(expression)); + } + return false; + } + var leftHandSide = expression.expression; + var leftHandSideSymbol = getResolvedSymbol(leftHandSide); + if (!leftHandSideSymbol) { + return false; + } + var globalESSymbol = getGlobalESSymbolConstructorSymbol(); + if (!globalESSymbol) { + return false; + } + if (leftHandSideSymbol !== globalESSymbol) { + if (reportError) { + error(leftHandSide, ts.Diagnostics.Symbol_reference_does_not_refer_to_the_global_Symbol_constructor_object); + } + return false; + } + return true; + } + function resolveUntypedCall(node) { + if (node.kind === 170) { + checkExpression(node.template); + } + else if (node.kind !== 139) { + ts.forEach(node.arguments, function (argument) { + checkExpression(argument); + }); + } + return anySignature; + } + function resolveErrorCall(node) { + resolveUntypedCall(node); + return unknownSignature; + } + function reorderCandidates(signatures, result) { + var lastParent; + var lastSymbol; + var cutoffIndex = 0; + var index; + var specializedIndex = -1; + var spliceIndex; + ts.Debug.assert(!result.length); + for (var _i = 0; _i < signatures.length; _i++) { + var signature = signatures[_i]; + var symbol = signature.declaration && getSymbolOfNode(signature.declaration); + var parent_5 = signature.declaration && signature.declaration.parent; + if (!lastSymbol || symbol === lastSymbol) { + if (lastParent && parent_5 === lastParent) { + index++; + } + else { + lastParent = parent_5; + index = cutoffIndex; + } + } + else { + index = cutoffIndex = result.length; + lastParent = parent_5; + } + lastSymbol = symbol; + if (signature.hasStringLiterals) { + specializedIndex++; + spliceIndex = specializedIndex; + cutoffIndex++; + } + else { + spliceIndex = index; + } + result.splice(spliceIndex, 0, signature); + } + } + function getSpreadArgumentIndex(args) { + for (var i = 0; i < args.length; i++) { + var arg = args[i]; + if (arg && arg.kind === 185) { + return i; + } + } + return -1; + } + function hasCorrectArity(node, args, signature) { + var adjustedArgCount; + var typeArguments; + var callIsIncomplete; + var isDecorator; + var spreadArgIndex = -1; + if (node.kind === 170) { + var tagExpression = node; + adjustedArgCount = args.length; + typeArguments = undefined; + if (tagExpression.template.kind === 183) { + var templateExpression = tagExpression.template; + var lastSpan = ts.lastOrUndefined(templateExpression.templateSpans); + ts.Debug.assert(lastSpan !== undefined); + callIsIncomplete = ts.nodeIsMissing(lastSpan.literal) || !!lastSpan.literal.isUnterminated; + } + else { + var templateLiteral = tagExpression.template; + ts.Debug.assert(templateLiteral.kind === 11); + callIsIncomplete = !!templateLiteral.isUnterminated; + } + } + else if (node.kind === 139) { + isDecorator = true; + typeArguments = undefined; + adjustedArgCount = getEffectiveArgumentCount(node, undefined, signature); + } + else { + var callExpression = node; + if (!callExpression.arguments) { + ts.Debug.assert(callExpression.kind === 169); + return signature.minArgumentCount === 0; + } + adjustedArgCount = callExpression.arguments.hasTrailingComma ? args.length + 1 : args.length; + callIsIncomplete = callExpression.arguments.end === callExpression.end; + typeArguments = callExpression.typeArguments; + spreadArgIndex = getSpreadArgumentIndex(args); + } + var hasRightNumberOfTypeArgs = !typeArguments || + (signature.typeParameters && typeArguments.length === signature.typeParameters.length); + if (!hasRightNumberOfTypeArgs) { + return false; + } + if (spreadArgIndex >= 0) { + return isRestParameterIndex(signature, spreadArgIndex); + } + if (!signature.hasRestParameter && adjustedArgCount > signature.parameters.length) { + return false; + } + var hasEnoughArguments = adjustedArgCount >= signature.minArgumentCount; + return callIsIncomplete || hasEnoughArguments; + } + function getSingleCallSignature(type) { + if (type.flags & 80896) { + var resolved = resolveStructuredTypeMembers(type); + if (resolved.callSignatures.length === 1 && resolved.constructSignatures.length === 0 && + resolved.properties.length === 0 && !resolved.stringIndexType && !resolved.numberIndexType) { + return resolved.callSignatures[0]; + } + } + return undefined; + } + function instantiateSignatureInContextOf(signature, contextualSignature, contextualMapper) { + var context = createInferenceContext(signature.typeParameters, true); + forEachMatchingParameterType(contextualSignature, signature, function (source, target) { + inferTypes(context, instantiateType(source, contextualMapper), target); + }); + return getSignatureInstantiation(signature, getInferredTypes(context)); + } + function inferTypeArguments(node, signature, args, excludeArgument, context) { + var typeParameters = signature.typeParameters; + var inferenceMapper = createInferenceMapper(context); + for (var i = 0; i < typeParameters.length; i++) { + if (!context.inferences[i].isFixed) { + context.inferredTypes[i] = undefined; + } + } + if (context.failedTypeParameterIndex !== undefined && !context.inferences[context.failedTypeParameterIndex].isFixed) { + context.failedTypeParameterIndex = undefined; + } + var argCount = getEffectiveArgumentCount(node, args, signature); + for (var i = 0; i < argCount; i++) { + var arg = getEffectiveArgument(node, args, i); + if (arg === undefined || arg.kind !== 187) { + var paramType = getTypeAtPosition(signature, i); + var argType = getEffectiveArgumentType(node, i, arg); + if (argType === undefined) { + var mapper = excludeArgument && excludeArgument[i] !== undefined ? identityMapper : inferenceMapper; + argType = checkExpressionWithContextualType(arg, paramType, mapper); + } + inferTypes(context, argType, paramType); + } + } + if (excludeArgument) { + for (var i = 0; i < argCount; i++) { + if (excludeArgument[i] === false) { + var arg = args[i]; + var paramType = getTypeAtPosition(signature, i); + inferTypes(context, checkExpressionWithContextualType(arg, paramType, inferenceMapper), paramType); + } + } + } + getInferredTypes(context); + } + function checkTypeArguments(signature, typeArguments, typeArgumentResultTypes, reportErrors, headMessage) { + var typeParameters = signature.typeParameters; + var typeArgumentsAreAssignable = true; + for (var i = 0; i < typeParameters.length; i++) { + var typeArgNode = typeArguments[i]; + var typeArgument = getTypeFromTypeNode(typeArgNode); + typeArgumentResultTypes[i] = typeArgument; + if (typeArgumentsAreAssignable) { + var constraint = getConstraintOfTypeParameter(typeParameters[i]); + if (constraint) { + var errorInfo = void 0; + var typeArgumentHeadMessage = ts.Diagnostics.Type_0_does_not_satisfy_the_constraint_1; + if (reportErrors && headMessage) { + errorInfo = ts.chainDiagnosticMessages(errorInfo, typeArgumentHeadMessage); + typeArgumentHeadMessage = headMessage; + } + typeArgumentsAreAssignable = checkTypeAssignableTo(typeArgument, constraint, reportErrors ? typeArgNode : undefined, typeArgumentHeadMessage, errorInfo); + } + } + } + return typeArgumentsAreAssignable; + } + function checkApplicableSignature(node, args, signature, relation, excludeArgument, reportErrors) { + var argCount = getEffectiveArgumentCount(node, args, signature); + for (var i = 0; i < argCount; i++) { + var arg = getEffectiveArgument(node, args, i); + if (arg === undefined || arg.kind !== 187) { + var paramType = getTypeAtPosition(signature, i); + var argType = getEffectiveArgumentType(node, i, arg); + if (argType === undefined) { + argType = arg.kind === 9 && !reportErrors + ? getStringLiteralType(arg) + : checkExpressionWithContextualType(arg, paramType, excludeArgument && excludeArgument[i] ? identityMapper : undefined); + } + var errorNode = reportErrors ? getEffectiveArgumentErrorNode(node, i, arg) : undefined; + var headMessage = ts.Diagnostics.Argument_of_type_0_is_not_assignable_to_parameter_of_type_1; + if (!checkTypeRelatedTo(argType, paramType, relation, errorNode, headMessage)) { + return false; + } + } + } + return true; + } + function getEffectiveCallArguments(node) { + var args; + if (node.kind === 170) { + var template = node.template; + args = [undefined]; + if (template.kind === 183) { + ts.forEach(template.templateSpans, function (span) { + args.push(span.expression); + }); + } + } + else if (node.kind === 139) { + return undefined; + } + else { + args = node.arguments || emptyArray; + } + return args; + } + function getEffectiveArgumentCount(node, args, signature) { + if (node.kind === 139) { + switch (node.parent.kind) { + case 214: + case 186: + return 1; + case 141: + return 2; + case 143: + case 145: + case 146: + if (languageVersion === 0) { + return 2; + } + return signature.parameters.length >= 3 ? 3 : 2; + case 138: + return 3; + } + } + else { + return args.length; + } + } + function getEffectiveDecoratorFirstArgumentType(node) { + if (node.kind === 214) { + var classSymbol = getSymbolOfNode(node); + return getTypeOfSymbol(classSymbol); + } + if (node.kind === 138) { + node = node.parent; + if (node.kind === 144) { + var classSymbol = getSymbolOfNode(node); + return getTypeOfSymbol(classSymbol); + } + } + if (node.kind === 141 || + node.kind === 143 || + node.kind === 145 || + node.kind === 146) { + return getParentTypeOfClassElement(node); + } + ts.Debug.fail("Unsupported decorator target."); + return unknownType; + } + function getEffectiveDecoratorSecondArgumentType(node) { + if (node.kind === 214) { + ts.Debug.fail("Class decorators should not have a second synthetic argument."); + return unknownType; + } + if (node.kind === 138) { + node = node.parent; + if (node.kind === 144) { + return anyType; + } + } + if (node.kind === 141 || + node.kind === 143 || + node.kind === 145 || + node.kind === 146) { + var element = node; + switch (element.name.kind) { + case 69: + case 8: + case 9: + return getStringLiteralType(element.name); + case 136: + var nameType = checkComputedPropertyName(element.name); + if (allConstituentTypesHaveKind(nameType, 16777216)) { + return nameType; + } + else { + return stringType; + } + default: + ts.Debug.fail("Unsupported property name."); + return unknownType; + } + } + ts.Debug.fail("Unsupported decorator target."); + return unknownType; + } + function getEffectiveDecoratorThirdArgumentType(node) { + if (node.kind === 214) { + ts.Debug.fail("Class decorators should not have a third synthetic argument."); + return unknownType; + } + if (node.kind === 138) { + return numberType; + } + if (node.kind === 141) { + ts.Debug.fail("Property decorators should not have a third synthetic argument."); + return unknownType; + } + if (node.kind === 143 || + node.kind === 145 || + node.kind === 146) { + var propertyType = getTypeOfNode(node); + return createTypedPropertyDescriptorType(propertyType); + } + ts.Debug.fail("Unsupported decorator target."); + return unknownType; + } + function getEffectiveDecoratorArgumentType(node, argIndex) { + if (argIndex === 0) { + return getEffectiveDecoratorFirstArgumentType(node.parent); + } + else if (argIndex === 1) { + return getEffectiveDecoratorSecondArgumentType(node.parent); + } + else if (argIndex === 2) { + return getEffectiveDecoratorThirdArgumentType(node.parent); + } + ts.Debug.fail("Decorators should not have a fourth synthetic argument."); + return unknownType; + } + function getEffectiveArgumentType(node, argIndex, arg) { + if (node.kind === 139) { + return getEffectiveDecoratorArgumentType(node, argIndex); + } + else if (argIndex === 0 && node.kind === 170) { + return globalTemplateStringsArrayType; + } + return undefined; + } + function getEffectiveArgument(node, args, argIndex) { + if (node.kind === 139 || + (argIndex === 0 && node.kind === 170)) { + return undefined; + } + return args[argIndex]; + } + function getEffectiveArgumentErrorNode(node, argIndex, arg) { + if (node.kind === 139) { + return node.expression; + } + else if (argIndex === 0 && node.kind === 170) { + return node.template; + } + else { + return arg; + } + } + function resolveCall(node, signatures, candidatesOutArray, headMessage) { + var isTaggedTemplate = node.kind === 170; + var isDecorator = node.kind === 139; + var typeArguments; + if (!isTaggedTemplate && !isDecorator) { + typeArguments = node.typeArguments; + if (node.expression.kind !== 95) { + ts.forEach(typeArguments, checkSourceElement); + } + } + var candidates = candidatesOutArray || []; + reorderCandidates(signatures, candidates); + if (!candidates.length) { + reportError(ts.Diagnostics.Supplied_parameters_do_not_match_any_signature_of_call_target); + return resolveErrorCall(node); + } + var args = getEffectiveCallArguments(node); + var excludeArgument; + if (!isDecorator) { + for (var i = isTaggedTemplate ? 1 : 0; i < args.length; i++) { + if (isContextSensitive(args[i])) { + if (!excludeArgument) { + excludeArgument = new Array(args.length); + } + excludeArgument[i] = true; + } + } + } + var candidateForArgumentError; + var candidateForTypeArgumentError; + var resultOfFailedInference; + var result; + if (candidates.length > 1) { + result = chooseOverload(candidates, subtypeRelation); + } + if (!result) { + candidateForArgumentError = undefined; + candidateForTypeArgumentError = undefined; + resultOfFailedInference = undefined; + result = chooseOverload(candidates, assignableRelation); + } + if (result) { + return result; + } + if (candidateForArgumentError) { + checkApplicableSignature(node, args, candidateForArgumentError, assignableRelation, undefined, true); + } + else if (candidateForTypeArgumentError) { + if (!isTaggedTemplate && !isDecorator && typeArguments) { + checkTypeArguments(candidateForTypeArgumentError, node.typeArguments, [], true, headMessage); + } + else { + ts.Debug.assert(resultOfFailedInference.failedTypeParameterIndex >= 0); + var failedTypeParameter = candidateForTypeArgumentError.typeParameters[resultOfFailedInference.failedTypeParameterIndex]; + var inferenceCandidates = getInferenceCandidates(resultOfFailedInference, resultOfFailedInference.failedTypeParameterIndex); + var diagnosticChainHead = ts.chainDiagnosticMessages(undefined, ts.Diagnostics.The_type_argument_for_type_parameter_0_cannot_be_inferred_from_the_usage_Consider_specifying_the_type_arguments_explicitly, typeToString(failedTypeParameter)); + if (headMessage) { + diagnosticChainHead = ts.chainDiagnosticMessages(diagnosticChainHead, headMessage); + } + reportNoCommonSupertypeError(inferenceCandidates, node.expression || node.tag, diagnosticChainHead); + } + } + else { + reportError(ts.Diagnostics.Supplied_parameters_do_not_match_any_signature_of_call_target); + } + if (!produceDiagnostics) { + for (var _i = 0; _i < candidates.length; _i++) { + var candidate = candidates[_i]; + if (hasCorrectArity(node, args, candidate)) { + if (candidate.typeParameters && typeArguments) { + candidate = getSignatureInstantiation(candidate, ts.map(typeArguments, getTypeFromTypeNode)); + } + return candidate; + } + } + } + return resolveErrorCall(node); + function reportError(message, arg0, arg1, arg2) { + var errorInfo; + errorInfo = ts.chainDiagnosticMessages(errorInfo, message, arg0, arg1, arg2); + if (headMessage) { + errorInfo = ts.chainDiagnosticMessages(errorInfo, headMessage); + } + diagnostics.add(ts.createDiagnosticForNodeFromMessageChain(node, errorInfo)); + } + function chooseOverload(candidates, relation) { + for (var _i = 0; _i < candidates.length; _i++) { + var originalCandidate = candidates[_i]; + if (!hasCorrectArity(node, args, originalCandidate)) { + continue; + } + var candidate = void 0; + var typeArgumentsAreValid = void 0; + var inferenceContext = originalCandidate.typeParameters + ? createInferenceContext(originalCandidate.typeParameters, false) + : undefined; + while (true) { + candidate = originalCandidate; + if (candidate.typeParameters) { + var typeArgumentTypes = void 0; + if (typeArguments) { + typeArgumentTypes = new Array(candidate.typeParameters.length); + typeArgumentsAreValid = checkTypeArguments(candidate, typeArguments, typeArgumentTypes, false); + } + else { + inferTypeArguments(node, candidate, args, excludeArgument, inferenceContext); + typeArgumentsAreValid = inferenceContext.failedTypeParameterIndex === undefined; + typeArgumentTypes = inferenceContext.inferredTypes; + } + if (!typeArgumentsAreValid) { + break; + } + candidate = getSignatureInstantiation(candidate, typeArgumentTypes); + } + if (!checkApplicableSignature(node, args, candidate, relation, excludeArgument, false)) { + break; + } + var index = excludeArgument ? ts.indexOf(excludeArgument, true) : -1; + if (index < 0) { + return candidate; + } + excludeArgument[index] = false; + } + if (originalCandidate.typeParameters) { + var instantiatedCandidate = candidate; + if (typeArgumentsAreValid) { + candidateForArgumentError = instantiatedCandidate; + } + else { + candidateForTypeArgumentError = originalCandidate; + if (!typeArguments) { + resultOfFailedInference = inferenceContext; + } + } + } + else { + ts.Debug.assert(originalCandidate === candidate); + candidateForArgumentError = originalCandidate; + } + } + return undefined; + } + } + function resolveCallExpression(node, candidatesOutArray) { + if (node.expression.kind === 95) { + var superType = checkSuperExpression(node.expression); + if (superType !== unknownType) { + var baseTypeNode = ts.getClassExtendsHeritageClauseElement(ts.getContainingClass(node)); + var baseConstructors = getInstantiatedConstructorsForTypeArguments(superType, baseTypeNode.typeArguments); + return resolveCall(node, baseConstructors, candidatesOutArray); + } + return resolveUntypedCall(node); + } + var funcType = checkExpression(node.expression); + var apparentType = getApparentType(funcType); + if (apparentType === unknownType) { + return resolveErrorCall(node); + } + var callSignatures = getSignaturesOfType(apparentType, 0); + var constructSignatures = getSignaturesOfType(apparentType, 1); + if (isTypeAny(funcType) || (!callSignatures.length && !constructSignatures.length && !(funcType.flags & 16384) && isTypeAssignableTo(funcType, globalFunctionType))) { + if (funcType !== unknownType && node.typeArguments) { + error(node, ts.Diagnostics.Untyped_function_calls_may_not_accept_type_arguments); + } + return resolveUntypedCall(node); + } + if (!callSignatures.length) { + if (constructSignatures.length) { + error(node, ts.Diagnostics.Value_of_type_0_is_not_callable_Did_you_mean_to_include_new, typeToString(funcType)); + } + else { + error(node, ts.Diagnostics.Cannot_invoke_an_expression_whose_type_lacks_a_call_signature); + } + return resolveErrorCall(node); + } + return resolveCall(node, callSignatures, candidatesOutArray); + } + function resolveNewExpression(node, candidatesOutArray) { + if (node.arguments && languageVersion < 1) { + var spreadIndex = getSpreadArgumentIndex(node.arguments); + if (spreadIndex >= 0) { + error(node.arguments[spreadIndex], ts.Diagnostics.Spread_operator_in_new_expressions_is_only_available_when_targeting_ECMAScript_5_and_higher); + } + } + var expressionType = checkExpression(node.expression); + expressionType = getApparentType(expressionType); + if (expressionType === unknownType) { + return resolveErrorCall(node); + } + var valueDecl = expressionType.symbol && getClassLikeDeclarationOfSymbol(expressionType.symbol); + if (valueDecl && valueDecl.flags & 256) { + error(node, ts.Diagnostics.Cannot_create_an_instance_of_the_abstract_class_0, ts.declarationNameToString(valueDecl.name)); + return resolveErrorCall(node); + } + if (isTypeAny(expressionType)) { + if (node.typeArguments) { + error(node, ts.Diagnostics.Untyped_function_calls_may_not_accept_type_arguments); + } + return resolveUntypedCall(node); + } + var constructSignatures = getSignaturesOfType(expressionType, 1); + if (constructSignatures.length) { + return resolveCall(node, constructSignatures, candidatesOutArray); + } + var callSignatures = getSignaturesOfType(expressionType, 0); + if (callSignatures.length) { + var signature = resolveCall(node, callSignatures, candidatesOutArray); + if (getReturnTypeOfSignature(signature) !== voidType) { + error(node, ts.Diagnostics.Only_a_void_function_can_be_called_with_the_new_keyword); + } + return signature; + } + error(node, ts.Diagnostics.Cannot_use_new_with_an_expression_whose_type_lacks_a_call_or_construct_signature); + return resolveErrorCall(node); + } + function resolveTaggedTemplateExpression(node, candidatesOutArray) { + var tagType = checkExpression(node.tag); + var apparentType = getApparentType(tagType); + if (apparentType === unknownType) { + return resolveErrorCall(node); + } + var callSignatures = getSignaturesOfType(apparentType, 0); + if (isTypeAny(tagType) || (!callSignatures.length && !(tagType.flags & 16384) && isTypeAssignableTo(tagType, globalFunctionType))) { + return resolveUntypedCall(node); + } + if (!callSignatures.length) { + error(node, ts.Diagnostics.Cannot_invoke_an_expression_whose_type_lacks_a_call_signature); + return resolveErrorCall(node); + } + return resolveCall(node, callSignatures, candidatesOutArray); + } + function getDiagnosticHeadMessageForDecoratorResolution(node) { + switch (node.parent.kind) { + case 214: + case 186: + return ts.Diagnostics.Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression; + case 138: + return ts.Diagnostics.Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression; + case 141: + return ts.Diagnostics.Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression; + case 143: + case 145: + case 146: + return ts.Diagnostics.Unable_to_resolve_signature_of_method_decorator_when_called_as_an_expression; + } + } + function resolveDecorator(node, candidatesOutArray) { + var funcType = checkExpression(node.expression); + var apparentType = getApparentType(funcType); + if (apparentType === unknownType) { + return resolveErrorCall(node); + } + var callSignatures = getSignaturesOfType(apparentType, 0); + if (funcType === anyType || (!callSignatures.length && !(funcType.flags & 16384) && isTypeAssignableTo(funcType, globalFunctionType))) { + return resolveUntypedCall(node); + } + var headMessage = getDiagnosticHeadMessageForDecoratorResolution(node); + if (!callSignatures.length) { + var errorInfo; + errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.Cannot_invoke_an_expression_whose_type_lacks_a_call_signature); + errorInfo = ts.chainDiagnosticMessages(errorInfo, headMessage); + diagnostics.add(ts.createDiagnosticForNodeFromMessageChain(node, errorInfo)); + return resolveErrorCall(node); + } + return resolveCall(node, callSignatures, candidatesOutArray, headMessage); + } + function getResolvedSignature(node, candidatesOutArray) { + var links = getNodeLinks(node); + if (!links.resolvedSignature || candidatesOutArray) { + links.resolvedSignature = anySignature; + if (node.kind === 168) { + links.resolvedSignature = resolveCallExpression(node, candidatesOutArray); + } + else if (node.kind === 169) { + links.resolvedSignature = resolveNewExpression(node, candidatesOutArray); + } + else if (node.kind === 170) { + links.resolvedSignature = resolveTaggedTemplateExpression(node, candidatesOutArray); + } + else if (node.kind === 139) { + links.resolvedSignature = resolveDecorator(node, candidatesOutArray); + } + else { + ts.Debug.fail("Branch in 'getResolvedSignature' should be unreachable."); + } + } + return links.resolvedSignature; + } + function checkCallExpression(node) { + checkGrammarTypeArguments(node, node.typeArguments) || checkGrammarArguments(node, node.arguments); + var signature = getResolvedSignature(node); + if (node.expression.kind === 95) { + return voidType; + } + if (node.kind === 169) { + var declaration = signature.declaration; + if (declaration && + declaration.kind !== 144 && + declaration.kind !== 148 && + declaration.kind !== 153) { + if (compilerOptions.noImplicitAny) { + error(node, ts.Diagnostics.new_expression_whose_target_lacks_a_construct_signature_implicitly_has_an_any_type); + } + return anyType; + } + } + return getReturnTypeOfSignature(signature); + } + function checkTaggedTemplateExpression(node) { + return getReturnTypeOfSignature(getResolvedSignature(node)); + } + function checkAssertion(node) { + var exprType = getRegularTypeOfObjectLiteral(checkExpression(node.expression)); + var targetType = getTypeFromTypeNode(node.type); + if (produceDiagnostics && targetType !== unknownType) { + var widenedType = getWidenedType(exprType); + if (!(isTypeAssignableTo(targetType, widenedType))) { + checkTypeAssignableTo(exprType, targetType, node, ts.Diagnostics.Neither_type_0_nor_type_1_is_assignable_to_the_other); + } + } + return targetType; + } + function getTypeAtPosition(signature, pos) { + return signature.hasRestParameter ? + pos < signature.parameters.length - 1 ? getTypeOfSymbol(signature.parameters[pos]) : getRestTypeOfSignature(signature) : + pos < signature.parameters.length ? getTypeOfSymbol(signature.parameters[pos]) : anyType; + } + function assignContextualParameterTypes(signature, context, mapper) { + var len = signature.parameters.length - (signature.hasRestParameter ? 1 : 0); + for (var i = 0; i < len; i++) { + var parameter = signature.parameters[i]; + 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); + } + } + function assignBindingElementTypes(node) { + if (ts.isBindingPattern(node.name)) { + for (var _i = 0, _a = node.name.elements; _i < _a.length; _i++) { + var element = _a[_i]; + if (element.kind !== 187) { + if (element.name.kind === 69) { + getSymbolLinks(getSymbolOfNode(element)).type = getTypeForBindingElement(element); + } + assignBindingElementTypes(element); + } + } + } + } + function assignTypeToParameterAndFixTypeParameters(parameter, contextualType, mapper) { + var links = getSymbolLinks(parameter); + if (!links.type) { + links.type = instantiateType(contextualType, mapper); + assignBindingElementTypes(parameter.valueDeclaration); + } + else if (isInferentialContext(mapper)) { + inferTypes(mapper.context, links.type, instantiateType(contextualType, mapper)); + } + } + function createPromiseType(promisedType) { + var globalPromiseType = getGlobalPromiseType(); + if (globalPromiseType !== emptyGenericType) { + promisedType = getAwaitedType(promisedType); + return createTypeReference(globalPromiseType, [promisedType]); + } + return emptyObjectType; + } + function getReturnTypeFromBody(func, contextualMapper) { + var contextualSignature = getContextualSignatureForFunctionLikeDeclaration(func); + if (!func.body) { + return unknownType; + } + var isAsync = ts.isAsyncFunctionLike(func); + var type; + if (func.body.kind !== 192) { + type = checkExpressionCached(func.body, contextualMapper); + if (isAsync) { + type = checkAwaitedType(type, func, ts.Diagnostics.Return_expression_in_async_function_does_not_have_a_valid_callable_then_member); + } + } + else { + var types; + var funcIsGenerator = !!func.asteriskToken; + if (funcIsGenerator) { + types = checkAndAggregateYieldOperandTypes(func.body, contextualMapper); + if (types.length === 0) { + var iterableIteratorAny = createIterableIteratorType(anyType); + if (compilerOptions.noImplicitAny) { + error(func.asteriskToken, ts.Diagnostics.Generator_implicitly_has_type_0_because_it_does_not_yield_any_values_Consider_supplying_a_return_type, typeToString(iterableIteratorAny)); + } + return iterableIteratorAny; + } + } + else { + types = checkAndAggregateReturnExpressionTypes(func.body, contextualMapper, isAsync); + if (types.length === 0) { + if (isAsync) { + var promiseType = createPromiseType(voidType); + if (promiseType === emptyObjectType) { + error(func, ts.Diagnostics.An_async_function_or_method_must_have_a_valid_awaitable_return_type); + return unknownType; + } + return promiseType; + } + else { + return voidType; + } + } + } + type = contextualSignature ? getUnionType(types) : getCommonSupertype(types); + if (!type) { + if (funcIsGenerator) { + error(func, ts.Diagnostics.No_best_common_type_exists_among_yield_expressions); + return createIterableIteratorType(unknownType); + } + else { + error(func, ts.Diagnostics.No_best_common_type_exists_among_return_expressions); + return unknownType; + } + } + if (funcIsGenerator) { + type = createIterableIteratorType(type); + } + } + if (!contextualSignature) { + reportErrorsFromWidening(func, type); + } + var widenedType = getWidenedType(type); + if (isAsync) { + var promiseType = createPromiseType(widenedType); + if (promiseType === emptyObjectType) { + error(func, ts.Diagnostics.An_async_function_or_method_must_have_a_valid_awaitable_return_type); + return unknownType; + } + return promiseType; + } + else { + return widenedType; + } + } + function checkAndAggregateYieldOperandTypes(body, contextualMapper) { + var aggregatedTypes = []; + ts.forEachYieldExpression(body, function (yieldExpression) { + var expr = yieldExpression.expression; + if (expr) { + var type = checkExpressionCached(expr, contextualMapper); + if (yieldExpression.asteriskToken) { + type = checkElementTypeOfIterable(type, yieldExpression.expression); + } + if (!ts.contains(aggregatedTypes, type)) { + aggregatedTypes.push(type); + } + } + }); + return aggregatedTypes; + } + function checkAndAggregateReturnExpressionTypes(body, contextualMapper, isAsync) { + var aggregatedTypes = []; + ts.forEachReturnStatement(body, function (returnStatement) { + var expr = returnStatement.expression; + if (expr) { + var type = checkExpressionCached(expr, contextualMapper); + if (isAsync) { + type = checkAwaitedType(type, body.parent, ts.Diagnostics.Return_expression_in_async_function_does_not_have_a_valid_callable_then_member); + } + if (!ts.contains(aggregatedTypes, type)) { + aggregatedTypes.push(type); + } + } + }); + return aggregatedTypes; + } + function bodyContainsAReturnStatement(funcBody) { + return ts.forEachReturnStatement(funcBody, function (returnStatement) { + return true; + }); + } + function bodyContainsSingleThrowStatement(body) { + return (body.statements.length === 1) && (body.statements[0].kind === 208); + } + function checkIfNonVoidFunctionHasReturnExpressionsOrSingleThrowStatment(func, returnType) { + if (!produceDiagnostics) { + return; + } + if (returnType === voidType || isTypeAny(returnType)) { + return; + } + if (ts.nodeIsMissing(func.body) || func.body.kind !== 192) { + return; + } + var bodyBlock = func.body; + if (bodyContainsAReturnStatement(bodyBlock)) { + return; + } + if (bodyContainsSingleThrowStatement(bodyBlock)) { + return; + } + error(func.type, ts.Diagnostics.A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value_or_consist_of_a_single_throw_statement); + } + function checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper) { + ts.Debug.assert(node.kind !== 143 || ts.isObjectLiteralMethod(node)); + var hasGrammarError = checkGrammarFunctionLikeDeclaration(node); + if (!hasGrammarError && node.kind === 173) { + checkGrammarForGenerator(node); + } + if (contextualMapper === identityMapper && isContextSensitive(node)) { + return anyFunctionType; + } + var isAsync = ts.isAsyncFunctionLike(node); + if (isAsync) { + emitAwaiter = true; + } + var links = getNodeLinks(node); + var type = getTypeOfSymbol(node.symbol); + var contextSensitive = isContextSensitive(node); + var mightFixTypeParameters = contextSensitive && isInferentialContext(contextualMapper); + if (mightFixTypeParameters || !(links.flags & 1024)) { + var contextualSignature = getContextualSignature(node); + var contextChecked = !!(links.flags & 1024); + if (mightFixTypeParameters || !contextChecked) { + links.flags |= 1024; + if (contextualSignature) { + var signature = getSignaturesOfType(type, 0)[0]; + if (contextSensitive) { + assignContextualParameterTypes(signature, contextualSignature, contextualMapper || identityMapper); + } + if (mightFixTypeParameters || !node.type && !signature.resolvedReturnType) { + var returnType = getReturnTypeFromBody(node, contextualMapper); + if (!signature.resolvedReturnType) { + signature.resolvedReturnType = returnType; + } + } + } + if (!contextChecked) { + checkSignatureDeclaration(node); + } + } + } + if (produceDiagnostics && node.kind !== 143 && node.kind !== 142) { + checkCollisionWithCapturedSuperVariable(node, node.name); + checkCollisionWithCapturedThisVariable(node, node.name); + } + return type; + } + function checkFunctionExpressionOrObjectLiteralMethodBody(node) { + ts.Debug.assert(node.kind !== 143 || ts.isObjectLiteralMethod(node)); + var isAsync = ts.isAsyncFunctionLike(node); + if (isAsync) { + emitAwaiter = true; + } + var returnType = node.type && getTypeFromTypeNode(node.type); + var promisedType; + if (returnType && isAsync) { + promisedType = checkAsyncFunctionReturnType(node); + } + if (returnType && !node.asteriskToken) { + checkIfNonVoidFunctionHasReturnExpressionsOrSingleThrowStatment(node, isAsync ? promisedType : returnType); + } + if (node.body) { + if (!node.type) { + getReturnTypeOfSignature(getSignatureFromDeclaration(node)); + } + if (node.body.kind === 192) { + checkSourceElement(node.body); + } + else { + var exprType = checkExpression(node.body); + if (returnType) { + if (isAsync) { + var awaitedType = checkAwaitedType(exprType, node.body, ts.Diagnostics.Expression_body_for_async_arrow_function_does_not_have_a_valid_callable_then_member); + checkTypeAssignableTo(awaitedType, promisedType, node.body); + } + else { + checkTypeAssignableTo(exprType, returnType, node.body); + } + } + checkFunctionAndClassExpressionBodies(node.body); + } + } + } + function checkArithmeticOperandType(operand, type, diagnostic) { + if (!isTypeAnyOrAllConstituentTypesHaveKind(type, 132)) { + error(operand, diagnostic); + return false; + } + return true; + } + function checkReferenceExpression(n, invalidReferenceMessage, constantVariableMessage) { + function findSymbol(n) { + var symbol = getNodeLinks(n).resolvedSymbol; + return symbol && getExportSymbolOfValueSymbolIfExported(symbol); + } + function isReferenceOrErrorExpression(n) { + switch (n.kind) { + case 69: { + var symbol = findSymbol(n); + return !symbol || symbol === unknownSymbol || symbol === argumentsSymbol || (symbol.flags & 3) !== 0; + } + case 166: { + var symbol = findSymbol(n); + return !symbol || symbol === unknownSymbol || (symbol.flags & ~8) !== 0; + } + case 167: + return true; + case 172: + return isReferenceOrErrorExpression(n.expression); + default: + return false; + } + } + function isConstVariableReference(n) { + switch (n.kind) { + case 69: + case 166: { + var symbol = findSymbol(n); + return symbol && (symbol.flags & 3) !== 0 && (getDeclarationFlagsFromSymbol(symbol) & 32768) !== 0; + } + case 167: { + var index = n.argumentExpression; + var symbol = findSymbol(n.expression); + if (symbol && index && index.kind === 9) { + var name_12 = index.text; + var prop = getPropertyOfType(getTypeOfSymbol(symbol), name_12); + return prop && (prop.flags & 3) !== 0 && (getDeclarationFlagsFromSymbol(prop) & 32768) !== 0; + } + return false; + } + case 172: + return isConstVariableReference(n.expression); + default: + return false; + } + } + if (!isReferenceOrErrorExpression(n)) { + error(n, invalidReferenceMessage); + return false; + } + if (isConstVariableReference(n)) { + error(n, constantVariableMessage); + return false; + } + return true; + } + function checkDeleteExpression(node) { + checkExpression(node.expression); + return booleanType; + } + function checkTypeOfExpression(node) { + checkExpression(node.expression); + return stringType; + } + function checkVoidExpression(node) { + checkExpression(node.expression); + return undefinedType; + } + function checkAwaitExpression(node) { + if (produceDiagnostics) { + if (!(node.parserContextFlags & 8)) { + grammarErrorOnFirstToken(node, ts.Diagnostics.await_expression_is_only_allowed_within_an_async_function); + } + if (isInParameterInitializerBeforeContainingFunction(node)) { + error(node, ts.Diagnostics.await_expressions_cannot_be_used_in_a_parameter_initializer); + } + } + var operandType = checkExpression(node.expression); + return checkAwaitedType(operandType, node); + } + function checkPrefixUnaryExpression(node) { + var operandType = checkExpression(node.operand); + switch (node.operator) { + case 35: + case 36: + case 50: + if (someConstituentTypeHasKind(operandType, 16777216)) { + error(node.operand, ts.Diagnostics.The_0_operator_cannot_be_applied_to_type_symbol, ts.tokenToString(node.operator)); + } + return numberType; + case 49: + return booleanType; + case 41: + case 42: + var ok = checkArithmeticOperandType(node.operand, operandType, ts.Diagnostics.An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type); + if (ok) { + checkReferenceExpression(node.operand, ts.Diagnostics.The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_property_or_indexer, ts.Diagnostics.The_operand_of_an_increment_or_decrement_operator_cannot_be_a_constant); + } + return numberType; + } + return unknownType; + } + function checkPostfixUnaryExpression(node) { + var operandType = checkExpression(node.operand); + var ok = checkArithmeticOperandType(node.operand, operandType, ts.Diagnostics.An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type); + if (ok) { + checkReferenceExpression(node.operand, ts.Diagnostics.The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_property_or_indexer, ts.Diagnostics.The_operand_of_an_increment_or_decrement_operator_cannot_be_a_constant); + } + return numberType; + } + function someConstituentTypeHasKind(type, kind) { + if (type.flags & kind) { + return true; + } + if (type.flags & 49152) { + var types = type.types; + for (var _i = 0; _i < types.length; _i++) { + var current = types[_i]; + if (current.flags & kind) { + return true; + } + } + return false; + } + return false; + } + function allConstituentTypesHaveKind(type, kind) { + if (type.flags & kind) { + return true; + } + if (type.flags & 49152) { + var types = type.types; + for (var _i = 0; _i < types.length; _i++) { + var current = types[_i]; + if (!(current.flags & kind)) { + return false; + } + } + return true; + } + return false; + } + function isConstEnumObjectType(type) { + return type.flags & (80896 | 65536) && type.symbol && isConstEnumSymbol(type.symbol); + } + function isConstEnumSymbol(symbol) { + return (symbol.flags & 128) !== 0; + } + function checkInstanceOfExpression(left, right, leftType, rightType) { + if (allConstituentTypesHaveKind(leftType, 16777726)) { + error(left, ts.Diagnostics.The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_parameter); + } + if (!(isTypeAny(rightType) || isTypeSubtypeOf(rightType, globalFunctionType))) { + error(right, ts.Diagnostics.The_right_hand_side_of_an_instanceof_expression_must_be_of_type_any_or_of_a_type_assignable_to_the_Function_interface_type); + } + return booleanType; + } + function checkInExpression(left, right, leftType, rightType) { + if (!isTypeAnyOrAllConstituentTypesHaveKind(leftType, 258 | 132 | 16777216)) { + error(left, ts.Diagnostics.The_left_hand_side_of_an_in_expression_must_be_of_type_any_string_number_or_symbol); + } + if (!isTypeAnyOrAllConstituentTypesHaveKind(rightType, 80896 | 512)) { + error(right, ts.Diagnostics.The_right_hand_side_of_an_in_expression_must_be_of_type_any_an_object_type_or_a_type_parameter); + } + return booleanType; + } + function checkObjectLiteralAssignment(node, sourceType, contextualMapper) { + var properties = node.properties; + for (var _i = 0; _i < properties.length; _i++) { + var p = properties[_i]; + if (p.kind === 245 || p.kind === 246) { + var name_13 = p.name; + var type = isTypeAny(sourceType) + ? sourceType + : getTypeOfPropertyOfType(sourceType, name_13.text) || + isNumericLiteralName(name_13.text) && getIndexTypeOfType(sourceType, 1) || + getIndexTypeOfType(sourceType, 0); + if (type) { + if (p.kind === 246) { + checkDestructuringAssignment(p, type); + } + else { + checkDestructuringAssignment(p.initializer || name_13, type); + } + } + else { + error(name_13, ts.Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(sourceType), ts.declarationNameToString(name_13)); + } + } + else { + error(p, ts.Diagnostics.Property_assignment_expected); + } + } + return sourceType; + } + function checkArrayLiteralAssignment(node, sourceType, contextualMapper) { + var elementType = checkIteratedTypeOrElementType(sourceType, node, false) || unknownType; + var elements = node.elements; + for (var i = 0; i < elements.length; i++) { + var e = elements[i]; + if (e.kind !== 187) { + if (e.kind !== 185) { + var propName = "" + i; + var type = isTypeAny(sourceType) + ? sourceType + : isTupleLikeType(sourceType) + ? getTypeOfPropertyOfType(sourceType, propName) + : elementType; + if (type) { + checkDestructuringAssignment(e, type, contextualMapper); + } + else { + if (isTupleType(sourceType)) { + error(e, ts.Diagnostics.Tuple_type_0_with_length_1_cannot_be_assigned_to_tuple_with_length_2, typeToString(sourceType), sourceType.elementTypes.length, elements.length); + } + else { + error(e, ts.Diagnostics.Type_0_has_no_property_1, typeToString(sourceType), propName); + } + } + } + else { + if (i < elements.length - 1) { + error(e, ts.Diagnostics.A_rest_element_must_be_last_in_an_array_destructuring_pattern); + } + else { + var restExpression = e.expression; + if (restExpression.kind === 181 && restExpression.operatorToken.kind === 56) { + error(restExpression.operatorToken, ts.Diagnostics.A_rest_element_cannot_have_an_initializer); + } + else { + checkDestructuringAssignment(restExpression, createArrayType(elementType), contextualMapper); + } + } + } + } + } + return sourceType; + } + function checkDestructuringAssignment(exprOrAssignment, sourceType, contextualMapper) { + var target; + if (exprOrAssignment.kind === 246) { + var prop = exprOrAssignment; + if (prop.objectAssignmentInitializer) { + checkBinaryLikeExpression(prop.name, prop.equalsToken, prop.objectAssignmentInitializer, contextualMapper); + } + target = exprOrAssignment.name; + } + else { + target = exprOrAssignment; + } + if (target.kind === 181 && target.operatorToken.kind === 56) { + checkBinaryExpression(target, contextualMapper); + target = target.left; + } + if (target.kind === 165) { + return checkObjectLiteralAssignment(target, sourceType, contextualMapper); + } + if (target.kind === 164) { + return checkArrayLiteralAssignment(target, sourceType, contextualMapper); + } + return checkReferenceAssignment(target, sourceType, contextualMapper); + } + function checkReferenceAssignment(target, sourceType, contextualMapper) { + var targetType = checkExpression(target, contextualMapper); + if (checkReferenceExpression(target, ts.Diagnostics.Invalid_left_hand_side_of_assignment_expression, ts.Diagnostics.Left_hand_side_of_assignment_expression_cannot_be_a_constant)) { + checkTypeAssignableTo(sourceType, targetType, target, undefined); + } + return sourceType; + } + function checkBinaryExpression(node, contextualMapper) { + return checkBinaryLikeExpression(node.left, node.operatorToken, node.right, contextualMapper, node); + } + function checkBinaryLikeExpression(left, operatorToken, right, contextualMapper, errorNode) { + var operator = operatorToken.kind; + if (operator === 56 && (left.kind === 165 || left.kind === 164)) { + return checkDestructuringAssignment(left, checkExpression(right, contextualMapper), contextualMapper); + } + var leftType = checkExpression(left, contextualMapper); + var rightType = checkExpression(right, contextualMapper); + switch (operator) { + case 37: + case 38: + case 59: + case 60: + case 39: + case 61: + case 40: + case 62: + case 36: + case 58: + case 43: + case 63: + case 44: + case 64: + case 45: + case 65: + case 47: + case 67: + case 48: + case 68: + case 46: + case 66: + if (leftType.flags & (32 | 64)) + leftType = rightType; + if (rightType.flags & (32 | 64)) + rightType = leftType; + var suggestedOperator; + if ((leftType.flags & 8) && + (rightType.flags & 8) && + (suggestedOperator = getSuggestedBooleanOperator(operatorToken.kind)) !== undefined) { + error(errorNode || operatorToken, ts.Diagnostics.The_0_operator_is_not_allowed_for_boolean_types_Consider_using_1_instead, ts.tokenToString(operatorToken.kind), ts.tokenToString(suggestedOperator)); + } + else { + var leftOk = checkArithmeticOperandType(left, leftType, ts.Diagnostics.The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type); + var rightOk = checkArithmeticOperandType(right, rightType, ts.Diagnostics.The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type); + if (leftOk && rightOk) { + checkAssignmentOperator(numberType); + } + } + return numberType; + case 35: + case 57: + if (leftType.flags & (32 | 64)) + leftType = rightType; + if (rightType.flags & (32 | 64)) + rightType = leftType; + var resultType; + if (allConstituentTypesHaveKind(leftType, 132) && allConstituentTypesHaveKind(rightType, 132)) { + resultType = numberType; + } + else { + if (allConstituentTypesHaveKind(leftType, 258) || allConstituentTypesHaveKind(rightType, 258)) { + resultType = stringType; + } + else if (isTypeAny(leftType) || isTypeAny(rightType)) { + resultType = leftType === unknownType || rightType === unknownType ? unknownType : anyType; + } + if (resultType && !checkForDisallowedESSymbolOperand(operator)) { + return resultType; + } + } + if (!resultType) { + reportOperatorError(); + return anyType; + } + if (operator === 57) { + checkAssignmentOperator(resultType); + } + return resultType; + case 25: + case 27: + case 28: + case 29: + if (!checkForDisallowedESSymbolOperand(operator)) { + return booleanType; + } + case 30: + case 31: + case 32: + case 33: + if (!isTypeAssignableTo(leftType, rightType) && !isTypeAssignableTo(rightType, leftType)) { + reportOperatorError(); + } + return booleanType; + case 91: + return checkInstanceOfExpression(left, right, leftType, rightType); + case 90: + return checkInExpression(left, right, leftType, rightType); + case 51: + return rightType; + case 52: + return getUnionType([leftType, rightType]); + case 56: + checkAssignmentOperator(rightType); + return getRegularTypeOfObjectLiteral(rightType); + case 24: + return rightType; + } + function checkForDisallowedESSymbolOperand(operator) { + var offendingSymbolOperand = someConstituentTypeHasKind(leftType, 16777216) ? left : + someConstituentTypeHasKind(rightType, 16777216) ? right : + undefined; + if (offendingSymbolOperand) { + error(offendingSymbolOperand, ts.Diagnostics.The_0_operator_cannot_be_applied_to_type_symbol, ts.tokenToString(operator)); + return false; + } + return true; + } + function getSuggestedBooleanOperator(operator) { + switch (operator) { + 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) { + var ok = checkReferenceExpression(left, ts.Diagnostics.Invalid_left_hand_side_of_assignment_expression, ts.Diagnostics.Left_hand_side_of_assignment_expression_cannot_be_a_constant); + if (ok) { + checkTypeAssignableTo(valueType, leftType, left, undefined); + } + } + } + function reportOperatorError() { + error(errorNode || operatorToken, ts.Diagnostics.Operator_0_cannot_be_applied_to_types_1_and_2, ts.tokenToString(operatorToken.kind), typeToString(leftType), typeToString(rightType)); + } + } + function isYieldExpressionInClass(node) { + var current = node; + var parent = node.parent; + while (parent) { + if (ts.isFunctionLike(parent) && current === parent.body) { + return false; + } + else if (ts.isClassLike(current)) { + return true; + } + current = parent; + parent = parent.parent; + } + return false; + } + function checkYieldExpression(node) { + if (produceDiagnostics) { + if (!(node.parserContextFlags & 2) || isYieldExpressionInClass(node)) { + grammarErrorOnFirstToken(node, ts.Diagnostics.A_yield_expression_is_only_allowed_in_a_generator_body); + } + if (isInParameterInitializerBeforeContainingFunction(node)) { + error(node, ts.Diagnostics.yield_expressions_cannot_be_used_in_a_parameter_initializer); + } + } + if (node.expression) { + var func = ts.getContainingFunction(node); + if (func && func.asteriskToken) { + var expressionType = checkExpressionCached(node.expression, undefined); + var expressionElementType; + var nodeIsYieldStar = !!node.asteriskToken; + if (nodeIsYieldStar) { + expressionElementType = checkElementTypeOfIterable(expressionType, node.expression); + } + if (func.type) { + var signatureElementType = getElementTypeOfIterableIterator(getTypeFromTypeNode(func.type)) || anyType; + if (nodeIsYieldStar) { + checkTypeAssignableTo(expressionElementType, signatureElementType, node.expression, undefined); + } + else { + checkTypeAssignableTo(expressionType, signatureElementType, node.expression, undefined); + } + } + } + } + return anyType; + } + function checkConditionalExpression(node, contextualMapper) { + checkExpression(node.condition); + var type1 = checkExpression(node.whenTrue, contextualMapper); + var type2 = checkExpression(node.whenFalse, contextualMapper); + return getUnionType([type1, type2]); + } + function checkTemplateExpression(node) { + ts.forEach(node.templateSpans, function (templateSpan) { + checkExpression(templateSpan.expression); + }); + return stringType; + } + function checkExpressionWithContextualType(node, contextualType, contextualMapper) { + var saveContextualType = node.contextualType; + node.contextualType = contextualType; + var result = checkExpression(node, contextualMapper); + node.contextualType = saveContextualType; + return result; + } + function checkExpressionCached(node, contextualMapper) { + var links = getNodeLinks(node); + if (!links.resolvedType) { + links.resolvedType = checkExpression(node, contextualMapper); + } + return links.resolvedType; + } + function checkPropertyAssignment(node, contextualMapper) { + if (node.name.kind === 136) { + checkComputedPropertyName(node.name); + } + return checkExpression(node.initializer, contextualMapper); + } + function checkObjectLiteralMethod(node, contextualMapper) { + checkGrammarMethod(node); + if (node.name.kind === 136) { + checkComputedPropertyName(node.name); + } + var uninstantiatedType = checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); + return instantiateTypeWithSingleGenericCallSignature(node, uninstantiatedType, contextualMapper); + } + function instantiateTypeWithSingleGenericCallSignature(node, type, contextualMapper) { + if (isInferentialContext(contextualMapper)) { + var signature = getSingleCallSignature(type); + if (signature && signature.typeParameters) { + var contextualType = getContextualType(node); + if (contextualType) { + var contextualSignature = getSingleCallSignature(contextualType); + if (contextualSignature && !contextualSignature.typeParameters) { + return getOrCreateTypeFromSignature(instantiateSignatureInContextOf(signature, contextualSignature, contextualMapper)); + } + } + } + } + return type; + } + function checkExpression(node, contextualMapper) { + var type; + if (node.kind === 135) { + type = checkQualifiedName(node); + } + else { + var uninstantiatedType = checkExpressionWorker(node, contextualMapper); + type = instantiateTypeWithSingleGenericCallSignature(node, uninstantiatedType, contextualMapper); + } + if (isConstEnumObjectType(type)) { + var ok = (node.parent.kind === 166 && node.parent.expression === node) || + (node.parent.kind === 167 && node.parent.expression === node) || + ((node.kind === 69 || node.kind === 135) && isInRightSideOfImportOrExportAssignment(node)); + if (!ok) { + error(node, ts.Diagnostics.const_enums_can_only_be_used_in_property_or_index_access_expressions_or_the_right_hand_side_of_an_import_declaration_or_export_assignment); + } + } + return type; + } + function checkNumericLiteral(node) { + checkGrammarNumericLiteral(node); + return numberType; + } + function checkExpressionWorker(node, contextualMapper) { + switch (node.kind) { + case 69: + return checkIdentifier(node); + case 97: + return checkThisExpression(node); + case 95: + return checkSuperExpression(node); + case 93: + return nullType; + case 99: + case 84: + return booleanType; + case 8: + return checkNumericLiteral(node); + case 183: + return checkTemplateExpression(node); + case 9: + case 11: + return stringType; + case 10: + return globalRegExpType; + case 164: + return checkArrayLiteral(node, contextualMapper); + case 165: + return checkObjectLiteral(node, contextualMapper); + case 166: + return checkPropertyAccessExpression(node); + case 167: + return checkIndexedAccess(node); + case 168: + case 169: + return checkCallExpression(node); + case 170: + return checkTaggedTemplateExpression(node); + case 172: + return checkExpression(node.expression, contextualMapper); + case 186: + return checkClassExpression(node); + case 173: + case 174: + return checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); + case 176: + return checkTypeOfExpression(node); + case 171: + case 189: + return checkAssertion(node); + case 175: + return checkDeleteExpression(node); + case 177: + return checkVoidExpression(node); + case 178: + return checkAwaitExpression(node); + case 179: + return checkPrefixUnaryExpression(node); + case 180: + return checkPostfixUnaryExpression(node); + case 181: + return checkBinaryExpression(node, contextualMapper); + case 182: + return checkConditionalExpression(node, contextualMapper); + case 185: + return checkSpreadElementExpression(node, contextualMapper); + case 187: + return undefinedType; + case 184: + return checkYieldExpression(node); + case 240: + return checkJsxExpression(node); + case 233: + return checkJsxElement(node); + case 234: + return checkJsxSelfClosingElement(node); + case 235: + ts.Debug.fail("Shouldn't ever directly check a JsxOpeningElement"); + } + return unknownType; + } + function checkTypeParameter(node) { + if (node.expression) { + grammarErrorOnFirstToken(node.expression, ts.Diagnostics.Type_expected); + } + checkSourceElement(node.constraint); + if (produceDiagnostics) { + checkTypeParameterHasIllegalReferencesInConstraint(node); + checkTypeNameIsReserved(node.name, ts.Diagnostics.Type_parameter_name_cannot_be_0); + } + } + function checkParameter(node) { + checkGrammarDecorators(node) || checkGrammarModifiers(node); + checkVariableLikeDeclaration(node); + var func = ts.getContainingFunction(node); + if (node.flags & 112) { + func = ts.getContainingFunction(node); + if (!(func.kind === 144 && ts.nodeIsPresent(func.body))) { + error(node, ts.Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation); + } + } + if (node.questionToken && ts.isBindingPattern(node.name) && func.body) { + error(node, ts.Diagnostics.A_binding_pattern_parameter_cannot_be_optional_in_an_implementation_signature); + } + if (node.dotDotDotToken && !ts.isBindingPattern(node.name) && !isArrayType(getTypeOfSymbol(node.symbol))) { + error(node, ts.Diagnostics.A_rest_parameter_must_be_of_an_array_type); + } + } + function isSyntacticallyValidGenerator(node) { + if (!node.asteriskToken || !node.body) { + return false; + } + return node.kind === 143 || + node.kind === 213 || + node.kind === 173; + } + function getTypePredicateParameterIndex(parameterList, parameter) { + if (parameterList) { + for (var i = 0; i < parameterList.length; i++) { + var param = parameterList[i]; + if (param.name.kind === 69 && + param.name.text === parameter.text) { + return i; + } + } + } + return -1; + } + function isInLegalTypePredicatePosition(node) { + switch (node.parent.kind) { + case 174: + case 147: + case 213: + case 173: + case 152: + case 143: + case 142: + return node === node.parent.type; + } + return false; + } + function checkSignatureDeclaration(node) { + if (node.kind === 149) { + checkGrammarIndexSignature(node); + } + else if (node.kind === 152 || node.kind === 213 || node.kind === 153 || + node.kind === 147 || node.kind === 144 || + node.kind === 148) { + checkGrammarFunctionLikeDeclaration(node); + } + checkTypeParameters(node.typeParameters); + ts.forEach(node.parameters, checkParameter); + if (node.type) { + if (node.type.kind === 150) { + var typePredicate = getSignatureFromDeclaration(node).typePredicate; + var typePredicateNode = node.type; + if (isInLegalTypePredicatePosition(typePredicateNode)) { + if (typePredicate.parameterIndex >= 0) { + if (node.parameters[typePredicate.parameterIndex].dotDotDotToken) { + error(typePredicateNode.parameterName, ts.Diagnostics.A_type_predicate_cannot_reference_a_rest_parameter); + } + else { + checkTypeAssignableTo(typePredicate.type, getTypeOfNode(node.parameters[typePredicate.parameterIndex]), typePredicateNode.type); + } + } + else if (typePredicateNode.parameterName) { + var hasReportedError = false; + for (var _i = 0, _a = node.parameters; _i < _a.length; _i++) { + var param = _a[_i]; + if (hasReportedError) { + break; + } + if (param.name.kind === 161 || + param.name.kind === 162) { + (function checkBindingPattern(pattern) { + for (var _i = 0, _a = pattern.elements; _i < _a.length; _i++) { + var element = _a[_i]; + if (element.name.kind === 69 && + element.name.text === typePredicate.parameterName) { + error(typePredicateNode.parameterName, ts.Diagnostics.A_type_predicate_cannot_reference_element_0_in_a_binding_pattern, typePredicate.parameterName); + hasReportedError = true; + break; + } + else if (element.name.kind === 162 || + element.name.kind === 161) { + checkBindingPattern(element.name); + } + } + })(param.name); + } + } + if (!hasReportedError) { + error(typePredicateNode.parameterName, ts.Diagnostics.Cannot_find_parameter_0, typePredicate.parameterName); + } + } + } + else { + error(typePredicateNode, ts.Diagnostics.A_type_predicate_is_only_allowed_in_return_type_position_for_functions_and_methods); + } + } + else { + checkSourceElement(node.type); + } + } + if (produceDiagnostics) { + checkCollisionWithArgumentsInGeneratedCode(node); + if (compilerOptions.noImplicitAny && !node.type) { + switch (node.kind) { + case 148: + error(node, ts.Diagnostics.Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); + break; + case 147: + error(node, ts.Diagnostics.Call_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); + break; + } + } + if (node.type) { + if (languageVersion >= 2 && isSyntacticallyValidGenerator(node)) { + var returnType = getTypeFromTypeNode(node.type); + if (returnType === voidType) { + error(node.type, ts.Diagnostics.A_generator_cannot_have_a_void_type_annotation); + } + else { + var generatorElementType = getElementTypeOfIterableIterator(returnType) || anyType; + var iterableIteratorInstantiation = createIterableIteratorType(generatorElementType); + checkTypeAssignableTo(iterableIteratorInstantiation, returnType, node.type); + } + } + } + } + checkSpecializedSignatureDeclaration(node); + } + function checkTypeForDuplicateIndexSignatures(node) { + if (node.kind === 215) { + var nodeSymbol = getSymbolOfNode(node); + if (nodeSymbol.declarations.length > 0 && nodeSymbol.declarations[0] !== node) { + return; + } + } + var indexSymbol = getIndexSymbol(getSymbolOfNode(node)); + if (indexSymbol) { + var seenNumericIndexer = false; + var seenStringIndexer = false; + for (var _i = 0, _a = indexSymbol.declarations; _i < _a.length; _i++) { + var decl = _a[_i]; + var declaration = decl; + if (declaration.parameters.length === 1 && declaration.parameters[0].type) { + switch (declaration.parameters[0].type.kind) { + case 130: + if (!seenStringIndexer) { + seenStringIndexer = true; + } + else { + error(declaration, ts.Diagnostics.Duplicate_string_index_signature); + } + break; + case 128: + if (!seenNumericIndexer) { + seenNumericIndexer = true; + } + else { + error(declaration, ts.Diagnostics.Duplicate_number_index_signature); + } + break; + } + } + } + } + } + function checkPropertyDeclaration(node) { + checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarProperty(node) || checkGrammarComputedPropertyName(node.name); + checkVariableLikeDeclaration(node); + } + function checkMethodDeclaration(node) { + checkGrammarMethod(node) || checkGrammarComputedPropertyName(node.name); + checkFunctionLikeDeclaration(node); + if (node.flags & 256 && node.body) { + error(node, ts.Diagnostics.Method_0_cannot_have_an_implementation_because_it_is_marked_abstract, ts.declarationNameToString(node.name)); + } + } + function checkConstructorDeclaration(node) { + checkSignatureDeclaration(node); + checkGrammarConstructorTypeParameters(node) || checkGrammarConstructorTypeAnnotation(node); + checkSourceElement(node.body); + var symbol = getSymbolOfNode(node); + var firstDeclaration = ts.getDeclarationOfKind(symbol, node.kind); + if (node === firstDeclaration) { + checkFunctionOrConstructorSymbol(symbol); + } + if (ts.nodeIsMissing(node.body)) { + return; + } + if (!produceDiagnostics) { + return; + } + function isSuperCallExpression(n) { + return n.kind === 168 && n.expression.kind === 95; + } + function containsSuperCallAsComputedPropertyName(n) { + return n.name && containsSuperCall(n.name); + } + function containsSuperCall(n) { + if (isSuperCallExpression(n)) { + return true; + } + else if (ts.isFunctionLike(n)) { + return false; + } + else if (ts.isClassLike(n)) { + return ts.forEach(n.members, containsSuperCallAsComputedPropertyName); + } + return ts.forEachChild(n, containsSuperCall); + } + function markThisReferencesAsErrors(n) { + if (n.kind === 97) { + error(n, ts.Diagnostics.this_cannot_be_referenced_in_current_location); + } + else if (n.kind !== 173 && n.kind !== 213) { + ts.forEachChild(n, markThisReferencesAsErrors); + } + } + function isInstancePropertyWithInitializer(n) { + return n.kind === 141 && + !(n.flags & 128) && + !!n.initializer; + } + var containingClassDecl = node.parent; + if (ts.getClassExtendsHeritageClauseElement(containingClassDecl)) { + var containingClassSymbol = getSymbolOfNode(containingClassDecl); + var containingClassInstanceType = getDeclaredTypeOfSymbol(containingClassSymbol); + var baseConstructorType = getBaseConstructorTypeOfClass(containingClassInstanceType); + if (containsSuperCall(node.body)) { + if (baseConstructorType === nullType) { + error(node, ts.Diagnostics.A_constructor_cannot_contain_a_super_call_when_its_class_extends_null); + } + var superCallShouldBeFirst = ts.forEach(node.parent.members, isInstancePropertyWithInitializer) || + ts.forEach(node.parameters, function (p) { return p.flags & (16 | 32 | 64); }); + if (superCallShouldBeFirst) { + var statements = node.body.statements; + var superCallStatement; + for (var _i = 0; _i < statements.length; _i++) { + var statement = statements[_i]; + if (statement.kind === 195 && isSuperCallExpression(statement.expression)) { + superCallStatement = statement; + break; + } + if (!ts.isPrologueDirective(statement)) { + break; + } + } + if (!superCallStatement) { + error(node, ts.Diagnostics.A_super_call_must_be_the_first_statement_in_the_constructor_when_a_class_contains_initialized_properties_or_has_parameter_properties); + } + else { + markThisReferencesAsErrors(superCallStatement.expression); + } + } + } + else if (baseConstructorType !== nullType) { + error(node, ts.Diagnostics.Constructors_for_derived_classes_must_contain_a_super_call); + } + } + } + function checkAccessorDeclaration(node) { + if (produceDiagnostics) { + checkGrammarFunctionLikeDeclaration(node) || checkGrammarAccessor(node) || checkGrammarComputedPropertyName(node.name); + if (node.kind === 145) { + if (!ts.isInAmbientContext(node) && ts.nodeIsPresent(node.body) && !(bodyContainsAReturnStatement(node.body) || bodyContainsSingleThrowStatement(node.body))) { + error(node.name, ts.Diagnostics.A_get_accessor_must_return_a_value_or_consist_of_a_single_throw_statement); + } + } + if (!ts.hasDynamicName(node)) { + var otherKind = node.kind === 145 ? 146 : 145; + var otherAccessor = ts.getDeclarationOfKind(node.symbol, otherKind); + if (otherAccessor) { + if (((node.flags & 112) !== (otherAccessor.flags & 112))) { + error(node.name, ts.Diagnostics.Getter_and_setter_accessors_do_not_agree_in_visibility); + } + var currentAccessorType = getAnnotatedAccessorType(node); + var otherAccessorType = getAnnotatedAccessorType(otherAccessor); + if (currentAccessorType && otherAccessorType) { + if (!isTypeIdenticalTo(currentAccessorType, otherAccessorType)) { + error(node, ts.Diagnostics.get_and_set_accessor_must_have_the_same_type); + } + } + } + } + getTypeOfAccessors(getSymbolOfNode(node)); + } + checkFunctionLikeDeclaration(node); + } + function checkMissingDeclaration(node) { + checkDecorators(node); + } + function checkTypeArgumentConstraints(typeParameters, typeArguments) { + var result = true; + for (var i = 0; i < typeParameters.length; i++) { + var constraint = getConstraintOfTypeParameter(typeParameters[i]); + if (constraint) { + var typeArgument = typeArguments[i]; + result = result && checkTypeAssignableTo(getTypeFromTypeNode(typeArgument), constraint, typeArgument, ts.Diagnostics.Type_0_does_not_satisfy_the_constraint_1); + } + } + return result; + } + function checkTypeReferenceNode(node) { + checkGrammarTypeArguments(node, node.typeArguments); + var type = getTypeFromTypeReference(node); + if (type !== unknownType && node.typeArguments) { + ts.forEach(node.typeArguments, checkSourceElement); + if (produceDiagnostics) { + var symbol = getNodeLinks(node).resolvedSymbol; + var typeParameters = symbol.flags & 524288 ? getSymbolLinks(symbol).typeParameters : type.target.localTypeParameters; + checkTypeArgumentConstraints(typeParameters, node.typeArguments); + } + } + } + function checkTypeQuery(node) { + getTypeFromTypeQueryNode(node); + } + function checkTypeLiteral(node) { + ts.forEach(node.members, checkSourceElement); + if (produceDiagnostics) { + var type = getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node); + checkIndexConstraints(type); + checkTypeForDuplicateIndexSignatures(node); + } + } + function checkArrayType(node) { + checkSourceElement(node.elementType); + } + function checkTupleType(node) { + var hasErrorFromDisallowedTrailingComma = checkGrammarForDisallowedTrailingComma(node.elementTypes); + if (!hasErrorFromDisallowedTrailingComma && node.elementTypes.length === 0) { + grammarErrorOnNode(node, ts.Diagnostics.A_tuple_type_element_list_cannot_be_empty); + } + ts.forEach(node.elementTypes, checkSourceElement); + } + function checkUnionOrIntersectionType(node) { + ts.forEach(node.types, checkSourceElement); + } + function isPrivateWithinAmbient(node) { + return (node.flags & 32) && ts.isInAmbientContext(node); + } + function checkSpecializedSignatureDeclaration(signatureDeclarationNode) { + if (!produceDiagnostics) { + return; + } + var signature = getSignatureFromDeclaration(signatureDeclarationNode); + if (!signature.hasStringLiterals) { + return; + } + if (ts.nodeIsPresent(signatureDeclarationNode.body)) { + error(signatureDeclarationNode, ts.Diagnostics.A_signature_with_an_implementation_cannot_use_a_string_literal_type); + return; + } + var signaturesToCheck; + if (!signatureDeclarationNode.name && signatureDeclarationNode.parent && signatureDeclarationNode.parent.kind === 215) { + ts.Debug.assert(signatureDeclarationNode.kind === 147 || signatureDeclarationNode.kind === 148); + var signatureKind = signatureDeclarationNode.kind === 147 ? 0 : 1; + var containingSymbol = getSymbolOfNode(signatureDeclarationNode.parent); + var containingType = getDeclaredTypeOfSymbol(containingSymbol); + signaturesToCheck = getSignaturesOfType(containingType, signatureKind); + } + else { + signaturesToCheck = getSignaturesOfSymbol(getSymbolOfNode(signatureDeclarationNode)); + } + for (var _i = 0; _i < signaturesToCheck.length; _i++) { + var otherSignature = signaturesToCheck[_i]; + if (!otherSignature.hasStringLiterals && isSignatureAssignableTo(signature, otherSignature)) { + return; + } + } + error(signatureDeclarationNode, ts.Diagnostics.Specialized_overload_signature_is_not_assignable_to_any_non_specialized_signature); + } + function getEffectiveDeclarationFlags(n, flagsToCheck) { + var flags = ts.getCombinedNodeFlags(n); + if (n.parent.kind !== 215 && + n.parent.kind !== 214 && + n.parent.kind !== 186 && + ts.isInAmbientContext(n)) { + if (!(flags & 2)) { + flags |= 1; + } + flags |= 2; + } + return flags & flagsToCheck; + } + function checkFunctionOrConstructorSymbol(symbol) { + if (!produceDiagnostics) { + return; + } + function getCanonicalOverload(overloads, implementation) { + var implementationSharesContainerWithFirstOverload = implementation !== undefined && implementation.parent === overloads[0].parent; + return implementationSharesContainerWithFirstOverload ? implementation : overloads[0]; + } + function checkFlagAgreementBetweenOverloads(overloads, implementation, flagsToCheck, someOverloadFlags, allOverloadFlags) { + var someButNotAllOverloadFlags = someOverloadFlags ^ allOverloadFlags; + if (someButNotAllOverloadFlags !== 0) { + var canonicalFlags = getEffectiveDeclarationFlags(getCanonicalOverload(overloads, implementation), flagsToCheck); + ts.forEach(overloads, function (o) { + var deviation = getEffectiveDeclarationFlags(o, flagsToCheck) ^ canonicalFlags; + if (deviation & 1) { + error(o.name, ts.Diagnostics.Overload_signatures_must_all_be_exported_or_not_exported); + } + else if (deviation & 2) { + error(o.name, ts.Diagnostics.Overload_signatures_must_all_be_ambient_or_non_ambient); + } + else if (deviation & (32 | 64)) { + error(o.name, ts.Diagnostics.Overload_signatures_must_all_be_public_private_or_protected); + } + else if (deviation & 256) { + error(o.name, ts.Diagnostics.Overload_signatures_must_all_be_abstract_or_not_abstract); + } + }); + } + } + function checkQuestionTokenAgreementBetweenOverloads(overloads, implementation, someHaveQuestionToken, allHaveQuestionToken) { + if (someHaveQuestionToken !== allHaveQuestionToken) { + var canonicalHasQuestionToken = ts.hasQuestionToken(getCanonicalOverload(overloads, implementation)); + ts.forEach(overloads, function (o) { + var deviation = ts.hasQuestionToken(o) !== canonicalHasQuestionToken; + if (deviation) { + error(o.name, ts.Diagnostics.Overload_signatures_must_all_be_optional_or_required); + } + }); + } + } + var flagsToCheck = 1 | 2 | 32 | 64 | 256; + var someNodeFlags = 0; + var allNodeFlags = flagsToCheck; + var someHaveQuestionToken = false; + var allHaveQuestionToken = true; + var hasOverloads = false; + var bodyDeclaration; + var lastSeenNonAmbientDeclaration; + var previousDeclaration; + var declarations = symbol.declarations; + var isConstructor = (symbol.flags & 16384) !== 0; + function reportImplementationExpectedError(node) { + if (node.name && ts.nodeIsMissing(node.name)) { + return; + } + var seen = false; + var subsequentNode = ts.forEachChild(node.parent, function (c) { + if (seen) { + return c; + } + else { + seen = c === node; + } + }); + if (subsequentNode) { + if (subsequentNode.kind === node.kind) { + var errorNode_1 = subsequentNode.name || subsequentNode; + if (node.name && subsequentNode.name && node.name.text === subsequentNode.name.text) { + ts.Debug.assert(node.kind === 143 || node.kind === 142); + ts.Debug.assert((node.flags & 128) !== (subsequentNode.flags & 128)); + var diagnostic = node.flags & 128 ? ts.Diagnostics.Function_overload_must_be_static : ts.Diagnostics.Function_overload_must_not_be_static; + error(errorNode_1, diagnostic); + return; + } + else if (ts.nodeIsPresent(subsequentNode.body)) { + error(errorNode_1, ts.Diagnostics.Function_implementation_name_must_be_0, ts.declarationNameToString(node.name)); + return; + } + } + } + var errorNode = node.name || node; + if (isConstructor) { + error(errorNode, ts.Diagnostics.Constructor_implementation_is_missing); + } + else { + if (node.flags & 256) { + error(errorNode, ts.Diagnostics.All_declarations_of_an_abstract_method_must_be_consecutive); + } + else { + error(errorNode, ts.Diagnostics.Function_implementation_is_missing_or_not_immediately_following_the_declaration); + } + } + } + var isExportSymbolInsideModule = symbol.parent && symbol.parent.flags & 1536; + var duplicateFunctionDeclaration = false; + var multipleConstructorImplementation = false; + for (var _i = 0; _i < declarations.length; _i++) { + var current = declarations[_i]; + var node = current; + var inAmbientContext = ts.isInAmbientContext(node); + var inAmbientContextOrInterface = node.parent.kind === 215 || node.parent.kind === 155 || inAmbientContext; + if (inAmbientContextOrInterface) { + previousDeclaration = undefined; + } + if (node.kind === 213 || node.kind === 143 || node.kind === 142 || node.kind === 144) { + var currentNodeFlags = getEffectiveDeclarationFlags(node, flagsToCheck); + someNodeFlags |= currentNodeFlags; + allNodeFlags &= currentNodeFlags; + someHaveQuestionToken = someHaveQuestionToken || ts.hasQuestionToken(node); + allHaveQuestionToken = allHaveQuestionToken && ts.hasQuestionToken(node); + if (ts.nodeIsPresent(node.body) && bodyDeclaration) { + if (isConstructor) { + multipleConstructorImplementation = true; + } + else { + duplicateFunctionDeclaration = true; + } + } + else if (!isExportSymbolInsideModule && previousDeclaration && previousDeclaration.parent === node.parent && previousDeclaration.end !== node.pos) { + reportImplementationExpectedError(previousDeclaration); + } + if (ts.nodeIsPresent(node.body)) { + if (!bodyDeclaration) { + bodyDeclaration = node; + } + } + else { + hasOverloads = true; + } + previousDeclaration = node; + if (!inAmbientContextOrInterface) { + lastSeenNonAmbientDeclaration = node; + } + } + } + if (multipleConstructorImplementation) { + ts.forEach(declarations, function (declaration) { + error(declaration, ts.Diagnostics.Multiple_constructor_implementations_are_not_allowed); + }); + } + if (duplicateFunctionDeclaration) { + ts.forEach(declarations, function (declaration) { + error(declaration.name, ts.Diagnostics.Duplicate_function_implementation); + }); + } + if (!isExportSymbolInsideModule && lastSeenNonAmbientDeclaration && !lastSeenNonAmbientDeclaration.body && + !(lastSeenNonAmbientDeclaration.flags & 256)) { + reportImplementationExpectedError(lastSeenNonAmbientDeclaration); + } + if (hasOverloads) { + checkFlagAgreementBetweenOverloads(declarations, bodyDeclaration, flagsToCheck, someNodeFlags, allNodeFlags); + checkQuestionTokenAgreementBetweenOverloads(declarations, bodyDeclaration, someHaveQuestionToken, allHaveQuestionToken); + if (bodyDeclaration) { + var signatures = getSignaturesOfSymbol(symbol); + var bodySignature = getSignatureFromDeclaration(bodyDeclaration); + if (!bodySignature.hasStringLiterals) { + for (var _a = 0; _a < signatures.length; _a++) { + var signature = signatures[_a]; + if (!signature.hasStringLiterals && !isSignatureAssignableTo(bodySignature, signature)) { + error(signature.declaration, ts.Diagnostics.Overload_signature_is_not_compatible_with_function_implementation); + break; + } + } + } + } + } + } + function checkExportsOnMergedDeclarations(node) { + if (!produceDiagnostics) { + return; + } + var symbol = node.localSymbol; + if (!symbol) { + symbol = getSymbolOfNode(node); + if (!(symbol.flags & 7340032)) { + return; + } + } + if (ts.getDeclarationOfKind(symbol, node.kind) !== node) { + return; + } + var exportedDeclarationSpaces = 0; + var nonExportedDeclarationSpaces = 0; + var defaultExportedDeclarationSpaces = 0; + for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { + var d = _a[_i]; + var declarationSpaces = getDeclarationSpaces(d); + var effectiveDeclarationFlags = getEffectiveDeclarationFlags(d, 1 | 1024); + if (effectiveDeclarationFlags & 1) { + if (effectiveDeclarationFlags & 1024) { + defaultExportedDeclarationSpaces |= declarationSpaces; + } + else { + exportedDeclarationSpaces |= declarationSpaces; + } + } + else { + nonExportedDeclarationSpaces |= declarationSpaces; + } + } + var nonDefaultExportedDeclarationSpaces = exportedDeclarationSpaces | nonExportedDeclarationSpaces; + var commonDeclarationSpacesForExportsAndLocals = exportedDeclarationSpaces & nonExportedDeclarationSpaces; + var commonDeclarationSpacesForDefaultAndNonDefault = defaultExportedDeclarationSpaces & nonDefaultExportedDeclarationSpaces; + if (commonDeclarationSpacesForExportsAndLocals || commonDeclarationSpacesForDefaultAndNonDefault) { + for (var _b = 0, _c = symbol.declarations; _b < _c.length; _b++) { + var d = _c[_b]; + var declarationSpaces = getDeclarationSpaces(d); + if (declarationSpaces & commonDeclarationSpacesForDefaultAndNonDefault) { + error(d.name, ts.Diagnostics.Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_default_0_declaration_instead, ts.declarationNameToString(d.name)); + } + else if (declarationSpaces & commonDeclarationSpacesForExportsAndLocals) { + error(d.name, ts.Diagnostics.Individual_declarations_in_merged_declaration_0_must_be_all_exported_or_all_local, ts.declarationNameToString(d.name)); + } + } + } + function getDeclarationSpaces(d) { + switch (d.kind) { + case 215: + return 2097152; + case 218: + return d.name.kind === 9 || ts.getModuleInstanceState(d) !== 0 + ? 4194304 | 1048576 + : 4194304; + case 214: + case 217: + return 2097152 | 1048576; + case 221: + var result = 0; + var target = resolveAlias(getSymbolOfNode(d)); + ts.forEach(target.declarations, function (d) { result |= getDeclarationSpaces(d); }); + return result; + default: + return 1048576; + } + } + } + function checkNonThenableType(type, location, message) { + type = getWidenedType(type); + if (!isTypeAny(type) && isTypeAssignableTo(type, getGlobalThenableType())) { + if (location) { + if (!message) { + message = ts.Diagnostics.Operand_for_await_does_not_have_a_valid_callable_then_member; + } + error(location, message); + } + return unknownType; + } + return type; + } + function getPromisedType(promise) { + if (promise.flags & 1) { + return undefined; + } + if ((promise.flags & 4096) && promise.target === tryGetGlobalPromiseType()) { + return promise.typeArguments[0]; + } + var globalPromiseLikeType = getInstantiatedGlobalPromiseLikeType(); + if (globalPromiseLikeType === emptyObjectType || !isTypeAssignableTo(promise, globalPromiseLikeType)) { + return undefined; + } + var thenFunction = getTypeOfPropertyOfType(promise, "then"); + if (thenFunction && (thenFunction.flags & 1)) { + return undefined; + } + var thenSignatures = thenFunction ? getSignaturesOfType(thenFunction, 0) : emptyArray; + if (thenSignatures.length === 0) { + return undefined; + } + var onfulfilledParameterType = getUnionType(ts.map(thenSignatures, getTypeOfFirstParameterOfSignature)); + if (onfulfilledParameterType.flags & 1) { + return undefined; + } + var onfulfilledParameterSignatures = getSignaturesOfType(onfulfilledParameterType, 0); + if (onfulfilledParameterSignatures.length === 0) { + return undefined; + } + var valueParameterType = getUnionType(ts.map(onfulfilledParameterSignatures, getTypeOfFirstParameterOfSignature)); + return valueParameterType; + } + function getTypeOfFirstParameterOfSignature(signature) { + return getTypeAtPosition(signature, 0); + } + function getAwaitedType(type) { + return checkAwaitedType(type, undefined, undefined); + } + function checkAwaitedType(type, location, message) { + return checkAwaitedTypeWorker(type); + function checkAwaitedTypeWorker(type) { + if (type.flags & 16384) { + var types = []; + for (var _i = 0, _a = type.types; _i < _a.length; _i++) { + var constituentType = _a[_i]; + types.push(checkAwaitedTypeWorker(constituentType)); + } + return getUnionType(types); + } + else { + var promisedType = getPromisedType(type); + if (promisedType === undefined) { + return checkNonThenableType(type, location, message); + } + else { + if (type.id === promisedType.id || awaitedTypeStack.indexOf(promisedType.id) >= 0) { + if (location) { + error(location, ts.Diagnostics._0_is_referenced_directly_or_indirectly_in_the_fulfillment_callback_of_its_own_then_method, symbolToString(type.symbol)); + } + return unknownType; + } + awaitedTypeStack.push(type.id); + var awaitedType = checkAwaitedTypeWorker(promisedType); + awaitedTypeStack.pop(); + return awaitedType; + } + } + } + } + function checkAsyncFunctionReturnType(node) { + var globalPromiseConstructorLikeType = getGlobalPromiseConstructorLikeType(); + if (globalPromiseConstructorLikeType === emptyObjectType) { + return unknownType; + } + var promiseType = getTypeFromTypeNode(node.type); + if (promiseType === unknownType && compilerOptions.isolatedModules) { + return unknownType; + } + var promiseConstructor = getMergedSymbol(promiseType.symbol); + if (!promiseConstructor || !symbolIsValue(promiseConstructor)) { + error(node, ts.Diagnostics.Type_0_is_not_a_valid_async_function_return_type, typeToString(promiseType)); + return unknownType; + } + var promiseConstructorType = getTypeOfSymbol(promiseConstructor); + if (!checkTypeAssignableTo(promiseConstructorType, globalPromiseConstructorLikeType, node, ts.Diagnostics.Type_0_is_not_a_valid_async_function_return_type)) { + return unknownType; + } + var promiseName = ts.getEntityNameFromTypeNode(node.type); + var root = getFirstIdentifier(promiseName); + var rootSymbol = getSymbol(node.locals, root.text, 107455); + if (rootSymbol) { + error(rootSymbol.valueDeclaration, ts.Diagnostics.Duplicate_identifier_0_Compiler_uses_declaration_1_to_support_async_functions, root.text, getFullyQualifiedName(promiseConstructor)); + return unknownType; + } + return checkAwaitedType(promiseType, node, ts.Diagnostics.An_async_function_or_method_must_have_a_valid_awaitable_return_type); + } + function checkDecorator(node) { + var signature = getResolvedSignature(node); + var returnType = getReturnTypeOfSignature(signature); + if (returnType.flags & 1) { + return; + } + var expectedReturnType; + var headMessage = getDiagnosticHeadMessageForDecoratorResolution(node); + var errorInfo; + switch (node.parent.kind) { + case 214: + var classSymbol = getSymbolOfNode(node.parent); + var classConstructorType = getTypeOfSymbol(classSymbol); + expectedReturnType = getUnionType([classConstructorType, voidType]); + break; + case 138: + expectedReturnType = voidType; + errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.The_return_type_of_a_parameter_decorator_function_must_be_either_void_or_any); + break; + case 141: + expectedReturnType = voidType; + errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.The_return_type_of_a_property_decorator_function_must_be_either_void_or_any); + break; + case 143: + case 145: + case 146: + var methodType = getTypeOfNode(node.parent); + var descriptorType = createTypedPropertyDescriptorType(methodType); + expectedReturnType = getUnionType([descriptorType, voidType]); + break; + } + checkTypeAssignableTo(returnType, expectedReturnType, node, headMessage, errorInfo); + } + function checkTypeNodeAsExpression(node) { + if (node && node.kind === 151) { + var root = getFirstIdentifier(node.typeName); + var meaning = root.parent.kind === 151 ? 793056 : 1536; + var rootSymbol = resolveName(root, root.text, meaning | 8388608, undefined, undefined); + if (rootSymbol && rootSymbol.flags & 8388608) { + var aliasTarget = resolveAlias(rootSymbol); + if (aliasTarget.flags & 107455 && !isConstEnumOrConstEnumOnlyModule(resolveAlias(rootSymbol))) { + markAliasSymbolAsReferenced(rootSymbol); + } + } + } + } + function checkTypeAnnotationAsExpression(node) { + switch (node.kind) { + case 141: + checkTypeNodeAsExpression(node.type); + break; + case 138: + checkTypeNodeAsExpression(node.type); + break; + case 143: + checkTypeNodeAsExpression(node.type); + break; + case 145: + checkTypeNodeAsExpression(node.type); + break; + case 146: + checkTypeNodeAsExpression(ts.getSetAccessorTypeAnnotationNode(node)); + break; + } + } + function checkParameterTypeAnnotationsAsExpressions(node) { + for (var _i = 0, _a = node.parameters; _i < _a.length; _i++) { + var parameter = _a[_i]; + checkTypeAnnotationAsExpression(parameter); + } + } + function checkDecorators(node) { + if (!node.decorators) { + return; + } + if (!ts.nodeCanBeDecorated(node)) { + return; + } + if (!compilerOptions.experimentalDecorators) { + error(node, ts.Diagnostics.Experimental_support_for_decorators_is_a_feature_that_is_subject_to_change_in_a_future_release_Specify_experimentalDecorators_to_remove_this_warning); + } + if (compilerOptions.emitDecoratorMetadata) { + switch (node.kind) { + case 214: + var constructor = ts.getFirstConstructorWithBody(node); + if (constructor) { + checkParameterTypeAnnotationsAsExpressions(constructor); + } + break; + case 143: + checkParameterTypeAnnotationsAsExpressions(node); + case 146: + case 145: + case 141: + case 138: + checkTypeAnnotationAsExpression(node); + break; + } + } + emitDecorate = true; + if (node.kind === 138) { + emitParam = true; + } + ts.forEach(node.decorators, checkDecorator); + } + function checkFunctionDeclaration(node) { + if (produceDiagnostics) { + checkFunctionLikeDeclaration(node) || checkGrammarForGenerator(node); + checkCollisionWithCapturedSuperVariable(node, node.name); + checkCollisionWithCapturedThisVariable(node, node.name); + checkCollisionWithRequireExportsInGeneratedCode(node, node.name); + } + } + function checkFunctionLikeDeclaration(node) { + checkDecorators(node); + checkSignatureDeclaration(node); + var isAsync = ts.isAsyncFunctionLike(node); + if (isAsync) { + emitAwaiter = true; + } + if (node.name && node.name.kind === 136) { + checkComputedPropertyName(node.name); + } + if (!ts.hasDynamicName(node)) { + var symbol = getSymbolOfNode(node); + var localSymbol = node.localSymbol || symbol; + var firstDeclaration = ts.getDeclarationOfKind(localSymbol, node.kind); + if (node === firstDeclaration) { + checkFunctionOrConstructorSymbol(localSymbol); + } + if (symbol.parent) { + if (ts.getDeclarationOfKind(symbol, node.kind) === node) { + checkFunctionOrConstructorSymbol(symbol); + } + } + } + checkSourceElement(node.body); + if (node.type && !isAccessor(node.kind) && !node.asteriskToken) { + var returnType = getTypeFromTypeNode(node.type); + var promisedType; + if (isAsync) { + promisedType = checkAsyncFunctionReturnType(node); + } + checkIfNonVoidFunctionHasReturnExpressionsOrSingleThrowStatment(node, isAsync ? promisedType : returnType); + } + if (produceDiagnostics && !node.type) { + if (compilerOptions.noImplicitAny && ts.nodeIsMissing(node.body) && !isPrivateWithinAmbient(node)) { + reportImplicitAnyError(node, anyType); + } + if (node.asteriskToken && ts.nodeIsPresent(node.body)) { + getReturnTypeOfSignature(getSignatureFromDeclaration(node)); + } + } + } + function checkBlock(node) { + if (node.kind === 192) { + checkGrammarStatementInAmbientContext(node); + } + ts.forEach(node.statements, checkSourceElement); + if (ts.isFunctionBlock(node) || node.kind === 219) { + checkFunctionAndClassExpressionBodies(node); + } + } + function checkCollisionWithArgumentsInGeneratedCode(node) { + if (!ts.hasRestParameter(node) || ts.isInAmbientContext(node) || ts.nodeIsMissing(node.body)) { + return; + } + ts.forEach(node.parameters, function (p) { + if (p.name && !ts.isBindingPattern(p.name) && p.name.text === argumentsSymbol.name) { + error(p, ts.Diagnostics.Duplicate_identifier_arguments_Compiler_uses_arguments_to_initialize_rest_parameters); + } + }); + } + function needCollisionCheckForIdentifier(node, identifier, name) { + if (!(identifier && identifier.text === name)) { + return false; + } + if (node.kind === 141 || + node.kind === 140 || + node.kind === 143 || + node.kind === 142 || + node.kind === 145 || + node.kind === 146) { + return false; + } + if (ts.isInAmbientContext(node)) { + return false; + } + var root = ts.getRootDeclaration(node); + if (root.kind === 138 && ts.nodeIsMissing(root.parent.body)) { + return false; + } + return true; + } + function checkCollisionWithCapturedThisVariable(node, name) { + if (needCollisionCheckForIdentifier(node, name, "_this")) { + potentialThisCollisions.push(node); + } + } + function checkIfThisIsCapturedInEnclosingScope(node) { + var current = node; + while (current) { + if (getNodeCheckFlags(current) & 4) { + var isDeclaration_1 = node.kind !== 69; + if (isDeclaration_1) { + error(node.name, ts.Diagnostics.Duplicate_identifier_this_Compiler_uses_variable_declaration_this_to_capture_this_reference); + } + else { + error(node, ts.Diagnostics.Expression_resolves_to_variable_declaration_this_that_compiler_uses_to_capture_this_reference); + } + return; + } + current = current.parent; + } + } + function checkCollisionWithCapturedSuperVariable(node, name) { + if (!needCollisionCheckForIdentifier(node, name, "_super")) { + return; + } + var enclosingClass = ts.getContainingClass(node); + if (!enclosingClass || ts.isInAmbientContext(enclosingClass)) { + return; + } + if (ts.getClassExtendsHeritageClauseElement(enclosingClass)) { + var isDeclaration_2 = node.kind !== 69; + if (isDeclaration_2) { + error(node, ts.Diagnostics.Duplicate_identifier_super_Compiler_uses_super_to_capture_base_class_reference); + } + else { + error(node, ts.Diagnostics.Expression_resolves_to_super_that_compiler_uses_to_capture_base_class_reference); + } + } + } + function checkCollisionWithRequireExportsInGeneratedCode(node, name) { + if (!needCollisionCheckForIdentifier(node, name, "require") && !needCollisionCheckForIdentifier(node, name, "exports")) { + return; + } + if (node.kind === 218 && ts.getModuleInstanceState(node) !== 1) { + return; + } + var parent = getDeclarationContainer(node); + if (parent.kind === 248 && ts.isExternalModule(parent)) { + error(name, ts.Diagnostics.Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module, ts.declarationNameToString(name), ts.declarationNameToString(name)); + } + } + function checkVarDeclaredNamesNotShadowed(node) { + if ((ts.getCombinedNodeFlags(node) & 49152) !== 0 || ts.isParameterDeclaration(node)) { + return; + } + if (node.kind === 211 && !node.initializer) { + return; + } + var symbol = getSymbolOfNode(node); + if (symbol.flags & 1) { + var localDeclarationSymbol = resolveName(node, node.name.text, 3, undefined, undefined); + if (localDeclarationSymbol && + localDeclarationSymbol !== symbol && + localDeclarationSymbol.flags & 2) { + if (getDeclarationFlagsFromSymbol(localDeclarationSymbol) & 49152) { + var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 212); + var container = varDeclList.parent.kind === 193 && varDeclList.parent.parent + ? varDeclList.parent.parent + : undefined; + var namesShareScope = container && + (container.kind === 192 && ts.isFunctionLike(container.parent) || + container.kind === 219 || + container.kind === 218 || + container.kind === 248); + if (!namesShareScope) { + var name_14 = symbolToString(localDeclarationSymbol); + error(node, ts.Diagnostics.Cannot_initialize_outer_scoped_variable_0_in_the_same_scope_as_block_scoped_declaration_1, name_14, name_14); + } + } + } + } + } + function checkParameterInitializer(node) { + if (ts.getRootDeclaration(node).kind !== 138) { + return; + } + var func = ts.getContainingFunction(node); + visit(node.initializer); + function visit(n) { + if (n.kind === 69) { + var referencedSymbol = getNodeLinks(n).resolvedSymbol; + if (referencedSymbol && referencedSymbol !== unknownSymbol && getSymbol(func.locals, referencedSymbol.name, 107455) === referencedSymbol) { + if (referencedSymbol.valueDeclaration.kind === 138) { + if (referencedSymbol.valueDeclaration === node) { + error(n, ts.Diagnostics.Parameter_0_cannot_be_referenced_in_its_initializer, ts.declarationNameToString(node.name)); + return; + } + if (referencedSymbol.valueDeclaration.pos < node.pos) { + return; + } + } + error(n, ts.Diagnostics.Initializer_of_parameter_0_cannot_reference_identifier_1_declared_after_it, ts.declarationNameToString(node.name), ts.declarationNameToString(n)); + } + } + else { + ts.forEachChild(n, visit); + } + } + } + function checkVariableLikeDeclaration(node) { + checkDecorators(node); + checkSourceElement(node.type); + if (node.name.kind === 136) { + checkComputedPropertyName(node.name); + if (node.initializer) { + checkExpressionCached(node.initializer); + } + } + if (ts.isBindingPattern(node.name)) { + ts.forEach(node.name.elements, checkSourceElement); + } + if (node.initializer && ts.getRootDeclaration(node).kind === 138 && ts.nodeIsMissing(ts.getContainingFunction(node).body)) { + error(node, ts.Diagnostics.A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation); + return; + } + if (ts.isBindingPattern(node.name)) { + if (node.initializer) { + checkTypeAssignableTo(checkExpressionCached(node.initializer), getWidenedTypeForVariableLikeDeclaration(node), node, undefined); + checkParameterInitializer(node); + } + return; + } + var symbol = getSymbolOfNode(node); + var type = getTypeOfVariableOrParameterOrProperty(symbol); + if (node === symbol.valueDeclaration) { + if (node.initializer) { + checkTypeAssignableTo(checkExpressionCached(node.initializer), type, node, undefined); + checkParameterInitializer(node); + } + } + else { + var declarationType = 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)); + } + if (node.initializer) { + checkTypeAssignableTo(checkExpressionCached(node.initializer), declarationType, node, undefined); + } + } + if (node.kind !== 141 && node.kind !== 140) { + checkExportsOnMergedDeclarations(node); + if (node.kind === 211 || node.kind === 163) { + checkVarDeclaredNamesNotShadowed(node); + } + checkCollisionWithCapturedSuperVariable(node, node.name); + checkCollisionWithCapturedThisVariable(node, node.name); + checkCollisionWithRequireExportsInGeneratedCode(node, node.name); + } + } + function checkVariableDeclaration(node) { + checkGrammarVariableDeclaration(node); + return checkVariableLikeDeclaration(node); + } + function checkBindingElement(node) { + checkGrammarBindingElement(node); + return checkVariableLikeDeclaration(node); + } + function checkVariableStatement(node) { + checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarVariableDeclarationList(node.declarationList) || checkGrammarForDisallowedLetOrConstStatement(node); + ts.forEach(node.declarationList.declarations, checkSourceElement); + } + function checkGrammarDisallowedModifiersOnObjectLiteralExpressionMethod(node) { + if (node.modifiers && node.parent.kind === 165) { + if (ts.isAsyncFunctionLike(node)) { + if (node.modifiers.length > 1) { + return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); + } + } + else { + return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); + } + } + } + function checkExpressionStatement(node) { + checkGrammarStatementInAmbientContext(node); + checkExpression(node.expression); + } + function checkIfStatement(node) { + checkGrammarStatementInAmbientContext(node); + checkExpression(node.expression); + checkSourceElement(node.thenStatement); + checkSourceElement(node.elseStatement); + } + function checkDoStatement(node) { + checkGrammarStatementInAmbientContext(node); + checkSourceElement(node.statement); + checkExpression(node.expression); + } + function checkWhileStatement(node) { + checkGrammarStatementInAmbientContext(node); + checkExpression(node.expression); + checkSourceElement(node.statement); + } + function checkForStatement(node) { + if (!checkGrammarStatementInAmbientContext(node)) { + if (node.initializer && node.initializer.kind === 212) { + checkGrammarVariableDeclarationList(node.initializer); + } + } + if (node.initializer) { + if (node.initializer.kind === 212) { + ts.forEach(node.initializer.declarations, checkVariableDeclaration); + } + else { + checkExpression(node.initializer); + } + } + if (node.condition) + checkExpression(node.condition); + if (node.incrementor) + checkExpression(node.incrementor); + checkSourceElement(node.statement); + } + function checkForOfStatement(node) { + checkGrammarForInOrForOfStatement(node); + if (node.initializer.kind === 212) { + checkForInOrForOfVariableDeclaration(node); + } + else { + var varExpr = node.initializer; + var iteratedType = checkRightHandSideOfForOf(node.expression); + if (varExpr.kind === 164 || varExpr.kind === 165) { + checkDestructuringAssignment(varExpr, iteratedType || unknownType); + } + else { + var leftType = checkExpression(varExpr); + checkReferenceExpression(varExpr, ts.Diagnostics.Invalid_left_hand_side_in_for_of_statement, ts.Diagnostics.The_left_hand_side_of_a_for_of_statement_cannot_be_a_previously_defined_constant); + if (iteratedType) { + checkTypeAssignableTo(iteratedType, leftType, varExpr, undefined); + } + } + } + checkSourceElement(node.statement); + } + function checkForInStatement(node) { + checkGrammarForInOrForOfStatement(node); + if (node.initializer.kind === 212) { + var variable = node.initializer.declarations[0]; + if (variable && ts.isBindingPattern(variable.name)) { + error(variable.name, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern); + } + checkForInOrForOfVariableDeclaration(node); + } + else { + var varExpr = node.initializer; + var leftType = checkExpression(varExpr); + if (varExpr.kind === 164 || varExpr.kind === 165) { + error(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern); + } + else if (!isTypeAnyOrAllConstituentTypesHaveKind(leftType, 258)) { + error(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_must_be_of_type_string_or_any); + } + else { + checkReferenceExpression(varExpr, ts.Diagnostics.Invalid_left_hand_side_in_for_in_statement, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_previously_defined_constant); + } + } + var rightType = checkExpression(node.expression); + if (!isTypeAnyOrAllConstituentTypesHaveKind(rightType, 80896 | 512)) { + error(node.expression, ts.Diagnostics.The_right_hand_side_of_a_for_in_statement_must_be_of_type_any_an_object_type_or_a_type_parameter); + } + checkSourceElement(node.statement); + } + function checkForInOrForOfVariableDeclaration(iterationStatement) { + var variableDeclarationList = iterationStatement.initializer; + if (variableDeclarationList.declarations.length >= 1) { + var decl = variableDeclarationList.declarations[0]; + checkVariableDeclaration(decl); + } + } + function checkRightHandSideOfForOf(rhsExpression) { + var expressionType = getTypeOfExpression(rhsExpression); + return checkIteratedTypeOrElementType(expressionType, rhsExpression, true); + } + function checkIteratedTypeOrElementType(inputType, errorNode, allowStringInput) { + if (isTypeAny(inputType)) { + return inputType; + } + if (languageVersion >= 2) { + return checkElementTypeOfIterable(inputType, errorNode); + } + if (allowStringInput) { + return checkElementTypeOfArrayOrString(inputType, errorNode); + } + if (isArrayLikeType(inputType)) { + var indexType = getIndexTypeOfType(inputType, 1); + if (indexType) { + return indexType; + } + } + error(errorNode, ts.Diagnostics.Type_0_is_not_an_array_type, typeToString(inputType)); + return unknownType; + } + function checkElementTypeOfIterable(iterable, errorNode) { + var elementType = getElementTypeOfIterable(iterable, errorNode); + if (errorNode && elementType) { + checkTypeAssignableTo(iterable, createIterableType(elementType), errorNode); + } + return elementType || anyType; + } + function getElementTypeOfIterable(type, errorNode) { + if (isTypeAny(type)) { + return undefined; + } + var typeAsIterable = type; + if (!typeAsIterable.iterableElementType) { + if ((type.flags & 4096) && type.target === globalIterableType) { + typeAsIterable.iterableElementType = type.typeArguments[0]; + } + else { + var iteratorFunction = getTypeOfPropertyOfType(type, ts.getPropertyNameForKnownSymbolName("iterator")); + if (isTypeAny(iteratorFunction)) { + return undefined; + } + var iteratorFunctionSignatures = iteratorFunction ? getSignaturesOfType(iteratorFunction, 0) : emptyArray; + if (iteratorFunctionSignatures.length === 0) { + if (errorNode) { + error(errorNode, ts.Diagnostics.Type_must_have_a_Symbol_iterator_method_that_returns_an_iterator); + } + return undefined; + } + typeAsIterable.iterableElementType = getElementTypeOfIterator(getUnionType(ts.map(iteratorFunctionSignatures, getReturnTypeOfSignature)), errorNode); + } + } + return typeAsIterable.iterableElementType; + } + function getElementTypeOfIterator(type, errorNode) { + if (isTypeAny(type)) { + return undefined; + } + var typeAsIterator = type; + if (!typeAsIterator.iteratorElementType) { + if ((type.flags & 4096) && type.target === globalIteratorType) { + typeAsIterator.iteratorElementType = type.typeArguments[0]; + } + else { + var iteratorNextFunction = getTypeOfPropertyOfType(type, "next"); + if (isTypeAny(iteratorNextFunction)) { + return undefined; + } + var iteratorNextFunctionSignatures = iteratorNextFunction ? getSignaturesOfType(iteratorNextFunction, 0) : emptyArray; + if (iteratorNextFunctionSignatures.length === 0) { + if (errorNode) { + error(errorNode, ts.Diagnostics.An_iterator_must_have_a_next_method); + } + return undefined; + } + var iteratorNextResult = getUnionType(ts.map(iteratorNextFunctionSignatures, getReturnTypeOfSignature)); + if (isTypeAny(iteratorNextResult)) { + return undefined; + } + var iteratorNextValue = getTypeOfPropertyOfType(iteratorNextResult, "value"); + if (!iteratorNextValue) { + if (errorNode) { + error(errorNode, ts.Diagnostics.The_type_returned_by_the_next_method_of_an_iterator_must_have_a_value_property); + } + return undefined; + } + typeAsIterator.iteratorElementType = iteratorNextValue; + } + } + return typeAsIterator.iteratorElementType; + } + function getElementTypeOfIterableIterator(type) { + if (isTypeAny(type)) { + return undefined; + } + if ((type.flags & 4096) && type.target === globalIterableIteratorType) { + return type.typeArguments[0]; + } + return getElementTypeOfIterable(type, undefined) || + getElementTypeOfIterator(type, undefined); + } + function checkElementTypeOfArrayOrString(arrayOrStringType, errorNode) { + ts.Debug.assert(languageVersion < 2); + var arrayType = removeTypesFromUnionType(arrayOrStringType, 258, true, true); + var hasStringConstituent = arrayOrStringType !== arrayType; + var reportedError = false; + if (hasStringConstituent) { + if (languageVersion < 1) { + error(errorNode, ts.Diagnostics.Using_a_string_in_a_for_of_statement_is_only_supported_in_ECMAScript_5_and_higher); + reportedError = true; + } + if (arrayType === emptyObjectType) { + return stringType; + } + } + if (!isArrayLikeType(arrayType)) { + if (!reportedError) { + var diagnostic = hasStringConstituent + ? ts.Diagnostics.Type_0_is_not_an_array_type + : ts.Diagnostics.Type_0_is_not_an_array_type_or_a_string_type; + error(errorNode, diagnostic, typeToString(arrayType)); + } + return hasStringConstituent ? stringType : unknownType; + } + var arrayElementType = getIndexTypeOfType(arrayType, 1) || unknownType; + if (hasStringConstituent) { + if (arrayElementType.flags & 258) { + return stringType; + } + return getUnionType([arrayElementType, stringType]); + } + return arrayElementType; + } + function checkBreakOrContinueStatement(node) { + checkGrammarStatementInAmbientContext(node) || checkGrammarBreakOrContinueStatement(node); + } + function isGetAccessorWithAnnotatatedSetAccessor(node) { + return !!(node.kind === 145 && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(node.symbol, 146))); + } + function checkReturnStatement(node) { + if (!checkGrammarStatementInAmbientContext(node)) { + var functionBlock = ts.getContainingFunction(node); + if (!functionBlock) { + grammarErrorOnFirstToken(node, ts.Diagnostics.A_return_statement_can_only_be_used_within_a_function_body); + } + } + if (node.expression) { + var func = ts.getContainingFunction(node); + if (func) { + var signature = getSignatureFromDeclaration(func); + var returnType = getReturnTypeOfSignature(signature); + var exprType = checkExpressionCached(node.expression); + if (func.asteriskToken) { + return; + } + if (func.kind === 146) { + error(node.expression, ts.Diagnostics.Setters_cannot_return_a_value); + } + else if (func.kind === 144) { + if (!isTypeAssignableTo(exprType, returnType)) { + error(node.expression, ts.Diagnostics.Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class); + } + } + else if (func.type || isGetAccessorWithAnnotatatedSetAccessor(func) || signature.typePredicate) { + if (ts.isAsyncFunctionLike(func)) { + var promisedType = getPromisedType(returnType); + var awaitedType = checkAwaitedType(exprType, node.expression, ts.Diagnostics.Return_expression_in_async_function_does_not_have_a_valid_callable_then_member); + if (promisedType) { + checkTypeAssignableTo(awaitedType, promisedType, node.expression); + } + } + else { + checkTypeAssignableTo(exprType, returnType, node.expression); + } + } + } + } + } + function checkWithStatement(node) { + if (!checkGrammarStatementInAmbientContext(node)) { + if (node.parserContextFlags & 8) { + grammarErrorOnFirstToken(node, ts.Diagnostics.with_statements_are_not_allowed_in_an_async_function_block); + } + } + checkExpression(node.expression); + error(node.expression, ts.Diagnostics.All_symbols_within_a_with_block_will_be_resolved_to_any); + } + function checkSwitchStatement(node) { + checkGrammarStatementInAmbientContext(node); + var firstDefaultClause; + var hasDuplicateDefaultClause = false; + var expressionType = checkExpression(node.expression); + ts.forEach(node.caseBlock.clauses, function (clause) { + if (clause.kind === 242 && !hasDuplicateDefaultClause) { + if (firstDefaultClause === undefined) { + firstDefaultClause = clause; + } + else { + var sourceFile = ts.getSourceFileOfNode(node); + var start = ts.skipTrivia(sourceFile.text, clause.pos); + var end = clause.statements.length > 0 ? clause.statements[0].pos : clause.end; + grammarErrorAtPos(sourceFile, start, end - start, ts.Diagnostics.A_default_clause_cannot_appear_more_than_once_in_a_switch_statement); + hasDuplicateDefaultClause = true; + } + } + if (produceDiagnostics && clause.kind === 241) { + var caseClause = clause; + var caseType = checkExpression(caseClause.expression); + if (!isTypeAssignableTo(expressionType, caseType)) { + checkTypeAssignableTo(caseType, expressionType, caseClause.expression, undefined); + } + } + ts.forEach(clause.statements, checkSourceElement); + }); + } + function checkLabeledStatement(node) { + if (!checkGrammarStatementInAmbientContext(node)) { + var current = node.parent; + while (current) { + if (ts.isFunctionLike(current)) { + break; + } + if (current.kind === 207 && current.label.text === node.label.text) { + var sourceFile = ts.getSourceFileOfNode(node); + grammarErrorOnNode(node.label, ts.Diagnostics.Duplicate_label_0, ts.getTextOfNodeFromSourceText(sourceFile.text, node.label)); + break; + } + current = current.parent; + } + } + checkSourceElement(node.statement); + } + function checkThrowStatement(node) { + if (!checkGrammarStatementInAmbientContext(node)) { + if (node.expression === undefined) { + grammarErrorAfterFirstToken(node, ts.Diagnostics.Line_break_not_permitted_here); + } + } + if (node.expression) { + checkExpression(node.expression); + } + } + function checkTryStatement(node) { + checkGrammarStatementInAmbientContext(node); + checkBlock(node.tryBlock); + var catchClause = node.catchClause; + if (catchClause) { + if (catchClause.variableDeclaration) { + if (catchClause.variableDeclaration.name.kind !== 69) { + grammarErrorOnFirstToken(catchClause.variableDeclaration.name, ts.Diagnostics.Catch_clause_variable_name_must_be_an_identifier); + } + else if (catchClause.variableDeclaration.type) { + grammarErrorOnFirstToken(catchClause.variableDeclaration.type, ts.Diagnostics.Catch_clause_variable_cannot_have_a_type_annotation); + } + else if (catchClause.variableDeclaration.initializer) { + grammarErrorOnFirstToken(catchClause.variableDeclaration.initializer, ts.Diagnostics.Catch_clause_variable_cannot_have_an_initializer); + } + else { + var identifierName = catchClause.variableDeclaration.name.text; + var locals = catchClause.block.locals; + if (locals && ts.hasProperty(locals, identifierName)) { + var localSymbol = locals[identifierName]; + if (localSymbol && (localSymbol.flags & 2) !== 0) { + grammarErrorOnNode(localSymbol.valueDeclaration, ts.Diagnostics.Cannot_redeclare_identifier_0_in_catch_clause, identifierName); + } + } + } + } + checkBlock(catchClause.block); + } + if (node.finallyBlock) { + checkBlock(node.finallyBlock); + } + } + function checkIndexConstraints(type) { + var declaredNumberIndexer = getIndexDeclarationOfSymbol(type.symbol, 1); + var declaredStringIndexer = getIndexDeclarationOfSymbol(type.symbol, 0); + var stringIndexType = getIndexTypeOfType(type, 0); + var numberIndexType = getIndexTypeOfType(type, 1); + if (stringIndexType || numberIndexType) { + ts.forEach(getPropertiesOfObjectType(type), function (prop) { + var propType = getTypeOfSymbol(prop); + checkIndexConstraintForProperty(prop, propType, type, declaredStringIndexer, stringIndexType, 0); + checkIndexConstraintForProperty(prop, propType, type, declaredNumberIndexer, numberIndexType, 1); + }); + if (type.flags & 1024 && ts.isClassLike(type.symbol.valueDeclaration)) { + var classDeclaration = type.symbol.valueDeclaration; + for (var _i = 0, _a = classDeclaration.members; _i < _a.length; _i++) { + var member = _a[_i]; + if (!(member.flags & 128) && ts.hasDynamicName(member)) { + var propType = getTypeOfSymbol(member.symbol); + checkIndexConstraintForProperty(member.symbol, propType, type, declaredStringIndexer, stringIndexType, 0); + checkIndexConstraintForProperty(member.symbol, propType, type, declaredNumberIndexer, numberIndexType, 1); + } + } + } + } + var errorNode; + if (stringIndexType && numberIndexType) { + errorNode = declaredNumberIndexer || declaredStringIndexer; + if (!errorNode && (type.flags & 2048)) { + var someBaseTypeHasBothIndexers = ts.forEach(getBaseTypes(type), function (base) { return getIndexTypeOfType(base, 0) && getIndexTypeOfType(base, 1); }); + errorNode = someBaseTypeHasBothIndexers ? undefined : type.symbol.declarations[0]; + } + } + if (errorNode && !isTypeAssignableTo(numberIndexType, stringIndexType)) { + error(errorNode, ts.Diagnostics.Numeric_index_type_0_is_not_assignable_to_string_index_type_1, typeToString(numberIndexType), typeToString(stringIndexType)); + } + function checkIndexConstraintForProperty(prop, propertyType, containingType, indexDeclaration, indexType, indexKind) { + if (!indexType) { + return; + } + if (indexKind === 1 && !isNumericName(prop.valueDeclaration.name)) { + return; + } + var errorNode; + if (prop.valueDeclaration.name.kind === 136 || prop.parent === containingType.symbol) { + errorNode = prop.valueDeclaration; + } + else if (indexDeclaration) { + errorNode = indexDeclaration; + } + else if (containingType.flags & 2048) { + var someBaseClassHasBothPropertyAndIndexer = ts.forEach(getBaseTypes(containingType), function (base) { return getPropertyOfObjectType(base, prop.name) && getIndexTypeOfType(base, indexKind); }); + errorNode = someBaseClassHasBothPropertyAndIndexer ? undefined : containingType.symbol.declarations[0]; + } + if (errorNode && !isTypeAssignableTo(propertyType, indexType)) { + var errorMessage = indexKind === 0 + ? ts.Diagnostics.Property_0_of_type_1_is_not_assignable_to_string_index_type_2 + : ts.Diagnostics.Property_0_of_type_1_is_not_assignable_to_numeric_index_type_2; + error(errorNode, errorMessage, symbolToString(prop), typeToString(propertyType), typeToString(indexType)); + } + } + } + function checkTypeNameIsReserved(name, message) { + switch (name.text) { + case "any": + case "number": + case "boolean": + case "string": + case "symbol": + case "void": + error(name, message, name.text); + } + } + function checkTypeParameters(typeParameterDeclarations) { + if (typeParameterDeclarations) { + for (var i = 0, n = typeParameterDeclarations.length; i < n; i++) { + var node = typeParameterDeclarations[i]; + checkTypeParameter(node); + if (produceDiagnostics) { + for (var j = 0; j < i; j++) { + if (typeParameterDeclarations[j].symbol === node.symbol) { + error(node.name, ts.Diagnostics.Duplicate_identifier_0, ts.declarationNameToString(node.name)); + } + } + } + } + } + } + function checkClassExpression(node) { + checkClassLikeDeclaration(node); + return getTypeOfSymbol(getSymbolOfNode(node)); + } + function checkClassDeclaration(node) { + if (!node.name && !(node.flags & 1024)) { + grammarErrorOnFirstToken(node, ts.Diagnostics.A_class_declaration_without_the_default_modifier_must_have_a_name); + } + checkClassLikeDeclaration(node); + ts.forEach(node.members, checkSourceElement); + } + function checkClassLikeDeclaration(node) { + checkGrammarClassDeclarationHeritageClauses(node); + checkDecorators(node); + if (node.name) { + checkTypeNameIsReserved(node.name, ts.Diagnostics.Class_name_cannot_be_0); + checkCollisionWithCapturedThisVariable(node, node.name); + checkCollisionWithRequireExportsInGeneratedCode(node, node.name); + } + checkTypeParameters(node.typeParameters); + checkExportsOnMergedDeclarations(node); + var symbol = getSymbolOfNode(node); + var type = getDeclaredTypeOfSymbol(symbol); + var typeWithThis = getTypeWithThisArgument(type); + var staticType = getTypeOfSymbol(symbol); + var baseTypeNode = ts.getClassExtendsHeritageClauseElement(node); + if (baseTypeNode) { + emitExtends = emitExtends || !ts.isInAmbientContext(node); + var baseTypes = getBaseTypes(type); + if (baseTypes.length && produceDiagnostics) { + var baseType = baseTypes[0]; + var staticBaseType = getBaseConstructorTypeOfClass(type); + checkSourceElement(baseTypeNode.expression); + if (baseTypeNode.typeArguments) { + ts.forEach(baseTypeNode.typeArguments, checkSourceElement); + for (var _i = 0, _a = getConstructorsForTypeArguments(staticBaseType, baseTypeNode.typeArguments); _i < _a.length; _i++) { + var constructor = _a[_i]; + if (!checkTypeArgumentConstraints(constructor.typeParameters, baseTypeNode.typeArguments)) { + break; + } + } + } + checkTypeAssignableTo(typeWithThis, getTypeWithThisArgument(baseType, type.thisType), node.name || node, ts.Diagnostics.Class_0_incorrectly_extends_base_class_1); + checkTypeAssignableTo(staticType, getTypeWithoutSignatures(staticBaseType), node.name || node, ts.Diagnostics.Class_static_side_0_incorrectly_extends_base_class_static_side_1); + if (!(staticBaseType.symbol && staticBaseType.symbol.flags & 32)) { + var constructors = getInstantiatedConstructorsForTypeArguments(staticBaseType, baseTypeNode.typeArguments); + if (ts.forEach(constructors, function (sig) { return getReturnTypeOfSignature(sig) !== baseType; })) { + error(baseTypeNode.expression, ts.Diagnostics.Base_constructors_must_all_have_the_same_return_type); + } + } + checkKindsOfPropertyMemberOverrides(type, baseType); + } + } + var implementedTypeNodes = ts.getClassImplementsHeritageClauseElements(node); + if (implementedTypeNodes) { + for (var _b = 0; _b < implementedTypeNodes.length; _b++) { + var typeRefNode = implementedTypeNodes[_b]; + if (!ts.isSupportedExpressionWithTypeArguments(typeRefNode)) { + error(typeRefNode.expression, ts.Diagnostics.A_class_can_only_implement_an_identifier_Slashqualified_name_with_optional_type_arguments); + } + checkTypeReferenceNode(typeRefNode); + if (produceDiagnostics) { + var t = getTypeFromTypeNode(typeRefNode); + if (t !== unknownType) { + var declaredType = (t.flags & 4096) ? t.target : t; + if (declaredType.flags & (1024 | 2048)) { + checkTypeAssignableTo(typeWithThis, getTypeWithThisArgument(t, type.thisType), node.name || node, ts.Diagnostics.Class_0_incorrectly_implements_interface_1); + } + else { + error(typeRefNode, ts.Diagnostics.A_class_may_only_implement_another_class_or_interface); + } + } + } + } + } + if (produceDiagnostics) { + checkIndexConstraints(type); + checkTypeForDuplicateIndexSignatures(node); + } + } + function getTargetSymbol(s) { + return s.flags & 16777216 ? getSymbolLinks(s).target : s; + } + function getClassLikeDeclarationOfSymbol(symbol) { + return ts.forEach(symbol.declarations, function (d) { return ts.isClassLike(d) ? d : undefined; }); + } + function checkKindsOfPropertyMemberOverrides(type, baseType) { + var baseProperties = getPropertiesOfObjectType(baseType); + for (var _i = 0; _i < baseProperties.length; _i++) { + var baseProperty = baseProperties[_i]; + var base = getTargetSymbol(baseProperty); + if (base.flags & 134217728) { + continue; + } + var derived = getTargetSymbol(getPropertyOfObjectType(type, base.name)); + var baseDeclarationFlags = getDeclarationFlagsFromSymbol(base); + ts.Debug.assert(!!derived, "derived should point to something, even if it is the base class' declaration."); + if (derived) { + if (derived === base) { + var derivedClassDecl = getClassLikeDeclarationOfSymbol(type.symbol); + if (baseDeclarationFlags & 256 && (!derivedClassDecl || !(derivedClassDecl.flags & 256))) { + if (derivedClassDecl.kind === 186) { + error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1, symbolToString(baseProperty), typeToString(baseType)); + } + else { + error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_0_does_not_implement_inherited_abstract_member_1_from_class_2, typeToString(type), symbolToString(baseProperty), typeToString(baseType)); + } + } + } + else { + var derivedDeclarationFlags = getDeclarationFlagsFromSymbol(derived); + if ((baseDeclarationFlags & 32) || (derivedDeclarationFlags & 32)) { + continue; + } + if ((baseDeclarationFlags & 128) !== (derivedDeclarationFlags & 128)) { + continue; + } + if ((base.flags & derived.flags & 8192) || ((base.flags & 98308) && (derived.flags & 98308))) { + continue; + } + var errorMessage = void 0; + if (base.flags & 8192) { + if (derived.flags & 98304) { + errorMessage = ts.Diagnostics.Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_accessor; + } + else { + ts.Debug.assert((derived.flags & 4) !== 0); + errorMessage = ts.Diagnostics.Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_property; + } + } + else if (base.flags & 4) { + ts.Debug.assert((derived.flags & 8192) !== 0); + errorMessage = ts.Diagnostics.Class_0_defines_instance_member_property_1_but_extended_class_2_defines_it_as_instance_member_function; + } + else { + ts.Debug.assert((base.flags & 98304) !== 0); + ts.Debug.assert((derived.flags & 8192) !== 0); + errorMessage = ts.Diagnostics.Class_0_defines_instance_member_accessor_1_but_extended_class_2_defines_it_as_instance_member_function; + } + error(derived.valueDeclaration.name, errorMessage, typeToString(baseType), symbolToString(base), typeToString(type)); + } + } + } + } + function isAccessor(kind) { + return kind === 145 || kind === 146; + } + function areTypeParametersIdentical(list1, list2) { + if (!list1 && !list2) { + return true; + } + if (!list1 || !list2 || list1.length !== list2.length) { + return false; + } + for (var i = 0, len = list1.length; i < len; i++) { + var tp1 = list1[i]; + var tp2 = list2[i]; + if (tp1.name.text !== tp2.name.text) { + return false; + } + if (!tp1.constraint && !tp2.constraint) { + continue; + } + if (!tp1.constraint || !tp2.constraint) { + return false; + } + if (!isTypeIdenticalTo(getTypeFromTypeNode(tp1.constraint), getTypeFromTypeNode(tp2.constraint))) { + return false; + } + } + return true; + } + function checkInheritedPropertiesAreIdentical(type, typeNode) { + var baseTypes = getBaseTypes(type); + if (baseTypes.length < 2) { + return true; + } + var seen = {}; + ts.forEach(resolveDeclaredMembers(type).declaredProperties, function (p) { seen[p.name] = { prop: p, containingType: type }; }); + var ok = true; + for (var _i = 0; _i < baseTypes.length; _i++) { + var base = baseTypes[_i]; + var properties = getPropertiesOfObjectType(getTypeWithThisArgument(base, type.thisType)); + for (var _a = 0; _a < properties.length; _a++) { + var prop = properties[_a]; + if (!ts.hasProperty(seen, prop.name)) { + seen[prop.name] = { prop: prop, containingType: base }; + } + else { + var existing = seen[prop.name]; + var isInheritedProperty = existing.containingType !== type; + if (isInheritedProperty && !isPropertyIdenticalTo(existing.prop, prop)) { + ok = false; + var typeName1 = typeToString(existing.containingType); + var typeName2 = typeToString(base); + var errorInfo = ts.chainDiagnosticMessages(undefined, ts.Diagnostics.Named_property_0_of_types_1_and_2_are_not_identical, symbolToString(prop), typeName1, typeName2); + errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.Interface_0_cannot_simultaneously_extend_types_1_and_2, typeToString(type), typeName1, typeName2); + diagnostics.add(ts.createDiagnosticForNodeFromMessageChain(typeNode, errorInfo)); + } + } + } + } + return ok; + } + function checkInterfaceDeclaration(node) { + checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarInterfaceDeclaration(node); + checkTypeParameters(node.typeParameters); + if (produceDiagnostics) { + checkTypeNameIsReserved(node.name, ts.Diagnostics.Interface_name_cannot_be_0); + checkExportsOnMergedDeclarations(node); + var symbol = getSymbolOfNode(node); + var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 215); + if (symbol.declarations.length > 1) { + if (node !== firstInterfaceDecl && !areTypeParametersIdentical(firstInterfaceDecl.typeParameters, node.typeParameters)) { + error(node.name, ts.Diagnostics.All_declarations_of_an_interface_must_have_identical_type_parameters); + } + } + if (node === firstInterfaceDecl) { + var type = getDeclaredTypeOfSymbol(symbol); + var typeWithThis = getTypeWithThisArgument(type); + if (checkInheritedPropertiesAreIdentical(type, node.name)) { + for (var _i = 0, _a = getBaseTypes(type); _i < _a.length; _i++) { + var baseType = _a[_i]; + checkTypeAssignableTo(typeWithThis, getTypeWithThisArgument(baseType, type.thisType), node.name, ts.Diagnostics.Interface_0_incorrectly_extends_interface_1); + } + checkIndexConstraints(type); + } + } + } + ts.forEach(ts.getInterfaceBaseTypeNodes(node), function (heritageElement) { + if (!ts.isSupportedExpressionWithTypeArguments(heritageElement)) { + error(heritageElement.expression, ts.Diagnostics.An_interface_can_only_extend_an_identifier_Slashqualified_name_with_optional_type_arguments); + } + checkTypeReferenceNode(heritageElement); + }); + ts.forEach(node.members, checkSourceElement); + if (produceDiagnostics) { + checkTypeForDuplicateIndexSignatures(node); + } + } + function checkTypeAliasDeclaration(node) { + checkGrammarDecorators(node) || checkGrammarModifiers(node); + checkTypeNameIsReserved(node.name, ts.Diagnostics.Type_alias_name_cannot_be_0); + checkSourceElement(node.type); + } + function computeEnumMemberValues(node) { + var nodeLinks = getNodeLinks(node); + if (!(nodeLinks.flags & 8192)) { + var enumSymbol = getSymbolOfNode(node); + var enumType = getDeclaredTypeOfSymbol(enumSymbol); + var autoValue = 0; + var ambient = ts.isInAmbientContext(node); + var enumIsConst = ts.isConst(node); + for (var _i = 0, _a = node.members; _i < _a.length; _i++) { + var member = _a[_i]; + if (member.name.kind === 136) { + error(member.name, ts.Diagnostics.Computed_property_names_are_not_allowed_in_enums); + } + else if (isNumericLiteralName(member.name.text)) { + error(member.name, ts.Diagnostics.An_enum_member_cannot_have_a_numeric_name); + } + var previousEnumMemberIsNonConstant = autoValue === undefined; + var initializer = member.initializer; + if (initializer) { + autoValue = computeConstantValueForEnumMemberInitializer(initializer, enumType, enumIsConst, ambient); + } + else if (ambient && !enumIsConst) { + autoValue = undefined; + } + else if (previousEnumMemberIsNonConstant) { + error(member.name, ts.Diagnostics.Enum_member_must_have_initializer); + } + if (autoValue !== undefined) { + getNodeLinks(member).enumMemberValue = autoValue++; + } + } + nodeLinks.flags |= 8192; + } + function computeConstantValueForEnumMemberInitializer(initializer, enumType, enumIsConst, ambient) { + var reportError = true; + var value = evalConstant(initializer); + if (reportError) { + if (value === undefined) { + if (enumIsConst) { + error(initializer, ts.Diagnostics.In_const_enum_declarations_member_initializer_must_be_constant_expression); + } + else if (ambient) { + error(initializer, ts.Diagnostics.In_ambient_enum_declarations_member_initializer_must_be_constant_expression); + } + else { + checkTypeAssignableTo(checkExpression(initializer), enumType, initializer, undefined); + } + } + else if (enumIsConst) { + if (isNaN(value)) { + error(initializer, ts.Diagnostics.const_enum_member_initializer_was_evaluated_to_disallowed_value_NaN); + } + else if (!isFinite(value)) { + error(initializer, ts.Diagnostics.const_enum_member_initializer_was_evaluated_to_a_non_finite_value); + } + } + } + return value; + function evalConstant(e) { + switch (e.kind) { + case 179: + 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; + } + return undefined; + case 181: + var left = evalConstant(e.left); + if (left === undefined) { + return undefined; + } + var right = evalConstant(e.right); + if (right === undefined) { + 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; + } + return undefined; + case 8: + return +e.text; + case 172: + return evalConstant(e.expression); + case 69: + case 167: + case 166: + var member = initializer.parent; + var currentType = getTypeOfSymbol(getSymbolOfNode(member.parent)); + var enumType_1; + var propertyName; + if (e.kind === 69) { + enumType_1 = currentType; + propertyName = e.text; + } + else { + var expression; + if (e.kind === 167) { + if (e.argumentExpression === undefined || + e.argumentExpression.kind !== 9) { + return undefined; + } + expression = e.expression; + propertyName = e.argumentExpression.text; + } + else { + expression = e.expression; + propertyName = e.name.text; + } + var current = expression; + while (current) { + if (current.kind === 69) { + break; + } + else if (current.kind === 166) { + current = current.expression; + } + else { + return undefined; + } + } + enumType_1 = checkExpression(expression); + if (!(enumType_1.symbol && (enumType_1.symbol.flags & 384))) { + return undefined; + } + } + if (propertyName === undefined) { + return undefined; + } + var property = getPropertyOfObjectType(enumType_1, propertyName); + if (!property || !(property.flags & 8)) { + return undefined; + } + var propertyDecl = property.valueDeclaration; + if (member === propertyDecl) { + return undefined; + } + if (!isBlockScopedNameDeclaredBeforeUse(propertyDecl, member)) { + reportError = false; + error(e, ts.Diagnostics.A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_enums); + return undefined; + } + return getNodeLinks(propertyDecl).enumMemberValue; + } + } + } + } + function checkEnumDeclaration(node) { + if (!produceDiagnostics) { + return; + } + checkGrammarDecorators(node) || checkGrammarModifiers(node); + checkTypeNameIsReserved(node.name, ts.Diagnostics.Enum_name_cannot_be_0); + checkCollisionWithCapturedThisVariable(node, node.name); + checkCollisionWithRequireExportsInGeneratedCode(node, node.name); + checkExportsOnMergedDeclarations(node); + computeEnumMemberValues(node); + var enumIsConst = ts.isConst(node); + if (compilerOptions.isolatedModules && enumIsConst && ts.isInAmbientContext(node)) { + error(node.name, ts.Diagnostics.Ambient_const_enums_are_not_allowed_when_the_isolatedModules_flag_is_provided); + } + var enumSymbol = getSymbolOfNode(node); + var firstDeclaration = ts.getDeclarationOfKind(enumSymbol, node.kind); + if (node === firstDeclaration) { + if (enumSymbol.declarations.length > 1) { + ts.forEach(enumSymbol.declarations, function (decl) { + if (ts.isConstEnumDeclaration(decl) !== enumIsConst) { + error(decl.name, ts.Diagnostics.Enum_declarations_must_all_be_const_or_non_const); + } + }); + } + var seenEnumMissingInitialInitializer = false; + ts.forEach(enumSymbol.declarations, function (declaration) { + if (declaration.kind !== 217) { + return false; + } + var enumDeclaration = declaration; + if (!enumDeclaration.members.length) { + return false; + } + var firstEnumMember = enumDeclaration.members[0]; + if (!firstEnumMember.initializer) { + if (seenEnumMissingInitialInitializer) { + error(firstEnumMember.name, ts.Diagnostics.In_an_enum_with_multiple_declarations_only_one_declaration_can_omit_an_initializer_for_its_first_enum_element); + } + else { + seenEnumMissingInitialInitializer = true; + } + } + }); + } + } + function getFirstNonAmbientClassOrFunctionDeclaration(symbol) { + var declarations = symbol.declarations; + for (var _i = 0; _i < declarations.length; _i++) { + var declaration = declarations[_i]; + if ((declaration.kind === 214 || + (declaration.kind === 213 && ts.nodeIsPresent(declaration.body))) && + !ts.isInAmbientContext(declaration)) { + return declaration; + } + } + return undefined; + } + function inSameLexicalScope(node1, node2) { + var container1 = ts.getEnclosingBlockScopeContainer(node1); + var container2 = ts.getEnclosingBlockScopeContainer(node2); + if (isGlobalSourceFile(container1)) { + return isGlobalSourceFile(container2); + } + else if (isGlobalSourceFile(container2)) { + return false; + } + else { + return container1 === container2; + } + } + function checkModuleDeclaration(node) { + if (produceDiagnostics) { + var isAmbientExternalModule = node.name.kind === 9; + var contextErrorMessage = isAmbientExternalModule + ? ts.Diagnostics.An_ambient_module_declaration_is_only_allowed_at_the_top_level_in_a_file + : ts.Diagnostics.A_namespace_declaration_is_only_allowed_in_a_namespace_or_module; + if (checkGrammarModuleElementContext(node, contextErrorMessage)) { + return; + } + if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node)) { + if (!ts.isInAmbientContext(node) && node.name.kind === 9) { + grammarErrorOnNode(node.name, ts.Diagnostics.Only_ambient_modules_can_use_quoted_names); + } + } + checkCollisionWithCapturedThisVariable(node, node.name); + checkCollisionWithRequireExportsInGeneratedCode(node, node.name); + checkExportsOnMergedDeclarations(node); + var symbol = getSymbolOfNode(node); + if (symbol.flags & 512 + && symbol.declarations.length > 1 + && !ts.isInAmbientContext(node) + && ts.isInstantiatedModule(node, compilerOptions.preserveConstEnums || compilerOptions.isolatedModules)) { + var firstNonAmbientClassOrFunc = getFirstNonAmbientClassOrFunctionDeclaration(symbol); + if (firstNonAmbientClassOrFunc) { + if (ts.getSourceFileOfNode(node) !== ts.getSourceFileOfNode(firstNonAmbientClassOrFunc)) { + error(node.name, ts.Diagnostics.A_namespace_declaration_cannot_be_in_a_different_file_from_a_class_or_function_with_which_it_is_merged); + } + else if (node.pos < firstNonAmbientClassOrFunc.pos) { + 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, 214); + if (mergedClass && + inSameLexicalScope(node, mergedClass)) { + getNodeLinks(node).flags |= 32768; + } + } + if (isAmbientExternalModule) { + if (!isGlobalSourceFile(node.parent)) { + error(node.name, ts.Diagnostics.Ambient_modules_cannot_be_nested_in_other_modules_or_namespaces); + } + if (ts.isExternalModuleNameRelative(node.name.text)) { + error(node.name, ts.Diagnostics.Ambient_module_declaration_cannot_specify_relative_module_name); + } + } + } + checkSourceElement(node.body); + } + function getFirstIdentifier(node) { + while (true) { + if (node.kind === 135) { + node = node.left; + } + else if (node.kind === 166) { + node = node.expression; + } + else { + break; + } + } + ts.Debug.assert(node.kind === 69); + return node; + } + function checkExternalImportOrExportDeclaration(node) { + var moduleName = ts.getExternalModuleName(node); + if (!ts.nodeIsMissing(moduleName) && moduleName.kind !== 9) { + error(moduleName, ts.Diagnostics.String_literal_expected); + return false; + } + var inAmbientExternalModule = node.parent.kind === 219 && node.parent.parent.name.kind === 9; + if (node.parent.kind !== 248 && !inAmbientExternalModule) { + error(moduleName, node.kind === 228 ? + ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace : + ts.Diagnostics.Import_declarations_in_a_namespace_cannot_reference_a_module); + return false; + } + if (inAmbientExternalModule && ts.isExternalModuleNameRelative(moduleName.text)) { + error(node, ts.Diagnostics.Import_or_export_declaration_in_an_ambient_module_declaration_cannot_reference_module_through_relative_module_name); + return false; + } + return true; + } + function checkAliasSymbol(node) { + var symbol = getSymbolOfNode(node); + var target = resolveAlias(symbol); + if (target !== unknownSymbol) { + var excludedMeanings = (symbol.flags & 107455 ? 107455 : 0) | + (symbol.flags & 793056 ? 793056 : 0) | + (symbol.flags & 1536 ? 1536 : 0); + if (target.flags & excludedMeanings) { + var message = node.kind === 230 ? + ts.Diagnostics.Export_declaration_conflicts_with_exported_declaration_of_0 : + ts.Diagnostics.Import_declaration_conflicts_with_local_declaration_of_0; + error(node, message, symbolToString(symbol)); + } + } + } + function checkImportBinding(node) { + checkCollisionWithCapturedThisVariable(node, node.name); + checkCollisionWithRequireExportsInGeneratedCode(node, node.name); + checkAliasSymbol(node); + } + function checkImportDeclaration(node) { + if (checkGrammarModuleElementContext(node, ts.Diagnostics.An_import_declaration_can_only_be_used_in_a_namespace_or_module)) { + return; + } + if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && (node.flags & 2035)) { + grammarErrorOnFirstToken(node, ts.Diagnostics.An_import_declaration_cannot_have_modifiers); + } + if (checkExternalImportOrExportDeclaration(node)) { + var importClause = node.importClause; + if (importClause) { + if (importClause.name) { + checkImportBinding(importClause); + } + if (importClause.namedBindings) { + if (importClause.namedBindings.kind === 224) { + checkImportBinding(importClause.namedBindings); + } + else { + ts.forEach(importClause.namedBindings.elements, checkImportBinding); + } + } + } + } + } + function checkImportEqualsDeclaration(node) { + if (checkGrammarModuleElementContext(node, ts.Diagnostics.An_import_declaration_can_only_be_used_in_a_namespace_or_module)) { + return; + } + checkGrammarDecorators(node) || checkGrammarModifiers(node); + if (ts.isInternalModuleImportEqualsDeclaration(node) || checkExternalImportOrExportDeclaration(node)) { + checkImportBinding(node); + if (node.flags & 1) { + markExportAsReferenced(node); + } + if (ts.isInternalModuleImportEqualsDeclaration(node)) { + var target = resolveAlias(getSymbolOfNode(node)); + if (target !== unknownSymbol) { + if (target.flags & 107455) { + var moduleName = getFirstIdentifier(node.moduleReference); + if (!(resolveEntityName(moduleName, 107455 | 1536).flags & 1536)) { + error(moduleName, ts.Diagnostics.Module_0_is_hidden_by_a_local_declaration_with_the_same_name, ts.declarationNameToString(moduleName)); + } + } + if (target.flags & 793056) { + checkTypeNameIsReserved(node.name, ts.Diagnostics.Import_name_cannot_be_0); + } + } + } + else { + if (modulekind === 5 && !ts.isInAmbientContext(node)) { + grammarErrorOnNode(node, ts.Diagnostics.Import_assignment_cannot_be_used_when_targeting_ECMAScript_6_modules_Consider_using_import_Asterisk_as_ns_from_mod_import_a_from_mod_import_d_from_mod_or_another_module_format_instead); + } + } + } + } + function checkExportDeclaration(node) { + if (checkGrammarModuleElementContext(node, ts.Diagnostics.An_export_declaration_can_only_be_used_in_a_module)) { + return; + } + if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && (node.flags & 2035)) { + grammarErrorOnFirstToken(node, ts.Diagnostics.An_export_declaration_cannot_have_modifiers); + } + if (!node.moduleSpecifier || checkExternalImportOrExportDeclaration(node)) { + if (node.exportClause) { + ts.forEach(node.exportClause.elements, checkExportSpecifier); + var inAmbientExternalModule = node.parent.kind === 219 && node.parent.parent.name.kind === 9; + if (node.parent.kind !== 248 && !inAmbientExternalModule) { + error(node, ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace); + } + } + else { + var moduleSymbol = resolveExternalModuleName(node, node.moduleSpecifier); + if (moduleSymbol && moduleSymbol.exports["export="]) { + error(node.moduleSpecifier, ts.Diagnostics.Module_0_uses_export_and_cannot_be_used_with_export_Asterisk, symbolToString(moduleSymbol)); + } + } + } + } + function checkGrammarModuleElementContext(node, errorMessage) { + if (node.parent.kind !== 248 && node.parent.kind !== 219 && node.parent.kind !== 218) { + return grammarErrorOnFirstToken(node, errorMessage); + } + } + function checkExportSpecifier(node) { + checkAliasSymbol(node); + if (!node.parent.parent.moduleSpecifier) { + markExportAsReferenced(node); + } + } + function checkExportAssignment(node) { + if (checkGrammarModuleElementContext(node, ts.Diagnostics.An_export_assignment_can_only_be_used_in_a_module)) { + return; + } + var container = node.parent.kind === 248 ? node.parent : node.parent.parent; + if (container.kind === 218 && container.name.kind === 69) { + error(node, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_namespace); + return; + } + if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && (node.flags & 2035)) { + grammarErrorOnFirstToken(node, ts.Diagnostics.An_export_assignment_cannot_have_modifiers); + } + if (node.expression.kind === 69) { + markExportAsReferenced(node); + } + else { + checkExpressionCached(node.expression); + } + checkExternalModuleExports(container); + if (node.isExportEquals && !ts.isInAmbientContext(node)) { + if (modulekind === 5) { + grammarErrorOnNode(node, ts.Diagnostics.Export_assignment_cannot_be_used_when_targeting_ECMAScript_6_modules_Consider_using_export_default_or_another_module_format_instead); + } + else if (modulekind === 4) { + grammarErrorOnNode(node, ts.Diagnostics.Export_assignment_is_not_supported_when_module_flag_is_system); + } + } + } + function getModuleStatements(node) { + if (node.kind === 248) { + return node.statements; + } + if (node.kind === 218 && node.body.kind === 219) { + return node.body.statements; + } + return emptyArray; + } + function hasExportedMembers(moduleSymbol) { + for (var id in moduleSymbol.exports) { + if (id !== "export=") { + return true; + } + } + return false; + } + function checkExternalModuleExports(node) { + var moduleSymbol = getSymbolOfNode(node); + var links = getSymbolLinks(moduleSymbol); + if (!links.exportsChecked) { + var exportEqualsSymbol = moduleSymbol.exports["export="]; + if (exportEqualsSymbol && hasExportedMembers(moduleSymbol)) { + var declaration = getDeclarationOfAliasSymbol(exportEqualsSymbol) || exportEqualsSymbol.valueDeclaration; + error(declaration, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_module_with_other_exported_elements); + } + links.exportsChecked = true; + } + } + function checkTypePredicate(node) { + if (!isInLegalTypePredicatePosition(node)) { + error(node, ts.Diagnostics.A_type_predicate_is_only_allowed_in_return_type_position_for_functions_and_methods); + } + } + function checkSourceElement(node) { + if (!node) { + return; + } + var kind = node.kind; + if (cancellationToken) { + switch (kind) { + case 218: + case 214: + case 215: + case 213: + cancellationToken.throwIfCancellationRequested(); + } + } + switch (kind) { + case 137: + return checkTypeParameter(node); + case 138: + return checkParameter(node); + case 141: + case 140: + return checkPropertyDeclaration(node); + case 152: + case 153: + case 147: + case 148: + return checkSignatureDeclaration(node); + case 149: + return checkSignatureDeclaration(node); + case 143: + case 142: + return checkMethodDeclaration(node); + case 144: + return checkConstructorDeclaration(node); + case 145: + case 146: + return checkAccessorDeclaration(node); + case 151: + return checkTypeReferenceNode(node); + case 150: + return checkTypePredicate(node); + case 154: + return checkTypeQuery(node); + case 155: + return checkTypeLiteral(node); + case 156: + return checkArrayType(node); + case 157: + return checkTupleType(node); + case 158: + case 159: + return checkUnionOrIntersectionType(node); + case 160: + return checkSourceElement(node.type); + case 213: + return checkFunctionDeclaration(node); + case 192: + case 219: + return checkBlock(node); + case 193: + return checkVariableStatement(node); + case 195: + return checkExpressionStatement(node); + case 196: + return checkIfStatement(node); + case 197: + return checkDoStatement(node); + case 198: + return checkWhileStatement(node); + case 199: + return checkForStatement(node); + case 200: + return checkForInStatement(node); + case 201: + return checkForOfStatement(node); + case 202: + case 203: + return checkBreakOrContinueStatement(node); + case 204: + return checkReturnStatement(node); + case 205: + return checkWithStatement(node); + case 206: + return checkSwitchStatement(node); + case 207: + return checkLabeledStatement(node); + case 208: + return checkThrowStatement(node); + case 209: + return checkTryStatement(node); + case 211: + return checkVariableDeclaration(node); + case 163: + return checkBindingElement(node); + case 214: + return checkClassDeclaration(node); + case 215: + return checkInterfaceDeclaration(node); + case 216: + return checkTypeAliasDeclaration(node); + case 217: + return checkEnumDeclaration(node); + case 218: + return checkModuleDeclaration(node); + case 222: + return checkImportDeclaration(node); + case 221: + return checkImportEqualsDeclaration(node); + case 228: + return checkExportDeclaration(node); + case 227: + return checkExportAssignment(node); + case 194: + checkGrammarStatementInAmbientContext(node); + return; + case 210: + checkGrammarStatementInAmbientContext(node); + return; + case 231: + return checkMissingDeclaration(node); + } + } + function checkFunctionAndClassExpressionBodies(node) { + switch (node.kind) { + case 173: + case 174: + ts.forEach(node.parameters, checkFunctionAndClassExpressionBodies); + checkFunctionExpressionOrObjectLiteralMethodBody(node); + break; + case 186: + ts.forEach(node.members, checkSourceElement); + ts.forEachChild(node, checkFunctionAndClassExpressionBodies); + break; + case 143: + case 142: + ts.forEach(node.decorators, checkFunctionAndClassExpressionBodies); + ts.forEach(node.parameters, checkFunctionAndClassExpressionBodies); + if (ts.isObjectLiteralMethod(node)) { + checkFunctionExpressionOrObjectLiteralMethodBody(node); + } + break; + case 144: + case 145: + case 146: + case 213: + ts.forEach(node.parameters, checkFunctionAndClassExpressionBodies); + break; + case 205: + checkFunctionAndClassExpressionBodies(node.expression); + break; + case 139: + case 138: + case 141: + case 140: + case 161: + case 162: + case 163: + case 164: + case 165: + case 245: + case 166: + case 167: + case 168: + case 169: + case 170: + case 183: + case 190: + case 171: + case 189: + case 172: + case 176: + case 177: + case 178: + case 175: + case 179: + case 180: + case 181: + case 182: + case 185: + case 184: + case 192: + case 219: + case 193: + case 195: + case 196: + case 197: + case 198: + case 199: + case 200: + case 201: + case 202: + case 203: + case 204: + case 206: + case 220: + case 241: + case 242: + case 207: + case 208: + case 209: + case 244: + case 211: + case 212: + case 214: + case 243: + case 188: + case 217: + case 247: + case 227: + case 248: + case 240: + case 233: + case 234: + case 238: + case 239: + case 235: + ts.forEachChild(node, checkFunctionAndClassExpressionBodies); + break; + } + } + function checkSourceFile(node) { + var start = new Date().getTime(); + checkSourceFileWorker(node); + ts.checkTime += new Date().getTime() - start; + } + function checkSourceFileWorker(node) { + var links = getNodeLinks(node); + if (!(links.flags & 1)) { + if (node.isDefaultLib && compilerOptions.skipDefaultLibCheck) { + return; + } + checkGrammarSourceFile(node); + emitExtends = false; + emitDecorate = false; + emitParam = false; + potentialThisCollisions.length = 0; + ts.forEach(node.statements, checkSourceElement); + checkFunctionAndClassExpressionBodies(node); + if (ts.isExternalModule(node)) { + checkExternalModuleExports(node); + } + if (potentialThisCollisions.length) { + ts.forEach(potentialThisCollisions, checkIfThisIsCapturedInEnclosingScope); + potentialThisCollisions.length = 0; + } + if (emitExtends) { + links.flags |= 8; + } + if (emitDecorate) { + links.flags |= 16; + } + if (emitParam) { + links.flags |= 32; + } + if (emitAwaiter) { + links.flags |= 64; + } + if (emitGenerator || (emitAwaiter && languageVersion < 2)) { + links.flags |= 128; + } + links.flags |= 1; + } + } + function getDiagnostics(sourceFile, ct) { + try { + cancellationToken = ct; + return getDiagnosticsWorker(sourceFile); + } + finally { + cancellationToken = undefined; + } + } + function getDiagnosticsWorker(sourceFile) { + throwIfNonDiagnosticsProducing(); + if (sourceFile) { + checkSourceFile(sourceFile); + return diagnostics.getDiagnostics(sourceFile.fileName); + } + ts.forEach(host.getSourceFiles(), checkSourceFile); + return diagnostics.getDiagnostics(); + } + function getGlobalDiagnostics() { + throwIfNonDiagnosticsProducing(); + return diagnostics.getGlobalDiagnostics(); + } + function throwIfNonDiagnosticsProducing() { + if (!produceDiagnostics) { + throw new Error("Trying to get diagnostics from a type checker that does not produce them."); + } + } + function isInsideWithStatementBody(node) { + if (node) { + while (node.parent) { + if (node.parent.kind === 205 && node.parent.statement === node) { + return true; + } + node = node.parent; + } + } + return false; + } + function getSymbolsInScope(location, meaning) { + var symbols = {}; + var memberFlags = 0; + if (isInsideWithStatementBody(location)) { + return []; + } + populateSymbols(); + return symbolsToArray(symbols); + function populateSymbols() { + while (location) { + if (location.locals && !isGlobalSourceFile(location)) { + copySymbols(location.locals, meaning); + } + switch (location.kind) { + case 248: + if (!ts.isExternalModule(location)) { + break; + } + case 218: + copySymbols(getSymbolOfNode(location).exports, meaning & 8914931); + break; + case 217: + copySymbols(getSymbolOfNode(location).exports, meaning & 8); + break; + case 186: + var className = location.name; + if (className) { + copySymbol(location.symbol, meaning); + } + case 214: + case 215: + if (!(memberFlags & 128)) { + copySymbols(getSymbolOfNode(location).members, meaning & 793056); + } + break; + case 173: + var funcName = location.name; + if (funcName) { + copySymbol(location.symbol, meaning); + } + break; + } + if (ts.introducesArgumentsExoticObject(location)) { + copySymbol(argumentsSymbol, meaning); + } + memberFlags = location.flags; + location = location.parent; + } + copySymbols(globals, meaning); + } + function copySymbol(symbol, meaning) { + if (symbol.flags & meaning) { + var id = symbol.name; + if (!ts.hasProperty(symbols, id)) { + symbols[id] = symbol; + } + } + } + function copySymbols(source, meaning) { + if (meaning) { + for (var id in source) { + var symbol = source[id]; + copySymbol(symbol, meaning); + } + } + } + } + function isTypeDeclarationName(name) { + return name.kind === 69 && + isTypeDeclaration(name.parent) && + name.parent.name === name; + } + function isTypeDeclaration(node) { + switch (node.kind) { + case 137: + case 214: + case 215: + case 216: + case 217: + return true; + } + } + function isTypeReferenceIdentifier(entityName) { + var node = entityName; + while (node.parent && node.parent.kind === 135) { + node = node.parent; + } + return node.parent && node.parent.kind === 151; + } + function isHeritageClauseElementIdentifier(entityName) { + var node = entityName; + while (node.parent && node.parent.kind === 166) { + node = node.parent; + } + return node.parent && node.parent.kind === 188; + } + function getLeftSideOfImportEqualsOrExportAssignment(nodeOnRightSide) { + while (nodeOnRightSide.parent.kind === 135) { + nodeOnRightSide = nodeOnRightSide.parent; + } + if (nodeOnRightSide.parent.kind === 221) { + return nodeOnRightSide.parent.moduleReference === nodeOnRightSide && nodeOnRightSide.parent; + } + if (nodeOnRightSide.parent.kind === 227) { + return nodeOnRightSide.parent.expression === nodeOnRightSide && nodeOnRightSide.parent; + } + return undefined; + } + function isInRightSideOfImportOrExportAssignment(node) { + return getLeftSideOfImportEqualsOrExportAssignment(node) !== undefined; + } + function getSymbolOfEntityNameOrPropertyAccessExpression(entityName) { + if (ts.isDeclarationName(entityName)) { + return getSymbolOfNode(entityName.parent); + } + if (entityName.parent.kind === 227) { + return resolveEntityName(entityName, 107455 | 793056 | 1536 | 8388608); + } + if (entityName.kind !== 166) { + if (isInRightSideOfImportOrExportAssignment(entityName)) { + return getSymbolOfPartOfRightHandSideOfImportEquals(entityName); + } + } + if (ts.isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { + entityName = entityName.parent; + } + if (isHeritageClauseElementIdentifier(entityName)) { + var meaning = 0; + if (entityName.parent.kind === 188) { + meaning = 793056; + if (ts.isExpressionWithTypeArgumentsInClassExtendsClause(entityName.parent)) { + meaning |= 107455; + } + } + else { + meaning = 1536; + } + meaning |= 8388608; + return resolveEntityName(entityName, meaning); + } + else if ((entityName.parent.kind === 235) || + (entityName.parent.kind === 234) || + (entityName.parent.kind === 237)) { + return getJsxElementTagSymbol(entityName.parent); + } + else if (ts.isExpression(entityName)) { + if (ts.nodeIsMissing(entityName)) { + return undefined; + } + if (entityName.kind === 69) { + var meaning = 107455 | 8388608; + return resolveEntityName(entityName, meaning); + } + else if (entityName.kind === 166) { + var symbol = getNodeLinks(entityName).resolvedSymbol; + if (!symbol) { + checkPropertyAccessExpression(entityName); + } + return getNodeLinks(entityName).resolvedSymbol; + } + else if (entityName.kind === 135) { + var symbol = getNodeLinks(entityName).resolvedSymbol; + if (!symbol) { + checkQualifiedName(entityName); + } + return getNodeLinks(entityName).resolvedSymbol; + } + } + else if (isTypeReferenceIdentifier(entityName)) { + var meaning = entityName.parent.kind === 151 ? 793056 : 1536; + meaning |= 8388608; + return resolveEntityName(entityName, meaning); + } + else if (entityName.parent.kind === 238) { + return getJsxAttributePropertySymbol(entityName.parent); + } + if (entityName.parent.kind === 150) { + return resolveEntityName(entityName, 1); + } + return undefined; + } + function getSymbolAtLocation(node) { + if (isInsideWithStatementBody(node)) { + return undefined; + } + if (ts.isDeclarationName(node)) { + return getSymbolOfNode(node.parent); + } + if (node.kind === 69) { + if (isInRightSideOfImportOrExportAssignment(node)) { + return node.parent.kind === 227 + ? getSymbolOfEntityNameOrPropertyAccessExpression(node) + : getSymbolOfPartOfRightHandSideOfImportEquals(node); + } + else if (node.parent.kind === 163 && + node.parent.parent.kind === 161 && + node === node.parent.propertyName) { + var typeOfPattern = getTypeOfNode(node.parent.parent); + var propertyDeclaration = typeOfPattern && getPropertyOfType(typeOfPattern, node.text); + if (propertyDeclaration) { + return propertyDeclaration; + } + } + } + switch (node.kind) { + case 69: + case 166: + case 135: + return getSymbolOfEntityNameOrPropertyAccessExpression(node); + case 97: + case 95: + var type = ts.isExpression(node) ? checkExpression(node) : getTypeFromTypeNode(node); + return type.symbol; + case 121: + var constructorDeclaration = node.parent; + if (constructorDeclaration && constructorDeclaration.kind === 144) { + return constructorDeclaration.parent.symbol; + } + return undefined; + case 9: + if ((ts.isExternalModuleImportEqualsDeclaration(node.parent.parent) && + ts.getExternalModuleImportEqualsDeclarationExpression(node.parent.parent) === node) || + ((node.parent.kind === 222 || node.parent.kind === 228) && + node.parent.moduleSpecifier === node)) { + return resolveExternalModuleName(node, node); + } + case 8: + if (node.parent.kind === 167 && node.parent.argumentExpression === node) { + var objectType = checkExpression(node.parent.expression); + if (objectType === unknownType) + return undefined; + var apparentType = getApparentType(objectType); + if (apparentType === unknownType) + return undefined; + return getPropertyOfType(apparentType, node.text); + } + break; + } + return undefined; + } + function getShorthandAssignmentValueSymbol(location) { + if (location && location.kind === 246) { + return resolveEntityName(location.name, 107455); + } + return undefined; + } + function getTypeOfNode(node) { + if (isInsideWithStatementBody(node)) { + return unknownType; + } + if (ts.isTypeNode(node)) { + return getTypeFromTypeNode(node); + } + if (ts.isExpression(node)) { + return getTypeOfExpression(node); + } + if (ts.isExpressionWithTypeArgumentsInClassExtendsClause(node)) { + return getBaseTypes(getDeclaredTypeOfSymbol(getSymbolOfNode(node.parent.parent)))[0]; + } + if (isTypeDeclaration(node)) { + var symbol = getSymbolOfNode(node); + return getDeclaredTypeOfSymbol(symbol); + } + if (isTypeDeclarationName(node)) { + var symbol = getSymbolAtLocation(node); + return symbol && getDeclaredTypeOfSymbol(symbol); + } + if (ts.isDeclaration(node)) { + var symbol = getSymbolOfNode(node); + return getTypeOfSymbol(symbol); + } + if (ts.isDeclarationName(node)) { + var symbol = getSymbolAtLocation(node); + return symbol && getTypeOfSymbol(symbol); + } + if (ts.isBindingPattern(node)) { + return getTypeForVariableLikeDeclaration(node.parent); + } + if (isInRightSideOfImportOrExportAssignment(node)) { + var symbol = getSymbolAtLocation(node); + var declaredType = symbol && getDeclaredTypeOfSymbol(symbol); + return declaredType !== unknownType ? declaredType : getTypeOfSymbol(symbol); + } + return unknownType; + } + function getTypeOfExpression(expr) { + if (ts.isRightSideOfQualifiedNameOrPropertyAccess(expr)) { + expr = expr.parent; + } + return checkExpression(expr); + } + function getParentTypeOfClassElement(node) { + var classSymbol = getSymbolOfNode(node.parent); + return node.flags & 128 + ? getTypeOfSymbol(classSymbol) + : getDeclaredTypeOfSymbol(classSymbol); + } + function getAugmentedPropertiesOfType(type) { + type = getApparentType(type); + var propsByName = createSymbolTable(getPropertiesOfType(type)); + if (getSignaturesOfType(type, 0).length || getSignaturesOfType(type, 1).length) { + ts.forEach(getPropertiesOfType(globalFunctionType), function (p) { + if (!ts.hasProperty(propsByName, p.name)) { + propsByName[p.name] = p; + } + }); + } + return getNamedMembers(propsByName); + } + function getRootSymbols(symbol) { + if (symbol.flags & 268435456) { + var symbols = []; + var name_15 = symbol.name; + ts.forEach(getSymbolLinks(symbol).containingType.types, function (t) { + var symbol = getPropertyOfType(t, name_15); + if (symbol) { + symbols.push(symbol); + } + }); + return symbols; + } + else if (symbol.flags & 67108864) { + var target = getSymbolLinks(symbol).target; + if (target) { + return [target]; + } + } + return [symbol]; + } + function isArgumentsLocalBinding(node) { + return getReferencedValueSymbol(node) === argumentsSymbol; + } + function getReferencedExportContainer(node) { + var symbol = getReferencedValueSymbol(node); + if (symbol) { + if (symbol.flags & 1048576) { + var exportSymbol = getMergedSymbol(symbol.exportSymbol); + if (exportSymbol.flags & 944) { + return undefined; + } + symbol = exportSymbol; + } + var parentSymbol = getParentOfSymbol(symbol); + if (parentSymbol) { + if (parentSymbol.flags & 512 && parentSymbol.valueDeclaration.kind === 248) { + return parentSymbol.valueDeclaration; + } + for (var n = node.parent; n; n = n.parent) { + if ((n.kind === 218 || n.kind === 217) && getSymbolOfNode(n) === parentSymbol) { + return n; + } + } + } + } + } + function getReferencedImportDeclaration(node) { + var symbol = getReferencedValueSymbol(node); + return symbol && symbol.flags & 8388608 ? getDeclarationOfAliasSymbol(symbol) : undefined; + } + function isStatementWithLocals(node) { + switch (node.kind) { + case 192: + case 220: + case 199: + case 200: + case 201: + return true; + } + return false; + } + function isNestedRedeclarationSymbol(symbol) { + if (symbol.flags & 418) { + var links = getSymbolLinks(symbol); + if (links.isNestedRedeclaration === undefined) { + var container = ts.getEnclosingBlockScopeContainer(symbol.valueDeclaration); + links.isNestedRedeclaration = isStatementWithLocals(container) && + !!resolveName(container.parent, symbol.name, 107455, undefined, undefined); + } + return links.isNestedRedeclaration; + } + return false; + } + function getReferencedNestedRedeclaration(node) { + var symbol = getReferencedValueSymbol(node); + return symbol && isNestedRedeclarationSymbol(symbol) ? symbol.valueDeclaration : undefined; + } + function isNestedRedeclaration(node) { + return isNestedRedeclarationSymbol(getSymbolOfNode(node)); + } + function isValueAliasDeclaration(node) { + switch (node.kind) { + case 221: + case 223: + case 224: + case 226: + case 230: + return isAliasResolvedToValue(getSymbolOfNode(node)); + case 228: + var exportClause = node.exportClause; + return exportClause && ts.forEach(exportClause.elements, isValueAliasDeclaration); + case 227: + return node.expression && node.expression.kind === 69 ? isAliasResolvedToValue(getSymbolOfNode(node)) : true; + } + return false; + } + function isTopLevelValueImportEqualsWithEntityName(node) { + if (node.parent.kind !== 248 || !ts.isInternalModuleImportEqualsDeclaration(node)) { + return false; + } + var isValue = isAliasResolvedToValue(getSymbolOfNode(node)); + return isValue && node.moduleReference && !ts.nodeIsMissing(node.moduleReference); + } + function isAliasResolvedToValue(symbol) { + var target = resolveAlias(symbol); + if (target === unknownSymbol && compilerOptions.isolatedModules) { + return true; + } + return target !== unknownSymbol && + target && + target.flags & 107455 && + (compilerOptions.preserveConstEnums || !isConstEnumOrConstEnumOnlyModule(target)); + } + function isConstEnumOrConstEnumOnlyModule(s) { + return isConstEnumSymbol(s) || s.constEnumOnlyModule; + } + function isReferencedAliasDeclaration(node, checkChildren) { + if (ts.isAliasSymbolDeclaration(node)) { + var symbol = getSymbolOfNode(node); + if (getSymbolLinks(symbol).referenced) { + return true; + } + } + if (checkChildren) { + return ts.forEachChild(node, function (node) { return isReferencedAliasDeclaration(node, checkChildren); }); + } + return false; + } + function isImplementationOfOverload(node) { + if (ts.nodeIsPresent(node.body)) { + var symbol = getSymbolOfNode(node); + var signaturesOfSymbol = getSignaturesOfSymbol(symbol); + return signaturesOfSymbol.length > 1 || + (signaturesOfSymbol.length === 1 && signaturesOfSymbol[0].declaration !== node); + } + return false; + } + function getNodeCheckFlags(node) { + return getNodeLinks(node).flags; + } + function getEnumMemberValue(node) { + computeEnumMemberValues(node.parent); + return getNodeLinks(node).enumMemberValue; + } + function getConstantValue(node) { + if (node.kind === 247) { + return getEnumMemberValue(node); + } + var symbol = getNodeLinks(node).resolvedSymbol; + if (symbol && (symbol.flags & 8)) { + if (ts.isConstEnumDeclaration(symbol.valueDeclaration.parent)) { + return getEnumMemberValue(symbol.valueDeclaration); + } + } + return undefined; + } + function isFunctionType(type) { + return type.flags & 80896 && getSignaturesOfType(type, 0).length > 0; + } + function getTypeReferenceSerializationKind(typeName) { + var valueSymbol = resolveEntityName(typeName, 107455, true); + var constructorType = valueSymbol ? getTypeOfSymbol(valueSymbol) : undefined; + if (constructorType && isConstructorType(constructorType)) { + return ts.TypeReferenceSerializationKind.TypeWithConstructSignatureAndValue; + } + var typeSymbol = resolveEntityName(typeName, 793056, true); + if (!typeSymbol) { + return ts.TypeReferenceSerializationKind.ObjectType; + } + var type = getDeclaredTypeOfSymbol(typeSymbol); + if (type === unknownType) { + return ts.TypeReferenceSerializationKind.Unknown; + } + else if (type.flags & 1) { + return ts.TypeReferenceSerializationKind.ObjectType; + } + else if (allConstituentTypesHaveKind(type, 16)) { + return ts.TypeReferenceSerializationKind.VoidType; + } + else if (allConstituentTypesHaveKind(type, 8)) { + return ts.TypeReferenceSerializationKind.BooleanType; + } + else if (allConstituentTypesHaveKind(type, 132)) { + return ts.TypeReferenceSerializationKind.NumberLikeType; + } + else if (allConstituentTypesHaveKind(type, 258)) { + return ts.TypeReferenceSerializationKind.StringLikeType; + } + else if (allConstituentTypesHaveKind(type, 8192)) { + return ts.TypeReferenceSerializationKind.ArrayLikeType; + } + else if (allConstituentTypesHaveKind(type, 16777216)) { + return ts.TypeReferenceSerializationKind.ESSymbolType; + } + else if (isFunctionType(type)) { + return ts.TypeReferenceSerializationKind.TypeWithCallSignature; + } + else if (isArrayType(type)) { + return ts.TypeReferenceSerializationKind.ArrayLikeType; + } + else { + return ts.TypeReferenceSerializationKind.ObjectType; + } + } + function writeTypeOfDeclaration(declaration, enclosingDeclaration, flags, writer) { + var symbol = getSymbolOfNode(declaration); + var type = symbol && !(symbol.flags & (2048 | 131072)) + ? getTypeOfSymbol(symbol) + : unknownType; + getSymbolDisplayBuilder().buildTypeDisplay(type, writer, enclosingDeclaration, flags); + } + function writeReturnTypeOfSignatureDeclaration(signatureDeclaration, enclosingDeclaration, flags, writer) { + var signature = getSignatureFromDeclaration(signatureDeclaration); + getSymbolDisplayBuilder().buildTypeDisplay(getReturnTypeOfSignature(signature), writer, enclosingDeclaration, flags); + } + function writeTypeOfExpression(expr, enclosingDeclaration, flags, writer) { + var type = getTypeOfExpression(expr); + getSymbolDisplayBuilder().buildTypeDisplay(type, writer, enclosingDeclaration, flags); + } + function hasGlobalName(name) { + return ts.hasProperty(globals, name); + } + function getReferencedValueSymbol(reference) { + return getNodeLinks(reference).resolvedSymbol || + resolveName(reference, reference.text, 107455 | 1048576 | 8388608, undefined, undefined); + } + function getReferencedValueDeclaration(reference) { + ts.Debug.assert(!ts.nodeIsSynthesized(reference)); + var symbol = getReferencedValueSymbol(reference); + return symbol && getExportSymbolOfValueSymbolIfExported(symbol).valueDeclaration; + } + function instantiateSingleCallFunctionType(functionType, typeArguments) { + if (functionType === unknownType) { + return unknownType; + } + var signature = getSingleCallSignature(functionType); + if (!signature) { + return unknownType; + } + var instantiatedSignature = getSignatureInstantiation(signature, typeArguments); + return getOrCreateTypeFromSignature(instantiatedSignature); + } + function createResolver() { + return { + getReferencedExportContainer: getReferencedExportContainer, + getReferencedImportDeclaration: getReferencedImportDeclaration, + getReferencedNestedRedeclaration: getReferencedNestedRedeclaration, + isNestedRedeclaration: isNestedRedeclaration, + isValueAliasDeclaration: isValueAliasDeclaration, + hasGlobalName: hasGlobalName, + isReferencedAliasDeclaration: isReferencedAliasDeclaration, + getNodeCheckFlags: getNodeCheckFlags, + isTopLevelValueImportEqualsWithEntityName: isTopLevelValueImportEqualsWithEntityName, + isDeclarationVisible: isDeclarationVisible, + isImplementationOfOverload: isImplementationOfOverload, + writeTypeOfDeclaration: writeTypeOfDeclaration, + writeReturnTypeOfSignatureDeclaration: writeReturnTypeOfSignatureDeclaration, + writeTypeOfExpression: writeTypeOfExpression, + isSymbolAccessible: isSymbolAccessible, + isEntityNameVisible: isEntityNameVisible, + getConstantValue: getConstantValue, + collectLinkedAliases: collectLinkedAliases, + getReferencedValueDeclaration: getReferencedValueDeclaration, + getTypeReferenceSerializationKind: getTypeReferenceSerializationKind, + isOptionalParameter: isOptionalParameter, + isArgumentsLocalBinding: isArgumentsLocalBinding + }; + } + function initializeTypeChecker() { + ts.forEach(host.getSourceFiles(), function (file) { + ts.bindSourceFile(file); + }); + ts.forEach(host.getSourceFiles(), function (file) { + if (!ts.isExternalModule(file)) { + mergeSymbolTable(globals, file.locals); + } + }); + getSymbolLinks(undefinedSymbol).type = undefinedType; + getSymbolLinks(argumentsSymbol).type = getGlobalType("IArguments"); + getSymbolLinks(unknownSymbol).type = unknownType; + globals[undefinedSymbol.name] = undefinedSymbol; + globalArrayType = getGlobalType("Array", 1); + globalObjectType = getGlobalType("Object"); + globalFunctionType = getGlobalType("Function"); + globalStringType = getGlobalType("String"); + globalNumberType = getGlobalType("Number"); + globalBooleanType = getGlobalType("Boolean"); + globalRegExpType = getGlobalType("RegExp"); + jsxElementType = getExportedTypeFromNamespace("JSX", JsxNames.Element); + getGlobalClassDecoratorType = ts.memoize(function () { return getGlobalType("ClassDecorator"); }); + getGlobalPropertyDecoratorType = ts.memoize(function () { return getGlobalType("PropertyDecorator"); }); + getGlobalMethodDecoratorType = ts.memoize(function () { return getGlobalType("MethodDecorator"); }); + getGlobalParameterDecoratorType = ts.memoize(function () { return getGlobalType("ParameterDecorator"); }); + getGlobalTypedPropertyDescriptorType = ts.memoize(function () { return getGlobalType("TypedPropertyDescriptor", 1); }); + getGlobalPromiseType = ts.memoize(function () { return getGlobalType("Promise", 1); }); + tryGetGlobalPromiseType = ts.memoize(function () { return getGlobalSymbol("Promise", 793056, undefined) && getGlobalPromiseType(); }); + getGlobalPromiseLikeType = ts.memoize(function () { return getGlobalType("PromiseLike", 1); }); + getInstantiatedGlobalPromiseLikeType = ts.memoize(createInstantiatedPromiseLikeType); + getGlobalPromiseConstructorSymbol = ts.memoize(function () { return getGlobalValueSymbol("Promise"); }); + getGlobalPromiseConstructorLikeType = ts.memoize(function () { return getGlobalType("PromiseConstructorLike"); }); + getGlobalThenableType = ts.memoize(createThenableType); + if (languageVersion >= 2) { + globalTemplateStringsArrayType = getGlobalType("TemplateStringsArray"); + globalESSymbolType = getGlobalType("Symbol"); + globalESSymbolConstructorSymbol = getGlobalValueSymbol("Symbol"); + globalIterableType = getGlobalType("Iterable", 1); + globalIteratorType = getGlobalType("Iterator", 1); + globalIterableIteratorType = getGlobalType("IterableIterator", 1); + } + else { + globalTemplateStringsArrayType = unknownType; + globalESSymbolType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); + globalESSymbolConstructorSymbol = undefined; + globalIterableType = emptyGenericType; + globalIteratorType = emptyGenericType; + globalIterableIteratorType = emptyGenericType; + } + anyArrayType = createArrayType(anyType); + } + function createInstantiatedPromiseLikeType() { + var promiseLikeType = getGlobalPromiseLikeType(); + if (promiseLikeType !== emptyGenericType) { + return createTypeReference(promiseLikeType, [anyType]); + } + return emptyObjectType; + } + function createThenableType() { + var thenPropertySymbol = createSymbol(67108864 | 4, "then"); + getSymbolLinks(thenPropertySymbol).type = globalFunctionType; + var thenableType = createObjectType(65536); + thenableType.properties = [thenPropertySymbol]; + thenableType.members = createSymbolTable(thenableType.properties); + thenableType.callSignatures = []; + thenableType.constructSignatures = []; + return thenableType; + } + function checkGrammarDecorators(node) { + if (!node.decorators) { + return false; + } + if (!ts.nodeCanBeDecorated(node)) { + return grammarErrorOnFirstToken(node, ts.Diagnostics.Decorators_are_not_valid_here); + } + else if (node.kind === 145 || node.kind === 146) { + var accessors = ts.getAllAccessorDeclarations(node.parent.members, node); + if (accessors.firstAccessor.decorators && node === accessors.secondAccessor) { + return grammarErrorOnFirstToken(node, ts.Diagnostics.Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name); + } + } + return false; + } + function checkGrammarModifiers(node) { + switch (node.kind) { + case 145: + case 146: + case 144: + case 141: + case 140: + case 143: + case 142: + case 149: + case 218: + case 222: + case 221: + case 228: + case 227: + case 138: + break; + case 213: + if (node.modifiers && (node.modifiers.length > 1 || node.modifiers[0].kind !== 118) && + node.parent.kind !== 219 && node.parent.kind !== 248) { + return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); + } + break; + case 214: + case 215: + case 193: + case 216: + if (node.modifiers && node.parent.kind !== 219 && node.parent.kind !== 248) { + return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); + } + break; + case 217: + if (node.modifiers && (node.modifiers.length > 1 || node.modifiers[0].kind !== 74) && + node.parent.kind !== 219 && node.parent.kind !== 248) { + return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); + } + break; + default: + return false; + } + if (!node.modifiers) { + return; + } + var lastStatic, lastPrivate, lastProtected, lastDeclare, lastAsync; + var flags = 0; + for (var _i = 0, _a = node.modifiers; _i < _a.length; _i++) { + var modifier = _a[_i]; + switch (modifier.kind) { + case 112: + case 111: + case 110: + var text = void 0; + if (modifier.kind === 112) { + text = "public"; + } + else if (modifier.kind === 111) { + text = "protected"; + lastProtected = modifier; + } + else { + text = "private"; + lastPrivate = modifier; + } + if (flags & 112) { + return grammarErrorOnNode(modifier, ts.Diagnostics.Accessibility_modifier_already_seen); + } + else if (flags & 128) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "static"); + } + else if (flags & 512) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "async"); + } + else if (node.parent.kind === 219 || node.parent.kind === 248) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_element, text); + } + else if (flags & 256) { + if (modifier.kind === 110) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, text, "abstract"); + } + else { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "abstract"); + } + } + flags |= ts.modifierToFlag(modifier.kind); + break; + case 113: + if (flags & 128) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "static"); + } + else if (flags & 512) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "static", "async"); + } + else if (node.parent.kind === 219 || node.parent.kind === 248) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_element, "static"); + } + else if (node.kind === 138) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "static"); + } + else if (flags & 256) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "static", "abstract"); + } + flags |= 128; + lastStatic = modifier; + break; + case 82: + if (flags & 1) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "export"); + } + else if (flags & 2) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "declare"); + } + else if (flags & 256) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "abstract"); + } + else if (flags & 512) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "async"); + } + else if (node.parent.kind === 214) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "export"); + } + else if (node.kind === 138) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "export"); + } + flags |= 1; + break; + case 122: + if (flags & 2) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "declare"); + } + else if (flags & 512) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); + } + else if (node.parent.kind === 214) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "declare"); + } + else if (node.kind === 138) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "declare"); + } + else if (ts.isInAmbientContext(node.parent) && node.parent.kind === 219) { + return grammarErrorOnNode(modifier, ts.Diagnostics.A_declare_modifier_cannot_be_used_in_an_already_ambient_context); + } + flags |= 2; + lastDeclare = modifier; + break; + case 115: + if (flags & 256) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "abstract"); + } + if (node.kind !== 214) { + if (node.kind !== 143) { + return grammarErrorOnNode(modifier, ts.Diagnostics.abstract_modifier_can_only_appear_on_a_class_or_method_declaration); + } + if (!(node.parent.kind === 214 && node.parent.flags & 256)) { + return grammarErrorOnNode(modifier, ts.Diagnostics.Abstract_methods_can_only_appear_within_an_abstract_class); + } + if (flags & 128) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "static", "abstract"); + } + if (flags & 32) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "private", "abstract"); + } + } + flags |= 256; + break; + case 118: + if (flags & 512) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "async"); + } + else if (flags & 2 || ts.isInAmbientContext(node.parent)) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); + } + else if (node.kind === 138) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "async"); + } + flags |= 512; + lastAsync = modifier; + break; + } + } + if (node.kind === 144) { + if (flags & 128) { + return grammarErrorOnNode(lastStatic, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "static"); + } + if (flags & 256) { + return grammarErrorOnNode(lastStatic, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "abstract"); + } + else if (flags & 64) { + return grammarErrorOnNode(lastProtected, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "protected"); + } + else if (flags & 32) { + return grammarErrorOnNode(lastPrivate, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "private"); + } + else if (flags & 512) { + return grammarErrorOnNode(lastAsync, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "async"); + } + return; + } + else if ((node.kind === 222 || node.kind === 221) && flags & 2) { + return grammarErrorOnNode(lastDeclare, ts.Diagnostics.A_0_modifier_cannot_be_used_with_an_import_declaration, "declare"); + } + else if (node.kind === 138 && (flags & 112) && ts.isBindingPattern(node.name)) { + return grammarErrorOnNode(node, ts.Diagnostics.A_parameter_property_may_not_be_a_binding_pattern); + } + if (flags & 512) { + return checkGrammarAsyncModifier(node, lastAsync); + } + } + function checkGrammarAsyncModifier(node, asyncModifier) { + if (languageVersion < 2) { + return grammarErrorOnNode(asyncModifier, ts.Diagnostics.Async_functions_are_only_available_when_targeting_ECMAScript_6_and_higher); + } + switch (node.kind) { + case 143: + case 213: + case 173: + case 174: + if (!node.asteriskToken) { + return false; + } + break; + } + return grammarErrorOnNode(asyncModifier, ts.Diagnostics._0_modifier_cannot_be_used_here, "async"); + } + function checkGrammarForDisallowedTrailingComma(list) { + if (list && list.hasTrailingComma) { + var start = list.end - ",".length; + var end = list.end; + var sourceFile = ts.getSourceFileOfNode(list[0]); + return grammarErrorAtPos(sourceFile, start, end - start, ts.Diagnostics.Trailing_comma_not_allowed); + } + } + function checkGrammarTypeParameterList(node, typeParameters, file) { + if (checkGrammarForDisallowedTrailingComma(typeParameters)) { + return true; + } + if (typeParameters && typeParameters.length === 0) { + var start = typeParameters.pos - "<".length; + var end = ts.skipTrivia(file.text, typeParameters.end) + ">".length; + return grammarErrorAtPos(file, start, end - start, ts.Diagnostics.Type_parameter_list_cannot_be_empty); + } + } + function checkGrammarParameterList(parameters) { + if (checkGrammarForDisallowedTrailingComma(parameters)) { + return true; + } + var seenOptionalParameter = false; + var parameterCount = parameters.length; + for (var i = 0; i < parameterCount; i++) { + var parameter = parameters[i]; + if (parameter.dotDotDotToken) { + if (i !== (parameterCount - 1)) { + return grammarErrorOnNode(parameter.dotDotDotToken, ts.Diagnostics.A_rest_parameter_must_be_last_in_a_parameter_list); + } + if (ts.isBindingPattern(parameter.name)) { + return grammarErrorOnNode(parameter.name, ts.Diagnostics.A_rest_element_cannot_contain_a_binding_pattern); + } + if (parameter.questionToken) { + return grammarErrorOnNode(parameter.questionToken, ts.Diagnostics.A_rest_parameter_cannot_be_optional); + } + if (parameter.initializer) { + return grammarErrorOnNode(parameter.name, ts.Diagnostics.A_rest_parameter_cannot_have_an_initializer); + } + } + else if (parameter.questionToken) { + seenOptionalParameter = true; + if (parameter.initializer) { + return grammarErrorOnNode(parameter.name, ts.Diagnostics.Parameter_cannot_have_question_mark_and_initializer); + } + } + else if (seenOptionalParameter && !parameter.initializer) { + return grammarErrorOnNode(parameter.name, ts.Diagnostics.A_required_parameter_cannot_follow_an_optional_parameter); + } + } + } + function checkGrammarFunctionLikeDeclaration(node) { + var file = ts.getSourceFileOfNode(node); + return checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarTypeParameterList(node, node.typeParameters, file) || + checkGrammarParameterList(node.parameters) || checkGrammarArrowFunction(node, file); + } + function checkGrammarArrowFunction(node, file) { + if (node.kind === 174) { + var arrowFunction = node; + var startLine = ts.getLineAndCharacterOfPosition(file, arrowFunction.equalsGreaterThanToken.pos).line; + var endLine = ts.getLineAndCharacterOfPosition(file, arrowFunction.equalsGreaterThanToken.end).line; + if (startLine !== endLine) { + return grammarErrorOnNode(arrowFunction.equalsGreaterThanToken, ts.Diagnostics.Line_terminator_not_permitted_before_arrow); + } + } + return false; + } + function checkGrammarIndexSignatureParameters(node) { + var parameter = node.parameters[0]; + if (node.parameters.length !== 1) { + if (parameter) { + return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_must_have_exactly_one_parameter); + } + else { + return grammarErrorOnNode(node, ts.Diagnostics.An_index_signature_must_have_exactly_one_parameter); + } + } + if (parameter.dotDotDotToken) { + return grammarErrorOnNode(parameter.dotDotDotToken, ts.Diagnostics.An_index_signature_cannot_have_a_rest_parameter); + } + if (parameter.flags & 2035) { + return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_cannot_have_an_accessibility_modifier); + } + if (parameter.questionToken) { + return grammarErrorOnNode(parameter.questionToken, ts.Diagnostics.An_index_signature_parameter_cannot_have_a_question_mark); + } + if (parameter.initializer) { + return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_cannot_have_an_initializer); + } + if (!parameter.type) { + return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_must_have_a_type_annotation); + } + if (parameter.type.kind !== 130 && parameter.type.kind !== 128) { + return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_type_must_be_string_or_number); + } + if (!node.type) { + return grammarErrorOnNode(node, ts.Diagnostics.An_index_signature_must_have_a_type_annotation); + } + } + function checkGrammarForIndexSignatureModifier(node) { + if (node.flags & 2035) { + grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_not_permitted_on_index_signature_members); + } + } + function checkGrammarIndexSignature(node) { + return checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarIndexSignatureParameters(node) || checkGrammarForIndexSignatureModifier(node); + } + function checkGrammarForAtLeastOneTypeArgument(node, typeArguments) { + if (typeArguments && typeArguments.length === 0) { + var sourceFile = ts.getSourceFileOfNode(node); + var start = typeArguments.pos - "<".length; + var end = ts.skipTrivia(sourceFile.text, typeArguments.end) + ">".length; + return grammarErrorAtPos(sourceFile, start, end - start, ts.Diagnostics.Type_argument_list_cannot_be_empty); + } + } + function checkGrammarTypeArguments(node, typeArguments) { + return checkGrammarForDisallowedTrailingComma(typeArguments) || + checkGrammarForAtLeastOneTypeArgument(node, typeArguments); + } + function checkGrammarForOmittedArgument(node, args) { + if (args) { + var sourceFile = ts.getSourceFileOfNode(node); + for (var _i = 0; _i < args.length; _i++) { + var arg = args[_i]; + if (arg.kind === 187) { + return grammarErrorAtPos(sourceFile, arg.pos, 0, ts.Diagnostics.Argument_expression_expected); + } + } + } + } + function checkGrammarArguments(node, args) { + return checkGrammarForDisallowedTrailingComma(args) || + checkGrammarForOmittedArgument(node, args); + } + function checkGrammarHeritageClause(node) { + var types = node.types; + if (checkGrammarForDisallowedTrailingComma(types)) { + return true; + } + if (types && types.length === 0) { + var listType = ts.tokenToString(node.token); + var sourceFile = ts.getSourceFileOfNode(node); + return grammarErrorAtPos(sourceFile, types.pos, 0, ts.Diagnostics._0_list_cannot_be_empty, listType); + } + } + function checkGrammarClassDeclarationHeritageClauses(node) { + var seenExtendsClause = false; + var seenImplementsClause = false; + 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 (seenExtendsClause) { + return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_already_seen); + } + if (seenImplementsClause) { + return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_must_precede_implements_clause); + } + if (heritageClause.types.length > 1) { + return grammarErrorOnFirstToken(heritageClause.types[1], ts.Diagnostics.Classes_can_only_extend_a_single_class); + } + seenExtendsClause = true; + } + else { + ts.Debug.assert(heritageClause.token === 106); + if (seenImplementsClause) { + return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.implements_clause_already_seen); + } + seenImplementsClause = true; + } + checkGrammarHeritageClause(heritageClause); + } + } + } + function checkGrammarInterfaceDeclaration(node) { + var seenExtendsClause = false; + if (node.heritageClauses) { + for (var _i = 0, _a = node.heritageClauses; _i < _a.length; _i++) { + var heritageClause = _a[_i]; + if (heritageClause.token === 83) { + if (seenExtendsClause) { + return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_already_seen); + } + seenExtendsClause = true; + } + else { + ts.Debug.assert(heritageClause.token === 106); + return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.Interface_declaration_cannot_have_implements_clause); + } + checkGrammarHeritageClause(heritageClause); + } + } + return false; + } + function checkGrammarComputedPropertyName(node) { + if (node.kind !== 136) { + return false; + } + var computedPropertyName = node; + if (computedPropertyName.expression.kind === 181 && computedPropertyName.expression.operatorToken.kind === 24) { + return grammarErrorOnNode(computedPropertyName.expression, ts.Diagnostics.A_comma_expression_is_not_allowed_in_a_computed_property_name); + } + } + function checkGrammarForGenerator(node) { + if (node.asteriskToken) { + ts.Debug.assert(node.kind === 213 || + node.kind === 173 || + node.kind === 143); + if (ts.isInAmbientContext(node)) { + return grammarErrorOnNode(node.asteriskToken, ts.Diagnostics.Generators_are_not_allowed_in_an_ambient_context); + } + if (!node.body) { + return grammarErrorOnNode(node.asteriskToken, ts.Diagnostics.An_overload_signature_cannot_be_declared_as_a_generator); + } + if (languageVersion < 2) { + return grammarErrorOnNode(node.asteriskToken, ts.Diagnostics.Generators_are_only_available_when_targeting_ECMAScript_6_or_higher); + } + } + } + function checkGrammarForInvalidQuestionMark(node, questionToken, message) { + if (questionToken) { + return grammarErrorOnNode(questionToken, message); + } + } + function checkGrammarObjectLiteralExpression(node, inDestructuring) { + var seen = {}; + var Property = 1; + var GetAccessor = 2; + var SetAccesor = 4; + var GetOrSetAccessor = GetAccessor | SetAccesor; + for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { + var prop = _a[_i]; + var name_16 = prop.name; + if (prop.kind === 187 || + name_16.kind === 136) { + checkGrammarComputedPropertyName(name_16); + continue; + } + if (prop.kind === 246 && !inDestructuring && prop.objectAssignmentInitializer) { + return grammarErrorOnNode(prop.equalsToken, ts.Diagnostics.can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment); + } + var currentKind = void 0; + if (prop.kind === 245 || prop.kind === 246) { + checkGrammarForInvalidQuestionMark(prop, prop.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional); + if (name_16.kind === 8) { + checkGrammarNumericLiteral(name_16); + } + currentKind = Property; + } + else if (prop.kind === 143) { + currentKind = Property; + } + else if (prop.kind === 145) { + currentKind = GetAccessor; + } + else if (prop.kind === 146) { + currentKind = SetAccesor; + } + else { + ts.Debug.fail("Unexpected syntax kind:" + prop.kind); + } + if (!ts.hasProperty(seen, name_16.text)) { + seen[name_16.text] = currentKind; + } + else { + var existingKind = seen[name_16.text]; + if (currentKind === Property && existingKind === Property) { + continue; + } + else if ((currentKind & GetOrSetAccessor) && (existingKind & GetOrSetAccessor)) { + if (existingKind !== GetOrSetAccessor && currentKind !== existingKind) { + seen[name_16.text] = currentKind | existingKind; + } + else { + return grammarErrorOnNode(name_16, ts.Diagnostics.An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name); + } + } + else { + return grammarErrorOnNode(name_16, ts.Diagnostics.An_object_literal_cannot_have_property_and_accessor_with_the_same_name); + } + } + } + } + function checkGrammarJsxElement(node) { + var seen = {}; + for (var _i = 0, _a = node.attributes; _i < _a.length; _i++) { + var attr = _a[_i]; + if (attr.kind === 239) { + continue; + } + var jsxAttr = attr; + var name_17 = jsxAttr.name; + if (!ts.hasProperty(seen, name_17.text)) { + seen[name_17.text] = true; + } + else { + return grammarErrorOnNode(name_17, ts.Diagnostics.JSX_elements_cannot_have_multiple_attributes_with_the_same_name); + } + var initializer = jsxAttr.initializer; + if (initializer && initializer.kind === 240 && !initializer.expression) { + return grammarErrorOnNode(jsxAttr.initializer, ts.Diagnostics.JSX_attributes_must_only_be_assigned_a_non_empty_expression); + } + } + } + function checkGrammarForInOrForOfStatement(forInOrOfStatement) { + if (checkGrammarStatementInAmbientContext(forInOrOfStatement)) { + return true; + } + if (forInOrOfStatement.initializer.kind === 212) { + var variableList = forInOrOfStatement.initializer; + if (!checkGrammarVariableDeclarationList(variableList)) { + if (variableList.declarations.length > 1) { + var diagnostic = forInOrOfStatement.kind === 200 + ? ts.Diagnostics.Only_a_single_variable_declaration_is_allowed_in_a_for_in_statement + : ts.Diagnostics.Only_a_single_variable_declaration_is_allowed_in_a_for_of_statement; + return grammarErrorOnFirstToken(variableList.declarations[1], diagnostic); + } + var firstDeclaration = variableList.declarations[0]; + if (firstDeclaration.initializer) { + var diagnostic = forInOrOfStatement.kind === 200 + ? ts.Diagnostics.The_variable_declaration_of_a_for_in_statement_cannot_have_an_initializer + : ts.Diagnostics.The_variable_declaration_of_a_for_of_statement_cannot_have_an_initializer; + return grammarErrorOnNode(firstDeclaration.name, diagnostic); + } + if (firstDeclaration.type) { + var diagnostic = forInOrOfStatement.kind === 200 + ? ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_use_a_type_annotation + : ts.Diagnostics.The_left_hand_side_of_a_for_of_statement_cannot_use_a_type_annotation; + return grammarErrorOnNode(firstDeclaration, diagnostic); + } + } + } + return false; + } + function checkGrammarAccessor(accessor) { + var kind = accessor.kind; + if (languageVersion < 1) { + return grammarErrorOnNode(accessor.name, ts.Diagnostics.Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher); + } + else if (ts.isInAmbientContext(accessor)) { + return grammarErrorOnNode(accessor.name, ts.Diagnostics.An_accessor_cannot_be_declared_in_an_ambient_context); + } + else if (accessor.body === undefined) { + return grammarErrorAtPos(ts.getSourceFileOfNode(accessor), accessor.end - 1, ";".length, ts.Diagnostics._0_expected, "{"); + } + else if (accessor.typeParameters) { + return grammarErrorOnNode(accessor.name, ts.Diagnostics.An_accessor_cannot_have_type_parameters); + } + else if (kind === 145 && accessor.parameters.length) { + return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_get_accessor_cannot_have_parameters); + } + else if (kind === 146) { + if (accessor.type) { + return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_set_accessor_cannot_have_a_return_type_annotation); + } + else if (accessor.parameters.length !== 1) { + return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_set_accessor_must_have_exactly_one_parameter); + } + else { + var parameter = accessor.parameters[0]; + if (parameter.dotDotDotToken) { + return grammarErrorOnNode(parameter.dotDotDotToken, ts.Diagnostics.A_set_accessor_cannot_have_rest_parameter); + } + else if (parameter.flags & 2035) { + return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation); + } + else if (parameter.questionToken) { + return grammarErrorOnNode(parameter.questionToken, ts.Diagnostics.A_set_accessor_cannot_have_an_optional_parameter); + } + else if (parameter.initializer) { + return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_set_accessor_parameter_cannot_have_an_initializer); + } + } + } + } + function checkGrammarForNonSymbolComputedProperty(node, message) { + if (node.kind === 136 && !ts.isWellKnownSymbolSyntactically(node.expression)) { + return grammarErrorOnNode(node, message); + } + } + function checkGrammarMethod(node) { + if (checkGrammarDisallowedModifiersOnObjectLiteralExpressionMethod(node) || + checkGrammarFunctionLikeDeclaration(node) || + checkGrammarForGenerator(node)) { + return true; + } + if (node.parent.kind === 165) { + if (checkGrammarForInvalidQuestionMark(node, node.questionToken, ts.Diagnostics.A_class_member_cannot_be_declared_optional)) { + return true; + } + else if (node.body === undefined) { + return grammarErrorAtPos(getSourceFile(node), node.end - 1, ";".length, ts.Diagnostics._0_expected, "{"); + } + } + if (ts.isClassLike(node.parent)) { + if (checkGrammarForInvalidQuestionMark(node, node.questionToken, ts.Diagnostics.A_class_member_cannot_be_declared_optional)) { + return true; + } + if (ts.isInAmbientContext(node)) { + return checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_an_ambient_context_must_directly_refer_to_a_built_in_symbol); + } + else if (!node.body) { + 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 === 215) { + return checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_an_interface_must_directly_refer_to_a_built_in_symbol); + } + else if (node.parent.kind === 155) { + return checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_type_literal_must_directly_refer_to_a_built_in_symbol); + } + } + function checkGrammarBreakOrContinueStatement(node) { + var current = node; + while (current) { + if (ts.isFunctionLike(current)) { + return grammarErrorOnNode(node, ts.Diagnostics.Jump_target_cannot_cross_function_boundary); + } + switch (current.kind) { + case 207: + if (node.label && current.label.text === node.label.text) { + var isMisplacedContinueLabel = node.kind === 202 + && !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); + } + return false; + } + break; + case 206: + if (node.kind === 203 && !node.label) { + return false; + } + break; + default: + if (ts.isIterationStatement(current, false) && !node.label) { + return false; + } + break; + } + current = current.parent; + } + if (node.label) { + var message = node.kind === 203 + ? ts.Diagnostics.A_break_statement_can_only_jump_to_a_label_of_an_enclosing_statement + : ts.Diagnostics.A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement; + return grammarErrorOnNode(node, message); + } + else { + var message = node.kind === 203 + ? ts.Diagnostics.A_break_statement_can_only_be_used_within_an_enclosing_iteration_or_switch_statement + : ts.Diagnostics.A_continue_statement_can_only_be_used_within_an_enclosing_iteration_statement; + return grammarErrorOnNode(node, message); + } + } + function checkGrammarBindingElement(node) { + if (node.dotDotDotToken) { + var elements = node.parent.elements; + 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 === 162 || node.name.kind === 161) { + return grammarErrorOnNode(node.name, ts.Diagnostics.A_rest_element_cannot_contain_a_binding_pattern); + } + if (node.initializer) { + return grammarErrorAtPos(ts.getSourceFileOfNode(node), node.initializer.pos - 1, 1, ts.Diagnostics.A_rest_element_cannot_have_an_initializer); + } + } + } + function checkGrammarVariableDeclaration(node) { + if (node.parent.parent.kind !== 200 && node.parent.parent.kind !== 201) { + if (ts.isInAmbientContext(node)) { + if (node.initializer) { + var equalsTokenLength = "=".length; + return grammarErrorAtPos(ts.getSourceFileOfNode(node), node.initializer.pos - equalsTokenLength, equalsTokenLength, ts.Diagnostics.Initializers_are_not_allowed_in_ambient_contexts); + } + } + else if (!node.initializer) { + if (ts.isBindingPattern(node.name) && !ts.isBindingPattern(node.parent)) { + return grammarErrorOnNode(node, ts.Diagnostics.A_destructuring_declaration_must_have_an_initializer); + } + if (ts.isConst(node)) { + return grammarErrorOnNode(node, ts.Diagnostics.const_declarations_must_be_initialized); + } + } + } + var checkLetConstNames = languageVersion >= 2 && (ts.isLet(node) || ts.isConst(node)); + return checkLetConstNames && checkGrammarNameInLetOrConstDeclarations(node.name); + } + function checkGrammarNameInLetOrConstDeclarations(name) { + if (name.kind === 69) { + if (name.text === "let") { + return grammarErrorOnNode(name, ts.Diagnostics.let_is_not_allowed_to_be_used_as_a_name_in_let_or_const_declarations); + } + } + else { + var elements = name.elements; + for (var _i = 0; _i < elements.length; _i++) { + var element = elements[_i]; + if (element.kind !== 187) { + checkGrammarNameInLetOrConstDeclarations(element.name); + } + } + } + } + function checkGrammarVariableDeclarationList(declarationList) { + var declarations = declarationList.declarations; + if (checkGrammarForDisallowedTrailingComma(declarationList.declarations)) { + return true; + } + if (!declarationList.declarations.length) { + return grammarErrorAtPos(ts.getSourceFileOfNode(declarationList), declarations.pos, declarations.end - declarations.pos, ts.Diagnostics.Variable_declaration_list_cannot_be_empty); + } + } + function allowLetAndConstDeclarations(parent) { + switch (parent.kind) { + case 196: + case 197: + case 198: + case 205: + case 199: + case 200: + case 201: + return false; + case 207: + return allowLetAndConstDeclarations(parent.parent); + } + return true; + } + function checkGrammarForDisallowedLetOrConstStatement(node) { + if (!allowLetAndConstDeclarations(node.parent)) { + if (ts.isLet(node.declarationList)) { + return grammarErrorOnNode(node, ts.Diagnostics.let_declarations_can_only_be_declared_inside_a_block); + } + else if (ts.isConst(node.declarationList)) { + return grammarErrorOnNode(node, ts.Diagnostics.const_declarations_can_only_be_declared_inside_a_block); + } + } + } + function isIntegerLiteral(expression) { + if (expression.kind === 179) { + var unaryExpression = expression; + if (unaryExpression.operator === 35 || unaryExpression.operator === 36) { + expression = unaryExpression.operand; + } + } + if (expression.kind === 8) { + return /^[0-9]+([eE]\+?[0-9]+)?$/.test(expression.text); + } + return false; + } + function hasParseDiagnostics(sourceFile) { + return sourceFile.parseDiagnostics.length > 0; + } + function grammarErrorOnFirstToken(node, message, arg0, arg1, arg2) { + var sourceFile = ts.getSourceFileOfNode(node); + if (!hasParseDiagnostics(sourceFile)) { + var span = ts.getSpanOfTokenAtPosition(sourceFile, node.pos); + diagnostics.add(ts.createFileDiagnostic(sourceFile, span.start, span.length, message, arg0, arg1, arg2)); + return true; + } + } + function grammarErrorAtPos(sourceFile, start, length, message, arg0, arg1, arg2) { + if (!hasParseDiagnostics(sourceFile)) { + diagnostics.add(ts.createFileDiagnostic(sourceFile, start, length, message, arg0, arg1, arg2)); + return true; + } + } + function grammarErrorOnNode(node, message, arg0, arg1, arg2) { + var sourceFile = ts.getSourceFileOfNode(node); + if (!hasParseDiagnostics(sourceFile)) { + diagnostics.add(ts.createDiagnosticForNode(node, message, arg0, arg1, arg2)); + return true; + } + } + function isEvalOrArgumentsIdentifier(node) { + return node.kind === 69 && + (node.text === "eval" || node.text === "arguments"); + } + function checkGrammarConstructorTypeParameters(node) { + if (node.typeParameters) { + return grammarErrorAtPos(ts.getSourceFileOfNode(node), node.typeParameters.pos, node.typeParameters.end - node.typeParameters.pos, ts.Diagnostics.Type_parameters_cannot_appear_on_a_constructor_declaration); + } + } + function checkGrammarConstructorTypeAnnotation(node) { + if (node.type) { + return grammarErrorOnNode(node.type, ts.Diagnostics.Type_annotation_cannot_appear_on_a_constructor_declaration); + } + } + function checkGrammarProperty(node) { + if (ts.isClassLike(node.parent)) { + if (checkGrammarForInvalidQuestionMark(node, node.questionToken, ts.Diagnostics.A_class_member_cannot_be_declared_optional) || + checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_class_property_declaration_must_directly_refer_to_a_built_in_symbol)) { + return true; + } + } + else if (node.parent.kind === 215) { + if (checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_an_interface_must_directly_refer_to_a_built_in_symbol)) { + return true; + } + } + else if (node.parent.kind === 155) { + if (checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_type_literal_must_directly_refer_to_a_built_in_symbol)) { + return true; + } + } + if (ts.isInAmbientContext(node) && node.initializer) { + return grammarErrorOnFirstToken(node.initializer, ts.Diagnostics.Initializers_are_not_allowed_in_ambient_contexts); + } + } + function checkGrammarTopLevelElementForRequiredDeclareModifier(node) { + if (node.kind === 215 || + node.kind === 216 || + node.kind === 222 || + node.kind === 221 || + node.kind === 228 || + node.kind === 227 || + (node.flags & 2) || + (node.flags & (1 | 1024))) { + return false; + } + return grammarErrorOnFirstToken(node, ts.Diagnostics.A_declare_modifier_is_required_for_a_top_level_declaration_in_a_d_ts_file); + } + function checkGrammarTopLevelElementsForRequiredDeclareModifier(file) { + for (var _i = 0, _a = file.statements; _i < _a.length; _i++) { + var decl = _a[_i]; + if (ts.isDeclaration(decl) || decl.kind === 193) { + if (checkGrammarTopLevelElementForRequiredDeclareModifier(decl)) { + return true; + } + } + } + } + function checkGrammarSourceFile(node) { + return ts.isInAmbientContext(node) && checkGrammarTopLevelElementsForRequiredDeclareModifier(node); + } + function checkGrammarStatementInAmbientContext(node) { + if (ts.isInAmbientContext(node)) { + if (isAccessor(node.parent.kind)) { + return getNodeLinks(node).hasReportedStatementInAmbientContext = true; + } + var links = getNodeLinks(node); + 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 === 192 || node.parent.kind === 219 || node.parent.kind === 248) { + var links_1 = getNodeLinks(node.parent); + if (!links_1.hasReportedStatementInAmbientContext) { + return links_1.hasReportedStatementInAmbientContext = grammarErrorOnFirstToken(node, ts.Diagnostics.Statements_are_not_allowed_in_ambient_contexts); + } + } + else { + } + } + } + function checkGrammarNumericLiteral(node) { + if (node.flags & 65536 && languageVersion >= 1) { + return grammarErrorOnNode(node, ts.Diagnostics.Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher); + } + } + function grammarErrorAfterFirstToken(node, message, arg0, arg1, arg2) { + var sourceFile = ts.getSourceFileOfNode(node); + if (!hasParseDiagnostics(sourceFile)) { + var span = ts.getSpanOfTokenAtPosition(sourceFile, node.pos); + diagnostics.add(ts.createFileDiagnostic(sourceFile, ts.textSpanEnd(span), 0, message, arg0, arg1, arg2)); + return true; + } + } + } + ts.createTypeChecker = createTypeChecker; +})(ts || (ts = {})); +var ts; +(function (ts) { + function getDeclarationDiagnostics(host, resolver, targetSourceFile) { + var diagnostics = []; + var jsFilePath = ts.getOwnEmitOutputFilePath(targetSourceFile, host, ".js"); + emitDeclarations(host, resolver, diagnostics, jsFilePath, targetSourceFile); + return diagnostics; + } + ts.getDeclarationDiagnostics = getDeclarationDiagnostics; + function emitDeclarations(host, resolver, diagnostics, jsFilePath, root) { + var newLine = host.getNewLine(); + var compilerOptions = host.getCompilerOptions(); + var write; + var writeLine; + var increaseIndent; + var decreaseIndent; + var writeTextOfNode; + var writer = createAndSetNewTextWriterWithSymbolWriter(); + var enclosingDeclaration; + var currentSourceFile; + var reportedDeclarationError = false; + var errorNameNode; + var emitJsDocComments = compilerOptions.removeComments ? function (declaration) { } : writeJsDocComments; + var emit = compilerOptions.stripInternal ? stripInternal : emitNode; + var moduleElementDeclarationEmitInfo = []; + var asynchronousSubModuleDeclarationEmitInfo; + var referencePathsOutput = ""; + if (root) { + if (!compilerOptions.noResolve) { + var addedGlobalFileReference = false; + ts.forEach(root.referencedFiles, function (fileReference) { + var referencedFile = ts.tryResolveScriptReference(host, root, fileReference); + if (referencedFile && ((referencedFile.flags & 8192) || + ts.shouldEmitToOwnFile(referencedFile, compilerOptions) || + !addedGlobalFileReference)) { + writeReferencePath(referencedFile); + if (!ts.isExternalModuleOrDeclarationFile(referencedFile)) { + addedGlobalFileReference = true; + } + } + }); + } + emitSourceFile(root); + if (moduleElementDeclarationEmitInfo.length) { + var oldWriter = writer; + ts.forEach(moduleElementDeclarationEmitInfo, function (aliasEmitInfo) { + if (aliasEmitInfo.isVisible) { + ts.Debug.assert(aliasEmitInfo.node.kind === 222); + createAndSetNewTextWriterWithSymbolWriter(); + ts.Debug.assert(aliasEmitInfo.indent === 0); + writeImportDeclaration(aliasEmitInfo.node); + aliasEmitInfo.asynchronousOutput = writer.getText(); + } + }); + setWriter(oldWriter); + } + } + else { + var emittedReferencedFiles = []; + ts.forEach(host.getSourceFiles(), function (sourceFile) { + if (!ts.isExternalModuleOrDeclarationFile(sourceFile)) { + if (!compilerOptions.noResolve) { + ts.forEach(sourceFile.referencedFiles, function (fileReference) { + var referencedFile = ts.tryResolveScriptReference(host, sourceFile, fileReference); + if (referencedFile && (ts.isExternalModuleOrDeclarationFile(referencedFile) && + !ts.contains(emittedReferencedFiles, referencedFile))) { + writeReferencePath(referencedFile); + emittedReferencedFiles.push(referencedFile); + } + }); + } + emitSourceFile(sourceFile); + } + }); + } + return { + reportedDeclarationError: reportedDeclarationError, + moduleElementDeclarationEmitInfo: moduleElementDeclarationEmitInfo, + synchronousDeclarationOutput: writer.getText(), + referencePathsOutput: referencePathsOutput + }; + function hasInternalAnnotation(range) { + var text = currentSourceFile.text; + var comment = text.substring(range.pos, range.end); + return comment.indexOf("@internal") >= 0; + } + function stripInternal(node) { + if (node) { + var leadingCommentRanges = ts.getLeadingCommentRanges(currentSourceFile.text, node.pos); + if (ts.forEach(leadingCommentRanges, hasInternalAnnotation)) { + return; + } + emitNode(node); + } + } + function createAndSetNewTextWriterWithSymbolWriter() { + var writer = ts.createTextWriter(newLine); + writer.trackSymbol = trackSymbol; + writer.reportInaccessibleThisError = reportInaccessibleThisError; + writer.writeKeyword = writer.write; + writer.writeOperator = writer.write; + writer.writePunctuation = writer.write; + writer.writeSpace = writer.write; + writer.writeStringLiteral = writer.writeLiteral; + writer.writeParameter = writer.write; + writer.writeSymbol = writer.write; + setWriter(writer); + return writer; + } + function setWriter(newWriter) { + writer = newWriter; + write = newWriter.write; + writeTextOfNode = newWriter.writeTextOfNode; + writeLine = newWriter.writeLine; + increaseIndent = newWriter.increaseIndent; + decreaseIndent = newWriter.decreaseIndent; + } + function writeAsynchronousModuleElements(nodes) { + var oldWriter = writer; + ts.forEach(nodes, function (declaration) { + var nodeToCheck; + if (declaration.kind === 211) { + nodeToCheck = declaration.parent.parent; + } + else if (declaration.kind === 225 || declaration.kind === 226 || declaration.kind === 223) { + ts.Debug.fail("We should be getting ImportDeclaration instead to write"); + } + else { + nodeToCheck = declaration; + } + var moduleElementEmitInfo = ts.forEach(moduleElementDeclarationEmitInfo, function (declEmitInfo) { return declEmitInfo.node === nodeToCheck ? declEmitInfo : undefined; }); + if (!moduleElementEmitInfo && asynchronousSubModuleDeclarationEmitInfo) { + moduleElementEmitInfo = ts.forEach(asynchronousSubModuleDeclarationEmitInfo, function (declEmitInfo) { return declEmitInfo.node === nodeToCheck ? declEmitInfo : undefined; }); + } + if (moduleElementEmitInfo) { + if (moduleElementEmitInfo.node.kind === 222) { + moduleElementEmitInfo.isVisible = true; + } + else { + createAndSetNewTextWriterWithSymbolWriter(); + for (var declarationIndent = moduleElementEmitInfo.indent; declarationIndent; declarationIndent--) { + increaseIndent(); + } + if (nodeToCheck.kind === 218) { + ts.Debug.assert(asynchronousSubModuleDeclarationEmitInfo === undefined); + asynchronousSubModuleDeclarationEmitInfo = []; + } + writeModuleElement(nodeToCheck); + if (nodeToCheck.kind === 218) { + moduleElementEmitInfo.subModuleElementDeclarationEmitInfo = asynchronousSubModuleDeclarationEmitInfo; + asynchronousSubModuleDeclarationEmitInfo = undefined; + } + moduleElementEmitInfo.asynchronousOutput = writer.getText(); + } + } + }); + setWriter(oldWriter); + } + function handleSymbolAccessibilityError(symbolAccesibilityResult) { + if (symbolAccesibilityResult.accessibility === 0) { + if (symbolAccesibilityResult && symbolAccesibilityResult.aliasesToMakeVisible) { + writeAsynchronousModuleElements(symbolAccesibilityResult.aliasesToMakeVisible); + } + } + else { + reportedDeclarationError = true; + var errorInfo = writer.getSymbolAccessibilityDiagnostic(symbolAccesibilityResult); + if (errorInfo) { + if (errorInfo.typeName) { + diagnostics.push(ts.createDiagnosticForNode(symbolAccesibilityResult.errorNode || errorInfo.errorNode, errorInfo.diagnosticMessage, ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, errorInfo.typeName), symbolAccesibilityResult.errorSymbolName, symbolAccesibilityResult.errorModuleName)); + } + else { + diagnostics.push(ts.createDiagnosticForNode(symbolAccesibilityResult.errorNode || errorInfo.errorNode, errorInfo.diagnosticMessage, symbolAccesibilityResult.errorSymbolName, symbolAccesibilityResult.errorModuleName)); + } + } + } + } + function trackSymbol(symbol, enclosingDeclaration, meaning) { + handleSymbolAccessibilityError(resolver.isSymbolAccessible(symbol, enclosingDeclaration, meaning)); + } + function reportInaccessibleThisError() { + if (errorNameNode) { + diagnostics.push(ts.createDiagnosticForNode(errorNameNode, ts.Diagnostics.The_inferred_type_of_0_references_an_inaccessible_this_type_A_type_annotation_is_necessary, ts.declarationNameToString(errorNameNode))); + } + } + function writeTypeOfDeclaration(declaration, type, getSymbolAccessibilityDiagnostic) { + writer.getSymbolAccessibilityDiagnostic = getSymbolAccessibilityDiagnostic; + write(": "); + if (type) { + emitType(type); + } + else { + errorNameNode = declaration.name; + resolver.writeTypeOfDeclaration(declaration, enclosingDeclaration, 2, writer); + errorNameNode = undefined; + } + } + function writeReturnTypeAtSignature(signature, getSymbolAccessibilityDiagnostic) { + writer.getSymbolAccessibilityDiagnostic = getSymbolAccessibilityDiagnostic; + write(": "); + if (signature.type) { + emitType(signature.type); + } + else { + errorNameNode = signature.name; + resolver.writeReturnTypeOfSignatureDeclaration(signature, enclosingDeclaration, 2, writer); + errorNameNode = undefined; + } + } + function emitLines(nodes) { + for (var _i = 0; _i < nodes.length; _i++) { + var node = nodes[_i]; + emit(node); + } + } + function emitSeparatedList(nodes, separator, eachNodeEmitFn, canEmitFn) { + var currentWriterPos = writer.getTextPos(); + for (var _i = 0; _i < nodes.length; _i++) { + var node = nodes[_i]; + if (!canEmitFn || canEmitFn(node)) { + if (currentWriterPos !== writer.getTextPos()) { + write(separator); + } + currentWriterPos = writer.getTextPos(); + eachNodeEmitFn(node); + } + } + } + function emitCommaList(nodes, eachNodeEmitFn, canEmitFn) { + emitSeparatedList(nodes, ", ", eachNodeEmitFn, canEmitFn); + } + function writeJsDocComments(declaration) { + if (declaration) { + var jsDocComments = ts.getJsDocComments(declaration, currentSourceFile); + ts.emitNewLineBeforeLeadingComments(currentSourceFile, writer, declaration, jsDocComments); + ts.emitComments(currentSourceFile, writer, jsDocComments, true, newLine, ts.writeCommentRange); + } + } + function emitTypeWithNewGetSymbolAccessibilityDiagnostic(type, getSymbolAccessibilityDiagnostic) { + writer.getSymbolAccessibilityDiagnostic = getSymbolAccessibilityDiagnostic; + emitType(type); + } + function emitType(type) { + switch (type.kind) { + case 117: + case 130: + case 128: + case 120: + case 131: + case 103: + case 97: + case 9: + return writeTextOfNode(currentSourceFile, type); + case 188: + return emitExpressionWithTypeArguments(type); + case 151: + return emitTypeReference(type); + case 154: + return emitTypeQuery(type); + case 156: + return emitArrayType(type); + case 157: + return emitTupleType(type); + case 158: + return emitUnionType(type); + case 159: + return emitIntersectionType(type); + case 160: + return emitParenType(type); + case 152: + case 153: + return emitSignatureDeclarationWithJsDocComments(type); + case 155: + return emitTypeLiteral(type); + case 69: + return emitEntityName(type); + case 135: + return emitEntityName(type); + case 150: + return emitTypePredicate(type); + } + function writeEntityName(entityName) { + if (entityName.kind === 69) { + writeTextOfNode(currentSourceFile, entityName); + } + else { + var left = entityName.kind === 135 ? entityName.left : entityName.expression; + var right = entityName.kind === 135 ? entityName.right : entityName.name; + writeEntityName(left); + write("."); + writeTextOfNode(currentSourceFile, right); + } + } + function emitEntityName(entityName) { + var visibilityResult = resolver.isEntityNameVisible(entityName, entityName.parent.kind === 221 ? entityName.parent : enclosingDeclaration); + handleSymbolAccessibilityError(visibilityResult); + writeEntityName(entityName); + } + function emitExpressionWithTypeArguments(node) { + if (ts.isSupportedExpressionWithTypeArguments(node)) { + ts.Debug.assert(node.expression.kind === 69 || node.expression.kind === 166); + emitEntityName(node.expression); + if (node.typeArguments) { + write("<"); + emitCommaList(node.typeArguments, emitType); + write(">"); + } + } + } + function emitTypeReference(type) { + emitEntityName(type.typeName); + if (type.typeArguments) { + write("<"); + emitCommaList(type.typeArguments, emitType); + write(">"); + } + } + function emitTypePredicate(type) { + writeTextOfNode(currentSourceFile, type.parameterName); + write(" is "); + emitType(type.type); + } + function emitTypeQuery(type) { + write("typeof "); + emitEntityName(type.exprName); + } + function emitArrayType(type) { + emitType(type.elementType); + write("[]"); + } + function emitTupleType(type) { + write("["); + emitCommaList(type.elementTypes, emitType); + write("]"); + } + function emitUnionType(type) { + emitSeparatedList(type.types, " | ", emitType); + } + function emitIntersectionType(type) { + emitSeparatedList(type.types, " & ", emitType); + } + function emitParenType(type) { + write("("); + emitType(type.type); + write(")"); + } + function emitTypeLiteral(type) { + write("{"); + if (type.members.length) { + writeLine(); + increaseIndent(); + emitLines(type.members); + decreaseIndent(); + } + write("}"); + } + } + function emitSourceFile(node) { + currentSourceFile = node; + enclosingDeclaration = node; + emitLines(node.statements); + } + function getExportDefaultTempVariableName() { + var baseName = "_default"; + if (!ts.hasProperty(currentSourceFile.identifiers, baseName)) { + return baseName; + } + var count = 0; + while (true) { + var name_18 = baseName + "_" + (++count); + if (!ts.hasProperty(currentSourceFile.identifiers, name_18)) { + return name_18; + } + } + } + function emitExportAssignment(node) { + if (node.expression.kind === 69) { + write(node.isExportEquals ? "export = " : "export default "); + writeTextOfNode(currentSourceFile, node.expression); + } + else { + var tempVarName = getExportDefaultTempVariableName(); + write("declare var "); + write(tempVarName); + write(": "); + writer.getSymbolAccessibilityDiagnostic = getDefaultExportAccessibilityDiagnostic; + resolver.writeTypeOfExpression(node.expression, enclosingDeclaration, 2, writer); + write(";"); + writeLine(); + write(node.isExportEquals ? "export = " : "export default "); + write(tempVarName); + } + write(";"); + writeLine(); + if (node.expression.kind === 69) { + var nodes = resolver.collectLinkedAliases(node.expression); + writeAsynchronousModuleElements(nodes); + } + function getDefaultExportAccessibilityDiagnostic(diagnostic) { + return { + diagnosticMessage: ts.Diagnostics.Default_export_of_the_module_has_or_is_using_private_name_0, + errorNode: node + }; + } + } + function isModuleElementVisible(node) { + return resolver.isDeclarationVisible(node); + } + function emitModuleElement(node, isModuleElementVisible) { + if (isModuleElementVisible) { + writeModuleElement(node); + } + else if (node.kind === 221 || + (node.parent.kind === 248 && ts.isExternalModule(currentSourceFile))) { + var isVisible; + if (asynchronousSubModuleDeclarationEmitInfo && node.parent.kind !== 248) { + asynchronousSubModuleDeclarationEmitInfo.push({ + node: node, + outputPos: writer.getTextPos(), + indent: writer.getIndent(), + isVisible: isVisible + }); + } + else { + if (node.kind === 222) { + var importDeclaration = node; + if (importDeclaration.importClause) { + isVisible = (importDeclaration.importClause.name && resolver.isDeclarationVisible(importDeclaration.importClause)) || + isVisibleNamedBinding(importDeclaration.importClause.namedBindings); + } + } + moduleElementDeclarationEmitInfo.push({ + node: node, + outputPos: writer.getTextPos(), + indent: writer.getIndent(), + isVisible: isVisible + }); + } + } + } + function writeModuleElement(node) { + switch (node.kind) { + case 213: + return writeFunctionDeclaration(node); + case 193: + return writeVariableStatement(node); + case 215: + return writeInterfaceDeclaration(node); + case 214: + return writeClassDeclaration(node); + case 216: + return writeTypeAliasDeclaration(node); + case 217: + return writeEnumDeclaration(node); + case 218: + return writeModuleDeclaration(node); + case 221: + return writeImportEqualsDeclaration(node); + case 222: + return writeImportDeclaration(node); + default: + ts.Debug.fail("Unknown symbol kind"); + } + } + function emitModuleElementDeclarationFlags(node) { + if (node.parent === currentSourceFile) { + if (node.flags & 1) { + write("export "); + } + if (node.flags & 1024) { + write("default "); + } + else if (node.kind !== 215) { + write("declare "); + } + } + } + function emitClassMemberDeclarationFlags(node) { + if (node.flags & 32) { + write("private "); + } + else if (node.flags & 64) { + write("protected "); + } + if (node.flags & 128) { + write("static "); + } + if (node.flags & 256) { + write("abstract "); + } + } + function writeImportEqualsDeclaration(node) { + emitJsDocComments(node); + if (node.flags & 1) { + write("export "); + } + write("import "); + writeTextOfNode(currentSourceFile, node.name); + write(" = "); + if (ts.isInternalModuleImportEqualsDeclaration(node)) { + emitTypeWithNewGetSymbolAccessibilityDiagnostic(node.moduleReference, getImportEntityNameVisibilityError); + write(";"); + } + else { + write("require("); + writeTextOfNode(currentSourceFile, ts.getExternalModuleImportEqualsDeclarationExpression(node)); + write(");"); + } + writer.writeLine(); + function getImportEntityNameVisibilityError(symbolAccesibilityResult) { + return { + diagnosticMessage: ts.Diagnostics.Import_declaration_0_is_using_private_name_1, + errorNode: node, + typeName: node.name + }; + } + } + function isVisibleNamedBinding(namedBindings) { + if (namedBindings) { + if (namedBindings.kind === 224) { + return resolver.isDeclarationVisible(namedBindings); + } + else { + return ts.forEach(namedBindings.elements, function (namedImport) { return resolver.isDeclarationVisible(namedImport); }); + } + } + } + function writeImportDeclaration(node) { + if (!node.importClause && !(node.flags & 1)) { + return; + } + emitJsDocComments(node); + if (node.flags & 1) { + write("export "); + } + write("import "); + if (node.importClause) { + var currentWriterPos = writer.getTextPos(); + if (node.importClause.name && resolver.isDeclarationVisible(node.importClause)) { + writeTextOfNode(currentSourceFile, node.importClause.name); + } + if (node.importClause.namedBindings && isVisibleNamedBinding(node.importClause.namedBindings)) { + if (currentWriterPos !== writer.getTextPos()) { + write(", "); + } + if (node.importClause.namedBindings.kind === 224) { + write("* as "); + writeTextOfNode(currentSourceFile, node.importClause.namedBindings.name); + } + else { + write("{ "); + emitCommaList(node.importClause.namedBindings.elements, emitImportOrExportSpecifier, resolver.isDeclarationVisible); + write(" }"); + } + } + write(" from "); + } + writeTextOfNode(currentSourceFile, node.moduleSpecifier); + write(";"); + writer.writeLine(); + } + function emitImportOrExportSpecifier(node) { + if (node.propertyName) { + writeTextOfNode(currentSourceFile, node.propertyName); + write(" as "); + } + writeTextOfNode(currentSourceFile, node.name); + } + function emitExportSpecifier(node) { + emitImportOrExportSpecifier(node); + var nodes = resolver.collectLinkedAliases(node.propertyName || node.name); + writeAsynchronousModuleElements(nodes); + } + function emitExportDeclaration(node) { + emitJsDocComments(node); + write("export "); + if (node.exportClause) { + write("{ "); + emitCommaList(node.exportClause.elements, emitExportSpecifier); + write(" }"); + } + else { + write("*"); + } + if (node.moduleSpecifier) { + write(" from "); + writeTextOfNode(currentSourceFile, node.moduleSpecifier); + } + write(";"); + writer.writeLine(); + } + function writeModuleDeclaration(node) { + emitJsDocComments(node); + emitModuleElementDeclarationFlags(node); + if (node.flags & 131072) { + write("namespace "); + } + else { + write("module "); + } + writeTextOfNode(currentSourceFile, node.name); + while (node.body.kind !== 219) { + node = node.body; + write("."); + writeTextOfNode(currentSourceFile, node.name); + } + var prevEnclosingDeclaration = enclosingDeclaration; + enclosingDeclaration = node; + write(" {"); + writeLine(); + increaseIndent(); + emitLines(node.body.statements); + decreaseIndent(); + write("}"); + writeLine(); + enclosingDeclaration = prevEnclosingDeclaration; + } + function writeTypeAliasDeclaration(node) { + var prevEnclosingDeclaration = enclosingDeclaration; + enclosingDeclaration = node; + emitJsDocComments(node); + emitModuleElementDeclarationFlags(node); + write("type "); + writeTextOfNode(currentSourceFile, node.name); + emitTypeParameters(node.typeParameters); + write(" = "); + emitTypeWithNewGetSymbolAccessibilityDiagnostic(node.type, getTypeAliasDeclarationVisibilityError); + write(";"); + writeLine(); + enclosingDeclaration = prevEnclosingDeclaration; + function getTypeAliasDeclarationVisibilityError(symbolAccesibilityResult) { + return { + diagnosticMessage: ts.Diagnostics.Exported_type_alias_0_has_or_is_using_private_name_1, + errorNode: node.type, + typeName: node.name + }; + } + } + function writeEnumDeclaration(node) { + emitJsDocComments(node); + emitModuleElementDeclarationFlags(node); + if (ts.isConst(node)) { + write("const "); + } + write("enum "); + writeTextOfNode(currentSourceFile, node.name); + write(" {"); + writeLine(); + increaseIndent(); + emitLines(node.members); + decreaseIndent(); + write("}"); + writeLine(); + } + function emitEnumMemberDeclaration(node) { + emitJsDocComments(node); + writeTextOfNode(currentSourceFile, node.name); + var enumMemberValue = resolver.getConstantValue(node); + if (enumMemberValue !== undefined) { + write(" = "); + write(enumMemberValue.toString()); + } + write(","); + writeLine(); + } + function isPrivateMethodTypeParameter(node) { + return node.parent.kind === 143 && (node.parent.flags & 32); + } + function emitTypeParameters(typeParameters) { + function emitTypeParameter(node) { + increaseIndent(); + emitJsDocComments(node); + decreaseIndent(); + writeTextOfNode(currentSourceFile, node.name); + if (node.constraint && !isPrivateMethodTypeParameter(node)) { + write(" extends "); + if (node.parent.kind === 152 || + node.parent.kind === 153 || + (node.parent.parent && node.parent.parent.kind === 155)) { + ts.Debug.assert(node.parent.kind === 143 || + node.parent.kind === 142 || + node.parent.kind === 152 || + node.parent.kind === 153 || + node.parent.kind === 147 || + node.parent.kind === 148); + emitType(node.constraint); + } + else { + emitTypeWithNewGetSymbolAccessibilityDiagnostic(node.constraint, getTypeParameterConstraintVisibilityError); + } + } + function getTypeParameterConstraintVisibilityError(symbolAccesibilityResult) { + var diagnosticMessage; + switch (node.parent.kind) { + case 214: + diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_class_has_or_is_using_private_name_1; + break; + case 215: + diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1; + break; + case 148: + diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; + break; + case 147: + diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; + break; + case 143: + case 142: + if (node.parent.flags & 128) { + diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1; + } + else if (node.parent.parent.kind === 214) { + diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_public_method_from_exported_class_has_or_is_using_private_name_1; + } + else { + diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1; + } + break; + case 213: + diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_function_has_or_is_using_private_name_1; + break; + default: + ts.Debug.fail("This is unknown parent for type parameter: " + node.parent.kind); + } + return { + diagnosticMessage: diagnosticMessage, + errorNode: node, + typeName: node.name + }; + } + } + if (typeParameters) { + write("<"); + emitCommaList(typeParameters, emitTypeParameter); + write(">"); + } + } + function emitHeritageClause(typeReferences, isImplementsList) { + if (typeReferences) { + write(isImplementsList ? " implements " : " extends "); + emitCommaList(typeReferences, emitTypeOfTypeReference); + } + function emitTypeOfTypeReference(node) { + if (ts.isSupportedExpressionWithTypeArguments(node)) { + emitTypeWithNewGetSymbolAccessibilityDiagnostic(node, getHeritageClauseVisibilityError); + } + else if (!isImplementsList && node.expression.kind === 93) { + write("null"); + } + function getHeritageClauseVisibilityError(symbolAccesibilityResult) { + var diagnosticMessage; + if (node.parent.parent.kind === 214) { + diagnosticMessage = isImplementsList ? + ts.Diagnostics.Implements_clause_of_exported_class_0_has_or_is_using_private_name_1 : + ts.Diagnostics.Extends_clause_of_exported_class_0_has_or_is_using_private_name_1; + } + else { + diagnosticMessage = ts.Diagnostics.Extends_clause_of_exported_interface_0_has_or_is_using_private_name_1; + } + return { + diagnosticMessage: diagnosticMessage, + errorNode: node, + typeName: node.parent.parent.name + }; + } + } + } + function writeClassDeclaration(node) { + function emitParameterProperties(constructorDeclaration) { + if (constructorDeclaration) { + ts.forEach(constructorDeclaration.parameters, function (param) { + if (param.flags & 112) { + emitPropertyDeclaration(param); + } + }); + } + } + emitJsDocComments(node); + emitModuleElementDeclarationFlags(node); + if (node.flags & 256) { + write("abstract "); + } + write("class "); + writeTextOfNode(currentSourceFile, node.name); + var prevEnclosingDeclaration = enclosingDeclaration; + enclosingDeclaration = node; + emitTypeParameters(node.typeParameters); + var baseTypeNode = ts.getClassExtendsHeritageClauseElement(node); + if (baseTypeNode) { + emitHeritageClause([baseTypeNode], false); + } + emitHeritageClause(ts.getClassImplementsHeritageClauseElements(node), true); + write(" {"); + writeLine(); + increaseIndent(); + emitParameterProperties(ts.getFirstConstructorWithBody(node)); + emitLines(node.members); + decreaseIndent(); + write("}"); + writeLine(); + enclosingDeclaration = prevEnclosingDeclaration; + } + function writeInterfaceDeclaration(node) { + emitJsDocComments(node); + emitModuleElementDeclarationFlags(node); + write("interface "); + writeTextOfNode(currentSourceFile, node.name); + var prevEnclosingDeclaration = enclosingDeclaration; + enclosingDeclaration = node; + emitTypeParameters(node.typeParameters); + emitHeritageClause(ts.getInterfaceBaseTypeNodes(node), false); + write(" {"); + writeLine(); + increaseIndent(); + emitLines(node.members); + decreaseIndent(); + write("}"); + writeLine(); + enclosingDeclaration = prevEnclosingDeclaration; + } + function emitPropertyDeclaration(node) { + if (ts.hasDynamicName(node)) { + return; + } + emitJsDocComments(node); + emitClassMemberDeclarationFlags(node); + emitVariableDeclaration(node); + write(";"); + writeLine(); + } + function emitVariableDeclaration(node) { + if (node.kind !== 211 || resolver.isDeclarationVisible(node)) { + if (ts.isBindingPattern(node.name)) { + emitBindingPattern(node.name); + } + else { + writeTextOfNode(currentSourceFile, node.name); + if ((node.kind === 141 || node.kind === 140) && ts.hasQuestionToken(node)) { + write("?"); + } + if ((node.kind === 141 || node.kind === 140) && node.parent.kind === 155) { + emitTypeOfVariableDeclarationFromTypeLiteral(node); + } + else if (!(node.flags & 32)) { + writeTypeOfDeclaration(node, node.type, getVariableDeclarationTypeVisibilityError); + } + } + } + function getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccesibilityResult) { + if (node.kind === 211) { + return symbolAccesibilityResult.errorModuleName ? + symbolAccesibilityResult.accessibility === 2 ? + ts.Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : + ts.Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_private_module_2 : + ts.Diagnostics.Exported_variable_0_has_or_is_using_private_name_1; + } + else if (node.kind === 141 || node.kind === 140) { + if (node.flags & 128) { + return symbolAccesibilityResult.errorModuleName ? + symbolAccesibilityResult.accessibility === 2 ? + ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : + ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : + ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_private_name_1; + } + else if (node.parent.kind === 214) { + return symbolAccesibilityResult.errorModuleName ? + symbolAccesibilityResult.accessibility === 2 ? + ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : + ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : + ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_private_name_1; + } + else { + return symbolAccesibilityResult.errorModuleName ? + ts.Diagnostics.Property_0_of_exported_interface_has_or_is_using_name_1_from_private_module_2 : + ts.Diagnostics.Property_0_of_exported_interface_has_or_is_using_private_name_1; + } + } + } + function getVariableDeclarationTypeVisibilityError(symbolAccesibilityResult) { + var diagnosticMessage = getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccesibilityResult); + return diagnosticMessage !== undefined ? { + diagnosticMessage: diagnosticMessage, + errorNode: node, + typeName: node.name + } : undefined; + } + function emitBindingPattern(bindingPattern) { + var elements = []; + for (var _i = 0, _a = bindingPattern.elements; _i < _a.length; _i++) { + var element = _a[_i]; + if (element.kind !== 187) { + elements.push(element); + } + } + emitCommaList(elements, emitBindingElement); + } + function emitBindingElement(bindingElement) { + function getBindingElementTypeVisibilityError(symbolAccesibilityResult) { + var diagnosticMessage = getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccesibilityResult); + return diagnosticMessage !== undefined ? { + diagnosticMessage: diagnosticMessage, + errorNode: bindingElement, + typeName: bindingElement.name + } : undefined; + } + if (bindingElement.name) { + if (ts.isBindingPattern(bindingElement.name)) { + emitBindingPattern(bindingElement.name); + } + else { + writeTextOfNode(currentSourceFile, bindingElement.name); + writeTypeOfDeclaration(bindingElement, undefined, getBindingElementTypeVisibilityError); + } + } + } + } + function emitTypeOfVariableDeclarationFromTypeLiteral(node) { + if (node.type) { + write(": "); + emitType(node.type); + } + } + function isVariableStatementVisible(node) { + return ts.forEach(node.declarationList.declarations, function (varDeclaration) { return resolver.isDeclarationVisible(varDeclaration); }); + } + function writeVariableStatement(node) { + emitJsDocComments(node); + emitModuleElementDeclarationFlags(node); + if (ts.isLet(node.declarationList)) { + write("let "); + } + else if (ts.isConst(node.declarationList)) { + write("const "); + } + else { + write("var "); + } + emitCommaList(node.declarationList.declarations, emitVariableDeclaration, resolver.isDeclarationVisible); + write(";"); + writeLine(); + } + function emitAccessorDeclaration(node) { + if (ts.hasDynamicName(node)) { + return; + } + var accessors = ts.getAllAccessorDeclarations(node.parent.members, node); + var accessorWithTypeAnnotation; + if (node === accessors.firstAccessor) { + emitJsDocComments(accessors.getAccessor); + emitJsDocComments(accessors.setAccessor); + emitClassMemberDeclarationFlags(node); + writeTextOfNode(currentSourceFile, node.name); + if (!(node.flags & 32)) { + accessorWithTypeAnnotation = node; + var type = getTypeAnnotationFromAccessor(node); + if (!type) { + var anotherAccessor = node.kind === 145 ? accessors.setAccessor : accessors.getAccessor; + type = getTypeAnnotationFromAccessor(anotherAccessor); + if (type) { + accessorWithTypeAnnotation = anotherAccessor; + } + } + writeTypeOfDeclaration(node, type, getAccessorDeclarationTypeVisibilityError); + } + write(";"); + writeLine(); + } + function getTypeAnnotationFromAccessor(accessor) { + if (accessor) { + return accessor.kind === 145 + ? accessor.type + : accessor.parameters.length > 0 + ? accessor.parameters[0].type + : undefined; + } + } + function getAccessorDeclarationTypeVisibilityError(symbolAccesibilityResult) { + var diagnosticMessage; + if (accessorWithTypeAnnotation.kind === 146) { + if (accessorWithTypeAnnotation.parent.flags & 128) { + diagnosticMessage = symbolAccesibilityResult.errorModuleName ? + ts.Diagnostics.Parameter_0_of_public_static_property_setter_from_exported_class_has_or_is_using_name_1_from_private_module_2 : + ts.Diagnostics.Parameter_0_of_public_static_property_setter_from_exported_class_has_or_is_using_private_name_1; + } + else { + diagnosticMessage = symbolAccesibilityResult.errorModuleName ? + ts.Diagnostics.Parameter_0_of_public_property_setter_from_exported_class_has_or_is_using_name_1_from_private_module_2 : + ts.Diagnostics.Parameter_0_of_public_property_setter_from_exported_class_has_or_is_using_private_name_1; + } + return { + diagnosticMessage: diagnosticMessage, + errorNode: accessorWithTypeAnnotation.parameters[0], + typeName: accessorWithTypeAnnotation.name + }; + } + else { + if (accessorWithTypeAnnotation.flags & 128) { + diagnosticMessage = symbolAccesibilityResult.errorModuleName ? + symbolAccesibilityResult.accessibility === 2 ? + ts.Diagnostics.Return_type_of_public_static_property_getter_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : + ts.Diagnostics.Return_type_of_public_static_property_getter_from_exported_class_has_or_is_using_name_0_from_private_module_1 : + ts.Diagnostics.Return_type_of_public_static_property_getter_from_exported_class_has_or_is_using_private_name_0; + } + else { + diagnosticMessage = symbolAccesibilityResult.errorModuleName ? + symbolAccesibilityResult.accessibility === 2 ? + ts.Diagnostics.Return_type_of_public_property_getter_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : + ts.Diagnostics.Return_type_of_public_property_getter_from_exported_class_has_or_is_using_name_0_from_private_module_1 : + ts.Diagnostics.Return_type_of_public_property_getter_from_exported_class_has_or_is_using_private_name_0; + } + return { + diagnosticMessage: diagnosticMessage, + errorNode: accessorWithTypeAnnotation.name, + typeName: undefined + }; + } + } + } + function writeFunctionDeclaration(node) { + if (ts.hasDynamicName(node)) { + return; + } + if (!resolver.isImplementationOfOverload(node)) { + emitJsDocComments(node); + if (node.kind === 213) { + emitModuleElementDeclarationFlags(node); + } + else if (node.kind === 143) { + emitClassMemberDeclarationFlags(node); + } + if (node.kind === 213) { + write("function "); + writeTextOfNode(currentSourceFile, node.name); + } + else if (node.kind === 144) { + write("constructor"); + } + else { + writeTextOfNode(currentSourceFile, node.name); + if (ts.hasQuestionToken(node)) { + write("?"); + } + } + emitSignatureDeclaration(node); + } + } + function emitSignatureDeclarationWithJsDocComments(node) { + emitJsDocComments(node); + emitSignatureDeclaration(node); + } + function emitSignatureDeclaration(node) { + if (node.kind === 148 || node.kind === 153) { + write("new "); + } + emitTypeParameters(node.typeParameters); + if (node.kind === 149) { + write("["); + } + else { + write("("); + } + var prevEnclosingDeclaration = enclosingDeclaration; + enclosingDeclaration = node; + emitCommaList(node.parameters, emitParameterDeclaration); + if (node.kind === 149) { + write("]"); + } + else { + write(")"); + } + var isFunctionTypeOrConstructorType = node.kind === 152 || node.kind === 153; + if (isFunctionTypeOrConstructorType || node.parent.kind === 155) { + if (node.type) { + write(isFunctionTypeOrConstructorType ? " => " : ": "); + emitType(node.type); + } + } + else if (node.kind !== 144 && !(node.flags & 32)) { + writeReturnTypeAtSignature(node, getReturnTypeVisibilityError); + } + enclosingDeclaration = prevEnclosingDeclaration; + if (!isFunctionTypeOrConstructorType) { + write(";"); + writeLine(); + } + function getReturnTypeVisibilityError(symbolAccesibilityResult) { + var diagnosticMessage; + switch (node.kind) { + case 148: + diagnosticMessage = symbolAccesibilityResult.errorModuleName ? + ts.Diagnostics.Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : + ts.Diagnostics.Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_0; + break; + case 147: + diagnosticMessage = symbolAccesibilityResult.errorModuleName ? + ts.Diagnostics.Return_type_of_call_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : + ts.Diagnostics.Return_type_of_call_signature_from_exported_interface_has_or_is_using_private_name_0; + break; + case 149: + diagnosticMessage = symbolAccesibilityResult.errorModuleName ? + ts.Diagnostics.Return_type_of_index_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : + ts.Diagnostics.Return_type_of_index_signature_from_exported_interface_has_or_is_using_private_name_0; + break; + case 143: + case 142: + if (node.flags & 128) { + diagnosticMessage = symbolAccesibilityResult.errorModuleName ? + symbolAccesibilityResult.accessibility === 2 ? + ts.Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : + 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 === 214) { + diagnosticMessage = symbolAccesibilityResult.errorModuleName ? + symbolAccesibilityResult.accessibility === 2 ? + ts.Diagnostics.Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : + ts.Diagnostics.Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_private_module_1 : + ts.Diagnostics.Return_type_of_public_method_from_exported_class_has_or_is_using_private_name_0; + } + else { + diagnosticMessage = symbolAccesibilityResult.errorModuleName ? + ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : + ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0; + } + break; + case 213: + diagnosticMessage = symbolAccesibilityResult.errorModuleName ? + symbolAccesibilityResult.accessibility === 2 ? + ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : + ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_name_0_from_private_module_1 : + ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_private_name_0; + break; + default: + ts.Debug.fail("This is unknown kind for signature: " + node.kind); + } + return { + diagnosticMessage: diagnosticMessage, + errorNode: node.name || node + }; + } + } + function emitParameterDeclaration(node) { + increaseIndent(); + emitJsDocComments(node); + if (node.dotDotDotToken) { + write("..."); + } + if (ts.isBindingPattern(node.name)) { + emitBindingPattern(node.name); + } + else { + writeTextOfNode(currentSourceFile, node.name); + } + if (resolver.isOptionalParameter(node)) { + write("?"); + } + decreaseIndent(); + if (node.parent.kind === 152 || + node.parent.kind === 153 || + node.parent.parent.kind === 155) { + emitTypeOfVariableDeclarationFromTypeLiteral(node); + } + else if (!(node.parent.flags & 32)) { + writeTypeOfDeclaration(node, node.type, getParameterDeclarationTypeVisibilityError); + } + function getParameterDeclarationTypeVisibilityError(symbolAccesibilityResult) { + var diagnosticMessage = getParameterDeclarationTypeVisibilityDiagnosticMessage(symbolAccesibilityResult); + return diagnosticMessage !== undefined ? { + diagnosticMessage: diagnosticMessage, + errorNode: node, + typeName: node.name + } : undefined; + } + function getParameterDeclarationTypeVisibilityDiagnosticMessage(symbolAccesibilityResult) { + switch (node.parent.kind) { + case 144: + return symbolAccesibilityResult.errorModuleName ? + symbolAccesibilityResult.accessibility === 2 ? + ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : + ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_private_module_2 : + ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_private_name_1; + case 148: + return symbolAccesibilityResult.errorModuleName ? + ts.Diagnostics.Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : + ts.Diagnostics.Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; + case 147: + return symbolAccesibilityResult.errorModuleName ? + ts.Diagnostics.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : + ts.Diagnostics.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; + case 143: + case 142: + if (node.parent.flags & 128) { + return symbolAccesibilityResult.errorModuleName ? + symbolAccesibilityResult.accessibility === 2 ? + ts.Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : + 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 === 214) { + return symbolAccesibilityResult.errorModuleName ? + symbolAccesibilityResult.accessibility === 2 ? + ts.Diagnostics.Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : + ts.Diagnostics.Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_private_module_2 : + ts.Diagnostics.Parameter_0_of_public_method_from_exported_class_has_or_is_using_private_name_1; + } + else { + return symbolAccesibilityResult.errorModuleName ? + 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 213: + return symbolAccesibilityResult.errorModuleName ? + symbolAccesibilityResult.accessibility === 2 ? + ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : + ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_name_1_from_private_module_2 : + ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_private_name_1; + default: + ts.Debug.fail("This is unknown parent for parameter: " + node.parent.kind); + } + } + function emitBindingPattern(bindingPattern) { + if (bindingPattern.kind === 161) { + write("{"); + emitCommaList(bindingPattern.elements, emitBindingElement); + write("}"); + } + else if (bindingPattern.kind === 162) { + write("["); + var elements = bindingPattern.elements; + emitCommaList(elements, emitBindingElement); + if (elements && elements.hasTrailingComma) { + write(", "); + } + write("]"); + } + } + function emitBindingElement(bindingElement) { + function getBindingElementTypeVisibilityError(symbolAccesibilityResult) { + var diagnosticMessage = getParameterDeclarationTypeVisibilityDiagnosticMessage(symbolAccesibilityResult); + return diagnosticMessage !== undefined ? { + diagnosticMessage: diagnosticMessage, + errorNode: bindingElement, + typeName: bindingElement.name + } : undefined; + } + if (bindingElement.kind === 187) { + write(" "); + } + else if (bindingElement.kind === 163) { + if (bindingElement.propertyName) { + writeTextOfNode(currentSourceFile, bindingElement.propertyName); + write(": "); + } + if (bindingElement.name) { + if (ts.isBindingPattern(bindingElement.name)) { + emitBindingPattern(bindingElement.name); + } + else { + ts.Debug.assert(bindingElement.name.kind === 69); + if (bindingElement.dotDotDotToken) { + write("..."); + } + writeTextOfNode(currentSourceFile, bindingElement.name); + } + } + } + } + } + function emitNode(node) { + switch (node.kind) { + case 213: + case 218: + case 221: + case 215: + case 214: + case 216: + case 217: + return emitModuleElement(node, isModuleElementVisible(node)); + case 193: + return emitModuleElement(node, isVariableStatementVisible(node)); + case 222: + return emitModuleElement(node, !node.importClause); + case 228: + return emitExportDeclaration(node); + case 144: + case 143: + case 142: + return writeFunctionDeclaration(node); + case 148: + case 147: + case 149: + return emitSignatureDeclarationWithJsDocComments(node); + case 145: + case 146: + return emitAccessorDeclaration(node); + case 141: + case 140: + return emitPropertyDeclaration(node); + case 247: + return emitEnumMemberDeclaration(node); + case 227: + return emitExportAssignment(node); + case 248: + return emitSourceFile(node); + } + } + function writeReferencePath(referencedFile) { + var declFileName = referencedFile.flags & 8192 + ? referencedFile.fileName + : ts.shouldEmitToOwnFile(referencedFile, compilerOptions) + ? ts.getOwnEmitOutputFilePath(referencedFile, host, ".d.ts") + : ts.removeFileExtension(compilerOptions.outFile || compilerOptions.out) + ".d.ts"; + declFileName = ts.getRelativePathToDirectoryOrUrl(ts.getDirectoryPath(ts.normalizeSlashes(jsFilePath)), declFileName, host.getCurrentDirectory(), host.getCanonicalFileName, false); + referencePathsOutput += "/// " + newLine; + } + } + function writeDeclarationFile(jsFilePath, sourceFile, host, resolver, diagnostics) { + var emitDeclarationResult = emitDeclarations(host, resolver, diagnostics, jsFilePath, sourceFile); + if (!emitDeclarationResult.reportedDeclarationError) { + var declarationOutput = emitDeclarationResult.referencePathsOutput + + getDeclarationOutput(emitDeclarationResult.synchronousDeclarationOutput, emitDeclarationResult.moduleElementDeclarationEmitInfo); + ts.writeFile(host, diagnostics, ts.removeFileExtension(jsFilePath) + ".d.ts", declarationOutput, host.getCompilerOptions().emitBOM); + } + function getDeclarationOutput(synchronousDeclarationOutput, moduleElementDeclarationEmitInfo) { + var appliedSyncOutputPos = 0; + var declarationOutput = ""; + ts.forEach(moduleElementDeclarationEmitInfo, function (aliasEmitInfo) { + if (aliasEmitInfo.asynchronousOutput) { + declarationOutput += synchronousDeclarationOutput.substring(appliedSyncOutputPos, aliasEmitInfo.outputPos); + declarationOutput += getDeclarationOutput(aliasEmitInfo.asynchronousOutput, aliasEmitInfo.subModuleElementDeclarationEmitInfo); + appliedSyncOutputPos = aliasEmitInfo.outputPos; + } + }); + declarationOutput += synchronousDeclarationOutput.substring(appliedSyncOutputPos); + return declarationOutput; + } + } + ts.writeDeclarationFile = writeDeclarationFile; +})(ts || (ts = {})); +var ts; +(function (ts) { + function isExternalModuleOrDeclarationFile(sourceFile) { + return ts.isExternalModule(sourceFile) || ts.isDeclarationFile(sourceFile); + } + ts.isExternalModuleOrDeclarationFile = isExternalModuleOrDeclarationFile; + var entities = { + "quot": 0x0022, + "amp": 0x0026, + "apos": 0x0027, + "lt": 0x003C, + "gt": 0x003E, + "nbsp": 0x00A0, + "iexcl": 0x00A1, + "cent": 0x00A2, + "pound": 0x00A3, + "curren": 0x00A4, + "yen": 0x00A5, + "brvbar": 0x00A6, + "sect": 0x00A7, + "uml": 0x00A8, + "copy": 0x00A9, + "ordf": 0x00AA, + "laquo": 0x00AB, + "not": 0x00AC, + "shy": 0x00AD, + "reg": 0x00AE, + "macr": 0x00AF, + "deg": 0x00B0, + "plusmn": 0x00B1, + "sup2": 0x00B2, + "sup3": 0x00B3, + "acute": 0x00B4, + "micro": 0x00B5, + "para": 0x00B6, + "middot": 0x00B7, + "cedil": 0x00B8, + "sup1": 0x00B9, + "ordm": 0x00BA, + "raquo": 0x00BB, + "frac14": 0x00BC, + "frac12": 0x00BD, + "frac34": 0x00BE, + "iquest": 0x00BF, + "Agrave": 0x00C0, + "Aacute": 0x00C1, + "Acirc": 0x00C2, + "Atilde": 0x00C3, + "Auml": 0x00C4, + "Aring": 0x00C5, + "AElig": 0x00C6, + "Ccedil": 0x00C7, + "Egrave": 0x00C8, + "Eacute": 0x00C9, + "Ecirc": 0x00CA, + "Euml": 0x00CB, + "Igrave": 0x00CC, + "Iacute": 0x00CD, + "Icirc": 0x00CE, + "Iuml": 0x00CF, + "ETH": 0x00D0, + "Ntilde": 0x00D1, + "Ograve": 0x00D2, + "Oacute": 0x00D3, + "Ocirc": 0x00D4, + "Otilde": 0x00D5, + "Ouml": 0x00D6, + "times": 0x00D7, + "Oslash": 0x00D8, + "Ugrave": 0x00D9, + "Uacute": 0x00DA, + "Ucirc": 0x00DB, + "Uuml": 0x00DC, + "Yacute": 0x00DD, + "THORN": 0x00DE, + "szlig": 0x00DF, + "agrave": 0x00E0, + "aacute": 0x00E1, + "acirc": 0x00E2, + "atilde": 0x00E3, + "auml": 0x00E4, + "aring": 0x00E5, + "aelig": 0x00E6, + "ccedil": 0x00E7, + "egrave": 0x00E8, + "eacute": 0x00E9, + "ecirc": 0x00EA, + "euml": 0x00EB, + "igrave": 0x00EC, + "iacute": 0x00ED, + "icirc": 0x00EE, + "iuml": 0x00EF, + "eth": 0x00F0, + "ntilde": 0x00F1, + "ograve": 0x00F2, + "oacute": 0x00F3, + "ocirc": 0x00F4, + "otilde": 0x00F5, + "ouml": 0x00F6, + "divide": 0x00F7, + "oslash": 0x00F8, + "ugrave": 0x00F9, + "uacute": 0x00FA, + "ucirc": 0x00FB, + "uuml": 0x00FC, + "yacute": 0x00FD, + "thorn": 0x00FE, + "yuml": 0x00FF, + "OElig": 0x0152, + "oelig": 0x0153, + "Scaron": 0x0160, + "scaron": 0x0161, + "Yuml": 0x0178, + "fnof": 0x0192, + "circ": 0x02C6, + "tilde": 0x02DC, + "Alpha": 0x0391, + "Beta": 0x0392, + "Gamma": 0x0393, + "Delta": 0x0394, + "Epsilon": 0x0395, + "Zeta": 0x0396, + "Eta": 0x0397, + "Theta": 0x0398, + "Iota": 0x0399, + "Kappa": 0x039A, + "Lambda": 0x039B, + "Mu": 0x039C, + "Nu": 0x039D, + "Xi": 0x039E, + "Omicron": 0x039F, + "Pi": 0x03A0, + "Rho": 0x03A1, + "Sigma": 0x03A3, + "Tau": 0x03A4, + "Upsilon": 0x03A5, + "Phi": 0x03A6, + "Chi": 0x03A7, + "Psi": 0x03A8, + "Omega": 0x03A9, + "alpha": 0x03B1, + "beta": 0x03B2, + "gamma": 0x03B3, + "delta": 0x03B4, + "epsilon": 0x03B5, + "zeta": 0x03B6, + "eta": 0x03B7, + "theta": 0x03B8, + "iota": 0x03B9, + "kappa": 0x03BA, + "lambda": 0x03BB, + "mu": 0x03BC, + "nu": 0x03BD, + "xi": 0x03BE, + "omicron": 0x03BF, + "pi": 0x03C0, + "rho": 0x03C1, + "sigmaf": 0x03C2, + "sigma": 0x03C3, + "tau": 0x03C4, + "upsilon": 0x03C5, + "phi": 0x03C6, + "chi": 0x03C7, + "psi": 0x03C8, + "omega": 0x03C9, + "thetasym": 0x03D1, + "upsih": 0x03D2, + "piv": 0x03D6, + "ensp": 0x2002, + "emsp": 0x2003, + "thinsp": 0x2009, + "zwnj": 0x200C, + "zwj": 0x200D, + "lrm": 0x200E, + "rlm": 0x200F, + "ndash": 0x2013, + "mdash": 0x2014, + "lsquo": 0x2018, + "rsquo": 0x2019, + "sbquo": 0x201A, + "ldquo": 0x201C, + "rdquo": 0x201D, + "bdquo": 0x201E, + "dagger": 0x2020, + "Dagger": 0x2021, + "bull": 0x2022, + "hellip": 0x2026, + "permil": 0x2030, + "prime": 0x2032, + "Prime": 0x2033, + "lsaquo": 0x2039, + "rsaquo": 0x203A, + "oline": 0x203E, + "frasl": 0x2044, + "euro": 0x20AC, + "image": 0x2111, + "weierp": 0x2118, + "real": 0x211C, + "trade": 0x2122, + "alefsym": 0x2135, + "larr": 0x2190, + "uarr": 0x2191, + "rarr": 0x2192, + "darr": 0x2193, + "harr": 0x2194, + "crarr": 0x21B5, + "lArr": 0x21D0, + "uArr": 0x21D1, + "rArr": 0x21D2, + "dArr": 0x21D3, + "hArr": 0x21D4, + "forall": 0x2200, + "part": 0x2202, + "exist": 0x2203, + "empty": 0x2205, + "nabla": 0x2207, + "isin": 0x2208, + "notin": 0x2209, + "ni": 0x220B, + "prod": 0x220F, + "sum": 0x2211, + "minus": 0x2212, + "lowast": 0x2217, + "radic": 0x221A, + "prop": 0x221D, + "infin": 0x221E, + "ang": 0x2220, + "and": 0x2227, + "or": 0x2228, + "cap": 0x2229, + "cup": 0x222A, + "int": 0x222B, + "there4": 0x2234, + "sim": 0x223C, + "cong": 0x2245, + "asymp": 0x2248, + "ne": 0x2260, + "equiv": 0x2261, + "le": 0x2264, + "ge": 0x2265, + "sub": 0x2282, + "sup": 0x2283, + "nsub": 0x2284, + "sube": 0x2286, + "supe": 0x2287, + "oplus": 0x2295, + "otimes": 0x2297, + "perp": 0x22A5, + "sdot": 0x22C5, + "lceil": 0x2308, + "rceil": 0x2309, + "lfloor": 0x230A, + "rfloor": 0x230B, + "lang": 0x2329, + "rang": 0x232A, + "loz": 0x25CA, + "spades": 0x2660, + "clubs": 0x2663, + "hearts": 0x2665, + "diams": 0x2666 + }; + function emitFiles(resolver, host, targetSourceFile) { + var extendsHelper = "\nvar __extends = (this && this.__extends) || function (d, b) {\n for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];\n function __() { this.constructor = d; }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n};"; + var decorateHelper = "\nvar __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\n return c > 3 && r && Object.defineProperty(target, key, r), r;\n};"; + var metadataHelper = "\nvar __metadata = (this && this.__metadata) || function (k, v) {\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(k, v);\n};"; + var paramHelper = "\nvar __param = (this && this.__param) || function (paramIndex, decorator) {\n return function (target, key) { decorator(target, key, paramIndex); }\n};"; + var awaiterHelper = "\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promise, generator) {\n return new Promise(function (resolve, reject) {\n generator = generator.call(thisArg, _arguments);\n function cast(value) { return value instanceof Promise && value.constructor === Promise ? value : new Promise(function (resolve) { resolve(value); }); }\n function onfulfill(value) { try { step(\"next\", value); } catch (e) { reject(e); } }\n function onreject(value) { try { step(\"throw\", value); } catch (e) { reject(e); } }\n function step(verb, value) {\n var result = generator[verb](value);\n result.done ? resolve(result.value) : cast(result.value).then(onfulfill, onreject);\n }\n step(\"next\", void 0);\n });\n};"; + var compilerOptions = host.getCompilerOptions(); + var languageVersion = compilerOptions.target || 0; + var modulekind = compilerOptions.module ? compilerOptions.module : languageVersion === 2 ? 5 : 0; + var sourceMapDataList = compilerOptions.sourceMap || compilerOptions.inlineSourceMap ? [] : undefined; + var diagnostics = []; + var newLine = host.getNewLine(); + var jsxDesugaring = host.getCompilerOptions().jsx !== 1; + var shouldEmitJsx = function (s) { return (s.languageVariant === 1 && !jsxDesugaring); }; + if (targetSourceFile === undefined) { + ts.forEach(host.getSourceFiles(), function (sourceFile) { + if (ts.shouldEmitToOwnFile(sourceFile, compilerOptions)) { + var jsFilePath = ts.getOwnEmitOutputFilePath(sourceFile, host, shouldEmitJsx(sourceFile) ? ".jsx" : ".js"); + emitFile(jsFilePath, sourceFile); + } + }); + if (compilerOptions.outFile || compilerOptions.out) { + emitFile(compilerOptions.outFile || compilerOptions.out); + } + } + else { + if (ts.shouldEmitToOwnFile(targetSourceFile, compilerOptions)) { + var jsFilePath = ts.getOwnEmitOutputFilePath(targetSourceFile, host, shouldEmitJsx(targetSourceFile) ? ".jsx" : ".js"); + emitFile(jsFilePath, targetSourceFile); + } + else if (!ts.isDeclarationFile(targetSourceFile) && (compilerOptions.outFile || compilerOptions.out)) { + emitFile(compilerOptions.outFile || compilerOptions.out); + } + } + diagnostics = ts.sortAndDeduplicateDiagnostics(diagnostics); + return { + emitSkipped: false, + diagnostics: diagnostics, + sourceMaps: sourceMapDataList + }; + function isNodeDescendentOf(node, ancestor) { + while (node) { + if (node === ancestor) + return true; + node = node.parent; + } + return false; + } + function isUniqueLocalName(name, container) { + for (var node = container; isNodeDescendentOf(node, container); node = node.nextContainer) { + if (node.locals && ts.hasProperty(node.locals, name)) { + if (node.locals[name].flags & (107455 | 1048576 | 8388608)) { + return false; + } + } + } + return true; + } + function setLabeledJump(state, isBreak, labelText, labelMarker) { + if (isBreak) { + if (!state.labeledNonLocalBreaks) { + state.labeledNonLocalBreaks = {}; + } + state.labeledNonLocalBreaks[labelText] = labelMarker; + } + else { + if (!state.labeledNonLocalContinues) { + state.labeledNonLocalContinues = {}; + } + state.labeledNonLocalContinues[labelText] = labelMarker; + } + } + function hoistVariableDeclarationFromLoop(state, declaration) { + if (!state.hoistedLocalVariables) { + state.hoistedLocalVariables = []; + } + visit(declaration.name); + function visit(node) { + if (node.kind === 69) { + state.hoistedLocalVariables.push(node); + } + else { + for (var _a = 0, _b = node.elements; _a < _b.length; _a++) { + var element = _b[_a]; + visit(element.name); + } + } + } + } + function emitJavaScript(jsFilePath, root) { + var writer = ts.createTextWriter(newLine); + var write = writer.write, writeTextOfNode = writer.writeTextOfNode, writeLine = writer.writeLine, increaseIndent = writer.increaseIndent, decreaseIndent = writer.decreaseIndent; + var currentSourceFile; + var exportFunctionForFile; + var generatedNameSet = {}; + var nodeToGeneratedName = []; + var computedPropertyNamesToGeneratedNames; + var convertedLoopState; + var extendsEmitted = false; + var decorateEmitted = false; + var paramEmitted = false; + var awaiterEmitted = false; + var tempFlags = 0; + var tempVariables; + var tempParameters; + var externalImports; + var exportSpecifiers; + var exportEquals; + var hasExportStars; + var writeEmittedFiles = writeJavaScriptFile; + var detachedCommentsInfo; + var writeComment = ts.writeCommentRange; + var emit = emitNodeWithCommentsAndWithoutSourcemap; + var emitStart = function (node) { }; + var emitEnd = function (node) { }; + var emitToken = emitTokenText; + var scopeEmitStart = function (scopeDeclaration, scopeName) { }; + var scopeEmitEnd = function () { }; + var sourceMapData; + var emitLeadingCommentsOfPosition = compilerOptions.removeComments ? function (pos) { } : emitLeadingCommentsOfPositionWorker; + var moduleEmitDelegates = (_a = {}, + _a[5] = emitES6Module, + _a[2] = emitAMDModule, + _a[4] = emitSystemModule, + _a[3] = emitUMDModule, + _a[1] = emitCommonJSModule, + _a + ); + if (compilerOptions.sourceMap || compilerOptions.inlineSourceMap) { + initializeEmitterWithSourceMaps(); + } + if (root) { + emitSourceFile(root); + } + else { + ts.forEach(host.getSourceFiles(), function (sourceFile) { + if (!isExternalModuleOrDeclarationFile(sourceFile)) { + emitSourceFile(sourceFile); + } + }); + } + writeLine(); + writeEmittedFiles(writer.getText(), compilerOptions.emitBOM); + return; + function emitSourceFile(sourceFile) { + currentSourceFile = sourceFile; + exportFunctionForFile = undefined; + emit(sourceFile); + } + function isUniqueName(name) { + return !resolver.hasGlobalName(name) && + !ts.hasProperty(currentSourceFile.identifiers, name) && + !ts.hasProperty(generatedNameSet, name); + } + function makeTempVariableName(flags) { + if (flags && !(tempFlags & flags)) { + var name_19 = flags === 268435456 ? "_i" : "_n"; + if (isUniqueName(name_19)) { + tempFlags |= flags; + return name_19; + } + } + while (true) { + var count = tempFlags & 268435455; + tempFlags++; + if (count !== 8 && count !== 13) { + var name_20 = count < 26 ? "_" + String.fromCharCode(97 + count) : "_" + (count - 26); + if (isUniqueName(name_20)) { + return name_20; + } + } + } + } + function makeUniqueName(baseName) { + if (baseName.charCodeAt(baseName.length - 1) !== 95) { + baseName += "_"; + } + var i = 1; + while (true) { + var generatedName = baseName + i; + if (isUniqueName(generatedName)) { + return generatedNameSet[generatedName] = generatedName; + } + i++; + } + } + function generateNameForModuleOrEnum(node) { + var name = node.name.text; + return isUniqueLocalName(name, node) ? name : makeUniqueName(name); + } + function generateNameForImportOrExportDeclaration(node) { + var expr = ts.getExternalModuleName(node); + var baseName = expr.kind === 9 ? + ts.escapeIdentifier(ts.makeIdentifierFromModuleName(expr.text)) : "module"; + return makeUniqueName(baseName); + } + function generateNameForExportDefault() { + return makeUniqueName("default"); + } + function generateNameForClassExpression() { + return makeUniqueName("class"); + } + function generateNameForNode(node) { + switch (node.kind) { + case 69: + return makeUniqueName(node.text); + case 218: + case 217: + return generateNameForModuleOrEnum(node); + case 222: + case 228: + return generateNameForImportOrExportDeclaration(node); + case 213: + case 214: + case 227: + return generateNameForExportDefault(); + case 186: + return generateNameForClassExpression(); + } + } + function getGeneratedNameForNode(node) { + var id = ts.getNodeId(node); + return nodeToGeneratedName[id] || (nodeToGeneratedName[id] = ts.unescapeIdentifier(generateNameForNode(node))); + } + function initializeEmitterWithSourceMaps() { + var sourceMapDir; + var sourceMapSourceIndex = -1; + var sourceMapNameIndexMap = {}; + var sourceMapNameIndices = []; + function getSourceMapNameIndex() { + return sourceMapNameIndices.length ? ts.lastOrUndefined(sourceMapNameIndices) : -1; + } + var lastRecordedSourceMapSpan; + var lastEncodedSourceMapSpan = { + emittedLine: 1, + emittedColumn: 1, + sourceLine: 1, + sourceColumn: 1, + sourceIndex: 0 + }; + var lastEncodedNameIndex = 0; + function encodeLastRecordedSourceMapSpan() { + if (!lastRecordedSourceMapSpan || lastRecordedSourceMapSpan === lastEncodedSourceMapSpan) { + return; + } + var prevEncodedEmittedColumn = lastEncodedSourceMapSpan.emittedColumn; + if (lastEncodedSourceMapSpan.emittedLine === lastRecordedSourceMapSpan.emittedLine) { + if (sourceMapData.sourceMapMappings) { + sourceMapData.sourceMapMappings += ","; + } + } + else { + for (var encodedLine = lastEncodedSourceMapSpan.emittedLine; encodedLine < lastRecordedSourceMapSpan.emittedLine; encodedLine++) { + sourceMapData.sourceMapMappings += ";"; + } + prevEncodedEmittedColumn = 1; + } + sourceMapData.sourceMapMappings += base64VLQFormatEncode(lastRecordedSourceMapSpan.emittedColumn - prevEncodedEmittedColumn); + sourceMapData.sourceMapMappings += base64VLQFormatEncode(lastRecordedSourceMapSpan.sourceIndex - lastEncodedSourceMapSpan.sourceIndex); + sourceMapData.sourceMapMappings += base64VLQFormatEncode(lastRecordedSourceMapSpan.sourceLine - lastEncodedSourceMapSpan.sourceLine); + sourceMapData.sourceMapMappings += base64VLQFormatEncode(lastRecordedSourceMapSpan.sourceColumn - lastEncodedSourceMapSpan.sourceColumn); + if (lastRecordedSourceMapSpan.nameIndex >= 0) { + sourceMapData.sourceMapMappings += base64VLQFormatEncode(lastRecordedSourceMapSpan.nameIndex - lastEncodedNameIndex); + lastEncodedNameIndex = lastRecordedSourceMapSpan.nameIndex; + } + lastEncodedSourceMapSpan = lastRecordedSourceMapSpan; + sourceMapData.sourceMapDecodedMappings.push(lastEncodedSourceMapSpan); + function base64VLQFormatEncode(inValue) { + function base64FormatEncode(inValue) { + if (inValue < 64) { + return "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(inValue); + } + throw TypeError(inValue + ": not a 64 based value"); + } + if (inValue < 0) { + inValue = ((-inValue) << 1) + 1; + } + else { + inValue = inValue << 1; + } + var encodedStr = ""; + do { + var currentDigit = inValue & 31; + inValue = inValue >> 5; + if (inValue > 0) { + currentDigit = currentDigit | 32; + } + encodedStr = encodedStr + base64FormatEncode(currentDigit); + } while (inValue > 0); + return encodedStr; + } + } + function recordSourceMapSpan(pos) { + var sourceLinePos = ts.getLineAndCharacterOfPosition(currentSourceFile, pos); + sourceLinePos.line++; + sourceLinePos.character++; + var emittedLine = writer.getLine(); + var emittedColumn = writer.getColumn(); + if (!lastRecordedSourceMapSpan || + lastRecordedSourceMapSpan.emittedLine !== emittedLine || + lastRecordedSourceMapSpan.emittedColumn !== emittedColumn || + (lastRecordedSourceMapSpan.sourceIndex === sourceMapSourceIndex && + (lastRecordedSourceMapSpan.sourceLine > sourceLinePos.line || + (lastRecordedSourceMapSpan.sourceLine === sourceLinePos.line && lastRecordedSourceMapSpan.sourceColumn > sourceLinePos.character)))) { + encodeLastRecordedSourceMapSpan(); + lastRecordedSourceMapSpan = { + emittedLine: emittedLine, + emittedColumn: emittedColumn, + sourceLine: sourceLinePos.line, + sourceColumn: sourceLinePos.character, + nameIndex: getSourceMapNameIndex(), + sourceIndex: sourceMapSourceIndex + }; + } + else { + lastRecordedSourceMapSpan.sourceLine = sourceLinePos.line; + lastRecordedSourceMapSpan.sourceColumn = sourceLinePos.character; + lastRecordedSourceMapSpan.sourceIndex = sourceMapSourceIndex; + } + } + function recordEmitNodeStartSpan(node) { + recordSourceMapSpan(ts.skipTrivia(currentSourceFile.text, node.pos)); + } + function recordEmitNodeEndSpan(node) { + recordSourceMapSpan(node.end); + } + function writeTextWithSpanRecord(tokenKind, startPos, emitFn) { + var tokenStartPos = ts.skipTrivia(currentSourceFile.text, startPos); + recordSourceMapSpan(tokenStartPos); + var tokenEndPos = emitTokenText(tokenKind, tokenStartPos, emitFn); + recordSourceMapSpan(tokenEndPos); + return tokenEndPos; + } + function recordNewSourceFileStart(node) { + var sourcesDirectoryPath = compilerOptions.sourceRoot ? host.getCommonSourceDirectory() : sourceMapDir; + sourceMapData.sourceMapSources.push(ts.getRelativePathToDirectoryOrUrl(sourcesDirectoryPath, node.fileName, host.getCurrentDirectory(), host.getCanonicalFileName, true)); + sourceMapSourceIndex = sourceMapData.sourceMapSources.length - 1; + sourceMapData.inputSourceFileNames.push(node.fileName); + if (compilerOptions.inlineSources) { + if (!sourceMapData.sourceMapSourcesContent) { + sourceMapData.sourceMapSourcesContent = []; + } + sourceMapData.sourceMapSourcesContent.push(node.text); + } + } + function recordScopeNameOfNode(node, scopeName) { + function recordScopeNameIndex(scopeNameIndex) { + sourceMapNameIndices.push(scopeNameIndex); + } + function recordScopeNameStart(scopeName) { + var scopeNameIndex = -1; + if (scopeName) { + var parentIndex = getSourceMapNameIndex(); + if (parentIndex !== -1) { + var name_21 = node.name; + if (!name_21 || name_21.kind !== 136) { + scopeName = "." + scopeName; + } + scopeName = sourceMapData.sourceMapNames[parentIndex] + scopeName; + } + scopeNameIndex = ts.getProperty(sourceMapNameIndexMap, scopeName); + if (scopeNameIndex === undefined) { + scopeNameIndex = sourceMapData.sourceMapNames.length; + sourceMapData.sourceMapNames.push(scopeName); + sourceMapNameIndexMap[scopeName] = scopeNameIndex; + } + } + recordScopeNameIndex(scopeNameIndex); + } + if (scopeName) { + recordScopeNameStart(scopeName); + } + else if (node.kind === 213 || + node.kind === 173 || + node.kind === 143 || + node.kind === 142 || + node.kind === 145 || + node.kind === 146 || + node.kind === 218 || + node.kind === 214 || + node.kind === 217) { + if (node.name) { + var name_22 = node.name; + scopeName = name_22.kind === 136 + ? ts.getTextOfNode(name_22) + : node.name.text; + } + recordScopeNameStart(scopeName); + } + else { + recordScopeNameIndex(getSourceMapNameIndex()); + } + } + function recordScopeNameEnd() { + sourceMapNameIndices.pop(); + } + ; + function writeCommentRangeWithMap(curentSourceFile, writer, comment, newLine) { + recordSourceMapSpan(comment.pos); + ts.writeCommentRange(currentSourceFile, writer, comment, newLine); + recordSourceMapSpan(comment.end); + } + function serializeSourceMapContents(version, file, sourceRoot, sources, names, mappings, sourcesContent) { + if (typeof JSON !== "undefined") { + var map_1 = { + version: version, + file: file, + sourceRoot: sourceRoot, + sources: sources, + names: names, + mappings: mappings + }; + if (sourcesContent !== undefined) { + map_1.sourcesContent = sourcesContent; + } + return JSON.stringify(map_1); + } + return "{\"version\":" + version + ",\"file\":\"" + ts.escapeString(file) + "\",\"sourceRoot\":\"" + ts.escapeString(sourceRoot) + "\",\"sources\":[" + serializeStringArray(sources) + "],\"names\":[" + serializeStringArray(names) + "],\"mappings\":\"" + ts.escapeString(mappings) + "\" " + (sourcesContent !== undefined ? ",\"sourcesContent\":[" + serializeStringArray(sourcesContent) + "]" : "") + "}"; + function serializeStringArray(list) { + var output = ""; + for (var i = 0, n = list.length; i < n; i++) { + if (i) { + output += ","; + } + output += "\"" + ts.escapeString(list[i]) + "\""; + } + return output; + } + } + function writeJavaScriptAndSourceMapFile(emitOutput, writeByteOrderMark) { + encodeLastRecordedSourceMapSpan(); + var sourceMapText = serializeSourceMapContents(3, sourceMapData.sourceMapFile, sourceMapData.sourceMapSourceRoot, sourceMapData.sourceMapSources, sourceMapData.sourceMapNames, sourceMapData.sourceMapMappings, sourceMapData.sourceMapSourcesContent); + sourceMapDataList.push(sourceMapData); + var sourceMapUrl; + if (compilerOptions.inlineSourceMap) { + var base64SourceMapText = ts.convertToBase64(sourceMapText); + sourceMapUrl = "//# sourceMappingURL=data:application/json;base64," + base64SourceMapText; + } + else { + ts.writeFile(host, diagnostics, sourceMapData.sourceMapFilePath, sourceMapText, false); + sourceMapUrl = "//# sourceMappingURL=" + sourceMapData.jsSourceMappingURL; + } + writeJavaScriptFile(emitOutput + sourceMapUrl, writeByteOrderMark); + } + var sourceMapJsFile = ts.getBaseFileName(ts.normalizeSlashes(jsFilePath)); + sourceMapData = { + sourceMapFilePath: jsFilePath + ".map", + jsSourceMappingURL: sourceMapJsFile + ".map", + sourceMapFile: sourceMapJsFile, + sourceMapSourceRoot: compilerOptions.sourceRoot || "", + sourceMapSources: [], + inputSourceFileNames: [], + sourceMapNames: [], + sourceMapMappings: "", + sourceMapSourcesContent: undefined, + sourceMapDecodedMappings: [] + }; + sourceMapData.sourceMapSourceRoot = ts.normalizeSlashes(sourceMapData.sourceMapSourceRoot); + if (sourceMapData.sourceMapSourceRoot.length && sourceMapData.sourceMapSourceRoot.charCodeAt(sourceMapData.sourceMapSourceRoot.length - 1) !== 47) { + sourceMapData.sourceMapSourceRoot += ts.directorySeparator; + } + if (compilerOptions.mapRoot) { + sourceMapDir = ts.normalizeSlashes(compilerOptions.mapRoot); + if (root) { + sourceMapDir = ts.getDirectoryPath(ts.getSourceFilePathInNewDir(root, host, sourceMapDir)); + } + if (!ts.isRootedDiskPath(sourceMapDir) && !ts.isUrl(sourceMapDir)) { + sourceMapDir = ts.combinePaths(host.getCommonSourceDirectory(), sourceMapDir); + sourceMapData.jsSourceMappingURL = ts.getRelativePathToDirectoryOrUrl(ts.getDirectoryPath(ts.normalizePath(jsFilePath)), ts.combinePaths(sourceMapDir, sourceMapData.jsSourceMappingURL), host.getCurrentDirectory(), host.getCanonicalFileName, true); + } + else { + sourceMapData.jsSourceMappingURL = ts.combinePaths(sourceMapDir, sourceMapData.jsSourceMappingURL); + } + } + else { + sourceMapDir = ts.getDirectoryPath(ts.normalizePath(jsFilePath)); + } + function emitNodeWithSourceMap(node) { + if (node) { + if (ts.nodeIsSynthesized(node)) { + return emitNodeWithoutSourceMap(node); + } + if (node.kind !== 248) { + recordEmitNodeStartSpan(node); + emitNodeWithoutSourceMap(node); + recordEmitNodeEndSpan(node); + } + else { + recordNewSourceFileStart(node); + emitNodeWithoutSourceMap(node); + } + } + } + function emitNodeWithCommentsAndWithSourcemap(node) { + emitNodeConsideringCommentsOption(node, emitNodeWithSourceMap); + } + writeEmittedFiles = writeJavaScriptAndSourceMapFile; + emit = emitNodeWithCommentsAndWithSourcemap; + emitStart = recordEmitNodeStartSpan; + emitEnd = recordEmitNodeEndSpan; + emitToken = writeTextWithSpanRecord; + scopeEmitStart = recordScopeNameOfNode; + scopeEmitEnd = recordScopeNameEnd; + writeComment = writeCommentRangeWithMap; + } + function writeJavaScriptFile(emitOutput, writeByteOrderMark) { + ts.writeFile(host, diagnostics, jsFilePath, emitOutput, writeByteOrderMark); + } + function createTempVariable(flags) { + var result = ts.createSynthesizedNode(69); + result.text = makeTempVariableName(flags); + return result; + } + function recordTempDeclaration(name) { + if (!tempVariables) { + tempVariables = []; + } + tempVariables.push(name); + } + function createAndRecordTempVariable(flags) { + var temp = createTempVariable(flags); + recordTempDeclaration(temp); + return temp; + } + function emitTempDeclarations(newLine) { + if (tempVariables) { + if (newLine) { + writeLine(); + } + else { + write(" "); + } + write("var "); + emitCommaList(tempVariables); + write(";"); + } + } + function emitTokenText(tokenKind, startPos, emitFn) { + var tokenString = ts.tokenToString(tokenKind); + if (emitFn) { + emitFn(); + } + else { + write(tokenString); + } + return startPos + tokenString.length; + } + function emitOptional(prefix, node) { + if (node) { + write(prefix); + emit(node); + } + } + function emitParenthesizedIf(node, parenthesized) { + if (parenthesized) { + write("("); + } + emit(node); + if (parenthesized) { + write(")"); + } + } + function emitTrailingCommaIfPresent(nodeList) { + if (nodeList.hasTrailingComma) { + write(","); + } + } + function emitLinePreservingList(parent, nodes, allowTrailingComma, spacesBetweenBraces) { + ts.Debug.assert(nodes.length > 0); + increaseIndent(); + if (nodeStartPositionsAreOnSameLine(parent, nodes[0])) { + if (spacesBetweenBraces) { + write(" "); + } + } + else { + writeLine(); + } + for (var i = 0, n = nodes.length; i < n; i++) { + if (i) { + if (nodeEndIsOnSameLineAsNodeStart(nodes[i - 1], nodes[i])) { + write(", "); + } + else { + write(","); + writeLine(); + } + } + emit(nodes[i]); + } + if (nodes.hasTrailingComma && allowTrailingComma) { + write(","); + } + decreaseIndent(); + if (nodeEndPositionsAreOnSameLine(parent, ts.lastOrUndefined(nodes))) { + if (spacesBetweenBraces) { + write(" "); + } + } + else { + writeLine(); + } + } + function emitList(nodes, start, count, multiLine, trailingComma, leadingComma, noTrailingNewLine, emitNode) { + if (!emitNode) { + emitNode = emit; + } + for (var i = 0; i < count; i++) { + if (multiLine) { + if (i || leadingComma) { + write(","); + } + writeLine(); + } + else { + if (i || leadingComma) { + write(", "); + } + } + var node = nodes[start + i]; + emitTrailingCommentsOfPosition(node.pos); + emitNode(node); + leadingComma = true; + } + if (trailingComma) { + write(","); + } + if (multiLine && !noTrailingNewLine) { + writeLine(); + } + return count; + } + function emitCommaList(nodes) { + if (nodes) { + emitList(nodes, 0, nodes.length, false, false); + } + } + function emitLines(nodes) { + emitLinesStartingAt(nodes, 0); + } + function emitLinesStartingAt(nodes, startIndex) { + for (var i = startIndex; i < nodes.length; i++) { + writeLine(); + emit(nodes[i]); + } + } + function isBinaryOrOctalIntegerLiteral(node, text) { + if (node.kind === 8 && text.length > 1) { + switch (text.charCodeAt(1)) { + case 98: + case 66: + case 111: + case 79: + return true; + } + } + return false; + } + function emitLiteral(node) { + var text = getLiteralText(node); + if ((compilerOptions.sourceMap || compilerOptions.inlineSourceMap) && (node.kind === 9 || ts.isTemplateLiteralKind(node.kind))) { + writer.writeLiteral(text); + } + else if (languageVersion < 2 && isBinaryOrOctalIntegerLiteral(node, text)) { + write(node.text); + } + else { + write(text); + } + } + function getLiteralText(node) { + if (languageVersion < 2 && (ts.isTemplateLiteralKind(node.kind) || node.hasExtendedUnicodeEscape)) { + return getQuotedEscapedLiteralText("\"", node.text, "\""); + } + if (node.parent) { + return ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, node); + } + switch (node.kind) { + case 9: + return getQuotedEscapedLiteralText("\"", node.text, "\""); + case 11: + return getQuotedEscapedLiteralText("`", node.text, "`"); + case 12: + return getQuotedEscapedLiteralText("`", node.text, "${"); + case 13: + return getQuotedEscapedLiteralText("}", node.text, "${"); + case 14: + return getQuotedEscapedLiteralText("}", node.text, "`"); + case 8: + return node.text; + } + ts.Debug.fail("Literal kind '" + node.kind + "' not accounted for."); + } + function getQuotedEscapedLiteralText(leftQuote, text, rightQuote) { + return leftQuote + ts.escapeNonAsciiCharacters(ts.escapeString(text)) + rightQuote; + } + function emitDownlevelRawTemplateLiteral(node) { + var text = ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, node); + var isLast = node.kind === 11 || node.kind === 14; + text = text.substring(1, text.length - (isLast ? 1 : 2)); + text = text.replace(/\r\n?/g, "\n"); + text = ts.escapeString(text); + write("\"" + text + "\""); + } + function emitDownlevelTaggedTemplateArray(node, literalEmitter) { + write("["); + if (node.template.kind === 11) { + literalEmitter(node.template); + } + else { + literalEmitter(node.template.head); + ts.forEach(node.template.templateSpans, function (child) { + write(", "); + literalEmitter(child.literal); + }); + } + write("]"); + } + function emitDownlevelTaggedTemplate(node) { + var tempVariable = createAndRecordTempVariable(0); + write("("); + emit(tempVariable); + write(" = "); + emitDownlevelTaggedTemplateArray(node, emit); + write(", "); + emit(tempVariable); + write(".raw = "); + emitDownlevelTaggedTemplateArray(node, emitDownlevelRawTemplateLiteral); + write(", "); + emitParenthesizedIf(node.tag, needsParenthesisForPropertyAccessOrInvocation(node.tag)); + write("("); + emit(tempVariable); + if (node.template.kind === 183) { + ts.forEach(node.template.templateSpans, function (templateSpan) { + write(", "); + var needsParens = templateSpan.expression.kind === 181 + && templateSpan.expression.operatorToken.kind === 24; + emitParenthesizedIf(templateSpan.expression, needsParens); + }); + } + write("))"); + } + function emitTemplateExpression(node) { + if (languageVersion >= 2) { + ts.forEachChild(node, emit); + return; + } + var emitOuterParens = ts.isExpression(node.parent) + && templateNeedsParens(node, node.parent); + if (emitOuterParens) { + write("("); + } + var headEmitted = false; + if (shouldEmitTemplateHead()) { + emitLiteral(node.head); + headEmitted = true; + } + for (var i = 0, n = node.templateSpans.length; i < n; i++) { + var templateSpan = node.templateSpans[i]; + var needsParens = templateSpan.expression.kind !== 172 + && comparePrecedenceToBinaryPlus(templateSpan.expression) !== 1; + if (i > 0 || headEmitted) { + write(" + "); + } + emitParenthesizedIf(templateSpan.expression, needsParens); + if (templateSpan.literal.text.length !== 0) { + write(" + "); + emitLiteral(templateSpan.literal); + } + } + if (emitOuterParens) { + write(")"); + } + function shouldEmitTemplateHead() { + ts.Debug.assert(node.templateSpans.length !== 0); + return node.head.text.length !== 0 || node.templateSpans[0].literal.text.length === 0; + } + function templateNeedsParens(template, parent) { + switch (parent.kind) { + case 168: + case 169: + return parent.expression === template; + case 170: + case 172: + return false; + default: + return comparePrecedenceToBinaryPlus(parent) !== -1; + } + } + function comparePrecedenceToBinaryPlus(expression) { + switch (expression.kind) { + case 181: + switch (expression.operatorToken.kind) { + case 37: + case 39: + case 40: + return 1; + case 35: + case 36: + return 0; + default: + return -1; + } + case 184: + case 182: + return -1; + default: + return 1; + } + } + } + function emitTemplateSpan(span) { + emit(span.expression); + emit(span.literal); + } + function jsxEmitReact(node) { + function emitTagName(name) { + if (name.kind === 69 && ts.isIntrinsicJsxName(name.text)) { + write("\""); + emit(name); + write("\""); + } + else { + emit(name); + } + } + function emitAttributeName(name) { + if (/[A-Za-z_]+[\w*]/.test(name.text)) { + write("\""); + emit(name); + write("\""); + } + else { + emit(name); + } + } + function emitJsxAttribute(node) { + emitAttributeName(node.name); + write(": "); + if (node.initializer) { + emit(node.initializer); + } + else { + write("true"); + } + } + function emitJsxElement(openingNode, children) { + var syntheticReactRef = ts.createSynthesizedNode(69); + syntheticReactRef.text = "React"; + syntheticReactRef.parent = openingNode; + emitLeadingComments(openingNode); + emitExpressionIdentifier(syntheticReactRef); + write(".createElement("); + emitTagName(openingNode.tagName); + write(", "); + if (openingNode.attributes.length === 0) { + write("null"); + } + else { + var attrs = openingNode.attributes; + if (ts.forEach(attrs, function (attr) { return attr.kind === 239; })) { + emitExpressionIdentifier(syntheticReactRef); + write(".__spread("); + var haveOpenedObjectLiteral = false; + for (var i_1 = 0; i_1 < attrs.length; i_1++) { + if (attrs[i_1].kind === 239) { + if (i_1 === 0) { + write("{}, "); + } + if (haveOpenedObjectLiteral) { + write("}"); + haveOpenedObjectLiteral = false; + } + if (i_1 > 0) { + write(", "); + } + emit(attrs[i_1].expression); + } + else { + ts.Debug.assert(attrs[i_1].kind === 238); + if (haveOpenedObjectLiteral) { + write(", "); + } + else { + haveOpenedObjectLiteral = true; + if (i_1 > 0) { + write(", "); + } + write("{"); + } + emitJsxAttribute(attrs[i_1]); + } + } + if (haveOpenedObjectLiteral) + write("}"); + write(")"); + } + else { + write("{"); + for (var i = 0; i < attrs.length; i++) { + if (i > 0) { + write(", "); + } + emitJsxAttribute(attrs[i]); + } + write("}"); + } + } + if (children) { + for (var i = 0; i < children.length; i++) { + if (children[i].kind === 240 && !(children[i].expression)) { + continue; + } + if (children[i].kind === 236) { + var text = getTextToEmit(children[i]); + if (text !== undefined) { + write(", \""); + write(text); + write("\""); + } + } + else { + write(", "); + emit(children[i]); + } + } + } + write(")"); + emitTrailingComments(openingNode); + } + if (node.kind === 233) { + emitJsxElement(node.openingElement, node.children); + } + else { + ts.Debug.assert(node.kind === 234); + emitJsxElement(node); + } + } + function jsxEmitPreserve(node) { + function emitJsxAttribute(node) { + emit(node.name); + if (node.initializer) { + write("="); + emit(node.initializer); + } + } + function emitJsxSpreadAttribute(node) { + write("{..."); + emit(node.expression); + write("}"); + } + function emitAttributes(attribs) { + for (var i = 0, n = attribs.length; i < n; i++) { + if (i > 0) { + write(" "); + } + if (attribs[i].kind === 239) { + emitJsxSpreadAttribute(attribs[i]); + } + else { + ts.Debug.assert(attribs[i].kind === 238); + emitJsxAttribute(attribs[i]); + } + } + } + function emitJsxOpeningOrSelfClosingElement(node) { + write("<"); + emit(node.tagName); + if (node.attributes.length > 0 || (node.kind === 234)) { + write(" "); + } + emitAttributes(node.attributes); + if (node.kind === 234) { + write("/>"); + } + else { + write(">"); + } + } + function emitJsxClosingElement(node) { + write(""); + } + function emitJsxElement(node) { + emitJsxOpeningOrSelfClosingElement(node.openingElement); + for (var i = 0, n = node.children.length; i < n; i++) { + emit(node.children[i]); + } + emitJsxClosingElement(node.closingElement); + } + if (node.kind === 233) { + emitJsxElement(node); + } + else { + ts.Debug.assert(node.kind === 234); + emitJsxOpeningOrSelfClosingElement(node); + } + } + function emitExpressionForPropertyName(node) { + ts.Debug.assert(node.kind !== 163); + if (node.kind === 9) { + emitLiteral(node); + } + else if (node.kind === 136) { + if (ts.nodeIsDecorated(node.parent)) { + if (!computedPropertyNamesToGeneratedNames) { + computedPropertyNamesToGeneratedNames = []; + } + var generatedName = computedPropertyNamesToGeneratedNames[ts.getNodeId(node)]; + if (generatedName) { + write(generatedName); + return; + } + generatedName = createAndRecordTempVariable(0).text; + computedPropertyNamesToGeneratedNames[ts.getNodeId(node)] = generatedName; + write(generatedName); + write(" = "); + } + emit(node.expression); + } + else { + write("\""); + if (node.kind === 8) { + write(node.text); + } + else { + writeTextOfNode(currentSourceFile, node); + } + write("\""); + } + } + function isExpressionIdentifier(node) { + var parent = node.parent; + switch (parent.kind) { + case 164: + case 189: + case 181: + case 168: + case 241: + case 136: + case 182: + case 139: + case 175: + case 197: + case 167: + case 227: + case 195: + case 188: + case 199: + case 200: + case 201: + case 196: + case 234: + case 235: + case 239: + case 240: + case 169: + case 172: + case 180: + case 179: + case 204: + case 246: + case 185: + case 206: + case 170: + case 190: + case 208: + case 171: + case 176: + case 177: + case 198: + case 205: + case 184: + return true; + case 163: + case 247: + case 138: + case 245: + case 141: + case 211: + return parent.initializer === node; + case 166: + return parent.expression === node; + case 174: + case 173: + return parent.body === node; + case 221: + return parent.moduleReference === node; + case 135: + return parent.left === node; + } + return false; + } + function emitExpressionIdentifier(node) { + if (resolver.getNodeCheckFlags(node) & 2048) { + write("_arguments"); + return; + } + var container = resolver.getReferencedExportContainer(node); + if (container) { + if (container.kind === 248) { + if (modulekind !== 5 && modulekind !== 4) { + write("exports."); + } + } + else { + write(getGeneratedNameForNode(container)); + write("."); + } + } + else { + if (modulekind !== 5) { + var declaration = resolver.getReferencedImportDeclaration(node); + if (declaration) { + if (declaration.kind === 223) { + write(getGeneratedNameForNode(declaration.parent)); + write(languageVersion === 0 ? "[\"default\"]" : ".default"); + return; + } + else if (declaration.kind === 226) { + write(getGeneratedNameForNode(declaration.parent.parent.parent)); + var name_23 = declaration.propertyName || declaration.name; + var identifier = ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, name_23); + if (languageVersion === 0 && identifier === "default") { + write("[\"default\"]"); + } + else { + write("."); + write(identifier); + } + return; + } + } + } + if (languageVersion !== 2) { + var declaration = resolver.getReferencedNestedRedeclaration(node); + if (declaration) { + write(getGeneratedNameForNode(declaration.name)); + return; + } + } + } + if (ts.nodeIsSynthesized(node)) { + write(node.text); + } + else { + writeTextOfNode(currentSourceFile, node); + } + } + function isNameOfNestedRedeclaration(node) { + if (languageVersion < 2) { + var parent_6 = node.parent; + switch (parent_6.kind) { + case 163: + case 214: + case 217: + case 211: + return parent_6.name === node && resolver.isNestedRedeclaration(parent_6); + } + } + return false; + } + function emitIdentifier(node) { + if (convertedLoopState) { + if (node.text == "arguments" && resolver.isArgumentsLocalBinding(node)) { + var name_24 = convertedLoopState.argumentsName || (convertedLoopState.argumentsName = makeUniqueName("arguments")); + write(name_24); + return; + } + } + if (!node.parent) { + write(node.text); + } + else if (isExpressionIdentifier(node)) { + emitExpressionIdentifier(node); + } + else if (isNameOfNestedRedeclaration(node)) { + write(getGeneratedNameForNode(node)); + } + else if (ts.nodeIsSynthesized(node)) { + write(node.text); + } + else { + writeTextOfNode(currentSourceFile, node); + } + } + function emitThis(node) { + if (resolver.getNodeCheckFlags(node) & 2) { + write("_this"); + } + else { + write("this"); + } + } + function emitSuper(node) { + if (languageVersion >= 2) { + write("super"); + } + else { + var flags = resolver.getNodeCheckFlags(node); + if (flags & 256) { + write("_super.prototype"); + } + else { + write("_super"); + } + } + } + function emitObjectBindingPattern(node) { + write("{ "); + var elements = node.elements; + emitList(elements, 0, elements.length, false, elements.hasTrailingComma); + write(" }"); + } + function emitArrayBindingPattern(node) { + write("["); + var elements = node.elements; + emitList(elements, 0, elements.length, false, elements.hasTrailingComma); + write("]"); + } + function emitBindingElement(node) { + if (node.propertyName) { + emit(node.propertyName); + write(": "); + } + if (node.dotDotDotToken) { + write("..."); + } + if (ts.isBindingPattern(node.name)) { + emit(node.name); + } + else { + emitModuleMemberName(node); + } + emitOptional(" = ", node.initializer); + } + function emitSpreadElementExpression(node) { + write("..."); + emit(node.expression); + } + function emitYieldExpression(node) { + write(ts.tokenToString(114)); + if (node.asteriskToken) { + write("*"); + } + if (node.expression) { + write(" "); + emit(node.expression); + } + } + function emitAwaitExpression(node) { + var needsParenthesis = needsParenthesisForAwaitExpressionAsYield(node); + if (needsParenthesis) { + write("("); + } + write(ts.tokenToString(114)); + write(" "); + emit(node.expression); + if (needsParenthesis) { + write(")"); + } + } + function needsParenthesisForAwaitExpressionAsYield(node) { + if (node.parent.kind === 181 && !ts.isAssignmentOperator(node.parent.operatorToken.kind)) { + return true; + } + else if (node.parent.kind === 182 && node.parent.condition === node) { + return true; + } + return false; + } + function needsParenthesisForPropertyAccessOrInvocation(node) { + switch (node.kind) { + case 69: + case 164: + case 166: + case 167: + case 168: + case 172: + return false; + } + return true; + } + function emitListWithSpread(elements, needsUniqueCopy, multiLine, trailingComma, useConcat) { + var pos = 0; + var group = 0; + var length = elements.length; + while (pos < length) { + if (group === 1 && useConcat) { + write(".concat("); + } + else if (group > 0) { + write(", "); + } + var e = elements[pos]; + if (e.kind === 185) { + e = e.expression; + emitParenthesizedIf(e, group === 0 && needsParenthesisForPropertyAccessOrInvocation(e)); + pos++; + if (pos === length && group === 0 && needsUniqueCopy && e.kind !== 164) { + write(".slice()"); + } + } + else { + var i = pos; + while (i < length && elements[i].kind !== 185) { + i++; + } + write("["); + if (multiLine) { + increaseIndent(); + } + emitList(elements, pos, i - pos, multiLine, trailingComma && i === length); + if (multiLine) { + decreaseIndent(); + } + write("]"); + pos = i; + } + group++; + } + if (group > 1) { + if (useConcat) { + write(")"); + } + } + } + function isSpreadElementExpression(node) { + return node.kind === 185; + } + function emitArrayLiteral(node) { + var elements = node.elements; + if (elements.length === 0) { + write("[]"); + } + else if (languageVersion >= 2 || !ts.forEach(elements, isSpreadElementExpression)) { + write("["); + emitLinePreservingList(node, node.elements, elements.hasTrailingComma, false); + write("]"); + } + else { + emitListWithSpread(elements, true, (node.flags & 2048) !== 0, elements.hasTrailingComma, true); + } + } + function emitObjectLiteralBody(node, numElements) { + if (numElements === 0) { + write("{}"); + return; + } + write("{"); + if (numElements > 0) { + var properties = node.properties; + if (numElements === properties.length) { + emitLinePreservingList(node, properties, languageVersion >= 1, true); + } + else { + var multiLine = (node.flags & 2048) !== 0; + if (!multiLine) { + write(" "); + } + else { + increaseIndent(); + } + emitList(properties, 0, numElements, multiLine, false); + if (!multiLine) { + write(" "); + } + else { + decreaseIndent(); + } + } + } + write("}"); + } + function emitDownlevelObjectLiteralWithComputedProperties(node, firstComputedPropertyIndex) { + var multiLine = (node.flags & 2048) !== 0; + var properties = node.properties; + write("("); + if (multiLine) { + increaseIndent(); + } + var tempVar = createAndRecordTempVariable(0); + emit(tempVar); + write(" = "); + emitObjectLiteralBody(node, firstComputedPropertyIndex); + for (var i = firstComputedPropertyIndex, n = properties.length; i < n; i++) { + writeComma(); + var property = properties[i]; + emitStart(property); + if (property.kind === 145 || property.kind === 146) { + var accessors = ts.getAllAccessorDeclarations(node.properties, property); + if (property !== accessors.firstAccessor) { + continue; + } + write("Object.defineProperty("); + emit(tempVar); + write(", "); + emitStart(node.name); + emitExpressionForPropertyName(property.name); + emitEnd(property.name); + write(", {"); + increaseIndent(); + if (accessors.getAccessor) { + writeLine(); + emitLeadingComments(accessors.getAccessor); + write("get: "); + emitStart(accessors.getAccessor); + write("function "); + emitSignatureAndBody(accessors.getAccessor); + emitEnd(accessors.getAccessor); + emitTrailingComments(accessors.getAccessor); + write(","); + } + if (accessors.setAccessor) { + writeLine(); + emitLeadingComments(accessors.setAccessor); + write("set: "); + emitStart(accessors.setAccessor); + write("function "); + emitSignatureAndBody(accessors.setAccessor); + emitEnd(accessors.setAccessor); + emitTrailingComments(accessors.setAccessor); + write(","); + } + writeLine(); + write("enumerable: true,"); + writeLine(); + write("configurable: true"); + decreaseIndent(); + writeLine(); + write("})"); + emitEnd(property); + } + else { + emitLeadingComments(property); + emitStart(property.name); + emit(tempVar); + emitMemberAccessForPropertyName(property.name); + emitEnd(property.name); + write(" = "); + if (property.kind === 245) { + emit(property.initializer); + } + else if (property.kind === 246) { + emitExpressionIdentifier(property.name); + } + else if (property.kind === 143) { + emitFunctionDeclaration(property); + } + else { + ts.Debug.fail("ObjectLiteralElement type not accounted for: " + property.kind); + } + } + emitEnd(property); + } + writeComma(); + emit(tempVar); + if (multiLine) { + decreaseIndent(); + writeLine(); + } + write(")"); + function writeComma() { + if (multiLine) { + write(","); + writeLine(); + } + else { + write(", "); + } + } + } + function emitObjectLiteral(node) { + var properties = node.properties; + if (languageVersion < 2) { + var numProperties = properties.length; + var numInitialNonComputedProperties = numProperties; + for (var i = 0, n = properties.length; i < n; i++) { + if (properties[i].name.kind === 136) { + numInitialNonComputedProperties = i; + break; + } + } + var hasComputedProperty = numInitialNonComputedProperties !== properties.length; + if (hasComputedProperty) { + emitDownlevelObjectLiteralWithComputedProperties(node, numInitialNonComputedProperties); + return; + } + } + emitObjectLiteralBody(node, properties.length); + } + function createBinaryExpression(left, operator, right, startsOnNewLine) { + var result = ts.createSynthesizedNode(181, startsOnNewLine); + result.operatorToken = ts.createSynthesizedNode(operator); + result.left = left; + result.right = right; + return result; + } + function createPropertyAccessExpression(expression, name) { + var result = ts.createSynthesizedNode(166); + result.expression = parenthesizeForAccess(expression); + result.dotToken = ts.createSynthesizedNode(21); + result.name = name; + return result; + } + function createElementAccessExpression(expression, argumentExpression) { + var result = ts.createSynthesizedNode(167); + result.expression = parenthesizeForAccess(expression); + result.argumentExpression = argumentExpression; + return result; + } + function parenthesizeForAccess(expr) { + while (expr.kind === 171 || expr.kind === 189) { + expr = expr.expression; + } + if (ts.isLeftHandSideExpression(expr) && + expr.kind !== 169 && + expr.kind !== 8) { + return expr; + } + var node = ts.createSynthesizedNode(172); + node.expression = expr; + return node; + } + function emitComputedPropertyName(node) { + write("["); + emitExpressionForPropertyName(node); + write("]"); + } + function emitMethod(node) { + if (languageVersion >= 2 && node.asteriskToken) { + write("*"); + } + emit(node.name); + if (languageVersion < 2) { + write(": function "); + } + emitSignatureAndBody(node); + } + function emitPropertyAssignment(node) { + emit(node.name); + write(": "); + emitTrailingCommentsOfPosition(node.initializer.pos); + emit(node.initializer); + } + function isNamespaceExportReference(node) { + var container = resolver.getReferencedExportContainer(node); + return container && container.kind !== 248; + } + function emitShorthandPropertyAssignment(node) { + writeTextOfNode(currentSourceFile, node.name); + if (languageVersion < 2 || isNamespaceExportReference(node.name)) { + write(": "); + emit(node.name); + } + if (languageVersion >= 2 && node.objectAssignmentInitializer) { + write(" = "); + emit(node.objectAssignmentInitializer); + } + } + function tryEmitConstantValue(node) { + var constantValue = tryGetConstEnumValue(node); + if (constantValue !== undefined) { + write(constantValue.toString()); + if (!compilerOptions.removeComments) { + var propertyName = node.kind === 166 ? ts.declarationNameToString(node.name) : ts.getTextOfNode(node.argumentExpression); + write(" /* " + propertyName + " */"); + } + return true; + } + return false; + } + function tryGetConstEnumValue(node) { + if (compilerOptions.isolatedModules) { + return undefined; + } + return node.kind === 166 || node.kind === 167 + ? resolver.getConstantValue(node) + : undefined; + } + function indentIfOnDifferentLines(parent, node1, node2, valueToWriteWhenNotIndenting) { + var realNodesAreOnDifferentLines = !ts.nodeIsSynthesized(parent) && !nodeEndIsOnSameLineAsNodeStart(node1, node2); + var synthesizedNodeIsOnDifferentLine = synthesizedNodeStartsOnNewLine(node2); + if (realNodesAreOnDifferentLines || synthesizedNodeIsOnDifferentLine) { + increaseIndent(); + writeLine(); + return true; + } + else { + if (valueToWriteWhenNotIndenting) { + write(valueToWriteWhenNotIndenting); + } + return false; + } + } + function emitPropertyAccess(node) { + if (tryEmitConstantValue(node)) { + return; + } + emit(node.expression); + var indentedBeforeDot = indentIfOnDifferentLines(node, node.expression, node.dotToken); + var shouldEmitSpace; + if (!indentedBeforeDot) { + if (node.expression.kind === 8) { + var text = ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, node.expression); + shouldEmitSpace = text.indexOf(ts.tokenToString(21)) < 0; + } + else { + var constantValue = tryGetConstEnumValue(node.expression); + shouldEmitSpace = isFinite(constantValue) && Math.floor(constantValue) === constantValue; + } + } + if (shouldEmitSpace) { + write(" ."); + } + else { + write("."); + } + var indentedAfterDot = indentIfOnDifferentLines(node, node.dotToken, node.name); + emit(node.name); + decreaseIndentIf(indentedBeforeDot, indentedAfterDot); + } + function emitQualifiedName(node) { + emit(node.left); + write("."); + emit(node.right); + } + function emitQualifiedNameAsExpression(node, useFallback) { + if (node.left.kind === 69) { + emitEntityNameAsExpression(node.left, useFallback); + } + else if (useFallback) { + var temp = createAndRecordTempVariable(0); + write("("); + emitNodeWithoutSourceMap(temp); + write(" = "); + emitEntityNameAsExpression(node.left, true); + write(") && "); + emitNodeWithoutSourceMap(temp); + } + else { + emitEntityNameAsExpression(node.left, false); + } + write("."); + emit(node.right); + } + function emitEntityNameAsExpression(node, useFallback) { + switch (node.kind) { + case 69: + if (useFallback) { + write("typeof "); + emitExpressionIdentifier(node); + write(" !== 'undefined' && "); + } + emitExpressionIdentifier(node); + break; + case 135: + emitQualifiedNameAsExpression(node, useFallback); + break; + } + } + function emitIndexedAccess(node) { + if (tryEmitConstantValue(node)) { + return; + } + emit(node.expression); + write("["); + emit(node.argumentExpression); + write("]"); + } + function hasSpreadElement(elements) { + return ts.forEach(elements, function (e) { return e.kind === 185; }); + } + function skipParentheses(node) { + while (node.kind === 172 || node.kind === 171 || node.kind === 189) { + node = node.expression; + } + return node; + } + function emitCallTarget(node) { + if (node.kind === 69 || node.kind === 97 || node.kind === 95) { + emit(node); + return node; + } + var temp = createAndRecordTempVariable(0); + write("("); + emit(temp); + write(" = "); + emit(node); + write(")"); + return temp; + } + function emitCallWithSpread(node) { + var target; + var expr = skipParentheses(node.expression); + if (expr.kind === 166) { + target = emitCallTarget(expr.expression); + write("."); + emit(expr.name); + } + else if (expr.kind === 167) { + target = emitCallTarget(expr.expression); + write("["); + emit(expr.argumentExpression); + write("]"); + } + else if (expr.kind === 95) { + target = expr; + write("_super"); + } + else { + emit(node.expression); + } + write(".apply("); + if (target) { + if (target.kind === 95) { + emitThis(target); + } + else { + emit(target); + } + } + else { + write("void 0"); + } + write(", "); + emitListWithSpread(node.arguments, false, false, false, true); + write(")"); + } + function emitCallExpression(node) { + if (languageVersion < 2 && hasSpreadElement(node.arguments)) { + emitCallWithSpread(node); + return; + } + var superCall = false; + if (node.expression.kind === 95) { + emitSuper(node.expression); + superCall = true; + } + else { + emit(node.expression); + superCall = node.expression.kind === 166 && node.expression.expression.kind === 95; + } + if (superCall && languageVersion < 2) { + write(".call("); + emitThis(node.expression); + if (node.arguments.length) { + write(", "); + emitCommaList(node.arguments); + } + write(")"); + } + else { + write("("); + emitCommaList(node.arguments); + write(")"); + } + } + function emitNewExpression(node) { + write("new "); + if (languageVersion === 1 && + node.arguments && + hasSpreadElement(node.arguments)) { + write("("); + var target = emitCallTarget(node.expression); + write(".bind.apply("); + emit(target); + write(", [void 0].concat("); + emitListWithSpread(node.arguments, false, false, false, false); + write(")))"); + write("()"); + } + else { + emit(node.expression); + if (node.arguments) { + write("("); + emitCommaList(node.arguments); + write(")"); + } + } + } + function emitTaggedTemplateExpression(node) { + if (languageVersion >= 2) { + emit(node.tag); + write(" "); + emit(node.template); + } + else { + emitDownlevelTaggedTemplate(node); + } + } + function emitParenExpression(node) { + if (!ts.nodeIsSynthesized(node) && node.parent.kind !== 174) { + if (node.expression.kind === 171 || node.expression.kind === 189) { + var operand = node.expression.expression; + while (operand.kind === 171 || operand.kind === 189) { + operand = operand.expression; + } + if (operand.kind !== 179 && + operand.kind !== 177 && + operand.kind !== 176 && + operand.kind !== 175 && + operand.kind !== 180 && + operand.kind !== 169 && + !(operand.kind === 168 && node.parent.kind === 169) && + !(operand.kind === 173 && node.parent.kind === 168) && + !(operand.kind === 8 && node.parent.kind === 166)) { + emit(operand); + return; + } + } + } + write("("); + emit(node.expression); + write(")"); + } + function emitDeleteExpression(node) { + write(ts.tokenToString(78)); + write(" "); + emit(node.expression); + } + function emitVoidExpression(node) { + write(ts.tokenToString(103)); + write(" "); + emit(node.expression); + } + function emitTypeOfExpression(node) { + write(ts.tokenToString(101)); + write(" "); + emit(node.expression); + } + function isNameOfExportedSourceLevelDeclarationInSystemExternalModule(node) { + if (!isCurrentFileSystemExternalModule() || node.kind !== 69 || ts.nodeIsSynthesized(node)) { + return false; + } + var isVariableDeclarationOrBindingElement = node.parent && (node.parent.kind === 211 || node.parent.kind === 163); + var targetDeclaration = isVariableDeclarationOrBindingElement + ? node.parent + : resolver.getReferencedValueDeclaration(node); + return isSourceFileLevelDeclarationInSystemJsModule(targetDeclaration, true); + } + function emitPrefixUnaryExpression(node) { + var exportChanged = isNameOfExportedSourceLevelDeclarationInSystemExternalModule(node.operand); + if (exportChanged) { + write(exportFunctionForFile + "(\""); + emitNodeWithoutSourceMap(node.operand); + write("\", "); + } + write(ts.tokenToString(node.operator)); + if (node.operand.kind === 179) { + var operand = node.operand; + if (node.operator === 35 && (operand.operator === 35 || operand.operator === 41)) { + write(" "); + } + else if (node.operator === 36 && (operand.operator === 36 || operand.operator === 42)) { + write(" "); + } + } + emit(node.operand); + if (exportChanged) { + write(")"); + } + } + function emitPostfixUnaryExpression(node) { + var exportChanged = isNameOfExportedSourceLevelDeclarationInSystemExternalModule(node.operand); + if (exportChanged) { + write("(" + exportFunctionForFile + "(\""); + emitNodeWithoutSourceMap(node.operand); + write("\", "); + write(ts.tokenToString(node.operator)); + emit(node.operand); + if (node.operator === 41) { + write(") - 1)"); + } + else { + write(") + 1)"); + } + } + else { + emit(node.operand); + write(ts.tokenToString(node.operator)); + } + } + function shouldHoistDeclarationInSystemJsModule(node) { + return isSourceFileLevelDeclarationInSystemJsModule(node, false); + } + function isSourceFileLevelDeclarationInSystemJsModule(node, isExported) { + if (!node || !isCurrentFileSystemExternalModule()) { + return false; + } + var current = node; + while (current) { + if (current.kind === 248) { + return !isExported || ((ts.getCombinedNodeFlags(node) & 1) !== 0); + } + else if (ts.isFunctionLike(current) || current.kind === 219) { + return false; + } + else { + current = current.parent; + } + } + } + function emitExponentiationOperator(node) { + var leftHandSideExpression = node.left; + if (node.operatorToken.kind === 60) { + var synthesizedLHS; + var shouldEmitParentheses = false; + if (ts.isElementAccessExpression(leftHandSideExpression)) { + shouldEmitParentheses = true; + write("("); + synthesizedLHS = ts.createSynthesizedNode(167, false); + var identifier = emitTempVariableAssignment(leftHandSideExpression.expression, false, false); + synthesizedLHS.expression = identifier; + if (leftHandSideExpression.argumentExpression.kind !== 8 && + leftHandSideExpression.argumentExpression.kind !== 9) { + var tempArgumentExpression = createAndRecordTempVariable(268435456); + synthesizedLHS.argumentExpression = tempArgumentExpression; + emitAssignment(tempArgumentExpression, leftHandSideExpression.argumentExpression, true); + } + else { + synthesizedLHS.argumentExpression = leftHandSideExpression.argumentExpression; + } + write(", "); + } + else if (ts.isPropertyAccessExpression(leftHandSideExpression)) { + shouldEmitParentheses = true; + write("("); + synthesizedLHS = ts.createSynthesizedNode(166, false); + var identifier = emitTempVariableAssignment(leftHandSideExpression.expression, false, false); + synthesizedLHS.expression = identifier; + synthesizedLHS.dotToken = leftHandSideExpression.dotToken; + synthesizedLHS.name = leftHandSideExpression.name; + write(", "); + } + emit(synthesizedLHS || leftHandSideExpression); + write(" = "); + write("Math.pow("); + emit(synthesizedLHS || leftHandSideExpression); + write(", "); + emit(node.right); + write(")"); + if (shouldEmitParentheses) { + write(")"); + } + } + else { + write("Math.pow("); + emit(leftHandSideExpression); + write(", "); + emit(node.right); + write(")"); + } + } + function emitBinaryExpression(node) { + if (languageVersion < 2 && node.operatorToken.kind === 56 && + (node.left.kind === 165 || node.left.kind === 164)) { + emitDestructuring(node, node.parent.kind === 195); + } + else { + var exportChanged = node.operatorToken.kind >= 56 && + node.operatorToken.kind <= 68 && + isNameOfExportedSourceLevelDeclarationInSystemExternalModule(node.left); + if (exportChanged) { + write(exportFunctionForFile + "(\""); + emitNodeWithoutSourceMap(node.left); + write("\", "); + } + if (node.operatorToken.kind === 38 || node.operatorToken.kind === 60) { + emitExponentiationOperator(node); + } + else { + emit(node.left); + var indentedBeforeOperator = indentIfOnDifferentLines(node, node.left, node.operatorToken, node.operatorToken.kind !== 24 ? " " : undefined); + write(ts.tokenToString(node.operatorToken.kind)); + var indentedAfterOperator = indentIfOnDifferentLines(node, node.operatorToken, node.right, " "); + emit(node.right); + decreaseIndentIf(indentedBeforeOperator, indentedAfterOperator); + } + if (exportChanged) { + write(")"); + } + } + } + function synthesizedNodeStartsOnNewLine(node) { + return ts.nodeIsSynthesized(node) && node.startsOnNewLine; + } + function emitConditionalExpression(node) { + emit(node.condition); + var indentedBeforeQuestion = indentIfOnDifferentLines(node, node.condition, node.questionToken, " "); + write("?"); + var indentedAfterQuestion = indentIfOnDifferentLines(node, node.questionToken, node.whenTrue, " "); + emit(node.whenTrue); + decreaseIndentIf(indentedBeforeQuestion, indentedAfterQuestion); + var indentedBeforeColon = indentIfOnDifferentLines(node, node.whenTrue, node.colonToken, " "); + write(":"); + var indentedAfterColon = indentIfOnDifferentLines(node, node.colonToken, node.whenFalse, " "); + emit(node.whenFalse); + decreaseIndentIf(indentedBeforeColon, indentedAfterColon); + } + function decreaseIndentIf(value1, value2) { + if (value1) { + decreaseIndent(); + } + if (value2) { + decreaseIndent(); + } + } + function isSingleLineEmptyBlock(node) { + if (node && node.kind === 192) { + var block = node; + return block.statements.length === 0 && nodeEndIsOnSameLineAsNodeStart(block, block); + } + } + function emitBlock(node) { + if (isSingleLineEmptyBlock(node)) { + emitToken(15, node.pos); + write(" "); + emitToken(16, node.statements.end); + return; + } + emitToken(15, node.pos); + increaseIndent(); + scopeEmitStart(node.parent); + if (node.kind === 219) { + ts.Debug.assert(node.parent.kind === 218); + emitCaptureThisForNodeIfNecessary(node.parent); + } + emitLines(node.statements); + if (node.kind === 219) { + emitTempDeclarations(true); + } + decreaseIndent(); + writeLine(); + emitToken(16, node.statements.end); + scopeEmitEnd(); + } + function emitEmbeddedStatement(node) { + if (node.kind === 192) { + write(" "); + emit(node); + } + else { + increaseIndent(); + writeLine(); + emit(node); + decreaseIndent(); + } + } + function emitExpressionStatement(node) { + emitParenthesizedIf(node.expression, node.expression.kind === 174); + write(";"); + } + function emitIfStatement(node) { + var endPos = emitToken(88, node.pos); + write(" "); + endPos = emitToken(17, endPos); + emit(node.expression); + emitToken(18, node.expression.end); + emitEmbeddedStatement(node.thenStatement); + if (node.elseStatement) { + writeLine(); + emitToken(80, node.thenStatement.end); + if (node.elseStatement.kind === 196) { + write(" "); + emit(node.elseStatement); + } + else { + emitEmbeddedStatement(node.elseStatement); + } + } + } + function emitDoStatement(node) { + emitLoop(node, emitDoStatementWorker); + } + function emitDoStatementWorker(node, loop) { + write("do"); + if (loop) { + emitConvertedLoopCall(loop, true); + } + else { + emitNormalLoopBody(node, true); + } + if (node.statement.kind === 192) { + write(" "); + } + else { + writeLine(); + } + write("while ("); + emit(node.expression); + write(");"); + } + function emitWhileStatement(node) { + emitLoop(node, emitWhileStatementWorker); + } + function emitWhileStatementWorker(node, loop) { + write("while ("); + emit(node.expression); + write(")"); + if (loop) { + emitConvertedLoopCall(loop, true); + } + else { + emitNormalLoopBody(node, true); + } + } + function tryEmitStartOfVariableDeclarationList(decl, startPos) { + if (shouldHoistVariable(decl, true)) { + return false; + } + if (convertedLoopState && (ts.getCombinedNodeFlags(decl) & 49152) === 0) { + for (var _a = 0, _b = decl.declarations; _a < _b.length; _a++) { + var varDecl = _b[_a]; + hoistVariableDeclarationFromLoop(convertedLoopState, varDecl); + } + return false; + } + var tokenKind = 102; + if (decl && languageVersion >= 2) { + if (ts.isLet(decl)) { + tokenKind = 108; + } + else if (ts.isConst(decl)) { + tokenKind = 74; + } + } + if (startPos !== undefined) { + emitToken(tokenKind, startPos); + write(" "); + } + else { + switch (tokenKind) { + case 102: + write("var "); + break; + case 108: + write("let "); + break; + case 74: + write("const "); + break; + } + } + return true; + } + function emitVariableDeclarationListSkippingUninitializedEntries(list) { + var started = false; + for (var _a = 0, _b = list.declarations; _a < _b.length; _a++) { + var decl = _b[_a]; + if (!decl.initializer) { + continue; + } + if (!started) { + started = true; + } + else { + write(", "); + } + emit(decl); + } + return started; + } + function shouldConvertLoopBody(node) { + return languageVersion < 2 && + (resolver.getNodeCheckFlags(node) & 65536) !== 0; + } + function emitLoop(node, loopEmitter) { + var shouldConvert = shouldConvertLoopBody(node); + if (!shouldConvert) { + loopEmitter(node, undefined); + } + else { + var loop = convertLoopBody(node); + if (node.parent.kind === 207) { + emitLabelAndColon(node.parent); + } + loopEmitter(node, loop); + } + } + function convertLoopBody(node) { + var functionName = makeUniqueName("_loop"); + var loopInitializer; + switch (node.kind) { + case 199: + case 200: + case 201: + if (node.initializer.kind === 212) { + loopInitializer = node.initializer; + } + break; + } + var loopParameters; + if (loopInitializer && (ts.getCombinedNodeFlags(loopInitializer) & 49152)) { + loopParameters = []; + for (var _a = 0, _b = loopInitializer.declarations; _a < _b.length; _a++) { + var varDeclaration = _b[_a]; + collectNames(varDeclaration.name); + } + } + var bodyIsBlock = node.statement.kind === 192; + var paramList = loopParameters ? loopParameters.join(", ") : ""; + writeLine(); + write("var " + functionName + " = function(" + paramList + ")"); + if (!bodyIsBlock) { + write(" {"); + writeLine(); + increaseIndent(); + } + var convertedOuterLoopState = convertedLoopState; + convertedLoopState = {}; + if (convertedOuterLoopState) { + if (convertedOuterLoopState.argumentsName) { + convertedLoopState.argumentsName = convertedOuterLoopState.argumentsName; + } + if (convertedOuterLoopState.hoistedLocalVariables) { + convertedLoopState.hoistedLocalVariables = convertedOuterLoopState.hoistedLocalVariables; + } + } + emitEmbeddedStatement(node.statement); + if (!bodyIsBlock) { + decreaseIndent(); + writeLine(); + write("}"); + } + write(";"); + writeLine(); + if (convertedLoopState.argumentsName) { + if (convertedOuterLoopState) { + convertedOuterLoopState.argumentsName = convertedLoopState.argumentsName; + } + else { + write("var " + convertedLoopState.argumentsName + " = arguments;"); + writeLine(); + } + } + if (convertedLoopState.hoistedLocalVariables) { + if (convertedOuterLoopState) { + convertedOuterLoopState.hoistedLocalVariables = convertedLoopState.hoistedLocalVariables; + } + else { + write("var "); + var seen; + for (var _c = 0, _d = convertedLoopState.hoistedLocalVariables; _c < _d.length; _c++) { + var id = _d[_c]; + if (!seen) { + seen = {}; + } + else { + write(", "); + } + if (!ts.hasProperty(seen, id.text)) { + emit(id); + seen[id.text] = id.text; + } + } + write(";"); + writeLine(); + } + } + var currentLoopState = convertedLoopState; + convertedLoopState = convertedOuterLoopState; + return { functionName: functionName, paramList: paramList, state: currentLoopState }; + function collectNames(name) { + if (name.kind === 69) { + var nameText = isNameOfNestedRedeclaration(name) ? getGeneratedNameForNode(name) : name.text; + loopParameters.push(nameText); + } + else { + for (var _a = 0, _b = name.elements; _a < _b.length; _a++) { + var element = _b[_a]; + collectNames(element.name); + } + } + } + } + function emitNormalLoopBody(node, emitAsEmbeddedStatement) { + var saveAllowedNonLabeledJumps; + if (convertedLoopState) { + saveAllowedNonLabeledJumps = convertedLoopState.allowedNonLabeledJumps; + convertedLoopState.allowedNonLabeledJumps = 2 | 4; + } + if (emitAsEmbeddedStatement) { + emitEmbeddedStatement(node.statement); + } + else if (node.statement.kind === 192) { + emitLines(node.statement.statements); + } + else { + writeLine(); + emit(node.statement); + } + if (convertedLoopState) { + convertedLoopState.allowedNonLabeledJumps = saveAllowedNonLabeledJumps; + } + } + function emitConvertedLoopCall(loop, emitAsBlock) { + if (emitAsBlock) { + write(" {"); + writeLine(); + increaseIndent(); + } + var isSimpleLoop = !loop.state.nonLocalJumps && + !loop.state.labeledNonLocalBreaks && + !loop.state.labeledNonLocalContinues; + var loopResult = makeUniqueName("state"); + if (!isSimpleLoop) { + write("var " + loopResult + " = "); + } + write(loop.functionName + "(" + loop.paramList + ");"); + if (!isSimpleLoop) { + writeLine(); + if (loop.state.nonLocalJumps & 8) { + write("if (typeof " + loopResult + " === \"object\") "); + if (convertedLoopState) { + write("return " + loopResult + ";"); + convertedLoopState.nonLocalJumps |= 8; + } + else { + write("return " + loopResult + ".value"); + } + writeLine(); + } + if (loop.state.nonLocalJumps & 2) { + write("if (" + loopResult + " === \"break\") break;"); + writeLine(); + } + if (loop.state.nonLocalJumps & 4) { + write("if (" + loopResult + " === \"continue\") continue;"); + writeLine(); + } + emitDispatchTableForLabeledJumps(loopResult, loop.state, convertedLoopState); + } + if (emitAsBlock) { + writeLine(); + decreaseIndent(); + write("}"); + } + function emitDispatchTableForLabeledJumps(loopResultVariable, currentLoop, outerLoop) { + if (!currentLoop.labeledNonLocalBreaks && !currentLoop.labeledNonLocalContinues) { + return; + } + write("switch(" + loopResultVariable + ") {"); + increaseIndent(); + emitDispatchEntriesForLabeledJumps(currentLoop.labeledNonLocalBreaks, true, loopResultVariable, outerLoop); + emitDispatchEntriesForLabeledJumps(currentLoop.labeledNonLocalContinues, false, loopResultVariable, outerLoop); + decreaseIndent(); + writeLine(); + write("}"); + } + function emitDispatchEntriesForLabeledJumps(table, isBreak, loopResultVariable, outerLoop) { + if (!table) { + return; + } + for (var labelText in table) { + var labelMarker = table[labelText]; + writeLine(); + write("case \"" + labelMarker + "\": "); + if (!outerLoop || (outerLoop.labels && outerLoop.labels[labelText])) { + if (isBreak) { + write("break "); + } + else { + write("continue "); + } + write(labelText + ";"); + } + else { + setLabeledJump(outerLoop, isBreak, labelText, labelMarker); + write("return " + loopResultVariable + ";"); + } + } + } + } + function emitForStatement(node) { + emitLoop(node, emitForStatementWorker); + } + function emitForStatementWorker(node, loop) { + var endPos = emitToken(86, node.pos); + write(" "); + endPos = emitToken(17, endPos); + if (node.initializer && node.initializer.kind === 212) { + var variableDeclarationList = node.initializer; + var startIsEmitted = tryEmitStartOfVariableDeclarationList(variableDeclarationList, endPos); + if (startIsEmitted) { + emitCommaList(variableDeclarationList.declarations); + } + else { + emitVariableDeclarationListSkippingUninitializedEntries(variableDeclarationList); + } + } + else if (node.initializer) { + emit(node.initializer); + } + write(";"); + emitOptional(" ", node.condition); + write(";"); + emitOptional(" ", node.incrementor); + write(")"); + if (loop) { + emitConvertedLoopCall(loop, true); + } + else { + emitNormalLoopBody(node, true); + } + } + function emitForInOrForOfStatement(node) { + if (languageVersion < 2 && node.kind === 201) { + emitLoop(node, emitDownLevelForOfStatementWorker); + } + else { + emitLoop(node, emitForInOrForOfStatementWorker); + } + } + function emitForInOrForOfStatementWorker(node, loop) { + var endPos = emitToken(86, node.pos); + write(" "); + endPos = emitToken(17, endPos); + if (node.initializer.kind === 212) { + var variableDeclarationList = node.initializer; + if (variableDeclarationList.declarations.length >= 1) { + tryEmitStartOfVariableDeclarationList(variableDeclarationList, endPos); + emit(variableDeclarationList.declarations[0]); + } + } + else { + emit(node.initializer); + } + if (node.kind === 200) { + write(" in "); + } + else { + write(" of "); + } + emit(node.expression); + emitToken(18, node.expression.end); + if (loop) { + emitConvertedLoopCall(loop, true); + } + else { + emitNormalLoopBody(node, true); + } + } + function emitDownLevelForOfStatement(node) { + emitLoop(node, emitDownLevelForOfStatementWorker); + } + function emitDownLevelForOfStatementWorker(node, loop) { + var endPos = emitToken(86, node.pos); + write(" "); + endPos = emitToken(17, endPos); + var rhsIsIdentifier = node.expression.kind === 69; + var counter = createTempVariable(268435456); + var rhsReference = rhsIsIdentifier ? node.expression : createTempVariable(0); + emitStart(node.expression); + write("var "); + emitNodeWithoutSourceMap(counter); + write(" = 0"); + emitEnd(node.expression); + if (!rhsIsIdentifier) { + write(", "); + emitStart(node.expression); + emitNodeWithoutSourceMap(rhsReference); + write(" = "); + emitNodeWithoutSourceMap(node.expression); + emitEnd(node.expression); + } + write("; "); + emitStart(node.initializer); + emitNodeWithoutSourceMap(counter); + write(" < "); + emitNodeWithCommentsAndWithoutSourcemap(rhsReference); + write(".length"); + emitEnd(node.initializer); + write("; "); + emitStart(node.initializer); + emitNodeWithoutSourceMap(counter); + write("++"); + emitEnd(node.initializer); + emitToken(18, node.expression.end); + write(" {"); + writeLine(); + increaseIndent(); + var rhsIterationValue = createElementAccessExpression(rhsReference, counter); + emitStart(node.initializer); + if (node.initializer.kind === 212) { + write("var "); + var variableDeclarationList = node.initializer; + if (variableDeclarationList.declarations.length > 0) { + var declaration = variableDeclarationList.declarations[0]; + if (ts.isBindingPattern(declaration.name)) { + emitDestructuring(declaration, false, rhsIterationValue); + } + else { + emitNodeWithCommentsAndWithoutSourcemap(declaration); + write(" = "); + emitNodeWithoutSourceMap(rhsIterationValue); + } + } + else { + emitNodeWithoutSourceMap(createTempVariable(0)); + write(" = "); + emitNodeWithoutSourceMap(rhsIterationValue); + } + } + else { + var assignmentExpression = createBinaryExpression(node.initializer, 56, rhsIterationValue, false); + if (node.initializer.kind === 164 || node.initializer.kind === 165) { + emitDestructuring(assignmentExpression, true, undefined); + } + else { + emitNodeWithCommentsAndWithoutSourcemap(assignmentExpression); + } + } + emitEnd(node.initializer); + write(";"); + if (loop) { + writeLine(); + emitConvertedLoopCall(loop, false); + } + else { + emitNormalLoopBody(node, false); + } + writeLine(); + decreaseIndent(); + write("}"); + } + function emitBreakOrContinueStatement(node) { + if (convertedLoopState) { + var jump = node.kind === 203 ? 2 : 4; + var canUseBreakOrContinue = (node.label && convertedLoopState.labels && convertedLoopState.labels[node.label.text]) || + (!node.label && (convertedLoopState.allowedNonLabeledJumps & jump)); + if (!canUseBreakOrContinue) { + if (!node.label) { + if (node.kind === 203) { + convertedLoopState.nonLocalJumps |= 2; + write("return \"break\";"); + } + else { + convertedLoopState.nonLocalJumps |= 4; + write("return \"continue\";"); + } + } + else { + var labelMarker; + if (node.kind === 203) { + 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); + } + write("return \"" + labelMarker + "\";"); + } + return; + } + } + emitToken(node.kind === 203 ? 70 : 75, node.pos); + emitOptional(" ", node.label); + write(";"); + } + function emitReturnStatement(node) { + if (convertedLoopState) { + convertedLoopState.nonLocalJumps |= 8; + write("return { value: "); + if (node.expression) { + emit(node.expression); + } + else { + write("void 0"); + } + write(" };"); + return; + } + emitToken(94, node.pos); + emitOptional(" ", node.expression); + write(";"); + } + function emitWithStatement(node) { + write("with ("); + emit(node.expression); + write(")"); + emitEmbeddedStatement(node.statement); + } + function emitSwitchStatement(node) { + var endPos = emitToken(96, node.pos); + write(" "); + emitToken(17, endPos); + emit(node.expression); + endPos = emitToken(18, node.expression.end); + write(" "); + var saveAllowedNonLabeledJumps; + if (convertedLoopState) { + saveAllowedNonLabeledJumps = convertedLoopState.allowedNonLabeledJumps; + convertedLoopState.allowedNonLabeledJumps |= 2; + } + emitCaseBlock(node.caseBlock, endPos); + if (convertedLoopState) { + convertedLoopState.allowedNonLabeledJumps = saveAllowedNonLabeledJumps; + } + } + function emitCaseBlock(node, startPos) { + emitToken(15, startPos); + increaseIndent(); + emitLines(node.clauses); + decreaseIndent(); + writeLine(); + emitToken(16, node.clauses.end); + } + function nodeStartPositionsAreOnSameLine(node1, node2) { + return ts.getLineOfLocalPosition(currentSourceFile, ts.skipTrivia(currentSourceFile.text, node1.pos)) === + ts.getLineOfLocalPosition(currentSourceFile, ts.skipTrivia(currentSourceFile.text, node2.pos)); + } + function nodeEndPositionsAreOnSameLine(node1, node2) { + return ts.getLineOfLocalPosition(currentSourceFile, node1.end) === + ts.getLineOfLocalPosition(currentSourceFile, node2.end); + } + function nodeEndIsOnSameLineAsNodeStart(node1, node2) { + return ts.getLineOfLocalPosition(currentSourceFile, node1.end) === + ts.getLineOfLocalPosition(currentSourceFile, ts.skipTrivia(currentSourceFile.text, node2.pos)); + } + function emitCaseOrDefaultClause(node) { + if (node.kind === 241) { + write("case "); + emit(node.expression); + write(":"); + } + else { + write("default:"); + } + if (node.statements.length === 1 && nodeStartPositionsAreOnSameLine(node, node.statements[0])) { + write(" "); + emit(node.statements[0]); + } + else { + increaseIndent(); + emitLines(node.statements); + decreaseIndent(); + } + } + function emitThrowStatement(node) { + write("throw "); + emit(node.expression); + write(";"); + } + function emitTryStatement(node) { + write("try "); + emit(node.tryBlock); + emit(node.catchClause); + if (node.finallyBlock) { + writeLine(); + write("finally "); + emit(node.finallyBlock); + } + } + function emitCatchClause(node) { + writeLine(); + var endPos = emitToken(72, node.pos); + write(" "); + emitToken(17, endPos); + emit(node.variableDeclaration); + emitToken(18, node.variableDeclaration ? node.variableDeclaration.end : endPos); + write(" "); + emitBlock(node.block); + } + function emitDebuggerStatement(node) { + emitToken(76, node.pos); + write(";"); + } + function emitLabelAndColon(node) { + emit(node.label); + write(": "); + } + function emitLabeledStatement(node) { + if (!ts.isIterationStatement(node.statement, false) || !shouldConvertLoopBody(node.statement)) { + emitLabelAndColon(node); + } + if (convertedLoopState) { + if (!convertedLoopState.labels) { + convertedLoopState.labels = {}; + } + convertedLoopState.labels[node.label.text] = node.label.text; + } + emit(node.statement); + if (convertedLoopState) { + convertedLoopState.labels[node.label.text] = undefined; + } + } + function getContainingModule(node) { + do { + node = node.parent; + } while (node && node.kind !== 218); + return node; + } + function emitContainingModuleName(node) { + var container = getContainingModule(node); + write(container ? getGeneratedNameForNode(container) : "exports"); + } + function emitModuleMemberName(node) { + emitStart(node.name); + if (ts.getCombinedNodeFlags(node) & 1) { + var container = getContainingModule(node); + if (container) { + write(getGeneratedNameForNode(container)); + write("."); + } + else if (modulekind !== 5 && modulekind !== 4) { + write("exports."); + } + } + emitNodeWithCommentsAndWithoutSourcemap(node.name); + emitEnd(node.name); + } + function createVoidZero() { + var zero = ts.createSynthesizedNode(8); + zero.text = "0"; + var result = ts.createSynthesizedNode(177); + result.expression = zero; + return result; + } + function emitEs6ExportDefaultCompat(node) { + if (node.parent.kind === 248) { + ts.Debug.assert(!!(node.flags & 1024) || node.kind === 227); + if (modulekind === 1 || modulekind === 2 || modulekind === 3) { + if (!currentSourceFile.symbol.exports["___esModule"]) { + if (languageVersion === 1) { + write("Object.defineProperty(exports, \"__esModule\", { value: true });"); + writeLine(); + } + else if (languageVersion === 0) { + write("exports.__esModule = true;"); + writeLine(); + } + } + } + } + } + function emitExportMemberAssignment(node) { + if (node.flags & 1) { + writeLine(); + emitStart(node); + if (modulekind === 4 && node.parent === currentSourceFile) { + write(exportFunctionForFile + "(\""); + if (node.flags & 1024) { + write("default"); + } + else { + emitNodeWithCommentsAndWithoutSourcemap(node.name); + } + write("\", "); + emitDeclarationName(node); + write(")"); + } + else { + if (node.flags & 1024) { + emitEs6ExportDefaultCompat(node); + if (languageVersion === 0) { + write("exports[\"default\"]"); + } + else { + write("exports.default"); + } + } + else { + emitModuleMemberName(node); + } + write(" = "); + emitDeclarationName(node); + } + emitEnd(node); + write(";"); + } + } + function emitExportMemberAssignments(name) { + if (modulekind === 4) { + return; + } + if (!exportEquals && exportSpecifiers && ts.hasProperty(exportSpecifiers, name.text)) { + for (var _a = 0, _b = exportSpecifiers[name.text]; _a < _b.length; _a++) { + var specifier = _b[_a]; + writeLine(); + emitStart(specifier.name); + emitContainingModuleName(specifier); + write("."); + emitNodeWithCommentsAndWithoutSourcemap(specifier.name); + emitEnd(specifier.name); + write(" = "); + emitExpressionIdentifier(name); + write(";"); + } + } + } + function emitExportSpecifierInSystemModule(specifier) { + ts.Debug.assert(modulekind === 4); + if (!resolver.getReferencedValueDeclaration(specifier.propertyName || specifier.name) && !resolver.isValueAliasDeclaration(specifier)) { + return; + } + writeLine(); + emitStart(specifier.name); + write(exportFunctionForFile + "(\""); + emitNodeWithCommentsAndWithoutSourcemap(specifier.name); + write("\", "); + emitExpressionIdentifier(specifier.propertyName || specifier.name); + write(")"); + emitEnd(specifier.name); + write(";"); + } + function emitAssignment(name, value, shouldEmitCommaBeforeAssignment) { + if (shouldEmitCommaBeforeAssignment) { + write(", "); + } + var exportChanged = isNameOfExportedSourceLevelDeclarationInSystemExternalModule(name); + if (exportChanged) { + write(exportFunctionForFile + "(\""); + emitNodeWithCommentsAndWithoutSourcemap(name); + write("\", "); + } + var isVariableDeclarationOrBindingElement = name.parent && (name.parent.kind === 211 || name.parent.kind === 163); + if (isVariableDeclarationOrBindingElement) { + emitModuleMemberName(name.parent); + } + else { + emit(name); + } + write(" = "); + emit(value); + if (exportChanged) { + write(")"); + } + } + function emitTempVariableAssignment(expression, canDefineTempVariablesInPlace, shouldEmitCommaBeforeAssignment) { + var identifier = createTempVariable(0); + if (!canDefineTempVariablesInPlace) { + recordTempDeclaration(identifier); + } + emitAssignment(identifier, expression, shouldEmitCommaBeforeAssignment); + return identifier; + } + function emitDestructuring(root, isAssignmentExpressionStatement, value) { + var emitCount = 0; + var canDefineTempVariablesInPlace = false; + if (root.kind === 211) { + var isExported = ts.getCombinedNodeFlags(root) & 1; + var isSourceLevelForSystemModuleKind = shouldHoistDeclarationInSystemJsModule(root); + canDefineTempVariablesInPlace = !isExported && !isSourceLevelForSystemModuleKind; + } + else if (root.kind === 138) { + canDefineTempVariablesInPlace = true; + } + if (root.kind === 181) { + emitAssignmentExpression(root); + } + else { + ts.Debug.assert(!isAssignmentExpressionStatement); + emitBindingElement(root, value); + } + function ensureIdentifier(expr, reuseIdentifierExpressions) { + if (expr.kind === 69 && reuseIdentifierExpressions) { + return expr; + } + var identifier = emitTempVariableAssignment(expr, canDefineTempVariablesInPlace, emitCount > 0); + emitCount++; + return identifier; + } + function createDefaultValueCheck(value, defaultValue) { + value = ensureIdentifier(value, true); + var equals = ts.createSynthesizedNode(181); + equals.left = value; + equals.operatorToken = ts.createSynthesizedNode(32); + equals.right = createVoidZero(); + return createConditionalExpression(equals, defaultValue, value); + } + function createConditionalExpression(condition, whenTrue, whenFalse) { + var cond = ts.createSynthesizedNode(182); + cond.condition = condition; + cond.questionToken = ts.createSynthesizedNode(53); + cond.whenTrue = whenTrue; + cond.colonToken = ts.createSynthesizedNode(54); + cond.whenFalse = whenFalse; + return cond; + } + function createNumericLiteral(value) { + var node = ts.createSynthesizedNode(8); + node.text = "" + value; + return node; + } + function createPropertyAccessForDestructuringProperty(object, propName) { + var syntheticName = ts.createSynthesizedNode(propName.kind); + syntheticName.text = propName.text; + if (syntheticName.kind !== 69) { + return createElementAccessExpression(object, syntheticName); + } + return createPropertyAccessExpression(object, syntheticName); + } + function createSliceCall(value, sliceIndex) { + var call = ts.createSynthesizedNode(168); + var sliceIdentifier = ts.createSynthesizedNode(69); + sliceIdentifier.text = "slice"; + call.expression = createPropertyAccessExpression(value, sliceIdentifier); + call.arguments = ts.createSynthesizedNodeArray(); + call.arguments[0] = createNumericLiteral(sliceIndex); + return call; + } + function emitObjectLiteralAssignment(target, value) { + var properties = target.properties; + if (properties.length !== 1) { + value = ensureIdentifier(value, true); + } + for (var _a = 0; _a < properties.length; _a++) { + var p = properties[_a]; + if (p.kind === 245 || p.kind === 246) { + var propName = p.name; + var target_1 = p.kind === 246 ? p : p.initializer || propName; + emitDestructuringAssignment(target_1, createPropertyAccessForDestructuringProperty(value, propName)); + } + } + } + function emitArrayLiteralAssignment(target, value) { + var elements = target.elements; + if (elements.length !== 1) { + value = ensureIdentifier(value, true); + } + for (var i = 0; i < elements.length; i++) { + var e = elements[i]; + if (e.kind !== 187) { + if (e.kind !== 185) { + emitDestructuringAssignment(e, createElementAccessExpression(value, createNumericLiteral(i))); + } + else if (i === elements.length - 1) { + emitDestructuringAssignment(e.expression, createSliceCall(value, i)); + } + } + } + } + function emitDestructuringAssignment(target, value) { + if (target.kind === 246) { + if (target.objectAssignmentInitializer) { + value = createDefaultValueCheck(value, target.objectAssignmentInitializer); + } + target = target.name; + } + else if (target.kind === 181 && target.operatorToken.kind === 56) { + value = createDefaultValueCheck(value, target.right); + target = target.left; + } + if (target.kind === 165) { + emitObjectLiteralAssignment(target, value); + } + else if (target.kind === 164) { + emitArrayLiteralAssignment(target, value); + } + else { + emitAssignment(target, value, emitCount > 0); + emitCount++; + } + } + function emitAssignmentExpression(root) { + var target = root.left; + var value = root.right; + if (ts.isEmptyObjectLiteralOrArrayLiteral(target)) { + emit(value); + } + else if (isAssignmentExpressionStatement) { + emitDestructuringAssignment(target, value); + } + else { + if (root.parent.kind !== 172) { + write("("); + } + value = ensureIdentifier(value, true); + emitDestructuringAssignment(target, value); + write(", "); + emit(value); + if (root.parent.kind !== 172) { + write(")"); + } + } + } + function emitBindingElement(target, value) { + if (target.initializer) { + value = value ? createDefaultValueCheck(value, target.initializer) : target.initializer; + } + else if (!value) { + value = createVoidZero(); + } + if (ts.isBindingPattern(target.name)) { + var pattern = target.name; + var elements = pattern.elements; + var numElements = elements.length; + if (numElements !== 1) { + value = ensureIdentifier(value, numElements !== 0); + } + for (var i = 0; i < numElements; i++) { + var element = elements[i]; + if (pattern.kind === 161) { + var propName = element.propertyName || element.name; + emitBindingElement(element, createPropertyAccessForDestructuringProperty(value, propName)); + } + else if (element.kind !== 187) { + if (!element.dotDotDotToken) { + emitBindingElement(element, createElementAccessExpression(value, createNumericLiteral(i))); + } + else if (i === numElements - 1) { + emitBindingElement(element, createSliceCall(value, i)); + } + } + } + } + else { + emitAssignment(target.name, value, emitCount > 0); + emitCount++; + } + } + } + function emitVariableDeclaration(node) { + if (ts.isBindingPattern(node.name)) { + if (languageVersion < 2) { + emitDestructuring(node, false); + } + else { + emit(node.name); + emitOptional(" = ", node.initializer); + } + } + else { + var initializer = node.initializer; + if (!initializer && languageVersion < 2) { + var isLetDefinedInLoop = (resolver.getNodeCheckFlags(node) & 16384) && + (getCombinedFlagsForIdentifier(node.name) & 16384); + if (isLetDefinedInLoop && + node.parent.parent.kind !== 200 && + node.parent.parent.kind !== 201) { + initializer = createVoidZero(); + } + } + var exportChanged = isNameOfExportedSourceLevelDeclarationInSystemExternalModule(node.name); + if (exportChanged) { + write(exportFunctionForFile + "(\""); + emitNodeWithCommentsAndWithoutSourcemap(node.name); + write("\", "); + } + emitModuleMemberName(node); + emitOptional(" = ", initializer); + if (exportChanged) { + write(")"); + } + } + } + function emitExportVariableAssignments(node) { + if (node.kind === 187) { + return; + } + var name = node.name; + if (name.kind === 69) { + emitExportMemberAssignments(name); + } + else if (ts.isBindingPattern(name)) { + ts.forEach(name.elements, emitExportVariableAssignments); + } + } + function getCombinedFlagsForIdentifier(node) { + if (!node.parent || (node.parent.kind !== 211 && node.parent.kind !== 163)) { + return 0; + } + return ts.getCombinedNodeFlags(node.parent); + } + function isES6ExportedDeclaration(node) { + return !!(node.flags & 1) && + modulekind === 5 && + node.parent.kind === 248; + } + function emitVariableStatement(node) { + var startIsEmitted = false; + if (node.flags & 1) { + if (isES6ExportedDeclaration(node)) { + write("export "); + startIsEmitted = tryEmitStartOfVariableDeclarationList(node.declarationList); + } + } + else { + startIsEmitted = tryEmitStartOfVariableDeclarationList(node.declarationList); + } + if (startIsEmitted) { + emitCommaList(node.declarationList.declarations); + write(";"); + } + else { + var atLeastOneItem = emitVariableDeclarationListSkippingUninitializedEntries(node.declarationList); + if (atLeastOneItem) { + write(";"); + } + } + if (modulekind !== 5 && node.parent === currentSourceFile) { + ts.forEach(node.declarationList.declarations, emitExportVariableAssignments); + } + } + function shouldEmitLeadingAndTrailingCommentsForVariableStatement(node) { + if (!(node.flags & 1)) { + return true; + } + if (isES6ExportedDeclaration(node)) { + return true; + } + for (var _a = 0, _b = node.declarationList.declarations; _a < _b.length; _a++) { + var declaration = _b[_a]; + if (declaration.initializer) { + return true; + } + } + return false; + } + function emitParameter(node) { + if (languageVersion < 2) { + if (ts.isBindingPattern(node.name)) { + var name_25 = createTempVariable(0); + if (!tempParameters) { + tempParameters = []; + } + tempParameters.push(name_25); + emit(name_25); + } + else { + emit(node.name); + } + } + else { + if (node.dotDotDotToken) { + write("..."); + } + emit(node.name); + emitOptional(" = ", node.initializer); + } + } + function emitDefaultValueAssignments(node) { + if (languageVersion < 2) { + var tempIndex = 0; + ts.forEach(node.parameters, function (parameter) { + if (parameter.dotDotDotToken) { + return; + } + var paramName = parameter.name, initializer = parameter.initializer; + if (ts.isBindingPattern(paramName)) { + var hasBindingElements = paramName.elements.length > 0; + if (hasBindingElements || initializer) { + writeLine(); + write("var "); + if (hasBindingElements) { + emitDestructuring(parameter, false, tempParameters[tempIndex]); + } + else { + emit(tempParameters[tempIndex]); + write(" = "); + emit(initializer); + } + write(";"); + tempIndex++; + } + } + else if (initializer) { + writeLine(); + emitStart(parameter); + write("if ("); + emitNodeWithoutSourceMap(paramName); + write(" === void 0)"); + emitEnd(parameter); + write(" { "); + emitStart(parameter); + emitNodeWithCommentsAndWithoutSourcemap(paramName); + write(" = "); + emitNodeWithCommentsAndWithoutSourcemap(initializer); + emitEnd(parameter); + write("; }"); + } + }); + } + } + function emitRestParameter(node) { + if (languageVersion < 2 && ts.hasRestParameter(node)) { + var restIndex = node.parameters.length - 1; + var restParam = node.parameters[restIndex]; + if (ts.isBindingPattern(restParam.name)) { + return; + } + var tempName = createTempVariable(268435456).text; + writeLine(); + emitLeadingComments(restParam); + emitStart(restParam); + write("var "); + emitNodeWithCommentsAndWithoutSourcemap(restParam.name); + write(" = [];"); + emitEnd(restParam); + emitTrailingComments(restParam); + writeLine(); + write("for ("); + emitStart(restParam); + write("var " + tempName + " = " + restIndex + ";"); + emitEnd(restParam); + write(" "); + emitStart(restParam); + write(tempName + " < arguments.length;"); + emitEnd(restParam); + write(" "); + emitStart(restParam); + write(tempName + "++"); + emitEnd(restParam); + write(") {"); + increaseIndent(); + writeLine(); + emitStart(restParam); + emitNodeWithCommentsAndWithoutSourcemap(restParam.name); + write("[" + tempName + " - " + restIndex + "] = arguments[" + tempName + "];"); + emitEnd(restParam); + decreaseIndent(); + writeLine(); + write("}"); + } + } + function emitAccessor(node) { + write(node.kind === 145 ? "get " : "set "); + emit(node.name); + emitSignatureAndBody(node); + } + function shouldEmitAsArrowFunction(node) { + return node.kind === 174 && languageVersion >= 2; + } + function emitDeclarationName(node) { + if (node.name) { + emitNodeWithCommentsAndWithoutSourcemap(node.name); + } + else { + write(getGeneratedNameForNode(node)); + } + } + function shouldEmitFunctionName(node) { + if (node.kind === 173) { + return !!node.name; + } + if (node.kind === 213) { + return !!node.name || languageVersion < 2; + } + } + function emitFunctionDeclaration(node) { + if (ts.nodeIsMissing(node.body)) { + return emitCommentsOnNotEmittedNode(node); + } + if (node.kind !== 143 && node.kind !== 142 && + node.parent && node.parent.kind !== 245 && + node.parent.kind !== 168) { + emitLeadingComments(node); + } + emitStart(node); + if (!shouldEmitAsArrowFunction(node)) { + if (isES6ExportedDeclaration(node)) { + write("export "); + if (node.flags & 1024) { + write("default "); + } + } + write("function"); + if (languageVersion >= 2 && node.asteriskToken) { + write("*"); + } + write(" "); + } + if (shouldEmitFunctionName(node)) { + emitDeclarationName(node); + } + emitSignatureAndBody(node); + if (modulekind !== 5 && node.kind === 213 && node.parent === currentSourceFile && node.name) { + emitExportMemberAssignments(node.name); + } + emitEnd(node); + if (node.kind !== 143 && node.kind !== 142) { + emitTrailingComments(node); + } + } + function emitCaptureThisForNodeIfNecessary(node) { + if (resolver.getNodeCheckFlags(node) & 4) { + writeLine(); + emitStart(node); + write("var _this = this;"); + emitEnd(node); + } + } + function emitSignatureParameters(node) { + increaseIndent(); + write("("); + if (node) { + var parameters = node.parameters; + var omitCount = languageVersion < 2 && ts.hasRestParameter(node) ? 1 : 0; + emitList(parameters, 0, parameters.length - omitCount, false, false); + } + write(")"); + decreaseIndent(); + } + function emitSignatureParametersForArrow(node) { + if (node.parameters.length === 1 && node.pos === node.parameters[0].pos) { + emit(node.parameters[0]); + return; + } + emitSignatureParameters(node); + } + function emitAsyncFunctionBodyForES6(node) { + var promiseConstructor = ts.getEntityNameFromTypeNode(node.type); + var isArrowFunction = node.kind === 174; + var hasLexicalArguments = (resolver.getNodeCheckFlags(node) & 4096) !== 0; + var args; + if (!isArrowFunction) { + write(" {"); + increaseIndent(); + writeLine(); + write("return"); + } + write(" __awaiter(this"); + if (hasLexicalArguments) { + write(", arguments"); + } + else { + write(", void 0"); + } + if (promiseConstructor) { + write(", "); + emitNodeWithoutSourceMap(promiseConstructor); + } + else { + write(", Promise"); + } + if (hasLexicalArguments) { + write(", function* (_arguments)"); + } + else { + write(", function* ()"); + } + emitFunctionBody(node); + write(")"); + if (!isArrowFunction) { + write(";"); + decreaseIndent(); + writeLine(); + write("}"); + } + } + function emitFunctionBody(node) { + if (!node.body) { + write(" { }"); + } + else { + if (node.body.kind === 192) { + emitBlockFunctionBody(node, node.body); + } + else { + emitExpressionFunctionBody(node, node.body); + } + } + } + function emitSignatureAndBody(node) { + var saveConvertedLoopState = convertedLoopState; + var saveTempFlags = tempFlags; + var saveTempVariables = tempVariables; + var saveTempParameters = tempParameters; + convertedLoopState = undefined; + tempFlags = 0; + tempVariables = undefined; + tempParameters = undefined; + if (shouldEmitAsArrowFunction(node)) { + emitSignatureParametersForArrow(node); + write(" =>"); + } + else { + emitSignatureParameters(node); + } + var isAsync = ts.isAsyncFunctionLike(node); + if (isAsync && languageVersion === 2) { + emitAsyncFunctionBodyForES6(node); + } + else { + emitFunctionBody(node); + } + if (!isES6ExportedDeclaration(node)) { + emitExportMemberAssignment(node); + } + ts.Debug.assert(convertedLoopState === undefined); + convertedLoopState = saveConvertedLoopState; + tempFlags = saveTempFlags; + tempVariables = saveTempVariables; + tempParameters = saveTempParameters; + } + function emitFunctionBodyPreamble(node) { + emitCaptureThisForNodeIfNecessary(node); + emitDefaultValueAssignments(node); + emitRestParameter(node); + } + function emitExpressionFunctionBody(node, body) { + if (languageVersion < 2 || node.flags & 512) { + emitDownLevelExpressionFunctionBody(node, body); + return; + } + write(" "); + var current = body; + while (current.kind === 171) { + current = current.expression; + } + emitParenthesizedIf(body, current.kind === 165); + } + function emitDownLevelExpressionFunctionBody(node, body) { + write(" {"); + scopeEmitStart(node); + increaseIndent(); + var outPos = writer.getTextPos(); + emitDetachedComments(node.body); + emitFunctionBodyPreamble(node); + var preambleEmitted = writer.getTextPos() !== outPos; + decreaseIndent(); + if (!preambleEmitted && nodeStartPositionsAreOnSameLine(node, body)) { + write(" "); + emitStart(body); + write("return "); + emit(body); + emitEnd(body); + write(";"); + emitTempDeclarations(false); + write(" "); + } + else { + increaseIndent(); + writeLine(); + emitLeadingComments(node.body); + write("return "); + emit(body); + write(";"); + emitTrailingComments(node.body); + emitTempDeclarations(true); + decreaseIndent(); + writeLine(); + } + emitStart(node.body); + write("}"); + emitEnd(node.body); + scopeEmitEnd(); + } + function emitBlockFunctionBody(node, body) { + write(" {"); + scopeEmitStart(node); + var initialTextPos = writer.getTextPos(); + increaseIndent(); + emitDetachedComments(body.statements); + var startIndex = emitDirectivePrologues(body.statements, true); + emitFunctionBodyPreamble(node); + decreaseIndent(); + var preambleEmitted = writer.getTextPos() !== initialTextPos; + if (!preambleEmitted && nodeEndIsOnSameLineAsNodeStart(body, body)) { + for (var _a = 0, _b = body.statements; _a < _b.length; _a++) { + var statement = _b[_a]; + write(" "); + emit(statement); + } + emitTempDeclarations(false); + write(" "); + emitLeadingCommentsOfPosition(body.statements.end); + } + else { + increaseIndent(); + emitLinesStartingAt(body.statements, startIndex); + emitTempDeclarations(true); + writeLine(); + emitLeadingCommentsOfPosition(body.statements.end); + decreaseIndent(); + } + emitToken(16, body.statements.end); + scopeEmitEnd(); + } + function findInitialSuperCall(ctor) { + if (ctor.body) { + var statement = ctor.body.statements[0]; + if (statement && statement.kind === 195) { + var expr = statement.expression; + if (expr && expr.kind === 168) { + var func = expr.expression; + if (func && func.kind === 95) { + return statement; + } + } + } + } + } + function emitParameterPropertyAssignments(node) { + ts.forEach(node.parameters, function (param) { + if (param.flags & 112) { + writeLine(); + emitStart(param); + emitStart(param.name); + write("this."); + emitNodeWithoutSourceMap(param.name); + emitEnd(param.name); + write(" = "); + emit(param.name); + write(";"); + emitEnd(param); + } + }); + } + function emitMemberAccessForPropertyName(memberName) { + if (memberName.kind === 9 || memberName.kind === 8) { + write("["); + emitNodeWithCommentsAndWithoutSourcemap(memberName); + write("]"); + } + else if (memberName.kind === 136) { + emitComputedPropertyName(memberName); + } + else { + write("."); + emitNodeWithCommentsAndWithoutSourcemap(memberName); + } + } + function getInitializedProperties(node, isStatic) { + var properties = []; + for (var _a = 0, _b = node.members; _a < _b.length; _a++) { + var member = _b[_a]; + if (member.kind === 141 && isStatic === ((member.flags & 128) !== 0) && member.initializer) { + properties.push(member); + } + } + return properties; + } + function emitPropertyDeclarations(node, properties) { + for (var _a = 0; _a < properties.length; _a++) { + var property = properties[_a]; + emitPropertyDeclaration(node, property); + } + } + function emitPropertyDeclaration(node, property, receiver, isExpression) { + writeLine(); + emitLeadingComments(property); + emitStart(property); + emitStart(property.name); + if (receiver) { + emit(receiver); + } + else { + if (property.flags & 128) { + emitDeclarationName(node); + } + else { + write("this"); + } + } + emitMemberAccessForPropertyName(property.name); + emitEnd(property.name); + write(" = "); + emit(property.initializer); + if (!isExpression) { + write(";"); + } + emitEnd(property); + emitTrailingComments(property); + } + function emitMemberFunctionsForES5AndLower(node) { + ts.forEach(node.members, function (member) { + if (member.kind === 191) { + writeLine(); + write(";"); + } + else if (member.kind === 143 || node.kind === 142) { + if (!member.body) { + return emitCommentsOnNotEmittedNode(member); + } + writeLine(); + emitLeadingComments(member); + emitStart(member); + emitStart(member.name); + emitClassMemberPrefix(node, member); + emitMemberAccessForPropertyName(member.name); + emitEnd(member.name); + write(" = "); + emitFunctionDeclaration(member); + emitEnd(member); + write(";"); + emitTrailingComments(member); + } + else if (member.kind === 145 || member.kind === 146) { + var accessors = ts.getAllAccessorDeclarations(node.members, member); + if (member === accessors.firstAccessor) { + writeLine(); + emitStart(member); + write("Object.defineProperty("); + emitStart(member.name); + emitClassMemberPrefix(node, member); + write(", "); + emitExpressionForPropertyName(member.name); + emitEnd(member.name); + write(", {"); + increaseIndent(); + if (accessors.getAccessor) { + writeLine(); + emitLeadingComments(accessors.getAccessor); + write("get: "); + emitStart(accessors.getAccessor); + write("function "); + emitSignatureAndBody(accessors.getAccessor); + emitEnd(accessors.getAccessor); + emitTrailingComments(accessors.getAccessor); + write(","); + } + if (accessors.setAccessor) { + writeLine(); + emitLeadingComments(accessors.setAccessor); + write("set: "); + emitStart(accessors.setAccessor); + write("function "); + emitSignatureAndBody(accessors.setAccessor); + emitEnd(accessors.setAccessor); + emitTrailingComments(accessors.setAccessor); + write(","); + } + writeLine(); + write("enumerable: true,"); + writeLine(); + write("configurable: true"); + decreaseIndent(); + writeLine(); + write("});"); + emitEnd(member); + } + } + }); + } + function emitMemberFunctionsForES6AndHigher(node) { + for (var _a = 0, _b = node.members; _a < _b.length; _a++) { + var member = _b[_a]; + if ((member.kind === 143 || node.kind === 142) && !member.body) { + emitCommentsOnNotEmittedNode(member); + } + else if (member.kind === 143 || + member.kind === 145 || + member.kind === 146) { + writeLine(); + emitLeadingComments(member); + emitStart(member); + if (member.flags & 128) { + write("static "); + } + if (member.kind === 145) { + write("get "); + } + else if (member.kind === 146) { + write("set "); + } + if (member.asteriskToken) { + write("*"); + } + emit(member.name); + emitSignatureAndBody(member); + emitEnd(member); + emitTrailingComments(member); + } + else if (member.kind === 191) { + writeLine(); + write(";"); + } + } + } + function emitConstructor(node, baseTypeElement) { + var saveConvertedLoopState = convertedLoopState; + var saveTempFlags = tempFlags; + var saveTempVariables = tempVariables; + var saveTempParameters = tempParameters; + convertedLoopState = undefined; + tempFlags = 0; + tempVariables = undefined; + tempParameters = undefined; + emitConstructorWorker(node, baseTypeElement); + ts.Debug.assert(convertedLoopState === undefined); + convertedLoopState = saveConvertedLoopState; + tempFlags = saveTempFlags; + tempVariables = saveTempVariables; + tempParameters = saveTempParameters; + } + function emitConstructorWorker(node, baseTypeElement) { + var hasInstancePropertyWithInitializer = false; + ts.forEach(node.members, function (member) { + if (member.kind === 144 && !member.body) { + emitCommentsOnNotEmittedNode(member); + } + if (member.kind === 141 && member.initializer && (member.flags & 128) === 0) { + hasInstancePropertyWithInitializer = true; + } + }); + var ctor = ts.getFirstConstructorWithBody(node); + if (languageVersion >= 2 && !ctor && !hasInstancePropertyWithInitializer) { + return; + } + if (ctor) { + emitLeadingComments(ctor); + } + emitStart(ctor || node); + if (languageVersion < 2) { + write("function "); + emitDeclarationName(node); + emitSignatureParameters(ctor); + } + else { + write("constructor"); + if (ctor) { + emitSignatureParameters(ctor); + } + else { + if (baseTypeElement) { + write("(...args)"); + } + else { + write("()"); + } + } + } + var startIndex = 0; + write(" {"); + scopeEmitStart(node, "constructor"); + increaseIndent(); + if (ctor) { + startIndex = emitDirectivePrologues(ctor.body.statements, true); + emitDetachedComments(ctor.body.statements); + } + emitCaptureThisForNodeIfNecessary(node); + var superCall; + if (ctor) { + emitDefaultValueAssignments(ctor); + emitRestParameter(ctor); + if (baseTypeElement) { + superCall = findInitialSuperCall(ctor); + if (superCall) { + writeLine(); + emit(superCall); + } + } + emitParameterPropertyAssignments(ctor); + } + else { + if (baseTypeElement) { + writeLine(); + emitStart(baseTypeElement); + if (languageVersion < 2) { + write("_super.apply(this, arguments);"); + } + else { + write("super(...args);"); + } + emitEnd(baseTypeElement); + } + } + emitPropertyDeclarations(node, getInitializedProperties(node, false)); + if (ctor) { + var statements = ctor.body.statements; + if (superCall) { + statements = statements.slice(1); + } + emitLinesStartingAt(statements, startIndex); + } + emitTempDeclarations(true); + writeLine(); + if (ctor) { + emitLeadingCommentsOfPosition(ctor.body.statements.end); + } + decreaseIndent(); + emitToken(16, ctor ? ctor.body.statements.end : node.members.end); + scopeEmitEnd(); + emitEnd(ctor || node); + if (ctor) { + emitTrailingComments(ctor); + } + } + function emitClassExpression(node) { + return emitClassLikeDeclaration(node); + } + function emitClassDeclaration(node) { + return emitClassLikeDeclaration(node); + } + function emitClassLikeDeclaration(node) { + if (languageVersion < 2) { + emitClassLikeDeclarationBelowES6(node); + } + else { + emitClassLikeDeclarationForES6AndHigher(node); + } + if (modulekind !== 5 && node.parent === currentSourceFile && node.name) { + emitExportMemberAssignments(node.name); + } + } + function emitClassLikeDeclarationForES6AndHigher(node) { + var thisNodeIsDecorated = ts.nodeIsDecorated(node); + if (node.kind === 214) { + if (thisNodeIsDecorated) { + if (isES6ExportedDeclaration(node) && !(node.flags & 1024)) { + write("export "); + } + write("let "); + emitDeclarationName(node); + write(" = "); + } + else if (isES6ExportedDeclaration(node)) { + write("export "); + if (node.flags & 1024) { + write("default "); + } + } + } + var staticProperties = getInitializedProperties(node, true); + var isClassExpressionWithStaticProperties = staticProperties.length > 0 && node.kind === 186; + var tempVariable; + if (isClassExpressionWithStaticProperties) { + tempVariable = createAndRecordTempVariable(0); + write("("); + increaseIndent(); + emit(tempVariable); + write(" = "); + } + write("class"); + if ((node.name || (node.flags & 1024 && staticProperties.length > 0)) && !thisNodeIsDecorated) { + write(" "); + emitDeclarationName(node); + } + var baseTypeNode = ts.getClassExtendsHeritageClauseElement(node); + if (baseTypeNode) { + write(" extends "); + emit(baseTypeNode.expression); + } + write(" {"); + increaseIndent(); + scopeEmitStart(node); + writeLine(); + emitConstructor(node, baseTypeNode); + emitMemberFunctionsForES6AndHigher(node); + decreaseIndent(); + writeLine(); + emitToken(16, node.members.end); + scopeEmitEnd(); + if (thisNodeIsDecorated) { + write(";"); + } + if (isClassExpressionWithStaticProperties) { + for (var _a = 0; _a < staticProperties.length; _a++) { + var property = staticProperties[_a]; + write(","); + writeLine(); + emitPropertyDeclaration(node, property, tempVariable, true); + } + write(","); + writeLine(); + emit(tempVariable); + decreaseIndent(); + write(")"); + } + else { + writeLine(); + emitPropertyDeclarations(node, staticProperties); + emitDecoratorsOfClass(node); + } + if (!isES6ExportedDeclaration(node) && (node.flags & 1)) { + writeLine(); + emitStart(node); + emitModuleMemberName(node); + write(" = "); + emitDeclarationName(node); + emitEnd(node); + write(";"); + } + else if (isES6ExportedDeclaration(node) && (node.flags & 1024) && thisNodeIsDecorated) { + writeLine(); + write("export default "); + emitDeclarationName(node); + write(";"); + } + } + function emitClassLikeDeclarationBelowES6(node) { + if (node.kind === 214) { + if (!shouldHoistDeclarationInSystemJsModule(node)) { + write("var "); + } + emitDeclarationName(node); + write(" = "); + } + write("(function ("); + var baseTypeNode = ts.getClassExtendsHeritageClauseElement(node); + if (baseTypeNode) { + write("_super"); + } + write(") {"); + var saveTempFlags = tempFlags; + var saveTempVariables = tempVariables; + var saveTempParameters = tempParameters; + var saveComputedPropertyNamesToGeneratedNames = computedPropertyNamesToGeneratedNames; + var saveConvertedLoopState = convertedLoopState; + convertedLoopState = undefined; + tempFlags = 0; + tempVariables = undefined; + tempParameters = undefined; + computedPropertyNamesToGeneratedNames = undefined; + increaseIndent(); + scopeEmitStart(node); + if (baseTypeNode) { + writeLine(); + emitStart(baseTypeNode); + write("__extends("); + emitDeclarationName(node); + write(", _super);"); + emitEnd(baseTypeNode); + } + writeLine(); + emitConstructor(node, baseTypeNode); + emitMemberFunctionsForES5AndLower(node); + emitPropertyDeclarations(node, getInitializedProperties(node, true)); + writeLine(); + emitDecoratorsOfClass(node); + writeLine(); + emitToken(16, node.members.end, function () { + write("return "); + emitDeclarationName(node); + }); + write(";"); + emitTempDeclarations(true); + ts.Debug.assert(convertedLoopState === undefined); + convertedLoopState = saveConvertedLoopState; + tempFlags = saveTempFlags; + tempVariables = saveTempVariables; + tempParameters = saveTempParameters; + computedPropertyNamesToGeneratedNames = saveComputedPropertyNamesToGeneratedNames; + decreaseIndent(); + writeLine(); + emitToken(16, node.members.end); + scopeEmitEnd(); + emitStart(node); + write(")("); + if (baseTypeNode) { + emit(baseTypeNode.expression); + } + write(")"); + if (node.kind === 214) { + write(";"); + } + emitEnd(node); + if (node.kind === 214) { + emitExportMemberAssignment(node); + } + } + function emitClassMemberPrefix(node, member) { + emitDeclarationName(node); + if (!(member.flags & 128)) { + write(".prototype"); + } + } + function emitDecoratorsOfClass(node) { + emitDecoratorsOfMembers(node, 0); + emitDecoratorsOfMembers(node, 128); + emitDecoratorsOfConstructor(node); + } + function emitDecoratorsOfConstructor(node) { + var decorators = node.decorators; + var constructor = ts.getFirstConstructorWithBody(node); + var hasDecoratedParameters = constructor && ts.forEach(constructor.parameters, ts.nodeIsDecorated); + if (!decorators && !hasDecoratedParameters) { + return; + } + writeLine(); + emitStart(node); + emitDeclarationName(node); + write(" = __decorate(["); + increaseIndent(); + writeLine(); + var decoratorCount = decorators ? decorators.length : 0; + var argumentsWritten = emitList(decorators, 0, decoratorCount, true, false, false, true, function (decorator) { + emitStart(decorator); + emit(decorator.expression); + emitEnd(decorator); + }); + argumentsWritten += emitDecoratorsOfParameters(constructor, argumentsWritten > 0); + emitSerializedTypeMetadata(node, argumentsWritten >= 0); + decreaseIndent(); + writeLine(); + write("], "); + emitDeclarationName(node); + write(");"); + emitEnd(node); + writeLine(); + } + function emitDecoratorsOfMembers(node, staticFlag) { + for (var _a = 0, _b = node.members; _a < _b.length; _a++) { + var member = _b[_a]; + if ((member.flags & 128) !== staticFlag) { + continue; + } + if (!ts.nodeCanBeDecorated(member)) { + continue; + } + if (!ts.nodeOrChildIsDecorated(member)) { + continue; + } + var decorators = void 0; + var functionLikeMember = void 0; + if (ts.isAccessor(member)) { + var accessors = ts.getAllAccessorDeclarations(node.members, member); + if (member !== accessors.firstAccessor) { + continue; + } + decorators = accessors.firstAccessor.decorators; + if (!decorators && accessors.secondAccessor) { + decorators = accessors.secondAccessor.decorators; + } + functionLikeMember = accessors.setAccessor; + } + else { + decorators = member.decorators; + if (member.kind === 143) { + functionLikeMember = member; + } + } + writeLine(); + emitStart(member); + write("__decorate(["); + increaseIndent(); + writeLine(); + var decoratorCount = decorators ? decorators.length : 0; + var argumentsWritten = emitList(decorators, 0, decoratorCount, true, false, false, true, function (decorator) { + emitStart(decorator); + emit(decorator.expression); + emitEnd(decorator); + }); + argumentsWritten += emitDecoratorsOfParameters(functionLikeMember, argumentsWritten > 0); + emitSerializedTypeMetadata(member, argumentsWritten > 0); + decreaseIndent(); + writeLine(); + write("], "); + emitStart(member.name); + emitClassMemberPrefix(node, member); + write(", "); + emitExpressionForPropertyName(member.name); + emitEnd(member.name); + if (languageVersion > 0) { + if (member.kind !== 141) { + write(", null"); + } + else { + write(", void 0"); + } + } + write(");"); + emitEnd(member); + writeLine(); + } + } + function emitDecoratorsOfParameters(node, leadingComma) { + var argumentsWritten = 0; + if (node) { + var parameterIndex = 0; + for (var _a = 0, _b = node.parameters; _a < _b.length; _a++) { + var parameter = _b[_a]; + if (ts.nodeIsDecorated(parameter)) { + var decorators = parameter.decorators; + argumentsWritten += emitList(decorators, 0, decorators.length, true, false, leadingComma, true, function (decorator) { + emitStart(decorator); + write("__param(" + parameterIndex + ", "); + emit(decorator.expression); + write(")"); + emitEnd(decorator); + }); + leadingComma = true; + } + ++parameterIndex; + } + } + return argumentsWritten; + } + function shouldEmitTypeMetadata(node) { + switch (node.kind) { + case 143: + case 145: + case 146: + case 141: + return true; + } + return false; + } + function shouldEmitReturnTypeMetadata(node) { + switch (node.kind) { + case 143: + return true; + } + return false; + } + function shouldEmitParamTypesMetadata(node) { + switch (node.kind) { + case 214: + case 143: + case 146: + return true; + } + return false; + } + function emitSerializedTypeOfNode(node) { + switch (node.kind) { + case 214: + write("Function"); + return; + case 141: + emitSerializedTypeNode(node.type); + return; + case 138: + emitSerializedTypeNode(node.type); + return; + case 145: + emitSerializedTypeNode(node.type); + return; + case 146: + emitSerializedTypeNode(ts.getSetAccessorTypeAnnotationNode(node)); + return; + } + if (ts.isFunctionLike(node)) { + write("Function"); + return; + } + write("void 0"); + } + function emitSerializedTypeNode(node) { + if (node) { + switch (node.kind) { + case 103: + write("void 0"); + return; + case 160: + emitSerializedTypeNode(node.type); + return; + case 152: + case 153: + write("Function"); + return; + case 156: + case 157: + write("Array"); + return; + case 150: + case 120: + write("Boolean"); + return; + case 130: + case 9: + write("String"); + return; + case 128: + write("Number"); + return; + case 131: + write("Symbol"); + return; + case 151: + emitSerializedTypeReferenceNode(node); + return; + case 154: + case 155: + case 158: + case 159: + case 117: + break; + default: + ts.Debug.fail("Cannot serialize unexpected type node."); + break; + } + } + write("Object"); + } + function emitSerializedTypeReferenceNode(node) { + var location = node.parent; + while (ts.isDeclaration(location) || ts.isTypeNode(location)) { + location = location.parent; + } + var typeName = ts.cloneEntityName(node.typeName); + typeName.parent = location; + var result = resolver.getTypeReferenceSerializationKind(typeName); + switch (result) { + case ts.TypeReferenceSerializationKind.Unknown: + var temp = createAndRecordTempVariable(0); + write("(typeof ("); + emitNodeWithoutSourceMap(temp); + write(" = "); + emitEntityNameAsExpression(typeName, true); + write(") === 'function' && "); + emitNodeWithoutSourceMap(temp); + write(") || Object"); + break; + case ts.TypeReferenceSerializationKind.TypeWithConstructSignatureAndValue: + emitEntityNameAsExpression(typeName, false); + break; + case ts.TypeReferenceSerializationKind.VoidType: + write("void 0"); + break; + case ts.TypeReferenceSerializationKind.BooleanType: + write("Boolean"); + break; + case ts.TypeReferenceSerializationKind.NumberLikeType: + write("Number"); + break; + case ts.TypeReferenceSerializationKind.StringLikeType: + write("String"); + break; + case ts.TypeReferenceSerializationKind.ArrayLikeType: + write("Array"); + break; + case ts.TypeReferenceSerializationKind.ESSymbolType: + if (languageVersion < 2) { + write("typeof Symbol === 'function' ? Symbol : Object"); + } + else { + write("Symbol"); + } + break; + case ts.TypeReferenceSerializationKind.TypeWithCallSignature: + write("Function"); + break; + case ts.TypeReferenceSerializationKind.ObjectType: + write("Object"); + break; + } + } + function emitSerializedParameterTypesOfNode(node) { + if (node) { + var valueDeclaration; + if (node.kind === 214) { + valueDeclaration = ts.getFirstConstructorWithBody(node); + } + else if (ts.isFunctionLike(node) && ts.nodeIsPresent(node.body)) { + valueDeclaration = node; + } + if (valueDeclaration) { + var parameters = valueDeclaration.parameters; + var parameterCount = parameters.length; + if (parameterCount > 0) { + for (var i = 0; i < parameterCount; i++) { + if (i > 0) { + write(", "); + } + if (parameters[i].dotDotDotToken) { + var parameterType = parameters[i].type; + if (parameterType.kind === 156) { + parameterType = parameterType.elementType; + } + else if (parameterType.kind === 151 && parameterType.typeArguments && parameterType.typeArguments.length === 1) { + parameterType = parameterType.typeArguments[0]; + } + else { + parameterType = undefined; + } + emitSerializedTypeNode(parameterType); + } + else { + emitSerializedTypeOfNode(parameters[i]); + } + } + } + } + } + } + function emitSerializedReturnTypeOfNode(node) { + if (node && ts.isFunctionLike(node) && node.type) { + emitSerializedTypeNode(node.type); + return; + } + write("void 0"); + } + function emitSerializedTypeMetadata(node, writeComma) { + var argumentsWritten = 0; + if (compilerOptions.emitDecoratorMetadata) { + if (shouldEmitTypeMetadata(node)) { + if (writeComma) { + write(", "); + } + writeLine(); + write("__metadata('design:type', "); + emitSerializedTypeOfNode(node); + write(")"); + argumentsWritten++; + } + if (shouldEmitParamTypesMetadata(node)) { + if (writeComma || argumentsWritten) { + write(", "); + } + writeLine(); + write("__metadata('design:paramtypes', ["); + emitSerializedParameterTypesOfNode(node); + write("])"); + argumentsWritten++; + } + if (shouldEmitReturnTypeMetadata(node)) { + if (writeComma || argumentsWritten) { + write(", "); + } + writeLine(); + write("__metadata('design:returntype', "); + emitSerializedReturnTypeOfNode(node); + write(")"); + argumentsWritten++; + } + } + return argumentsWritten; + } + function emitInterfaceDeclaration(node) { + emitCommentsOnNotEmittedNode(node); + } + function shouldEmitEnumDeclaration(node) { + var isConstEnum = ts.isConst(node); + return !isConstEnum || compilerOptions.preserveConstEnums || compilerOptions.isolatedModules; + } + function emitEnumDeclaration(node) { + if (!shouldEmitEnumDeclaration(node)) { + return; + } + if (!shouldHoistDeclarationInSystemJsModule(node)) { + if (!(node.flags & 1) || isES6ExportedDeclaration(node)) { + emitStart(node); + if (isES6ExportedDeclaration(node)) { + write("export "); + } + write("var "); + emit(node.name); + emitEnd(node); + write(";"); + } + } + writeLine(); + emitStart(node); + write("(function ("); + emitStart(node.name); + write(getGeneratedNameForNode(node)); + emitEnd(node.name); + write(") {"); + increaseIndent(); + scopeEmitStart(node); + emitLines(node.members); + decreaseIndent(); + writeLine(); + emitToken(16, node.members.end); + scopeEmitEnd(); + write(")("); + emitModuleMemberName(node); + write(" || ("); + emitModuleMemberName(node); + write(" = {}));"); + emitEnd(node); + if (!isES6ExportedDeclaration(node) && node.flags & 1 && !shouldHoistDeclarationInSystemJsModule(node)) { + writeLine(); + emitStart(node); + write("var "); + emit(node.name); + write(" = "); + emitModuleMemberName(node); + emitEnd(node); + write(";"); + } + if (modulekind !== 5 && node.parent === currentSourceFile) { + if (modulekind === 4 && (node.flags & 1)) { + writeLine(); + write(exportFunctionForFile + "(\""); + emitDeclarationName(node); + write("\", "); + emitDeclarationName(node); + write(");"); + } + emitExportMemberAssignments(node.name); + } + } + function emitEnumMember(node) { + var enumParent = node.parent; + emitStart(node); + write(getGeneratedNameForNode(enumParent)); + write("["); + write(getGeneratedNameForNode(enumParent)); + write("["); + emitExpressionForPropertyName(node.name); + write("] = "); + writeEnumMemberDeclarationValue(node); + write("] = "); + emitExpressionForPropertyName(node.name); + emitEnd(node); + write(";"); + } + function writeEnumMemberDeclarationValue(member) { + var value = resolver.getConstantValue(member); + if (value !== undefined) { + write(value.toString()); + return; + } + else if (member.initializer) { + emit(member.initializer); + } + else { + write("undefined"); + } + } + function getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration) { + if (moduleDeclaration.body.kind === 218) { + var recursiveInnerModule = getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration.body); + return recursiveInnerModule || moduleDeclaration.body; + } + } + function shouldEmitModuleDeclaration(node) { + return ts.isInstantiatedModule(node, compilerOptions.preserveConstEnums || compilerOptions.isolatedModules); + } + function isModuleMergedWithES6Class(node) { + return languageVersion === 2 && !!(resolver.getNodeCheckFlags(node) & 32768); + } + function emitModuleDeclaration(node) { + var shouldEmit = shouldEmitModuleDeclaration(node); + if (!shouldEmit) { + return emitCommentsOnNotEmittedNode(node); + } + var hoistedInDeclarationScope = shouldHoistDeclarationInSystemJsModule(node); + var emitVarForModule = !hoistedInDeclarationScope && !isModuleMergedWithES6Class(node); + if (emitVarForModule) { + emitStart(node); + if (isES6ExportedDeclaration(node)) { + write("export "); + } + write("var "); + emit(node.name); + write(";"); + emitEnd(node); + writeLine(); + } + emitStart(node); + write("(function ("); + emitStart(node.name); + write(getGeneratedNameForNode(node)); + emitEnd(node.name); + write(") "); + if (node.body.kind === 219) { + var saveConvertedLoopState = convertedLoopState; + var saveTempFlags = tempFlags; + var saveTempVariables = tempVariables; + convertedLoopState = undefined; + tempFlags = 0; + tempVariables = undefined; + emit(node.body); + ts.Debug.assert(convertedLoopState === undefined); + convertedLoopState = saveConvertedLoopState; + tempFlags = saveTempFlags; + tempVariables = saveTempVariables; + } + else { + write("{"); + increaseIndent(); + scopeEmitStart(node); + emitCaptureThisForNodeIfNecessary(node); + writeLine(); + emit(node.body); + decreaseIndent(); + writeLine(); + var moduleBlock = getInnerMostModuleDeclarationFromDottedModule(node).body; + emitToken(16, moduleBlock.statements.end); + scopeEmitEnd(); + } + write(")("); + if ((node.flags & 1) && !isES6ExportedDeclaration(node)) { + emit(node.name); + write(" = "); + } + emitModuleMemberName(node); + write(" || ("); + emitModuleMemberName(node); + write(" = {}));"); + emitEnd(node); + if (!isES6ExportedDeclaration(node) && node.name.kind === 69 && node.parent === currentSourceFile) { + if (modulekind === 4 && (node.flags & 1)) { + writeLine(); + write(exportFunctionForFile + "(\""); + emitDeclarationName(node); + write("\", "); + emitDeclarationName(node); + write(");"); + } + emitExportMemberAssignments(node.name); + } + } + function tryRenameExternalModule(moduleName) { + if (currentSourceFile.renamedDependencies && ts.hasProperty(currentSourceFile.renamedDependencies, moduleName.text)) { + return "\"" + currentSourceFile.renamedDependencies[moduleName.text] + "\""; + } + return undefined; + } + function emitRequire(moduleName) { + if (moduleName.kind === 9) { + write("require("); + var text = tryRenameExternalModule(moduleName); + if (text) { + write(text); + } + else { + emitStart(moduleName); + emitLiteral(moduleName); + emitEnd(moduleName); + } + emitToken(18, moduleName.end); + } + else { + write("require()"); + } + } + function getNamespaceDeclarationNode(node) { + if (node.kind === 221) { + return node; + } + var importClause = node.importClause; + if (importClause && importClause.namedBindings && importClause.namedBindings.kind === 224) { + return importClause.namedBindings; + } + } + function isDefaultImport(node) { + return node.kind === 222 && node.importClause && !!node.importClause.name; + } + function emitExportImportAssignments(node) { + if (ts.isAliasSymbolDeclaration(node) && resolver.isValueAliasDeclaration(node)) { + emitExportMemberAssignments(node.name); + } + ts.forEachChild(node, emitExportImportAssignments); + } + function emitImportDeclaration(node) { + if (modulekind !== 5) { + return emitExternalImportDeclaration(node); + } + if (node.importClause) { + var shouldEmitDefaultBindings = resolver.isReferencedAliasDeclaration(node.importClause); + var shouldEmitNamedBindings = node.importClause.namedBindings && resolver.isReferencedAliasDeclaration(node.importClause.namedBindings, true); + if (shouldEmitDefaultBindings || shouldEmitNamedBindings) { + write("import "); + emitStart(node.importClause); + if (shouldEmitDefaultBindings) { + emit(node.importClause.name); + if (shouldEmitNamedBindings) { + write(", "); + } + } + if (shouldEmitNamedBindings) { + emitLeadingComments(node.importClause.namedBindings); + emitStart(node.importClause.namedBindings); + if (node.importClause.namedBindings.kind === 224) { + write("* as "); + emit(node.importClause.namedBindings.name); + } + else { + write("{ "); + emitExportOrImportSpecifierList(node.importClause.namedBindings.elements, resolver.isReferencedAliasDeclaration); + write(" }"); + } + emitEnd(node.importClause.namedBindings); + emitTrailingComments(node.importClause.namedBindings); + } + emitEnd(node.importClause); + write(" from "); + emit(node.moduleSpecifier); + write(";"); + } + } + else { + write("import "); + emit(node.moduleSpecifier); + write(";"); + } + } + function emitExternalImportDeclaration(node) { + if (ts.contains(externalImports, node)) { + var isExportedImport = node.kind === 221 && (node.flags & 1) !== 0; + var namespaceDeclaration = getNamespaceDeclarationNode(node); + if (modulekind !== 2) { + emitLeadingComments(node); + emitStart(node); + if (namespaceDeclaration && !isDefaultImport(node)) { + if (!isExportedImport) + write("var "); + emitModuleMemberName(namespaceDeclaration); + write(" = "); + } + else { + var isNakedImport = 222 && !node.importClause; + if (!isNakedImport) { + write("var "); + write(getGeneratedNameForNode(node)); + write(" = "); + } + } + emitRequire(ts.getExternalModuleName(node)); + if (namespaceDeclaration && isDefaultImport(node)) { + write(", "); + emitModuleMemberName(namespaceDeclaration); + write(" = "); + write(getGeneratedNameForNode(node)); + } + write(";"); + emitEnd(node); + emitExportImportAssignments(node); + emitTrailingComments(node); + } + else { + if (isExportedImport) { + emitModuleMemberName(namespaceDeclaration); + write(" = "); + emit(namespaceDeclaration.name); + write(";"); + } + else if (namespaceDeclaration && isDefaultImport(node)) { + write("var "); + emitModuleMemberName(namespaceDeclaration); + write(" = "); + write(getGeneratedNameForNode(node)); + write(";"); + } + emitExportImportAssignments(node); + } + } + } + function emitImportEqualsDeclaration(node) { + if (ts.isExternalModuleImportEqualsDeclaration(node)) { + emitExternalImportDeclaration(node); + return; + } + if (resolver.isReferencedAliasDeclaration(node) || + (!ts.isExternalModule(currentSourceFile) && resolver.isTopLevelValueImportEqualsWithEntityName(node))) { + emitLeadingComments(node); + emitStart(node); + var variableDeclarationIsHoisted = shouldHoistVariable(node, true); + var isExported = isSourceFileLevelDeclarationInSystemJsModule(node, true); + if (!variableDeclarationIsHoisted) { + ts.Debug.assert(!isExported); + if (isES6ExportedDeclaration(node)) { + write("export "); + write("var "); + } + else if (!(node.flags & 1)) { + write("var "); + } + } + if (isExported) { + write(exportFunctionForFile + "(\""); + emitNodeWithoutSourceMap(node.name); + write("\", "); + } + emitModuleMemberName(node); + write(" = "); + emit(node.moduleReference); + if (isExported) { + write(")"); + } + write(";"); + emitEnd(node); + emitExportImportAssignments(node); + emitTrailingComments(node); + } + } + function emitExportDeclaration(node) { + ts.Debug.assert(modulekind !== 4); + if (modulekind !== 5) { + if (node.moduleSpecifier && (!node.exportClause || resolver.isValueAliasDeclaration(node))) { + emitStart(node); + var generatedName = getGeneratedNameForNode(node); + if (node.exportClause) { + if (modulekind !== 2) { + write("var "); + write(generatedName); + write(" = "); + emitRequire(ts.getExternalModuleName(node)); + write(";"); + } + for (var _a = 0, _b = node.exportClause.elements; _a < _b.length; _a++) { + var specifier = _b[_a]; + if (resolver.isValueAliasDeclaration(specifier)) { + writeLine(); + emitStart(specifier); + emitContainingModuleName(specifier); + write("."); + emitNodeWithCommentsAndWithoutSourcemap(specifier.name); + write(" = "); + write(generatedName); + write("."); + emitNodeWithCommentsAndWithoutSourcemap(specifier.propertyName || specifier.name); + write(";"); + emitEnd(specifier); + } + } + } + else { + writeLine(); + write("__export("); + if (modulekind !== 2) { + emitRequire(ts.getExternalModuleName(node)); + } + else { + write(generatedName); + } + write(");"); + } + emitEnd(node); + } + } + else { + if (!node.exportClause || resolver.isValueAliasDeclaration(node)) { + write("export "); + if (node.exportClause) { + write("{ "); + emitExportOrImportSpecifierList(node.exportClause.elements, resolver.isValueAliasDeclaration); + write(" }"); + } + else { + write("*"); + } + if (node.moduleSpecifier) { + write(" from "); + emit(node.moduleSpecifier); + } + write(";"); + } + } + } + function emitExportOrImportSpecifierList(specifiers, shouldEmit) { + ts.Debug.assert(modulekind === 5); + var needsComma = false; + for (var _a = 0; _a < specifiers.length; _a++) { + var specifier = specifiers[_a]; + if (shouldEmit(specifier)) { + if (needsComma) { + write(", "); + } + if (specifier.propertyName) { + emit(specifier.propertyName); + write(" as "); + } + emit(specifier.name); + needsComma = true; + } + } + } + function emitExportAssignment(node) { + if (!node.isExportEquals && resolver.isValueAliasDeclaration(node)) { + if (modulekind === 5) { + writeLine(); + emitStart(node); + write("export default "); + var expression = node.expression; + emit(expression); + if (expression.kind !== 213 && + expression.kind !== 214) { + write(";"); + } + emitEnd(node); + } + else { + writeLine(); + emitStart(node); + if (modulekind === 4) { + write(exportFunctionForFile + "(\"default\","); + emit(node.expression); + write(")"); + } + else { + emitEs6ExportDefaultCompat(node); + emitContainingModuleName(node); + if (languageVersion === 0) { + write("[\"default\"] = "); + } + else { + write(".default = "); + } + emit(node.expression); + } + write(";"); + emitEnd(node); + } + } + } + function collectExternalModuleInfo(sourceFile) { + externalImports = []; + exportSpecifiers = {}; + exportEquals = undefined; + hasExportStars = false; + for (var _a = 0, _b = sourceFile.statements; _a < _b.length; _a++) { + var node = _b[_a]; + switch (node.kind) { + case 222: + if (!node.importClause || + resolver.isReferencedAliasDeclaration(node.importClause, true)) { + externalImports.push(node); + } + break; + case 221: + if (node.moduleReference.kind === 232 && resolver.isReferencedAliasDeclaration(node)) { + externalImports.push(node); + } + break; + case 228: + if (node.moduleSpecifier) { + if (!node.exportClause) { + externalImports.push(node); + hasExportStars = true; + } + else if (resolver.isValueAliasDeclaration(node)) { + externalImports.push(node); + } + } + else { + for (var _c = 0, _d = node.exportClause.elements; _c < _d.length; _c++) { + var specifier = _d[_c]; + var name_26 = (specifier.propertyName || specifier.name).text; + (exportSpecifiers[name_26] || (exportSpecifiers[name_26] = [])).push(specifier); + } + } + break; + case 227: + if (node.isExportEquals && !exportEquals) { + exportEquals = node; + } + break; + } + } + } + function emitExportStarHelper() { + if (hasExportStars) { + writeLine(); + write("function __export(m) {"); + increaseIndent(); + writeLine(); + write("for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];"); + decreaseIndent(); + writeLine(); + write("}"); + } + } + function getLocalNameForExternalImport(node) { + var namespaceDeclaration = getNamespaceDeclarationNode(node); + if (namespaceDeclaration && !isDefaultImport(node)) { + return ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, namespaceDeclaration.name); + } + if (node.kind === 222 && node.importClause) { + return getGeneratedNameForNode(node); + } + if (node.kind === 228 && node.moduleSpecifier) { + return getGeneratedNameForNode(node); + } + } + function getExternalModuleNameText(importNode) { + var moduleName = ts.getExternalModuleName(importNode); + if (moduleName.kind === 9) { + return tryRenameExternalModule(moduleName) || getLiteralText(moduleName); + } + return undefined; + } + function emitVariableDeclarationsForImports() { + if (externalImports.length === 0) { + return; + } + writeLine(); + var started = false; + for (var _a = 0; _a < externalImports.length; _a++) { + var importNode = externalImports[_a]; + var skipNode = importNode.kind === 228 || + (importNode.kind === 222 && !importNode.importClause); + if (skipNode) { + continue; + } + if (!started) { + write("var "); + started = true; + } + else { + write(", "); + } + write(getLocalNameForExternalImport(importNode)); + } + if (started) { + write(";"); + } + } + function emitLocalStorageForExportedNamesIfNecessary(exportedDeclarations) { + if (!hasExportStars) { + return undefined; + } + if (!exportedDeclarations && ts.isEmpty(exportSpecifiers)) { + var hasExportDeclarationWithExportClause = false; + for (var _a = 0; _a < externalImports.length; _a++) { + var externalImport = externalImports[_a]; + if (externalImport.kind === 228 && externalImport.exportClause) { + hasExportDeclarationWithExportClause = true; + break; + } + } + if (!hasExportDeclarationWithExportClause) { + return emitExportStarFunction(undefined); + } + } + var exportedNamesStorageRef = makeUniqueName("exportedNames"); + writeLine(); + write("var " + exportedNamesStorageRef + " = {"); + increaseIndent(); + var started = false; + if (exportedDeclarations) { + for (var i = 0; i < exportedDeclarations.length; ++i) { + writeExportedName(exportedDeclarations[i]); + } + } + if (exportSpecifiers) { + for (var n in exportSpecifiers) { + for (var _b = 0, _c = exportSpecifiers[n]; _b < _c.length; _b++) { + var specifier = _c[_b]; + writeExportedName(specifier.name); + } + } + } + for (var _d = 0; _d < externalImports.length; _d++) { + var externalImport = externalImports[_d]; + if (externalImport.kind !== 228) { + continue; + } + var exportDecl = externalImport; + if (!exportDecl.exportClause) { + continue; + } + for (var _e = 0, _f = exportDecl.exportClause.elements; _e < _f.length; _e++) { + var element = _f[_e]; + writeExportedName(element.name || element.propertyName); + } + } + decreaseIndent(); + writeLine(); + write("};"); + return emitExportStarFunction(exportedNamesStorageRef); + function emitExportStarFunction(localNames) { + var exportStarFunction = makeUniqueName("exportStar"); + writeLine(); + write("function " + exportStarFunction + "(m) {"); + increaseIndent(); + writeLine(); + write("var exports = {};"); + writeLine(); + write("for(var n in m) {"); + increaseIndent(); + writeLine(); + write("if (n !== \"default\""); + if (localNames) { + write("&& !" + localNames + ".hasOwnProperty(n)"); + } + write(") exports[n] = m[n];"); + decreaseIndent(); + writeLine(); + write("}"); + writeLine(); + write(exportFunctionForFile + "(exports);"); + decreaseIndent(); + writeLine(); + write("}"); + return exportStarFunction; + } + function writeExportedName(node) { + if (node.kind !== 69 && node.flags & 1024) { + return; + } + if (started) { + write(","); + } + else { + started = true; + } + writeLine(); + write("'"); + if (node.kind === 69) { + emitNodeWithCommentsAndWithoutSourcemap(node); + } + else { + emitDeclarationName(node); + } + write("': true"); + } + } + function processTopLevelVariableAndFunctionDeclarations(node) { + var hoistedVars; + var hoistedFunctionDeclarations; + var exportedDeclarations; + visit(node); + if (hoistedVars) { + writeLine(); + write("var "); + var seen = {}; + for (var i = 0; i < hoistedVars.length; ++i) { + var local = hoistedVars[i]; + var name_27 = local.kind === 69 + ? local + : local.name; + if (name_27) { + var text = ts.unescapeIdentifier(name_27.text); + if (ts.hasProperty(seen, text)) { + continue; + } + else { + seen[text] = text; + } + } + if (i !== 0) { + write(", "); + } + if (local.kind === 214 || local.kind === 218 || local.kind === 217) { + emitDeclarationName(local); + } + else { + emit(local); + } + var flags = ts.getCombinedNodeFlags(local.kind === 69 ? local.parent : local); + if (flags & 1) { + if (!exportedDeclarations) { + exportedDeclarations = []; + } + exportedDeclarations.push(local); + } + } + write(";"); + } + if (hoistedFunctionDeclarations) { + for (var _a = 0; _a < hoistedFunctionDeclarations.length; _a++) { + var f = hoistedFunctionDeclarations[_a]; + writeLine(); + emit(f); + if (f.flags & 1) { + if (!exportedDeclarations) { + exportedDeclarations = []; + } + exportedDeclarations.push(f); + } + } + } + return exportedDeclarations; + function visit(node) { + if (node.flags & 2) { + return; + } + if (node.kind === 213) { + if (!hoistedFunctionDeclarations) { + hoistedFunctionDeclarations = []; + } + hoistedFunctionDeclarations.push(node); + return; + } + if (node.kind === 214) { + if (!hoistedVars) { + hoistedVars = []; + } + hoistedVars.push(node); + return; + } + if (node.kind === 217) { + if (shouldEmitEnumDeclaration(node)) { + if (!hoistedVars) { + hoistedVars = []; + } + hoistedVars.push(node); + } + return; + } + if (node.kind === 218) { + if (shouldEmitModuleDeclaration(node)) { + if (!hoistedVars) { + hoistedVars = []; + } + hoistedVars.push(node); + } + return; + } + if (node.kind === 211 || node.kind === 163) { + if (shouldHoistVariable(node, false)) { + var name_28 = node.name; + if (name_28.kind === 69) { + if (!hoistedVars) { + hoistedVars = []; + } + hoistedVars.push(name_28); + } + else { + ts.forEachChild(name_28, visit); + } + } + return; + } + if (ts.isInternalModuleImportEqualsDeclaration(node) && resolver.isValueAliasDeclaration(node)) { + if (!hoistedVars) { + hoistedVars = []; + } + hoistedVars.push(node.name); + return; + } + if (ts.isBindingPattern(node)) { + ts.forEach(node.elements, visit); + return; + } + if (!ts.isDeclaration(node)) { + ts.forEachChild(node, visit); + } + } + } + function shouldHoistVariable(node, checkIfSourceFileLevelDecl) { + if (checkIfSourceFileLevelDecl && !shouldHoistDeclarationInSystemJsModule(node)) { + return false; + } + return (ts.getCombinedNodeFlags(node) & 49152) === 0 || + ts.getEnclosingBlockScopeContainer(node).kind === 248; + } + function isCurrentFileSystemExternalModule() { + return modulekind === 4 && ts.isExternalModule(currentSourceFile); + } + function emitSystemModuleBody(node, dependencyGroups, startIndex) { + emitVariableDeclarationsForImports(); + writeLine(); + var exportedDeclarations = processTopLevelVariableAndFunctionDeclarations(node); + var exportStarFunction = emitLocalStorageForExportedNamesIfNecessary(exportedDeclarations); + writeLine(); + write("return {"); + increaseIndent(); + writeLine(); + emitSetters(exportStarFunction, dependencyGroups); + writeLine(); + emitExecute(node, startIndex); + decreaseIndent(); + writeLine(); + write("}"); + emitTempDeclarations(true); + } + function emitSetters(exportStarFunction, dependencyGroups) { + write("setters:["); + for (var i = 0; i < dependencyGroups.length; ++i) { + if (i !== 0) { + write(","); + } + writeLine(); + increaseIndent(); + var group = dependencyGroups[i]; + var parameterName = makeUniqueName(ts.forEach(group, getLocalNameForExternalImport) || ""); + write("function (" + parameterName + ") {"); + increaseIndent(); + for (var _a = 0; _a < group.length; _a++) { + var entry = group[_a]; + var importVariableName = getLocalNameForExternalImport(entry) || ""; + switch (entry.kind) { + case 222: + if (!entry.importClause) { + break; + } + case 221: + ts.Debug.assert(importVariableName !== ""); + writeLine(); + write(importVariableName + " = " + parameterName + ";"); + writeLine(); + break; + case 228: + ts.Debug.assert(importVariableName !== ""); + if (entry.exportClause) { + writeLine(); + write(exportFunctionForFile + "({"); + writeLine(); + increaseIndent(); + for (var i_2 = 0, len = entry.exportClause.elements.length; i_2 < len; ++i_2) { + if (i_2 !== 0) { + write(","); + writeLine(); + } + var e = entry.exportClause.elements[i_2]; + write("\""); + emitNodeWithCommentsAndWithoutSourcemap(e.name); + write("\": " + parameterName + "[\""); + emitNodeWithCommentsAndWithoutSourcemap(e.propertyName || e.name); + write("\"]"); + } + decreaseIndent(); + writeLine(); + write("});"); + } + else { + writeLine(); + write(exportStarFunction + "(" + parameterName + ");"); + } + writeLine(); + break; + } + } + decreaseIndent(); + write("}"); + decreaseIndent(); + } + write("],"); + } + function emitExecute(node, startIndex) { + write("execute: function() {"); + increaseIndent(); + writeLine(); + for (var i = startIndex; i < node.statements.length; ++i) { + var statement = node.statements[i]; + switch (statement.kind) { + case 213: + case 222: + continue; + case 228: + if (!statement.moduleSpecifier) { + for (var _a = 0, _b = statement.exportClause.elements; _a < _b.length; _a++) { + var element = _b[_a]; + emitExportSpecifierInSystemModule(element); + } + } + continue; + case 221: + if (!ts.isInternalModuleImportEqualsDeclaration(statement)) { + continue; + } + default: + writeLine(); + emit(statement); + } + } + decreaseIndent(); + writeLine(); + write("}"); + } + function emitSystemModule(node) { + collectExternalModuleInfo(node); + ts.Debug.assert(!exportFunctionForFile); + exportFunctionForFile = makeUniqueName("exports"); + writeLine(); + write("System.register("); + if (node.moduleName) { + write("\"" + node.moduleName + "\", "); + } + write("["); + var groupIndices = {}; + var dependencyGroups = []; + for (var i = 0; i < externalImports.length; ++i) { + var text = getExternalModuleNameText(externalImports[i]); + if (ts.hasProperty(groupIndices, text)) { + var groupIndex = groupIndices[text]; + dependencyGroups[groupIndex].push(externalImports[i]); + continue; + } + else { + groupIndices[text] = dependencyGroups.length; + dependencyGroups.push([externalImports[i]]); + } + if (i !== 0) { + write(", "); + } + write(text); + } + write("], function(" + exportFunctionForFile + ") {"); + writeLine(); + increaseIndent(); + var startIndex = emitDirectivePrologues(node.statements, true); + emitEmitHelpers(node); + emitCaptureThisForNodeIfNecessary(node); + emitSystemModuleBody(node, dependencyGroups, startIndex); + decreaseIndent(); + writeLine(); + write("});"); + } + function getAMDDependencyNames(node, includeNonAmdDependencies) { + var aliasedModuleNames = []; + var unaliasedModuleNames = []; + var importAliasNames = []; + for (var _a = 0, _b = node.amdDependencies; _a < _b.length; _a++) { + var amdDependency = _b[_a]; + if (amdDependency.name) { + aliasedModuleNames.push("\"" + amdDependency.path + "\""); + importAliasNames.push(amdDependency.name); + } + else { + unaliasedModuleNames.push("\"" + amdDependency.path + "\""); + } + } + for (var _c = 0; _c < externalImports.length; _c++) { + var importNode = externalImports[_c]; + var externalModuleName = getExternalModuleNameText(importNode); + var importAliasName = getLocalNameForExternalImport(importNode); + if (includeNonAmdDependencies && importAliasName) { + aliasedModuleNames.push(externalModuleName); + importAliasNames.push(importAliasName); + } + else { + unaliasedModuleNames.push(externalModuleName); + } + } + return { aliasedModuleNames: aliasedModuleNames, unaliasedModuleNames: unaliasedModuleNames, importAliasNames: importAliasNames }; + } + function emitAMDDependencies(node, includeNonAmdDependencies) { + var dependencyNames = getAMDDependencyNames(node, includeNonAmdDependencies); + emitAMDDependencyList(dependencyNames); + write(", "); + emitAMDFactoryHeader(dependencyNames); + } + function emitAMDDependencyList(_a) { + var aliasedModuleNames = _a.aliasedModuleNames, unaliasedModuleNames = _a.unaliasedModuleNames; + write("[\"require\", \"exports\""); + if (aliasedModuleNames.length) { + write(", "); + write(aliasedModuleNames.join(", ")); + } + if (unaliasedModuleNames.length) { + write(", "); + write(unaliasedModuleNames.join(", ")); + } + write("]"); + } + function emitAMDFactoryHeader(_a) { + var importAliasNames = _a.importAliasNames; + write("function (require, exports"); + if (importAliasNames.length) { + write(", "); + write(importAliasNames.join(", ")); + } + write(") {"); + } + function emitAMDModule(node) { + emitEmitHelpers(node); + collectExternalModuleInfo(node); + writeLine(); + write("define("); + if (node.moduleName) { + write("\"" + node.moduleName + "\", "); + } + emitAMDDependencies(node, true); + increaseIndent(); + var startIndex = emitDirectivePrologues(node.statements, true); + emitExportStarHelper(); + emitCaptureThisForNodeIfNecessary(node); + emitLinesStartingAt(node.statements, startIndex); + emitTempDeclarations(true); + emitExportEquals(true); + decreaseIndent(); + writeLine(); + write("});"); + } + function emitCommonJSModule(node) { + var startIndex = emitDirectivePrologues(node.statements, false); + emitEmitHelpers(node); + collectExternalModuleInfo(node); + emitExportStarHelper(); + emitCaptureThisForNodeIfNecessary(node); + emitLinesStartingAt(node.statements, startIndex); + emitTempDeclarations(true); + emitExportEquals(false); + } + function emitUMDModule(node) { + emitEmitHelpers(node); + collectExternalModuleInfo(node); + var dependencyNames = getAMDDependencyNames(node, false); + writeLines("(function (factory) {\n if (typeof module === 'object' && typeof module.exports === 'object') {\n var v = factory(require, exports); if (v !== undefined) module.exports = v;\n }\n else if (typeof define === 'function' && define.amd) {\n define("); + emitAMDDependencyList(dependencyNames); + write(", factory);"); + writeLines(" }\n})("); + emitAMDFactoryHeader(dependencyNames); + increaseIndent(); + var startIndex = emitDirectivePrologues(node.statements, true); + emitExportStarHelper(); + emitCaptureThisForNodeIfNecessary(node); + emitLinesStartingAt(node.statements, startIndex); + emitTempDeclarations(true); + emitExportEquals(true); + decreaseIndent(); + writeLine(); + write("});"); + } + function emitES6Module(node) { + externalImports = undefined; + exportSpecifiers = undefined; + exportEquals = undefined; + hasExportStars = false; + var startIndex = emitDirectivePrologues(node.statements, false); + emitEmitHelpers(node); + emitCaptureThisForNodeIfNecessary(node); + emitLinesStartingAt(node.statements, startIndex); + emitTempDeclarations(true); + } + function emitExportEquals(emitAsReturn) { + if (exportEquals && resolver.isValueAliasDeclaration(exportEquals)) { + writeLine(); + emitStart(exportEquals); + write(emitAsReturn ? "return " : "module.exports = "); + emit(exportEquals.expression); + write(";"); + emitEnd(exportEquals); + } + } + function emitJsxElement(node) { + switch (compilerOptions.jsx) { + case 2: + jsxEmitReact(node); + break; + case 1: + default: + jsxEmitPreserve(node); + break; + } + } + function trimReactWhitespaceAndApplyEntities(node) { + var result = undefined; + var text = ts.getTextOfNode(node, true); + var firstNonWhitespace = 0; + var lastNonWhitespace = -1; + for (var i = 0; i < text.length; i++) { + var c = text.charCodeAt(i); + if (ts.isLineBreak(c)) { + if (firstNonWhitespace !== -1 && (lastNonWhitespace - firstNonWhitespace + 1 > 0)) { + var part = text.substr(firstNonWhitespace, lastNonWhitespace - firstNonWhitespace + 1); + result = (result ? result + "\" + ' ' + \"" : "") + ts.escapeString(part); + } + firstNonWhitespace = -1; + } + else if (!ts.isWhiteSpace(c)) { + lastNonWhitespace = i; + if (firstNonWhitespace === -1) { + firstNonWhitespace = i; + } + } + } + if (firstNonWhitespace !== -1) { + var part = text.substr(firstNonWhitespace); + result = (result ? result + "\" + ' ' + \"" : "") + ts.escapeString(part); + } + if (result) { + result = result.replace(/&(\w+);/g, function (s, m) { + if (entities[m] !== undefined) { + return String.fromCharCode(entities[m]); + } + else { + return s; + } + }); + } + return result; + } + function getTextToEmit(node) { + switch (compilerOptions.jsx) { + case 2: + var text = trimReactWhitespaceAndApplyEntities(node); + if (text === undefined || text.length === 0) { + return undefined; + } + else { + return text; + } + case 1: + default: + return ts.getTextOfNode(node, true); + } + } + function emitJsxText(node) { + switch (compilerOptions.jsx) { + case 2: + write("\""); + write(trimReactWhitespaceAndApplyEntities(node)); + write("\""); + break; + case 1: + default: + writer.writeLiteral(ts.getTextOfNode(node, true)); + break; + } + } + function emitJsxExpression(node) { + if (node.expression) { + switch (compilerOptions.jsx) { + case 1: + default: + write("{"); + emit(node.expression); + write("}"); + break; + case 2: + emit(node.expression); + break; + } + } + } + function emitDirectivePrologues(statements, startWithNewLine) { + for (var i = 0; i < statements.length; ++i) { + if (ts.isPrologueDirective(statements[i])) { + if (startWithNewLine || i > 0) { + writeLine(); + } + emit(statements[i]); + } + else { + return i; + } + } + return statements.length; + } + function writeLines(text) { + var lines = text.split(/\r\n|\r|\n/g); + for (var i = 0; i < lines.length; ++i) { + var line = lines[i]; + if (line.length) { + writeLine(); + write(line); + } + } + } + function emitEmitHelpers(node) { + if (!compilerOptions.noEmitHelpers) { + if ((languageVersion < 2) && (!extendsEmitted && resolver.getNodeCheckFlags(node) & 8)) { + writeLines(extendsHelper); + extendsEmitted = true; + } + if (!decorateEmitted && resolver.getNodeCheckFlags(node) & 16) { + writeLines(decorateHelper); + if (compilerOptions.emitDecoratorMetadata) { + writeLines(metadataHelper); + } + decorateEmitted = true; + } + if (!paramEmitted && resolver.getNodeCheckFlags(node) & 32) { + writeLines(paramHelper); + paramEmitted = true; + } + if (!awaiterEmitted && resolver.getNodeCheckFlags(node) & 64) { + writeLines(awaiterHelper); + awaiterEmitted = true; + } + } + } + function emitSourceFileNode(node) { + writeLine(); + emitShebang(); + emitDetachedComments(node); + if (ts.isExternalModule(node) || compilerOptions.isolatedModules) { + var emitModule = moduleEmitDelegates[modulekind] || moduleEmitDelegates[1]; + emitModule(node); + } + else { + var startIndex = emitDirectivePrologues(node.statements, false); + externalImports = undefined; + exportSpecifiers = undefined; + exportEquals = undefined; + hasExportStars = false; + emitEmitHelpers(node); + emitCaptureThisForNodeIfNecessary(node); + emitLinesStartingAt(node.statements, startIndex); + emitTempDeclarations(true); + } + emitLeadingComments(node.endOfFileToken); + } + function emitNodeWithCommentsAndWithoutSourcemap(node) { + emitNodeConsideringCommentsOption(node, emitNodeWithoutSourceMap); + } + function emitNodeConsideringCommentsOption(node, emitNodeConsideringSourcemap) { + if (node) { + if (node.flags & 2) { + return emitCommentsOnNotEmittedNode(node); + } + if (isSpecializedCommentHandling(node)) { + return emitNodeWithoutSourceMap(node); + } + var emitComments_1 = shouldEmitLeadingAndTrailingComments(node); + if (emitComments_1) { + emitLeadingComments(node); + } + emitNodeConsideringSourcemap(node); + if (emitComments_1) { + emitTrailingComments(node); + } + } + } + function emitNodeWithoutSourceMap(node) { + if (node) { + emitJavaScriptWorker(node); + } + } + function isSpecializedCommentHandling(node) { + switch (node.kind) { + case 215: + case 213: + case 222: + case 221: + case 216: + case 227: + return true; + } + } + function shouldEmitLeadingAndTrailingComments(node) { + switch (node.kind) { + case 193: + return shouldEmitLeadingAndTrailingCommentsForVariableStatement(node); + case 218: + return shouldEmitModuleDeclaration(node); + case 217: + return shouldEmitEnumDeclaration(node); + } + ts.Debug.assert(!isSpecializedCommentHandling(node)); + if (node.kind !== 192 && + node.parent && + node.parent.kind === 174 && + node.parent.body === node && + compilerOptions.target <= 1) { + return false; + } + return true; + } + function emitJavaScriptWorker(node) { + switch (node.kind) { + case 69: + return emitIdentifier(node); + case 138: + return emitParameter(node); + case 143: + case 142: + return emitMethod(node); + case 145: + case 146: + return emitAccessor(node); + case 97: + return emitThis(node); + case 95: + return emitSuper(node); + case 93: + return write("null"); + case 99: + return write("true"); + case 84: + return write("false"); + case 8: + case 9: + case 10: + case 11: + case 12: + case 13: + case 14: + return emitLiteral(node); + case 183: + return emitTemplateExpression(node); + case 190: + return emitTemplateSpan(node); + case 233: + case 234: + return emitJsxElement(node); + case 236: + return emitJsxText(node); + case 240: + return emitJsxExpression(node); + case 135: + return emitQualifiedName(node); + case 161: + return emitObjectBindingPattern(node); + case 162: + return emitArrayBindingPattern(node); + case 163: + return emitBindingElement(node); + case 164: + return emitArrayLiteral(node); + case 165: + return emitObjectLiteral(node); + case 245: + return emitPropertyAssignment(node); + case 246: + return emitShorthandPropertyAssignment(node); + case 136: + return emitComputedPropertyName(node); + case 166: + return emitPropertyAccess(node); + case 167: + return emitIndexedAccess(node); + case 168: + return emitCallExpression(node); + case 169: + return emitNewExpression(node); + case 170: + return emitTaggedTemplateExpression(node); + case 171: + return emit(node.expression); + case 189: + return emit(node.expression); + case 172: + return emitParenExpression(node); + case 213: + case 173: + case 174: + return emitFunctionDeclaration(node); + case 175: + return emitDeleteExpression(node); + case 176: + return emitTypeOfExpression(node); + case 177: + return emitVoidExpression(node); + case 178: + return emitAwaitExpression(node); + case 179: + return emitPrefixUnaryExpression(node); + case 180: + return emitPostfixUnaryExpression(node); + case 181: + return emitBinaryExpression(node); + case 182: + return emitConditionalExpression(node); + case 185: + return emitSpreadElementExpression(node); + case 184: + return emitYieldExpression(node); + case 187: + return; + case 192: + case 219: + return emitBlock(node); + case 193: + return emitVariableStatement(node); + case 194: + return write(";"); + case 195: + return emitExpressionStatement(node); + case 196: + return emitIfStatement(node); + case 197: + return emitDoStatement(node); + case 198: + return emitWhileStatement(node); + case 199: + return emitForStatement(node); + case 201: + case 200: + return emitForInOrForOfStatement(node); + case 202: + case 203: + return emitBreakOrContinueStatement(node); + case 204: + return emitReturnStatement(node); + case 205: + return emitWithStatement(node); + case 206: + return emitSwitchStatement(node); + case 241: + case 242: + return emitCaseOrDefaultClause(node); + case 207: + return emitLabeledStatement(node); + case 208: + return emitThrowStatement(node); + case 209: + return emitTryStatement(node); + case 244: + return emitCatchClause(node); + case 210: + return emitDebuggerStatement(node); + case 211: + return emitVariableDeclaration(node); + case 186: + return emitClassExpression(node); + case 214: + return emitClassDeclaration(node); + case 215: + return emitInterfaceDeclaration(node); + case 217: + return emitEnumDeclaration(node); + case 247: + return emitEnumMember(node); + case 218: + return emitModuleDeclaration(node); + case 222: + return emitImportDeclaration(node); + case 221: + return emitImportEqualsDeclaration(node); + case 228: + return emitExportDeclaration(node); + case 227: + return emitExportAssignment(node); + case 248: + return emitSourceFileNode(node); + } + } + function hasDetachedComments(pos) { + return detachedCommentsInfo !== undefined && ts.lastOrUndefined(detachedCommentsInfo).nodePos === pos; + } + function getLeadingCommentsWithoutDetachedComments() { + var leadingComments = ts.getLeadingCommentRanges(currentSourceFile.text, ts.lastOrUndefined(detachedCommentsInfo).detachedCommentEndPos); + if (detachedCommentsInfo.length - 1) { + detachedCommentsInfo.pop(); + } + else { + detachedCommentsInfo = undefined; + } + return leadingComments; + } + function isPinnedComments(comment) { + return currentSourceFile.text.charCodeAt(comment.pos + 1) === 42 && + currentSourceFile.text.charCodeAt(comment.pos + 2) === 33; + } + function isTripleSlashComment(comment) { + if (currentSourceFile.text.charCodeAt(comment.pos + 1) === 47 && + comment.pos + 2 < comment.end && + currentSourceFile.text.charCodeAt(comment.pos + 2) === 47) { + var textSubStr = currentSourceFile.text.substring(comment.pos, comment.end); + return textSubStr.match(ts.fullTripleSlashReferencePathRegEx) || + textSubStr.match(ts.fullTripleSlashAMDReferencePathRegEx) ? + true : false; + } + return false; + } + function getLeadingCommentsToEmit(node) { + if (node.parent) { + if (node.parent.kind === 248 || node.pos !== node.parent.pos) { + if (hasDetachedComments(node.pos)) { + return getLeadingCommentsWithoutDetachedComments(); + } + else { + return ts.getLeadingCommentRangesOfNode(node, currentSourceFile); + } + } + } + } + function getTrailingCommentsToEmit(node) { + if (node.parent) { + if (node.parent.kind === 248 || node.end !== node.parent.end) { + return ts.getTrailingCommentRanges(currentSourceFile.text, node.end); + } + } + } + function emitCommentsOnNotEmittedNode(node) { + emitLeadingCommentsWorker(node, false); + } + function emitLeadingComments(node) { + return emitLeadingCommentsWorker(node, true); + } + function emitLeadingCommentsWorker(node, isEmittedNode) { + if (compilerOptions.removeComments) { + return; + } + var leadingComments; + if (isEmittedNode) { + leadingComments = getLeadingCommentsToEmit(node); + } + else { + if (node.pos === 0) { + leadingComments = ts.filter(getLeadingCommentsToEmit(node), isTripleSlashComment); + } + } + ts.emitNewLineBeforeLeadingComments(currentSourceFile, writer, node, leadingComments); + ts.emitComments(currentSourceFile, writer, leadingComments, true, newLine, writeComment); + } + function emitTrailingComments(node) { + if (compilerOptions.removeComments) { + return; + } + var trailingComments = getTrailingCommentsToEmit(node); + ts.emitComments(currentSourceFile, writer, trailingComments, false, newLine, writeComment); + } + function emitTrailingCommentsOfPosition(pos) { + if (compilerOptions.removeComments) { + return; + } + var trailingComments = ts.getTrailingCommentRanges(currentSourceFile.text, pos); + ts.emitComments(currentSourceFile, writer, trailingComments, true, newLine, writeComment); + } + function emitLeadingCommentsOfPositionWorker(pos) { + if (compilerOptions.removeComments) { + return; + } + var leadingComments; + if (hasDetachedComments(pos)) { + leadingComments = getLeadingCommentsWithoutDetachedComments(); + } + else { + leadingComments = ts.getLeadingCommentRanges(currentSourceFile.text, pos); + } + ts.emitNewLineBeforeLeadingComments(currentSourceFile, writer, { pos: pos, end: pos }, leadingComments); + ts.emitComments(currentSourceFile, writer, leadingComments, true, newLine, writeComment); + } + function emitDetachedComments(node) { + var leadingComments; + if (compilerOptions.removeComments) { + if (node.pos === 0) { + leadingComments = ts.filter(ts.getLeadingCommentRanges(currentSourceFile.text, node.pos), isPinnedComments); + } + } + else { + leadingComments = ts.getLeadingCommentRanges(currentSourceFile.text, node.pos); + } + if (leadingComments) { + var detachedComments = []; + var lastComment; + ts.forEach(leadingComments, function (comment) { + if (lastComment) { + var lastCommentLine = ts.getLineOfLocalPosition(currentSourceFile, lastComment.end); + var commentLine = ts.getLineOfLocalPosition(currentSourceFile, comment.pos); + if (commentLine >= lastCommentLine + 2) { + return detachedComments; + } + } + detachedComments.push(comment); + lastComment = comment; + }); + if (detachedComments.length) { + var lastCommentLine = ts.getLineOfLocalPosition(currentSourceFile, ts.lastOrUndefined(detachedComments).end); + var nodeLine = ts.getLineOfLocalPosition(currentSourceFile, ts.skipTrivia(currentSourceFile.text, node.pos)); + if (nodeLine >= lastCommentLine + 2) { + ts.emitNewLineBeforeLeadingComments(currentSourceFile, writer, node, leadingComments); + ts.emitComments(currentSourceFile, writer, detachedComments, true, newLine, writeComment); + var currentDetachedCommentInfo = { nodePos: node.pos, detachedCommentEndPos: ts.lastOrUndefined(detachedComments).end }; + if (detachedCommentsInfo) { + detachedCommentsInfo.push(currentDetachedCommentInfo); + } + else { + detachedCommentsInfo = [currentDetachedCommentInfo]; + } + } + } + } + } + function emitShebang() { + var shebang = ts.getShebang(currentSourceFile.text); + if (shebang) { + write(shebang); + } + } + var _a; + } + function emitFile(jsFilePath, sourceFile) { + emitJavaScript(jsFilePath, sourceFile); + if (compilerOptions.declaration) { + ts.writeDeclarationFile(jsFilePath, sourceFile, host, resolver, diagnostics); + } + } + } + ts.emitFiles = emitFiles; +})(ts || (ts = {})); +var ts; +(function (ts) { + ts.programTime = 0; + ts.emitTime = 0; + ts.ioReadTime = 0; + ts.ioWriteTime = 0; + var emptyArray = []; + ts.version = "1.8.0"; + function findConfigFile(searchPath) { + var fileName = "tsconfig.json"; + while (true) { + if (ts.sys.fileExists(fileName)) { + return fileName; + } + var parentPath = ts.getDirectoryPath(searchPath); + if (parentPath === searchPath) { + break; + } + searchPath = parentPath; + fileName = "../" + fileName; + } + return undefined; + } + ts.findConfigFile = findConfigFile; + function resolveTripleslashReference(moduleName, containingFile) { + var basePath = ts.getDirectoryPath(containingFile); + var referencedFileName = ts.isRootedDiskPath(moduleName) ? moduleName : ts.combinePaths(basePath, moduleName); + return ts.normalizePath(referencedFileName); + } + ts.resolveTripleslashReference = resolveTripleslashReference; + function resolveModuleName(moduleName, containingFile, compilerOptions, host) { + var moduleResolution = compilerOptions.moduleResolution !== undefined + ? compilerOptions.moduleResolution + : compilerOptions.module === 1 ? 2 : 1; + switch (moduleResolution) { + case 2: return nodeModuleNameResolver(moduleName, containingFile, host); + case 1: return classicNameResolver(moduleName, containingFile, compilerOptions, host); + } + } + ts.resolveModuleName = resolveModuleName; + function nodeModuleNameResolver(moduleName, containingFile, host) { + var containingDirectory = ts.getDirectoryPath(containingFile); + if (ts.getRootLength(moduleName) !== 0 || nameStartsWithDotSlashOrDotDotSlash(moduleName)) { + var failedLookupLocations = []; + var candidate = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName)); + var resolvedFileName = loadNodeModuleFromFile(candidate, failedLookupLocations, host); + if (resolvedFileName) { + return { resolvedModule: { resolvedFileName: resolvedFileName }, failedLookupLocations: failedLookupLocations }; + } + resolvedFileName = loadNodeModuleFromDirectory(candidate, failedLookupLocations, host); + return resolvedFileName + ? { resolvedModule: { resolvedFileName: resolvedFileName }, failedLookupLocations: failedLookupLocations } + : { resolvedModule: undefined, failedLookupLocations: failedLookupLocations }; + } + else { + return loadModuleFromNodeModules(moduleName, containingDirectory, host); + } + } + ts.nodeModuleNameResolver = nodeModuleNameResolver; + function loadNodeModuleFromFile(candidate, failedLookupLocation, host) { + return ts.forEach(ts.moduleFileExtensions, tryLoad); + function tryLoad(ext) { + var fileName = ts.fileExtensionIs(candidate, ext) ? candidate : candidate + ext; + if (host.fileExists(fileName)) { + return fileName; + } + else { + failedLookupLocation.push(fileName); + return undefined; + } + } + } + function loadNodeModuleFromDirectory(candidate, failedLookupLocation, host) { + var packageJsonPath = ts.combinePaths(candidate, "package.json"); + if (host.fileExists(packageJsonPath)) { + var jsonContent; + try { + var jsonText = host.readFile(packageJsonPath); + jsonContent = jsonText ? JSON.parse(jsonText) : { typings: undefined }; + } + catch (e) { + jsonContent = { typings: undefined }; + } + if (jsonContent.typings) { + var result = loadNodeModuleFromFile(ts.normalizePath(ts.combinePaths(candidate, jsonContent.typings)), failedLookupLocation, host); + if (result) { + return result; + } + } + } + else { + failedLookupLocation.push(packageJsonPath); + } + return loadNodeModuleFromFile(ts.combinePaths(candidate, "index"), failedLookupLocation, host); + } + function loadModuleFromNodeModules(moduleName, directory, host) { + var failedLookupLocations = []; + directory = ts.normalizeSlashes(directory); + while (true) { + var baseName = ts.getBaseFileName(directory); + if (baseName !== "node_modules") { + var nodeModulesFolder = ts.combinePaths(directory, "node_modules"); + var candidate = ts.normalizePath(ts.combinePaths(nodeModulesFolder, moduleName)); + var result = loadNodeModuleFromFile(candidate, failedLookupLocations, host); + if (result) { + return { resolvedModule: { resolvedFileName: result, isExternalLibraryImport: true }, failedLookupLocations: failedLookupLocations }; + } + result = loadNodeModuleFromDirectory(candidate, failedLookupLocations, host); + if (result) { + return { resolvedModule: { resolvedFileName: result, isExternalLibraryImport: true }, failedLookupLocations: failedLookupLocations }; + } + } + var parentPath = ts.getDirectoryPath(directory); + if (parentPath === directory) { + break; + } + directory = parentPath; + } + return { resolvedModule: undefined, failedLookupLocations: failedLookupLocations }; + } + function nameStartsWithDotSlashOrDotDotSlash(name) { + var i = name.lastIndexOf("./", 1); + return i === 0 || (i === 1 && name.charCodeAt(0) === 46); + } + function classicNameResolver(moduleName, containingFile, compilerOptions, host) { + if (moduleName.indexOf("!") != -1) { + return { resolvedModule: undefined, failedLookupLocations: [] }; + } + var searchPath = ts.getDirectoryPath(containingFile); + var searchName; + var failedLookupLocations = []; + var referencedSourceFile; + while (true) { + searchName = ts.normalizePath(ts.combinePaths(searchPath, moduleName)); + referencedSourceFile = ts.forEach(ts.supportedExtensions, function (extension) { + if (extension === ".tsx" && !compilerOptions.jsx) { + return undefined; + } + var candidate = searchName + extension; + if (host.fileExists(candidate)) { + return candidate; + } + else { + failedLookupLocations.push(candidate); + } + }); + if (referencedSourceFile) { + break; + } + var parentPath = ts.getDirectoryPath(searchPath); + if (parentPath === searchPath) { + break; + } + searchPath = parentPath; + } + return referencedSourceFile + ? { resolvedModule: { resolvedFileName: referencedSourceFile }, failedLookupLocations: failedLookupLocations } + : { resolvedModule: undefined, failedLookupLocations: failedLookupLocations }; + } + ts.classicNameResolver = classicNameResolver; + ts.defaultInitCompilerOptions = { + module: 1, + target: 0, + noImplicitAny: false, + outDir: "built", + rootDir: ".", + sourceMap: false + }; + function createCompilerHost(options, setParentNodes) { + var existingDirectories = {}; + function getCanonicalFileName(fileName) { + return ts.sys.useCaseSensitiveFileNames ? fileName : fileName.toLowerCase(); + } + var unsupportedFileEncodingErrorCode = -2147024809; + function getSourceFile(fileName, languageVersion, onError) { + var text; + try { + var start = new Date().getTime(); + text = ts.sys.readFile(fileName, options.charset); + ts.ioReadTime += new Date().getTime() - start; + } + catch (e) { + if (onError) { + onError(e.number === unsupportedFileEncodingErrorCode + ? ts.createCompilerDiagnostic(ts.Diagnostics.Unsupported_file_encoding).messageText + : e.message); + } + text = ""; + } + return text !== undefined ? ts.createSourceFile(fileName, text, languageVersion, setParentNodes) : undefined; + } + function directoryExists(directoryPath) { + if (ts.hasProperty(existingDirectories, directoryPath)) { + return true; + } + if (ts.sys.directoryExists(directoryPath)) { + existingDirectories[directoryPath] = true; + return true; + } + return false; + } + function ensureDirectoriesExist(directoryPath) { + if (directoryPath.length > ts.getRootLength(directoryPath) && !directoryExists(directoryPath)) { + var parentDirectory = ts.getDirectoryPath(directoryPath); + ensureDirectoriesExist(parentDirectory); + ts.sys.createDirectory(directoryPath); + } + } + function writeFile(fileName, data, writeByteOrderMark, onError) { + try { + var start = new Date().getTime(); + ensureDirectoriesExist(ts.getDirectoryPath(ts.normalizePath(fileName))); + ts.sys.writeFile(fileName, data, writeByteOrderMark); + ts.ioWriteTime += new Date().getTime() - start; + } + catch (e) { + if (onError) { + onError(e.message); + } + } + } + var newLine = ts.getNewLineCharacter(options); + return { + getSourceFile: getSourceFile, + getDefaultLibFileName: function (options) { return ts.combinePaths(ts.getDirectoryPath(ts.normalizePath(ts.sys.getExecutingFilePath())), ts.getDefaultLibFileName(options)); }, + writeFile: writeFile, + getCurrentDirectory: ts.memoize(function () { return ts.sys.getCurrentDirectory(); }), + useCaseSensitiveFileNames: function () { return ts.sys.useCaseSensitiveFileNames; }, + getCanonicalFileName: getCanonicalFileName, + getNewLine: function () { return newLine; }, + fileExists: function (fileName) { return ts.sys.fileExists(fileName); }, + readFile: function (fileName) { return ts.sys.readFile(fileName); } + }; + } + ts.createCompilerHost = createCompilerHost; + function getPreEmitDiagnostics(program, sourceFile, cancellationToken) { + var diagnostics = program.getOptionsDiagnostics(cancellationToken).concat(program.getSyntacticDiagnostics(sourceFile, cancellationToken), program.getGlobalDiagnostics(cancellationToken), program.getSemanticDiagnostics(sourceFile, cancellationToken)); + if (program.getCompilerOptions().declaration) { + diagnostics.concat(program.getDeclarationDiagnostics(sourceFile, cancellationToken)); + } + return ts.sortAndDeduplicateDiagnostics(diagnostics); + } + ts.getPreEmitDiagnostics = getPreEmitDiagnostics; + function flattenDiagnosticMessageText(messageText, newLine) { + if (typeof messageText === "string") { + return messageText; + } + else { + var diagnosticChain = messageText; + var result = ""; + var indent = 0; + while (diagnosticChain) { + if (indent) { + result += newLine; + for (var i = 0; i < indent; i++) { + result += " "; + } + } + result += diagnosticChain.messageText; + indent++; + diagnosticChain = diagnosticChain.next; + } + return result; + } + } + ts.flattenDiagnosticMessageText = flattenDiagnosticMessageText; + function createProgram(rootNames, options, host, oldProgram) { + var program; + var files = []; + var fileProcessingDiagnostics = ts.createDiagnosticCollection(); + var programDiagnostics = ts.createDiagnosticCollection(); + var commonSourceDirectory; + var diagnosticsProducingTypeChecker; + var noDiagnosticsTypeChecker; + var classifiableNames; + var skipDefaultLib = options.noLib; + var start = new Date().getTime(); + host = host || createCompilerHost(options); + var currentDirectory = host.getCurrentDirectory(); + var resolveModuleNamesWorker = host.resolveModuleNames + ? (function (moduleNames, containingFile) { return host.resolveModuleNames(moduleNames, containingFile); }) + : (function (moduleNames, containingFile) { return ts.map(moduleNames, function (moduleName) { return resolveModuleName(moduleName, containingFile, options, host).resolvedModule; }); }); + var filesByName = ts.createFileMap(getCanonicalFileName); + var filesByNameIgnoreCase = host.useCaseSensitiveFileNames() ? ts.createFileMap(function (fileName) { return fileName.toLowerCase(); }) : undefined; + if (oldProgram) { + var oldOptions = oldProgram.getCompilerOptions(); + if ((oldOptions.module !== options.module) || + (oldOptions.noResolve !== options.noResolve) || + (oldOptions.target !== options.target) || + (oldOptions.noLib !== options.noLib) || + (oldOptions.jsx !== options.jsx)) { + oldProgram = undefined; + } + } + if (!tryReuseStructureFromOldProgram()) { + ts.forEach(rootNames, function (name) { return processRootFile(name, false); }); + if (!skipDefaultLib) { + processRootFile(host.getDefaultLibFileName(options), true); + } + } + verifyCompilerOptions(); + oldProgram = undefined; + ts.programTime += new Date().getTime() - start; + program = { + getRootFileNames: function () { return rootNames; }, + getSourceFile: getSourceFile, + getSourceFiles: function () { return files; }, + getCompilerOptions: function () { return options; }, + getSyntacticDiagnostics: getSyntacticDiagnostics, + getOptionsDiagnostics: getOptionsDiagnostics, + getGlobalDiagnostics: getGlobalDiagnostics, + getSemanticDiagnostics: getSemanticDiagnostics, + getDeclarationDiagnostics: getDeclarationDiagnostics, + getTypeChecker: getTypeChecker, + getClassifiableNames: getClassifiableNames, + getDiagnosticsProducingTypeChecker: getDiagnosticsProducingTypeChecker, + getCommonSourceDirectory: function () { return commonSourceDirectory; }, + emit: emit, + getCurrentDirectory: function () { return currentDirectory; }, + getNodeCount: function () { return getDiagnosticsProducingTypeChecker().getNodeCount(); }, + getIdentifierCount: function () { return getDiagnosticsProducingTypeChecker().getIdentifierCount(); }, + getSymbolCount: function () { return getDiagnosticsProducingTypeChecker().getSymbolCount(); }, + getTypeCount: function () { return getDiagnosticsProducingTypeChecker().getTypeCount(); }, + getFileProcessingDiagnostics: function () { return fileProcessingDiagnostics; } + }; + return program; + function getClassifiableNames() { + if (!classifiableNames) { + getTypeChecker(); + classifiableNames = {}; + for (var _i = 0; _i < files.length; _i++) { + var sourceFile = files[_i]; + ts.copyMap(sourceFile.classifiableNames, classifiableNames); + } + } + return classifiableNames; + } + function tryReuseStructureFromOldProgram() { + if (!oldProgram) { + return false; + } + ts.Debug.assert(!oldProgram.structureIsReused); + var oldRootNames = oldProgram.getRootFileNames(); + if (!ts.arrayIsEqualTo(oldRootNames, rootNames)) { + return false; + } + var newSourceFiles = []; + var normalizedAbsoluteFileNames = []; + var modifiedSourceFiles = []; + for (var _i = 0, _a = oldProgram.getSourceFiles(); _i < _a.length; _i++) { + var oldSourceFile = _a[_i]; + var newSourceFile = host.getSourceFile(oldSourceFile.fileName, options.target); + if (!newSourceFile) { + return false; + } + var normalizedAbsolutePath = ts.getNormalizedAbsolutePath(newSourceFile.fileName, currentDirectory); + normalizedAbsoluteFileNames.push(normalizedAbsolutePath); + if (oldSourceFile !== newSourceFile) { + if (oldSourceFile.hasNoDefaultLib !== newSourceFile.hasNoDefaultLib) { + return false; + } + if (!ts.arrayIsEqualTo(oldSourceFile.referencedFiles, newSourceFile.referencedFiles, fileReferenceIsEqualTo)) { + return false; + } + collectExternalModuleReferences(newSourceFile); + if (!ts.arrayIsEqualTo(oldSourceFile.imports, newSourceFile.imports, moduleNameIsEqualTo)) { + return false; + } + if (resolveModuleNamesWorker) { + var moduleNames = ts.map(newSourceFile.imports, function (name) { return name.text; }); + var resolutions = resolveModuleNamesWorker(moduleNames, normalizedAbsolutePath); + for (var i = 0; i < moduleNames.length; ++i) { + var newResolution = resolutions[i]; + var oldResolution = ts.getResolvedModule(oldSourceFile, moduleNames[i]); + var resolutionChanged = oldResolution + ? !newResolution || + oldResolution.resolvedFileName !== newResolution.resolvedFileName || + !!oldResolution.isExternalLibraryImport !== !!newResolution.isExternalLibraryImport + : newResolution; + if (resolutionChanged) { + return false; + } + } + } + newSourceFile.resolvedModules = oldSourceFile.resolvedModules; + modifiedSourceFiles.push(newSourceFile); + } + else { + newSourceFile = oldSourceFile; + } + newSourceFiles.push(newSourceFile); + } + for (var i = 0, len = newSourceFiles.length; i < len; ++i) { + filesByName.set(normalizedAbsoluteFileNames[i], newSourceFiles[i]); + } + files = newSourceFiles; + fileProcessingDiagnostics = oldProgram.getFileProcessingDiagnostics(); + for (var _b = 0; _b < modifiedSourceFiles.length; _b++) { + var modifiedFile = modifiedSourceFiles[_b]; + fileProcessingDiagnostics.reattachFileDiagnostics(modifiedFile); + } + oldProgram.structureIsReused = true; + return true; + } + function getEmitHost(writeFileCallback) { + return { + getCanonicalFileName: getCanonicalFileName, + getCommonSourceDirectory: program.getCommonSourceDirectory, + getCompilerOptions: program.getCompilerOptions, + getCurrentDirectory: function () { return currentDirectory; }, + getNewLine: function () { return host.getNewLine(); }, + getSourceFile: program.getSourceFile, + getSourceFiles: program.getSourceFiles, + writeFile: writeFileCallback || (function (fileName, data, writeByteOrderMark, onError) { return host.writeFile(fileName, data, writeByteOrderMark, onError); }) + }; + } + function getDiagnosticsProducingTypeChecker() { + return diagnosticsProducingTypeChecker || (diagnosticsProducingTypeChecker = ts.createTypeChecker(program, true)); + } + function getTypeChecker() { + return noDiagnosticsTypeChecker || (noDiagnosticsTypeChecker = ts.createTypeChecker(program, false)); + } + function emit(sourceFile, writeFileCallback, cancellationToken) { + var _this = this; + return runWithCancellationToken(function () { return emitWorker(_this, sourceFile, writeFileCallback, cancellationToken); }); + } + function emitWorker(program, sourceFile, writeFileCallback, cancellationToken) { + if (options.noEmitOnError && getPreEmitDiagnostics(program, undefined, cancellationToken).length > 0) { + return { diagnostics: [], sourceMaps: undefined, emitSkipped: true }; + } + var emitResolver = getDiagnosticsProducingTypeChecker().getEmitResolver((options.outFile || options.out) ? undefined : sourceFile); + var start = new Date().getTime(); + var emitResult = ts.emitFiles(emitResolver, getEmitHost(writeFileCallback), sourceFile); + ts.emitTime += new Date().getTime() - start; + return emitResult; + } + function getSourceFile(fileName) { + return filesByName.get(ts.getNormalizedAbsolutePath(fileName, currentDirectory)); + } + function getDiagnosticsHelper(sourceFile, getDiagnostics, cancellationToken) { + if (sourceFile) { + return getDiagnostics(sourceFile, cancellationToken); + } + var allDiagnostics = []; + ts.forEach(program.getSourceFiles(), function (sourceFile) { + if (cancellationToken) { + cancellationToken.throwIfCancellationRequested(); + } + ts.addRange(allDiagnostics, getDiagnostics(sourceFile, cancellationToken)); + }); + return ts.sortAndDeduplicateDiagnostics(allDiagnostics); + } + function getSyntacticDiagnostics(sourceFile, cancellationToken) { + return getDiagnosticsHelper(sourceFile, getSyntacticDiagnosticsForFile, cancellationToken); + } + function getSemanticDiagnostics(sourceFile, cancellationToken) { + return getDiagnosticsHelper(sourceFile, getSemanticDiagnosticsForFile, cancellationToken); + } + function getDeclarationDiagnostics(sourceFile, cancellationToken) { + return getDiagnosticsHelper(sourceFile, getDeclarationDiagnosticsForFile, cancellationToken); + } + function getSyntacticDiagnosticsForFile(sourceFile, cancellationToken) { + return sourceFile.parseDiagnostics; + } + function runWithCancellationToken(func) { + try { + return func(); + } + catch (e) { + if (e instanceof ts.OperationCanceledException) { + noDiagnosticsTypeChecker = undefined; + diagnosticsProducingTypeChecker = undefined; + } + throw e; + } + } + function getSemanticDiagnosticsForFile(sourceFile, cancellationToken) { + return runWithCancellationToken(function () { + var typeChecker = getDiagnosticsProducingTypeChecker(); + ts.Debug.assert(!!sourceFile.bindDiagnostics); + var bindDiagnostics = sourceFile.bindDiagnostics; + var checkDiagnostics = typeChecker.getDiagnostics(sourceFile, cancellationToken); + var fileProcessingDiagnosticsInFile = fileProcessingDiagnostics.getDiagnostics(sourceFile.fileName); + var programDiagnosticsInFile = programDiagnostics.getDiagnostics(sourceFile.fileName); + return bindDiagnostics.concat(checkDiagnostics).concat(fileProcessingDiagnosticsInFile).concat(programDiagnosticsInFile); + }); + } + function getDeclarationDiagnosticsForFile(sourceFile, cancellationToken) { + return runWithCancellationToken(function () { + if (!ts.isDeclarationFile(sourceFile)) { + var resolver = getDiagnosticsProducingTypeChecker().getEmitResolver(sourceFile, cancellationToken); + var writeFile_1 = function () { }; + return ts.getDeclarationDiagnostics(getEmitHost(writeFile_1), resolver, sourceFile); + } + }); + } + function getOptionsDiagnostics() { + var allDiagnostics = []; + ts.addRange(allDiagnostics, fileProcessingDiagnostics.getGlobalDiagnostics()); + ts.addRange(allDiagnostics, programDiagnostics.getGlobalDiagnostics()); + return ts.sortAndDeduplicateDiagnostics(allDiagnostics); + } + function getGlobalDiagnostics() { + var allDiagnostics = []; + ts.addRange(allDiagnostics, getDiagnosticsProducingTypeChecker().getGlobalDiagnostics()); + return ts.sortAndDeduplicateDiagnostics(allDiagnostics); + } + function hasExtension(fileName) { + return ts.getBaseFileName(fileName).indexOf(".") >= 0; + } + function processRootFile(fileName, isDefaultLib) { + processSourceFile(ts.normalizePath(fileName), isDefaultLib); + } + function fileReferenceIsEqualTo(a, b) { + return a.fileName === b.fileName; + } + function moduleNameIsEqualTo(a, b) { + return a.text === b.text; + } + function collectExternalModuleReferences(file) { + if (file.imports) { + return; + } + var imports; + for (var _i = 0, _a = file.statements; _i < _a.length; _i++) { + var node = _a[_i]; + collect(node, true); + } + file.imports = imports || emptyArray; + function collect(node, allowRelativeModuleNames) { + switch (node.kind) { + case 222: + case 221: + case 228: + var moduleNameExpr = ts.getExternalModuleName(node); + if (!moduleNameExpr || moduleNameExpr.kind !== 9) { + break; + } + if (!moduleNameExpr.text) { + break; + } + if (allowRelativeModuleNames || !ts.isExternalModuleNameRelative(moduleNameExpr.text)) { + (imports || (imports = [])).push(moduleNameExpr); + } + break; + case 218: + if (node.name.kind === 9 && (node.flags & 2 || ts.isDeclarationFile(file))) { + ts.forEachChild(node.body, function (node) { + collect(node, false); + }); + } + break; + } + } + } + function processSourceFile(fileName, isDefaultLib, refFile, refPos, refEnd) { + var diagnosticArgument; + var diagnostic; + if (hasExtension(fileName)) { + if (!options.allowNonTsExtensions && !ts.forEach(ts.supportedExtensions, function (extension) { return ts.fileExtensionIs(host.getCanonicalFileName(fileName), extension); })) { + diagnostic = ts.Diagnostics.File_0_has_unsupported_extension_The_only_supported_extensions_are_1; + diagnosticArgument = [fileName, "'" + ts.supportedExtensions.join("', '") + "'"]; + } + else if (!findSourceFile(fileName, ts.getNormalizedAbsolutePath(fileName, currentDirectory), isDefaultLib, refFile, refPos, refEnd)) { + diagnostic = ts.Diagnostics.File_0_not_found; + diagnosticArgument = [fileName]; + } + else if (refFile && host.getCanonicalFileName(fileName) === host.getCanonicalFileName(refFile.fileName)) { + diagnostic = ts.Diagnostics.A_file_cannot_have_a_reference_to_itself; + diagnosticArgument = [fileName]; + } + } + else { + var nonTsFile = options.allowNonTsExtensions && findSourceFile(fileName, ts.getNormalizedAbsolutePath(fileName, currentDirectory), isDefaultLib, refFile, refPos, refEnd); + if (!nonTsFile) { + if (options.allowNonTsExtensions) { + diagnostic = ts.Diagnostics.File_0_not_found; + diagnosticArgument = [fileName]; + } + else if (!ts.forEach(ts.supportedExtensions, function (extension) { return findSourceFile(fileName + extension, ts.getNormalizedAbsolutePath(fileName + extension, currentDirectory), isDefaultLib, refFile, refPos, refEnd); })) { + diagnostic = ts.Diagnostics.File_0_not_found; + fileName += ".ts"; + diagnosticArgument = [fileName]; + } + } + } + if (diagnostic) { + if (refFile !== undefined && refEnd !== undefined && refPos !== undefined) { + fileProcessingDiagnostics.add(ts.createFileDiagnostic.apply(void 0, [refFile, refPos, refEnd - refPos, diagnostic].concat(diagnosticArgument))); + } + else { + fileProcessingDiagnostics.add(ts.createCompilerDiagnostic.apply(void 0, [diagnostic].concat(diagnosticArgument))); + } + } + } + function reportFileNamesDifferOnlyInCasingError(fileName, existingFileName, refFile, refPos, refEnd) { + if (refFile !== undefined && refPos !== undefined && refEnd !== undefined) { + fileProcessingDiagnostics.add(ts.createFileDiagnostic(refFile, refPos, refEnd - refPos, ts.Diagnostics.File_name_0_differs_from_already_included_file_name_1_only_in_casing, fileName, existingFileName)); + } + else { + fileProcessingDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.File_name_0_differs_from_already_included_file_name_1_only_in_casing, fileName, existingFileName)); + } + } + function findSourceFile(fileName, normalizedAbsolutePath, isDefaultLib, refFile, refPos, refEnd) { + if (filesByName.contains(normalizedAbsolutePath)) { + var file_1 = filesByName.get(normalizedAbsolutePath); + if (file_1 && options.forceConsistentCasingInFileNames && ts.getNormalizedAbsolutePath(file_1.fileName, currentDirectory) !== normalizedAbsolutePath) { + reportFileNamesDifferOnlyInCasingError(fileName, file_1.fileName, refFile, refPos, refEnd); + } + return file_1; + } + var file = host.getSourceFile(fileName, options.target, function (hostErrorMessage) { + if (refFile !== undefined && refPos !== undefined && refEnd !== undefined) { + fileProcessingDiagnostics.add(ts.createFileDiagnostic(refFile, refPos, refEnd - refPos, ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage)); + } + else { + fileProcessingDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage)); + } + }); + filesByName.set(normalizedAbsolutePath, file); + if (file) { + if (host.useCaseSensitiveFileNames()) { + var existingFile = filesByNameIgnoreCase.get(normalizedAbsolutePath); + if (existingFile) { + reportFileNamesDifferOnlyInCasingError(fileName, existingFile.fileName, refFile, refPos, refEnd); + } + else { + filesByNameIgnoreCase.set(normalizedAbsolutePath, file); + } + } + skipDefaultLib = skipDefaultLib || file.hasNoDefaultLib; + var basePath = ts.getDirectoryPath(fileName); + if (!options.noResolve) { + processReferencedFiles(file, basePath); + } + processImportedModules(file, basePath); + if (isDefaultLib) { + file.isDefaultLib = true; + files.unshift(file); + } + else { + files.push(file); + } + } + return file; + } + function processReferencedFiles(file, basePath) { + ts.forEach(file.referencedFiles, function (ref) { + var referencedFileName = resolveTripleslashReference(ref.fileName, file.fileName); + processSourceFile(referencedFileName, false, file, ref.pos, ref.end); + }); + } + function getCanonicalFileName(fileName) { + return host.getCanonicalFileName(fileName); + } + function processImportedModules(file, basePath) { + collectExternalModuleReferences(file); + if (file.imports.length) { + file.resolvedModules = {}; + var moduleNames = ts.map(file.imports, function (name) { return name.text; }); + var resolutions = resolveModuleNamesWorker(moduleNames, ts.getNormalizedAbsolutePath(file.fileName, currentDirectory)); + for (var i = 0; i < file.imports.length; ++i) { + var resolution = resolutions[i]; + ts.setResolvedModule(file, moduleNames[i], resolution); + if (resolution && !options.noResolve) { + var absoluteImportPath = ts.isRootedDiskPath(resolution.resolvedFileName) + ? resolution.resolvedFileName + : ts.getNormalizedAbsolutePath(resolution.resolvedFileName, currentDirectory); + var relativePath = ts.getRelativePathToDirectoryOrUrl(currentDirectory, absoluteImportPath, currentDirectory, getCanonicalFileName, false); + var importedFile = findSourceFile(relativePath, absoluteImportPath, false, file, ts.skipTrivia(file.text, file.imports[i].pos), file.imports[i].end); + if (importedFile && resolution.isExternalLibraryImport) { + if (!ts.isExternalModule(importedFile)) { + var start_2 = ts.getTokenPosOfNode(file.imports[i], file); + fileProcessingDiagnostics.add(ts.createFileDiagnostic(file, start_2, file.imports[i].end - start_2, ts.Diagnostics.Exported_external_package_typings_file_0_is_not_a_module_Please_contact_the_package_author_to_update_the_package_definition, importedFile.fileName)); + } + else if (importedFile.referencedFiles.length) { + var firstRef = importedFile.referencedFiles[0]; + fileProcessingDiagnostics.add(ts.createFileDiagnostic(importedFile, firstRef.pos, firstRef.end - firstRef.pos, ts.Diagnostics.Exported_external_package_typings_file_cannot_contain_tripleslash_references_Please_contact_the_package_author_to_update_the_package_definition)); + } + } + } + } + } + else { + file.resolvedModules = undefined; + } + return; + } + function computeCommonSourceDirectory(sourceFiles) { + var commonPathComponents; + ts.forEach(files, function (sourceFile) { + if (ts.isDeclarationFile(sourceFile)) { + return; + } + var sourcePathComponents = ts.getNormalizedPathComponents(sourceFile.fileName, currentDirectory); + sourcePathComponents.pop(); + if (!commonPathComponents) { + commonPathComponents = sourcePathComponents; + return; + } + for (var i = 0, n = Math.min(commonPathComponents.length, sourcePathComponents.length); i < n; i++) { + if (commonPathComponents[i] !== sourcePathComponents[i]) { + if (i === 0) { + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_find_the_common_subdirectory_path_for_the_input_files)); + return; + } + commonPathComponents.length = i; + break; + } + } + if (sourcePathComponents.length < commonPathComponents.length) { + commonPathComponents.length = sourcePathComponents.length; + } + }); + return ts.getNormalizedPathFromPathComponents(commonPathComponents); + } + function checkSourceFilesBelongToPath(sourceFiles, rootDirectory) { + var allFilesBelongToPath = true; + if (sourceFiles) { + var absoluteRootDirectoryPath = host.getCanonicalFileName(ts.getNormalizedAbsolutePath(rootDirectory, currentDirectory)); + for (var _i = 0; _i < sourceFiles.length; _i++) { + var sourceFile = sourceFiles[_i]; + if (!ts.isDeclarationFile(sourceFile)) { + var absoluteSourceFilePath = host.getCanonicalFileName(ts.getNormalizedAbsolutePath(sourceFile.fileName, currentDirectory)); + if (absoluteSourceFilePath.indexOf(absoluteRootDirectoryPath) !== 0) { + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.File_0_is_not_under_rootDir_1_rootDir_is_expected_to_contain_all_source_files, sourceFile.fileName, options.rootDir)); + allFilesBelongToPath = false; + } + } + } + } + return allFilesBelongToPath; + } + function verifyCompilerOptions() { + if (options.isolatedModules) { + if (options.declaration) { + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "declaration", "isolatedModules")); + } + if (options.noEmitOnError) { + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "noEmitOnError", "isolatedModules")); + } + if (options.out) { + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "out", "isolatedModules")); + } + if (options.outFile) { + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "outFile", "isolatedModules")); + } + } + if (options.inlineSourceMap) { + if (options.sourceMap) { + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "sourceMap", "inlineSourceMap")); + } + if (options.mapRoot) { + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "mapRoot", "inlineSourceMap")); + } + if (options.sourceRoot) { + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "sourceRoot", "inlineSourceMap")); + } + } + if (options.inlineSources) { + if (!options.sourceMap && !options.inlineSourceMap) { + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_inlineSources_can_only_be_used_when_either_option_inlineSourceMap_or_option_sourceMap_is_provided)); + } + } + if (options.out && options.outFile) { + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "out", "outFile")); + } + if (!options.sourceMap && (options.mapRoot || options.sourceRoot)) { + if (options.mapRoot) { + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "mapRoot", "sourceMap")); + } + if (options.sourceRoot) { + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "sourceRoot", "sourceMap")); + } + return; + } + var languageVersion = options.target || 0; + var outFile = options.outFile || options.out; + var firstExternalModuleSourceFile = ts.forEach(files, function (f) { return ts.isExternalModule(f) ? f : undefined; }); + if (options.isolatedModules) { + if (!options.module && languageVersion < 2) { + 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; }); + if (firstNonExternalModuleSourceFile) { + var span = ts.getErrorSpanForNode(firstNonExternalModuleSourceFile, firstNonExternalModuleSourceFile); + programDiagnostics.add(ts.createFileDiagnostic(firstNonExternalModuleSourceFile, span.start, span.length, ts.Diagnostics.Cannot_compile_namespaces_when_the_isolatedModules_flag_is_provided)); + } + } + else if (firstExternalModuleSourceFile && languageVersion < 2 && !options.module) { + var span = ts.getErrorSpanForNode(firstExternalModuleSourceFile, firstExternalModuleSourceFile.externalModuleIndicator); + programDiagnostics.add(ts.createFileDiagnostic(firstExternalModuleSourceFile, span.start, span.length, ts.Diagnostics.Cannot_compile_modules_unless_the_module_flag_is_provided)); + } + if (options.module === 5 && languageVersion < 2) { + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_compile_modules_into_es2015_when_targeting_ES5_or_lower)); + } + if (options.outDir || + options.sourceRoot || + (options.mapRoot && + (!outFile || firstExternalModuleSourceFile !== undefined))) { + if (options.rootDir && checkSourceFilesBelongToPath(files, options.rootDir)) { + commonSourceDirectory = ts.getNormalizedAbsolutePath(options.rootDir, currentDirectory); + } + else { + commonSourceDirectory = computeCommonSourceDirectory(files); + } + if (commonSourceDirectory && commonSourceDirectory[commonSourceDirectory.length - 1] !== ts.directorySeparator) { + commonSourceDirectory += ts.directorySeparator; + } + } + if (options.noEmit) { + if (options.out) { + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "noEmit", "out")); + } + if (options.outFile) { + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "noEmit", "outFile")); + } + if (options.outDir) { + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "noEmit", "outDir")); + } + if (options.declaration) { + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "noEmit", "declaration")); + } + } + if (options.emitDecoratorMetadata && + !options.experimentalDecorators) { + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "emitDecoratorMetadata", "experimentalDecorators")); + } + } + } + ts.createProgram = createProgram; +})(ts || (ts = {})); +var ts; +(function (ts) { + ts.optionDeclarations = [ + { + name: "charset", + type: "string" + }, + { + name: "declaration", + shortName: "d", + type: "boolean", + description: ts.Diagnostics.Generates_corresponding_d_ts_file + }, + { + name: "diagnostics", + type: "boolean" + }, + { + name: "emitBOM", + type: "boolean" + }, + { + name: "help", + shortName: "h", + type: "boolean", + description: ts.Diagnostics.Print_this_message + }, + { + 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: { + "preserve": 1, + "react": 2 + }, + paramType: ts.Diagnostics.KIND, + description: ts.Diagnostics.Specify_JSX_code_generation_Colon_preserve_or_react, + error: ts.Diagnostics.Argument_for_jsx_must_be_preserve_or_react + }, + { + name: "listFiles", + type: "boolean" + }, + { + name: "locale", + type: "string" + }, + { + name: "mapRoot", + type: "string", + isFilePath: true, + description: ts.Diagnostics.Specifies_the_location_where_debugger_should_locate_map_files_instead_of_generated_locations, + paramType: ts.Diagnostics.LOCATION + }, + { + name: "module", + shortName: "m", + type: { + "commonjs": 1, + "amd": 2, + "system": 4, + "umd": 3, + "es6": 5, + "es2015": 5 + }, + description: ts.Diagnostics.Specify_module_code_generation_Colon_commonjs_amd_system_umd_or_es2015, + paramType: ts.Diagnostics.KIND, + error: ts.Diagnostics.Argument_for_module_option_must_be_commonjs_amd_system_umd_or_es2015 + }, + { + name: "newLine", + type: { + "crlf": 0, + "lf": 1 + }, + description: ts.Diagnostics.Specifies_the_end_of_line_sequence_to_be_used_when_emitting_files_Colon_CRLF_dos_or_LF_unix, + paramType: ts.Diagnostics.NEWLINE, + error: ts.Diagnostics.Argument_for_newLine_option_must_be_CRLF_or_LF + }, + { + 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: "noImplicitAny", + type: "boolean", + description: ts.Diagnostics.Raise_error_on_expressions_and_declarations_with_an_implied_any_type + }, + { + name: "noLib", + type: "boolean" + }, + { + name: "noResolve", + type: "boolean" + }, + { + name: "skipDefaultLibCheck", + type: "boolean" + }, + { + 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: "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, + description: ts.Diagnostics.Specifies_the_root_directory_of_input_files_Use_to_control_the_output_directory_structure_with_outDir, + paramType: ts.Diagnostics.LOCATION + }, + { + name: "isolatedModules", + type: "boolean" + }, + { + name: "sourceMap", + type: "boolean", + description: ts.Diagnostics.Generates_corresponding_map_file + }, + { + name: "sourceRoot", + type: "string", + isFilePath: true, + description: ts.Diagnostics.Specifies_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: { + "es3": 0, + "es5": 1, + "es6": 2, + "es2015": 2 + }, + description: ts.Diagnostics.Specify_ECMAScript_target_version_Colon_ES3_default_ES5_or_ES2015_experimental, + paramType: ts.Diagnostics.VERSION, + error: ts.Diagnostics.Argument_for_target_option_must_be_ES3_ES5_or_ES2015 + }, + { + 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: { + "node": 2, + "classic": 1 + }, + description: ts.Diagnostics.Specifies_module_resolution_strategy_Colon_node_Node_js_or_classic_TypeScript_pre_1_6, + error: ts.Diagnostics.Argument_for_moduleResolution_option_must_be_node_or_classic + }, + { + name: "forceConsistentCasingInFileNames", + type: "boolean", + description: ts.Diagnostics.Disallow_inconsistently_cased_references_to_the_same_file + }, + ]; + var optionNameMapCache; + function getOptionNameMap() { + if (optionNameMapCache) { + return optionNameMapCache; + } + var optionNameMap = {}; + var shortOptionNames = {}; + 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 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++]; + 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 (ts.hasProperty(shortOptionNames, s)) { + s = shortOptionNames[s]; + } + if (ts.hasProperty(optionNameMap, s)) { + var opt = optionNameMap[s]; + 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++]); + break; + case "boolean": + options[opt.name] = true; + break; + case "string": + options[opt.name] = args[i++] || ""; + break; + default: + var map_2 = opt.type; + var key = (args[i++] || "").toLowerCase(); + if (ts.hasProperty(map_2, key)) { + options[opt.name] = map_2[key]; + } + else { + errors.push(ts.createCompilerDiagnostic(opt.error)); + } + } + } + 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) { + try { + return { config: /\S/.test(jsonText) ? JSON.parse(jsonText) : {} }; + } + catch (e) { + return { error: ts.createCompilerDiagnostic(ts.Diagnostics.Failed_to_parse_file_0_Colon_1, fileName, e.message) }; + } + } + ts.parseConfigFileTextToJson = parseConfigFileTextToJson; + function parseJsonConfigFileContent(json, host, basePath) { + var _a = convertCompilerOptionsFromJson(json["compilerOptions"], basePath), options = _a.options, errors = _a.errors; + return { + options: options, + fileNames: getFileNames(), + errors: errors + }; + function getFileNames() { + var fileNames = []; + if (ts.hasProperty(json, "files")) { + if (json["files"] instanceof Array) { + fileNames = ts.map(json["files"], function (s) { return ts.combinePaths(basePath, s); }); + } + else { + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Compiler_option_0_requires_a_value_of_type_1, "files", "Array")); + } + } + else { + var exclude = json["exclude"] instanceof Array ? ts.map(json["exclude"], ts.normalizeSlashes) : undefined; + var sysFiles = host.readDirectory(basePath, ".ts", exclude).concat(host.readDirectory(basePath, ".tsx", exclude)); + for (var i = 0; i < sysFiles.length; i++) { + var name_29 = sysFiles[i]; + if (ts.fileExtensionIs(name_29, ".d.ts")) { + var baseName = name_29.substr(0, name_29.length - ".d.ts".length); + if (!ts.contains(sysFiles, baseName + ".tsx") && !ts.contains(sysFiles, baseName + ".ts")) { + fileNames.push(name_29); + } + } + else if (ts.fileExtensionIs(name_29, ".ts")) { + if (!ts.contains(sysFiles, name_29 + "x")) { + fileNames.push(name_29); + } + } + else { + fileNames.push(name_29); + } + } + } + return fileNames; + } + } + ts.parseJsonConfigFileContent = parseJsonConfigFileContent; + function convertCompilerOptionsFromJson(jsonOptions, basePath) { + var options = {}; + var errors = []; + if (!jsonOptions) { + return { options: options, errors: errors }; + } + var optionNameMap = ts.arrayToMap(ts.optionDeclarations, function (opt) { return opt.name; }); + for (var id in jsonOptions) { + if (ts.hasProperty(optionNameMap, id)) { + var opt = optionNameMap[id]; + var optType = opt.type; + var value = jsonOptions[id]; + var expectedType = typeof optType === "string" ? optType : "string"; + if (typeof value === expectedType) { + if (typeof optType !== "string") { + var key = value.toLowerCase(); + if (ts.hasProperty(optType, key)) { + value = optType[key]; + } + else { + errors.push(ts.createCompilerDiagnostic(opt.error)); + value = 0; + } + } + if (opt.isFilePath) { + value = ts.normalizePath(ts.combinePaths(basePath, value)); + if (value === "") { + value = "."; + } + } + options[opt.name] = value; + } + else { + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Compiler_option_0_requires_a_value_of_type_1, id, expectedType)); + } + } + else { + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Unknown_compiler_option_0, id)); + } + } + return { options: options, errors: errors }; + } + ts.convertCompilerOptionsFromJson = convertCompilerOptionsFromJson; +})(ts || (ts = {})); +var ts; +(function (ts) { + function validateLocaleAndSetLanguage(locale, errors) { + var matchResult = /^([a-z]+)([_\-]([a-z]+))?$/.exec(locale.toLowerCase()); + if (!matchResult) { + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Locale_must_be_of_the_form_language_or_language_territory_For_example_0_or_1, "en", "ja-jp")); + return false; + } + var language = matchResult[1]; + var territory = matchResult[3]; + if (!trySetLanguageAndTerritory(language, territory, errors) && + !trySetLanguageAndTerritory(language, undefined, errors)) { + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Unsupported_locale_0, locale)); + return false; + } + return true; + } + function trySetLanguageAndTerritory(language, territory, errors) { + var compilerFilePath = ts.normalizePath(ts.sys.getExecutingFilePath()); + var containingDirectoryPath = ts.getDirectoryPath(compilerFilePath); + var filePath = ts.combinePaths(containingDirectoryPath, language); + if (territory) { + filePath = filePath + "-" + territory; + } + filePath = ts.sys.resolvePath(ts.combinePaths(filePath, "diagnosticMessages.generated.json")); + if (!ts.sys.fileExists(filePath)) { + return false; + } + var fileContents = ""; + try { + fileContents = ts.sys.readFile(filePath); + } + catch (e) { + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Unable_to_open_file_0, filePath)); + return false; + } + try { + ts.localizedDiagnosticMessages = JSON.parse(fileContents); + } + catch (e) { + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Corrupted_locale_file_0, filePath)); + return false; + } + return true; + } + function countLines(program) { + var count = 0; + ts.forEach(program.getSourceFiles(), function (file) { + count += ts.getLineStarts(file).length; + }); + return count; + } + function getDiagnosticText(message) { + var args = []; + for (var _i = 1; _i < arguments.length; _i++) { + args[_i - 1] = arguments[_i]; + } + var diagnostic = ts.createCompilerDiagnostic.apply(undefined, arguments); + return diagnostic.messageText; + } + function reportDiagnostic(diagnostic) { + var output = ""; + if (diagnostic.file) { + var loc = ts.getLineAndCharacterOfPosition(diagnostic.file, diagnostic.start); + output += diagnostic.file.fileName + "(" + (loc.line + 1) + "," + (loc.character + 1) + "): "; + } + var category = ts.DiagnosticCategory[diagnostic.category].toLowerCase(); + output += category + " TS" + diagnostic.code + ": " + ts.flattenDiagnosticMessageText(diagnostic.messageText, ts.sys.newLine) + ts.sys.newLine; + ts.sys.write(output); + } + function reportDiagnostics(diagnostics) { + for (var i = 0; i < diagnostics.length; i++) { + reportDiagnostic(diagnostics[i]); + } + } + function reportWatchDiagnostic(diagnostic) { + var output = new Date().toLocaleTimeString() + " - "; + if (diagnostic.file) { + var loc = ts.getLineAndCharacterOfPosition(diagnostic.file, diagnostic.start); + output += diagnostic.file.fileName + "(" + (loc.line + 1) + "," + (loc.character + 1) + "): "; + } + output += "" + ts.flattenDiagnosticMessageText(diagnostic.messageText, ts.sys.newLine) + ts.sys.newLine; + ts.sys.write(output); + } + function padLeft(s, length) { + while (s.length < length) { + s = " " + s; + } + return s; + } + function padRight(s, length) { + while (s.length < length) { + s = s + " "; + } + return s; + } + function reportStatisticalValue(name, value) { + ts.sys.write(padRight(name + ":", 12) + padLeft(value.toString(), 10) + ts.sys.newLine); + } + function reportCountStatistic(name, count) { + reportStatisticalValue(name, "" + count); + } + function reportTimeStatistic(name, time) { + reportStatisticalValue(name, (time / 1000).toFixed(2) + "s"); + } + function isJSONSupported() { + return typeof JSON === "object" && typeof JSON.parse === "function"; + } + function executeCommandLine(args) { + var commandLine = ts.parseCommandLine(args); + var configFileName; + var cachedConfigFileText; + var configFileWatcher; + var directoryWatcher; + var cachedProgram; + var rootFileNames; + var compilerOptions; + var compilerHost; + var hostGetSourceFile; + var timerHandleForRecompilation; + var timerHandleForDirectoryChanges; + var cachedExistingFiles; + var hostFileExists; + if (commandLine.options.locale) { + if (!isJSONSupported()) { + reportDiagnostic(ts.createCompilerDiagnostic(ts.Diagnostics.The_current_host_does_not_support_the_0_option, "--locale")); + return ts.sys.exit(ts.ExitStatus.DiagnosticsPresent_OutputsSkipped); + } + validateLocaleAndSetLanguage(commandLine.options.locale, commandLine.errors); + } + if (commandLine.errors.length > 0) { + reportDiagnostics(commandLine.errors); + return ts.sys.exit(ts.ExitStatus.DiagnosticsPresent_OutputsSkipped); + } + if (commandLine.options.init) { + writeConfigFile(commandLine.options, commandLine.fileNames); + return ts.sys.exit(ts.ExitStatus.Success); + } + if (commandLine.options.version) { + reportDiagnostic(ts.createCompilerDiagnostic(ts.Diagnostics.Version_0, ts.version)); + return ts.sys.exit(ts.ExitStatus.Success); + } + if (commandLine.options.help) { + printVersion(); + printHelp(); + return ts.sys.exit(ts.ExitStatus.Success); + } + if (commandLine.options.project) { + if (!isJSONSupported()) { + reportDiagnostic(ts.createCompilerDiagnostic(ts.Diagnostics.The_current_host_does_not_support_the_0_option, "--project")); + return ts.sys.exit(ts.ExitStatus.DiagnosticsPresent_OutputsSkipped); + } + configFileName = ts.normalizePath(ts.combinePaths(commandLine.options.project, "tsconfig.json")); + if (commandLine.fileNames.length !== 0) { + reportDiagnostic(ts.createCompilerDiagnostic(ts.Diagnostics.Option_project_cannot_be_mixed_with_source_files_on_a_command_line)); + return ts.sys.exit(ts.ExitStatus.DiagnosticsPresent_OutputsSkipped); + } + } + else if (commandLine.fileNames.length === 0 && isJSONSupported()) { + var searchPath = ts.normalizePath(ts.sys.getCurrentDirectory()); + configFileName = ts.findConfigFile(searchPath); + } + if (commandLine.fileNames.length === 0 && !configFileName) { + printVersion(); + printHelp(); + return ts.sys.exit(ts.ExitStatus.Success); + } + if (commandLine.options.watch && commandLine.options.hasOwnProperty("watch")) { + if (!ts.sys.watchFile) { + reportDiagnostic(ts.createCompilerDiagnostic(ts.Diagnostics.The_current_host_does_not_support_the_0_option, "--watch")); + return ts.sys.exit(ts.ExitStatus.DiagnosticsPresent_OutputsSkipped); + } + if (configFileName) { + configFileWatcher = ts.sys.watchFile(configFileName, configFileChanged); + } + if (ts.sys.watchDirectory && configFileName) { + var directory = ts.getDirectoryPath(configFileName); + directoryWatcher = ts.sys.watchDirectory(directory == "" ? "." : directory, watchedDirectoryChanged, true); + } + } + performCompilation(); + function parseConfigFile() { + if (!cachedConfigFileText) { + try { + cachedConfigFileText = ts.sys.readFile(configFileName); + } + catch (e) { + var error = ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_read_file_0_Colon_1, configFileName, e.message); + reportWatchDiagnostic(error); + ts.sys.exit(ts.ExitStatus.DiagnosticsPresent_OutputsSkipped); + return; + } + } + var result = ts.parseConfigFileTextToJson(configFileName, cachedConfigFileText); + var configObject = result.config; + var configParseResult = ts.parseJsonConfigFileContent(configObject, ts.sys, ts.getDirectoryPath(configFileName)); + if (configParseResult.errors.length > 0) { + reportDiagnostics(configParseResult.errors); + ts.sys.exit(ts.ExitStatus.DiagnosticsPresent_OutputsSkipped); + return; + } + return configParseResult; + } + function performCompilation() { + if (!cachedProgram) { + if (configFileName) { + var configParseResult = parseConfigFile(); + rootFileNames = configParseResult.fileNames; + compilerOptions = ts.extend(commandLine.options, configParseResult.options); + } + else { + rootFileNames = commandLine.fileNames; + compilerOptions = commandLine.options; + } + compilerHost = ts.createCompilerHost(compilerOptions); + hostGetSourceFile = compilerHost.getSourceFile; + compilerHost.getSourceFile = getSourceFile; + hostFileExists = compilerHost.fileExists; + compilerHost.fileExists = cachedFileExists; + } + cachedExistingFiles = {}; + var compileResult = compile(rootFileNames, compilerOptions, compilerHost); + if (!compilerOptions.watch) { + return ts.sys.exit(compileResult.exitStatus); + } + setCachedProgram(compileResult.program); + reportWatchDiagnostic(ts.createCompilerDiagnostic(ts.Diagnostics.Compilation_complete_Watching_for_file_changes)); + } + function cachedFileExists(fileName) { + if (ts.hasProperty(cachedExistingFiles, fileName)) { + return cachedExistingFiles[fileName]; + } + return cachedExistingFiles[fileName] = hostFileExists(fileName); + } + function getSourceFile(fileName, languageVersion, onError) { + if (cachedProgram) { + var sourceFile_1 = cachedProgram.getSourceFile(fileName); + if (sourceFile_1 && sourceFile_1.fileWatcher) { + return sourceFile_1; + } + } + var sourceFile = hostGetSourceFile(fileName, languageVersion, onError); + if (sourceFile && compilerOptions.watch) { + sourceFile.fileWatcher = ts.sys.watchFile(sourceFile.fileName, function (fileName, removed) { return sourceFileChanged(sourceFile, removed); }); + } + return sourceFile; + } + function setCachedProgram(program) { + if (cachedProgram) { + var newSourceFiles = program ? program.getSourceFiles() : undefined; + ts.forEach(cachedProgram.getSourceFiles(), function (sourceFile) { + if (!(newSourceFiles && ts.contains(newSourceFiles, sourceFile))) { + if (sourceFile.fileWatcher) { + sourceFile.fileWatcher.close(); + sourceFile.fileWatcher = undefined; + } + } + }); + } + cachedProgram = program; + } + function sourceFileChanged(sourceFile, removed) { + sourceFile.fileWatcher.close(); + sourceFile.fileWatcher = undefined; + if (removed) { + var index = rootFileNames.indexOf(sourceFile.fileName); + if (index >= 0) { + rootFileNames.splice(index, 1); + } + } + startTimerForRecompilation(); + } + function configFileChanged() { + setCachedProgram(undefined); + cachedConfigFileText = undefined; + startTimerForRecompilation(); + } + function watchedDirectoryChanged(fileName) { + if (fileName && !ts.isSupportedSourceFileName(fileName)) { + return; + } + startTimerForHandlingDirectoryChanges(); + } + function startTimerForHandlingDirectoryChanges() { + if (timerHandleForDirectoryChanges) { + clearTimeout(timerHandleForDirectoryChanges); + } + timerHandleForDirectoryChanges = setTimeout(directoryChangeHandler, 250); + } + function directoryChangeHandler() { + var parsedCommandLine = parseConfigFile(); + var newFileNames = ts.map(parsedCommandLine.fileNames, compilerHost.getCanonicalFileName); + var canonicalRootFileNames = ts.map(rootFileNames, compilerHost.getCanonicalFileName); + if (!ts.arrayIsEqualTo(newFileNames && newFileNames.sort(), canonicalRootFileNames && canonicalRootFileNames.sort())) { + setCachedProgram(undefined); + startTimerForRecompilation(); + } + } + function startTimerForRecompilation() { + if (timerHandleForRecompilation) { + clearTimeout(timerHandleForRecompilation); + } + timerHandleForRecompilation = setTimeout(recompile, 250); + } + function recompile() { + timerHandleForRecompilation = undefined; + reportWatchDiagnostic(ts.createCompilerDiagnostic(ts.Diagnostics.File_change_detected_Starting_incremental_compilation)); + performCompilation(); + } + } + ts.executeCommandLine = executeCommandLine; + function compile(fileNames, compilerOptions, compilerHost) { + ts.ioReadTime = 0; + ts.ioWriteTime = 0; + ts.programTime = 0; + ts.bindTime = 0; + ts.checkTime = 0; + ts.emitTime = 0; + var program = ts.createProgram(fileNames, compilerOptions, compilerHost); + var exitStatus = compileProgram(); + if (compilerOptions.listFiles) { + ts.forEach(program.getSourceFiles(), function (file) { + ts.sys.write(file.fileName + ts.sys.newLine); + }); + } + if (compilerOptions.diagnostics) { + var memoryUsed = ts.sys.getMemoryUsage ? ts.sys.getMemoryUsage() : -1; + reportCountStatistic("Files", program.getSourceFiles().length); + reportCountStatistic("Lines", countLines(program)); + reportCountStatistic("Nodes", program.getNodeCount()); + reportCountStatistic("Identifiers", program.getIdentifierCount()); + reportCountStatistic("Symbols", program.getSymbolCount()); + reportCountStatistic("Types", program.getTypeCount()); + if (memoryUsed >= 0) { + reportStatisticalValue("Memory used", Math.round(memoryUsed / 1000) + "K"); + } + reportTimeStatistic("I/O read", ts.ioReadTime); + reportTimeStatistic("I/O write", ts.ioWriteTime); + reportTimeStatistic("Parse time", ts.programTime); + reportTimeStatistic("Bind time", ts.bindTime); + reportTimeStatistic("Check time", ts.checkTime); + reportTimeStatistic("Emit time", ts.emitTime); + reportTimeStatistic("Total time", ts.programTime + ts.bindTime + ts.checkTime + ts.emitTime); + } + return { program: program, exitStatus: exitStatus }; + function compileProgram() { + var diagnostics; + diagnostics = program.getSyntacticDiagnostics(); + if (diagnostics.length === 0) { + diagnostics = program.getOptionsDiagnostics().concat(program.getGlobalDiagnostics()); + if (diagnostics.length === 0) { + diagnostics = program.getSemanticDiagnostics(); + } + } + reportDiagnostics(diagnostics); + if (compilerOptions.noEmit) { + return diagnostics.length + ? ts.ExitStatus.DiagnosticsPresent_OutputsSkipped + : ts.ExitStatus.Success; + } + var emitOutput = program.emit(); + reportDiagnostics(emitOutput.diagnostics); + if (emitOutput.emitSkipped) { + return ts.ExitStatus.DiagnosticsPresent_OutputsSkipped; + } + if (diagnostics.length > 0 || emitOutput.diagnostics.length > 0) { + return ts.ExitStatus.DiagnosticsPresent_OutputsGenerated; + } + return ts.ExitStatus.Success; + } + } + function printVersion() { + ts.sys.write(getDiagnosticText(ts.Diagnostics.Version_0, ts.version) + ts.sys.newLine); + } + function printHelp() { + var output = ""; + var syntaxLength = getDiagnosticText(ts.Diagnostics.Syntax_Colon_0, "").length; + var examplesLength = getDiagnosticText(ts.Diagnostics.Examples_Colon_0, "").length; + var marginLength = Math.max(syntaxLength, examplesLength); + var syntax = makePadding(marginLength - syntaxLength); + syntax += "tsc [" + getDiagnosticText(ts.Diagnostics.options) + "] [" + getDiagnosticText(ts.Diagnostics.file) + " ...]"; + output += getDiagnosticText(ts.Diagnostics.Syntax_Colon_0, syntax); + output += ts.sys.newLine + ts.sys.newLine; + var padding = makePadding(marginLength); + output += getDiagnosticText(ts.Diagnostics.Examples_Colon_0, makePadding(marginLength - examplesLength) + "tsc hello.ts") + ts.sys.newLine; + output += padding + "tsc --out file.js file.ts" + ts.sys.newLine; + output += padding + "tsc @args.txt" + ts.sys.newLine; + output += ts.sys.newLine; + output += getDiagnosticText(ts.Diagnostics.Options_Colon) + ts.sys.newLine; + var optsList = ts.filter(ts.optionDeclarations.slice(), function (v) { return !v.experimental; }); + optsList.sort(function (a, b) { return ts.compareValues(a.name.toLowerCase(), b.name.toLowerCase()); }); + marginLength = 0; + var usageColumn = []; + var descriptionColumn = []; + for (var i = 0; i < optsList.length; i++) { + var option = optsList[i]; + if (!option.description) { + continue; + } + var usageText_1 = " "; + if (option.shortName) { + usageText_1 += "-" + option.shortName; + usageText_1 += getParamType(option); + usageText_1 += ", "; + } + usageText_1 += "--" + option.name; + usageText_1 += getParamType(option); + usageColumn.push(usageText_1); + descriptionColumn.push(getDiagnosticText(option.description)); + marginLength = Math.max(usageText_1.length, marginLength); + } + var usageText = " @<" + getDiagnosticText(ts.Diagnostics.file) + ">"; + usageColumn.push(usageText); + descriptionColumn.push(getDiagnosticText(ts.Diagnostics.Insert_command_line_options_and_files_from_a_file)); + marginLength = Math.max(usageText.length, marginLength); + for (var i = 0; i < usageColumn.length; i++) { + var usage = usageColumn[i]; + var description = descriptionColumn[i]; + output += usage + makePadding(marginLength - usage.length + 2) + description + ts.sys.newLine; + } + ts.sys.write(output); + return; + function getParamType(option) { + if (option.paramType !== undefined) { + return " " + getDiagnosticText(option.paramType); + } + return ""; + } + function makePadding(paddingLength) { + return Array(paddingLength + 1).join(" "); + } + } + function writeConfigFile(options, fileNames) { + var currentDirectory = ts.sys.getCurrentDirectory(); + var file = ts.normalizePath(ts.combinePaths(currentDirectory, "tsconfig.json")); + if (ts.sys.fileExists(file)) { + reportDiagnostic(ts.createCompilerDiagnostic(ts.Diagnostics.A_tsconfig_json_file_is_already_defined_at_Colon_0, file)); + } + else { + var compilerOptions = ts.extend(options, ts.defaultInitCompilerOptions); + var configurations = { + compilerOptions: serializeCompilerOptions(compilerOptions), + exclude: ["node_modules"] + }; + if (fileNames && fileNames.length) { + configurations.files = fileNames; + } + ts.sys.writeFile(file, JSON.stringify(configurations, undefined, 4)); + reportDiagnostic(ts.createCompilerDiagnostic(ts.Diagnostics.Successfully_created_a_tsconfig_json_file)); + } + return; + function serializeCompilerOptions(options) { + var result = {}; + var optionsNameMap = ts.getOptionNameMap().optionNameMap; + for (var name_30 in options) { + if (ts.hasProperty(options, name_30)) { + var value = options[name_30]; + switch (name_30) { + case "init": + case "watch": + case "version": + case "help": + case "project": + break; + default: + var optionDefinition = optionsNameMap[name_30.toLowerCase()]; + if (optionDefinition) { + if (typeof optionDefinition.type === "string") { + result[name_30] = value; + } + else { + var typeMap = optionDefinition.type; + for (var key in typeMap) { + if (ts.hasProperty(typeMap, key)) { + if (typeMap[key] === value) + result[name_30] = key; + } + } + } + } + break; + } + } + } + return result; + } + } +})(ts || (ts = {})); +ts.executeCommandLine(ts.sys.args); diff --git a/lib/tsserver.js b/lib/tsserver.js index af03b910434..77348ce6e8a 100644 --- a/lib/tsserver.js +++ b/lib/tsserver.js @@ -13,44952 +13,45363 @@ See the Apache Version 2.0 License for specific language governing permissions and limitations under the License. ***************************************************************************** */ -var ts; -(function (ts) { - var OperationCanceledException = (function () { - function OperationCanceledException() { - } - return OperationCanceledException; - })(); - ts.OperationCanceledException = OperationCanceledException; - (function (ExitStatus) { - ExitStatus[ExitStatus["Success"] = 0] = "Success"; - ExitStatus[ExitStatus["DiagnosticsPresent_OutputsSkipped"] = 1] = "DiagnosticsPresent_OutputsSkipped"; - ExitStatus[ExitStatus["DiagnosticsPresent_OutputsGenerated"] = 2] = "DiagnosticsPresent_OutputsGenerated"; - })(ts.ExitStatus || (ts.ExitStatus = {})); - var ExitStatus = ts.ExitStatus; - (function (TypeReferenceSerializationKind) { - TypeReferenceSerializationKind[TypeReferenceSerializationKind["Unknown"] = 0] = "Unknown"; - TypeReferenceSerializationKind[TypeReferenceSerializationKind["TypeWithConstructSignatureAndValue"] = 1] = "TypeWithConstructSignatureAndValue"; - TypeReferenceSerializationKind[TypeReferenceSerializationKind["VoidType"] = 2] = "VoidType"; - TypeReferenceSerializationKind[TypeReferenceSerializationKind["NumberLikeType"] = 3] = "NumberLikeType"; - TypeReferenceSerializationKind[TypeReferenceSerializationKind["StringLikeType"] = 4] = "StringLikeType"; - TypeReferenceSerializationKind[TypeReferenceSerializationKind["BooleanType"] = 5] = "BooleanType"; - TypeReferenceSerializationKind[TypeReferenceSerializationKind["ArrayLikeType"] = 6] = "ArrayLikeType"; - TypeReferenceSerializationKind[TypeReferenceSerializationKind["ESSymbolType"] = 7] = "ESSymbolType"; - TypeReferenceSerializationKind[TypeReferenceSerializationKind["TypeWithCallSignature"] = 8] = "TypeWithCallSignature"; - TypeReferenceSerializationKind[TypeReferenceSerializationKind["ObjectType"] = 9] = "ObjectType"; - })(ts.TypeReferenceSerializationKind || (ts.TypeReferenceSerializationKind = {})); - var TypeReferenceSerializationKind = ts.TypeReferenceSerializationKind; - (function (DiagnosticCategory) { - DiagnosticCategory[DiagnosticCategory["Warning"] = 0] = "Warning"; - DiagnosticCategory[DiagnosticCategory["Error"] = 1] = "Error"; - DiagnosticCategory[DiagnosticCategory["Message"] = 2] = "Message"; - })(ts.DiagnosticCategory || (ts.DiagnosticCategory = {})); - var DiagnosticCategory = ts.DiagnosticCategory; -})(ts || (ts = {})); -var ts; -(function (ts) { - function createFileMap(getCanonicalFileName) { - var files = {}; - return { - get: get, - set: set, - contains: contains, - remove: remove, - clear: clear, - forEachValue: forEachValueInMap - }; - function set(fileName, value) { - files[normalizeKey(fileName)] = value; - } - function get(fileName) { - return files[normalizeKey(fileName)]; - } - function contains(fileName) { - return hasProperty(files, normalizeKey(fileName)); - } - function remove(fileName) { - var key = normalizeKey(fileName); - delete files[key]; - } - function forEachValueInMap(f) { - forEachValue(files, f); - } - function normalizeKey(key) { - return getCanonicalFileName(normalizeSlashes(key)); - } - function clear() { - files = {}; - } - } - ts.createFileMap = createFileMap; - function forEach(array, callback) { - if (array) { - for (var i = 0, len = array.length; i < len; i++) { - var result = callback(array[i], i); - if (result) { - return result; - } - } - } - return undefined; - } - ts.forEach = forEach; - function contains(array, value) { - if (array) { - for (var _i = 0; _i < array.length; _i++) { - var v = array[_i]; - if (v === value) { - return true; - } - } - } - return false; - } - ts.contains = contains; - function indexOf(array, value) { - if (array) { - for (var i = 0, len = array.length; i < len; i++) { - if (array[i] === value) { - return i; - } - } - } - return -1; - } - ts.indexOf = indexOf; - function countWhere(array, predicate) { - var count = 0; - if (array) { - for (var _i = 0; _i < array.length; _i++) { - var v = array[_i]; - if (predicate(v)) { - count++; - } - } - } - return count; - } - ts.countWhere = countWhere; - function filter(array, f) { - var result; - if (array) { - result = []; - for (var _i = 0; _i < array.length; _i++) { - var item = array[_i]; - if (f(item)) { - result.push(item); - } - } - } - return result; - } - ts.filter = filter; - function map(array, f) { - var result; - if (array) { - result = []; - for (var _i = 0; _i < array.length; _i++) { - var v = array[_i]; - result.push(f(v)); - } - } - return result; - } - ts.map = map; - function concatenate(array1, array2) { - if (!array2 || !array2.length) - return array1; - if (!array1 || !array1.length) - return array2; - return array1.concat(array2); - } - ts.concatenate = concatenate; - function deduplicate(array) { - var result; - if (array) { - result = []; - for (var _i = 0; _i < array.length; _i++) { - var item = array[_i]; - if (!contains(result, item)) { - result.push(item); - } - } - } - return result; - } - ts.deduplicate = deduplicate; - function sum(array, prop) { - var result = 0; - for (var _i = 0; _i < array.length; _i++) { - var v = array[_i]; - result += v[prop]; - } - return result; - } - ts.sum = sum; - function addRange(to, from) { - if (to && from) { - for (var _i = 0; _i < from.length; _i++) { - var v = from[_i]; - to.push(v); - } - } - } - ts.addRange = addRange; - function rangeEquals(array1, array2, pos, end) { - while (pos < end) { - if (array1[pos] !== array2[pos]) { - return false; - } - pos++; - } - return true; - } - ts.rangeEquals = rangeEquals; - function lastOrUndefined(array) { - if (array.length === 0) { - return undefined; - } - return array[array.length - 1]; - } - ts.lastOrUndefined = lastOrUndefined; - function binarySearch(array, value) { - var low = 0; - var high = array.length - 1; - while (low <= high) { - var middle = low + ((high - low) >> 1); - var midValue = array[middle]; - if (midValue === value) { - return middle; - } - else if (midValue > value) { - high = middle - 1; - } - else { - low = middle + 1; - } - } - return ~low; - } - ts.binarySearch = binarySearch; - function reduceLeft(array, f, initial) { - if (array) { - var count = array.length; - if (count > 0) { - var pos = 0; - var result = arguments.length <= 2 ? array[pos++] : initial; - while (pos < count) { - result = f(result, array[pos++]); - } - return result; - } - } - return initial; - } - ts.reduceLeft = reduceLeft; - function reduceRight(array, f, initial) { - if (array) { - var pos = array.length - 1; - if (pos >= 0) { - var result = arguments.length <= 2 ? array[pos--] : initial; - while (pos >= 0) { - result = f(result, array[pos--]); - } - return result; - } - } - return initial; - } - ts.reduceRight = reduceRight; - var hasOwnProperty = Object.prototype.hasOwnProperty; - function hasProperty(map, key) { - return hasOwnProperty.call(map, key); - } - ts.hasProperty = hasProperty; - function getProperty(map, key) { - return hasOwnProperty.call(map, key) ? map[key] : undefined; - } - ts.getProperty = getProperty; - function isEmpty(map) { - for (var id in map) { - if (hasProperty(map, id)) { - return false; - } - } - return true; - } - ts.isEmpty = isEmpty; - function clone(object) { - var result = {}; - for (var id in object) { - result[id] = object[id]; - } - return result; - } - ts.clone = clone; - function extend(first, second) { - var result = {}; - for (var id in first) { - result[id] = first[id]; - } - for (var id in second) { - if (!hasProperty(result, id)) { - result[id] = second[id]; - } - } - return result; - } - ts.extend = extend; - function forEachValue(map, callback) { - var result; - for (var id in map) { - if (result = callback(map[id])) - break; - } - return result; - } - ts.forEachValue = forEachValue; - function forEachKey(map, callback) { - var result; - for (var id in map) { - if (result = callback(id)) - break; - } - return result; - } - ts.forEachKey = forEachKey; - function lookUp(map, key) { - return hasProperty(map, key) ? map[key] : undefined; - } - ts.lookUp = lookUp; - function copyMap(source, target) { - for (var p in source) { - target[p] = source[p]; - } - } - ts.copyMap = copyMap; - function arrayToMap(array, makeKey) { - var result = {}; - forEach(array, function (value) { - result[makeKey(value)] = value; - }); - return result; - } - ts.arrayToMap = arrayToMap; - function memoize(callback) { - var value; - return function () { - if (callback) { - value = callback(); - callback = undefined; - } - return value; - }; - } - ts.memoize = memoize; - function formatStringFromArgs(text, args, baseIndex) { - baseIndex = baseIndex || 0; - return text.replace(/{(\d+)}/g, function (match, index) { return args[+index + baseIndex]; }); - } - ts.localizedDiagnosticMessages = undefined; - function getLocaleSpecificMessage(message) { - return ts.localizedDiagnosticMessages && ts.localizedDiagnosticMessages[message] - ? ts.localizedDiagnosticMessages[message] - : message; - } - ts.getLocaleSpecificMessage = getLocaleSpecificMessage; - function createFileDiagnostic(file, start, length, message) { - var end = start + length; - Debug.assert(start >= 0, "start must be non-negative, is " + start); - Debug.assert(length >= 0, "length must be non-negative, is " + length); - if (file) { - Debug.assert(start <= file.text.length, "start must be within the bounds of the file. " + start + " > " + file.text.length); - Debug.assert(end <= file.text.length, "end must be the bounds of the file. " + end + " > " + file.text.length); - } - var text = getLocaleSpecificMessage(message.key); - if (arguments.length > 4) { - text = formatStringFromArgs(text, arguments, 4); - } - return { - file: file, - start: start, - length: length, - messageText: text, - category: message.category, - code: message.code - }; - } - ts.createFileDiagnostic = createFileDiagnostic; - function createCompilerDiagnostic(message) { - var text = getLocaleSpecificMessage(message.key); - if (arguments.length > 1) { - text = formatStringFromArgs(text, arguments, 1); - } - return { - file: undefined, - start: undefined, - length: undefined, - messageText: text, - category: message.category, - code: message.code - }; - } - ts.createCompilerDiagnostic = createCompilerDiagnostic; - function chainDiagnosticMessages(details, message) { - var text = getLocaleSpecificMessage(message.key); - if (arguments.length > 2) { - text = formatStringFromArgs(text, arguments, 2); - } - return { - messageText: text, - category: message.category, - code: message.code, - next: details - }; - } - ts.chainDiagnosticMessages = chainDiagnosticMessages; - function concatenateDiagnosticMessageChains(headChain, tailChain) { - var lastChain = headChain; - while (lastChain.next) { - lastChain = lastChain.next; - } - lastChain.next = tailChain; - return headChain; - } - ts.concatenateDiagnosticMessageChains = concatenateDiagnosticMessageChains; - function compareValues(a, b) { - if (a === b) - return 0; - if (a === undefined) - return -1; - if (b === undefined) - return 1; - return a < b ? -1 : 1; - } - ts.compareValues = compareValues; - function getDiagnosticFileName(diagnostic) { - return diagnostic.file ? diagnostic.file.fileName : undefined; - } - function compareDiagnostics(d1, d2) { - return compareValues(getDiagnosticFileName(d1), getDiagnosticFileName(d2)) || - compareValues(d1.start, d2.start) || - compareValues(d1.length, d2.length) || - compareValues(d1.code, d2.code) || - compareMessageText(d1.messageText, d2.messageText) || - 0; - } - ts.compareDiagnostics = compareDiagnostics; - function compareMessageText(text1, text2) { - while (text1 && text2) { - var string1 = typeof text1 === "string" ? text1 : text1.messageText; - var string2 = typeof text2 === "string" ? text2 : text2.messageText; - var res = compareValues(string1, string2); - if (res) { - return res; - } - text1 = typeof text1 === "string" ? undefined : text1.next; - text2 = typeof text2 === "string" ? undefined : text2.next; - } - if (!text1 && !text2) { - return 0; - } - return text1 ? 1 : -1; - } - function sortAndDeduplicateDiagnostics(diagnostics) { - return deduplicateSortedDiagnostics(diagnostics.sort(compareDiagnostics)); - } - ts.sortAndDeduplicateDiagnostics = sortAndDeduplicateDiagnostics; - function deduplicateSortedDiagnostics(diagnostics) { - if (diagnostics.length < 2) { - return diagnostics; - } - var newDiagnostics = [diagnostics[0]]; - var previousDiagnostic = diagnostics[0]; - for (var i = 1; i < diagnostics.length; i++) { - var currentDiagnostic = diagnostics[i]; - var isDupe = compareDiagnostics(currentDiagnostic, previousDiagnostic) === 0; - if (!isDupe) { - newDiagnostics.push(currentDiagnostic); - previousDiagnostic = currentDiagnostic; - } - } - return newDiagnostics; - } - ts.deduplicateSortedDiagnostics = deduplicateSortedDiagnostics; - function normalizeSlashes(path) { - return path.replace(/\\/g, "/"); - } - ts.normalizeSlashes = normalizeSlashes; - function getRootLength(path) { - if (path.charCodeAt(0) === 47) { - if (path.charCodeAt(1) !== 47) - return 1; - var p1 = path.indexOf("/", 2); - if (p1 < 0) - return 2; - var p2 = path.indexOf("/", p1 + 1); - if (p2 < 0) - return p1 + 1; - return p2 + 1; - } - if (path.charCodeAt(1) === 58) { - if (path.charCodeAt(2) === 47) - return 3; - return 2; - } - if (path.lastIndexOf("file:///", 0) === 0) { - return "file:///".length; - } - var idx = path.indexOf("://"); - if (idx !== -1) { - return idx + "://".length; - } - return 0; - } - ts.getRootLength = getRootLength; - ts.directorySeparator = "/"; - function getNormalizedParts(normalizedSlashedPath, rootLength) { - var parts = normalizedSlashedPath.substr(rootLength).split(ts.directorySeparator); - var normalized = []; - for (var _i = 0; _i < parts.length; _i++) { - var part = parts[_i]; - if (part !== ".") { - if (part === ".." && normalized.length > 0 && lastOrUndefined(normalized) !== "..") { - normalized.pop(); - } - else { - if (part) { - normalized.push(part); - } - } - } - } - return normalized; - } - function normalizePath(path) { - path = normalizeSlashes(path); - var rootLength = getRootLength(path); - var normalized = getNormalizedParts(path, rootLength); - return path.substr(0, rootLength) + normalized.join(ts.directorySeparator); - } - ts.normalizePath = normalizePath; - function getDirectoryPath(path) { - return path.substr(0, Math.max(getRootLength(path), path.lastIndexOf(ts.directorySeparator))); - } - ts.getDirectoryPath = getDirectoryPath; - function isUrl(path) { - return path && !isRootedDiskPath(path) && path.indexOf("://") !== -1; - } - ts.isUrl = isUrl; - function isRootedDiskPath(path) { - return getRootLength(path) !== 0; - } - ts.isRootedDiskPath = isRootedDiskPath; - function normalizedPathComponents(path, rootLength) { - var normalizedParts = getNormalizedParts(path, rootLength); - return [path.substr(0, rootLength)].concat(normalizedParts); - } - function getNormalizedPathComponents(path, currentDirectory) { - path = normalizeSlashes(path); - var rootLength = getRootLength(path); - if (rootLength === 0) { - path = combinePaths(normalizeSlashes(currentDirectory), path); - rootLength = getRootLength(path); - } - return normalizedPathComponents(path, rootLength); - } - ts.getNormalizedPathComponents = getNormalizedPathComponents; - function getNormalizedAbsolutePath(fileName, currentDirectory) { - return getNormalizedPathFromPathComponents(getNormalizedPathComponents(fileName, currentDirectory)); - } - ts.getNormalizedAbsolutePath = getNormalizedAbsolutePath; - function getNormalizedPathFromPathComponents(pathComponents) { - if (pathComponents && pathComponents.length) { - return pathComponents[0] + pathComponents.slice(1).join(ts.directorySeparator); - } - } - ts.getNormalizedPathFromPathComponents = getNormalizedPathFromPathComponents; - function getNormalizedPathComponentsOfUrl(url) { - var urlLength = url.length; - var rootLength = url.indexOf("://") + "://".length; - while (rootLength < urlLength) { - if (url.charCodeAt(rootLength) === 47) { - rootLength++; - } - else { - break; - } - } - if (rootLength === urlLength) { - return [url]; - } - var indexOfNextSlash = url.indexOf(ts.directorySeparator, rootLength); - if (indexOfNextSlash !== -1) { - rootLength = indexOfNextSlash + 1; - return normalizedPathComponents(url, rootLength); - } - else { - return [url + ts.directorySeparator]; - } - } - function getNormalizedPathOrUrlComponents(pathOrUrl, currentDirectory) { - if (isUrl(pathOrUrl)) { - return getNormalizedPathComponentsOfUrl(pathOrUrl); - } - else { - return getNormalizedPathComponents(pathOrUrl, currentDirectory); - } - } - function getRelativePathToDirectoryOrUrl(directoryPathOrUrl, relativeOrAbsolutePath, currentDirectory, getCanonicalFileName, isAbsolutePathAnUrl) { - var pathComponents = getNormalizedPathOrUrlComponents(relativeOrAbsolutePath, currentDirectory); - var directoryComponents = getNormalizedPathOrUrlComponents(directoryPathOrUrl, currentDirectory); - if (directoryComponents.length > 1 && lastOrUndefined(directoryComponents) === "") { - directoryComponents.length--; - } - for (var joinStartIndex = 0; joinStartIndex < pathComponents.length && joinStartIndex < directoryComponents.length; joinStartIndex++) { - if (getCanonicalFileName(directoryComponents[joinStartIndex]) !== getCanonicalFileName(pathComponents[joinStartIndex])) { - break; - } - } - if (joinStartIndex) { - var relativePath = ""; - var relativePathComponents = pathComponents.slice(joinStartIndex, pathComponents.length); - for (; joinStartIndex < directoryComponents.length; joinStartIndex++) { - if (directoryComponents[joinStartIndex] !== "") { - relativePath = relativePath + ".." + ts.directorySeparator; - } - } - return relativePath + relativePathComponents.join(ts.directorySeparator); - } - var absolutePath = getNormalizedPathFromPathComponents(pathComponents); - if (isAbsolutePathAnUrl && isRootedDiskPath(absolutePath)) { - absolutePath = "file:///" + absolutePath; - } - return absolutePath; - } - ts.getRelativePathToDirectoryOrUrl = getRelativePathToDirectoryOrUrl; - function getBaseFileName(path) { - if (!path) { - return undefined; - } - var i = path.lastIndexOf(ts.directorySeparator); - return i < 0 ? path : path.substring(i + 1); - } - ts.getBaseFileName = getBaseFileName; - function combinePaths(path1, path2) { - if (!(path1 && path1.length)) - return path2; - if (!(path2 && path2.length)) - return path1; - if (getRootLength(path2) !== 0) - return path2; - if (path1.charAt(path1.length - 1) === ts.directorySeparator) - return path1 + path2; - return path1 + ts.directorySeparator + path2; - } - ts.combinePaths = combinePaths; - function fileExtensionIs(path, extension) { - var pathLen = path.length; - var extLen = extension.length; - return pathLen > extLen && path.substr(pathLen - extLen, extLen) === extension; - } - ts.fileExtensionIs = fileExtensionIs; - ts.supportedExtensions = [".ts", ".tsx", ".d.ts"]; - ts.moduleFileExtensions = ts.supportedExtensions; - function isSupportedSourceFileName(fileName) { - if (!fileName) { - return false; - } - for (var _i = 0; _i < ts.supportedExtensions.length; _i++) { - var extension = ts.supportedExtensions[_i]; - if (fileExtensionIs(fileName, extension)) { - return true; - } - } - return false; - } - ts.isSupportedSourceFileName = isSupportedSourceFileName; - var extensionsToRemove = [".d.ts", ".ts", ".js", ".tsx", ".jsx"]; - function removeFileExtension(path) { - for (var _i = 0; _i < extensionsToRemove.length; _i++) { - var ext = extensionsToRemove[_i]; - if (fileExtensionIs(path, ext)) { - return path.substr(0, path.length - ext.length); - } - } - return path; - } - ts.removeFileExtension = removeFileExtension; - var backslashOrDoubleQuote = /[\"\\]/g; - var escapedCharsRegExp = /[\u0000-\u001f\t\v\f\b\r\n\u2028\u2029\u0085]/g; - var escapedCharsMap = { - "\0": "\\0", - "\t": "\\t", - "\v": "\\v", - "\f": "\\f", - "\b": "\\b", - "\r": "\\r", - "\n": "\\n", - "\\": "\\\\", - "\"": "\\\"", - "\u2028": "\\u2028", - "\u2029": "\\u2029", - "\u0085": "\\u0085" - }; - function Symbol(flags, name) { - this.flags = flags; - this.name = name; - this.declarations = undefined; - } - function Type(checker, flags) { - this.flags = flags; - } - function Signature(checker) { - } - ts.objectAllocator = { - getNodeConstructor: function (kind) { - function Node(pos, end) { - this.pos = pos; - this.end = end; - this.flags = 0; - this.parent = undefined; - } - Node.prototype = { kind: kind }; - return Node; - }, - getSymbolConstructor: function () { return Symbol; }, - getTypeConstructor: function () { return Type; }, - getSignatureConstructor: function () { return Signature; } - }; - var Debug; - (function (Debug) { - var currentAssertionLevel = 0; - function shouldAssert(level) { - return currentAssertionLevel >= level; - } - Debug.shouldAssert = shouldAssert; - function assert(expression, message, verboseDebugInfo) { - if (!expression) { - var verboseDebugString = ""; - if (verboseDebugInfo) { - verboseDebugString = "\r\nVerbose Debug Information: " + verboseDebugInfo(); - } - throw new Error("Debug Failure. False expression: " + (message || "") + verboseDebugString); - } - } - Debug.assert = assert; - function fail(message) { - Debug.assert(false, message); - } - Debug.fail = fail; - })(Debug = ts.Debug || (ts.Debug = {})); - function copyListRemovingItem(item, list) { - var copiedList = []; - for (var _i = 0; _i < list.length; _i++) { - var e = list[_i]; - if (e !== item) { - copiedList.push(e); - } - } - return copiedList; - } - ts.copyListRemovingItem = copyListRemovingItem; -})(ts || (ts = {})); -var ts; -(function (ts) { - ts.sys = (function () { - function getWScriptSystem() { - var fso = new ActiveXObject("Scripting.FileSystemObject"); - var fileStream = new ActiveXObject("ADODB.Stream"); - fileStream.Type = 2; - var binaryStream = new ActiveXObject("ADODB.Stream"); - binaryStream.Type = 1; - var args = []; - for (var i = 0; i < WScript.Arguments.length; i++) { - args[i] = WScript.Arguments.Item(i); - } - function readFile(fileName, encoding) { - if (!fso.FileExists(fileName)) { - return undefined; - } - fileStream.Open(); - try { - if (encoding) { - fileStream.Charset = encoding; - fileStream.LoadFromFile(fileName); - } - else { - fileStream.Charset = "x-ansi"; - fileStream.LoadFromFile(fileName); - var bom = fileStream.ReadText(2) || ""; - fileStream.Position = 0; - fileStream.Charset = bom.length >= 2 && (bom.charCodeAt(0) === 0xFF && bom.charCodeAt(1) === 0xFE || bom.charCodeAt(0) === 0xFE && bom.charCodeAt(1) === 0xFF) ? "unicode" : "utf-8"; - } - return fileStream.ReadText(); - } - catch (e) { - throw e; - } - finally { - fileStream.Close(); - } - } - function writeFile(fileName, data, writeByteOrderMark) { - fileStream.Open(); - binaryStream.Open(); - try { - fileStream.Charset = "utf-8"; - fileStream.WriteText(data); - if (writeByteOrderMark) { - fileStream.Position = 0; - } - else { - fileStream.Position = 3; - } - fileStream.CopyTo(binaryStream); - binaryStream.SaveToFile(fileName, 2); - } - finally { - binaryStream.Close(); - fileStream.Close(); - } - } - function getCanonicalPath(path) { - return path.toLowerCase(); - } - function getNames(collection) { - var result = []; - for (var e = new Enumerator(collection); !e.atEnd(); e.moveNext()) { - result.push(e.item().Name); - } - return result.sort(); - } - function readDirectory(path, extension, exclude) { - var result = []; - exclude = ts.map(exclude, function (s) { return getCanonicalPath(ts.combinePaths(path, s)); }); - visitDirectory(path); - return result; - function visitDirectory(path) { - var folder = fso.GetFolder(path || "."); - var files = getNames(folder.files); - for (var _i = 0; _i < files.length; _i++) { - var current = files[_i]; - var name_1 = ts.combinePaths(path, current); - if ((!extension || ts.fileExtensionIs(name_1, extension)) && !ts.contains(exclude, getCanonicalPath(name_1))) { - result.push(name_1); - } - } - var subfolders = getNames(folder.subfolders); - for (var _a = 0; _a < subfolders.length; _a++) { - var current = subfolders[_a]; - var name_2 = ts.combinePaths(path, current); - if (!ts.contains(exclude, getCanonicalPath(name_2))) { - visitDirectory(name_2); - } - } - } - } - return { - args: args, - newLine: "\r\n", - useCaseSensitiveFileNames: false, - write: function (s) { - WScript.StdOut.Write(s); - }, - readFile: readFile, - writeFile: writeFile, - resolvePath: function (path) { - return fso.GetAbsolutePathName(path); - }, - fileExists: function (path) { - return fso.FileExists(path); - }, - directoryExists: function (path) { - return fso.FolderExists(path); - }, - createDirectory: function (directoryName) { - if (!this.directoryExists(directoryName)) { - fso.CreateFolder(directoryName); - } - }, - getExecutingFilePath: function () { - return WScript.ScriptFullName; - }, - getCurrentDirectory: function () { - return new ActiveXObject("WScript.Shell").CurrentDirectory; - }, - readDirectory: readDirectory, - exit: function (exitCode) { - try { - WScript.Quit(exitCode); - } - catch (e) { - } - } - }; - } - function getNodeSystem() { - var _fs = require("fs"); - var _path = require("path"); - var _os = require("os"); - function createWatchedFileSet(interval, chunkSize) { - if (interval === void 0) { interval = 2500; } - if (chunkSize === void 0) { chunkSize = 30; } - var watchedFiles = []; - var nextFileToCheck = 0; - var watchTimer; - function getModifiedTime(fileName) { - return _fs.statSync(fileName).mtime; - } - function poll(checkedIndex) { - var watchedFile = watchedFiles[checkedIndex]; - if (!watchedFile) { - return; - } - _fs.stat(watchedFile.fileName, function (err, stats) { - if (err) { - watchedFile.callback(watchedFile.fileName); - } - else if (watchedFile.mtime.getTime() !== stats.mtime.getTime()) { - watchedFile.mtime = getModifiedTime(watchedFile.fileName); - watchedFile.callback(watchedFile.fileName, watchedFile.mtime.getTime() === 0); - } - }); - } - function startWatchTimer() { - watchTimer = setInterval(function () { - var count = 0; - var nextToCheck = nextFileToCheck; - var firstCheck = -1; - while ((count < chunkSize) && (nextToCheck !== firstCheck)) { - poll(nextToCheck); - if (firstCheck < 0) { - firstCheck = nextToCheck; - } - nextToCheck++; - if (nextToCheck === watchedFiles.length) { - nextToCheck = 0; - } - count++; - } - nextFileToCheck = nextToCheck; - }, interval); - } - function addFile(fileName, callback) { - var file = { - fileName: fileName, - callback: callback, - mtime: getModifiedTime(fileName) - }; - watchedFiles.push(file); - if (watchedFiles.length === 1) { - startWatchTimer(); - } - return file; - } - function removeFile(file) { - watchedFiles = ts.copyListRemovingItem(file, watchedFiles); - } - return { - getModifiedTime: getModifiedTime, - poll: poll, - startWatchTimer: startWatchTimer, - addFile: addFile, - removeFile: removeFile - }; - } - var watchedFileSet = createWatchedFileSet(); - function isNode4OrLater() { - return parseInt(process.version.charAt(1)) >= 4; - } - var platform = _os.platform(); - var useCaseSensitiveFileNames = platform !== "win32" && platform !== "win64" && platform !== "darwin"; - function readFile(fileName, encoding) { - if (!_fs.existsSync(fileName)) { - return undefined; - } - var buffer = _fs.readFileSync(fileName); - var len = buffer.length; - if (len >= 2 && buffer[0] === 0xFE && buffer[1] === 0xFF) { - len &= ~1; - for (var i = 0; i < len; i += 2) { - var temp = buffer[i]; - buffer[i] = buffer[i + 1]; - buffer[i + 1] = temp; - } - return buffer.toString("utf16le", 2); - } - if (len >= 2 && buffer[0] === 0xFF && buffer[1] === 0xFE) { - return buffer.toString("utf16le", 2); - } - if (len >= 3 && buffer[0] === 0xEF && buffer[1] === 0xBB && buffer[2] === 0xBF) { - return buffer.toString("utf8", 3); - } - return buffer.toString("utf8"); - } - function writeFile(fileName, data, writeByteOrderMark) { - if (writeByteOrderMark) { - data = "\uFEFF" + data; - } - _fs.writeFileSync(fileName, data, "utf8"); - } - function getCanonicalPath(path) { - return useCaseSensitiveFileNames ? path.toLowerCase() : path; - } - function readDirectory(path, extension, exclude) { - var result = []; - exclude = ts.map(exclude, function (s) { return getCanonicalPath(ts.combinePaths(path, s)); }); - visitDirectory(path); - return result; - function visitDirectory(path) { - var files = _fs.readdirSync(path || ".").sort(); - var directories = []; - for (var _i = 0; _i < files.length; _i++) { - var current = files[_i]; - var name_3 = ts.combinePaths(path, current); - if (!ts.contains(exclude, getCanonicalPath(name_3))) { - var stat = _fs.statSync(name_3); - if (stat.isFile()) { - if (!extension || ts.fileExtensionIs(name_3, extension)) { - result.push(name_3); - } - } - else if (stat.isDirectory()) { - directories.push(name_3); - } - } - } - for (var _a = 0; _a < directories.length; _a++) { - var current = directories[_a]; - visitDirectory(current); - } - } - } - return { - args: process.argv.slice(2), - newLine: _os.EOL, - useCaseSensitiveFileNames: useCaseSensitiveFileNames, - write: function (s) { - var buffer = new Buffer(s, "utf8"); - var offset = 0; - var toWrite = buffer.length; - var written = 0; - while ((written = _fs.writeSync(1, buffer, offset, toWrite)) < toWrite) { - offset += written; - toWrite -= written; - } - }, - readFile: readFile, - writeFile: writeFile, - watchFile: function (fileName, callback) { - if (isNode4OrLater()) { - return _fs.watch(fileName, function (eventName, relativeFileName) { return callback(fileName); }); - } - var watchedFile = watchedFileSet.addFile(fileName, callback); - return { - close: function () { return watchedFileSet.removeFile(watchedFile); } - }; - }, - watchDirectory: function (path, callback, recursive) { - return _fs.watch(path, { persistent: true, recursive: !!recursive }, function (eventName, relativeFileName) { - if (eventName === "rename") { - callback(!relativeFileName ? relativeFileName : ts.normalizePath(ts.combinePaths(path, relativeFileName))); - } - ; - }); - }, - resolvePath: function (path) { - return _path.resolve(path); - }, - fileExists: function (path) { - return _fs.existsSync(path); - }, - directoryExists: function (path) { - return _fs.existsSync(path) && _fs.statSync(path).isDirectory(); - }, - createDirectory: function (directoryName) { - if (!this.directoryExists(directoryName)) { - _fs.mkdirSync(directoryName); - } - }, - getExecutingFilePath: function () { - return __filename; - }, - getCurrentDirectory: function () { - return process.cwd(); - }, - readDirectory: readDirectory, - getMemoryUsage: function () { - if (global.gc) { - global.gc(); - } - return process.memoryUsage().heapUsed; - }, - exit: function (exitCode) { - process.exit(exitCode); - } - }; - } - if (typeof WScript !== "undefined" && typeof ActiveXObject === "function") { - return getWScriptSystem(); - } - else if (typeof process !== "undefined" && process.nextTick && !process.browser && typeof require !== "undefined") { - return getNodeSystem(); - } - else { - return undefined; - } - })(); -})(ts || (ts = {})); -var ts; -(function (ts) { - ts.Diagnostics = { - Unterminated_string_literal: { code: 1002, category: ts.DiagnosticCategory.Error, key: "Unterminated string literal." }, - Identifier_expected: { code: 1003, category: ts.DiagnosticCategory.Error, key: "Identifier expected." }, - _0_expected: { code: 1005, category: ts.DiagnosticCategory.Error, key: "'{0}' expected." }, - A_file_cannot_have_a_reference_to_itself: { code: 1006, category: ts.DiagnosticCategory.Error, key: "A file cannot have a reference to itself." }, - Trailing_comma_not_allowed: { code: 1009, category: ts.DiagnosticCategory.Error, key: "Trailing comma not allowed." }, - Asterisk_Slash_expected: { code: 1010, category: ts.DiagnosticCategory.Error, key: "'*/' expected." }, - Unexpected_token: { code: 1012, category: ts.DiagnosticCategory.Error, key: "Unexpected token." }, - A_rest_parameter_must_be_last_in_a_parameter_list: { code: 1014, category: ts.DiagnosticCategory.Error, key: "A rest parameter must be last in a parameter list." }, - Parameter_cannot_have_question_mark_and_initializer: { code: 1015, category: ts.DiagnosticCategory.Error, key: "Parameter cannot have question mark and initializer." }, - A_required_parameter_cannot_follow_an_optional_parameter: { code: 1016, category: ts.DiagnosticCategory.Error, key: "A required parameter cannot follow an optional parameter." }, - An_index_signature_cannot_have_a_rest_parameter: { code: 1017, category: ts.DiagnosticCategory.Error, key: "An index signature cannot have a rest parameter." }, - An_index_signature_parameter_cannot_have_an_accessibility_modifier: { code: 1018, category: ts.DiagnosticCategory.Error, key: "An index signature parameter cannot have an accessibility modifier." }, - An_index_signature_parameter_cannot_have_a_question_mark: { code: 1019, category: ts.DiagnosticCategory.Error, key: "An index signature parameter cannot have a question mark." }, - An_index_signature_parameter_cannot_have_an_initializer: { code: 1020, category: ts.DiagnosticCategory.Error, key: "An index signature parameter cannot have an initializer." }, - An_index_signature_must_have_a_type_annotation: { code: 1021, category: ts.DiagnosticCategory.Error, key: "An index signature must have a type annotation." }, - An_index_signature_parameter_must_have_a_type_annotation: { code: 1022, category: ts.DiagnosticCategory.Error, key: "An index signature parameter must have a type annotation." }, - An_index_signature_parameter_type_must_be_string_or_number: { code: 1023, category: ts.DiagnosticCategory.Error, key: "An index signature parameter type must be 'string' or 'number'." }, - Accessibility_modifier_already_seen: { code: 1028, category: ts.DiagnosticCategory.Error, key: "Accessibility modifier already seen." }, - _0_modifier_must_precede_1_modifier: { code: 1029, category: ts.DiagnosticCategory.Error, key: "'{0}' modifier must precede '{1}' modifier." }, - _0_modifier_already_seen: { code: 1030, category: ts.DiagnosticCategory.Error, key: "'{0}' modifier already seen." }, - _0_modifier_cannot_appear_on_a_class_element: { code: 1031, category: ts.DiagnosticCategory.Error, key: "'{0}' modifier cannot appear on a class element." }, - super_must_be_followed_by_an_argument_list_or_member_access: { code: 1034, category: ts.DiagnosticCategory.Error, key: "'super' must be followed by an argument list or member access." }, - Only_ambient_modules_can_use_quoted_names: { code: 1035, category: ts.DiagnosticCategory.Error, key: "Only ambient modules can use quoted names." }, - Statements_are_not_allowed_in_ambient_contexts: { code: 1036, category: ts.DiagnosticCategory.Error, key: "Statements are not allowed in ambient contexts." }, - A_declare_modifier_cannot_be_used_in_an_already_ambient_context: { code: 1038, category: ts.DiagnosticCategory.Error, key: "A 'declare' modifier cannot be used in an already ambient context." }, - Initializers_are_not_allowed_in_ambient_contexts: { code: 1039, category: ts.DiagnosticCategory.Error, key: "Initializers are not allowed in ambient contexts." }, - _0_modifier_cannot_be_used_in_an_ambient_context: { code: 1040, category: ts.DiagnosticCategory.Error, key: "'{0}' modifier cannot be used in an ambient context." }, - _0_modifier_cannot_be_used_with_a_class_declaration: { code: 1041, category: ts.DiagnosticCategory.Error, key: "'{0}' modifier cannot be used with a class declaration." }, - _0_modifier_cannot_be_used_here: { code: 1042, category: ts.DiagnosticCategory.Error, key: "'{0}' modifier cannot be used here." }, - _0_modifier_cannot_appear_on_a_data_property: { code: 1043, category: ts.DiagnosticCategory.Error, key: "'{0}' modifier cannot appear on a data property." }, - _0_modifier_cannot_appear_on_a_module_element: { code: 1044, category: ts.DiagnosticCategory.Error, key: "'{0}' modifier cannot appear on a module element." }, - A_0_modifier_cannot_be_used_with_an_interface_declaration: { code: 1045, category: ts.DiagnosticCategory.Error, key: "A '{0}' modifier cannot be used with an interface declaration." }, - A_declare_modifier_is_required_for_a_top_level_declaration_in_a_d_ts_file: { code: 1046, category: ts.DiagnosticCategory.Error, key: "A 'declare' modifier is required for a top level declaration in a .d.ts file." }, - A_rest_parameter_cannot_be_optional: { code: 1047, category: ts.DiagnosticCategory.Error, key: "A rest parameter cannot be optional." }, - A_rest_parameter_cannot_have_an_initializer: { code: 1048, category: ts.DiagnosticCategory.Error, key: "A rest parameter cannot have an initializer." }, - A_set_accessor_must_have_exactly_one_parameter: { code: 1049, category: ts.DiagnosticCategory.Error, key: "A 'set' accessor must have exactly one parameter." }, - A_set_accessor_cannot_have_an_optional_parameter: { code: 1051, category: ts.DiagnosticCategory.Error, key: "A 'set' accessor cannot have an optional parameter." }, - A_set_accessor_parameter_cannot_have_an_initializer: { code: 1052, category: ts.DiagnosticCategory.Error, key: "A 'set' accessor parameter cannot have an initializer." }, - A_set_accessor_cannot_have_rest_parameter: { code: 1053, category: ts.DiagnosticCategory.Error, key: "A 'set' accessor cannot have rest parameter." }, - A_get_accessor_cannot_have_parameters: { code: 1054, category: ts.DiagnosticCategory.Error, key: "A 'get' accessor cannot have parameters." }, - Type_0_is_not_a_valid_async_function_return_type: { code: 1055, category: ts.DiagnosticCategory.Error, key: "Type '{0}' is not a valid async function return type." }, - Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher: { code: 1056, category: ts.DiagnosticCategory.Error, key: "Accessors are only available when targeting ECMAScript 5 and higher." }, - An_async_function_or_method_must_have_a_valid_awaitable_return_type: { code: 1057, category: ts.DiagnosticCategory.Error, key: "An async function or method must have a valid awaitable return type." }, - Operand_for_await_does_not_have_a_valid_callable_then_member: { code: 1058, category: ts.DiagnosticCategory.Error, key: "Operand for 'await' does not have a valid callable 'then' member." }, - Return_expression_in_async_function_does_not_have_a_valid_callable_then_member: { code: 1059, category: ts.DiagnosticCategory.Error, key: "Return expression in async function does not have a valid callable 'then' member." }, - Expression_body_for_async_arrow_function_does_not_have_a_valid_callable_then_member: { code: 1060, category: ts.DiagnosticCategory.Error, key: "Expression body for async arrow function does not have a valid callable 'then' member." }, - Enum_member_must_have_initializer: { code: 1061, category: ts.DiagnosticCategory.Error, key: "Enum member must have initializer." }, - _0_is_referenced_directly_or_indirectly_in_the_fulfillment_callback_of_its_own_then_method: { code: 1062, category: ts.DiagnosticCategory.Error, key: "{0} is referenced directly or indirectly in the fulfillment callback of its own 'then' method." }, - An_export_assignment_cannot_be_used_in_a_namespace: { code: 1063, category: ts.DiagnosticCategory.Error, key: "An export assignment cannot be used in a namespace." }, - In_ambient_enum_declarations_member_initializer_must_be_constant_expression: { code: 1066, category: ts.DiagnosticCategory.Error, key: "In ambient enum declarations member initializer must be constant expression." }, - Unexpected_token_A_constructor_method_accessor_or_property_was_expected: { code: 1068, category: ts.DiagnosticCategory.Error, key: "Unexpected token. A constructor, method, accessor, or property was expected." }, - A_0_modifier_cannot_be_used_with_an_import_declaration: { code: 1079, category: ts.DiagnosticCategory.Error, key: "A '{0}' modifier cannot be used with an import declaration." }, - Invalid_reference_directive_syntax: { code: 1084, category: ts.DiagnosticCategory.Error, key: "Invalid 'reference' directive syntax." }, - Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher: { code: 1085, category: ts.DiagnosticCategory.Error, key: "Octal literals are not available when targeting ECMAScript 5 and higher." }, - An_accessor_cannot_be_declared_in_an_ambient_context: { code: 1086, category: ts.DiagnosticCategory.Error, key: "An accessor cannot be declared in an ambient context." }, - _0_modifier_cannot_appear_on_a_constructor_declaration: { code: 1089, category: ts.DiagnosticCategory.Error, key: "'{0}' modifier cannot appear on a constructor declaration." }, - _0_modifier_cannot_appear_on_a_parameter: { code: 1090, category: ts.DiagnosticCategory.Error, key: "'{0}' modifier cannot appear on a parameter." }, - Only_a_single_variable_declaration_is_allowed_in_a_for_in_statement: { code: 1091, category: ts.DiagnosticCategory.Error, key: "Only a single variable declaration is allowed in a 'for...in' statement." }, - Type_parameters_cannot_appear_on_a_constructor_declaration: { code: 1092, category: ts.DiagnosticCategory.Error, key: "Type parameters cannot appear on a constructor declaration." }, - Type_annotation_cannot_appear_on_a_constructor_declaration: { code: 1093, category: ts.DiagnosticCategory.Error, key: "Type annotation cannot appear on a constructor declaration." }, - An_accessor_cannot_have_type_parameters: { code: 1094, category: ts.DiagnosticCategory.Error, key: "An accessor cannot have type parameters." }, - A_set_accessor_cannot_have_a_return_type_annotation: { code: 1095, category: ts.DiagnosticCategory.Error, key: "A 'set' accessor cannot have a return type annotation." }, - An_index_signature_must_have_exactly_one_parameter: { code: 1096, category: ts.DiagnosticCategory.Error, key: "An index signature must have exactly one parameter." }, - _0_list_cannot_be_empty: { code: 1097, category: ts.DiagnosticCategory.Error, key: "'{0}' list cannot be empty." }, - Type_parameter_list_cannot_be_empty: { code: 1098, category: ts.DiagnosticCategory.Error, key: "Type parameter list cannot be empty." }, - Type_argument_list_cannot_be_empty: { code: 1099, category: ts.DiagnosticCategory.Error, key: "Type argument list cannot be empty." }, - Invalid_use_of_0_in_strict_mode: { code: 1100, category: ts.DiagnosticCategory.Error, key: "Invalid use of '{0}' in strict mode." }, - with_statements_are_not_allowed_in_strict_mode: { code: 1101, category: ts.DiagnosticCategory.Error, key: "'with' statements are not allowed in strict mode." }, - delete_cannot_be_called_on_an_identifier_in_strict_mode: { code: 1102, category: ts.DiagnosticCategory.Error, key: "'delete' cannot be called on an identifier in strict mode." }, - A_continue_statement_can_only_be_used_within_an_enclosing_iteration_statement: { code: 1104, category: ts.DiagnosticCategory.Error, key: "A 'continue' statement can only be used within an enclosing iteration statement." }, - A_break_statement_can_only_be_used_within_an_enclosing_iteration_or_switch_statement: { code: 1105, category: ts.DiagnosticCategory.Error, key: "A 'break' statement can only be used within an enclosing iteration or switch statement." }, - Jump_target_cannot_cross_function_boundary: { code: 1107, category: ts.DiagnosticCategory.Error, key: "Jump target cannot cross function boundary." }, - A_return_statement_can_only_be_used_within_a_function_body: { code: 1108, category: ts.DiagnosticCategory.Error, key: "A 'return' statement can only be used within a function body." }, - Expression_expected: { code: 1109, category: ts.DiagnosticCategory.Error, key: "Expression expected." }, - Type_expected: { code: 1110, category: ts.DiagnosticCategory.Error, key: "Type expected." }, - A_class_member_cannot_be_declared_optional: { code: 1112, category: ts.DiagnosticCategory.Error, key: "A class member cannot be declared optional." }, - A_default_clause_cannot_appear_more_than_once_in_a_switch_statement: { code: 1113, category: ts.DiagnosticCategory.Error, key: "A 'default' clause cannot appear more than once in a 'switch' statement." }, - Duplicate_label_0: { code: 1114, category: ts.DiagnosticCategory.Error, key: "Duplicate label '{0}'" }, - A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement: { code: 1115, category: ts.DiagnosticCategory.Error, key: "A 'continue' statement can only jump to a label of an enclosing iteration statement." }, - A_break_statement_can_only_jump_to_a_label_of_an_enclosing_statement: { code: 1116, category: ts.DiagnosticCategory.Error, key: "A 'break' statement can only jump to a label of an enclosing statement." }, - An_object_literal_cannot_have_multiple_properties_with_the_same_name_in_strict_mode: { code: 1117, category: ts.DiagnosticCategory.Error, key: "An object literal cannot have multiple properties with the same name in strict mode." }, - An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name: { code: 1118, category: ts.DiagnosticCategory.Error, key: "An object literal cannot have multiple get/set accessors with the same name." }, - An_object_literal_cannot_have_property_and_accessor_with_the_same_name: { code: 1119, category: ts.DiagnosticCategory.Error, key: "An object literal cannot have property and accessor with the same name." }, - An_export_assignment_cannot_have_modifiers: { code: 1120, category: ts.DiagnosticCategory.Error, key: "An export assignment cannot have modifiers." }, - Octal_literals_are_not_allowed_in_strict_mode: { code: 1121, category: ts.DiagnosticCategory.Error, key: "Octal literals are not allowed in strict mode." }, - A_tuple_type_element_list_cannot_be_empty: { code: 1122, category: ts.DiagnosticCategory.Error, key: "A tuple type element list cannot be empty." }, - Variable_declaration_list_cannot_be_empty: { code: 1123, category: ts.DiagnosticCategory.Error, key: "Variable declaration list cannot be empty." }, - Digit_expected: { code: 1124, category: ts.DiagnosticCategory.Error, key: "Digit expected." }, - Hexadecimal_digit_expected: { code: 1125, category: ts.DiagnosticCategory.Error, key: "Hexadecimal digit expected." }, - Unexpected_end_of_text: { code: 1126, category: ts.DiagnosticCategory.Error, key: "Unexpected end of text." }, - Invalid_character: { code: 1127, category: ts.DiagnosticCategory.Error, key: "Invalid character." }, - Declaration_or_statement_expected: { code: 1128, category: ts.DiagnosticCategory.Error, key: "Declaration or statement expected." }, - Statement_expected: { code: 1129, category: ts.DiagnosticCategory.Error, key: "Statement expected." }, - case_or_default_expected: { code: 1130, category: ts.DiagnosticCategory.Error, key: "'case' or 'default' expected." }, - Property_or_signature_expected: { code: 1131, category: ts.DiagnosticCategory.Error, key: "Property or signature expected." }, - Enum_member_expected: { code: 1132, category: ts.DiagnosticCategory.Error, key: "Enum member expected." }, - Variable_declaration_expected: { code: 1134, category: ts.DiagnosticCategory.Error, key: "Variable declaration expected." }, - Argument_expression_expected: { code: 1135, category: ts.DiagnosticCategory.Error, key: "Argument expression expected." }, - Property_assignment_expected: { code: 1136, category: ts.DiagnosticCategory.Error, key: "Property assignment expected." }, - Expression_or_comma_expected: { code: 1137, category: ts.DiagnosticCategory.Error, key: "Expression or comma expected." }, - Parameter_declaration_expected: { code: 1138, category: ts.DiagnosticCategory.Error, key: "Parameter declaration expected." }, - Type_parameter_declaration_expected: { code: 1139, category: ts.DiagnosticCategory.Error, key: "Type parameter declaration expected." }, - Type_argument_expected: { code: 1140, category: ts.DiagnosticCategory.Error, key: "Type argument expected." }, - String_literal_expected: { code: 1141, category: ts.DiagnosticCategory.Error, key: "String literal expected." }, - Line_break_not_permitted_here: { code: 1142, category: ts.DiagnosticCategory.Error, key: "Line break not permitted here." }, - or_expected: { code: 1144, category: ts.DiagnosticCategory.Error, key: "'{' or ';' expected." }, - Modifiers_not_permitted_on_index_signature_members: { code: 1145, category: ts.DiagnosticCategory.Error, key: "Modifiers not permitted on index signature members." }, - Declaration_expected: { code: 1146, category: ts.DiagnosticCategory.Error, key: "Declaration expected." }, - Import_declarations_in_a_namespace_cannot_reference_a_module: { code: 1147, category: ts.DiagnosticCategory.Error, key: "Import declarations in a namespace cannot reference a module." }, - Cannot_compile_modules_unless_the_module_flag_is_provided: { code: 1148, category: ts.DiagnosticCategory.Error, key: "Cannot compile modules unless the '--module' flag is provided." }, - File_name_0_differs_from_already_included_file_name_1_only_in_casing: { code: 1149, category: ts.DiagnosticCategory.Error, key: "File name '{0}' differs from already included file name '{1}' only in casing" }, - new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead: { code: 1150, category: ts.DiagnosticCategory.Error, key: "'new T[]' cannot be used to create an array. Use 'new Array()' instead." }, - const_declarations_must_be_initialized: { code: 1155, category: ts.DiagnosticCategory.Error, key: "'const' declarations must be initialized" }, - const_declarations_can_only_be_declared_inside_a_block: { code: 1156, category: ts.DiagnosticCategory.Error, key: "'const' declarations can only be declared inside a block." }, - let_declarations_can_only_be_declared_inside_a_block: { code: 1157, category: ts.DiagnosticCategory.Error, key: "'let' declarations can only be declared inside a block." }, - Unterminated_template_literal: { code: 1160, category: ts.DiagnosticCategory.Error, key: "Unterminated template literal." }, - Unterminated_regular_expression_literal: { code: 1161, category: ts.DiagnosticCategory.Error, key: "Unterminated regular expression literal." }, - An_object_member_cannot_be_declared_optional: { code: 1162, category: ts.DiagnosticCategory.Error, key: "An object member cannot be declared optional." }, - A_yield_expression_is_only_allowed_in_a_generator_body: { code: 1163, category: ts.DiagnosticCategory.Error, key: "A 'yield' expression is only allowed in a generator body." }, - Computed_property_names_are_not_allowed_in_enums: { code: 1164, category: ts.DiagnosticCategory.Error, key: "Computed property names are not allowed in enums." }, - A_computed_property_name_in_an_ambient_context_must_directly_refer_to_a_built_in_symbol: { code: 1165, category: ts.DiagnosticCategory.Error, key: "A computed property name in an ambient context must directly refer to a built-in symbol." }, - A_computed_property_name_in_a_class_property_declaration_must_directly_refer_to_a_built_in_symbol: { code: 1166, category: ts.DiagnosticCategory.Error, key: "A computed property name in a class property declaration must directly refer to a built-in symbol." }, - A_computed_property_name_in_a_method_overload_must_directly_refer_to_a_built_in_symbol: { code: 1168, category: ts.DiagnosticCategory.Error, key: "A computed property name in a method overload must directly refer to a built-in symbol." }, - A_computed_property_name_in_an_interface_must_directly_refer_to_a_built_in_symbol: { code: 1169, category: ts.DiagnosticCategory.Error, key: "A computed property name in an interface must directly refer to a built-in symbol." }, - A_computed_property_name_in_a_type_literal_must_directly_refer_to_a_built_in_symbol: { code: 1170, category: ts.DiagnosticCategory.Error, key: "A computed property name in a type literal must directly refer to a built-in symbol." }, - A_comma_expression_is_not_allowed_in_a_computed_property_name: { code: 1171, category: ts.DiagnosticCategory.Error, key: "A comma expression is not allowed in a computed property name." }, - extends_clause_already_seen: { code: 1172, category: ts.DiagnosticCategory.Error, key: "'extends' clause already seen." }, - extends_clause_must_precede_implements_clause: { code: 1173, category: ts.DiagnosticCategory.Error, key: "'extends' clause must precede 'implements' clause." }, - Classes_can_only_extend_a_single_class: { code: 1174, category: ts.DiagnosticCategory.Error, key: "Classes can only extend a single class." }, - implements_clause_already_seen: { code: 1175, category: ts.DiagnosticCategory.Error, key: "'implements' clause already seen." }, - Interface_declaration_cannot_have_implements_clause: { code: 1176, category: ts.DiagnosticCategory.Error, key: "Interface declaration cannot have 'implements' clause." }, - Binary_digit_expected: { code: 1177, category: ts.DiagnosticCategory.Error, key: "Binary digit expected." }, - Octal_digit_expected: { code: 1178, category: ts.DiagnosticCategory.Error, key: "Octal digit expected." }, - Unexpected_token_expected: { code: 1179, category: ts.DiagnosticCategory.Error, key: "Unexpected token. '{' expected." }, - Property_destructuring_pattern_expected: { code: 1180, category: ts.DiagnosticCategory.Error, key: "Property destructuring pattern expected." }, - Array_element_destructuring_pattern_expected: { code: 1181, category: ts.DiagnosticCategory.Error, key: "Array element destructuring pattern expected." }, - A_destructuring_declaration_must_have_an_initializer: { code: 1182, category: ts.DiagnosticCategory.Error, key: "A destructuring declaration must have an initializer." }, - An_implementation_cannot_be_declared_in_ambient_contexts: { code: 1183, category: ts.DiagnosticCategory.Error, key: "An implementation cannot be declared in ambient contexts." }, - Modifiers_cannot_appear_here: { code: 1184, category: ts.DiagnosticCategory.Error, key: "Modifiers cannot appear here." }, - Merge_conflict_marker_encountered: { code: 1185, category: ts.DiagnosticCategory.Error, key: "Merge conflict marker encountered." }, - A_rest_element_cannot_have_an_initializer: { code: 1186, category: ts.DiagnosticCategory.Error, key: "A rest element cannot have an initializer." }, - A_parameter_property_may_not_be_a_binding_pattern: { code: 1187, category: ts.DiagnosticCategory.Error, key: "A parameter property may not be a binding pattern." }, - Only_a_single_variable_declaration_is_allowed_in_a_for_of_statement: { code: 1188, category: ts.DiagnosticCategory.Error, key: "Only a single variable declaration is allowed in a 'for...of' statement." }, - The_variable_declaration_of_a_for_in_statement_cannot_have_an_initializer: { code: 1189, category: ts.DiagnosticCategory.Error, key: "The variable declaration of a 'for...in' statement cannot have an initializer." }, - The_variable_declaration_of_a_for_of_statement_cannot_have_an_initializer: { code: 1190, category: ts.DiagnosticCategory.Error, key: "The variable declaration of a 'for...of' statement cannot have an initializer." }, - An_import_declaration_cannot_have_modifiers: { code: 1191, category: ts.DiagnosticCategory.Error, key: "An import declaration cannot have modifiers." }, - Module_0_has_no_default_export: { code: 1192, category: ts.DiagnosticCategory.Error, key: "Module '{0}' has no default export." }, - An_export_declaration_cannot_have_modifiers: { code: 1193, category: ts.DiagnosticCategory.Error, key: "An export declaration cannot have modifiers." }, - Export_declarations_are_not_permitted_in_a_namespace: { code: 1194, category: ts.DiagnosticCategory.Error, key: "Export declarations are not permitted in a namespace." }, - Catch_clause_variable_name_must_be_an_identifier: { code: 1195, category: ts.DiagnosticCategory.Error, key: "Catch clause variable name must be an identifier." }, - Catch_clause_variable_cannot_have_a_type_annotation: { code: 1196, category: ts.DiagnosticCategory.Error, key: "Catch clause variable cannot have a type annotation." }, - Catch_clause_variable_cannot_have_an_initializer: { code: 1197, category: ts.DiagnosticCategory.Error, key: "Catch clause variable cannot have an initializer." }, - An_extended_Unicode_escape_value_must_be_between_0x0_and_0x10FFFF_inclusive: { code: 1198, category: ts.DiagnosticCategory.Error, key: "An extended Unicode escape value must be between 0x0 and 0x10FFFF inclusive." }, - Unterminated_Unicode_escape_sequence: { code: 1199, category: ts.DiagnosticCategory.Error, key: "Unterminated Unicode escape sequence." }, - Line_terminator_not_permitted_before_arrow: { code: 1200, category: ts.DiagnosticCategory.Error, key: "Line terminator not permitted before arrow." }, - Import_assignment_cannot_be_used_when_targeting_ECMAScript_6_modules_Consider_using_import_Asterisk_as_ns_from_mod_import_a_from_mod_import_d_from_mod_or_another_module_format_instead: { code: 1202, category: ts.DiagnosticCategory.Error, key: "Import assignment cannot be used when targeting ECMAScript 6 modules. Consider using 'import * as ns from \"mod\"', 'import {a} from \"mod\"', 'import d from \"mod\"', or another module format instead." }, - Export_assignment_cannot_be_used_when_targeting_ECMAScript_6_modules_Consider_using_export_default_or_another_module_format_instead: { code: 1203, category: ts.DiagnosticCategory.Error, key: "Export assignment cannot be used when targeting ECMAScript 6 modules. Consider using 'export default' or another module format instead." }, - Cannot_compile_modules_into_es2015_when_targeting_ES5_or_lower: { code: 1204, category: ts.DiagnosticCategory.Error, key: "Cannot compile modules into 'es2015' when targeting 'ES5' or lower." }, - Decorators_are_not_valid_here: { code: 1206, category: ts.DiagnosticCategory.Error, key: "Decorators are not valid here." }, - Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name: { code: 1207, category: ts.DiagnosticCategory.Error, key: "Decorators cannot be applied to multiple get/set accessors of the same name." }, - Cannot_compile_namespaces_when_the_isolatedModules_flag_is_provided: { code: 1208, category: ts.DiagnosticCategory.Error, key: "Cannot compile namespaces when the '--isolatedModules' flag is provided." }, - Ambient_const_enums_are_not_allowed_when_the_isolatedModules_flag_is_provided: { code: 1209, category: ts.DiagnosticCategory.Error, key: "Ambient const enums are not allowed when the '--isolatedModules' flag is provided." }, - Invalid_use_of_0_Class_definitions_are_automatically_in_strict_mode: { code: 1210, category: ts.DiagnosticCategory.Error, key: "Invalid use of '{0}'. Class definitions are automatically in strict mode." }, - A_class_declaration_without_the_default_modifier_must_have_a_name: { code: 1211, category: ts.DiagnosticCategory.Error, key: "A class declaration without the 'default' modifier must have a name" }, - Identifier_expected_0_is_a_reserved_word_in_strict_mode: { code: 1212, category: ts.DiagnosticCategory.Error, key: "Identifier expected. '{0}' is a reserved word in strict mode" }, - Identifier_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_strict_mode: { code: 1213, category: ts.DiagnosticCategory.Error, key: "Identifier expected. '{0}' is a reserved word in strict mode. Class definitions are automatically in strict mode." }, - Identifier_expected_0_is_a_reserved_word_in_strict_mode_Modules_are_automatically_in_strict_mode: { code: 1214, category: ts.DiagnosticCategory.Error, key: "Identifier expected. '{0}' is a reserved word in strict mode. Modules are automatically in strict mode." }, - Invalid_use_of_0_Modules_are_automatically_in_strict_mode: { code: 1215, category: ts.DiagnosticCategory.Error, key: "Invalid use of '{0}'. Modules are automatically in strict mode." }, - Export_assignment_is_not_supported_when_module_flag_is_system: { code: 1218, category: ts.DiagnosticCategory.Error, key: "Export assignment is not supported when '--module' flag is 'system'." }, - Experimental_support_for_decorators_is_a_feature_that_is_subject_to_change_in_a_future_release_Specify_experimentalDecorators_to_remove_this_warning: { code: 1219, category: ts.DiagnosticCategory.Error, key: "Experimental support for decorators is a feature that is subject to change in a future release. Specify '--experimentalDecorators' to remove this warning." }, - Generators_are_only_available_when_targeting_ECMAScript_6_or_higher: { code: 1220, category: ts.DiagnosticCategory.Error, key: "Generators are only available when targeting ECMAScript 6 or higher." }, - Generators_are_not_allowed_in_an_ambient_context: { code: 1221, category: ts.DiagnosticCategory.Error, key: "Generators are not allowed in an ambient context." }, - An_overload_signature_cannot_be_declared_as_a_generator: { code: 1222, category: ts.DiagnosticCategory.Error, key: "An overload signature cannot be declared as a generator." }, - _0_tag_already_specified: { code: 1223, category: ts.DiagnosticCategory.Error, key: "'{0}' tag already specified." }, - Signature_0_must_have_a_type_predicate: { code: 1224, category: ts.DiagnosticCategory.Error, key: "Signature '{0}' must have a type predicate." }, - Cannot_find_parameter_0: { code: 1225, category: ts.DiagnosticCategory.Error, key: "Cannot find parameter '{0}'." }, - Type_predicate_0_is_not_assignable_to_1: { code: 1226, category: ts.DiagnosticCategory.Error, key: "Type predicate '{0}' is not assignable to '{1}'." }, - Parameter_0_is_not_in_the_same_position_as_parameter_1: { code: 1227, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' is not in the same position as parameter '{1}'." }, - A_type_predicate_is_only_allowed_in_return_type_position_for_functions_and_methods: { code: 1228, category: ts.DiagnosticCategory.Error, key: "A type predicate is only allowed in return type position for functions and methods." }, - A_type_predicate_cannot_reference_a_rest_parameter: { code: 1229, category: ts.DiagnosticCategory.Error, key: "A type predicate cannot reference a rest parameter." }, - A_type_predicate_cannot_reference_element_0_in_a_binding_pattern: { code: 1230, category: ts.DiagnosticCategory.Error, key: "A type predicate cannot reference element '{0}' in a binding pattern." }, - An_export_assignment_can_only_be_used_in_a_module: { code: 1231, category: ts.DiagnosticCategory.Error, key: "An export assignment can only be used in a module." }, - An_import_declaration_can_only_be_used_in_a_namespace_or_module: { code: 1232, category: ts.DiagnosticCategory.Error, key: "An import declaration can only be used in a namespace or module." }, - An_export_declaration_can_only_be_used_in_a_module: { code: 1233, category: ts.DiagnosticCategory.Error, key: "An export declaration can only be used in a module." }, - An_ambient_module_declaration_is_only_allowed_at_the_top_level_in_a_file: { code: 1234, category: ts.DiagnosticCategory.Error, key: "An ambient module declaration is only allowed at the top level in a file." }, - A_namespace_declaration_is_only_allowed_in_a_namespace_or_module: { code: 1235, category: ts.DiagnosticCategory.Error, key: "A namespace declaration is only allowed in a namespace or module." }, - The_return_type_of_a_property_decorator_function_must_be_either_void_or_any: { code: 1236, category: ts.DiagnosticCategory.Error, key: "The return type of a property decorator function must be either 'void' or 'any'." }, - The_return_type_of_a_parameter_decorator_function_must_be_either_void_or_any: { code: 1237, category: ts.DiagnosticCategory.Error, key: "The return type of a parameter decorator function must be either 'void' or 'any'." }, - Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression: { code: 1238, category: ts.DiagnosticCategory.Error, key: "Unable to resolve signature of class decorator when called as an expression." }, - Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression: { code: 1239, category: ts.DiagnosticCategory.Error, key: "Unable to resolve signature of parameter decorator when called as an expression." }, - Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression: { code: 1240, category: ts.DiagnosticCategory.Error, key: "Unable to resolve signature of property decorator when called as an expression." }, - Unable_to_resolve_signature_of_method_decorator_when_called_as_an_expression: { code: 1241, category: ts.DiagnosticCategory.Error, key: "Unable to resolve signature of method decorator when called as an expression." }, - abstract_modifier_can_only_appear_on_a_class_or_method_declaration: { code: 1242, category: ts.DiagnosticCategory.Error, key: "'abstract' modifier can only appear on a class or method declaration." }, - _0_modifier_cannot_be_used_with_1_modifier: { code: 1243, category: ts.DiagnosticCategory.Error, key: "'{0}' modifier cannot be used with '{1}' modifier." }, - Abstract_methods_can_only_appear_within_an_abstract_class: { code: 1244, category: ts.DiagnosticCategory.Error, key: "Abstract methods can only appear within an abstract class." }, - Method_0_cannot_have_an_implementation_because_it_is_marked_abstract: { code: 1245, category: ts.DiagnosticCategory.Error, key: "Method '{0}' cannot have an implementation because it is marked abstract." }, - with_statements_are_not_allowed_in_an_async_function_block: { code: 1300, category: ts.DiagnosticCategory.Error, key: "'with' statements are not allowed in an async function block." }, - await_expression_is_only_allowed_within_an_async_function: { code: 1308, category: ts.DiagnosticCategory.Error, key: "'await' expression is only allowed within an async function." }, - Async_functions_are_only_available_when_targeting_ECMAScript_6_and_higher: { code: 1311, category: ts.DiagnosticCategory.Error, key: "Async functions are only available when targeting ECMAScript 6 and higher." }, - can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment: { code: 1312, category: ts.DiagnosticCategory.Error, key: "'=' can only be used in an object literal property inside a destructuring assignment." }, - Duplicate_identifier_0: { code: 2300, category: ts.DiagnosticCategory.Error, key: "Duplicate identifier '{0}'." }, - Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor: { code: 2301, category: ts.DiagnosticCategory.Error, key: "Initializer of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor." }, - Static_members_cannot_reference_class_type_parameters: { code: 2302, category: ts.DiagnosticCategory.Error, key: "Static members cannot reference class type parameters." }, - Circular_definition_of_import_alias_0: { code: 2303, category: ts.DiagnosticCategory.Error, key: "Circular definition of import alias '{0}'." }, - Cannot_find_name_0: { code: 2304, category: ts.DiagnosticCategory.Error, key: "Cannot find name '{0}'." }, - Module_0_has_no_exported_member_1: { code: 2305, category: ts.DiagnosticCategory.Error, key: "Module '{0}' has no exported member '{1}'." }, - File_0_is_not_a_module: { code: 2306, category: ts.DiagnosticCategory.Error, key: "File '{0}' is not a module." }, - Cannot_find_module_0: { code: 2307, category: ts.DiagnosticCategory.Error, key: "Cannot find module '{0}'." }, - An_export_assignment_cannot_be_used_in_a_module_with_other_exported_elements: { code: 2309, category: ts.DiagnosticCategory.Error, key: "An export assignment cannot be used in a module with other exported elements." }, - Type_0_recursively_references_itself_as_a_base_type: { code: 2310, category: ts.DiagnosticCategory.Error, key: "Type '{0}' recursively references itself as a base type." }, - A_class_may_only_extend_another_class: { code: 2311, category: ts.DiagnosticCategory.Error, key: "A class may only extend another class." }, - An_interface_may_only_extend_a_class_or_another_interface: { code: 2312, category: ts.DiagnosticCategory.Error, key: "An interface may only extend a class or another interface." }, - Constraint_of_a_type_parameter_cannot_reference_any_type_parameter_from_the_same_type_parameter_list: { code: 2313, category: ts.DiagnosticCategory.Error, key: "Constraint of a type parameter cannot reference any type parameter from the same type parameter list." }, - Generic_type_0_requires_1_type_argument_s: { code: 2314, category: ts.DiagnosticCategory.Error, key: "Generic type '{0}' requires {1} type argument(s)." }, - Type_0_is_not_generic: { code: 2315, category: ts.DiagnosticCategory.Error, key: "Type '{0}' is not generic." }, - Global_type_0_must_be_a_class_or_interface_type: { code: 2316, category: ts.DiagnosticCategory.Error, key: "Global type '{0}' must be a class or interface type." }, - Global_type_0_must_have_1_type_parameter_s: { code: 2317, category: ts.DiagnosticCategory.Error, key: "Global type '{0}' must have {1} type parameter(s)." }, - Cannot_find_global_type_0: { code: 2318, category: ts.DiagnosticCategory.Error, key: "Cannot find global type '{0}'." }, - Named_property_0_of_types_1_and_2_are_not_identical: { code: 2319, category: ts.DiagnosticCategory.Error, key: "Named property '{0}' of types '{1}' and '{2}' are not identical." }, - Interface_0_cannot_simultaneously_extend_types_1_and_2: { code: 2320, category: ts.DiagnosticCategory.Error, key: "Interface '{0}' cannot simultaneously extend types '{1}' and '{2}'." }, - Excessive_stack_depth_comparing_types_0_and_1: { code: 2321, category: ts.DiagnosticCategory.Error, key: "Excessive stack depth comparing types '{0}' and '{1}'." }, - Type_0_is_not_assignable_to_type_1: { code: 2322, category: ts.DiagnosticCategory.Error, key: "Type '{0}' is not assignable to type '{1}'." }, - Property_0_is_missing_in_type_1: { code: 2324, category: ts.DiagnosticCategory.Error, key: "Property '{0}' is missing in type '{1}'." }, - Property_0_is_private_in_type_1_but_not_in_type_2: { code: 2325, category: ts.DiagnosticCategory.Error, key: "Property '{0}' is private in type '{1}' but not in type '{2}'." }, - Types_of_property_0_are_incompatible: { code: 2326, category: ts.DiagnosticCategory.Error, key: "Types of property '{0}' are incompatible." }, - Property_0_is_optional_in_type_1_but_required_in_type_2: { code: 2327, category: ts.DiagnosticCategory.Error, key: "Property '{0}' is optional in type '{1}' but required in type '{2}'." }, - Types_of_parameters_0_and_1_are_incompatible: { code: 2328, category: ts.DiagnosticCategory.Error, key: "Types of parameters '{0}' and '{1}' are incompatible." }, - Index_signature_is_missing_in_type_0: { code: 2329, category: ts.DiagnosticCategory.Error, key: "Index signature is missing in type '{0}'." }, - Index_signatures_are_incompatible: { code: 2330, category: ts.DiagnosticCategory.Error, key: "Index signatures are incompatible." }, - this_cannot_be_referenced_in_a_module_or_namespace_body: { code: 2331, category: ts.DiagnosticCategory.Error, key: "'this' cannot be referenced in a module or namespace body." }, - this_cannot_be_referenced_in_current_location: { code: 2332, category: ts.DiagnosticCategory.Error, key: "'this' cannot be referenced in current location." }, - this_cannot_be_referenced_in_constructor_arguments: { code: 2333, category: ts.DiagnosticCategory.Error, key: "'this' cannot be referenced in constructor arguments." }, - this_cannot_be_referenced_in_a_static_property_initializer: { code: 2334, category: ts.DiagnosticCategory.Error, key: "'this' cannot be referenced in a static property initializer." }, - super_can_only_be_referenced_in_a_derived_class: { code: 2335, category: ts.DiagnosticCategory.Error, key: "'super' can only be referenced in a derived class." }, - super_cannot_be_referenced_in_constructor_arguments: { code: 2336, category: ts.DiagnosticCategory.Error, key: "'super' cannot be referenced in constructor arguments." }, - Super_calls_are_not_permitted_outside_constructors_or_in_nested_functions_inside_constructors: { code: 2337, category: ts.DiagnosticCategory.Error, key: "Super calls are not permitted outside constructors or in nested functions inside constructors." }, - super_property_access_is_permitted_only_in_a_constructor_member_function_or_member_accessor_of_a_derived_class: { code: 2338, category: ts.DiagnosticCategory.Error, key: "'super' property access is permitted only in a constructor, member function, or member accessor of a derived class." }, - Property_0_does_not_exist_on_type_1: { code: 2339, category: ts.DiagnosticCategory.Error, key: "Property '{0}' does not exist on type '{1}'." }, - Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword: { code: 2340, category: ts.DiagnosticCategory.Error, key: "Only public and protected methods of the base class are accessible via the 'super' keyword." }, - Property_0_is_private_and_only_accessible_within_class_1: { code: 2341, category: ts.DiagnosticCategory.Error, key: "Property '{0}' is private and only accessible within class '{1}'." }, - An_index_expression_argument_must_be_of_type_string_number_symbol_or_any: { code: 2342, category: ts.DiagnosticCategory.Error, key: "An index expression argument must be of type 'string', 'number', 'symbol', or 'any'." }, - Type_0_does_not_satisfy_the_constraint_1: { code: 2344, category: ts.DiagnosticCategory.Error, key: "Type '{0}' does not satisfy the constraint '{1}'." }, - Argument_of_type_0_is_not_assignable_to_parameter_of_type_1: { code: 2345, category: ts.DiagnosticCategory.Error, key: "Argument of type '{0}' is not assignable to parameter of type '{1}'." }, - Supplied_parameters_do_not_match_any_signature_of_call_target: { code: 2346, category: ts.DiagnosticCategory.Error, key: "Supplied parameters do not match any signature of call target." }, - Untyped_function_calls_may_not_accept_type_arguments: { code: 2347, category: ts.DiagnosticCategory.Error, key: "Untyped function calls may not accept type arguments." }, - Value_of_type_0_is_not_callable_Did_you_mean_to_include_new: { code: 2348, category: ts.DiagnosticCategory.Error, key: "Value of type '{0}' is not callable. Did you mean to include 'new'?" }, - Cannot_invoke_an_expression_whose_type_lacks_a_call_signature: { code: 2349, category: ts.DiagnosticCategory.Error, key: "Cannot invoke an expression whose type lacks a call signature." }, - Only_a_void_function_can_be_called_with_the_new_keyword: { code: 2350, category: ts.DiagnosticCategory.Error, key: "Only a void function can be called with the 'new' keyword." }, - Cannot_use_new_with_an_expression_whose_type_lacks_a_call_or_construct_signature: { code: 2351, category: ts.DiagnosticCategory.Error, key: "Cannot use 'new' with an expression whose type lacks a call or construct signature." }, - Neither_type_0_nor_type_1_is_assignable_to_the_other: { code: 2352, category: ts.DiagnosticCategory.Error, key: "Neither type '{0}' nor type '{1}' is assignable to the other." }, - Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1: { code: 2353, category: ts.DiagnosticCategory.Error, key: "Object literal may only specify known properties, and '{0}' does not exist in type '{1}'." }, - No_best_common_type_exists_among_return_expressions: { code: 2354, category: ts.DiagnosticCategory.Error, key: "No best common type exists among return expressions." }, - A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value_or_consist_of_a_single_throw_statement: { code: 2355, category: ts.DiagnosticCategory.Error, key: "A function whose declared type is neither 'void' nor 'any' must return a value or consist of a single 'throw' statement." }, - An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type: { code: 2356, category: ts.DiagnosticCategory.Error, key: "An arithmetic operand must be of type 'any', 'number' or an enum type." }, - The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_property_or_indexer: { code: 2357, category: ts.DiagnosticCategory.Error, key: "The operand of an increment or decrement operator must be a variable, property or indexer." }, - The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_parameter: { code: 2358, category: ts.DiagnosticCategory.Error, key: "The left-hand side of an 'instanceof' expression must be of type 'any', an object type or a type parameter." }, - The_right_hand_side_of_an_instanceof_expression_must_be_of_type_any_or_of_a_type_assignable_to_the_Function_interface_type: { code: 2359, category: ts.DiagnosticCategory.Error, key: "The right-hand side of an 'instanceof' expression must be of type 'any' or of a type assignable to the 'Function' interface type." }, - The_left_hand_side_of_an_in_expression_must_be_of_type_any_string_number_or_symbol: { code: 2360, category: ts.DiagnosticCategory.Error, key: "The left-hand side of an 'in' expression must be of type 'any', 'string', 'number', or 'symbol'." }, - The_right_hand_side_of_an_in_expression_must_be_of_type_any_an_object_type_or_a_type_parameter: { code: 2361, category: ts.DiagnosticCategory.Error, key: "The right-hand side of an 'in' expression must be of type 'any', an object type or a type parameter" }, - The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type: { code: 2362, category: ts.DiagnosticCategory.Error, key: "The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type." }, - The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type: { code: 2363, category: ts.DiagnosticCategory.Error, key: "The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type." }, - Invalid_left_hand_side_of_assignment_expression: { code: 2364, category: ts.DiagnosticCategory.Error, key: "Invalid left-hand side of assignment expression." }, - Operator_0_cannot_be_applied_to_types_1_and_2: { code: 2365, category: ts.DiagnosticCategory.Error, key: "Operator '{0}' cannot be applied to types '{1}' and '{2}'." }, - Type_parameter_name_cannot_be_0: { code: 2368, category: ts.DiagnosticCategory.Error, key: "Type parameter name cannot be '{0}'" }, - A_parameter_property_is_only_allowed_in_a_constructor_implementation: { code: 2369, category: ts.DiagnosticCategory.Error, key: "A parameter property is only allowed in a constructor implementation." }, - A_rest_parameter_must_be_of_an_array_type: { code: 2370, category: ts.DiagnosticCategory.Error, key: "A rest parameter must be of an array type." }, - A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation: { code: 2371, category: ts.DiagnosticCategory.Error, key: "A parameter initializer is only allowed in a function or constructor implementation." }, - Parameter_0_cannot_be_referenced_in_its_initializer: { code: 2372, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' cannot be referenced in its initializer." }, - Initializer_of_parameter_0_cannot_reference_identifier_1_declared_after_it: { code: 2373, category: ts.DiagnosticCategory.Error, key: "Initializer of parameter '{0}' cannot reference identifier '{1}' declared after it." }, - Duplicate_string_index_signature: { code: 2374, category: ts.DiagnosticCategory.Error, key: "Duplicate string index signature." }, - Duplicate_number_index_signature: { code: 2375, category: ts.DiagnosticCategory.Error, key: "Duplicate number index signature." }, - A_super_call_must_be_the_first_statement_in_the_constructor_when_a_class_contains_initialized_properties_or_has_parameter_properties: { code: 2376, category: ts.DiagnosticCategory.Error, key: "A 'super' call must be the first statement in the constructor when a class contains initialized properties or has parameter properties." }, - Constructors_for_derived_classes_must_contain_a_super_call: { code: 2377, category: ts.DiagnosticCategory.Error, key: "Constructors for derived classes must contain a 'super' call." }, - A_get_accessor_must_return_a_value_or_consist_of_a_single_throw_statement: { code: 2378, category: ts.DiagnosticCategory.Error, key: "A 'get' accessor must return a value or consist of a single 'throw' statement." }, - Getter_and_setter_accessors_do_not_agree_in_visibility: { code: 2379, category: ts.DiagnosticCategory.Error, key: "Getter and setter accessors do not agree in visibility." }, - get_and_set_accessor_must_have_the_same_type: { code: 2380, category: ts.DiagnosticCategory.Error, key: "'get' and 'set' accessor must have the same type." }, - A_signature_with_an_implementation_cannot_use_a_string_literal_type: { code: 2381, category: ts.DiagnosticCategory.Error, key: "A signature with an implementation cannot use a string literal type." }, - Specialized_overload_signature_is_not_assignable_to_any_non_specialized_signature: { code: 2382, category: ts.DiagnosticCategory.Error, key: "Specialized overload signature is not assignable to any non-specialized signature." }, - Overload_signatures_must_all_be_exported_or_not_exported: { code: 2383, category: ts.DiagnosticCategory.Error, key: "Overload signatures must all be exported or not exported." }, - Overload_signatures_must_all_be_ambient_or_non_ambient: { code: 2384, category: ts.DiagnosticCategory.Error, key: "Overload signatures must all be ambient or non-ambient." }, - Overload_signatures_must_all_be_public_private_or_protected: { code: 2385, category: ts.DiagnosticCategory.Error, key: "Overload signatures must all be public, private or protected." }, - Overload_signatures_must_all_be_optional_or_required: { code: 2386, category: ts.DiagnosticCategory.Error, key: "Overload signatures must all be optional or required." }, - Function_overload_must_be_static: { code: 2387, category: ts.DiagnosticCategory.Error, key: "Function overload must be static." }, - Function_overload_must_not_be_static: { code: 2388, category: ts.DiagnosticCategory.Error, key: "Function overload must not be static." }, - Function_implementation_name_must_be_0: { code: 2389, category: ts.DiagnosticCategory.Error, key: "Function implementation name must be '{0}'." }, - Constructor_implementation_is_missing: { code: 2390, category: ts.DiagnosticCategory.Error, key: "Constructor implementation is missing." }, - Function_implementation_is_missing_or_not_immediately_following_the_declaration: { code: 2391, category: ts.DiagnosticCategory.Error, key: "Function implementation is missing or not immediately following the declaration." }, - Multiple_constructor_implementations_are_not_allowed: { code: 2392, category: ts.DiagnosticCategory.Error, key: "Multiple constructor implementations are not allowed." }, - Duplicate_function_implementation: { code: 2393, category: ts.DiagnosticCategory.Error, key: "Duplicate function implementation." }, - Overload_signature_is_not_compatible_with_function_implementation: { code: 2394, category: ts.DiagnosticCategory.Error, key: "Overload signature is not compatible with function implementation." }, - Individual_declarations_in_merged_declaration_0_must_be_all_exported_or_all_local: { code: 2395, category: ts.DiagnosticCategory.Error, key: "Individual declarations in merged declaration '{0}' must be all exported or all local." }, - Duplicate_identifier_arguments_Compiler_uses_arguments_to_initialize_rest_parameters: { code: 2396, category: ts.DiagnosticCategory.Error, key: "Duplicate identifier 'arguments'. Compiler uses 'arguments' to initialize rest parameters." }, - Duplicate_identifier_this_Compiler_uses_variable_declaration_this_to_capture_this_reference: { code: 2399, category: ts.DiagnosticCategory.Error, key: "Duplicate identifier '_this'. Compiler uses variable declaration '_this' to capture 'this' reference." }, - Expression_resolves_to_variable_declaration_this_that_compiler_uses_to_capture_this_reference: { code: 2400, category: ts.DiagnosticCategory.Error, key: "Expression resolves to variable declaration '_this' that compiler uses to capture 'this' reference." }, - Duplicate_identifier_super_Compiler_uses_super_to_capture_base_class_reference: { code: 2401, category: ts.DiagnosticCategory.Error, key: "Duplicate identifier '_super'. Compiler uses '_super' to capture base class reference." }, - Expression_resolves_to_super_that_compiler_uses_to_capture_base_class_reference: { code: 2402, category: ts.DiagnosticCategory.Error, key: "Expression resolves to '_super' that compiler uses to capture base class reference." }, - Subsequent_variable_declarations_must_have_the_same_type_Variable_0_must_be_of_type_1_but_here_has_type_2: { code: 2403, category: ts.DiagnosticCategory.Error, key: "Subsequent variable declarations must have the same type. Variable '{0}' must be of type '{1}', but here has type '{2}'." }, - The_left_hand_side_of_a_for_in_statement_cannot_use_a_type_annotation: { code: 2404, category: ts.DiagnosticCategory.Error, key: "The left-hand side of a 'for...in' statement cannot use a type annotation." }, - The_left_hand_side_of_a_for_in_statement_must_be_of_type_string_or_any: { code: 2405, category: ts.DiagnosticCategory.Error, key: "The left-hand side of a 'for...in' statement must be of type 'string' or 'any'." }, - Invalid_left_hand_side_in_for_in_statement: { code: 2406, category: ts.DiagnosticCategory.Error, key: "Invalid left-hand side in 'for...in' statement." }, - The_right_hand_side_of_a_for_in_statement_must_be_of_type_any_an_object_type_or_a_type_parameter: { code: 2407, category: ts.DiagnosticCategory.Error, key: "The right-hand side of a 'for...in' statement must be of type 'any', an object type or a type parameter." }, - Setters_cannot_return_a_value: { code: 2408, category: ts.DiagnosticCategory.Error, key: "Setters cannot return a value." }, - Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class: { code: 2409, category: ts.DiagnosticCategory.Error, key: "Return type of constructor signature must be assignable to the instance type of the class" }, - All_symbols_within_a_with_block_will_be_resolved_to_any: { code: 2410, category: ts.DiagnosticCategory.Error, key: "All symbols within a 'with' block will be resolved to 'any'." }, - Property_0_of_type_1_is_not_assignable_to_string_index_type_2: { code: 2411, category: ts.DiagnosticCategory.Error, key: "Property '{0}' of type '{1}' is not assignable to string index type '{2}'." }, - Property_0_of_type_1_is_not_assignable_to_numeric_index_type_2: { code: 2412, category: ts.DiagnosticCategory.Error, key: "Property '{0}' of type '{1}' is not assignable to numeric index type '{2}'." }, - Numeric_index_type_0_is_not_assignable_to_string_index_type_1: { code: 2413, category: ts.DiagnosticCategory.Error, key: "Numeric index type '{0}' is not assignable to string index type '{1}'." }, - Class_name_cannot_be_0: { code: 2414, category: ts.DiagnosticCategory.Error, key: "Class name cannot be '{0}'" }, - Class_0_incorrectly_extends_base_class_1: { code: 2415, category: ts.DiagnosticCategory.Error, key: "Class '{0}' incorrectly extends base class '{1}'." }, - Class_static_side_0_incorrectly_extends_base_class_static_side_1: { code: 2417, category: ts.DiagnosticCategory.Error, key: "Class static side '{0}' incorrectly extends base class static side '{1}'." }, - Type_name_0_in_extends_clause_does_not_reference_constructor_function_for_0: { code: 2419, category: ts.DiagnosticCategory.Error, key: "Type name '{0}' in extends clause does not reference constructor function for '{0}'." }, - Class_0_incorrectly_implements_interface_1: { code: 2420, category: ts.DiagnosticCategory.Error, key: "Class '{0}' incorrectly implements interface '{1}'." }, - A_class_may_only_implement_another_class_or_interface: { code: 2422, category: ts.DiagnosticCategory.Error, key: "A class may only implement another class or interface." }, - Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_accessor: { code: 2423, category: ts.DiagnosticCategory.Error, key: "Class '{0}' defines instance member function '{1}', but extended class '{2}' defines it as instance member accessor." }, - Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_property: { code: 2424, category: ts.DiagnosticCategory.Error, key: "Class '{0}' defines instance member function '{1}', but extended class '{2}' defines it as instance member property." }, - Class_0_defines_instance_member_property_1_but_extended_class_2_defines_it_as_instance_member_function: { code: 2425, category: ts.DiagnosticCategory.Error, key: "Class '{0}' defines instance member property '{1}', but extended class '{2}' defines it as instance member function." }, - Class_0_defines_instance_member_accessor_1_but_extended_class_2_defines_it_as_instance_member_function: { code: 2426, category: ts.DiagnosticCategory.Error, key: "Class '{0}' defines instance member accessor '{1}', but extended class '{2}' defines it as instance member function." }, - Interface_name_cannot_be_0: { code: 2427, category: ts.DiagnosticCategory.Error, key: "Interface name cannot be '{0}'" }, - All_declarations_of_an_interface_must_have_identical_type_parameters: { code: 2428, category: ts.DiagnosticCategory.Error, key: "All declarations of an interface must have identical type parameters." }, - Interface_0_incorrectly_extends_interface_1: { code: 2430, category: ts.DiagnosticCategory.Error, key: "Interface '{0}' incorrectly extends interface '{1}'." }, - Enum_name_cannot_be_0: { code: 2431, category: ts.DiagnosticCategory.Error, key: "Enum name cannot be '{0}'" }, - In_an_enum_with_multiple_declarations_only_one_declaration_can_omit_an_initializer_for_its_first_enum_element: { code: 2432, category: ts.DiagnosticCategory.Error, key: "In an enum with multiple declarations, only one declaration can omit an initializer for its first enum element." }, - A_namespace_declaration_cannot_be_in_a_different_file_from_a_class_or_function_with_which_it_is_merged: { code: 2433, category: ts.DiagnosticCategory.Error, key: "A namespace declaration cannot be in a different file from a class or function with which it is merged" }, - A_namespace_declaration_cannot_be_located_prior_to_a_class_or_function_with_which_it_is_merged: { code: 2434, category: ts.DiagnosticCategory.Error, key: "A namespace declaration cannot be located prior to a class or function with which it is merged" }, - Ambient_modules_cannot_be_nested_in_other_modules_or_namespaces: { code: 2435, category: ts.DiagnosticCategory.Error, key: "Ambient modules cannot be nested in other modules or namespaces." }, - Ambient_module_declaration_cannot_specify_relative_module_name: { code: 2436, category: ts.DiagnosticCategory.Error, key: "Ambient module declaration cannot specify relative module name." }, - Module_0_is_hidden_by_a_local_declaration_with_the_same_name: { code: 2437, category: ts.DiagnosticCategory.Error, key: "Module '{0}' is hidden by a local declaration with the same name" }, - Import_name_cannot_be_0: { code: 2438, category: ts.DiagnosticCategory.Error, key: "Import name cannot be '{0}'" }, - Import_or_export_declaration_in_an_ambient_module_declaration_cannot_reference_module_through_relative_module_name: { code: 2439, category: ts.DiagnosticCategory.Error, key: "Import or export declaration in an ambient module declaration cannot reference module through relative module name." }, - Import_declaration_conflicts_with_local_declaration_of_0: { code: 2440, category: ts.DiagnosticCategory.Error, key: "Import declaration conflicts with local declaration of '{0}'" }, - Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module: { code: 2441, category: ts.DiagnosticCategory.Error, key: "Duplicate identifier '{0}'. Compiler reserves name '{1}' in top level scope of a module." }, - Types_have_separate_declarations_of_a_private_property_0: { code: 2442, category: ts.DiagnosticCategory.Error, key: "Types have separate declarations of a private property '{0}'." }, - Property_0_is_protected_but_type_1_is_not_a_class_derived_from_2: { code: 2443, category: ts.DiagnosticCategory.Error, key: "Property '{0}' is protected but type '{1}' is not a class derived from '{2}'." }, - Property_0_is_protected_in_type_1_but_public_in_type_2: { code: 2444, category: ts.DiagnosticCategory.Error, key: "Property '{0}' is protected in type '{1}' but public in type '{2}'." }, - Property_0_is_protected_and_only_accessible_within_class_1_and_its_subclasses: { code: 2445, category: ts.DiagnosticCategory.Error, key: "Property '{0}' is protected and only accessible within class '{1}' and its subclasses." }, - Property_0_is_protected_and_only_accessible_through_an_instance_of_class_1: { code: 2446, category: ts.DiagnosticCategory.Error, key: "Property '{0}' is protected and only accessible through an instance of class '{1}'." }, - The_0_operator_is_not_allowed_for_boolean_types_Consider_using_1_instead: { code: 2447, category: ts.DiagnosticCategory.Error, key: "The '{0}' operator is not allowed for boolean types. Consider using '{1}' instead." }, - Block_scoped_variable_0_used_before_its_declaration: { code: 2448, category: ts.DiagnosticCategory.Error, key: "Block-scoped variable '{0}' used before its declaration." }, - The_operand_of_an_increment_or_decrement_operator_cannot_be_a_constant: { code: 2449, category: ts.DiagnosticCategory.Error, key: "The operand of an increment or decrement operator cannot be a constant." }, - Left_hand_side_of_assignment_expression_cannot_be_a_constant: { code: 2450, category: ts.DiagnosticCategory.Error, key: "Left-hand side of assignment expression cannot be a constant." }, - Cannot_redeclare_block_scoped_variable_0: { code: 2451, category: ts.DiagnosticCategory.Error, key: "Cannot redeclare block-scoped variable '{0}'." }, - An_enum_member_cannot_have_a_numeric_name: { code: 2452, category: ts.DiagnosticCategory.Error, key: "An enum member cannot have a numeric name." }, - The_type_argument_for_type_parameter_0_cannot_be_inferred_from_the_usage_Consider_specifying_the_type_arguments_explicitly: { code: 2453, category: ts.DiagnosticCategory.Error, key: "The type argument for type parameter '{0}' cannot be inferred from the usage. Consider specifying the type arguments explicitly." }, - Type_argument_candidate_1_is_not_a_valid_type_argument_because_it_is_not_a_supertype_of_candidate_0: { code: 2455, category: ts.DiagnosticCategory.Error, key: "Type argument candidate '{1}' is not a valid type argument because it is not a supertype of candidate '{0}'." }, - Type_alias_0_circularly_references_itself: { code: 2456, category: ts.DiagnosticCategory.Error, key: "Type alias '{0}' circularly references itself." }, - Type_alias_name_cannot_be_0: { code: 2457, category: ts.DiagnosticCategory.Error, key: "Type alias name cannot be '{0}'" }, - An_AMD_module_cannot_have_multiple_name_assignments: { code: 2458, category: ts.DiagnosticCategory.Error, key: "An AMD module cannot have multiple name assignments." }, - Type_0_has_no_property_1_and_no_string_index_signature: { code: 2459, category: ts.DiagnosticCategory.Error, key: "Type '{0}' has no property '{1}' and no string index signature." }, - Type_0_has_no_property_1: { code: 2460, category: ts.DiagnosticCategory.Error, key: "Type '{0}' has no property '{1}'." }, - Type_0_is_not_an_array_type: { code: 2461, category: ts.DiagnosticCategory.Error, key: "Type '{0}' is not an array type." }, - A_rest_element_must_be_last_in_an_array_destructuring_pattern: { code: 2462, category: ts.DiagnosticCategory.Error, key: "A rest element must be last in an array destructuring pattern" }, - A_binding_pattern_parameter_cannot_be_optional_in_an_implementation_signature: { code: 2463, category: ts.DiagnosticCategory.Error, key: "A binding pattern parameter cannot be optional in an implementation signature." }, - A_computed_property_name_must_be_of_type_string_number_symbol_or_any: { code: 2464, category: ts.DiagnosticCategory.Error, key: "A computed property name must be of type 'string', 'number', 'symbol', or 'any'." }, - this_cannot_be_referenced_in_a_computed_property_name: { code: 2465, category: ts.DiagnosticCategory.Error, key: "'this' cannot be referenced in a computed property name." }, - super_cannot_be_referenced_in_a_computed_property_name: { code: 2466, category: ts.DiagnosticCategory.Error, key: "'super' cannot be referenced in a computed property name." }, - A_computed_property_name_cannot_reference_a_type_parameter_from_its_containing_type: { code: 2467, category: ts.DiagnosticCategory.Error, key: "A computed property name cannot reference a type parameter from its containing type." }, - Cannot_find_global_value_0: { code: 2468, category: ts.DiagnosticCategory.Error, key: "Cannot find global value '{0}'." }, - The_0_operator_cannot_be_applied_to_type_symbol: { code: 2469, category: ts.DiagnosticCategory.Error, key: "The '{0}' operator cannot be applied to type 'symbol'." }, - Symbol_reference_does_not_refer_to_the_global_Symbol_constructor_object: { code: 2470, category: ts.DiagnosticCategory.Error, key: "'Symbol' reference does not refer to the global Symbol constructor object." }, - A_computed_property_name_of_the_form_0_must_be_of_type_symbol: { code: 2471, category: ts.DiagnosticCategory.Error, key: "A computed property name of the form '{0}' must be of type 'symbol'." }, - Spread_operator_in_new_expressions_is_only_available_when_targeting_ECMAScript_5_and_higher: { code: 2472, category: ts.DiagnosticCategory.Error, key: "Spread operator in 'new' expressions is only available when targeting ECMAScript 5 and higher." }, - Enum_declarations_must_all_be_const_or_non_const: { code: 2473, category: ts.DiagnosticCategory.Error, key: "Enum declarations must all be const or non-const." }, - In_const_enum_declarations_member_initializer_must_be_constant_expression: { code: 2474, category: ts.DiagnosticCategory.Error, key: "In 'const' enum declarations member initializer must be constant expression." }, - const_enums_can_only_be_used_in_property_or_index_access_expressions_or_the_right_hand_side_of_an_import_declaration_or_export_assignment: { code: 2475, category: ts.DiagnosticCategory.Error, key: "'const' enums can only be used in property or index access expressions or the right hand side of an import declaration or export assignment." }, - A_const_enum_member_can_only_be_accessed_using_a_string_literal: { code: 2476, category: ts.DiagnosticCategory.Error, key: "A const enum member can only be accessed using a string literal." }, - const_enum_member_initializer_was_evaluated_to_a_non_finite_value: { code: 2477, category: ts.DiagnosticCategory.Error, key: "'const' enum member initializer was evaluated to a non-finite value." }, - const_enum_member_initializer_was_evaluated_to_disallowed_value_NaN: { code: 2478, category: ts.DiagnosticCategory.Error, key: "'const' enum member initializer was evaluated to disallowed value 'NaN'." }, - Property_0_does_not_exist_on_const_enum_1: { code: 2479, category: ts.DiagnosticCategory.Error, key: "Property '{0}' does not exist on 'const' enum '{1}'." }, - let_is_not_allowed_to_be_used_as_a_name_in_let_or_const_declarations: { code: 2480, category: ts.DiagnosticCategory.Error, key: "'let' is not allowed to be used as a name in 'let' or 'const' declarations." }, - Cannot_initialize_outer_scoped_variable_0_in_the_same_scope_as_block_scoped_declaration_1: { code: 2481, category: ts.DiagnosticCategory.Error, key: "Cannot initialize outer scoped variable '{0}' in the same scope as block scoped declaration '{1}'." }, - The_left_hand_side_of_a_for_of_statement_cannot_use_a_type_annotation: { code: 2483, category: ts.DiagnosticCategory.Error, key: "The left-hand side of a 'for...of' statement cannot use a type annotation." }, - Export_declaration_conflicts_with_exported_declaration_of_0: { code: 2484, category: ts.DiagnosticCategory.Error, key: "Export declaration conflicts with exported declaration of '{0}'" }, - The_left_hand_side_of_a_for_of_statement_cannot_be_a_previously_defined_constant: { code: 2485, category: ts.DiagnosticCategory.Error, key: "The left-hand side of a 'for...of' statement cannot be a previously defined constant." }, - The_left_hand_side_of_a_for_in_statement_cannot_be_a_previously_defined_constant: { code: 2486, category: ts.DiagnosticCategory.Error, key: "The left-hand side of a 'for...in' statement cannot be a previously defined constant." }, - Invalid_left_hand_side_in_for_of_statement: { code: 2487, category: ts.DiagnosticCategory.Error, key: "Invalid left-hand side in 'for...of' statement." }, - Type_must_have_a_Symbol_iterator_method_that_returns_an_iterator: { code: 2488, category: ts.DiagnosticCategory.Error, key: "Type must have a '[Symbol.iterator]()' method that returns an iterator." }, - An_iterator_must_have_a_next_method: { code: 2489, category: ts.DiagnosticCategory.Error, key: "An iterator must have a 'next()' method." }, - The_type_returned_by_the_next_method_of_an_iterator_must_have_a_value_property: { code: 2490, category: ts.DiagnosticCategory.Error, key: "The type returned by the 'next()' method of an iterator must have a 'value' property." }, - The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern: { code: 2491, category: ts.DiagnosticCategory.Error, key: "The left-hand side of a 'for...in' statement cannot be a destructuring pattern." }, - Cannot_redeclare_identifier_0_in_catch_clause: { code: 2492, category: ts.DiagnosticCategory.Error, key: "Cannot redeclare identifier '{0}' in catch clause" }, - Tuple_type_0_with_length_1_cannot_be_assigned_to_tuple_with_length_2: { code: 2493, category: ts.DiagnosticCategory.Error, key: "Tuple type '{0}' with length '{1}' cannot be assigned to tuple with length '{2}'." }, - Using_a_string_in_a_for_of_statement_is_only_supported_in_ECMAScript_5_and_higher: { code: 2494, category: ts.DiagnosticCategory.Error, key: "Using a string in a 'for...of' statement is only supported in ECMAScript 5 and higher." }, - Type_0_is_not_an_array_type_or_a_string_type: { code: 2495, category: ts.DiagnosticCategory.Error, key: "Type '{0}' is not an array type or a string type." }, - The_arguments_object_cannot_be_referenced_in_an_arrow_function_in_ES3_and_ES5_Consider_using_a_standard_function_expression: { code: 2496, category: ts.DiagnosticCategory.Error, key: "The 'arguments' object cannot be referenced in an arrow function in ES3 and ES5. Consider using a standard function expression." }, - Module_0_resolves_to_a_non_module_entity_and_cannot_be_imported_using_this_construct: { code: 2497, category: ts.DiagnosticCategory.Error, key: "Module '{0}' resolves to a non-module entity and cannot be imported using this construct." }, - Module_0_uses_export_and_cannot_be_used_with_export_Asterisk: { code: 2498, category: ts.DiagnosticCategory.Error, key: "Module '{0}' uses 'export =' and cannot be used with 'export *'." }, - An_interface_can_only_extend_an_identifier_Slashqualified_name_with_optional_type_arguments: { code: 2499, category: ts.DiagnosticCategory.Error, key: "An interface can only extend an identifier/qualified-name with optional type arguments." }, - A_class_can_only_implement_an_identifier_Slashqualified_name_with_optional_type_arguments: { code: 2500, category: ts.DiagnosticCategory.Error, key: "A class can only implement an identifier/qualified-name with optional type arguments." }, - A_rest_element_cannot_contain_a_binding_pattern: { code: 2501, category: ts.DiagnosticCategory.Error, key: "A rest element cannot contain a binding pattern." }, - _0_is_referenced_directly_or_indirectly_in_its_own_type_annotation: { code: 2502, category: ts.DiagnosticCategory.Error, key: "'{0}' is referenced directly or indirectly in its own type annotation." }, - Cannot_find_namespace_0: { code: 2503, category: ts.DiagnosticCategory.Error, key: "Cannot find namespace '{0}'." }, - No_best_common_type_exists_among_yield_expressions: { code: 2504, category: ts.DiagnosticCategory.Error, key: "No best common type exists among yield expressions." }, - A_generator_cannot_have_a_void_type_annotation: { code: 2505, category: ts.DiagnosticCategory.Error, key: "A generator cannot have a 'void' type annotation." }, - _0_is_referenced_directly_or_indirectly_in_its_own_base_expression: { code: 2506, category: ts.DiagnosticCategory.Error, key: "'{0}' is referenced directly or indirectly in its own base expression." }, - Type_0_is_not_a_constructor_function_type: { code: 2507, category: ts.DiagnosticCategory.Error, key: "Type '{0}' is not a constructor function type." }, - No_base_constructor_has_the_specified_number_of_type_arguments: { code: 2508, category: ts.DiagnosticCategory.Error, key: "No base constructor has the specified number of type arguments." }, - Base_constructor_return_type_0_is_not_a_class_or_interface_type: { code: 2509, category: ts.DiagnosticCategory.Error, key: "Base constructor return type '{0}' is not a class or interface type." }, - Base_constructors_must_all_have_the_same_return_type: { code: 2510, category: ts.DiagnosticCategory.Error, key: "Base constructors must all have the same return type." }, - Cannot_create_an_instance_of_the_abstract_class_0: { code: 2511, category: ts.DiagnosticCategory.Error, key: "Cannot create an instance of the abstract class '{0}'." }, - Overload_signatures_must_all_be_abstract_or_not_abstract: { code: 2512, category: ts.DiagnosticCategory.Error, key: "Overload signatures must all be abstract or not abstract." }, - Abstract_method_0_in_class_1_cannot_be_accessed_via_super_expression: { code: 2513, category: ts.DiagnosticCategory.Error, key: "Abstract method '{0}' in class '{1}' cannot be accessed via super expression." }, - Classes_containing_abstract_methods_must_be_marked_abstract: { code: 2514, category: ts.DiagnosticCategory.Error, key: "Classes containing abstract methods must be marked abstract." }, - Non_abstract_class_0_does_not_implement_inherited_abstract_member_1_from_class_2: { code: 2515, category: ts.DiagnosticCategory.Error, key: "Non-abstract class '{0}' does not implement inherited abstract member '{1}' from class '{2}'." }, - All_declarations_of_an_abstract_method_must_be_consecutive: { code: 2516, category: ts.DiagnosticCategory.Error, key: "All declarations of an abstract method must be consecutive." }, - Cannot_assign_an_abstract_constructor_type_to_a_non_abstract_constructor_type: { code: 2517, category: ts.DiagnosticCategory.Error, key: "Cannot assign an abstract constructor type to a non-abstract constructor type." }, - Duplicate_identifier_0_Compiler_uses_declaration_1_to_support_async_functions: { code: 2520, category: ts.DiagnosticCategory.Error, key: "Duplicate identifier '{0}'. Compiler uses declaration '{1}' to support async functions." }, - Expression_resolves_to_variable_declaration_0_that_compiler_uses_to_support_async_functions: { code: 2521, category: ts.DiagnosticCategory.Error, key: "Expression resolves to variable declaration '{0}' that compiler uses to support async functions." }, - The_arguments_object_cannot_be_referenced_in_an_async_arrow_function_Consider_using_a_standard_async_function_expression: { code: 2522, category: ts.DiagnosticCategory.Error, key: "The 'arguments' object cannot be referenced in an async arrow function. Consider using a standard async function expression." }, - yield_expressions_cannot_be_used_in_a_parameter_initializer: { code: 2523, category: ts.DiagnosticCategory.Error, key: "'yield' expressions cannot be used in a parameter initializer." }, - await_expressions_cannot_be_used_in_a_parameter_initializer: { code: 2524, category: ts.DiagnosticCategory.Error, key: "'await' expressions cannot be used in a parameter initializer." }, - Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value: { code: 2525, category: ts.DiagnosticCategory.Error, key: "Initializer provides no value for this binding element and the binding element has no default value." }, - A_this_type_is_available_only_in_a_non_static_member_of_a_class_or_interface: { code: 2526, category: ts.DiagnosticCategory.Error, key: "A 'this' type is available only in a non-static member of a class or interface." }, - The_inferred_type_of_0_references_an_inaccessible_this_type_A_type_annotation_is_necessary: { code: 2527, category: ts.DiagnosticCategory.Error, key: "The inferred type of '{0}' references an inaccessible 'this' type. A type annotation is necessary." }, - A_module_cannot_have_multiple_default_exports: { code: 2528, category: ts.DiagnosticCategory.Error, key: "A module cannot have multiple default exports." }, - JSX_element_attributes_type_0_must_be_an_object_type: { code: 2600, category: ts.DiagnosticCategory.Error, key: "JSX element attributes type '{0}' must be an object type." }, - The_return_type_of_a_JSX_element_constructor_must_return_an_object_type: { code: 2601, category: ts.DiagnosticCategory.Error, key: "The return type of a JSX element constructor must return an object type." }, - JSX_element_implicitly_has_type_any_because_the_global_type_JSX_Element_does_not_exist: { code: 2602, category: ts.DiagnosticCategory.Error, key: "JSX element implicitly has type 'any' because the global type 'JSX.Element' does not exist." }, - Property_0_in_type_1_is_not_assignable_to_type_2: { code: 2603, category: ts.DiagnosticCategory.Error, key: "Property '{0}' in type '{1}' is not assignable to type '{2}'" }, - JSX_element_type_0_does_not_have_any_construct_or_call_signatures: { code: 2604, category: ts.DiagnosticCategory.Error, key: "JSX element type '{0}' does not have any construct or call signatures." }, - JSX_element_type_0_is_not_a_constructor_function_for_JSX_elements: { code: 2605, category: ts.DiagnosticCategory.Error, key: "JSX element type '{0}' is not a constructor function for JSX elements." }, - Property_0_of_JSX_spread_attribute_is_not_assignable_to_target_property: { code: 2606, category: ts.DiagnosticCategory.Error, key: "Property '{0}' of JSX spread attribute is not assignable to target property." }, - JSX_element_class_does_not_support_attributes_because_it_does_not_have_a_0_property: { code: 2607, category: ts.DiagnosticCategory.Error, key: "JSX element class does not support attributes because it does not have a '{0}' property" }, - The_global_type_JSX_0_may_not_have_more_than_one_property: { code: 2608, category: ts.DiagnosticCategory.Error, key: "The global type 'JSX.{0}' may not have more than one property" }, - Cannot_emit_namespaced_JSX_elements_in_React: { code: 2650, category: ts.DiagnosticCategory.Error, key: "Cannot emit namespaced JSX elements in React" }, - A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_enums: { code: 2651, category: ts.DiagnosticCategory.Error, key: "A member initializer in a enum declaration cannot reference members declared after it, including members defined in other enums." }, - Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_default_0_declaration_instead: { code: 2652, category: ts.DiagnosticCategory.Error, key: "Merged declaration '{0}' cannot include a default export declaration. Consider adding a separate 'export default {0}' declaration instead." }, - Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1: { code: 2653, category: ts.DiagnosticCategory.Error, key: "Non-abstract class expression does not implement inherited abstract member '{0}' from class '{1}'." }, - Exported_external_package_typings_file_cannot_contain_tripleslash_references_Please_contact_the_package_author_to_update_the_package_definition: { code: 2654, category: ts.DiagnosticCategory.Error, key: "Exported external package typings file cannot contain tripleslash references. Please contact the package author to update the package definition." }, - Exported_external_package_typings_can_only_be_in_d_ts_files_Please_contact_the_package_author_to_update_the_package_definition: { code: 2655, category: ts.DiagnosticCategory.Error, key: "Exported external package typings can only be in '.d.ts' files. Please contact the package author to update the package definition." }, - Exported_external_package_typings_file_0_is_not_a_module_Please_contact_the_package_author_to_update_the_package_definition: { code: 2656, category: ts.DiagnosticCategory.Error, key: "Exported external package typings file '{0}' is not a module. Please contact the package author to update the package definition." }, - JSX_expressions_must_have_one_parent_element: { code: 2657, category: ts.DiagnosticCategory.Error, key: "JSX expressions must have one parent element" }, - Import_declaration_0_is_using_private_name_1: { code: 4000, category: ts.DiagnosticCategory.Error, key: "Import declaration '{0}' is using private name '{1}'." }, - Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: { code: 4002, category: ts.DiagnosticCategory.Error, key: "Type parameter '{0}' of exported class has or is using private name '{1}'." }, - Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1: { code: 4004, category: ts.DiagnosticCategory.Error, key: "Type parameter '{0}' of exported interface has or is using private name '{1}'." }, - Type_parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1: { code: 4006, category: ts.DiagnosticCategory.Error, key: "Type parameter '{0}' of constructor signature from exported interface has or is using private name '{1}'." }, - Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1: { code: 4008, category: ts.DiagnosticCategory.Error, key: "Type parameter '{0}' of call signature from exported interface has or is using private name '{1}'." }, - Type_parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1: { code: 4010, category: ts.DiagnosticCategory.Error, key: "Type parameter '{0}' of public static method from exported class has or is using private name '{1}'." }, - Type_parameter_0_of_public_method_from_exported_class_has_or_is_using_private_name_1: { code: 4012, category: ts.DiagnosticCategory.Error, key: "Type parameter '{0}' of public method from exported class has or is using private name '{1}'." }, - Type_parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1: { code: 4014, category: ts.DiagnosticCategory.Error, key: "Type parameter '{0}' of method from exported interface has or is using private name '{1}'." }, - Type_parameter_0_of_exported_function_has_or_is_using_private_name_1: { code: 4016, category: ts.DiagnosticCategory.Error, key: "Type parameter '{0}' of exported function has or is using private name '{1}'." }, - Implements_clause_of_exported_class_0_has_or_is_using_private_name_1: { code: 4019, category: ts.DiagnosticCategory.Error, key: "Implements clause of exported class '{0}' has or is using private name '{1}'." }, - Extends_clause_of_exported_class_0_has_or_is_using_private_name_1: { code: 4020, category: ts.DiagnosticCategory.Error, key: "Extends clause of exported class '{0}' has or is using private name '{1}'." }, - Extends_clause_of_exported_interface_0_has_or_is_using_private_name_1: { code: 4022, category: ts.DiagnosticCategory.Error, key: "Extends clause of exported interface '{0}' has or is using private name '{1}'." }, - Exported_variable_0_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: { code: 4023, category: ts.DiagnosticCategory.Error, key: "Exported variable '{0}' has or is using name '{1}' from external module {2} but cannot be named." }, - Exported_variable_0_has_or_is_using_name_1_from_private_module_2: { code: 4024, category: ts.DiagnosticCategory.Error, key: "Exported variable '{0}' has or is using name '{1}' from private module '{2}'." }, - Exported_variable_0_has_or_is_using_private_name_1: { code: 4025, category: ts.DiagnosticCategory.Error, key: "Exported variable '{0}' has or is using private name '{1}'." }, - Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: { code: 4026, category: ts.DiagnosticCategory.Error, key: "Public static property '{0}' of exported class has or is using name '{1}' from external module {2} but cannot be named." }, - Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2: { code: 4027, category: ts.DiagnosticCategory.Error, key: "Public static property '{0}' of exported class has or is using name '{1}' from private module '{2}'." }, - Public_static_property_0_of_exported_class_has_or_is_using_private_name_1: { code: 4028, category: ts.DiagnosticCategory.Error, key: "Public static property '{0}' of exported class has or is using private name '{1}'." }, - Public_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: { code: 4029, category: ts.DiagnosticCategory.Error, key: "Public property '{0}' of exported class has or is using name '{1}' from external module {2} but cannot be named." }, - Public_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2: { code: 4030, category: ts.DiagnosticCategory.Error, key: "Public property '{0}' of exported class has or is using name '{1}' from private module '{2}'." }, - Public_property_0_of_exported_class_has_or_is_using_private_name_1: { code: 4031, category: ts.DiagnosticCategory.Error, key: "Public property '{0}' of exported class has or is using private name '{1}'." }, - Property_0_of_exported_interface_has_or_is_using_name_1_from_private_module_2: { code: 4032, category: ts.DiagnosticCategory.Error, key: "Property '{0}' of exported interface has or is using name '{1}' from private module '{2}'." }, - Property_0_of_exported_interface_has_or_is_using_private_name_1: { code: 4033, category: ts.DiagnosticCategory.Error, key: "Property '{0}' of exported interface has or is using private name '{1}'." }, - Parameter_0_of_public_static_property_setter_from_exported_class_has_or_is_using_name_1_from_private_module_2: { code: 4034, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' of public static property setter from exported class has or is using name '{1}' from private module '{2}'." }, - Parameter_0_of_public_static_property_setter_from_exported_class_has_or_is_using_private_name_1: { code: 4035, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' of public static property setter from exported class has or is using private name '{1}'." }, - Parameter_0_of_public_property_setter_from_exported_class_has_or_is_using_name_1_from_private_module_2: { code: 4036, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' of public property setter from exported class has or is using name '{1}' from private module '{2}'." }, - Parameter_0_of_public_property_setter_from_exported_class_has_or_is_using_private_name_1: { code: 4037, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' of public property setter from exported class has or is using private name '{1}'." }, - Return_type_of_public_static_property_getter_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named: { code: 4038, category: ts.DiagnosticCategory.Error, key: "Return type of public static property getter from exported class has or is using name '{0}' from external module {1} but cannot be named." }, - Return_type_of_public_static_property_getter_from_exported_class_has_or_is_using_name_0_from_private_module_1: { code: 4039, category: ts.DiagnosticCategory.Error, key: "Return type of public static property getter from exported class has or is using name '{0}' from private module '{1}'." }, - Return_type_of_public_static_property_getter_from_exported_class_has_or_is_using_private_name_0: { code: 4040, category: ts.DiagnosticCategory.Error, key: "Return type of public static property getter from exported class has or is using private name '{0}'." }, - Return_type_of_public_property_getter_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named: { code: 4041, category: ts.DiagnosticCategory.Error, key: "Return type of public property getter from exported class has or is using name '{0}' from external module {1} but cannot be named." }, - Return_type_of_public_property_getter_from_exported_class_has_or_is_using_name_0_from_private_module_1: { code: 4042, category: ts.DiagnosticCategory.Error, key: "Return type of public property getter from exported class has or is using name '{0}' from private module '{1}'." }, - Return_type_of_public_property_getter_from_exported_class_has_or_is_using_private_name_0: { code: 4043, category: ts.DiagnosticCategory.Error, key: "Return type of public property getter from exported class has or is using private name '{0}'." }, - Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1: { code: 4044, category: ts.DiagnosticCategory.Error, key: "Return type of constructor signature from exported interface has or is using name '{0}' from private module '{1}'." }, - Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_0: { code: 4045, category: ts.DiagnosticCategory.Error, key: "Return type of constructor signature from exported interface has or is using private name '{0}'." }, - Return_type_of_call_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1: { code: 4046, category: ts.DiagnosticCategory.Error, key: "Return type of call signature from exported interface has or is using name '{0}' from private module '{1}'." }, - Return_type_of_call_signature_from_exported_interface_has_or_is_using_private_name_0: { code: 4047, category: ts.DiagnosticCategory.Error, key: "Return type of call signature from exported interface has or is using private name '{0}'." }, - Return_type_of_index_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1: { code: 4048, category: ts.DiagnosticCategory.Error, key: "Return type of index signature from exported interface has or is using name '{0}' from private module '{1}'." }, - Return_type_of_index_signature_from_exported_interface_has_or_is_using_private_name_0: { code: 4049, category: ts.DiagnosticCategory.Error, key: "Return type of index signature from exported interface has or is using private name '{0}'." }, - Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named: { code: 4050, category: ts.DiagnosticCategory.Error, key: "Return type of public static method from exported class has or is using name '{0}' from external module {1} but cannot be named." }, - Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_private_module_1: { code: 4051, category: ts.DiagnosticCategory.Error, key: "Return type of public static method from exported class has or is using name '{0}' from private module '{1}'." }, - Return_type_of_public_static_method_from_exported_class_has_or_is_using_private_name_0: { code: 4052, category: ts.DiagnosticCategory.Error, key: "Return type of public static method from exported class has or is using private name '{0}'." }, - Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named: { code: 4053, category: ts.DiagnosticCategory.Error, key: "Return type of public method from exported class has or is using name '{0}' from external module {1} but cannot be named." }, - Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_private_module_1: { code: 4054, category: ts.DiagnosticCategory.Error, key: "Return type of public method from exported class has or is using name '{0}' from private module '{1}'." }, - Return_type_of_public_method_from_exported_class_has_or_is_using_private_name_0: { code: 4055, category: ts.DiagnosticCategory.Error, key: "Return type of public method from exported class has or is using private name '{0}'." }, - Return_type_of_method_from_exported_interface_has_or_is_using_name_0_from_private_module_1: { code: 4056, category: ts.DiagnosticCategory.Error, key: "Return type of method from exported interface has or is using name '{0}' from private module '{1}'." }, - Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0: { code: 4057, category: ts.DiagnosticCategory.Error, key: "Return type of method from exported interface has or is using private name '{0}'." }, - Return_type_of_exported_function_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named: { code: 4058, category: ts.DiagnosticCategory.Error, key: "Return type of exported function has or is using name '{0}' from external module {1} but cannot be named." }, - Return_type_of_exported_function_has_or_is_using_name_0_from_private_module_1: { code: 4059, category: ts.DiagnosticCategory.Error, key: "Return type of exported function has or is using name '{0}' from private module '{1}'." }, - Return_type_of_exported_function_has_or_is_using_private_name_0: { code: 4060, category: ts.DiagnosticCategory.Error, key: "Return type of exported function has or is using private name '{0}'." }, - Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: { code: 4061, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' of constructor from exported class has or is using name '{1}' from external module {2} but cannot be named." }, - Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_private_module_2: { code: 4062, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' of constructor from exported class has or is using name '{1}' from private module '{2}'." }, - Parameter_0_of_constructor_from_exported_class_has_or_is_using_private_name_1: { code: 4063, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' of constructor from exported class has or is using private name '{1}'." }, - Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2: { code: 4064, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' of constructor signature from exported interface has or is using name '{1}' from private module '{2}'." }, - Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1: { code: 4065, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' of constructor signature from exported interface has or is using private name '{1}'." }, - Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2: { code: 4066, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' of call signature from exported interface has or is using name '{1}' from private module '{2}'." }, - Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1: { code: 4067, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' of call signature from exported interface has or is using private name '{1}'." }, - Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: { code: 4068, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' of public static method from exported class has or is using name '{1}' from external module {2} but cannot be named." }, - Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_private_module_2: { code: 4069, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' of public static method from exported class has or is using name '{1}' from private module '{2}'." }, - Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1: { code: 4070, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' of public static method from exported class has or is using private name '{1}'." }, - Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: { code: 4071, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' of public method from exported class has or is using name '{1}' from external module {2} but cannot be named." }, - Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_private_module_2: { code: 4072, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' of public method from exported class has or is using name '{1}' from private module '{2}'." }, - Parameter_0_of_public_method_from_exported_class_has_or_is_using_private_name_1: { code: 4073, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' of public method from exported class has or is using private name '{1}'." }, - Parameter_0_of_method_from_exported_interface_has_or_is_using_name_1_from_private_module_2: { code: 4074, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' of method from exported interface has or is using name '{1}' from private module '{2}'." }, - Parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1: { code: 4075, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' of method from exported interface has or is using private name '{1}'." }, - Parameter_0_of_exported_function_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: { code: 4076, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' of exported function has or is using name '{1}' from external module {2} but cannot be named." }, - Parameter_0_of_exported_function_has_or_is_using_name_1_from_private_module_2: { code: 4077, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' of exported function has or is using name '{1}' from private module '{2}'." }, - Parameter_0_of_exported_function_has_or_is_using_private_name_1: { code: 4078, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' of exported function has or is using private name '{1}'." }, - Exported_type_alias_0_has_or_is_using_private_name_1: { code: 4081, category: ts.DiagnosticCategory.Error, key: "Exported type alias '{0}' has or is using private name '{1}'." }, - Default_export_of_the_module_has_or_is_using_private_name_0: { code: 4082, category: ts.DiagnosticCategory.Error, key: "Default export of the module has or is using private name '{0}'." }, - Loop_contains_block_scoped_variable_0_referenced_by_a_function_in_the_loop_This_is_only_supported_in_ECMAScript_6_or_higher: { code: 4091, category: ts.DiagnosticCategory.Error, key: "Loop contains block-scoped variable '{0}' referenced by a function in the loop. This is only supported in ECMAScript 6 or higher." }, - The_current_host_does_not_support_the_0_option: { code: 5001, category: ts.DiagnosticCategory.Error, key: "The current host does not support the '{0}' option." }, - Cannot_find_the_common_subdirectory_path_for_the_input_files: { code: 5009, category: ts.DiagnosticCategory.Error, key: "Cannot find the common subdirectory path for the input files." }, - Cannot_read_file_0_Colon_1: { code: 5012, category: ts.DiagnosticCategory.Error, key: "Cannot read file '{0}': {1}" }, - Unsupported_file_encoding: { code: 5013, category: ts.DiagnosticCategory.Error, key: "Unsupported file encoding." }, - Failed_to_parse_file_0_Colon_1: { code: 5014, category: ts.DiagnosticCategory.Error, key: "Failed to parse file '{0}': {1}." }, - Unknown_compiler_option_0: { code: 5023, category: ts.DiagnosticCategory.Error, key: "Unknown compiler option '{0}'." }, - Compiler_option_0_requires_a_value_of_type_1: { code: 5024, category: ts.DiagnosticCategory.Error, key: "Compiler option '{0}' requires a value of type {1}." }, - Could_not_write_file_0_Colon_1: { code: 5033, category: ts.DiagnosticCategory.Error, key: "Could not write file '{0}': {1}" }, - Option_project_cannot_be_mixed_with_source_files_on_a_command_line: { code: 5042, category: ts.DiagnosticCategory.Error, key: "Option 'project' cannot be mixed with source files on a command line." }, - Option_isolatedModules_can_only_be_used_when_either_option_module_is_provided_or_option_target_is_ES2015_or_higher: { code: 5047, category: ts.DiagnosticCategory.Error, key: "Option 'isolatedModules' can only be used when either option '--module' is provided or option 'target' is 'ES2015' or higher." }, - Option_inlineSources_can_only_be_used_when_either_option_inlineSourceMap_or_option_sourceMap_is_provided: { code: 5051, category: ts.DiagnosticCategory.Error, key: "Option 'inlineSources' can only be used when either option '--inlineSourceMap' or option '--sourceMap' is provided." }, - Option_0_cannot_be_specified_without_specifying_option_1: { code: 5052, category: ts.DiagnosticCategory.Error, key: "Option '{0}' cannot be specified without specifying option '{1}'." }, - Option_0_cannot_be_specified_with_option_1: { code: 5053, category: ts.DiagnosticCategory.Error, key: "Option '{0}' cannot be specified with option '{1}'." }, - A_tsconfig_json_file_is_already_defined_at_Colon_0: { code: 5054, category: ts.DiagnosticCategory.Error, key: "A 'tsconfig.json' file is already defined at: '{0}'." }, - Concatenate_and_emit_output_to_single_file: { code: 6001, category: ts.DiagnosticCategory.Message, key: "Concatenate and emit output to single file." }, - Generates_corresponding_d_ts_file: { code: 6002, category: ts.DiagnosticCategory.Message, key: "Generates corresponding '.d.ts' file." }, - Specifies_the_location_where_debugger_should_locate_map_files_instead_of_generated_locations: { code: 6003, category: ts.DiagnosticCategory.Message, key: "Specifies the location where debugger should locate map files instead of generated locations." }, - Specifies_the_location_where_debugger_should_locate_TypeScript_files_instead_of_source_locations: { code: 6004, category: ts.DiagnosticCategory.Message, key: "Specifies the location where debugger should locate TypeScript files instead of source locations." }, - Watch_input_files: { code: 6005, category: ts.DiagnosticCategory.Message, key: "Watch input files." }, - Redirect_output_structure_to_the_directory: { code: 6006, category: ts.DiagnosticCategory.Message, key: "Redirect output structure to the directory." }, - Do_not_erase_const_enum_declarations_in_generated_code: { code: 6007, category: ts.DiagnosticCategory.Message, key: "Do not erase const enum declarations in generated code." }, - Do_not_emit_outputs_if_any_errors_were_reported: { code: 6008, category: ts.DiagnosticCategory.Message, key: "Do not emit outputs if any errors were reported." }, - Do_not_emit_comments_to_output: { code: 6009, category: ts.DiagnosticCategory.Message, key: "Do not emit comments to output." }, - Do_not_emit_outputs: { code: 6010, category: ts.DiagnosticCategory.Message, key: "Do not emit outputs." }, - Specify_ECMAScript_target_version_Colon_ES3_default_ES5_or_ES2015_experimental: { code: 6015, category: ts.DiagnosticCategory.Message, key: "Specify ECMAScript target version: 'ES3' (default), 'ES5', or 'ES2015' (experimental)" }, - Specify_module_code_generation_Colon_commonjs_amd_system_umd_or_es2015: { code: 6016, category: ts.DiagnosticCategory.Message, key: "Specify module code generation: 'commonjs', 'amd', 'system', 'umd' or 'es2015'" }, - Print_this_message: { code: 6017, category: ts.DiagnosticCategory.Message, key: "Print this message." }, - Print_the_compiler_s_version: { code: 6019, category: ts.DiagnosticCategory.Message, key: "Print the compiler's version." }, - Compile_the_project_in_the_given_directory: { code: 6020, category: ts.DiagnosticCategory.Message, key: "Compile the project in the given directory." }, - Syntax_Colon_0: { code: 6023, category: ts.DiagnosticCategory.Message, key: "Syntax: {0}" }, - options: { code: 6024, category: ts.DiagnosticCategory.Message, key: "options" }, - file: { code: 6025, category: ts.DiagnosticCategory.Message, key: "file" }, - Examples_Colon_0: { code: 6026, category: ts.DiagnosticCategory.Message, key: "Examples: {0}" }, - Options_Colon: { code: 6027, category: ts.DiagnosticCategory.Message, key: "Options:" }, - Version_0: { code: 6029, category: ts.DiagnosticCategory.Message, key: "Version {0}" }, - Insert_command_line_options_and_files_from_a_file: { code: 6030, category: ts.DiagnosticCategory.Message, key: "Insert command line options and files from a file." }, - File_change_detected_Starting_incremental_compilation: { code: 6032, category: ts.DiagnosticCategory.Message, key: "File change detected. Starting incremental compilation..." }, - KIND: { code: 6034, category: ts.DiagnosticCategory.Message, key: "KIND" }, - FILE: { code: 6035, category: ts.DiagnosticCategory.Message, key: "FILE" }, - VERSION: { code: 6036, category: ts.DiagnosticCategory.Message, key: "VERSION" }, - LOCATION: { code: 6037, category: ts.DiagnosticCategory.Message, key: "LOCATION" }, - DIRECTORY: { code: 6038, category: ts.DiagnosticCategory.Message, key: "DIRECTORY" }, - Compilation_complete_Watching_for_file_changes: { code: 6042, category: ts.DiagnosticCategory.Message, key: "Compilation complete. Watching for file changes." }, - Generates_corresponding_map_file: { code: 6043, category: ts.DiagnosticCategory.Message, key: "Generates corresponding '.map' file." }, - Compiler_option_0_expects_an_argument: { code: 6044, category: ts.DiagnosticCategory.Error, key: "Compiler option '{0}' expects an argument." }, - Unterminated_quoted_string_in_response_file_0: { code: 6045, category: ts.DiagnosticCategory.Error, key: "Unterminated quoted string in response file '{0}'." }, - Argument_for_module_option_must_be_commonjs_amd_system_umd_or_es2015: { code: 6046, category: ts.DiagnosticCategory.Error, key: "Argument for '--module' option must be 'commonjs', 'amd', 'system', 'umd', or 'es2015'." }, - Argument_for_target_option_must_be_ES3_ES5_or_ES2015: { code: 6047, category: ts.DiagnosticCategory.Error, key: "Argument for '--target' option must be 'ES3', 'ES5', or 'ES2015'." }, - Locale_must_be_of_the_form_language_or_language_territory_For_example_0_or_1: { code: 6048, category: ts.DiagnosticCategory.Error, key: "Locale must be of the form or -. For example '{0}' or '{1}'." }, - Unsupported_locale_0: { code: 6049, category: ts.DiagnosticCategory.Error, key: "Unsupported locale '{0}'." }, - Unable_to_open_file_0: { code: 6050, category: ts.DiagnosticCategory.Error, key: "Unable to open file '{0}'." }, - Corrupted_locale_file_0: { code: 6051, category: ts.DiagnosticCategory.Error, key: "Corrupted locale file {0}." }, - Raise_error_on_expressions_and_declarations_with_an_implied_any_type: { code: 6052, category: ts.DiagnosticCategory.Message, key: "Raise error on expressions and declarations with an implied 'any' type." }, - File_0_not_found: { code: 6053, category: ts.DiagnosticCategory.Error, key: "File '{0}' not found." }, - File_0_has_unsupported_extension_The_only_supported_extensions_are_1: { code: 6054, category: ts.DiagnosticCategory.Error, key: "File '{0}' has unsupported extension. The only supported extensions are {1}." }, - Suppress_noImplicitAny_errors_for_indexing_objects_lacking_index_signatures: { code: 6055, category: ts.DiagnosticCategory.Message, key: "Suppress noImplicitAny errors for indexing objects lacking index signatures." }, - Do_not_emit_declarations_for_code_that_has_an_internal_annotation: { code: 6056, category: ts.DiagnosticCategory.Message, key: "Do not emit declarations for code that has an '@internal' annotation." }, - Specifies_the_root_directory_of_input_files_Use_to_control_the_output_directory_structure_with_outDir: { code: 6058, category: ts.DiagnosticCategory.Message, key: "Specifies the root directory of input files. Use to control the output directory structure with --outDir." }, - File_0_is_not_under_rootDir_1_rootDir_is_expected_to_contain_all_source_files: { code: 6059, category: ts.DiagnosticCategory.Error, key: "File '{0}' is not under 'rootDir' '{1}'. 'rootDir' is expected to contain all source files." }, - Specifies_the_end_of_line_sequence_to_be_used_when_emitting_files_Colon_CRLF_dos_or_LF_unix: { code: 6060, category: ts.DiagnosticCategory.Message, key: "Specifies the end of line sequence to be used when emitting files: 'CRLF' (dos) or 'LF' (unix)." }, - NEWLINE: { code: 6061, category: ts.DiagnosticCategory.Message, key: "NEWLINE" }, - Argument_for_newLine_option_must_be_CRLF_or_LF: { code: 6062, category: ts.DiagnosticCategory.Error, key: "Argument for '--newLine' option must be 'CRLF' or 'LF'." }, - Argument_for_moduleResolution_option_must_be_node_or_classic: { code: 6063, category: ts.DiagnosticCategory.Error, key: "Argument for '--moduleResolution' option must be 'node' or 'classic'." }, - Specify_JSX_code_generation_Colon_preserve_or_react: { code: 6080, category: ts.DiagnosticCategory.Message, key: "Specify JSX code generation: 'preserve' or 'react'" }, - Argument_for_jsx_must_be_preserve_or_react: { code: 6081, category: ts.DiagnosticCategory.Message, key: "Argument for '--jsx' must be 'preserve' or 'react'." }, - Enables_experimental_support_for_ES7_decorators: { code: 6065, category: ts.DiagnosticCategory.Message, key: "Enables experimental support for ES7 decorators." }, - Enables_experimental_support_for_emitting_type_metadata_for_decorators: { code: 6066, category: ts.DiagnosticCategory.Message, key: "Enables experimental support for emitting type metadata for decorators." }, - Enables_experimental_support_for_ES7_async_functions: { code: 6068, category: ts.DiagnosticCategory.Message, key: "Enables experimental support for ES7 async functions." }, - Specifies_module_resolution_strategy_Colon_node_Node_js_or_classic_TypeScript_pre_1_6: { code: 6069, category: ts.DiagnosticCategory.Message, key: "Specifies module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6)." }, - Initializes_a_TypeScript_project_and_creates_a_tsconfig_json_file: { code: 6070, category: ts.DiagnosticCategory.Message, key: "Initializes a TypeScript project and creates a tsconfig.json file." }, - Successfully_created_a_tsconfig_json_file: { code: 6071, category: ts.DiagnosticCategory.Message, key: "Successfully created a tsconfig.json file." }, - Suppress_excess_property_checks_for_object_literals: { code: 6072, category: ts.DiagnosticCategory.Message, key: "Suppress excess property checks for object literals." }, - Variable_0_implicitly_has_an_1_type: { code: 7005, category: ts.DiagnosticCategory.Error, key: "Variable '{0}' implicitly has an '{1}' type." }, - Parameter_0_implicitly_has_an_1_type: { code: 7006, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' implicitly has an '{1}' type." }, - Member_0_implicitly_has_an_1_type: { code: 7008, category: ts.DiagnosticCategory.Error, key: "Member '{0}' implicitly has an '{1}' type." }, - new_expression_whose_target_lacks_a_construct_signature_implicitly_has_an_any_type: { code: 7009, category: ts.DiagnosticCategory.Error, key: "'new' expression, whose target lacks a construct signature, implicitly has an 'any' type." }, - _0_which_lacks_return_type_annotation_implicitly_has_an_1_return_type: { code: 7010, category: ts.DiagnosticCategory.Error, key: "'{0}', which lacks return-type annotation, implicitly has an '{1}' return type." }, - Function_expression_which_lacks_return_type_annotation_implicitly_has_an_0_return_type: { code: 7011, category: ts.DiagnosticCategory.Error, key: "Function expression, which lacks return-type annotation, implicitly has an '{0}' return type." }, - Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type: { code: 7013, category: ts.DiagnosticCategory.Error, key: "Construct signature, which lacks return-type annotation, implicitly has an 'any' return type." }, - Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_type_annotation: { code: 7016, category: ts.DiagnosticCategory.Error, key: "Property '{0}' implicitly has type 'any', because its 'set' accessor lacks a type annotation." }, - Index_signature_of_object_type_implicitly_has_an_any_type: { code: 7017, category: ts.DiagnosticCategory.Error, key: "Index signature of object type implicitly has an 'any' type." }, - Object_literal_s_property_0_implicitly_has_an_1_type: { code: 7018, category: ts.DiagnosticCategory.Error, key: "Object literal's property '{0}' implicitly has an '{1}' type." }, - Rest_parameter_0_implicitly_has_an_any_type: { code: 7019, category: ts.DiagnosticCategory.Error, key: "Rest parameter '{0}' implicitly has an 'any[]' type." }, - Call_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type: { code: 7020, category: ts.DiagnosticCategory.Error, key: "Call signature, which lacks return-type annotation, implicitly has an 'any' return type." }, - _0_implicitly_has_type_any_because_it_does_not_have_a_type_annotation_and_is_referenced_directly_or_indirectly_in_its_own_initializer: { code: 7022, category: ts.DiagnosticCategory.Error, key: "'{0}' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer." }, - _0_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions: { code: 7023, category: ts.DiagnosticCategory.Error, key: "'{0}' implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions." }, - Function_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions: { code: 7024, category: ts.DiagnosticCategory.Error, key: "Function implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions." }, - Generator_implicitly_has_type_0_because_it_does_not_yield_any_values_Consider_supplying_a_return_type: { code: 7025, category: ts.DiagnosticCategory.Error, key: "Generator implicitly has type '{0}' because it does not yield any values. Consider supplying a return type." }, - JSX_element_implicitly_has_type_any_because_no_interface_JSX_0_exists: { code: 7026, category: ts.DiagnosticCategory.Error, key: "JSX element implicitly has type 'any' because no interface 'JSX.{0}' exists" }, - You_cannot_rename_this_element: { code: 8000, category: ts.DiagnosticCategory.Error, key: "You cannot rename this element." }, - You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library: { code: 8001, category: ts.DiagnosticCategory.Error, key: "You cannot rename elements that are defined in the standard TypeScript library." }, - 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." }, - export_can_only_be_used_in_a_ts_file: { code: 8003, category: ts.DiagnosticCategory.Error, key: "'export=' can only be used in a .ts file." }, - type_parameter_declarations_can_only_be_used_in_a_ts_file: { code: 8004, category: ts.DiagnosticCategory.Error, key: "'type parameter declarations' can only be used in a .ts file." }, - implements_clauses_can_only_be_used_in_a_ts_file: { code: 8005, category: ts.DiagnosticCategory.Error, key: "'implements clauses' can only be used in a .ts file." }, - interface_declarations_can_only_be_used_in_a_ts_file: { code: 8006, category: ts.DiagnosticCategory.Error, key: "'interface declarations' can only be used in a .ts file." }, - module_declarations_can_only_be_used_in_a_ts_file: { code: 8007, category: ts.DiagnosticCategory.Error, key: "'module declarations' can only be used in a .ts file." }, - type_aliases_can_only_be_used_in_a_ts_file: { code: 8008, category: ts.DiagnosticCategory.Error, key: "'type aliases' can only be used in a .ts file." }, - _0_can_only_be_used_in_a_ts_file: { code: 8009, category: ts.DiagnosticCategory.Error, key: "'{0}' can only be used in a .ts file." }, - types_can_only_be_used_in_a_ts_file: { code: 8010, category: ts.DiagnosticCategory.Error, key: "'types' can only be used in a .ts file." }, - type_arguments_can_only_be_used_in_a_ts_file: { code: 8011, category: ts.DiagnosticCategory.Error, key: "'type arguments' can only be used in a .ts file." }, - parameter_modifiers_can_only_be_used_in_a_ts_file: { code: 8012, category: ts.DiagnosticCategory.Error, key: "'parameter modifiers' can only be used in a .ts file." }, - property_declarations_can_only_be_used_in_a_ts_file: { code: 8014, category: ts.DiagnosticCategory.Error, key: "'property declarations' can only be used in a .ts file." }, - enum_declarations_can_only_be_used_in_a_ts_file: { code: 8015, category: ts.DiagnosticCategory.Error, key: "'enum declarations' can only be used in a .ts file." }, - type_assertion_expressions_can_only_be_used_in_a_ts_file: { code: 8016, category: ts.DiagnosticCategory.Error, key: "'type assertion expressions' can only be used in a .ts file." }, - decorators_can_only_be_used_in_a_ts_file: { code: 8017, category: ts.DiagnosticCategory.Error, key: "'decorators' can only be used in a .ts file." }, - Only_identifiers_Slashqualified_names_with_optional_type_arguments_are_currently_supported_in_a_class_extends_clauses: { code: 9002, category: ts.DiagnosticCategory.Error, key: "Only identifiers/qualified-names with optional type arguments are currently supported in a class 'extends' clauses." }, - class_expressions_are_not_currently_supported: { code: 9003, category: ts.DiagnosticCategory.Error, key: "'class' expressions are not currently supported." }, - JSX_attributes_must_only_be_assigned_a_non_empty_expression: { code: 17000, category: ts.DiagnosticCategory.Error, key: "JSX attributes must only be assigned a non-empty 'expression'." }, - JSX_elements_cannot_have_multiple_attributes_with_the_same_name: { code: 17001, category: ts.DiagnosticCategory.Error, key: "JSX elements cannot have multiple attributes with the same name." }, - Expected_corresponding_JSX_closing_tag_for_0: { code: 17002, category: ts.DiagnosticCategory.Error, key: "Expected corresponding JSX closing tag for '{0}'." }, - JSX_attribute_expected: { code: 17003, category: ts.DiagnosticCategory.Error, key: "JSX attribute expected." }, - Cannot_use_JSX_unless_the_jsx_flag_is_provided: { code: 17004, category: ts.DiagnosticCategory.Error, key: "Cannot use JSX unless the '--jsx' flag is provided." }, - A_constructor_cannot_contain_a_super_call_when_its_class_extends_null: { code: 17005, category: ts.DiagnosticCategory.Error, key: "A constructor cannot contain a 'super' call when its class extends 'null'" }, - An_unary_expression_with_the_0_operator_is_not_allowed_in_the_left_hand_side_of_an_exponentiation_expression_Consider_enclosing_the_expression_in_parentheses: { code: 17006, category: ts.DiagnosticCategory.Error, key: "An unary expression with the '{0}' operator is not allowed in the left-hand side of an exponentiation expression. Consider enclosing the expression in parentheses." }, - A_type_assertion_expression_is_not_allowed_in_the_left_hand_side_of_an_exponentiation_expression_Consider_enclosing_the_expression_in_parentheses: { code: 17007, category: ts.DiagnosticCategory.Error, key: "A type assertion expression is not allowed in the left-hand side of an exponentiation expression. Consider enclosing the expression in parentheses." } - }; -})(ts || (ts = {})); -var ts; -(function (ts) { - function tokenIsIdentifierOrKeyword(token) { - return token >= 69; - } - ts.tokenIsIdentifierOrKeyword = tokenIsIdentifierOrKeyword; - var textToToken = { - "abstract": 115, - "any": 117, - "as": 116, - "boolean": 120, - "break": 70, - "case": 71, - "catch": 72, - "class": 73, - "continue": 75, - "const": 74, - "constructor": 121, - "debugger": 76, - "declare": 122, - "default": 77, - "delete": 78, - "do": 79, - "else": 80, - "enum": 81, - "export": 82, - "extends": 83, - "false": 84, - "finally": 85, - "for": 86, - "from": 133, - "function": 87, - "get": 123, - "if": 88, - "implements": 106, - "import": 89, - "in": 90, - "instanceof": 91, - "interface": 107, - "is": 124, - "let": 108, - "module": 125, - "namespace": 126, - "new": 92, - "null": 93, - "number": 128, - "package": 109, - "private": 110, - "protected": 111, - "public": 112, - "require": 127, - "return": 94, - "set": 129, - "static": 113, - "string": 130, - "super": 95, - "switch": 96, - "symbol": 131, - "this": 97, - "throw": 98, - "true": 99, - "try": 100, - "type": 132, - "typeof": 101, - "var": 102, - "void": 103, - "while": 104, - "with": 105, - "yield": 114, - "async": 118, - "await": 119, - "of": 134, - "{": 15, - "}": 16, - "(": 17, - ")": 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) { - if (source.hasOwnProperty(name_4)) { - 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++); - 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 ch === 32 || - ch === 9 || - ch === 11 || - ch === 12 || - ch === 160 || - ch === 133 || - ch === 5760 || - ch >= 8192 && ch <= 8203 || - ch === 8239 || - ch === 8287 || - ch === 12288 || - ch === 65279; - } - ts.isWhiteSpace = isWhiteSpace; - function isLineBreak(ch) { - return ch === 10 || - ch === 13 || - ch === 8232 || - ch === 8233; - } - 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) { - 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 (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) || isLineBreak(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 getCommentRanges(text, pos, trailing) { - var result; - var collecting = trailing || pos === 0; - while (true) { - var ch = text.charCodeAt(pos); - switch (ch) { - case 13: - if (text.charCodeAt(pos + 1) === 10) { - pos++; - } - case 10: - pos++; - if (trailing) { - return result; - } - collecting = true; - if (result && result.length) { - ts.lastOrUndefined(result).hasTrailingNewLine = 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 (!result) { - result = []; - } - result.push({ pos: startPos, end: pos, hasTrailingNewLine: hasTrailingNewLine, kind: kind }); - } - continue; - } - break; - default: - if (ch > 127 && (isWhiteSpace(ch) || isLineBreak(ch))) { - if (result && result.length && isLineBreak(ch)) { - ts.lastOrUndefined(result).hasTrailingNewLine = true; - } - pos++; - continue; - } - break; - } - return result; - } - } - function getLeadingCommentRanges(text, pos) { - return getCommentRanges(text, pos, false); - } - ts.getLeadingCommentRanges = getLeadingCommentRanges; - function getTrailingCommentRanges(text, pos) { - return getCommentRanges(text, pos, true); - } - 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 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, - reScanJsxToken: reScanJsxToken, - scanJsxToken: scanJsxToken, - scan: scan, - setText: setText, - setScriptTarget: setScriptTarget, - setLanguageVariant: setLanguageVariant, - setOnError: setOnError, - setTextPos: setTextPos, - tryScan: tryScan, - lookAhead: lookAhead - }; - 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() { - var quote = text.charCodeAt(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) { - 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++); - 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 && isWhiteSpace(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; - } - return pos++, 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; - } - return pos++, 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; - } - return pos++, token = 46; - case 40: - return pos++, token = 17; - case 41: - return pos++, token = 18; - case 42: - if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 59; - } - if (text.charCodeAt(pos + 1) === 42) { - if (text.charCodeAt(pos + 2) === 61) { - return pos += 3, token = 60; - } - return pos += 2, token = 38; - } - return pos++, token = 37; - case 43: - if (text.charCodeAt(pos + 1) === 43) { - return pos += 2, token = 41; - } - if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 57; - } - return pos++, token = 35; - case 44: - return pos++, token = 24; - case 45: - if (text.charCodeAt(pos + 1) === 45) { - return pos += 2, token = 42; - } - if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 58; - } - return pos++, 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; - } - return pos++, 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; - } - return pos++, 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: - return pos++, token = 54; - case 59: - return pos++, 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; - } - return pos++, 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; - } - return pos++, token = 56; - case 62: - if (isConflictMarkerTrivia(text, pos)) { - pos = scanConflictMarkerTrivia(text, pos, error); - if (skipTrivia) { - continue; - } - else { - return token = 7; - } - } - return pos++, token = 27; - case 63: - return pos++, token = 53; - case 91: - return pos++, token = 19; - case 93: - return pos++, token = 20; - case 94: - if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 68; - } - return pos++, token = 48; - case 123: - return pos++, 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; - } - return pos++, token = 47; - case 125: - return pos++, token = 16; - case 126: - return pos++, token = 50; - case 64: - return pos++, 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); - return pos++, 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 (isWhiteSpace(ch)) { - pos++; - continue; - } - else if (isLineBreak(ch)) { - precedingLineBreak = true; - pos++; - continue; - } - error(ts.Diagnostics.Invalid_character); - return pos++, 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; - } - return pos++, token = 44; - } - if (text.charCodeAt(pos) === 61) { - return pos++, 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 = 236; - } - 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 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 lookAhead(callback) { - return speculationHelper(callback, true); - } - function tryScan(callback) { - return speculationHelper(callback, false); - } - 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.optionDeclarations = [ - { - name: "charset", - type: "string" - }, - { - name: "declaration", - shortName: "d", - type: "boolean", - description: ts.Diagnostics.Generates_corresponding_d_ts_file - }, - { - name: "diagnostics", - type: "boolean" - }, - { - name: "emitBOM", - type: "boolean" - }, - { - name: "help", - shortName: "h", - type: "boolean", - description: ts.Diagnostics.Print_this_message - }, - { - 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: { - "preserve": 1, - "react": 2 - }, - paramType: ts.Diagnostics.KIND, - description: ts.Diagnostics.Specify_JSX_code_generation_Colon_preserve_or_react, - error: ts.Diagnostics.Argument_for_jsx_must_be_preserve_or_react - }, - { - name: "listFiles", - type: "boolean" - }, - { - name: "locale", - type: "string" - }, - { - name: "mapRoot", - type: "string", - isFilePath: true, - description: ts.Diagnostics.Specifies_the_location_where_debugger_should_locate_map_files_instead_of_generated_locations, - paramType: ts.Diagnostics.LOCATION - }, - { - name: "module", - shortName: "m", - type: { - "commonjs": 1, - "amd": 2, - "system": 4, - "umd": 3, - "es6": 5, - "es2015": 5 - }, - description: ts.Diagnostics.Specify_module_code_generation_Colon_commonjs_amd_system_umd_or_es2015, - paramType: ts.Diagnostics.KIND, - error: ts.Diagnostics.Argument_for_module_option_must_be_commonjs_amd_system_umd_or_es2015 - }, - { - name: "newLine", - type: { - "crlf": 0, - "lf": 1 - }, - description: ts.Diagnostics.Specifies_the_end_of_line_sequence_to_be_used_when_emitting_files_Colon_CRLF_dos_or_LF_unix, - paramType: ts.Diagnostics.NEWLINE, - error: ts.Diagnostics.Argument_for_newLine_option_must_be_CRLF_or_LF - }, - { - 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: "noImplicitAny", - type: "boolean", - description: ts.Diagnostics.Raise_error_on_expressions_and_declarations_with_an_implied_any_type - }, - { - name: "noLib", - type: "boolean" - }, - { - name: "noResolve", - type: "boolean" - }, - { - name: "skipDefaultLibCheck", - type: "boolean" - }, - { - 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: "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, - description: ts.Diagnostics.Specifies_the_root_directory_of_input_files_Use_to_control_the_output_directory_structure_with_outDir, - paramType: ts.Diagnostics.LOCATION - }, - { - name: "isolatedModules", - type: "boolean" - }, - { - name: "sourceMap", - type: "boolean", - description: ts.Diagnostics.Generates_corresponding_map_file - }, - { - name: "sourceRoot", - type: "string", - isFilePath: true, - description: ts.Diagnostics.Specifies_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: { - "es3": 0, - "es5": 1, - "es6": 2, - "es2015": 2 - }, - description: ts.Diagnostics.Specify_ECMAScript_target_version_Colon_ES3_default_ES5_or_ES2015_experimental, - paramType: ts.Diagnostics.VERSION, - error: ts.Diagnostics.Argument_for_target_option_must_be_ES3_ES5_or_ES2015 - }, - { - 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: { - "node": 2, - "classic": 1 - }, - description: ts.Diagnostics.Specifies_module_resolution_strategy_Colon_node_Node_js_or_classic_TypeScript_pre_1_6, - error: ts.Diagnostics.Argument_for_moduleResolution_option_must_be_node_or_classic - } - ]; - var optionNameMapCache; - function getOptionNameMap() { - if (optionNameMapCache) { - return optionNameMapCache; - } - var optionNameMap = {}; - var shortOptionNames = {}; - 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 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++]; - 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 (ts.hasProperty(shortOptionNames, s)) { - s = shortOptionNames[s]; - } - if (ts.hasProperty(optionNameMap, s)) { - var opt = optionNameMap[s]; - 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++]); - break; - case "boolean": - options[opt.name] = true; - break; - case "string": - options[opt.name] = args[i++] || ""; - break; - default: - var map_1 = opt.type; - var key = (args[i++] || "").toLowerCase(); - if (ts.hasProperty(map_1, key)) { - options[opt.name] = map_1[key]; - } - else { - errors.push(ts.createCompilerDiagnostic(opt.error)); - } - } - } - 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) { - try { - return { config: /\S/.test(jsonText) ? JSON.parse(jsonText) : {} }; - } - catch (e) { - return { error: ts.createCompilerDiagnostic(ts.Diagnostics.Failed_to_parse_file_0_Colon_1, fileName, e.message) }; - } - } - ts.parseConfigFileTextToJson = parseConfigFileTextToJson; - function parseJsonConfigFileContent(json, host, basePath) { - var _a = convertCompilerOptionsFromJson(json["compilerOptions"], basePath), options = _a.options, errors = _a.errors; - return { - options: options, - fileNames: getFileNames(), - errors: errors - }; - function getFileNames() { - var fileNames = []; - if (ts.hasProperty(json, "files")) { - if (json["files"] instanceof Array) { - fileNames = ts.map(json["files"], function (s) { return ts.combinePaths(basePath, s); }); - } - else { - errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Compiler_option_0_requires_a_value_of_type_1, "files", "Array")); - } - } - else { - var exclude = json["exclude"] instanceof Array ? ts.map(json["exclude"], ts.normalizeSlashes) : undefined; - var sysFiles = host.readDirectory(basePath, ".ts", exclude).concat(host.readDirectory(basePath, ".tsx", exclude)); - for (var i = 0; i < sysFiles.length; i++) { - var name_5 = sysFiles[i]; - if (ts.fileExtensionIs(name_5, ".d.ts")) { - var baseName = name_5.substr(0, name_5.length - ".d.ts".length); - if (!ts.contains(sysFiles, baseName + ".tsx") && !ts.contains(sysFiles, baseName + ".ts")) { - fileNames.push(name_5); - } - } - else if (ts.fileExtensionIs(name_5, ".ts")) { - if (!ts.contains(sysFiles, name_5 + "x")) { - fileNames.push(name_5); - } - } - else { - fileNames.push(name_5); - } - } - } - return fileNames; - } - } - ts.parseJsonConfigFileContent = parseJsonConfigFileContent; - function convertCompilerOptionsFromJson(jsonOptions, basePath) { - var options = {}; - var errors = []; - if (!jsonOptions) { - return { options: options, errors: errors }; - } - var optionNameMap = ts.arrayToMap(ts.optionDeclarations, function (opt) { return opt.name; }); - for (var id in jsonOptions) { - if (ts.hasProperty(optionNameMap, id)) { - var opt = optionNameMap[id]; - var optType = opt.type; - var value = jsonOptions[id]; - var expectedType = typeof optType === "string" ? optType : "string"; - if (typeof value === expectedType) { - if (typeof optType !== "string") { - var key = value.toLowerCase(); - if (ts.hasProperty(optType, key)) { - value = optType[key]; - } - else { - errors.push(ts.createCompilerDiagnostic(opt.error)); - value = 0; - } - } - if (opt.isFilePath) { - value = ts.normalizePath(ts.combinePaths(basePath, value)); - if (value === "") { - value = "."; - } - } - options[opt.name] = value; - } - else { - errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Compiler_option_0_requires_a_value_of_type_1, id, expectedType)); - } - } - else { - errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Unknown_compiler_option_0, id)); - } - } - return { options: options, errors: errors }; - } - ts.convertCompilerOptionsFromJson = convertCompilerOptionsFromJson; -})(ts || (ts = {})); -var ts; -(function (ts) { - function getDeclarationOfKind(symbol, kind) { - var declarations = symbol.declarations; - if (declarations) { - for (var _i = 0; _i < declarations.length; _i++) { - var declaration = declarations[_i]; - if (declaration.kind === kind) { - return declaration; - } - } - } - return undefined; - } - ts.getDeclarationOfKind = getDeclarationOfKind; - var stringWriters = []; - function getSingleLineStringWriter() { - if (stringWriters.length === 0) { - var str = ""; - var writeText = function (text) { return str += text; }; - return { - string: function () { return str; }, - writeKeyword: writeText, - writeOperator: writeText, - writePunctuation: writeText, - writeSpace: writeText, - writeStringLiteral: writeText, - writeParameter: writeText, - writeSymbol: writeText, - writeLine: function () { return str += " "; }, - increaseIndent: function () { }, - decreaseIndent: function () { }, - clear: function () { return str = ""; }, - trackSymbol: function () { }, - reportInaccessibleThisError: function () { } - }; - } - return stringWriters.pop(); - } - ts.getSingleLineStringWriter = getSingleLineStringWriter; - function releaseStringWriter(writer) { - writer.clear(); - stringWriters.push(writer); - } - ts.releaseStringWriter = releaseStringWriter; - function getFullWidth(node) { - return node.end - node.pos; - } - ts.getFullWidth = getFullWidth; - function arrayIsEqualTo(array1, array2, equaler) { - if (!array1 || !array2) { - return array1 === array2; - } - if (array1.length !== array2.length) { - return false; - } - for (var i = 0; i < array1.length; ++i) { - var equals = equaler ? equaler(array1[i], array2[i]) : array1[i] === array2[i]; - if (!equals) { - return false; - } - } - return true; - } - ts.arrayIsEqualTo = arrayIsEqualTo; - function hasResolvedModule(sourceFile, moduleNameText) { - return sourceFile.resolvedModules && ts.hasProperty(sourceFile.resolvedModules, moduleNameText); - } - ts.hasResolvedModule = hasResolvedModule; - function getResolvedModule(sourceFile, moduleNameText) { - return hasResolvedModule(sourceFile, moduleNameText) ? sourceFile.resolvedModules[moduleNameText] : undefined; - } - ts.getResolvedModule = getResolvedModule; - function setResolvedModule(sourceFile, moduleNameText, resolvedModule) { - if (!sourceFile.resolvedModules) { - sourceFile.resolvedModules = {}; - } - sourceFile.resolvedModules[moduleNameText] = resolvedModule; - } - ts.setResolvedModule = setResolvedModule; - function containsParseError(node) { - aggregateChildData(node); - return (node.parserContextFlags & 64) !== 0; - } - ts.containsParseError = containsParseError; - function aggregateChildData(node) { - if (!(node.parserContextFlags & 128)) { - var thisNodeOrAnySubNodesHasError = ((node.parserContextFlags & 16) !== 0) || - ts.forEachChild(node, containsParseError); - if (thisNodeOrAnySubNodesHasError) { - node.parserContextFlags |= 64; - } - node.parserContextFlags |= 128; - } - } - function getSourceFileOfNode(node) { - while (node && node.kind !== 248) { - node = node.parent; - } - return node; - } - ts.getSourceFileOfNode = getSourceFileOfNode; - function getStartPositionOfLine(line, sourceFile) { - ts.Debug.assert(line >= 0); - return ts.getLineStarts(sourceFile)[line]; - } - ts.getStartPositionOfLine = getStartPositionOfLine; - function nodePosToString(node) { - var file = getSourceFileOfNode(node); - var loc = ts.getLineAndCharacterOfPosition(file, node.pos); - return file.fileName + "(" + (loc.line + 1) + "," + (loc.character + 1) + ")"; - } - ts.nodePosToString = nodePosToString; - function getStartPosOfNode(node) { - return node.pos; - } - ts.getStartPosOfNode = getStartPosOfNode; - function nodeIsMissing(node) { - if (!node) { - return true; - } - return node.pos === node.end && node.pos >= 0 && node.kind !== 1; - } - ts.nodeIsMissing = nodeIsMissing; - function nodeIsPresent(node) { - return !nodeIsMissing(node); - } - ts.nodeIsPresent = nodeIsPresent; - function getTokenPosOfNode(node, sourceFile) { - if (nodeIsMissing(node)) { - return node.pos; - } - return ts.skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.pos); - } - ts.getTokenPosOfNode = getTokenPosOfNode; - function getNonDecoratorTokenPosOfNode(node, sourceFile) { - if (nodeIsMissing(node) || !node.decorators) { - return getTokenPosOfNode(node, sourceFile); - } - return ts.skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.decorators.end); - } - ts.getNonDecoratorTokenPosOfNode = getNonDecoratorTokenPosOfNode; - function getSourceTextOfNodeFromSourceFile(sourceFile, node, includeTrivia) { - if (includeTrivia === void 0) { includeTrivia = false; } - if (nodeIsMissing(node)) { - return ""; - } - var text = sourceFile.text; - return text.substring(includeTrivia ? node.pos : ts.skipTrivia(text, node.pos), node.end); - } - ts.getSourceTextOfNodeFromSourceFile = getSourceTextOfNodeFromSourceFile; - function getTextOfNodeFromSourceText(sourceText, node) { - if (nodeIsMissing(node)) { - return ""; - } - return sourceText.substring(ts.skipTrivia(sourceText, node.pos), node.end); - } - ts.getTextOfNodeFromSourceText = getTextOfNodeFromSourceText; - function getTextOfNode(node, includeTrivia) { - if (includeTrivia === void 0) { includeTrivia = false; } - return getSourceTextOfNodeFromSourceFile(getSourceFileOfNode(node), node, includeTrivia); - } - ts.getTextOfNode = getTextOfNode; - function escapeIdentifier(identifier) { - return identifier.length >= 2 && identifier.charCodeAt(0) === 95 && identifier.charCodeAt(1) === 95 ? "_" + identifier : identifier; - } - ts.escapeIdentifier = escapeIdentifier; - function unescapeIdentifier(identifier) { - return identifier.length >= 3 && identifier.charCodeAt(0) === 95 && identifier.charCodeAt(1) === 95 && identifier.charCodeAt(2) === 95 ? identifier.substr(1) : identifier; - } - ts.unescapeIdentifier = unescapeIdentifier; - function makeIdentifierFromModuleName(moduleName) { - return ts.getBaseFileName(moduleName).replace(/^(\d)/, "_$1").replace(/\W/g, "_"); - } - ts.makeIdentifierFromModuleName = makeIdentifierFromModuleName; - function isBlockOrCatchScoped(declaration) { - return (getCombinedNodeFlags(declaration) & 49152) !== 0 || - isCatchClauseVariableDeclaration(declaration); - } - ts.isBlockOrCatchScoped = isBlockOrCatchScoped; - function getEnclosingBlockScopeContainer(node) { - var current = node.parent; - while (current) { - if (isFunctionLike(current)) { - return current; - } - switch (current.kind) { - case 248: - case 220: - case 244: - case 218: - case 199: - case 200: - case 201: - return current; - case 192: - if (!isFunctionLike(current.parent)) { - return current; - } - } - current = current.parent; - } - } - ts.getEnclosingBlockScopeContainer = getEnclosingBlockScopeContainer; - function isCatchClauseVariableDeclaration(declaration) { - return declaration && - declaration.kind === 211 && - declaration.parent && - declaration.parent.kind === 244; - } - ts.isCatchClauseVariableDeclaration = isCatchClauseVariableDeclaration; - function declarationNameToString(name) { - return getFullWidth(name) === 0 ? "(Missing)" : getTextOfNode(name); - } - ts.declarationNameToString = declarationNameToString; - function createDiagnosticForNode(node, message, arg0, arg1, arg2) { - var sourceFile = getSourceFileOfNode(node); - var span = getErrorSpanForNode(sourceFile, node); - return ts.createFileDiagnostic(sourceFile, span.start, span.length, message, arg0, arg1, arg2); - } - ts.createDiagnosticForNode = createDiagnosticForNode; - function createDiagnosticForNodeFromMessageChain(node, messageChain) { - var sourceFile = getSourceFileOfNode(node); - var span = getErrorSpanForNode(sourceFile, node); - return { - file: sourceFile, - start: span.start, - length: span.length, - code: messageChain.code, - category: messageChain.category, - messageText: messageChain.next ? messageChain : messageChain.messageText - }; - } - ts.createDiagnosticForNodeFromMessageChain = createDiagnosticForNodeFromMessageChain; - function getSpanOfTokenAtPosition(sourceFile, pos) { - var scanner = ts.createScanner(sourceFile.languageVersion, true, sourceFile.languageVariant, sourceFile.text, undefined, pos); - scanner.scan(); - var start = scanner.getTokenPos(); - return ts.createTextSpanFromBounds(start, scanner.getTextPos()); - } - ts.getSpanOfTokenAtPosition = getSpanOfTokenAtPosition; - function getErrorSpanForNode(sourceFile, node) { - var errorNode = node; - switch (node.kind) { - case 248: - var pos_1 = ts.skipTrivia(sourceFile.text, 0, false); - if (pos_1 === sourceFile.text.length) { - return ts.createTextSpan(0, 0); - } - return getSpanOfTokenAtPosition(sourceFile, pos_1); - case 211: - case 163: - case 214: - case 186: - case 215: - case 218: - case 217: - case 247: - case 213: - case 173: - errorNode = node.name; - break; - } - if (errorNode === undefined) { - return getSpanOfTokenAtPosition(sourceFile, node.pos); - } - var pos = nodeIsMissing(errorNode) - ? errorNode.pos - : ts.skipTrivia(sourceFile.text, errorNode.pos); - return ts.createTextSpanFromBounds(pos, errorNode.end); - } - ts.getErrorSpanForNode = getErrorSpanForNode; - function isExternalModule(file) { - return file.externalModuleIndicator !== undefined; - } - ts.isExternalModule = isExternalModule; - function isDeclarationFile(file) { - return (file.flags & 8192) !== 0; - } - ts.isDeclarationFile = isDeclarationFile; - function isConstEnumDeclaration(node) { - return node.kind === 217 && isConst(node); - } - ts.isConstEnumDeclaration = isConstEnumDeclaration; - function walkUpBindingElementsAndPatterns(node) { - while (node && (node.kind === 163 || isBindingPattern(node))) { - node = node.parent; - } - return node; - } - function getCombinedNodeFlags(node) { - node = walkUpBindingElementsAndPatterns(node); - var flags = node.flags; - if (node.kind === 211) { - node = node.parent; - } - if (node && node.kind === 212) { - flags |= node.flags; - node = node.parent; - } - if (node && node.kind === 193) { - flags |= node.flags; - } - return flags; - } - ts.getCombinedNodeFlags = getCombinedNodeFlags; - function isConst(node) { - return !!(getCombinedNodeFlags(node) & 32768); - } - ts.isConst = isConst; - function isLet(node) { - return !!(getCombinedNodeFlags(node) & 16384); - } - ts.isLet = isLet; - function isPrologueDirective(node) { - return node.kind === 195 && node.expression.kind === 9; - } - ts.isPrologueDirective = isPrologueDirective; - function getLeadingCommentRangesOfNode(node, sourceFileOfNode) { - return ts.getLeadingCommentRanges(sourceFileOfNode.text, node.pos); - } - ts.getLeadingCommentRangesOfNode = getLeadingCommentRangesOfNode; - function getJsDocComments(node, sourceFileOfNode) { - var commentRanges = (node.kind === 138 || node.kind === 137) ? - ts.concatenate(ts.getTrailingCommentRanges(sourceFileOfNode.text, node.pos), ts.getLeadingCommentRanges(sourceFileOfNode.text, node.pos)) : - getLeadingCommentRangesOfNode(node, sourceFileOfNode); - return ts.filter(commentRanges, isJsDocComment); - function isJsDocComment(comment) { - return sourceFileOfNode.text.charCodeAt(comment.pos + 1) === 42 && - sourceFileOfNode.text.charCodeAt(comment.pos + 2) === 42 && - sourceFileOfNode.text.charCodeAt(comment.pos + 3) !== 47; - } - } - ts.getJsDocComments = getJsDocComments; - ts.fullTripleSlashReferencePathRegEx = /^(\/\/\/\s*/; - ts.fullTripleSlashAMDReferencePathRegEx = /^(\/\/\/\s*/; - function isTypeNode(node) { - if (151 <= node.kind && node.kind <= 160) { - return true; - } - switch (node.kind) { - case 117: - case 128: - case 130: - case 120: - case 131: - return true; - case 103: - return node.parent.kind !== 177; - case 9: - return node.parent.kind === 138; - case 188: - return !isExpressionWithTypeArgumentsInClassExtendsClause(node); - case 69: - if (node.parent.kind === 135 && node.parent.right === node) { - node = node.parent; - } - else if (node.parent.kind === 166 && node.parent.name === node) { - node = node.parent; - } - ts.Debug.assert(node.kind === 69 || node.kind === 135 || node.kind === 166, "'node' was expected to be a qualified name, identifier or property access in 'isTypeNode'."); - case 135: - case 166: - case 97: - var parent_1 = node.parent; - if (parent_1.kind === 154) { - return false; - } - if (151 <= parent_1.kind && parent_1.kind <= 160) { - return true; - } - switch (parent_1.kind) { - case 188: - return !isExpressionWithTypeArgumentsInClassExtendsClause(parent_1); - case 137: - return node === parent_1.constraint; - case 141: - case 140: - case 138: - case 211: - return node === parent_1.type; - case 213: - case 173: - case 174: - case 144: - case 143: - case 142: - case 145: - case 146: - return node === parent_1.type; - case 147: - case 148: - case 149: - return node === parent_1.type; - case 171: - return node === parent_1.type; - case 168: - case 169: - return parent_1.typeArguments && ts.indexOf(parent_1.typeArguments, node) >= 0; - case 170: - return false; - } - } - return false; - } - ts.isTypeNode = isTypeNode; - function forEachReturnStatement(body, visitor) { - return traverse(body); - function traverse(node) { - switch (node.kind) { - case 204: - return visitor(node); - case 220: - case 192: - case 196: - case 197: - case 198: - case 199: - case 200: - case 201: - case 205: - case 206: - case 241: - case 242: - case 207: - case 209: - case 244: - return ts.forEachChild(node, traverse); - } - } - } - ts.forEachReturnStatement = forEachReturnStatement; - function forEachYieldExpression(body, visitor) { - return traverse(body); - function traverse(node) { - switch (node.kind) { - case 184: - visitor(node); - var operand = node.expression; - if (operand) { - traverse(operand); - } - case 217: - case 215: - case 218: - case 216: - case 214: - case 186: - return; - default: - if (isFunctionLike(node)) { - var name_6 = node.name; - if (name_6 && name_6.kind === 136) { - traverse(name_6.expression); - return; - } - } - else if (!isTypeNode(node)) { - ts.forEachChild(node, traverse); - } - } - } - } - ts.forEachYieldExpression = forEachYieldExpression; - function isVariableLike(node) { - if (node) { - switch (node.kind) { - case 163: - case 247: - case 138: - case 245: - case 141: - case 140: - case 246: - case 211: - return true; - } - } - return false; - } - ts.isVariableLike = isVariableLike; - function isAccessor(node) { - return node && (node.kind === 145 || node.kind === 146); - } - ts.isAccessor = isAccessor; - function isClassLike(node) { - return node && (node.kind === 214 || node.kind === 186); - } - ts.isClassLike = isClassLike; - function isFunctionLike(node) { - if (node) { - switch (node.kind) { - case 144: - case 173: - case 213: - case 174: - case 143: - case 142: - case 145: - case 146: - case 147: - case 148: - case 149: - case 152: - case 153: - return true; - } - } - return false; - } - ts.isFunctionLike = isFunctionLike; - function introducesArgumentsExoticObject(node) { - switch (node.kind) { - case 143: - case 142: - case 144: - case 145: - case 146: - case 213: - case 173: - return true; - } - return false; - } - ts.introducesArgumentsExoticObject = introducesArgumentsExoticObject; - function isFunctionBlock(node) { - return node && node.kind === 192 && isFunctionLike(node.parent); - } - ts.isFunctionBlock = isFunctionBlock; - function isObjectLiteralMethod(node) { - return node && node.kind === 143 && node.parent.kind === 165; - } - ts.isObjectLiteralMethod = isObjectLiteralMethod; - function getContainingFunction(node) { - while (true) { - node = node.parent; - if (!node || isFunctionLike(node)) { - return node; - } - } - } - ts.getContainingFunction = getContainingFunction; - function getContainingClass(node) { - while (true) { - node = node.parent; - if (!node || isClassLike(node)) { - return node; - } - } - } - ts.getContainingClass = getContainingClass; - function getThisContainer(node, includeArrowFunctions) { - while (true) { - node = node.parent; - if (!node) { - return undefined; - } - switch (node.kind) { - case 136: - if (isClassLike(node.parent.parent)) { - return node; - } - node = node.parent; - break; - case 139: - if (node.parent.kind === 138 && isClassElement(node.parent.parent)) { - node = node.parent.parent; - } - else if (isClassElement(node.parent)) { - node = node.parent; - } - break; - case 174: - if (!includeArrowFunctions) { - continue; - } - case 213: - case 173: - case 218: - case 141: - case 140: - case 143: - case 142: - case 144: - case 145: - case 146: - case 147: - case 148: - case 149: - case 217: - case 248: - return node; - } - } - } - ts.getThisContainer = getThisContainer; - function getSuperContainer(node, includeFunctions) { - while (true) { - node = node.parent; - if (!node) - return node; - switch (node.kind) { - case 136: - if (isClassLike(node.parent.parent)) { - return node; - } - node = node.parent; - break; - case 139: - if (node.parent.kind === 138 && isClassElement(node.parent.parent)) { - node = node.parent.parent; - } - else if (isClassElement(node.parent)) { - node = node.parent; - } - break; - case 213: - case 173: - case 174: - if (!includeFunctions) { - continue; - } - case 141: - case 140: - case 143: - case 142: - case 144: - case 145: - case 146: - return node; - } - } - } - ts.getSuperContainer = getSuperContainer; - function getEntityNameFromTypeNode(node) { - if (node) { - switch (node.kind) { - case 151: - return node.typeName; - case 188: - return node.expression; - case 69: - case 135: - return node; - } - } - return undefined; - } - ts.getEntityNameFromTypeNode = getEntityNameFromTypeNode; - function getInvokedExpression(node) { - if (node.kind === 170) { - return node.tag; - } - return node.expression; - } - ts.getInvokedExpression = getInvokedExpression; - function nodeCanBeDecorated(node) { - switch (node.kind) { - case 214: - return true; - case 141: - return node.parent.kind === 214; - case 138: - return node.parent.body && node.parent.parent.kind === 214; - case 145: - case 146: - case 143: - return node.body && node.parent.kind === 214; - } - return false; - } - ts.nodeCanBeDecorated = nodeCanBeDecorated; - function nodeIsDecorated(node) { - switch (node.kind) { - case 214: - if (node.decorators) { - return true; - } - return false; - case 141: - case 138: - if (node.decorators) { - return true; - } - return false; - case 145: - if (node.body && node.decorators) { - return true; - } - return false; - case 143: - case 146: - if (node.body && node.decorators) { - return true; - } - return false; - } - return false; - } - ts.nodeIsDecorated = nodeIsDecorated; - function childIsDecorated(node) { - switch (node.kind) { - case 214: - return ts.forEach(node.members, nodeOrChildIsDecorated); - case 143: - case 146: - return ts.forEach(node.parameters, nodeIsDecorated); - } - return false; - } - ts.childIsDecorated = childIsDecorated; - function nodeOrChildIsDecorated(node) { - return nodeIsDecorated(node) || childIsDecorated(node); - } - ts.nodeOrChildIsDecorated = nodeOrChildIsDecorated; - function isPropertyAccessExpression(node) { - return node.kind === 166; - } - ts.isPropertyAccessExpression = isPropertyAccessExpression; - function isElementAccessExpression(node) { - return node.kind === 167; - } - ts.isElementAccessExpression = isElementAccessExpression; - function isExpression(node) { - switch (node.kind) { - case 95: - case 93: - case 99: - case 84: - case 10: - case 164: - case 165: - case 166: - case 167: - case 168: - case 169: - case 170: - case 189: - case 171: - case 172: - case 173: - case 186: - case 174: - case 177: - case 175: - case 176: - case 179: - case 180: - case 181: - case 182: - case 185: - case 183: - case 11: - case 187: - case 233: - case 234: - case 184: - case 178: - return true; - case 135: - while (node.parent.kind === 135) { - node = node.parent; - } - return node.parent.kind === 154; - case 69: - if (node.parent.kind === 154) { - return true; - } - case 8: - case 9: - case 97: - var parent_2 = node.parent; - switch (parent_2.kind) { - case 211: - case 138: - case 141: - case 140: - case 247: - case 245: - case 163: - return parent_2.initializer === node; - case 195: - case 196: - case 197: - case 198: - case 204: - case 205: - case 206: - case 241: - case 208: - case 206: - return parent_2.expression === node; - case 199: - var forStatement = parent_2; - return (forStatement.initializer === node && forStatement.initializer.kind !== 212) || - forStatement.condition === node || - forStatement.incrementor === node; - case 200: - case 201: - var forInStatement = parent_2; - return (forInStatement.initializer === node && forInStatement.initializer.kind !== 212) || - forInStatement.expression === node; - case 171: - case 189: - return node === parent_2.expression; - case 190: - return node === parent_2.expression; - case 136: - return node === parent_2.expression; - case 139: - case 240: - case 239: - return true; - case 188: - return parent_2.expression === node && isExpressionWithTypeArgumentsInClassExtendsClause(parent_2); - default: - if (isExpression(parent_2)) { - return true; - } - } - } - return false; - } - ts.isExpression = isExpression; - function isExternalModuleNameRelative(moduleName) { - return moduleName.substr(0, 2) === "./" || moduleName.substr(0, 3) === "../" || moduleName.substr(0, 2) === ".\\" || moduleName.substr(0, 3) === "..\\"; - } - ts.isExternalModuleNameRelative = isExternalModuleNameRelative; - function isInstantiatedModule(node, preserveConstEnums) { - var moduleState = ts.getModuleInstanceState(node); - return moduleState === 1 || - (preserveConstEnums && moduleState === 2); - } - ts.isInstantiatedModule = isInstantiatedModule; - function isExternalModuleImportEqualsDeclaration(node) { - return node.kind === 221 && node.moduleReference.kind === 232; - } - ts.isExternalModuleImportEqualsDeclaration = isExternalModuleImportEqualsDeclaration; - function getExternalModuleImportEqualsDeclarationExpression(node) { - ts.Debug.assert(isExternalModuleImportEqualsDeclaration(node)); - return node.moduleReference.expression; - } - ts.getExternalModuleImportEqualsDeclarationExpression = getExternalModuleImportEqualsDeclarationExpression; - function isInternalModuleImportEqualsDeclaration(node) { - return node.kind === 221 && node.moduleReference.kind !== 232; - } - ts.isInternalModuleImportEqualsDeclaration = isInternalModuleImportEqualsDeclaration; - function getExternalModuleName(node) { - if (node.kind === 222) { - return node.moduleSpecifier; - } - if (node.kind === 221) { - var reference = node.moduleReference; - if (reference.kind === 232) { - return reference.expression; - } - } - if (node.kind === 228) { - return node.moduleSpecifier; - } - } - ts.getExternalModuleName = getExternalModuleName; - function hasQuestionToken(node) { - if (node) { - switch (node.kind) { - case 138: - case 143: - case 142: - case 246: - case 245: - case 141: - case 140: - return node.questionToken !== undefined; - } - } - return false; - } - ts.hasQuestionToken = hasQuestionToken; - function isJSDocConstructSignature(node) { - return node.kind === 261 && - node.parameters.length > 0 && - node.parameters[0].type.kind === 263; - } - ts.isJSDocConstructSignature = isJSDocConstructSignature; - function getJSDocTag(node, kind) { - if (node && node.jsDocComment) { - for (var _i = 0, _a = node.jsDocComment.tags; _i < _a.length; _i++) { - var tag = _a[_i]; - if (tag.kind === kind) { - return tag; - } - } - } - } - function getJSDocTypeTag(node) { - return getJSDocTag(node, 269); - } - ts.getJSDocTypeTag = getJSDocTypeTag; - function getJSDocReturnTag(node) { - return getJSDocTag(node, 268); - } - ts.getJSDocReturnTag = getJSDocReturnTag; - function getJSDocTemplateTag(node) { - return getJSDocTag(node, 270); - } - ts.getJSDocTemplateTag = getJSDocTemplateTag; - function getCorrespondingJSDocParameterTag(parameter) { - if (parameter.name && parameter.name.kind === 69) { - var parameterName = parameter.name.text; - var docComment = parameter.parent.jsDocComment; - if (docComment) { - return ts.forEach(docComment.tags, function (t) { - if (t.kind === 267) { - var parameterTag = t; - var name_7 = parameterTag.preParameterName || parameterTag.postParameterName; - if (name_7.text === parameterName) { - return t; - } - } - }); - } - } - } - ts.getCorrespondingJSDocParameterTag = getCorrespondingJSDocParameterTag; - function hasRestParameter(s) { - return isRestParameter(ts.lastOrUndefined(s.parameters)); - } - ts.hasRestParameter = hasRestParameter; - function isRestParameter(node) { - if (node) { - if (node.parserContextFlags & 32) { - if (node.type && node.type.kind === 262) { - return true; - } - var paramTag = getCorrespondingJSDocParameterTag(node); - if (paramTag && paramTag.typeExpression) { - return paramTag.typeExpression.type.kind === 262; - } - } - return node.dotDotDotToken !== undefined; - } - return false; - } - ts.isRestParameter = isRestParameter; - function isLiteralKind(kind) { - return 8 <= kind && kind <= 11; - } - ts.isLiteralKind = isLiteralKind; - function isTextualLiteralKind(kind) { - return kind === 9 || kind === 11; - } - ts.isTextualLiteralKind = isTextualLiteralKind; - function isTemplateLiteralKind(kind) { - return 11 <= kind && kind <= 14; - } - ts.isTemplateLiteralKind = isTemplateLiteralKind; - function isBindingPattern(node) { - return !!node && (node.kind === 162 || node.kind === 161); - } - ts.isBindingPattern = isBindingPattern; - function isInAmbientContext(node) { - while (node) { - if (node.flags & (2 | 8192)) { - return true; - } - node = node.parent; - } - return false; - } - ts.isInAmbientContext = isInAmbientContext; - function isDeclaration(node) { - switch (node.kind) { - case 174: - case 163: - case 214: - case 186: - case 144: - case 217: - case 247: - case 230: - case 213: - case 173: - case 145: - case 223: - case 221: - case 226: - case 215: - case 143: - case 142: - case 218: - case 224: - case 138: - case 245: - case 141: - case 140: - case 146: - case 246: - case 216: - case 137: - case 211: - return true; - } - return false; - } - ts.isDeclaration = isDeclaration; - function isStatement(n) { - switch (n.kind) { - case 203: - case 202: - case 210: - case 197: - case 195: - case 194: - case 200: - case 201: - case 199: - case 196: - case 207: - case 204: - case 206: - case 98: - case 209: - case 193: - case 198: - case 205: - case 227: - return true; - default: - return false; - } - } - ts.isStatement = isStatement; - function isClassElement(n) { - switch (n.kind) { - case 144: - case 141: - case 143: - case 145: - case 146: - case 142: - case 149: - return true; - default: - return false; - } - } - ts.isClassElement = isClassElement; - function isDeclarationName(name) { - if (name.kind !== 69 && name.kind !== 9 && name.kind !== 8) { - return false; - } - var parent = name.parent; - if (parent.kind === 226 || parent.kind === 230) { - if (parent.propertyName) { - return true; - } - } - if (isDeclaration(parent)) { - return parent.name === name; - } - return false; - } - ts.isDeclarationName = isDeclarationName; - function isIdentifierName(node) { - var parent = node.parent; - switch (parent.kind) { - case 141: - case 140: - case 143: - case 142: - case 145: - case 146: - case 247: - case 245: - case 166: - return parent.name === node; - case 135: - if (parent.right === node) { - while (parent.kind === 135) { - parent = parent.parent; - } - return parent.kind === 154; - } - return false; - case 163: - case 226: - return parent.propertyName === node; - case 230: - return true; - } - return false; - } - ts.isIdentifierName = isIdentifierName; - function isAliasSymbolDeclaration(node) { - return node.kind === 221 || - node.kind === 223 && !!node.name || - node.kind === 224 || - node.kind === 226 || - node.kind === 230 || - node.kind === 227 && node.expression.kind === 69; - } - ts.isAliasSymbolDeclaration = isAliasSymbolDeclaration; - function getClassExtendsHeritageClauseElement(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 83); - return heritageClause && heritageClause.types.length > 0 ? heritageClause.types[0] : undefined; - } - ts.getClassExtendsHeritageClauseElement = getClassExtendsHeritageClauseElement; - function getClassImplementsHeritageClauseElements(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 106); - return heritageClause ? heritageClause.types : undefined; - } - ts.getClassImplementsHeritageClauseElements = getClassImplementsHeritageClauseElements; - function getInterfaceBaseTypeNodes(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 83); - return heritageClause ? heritageClause.types : undefined; - } - ts.getInterfaceBaseTypeNodes = getInterfaceBaseTypeNodes; - function getHeritageClause(clauses, kind) { - if (clauses) { - for (var _i = 0; _i < clauses.length; _i++) { - var clause = clauses[_i]; - if (clause.token === kind) { - return clause; - } - } - } - return undefined; - } - ts.getHeritageClause = getHeritageClause; - function tryResolveScriptReference(host, sourceFile, reference) { - if (!host.getCompilerOptions().noResolve) { - var referenceFileName = ts.isRootedDiskPath(reference.fileName) ? reference.fileName : ts.combinePaths(ts.getDirectoryPath(sourceFile.fileName), reference.fileName); - referenceFileName = ts.getNormalizedAbsolutePath(referenceFileName, host.getCurrentDirectory()); - return host.getSourceFile(referenceFileName); - } - } - ts.tryResolveScriptReference = tryResolveScriptReference; - function getAncestor(node, kind) { - while (node) { - if (node.kind === kind) { - return node; - } - node = node.parent; - } - return undefined; - } - ts.getAncestor = getAncestor; - function getFileReferenceFromReferencePath(comment, commentRange) { - var simpleReferenceRegEx = /^\/\/\/\s*/gim; - if (simpleReferenceRegEx.exec(comment)) { - if (isNoDefaultLibRegEx.exec(comment)) { - return { - isNoDefaultLib: true - }; - } - else { - var matchResult = ts.fullTripleSlashReferencePathRegEx.exec(comment); - if (matchResult) { - var start = commentRange.pos; - var end = commentRange.end; - return { - fileReference: { - pos: start, - end: end, - fileName: matchResult[3] - }, - isNoDefaultLib: false - }; - } - else { - return { - diagnosticMessage: ts.Diagnostics.Invalid_reference_directive_syntax, - isNoDefaultLib: false - }; - } - } - } - return undefined; - } - ts.getFileReferenceFromReferencePath = getFileReferenceFromReferencePath; - function isKeyword(token) { - return 70 <= token && token <= 134; - } - ts.isKeyword = isKeyword; - function isTrivia(token) { - return 2 <= token && token <= 7; - } - ts.isTrivia = isTrivia; - function isAsyncFunctionLike(node) { - return isFunctionLike(node) && (node.flags & 512) !== 0 && !isAccessor(node); - } - ts.isAsyncFunctionLike = isAsyncFunctionLike; - function hasDynamicName(declaration) { - return declaration.name && - declaration.name.kind === 136 && - !isWellKnownSymbolSyntactically(declaration.name.expression); - } - ts.hasDynamicName = hasDynamicName; - function isWellKnownSymbolSyntactically(node) { - return isPropertyAccessExpression(node) && isESSymbolIdentifier(node.expression); - } - ts.isWellKnownSymbolSyntactically = isWellKnownSymbolSyntactically; - function getPropertyNameForPropertyNameNode(name) { - if (name.kind === 69 || name.kind === 9 || name.kind === 8) { - return name.text; - } - if (name.kind === 136) { - var nameExpression = name.expression; - if (isWellKnownSymbolSyntactically(nameExpression)) { - var rightHandSideName = nameExpression.name.text; - return getPropertyNameForKnownSymbolName(rightHandSideName); - } - } - return undefined; - } - ts.getPropertyNameForPropertyNameNode = getPropertyNameForPropertyNameNode; - function getPropertyNameForKnownSymbolName(symbolName) { - return "__@" + symbolName; - } - ts.getPropertyNameForKnownSymbolName = getPropertyNameForKnownSymbolName; - function isESSymbolIdentifier(node) { - return node.kind === 69 && node.text === "Symbol"; - } - ts.isESSymbolIdentifier = isESSymbolIdentifier; - function isModifier(token) { - switch (token) { - case 115: - case 118: - case 74: - case 122: - case 77: - case 82: - case 112: - case 110: - case 111: - case 113: - return true; - } - return false; - } - ts.isModifier = isModifier; - function isParameterDeclaration(node) { - var root = getRootDeclaration(node); - return root.kind === 138; - } - ts.isParameterDeclaration = isParameterDeclaration; - function getRootDeclaration(node) { - while (node.kind === 163) { - node = node.parent.parent; - } - return node; - } - ts.getRootDeclaration = getRootDeclaration; - function nodeStartsNewLexicalEnvironment(n) { - return isFunctionLike(n) || n.kind === 218 || n.kind === 248; - } - ts.nodeStartsNewLexicalEnvironment = nodeStartsNewLexicalEnvironment; - function cloneEntityName(node) { - if (node.kind === 69) { - var clone_1 = createSynthesizedNode(69); - clone_1.text = node.text; - return clone_1; - } - else { - var clone_2 = createSynthesizedNode(135); - clone_2.left = cloneEntityName(node.left); - clone_2.left.parent = clone_2; - clone_2.right = cloneEntityName(node.right); - clone_2.right.parent = clone_2; - return clone_2; - } - } - ts.cloneEntityName = cloneEntityName; - function nodeIsSynthesized(node) { - return node.pos === -1; - } - ts.nodeIsSynthesized = nodeIsSynthesized; - function createSynthesizedNode(kind, startsOnNewLine) { - var node = ts.createNode(kind, -1, -1); - node.startsOnNewLine = startsOnNewLine; - return node; - } - ts.createSynthesizedNode = createSynthesizedNode; - function createSynthesizedNodeArray() { - var array = []; - array.pos = -1; - array.end = -1; - return array; - } - ts.createSynthesizedNodeArray = createSynthesizedNodeArray; - function createDiagnosticCollection() { - var nonFileDiagnostics = []; - var fileDiagnostics = {}; - var diagnosticsModified = false; - var modificationCount = 0; - return { - add: add, - getGlobalDiagnostics: getGlobalDiagnostics, - getDiagnostics: getDiagnostics, - getModificationCount: getModificationCount, - reattachFileDiagnostics: reattachFileDiagnostics - }; - function getModificationCount() { - return modificationCount; - } - function reattachFileDiagnostics(newFile) { - if (!ts.hasProperty(fileDiagnostics, newFile.fileName)) { - return; - } - for (var _i = 0, _a = fileDiagnostics[newFile.fileName]; _i < _a.length; _i++) { - var diagnostic = _a[_i]; - diagnostic.file = newFile; - } - } - function add(diagnostic) { - var diagnostics; - if (diagnostic.file) { - diagnostics = fileDiagnostics[diagnostic.file.fileName]; - if (!diagnostics) { - diagnostics = []; - fileDiagnostics[diagnostic.file.fileName] = diagnostics; - } - } - else { - diagnostics = nonFileDiagnostics; - } - diagnostics.push(diagnostic); - diagnosticsModified = true; - modificationCount++; - } - function getGlobalDiagnostics() { - sortAndDeduplicate(); - return nonFileDiagnostics; - } - function getDiagnostics(fileName) { - sortAndDeduplicate(); - if (fileName) { - return fileDiagnostics[fileName] || []; - } - var allDiagnostics = []; - function pushDiagnostic(d) { - allDiagnostics.push(d); - } - ts.forEach(nonFileDiagnostics, pushDiagnostic); - for (var key in fileDiagnostics) { - if (ts.hasProperty(fileDiagnostics, key)) { - ts.forEach(fileDiagnostics[key], pushDiagnostic); - } - } - return ts.sortAndDeduplicateDiagnostics(allDiagnostics); - } - function sortAndDeduplicate() { - if (!diagnosticsModified) { - return; - } - diagnosticsModified = false; - nonFileDiagnostics = ts.sortAndDeduplicateDiagnostics(nonFileDiagnostics); - for (var key in fileDiagnostics) { - if (ts.hasProperty(fileDiagnostics, key)) { - fileDiagnostics[key] = ts.sortAndDeduplicateDiagnostics(fileDiagnostics[key]); - } - } - } - } - ts.createDiagnosticCollection = createDiagnosticCollection; - var escapedCharsRegExp = /[\\\"\u0000-\u001f\t\v\f\b\r\n\u2028\u2029\u0085]/g; - var escapedCharsMap = { - "\0": "\\0", - "\t": "\\t", - "\v": "\\v", - "\f": "\\f", - "\b": "\\b", - "\r": "\\r", - "\n": "\\n", - "\\": "\\\\", - "\"": "\\\"", - "\u2028": "\\u2028", - "\u2029": "\\u2029", - "\u0085": "\\u0085" - }; - function escapeString(s) { - s = escapedCharsRegExp.test(s) ? s.replace(escapedCharsRegExp, getReplacement) : s; - return s; - function getReplacement(c) { - return escapedCharsMap[c] || get16BitUnicodeEscapeSequence(c.charCodeAt(0)); - } - } - ts.escapeString = escapeString; - function isIntrinsicJsxName(name) { - var ch = name.substr(0, 1); - return ch.toLowerCase() === ch; - } - ts.isIntrinsicJsxName = isIntrinsicJsxName; - function get16BitUnicodeEscapeSequence(charCode) { - var hexCharCode = charCode.toString(16).toUpperCase(); - var paddedHexCode = ("0000" + hexCharCode).slice(-4); - return "\\u" + paddedHexCode; - } - var nonAsciiCharacters = /[^\u0000-\u007F]/g; - function escapeNonAsciiCharacters(s) { - return nonAsciiCharacters.test(s) ? - s.replace(nonAsciiCharacters, function (c) { return get16BitUnicodeEscapeSequence(c.charCodeAt(0)); }) : - s; - } - ts.escapeNonAsciiCharacters = escapeNonAsciiCharacters; - var indentStrings = ["", " "]; - function getIndentString(level) { - if (indentStrings[level] === undefined) { - indentStrings[level] = getIndentString(level - 1) + indentStrings[1]; - } - return indentStrings[level]; - } - ts.getIndentString = getIndentString; - function getIndentSize() { - return indentStrings[1].length; - } - ts.getIndentSize = getIndentSize; - function createTextWriter(newLine) { - var output = ""; - var indent = 0; - var lineStart = true; - var lineCount = 0; - var linePos = 0; - function write(s) { - if (s && s.length) { - if (lineStart) { - output += getIndentString(indent); - lineStart = false; - } - output += s; - } - } - function rawWrite(s) { - if (s !== undefined) { - if (lineStart) { - lineStart = false; - } - output += s; - } - } - function writeLiteral(s) { - if (s && s.length) { - write(s); - var lineStartsOfS = ts.computeLineStarts(s); - if (lineStartsOfS.length > 1) { - lineCount = lineCount + lineStartsOfS.length - 1; - linePos = output.length - s.length + ts.lastOrUndefined(lineStartsOfS); - } - } - } - function writeLine() { - if (!lineStart) { - output += newLine; - lineCount++; - linePos = output.length; - lineStart = true; - } - } - function writeTextOfNode(sourceFile, node) { - write(getSourceTextOfNodeFromSourceFile(sourceFile, node)); - } - return { - write: write, - rawWrite: rawWrite, - writeTextOfNode: writeTextOfNode, - writeLiteral: writeLiteral, - writeLine: writeLine, - increaseIndent: function () { return indent++; }, - decreaseIndent: function () { return indent--; }, - getIndent: function () { return indent; }, - getTextPos: function () { return output.length; }, - getLine: function () { return lineCount + 1; }, - getColumn: function () { return lineStart ? indent * getIndentSize() + 1 : output.length - linePos + 1; }, - getText: function () { return output; } - }; - } - ts.createTextWriter = createTextWriter; - function getOwnEmitOutputFilePath(sourceFile, host, extension) { - var compilerOptions = host.getCompilerOptions(); - var emitOutputFilePathWithoutExtension; - if (compilerOptions.outDir) { - emitOutputFilePathWithoutExtension = ts.removeFileExtension(getSourceFilePathInNewDir(sourceFile, host, compilerOptions.outDir)); - } - else { - emitOutputFilePathWithoutExtension = ts.removeFileExtension(sourceFile.fileName); - } - return emitOutputFilePathWithoutExtension + extension; - } - ts.getOwnEmitOutputFilePath = getOwnEmitOutputFilePath; - function getSourceFilePathInNewDir(sourceFile, host, newDirPath) { - var sourceFilePath = ts.getNormalizedAbsolutePath(sourceFile.fileName, host.getCurrentDirectory()); - sourceFilePath = sourceFilePath.replace(host.getCommonSourceDirectory(), ""); - return ts.combinePaths(newDirPath, sourceFilePath); - } - ts.getSourceFilePathInNewDir = getSourceFilePathInNewDir; - function writeFile(host, diagnostics, fileName, data, writeByteOrderMark) { - host.writeFile(fileName, data, writeByteOrderMark, function (hostErrorMessage) { - diagnostics.push(ts.createCompilerDiagnostic(ts.Diagnostics.Could_not_write_file_0_Colon_1, fileName, hostErrorMessage)); - }); - } - ts.writeFile = writeFile; - function getLineOfLocalPosition(currentSourceFile, pos) { - return ts.getLineAndCharacterOfPosition(currentSourceFile, pos).line; - } - ts.getLineOfLocalPosition = getLineOfLocalPosition; - function getFirstConstructorWithBody(node) { - return ts.forEach(node.members, function (member) { - if (member.kind === 144 && nodeIsPresent(member.body)) { - return member; - } - }); - } - ts.getFirstConstructorWithBody = getFirstConstructorWithBody; - function getSetAccessorTypeAnnotationNode(accessor) { - return accessor && accessor.parameters.length > 0 && accessor.parameters[0].type; - } - ts.getSetAccessorTypeAnnotationNode = getSetAccessorTypeAnnotationNode; - function shouldEmitToOwnFile(sourceFile, compilerOptions) { - if (!isDeclarationFile(sourceFile)) { - if ((isExternalModule(sourceFile) || !(compilerOptions.outFile || compilerOptions.out))) { - return compilerOptions.isolatedModules || !ts.fileExtensionIs(sourceFile.fileName, ".js"); - } - return false; - } - return false; - } - ts.shouldEmitToOwnFile = shouldEmitToOwnFile; - function getAllAccessorDeclarations(declarations, accessor) { - var firstAccessor; - var secondAccessor; - var getAccessor; - var setAccessor; - if (hasDynamicName(accessor)) { - firstAccessor = accessor; - if (accessor.kind === 145) { - getAccessor = accessor; - } - else if (accessor.kind === 146) { - setAccessor = accessor; - } - else { - ts.Debug.fail("Accessor has wrong kind"); - } - } - else { - ts.forEach(declarations, function (member) { - if ((member.kind === 145 || member.kind === 146) - && (member.flags & 128) === (accessor.flags & 128)) { - var memberName = getPropertyNameForPropertyNameNode(member.name); - var accessorName = getPropertyNameForPropertyNameNode(accessor.name); - if (memberName === accessorName) { - if (!firstAccessor) { - firstAccessor = member; - } - else if (!secondAccessor) { - secondAccessor = member; - } - if (member.kind === 145 && !getAccessor) { - getAccessor = member; - } - if (member.kind === 146 && !setAccessor) { - setAccessor = member; - } - } - } - }); - } - return { - firstAccessor: firstAccessor, - secondAccessor: secondAccessor, - getAccessor: getAccessor, - setAccessor: setAccessor - }; - } - ts.getAllAccessorDeclarations = getAllAccessorDeclarations; - function emitNewLineBeforeLeadingComments(currentSourceFile, writer, node, leadingComments) { - if (leadingComments && leadingComments.length && node.pos !== leadingComments[0].pos && - getLineOfLocalPosition(currentSourceFile, node.pos) !== getLineOfLocalPosition(currentSourceFile, leadingComments[0].pos)) { - writer.writeLine(); - } - } - ts.emitNewLineBeforeLeadingComments = emitNewLineBeforeLeadingComments; - function emitComments(currentSourceFile, writer, comments, trailingSeparator, newLine, writeComment) { - var emitLeadingSpace = !trailingSeparator; - ts.forEach(comments, function (comment) { - if (emitLeadingSpace) { - writer.write(" "); - emitLeadingSpace = false; - } - writeComment(currentSourceFile, writer, comment, newLine); - if (comment.hasTrailingNewLine) { - writer.writeLine(); - } - else if (trailingSeparator) { - writer.write(" "); - } - else { - emitLeadingSpace = true; - } - }); - } - ts.emitComments = emitComments; - function writeCommentRange(currentSourceFile, writer, comment, newLine) { - if (currentSourceFile.text.charCodeAt(comment.pos + 1) === 42) { - var firstCommentLineAndCharacter = ts.getLineAndCharacterOfPosition(currentSourceFile, comment.pos); - var lineCount = ts.getLineStarts(currentSourceFile).length; - var firstCommentLineIndent; - for (var pos = comment.pos, currentLine = firstCommentLineAndCharacter.line; pos < comment.end; currentLine++) { - var nextLineStart = (currentLine + 1) === lineCount - ? currentSourceFile.text.length + 1 - : getStartPositionOfLine(currentLine + 1, currentSourceFile); - if (pos !== comment.pos) { - if (firstCommentLineIndent === undefined) { - firstCommentLineIndent = calculateIndent(getStartPositionOfLine(firstCommentLineAndCharacter.line, currentSourceFile), comment.pos); - } - var currentWriterIndentSpacing = writer.getIndent() * getIndentSize(); - var spacesToEmit = currentWriterIndentSpacing - firstCommentLineIndent + calculateIndent(pos, nextLineStart); - if (spacesToEmit > 0) { - var numberOfSingleSpacesToEmit = spacesToEmit % getIndentSize(); - var indentSizeSpaceString = getIndentString((spacesToEmit - numberOfSingleSpacesToEmit) / getIndentSize()); - writer.rawWrite(indentSizeSpaceString); - while (numberOfSingleSpacesToEmit) { - writer.rawWrite(" "); - numberOfSingleSpacesToEmit--; - } - } - else { - writer.rawWrite(""); - } - } - writeTrimmedCurrentLine(pos, nextLineStart); - pos = nextLineStart; - } - } - else { - writer.write(currentSourceFile.text.substring(comment.pos, comment.end)); - } - function writeTrimmedCurrentLine(pos, nextLineStart) { - var end = Math.min(comment.end, nextLineStart - 1); - var currentLineText = currentSourceFile.text.substring(pos, end).replace(/^\s+|\s+$/g, ""); - if (currentLineText) { - writer.write(currentLineText); - if (end !== comment.end) { - writer.writeLine(); - } - } - else { - writer.writeLiteral(newLine); - } - } - function calculateIndent(pos, end) { - var currentLineIndent = 0; - for (; pos < end && ts.isWhiteSpace(currentSourceFile.text.charCodeAt(pos)); pos++) { - if (currentSourceFile.text.charCodeAt(pos) === 9) { - currentLineIndent += getIndentSize() - (currentLineIndent % getIndentSize()); - } - else { - currentLineIndent++; - } - } - return currentLineIndent; - } - } - ts.writeCommentRange = writeCommentRange; - function modifierToFlag(token) { - switch (token) { - case 113: return 128; - case 112: return 16; - case 111: return 64; - case 110: return 32; - case 115: return 256; - case 82: return 1; - case 122: return 2; - case 74: return 32768; - case 77: return 1024; - case 118: return 512; - } - return 0; - } - ts.modifierToFlag = modifierToFlag; - function isLeftHandSideExpression(expr) { - if (expr) { - switch (expr.kind) { - case 166: - case 167: - case 169: - case 168: - case 233: - case 234: - case 170: - case 164: - case 172: - case 165: - case 186: - case 173: - case 69: - case 10: - case 8: - case 9: - case 11: - case 183: - case 84: - case 93: - case 97: - case 99: - case 95: - return true; - } - } - return false; - } - ts.isLeftHandSideExpression = isLeftHandSideExpression; - function isAssignmentOperator(token) { - return token >= 56 && token <= 68; - } - ts.isAssignmentOperator = isAssignmentOperator; - function isExpressionWithTypeArgumentsInClassExtendsClause(node) { - return node.kind === 188 && - node.parent.token === 83 && - isClassLike(node.parent.parent); - } - ts.isExpressionWithTypeArgumentsInClassExtendsClause = isExpressionWithTypeArgumentsInClassExtendsClause; - function isSupportedExpressionWithTypeArguments(node) { - return isSupportedExpressionWithTypeArgumentsRest(node.expression); - } - ts.isSupportedExpressionWithTypeArguments = isSupportedExpressionWithTypeArguments; - function isSupportedExpressionWithTypeArgumentsRest(node) { - if (node.kind === 69) { - return true; - } - else if (isPropertyAccessExpression(node)) { - return isSupportedExpressionWithTypeArgumentsRest(node.expression); - } - else { - return false; - } - } - function isRightSideOfQualifiedNameOrPropertyAccess(node) { - return (node.parent.kind === 135 && node.parent.right === node) || - (node.parent.kind === 166 && node.parent.name === node); - } - ts.isRightSideOfQualifiedNameOrPropertyAccess = isRightSideOfQualifiedNameOrPropertyAccess; - function isEmptyObjectLiteralOrArrayLiteral(expression) { - var kind = expression.kind; - if (kind === 165) { - return expression.properties.length === 0; - } - if (kind === 164) { - return expression.elements.length === 0; - } - return false; - } - ts.isEmptyObjectLiteralOrArrayLiteral = isEmptyObjectLiteralOrArrayLiteral; - function getLocalSymbolForExportDefault(symbol) { - return symbol && symbol.valueDeclaration && (symbol.valueDeclaration.flags & 1024) ? symbol.valueDeclaration.localSymbol : undefined; - } - ts.getLocalSymbolForExportDefault = getLocalSymbolForExportDefault; - function isJavaScript(fileName) { - return ts.fileExtensionIs(fileName, ".js"); - } - ts.isJavaScript = isJavaScript; - function isTsx(fileName) { - return ts.fileExtensionIs(fileName, ".tsx"); - } - ts.isTsx = isTsx; - function getExpandedCharCodes(input) { - var output = []; - var length = input.length; - for (var i = 0; i < length; i++) { - var charCode = input.charCodeAt(i); - if (charCode < 0x80) { - output.push(charCode); - } - else if (charCode < 0x800) { - output.push((charCode >> 6) | 192); - output.push((charCode & 63) | 128); - } - else if (charCode < 0x10000) { - output.push((charCode >> 12) | 224); - output.push(((charCode >> 6) & 63) | 128); - output.push((charCode & 63) | 128); - } - else if (charCode < 0x20000) { - output.push((charCode >> 18) | 240); - output.push(((charCode >> 12) & 63) | 128); - output.push(((charCode >> 6) & 63) | 128); - output.push((charCode & 63) | 128); - } - else { - ts.Debug.assert(false, "Unexpected code point"); - } - } - return output; - } - var base64Digits = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="; - function convertToBase64(input) { - var result = ""; - var charCodes = getExpandedCharCodes(input); - var i = 0; - var length = charCodes.length; - var byte1, byte2, byte3, byte4; - while (i < length) { - byte1 = charCodes[i] >> 2; - byte2 = (charCodes[i] & 3) << 4 | charCodes[i + 1] >> 4; - byte3 = (charCodes[i + 1] & 15) << 2 | charCodes[i + 2] >> 6; - byte4 = charCodes[i + 2] & 63; - if (i + 1 >= length) { - byte3 = byte4 = 64; - } - else if (i + 2 >= length) { - byte4 = 64; - } - result += base64Digits.charAt(byte1) + base64Digits.charAt(byte2) + base64Digits.charAt(byte3) + base64Digits.charAt(byte4); - i += 3; - } - return result; - } - ts.convertToBase64 = convertToBase64; - var carriageReturnLineFeed = "\r\n"; - var lineFeed = "\n"; - function getNewLineCharacter(options) { - if (options.newLine === 0) { - return carriageReturnLineFeed; - } - else if (options.newLine === 1) { - return lineFeed; - } - else if (ts.sys) { - return ts.sys.newLine; - } - return carriageReturnLineFeed; - } - ts.getNewLineCharacter = getNewLineCharacter; -})(ts || (ts = {})); -var ts; -(function (ts) { - function getDefaultLibFileName(options) { - return options.target === 2 ? "lib.es6.d.ts" : "lib.d.ts"; - } - ts.getDefaultLibFileName = getDefaultLibFileName; - function textSpanEnd(span) { - return span.start + span.length; - } - ts.textSpanEnd = textSpanEnd; - function textSpanIsEmpty(span) { - return span.length === 0; - } - ts.textSpanIsEmpty = textSpanIsEmpty; - function textSpanContainsPosition(span, position) { - return position >= span.start && position < textSpanEnd(span); - } - ts.textSpanContainsPosition = textSpanContainsPosition; - function textSpanContainsTextSpan(span, other) { - return other.start >= span.start && textSpanEnd(other) <= textSpanEnd(span); - } - ts.textSpanContainsTextSpan = textSpanContainsTextSpan; - function textSpanOverlapsWith(span, other) { - var overlapStart = Math.max(span.start, other.start); - var overlapEnd = Math.min(textSpanEnd(span), textSpanEnd(other)); - return overlapStart < overlapEnd; - } - ts.textSpanOverlapsWith = textSpanOverlapsWith; - function textSpanOverlap(span1, span2) { - var overlapStart = Math.max(span1.start, span2.start); - var overlapEnd = Math.min(textSpanEnd(span1), textSpanEnd(span2)); - if (overlapStart < overlapEnd) { - return createTextSpanFromBounds(overlapStart, overlapEnd); - } - return undefined; - } - ts.textSpanOverlap = textSpanOverlap; - function textSpanIntersectsWithTextSpan(span, other) { - return other.start <= textSpanEnd(span) && textSpanEnd(other) >= span.start; - } - ts.textSpanIntersectsWithTextSpan = textSpanIntersectsWithTextSpan; - function textSpanIntersectsWith(span, start, length) { - var end = start + length; - return start <= textSpanEnd(span) && end >= span.start; - } - ts.textSpanIntersectsWith = textSpanIntersectsWith; - function decodedTextSpanIntersectsWith(start1, length1, start2, length2) { - var end1 = start1 + length1; - var end2 = start2 + length2; - return start2 <= end1 && end2 >= start1; - } - ts.decodedTextSpanIntersectsWith = decodedTextSpanIntersectsWith; - function textSpanIntersectsWithPosition(span, position) { - return position <= textSpanEnd(span) && position >= span.start; - } - ts.textSpanIntersectsWithPosition = textSpanIntersectsWithPosition; - function textSpanIntersection(span1, span2) { - var intersectStart = Math.max(span1.start, span2.start); - var intersectEnd = Math.min(textSpanEnd(span1), textSpanEnd(span2)); - if (intersectStart <= intersectEnd) { - return createTextSpanFromBounds(intersectStart, intersectEnd); - } - return undefined; - } - ts.textSpanIntersection = textSpanIntersection; - function createTextSpan(start, length) { - if (start < 0) { - throw new Error("start < 0"); - } - if (length < 0) { - throw new Error("length < 0"); - } - return { start: start, length: length }; - } - ts.createTextSpan = createTextSpan; - function createTextSpanFromBounds(start, end) { - return createTextSpan(start, end - start); - } - ts.createTextSpanFromBounds = createTextSpanFromBounds; - function textChangeRangeNewSpan(range) { - return createTextSpan(range.span.start, range.newLength); - } - ts.textChangeRangeNewSpan = textChangeRangeNewSpan; - function textChangeRangeIsUnchanged(range) { - return textSpanIsEmpty(range.span) && range.newLength === 0; - } - ts.textChangeRangeIsUnchanged = textChangeRangeIsUnchanged; - function createTextChangeRange(span, newLength) { - if (newLength < 0) { - throw new Error("newLength < 0"); - } - return { span: span, newLength: newLength }; - } - ts.createTextChangeRange = createTextChangeRange; - ts.unchangedTextChangeRange = createTextChangeRange(createTextSpan(0, 0), 0); - function collapseTextChangeRangesAcrossMultipleVersions(changes) { - if (changes.length === 0) { - return ts.unchangedTextChangeRange; - } - if (changes.length === 1) { - return changes[0]; - } - var change0 = changes[0]; - var oldStartN = change0.span.start; - var oldEndN = textSpanEnd(change0.span); - var newEndN = oldStartN + change0.newLength; - for (var i = 1; i < changes.length; i++) { - var nextChange = changes[i]; - var oldStart1 = oldStartN; - var oldEnd1 = oldEndN; - var newEnd1 = newEndN; - var oldStart2 = nextChange.span.start; - var oldEnd2 = textSpanEnd(nextChange.span); - var newEnd2 = oldStart2 + nextChange.newLength; - oldStartN = Math.min(oldStart1, oldStart2); - oldEndN = Math.max(oldEnd1, oldEnd1 + (oldEnd2 - newEnd1)); - newEndN = Math.max(newEnd2, newEnd2 + (newEnd1 - oldEnd2)); - } - return createTextChangeRange(createTextSpanFromBounds(oldStartN, oldEndN), newEndN - oldStartN); - } - ts.collapseTextChangeRangesAcrossMultipleVersions = collapseTextChangeRangesAcrossMultipleVersions; - function getTypeParameterOwner(d) { - if (d && d.kind === 137) { - for (var current = d; current; current = current.parent) { - if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 215) { - return current; - } - } - } - } - ts.getTypeParameterOwner = getTypeParameterOwner; -})(ts || (ts = {})); -var ts; -(function (ts) { - var nodeConstructors = new Array(272); - ts.parseTime = 0; - function getNodeConstructor(kind) { - return nodeConstructors[kind] || (nodeConstructors[kind] = ts.objectAllocator.getNodeConstructor(kind)); - } - ts.getNodeConstructor = getNodeConstructor; - function createNode(kind, pos, end) { - return new (getNodeConstructor(kind))(pos, end); - } - ts.createNode = createNode; - function visitNode(cbNode, node) { - if (node) { - return cbNode(node); - } - } - function visitNodeArray(cbNodes, nodes) { - if (nodes) { - return cbNodes(nodes); - } - } - function visitEachNode(cbNode, nodes) { - if (nodes) { - for (var _i = 0; _i < nodes.length; _i++) { - var node = nodes[_i]; - var result = cbNode(node); - if (result) { - return result; - } - } - } - } - function forEachChild(node, cbNode, cbNodeArray) { - if (!node) { - return; - } - var visitNodes = cbNodeArray ? visitNodeArray : visitEachNode; - var cbNodes = cbNodeArray || cbNode; - switch (node.kind) { - case 135: - return visitNode(cbNode, node.left) || - visitNode(cbNode, node.right); - case 137: - return visitNode(cbNode, node.name) || - visitNode(cbNode, node.constraint) || - visitNode(cbNode, node.expression); - case 246: - return visitNodes(cbNodes, node.decorators) || - visitNodes(cbNodes, node.modifiers) || - visitNode(cbNode, node.name) || - visitNode(cbNode, node.questionToken) || - visitNode(cbNode, node.equalsToken) || - visitNode(cbNode, node.objectAssignmentInitializer); - case 138: - case 141: - case 140: - case 245: - case 211: - case 163: - return visitNodes(cbNodes, node.decorators) || - visitNodes(cbNodes, node.modifiers) || - visitNode(cbNode, node.propertyName) || - visitNode(cbNode, node.dotDotDotToken) || - visitNode(cbNode, node.name) || - visitNode(cbNode, node.questionToken) || - visitNode(cbNode, node.type) || - visitNode(cbNode, node.initializer); - case 152: - case 153: - case 147: - case 148: - case 149: - return visitNodes(cbNodes, node.decorators) || - visitNodes(cbNodes, node.modifiers) || - visitNodes(cbNodes, node.typeParameters) || - visitNodes(cbNodes, node.parameters) || - visitNode(cbNode, node.type); - case 143: - case 142: - case 144: - case 145: - case 146: - case 173: - case 213: - case 174: - return visitNodes(cbNodes, node.decorators) || - visitNodes(cbNodes, node.modifiers) || - visitNode(cbNode, node.asteriskToken) || - visitNode(cbNode, node.name) || - visitNode(cbNode, node.questionToken) || - visitNodes(cbNodes, node.typeParameters) || - visitNodes(cbNodes, node.parameters) || - visitNode(cbNode, node.type) || - visitNode(cbNode, node.equalsGreaterThanToken) || - visitNode(cbNode, node.body); - case 151: - return visitNode(cbNode, node.typeName) || - visitNodes(cbNodes, node.typeArguments); - case 150: - return visitNode(cbNode, node.parameterName) || - visitNode(cbNode, node.type); - case 154: - return visitNode(cbNode, node.exprName); - case 155: - return visitNodes(cbNodes, node.members); - case 156: - return visitNode(cbNode, node.elementType); - case 157: - return visitNodes(cbNodes, node.elementTypes); - case 158: - case 159: - return visitNodes(cbNodes, node.types); - case 160: - return visitNode(cbNode, node.type); - case 161: - case 162: - return visitNodes(cbNodes, node.elements); - case 164: - return visitNodes(cbNodes, node.elements); - case 165: - return visitNodes(cbNodes, node.properties); - case 166: - return visitNode(cbNode, node.expression) || - visitNode(cbNode, node.dotToken) || - visitNode(cbNode, node.name); - case 167: - return visitNode(cbNode, node.expression) || - visitNode(cbNode, node.argumentExpression); - case 168: - case 169: - return visitNode(cbNode, node.expression) || - visitNodes(cbNodes, node.typeArguments) || - visitNodes(cbNodes, node.arguments); - case 170: - return visitNode(cbNode, node.tag) || - visitNode(cbNode, node.template); - case 171: - return visitNode(cbNode, node.type) || - visitNode(cbNode, node.expression); - case 172: - return visitNode(cbNode, node.expression); - case 175: - return visitNode(cbNode, node.expression); - case 176: - return visitNode(cbNode, node.expression); - case 177: - return visitNode(cbNode, node.expression); - case 179: - return visitNode(cbNode, node.operand); - case 184: - return visitNode(cbNode, node.asteriskToken) || - visitNode(cbNode, node.expression); - case 178: - return visitNode(cbNode, node.expression); - case 180: - return visitNode(cbNode, node.operand); - case 181: - return visitNode(cbNode, node.left) || - visitNode(cbNode, node.operatorToken) || - visitNode(cbNode, node.right); - case 189: - return visitNode(cbNode, node.expression) || - visitNode(cbNode, node.type); - case 182: - return visitNode(cbNode, node.condition) || - visitNode(cbNode, node.questionToken) || - visitNode(cbNode, node.whenTrue) || - visitNode(cbNode, node.colonToken) || - visitNode(cbNode, node.whenFalse); - case 185: - return visitNode(cbNode, node.expression); - case 192: - case 219: - return visitNodes(cbNodes, node.statements); - case 248: - return visitNodes(cbNodes, node.statements) || - visitNode(cbNode, node.endOfFileToken); - case 193: - return visitNodes(cbNodes, node.decorators) || - visitNodes(cbNodes, node.modifiers) || - visitNode(cbNode, node.declarationList); - case 212: - return visitNodes(cbNodes, node.declarations); - case 195: - return visitNode(cbNode, node.expression); - case 196: - return visitNode(cbNode, node.expression) || - visitNode(cbNode, node.thenStatement) || - visitNode(cbNode, node.elseStatement); - case 197: - return visitNode(cbNode, node.statement) || - visitNode(cbNode, node.expression); - case 198: - return visitNode(cbNode, node.expression) || - visitNode(cbNode, node.statement); - case 199: - return visitNode(cbNode, node.initializer) || - visitNode(cbNode, node.condition) || - visitNode(cbNode, node.incrementor) || - visitNode(cbNode, node.statement); - case 200: - return visitNode(cbNode, node.initializer) || - visitNode(cbNode, node.expression) || - visitNode(cbNode, node.statement); - case 201: - return visitNode(cbNode, node.initializer) || - visitNode(cbNode, node.expression) || - visitNode(cbNode, node.statement); - case 202: - case 203: - return visitNode(cbNode, node.label); - case 204: - return visitNode(cbNode, node.expression); - case 205: - return visitNode(cbNode, node.expression) || - visitNode(cbNode, node.statement); - case 206: - return visitNode(cbNode, node.expression) || - visitNode(cbNode, node.caseBlock); - case 220: - return visitNodes(cbNodes, node.clauses); - case 241: - return visitNode(cbNode, node.expression) || - visitNodes(cbNodes, node.statements); - case 242: - return visitNodes(cbNodes, node.statements); - case 207: - return visitNode(cbNode, node.label) || - visitNode(cbNode, node.statement); - case 208: - return visitNode(cbNode, node.expression); - case 209: - return visitNode(cbNode, node.tryBlock) || - visitNode(cbNode, node.catchClause) || - visitNode(cbNode, node.finallyBlock); - case 244: - return visitNode(cbNode, node.variableDeclaration) || - visitNode(cbNode, node.block); - case 139: - return visitNode(cbNode, node.expression); - case 214: - case 186: - return visitNodes(cbNodes, node.decorators) || - visitNodes(cbNodes, node.modifiers) || - visitNode(cbNode, node.name) || - visitNodes(cbNodes, node.typeParameters) || - visitNodes(cbNodes, node.heritageClauses) || - visitNodes(cbNodes, node.members); - case 215: - return visitNodes(cbNodes, node.decorators) || - visitNodes(cbNodes, node.modifiers) || - visitNode(cbNode, node.name) || - visitNodes(cbNodes, node.typeParameters) || - visitNodes(cbNodes, node.heritageClauses) || - visitNodes(cbNodes, node.members); - case 216: - return visitNodes(cbNodes, node.decorators) || - visitNodes(cbNodes, node.modifiers) || - visitNode(cbNode, node.name) || - visitNodes(cbNodes, node.typeParameters) || - visitNode(cbNode, node.type); - case 217: - return visitNodes(cbNodes, node.decorators) || - visitNodes(cbNodes, node.modifiers) || - visitNode(cbNode, node.name) || - visitNodes(cbNodes, node.members); - case 247: - return visitNode(cbNode, node.name) || - visitNode(cbNode, node.initializer); - case 218: - return visitNodes(cbNodes, node.decorators) || - visitNodes(cbNodes, node.modifiers) || - visitNode(cbNode, node.name) || - visitNode(cbNode, node.body); - case 221: - return visitNodes(cbNodes, node.decorators) || - visitNodes(cbNodes, node.modifiers) || - visitNode(cbNode, node.name) || - visitNode(cbNode, node.moduleReference); - case 222: - return visitNodes(cbNodes, node.decorators) || - visitNodes(cbNodes, node.modifiers) || - visitNode(cbNode, node.importClause) || - visitNode(cbNode, node.moduleSpecifier); - case 223: - return visitNode(cbNode, node.name) || - visitNode(cbNode, node.namedBindings); - case 224: - return visitNode(cbNode, node.name); - case 225: - case 229: - return visitNodes(cbNodes, node.elements); - case 228: - return visitNodes(cbNodes, node.decorators) || - visitNodes(cbNodes, node.modifiers) || - visitNode(cbNode, node.exportClause) || - visitNode(cbNode, node.moduleSpecifier); - case 226: - case 230: - return visitNode(cbNode, node.propertyName) || - visitNode(cbNode, node.name); - case 227: - return visitNodes(cbNodes, node.decorators) || - visitNodes(cbNodes, node.modifiers) || - visitNode(cbNode, node.expression); - case 183: - return visitNode(cbNode, node.head) || visitNodes(cbNodes, node.templateSpans); - case 190: - return visitNode(cbNode, node.expression) || visitNode(cbNode, node.literal); - case 136: - return visitNode(cbNode, node.expression); - case 243: - return visitNodes(cbNodes, node.types); - case 188: - return visitNode(cbNode, node.expression) || - visitNodes(cbNodes, node.typeArguments); - case 232: - return visitNode(cbNode, node.expression); - case 231: - return visitNodes(cbNodes, node.decorators); - case 233: - return visitNode(cbNode, node.openingElement) || - visitNodes(cbNodes, node.children) || - visitNode(cbNode, node.closingElement); - case 234: - case 235: - return visitNode(cbNode, node.tagName) || - visitNodes(cbNodes, node.attributes); - case 238: - return visitNode(cbNode, node.name) || - visitNode(cbNode, node.initializer); - case 239: - return visitNode(cbNode, node.expression); - case 240: - return visitNode(cbNode, node.expression); - case 237: - return visitNode(cbNode, node.tagName); - case 249: - return visitNode(cbNode, node.type); - case 253: - return visitNodes(cbNodes, node.types); - case 254: - return visitNodes(cbNodes, node.types); - case 252: - return visitNode(cbNode, node.elementType); - case 256: - return visitNode(cbNode, node.type); - case 255: - return visitNode(cbNode, node.type); - case 257: - return visitNodes(cbNodes, node.members); - case 259: - return visitNode(cbNode, node.name) || - visitNodes(cbNodes, node.typeArguments); - case 260: - return visitNode(cbNode, node.type); - case 261: - return visitNodes(cbNodes, node.parameters) || - visitNode(cbNode, node.type); - case 262: - return visitNode(cbNode, node.type); - case 263: - return visitNode(cbNode, node.type); - case 264: - return visitNode(cbNode, node.type); - case 258: - return visitNode(cbNode, node.name) || - visitNode(cbNode, node.type); - case 265: - return visitNodes(cbNodes, node.tags); - case 267: - return visitNode(cbNode, node.preParameterName) || - visitNode(cbNode, node.typeExpression) || - visitNode(cbNode, node.postParameterName); - case 268: - return visitNode(cbNode, node.typeExpression); - case 269: - return visitNode(cbNode, node.typeExpression); - case 270: - return visitNodes(cbNodes, node.typeParameters); - } - } - ts.forEachChild = forEachChild; - function createSourceFile(fileName, sourceText, languageVersion, setParentNodes) { - if (setParentNodes === void 0) { setParentNodes = false; } - var start = new Date().getTime(); - var result = Parser.parseSourceFile(fileName, sourceText, languageVersion, undefined, setParentNodes); - ts.parseTime += new Date().getTime() - start; - return result; - } - ts.createSourceFile = createSourceFile; - function updateSourceFile(sourceFile, newText, textChangeRange, aggressiveChecks) { - return IncrementalParser.updateSourceFile(sourceFile, newText, textChangeRange, aggressiveChecks); - } - ts.updateSourceFile = updateSourceFile; - function parseIsolatedJSDocComment(content, start, length) { - return Parser.JSDocParser.parseIsolatedJSDocComment(content, start, length); - } - ts.parseIsolatedJSDocComment = parseIsolatedJSDocComment; - function parseJSDocTypeExpressionForTests(content, start, length) { - return Parser.JSDocParser.parseJSDocTypeExpressionForTests(content, start, length); - } - ts.parseJSDocTypeExpressionForTests = parseJSDocTypeExpressionForTests; - var Parser; - (function (Parser) { - var scanner = ts.createScanner(2, true); - var disallowInAndDecoratorContext = 1 | 4; - var sourceFile; - var parseDiagnostics; - var syntaxCursor; - var token; - var sourceText; - var nodeCount; - var identifiers; - var identifierCount; - var parsingContext; - var contextFlags; - var parseErrorBeforeNextFinishedNode = false; - function parseSourceFile(fileName, _sourceText, languageVersion, _syntaxCursor, setParentNodes) { - initializeState(fileName, _sourceText, languageVersion, _syntaxCursor); - var result = parseSourceFileWorker(fileName, languageVersion, setParentNodes); - clearState(); - return result; - } - Parser.parseSourceFile = parseSourceFile; - function initializeState(fileName, _sourceText, languageVersion, _syntaxCursor) { - sourceText = _sourceText; - syntaxCursor = _syntaxCursor; - parseDiagnostics = []; - parsingContext = 0; - identifiers = {}; - identifierCount = 0; - nodeCount = 0; - contextFlags = ts.isJavaScript(fileName) ? 32 : 0; - parseErrorBeforeNextFinishedNode = false; - scanner.setText(sourceText); - scanner.setOnError(scanError); - scanner.setScriptTarget(languageVersion); - scanner.setLanguageVariant(ts.isTsx(fileName) ? 1 : 0); - } - function clearState() { - scanner.setText(""); - scanner.setOnError(undefined); - parseDiagnostics = undefined; - sourceFile = undefined; - identifiers = undefined; - syntaxCursor = undefined; - sourceText = undefined; - } - function parseSourceFileWorker(fileName, languageVersion, setParentNodes) { - sourceFile = createSourceFile(fileName, languageVersion); - token = nextToken(); - processReferenceComments(sourceFile); - sourceFile.statements = parseList(0, parseStatement); - ts.Debug.assert(token === 1); - sourceFile.endOfFileToken = parseTokenNode(); - setExternalModuleIndicator(sourceFile); - sourceFile.nodeCount = nodeCount; - sourceFile.identifierCount = identifierCount; - sourceFile.identifiers = identifiers; - sourceFile.parseDiagnostics = parseDiagnostics; - if (setParentNodes) { - fixupParentReferences(sourceFile); - } - if (ts.isJavaScript(fileName)) { - addJSDocComments(); - } - return sourceFile; - } - function addJSDocComments() { - forEachChild(sourceFile, visit); - return; - function visit(node) { - switch (node.kind) { - case 193: - case 213: - case 138: - addJSDocComment(node); - } - forEachChild(node, visit); - } - } - function addJSDocComment(node) { - var comments = ts.getLeadingCommentRangesOfNode(node, sourceFile); - if (comments) { - for (var _i = 0; _i < comments.length; _i++) { - var comment = comments[_i]; - var jsDocComment = JSDocParser.parseJSDocComment(node, comment.pos, comment.end - comment.pos); - if (jsDocComment) { - node.jsDocComment = jsDocComment; - } - } - } - } - function fixupParentReferences(sourceFile) { - var parent = sourceFile; - forEachChild(sourceFile, visitNode); - return; - function visitNode(n) { - if (n.parent !== parent) { - n.parent = parent; - var saveParent = parent; - parent = n; - forEachChild(n, visitNode); - parent = saveParent; - } - } - } - Parser.fixupParentReferences = fixupParentReferences; - function createSourceFile(fileName, languageVersion) { - var sourceFile = createNode(248, 0); - sourceFile.pos = 0; - sourceFile.end = sourceText.length; - sourceFile.text = sourceText; - sourceFile.bindDiagnostics = []; - sourceFile.languageVersion = languageVersion; - sourceFile.fileName = ts.normalizePath(fileName); - sourceFile.flags = ts.fileExtensionIs(sourceFile.fileName, ".d.ts") ? 8192 : 0; - sourceFile.languageVariant = ts.isTsx(sourceFile.fileName) ? 1 : 0; - return sourceFile; - } - function setContextFlag(val, flag) { - if (val) { - contextFlags |= flag; - } - else { - contextFlags &= ~flag; - } - } - function setDisallowInContext(val) { - setContextFlag(val, 1); - } - function setYieldContext(val) { - setContextFlag(val, 2); - } - function setDecoratorContext(val) { - setContextFlag(val, 4); - } - function setAwaitContext(val) { - setContextFlag(val, 8); - } - function doOutsideOfContext(context, func) { - var contextFlagsToClear = context & contextFlags; - if (contextFlagsToClear) { - setContextFlag(false, contextFlagsToClear); - var result = func(); - setContextFlag(true, contextFlagsToClear); - return result; - } - return func(); - } - function doInsideOfContext(context, func) { - var contextFlagsToSet = context & ~contextFlags; - if (contextFlagsToSet) { - setContextFlag(true, contextFlagsToSet); - var result = func(); - setContextFlag(false, contextFlagsToSet); - return result; - } - return func(); - } - function allowInAnd(func) { - return doOutsideOfContext(1, func); - } - function disallowInAnd(func) { - return doInsideOfContext(1, func); - } - function doInYieldContext(func) { - return doInsideOfContext(2, func); - } - function doOutsideOfYieldContext(func) { - return doOutsideOfContext(2, func); - } - function doInDecoratorContext(func) { - return doInsideOfContext(4, func); - } - function doInAwaitContext(func) { - return doInsideOfContext(8, func); - } - function doOutsideOfAwaitContext(func) { - return doOutsideOfContext(8, func); - } - function doInYieldAndAwaitContext(func) { - return doInsideOfContext(2 | 8, func); - } - function doOutsideOfYieldAndAwaitContext(func) { - return doOutsideOfContext(2 | 8, func); - } - function inContext(flags) { - return (contextFlags & flags) !== 0; - } - function inYieldContext() { - return inContext(2); - } - function inDisallowInContext() { - return inContext(1); - } - function inDecoratorContext() { - return inContext(4); - } - function inAwaitContext() { - return inContext(8); - } - function parseErrorAtCurrentToken(message, arg0) { - var start = scanner.getTokenPos(); - var length = scanner.getTextPos() - start; - parseErrorAtPosition(start, length, message, arg0); - } - function parseErrorAtPosition(start, length, message, arg0) { - var lastError = ts.lastOrUndefined(parseDiagnostics); - if (!lastError || start !== lastError.start) { - parseDiagnostics.push(ts.createFileDiagnostic(sourceFile, start, length, message, arg0)); - } - parseErrorBeforeNextFinishedNode = true; - } - function scanError(message, length) { - var pos = scanner.getTextPos(); - parseErrorAtPosition(pos, length || 0, message); - } - function getNodePos() { - return scanner.getStartPos(); - } - function getNodeEnd() { - return scanner.getStartPos(); - } - function nextToken() { - return token = scanner.scan(); - } - function getTokenPos(pos) { - return ts.skipTrivia(sourceText, pos); - } - function reScanGreaterToken() { - return token = scanner.reScanGreaterToken(); - } - function reScanSlashToken() { - return token = scanner.reScanSlashToken(); - } - function reScanTemplateToken() { - return token = scanner.reScanTemplateToken(); - } - function scanJsxIdentifier() { - return token = scanner.scanJsxIdentifier(); - } - function scanJsxText() { - return token = scanner.scanJsxToken(); - } - function speculationHelper(callback, isLookAhead) { - var saveToken = token; - var saveParseDiagnosticsLength = parseDiagnostics.length; - var saveParseErrorBeforeNextFinishedNode = parseErrorBeforeNextFinishedNode; - var saveContextFlags = contextFlags; - var result = isLookAhead - ? scanner.lookAhead(callback) - : scanner.tryScan(callback); - ts.Debug.assert(saveContextFlags === contextFlags); - if (!result || isLookAhead) { - token = saveToken; - parseDiagnostics.length = saveParseDiagnosticsLength; - parseErrorBeforeNextFinishedNode = saveParseErrorBeforeNextFinishedNode; - } - return result; - } - function lookAhead(callback) { - return speculationHelper(callback, true); - } - function tryParse(callback) { - return speculationHelper(callback, false); - } - function isIdentifier() { - if (token === 69) { - return true; - } - if (token === 114 && inYieldContext()) { - return false; - } - if (token === 119 && inAwaitContext()) { - return false; - } - return token > 105; - } - function parseExpected(kind, diagnosticMessage, shouldAdvance) { - if (shouldAdvance === void 0) { shouldAdvance = true; } - if (token === kind) { - if (shouldAdvance) { - nextToken(); - } - return true; - } - if (diagnosticMessage) { - parseErrorAtCurrentToken(diagnosticMessage); - } - else { - parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(kind)); - } - return false; - } - function parseOptional(t) { - if (token === t) { - nextToken(); - return true; - } - return false; - } - function parseOptionalToken(t) { - if (token === t) { - return parseTokenNode(); - } - return undefined; - } - function parseExpectedToken(t, reportAtCurrentPosition, diagnosticMessage, arg0) { - return parseOptionalToken(t) || - createMissingNode(t, reportAtCurrentPosition, diagnosticMessage, arg0); - } - function parseTokenNode() { - var node = createNode(token); - nextToken(); - return finishNode(node); - } - function canParseSemicolon() { - if (token === 23) { - return true; - } - return token === 16 || token === 1 || scanner.hasPrecedingLineBreak(); - } - function parseSemicolon() { - if (canParseSemicolon()) { - if (token === 23) { - nextToken(); - } - return true; - } - else { - return parseExpected(23); - } - } - function createNode(kind, pos) { - nodeCount++; - if (!(pos >= 0)) { - pos = scanner.getStartPos(); - } - return new (nodeConstructors[kind] || (nodeConstructors[kind] = ts.objectAllocator.getNodeConstructor(kind)))(pos, pos); - } - function finishNode(node, end) { - node.end = end === undefined ? scanner.getStartPos() : end; - if (contextFlags) { - node.parserContextFlags = contextFlags; - } - if (parseErrorBeforeNextFinishedNode) { - parseErrorBeforeNextFinishedNode = false; - node.parserContextFlags |= 16; - } - return node; - } - function createMissingNode(kind, reportAtCurrentPosition, diagnosticMessage, arg0) { - if (reportAtCurrentPosition) { - parseErrorAtPosition(scanner.getStartPos(), 0, diagnosticMessage, arg0); - } - else { - parseErrorAtCurrentToken(diagnosticMessage, arg0); - } - var result = createNode(kind, scanner.getStartPos()); - result.text = ""; - return finishNode(result); - } - function internIdentifier(text) { - text = ts.escapeIdentifier(text); - return ts.hasProperty(identifiers, text) ? identifiers[text] : (identifiers[text] = text); - } - function createIdentifier(isIdentifier, diagnosticMessage) { - identifierCount++; - if (isIdentifier) { - var node = createNode(69); - if (token !== 69) { - node.originalKeywordKind = token; - } - node.text = internIdentifier(scanner.getTokenValue()); - nextToken(); - return finishNode(node); - } - return createMissingNode(69, false, diagnosticMessage || ts.Diagnostics.Identifier_expected); - } - function parseIdentifier(diagnosticMessage) { - return createIdentifier(isIdentifier(), diagnosticMessage); - } - function parseIdentifierName() { - return createIdentifier(ts.tokenIsIdentifierOrKeyword(token)); - } - function isLiteralPropertyName() { - return ts.tokenIsIdentifierOrKeyword(token) || - token === 9 || - token === 8; - } - function parsePropertyNameWorker(allowComputedPropertyNames) { - if (token === 9 || token === 8) { - return parseLiteralNode(true); - } - if (allowComputedPropertyNames && token === 19) { - return parseComputedPropertyName(); - } - return parseIdentifierName(); - } - function parsePropertyName() { - return parsePropertyNameWorker(true); - } - function parseSimplePropertyName() { - return parsePropertyNameWorker(false); - } - function isSimplePropertyName() { - return token === 9 || token === 8 || ts.tokenIsIdentifierOrKeyword(token); - } - function parseComputedPropertyName() { - var node = createNode(136); - parseExpected(19); - node.expression = allowInAnd(parseExpression); - parseExpected(20); - return finishNode(node); - } - function parseContextualModifier(t) { - return token === t && tryParse(nextTokenCanFollowModifier); - } - function nextTokenCanFollowModifier() { - if (token === 74) { - return nextToken() === 81; - } - if (token === 82) { - nextToken(); - if (token === 77) { - return lookAhead(nextTokenIsClassOrFunction); - } - return token !== 37 && token !== 15 && canFollowModifier(); - } - if (token === 77) { - return nextTokenIsClassOrFunction(); - } - if (token === 113) { - nextToken(); - return canFollowModifier(); - } - nextToken(); - if (scanner.hasPrecedingLineBreak()) { - return false; - } - return canFollowModifier(); - } - function parseAnyContextualModifier() { - return ts.isModifier(token) && tryParse(nextTokenCanFollowModifier); - } - function canFollowModifier() { - return token === 19 - || token === 15 - || token === 37 - || isLiteralPropertyName(); - } - function nextTokenIsClassOrFunction() { - nextToken(); - return token === 73 || token === 87; - } - function isListElement(parsingContext, inErrorRecovery) { - var node = currentNode(parsingContext); - if (node) { - return true; - } - switch (parsingContext) { - case 0: - case 1: - case 3: - return !(token === 23 && inErrorRecovery) && isStartOfStatement(); - case 2: - return token === 71 || token === 77; - case 4: - return isStartOfTypeMember(); - case 5: - return lookAhead(isClassMemberStart) || (token === 23 && !inErrorRecovery); - case 6: - return token === 19 || isLiteralPropertyName(); - case 12: - return token === 19 || token === 37 || isLiteralPropertyName(); - case 9: - return isLiteralPropertyName(); - case 7: - if (token === 15) { - return lookAhead(isValidHeritageClauseObjectLiteral); - } - if (!inErrorRecovery) { - return isStartOfLeftHandSideExpression() && !isHeritageClauseExtendsOrImplementsKeyword(); - } - else { - return isIdentifier() && !isHeritageClauseExtendsOrImplementsKeyword(); - } - case 8: - return isIdentifierOrPattern(); - case 10: - return token === 24 || token === 22 || isIdentifierOrPattern(); - case 17: - return isIdentifier(); - case 11: - case 15: - return token === 24 || token === 22 || isStartOfExpression(); - case 16: - return isStartOfParameter(); - case 18: - case 19: - return token === 24 || isStartOfType(); - case 20: - return isHeritageClause(); - case 21: - return ts.tokenIsIdentifierOrKeyword(token); - case 13: - return ts.tokenIsIdentifierOrKeyword(token) || token === 15; - case 14: - return true; - case 22: - case 23: - case 25: - return JSDocParser.isJSDocType(); - case 24: - return isSimplePropertyName(); - } - ts.Debug.fail("Non-exhaustive case in 'isListElement'."); - } - function isValidHeritageClauseObjectLiteral() { - ts.Debug.assert(token === 15); - if (nextToken() === 16) { - var next = nextToken(); - return next === 24 || next === 15 || next === 83 || next === 106; - } - return true; - } - function nextTokenIsIdentifier() { - nextToken(); - return isIdentifier(); - } - function nextTokenIsIdentifierOrKeyword() { - nextToken(); - return ts.tokenIsIdentifierOrKeyword(token); - } - function isHeritageClauseExtendsOrImplementsKeyword() { - if (token === 106 || - token === 83) { - return lookAhead(nextTokenIsStartOfExpression); - } - return false; - } - function nextTokenIsStartOfExpression() { - nextToken(); - return isStartOfExpression(); - } - function isListTerminator(kind) { - if (token === 1) { - return true; - } - switch (kind) { - case 1: - case 2: - case 4: - case 5: - case 6: - case 12: - case 9: - case 21: - return token === 16; - case 3: - return token === 16 || token === 71 || token === 77; - case 7: - return token === 15 || token === 83 || token === 106; - case 8: - return isVariableDeclaratorListTerminator(); - case 17: - return token === 27 || token === 17 || token === 15 || token === 83 || token === 106; - case 11: - return token === 18 || token === 23; - case 15: - case 19: - case 10: - return token === 20; - case 16: - return token === 18 || token === 20; - case 18: - return token === 27 || token === 17; - case 20: - return token === 15 || token === 16; - case 13: - return token === 27 || token === 39; - case 14: - return token === 25 && lookAhead(nextTokenIsSlash); - case 22: - return token === 18 || token === 54 || token === 16; - case 23: - return token === 27 || token === 16; - case 25: - return token === 20 || token === 16; - case 24: - return token === 16; - } - } - function isVariableDeclaratorListTerminator() { - if (canParseSemicolon()) { - return true; - } - if (isInOrOfKeyword(token)) { - return true; - } - if (token === 34) { - return true; - } - return false; - } - function isInSomeParsingContext() { - for (var kind = 0; kind < 26; kind++) { - if (parsingContext & (1 << kind)) { - if (isListElement(kind, true) || isListTerminator(kind)) { - return true; - } - } - } - return false; - } - function parseList(kind, parseElement) { - var saveParsingContext = parsingContext; - parsingContext |= 1 << kind; - var result = []; - result.pos = getNodePos(); - while (!isListTerminator(kind)) { - if (isListElement(kind, false)) { - var element = parseListElement(kind, parseElement); - result.push(element); - continue; - } - if (abortParsingListOrMoveToNextToken(kind)) { - break; - } - } - result.end = getNodeEnd(); - parsingContext = saveParsingContext; - return result; - } - function parseListElement(parsingContext, parseElement) { - var node = currentNode(parsingContext); - if (node) { - return consumeNode(node); - } - return parseElement(); - } - function currentNode(parsingContext) { - if (parseErrorBeforeNextFinishedNode) { - return undefined; - } - if (!syntaxCursor) { - return undefined; - } - var node = syntaxCursor.currentNode(scanner.getStartPos()); - if (ts.nodeIsMissing(node)) { - return undefined; - } - if (node.intersectsChange) { - return undefined; - } - if (ts.containsParseError(node)) { - return undefined; - } - var nodeContextFlags = node.parserContextFlags & 31; - if (nodeContextFlags !== contextFlags) { - return undefined; - } - if (!canReuseNode(node, parsingContext)) { - return undefined; - } - return node; - } - function consumeNode(node) { - scanner.setTextPos(node.end); - nextToken(); - return node; - } - function canReuseNode(node, parsingContext) { - switch (parsingContext) { - case 5: - return isReusableClassMember(node); - case 2: - return isReusableSwitchClause(node); - case 0: - case 1: - case 3: - return isReusableStatement(node); - case 6: - return isReusableEnumMember(node); - case 4: - return isReusableTypeMember(node); - case 8: - return isReusableVariableDeclaration(node); - case 16: - return isReusableParameter(node); - case 20: - case 17: - case 19: - case 18: - case 11: - case 12: - case 7: - case 13: - case 14: - } - return false; - } - function isReusableClassMember(node) { - if (node) { - switch (node.kind) { - case 144: - case 149: - case 145: - case 146: - case 141: - case 191: - return true; - case 143: - var methodDeclaration = node; - var nameIsConstructor = methodDeclaration.name.kind === 69 && - methodDeclaration.name.originalKeywordKind === 121; - return !nameIsConstructor; - } - } - return false; - } - function isReusableSwitchClause(node) { - if (node) { - switch (node.kind) { - case 241: - case 242: - return true; - } - } - return false; - } - function isReusableStatement(node) { - if (node) { - switch (node.kind) { - case 213: - case 193: - case 192: - case 196: - case 195: - case 208: - case 204: - case 206: - case 203: - case 202: - case 200: - case 201: - case 199: - case 198: - case 205: - case 194: - case 209: - case 207: - case 197: - case 210: - case 222: - case 221: - case 228: - case 227: - case 218: - case 214: - case 215: - case 217: - case 216: - return true; - } - } - return false; - } - function isReusableEnumMember(node) { - return node.kind === 247; - } - function isReusableTypeMember(node) { - if (node) { - switch (node.kind) { - case 148: - case 142: - case 149: - case 140: - case 147: - return true; - } - } - return false; - } - function isReusableVariableDeclaration(node) { - if (node.kind !== 211) { - return false; - } - var variableDeclarator = node; - return variableDeclarator.initializer === undefined; - } - function isReusableParameter(node) { - if (node.kind !== 138) { - return false; - } - var parameter = node; - return parameter.initializer === undefined; - } - function abortParsingListOrMoveToNextToken(kind) { - parseErrorAtCurrentToken(parsingContextErrors(kind)); - if (isInSomeParsingContext()) { - return true; - } - nextToken(); - return false; - } - function parsingContextErrors(context) { - switch (context) { - case 0: return ts.Diagnostics.Declaration_or_statement_expected; - case 1: return ts.Diagnostics.Declaration_or_statement_expected; - case 2: return ts.Diagnostics.case_or_default_expected; - case 3: return ts.Diagnostics.Statement_expected; - case 4: return ts.Diagnostics.Property_or_signature_expected; - case 5: return ts.Diagnostics.Unexpected_token_A_constructor_method_accessor_or_property_was_expected; - case 6: return ts.Diagnostics.Enum_member_expected; - case 7: return ts.Diagnostics.Expression_expected; - case 8: return ts.Diagnostics.Variable_declaration_expected; - case 9: return ts.Diagnostics.Property_destructuring_pattern_expected; - case 10: return ts.Diagnostics.Array_element_destructuring_pattern_expected; - case 11: return ts.Diagnostics.Argument_expression_expected; - case 12: return ts.Diagnostics.Property_assignment_expected; - case 15: return ts.Diagnostics.Expression_or_comma_expected; - case 16: return ts.Diagnostics.Parameter_declaration_expected; - case 17: return ts.Diagnostics.Type_parameter_declaration_expected; - case 18: return ts.Diagnostics.Type_argument_expected; - case 19: return ts.Diagnostics.Type_expected; - case 20: return ts.Diagnostics.Unexpected_token_expected; - case 21: return ts.Diagnostics.Identifier_expected; - case 13: return ts.Diagnostics.Identifier_expected; - case 14: return ts.Diagnostics.Identifier_expected; - case 22: return ts.Diagnostics.Parameter_declaration_expected; - case 23: return ts.Diagnostics.Type_argument_expected; - case 25: return ts.Diagnostics.Type_expected; - case 24: return ts.Diagnostics.Property_assignment_expected; - } - } - ; - function parseDelimitedList(kind, parseElement, considerSemicolonAsDelimeter) { - var saveParsingContext = parsingContext; - parsingContext |= 1 << kind; - var result = []; - result.pos = getNodePos(); - var commaStart = -1; - while (true) { - if (isListElement(kind, false)) { - result.push(parseListElement(kind, parseElement)); - commaStart = scanner.getTokenPos(); - if (parseOptional(24)) { - continue; - } - commaStart = -1; - if (isListTerminator(kind)) { - break; - } - parseExpected(24); - if (considerSemicolonAsDelimeter && token === 23 && !scanner.hasPrecedingLineBreak()) { - nextToken(); - } - continue; - } - if (isListTerminator(kind)) { - break; - } - if (abortParsingListOrMoveToNextToken(kind)) { - break; - } - } - if (commaStart >= 0) { - result.hasTrailingComma = true; - } - result.end = getNodeEnd(); - parsingContext = saveParsingContext; - return result; - } - function createMissingList() { - var pos = getNodePos(); - var result = []; - result.pos = pos; - result.end = pos; - return result; - } - function parseBracketedList(kind, parseElement, open, close) { - if (parseExpected(open)) { - var result = parseDelimitedList(kind, parseElement); - parseExpected(close); - return result; - } - return createMissingList(); - } - function parseEntityName(allowReservedWords, diagnosticMessage) { - var entity = parseIdentifier(diagnosticMessage); - while (parseOptional(21)) { - var node = createNode(135, entity.pos); - node.left = entity; - node.right = parseRightSideOfDot(allowReservedWords); - entity = finishNode(node); - } - return entity; - } - function parseRightSideOfDot(allowIdentifierNames) { - if (scanner.hasPrecedingLineBreak() && ts.tokenIsIdentifierOrKeyword(token)) { - var matchesPattern = lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine); - if (matchesPattern) { - return createMissingNode(69, true, ts.Diagnostics.Identifier_expected); - } - } - return allowIdentifierNames ? parseIdentifierName() : parseIdentifier(); - } - function parseTemplateExpression() { - var template = createNode(183); - template.head = parseLiteralNode(); - ts.Debug.assert(template.head.kind === 12, "Template head has wrong token kind"); - var templateSpans = []; - templateSpans.pos = getNodePos(); - do { - templateSpans.push(parseTemplateSpan()); - } while (ts.lastOrUndefined(templateSpans).literal.kind === 13); - templateSpans.end = getNodeEnd(); - template.templateSpans = templateSpans; - return finishNode(template); - } - function parseTemplateSpan() { - var span = createNode(190); - span.expression = allowInAnd(parseExpression); - var literal; - if (token === 16) { - reScanTemplateToken(); - literal = parseLiteralNode(); - } - else { - literal = parseExpectedToken(14, false, ts.Diagnostics._0_expected, ts.tokenToString(16)); - } - span.literal = literal; - return finishNode(span); - } - function parseLiteralNode(internName) { - var node = createNode(token); - var text = scanner.getTokenValue(); - node.text = internName ? internIdentifier(text) : text; - if (scanner.hasExtendedUnicodeEscape()) { - node.hasExtendedUnicodeEscape = true; - } - if (scanner.isUnterminated()) { - node.isUnterminated = true; - } - var tokenPos = scanner.getTokenPos(); - nextToken(); - finishNode(node); - if (node.kind === 8 - && sourceText.charCodeAt(tokenPos) === 48 - && ts.isOctalDigit(sourceText.charCodeAt(tokenPos + 1))) { - node.flags |= 65536; - } - return node; - } - function parseTypeReferenceOrTypePredicate() { - var typeName = parseEntityName(false, ts.Diagnostics.Type_expected); - if (typeName.kind === 69 && token === 124 && !scanner.hasPrecedingLineBreak()) { - nextToken(); - var node_1 = createNode(150, typeName.pos); - node_1.parameterName = typeName; - node_1.type = parseType(); - return finishNode(node_1); - } - var node = createNode(151, typeName.pos); - node.typeName = typeName; - if (!scanner.hasPrecedingLineBreak() && token === 25) { - node.typeArguments = parseBracketedList(18, parseType, 25, 27); - } - return finishNode(node); - } - function parseTypeQuery() { - var node = createNode(154); - parseExpected(101); - node.exprName = parseEntityName(true); - return finishNode(node); - } - function parseTypeParameter() { - var node = createNode(137); - node.name = parseIdentifier(); - if (parseOptional(83)) { - if (isStartOfType() || !isStartOfExpression()) { - node.constraint = parseType(); - } - else { - node.expression = parseUnaryExpressionOrHigher(); - } - } - return finishNode(node); - } - function parseTypeParameters() { - if (token === 25) { - return parseBracketedList(17, parseTypeParameter, 25, 27); - } - } - function parseParameterType() { - if (parseOptional(54)) { - return token === 9 - ? parseLiteralNode(true) - : parseType(); - } - return undefined; - } - function isStartOfParameter() { - return token === 22 || isIdentifierOrPattern() || ts.isModifier(token) || token === 55; - } - function setModifiers(node, modifiers) { - if (modifiers) { - node.flags |= modifiers.flags; - node.modifiers = modifiers; - } - } - function parseParameter() { - var node = createNode(138); - node.decorators = parseDecorators(); - setModifiers(node, parseModifiers()); - node.dotDotDotToken = parseOptionalToken(22); - node.name = parseIdentifierOrPattern(); - if (ts.getFullWidth(node.name) === 0 && node.flags === 0 && ts.isModifier(token)) { - nextToken(); - } - node.questionToken = parseOptionalToken(53); - node.type = parseParameterType(); - node.initializer = parseBindingElementInitializer(true); - return finishNode(node); - } - function parseBindingElementInitializer(inParameter) { - return inParameter ? parseParameterInitializer() : parseNonParameterInitializer(); - } - function parseParameterInitializer() { - return parseInitializer(true); - } - function fillSignature(returnToken, yieldContext, awaitContext, requireCompleteParameterList, signature) { - var returnTokenRequired = returnToken === 34; - signature.typeParameters = parseTypeParameters(); - signature.parameters = parseParameterList(yieldContext, awaitContext, requireCompleteParameterList); - if (returnTokenRequired) { - parseExpected(returnToken); - signature.type = parseType(); - } - else if (parseOptional(returnToken)) { - signature.type = parseType(); - } - } - function parseParameterList(yieldContext, awaitContext, requireCompleteParameterList) { - if (parseExpected(17)) { - var savedYieldContext = inYieldContext(); - var savedAwaitContext = inAwaitContext(); - setYieldContext(yieldContext); - setAwaitContext(awaitContext); - var result = parseDelimitedList(16, parseParameter); - setYieldContext(savedYieldContext); - setAwaitContext(savedAwaitContext); - if (!parseExpected(18) && requireCompleteParameterList) { - return undefined; - } - return result; - } - return requireCompleteParameterList ? undefined : createMissingList(); - } - function parseTypeMemberSemicolon() { - if (parseOptional(24)) { - return; - } - parseSemicolon(); - } - function parseSignatureMember(kind) { - var node = createNode(kind); - if (kind === 148) { - parseExpected(92); - } - fillSignature(54, false, false, false, node); - parseTypeMemberSemicolon(); - return finishNode(node); - } - function isIndexSignature() { - if (token !== 19) { - return false; - } - return lookAhead(isUnambiguouslyIndexSignature); - } - function isUnambiguouslyIndexSignature() { - nextToken(); - if (token === 22 || token === 20) { - return true; - } - if (ts.isModifier(token)) { - nextToken(); - if (isIdentifier()) { - return true; - } - } - else if (!isIdentifier()) { - return false; - } - else { - nextToken(); - } - if (token === 54 || token === 24) { - return true; - } - if (token !== 53) { - return false; - } - nextToken(); - return token === 54 || token === 24 || token === 20; - } - function parseIndexSignatureDeclaration(fullStart, decorators, modifiers) { - var node = createNode(149, fullStart); - node.decorators = decorators; - setModifiers(node, modifiers); - node.parameters = parseBracketedList(16, parseParameter, 19, 20); - node.type = parseTypeAnnotation(); - parseTypeMemberSemicolon(); - return finishNode(node); - } - function parsePropertyOrMethodSignature() { - var fullStart = scanner.getStartPos(); - var name = parsePropertyName(); - var questionToken = parseOptionalToken(53); - if (token === 17 || token === 25) { - var method = createNode(142, fullStart); - method.name = name; - method.questionToken = questionToken; - fillSignature(54, false, false, false, method); - parseTypeMemberSemicolon(); - return finishNode(method); - } - else { - var property = createNode(140, fullStart); - property.name = name; - property.questionToken = questionToken; - property.type = parseTypeAnnotation(); - parseTypeMemberSemicolon(); - return finishNode(property); - } - } - function isStartOfTypeMember() { - switch (token) { - case 17: - case 25: - case 19: - return true; - default: - if (ts.isModifier(token)) { - var result = lookAhead(isStartOfIndexSignatureDeclaration); - if (result) { - return result; - } - } - return isLiteralPropertyName() && lookAhead(isTypeMemberWithLiteralPropertyName); - } - } - function isStartOfIndexSignatureDeclaration() { - while (ts.isModifier(token)) { - nextToken(); - } - return isIndexSignature(); - } - function isTypeMemberWithLiteralPropertyName() { - nextToken(); - return token === 17 || - token === 25 || - token === 53 || - token === 54 || - canParseSemicolon(); - } - function parseTypeMember() { - switch (token) { - case 17: - case 25: - return parseSignatureMember(147); - case 19: - return isIndexSignature() - ? parseIndexSignatureDeclaration(scanner.getStartPos(), undefined, undefined) - : parsePropertyOrMethodSignature(); - case 92: - if (lookAhead(isStartOfConstructSignature)) { - return parseSignatureMember(148); - } - case 9: - case 8: - return parsePropertyOrMethodSignature(); - default: - if (ts.isModifier(token)) { - var result = tryParse(parseIndexSignatureWithModifiers); - if (result) { - return result; - } - } - if (ts.tokenIsIdentifierOrKeyword(token)) { - return parsePropertyOrMethodSignature(); - } - } - } - function parseIndexSignatureWithModifiers() { - var fullStart = scanner.getStartPos(); - var decorators = parseDecorators(); - var modifiers = parseModifiers(); - return isIndexSignature() - ? parseIndexSignatureDeclaration(fullStart, decorators, modifiers) - : undefined; - } - function isStartOfConstructSignature() { - nextToken(); - return token === 17 || token === 25; - } - function parseTypeLiteral() { - var node = createNode(155); - node.members = parseObjectTypeMembers(); - return finishNode(node); - } - function parseObjectTypeMembers() { - var members; - if (parseExpected(15)) { - members = parseList(4, parseTypeMember); - parseExpected(16); - } - else { - members = createMissingList(); - } - return members; - } - function parseTupleType() { - var node = createNode(157); - node.elementTypes = parseBracketedList(19, parseType, 19, 20); - return finishNode(node); - } - function parseParenthesizedType() { - var node = createNode(160); - parseExpected(17); - node.type = parseType(); - parseExpected(18); - return finishNode(node); - } - function parseFunctionOrConstructorType(kind) { - var node = createNode(kind); - if (kind === 153) { - parseExpected(92); - } - fillSignature(34, false, false, false, node); - return finishNode(node); - } - function parseKeywordAndNoDot() { - var node = parseTokenNode(); - return token === 21 ? undefined : node; - } - function parseNonArrayType() { - switch (token) { - case 117: - case 130: - case 128: - case 120: - case 131: - var node = tryParse(parseKeywordAndNoDot); - return node || parseTypeReferenceOrTypePredicate(); - case 103: - case 97: - return parseTokenNode(); - case 101: - return parseTypeQuery(); - case 15: - return parseTypeLiteral(); - case 19: - return parseTupleType(); - case 17: - return parseParenthesizedType(); - default: - return parseTypeReferenceOrTypePredicate(); - } - } - function isStartOfType() { - switch (token) { - case 117: - case 130: - case 128: - case 120: - case 131: - case 103: - case 97: - case 101: - case 15: - case 19: - case 25: - case 92: - return true; - case 17: - return lookAhead(isStartOfParenthesizedOrFunctionType); - default: - return isIdentifier(); - } - } - function isStartOfParenthesizedOrFunctionType() { - nextToken(); - return token === 18 || isStartOfParameter() || isStartOfType(); - } - function parseArrayTypeOrHigher() { - var type = parseNonArrayType(); - while (!scanner.hasPrecedingLineBreak() && parseOptional(19)) { - parseExpected(20); - var node = createNode(156, type.pos); - node.elementType = type; - type = finishNode(node); - } - return type; - } - function parseUnionOrIntersectionType(kind, parseConstituentType, operator) { - var type = parseConstituentType(); - if (token === operator) { - var types = [type]; - types.pos = type.pos; - while (parseOptional(operator)) { - types.push(parseConstituentType()); - } - types.end = getNodeEnd(); - var node = createNode(kind, type.pos); - node.types = types; - type = finishNode(node); - } - return type; - } - function parseIntersectionTypeOrHigher() { - return parseUnionOrIntersectionType(159, parseArrayTypeOrHigher, 46); - } - function parseUnionTypeOrHigher() { - return parseUnionOrIntersectionType(158, parseIntersectionTypeOrHigher, 47); - } - function isStartOfFunctionType() { - if (token === 25) { - return true; - } - return token === 17 && lookAhead(isUnambiguouslyStartOfFunctionType); - } - function isUnambiguouslyStartOfFunctionType() { - nextToken(); - if (token === 18 || token === 22) { - return true; - } - if (isIdentifier() || ts.isModifier(token)) { - nextToken(); - if (token === 54 || token === 24 || - token === 53 || token === 56 || - isIdentifier() || ts.isModifier(token)) { - return true; - } - if (token === 18) { - nextToken(); - if (token === 34) { - return true; - } - } - } - return false; - } - function parseType() { - return doOutsideOfContext(10, parseTypeWorker); - } - function parseTypeWorker() { - if (isStartOfFunctionType()) { - return parseFunctionOrConstructorType(152); - } - if (token === 92) { - return parseFunctionOrConstructorType(153); - } - return parseUnionTypeOrHigher(); - } - function parseTypeAnnotation() { - return parseOptional(54) ? parseType() : undefined; - } - function isStartOfLeftHandSideExpression() { - switch (token) { - case 97: - case 95: - case 93: - case 99: - case 84: - 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: - return true; - default: - return isIdentifier(); - } - } - function isStartOfExpression() { - if (isStartOfLeftHandSideExpression()) { - return true; - } - switch (token) { - case 35: - case 36: - case 50: - case 49: - case 78: - case 101: - case 103: - case 41: - case 42: - case 25: - case 119: - case 114: - return true; - default: - if (isBinaryOperator()) { - return true; - } - return isIdentifier(); - } - } - function isStartOfExpressionStatement() { - return token !== 15 && - token !== 87 && - token !== 73 && - token !== 55 && - isStartOfExpression(); - } - function allowInAndParseExpression() { - return allowInAnd(parseExpression); - } - function parseExpression() { - var saveDecoratorContext = inDecoratorContext(); - if (saveDecoratorContext) { - setDecoratorContext(false); - } - var expr = parseAssignmentExpressionOrHigher(); - var operatorToken; - while ((operatorToken = parseOptionalToken(24))) { - expr = makeBinaryExpression(expr, operatorToken, parseAssignmentExpressionOrHigher()); - } - if (saveDecoratorContext) { - setDecoratorContext(true); - } - return expr; - } - function parseInitializer(inParameter) { - if (token !== 56) { - if (scanner.hasPrecedingLineBreak() || (inParameter && token === 15) || !isStartOfExpression()) { - return undefined; - } - } - parseExpected(56); - return parseAssignmentExpressionOrHigher(); - } - function parseAssignmentExpressionOrHigher() { - if (isYieldExpression()) { - return parseYieldExpression(); - } - var arrowExpression = tryParseParenthesizedArrowFunctionExpression(); - if (arrowExpression) { - return arrowExpression; - } - var expr = parseBinaryExpressionOrHigher(0); - if (expr.kind === 69 && token === 34) { - return parseSimpleArrowFunctionExpression(expr); - } - if (ts.isLeftHandSideExpression(expr) && ts.isAssignmentOperator(reScanGreaterToken())) { - return makeBinaryExpression(expr, parseTokenNode(), parseAssignmentExpressionOrHigher()); - } - return parseConditionalExpressionRest(expr); - } - function isYieldExpression() { - if (token === 114) { - if (inYieldContext()) { - return true; - } - return lookAhead(nextTokenIsIdentifierOrKeywordOrNumberOnSameLine); - } - return false; - } - function nextTokenIsIdentifierOnSameLine() { - nextToken(); - return !scanner.hasPrecedingLineBreak() && isIdentifier(); - } - function parseYieldExpression() { - var node = createNode(184); - nextToken(); - if (!scanner.hasPrecedingLineBreak() && - (token === 37 || isStartOfExpression())) { - node.asteriskToken = parseOptionalToken(37); - node.expression = parseAssignmentExpressionOrHigher(); - return finishNode(node); - } - else { - return finishNode(node); - } - } - function parseSimpleArrowFunctionExpression(identifier) { - ts.Debug.assert(token === 34, "parseSimpleArrowFunctionExpression should only have been called if we had a =>"); - var node = createNode(174, identifier.pos); - var parameter = createNode(138, identifier.pos); - parameter.name = identifier; - finishNode(parameter); - node.parameters = [parameter]; - node.parameters.pos = parameter.pos; - node.parameters.end = parameter.end; - node.equalsGreaterThanToken = parseExpectedToken(34, false, ts.Diagnostics._0_expected, "=>"); - node.body = parseArrowFunctionExpressionBody(false); - return finishNode(node); - } - function tryParseParenthesizedArrowFunctionExpression() { - var triState = isParenthesizedArrowFunctionExpression(); - if (triState === 0) { - return undefined; - } - var arrowFunction = triState === 1 - ? parseParenthesizedArrowFunctionExpressionHead(true) - : tryParse(parsePossibleParenthesizedArrowFunctionExpressionHead); - if (!arrowFunction) { - return undefined; - } - var isAsync = !!(arrowFunction.flags & 512); - var lastToken = token; - arrowFunction.equalsGreaterThanToken = parseExpectedToken(34, false, ts.Diagnostics._0_expected, "=>"); - arrowFunction.body = (lastToken === 34 || lastToken === 15) - ? parseArrowFunctionExpressionBody(isAsync) - : parseIdentifier(); - return finishNode(arrowFunction); - } - function isParenthesizedArrowFunctionExpression() { - if (token === 17 || token === 25 || token === 118) { - return lookAhead(isParenthesizedArrowFunctionExpressionWorker); - } - if (token === 34) { - return 1; - } - return 0; - } - function isParenthesizedArrowFunctionExpressionWorker() { - if (token === 118) { - nextToken(); - if (scanner.hasPrecedingLineBreak()) { - return 0; - } - if (token !== 17 && token !== 25) { - return 0; - } - } - var first = token; - var second = nextToken(); - if (first === 17) { - if (second === 18) { - var third = nextToken(); - switch (third) { - case 34: - case 54: - case 15: - return 1; - default: - return 0; - } - } - if (second === 19 || second === 15) { - return 2; - } - if (second === 22) { - return 1; - } - if (!isIdentifier()) { - return 0; - } - if (nextToken() === 54) { - return 1; - } - return 2; - } - else { - ts.Debug.assert(first === 25); - if (!isIdentifier()) { - return 0; - } - if (sourceFile.languageVariant === 1) { - var isArrowFunctionInJsx = lookAhead(function () { - var third = nextToken(); - if (third === 83) { - var fourth = nextToken(); - switch (fourth) { - case 56: - case 27: - return false; - default: - return true; - } - } - else if (third === 24) { - return true; - } - return false; - }); - if (isArrowFunctionInJsx) { - return 1; - } - return 0; - } - return 2; - } - } - function parsePossibleParenthesizedArrowFunctionExpressionHead() { - return parseParenthesizedArrowFunctionExpressionHead(false); - } - function parseParenthesizedArrowFunctionExpressionHead(allowAmbiguity) { - var node = createNode(174); - setModifiers(node, parseModifiersForArrowFunction()); - var isAsync = !!(node.flags & 512); - fillSignature(54, false, isAsync, !allowAmbiguity, node); - if (!node.parameters) { - return undefined; - } - if (!allowAmbiguity && token !== 34 && token !== 15) { - return undefined; - } - return node; - } - function parseArrowFunctionExpressionBody(isAsync) { - if (token === 15) { - return parseFunctionBlock(false, isAsync, false); - } - if (token !== 23 && - token !== 87 && - token !== 73 && - isStartOfStatement() && - !isStartOfExpressionStatement()) { - return parseFunctionBlock(false, isAsync, true); - } - return isAsync - ? doInAwaitContext(parseAssignmentExpressionOrHigher) - : doOutsideOfAwaitContext(parseAssignmentExpressionOrHigher); - } - function parseConditionalExpressionRest(leftOperand) { - var questionToken = parseOptionalToken(53); - if (!questionToken) { - return leftOperand; - } - var node = createNode(182, 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.whenFalse = parseAssignmentExpressionOrHigher(); - return finishNode(node); - } - function parseBinaryExpressionOrHigher(precedence) { - var leftOperand = parseUnaryExpressionOrHigher(); - return parseBinaryExpressionRest(precedence, leftOperand); - } - function isInOrOfKeyword(t) { - return t === 90 || t === 134; - } - function parseBinaryExpressionRest(precedence, leftOperand) { - while (true) { - reScanGreaterToken(); - var newPrecedence = getBinaryOperatorPrecedence(); - var consumeCurrentOperator = token === 38 ? - newPrecedence >= precedence : - newPrecedence > precedence; - if (!consumeCurrentOperator) { - break; - } - if (token === 90 && inDisallowInContext()) { - break; - } - if (token === 116) { - if (scanner.hasPrecedingLineBreak()) { - break; - } - else { - nextToken(); - leftOperand = makeAsExpression(leftOperand, parseType()); - } - } - else { - leftOperand = makeBinaryExpression(leftOperand, parseTokenNode(), parseBinaryExpressionOrHigher(newPrecedence)); - } - } - return leftOperand; - } - function isBinaryOperator() { - if (inDisallowInContext() && token === 90) { - return false; - } - return getBinaryOperatorPrecedence() > 0; - } - function getBinaryOperatorPrecedence() { - switch (token) { - case 52: - return 1; - case 51: - return 2; - case 47: - return 3; - case 48: - return 4; - case 46: - return 5; - case 30: - case 31: - case 32: - case 33: - return 6; - case 25: - case 27: - case 28: - case 29: - case 91: - case 90: - case 116: - return 7; - case 43: - case 44: - case 45: - return 8; - case 35: - case 36: - return 9; - case 37: - case 39: - case 40: - return 10; - case 38: - return 11; - } - return -1; - } - function makeBinaryExpression(left, operatorToken, right) { - var node = createNode(181, left.pos); - node.left = left; - node.operatorToken = operatorToken; - node.right = right; - return finishNode(node); - } - function makeAsExpression(left, right) { - var node = createNode(189, left.pos); - node.expression = left; - node.type = right; - return finishNode(node); - } - function parsePrefixUnaryExpression() { - var node = createNode(179); - node.operator = token; - nextToken(); - node.operand = parseSimpleUnaryExpression(); - return finishNode(node); - } - function parseDeleteExpression() { - var node = createNode(175); - nextToken(); - node.expression = parseSimpleUnaryExpression(); - return finishNode(node); - } - function parseTypeOfExpression() { - var node = createNode(176); - nextToken(); - node.expression = parseSimpleUnaryExpression(); - return finishNode(node); - } - function parseVoidExpression() { - var node = createNode(177); - nextToken(); - node.expression = parseSimpleUnaryExpression(); - return finishNode(node); - } - function isAwaitExpression() { - if (token === 119) { - if (inAwaitContext()) { - return true; - } - return lookAhead(nextTokenIsIdentifierOnSameLine); - } - return false; - } - function parseAwaitExpression() { - var node = createNode(178); - nextToken(); - node.expression = parseSimpleUnaryExpression(); - return finishNode(node); - } - function parseUnaryExpressionOrHigher() { - if (isAwaitExpression()) { - return parseAwaitExpression(); - } - if (isIncrementExpression()) { - var incrementExpression = parseIncrementExpression(); - return token === 38 ? - parseBinaryExpressionRest(getBinaryOperatorPrecedence(), incrementExpression) : - incrementExpression; - } - var unaryOperator = token; - var simpleUnaryExpression = parseSimpleUnaryExpression(); - if (token === 38) { - var diagnostic; - var start = ts.skipTrivia(sourceText, simpleUnaryExpression.pos); - if (simpleUnaryExpression.kind === 171) { - parseErrorAtPosition(start, simpleUnaryExpression.end - start, ts.Diagnostics.A_type_assertion_expression_is_not_allowed_in_the_left_hand_side_of_an_exponentiation_expression_Consider_enclosing_the_expression_in_parentheses); - } - else { - parseErrorAtPosition(start, simpleUnaryExpression.end - start, ts.Diagnostics.An_unary_expression_with_the_0_operator_is_not_allowed_in_the_left_hand_side_of_an_exponentiation_expression_Consider_enclosing_the_expression_in_parentheses, ts.tokenToString(unaryOperator)); - } - } - return simpleUnaryExpression; - } - function parseSimpleUnaryExpression() { - switch (token) { - case 35: - case 36: - case 50: - case 49: - return parsePrefixUnaryExpression(); - case 78: - return parseDeleteExpression(); - case 101: - return parseTypeOfExpression(); - case 103: - return parseVoidExpression(); - case 25: - return parseTypeAssertion(); - default: - return parseIncrementExpression(); - } - } - function isIncrementExpression() { - switch (token) { - case 35: - case 36: - case 50: - case 49: - case 78: - case 101: - case 103: - return false; - case 25: - if (sourceFile.languageVariant !== 1) { - return false; - } - default: - return true; - } - } - function parseIncrementExpression() { - if (token === 41 || token === 42) { - var node = createNode(179); - node.operator = token; - nextToken(); - node.operand = parseLeftHandSideExpressionOrHigher(); - return finishNode(node); - } - else if (sourceFile.languageVariant === 1 && token === 25 && lookAhead(nextTokenIsIdentifierOrKeyword)) { - return parseJsxElementOrSelfClosingElement(true); - } - var expression = parseLeftHandSideExpressionOrHigher(); - ts.Debug.assert(ts.isLeftHandSideExpression(expression)); - if ((token === 41 || token === 42) && !scanner.hasPrecedingLineBreak()) { - var node = createNode(180, expression.pos); - node.operand = expression; - node.operator = token; - nextToken(); - return finishNode(node); - } - return expression; - } - function parseLeftHandSideExpressionOrHigher() { - var expression = token === 95 - ? parseSuperExpression() - : parseMemberExpressionOrHigher(); - return parseCallExpressionRest(expression); - } - function parseMemberExpressionOrHigher() { - var expression = parsePrimaryExpression(); - return parseMemberExpressionRest(expression); - } - function parseSuperExpression() { - var expression = parseTokenNode(); - if (token === 17 || token === 21 || token === 19) { - return expression; - } - var node = createNode(166, expression.pos); - node.expression = expression; - node.dotToken = parseExpectedToken(21, false, ts.Diagnostics.super_must_be_followed_by_an_argument_list_or_member_access); - node.name = parseRightSideOfDot(true); - return finishNode(node); - } - function parseJsxElementOrSelfClosingElement(inExpressionContext) { - var opening = parseJsxOpeningOrSelfClosingElement(inExpressionContext); - var result; - if (opening.kind === 235) { - var node = createNode(233, opening.pos); - node.openingElement = opening; - node.children = parseJsxChildren(node.openingElement.tagName); - node.closingElement = parseJsxClosingElement(inExpressionContext); - result = finishNode(node); - } - else { - ts.Debug.assert(opening.kind === 234); - result = opening; - } - if (inExpressionContext && token === 25) { - var invalidElement = tryParse(function () { return parseJsxElementOrSelfClosingElement(true); }); - if (invalidElement) { - parseErrorAtCurrentToken(ts.Diagnostics.JSX_expressions_must_have_one_parent_element); - var badNode = createNode(181, result.pos); - badNode.end = invalidElement.end; - badNode.left = result; - badNode.right = invalidElement; - badNode.operatorToken = createMissingNode(24, false, undefined); - badNode.operatorToken.pos = badNode.operatorToken.end = badNode.right.pos; - return badNode; - } - } - return result; - } - function parseJsxText() { - var node = createNode(236, scanner.getStartPos()); - token = scanner.scanJsxToken(); - return finishNode(node); - } - function parseJsxChild() { - switch (token) { - case 236: - return parseJsxText(); - case 15: - return parseJsxExpression(false); - case 25: - return parseJsxElementOrSelfClosingElement(false); - } - ts.Debug.fail("Unknown JSX child kind " + token); - } - function parseJsxChildren(openingTagName) { - var result = []; - result.pos = scanner.getStartPos(); - var saveParsingContext = parsingContext; - parsingContext |= 1 << 14; - while (true) { - token = scanner.reScanJsxToken(); - if (token === 26) { - break; - } - else if (token === 1) { - parseErrorAtCurrentToken(ts.Diagnostics.Expected_corresponding_JSX_closing_tag_for_0, ts.getTextOfNodeFromSourceText(sourceText, openingTagName)); - break; - } - result.push(parseJsxChild()); - } - result.end = scanner.getTokenPos(); - parsingContext = saveParsingContext; - return result; - } - function parseJsxOpeningOrSelfClosingElement(inExpressionContext) { - var fullStart = scanner.getStartPos(); - parseExpected(25); - var tagName = parseJsxElementName(); - var attributes = parseList(13, parseJsxAttribute); - var node; - if (token === 27) { - node = createNode(235, fullStart); - scanJsxText(); - } - else { - parseExpected(39); - if (inExpressionContext) { - parseExpected(27); - } - else { - parseExpected(27, undefined, false); - scanJsxText(); - } - node = createNode(234, fullStart); - } - node.tagName = tagName; - node.attributes = attributes; - return finishNode(node); - } - function parseJsxElementName() { - scanJsxIdentifier(); - var elementName = parseIdentifierName(); - while (parseOptional(21)) { - scanJsxIdentifier(); - var node = createNode(135, elementName.pos); - node.left = elementName; - node.right = parseIdentifierName(); - elementName = finishNode(node); - } - return elementName; - } - function parseJsxExpression(inExpressionContext) { - var node = createNode(240); - parseExpected(15); - if (token !== 16) { - node.expression = parseExpression(); - } - if (inExpressionContext) { - parseExpected(16); - } - else { - parseExpected(16, undefined, false); - scanJsxText(); - } - return finishNode(node); - } - function parseJsxAttribute() { - if (token === 15) { - return parseJsxSpreadAttribute(); - } - scanJsxIdentifier(); - var node = createNode(238); - node.name = parseIdentifierName(); - if (parseOptional(56)) { - switch (token) { - case 9: - node.initializer = parseLiteralNode(); - break; - default: - node.initializer = parseJsxExpression(true); - break; - } - } - return finishNode(node); - } - function parseJsxSpreadAttribute() { - var node = createNode(239); - parseExpected(15); - parseExpected(22); - node.expression = parseExpression(); - parseExpected(16); - return finishNode(node); - } - function parseJsxClosingElement(inExpressionContext) { - var node = createNode(237); - parseExpected(26); - node.tagName = parseJsxElementName(); - if (inExpressionContext) { - parseExpected(27); - } - else { - parseExpected(27, undefined, false); - scanJsxText(); - } - return finishNode(node); - } - function parseTypeAssertion() { - var node = createNode(171); - parseExpected(25); - node.type = parseType(); - parseExpected(27); - node.expression = parseSimpleUnaryExpression(); - return finishNode(node); - } - function parseMemberExpressionRest(expression) { - while (true) { - var dotToken = parseOptionalToken(21); - if (dotToken) { - var propertyAccess = createNode(166, expression.pos); - propertyAccess.expression = expression; - propertyAccess.dotToken = dotToken; - propertyAccess.name = parseRightSideOfDot(true); - expression = finishNode(propertyAccess); - continue; - } - if (!inDecoratorContext() && parseOptional(19)) { - var indexedAccess = createNode(167, expression.pos); - indexedAccess.expression = expression; - if (token !== 20) { - indexedAccess.argumentExpression = allowInAnd(parseExpression); - if (indexedAccess.argumentExpression.kind === 9 || indexedAccess.argumentExpression.kind === 8) { - var literal = indexedAccess.argumentExpression; - literal.text = internIdentifier(literal.text); - } - } - parseExpected(20); - expression = finishNode(indexedAccess); - continue; - } - if (token === 11 || token === 12) { - var tagExpression = createNode(170, expression.pos); - tagExpression.tag = expression; - tagExpression.template = token === 11 - ? parseLiteralNode() - : parseTemplateExpression(); - expression = finishNode(tagExpression); - continue; - } - return expression; - } - } - function parseCallExpressionRest(expression) { - while (true) { - expression = parseMemberExpressionRest(expression); - if (token === 25) { - var typeArguments = tryParse(parseTypeArgumentsInExpression); - if (!typeArguments) { - return expression; - } - var callExpr = createNode(168, expression.pos); - callExpr.expression = expression; - callExpr.typeArguments = typeArguments; - callExpr.arguments = parseArgumentList(); - expression = finishNode(callExpr); - continue; - } - else if (token === 17) { - var callExpr = createNode(168, expression.pos); - callExpr.expression = expression; - callExpr.arguments = parseArgumentList(); - expression = finishNode(callExpr); - continue; - } - return expression; - } - } - function parseArgumentList() { - parseExpected(17); - var result = parseDelimitedList(11, parseArgumentExpression); - parseExpected(18); - return result; - } - function parseTypeArgumentsInExpression() { - if (!parseOptional(25)) { - return undefined; - } - var typeArguments = parseDelimitedList(18, parseType); - if (!parseExpected(27)) { - return undefined; - } - return typeArguments && canFollowTypeArgumentsInExpression() - ? typeArguments - : undefined; - } - function canFollowTypeArgumentsInExpression() { - switch (token) { - case 17: - case 21: - case 18: - case 20: - case 54: - case 23: - case 53: - case 30: - case 32: - case 31: - case 33: - case 51: - case 52: - case 48: - case 46: - case 47: - case 16: - case 1: - return true; - case 24: - case 15: - default: - return false; - } - } - function parsePrimaryExpression() { - switch (token) { - case 8: - case 9: - case 11: - return parseLiteralNode(); - case 97: - case 95: - case 93: - case 99: - case 84: - return parseTokenNode(); - case 17: - return parseParenthesizedExpression(); - case 19: - return parseArrayLiteralExpression(); - case 15: - return parseObjectLiteralExpression(); - case 118: - if (!lookAhead(nextTokenIsFunctionKeywordOnSameLine)) { - break; - } - return parseFunctionExpression(); - case 73: - return parseClassExpression(); - case 87: - return parseFunctionExpression(); - case 92: - return parseNewExpression(); - case 39: - case 61: - if (reScanSlashToken() === 10) { - return parseLiteralNode(); - } - break; - case 12: - return parseTemplateExpression(); - } - return parseIdentifier(ts.Diagnostics.Expression_expected); - } - function parseParenthesizedExpression() { - var node = createNode(172); - parseExpected(17); - node.expression = allowInAnd(parseExpression); - parseExpected(18); - return finishNode(node); - } - function parseSpreadElement() { - var node = createNode(185); - parseExpected(22); - node.expression = parseAssignmentExpressionOrHigher(); - return finishNode(node); - } - function parseArgumentOrArrayLiteralElement() { - return token === 22 ? parseSpreadElement() : - token === 24 ? createNode(187) : - parseAssignmentExpressionOrHigher(); - } - function parseArgumentExpression() { - return doOutsideOfContext(disallowInAndDecoratorContext, parseArgumentOrArrayLiteralElement); - } - function parseArrayLiteralExpression() { - var node = createNode(164); - parseExpected(19); - if (scanner.hasPrecedingLineBreak()) - node.flags |= 2048; - node.elements = parseDelimitedList(15, parseArgumentOrArrayLiteralElement); - parseExpected(20); - return finishNode(node); - } - function tryParseAccessorDeclaration(fullStart, decorators, modifiers) { - if (parseContextualModifier(123)) { - return parseAccessorDeclaration(145, fullStart, decorators, modifiers); - } - else if (parseContextualModifier(129)) { - return parseAccessorDeclaration(146, fullStart, decorators, modifiers); - } - return undefined; - } - function parseObjectLiteralElement() { - var fullStart = scanner.getStartPos(); - var decorators = parseDecorators(); - var modifiers = parseModifiers(); - var accessor = tryParseAccessorDeclaration(fullStart, decorators, modifiers); - if (accessor) { - return accessor; - } - var asteriskToken = parseOptionalToken(37); - var tokenIsIdentifier = isIdentifier(); - var nameToken = token; - var propertyName = parsePropertyName(); - var questionToken = parseOptionalToken(53); - if (asteriskToken || token === 17 || token === 25) { - return parseMethodDeclaration(fullStart, decorators, modifiers, asteriskToken, propertyName, questionToken); - } - var isShorthandPropertyAssignment = tokenIsIdentifier && (token === 24 || token === 16 || token === 56); - if (isShorthandPropertyAssignment) { - var shorthandDeclaration = createNode(246, fullStart); - shorthandDeclaration.name = propertyName; - shorthandDeclaration.questionToken = questionToken; - var equalsToken = parseOptionalToken(56); - if (equalsToken) { - shorthandDeclaration.equalsToken = equalsToken; - shorthandDeclaration.objectAssignmentInitializer = allowInAnd(parseAssignmentExpressionOrHigher); - } - return finishNode(shorthandDeclaration); - } - else { - var propertyAssignment = createNode(245, fullStart); - propertyAssignment.name = propertyName; - propertyAssignment.questionToken = questionToken; - parseExpected(54); - propertyAssignment.initializer = allowInAnd(parseAssignmentExpressionOrHigher); - return finishNode(propertyAssignment); - } - } - function parseObjectLiteralExpression() { - var node = createNode(165); - parseExpected(15); - if (scanner.hasPrecedingLineBreak()) { - node.flags |= 2048; - } - node.properties = parseDelimitedList(12, parseObjectLiteralElement, true); - parseExpected(16); - return finishNode(node); - } - function parseFunctionExpression() { - var saveDecoratorContext = inDecoratorContext(); - if (saveDecoratorContext) { - setDecoratorContext(false); - } - var node = createNode(173); - setModifiers(node, parseModifiers()); - parseExpected(87); - node.asteriskToken = parseOptionalToken(37); - var isGenerator = !!node.asteriskToken; - var isAsync = !!(node.flags & 512); - node.name = - isGenerator && isAsync ? doInYieldAndAwaitContext(parseOptionalIdentifier) : - isGenerator ? doInYieldContext(parseOptionalIdentifier) : - isAsync ? doInAwaitContext(parseOptionalIdentifier) : - parseOptionalIdentifier(); - fillSignature(54, isGenerator, isAsync, false, node); - node.body = parseFunctionBlock(isGenerator, isAsync, false); - if (saveDecoratorContext) { - setDecoratorContext(true); - } - return finishNode(node); - } - function parseOptionalIdentifier() { - return isIdentifier() ? parseIdentifier() : undefined; - } - function parseNewExpression() { - var node = createNode(169); - parseExpected(92); - node.expression = parseMemberExpressionOrHigher(); - node.typeArguments = tryParse(parseTypeArgumentsInExpression); - if (node.typeArguments || token === 17) { - node.arguments = parseArgumentList(); - } - return finishNode(node); - } - function parseBlock(ignoreMissingOpenBrace, diagnosticMessage) { - var node = createNode(192); - if (parseExpected(15, diagnosticMessage) || ignoreMissingOpenBrace) { - node.statements = parseList(1, parseStatement); - parseExpected(16); - } - else { - node.statements = createMissingList(); - } - return finishNode(node); - } - function parseFunctionBlock(allowYield, allowAwait, ignoreMissingOpenBrace, diagnosticMessage) { - var savedYieldContext = inYieldContext(); - setYieldContext(allowYield); - var savedAwaitContext = inAwaitContext(); - setAwaitContext(allowAwait); - var saveDecoratorContext = inDecoratorContext(); - if (saveDecoratorContext) { - setDecoratorContext(false); - } - var block = parseBlock(ignoreMissingOpenBrace, diagnosticMessage); - if (saveDecoratorContext) { - setDecoratorContext(true); - } - setYieldContext(savedYieldContext); - setAwaitContext(savedAwaitContext); - return block; - } - function parseEmptyStatement() { - var node = createNode(194); - parseExpected(23); - return finishNode(node); - } - function parseIfStatement() { - var node = createNode(196); - parseExpected(88); - parseExpected(17); - node.expression = allowInAnd(parseExpression); - parseExpected(18); - node.thenStatement = parseStatement(); - node.elseStatement = parseOptional(80) ? parseStatement() : undefined; - return finishNode(node); - } - function parseDoStatement() { - var node = createNode(197); - parseExpected(79); - node.statement = parseStatement(); - parseExpected(104); - parseExpected(17); - node.expression = allowInAnd(parseExpression); - parseExpected(18); - parseOptional(23); - return finishNode(node); - } - function parseWhileStatement() { - var node = createNode(198); - parseExpected(104); - parseExpected(17); - node.expression = allowInAnd(parseExpression); - parseExpected(18); - node.statement = parseStatement(); - return finishNode(node); - } - function parseForOrForInOrForOfStatement() { - var pos = getNodePos(); - parseExpected(86); - parseExpected(17); - var initializer = undefined; - if (token !== 23) { - if (token === 102 || token === 108 || token === 74) { - initializer = parseVariableDeclarationList(true); - } - else { - initializer = disallowInAnd(parseExpression); - } - } - var forOrForInOrForOfStatement; - if (parseOptional(90)) { - var forInStatement = createNode(200, pos); - forInStatement.initializer = initializer; - forInStatement.expression = allowInAnd(parseExpression); - parseExpected(18); - forOrForInOrForOfStatement = forInStatement; - } - else if (parseOptional(134)) { - var forOfStatement = createNode(201, pos); - forOfStatement.initializer = initializer; - forOfStatement.expression = allowInAnd(parseAssignmentExpressionOrHigher); - parseExpected(18); - forOrForInOrForOfStatement = forOfStatement; - } - else { - var forStatement = createNode(199, pos); - forStatement.initializer = initializer; - parseExpected(23); - if (token !== 23 && token !== 18) { - forStatement.condition = allowInAnd(parseExpression); - } - parseExpected(23); - if (token !== 18) { - forStatement.incrementor = allowInAnd(parseExpression); - } - parseExpected(18); - forOrForInOrForOfStatement = forStatement; - } - forOrForInOrForOfStatement.statement = parseStatement(); - return finishNode(forOrForInOrForOfStatement); - } - function parseBreakOrContinueStatement(kind) { - var node = createNode(kind); - parseExpected(kind === 203 ? 70 : 75); - if (!canParseSemicolon()) { - node.label = parseIdentifier(); - } - parseSemicolon(); - return finishNode(node); - } - function parseReturnStatement() { - var node = createNode(204); - parseExpected(94); - if (!canParseSemicolon()) { - node.expression = allowInAnd(parseExpression); - } - parseSemicolon(); - return finishNode(node); - } - function parseWithStatement() { - var node = createNode(205); - parseExpected(105); - parseExpected(17); - node.expression = allowInAnd(parseExpression); - parseExpected(18); - node.statement = parseStatement(); - return finishNode(node); - } - function parseCaseClause() { - var node = createNode(241); - parseExpected(71); - node.expression = allowInAnd(parseExpression); - parseExpected(54); - node.statements = parseList(3, parseStatement); - return finishNode(node); - } - function parseDefaultClause() { - var node = createNode(242); - parseExpected(77); - parseExpected(54); - node.statements = parseList(3, parseStatement); - return finishNode(node); - } - function parseCaseOrDefaultClause() { - return token === 71 ? parseCaseClause() : parseDefaultClause(); - } - function parseSwitchStatement() { - var node = createNode(206); - parseExpected(96); - parseExpected(17); - node.expression = allowInAnd(parseExpression); - parseExpected(18); - var caseBlock = createNode(220, scanner.getStartPos()); - parseExpected(15); - caseBlock.clauses = parseList(2, parseCaseOrDefaultClause); - parseExpected(16); - node.caseBlock = finishNode(caseBlock); - return finishNode(node); - } - function parseThrowStatement() { - var node = createNode(208); - parseExpected(98); - node.expression = scanner.hasPrecedingLineBreak() ? undefined : allowInAnd(parseExpression); - parseSemicolon(); - return finishNode(node); - } - function parseTryStatement() { - var node = createNode(209); - parseExpected(100); - node.tryBlock = parseBlock(false); - node.catchClause = token === 72 ? parseCatchClause() : undefined; - if (!node.catchClause || token === 85) { - parseExpected(85); - node.finallyBlock = parseBlock(false); - } - return finishNode(node); - } - function parseCatchClause() { - var result = createNode(244); - parseExpected(72); - if (parseExpected(17)) { - result.variableDeclaration = parseVariableDeclaration(); - } - parseExpected(18); - result.block = parseBlock(false); - return finishNode(result); - } - function parseDebuggerStatement() { - var node = createNode(210); - parseExpected(76); - parseSemicolon(); - return finishNode(node); - } - function parseExpressionOrLabeledStatement() { - var fullStart = scanner.getStartPos(); - var expression = allowInAnd(parseExpression); - if (expression.kind === 69 && parseOptional(54)) { - var labeledStatement = createNode(207, fullStart); - labeledStatement.label = expression; - labeledStatement.statement = parseStatement(); - return finishNode(labeledStatement); - } - else { - var expressionStatement = createNode(195, fullStart); - expressionStatement.expression = expression; - parseSemicolon(); - return finishNode(expressionStatement); - } - } - function nextTokenIsIdentifierOrKeywordOnSameLine() { - nextToken(); - return ts.tokenIsIdentifierOrKeyword(token) && !scanner.hasPrecedingLineBreak(); - } - function nextTokenIsFunctionKeywordOnSameLine() { - nextToken(); - return token === 87 && !scanner.hasPrecedingLineBreak(); - } - function nextTokenIsIdentifierOrKeywordOrNumberOnSameLine() { - nextToken(); - return (ts.tokenIsIdentifierOrKeyword(token) || token === 8) && !scanner.hasPrecedingLineBreak(); - } - function isDeclaration() { - while (true) { - switch (token) { - case 102: - case 108: - case 74: - case 87: - case 73: - case 81: - return true; - case 107: - case 132: - return nextTokenIsIdentifierOnSameLine(); - case 125: - case 126: - return nextTokenIsIdentifierOrStringLiteralOnSameLine(); - case 115: - case 118: - case 122: - case 110: - case 111: - case 112: - nextToken(); - if (scanner.hasPrecedingLineBreak()) { - return false; - } - continue; - case 89: - nextToken(); - return token === 9 || token === 37 || - token === 15 || ts.tokenIsIdentifierOrKeyword(token); - case 82: - nextToken(); - if (token === 56 || token === 37 || - token === 15 || token === 77) { - return true; - } - continue; - case 113: - nextToken(); - continue; - default: - return false; - } - } - } - function isStartOfDeclaration() { - return lookAhead(isDeclaration); - } - function isStartOfStatement() { - switch (token) { - case 55: - case 23: - case 15: - case 102: - case 108: - case 87: - case 73: - case 81: - 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: - return isStartOfDeclaration(); - case 118: - case 122: - case 107: - case 125: - case 126: - case 132: - return true; - case 112: - case 110: - case 111: - case 113: - return isStartOfDeclaration() || !lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine); - default: - return isStartOfExpression(); - } - } - function nextTokenIsIdentifierOrStartOfDestructuring() { - nextToken(); - return isIdentifier() || token === 15 || token === 19; - } - function isLetDeclaration() { - return lookAhead(nextTokenIsIdentifierOrStartOfDestructuring); - } - function parseStatement() { - switch (token) { - case 23: - return parseEmptyStatement(); - case 15: - return parseBlock(false); - case 102: - return parseVariableStatement(scanner.getStartPos(), undefined, undefined); - case 108: - 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(202); - case 70: - return parseBreakOrContinueStatement(203); - 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 132: - case 125: - case 126: - case 122: - case 74: - case 81: - case 82: - case 89: - case 110: - case 111: - case 112: - case 115: - case 113: - if (isStartOfDeclaration()) { - return parseDeclaration(); - } - break; - } - return parseExpressionOrLabeledStatement(); - } - function parseDeclaration() { - var fullStart = getNodePos(); - var decorators = parseDecorators(); - var modifiers = parseModifiers(); - switch (token) { - case 102: - case 108: - case 74: - return parseVariableStatement(fullStart, decorators, modifiers); - case 87: - return parseFunctionDeclaration(fullStart, decorators, modifiers); - case 73: - return parseClassDeclaration(fullStart, decorators, modifiers); - case 107: - return parseInterfaceDeclaration(fullStart, decorators, modifiers); - case 132: - return parseTypeAliasDeclaration(fullStart, decorators, modifiers); - case 81: - return parseEnumDeclaration(fullStart, decorators, modifiers); - case 125: - case 126: - return parseModuleDeclaration(fullStart, decorators, modifiers); - case 89: - return parseImportDeclarationOrImportEqualsDeclaration(fullStart, decorators, modifiers); - case 82: - nextToken(); - return token === 77 || token === 56 ? - parseExportAssignment(fullStart, decorators, modifiers) : - parseExportDeclaration(fullStart, decorators, modifiers); - default: - if (decorators || modifiers) { - var node = createMissingNode(231, true, ts.Diagnostics.Declaration_expected); - node.pos = fullStart; - node.decorators = decorators; - setModifiers(node, modifiers); - return finishNode(node); - } - } - } - function nextTokenIsIdentifierOrStringLiteralOnSameLine() { - nextToken(); - return !scanner.hasPrecedingLineBreak() && (isIdentifier() || token === 9); - } - function parseFunctionBlockOrSemicolon(isGenerator, isAsync, diagnosticMessage) { - if (token !== 15 && canParseSemicolon()) { - parseSemicolon(); - return; - } - return parseFunctionBlock(isGenerator, isAsync, false, diagnosticMessage); - } - function parseArrayBindingElement() { - if (token === 24) { - return createNode(187); - } - var node = createNode(163); - node.dotDotDotToken = parseOptionalToken(22); - node.name = parseIdentifierOrPattern(); - node.initializer = parseBindingElementInitializer(false); - return finishNode(node); - } - function parseObjectBindingElement() { - var node = createNode(163); - var tokenIsIdentifier = isIdentifier(); - var propertyName = parsePropertyName(); - if (tokenIsIdentifier && token !== 54) { - node.name = propertyName; - } - else { - parseExpected(54); - node.propertyName = propertyName; - node.name = parseIdentifierOrPattern(); - } - node.initializer = parseBindingElementInitializer(false); - return finishNode(node); - } - function parseObjectBindingPattern() { - var node = createNode(161); - parseExpected(15); - node.elements = parseDelimitedList(9, parseObjectBindingElement); - parseExpected(16); - return finishNode(node); - } - function parseArrayBindingPattern() { - var node = createNode(162); - parseExpected(19); - node.elements = parseDelimitedList(10, parseArrayBindingElement); - parseExpected(20); - return finishNode(node); - } - function isIdentifierOrPattern() { - return token === 15 || token === 19 || isIdentifier(); - } - function parseIdentifierOrPattern() { - if (token === 19) { - return parseArrayBindingPattern(); - } - if (token === 15) { - return parseObjectBindingPattern(); - } - return parseIdentifier(); - } - function parseVariableDeclaration() { - var node = createNode(211); - node.name = parseIdentifierOrPattern(); - node.type = parseTypeAnnotation(); - if (!isInOrOfKeyword(token)) { - node.initializer = parseInitializer(false); - } - return finishNode(node); - } - function parseVariableDeclarationList(inForStatementInitializer) { - var node = createNode(212); - switch (token) { - case 102: - break; - case 108: - node.flags |= 16384; - break; - case 74: - node.flags |= 32768; - break; - default: - ts.Debug.fail(); - } - nextToken(); - if (token === 134 && lookAhead(canFollowContextualOfKeyword)) { - node.declarations = createMissingList(); - } - else { - var savedDisallowIn = inDisallowInContext(); - setDisallowInContext(inForStatementInitializer); - node.declarations = parseDelimitedList(8, parseVariableDeclaration); - setDisallowInContext(savedDisallowIn); - } - return finishNode(node); - } - function canFollowContextualOfKeyword() { - return nextTokenIsIdentifier() && nextToken() === 18; - } - function parseVariableStatement(fullStart, decorators, modifiers) { - var node = createNode(193, fullStart); - node.decorators = decorators; - setModifiers(node, modifiers); - node.declarationList = parseVariableDeclarationList(false); - parseSemicolon(); - return finishNode(node); - } - function parseFunctionDeclaration(fullStart, decorators, modifiers) { - var node = createNode(213, fullStart); - node.decorators = decorators; - setModifiers(node, modifiers); - parseExpected(87); - node.asteriskToken = parseOptionalToken(37); - node.name = node.flags & 1024 ? parseOptionalIdentifier() : parseIdentifier(); - var isGenerator = !!node.asteriskToken; - var isAsync = !!(node.flags & 512); - fillSignature(54, isGenerator, isAsync, false, node); - node.body = parseFunctionBlockOrSemicolon(isGenerator, isAsync, ts.Diagnostics.or_expected); - return finishNode(node); - } - function parseConstructorDeclaration(pos, decorators, modifiers) { - var node = createNode(144, pos); - node.decorators = decorators; - setModifiers(node, modifiers); - parseExpected(121); - fillSignature(54, false, false, false, node); - node.body = parseFunctionBlockOrSemicolon(false, false, ts.Diagnostics.or_expected); - return finishNode(node); - } - function parseMethodDeclaration(fullStart, decorators, modifiers, asteriskToken, name, questionToken, diagnosticMessage) { - var method = createNode(143, fullStart); - method.decorators = decorators; - setModifiers(method, modifiers); - method.asteriskToken = asteriskToken; - method.name = name; - method.questionToken = questionToken; - var isGenerator = !!asteriskToken; - var isAsync = !!(method.flags & 512); - fillSignature(54, isGenerator, isAsync, false, method); - method.body = parseFunctionBlockOrSemicolon(isGenerator, isAsync, diagnosticMessage); - return finishNode(method); - } - function parsePropertyDeclaration(fullStart, decorators, modifiers, name, questionToken) { - var property = createNode(141, fullStart); - property.decorators = decorators; - setModifiers(property, modifiers); - property.name = name; - property.questionToken = questionToken; - property.type = parseTypeAnnotation(); - property.initializer = modifiers && modifiers.flags & 128 - ? allowInAnd(parseNonParameterInitializer) - : doOutsideOfContext(2 | 1, parseNonParameterInitializer); - parseSemicolon(); - return finishNode(property); - } - function parsePropertyOrMethodDeclaration(fullStart, decorators, modifiers) { - var asteriskToken = parseOptionalToken(37); - var name = parsePropertyName(); - var questionToken = parseOptionalToken(53); - if (asteriskToken || token === 17 || token === 25) { - return parseMethodDeclaration(fullStart, decorators, modifiers, asteriskToken, name, questionToken, ts.Diagnostics.or_expected); - } - else { - return parsePropertyDeclaration(fullStart, decorators, modifiers, name, questionToken); - } - } - function parseNonParameterInitializer() { - return parseInitializer(false); - } - function parseAccessorDeclaration(kind, fullStart, decorators, modifiers) { - var node = createNode(kind, fullStart); - node.decorators = decorators; - setModifiers(node, modifiers); - node.name = parsePropertyName(); - fillSignature(54, false, false, false, node); - node.body = parseFunctionBlockOrSemicolon(false, false); - return finishNode(node); - } - function isClassMemberModifier(idToken) { - switch (idToken) { - case 112: - case 110: - case 111: - case 113: - return true; - default: - return false; - } - } - function isClassMemberStart() { - var idToken; - if (token === 55) { - return true; - } - while (ts.isModifier(token)) { - idToken = token; - if (isClassMemberModifier(idToken)) { - return true; - } - nextToken(); - } - if (token === 37) { - return true; - } - if (isLiteralPropertyName()) { - idToken = token; - nextToken(); - } - if (token === 19) { - return true; - } - if (idToken !== undefined) { - if (!ts.isKeyword(idToken) || idToken === 129 || idToken === 123) { - return true; - } - switch (token) { - case 17: - case 25: - case 54: - case 56: - case 53: - return true; - default: - return canParseSemicolon(); - } - } - return false; - } - function parseDecorators() { - var decorators; - while (true) { - var decoratorStart = getNodePos(); - if (!parseOptional(55)) { - break; - } - if (!decorators) { - decorators = []; - decorators.pos = scanner.getStartPos(); - } - var decorator = createNode(139, decoratorStart); - decorator.expression = doInDecoratorContext(parseLeftHandSideExpressionOrHigher); - decorators.push(finishNode(decorator)); - } - if (decorators) { - decorators.end = getNodeEnd(); - } - return decorators; - } - function parseModifiers() { - var flags = 0; - var modifiers; - while (true) { - var modifierStart = scanner.getStartPos(); - var modifierKind = token; - if (!parseAnyContextualModifier()) { - break; - } - if (!modifiers) { - modifiers = []; - modifiers.pos = modifierStart; - } - flags |= ts.modifierToFlag(modifierKind); - modifiers.push(finishNode(createNode(modifierKind, modifierStart))); - } - if (modifiers) { - modifiers.flags = flags; - modifiers.end = scanner.getStartPos(); - } - return modifiers; - } - function parseModifiersForArrowFunction() { - var flags = 0; - var modifiers; - if (token === 118) { - var modifierStart = scanner.getStartPos(); - var modifierKind = token; - nextToken(); - modifiers = []; - modifiers.pos = modifierStart; - flags |= ts.modifierToFlag(modifierKind); - modifiers.push(finishNode(createNode(modifierKind, modifierStart))); - modifiers.flags = flags; - modifiers.end = scanner.getStartPos(); - } - return modifiers; - } - function parseClassElement() { - if (token === 23) { - var result = createNode(191); - nextToken(); - return finishNode(result); - } - var fullStart = getNodePos(); - var decorators = parseDecorators(); - var modifiers = parseModifiers(); - var accessor = tryParseAccessorDeclaration(fullStart, decorators, modifiers); - if (accessor) { - return accessor; - } - if (token === 121) { - return parseConstructorDeclaration(fullStart, decorators, modifiers); - } - if (isIndexSignature()) { - return parseIndexSignatureDeclaration(fullStart, decorators, modifiers); - } - if (ts.tokenIsIdentifierOrKeyword(token) || - token === 9 || - token === 8 || - token === 37 || - token === 19) { - return parsePropertyOrMethodDeclaration(fullStart, decorators, modifiers); - } - if (decorators || modifiers) { - var name_8 = createMissingNode(69, true, ts.Diagnostics.Declaration_expected); - return parsePropertyDeclaration(fullStart, decorators, modifiers, name_8, undefined); - } - ts.Debug.fail("Should not have attempted to parse class member declaration."); - } - function parseClassExpression() { - return parseClassDeclarationOrExpression(scanner.getStartPos(), undefined, undefined, 186); - } - function parseClassDeclaration(fullStart, decorators, modifiers) { - return parseClassDeclarationOrExpression(fullStart, decorators, modifiers, 214); - } - function parseClassDeclarationOrExpression(fullStart, decorators, modifiers, kind) { - var node = createNode(kind, fullStart); - node.decorators = decorators; - setModifiers(node, modifiers); - parseExpected(73); - node.name = parseNameOfClassDeclarationOrExpression(); - node.typeParameters = parseTypeParameters(); - node.heritageClauses = parseHeritageClauses(true); - if (parseExpected(15)) { - node.members = parseClassMembers(); - parseExpected(16); - } - else { - node.members = createMissingList(); - } - return finishNode(node); - } - function parseNameOfClassDeclarationOrExpression() { - return isIdentifier() && !isImplementsClause() - ? parseIdentifier() - : undefined; - } - function isImplementsClause() { - return token === 106 && lookAhead(nextTokenIsIdentifierOrKeyword); - } - function parseHeritageClauses(isClassHeritageClause) { - if (isHeritageClause()) { - return parseList(20, parseHeritageClause); - } - return undefined; - } - function parseHeritageClausesWorker() { - return parseList(20, parseHeritageClause); - } - function parseHeritageClause() { - if (token === 83 || token === 106) { - var node = createNode(243); - node.token = token; - nextToken(); - node.types = parseDelimitedList(7, parseExpressionWithTypeArguments); - return finishNode(node); - } - return undefined; - } - function parseExpressionWithTypeArguments() { - var node = createNode(188); - node.expression = parseLeftHandSideExpressionOrHigher(); - if (token === 25) { - node.typeArguments = parseBracketedList(18, parseType, 25, 27); - } - return finishNode(node); - } - function isHeritageClause() { - return token === 83 || token === 106; - } - function parseClassMembers() { - return parseList(5, parseClassElement); - } - function parseInterfaceDeclaration(fullStart, decorators, modifiers) { - var node = createNode(215, fullStart); - node.decorators = decorators; - setModifiers(node, modifiers); - parseExpected(107); - node.name = parseIdentifier(); - node.typeParameters = parseTypeParameters(); - node.heritageClauses = parseHeritageClauses(false); - node.members = parseObjectTypeMembers(); - return finishNode(node); - } - function parseTypeAliasDeclaration(fullStart, decorators, modifiers) { - var node = createNode(216, fullStart); - node.decorators = decorators; - setModifiers(node, modifiers); - parseExpected(132); - node.name = parseIdentifier(); - node.typeParameters = parseTypeParameters(); - parseExpected(56); - node.type = parseType(); - parseSemicolon(); - return finishNode(node); - } - function parseEnumMember() { - var node = createNode(247, scanner.getStartPos()); - node.name = parsePropertyName(); - node.initializer = allowInAnd(parseNonParameterInitializer); - return finishNode(node); - } - function parseEnumDeclaration(fullStart, decorators, modifiers) { - var node = createNode(217, fullStart); - node.decorators = decorators; - setModifiers(node, modifiers); - parseExpected(81); - node.name = parseIdentifier(); - if (parseExpected(15)) { - node.members = parseDelimitedList(6, parseEnumMember); - parseExpected(16); - } - else { - node.members = createMissingList(); - } - return finishNode(node); - } - function parseModuleBlock() { - var node = createNode(219, scanner.getStartPos()); - if (parseExpected(15)) { - node.statements = parseList(1, parseStatement); - parseExpected(16); - } - else { - node.statements = createMissingList(); - } - return finishNode(node); - } - function parseModuleOrNamespaceDeclaration(fullStart, decorators, modifiers, flags) { - var node = createNode(218, fullStart); - var namespaceFlag = flags & 131072; - node.decorators = decorators; - setModifiers(node, modifiers); - node.flags |= flags; - node.name = parseIdentifier(); - node.body = parseOptional(21) - ? parseModuleOrNamespaceDeclaration(getNodePos(), undefined, undefined, 1 | namespaceFlag) - : parseModuleBlock(); - return finishNode(node); - } - function parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers) { - var node = createNode(218, fullStart); - node.decorators = decorators; - setModifiers(node, modifiers); - node.name = parseLiteralNode(true); - node.body = parseModuleBlock(); - return finishNode(node); - } - function parseModuleDeclaration(fullStart, decorators, modifiers) { - var flags = modifiers ? modifiers.flags : 0; - if (parseOptional(126)) { - flags |= 131072; - } - else { - parseExpected(125); - if (token === 9) { - return parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers); - } - } - return parseModuleOrNamespaceDeclaration(fullStart, decorators, modifiers, flags); - } - function isExternalModuleReference() { - return token === 127 && - lookAhead(nextTokenIsOpenParen); - } - function nextTokenIsOpenParen() { - return nextToken() === 17; - } - function nextTokenIsSlash() { - return nextToken() === 39; - } - function nextTokenIsCommaOrFromKeyword() { - nextToken(); - return token === 24 || - token === 133; - } - function parseImportDeclarationOrImportEqualsDeclaration(fullStart, decorators, modifiers) { - parseExpected(89); - var afterImportPos = scanner.getStartPos(); - var identifier; - if (isIdentifier()) { - identifier = parseIdentifier(); - if (token !== 24 && token !== 133) { - var importEqualsDeclaration = createNode(221, fullStart); - importEqualsDeclaration.decorators = decorators; - setModifiers(importEqualsDeclaration, modifiers); - importEqualsDeclaration.name = identifier; - parseExpected(56); - importEqualsDeclaration.moduleReference = parseModuleReference(); - parseSemicolon(); - return finishNode(importEqualsDeclaration); - } - } - var importDeclaration = createNode(222, fullStart); - importDeclaration.decorators = decorators; - setModifiers(importDeclaration, modifiers); - if (identifier || - token === 37 || - token === 15) { - importDeclaration.importClause = parseImportClause(identifier, afterImportPos); - parseExpected(133); - } - importDeclaration.moduleSpecifier = parseModuleSpecifier(); - parseSemicolon(); - return finishNode(importDeclaration); - } - function parseImportClause(identifier, fullStart) { - var importClause = createNode(223, fullStart); - if (identifier) { - importClause.name = identifier; - } - if (!importClause.name || - parseOptional(24)) { - importClause.namedBindings = token === 37 ? parseNamespaceImport() : parseNamedImportsOrExports(225); - } - return finishNode(importClause); - } - function parseModuleReference() { - return isExternalModuleReference() - ? parseExternalModuleReference() - : parseEntityName(false); - } - function parseExternalModuleReference() { - var node = createNode(232); - parseExpected(127); - parseExpected(17); - node.expression = parseModuleSpecifier(); - parseExpected(18); - return finishNode(node); - } - function parseModuleSpecifier() { - var result = parseExpression(); - if (result.kind === 9) { - internIdentifier(result.text); - } - return result; - } - function parseNamespaceImport() { - var namespaceImport = createNode(224); - parseExpected(37); - parseExpected(116); - namespaceImport.name = parseIdentifier(); - return finishNode(namespaceImport); - } - function parseNamedImportsOrExports(kind) { - var node = createNode(kind); - node.elements = parseBracketedList(21, kind === 225 ? parseImportSpecifier : parseExportSpecifier, 15, 16); - return finishNode(node); - } - function parseExportSpecifier() { - return parseImportOrExportSpecifier(230); - } - function parseImportSpecifier() { - return parseImportOrExportSpecifier(226); - } - function parseImportOrExportSpecifier(kind) { - var node = createNode(kind); - var checkIdentifierIsKeyword = ts.isKeyword(token) && !isIdentifier(); - var checkIdentifierStart = scanner.getTokenPos(); - var checkIdentifierEnd = scanner.getTextPos(); - var identifierName = parseIdentifierName(); - if (token === 116) { - node.propertyName = identifierName; - parseExpected(116); - checkIdentifierIsKeyword = ts.isKeyword(token) && !isIdentifier(); - checkIdentifierStart = scanner.getTokenPos(); - checkIdentifierEnd = scanner.getTextPos(); - node.name = parseIdentifierName(); - } - else { - node.name = identifierName; - } - if (kind === 226 && checkIdentifierIsKeyword) { - parseErrorAtPosition(checkIdentifierStart, checkIdentifierEnd - checkIdentifierStart, ts.Diagnostics.Identifier_expected); - } - return finishNode(node); - } - function parseExportDeclaration(fullStart, decorators, modifiers) { - var node = createNode(228, fullStart); - node.decorators = decorators; - setModifiers(node, modifiers); - if (parseOptional(37)) { - parseExpected(133); - node.moduleSpecifier = parseModuleSpecifier(); - } - else { - node.exportClause = parseNamedImportsOrExports(229); - if (token === 133 || (token === 9 && !scanner.hasPrecedingLineBreak())) { - parseExpected(133); - node.moduleSpecifier = parseModuleSpecifier(); - } - } - parseSemicolon(); - return finishNode(node); - } - function parseExportAssignment(fullStart, decorators, modifiers) { - var node = createNode(227, fullStart); - node.decorators = decorators; - setModifiers(node, modifiers); - if (parseOptional(56)) { - node.isExportEquals = true; - } - else { - parseExpected(77); - } - node.expression = parseAssignmentExpressionOrHigher(); - parseSemicolon(); - return finishNode(node); - } - function processReferenceComments(sourceFile) { - var triviaScanner = ts.createScanner(sourceFile.languageVersion, false, 0, sourceText); - var referencedFiles = []; - var amdDependencies = []; - var amdModuleName; - while (true) { - var kind = triviaScanner.scan(); - if (kind === 5 || kind === 4 || kind === 3) { - continue; - } - if (kind !== 2) { - break; - } - var range = { pos: triviaScanner.getTokenPos(), end: triviaScanner.getTextPos(), kind: triviaScanner.getToken() }; - var comment = sourceText.substring(range.pos, range.end); - var referencePathMatchResult = ts.getFileReferenceFromReferencePath(comment, range); - if (referencePathMatchResult) { - var fileReference = referencePathMatchResult.fileReference; - sourceFile.hasNoDefaultLib = referencePathMatchResult.isNoDefaultLib; - var diagnosticMessage = referencePathMatchResult.diagnosticMessage; - if (fileReference) { - referencedFiles.push(fileReference); - } - if (diagnosticMessage) { - parseDiagnostics.push(ts.createFileDiagnostic(sourceFile, range.pos, range.end - range.pos, diagnosticMessage)); - } - } - else { - var amdModuleNameRegEx = /^\/\/\/\s*".length; - return parseErrorAtPosition(start, end - start, ts.Diagnostics.Type_argument_list_cannot_be_empty); - } - } - function parseQualifiedName(left) { - var result = createNode(135, left.pos); - result.left = left; - result.right = parseIdentifierName(); - return finishNode(result); - } - function parseJSDocRecordType() { - var result = createNode(257); - nextToken(); - result.members = parseDelimitedList(24, parseJSDocRecordMember); - checkForTrailingComma(result.members); - parseExpected(16); - return finishNode(result); - } - function parseJSDocRecordMember() { - var result = createNode(258); - result.name = parseSimplePropertyName(); - if (token === 54) { - nextToken(); - result.type = parseJSDocType(); - } - return finishNode(result); - } - function parseJSDocNonNullableType() { - var result = createNode(256); - nextToken(); - result.type = parseJSDocType(); - return finishNode(result); - } - function parseJSDocTupleType() { - var result = createNode(254); - nextToken(); - result.types = parseDelimitedList(25, parseJSDocType); - checkForTrailingComma(result.types); - parseExpected(20); - return finishNode(result); - } - function checkForTrailingComma(list) { - if (parseDiagnostics.length === 0 && list.hasTrailingComma) { - var start = list.end - ",".length; - parseErrorAtPosition(start, ",".length, ts.Diagnostics.Trailing_comma_not_allowed); - } - } - function parseJSDocUnionType() { - var result = createNode(253); - nextToken(); - result.types = parseJSDocTypeList(parseJSDocType()); - parseExpected(18); - return finishNode(result); - } - function parseJSDocTypeList(firstType) { - ts.Debug.assert(!!firstType); - var types = []; - types.pos = firstType.pos; - types.push(firstType); - while (parseOptional(47)) { - types.push(parseJSDocType()); - } - types.end = scanner.getStartPos(); - return types; - } - function parseJSDocAllType() { - var result = createNode(250); - nextToken(); - return finishNode(result); - } - function parseJSDocUnknownOrNullableType() { - var pos = scanner.getStartPos(); - nextToken(); - if (token === 24 || - token === 16 || - token === 18 || - token === 27 || - token === 56 || - token === 47) { - var result = createNode(251, pos); - return finishNode(result); - } - else { - var result = createNode(255, pos); - result.type = parseJSDocType(); - return finishNode(result); - } - } - function parseIsolatedJSDocComment(content, start, length) { - initializeState("file.js", content, 2, undefined); - var jsDocComment = parseJSDocComment(undefined, start, length); - var diagnostics = parseDiagnostics; - clearState(); - return jsDocComment ? { jsDocComment: jsDocComment, diagnostics: diagnostics } : undefined; - } - JSDocParser.parseIsolatedJSDocComment = parseIsolatedJSDocComment; - function parseJSDocComment(parent, start, length) { - var comment = parseJSDocCommentWorker(start, length); - if (comment) { - fixupParentReferences(comment); - comment.parent = parent; - } - return comment; - } - JSDocParser.parseJSDocComment = parseJSDocComment; - function parseJSDocCommentWorker(start, length) { - var content = sourceText; - start = start || 0; - var end = length === undefined ? content.length : start + length; - length = end - start; - ts.Debug.assert(start >= 0); - ts.Debug.assert(start <= end); - ts.Debug.assert(end <= content.length); - var tags; - var pos; - if (length >= "/** */".length) { - if (content.charCodeAt(start) === 47 && - content.charCodeAt(start + 1) === 42 && - content.charCodeAt(start + 2) === 42 && - content.charCodeAt(start + 3) !== 42) { - var canParseTag = true; - var seenAsterisk = true; - for (pos = start + "/**".length; pos < end;) { - var ch = content.charCodeAt(pos); - pos++; - if (ch === 64 && canParseTag) { - parseTag(); - canParseTag = false; - continue; - } - if (ts.isLineBreak(ch)) { - canParseTag = true; - seenAsterisk = false; - continue; - } - if (ts.isWhiteSpace(ch)) { - continue; - } - if (ch === 42) { - if (seenAsterisk) { - canParseTag = false; - } - seenAsterisk = true; - continue; - } - canParseTag = false; - } - } - } - return createJSDocComment(); - function createJSDocComment() { - if (!tags) { - return undefined; - } - var result = createNode(265, start); - result.tags = tags; - return finishNode(result, end); - } - function skipWhitespace() { - while (pos < end && ts.isWhiteSpace(content.charCodeAt(pos))) { - pos++; - } - } - function parseTag() { - ts.Debug.assert(content.charCodeAt(pos - 1) === 64); - var atToken = createNode(55, pos - 1); - atToken.end = pos; - var tagName = scanIdentifier(); - if (!tagName) { - return; - } - var tag = handleTag(atToken, tagName) || handleUnknownTag(atToken, tagName); - addTag(tag); - } - function handleTag(atToken, tagName) { - if (tagName) { - switch (tagName.text) { - case "param": - return handleParamTag(atToken, tagName); - case "return": - case "returns": - return handleReturnTag(atToken, tagName); - case "template": - return handleTemplateTag(atToken, tagName); - case "type": - return handleTypeTag(atToken, tagName); - } - } - return undefined; - } - function handleUnknownTag(atToken, tagName) { - var result = createNode(266, atToken.pos); - result.atToken = atToken; - result.tagName = tagName; - return finishNode(result, pos); - } - function addTag(tag) { - if (tag) { - if (!tags) { - tags = []; - tags.pos = tag.pos; - } - tags.push(tag); - tags.end = tag.end; - } - } - function tryParseTypeExpression() { - skipWhitespace(); - if (content.charCodeAt(pos) !== 123) { - return undefined; - } - var typeExpression = parseJSDocTypeExpression(pos, end - pos); - pos = typeExpression.end; - return typeExpression; - } - function handleParamTag(atToken, tagName) { - var typeExpression = tryParseTypeExpression(); - skipWhitespace(); - var name; - var isBracketed; - if (content.charCodeAt(pos) === 91) { - pos++; - skipWhitespace(); - name = scanIdentifier(); - isBracketed = true; - } - else { - name = scanIdentifier(); - } - if (!name) { - parseErrorAtPosition(pos, 0, ts.Diagnostics.Identifier_expected); - } - var preName, postName; - if (typeExpression) { - postName = name; - } - else { - preName = name; - } - if (!typeExpression) { - typeExpression = tryParseTypeExpression(); - } - var result = createNode(267, atToken.pos); - result.atToken = atToken; - result.tagName = tagName; - result.preParameterName = preName; - result.typeExpression = typeExpression; - result.postParameterName = postName; - result.isBracketed = isBracketed; - return finishNode(result, pos); - } - function handleReturnTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 268; })) { - parseErrorAtPosition(tagName.pos, pos - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); - } - var result = createNode(268, atToken.pos); - result.atToken = atToken; - result.tagName = tagName; - result.typeExpression = tryParseTypeExpression(); - return finishNode(result, pos); - } - function handleTypeTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 269; })) { - parseErrorAtPosition(tagName.pos, pos - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); - } - var result = createNode(269, atToken.pos); - result.atToken = atToken; - result.tagName = tagName; - result.typeExpression = tryParseTypeExpression(); - return finishNode(result, pos); - } - function handleTemplateTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 270; })) { - parseErrorAtPosition(tagName.pos, pos - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); - } - var typeParameters = []; - typeParameters.pos = pos; - while (true) { - skipWhitespace(); - var startPos = pos; - var name_9 = scanIdentifier(); - if (!name_9) { - parseErrorAtPosition(startPos, 0, ts.Diagnostics.Identifier_expected); - return undefined; - } - var typeParameter = createNode(137, name_9.pos); - typeParameter.name = name_9; - finishNode(typeParameter, pos); - typeParameters.push(typeParameter); - skipWhitespace(); - if (content.charCodeAt(pos) !== 44) { - break; - } - pos++; - } - typeParameters.end = pos; - var result = createNode(270, atToken.pos); - result.atToken = atToken; - result.tagName = tagName; - result.typeParameters = typeParameters; - return finishNode(result, pos); - } - function scanIdentifier() { - var startPos = pos; - for (; pos < end; pos++) { - var ch = content.charCodeAt(pos); - if (pos === startPos && ts.isIdentifierStart(ch, 2)) { - continue; - } - else if (pos > startPos && ts.isIdentifierPart(ch, 2)) { - continue; - } - break; - } - if (startPos === pos) { - return undefined; - } - var result = createNode(69, startPos); - result.text = content.substring(startPos, pos); - return finishNode(result, pos); - } - } - JSDocParser.parseJSDocCommentWorker = parseJSDocCommentWorker; - })(JSDocParser = Parser.JSDocParser || (Parser.JSDocParser = {})); - })(Parser || (Parser = {})); - var IncrementalParser; - (function (IncrementalParser) { - function updateSourceFile(sourceFile, newText, textChangeRange, aggressiveChecks) { - aggressiveChecks = aggressiveChecks || ts.Debug.shouldAssert(2); - checkChangeRange(sourceFile, newText, textChangeRange, aggressiveChecks); - if (ts.textChangeRangeIsUnchanged(textChangeRange)) { - return sourceFile; - } - if (sourceFile.statements.length === 0) { - return Parser.parseSourceFile(sourceFile.fileName, newText, sourceFile.languageVersion, undefined, true); - } - var incrementalSourceFile = sourceFile; - ts.Debug.assert(!incrementalSourceFile.hasBeenIncrementallyParsed); - incrementalSourceFile.hasBeenIncrementallyParsed = true; - var oldText = sourceFile.text; - var syntaxCursor = createSyntaxCursor(sourceFile); - var changeRange = extendToAffectedRange(sourceFile, textChangeRange); - checkChangeRange(sourceFile, newText, changeRange, aggressiveChecks); - ts.Debug.assert(changeRange.span.start <= textChangeRange.span.start); - ts.Debug.assert(ts.textSpanEnd(changeRange.span) === ts.textSpanEnd(textChangeRange.span)); - ts.Debug.assert(ts.textSpanEnd(ts.textChangeRangeNewSpan(changeRange)) === ts.textSpanEnd(ts.textChangeRangeNewSpan(textChangeRange))); - var delta = ts.textChangeRangeNewSpan(changeRange).length - changeRange.span.length; - updateTokenPositionsAndMarkElements(incrementalSourceFile, changeRange.span.start, ts.textSpanEnd(changeRange.span), ts.textSpanEnd(ts.textChangeRangeNewSpan(changeRange)), delta, oldText, newText, aggressiveChecks); - var result = Parser.parseSourceFile(sourceFile.fileName, newText, sourceFile.languageVersion, syntaxCursor, true); - return result; - } - IncrementalParser.updateSourceFile = updateSourceFile; - function moveElementEntirelyPastChangeRange(element, isArray, delta, oldText, newText, aggressiveChecks) { - if (isArray) { - visitArray(element); - } - else { - visitNode(element); - } - return; - function visitNode(node) { - var text = ""; - if (aggressiveChecks && shouldCheckNode(node)) { - text = oldText.substring(node.pos, node.end); - } - if (node._children) { - node._children = undefined; - } - if (node.jsDocComment) { - node.jsDocComment = undefined; - } - node.pos += delta; - node.end += delta; - if (aggressiveChecks && shouldCheckNode(node)) { - ts.Debug.assert(text === newText.substring(node.pos, node.end)); - } - forEachChild(node, visitNode, visitArray); - checkNodePositions(node, aggressiveChecks); - } - function visitArray(array) { - array._children = undefined; - array.pos += delta; - array.end += delta; - for (var _i = 0; _i < array.length; _i++) { - var node = array[_i]; - visitNode(node); - } - } - } - function shouldCheckNode(node) { - switch (node.kind) { - case 9: - case 8: - case 69: - return true; - } - return false; - } - function adjustIntersectingElement(element, changeStart, changeRangeOldEnd, changeRangeNewEnd, delta) { - ts.Debug.assert(element.end >= changeStart, "Adjusting an element that was entirely before the change range"); - ts.Debug.assert(element.pos <= changeRangeOldEnd, "Adjusting an element that was entirely after the change range"); - ts.Debug.assert(element.pos <= element.end); - element.pos = Math.min(element.pos, changeRangeNewEnd); - if (element.end >= changeRangeOldEnd) { - element.end += delta; - } - else { - element.end = Math.min(element.end, changeRangeNewEnd); - } - ts.Debug.assert(element.pos <= element.end); - if (element.parent) { - ts.Debug.assert(element.pos >= element.parent.pos); - ts.Debug.assert(element.end <= element.parent.end); - } - } - function checkNodePositions(node, aggressiveChecks) { - if (aggressiveChecks) { - var pos = node.pos; - forEachChild(node, function (child) { - ts.Debug.assert(child.pos >= pos); - pos = child.end; - }); - ts.Debug.assert(pos <= node.end); - } - } - function updateTokenPositionsAndMarkElements(sourceFile, changeStart, changeRangeOldEnd, changeRangeNewEnd, delta, oldText, newText, aggressiveChecks) { - visitNode(sourceFile); - return; - function visitNode(child) { - ts.Debug.assert(child.pos <= child.end); - if (child.pos > changeRangeOldEnd) { - moveElementEntirelyPastChangeRange(child, false, delta, oldText, newText, aggressiveChecks); - return; - } - var fullEnd = child.end; - if (fullEnd >= changeStart) { - child.intersectsChange = true; - child._children = undefined; - adjustIntersectingElement(child, changeStart, changeRangeOldEnd, changeRangeNewEnd, delta); - forEachChild(child, visitNode, visitArray); - checkNodePositions(child, aggressiveChecks); - return; - } - ts.Debug.assert(fullEnd < changeStart); - } - function visitArray(array) { - ts.Debug.assert(array.pos <= array.end); - if (array.pos > changeRangeOldEnd) { - moveElementEntirelyPastChangeRange(array, true, delta, oldText, newText, aggressiveChecks); - return; - } - var fullEnd = array.end; - if (fullEnd >= changeStart) { - array.intersectsChange = true; - array._children = undefined; - adjustIntersectingElement(array, changeStart, changeRangeOldEnd, changeRangeNewEnd, delta); - for (var _i = 0; _i < array.length; _i++) { - var node = array[_i]; - visitNode(node); - } - return; - } - ts.Debug.assert(fullEnd < changeStart); - } - } - function extendToAffectedRange(sourceFile, changeRange) { - var maxLookahead = 1; - var start = changeRange.span.start; - for (var i = 0; start > 0 && i <= maxLookahead; i++) { - var nearestNode = findNearestNodeStartingBeforeOrAtPosition(sourceFile, start); - ts.Debug.assert(nearestNode.pos <= start); - var position = nearestNode.pos; - start = Math.max(0, position - 1); - } - var finalSpan = ts.createTextSpanFromBounds(start, ts.textSpanEnd(changeRange.span)); - var finalLength = changeRange.newLength + (changeRange.span.start - start); - return ts.createTextChangeRange(finalSpan, finalLength); - } - function findNearestNodeStartingBeforeOrAtPosition(sourceFile, position) { - var bestResult = sourceFile; - var lastNodeEntirelyBeforePosition; - forEachChild(sourceFile, visit); - if (lastNodeEntirelyBeforePosition) { - var lastChildOfLastEntireNodeBeforePosition = getLastChild(lastNodeEntirelyBeforePosition); - if (lastChildOfLastEntireNodeBeforePosition.pos > bestResult.pos) { - bestResult = lastChildOfLastEntireNodeBeforePosition; - } - } - return bestResult; - function getLastChild(node) { - while (true) { - var lastChild = getLastChildWorker(node); - if (lastChild) { - node = lastChild; - } - else { - return node; - } - } - } - function getLastChildWorker(node) { - var last = undefined; - forEachChild(node, function (child) { - if (ts.nodeIsPresent(child)) { - last = child; - } - }); - return last; - } - function visit(child) { - if (ts.nodeIsMissing(child)) { - return; - } - if (child.pos <= position) { - if (child.pos >= bestResult.pos) { - bestResult = child; - } - if (position < child.end) { - forEachChild(child, visit); - return true; - } - else { - ts.Debug.assert(child.end <= position); - lastNodeEntirelyBeforePosition = child; - } - } - else { - ts.Debug.assert(child.pos > position); - return true; - } - } - } - function checkChangeRange(sourceFile, newText, textChangeRange, aggressiveChecks) { - var oldText = sourceFile.text; - if (textChangeRange) { - ts.Debug.assert((oldText.length - textChangeRange.span.length + textChangeRange.newLength) === newText.length); - if (aggressiveChecks || ts.Debug.shouldAssert(3)) { - var oldTextPrefix = oldText.substr(0, textChangeRange.span.start); - var newTextPrefix = newText.substr(0, textChangeRange.span.start); - ts.Debug.assert(oldTextPrefix === newTextPrefix); - var oldTextSuffix = oldText.substring(ts.textSpanEnd(textChangeRange.span), oldText.length); - var newTextSuffix = newText.substring(ts.textSpanEnd(ts.textChangeRangeNewSpan(textChangeRange)), newText.length); - ts.Debug.assert(oldTextSuffix === newTextSuffix); - } - } - } - function createSyntaxCursor(sourceFile) { - var currentArray = sourceFile.statements; - var currentArrayIndex = 0; - ts.Debug.assert(currentArrayIndex < currentArray.length); - var current = currentArray[currentArrayIndex]; - var lastQueriedPosition = -1; - return { - currentNode: function (position) { - if (position !== lastQueriedPosition) { - if (current && current.end === position && currentArrayIndex < (currentArray.length - 1)) { - currentArrayIndex++; - current = currentArray[currentArrayIndex]; - } - if (!current || current.pos !== position) { - findHighestListElementThatStartsAtPosition(position); - } - } - lastQueriedPosition = position; - ts.Debug.assert(!current || current.pos === position); - return current; - } - }; - function findHighestListElementThatStartsAtPosition(position) { - currentArray = undefined; - currentArrayIndex = -1; - current = undefined; - forEachChild(sourceFile, visitNode, visitArray); - return; - function visitNode(node) { - if (position >= node.pos && position < node.end) { - forEachChild(node, visitNode, visitArray); - return true; - } - return false; - } - function visitArray(array) { - if (position >= array.pos && position < array.end) { - for (var i = 0, n = array.length; i < n; i++) { - var child = array[i]; - if (child) { - if (child.pos === position) { - currentArray = array; - currentArrayIndex = i; - current = child; - return true; - } - else { - if (child.pos < position && position < child.end) { - forEachChild(child, visitNode, visitArray); - return true; - } - } - } - } - } - return false; - } - } - } - })(IncrementalParser || (IncrementalParser = {})); -})(ts || (ts = {})); -var ts; -(function (ts) { - ts.bindTime = 0; - function getModuleInstanceState(node) { - if (node.kind === 215 || node.kind === 216) { - return 0; - } - else if (ts.isConstEnumDeclaration(node)) { - return 2; - } - else if ((node.kind === 222 || node.kind === 221) && !(node.flags & 1)) { - return 0; - } - else if (node.kind === 219) { - var state = 0; - ts.forEachChild(node, function (n) { - switch (getModuleInstanceState(n)) { - case 0: - return false; - case 2: - state = 2; - return false; - case 1: - state = 1; - return true; - } - }); - return state; - } - else if (node.kind === 218) { - return getModuleInstanceState(node.body); - } - else { - return 1; - } - } - ts.getModuleInstanceState = getModuleInstanceState; - function bindSourceFile(file) { - var start = new Date().getTime(); - bindSourceFileWorker(file); - ts.bindTime += new Date().getTime() - start; - } - ts.bindSourceFile = bindSourceFile; - function bindSourceFileWorker(file) { - var parent; - var container; - var blockScopeContainer; - var lastContainer; - var seenThisKeyword; - var inStrictMode = !!file.externalModuleIndicator; - var symbolCount = 0; - var Symbol = ts.objectAllocator.getSymbolConstructor(); - var classifiableNames = {}; - if (!file.locals) { - bind(file); - file.symbolCount = symbolCount; - file.classifiableNames = classifiableNames; - } - return; - function createSymbol(flags, name) { - symbolCount++; - return new Symbol(flags, name); - } - function addDeclarationToSymbol(symbol, node, symbolFlags) { - symbol.flags |= symbolFlags; - node.symbol = symbol; - if (!symbol.declarations) { - symbol.declarations = []; - } - symbol.declarations.push(node); - if (symbolFlags & 1952 && !symbol.exports) { - symbol.exports = {}; - } - if (symbolFlags & 6240 && !symbol.members) { - symbol.members = {}; - } - if (symbolFlags & 107455 && !symbol.valueDeclaration) { - symbol.valueDeclaration = node; - } - } - function getDeclarationName(node) { - if (node.name) { - if (node.kind === 218 && node.name.kind === 9) { - return "\"" + node.name.text + "\""; - } - if (node.name.kind === 136) { - var nameExpression = node.name.expression; - ts.Debug.assert(ts.isWellKnownSymbolSyntactically(nameExpression)); - return ts.getPropertyNameForKnownSymbolName(nameExpression.name.text); - } - return node.name.text; - } - switch (node.kind) { - case 144: - return "__constructor"; - case 152: - case 147: - return "__call"; - case 153: - case 148: - return "__new"; - case 149: - return "__index"; - case 228: - return "__export"; - case 227: - return node.isExportEquals ? "export=" : "default"; - case 213: - case 214: - return node.flags & 1024 ? "default" : undefined; - } - } - function getDisplayName(node) { - return node.name ? ts.declarationNameToString(node.name) : getDeclarationName(node); - } - function declareSymbol(symbolTable, parent, node, includes, excludes) { - ts.Debug.assert(!ts.hasDynamicName(node)); - var isDefaultExport = node.flags & 1024; - var name = isDefaultExport && parent ? "default" : getDeclarationName(node); - var symbol; - if (name !== undefined) { - symbol = ts.hasProperty(symbolTable, name) - ? symbolTable[name] - : (symbolTable[name] = createSymbol(0, name)); - if (name && (includes & 788448)) { - classifiableNames[name] = name; - } - if (symbol.flags & excludes) { - if (node.name) { - node.name.parent = node; - } - var message = symbol.flags & 2 - ? ts.Diagnostics.Cannot_redeclare_block_scoped_variable_0 - : ts.Diagnostics.Duplicate_identifier_0; - ts.forEach(symbol.declarations, function (declaration) { - if (declaration.flags & 1024) { - message = ts.Diagnostics.A_module_cannot_have_multiple_default_exports; - } - }); - ts.forEach(symbol.declarations, function (declaration) { - file.bindDiagnostics.push(ts.createDiagnosticForNode(declaration.name || declaration, message, getDisplayName(declaration))); - }); - file.bindDiagnostics.push(ts.createDiagnosticForNode(node.name || node, message, getDisplayName(node))); - symbol = createSymbol(0, name); - } - } - else { - symbol = createSymbol(0, "__missing"); - } - addDeclarationToSymbol(symbol, node, includes); - symbol.parent = parent; - return symbol; - } - function declareModuleMember(node, symbolFlags, symbolExcludes) { - var hasExportModifier = ts.getCombinedNodeFlags(node) & 1; - if (symbolFlags & 8388608) { - if (node.kind === 230 || (node.kind === 221 && hasExportModifier)) { - return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); - } - else { - return declareSymbol(container.locals, undefined, node, symbolFlags, symbolExcludes); - } - } - else { - if (hasExportModifier || container.flags & 262144) { - var exportKind = (symbolFlags & 107455 ? 1048576 : 0) | - (symbolFlags & 793056 ? 2097152 : 0) | - (symbolFlags & 1536 ? 4194304 : 0); - var 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); - } - } - } - function bindChildren(node) { - var saveParent = parent; - var saveContainer = container; - var savedBlockScopeContainer = blockScopeContainer; - parent = node; - var containerFlags = getContainerFlags(node); - if (containerFlags & 1) { - container = blockScopeContainer = node; - if (containerFlags & 4) { - container.locals = {}; - } - addToContainerChain(container); - } - else if (containerFlags & 2) { - blockScopeContainer = node; - blockScopeContainer.locals = undefined; - } - if (node.kind === 215) { - seenThisKeyword = false; - ts.forEachChild(node, bind); - node.flags = seenThisKeyword ? node.flags | 524288 : node.flags & ~524288; - } - else { - ts.forEachChild(node, bind); - } - container = saveContainer; - parent = saveParent; - blockScopeContainer = savedBlockScopeContainer; - } - function getContainerFlags(node) { - switch (node.kind) { - case 186: - case 214: - case 215: - case 217: - case 155: - case 165: - return 1; - case 147: - case 148: - case 149: - case 143: - case 142: - case 213: - case 144: - case 145: - case 146: - case 152: - case 153: - case 173: - case 174: - case 218: - case 248: - case 216: - return 5; - case 244: - case 199: - case 200: - case 201: - case 220: - return 2; - case 192: - return ts.isFunctionLike(node.parent) ? 0 : 2; - } - return 0; - } - function addToContainerChain(next) { - if (lastContainer) { - lastContainer.nextContainer = next; - } - lastContainer = next; - } - function declareSymbolAndAddToSymbolTable(node, symbolFlags, symbolExcludes) { - declareSymbolAndAddToSymbolTableWorker(node, symbolFlags, symbolExcludes); - } - function declareSymbolAndAddToSymbolTableWorker(node, symbolFlags, symbolExcludes) { - switch (container.kind) { - case 218: - return declareModuleMember(node, symbolFlags, symbolExcludes); - case 248: - return declareSourceFileMember(node, symbolFlags, symbolExcludes); - case 186: - case 214: - return declareClassMember(node, symbolFlags, symbolExcludes); - case 217: - return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); - case 155: - case 165: - case 215: - return declareSymbol(container.symbol.members, container.symbol, node, symbolFlags, symbolExcludes); - case 152: - case 153: - case 147: - case 148: - case 149: - case 143: - case 142: - case 144: - case 145: - case 146: - case 213: - case 173: - case 174: - case 216: - return declareSymbol(container.locals, undefined, node, symbolFlags, symbolExcludes); - } - } - function declareClassMember(node, symbolFlags, symbolExcludes) { - return node.flags & 128 - ? declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes) - : declareSymbol(container.symbol.members, container.symbol, node, symbolFlags, symbolExcludes); - } - function declareSourceFileMember(node, symbolFlags, symbolExcludes) { - return ts.isExternalModule(file) - ? declareModuleMember(node, symbolFlags, symbolExcludes) - : declareSymbol(file.locals, undefined, node, symbolFlags, symbolExcludes); - } - function isAmbientContext(node) { - while (node) { - if (node.flags & 2) { - return true; - } - node = node.parent; - } - return false; - } - function hasExportDeclarations(node) { - var body = node.kind === 248 ? node : node.body; - if (body.kind === 248 || body.kind === 219) { - for (var _i = 0, _a = body.statements; _i < _a.length; _i++) { - var stat = _a[_i]; - if (stat.kind === 228 || stat.kind === 227) { - return true; - } - } - } - return false; - } - function setExportContextFlag(node) { - if (isAmbientContext(node) && !hasExportDeclarations(node)) { - node.flags |= 262144; - } - else { - node.flags &= ~262144; - } - } - function bindModuleDeclaration(node) { - setExportContextFlag(node); - if (node.name.kind === 9) { - declareSymbolAndAddToSymbolTable(node, 512, 106639); - } - else { - var state = getModuleInstanceState(node); - if (state === 0) { - declareSymbolAndAddToSymbolTable(node, 1024, 0); - } - else { - declareSymbolAndAddToSymbolTable(node, 512, 106639); - if (node.symbol.flags & (16 | 32 | 256)) { - node.symbol.constEnumOnlyModule = false; - } - else { - var currentModuleIsConstEnumOnly = state === 2; - if (node.symbol.constEnumOnlyModule === undefined) { - node.symbol.constEnumOnlyModule = currentModuleIsConstEnumOnly; - } - else { - node.symbol.constEnumOnlyModule = node.symbol.constEnumOnlyModule && currentModuleIsConstEnumOnly; - } - } - } - } - } - function bindFunctionOrConstructorType(node) { - var symbol = createSymbol(131072, getDeclarationName(node)); - addDeclarationToSymbol(symbol, node, 131072); - var typeLiteralSymbol = createSymbol(2048, "__type"); - addDeclarationToSymbol(typeLiteralSymbol, node, 2048); - typeLiteralSymbol.members = (_a = {}, _a[symbol.name] = symbol, _a); - var _a; - } - function bindObjectLiteralExpression(node) { - if (inStrictMode) { - var seen = {}; - for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { - var prop = _a[_i]; - if (prop.name.kind !== 69) { - continue; - } - var identifier = prop.name; - var currentKind = prop.kind === 245 || prop.kind === 246 || prop.kind === 143 - ? 1 - : 2; - var existingKind = seen[identifier.text]; - if (!existingKind) { - seen[identifier.text] = currentKind; - continue; - } - if (currentKind === 1 && existingKind === 1) { - var span = ts.getErrorSpanForNode(file, identifier); - file.bindDiagnostics.push(ts.createFileDiagnostic(file, span.start, span.length, ts.Diagnostics.An_object_literal_cannot_have_multiple_properties_with_the_same_name_in_strict_mode)); - } - } - } - return bindAnonymousDeclaration(node, 4096, "__object"); - } - function bindAnonymousDeclaration(node, symbolFlags, name) { - var symbol = createSymbol(symbolFlags, name); - addDeclarationToSymbol(symbol, node, symbolFlags); - } - function bindBlockScopedDeclaration(node, symbolFlags, symbolExcludes) { - switch (blockScopeContainer.kind) { - case 218: - declareModuleMember(node, symbolFlags, symbolExcludes); - break; - case 248: - if (ts.isExternalModule(container)) { - declareModuleMember(node, symbolFlags, symbolExcludes); - break; - } - default: - if (!blockScopeContainer.locals) { - blockScopeContainer.locals = {}; - addToContainerChain(blockScopeContainer); - } - declareSymbol(blockScopeContainer.locals, undefined, node, symbolFlags, symbolExcludes); - } - } - function bindBlockScopedVariableDeclaration(node) { - bindBlockScopedDeclaration(node, 2, 107455); - } - function checkStrictModeIdentifier(node) { - if (inStrictMode && - node.originalKeywordKind >= 106 && - node.originalKeywordKind <= 114 && - !ts.isIdentifierName(node)) { - if (!file.parseDiagnostics.length) { - file.bindDiagnostics.push(ts.createDiagnosticForNode(node, getStrictModeIdentifierMessage(node), ts.declarationNameToString(node))); - } - } - } - function getStrictModeIdentifierMessage(node) { - if (ts.getContainingClass(node)) { - return ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_strict_mode; - } - if (file.externalModuleIndicator) { - return ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode_Modules_are_automatically_in_strict_mode; - } - return ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode; - } - function checkStrictModeBinaryExpression(node) { - if (inStrictMode && ts.isLeftHandSideExpression(node.left) && ts.isAssignmentOperator(node.operatorToken.kind)) { - checkStrictModeEvalOrArguments(node, node.left); - } - } - function checkStrictModeCatchClause(node) { - if (inStrictMode && node.variableDeclaration) { - checkStrictModeEvalOrArguments(node, node.variableDeclaration.name); - } - } - function checkStrictModeDeleteExpression(node) { - if (inStrictMode && node.expression.kind === 69) { - var span = ts.getErrorSpanForNode(file, node.expression); - file.bindDiagnostics.push(ts.createFileDiagnostic(file, span.start, span.length, ts.Diagnostics.delete_cannot_be_called_on_an_identifier_in_strict_mode)); - } - } - function isEvalOrArgumentsIdentifier(node) { - return node.kind === 69 && - (node.text === "eval" || node.text === "arguments"); - } - function checkStrictModeEvalOrArguments(contextNode, name) { - if (name && name.kind === 69) { - var identifier = name; - if (isEvalOrArgumentsIdentifier(identifier)) { - var span = ts.getErrorSpanForNode(file, name); - file.bindDiagnostics.push(ts.createFileDiagnostic(file, span.start, span.length, getStrictModeEvalOrArgumentsMessage(contextNode), identifier.text)); - } - } - } - function getStrictModeEvalOrArgumentsMessage(node) { - if (ts.getContainingClass(node)) { - return ts.Diagnostics.Invalid_use_of_0_Class_definitions_are_automatically_in_strict_mode; - } - if (file.externalModuleIndicator) { - return ts.Diagnostics.Invalid_use_of_0_Modules_are_automatically_in_strict_mode; - } - return ts.Diagnostics.Invalid_use_of_0_in_strict_mode; - } - function checkStrictModeFunctionName(node) { - if (inStrictMode) { - checkStrictModeEvalOrArguments(node, node.name); - } - } - function checkStrictModeNumericLiteral(node) { - if (inStrictMode && node.flags & 65536) { - file.bindDiagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.Octal_literals_are_not_allowed_in_strict_mode)); - } - } - function checkStrictModePostfixUnaryExpression(node) { - if (inStrictMode) { - checkStrictModeEvalOrArguments(node, node.operand); - } - } - function checkStrictModePrefixUnaryExpression(node) { - if (inStrictMode) { - if (node.operator === 41 || node.operator === 42) { - checkStrictModeEvalOrArguments(node, node.operand); - } - } - } - function checkStrictModeWithStatement(node) { - if (inStrictMode) { - grammarErrorOnFirstToken(node, ts.Diagnostics.with_statements_are_not_allowed_in_strict_mode); - } - } - function grammarErrorOnFirstToken(node, message, arg0, arg1, arg2) { - var span = ts.getSpanOfTokenAtPosition(file, node.pos); - file.bindDiagnostics.push(ts.createFileDiagnostic(file, span.start, span.length, message, arg0, arg1, arg2)); - } - function getDestructuringParameterName(node) { - return "__" + ts.indexOf(node.parent.parameters, node); - } - function bind(node) { - node.parent = parent; - var savedInStrictMode = inStrictMode; - if (!savedInStrictMode) { - updateStrictMode(node); - } - bindWorker(node); - bindChildren(node); - inStrictMode = savedInStrictMode; - } - function updateStrictMode(node) { - switch (node.kind) { - case 248: - case 219: - updateStrictModeStatementList(node.statements); - return; - case 192: - if (ts.isFunctionLike(node.parent)) { - updateStrictModeStatementList(node.statements); - } - return; - case 214: - case 186: - inStrictMode = true; - return; - } - } - function updateStrictModeStatementList(statements) { - for (var _i = 0; _i < statements.length; _i++) { - var statement = statements[_i]; - if (!ts.isPrologueDirective(statement)) { - return; - } - if (isUseStrictPrologueDirective(statement)) { - inStrictMode = true; - return; - } - } - } - function isUseStrictPrologueDirective(node) { - var nodeText = ts.getTextOfNodeFromSourceText(file.text, node.expression); - return nodeText === "\"use strict\"" || nodeText === "'use strict'"; - } - function bindWorker(node) { - switch (node.kind) { - case 69: - return checkStrictModeIdentifier(node); - case 181: - return checkStrictModeBinaryExpression(node); - case 244: - return checkStrictModeCatchClause(node); - case 175: - return checkStrictModeDeleteExpression(node); - case 8: - return checkStrictModeNumericLiteral(node); - case 180: - return checkStrictModePostfixUnaryExpression(node); - case 179: - return checkStrictModePrefixUnaryExpression(node); - case 205: - return checkStrictModeWithStatement(node); - case 97: - seenThisKeyword = true; - return; - case 137: - return declareSymbolAndAddToSymbolTable(node, 262144, 530912); - case 138: - return bindParameter(node); - case 211: - case 163: - return bindVariableDeclarationOrBindingElement(node); - case 141: - case 140: - return bindPropertyOrMethodOrAccessor(node, 4 | (node.questionToken ? 536870912 : 0), 107455); - case 245: - case 246: - return bindPropertyOrMethodOrAccessor(node, 4, 107455); - case 247: - return bindPropertyOrMethodOrAccessor(node, 8, 107455); - case 147: - case 148: - case 149: - return declareSymbolAndAddToSymbolTable(node, 131072, 0); - case 143: - case 142: - return bindPropertyOrMethodOrAccessor(node, 8192 | (node.questionToken ? 536870912 : 0), ts.isObjectLiteralMethod(node) ? 107455 : 99263); - case 213: - checkStrictModeFunctionName(node); - return declareSymbolAndAddToSymbolTable(node, 16, 106927); - case 144: - return declareSymbolAndAddToSymbolTable(node, 16384, 0); - case 145: - return bindPropertyOrMethodOrAccessor(node, 32768, 41919); - case 146: - return bindPropertyOrMethodOrAccessor(node, 65536, 74687); - case 152: - case 153: - return bindFunctionOrConstructorType(node); - case 155: - return bindAnonymousDeclaration(node, 2048, "__type"); - case 165: - return bindObjectLiteralExpression(node); - case 173: - case 174: - checkStrictModeFunctionName(node); - var bindingName = node.name ? node.name.text : "__function"; - return bindAnonymousDeclaration(node, 16, bindingName); - case 186: - case 214: - return bindClassLikeDeclaration(node); - case 215: - return bindBlockScopedDeclaration(node, 64, 792960); - case 216: - return bindBlockScopedDeclaration(node, 524288, 793056); - case 217: - return bindEnumDeclaration(node); - case 218: - return bindModuleDeclaration(node); - case 221: - case 224: - case 226: - case 230: - return declareSymbolAndAddToSymbolTable(node, 8388608, 8388608); - case 223: - return bindImportClause(node); - case 228: - return bindExportDeclaration(node); - case 227: - return bindExportAssignment(node); - case 248: - return bindSourceFileIfExternalModule(); - } - } - function bindSourceFileIfExternalModule() { - setExportContextFlag(file); - if (ts.isExternalModule(file)) { - bindAnonymousDeclaration(file, 512, "\"" + ts.removeFileExtension(file.fileName) + "\""); - } - } - function bindExportAssignment(node) { - if (!container.symbol || !container.symbol.exports) { - bindAnonymousDeclaration(node, 8388608, getDeclarationName(node)); - } - else if (node.expression.kind === 69) { - declareSymbol(container.symbol.exports, container.symbol, node, 8388608, 107455 | 8388608); - } - else { - declareSymbol(container.symbol.exports, container.symbol, node, 4, 107455 | 8388608); - } - } - function bindExportDeclaration(node) { - if (!container.symbol || !container.symbol.exports) { - bindAnonymousDeclaration(node, 1073741824, getDeclarationName(node)); - } - else if (!node.exportClause) { - declareSymbol(container.symbol.exports, container.symbol, node, 1073741824, 0); - } - } - function bindImportClause(node) { - if (node.name) { - declareSymbolAndAddToSymbolTable(node, 8388608, 8388608); - } - } - function bindClassLikeDeclaration(node) { - if (node.kind === 214) { - bindBlockScopedDeclaration(node, 32, 899519); - } - else { - var bindingName = node.name ? node.name.text : "__class"; - bindAnonymousDeclaration(node, 32, bindingName); - if (node.name) { - classifiableNames[node.name.text] = node.name.text; - } - } - var symbol = node.symbol; - var prototypeSymbol = createSymbol(4 | 134217728, "prototype"); - if (ts.hasProperty(symbol.exports, prototypeSymbol.name)) { - if (node.name) { - node.name.parent = node; - } - file.bindDiagnostics.push(ts.createDiagnosticForNode(symbol.exports[prototypeSymbol.name].declarations[0], ts.Diagnostics.Duplicate_identifier_0, prototypeSymbol.name)); - } - symbol.exports[prototypeSymbol.name] = prototypeSymbol; - prototypeSymbol.parent = symbol; - } - function bindEnumDeclaration(node) { - return ts.isConst(node) - ? bindBlockScopedDeclaration(node, 128, 899967) - : bindBlockScopedDeclaration(node, 256, 899327); - } - function bindVariableDeclarationOrBindingElement(node) { - if (inStrictMode) { - checkStrictModeEvalOrArguments(node, node.name); - } - if (!ts.isBindingPattern(node.name)) { - if (ts.isBlockOrCatchScoped(node)) { - bindBlockScopedVariableDeclaration(node); - } - else if (ts.isParameterDeclaration(node)) { - declareSymbolAndAddToSymbolTable(node, 1, 107455); - } - else { - declareSymbolAndAddToSymbolTable(node, 1, 107454); - } - } - } - function bindParameter(node) { - if (inStrictMode) { - checkStrictModeEvalOrArguments(node, node.name); - } - if (ts.isBindingPattern(node.name)) { - bindAnonymousDeclaration(node, 1, getDestructuringParameterName(node)); - } - else { - declareSymbolAndAddToSymbolTable(node, 1, 107455); - } - if (node.flags & 112 && - node.parent.kind === 144 && - ts.isClassLike(node.parent.parent)) { - var classDeclaration = node.parent.parent; - declareSymbol(classDeclaration.symbol.members, classDeclaration.symbol, node, 4, 107455); - } - } - function bindPropertyOrMethodOrAccessor(node, symbolFlags, symbolExcludes) { - return ts.hasDynamicName(node) - ? bindAnonymousDeclaration(node, symbolFlags, "__computed") - : declareSymbolAndAddToSymbolTable(node, symbolFlags, symbolExcludes); - } - } -})(ts || (ts = {})); -var ts; -(function (ts) { - var nextSymbolId = 1; - var nextNodeId = 1; - var nextMergeId = 1; - function getNodeId(node) { - if (!node.id) - node.id = nextNodeId++; - return node.id; - } - ts.getNodeId = getNodeId; - ts.checkTime = 0; - function getSymbolId(symbol) { - if (!symbol.id) { - symbol.id = nextSymbolId++; - } - return symbol.id; - } - ts.getSymbolId = getSymbolId; - function createTypeChecker(host, produceDiagnostics) { - var cancellationToken; - var Symbol = ts.objectAllocator.getSymbolConstructor(); - var Type = ts.objectAllocator.getTypeConstructor(); - var Signature = ts.objectAllocator.getSignatureConstructor(); - var typeCount = 0; - var symbolCount = 0; - var emptyArray = []; - var emptySymbols = {}; - var compilerOptions = host.getCompilerOptions(); - var languageVersion = compilerOptions.target || 0; - var modulekind = compilerOptions.module ? compilerOptions.module : languageVersion === 2 ? 5 : 0; - var emitResolver = createResolver(); - var undefinedSymbol = createSymbol(4 | 67108864, "undefined"); - var argumentsSymbol = createSymbol(4 | 67108864, "arguments"); - var checker = { - getNodeCount: function () { return ts.sum(host.getSourceFiles(), "nodeCount"); }, - getIdentifierCount: function () { return ts.sum(host.getSourceFiles(), "identifierCount"); }, - getSymbolCount: function () { return ts.sum(host.getSourceFiles(), "symbolCount") + symbolCount; }, - getTypeCount: function () { return typeCount; }, - isUndefinedSymbol: function (symbol) { return symbol === undefinedSymbol; }, - isArgumentsSymbol: function (symbol) { return symbol === argumentsSymbol; }, - getDiagnostics: getDiagnostics, - getGlobalDiagnostics: getGlobalDiagnostics, - getTypeOfSymbolAtLocation: getNarrowedTypeOfSymbol, - getDeclaredTypeOfSymbol: getDeclaredTypeOfSymbol, - getPropertiesOfType: getPropertiesOfType, - getPropertyOfType: getPropertyOfType, - getSignaturesOfType: getSignaturesOfType, - getIndexTypeOfType: getIndexTypeOfType, - getBaseTypes: getBaseTypes, - getReturnTypeOfSignature: getReturnTypeOfSignature, - getSymbolsInScope: getSymbolsInScope, - getSymbolAtLocation: getSymbolAtLocation, - getShorthandAssignmentValueSymbol: getShorthandAssignmentValueSymbol, - getTypeAtLocation: getTypeOfNode, - typeToString: typeToString, - getSymbolDisplayBuilder: getSymbolDisplayBuilder, - symbolToString: symbolToString, - getAugmentedPropertiesOfType: getAugmentedPropertiesOfType, - getRootSymbols: getRootSymbols, - getContextualType: getContextualType, - getFullyQualifiedName: getFullyQualifiedName, - getResolvedSignature: getResolvedSignature, - getConstantValue: getConstantValue, - isValidPropertyAccess: isValidPropertyAccess, - getSignatureFromDeclaration: getSignatureFromDeclaration, - isImplementationOfOverload: isImplementationOfOverload, - getAliasedSymbol: resolveAlias, - getEmitResolver: getEmitResolver, - getExportsOfModule: getExportsOfModuleAsArray, - getJsxElementAttributesType: getJsxElementAttributesType, - getJsxIntrinsicTagNames: getJsxIntrinsicTagNames, - isOptionalParameter: isOptionalParameter - }; - var unknownSymbol = createSymbol(4 | 67108864, "unknown"); - var resolvingSymbol = createSymbol(67108864, "__resolving__"); - var anyType = createIntrinsicType(1, "any"); - var stringType = createIntrinsicType(2, "string"); - var numberType = createIntrinsicType(4, "number"); - var booleanType = createIntrinsicType(8, "boolean"); - var esSymbolType = createIntrinsicType(16777216, "symbol"); - var voidType = createIntrinsicType(16, "void"); - var undefinedType = createIntrinsicType(32 | 2097152, "undefined"); - var nullType = createIntrinsicType(64 | 2097152, "null"); - var unknownType = createIntrinsicType(1, "unknown"); - var circularType = createIntrinsicType(1, "__circular__"); - var emptyObjectType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); - var emptyGenericType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); - emptyGenericType.instantiations = {}; - var anyFunctionType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); - anyFunctionType.flags |= 8388608; - var noConstraintType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); - var anySignature = createSignature(undefined, undefined, emptyArray, anyType, undefined, 0, false, false); - var unknownSignature = createSignature(undefined, undefined, emptyArray, unknownType, undefined, 0, false, false); - var globals = {}; - var globalESSymbolConstructorSymbol; - var getGlobalPromiseConstructorSymbol; - var globalObjectType; - var globalFunctionType; - var globalArrayType; - var globalStringType; - var globalNumberType; - var globalBooleanType; - var globalRegExpType; - var globalTemplateStringsArrayType; - var globalESSymbolType; - var jsxElementType; - var jsxIntrinsicElementsType; - var globalIterableType; - var globalIteratorType; - var globalIterableIteratorType; - var anyArrayType; - var getGlobalClassDecoratorType; - var getGlobalParameterDecoratorType; - var getGlobalPropertyDecoratorType; - var getGlobalMethodDecoratorType; - var getGlobalTypedPropertyDescriptorType; - var getGlobalPromiseType; - var tryGetGlobalPromiseType; - var getGlobalPromiseLikeType; - var getInstantiatedGlobalPromiseLikeType; - var getGlobalPromiseConstructorLikeType; - var getGlobalThenableType; - var tupleTypes = {}; - var unionTypes = {}; - var intersectionTypes = {}; - var stringLiteralTypes = {}; - var emitExtends = false; - var emitDecorate = false; - var emitParam = false; - var emitAwaiter = false; - var emitGenerator = false; - var resolutionTargets = []; - var resolutionResults = []; - var resolutionPropertyNames = []; - var mergedSymbols = []; - var symbolLinks = []; - var nodeLinks = []; - var potentialThisCollisions = []; - var awaitedTypeStack = []; - var diagnostics = ts.createDiagnosticCollection(); - var primitiveTypeInfo = { - "string": { - type: stringType, - flags: 258 - }, - "number": { - type: numberType, - flags: 132 - }, - "boolean": { - type: booleanType, - flags: 8 - }, - "symbol": { - type: esSymbolType, - flags: 16777216 - } - }; - var JsxNames = { - JSX: "JSX", - IntrinsicElements: "IntrinsicElements", - ElementClass: "ElementClass", - ElementAttributesPropertyNameContainer: "ElementAttributesProperty", - Element: "Element" - }; - var subtypeRelation = {}; - var assignableRelation = {}; - var identityRelation = {}; - var _displayBuilder; - initializeTypeChecker(); - return checker; - function getEmitResolver(sourceFile, cancellationToken) { - getDiagnostics(sourceFile, cancellationToken); - return emitResolver; - } - function error(location, message, arg0, arg1, arg2) { - var diagnostic = location - ? ts.createDiagnosticForNode(location, message, arg0, arg1, arg2) - : ts.createCompilerDiagnostic(message, arg0, arg1, arg2); - diagnostics.add(diagnostic); - } - function createSymbol(flags, name) { - symbolCount++; - return new Symbol(flags, name); - } - function getExcludedSymbolFlags(flags) { - var result = 0; - if (flags & 2) - result |= 107455; - if (flags & 1) - result |= 107454; - if (flags & 4) - result |= 107455; - if (flags & 8) - result |= 107455; - if (flags & 16) - result |= 106927; - if (flags & 32) - result |= 899519; - if (flags & 64) - result |= 792960; - if (flags & 256) - result |= 899327; - if (flags & 128) - result |= 899967; - if (flags & 512) - result |= 106639; - if (flags & 8192) - result |= 99263; - if (flags & 32768) - result |= 41919; - if (flags & 65536) - result |= 74687; - if (flags & 262144) - result |= 530912; - if (flags & 524288) - result |= 793056; - if (flags & 8388608) - result |= 8388608; - return result; - } - function recordMergedSymbol(target, source) { - if (!source.mergeId) - source.mergeId = nextMergeId++; - mergedSymbols[source.mergeId] = target; - } - function cloneSymbol(symbol) { - var result = createSymbol(symbol.flags | 33554432, symbol.name); - result.declarations = symbol.declarations.slice(0); - result.parent = symbol.parent; - if (symbol.valueDeclaration) - result.valueDeclaration = symbol.valueDeclaration; - if (symbol.constEnumOnlyModule) - result.constEnumOnlyModule = true; - if (symbol.members) - result.members = cloneSymbolTable(symbol.members); - if (symbol.exports) - result.exports = cloneSymbolTable(symbol.exports); - recordMergedSymbol(result, symbol); - return result; - } - function mergeSymbol(target, source) { - if (!(target.flags & getExcludedSymbolFlags(source.flags))) { - if (source.flags & 512 && target.flags & 512 && target.constEnumOnlyModule && !source.constEnumOnlyModule) { - target.constEnumOnlyModule = false; - } - target.flags |= source.flags; - if (!target.valueDeclaration && source.valueDeclaration) - target.valueDeclaration = source.valueDeclaration; - ts.forEach(source.declarations, function (node) { - target.declarations.push(node); - }); - if (source.members) { - if (!target.members) - target.members = {}; - mergeSymbolTable(target.members, source.members); - } - if (source.exports) { - if (!target.exports) - target.exports = {}; - mergeSymbolTable(target.exports, source.exports); - } - recordMergedSymbol(target, source); - } - else { - var message = target.flags & 2 || source.flags & 2 - ? ts.Diagnostics.Cannot_redeclare_block_scoped_variable_0 : ts.Diagnostics.Duplicate_identifier_0; - ts.forEach(source.declarations, function (node) { - error(node.name ? node.name : node, message, symbolToString(source)); - }); - ts.forEach(target.declarations, function (node) { - error(node.name ? node.name : node, message, symbolToString(source)); - }); - } - } - function cloneSymbolTable(symbolTable) { - var result = {}; - for (var id in symbolTable) { - if (ts.hasProperty(symbolTable, id)) { - result[id] = symbolTable[id]; - } - } - return result; - } - function mergeSymbolTable(target, source) { - for (var id in source) { - if (ts.hasProperty(source, id)) { - if (!ts.hasProperty(target, id)) { - target[id] = source[id]; - } - else { - var symbol = target[id]; - if (!(symbol.flags & 33554432)) { - target[id] = symbol = cloneSymbol(symbol); - } - mergeSymbol(symbol, source[id]); - } - } - } - } - function getSymbolLinks(symbol) { - if (symbol.flags & 67108864) - return symbol; - var id = getSymbolId(symbol); - return symbolLinks[id] || (symbolLinks[id] = {}); - } - function getNodeLinks(node) { - var nodeId = getNodeId(node); - return nodeLinks[nodeId] || (nodeLinks[nodeId] = {}); - } - function getSourceFile(node) { - return ts.getAncestor(node, 248); - } - function isGlobalSourceFile(node) { - return node.kind === 248 && !ts.isExternalModule(node); - } - function getSymbol(symbols, name, meaning) { - if (meaning && ts.hasProperty(symbols, name)) { - var symbol = symbols[name]; - ts.Debug.assert((symbol.flags & 16777216) === 0, "Should never get an instantiated symbol here."); - if (symbol.flags & meaning) { - return symbol; - } - if (symbol.flags & 8388608) { - var target = resolveAlias(symbol); - if (target === unknownSymbol || target.flags & meaning) { - return symbol; - } - } - } - } - function isBlockScopedNameDeclaredBeforeUse(declaration, usage) { - var declarationFile = ts.getSourceFileOfNode(declaration); - var useFile = ts.getSourceFileOfNode(usage); - if (declarationFile !== useFile) { - if (modulekind || (!compilerOptions.outFile && !compilerOptions.out)) { - return true; - } - var sourceFiles = host.getSourceFiles(); - return ts.indexOf(sourceFiles, declarationFile) <= ts.indexOf(sourceFiles, useFile); - } - if (declaration.pos <= usage.pos) { - return declaration.kind !== 211 || - !isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage); - } - return isUsedInFunctionOrNonStaticProperty(declaration, usage); - function isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage) { - var container = ts.getEnclosingBlockScopeContainer(declaration); - if (declaration.parent.parent.kind === 193 || - declaration.parent.parent.kind === 199) { - return isSameScopeDescendentOf(usage, declaration, container); - } - else if (declaration.parent.parent.kind === 201 || - declaration.parent.parent.kind === 200) { - var expression = declaration.parent.parent.expression; - return isSameScopeDescendentOf(usage, expression, container); - } - } - function isUsedInFunctionOrNonStaticProperty(declaration, usage) { - var container = ts.getEnclosingBlockScopeContainer(declaration); - var current = usage; - while (current) { - if (current === container) { - return false; - } - if (ts.isFunctionLike(current)) { - return true; - } - var initializerOfNonStaticProperty = current.parent && - current.parent.kind === 141 && - (current.parent.flags & 128) === 0 && - current.parent.initializer === current; - if (initializerOfNonStaticProperty) { - return true; - } - current = current.parent; - } - return false; - } - } - function resolveName(location, name, meaning, nameNotFoundMessage, nameArg) { - var result; - var lastLocation; - var propertyWithInvalidInitializer; - var errorLocation = location; - var grandparent; - loop: while (location) { - if (location.locals && !isGlobalSourceFile(location)) { - if (result = getSymbol(location.locals, name, meaning)) { - if (!(meaning & 793056) || - !(result.flags & (793056 & ~262144)) || - !ts.isFunctionLike(location) || - lastLocation === location.body) { - break loop; - } - result = undefined; - } - } - switch (location.kind) { - case 248: - if (!ts.isExternalModule(location)) - break; - case 218: - var moduleExports = getSymbolOfNode(location).exports; - if (location.kind === 248 || - (location.kind === 218 && location.name.kind === 9)) { - if (ts.hasProperty(moduleExports, name) && - moduleExports[name].flags === 8388608 && - ts.getDeclarationOfKind(moduleExports[name], 230)) { - break; - } - result = moduleExports["default"]; - var localSymbol = ts.getLocalSymbolForExportDefault(result); - if (result && localSymbol && (result.flags & meaning) && localSymbol.name === name) { - break loop; - } - result = undefined; - } - if (result = getSymbol(moduleExports, name, meaning & 8914931)) { - break loop; - } - break; - case 217: - if (result = getSymbol(getSymbolOfNode(location).exports, name, meaning & 8)) { - break loop; - } - break; - case 141: - case 140: - if (ts.isClassLike(location.parent) && !(location.flags & 128)) { - var ctor = findConstructorDeclaration(location.parent); - if (ctor && ctor.locals) { - if (getSymbol(ctor.locals, name, meaning & 107455)) { - propertyWithInvalidInitializer = location; - } - } - } - break; - case 214: - case 186: - case 215: - if (result = getSymbol(getSymbolOfNode(location).members, name, meaning & 793056)) { - if (lastLocation && lastLocation.flags & 128) { - error(errorLocation, ts.Diagnostics.Static_members_cannot_reference_class_type_parameters); - return undefined; - } - break loop; - } - if (location.kind === 186 && meaning & 32) { - var className = location.name; - if (className && name === className.text) { - result = location.symbol; - break loop; - } - } - break; - case 136: - grandparent = location.parent.parent; - if (ts.isClassLike(grandparent) || grandparent.kind === 215) { - if (result = getSymbol(getSymbolOfNode(grandparent).members, name, meaning & 793056)) { - error(errorLocation, ts.Diagnostics.A_computed_property_name_cannot_reference_a_type_parameter_from_its_containing_type); - return undefined; - } - } - break; - case 143: - case 142: - case 144: - case 145: - case 146: - case 213: - case 174: - if (meaning & 3 && name === "arguments") { - result = argumentsSymbol; - break loop; - } - break; - case 173: - if (meaning & 3 && name === "arguments") { - result = argumentsSymbol; - break loop; - } - if (meaning & 16) { - var functionName = location.name; - if (functionName && name === functionName.text) { - result = location.symbol; - break loop; - } - } - break; - case 139: - if (location.parent && location.parent.kind === 138) { - location = location.parent; - } - if (location.parent && ts.isClassElement(location.parent)) { - location = location.parent; - } - break; - } - lastLocation = location; - location = location.parent; - } - if (!result) { - result = getSymbol(globals, name, meaning); - } - if (!result) { - if (nameNotFoundMessage) { - error(errorLocation, nameNotFoundMessage, typeof nameArg === "string" ? nameArg : ts.declarationNameToString(nameArg)); - } - return undefined; - } - if (nameNotFoundMessage) { - if (propertyWithInvalidInitializer) { - var propertyName = propertyWithInvalidInitializer.name; - error(errorLocation, ts.Diagnostics.Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor, ts.declarationNameToString(propertyName), typeof nameArg === "string" ? nameArg : ts.declarationNameToString(nameArg)); - return undefined; - } - if (meaning & 2) { - var exportOrLocalSymbol = getExportSymbolOfValueSymbolIfExported(result); - if (exportOrLocalSymbol.flags & 2) { - checkResolvedBlockScopedVariable(exportOrLocalSymbol, errorLocation); - } - } - } - return result; - } - function checkResolvedBlockScopedVariable(result, errorLocation) { - 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 (!isBlockScopedNameDeclaredBeforeUse(ts.getAncestor(declaration, 211), errorLocation)) { - error(errorLocation, ts.Diagnostics.Block_scoped_variable_0_used_before_its_declaration, ts.declarationNameToString(declaration.name)); - } - } - function isSameScopeDescendentOf(initial, parent, stopAt) { - if (!parent) { - return false; - } - for (var current = initial; current && current !== stopAt && !ts.isFunctionLike(current); current = current.parent) { - if (current === parent) { - return true; - } - } - return false; - } - function getAnyImportSyntax(node) { - if (ts.isAliasSymbolDeclaration(node)) { - if (node.kind === 221) { - return node; - } - while (node && node.kind !== 222) { - node = node.parent; - } - return node; - } - } - function getDeclarationOfAliasSymbol(symbol) { - return ts.forEach(symbol.declarations, function (d) { return ts.isAliasSymbolDeclaration(d) ? d : undefined; }); - } - function getTargetOfImportEqualsDeclaration(node) { - if (node.moduleReference.kind === 232) { - return resolveExternalModuleSymbol(resolveExternalModuleName(node, ts.getExternalModuleImportEqualsDeclarationExpression(node))); - } - return getSymbolOfPartOfRightHandSideOfImportEquals(node.moduleReference, node); - } - function getTargetOfImportClause(node) { - var moduleSymbol = resolveExternalModuleName(node, node.parent.moduleSpecifier); - if (moduleSymbol) { - var exportDefaultSymbol = resolveSymbol(moduleSymbol.exports["default"]); - if (!exportDefaultSymbol) { - error(node.name, ts.Diagnostics.Module_0_has_no_default_export, symbolToString(moduleSymbol)); - } - return exportDefaultSymbol; - } - } - function getTargetOfNamespaceImport(node) { - var moduleSpecifier = node.parent.parent.moduleSpecifier; - return resolveESModuleSymbol(resolveExternalModuleName(node, moduleSpecifier), moduleSpecifier); - } - function getMemberOfModuleVariable(moduleSymbol, name) { - if (moduleSymbol.flags & 3) { - var typeAnnotation = moduleSymbol.valueDeclaration.type; - if (typeAnnotation) { - return getPropertyOfType(getTypeFromTypeNode(typeAnnotation), name); - } - } - } - function combineValueAndTypeSymbols(valueSymbol, typeSymbol) { - if (valueSymbol.flags & (793056 | 1536)) { - return valueSymbol; - } - var result = createSymbol(valueSymbol.flags | typeSymbol.flags, valueSymbol.name); - result.declarations = ts.concatenate(valueSymbol.declarations, typeSymbol.declarations); - result.parent = valueSymbol.parent || typeSymbol.parent; - if (valueSymbol.valueDeclaration) - result.valueDeclaration = valueSymbol.valueDeclaration; - if (typeSymbol.members) - result.members = typeSymbol.members; - if (valueSymbol.exports) - result.exports = valueSymbol.exports; - return result; - } - function getExportOfModule(symbol, name) { - if (symbol.flags & 1536) { - var exports_1 = getExportsOfSymbol(symbol); - if (ts.hasProperty(exports_1, name)) { - return resolveSymbol(exports_1[name]); - } - } - } - function getPropertyOfVariable(symbol, name) { - if (symbol.flags & 3) { - var typeAnnotation = symbol.valueDeclaration.type; - if (typeAnnotation) { - return resolveSymbol(getPropertyOfType(getTypeFromTypeNode(typeAnnotation), name)); - } - } - } - function getExternalModuleMember(node, specifier) { - var moduleSymbol = resolveExternalModuleName(node, node.moduleSpecifier); - var targetSymbol = resolveESModuleSymbol(moduleSymbol, node.moduleSpecifier); - if (targetSymbol) { - var name_10 = specifier.propertyName || specifier.name; - if (name_10.text) { - var symbolFromModule = getExportOfModule(targetSymbol, name_10.text); - var symbolFromVariable = getPropertyOfVariable(targetSymbol, name_10.text); - var symbol = symbolFromModule && symbolFromVariable ? - combineValueAndTypeSymbols(symbolFromVariable, symbolFromModule) : - symbolFromModule || symbolFromVariable; - if (!symbol) { - error(name_10, ts.Diagnostics.Module_0_has_no_exported_member_1, getFullyQualifiedName(moduleSymbol), ts.declarationNameToString(name_10)); - } - return symbol; - } - } - } - function getTargetOfImportSpecifier(node) { - return getExternalModuleMember(node.parent.parent.parent, node); - } - function getTargetOfExportSpecifier(node) { - return node.parent.parent.moduleSpecifier ? - getExternalModuleMember(node.parent.parent, node) : - resolveEntityName(node.propertyName || node.name, 107455 | 793056 | 1536); - } - function getTargetOfExportAssignment(node) { - return resolveEntityName(node.expression, 107455 | 793056 | 1536); - } - function getTargetOfAliasDeclaration(node) { - switch (node.kind) { - case 221: - return getTargetOfImportEqualsDeclaration(node); - case 223: - return getTargetOfImportClause(node); - case 224: - return getTargetOfNamespaceImport(node); - case 226: - return getTargetOfImportSpecifier(node); - case 230: - return getTargetOfExportSpecifier(node); - case 227: - return getTargetOfExportAssignment(node); - } - } - function resolveSymbol(symbol) { - return symbol && symbol.flags & 8388608 && !(symbol.flags & (107455 | 793056 | 1536)) ? resolveAlias(symbol) : symbol; - } - function resolveAlias(symbol) { - ts.Debug.assert((symbol.flags & 8388608) !== 0, "Should only get Alias here."); - var links = getSymbolLinks(symbol); - if (!links.target) { - links.target = resolvingSymbol; - var node = getDeclarationOfAliasSymbol(symbol); - var target = getTargetOfAliasDeclaration(node); - if (links.target === resolvingSymbol) { - links.target = target || unknownSymbol; - } - else { - error(node, ts.Diagnostics.Circular_definition_of_import_alias_0, symbolToString(symbol)); - } - } - else if (links.target === resolvingSymbol) { - links.target = unknownSymbol; - } - return links.target; - } - function markExportAsReferenced(node) { - var symbol = getSymbolOfNode(node); - var target = resolveAlias(symbol); - if (target) { - var markAlias = (target === unknownSymbol && compilerOptions.isolatedModules) || - (target !== unknownSymbol && (target.flags & 107455) && !isConstEnumOrConstEnumOnlyModule(target)); - if (markAlias) { - markAliasSymbolAsReferenced(symbol); - } - } - } - function markAliasSymbolAsReferenced(symbol) { - var links = getSymbolLinks(symbol); - if (!links.referenced) { - links.referenced = true; - var node = getDeclarationOfAliasSymbol(symbol); - if (node.kind === 227) { - checkExpressionCached(node.expression); - } - else if (node.kind === 230) { - checkExpressionCached(node.propertyName || node.name); - } - else if (ts.isInternalModuleImportEqualsDeclaration(node)) { - checkExpressionCached(node.moduleReference); - } - } - } - function getSymbolOfPartOfRightHandSideOfImportEquals(entityName, importDeclaration) { - if (!importDeclaration) { - importDeclaration = ts.getAncestor(entityName, 221); - ts.Debug.assert(importDeclaration !== undefined); - } - if (entityName.kind === 69 && ts.isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { - entityName = entityName.parent; - } - if (entityName.kind === 69 || entityName.parent.kind === 135) { - return resolveEntityName(entityName, 1536); - } - else { - ts.Debug.assert(entityName.parent.kind === 221); - return resolveEntityName(entityName, 107455 | 793056 | 1536); - } - } - function getFullyQualifiedName(symbol) { - return symbol.parent ? getFullyQualifiedName(symbol.parent) + "." + symbolToString(symbol) : symbolToString(symbol); - } - function resolveEntityName(name, meaning, ignoreErrors) { - if (ts.nodeIsMissing(name)) { - return undefined; - } - var symbol; - if (name.kind === 69) { - var message = meaning === 1536 ? ts.Diagnostics.Cannot_find_namespace_0 : ts.Diagnostics.Cannot_find_name_0; - symbol = resolveName(name, name.text, meaning, ignoreErrors ? undefined : message, name); - if (!symbol) { - return undefined; - } - } - else if (name.kind === 135 || name.kind === 166) { - var left = name.kind === 135 ? name.left : name.expression; - var right = name.kind === 135 ? name.right : name.name; - var namespace = resolveEntityName(left, 1536, ignoreErrors); - if (!namespace || namespace === unknownSymbol || ts.nodeIsMissing(right)) { - return undefined; - } - symbol = getSymbol(getExportsOfSymbol(namespace), right.text, meaning); - if (!symbol) { - if (!ignoreErrors) { - error(right, ts.Diagnostics.Module_0_has_no_exported_member_1, getFullyQualifiedName(namespace), ts.declarationNameToString(right)); - } - return undefined; - } - } - else { - ts.Debug.fail("Unknown entity name kind."); - } - ts.Debug.assert((symbol.flags & 16777216) === 0, "Should never get an instantiated symbol here."); - return symbol.flags & meaning ? symbol : resolveAlias(symbol); - } - function resolveExternalModuleName(location, moduleReferenceExpression) { - if (moduleReferenceExpression.kind !== 9) { - return; - } - var moduleReferenceLiteral = moduleReferenceExpression; - var searchPath = ts.getDirectoryPath(getSourceFile(location).fileName); - var moduleName = ts.escapeIdentifier(moduleReferenceLiteral.text); - if (moduleName === undefined) { - return; - } - var isRelative = ts.isExternalModuleNameRelative(moduleName); - if (!isRelative) { - var symbol = getSymbol(globals, "\"" + moduleName + "\"", 512); - if (symbol) { - return symbol; - } - } - var resolvedModule = ts.getResolvedModule(getSourceFile(location), moduleReferenceLiteral.text); - var sourceFile = resolvedModule && host.getSourceFile(resolvedModule.resolvedFileName); - if (sourceFile) { - if (sourceFile.symbol) { - return sourceFile.symbol; - } - error(moduleReferenceLiteral, ts.Diagnostics.File_0_is_not_a_module, sourceFile.fileName); - return; - } - error(moduleReferenceLiteral, ts.Diagnostics.Cannot_find_module_0, moduleName); - } - function resolveExternalModuleSymbol(moduleSymbol) { - return moduleSymbol && resolveSymbol(moduleSymbol.exports["export="]) || moduleSymbol; - } - function resolveESModuleSymbol(moduleSymbol, moduleReferenceExpression) { - var symbol = resolveExternalModuleSymbol(moduleSymbol); - if (symbol && !(symbol.flags & (1536 | 3))) { - error(moduleReferenceExpression, ts.Diagnostics.Module_0_resolves_to_a_non_module_entity_and_cannot_be_imported_using_this_construct, symbolToString(moduleSymbol)); - symbol = undefined; - } - return symbol; - } - function getExportAssignmentSymbol(moduleSymbol) { - return moduleSymbol.exports["export="]; - } - function getExportsOfModuleAsArray(moduleSymbol) { - return symbolsToArray(getExportsOfModule(moduleSymbol)); - } - function getExportsOfSymbol(symbol) { - return symbol.flags & 1536 ? getExportsOfModule(symbol) : symbol.exports || emptySymbols; - } - function getExportsOfModule(moduleSymbol) { - var links = getSymbolLinks(moduleSymbol); - return links.resolvedExports || (links.resolvedExports = getExportsForModule(moduleSymbol)); - } - function extendExportSymbols(target, source) { - for (var id in source) { - if (id !== "default" && !ts.hasProperty(target, id)) { - target[id] = source[id]; - } - } - } - function getExportsForModule(moduleSymbol) { - var result; - var visitedSymbols = []; - visit(moduleSymbol); - return result || moduleSymbol.exports; - function visit(symbol) { - if (symbol && symbol.flags & 1952 && !ts.contains(visitedSymbols, symbol)) { - visitedSymbols.push(symbol); - if (symbol !== moduleSymbol) { - if (!result) { - result = cloneSymbolTable(moduleSymbol.exports); - } - extendExportSymbols(result, symbol.exports); - } - var exportStars = symbol.exports["__export"]; - if (exportStars) { - for (var _i = 0, _a = exportStars.declarations; _i < _a.length; _i++) { - var node = _a[_i]; - visit(resolveExternalModuleName(node, node.moduleSpecifier)); - } - } - } - } - } - function getMergedSymbol(symbol) { - var merged; - return symbol && symbol.mergeId && (merged = mergedSymbols[symbol.mergeId]) ? merged : symbol; - } - function getSymbolOfNode(node) { - return getMergedSymbol(node.symbol); - } - function getParentOfSymbol(symbol) { - return getMergedSymbol(symbol.parent); - } - function getExportSymbolOfValueSymbolIfExported(symbol) { - return symbol && (symbol.flags & 1048576) !== 0 - ? getMergedSymbol(symbol.exportSymbol) - : symbol; - } - function symbolIsValue(symbol) { - if (symbol.flags & 16777216) { - return symbolIsValue(getSymbolLinks(symbol).target); - } - if (symbol.flags & 107455) { - return true; - } - if (symbol.flags & 8388608) { - return (resolveAlias(symbol).flags & 107455) !== 0; - } - return false; - } - function findConstructorDeclaration(node) { - var members = node.members; - for (var _i = 0; _i < members.length; _i++) { - var member = members[_i]; - if (member.kind === 144 && ts.nodeIsPresent(member.body)) { - return member; - } - } - } - function createType(flags) { - var result = new Type(checker, flags); - result.id = typeCount++; - return result; - } - function createIntrinsicType(kind, intrinsicName) { - var type = createType(kind); - type.intrinsicName = intrinsicName; - return type; - } - function createObjectType(kind, symbol) { - var type = createType(kind); - type.symbol = symbol; - return type; - } - function isReservedMemberName(name) { - return name.charCodeAt(0) === 95 && - name.charCodeAt(1) === 95 && - name.charCodeAt(2) !== 95 && - name.charCodeAt(2) !== 64; - } - function getNamedMembers(members) { - var result; - for (var id in members) { - if (ts.hasProperty(members, id)) { - if (!isReservedMemberName(id)) { - if (!result) - result = []; - var symbol = members[id]; - if (symbolIsValue(symbol)) { - result.push(symbol); - } - } - } - } - return result || emptyArray; - } - function setObjectTypeMembers(type, members, callSignatures, constructSignatures, stringIndexType, numberIndexType) { - type.members = members; - type.properties = getNamedMembers(members); - type.callSignatures = callSignatures; - type.constructSignatures = constructSignatures; - if (stringIndexType) - type.stringIndexType = stringIndexType; - if (numberIndexType) - type.numberIndexType = numberIndexType; - return type; - } - function createAnonymousType(symbol, members, callSignatures, constructSignatures, stringIndexType, numberIndexType) { - return setObjectTypeMembers(createObjectType(65536, symbol), members, callSignatures, constructSignatures, stringIndexType, numberIndexType); - } - function forEachSymbolTableInScope(enclosingDeclaration, callback) { - var result; - for (var location_1 = enclosingDeclaration; location_1; location_1 = location_1.parent) { - if (location_1.locals && !isGlobalSourceFile(location_1)) { - if (result = callback(location_1.locals)) { - return result; - } - } - switch (location_1.kind) { - case 248: - if (!ts.isExternalModule(location_1)) { - break; - } - case 218: - if (result = callback(getSymbolOfNode(location_1).exports)) { - return result; - } - break; - case 214: - case 215: - if (result = callback(getSymbolOfNode(location_1).members)) { - return result; - } - break; - } - } - return callback(globals); - } - function getQualifiedLeftMeaning(rightMeaning) { - return rightMeaning === 107455 ? 107455 : 1536; - } - function getAccessibleSymbolChain(symbol, enclosingDeclaration, meaning, useOnlyExternalAliasing) { - function getAccessibleSymbolChainFromSymbolTable(symbols) { - function canQualifySymbol(symbolFromSymbolTable, meaning) { - if (!needsQualification(symbolFromSymbolTable, enclosingDeclaration, meaning)) { - return true; - } - var accessibleParent = getAccessibleSymbolChain(symbolFromSymbolTable.parent, enclosingDeclaration, getQualifiedLeftMeaning(meaning), useOnlyExternalAliasing); - return !!accessibleParent; - } - function isAccessible(symbolFromSymbolTable, resolvedAliasSymbol) { - if (symbol === (resolvedAliasSymbol || symbolFromSymbolTable)) { - return !ts.forEach(symbolFromSymbolTable.declarations, hasExternalModuleSymbol) && - canQualifySymbol(symbolFromSymbolTable, meaning); - } - } - if (isAccessible(ts.lookUp(symbols, symbol.name))) { - return [symbol]; - } - return ts.forEachValue(symbols, function (symbolFromSymbolTable) { - if (symbolFromSymbolTable.flags & 8388608 - && symbolFromSymbolTable.name !== "export=" - && !ts.getDeclarationOfKind(symbolFromSymbolTable, 230)) { - if (!useOnlyExternalAliasing || - ts.forEach(symbolFromSymbolTable.declarations, ts.isExternalModuleImportEqualsDeclaration)) { - var resolvedImportedSymbol = resolveAlias(symbolFromSymbolTable); - if (isAccessible(symbolFromSymbolTable, resolveAlias(symbolFromSymbolTable))) { - return [symbolFromSymbolTable]; - } - var accessibleSymbolsFromExports = resolvedImportedSymbol.exports ? getAccessibleSymbolChainFromSymbolTable(resolvedImportedSymbol.exports) : undefined; - if (accessibleSymbolsFromExports && canQualifySymbol(symbolFromSymbolTable, getQualifiedLeftMeaning(meaning))) { - return [symbolFromSymbolTable].concat(accessibleSymbolsFromExports); - } - } - } - }); - } - if (symbol) { - return forEachSymbolTableInScope(enclosingDeclaration, getAccessibleSymbolChainFromSymbolTable); - } - } - function needsQualification(symbol, enclosingDeclaration, meaning) { - var qualify = false; - forEachSymbolTableInScope(enclosingDeclaration, function (symbolTable) { - if (!ts.hasProperty(symbolTable, symbol.name)) { - return false; - } - var symbolFromSymbolTable = symbolTable[symbol.name]; - if (symbolFromSymbolTable === symbol) { - return true; - } - symbolFromSymbolTable = (symbolFromSymbolTable.flags & 8388608 && !ts.getDeclarationOfKind(symbolFromSymbolTable, 230)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; - if (symbolFromSymbolTable.flags & meaning) { - qualify = true; - return true; - } - return false; - }); - return qualify; - } - function isSymbolAccessible(symbol, enclosingDeclaration, meaning) { - if (symbol && enclosingDeclaration && !(symbol.flags & 262144)) { - var initialSymbol = symbol; - var meaningToLook = meaning; - while (symbol) { - var accessibleSymbolChain = getAccessibleSymbolChain(symbol, enclosingDeclaration, meaningToLook, false); - if (accessibleSymbolChain) { - var hasAccessibleDeclarations = hasVisibleDeclarations(accessibleSymbolChain[0]); - if (!hasAccessibleDeclarations) { - return { - accessibility: 1, - errorSymbolName: symbolToString(initialSymbol, enclosingDeclaration, meaning), - errorModuleName: symbol !== initialSymbol ? symbolToString(symbol, enclosingDeclaration, 1536) : undefined - }; - } - return hasAccessibleDeclarations; - } - meaningToLook = getQualifiedLeftMeaning(meaning); - symbol = getParentOfSymbol(symbol); - } - var symbolExternalModule = ts.forEach(initialSymbol.declarations, getExternalModuleContainer); - if (symbolExternalModule) { - var enclosingExternalModule = getExternalModuleContainer(enclosingDeclaration); - if (symbolExternalModule !== enclosingExternalModule) { - return { - accessibility: 2, - errorSymbolName: symbolToString(initialSymbol, enclosingDeclaration, meaning), - errorModuleName: symbolToString(symbolExternalModule) - }; - } - } - return { - accessibility: 1, - errorSymbolName: symbolToString(initialSymbol, enclosingDeclaration, meaning) - }; - } - return { accessibility: 0 }; - function getExternalModuleContainer(declaration) { - for (; declaration; declaration = declaration.parent) { - if (hasExternalModuleSymbol(declaration)) { - return getSymbolOfNode(declaration); - } - } - } - } - function hasExternalModuleSymbol(declaration) { - return (declaration.kind === 218 && declaration.name.kind === 9) || - (declaration.kind === 248 && ts.isExternalModule(declaration)); - } - function hasVisibleDeclarations(symbol) { - var aliasesToMakeVisible; - if (ts.forEach(symbol.declarations, function (declaration) { return !getIsDeclarationVisible(declaration); })) { - return undefined; - } - return { accessibility: 0, aliasesToMakeVisible: aliasesToMakeVisible }; - function getIsDeclarationVisible(declaration) { - if (!isDeclarationVisible(declaration)) { - var anyImportSyntax = getAnyImportSyntax(declaration); - if (anyImportSyntax && - !(anyImportSyntax.flags & 1) && - isDeclarationVisible(anyImportSyntax.parent)) { - getNodeLinks(declaration).isVisible = true; - if (aliasesToMakeVisible) { - if (!ts.contains(aliasesToMakeVisible, anyImportSyntax)) { - aliasesToMakeVisible.push(anyImportSyntax); - } - } - else { - aliasesToMakeVisible = [anyImportSyntax]; - } - return true; - } - return false; - } - return true; - } - } - function isEntityNameVisible(entityName, enclosingDeclaration) { - var meaning; - if (entityName.parent.kind === 154) { - meaning = 107455 | 1048576; - } - else if (entityName.kind === 135 || entityName.kind === 166 || - entityName.parent.kind === 221) { - meaning = 1536; - } - else { - meaning = 793056; - } - var firstIdentifier = getFirstIdentifier(entityName); - var symbol = resolveName(enclosingDeclaration, firstIdentifier.text, meaning, undefined, undefined); - return (symbol && hasVisibleDeclarations(symbol)) || { - accessibility: 1, - errorSymbolName: ts.getTextOfNode(firstIdentifier), - errorNode: firstIdentifier - }; - } - function writeKeyword(writer, kind) { - writer.writeKeyword(ts.tokenToString(kind)); - } - function writePunctuation(writer, kind) { - writer.writePunctuation(ts.tokenToString(kind)); - } - function writeSpace(writer) { - writer.writeSpace(" "); - } - function symbolToString(symbol, enclosingDeclaration, meaning) { - var writer = ts.getSingleLineStringWriter(); - getSymbolDisplayBuilder().buildSymbolDisplay(symbol, writer, enclosingDeclaration, meaning); - var result = writer.string(); - ts.releaseStringWriter(writer); - return result; - } - function signatureToString(signature, enclosingDeclaration, flags) { - var writer = ts.getSingleLineStringWriter(); - getSymbolDisplayBuilder().buildSignatureDisplay(signature, writer, enclosingDeclaration, flags); - var result = writer.string(); - ts.releaseStringWriter(writer); - return result; - } - function typeToString(type, enclosingDeclaration, flags) { - var writer = ts.getSingleLineStringWriter(); - getSymbolDisplayBuilder().buildTypeDisplay(type, writer, enclosingDeclaration, flags); - var result = writer.string(); - ts.releaseStringWriter(writer); - var maxLength = compilerOptions.noErrorTruncation || flags & 4 ? undefined : 100; - if (maxLength && result.length >= maxLength) { - result = result.substr(0, maxLength - "...".length) + "..."; - } - return result; - } - function getTypeAliasForTypeLiteral(type) { - if (type.symbol && type.symbol.flags & 2048) { - var node = type.symbol.declarations[0].parent; - while (node.kind === 160) { - node = node.parent; - } - if (node.kind === 216) { - return getSymbolOfNode(node); - } - } - return undefined; - } - function getSymbolDisplayBuilder() { - function getNameOfSymbol(symbol) { - if (symbol.declarations && symbol.declarations.length) { - var declaration = symbol.declarations[0]; - if (declaration.name) { - return ts.declarationNameToString(declaration.name); - } - switch (declaration.kind) { - case 186: - return "(Anonymous class)"; - case 173: - case 174: - return "(Anonymous function)"; - } - } - return symbol.name; - } - function appendSymbolNameOnly(symbol, writer) { - writer.writeSymbol(getNameOfSymbol(symbol), symbol); - } - function buildSymbolDisplay(symbol, writer, enclosingDeclaration, meaning, flags, typeFlags) { - var parentSymbol; - function appendParentTypeArgumentsAndSymbolName(symbol) { - if (parentSymbol) { - if (flags & 1) { - if (symbol.flags & 16777216) { - buildDisplayForTypeArgumentsAndDelimiters(getTypeParametersOfClassOrInterface(parentSymbol), symbol.mapper, writer, enclosingDeclaration); - } - else { - buildTypeParameterDisplayFromSymbol(parentSymbol, writer, enclosingDeclaration); - } - } - writePunctuation(writer, 21); - } - parentSymbol = symbol; - appendSymbolNameOnly(symbol, writer); - } - writer.trackSymbol(symbol, enclosingDeclaration, meaning); - function walkSymbol(symbol, meaning) { - if (symbol) { - var accessibleSymbolChain = getAccessibleSymbolChain(symbol, enclosingDeclaration, meaning, !!(flags & 2)); - if (!accessibleSymbolChain || - needsQualification(accessibleSymbolChain[0], enclosingDeclaration, accessibleSymbolChain.length === 1 ? meaning : getQualifiedLeftMeaning(meaning))) { - walkSymbol(getParentOfSymbol(accessibleSymbolChain ? accessibleSymbolChain[0] : symbol), getQualifiedLeftMeaning(meaning)); - } - if (accessibleSymbolChain) { - for (var _i = 0; _i < accessibleSymbolChain.length; _i++) { - var accessibleSymbol = accessibleSymbolChain[_i]; - appendParentTypeArgumentsAndSymbolName(accessibleSymbol); - } - } - else { - if (!parentSymbol && ts.forEach(symbol.declarations, hasExternalModuleSymbol)) { - return; - } - if (symbol.flags & 2048 || symbol.flags & 4096) { - return; - } - appendParentTypeArgumentsAndSymbolName(symbol); - } - } - } - var isTypeParameter = symbol.flags & 262144; - var typeFormatFlag = 128 & typeFlags; - if (!isTypeParameter && (enclosingDeclaration || typeFormatFlag)) { - walkSymbol(symbol, meaning); - return; - } - return appendParentTypeArgumentsAndSymbolName(symbol); - } - function buildTypeDisplay(type, writer, enclosingDeclaration, globalFlags, symbolStack) { - var globalFlagsToPass = globalFlags & 16; - var inObjectTypeLiteral = false; - return writeType(type, globalFlags); - function writeType(type, flags) { - if (type.flags & 16777343) { - writer.writeKeyword(!(globalFlags & 16) && isTypeAny(type) - ? "any" - : type.intrinsicName); - } - else if (type.flags & 33554432) { - if (inObjectTypeLiteral) { - writer.reportInaccessibleThisError(); - } - writer.writeKeyword("this"); - } - else if (type.flags & 4096) { - writeTypeReference(type, flags); - } - else if (type.flags & (1024 | 2048 | 128 | 512)) { - buildSymbolDisplay(type.symbol, writer, enclosingDeclaration, 793056, 0, flags); - } - else if (type.flags & 8192) { - writeTupleType(type); - } - else if (type.flags & 49152) { - writeUnionOrIntersectionType(type, flags); - } - else if (type.flags & 65536) { - writeAnonymousType(type, flags); - } - else if (type.flags & 256) { - writer.writeStringLiteral(type.text); - } - else { - writePunctuation(writer, 15); - writeSpace(writer); - writePunctuation(writer, 22); - writeSpace(writer); - writePunctuation(writer, 16); - } - } - function writeTypeList(types, delimiter) { - for (var i = 0; i < types.length; i++) { - if (i > 0) { - if (delimiter !== 24) { - writeSpace(writer); - } - writePunctuation(writer, delimiter); - writeSpace(writer); - } - writeType(types[i], delimiter === 24 ? 0 : 64); - } - } - function writeSymbolTypeReference(symbol, typeArguments, pos, end, flags) { - if (symbol.flags & 32 || !isReservedMemberName(symbol.name)) { - buildSymbolDisplay(symbol, writer, enclosingDeclaration, 793056, 0, flags); - } - if (pos < end) { - writePunctuation(writer, 25); - writeType(typeArguments[pos++], 0); - while (pos < end) { - writePunctuation(writer, 24); - writeSpace(writer); - writeType(typeArguments[pos++], 0); - } - writePunctuation(writer, 27); - } - } - 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); - } - else { - var outerTypeParameters = type.target.outerTypeParameters; - var i = 0; - if (outerTypeParameters) { - var length_1 = outerTypeParameters.length; - while (i < length_1) { - var start = i; - var parent_3 = getParentSymbolOfTypeParameter(outerTypeParameters[i]); - do { - i++; - } while (i < length_1 && getParentSymbolOfTypeParameter(outerTypeParameters[i]) === parent_3); - if (!ts.rangeEquals(outerTypeParameters, typeArguments, start, i)) { - writeSymbolTypeReference(parent_3, typeArguments, start, i, flags); - writePunctuation(writer, 21); - } - } - } - var typeParameterCount = (type.target.typeParameters || emptyArray).length; - writeSymbolTypeReference(type.symbol, typeArguments, i, typeParameterCount, flags); - } - } - function writeTupleType(type) { - writePunctuation(writer, 19); - writeTypeList(type.elementTypes, 24); - writePunctuation(writer, 20); - } - function writeUnionOrIntersectionType(type, flags) { - if (flags & 64) { - writePunctuation(writer, 17); - } - writeTypeList(type.types, type.flags & 16384 ? 47 : 46); - if (flags & 64) { - writePunctuation(writer, 18); - } - } - function writeAnonymousType(type, flags) { - var symbol = type.symbol; - if (symbol) { - if (symbol.flags & (32 | 384 | 512)) { - writeTypeofSymbol(type, flags); - } - else if (shouldWriteTypeOfFunctionSymbol()) { - writeTypeofSymbol(type, flags); - } - else if (ts.contains(symbolStack, symbol)) { - var typeAlias = getTypeAliasForTypeLiteral(type); - if (typeAlias) { - buildSymbolDisplay(typeAlias, writer, enclosingDeclaration, 793056, 0, flags); - } - else { - writeKeyword(writer, 117); - } - } - else { - if (!symbolStack) { - symbolStack = []; - } - symbolStack.push(symbol); - writeLiteralType(type, flags); - symbolStack.pop(); - } - } - else { - writeLiteralType(type, flags); - } - function shouldWriteTypeOfFunctionSymbol() { - var isStaticMethodSymbol = !!(symbol.flags & 8192 && - ts.forEach(symbol.declarations, function (declaration) { return declaration.flags & 128; })); - var isNonLocalFunctionSymbol = !!(symbol.flags & 16) && - (symbol.parent || - ts.forEach(symbol.declarations, function (declaration) { - return declaration.parent.kind === 248 || declaration.parent.kind === 219; - })); - if (isStaticMethodSymbol || isNonLocalFunctionSymbol) { - return !!(flags & 2) || - (ts.contains(symbolStack, symbol)); - } - } - } - function writeTypeofSymbol(type, typeFormatFlags) { - writeKeyword(writer, 101); - writeSpace(writer); - buildSymbolDisplay(type.symbol, writer, enclosingDeclaration, 107455, 0, typeFormatFlags); - } - function getIndexerParameterName(type, indexKind, fallbackName) { - var declaration = getIndexDeclarationOfSymbol(type.symbol, indexKind); - if (!declaration) { - return fallbackName; - } - ts.Debug.assert(declaration.parameters.length !== 0); - return ts.declarationNameToString(declaration.parameters[0].name); - } - function writeLiteralType(type, flags) { - var resolved = resolveStructuredTypeMembers(type); - if (!resolved.properties.length && !resolved.stringIndexType && !resolved.numberIndexType) { - if (!resolved.callSignatures.length && !resolved.constructSignatures.length) { - writePunctuation(writer, 15); - writePunctuation(writer, 16); - return; - } - if (resolved.callSignatures.length === 1 && !resolved.constructSignatures.length) { - if (flags & 64) { - writePunctuation(writer, 17); - } - buildSignatureDisplay(resolved.callSignatures[0], writer, enclosingDeclaration, globalFlagsToPass | 8, symbolStack); - if (flags & 64) { - writePunctuation(writer, 18); - } - return; - } - if (resolved.constructSignatures.length === 1 && !resolved.callSignatures.length) { - if (flags & 64) { - writePunctuation(writer, 17); - } - writeKeyword(writer, 92); - writeSpace(writer); - buildSignatureDisplay(resolved.constructSignatures[0], writer, enclosingDeclaration, globalFlagsToPass | 8, symbolStack); - if (flags & 64) { - writePunctuation(writer, 18); - } - return; - } - } - var saveInObjectTypeLiteral = inObjectTypeLiteral; - inObjectTypeLiteral = true; - writePunctuation(writer, 15); - writer.writeLine(); - writer.increaseIndent(); - for (var _i = 0, _a = resolved.callSignatures; _i < _a.length; _i++) { - var signature = _a[_i]; - buildSignatureDisplay(signature, writer, enclosingDeclaration, globalFlagsToPass, symbolStack); - writePunctuation(writer, 23); - writer.writeLine(); - } - for (var _b = 0, _c = resolved.constructSignatures; _b < _c.length; _b++) { - var signature = _c[_b]; - writeKeyword(writer, 92); - writeSpace(writer); - buildSignatureDisplay(signature, writer, enclosingDeclaration, globalFlagsToPass, symbolStack); - writePunctuation(writer, 23); - writer.writeLine(); - } - if (resolved.stringIndexType) { - writePunctuation(writer, 19); - writer.writeParameter(getIndexerParameterName(resolved, 0, "x")); - writePunctuation(writer, 54); - writeSpace(writer); - writeKeyword(writer, 130); - writePunctuation(writer, 20); - writePunctuation(writer, 54); - writeSpace(writer); - writeType(resolved.stringIndexType, 0); - writePunctuation(writer, 23); - writer.writeLine(); - } - if (resolved.numberIndexType) { - writePunctuation(writer, 19); - writer.writeParameter(getIndexerParameterName(resolved, 1, "x")); - writePunctuation(writer, 54); - writeSpace(writer); - writeKeyword(writer, 128); - writePunctuation(writer, 20); - writePunctuation(writer, 54); - writeSpace(writer); - writeType(resolved.numberIndexType, 0); - writePunctuation(writer, 23); - writer.writeLine(); - } - for (var _d = 0, _e = resolved.properties; _d < _e.length; _d++) { - var p = _e[_d]; - var t = getTypeOfSymbol(p); - if (p.flags & (16 | 8192) && !getPropertiesOfObjectType(t).length) { - var signatures = getSignaturesOfType(t, 0); - for (var _f = 0; _f < signatures.length; _f++) { - var signature = signatures[_f]; - buildSymbolDisplay(p, writer); - if (p.flags & 536870912) { - writePunctuation(writer, 53); - } - buildSignatureDisplay(signature, writer, enclosingDeclaration, globalFlagsToPass, symbolStack); - writePunctuation(writer, 23); - writer.writeLine(); - } - } - else { - buildSymbolDisplay(p, writer); - if (p.flags & 536870912) { - writePunctuation(writer, 53); - } - writePunctuation(writer, 54); - writeSpace(writer); - writeType(t, 0); - writePunctuation(writer, 23); - writer.writeLine(); - } - } - writer.decreaseIndent(); - writePunctuation(writer, 16); - inObjectTypeLiteral = saveInObjectTypeLiteral; - } - } - function buildTypeParameterDisplayFromSymbol(symbol, writer, enclosingDeclaraiton, flags) { - var targetSymbol = getTargetSymbol(symbol); - if (targetSymbol.flags & 32 || targetSymbol.flags & 64 || targetSymbol.flags & 524288) { - buildDisplayForTypeParametersAndDelimiters(getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol), writer, enclosingDeclaraiton, flags); - } - } - function buildTypeParameterDisplay(tp, writer, enclosingDeclaration, flags, symbolStack) { - appendSymbolNameOnly(tp.symbol, writer); - var constraint = getConstraintOfTypeParameter(tp); - if (constraint) { - writeSpace(writer); - writeKeyword(writer, 83); - writeSpace(writer); - buildTypeDisplay(constraint, writer, enclosingDeclaration, flags, symbolStack); - } - } - function buildParameterDisplay(p, writer, enclosingDeclaration, flags, symbolStack) { - var parameterNode = p.valueDeclaration; - if (ts.isRestParameter(parameterNode)) { - writePunctuation(writer, 22); - } - appendSymbolNameOnly(p, writer); - if (isOptionalParameter(parameterNode)) { - writePunctuation(writer, 53); - } - writePunctuation(writer, 54); - writeSpace(writer); - buildTypeDisplay(getTypeOfSymbol(p), writer, enclosingDeclaration, flags, symbolStack); - } - function buildDisplayForTypeParametersAndDelimiters(typeParameters, writer, enclosingDeclaration, flags, symbolStack) { - if (typeParameters && typeParameters.length) { - writePunctuation(writer, 25); - for (var i = 0; i < typeParameters.length; i++) { - if (i > 0) { - writePunctuation(writer, 24); - writeSpace(writer); - } - buildTypeParameterDisplay(typeParameters[i], writer, enclosingDeclaration, flags, symbolStack); - } - writePunctuation(writer, 27); - } - } - function buildDisplayForTypeArgumentsAndDelimiters(typeParameters, mapper, writer, enclosingDeclaration, flags, symbolStack) { - if (typeParameters && typeParameters.length) { - writePunctuation(writer, 25); - for (var i = 0; i < typeParameters.length; i++) { - if (i > 0) { - writePunctuation(writer, 24); - writeSpace(writer); - } - buildTypeDisplay(mapper(typeParameters[i]), writer, enclosingDeclaration, 0); - } - writePunctuation(writer, 27); - } - } - function buildDisplayForParametersAndDelimiters(parameters, writer, enclosingDeclaration, flags, symbolStack) { - writePunctuation(writer, 17); - for (var i = 0; i < parameters.length; i++) { - if (i > 0) { - writePunctuation(writer, 24); - writeSpace(writer); - } - buildParameterDisplay(parameters[i], writer, enclosingDeclaration, flags, symbolStack); - } - writePunctuation(writer, 18); - } - function buildReturnTypeDisplay(signature, writer, enclosingDeclaration, flags, symbolStack) { - if (flags & 8) { - writeSpace(writer); - writePunctuation(writer, 34); - } - else { - writePunctuation(writer, 54); - } - writeSpace(writer); - var returnType; - if (signature.typePredicate) { - writer.writeParameter(signature.typePredicate.parameterName); - writeSpace(writer); - writeKeyword(writer, 124); - writeSpace(writer); - returnType = signature.typePredicate.type; - } - else { - returnType = getReturnTypeOfSignature(signature); - } - buildTypeDisplay(returnType, writer, enclosingDeclaration, flags, symbolStack); - } - function buildSignatureDisplay(signature, writer, enclosingDeclaration, flags, symbolStack) { - if (signature.target && (flags & 32)) { - buildDisplayForTypeArgumentsAndDelimiters(signature.target.typeParameters, signature.mapper, writer, enclosingDeclaration); - } - else { - buildDisplayForTypeParametersAndDelimiters(signature.typeParameters, writer, enclosingDeclaration, flags, symbolStack); - } - buildDisplayForParametersAndDelimiters(signature.parameters, writer, enclosingDeclaration, flags, symbolStack); - buildReturnTypeDisplay(signature, writer, enclosingDeclaration, flags, symbolStack); - } - return _displayBuilder || (_displayBuilder = { - buildSymbolDisplay: buildSymbolDisplay, - buildTypeDisplay: buildTypeDisplay, - buildTypeParameterDisplay: buildTypeParameterDisplay, - buildParameterDisplay: buildParameterDisplay, - buildDisplayForParametersAndDelimiters: buildDisplayForParametersAndDelimiters, - buildDisplayForTypeParametersAndDelimiters: buildDisplayForTypeParametersAndDelimiters, - buildTypeParameterDisplayFromSymbol: buildTypeParameterDisplayFromSymbol, - buildSignatureDisplay: buildSignatureDisplay, - buildReturnTypeDisplay: buildReturnTypeDisplay - }); - } - function isDeclarationVisible(node) { - function getContainingExternalModule(node) { - for (; node; node = node.parent) { - if (node.kind === 218) { - if (node.name.kind === 9) { - return node; - } - } - else if (node.kind === 248) { - return ts.isExternalModule(node) ? node : undefined; - } - } - ts.Debug.fail("getContainingModule cant reach here"); - } - function isUsedInExportAssignment(node) { - var externalModule = getContainingExternalModule(node); - var exportAssignmentSymbol; - var resolvedExportSymbol; - if (externalModule) { - var externalModuleSymbol = getSymbolOfNode(externalModule); - exportAssignmentSymbol = getExportAssignmentSymbol(externalModuleSymbol); - var symbolOfNode = getSymbolOfNode(node); - if (isSymbolUsedInExportAssignment(symbolOfNode)) { - return true; - } - if (symbolOfNode.flags & 8388608) { - return isSymbolUsedInExportAssignment(resolveAlias(symbolOfNode)); - } - } - function isSymbolUsedInExportAssignment(symbol) { - if (exportAssignmentSymbol === symbol) { - return true; - } - if (exportAssignmentSymbol && !!(exportAssignmentSymbol.flags & 8388608)) { - resolvedExportSymbol = resolvedExportSymbol || resolveAlias(exportAssignmentSymbol); - if (resolvedExportSymbol === symbol) { - return true; - } - return ts.forEach(resolvedExportSymbol.declarations, function (current) { - while (current) { - if (current === node) { - return true; - } - current = current.parent; - } - }); - } - } - } - function determineIfDeclarationIsVisible() { - switch (node.kind) { - case 163: - return isDeclarationVisible(node.parent.parent); - case 211: - if (ts.isBindingPattern(node.name) && - !node.name.elements.length) { - return false; - } - case 218: - case 214: - case 215: - case 216: - case 213: - case 217: - case 221: - var parent_4 = getDeclarationContainer(node); - if (!(ts.getCombinedNodeFlags(node) & 1) && - !(node.kind !== 221 && parent_4.kind !== 248 && ts.isInAmbientContext(parent_4))) { - return isGlobalSourceFile(parent_4); - } - return isDeclarationVisible(parent_4); - case 141: - case 140: - case 145: - case 146: - case 143: - case 142: - if (node.flags & (32 | 64)) { - return false; - } - case 144: - case 148: - case 147: - case 149: - case 138: - case 219: - case 152: - case 153: - case 155: - case 151: - case 156: - case 157: - case 158: - case 159: - case 160: - return isDeclarationVisible(node.parent); - case 223: - case 224: - case 226: - return false; - case 137: - case 248: - return true; - case 227: - return false; - default: - ts.Debug.fail("isDeclarationVisible unknown: SyntaxKind: " + node.kind); - } - } - if (node) { - var links = getNodeLinks(node); - if (links.isVisible === undefined) { - links.isVisible = !!determineIfDeclarationIsVisible(); - } - return links.isVisible; - } - } - function collectLinkedAliases(node) { - var exportSymbol; - if (node.parent && node.parent.kind === 227) { - exportSymbol = resolveName(node.parent, node.text, 107455 | 793056 | 1536 | 8388608, ts.Diagnostics.Cannot_find_name_0, node); - } - else if (node.parent.kind === 230) { - var exportSpecifier = node.parent; - exportSymbol = exportSpecifier.parent.parent.moduleSpecifier ? - getExternalModuleMember(exportSpecifier.parent.parent, exportSpecifier) : - resolveEntityName(exportSpecifier.propertyName || exportSpecifier.name, 107455 | 793056 | 1536 | 8388608); - } - var result = []; - if (exportSymbol) { - buildVisibleNodeList(exportSymbol.declarations); - } - return result; - function buildVisibleNodeList(declarations) { - ts.forEach(declarations, function (declaration) { - getNodeLinks(declaration).isVisible = true; - var resultNode = getAnyImportSyntax(declaration) || declaration; - if (!ts.contains(result, resultNode)) { - result.push(resultNode); - } - if (ts.isInternalModuleImportEqualsDeclaration(declaration)) { - var internalModuleReference = declaration.moduleReference; - var firstIdentifier = getFirstIdentifier(internalModuleReference); - var importSymbol = resolveName(declaration, firstIdentifier.text, 107455 | 793056 | 1536, ts.Diagnostics.Cannot_find_name_0, firstIdentifier); - buildVisibleNodeList(importSymbol.declarations); - } - }); - } - } - function pushTypeResolution(target, propertyName) { - var resolutionCycleStartIndex = findResolutionCycleStartIndex(target, propertyName); - if (resolutionCycleStartIndex >= 0) { - var length_2 = resolutionTargets.length; - for (var i = resolutionCycleStartIndex; i < length_2; i++) { - resolutionResults[i] = false; - } - return false; - } - resolutionTargets.push(target); - resolutionResults.push(true); - resolutionPropertyNames.push(propertyName); - return true; - } - function findResolutionCycleStartIndex(target, propertyName) { - for (var i = resolutionTargets.length - 1; i >= 0; i--) { - if (hasType(resolutionTargets[i], resolutionPropertyNames[i])) { - return -1; - } - if (resolutionTargets[i] === target && resolutionPropertyNames[i] === propertyName) { - return i; - } - } - return -1; - } - function hasType(target, propertyName) { - if (propertyName === 0) { - return getSymbolLinks(target).type; - } - if (propertyName === 2) { - return getSymbolLinks(target).declaredType; - } - if (propertyName === 1) { - ts.Debug.assert(!!(target.flags & 1024)); - return target.resolvedBaseConstructorType; - } - if (propertyName === 3) { - return target.resolvedReturnType; - } - ts.Debug.fail("Unhandled TypeSystemPropertyName " + propertyName); - } - function popTypeResolution() { - resolutionTargets.pop(); - resolutionPropertyNames.pop(); - return resolutionResults.pop(); - } - function getDeclarationContainer(node) { - node = ts.getRootDeclaration(node); - return node.kind === 211 ? node.parent.parent.parent : node.parent; - } - function getTypeOfPrototypeProperty(prototype) { - var classType = getDeclaredTypeOfSymbol(prototype.parent); - return classType.typeParameters ? createTypeReference(classType, ts.map(classType.typeParameters, function (_) { return anyType; })) : classType; - } - function getTypeOfPropertyOfType(type, name) { - var prop = getPropertyOfType(type, name); - return prop ? getTypeOfSymbol(prop) : undefined; - } - function isTypeAny(type) { - return type && (type.flags & 1) !== 0; - } - function getTypeForBindingElementParent(node) { - var symbol = getSymbolOfNode(node); - return symbol && getSymbolLinks(symbol).type || getTypeForVariableLikeDeclaration(node); - } - function getTypeForBindingElement(declaration) { - var pattern = declaration.parent; - var parentType = getTypeForBindingElementParent(pattern.parent); - if (parentType === unknownType) { - return unknownType; - } - if (!parentType || isTypeAny(parentType)) { - if (declaration.initializer) { - return checkExpressionCached(declaration.initializer); - } - return parentType; - } - var type; - if (pattern.kind === 161) { - var name_11 = declaration.propertyName || declaration.name; - type = getTypeOfPropertyOfType(parentType, name_11.text) || - isNumericLiteralName(name_11.text) && getIndexTypeOfType(parentType, 1) || - getIndexTypeOfType(parentType, 0); - if (!type) { - error(name_11, ts.Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(parentType), ts.declarationNameToString(name_11)); - return unknownType; - } - } - else { - var elementType = checkIteratedTypeOrElementType(parentType, pattern, false); - if (!declaration.dotDotDotToken) { - var propName = "" + ts.indexOf(pattern.elements, declaration); - type = isTupleLikeType(parentType) - ? getTypeOfPropertyOfType(parentType, propName) - : elementType; - if (!type) { - if (isTupleType(parentType)) { - error(declaration, ts.Diagnostics.Tuple_type_0_with_length_1_cannot_be_assigned_to_tuple_with_length_2, typeToString(parentType), parentType.elementTypes.length, pattern.elements.length); - } - else { - error(declaration, ts.Diagnostics.Type_0_has_no_property_1, typeToString(parentType), propName); - } - return unknownType; - } - } - else { - type = createArrayType(elementType); - } - } - return type; - } - function getTypeForVariableLikeDeclaration(declaration) { - if (declaration.parent.parent.kind === 200) { - return anyType; - } - if (declaration.parent.parent.kind === 201) { - return checkRightHandSideOfForOf(declaration.parent.parent.expression) || anyType; - } - if (ts.isBindingPattern(declaration.parent)) { - return getTypeForBindingElement(declaration); - } - if (declaration.type) { - return getTypeFromTypeNode(declaration.type); - } - if (declaration.kind === 138) { - var func = declaration.parent; - if (func.kind === 146 && !ts.hasDynamicName(func)) { - var getter = ts.getDeclarationOfKind(declaration.parent.symbol, 145); - if (getter) { - return getReturnTypeOfSignature(getSignatureFromDeclaration(getter)); - } - } - var type = getContextuallyTypedParameterType(declaration); - if (type) { - return type; - } - } - if (declaration.initializer) { - return checkExpressionCached(declaration.initializer); - } - if (declaration.kind === 246) { - return checkIdentifier(declaration.name); - } - if (ts.isBindingPattern(declaration.name)) { - return getTypeFromBindingPattern(declaration.name, false); - } - return undefined; - } - function getTypeFromBindingElement(element, includePatternInType) { - if (element.initializer) { - return getWidenedType(checkExpressionCached(element.initializer)); - } - if (ts.isBindingPattern(element.name)) { - return getTypeFromBindingPattern(element.name, includePatternInType); - } - return anyType; - } - function getTypeFromObjectBindingPattern(pattern, includePatternInType) { - var members = {}; - ts.forEach(pattern.elements, function (e) { - var flags = 4 | 67108864 | (e.initializer ? 536870912 : 0); - var name = e.propertyName || e.name; - var symbol = createSymbol(flags, name.text); - symbol.type = getTypeFromBindingElement(e, includePatternInType); - symbol.bindingElement = e; - members[symbol.name] = symbol; - }); - var result = createAnonymousType(undefined, members, emptyArray, emptyArray, undefined, undefined); - if (includePatternInType) { - result.pattern = pattern; - } - return result; - } - function getTypeFromArrayBindingPattern(pattern, includePatternInType) { - var elements = pattern.elements; - if (elements.length === 0 || elements[elements.length - 1].dotDotDotToken) { - return languageVersion >= 2 ? createIterableType(anyType) : anyArrayType; - } - var elementTypes = ts.map(elements, function (e) { return e.kind === 187 ? anyType : getTypeFromBindingElement(e, includePatternInType); }); - if (includePatternInType) { - var result = createNewTupleType(elementTypes); - result.pattern = pattern; - return result; - } - return createTupleType(elementTypes); - } - function getTypeFromBindingPattern(pattern, includePatternInType) { - return pattern.kind === 161 - ? getTypeFromObjectBindingPattern(pattern, includePatternInType) - : getTypeFromArrayBindingPattern(pattern, includePatternInType); - } - function getWidenedTypeForVariableLikeDeclaration(declaration, reportErrors) { - var type = getTypeForVariableLikeDeclaration(declaration); - if (type) { - if (reportErrors) { - reportErrorsFromWidening(declaration, type); - } - return declaration.kind !== 245 ? getWidenedType(type) : type; - } - type = declaration.dotDotDotToken ? anyArrayType : anyType; - if (reportErrors && compilerOptions.noImplicitAny) { - var root = ts.getRootDeclaration(declaration); - if (!isPrivateWithinAmbient(root) && !(root.kind === 138 && isPrivateWithinAmbient(root.parent))) { - reportImplicitAnyError(declaration, type); - } - } - return type; - } - function getTypeOfVariableOrParameterOrProperty(symbol) { - var links = getSymbolLinks(symbol); - if (!links.type) { - if (symbol.flags & 134217728) { - return links.type = getTypeOfPrototypeProperty(symbol); - } - var declaration = symbol.valueDeclaration; - if (declaration.parent.kind === 244) { - return links.type = anyType; - } - if (declaration.kind === 227) { - return links.type = checkExpression(declaration.expression); - } - if (!pushTypeResolution(symbol, 0)) { - return unknownType; - } - var type = getWidenedTypeForVariableLikeDeclaration(declaration, true); - if (!popTypeResolution()) { - if (symbol.valueDeclaration.type) { - type = unknownType; - error(symbol.valueDeclaration, ts.Diagnostics._0_is_referenced_directly_or_indirectly_in_its_own_type_annotation, symbolToString(symbol)); - } - else { - type = anyType; - if (compilerOptions.noImplicitAny) { - error(symbol.valueDeclaration, ts.Diagnostics._0_implicitly_has_type_any_because_it_does_not_have_a_type_annotation_and_is_referenced_directly_or_indirectly_in_its_own_initializer, symbolToString(symbol)); - } - } - } - links.type = type; - } - return links.type; - } - function getAnnotatedAccessorType(accessor) { - if (accessor) { - if (accessor.kind === 145) { - return accessor.type && getTypeFromTypeNode(accessor.type); - } - else { - var setterTypeAnnotation = ts.getSetAccessorTypeAnnotationNode(accessor); - return setterTypeAnnotation && getTypeFromTypeNode(setterTypeAnnotation); - } - } - return undefined; - } - function getTypeOfAccessors(symbol) { - var links = getSymbolLinks(symbol); - if (!links.type) { - if (!pushTypeResolution(symbol, 0)) { - return unknownType; - } - var getter = ts.getDeclarationOfKind(symbol, 145); - var setter = ts.getDeclarationOfKind(symbol, 146); - var type; - var getterReturnType = getAnnotatedAccessorType(getter); - if (getterReturnType) { - type = getterReturnType; - } - else { - var setterParameterType = getAnnotatedAccessorType(setter); - if (setterParameterType) { - type = setterParameterType; - } - else { - if (getter && getter.body) { - type = getReturnTypeFromBody(getter); - } - else { - if (compilerOptions.noImplicitAny) { - error(setter, ts.Diagnostics.Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_type_annotation, symbolToString(symbol)); - } - type = anyType; - } - } - } - if (!popTypeResolution()) { - type = anyType; - if (compilerOptions.noImplicitAny) { - var getter_1 = ts.getDeclarationOfKind(symbol, 145); - error(getter_1, ts.Diagnostics._0_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions, symbolToString(symbol)); - } - } - links.type = type; - } - return links.type; - } - function getTypeOfFuncClassEnumModule(symbol) { - var links = getSymbolLinks(symbol); - if (!links.type) { - links.type = createObjectType(65536, symbol); - } - return links.type; - } - function getTypeOfEnumMember(symbol) { - var links = getSymbolLinks(symbol); - if (!links.type) { - links.type = getDeclaredTypeOfEnum(getParentOfSymbol(symbol)); - } - return links.type; - } - function getTypeOfAlias(symbol) { - var links = getSymbolLinks(symbol); - if (!links.type) { - var targetSymbol = resolveAlias(symbol); - links.type = targetSymbol.flags & 107455 - ? getTypeOfSymbol(targetSymbol) - : unknownType; - } - return links.type; - } - function getTypeOfInstantiatedSymbol(symbol) { - var links = getSymbolLinks(symbol); - if (!links.type) { - links.type = instantiateType(getTypeOfSymbol(links.target), links.mapper); - } - return links.type; - } - function getTypeOfSymbol(symbol) { - if (symbol.flags & 16777216) { - return getTypeOfInstantiatedSymbol(symbol); - } - if (symbol.flags & (3 | 4)) { - return getTypeOfVariableOrParameterOrProperty(symbol); - } - if (symbol.flags & (16 | 8192 | 32 | 384 | 512)) { - return getTypeOfFuncClassEnumModule(symbol); - } - if (symbol.flags & 8) { - return getTypeOfEnumMember(symbol); - } - if (symbol.flags & 98304) { - return getTypeOfAccessors(symbol); - } - if (symbol.flags & 8388608) { - return getTypeOfAlias(symbol); - } - return unknownType; - } - function getTargetType(type) { - return type.flags & 4096 ? type.target : type; - } - function hasBaseType(type, checkBase) { - return check(type); - function check(type) { - var target = getTargetType(type); - return target === checkBase || ts.forEach(getBaseTypes(target), check); - } - } - function appendTypeParameters(typeParameters, declarations) { - for (var _i = 0; _i < declarations.length; _i++) { - var declaration = declarations[_i]; - var tp = getDeclaredTypeOfTypeParameter(getSymbolOfNode(declaration)); - if (!typeParameters) { - typeParameters = [tp]; - } - else if (!ts.contains(typeParameters, tp)) { - typeParameters.push(tp); - } - } - return typeParameters; - } - function appendOuterTypeParameters(typeParameters, node) { - while (true) { - node = node.parent; - if (!node) { - return typeParameters; - } - if (node.kind === 214 || node.kind === 186 || - node.kind === 213 || node.kind === 173 || - node.kind === 143 || node.kind === 174) { - var declarations = node.typeParameters; - if (declarations) { - return appendTypeParameters(appendOuterTypeParameters(typeParameters, node), declarations); - } - } - } - } - function getOuterTypeParametersOfClassOrInterface(symbol) { - var declaration = symbol.flags & 32 ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 215); - return appendOuterTypeParameters(undefined, declaration); - } - function getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol) { - var result; - for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { - var node = _a[_i]; - if (node.kind === 215 || node.kind === 214 || - node.kind === 186 || node.kind === 216) { - var declaration = node; - if (declaration.typeParameters) { - result = appendTypeParameters(result, declaration.typeParameters); - } - } - } - return result; - } - function getTypeParametersOfClassOrInterface(symbol) { - return ts.concatenate(getOuterTypeParametersOfClassOrInterface(symbol), getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol)); - } - function isConstructorType(type) { - return type.flags & 80896 && getSignaturesOfType(type, 1).length > 0; - } - function getBaseTypeNodeOfClass(type) { - return ts.getClassExtendsHeritageClauseElement(type.symbol.valueDeclaration); - } - function getConstructorsForTypeArguments(type, typeArgumentNodes) { - var typeArgCount = typeArgumentNodes ? typeArgumentNodes.length : 0; - return ts.filter(getSignaturesOfType(type, 1), function (sig) { return (sig.typeParameters ? sig.typeParameters.length : 0) === typeArgCount; }); - } - function getInstantiatedConstructorsForTypeArguments(type, typeArgumentNodes) { - var signatures = getConstructorsForTypeArguments(type, typeArgumentNodes); - if (typeArgumentNodes) { - var typeArguments = ts.map(typeArgumentNodes, getTypeFromTypeNode); - signatures = ts.map(signatures, function (sig) { return getSignatureInstantiation(sig, typeArguments); }); - } - return signatures; - } - function getBaseConstructorTypeOfClass(type) { - if (!type.resolvedBaseConstructorType) { - var baseTypeNode = getBaseTypeNodeOfClass(type); - if (!baseTypeNode) { - return type.resolvedBaseConstructorType = undefinedType; - } - if (!pushTypeResolution(type, 1)) { - return unknownType; - } - var baseConstructorType = checkExpression(baseTypeNode.expression); - if (baseConstructorType.flags & 80896) { - resolveStructuredTypeMembers(baseConstructorType); - } - if (!popTypeResolution()) { - error(type.symbol.valueDeclaration, ts.Diagnostics._0_is_referenced_directly_or_indirectly_in_its_own_base_expression, symbolToString(type.symbol)); - return type.resolvedBaseConstructorType = unknownType; - } - if (baseConstructorType !== unknownType && baseConstructorType !== nullType && !isConstructorType(baseConstructorType)) { - error(baseTypeNode.expression, ts.Diagnostics.Type_0_is_not_a_constructor_function_type, typeToString(baseConstructorType)); - return type.resolvedBaseConstructorType = unknownType; - } - type.resolvedBaseConstructorType = baseConstructorType; - } - return type.resolvedBaseConstructorType; - } - function hasClassBaseType(type) { - return !!ts.forEach(getBaseTypes(type), function (t) { return !!(t.symbol.flags & 32); }); - } - function getBaseTypes(type) { - var isClass = type.symbol.flags & 32; - var isInterface = type.symbol.flags & 64; - if (!type.resolvedBaseTypes) { - if (!isClass && !isInterface) { - ts.Debug.fail("type must be class or interface"); - } - if (isClass) { - resolveBaseTypesOfClass(type); - } - if (isInterface) { - resolveBaseTypesOfInterface(type); - } - } - return type.resolvedBaseTypes; - } - function resolveBaseTypesOfClass(type) { - type.resolvedBaseTypes = type.resolvedBaseTypes || emptyArray; - var baseContructorType = getBaseConstructorTypeOfClass(type); - if (!(baseContructorType.flags & 80896)) { - return; - } - var baseTypeNode = getBaseTypeNodeOfClass(type); - var baseType; - if (baseContructorType.symbol && baseContructorType.symbol.flags & 32) { - baseType = getTypeFromClassOrInterfaceReference(baseTypeNode, baseContructorType.symbol); - } - else { - var constructors = getInstantiatedConstructorsForTypeArguments(baseContructorType, baseTypeNode.typeArguments); - if (!constructors.length) { - error(baseTypeNode.expression, ts.Diagnostics.No_base_constructor_has_the_specified_number_of_type_arguments); - return; - } - baseType = getReturnTypeOfSignature(constructors[0]); - } - if (baseType === unknownType) { - return; - } - if (!(getTargetType(baseType).flags & (1024 | 2048))) { - error(baseTypeNode.expression, ts.Diagnostics.Base_constructor_return_type_0_is_not_a_class_or_interface_type, typeToString(baseType)); - return; - } - if (type === baseType || hasBaseType(baseType, type)) { - error(type.symbol.valueDeclaration, ts.Diagnostics.Type_0_recursively_references_itself_as_a_base_type, typeToString(type, undefined, 1)); - return; - } - if (type.resolvedBaseTypes === emptyArray) { - type.resolvedBaseTypes = [baseType]; - } - else { - type.resolvedBaseTypes.push(baseType); - } - } - function resolveBaseTypesOfInterface(type) { - type.resolvedBaseTypes = type.resolvedBaseTypes || emptyArray; - for (var _i = 0, _a = type.symbol.declarations; _i < _a.length; _i++) { - var declaration = _a[_i]; - if (declaration.kind === 215 && ts.getInterfaceBaseTypeNodes(declaration)) { - for (var _b = 0, _c = ts.getInterfaceBaseTypeNodes(declaration); _b < _c.length; _b++) { - var node = _c[_b]; - var baseType = getTypeFromTypeNode(node); - if (baseType !== unknownType) { - if (getTargetType(baseType).flags & (1024 | 2048)) { - if (type !== baseType && !hasBaseType(baseType, type)) { - if (type.resolvedBaseTypes === emptyArray) { - type.resolvedBaseTypes = [baseType]; - } - else { - type.resolvedBaseTypes.push(baseType); - } - } - else { - error(declaration, ts.Diagnostics.Type_0_recursively_references_itself_as_a_base_type, typeToString(type, undefined, 1)); - } - } - else { - error(node, ts.Diagnostics.An_interface_may_only_extend_a_class_or_another_interface); - } - } - } - } - } - } - function isIndependentInterface(symbol) { - for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { - var declaration = _a[_i]; - if (declaration.kind === 215) { - if (declaration.flags & 524288) { - return false; - } - var baseTypeNodes = ts.getInterfaceBaseTypeNodes(declaration); - if (baseTypeNodes) { - for (var _b = 0; _b < baseTypeNodes.length; _b++) { - var node = baseTypeNodes[_b]; - if (ts.isSupportedExpressionWithTypeArguments(node)) { - var baseSymbol = resolveEntityName(node.expression, 793056, true); - if (!baseSymbol || !(baseSymbol.flags & 64) || getDeclaredTypeOfClassOrInterface(baseSymbol).thisType) { - return false; - } - } - } - } - } - } - return true; - } - function getDeclaredTypeOfClassOrInterface(symbol) { - var links = getSymbolLinks(symbol); - if (!links.declaredType) { - var kind = symbol.flags & 32 ? 1024 : 2048; - var type = links.declaredType = createObjectType(kind, symbol); - var outerTypeParameters = getOuterTypeParametersOfClassOrInterface(symbol); - var localTypeParameters = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol); - if (outerTypeParameters || localTypeParameters || kind === 1024 || !isIndependentInterface(symbol)) { - type.flags |= 4096; - type.typeParameters = ts.concatenate(outerTypeParameters, localTypeParameters); - type.outerTypeParameters = outerTypeParameters; - type.localTypeParameters = localTypeParameters; - type.instantiations = {}; - type.instantiations[getTypeListId(type.typeParameters)] = type; - type.target = type; - type.typeArguments = type.typeParameters; - type.thisType = createType(512 | 33554432); - type.thisType.symbol = symbol; - type.thisType.constraint = getTypeWithThisArgument(type); - } - } - return links.declaredType; - } - function getDeclaredTypeOfTypeAlias(symbol) { - var links = getSymbolLinks(symbol); - if (!links.declaredType) { - if (!pushTypeResolution(symbol, 2)) { - return unknownType; - } - var declaration = ts.getDeclarationOfKind(symbol, 216); - var type = getTypeFromTypeNode(declaration.type); - if (popTypeResolution()) { - links.typeParameters = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol); - if (links.typeParameters) { - links.instantiations = {}; - links.instantiations[getTypeListId(links.typeParameters)] = type; - } - } - else { - type = unknownType; - error(declaration.name, ts.Diagnostics.Type_alias_0_circularly_references_itself, symbolToString(symbol)); - } - links.declaredType = type; - } - return links.declaredType; - } - function getDeclaredTypeOfEnum(symbol) { - var links = getSymbolLinks(symbol); - if (!links.declaredType) { - var type = createType(128); - type.symbol = symbol; - links.declaredType = type; - } - return links.declaredType; - } - function getDeclaredTypeOfTypeParameter(symbol) { - var links = getSymbolLinks(symbol); - if (!links.declaredType) { - var type = createType(512); - type.symbol = symbol; - if (!ts.getDeclarationOfKind(symbol, 137).constraint) { - type.constraint = noConstraintType; - } - links.declaredType = type; - } - return links.declaredType; - } - function getDeclaredTypeOfAlias(symbol) { - var links = getSymbolLinks(symbol); - if (!links.declaredType) { - links.declaredType = getDeclaredTypeOfSymbol(resolveAlias(symbol)); - } - return links.declaredType; - } - function getDeclaredTypeOfSymbol(symbol) { - ts.Debug.assert((symbol.flags & 16777216) === 0); - if (symbol.flags & (32 | 64)) { - return getDeclaredTypeOfClassOrInterface(symbol); - } - if (symbol.flags & 524288) { - return getDeclaredTypeOfTypeAlias(symbol); - } - if (symbol.flags & 384) { - return getDeclaredTypeOfEnum(symbol); - } - if (symbol.flags & 262144) { - return getDeclaredTypeOfTypeParameter(symbol); - } - if (symbol.flags & 8388608) { - return getDeclaredTypeOfAlias(symbol); - } - return unknownType; - } - function isIndependentTypeReference(node) { - if (node.typeArguments) { - for (var _i = 0, _a = node.typeArguments; _i < _a.length; _i++) { - var typeNode = _a[_i]; - if (!isIndependentType(typeNode)) { - return false; - } - } - } - return true; - } - function isIndependentType(node) { - switch (node.kind) { - case 117: - case 130: - case 128: - case 120: - case 131: - case 103: - case 9: - return true; - case 156: - return isIndependentType(node.elementType); - case 151: - return isIndependentTypeReference(node); - } - return false; - } - function isIndependentVariableLikeDeclaration(node) { - return node.type && isIndependentType(node.type) || !node.type && !node.initializer; - } - function isIndependentFunctionLikeDeclaration(node) { - if (node.kind !== 144 && (!node.type || !isIndependentType(node.type))) { - return false; - } - for (var _i = 0, _a = node.parameters; _i < _a.length; _i++) { - var parameter = _a[_i]; - if (!isIndependentVariableLikeDeclaration(parameter)) { - return false; - } - } - return true; - } - function isIndependentMember(symbol) { - if (symbol.declarations && symbol.declarations.length === 1) { - var declaration = symbol.declarations[0]; - if (declaration) { - switch (declaration.kind) { - case 141: - case 140: - return isIndependentVariableLikeDeclaration(declaration); - case 143: - case 142: - case 144: - return isIndependentFunctionLikeDeclaration(declaration); - } - } - } - return false; - } - function createSymbolTable(symbols) { - var result = {}; - for (var _i = 0; _i < symbols.length; _i++) { - var symbol = symbols[_i]; - result[symbol.name] = symbol; - } - return result; - } - function createInstantiatedSymbolTable(symbols, mapper, mappingThisOnly) { - var result = {}; - for (var _i = 0; _i < symbols.length; _i++) { - var symbol = symbols[_i]; - result[symbol.name] = mappingThisOnly && isIndependentMember(symbol) ? symbol : instantiateSymbol(symbol, mapper); - } - return result; - } - function addInheritedMembers(symbols, baseSymbols) { - for (var _i = 0; _i < baseSymbols.length; _i++) { - var s = baseSymbols[_i]; - if (!ts.hasProperty(symbols, s.name)) { - symbols[s.name] = s; - } - } - } - function addInheritedSignatures(signatures, baseSignatures) { - if (baseSignatures) { - for (var _i = 0; _i < baseSignatures.length; _i++) { - var signature = baseSignatures[_i]; - signatures.push(signature); - } - } - } - function resolveDeclaredMembers(type) { - if (!type.declaredProperties) { - var symbol = type.symbol; - type.declaredProperties = getNamedMembers(symbol.members); - type.declaredCallSignatures = getSignaturesOfSymbol(symbol.members["__call"]); - type.declaredConstructSignatures = getSignaturesOfSymbol(symbol.members["__new"]); - type.declaredStringIndexType = getIndexTypeOfSymbol(symbol, 0); - type.declaredNumberIndexType = getIndexTypeOfSymbol(symbol, 1); - } - return type; - } - function getTypeWithThisArgument(type, thisArgument) { - if (type.flags & 4096) { - return createTypeReference(type.target, ts.concatenate(type.typeArguments, [thisArgument || type.target.thisType])); - } - return type; - } - function resolveObjectTypeMembers(type, source, typeParameters, typeArguments) { - var mapper = identityMapper; - var members = source.symbol.members; - var callSignatures = source.declaredCallSignatures; - var constructSignatures = source.declaredConstructSignatures; - var stringIndexType = source.declaredStringIndexType; - var numberIndexType = source.declaredNumberIndexType; - if (!ts.rangeEquals(typeParameters, typeArguments, 0, typeParameters.length)) { - mapper = createTypeMapper(typeParameters, typeArguments); - members = createInstantiatedSymbolTable(source.declaredProperties, mapper, typeParameters.length === 1); - callSignatures = instantiateList(source.declaredCallSignatures, mapper, instantiateSignature); - constructSignatures = instantiateList(source.declaredConstructSignatures, mapper, instantiateSignature); - stringIndexType = instantiateType(source.declaredStringIndexType, mapper); - numberIndexType = instantiateType(source.declaredNumberIndexType, mapper); - } - var baseTypes = getBaseTypes(source); - if (baseTypes.length) { - if (members === source.symbol.members) { - members = createSymbolTable(source.declaredProperties); - } - var thisArgument = ts.lastOrUndefined(typeArguments); - for (var _i = 0; _i < baseTypes.length; _i++) { - var baseType = baseTypes[_i]; - var instantiatedBaseType = thisArgument ? getTypeWithThisArgument(instantiateType(baseType, mapper), thisArgument) : baseType; - addInheritedMembers(members, getPropertiesOfObjectType(instantiatedBaseType)); - callSignatures = ts.concatenate(callSignatures, getSignaturesOfType(instantiatedBaseType, 0)); - constructSignatures = ts.concatenate(constructSignatures, getSignaturesOfType(instantiatedBaseType, 1)); - stringIndexType = stringIndexType || getIndexTypeOfType(instantiatedBaseType, 0); - numberIndexType = numberIndexType || getIndexTypeOfType(instantiatedBaseType, 1); - } - } - setObjectTypeMembers(type, members, callSignatures, constructSignatures, stringIndexType, numberIndexType); - } - function resolveClassOrInterfaceMembers(type) { - resolveObjectTypeMembers(type, resolveDeclaredMembers(type), emptyArray, emptyArray); - } - function resolveTypeReferenceMembers(type) { - var source = resolveDeclaredMembers(type.target); - var typeParameters = ts.concatenate(source.typeParameters, [source.thisType]); - var typeArguments = type.typeArguments && type.typeArguments.length === typeParameters.length ? - type.typeArguments : ts.concatenate(type.typeArguments, [type]); - resolveObjectTypeMembers(type, source, typeParameters, typeArguments); - } - function createSignature(declaration, typeParameters, parameters, resolvedReturnType, typePredicate, minArgumentCount, hasRestParameter, hasStringLiterals) { - var sig = new Signature(checker); - sig.declaration = declaration; - sig.typeParameters = typeParameters; - sig.parameters = parameters; - sig.resolvedReturnType = resolvedReturnType; - sig.typePredicate = typePredicate; - sig.minArgumentCount = minArgumentCount; - sig.hasRestParameter = hasRestParameter; - sig.hasStringLiterals = hasStringLiterals; - return sig; - } - function cloneSignature(sig) { - return createSignature(sig.declaration, sig.typeParameters, sig.parameters, sig.resolvedReturnType, sig.typePredicate, sig.minArgumentCount, sig.hasRestParameter, sig.hasStringLiterals); - } - function getDefaultConstructSignatures(classType) { - if (!hasClassBaseType(classType)) { - return [createSignature(undefined, classType.localTypeParameters, emptyArray, classType, undefined, 0, false, false)]; - } - var baseConstructorType = getBaseConstructorTypeOfClass(classType); - var baseSignatures = getSignaturesOfType(baseConstructorType, 1); - var baseTypeNode = getBaseTypeNodeOfClass(classType); - var typeArguments = ts.map(baseTypeNode.typeArguments, getTypeFromTypeNode); - var typeArgCount = typeArguments ? typeArguments.length : 0; - var result = []; - for (var _i = 0; _i < baseSignatures.length; _i++) { - var baseSig = baseSignatures[_i]; - var typeParamCount = baseSig.typeParameters ? baseSig.typeParameters.length : 0; - if (typeParamCount === typeArgCount) { - var sig = typeParamCount ? getSignatureInstantiation(baseSig, typeArguments) : cloneSignature(baseSig); - sig.typeParameters = classType.localTypeParameters; - sig.resolvedReturnType = classType; - result.push(sig); - } - } - return result; - } - function createTupleTypeMemberSymbols(memberTypes) { - var members = {}; - for (var i = 0; i < memberTypes.length; i++) { - var symbol = createSymbol(4 | 67108864, "" + i); - symbol.type = memberTypes[i]; - members[i] = symbol; - } - return members; - } - function resolveTupleTypeMembers(type) { - var arrayElementType = getUnionType(type.elementTypes, true); - var arrayType = resolveStructuredTypeMembers(createTypeFromGenericGlobalType(globalArrayType, [arrayElementType, type])); - var members = createTupleTypeMemberSymbols(type.elementTypes); - addInheritedMembers(members, arrayType.properties); - setObjectTypeMembers(type, members, arrayType.callSignatures, arrayType.constructSignatures, arrayType.stringIndexType, arrayType.numberIndexType); - } - function findMatchingSignature(signatureList, signature, partialMatch, ignoreReturnTypes) { - for (var _i = 0; _i < signatureList.length; _i++) { - var s = signatureList[_i]; - if (compareSignatures(s, signature, partialMatch, ignoreReturnTypes, compareTypes)) { - return s; - } - } - } - function findMatchingSignatures(signatureLists, signature, listIndex) { - if (signature.typeParameters) { - if (listIndex > 0) { - return undefined; - } - for (var i = 1; i < signatureLists.length; i++) { - if (!findMatchingSignature(signatureLists[i], signature, false, false)) { - return undefined; - } - } - return [signature]; - } - var result = undefined; - for (var i = 0; i < signatureLists.length; i++) { - var match = i === listIndex ? signature : findMatchingSignature(signatureLists[i], signature, true, true); - if (!match) { - return undefined; - } - if (!ts.contains(result, match)) { - (result || (result = [])).push(match); - } - } - return result; - } - function getUnionSignatures(types, kind) { - var signatureLists = ts.map(types, function (t) { return getSignaturesOfType(t, kind); }); - var result = undefined; - for (var i = 0; i < signatureLists.length; i++) { - for (var _i = 0, _a = signatureLists[i]; _i < _a.length; _i++) { - var signature = _a[_i]; - if (!result || !findMatchingSignature(result, signature, false, true)) { - var unionSignatures = findMatchingSignatures(signatureLists, signature, i); - if (unionSignatures) { - var s = signature; - if (unionSignatures.length > 1) { - s = cloneSignature(signature); - s.resolvedReturnType = undefined; - s.unionSignatures = unionSignatures; - } - (result || (result = [])).push(s); - } - } - } - } - return result || emptyArray; - } - function getUnionIndexType(types, kind) { - var indexTypes = []; - for (var _i = 0; _i < types.length; _i++) { - var type = types[_i]; - var indexType = getIndexTypeOfType(type, kind); - if (!indexType) { - return undefined; - } - indexTypes.push(indexType); - } - return getUnionType(indexTypes); - } - function resolveUnionTypeMembers(type) { - var callSignatures = getUnionSignatures(type.types, 0); - var constructSignatures = getUnionSignatures(type.types, 1); - var stringIndexType = getUnionIndexType(type.types, 0); - var numberIndexType = getUnionIndexType(type.types, 1); - setObjectTypeMembers(type, emptySymbols, callSignatures, constructSignatures, stringIndexType, numberIndexType); - } - function intersectTypes(type1, type2) { - return !type1 ? type2 : !type2 ? type1 : getIntersectionType([type1, type2]); - } - function resolveIntersectionTypeMembers(type) { - var callSignatures = emptyArray; - var constructSignatures = emptyArray; - var stringIndexType = undefined; - var numberIndexType = undefined; - for (var _i = 0, _a = type.types; _i < _a.length; _i++) { - var t = _a[_i]; - callSignatures = ts.concatenate(callSignatures, getSignaturesOfType(t, 0)); - constructSignatures = ts.concatenate(constructSignatures, getSignaturesOfType(t, 1)); - stringIndexType = intersectTypes(stringIndexType, getIndexTypeOfType(t, 0)); - numberIndexType = intersectTypes(numberIndexType, getIndexTypeOfType(t, 1)); - } - setObjectTypeMembers(type, emptySymbols, callSignatures, constructSignatures, stringIndexType, numberIndexType); - } - function resolveAnonymousTypeMembers(type) { - var symbol = type.symbol; - var members; - var callSignatures; - var constructSignatures; - var stringIndexType; - var numberIndexType; - if (type.target) { - members = createInstantiatedSymbolTable(getPropertiesOfObjectType(type.target), type.mapper, false); - callSignatures = instantiateList(getSignaturesOfType(type.target, 0), type.mapper, instantiateSignature); - constructSignatures = instantiateList(getSignaturesOfType(type.target, 1), type.mapper, instantiateSignature); - stringIndexType = instantiateType(getIndexTypeOfType(type.target, 0), type.mapper); - numberIndexType = instantiateType(getIndexTypeOfType(type.target, 1), type.mapper); - } - else if (symbol.flags & 2048) { - members = symbol.members; - callSignatures = getSignaturesOfSymbol(members["__call"]); - constructSignatures = getSignaturesOfSymbol(members["__new"]); - stringIndexType = getIndexTypeOfSymbol(symbol, 0); - numberIndexType = getIndexTypeOfSymbol(symbol, 1); - } - else { - members = emptySymbols; - callSignatures = emptyArray; - constructSignatures = emptyArray; - if (symbol.flags & 1952) { - members = getExportsOfSymbol(symbol); - } - if (symbol.flags & (16 | 8192)) { - callSignatures = getSignaturesOfSymbol(symbol); - } - if (symbol.flags & 32) { - var classType = getDeclaredTypeOfClassOrInterface(symbol); - constructSignatures = getSignaturesOfSymbol(symbol.members["__constructor"]); - if (!constructSignatures.length) { - constructSignatures = getDefaultConstructSignatures(classType); - } - var baseConstructorType = getBaseConstructorTypeOfClass(classType); - if (baseConstructorType.flags & 80896) { - members = createSymbolTable(getNamedMembers(members)); - addInheritedMembers(members, getPropertiesOfObjectType(baseConstructorType)); - } - } - stringIndexType = undefined; - numberIndexType = (symbol.flags & 384) ? stringType : undefined; - } - setObjectTypeMembers(type, members, callSignatures, constructSignatures, stringIndexType, numberIndexType); - } - function resolveStructuredTypeMembers(type) { - if (!type.members) { - if (type.flags & 4096) { - resolveTypeReferenceMembers(type); - } - else if (type.flags & (1024 | 2048)) { - resolveClassOrInterfaceMembers(type); - } - else if (type.flags & 65536) { - resolveAnonymousTypeMembers(type); - } - else if (type.flags & 8192) { - resolveTupleTypeMembers(type); - } - else if (type.flags & 16384) { - resolveUnionTypeMembers(type); - } - else if (type.flags & 32768) { - resolveIntersectionTypeMembers(type); - } - } - return type; - } - function getPropertiesOfObjectType(type) { - if (type.flags & 80896) { - return resolveStructuredTypeMembers(type).properties; - } - return emptyArray; - } - function getPropertyOfObjectType(type, name) { - if (type.flags & 80896) { - var resolved = resolveStructuredTypeMembers(type); - if (ts.hasProperty(resolved.members, name)) { - var symbol = resolved.members[name]; - if (symbolIsValue(symbol)) { - return symbol; - } - } - } - } - function getPropertiesOfUnionOrIntersectionType(type) { - for (var _i = 0, _a = type.types; _i < _a.length; _i++) { - var current = _a[_i]; - for (var _b = 0, _c = getPropertiesOfType(current); _b < _c.length; _b++) { - var prop = _c[_b]; - getPropertyOfUnionOrIntersectionType(type, prop.name); - } - if (type.flags & 16384) { - break; - } - } - return type.resolvedProperties ? symbolsToArray(type.resolvedProperties) : emptyArray; - } - function getPropertiesOfType(type) { - type = getApparentType(type); - return type.flags & 49152 ? getPropertiesOfUnionOrIntersectionType(type) : getPropertiesOfObjectType(type); - } - function getApparentType(type) { - if (type.flags & 512) { - do { - type = getConstraintOfTypeParameter(type); - } while (type && type.flags & 512); - if (!type) { - type = emptyObjectType; - } - } - if (type.flags & 258) { - type = globalStringType; - } - else if (type.flags & 132) { - type = globalNumberType; - } - else if (type.flags & 8) { - type = globalBooleanType; - } - else if (type.flags & 16777216) { - type = globalESSymbolType; - } - return type; - } - function createUnionOrIntersectionProperty(containingType, name) { - var types = containingType.types; - var props; - for (var _i = 0; _i < types.length; _i++) { - var current = types[_i]; - var type = getApparentType(current); - if (type !== unknownType) { - var prop = getPropertyOfType(type, name); - if (prop && !(getDeclarationFlagsFromSymbol(prop) & (32 | 64))) { - if (!props) { - props = [prop]; - } - else if (!ts.contains(props, prop)) { - props.push(prop); - } - } - else if (containingType.flags & 16384) { - return undefined; - } - } - } - if (!props) { - return undefined; - } - if (props.length === 1) { - return props[0]; - } - var propTypes = []; - var declarations = []; - for (var _a = 0; _a < props.length; _a++) { - var prop = props[_a]; - if (prop.declarations) { - ts.addRange(declarations, prop.declarations); - } - propTypes.push(getTypeOfSymbol(prop)); - } - var result = createSymbol(4 | 67108864 | 268435456, name); - result.containingType = containingType; - result.declarations = declarations; - result.type = containingType.flags & 16384 ? getUnionType(propTypes) : getIntersectionType(propTypes); - return result; - } - function getPropertyOfUnionOrIntersectionType(type, name) { - var properties = type.resolvedProperties || (type.resolvedProperties = {}); - if (ts.hasProperty(properties, name)) { - return properties[name]; - } - var property = createUnionOrIntersectionProperty(type, name); - if (property) { - properties[name] = property; - } - return property; - } - function getPropertyOfType(type, name) { - type = getApparentType(type); - if (type.flags & 80896) { - var resolved = resolveStructuredTypeMembers(type); - if (ts.hasProperty(resolved.members, name)) { - var symbol = resolved.members[name]; - if (symbolIsValue(symbol)) { - return symbol; - } - } - if (resolved === anyFunctionType || resolved.callSignatures.length || resolved.constructSignatures.length) { - var symbol = getPropertyOfObjectType(globalFunctionType, name); - if (symbol) { - return symbol; - } - } - return getPropertyOfObjectType(globalObjectType, name); - } - if (type.flags & 49152) { - return getPropertyOfUnionOrIntersectionType(type, name); - } - return undefined; - } - function getSignaturesOfStructuredType(type, kind) { - if (type.flags & 130048) { - var resolved = resolveStructuredTypeMembers(type); - return kind === 0 ? resolved.callSignatures : resolved.constructSignatures; - } - return emptyArray; - } - function getSignaturesOfType(type, kind) { - return getSignaturesOfStructuredType(getApparentType(type), kind); - } - function typeHasConstructSignatures(type) { - var apparentType = getApparentType(type); - if (apparentType.flags & (80896 | 16384)) { - var resolved = resolveStructuredTypeMembers(type); - return resolved.constructSignatures.length > 0; - } - return false; - } - function typeHasCallOrConstructSignatures(type) { - var apparentType = getApparentType(type); - if (apparentType.flags & 130048) { - var resolved = resolveStructuredTypeMembers(type); - return resolved.callSignatures.length > 0 || resolved.constructSignatures.length > 0; - } - return false; - } - function getIndexTypeOfStructuredType(type, kind) { - if (type.flags & 130048) { - var resolved = resolveStructuredTypeMembers(type); - return kind === 0 ? resolved.stringIndexType : resolved.numberIndexType; - } - } - function getIndexTypeOfType(type, kind) { - return getIndexTypeOfStructuredType(getApparentType(type), kind); - } - function getTypeParametersFromDeclaration(typeParameterDeclarations) { - var result = []; - ts.forEach(typeParameterDeclarations, function (node) { - var tp = getDeclaredTypeOfTypeParameter(node.symbol); - if (!ts.contains(result, tp)) { - result.push(tp); - } - }); - return result; - } - function symbolsToArray(symbols) { - var result = []; - for (var id in symbols) { - if (!isReservedMemberName(id)) { - result.push(symbols[id]); - } - } - return result; - } - function isOptionalParameter(node) { - if (ts.hasQuestionToken(node)) { - return true; - } - if (node.initializer) { - var signatureDeclaration = node.parent; - var signature = getSignatureFromDeclaration(signatureDeclaration); - var parameterIndex = signatureDeclaration.parameters.indexOf(node); - ts.Debug.assert(parameterIndex >= 0); - return parameterIndex >= signature.minArgumentCount; - } - return false; - } - function getSignatureFromDeclaration(declaration) { - var links = getNodeLinks(declaration); - if (!links.resolvedSignature) { - var classType = declaration.kind === 144 ? - getDeclaredTypeOfClassOrInterface(getMergedSymbol(declaration.parent.symbol)) - : undefined; - var typeParameters = classType ? classType.localTypeParameters : - declaration.typeParameters ? getTypeParametersFromDeclaration(declaration.typeParameters) : undefined; - var parameters = []; - var hasStringLiterals = false; - var minArgumentCount = -1; - for (var i = 0, n = declaration.parameters.length; i < n; i++) { - var param = declaration.parameters[i]; - parameters.push(param.symbol); - if (param.type && param.type.kind === 9) { - hasStringLiterals = true; - } - if (param.initializer || param.questionToken || param.dotDotDotToken) { - if (minArgumentCount < 0) { - minArgumentCount = i; - } - } - else { - minArgumentCount = -1; - } - } - if (minArgumentCount < 0) { - minArgumentCount = declaration.parameters.length; - } - var returnType; - var typePredicate; - if (classType) { - returnType = classType; - } - else if (declaration.type) { - returnType = getTypeFromTypeNode(declaration.type); - if (declaration.type.kind === 150) { - var typePredicateNode = declaration.type; - typePredicate = { - parameterName: typePredicateNode.parameterName ? typePredicateNode.parameterName.text : undefined, - parameterIndex: typePredicateNode.parameterName ? getTypePredicateParameterIndex(declaration.parameters, typePredicateNode.parameterName) : undefined, - type: getTypeFromTypeNode(typePredicateNode.type) - }; - } - } - else { - if (declaration.kind === 145 && !ts.hasDynamicName(declaration)) { - var setter = ts.getDeclarationOfKind(declaration.symbol, 146); - returnType = getAnnotatedAccessorType(setter); - } - if (!returnType && ts.nodeIsMissing(declaration.body)) { - returnType = anyType; - } - } - links.resolvedSignature = createSignature(declaration, typeParameters, parameters, returnType, typePredicate, minArgumentCount, ts.hasRestParameter(declaration), hasStringLiterals); - } - return links.resolvedSignature; - } - function getSignaturesOfSymbol(symbol) { - if (!symbol) - return emptyArray; - var result = []; - for (var i = 0, len = symbol.declarations.length; i < len; i++) { - var node = symbol.declarations[i]; - switch (node.kind) { - case 152: - case 153: - case 213: - case 143: - case 142: - case 144: - case 147: - case 148: - case 149: - case 145: - case 146: - case 173: - case 174: - if (i > 0 && node.body) { - var previous = symbol.declarations[i - 1]; - if (node.parent === previous.parent && node.kind === previous.kind && node.pos === previous.end) { - break; - } - } - result.push(getSignatureFromDeclaration(node)); - } - } - return result; - } - function getReturnTypeOfSignature(signature) { - if (!signature.resolvedReturnType) { - if (!pushTypeResolution(signature, 3)) { - return unknownType; - } - var type; - if (signature.target) { - type = instantiateType(getReturnTypeOfSignature(signature.target), signature.mapper); - } - else if (signature.unionSignatures) { - type = getUnionType(ts.map(signature.unionSignatures, getReturnTypeOfSignature)); - } - else { - type = getReturnTypeFromBody(signature.declaration); - } - if (!popTypeResolution()) { - type = anyType; - if (compilerOptions.noImplicitAny) { - var declaration = signature.declaration; - if (declaration.name) { - error(declaration.name, 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, ts.declarationNameToString(declaration.name)); - } - else { - error(declaration, ts.Diagnostics.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); - } - } - } - signature.resolvedReturnType = type; - } - return signature.resolvedReturnType; - } - function getRestTypeOfSignature(signature) { - if (signature.hasRestParameter) { - var type = getTypeOfSymbol(ts.lastOrUndefined(signature.parameters)); - if (type.flags & 4096 && type.target === globalArrayType) { - return type.typeArguments[0]; - } - } - return anyType; - } - function getSignatureInstantiation(signature, typeArguments) { - return instantiateSignature(signature, createTypeMapper(signature.typeParameters, typeArguments), true); - } - function getErasedSignature(signature) { - if (!signature.typeParameters) - return signature; - if (!signature.erasedSignatureCache) { - if (signature.target) { - signature.erasedSignatureCache = instantiateSignature(getErasedSignature(signature.target), signature.mapper); - } - else { - signature.erasedSignatureCache = instantiateSignature(signature, createTypeEraser(signature.typeParameters), true); - } - } - return signature.erasedSignatureCache; - } - function getOrCreateTypeFromSignature(signature) { - if (!signature.isolatedSignatureType) { - var isConstructor = signature.declaration.kind === 144 || signature.declaration.kind === 148; - var type = createObjectType(65536 | 262144); - type.members = emptySymbols; - type.properties = emptyArray; - type.callSignatures = !isConstructor ? [signature] : emptyArray; - type.constructSignatures = isConstructor ? [signature] : emptyArray; - signature.isolatedSignatureType = type; - } - return signature.isolatedSignatureType; - } - function getIndexSymbol(symbol) { - return symbol.members["__index"]; - } - function getIndexDeclarationOfSymbol(symbol, kind) { - var syntaxKind = kind === 1 ? 128 : 130; - var indexSymbol = getIndexSymbol(symbol); - if (indexSymbol) { - for (var _i = 0, _a = indexSymbol.declarations; _i < _a.length; _i++) { - var decl = _a[_i]; - var node = decl; - if (node.parameters.length === 1) { - var parameter = node.parameters[0]; - if (parameter && parameter.type && parameter.type.kind === syntaxKind) { - return node; - } - } - } - } - return undefined; - } - function getIndexTypeOfSymbol(symbol, kind) { - var declaration = getIndexDeclarationOfSymbol(symbol, kind); - return declaration - ? declaration.type ? getTypeFromTypeNode(declaration.type) : anyType - : undefined; - } - function getConstraintOfTypeParameter(type) { - if (!type.constraint) { - if (type.target) { - var targetConstraint = getConstraintOfTypeParameter(type.target); - type.constraint = targetConstraint ? instantiateType(targetConstraint, type.mapper) : noConstraintType; - } - else { - type.constraint = getTypeFromTypeNode(ts.getDeclarationOfKind(type.symbol, 137).constraint); - } - } - return type.constraint === noConstraintType ? undefined : type.constraint; - } - function getParentSymbolOfTypeParameter(typeParameter) { - return getSymbolOfNode(ts.getDeclarationOfKind(typeParameter.symbol, 137).parent); - } - function getTypeListId(types) { - if (types) { - switch (types.length) { - case 1: - return "" + types[0].id; - case 2: - return types[0].id + "," + types[1].id; - default: - var result = ""; - for (var i = 0; i < types.length; i++) { - if (i > 0) { - result += ","; - } - result += types[i].id; - } - return result; - } - } - return ""; - } - function getPropagatingFlagsOfTypes(types) { - var result = 0; - for (var _i = 0; _i < types.length; _i++) { - var type = types[_i]; - result |= type.flags; - } - return result & 14680064; - } - function createTypeReference(target, typeArguments) { - var id = getTypeListId(typeArguments); - var type = target.instantiations[id]; - if (!type) { - var flags = 4096 | (typeArguments ? getPropagatingFlagsOfTypes(typeArguments) : 0); - type = target.instantiations[id] = createObjectType(flags, target.symbol); - type.target = target; - type.typeArguments = typeArguments; - } - return type; - } - function isTypeParameterReferenceIllegalInConstraint(typeReferenceNode, typeParameterSymbol) { - var links = getNodeLinks(typeReferenceNode); - if (links.isIllegalTypeReferenceInConstraint !== undefined) { - return links.isIllegalTypeReferenceInConstraint; - } - var currentNode = typeReferenceNode; - while (!ts.forEach(typeParameterSymbol.declarations, function (d) { return d.parent === currentNode.parent; })) { - currentNode = currentNode.parent; - } - links.isIllegalTypeReferenceInConstraint = currentNode.kind === 137; - return links.isIllegalTypeReferenceInConstraint; - } - function checkTypeParameterHasIllegalReferencesInConstraint(typeParameter) { - var typeParameterSymbol; - function check(n) { - if (n.kind === 151 && n.typeName.kind === 69) { - var links = getNodeLinks(n); - if (links.isIllegalTypeReferenceInConstraint === undefined) { - var symbol = resolveName(typeParameter, n.typeName.text, 793056, undefined, undefined); - if (symbol && (symbol.flags & 262144)) { - links.isIllegalTypeReferenceInConstraint = ts.forEach(symbol.declarations, function (d) { return d.parent === typeParameter.parent; }); - } - } - if (links.isIllegalTypeReferenceInConstraint) { - error(typeParameter, ts.Diagnostics.Constraint_of_a_type_parameter_cannot_reference_any_type_parameter_from_the_same_type_parameter_list); - } - } - ts.forEachChild(n, check); - } - if (typeParameter.constraint) { - typeParameterSymbol = getSymbolOfNode(typeParameter); - check(typeParameter.constraint); - } - } - function getTypeFromClassOrInterfaceReference(node, symbol) { - var type = getDeclaredTypeOfSymbol(symbol); - var typeParameters = type.localTypeParameters; - if (typeParameters) { - if (!node.typeArguments || node.typeArguments.length !== typeParameters.length) { - error(node, ts.Diagnostics.Generic_type_0_requires_1_type_argument_s, typeToString(type, undefined, 1), typeParameters.length); - return unknownType; - } - return createTypeReference(type, ts.concatenate(type.outerTypeParameters, ts.map(node.typeArguments, getTypeFromTypeNode))); - } - if (node.typeArguments) { - error(node, ts.Diagnostics.Type_0_is_not_generic, typeToString(type)); - return unknownType; - } - return type; - } - function getTypeFromTypeAliasReference(node, symbol) { - var type = getDeclaredTypeOfSymbol(symbol); - var links = getSymbolLinks(symbol); - var typeParameters = links.typeParameters; - if (typeParameters) { - if (!node.typeArguments || node.typeArguments.length !== typeParameters.length) { - error(node, ts.Diagnostics.Generic_type_0_requires_1_type_argument_s, symbolToString(symbol), typeParameters.length); - return unknownType; - } - var typeArguments = ts.map(node.typeArguments, getTypeFromTypeNode); - var id = getTypeListId(typeArguments); - return links.instantiations[id] || (links.instantiations[id] = instantiateType(type, createTypeMapper(typeParameters, typeArguments))); - } - if (node.typeArguments) { - error(node, ts.Diagnostics.Type_0_is_not_generic, symbolToString(symbol)); - return unknownType; - } - return type; - } - function getTypeFromNonGenericTypeReference(node, symbol) { - if (symbol.flags & 262144 && isTypeParameterReferenceIllegalInConstraint(node, symbol)) { - return unknownType; - } - if (node.typeArguments) { - error(node, ts.Diagnostics.Type_0_is_not_generic, symbolToString(symbol)); - return unknownType; - } - return getDeclaredTypeOfSymbol(symbol); - } - function getTypeFromTypeReference(node) { - var links = getNodeLinks(node); - if (!links.resolvedType) { - var typeNameOrExpression = node.kind === 151 ? node.typeName : - ts.isSupportedExpressionWithTypeArguments(node) ? node.expression : - undefined; - var symbol = typeNameOrExpression && resolveEntityName(typeNameOrExpression, 793056) || unknownSymbol; - var type = symbol === unknownSymbol ? unknownType : - symbol.flags & (32 | 64) ? getTypeFromClassOrInterfaceReference(node, symbol) : - symbol.flags & 524288 ? getTypeFromTypeAliasReference(node, symbol) : - getTypeFromNonGenericTypeReference(node, symbol); - links.resolvedSymbol = symbol; - links.resolvedType = type; - } - return links.resolvedType; - } - function getTypeFromTypeQueryNode(node) { - var links = getNodeLinks(node); - if (!links.resolvedType) { - links.resolvedType = getWidenedType(checkExpression(node.exprName)); - } - return links.resolvedType; - } - function getTypeOfGlobalSymbol(symbol, arity) { - function getTypeDeclaration(symbol) { - var declarations = symbol.declarations; - for (var _i = 0; _i < declarations.length; _i++) { - var declaration = declarations[_i]; - switch (declaration.kind) { - case 214: - case 215: - case 217: - return declaration; - } - } - } - if (!symbol) { - return arity ? emptyGenericType : emptyObjectType; - } - var type = getDeclaredTypeOfSymbol(symbol); - if (!(type.flags & 80896)) { - error(getTypeDeclaration(symbol), ts.Diagnostics.Global_type_0_must_be_a_class_or_interface_type, symbol.name); - return arity ? emptyGenericType : emptyObjectType; - } - if ((type.typeParameters ? type.typeParameters.length : 0) !== arity) { - error(getTypeDeclaration(symbol), ts.Diagnostics.Global_type_0_must_have_1_type_parameter_s, symbol.name, arity); - return arity ? emptyGenericType : emptyObjectType; - } - return type; - } - function getGlobalValueSymbol(name) { - return getGlobalSymbol(name, 107455, ts.Diagnostics.Cannot_find_global_value_0); - } - function getGlobalTypeSymbol(name) { - return getGlobalSymbol(name, 793056, ts.Diagnostics.Cannot_find_global_type_0); - } - function getGlobalSymbol(name, meaning, diagnostic) { - return resolveName(undefined, name, meaning, diagnostic, name); - } - function getGlobalType(name, arity) { - if (arity === void 0) { arity = 0; } - return getTypeOfGlobalSymbol(getGlobalTypeSymbol(name), arity); - } - function tryGetGlobalType(name, arity) { - if (arity === void 0) { arity = 0; } - return getTypeOfGlobalSymbol(getGlobalSymbol(name, 793056, undefined), arity); - } - function getExportedTypeFromNamespace(namespace, name) { - var namespaceSymbol = getGlobalSymbol(namespace, 1536, undefined); - var typeSymbol = namespaceSymbol && getSymbol(namespaceSymbol.exports, name, 793056); - return typeSymbol && getDeclaredTypeOfSymbol(typeSymbol); - } - function getGlobalESSymbolConstructorSymbol() { - return globalESSymbolConstructorSymbol || (globalESSymbolConstructorSymbol = getGlobalValueSymbol("Symbol")); - } - function createTypedPropertyDescriptorType(propertyType) { - var globalTypedPropertyDescriptorType = getGlobalTypedPropertyDescriptorType(); - return globalTypedPropertyDescriptorType !== emptyGenericType - ? createTypeReference(globalTypedPropertyDescriptorType, [propertyType]) - : emptyObjectType; - } - function createTypeFromGenericGlobalType(genericGlobalType, typeArguments) { - return genericGlobalType !== emptyGenericType ? createTypeReference(genericGlobalType, typeArguments) : emptyObjectType; - } - function createIterableType(elementType) { - return createTypeFromGenericGlobalType(globalIterableType, [elementType]); - } - function createIterableIteratorType(elementType) { - return createTypeFromGenericGlobalType(globalIterableIteratorType, [elementType]); - } - function createArrayType(elementType) { - return createTypeFromGenericGlobalType(globalArrayType, [elementType]); - } - function getTypeFromArrayTypeNode(node) { - var links = getNodeLinks(node); - if (!links.resolvedType) { - links.resolvedType = createArrayType(getTypeFromTypeNode(node.elementType)); - } - return links.resolvedType; - } - function createTupleType(elementTypes) { - var id = getTypeListId(elementTypes); - return tupleTypes[id] || (tupleTypes[id] = createNewTupleType(elementTypes)); - } - function createNewTupleType(elementTypes) { - var type = createObjectType(8192 | getPropagatingFlagsOfTypes(elementTypes)); - type.elementTypes = elementTypes; - return type; - } - function getTypeFromTupleTypeNode(node) { - var links = getNodeLinks(node); - if (!links.resolvedType) { - links.resolvedType = createTupleType(ts.map(node.elementTypes, getTypeFromTypeNode)); - } - return links.resolvedType; - } - function addTypeToSet(typeSet, type, typeSetKind) { - if (type.flags & typeSetKind) { - addTypesToSet(typeSet, type.types, typeSetKind); - } - else if (!ts.contains(typeSet, type)) { - typeSet.push(type); - } - } - function addTypesToSet(typeSet, types, typeSetKind) { - for (var _i = 0; _i < types.length; _i++) { - var type = types[_i]; - addTypeToSet(typeSet, type, typeSetKind); - } - } - function isSubtypeOfAny(candidate, types) { - for (var i = 0, len = types.length; i < len; i++) { - if (candidate !== types[i] && isTypeSubtypeOf(candidate, types[i])) { - return true; - } - } - return false; - } - function removeSubtypes(types) { - var i = types.length; - while (i > 0) { - i--; - if (isSubtypeOfAny(types[i], types)) { - types.splice(i, 1); - } - } - } - function containsTypeAny(types) { - for (var _i = 0; _i < types.length; _i++) { - var type = types[_i]; - if (isTypeAny(type)) { - return true; - } - } - return false; - } - function removeAllButLast(types, typeToRemove) { - var i = types.length; - while (i > 0 && types.length > 1) { - i--; - if (types[i] === typeToRemove) { - types.splice(i, 1); - } - } - } - function getUnionType(types, noSubtypeReduction) { - if (types.length === 0) { - return emptyObjectType; - } - var typeSet = []; - addTypesToSet(typeSet, types, 16384); - if (containsTypeAny(typeSet)) { - return anyType; - } - if (noSubtypeReduction) { - removeAllButLast(typeSet, undefinedType); - removeAllButLast(typeSet, nullType); - } - else { - removeSubtypes(typeSet); - } - if (typeSet.length === 1) { - return typeSet[0]; - } - var id = getTypeListId(typeSet); - var type = unionTypes[id]; - if (!type) { - type = unionTypes[id] = createObjectType(16384 | getPropagatingFlagsOfTypes(typeSet)); - type.types = typeSet; - } - return type; - } - function getTypeFromUnionTypeNode(node) { - var links = getNodeLinks(node); - if (!links.resolvedType) { - links.resolvedType = getUnionType(ts.map(node.types, getTypeFromTypeNode), true); - } - return links.resolvedType; - } - function getIntersectionType(types) { - if (types.length === 0) { - return emptyObjectType; - } - var typeSet = []; - addTypesToSet(typeSet, types, 32768); - if (containsTypeAny(typeSet)) { - return anyType; - } - if (typeSet.length === 1) { - return typeSet[0]; - } - var id = getTypeListId(typeSet); - var type = intersectionTypes[id]; - if (!type) { - type = intersectionTypes[id] = createObjectType(32768 | getPropagatingFlagsOfTypes(typeSet)); - type.types = typeSet; - } - return type; - } - function getTypeFromIntersectionTypeNode(node) { - var links = getNodeLinks(node); - if (!links.resolvedType) { - links.resolvedType = getIntersectionType(ts.map(node.types, getTypeFromTypeNode)); - } - return links.resolvedType; - } - function getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node) { - var links = getNodeLinks(node); - if (!links.resolvedType) { - links.resolvedType = createObjectType(65536, node.symbol); - } - return links.resolvedType; - } - function getStringLiteralType(node) { - if (ts.hasProperty(stringLiteralTypes, node.text)) { - return stringLiteralTypes[node.text]; - } - var type = stringLiteralTypes[node.text] = createType(256); - type.text = ts.getTextOfNode(node); - return type; - } - function getTypeFromStringLiteral(node) { - var links = getNodeLinks(node); - if (!links.resolvedType) { - links.resolvedType = getStringLiteralType(node); - } - return links.resolvedType; - } - function getThisType(node) { - var container = ts.getThisContainer(node, false); - var parent = container && container.parent; - if (parent && (ts.isClassLike(parent) || parent.kind === 215)) { - if (!(container.flags & 128)) { - return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(parent)).thisType; - } - } - error(node, ts.Diagnostics.A_this_type_is_available_only_in_a_non_static_member_of_a_class_or_interface); - return unknownType; - } - function getTypeFromThisTypeNode(node) { - var links = getNodeLinks(node); - if (!links.resolvedType) { - links.resolvedType = getThisType(node); - } - return links.resolvedType; - } - function getTypeFromTypeNode(node) { - switch (node.kind) { - case 117: - return anyType; - case 130: - return stringType; - case 128: - return numberType; - case 120: - return booleanType; - case 131: - return esSymbolType; - case 103: - return voidType; - case 97: - return getTypeFromThisTypeNode(node); - case 9: - return getTypeFromStringLiteral(node); - case 151: - return getTypeFromTypeReference(node); - case 150: - return booleanType; - case 188: - return getTypeFromTypeReference(node); - case 154: - return getTypeFromTypeQueryNode(node); - case 156: - return getTypeFromArrayTypeNode(node); - case 157: - return getTypeFromTupleTypeNode(node); - case 158: - return getTypeFromUnionTypeNode(node); - case 159: - return getTypeFromIntersectionTypeNode(node); - case 160: - return getTypeFromTypeNode(node.type); - case 152: - case 153: - case 155: - return getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node); - case 69: - case 135: - var symbol = getSymbolAtLocation(node); - return symbol && getDeclaredTypeOfSymbol(symbol); - default: - return unknownType; - } - } - function instantiateList(items, mapper, instantiator) { - if (items && items.length) { - var result = []; - for (var _i = 0; _i < items.length; _i++) { - var v = items[_i]; - result.push(instantiator(v, mapper)); - } - return result; - } - return items; - } - function createUnaryTypeMapper(source, target) { - return function (t) { return t === source ? target : t; }; - } - function createBinaryTypeMapper(source1, target1, source2, target2) { - return function (t) { return t === source1 ? target1 : t === source2 ? target2 : t; }; - } - function createTypeMapper(sources, targets) { - switch (sources.length) { - case 1: return createUnaryTypeMapper(sources[0], targets[0]); - case 2: return createBinaryTypeMapper(sources[0], targets[0], sources[1], targets[1]); - } - return function (t) { - for (var i = 0; i < sources.length; i++) { - if (t === sources[i]) { - return targets[i]; - } - } - return t; - }; - } - function createUnaryTypeEraser(source) { - return function (t) { return t === source ? anyType : t; }; - } - function createBinaryTypeEraser(source1, source2) { - return function (t) { return t === source1 || t === source2 ? anyType : t; }; - } - function createTypeEraser(sources) { - switch (sources.length) { - case 1: return createUnaryTypeEraser(sources[0]); - case 2: return createBinaryTypeEraser(sources[0], sources[1]); - } - return function (t) { - for (var _i = 0; _i < sources.length; _i++) { - var source = sources[_i]; - if (t === source) { - return anyType; - } - } - return t; - }; - } - function createInferenceMapper(context) { - var mapper = function (t) { - for (var i = 0; i < context.typeParameters.length; i++) { - if (t === context.typeParameters[i]) { - context.inferences[i].isFixed = true; - return getInferredType(context, i); - } - } - return t; - }; - mapper.context = context; - return mapper; - } - function identityMapper(type) { - return type; - } - function combineTypeMappers(mapper1, mapper2) { - return function (t) { return instantiateType(mapper1(t), mapper2); }; - } - function instantiateTypeParameter(typeParameter, mapper) { - var result = createType(512); - result.symbol = typeParameter.symbol; - if (typeParameter.constraint) { - result.constraint = instantiateType(typeParameter.constraint, mapper); - } - else { - result.target = typeParameter; - result.mapper = mapper; - } - return result; - } - function instantiateSignature(signature, mapper, eraseTypeParameters) { - var freshTypeParameters; - var freshTypePredicate; - if (signature.typeParameters && !eraseTypeParameters) { - freshTypeParameters = instantiateList(signature.typeParameters, mapper, instantiateTypeParameter); - mapper = combineTypeMappers(createTypeMapper(signature.typeParameters, freshTypeParameters), mapper); - } - if (signature.typePredicate) { - freshTypePredicate = { - parameterName: signature.typePredicate.parameterName, - parameterIndex: signature.typePredicate.parameterIndex, - type: instantiateType(signature.typePredicate.type, mapper) - }; - } - var result = createSignature(signature.declaration, freshTypeParameters, instantiateList(signature.parameters, mapper, instantiateSymbol), instantiateType(signature.resolvedReturnType, mapper), freshTypePredicate, signature.minArgumentCount, signature.hasRestParameter, signature.hasStringLiterals); - result.target = signature; - result.mapper = mapper; - return result; - } - function instantiateSymbol(symbol, mapper) { - if (symbol.flags & 16777216) { - var links = getSymbolLinks(symbol); - symbol = links.target; - mapper = combineTypeMappers(links.mapper, mapper); - } - var result = createSymbol(16777216 | 67108864 | symbol.flags, symbol.name); - result.declarations = symbol.declarations; - result.parent = symbol.parent; - result.target = symbol; - result.mapper = mapper; - if (symbol.valueDeclaration) { - result.valueDeclaration = symbol.valueDeclaration; - } - return result; - } - function instantiateAnonymousType(type, mapper) { - if (mapper.instantiations) { - var cachedType = mapper.instantiations[type.id]; - if (cachedType) { - return cachedType; - } - } - else { - mapper.instantiations = []; - } - var result = createObjectType(65536 | 131072, type.symbol); - result.target = type; - result.mapper = mapper; - mapper.instantiations[type.id] = result; - return result; - } - function instantiateType(type, mapper) { - if (type && mapper !== identityMapper) { - if (type.flags & 512) { - return mapper(type); - } - if (type.flags & 65536) { - return type.symbol && type.symbol.flags & (16 | 8192 | 32 | 2048 | 4096) ? - instantiateAnonymousType(type, mapper) : type; - } - if (type.flags & 4096) { - return createTypeReference(type.target, instantiateList(type.typeArguments, mapper, instantiateType)); - } - if (type.flags & 8192) { - return createTupleType(instantiateList(type.elementTypes, mapper, instantiateType)); - } - if (type.flags & 16384) { - return getUnionType(instantiateList(type.types, mapper, instantiateType), true); - } - if (type.flags & 32768) { - return getIntersectionType(instantiateList(type.types, mapper, instantiateType)); - } - } - return type; - } - function isContextSensitive(node) { - ts.Debug.assert(node.kind !== 143 || ts.isObjectLiteralMethod(node)); - switch (node.kind) { - case 173: - case 174: - return isContextSensitiveFunctionLikeDeclaration(node); - case 165: - return ts.forEach(node.properties, isContextSensitive); - case 164: - return ts.forEach(node.elements, isContextSensitive); - case 182: - return isContextSensitive(node.whenTrue) || - isContextSensitive(node.whenFalse); - case 181: - return node.operatorToken.kind === 52 && - (isContextSensitive(node.left) || isContextSensitive(node.right)); - case 245: - return isContextSensitive(node.initializer); - case 143: - case 142: - return isContextSensitiveFunctionLikeDeclaration(node); - case 172: - return isContextSensitive(node.expression); - } - return false; - } - function isContextSensitiveFunctionLikeDeclaration(node) { - return !node.typeParameters && node.parameters.length && !ts.forEach(node.parameters, function (p) { return p.type; }); - } - function getTypeWithoutSignatures(type) { - if (type.flags & 80896) { - var resolved = resolveStructuredTypeMembers(type); - if (resolved.constructSignatures.length) { - var result = createObjectType(65536, type.symbol); - result.members = resolved.members; - result.properties = resolved.properties; - result.callSignatures = emptyArray; - result.constructSignatures = emptyArray; - type = result; - } - } - return type; - } - function isTypeIdenticalTo(source, target) { - return checkTypeRelatedTo(source, target, identityRelation, undefined); - } - function compareTypes(source, target) { - return checkTypeRelatedTo(source, target, identityRelation, undefined) ? -1 : 0; - } - function isTypeSubtypeOf(source, target) { - return checkTypeSubtypeOf(source, target, undefined); - } - function isTypeAssignableTo(source, target) { - return checkTypeAssignableTo(source, target, undefined); - } - function checkTypeSubtypeOf(source, target, errorNode, headMessage, containingMessageChain) { - return checkTypeRelatedTo(source, target, subtypeRelation, errorNode, headMessage, containingMessageChain); - } - function checkTypeAssignableTo(source, target, errorNode, headMessage, containingMessageChain) { - return checkTypeRelatedTo(source, target, assignableRelation, errorNode, headMessage, containingMessageChain); - } - function isSignatureAssignableTo(source, target) { - var sourceType = getOrCreateTypeFromSignature(source); - var targetType = getOrCreateTypeFromSignature(target); - return checkTypeRelatedTo(sourceType, targetType, assignableRelation, undefined); - } - function checkTypeRelatedTo(source, target, relation, errorNode, headMessage, containingMessageChain) { - var errorInfo; - var sourceStack; - var targetStack; - var maybeStack; - var expandingFlags; - var depth = 0; - var overflow = false; - var elaborateErrors = false; - ts.Debug.assert(relation !== identityRelation || !errorNode, "no error reporting in identity checking"); - var result = isRelatedTo(source, target, errorNode !== undefined, headMessage); - if (overflow) { - error(errorNode, ts.Diagnostics.Excessive_stack_depth_comparing_types_0_and_1, typeToString(source), typeToString(target)); - } - else if (errorInfo) { - if (errorInfo.next === undefined) { - errorInfo = undefined; - elaborateErrors = true; - isRelatedTo(source, target, errorNode !== undefined, headMessage); - } - if (containingMessageChain) { - errorInfo = ts.concatenateDiagnosticMessageChains(containingMessageChain, errorInfo); - } - diagnostics.add(ts.createDiagnosticForNodeFromMessageChain(errorNode, errorInfo)); - } - return result !== 0; - function reportError(message, arg0, arg1, arg2) { - errorInfo = ts.chainDiagnosticMessages(errorInfo, message, arg0, arg1, arg2); - } - function reportRelationError(message, source, target) { - var sourceType = typeToString(source); - var targetType = typeToString(target); - if (sourceType === targetType) { - sourceType = typeToString(source, undefined, 128); - targetType = typeToString(target, undefined, 128); - } - reportError(message || ts.Diagnostics.Type_0_is_not_assignable_to_type_1, sourceType, targetType); - } - function isRelatedTo(source, target, reportErrors, headMessage) { - var result; - if (source === target) - return -1; - if (relation === identityRelation) { - return isIdenticalTo(source, target); - } - if (isTypeAny(target)) - return -1; - if (source === undefinedType) - return -1; - if (source === nullType && target !== undefinedType) - return -1; - if (source.flags & 128 && target === numberType) - return -1; - if (source.flags & 256 && target === stringType) - return -1; - if (relation === assignableRelation) { - if (isTypeAny(source)) - return -1; - if (source === numberType && target.flags & 128) - return -1; - } - if (source.flags & 1048576) { - if (hasExcessProperties(source, target, reportErrors)) { - if (reportErrors) { - reportRelationError(headMessage, source, target); - } - return 0; - } - if (target.flags & 49152) { - source = getRegularTypeOfObjectLiteral(source); - } - } - var saveErrorInfo = errorInfo; - if (source.flags & 16384) { - if (result = eachTypeRelatedToType(source, target, reportErrors)) { - return result; - } - } - else if (target.flags & 32768) { - if (result = typeRelatedToEachType(source, target, reportErrors)) { - return result; - } - } - else { - if (source.flags & 32768) { - if (result = someTypeRelatedToType(source, target, reportErrors && !(target.flags & 16384))) { - return result; - } - } - if (target.flags & 16384) { - if (result = typeRelatedToSomeType(source, target, reportErrors)) { - return result; - } - } - } - if (source.flags & 512) { - var constraint = getConstraintOfTypeParameter(source); - if (!constraint || constraint.flags & 1) { - constraint = emptyObjectType; - } - var reportConstraintErrors = reportErrors && constraint !== emptyObjectType; - if (result = isRelatedTo(constraint, target, reportConstraintErrors)) { - errorInfo = saveErrorInfo; - return result; - } - } - else { - if (source.flags & 4096 && target.flags & 4096 && source.target === target.target) { - if (result = typeArgumentsRelatedTo(source, target, reportErrors)) { - return result; - } - } - var apparentType = getApparentType(source); - if (apparentType.flags & (80896 | 32768) && target.flags & 80896) { - var reportStructuralErrors = reportErrors && errorInfo === saveErrorInfo; - if (result = objectTypeRelatedTo(apparentType, source, target, reportStructuralErrors)) { - errorInfo = saveErrorInfo; - return result; - } - } - } - if (reportErrors) { - reportRelationError(headMessage, source, target); - } - return 0; - } - function isIdenticalTo(source, target) { - var result; - if (source.flags & 80896 && target.flags & 80896) { - if (source.flags & 4096 && target.flags & 4096 && source.target === target.target) { - if (result = typeArgumentsRelatedTo(source, target, false)) { - return result; - } - } - return objectTypeRelatedTo(source, source, target, false); - } - if (source.flags & 512 && target.flags & 512) { - return typeParameterIdenticalTo(source, target); - } - if (source.flags & 16384 && target.flags & 16384 || - source.flags & 32768 && target.flags & 32768) { - if (result = eachTypeRelatedToSomeType(source, target)) { - if (result &= eachTypeRelatedToSomeType(target, source)) { - return result; - } - } - } - return 0; - } - function isKnownProperty(type, name) { - if (type.flags & 80896) { - var resolved = resolveStructuredTypeMembers(type); - if (relation === assignableRelation && (type === globalObjectType || resolved.properties.length === 0) || - resolved.stringIndexType || resolved.numberIndexType || getPropertyOfType(type, name)) { - return true; - } - } - else if (type.flags & 49152) { - for (var _i = 0, _a = type.types; _i < _a.length; _i++) { - var t = _a[_i]; - if (isKnownProperty(t, name)) { - return true; - } - } - } - return false; - } - function hasExcessProperties(source, target, reportErrors) { - if (someConstituentTypeHasKind(target, 80896)) { - for (var _i = 0, _a = getPropertiesOfObjectType(source); _i < _a.length; _i++) { - var prop = _a[_i]; - if (!isKnownProperty(target, prop.name)) { - if (reportErrors) { - errorNode = prop.valueDeclaration; - reportError(ts.Diagnostics.Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1, symbolToString(prop), typeToString(target)); - } - return true; - } - } - } - return false; - } - function eachTypeRelatedToSomeType(source, target) { - var result = -1; - var sourceTypes = source.types; - for (var _i = 0; _i < sourceTypes.length; _i++) { - var sourceType = sourceTypes[_i]; - var related = typeRelatedToSomeType(sourceType, target, false); - if (!related) { - return 0; - } - result &= related; - } - return result; - } - function typeRelatedToSomeType(source, target, reportErrors) { - var targetTypes = target.types; - for (var i = 0, len = targetTypes.length; i < len; i++) { - var related = isRelatedTo(source, targetTypes[i], reportErrors && i === len - 1); - if (related) { - return related; - } - } - return 0; - } - function typeRelatedToEachType(source, target, reportErrors) { - var result = -1; - var targetTypes = target.types; - for (var _i = 0; _i < targetTypes.length; _i++) { - var targetType = targetTypes[_i]; - var related = isRelatedTo(source, targetType, reportErrors); - if (!related) { - return 0; - } - result &= related; - } - return result; - } - function someTypeRelatedToType(source, target, reportErrors) { - var sourceTypes = source.types; - for (var i = 0, len = sourceTypes.length; i < len; i++) { - var related = isRelatedTo(sourceTypes[i], target, reportErrors && i === len - 1); - if (related) { - return related; - } - } - return 0; - } - function eachTypeRelatedToType(source, target, reportErrors) { - var result = -1; - var sourceTypes = source.types; - for (var _i = 0; _i < sourceTypes.length; _i++) { - var sourceType = sourceTypes[_i]; - var related = isRelatedTo(sourceType, target, reportErrors); - if (!related) { - return 0; - } - result &= related; - } - return result; - } - function typeArgumentsRelatedTo(source, target, reportErrors) { - var sources = source.typeArguments || emptyArray; - var targets = target.typeArguments || emptyArray; - if (sources.length !== targets.length && relation === identityRelation) { - return 0; - } - var result = -1; - for (var i = 0; i < targets.length; i++) { - var related = isRelatedTo(sources[i], targets[i], reportErrors); - if (!related) { - return 0; - } - result &= related; - } - return result; - } - function typeParameterIdenticalTo(source, target) { - if (source.symbol.name !== target.symbol.name) { - return 0; - } - if (source.constraint === target.constraint) { - return -1; - } - if (source.constraint === noConstraintType || target.constraint === noConstraintType) { - return 0; - } - return isIdenticalTo(source.constraint, target.constraint); - } - function objectTypeRelatedTo(apparentSource, originalSource, target, reportErrors) { - if (overflow) { - return 0; - } - var id = relation !== identityRelation || apparentSource.id < target.id ? apparentSource.id + "," + target.id : target.id + "," + apparentSource.id; - var related = relation[id]; - if (related !== undefined) { - if (!elaborateErrors || (related === 3)) { - return related === 1 ? -1 : 0; - } - } - if (depth > 0) { - for (var i = 0; i < depth; i++) { - if (maybeStack[i][id]) { - return 1; - } - } - if (depth === 100) { - overflow = true; - return 0; - } - } - else { - sourceStack = []; - targetStack = []; - maybeStack = []; - expandingFlags = 0; - } - sourceStack[depth] = apparentSource; - targetStack[depth] = target; - maybeStack[depth] = {}; - maybeStack[depth][id] = 1; - depth++; - var saveExpandingFlags = expandingFlags; - if (!(expandingFlags & 1) && isDeeplyNestedGeneric(apparentSource, sourceStack, depth)) - expandingFlags |= 1; - if (!(expandingFlags & 2) && isDeeplyNestedGeneric(target, targetStack, depth)) - expandingFlags |= 2; - var result; - if (expandingFlags === 3) { - result = 1; - } - else { - result = propertiesRelatedTo(apparentSource, target, reportErrors); - if (result) { - result &= signaturesRelatedTo(apparentSource, target, 0, reportErrors); - if (result) { - result &= signaturesRelatedTo(apparentSource, target, 1, reportErrors); - if (result) { - result &= stringIndexTypesRelatedTo(apparentSource, originalSource, target, reportErrors); - if (result) { - result &= numberIndexTypesRelatedTo(apparentSource, originalSource, target, reportErrors); - } - } - } - } - } - expandingFlags = saveExpandingFlags; - depth--; - if (result) { - var maybeCache = maybeStack[depth]; - var destinationCache = (result === -1 || depth === 0) ? relation : maybeStack[depth - 1]; - ts.copyMap(maybeCache, destinationCache); - } - else { - relation[id] = reportErrors ? 3 : 2; - } - return result; - } - function propertiesRelatedTo(source, target, reportErrors) { - if (relation === identityRelation) { - return propertiesIdenticalTo(source, target); - } - var result = -1; - var properties = getPropertiesOfObjectType(target); - var requireOptionalProperties = relation === subtypeRelation && !(source.flags & 524288); - for (var _i = 0; _i < properties.length; _i++) { - var targetProp = properties[_i]; - var sourceProp = getPropertyOfType(source, targetProp.name); - if (sourceProp !== targetProp) { - if (!sourceProp) { - if (!(targetProp.flags & 536870912) || requireOptionalProperties) { - if (reportErrors) { - reportError(ts.Diagnostics.Property_0_is_missing_in_type_1, symbolToString(targetProp), typeToString(source)); - } - return 0; - } - } - else if (!(targetProp.flags & 134217728)) { - var sourcePropFlags = getDeclarationFlagsFromSymbol(sourceProp); - var targetPropFlags = getDeclarationFlagsFromSymbol(targetProp); - if (sourcePropFlags & 32 || targetPropFlags & 32) { - if (sourceProp.valueDeclaration !== targetProp.valueDeclaration) { - if (reportErrors) { - if (sourcePropFlags & 32 && targetPropFlags & 32) { - reportError(ts.Diagnostics.Types_have_separate_declarations_of_a_private_property_0, symbolToString(targetProp)); - } - else { - reportError(ts.Diagnostics.Property_0_is_private_in_type_1_but_not_in_type_2, symbolToString(targetProp), typeToString(sourcePropFlags & 32 ? source : target), typeToString(sourcePropFlags & 32 ? target : source)); - } - } - return 0; - } - } - else if (targetPropFlags & 64) { - var sourceDeclaredInClass = sourceProp.parent && sourceProp.parent.flags & 32; - var sourceClass = sourceDeclaredInClass ? getDeclaredTypeOfSymbol(sourceProp.parent) : undefined; - var targetClass = getDeclaredTypeOfSymbol(targetProp.parent); - if (!sourceClass || !hasBaseType(sourceClass, targetClass)) { - if (reportErrors) { - reportError(ts.Diagnostics.Property_0_is_protected_but_type_1_is_not_a_class_derived_from_2, symbolToString(targetProp), typeToString(sourceClass || source), typeToString(targetClass)); - } - return 0; - } - } - else if (sourcePropFlags & 64) { - if (reportErrors) { - reportError(ts.Diagnostics.Property_0_is_protected_in_type_1_but_public_in_type_2, symbolToString(targetProp), typeToString(source), typeToString(target)); - } - return 0; - } - var related = isRelatedTo(getTypeOfSymbol(sourceProp), getTypeOfSymbol(targetProp), reportErrors); - if (!related) { - if (reportErrors) { - reportError(ts.Diagnostics.Types_of_property_0_are_incompatible, symbolToString(targetProp)); - } - return 0; - } - result &= related; - if (sourceProp.flags & 536870912 && !(targetProp.flags & 536870912)) { - if (reportErrors) { - reportError(ts.Diagnostics.Property_0_is_optional_in_type_1_but_required_in_type_2, symbolToString(targetProp), typeToString(source), typeToString(target)); - } - return 0; - } - } - } - } - return result; - } - function propertiesIdenticalTo(source, target) { - if (!(source.flags & 80896 && target.flags & 80896)) { - return 0; - } - var sourceProperties = getPropertiesOfObjectType(source); - var targetProperties = getPropertiesOfObjectType(target); - if (sourceProperties.length !== targetProperties.length) { - return 0; - } - var result = -1; - for (var _i = 0; _i < sourceProperties.length; _i++) { - var sourceProp = sourceProperties[_i]; - var targetProp = getPropertyOfObjectType(target, sourceProp.name); - if (!targetProp) { - return 0; - } - var related = compareProperties(sourceProp, targetProp, isRelatedTo); - if (!related) { - return 0; - } - result &= related; - } - return result; - } - function signaturesRelatedTo(source, target, kind, reportErrors) { - if (relation === identityRelation) { - return signaturesIdenticalTo(source, target, kind); - } - if (target === anyFunctionType || source === anyFunctionType) { - return -1; - } - var sourceSignatures = getSignaturesOfType(source, kind); - var targetSignatures = getSignaturesOfType(target, kind); - var result = -1; - var saveErrorInfo = errorInfo; - if (kind === 1) { - var sourceSig = sourceSignatures[0]; - var targetSig = targetSignatures[0]; - result &= abstractSignatureRelatedTo(source, sourceSig, target, targetSig); - if (result !== -1) { - return result; - } - } - outer: for (var _i = 0; _i < targetSignatures.length; _i++) { - var t = targetSignatures[_i]; - if (!t.hasStringLiterals || target.flags & 262144) { - var localErrors = reportErrors; - var checkedAbstractAssignability = false; - for (var _a = 0; _a < sourceSignatures.length; _a++) { - var s = sourceSignatures[_a]; - if (!s.hasStringLiterals || source.flags & 262144) { - var related = signatureRelatedTo(s, t, localErrors); - if (related) { - result &= related; - errorInfo = saveErrorInfo; - continue outer; - } - localErrors = false; - } - } - return 0; - } - } - return result; - function abstractSignatureRelatedTo(source, sourceSig, target, targetSig) { - if (sourceSig && targetSig) { - var sourceDecl = source.symbol && getClassLikeDeclarationOfSymbol(source.symbol); - var targetDecl = target.symbol && getClassLikeDeclarationOfSymbol(target.symbol); - if (!sourceDecl) { - return -1; - } - var sourceErasedSignature = getErasedSignature(sourceSig); - var targetErasedSignature = getErasedSignature(targetSig); - var sourceReturnType = sourceErasedSignature && getReturnTypeOfSignature(sourceErasedSignature); - var targetReturnType = targetErasedSignature && getReturnTypeOfSignature(targetErasedSignature); - var sourceReturnDecl = sourceReturnType && sourceReturnType.symbol && getClassLikeDeclarationOfSymbol(sourceReturnType.symbol); - var targetReturnDecl = targetReturnType && targetReturnType.symbol && getClassLikeDeclarationOfSymbol(targetReturnType.symbol); - var sourceIsAbstract = sourceReturnDecl && sourceReturnDecl.flags & 256; - var targetIsAbstract = targetReturnDecl && targetReturnDecl.flags & 256; - if (sourceIsAbstract && !(targetIsAbstract && targetDecl)) { - if (reportErrors) { - reportError(ts.Diagnostics.Cannot_assign_an_abstract_constructor_type_to_a_non_abstract_constructor_type); - } - return 0; - } - } - return -1; - } - } - function signatureRelatedTo(source, target, reportErrors) { - if (source === target) { - return -1; - } - if (!target.hasRestParameter && source.minArgumentCount > target.parameters.length) { - return 0; - } - var sourceMax = source.parameters.length; - var targetMax = target.parameters.length; - var checkCount; - if (source.hasRestParameter && target.hasRestParameter) { - checkCount = sourceMax > targetMax ? sourceMax : targetMax; - sourceMax--; - targetMax--; - } - else if (source.hasRestParameter) { - sourceMax--; - checkCount = targetMax; - } - else if (target.hasRestParameter) { - targetMax--; - checkCount = sourceMax; - } - else { - checkCount = sourceMax < targetMax ? sourceMax : targetMax; - } - source = getErasedSignature(source); - target = getErasedSignature(target); - var result = -1; - for (var i = 0; i < checkCount; i++) { - var s = i < sourceMax ? getTypeOfSymbol(source.parameters[i]) : getRestTypeOfSignature(source); - var t = i < targetMax ? getTypeOfSymbol(target.parameters[i]) : getRestTypeOfSignature(target); - var saveErrorInfo = errorInfo; - var related = isRelatedTo(s, t, reportErrors); - if (!related) { - related = isRelatedTo(t, s, false); - if (!related) { - if (reportErrors) { - reportError(ts.Diagnostics.Types_of_parameters_0_and_1_are_incompatible, source.parameters[i < sourceMax ? i : sourceMax].name, target.parameters[i < targetMax ? i : targetMax].name); - } - return 0; - } - errorInfo = saveErrorInfo; - } - result &= related; - } - if (source.typePredicate && target.typePredicate) { - var hasDifferentParameterIndex = source.typePredicate.parameterIndex !== target.typePredicate.parameterIndex; - var hasDifferentTypes; - if (hasDifferentParameterIndex || - (hasDifferentTypes = !isTypeIdenticalTo(source.typePredicate.type, target.typePredicate.type))) { - if (reportErrors) { - var sourceParamText = source.typePredicate.parameterName; - var targetParamText = target.typePredicate.parameterName; - var sourceTypeText = typeToString(source.typePredicate.type); - var targetTypeText = typeToString(target.typePredicate.type); - if (hasDifferentParameterIndex) { - reportError(ts.Diagnostics.Parameter_0_is_not_in_the_same_position_as_parameter_1, sourceParamText, targetParamText); - } - else if (hasDifferentTypes) { - reportError(ts.Diagnostics.Type_0_is_not_assignable_to_type_1, sourceTypeText, targetTypeText); - } - reportError(ts.Diagnostics.Type_predicate_0_is_not_assignable_to_1, sourceParamText + " is " + sourceTypeText, targetParamText + " is " + targetTypeText); - } - return 0; - } - } - else if (!source.typePredicate && target.typePredicate) { - if (reportErrors) { - reportError(ts.Diagnostics.Signature_0_must_have_a_type_predicate, signatureToString(source)); - } - return 0; - } - var targetReturnType = getReturnTypeOfSignature(target); - if (targetReturnType === voidType) - return result; - var sourceReturnType = getReturnTypeOfSignature(source); - return result & isRelatedTo(sourceReturnType, targetReturnType, reportErrors); - } - function signaturesIdenticalTo(source, target, kind) { - var sourceSignatures = getSignaturesOfType(source, kind); - var targetSignatures = getSignaturesOfType(target, kind); - if (sourceSignatures.length !== targetSignatures.length) { - return 0; - } - var result = -1; - for (var i = 0, len = sourceSignatures.length; i < len; ++i) { - var related = compareSignatures(sourceSignatures[i], targetSignatures[i], false, false, isRelatedTo); - if (!related) { - return 0; - } - result &= related; - } - return result; - } - function stringIndexTypesRelatedTo(source, originalSource, target, reportErrors) { - if (relation === identityRelation) { - return indexTypesIdenticalTo(0, source, target); - } - var targetType = getIndexTypeOfType(target, 0); - if (targetType) { - if ((targetType.flags & 1) && !(originalSource.flags & 16777726)) { - return -1; - } - var sourceType = getIndexTypeOfType(source, 0); - if (!sourceType) { - if (reportErrors) { - reportError(ts.Diagnostics.Index_signature_is_missing_in_type_0, typeToString(source)); - } - return 0; - } - var related = isRelatedTo(sourceType, targetType, reportErrors); - if (!related) { - if (reportErrors) { - reportError(ts.Diagnostics.Index_signatures_are_incompatible); - } - return 0; - } - return related; - } - return -1; - } - function numberIndexTypesRelatedTo(source, originalSource, target, reportErrors) { - if (relation === identityRelation) { - return indexTypesIdenticalTo(1, source, target); - } - var targetType = getIndexTypeOfType(target, 1); - if (targetType) { - if ((targetType.flags & 1) && !(originalSource.flags & 16777726)) { - return -1; - } - var sourceStringType = getIndexTypeOfType(source, 0); - var sourceNumberType = getIndexTypeOfType(source, 1); - if (!(sourceStringType || sourceNumberType)) { - if (reportErrors) { - reportError(ts.Diagnostics.Index_signature_is_missing_in_type_0, typeToString(source)); - } - return 0; - } - var related; - if (sourceStringType && sourceNumberType) { - related = isRelatedTo(sourceStringType, targetType, false) || isRelatedTo(sourceNumberType, targetType, reportErrors); - } - else { - related = isRelatedTo(sourceStringType || sourceNumberType, targetType, reportErrors); - } - if (!related) { - if (reportErrors) { - reportError(ts.Diagnostics.Index_signatures_are_incompatible); - } - return 0; - } - return related; - } - return -1; - } - function indexTypesIdenticalTo(indexKind, source, target) { - var targetType = getIndexTypeOfType(target, indexKind); - var sourceType = getIndexTypeOfType(source, indexKind); - if (!sourceType && !targetType) { - return -1; - } - if (sourceType && targetType) { - return isRelatedTo(sourceType, targetType); - } - return 0; - } - } - function isDeeplyNestedGeneric(type, stack, depth) { - if (type.flags & (4096 | 131072) && depth >= 5) { - var symbol = type.symbol; - var count = 0; - for (var i = 0; i < depth; i++) { - var t = stack[i]; - if (t.flags & (4096 | 131072) && t.symbol === symbol) { - count++; - if (count >= 5) - return true; - } - } - } - return false; - } - function isPropertyIdenticalTo(sourceProp, targetProp) { - return compareProperties(sourceProp, targetProp, compareTypes) !== 0; - } - function compareProperties(sourceProp, targetProp, compareTypes) { - if (sourceProp === targetProp) { - return -1; - } - var sourcePropAccessibility = getDeclarationFlagsFromSymbol(sourceProp) & (32 | 64); - var targetPropAccessibility = getDeclarationFlagsFromSymbol(targetProp) & (32 | 64); - if (sourcePropAccessibility !== targetPropAccessibility) { - return 0; - } - if (sourcePropAccessibility) { - if (getTargetSymbol(sourceProp) !== getTargetSymbol(targetProp)) { - return 0; - } - } - else { - if ((sourceProp.flags & 536870912) !== (targetProp.flags & 536870912)) { - return 0; - } - } - return compareTypes(getTypeOfSymbol(sourceProp), getTypeOfSymbol(targetProp)); - } - function compareSignatures(source, target, partialMatch, ignoreReturnTypes, compareTypes) { - if (source === target) { - return -1; - } - if (source.parameters.length !== target.parameters.length || - source.minArgumentCount !== target.minArgumentCount || - source.hasRestParameter !== target.hasRestParameter) { - if (!partialMatch || - source.parameters.length < target.parameters.length && !source.hasRestParameter || - source.minArgumentCount > target.minArgumentCount) { - return 0; - } - } - var result = -1; - if (source.typeParameters && target.typeParameters) { - if (source.typeParameters.length !== target.typeParameters.length) { - return 0; - } - for (var i = 0, len = source.typeParameters.length; i < len; ++i) { - var related = compareTypes(source.typeParameters[i], target.typeParameters[i]); - if (!related) { - return 0; - } - result &= related; - } - } - else if (source.typeParameters || target.typeParameters) { - return 0; - } - source = getErasedSignature(source); - target = getErasedSignature(target); - var targetLen = target.parameters.length; - for (var i = 0; i < targetLen; i++) { - var s = isRestParameterIndex(source, i) ? getRestTypeOfSignature(source) : getTypeOfSymbol(source.parameters[i]); - var t = isRestParameterIndex(target, i) ? getRestTypeOfSignature(target) : getTypeOfSymbol(target.parameters[i]); - var related = compareTypes(s, t); - if (!related) { - return 0; - } - result &= related; - } - if (!ignoreReturnTypes) { - result &= compareTypes(getReturnTypeOfSignature(source), getReturnTypeOfSignature(target)); - } - return result; - } - function isRestParameterIndex(signature, parameterIndex) { - return signature.hasRestParameter && parameterIndex >= signature.parameters.length - 1; - } - function isSupertypeOfEach(candidate, types) { - for (var _i = 0; _i < types.length; _i++) { - var type = types[_i]; - if (candidate !== type && !isTypeSubtypeOf(type, candidate)) - return false; - } - return true; - } - function getCommonSupertype(types) { - return ts.forEach(types, function (t) { return isSupertypeOfEach(t, types) ? t : undefined; }); - } - function reportNoCommonSupertypeError(types, errorLocation, errorMessageChainHead) { - var bestSupertype; - var bestSupertypeDownfallType; - var bestSupertypeScore = 0; - for (var i = 0; i < types.length; i++) { - var score = 0; - var downfallType = undefined; - for (var j = 0; j < types.length; j++) { - if (isTypeSubtypeOf(types[j], types[i])) { - score++; - } - else if (!downfallType) { - downfallType = types[j]; - } - } - ts.Debug.assert(!!downfallType, "If there is no common supertype, each type should have a downfallType"); - if (score > bestSupertypeScore) { - bestSupertype = types[i]; - bestSupertypeDownfallType = downfallType; - bestSupertypeScore = score; - } - if (bestSupertypeScore === types.length - 1) { - break; - } - } - checkTypeSubtypeOf(bestSupertypeDownfallType, bestSupertype, errorLocation, ts.Diagnostics.Type_argument_candidate_1_is_not_a_valid_type_argument_because_it_is_not_a_supertype_of_candidate_0, errorMessageChainHead); - } - function isArrayType(type) { - return type.flags & 4096 && type.target === globalArrayType; - } - function isArrayLikeType(type) { - return !(type.flags & (32 | 64)) && isTypeAssignableTo(type, anyArrayType); - } - function isTupleLikeType(type) { - return !!getPropertyOfType(type, "0"); - } - function isTupleType(type) { - return !!(type.flags & 8192); - } - function getRegularTypeOfObjectLiteral(type) { - if (type.flags & 1048576) { - var regularType = type.regularType; - if (!regularType) { - regularType = createType(type.flags & ~1048576); - regularType.symbol = type.symbol; - regularType.members = type.members; - regularType.properties = type.properties; - regularType.callSignatures = type.callSignatures; - regularType.constructSignatures = type.constructSignatures; - regularType.stringIndexType = type.stringIndexType; - regularType.numberIndexType = type.numberIndexType; - type.regularType = regularType; - } - return regularType; - } - return type; - } - function getWidenedTypeOfObjectLiteral(type) { - var properties = getPropertiesOfObjectType(type); - var members = {}; - ts.forEach(properties, function (p) { - var propType = getTypeOfSymbol(p); - var widenedType = getWidenedType(propType); - if (propType !== widenedType) { - var symbol = createSymbol(p.flags | 67108864, p.name); - symbol.declarations = p.declarations; - symbol.parent = p.parent; - symbol.type = widenedType; - symbol.target = p; - if (p.valueDeclaration) - symbol.valueDeclaration = p.valueDeclaration; - p = symbol; - } - members[p.name] = p; - }); - var stringIndexType = getIndexTypeOfType(type, 0); - var numberIndexType = getIndexTypeOfType(type, 1); - if (stringIndexType) - stringIndexType = getWidenedType(stringIndexType); - if (numberIndexType) - numberIndexType = getWidenedType(numberIndexType); - return createAnonymousType(type.symbol, members, emptyArray, emptyArray, stringIndexType, numberIndexType); - } - function getWidenedType(type) { - if (type.flags & 6291456) { - if (type.flags & (32 | 64)) { - return anyType; - } - if (type.flags & 524288) { - return getWidenedTypeOfObjectLiteral(type); - } - if (type.flags & 16384) { - return getUnionType(ts.map(type.types, getWidenedType), true); - } - if (isArrayType(type)) { - return createArrayType(getWidenedType(type.typeArguments[0])); - } - if (isTupleType(type)) { - return createTupleType(ts.map(type.elementTypes, getWidenedType)); - } - } - return type; - } - function reportWideningErrorsInType(type) { - var errorReported = false; - if (type.flags & 16384) { - for (var _i = 0, _a = type.types; _i < _a.length; _i++) { - var t = _a[_i]; - if (reportWideningErrorsInType(t)) { - errorReported = true; - } - } - } - if (isArrayType(type)) { - return reportWideningErrorsInType(type.typeArguments[0]); - } - if (isTupleType(type)) { - for (var _b = 0, _c = type.elementTypes; _b < _c.length; _b++) { - var t = _c[_b]; - if (reportWideningErrorsInType(t)) { - errorReported = true; - } - } - } - if (type.flags & 524288) { - for (var _d = 0, _e = getPropertiesOfObjectType(type); _d < _e.length; _d++) { - var p = _e[_d]; - var t = getTypeOfSymbol(p); - if (t.flags & 2097152) { - if (!reportWideningErrorsInType(t)) { - error(p.valueDeclaration, ts.Diagnostics.Object_literal_s_property_0_implicitly_has_an_1_type, p.name, typeToString(getWidenedType(t))); - } - errorReported = true; - } - } - } - return errorReported; - } - function reportImplicitAnyError(declaration, type) { - var typeAsString = typeToString(getWidenedType(type)); - var diagnostic; - switch (declaration.kind) { - case 141: - case 140: - diagnostic = ts.Diagnostics.Member_0_implicitly_has_an_1_type; - break; - case 138: - diagnostic = declaration.dotDotDotToken ? - ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type : - ts.Diagnostics.Parameter_0_implicitly_has_an_1_type; - break; - case 213: - case 143: - case 142: - case 145: - case 146: - case 173: - case 174: - if (!declaration.name) { - error(declaration, ts.Diagnostics.Function_expression_which_lacks_return_type_annotation_implicitly_has_an_0_return_type, typeAsString); - return; - } - diagnostic = ts.Diagnostics._0_which_lacks_return_type_annotation_implicitly_has_an_1_return_type; - break; - default: - diagnostic = ts.Diagnostics.Variable_0_implicitly_has_an_1_type; - } - error(declaration, diagnostic, ts.declarationNameToString(declaration.name), typeAsString); - } - function reportErrorsFromWidening(declaration, type) { - if (produceDiagnostics && compilerOptions.noImplicitAny && type.flags & 2097152) { - if (!reportWideningErrorsInType(type)) { - reportImplicitAnyError(declaration, type); - } - } - } - function forEachMatchingParameterType(source, target, callback) { - var sourceMax = source.parameters.length; - var targetMax = target.parameters.length; - var count; - if (source.hasRestParameter && target.hasRestParameter) { - count = sourceMax > targetMax ? sourceMax : targetMax; - sourceMax--; - targetMax--; - } - else if (source.hasRestParameter) { - sourceMax--; - count = targetMax; - } - else if (target.hasRestParameter) { - targetMax--; - count = sourceMax; - } - else { - count = sourceMax < targetMax ? sourceMax : targetMax; - } - for (var i = 0; i < count; i++) { - var s = i < sourceMax ? getTypeOfSymbol(source.parameters[i]) : getRestTypeOfSignature(source); - var t = i < targetMax ? getTypeOfSymbol(target.parameters[i]) : getRestTypeOfSignature(target); - callback(s, t); - } - } - function createInferenceContext(typeParameters, inferUnionTypes) { - var inferences = []; - for (var _i = 0; _i < typeParameters.length; _i++) { - var unused = typeParameters[_i]; - inferences.push({ - primary: undefined, secondary: undefined, isFixed: false - }); - } - return { - typeParameters: typeParameters, - inferUnionTypes: inferUnionTypes, - inferences: inferences, - inferredTypes: new Array(typeParameters.length) - }; - } - function inferTypes(context, source, target) { - var sourceStack; - var targetStack; - var depth = 0; - var inferiority = 0; - inferFromTypes(source, target); - function isInProcess(source, target) { - for (var i = 0; i < depth; i++) { - if (source === sourceStack[i] && target === targetStack[i]) { - return true; - } - } - return false; - } - function inferFromTypes(source, target) { - if (target.flags & 512) { - if (source.flags & 8388608) { - return; - } - var typeParameters = context.typeParameters; - for (var i = 0; i < typeParameters.length; i++) { - if (target === typeParameters[i]) { - var inferences = context.inferences[i]; - if (!inferences.isFixed) { - var candidates = inferiority ? - inferences.secondary || (inferences.secondary = []) : - inferences.primary || (inferences.primary = []); - if (!ts.contains(candidates, source)) { - candidates.push(source); - } - } - return; - } - } - } - else if (source.flags & 4096 && target.flags & 4096 && source.target === target.target) { - var sourceTypes = source.typeArguments || emptyArray; - var targetTypes = target.typeArguments || emptyArray; - var count = sourceTypes.length < targetTypes.length ? sourceTypes.length : targetTypes.length; - for (var i = 0; i < count; i++) { - inferFromTypes(sourceTypes[i], targetTypes[i]); - } - } - else if (source.flags & 8192 && target.flags & 8192 && source.elementTypes.length === target.elementTypes.length) { - var sourceTypes = source.elementTypes; - var targetTypes = target.elementTypes; - for (var i = 0; i < sourceTypes.length; i++) { - inferFromTypes(sourceTypes[i], targetTypes[i]); - } - } - else if (target.flags & 49152) { - var targetTypes = target.types; - var typeParameterCount = 0; - var typeParameter; - for (var _i = 0; _i < targetTypes.length; _i++) { - var t = targetTypes[_i]; - if (t.flags & 512 && ts.contains(context.typeParameters, t)) { - typeParameter = t; - typeParameterCount++; - } - else { - inferFromTypes(source, t); - } - } - if (target.flags & 16384 && typeParameterCount === 1) { - inferiority++; - inferFromTypes(source, typeParameter); - inferiority--; - } - } - else if (source.flags & 49152) { - var sourceTypes = source.types; - for (var _a = 0; _a < sourceTypes.length; _a++) { - var sourceType = sourceTypes[_a]; - inferFromTypes(sourceType, target); - } - } - else { - source = getApparentType(source); - if (source.flags & 80896 && (target.flags & (4096 | 8192) || - (target.flags & 65536) && target.symbol && target.symbol.flags & (8192 | 2048 | 32))) { - if (isInProcess(source, target)) { - return; - } - if (isDeeplyNestedGeneric(source, sourceStack, depth) && isDeeplyNestedGeneric(target, targetStack, depth)) { - return; - } - if (depth === 0) { - sourceStack = []; - targetStack = []; - } - sourceStack[depth] = source; - targetStack[depth] = target; - depth++; - inferFromProperties(source, target); - inferFromSignatures(source, target, 0); - inferFromSignatures(source, target, 1); - inferFromIndexTypes(source, target, 0, 0); - inferFromIndexTypes(source, target, 1, 1); - inferFromIndexTypes(source, target, 0, 1); - depth--; - } - } - } - function inferFromProperties(source, target) { - var properties = getPropertiesOfObjectType(target); - for (var _i = 0; _i < properties.length; _i++) { - var targetProp = properties[_i]; - var sourceProp = getPropertyOfObjectType(source, targetProp.name); - if (sourceProp) { - inferFromTypes(getTypeOfSymbol(sourceProp), getTypeOfSymbol(targetProp)); - } - } - } - function inferFromSignatures(source, target, kind) { - var sourceSignatures = getSignaturesOfType(source, kind); - var targetSignatures = getSignaturesOfType(target, kind); - var sourceLen = sourceSignatures.length; - var targetLen = targetSignatures.length; - var len = sourceLen < targetLen ? sourceLen : targetLen; - for (var i = 0; i < len; i++) { - inferFromSignature(getErasedSignature(sourceSignatures[sourceLen - len + i]), getErasedSignature(targetSignatures[targetLen - len + i])); - } - } - function inferFromSignature(source, target) { - forEachMatchingParameterType(source, target, inferFromTypes); - if (source.typePredicate && target.typePredicate) { - if (target.typePredicate.parameterIndex === source.typePredicate.parameterIndex) { - inferFromTypes(source.typePredicate.type, target.typePredicate.type); - } - } - else { - inferFromTypes(getReturnTypeOfSignature(source), getReturnTypeOfSignature(target)); - } - } - function inferFromIndexTypes(source, target, sourceKind, targetKind) { - var targetIndexType = getIndexTypeOfType(target, targetKind); - if (targetIndexType) { - var sourceIndexType = getIndexTypeOfType(source, sourceKind); - if (sourceIndexType) { - inferFromTypes(sourceIndexType, targetIndexType); - } - } - } - } - function getInferenceCandidates(context, index) { - var inferences = context.inferences[index]; - return inferences.primary || inferences.secondary || emptyArray; - } - function getInferredType(context, index) { - var inferredType = context.inferredTypes[index]; - var inferenceSucceeded; - if (!inferredType) { - var inferences = getInferenceCandidates(context, index); - if (inferences.length) { - var unionOrSuperType = context.inferUnionTypes ? getUnionType(inferences) : getCommonSupertype(inferences); - inferredType = unionOrSuperType ? getWidenedType(unionOrSuperType) : unknownType; - inferenceSucceeded = !!unionOrSuperType; - } - else { - inferredType = emptyObjectType; - inferenceSucceeded = true; - } - if (inferenceSucceeded) { - var constraint = getConstraintOfTypeParameter(context.typeParameters[index]); - inferredType = constraint && !isTypeAssignableTo(inferredType, constraint) ? constraint : inferredType; - } - else if (context.failedTypeParameterIndex === undefined || context.failedTypeParameterIndex > index) { - context.failedTypeParameterIndex = index; - } - context.inferredTypes[index] = inferredType; - } - return inferredType; - } - function getInferredTypes(context) { - for (var i = 0; i < context.inferredTypes.length; i++) { - getInferredType(context, i); - } - return context.inferredTypes; - } - function hasAncestor(node, kind) { - return ts.getAncestor(node, kind) !== undefined; - } - function getResolvedSymbol(node) { - var links = getNodeLinks(node); - if (!links.resolvedSymbol) { - links.resolvedSymbol = (!ts.nodeIsMissing(node) && resolveName(node, node.text, 107455 | 1048576, ts.Diagnostics.Cannot_find_name_0, node)) || unknownSymbol; - } - return links.resolvedSymbol; - } - function isInTypeQuery(node) { - while (node) { - switch (node.kind) { - case 154: - return true; - case 69: - case 135: - node = node.parent; - continue; - default: - return false; - } - } - ts.Debug.fail("should not get here"); - } - function removeTypesFromUnionType(type, typeKind, isOfTypeKind, allowEmptyUnionResult) { - if (type.flags & 16384) { - var types = type.types; - if (ts.forEach(types, function (t) { return !!(t.flags & typeKind) === isOfTypeKind; })) { - var narrowedType = getUnionType(ts.filter(types, function (t) { return !(t.flags & typeKind) === isOfTypeKind; })); - if (allowEmptyUnionResult || narrowedType !== emptyObjectType) { - return narrowedType; - } - } - } - else if (allowEmptyUnionResult && !!(type.flags & typeKind) === isOfTypeKind) { - return getUnionType(emptyArray); - } - return type; - } - function hasInitializer(node) { - return !!(node.initializer || ts.isBindingPattern(node.parent) && hasInitializer(node.parent.parent)); - } - function isVariableAssignedWithin(symbol, node) { - var links = getNodeLinks(node); - if (links.assignmentChecks) { - var cachedResult = links.assignmentChecks[symbol.id]; - if (cachedResult !== undefined) { - return cachedResult; - } - } - else { - links.assignmentChecks = {}; - } - return links.assignmentChecks[symbol.id] = isAssignedIn(node); - function isAssignedInBinaryExpression(node) { - if (node.operatorToken.kind >= 56 && node.operatorToken.kind <= 68) { - var n = node.left; - while (n.kind === 172) { - n = n.expression; - } - if (n.kind === 69 && getResolvedSymbol(n) === symbol) { - return true; - } - } - return ts.forEachChild(node, isAssignedIn); - } - function isAssignedInVariableDeclaration(node) { - if (!ts.isBindingPattern(node.name) && getSymbolOfNode(node) === symbol && hasInitializer(node)) { - return true; - } - return ts.forEachChild(node, isAssignedIn); - } - function isAssignedIn(node) { - switch (node.kind) { - case 181: - return isAssignedInBinaryExpression(node); - case 211: - case 163: - return isAssignedInVariableDeclaration(node); - case 161: - case 162: - case 164: - case 165: - case 166: - case 167: - case 168: - case 169: - case 171: - case 189: - case 172: - case 179: - case 175: - case 178: - case 176: - case 177: - case 180: - case 184: - case 182: - case 185: - case 192: - case 193: - case 195: - case 196: - case 197: - case 198: - case 199: - case 200: - case 201: - case 204: - case 205: - case 206: - case 241: - case 242: - case 207: - case 208: - case 209: - case 244: - case 233: - case 234: - case 238: - case 239: - case 235: - case 240: - return ts.forEachChild(node, isAssignedIn); - } - return false; - } - } - function getNarrowedTypeOfSymbol(symbol, node) { - var type = getTypeOfSymbol(symbol); - if (node && symbol.flags & 3) { - if (isTypeAny(type) || type.flags & (80896 | 16384 | 512)) { - loop: while (node.parent) { - var child = node; - node = node.parent; - var narrowedType = type; - switch (node.kind) { - case 196: - if (child !== node.expression) { - narrowedType = narrowType(type, node.expression, child === node.thenStatement); - } - break; - case 182: - if (child !== node.condition) { - narrowedType = narrowType(type, node.condition, child === node.whenTrue); - } - break; - case 181: - if (child === node.right) { - if (node.operatorToken.kind === 51) { - narrowedType = narrowType(type, node.left, true); - } - else if (node.operatorToken.kind === 52) { - narrowedType = narrowType(type, node.left, false); - } - } - break; - case 248: - case 218: - case 213: - case 143: - case 142: - case 145: - case 146: - case 144: - break loop; - } - if (narrowedType !== type) { - if (isVariableAssignedWithin(symbol, node)) { - break; - } - type = narrowedType; - } - } - } - } - return type; - function narrowTypeByEquality(type, expr, assumeTrue) { - if (expr.left.kind !== 176 || expr.right.kind !== 9) { - return type; - } - var left = expr.left; - var right = expr.right; - if (left.expression.kind !== 69 || getResolvedSymbol(left.expression) !== symbol) { - return type; - } - var typeInfo = primitiveTypeInfo[right.text]; - if (expr.operatorToken.kind === 33) { - assumeTrue = !assumeTrue; - } - if (assumeTrue) { - if (!typeInfo) { - return removeTypesFromUnionType(type, 258 | 132 | 8 | 16777216, true, false); - } - if (isTypeSubtypeOf(typeInfo.type, type)) { - return typeInfo.type; - } - return removeTypesFromUnionType(type, typeInfo.flags, false, false); - } - else { - if (typeInfo) { - return removeTypesFromUnionType(type, typeInfo.flags, true, false); - } - return type; - } - } - function narrowTypeByAnd(type, expr, assumeTrue) { - if (assumeTrue) { - return narrowType(narrowType(type, expr.left, true), expr.right, true); - } - else { - return getUnionType([ - narrowType(type, expr.left, false), - narrowType(narrowType(type, expr.left, true), expr.right, false) - ]); - } - } - function narrowTypeByOr(type, expr, assumeTrue) { - if (assumeTrue) { - return getUnionType([ - narrowType(type, expr.left, true), - narrowType(narrowType(type, expr.left, false), expr.right, true) - ]); - } - else { - return narrowType(narrowType(type, expr.left, false), expr.right, false); - } - } - function narrowTypeByInstanceof(type, expr, assumeTrue) { - if (isTypeAny(type) || !assumeTrue || expr.left.kind !== 69 || getResolvedSymbol(expr.left) !== symbol) { - return type; - } - var rightType = checkExpression(expr.right); - if (!isTypeSubtypeOf(rightType, globalFunctionType)) { - return type; - } - var targetType; - var prototypeProperty = getPropertyOfType(rightType, "prototype"); - if (prototypeProperty) { - var prototypePropertyType = getTypeOfSymbol(prototypeProperty); - if (!isTypeAny(prototypePropertyType)) { - targetType = prototypePropertyType; - } - } - if (!targetType) { - var constructSignatures; - if (rightType.flags & 2048) { - constructSignatures = resolveDeclaredMembers(rightType).declaredConstructSignatures; - } - else if (rightType.flags & 65536) { - constructSignatures = getSignaturesOfType(rightType, 1); - } - if (constructSignatures && constructSignatures.length) { - targetType = getUnionType(ts.map(constructSignatures, function (signature) { return getReturnTypeOfSignature(getErasedSignature(signature)); })); - } - } - if (targetType) { - return getNarrowedType(type, targetType); - } - return type; - } - function getNarrowedType(originalType, narrowedTypeCandidate) { - if (originalType.flags & 16384) { - var assignableConstituents = ts.filter(originalType.types, function (t) { return isTypeAssignableTo(t, narrowedTypeCandidate); }); - if (assignableConstituents.length) { - return getUnionType(assignableConstituents); - } - } - if (isTypeAssignableTo(narrowedTypeCandidate, originalType)) { - return narrowedTypeCandidate; - } - return originalType; - } - function narrowTypeByTypePredicate(type, expr, assumeTrue) { - if (type.flags & 1) { - return type; - } - var signature = getResolvedSignature(expr); - if (signature.typePredicate && - expr.arguments[signature.typePredicate.parameterIndex] && - getSymbolAtLocation(expr.arguments[signature.typePredicate.parameterIndex]) === symbol) { - if (!assumeTrue) { - if (type.flags & 16384) { - return getUnionType(ts.filter(type.types, function (t) { return !isTypeSubtypeOf(t, signature.typePredicate.type); })); - } - return type; - } - return getNarrowedType(type, signature.typePredicate.type); - } - return type; - } - function narrowType(type, expr, assumeTrue) { - switch (expr.kind) { - case 168: - return narrowTypeByTypePredicate(type, expr, assumeTrue); - case 172: - return narrowType(type, expr.expression, assumeTrue); - case 181: - var operator = expr.operatorToken.kind; - if (operator === 32 || operator === 33) { - return narrowTypeByEquality(type, expr, assumeTrue); - } - else if (operator === 51) { - return narrowTypeByAnd(type, expr, assumeTrue); - } - else if (operator === 52) { - return narrowTypeByOr(type, expr, assumeTrue); - } - else if (operator === 91) { - return narrowTypeByInstanceof(type, expr, assumeTrue); - } - break; - case 179: - if (expr.operator === 49) { - return narrowType(type, expr.operand, !assumeTrue); - } - break; - } - return type; - } - } - function checkIdentifier(node) { - var symbol = getResolvedSymbol(node); - if (symbol === argumentsSymbol) { - var container = ts.getContainingFunction(node); - if (container.kind === 174) { - if (languageVersion < 2) { - error(node, ts.Diagnostics.The_arguments_object_cannot_be_referenced_in_an_arrow_function_in_ES3_and_ES5_Consider_using_a_standard_function_expression); - } - } - if (node.parserContextFlags & 8) { - getNodeLinks(container).flags |= 4096; - getNodeLinks(node).flags |= 2048; - } - } - if (symbol.flags & 8388608 && !isInTypeQuery(node) && !isConstEnumOrConstEnumOnlyModule(resolveAlias(symbol))) { - markAliasSymbolAsReferenced(symbol); - } - checkCollisionWithCapturedSuperVariable(node, node); - checkCollisionWithCapturedThisVariable(node, node); - checkBlockScopedBindingCapturedInLoop(node, symbol); - return getNarrowedTypeOfSymbol(getExportSymbolOfValueSymbolIfExported(symbol), node); - } - function isInsideFunction(node, threshold) { - var current = node; - while (current && current !== threshold) { - if (ts.isFunctionLike(current)) { - return true; - } - current = current.parent; - } - return false; - } - function checkBlockScopedBindingCapturedInLoop(node, symbol) { - if (languageVersion >= 2 || - (symbol.flags & 2) === 0 || - symbol.valueDeclaration.parent.kind === 244) { - return; - } - var container = symbol.valueDeclaration; - while (container.kind !== 212) { - container = container.parent; - } - container = container.parent; - if (container.kind === 193) { - container = container.parent; - } - var inFunction = isInsideFunction(node.parent, container); - var current = container; - while (current && !ts.nodeStartsNewLexicalEnvironment(current)) { - if (isIterationStatement(current, false)) { - if (inFunction) { - grammarErrorOnFirstToken(current, ts.Diagnostics.Loop_contains_block_scoped_variable_0_referenced_by_a_function_in_the_loop_This_is_only_supported_in_ECMAScript_6_or_higher, ts.declarationNameToString(node)); - } - getNodeLinks(symbol.valueDeclaration).flags |= 16384; - break; - } - current = current.parent; - } - } - function captureLexicalThis(node, container) { - getNodeLinks(node).flags |= 2; - if (container.kind === 141 || container.kind === 144) { - var classNode = container.parent; - getNodeLinks(classNode).flags |= 4; - } - else { - getNodeLinks(container).flags |= 4; - } - } - function checkThisExpression(node) { - var container = ts.getThisContainer(node, true); - var needToCaptureLexicalThis = false; - if (container.kind === 174) { - container = ts.getThisContainer(container, false); - needToCaptureLexicalThis = (languageVersion < 2); - } - switch (container.kind) { - case 218: - error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_module_or_namespace_body); - break; - case 217: - error(node, ts.Diagnostics.this_cannot_be_referenced_in_current_location); - break; - case 144: - if (isInConstructorArgumentInitializer(node, container)) { - error(node, ts.Diagnostics.this_cannot_be_referenced_in_constructor_arguments); - } - break; - case 141: - case 140: - if (container.flags & 128) { - error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_static_property_initializer); - } - break; - case 136: - error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_computed_property_name); - break; - } - if (needToCaptureLexicalThis) { - captureLexicalThis(node, container); - } - if (ts.isClassLike(container.parent)) { - var symbol = getSymbolOfNode(container.parent); - return container.flags & 128 ? getTypeOfSymbol(symbol) : getDeclaredTypeOfSymbol(symbol).thisType; - } - return anyType; - } - function isInConstructorArgumentInitializer(node, constructorDecl) { - for (var n = node; n && n !== constructorDecl; n = n.parent) { - if (n.kind === 138) { - return true; - } - } - return false; - } - function checkSuperExpression(node) { - var isCallExpression = node.parent.kind === 168 && node.parent.expression === node; - var classDeclaration = ts.getContainingClass(node); - var classType = classDeclaration && getDeclaredTypeOfSymbol(getSymbolOfNode(classDeclaration)); - var baseClassType = classType && getBaseTypes(classType)[0]; - var container = ts.getSuperContainer(node, true); - var needToCaptureLexicalThis = false; - if (!isCallExpression) { - while (container && container.kind === 174) { - container = ts.getSuperContainer(container, true); - needToCaptureLexicalThis = languageVersion < 2; - } - } - var canUseSuperExpression = isLegalUsageOfSuperExpression(container); - var nodeCheckFlag = 0; - if (canUseSuperExpression) { - if ((container.flags & 128) || isCallExpression) { - nodeCheckFlag = 512; - } - else { - nodeCheckFlag = 256; - } - getNodeLinks(node).flags |= nodeCheckFlag; - if (needToCaptureLexicalThis) { - captureLexicalThis(node.parent, container); - } - } - if (!baseClassType) { - if (!classDeclaration || !ts.getClassExtendsHeritageClauseElement(classDeclaration)) { - error(node, ts.Diagnostics.super_can_only_be_referenced_in_a_derived_class); - } - return unknownType; - } - if (!canUseSuperExpression) { - if (container && container.kind === 136) { - 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 { - error(node, ts.Diagnostics.super_property_access_is_permitted_only_in_a_constructor_member_function_or_member_accessor_of_a_derived_class); - } - return unknownType; - } - if (container.kind === 144 && isInConstructorArgumentInitializer(node, container)) { - error(node, ts.Diagnostics.super_cannot_be_referenced_in_constructor_arguments); - return unknownType; - } - return nodeCheckFlag === 512 - ? getBaseConstructorTypeOfClass(classType) - : baseClassType; - function isLegalUsageOfSuperExpression(container) { - if (!container) { - return false; - } - if (isCallExpression) { - return container.kind === 144; - } - else { - if (container && ts.isClassLike(container.parent)) { - if (container.flags & 128) { - return container.kind === 143 || - container.kind === 142 || - container.kind === 145 || - container.kind === 146; - } - else { - return container.kind === 143 || - container.kind === 142 || - container.kind === 145 || - container.kind === 146 || - container.kind === 141 || - container.kind === 140 || - container.kind === 144; - } - } - } - return false; - } - } - function getContextuallyTypedParameterType(parameter) { - var func = parameter.parent; - if (isFunctionExpressionOrArrowFunction(func) || ts.isObjectLiteralMethod(func)) { - if (isContextSensitive(func)) { - var contextualSignature = getContextualSignature(func); - if (contextualSignature) { - var funcHasRestParameters = ts.hasRestParameter(func); - var len = func.parameters.length - (funcHasRestParameters ? 1 : 0); - var indexOfParameter = ts.indexOf(func.parameters, parameter); - if (indexOfParameter < len) { - return getTypeAtPosition(contextualSignature, indexOfParameter); - } - if (funcHasRestParameters && - indexOfParameter === (func.parameters.length - 1) && - isRestParameterIndex(contextualSignature, func.parameters.length - 1)) { - return getTypeOfSymbol(ts.lastOrUndefined(contextualSignature.parameters)); - } - } - } - } - return undefined; - } - function getContextualTypeForInitializerExpression(node) { - var declaration = node.parent; - if (node === declaration.initializer) { - if (declaration.type) { - return getTypeFromTypeNode(declaration.type); - } - if (declaration.kind === 138) { - var type = getContextuallyTypedParameterType(declaration); - if (type) { - return type; - } - } - if (ts.isBindingPattern(declaration.name)) { - return getTypeFromBindingPattern(declaration.name, true); - } - } - return undefined; - } - function getContextualTypeForReturnExpression(node) { - var func = ts.getContainingFunction(node); - if (func && !func.asteriskToken) { - return getContextualReturnType(func); - } - return undefined; - } - function getContextualTypeForYieldOperand(node) { - var func = ts.getContainingFunction(node); - if (func) { - var contextualReturnType = getContextualReturnType(func); - if (contextualReturnType) { - return node.asteriskToken - ? contextualReturnType - : getElementTypeOfIterableIterator(contextualReturnType); - } - } - return undefined; - } - function isInParameterInitializerBeforeContainingFunction(node) { - while (node.parent && !ts.isFunctionLike(node.parent)) { - if (node.parent.kind === 138 && node.parent.initializer === node) { - return true; - } - node = node.parent; - } - return false; - } - function getContextualReturnType(functionDecl) { - if (functionDecl.type || - functionDecl.kind === 144 || - functionDecl.kind === 145 && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(functionDecl.symbol, 146))) { - return getReturnTypeOfSignature(getSignatureFromDeclaration(functionDecl)); - } - var signature = getContextualSignatureForFunctionLikeDeclaration(functionDecl); - if (signature) { - return getReturnTypeOfSignature(signature); - } - return undefined; - } - function getContextualTypeForArgument(callTarget, arg) { - var args = getEffectiveCallArguments(callTarget); - var argIndex = ts.indexOf(args, arg); - if (argIndex >= 0) { - var signature = getResolvedSignature(callTarget); - return getTypeAtPosition(signature, argIndex); - } - return undefined; - } - function getContextualTypeForSubstitutionExpression(template, substitutionExpression) { - if (template.parent.kind === 170) { - return getContextualTypeForArgument(template.parent, substitutionExpression); - } - return undefined; - } - function getContextualTypeForBinaryOperand(node) { - var binaryExpression = node.parent; - var operator = binaryExpression.operatorToken.kind; - if (operator >= 56 && operator <= 68) { - if (node === binaryExpression.right) { - return checkExpression(binaryExpression.left); - } - } - else if (operator === 52) { - var type = getContextualType(binaryExpression); - if (!type && node === binaryExpression.right) { - type = checkExpression(binaryExpression.left); - } - return type; - } - return undefined; - } - function applyToContextualType(type, mapper) { - if (!(type.flags & 16384)) { - return mapper(type); - } - var types = type.types; - var mappedType; - var mappedTypes; - for (var _i = 0; _i < types.length; _i++) { - var current = types[_i]; - var t = mapper(current); - if (t) { - if (!mappedType) { - mappedType = t; - } - else if (!mappedTypes) { - mappedTypes = [mappedType, t]; - } - else { - mappedTypes.push(t); - } - } - } - return mappedTypes ? getUnionType(mappedTypes) : mappedType; - } - function getTypeOfPropertyOfContextualType(type, name) { - return applyToContextualType(type, function (t) { - var prop = t.flags & 130048 ? getPropertyOfType(t, name) : undefined; - return prop ? getTypeOfSymbol(prop) : undefined; - }); - } - function getIndexTypeOfContextualType(type, kind) { - return applyToContextualType(type, function (t) { return getIndexTypeOfStructuredType(t, kind); }); - } - function contextualTypeIsTupleLikeType(type) { - return !!(type.flags & 16384 ? ts.forEach(type.types, isTupleLikeType) : isTupleLikeType(type)); - } - function contextualTypeHasIndexSignature(type, kind) { - return !!(type.flags & 16384 ? ts.forEach(type.types, function (t) { return getIndexTypeOfStructuredType(t, kind); }) : getIndexTypeOfStructuredType(type, kind)); - } - function getContextualTypeForObjectLiteralMethod(node) { - ts.Debug.assert(ts.isObjectLiteralMethod(node)); - if (isInsideWithStatementBody(node)) { - return undefined; - } - return getContextualTypeForObjectLiteralElement(node); - } - function getContextualTypeForObjectLiteralElement(element) { - var objectLiteral = element.parent; - var type = getContextualType(objectLiteral); - if (type) { - if (!ts.hasDynamicName(element)) { - var symbolName = getSymbolOfNode(element).name; - var propertyType = getTypeOfPropertyOfContextualType(type, symbolName); - if (propertyType) { - return propertyType; - } - } - return isNumericName(element.name) && getIndexTypeOfContextualType(type, 1) || - getIndexTypeOfContextualType(type, 0); - } - return undefined; - } - function getContextualTypeForElementExpression(node) { - var arrayLiteral = node.parent; - var type = getContextualType(arrayLiteral); - if (type) { - var index = ts.indexOf(arrayLiteral.elements, node); - return getTypeOfPropertyOfContextualType(type, "" + index) - || getIndexTypeOfContextualType(type, 1) - || (languageVersion >= 2 ? getElementTypeOfIterable(type, undefined) : undefined); - } - return undefined; - } - function getContextualTypeForConditionalOperand(node) { - var conditional = node.parent; - return node === conditional.whenTrue || node === conditional.whenFalse ? getContextualType(conditional) : undefined; - } - function getContextualTypeForJsxExpression(expr) { - if (expr.parent.kind === 238) { - var attrib = expr.parent; - var attrsType = getJsxElementAttributesType(attrib.parent); - if (!attrsType || isTypeAny(attrsType)) { - return undefined; - } - else { - return getTypeOfPropertyOfType(attrsType, attrib.name.text); - } - } - if (expr.kind === 239) { - return getJsxElementAttributesType(expr.parent); - } - return undefined; - } - function getContextualType(node) { - var type = getContextualTypeWorker(node); - return type && getApparentType(type); - } - function getContextualTypeWorker(node) { - if (isInsideWithStatementBody(node)) { - return undefined; - } - if (node.contextualType) { - return node.contextualType; - } - var parent = node.parent; - switch (parent.kind) { - case 211: - case 138: - case 141: - case 140: - case 163: - return getContextualTypeForInitializerExpression(node); - case 174: - case 204: - return getContextualTypeForReturnExpression(node); - case 184: - return getContextualTypeForYieldOperand(parent); - case 168: - case 169: - return getContextualTypeForArgument(parent, node); - case 171: - case 189: - return getTypeFromTypeNode(parent.type); - case 181: - return getContextualTypeForBinaryOperand(node); - case 245: - return getContextualTypeForObjectLiteralElement(parent); - case 164: - return getContextualTypeForElementExpression(node); - case 182: - return getContextualTypeForConditionalOperand(node); - case 190: - ts.Debug.assert(parent.parent.kind === 183); - return getContextualTypeForSubstitutionExpression(parent.parent, node); - case 172: - return getContextualType(parent); - case 240: - case 239: - return getContextualTypeForJsxExpression(parent); - } - return undefined; - } - function getNonGenericSignature(type) { - var signatures = getSignaturesOfStructuredType(type, 0); - if (signatures.length === 1) { - var signature = signatures[0]; - if (!signature.typeParameters) { - return signature; - } - } - } - function isFunctionExpressionOrArrowFunction(node) { - return node.kind === 173 || node.kind === 174; - } - function getContextualSignatureForFunctionLikeDeclaration(node) { - return isFunctionExpressionOrArrowFunction(node) || ts.isObjectLiteralMethod(node) - ? getContextualSignature(node) - : undefined; - } - function getContextualSignature(node) { - ts.Debug.assert(node.kind !== 143 || ts.isObjectLiteralMethod(node)); - var type = ts.isObjectLiteralMethod(node) - ? getContextualTypeForObjectLiteralMethod(node) - : getContextualType(node); - if (!type) { - return undefined; - } - if (!(type.flags & 16384)) { - return getNonGenericSignature(type); - } - var signatureList; - var types = type.types; - for (var _i = 0; _i < types.length; _i++) { - var current = types[_i]; - var signature = getNonGenericSignature(current); - if (signature) { - if (!signatureList) { - signatureList = [signature]; - } - else if (!compareSignatures(signatureList[0], signature, false, true, compareTypes)) { - return undefined; - } - else { - signatureList.push(signature); - } - } - } - var result; - if (signatureList) { - result = cloneSignature(signatureList[0]); - result.resolvedReturnType = undefined; - result.unionSignatures = signatureList; - } - return result; - } - function isInferentialContext(mapper) { - return mapper && mapper.context; - } - function isAssignmentTarget(node) { - var parent = node.parent; - if (parent.kind === 181 && parent.operatorToken.kind === 56 && parent.left === node) { - return true; - } - if (parent.kind === 245) { - return isAssignmentTarget(parent.parent); - } - if (parent.kind === 164) { - return isAssignmentTarget(parent); - } - return false; - } - function checkSpreadElementExpression(node, contextualMapper) { - var arrayOrIterableType = checkExpressionCached(node.expression, contextualMapper); - return checkIteratedTypeOrElementType(arrayOrIterableType, node.expression, false); - } - function hasDefaultValue(node) { - return (node.kind === 163 && !!node.initializer) || - (node.kind === 181 && node.operatorToken.kind === 56); - } - function checkArrayLiteral(node, contextualMapper) { - var elements = node.elements; - var hasSpreadElement = false; - var elementTypes = []; - var inDestructuringPattern = isAssignmentTarget(node); - for (var _i = 0; _i < elements.length; _i++) { - var e = elements[_i]; - if (inDestructuringPattern && e.kind === 185) { - var restArrayType = checkExpression(e.expression, contextualMapper); - var restElementType = getIndexTypeOfType(restArrayType, 1) || - (languageVersion >= 2 ? getElementTypeOfIterable(restArrayType, undefined) : undefined); - if (restElementType) { - elementTypes.push(restElementType); - } - } - else { - var type = checkExpression(e, contextualMapper); - elementTypes.push(type); - } - hasSpreadElement = hasSpreadElement || e.kind === 185; - } - if (!hasSpreadElement) { - if (inDestructuringPattern && elementTypes.length) { - var type = createNewTupleType(elementTypes); - type.pattern = node; - return type; - } - var contextualType = getContextualType(node); - if (contextualType && contextualTypeIsTupleLikeType(contextualType)) { - var pattern = contextualType.pattern; - if (pattern && (pattern.kind === 162 || pattern.kind === 164)) { - var patternElements = pattern.elements; - for (var i = elementTypes.length; i < patternElements.length; i++) { - var patternElement = patternElements[i]; - if (hasDefaultValue(patternElement)) { - elementTypes.push(contextualType.elementTypes[i]); - } - else { - if (patternElement.kind !== 187) { - error(patternElement, ts.Diagnostics.Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value); - } - elementTypes.push(unknownType); - } - } - } - if (elementTypes.length) { - return createTupleType(elementTypes); - } - } - } - return createArrayType(elementTypes.length ? getUnionType(elementTypes) : undefinedType); - } - function isNumericName(name) { - return name.kind === 136 ? isNumericComputedName(name) : isNumericLiteralName(name.text); - } - function isNumericComputedName(name) { - return isTypeAnyOrAllConstituentTypesHaveKind(checkComputedPropertyName(name), 132); - } - function isTypeAnyOrAllConstituentTypesHaveKind(type, kind) { - return isTypeAny(type) || allConstituentTypesHaveKind(type, kind); - } - function isNumericLiteralName(name) { - return (+name).toString() === name; - } - function checkComputedPropertyName(node) { - var links = getNodeLinks(node.expression); - if (!links.resolvedType) { - links.resolvedType = checkExpression(node.expression); - if (!isTypeAnyOrAllConstituentTypesHaveKind(links.resolvedType, 132 | 258 | 16777216)) { - error(node, ts.Diagnostics.A_computed_property_name_must_be_of_type_string_number_symbol_or_any); - } - else { - checkThatExpressionIsProperSymbolReference(node.expression, links.resolvedType, true); - } - } - return links.resolvedType; - } - function checkObjectLiteral(node, contextualMapper) { - var inDestructuringPattern = isAssignmentTarget(node); - checkGrammarObjectLiteralExpression(node, inDestructuringPattern); - var propertiesTable = {}; - var propertiesArray = []; - var contextualType = getContextualType(node); - var contextualTypeHasPattern = contextualType && contextualType.pattern && - (contextualType.pattern.kind === 161 || contextualType.pattern.kind === 165); - var typeFlags = 0; - for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { - var memberDecl = _a[_i]; - var member = memberDecl.symbol; - if (memberDecl.kind === 245 || - memberDecl.kind === 246 || - ts.isObjectLiteralMethod(memberDecl)) { - var type = void 0; - if (memberDecl.kind === 245) { - type = checkPropertyAssignment(memberDecl, contextualMapper); - } - else if (memberDecl.kind === 143) { - type = checkObjectLiteralMethod(memberDecl, contextualMapper); - } - else { - ts.Debug.assert(memberDecl.kind === 246); - type = checkExpression(memberDecl.name, contextualMapper); - } - typeFlags |= type.flags; - var prop = createSymbol(4 | 67108864 | member.flags, member.name); - if (inDestructuringPattern) { - var isOptional = (memberDecl.kind === 245 && hasDefaultValue(memberDecl.initializer)) || - (memberDecl.kind === 246 && memberDecl.objectAssignmentInitializer); - if (isOptional) { - prop.flags |= 536870912; - } - } - else if (contextualTypeHasPattern) { - var impliedProp = getPropertyOfType(contextualType, member.name); - if (impliedProp) { - prop.flags |= impliedProp.flags & 536870912; - } - else if (!compilerOptions.suppressExcessPropertyErrors) { - error(memberDecl.name, ts.Diagnostics.Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1, symbolToString(member), typeToString(contextualType)); - } - } - prop.declarations = member.declarations; - prop.parent = member.parent; - if (member.valueDeclaration) { - prop.valueDeclaration = member.valueDeclaration; - } - prop.type = type; - prop.target = member; - member = prop; - } - else { - ts.Debug.assert(memberDecl.kind === 145 || memberDecl.kind === 146); - checkAccessorDeclaration(memberDecl); - } - if (!ts.hasDynamicName(memberDecl)) { - propertiesTable[member.name] = member; - } - propertiesArray.push(member); - } - if (contextualTypeHasPattern) { - for (var _b = 0, _c = getPropertiesOfType(contextualType); _b < _c.length; _b++) { - var prop = _c[_b]; - if (!ts.hasProperty(propertiesTable, prop.name)) { - if (!(prop.flags & 536870912)) { - error(prop.valueDeclaration || prop.bindingElement, ts.Diagnostics.Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value); - } - propertiesTable[prop.name] = prop; - propertiesArray.push(prop); - } - } - } - var stringIndexType = getIndexType(0); - var numberIndexType = getIndexType(1); - var result = createAnonymousType(node.symbol, propertiesTable, emptyArray, emptyArray, stringIndexType, numberIndexType); - var freshObjectLiteralFlag = compilerOptions.suppressExcessPropertyErrors ? 0 : 1048576; - result.flags |= 524288 | 4194304 | freshObjectLiteralFlag | (typeFlags & 14680064); - if (inDestructuringPattern) { - result.pattern = node; - } - return result; - function getIndexType(kind) { - if (contextualType && contextualTypeHasIndexSignature(contextualType, kind)) { - var propTypes = []; - for (var i = 0; i < propertiesArray.length; i++) { - var propertyDecl = node.properties[i]; - if (kind === 0 || isNumericName(propertyDecl.name)) { - var type = getTypeOfSymbol(propertiesArray[i]); - if (!ts.contains(propTypes, type)) { - propTypes.push(type); - } - } - } - var result_1 = propTypes.length ? getUnionType(propTypes) : undefinedType; - typeFlags |= result_1.flags; - return result_1; - } - return undefined; - } - } - function checkJsxSelfClosingElement(node) { - checkJsxOpeningLikeElement(node); - return jsxElementType || anyType; - } - function tagNamesAreEquivalent(lhs, rhs) { - if (lhs.kind !== rhs.kind) { - return false; - } - if (lhs.kind === 69) { - return lhs.text === rhs.text; - } - return lhs.right.text === rhs.right.text && - tagNamesAreEquivalent(lhs.left, rhs.left); - } - function checkJsxElement(node) { - checkJsxOpeningLikeElement(node.openingElement); - if (!tagNamesAreEquivalent(node.openingElement.tagName, node.closingElement.tagName)) { - error(node.closingElement, ts.Diagnostics.Expected_corresponding_JSX_closing_tag_for_0, ts.getTextOfNode(node.openingElement.tagName)); - } - else { - getJsxElementTagSymbol(node.closingElement); - } - for (var _i = 0, _a = node.children; _i < _a.length; _i++) { - var child = _a[_i]; - switch (child.kind) { - case 240: - checkJsxExpression(child); - break; - case 233: - checkJsxElement(child); - break; - case 234: - checkJsxSelfClosingElement(child); - break; - } - } - return jsxElementType || anyType; - } - function isUnhyphenatedJsxName(name) { - return name.indexOf("-") < 0; - } - function isJsxIntrinsicIdentifier(tagName) { - if (tagName.kind === 135) { - return false; - } - else { - return ts.isIntrinsicJsxName(tagName.text); - } - } - function checkJsxAttribute(node, elementAttributesType, nameTable) { - var correspondingPropType = undefined; - if (elementAttributesType === emptyObjectType && isUnhyphenatedJsxName(node.name.text)) { - error(node.parent, ts.Diagnostics.JSX_element_class_does_not_support_attributes_because_it_does_not_have_a_0_property, getJsxElementPropertiesName()); - } - else if (elementAttributesType && !isTypeAny(elementAttributesType)) { - var correspondingPropSymbol = getPropertyOfType(elementAttributesType, node.name.text); - correspondingPropType = correspondingPropSymbol && getTypeOfSymbol(correspondingPropSymbol); - if (isUnhyphenatedJsxName(node.name.text)) { - var indexerType = getIndexTypeOfType(elementAttributesType, 0); - if (indexerType) { - correspondingPropType = indexerType; - } - else { - if (!correspondingPropType) { - error(node.name, ts.Diagnostics.Property_0_does_not_exist_on_type_1, node.name.text, typeToString(elementAttributesType)); - return unknownType; - } - } - } - } - var exprType; - if (node.initializer) { - exprType = checkExpression(node.initializer); - } - else { - exprType = booleanType; - } - if (correspondingPropType) { - checkTypeAssignableTo(exprType, correspondingPropType, node); - } - nameTable[node.name.text] = true; - return exprType; - } - function checkJsxSpreadAttribute(node, elementAttributesType, nameTable) { - var type = checkExpression(node.expression); - var props = getPropertiesOfType(type); - for (var _i = 0; _i < props.length; _i++) { - var prop = props[_i]; - if (!nameTable[prop.name]) { - var targetPropSym = getPropertyOfType(elementAttributesType, prop.name); - if (targetPropSym) { - var msg = ts.chainDiagnosticMessages(undefined, ts.Diagnostics.Property_0_of_JSX_spread_attribute_is_not_assignable_to_target_property, prop.name); - checkTypeAssignableTo(getTypeOfSymbol(prop), getTypeOfSymbol(targetPropSym), node, undefined, msg); - } - nameTable[prop.name] = true; - } - } - return type; - } - function getJsxIntrinsicElementsType() { - if (!jsxIntrinsicElementsType) { - jsxIntrinsicElementsType = getExportedTypeFromNamespace(JsxNames.JSX, JsxNames.IntrinsicElements) || unknownType; - } - return jsxIntrinsicElementsType; - } - function getJsxElementTagSymbol(node) { - var flags = 8; - var links = getNodeLinks(node); - if (!links.resolvedSymbol) { - if (isJsxIntrinsicIdentifier(node.tagName)) { - links.resolvedSymbol = lookupIntrinsicTag(node); - } - else { - links.resolvedSymbol = lookupClassTag(node); - } - } - return links.resolvedSymbol; - function lookupIntrinsicTag(node) { - var intrinsicElementsType = getJsxIntrinsicElementsType(); - if (intrinsicElementsType !== unknownType) { - var intrinsicProp = getPropertyOfType(intrinsicElementsType, node.tagName.text); - if (intrinsicProp) { - links.jsxFlags |= 1; - return intrinsicProp; - } - var indexSignatureType = getIndexTypeOfType(intrinsicElementsType, 0); - if (indexSignatureType) { - links.jsxFlags |= 2; - return intrinsicElementsType.symbol; - } - error(node, ts.Diagnostics.Property_0_does_not_exist_on_type_1, node.tagName.text, "JSX." + JsxNames.IntrinsicElements); - return unknownSymbol; - } - else { - if (compilerOptions.noImplicitAny) { - error(node, ts.Diagnostics.JSX_element_implicitly_has_type_any_because_no_interface_JSX_0_exists, JsxNames.IntrinsicElements); - } - } - } - function lookupClassTag(node) { - var valueSymbol = resolveJsxTagName(node); - if (valueSymbol && valueSymbol !== unknownSymbol) { - links.jsxFlags |= 4; - if (valueSymbol.flags & 8388608) { - markAliasSymbolAsReferenced(valueSymbol); - } - } - return valueSymbol || unknownSymbol; - } - function resolveJsxTagName(node) { - if (node.tagName.kind === 69) { - var tag = node.tagName; - var sym = getResolvedSymbol(tag); - return sym.exportSymbol || sym; - } - else { - return checkQualifiedName(node.tagName).symbol; - } - } - } - function getJsxElementInstanceType(node) { - ts.Debug.assert(!!(getNodeLinks(node).jsxFlags & 4), "Should not call getJsxElementInstanceType on non-class Element"); - var classSymbol = getJsxElementTagSymbol(node); - if (classSymbol === unknownSymbol) { - return anyType; - } - var valueType = getTypeOfSymbol(classSymbol); - if (isTypeAny(valueType)) { - return anyType; - } - var signatures = getSignaturesOfType(valueType, 1); - if (signatures.length === 0) { - signatures = getSignaturesOfType(valueType, 0); - if (signatures.length === 0) { - error(node.tagName, ts.Diagnostics.JSX_element_type_0_does_not_have_any_construct_or_call_signatures, ts.getTextOfNode(node.tagName)); - return unknownType; - } - } - var returnType = getUnionType(signatures.map(getReturnTypeOfSignature)); - var elemClassType = getJsxGlobalElementClassType(); - if (elemClassType) { - checkTypeRelatedTo(returnType, elemClassType, assignableRelation, node, ts.Diagnostics.JSX_element_type_0_is_not_a_constructor_function_for_JSX_elements); - } - return returnType; - } - function getJsxElementPropertiesName() { - var jsxNamespace = getGlobalSymbol(JsxNames.JSX, 1536, undefined); - var attribsPropTypeSym = jsxNamespace && getSymbol(jsxNamespace.exports, JsxNames.ElementAttributesPropertyNameContainer, 793056); - var attribPropType = attribsPropTypeSym && getDeclaredTypeOfSymbol(attribsPropTypeSym); - var attribProperties = attribPropType && getPropertiesOfType(attribPropType); - if (attribProperties) { - if (attribProperties.length === 0) { - return ""; - } - else if (attribProperties.length === 1) { - return attribProperties[0].name; - } - else { - error(attribsPropTypeSym.declarations[0], ts.Diagnostics.The_global_type_JSX_0_may_not_have_more_than_one_property, JsxNames.ElementAttributesPropertyNameContainer); - return undefined; - } - } - else { - return undefined; - } - } - function getJsxElementAttributesType(node) { - var links = getNodeLinks(node); - if (!links.resolvedJsxType) { - var sym = getJsxElementTagSymbol(node); - if (links.jsxFlags & 4) { - var elemInstanceType = getJsxElementInstanceType(node); - if (isTypeAny(elemInstanceType)) { - return links.resolvedJsxType = elemInstanceType; - } - var propsName = getJsxElementPropertiesName(); - if (propsName === undefined) { - return links.resolvedJsxType = anyType; - } - else if (propsName === "") { - return links.resolvedJsxType = elemInstanceType; - } - else { - var attributesType = getTypeOfPropertyOfType(elemInstanceType, propsName); - if (!attributesType) { - return links.resolvedJsxType = emptyObjectType; - } - else if (isTypeAny(attributesType) || (attributesType === unknownType)) { - return links.resolvedJsxType = attributesType; - } - else if (!(attributesType.flags & 80896)) { - error(node.tagName, ts.Diagnostics.JSX_element_attributes_type_0_must_be_an_object_type, typeToString(attributesType)); - return links.resolvedJsxType = anyType; - } - else { - return links.resolvedJsxType = attributesType; - } - } - } - else if (links.jsxFlags & 1) { - return links.resolvedJsxType = getTypeOfSymbol(sym); - } - else if (links.jsxFlags & 2) { - return links.resolvedJsxType = getIndexTypeOfSymbol(sym, 0); - } - else { - return links.resolvedJsxType = anyType; - } - } - return links.resolvedJsxType; - } - function getJsxAttributePropertySymbol(attrib) { - var attributesType = getJsxElementAttributesType(attrib.parent); - var prop = getPropertyOfType(attributesType, attrib.name.text); - return prop || unknownSymbol; - } - var jsxElementClassType = undefined; - function getJsxGlobalElementClassType() { - if (!jsxElementClassType) { - jsxElementClassType = getExportedTypeFromNamespace(JsxNames.JSX, JsxNames.ElementClass); - } - return jsxElementClassType; - } - function getJsxIntrinsicTagNames() { - var intrinsics = getJsxIntrinsicElementsType(); - return intrinsics ? getPropertiesOfType(intrinsics) : emptyArray; - } - function checkJsxPreconditions(errorNode) { - if ((compilerOptions.jsx || 0) === 0) { - error(errorNode, ts.Diagnostics.Cannot_use_JSX_unless_the_jsx_flag_is_provided); - } - if (jsxElementType === undefined) { - if (compilerOptions.noImplicitAny) { - error(errorNode, ts.Diagnostics.JSX_element_implicitly_has_type_any_because_the_global_type_JSX_Element_does_not_exist); - } - } - } - function checkJsxOpeningLikeElement(node) { - checkGrammarJsxElement(node); - checkJsxPreconditions(node); - if (compilerOptions.jsx === 2) { - var reactSym = resolveName(node.tagName, "React", 107455, ts.Diagnostics.Cannot_find_name_0, "React"); - if (reactSym) { - getSymbolLinks(reactSym).referenced = true; - } - } - var targetAttributesType = getJsxElementAttributesType(node); - var nameTable = {}; - var sawSpreadedAny = false; - for (var i = node.attributes.length - 1; i >= 0; i--) { - if (node.attributes[i].kind === 238) { - checkJsxAttribute((node.attributes[i]), targetAttributesType, nameTable); - } - else { - ts.Debug.assert(node.attributes[i].kind === 239); - var spreadType = checkJsxSpreadAttribute((node.attributes[i]), targetAttributesType, nameTable); - if (isTypeAny(spreadType)) { - sawSpreadedAny = true; - } - } - } - if (targetAttributesType && !sawSpreadedAny) { - var targetProperties = getPropertiesOfType(targetAttributesType); - for (var i = 0; i < targetProperties.length; i++) { - if (!(targetProperties[i].flags & 536870912) && - nameTable[targetProperties[i].name] === undefined) { - error(node, ts.Diagnostics.Property_0_is_missing_in_type_1, targetProperties[i].name, typeToString(targetAttributesType)); - } - } - } - } - function checkJsxExpression(node) { - if (node.expression) { - return checkExpression(node.expression); - } - else { - return unknownType; - } - } - function getDeclarationKindFromSymbol(s) { - return s.valueDeclaration ? s.valueDeclaration.kind : 141; - } - function getDeclarationFlagsFromSymbol(s) { - return s.valueDeclaration ? ts.getCombinedNodeFlags(s.valueDeclaration) : s.flags & 134217728 ? 16 | 128 : 0; - } - function checkClassPropertyAccess(node, left, type, prop) { - var flags = getDeclarationFlagsFromSymbol(prop); - var declaringClass = getDeclaredTypeOfSymbol(prop.parent); - if (left.kind === 95) { - var errorNode = node.kind === 166 ? - node.name : - node.right; - if (getDeclarationKindFromSymbol(prop) !== 143) { - error(errorNode, ts.Diagnostics.Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword); - return false; - } - if (flags & 256) { - error(errorNode, ts.Diagnostics.Abstract_method_0_in_class_1_cannot_be_accessed_via_super_expression, symbolToString(prop), typeToString(declaringClass)); - return false; - } - } - if (!(flags & (32 | 64))) { - return true; - } - var enclosingClassDeclaration = ts.getContainingClass(node); - var enclosingClass = enclosingClassDeclaration ? getDeclaredTypeOfSymbol(getSymbolOfNode(enclosingClassDeclaration)) : undefined; - if (flags & 32) { - if (declaringClass !== enclosingClass) { - error(node, ts.Diagnostics.Property_0_is_private_and_only_accessible_within_class_1, symbolToString(prop), typeToString(declaringClass)); - return false; - } - return true; - } - if (left.kind === 95) { - return true; - } - if (!enclosingClass || !hasBaseType(enclosingClass, declaringClass)) { - error(node, ts.Diagnostics.Property_0_is_protected_and_only_accessible_within_class_1_and_its_subclasses, symbolToString(prop), typeToString(declaringClass)); - return false; - } - if (flags & 128) { - return true; - } - if (type.flags & 33554432) { - type = getConstraintOfTypeParameter(type); - } - if (!(getTargetType(type).flags & (1024 | 2048) && hasBaseType(type, enclosingClass))) { - error(node, ts.Diagnostics.Property_0_is_protected_and_only_accessible_through_an_instance_of_class_1, symbolToString(prop), typeToString(enclosingClass)); - return false; - } - return true; - } - function checkPropertyAccessExpression(node) { - return checkPropertyAccessExpressionOrQualifiedName(node, node.expression, node.name); - } - function checkQualifiedName(node) { - return checkPropertyAccessExpressionOrQualifiedName(node, node.left, node.right); - } - function checkPropertyAccessExpressionOrQualifiedName(node, left, right) { - var type = checkExpression(left); - if (isTypeAny(type)) { - return type; - } - var apparentType = getApparentType(getWidenedType(type)); - if (apparentType === unknownType) { - return unknownType; - } - var prop = getPropertyOfType(apparentType, right.text); - if (!prop) { - if (right.text) { - error(right, ts.Diagnostics.Property_0_does_not_exist_on_type_1, ts.declarationNameToString(right), typeToString(type.flags & 33554432 ? apparentType : type)); - } - return unknownType; - } - getNodeLinks(node).resolvedSymbol = prop; - if (prop.parent && prop.parent.flags & 32) { - checkClassPropertyAccess(node, left, apparentType, prop); - } - return getTypeOfSymbol(prop); - } - function isValidPropertyAccess(node, propertyName) { - var left = node.kind === 166 - ? node.expression - : node.left; - var type = checkExpression(left); - if (type !== unknownType && !isTypeAny(type)) { - var prop = getPropertyOfType(getWidenedType(type), propertyName); - if (prop && prop.parent && prop.parent.flags & 32) { - return checkClassPropertyAccess(node, left, type, prop); - } - } - return true; - } - function checkIndexedAccess(node) { - if (!node.argumentExpression) { - var sourceFile = getSourceFile(node); - if (node.parent.kind === 169 && node.parent.expression === node) { - var start = ts.skipTrivia(sourceFile.text, node.expression.end); - var end = node.end; - grammarErrorAtPos(sourceFile, start, end - start, ts.Diagnostics.new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead); - } - else { - var start = node.end - "]".length; - var end = node.end; - grammarErrorAtPos(sourceFile, start, end - start, ts.Diagnostics.Expression_expected); - } - } - var objectType = getApparentType(checkExpression(node.expression)); - var indexType = node.argumentExpression ? checkExpression(node.argumentExpression) : unknownType; - if (objectType === unknownType) { - return unknownType; - } - var isConstEnum = isConstEnumObjectType(objectType); - if (isConstEnum && - (!node.argumentExpression || node.argumentExpression.kind !== 9)) { - error(node.argumentExpression, ts.Diagnostics.A_const_enum_member_can_only_be_accessed_using_a_string_literal); - return unknownType; - } - if (node.argumentExpression) { - var name_12 = getPropertyNameForIndexedAccess(node.argumentExpression, indexType); - if (name_12 !== undefined) { - var prop = getPropertyOfType(objectType, name_12); - 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_12, symbolToString(objectType.symbol)); - return unknownType; - } - } - } - if (isTypeAnyOrAllConstituentTypesHaveKind(indexType, 258 | 132 | 16777216)) { - if (isTypeAnyOrAllConstituentTypesHaveKind(indexType, 132)) { - var numberIndexType = getIndexTypeOfType(objectType, 1); - if (numberIndexType) { - return numberIndexType; - } - } - var stringIndexType = getIndexTypeOfType(objectType, 0); - if (stringIndexType) { - return stringIndexType; - } - if (compilerOptions.noImplicitAny && !compilerOptions.suppressImplicitAnyIndexErrors && !isTypeAny(objectType)) { - error(node, ts.Diagnostics.Index_signature_of_object_type_implicitly_has_an_any_type); - } - return anyType; - } - error(node, ts.Diagnostics.An_index_expression_argument_must_be_of_type_string_number_symbol_or_any); - return unknownType; - } - function getPropertyNameForIndexedAccess(indexArgumentExpression, indexArgumentType) { - if (indexArgumentExpression.kind === 9 || indexArgumentExpression.kind === 8) { - return indexArgumentExpression.text; - } - if (indexArgumentExpression.kind === 167 || indexArgumentExpression.kind === 166) { - var value = getConstantValue(indexArgumentExpression); - if (value !== undefined) { - return value.toString(); - } - } - if (checkThatExpressionIsProperSymbolReference(indexArgumentExpression, indexArgumentType, false)) { - var rightHandSideName = indexArgumentExpression.name.text; - return ts.getPropertyNameForKnownSymbolName(rightHandSideName); - } - return undefined; - } - function checkThatExpressionIsProperSymbolReference(expression, expressionType, reportError) { - if (expressionType === unknownType) { - return false; - } - if (!ts.isWellKnownSymbolSyntactically(expression)) { - return false; - } - if ((expressionType.flags & 16777216) === 0) { - if (reportError) { - error(expression, ts.Diagnostics.A_computed_property_name_of_the_form_0_must_be_of_type_symbol, ts.getTextOfNode(expression)); - } - return false; - } - var leftHandSide = expression.expression; - var leftHandSideSymbol = getResolvedSymbol(leftHandSide); - if (!leftHandSideSymbol) { - return false; - } - var globalESSymbol = getGlobalESSymbolConstructorSymbol(); - if (!globalESSymbol) { - return false; - } - if (leftHandSideSymbol !== globalESSymbol) { - if (reportError) { - error(leftHandSide, ts.Diagnostics.Symbol_reference_does_not_refer_to_the_global_Symbol_constructor_object); - } - return false; - } - return true; - } - function resolveUntypedCall(node) { - if (node.kind === 170) { - checkExpression(node.template); - } - else if (node.kind !== 139) { - ts.forEach(node.arguments, function (argument) { - checkExpression(argument); - }); - } - return anySignature; - } - function resolveErrorCall(node) { - resolveUntypedCall(node); - return unknownSignature; - } - function reorderCandidates(signatures, result) { - var lastParent; - var lastSymbol; - var cutoffIndex = 0; - var index; - var specializedIndex = -1; - var spliceIndex; - ts.Debug.assert(!result.length); - for (var _i = 0; _i < signatures.length; _i++) { - var signature = signatures[_i]; - var symbol = signature.declaration && getSymbolOfNode(signature.declaration); - var parent_5 = signature.declaration && signature.declaration.parent; - if (!lastSymbol || symbol === lastSymbol) { - if (lastParent && parent_5 === lastParent) { - index++; - } - else { - lastParent = parent_5; - index = cutoffIndex; - } - } - else { - index = cutoffIndex = result.length; - lastParent = parent_5; - } - lastSymbol = symbol; - if (signature.hasStringLiterals) { - specializedIndex++; - spliceIndex = specializedIndex; - cutoffIndex++; - } - else { - spliceIndex = index; - } - result.splice(spliceIndex, 0, signature); - } - } - function getSpreadArgumentIndex(args) { - for (var i = 0; i < args.length; i++) { - var arg = args[i]; - if (arg && arg.kind === 185) { - return i; - } - } - return -1; - } - function hasCorrectArity(node, args, signature) { - var adjustedArgCount; - var typeArguments; - var callIsIncomplete; - var isDecorator; - var spreadArgIndex = -1; - if (node.kind === 170) { - var tagExpression = node; - adjustedArgCount = args.length; - typeArguments = undefined; - if (tagExpression.template.kind === 183) { - var templateExpression = tagExpression.template; - var lastSpan = ts.lastOrUndefined(templateExpression.templateSpans); - ts.Debug.assert(lastSpan !== undefined); - callIsIncomplete = ts.nodeIsMissing(lastSpan.literal) || !!lastSpan.literal.isUnterminated; - } - else { - var templateLiteral = tagExpression.template; - ts.Debug.assert(templateLiteral.kind === 11); - callIsIncomplete = !!templateLiteral.isUnterminated; - } - } - else if (node.kind === 139) { - isDecorator = true; - typeArguments = undefined; - adjustedArgCount = getEffectiveArgumentCount(node, undefined, signature); - } - else { - var callExpression = node; - if (!callExpression.arguments) { - ts.Debug.assert(callExpression.kind === 169); - return signature.minArgumentCount === 0; - } - adjustedArgCount = callExpression.arguments.hasTrailingComma ? args.length + 1 : args.length; - callIsIncomplete = callExpression.arguments.end === callExpression.end; - typeArguments = callExpression.typeArguments; - spreadArgIndex = getSpreadArgumentIndex(args); - } - var hasRightNumberOfTypeArgs = !typeArguments || - (signature.typeParameters && typeArguments.length === signature.typeParameters.length); - if (!hasRightNumberOfTypeArgs) { - return false; - } - if (spreadArgIndex >= 0) { - return isRestParameterIndex(signature, spreadArgIndex); - } - if (!signature.hasRestParameter && adjustedArgCount > signature.parameters.length) { - return false; - } - var hasEnoughArguments = adjustedArgCount >= signature.minArgumentCount; - return callIsIncomplete || hasEnoughArguments; - } - function getSingleCallSignature(type) { - if (type.flags & 80896) { - var resolved = resolveStructuredTypeMembers(type); - if (resolved.callSignatures.length === 1 && resolved.constructSignatures.length === 0 && - resolved.properties.length === 0 && !resolved.stringIndexType && !resolved.numberIndexType) { - return resolved.callSignatures[0]; - } - } - return undefined; - } - function instantiateSignatureInContextOf(signature, contextualSignature, contextualMapper) { - var context = createInferenceContext(signature.typeParameters, true); - forEachMatchingParameterType(contextualSignature, signature, function (source, target) { - inferTypes(context, instantiateType(source, contextualMapper), target); - }); - return getSignatureInstantiation(signature, getInferredTypes(context)); - } - function inferTypeArguments(node, signature, args, excludeArgument, context) { - var typeParameters = signature.typeParameters; - var inferenceMapper = createInferenceMapper(context); - for (var i = 0; i < typeParameters.length; i++) { - if (!context.inferences[i].isFixed) { - context.inferredTypes[i] = undefined; - } - } - if (context.failedTypeParameterIndex !== undefined && !context.inferences[context.failedTypeParameterIndex].isFixed) { - context.failedTypeParameterIndex = undefined; - } - var argCount = getEffectiveArgumentCount(node, args, signature); - for (var i = 0; i < argCount; i++) { - var arg = getEffectiveArgument(node, args, i); - if (arg === undefined || arg.kind !== 187) { - var paramType = getTypeAtPosition(signature, i); - var argType = getEffectiveArgumentType(node, i, arg); - if (argType === undefined) { - var mapper = excludeArgument && excludeArgument[i] !== undefined ? identityMapper : inferenceMapper; - argType = checkExpressionWithContextualType(arg, paramType, mapper); - } - inferTypes(context, argType, paramType); - } - } - if (excludeArgument) { - for (var i = 0; i < argCount; i++) { - if (excludeArgument[i] === false) { - var arg = args[i]; - var paramType = getTypeAtPosition(signature, i); - inferTypes(context, checkExpressionWithContextualType(arg, paramType, inferenceMapper), paramType); - } - } - } - getInferredTypes(context); - } - function checkTypeArguments(signature, typeArguments, typeArgumentResultTypes, reportErrors, headMessage) { - var typeParameters = signature.typeParameters; - var typeArgumentsAreAssignable = true; - for (var i = 0; i < typeParameters.length; i++) { - var typeArgNode = typeArguments[i]; - var typeArgument = getTypeFromTypeNode(typeArgNode); - typeArgumentResultTypes[i] = typeArgument; - if (typeArgumentsAreAssignable) { - var constraint = getConstraintOfTypeParameter(typeParameters[i]); - if (constraint) { - var errorInfo = void 0; - var typeArgumentHeadMessage = ts.Diagnostics.Type_0_does_not_satisfy_the_constraint_1; - if (reportErrors && headMessage) { - errorInfo = ts.chainDiagnosticMessages(errorInfo, typeArgumentHeadMessage); - typeArgumentHeadMessage = headMessage; - } - typeArgumentsAreAssignable = checkTypeAssignableTo(typeArgument, constraint, reportErrors ? typeArgNode : undefined, typeArgumentHeadMessage, errorInfo); - } - } - } - return typeArgumentsAreAssignable; - } - function checkApplicableSignature(node, args, signature, relation, excludeArgument, reportErrors) { - var argCount = getEffectiveArgumentCount(node, args, signature); - for (var i = 0; i < argCount; i++) { - var arg = getEffectiveArgument(node, args, i); - if (arg === undefined || arg.kind !== 187) { - var paramType = getTypeAtPosition(signature, i); - var argType = getEffectiveArgumentType(node, i, arg); - if (argType === undefined) { - argType = arg.kind === 9 && !reportErrors - ? getStringLiteralType(arg) - : checkExpressionWithContextualType(arg, paramType, excludeArgument && excludeArgument[i] ? identityMapper : undefined); - } - var errorNode = reportErrors ? getEffectiveArgumentErrorNode(node, i, arg) : undefined; - var headMessage = ts.Diagnostics.Argument_of_type_0_is_not_assignable_to_parameter_of_type_1; - if (!checkTypeRelatedTo(argType, paramType, relation, errorNode, headMessage)) { - return false; - } - } - } - return true; - } - function getEffectiveCallArguments(node) { - var args; - if (node.kind === 170) { - var template = node.template; - args = [undefined]; - if (template.kind === 183) { - ts.forEach(template.templateSpans, function (span) { - args.push(span.expression); - }); - } - } - else if (node.kind === 139) { - return undefined; - } - else { - args = node.arguments || emptyArray; - } - return args; - } - function getEffectiveArgumentCount(node, args, signature) { - if (node.kind === 139) { - switch (node.parent.kind) { - case 214: - case 186: - return 1; - case 141: - return 2; - case 143: - case 145: - case 146: - if (languageVersion === 0) { - return 2; - } - return signature.parameters.length >= 3 ? 3 : 2; - case 138: - return 3; - } - } - else { - return args.length; - } - } - function getEffectiveDecoratorFirstArgumentType(node) { - if (node.kind === 214) { - var classSymbol = getSymbolOfNode(node); - return getTypeOfSymbol(classSymbol); - } - if (node.kind === 138) { - node = node.parent; - if (node.kind === 144) { - var classSymbol = getSymbolOfNode(node); - return getTypeOfSymbol(classSymbol); - } - } - if (node.kind === 141 || - node.kind === 143 || - node.kind === 145 || - node.kind === 146) { - return getParentTypeOfClassElement(node); - } - ts.Debug.fail("Unsupported decorator target."); - return unknownType; - } - function getEffectiveDecoratorSecondArgumentType(node) { - if (node.kind === 214) { - ts.Debug.fail("Class decorators should not have a second synthetic argument."); - return unknownType; - } - if (node.kind === 138) { - node = node.parent; - if (node.kind === 144) { - return anyType; - } - } - if (node.kind === 141 || - node.kind === 143 || - node.kind === 145 || - node.kind === 146) { - var element = node; - switch (element.name.kind) { - case 69: - case 8: - case 9: - return getStringLiteralType(element.name); - case 136: - var nameType = checkComputedPropertyName(element.name); - if (allConstituentTypesHaveKind(nameType, 16777216)) { - return nameType; - } - else { - return stringType; - } - default: - ts.Debug.fail("Unsupported property name."); - return unknownType; - } - } - ts.Debug.fail("Unsupported decorator target."); - return unknownType; - } - function getEffectiveDecoratorThirdArgumentType(node) { - if (node.kind === 214) { - ts.Debug.fail("Class decorators should not have a third synthetic argument."); - return unknownType; - } - if (node.kind === 138) { - return numberType; - } - if (node.kind === 141) { - ts.Debug.fail("Property decorators should not have a third synthetic argument."); - return unknownType; - } - if (node.kind === 143 || - node.kind === 145 || - node.kind === 146) { - var propertyType = getTypeOfNode(node); - return createTypedPropertyDescriptorType(propertyType); - } - ts.Debug.fail("Unsupported decorator target."); - return unknownType; - } - function getEffectiveDecoratorArgumentType(node, argIndex) { - if (argIndex === 0) { - return getEffectiveDecoratorFirstArgumentType(node.parent); - } - else if (argIndex === 1) { - return getEffectiveDecoratorSecondArgumentType(node.parent); - } - else if (argIndex === 2) { - return getEffectiveDecoratorThirdArgumentType(node.parent); - } - ts.Debug.fail("Decorators should not have a fourth synthetic argument."); - return unknownType; - } - function getEffectiveArgumentType(node, argIndex, arg) { - if (node.kind === 139) { - return getEffectiveDecoratorArgumentType(node, argIndex); - } - else if (argIndex === 0 && node.kind === 170) { - return globalTemplateStringsArrayType; - } - return undefined; - } - function getEffectiveArgument(node, args, argIndex) { - if (node.kind === 139 || - (argIndex === 0 && node.kind === 170)) { - return undefined; - } - return args[argIndex]; - } - function getEffectiveArgumentErrorNode(node, argIndex, arg) { - if (node.kind === 139) { - return node.expression; - } - else if (argIndex === 0 && node.kind === 170) { - return node.template; - } - else { - return arg; - } - } - function resolveCall(node, signatures, candidatesOutArray, headMessage) { - var isTaggedTemplate = node.kind === 170; - var isDecorator = node.kind === 139; - var typeArguments; - if (!isTaggedTemplate && !isDecorator) { - typeArguments = node.typeArguments; - if (node.expression.kind !== 95) { - ts.forEach(typeArguments, checkSourceElement); - } - } - var candidates = candidatesOutArray || []; - reorderCandidates(signatures, candidates); - if (!candidates.length) { - reportError(ts.Diagnostics.Supplied_parameters_do_not_match_any_signature_of_call_target); - return resolveErrorCall(node); - } - var args = getEffectiveCallArguments(node); - var excludeArgument; - if (!isDecorator) { - for (var i = isTaggedTemplate ? 1 : 0; i < args.length; i++) { - if (isContextSensitive(args[i])) { - if (!excludeArgument) { - excludeArgument = new Array(args.length); - } - excludeArgument[i] = true; - } - } - } - var candidateForArgumentError; - var candidateForTypeArgumentError; - var resultOfFailedInference; - var result; - if (candidates.length > 1) { - result = chooseOverload(candidates, subtypeRelation); - } - if (!result) { - candidateForArgumentError = undefined; - candidateForTypeArgumentError = undefined; - resultOfFailedInference = undefined; - result = chooseOverload(candidates, assignableRelation); - } - if (result) { - return result; - } - if (candidateForArgumentError) { - checkApplicableSignature(node, args, candidateForArgumentError, assignableRelation, undefined, true); - } - else if (candidateForTypeArgumentError) { - if (!isTaggedTemplate && !isDecorator && typeArguments) { - checkTypeArguments(candidateForTypeArgumentError, node.typeArguments, [], true, headMessage); - } - else { - ts.Debug.assert(resultOfFailedInference.failedTypeParameterIndex >= 0); - var failedTypeParameter = candidateForTypeArgumentError.typeParameters[resultOfFailedInference.failedTypeParameterIndex]; - var inferenceCandidates = getInferenceCandidates(resultOfFailedInference, resultOfFailedInference.failedTypeParameterIndex); - var diagnosticChainHead = ts.chainDiagnosticMessages(undefined, ts.Diagnostics.The_type_argument_for_type_parameter_0_cannot_be_inferred_from_the_usage_Consider_specifying_the_type_arguments_explicitly, typeToString(failedTypeParameter)); - if (headMessage) { - diagnosticChainHead = ts.chainDiagnosticMessages(diagnosticChainHead, headMessage); - } - reportNoCommonSupertypeError(inferenceCandidates, node.expression || node.tag, diagnosticChainHead); - } - } - else { - reportError(ts.Diagnostics.Supplied_parameters_do_not_match_any_signature_of_call_target); - } - if (!produceDiagnostics) { - for (var _i = 0; _i < candidates.length; _i++) { - var candidate = candidates[_i]; - if (hasCorrectArity(node, args, candidate)) { - if (candidate.typeParameters && typeArguments) { - candidate = getSignatureInstantiation(candidate, ts.map(typeArguments, getTypeFromTypeNode)); - } - return candidate; - } - } - } - return resolveErrorCall(node); - function reportError(message, arg0, arg1, arg2) { - var errorInfo; - errorInfo = ts.chainDiagnosticMessages(errorInfo, message, arg0, arg1, arg2); - if (headMessage) { - errorInfo = ts.chainDiagnosticMessages(errorInfo, headMessage); - } - diagnostics.add(ts.createDiagnosticForNodeFromMessageChain(node, errorInfo)); - } - function chooseOverload(candidates, relation) { - for (var _i = 0; _i < candidates.length; _i++) { - var originalCandidate = candidates[_i]; - if (!hasCorrectArity(node, args, originalCandidate)) { - continue; - } - var candidate = void 0; - var typeArgumentsAreValid = void 0; - var inferenceContext = originalCandidate.typeParameters - ? createInferenceContext(originalCandidate.typeParameters, false) - : undefined; - while (true) { - candidate = originalCandidate; - if (candidate.typeParameters) { - var typeArgumentTypes = void 0; - if (typeArguments) { - typeArgumentTypes = new Array(candidate.typeParameters.length); - typeArgumentsAreValid = checkTypeArguments(candidate, typeArguments, typeArgumentTypes, false); - } - else { - inferTypeArguments(node, candidate, args, excludeArgument, inferenceContext); - typeArgumentsAreValid = inferenceContext.failedTypeParameterIndex === undefined; - typeArgumentTypes = inferenceContext.inferredTypes; - } - if (!typeArgumentsAreValid) { - break; - } - candidate = getSignatureInstantiation(candidate, typeArgumentTypes); - } - if (!checkApplicableSignature(node, args, candidate, relation, excludeArgument, false)) { - break; - } - var index = excludeArgument ? ts.indexOf(excludeArgument, true) : -1; - if (index < 0) { - return candidate; - } - excludeArgument[index] = false; - } - if (originalCandidate.typeParameters) { - var instantiatedCandidate = candidate; - if (typeArgumentsAreValid) { - candidateForArgumentError = instantiatedCandidate; - } - else { - candidateForTypeArgumentError = originalCandidate; - if (!typeArguments) { - resultOfFailedInference = inferenceContext; - } - } - } - else { - ts.Debug.assert(originalCandidate === candidate); - candidateForArgumentError = originalCandidate; - } - } - return undefined; - } - } - function resolveCallExpression(node, candidatesOutArray) { - if (node.expression.kind === 95) { - var superType = checkSuperExpression(node.expression); - if (superType !== unknownType) { - var baseTypeNode = ts.getClassExtendsHeritageClauseElement(ts.getContainingClass(node)); - var baseConstructors = getInstantiatedConstructorsForTypeArguments(superType, baseTypeNode.typeArguments); - return resolveCall(node, baseConstructors, candidatesOutArray); - } - return resolveUntypedCall(node); - } - var funcType = checkExpression(node.expression); - var apparentType = getApparentType(funcType); - if (apparentType === unknownType) { - return resolveErrorCall(node); - } - var callSignatures = getSignaturesOfType(apparentType, 0); - var constructSignatures = getSignaturesOfType(apparentType, 1); - if (isTypeAny(funcType) || (!callSignatures.length && !constructSignatures.length && !(funcType.flags & 16384) && isTypeAssignableTo(funcType, globalFunctionType))) { - if (funcType !== unknownType && node.typeArguments) { - error(node, ts.Diagnostics.Untyped_function_calls_may_not_accept_type_arguments); - } - return resolveUntypedCall(node); - } - if (!callSignatures.length) { - if (constructSignatures.length) { - error(node, ts.Diagnostics.Value_of_type_0_is_not_callable_Did_you_mean_to_include_new, typeToString(funcType)); - } - else { - error(node, ts.Diagnostics.Cannot_invoke_an_expression_whose_type_lacks_a_call_signature); - } - return resolveErrorCall(node); - } - return resolveCall(node, callSignatures, candidatesOutArray); - } - function resolveNewExpression(node, candidatesOutArray) { - if (node.arguments && languageVersion < 1) { - var spreadIndex = getSpreadArgumentIndex(node.arguments); - if (spreadIndex >= 0) { - error(node.arguments[spreadIndex], ts.Diagnostics.Spread_operator_in_new_expressions_is_only_available_when_targeting_ECMAScript_5_and_higher); - } - } - var expressionType = checkExpression(node.expression); - expressionType = getApparentType(expressionType); - if (expressionType === unknownType) { - return resolveErrorCall(node); - } - var valueDecl = expressionType.symbol && getClassLikeDeclarationOfSymbol(expressionType.symbol); - if (valueDecl && valueDecl.flags & 256) { - error(node, ts.Diagnostics.Cannot_create_an_instance_of_the_abstract_class_0, ts.declarationNameToString(valueDecl.name)); - return resolveErrorCall(node); - } - if (isTypeAny(expressionType)) { - if (node.typeArguments) { - error(node, ts.Diagnostics.Untyped_function_calls_may_not_accept_type_arguments); - } - return resolveUntypedCall(node); - } - var constructSignatures = getSignaturesOfType(expressionType, 1); - if (constructSignatures.length) { - return resolveCall(node, constructSignatures, candidatesOutArray); - } - var callSignatures = getSignaturesOfType(expressionType, 0); - if (callSignatures.length) { - var signature = resolveCall(node, callSignatures, candidatesOutArray); - if (getReturnTypeOfSignature(signature) !== voidType) { - error(node, ts.Diagnostics.Only_a_void_function_can_be_called_with_the_new_keyword); - } - return signature; - } - error(node, ts.Diagnostics.Cannot_use_new_with_an_expression_whose_type_lacks_a_call_or_construct_signature); - return resolveErrorCall(node); - } - function resolveTaggedTemplateExpression(node, candidatesOutArray) { - var tagType = checkExpression(node.tag); - var apparentType = getApparentType(tagType); - if (apparentType === unknownType) { - return resolveErrorCall(node); - } - var callSignatures = getSignaturesOfType(apparentType, 0); - if (isTypeAny(tagType) || (!callSignatures.length && !(tagType.flags & 16384) && isTypeAssignableTo(tagType, globalFunctionType))) { - return resolveUntypedCall(node); - } - if (!callSignatures.length) { - error(node, ts.Diagnostics.Cannot_invoke_an_expression_whose_type_lacks_a_call_signature); - return resolveErrorCall(node); - } - return resolveCall(node, callSignatures, candidatesOutArray); - } - function getDiagnosticHeadMessageForDecoratorResolution(node) { - switch (node.parent.kind) { - case 214: - case 186: - return ts.Diagnostics.Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression; - case 138: - return ts.Diagnostics.Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression; - case 141: - return ts.Diagnostics.Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression; - case 143: - case 145: - case 146: - return ts.Diagnostics.Unable_to_resolve_signature_of_method_decorator_when_called_as_an_expression; - } - } - function resolveDecorator(node, candidatesOutArray) { - var funcType = checkExpression(node.expression); - var apparentType = getApparentType(funcType); - if (apparentType === unknownType) { - return resolveErrorCall(node); - } - var callSignatures = getSignaturesOfType(apparentType, 0); - if (funcType === anyType || (!callSignatures.length && !(funcType.flags & 16384) && isTypeAssignableTo(funcType, globalFunctionType))) { - return resolveUntypedCall(node); - } - var headMessage = getDiagnosticHeadMessageForDecoratorResolution(node); - if (!callSignatures.length) { - var errorInfo; - errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.Cannot_invoke_an_expression_whose_type_lacks_a_call_signature); - errorInfo = ts.chainDiagnosticMessages(errorInfo, headMessage); - diagnostics.add(ts.createDiagnosticForNodeFromMessageChain(node, errorInfo)); - return resolveErrorCall(node); - } - return resolveCall(node, callSignatures, candidatesOutArray, headMessage); - } - function getResolvedSignature(node, candidatesOutArray) { - var links = getNodeLinks(node); - if (!links.resolvedSignature || candidatesOutArray) { - links.resolvedSignature = anySignature; - if (node.kind === 168) { - links.resolvedSignature = resolveCallExpression(node, candidatesOutArray); - } - else if (node.kind === 169) { - links.resolvedSignature = resolveNewExpression(node, candidatesOutArray); - } - else if (node.kind === 170) { - links.resolvedSignature = resolveTaggedTemplateExpression(node, candidatesOutArray); - } - else if (node.kind === 139) { - links.resolvedSignature = resolveDecorator(node, candidatesOutArray); - } - else { - ts.Debug.fail("Branch in 'getResolvedSignature' should be unreachable."); - } - } - return links.resolvedSignature; - } - function checkCallExpression(node) { - checkGrammarTypeArguments(node, node.typeArguments) || checkGrammarArguments(node, node.arguments); - var signature = getResolvedSignature(node); - if (node.expression.kind === 95) { - return voidType; - } - if (node.kind === 169) { - var declaration = signature.declaration; - if (declaration && - declaration.kind !== 144 && - declaration.kind !== 148 && - declaration.kind !== 153) { - if (compilerOptions.noImplicitAny) { - error(node, ts.Diagnostics.new_expression_whose_target_lacks_a_construct_signature_implicitly_has_an_any_type); - } - return anyType; - } - } - return getReturnTypeOfSignature(signature); - } - function checkTaggedTemplateExpression(node) { - return getReturnTypeOfSignature(getResolvedSignature(node)); - } - function checkAssertion(node) { - var exprType = getRegularTypeOfObjectLiteral(checkExpression(node.expression)); - var targetType = getTypeFromTypeNode(node.type); - if (produceDiagnostics && targetType !== unknownType) { - var widenedType = getWidenedType(exprType); - if (!(isTypeAssignableTo(targetType, widenedType))) { - checkTypeAssignableTo(exprType, targetType, node, ts.Diagnostics.Neither_type_0_nor_type_1_is_assignable_to_the_other); - } - } - return targetType; - } - function getTypeAtPosition(signature, pos) { - return signature.hasRestParameter ? - pos < signature.parameters.length - 1 ? getTypeOfSymbol(signature.parameters[pos]) : getRestTypeOfSignature(signature) : - pos < signature.parameters.length ? getTypeOfSymbol(signature.parameters[pos]) : anyType; - } - function assignContextualParameterTypes(signature, context, mapper) { - var len = signature.parameters.length - (signature.hasRestParameter ? 1 : 0); - for (var i = 0; i < len; i++) { - var parameter = signature.parameters[i]; - 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); - } - } - function assignBindingElementTypes(node) { - if (ts.isBindingPattern(node.name)) { - for (var _i = 0, _a = node.name.elements; _i < _a.length; _i++) { - var element = _a[_i]; - if (element.kind !== 187) { - getSymbolLinks(getSymbolOfNode(element)).type = getTypeForBindingElement(element); - assignBindingElementTypes(element); - } - } - } - } - function assignTypeToParameterAndFixTypeParameters(parameter, contextualType, mapper) { - var links = getSymbolLinks(parameter); - if (!links.type) { - links.type = instantiateType(contextualType, mapper); - assignBindingElementTypes(parameter.valueDeclaration); - } - else if (isInferentialContext(mapper)) { - inferTypes(mapper.context, links.type, instantiateType(contextualType, mapper)); - } - } - function createPromiseType(promisedType) { - var globalPromiseType = getGlobalPromiseType(); - if (globalPromiseType !== emptyGenericType) { - promisedType = getAwaitedType(promisedType); - return createTypeReference(globalPromiseType, [promisedType]); - } - return emptyObjectType; - } - function getReturnTypeFromBody(func, contextualMapper) { - var contextualSignature = getContextualSignatureForFunctionLikeDeclaration(func); - if (!func.body) { - return unknownType; - } - var isAsync = ts.isAsyncFunctionLike(func); - var type; - if (func.body.kind !== 192) { - type = checkExpressionCached(func.body, contextualMapper); - if (isAsync) { - type = checkAwaitedType(type, func, ts.Diagnostics.Return_expression_in_async_function_does_not_have_a_valid_callable_then_member); - } - } - else { - var types; - var funcIsGenerator = !!func.asteriskToken; - if (funcIsGenerator) { - types = checkAndAggregateYieldOperandTypes(func.body, contextualMapper); - if (types.length === 0) { - var iterableIteratorAny = createIterableIteratorType(anyType); - if (compilerOptions.noImplicitAny) { - error(func.asteriskToken, ts.Diagnostics.Generator_implicitly_has_type_0_because_it_does_not_yield_any_values_Consider_supplying_a_return_type, typeToString(iterableIteratorAny)); - } - return iterableIteratorAny; - } - } - else { - types = checkAndAggregateReturnExpressionTypes(func.body, contextualMapper, isAsync); - if (types.length === 0) { - if (isAsync) { - var promiseType = createPromiseType(voidType); - if (promiseType === emptyObjectType) { - error(func, ts.Diagnostics.An_async_function_or_method_must_have_a_valid_awaitable_return_type); - return unknownType; - } - return promiseType; - } - else { - return voidType; - } - } - } - type = contextualSignature ? getUnionType(types) : getCommonSupertype(types); - if (!type) { - if (funcIsGenerator) { - error(func, ts.Diagnostics.No_best_common_type_exists_among_yield_expressions); - return createIterableIteratorType(unknownType); - } - else { - error(func, ts.Diagnostics.No_best_common_type_exists_among_return_expressions); - return unknownType; - } - } - if (funcIsGenerator) { - type = createIterableIteratorType(type); - } - } - if (!contextualSignature) { - reportErrorsFromWidening(func, type); - } - var widenedType = getWidenedType(type); - if (isAsync) { - var promiseType = createPromiseType(widenedType); - if (promiseType === emptyObjectType) { - error(func, ts.Diagnostics.An_async_function_or_method_must_have_a_valid_awaitable_return_type); - return unknownType; - } - return promiseType; - } - else { - return widenedType; - } - } - function checkAndAggregateYieldOperandTypes(body, contextualMapper) { - var aggregatedTypes = []; - ts.forEachYieldExpression(body, function (yieldExpression) { - var expr = yieldExpression.expression; - if (expr) { - var type = checkExpressionCached(expr, contextualMapper); - if (yieldExpression.asteriskToken) { - type = checkElementTypeOfIterable(type, yieldExpression.expression); - } - if (!ts.contains(aggregatedTypes, type)) { - aggregatedTypes.push(type); - } - } - }); - return aggregatedTypes; - } - function checkAndAggregateReturnExpressionTypes(body, contextualMapper, isAsync) { - var aggregatedTypes = []; - ts.forEachReturnStatement(body, function (returnStatement) { - var expr = returnStatement.expression; - if (expr) { - var type = checkExpressionCached(expr, contextualMapper); - if (isAsync) { - type = checkAwaitedType(type, body.parent, ts.Diagnostics.Return_expression_in_async_function_does_not_have_a_valid_callable_then_member); - } - if (!ts.contains(aggregatedTypes, type)) { - aggregatedTypes.push(type); - } - } - }); - return aggregatedTypes; - } - function bodyContainsAReturnStatement(funcBody) { - return ts.forEachReturnStatement(funcBody, function (returnStatement) { - return true; - }); - } - function bodyContainsSingleThrowStatement(body) { - return (body.statements.length === 1) && (body.statements[0].kind === 208); - } - function checkIfNonVoidFunctionHasReturnExpressionsOrSingleThrowStatment(func, returnType) { - if (!produceDiagnostics) { - return; - } - if (returnType === voidType || isTypeAny(returnType)) { - return; - } - if (ts.nodeIsMissing(func.body) || func.body.kind !== 192) { - return; - } - var bodyBlock = func.body; - if (bodyContainsAReturnStatement(bodyBlock)) { - return; - } - if (bodyContainsSingleThrowStatement(bodyBlock)) { - return; - } - error(func.type, ts.Diagnostics.A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value_or_consist_of_a_single_throw_statement); - } - function checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper) { - ts.Debug.assert(node.kind !== 143 || ts.isObjectLiteralMethod(node)); - var hasGrammarError = checkGrammarFunctionLikeDeclaration(node); - if (!hasGrammarError && node.kind === 173) { - checkGrammarForGenerator(node); - } - if (contextualMapper === identityMapper && isContextSensitive(node)) { - return anyFunctionType; - } - var isAsync = ts.isAsyncFunctionLike(node); - if (isAsync) { - emitAwaiter = true; - } - var links = getNodeLinks(node); - var type = getTypeOfSymbol(node.symbol); - var contextSensitive = isContextSensitive(node); - var mightFixTypeParameters = contextSensitive && isInferentialContext(contextualMapper); - if (mightFixTypeParameters || !(links.flags & 1024)) { - var contextualSignature = getContextualSignature(node); - var contextChecked = !!(links.flags & 1024); - if (mightFixTypeParameters || !contextChecked) { - links.flags |= 1024; - if (contextualSignature) { - var signature = getSignaturesOfType(type, 0)[0]; - if (contextSensitive) { - assignContextualParameterTypes(signature, contextualSignature, contextualMapper || identityMapper); - } - if (mightFixTypeParameters || !node.type && !signature.resolvedReturnType) { - var returnType = getReturnTypeFromBody(node, contextualMapper); - if (!signature.resolvedReturnType) { - signature.resolvedReturnType = returnType; - } - } - } - if (!contextChecked) { - checkSignatureDeclaration(node); - } - } - } - if (produceDiagnostics && node.kind !== 143 && node.kind !== 142) { - checkCollisionWithCapturedSuperVariable(node, node.name); - checkCollisionWithCapturedThisVariable(node, node.name); - } - return type; - } - function checkFunctionExpressionOrObjectLiteralMethodBody(node) { - ts.Debug.assert(node.kind !== 143 || ts.isObjectLiteralMethod(node)); - var isAsync = ts.isAsyncFunctionLike(node); - if (isAsync) { - emitAwaiter = true; - } - var returnType = node.type && getTypeFromTypeNode(node.type); - var promisedType; - if (returnType && isAsync) { - promisedType = checkAsyncFunctionReturnType(node); - } - if (returnType && !node.asteriskToken) { - checkIfNonVoidFunctionHasReturnExpressionsOrSingleThrowStatment(node, isAsync ? promisedType : returnType); - } - if (node.body) { - if (!node.type) { - getReturnTypeOfSignature(getSignatureFromDeclaration(node)); - } - if (node.body.kind === 192) { - checkSourceElement(node.body); - } - else { - var exprType = checkExpression(node.body); - if (returnType) { - if (isAsync) { - var awaitedType = checkAwaitedType(exprType, node.body, ts.Diagnostics.Expression_body_for_async_arrow_function_does_not_have_a_valid_callable_then_member); - checkTypeAssignableTo(awaitedType, promisedType, node.body); - } - else { - checkTypeAssignableTo(exprType, returnType, node.body); - } - } - checkFunctionAndClassExpressionBodies(node.body); - } - } - } - function checkArithmeticOperandType(operand, type, diagnostic) { - if (!isTypeAnyOrAllConstituentTypesHaveKind(type, 132)) { - error(operand, diagnostic); - return false; - } - return true; - } - function checkReferenceExpression(n, invalidReferenceMessage, constantVariableMessage) { - function findSymbol(n) { - var symbol = getNodeLinks(n).resolvedSymbol; - return symbol && getExportSymbolOfValueSymbolIfExported(symbol); - } - function isReferenceOrErrorExpression(n) { - switch (n.kind) { - case 69: { - var symbol = findSymbol(n); - return !symbol || symbol === unknownSymbol || symbol === argumentsSymbol || (symbol.flags & 3) !== 0; - } - case 166: { - var symbol = findSymbol(n); - return !symbol || symbol === unknownSymbol || (symbol.flags & ~8) !== 0; - } - case 167: - return true; - case 172: - return isReferenceOrErrorExpression(n.expression); - default: - return false; - } - } - function isConstVariableReference(n) { - switch (n.kind) { - case 69: - case 166: { - var symbol = findSymbol(n); - return symbol && (symbol.flags & 3) !== 0 && (getDeclarationFlagsFromSymbol(symbol) & 32768) !== 0; - } - case 167: { - var index = n.argumentExpression; - var symbol = findSymbol(n.expression); - if (symbol && index && index.kind === 9) { - var name_13 = index.text; - var prop = getPropertyOfType(getTypeOfSymbol(symbol), name_13); - return prop && (prop.flags & 3) !== 0 && (getDeclarationFlagsFromSymbol(prop) & 32768) !== 0; - } - return false; - } - case 172: - return isConstVariableReference(n.expression); - default: - return false; - } - } - if (!isReferenceOrErrorExpression(n)) { - error(n, invalidReferenceMessage); - return false; - } - if (isConstVariableReference(n)) { - error(n, constantVariableMessage); - return false; - } - return true; - } - function checkDeleteExpression(node) { - checkExpression(node.expression); - return booleanType; - } - function checkTypeOfExpression(node) { - checkExpression(node.expression); - return stringType; - } - function checkVoidExpression(node) { - checkExpression(node.expression); - return undefinedType; - } - function checkAwaitExpression(node) { - if (produceDiagnostics) { - if (!(node.parserContextFlags & 8)) { - grammarErrorOnFirstToken(node, ts.Diagnostics.await_expression_is_only_allowed_within_an_async_function); - } - if (isInParameterInitializerBeforeContainingFunction(node)) { - error(node, ts.Diagnostics.await_expressions_cannot_be_used_in_a_parameter_initializer); - } - } - var operandType = checkExpression(node.expression); - return checkAwaitedType(operandType, node); - } - function checkPrefixUnaryExpression(node) { - var operandType = checkExpression(node.operand); - switch (node.operator) { - case 35: - case 36: - case 50: - if (someConstituentTypeHasKind(operandType, 16777216)) { - error(node.operand, ts.Diagnostics.The_0_operator_cannot_be_applied_to_type_symbol, ts.tokenToString(node.operator)); - } - return numberType; - case 49: - return booleanType; - case 41: - case 42: - var ok = checkArithmeticOperandType(node.operand, operandType, ts.Diagnostics.An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type); - if (ok) { - checkReferenceExpression(node.operand, ts.Diagnostics.The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_property_or_indexer, ts.Diagnostics.The_operand_of_an_increment_or_decrement_operator_cannot_be_a_constant); - } - return numberType; - } - return unknownType; - } - function checkPostfixUnaryExpression(node) { - var operandType = checkExpression(node.operand); - var ok = checkArithmeticOperandType(node.operand, operandType, ts.Diagnostics.An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type); - if (ok) { - checkReferenceExpression(node.operand, ts.Diagnostics.The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_property_or_indexer, ts.Diagnostics.The_operand_of_an_increment_or_decrement_operator_cannot_be_a_constant); - } - return numberType; - } - function someConstituentTypeHasKind(type, kind) { - if (type.flags & kind) { - return true; - } - if (type.flags & 49152) { - var types = type.types; - for (var _i = 0; _i < types.length; _i++) { - var current = types[_i]; - if (current.flags & kind) { - return true; - } - } - return false; - } - return false; - } - function allConstituentTypesHaveKind(type, kind) { - if (type.flags & kind) { - return true; - } - if (type.flags & 49152) { - var types = type.types; - for (var _i = 0; _i < types.length; _i++) { - var current = types[_i]; - if (!(current.flags & kind)) { - return false; - } - } - return true; - } - return false; - } - function isConstEnumObjectType(type) { - return type.flags & (80896 | 65536) && type.symbol && isConstEnumSymbol(type.symbol); - } - function isConstEnumSymbol(symbol) { - return (symbol.flags & 128) !== 0; - } - function checkInstanceOfExpression(left, right, leftType, rightType) { - if (allConstituentTypesHaveKind(leftType, 16777726)) { - error(left, ts.Diagnostics.The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_parameter); - } - if (!(isTypeAny(rightType) || isTypeSubtypeOf(rightType, globalFunctionType))) { - error(right, ts.Diagnostics.The_right_hand_side_of_an_instanceof_expression_must_be_of_type_any_or_of_a_type_assignable_to_the_Function_interface_type); - } - return booleanType; - } - function checkInExpression(left, right, leftType, rightType) { - if (!isTypeAnyOrAllConstituentTypesHaveKind(leftType, 258 | 132 | 16777216)) { - error(left, ts.Diagnostics.The_left_hand_side_of_an_in_expression_must_be_of_type_any_string_number_or_symbol); - } - if (!isTypeAnyOrAllConstituentTypesHaveKind(rightType, 80896 | 512)) { - error(right, ts.Diagnostics.The_right_hand_side_of_an_in_expression_must_be_of_type_any_an_object_type_or_a_type_parameter); - } - return booleanType; - } - function checkObjectLiteralAssignment(node, sourceType, contextualMapper) { - var properties = node.properties; - for (var _i = 0; _i < properties.length; _i++) { - var p = properties[_i]; - if (p.kind === 245 || p.kind === 246) { - var name_14 = p.name; - var type = isTypeAny(sourceType) - ? sourceType - : getTypeOfPropertyOfType(sourceType, name_14.text) || - isNumericLiteralName(name_14.text) && getIndexTypeOfType(sourceType, 1) || - getIndexTypeOfType(sourceType, 0); - if (type) { - if (p.kind === 246) { - checkDestructuringAssignment(p, type); - } - else { - checkDestructuringAssignment(p.initializer || name_14, type); - } - } - else { - error(name_14, ts.Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(sourceType), ts.declarationNameToString(name_14)); - } - } - else { - error(p, ts.Diagnostics.Property_assignment_expected); - } - } - return sourceType; - } - function checkArrayLiteralAssignment(node, sourceType, contextualMapper) { - var elementType = checkIteratedTypeOrElementType(sourceType, node, false) || unknownType; - var elements = node.elements; - for (var i = 0; i < elements.length; i++) { - var e = elements[i]; - if (e.kind !== 187) { - if (e.kind !== 185) { - var propName = "" + i; - var type = isTypeAny(sourceType) - ? sourceType - : isTupleLikeType(sourceType) - ? getTypeOfPropertyOfType(sourceType, propName) - : elementType; - if (type) { - checkDestructuringAssignment(e, type, contextualMapper); - } - else { - if (isTupleType(sourceType)) { - error(e, ts.Diagnostics.Tuple_type_0_with_length_1_cannot_be_assigned_to_tuple_with_length_2, typeToString(sourceType), sourceType.elementTypes.length, elements.length); - } - else { - error(e, ts.Diagnostics.Type_0_has_no_property_1, typeToString(sourceType), propName); - } - } - } - else { - if (i < elements.length - 1) { - error(e, ts.Diagnostics.A_rest_element_must_be_last_in_an_array_destructuring_pattern); - } - else { - var restExpression = e.expression; - if (restExpression.kind === 181 && restExpression.operatorToken.kind === 56) { - error(restExpression.operatorToken, ts.Diagnostics.A_rest_element_cannot_have_an_initializer); - } - else { - checkDestructuringAssignment(restExpression, createArrayType(elementType), contextualMapper); - } - } - } - } - } - return sourceType; - } - function checkDestructuringAssignment(exprOrAssignment, sourceType, contextualMapper) { - var target; - if (exprOrAssignment.kind === 246) { - var prop = exprOrAssignment; - if (prop.objectAssignmentInitializer) { - checkBinaryLikeExpression(prop.name, prop.equalsToken, prop.objectAssignmentInitializer, contextualMapper); - } - target = exprOrAssignment.name; - } - else { - target = exprOrAssignment; - } - if (target.kind === 181 && target.operatorToken.kind === 56) { - checkBinaryExpression(target, contextualMapper); - target = target.left; - } - if (target.kind === 165) { - return checkObjectLiteralAssignment(target, sourceType, contextualMapper); - } - if (target.kind === 164) { - return checkArrayLiteralAssignment(target, sourceType, contextualMapper); - } - return checkReferenceAssignment(target, sourceType, contextualMapper); - } - function checkReferenceAssignment(target, sourceType, contextualMapper) { - var targetType = checkExpression(target, contextualMapper); - if (checkReferenceExpression(target, ts.Diagnostics.Invalid_left_hand_side_of_assignment_expression, ts.Diagnostics.Left_hand_side_of_assignment_expression_cannot_be_a_constant)) { - checkTypeAssignableTo(sourceType, targetType, target, undefined); - } - return sourceType; - } - function checkBinaryExpression(node, contextualMapper) { - return checkBinaryLikeExpression(node.left, node.operatorToken, node.right, contextualMapper, node); - } - function checkBinaryLikeExpression(left, operatorToken, right, contextualMapper, errorNode) { - var operator = operatorToken.kind; - if (operator === 56 && (left.kind === 165 || left.kind === 164)) { - return checkDestructuringAssignment(left, checkExpression(right, contextualMapper), contextualMapper); - } - var leftType = checkExpression(left, contextualMapper); - var rightType = checkExpression(right, contextualMapper); - switch (operator) { - case 37: - case 38: - case 59: - case 60: - case 39: - case 61: - case 40: - case 62: - case 36: - case 58: - case 43: - case 63: - case 44: - case 64: - case 45: - case 65: - case 47: - case 67: - case 48: - case 68: - case 46: - case 66: - if (leftType.flags & (32 | 64)) - leftType = rightType; - if (rightType.flags & (32 | 64)) - rightType = leftType; - var suggestedOperator; - if ((leftType.flags & 8) && - (rightType.flags & 8) && - (suggestedOperator = getSuggestedBooleanOperator(operatorToken.kind)) !== undefined) { - error(errorNode || operatorToken, ts.Diagnostics.The_0_operator_is_not_allowed_for_boolean_types_Consider_using_1_instead, ts.tokenToString(operatorToken.kind), ts.tokenToString(suggestedOperator)); - } - else { - var leftOk = checkArithmeticOperandType(left, leftType, ts.Diagnostics.The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type); - var rightOk = checkArithmeticOperandType(right, rightType, ts.Diagnostics.The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type); - if (leftOk && rightOk) { - checkAssignmentOperator(numberType); - } - } - return numberType; - case 35: - case 57: - if (leftType.flags & (32 | 64)) - leftType = rightType; - if (rightType.flags & (32 | 64)) - rightType = leftType; - var resultType; - if (allConstituentTypesHaveKind(leftType, 132) && allConstituentTypesHaveKind(rightType, 132)) { - resultType = numberType; - } - else { - if (allConstituentTypesHaveKind(leftType, 258) || allConstituentTypesHaveKind(rightType, 258)) { - resultType = stringType; - } - else if (isTypeAny(leftType) || isTypeAny(rightType)) { - resultType = leftType === unknownType || rightType === unknownType ? unknownType : anyType; - } - if (resultType && !checkForDisallowedESSymbolOperand(operator)) { - return resultType; - } - } - if (!resultType) { - reportOperatorError(); - return anyType; - } - if (operator === 57) { - checkAssignmentOperator(resultType); - } - return resultType; - case 25: - case 27: - case 28: - case 29: - if (!checkForDisallowedESSymbolOperand(operator)) { - return booleanType; - } - case 30: - case 31: - case 32: - case 33: - if (!isTypeAssignableTo(leftType, rightType) && !isTypeAssignableTo(rightType, leftType)) { - reportOperatorError(); - } - return booleanType; - case 91: - return checkInstanceOfExpression(left, right, leftType, rightType); - case 90: - return checkInExpression(left, right, leftType, rightType); - case 51: - return rightType; - case 52: - return getUnionType([leftType, rightType]); - case 56: - checkAssignmentOperator(rightType); - return getRegularTypeOfObjectLiteral(rightType); - case 24: - return rightType; - } - function checkForDisallowedESSymbolOperand(operator) { - var offendingSymbolOperand = someConstituentTypeHasKind(leftType, 16777216) ? left : - someConstituentTypeHasKind(rightType, 16777216) ? right : - undefined; - if (offendingSymbolOperand) { - error(offendingSymbolOperand, ts.Diagnostics.The_0_operator_cannot_be_applied_to_type_symbol, ts.tokenToString(operator)); - return false; - } - return true; - } - function getSuggestedBooleanOperator(operator) { - switch (operator) { - 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) { - var ok = checkReferenceExpression(left, ts.Diagnostics.Invalid_left_hand_side_of_assignment_expression, ts.Diagnostics.Left_hand_side_of_assignment_expression_cannot_be_a_constant); - if (ok) { - checkTypeAssignableTo(valueType, leftType, left, undefined); - } - } - } - function reportOperatorError() { - error(errorNode || operatorToken, ts.Diagnostics.Operator_0_cannot_be_applied_to_types_1_and_2, ts.tokenToString(operatorToken.kind), typeToString(leftType), typeToString(rightType)); - } - } - function isYieldExpressionInClass(node) { - var current = node; - var parent = node.parent; - while (parent) { - if (ts.isFunctionLike(parent) && current === parent.body) { - return false; - } - else if (ts.isClassLike(current)) { - return true; - } - current = parent; - parent = parent.parent; - } - return false; - } - function checkYieldExpression(node) { - if (produceDiagnostics) { - if (!(node.parserContextFlags & 2) || isYieldExpressionInClass(node)) { - grammarErrorOnFirstToken(node, ts.Diagnostics.A_yield_expression_is_only_allowed_in_a_generator_body); - } - if (isInParameterInitializerBeforeContainingFunction(node)) { - error(node, ts.Diagnostics.yield_expressions_cannot_be_used_in_a_parameter_initializer); - } - } - if (node.expression) { - var func = ts.getContainingFunction(node); - if (func && func.asteriskToken) { - var expressionType = checkExpressionCached(node.expression, undefined); - var expressionElementType; - var nodeIsYieldStar = !!node.asteriskToken; - if (nodeIsYieldStar) { - expressionElementType = checkElementTypeOfIterable(expressionType, node.expression); - } - if (func.type) { - var signatureElementType = getElementTypeOfIterableIterator(getTypeFromTypeNode(func.type)) || anyType; - if (nodeIsYieldStar) { - checkTypeAssignableTo(expressionElementType, signatureElementType, node.expression, undefined); - } - else { - checkTypeAssignableTo(expressionType, signatureElementType, node.expression, undefined); - } - } - } - } - return anyType; - } - function checkConditionalExpression(node, contextualMapper) { - checkExpression(node.condition); - var type1 = checkExpression(node.whenTrue, contextualMapper); - var type2 = checkExpression(node.whenFalse, contextualMapper); - return getUnionType([type1, type2]); - } - function checkTemplateExpression(node) { - ts.forEach(node.templateSpans, function (templateSpan) { - checkExpression(templateSpan.expression); - }); - return stringType; - } - function checkExpressionWithContextualType(node, contextualType, contextualMapper) { - var saveContextualType = node.contextualType; - node.contextualType = contextualType; - var result = checkExpression(node, contextualMapper); - node.contextualType = saveContextualType; - return result; - } - function checkExpressionCached(node, contextualMapper) { - var links = getNodeLinks(node); - if (!links.resolvedType) { - links.resolvedType = checkExpression(node, contextualMapper); - } - return links.resolvedType; - } - function checkPropertyAssignment(node, contextualMapper) { - if (node.name.kind === 136) { - checkComputedPropertyName(node.name); - } - return checkExpression(node.initializer, contextualMapper); - } - function checkObjectLiteralMethod(node, contextualMapper) { - checkGrammarMethod(node); - if (node.name.kind === 136) { - checkComputedPropertyName(node.name); - } - var uninstantiatedType = checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); - return instantiateTypeWithSingleGenericCallSignature(node, uninstantiatedType, contextualMapper); - } - function instantiateTypeWithSingleGenericCallSignature(node, type, contextualMapper) { - if (isInferentialContext(contextualMapper)) { - var signature = getSingleCallSignature(type); - if (signature && signature.typeParameters) { - var contextualType = getContextualType(node); - if (contextualType) { - var contextualSignature = getSingleCallSignature(contextualType); - if (contextualSignature && !contextualSignature.typeParameters) { - return getOrCreateTypeFromSignature(instantiateSignatureInContextOf(signature, contextualSignature, contextualMapper)); - } - } - } - } - return type; - } - function checkExpression(node, contextualMapper) { - var type; - if (node.kind === 135) { - type = checkQualifiedName(node); - } - else { - var uninstantiatedType = checkExpressionWorker(node, contextualMapper); - type = instantiateTypeWithSingleGenericCallSignature(node, uninstantiatedType, contextualMapper); - } - if (isConstEnumObjectType(type)) { - var ok = (node.parent.kind === 166 && node.parent.expression === node) || - (node.parent.kind === 167 && node.parent.expression === node) || - ((node.kind === 69 || node.kind === 135) && isInRightSideOfImportOrExportAssignment(node)); - if (!ok) { - error(node, ts.Diagnostics.const_enums_can_only_be_used_in_property_or_index_access_expressions_or_the_right_hand_side_of_an_import_declaration_or_export_assignment); - } - } - return type; - } - function checkNumericLiteral(node) { - checkGrammarNumericLiteral(node); - return numberType; - } - function checkExpressionWorker(node, contextualMapper) { - switch (node.kind) { - case 69: - return checkIdentifier(node); - case 97: - return checkThisExpression(node); - case 95: - return checkSuperExpression(node); - case 93: - return nullType; - case 99: - case 84: - return booleanType; - case 8: - return checkNumericLiteral(node); - case 183: - return checkTemplateExpression(node); - case 9: - case 11: - return stringType; - case 10: - return globalRegExpType; - case 164: - return checkArrayLiteral(node, contextualMapper); - case 165: - return checkObjectLiteral(node, contextualMapper); - case 166: - return checkPropertyAccessExpression(node); - case 167: - return checkIndexedAccess(node); - case 168: - case 169: - return checkCallExpression(node); - case 170: - return checkTaggedTemplateExpression(node); - case 172: - return checkExpression(node.expression, contextualMapper); - case 186: - return checkClassExpression(node); - case 173: - case 174: - return checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); - case 176: - return checkTypeOfExpression(node); - case 171: - case 189: - return checkAssertion(node); - case 175: - return checkDeleteExpression(node); - case 177: - return checkVoidExpression(node); - case 178: - return checkAwaitExpression(node); - case 179: - return checkPrefixUnaryExpression(node); - case 180: - return checkPostfixUnaryExpression(node); - case 181: - return checkBinaryExpression(node, contextualMapper); - case 182: - return checkConditionalExpression(node, contextualMapper); - case 185: - return checkSpreadElementExpression(node, contextualMapper); - case 187: - return undefinedType; - case 184: - return checkYieldExpression(node); - case 240: - return checkJsxExpression(node); - case 233: - return checkJsxElement(node); - case 234: - return checkJsxSelfClosingElement(node); - case 235: - ts.Debug.fail("Shouldn't ever directly check a JsxOpeningElement"); - } - return unknownType; - } - function checkTypeParameter(node) { - if (node.expression) { - grammarErrorOnFirstToken(node.expression, ts.Diagnostics.Type_expected); - } - checkSourceElement(node.constraint); - if (produceDiagnostics) { - checkTypeParameterHasIllegalReferencesInConstraint(node); - checkTypeNameIsReserved(node.name, ts.Diagnostics.Type_parameter_name_cannot_be_0); - } - } - function checkParameter(node) { - checkGrammarDecorators(node) || checkGrammarModifiers(node); - checkVariableLikeDeclaration(node); - var func = ts.getContainingFunction(node); - if (node.flags & 112) { - func = ts.getContainingFunction(node); - if (!(func.kind === 144 && ts.nodeIsPresent(func.body))) { - error(node, ts.Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation); - } - } - if (node.questionToken && ts.isBindingPattern(node.name) && func.body) { - error(node, ts.Diagnostics.A_binding_pattern_parameter_cannot_be_optional_in_an_implementation_signature); - } - if (node.dotDotDotToken && !ts.isBindingPattern(node.name) && !isArrayType(getTypeOfSymbol(node.symbol))) { - error(node, ts.Diagnostics.A_rest_parameter_must_be_of_an_array_type); - } - } - function isSyntacticallyValidGenerator(node) { - if (!node.asteriskToken || !node.body) { - return false; - } - return node.kind === 143 || - node.kind === 213 || - node.kind === 173; - } - function getTypePredicateParameterIndex(parameterList, parameter) { - if (parameterList) { - for (var i = 0; i < parameterList.length; i++) { - var param = parameterList[i]; - if (param.name.kind === 69 && - param.name.text === parameter.text) { - return i; - } - } - } - return -1; - } - function isInLegalTypePredicatePosition(node) { - switch (node.parent.kind) { - case 174: - case 147: - case 213: - case 173: - case 152: - case 143: - case 142: - return node === node.parent.type; - } - return false; - } - function checkSignatureDeclaration(node) { - if (node.kind === 149) { - checkGrammarIndexSignature(node); - } - else if (node.kind === 152 || node.kind === 213 || node.kind === 153 || - node.kind === 147 || node.kind === 144 || - node.kind === 148) { - checkGrammarFunctionLikeDeclaration(node); - } - checkTypeParameters(node.typeParameters); - ts.forEach(node.parameters, checkParameter); - if (node.type) { - if (node.type.kind === 150) { - var typePredicate = getSignatureFromDeclaration(node).typePredicate; - var typePredicateNode = node.type; - if (isInLegalTypePredicatePosition(typePredicateNode)) { - if (typePredicate.parameterIndex >= 0) { - if (node.parameters[typePredicate.parameterIndex].dotDotDotToken) { - error(typePredicateNode.parameterName, ts.Diagnostics.A_type_predicate_cannot_reference_a_rest_parameter); - } - else { - checkTypeAssignableTo(typePredicate.type, getTypeOfNode(node.parameters[typePredicate.parameterIndex]), typePredicateNode.type); - } - } - else if (typePredicateNode.parameterName) { - var hasReportedError = false; - for (var _i = 0, _a = node.parameters; _i < _a.length; _i++) { - var param = _a[_i]; - if (hasReportedError) { - break; - } - if (param.name.kind === 161 || - param.name.kind === 162) { - (function checkBindingPattern(pattern) { - for (var _i = 0, _a = pattern.elements; _i < _a.length; _i++) { - var element = _a[_i]; - if (element.name.kind === 69 && - element.name.text === typePredicate.parameterName) { - error(typePredicateNode.parameterName, ts.Diagnostics.A_type_predicate_cannot_reference_element_0_in_a_binding_pattern, typePredicate.parameterName); - hasReportedError = true; - break; - } - else if (element.name.kind === 162 || - element.name.kind === 161) { - checkBindingPattern(element.name); - } - } - })(param.name); - } - } - if (!hasReportedError) { - error(typePredicateNode.parameterName, ts.Diagnostics.Cannot_find_parameter_0, typePredicate.parameterName); - } - } - } - else { - error(typePredicateNode, ts.Diagnostics.A_type_predicate_is_only_allowed_in_return_type_position_for_functions_and_methods); - } - } - else { - checkSourceElement(node.type); - } - } - if (produceDiagnostics) { - checkCollisionWithArgumentsInGeneratedCode(node); - if (compilerOptions.noImplicitAny && !node.type) { - switch (node.kind) { - case 148: - error(node, ts.Diagnostics.Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); - break; - case 147: - error(node, ts.Diagnostics.Call_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); - break; - } - } - if (node.type) { - if (languageVersion >= 2 && isSyntacticallyValidGenerator(node)) { - var returnType = getTypeFromTypeNode(node.type); - if (returnType === voidType) { - error(node.type, ts.Diagnostics.A_generator_cannot_have_a_void_type_annotation); - } - else { - var generatorElementType = getElementTypeOfIterableIterator(returnType) || anyType; - var iterableIteratorInstantiation = createIterableIteratorType(generatorElementType); - checkTypeAssignableTo(iterableIteratorInstantiation, returnType, node.type); - } - } - } - } - checkSpecializedSignatureDeclaration(node); - } - function checkTypeForDuplicateIndexSignatures(node) { - if (node.kind === 215) { - var nodeSymbol = getSymbolOfNode(node); - if (nodeSymbol.declarations.length > 0 && nodeSymbol.declarations[0] !== node) { - return; - } - } - var indexSymbol = getIndexSymbol(getSymbolOfNode(node)); - if (indexSymbol) { - var seenNumericIndexer = false; - var seenStringIndexer = false; - for (var _i = 0, _a = indexSymbol.declarations; _i < _a.length; _i++) { - var decl = _a[_i]; - var declaration = decl; - if (declaration.parameters.length === 1 && declaration.parameters[0].type) { - switch (declaration.parameters[0].type.kind) { - case 130: - if (!seenStringIndexer) { - seenStringIndexer = true; - } - else { - error(declaration, ts.Diagnostics.Duplicate_string_index_signature); - } - break; - case 128: - if (!seenNumericIndexer) { - seenNumericIndexer = true; - } - else { - error(declaration, ts.Diagnostics.Duplicate_number_index_signature); - } - break; - } - } - } - } - } - function checkPropertyDeclaration(node) { - checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarProperty(node) || checkGrammarComputedPropertyName(node.name); - checkVariableLikeDeclaration(node); - } - function checkMethodDeclaration(node) { - checkGrammarMethod(node) || checkGrammarComputedPropertyName(node.name); - checkFunctionLikeDeclaration(node); - if (node.flags & 256 && node.body) { - error(node, ts.Diagnostics.Method_0_cannot_have_an_implementation_because_it_is_marked_abstract, ts.declarationNameToString(node.name)); - } - } - function checkConstructorDeclaration(node) { - checkSignatureDeclaration(node); - checkGrammarConstructorTypeParameters(node) || checkGrammarConstructorTypeAnnotation(node); - checkSourceElement(node.body); - var symbol = getSymbolOfNode(node); - var firstDeclaration = ts.getDeclarationOfKind(symbol, node.kind); - if (node === firstDeclaration) { - checkFunctionOrConstructorSymbol(symbol); - } - if (ts.nodeIsMissing(node.body)) { - return; - } - if (!produceDiagnostics) { - return; - } - function isSuperCallExpression(n) { - return n.kind === 168 && n.expression.kind === 95; - } - function containsSuperCallAsComputedPropertyName(n) { - return n.name && containsSuperCall(n.name); - } - function containsSuperCall(n) { - if (isSuperCallExpression(n)) { - return true; - } - else if (ts.isFunctionLike(n)) { - return false; - } - else if (ts.isClassLike(n)) { - return ts.forEach(n.members, containsSuperCallAsComputedPropertyName); - } - return ts.forEachChild(n, containsSuperCall); - } - function markThisReferencesAsErrors(n) { - if (n.kind === 97) { - error(n, ts.Diagnostics.this_cannot_be_referenced_in_current_location); - } - else if (n.kind !== 173 && n.kind !== 213) { - ts.forEachChild(n, markThisReferencesAsErrors); - } - } - function isInstancePropertyWithInitializer(n) { - return n.kind === 141 && - !(n.flags & 128) && - !!n.initializer; - } - var containingClassDecl = node.parent; - if (ts.getClassExtendsHeritageClauseElement(containingClassDecl)) { - var containingClassSymbol = getSymbolOfNode(containingClassDecl); - var containingClassInstanceType = getDeclaredTypeOfSymbol(containingClassSymbol); - var baseConstructorType = getBaseConstructorTypeOfClass(containingClassInstanceType); - if (containsSuperCall(node.body)) { - if (baseConstructorType === nullType) { - error(node, ts.Diagnostics.A_constructor_cannot_contain_a_super_call_when_its_class_extends_null); - } - var superCallShouldBeFirst = ts.forEach(node.parent.members, isInstancePropertyWithInitializer) || - ts.forEach(node.parameters, function (p) { return p.flags & (16 | 32 | 64); }); - if (superCallShouldBeFirst) { - var statements = node.body.statements; - var superCallStatement; - for (var _i = 0; _i < statements.length; _i++) { - var statement = statements[_i]; - if (statement.kind === 195 && isSuperCallExpression(statement.expression)) { - superCallStatement = statement; - break; - } - if (!ts.isPrologueDirective(statement)) { - break; - } - } - if (!superCallStatement) { - error(node, ts.Diagnostics.A_super_call_must_be_the_first_statement_in_the_constructor_when_a_class_contains_initialized_properties_or_has_parameter_properties); - } - else { - markThisReferencesAsErrors(superCallStatement.expression); - } - } - } - else if (baseConstructorType !== nullType) { - error(node, ts.Diagnostics.Constructors_for_derived_classes_must_contain_a_super_call); - } - } - } - function checkAccessorDeclaration(node) { - if (produceDiagnostics) { - checkGrammarFunctionLikeDeclaration(node) || checkGrammarAccessor(node) || checkGrammarComputedPropertyName(node.name); - if (node.kind === 145) { - if (!ts.isInAmbientContext(node) && ts.nodeIsPresent(node.body) && !(bodyContainsAReturnStatement(node.body) || bodyContainsSingleThrowStatement(node.body))) { - error(node.name, ts.Diagnostics.A_get_accessor_must_return_a_value_or_consist_of_a_single_throw_statement); - } - } - if (!ts.hasDynamicName(node)) { - var otherKind = node.kind === 145 ? 146 : 145; - var otherAccessor = ts.getDeclarationOfKind(node.symbol, otherKind); - if (otherAccessor) { - if (((node.flags & 112) !== (otherAccessor.flags & 112))) { - error(node.name, ts.Diagnostics.Getter_and_setter_accessors_do_not_agree_in_visibility); - } - var currentAccessorType = getAnnotatedAccessorType(node); - var otherAccessorType = getAnnotatedAccessorType(otherAccessor); - if (currentAccessorType && otherAccessorType) { - if (!isTypeIdenticalTo(currentAccessorType, otherAccessorType)) { - error(node, ts.Diagnostics.get_and_set_accessor_must_have_the_same_type); - } - } - } - } - getTypeOfAccessors(getSymbolOfNode(node)); - } - checkFunctionLikeDeclaration(node); - } - function checkMissingDeclaration(node) { - checkDecorators(node); - } - function checkTypeArgumentConstraints(typeParameters, typeArguments) { - var result = true; - for (var i = 0; i < typeParameters.length; i++) { - var constraint = getConstraintOfTypeParameter(typeParameters[i]); - if (constraint) { - var typeArgument = typeArguments[i]; - result = result && checkTypeAssignableTo(getTypeFromTypeNode(typeArgument), constraint, typeArgument, ts.Diagnostics.Type_0_does_not_satisfy_the_constraint_1); - } - } - return result; - } - function checkTypeReferenceNode(node) { - checkGrammarTypeArguments(node, node.typeArguments); - var type = getTypeFromTypeReference(node); - if (type !== unknownType && node.typeArguments) { - ts.forEach(node.typeArguments, checkSourceElement); - if (produceDiagnostics) { - var symbol = getNodeLinks(node).resolvedSymbol; - var typeParameters = symbol.flags & 524288 ? getSymbolLinks(symbol).typeParameters : type.target.localTypeParameters; - checkTypeArgumentConstraints(typeParameters, node.typeArguments); - } - } - } - function checkTypeQuery(node) { - getTypeFromTypeQueryNode(node); - } - function checkTypeLiteral(node) { - ts.forEach(node.members, checkSourceElement); - if (produceDiagnostics) { - var type = getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node); - checkIndexConstraints(type); - checkTypeForDuplicateIndexSignatures(node); - } - } - function checkArrayType(node) { - checkSourceElement(node.elementType); - } - function checkTupleType(node) { - var hasErrorFromDisallowedTrailingComma = checkGrammarForDisallowedTrailingComma(node.elementTypes); - if (!hasErrorFromDisallowedTrailingComma && node.elementTypes.length === 0) { - grammarErrorOnNode(node, ts.Diagnostics.A_tuple_type_element_list_cannot_be_empty); - } - ts.forEach(node.elementTypes, checkSourceElement); - } - function checkUnionOrIntersectionType(node) { - ts.forEach(node.types, checkSourceElement); - } - function isPrivateWithinAmbient(node) { - return (node.flags & 32) && ts.isInAmbientContext(node); - } - function checkSpecializedSignatureDeclaration(signatureDeclarationNode) { - if (!produceDiagnostics) { - return; - } - var signature = getSignatureFromDeclaration(signatureDeclarationNode); - if (!signature.hasStringLiterals) { - return; - } - if (ts.nodeIsPresent(signatureDeclarationNode.body)) { - error(signatureDeclarationNode, ts.Diagnostics.A_signature_with_an_implementation_cannot_use_a_string_literal_type); - return; - } - var signaturesToCheck; - if (!signatureDeclarationNode.name && signatureDeclarationNode.parent && signatureDeclarationNode.parent.kind === 215) { - ts.Debug.assert(signatureDeclarationNode.kind === 147 || signatureDeclarationNode.kind === 148); - var signatureKind = signatureDeclarationNode.kind === 147 ? 0 : 1; - var containingSymbol = getSymbolOfNode(signatureDeclarationNode.parent); - var containingType = getDeclaredTypeOfSymbol(containingSymbol); - signaturesToCheck = getSignaturesOfType(containingType, signatureKind); - } - else { - signaturesToCheck = getSignaturesOfSymbol(getSymbolOfNode(signatureDeclarationNode)); - } - for (var _i = 0; _i < signaturesToCheck.length; _i++) { - var otherSignature = signaturesToCheck[_i]; - if (!otherSignature.hasStringLiterals && isSignatureAssignableTo(signature, otherSignature)) { - return; - } - } - error(signatureDeclarationNode, ts.Diagnostics.Specialized_overload_signature_is_not_assignable_to_any_non_specialized_signature); - } - function getEffectiveDeclarationFlags(n, flagsToCheck) { - var flags = ts.getCombinedNodeFlags(n); - if (n.parent.kind !== 215 && - n.parent.kind !== 214 && - n.parent.kind !== 186 && - ts.isInAmbientContext(n)) { - if (!(flags & 2)) { - flags |= 1; - } - flags |= 2; - } - return flags & flagsToCheck; - } - function checkFunctionOrConstructorSymbol(symbol) { - if (!produceDiagnostics) { - return; - } - function getCanonicalOverload(overloads, implementation) { - var implementationSharesContainerWithFirstOverload = implementation !== undefined && implementation.parent === overloads[0].parent; - return implementationSharesContainerWithFirstOverload ? implementation : overloads[0]; - } - function checkFlagAgreementBetweenOverloads(overloads, implementation, flagsToCheck, someOverloadFlags, allOverloadFlags) { - var someButNotAllOverloadFlags = someOverloadFlags ^ allOverloadFlags; - if (someButNotAllOverloadFlags !== 0) { - var canonicalFlags = getEffectiveDeclarationFlags(getCanonicalOverload(overloads, implementation), flagsToCheck); - ts.forEach(overloads, function (o) { - var deviation = getEffectiveDeclarationFlags(o, flagsToCheck) ^ canonicalFlags; - if (deviation & 1) { - error(o.name, ts.Diagnostics.Overload_signatures_must_all_be_exported_or_not_exported); - } - else if (deviation & 2) { - error(o.name, ts.Diagnostics.Overload_signatures_must_all_be_ambient_or_non_ambient); - } - else if (deviation & (32 | 64)) { - error(o.name, ts.Diagnostics.Overload_signatures_must_all_be_public_private_or_protected); - } - else if (deviation & 256) { - error(o.name, ts.Diagnostics.Overload_signatures_must_all_be_abstract_or_not_abstract); - } - }); - } - } - function checkQuestionTokenAgreementBetweenOverloads(overloads, implementation, someHaveQuestionToken, allHaveQuestionToken) { - if (someHaveQuestionToken !== allHaveQuestionToken) { - var canonicalHasQuestionToken = ts.hasQuestionToken(getCanonicalOverload(overloads, implementation)); - ts.forEach(overloads, function (o) { - var deviation = ts.hasQuestionToken(o) !== canonicalHasQuestionToken; - if (deviation) { - error(o.name, ts.Diagnostics.Overload_signatures_must_all_be_optional_or_required); - } - }); - } - } - var flagsToCheck = 1 | 2 | 32 | 64 | 256; - var someNodeFlags = 0; - var allNodeFlags = flagsToCheck; - var someHaveQuestionToken = false; - var allHaveQuestionToken = true; - var hasOverloads = false; - var bodyDeclaration; - var lastSeenNonAmbientDeclaration; - var previousDeclaration; - var declarations = symbol.declarations; - var isConstructor = (symbol.flags & 16384) !== 0; - function reportImplementationExpectedError(node) { - if (node.name && ts.nodeIsMissing(node.name)) { - return; - } - var seen = false; - var subsequentNode = ts.forEachChild(node.parent, function (c) { - if (seen) { - return c; - } - else { - seen = c === node; - } - }); - if (subsequentNode) { - if (subsequentNode.kind === node.kind) { - var errorNode_1 = subsequentNode.name || subsequentNode; - if (node.name && subsequentNode.name && node.name.text === subsequentNode.name.text) { - ts.Debug.assert(node.kind === 143 || node.kind === 142); - ts.Debug.assert((node.flags & 128) !== (subsequentNode.flags & 128)); - var diagnostic = node.flags & 128 ? ts.Diagnostics.Function_overload_must_be_static : ts.Diagnostics.Function_overload_must_not_be_static; - error(errorNode_1, diagnostic); - return; - } - else if (ts.nodeIsPresent(subsequentNode.body)) { - error(errorNode_1, ts.Diagnostics.Function_implementation_name_must_be_0, ts.declarationNameToString(node.name)); - return; - } - } - } - var errorNode = node.name || node; - if (isConstructor) { - error(errorNode, ts.Diagnostics.Constructor_implementation_is_missing); - } - else { - if (node.flags & 256) { - error(errorNode, ts.Diagnostics.All_declarations_of_an_abstract_method_must_be_consecutive); - } - else { - error(errorNode, ts.Diagnostics.Function_implementation_is_missing_or_not_immediately_following_the_declaration); - } - } - } - var isExportSymbolInsideModule = symbol.parent && symbol.parent.flags & 1536; - var duplicateFunctionDeclaration = false; - var multipleConstructorImplementation = false; - for (var _i = 0; _i < declarations.length; _i++) { - var current = declarations[_i]; - var node = current; - var inAmbientContext = ts.isInAmbientContext(node); - var inAmbientContextOrInterface = node.parent.kind === 215 || node.parent.kind === 155 || inAmbientContext; - if (inAmbientContextOrInterface) { - previousDeclaration = undefined; - } - if (node.kind === 213 || node.kind === 143 || node.kind === 142 || node.kind === 144) { - var currentNodeFlags = getEffectiveDeclarationFlags(node, flagsToCheck); - someNodeFlags |= currentNodeFlags; - allNodeFlags &= currentNodeFlags; - someHaveQuestionToken = someHaveQuestionToken || ts.hasQuestionToken(node); - allHaveQuestionToken = allHaveQuestionToken && ts.hasQuestionToken(node); - if (ts.nodeIsPresent(node.body) && bodyDeclaration) { - if (isConstructor) { - multipleConstructorImplementation = true; - } - else { - duplicateFunctionDeclaration = true; - } - } - else if (!isExportSymbolInsideModule && previousDeclaration && previousDeclaration.parent === node.parent && previousDeclaration.end !== node.pos) { - reportImplementationExpectedError(previousDeclaration); - } - if (ts.nodeIsPresent(node.body)) { - if (!bodyDeclaration) { - bodyDeclaration = node; - } - } - else { - hasOverloads = true; - } - previousDeclaration = node; - if (!inAmbientContextOrInterface) { - lastSeenNonAmbientDeclaration = node; - } - } - } - if (multipleConstructorImplementation) { - ts.forEach(declarations, function (declaration) { - error(declaration, ts.Diagnostics.Multiple_constructor_implementations_are_not_allowed); - }); - } - if (duplicateFunctionDeclaration) { - ts.forEach(declarations, function (declaration) { - error(declaration.name, ts.Diagnostics.Duplicate_function_implementation); - }); - } - if (!isExportSymbolInsideModule && lastSeenNonAmbientDeclaration && !lastSeenNonAmbientDeclaration.body && - !(lastSeenNonAmbientDeclaration.flags & 256)) { - reportImplementationExpectedError(lastSeenNonAmbientDeclaration); - } - if (hasOverloads) { - checkFlagAgreementBetweenOverloads(declarations, bodyDeclaration, flagsToCheck, someNodeFlags, allNodeFlags); - checkQuestionTokenAgreementBetweenOverloads(declarations, bodyDeclaration, someHaveQuestionToken, allHaveQuestionToken); - if (bodyDeclaration) { - var signatures = getSignaturesOfSymbol(symbol); - var bodySignature = getSignatureFromDeclaration(bodyDeclaration); - if (!bodySignature.hasStringLiterals) { - for (var _a = 0; _a < signatures.length; _a++) { - var signature = signatures[_a]; - if (!signature.hasStringLiterals && !isSignatureAssignableTo(bodySignature, signature)) { - error(signature.declaration, ts.Diagnostics.Overload_signature_is_not_compatible_with_function_implementation); - break; - } - } - } - } - } - } - function checkExportsOnMergedDeclarations(node) { - if (!produceDiagnostics) { - return; - } - var symbol = node.localSymbol; - if (!symbol) { - symbol = getSymbolOfNode(node); - if (!(symbol.flags & 7340032)) { - return; - } - } - if (ts.getDeclarationOfKind(symbol, node.kind) !== node) { - return; - } - var exportedDeclarationSpaces = 0; - var nonExportedDeclarationSpaces = 0; - var defaultExportedDeclarationSpaces = 0; - for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { - var d = _a[_i]; - var declarationSpaces = getDeclarationSpaces(d); - var effectiveDeclarationFlags = getEffectiveDeclarationFlags(d, 1 | 1024); - if (effectiveDeclarationFlags & 1) { - if (effectiveDeclarationFlags & 1024) { - defaultExportedDeclarationSpaces |= declarationSpaces; - } - else { - exportedDeclarationSpaces |= declarationSpaces; - } - } - else { - nonExportedDeclarationSpaces |= declarationSpaces; - } - } - var nonDefaultExportedDeclarationSpaces = exportedDeclarationSpaces | nonExportedDeclarationSpaces; - var commonDeclarationSpacesForExportsAndLocals = exportedDeclarationSpaces & nonExportedDeclarationSpaces; - var commonDeclarationSpacesForDefaultAndNonDefault = defaultExportedDeclarationSpaces & nonDefaultExportedDeclarationSpaces; - if (commonDeclarationSpacesForExportsAndLocals || commonDeclarationSpacesForDefaultAndNonDefault) { - for (var _b = 0, _c = symbol.declarations; _b < _c.length; _b++) { - var d = _c[_b]; - var declarationSpaces = getDeclarationSpaces(d); - if (declarationSpaces & commonDeclarationSpacesForDefaultAndNonDefault) { - error(d.name, ts.Diagnostics.Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_default_0_declaration_instead, ts.declarationNameToString(d.name)); - } - else if (declarationSpaces & commonDeclarationSpacesForExportsAndLocals) { - error(d.name, ts.Diagnostics.Individual_declarations_in_merged_declaration_0_must_be_all_exported_or_all_local, ts.declarationNameToString(d.name)); - } - } - } - function getDeclarationSpaces(d) { - switch (d.kind) { - case 215: - return 2097152; - case 218: - return d.name.kind === 9 || ts.getModuleInstanceState(d) !== 0 - ? 4194304 | 1048576 - : 4194304; - case 214: - case 217: - return 2097152 | 1048576; - case 221: - var result = 0; - var target = resolveAlias(getSymbolOfNode(d)); - ts.forEach(target.declarations, function (d) { result |= getDeclarationSpaces(d); }); - return result; - default: - return 1048576; - } - } - } - function checkNonThenableType(type, location, message) { - type = getWidenedType(type); - if (!isTypeAny(type) && isTypeAssignableTo(type, getGlobalThenableType())) { - if (location) { - if (!message) { - message = ts.Diagnostics.Operand_for_await_does_not_have_a_valid_callable_then_member; - } - error(location, message); - } - return unknownType; - } - return type; - } - function getPromisedType(promise) { - if (promise.flags & 1) { - return undefined; - } - if ((promise.flags & 4096) && promise.target === tryGetGlobalPromiseType()) { - return promise.typeArguments[0]; - } - var globalPromiseLikeType = getInstantiatedGlobalPromiseLikeType(); - if (globalPromiseLikeType === emptyObjectType || !isTypeAssignableTo(promise, globalPromiseLikeType)) { - return undefined; - } - var thenFunction = getTypeOfPropertyOfType(promise, "then"); - if (thenFunction && (thenFunction.flags & 1)) { - return undefined; - } - var thenSignatures = thenFunction ? getSignaturesOfType(thenFunction, 0) : emptyArray; - if (thenSignatures.length === 0) { - return undefined; - } - var onfulfilledParameterType = getUnionType(ts.map(thenSignatures, getTypeOfFirstParameterOfSignature)); - if (onfulfilledParameterType.flags & 1) { - return undefined; - } - var onfulfilledParameterSignatures = getSignaturesOfType(onfulfilledParameterType, 0); - if (onfulfilledParameterSignatures.length === 0) { - return undefined; - } - var valueParameterType = getUnionType(ts.map(onfulfilledParameterSignatures, getTypeOfFirstParameterOfSignature)); - return valueParameterType; - } - function getTypeOfFirstParameterOfSignature(signature) { - return getTypeAtPosition(signature, 0); - } - function getAwaitedType(type) { - return checkAwaitedType(type, undefined, undefined); - } - function checkAwaitedType(type, location, message) { - return checkAwaitedTypeWorker(type); - function checkAwaitedTypeWorker(type) { - if (type.flags & 16384) { - var types = []; - for (var _i = 0, _a = type.types; _i < _a.length; _i++) { - var constituentType = _a[_i]; - types.push(checkAwaitedTypeWorker(constituentType)); - } - return getUnionType(types); - } - else { - var promisedType = getPromisedType(type); - if (promisedType === undefined) { - return checkNonThenableType(type, location, message); - } - else { - if (type.id === promisedType.id || awaitedTypeStack.indexOf(promisedType.id) >= 0) { - if (location) { - error(location, ts.Diagnostics._0_is_referenced_directly_or_indirectly_in_the_fulfillment_callback_of_its_own_then_method, symbolToString(type.symbol)); - } - return unknownType; - } - awaitedTypeStack.push(type.id); - var awaitedType = checkAwaitedTypeWorker(promisedType); - awaitedTypeStack.pop(); - return awaitedType; - } - } - } - } - function checkAsyncFunctionReturnType(node) { - var globalPromiseConstructorLikeType = getGlobalPromiseConstructorLikeType(); - if (globalPromiseConstructorLikeType === emptyObjectType) { - return unknownType; - } - var promiseType = getTypeFromTypeNode(node.type); - if (promiseType === unknownType && compilerOptions.isolatedModules) { - return unknownType; - } - var promiseConstructor = getMergedSymbol(promiseType.symbol); - if (!promiseConstructor || !symbolIsValue(promiseConstructor)) { - error(node, ts.Diagnostics.Type_0_is_not_a_valid_async_function_return_type, typeToString(promiseType)); - return unknownType; - } - var promiseConstructorType = getTypeOfSymbol(promiseConstructor); - if (!checkTypeAssignableTo(promiseConstructorType, globalPromiseConstructorLikeType, node, ts.Diagnostics.Type_0_is_not_a_valid_async_function_return_type)) { - return unknownType; - } - var promiseName = ts.getEntityNameFromTypeNode(node.type); - var root = getFirstIdentifier(promiseName); - var rootSymbol = getSymbol(node.locals, root.text, 107455); - if (rootSymbol) { - error(rootSymbol.valueDeclaration, ts.Diagnostics.Duplicate_identifier_0_Compiler_uses_declaration_1_to_support_async_functions, root.text, getFullyQualifiedName(promiseConstructor)); - return unknownType; - } - return checkAwaitedType(promiseType, node, ts.Diagnostics.An_async_function_or_method_must_have_a_valid_awaitable_return_type); - } - function checkDecorator(node) { - var signature = getResolvedSignature(node); - var returnType = getReturnTypeOfSignature(signature); - if (returnType.flags & 1) { - return; - } - var expectedReturnType; - var headMessage = getDiagnosticHeadMessageForDecoratorResolution(node); - var errorInfo; - switch (node.parent.kind) { - case 214: - var classSymbol = getSymbolOfNode(node.parent); - var classConstructorType = getTypeOfSymbol(classSymbol); - expectedReturnType = getUnionType([classConstructorType, voidType]); - break; - case 138: - expectedReturnType = voidType; - errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.The_return_type_of_a_parameter_decorator_function_must_be_either_void_or_any); - break; - case 141: - expectedReturnType = voidType; - errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.The_return_type_of_a_property_decorator_function_must_be_either_void_or_any); - break; - case 143: - case 145: - case 146: - var methodType = getTypeOfNode(node.parent); - var descriptorType = createTypedPropertyDescriptorType(methodType); - expectedReturnType = getUnionType([descriptorType, voidType]); - break; - } - checkTypeAssignableTo(returnType, expectedReturnType, node, headMessage, errorInfo); - } - function checkTypeNodeAsExpression(node) { - if (node && node.kind === 151) { - var root = getFirstIdentifier(node.typeName); - var meaning = root.parent.kind === 151 ? 793056 : 1536; - var rootSymbol = resolveName(root, root.text, meaning | 8388608, undefined, undefined); - if (rootSymbol && rootSymbol.flags & 8388608) { - var aliasTarget = resolveAlias(rootSymbol); - if (aliasTarget.flags & 107455 && !isConstEnumOrConstEnumOnlyModule(resolveAlias(rootSymbol))) { - markAliasSymbolAsReferenced(rootSymbol); - } - } - } - } - function checkTypeAnnotationAsExpression(node) { - switch (node.kind) { - case 141: - checkTypeNodeAsExpression(node.type); - break; - case 138: - checkTypeNodeAsExpression(node.type); - break; - case 143: - checkTypeNodeAsExpression(node.type); - break; - case 145: - checkTypeNodeAsExpression(node.type); - break; - case 146: - checkTypeNodeAsExpression(ts.getSetAccessorTypeAnnotationNode(node)); - break; - } - } - function checkParameterTypeAnnotationsAsExpressions(node) { - for (var _i = 0, _a = node.parameters; _i < _a.length; _i++) { - var parameter = _a[_i]; - checkTypeAnnotationAsExpression(parameter); - } - } - function checkDecorators(node) { - if (!node.decorators) { - return; - } - if (!ts.nodeCanBeDecorated(node)) { - return; - } - if (!compilerOptions.experimentalDecorators) { - error(node, ts.Diagnostics.Experimental_support_for_decorators_is_a_feature_that_is_subject_to_change_in_a_future_release_Specify_experimentalDecorators_to_remove_this_warning); - } - if (compilerOptions.emitDecoratorMetadata) { - switch (node.kind) { - case 214: - var constructor = ts.getFirstConstructorWithBody(node); - if (constructor) { - checkParameterTypeAnnotationsAsExpressions(constructor); - } - break; - case 143: - checkParameterTypeAnnotationsAsExpressions(node); - case 146: - case 145: - case 141: - case 138: - checkTypeAnnotationAsExpression(node); - break; - } - } - emitDecorate = true; - if (node.kind === 138) { - emitParam = true; - } - ts.forEach(node.decorators, checkDecorator); - } - function checkFunctionDeclaration(node) { - if (produceDiagnostics) { - checkFunctionLikeDeclaration(node) || checkGrammarForGenerator(node); - checkCollisionWithCapturedSuperVariable(node, node.name); - checkCollisionWithCapturedThisVariable(node, node.name); - checkCollisionWithRequireExportsInGeneratedCode(node, node.name); - } - } - function checkFunctionLikeDeclaration(node) { - checkDecorators(node); - checkSignatureDeclaration(node); - var isAsync = ts.isAsyncFunctionLike(node); - if (isAsync) { - emitAwaiter = true; - } - if (node.name && node.name.kind === 136) { - checkComputedPropertyName(node.name); - } - if (!ts.hasDynamicName(node)) { - var symbol = getSymbolOfNode(node); - var localSymbol = node.localSymbol || symbol; - var firstDeclaration = ts.getDeclarationOfKind(localSymbol, node.kind); - if (node === firstDeclaration) { - checkFunctionOrConstructorSymbol(localSymbol); - } - if (symbol.parent) { - if (ts.getDeclarationOfKind(symbol, node.kind) === node) { - checkFunctionOrConstructorSymbol(symbol); - } - } - } - checkSourceElement(node.body); - if (node.type && !isAccessor(node.kind) && !node.asteriskToken) { - var returnType = getTypeFromTypeNode(node.type); - var promisedType; - if (isAsync) { - promisedType = checkAsyncFunctionReturnType(node); - } - checkIfNonVoidFunctionHasReturnExpressionsOrSingleThrowStatment(node, isAsync ? promisedType : returnType); - } - if (produceDiagnostics && !node.type) { - if (compilerOptions.noImplicitAny && ts.nodeIsMissing(node.body) && !isPrivateWithinAmbient(node)) { - reportImplicitAnyError(node, anyType); - } - if (node.asteriskToken && ts.nodeIsPresent(node.body)) { - getReturnTypeOfSignature(getSignatureFromDeclaration(node)); - } - } - } - function checkBlock(node) { - if (node.kind === 192) { - checkGrammarStatementInAmbientContext(node); - } - ts.forEach(node.statements, checkSourceElement); - if (ts.isFunctionBlock(node) || node.kind === 219) { - checkFunctionAndClassExpressionBodies(node); - } - } - function checkCollisionWithArgumentsInGeneratedCode(node) { - if (!ts.hasRestParameter(node) || ts.isInAmbientContext(node) || ts.nodeIsMissing(node.body)) { - return; - } - ts.forEach(node.parameters, function (p) { - if (p.name && !ts.isBindingPattern(p.name) && p.name.text === argumentsSymbol.name) { - error(p, ts.Diagnostics.Duplicate_identifier_arguments_Compiler_uses_arguments_to_initialize_rest_parameters); - } - }); - } - function needCollisionCheckForIdentifier(node, identifier, name) { - if (!(identifier && identifier.text === name)) { - return false; - } - if (node.kind === 141 || - node.kind === 140 || - node.kind === 143 || - node.kind === 142 || - node.kind === 145 || - node.kind === 146) { - return false; - } - if (ts.isInAmbientContext(node)) { - return false; - } - var root = ts.getRootDeclaration(node); - if (root.kind === 138 && ts.nodeIsMissing(root.parent.body)) { - return false; - } - return true; - } - function checkCollisionWithCapturedThisVariable(node, name) { - if (needCollisionCheckForIdentifier(node, name, "_this")) { - potentialThisCollisions.push(node); - } - } - function checkIfThisIsCapturedInEnclosingScope(node) { - var current = node; - while (current) { - if (getNodeCheckFlags(current) & 4) { - var isDeclaration_1 = node.kind !== 69; - if (isDeclaration_1) { - error(node.name, ts.Diagnostics.Duplicate_identifier_this_Compiler_uses_variable_declaration_this_to_capture_this_reference); - } - else { - error(node, ts.Diagnostics.Expression_resolves_to_variable_declaration_this_that_compiler_uses_to_capture_this_reference); - } - return; - } - current = current.parent; - } - } - function checkCollisionWithCapturedSuperVariable(node, name) { - if (!needCollisionCheckForIdentifier(node, name, "_super")) { - return; - } - var enclosingClass = ts.getContainingClass(node); - if (!enclosingClass || ts.isInAmbientContext(enclosingClass)) { - return; - } - if (ts.getClassExtendsHeritageClauseElement(enclosingClass)) { - var isDeclaration_2 = node.kind !== 69; - if (isDeclaration_2) { - error(node, ts.Diagnostics.Duplicate_identifier_super_Compiler_uses_super_to_capture_base_class_reference); - } - else { - error(node, ts.Diagnostics.Expression_resolves_to_super_that_compiler_uses_to_capture_base_class_reference); - } - } - } - function checkCollisionWithRequireExportsInGeneratedCode(node, name) { - if (!needCollisionCheckForIdentifier(node, name, "require") && !needCollisionCheckForIdentifier(node, name, "exports")) { - return; - } - if (node.kind === 218 && ts.getModuleInstanceState(node) !== 1) { - return; - } - var parent = getDeclarationContainer(node); - if (parent.kind === 248 && ts.isExternalModule(parent)) { - error(name, ts.Diagnostics.Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module, ts.declarationNameToString(name), ts.declarationNameToString(name)); - } - } - function checkVarDeclaredNamesNotShadowed(node) { - if ((ts.getCombinedNodeFlags(node) & 49152) !== 0 || ts.isParameterDeclaration(node)) { - return; - } - if (node.kind === 211 && !node.initializer) { - return; - } - var symbol = getSymbolOfNode(node); - if (symbol.flags & 1) { - var localDeclarationSymbol = resolveName(node, node.name.text, 3, undefined, undefined); - if (localDeclarationSymbol && - localDeclarationSymbol !== symbol && - localDeclarationSymbol.flags & 2) { - if (getDeclarationFlagsFromSymbol(localDeclarationSymbol) & 49152) { - var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 212); - var container = varDeclList.parent.kind === 193 && varDeclList.parent.parent - ? varDeclList.parent.parent - : undefined; - var namesShareScope = container && - (container.kind === 192 && ts.isFunctionLike(container.parent) || - container.kind === 219 || - container.kind === 218 || - container.kind === 248); - if (!namesShareScope) { - var name_15 = symbolToString(localDeclarationSymbol); - error(node, ts.Diagnostics.Cannot_initialize_outer_scoped_variable_0_in_the_same_scope_as_block_scoped_declaration_1, name_15, name_15); - } - } - } - } - } - function checkParameterInitializer(node) { - if (ts.getRootDeclaration(node).kind !== 138) { - return; - } - var func = ts.getContainingFunction(node); - visit(node.initializer); - function visit(n) { - if (n.kind === 69) { - var referencedSymbol = getNodeLinks(n).resolvedSymbol; - if (referencedSymbol && referencedSymbol !== unknownSymbol && getSymbol(func.locals, referencedSymbol.name, 107455) === referencedSymbol) { - if (referencedSymbol.valueDeclaration.kind === 138) { - if (referencedSymbol.valueDeclaration === node) { - error(n, ts.Diagnostics.Parameter_0_cannot_be_referenced_in_its_initializer, ts.declarationNameToString(node.name)); - return; - } - if (referencedSymbol.valueDeclaration.pos < node.pos) { - return; - } - } - error(n, ts.Diagnostics.Initializer_of_parameter_0_cannot_reference_identifier_1_declared_after_it, ts.declarationNameToString(node.name), ts.declarationNameToString(n)); - } - } - else { - ts.forEachChild(n, visit); - } - } - } - function checkVariableLikeDeclaration(node) { - checkDecorators(node); - checkSourceElement(node.type); - if (node.name.kind === 136) { - checkComputedPropertyName(node.name); - if (node.initializer) { - checkExpressionCached(node.initializer); - } - } - if (ts.isBindingPattern(node.name)) { - ts.forEach(node.name.elements, checkSourceElement); - } - if (node.initializer && ts.getRootDeclaration(node).kind === 138 && ts.nodeIsMissing(ts.getContainingFunction(node).body)) { - error(node, ts.Diagnostics.A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation); - return; - } - if (ts.isBindingPattern(node.name)) { - if (node.initializer) { - checkTypeAssignableTo(checkExpressionCached(node.initializer), getWidenedTypeForVariableLikeDeclaration(node), node, undefined); - checkParameterInitializer(node); - } - return; - } - var symbol = getSymbolOfNode(node); - var type = getTypeOfVariableOrParameterOrProperty(symbol); - if (node === symbol.valueDeclaration) { - if (node.initializer) { - checkTypeAssignableTo(checkExpressionCached(node.initializer), type, node, undefined); - checkParameterInitializer(node); - } - } - else { - var declarationType = 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)); - } - if (node.initializer) { - checkTypeAssignableTo(checkExpressionCached(node.initializer), declarationType, node, undefined); - } - } - if (node.kind !== 141 && node.kind !== 140) { - checkExportsOnMergedDeclarations(node); - if (node.kind === 211 || node.kind === 163) { - checkVarDeclaredNamesNotShadowed(node); - } - checkCollisionWithCapturedSuperVariable(node, node.name); - checkCollisionWithCapturedThisVariable(node, node.name); - checkCollisionWithRequireExportsInGeneratedCode(node, node.name); - } - } - function checkVariableDeclaration(node) { - checkGrammarVariableDeclaration(node); - return checkVariableLikeDeclaration(node); - } - function checkBindingElement(node) { - checkGrammarBindingElement(node); - return checkVariableLikeDeclaration(node); - } - function checkVariableStatement(node) { - checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarVariableDeclarationList(node.declarationList) || checkGrammarForDisallowedLetOrConstStatement(node); - ts.forEach(node.declarationList.declarations, checkSourceElement); - } - function checkGrammarDisallowedModifiersOnObjectLiteralExpressionMethod(node) { - if (node.modifiers && node.parent.kind === 165) { - if (ts.isAsyncFunctionLike(node)) { - if (node.modifiers.length > 1) { - return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); - } - } - else { - return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); - } - } - } - function checkExpressionStatement(node) { - checkGrammarStatementInAmbientContext(node); - checkExpression(node.expression); - } - function checkIfStatement(node) { - checkGrammarStatementInAmbientContext(node); - checkExpression(node.expression); - checkSourceElement(node.thenStatement); - checkSourceElement(node.elseStatement); - } - function checkDoStatement(node) { - checkGrammarStatementInAmbientContext(node); - checkSourceElement(node.statement); - checkExpression(node.expression); - } - function checkWhileStatement(node) { - checkGrammarStatementInAmbientContext(node); - checkExpression(node.expression); - checkSourceElement(node.statement); - } - function checkForStatement(node) { - if (!checkGrammarStatementInAmbientContext(node)) { - if (node.initializer && node.initializer.kind === 212) { - checkGrammarVariableDeclarationList(node.initializer); - } - } - if (node.initializer) { - if (node.initializer.kind === 212) { - ts.forEach(node.initializer.declarations, checkVariableDeclaration); - } - else { - checkExpression(node.initializer); - } - } - if (node.condition) - checkExpression(node.condition); - if (node.incrementor) - checkExpression(node.incrementor); - checkSourceElement(node.statement); - } - function checkForOfStatement(node) { - checkGrammarForInOrForOfStatement(node); - if (node.initializer.kind === 212) { - checkForInOrForOfVariableDeclaration(node); - } - else { - var varExpr = node.initializer; - var iteratedType = checkRightHandSideOfForOf(node.expression); - if (varExpr.kind === 164 || varExpr.kind === 165) { - checkDestructuringAssignment(varExpr, iteratedType || unknownType); - } - else { - var leftType = checkExpression(varExpr); - checkReferenceExpression(varExpr, ts.Diagnostics.Invalid_left_hand_side_in_for_of_statement, ts.Diagnostics.The_left_hand_side_of_a_for_of_statement_cannot_be_a_previously_defined_constant); - if (iteratedType) { - checkTypeAssignableTo(iteratedType, leftType, varExpr, undefined); - } - } - } - checkSourceElement(node.statement); - } - function checkForInStatement(node) { - checkGrammarForInOrForOfStatement(node); - if (node.initializer.kind === 212) { - var variable = node.initializer.declarations[0]; - if (variable && ts.isBindingPattern(variable.name)) { - error(variable.name, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern); - } - checkForInOrForOfVariableDeclaration(node); - } - else { - var varExpr = node.initializer; - var leftType = checkExpression(varExpr); - if (varExpr.kind === 164 || varExpr.kind === 165) { - error(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern); - } - else if (!isTypeAnyOrAllConstituentTypesHaveKind(leftType, 258)) { - error(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_must_be_of_type_string_or_any); - } - else { - checkReferenceExpression(varExpr, ts.Diagnostics.Invalid_left_hand_side_in_for_in_statement, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_previously_defined_constant); - } - } - var rightType = checkExpression(node.expression); - if (!isTypeAnyOrAllConstituentTypesHaveKind(rightType, 80896 | 512)) { - error(node.expression, ts.Diagnostics.The_right_hand_side_of_a_for_in_statement_must_be_of_type_any_an_object_type_or_a_type_parameter); - } - checkSourceElement(node.statement); - } - function checkForInOrForOfVariableDeclaration(iterationStatement) { - var variableDeclarationList = iterationStatement.initializer; - if (variableDeclarationList.declarations.length >= 1) { - var decl = variableDeclarationList.declarations[0]; - checkVariableDeclaration(decl); - } - } - function checkRightHandSideOfForOf(rhsExpression) { - var expressionType = getTypeOfExpression(rhsExpression); - return checkIteratedTypeOrElementType(expressionType, rhsExpression, true); - } - function checkIteratedTypeOrElementType(inputType, errorNode, allowStringInput) { - if (isTypeAny(inputType)) { - return inputType; - } - if (languageVersion >= 2) { - return checkElementTypeOfIterable(inputType, errorNode); - } - if (allowStringInput) { - return checkElementTypeOfArrayOrString(inputType, errorNode); - } - if (isArrayLikeType(inputType)) { - var indexType = getIndexTypeOfType(inputType, 1); - if (indexType) { - return indexType; - } - } - error(errorNode, ts.Diagnostics.Type_0_is_not_an_array_type, typeToString(inputType)); - return unknownType; - } - function checkElementTypeOfIterable(iterable, errorNode) { - var elementType = getElementTypeOfIterable(iterable, errorNode); - if (errorNode && elementType) { - checkTypeAssignableTo(iterable, createIterableType(elementType), errorNode); - } - return elementType || anyType; - } - function getElementTypeOfIterable(type, errorNode) { - if (isTypeAny(type)) { - return undefined; - } - var typeAsIterable = type; - if (!typeAsIterable.iterableElementType) { - if ((type.flags & 4096) && type.target === globalIterableType) { - typeAsIterable.iterableElementType = type.typeArguments[0]; - } - else { - var iteratorFunction = getTypeOfPropertyOfType(type, ts.getPropertyNameForKnownSymbolName("iterator")); - if (isTypeAny(iteratorFunction)) { - return undefined; - } - var iteratorFunctionSignatures = iteratorFunction ? getSignaturesOfType(iteratorFunction, 0) : emptyArray; - if (iteratorFunctionSignatures.length === 0) { - if (errorNode) { - error(errorNode, ts.Diagnostics.Type_must_have_a_Symbol_iterator_method_that_returns_an_iterator); - } - return undefined; - } - typeAsIterable.iterableElementType = getElementTypeOfIterator(getUnionType(ts.map(iteratorFunctionSignatures, getReturnTypeOfSignature)), errorNode); - } - } - return typeAsIterable.iterableElementType; - } - function getElementTypeOfIterator(type, errorNode) { - if (isTypeAny(type)) { - return undefined; - } - var typeAsIterator = type; - if (!typeAsIterator.iteratorElementType) { - if ((type.flags & 4096) && type.target === globalIteratorType) { - typeAsIterator.iteratorElementType = type.typeArguments[0]; - } - else { - var iteratorNextFunction = getTypeOfPropertyOfType(type, "next"); - if (isTypeAny(iteratorNextFunction)) { - return undefined; - } - var iteratorNextFunctionSignatures = iteratorNextFunction ? getSignaturesOfType(iteratorNextFunction, 0) : emptyArray; - if (iteratorNextFunctionSignatures.length === 0) { - if (errorNode) { - error(errorNode, ts.Diagnostics.An_iterator_must_have_a_next_method); - } - return undefined; - } - var iteratorNextResult = getUnionType(ts.map(iteratorNextFunctionSignatures, getReturnTypeOfSignature)); - if (isTypeAny(iteratorNextResult)) { - return undefined; - } - var iteratorNextValue = getTypeOfPropertyOfType(iteratorNextResult, "value"); - if (!iteratorNextValue) { - if (errorNode) { - error(errorNode, ts.Diagnostics.The_type_returned_by_the_next_method_of_an_iterator_must_have_a_value_property); - } - return undefined; - } - typeAsIterator.iteratorElementType = iteratorNextValue; - } - } - return typeAsIterator.iteratorElementType; - } - function getElementTypeOfIterableIterator(type) { - if (isTypeAny(type)) { - return undefined; - } - if ((type.flags & 4096) && type.target === globalIterableIteratorType) { - return type.typeArguments[0]; - } - return getElementTypeOfIterable(type, undefined) || - getElementTypeOfIterator(type, undefined); - } - function checkElementTypeOfArrayOrString(arrayOrStringType, errorNode) { - ts.Debug.assert(languageVersion < 2); - var arrayType = removeTypesFromUnionType(arrayOrStringType, 258, true, true); - var hasStringConstituent = arrayOrStringType !== arrayType; - var reportedError = false; - if (hasStringConstituent) { - if (languageVersion < 1) { - error(errorNode, ts.Diagnostics.Using_a_string_in_a_for_of_statement_is_only_supported_in_ECMAScript_5_and_higher); - reportedError = true; - } - if (arrayType === emptyObjectType) { - return stringType; - } - } - if (!isArrayLikeType(arrayType)) { - if (!reportedError) { - var diagnostic = hasStringConstituent - ? ts.Diagnostics.Type_0_is_not_an_array_type - : ts.Diagnostics.Type_0_is_not_an_array_type_or_a_string_type; - error(errorNode, diagnostic, typeToString(arrayType)); - } - return hasStringConstituent ? stringType : unknownType; - } - var arrayElementType = getIndexTypeOfType(arrayType, 1) || unknownType; - if (hasStringConstituent) { - if (arrayElementType.flags & 258) { - return stringType; - } - return getUnionType([arrayElementType, stringType]); - } - return arrayElementType; - } - function checkBreakOrContinueStatement(node) { - checkGrammarStatementInAmbientContext(node) || checkGrammarBreakOrContinueStatement(node); - } - function isGetAccessorWithAnnotatatedSetAccessor(node) { - return !!(node.kind === 145 && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(node.symbol, 146))); - } - function checkReturnStatement(node) { - if (!checkGrammarStatementInAmbientContext(node)) { - var functionBlock = ts.getContainingFunction(node); - if (!functionBlock) { - grammarErrorOnFirstToken(node, ts.Diagnostics.A_return_statement_can_only_be_used_within_a_function_body); - } - } - if (node.expression) { - var func = ts.getContainingFunction(node); - if (func) { - var signature = getSignatureFromDeclaration(func); - var returnType = getReturnTypeOfSignature(signature); - var exprType = checkExpressionCached(node.expression); - if (func.asteriskToken) { - return; - } - if (func.kind === 146) { - error(node.expression, ts.Diagnostics.Setters_cannot_return_a_value); - } - else if (func.kind === 144) { - if (!isTypeAssignableTo(exprType, returnType)) { - error(node.expression, ts.Diagnostics.Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class); - } - } - else if (func.type || isGetAccessorWithAnnotatatedSetAccessor(func) || signature.typePredicate) { - if (ts.isAsyncFunctionLike(func)) { - var promisedType = getPromisedType(returnType); - var awaitedType = checkAwaitedType(exprType, node.expression, ts.Diagnostics.Return_expression_in_async_function_does_not_have_a_valid_callable_then_member); - if (promisedType) { - checkTypeAssignableTo(awaitedType, promisedType, node.expression); - } - } - else { - checkTypeAssignableTo(exprType, returnType, node.expression); - } - } - } - } - } - function checkWithStatement(node) { - if (!checkGrammarStatementInAmbientContext(node)) { - if (node.parserContextFlags & 8) { - grammarErrorOnFirstToken(node, ts.Diagnostics.with_statements_are_not_allowed_in_an_async_function_block); - } - } - checkExpression(node.expression); - error(node.expression, ts.Diagnostics.All_symbols_within_a_with_block_will_be_resolved_to_any); - } - function checkSwitchStatement(node) { - checkGrammarStatementInAmbientContext(node); - var firstDefaultClause; - var hasDuplicateDefaultClause = false; - var expressionType = checkExpression(node.expression); - ts.forEach(node.caseBlock.clauses, function (clause) { - if (clause.kind === 242 && !hasDuplicateDefaultClause) { - if (firstDefaultClause === undefined) { - firstDefaultClause = clause; - } - else { - var sourceFile = ts.getSourceFileOfNode(node); - var start = ts.skipTrivia(sourceFile.text, clause.pos); - var end = clause.statements.length > 0 ? clause.statements[0].pos : clause.end; - grammarErrorAtPos(sourceFile, start, end - start, ts.Diagnostics.A_default_clause_cannot_appear_more_than_once_in_a_switch_statement); - hasDuplicateDefaultClause = true; - } - } - if (produceDiagnostics && clause.kind === 241) { - var caseClause = clause; - var caseType = checkExpression(caseClause.expression); - if (!isTypeAssignableTo(expressionType, caseType)) { - checkTypeAssignableTo(caseType, expressionType, caseClause.expression, undefined); - } - } - ts.forEach(clause.statements, checkSourceElement); - }); - } - function checkLabeledStatement(node) { - if (!checkGrammarStatementInAmbientContext(node)) { - var current = node.parent; - while (current) { - if (ts.isFunctionLike(current)) { - break; - } - if (current.kind === 207 && current.label.text === node.label.text) { - var sourceFile = ts.getSourceFileOfNode(node); - grammarErrorOnNode(node.label, ts.Diagnostics.Duplicate_label_0, ts.getTextOfNodeFromSourceText(sourceFile.text, node.label)); - break; - } - current = current.parent; - } - } - checkSourceElement(node.statement); - } - function checkThrowStatement(node) { - if (!checkGrammarStatementInAmbientContext(node)) { - if (node.expression === undefined) { - grammarErrorAfterFirstToken(node, ts.Diagnostics.Line_break_not_permitted_here); - } - } - if (node.expression) { - checkExpression(node.expression); - } - } - function checkTryStatement(node) { - checkGrammarStatementInAmbientContext(node); - checkBlock(node.tryBlock); - var catchClause = node.catchClause; - if (catchClause) { - if (catchClause.variableDeclaration) { - if (catchClause.variableDeclaration.name.kind !== 69) { - grammarErrorOnFirstToken(catchClause.variableDeclaration.name, ts.Diagnostics.Catch_clause_variable_name_must_be_an_identifier); - } - else if (catchClause.variableDeclaration.type) { - grammarErrorOnFirstToken(catchClause.variableDeclaration.type, ts.Diagnostics.Catch_clause_variable_cannot_have_a_type_annotation); - } - else if (catchClause.variableDeclaration.initializer) { - grammarErrorOnFirstToken(catchClause.variableDeclaration.initializer, ts.Diagnostics.Catch_clause_variable_cannot_have_an_initializer); - } - else { - var identifierName = catchClause.variableDeclaration.name.text; - var locals = catchClause.block.locals; - if (locals && ts.hasProperty(locals, identifierName)) { - var localSymbol = locals[identifierName]; - if (localSymbol && (localSymbol.flags & 2) !== 0) { - grammarErrorOnNode(localSymbol.valueDeclaration, ts.Diagnostics.Cannot_redeclare_identifier_0_in_catch_clause, identifierName); - } - } - } - } - checkBlock(catchClause.block); - } - if (node.finallyBlock) { - checkBlock(node.finallyBlock); - } - } - function checkIndexConstraints(type) { - var declaredNumberIndexer = getIndexDeclarationOfSymbol(type.symbol, 1); - var declaredStringIndexer = getIndexDeclarationOfSymbol(type.symbol, 0); - var stringIndexType = getIndexTypeOfType(type, 0); - var numberIndexType = getIndexTypeOfType(type, 1); - if (stringIndexType || numberIndexType) { - ts.forEach(getPropertiesOfObjectType(type), function (prop) { - var propType = getTypeOfSymbol(prop); - checkIndexConstraintForProperty(prop, propType, type, declaredStringIndexer, stringIndexType, 0); - checkIndexConstraintForProperty(prop, propType, type, declaredNumberIndexer, numberIndexType, 1); - }); - if (type.flags & 1024 && ts.isClassLike(type.symbol.valueDeclaration)) { - var classDeclaration = type.symbol.valueDeclaration; - for (var _i = 0, _a = classDeclaration.members; _i < _a.length; _i++) { - var member = _a[_i]; - if (!(member.flags & 128) && ts.hasDynamicName(member)) { - var propType = getTypeOfSymbol(member.symbol); - checkIndexConstraintForProperty(member.symbol, propType, type, declaredStringIndexer, stringIndexType, 0); - checkIndexConstraintForProperty(member.symbol, propType, type, declaredNumberIndexer, numberIndexType, 1); - } - } - } - } - var errorNode; - if (stringIndexType && numberIndexType) { - errorNode = declaredNumberIndexer || declaredStringIndexer; - if (!errorNode && (type.flags & 2048)) { - var someBaseTypeHasBothIndexers = ts.forEach(getBaseTypes(type), function (base) { return getIndexTypeOfType(base, 0) && getIndexTypeOfType(base, 1); }); - errorNode = someBaseTypeHasBothIndexers ? undefined : type.symbol.declarations[0]; - } - } - if (errorNode && !isTypeAssignableTo(numberIndexType, stringIndexType)) { - error(errorNode, ts.Diagnostics.Numeric_index_type_0_is_not_assignable_to_string_index_type_1, typeToString(numberIndexType), typeToString(stringIndexType)); - } - function checkIndexConstraintForProperty(prop, propertyType, containingType, indexDeclaration, indexType, indexKind) { - if (!indexType) { - return; - } - if (indexKind === 1 && !isNumericName(prop.valueDeclaration.name)) { - return; - } - var errorNode; - if (prop.valueDeclaration.name.kind === 136 || prop.parent === containingType.symbol) { - errorNode = prop.valueDeclaration; - } - else if (indexDeclaration) { - errorNode = indexDeclaration; - } - else if (containingType.flags & 2048) { - var someBaseClassHasBothPropertyAndIndexer = ts.forEach(getBaseTypes(containingType), function (base) { return getPropertyOfObjectType(base, prop.name) && getIndexTypeOfType(base, indexKind); }); - errorNode = someBaseClassHasBothPropertyAndIndexer ? undefined : containingType.symbol.declarations[0]; - } - if (errorNode && !isTypeAssignableTo(propertyType, indexType)) { - var errorMessage = indexKind === 0 - ? ts.Diagnostics.Property_0_of_type_1_is_not_assignable_to_string_index_type_2 - : ts.Diagnostics.Property_0_of_type_1_is_not_assignable_to_numeric_index_type_2; - error(errorNode, errorMessage, symbolToString(prop), typeToString(propertyType), typeToString(indexType)); - } - } - } - function checkTypeNameIsReserved(name, message) { - switch (name.text) { - case "any": - case "number": - case "boolean": - case "string": - case "symbol": - case "void": - error(name, message, name.text); - } - } - function checkTypeParameters(typeParameterDeclarations) { - if (typeParameterDeclarations) { - for (var i = 0, n = typeParameterDeclarations.length; i < n; i++) { - var node = typeParameterDeclarations[i]; - checkTypeParameter(node); - if (produceDiagnostics) { - for (var j = 0; j < i; j++) { - if (typeParameterDeclarations[j].symbol === node.symbol) { - error(node.name, ts.Diagnostics.Duplicate_identifier_0, ts.declarationNameToString(node.name)); - } - } - } - } - } - } - function checkClassExpression(node) { - checkClassLikeDeclaration(node); - return getTypeOfSymbol(getSymbolOfNode(node)); - } - function checkClassDeclaration(node) { - if (!node.name && !(node.flags & 1024)) { - grammarErrorOnFirstToken(node, ts.Diagnostics.A_class_declaration_without_the_default_modifier_must_have_a_name); - } - checkClassLikeDeclaration(node); - ts.forEach(node.members, checkSourceElement); - } - function checkClassLikeDeclaration(node) { - checkGrammarClassDeclarationHeritageClauses(node); - checkDecorators(node); - if (node.name) { - checkTypeNameIsReserved(node.name, ts.Diagnostics.Class_name_cannot_be_0); - checkCollisionWithCapturedThisVariable(node, node.name); - checkCollisionWithRequireExportsInGeneratedCode(node, node.name); - } - checkTypeParameters(node.typeParameters); - checkExportsOnMergedDeclarations(node); - var symbol = getSymbolOfNode(node); - var type = getDeclaredTypeOfSymbol(symbol); - var typeWithThis = getTypeWithThisArgument(type); - var staticType = getTypeOfSymbol(symbol); - var baseTypeNode = ts.getClassExtendsHeritageClauseElement(node); - if (baseTypeNode) { - emitExtends = emitExtends || !ts.isInAmbientContext(node); - var baseTypes = getBaseTypes(type); - if (baseTypes.length && produceDiagnostics) { - var baseType = baseTypes[0]; - var staticBaseType = getBaseConstructorTypeOfClass(type); - checkSourceElement(baseTypeNode.expression); - if (baseTypeNode.typeArguments) { - ts.forEach(baseTypeNode.typeArguments, checkSourceElement); - for (var _i = 0, _a = getConstructorsForTypeArguments(staticBaseType, baseTypeNode.typeArguments); _i < _a.length; _i++) { - var constructor = _a[_i]; - if (!checkTypeArgumentConstraints(constructor.typeParameters, baseTypeNode.typeArguments)) { - break; - } - } - } - checkTypeAssignableTo(typeWithThis, getTypeWithThisArgument(baseType, type.thisType), node.name || node, ts.Diagnostics.Class_0_incorrectly_extends_base_class_1); - checkTypeAssignableTo(staticType, getTypeWithoutSignatures(staticBaseType), node.name || node, ts.Diagnostics.Class_static_side_0_incorrectly_extends_base_class_static_side_1); - if (!(staticBaseType.symbol && staticBaseType.symbol.flags & 32)) { - var constructors = getInstantiatedConstructorsForTypeArguments(staticBaseType, baseTypeNode.typeArguments); - if (ts.forEach(constructors, function (sig) { return getReturnTypeOfSignature(sig) !== baseType; })) { - error(baseTypeNode.expression, ts.Diagnostics.Base_constructors_must_all_have_the_same_return_type); - } - } - checkKindsOfPropertyMemberOverrides(type, baseType); - } - } - var implementedTypeNodes = ts.getClassImplementsHeritageClauseElements(node); - if (implementedTypeNodes) { - for (var _b = 0; _b < implementedTypeNodes.length; _b++) { - var typeRefNode = implementedTypeNodes[_b]; - if (!ts.isSupportedExpressionWithTypeArguments(typeRefNode)) { - error(typeRefNode.expression, ts.Diagnostics.A_class_can_only_implement_an_identifier_Slashqualified_name_with_optional_type_arguments); - } - checkTypeReferenceNode(typeRefNode); - if (produceDiagnostics) { - var t = getTypeFromTypeNode(typeRefNode); - if (t !== unknownType) { - var declaredType = (t.flags & 4096) ? t.target : t; - if (declaredType.flags & (1024 | 2048)) { - checkTypeAssignableTo(typeWithThis, getTypeWithThisArgument(t, type.thisType), node.name || node, ts.Diagnostics.Class_0_incorrectly_implements_interface_1); - } - else { - error(typeRefNode, ts.Diagnostics.A_class_may_only_implement_another_class_or_interface); - } - } - } - } - } - if (produceDiagnostics) { - checkIndexConstraints(type); - checkTypeForDuplicateIndexSignatures(node); - } - } - function getTargetSymbol(s) { - return s.flags & 16777216 ? getSymbolLinks(s).target : s; - } - function getClassLikeDeclarationOfSymbol(symbol) { - return ts.forEach(symbol.declarations, function (d) { return ts.isClassLike(d) ? d : undefined; }); - } - function checkKindsOfPropertyMemberOverrides(type, baseType) { - var baseProperties = getPropertiesOfObjectType(baseType); - for (var _i = 0; _i < baseProperties.length; _i++) { - var baseProperty = baseProperties[_i]; - var base = getTargetSymbol(baseProperty); - if (base.flags & 134217728) { - continue; - } - var derived = getTargetSymbol(getPropertyOfObjectType(type, base.name)); - var baseDeclarationFlags = getDeclarationFlagsFromSymbol(base); - ts.Debug.assert(!!derived, "derived should point to something, even if it is the base class' declaration."); - if (derived) { - if (derived === base) { - var derivedClassDecl = getClassLikeDeclarationOfSymbol(type.symbol); - if (baseDeclarationFlags & 256 && (!derivedClassDecl || !(derivedClassDecl.flags & 256))) { - if (derivedClassDecl.kind === 186) { - error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1, symbolToString(baseProperty), typeToString(baseType)); - } - else { - error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_0_does_not_implement_inherited_abstract_member_1_from_class_2, typeToString(type), symbolToString(baseProperty), typeToString(baseType)); - } - } - } - else { - var derivedDeclarationFlags = getDeclarationFlagsFromSymbol(derived); - if ((baseDeclarationFlags & 32) || (derivedDeclarationFlags & 32)) { - continue; - } - if ((baseDeclarationFlags & 128) !== (derivedDeclarationFlags & 128)) { - continue; - } - if ((base.flags & derived.flags & 8192) || ((base.flags & 98308) && (derived.flags & 98308))) { - continue; - } - var errorMessage = void 0; - if (base.flags & 8192) { - if (derived.flags & 98304) { - errorMessage = ts.Diagnostics.Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_accessor; - } - else { - ts.Debug.assert((derived.flags & 4) !== 0); - errorMessage = ts.Diagnostics.Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_property; - } - } - else if (base.flags & 4) { - ts.Debug.assert((derived.flags & 8192) !== 0); - errorMessage = ts.Diagnostics.Class_0_defines_instance_member_property_1_but_extended_class_2_defines_it_as_instance_member_function; - } - else { - ts.Debug.assert((base.flags & 98304) !== 0); - ts.Debug.assert((derived.flags & 8192) !== 0); - errorMessage = ts.Diagnostics.Class_0_defines_instance_member_accessor_1_but_extended_class_2_defines_it_as_instance_member_function; - } - error(derived.valueDeclaration.name, errorMessage, typeToString(baseType), symbolToString(base), typeToString(type)); - } - } - } - } - function isAccessor(kind) { - return kind === 145 || kind === 146; - } - function areTypeParametersIdentical(list1, list2) { - if (!list1 && !list2) { - return true; - } - if (!list1 || !list2 || list1.length !== list2.length) { - return false; - } - for (var i = 0, len = list1.length; i < len; i++) { - var tp1 = list1[i]; - var tp2 = list2[i]; - if (tp1.name.text !== tp2.name.text) { - return false; - } - if (!tp1.constraint && !tp2.constraint) { - continue; - } - if (!tp1.constraint || !tp2.constraint) { - return false; - } - if (!isTypeIdenticalTo(getTypeFromTypeNode(tp1.constraint), getTypeFromTypeNode(tp2.constraint))) { - return false; - } - } - return true; - } - function checkInheritedPropertiesAreIdentical(type, typeNode) { - var baseTypes = getBaseTypes(type); - if (baseTypes.length < 2) { - return true; - } - var seen = {}; - ts.forEach(resolveDeclaredMembers(type).declaredProperties, function (p) { seen[p.name] = { prop: p, containingType: type }; }); - var ok = true; - for (var _i = 0; _i < baseTypes.length; _i++) { - var base = baseTypes[_i]; - var properties = getPropertiesOfObjectType(getTypeWithThisArgument(base, type.thisType)); - for (var _a = 0; _a < properties.length; _a++) { - var prop = properties[_a]; - if (!ts.hasProperty(seen, prop.name)) { - seen[prop.name] = { prop: prop, containingType: base }; - } - else { - var existing = seen[prop.name]; - var isInheritedProperty = existing.containingType !== type; - if (isInheritedProperty && !isPropertyIdenticalTo(existing.prop, prop)) { - ok = false; - var typeName1 = typeToString(existing.containingType); - var typeName2 = typeToString(base); - var errorInfo = ts.chainDiagnosticMessages(undefined, ts.Diagnostics.Named_property_0_of_types_1_and_2_are_not_identical, symbolToString(prop), typeName1, typeName2); - errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.Interface_0_cannot_simultaneously_extend_types_1_and_2, typeToString(type), typeName1, typeName2); - diagnostics.add(ts.createDiagnosticForNodeFromMessageChain(typeNode, errorInfo)); - } - } - } - } - return ok; - } - function checkInterfaceDeclaration(node) { - checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarInterfaceDeclaration(node); - checkTypeParameters(node.typeParameters); - if (produceDiagnostics) { - checkTypeNameIsReserved(node.name, ts.Diagnostics.Interface_name_cannot_be_0); - checkExportsOnMergedDeclarations(node); - var symbol = getSymbolOfNode(node); - var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 215); - if (symbol.declarations.length > 1) { - if (node !== firstInterfaceDecl && !areTypeParametersIdentical(firstInterfaceDecl.typeParameters, node.typeParameters)) { - error(node.name, ts.Diagnostics.All_declarations_of_an_interface_must_have_identical_type_parameters); - } - } - if (node === firstInterfaceDecl) { - var type = getDeclaredTypeOfSymbol(symbol); - var typeWithThis = getTypeWithThisArgument(type); - if (checkInheritedPropertiesAreIdentical(type, node.name)) { - for (var _i = 0, _a = getBaseTypes(type); _i < _a.length; _i++) { - var baseType = _a[_i]; - checkTypeAssignableTo(typeWithThis, getTypeWithThisArgument(baseType, type.thisType), node.name, ts.Diagnostics.Interface_0_incorrectly_extends_interface_1); - } - checkIndexConstraints(type); - } - } - } - ts.forEach(ts.getInterfaceBaseTypeNodes(node), function (heritageElement) { - if (!ts.isSupportedExpressionWithTypeArguments(heritageElement)) { - error(heritageElement.expression, ts.Diagnostics.An_interface_can_only_extend_an_identifier_Slashqualified_name_with_optional_type_arguments); - } - checkTypeReferenceNode(heritageElement); - }); - ts.forEach(node.members, checkSourceElement); - if (produceDiagnostics) { - checkTypeForDuplicateIndexSignatures(node); - } - } - function checkTypeAliasDeclaration(node) { - checkGrammarDecorators(node) || checkGrammarModifiers(node); - checkTypeNameIsReserved(node.name, ts.Diagnostics.Type_alias_name_cannot_be_0); - checkSourceElement(node.type); - } - function computeEnumMemberValues(node) { - var nodeLinks = getNodeLinks(node); - if (!(nodeLinks.flags & 8192)) { - var enumSymbol = getSymbolOfNode(node); - var enumType = getDeclaredTypeOfSymbol(enumSymbol); - var autoValue = 0; - var ambient = ts.isInAmbientContext(node); - var enumIsConst = ts.isConst(node); - for (var _i = 0, _a = node.members; _i < _a.length; _i++) { - var member = _a[_i]; - if (member.name.kind === 136) { - error(member.name, ts.Diagnostics.Computed_property_names_are_not_allowed_in_enums); - } - else if (isNumericLiteralName(member.name.text)) { - error(member.name, ts.Diagnostics.An_enum_member_cannot_have_a_numeric_name); - } - var previousEnumMemberIsNonConstant = autoValue === undefined; - var initializer = member.initializer; - if (initializer) { - autoValue = computeConstantValueForEnumMemberInitializer(initializer, enumType, enumIsConst, ambient); - } - else if (ambient && !enumIsConst) { - autoValue = undefined; - } - else if (previousEnumMemberIsNonConstant) { - error(member.name, ts.Diagnostics.Enum_member_must_have_initializer); - } - if (autoValue !== undefined) { - getNodeLinks(member).enumMemberValue = autoValue++; - } - } - nodeLinks.flags |= 8192; - } - function computeConstantValueForEnumMemberInitializer(initializer, enumType, enumIsConst, ambient) { - var reportError = true; - var value = evalConstant(initializer); - if (reportError) { - if (value === undefined) { - if (enumIsConst) { - error(initializer, ts.Diagnostics.In_const_enum_declarations_member_initializer_must_be_constant_expression); - } - else if (ambient) { - error(initializer, ts.Diagnostics.In_ambient_enum_declarations_member_initializer_must_be_constant_expression); - } - else { - checkTypeAssignableTo(checkExpression(initializer), enumType, initializer, undefined); - } - } - else if (enumIsConst) { - if (isNaN(value)) { - error(initializer, ts.Diagnostics.const_enum_member_initializer_was_evaluated_to_disallowed_value_NaN); - } - else if (!isFinite(value)) { - error(initializer, ts.Diagnostics.const_enum_member_initializer_was_evaluated_to_a_non_finite_value); - } - } - } - return value; - function evalConstant(e) { - switch (e.kind) { - case 179: - 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; - } - return undefined; - case 181: - var left = evalConstant(e.left); - if (left === undefined) { - return undefined; - } - var right = evalConstant(e.right); - if (right === undefined) { - 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; - } - return undefined; - case 8: - return +e.text; - case 172: - return evalConstant(e.expression); - case 69: - case 167: - case 166: - var member = initializer.parent; - var currentType = getTypeOfSymbol(getSymbolOfNode(member.parent)); - var enumType_1; - var propertyName; - if (e.kind === 69) { - enumType_1 = currentType; - propertyName = e.text; - } - else { - var expression; - if (e.kind === 167) { - if (e.argumentExpression === undefined || - e.argumentExpression.kind !== 9) { - return undefined; - } - expression = e.expression; - propertyName = e.argumentExpression.text; - } - else { - expression = e.expression; - propertyName = e.name.text; - } - var current = expression; - while (current) { - if (current.kind === 69) { - break; - } - else if (current.kind === 166) { - current = current.expression; - } - else { - return undefined; - } - } - enumType_1 = checkExpression(expression); - if (!(enumType_1.symbol && (enumType_1.symbol.flags & 384))) { - return undefined; - } - } - if (propertyName === undefined) { - return undefined; - } - var property = getPropertyOfObjectType(enumType_1, propertyName); - if (!property || !(property.flags & 8)) { - return undefined; - } - var propertyDecl = property.valueDeclaration; - if (member === propertyDecl) { - return undefined; - } - if (!isBlockScopedNameDeclaredBeforeUse(propertyDecl, member)) { - reportError = false; - error(e, ts.Diagnostics.A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_enums); - return undefined; - } - return getNodeLinks(propertyDecl).enumMemberValue; - } - } - } - } - function checkEnumDeclaration(node) { - if (!produceDiagnostics) { - return; - } - checkGrammarDecorators(node) || checkGrammarModifiers(node); - checkTypeNameIsReserved(node.name, ts.Diagnostics.Enum_name_cannot_be_0); - checkCollisionWithCapturedThisVariable(node, node.name); - checkCollisionWithRequireExportsInGeneratedCode(node, node.name); - checkExportsOnMergedDeclarations(node); - computeEnumMemberValues(node); - var enumIsConst = ts.isConst(node); - if (compilerOptions.isolatedModules && enumIsConst && ts.isInAmbientContext(node)) { - error(node.name, ts.Diagnostics.Ambient_const_enums_are_not_allowed_when_the_isolatedModules_flag_is_provided); - } - var enumSymbol = getSymbolOfNode(node); - var firstDeclaration = ts.getDeclarationOfKind(enumSymbol, node.kind); - if (node === firstDeclaration) { - if (enumSymbol.declarations.length > 1) { - ts.forEach(enumSymbol.declarations, function (decl) { - if (ts.isConstEnumDeclaration(decl) !== enumIsConst) { - error(decl.name, ts.Diagnostics.Enum_declarations_must_all_be_const_or_non_const); - } - }); - } - var seenEnumMissingInitialInitializer = false; - ts.forEach(enumSymbol.declarations, function (declaration) { - if (declaration.kind !== 217) { - return false; - } - var enumDeclaration = declaration; - if (!enumDeclaration.members.length) { - return false; - } - var firstEnumMember = enumDeclaration.members[0]; - if (!firstEnumMember.initializer) { - if (seenEnumMissingInitialInitializer) { - error(firstEnumMember.name, ts.Diagnostics.In_an_enum_with_multiple_declarations_only_one_declaration_can_omit_an_initializer_for_its_first_enum_element); - } - else { - seenEnumMissingInitialInitializer = true; - } - } - }); - } - } - function getFirstNonAmbientClassOrFunctionDeclaration(symbol) { - var declarations = symbol.declarations; - for (var _i = 0; _i < declarations.length; _i++) { - var declaration = declarations[_i]; - if ((declaration.kind === 214 || - (declaration.kind === 213 && ts.nodeIsPresent(declaration.body))) && - !ts.isInAmbientContext(declaration)) { - return declaration; - } - } - return undefined; - } - function inSameLexicalScope(node1, node2) { - var container1 = ts.getEnclosingBlockScopeContainer(node1); - var container2 = ts.getEnclosingBlockScopeContainer(node2); - if (isGlobalSourceFile(container1)) { - return isGlobalSourceFile(container2); - } - else if (isGlobalSourceFile(container2)) { - return false; - } - else { - return container1 === container2; - } - } - function checkModuleDeclaration(node) { - if (produceDiagnostics) { - var isAmbientExternalModule = node.name.kind === 9; - var contextErrorMessage = isAmbientExternalModule - ? ts.Diagnostics.An_ambient_module_declaration_is_only_allowed_at_the_top_level_in_a_file - : ts.Diagnostics.A_namespace_declaration_is_only_allowed_in_a_namespace_or_module; - if (checkGrammarModuleElementContext(node, contextErrorMessage)) { - return; - } - if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node)) { - if (!ts.isInAmbientContext(node) && node.name.kind === 9) { - grammarErrorOnNode(node.name, ts.Diagnostics.Only_ambient_modules_can_use_quoted_names); - } - } - checkCollisionWithCapturedThisVariable(node, node.name); - checkCollisionWithRequireExportsInGeneratedCode(node, node.name); - checkExportsOnMergedDeclarations(node); - var symbol = getSymbolOfNode(node); - if (symbol.flags & 512 - && symbol.declarations.length > 1 - && !ts.isInAmbientContext(node) - && ts.isInstantiatedModule(node, compilerOptions.preserveConstEnums || compilerOptions.isolatedModules)) { - var firstNonAmbientClassOrFunc = getFirstNonAmbientClassOrFunctionDeclaration(symbol); - if (firstNonAmbientClassOrFunc) { - if (ts.getSourceFileOfNode(node) !== ts.getSourceFileOfNode(firstNonAmbientClassOrFunc)) { - error(node.name, ts.Diagnostics.A_namespace_declaration_cannot_be_in_a_different_file_from_a_class_or_function_with_which_it_is_merged); - } - else if (node.pos < firstNonAmbientClassOrFunc.pos) { - 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, 214); - if (mergedClass && - inSameLexicalScope(node, mergedClass)) { - getNodeLinks(node).flags |= 32768; - } - } - if (isAmbientExternalModule) { - if (!isGlobalSourceFile(node.parent)) { - error(node.name, ts.Diagnostics.Ambient_modules_cannot_be_nested_in_other_modules_or_namespaces); - } - if (ts.isExternalModuleNameRelative(node.name.text)) { - error(node.name, ts.Diagnostics.Ambient_module_declaration_cannot_specify_relative_module_name); - } - } - } - checkSourceElement(node.body); - } - function getFirstIdentifier(node) { - while (true) { - if (node.kind === 135) { - node = node.left; - } - else if (node.kind === 166) { - node = node.expression; - } - else { - break; - } - } - ts.Debug.assert(node.kind === 69); - return node; - } - function checkExternalImportOrExportDeclaration(node) { - var moduleName = ts.getExternalModuleName(node); - if (!ts.nodeIsMissing(moduleName) && moduleName.kind !== 9) { - error(moduleName, ts.Diagnostics.String_literal_expected); - return false; - } - var inAmbientExternalModule = node.parent.kind === 219 && node.parent.parent.name.kind === 9; - if (node.parent.kind !== 248 && !inAmbientExternalModule) { - error(moduleName, node.kind === 228 ? - ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace : - ts.Diagnostics.Import_declarations_in_a_namespace_cannot_reference_a_module); - return false; - } - if (inAmbientExternalModule && ts.isExternalModuleNameRelative(moduleName.text)) { - error(node, ts.Diagnostics.Import_or_export_declaration_in_an_ambient_module_declaration_cannot_reference_module_through_relative_module_name); - return false; - } - return true; - } - function checkAliasSymbol(node) { - var symbol = getSymbolOfNode(node); - var target = resolveAlias(symbol); - if (target !== unknownSymbol) { - var excludedMeanings = (symbol.flags & 107455 ? 107455 : 0) | - (symbol.flags & 793056 ? 793056 : 0) | - (symbol.flags & 1536 ? 1536 : 0); - if (target.flags & excludedMeanings) { - var message = node.kind === 230 ? - ts.Diagnostics.Export_declaration_conflicts_with_exported_declaration_of_0 : - ts.Diagnostics.Import_declaration_conflicts_with_local_declaration_of_0; - error(node, message, symbolToString(symbol)); - } - } - } - function checkImportBinding(node) { - checkCollisionWithCapturedThisVariable(node, node.name); - checkCollisionWithRequireExportsInGeneratedCode(node, node.name); - checkAliasSymbol(node); - } - function checkImportDeclaration(node) { - if (checkGrammarModuleElementContext(node, ts.Diagnostics.An_import_declaration_can_only_be_used_in_a_namespace_or_module)) { - return; - } - if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && (node.flags & 2035)) { - grammarErrorOnFirstToken(node, ts.Diagnostics.An_import_declaration_cannot_have_modifiers); - } - if (checkExternalImportOrExportDeclaration(node)) { - var importClause = node.importClause; - if (importClause) { - if (importClause.name) { - checkImportBinding(importClause); - } - if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 224) { - checkImportBinding(importClause.namedBindings); - } - else { - ts.forEach(importClause.namedBindings.elements, checkImportBinding); - } - } - } - } - } - function checkImportEqualsDeclaration(node) { - if (checkGrammarModuleElementContext(node, ts.Diagnostics.An_import_declaration_can_only_be_used_in_a_namespace_or_module)) { - return; - } - checkGrammarDecorators(node) || checkGrammarModifiers(node); - if (ts.isInternalModuleImportEqualsDeclaration(node) || checkExternalImportOrExportDeclaration(node)) { - checkImportBinding(node); - if (node.flags & 1) { - markExportAsReferenced(node); - } - if (ts.isInternalModuleImportEqualsDeclaration(node)) { - var target = resolveAlias(getSymbolOfNode(node)); - if (target !== unknownSymbol) { - if (target.flags & 107455) { - var moduleName = getFirstIdentifier(node.moduleReference); - if (!(resolveEntityName(moduleName, 107455 | 1536).flags & 1536)) { - error(moduleName, ts.Diagnostics.Module_0_is_hidden_by_a_local_declaration_with_the_same_name, ts.declarationNameToString(moduleName)); - } - } - if (target.flags & 793056) { - checkTypeNameIsReserved(node.name, ts.Diagnostics.Import_name_cannot_be_0); - } - } - } - else { - if (modulekind === 5 && !ts.isInAmbientContext(node)) { - grammarErrorOnNode(node, ts.Diagnostics.Import_assignment_cannot_be_used_when_targeting_ECMAScript_6_modules_Consider_using_import_Asterisk_as_ns_from_mod_import_a_from_mod_import_d_from_mod_or_another_module_format_instead); - } - } - } - } - function checkExportDeclaration(node) { - if (checkGrammarModuleElementContext(node, ts.Diagnostics.An_export_declaration_can_only_be_used_in_a_module)) { - return; - } - if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && (node.flags & 2035)) { - grammarErrorOnFirstToken(node, ts.Diagnostics.An_export_declaration_cannot_have_modifiers); - } - if (!node.moduleSpecifier || checkExternalImportOrExportDeclaration(node)) { - if (node.exportClause) { - ts.forEach(node.exportClause.elements, checkExportSpecifier); - var inAmbientExternalModule = node.parent.kind === 219 && node.parent.parent.name.kind === 9; - if (node.parent.kind !== 248 && !inAmbientExternalModule) { - error(node, ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace); - } - } - else { - var moduleSymbol = resolveExternalModuleName(node, node.moduleSpecifier); - if (moduleSymbol && moduleSymbol.exports["export="]) { - error(node.moduleSpecifier, ts.Diagnostics.Module_0_uses_export_and_cannot_be_used_with_export_Asterisk, symbolToString(moduleSymbol)); - } - } - } - } - function checkGrammarModuleElementContext(node, errorMessage) { - if (node.parent.kind !== 248 && node.parent.kind !== 219 && node.parent.kind !== 218) { - return grammarErrorOnFirstToken(node, errorMessage); - } - } - function checkExportSpecifier(node) { - checkAliasSymbol(node); - if (!node.parent.parent.moduleSpecifier) { - markExportAsReferenced(node); - } - } - function checkExportAssignment(node) { - if (checkGrammarModuleElementContext(node, ts.Diagnostics.An_export_assignment_can_only_be_used_in_a_module)) { - return; - } - var container = node.parent.kind === 248 ? node.parent : node.parent.parent; - if (container.kind === 218 && container.name.kind === 69) { - error(node, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_namespace); - return; - } - if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && (node.flags & 2035)) { - grammarErrorOnFirstToken(node, ts.Diagnostics.An_export_assignment_cannot_have_modifiers); - } - if (node.expression.kind === 69) { - markExportAsReferenced(node); - } - else { - checkExpressionCached(node.expression); - } - checkExternalModuleExports(container); - if (node.isExportEquals && !ts.isInAmbientContext(node)) { - if (modulekind === 5) { - grammarErrorOnNode(node, ts.Diagnostics.Export_assignment_cannot_be_used_when_targeting_ECMAScript_6_modules_Consider_using_export_default_or_another_module_format_instead); - } - else if (modulekind === 4) { - grammarErrorOnNode(node, ts.Diagnostics.Export_assignment_is_not_supported_when_module_flag_is_system); - } - } - } - function getModuleStatements(node) { - if (node.kind === 248) { - return node.statements; - } - if (node.kind === 218 && node.body.kind === 219) { - return node.body.statements; - } - return emptyArray; - } - function hasExportedMembers(moduleSymbol) { - for (var id in moduleSymbol.exports) { - if (id !== "export=") { - return true; - } - } - return false; - } - function checkExternalModuleExports(node) { - var moduleSymbol = getSymbolOfNode(node); - var links = getSymbolLinks(moduleSymbol); - if (!links.exportsChecked) { - var exportEqualsSymbol = moduleSymbol.exports["export="]; - if (exportEqualsSymbol && hasExportedMembers(moduleSymbol)) { - var declaration = getDeclarationOfAliasSymbol(exportEqualsSymbol) || exportEqualsSymbol.valueDeclaration; - error(declaration, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_module_with_other_exported_elements); - } - links.exportsChecked = true; - } - } - function checkTypePredicate(node) { - if (!isInLegalTypePredicatePosition(node)) { - error(node, ts.Diagnostics.A_type_predicate_is_only_allowed_in_return_type_position_for_functions_and_methods); - } - } - function checkSourceElement(node) { - if (!node) { - return; - } - var kind = node.kind; - if (cancellationToken) { - switch (kind) { - case 218: - case 214: - case 215: - case 213: - cancellationToken.throwIfCancellationRequested(); - } - } - switch (kind) { - case 137: - return checkTypeParameter(node); - case 138: - return checkParameter(node); - case 141: - case 140: - return checkPropertyDeclaration(node); - case 152: - case 153: - case 147: - case 148: - return checkSignatureDeclaration(node); - case 149: - return checkSignatureDeclaration(node); - case 143: - case 142: - return checkMethodDeclaration(node); - case 144: - return checkConstructorDeclaration(node); - case 145: - case 146: - return checkAccessorDeclaration(node); - case 151: - return checkTypeReferenceNode(node); - case 150: - return checkTypePredicate(node); - case 154: - return checkTypeQuery(node); - case 155: - return checkTypeLiteral(node); - case 156: - return checkArrayType(node); - case 157: - return checkTupleType(node); - case 158: - case 159: - return checkUnionOrIntersectionType(node); - case 160: - return checkSourceElement(node.type); - case 213: - return checkFunctionDeclaration(node); - case 192: - case 219: - return checkBlock(node); - case 193: - return checkVariableStatement(node); - case 195: - return checkExpressionStatement(node); - case 196: - return checkIfStatement(node); - case 197: - return checkDoStatement(node); - case 198: - return checkWhileStatement(node); - case 199: - return checkForStatement(node); - case 200: - return checkForInStatement(node); - case 201: - return checkForOfStatement(node); - case 202: - case 203: - return checkBreakOrContinueStatement(node); - case 204: - return checkReturnStatement(node); - case 205: - return checkWithStatement(node); - case 206: - return checkSwitchStatement(node); - case 207: - return checkLabeledStatement(node); - case 208: - return checkThrowStatement(node); - case 209: - return checkTryStatement(node); - case 211: - return checkVariableDeclaration(node); - case 163: - return checkBindingElement(node); - case 214: - return checkClassDeclaration(node); - case 215: - return checkInterfaceDeclaration(node); - case 216: - return checkTypeAliasDeclaration(node); - case 217: - return checkEnumDeclaration(node); - case 218: - return checkModuleDeclaration(node); - case 222: - return checkImportDeclaration(node); - case 221: - return checkImportEqualsDeclaration(node); - case 228: - return checkExportDeclaration(node); - case 227: - return checkExportAssignment(node); - case 194: - checkGrammarStatementInAmbientContext(node); - return; - case 210: - checkGrammarStatementInAmbientContext(node); - return; - case 231: - return checkMissingDeclaration(node); - } - } - function checkFunctionAndClassExpressionBodies(node) { - switch (node.kind) { - case 173: - case 174: - ts.forEach(node.parameters, checkFunctionAndClassExpressionBodies); - checkFunctionExpressionOrObjectLiteralMethodBody(node); - break; - case 186: - ts.forEach(node.members, checkSourceElement); - ts.forEachChild(node, checkFunctionAndClassExpressionBodies); - break; - case 143: - case 142: - ts.forEach(node.decorators, checkFunctionAndClassExpressionBodies); - ts.forEach(node.parameters, checkFunctionAndClassExpressionBodies); - if (ts.isObjectLiteralMethod(node)) { - checkFunctionExpressionOrObjectLiteralMethodBody(node); - } - break; - case 144: - case 145: - case 146: - case 213: - ts.forEach(node.parameters, checkFunctionAndClassExpressionBodies); - break; - case 205: - checkFunctionAndClassExpressionBodies(node.expression); - break; - case 139: - case 138: - case 141: - case 140: - case 161: - case 162: - case 163: - case 164: - case 165: - case 245: - case 166: - case 167: - case 168: - case 169: - case 170: - case 183: - case 190: - case 171: - case 189: - case 172: - case 176: - case 177: - case 178: - case 175: - case 179: - case 180: - case 181: - case 182: - case 185: - case 184: - case 192: - case 219: - case 193: - case 195: - case 196: - case 197: - case 198: - case 199: - case 200: - case 201: - case 202: - case 203: - case 204: - case 206: - case 220: - case 241: - case 242: - case 207: - case 208: - case 209: - case 244: - case 211: - case 212: - case 214: - case 243: - case 188: - case 217: - case 247: - case 227: - case 248: - case 240: - case 233: - case 234: - case 238: - case 239: - case 235: - ts.forEachChild(node, checkFunctionAndClassExpressionBodies); - break; - } - } - function checkSourceFile(node) { - var start = new Date().getTime(); - checkSourceFileWorker(node); - ts.checkTime += new Date().getTime() - start; - } - function checkSourceFileWorker(node) { - var links = getNodeLinks(node); - if (!(links.flags & 1)) { - if (node.isDefaultLib && compilerOptions.skipDefaultLibCheck) { - return; - } - checkGrammarSourceFile(node); - emitExtends = false; - emitDecorate = false; - emitParam = false; - potentialThisCollisions.length = 0; - ts.forEach(node.statements, checkSourceElement); - checkFunctionAndClassExpressionBodies(node); - if (ts.isExternalModule(node)) { - checkExternalModuleExports(node); - } - if (potentialThisCollisions.length) { - ts.forEach(potentialThisCollisions, checkIfThisIsCapturedInEnclosingScope); - potentialThisCollisions.length = 0; - } - if (emitExtends) { - links.flags |= 8; - } - if (emitDecorate) { - links.flags |= 16; - } - if (emitParam) { - links.flags |= 32; - } - if (emitAwaiter) { - links.flags |= 64; - } - if (emitGenerator || (emitAwaiter && languageVersion < 2)) { - links.flags |= 128; - } - links.flags |= 1; - } - } - function getDiagnostics(sourceFile, ct) { - try { - cancellationToken = ct; - return getDiagnosticsWorker(sourceFile); - } - finally { - cancellationToken = undefined; - } - } - function getDiagnosticsWorker(sourceFile) { - throwIfNonDiagnosticsProducing(); - if (sourceFile) { - checkSourceFile(sourceFile); - return diagnostics.getDiagnostics(sourceFile.fileName); - } - ts.forEach(host.getSourceFiles(), checkSourceFile); - return diagnostics.getDiagnostics(); - } - function getGlobalDiagnostics() { - throwIfNonDiagnosticsProducing(); - return diagnostics.getGlobalDiagnostics(); - } - function throwIfNonDiagnosticsProducing() { - if (!produceDiagnostics) { - throw new Error("Trying to get diagnostics from a type checker that does not produce them."); - } - } - function isInsideWithStatementBody(node) { - if (node) { - while (node.parent) { - if (node.parent.kind === 205 && node.parent.statement === node) { - return true; - } - node = node.parent; - } - } - return false; - } - function getSymbolsInScope(location, meaning) { - var symbols = {}; - var memberFlags = 0; - if (isInsideWithStatementBody(location)) { - return []; - } - populateSymbols(); - return symbolsToArray(symbols); - function populateSymbols() { - while (location) { - if (location.locals && !isGlobalSourceFile(location)) { - copySymbols(location.locals, meaning); - } - switch (location.kind) { - case 248: - if (!ts.isExternalModule(location)) { - break; - } - case 218: - copySymbols(getSymbolOfNode(location).exports, meaning & 8914931); - break; - case 217: - copySymbols(getSymbolOfNode(location).exports, meaning & 8); - break; - case 186: - var className = location.name; - if (className) { - copySymbol(location.symbol, meaning); - } - case 214: - case 215: - if (!(memberFlags & 128)) { - copySymbols(getSymbolOfNode(location).members, meaning & 793056); - } - break; - case 173: - var funcName = location.name; - if (funcName) { - copySymbol(location.symbol, meaning); - } - break; - } - if (ts.introducesArgumentsExoticObject(location)) { - copySymbol(argumentsSymbol, meaning); - } - memberFlags = location.flags; - location = location.parent; - } - copySymbols(globals, meaning); - } - function copySymbol(symbol, meaning) { - if (symbol.flags & meaning) { - var id = symbol.name; - if (!ts.hasProperty(symbols, id)) { - symbols[id] = symbol; - } - } - } - function copySymbols(source, meaning) { - if (meaning) { - for (var id in source) { - var symbol = source[id]; - copySymbol(symbol, meaning); - } - } - } - } - function isTypeDeclarationName(name) { - return name.kind === 69 && - isTypeDeclaration(name.parent) && - name.parent.name === name; - } - function isTypeDeclaration(node) { - switch (node.kind) { - case 137: - case 214: - case 215: - case 216: - case 217: - return true; - } - } - function isTypeReferenceIdentifier(entityName) { - var node = entityName; - while (node.parent && node.parent.kind === 135) { - node = node.parent; - } - return node.parent && node.parent.kind === 151; - } - function isHeritageClauseElementIdentifier(entityName) { - var node = entityName; - while (node.parent && node.parent.kind === 166) { - node = node.parent; - } - return node.parent && node.parent.kind === 188; - } - function getLeftSideOfImportEqualsOrExportAssignment(nodeOnRightSide) { - while (nodeOnRightSide.parent.kind === 135) { - nodeOnRightSide = nodeOnRightSide.parent; - } - if (nodeOnRightSide.parent.kind === 221) { - return nodeOnRightSide.parent.moduleReference === nodeOnRightSide && nodeOnRightSide.parent; - } - if (nodeOnRightSide.parent.kind === 227) { - return nodeOnRightSide.parent.expression === nodeOnRightSide && nodeOnRightSide.parent; - } - return undefined; - } - function isInRightSideOfImportOrExportAssignment(node) { - return getLeftSideOfImportEqualsOrExportAssignment(node) !== undefined; - } - function getSymbolOfEntityNameOrPropertyAccessExpression(entityName) { - if (ts.isDeclarationName(entityName)) { - return getSymbolOfNode(entityName.parent); - } - if (entityName.parent.kind === 227) { - return resolveEntityName(entityName, 107455 | 793056 | 1536 | 8388608); - } - if (entityName.kind !== 166) { - if (isInRightSideOfImportOrExportAssignment(entityName)) { - return getSymbolOfPartOfRightHandSideOfImportEquals(entityName); - } - } - if (ts.isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { - entityName = entityName.parent; - } - if (isHeritageClauseElementIdentifier(entityName)) { - var meaning = 0; - if (entityName.parent.kind === 188) { - meaning = 793056; - if (ts.isExpressionWithTypeArgumentsInClassExtendsClause(entityName.parent)) { - meaning |= 107455; - } - } - else { - meaning = 1536; - } - meaning |= 8388608; - return resolveEntityName(entityName, meaning); - } - else if ((entityName.parent.kind === 235) || - (entityName.parent.kind === 234) || - (entityName.parent.kind === 237)) { - return getJsxElementTagSymbol(entityName.parent); - } - else if (ts.isExpression(entityName)) { - if (ts.nodeIsMissing(entityName)) { - return undefined; - } - if (entityName.kind === 69) { - var meaning = 107455 | 8388608; - return resolveEntityName(entityName, meaning); - } - else if (entityName.kind === 166) { - var symbol = getNodeLinks(entityName).resolvedSymbol; - if (!symbol) { - checkPropertyAccessExpression(entityName); - } - return getNodeLinks(entityName).resolvedSymbol; - } - else if (entityName.kind === 135) { - var symbol = getNodeLinks(entityName).resolvedSymbol; - if (!symbol) { - checkQualifiedName(entityName); - } - return getNodeLinks(entityName).resolvedSymbol; - } - } - else if (isTypeReferenceIdentifier(entityName)) { - var meaning = entityName.parent.kind === 151 ? 793056 : 1536; - meaning |= 8388608; - return resolveEntityName(entityName, meaning); - } - else if (entityName.parent.kind === 238) { - return getJsxAttributePropertySymbol(entityName.parent); - } - if (entityName.parent.kind === 150) { - return resolveEntityName(entityName, 1); - } - return undefined; - } - function getSymbolAtLocation(node) { - if (isInsideWithStatementBody(node)) { - return undefined; - } - if (ts.isDeclarationName(node)) { - return getSymbolOfNode(node.parent); - } - if (node.kind === 69) { - if (isInRightSideOfImportOrExportAssignment(node)) { - return node.parent.kind === 227 - ? getSymbolOfEntityNameOrPropertyAccessExpression(node) - : getSymbolOfPartOfRightHandSideOfImportEquals(node); - } - else if (node.parent.kind === 163 && - node.parent.parent.kind === 161 && - node === node.parent.propertyName) { - var typeOfPattern = getTypeOfNode(node.parent.parent); - var propertyDeclaration = typeOfPattern && getPropertyOfType(typeOfPattern, node.text); - if (propertyDeclaration) { - return propertyDeclaration; - } - } - } - switch (node.kind) { - case 69: - case 166: - case 135: - return getSymbolOfEntityNameOrPropertyAccessExpression(node); - case 97: - case 95: - var type = ts.isExpression(node) ? checkExpression(node) : getTypeFromTypeNode(node); - return type.symbol; - case 121: - var constructorDeclaration = node.parent; - if (constructorDeclaration && constructorDeclaration.kind === 144) { - return constructorDeclaration.parent.symbol; - } - return undefined; - case 9: - if ((ts.isExternalModuleImportEqualsDeclaration(node.parent.parent) && - ts.getExternalModuleImportEqualsDeclarationExpression(node.parent.parent) === node) || - ((node.parent.kind === 222 || node.parent.kind === 228) && - node.parent.moduleSpecifier === node)) { - return resolveExternalModuleName(node, node); - } - case 8: - if (node.parent.kind === 167 && node.parent.argumentExpression === node) { - var objectType = checkExpression(node.parent.expression); - if (objectType === unknownType) - return undefined; - var apparentType = getApparentType(objectType); - if (apparentType === unknownType) - return undefined; - return getPropertyOfType(apparentType, node.text); - } - break; - } - return undefined; - } - function getShorthandAssignmentValueSymbol(location) { - if (location && location.kind === 246) { - return resolveEntityName(location.name, 107455); - } - return undefined; - } - function getTypeOfNode(node) { - if (isInsideWithStatementBody(node)) { - return unknownType; - } - if (ts.isTypeNode(node)) { - return getTypeFromTypeNode(node); - } - if (ts.isExpression(node)) { - return getTypeOfExpression(node); - } - if (ts.isExpressionWithTypeArgumentsInClassExtendsClause(node)) { - return getBaseTypes(getDeclaredTypeOfSymbol(getSymbolOfNode(node.parent.parent)))[0]; - } - if (isTypeDeclaration(node)) { - var symbol = getSymbolOfNode(node); - return getDeclaredTypeOfSymbol(symbol); - } - if (isTypeDeclarationName(node)) { - var symbol = getSymbolAtLocation(node); - return symbol && getDeclaredTypeOfSymbol(symbol); - } - if (ts.isDeclaration(node)) { - var symbol = getSymbolOfNode(node); - return getTypeOfSymbol(symbol); - } - if (ts.isDeclarationName(node)) { - var symbol = getSymbolAtLocation(node); - return symbol && getTypeOfSymbol(symbol); - } - if (ts.isBindingPattern(node)) { - return getTypeForVariableLikeDeclaration(node.parent); - } - if (isInRightSideOfImportOrExportAssignment(node)) { - var symbol = getSymbolAtLocation(node); - var declaredType = symbol && getDeclaredTypeOfSymbol(symbol); - return declaredType !== unknownType ? declaredType : getTypeOfSymbol(symbol); - } - return unknownType; - } - function getTypeOfExpression(expr) { - if (ts.isRightSideOfQualifiedNameOrPropertyAccess(expr)) { - expr = expr.parent; - } - return checkExpression(expr); - } - function getParentTypeOfClassElement(node) { - var classSymbol = getSymbolOfNode(node.parent); - return node.flags & 128 - ? getTypeOfSymbol(classSymbol) - : getDeclaredTypeOfSymbol(classSymbol); - } - function getAugmentedPropertiesOfType(type) { - type = getApparentType(type); - var propsByName = createSymbolTable(getPropertiesOfType(type)); - if (getSignaturesOfType(type, 0).length || getSignaturesOfType(type, 1).length) { - ts.forEach(getPropertiesOfType(globalFunctionType), function (p) { - if (!ts.hasProperty(propsByName, p.name)) { - propsByName[p.name] = p; - } - }); - } - return getNamedMembers(propsByName); - } - function getRootSymbols(symbol) { - if (symbol.flags & 268435456) { - var symbols = []; - var name_16 = symbol.name; - ts.forEach(getSymbolLinks(symbol).containingType.types, function (t) { - var symbol = getPropertyOfType(t, name_16); - if (symbol) { - symbols.push(symbol); - } - }); - return symbols; - } - else if (symbol.flags & 67108864) { - var target = getSymbolLinks(symbol).target; - if (target) { - return [target]; - } - } - return [symbol]; - } - function getReferencedExportContainer(node) { - var symbol = getReferencedValueSymbol(node); - if (symbol) { - if (symbol.flags & 1048576) { - var exportSymbol = getMergedSymbol(symbol.exportSymbol); - if (exportSymbol.flags & 944) { - return undefined; - } - symbol = exportSymbol; - } - var parentSymbol = getParentOfSymbol(symbol); - if (parentSymbol) { - if (parentSymbol.flags & 512 && parentSymbol.valueDeclaration.kind === 248) { - return parentSymbol.valueDeclaration; - } - for (var n = node.parent; n; n = n.parent) { - if ((n.kind === 218 || n.kind === 217) && getSymbolOfNode(n) === parentSymbol) { - return n; - } - } - } - } - } - function getReferencedImportDeclaration(node) { - var symbol = getReferencedValueSymbol(node); - return symbol && symbol.flags & 8388608 ? getDeclarationOfAliasSymbol(symbol) : undefined; - } - function isStatementWithLocals(node) { - switch (node.kind) { - case 192: - case 220: - case 199: - case 200: - case 201: - return true; - } - return false; - } - function isNestedRedeclarationSymbol(symbol) { - if (symbol.flags & 418) { - var links = getSymbolLinks(symbol); - if (links.isNestedRedeclaration === undefined) { - var container = ts.getEnclosingBlockScopeContainer(symbol.valueDeclaration); - links.isNestedRedeclaration = isStatementWithLocals(container) && - !!resolveName(container.parent, symbol.name, 107455, undefined, undefined); - } - return links.isNestedRedeclaration; - } - return false; - } - function getReferencedNestedRedeclaration(node) { - var symbol = getReferencedValueSymbol(node); - return symbol && isNestedRedeclarationSymbol(symbol) ? symbol.valueDeclaration : undefined; - } - function isNestedRedeclaration(node) { - return isNestedRedeclarationSymbol(getSymbolOfNode(node)); - } - function isValueAliasDeclaration(node) { - switch (node.kind) { - case 221: - case 223: - case 224: - case 226: - case 230: - return isAliasResolvedToValue(getSymbolOfNode(node)); - case 228: - var exportClause = node.exportClause; - return exportClause && ts.forEach(exportClause.elements, isValueAliasDeclaration); - case 227: - return node.expression && node.expression.kind === 69 ? isAliasResolvedToValue(getSymbolOfNode(node)) : true; - } - return false; - } - function isTopLevelValueImportEqualsWithEntityName(node) { - if (node.parent.kind !== 248 || !ts.isInternalModuleImportEqualsDeclaration(node)) { - return false; - } - var isValue = isAliasResolvedToValue(getSymbolOfNode(node)); - return isValue && node.moduleReference && !ts.nodeIsMissing(node.moduleReference); - } - function isAliasResolvedToValue(symbol) { - var target = resolveAlias(symbol); - if (target === unknownSymbol && compilerOptions.isolatedModules) { - return true; - } - return target !== unknownSymbol && - target && - target.flags & 107455 && - (compilerOptions.preserveConstEnums || !isConstEnumOrConstEnumOnlyModule(target)); - } - function isConstEnumOrConstEnumOnlyModule(s) { - return isConstEnumSymbol(s) || s.constEnumOnlyModule; - } - function isReferencedAliasDeclaration(node, checkChildren) { - if (ts.isAliasSymbolDeclaration(node)) { - var symbol = getSymbolOfNode(node); - if (getSymbolLinks(symbol).referenced) { - return true; - } - } - if (checkChildren) { - return ts.forEachChild(node, function (node) { return isReferencedAliasDeclaration(node, checkChildren); }); - } - return false; - } - function isImplementationOfOverload(node) { - if (ts.nodeIsPresent(node.body)) { - var symbol = getSymbolOfNode(node); - var signaturesOfSymbol = getSignaturesOfSymbol(symbol); - return signaturesOfSymbol.length > 1 || - (signaturesOfSymbol.length === 1 && signaturesOfSymbol[0].declaration !== node); - } - return false; - } - function getNodeCheckFlags(node) { - return getNodeLinks(node).flags; - } - function getEnumMemberValue(node) { - computeEnumMemberValues(node.parent); - return getNodeLinks(node).enumMemberValue; - } - function getConstantValue(node) { - if (node.kind === 247) { - return getEnumMemberValue(node); - } - var symbol = getNodeLinks(node).resolvedSymbol; - if (symbol && (symbol.flags & 8)) { - if (ts.isConstEnumDeclaration(symbol.valueDeclaration.parent)) { - return getEnumMemberValue(symbol.valueDeclaration); - } - } - return undefined; - } - function isFunctionType(type) { - return type.flags & 80896 && getSignaturesOfType(type, 0).length > 0; - } - function getTypeReferenceSerializationKind(typeName) { - var valueSymbol = resolveEntityName(typeName, 107455, true); - var constructorType = valueSymbol ? getTypeOfSymbol(valueSymbol) : undefined; - if (constructorType && isConstructorType(constructorType)) { - return ts.TypeReferenceSerializationKind.TypeWithConstructSignatureAndValue; - } - var typeSymbol = resolveEntityName(typeName, 793056, true); - if (!typeSymbol) { - return ts.TypeReferenceSerializationKind.ObjectType; - } - var type = getDeclaredTypeOfSymbol(typeSymbol); - if (type === unknownType) { - return ts.TypeReferenceSerializationKind.Unknown; - } - else if (type.flags & 1) { - return ts.TypeReferenceSerializationKind.ObjectType; - } - else if (allConstituentTypesHaveKind(type, 16)) { - return ts.TypeReferenceSerializationKind.VoidType; - } - else if (allConstituentTypesHaveKind(type, 8)) { - return ts.TypeReferenceSerializationKind.BooleanType; - } - else if (allConstituentTypesHaveKind(type, 132)) { - return ts.TypeReferenceSerializationKind.NumberLikeType; - } - else if (allConstituentTypesHaveKind(type, 258)) { - return ts.TypeReferenceSerializationKind.StringLikeType; - } - else if (allConstituentTypesHaveKind(type, 8192)) { - return ts.TypeReferenceSerializationKind.ArrayLikeType; - } - else if (allConstituentTypesHaveKind(type, 16777216)) { - return ts.TypeReferenceSerializationKind.ESSymbolType; - } - else if (isFunctionType(type)) { - return ts.TypeReferenceSerializationKind.TypeWithCallSignature; - } - else if (isArrayType(type)) { - return ts.TypeReferenceSerializationKind.ArrayLikeType; - } - else { - return ts.TypeReferenceSerializationKind.ObjectType; - } - } - function writeTypeOfDeclaration(declaration, enclosingDeclaration, flags, writer) { - var symbol = getSymbolOfNode(declaration); - var type = symbol && !(symbol.flags & (2048 | 131072)) - ? getTypeOfSymbol(symbol) - : unknownType; - getSymbolDisplayBuilder().buildTypeDisplay(type, writer, enclosingDeclaration, flags); - } - function writeReturnTypeOfSignatureDeclaration(signatureDeclaration, enclosingDeclaration, flags, writer) { - var signature = getSignatureFromDeclaration(signatureDeclaration); - getSymbolDisplayBuilder().buildTypeDisplay(getReturnTypeOfSignature(signature), writer, enclosingDeclaration, flags); - } - function writeTypeOfExpression(expr, enclosingDeclaration, flags, writer) { - var type = getTypeOfExpression(expr); - getSymbolDisplayBuilder().buildTypeDisplay(type, writer, enclosingDeclaration, flags); - } - function hasGlobalName(name) { - return ts.hasProperty(globals, name); - } - function getReferencedValueSymbol(reference) { - return getNodeLinks(reference).resolvedSymbol || - resolveName(reference, reference.text, 107455 | 1048576 | 8388608, undefined, undefined); - } - function getReferencedValueDeclaration(reference) { - ts.Debug.assert(!ts.nodeIsSynthesized(reference)); - var symbol = getReferencedValueSymbol(reference); - return symbol && getExportSymbolOfValueSymbolIfExported(symbol).valueDeclaration; - } - function instantiateSingleCallFunctionType(functionType, typeArguments) { - if (functionType === unknownType) { - return unknownType; - } - var signature = getSingleCallSignature(functionType); - if (!signature) { - return unknownType; - } - var instantiatedSignature = getSignatureInstantiation(signature, typeArguments); - return getOrCreateTypeFromSignature(instantiatedSignature); - } - function createResolver() { - return { - getReferencedExportContainer: getReferencedExportContainer, - getReferencedImportDeclaration: getReferencedImportDeclaration, - getReferencedNestedRedeclaration: getReferencedNestedRedeclaration, - isNestedRedeclaration: isNestedRedeclaration, - isValueAliasDeclaration: isValueAliasDeclaration, - hasGlobalName: hasGlobalName, - isReferencedAliasDeclaration: isReferencedAliasDeclaration, - getNodeCheckFlags: getNodeCheckFlags, - isTopLevelValueImportEqualsWithEntityName: isTopLevelValueImportEqualsWithEntityName, - isDeclarationVisible: isDeclarationVisible, - isImplementationOfOverload: isImplementationOfOverload, - writeTypeOfDeclaration: writeTypeOfDeclaration, - writeReturnTypeOfSignatureDeclaration: writeReturnTypeOfSignatureDeclaration, - writeTypeOfExpression: writeTypeOfExpression, - isSymbolAccessible: isSymbolAccessible, - isEntityNameVisible: isEntityNameVisible, - getConstantValue: getConstantValue, - collectLinkedAliases: collectLinkedAliases, - getReferencedValueDeclaration: getReferencedValueDeclaration, - getTypeReferenceSerializationKind: getTypeReferenceSerializationKind, - isOptionalParameter: isOptionalParameter - }; - } - function initializeTypeChecker() { - ts.forEach(host.getSourceFiles(), function (file) { - ts.bindSourceFile(file); - }); - ts.forEach(host.getSourceFiles(), function (file) { - if (!ts.isExternalModule(file)) { - mergeSymbolTable(globals, file.locals); - } - }); - getSymbolLinks(undefinedSymbol).type = undefinedType; - getSymbolLinks(argumentsSymbol).type = getGlobalType("IArguments"); - getSymbolLinks(unknownSymbol).type = unknownType; - globals[undefinedSymbol.name] = undefinedSymbol; - globalArrayType = getGlobalType("Array", 1); - globalObjectType = getGlobalType("Object"); - globalFunctionType = getGlobalType("Function"); - globalStringType = getGlobalType("String"); - globalNumberType = getGlobalType("Number"); - globalBooleanType = getGlobalType("Boolean"); - globalRegExpType = getGlobalType("RegExp"); - jsxElementType = getExportedTypeFromNamespace("JSX", JsxNames.Element); - getGlobalClassDecoratorType = ts.memoize(function () { return getGlobalType("ClassDecorator"); }); - getGlobalPropertyDecoratorType = ts.memoize(function () { return getGlobalType("PropertyDecorator"); }); - getGlobalMethodDecoratorType = ts.memoize(function () { return getGlobalType("MethodDecorator"); }); - getGlobalParameterDecoratorType = ts.memoize(function () { return getGlobalType("ParameterDecorator"); }); - getGlobalTypedPropertyDescriptorType = ts.memoize(function () { return getGlobalType("TypedPropertyDescriptor", 1); }); - getGlobalPromiseType = ts.memoize(function () { return getGlobalType("Promise", 1); }); - tryGetGlobalPromiseType = ts.memoize(function () { return getGlobalSymbol("Promise", 793056, undefined) && getGlobalPromiseType(); }); - getGlobalPromiseLikeType = ts.memoize(function () { return getGlobalType("PromiseLike", 1); }); - getInstantiatedGlobalPromiseLikeType = ts.memoize(createInstantiatedPromiseLikeType); - getGlobalPromiseConstructorSymbol = ts.memoize(function () { return getGlobalValueSymbol("Promise"); }); - getGlobalPromiseConstructorLikeType = ts.memoize(function () { return getGlobalType("PromiseConstructorLike"); }); - getGlobalThenableType = ts.memoize(createThenableType); - if (languageVersion >= 2) { - globalTemplateStringsArrayType = getGlobalType("TemplateStringsArray"); - globalESSymbolType = getGlobalType("Symbol"); - globalESSymbolConstructorSymbol = getGlobalValueSymbol("Symbol"); - globalIterableType = getGlobalType("Iterable", 1); - globalIteratorType = getGlobalType("Iterator", 1); - globalIterableIteratorType = getGlobalType("IterableIterator", 1); - } - else { - globalTemplateStringsArrayType = unknownType; - globalESSymbolType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); - globalESSymbolConstructorSymbol = undefined; - globalIterableType = emptyGenericType; - globalIteratorType = emptyGenericType; - globalIterableIteratorType = emptyGenericType; - } - anyArrayType = createArrayType(anyType); - } - function createInstantiatedPromiseLikeType() { - var promiseLikeType = getGlobalPromiseLikeType(); - if (promiseLikeType !== emptyGenericType) { - return createTypeReference(promiseLikeType, [anyType]); - } - return emptyObjectType; - } - function createThenableType() { - var thenPropertySymbol = createSymbol(67108864 | 4, "then"); - getSymbolLinks(thenPropertySymbol).type = globalFunctionType; - var thenableType = createObjectType(65536); - thenableType.properties = [thenPropertySymbol]; - thenableType.members = createSymbolTable(thenableType.properties); - thenableType.callSignatures = []; - thenableType.constructSignatures = []; - return thenableType; - } - function checkGrammarDecorators(node) { - if (!node.decorators) { - return false; - } - if (!ts.nodeCanBeDecorated(node)) { - return grammarErrorOnFirstToken(node, ts.Diagnostics.Decorators_are_not_valid_here); - } - else if (node.kind === 145 || node.kind === 146) { - var accessors = ts.getAllAccessorDeclarations(node.parent.members, node); - if (accessors.firstAccessor.decorators && node === accessors.secondAccessor) { - return grammarErrorOnFirstToken(node, ts.Diagnostics.Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name); - } - } - return false; - } - function checkGrammarModifiers(node) { - switch (node.kind) { - case 145: - case 146: - case 144: - case 141: - case 140: - case 143: - case 142: - case 149: - case 218: - case 222: - case 221: - case 228: - case 227: - case 138: - break; - case 213: - if (node.modifiers && (node.modifiers.length > 1 || node.modifiers[0].kind !== 118) && - node.parent.kind !== 219 && node.parent.kind !== 248) { - return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); - } - break; - case 214: - case 215: - case 193: - case 216: - if (node.modifiers && node.parent.kind !== 219 && node.parent.kind !== 248) { - return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); - } - break; - case 217: - if (node.modifiers && (node.modifiers.length > 1 || node.modifiers[0].kind !== 74) && - node.parent.kind !== 219 && node.parent.kind !== 248) { - return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); - } - break; - default: - return false; - } - if (!node.modifiers) { - return; - } - var lastStatic, lastPrivate, lastProtected, lastDeclare, lastAsync; - var flags = 0; - for (var _i = 0, _a = node.modifiers; _i < _a.length; _i++) { - var modifier = _a[_i]; - switch (modifier.kind) { - case 112: - case 111: - case 110: - var text = void 0; - if (modifier.kind === 112) { - text = "public"; - } - else if (modifier.kind === 111) { - text = "protected"; - lastProtected = modifier; - } - else { - text = "private"; - lastPrivate = modifier; - } - if (flags & 112) { - return grammarErrorOnNode(modifier, ts.Diagnostics.Accessibility_modifier_already_seen); - } - else if (flags & 128) { - return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "static"); - } - else if (flags & 512) { - return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "async"); - } - else if (node.parent.kind === 219 || node.parent.kind === 248) { - return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_element, text); - } - else if (flags & 256) { - if (modifier.kind === 110) { - return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, text, "abstract"); - } - else { - return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "abstract"); - } - } - flags |= ts.modifierToFlag(modifier.kind); - break; - case 113: - if (flags & 128) { - return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "static"); - } - else if (flags & 512) { - return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "static", "async"); - } - else if (node.parent.kind === 219 || node.parent.kind === 248) { - return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_element, "static"); - } - else if (node.kind === 138) { - return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "static"); - } - else if (flags & 256) { - return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "static", "abstract"); - } - flags |= 128; - lastStatic = modifier; - break; - case 82: - if (flags & 1) { - return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "export"); - } - else if (flags & 2) { - return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "declare"); - } - else if (flags & 256) { - return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "abstract"); - } - else if (flags & 512) { - return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "async"); - } - else if (node.parent.kind === 214) { - return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "export"); - } - else if (node.kind === 138) { - return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "export"); - } - flags |= 1; - break; - case 122: - if (flags & 2) { - return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "declare"); - } - else if (flags & 512) { - return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); - } - else if (node.parent.kind === 214) { - return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "declare"); - } - else if (node.kind === 138) { - return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "declare"); - } - else if (ts.isInAmbientContext(node.parent) && node.parent.kind === 219) { - return grammarErrorOnNode(modifier, ts.Diagnostics.A_declare_modifier_cannot_be_used_in_an_already_ambient_context); - } - flags |= 2; - lastDeclare = modifier; - break; - case 115: - if (flags & 256) { - return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "abstract"); - } - if (node.kind !== 214) { - if (node.kind !== 143) { - return grammarErrorOnNode(modifier, ts.Diagnostics.abstract_modifier_can_only_appear_on_a_class_or_method_declaration); - } - if (!(node.parent.kind === 214 && node.parent.flags & 256)) { - return grammarErrorOnNode(modifier, ts.Diagnostics.Abstract_methods_can_only_appear_within_an_abstract_class); - } - if (flags & 128) { - return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "static", "abstract"); - } - if (flags & 32) { - return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "private", "abstract"); - } - } - flags |= 256; - break; - case 118: - if (flags & 512) { - return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "async"); - } - else if (flags & 2 || ts.isInAmbientContext(node.parent)) { - return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); - } - else if (node.kind === 138) { - return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "async"); - } - flags |= 512; - lastAsync = modifier; - break; - } - } - if (node.kind === 144) { - if (flags & 128) { - return grammarErrorOnNode(lastStatic, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "static"); - } - if (flags & 256) { - return grammarErrorOnNode(lastStatic, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "abstract"); - } - else if (flags & 64) { - return grammarErrorOnNode(lastProtected, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "protected"); - } - else if (flags & 32) { - return grammarErrorOnNode(lastPrivate, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "private"); - } - else if (flags & 512) { - return grammarErrorOnNode(lastAsync, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "async"); - } - return; - } - else if ((node.kind === 222 || node.kind === 221) && flags & 2) { - return grammarErrorOnNode(lastDeclare, ts.Diagnostics.A_0_modifier_cannot_be_used_with_an_import_declaration, "declare"); - } - else if (node.kind === 138 && (flags & 112) && ts.isBindingPattern(node.name)) { - return grammarErrorOnNode(node, ts.Diagnostics.A_parameter_property_may_not_be_a_binding_pattern); - } - if (flags & 512) { - return checkGrammarAsyncModifier(node, lastAsync); - } - } - function checkGrammarAsyncModifier(node, asyncModifier) { - if (languageVersion < 2) { - return grammarErrorOnNode(asyncModifier, ts.Diagnostics.Async_functions_are_only_available_when_targeting_ECMAScript_6_and_higher); - } - switch (node.kind) { - case 143: - case 213: - case 173: - case 174: - if (!node.asteriskToken) { - return false; - } - break; - } - return grammarErrorOnNode(asyncModifier, ts.Diagnostics._0_modifier_cannot_be_used_here, "async"); - } - function checkGrammarForDisallowedTrailingComma(list) { - if (list && list.hasTrailingComma) { - var start = list.end - ",".length; - var end = list.end; - var sourceFile = ts.getSourceFileOfNode(list[0]); - return grammarErrorAtPos(sourceFile, start, end - start, ts.Diagnostics.Trailing_comma_not_allowed); - } - } - function checkGrammarTypeParameterList(node, typeParameters, file) { - if (checkGrammarForDisallowedTrailingComma(typeParameters)) { - return true; - } - if (typeParameters && typeParameters.length === 0) { - var start = typeParameters.pos - "<".length; - var end = ts.skipTrivia(file.text, typeParameters.end) + ">".length; - return grammarErrorAtPos(file, start, end - start, ts.Diagnostics.Type_parameter_list_cannot_be_empty); - } - } - function checkGrammarParameterList(parameters) { - if (checkGrammarForDisallowedTrailingComma(parameters)) { - return true; - } - var seenOptionalParameter = false; - var parameterCount = parameters.length; - for (var i = 0; i < parameterCount; i++) { - var parameter = parameters[i]; - if (parameter.dotDotDotToken) { - if (i !== (parameterCount - 1)) { - return grammarErrorOnNode(parameter.dotDotDotToken, ts.Diagnostics.A_rest_parameter_must_be_last_in_a_parameter_list); - } - if (ts.isBindingPattern(parameter.name)) { - return grammarErrorOnNode(parameter.name, ts.Diagnostics.A_rest_element_cannot_contain_a_binding_pattern); - } - if (parameter.questionToken) { - return grammarErrorOnNode(parameter.questionToken, ts.Diagnostics.A_rest_parameter_cannot_be_optional); - } - if (parameter.initializer) { - return grammarErrorOnNode(parameter.name, ts.Diagnostics.A_rest_parameter_cannot_have_an_initializer); - } - } - else if (parameter.questionToken) { - seenOptionalParameter = true; - if (parameter.initializer) { - return grammarErrorOnNode(parameter.name, ts.Diagnostics.Parameter_cannot_have_question_mark_and_initializer); - } - } - else if (seenOptionalParameter && !parameter.initializer) { - return grammarErrorOnNode(parameter.name, ts.Diagnostics.A_required_parameter_cannot_follow_an_optional_parameter); - } - } - } - function checkGrammarFunctionLikeDeclaration(node) { - var file = ts.getSourceFileOfNode(node); - return checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarTypeParameterList(node, node.typeParameters, file) || - checkGrammarParameterList(node.parameters) || checkGrammarArrowFunction(node, file); - } - function checkGrammarArrowFunction(node, file) { - if (node.kind === 174) { - var arrowFunction = node; - var startLine = ts.getLineAndCharacterOfPosition(file, arrowFunction.equalsGreaterThanToken.pos).line; - var endLine = ts.getLineAndCharacterOfPosition(file, arrowFunction.equalsGreaterThanToken.end).line; - if (startLine !== endLine) { - return grammarErrorOnNode(arrowFunction.equalsGreaterThanToken, ts.Diagnostics.Line_terminator_not_permitted_before_arrow); - } - } - return false; - } - function checkGrammarIndexSignatureParameters(node) { - var parameter = node.parameters[0]; - if (node.parameters.length !== 1) { - if (parameter) { - return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_must_have_exactly_one_parameter); - } - else { - return grammarErrorOnNode(node, ts.Diagnostics.An_index_signature_must_have_exactly_one_parameter); - } - } - if (parameter.dotDotDotToken) { - return grammarErrorOnNode(parameter.dotDotDotToken, ts.Diagnostics.An_index_signature_cannot_have_a_rest_parameter); - } - if (parameter.flags & 2035) { - return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_cannot_have_an_accessibility_modifier); - } - if (parameter.questionToken) { - return grammarErrorOnNode(parameter.questionToken, ts.Diagnostics.An_index_signature_parameter_cannot_have_a_question_mark); - } - if (parameter.initializer) { - return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_cannot_have_an_initializer); - } - if (!parameter.type) { - return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_must_have_a_type_annotation); - } - if (parameter.type.kind !== 130 && parameter.type.kind !== 128) { - return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_type_must_be_string_or_number); - } - if (!node.type) { - return grammarErrorOnNode(node, ts.Diagnostics.An_index_signature_must_have_a_type_annotation); - } - } - function checkGrammarForIndexSignatureModifier(node) { - if (node.flags & 2035) { - grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_not_permitted_on_index_signature_members); - } - } - function checkGrammarIndexSignature(node) { - return checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarIndexSignatureParameters(node) || checkGrammarForIndexSignatureModifier(node); - } - function checkGrammarForAtLeastOneTypeArgument(node, typeArguments) { - if (typeArguments && typeArguments.length === 0) { - var sourceFile = ts.getSourceFileOfNode(node); - var start = typeArguments.pos - "<".length; - var end = ts.skipTrivia(sourceFile.text, typeArguments.end) + ">".length; - return grammarErrorAtPos(sourceFile, start, end - start, ts.Diagnostics.Type_argument_list_cannot_be_empty); - } - } - function checkGrammarTypeArguments(node, typeArguments) { - return checkGrammarForDisallowedTrailingComma(typeArguments) || - checkGrammarForAtLeastOneTypeArgument(node, typeArguments); - } - function checkGrammarForOmittedArgument(node, args) { - if (args) { - var sourceFile = ts.getSourceFileOfNode(node); - for (var _i = 0; _i < args.length; _i++) { - var arg = args[_i]; - if (arg.kind === 187) { - return grammarErrorAtPos(sourceFile, arg.pos, 0, ts.Diagnostics.Argument_expression_expected); - } - } - } - } - function checkGrammarArguments(node, args) { - return checkGrammarForDisallowedTrailingComma(args) || - checkGrammarForOmittedArgument(node, args); - } - function checkGrammarHeritageClause(node) { - var types = node.types; - if (checkGrammarForDisallowedTrailingComma(types)) { - return true; - } - if (types && types.length === 0) { - var listType = ts.tokenToString(node.token); - var sourceFile = ts.getSourceFileOfNode(node); - return grammarErrorAtPos(sourceFile, types.pos, 0, ts.Diagnostics._0_list_cannot_be_empty, listType); - } - } - function checkGrammarClassDeclarationHeritageClauses(node) { - var seenExtendsClause = false; - var seenImplementsClause = false; - 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 (seenExtendsClause) { - return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_already_seen); - } - if (seenImplementsClause) { - return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_must_precede_implements_clause); - } - if (heritageClause.types.length > 1) { - return grammarErrorOnFirstToken(heritageClause.types[1], ts.Diagnostics.Classes_can_only_extend_a_single_class); - } - seenExtendsClause = true; - } - else { - ts.Debug.assert(heritageClause.token === 106); - if (seenImplementsClause) { - return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.implements_clause_already_seen); - } - seenImplementsClause = true; - } - checkGrammarHeritageClause(heritageClause); - } - } - } - function checkGrammarInterfaceDeclaration(node) { - var seenExtendsClause = false; - if (node.heritageClauses) { - for (var _i = 0, _a = node.heritageClauses; _i < _a.length; _i++) { - var heritageClause = _a[_i]; - if (heritageClause.token === 83) { - if (seenExtendsClause) { - return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_already_seen); - } - seenExtendsClause = true; - } - else { - ts.Debug.assert(heritageClause.token === 106); - return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.Interface_declaration_cannot_have_implements_clause); - } - checkGrammarHeritageClause(heritageClause); - } - } - return false; - } - function checkGrammarComputedPropertyName(node) { - if (node.kind !== 136) { - return false; - } - var computedPropertyName = node; - if (computedPropertyName.expression.kind === 181 && computedPropertyName.expression.operatorToken.kind === 24) { - return grammarErrorOnNode(computedPropertyName.expression, ts.Diagnostics.A_comma_expression_is_not_allowed_in_a_computed_property_name); - } - } - function checkGrammarForGenerator(node) { - if (node.asteriskToken) { - ts.Debug.assert(node.kind === 213 || - node.kind === 173 || - node.kind === 143); - if (ts.isInAmbientContext(node)) { - return grammarErrorOnNode(node.asteriskToken, ts.Diagnostics.Generators_are_not_allowed_in_an_ambient_context); - } - if (!node.body) { - return grammarErrorOnNode(node.asteriskToken, ts.Diagnostics.An_overload_signature_cannot_be_declared_as_a_generator); - } - if (languageVersion < 2) { - return grammarErrorOnNode(node.asteriskToken, ts.Diagnostics.Generators_are_only_available_when_targeting_ECMAScript_6_or_higher); - } - } - } - function checkGrammarForInvalidQuestionMark(node, questionToken, message) { - if (questionToken) { - return grammarErrorOnNode(questionToken, message); - } - } - function checkGrammarObjectLiteralExpression(node, inDestructuring) { - var seen = {}; - var Property = 1; - var GetAccessor = 2; - var SetAccesor = 4; - var GetOrSetAccessor = GetAccessor | SetAccesor; - for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { - var prop = _a[_i]; - var name_17 = prop.name; - if (prop.kind === 187 || - name_17.kind === 136) { - checkGrammarComputedPropertyName(name_17); - continue; - } - if (prop.kind === 246 && !inDestructuring && prop.objectAssignmentInitializer) { - return grammarErrorOnNode(prop.equalsToken, ts.Diagnostics.can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment); - } - var currentKind = void 0; - if (prop.kind === 245 || prop.kind === 246) { - checkGrammarForInvalidQuestionMark(prop, prop.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional); - if (name_17.kind === 8) { - checkGrammarNumericLiteral(name_17); - } - currentKind = Property; - } - else if (prop.kind === 143) { - currentKind = Property; - } - else if (prop.kind === 145) { - currentKind = GetAccessor; - } - else if (prop.kind === 146) { - currentKind = SetAccesor; - } - else { - ts.Debug.fail("Unexpected syntax kind:" + prop.kind); - } - if (!ts.hasProperty(seen, name_17.text)) { - seen[name_17.text] = currentKind; - } - else { - var existingKind = seen[name_17.text]; - if (currentKind === Property && existingKind === Property) { - continue; - } - else if ((currentKind & GetOrSetAccessor) && (existingKind & GetOrSetAccessor)) { - if (existingKind !== GetOrSetAccessor && currentKind !== existingKind) { - seen[name_17.text] = currentKind | existingKind; - } - else { - return grammarErrorOnNode(name_17, ts.Diagnostics.An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name); - } - } - else { - return grammarErrorOnNode(name_17, ts.Diagnostics.An_object_literal_cannot_have_property_and_accessor_with_the_same_name); - } - } - } - } - function checkGrammarJsxElement(node) { - var seen = {}; - for (var _i = 0, _a = node.attributes; _i < _a.length; _i++) { - var attr = _a[_i]; - if (attr.kind === 239) { - continue; - } - var jsxAttr = attr; - var name_18 = jsxAttr.name; - if (!ts.hasProperty(seen, name_18.text)) { - seen[name_18.text] = true; - } - else { - return grammarErrorOnNode(name_18, ts.Diagnostics.JSX_elements_cannot_have_multiple_attributes_with_the_same_name); - } - var initializer = jsxAttr.initializer; - if (initializer && initializer.kind === 240 && !initializer.expression) { - return grammarErrorOnNode(jsxAttr.initializer, ts.Diagnostics.JSX_attributes_must_only_be_assigned_a_non_empty_expression); - } - } - } - function checkGrammarForInOrForOfStatement(forInOrOfStatement) { - if (checkGrammarStatementInAmbientContext(forInOrOfStatement)) { - return true; - } - if (forInOrOfStatement.initializer.kind === 212) { - var variableList = forInOrOfStatement.initializer; - if (!checkGrammarVariableDeclarationList(variableList)) { - if (variableList.declarations.length > 1) { - var diagnostic = forInOrOfStatement.kind === 200 - ? ts.Diagnostics.Only_a_single_variable_declaration_is_allowed_in_a_for_in_statement - : ts.Diagnostics.Only_a_single_variable_declaration_is_allowed_in_a_for_of_statement; - return grammarErrorOnFirstToken(variableList.declarations[1], diagnostic); - } - var firstDeclaration = variableList.declarations[0]; - if (firstDeclaration.initializer) { - var diagnostic = forInOrOfStatement.kind === 200 - ? ts.Diagnostics.The_variable_declaration_of_a_for_in_statement_cannot_have_an_initializer - : ts.Diagnostics.The_variable_declaration_of_a_for_of_statement_cannot_have_an_initializer; - return grammarErrorOnNode(firstDeclaration.name, diagnostic); - } - if (firstDeclaration.type) { - var diagnostic = forInOrOfStatement.kind === 200 - ? ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_use_a_type_annotation - : ts.Diagnostics.The_left_hand_side_of_a_for_of_statement_cannot_use_a_type_annotation; - return grammarErrorOnNode(firstDeclaration, diagnostic); - } - } - } - return false; - } - function checkGrammarAccessor(accessor) { - var kind = accessor.kind; - if (languageVersion < 1) { - return grammarErrorOnNode(accessor.name, ts.Diagnostics.Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher); - } - else if (ts.isInAmbientContext(accessor)) { - return grammarErrorOnNode(accessor.name, ts.Diagnostics.An_accessor_cannot_be_declared_in_an_ambient_context); - } - else if (accessor.body === undefined) { - return grammarErrorAtPos(ts.getSourceFileOfNode(accessor), accessor.end - 1, ";".length, ts.Diagnostics._0_expected, "{"); - } - else if (accessor.typeParameters) { - return grammarErrorOnNode(accessor.name, ts.Diagnostics.An_accessor_cannot_have_type_parameters); - } - else if (kind === 145 && accessor.parameters.length) { - return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_get_accessor_cannot_have_parameters); - } - else if (kind === 146) { - if (accessor.type) { - return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_set_accessor_cannot_have_a_return_type_annotation); - } - else if (accessor.parameters.length !== 1) { - return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_set_accessor_must_have_exactly_one_parameter); - } - else { - var parameter = accessor.parameters[0]; - if (parameter.dotDotDotToken) { - return grammarErrorOnNode(parameter.dotDotDotToken, ts.Diagnostics.A_set_accessor_cannot_have_rest_parameter); - } - else if (parameter.flags & 2035) { - return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation); - } - else if (parameter.questionToken) { - return grammarErrorOnNode(parameter.questionToken, ts.Diagnostics.A_set_accessor_cannot_have_an_optional_parameter); - } - else if (parameter.initializer) { - return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_set_accessor_parameter_cannot_have_an_initializer); - } - } - } - } - function checkGrammarForNonSymbolComputedProperty(node, message) { - if (node.kind === 136 && !ts.isWellKnownSymbolSyntactically(node.expression)) { - return grammarErrorOnNode(node, message); - } - } - function checkGrammarMethod(node) { - if (checkGrammarDisallowedModifiersOnObjectLiteralExpressionMethod(node) || - checkGrammarFunctionLikeDeclaration(node) || - checkGrammarForGenerator(node)) { - return true; - } - if (node.parent.kind === 165) { - if (checkGrammarForInvalidQuestionMark(node, node.questionToken, ts.Diagnostics.A_class_member_cannot_be_declared_optional)) { - return true; - } - else if (node.body === undefined) { - return grammarErrorAtPos(getSourceFile(node), node.end - 1, ";".length, ts.Diagnostics._0_expected, "{"); - } - } - if (ts.isClassLike(node.parent)) { - if (checkGrammarForInvalidQuestionMark(node, node.questionToken, ts.Diagnostics.A_class_member_cannot_be_declared_optional)) { - return true; - } - if (ts.isInAmbientContext(node)) { - return checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_an_ambient_context_must_directly_refer_to_a_built_in_symbol); - } - else if (!node.body) { - 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 === 215) { - return checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_an_interface_must_directly_refer_to_a_built_in_symbol); - } - else if (node.parent.kind === 155) { - return checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_type_literal_must_directly_refer_to_a_built_in_symbol); - } - } - function isIterationStatement(node, lookInLabeledStatements) { - switch (node.kind) { - case 199: - case 200: - case 201: - case 197: - case 198: - return true; - case 207: - return lookInLabeledStatements && isIterationStatement(node.statement, lookInLabeledStatements); - } - return false; - } - function checkGrammarBreakOrContinueStatement(node) { - var current = node; - while (current) { - if (ts.isFunctionLike(current)) { - return grammarErrorOnNode(node, ts.Diagnostics.Jump_target_cannot_cross_function_boundary); - } - switch (current.kind) { - case 207: - if (node.label && current.label.text === node.label.text) { - var isMisplacedContinueLabel = node.kind === 202 - && !isIterationStatement(current.statement, true); - if (isMisplacedContinueLabel) { - return grammarErrorOnNode(node, ts.Diagnostics.A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement); - } - return false; - } - break; - case 206: - if (node.kind === 203 && !node.label) { - return false; - } - break; - default: - if (isIterationStatement(current, false) && !node.label) { - return false; - } - break; - } - current = current.parent; - } - if (node.label) { - var message = node.kind === 203 - ? ts.Diagnostics.A_break_statement_can_only_jump_to_a_label_of_an_enclosing_statement - : ts.Diagnostics.A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement; - return grammarErrorOnNode(node, message); - } - else { - var message = node.kind === 203 - ? ts.Diagnostics.A_break_statement_can_only_be_used_within_an_enclosing_iteration_or_switch_statement - : ts.Diagnostics.A_continue_statement_can_only_be_used_within_an_enclosing_iteration_statement; - return grammarErrorOnNode(node, message); - } - } - function checkGrammarBindingElement(node) { - if (node.dotDotDotToken) { - var elements = node.parent.elements; - 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 === 162 || node.name.kind === 161) { - return grammarErrorOnNode(node.name, ts.Diagnostics.A_rest_element_cannot_contain_a_binding_pattern); - } - if (node.initializer) { - return grammarErrorAtPos(ts.getSourceFileOfNode(node), node.initializer.pos - 1, 1, ts.Diagnostics.A_rest_element_cannot_have_an_initializer); - } - } - } - function checkGrammarVariableDeclaration(node) { - if (node.parent.parent.kind !== 200 && node.parent.parent.kind !== 201) { - if (ts.isInAmbientContext(node)) { - if (node.initializer) { - var equalsTokenLength = "=".length; - return grammarErrorAtPos(ts.getSourceFileOfNode(node), node.initializer.pos - equalsTokenLength, equalsTokenLength, ts.Diagnostics.Initializers_are_not_allowed_in_ambient_contexts); - } - } - else if (!node.initializer) { - if (ts.isBindingPattern(node.name) && !ts.isBindingPattern(node.parent)) { - return grammarErrorOnNode(node, ts.Diagnostics.A_destructuring_declaration_must_have_an_initializer); - } - if (ts.isConst(node)) { - return grammarErrorOnNode(node, ts.Diagnostics.const_declarations_must_be_initialized); - } - } - } - var checkLetConstNames = languageVersion >= 2 && (ts.isLet(node) || ts.isConst(node)); - return checkLetConstNames && checkGrammarNameInLetOrConstDeclarations(node.name); - } - function checkGrammarNameInLetOrConstDeclarations(name) { - if (name.kind === 69) { - if (name.text === "let") { - return grammarErrorOnNode(name, ts.Diagnostics.let_is_not_allowed_to_be_used_as_a_name_in_let_or_const_declarations); - } - } - else { - var elements = name.elements; - for (var _i = 0; _i < elements.length; _i++) { - var element = elements[_i]; - if (element.kind !== 187) { - checkGrammarNameInLetOrConstDeclarations(element.name); - } - } - } - } - function checkGrammarVariableDeclarationList(declarationList) { - var declarations = declarationList.declarations; - if (checkGrammarForDisallowedTrailingComma(declarationList.declarations)) { - return true; - } - if (!declarationList.declarations.length) { - return grammarErrorAtPos(ts.getSourceFileOfNode(declarationList), declarations.pos, declarations.end - declarations.pos, ts.Diagnostics.Variable_declaration_list_cannot_be_empty); - } - } - function allowLetAndConstDeclarations(parent) { - switch (parent.kind) { - case 196: - case 197: - case 198: - case 205: - case 199: - case 200: - case 201: - return false; - case 207: - return allowLetAndConstDeclarations(parent.parent); - } - return true; - } - function checkGrammarForDisallowedLetOrConstStatement(node) { - if (!allowLetAndConstDeclarations(node.parent)) { - if (ts.isLet(node.declarationList)) { - return grammarErrorOnNode(node, ts.Diagnostics.let_declarations_can_only_be_declared_inside_a_block); - } - else if (ts.isConst(node.declarationList)) { - return grammarErrorOnNode(node, ts.Diagnostics.const_declarations_can_only_be_declared_inside_a_block); - } - } - } - function isIntegerLiteral(expression) { - if (expression.kind === 179) { - var unaryExpression = expression; - if (unaryExpression.operator === 35 || unaryExpression.operator === 36) { - expression = unaryExpression.operand; - } - } - if (expression.kind === 8) { - return /^[0-9]+([eE]\+?[0-9]+)?$/.test(expression.text); - } - return false; - } - function hasParseDiagnostics(sourceFile) { - return sourceFile.parseDiagnostics.length > 0; - } - function grammarErrorOnFirstToken(node, message, arg0, arg1, arg2) { - var sourceFile = ts.getSourceFileOfNode(node); - if (!hasParseDiagnostics(sourceFile)) { - var span = ts.getSpanOfTokenAtPosition(sourceFile, node.pos); - diagnostics.add(ts.createFileDiagnostic(sourceFile, span.start, span.length, message, arg0, arg1, arg2)); - return true; - } - } - function grammarErrorAtPos(sourceFile, start, length, message, arg0, arg1, arg2) { - if (!hasParseDiagnostics(sourceFile)) { - diagnostics.add(ts.createFileDiagnostic(sourceFile, start, length, message, arg0, arg1, arg2)); - return true; - } - } - function grammarErrorOnNode(node, message, arg0, arg1, arg2) { - var sourceFile = ts.getSourceFileOfNode(node); - if (!hasParseDiagnostics(sourceFile)) { - diagnostics.add(ts.createDiagnosticForNode(node, message, arg0, arg1, arg2)); - return true; - } - } - function isEvalOrArgumentsIdentifier(node) { - return node.kind === 69 && - (node.text === "eval" || node.text === "arguments"); - } - function checkGrammarConstructorTypeParameters(node) { - if (node.typeParameters) { - return grammarErrorAtPos(ts.getSourceFileOfNode(node), node.typeParameters.pos, node.typeParameters.end - node.typeParameters.pos, ts.Diagnostics.Type_parameters_cannot_appear_on_a_constructor_declaration); - } - } - function checkGrammarConstructorTypeAnnotation(node) { - if (node.type) { - return grammarErrorOnNode(node.type, ts.Diagnostics.Type_annotation_cannot_appear_on_a_constructor_declaration); - } - } - function checkGrammarProperty(node) { - if (ts.isClassLike(node.parent)) { - if (checkGrammarForInvalidQuestionMark(node, node.questionToken, ts.Diagnostics.A_class_member_cannot_be_declared_optional) || - checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_class_property_declaration_must_directly_refer_to_a_built_in_symbol)) { - return true; - } - } - else if (node.parent.kind === 215) { - if (checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_an_interface_must_directly_refer_to_a_built_in_symbol)) { - return true; - } - } - else if (node.parent.kind === 155) { - if (checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_type_literal_must_directly_refer_to_a_built_in_symbol)) { - return true; - } - } - if (ts.isInAmbientContext(node) && node.initializer) { - return grammarErrorOnFirstToken(node.initializer, ts.Diagnostics.Initializers_are_not_allowed_in_ambient_contexts); - } - } - function checkGrammarTopLevelElementForRequiredDeclareModifier(node) { - if (node.kind === 215 || - node.kind === 222 || - node.kind === 221 || - node.kind === 228 || - node.kind === 227 || - (node.flags & 2) || - (node.flags & (1 | 1024))) { - return false; - } - return grammarErrorOnFirstToken(node, ts.Diagnostics.A_declare_modifier_is_required_for_a_top_level_declaration_in_a_d_ts_file); - } - function checkGrammarTopLevelElementsForRequiredDeclareModifier(file) { - for (var _i = 0, _a = file.statements; _i < _a.length; _i++) { - var decl = _a[_i]; - if (ts.isDeclaration(decl) || decl.kind === 193) { - if (checkGrammarTopLevelElementForRequiredDeclareModifier(decl)) { - return true; - } - } - } - } - function checkGrammarSourceFile(node) { - return ts.isInAmbientContext(node) && checkGrammarTopLevelElementsForRequiredDeclareModifier(node); - } - function checkGrammarStatementInAmbientContext(node) { - if (ts.isInAmbientContext(node)) { - if (isAccessor(node.parent.kind)) { - return getNodeLinks(node).hasReportedStatementInAmbientContext = true; - } - var links = getNodeLinks(node); - 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 === 192 || node.parent.kind === 219 || node.parent.kind === 248) { - var links_1 = getNodeLinks(node.parent); - if (!links_1.hasReportedStatementInAmbientContext) { - return links_1.hasReportedStatementInAmbientContext = grammarErrorOnFirstToken(node, ts.Diagnostics.Statements_are_not_allowed_in_ambient_contexts); - } - } - else { - } - } - } - function checkGrammarNumericLiteral(node) { - if (node.flags & 65536 && languageVersion >= 1) { - return grammarErrorOnNode(node, ts.Diagnostics.Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher); - } - } - function grammarErrorAfterFirstToken(node, message, arg0, arg1, arg2) { - var sourceFile = ts.getSourceFileOfNode(node); - if (!hasParseDiagnostics(sourceFile)) { - var span = ts.getSpanOfTokenAtPosition(sourceFile, node.pos); - diagnostics.add(ts.createFileDiagnostic(sourceFile, ts.textSpanEnd(span), 0, message, arg0, arg1, arg2)); - return true; - } - } - } - ts.createTypeChecker = createTypeChecker; -})(ts || (ts = {})); -var ts; -(function (ts) { - function getDeclarationDiagnostics(host, resolver, targetSourceFile) { - var diagnostics = []; - var jsFilePath = ts.getOwnEmitOutputFilePath(targetSourceFile, host, ".js"); - emitDeclarations(host, resolver, diagnostics, jsFilePath, targetSourceFile); - return diagnostics; - } - ts.getDeclarationDiagnostics = getDeclarationDiagnostics; - function emitDeclarations(host, resolver, diagnostics, jsFilePath, root) { - var newLine = host.getNewLine(); - var compilerOptions = host.getCompilerOptions(); - var write; - var writeLine; - var increaseIndent; - var decreaseIndent; - var writeTextOfNode; - var writer = createAndSetNewTextWriterWithSymbolWriter(); - var enclosingDeclaration; - var currentSourceFile; - var reportedDeclarationError = false; - var errorNameNode; - var emitJsDocComments = compilerOptions.removeComments ? function (declaration) { } : writeJsDocComments; - var emit = compilerOptions.stripInternal ? stripInternal : emitNode; - var moduleElementDeclarationEmitInfo = []; - var asynchronousSubModuleDeclarationEmitInfo; - var referencePathsOutput = ""; - if (root) { - if (!compilerOptions.noResolve) { - var addedGlobalFileReference = false; - ts.forEach(root.referencedFiles, function (fileReference) { - var referencedFile = ts.tryResolveScriptReference(host, root, fileReference); - if (referencedFile && ((referencedFile.flags & 8192) || - ts.shouldEmitToOwnFile(referencedFile, compilerOptions) || - !addedGlobalFileReference)) { - writeReferencePath(referencedFile); - if (!ts.isExternalModuleOrDeclarationFile(referencedFile)) { - addedGlobalFileReference = true; - } - } - }); - } - emitSourceFile(root); - if (moduleElementDeclarationEmitInfo.length) { - var oldWriter = writer; - ts.forEach(moduleElementDeclarationEmitInfo, function (aliasEmitInfo) { - if (aliasEmitInfo.isVisible) { - ts.Debug.assert(aliasEmitInfo.node.kind === 222); - createAndSetNewTextWriterWithSymbolWriter(); - ts.Debug.assert(aliasEmitInfo.indent === 0); - writeImportDeclaration(aliasEmitInfo.node); - aliasEmitInfo.asynchronousOutput = writer.getText(); - } - }); - setWriter(oldWriter); - } - } - else { - var emittedReferencedFiles = []; - ts.forEach(host.getSourceFiles(), function (sourceFile) { - if (!ts.isExternalModuleOrDeclarationFile(sourceFile)) { - if (!compilerOptions.noResolve) { - ts.forEach(sourceFile.referencedFiles, function (fileReference) { - var referencedFile = ts.tryResolveScriptReference(host, sourceFile, fileReference); - if (referencedFile && (ts.isExternalModuleOrDeclarationFile(referencedFile) && - !ts.contains(emittedReferencedFiles, referencedFile))) { - writeReferencePath(referencedFile); - emittedReferencedFiles.push(referencedFile); - } - }); - } - emitSourceFile(sourceFile); - } - }); - } - return { - reportedDeclarationError: reportedDeclarationError, - moduleElementDeclarationEmitInfo: moduleElementDeclarationEmitInfo, - synchronousDeclarationOutput: writer.getText(), - referencePathsOutput: referencePathsOutput - }; - function hasInternalAnnotation(range) { - var text = currentSourceFile.text; - var comment = text.substring(range.pos, range.end); - return comment.indexOf("@internal") >= 0; - } - function stripInternal(node) { - if (node) { - var leadingCommentRanges = ts.getLeadingCommentRanges(currentSourceFile.text, node.pos); - if (ts.forEach(leadingCommentRanges, hasInternalAnnotation)) { - return; - } - emitNode(node); - } - } - function createAndSetNewTextWriterWithSymbolWriter() { - var writer = ts.createTextWriter(newLine); - writer.trackSymbol = trackSymbol; - writer.reportInaccessibleThisError = reportInaccessibleThisError; - writer.writeKeyword = writer.write; - writer.writeOperator = writer.write; - writer.writePunctuation = writer.write; - writer.writeSpace = writer.write; - writer.writeStringLiteral = writer.writeLiteral; - writer.writeParameter = writer.write; - writer.writeSymbol = writer.write; - setWriter(writer); - return writer; - } - function setWriter(newWriter) { - writer = newWriter; - write = newWriter.write; - writeTextOfNode = newWriter.writeTextOfNode; - writeLine = newWriter.writeLine; - increaseIndent = newWriter.increaseIndent; - decreaseIndent = newWriter.decreaseIndent; - } - function writeAsynchronousModuleElements(nodes) { - var oldWriter = writer; - ts.forEach(nodes, function (declaration) { - var nodeToCheck; - if (declaration.kind === 211) { - nodeToCheck = declaration.parent.parent; - } - else if (declaration.kind === 225 || declaration.kind === 226 || declaration.kind === 223) { - ts.Debug.fail("We should be getting ImportDeclaration instead to write"); - } - else { - nodeToCheck = declaration; - } - var moduleElementEmitInfo = ts.forEach(moduleElementDeclarationEmitInfo, function (declEmitInfo) { return declEmitInfo.node === nodeToCheck ? declEmitInfo : undefined; }); - if (!moduleElementEmitInfo && asynchronousSubModuleDeclarationEmitInfo) { - moduleElementEmitInfo = ts.forEach(asynchronousSubModuleDeclarationEmitInfo, function (declEmitInfo) { return declEmitInfo.node === nodeToCheck ? declEmitInfo : undefined; }); - } - if (moduleElementEmitInfo) { - if (moduleElementEmitInfo.node.kind === 222) { - moduleElementEmitInfo.isVisible = true; - } - else { - createAndSetNewTextWriterWithSymbolWriter(); - for (var declarationIndent = moduleElementEmitInfo.indent; declarationIndent; declarationIndent--) { - increaseIndent(); - } - if (nodeToCheck.kind === 218) { - ts.Debug.assert(asynchronousSubModuleDeclarationEmitInfo === undefined); - asynchronousSubModuleDeclarationEmitInfo = []; - } - writeModuleElement(nodeToCheck); - if (nodeToCheck.kind === 218) { - moduleElementEmitInfo.subModuleElementDeclarationEmitInfo = asynchronousSubModuleDeclarationEmitInfo; - asynchronousSubModuleDeclarationEmitInfo = undefined; - } - moduleElementEmitInfo.asynchronousOutput = writer.getText(); - } - } - }); - setWriter(oldWriter); - } - function handleSymbolAccessibilityError(symbolAccesibilityResult) { - if (symbolAccesibilityResult.accessibility === 0) { - if (symbolAccesibilityResult && symbolAccesibilityResult.aliasesToMakeVisible) { - writeAsynchronousModuleElements(symbolAccesibilityResult.aliasesToMakeVisible); - } - } - else { - reportedDeclarationError = true; - var errorInfo = writer.getSymbolAccessibilityDiagnostic(symbolAccesibilityResult); - if (errorInfo) { - if (errorInfo.typeName) { - diagnostics.push(ts.createDiagnosticForNode(symbolAccesibilityResult.errorNode || errorInfo.errorNode, errorInfo.diagnosticMessage, ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, errorInfo.typeName), symbolAccesibilityResult.errorSymbolName, symbolAccesibilityResult.errorModuleName)); - } - else { - diagnostics.push(ts.createDiagnosticForNode(symbolAccesibilityResult.errorNode || errorInfo.errorNode, errorInfo.diagnosticMessage, symbolAccesibilityResult.errorSymbolName, symbolAccesibilityResult.errorModuleName)); - } - } - } - } - function trackSymbol(symbol, enclosingDeclaration, meaning) { - handleSymbolAccessibilityError(resolver.isSymbolAccessible(symbol, enclosingDeclaration, meaning)); - } - function reportInaccessibleThisError() { - if (errorNameNode) { - diagnostics.push(ts.createDiagnosticForNode(errorNameNode, ts.Diagnostics.The_inferred_type_of_0_references_an_inaccessible_this_type_A_type_annotation_is_necessary, ts.declarationNameToString(errorNameNode))); - } - } - function writeTypeOfDeclaration(declaration, type, getSymbolAccessibilityDiagnostic) { - writer.getSymbolAccessibilityDiagnostic = getSymbolAccessibilityDiagnostic; - write(": "); - if (type) { - emitType(type); - } - else { - errorNameNode = declaration.name; - resolver.writeTypeOfDeclaration(declaration, enclosingDeclaration, 2, writer); - errorNameNode = undefined; - } - } - function writeReturnTypeAtSignature(signature, getSymbolAccessibilityDiagnostic) { - writer.getSymbolAccessibilityDiagnostic = getSymbolAccessibilityDiagnostic; - write(": "); - if (signature.type) { - emitType(signature.type); - } - else { - errorNameNode = signature.name; - resolver.writeReturnTypeOfSignatureDeclaration(signature, enclosingDeclaration, 2, writer); - errorNameNode = undefined; - } - } - function emitLines(nodes) { - for (var _i = 0; _i < nodes.length; _i++) { - var node = nodes[_i]; - emit(node); - } - } - function emitSeparatedList(nodes, separator, eachNodeEmitFn, canEmitFn) { - var currentWriterPos = writer.getTextPos(); - for (var _i = 0; _i < nodes.length; _i++) { - var node = nodes[_i]; - if (!canEmitFn || canEmitFn(node)) { - if (currentWriterPos !== writer.getTextPos()) { - write(separator); - } - currentWriterPos = writer.getTextPos(); - eachNodeEmitFn(node); - } - } - } - function emitCommaList(nodes, eachNodeEmitFn, canEmitFn) { - emitSeparatedList(nodes, ", ", eachNodeEmitFn, canEmitFn); - } - function writeJsDocComments(declaration) { - if (declaration) { - var jsDocComments = ts.getJsDocComments(declaration, currentSourceFile); - ts.emitNewLineBeforeLeadingComments(currentSourceFile, writer, declaration, jsDocComments); - ts.emitComments(currentSourceFile, writer, jsDocComments, true, newLine, ts.writeCommentRange); - } - } - function emitTypeWithNewGetSymbolAccessibilityDiagnostic(type, getSymbolAccessibilityDiagnostic) { - writer.getSymbolAccessibilityDiagnostic = getSymbolAccessibilityDiagnostic; - emitType(type); - } - function emitType(type) { - switch (type.kind) { - case 117: - case 130: - case 128: - case 120: - case 131: - case 103: - case 97: - case 9: - return writeTextOfNode(currentSourceFile, type); - case 188: - return emitExpressionWithTypeArguments(type); - case 151: - return emitTypeReference(type); - case 154: - return emitTypeQuery(type); - case 156: - return emitArrayType(type); - case 157: - return emitTupleType(type); - case 158: - return emitUnionType(type); - case 159: - return emitIntersectionType(type); - case 160: - return emitParenType(type); - case 152: - case 153: - return emitSignatureDeclarationWithJsDocComments(type); - case 155: - return emitTypeLiteral(type); - case 69: - return emitEntityName(type); - case 135: - return emitEntityName(type); - case 150: - return emitTypePredicate(type); - } - function writeEntityName(entityName) { - if (entityName.kind === 69) { - writeTextOfNode(currentSourceFile, entityName); - } - else { - var left = entityName.kind === 135 ? entityName.left : entityName.expression; - var right = entityName.kind === 135 ? entityName.right : entityName.name; - writeEntityName(left); - write("."); - writeTextOfNode(currentSourceFile, right); - } - } - function emitEntityName(entityName) { - var visibilityResult = resolver.isEntityNameVisible(entityName, entityName.parent.kind === 221 ? entityName.parent : enclosingDeclaration); - handleSymbolAccessibilityError(visibilityResult); - writeEntityName(entityName); - } - function emitExpressionWithTypeArguments(node) { - if (ts.isSupportedExpressionWithTypeArguments(node)) { - ts.Debug.assert(node.expression.kind === 69 || node.expression.kind === 166); - emitEntityName(node.expression); - if (node.typeArguments) { - write("<"); - emitCommaList(node.typeArguments, emitType); - write(">"); - } - } - } - function emitTypeReference(type) { - emitEntityName(type.typeName); - if (type.typeArguments) { - write("<"); - emitCommaList(type.typeArguments, emitType); - write(">"); - } - } - function emitTypePredicate(type) { - writeTextOfNode(currentSourceFile, type.parameterName); - write(" is "); - emitType(type.type); - } - function emitTypeQuery(type) { - write("typeof "); - emitEntityName(type.exprName); - } - function emitArrayType(type) { - emitType(type.elementType); - write("[]"); - } - function emitTupleType(type) { - write("["); - emitCommaList(type.elementTypes, emitType); - write("]"); - } - function emitUnionType(type) { - emitSeparatedList(type.types, " | ", emitType); - } - function emitIntersectionType(type) { - emitSeparatedList(type.types, " & ", emitType); - } - function emitParenType(type) { - write("("); - emitType(type.type); - write(")"); - } - function emitTypeLiteral(type) { - write("{"); - if (type.members.length) { - writeLine(); - increaseIndent(); - emitLines(type.members); - decreaseIndent(); - } - write("}"); - } - } - function emitSourceFile(node) { - currentSourceFile = node; - enclosingDeclaration = node; - emitLines(node.statements); - } - function getExportDefaultTempVariableName() { - var baseName = "_default"; - if (!ts.hasProperty(currentSourceFile.identifiers, baseName)) { - return baseName; - } - var count = 0; - while (true) { - var name_19 = baseName + "_" + (++count); - if (!ts.hasProperty(currentSourceFile.identifiers, name_19)) { - return name_19; - } - } - } - function emitExportAssignment(node) { - if (node.expression.kind === 69) { - write(node.isExportEquals ? "export = " : "export default "); - writeTextOfNode(currentSourceFile, node.expression); - } - else { - var tempVarName = getExportDefaultTempVariableName(); - write("declare var "); - write(tempVarName); - write(": "); - writer.getSymbolAccessibilityDiagnostic = getDefaultExportAccessibilityDiagnostic; - resolver.writeTypeOfExpression(node.expression, enclosingDeclaration, 2, writer); - write(";"); - writeLine(); - write(node.isExportEquals ? "export = " : "export default "); - write(tempVarName); - } - write(";"); - writeLine(); - if (node.expression.kind === 69) { - var nodes = resolver.collectLinkedAliases(node.expression); - writeAsynchronousModuleElements(nodes); - } - function getDefaultExportAccessibilityDiagnostic(diagnostic) { - return { - diagnosticMessage: ts.Diagnostics.Default_export_of_the_module_has_or_is_using_private_name_0, - errorNode: node - }; - } - } - function isModuleElementVisible(node) { - return resolver.isDeclarationVisible(node); - } - function emitModuleElement(node, isModuleElementVisible) { - if (isModuleElementVisible) { - writeModuleElement(node); - } - else if (node.kind === 221 || - (node.parent.kind === 248 && ts.isExternalModule(currentSourceFile))) { - var isVisible; - if (asynchronousSubModuleDeclarationEmitInfo && node.parent.kind !== 248) { - asynchronousSubModuleDeclarationEmitInfo.push({ - node: node, - outputPos: writer.getTextPos(), - indent: writer.getIndent(), - isVisible: isVisible - }); - } - else { - if (node.kind === 222) { - var importDeclaration = node; - if (importDeclaration.importClause) { - isVisible = (importDeclaration.importClause.name && resolver.isDeclarationVisible(importDeclaration.importClause)) || - isVisibleNamedBinding(importDeclaration.importClause.namedBindings); - } - } - moduleElementDeclarationEmitInfo.push({ - node: node, - outputPos: writer.getTextPos(), - indent: writer.getIndent(), - isVisible: isVisible - }); - } - } - } - function writeModuleElement(node) { - switch (node.kind) { - case 213: - return writeFunctionDeclaration(node); - case 193: - return writeVariableStatement(node); - case 215: - return writeInterfaceDeclaration(node); - case 214: - return writeClassDeclaration(node); - case 216: - return writeTypeAliasDeclaration(node); - case 217: - return writeEnumDeclaration(node); - case 218: - return writeModuleDeclaration(node); - case 221: - return writeImportEqualsDeclaration(node); - case 222: - return writeImportDeclaration(node); - default: - ts.Debug.fail("Unknown symbol kind"); - } - } - function emitModuleElementDeclarationFlags(node) { - if (node.parent === currentSourceFile) { - if (node.flags & 1) { - write("export "); - } - if (node.flags & 1024) { - write("default "); - } - else if (node.kind !== 215) { - write("declare "); - } - } - } - function emitClassMemberDeclarationFlags(node) { - if (node.flags & 32) { - write("private "); - } - else if (node.flags & 64) { - write("protected "); - } - if (node.flags & 128) { - write("static "); - } - if (node.flags & 256) { - write("abstract "); - } - } - function writeImportEqualsDeclaration(node) { - emitJsDocComments(node); - if (node.flags & 1) { - write("export "); - } - write("import "); - writeTextOfNode(currentSourceFile, node.name); - write(" = "); - if (ts.isInternalModuleImportEqualsDeclaration(node)) { - emitTypeWithNewGetSymbolAccessibilityDiagnostic(node.moduleReference, getImportEntityNameVisibilityError); - write(";"); - } - else { - write("require("); - writeTextOfNode(currentSourceFile, ts.getExternalModuleImportEqualsDeclarationExpression(node)); - write(");"); - } - writer.writeLine(); - function getImportEntityNameVisibilityError(symbolAccesibilityResult) { - return { - diagnosticMessage: ts.Diagnostics.Import_declaration_0_is_using_private_name_1, - errorNode: node, - typeName: node.name - }; - } - } - function isVisibleNamedBinding(namedBindings) { - if (namedBindings) { - if (namedBindings.kind === 224) { - return resolver.isDeclarationVisible(namedBindings); - } - else { - return ts.forEach(namedBindings.elements, function (namedImport) { return resolver.isDeclarationVisible(namedImport); }); - } - } - } - function writeImportDeclaration(node) { - if (!node.importClause && !(node.flags & 1)) { - return; - } - emitJsDocComments(node); - if (node.flags & 1) { - write("export "); - } - write("import "); - if (node.importClause) { - var currentWriterPos = writer.getTextPos(); - if (node.importClause.name && resolver.isDeclarationVisible(node.importClause)) { - writeTextOfNode(currentSourceFile, node.importClause.name); - } - if (node.importClause.namedBindings && isVisibleNamedBinding(node.importClause.namedBindings)) { - if (currentWriterPos !== writer.getTextPos()) { - write(", "); - } - if (node.importClause.namedBindings.kind === 224) { - write("* as "); - writeTextOfNode(currentSourceFile, node.importClause.namedBindings.name); - } - else { - write("{ "); - emitCommaList(node.importClause.namedBindings.elements, emitImportOrExportSpecifier, resolver.isDeclarationVisible); - write(" }"); - } - } - write(" from "); - } - writeTextOfNode(currentSourceFile, node.moduleSpecifier); - write(";"); - writer.writeLine(); - } - function emitImportOrExportSpecifier(node) { - if (node.propertyName) { - writeTextOfNode(currentSourceFile, node.propertyName); - write(" as "); - } - writeTextOfNode(currentSourceFile, node.name); - } - function emitExportSpecifier(node) { - emitImportOrExportSpecifier(node); - var nodes = resolver.collectLinkedAliases(node.propertyName || node.name); - writeAsynchronousModuleElements(nodes); - } - function emitExportDeclaration(node) { - emitJsDocComments(node); - write("export "); - if (node.exportClause) { - write("{ "); - emitCommaList(node.exportClause.elements, emitExportSpecifier); - write(" }"); - } - else { - write("*"); - } - if (node.moduleSpecifier) { - write(" from "); - writeTextOfNode(currentSourceFile, node.moduleSpecifier); - } - write(";"); - writer.writeLine(); - } - function writeModuleDeclaration(node) { - emitJsDocComments(node); - emitModuleElementDeclarationFlags(node); - if (node.flags & 131072) { - write("namespace "); - } - else { - write("module "); - } - writeTextOfNode(currentSourceFile, node.name); - while (node.body.kind !== 219) { - node = node.body; - write("."); - writeTextOfNode(currentSourceFile, node.name); - } - var prevEnclosingDeclaration = enclosingDeclaration; - enclosingDeclaration = node; - write(" {"); - writeLine(); - increaseIndent(); - emitLines(node.body.statements); - decreaseIndent(); - write("}"); - writeLine(); - enclosingDeclaration = prevEnclosingDeclaration; - } - function writeTypeAliasDeclaration(node) { - var prevEnclosingDeclaration = enclosingDeclaration; - enclosingDeclaration = node; - emitJsDocComments(node); - emitModuleElementDeclarationFlags(node); - write("type "); - writeTextOfNode(currentSourceFile, node.name); - emitTypeParameters(node.typeParameters); - write(" = "); - emitTypeWithNewGetSymbolAccessibilityDiagnostic(node.type, getTypeAliasDeclarationVisibilityError); - write(";"); - writeLine(); - enclosingDeclaration = prevEnclosingDeclaration; - function getTypeAliasDeclarationVisibilityError(symbolAccesibilityResult) { - return { - diagnosticMessage: ts.Diagnostics.Exported_type_alias_0_has_or_is_using_private_name_1, - errorNode: node.type, - typeName: node.name - }; - } - } - function writeEnumDeclaration(node) { - emitJsDocComments(node); - emitModuleElementDeclarationFlags(node); - if (ts.isConst(node)) { - write("const "); - } - write("enum "); - writeTextOfNode(currentSourceFile, node.name); - write(" {"); - writeLine(); - increaseIndent(); - emitLines(node.members); - decreaseIndent(); - write("}"); - writeLine(); - } - function emitEnumMemberDeclaration(node) { - emitJsDocComments(node); - writeTextOfNode(currentSourceFile, node.name); - var enumMemberValue = resolver.getConstantValue(node); - if (enumMemberValue !== undefined) { - write(" = "); - write(enumMemberValue.toString()); - } - write(","); - writeLine(); - } - function isPrivateMethodTypeParameter(node) { - return node.parent.kind === 143 && (node.parent.flags & 32); - } - function emitTypeParameters(typeParameters) { - function emitTypeParameter(node) { - increaseIndent(); - emitJsDocComments(node); - decreaseIndent(); - writeTextOfNode(currentSourceFile, node.name); - if (node.constraint && !isPrivateMethodTypeParameter(node)) { - write(" extends "); - if (node.parent.kind === 152 || - node.parent.kind === 153 || - (node.parent.parent && node.parent.parent.kind === 155)) { - ts.Debug.assert(node.parent.kind === 143 || - node.parent.kind === 142 || - node.parent.kind === 152 || - node.parent.kind === 153 || - node.parent.kind === 147 || - node.parent.kind === 148); - emitType(node.constraint); - } - else { - emitTypeWithNewGetSymbolAccessibilityDiagnostic(node.constraint, getTypeParameterConstraintVisibilityError); - } - } - function getTypeParameterConstraintVisibilityError(symbolAccesibilityResult) { - var diagnosticMessage; - switch (node.parent.kind) { - case 214: - diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_class_has_or_is_using_private_name_1; - break; - case 215: - diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1; - break; - case 148: - diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; - break; - case 147: - diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; - break; - case 143: - case 142: - if (node.parent.flags & 128) { - diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1; - } - else if (node.parent.parent.kind === 214) { - diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_public_method_from_exported_class_has_or_is_using_private_name_1; - } - else { - diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1; - } - break; - case 213: - diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_function_has_or_is_using_private_name_1; - break; - default: - ts.Debug.fail("This is unknown parent for type parameter: " + node.parent.kind); - } - return { - diagnosticMessage: diagnosticMessage, - errorNode: node, - typeName: node.name - }; - } - } - if (typeParameters) { - write("<"); - emitCommaList(typeParameters, emitTypeParameter); - write(">"); - } - } - function emitHeritageClause(typeReferences, isImplementsList) { - if (typeReferences) { - write(isImplementsList ? " implements " : " extends "); - emitCommaList(typeReferences, emitTypeOfTypeReference); - } - function emitTypeOfTypeReference(node) { - if (ts.isSupportedExpressionWithTypeArguments(node)) { - emitTypeWithNewGetSymbolAccessibilityDiagnostic(node, getHeritageClauseVisibilityError); - } - else if (!isImplementsList && node.expression.kind === 93) { - write("null"); - } - function getHeritageClauseVisibilityError(symbolAccesibilityResult) { - var diagnosticMessage; - if (node.parent.parent.kind === 214) { - diagnosticMessage = isImplementsList ? - ts.Diagnostics.Implements_clause_of_exported_class_0_has_or_is_using_private_name_1 : - ts.Diagnostics.Extends_clause_of_exported_class_0_has_or_is_using_private_name_1; - } - else { - diagnosticMessage = ts.Diagnostics.Extends_clause_of_exported_interface_0_has_or_is_using_private_name_1; - } - return { - diagnosticMessage: diagnosticMessage, - errorNode: node, - typeName: node.parent.parent.name - }; - } - } - } - function writeClassDeclaration(node) { - function emitParameterProperties(constructorDeclaration) { - if (constructorDeclaration) { - ts.forEach(constructorDeclaration.parameters, function (param) { - if (param.flags & 112) { - emitPropertyDeclaration(param); - } - }); - } - } - emitJsDocComments(node); - emitModuleElementDeclarationFlags(node); - if (node.flags & 256) { - write("abstract "); - } - write("class "); - writeTextOfNode(currentSourceFile, node.name); - var prevEnclosingDeclaration = enclosingDeclaration; - enclosingDeclaration = node; - emitTypeParameters(node.typeParameters); - var baseTypeNode = ts.getClassExtendsHeritageClauseElement(node); - if (baseTypeNode) { - emitHeritageClause([baseTypeNode], false); - } - emitHeritageClause(ts.getClassImplementsHeritageClauseElements(node), true); - write(" {"); - writeLine(); - increaseIndent(); - emitParameterProperties(ts.getFirstConstructorWithBody(node)); - emitLines(node.members); - decreaseIndent(); - write("}"); - writeLine(); - enclosingDeclaration = prevEnclosingDeclaration; - } - function writeInterfaceDeclaration(node) { - emitJsDocComments(node); - emitModuleElementDeclarationFlags(node); - write("interface "); - writeTextOfNode(currentSourceFile, node.name); - var prevEnclosingDeclaration = enclosingDeclaration; - enclosingDeclaration = node; - emitTypeParameters(node.typeParameters); - emitHeritageClause(ts.getInterfaceBaseTypeNodes(node), false); - write(" {"); - writeLine(); - increaseIndent(); - emitLines(node.members); - decreaseIndent(); - write("}"); - writeLine(); - enclosingDeclaration = prevEnclosingDeclaration; - } - function emitPropertyDeclaration(node) { - if (ts.hasDynamicName(node)) { - return; - } - emitJsDocComments(node); - emitClassMemberDeclarationFlags(node); - emitVariableDeclaration(node); - write(";"); - writeLine(); - } - function emitVariableDeclaration(node) { - if (node.kind !== 211 || resolver.isDeclarationVisible(node)) { - if (ts.isBindingPattern(node.name)) { - emitBindingPattern(node.name); - } - else { - writeTextOfNode(currentSourceFile, node.name); - if ((node.kind === 141 || node.kind === 140) && ts.hasQuestionToken(node)) { - write("?"); - } - if ((node.kind === 141 || node.kind === 140) && node.parent.kind === 155) { - emitTypeOfVariableDeclarationFromTypeLiteral(node); - } - else if (!(node.flags & 32)) { - writeTypeOfDeclaration(node, node.type, getVariableDeclarationTypeVisibilityError); - } - } - } - function getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccesibilityResult) { - if (node.kind === 211) { - return symbolAccesibilityResult.errorModuleName ? - symbolAccesibilityResult.accessibility === 2 ? - ts.Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : - ts.Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_private_module_2 : - ts.Diagnostics.Exported_variable_0_has_or_is_using_private_name_1; - } - else if (node.kind === 141 || node.kind === 140) { - if (node.flags & 128) { - return symbolAccesibilityResult.errorModuleName ? - symbolAccesibilityResult.accessibility === 2 ? - ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : - ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : - ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_private_name_1; - } - else if (node.parent.kind === 214) { - return symbolAccesibilityResult.errorModuleName ? - symbolAccesibilityResult.accessibility === 2 ? - ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : - ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : - ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_private_name_1; - } - else { - return symbolAccesibilityResult.errorModuleName ? - ts.Diagnostics.Property_0_of_exported_interface_has_or_is_using_name_1_from_private_module_2 : - ts.Diagnostics.Property_0_of_exported_interface_has_or_is_using_private_name_1; - } - } - } - function getVariableDeclarationTypeVisibilityError(symbolAccesibilityResult) { - var diagnosticMessage = getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccesibilityResult); - return diagnosticMessage !== undefined ? { - diagnosticMessage: diagnosticMessage, - errorNode: node, - typeName: node.name - } : undefined; - } - function emitBindingPattern(bindingPattern) { - var elements = []; - for (var _i = 0, _a = bindingPattern.elements; _i < _a.length; _i++) { - var element = _a[_i]; - if (element.kind !== 187) { - elements.push(element); - } - } - emitCommaList(elements, emitBindingElement); - } - function emitBindingElement(bindingElement) { - function getBindingElementTypeVisibilityError(symbolAccesibilityResult) { - var diagnosticMessage = getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccesibilityResult); - return diagnosticMessage !== undefined ? { - diagnosticMessage: diagnosticMessage, - errorNode: bindingElement, - typeName: bindingElement.name - } : undefined; - } - if (bindingElement.name) { - if (ts.isBindingPattern(bindingElement.name)) { - emitBindingPattern(bindingElement.name); - } - else { - writeTextOfNode(currentSourceFile, bindingElement.name); - writeTypeOfDeclaration(bindingElement, undefined, getBindingElementTypeVisibilityError); - } - } - } - } - function emitTypeOfVariableDeclarationFromTypeLiteral(node) { - if (node.type) { - write(": "); - emitType(node.type); - } - } - function isVariableStatementVisible(node) { - return ts.forEach(node.declarationList.declarations, function (varDeclaration) { return resolver.isDeclarationVisible(varDeclaration); }); - } - function writeVariableStatement(node) { - emitJsDocComments(node); - emitModuleElementDeclarationFlags(node); - if (ts.isLet(node.declarationList)) { - write("let "); - } - else if (ts.isConst(node.declarationList)) { - write("const "); - } - else { - write("var "); - } - emitCommaList(node.declarationList.declarations, emitVariableDeclaration, resolver.isDeclarationVisible); - write(";"); - writeLine(); - } - function emitAccessorDeclaration(node) { - if (ts.hasDynamicName(node)) { - return; - } - var accessors = ts.getAllAccessorDeclarations(node.parent.members, node); - var accessorWithTypeAnnotation; - if (node === accessors.firstAccessor) { - emitJsDocComments(accessors.getAccessor); - emitJsDocComments(accessors.setAccessor); - emitClassMemberDeclarationFlags(node); - writeTextOfNode(currentSourceFile, node.name); - if (!(node.flags & 32)) { - accessorWithTypeAnnotation = node; - var type = getTypeAnnotationFromAccessor(node); - if (!type) { - var anotherAccessor = node.kind === 145 ? accessors.setAccessor : accessors.getAccessor; - type = getTypeAnnotationFromAccessor(anotherAccessor); - if (type) { - accessorWithTypeAnnotation = anotherAccessor; - } - } - writeTypeOfDeclaration(node, type, getAccessorDeclarationTypeVisibilityError); - } - write(";"); - writeLine(); - } - function getTypeAnnotationFromAccessor(accessor) { - if (accessor) { - return accessor.kind === 145 - ? accessor.type - : accessor.parameters.length > 0 - ? accessor.parameters[0].type - : undefined; - } - } - function getAccessorDeclarationTypeVisibilityError(symbolAccesibilityResult) { - var diagnosticMessage; - if (accessorWithTypeAnnotation.kind === 146) { - if (accessorWithTypeAnnotation.parent.flags & 128) { - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? - ts.Diagnostics.Parameter_0_of_public_static_property_setter_from_exported_class_has_or_is_using_name_1_from_private_module_2 : - ts.Diagnostics.Parameter_0_of_public_static_property_setter_from_exported_class_has_or_is_using_private_name_1; - } - else { - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? - ts.Diagnostics.Parameter_0_of_public_property_setter_from_exported_class_has_or_is_using_name_1_from_private_module_2 : - ts.Diagnostics.Parameter_0_of_public_property_setter_from_exported_class_has_or_is_using_private_name_1; - } - return { - diagnosticMessage: diagnosticMessage, - errorNode: accessorWithTypeAnnotation.parameters[0], - typeName: accessorWithTypeAnnotation.name - }; - } - else { - if (accessorWithTypeAnnotation.flags & 128) { - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? - symbolAccesibilityResult.accessibility === 2 ? - ts.Diagnostics.Return_type_of_public_static_property_getter_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : - ts.Diagnostics.Return_type_of_public_static_property_getter_from_exported_class_has_or_is_using_name_0_from_private_module_1 : - ts.Diagnostics.Return_type_of_public_static_property_getter_from_exported_class_has_or_is_using_private_name_0; - } - else { - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? - symbolAccesibilityResult.accessibility === 2 ? - ts.Diagnostics.Return_type_of_public_property_getter_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : - ts.Diagnostics.Return_type_of_public_property_getter_from_exported_class_has_or_is_using_name_0_from_private_module_1 : - ts.Diagnostics.Return_type_of_public_property_getter_from_exported_class_has_or_is_using_private_name_0; - } - return { - diagnosticMessage: diagnosticMessage, - errorNode: accessorWithTypeAnnotation.name, - typeName: undefined - }; - } - } - } - function writeFunctionDeclaration(node) { - if (ts.hasDynamicName(node)) { - return; - } - if (!resolver.isImplementationOfOverload(node)) { - emitJsDocComments(node); - if (node.kind === 213) { - emitModuleElementDeclarationFlags(node); - } - else if (node.kind === 143) { - emitClassMemberDeclarationFlags(node); - } - if (node.kind === 213) { - write("function "); - writeTextOfNode(currentSourceFile, node.name); - } - else if (node.kind === 144) { - write("constructor"); - } - else { - writeTextOfNode(currentSourceFile, node.name); - if (ts.hasQuestionToken(node)) { - write("?"); - } - } - emitSignatureDeclaration(node); - } - } - function emitSignatureDeclarationWithJsDocComments(node) { - emitJsDocComments(node); - emitSignatureDeclaration(node); - } - function emitSignatureDeclaration(node) { - if (node.kind === 148 || node.kind === 153) { - write("new "); - } - emitTypeParameters(node.typeParameters); - if (node.kind === 149) { - write("["); - } - else { - write("("); - } - var prevEnclosingDeclaration = enclosingDeclaration; - enclosingDeclaration = node; - emitCommaList(node.parameters, emitParameterDeclaration); - if (node.kind === 149) { - write("]"); - } - else { - write(")"); - } - var isFunctionTypeOrConstructorType = node.kind === 152 || node.kind === 153; - if (isFunctionTypeOrConstructorType || node.parent.kind === 155) { - if (node.type) { - write(isFunctionTypeOrConstructorType ? " => " : ": "); - emitType(node.type); - } - } - else if (node.kind !== 144 && !(node.flags & 32)) { - writeReturnTypeAtSignature(node, getReturnTypeVisibilityError); - } - enclosingDeclaration = prevEnclosingDeclaration; - if (!isFunctionTypeOrConstructorType) { - write(";"); - writeLine(); - } - function getReturnTypeVisibilityError(symbolAccesibilityResult) { - var diagnosticMessage; - switch (node.kind) { - case 148: - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? - ts.Diagnostics.Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : - ts.Diagnostics.Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_0; - break; - case 147: - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? - ts.Diagnostics.Return_type_of_call_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : - ts.Diagnostics.Return_type_of_call_signature_from_exported_interface_has_or_is_using_private_name_0; - break; - case 149: - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? - ts.Diagnostics.Return_type_of_index_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : - ts.Diagnostics.Return_type_of_index_signature_from_exported_interface_has_or_is_using_private_name_0; - break; - case 143: - case 142: - if (node.flags & 128) { - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? - symbolAccesibilityResult.accessibility === 2 ? - ts.Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : - 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 === 214) { - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? - symbolAccesibilityResult.accessibility === 2 ? - ts.Diagnostics.Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : - ts.Diagnostics.Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_private_module_1 : - ts.Diagnostics.Return_type_of_public_method_from_exported_class_has_or_is_using_private_name_0; - } - else { - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? - ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : - ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0; - } - break; - case 213: - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? - symbolAccesibilityResult.accessibility === 2 ? - ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : - ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_name_0_from_private_module_1 : - ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_private_name_0; - break; - default: - ts.Debug.fail("This is unknown kind for signature: " + node.kind); - } - return { - diagnosticMessage: diagnosticMessage, - errorNode: node.name || node - }; - } - } - function emitParameterDeclaration(node) { - increaseIndent(); - emitJsDocComments(node); - if (node.dotDotDotToken) { - write("..."); - } - if (ts.isBindingPattern(node.name)) { - emitBindingPattern(node.name); - } - else { - writeTextOfNode(currentSourceFile, node.name); - } - if (resolver.isOptionalParameter(node)) { - write("?"); - } - decreaseIndent(); - if (node.parent.kind === 152 || - node.parent.kind === 153 || - node.parent.parent.kind === 155) { - emitTypeOfVariableDeclarationFromTypeLiteral(node); - } - else if (!(node.parent.flags & 32)) { - writeTypeOfDeclaration(node, node.type, getParameterDeclarationTypeVisibilityError); - } - function getParameterDeclarationTypeVisibilityError(symbolAccesibilityResult) { - var diagnosticMessage = getParameterDeclarationTypeVisibilityDiagnosticMessage(symbolAccesibilityResult); - return diagnosticMessage !== undefined ? { - diagnosticMessage: diagnosticMessage, - errorNode: node, - typeName: node.name - } : undefined; - } - function getParameterDeclarationTypeVisibilityDiagnosticMessage(symbolAccesibilityResult) { - switch (node.parent.kind) { - case 144: - return symbolAccesibilityResult.errorModuleName ? - symbolAccesibilityResult.accessibility === 2 ? - ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : - ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_private_module_2 : - ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_private_name_1; - case 148: - return symbolAccesibilityResult.errorModuleName ? - ts.Diagnostics.Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : - ts.Diagnostics.Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; - case 147: - return symbolAccesibilityResult.errorModuleName ? - ts.Diagnostics.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : - ts.Diagnostics.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; - case 143: - case 142: - if (node.parent.flags & 128) { - return symbolAccesibilityResult.errorModuleName ? - symbolAccesibilityResult.accessibility === 2 ? - ts.Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : - 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 === 214) { - return symbolAccesibilityResult.errorModuleName ? - symbolAccesibilityResult.accessibility === 2 ? - ts.Diagnostics.Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : - ts.Diagnostics.Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_private_module_2 : - ts.Diagnostics.Parameter_0_of_public_method_from_exported_class_has_or_is_using_private_name_1; - } - else { - return symbolAccesibilityResult.errorModuleName ? - 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 213: - return symbolAccesibilityResult.errorModuleName ? - symbolAccesibilityResult.accessibility === 2 ? - ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : - ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_name_1_from_private_module_2 : - ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_private_name_1; - default: - ts.Debug.fail("This is unknown parent for parameter: " + node.parent.kind); - } - } - function emitBindingPattern(bindingPattern) { - if (bindingPattern.kind === 161) { - write("{"); - emitCommaList(bindingPattern.elements, emitBindingElement); - write("}"); - } - else if (bindingPattern.kind === 162) { - write("["); - var elements = bindingPattern.elements; - emitCommaList(elements, emitBindingElement); - if (elements && elements.hasTrailingComma) { - write(", "); - } - write("]"); - } - } - function emitBindingElement(bindingElement) { - function getBindingElementTypeVisibilityError(symbolAccesibilityResult) { - var diagnosticMessage = getParameterDeclarationTypeVisibilityDiagnosticMessage(symbolAccesibilityResult); - return diagnosticMessage !== undefined ? { - diagnosticMessage: diagnosticMessage, - errorNode: bindingElement, - typeName: bindingElement.name - } : undefined; - } - if (bindingElement.kind === 187) { - write(" "); - } - else if (bindingElement.kind === 163) { - if (bindingElement.propertyName) { - writeTextOfNode(currentSourceFile, bindingElement.propertyName); - write(": "); - } - if (bindingElement.name) { - if (ts.isBindingPattern(bindingElement.name)) { - emitBindingPattern(bindingElement.name); - } - else { - ts.Debug.assert(bindingElement.name.kind === 69); - if (bindingElement.dotDotDotToken) { - write("..."); - } - writeTextOfNode(currentSourceFile, bindingElement.name); - } - } - } - } - } - function emitNode(node) { - switch (node.kind) { - case 213: - case 218: - case 221: - case 215: - case 214: - case 216: - case 217: - return emitModuleElement(node, isModuleElementVisible(node)); - case 193: - return emitModuleElement(node, isVariableStatementVisible(node)); - case 222: - return emitModuleElement(node, !node.importClause); - case 228: - return emitExportDeclaration(node); - case 144: - case 143: - case 142: - return writeFunctionDeclaration(node); - case 148: - case 147: - case 149: - return emitSignatureDeclarationWithJsDocComments(node); - case 145: - case 146: - return emitAccessorDeclaration(node); - case 141: - case 140: - return emitPropertyDeclaration(node); - case 247: - return emitEnumMemberDeclaration(node); - case 227: - return emitExportAssignment(node); - case 248: - return emitSourceFile(node); - } - } - function writeReferencePath(referencedFile) { - var declFileName = referencedFile.flags & 8192 - ? referencedFile.fileName - : ts.shouldEmitToOwnFile(referencedFile, compilerOptions) - ? ts.getOwnEmitOutputFilePath(referencedFile, host, ".d.ts") - : ts.removeFileExtension(compilerOptions.outFile || compilerOptions.out) + ".d.ts"; - declFileName = ts.getRelativePathToDirectoryOrUrl(ts.getDirectoryPath(ts.normalizeSlashes(jsFilePath)), declFileName, host.getCurrentDirectory(), host.getCanonicalFileName, false); - referencePathsOutput += "/// " + newLine; - } - } - function writeDeclarationFile(jsFilePath, sourceFile, host, resolver, diagnostics) { - var emitDeclarationResult = emitDeclarations(host, resolver, diagnostics, jsFilePath, sourceFile); - if (!emitDeclarationResult.reportedDeclarationError) { - var declarationOutput = emitDeclarationResult.referencePathsOutput - + getDeclarationOutput(emitDeclarationResult.synchronousDeclarationOutput, emitDeclarationResult.moduleElementDeclarationEmitInfo); - ts.writeFile(host, diagnostics, ts.removeFileExtension(jsFilePath) + ".d.ts", declarationOutput, host.getCompilerOptions().emitBOM); - } - function getDeclarationOutput(synchronousDeclarationOutput, moduleElementDeclarationEmitInfo) { - var appliedSyncOutputPos = 0; - var declarationOutput = ""; - ts.forEach(moduleElementDeclarationEmitInfo, function (aliasEmitInfo) { - if (aliasEmitInfo.asynchronousOutput) { - declarationOutput += synchronousDeclarationOutput.substring(appliedSyncOutputPos, aliasEmitInfo.outputPos); - declarationOutput += getDeclarationOutput(aliasEmitInfo.asynchronousOutput, aliasEmitInfo.subModuleElementDeclarationEmitInfo); - appliedSyncOutputPos = aliasEmitInfo.outputPos; - } - }); - declarationOutput += synchronousDeclarationOutput.substring(appliedSyncOutputPos); - return declarationOutput; - } - } - ts.writeDeclarationFile = writeDeclarationFile; -})(ts || (ts = {})); -var ts; -(function (ts) { - function isExternalModuleOrDeclarationFile(sourceFile) { - return ts.isExternalModule(sourceFile) || ts.isDeclarationFile(sourceFile); - } - ts.isExternalModuleOrDeclarationFile = isExternalModuleOrDeclarationFile; - var entities = { - "quot": 0x0022, - "amp": 0x0026, - "apos": 0x0027, - "lt": 0x003C, - "gt": 0x003E, - "nbsp": 0x00A0, - "iexcl": 0x00A1, - "cent": 0x00A2, - "pound": 0x00A3, - "curren": 0x00A4, - "yen": 0x00A5, - "brvbar": 0x00A6, - "sect": 0x00A7, - "uml": 0x00A8, - "copy": 0x00A9, - "ordf": 0x00AA, - "laquo": 0x00AB, - "not": 0x00AC, - "shy": 0x00AD, - "reg": 0x00AE, - "macr": 0x00AF, - "deg": 0x00B0, - "plusmn": 0x00B1, - "sup2": 0x00B2, - "sup3": 0x00B3, - "acute": 0x00B4, - "micro": 0x00B5, - "para": 0x00B6, - "middot": 0x00B7, - "cedil": 0x00B8, - "sup1": 0x00B9, - "ordm": 0x00BA, - "raquo": 0x00BB, - "frac14": 0x00BC, - "frac12": 0x00BD, - "frac34": 0x00BE, - "iquest": 0x00BF, - "Agrave": 0x00C0, - "Aacute": 0x00C1, - "Acirc": 0x00C2, - "Atilde": 0x00C3, - "Auml": 0x00C4, - "Aring": 0x00C5, - "AElig": 0x00C6, - "Ccedil": 0x00C7, - "Egrave": 0x00C8, - "Eacute": 0x00C9, - "Ecirc": 0x00CA, - "Euml": 0x00CB, - "Igrave": 0x00CC, - "Iacute": 0x00CD, - "Icirc": 0x00CE, - "Iuml": 0x00CF, - "ETH": 0x00D0, - "Ntilde": 0x00D1, - "Ograve": 0x00D2, - "Oacute": 0x00D3, - "Ocirc": 0x00D4, - "Otilde": 0x00D5, - "Ouml": 0x00D6, - "times": 0x00D7, - "Oslash": 0x00D8, - "Ugrave": 0x00D9, - "Uacute": 0x00DA, - "Ucirc": 0x00DB, - "Uuml": 0x00DC, - "Yacute": 0x00DD, - "THORN": 0x00DE, - "szlig": 0x00DF, - "agrave": 0x00E0, - "aacute": 0x00E1, - "acirc": 0x00E2, - "atilde": 0x00E3, - "auml": 0x00E4, - "aring": 0x00E5, - "aelig": 0x00E6, - "ccedil": 0x00E7, - "egrave": 0x00E8, - "eacute": 0x00E9, - "ecirc": 0x00EA, - "euml": 0x00EB, - "igrave": 0x00EC, - "iacute": 0x00ED, - "icirc": 0x00EE, - "iuml": 0x00EF, - "eth": 0x00F0, - "ntilde": 0x00F1, - "ograve": 0x00F2, - "oacute": 0x00F3, - "ocirc": 0x00F4, - "otilde": 0x00F5, - "ouml": 0x00F6, - "divide": 0x00F7, - "oslash": 0x00F8, - "ugrave": 0x00F9, - "uacute": 0x00FA, - "ucirc": 0x00FB, - "uuml": 0x00FC, - "yacute": 0x00FD, - "thorn": 0x00FE, - "yuml": 0x00FF, - "OElig": 0x0152, - "oelig": 0x0153, - "Scaron": 0x0160, - "scaron": 0x0161, - "Yuml": 0x0178, - "fnof": 0x0192, - "circ": 0x02C6, - "tilde": 0x02DC, - "Alpha": 0x0391, - "Beta": 0x0392, - "Gamma": 0x0393, - "Delta": 0x0394, - "Epsilon": 0x0395, - "Zeta": 0x0396, - "Eta": 0x0397, - "Theta": 0x0398, - "Iota": 0x0399, - "Kappa": 0x039A, - "Lambda": 0x039B, - "Mu": 0x039C, - "Nu": 0x039D, - "Xi": 0x039E, - "Omicron": 0x039F, - "Pi": 0x03A0, - "Rho": 0x03A1, - "Sigma": 0x03A3, - "Tau": 0x03A4, - "Upsilon": 0x03A5, - "Phi": 0x03A6, - "Chi": 0x03A7, - "Psi": 0x03A8, - "Omega": 0x03A9, - "alpha": 0x03B1, - "beta": 0x03B2, - "gamma": 0x03B3, - "delta": 0x03B4, - "epsilon": 0x03B5, - "zeta": 0x03B6, - "eta": 0x03B7, - "theta": 0x03B8, - "iota": 0x03B9, - "kappa": 0x03BA, - "lambda": 0x03BB, - "mu": 0x03BC, - "nu": 0x03BD, - "xi": 0x03BE, - "omicron": 0x03BF, - "pi": 0x03C0, - "rho": 0x03C1, - "sigmaf": 0x03C2, - "sigma": 0x03C3, - "tau": 0x03C4, - "upsilon": 0x03C5, - "phi": 0x03C6, - "chi": 0x03C7, - "psi": 0x03C8, - "omega": 0x03C9, - "thetasym": 0x03D1, - "upsih": 0x03D2, - "piv": 0x03D6, - "ensp": 0x2002, - "emsp": 0x2003, - "thinsp": 0x2009, - "zwnj": 0x200C, - "zwj": 0x200D, - "lrm": 0x200E, - "rlm": 0x200F, - "ndash": 0x2013, - "mdash": 0x2014, - "lsquo": 0x2018, - "rsquo": 0x2019, - "sbquo": 0x201A, - "ldquo": 0x201C, - "rdquo": 0x201D, - "bdquo": 0x201E, - "dagger": 0x2020, - "Dagger": 0x2021, - "bull": 0x2022, - "hellip": 0x2026, - "permil": 0x2030, - "prime": 0x2032, - "Prime": 0x2033, - "lsaquo": 0x2039, - "rsaquo": 0x203A, - "oline": 0x203E, - "frasl": 0x2044, - "euro": 0x20AC, - "image": 0x2111, - "weierp": 0x2118, - "real": 0x211C, - "trade": 0x2122, - "alefsym": 0x2135, - "larr": 0x2190, - "uarr": 0x2191, - "rarr": 0x2192, - "darr": 0x2193, - "harr": 0x2194, - "crarr": 0x21B5, - "lArr": 0x21D0, - "uArr": 0x21D1, - "rArr": 0x21D2, - "dArr": 0x21D3, - "hArr": 0x21D4, - "forall": 0x2200, - "part": 0x2202, - "exist": 0x2203, - "empty": 0x2205, - "nabla": 0x2207, - "isin": 0x2208, - "notin": 0x2209, - "ni": 0x220B, - "prod": 0x220F, - "sum": 0x2211, - "minus": 0x2212, - "lowast": 0x2217, - "radic": 0x221A, - "prop": 0x221D, - "infin": 0x221E, - "ang": 0x2220, - "and": 0x2227, - "or": 0x2228, - "cap": 0x2229, - "cup": 0x222A, - "int": 0x222B, - "there4": 0x2234, - "sim": 0x223C, - "cong": 0x2245, - "asymp": 0x2248, - "ne": 0x2260, - "equiv": 0x2261, - "le": 0x2264, - "ge": 0x2265, - "sub": 0x2282, - "sup": 0x2283, - "nsub": 0x2284, - "sube": 0x2286, - "supe": 0x2287, - "oplus": 0x2295, - "otimes": 0x2297, - "perp": 0x22A5, - "sdot": 0x22C5, - "lceil": 0x2308, - "rceil": 0x2309, - "lfloor": 0x230A, - "rfloor": 0x230B, - "lang": 0x2329, - "rang": 0x232A, - "loz": 0x25CA, - "spades": 0x2660, - "clubs": 0x2663, - "hearts": 0x2665, - "diams": 0x2666 - }; - function emitFiles(resolver, host, targetSourceFile) { - var extendsHelper = "\nvar __extends = (this && this.__extends) || function (d, b) {\n for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];\n function __() { this.constructor = d; }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n};"; - var decorateHelper = "\nvar __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\n return c > 3 && r && Object.defineProperty(target, key, r), r;\n};"; - var metadataHelper = "\nvar __metadata = (this && this.__metadata) || function (k, v) {\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(k, v);\n};"; - var paramHelper = "\nvar __param = (this && this.__param) || function (paramIndex, decorator) {\n return function (target, key) { decorator(target, key, paramIndex); }\n};"; - var awaiterHelper = "\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promise, generator) {\n return new Promise(function (resolve, reject) {\n generator = generator.call(thisArg, _arguments);\n function cast(value) { return value instanceof Promise && value.constructor === Promise ? value : new Promise(function (resolve) { resolve(value); }); }\n function onfulfill(value) { try { step(\"next\", value); } catch (e) { reject(e); } }\n function onreject(value) { try { step(\"throw\", value); } catch (e) { reject(e); } }\n function step(verb, value) {\n var result = generator[verb](value);\n result.done ? resolve(result.value) : cast(result.value).then(onfulfill, onreject);\n }\n step(\"next\", void 0);\n });\n};"; - var compilerOptions = host.getCompilerOptions(); - var languageVersion = compilerOptions.target || 0; - var modulekind = compilerOptions.module ? compilerOptions.module : languageVersion === 2 ? 5 : 0; - var sourceMapDataList = compilerOptions.sourceMap || compilerOptions.inlineSourceMap ? [] : undefined; - var diagnostics = []; - var newLine = host.getNewLine(); - var jsxDesugaring = host.getCompilerOptions().jsx !== 1; - var shouldEmitJsx = function (s) { return (s.languageVariant === 1 && !jsxDesugaring); }; - if (targetSourceFile === undefined) { - ts.forEach(host.getSourceFiles(), function (sourceFile) { - if (ts.shouldEmitToOwnFile(sourceFile, compilerOptions)) { - var jsFilePath = ts.getOwnEmitOutputFilePath(sourceFile, host, shouldEmitJsx(sourceFile) ? ".jsx" : ".js"); - emitFile(jsFilePath, sourceFile); - } - }); - if (compilerOptions.outFile || compilerOptions.out) { - emitFile(compilerOptions.outFile || compilerOptions.out); - } - } - else { - if (ts.shouldEmitToOwnFile(targetSourceFile, compilerOptions)) { - var jsFilePath = ts.getOwnEmitOutputFilePath(targetSourceFile, host, shouldEmitJsx(targetSourceFile) ? ".jsx" : ".js"); - emitFile(jsFilePath, targetSourceFile); - } - else if (!ts.isDeclarationFile(targetSourceFile) && (compilerOptions.outFile || compilerOptions.out)) { - emitFile(compilerOptions.outFile || compilerOptions.out); - } - } - diagnostics = ts.sortAndDeduplicateDiagnostics(diagnostics); - return { - emitSkipped: false, - diagnostics: diagnostics, - sourceMaps: sourceMapDataList - }; - function isNodeDescendentOf(node, ancestor) { - while (node) { - if (node === ancestor) - return true; - node = node.parent; - } - return false; - } - function isUniqueLocalName(name, container) { - for (var node = container; isNodeDescendentOf(node, container); node = node.nextContainer) { - if (node.locals && ts.hasProperty(node.locals, name)) { - if (node.locals[name].flags & (107455 | 1048576 | 8388608)) { - return false; - } - } - } - return true; - } - function emitJavaScript(jsFilePath, root) { - var writer = ts.createTextWriter(newLine); - var write = writer.write, writeTextOfNode = writer.writeTextOfNode, writeLine = writer.writeLine, increaseIndent = writer.increaseIndent, decreaseIndent = writer.decreaseIndent; - var currentSourceFile; - var exportFunctionForFile; - var generatedNameSet = {}; - var nodeToGeneratedName = []; - var computedPropertyNamesToGeneratedNames; - var extendsEmitted = false; - var decorateEmitted = false; - var paramEmitted = false; - var awaiterEmitted = false; - var tempFlags = 0; - var tempVariables; - var tempParameters; - var externalImports; - var exportSpecifiers; - var exportEquals; - var hasExportStars; - var writeEmittedFiles = writeJavaScriptFile; - var detachedCommentsInfo; - var writeComment = ts.writeCommentRange; - var emit = emitNodeWithCommentsAndWithoutSourcemap; - var emitStart = function (node) { }; - var emitEnd = function (node) { }; - var emitToken = emitTokenText; - var scopeEmitStart = function (scopeDeclaration, scopeName) { }; - var scopeEmitEnd = function () { }; - var sourceMapData; - var emitLeadingCommentsOfPosition = compilerOptions.removeComments ? function (pos) { } : emitLeadingCommentsOfPositionWorker; - var moduleEmitDelegates = (_a = {}, - _a[5] = emitES6Module, - _a[2] = emitAMDModule, - _a[4] = emitSystemModule, - _a[3] = emitUMDModule, - _a[1] = emitCommonJSModule, - _a - ); - if (compilerOptions.sourceMap || compilerOptions.inlineSourceMap) { - initializeEmitterWithSourceMaps(); - } - if (root) { - emitSourceFile(root); - } - else { - ts.forEach(host.getSourceFiles(), function (sourceFile) { - if (!isExternalModuleOrDeclarationFile(sourceFile)) { - emitSourceFile(sourceFile); - } - }); - } - writeLine(); - writeEmittedFiles(writer.getText(), compilerOptions.emitBOM); - return; - function emitSourceFile(sourceFile) { - currentSourceFile = sourceFile; - exportFunctionForFile = undefined; - emit(sourceFile); - } - function isUniqueName(name) { - return !resolver.hasGlobalName(name) && - !ts.hasProperty(currentSourceFile.identifiers, name) && - !ts.hasProperty(generatedNameSet, name); - } - function makeTempVariableName(flags) { - if (flags && !(tempFlags & flags)) { - var name_20 = flags === 268435456 ? "_i" : "_n"; - if (isUniqueName(name_20)) { - tempFlags |= flags; - return name_20; - } - } - while (true) { - var count = tempFlags & 268435455; - tempFlags++; - if (count !== 8 && count !== 13) { - var name_21 = count < 26 ? "_" + String.fromCharCode(97 + count) : "_" + (count - 26); - if (isUniqueName(name_21)) { - return name_21; - } - } - } - } - function makeUniqueName(baseName) { - if (baseName.charCodeAt(baseName.length - 1) !== 95) { - baseName += "_"; - } - var i = 1; - while (true) { - var generatedName = baseName + i; - if (isUniqueName(generatedName)) { - return generatedNameSet[generatedName] = generatedName; - } - i++; - } - } - function generateNameForModuleOrEnum(node) { - var name = node.name.text; - return isUniqueLocalName(name, node) ? name : makeUniqueName(name); - } - function generateNameForImportOrExportDeclaration(node) { - var expr = ts.getExternalModuleName(node); - var baseName = expr.kind === 9 ? - ts.escapeIdentifier(ts.makeIdentifierFromModuleName(expr.text)) : "module"; - return makeUniqueName(baseName); - } - function generateNameForExportDefault() { - return makeUniqueName("default"); - } - function generateNameForClassExpression() { - return makeUniqueName("class"); - } - function generateNameForNode(node) { - switch (node.kind) { - case 69: - return makeUniqueName(node.text); - case 218: - case 217: - return generateNameForModuleOrEnum(node); - case 222: - case 228: - return generateNameForImportOrExportDeclaration(node); - case 213: - case 214: - case 227: - return generateNameForExportDefault(); - case 186: - return generateNameForClassExpression(); - } - } - function getGeneratedNameForNode(node) { - var id = ts.getNodeId(node); - return nodeToGeneratedName[id] || (nodeToGeneratedName[id] = ts.unescapeIdentifier(generateNameForNode(node))); - } - function initializeEmitterWithSourceMaps() { - var sourceMapDir; - var sourceMapSourceIndex = -1; - var sourceMapNameIndexMap = {}; - var sourceMapNameIndices = []; - function getSourceMapNameIndex() { - return sourceMapNameIndices.length ? ts.lastOrUndefined(sourceMapNameIndices) : -1; - } - var lastRecordedSourceMapSpan; - var lastEncodedSourceMapSpan = { - emittedLine: 1, - emittedColumn: 1, - sourceLine: 1, - sourceColumn: 1, - sourceIndex: 0 - }; - var lastEncodedNameIndex = 0; - function encodeLastRecordedSourceMapSpan() { - if (!lastRecordedSourceMapSpan || lastRecordedSourceMapSpan === lastEncodedSourceMapSpan) { - return; - } - var prevEncodedEmittedColumn = lastEncodedSourceMapSpan.emittedColumn; - if (lastEncodedSourceMapSpan.emittedLine === lastRecordedSourceMapSpan.emittedLine) { - if (sourceMapData.sourceMapMappings) { - sourceMapData.sourceMapMappings += ","; - } - } - else { - for (var encodedLine = lastEncodedSourceMapSpan.emittedLine; encodedLine < lastRecordedSourceMapSpan.emittedLine; encodedLine++) { - sourceMapData.sourceMapMappings += ";"; - } - prevEncodedEmittedColumn = 1; - } - sourceMapData.sourceMapMappings += base64VLQFormatEncode(lastRecordedSourceMapSpan.emittedColumn - prevEncodedEmittedColumn); - sourceMapData.sourceMapMappings += base64VLQFormatEncode(lastRecordedSourceMapSpan.sourceIndex - lastEncodedSourceMapSpan.sourceIndex); - sourceMapData.sourceMapMappings += base64VLQFormatEncode(lastRecordedSourceMapSpan.sourceLine - lastEncodedSourceMapSpan.sourceLine); - sourceMapData.sourceMapMappings += base64VLQFormatEncode(lastRecordedSourceMapSpan.sourceColumn - lastEncodedSourceMapSpan.sourceColumn); - if (lastRecordedSourceMapSpan.nameIndex >= 0) { - sourceMapData.sourceMapMappings += base64VLQFormatEncode(lastRecordedSourceMapSpan.nameIndex - lastEncodedNameIndex); - lastEncodedNameIndex = lastRecordedSourceMapSpan.nameIndex; - } - lastEncodedSourceMapSpan = lastRecordedSourceMapSpan; - sourceMapData.sourceMapDecodedMappings.push(lastEncodedSourceMapSpan); - function base64VLQFormatEncode(inValue) { - function base64FormatEncode(inValue) { - if (inValue < 64) { - return "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(inValue); - } - throw TypeError(inValue + ": not a 64 based value"); - } - if (inValue < 0) { - inValue = ((-inValue) << 1) + 1; - } - else { - inValue = inValue << 1; - } - var encodedStr = ""; - do { - var currentDigit = inValue & 31; - inValue = inValue >> 5; - if (inValue > 0) { - currentDigit = currentDigit | 32; - } - encodedStr = encodedStr + base64FormatEncode(currentDigit); - } while (inValue > 0); - return encodedStr; - } - } - function recordSourceMapSpan(pos) { - var sourceLinePos = ts.getLineAndCharacterOfPosition(currentSourceFile, pos); - sourceLinePos.line++; - sourceLinePos.character++; - var emittedLine = writer.getLine(); - var emittedColumn = writer.getColumn(); - if (!lastRecordedSourceMapSpan || - lastRecordedSourceMapSpan.emittedLine !== emittedLine || - lastRecordedSourceMapSpan.emittedColumn !== emittedColumn || - (lastRecordedSourceMapSpan.sourceIndex === sourceMapSourceIndex && - (lastRecordedSourceMapSpan.sourceLine > sourceLinePos.line || - (lastRecordedSourceMapSpan.sourceLine === sourceLinePos.line && lastRecordedSourceMapSpan.sourceColumn > sourceLinePos.character)))) { - encodeLastRecordedSourceMapSpan(); - lastRecordedSourceMapSpan = { - emittedLine: emittedLine, - emittedColumn: emittedColumn, - sourceLine: sourceLinePos.line, - sourceColumn: sourceLinePos.character, - nameIndex: getSourceMapNameIndex(), - sourceIndex: sourceMapSourceIndex - }; - } - else { - lastRecordedSourceMapSpan.sourceLine = sourceLinePos.line; - lastRecordedSourceMapSpan.sourceColumn = sourceLinePos.character; - lastRecordedSourceMapSpan.sourceIndex = sourceMapSourceIndex; - } - } - function recordEmitNodeStartSpan(node) { - recordSourceMapSpan(ts.skipTrivia(currentSourceFile.text, node.pos)); - } - function recordEmitNodeEndSpan(node) { - recordSourceMapSpan(node.end); - } - function writeTextWithSpanRecord(tokenKind, startPos, emitFn) { - var tokenStartPos = ts.skipTrivia(currentSourceFile.text, startPos); - recordSourceMapSpan(tokenStartPos); - var tokenEndPos = emitTokenText(tokenKind, tokenStartPos, emitFn); - recordSourceMapSpan(tokenEndPos); - return tokenEndPos; - } - function recordNewSourceFileStart(node) { - var sourcesDirectoryPath = compilerOptions.sourceRoot ? host.getCommonSourceDirectory() : sourceMapDir; - sourceMapData.sourceMapSources.push(ts.getRelativePathToDirectoryOrUrl(sourcesDirectoryPath, node.fileName, host.getCurrentDirectory(), host.getCanonicalFileName, true)); - sourceMapSourceIndex = sourceMapData.sourceMapSources.length - 1; - sourceMapData.inputSourceFileNames.push(node.fileName); - if (compilerOptions.inlineSources) { - if (!sourceMapData.sourceMapSourcesContent) { - sourceMapData.sourceMapSourcesContent = []; - } - sourceMapData.sourceMapSourcesContent.push(node.text); - } - } - function recordScopeNameOfNode(node, scopeName) { - function recordScopeNameIndex(scopeNameIndex) { - sourceMapNameIndices.push(scopeNameIndex); - } - function recordScopeNameStart(scopeName) { - var scopeNameIndex = -1; - if (scopeName) { - var parentIndex = getSourceMapNameIndex(); - if (parentIndex !== -1) { - var name_22 = node.name; - if (!name_22 || name_22.kind !== 136) { - scopeName = "." + scopeName; - } - scopeName = sourceMapData.sourceMapNames[parentIndex] + scopeName; - } - scopeNameIndex = ts.getProperty(sourceMapNameIndexMap, scopeName); - if (scopeNameIndex === undefined) { - scopeNameIndex = sourceMapData.sourceMapNames.length; - sourceMapData.sourceMapNames.push(scopeName); - sourceMapNameIndexMap[scopeName] = scopeNameIndex; - } - } - recordScopeNameIndex(scopeNameIndex); - } - if (scopeName) { - recordScopeNameStart(scopeName); - } - else if (node.kind === 213 || - node.kind === 173 || - node.kind === 143 || - node.kind === 142 || - node.kind === 145 || - node.kind === 146 || - node.kind === 218 || - node.kind === 214 || - node.kind === 217) { - if (node.name) { - var name_23 = node.name; - scopeName = name_23.kind === 136 - ? ts.getTextOfNode(name_23) - : node.name.text; - } - recordScopeNameStart(scopeName); - } - else { - recordScopeNameIndex(getSourceMapNameIndex()); - } - } - function recordScopeNameEnd() { - sourceMapNameIndices.pop(); - } - ; - function writeCommentRangeWithMap(curentSourceFile, writer, comment, newLine) { - recordSourceMapSpan(comment.pos); - ts.writeCommentRange(currentSourceFile, writer, comment, newLine); - recordSourceMapSpan(comment.end); - } - function serializeSourceMapContents(version, file, sourceRoot, sources, names, mappings, sourcesContent) { - if (typeof JSON !== "undefined") { - var map_2 = { - version: version, - file: file, - sourceRoot: sourceRoot, - sources: sources, - names: names, - mappings: mappings - }; - if (sourcesContent !== undefined) { - map_2.sourcesContent = sourcesContent; - } - return JSON.stringify(map_2); - } - return "{\"version\":" + version + ",\"file\":\"" + ts.escapeString(file) + "\",\"sourceRoot\":\"" + ts.escapeString(sourceRoot) + "\",\"sources\":[" + serializeStringArray(sources) + "],\"names\":[" + serializeStringArray(names) + "],\"mappings\":\"" + ts.escapeString(mappings) + "\" " + (sourcesContent !== undefined ? ",\"sourcesContent\":[" + serializeStringArray(sourcesContent) + "]" : "") + "}"; - function serializeStringArray(list) { - var output = ""; - for (var i = 0, n = list.length; i < n; i++) { - if (i) { - output += ","; - } - output += "\"" + ts.escapeString(list[i]) + "\""; - } - return output; - } - } - function writeJavaScriptAndSourceMapFile(emitOutput, writeByteOrderMark) { - encodeLastRecordedSourceMapSpan(); - var sourceMapText = serializeSourceMapContents(3, sourceMapData.sourceMapFile, sourceMapData.sourceMapSourceRoot, sourceMapData.sourceMapSources, sourceMapData.sourceMapNames, sourceMapData.sourceMapMappings, sourceMapData.sourceMapSourcesContent); - sourceMapDataList.push(sourceMapData); - var sourceMapUrl; - if (compilerOptions.inlineSourceMap) { - var base64SourceMapText = ts.convertToBase64(sourceMapText); - sourceMapUrl = "//# sourceMappingURL=data:application/json;base64," + base64SourceMapText; - } - else { - ts.writeFile(host, diagnostics, sourceMapData.sourceMapFilePath, sourceMapText, false); - sourceMapUrl = "//# sourceMappingURL=" + sourceMapData.jsSourceMappingURL; - } - writeJavaScriptFile(emitOutput + sourceMapUrl, writeByteOrderMark); - } - var sourceMapJsFile = ts.getBaseFileName(ts.normalizeSlashes(jsFilePath)); - sourceMapData = { - sourceMapFilePath: jsFilePath + ".map", - jsSourceMappingURL: sourceMapJsFile + ".map", - sourceMapFile: sourceMapJsFile, - sourceMapSourceRoot: compilerOptions.sourceRoot || "", - sourceMapSources: [], - inputSourceFileNames: [], - sourceMapNames: [], - sourceMapMappings: "", - sourceMapSourcesContent: undefined, - sourceMapDecodedMappings: [] - }; - sourceMapData.sourceMapSourceRoot = ts.normalizeSlashes(sourceMapData.sourceMapSourceRoot); - if (sourceMapData.sourceMapSourceRoot.length && sourceMapData.sourceMapSourceRoot.charCodeAt(sourceMapData.sourceMapSourceRoot.length - 1) !== 47) { - sourceMapData.sourceMapSourceRoot += ts.directorySeparator; - } - if (compilerOptions.mapRoot) { - sourceMapDir = ts.normalizeSlashes(compilerOptions.mapRoot); - if (root) { - sourceMapDir = ts.getDirectoryPath(ts.getSourceFilePathInNewDir(root, host, sourceMapDir)); - } - if (!ts.isRootedDiskPath(sourceMapDir) && !ts.isUrl(sourceMapDir)) { - sourceMapDir = ts.combinePaths(host.getCommonSourceDirectory(), sourceMapDir); - sourceMapData.jsSourceMappingURL = ts.getRelativePathToDirectoryOrUrl(ts.getDirectoryPath(ts.normalizePath(jsFilePath)), ts.combinePaths(sourceMapDir, sourceMapData.jsSourceMappingURL), host.getCurrentDirectory(), host.getCanonicalFileName, true); - } - else { - sourceMapData.jsSourceMappingURL = ts.combinePaths(sourceMapDir, sourceMapData.jsSourceMappingURL); - } - } - else { - sourceMapDir = ts.getDirectoryPath(ts.normalizePath(jsFilePath)); - } - function emitNodeWithSourceMap(node) { - if (node) { - if (ts.nodeIsSynthesized(node)) { - return emitNodeWithoutSourceMap(node); - } - if (node.kind !== 248) { - recordEmitNodeStartSpan(node); - emitNodeWithoutSourceMap(node); - recordEmitNodeEndSpan(node); - } - else { - recordNewSourceFileStart(node); - emitNodeWithoutSourceMap(node); - } - } - } - function emitNodeWithCommentsAndWithSourcemap(node) { - emitNodeConsideringCommentsOption(node, emitNodeWithSourceMap); - } - writeEmittedFiles = writeJavaScriptAndSourceMapFile; - emit = emitNodeWithCommentsAndWithSourcemap; - emitStart = recordEmitNodeStartSpan; - emitEnd = recordEmitNodeEndSpan; - emitToken = writeTextWithSpanRecord; - scopeEmitStart = recordScopeNameOfNode; - scopeEmitEnd = recordScopeNameEnd; - writeComment = writeCommentRangeWithMap; - } - function writeJavaScriptFile(emitOutput, writeByteOrderMark) { - ts.writeFile(host, diagnostics, jsFilePath, emitOutput, writeByteOrderMark); - } - function createTempVariable(flags) { - var result = ts.createSynthesizedNode(69); - result.text = makeTempVariableName(flags); - return result; - } - function recordTempDeclaration(name) { - if (!tempVariables) { - tempVariables = []; - } - tempVariables.push(name); - } - function createAndRecordTempVariable(flags) { - var temp = createTempVariable(flags); - recordTempDeclaration(temp); - return temp; - } - function emitTempDeclarations(newLine) { - if (tempVariables) { - if (newLine) { - writeLine(); - } - else { - write(" "); - } - write("var "); - emitCommaList(tempVariables); - write(";"); - } - } - function emitTokenText(tokenKind, startPos, emitFn) { - var tokenString = ts.tokenToString(tokenKind); - if (emitFn) { - emitFn(); - } - else { - write(tokenString); - } - return startPos + tokenString.length; - } - function emitOptional(prefix, node) { - if (node) { - write(prefix); - emit(node); - } - } - function emitParenthesizedIf(node, parenthesized) { - if (parenthesized) { - write("("); - } - emit(node); - if (parenthesized) { - write(")"); - } - } - function emitTrailingCommaIfPresent(nodeList) { - if (nodeList.hasTrailingComma) { - write(","); - } - } - function emitLinePreservingList(parent, nodes, allowTrailingComma, spacesBetweenBraces) { - ts.Debug.assert(nodes.length > 0); - increaseIndent(); - if (nodeStartPositionsAreOnSameLine(parent, nodes[0])) { - if (spacesBetweenBraces) { - write(" "); - } - } - else { - writeLine(); - } - for (var i = 0, n = nodes.length; i < n; i++) { - if (i) { - if (nodeEndIsOnSameLineAsNodeStart(nodes[i - 1], nodes[i])) { - write(", "); - } - else { - write(","); - writeLine(); - } - } - emit(nodes[i]); - } - if (nodes.hasTrailingComma && allowTrailingComma) { - write(","); - } - decreaseIndent(); - if (nodeEndPositionsAreOnSameLine(parent, ts.lastOrUndefined(nodes))) { - if (spacesBetweenBraces) { - write(" "); - } - } - else { - writeLine(); - } - } - function emitList(nodes, start, count, multiLine, trailingComma, leadingComma, noTrailingNewLine, emitNode) { - if (!emitNode) { - emitNode = emit; - } - for (var i = 0; i < count; i++) { - if (multiLine) { - if (i || leadingComma) { - write(","); - } - writeLine(); - } - else { - if (i || leadingComma) { - write(", "); - } - } - var node = nodes[start + i]; - emitTrailingCommentsOfPosition(node.pos); - emitNode(node); - leadingComma = true; - } - if (trailingComma) { - write(","); - } - if (multiLine && !noTrailingNewLine) { - writeLine(); - } - return count; - } - function emitCommaList(nodes) { - if (nodes) { - emitList(nodes, 0, nodes.length, false, false); - } - } - function emitLines(nodes) { - emitLinesStartingAt(nodes, 0); - } - function emitLinesStartingAt(nodes, startIndex) { - for (var i = startIndex; i < nodes.length; i++) { - writeLine(); - emit(nodes[i]); - } - } - function isBinaryOrOctalIntegerLiteral(node, text) { - if (node.kind === 8 && text.length > 1) { - switch (text.charCodeAt(1)) { - case 98: - case 66: - case 111: - case 79: - return true; - } - } - return false; - } - function emitLiteral(node) { - var text = getLiteralText(node); - if ((compilerOptions.sourceMap || compilerOptions.inlineSourceMap) && (node.kind === 9 || ts.isTemplateLiteralKind(node.kind))) { - writer.writeLiteral(text); - } - else if (languageVersion < 2 && isBinaryOrOctalIntegerLiteral(node, text)) { - write(node.text); - } - else { - write(text); - } - } - function getLiteralText(node) { - if (languageVersion < 2 && (ts.isTemplateLiteralKind(node.kind) || node.hasExtendedUnicodeEscape)) { - return getQuotedEscapedLiteralText("\"", node.text, "\""); - } - if (node.parent) { - return ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, node); - } - switch (node.kind) { - case 9: - return getQuotedEscapedLiteralText("\"", node.text, "\""); - case 11: - return getQuotedEscapedLiteralText("`", node.text, "`"); - case 12: - return getQuotedEscapedLiteralText("`", node.text, "${"); - case 13: - return getQuotedEscapedLiteralText("}", node.text, "${"); - case 14: - return getQuotedEscapedLiteralText("}", node.text, "`"); - case 8: - return node.text; - } - ts.Debug.fail("Literal kind '" + node.kind + "' not accounted for."); - } - function getQuotedEscapedLiteralText(leftQuote, text, rightQuote) { - return leftQuote + ts.escapeNonAsciiCharacters(ts.escapeString(text)) + rightQuote; - } - function emitDownlevelRawTemplateLiteral(node) { - var text = ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, node); - var isLast = node.kind === 11 || node.kind === 14; - text = text.substring(1, text.length - (isLast ? 1 : 2)); - text = text.replace(/\r\n?/g, "\n"); - text = ts.escapeString(text); - write("\"" + text + "\""); - } - function emitDownlevelTaggedTemplateArray(node, literalEmitter) { - write("["); - if (node.template.kind === 11) { - literalEmitter(node.template); - } - else { - literalEmitter(node.template.head); - ts.forEach(node.template.templateSpans, function (child) { - write(", "); - literalEmitter(child.literal); - }); - } - write("]"); - } - function emitDownlevelTaggedTemplate(node) { - var tempVariable = createAndRecordTempVariable(0); - write("("); - emit(tempVariable); - write(" = "); - emitDownlevelTaggedTemplateArray(node, emit); - write(", "); - emit(tempVariable); - write(".raw = "); - emitDownlevelTaggedTemplateArray(node, emitDownlevelRawTemplateLiteral); - write(", "); - emitParenthesizedIf(node.tag, needsParenthesisForPropertyAccessOrInvocation(node.tag)); - write("("); - emit(tempVariable); - if (node.template.kind === 183) { - ts.forEach(node.template.templateSpans, function (templateSpan) { - write(", "); - var needsParens = templateSpan.expression.kind === 181 - && templateSpan.expression.operatorToken.kind === 24; - emitParenthesizedIf(templateSpan.expression, needsParens); - }); - } - write("))"); - } - function emitTemplateExpression(node) { - if (languageVersion >= 2) { - ts.forEachChild(node, emit); - return; - } - var emitOuterParens = ts.isExpression(node.parent) - && templateNeedsParens(node, node.parent); - if (emitOuterParens) { - write("("); - } - var headEmitted = false; - if (shouldEmitTemplateHead()) { - emitLiteral(node.head); - headEmitted = true; - } - for (var i = 0, n = node.templateSpans.length; i < n; i++) { - var templateSpan = node.templateSpans[i]; - var needsParens = templateSpan.expression.kind !== 172 - && comparePrecedenceToBinaryPlus(templateSpan.expression) !== 1; - if (i > 0 || headEmitted) { - write(" + "); - } - emitParenthesizedIf(templateSpan.expression, needsParens); - if (templateSpan.literal.text.length !== 0) { - write(" + "); - emitLiteral(templateSpan.literal); - } - } - if (emitOuterParens) { - write(")"); - } - function shouldEmitTemplateHead() { - ts.Debug.assert(node.templateSpans.length !== 0); - return node.head.text.length !== 0 || node.templateSpans[0].literal.text.length === 0; - } - function templateNeedsParens(template, parent) { - switch (parent.kind) { - case 168: - case 169: - return parent.expression === template; - case 170: - case 172: - return false; - default: - return comparePrecedenceToBinaryPlus(parent) !== -1; - } - } - function comparePrecedenceToBinaryPlus(expression) { - switch (expression.kind) { - case 181: - switch (expression.operatorToken.kind) { - case 37: - case 39: - case 40: - return 1; - case 35: - case 36: - return 0; - default: - return -1; - } - case 184: - case 182: - return -1; - default: - return 1; - } - } - } - function emitTemplateSpan(span) { - emit(span.expression); - emit(span.literal); - } - function jsxEmitReact(node) { - function emitTagName(name) { - if (name.kind === 69 && ts.isIntrinsicJsxName(name.text)) { - write("\""); - emit(name); - write("\""); - } - else { - emit(name); - } - } - function emitAttributeName(name) { - if (/[A-Za-z_]+[\w*]/.test(name.text)) { - write("\""); - emit(name); - write("\""); - } - else { - emit(name); - } - } - function emitJsxAttribute(node) { - emitAttributeName(node.name); - write(": "); - if (node.initializer) { - emit(node.initializer); - } - else { - write("true"); - } - } - function emitJsxElement(openingNode, children) { - var syntheticReactRef = ts.createSynthesizedNode(69); - syntheticReactRef.text = "React"; - syntheticReactRef.parent = openingNode; - emitLeadingComments(openingNode); - emitExpressionIdentifier(syntheticReactRef); - write(".createElement("); - emitTagName(openingNode.tagName); - write(", "); - if (openingNode.attributes.length === 0) { - write("null"); - } - else { - var attrs = openingNode.attributes; - if (ts.forEach(attrs, function (attr) { return attr.kind === 239; })) { - emitExpressionIdentifier(syntheticReactRef); - write(".__spread("); - var haveOpenedObjectLiteral = false; - for (var i_1 = 0; i_1 < attrs.length; i_1++) { - if (attrs[i_1].kind === 239) { - if (i_1 === 0) { - write("{}, "); - } - if (haveOpenedObjectLiteral) { - write("}"); - haveOpenedObjectLiteral = false; - } - if (i_1 > 0) { - write(", "); - } - emit(attrs[i_1].expression); - } - else { - ts.Debug.assert(attrs[i_1].kind === 238); - if (haveOpenedObjectLiteral) { - write(", "); - } - else { - haveOpenedObjectLiteral = true; - if (i_1 > 0) { - write(", "); - } - write("{"); - } - emitJsxAttribute(attrs[i_1]); - } - } - if (haveOpenedObjectLiteral) - write("}"); - write(")"); - } - else { - write("{"); - for (var i = 0; i < attrs.length; i++) { - if (i > 0) { - write(", "); - } - emitJsxAttribute(attrs[i]); - } - write("}"); - } - } - if (children) { - for (var i = 0; i < children.length; i++) { - if (children[i].kind === 240 && !(children[i].expression)) { - continue; - } - if (children[i].kind === 236) { - var text = getTextToEmit(children[i]); - if (text !== undefined) { - write(", \""); - write(text); - write("\""); - } - } - else { - write(", "); - emit(children[i]); - } - } - } - write(")"); - emitTrailingComments(openingNode); - } - if (node.kind === 233) { - emitJsxElement(node.openingElement, node.children); - } - else { - ts.Debug.assert(node.kind === 234); - emitJsxElement(node); - } - } - function jsxEmitPreserve(node) { - function emitJsxAttribute(node) { - emit(node.name); - if (node.initializer) { - write("="); - emit(node.initializer); - } - } - function emitJsxSpreadAttribute(node) { - write("{..."); - emit(node.expression); - write("}"); - } - function emitAttributes(attribs) { - for (var i = 0, n = attribs.length; i < n; i++) { - if (i > 0) { - write(" "); - } - if (attribs[i].kind === 239) { - emitJsxSpreadAttribute(attribs[i]); - } - else { - ts.Debug.assert(attribs[i].kind === 238); - emitJsxAttribute(attribs[i]); - } - } - } - function emitJsxOpeningOrSelfClosingElement(node) { - write("<"); - emit(node.tagName); - if (node.attributes.length > 0 || (node.kind === 234)) { - write(" "); - } - emitAttributes(node.attributes); - if (node.kind === 234) { - write("/>"); - } - else { - write(">"); - } - } - function emitJsxClosingElement(node) { - write(""); - } - function emitJsxElement(node) { - emitJsxOpeningOrSelfClosingElement(node.openingElement); - for (var i = 0, n = node.children.length; i < n; i++) { - emit(node.children[i]); - } - emitJsxClosingElement(node.closingElement); - } - if (node.kind === 233) { - emitJsxElement(node); - } - else { - ts.Debug.assert(node.kind === 234); - emitJsxOpeningOrSelfClosingElement(node); - } - } - function emitExpressionForPropertyName(node) { - ts.Debug.assert(node.kind !== 163); - if (node.kind === 9) { - emitLiteral(node); - } - else if (node.kind === 136) { - if (ts.nodeIsDecorated(node.parent)) { - if (!computedPropertyNamesToGeneratedNames) { - computedPropertyNamesToGeneratedNames = []; - } - var generatedName = computedPropertyNamesToGeneratedNames[ts.getNodeId(node)]; - if (generatedName) { - write(generatedName); - return; - } - generatedName = createAndRecordTempVariable(0).text; - computedPropertyNamesToGeneratedNames[ts.getNodeId(node)] = generatedName; - write(generatedName); - write(" = "); - } - emit(node.expression); - } - else { - write("\""); - if (node.kind === 8) { - write(node.text); - } - else { - writeTextOfNode(currentSourceFile, node); - } - write("\""); - } - } - function isExpressionIdentifier(node) { - var parent = node.parent; - switch (parent.kind) { - case 164: - case 189: - case 181: - case 168: - case 241: - case 136: - case 182: - case 139: - case 175: - case 197: - case 167: - case 227: - case 195: - case 188: - case 199: - case 200: - case 201: - case 196: - case 234: - case 235: - case 239: - case 240: - case 169: - case 172: - case 180: - case 179: - case 204: - case 246: - case 185: - case 206: - case 170: - case 190: - case 208: - case 171: - case 176: - case 177: - case 198: - case 205: - case 184: - return true; - case 163: - case 247: - case 138: - case 245: - case 141: - case 211: - return parent.initializer === node; - case 166: - return parent.expression === node; - case 174: - case 173: - return parent.body === node; - case 221: - return parent.moduleReference === node; - case 135: - return parent.left === node; - } - return false; - } - function emitExpressionIdentifier(node) { - if (resolver.getNodeCheckFlags(node) & 2048) { - write("_arguments"); - return; - } - var container = resolver.getReferencedExportContainer(node); - if (container) { - if (container.kind === 248) { - if (modulekind !== 5 && modulekind !== 4) { - write("exports."); - } - } - else { - write(getGeneratedNameForNode(container)); - write("."); - } - } - else { - if (modulekind !== 5) { - var declaration = resolver.getReferencedImportDeclaration(node); - if (declaration) { - if (declaration.kind === 223) { - write(getGeneratedNameForNode(declaration.parent)); - write(languageVersion === 0 ? "[\"default\"]" : ".default"); - return; - } - else if (declaration.kind === 226) { - write(getGeneratedNameForNode(declaration.parent.parent.parent)); - var name_24 = declaration.propertyName || declaration.name; - var identifier = ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, name_24); - if (languageVersion === 0 && identifier === "default") { - write("[\"default\"]"); - } - else { - write("."); - write(identifier); - } - return; - } - } - } - if (languageVersion !== 2) { - var declaration = resolver.getReferencedNestedRedeclaration(node); - if (declaration) { - write(getGeneratedNameForNode(declaration.name)); - return; - } - } - } - if (ts.nodeIsSynthesized(node)) { - write(node.text); - } - else { - writeTextOfNode(currentSourceFile, node); - } - } - function isNameOfNestedRedeclaration(node) { - if (languageVersion < 2) { - var parent_6 = node.parent; - switch (parent_6.kind) { - case 163: - case 214: - case 217: - case 211: - return parent_6.name === node && resolver.isNestedRedeclaration(parent_6); - } - } - return false; - } - function emitIdentifier(node) { - if (!node.parent) { - write(node.text); - } - else if (isExpressionIdentifier(node)) { - emitExpressionIdentifier(node); - } - else if (isNameOfNestedRedeclaration(node)) { - write(getGeneratedNameForNode(node)); - } - else if (ts.nodeIsSynthesized(node)) { - write(node.text); - } - else { - writeTextOfNode(currentSourceFile, node); - } - } - function emitThis(node) { - if (resolver.getNodeCheckFlags(node) & 2) { - write("_this"); - } - else { - write("this"); - } - } - function emitSuper(node) { - if (languageVersion >= 2) { - write("super"); - } - else { - var flags = resolver.getNodeCheckFlags(node); - if (flags & 256) { - write("_super.prototype"); - } - else { - write("_super"); - } - } - } - function emitObjectBindingPattern(node) { - write("{ "); - var elements = node.elements; - emitList(elements, 0, elements.length, false, elements.hasTrailingComma); - write(" }"); - } - function emitArrayBindingPattern(node) { - write("["); - var elements = node.elements; - emitList(elements, 0, elements.length, false, elements.hasTrailingComma); - write("]"); - } - function emitBindingElement(node) { - if (node.propertyName) { - emit(node.propertyName); - write(": "); - } - if (node.dotDotDotToken) { - write("..."); - } - if (ts.isBindingPattern(node.name)) { - emit(node.name); - } - else { - emitModuleMemberName(node); - } - emitOptional(" = ", node.initializer); - } - function emitSpreadElementExpression(node) { - write("..."); - emit(node.expression); - } - function emitYieldExpression(node) { - write(ts.tokenToString(114)); - if (node.asteriskToken) { - write("*"); - } - if (node.expression) { - write(" "); - emit(node.expression); - } - } - function emitAwaitExpression(node) { - var needsParenthesis = needsParenthesisForAwaitExpressionAsYield(node); - if (needsParenthesis) { - write("("); - } - write(ts.tokenToString(114)); - write(" "); - emit(node.expression); - if (needsParenthesis) { - write(")"); - } - } - function needsParenthesisForAwaitExpressionAsYield(node) { - if (node.parent.kind === 181 && !ts.isAssignmentOperator(node.parent.operatorToken.kind)) { - return true; - } - else if (node.parent.kind === 182 && node.parent.condition === node) { - return true; - } - return false; - } - function needsParenthesisForPropertyAccessOrInvocation(node) { - switch (node.kind) { - case 69: - case 164: - case 166: - case 167: - case 168: - case 172: - return false; - } - return true; - } - function emitListWithSpread(elements, needsUniqueCopy, multiLine, trailingComma, useConcat) { - var pos = 0; - var group = 0; - var length = elements.length; - while (pos < length) { - if (group === 1 && useConcat) { - write(".concat("); - } - else if (group > 0) { - write(", "); - } - var e = elements[pos]; - if (e.kind === 185) { - e = e.expression; - emitParenthesizedIf(e, group === 0 && needsParenthesisForPropertyAccessOrInvocation(e)); - pos++; - if (pos === length && group === 0 && needsUniqueCopy && e.kind !== 164) { - write(".slice()"); - } - } - else { - var i = pos; - while (i < length && elements[i].kind !== 185) { - i++; - } - write("["); - if (multiLine) { - increaseIndent(); - } - emitList(elements, pos, i - pos, multiLine, trailingComma && i === length); - if (multiLine) { - decreaseIndent(); - } - write("]"); - pos = i; - } - group++; - } - if (group > 1) { - if (useConcat) { - write(")"); - } - } - } - function isSpreadElementExpression(node) { - return node.kind === 185; - } - function emitArrayLiteral(node) { - var elements = node.elements; - if (elements.length === 0) { - write("[]"); - } - else if (languageVersion >= 2 || !ts.forEach(elements, isSpreadElementExpression)) { - write("["); - emitLinePreservingList(node, node.elements, elements.hasTrailingComma, false); - write("]"); - } - else { - emitListWithSpread(elements, true, (node.flags & 2048) !== 0, elements.hasTrailingComma, true); - } - } - function emitObjectLiteralBody(node, numElements) { - if (numElements === 0) { - write("{}"); - return; - } - write("{"); - if (numElements > 0) { - var properties = node.properties; - if (numElements === properties.length) { - emitLinePreservingList(node, properties, languageVersion >= 1, true); - } - else { - var multiLine = (node.flags & 2048) !== 0; - if (!multiLine) { - write(" "); - } - else { - increaseIndent(); - } - emitList(properties, 0, numElements, multiLine, false); - if (!multiLine) { - write(" "); - } - else { - decreaseIndent(); - } - } - } - write("}"); - } - function emitDownlevelObjectLiteralWithComputedProperties(node, firstComputedPropertyIndex) { - var multiLine = (node.flags & 2048) !== 0; - var properties = node.properties; - write("("); - if (multiLine) { - increaseIndent(); - } - var tempVar = createAndRecordTempVariable(0); - emit(tempVar); - write(" = "); - emitObjectLiteralBody(node, firstComputedPropertyIndex); - for (var i = firstComputedPropertyIndex, n = properties.length; i < n; i++) { - writeComma(); - var property = properties[i]; - emitStart(property); - if (property.kind === 145 || property.kind === 146) { - var accessors = ts.getAllAccessorDeclarations(node.properties, property); - if (property !== accessors.firstAccessor) { - continue; - } - write("Object.defineProperty("); - emit(tempVar); - write(", "); - emitStart(node.name); - emitExpressionForPropertyName(property.name); - emitEnd(property.name); - write(", {"); - increaseIndent(); - if (accessors.getAccessor) { - writeLine(); - emitLeadingComments(accessors.getAccessor); - write("get: "); - emitStart(accessors.getAccessor); - write("function "); - emitSignatureAndBody(accessors.getAccessor); - emitEnd(accessors.getAccessor); - emitTrailingComments(accessors.getAccessor); - write(","); - } - if (accessors.setAccessor) { - writeLine(); - emitLeadingComments(accessors.setAccessor); - write("set: "); - emitStart(accessors.setAccessor); - write("function "); - emitSignatureAndBody(accessors.setAccessor); - emitEnd(accessors.setAccessor); - emitTrailingComments(accessors.setAccessor); - write(","); - } - writeLine(); - write("enumerable: true,"); - writeLine(); - write("configurable: true"); - decreaseIndent(); - writeLine(); - write("})"); - emitEnd(property); - } - else { - emitLeadingComments(property); - emitStart(property.name); - emit(tempVar); - emitMemberAccessForPropertyName(property.name); - emitEnd(property.name); - write(" = "); - if (property.kind === 245) { - emit(property.initializer); - } - else if (property.kind === 246) { - emitExpressionIdentifier(property.name); - } - else if (property.kind === 143) { - emitFunctionDeclaration(property); - } - else { - ts.Debug.fail("ObjectLiteralElement type not accounted for: " + property.kind); - } - } - emitEnd(property); - } - writeComma(); - emit(tempVar); - if (multiLine) { - decreaseIndent(); - writeLine(); - } - write(")"); - function writeComma() { - if (multiLine) { - write(","); - writeLine(); - } - else { - write(", "); - } - } - } - function emitObjectLiteral(node) { - var properties = node.properties; - if (languageVersion < 2) { - var numProperties = properties.length; - var numInitialNonComputedProperties = numProperties; - for (var i = 0, n = properties.length; i < n; i++) { - if (properties[i].name.kind === 136) { - numInitialNonComputedProperties = i; - break; - } - } - var hasComputedProperty = numInitialNonComputedProperties !== properties.length; - if (hasComputedProperty) { - emitDownlevelObjectLiteralWithComputedProperties(node, numInitialNonComputedProperties); - return; - } - } - emitObjectLiteralBody(node, properties.length); - } - function createBinaryExpression(left, operator, right, startsOnNewLine) { - var result = ts.createSynthesizedNode(181, startsOnNewLine); - result.operatorToken = ts.createSynthesizedNode(operator); - result.left = left; - result.right = right; - return result; - } - function createPropertyAccessExpression(expression, name) { - var result = ts.createSynthesizedNode(166); - result.expression = parenthesizeForAccess(expression); - result.dotToken = ts.createSynthesizedNode(21); - result.name = name; - return result; - } - function createElementAccessExpression(expression, argumentExpression) { - var result = ts.createSynthesizedNode(167); - result.expression = parenthesizeForAccess(expression); - result.argumentExpression = argumentExpression; - return result; - } - function parenthesizeForAccess(expr) { - while (expr.kind === 171 || expr.kind === 189) { - expr = expr.expression; - } - if (ts.isLeftHandSideExpression(expr) && - expr.kind !== 169 && - expr.kind !== 8) { - return expr; - } - var node = ts.createSynthesizedNode(172); - node.expression = expr; - return node; - } - function emitComputedPropertyName(node) { - write("["); - emitExpressionForPropertyName(node); - write("]"); - } - function emitMethod(node) { - if (languageVersion >= 2 && node.asteriskToken) { - write("*"); - } - emit(node.name); - if (languageVersion < 2) { - write(": function "); - } - emitSignatureAndBody(node); - } - function emitPropertyAssignment(node) { - emit(node.name); - write(": "); - emitTrailingCommentsOfPosition(node.initializer.pos); - emit(node.initializer); - } - function isNamespaceExportReference(node) { - var container = resolver.getReferencedExportContainer(node); - return container && container.kind !== 248; - } - function emitShorthandPropertyAssignment(node) { - writeTextOfNode(currentSourceFile, node.name); - if (languageVersion < 2 || isNamespaceExportReference(node.name)) { - write(": "); - emit(node.name); - } - if (languageVersion >= 2 && node.objectAssignmentInitializer) { - write(" = "); - emit(node.objectAssignmentInitializer); - } - } - function tryEmitConstantValue(node) { - var constantValue = tryGetConstEnumValue(node); - if (constantValue !== undefined) { - write(constantValue.toString()); - if (!compilerOptions.removeComments) { - var propertyName = node.kind === 166 ? ts.declarationNameToString(node.name) : ts.getTextOfNode(node.argumentExpression); - write(" /* " + propertyName + " */"); - } - return true; - } - return false; - } - function tryGetConstEnumValue(node) { - if (compilerOptions.isolatedModules) { - return undefined; - } - return node.kind === 166 || node.kind === 167 - ? resolver.getConstantValue(node) - : undefined; - } - function indentIfOnDifferentLines(parent, node1, node2, valueToWriteWhenNotIndenting) { - var realNodesAreOnDifferentLines = !ts.nodeIsSynthesized(parent) && !nodeEndIsOnSameLineAsNodeStart(node1, node2); - var synthesizedNodeIsOnDifferentLine = synthesizedNodeStartsOnNewLine(node2); - if (realNodesAreOnDifferentLines || synthesizedNodeIsOnDifferentLine) { - increaseIndent(); - writeLine(); - return true; - } - else { - if (valueToWriteWhenNotIndenting) { - write(valueToWriteWhenNotIndenting); - } - return false; - } - } - function emitPropertyAccess(node) { - if (tryEmitConstantValue(node)) { - return; - } - emit(node.expression); - var indentedBeforeDot = indentIfOnDifferentLines(node, node.expression, node.dotToken); - var shouldEmitSpace; - if (!indentedBeforeDot) { - if (node.expression.kind === 8) { - var text = ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, node.expression); - shouldEmitSpace = text.indexOf(ts.tokenToString(21)) < 0; - } - else { - var constantValue = tryGetConstEnumValue(node.expression); - shouldEmitSpace = isFinite(constantValue) && Math.floor(constantValue) === constantValue; - } - } - if (shouldEmitSpace) { - write(" ."); - } - else { - write("."); - } - var indentedAfterDot = indentIfOnDifferentLines(node, node.dotToken, node.name); - emit(node.name); - decreaseIndentIf(indentedBeforeDot, indentedAfterDot); - } - function emitQualifiedName(node) { - emit(node.left); - write("."); - emit(node.right); - } - function emitQualifiedNameAsExpression(node, useFallback) { - if (node.left.kind === 69) { - emitEntityNameAsExpression(node.left, useFallback); - } - else if (useFallback) { - var temp = createAndRecordTempVariable(0); - write("("); - emitNodeWithoutSourceMap(temp); - write(" = "); - emitEntityNameAsExpression(node.left, true); - write(") && "); - emitNodeWithoutSourceMap(temp); - } - else { - emitEntityNameAsExpression(node.left, false); - } - write("."); - emit(node.right); - } - function emitEntityNameAsExpression(node, useFallback) { - switch (node.kind) { - case 69: - if (useFallback) { - write("typeof "); - emitExpressionIdentifier(node); - write(" !== 'undefined' && "); - } - emitExpressionIdentifier(node); - break; - case 135: - emitQualifiedNameAsExpression(node, useFallback); - break; - } - } - function emitIndexedAccess(node) { - if (tryEmitConstantValue(node)) { - return; - } - emit(node.expression); - write("["); - emit(node.argumentExpression); - write("]"); - } - function hasSpreadElement(elements) { - return ts.forEach(elements, function (e) { return e.kind === 185; }); - } - function skipParentheses(node) { - while (node.kind === 172 || node.kind === 171 || node.kind === 189) { - node = node.expression; - } - return node; - } - function emitCallTarget(node) { - if (node.kind === 69 || node.kind === 97 || node.kind === 95) { - emit(node); - return node; - } - var temp = createAndRecordTempVariable(0); - write("("); - emit(temp); - write(" = "); - emit(node); - write(")"); - return temp; - } - function emitCallWithSpread(node) { - var target; - var expr = skipParentheses(node.expression); - if (expr.kind === 166) { - target = emitCallTarget(expr.expression); - write("."); - emit(expr.name); - } - else if (expr.kind === 167) { - target = emitCallTarget(expr.expression); - write("["); - emit(expr.argumentExpression); - write("]"); - } - else if (expr.kind === 95) { - target = expr; - write("_super"); - } - else { - emit(node.expression); - } - write(".apply("); - if (target) { - if (target.kind === 95) { - emitThis(target); - } - else { - emit(target); - } - } - else { - write("void 0"); - } - write(", "); - emitListWithSpread(node.arguments, false, false, false, true); - write(")"); - } - function emitCallExpression(node) { - if (languageVersion < 2 && hasSpreadElement(node.arguments)) { - emitCallWithSpread(node); - return; - } - var superCall = false; - if (node.expression.kind === 95) { - emitSuper(node.expression); - superCall = true; - } - else { - emit(node.expression); - superCall = node.expression.kind === 166 && node.expression.expression.kind === 95; - } - if (superCall && languageVersion < 2) { - write(".call("); - emitThis(node.expression); - if (node.arguments.length) { - write(", "); - emitCommaList(node.arguments); - } - write(")"); - } - else { - write("("); - emitCommaList(node.arguments); - write(")"); - } - } - function emitNewExpression(node) { - write("new "); - if (languageVersion === 1 && - node.arguments && - hasSpreadElement(node.arguments)) { - write("("); - var target = emitCallTarget(node.expression); - write(".bind.apply("); - emit(target); - write(", [void 0].concat("); - emitListWithSpread(node.arguments, false, false, false, false); - write(")))"); - write("()"); - } - else { - emit(node.expression); - if (node.arguments) { - write("("); - emitCommaList(node.arguments); - write(")"); - } - } - } - function emitTaggedTemplateExpression(node) { - if (languageVersion >= 2) { - emit(node.tag); - write(" "); - emit(node.template); - } - else { - emitDownlevelTaggedTemplate(node); - } - } - function emitParenExpression(node) { - if (!ts.nodeIsSynthesized(node) && node.parent.kind !== 174) { - if (node.expression.kind === 171 || node.expression.kind === 189) { - var operand = node.expression.expression; - while (operand.kind === 171 || operand.kind === 189) { - operand = operand.expression; - } - if (operand.kind !== 179 && - operand.kind !== 177 && - operand.kind !== 176 && - operand.kind !== 175 && - operand.kind !== 180 && - operand.kind !== 169 && - !(operand.kind === 168 && node.parent.kind === 169) && - !(operand.kind === 173 && node.parent.kind === 168) && - !(operand.kind === 8 && node.parent.kind === 166)) { - emit(operand); - return; - } - } - } - write("("); - emit(node.expression); - write(")"); - } - function emitDeleteExpression(node) { - write(ts.tokenToString(78)); - write(" "); - emit(node.expression); - } - function emitVoidExpression(node) { - write(ts.tokenToString(103)); - write(" "); - emit(node.expression); - } - function emitTypeOfExpression(node) { - write(ts.tokenToString(101)); - write(" "); - emit(node.expression); - } - function isNameOfExportedSourceLevelDeclarationInSystemExternalModule(node) { - if (!isCurrentFileSystemExternalModule() || node.kind !== 69 || ts.nodeIsSynthesized(node)) { - return false; - } - var isVariableDeclarationOrBindingElement = node.parent && (node.parent.kind === 211 || node.parent.kind === 163); - var targetDeclaration = isVariableDeclarationOrBindingElement - ? node.parent - : resolver.getReferencedValueDeclaration(node); - return isSourceFileLevelDeclarationInSystemJsModule(targetDeclaration, true); - } - function emitPrefixUnaryExpression(node) { - var exportChanged = isNameOfExportedSourceLevelDeclarationInSystemExternalModule(node.operand); - if (exportChanged) { - write(exportFunctionForFile + "(\""); - emitNodeWithoutSourceMap(node.operand); - write("\", "); - } - write(ts.tokenToString(node.operator)); - if (node.operand.kind === 179) { - var operand = node.operand; - if (node.operator === 35 && (operand.operator === 35 || operand.operator === 41)) { - write(" "); - } - else if (node.operator === 36 && (operand.operator === 36 || operand.operator === 42)) { - write(" "); - } - } - emit(node.operand); - if (exportChanged) { - write(")"); - } - } - function emitPostfixUnaryExpression(node) { - var exportChanged = isNameOfExportedSourceLevelDeclarationInSystemExternalModule(node.operand); - if (exportChanged) { - write("(" + exportFunctionForFile + "(\""); - emitNodeWithoutSourceMap(node.operand); - write("\", "); - write(ts.tokenToString(node.operator)); - emit(node.operand); - if (node.operator === 41) { - write(") - 1)"); - } - else { - write(") + 1)"); - } - } - else { - emit(node.operand); - write(ts.tokenToString(node.operator)); - } - } - function shouldHoistDeclarationInSystemJsModule(node) { - return isSourceFileLevelDeclarationInSystemJsModule(node, false); - } - function isSourceFileLevelDeclarationInSystemJsModule(node, isExported) { - if (!node || !isCurrentFileSystemExternalModule()) { - return false; - } - var current = node; - while (current) { - if (current.kind === 248) { - return !isExported || ((ts.getCombinedNodeFlags(node) & 1) !== 0); - } - else if (ts.isFunctionLike(current) || current.kind === 219) { - return false; - } - else { - current = current.parent; - } - } - } - function emitExponentiationOperator(node) { - var leftHandSideExpression = node.left; - if (node.operatorToken.kind === 60) { - var synthesizedLHS; - var shouldEmitParentheses = false; - if (ts.isElementAccessExpression(leftHandSideExpression)) { - shouldEmitParentheses = true; - write("("); - synthesizedLHS = ts.createSynthesizedNode(167, false); - var identifier = emitTempVariableAssignment(leftHandSideExpression.expression, false, false); - synthesizedLHS.expression = identifier; - if (leftHandSideExpression.argumentExpression.kind !== 8 && - leftHandSideExpression.argumentExpression.kind !== 9) { - var tempArgumentExpression = createAndRecordTempVariable(268435456); - synthesizedLHS.argumentExpression = tempArgumentExpression; - emitAssignment(tempArgumentExpression, leftHandSideExpression.argumentExpression, true); - } - else { - synthesizedLHS.argumentExpression = leftHandSideExpression.argumentExpression; - } - write(", "); - } - else if (ts.isPropertyAccessExpression(leftHandSideExpression)) { - shouldEmitParentheses = true; - write("("); - synthesizedLHS = ts.createSynthesizedNode(166, false); - var identifier = emitTempVariableAssignment(leftHandSideExpression.expression, false, false); - synthesizedLHS.expression = identifier; - synthesizedLHS.dotToken = leftHandSideExpression.dotToken; - synthesizedLHS.name = leftHandSideExpression.name; - write(", "); - } - emit(synthesizedLHS || leftHandSideExpression); - write(" = "); - write("Math.pow("); - emit(synthesizedLHS || leftHandSideExpression); - write(", "); - emit(node.right); - write(")"); - if (shouldEmitParentheses) { - write(")"); - } - } - else { - write("Math.pow("); - emit(leftHandSideExpression); - write(", "); - emit(node.right); - write(")"); - } - } - function emitBinaryExpression(node) { - if (languageVersion < 2 && node.operatorToken.kind === 56 && - (node.left.kind === 165 || node.left.kind === 164)) { - emitDestructuring(node, node.parent.kind === 195); - } - else { - var exportChanged = node.operatorToken.kind >= 56 && - node.operatorToken.kind <= 68 && - isNameOfExportedSourceLevelDeclarationInSystemExternalModule(node.left); - if (exportChanged) { - write(exportFunctionForFile + "(\""); - emitNodeWithoutSourceMap(node.left); - write("\", "); - } - if (node.operatorToken.kind === 38 || node.operatorToken.kind === 60) { - emitExponentiationOperator(node); - } - else { - emit(node.left); - var indentedBeforeOperator = indentIfOnDifferentLines(node, node.left, node.operatorToken, node.operatorToken.kind !== 24 ? " " : undefined); - write(ts.tokenToString(node.operatorToken.kind)); - var indentedAfterOperator = indentIfOnDifferentLines(node, node.operatorToken, node.right, " "); - emit(node.right); - decreaseIndentIf(indentedBeforeOperator, indentedAfterOperator); - } - if (exportChanged) { - write(")"); - } - } - } - function synthesizedNodeStartsOnNewLine(node) { - return ts.nodeIsSynthesized(node) && node.startsOnNewLine; - } - function emitConditionalExpression(node) { - emit(node.condition); - var indentedBeforeQuestion = indentIfOnDifferentLines(node, node.condition, node.questionToken, " "); - write("?"); - var indentedAfterQuestion = indentIfOnDifferentLines(node, node.questionToken, node.whenTrue, " "); - emit(node.whenTrue); - decreaseIndentIf(indentedBeforeQuestion, indentedAfterQuestion); - var indentedBeforeColon = indentIfOnDifferentLines(node, node.whenTrue, node.colonToken, " "); - write(":"); - var indentedAfterColon = indentIfOnDifferentLines(node, node.colonToken, node.whenFalse, " "); - emit(node.whenFalse); - decreaseIndentIf(indentedBeforeColon, indentedAfterColon); - } - function decreaseIndentIf(value1, value2) { - if (value1) { - decreaseIndent(); - } - if (value2) { - decreaseIndent(); - } - } - function isSingleLineEmptyBlock(node) { - if (node && node.kind === 192) { - var block = node; - return block.statements.length === 0 && nodeEndIsOnSameLineAsNodeStart(block, block); - } - } - function emitBlock(node) { - if (isSingleLineEmptyBlock(node)) { - emitToken(15, node.pos); - write(" "); - emitToken(16, node.statements.end); - return; - } - emitToken(15, node.pos); - increaseIndent(); - scopeEmitStart(node.parent); - if (node.kind === 219) { - ts.Debug.assert(node.parent.kind === 218); - emitCaptureThisForNodeIfNecessary(node.parent); - } - emitLines(node.statements); - if (node.kind === 219) { - emitTempDeclarations(true); - } - decreaseIndent(); - writeLine(); - emitToken(16, node.statements.end); - scopeEmitEnd(); - } - function emitEmbeddedStatement(node) { - if (node.kind === 192) { - write(" "); - emit(node); - } - else { - increaseIndent(); - writeLine(); - emit(node); - decreaseIndent(); - } - } - function emitExpressionStatement(node) { - emitParenthesizedIf(node.expression, node.expression.kind === 174); - write(";"); - } - function emitIfStatement(node) { - var endPos = emitToken(88, node.pos); - write(" "); - endPos = emitToken(17, endPos); - emit(node.expression); - emitToken(18, node.expression.end); - emitEmbeddedStatement(node.thenStatement); - if (node.elseStatement) { - writeLine(); - emitToken(80, node.thenStatement.end); - if (node.elseStatement.kind === 196) { - write(" "); - emit(node.elseStatement); - } - else { - emitEmbeddedStatement(node.elseStatement); - } - } - } - function emitDoStatement(node) { - write("do"); - emitEmbeddedStatement(node.statement); - if (node.statement.kind === 192) { - write(" "); - } - else { - writeLine(); - } - write("while ("); - emit(node.expression); - write(");"); - } - function emitWhileStatement(node) { - write("while ("); - emit(node.expression); - write(")"); - emitEmbeddedStatement(node.statement); - } - function tryEmitStartOfVariableDeclarationList(decl, startPos) { - if (shouldHoistVariable(decl, true)) { - return false; - } - var tokenKind = 102; - if (decl && languageVersion >= 2) { - if (ts.isLet(decl)) { - tokenKind = 108; - } - else if (ts.isConst(decl)) { - tokenKind = 74; - } - } - if (startPos !== undefined) { - emitToken(tokenKind, startPos); - write(" "); - } - else { - switch (tokenKind) { - case 102: - write("var "); - break; - case 108: - write("let "); - break; - case 74: - write("const "); - break; - } - } - return true; - } - function emitVariableDeclarationListSkippingUninitializedEntries(list) { - var started = false; - for (var _a = 0, _b = list.declarations; _a < _b.length; _a++) { - var decl = _b[_a]; - if (!decl.initializer) { - continue; - } - if (!started) { - started = true; - } - else { - write(", "); - } - emit(decl); - } - return started; - } - function emitForStatement(node) { - var endPos = emitToken(86, node.pos); - write(" "); - endPos = emitToken(17, endPos); - if (node.initializer && node.initializer.kind === 212) { - var variableDeclarationList = node.initializer; - var startIsEmitted = tryEmitStartOfVariableDeclarationList(variableDeclarationList, endPos); - if (startIsEmitted) { - emitCommaList(variableDeclarationList.declarations); - } - else { - emitVariableDeclarationListSkippingUninitializedEntries(variableDeclarationList); - } - } - else if (node.initializer) { - emit(node.initializer); - } - write(";"); - emitOptional(" ", node.condition); - write(";"); - emitOptional(" ", node.incrementor); - write(")"); - emitEmbeddedStatement(node.statement); - } - function emitForInOrForOfStatement(node) { - if (languageVersion < 2 && node.kind === 201) { - return emitDownLevelForOfStatement(node); - } - var endPos = emitToken(86, node.pos); - write(" "); - endPos = emitToken(17, endPos); - if (node.initializer.kind === 212) { - var variableDeclarationList = node.initializer; - if (variableDeclarationList.declarations.length >= 1) { - tryEmitStartOfVariableDeclarationList(variableDeclarationList, endPos); - emit(variableDeclarationList.declarations[0]); - } - } - else { - emit(node.initializer); - } - if (node.kind === 200) { - write(" in "); - } - else { - write(" of "); - } - emit(node.expression); - emitToken(18, node.expression.end); - emitEmbeddedStatement(node.statement); - } - function emitDownLevelForOfStatement(node) { - var endPos = emitToken(86, node.pos); - write(" "); - endPos = emitToken(17, endPos); - var rhsIsIdentifier = node.expression.kind === 69; - var counter = createTempVariable(268435456); - var rhsReference = rhsIsIdentifier ? node.expression : createTempVariable(0); - emitStart(node.expression); - write("var "); - emitNodeWithoutSourceMap(counter); - write(" = 0"); - emitEnd(node.expression); - if (!rhsIsIdentifier) { - write(", "); - emitStart(node.expression); - emitNodeWithoutSourceMap(rhsReference); - write(" = "); - emitNodeWithoutSourceMap(node.expression); - emitEnd(node.expression); - } - write("; "); - emitStart(node.initializer); - emitNodeWithoutSourceMap(counter); - write(" < "); - emitNodeWithCommentsAndWithoutSourcemap(rhsReference); - write(".length"); - emitEnd(node.initializer); - write("; "); - emitStart(node.initializer); - emitNodeWithoutSourceMap(counter); - write("++"); - emitEnd(node.initializer); - emitToken(18, node.expression.end); - write(" {"); - writeLine(); - increaseIndent(); - var rhsIterationValue = createElementAccessExpression(rhsReference, counter); - emitStart(node.initializer); - if (node.initializer.kind === 212) { - write("var "); - var variableDeclarationList = node.initializer; - if (variableDeclarationList.declarations.length > 0) { - var declaration = variableDeclarationList.declarations[0]; - if (ts.isBindingPattern(declaration.name)) { - emitDestructuring(declaration, false, rhsIterationValue); - } - else { - emitNodeWithCommentsAndWithoutSourcemap(declaration); - write(" = "); - emitNodeWithoutSourceMap(rhsIterationValue); - } - } - else { - emitNodeWithoutSourceMap(createTempVariable(0)); - write(" = "); - emitNodeWithoutSourceMap(rhsIterationValue); - } - } - else { - var assignmentExpression = createBinaryExpression(node.initializer, 56, rhsIterationValue, false); - if (node.initializer.kind === 164 || node.initializer.kind === 165) { - emitDestructuring(assignmentExpression, true, undefined); - } - else { - emitNodeWithCommentsAndWithoutSourcemap(assignmentExpression); - } - } - emitEnd(node.initializer); - write(";"); - if (node.statement.kind === 192) { - emitLines(node.statement.statements); - } - else { - writeLine(); - emit(node.statement); - } - writeLine(); - decreaseIndent(); - write("}"); - } - function emitBreakOrContinueStatement(node) { - emitToken(node.kind === 203 ? 70 : 75, node.pos); - emitOptional(" ", node.label); - write(";"); - } - function emitReturnStatement(node) { - emitToken(94, node.pos); - emitOptional(" ", node.expression); - write(";"); - } - function emitWithStatement(node) { - write("with ("); - emit(node.expression); - write(")"); - emitEmbeddedStatement(node.statement); - } - function emitSwitchStatement(node) { - var endPos = emitToken(96, node.pos); - write(" "); - emitToken(17, endPos); - emit(node.expression); - endPos = emitToken(18, node.expression.end); - write(" "); - emitCaseBlock(node.caseBlock, endPos); - } - function emitCaseBlock(node, startPos) { - emitToken(15, startPos); - increaseIndent(); - emitLines(node.clauses); - decreaseIndent(); - writeLine(); - emitToken(16, node.clauses.end); - } - function nodeStartPositionsAreOnSameLine(node1, node2) { - return ts.getLineOfLocalPosition(currentSourceFile, ts.skipTrivia(currentSourceFile.text, node1.pos)) === - ts.getLineOfLocalPosition(currentSourceFile, ts.skipTrivia(currentSourceFile.text, node2.pos)); - } - function nodeEndPositionsAreOnSameLine(node1, node2) { - return ts.getLineOfLocalPosition(currentSourceFile, node1.end) === - ts.getLineOfLocalPosition(currentSourceFile, node2.end); - } - function nodeEndIsOnSameLineAsNodeStart(node1, node2) { - return ts.getLineOfLocalPosition(currentSourceFile, node1.end) === - ts.getLineOfLocalPosition(currentSourceFile, ts.skipTrivia(currentSourceFile.text, node2.pos)); - } - function emitCaseOrDefaultClause(node) { - if (node.kind === 241) { - write("case "); - emit(node.expression); - write(":"); - } - else { - write("default:"); - } - if (node.statements.length === 1 && nodeStartPositionsAreOnSameLine(node, node.statements[0])) { - write(" "); - emit(node.statements[0]); - } - else { - increaseIndent(); - emitLines(node.statements); - decreaseIndent(); - } - } - function emitThrowStatement(node) { - write("throw "); - emit(node.expression); - write(";"); - } - function emitTryStatement(node) { - write("try "); - emit(node.tryBlock); - emit(node.catchClause); - if (node.finallyBlock) { - writeLine(); - write("finally "); - emit(node.finallyBlock); - } - } - function emitCatchClause(node) { - writeLine(); - var endPos = emitToken(72, node.pos); - write(" "); - emitToken(17, endPos); - emit(node.variableDeclaration); - emitToken(18, node.variableDeclaration ? node.variableDeclaration.end : endPos); - write(" "); - emitBlock(node.block); - } - function emitDebuggerStatement(node) { - emitToken(76, node.pos); - write(";"); - } - function emitLabelledStatement(node) { - emit(node.label); - write(": "); - emit(node.statement); - } - function getContainingModule(node) { - do { - node = node.parent; - } while (node && node.kind !== 218); - return node; - } - function emitContainingModuleName(node) { - var container = getContainingModule(node); - write(container ? getGeneratedNameForNode(container) : "exports"); - } - function emitModuleMemberName(node) { - emitStart(node.name); - if (ts.getCombinedNodeFlags(node) & 1) { - var container = getContainingModule(node); - if (container) { - write(getGeneratedNameForNode(container)); - write("."); - } - else if (modulekind !== 5 && modulekind !== 4) { - write("exports."); - } - } - emitNodeWithCommentsAndWithoutSourcemap(node.name); - emitEnd(node.name); - } - function createVoidZero() { - var zero = ts.createSynthesizedNode(8); - zero.text = "0"; - var result = ts.createSynthesizedNode(177); - result.expression = zero; - return result; - } - function emitEs6ExportDefaultCompat(node) { - if (node.parent.kind === 248) { - ts.Debug.assert(!!(node.flags & 1024) || node.kind === 227); - if (modulekind === 1 || modulekind === 2 || modulekind === 3) { - if (!currentSourceFile.symbol.exports["___esModule"]) { - if (languageVersion === 1) { - write("Object.defineProperty(exports, \"__esModule\", { value: true });"); - writeLine(); - } - else if (languageVersion === 0) { - write("exports.__esModule = true;"); - writeLine(); - } - } - } - } - } - function emitExportMemberAssignment(node) { - if (node.flags & 1) { - writeLine(); - emitStart(node); - if (modulekind === 4 && node.parent === currentSourceFile) { - write(exportFunctionForFile + "(\""); - if (node.flags & 1024) { - write("default"); - } - else { - emitNodeWithCommentsAndWithoutSourcemap(node.name); - } - write("\", "); - emitDeclarationName(node); - write(")"); - } - else { - if (node.flags & 1024) { - emitEs6ExportDefaultCompat(node); - if (languageVersion === 0) { - write("exports[\"default\"]"); - } - else { - write("exports.default"); - } - } - else { - emitModuleMemberName(node); - } - write(" = "); - emitDeclarationName(node); - } - emitEnd(node); - write(";"); - } - } - function emitExportMemberAssignments(name) { - if (modulekind === 4) { - return; - } - if (!exportEquals && exportSpecifiers && ts.hasProperty(exportSpecifiers, name.text)) { - for (var _a = 0, _b = exportSpecifiers[name.text]; _a < _b.length; _a++) { - var specifier = _b[_a]; - writeLine(); - emitStart(specifier.name); - emitContainingModuleName(specifier); - write("."); - emitNodeWithCommentsAndWithoutSourcemap(specifier.name); - emitEnd(specifier.name); - write(" = "); - emitExpressionIdentifier(name); - write(";"); - } - } - } - function emitExportSpecifierInSystemModule(specifier) { - ts.Debug.assert(modulekind === 4); - if (!resolver.getReferencedValueDeclaration(specifier.propertyName || specifier.name) && !resolver.isValueAliasDeclaration(specifier)) { - return; - } - writeLine(); - emitStart(specifier.name); - write(exportFunctionForFile + "(\""); - emitNodeWithCommentsAndWithoutSourcemap(specifier.name); - write("\", "); - emitExpressionIdentifier(specifier.propertyName || specifier.name); - write(")"); - emitEnd(specifier.name); - write(";"); - } - function emitAssignment(name, value, shouldEmitCommaBeforeAssignment) { - if (shouldEmitCommaBeforeAssignment) { - write(", "); - } - var exportChanged = isNameOfExportedSourceLevelDeclarationInSystemExternalModule(name); - if (exportChanged) { - write(exportFunctionForFile + "(\""); - emitNodeWithCommentsAndWithoutSourcemap(name); - write("\", "); - } - var isVariableDeclarationOrBindingElement = name.parent && (name.parent.kind === 211 || name.parent.kind === 163); - if (isVariableDeclarationOrBindingElement) { - emitModuleMemberName(name.parent); - } - else { - emit(name); - } - write(" = "); - emit(value); - if (exportChanged) { - write(")"); - } - } - function emitTempVariableAssignment(expression, canDefineTempVariablesInPlace, shouldEmitCommaBeforeAssignment) { - var identifier = createTempVariable(0); - if (!canDefineTempVariablesInPlace) { - recordTempDeclaration(identifier); - } - emitAssignment(identifier, expression, shouldEmitCommaBeforeAssignment); - return identifier; - } - function emitDestructuring(root, isAssignmentExpressionStatement, value) { - var emitCount = 0; - var canDefineTempVariablesInPlace = false; - if (root.kind === 211) { - var isExported = ts.getCombinedNodeFlags(root) & 1; - var isSourceLevelForSystemModuleKind = shouldHoistDeclarationInSystemJsModule(root); - canDefineTempVariablesInPlace = !isExported && !isSourceLevelForSystemModuleKind; - } - else if (root.kind === 138) { - canDefineTempVariablesInPlace = true; - } - if (root.kind === 181) { - emitAssignmentExpression(root); - } - else { - ts.Debug.assert(!isAssignmentExpressionStatement); - emitBindingElement(root, value); - } - function ensureIdentifier(expr, reuseIdentifierExpressions) { - if (expr.kind === 69 && reuseIdentifierExpressions) { - return expr; - } - var identifier = emitTempVariableAssignment(expr, canDefineTempVariablesInPlace, emitCount > 0); - emitCount++; - return identifier; - } - function createDefaultValueCheck(value, defaultValue) { - value = ensureIdentifier(value, true); - var equals = ts.createSynthesizedNode(181); - equals.left = value; - equals.operatorToken = ts.createSynthesizedNode(32); - equals.right = createVoidZero(); - return createConditionalExpression(equals, defaultValue, value); - } - function createConditionalExpression(condition, whenTrue, whenFalse) { - var cond = ts.createSynthesizedNode(182); - cond.condition = condition; - cond.questionToken = ts.createSynthesizedNode(53); - cond.whenTrue = whenTrue; - cond.colonToken = ts.createSynthesizedNode(54); - cond.whenFalse = whenFalse; - return cond; - } - function createNumericLiteral(value) { - var node = ts.createSynthesizedNode(8); - node.text = "" + value; - return node; - } - function createPropertyAccessForDestructuringProperty(object, propName) { - var syntheticName = ts.createSynthesizedNode(propName.kind); - syntheticName.text = propName.text; - if (syntheticName.kind !== 69) { - return createElementAccessExpression(object, syntheticName); - } - return createPropertyAccessExpression(object, syntheticName); - } - function createSliceCall(value, sliceIndex) { - var call = ts.createSynthesizedNode(168); - var sliceIdentifier = ts.createSynthesizedNode(69); - sliceIdentifier.text = "slice"; - call.expression = createPropertyAccessExpression(value, sliceIdentifier); - call.arguments = ts.createSynthesizedNodeArray(); - call.arguments[0] = createNumericLiteral(sliceIndex); - return call; - } - function emitObjectLiteralAssignment(target, value) { - var properties = target.properties; - if (properties.length !== 1) { - value = ensureIdentifier(value, true); - } - for (var _a = 0; _a < properties.length; _a++) { - var p = properties[_a]; - if (p.kind === 245 || p.kind === 246) { - var propName = p.name; - var target_1 = p.kind === 246 ? p : p.initializer || propName; - emitDestructuringAssignment(target_1, createPropertyAccessForDestructuringProperty(value, propName)); - } - } - } - function emitArrayLiteralAssignment(target, value) { - var elements = target.elements; - if (elements.length !== 1) { - value = ensureIdentifier(value, true); - } - for (var i = 0; i < elements.length; i++) { - var e = elements[i]; - if (e.kind !== 187) { - if (e.kind !== 185) { - emitDestructuringAssignment(e, createElementAccessExpression(value, createNumericLiteral(i))); - } - else if (i === elements.length - 1) { - emitDestructuringAssignment(e.expression, createSliceCall(value, i)); - } - } - } - } - function emitDestructuringAssignment(target, value) { - if (target.kind === 246) { - if (target.objectAssignmentInitializer) { - value = createDefaultValueCheck(value, target.objectAssignmentInitializer); - } - target = target.name; - } - else if (target.kind === 181 && target.operatorToken.kind === 56) { - value = createDefaultValueCheck(value, target.right); - target = target.left; - } - if (target.kind === 165) { - emitObjectLiteralAssignment(target, value); - } - else if (target.kind === 164) { - emitArrayLiteralAssignment(target, value); - } - else { - emitAssignment(target, value, emitCount > 0); - emitCount++; - } - } - function emitAssignmentExpression(root) { - var target = root.left; - var value = root.right; - if (ts.isEmptyObjectLiteralOrArrayLiteral(target)) { - emit(value); - } - else if (isAssignmentExpressionStatement) { - emitDestructuringAssignment(target, value); - } - else { - if (root.parent.kind !== 172) { - write("("); - } - value = ensureIdentifier(value, true); - emitDestructuringAssignment(target, value); - write(", "); - emit(value); - if (root.parent.kind !== 172) { - write(")"); - } - } - } - function emitBindingElement(target, value) { - if (target.initializer) { - value = value ? createDefaultValueCheck(value, target.initializer) : target.initializer; - } - else if (!value) { - value = createVoidZero(); - } - if (ts.isBindingPattern(target.name)) { - var pattern = target.name; - var elements = pattern.elements; - var numElements = elements.length; - if (numElements !== 1) { - value = ensureIdentifier(value, numElements !== 0); - } - for (var i = 0; i < numElements; i++) { - var element = elements[i]; - if (pattern.kind === 161) { - var propName = element.propertyName || element.name; - emitBindingElement(element, createPropertyAccessForDestructuringProperty(value, propName)); - } - else if (element.kind !== 187) { - if (!element.dotDotDotToken) { - emitBindingElement(element, createElementAccessExpression(value, createNumericLiteral(i))); - } - else if (i === numElements - 1) { - emitBindingElement(element, createSliceCall(value, i)); - } - } - } - } - else { - emitAssignment(target.name, value, emitCount > 0); - emitCount++; - } - } - } - function emitVariableDeclaration(node) { - if (ts.isBindingPattern(node.name)) { - if (languageVersion < 2) { - emitDestructuring(node, false); - } - else { - emit(node.name); - emitOptional(" = ", node.initializer); - } - } - else { - var initializer = node.initializer; - if (!initializer && languageVersion < 2) { - var isUninitializedLet = (resolver.getNodeCheckFlags(node) & 16384) && - (getCombinedFlagsForIdentifier(node.name) & 16384); - if (isUninitializedLet && - node.parent.parent.kind !== 200 && - node.parent.parent.kind !== 201) { - initializer = createVoidZero(); - } - } - var exportChanged = isNameOfExportedSourceLevelDeclarationInSystemExternalModule(node.name); - if (exportChanged) { - write(exportFunctionForFile + "(\""); - emitNodeWithCommentsAndWithoutSourcemap(node.name); - write("\", "); - } - emitModuleMemberName(node); - emitOptional(" = ", initializer); - if (exportChanged) { - write(")"); - } - } - } - function emitExportVariableAssignments(node) { - if (node.kind === 187) { - return; - } - var name = node.name; - if (name.kind === 69) { - emitExportMemberAssignments(name); - } - else if (ts.isBindingPattern(name)) { - ts.forEach(name.elements, emitExportVariableAssignments); - } - } - function getCombinedFlagsForIdentifier(node) { - if (!node.parent || (node.parent.kind !== 211 && node.parent.kind !== 163)) { - return 0; - } - return ts.getCombinedNodeFlags(node.parent); - } - function isES6ExportedDeclaration(node) { - return !!(node.flags & 1) && - modulekind === 5 && - node.parent.kind === 248; - } - function emitVariableStatement(node) { - var startIsEmitted = false; - if (node.flags & 1) { - if (isES6ExportedDeclaration(node)) { - write("export "); - startIsEmitted = tryEmitStartOfVariableDeclarationList(node.declarationList); - } - } - else { - startIsEmitted = tryEmitStartOfVariableDeclarationList(node.declarationList); - } - if (startIsEmitted) { - emitCommaList(node.declarationList.declarations); - write(";"); - } - else { - var atLeastOneItem = emitVariableDeclarationListSkippingUninitializedEntries(node.declarationList); - if (atLeastOneItem) { - write(";"); - } - } - if (modulekind !== 5 && node.parent === currentSourceFile) { - ts.forEach(node.declarationList.declarations, emitExportVariableAssignments); - } - } - function shouldEmitLeadingAndTrailingCommentsForVariableStatement(node) { - if (!(node.flags & 1)) { - return true; - } - if (isES6ExportedDeclaration(node)) { - return true; - } - for (var _a = 0, _b = node.declarationList.declarations; _a < _b.length; _a++) { - var declaration = _b[_a]; - if (declaration.initializer) { - return true; - } - } - return false; - } - function emitParameter(node) { - if (languageVersion < 2) { - if (ts.isBindingPattern(node.name)) { - var name_25 = createTempVariable(0); - if (!tempParameters) { - tempParameters = []; - } - tempParameters.push(name_25); - emit(name_25); - } - else { - emit(node.name); - } - } - else { - if (node.dotDotDotToken) { - write("..."); - } - emit(node.name); - emitOptional(" = ", node.initializer); - } - } - function emitDefaultValueAssignments(node) { - if (languageVersion < 2) { - var tempIndex = 0; - ts.forEach(node.parameters, function (parameter) { - if (parameter.dotDotDotToken) { - return; - } - var paramName = parameter.name, initializer = parameter.initializer; - if (ts.isBindingPattern(paramName)) { - var hasBindingElements = paramName.elements.length > 0; - if (hasBindingElements || initializer) { - writeLine(); - write("var "); - if (hasBindingElements) { - emitDestructuring(parameter, false, tempParameters[tempIndex]); - } - else { - emit(tempParameters[tempIndex]); - write(" = "); - emit(initializer); - } - write(";"); - tempIndex++; - } - } - else if (initializer) { - writeLine(); - emitStart(parameter); - write("if ("); - emitNodeWithoutSourceMap(paramName); - write(" === void 0)"); - emitEnd(parameter); - write(" { "); - emitStart(parameter); - emitNodeWithCommentsAndWithoutSourcemap(paramName); - write(" = "); - emitNodeWithCommentsAndWithoutSourcemap(initializer); - emitEnd(parameter); - write("; }"); - } - }); - } - } - function emitRestParameter(node) { - if (languageVersion < 2 && ts.hasRestParameter(node)) { - var restIndex = node.parameters.length - 1; - var restParam = node.parameters[restIndex]; - if (ts.isBindingPattern(restParam.name)) { - return; - } - var tempName = createTempVariable(268435456).text; - writeLine(); - emitLeadingComments(restParam); - emitStart(restParam); - write("var "); - emitNodeWithCommentsAndWithoutSourcemap(restParam.name); - write(" = [];"); - emitEnd(restParam); - emitTrailingComments(restParam); - writeLine(); - write("for ("); - emitStart(restParam); - write("var " + tempName + " = " + restIndex + ";"); - emitEnd(restParam); - write(" "); - emitStart(restParam); - write(tempName + " < arguments.length;"); - emitEnd(restParam); - write(" "); - emitStart(restParam); - write(tempName + "++"); - emitEnd(restParam); - write(") {"); - increaseIndent(); - writeLine(); - emitStart(restParam); - emitNodeWithCommentsAndWithoutSourcemap(restParam.name); - write("[" + tempName + " - " + restIndex + "] = arguments[" + tempName + "];"); - emitEnd(restParam); - decreaseIndent(); - writeLine(); - write("}"); - } - } - function emitAccessor(node) { - write(node.kind === 145 ? "get " : "set "); - emit(node.name); - emitSignatureAndBody(node); - } - function shouldEmitAsArrowFunction(node) { - return node.kind === 174 && languageVersion >= 2; - } - function emitDeclarationName(node) { - if (node.name) { - emitNodeWithCommentsAndWithoutSourcemap(node.name); - } - else { - write(getGeneratedNameForNode(node)); - } - } - function shouldEmitFunctionName(node) { - if (node.kind === 173) { - return !!node.name; - } - if (node.kind === 213) { - return !!node.name || languageVersion < 2; - } - } - function emitFunctionDeclaration(node) { - if (ts.nodeIsMissing(node.body)) { - return emitCommentsOnNotEmittedNode(node); - } - if (node.kind !== 143 && node.kind !== 142 && - node.parent && node.parent.kind !== 245 && - node.parent.kind !== 168) { - emitLeadingComments(node); - } - emitStart(node); - if (!shouldEmitAsArrowFunction(node)) { - if (isES6ExportedDeclaration(node)) { - write("export "); - if (node.flags & 1024) { - write("default "); - } - } - write("function"); - if (languageVersion >= 2 && node.asteriskToken) { - write("*"); - } - write(" "); - } - if (shouldEmitFunctionName(node)) { - emitDeclarationName(node); - } - emitSignatureAndBody(node); - if (modulekind !== 5 && node.kind === 213 && node.parent === currentSourceFile && node.name) { - emitExportMemberAssignments(node.name); - } - emitEnd(node); - if (node.kind !== 143 && node.kind !== 142) { - emitTrailingComments(node); - } - } - function emitCaptureThisForNodeIfNecessary(node) { - if (resolver.getNodeCheckFlags(node) & 4) { - writeLine(); - emitStart(node); - write("var _this = this;"); - emitEnd(node); - } - } - function emitSignatureParameters(node) { - increaseIndent(); - write("("); - if (node) { - var parameters = node.parameters; - var omitCount = languageVersion < 2 && ts.hasRestParameter(node) ? 1 : 0; - emitList(parameters, 0, parameters.length - omitCount, false, false); - } - write(")"); - decreaseIndent(); - } - function emitSignatureParametersForArrow(node) { - if (node.parameters.length === 1 && node.pos === node.parameters[0].pos) { - emit(node.parameters[0]); - return; - } - emitSignatureParameters(node); - } - function emitAsyncFunctionBodyForES6(node) { - var promiseConstructor = ts.getEntityNameFromTypeNode(node.type); - var isArrowFunction = node.kind === 174; - var hasLexicalArguments = (resolver.getNodeCheckFlags(node) & 4096) !== 0; - var args; - if (!isArrowFunction) { - write(" {"); - increaseIndent(); - writeLine(); - write("return"); - } - write(" __awaiter(this"); - if (hasLexicalArguments) { - write(", arguments"); - } - else { - write(", void 0"); - } - if (promiseConstructor) { - write(", "); - emitNodeWithoutSourceMap(promiseConstructor); - } - else { - write(", Promise"); - } - if (hasLexicalArguments) { - write(", function* (_arguments)"); - } - else { - write(", function* ()"); - } - emitFunctionBody(node); - write(")"); - if (!isArrowFunction) { - write(";"); - decreaseIndent(); - writeLine(); - write("}"); - } - } - function emitFunctionBody(node) { - if (!node.body) { - write(" { }"); - } - else { - if (node.body.kind === 192) { - emitBlockFunctionBody(node, node.body); - } - else { - emitExpressionFunctionBody(node, node.body); - } - } - } - function emitSignatureAndBody(node) { - var saveTempFlags = tempFlags; - var saveTempVariables = tempVariables; - var saveTempParameters = tempParameters; - tempFlags = 0; - tempVariables = undefined; - tempParameters = undefined; - if (shouldEmitAsArrowFunction(node)) { - emitSignatureParametersForArrow(node); - write(" =>"); - } - else { - emitSignatureParameters(node); - } - var isAsync = ts.isAsyncFunctionLike(node); - if (isAsync && languageVersion === 2) { - emitAsyncFunctionBodyForES6(node); - } - else { - emitFunctionBody(node); - } - if (!isES6ExportedDeclaration(node)) { - emitExportMemberAssignment(node); - } - tempFlags = saveTempFlags; - tempVariables = saveTempVariables; - tempParameters = saveTempParameters; - } - function emitFunctionBodyPreamble(node) { - emitCaptureThisForNodeIfNecessary(node); - emitDefaultValueAssignments(node); - emitRestParameter(node); - } - function emitExpressionFunctionBody(node, body) { - if (languageVersion < 2 || node.flags & 512) { - emitDownLevelExpressionFunctionBody(node, body); - return; - } - write(" "); - var current = body; - while (current.kind === 171) { - current = current.expression; - } - emitParenthesizedIf(body, current.kind === 165); - } - function emitDownLevelExpressionFunctionBody(node, body) { - write(" {"); - scopeEmitStart(node); - increaseIndent(); - var outPos = writer.getTextPos(); - emitDetachedComments(node.body); - emitFunctionBodyPreamble(node); - var preambleEmitted = writer.getTextPos() !== outPos; - decreaseIndent(); - if (!preambleEmitted && nodeStartPositionsAreOnSameLine(node, body)) { - write(" "); - emitStart(body); - write("return "); - emit(body); - emitEnd(body); - write(";"); - emitTempDeclarations(false); - write(" "); - } - else { - increaseIndent(); - writeLine(); - emitLeadingComments(node.body); - write("return "); - emit(body); - write(";"); - emitTrailingComments(node.body); - emitTempDeclarations(true); - decreaseIndent(); - writeLine(); - } - emitStart(node.body); - write("}"); - emitEnd(node.body); - scopeEmitEnd(); - } - function emitBlockFunctionBody(node, body) { - write(" {"); - scopeEmitStart(node); - var initialTextPos = writer.getTextPos(); - increaseIndent(); - emitDetachedComments(body.statements); - var startIndex = emitDirectivePrologues(body.statements, true); - emitFunctionBodyPreamble(node); - decreaseIndent(); - var preambleEmitted = writer.getTextPos() !== initialTextPos; - if (!preambleEmitted && nodeEndIsOnSameLineAsNodeStart(body, body)) { - for (var _a = 0, _b = body.statements; _a < _b.length; _a++) { - var statement = _b[_a]; - write(" "); - emit(statement); - } - emitTempDeclarations(false); - write(" "); - emitLeadingCommentsOfPosition(body.statements.end); - } - else { - increaseIndent(); - emitLinesStartingAt(body.statements, startIndex); - emitTempDeclarations(true); - writeLine(); - emitLeadingCommentsOfPosition(body.statements.end); - decreaseIndent(); - } - emitToken(16, body.statements.end); - scopeEmitEnd(); - } - function findInitialSuperCall(ctor) { - if (ctor.body) { - var statement = ctor.body.statements[0]; - if (statement && statement.kind === 195) { - var expr = statement.expression; - if (expr && expr.kind === 168) { - var func = expr.expression; - if (func && func.kind === 95) { - return statement; - } - } - } - } - } - function emitParameterPropertyAssignments(node) { - ts.forEach(node.parameters, function (param) { - if (param.flags & 112) { - writeLine(); - emitStart(param); - emitStart(param.name); - write("this."); - emitNodeWithoutSourceMap(param.name); - emitEnd(param.name); - write(" = "); - emit(param.name); - write(";"); - emitEnd(param); - } - }); - } - function emitMemberAccessForPropertyName(memberName) { - if (memberName.kind === 9 || memberName.kind === 8) { - write("["); - emitNodeWithCommentsAndWithoutSourcemap(memberName); - write("]"); - } - else if (memberName.kind === 136) { - emitComputedPropertyName(memberName); - } - else { - write("."); - emitNodeWithCommentsAndWithoutSourcemap(memberName); - } - } - function getInitializedProperties(node, isStatic) { - var properties = []; - for (var _a = 0, _b = node.members; _a < _b.length; _a++) { - var member = _b[_a]; - if (member.kind === 141 && isStatic === ((member.flags & 128) !== 0) && member.initializer) { - properties.push(member); - } - } - return properties; - } - function emitPropertyDeclarations(node, properties) { - for (var _a = 0; _a < properties.length; _a++) { - var property = properties[_a]; - emitPropertyDeclaration(node, property); - } - } - function emitPropertyDeclaration(node, property, receiver, isExpression) { - writeLine(); - emitLeadingComments(property); - emitStart(property); - emitStart(property.name); - if (receiver) { - emit(receiver); - } - else { - if (property.flags & 128) { - emitDeclarationName(node); - } - else { - write("this"); - } - } - emitMemberAccessForPropertyName(property.name); - emitEnd(property.name); - write(" = "); - emit(property.initializer); - if (!isExpression) { - write(";"); - } - emitEnd(property); - emitTrailingComments(property); - } - function emitMemberFunctionsForES5AndLower(node) { - ts.forEach(node.members, function (member) { - if (member.kind === 191) { - writeLine(); - write(";"); - } - else if (member.kind === 143 || node.kind === 142) { - if (!member.body) { - return emitCommentsOnNotEmittedNode(member); - } - writeLine(); - emitLeadingComments(member); - emitStart(member); - emitStart(member.name); - emitClassMemberPrefix(node, member); - emitMemberAccessForPropertyName(member.name); - emitEnd(member.name); - write(" = "); - emitFunctionDeclaration(member); - emitEnd(member); - write(";"); - emitTrailingComments(member); - } - else if (member.kind === 145 || member.kind === 146) { - var accessors = ts.getAllAccessorDeclarations(node.members, member); - if (member === accessors.firstAccessor) { - writeLine(); - emitStart(member); - write("Object.defineProperty("); - emitStart(member.name); - emitClassMemberPrefix(node, member); - write(", "); - emitExpressionForPropertyName(member.name); - emitEnd(member.name); - write(", {"); - increaseIndent(); - if (accessors.getAccessor) { - writeLine(); - emitLeadingComments(accessors.getAccessor); - write("get: "); - emitStart(accessors.getAccessor); - write("function "); - emitSignatureAndBody(accessors.getAccessor); - emitEnd(accessors.getAccessor); - emitTrailingComments(accessors.getAccessor); - write(","); - } - if (accessors.setAccessor) { - writeLine(); - emitLeadingComments(accessors.setAccessor); - write("set: "); - emitStart(accessors.setAccessor); - write("function "); - emitSignatureAndBody(accessors.setAccessor); - emitEnd(accessors.setAccessor); - emitTrailingComments(accessors.setAccessor); - write(","); - } - writeLine(); - write("enumerable: true,"); - writeLine(); - write("configurable: true"); - decreaseIndent(); - writeLine(); - write("});"); - emitEnd(member); - } - } - }); - } - function emitMemberFunctionsForES6AndHigher(node) { - for (var _a = 0, _b = node.members; _a < _b.length; _a++) { - var member = _b[_a]; - if ((member.kind === 143 || node.kind === 142) && !member.body) { - emitCommentsOnNotEmittedNode(member); - } - else if (member.kind === 143 || - member.kind === 145 || - member.kind === 146) { - writeLine(); - emitLeadingComments(member); - emitStart(member); - if (member.flags & 128) { - write("static "); - } - if (member.kind === 145) { - write("get "); - } - else if (member.kind === 146) { - write("set "); - } - if (member.asteriskToken) { - write("*"); - } - emit(member.name); - emitSignatureAndBody(member); - emitEnd(member); - emitTrailingComments(member); - } - else if (member.kind === 191) { - writeLine(); - write(";"); - } - } - } - function emitConstructor(node, baseTypeElement) { - var saveTempFlags = tempFlags; - var saveTempVariables = tempVariables; - var saveTempParameters = tempParameters; - tempFlags = 0; - tempVariables = undefined; - tempParameters = undefined; - emitConstructorWorker(node, baseTypeElement); - tempFlags = saveTempFlags; - tempVariables = saveTempVariables; - tempParameters = saveTempParameters; - } - function emitConstructorWorker(node, baseTypeElement) { - var hasInstancePropertyWithInitializer = false; - ts.forEach(node.members, function (member) { - if (member.kind === 144 && !member.body) { - emitCommentsOnNotEmittedNode(member); - } - if (member.kind === 141 && member.initializer && (member.flags & 128) === 0) { - hasInstancePropertyWithInitializer = true; - } - }); - var ctor = ts.getFirstConstructorWithBody(node); - if (languageVersion >= 2 && !ctor && !hasInstancePropertyWithInitializer) { - return; - } - if (ctor) { - emitLeadingComments(ctor); - } - emitStart(ctor || node); - if (languageVersion < 2) { - write("function "); - emitDeclarationName(node); - emitSignatureParameters(ctor); - } - else { - write("constructor"); - if (ctor) { - emitSignatureParameters(ctor); - } - else { - if (baseTypeElement) { - write("(...args)"); - } - else { - write("()"); - } - } - } - var startIndex = 0; - write(" {"); - scopeEmitStart(node, "constructor"); - increaseIndent(); - if (ctor) { - startIndex = emitDirectivePrologues(ctor.body.statements, true); - emitDetachedComments(ctor.body.statements); - } - emitCaptureThisForNodeIfNecessary(node); - var superCall; - if (ctor) { - emitDefaultValueAssignments(ctor); - emitRestParameter(ctor); - if (baseTypeElement) { - superCall = findInitialSuperCall(ctor); - if (superCall) { - writeLine(); - emit(superCall); - } - } - emitParameterPropertyAssignments(ctor); - } - else { - if (baseTypeElement) { - writeLine(); - emitStart(baseTypeElement); - if (languageVersion < 2) { - write("_super.apply(this, arguments);"); - } - else { - write("super(...args);"); - } - emitEnd(baseTypeElement); - } - } - emitPropertyDeclarations(node, getInitializedProperties(node, false)); - if (ctor) { - var statements = ctor.body.statements; - if (superCall) { - statements = statements.slice(1); - } - emitLinesStartingAt(statements, startIndex); - } - emitTempDeclarations(true); - writeLine(); - if (ctor) { - emitLeadingCommentsOfPosition(ctor.body.statements.end); - } - decreaseIndent(); - emitToken(16, ctor ? ctor.body.statements.end : node.members.end); - scopeEmitEnd(); - emitEnd(ctor || node); - if (ctor) { - emitTrailingComments(ctor); - } - } - function emitClassExpression(node) { - return emitClassLikeDeclaration(node); - } - function emitClassDeclaration(node) { - return emitClassLikeDeclaration(node); - } - function emitClassLikeDeclaration(node) { - if (languageVersion < 2) { - emitClassLikeDeclarationBelowES6(node); - } - else { - emitClassLikeDeclarationForES6AndHigher(node); - } - if (modulekind !== 5 && node.parent === currentSourceFile && node.name) { - emitExportMemberAssignments(node.name); - } - } - function emitClassLikeDeclarationForES6AndHigher(node) { - var thisNodeIsDecorated = ts.nodeIsDecorated(node); - if (node.kind === 214) { - if (thisNodeIsDecorated) { - if (isES6ExportedDeclaration(node) && !(node.flags & 1024)) { - write("export "); - } - write("let "); - emitDeclarationName(node); - write(" = "); - } - else if (isES6ExportedDeclaration(node)) { - write("export "); - if (node.flags & 1024) { - write("default "); - } - } - } - var staticProperties = getInitializedProperties(node, true); - var isClassExpressionWithStaticProperties = staticProperties.length > 0 && node.kind === 186; - var tempVariable; - if (isClassExpressionWithStaticProperties) { - tempVariable = createAndRecordTempVariable(0); - write("("); - increaseIndent(); - emit(tempVariable); - write(" = "); - } - write("class"); - if ((node.name || (node.flags & 1024 && staticProperties.length > 0)) && !thisNodeIsDecorated) { - write(" "); - emitDeclarationName(node); - } - var baseTypeNode = ts.getClassExtendsHeritageClauseElement(node); - if (baseTypeNode) { - write(" extends "); - emit(baseTypeNode.expression); - } - write(" {"); - increaseIndent(); - scopeEmitStart(node); - writeLine(); - emitConstructor(node, baseTypeNode); - emitMemberFunctionsForES6AndHigher(node); - decreaseIndent(); - writeLine(); - emitToken(16, node.members.end); - scopeEmitEnd(); - if (thisNodeIsDecorated) { - write(";"); - } - if (isClassExpressionWithStaticProperties) { - for (var _a = 0; _a < staticProperties.length; _a++) { - var property = staticProperties[_a]; - write(","); - writeLine(); - emitPropertyDeclaration(node, property, tempVariable, true); - } - write(","); - writeLine(); - emit(tempVariable); - decreaseIndent(); - write(")"); - } - else { - writeLine(); - emitPropertyDeclarations(node, staticProperties); - emitDecoratorsOfClass(node); - } - if (!isES6ExportedDeclaration(node) && (node.flags & 1)) { - writeLine(); - emitStart(node); - emitModuleMemberName(node); - write(" = "); - emitDeclarationName(node); - emitEnd(node); - write(";"); - } - else if (isES6ExportedDeclaration(node) && (node.flags & 1024) && thisNodeIsDecorated) { - writeLine(); - write("export default "); - emitDeclarationName(node); - write(";"); - } - } - function emitClassLikeDeclarationBelowES6(node) { - if (node.kind === 214) { - if (!shouldHoistDeclarationInSystemJsModule(node)) { - write("var "); - } - emitDeclarationName(node); - write(" = "); - } - write("(function ("); - var baseTypeNode = ts.getClassExtendsHeritageClauseElement(node); - if (baseTypeNode) { - write("_super"); - } - write(") {"); - var saveTempFlags = tempFlags; - var saveTempVariables = tempVariables; - var saveTempParameters = tempParameters; - var saveComputedPropertyNamesToGeneratedNames = computedPropertyNamesToGeneratedNames; - tempFlags = 0; - tempVariables = undefined; - tempParameters = undefined; - computedPropertyNamesToGeneratedNames = undefined; - increaseIndent(); - scopeEmitStart(node); - if (baseTypeNode) { - writeLine(); - emitStart(baseTypeNode); - write("__extends("); - emitDeclarationName(node); - write(", _super);"); - emitEnd(baseTypeNode); - } - writeLine(); - emitConstructor(node, baseTypeNode); - emitMemberFunctionsForES5AndLower(node); - emitPropertyDeclarations(node, getInitializedProperties(node, true)); - writeLine(); - emitDecoratorsOfClass(node); - writeLine(); - emitToken(16, node.members.end, function () { - write("return "); - emitDeclarationName(node); - }); - write(";"); - emitTempDeclarations(true); - tempFlags = saveTempFlags; - tempVariables = saveTempVariables; - tempParameters = saveTempParameters; - computedPropertyNamesToGeneratedNames = saveComputedPropertyNamesToGeneratedNames; - decreaseIndent(); - writeLine(); - emitToken(16, node.members.end); - scopeEmitEnd(); - emitStart(node); - write(")("); - if (baseTypeNode) { - emit(baseTypeNode.expression); - } - write(")"); - if (node.kind === 214) { - write(";"); - } - emitEnd(node); - if (node.kind === 214) { - emitExportMemberAssignment(node); - } - } - function emitClassMemberPrefix(node, member) { - emitDeclarationName(node); - if (!(member.flags & 128)) { - write(".prototype"); - } - } - function emitDecoratorsOfClass(node) { - emitDecoratorsOfMembers(node, 0); - emitDecoratorsOfMembers(node, 128); - emitDecoratorsOfConstructor(node); - } - function emitDecoratorsOfConstructor(node) { - var decorators = node.decorators; - var constructor = ts.getFirstConstructorWithBody(node); - var hasDecoratedParameters = constructor && ts.forEach(constructor.parameters, ts.nodeIsDecorated); - if (!decorators && !hasDecoratedParameters) { - return; - } - writeLine(); - emitStart(node); - emitDeclarationName(node); - write(" = __decorate(["); - increaseIndent(); - writeLine(); - var decoratorCount = decorators ? decorators.length : 0; - var argumentsWritten = emitList(decorators, 0, decoratorCount, true, false, false, true, function (decorator) { - emitStart(decorator); - emit(decorator.expression); - emitEnd(decorator); - }); - argumentsWritten += emitDecoratorsOfParameters(constructor, argumentsWritten > 0); - emitSerializedTypeMetadata(node, argumentsWritten >= 0); - decreaseIndent(); - writeLine(); - write("], "); - emitDeclarationName(node); - write(");"); - emitEnd(node); - writeLine(); - } - function emitDecoratorsOfMembers(node, staticFlag) { - for (var _a = 0, _b = node.members; _a < _b.length; _a++) { - var member = _b[_a]; - if ((member.flags & 128) !== staticFlag) { - continue; - } - if (!ts.nodeCanBeDecorated(member)) { - continue; - } - if (!ts.nodeOrChildIsDecorated(member)) { - continue; - } - var decorators = void 0; - var functionLikeMember = void 0; - if (ts.isAccessor(member)) { - var accessors = ts.getAllAccessorDeclarations(node.members, member); - if (member !== accessors.firstAccessor) { - continue; - } - decorators = accessors.firstAccessor.decorators; - if (!decorators && accessors.secondAccessor) { - decorators = accessors.secondAccessor.decorators; - } - functionLikeMember = accessors.setAccessor; - } - else { - decorators = member.decorators; - if (member.kind === 143) { - functionLikeMember = member; - } - } - writeLine(); - emitStart(member); - write("__decorate(["); - increaseIndent(); - writeLine(); - var decoratorCount = decorators ? decorators.length : 0; - var argumentsWritten = emitList(decorators, 0, decoratorCount, true, false, false, true, function (decorator) { - emitStart(decorator); - emit(decorator.expression); - emitEnd(decorator); - }); - argumentsWritten += emitDecoratorsOfParameters(functionLikeMember, argumentsWritten > 0); - emitSerializedTypeMetadata(member, argumentsWritten > 0); - decreaseIndent(); - writeLine(); - write("], "); - emitStart(member.name); - emitClassMemberPrefix(node, member); - write(", "); - emitExpressionForPropertyName(member.name); - emitEnd(member.name); - if (languageVersion > 0) { - if (member.kind !== 141) { - write(", null"); - } - else { - write(", void 0"); - } - } - write(");"); - emitEnd(member); - writeLine(); - } - } - function emitDecoratorsOfParameters(node, leadingComma) { - var argumentsWritten = 0; - if (node) { - var parameterIndex = 0; - for (var _a = 0, _b = node.parameters; _a < _b.length; _a++) { - var parameter = _b[_a]; - if (ts.nodeIsDecorated(parameter)) { - var decorators = parameter.decorators; - argumentsWritten += emitList(decorators, 0, decorators.length, true, false, leadingComma, true, function (decorator) { - emitStart(decorator); - write("__param(" + parameterIndex + ", "); - emit(decorator.expression); - write(")"); - emitEnd(decorator); - }); - leadingComma = true; - } - ++parameterIndex; - } - } - return argumentsWritten; - } - function shouldEmitTypeMetadata(node) { - switch (node.kind) { - case 143: - case 145: - case 146: - case 141: - return true; - } - return false; - } - function shouldEmitReturnTypeMetadata(node) { - switch (node.kind) { - case 143: - return true; - } - return false; - } - function shouldEmitParamTypesMetadata(node) { - switch (node.kind) { - case 214: - case 143: - case 146: - return true; - } - return false; - } - function emitSerializedTypeOfNode(node) { - switch (node.kind) { - case 214: - write("Function"); - return; - case 141: - emitSerializedTypeNode(node.type); - return; - case 138: - emitSerializedTypeNode(node.type); - return; - case 145: - emitSerializedTypeNode(node.type); - return; - case 146: - emitSerializedTypeNode(ts.getSetAccessorTypeAnnotationNode(node)); - return; - } - if (ts.isFunctionLike(node)) { - write("Function"); - return; - } - write("void 0"); - } - function emitSerializedTypeNode(node) { - if (node) { - switch (node.kind) { - case 103: - write("void 0"); - return; - case 160: - emitSerializedTypeNode(node.type); - return; - case 152: - case 153: - write("Function"); - return; - case 156: - case 157: - write("Array"); - return; - case 150: - case 120: - write("Boolean"); - return; - case 130: - case 9: - write("String"); - return; - case 128: - write("Number"); - return; - case 131: - write("Symbol"); - return; - case 151: - emitSerializedTypeReferenceNode(node); - return; - case 154: - case 155: - case 158: - case 159: - case 117: - break; - default: - ts.Debug.fail("Cannot serialize unexpected type node."); - break; - } - } - write("Object"); - } - function emitSerializedTypeReferenceNode(node) { - var location = node.parent; - while (ts.isDeclaration(location) || ts.isTypeNode(location)) { - location = location.parent; - } - var typeName = ts.cloneEntityName(node.typeName); - typeName.parent = location; - var result = resolver.getTypeReferenceSerializationKind(typeName); - switch (result) { - case ts.TypeReferenceSerializationKind.Unknown: - var temp = createAndRecordTempVariable(0); - write("(typeof ("); - emitNodeWithoutSourceMap(temp); - write(" = "); - emitEntityNameAsExpression(typeName, true); - write(") === 'function' && "); - emitNodeWithoutSourceMap(temp); - write(") || Object"); - break; - case ts.TypeReferenceSerializationKind.TypeWithConstructSignatureAndValue: - emitEntityNameAsExpression(typeName, false); - break; - case ts.TypeReferenceSerializationKind.VoidType: - write("void 0"); - break; - case ts.TypeReferenceSerializationKind.BooleanType: - write("Boolean"); - break; - case ts.TypeReferenceSerializationKind.NumberLikeType: - write("Number"); - break; - case ts.TypeReferenceSerializationKind.StringLikeType: - write("String"); - break; - case ts.TypeReferenceSerializationKind.ArrayLikeType: - write("Array"); - break; - case ts.TypeReferenceSerializationKind.ESSymbolType: - if (languageVersion < 2) { - write("typeof Symbol === 'function' ? Symbol : Object"); - } - else { - write("Symbol"); - } - break; - case ts.TypeReferenceSerializationKind.TypeWithCallSignature: - write("Function"); - break; - case ts.TypeReferenceSerializationKind.ObjectType: - write("Object"); - break; - } - } - function emitSerializedParameterTypesOfNode(node) { - if (node) { - var valueDeclaration; - if (node.kind === 214) { - valueDeclaration = ts.getFirstConstructorWithBody(node); - } - else if (ts.isFunctionLike(node) && ts.nodeIsPresent(node.body)) { - valueDeclaration = node; - } - if (valueDeclaration) { - var parameters = valueDeclaration.parameters; - var parameterCount = parameters.length; - if (parameterCount > 0) { - for (var i = 0; i < parameterCount; i++) { - if (i > 0) { - write(", "); - } - if (parameters[i].dotDotDotToken) { - var parameterType = parameters[i].type; - if (parameterType.kind === 156) { - parameterType = parameterType.elementType; - } - else if (parameterType.kind === 151 && parameterType.typeArguments && parameterType.typeArguments.length === 1) { - parameterType = parameterType.typeArguments[0]; - } - else { - parameterType = undefined; - } - emitSerializedTypeNode(parameterType); - } - else { - emitSerializedTypeOfNode(parameters[i]); - } - } - } - } - } - } - function emitSerializedReturnTypeOfNode(node) { - if (node && ts.isFunctionLike(node) && node.type) { - emitSerializedTypeNode(node.type); - return; - } - write("void 0"); - } - function emitSerializedTypeMetadata(node, writeComma) { - var argumentsWritten = 0; - if (compilerOptions.emitDecoratorMetadata) { - if (shouldEmitTypeMetadata(node)) { - if (writeComma) { - write(", "); - } - writeLine(); - write("__metadata('design:type', "); - emitSerializedTypeOfNode(node); - write(")"); - argumentsWritten++; - } - if (shouldEmitParamTypesMetadata(node)) { - if (writeComma || argumentsWritten) { - write(", "); - } - writeLine(); - write("__metadata('design:paramtypes', ["); - emitSerializedParameterTypesOfNode(node); - write("])"); - argumentsWritten++; - } - if (shouldEmitReturnTypeMetadata(node)) { - if (writeComma || argumentsWritten) { - write(", "); - } - writeLine(); - write("__metadata('design:returntype', "); - emitSerializedReturnTypeOfNode(node); - write(")"); - argumentsWritten++; - } - } - return argumentsWritten; - } - function emitInterfaceDeclaration(node) { - emitCommentsOnNotEmittedNode(node); - } - function shouldEmitEnumDeclaration(node) { - var isConstEnum = ts.isConst(node); - return !isConstEnum || compilerOptions.preserveConstEnums || compilerOptions.isolatedModules; - } - function emitEnumDeclaration(node) { - if (!shouldEmitEnumDeclaration(node)) { - return; - } - if (!shouldHoistDeclarationInSystemJsModule(node)) { - if (!(node.flags & 1) || isES6ExportedDeclaration(node)) { - emitStart(node); - if (isES6ExportedDeclaration(node)) { - write("export "); - } - write("var "); - emit(node.name); - emitEnd(node); - write(";"); - } - } - writeLine(); - emitStart(node); - write("(function ("); - emitStart(node.name); - write(getGeneratedNameForNode(node)); - emitEnd(node.name); - write(") {"); - increaseIndent(); - scopeEmitStart(node); - emitLines(node.members); - decreaseIndent(); - writeLine(); - emitToken(16, node.members.end); - scopeEmitEnd(); - write(")("); - emitModuleMemberName(node); - write(" || ("); - emitModuleMemberName(node); - write(" = {}));"); - emitEnd(node); - if (!isES6ExportedDeclaration(node) && node.flags & 1 && !shouldHoistDeclarationInSystemJsModule(node)) { - writeLine(); - emitStart(node); - write("var "); - emit(node.name); - write(" = "); - emitModuleMemberName(node); - emitEnd(node); - write(";"); - } - if (modulekind !== 5 && node.parent === currentSourceFile) { - if (modulekind === 4 && (node.flags & 1)) { - writeLine(); - write(exportFunctionForFile + "(\""); - emitDeclarationName(node); - write("\", "); - emitDeclarationName(node); - write(");"); - } - emitExportMemberAssignments(node.name); - } - } - function emitEnumMember(node) { - var enumParent = node.parent; - emitStart(node); - write(getGeneratedNameForNode(enumParent)); - write("["); - write(getGeneratedNameForNode(enumParent)); - write("["); - emitExpressionForPropertyName(node.name); - write("] = "); - writeEnumMemberDeclarationValue(node); - write("] = "); - emitExpressionForPropertyName(node.name); - emitEnd(node); - write(";"); - } - function writeEnumMemberDeclarationValue(member) { - var value = resolver.getConstantValue(member); - if (value !== undefined) { - write(value.toString()); - return; - } - else if (member.initializer) { - emit(member.initializer); - } - else { - write("undefined"); - } - } - function getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration) { - if (moduleDeclaration.body.kind === 218) { - var recursiveInnerModule = getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration.body); - return recursiveInnerModule || moduleDeclaration.body; - } - } - function shouldEmitModuleDeclaration(node) { - return ts.isInstantiatedModule(node, compilerOptions.preserveConstEnums || compilerOptions.isolatedModules); - } - function isModuleMergedWithES6Class(node) { - return languageVersion === 2 && !!(resolver.getNodeCheckFlags(node) & 32768); - } - function emitModuleDeclaration(node) { - var shouldEmit = shouldEmitModuleDeclaration(node); - if (!shouldEmit) { - return emitCommentsOnNotEmittedNode(node); - } - var hoistedInDeclarationScope = shouldHoistDeclarationInSystemJsModule(node); - var emitVarForModule = !hoistedInDeclarationScope && !isModuleMergedWithES6Class(node); - if (emitVarForModule) { - emitStart(node); - if (isES6ExportedDeclaration(node)) { - write("export "); - } - write("var "); - emit(node.name); - write(";"); - emitEnd(node); - writeLine(); - } - emitStart(node); - write("(function ("); - emitStart(node.name); - write(getGeneratedNameForNode(node)); - emitEnd(node.name); - write(") "); - if (node.body.kind === 219) { - var saveTempFlags = tempFlags; - var saveTempVariables = tempVariables; - tempFlags = 0; - tempVariables = undefined; - emit(node.body); - tempFlags = saveTempFlags; - tempVariables = saveTempVariables; - } - else { - write("{"); - increaseIndent(); - scopeEmitStart(node); - emitCaptureThisForNodeIfNecessary(node); - writeLine(); - emit(node.body); - decreaseIndent(); - writeLine(); - var moduleBlock = getInnerMostModuleDeclarationFromDottedModule(node).body; - emitToken(16, moduleBlock.statements.end); - scopeEmitEnd(); - } - write(")("); - if ((node.flags & 1) && !isES6ExportedDeclaration(node)) { - emit(node.name); - write(" = "); - } - emitModuleMemberName(node); - write(" || ("); - emitModuleMemberName(node); - write(" = {}));"); - emitEnd(node); - if (!isES6ExportedDeclaration(node) && node.name.kind === 69 && node.parent === currentSourceFile) { - if (modulekind === 4 && (node.flags & 1)) { - writeLine(); - write(exportFunctionForFile + "(\""); - emitDeclarationName(node); - write("\", "); - emitDeclarationName(node); - write(");"); - } - emitExportMemberAssignments(node.name); - } - } - function tryRenameExternalModule(moduleName) { - if (currentSourceFile.renamedDependencies && ts.hasProperty(currentSourceFile.renamedDependencies, moduleName.text)) { - return "\"" + currentSourceFile.renamedDependencies[moduleName.text] + "\""; - } - return undefined; - } - function emitRequire(moduleName) { - if (moduleName.kind === 9) { - write("require("); - var text = tryRenameExternalModule(moduleName); - if (text) { - write(text); - } - else { - emitStart(moduleName); - emitLiteral(moduleName); - emitEnd(moduleName); - } - emitToken(18, moduleName.end); - } - else { - write("require()"); - } - } - function getNamespaceDeclarationNode(node) { - if (node.kind === 221) { - return node; - } - var importClause = node.importClause; - if (importClause && importClause.namedBindings && importClause.namedBindings.kind === 224) { - return importClause.namedBindings; - } - } - function isDefaultImport(node) { - return node.kind === 222 && node.importClause && !!node.importClause.name; - } - function emitExportImportAssignments(node) { - if (ts.isAliasSymbolDeclaration(node) && resolver.isValueAliasDeclaration(node)) { - emitExportMemberAssignments(node.name); - } - ts.forEachChild(node, emitExportImportAssignments); - } - function emitImportDeclaration(node) { - if (modulekind !== 5) { - return emitExternalImportDeclaration(node); - } - if (node.importClause) { - var shouldEmitDefaultBindings = resolver.isReferencedAliasDeclaration(node.importClause); - var shouldEmitNamedBindings = node.importClause.namedBindings && resolver.isReferencedAliasDeclaration(node.importClause.namedBindings, true); - if (shouldEmitDefaultBindings || shouldEmitNamedBindings) { - write("import "); - emitStart(node.importClause); - if (shouldEmitDefaultBindings) { - emit(node.importClause.name); - if (shouldEmitNamedBindings) { - write(", "); - } - } - if (shouldEmitNamedBindings) { - emitLeadingComments(node.importClause.namedBindings); - emitStart(node.importClause.namedBindings); - if (node.importClause.namedBindings.kind === 224) { - write("* as "); - emit(node.importClause.namedBindings.name); - } - else { - write("{ "); - emitExportOrImportSpecifierList(node.importClause.namedBindings.elements, resolver.isReferencedAliasDeclaration); - write(" }"); - } - emitEnd(node.importClause.namedBindings); - emitTrailingComments(node.importClause.namedBindings); - } - emitEnd(node.importClause); - write(" from "); - emit(node.moduleSpecifier); - write(";"); - } - } - else { - write("import "); - emit(node.moduleSpecifier); - write(";"); - } - } - function emitExternalImportDeclaration(node) { - if (ts.contains(externalImports, node)) { - var isExportedImport = node.kind === 221 && (node.flags & 1) !== 0; - var namespaceDeclaration = getNamespaceDeclarationNode(node); - if (modulekind !== 2) { - emitLeadingComments(node); - emitStart(node); - if (namespaceDeclaration && !isDefaultImport(node)) { - if (!isExportedImport) - write("var "); - emitModuleMemberName(namespaceDeclaration); - write(" = "); - } - else { - var isNakedImport = 222 && !node.importClause; - if (!isNakedImport) { - write("var "); - write(getGeneratedNameForNode(node)); - write(" = "); - } - } - emitRequire(ts.getExternalModuleName(node)); - if (namespaceDeclaration && isDefaultImport(node)) { - write(", "); - emitModuleMemberName(namespaceDeclaration); - write(" = "); - write(getGeneratedNameForNode(node)); - } - write(";"); - emitEnd(node); - emitExportImportAssignments(node); - emitTrailingComments(node); - } - else { - if (isExportedImport) { - emitModuleMemberName(namespaceDeclaration); - write(" = "); - emit(namespaceDeclaration.name); - write(";"); - } - else if (namespaceDeclaration && isDefaultImport(node)) { - write("var "); - emitModuleMemberName(namespaceDeclaration); - write(" = "); - write(getGeneratedNameForNode(node)); - write(";"); - } - emitExportImportAssignments(node); - } - } - } - function emitImportEqualsDeclaration(node) { - if (ts.isExternalModuleImportEqualsDeclaration(node)) { - emitExternalImportDeclaration(node); - return; - } - if (resolver.isReferencedAliasDeclaration(node) || - (!ts.isExternalModule(currentSourceFile) && resolver.isTopLevelValueImportEqualsWithEntityName(node))) { - emitLeadingComments(node); - emitStart(node); - var variableDeclarationIsHoisted = shouldHoistVariable(node, true); - var isExported = isSourceFileLevelDeclarationInSystemJsModule(node, true); - if (!variableDeclarationIsHoisted) { - ts.Debug.assert(!isExported); - if (isES6ExportedDeclaration(node)) { - write("export "); - write("var "); - } - else if (!(node.flags & 1)) { - write("var "); - } - } - if (isExported) { - write(exportFunctionForFile + "(\""); - emitNodeWithoutSourceMap(node.name); - write("\", "); - } - emitModuleMemberName(node); - write(" = "); - emit(node.moduleReference); - if (isExported) { - write(")"); - } - write(";"); - emitEnd(node); - emitExportImportAssignments(node); - emitTrailingComments(node); - } - } - function emitExportDeclaration(node) { - ts.Debug.assert(modulekind !== 4); - if (modulekind !== 5) { - if (node.moduleSpecifier && (!node.exportClause || resolver.isValueAliasDeclaration(node))) { - emitStart(node); - var generatedName = getGeneratedNameForNode(node); - if (node.exportClause) { - if (modulekind !== 2) { - write("var "); - write(generatedName); - write(" = "); - emitRequire(ts.getExternalModuleName(node)); - write(";"); - } - for (var _a = 0, _b = node.exportClause.elements; _a < _b.length; _a++) { - var specifier = _b[_a]; - if (resolver.isValueAliasDeclaration(specifier)) { - writeLine(); - emitStart(specifier); - emitContainingModuleName(specifier); - write("."); - emitNodeWithCommentsAndWithoutSourcemap(specifier.name); - write(" = "); - write(generatedName); - write("."); - emitNodeWithCommentsAndWithoutSourcemap(specifier.propertyName || specifier.name); - write(";"); - emitEnd(specifier); - } - } - } - else { - writeLine(); - write("__export("); - if (modulekind !== 2) { - emitRequire(ts.getExternalModuleName(node)); - } - else { - write(generatedName); - } - write(");"); - } - emitEnd(node); - } - } - else { - if (!node.exportClause || resolver.isValueAliasDeclaration(node)) { - write("export "); - if (node.exportClause) { - write("{ "); - emitExportOrImportSpecifierList(node.exportClause.elements, resolver.isValueAliasDeclaration); - write(" }"); - } - else { - write("*"); - } - if (node.moduleSpecifier) { - write(" from "); - emit(node.moduleSpecifier); - } - write(";"); - } - } - } - function emitExportOrImportSpecifierList(specifiers, shouldEmit) { - ts.Debug.assert(modulekind === 5); - var needsComma = false; - for (var _a = 0; _a < specifiers.length; _a++) { - var specifier = specifiers[_a]; - if (shouldEmit(specifier)) { - if (needsComma) { - write(", "); - } - if (specifier.propertyName) { - emit(specifier.propertyName); - write(" as "); - } - emit(specifier.name); - needsComma = true; - } - } - } - function emitExportAssignment(node) { - if (!node.isExportEquals && resolver.isValueAliasDeclaration(node)) { - if (modulekind === 5) { - writeLine(); - emitStart(node); - write("export default "); - var expression = node.expression; - emit(expression); - if (expression.kind !== 213 && - expression.kind !== 214) { - write(";"); - } - emitEnd(node); - } - else { - writeLine(); - emitStart(node); - if (modulekind === 4) { - write(exportFunctionForFile + "(\"default\","); - emit(node.expression); - write(")"); - } - else { - emitEs6ExportDefaultCompat(node); - emitContainingModuleName(node); - if (languageVersion === 0) { - write("[\"default\"] = "); - } - else { - write(".default = "); - } - emit(node.expression); - } - write(";"); - emitEnd(node); - } - } - } - function collectExternalModuleInfo(sourceFile) { - externalImports = []; - exportSpecifiers = {}; - exportEquals = undefined; - hasExportStars = false; - for (var _a = 0, _b = sourceFile.statements; _a < _b.length; _a++) { - var node = _b[_a]; - switch (node.kind) { - case 222: - if (!node.importClause || - resolver.isReferencedAliasDeclaration(node.importClause, true)) { - externalImports.push(node); - } - break; - case 221: - if (node.moduleReference.kind === 232 && resolver.isReferencedAliasDeclaration(node)) { - externalImports.push(node); - } - break; - case 228: - if (node.moduleSpecifier) { - if (!node.exportClause) { - externalImports.push(node); - hasExportStars = true; - } - else if (resolver.isValueAliasDeclaration(node)) { - externalImports.push(node); - } - } - else { - for (var _c = 0, _d = node.exportClause.elements; _c < _d.length; _c++) { - var specifier = _d[_c]; - var name_26 = (specifier.propertyName || specifier.name).text; - (exportSpecifiers[name_26] || (exportSpecifiers[name_26] = [])).push(specifier); - } - } - break; - case 227: - if (node.isExportEquals && !exportEquals) { - exportEquals = node; - } - break; - } - } - } - function emitExportStarHelper() { - if (hasExportStars) { - writeLine(); - write("function __export(m) {"); - increaseIndent(); - writeLine(); - write("for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];"); - decreaseIndent(); - writeLine(); - write("}"); - } - } - function getLocalNameForExternalImport(node) { - var namespaceDeclaration = getNamespaceDeclarationNode(node); - if (namespaceDeclaration && !isDefaultImport(node)) { - return ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, namespaceDeclaration.name); - } - if (node.kind === 222 && node.importClause) { - return getGeneratedNameForNode(node); - } - if (node.kind === 228 && node.moduleSpecifier) { - return getGeneratedNameForNode(node); - } - } - function getExternalModuleNameText(importNode) { - var moduleName = ts.getExternalModuleName(importNode); - if (moduleName.kind === 9) { - return tryRenameExternalModule(moduleName) || getLiteralText(moduleName); - } - return undefined; - } - function emitVariableDeclarationsForImports() { - if (externalImports.length === 0) { - return; - } - writeLine(); - var started = false; - for (var _a = 0; _a < externalImports.length; _a++) { - var importNode = externalImports[_a]; - var skipNode = importNode.kind === 228 || - (importNode.kind === 222 && !importNode.importClause); - if (skipNode) { - continue; - } - if (!started) { - write("var "); - started = true; - } - else { - write(", "); - } - write(getLocalNameForExternalImport(importNode)); - } - if (started) { - write(";"); - } - } - function emitLocalStorageForExportedNamesIfNecessary(exportedDeclarations) { - if (!hasExportStars) { - return undefined; - } - if (!exportedDeclarations && ts.isEmpty(exportSpecifiers)) { - var hasExportDeclarationWithExportClause = false; - for (var _a = 0; _a < externalImports.length; _a++) { - var externalImport = externalImports[_a]; - if (externalImport.kind === 228 && externalImport.exportClause) { - hasExportDeclarationWithExportClause = true; - break; - } - } - if (!hasExportDeclarationWithExportClause) { - return emitExportStarFunction(undefined); - } - } - var exportedNamesStorageRef = makeUniqueName("exportedNames"); - writeLine(); - write("var " + exportedNamesStorageRef + " = {"); - increaseIndent(); - var started = false; - if (exportedDeclarations) { - for (var i = 0; i < exportedDeclarations.length; ++i) { - writeExportedName(exportedDeclarations[i]); - } - } - if (exportSpecifiers) { - for (var n in exportSpecifiers) { - for (var _b = 0, _c = exportSpecifiers[n]; _b < _c.length; _b++) { - var specifier = _c[_b]; - writeExportedName(specifier.name); - } - } - } - for (var _d = 0; _d < externalImports.length; _d++) { - var externalImport = externalImports[_d]; - if (externalImport.kind !== 228) { - continue; - } - var exportDecl = externalImport; - if (!exportDecl.exportClause) { - continue; - } - for (var _e = 0, _f = exportDecl.exportClause.elements; _e < _f.length; _e++) { - var element = _f[_e]; - writeExportedName(element.name || element.propertyName); - } - } - decreaseIndent(); - writeLine(); - write("};"); - return emitExportStarFunction(exportedNamesStorageRef); - function emitExportStarFunction(localNames) { - var exportStarFunction = makeUniqueName("exportStar"); - writeLine(); - write("function " + exportStarFunction + "(m) {"); - increaseIndent(); - writeLine(); - write("var exports = {};"); - writeLine(); - write("for(var n in m) {"); - increaseIndent(); - writeLine(); - write("if (n !== \"default\""); - if (localNames) { - write("&& !" + localNames + ".hasOwnProperty(n)"); - } - write(") exports[n] = m[n];"); - decreaseIndent(); - writeLine(); - write("}"); - writeLine(); - write(exportFunctionForFile + "(exports);"); - decreaseIndent(); - writeLine(); - write("}"); - return exportStarFunction; - } - function writeExportedName(node) { - if (node.kind !== 69 && node.flags & 1024) { - return; - } - if (started) { - write(","); - } - else { - started = true; - } - writeLine(); - write("'"); - if (node.kind === 69) { - emitNodeWithCommentsAndWithoutSourcemap(node); - } - else { - emitDeclarationName(node); - } - write("': true"); - } - } - function processTopLevelVariableAndFunctionDeclarations(node) { - var hoistedVars; - var hoistedFunctionDeclarations; - var exportedDeclarations; - visit(node); - if (hoistedVars) { - writeLine(); - write("var "); - var seen = {}; - for (var i = 0; i < hoistedVars.length; ++i) { - var local = hoistedVars[i]; - var name_27 = local.kind === 69 - ? local - : local.name; - if (name_27) { - var text = ts.unescapeIdentifier(name_27.text); - if (ts.hasProperty(seen, text)) { - continue; - } - else { - seen[text] = text; - } - } - if (i !== 0) { - write(", "); - } - if (local.kind === 214 || local.kind === 218 || local.kind === 217) { - emitDeclarationName(local); - } - else { - emit(local); - } - var flags = ts.getCombinedNodeFlags(local.kind === 69 ? local.parent : local); - if (flags & 1) { - if (!exportedDeclarations) { - exportedDeclarations = []; - } - exportedDeclarations.push(local); - } - } - write(";"); - } - if (hoistedFunctionDeclarations) { - for (var _a = 0; _a < hoistedFunctionDeclarations.length; _a++) { - var f = hoistedFunctionDeclarations[_a]; - writeLine(); - emit(f); - if (f.flags & 1) { - if (!exportedDeclarations) { - exportedDeclarations = []; - } - exportedDeclarations.push(f); - } - } - } - return exportedDeclarations; - function visit(node) { - if (node.flags & 2) { - return; - } - if (node.kind === 213) { - if (!hoistedFunctionDeclarations) { - hoistedFunctionDeclarations = []; - } - hoistedFunctionDeclarations.push(node); - return; - } - if (node.kind === 214) { - if (!hoistedVars) { - hoistedVars = []; - } - hoistedVars.push(node); - return; - } - if (node.kind === 217) { - if (shouldEmitEnumDeclaration(node)) { - if (!hoistedVars) { - hoistedVars = []; - } - hoistedVars.push(node); - } - return; - } - if (node.kind === 218) { - if (shouldEmitModuleDeclaration(node)) { - if (!hoistedVars) { - hoistedVars = []; - } - hoistedVars.push(node); - } - return; - } - if (node.kind === 211 || node.kind === 163) { - if (shouldHoistVariable(node, false)) { - var name_28 = node.name; - if (name_28.kind === 69) { - if (!hoistedVars) { - hoistedVars = []; - } - hoistedVars.push(name_28); - } - else { - ts.forEachChild(name_28, visit); - } - } - return; - } - if (ts.isInternalModuleImportEqualsDeclaration(node) && resolver.isValueAliasDeclaration(node)) { - if (!hoistedVars) { - hoistedVars = []; - } - hoistedVars.push(node.name); - return; - } - if (ts.isBindingPattern(node)) { - ts.forEach(node.elements, visit); - return; - } - if (!ts.isDeclaration(node)) { - ts.forEachChild(node, visit); - } - } - } - function shouldHoistVariable(node, checkIfSourceFileLevelDecl) { - if (checkIfSourceFileLevelDecl && !shouldHoistDeclarationInSystemJsModule(node)) { - return false; - } - return (ts.getCombinedNodeFlags(node) & 49152) === 0 || - ts.getEnclosingBlockScopeContainer(node).kind === 248; - } - function isCurrentFileSystemExternalModule() { - return modulekind === 4 && ts.isExternalModule(currentSourceFile); - } - function emitSystemModuleBody(node, dependencyGroups, startIndex) { - emitVariableDeclarationsForImports(); - writeLine(); - var exportedDeclarations = processTopLevelVariableAndFunctionDeclarations(node); - var exportStarFunction = emitLocalStorageForExportedNamesIfNecessary(exportedDeclarations); - writeLine(); - write("return {"); - increaseIndent(); - writeLine(); - emitSetters(exportStarFunction, dependencyGroups); - writeLine(); - emitExecute(node, startIndex); - decreaseIndent(); - writeLine(); - write("}"); - emitTempDeclarations(true); - } - function emitSetters(exportStarFunction, dependencyGroups) { - write("setters:["); - for (var i = 0; i < dependencyGroups.length; ++i) { - if (i !== 0) { - write(","); - } - writeLine(); - increaseIndent(); - var group = dependencyGroups[i]; - var parameterName = makeUniqueName(ts.forEach(group, getLocalNameForExternalImport) || ""); - write("function (" + parameterName + ") {"); - increaseIndent(); - for (var _a = 0; _a < group.length; _a++) { - var entry = group[_a]; - var importVariableName = getLocalNameForExternalImport(entry) || ""; - switch (entry.kind) { - case 222: - if (!entry.importClause) { - break; - } - case 221: - ts.Debug.assert(importVariableName !== ""); - writeLine(); - write(importVariableName + " = " + parameterName + ";"); - writeLine(); - break; - case 228: - ts.Debug.assert(importVariableName !== ""); - if (entry.exportClause) { - writeLine(); - write(exportFunctionForFile + "({"); - writeLine(); - increaseIndent(); - for (var i_2 = 0, len = entry.exportClause.elements.length; i_2 < len; ++i_2) { - if (i_2 !== 0) { - write(","); - writeLine(); - } - var e = entry.exportClause.elements[i_2]; - write("\""); - emitNodeWithCommentsAndWithoutSourcemap(e.name); - write("\": " + parameterName + "[\""); - emitNodeWithCommentsAndWithoutSourcemap(e.propertyName || e.name); - write("\"]"); - } - decreaseIndent(); - writeLine(); - write("});"); - } - else { - writeLine(); - write(exportStarFunction + "(" + parameterName + ");"); - } - writeLine(); - break; - } - } - decreaseIndent(); - write("}"); - decreaseIndent(); - } - write("],"); - } - function emitExecute(node, startIndex) { - write("execute: function() {"); - increaseIndent(); - writeLine(); - for (var i = startIndex; i < node.statements.length; ++i) { - var statement = node.statements[i]; - switch (statement.kind) { - case 213: - case 222: - continue; - case 228: - if (!statement.moduleSpecifier) { - for (var _a = 0, _b = statement.exportClause.elements; _a < _b.length; _a++) { - var element = _b[_a]; - emitExportSpecifierInSystemModule(element); - } - } - continue; - case 221: - if (!ts.isInternalModuleImportEqualsDeclaration(statement)) { - continue; - } - default: - writeLine(); - emit(statement); - } - } - decreaseIndent(); - writeLine(); - write("}"); - } - function emitSystemModule(node) { - collectExternalModuleInfo(node); - ts.Debug.assert(!exportFunctionForFile); - exportFunctionForFile = makeUniqueName("exports"); - writeLine(); - write("System.register("); - if (node.moduleName) { - write("\"" + node.moduleName + "\", "); - } - write("["); - var groupIndices = {}; - var dependencyGroups = []; - for (var i = 0; i < externalImports.length; ++i) { - var text = getExternalModuleNameText(externalImports[i]); - if (ts.hasProperty(groupIndices, text)) { - var groupIndex = groupIndices[text]; - dependencyGroups[groupIndex].push(externalImports[i]); - continue; - } - else { - groupIndices[text] = dependencyGroups.length; - dependencyGroups.push([externalImports[i]]); - } - if (i !== 0) { - write(", "); - } - write(text); - } - write("], function(" + exportFunctionForFile + ") {"); - writeLine(); - increaseIndent(); - var startIndex = emitDirectivePrologues(node.statements, true); - emitEmitHelpers(node); - emitCaptureThisForNodeIfNecessary(node); - emitSystemModuleBody(node, dependencyGroups, startIndex); - decreaseIndent(); - writeLine(); - write("});"); - } - function getAMDDependencyNames(node, includeNonAmdDependencies) { - var aliasedModuleNames = []; - var unaliasedModuleNames = []; - var importAliasNames = []; - for (var _a = 0, _b = node.amdDependencies; _a < _b.length; _a++) { - var amdDependency = _b[_a]; - if (amdDependency.name) { - aliasedModuleNames.push("\"" + amdDependency.path + "\""); - importAliasNames.push(amdDependency.name); - } - else { - unaliasedModuleNames.push("\"" + amdDependency.path + "\""); - } - } - for (var _c = 0; _c < externalImports.length; _c++) { - var importNode = externalImports[_c]; - var externalModuleName = getExternalModuleNameText(importNode); - var importAliasName = getLocalNameForExternalImport(importNode); - if (includeNonAmdDependencies && importAliasName) { - aliasedModuleNames.push(externalModuleName); - importAliasNames.push(importAliasName); - } - else { - unaliasedModuleNames.push(externalModuleName); - } - } - return { aliasedModuleNames: aliasedModuleNames, unaliasedModuleNames: unaliasedModuleNames, importAliasNames: importAliasNames }; - } - function emitAMDDependencies(node, includeNonAmdDependencies) { - var dependencyNames = getAMDDependencyNames(node, includeNonAmdDependencies); - emitAMDDependencyList(dependencyNames); - write(", "); - emitAMDFactoryHeader(dependencyNames); - } - function emitAMDDependencyList(_a) { - var aliasedModuleNames = _a.aliasedModuleNames, unaliasedModuleNames = _a.unaliasedModuleNames; - write("[\"require\", \"exports\""); - if (aliasedModuleNames.length) { - write(", "); - write(aliasedModuleNames.join(", ")); - } - if (unaliasedModuleNames.length) { - write(", "); - write(unaliasedModuleNames.join(", ")); - } - write("]"); - } - function emitAMDFactoryHeader(_a) { - var importAliasNames = _a.importAliasNames; - write("function (require, exports"); - if (importAliasNames.length) { - write(", "); - write(importAliasNames.join(", ")); - } - write(") {"); - } - function emitAMDModule(node) { - emitEmitHelpers(node); - collectExternalModuleInfo(node); - writeLine(); - write("define("); - if (node.moduleName) { - write("\"" + node.moduleName + "\", "); - } - emitAMDDependencies(node, true); - increaseIndent(); - var startIndex = emitDirectivePrologues(node.statements, true); - emitExportStarHelper(); - emitCaptureThisForNodeIfNecessary(node); - emitLinesStartingAt(node.statements, startIndex); - emitTempDeclarations(true); - emitExportEquals(true); - decreaseIndent(); - writeLine(); - write("});"); - } - function emitCommonJSModule(node) { - var startIndex = emitDirectivePrologues(node.statements, false); - emitEmitHelpers(node); - collectExternalModuleInfo(node); - emitExportStarHelper(); - emitCaptureThisForNodeIfNecessary(node); - emitLinesStartingAt(node.statements, startIndex); - emitTempDeclarations(true); - emitExportEquals(false); - } - function emitUMDModule(node) { - emitEmitHelpers(node); - collectExternalModuleInfo(node); - var dependencyNames = getAMDDependencyNames(node, false); - writeLines("(function (factory) {\n if (typeof module === 'object' && typeof module.exports === 'object') {\n var v = factory(require, exports); if (v !== undefined) module.exports = v;\n }\n else if (typeof define === 'function' && define.amd) {\n define("); - emitAMDDependencyList(dependencyNames); - write(", factory);"); - writeLines(" }\n})("); - emitAMDFactoryHeader(dependencyNames); - increaseIndent(); - var startIndex = emitDirectivePrologues(node.statements, true); - emitExportStarHelper(); - emitCaptureThisForNodeIfNecessary(node); - emitLinesStartingAt(node.statements, startIndex); - emitTempDeclarations(true); - emitExportEquals(true); - decreaseIndent(); - writeLine(); - write("});"); - } - function emitES6Module(node) { - externalImports = undefined; - exportSpecifiers = undefined; - exportEquals = undefined; - hasExportStars = false; - var startIndex = emitDirectivePrologues(node.statements, false); - emitEmitHelpers(node); - emitCaptureThisForNodeIfNecessary(node); - emitLinesStartingAt(node.statements, startIndex); - emitTempDeclarations(true); - } - function emitExportEquals(emitAsReturn) { - if (exportEquals && resolver.isValueAliasDeclaration(exportEquals)) { - writeLine(); - emitStart(exportEquals); - write(emitAsReturn ? "return " : "module.exports = "); - emit(exportEquals.expression); - write(";"); - emitEnd(exportEquals); - } - } - function emitJsxElement(node) { - switch (compilerOptions.jsx) { - case 2: - jsxEmitReact(node); - break; - case 1: - default: - jsxEmitPreserve(node); - break; - } - } - function trimReactWhitespaceAndApplyEntities(node) { - var result = undefined; - var text = ts.getTextOfNode(node, true); - var firstNonWhitespace = 0; - var lastNonWhitespace = -1; - for (var i = 0; i < text.length; i++) { - var c = text.charCodeAt(i); - if (ts.isLineBreak(c)) { - if (firstNonWhitespace !== -1 && (lastNonWhitespace - firstNonWhitespace + 1 > 0)) { - var part = text.substr(firstNonWhitespace, lastNonWhitespace - firstNonWhitespace + 1); - result = (result ? result + "\" + ' ' + \"" : "") + ts.escapeString(part); - } - firstNonWhitespace = -1; - } - else if (!ts.isWhiteSpace(c)) { - lastNonWhitespace = i; - if (firstNonWhitespace === -1) { - firstNonWhitespace = i; - } - } - } - if (firstNonWhitespace !== -1) { - var part = text.substr(firstNonWhitespace); - result = (result ? result + "\" + ' ' + \"" : "") + ts.escapeString(part); - } - if (result) { - result = result.replace(/&(\w+);/g, function (s, m) { - if (entities[m] !== undefined) { - return String.fromCharCode(entities[m]); - } - else { - return s; - } - }); - } - return result; - } - function getTextToEmit(node) { - switch (compilerOptions.jsx) { - case 2: - var text = trimReactWhitespaceAndApplyEntities(node); - if (text === undefined || text.length === 0) { - return undefined; - } - else { - return text; - } - case 1: - default: - return ts.getTextOfNode(node, true); - } - } - function emitJsxText(node) { - switch (compilerOptions.jsx) { - case 2: - write("\""); - write(trimReactWhitespaceAndApplyEntities(node)); - write("\""); - break; - case 1: - default: - writer.writeLiteral(ts.getTextOfNode(node, true)); - break; - } - } - function emitJsxExpression(node) { - if (node.expression) { - switch (compilerOptions.jsx) { - case 1: - default: - write("{"); - emit(node.expression); - write("}"); - break; - case 2: - emit(node.expression); - break; - } - } - } - function emitDirectivePrologues(statements, startWithNewLine) { - for (var i = 0; i < statements.length; ++i) { - if (ts.isPrologueDirective(statements[i])) { - if (startWithNewLine || i > 0) { - writeLine(); - } - emit(statements[i]); - } - else { - return i; - } - } - return statements.length; - } - function writeLines(text) { - var lines = text.split(/\r\n|\r|\n/g); - for (var i = 0; i < lines.length; ++i) { - var line = lines[i]; - if (line.length) { - writeLine(); - write(line); - } - } - } - function emitEmitHelpers(node) { - if (!compilerOptions.noEmitHelpers) { - if ((languageVersion < 2) && (!extendsEmitted && resolver.getNodeCheckFlags(node) & 8)) { - writeLines(extendsHelper); - extendsEmitted = true; - } - if (!decorateEmitted && resolver.getNodeCheckFlags(node) & 16) { - writeLines(decorateHelper); - if (compilerOptions.emitDecoratorMetadata) { - writeLines(metadataHelper); - } - decorateEmitted = true; - } - if (!paramEmitted && resolver.getNodeCheckFlags(node) & 32) { - writeLines(paramHelper); - paramEmitted = true; - } - if (!awaiterEmitted && resolver.getNodeCheckFlags(node) & 64) { - writeLines(awaiterHelper); - awaiterEmitted = true; - } - } - } - function emitSourceFileNode(node) { - writeLine(); - emitShebang(); - emitDetachedComments(node); - if (ts.isExternalModule(node) || compilerOptions.isolatedModules) { - var emitModule = moduleEmitDelegates[modulekind] || moduleEmitDelegates[1]; - emitModule(node); - } - else { - var startIndex = emitDirectivePrologues(node.statements, false); - externalImports = undefined; - exportSpecifiers = undefined; - exportEquals = undefined; - hasExportStars = false; - emitEmitHelpers(node); - emitCaptureThisForNodeIfNecessary(node); - emitLinesStartingAt(node.statements, startIndex); - emitTempDeclarations(true); - } - emitLeadingComments(node.endOfFileToken); - } - function emitNodeWithCommentsAndWithoutSourcemap(node) { - emitNodeConsideringCommentsOption(node, emitNodeWithoutSourceMap); - } - function emitNodeConsideringCommentsOption(node, emitNodeConsideringSourcemap) { - if (node) { - if (node.flags & 2) { - return emitCommentsOnNotEmittedNode(node); - } - if (isSpecializedCommentHandling(node)) { - return emitNodeWithoutSourceMap(node); - } - var emitComments_1 = shouldEmitLeadingAndTrailingComments(node); - if (emitComments_1) { - emitLeadingComments(node); - } - emitNodeConsideringSourcemap(node); - if (emitComments_1) { - emitTrailingComments(node); - } - } - } - function emitNodeWithoutSourceMap(node) { - if (node) { - emitJavaScriptWorker(node); - } - } - function isSpecializedCommentHandling(node) { - switch (node.kind) { - case 215: - case 213: - case 222: - case 221: - case 216: - case 227: - return true; - } - } - function shouldEmitLeadingAndTrailingComments(node) { - switch (node.kind) { - case 193: - return shouldEmitLeadingAndTrailingCommentsForVariableStatement(node); - case 218: - return shouldEmitModuleDeclaration(node); - case 217: - return shouldEmitEnumDeclaration(node); - } - ts.Debug.assert(!isSpecializedCommentHandling(node)); - if (node.kind !== 192 && - node.parent && - node.parent.kind === 174 && - node.parent.body === node && - compilerOptions.target <= 1) { - return false; - } - return true; - } - function emitJavaScriptWorker(node) { - switch (node.kind) { - case 69: - return emitIdentifier(node); - case 138: - return emitParameter(node); - case 143: - case 142: - return emitMethod(node); - case 145: - case 146: - return emitAccessor(node); - case 97: - return emitThis(node); - case 95: - return emitSuper(node); - case 93: - return write("null"); - case 99: - return write("true"); - case 84: - return write("false"); - case 8: - case 9: - case 10: - case 11: - case 12: - case 13: - case 14: - return emitLiteral(node); - case 183: - return emitTemplateExpression(node); - case 190: - return emitTemplateSpan(node); - case 233: - case 234: - return emitJsxElement(node); - case 236: - return emitJsxText(node); - case 240: - return emitJsxExpression(node); - case 135: - return emitQualifiedName(node); - case 161: - return emitObjectBindingPattern(node); - case 162: - return emitArrayBindingPattern(node); - case 163: - return emitBindingElement(node); - case 164: - return emitArrayLiteral(node); - case 165: - return emitObjectLiteral(node); - case 245: - return emitPropertyAssignment(node); - case 246: - return emitShorthandPropertyAssignment(node); - case 136: - return emitComputedPropertyName(node); - case 166: - return emitPropertyAccess(node); - case 167: - return emitIndexedAccess(node); - case 168: - return emitCallExpression(node); - case 169: - return emitNewExpression(node); - case 170: - return emitTaggedTemplateExpression(node); - case 171: - return emit(node.expression); - case 189: - return emit(node.expression); - case 172: - return emitParenExpression(node); - case 213: - case 173: - case 174: - return emitFunctionDeclaration(node); - case 175: - return emitDeleteExpression(node); - case 176: - return emitTypeOfExpression(node); - case 177: - return emitVoidExpression(node); - case 178: - return emitAwaitExpression(node); - case 179: - return emitPrefixUnaryExpression(node); - case 180: - return emitPostfixUnaryExpression(node); - case 181: - return emitBinaryExpression(node); - case 182: - return emitConditionalExpression(node); - case 185: - return emitSpreadElementExpression(node); - case 184: - return emitYieldExpression(node); - case 187: - return; - case 192: - case 219: - return emitBlock(node); - case 193: - return emitVariableStatement(node); - case 194: - return write(";"); - case 195: - return emitExpressionStatement(node); - case 196: - return emitIfStatement(node); - case 197: - return emitDoStatement(node); - case 198: - return emitWhileStatement(node); - case 199: - return emitForStatement(node); - case 201: - case 200: - return emitForInOrForOfStatement(node); - case 202: - case 203: - return emitBreakOrContinueStatement(node); - case 204: - return emitReturnStatement(node); - case 205: - return emitWithStatement(node); - case 206: - return emitSwitchStatement(node); - case 241: - case 242: - return emitCaseOrDefaultClause(node); - case 207: - return emitLabelledStatement(node); - case 208: - return emitThrowStatement(node); - case 209: - return emitTryStatement(node); - case 244: - return emitCatchClause(node); - case 210: - return emitDebuggerStatement(node); - case 211: - return emitVariableDeclaration(node); - case 186: - return emitClassExpression(node); - case 214: - return emitClassDeclaration(node); - case 215: - return emitInterfaceDeclaration(node); - case 217: - return emitEnumDeclaration(node); - case 247: - return emitEnumMember(node); - case 218: - return emitModuleDeclaration(node); - case 222: - return emitImportDeclaration(node); - case 221: - return emitImportEqualsDeclaration(node); - case 228: - return emitExportDeclaration(node); - case 227: - return emitExportAssignment(node); - case 248: - return emitSourceFileNode(node); - } - } - function hasDetachedComments(pos) { - return detachedCommentsInfo !== undefined && ts.lastOrUndefined(detachedCommentsInfo).nodePos === pos; - } - function getLeadingCommentsWithoutDetachedComments() { - var leadingComments = ts.getLeadingCommentRanges(currentSourceFile.text, ts.lastOrUndefined(detachedCommentsInfo).detachedCommentEndPos); - if (detachedCommentsInfo.length - 1) { - detachedCommentsInfo.pop(); - } - else { - detachedCommentsInfo = undefined; - } - return leadingComments; - } - function isPinnedComments(comment) { - return currentSourceFile.text.charCodeAt(comment.pos + 1) === 42 && - currentSourceFile.text.charCodeAt(comment.pos + 2) === 33; - } - function isTripleSlashComment(comment) { - if (currentSourceFile.text.charCodeAt(comment.pos + 1) === 47 && - comment.pos + 2 < comment.end && - currentSourceFile.text.charCodeAt(comment.pos + 2) === 47) { - var textSubStr = currentSourceFile.text.substring(comment.pos, comment.end); - return textSubStr.match(ts.fullTripleSlashReferencePathRegEx) || - textSubStr.match(ts.fullTripleSlashAMDReferencePathRegEx) ? - true : false; - } - return false; - } - function getLeadingCommentsToEmit(node) { - if (node.parent) { - if (node.parent.kind === 248 || node.pos !== node.parent.pos) { - if (hasDetachedComments(node.pos)) { - return getLeadingCommentsWithoutDetachedComments(); - } - else { - return ts.getLeadingCommentRangesOfNode(node, currentSourceFile); - } - } - } - } - function getTrailingCommentsToEmit(node) { - if (node.parent) { - if (node.parent.kind === 248 || node.end !== node.parent.end) { - return ts.getTrailingCommentRanges(currentSourceFile.text, node.end); - } - } - } - function emitCommentsOnNotEmittedNode(node) { - emitLeadingCommentsWorker(node, false); - } - function emitLeadingComments(node) { - return emitLeadingCommentsWorker(node, true); - } - function emitLeadingCommentsWorker(node, isEmittedNode) { - if (compilerOptions.removeComments) { - return; - } - var leadingComments; - if (isEmittedNode) { - leadingComments = getLeadingCommentsToEmit(node); - } - else { - if (node.pos === 0) { - leadingComments = ts.filter(getLeadingCommentsToEmit(node), isTripleSlashComment); - } - } - ts.emitNewLineBeforeLeadingComments(currentSourceFile, writer, node, leadingComments); - ts.emitComments(currentSourceFile, writer, leadingComments, true, newLine, writeComment); - } - function emitTrailingComments(node) { - if (compilerOptions.removeComments) { - return; - } - var trailingComments = getTrailingCommentsToEmit(node); - ts.emitComments(currentSourceFile, writer, trailingComments, false, newLine, writeComment); - } - function emitTrailingCommentsOfPosition(pos) { - if (compilerOptions.removeComments) { - return; - } - var trailingComments = ts.getTrailingCommentRanges(currentSourceFile.text, pos); - ts.emitComments(currentSourceFile, writer, trailingComments, true, newLine, writeComment); - } - function emitLeadingCommentsOfPositionWorker(pos) { - if (compilerOptions.removeComments) { - return; - } - var leadingComments; - if (hasDetachedComments(pos)) { - leadingComments = getLeadingCommentsWithoutDetachedComments(); - } - else { - leadingComments = ts.getLeadingCommentRanges(currentSourceFile.text, pos); - } - ts.emitNewLineBeforeLeadingComments(currentSourceFile, writer, { pos: pos, end: pos }, leadingComments); - ts.emitComments(currentSourceFile, writer, leadingComments, true, newLine, writeComment); - } - function emitDetachedComments(node) { - var leadingComments; - if (compilerOptions.removeComments) { - if (node.pos === 0) { - leadingComments = ts.filter(ts.getLeadingCommentRanges(currentSourceFile.text, node.pos), isPinnedComments); - } - } - else { - leadingComments = ts.getLeadingCommentRanges(currentSourceFile.text, node.pos); - } - if (leadingComments) { - var detachedComments = []; - var lastComment; - ts.forEach(leadingComments, function (comment) { - if (lastComment) { - var lastCommentLine = ts.getLineOfLocalPosition(currentSourceFile, lastComment.end); - var commentLine = ts.getLineOfLocalPosition(currentSourceFile, comment.pos); - if (commentLine >= lastCommentLine + 2) { - return detachedComments; - } - } - detachedComments.push(comment); - lastComment = comment; - }); - if (detachedComments.length) { - var lastCommentLine = ts.getLineOfLocalPosition(currentSourceFile, ts.lastOrUndefined(detachedComments).end); - var nodeLine = ts.getLineOfLocalPosition(currentSourceFile, ts.skipTrivia(currentSourceFile.text, node.pos)); - if (nodeLine >= lastCommentLine + 2) { - ts.emitNewLineBeforeLeadingComments(currentSourceFile, writer, node, leadingComments); - ts.emitComments(currentSourceFile, writer, detachedComments, true, newLine, writeComment); - var currentDetachedCommentInfo = { nodePos: node.pos, detachedCommentEndPos: ts.lastOrUndefined(detachedComments).end }; - if (detachedCommentsInfo) { - detachedCommentsInfo.push(currentDetachedCommentInfo); - } - else { - detachedCommentsInfo = [currentDetachedCommentInfo]; - } - } - } - } - } - function emitShebang() { - var shebang = ts.getShebang(currentSourceFile.text); - if (shebang) { - write(shebang); - } - } - var _a; - } - function emitFile(jsFilePath, sourceFile) { - emitJavaScript(jsFilePath, sourceFile); - if (compilerOptions.declaration) { - ts.writeDeclarationFile(jsFilePath, sourceFile, host, resolver, diagnostics); - } - } - } - ts.emitFiles = emitFiles; -})(ts || (ts = {})); -var ts; -(function (ts) { - ts.programTime = 0; - ts.emitTime = 0; - ts.ioReadTime = 0; - ts.ioWriteTime = 0; - var emptyArray = []; - ts.version = "1.8.0"; - function findConfigFile(searchPath) { - var fileName = "tsconfig.json"; - while (true) { - if (ts.sys.fileExists(fileName)) { - return fileName; - } - var parentPath = ts.getDirectoryPath(searchPath); - if (parentPath === searchPath) { - break; - } - searchPath = parentPath; - fileName = "../" + fileName; - } - return undefined; - } - ts.findConfigFile = findConfigFile; - function resolveTripleslashReference(moduleName, containingFile) { - var basePath = ts.getDirectoryPath(containingFile); - var referencedFileName = ts.isRootedDiskPath(moduleName) ? moduleName : ts.combinePaths(basePath, moduleName); - return ts.normalizePath(referencedFileName); - } - ts.resolveTripleslashReference = resolveTripleslashReference; - function resolveModuleName(moduleName, containingFile, compilerOptions, host) { - var moduleResolution = compilerOptions.moduleResolution !== undefined - ? compilerOptions.moduleResolution - : compilerOptions.module === 1 ? 2 : 1; - switch (moduleResolution) { - case 2: return nodeModuleNameResolver(moduleName, containingFile, host); - case 1: return classicNameResolver(moduleName, containingFile, compilerOptions, host); - } - } - ts.resolveModuleName = resolveModuleName; - function nodeModuleNameResolver(moduleName, containingFile, host) { - var containingDirectory = ts.getDirectoryPath(containingFile); - if (ts.getRootLength(moduleName) !== 0 || nameStartsWithDotSlashOrDotDotSlash(moduleName)) { - var failedLookupLocations = []; - var candidate = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName)); - var resolvedFileName = loadNodeModuleFromFile(candidate, failedLookupLocations, host); - if (resolvedFileName) { - return { resolvedModule: { resolvedFileName: resolvedFileName }, failedLookupLocations: failedLookupLocations }; - } - resolvedFileName = loadNodeModuleFromDirectory(candidate, failedLookupLocations, host); - return resolvedFileName - ? { resolvedModule: { resolvedFileName: resolvedFileName }, failedLookupLocations: failedLookupLocations } - : { resolvedModule: undefined, failedLookupLocations: failedLookupLocations }; - } - else { - return loadModuleFromNodeModules(moduleName, containingDirectory, host); - } - } - ts.nodeModuleNameResolver = nodeModuleNameResolver; - function loadNodeModuleFromFile(candidate, failedLookupLocation, host) { - return ts.forEach(ts.moduleFileExtensions, tryLoad); - function tryLoad(ext) { - var fileName = ts.fileExtensionIs(candidate, ext) ? candidate : candidate + ext; - if (host.fileExists(fileName)) { - return fileName; - } - else { - failedLookupLocation.push(fileName); - return undefined; - } - } - } - function loadNodeModuleFromDirectory(candidate, failedLookupLocation, host) { - var packageJsonPath = ts.combinePaths(candidate, "package.json"); - if (host.fileExists(packageJsonPath)) { - var jsonContent; - try { - var jsonText = host.readFile(packageJsonPath); - jsonContent = jsonText ? JSON.parse(jsonText) : { typings: undefined }; - } - catch (e) { - jsonContent = { typings: undefined }; - } - if (jsonContent.typings) { - var result = loadNodeModuleFromFile(ts.normalizePath(ts.combinePaths(candidate, jsonContent.typings)), failedLookupLocation, host); - if (result) { - return result; - } - } - } - else { - failedLookupLocation.push(packageJsonPath); - } - return loadNodeModuleFromFile(ts.combinePaths(candidate, "index"), failedLookupLocation, host); - } - function loadModuleFromNodeModules(moduleName, directory, host) { - var failedLookupLocations = []; - directory = ts.normalizeSlashes(directory); - while (true) { - var baseName = ts.getBaseFileName(directory); - if (baseName !== "node_modules") { - var nodeModulesFolder = ts.combinePaths(directory, "node_modules"); - var candidate = ts.normalizePath(ts.combinePaths(nodeModulesFolder, moduleName)); - var result = loadNodeModuleFromFile(candidate, failedLookupLocations, host); - if (result) { - return { resolvedModule: { resolvedFileName: result, isExternalLibraryImport: true }, failedLookupLocations: failedLookupLocations }; - } - result = loadNodeModuleFromDirectory(candidate, failedLookupLocations, host); - if (result) { - return { resolvedModule: { resolvedFileName: result, isExternalLibraryImport: true }, failedLookupLocations: failedLookupLocations }; - } - } - var parentPath = ts.getDirectoryPath(directory); - if (parentPath === directory) { - break; - } - directory = parentPath; - } - return { resolvedModule: undefined, failedLookupLocations: failedLookupLocations }; - } - function nameStartsWithDotSlashOrDotDotSlash(name) { - var i = name.lastIndexOf("./", 1); - return i === 0 || (i === 1 && name.charCodeAt(0) === 46); - } - function classicNameResolver(moduleName, containingFile, compilerOptions, host) { - if (moduleName.indexOf("!") != -1) { - return { resolvedModule: undefined, failedLookupLocations: [] }; - } - var searchPath = ts.getDirectoryPath(containingFile); - var searchName; - var failedLookupLocations = []; - var referencedSourceFile; - while (true) { - searchName = ts.normalizePath(ts.combinePaths(searchPath, moduleName)); - referencedSourceFile = ts.forEach(ts.supportedExtensions, function (extension) { - if (extension === ".tsx" && !compilerOptions.jsx) { - return undefined; - } - var candidate = searchName + extension; - if (host.fileExists(candidate)) { - return candidate; - } - else { - failedLookupLocations.push(candidate); - } - }); - if (referencedSourceFile) { - break; - } - var parentPath = ts.getDirectoryPath(searchPath); - if (parentPath === searchPath) { - break; - } - searchPath = parentPath; - } - return referencedSourceFile - ? { resolvedModule: { resolvedFileName: referencedSourceFile }, failedLookupLocations: failedLookupLocations } - : { resolvedModule: undefined, failedLookupLocations: failedLookupLocations }; - } - ts.classicNameResolver = classicNameResolver; - ts.defaultInitCompilerOptions = { - module: 1, - target: 0, - noImplicitAny: false, - outDir: "built", - rootDir: ".", - sourceMap: false - }; - function createCompilerHost(options, setParentNodes) { - var currentDirectory; - var existingDirectories = {}; - function getCanonicalFileName(fileName) { - return ts.sys.useCaseSensitiveFileNames ? fileName : fileName.toLowerCase(); - } - var unsupportedFileEncodingErrorCode = -2147024809; - function getSourceFile(fileName, languageVersion, onError) { - var text; - try { - var start = new Date().getTime(); - text = ts.sys.readFile(fileName, options.charset); - ts.ioReadTime += new Date().getTime() - start; - } - catch (e) { - if (onError) { - onError(e.number === unsupportedFileEncodingErrorCode - ? ts.createCompilerDiagnostic(ts.Diagnostics.Unsupported_file_encoding).messageText - : e.message); - } - text = ""; - } - return text !== undefined ? ts.createSourceFile(fileName, text, languageVersion, setParentNodes) : undefined; - } - function directoryExists(directoryPath) { - if (ts.hasProperty(existingDirectories, directoryPath)) { - return true; - } - if (ts.sys.directoryExists(directoryPath)) { - existingDirectories[directoryPath] = true; - return true; - } - return false; - } - function ensureDirectoriesExist(directoryPath) { - if (directoryPath.length > ts.getRootLength(directoryPath) && !directoryExists(directoryPath)) { - var parentDirectory = ts.getDirectoryPath(directoryPath); - ensureDirectoriesExist(parentDirectory); - ts.sys.createDirectory(directoryPath); - } - } - function writeFile(fileName, data, writeByteOrderMark, onError) { - try { - var start = new Date().getTime(); - ensureDirectoriesExist(ts.getDirectoryPath(ts.normalizePath(fileName))); - ts.sys.writeFile(fileName, data, writeByteOrderMark); - ts.ioWriteTime += new Date().getTime() - start; - } - catch (e) { - if (onError) { - onError(e.message); - } - } - } - var newLine = ts.getNewLineCharacter(options); - return { - getSourceFile: getSourceFile, - getDefaultLibFileName: function (options) { return ts.combinePaths(ts.getDirectoryPath(ts.normalizePath(ts.sys.getExecutingFilePath())), ts.getDefaultLibFileName(options)); }, - writeFile: writeFile, - getCurrentDirectory: function () { return currentDirectory || (currentDirectory = ts.sys.getCurrentDirectory()); }, - useCaseSensitiveFileNames: function () { return ts.sys.useCaseSensitiveFileNames; }, - getCanonicalFileName: getCanonicalFileName, - getNewLine: function () { return newLine; }, - fileExists: function (fileName) { return ts.sys.fileExists(fileName); }, - readFile: function (fileName) { return ts.sys.readFile(fileName); } - }; - } - ts.createCompilerHost = createCompilerHost; - function getPreEmitDiagnostics(program, sourceFile, cancellationToken) { - var diagnostics = program.getOptionsDiagnostics(cancellationToken).concat(program.getSyntacticDiagnostics(sourceFile, cancellationToken), program.getGlobalDiagnostics(cancellationToken), program.getSemanticDiagnostics(sourceFile, cancellationToken)); - if (program.getCompilerOptions().declaration) { - diagnostics.concat(program.getDeclarationDiagnostics(sourceFile, cancellationToken)); - } - return ts.sortAndDeduplicateDiagnostics(diagnostics); - } - ts.getPreEmitDiagnostics = getPreEmitDiagnostics; - function flattenDiagnosticMessageText(messageText, newLine) { - if (typeof messageText === "string") { - return messageText; - } - else { - var diagnosticChain = messageText; - var result = ""; - var indent = 0; - while (diagnosticChain) { - if (indent) { - result += newLine; - for (var i = 0; i < indent; i++) { - result += " "; - } - } - result += diagnosticChain.messageText; - indent++; - diagnosticChain = diagnosticChain.next; - } - return result; - } - } - ts.flattenDiagnosticMessageText = flattenDiagnosticMessageText; - function createProgram(rootNames, options, host, oldProgram) { - var program; - var files = []; - var fileProcessingDiagnostics = ts.createDiagnosticCollection(); - var programDiagnostics = ts.createDiagnosticCollection(); - var commonSourceDirectory; - var diagnosticsProducingTypeChecker; - var noDiagnosticsTypeChecker; - var classifiableNames; - var skipDefaultLib = options.noLib; - var start = new Date().getTime(); - host = host || createCompilerHost(options); - var resolveModuleNamesWorker = host.resolveModuleNames - ? (function (moduleNames, containingFile) { return host.resolveModuleNames(moduleNames, containingFile); }) - : (function (moduleNames, containingFile) { return ts.map(moduleNames, function (moduleName) { return resolveModuleName(moduleName, containingFile, options, host).resolvedModule; }); }); - var filesByName = ts.createFileMap(function (fileName) { return host.getCanonicalFileName(fileName); }); - if (oldProgram) { - var oldOptions = oldProgram.getCompilerOptions(); - if ((oldOptions.module !== options.module) || - (oldOptions.noResolve !== options.noResolve) || - (oldOptions.target !== options.target) || - (oldOptions.noLib !== options.noLib) || - (oldOptions.jsx !== options.jsx)) { - oldProgram = undefined; - } - } - if (!tryReuseStructureFromOldProgram()) { - ts.forEach(rootNames, function (name) { return processRootFile(name, false); }); - if (!skipDefaultLib) { - processRootFile(host.getDefaultLibFileName(options), true); - } - } - verifyCompilerOptions(); - oldProgram = undefined; - ts.programTime += new Date().getTime() - start; - program = { - getRootFileNames: function () { return rootNames; }, - getSourceFile: getSourceFile, - getSourceFiles: function () { return files; }, - getCompilerOptions: function () { return options; }, - getSyntacticDiagnostics: getSyntacticDiagnostics, - getOptionsDiagnostics: getOptionsDiagnostics, - getGlobalDiagnostics: getGlobalDiagnostics, - getSemanticDiagnostics: getSemanticDiagnostics, - getDeclarationDiagnostics: getDeclarationDiagnostics, - getTypeChecker: getTypeChecker, - getClassifiableNames: getClassifiableNames, - getDiagnosticsProducingTypeChecker: getDiagnosticsProducingTypeChecker, - getCommonSourceDirectory: function () { return commonSourceDirectory; }, - emit: emit, - getCurrentDirectory: function () { return host.getCurrentDirectory(); }, - getNodeCount: function () { return getDiagnosticsProducingTypeChecker().getNodeCount(); }, - getIdentifierCount: function () { return getDiagnosticsProducingTypeChecker().getIdentifierCount(); }, - getSymbolCount: function () { return getDiagnosticsProducingTypeChecker().getSymbolCount(); }, - getTypeCount: function () { return getDiagnosticsProducingTypeChecker().getTypeCount(); }, - getFileProcessingDiagnostics: function () { return fileProcessingDiagnostics; } - }; - return program; - function getClassifiableNames() { - if (!classifiableNames) { - getTypeChecker(); - classifiableNames = {}; - for (var _i = 0; _i < files.length; _i++) { - var sourceFile = files[_i]; - ts.copyMap(sourceFile.classifiableNames, classifiableNames); - } - } - return classifiableNames; - } - function tryReuseStructureFromOldProgram() { - if (!oldProgram) { - return false; - } - ts.Debug.assert(!oldProgram.structureIsReused); - var oldRootNames = oldProgram.getRootFileNames(); - if (!ts.arrayIsEqualTo(oldRootNames, rootNames)) { - return false; - } - var newSourceFiles = []; - var modifiedSourceFiles = []; - for (var _i = 0, _a = oldProgram.getSourceFiles(); _i < _a.length; _i++) { - var oldSourceFile = _a[_i]; - var newSourceFile = host.getSourceFile(oldSourceFile.fileName, options.target); - if (!newSourceFile) { - return false; - } - if (oldSourceFile !== newSourceFile) { - if (oldSourceFile.hasNoDefaultLib !== newSourceFile.hasNoDefaultLib) { - return false; - } - if (!ts.arrayIsEqualTo(oldSourceFile.referencedFiles, newSourceFile.referencedFiles, fileReferenceIsEqualTo)) { - return false; - } - collectExternalModuleReferences(newSourceFile); - if (!ts.arrayIsEqualTo(oldSourceFile.imports, newSourceFile.imports, moduleNameIsEqualTo)) { - return false; - } - if (resolveModuleNamesWorker) { - var moduleNames = ts.map(newSourceFile.imports, function (name) { return name.text; }); - var resolutions = resolveModuleNamesWorker(moduleNames, newSourceFile.fileName); - for (var i = 0; i < moduleNames.length; ++i) { - var newResolution = resolutions[i]; - var oldResolution = ts.getResolvedModule(oldSourceFile, moduleNames[i]); - var resolutionChanged = oldResolution - ? !newResolution || - oldResolution.resolvedFileName !== newResolution.resolvedFileName || - !!oldResolution.isExternalLibraryImport !== !!newResolution.isExternalLibraryImport - : newResolution; - if (resolutionChanged) { - return false; - } - } - } - newSourceFile.resolvedModules = oldSourceFile.resolvedModules; - modifiedSourceFiles.push(newSourceFile); - } - else { - newSourceFile = oldSourceFile; - } - newSourceFiles.push(newSourceFile); - } - for (var _b = 0; _b < newSourceFiles.length; _b++) { - var file = newSourceFiles[_b]; - filesByName.set(file.fileName, file); - } - files = newSourceFiles; - fileProcessingDiagnostics = oldProgram.getFileProcessingDiagnostics(); - for (var _c = 0; _c < modifiedSourceFiles.length; _c++) { - var modifiedFile = modifiedSourceFiles[_c]; - fileProcessingDiagnostics.reattachFileDiagnostics(modifiedFile); - } - oldProgram.structureIsReused = true; - return true; - } - function getEmitHost(writeFileCallback) { - return { - getCanonicalFileName: function (fileName) { return host.getCanonicalFileName(fileName); }, - getCommonSourceDirectory: program.getCommonSourceDirectory, - getCompilerOptions: program.getCompilerOptions, - getCurrentDirectory: function () { return host.getCurrentDirectory(); }, - getNewLine: function () { return host.getNewLine(); }, - getSourceFile: program.getSourceFile, - getSourceFiles: program.getSourceFiles, - writeFile: writeFileCallback || (function (fileName, data, writeByteOrderMark, onError) { return host.writeFile(fileName, data, writeByteOrderMark, onError); }) - }; - } - function getDiagnosticsProducingTypeChecker() { - return diagnosticsProducingTypeChecker || (diagnosticsProducingTypeChecker = ts.createTypeChecker(program, true)); - } - function getTypeChecker() { - return noDiagnosticsTypeChecker || (noDiagnosticsTypeChecker = ts.createTypeChecker(program, false)); - } - function emit(sourceFile, writeFileCallback, cancellationToken) { - var _this = this; - return runWithCancellationToken(function () { return emitWorker(_this, sourceFile, writeFileCallback, cancellationToken); }); - } - function emitWorker(program, sourceFile, writeFileCallback, cancellationToken) { - if (options.noEmitOnError && getPreEmitDiagnostics(program, undefined, cancellationToken).length > 0) { - return { diagnostics: [], sourceMaps: undefined, emitSkipped: true }; - } - var emitResolver = getDiagnosticsProducingTypeChecker().getEmitResolver((options.outFile || options.out) ? undefined : sourceFile); - var start = new Date().getTime(); - var emitResult = ts.emitFiles(emitResolver, getEmitHost(writeFileCallback), sourceFile); - ts.emitTime += new Date().getTime() - start; - return emitResult; - } - function getSourceFile(fileName) { - return filesByName.get(fileName) || filesByName.get(ts.getNormalizedAbsolutePath(fileName, host.getCurrentDirectory())); - } - function getDiagnosticsHelper(sourceFile, getDiagnostics, cancellationToken) { - if (sourceFile) { - return getDiagnostics(sourceFile, cancellationToken); - } - var allDiagnostics = []; - ts.forEach(program.getSourceFiles(), function (sourceFile) { - if (cancellationToken) { - cancellationToken.throwIfCancellationRequested(); - } - ts.addRange(allDiagnostics, getDiagnostics(sourceFile, cancellationToken)); - }); - return ts.sortAndDeduplicateDiagnostics(allDiagnostics); - } - function getSyntacticDiagnostics(sourceFile, cancellationToken) { - return getDiagnosticsHelper(sourceFile, getSyntacticDiagnosticsForFile, cancellationToken); - } - function getSemanticDiagnostics(sourceFile, cancellationToken) { - return getDiagnosticsHelper(sourceFile, getSemanticDiagnosticsForFile, cancellationToken); - } - function getDeclarationDiagnostics(sourceFile, cancellationToken) { - return getDiagnosticsHelper(sourceFile, getDeclarationDiagnosticsForFile, cancellationToken); - } - function getSyntacticDiagnosticsForFile(sourceFile, cancellationToken) { - return sourceFile.parseDiagnostics; - } - function runWithCancellationToken(func) { - try { - return func(); - } - catch (e) { - if (e instanceof ts.OperationCanceledException) { - noDiagnosticsTypeChecker = undefined; - diagnosticsProducingTypeChecker = undefined; - } - throw e; - } - } - function getSemanticDiagnosticsForFile(sourceFile, cancellationToken) { - return runWithCancellationToken(function () { - var typeChecker = getDiagnosticsProducingTypeChecker(); - ts.Debug.assert(!!sourceFile.bindDiagnostics); - var bindDiagnostics = sourceFile.bindDiagnostics; - var checkDiagnostics = typeChecker.getDiagnostics(sourceFile, cancellationToken); - var fileProcessingDiagnosticsInFile = fileProcessingDiagnostics.getDiagnostics(sourceFile.fileName); - var programDiagnosticsInFile = programDiagnostics.getDiagnostics(sourceFile.fileName); - return bindDiagnostics.concat(checkDiagnostics).concat(fileProcessingDiagnosticsInFile).concat(programDiagnosticsInFile); - }); - } - function getDeclarationDiagnosticsForFile(sourceFile, cancellationToken) { - return runWithCancellationToken(function () { - if (!ts.isDeclarationFile(sourceFile)) { - var resolver = getDiagnosticsProducingTypeChecker().getEmitResolver(sourceFile, cancellationToken); - var writeFile_1 = function () { }; - return ts.getDeclarationDiagnostics(getEmitHost(writeFile_1), resolver, sourceFile); - } - }); - } - function getOptionsDiagnostics() { - var allDiagnostics = []; - ts.addRange(allDiagnostics, fileProcessingDiagnostics.getGlobalDiagnostics()); - ts.addRange(allDiagnostics, programDiagnostics.getGlobalDiagnostics()); - return ts.sortAndDeduplicateDiagnostics(allDiagnostics); - } - function getGlobalDiagnostics() { - var allDiagnostics = []; - ts.addRange(allDiagnostics, getDiagnosticsProducingTypeChecker().getGlobalDiagnostics()); - return ts.sortAndDeduplicateDiagnostics(allDiagnostics); - } - function hasExtension(fileName) { - return ts.getBaseFileName(fileName).indexOf(".") >= 0; - } - function processRootFile(fileName, isDefaultLib) { - processSourceFile(ts.normalizePath(fileName), isDefaultLib); - } - function fileReferenceIsEqualTo(a, b) { - return a.fileName === b.fileName; - } - function moduleNameIsEqualTo(a, b) { - return a.text === b.text; - } - function collectExternalModuleReferences(file) { - if (file.imports) { - return; - } - var imports; - for (var _i = 0, _a = file.statements; _i < _a.length; _i++) { - var node = _a[_i]; - collect(node, true); - } - file.imports = imports || emptyArray; - function collect(node, allowRelativeModuleNames) { - switch (node.kind) { - case 222: - case 221: - case 228: - var moduleNameExpr = ts.getExternalModuleName(node); - if (!moduleNameExpr || moduleNameExpr.kind !== 9) { - break; - } - if (!moduleNameExpr.text) { - break; - } - if (allowRelativeModuleNames || !ts.isExternalModuleNameRelative(moduleNameExpr.text)) { - (imports || (imports = [])).push(moduleNameExpr); - } - break; - case 218: - if (node.name.kind === 9 && (node.flags & 2 || ts.isDeclarationFile(file))) { - ts.forEachChild(node.body, function (node) { - collect(node, false); - }); - } - break; - } - } - } - function processSourceFile(fileName, isDefaultLib, refFile, refPos, refEnd) { - var diagnosticArgument; - var diagnostic; - if (hasExtension(fileName)) { - if (!options.allowNonTsExtensions && !ts.forEach(ts.supportedExtensions, function (extension) { return ts.fileExtensionIs(host.getCanonicalFileName(fileName), extension); })) { - diagnostic = ts.Diagnostics.File_0_has_unsupported_extension_The_only_supported_extensions_are_1; - diagnosticArgument = [fileName, "'" + ts.supportedExtensions.join("', '") + "'"]; - } - else if (!findSourceFile(fileName, isDefaultLib, refFile, refPos, refEnd)) { - diagnostic = ts.Diagnostics.File_0_not_found; - diagnosticArgument = [fileName]; - } - else if (refFile && host.getCanonicalFileName(fileName) === host.getCanonicalFileName(refFile.fileName)) { - diagnostic = ts.Diagnostics.A_file_cannot_have_a_reference_to_itself; - diagnosticArgument = [fileName]; - } - } - else { - var nonTsFile = options.allowNonTsExtensions && findSourceFile(fileName, isDefaultLib, refFile, refPos, refEnd); - if (!nonTsFile) { - if (options.allowNonTsExtensions) { - diagnostic = ts.Diagnostics.File_0_not_found; - diagnosticArgument = [fileName]; - } - else if (!ts.forEach(ts.supportedExtensions, function (extension) { return findSourceFile(fileName + extension, isDefaultLib, refFile, refPos, refEnd); })) { - diagnostic = ts.Diagnostics.File_0_not_found; - fileName += ".ts"; - diagnosticArgument = [fileName]; - } - } - } - if (diagnostic) { - if (refFile !== undefined && refEnd !== undefined && refPos !== undefined) { - fileProcessingDiagnostics.add(ts.createFileDiagnostic.apply(void 0, [refFile, refPos, refEnd - refPos, diagnostic].concat(diagnosticArgument))); - } - else { - fileProcessingDiagnostics.add(ts.createCompilerDiagnostic.apply(void 0, [diagnostic].concat(diagnosticArgument))); - } - } - } - function findSourceFile(fileName, isDefaultLib, refFile, refPos, refEnd) { - if (filesByName.contains(fileName)) { - return getSourceFileFromCache(fileName, false); - } - var normalizedAbsolutePath = ts.getNormalizedAbsolutePath(fileName, host.getCurrentDirectory()); - if (filesByName.contains(normalizedAbsolutePath)) { - var file_1 = getSourceFileFromCache(normalizedAbsolutePath, true); - filesByName.set(fileName, file_1); - return file_1; - } - var file = host.getSourceFile(fileName, options.target, function (hostErrorMessage) { - if (refFile !== undefined && refPos !== undefined && refEnd !== undefined) { - fileProcessingDiagnostics.add(ts.createFileDiagnostic(refFile, refPos, refEnd - refPos, ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage)); - } - else { - fileProcessingDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage)); - } - }); - filesByName.set(fileName, file); - if (file) { - skipDefaultLib = skipDefaultLib || file.hasNoDefaultLib; - filesByName.set(normalizedAbsolutePath, file); - var basePath = ts.getDirectoryPath(fileName); - if (!options.noResolve) { - processReferencedFiles(file, basePath); - } - processImportedModules(file, basePath); - if (isDefaultLib) { - file.isDefaultLib = true; - files.unshift(file); - } - else { - files.push(file); - } - } - return file; - function getSourceFileFromCache(fileName, useAbsolutePath) { - var file = filesByName.get(fileName); - if (file && host.useCaseSensitiveFileNames()) { - var sourceFileName = useAbsolutePath ? ts.getNormalizedAbsolutePath(file.fileName, host.getCurrentDirectory()) : file.fileName; - if (ts.normalizeSlashes(fileName) !== ts.normalizeSlashes(sourceFileName)) { - if (refFile !== undefined && refPos !== undefined && refEnd !== undefined) { - fileProcessingDiagnostics.add(ts.createFileDiagnostic(refFile, refPos, refEnd - refPos, ts.Diagnostics.File_name_0_differs_from_already_included_file_name_1_only_in_casing, fileName, sourceFileName)); - } - else { - fileProcessingDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.File_name_0_differs_from_already_included_file_name_1_only_in_casing, fileName, sourceFileName)); - } - } - } - return file; - } - } - function processReferencedFiles(file, basePath) { - ts.forEach(file.referencedFiles, function (ref) { - var referencedFileName = resolveTripleslashReference(ref.fileName, file.fileName); - processSourceFile(referencedFileName, false, file, ref.pos, ref.end); - }); - } - function processImportedModules(file, basePath) { - collectExternalModuleReferences(file); - if (file.imports.length) { - file.resolvedModules = {}; - var moduleNames = ts.map(file.imports, function (name) { return name.text; }); - var resolutions = resolveModuleNamesWorker(moduleNames, file.fileName); - for (var i = 0; i < file.imports.length; ++i) { - var resolution = resolutions[i]; - ts.setResolvedModule(file, moduleNames[i], resolution); - if (resolution && !options.noResolve) { - var importedFile = findModuleSourceFile(resolution.resolvedFileName, file.imports[i]); - if (importedFile && resolution.isExternalLibraryImport) { - if (!ts.isExternalModule(importedFile)) { - var start_2 = ts.getTokenPosOfNode(file.imports[i], file); - fileProcessingDiagnostics.add(ts.createFileDiagnostic(file, start_2, file.imports[i].end - start_2, ts.Diagnostics.Exported_external_package_typings_file_0_is_not_a_module_Please_contact_the_package_author_to_update_the_package_definition, importedFile.fileName)); - } - else if (!ts.fileExtensionIs(importedFile.fileName, ".d.ts")) { - var start_3 = ts.getTokenPosOfNode(file.imports[i], file); - fileProcessingDiagnostics.add(ts.createFileDiagnostic(file, start_3, file.imports[i].end - start_3, ts.Diagnostics.Exported_external_package_typings_can_only_be_in_d_ts_files_Please_contact_the_package_author_to_update_the_package_definition)); - } - else if (importedFile.referencedFiles.length) { - var firstRef = importedFile.referencedFiles[0]; - fileProcessingDiagnostics.add(ts.createFileDiagnostic(importedFile, firstRef.pos, firstRef.end - firstRef.pos, ts.Diagnostics.Exported_external_package_typings_file_cannot_contain_tripleslash_references_Please_contact_the_package_author_to_update_the_package_definition)); - } - } - } - } - } - else { - file.resolvedModules = undefined; - } - return; - function findModuleSourceFile(fileName, nameLiteral) { - return findSourceFile(fileName, false, file, ts.skipTrivia(file.text, nameLiteral.pos), nameLiteral.end); - } - } - function computeCommonSourceDirectory(sourceFiles) { - var commonPathComponents; - var currentDirectory = host.getCurrentDirectory(); - ts.forEach(files, function (sourceFile) { - if (ts.isDeclarationFile(sourceFile)) { - return; - } - var sourcePathComponents = ts.getNormalizedPathComponents(sourceFile.fileName, currentDirectory); - sourcePathComponents.pop(); - if (!commonPathComponents) { - commonPathComponents = sourcePathComponents; - return; - } - for (var i = 0, n = Math.min(commonPathComponents.length, sourcePathComponents.length); i < n; i++) { - if (commonPathComponents[i] !== sourcePathComponents[i]) { - if (i === 0) { - programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_find_the_common_subdirectory_path_for_the_input_files)); - return; - } - commonPathComponents.length = i; - break; - } - } - if (sourcePathComponents.length < commonPathComponents.length) { - commonPathComponents.length = sourcePathComponents.length; - } - }); - return ts.getNormalizedPathFromPathComponents(commonPathComponents); - } - function checkSourceFilesBelongToPath(sourceFiles, rootDirectory) { - var allFilesBelongToPath = true; - if (sourceFiles) { - var currentDirectory = host.getCurrentDirectory(); - var absoluteRootDirectoryPath = host.getCanonicalFileName(ts.getNormalizedAbsolutePath(rootDirectory, currentDirectory)); - for (var _i = 0; _i < sourceFiles.length; _i++) { - var sourceFile = sourceFiles[_i]; - if (!ts.isDeclarationFile(sourceFile)) { - var absoluteSourceFilePath = host.getCanonicalFileName(ts.getNormalizedAbsolutePath(sourceFile.fileName, currentDirectory)); - if (absoluteSourceFilePath.indexOf(absoluteRootDirectoryPath) !== 0) { - programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.File_0_is_not_under_rootDir_1_rootDir_is_expected_to_contain_all_source_files, sourceFile.fileName, options.rootDir)); - allFilesBelongToPath = false; - } - } - } - } - return allFilesBelongToPath; - } - function verifyCompilerOptions() { - if (options.isolatedModules) { - if (options.declaration) { - programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "declaration", "isolatedModules")); - } - if (options.noEmitOnError) { - programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "noEmitOnError", "isolatedModules")); - } - if (options.out) { - programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "out", "isolatedModules")); - } - if (options.outFile) { - programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "outFile", "isolatedModules")); - } - } - if (options.inlineSourceMap) { - if (options.sourceMap) { - programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "sourceMap", "inlineSourceMap")); - } - if (options.mapRoot) { - programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "mapRoot", "inlineSourceMap")); - } - if (options.sourceRoot) { - programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "sourceRoot", "inlineSourceMap")); - } - } - if (options.inlineSources) { - if (!options.sourceMap && !options.inlineSourceMap) { - programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_inlineSources_can_only_be_used_when_either_option_inlineSourceMap_or_option_sourceMap_is_provided)); - } - } - if (options.out && options.outFile) { - programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "out", "outFile")); - } - if (!options.sourceMap && (options.mapRoot || options.sourceRoot)) { - if (options.mapRoot) { - programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "mapRoot", "sourceMap")); - } - if (options.sourceRoot) { - programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "sourceRoot", "sourceMap")); - } - return; - } - var languageVersion = options.target || 0; - var outFile = options.outFile || options.out; - var firstExternalModuleSourceFile = ts.forEach(files, function (f) { return ts.isExternalModule(f) ? f : undefined; }); - if (options.isolatedModules) { - if (!options.module && languageVersion < 2) { - 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; }); - if (firstNonExternalModuleSourceFile) { - var span = ts.getErrorSpanForNode(firstNonExternalModuleSourceFile, firstNonExternalModuleSourceFile); - programDiagnostics.add(ts.createFileDiagnostic(firstNonExternalModuleSourceFile, span.start, span.length, ts.Diagnostics.Cannot_compile_namespaces_when_the_isolatedModules_flag_is_provided)); - } - } - else if (firstExternalModuleSourceFile && languageVersion < 2 && !options.module) { - var span = ts.getErrorSpanForNode(firstExternalModuleSourceFile, firstExternalModuleSourceFile.externalModuleIndicator); - programDiagnostics.add(ts.createFileDiagnostic(firstExternalModuleSourceFile, span.start, span.length, ts.Diagnostics.Cannot_compile_modules_unless_the_module_flag_is_provided)); - } - if (options.module === 5 && languageVersion < 2) { - programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_compile_modules_into_es2015_when_targeting_ES5_or_lower)); - } - if (options.outDir || - options.sourceRoot || - (options.mapRoot && - (!outFile || firstExternalModuleSourceFile !== undefined))) { - if (options.rootDir && checkSourceFilesBelongToPath(files, options.rootDir)) { - commonSourceDirectory = ts.getNormalizedAbsolutePath(options.rootDir, host.getCurrentDirectory()); - } - else { - commonSourceDirectory = computeCommonSourceDirectory(files); - } - if (commonSourceDirectory && commonSourceDirectory[commonSourceDirectory.length - 1] !== ts.directorySeparator) { - commonSourceDirectory += ts.directorySeparator; - } - } - if (options.noEmit) { - if (options.out) { - programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "noEmit", "out")); - } - if (options.outFile) { - programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "noEmit", "outFile")); - } - if (options.outDir) { - programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "noEmit", "outDir")); - } - if (options.declaration) { - programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "noEmit", "declaration")); - } - } - if (options.emitDecoratorMetadata && - !options.experimentalDecorators) { - programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "emitDecoratorMetadata", "experimentalDecorators")); - } - } - } - ts.createProgram = createProgram; -})(ts || (ts = {})); -var ts; -(function (ts) { - var BreakpointResolver; - (function (BreakpointResolver) { - function spanInSourceFileAtLocation(sourceFile, position) { - if (sourceFile.flags & 8192) { - return undefined; - } - var tokenAtLocation = ts.getTokenAtPosition(sourceFile, position); - var lineOfPosition = sourceFile.getLineAndCharacterOfPosition(position).line; - if (sourceFile.getLineAndCharacterOfPosition(tokenAtLocation.getStart()).line > lineOfPosition) { - tokenAtLocation = ts.findPrecedingToken(tokenAtLocation.pos, sourceFile); - if (!tokenAtLocation || sourceFile.getLineAndCharacterOfPosition(tokenAtLocation.getEnd()).line !== lineOfPosition) { - return undefined; - } - } - if (ts.isInAmbientContext(tokenAtLocation)) { - return undefined; - } - return spanInNode(tokenAtLocation); - function textSpan(startNode, endNode) { - return ts.createTextSpanFromBounds(startNode.getStart(), (endNode || startNode).getEnd()); - } - function spanInNodeIfStartsOnSameLine(node, otherwiseOnNode) { - if (node && lineOfPosition === sourceFile.getLineAndCharacterOfPosition(node.getStart()).line) { - return spanInNode(node); - } - return spanInNode(otherwiseOnNode); - } - function spanInPreviousNode(node) { - return spanInNode(ts.findPrecedingToken(node.pos, sourceFile)); - } - function spanInNextNode(node) { - return spanInNode(ts.findNextToken(node, node.parent)); - } - function spanInNode(node) { - if (node) { - if (ts.isExpression(node)) { - if (node.parent.kind === 197) { - return spanInPreviousNode(node); - } - if (node.parent.kind === 199) { - return textSpan(node); - } - if (node.parent.kind === 181 && node.parent.operatorToken.kind === 24) { - return textSpan(node); - } - if (node.parent.kind === 174 && node.parent.body === node) { - return textSpan(node); - } - } - switch (node.kind) { - case 193: - return spanInVariableDeclaration(node.declarationList.declarations[0]); - case 211: - case 141: - case 140: - return spanInVariableDeclaration(node); - case 138: - return spanInParameterDeclaration(node); - case 213: - case 143: - case 142: - case 145: - case 146: - case 144: - case 173: - case 174: - return spanInFunctionDeclaration(node); - case 192: - if (ts.isFunctionBlock(node)) { - return spanInFunctionBlock(node); - } - case 219: - return spanInBlock(node); - case 244: - return spanInBlock(node.block); - case 195: - return textSpan(node.expression); - case 204: - return textSpan(node.getChildAt(0), node.expression); - case 198: - return textSpan(node, ts.findNextToken(node.expression, node)); - case 197: - return spanInNode(node.statement); - case 210: - return textSpan(node.getChildAt(0)); - case 196: - return textSpan(node, ts.findNextToken(node.expression, node)); - case 207: - return spanInNode(node.statement); - case 203: - case 202: - return textSpan(node.getChildAt(0), node.label); - case 199: - return spanInForStatement(node); - case 200: - case 201: - return textSpan(node, ts.findNextToken(node.expression, node)); - case 206: - return textSpan(node, ts.findNextToken(node.expression, node)); - case 241: - case 242: - return spanInNode(node.statements[0]); - case 209: - return spanInBlock(node.tryBlock); - case 208: - return textSpan(node, node.expression); - case 227: - return textSpan(node, node.expression); - case 221: - return textSpan(node, node.moduleReference); - case 222: - return textSpan(node, node.moduleSpecifier); - case 228: - return textSpan(node, node.moduleSpecifier); - case 218: - if (ts.getModuleInstanceState(node) !== 1) { - return undefined; - } - case 214: - case 217: - case 247: - case 168: - case 169: - return textSpan(node); - case 205: - return spanInNode(node.statement); - case 215: - case 216: - return undefined; - case 23: - 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 17: - return spanInOpenParenToken(node); - case 18: - return spanInCloseParenToken(node); - case 54: - return spanInColonToken(node); - case 27: - case 25: - return spanInGreaterThanOrLessThanToken(node); - case 104: - return spanInWhileKeyword(node); - case 80: - case 72: - case 85: - return spanInNextNode(node); - default: - if (node.parent.kind === 245 && node.parent.name === node) { - return spanInNode(node.parent.initializer); - } - if (node.parent.kind === 171 && node.parent.type === node) { - return spanInNode(node.parent.expression); - } - if (ts.isFunctionLike(node.parent) && node.parent.type === node) { - return spanInPreviousNode(node); - } - return spanInNode(node.parent); - } - } - function spanInVariableDeclaration(variableDeclaration) { - if (variableDeclaration.parent.parent.kind === 200 || - variableDeclaration.parent.parent.kind === 201) { - return spanInNode(variableDeclaration.parent.parent); - } - var isParentVariableStatement = variableDeclaration.parent.parent.kind === 193; - var isDeclarationOfForStatement = variableDeclaration.parent.parent.kind === 199 && ts.contains(variableDeclaration.parent.parent.initializer.declarations, variableDeclaration); - var declarations = isParentVariableStatement - ? variableDeclaration.parent.parent.declarationList.declarations - : isDeclarationOfForStatement - ? variableDeclaration.parent.parent.initializer.declarations - : undefined; - if (variableDeclaration.initializer || (variableDeclaration.flags & 1)) { - if (declarations && declarations[0] === variableDeclaration) { - if (isParentVariableStatement) { - return textSpan(variableDeclaration.parent, variableDeclaration); - } - else { - ts.Debug.assert(isDeclarationOfForStatement); - return textSpan(ts.findPrecedingToken(variableDeclaration.pos, sourceFile, variableDeclaration.parent), variableDeclaration); - } - } - else { - return textSpan(variableDeclaration); - } - } - else if (declarations && declarations[0] !== variableDeclaration) { - var indexOfCurrentDeclaration = ts.indexOf(declarations, variableDeclaration); - return spanInVariableDeclaration(declarations[indexOfCurrentDeclaration - 1]); - } - } - function canHaveSpanInParameterDeclaration(parameter) { - return !!parameter.initializer || parameter.dotDotDotToken !== undefined || - !!(parameter.flags & 16) || !!(parameter.flags & 32); - } - function spanInParameterDeclaration(parameter) { - if (canHaveSpanInParameterDeclaration(parameter)) { - return textSpan(parameter); - } - else { - var functionDeclaration = parameter.parent; - var indexOfParameter = ts.indexOf(functionDeclaration.parameters, parameter); - if (indexOfParameter) { - return spanInParameterDeclaration(functionDeclaration.parameters[indexOfParameter - 1]); - } - else { - return spanInNode(functionDeclaration.body); - } - } - } - function canFunctionHaveSpanInWholeDeclaration(functionDeclaration) { - return !!(functionDeclaration.flags & 1) || - (functionDeclaration.parent.kind === 214 && functionDeclaration.kind !== 144); - } - function spanInFunctionDeclaration(functionDeclaration) { - if (!functionDeclaration.body) { - return undefined; - } - if (canFunctionHaveSpanInWholeDeclaration(functionDeclaration)) { - return textSpan(functionDeclaration); - } - return spanInNode(functionDeclaration.body); - } - function spanInFunctionBlock(block) { - var nodeForSpanInBlock = block.statements.length ? block.statements[0] : block.getLastToken(); - if (canFunctionHaveSpanInWholeDeclaration(block.parent)) { - return spanInNodeIfStartsOnSameLine(block.parent, nodeForSpanInBlock); - } - return spanInNode(nodeForSpanInBlock); - } - function spanInBlock(block) { - switch (block.parent.kind) { - case 218: - if (ts.getModuleInstanceState(block.parent) !== 1) { - return undefined; - } - case 198: - case 196: - case 200: - case 201: - return spanInNodeIfStartsOnSameLine(block.parent, block.statements[0]); - case 199: - return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(block.pos, sourceFile, block.parent), block.statements[0]); - } - return spanInNode(block.statements[0]); - } - function spanInForStatement(forStatement) { - if (forStatement.initializer) { - if (forStatement.initializer.kind === 212) { - var variableDeclarationList = forStatement.initializer; - if (variableDeclarationList.declarations.length > 0) { - return spanInNode(variableDeclarationList.declarations[0]); - } - } - else { - return spanInNode(forStatement.initializer); - } - } - if (forStatement.condition) { - return textSpan(forStatement.condition); - } - if (forStatement.incrementor) { - return textSpan(forStatement.incrementor); - } - } - function spanInOpenBraceToken(node) { - switch (node.parent.kind) { - case 217: - var enumDeclaration = node.parent; - return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), enumDeclaration.members.length ? enumDeclaration.members[0] : enumDeclaration.getLastToken(sourceFile)); - case 214: - var classDeclaration = node.parent; - return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), classDeclaration.members.length ? classDeclaration.members[0] : classDeclaration.getLastToken(sourceFile)); - case 220: - return spanInNodeIfStartsOnSameLine(node.parent.parent, node.parent.clauses[0]); - } - return spanInNode(node.parent); - } - function spanInCloseBraceToken(node) { - switch (node.parent.kind) { - case 219: - if (ts.getModuleInstanceState(node.parent.parent) !== 1) { - return undefined; - } - case 217: - case 214: - return textSpan(node); - case 192: - if (ts.isFunctionBlock(node.parent)) { - return textSpan(node); - } - case 244: - return spanInNode(ts.lastOrUndefined(node.parent.statements)); - ; - case 220: - var caseBlock = node.parent; - var lastClause = ts.lastOrUndefined(caseBlock.clauses); - if (lastClause) { - return spanInNode(ts.lastOrUndefined(lastClause.statements)); - } - return undefined; - default: - return spanInNode(node.parent); - } - } - function spanInOpenParenToken(node) { - if (node.parent.kind === 197) { - return spanInPreviousNode(node); - } - return spanInNode(node.parent); - } - function spanInCloseParenToken(node) { - switch (node.parent.kind) { - case 173: - case 213: - case 174: - case 143: - case 142: - case 145: - case 146: - case 144: - case 198: - case 197: - case 199: - return spanInPreviousNode(node); - default: - return spanInNode(node.parent); - } - return spanInNode(node.parent); - } - function spanInColonToken(node) { - if (ts.isFunctionLike(node.parent) || node.parent.kind === 245) { - return spanInPreviousNode(node); - } - return spanInNode(node.parent); - } - function spanInGreaterThanOrLessThanToken(node) { - if (node.parent.kind === 171) { - return spanInNode(node.parent.expression); - } - return spanInNode(node.parent); - } - function spanInWhileKeyword(node) { - if (node.parent.kind === 197) { - return textSpan(node, ts.findNextToken(node.parent.expression, node.parent)); - } - return spanInNode(node.parent); - } - } - } - BreakpointResolver.spanInSourceFileAtLocation = spanInSourceFileAtLocation; - })(BreakpointResolver = ts.BreakpointResolver || (ts.BreakpointResolver = {})); -})(ts || (ts = {})); -var ts; -(function (ts) { - var OutliningElementsCollector; - (function (OutliningElementsCollector) { - function collectElements(sourceFile) { - var elements = []; - var collapseText = "..."; - function addOutliningSpan(hintSpanNode, startElement, endElement, autoCollapse) { - if (hintSpanNode && startElement && endElement) { - var span = { - textSpan: ts.createTextSpanFromBounds(startElement.pos, endElement.end), - hintSpan: ts.createTextSpanFromBounds(hintSpanNode.getStart(), hintSpanNode.end), - bannerText: collapseText, - autoCollapse: autoCollapse - }; - elements.push(span); - } - } - function addOutliningSpanComments(commentSpan, autoCollapse) { - if (commentSpan) { - var span = { - textSpan: ts.createTextSpanFromBounds(commentSpan.pos, commentSpan.end), - hintSpan: ts.createTextSpanFromBounds(commentSpan.pos, commentSpan.end), - bannerText: collapseText, - autoCollapse: autoCollapse - }; - elements.push(span); - } - } - function addOutliningForLeadingCommentsForNode(n) { - var comments = ts.getLeadingCommentRangesOfNode(n, sourceFile); - if (comments) { - var firstSingleLineCommentStart = -1; - var lastSingleLineCommentEnd = -1; - var isFirstSingleLineComment = true; - var singleLineCommentCount = 0; - for (var _i = 0; _i < comments.length; _i++) { - var currentComment = comments[_i]; - if (currentComment.kind === 2) { - if (isFirstSingleLineComment) { - firstSingleLineCommentStart = currentComment.pos; - } - isFirstSingleLineComment = false; - lastSingleLineCommentEnd = currentComment.end; - singleLineCommentCount++; - } - else if (currentComment.kind === 3) { - combineAndAddMultipleSingleLineComments(singleLineCommentCount, firstSingleLineCommentStart, lastSingleLineCommentEnd); - addOutliningSpanComments(currentComment, false); - singleLineCommentCount = 0; - lastSingleLineCommentEnd = -1; - isFirstSingleLineComment = true; - } - } - combineAndAddMultipleSingleLineComments(singleLineCommentCount, firstSingleLineCommentStart, lastSingleLineCommentEnd); - } - } - function combineAndAddMultipleSingleLineComments(count, start, end) { - if (count > 1) { - var multipleSingleLineComments = { - pos: start, - end: end, - kind: 2 - }; - addOutliningSpanComments(multipleSingleLineComments, false); - } - } - function autoCollapse(node) { - return ts.isFunctionBlock(node) && node.parent.kind !== 174; - } - var depth = 0; - var maxDepth = 20; - function walk(n) { - if (depth > maxDepth) { - return; - } - if (ts.isDeclaration(n)) { - addOutliningForLeadingCommentsForNode(n); - } - switch (n.kind) { - case 192: - if (!ts.isFunctionBlock(n)) { - var parent_7 = n.parent; - var openBrace = ts.findChildOfKind(n, 15, sourceFile); - var closeBrace = ts.findChildOfKind(n, 16, sourceFile); - if (parent_7.kind === 197 || - parent_7.kind === 200 || - parent_7.kind === 201 || - parent_7.kind === 199 || - parent_7.kind === 196 || - parent_7.kind === 198 || - parent_7.kind === 205 || - parent_7.kind === 244) { - addOutliningSpan(parent_7, openBrace, closeBrace, autoCollapse(n)); - break; - } - if (parent_7.kind === 209) { - var tryStatement = parent_7; - if (tryStatement.tryBlock === n) { - addOutliningSpan(parent_7, openBrace, closeBrace, autoCollapse(n)); - break; - } - else if (tryStatement.finallyBlock === n) { - var finallyKeyword = ts.findChildOfKind(tryStatement, 85, sourceFile); - if (finallyKeyword) { - addOutliningSpan(finallyKeyword, openBrace, closeBrace, autoCollapse(n)); - break; - } - } - } - var span = ts.createTextSpanFromBounds(n.getStart(), n.end); - elements.push({ - textSpan: span, - hintSpan: span, - bannerText: collapseText, - autoCollapse: autoCollapse(n) - }); - break; - } - case 219: { - var openBrace = ts.findChildOfKind(n, 15, sourceFile); - var closeBrace = ts.findChildOfKind(n, 16, sourceFile); - addOutliningSpan(n.parent, openBrace, closeBrace, autoCollapse(n)); - break; - } - case 214: - case 215: - case 217: - case 165: - case 220: { - var openBrace = ts.findChildOfKind(n, 15, sourceFile); - var closeBrace = ts.findChildOfKind(n, 16, sourceFile); - addOutliningSpan(n, openBrace, closeBrace, autoCollapse(n)); - break; - } - case 164: - var openBracket = ts.findChildOfKind(n, 19, sourceFile); - var closeBracket = ts.findChildOfKind(n, 20, sourceFile); - addOutliningSpan(n, openBracket, closeBracket, autoCollapse(n)); - break; - } - depth++; - ts.forEachChild(n, walk); - depth--; - } - walk(sourceFile); - return elements; - } - OutliningElementsCollector.collectElements = collectElements; - })(OutliningElementsCollector = ts.OutliningElementsCollector || (ts.OutliningElementsCollector = {})); -})(ts || (ts = {})); -var ts; -(function (ts) { - var NavigateTo; - (function (NavigateTo) { - function getNavigateToItems(program, cancellationToken, searchValue, maxResultCount) { - var patternMatcher = ts.createPatternMatcher(searchValue); - var rawItems = []; - ts.forEach(program.getSourceFiles(), function (sourceFile) { - cancellationToken.throwIfCancellationRequested(); - var nameToDeclarations = sourceFile.getNamedDeclarations(); - for (var name_29 in nameToDeclarations) { - var declarations = ts.getProperty(nameToDeclarations, name_29); - if (declarations) { - var matches = patternMatcher.getMatchesForLastSegmentOfPattern(name_29); - if (!matches) { - continue; - } - for (var _i = 0; _i < declarations.length; _i++) { - var declaration = declarations[_i]; - if (patternMatcher.patternContainsDots) { - var containers = getContainers(declaration); - if (!containers) { - return undefined; - } - matches = patternMatcher.getMatches(containers, name_29); - if (!matches) { - continue; - } - } - var fileName = sourceFile.fileName; - var matchKind = bestMatchKind(matches); - rawItems.push({ name: name_29, fileName: fileName, matchKind: matchKind, isCaseSensitive: allMatchesAreCaseSensitive(matches), declaration: declaration }); - } - } - } - }); - rawItems.sort(compareNavigateToItems); - if (maxResultCount !== undefined) { - rawItems = rawItems.slice(0, maxResultCount); - } - var items = ts.map(rawItems, createNavigateToItem); - return items; - function allMatchesAreCaseSensitive(matches) { - ts.Debug.assert(matches.length > 0); - for (var _i = 0; _i < matches.length; _i++) { - var match = matches[_i]; - if (!match.isCaseSensitive) { - return false; - } - } - return true; - } - function getTextOfIdentifierOrLiteral(node) { - if (node) { - if (node.kind === 69 || - node.kind === 9 || - node.kind === 8) { - return node.text; - } - } - return undefined; - } - function tryAddSingleDeclarationName(declaration, containers) { - if (declaration && declaration.name) { - var text = getTextOfIdentifierOrLiteral(declaration.name); - if (text !== undefined) { - containers.unshift(text); - } - else if (declaration.name.kind === 136) { - return tryAddComputedPropertyName(declaration.name.expression, containers, true); - } - else { - return false; - } - } - return true; - } - function tryAddComputedPropertyName(expression, containers, includeLastPortion) { - var text = getTextOfIdentifierOrLiteral(expression); - if (text !== undefined) { - if (includeLastPortion) { - containers.unshift(text); - } - return true; - } - if (expression.kind === 166) { - var propertyAccess = expression; - if (includeLastPortion) { - containers.unshift(propertyAccess.name.text); - } - return tryAddComputedPropertyName(propertyAccess.expression, containers, true); - } - return false; - } - function getContainers(declaration) { - var containers = []; - if (declaration.name.kind === 136) { - if (!tryAddComputedPropertyName(declaration.name.expression, containers, false)) { - return undefined; - } - } - declaration = ts.getContainerNode(declaration); - while (declaration) { - if (!tryAddSingleDeclarationName(declaration, containers)) { - return undefined; - } - declaration = ts.getContainerNode(declaration); - } - return containers; - } - function bestMatchKind(matches) { - ts.Debug.assert(matches.length > 0); - var bestMatchKind = ts.PatternMatchKind.camelCase; - for (var _i = 0; _i < matches.length; _i++) { - var match = matches[_i]; - var kind = match.kind; - if (kind < bestMatchKind) { - bestMatchKind = kind; - } - } - return bestMatchKind; - } - var baseSensitivity = { sensitivity: "base" }; - function compareNavigateToItems(i1, i2) { - return i1.matchKind - i2.matchKind || - i1.name.localeCompare(i2.name, undefined, baseSensitivity) || - i1.name.localeCompare(i2.name); - } - function createNavigateToItem(rawItem) { - var declaration = rawItem.declaration; - var container = ts.getContainerNode(declaration); - return { - name: rawItem.name, - kind: ts.getNodeKind(declaration), - kindModifiers: ts.getNodeModifiers(declaration), - matchKind: ts.PatternMatchKind[rawItem.matchKind], - isCaseSensitive: rawItem.isCaseSensitive, - fileName: rawItem.fileName, - textSpan: ts.createTextSpanFromBounds(declaration.getStart(), declaration.getEnd()), - containerName: container && container.name ? container.name.text : "", - containerKind: container && container.name ? ts.getNodeKind(container) : "" - }; - } - } - NavigateTo.getNavigateToItems = getNavigateToItems; - })(NavigateTo = ts.NavigateTo || (ts.NavigateTo = {})); -})(ts || (ts = {})); -var ts; -(function (ts) { - var NavigationBar; - (function (NavigationBar) { - function getNavigationBarItems(sourceFile) { - var hasGlobalNode = false; - return getItemsWorker(getTopLevelNodes(sourceFile), createTopLevelItem); - function getIndent(node) { - var indent = hasGlobalNode ? 1 : 0; - var current = node.parent; - while (current) { - switch (current.kind) { - case 218: - do { - current = current.parent; - } while (current.kind === 218); - case 214: - case 217: - case 215: - case 213: - indent++; - } - current = current.parent; - } - return indent; - } - function getChildNodes(nodes) { - var childNodes = []; - function visit(node) { - switch (node.kind) { - case 193: - ts.forEach(node.declarationList.declarations, visit); - break; - case 161: - case 162: - ts.forEach(node.elements, visit); - break; - case 228: - if (node.exportClause) { - ts.forEach(node.exportClause.elements, visit); - } - break; - case 222: - var importClause = node.importClause; - if (importClause) { - if (importClause.name) { - childNodes.push(importClause); - } - if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 224) { - childNodes.push(importClause.namedBindings); - } - else { - ts.forEach(importClause.namedBindings.elements, visit); - } - } - } - break; - case 163: - case 211: - if (ts.isBindingPattern(node.name)) { - visit(node.name); - break; - } - case 214: - case 217: - case 215: - case 218: - case 213: - case 221: - case 226: - case 230: - childNodes.push(node); - break; - } - } - ts.forEach(nodes, visit); - return sortNodes(childNodes); - } - function getTopLevelNodes(node) { - var topLevelNodes = []; - topLevelNodes.push(node); - addTopLevelNodes(node.statements, topLevelNodes); - return topLevelNodes; - } - function sortNodes(nodes) { - return nodes.slice(0).sort(function (n1, n2) { - if (n1.name && n2.name) { - return ts.getPropertyNameForPropertyNameNode(n1.name).localeCompare(ts.getPropertyNameForPropertyNameNode(n2.name)); - } - else if (n1.name) { - return 1; - } - else if (n2.name) { - return -1; - } - else { - return n1.kind - n2.kind; - } - }); - } - function addTopLevelNodes(nodes, topLevelNodes) { - nodes = sortNodes(nodes); - for (var _i = 0; _i < nodes.length; _i++) { - var node = nodes[_i]; - switch (node.kind) { - case 214: - case 217: - case 215: - topLevelNodes.push(node); - break; - case 218: - var moduleDeclaration = node; - topLevelNodes.push(node); - addTopLevelNodes(getInnermostModule(moduleDeclaration).body.statements, topLevelNodes); - break; - case 213: - var functionDeclaration = node; - if (isTopLevelFunctionDeclaration(functionDeclaration)) { - topLevelNodes.push(node); - addTopLevelNodes(functionDeclaration.body.statements, topLevelNodes); - } - break; - } - } - } - function isTopLevelFunctionDeclaration(functionDeclaration) { - if (functionDeclaration.kind === 213) { - if (functionDeclaration.body && functionDeclaration.body.kind === 192) { - if (ts.forEach(functionDeclaration.body.statements, function (s) { return s.kind === 213 && !isEmpty(s.name.text); })) { - return true; - } - if (!ts.isFunctionBlock(functionDeclaration.parent)) { - return true; - } - } - } - return false; - } - function getItemsWorker(nodes, createItem) { - var items = []; - var keyToItem = {}; - for (var _i = 0; _i < nodes.length; _i++) { - var child = nodes[_i]; - var item = createItem(child); - if (item !== undefined) { - if (item.text.length > 0) { - var key = item.text + "-" + item.kind + "-" + item.indent; - var itemWithSameName = keyToItem[key]; - if (itemWithSameName) { - merge(itemWithSameName, item); - } - else { - keyToItem[key] = item; - items.push(item); - } - } - } - } - return items; - } - function merge(target, source) { - ts.addRange(target.spans, source.spans); - if (source.childItems) { - if (!target.childItems) { - target.childItems = []; - } - outer: for (var _i = 0, _a = source.childItems; _i < _a.length; _i++) { - var sourceChild = _a[_i]; - for (var _b = 0, _c = target.childItems; _b < _c.length; _b++) { - var targetChild = _c[_b]; - if (targetChild.text === sourceChild.text && targetChild.kind === sourceChild.kind) { - merge(targetChild, sourceChild); - continue outer; - } - } - target.childItems.push(sourceChild); - } - } - } - function createChildItem(node) { - switch (node.kind) { - case 138: - if (ts.isBindingPattern(node.name)) { - break; - } - if ((node.flags & 2035) === 0) { - return undefined; - } - return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberVariableElement); - case 143: - case 142: - return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberFunctionElement); - case 145: - return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberGetAccessorElement); - case 146: - return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberSetAccessorElement); - case 149: - return createItem(node, "[]", ts.ScriptElementKind.indexSignatureElement); - case 247: - return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberVariableElement); - case 147: - return createItem(node, "()", ts.ScriptElementKind.callSignatureElement); - case 148: - return createItem(node, "new()", ts.ScriptElementKind.constructSignatureElement); - case 141: - case 140: - return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberVariableElement); - case 213: - return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.functionElement); - case 211: - case 163: - var variableDeclarationNode; - var name_30; - if (node.kind === 163) { - name_30 = node.name; - variableDeclarationNode = node; - while (variableDeclarationNode && variableDeclarationNode.kind !== 211) { - variableDeclarationNode = variableDeclarationNode.parent; - } - ts.Debug.assert(variableDeclarationNode !== undefined); - } - else { - ts.Debug.assert(!ts.isBindingPattern(node.name)); - variableDeclarationNode = node; - name_30 = node.name; - } - if (ts.isConst(variableDeclarationNode)) { - return createItem(node, getTextOfNode(name_30), ts.ScriptElementKind.constElement); - } - else if (ts.isLet(variableDeclarationNode)) { - return createItem(node, getTextOfNode(name_30), ts.ScriptElementKind.letElement); - } - else { - return createItem(node, getTextOfNode(name_30), ts.ScriptElementKind.variableElement); - } - case 144: - return createItem(node, "constructor", ts.ScriptElementKind.constructorImplementationElement); - case 230: - case 226: - case 221: - case 223: - case 224: - return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.alias); - } - return undefined; - function createItem(node, name, scriptElementKind) { - return getNavigationBarItem(name, scriptElementKind, ts.getNodeModifiers(node), [getNodeSpan(node)]); - } - } - function isEmpty(text) { - return !text || text.trim() === ""; - } - function getNavigationBarItem(text, kind, kindModifiers, spans, childItems, indent) { - if (childItems === void 0) { childItems = []; } - if (indent === void 0) { indent = 0; } - if (isEmpty(text)) { - return undefined; - } - return { - text: text, - kind: kind, - kindModifiers: kindModifiers, - spans: spans, - childItems: childItems, - indent: indent, - bolded: false, - grayed: false - }; - } - function createTopLevelItem(node) { - switch (node.kind) { - case 248: - return createSourceFileItem(node); - case 214: - return createClassItem(node); - case 217: - return createEnumItem(node); - case 215: - return createIterfaceItem(node); - case 218: - return createModuleItem(node); - case 213: - return createFunctionItem(node); - } - return undefined; - function getModuleName(moduleDeclaration) { - if (moduleDeclaration.name.kind === 9) { - return getTextOfNode(moduleDeclaration.name); - } - var result = []; - result.push(moduleDeclaration.name.text); - while (moduleDeclaration.body && moduleDeclaration.body.kind === 218) { - moduleDeclaration = moduleDeclaration.body; - result.push(moduleDeclaration.name.text); - } - return result.join("."); - } - function createModuleItem(node) { - var moduleName = getModuleName(node); - var childItems = getItemsWorker(getChildNodes(getInnermostModule(node).body.statements), createChildItem); - return getNavigationBarItem(moduleName, ts.ScriptElementKind.moduleElement, ts.getNodeModifiers(node), [getNodeSpan(node)], childItems, getIndent(node)); - } - function createFunctionItem(node) { - if (node.body && node.body.kind === 192) { - var childItems = getItemsWorker(sortNodes(node.body.statements), createChildItem); - return getNavigationBarItem(!node.name ? "default" : node.name.text, ts.ScriptElementKind.functionElement, ts.getNodeModifiers(node), [getNodeSpan(node)], childItems, getIndent(node)); - } - return undefined; - } - function createSourceFileItem(node) { - var childItems = getItemsWorker(getChildNodes(node.statements), createChildItem); - if (childItems === undefined || childItems.length === 0) { - return undefined; - } - hasGlobalNode = true; - var rootName = ts.isExternalModule(node) - ? "\"" + ts.escapeString(ts.getBaseFileName(ts.removeFileExtension(ts.normalizePath(node.fileName)))) + "\"" - : ""; - return getNavigationBarItem(rootName, ts.ScriptElementKind.moduleElement, ts.ScriptElementKindModifier.none, [getNodeSpan(node)], childItems); - } - function createClassItem(node) { - var childItems; - if (node.members) { - var constructor = ts.forEach(node.members, function (member) { - return member.kind === 144 && member; - }); - var nodes = removeDynamicallyNamedProperties(node); - if (constructor) { - ts.addRange(nodes, ts.filter(constructor.parameters, function (p) { return !ts.isBindingPattern(p.name); })); - } - childItems = getItemsWorker(sortNodes(nodes), createChildItem); - } - var nodeName = !node.name ? "default" : node.name.text; - return getNavigationBarItem(nodeName, ts.ScriptElementKind.classElement, ts.getNodeModifiers(node), [getNodeSpan(node)], childItems, getIndent(node)); - } - function createEnumItem(node) { - var childItems = getItemsWorker(sortNodes(removeComputedProperties(node)), createChildItem); - return getNavigationBarItem(node.name.text, ts.ScriptElementKind.enumElement, ts.getNodeModifiers(node), [getNodeSpan(node)], childItems, getIndent(node)); - } - function createIterfaceItem(node) { - var childItems = getItemsWorker(sortNodes(removeDynamicallyNamedProperties(node)), createChildItem); - return getNavigationBarItem(node.name.text, ts.ScriptElementKind.interfaceElement, ts.getNodeModifiers(node), [getNodeSpan(node)], childItems, getIndent(node)); - } - } - function removeComputedProperties(node) { - return ts.filter(node.members, function (member) { return member.name === undefined || member.name.kind !== 136; }); - } - function removeDynamicallyNamedProperties(node) { - return ts.filter(node.members, function (member) { return !ts.hasDynamicName(member); }); - } - function getInnermostModule(node) { - while (node.body.kind === 218) { - node = node.body; - } - return node; - } - function getNodeSpan(node) { - return node.kind === 248 - ? ts.createTextSpanFromBounds(node.getFullStart(), node.getEnd()) - : ts.createTextSpanFromBounds(node.getStart(), node.getEnd()); - } - function getTextOfNode(node) { - return ts.getTextOfNodeFromSourceText(sourceFile.text, node); - } - } - NavigationBar.getNavigationBarItems = getNavigationBarItems; - })(NavigationBar = ts.NavigationBar || (ts.NavigationBar = {})); -})(ts || (ts = {})); -var ts; -(function (ts) { - (function (PatternMatchKind) { - PatternMatchKind[PatternMatchKind["exact"] = 0] = "exact"; - PatternMatchKind[PatternMatchKind["prefix"] = 1] = "prefix"; - PatternMatchKind[PatternMatchKind["substring"] = 2] = "substring"; - PatternMatchKind[PatternMatchKind["camelCase"] = 3] = "camelCase"; - })(ts.PatternMatchKind || (ts.PatternMatchKind = {})); - var PatternMatchKind = ts.PatternMatchKind; - function createPatternMatch(kind, punctuationStripped, isCaseSensitive, camelCaseWeight) { - return { - kind: kind, - punctuationStripped: punctuationStripped, - isCaseSensitive: isCaseSensitive, - camelCaseWeight: camelCaseWeight - }; - } - function createPatternMatcher(pattern) { - var stringToWordSpans = {}; - pattern = pattern.trim(); - var fullPatternSegment = createSegment(pattern); - var dotSeparatedSegments = pattern.split(".").map(function (p) { return createSegment(p.trim()); }); - var invalidPattern = dotSeparatedSegments.length === 0 || ts.forEach(dotSeparatedSegments, segmentIsInvalid); - return { - getMatches: getMatches, - getMatchesForLastSegmentOfPattern: getMatchesForLastSegmentOfPattern, - patternContainsDots: dotSeparatedSegments.length > 1 - }; - function skipMatch(candidate) { - return invalidPattern || !candidate; - } - function getMatchesForLastSegmentOfPattern(candidate) { - if (skipMatch(candidate)) { - return undefined; - } - return matchSegment(candidate, ts.lastOrUndefined(dotSeparatedSegments)); - } - function getMatches(candidateContainers, candidate) { - if (skipMatch(candidate)) { - return undefined; - } - var candidateMatch = matchSegment(candidate, ts.lastOrUndefined(dotSeparatedSegments)); - if (!candidateMatch) { - return undefined; - } - candidateContainers = candidateContainers || []; - if (dotSeparatedSegments.length - 1 > candidateContainers.length) { - return undefined; - } - var totalMatch = candidateMatch; - for (var i = dotSeparatedSegments.length - 2, j = candidateContainers.length - 1; i >= 0; i--, j--) { - var segment = dotSeparatedSegments[i]; - var containerName = candidateContainers[j]; - var containerMatch = matchSegment(containerName, segment); - if (!containerMatch) { - return undefined; - } - ts.addRange(totalMatch, containerMatch); - } - return totalMatch; - } - function getWordSpans(word) { - if (!ts.hasProperty(stringToWordSpans, word)) { - stringToWordSpans[word] = breakIntoWordSpans(word); - } - return stringToWordSpans[word]; - } - function matchTextChunk(candidate, chunk, punctuationStripped) { - var index = indexOfIgnoringCase(candidate, chunk.textLowerCase); - if (index === 0) { - if (chunk.text.length === candidate.length) { - return createPatternMatch(PatternMatchKind.exact, punctuationStripped, candidate === chunk.text); - } - else { - return createPatternMatch(PatternMatchKind.prefix, punctuationStripped, startsWith(candidate, chunk.text)); - } - } - var isLowercase = chunk.isLowerCase; - if (isLowercase) { - if (index > 0) { - var wordSpans = getWordSpans(candidate); - for (var _i = 0; _i < wordSpans.length; _i++) { - var span = wordSpans[_i]; - if (partStartsWith(candidate, span, chunk.text, true)) { - return createPatternMatch(PatternMatchKind.substring, punctuationStripped, partStartsWith(candidate, span, chunk.text, false)); - } - } - } - } - else { - if (candidate.indexOf(chunk.text) > 0) { - return createPatternMatch(PatternMatchKind.substring, punctuationStripped, true); - } - } - if (!isLowercase) { - if (chunk.characterSpans.length > 0) { - var candidateParts = getWordSpans(candidate); - var camelCaseWeight = tryCamelCaseMatch(candidate, candidateParts, chunk, false); - if (camelCaseWeight !== undefined) { - return createPatternMatch(PatternMatchKind.camelCase, punctuationStripped, true, camelCaseWeight); - } - camelCaseWeight = tryCamelCaseMatch(candidate, candidateParts, chunk, true); - if (camelCaseWeight !== undefined) { - return createPatternMatch(PatternMatchKind.camelCase, punctuationStripped, false, camelCaseWeight); - } - } - } - if (isLowercase) { - if (chunk.text.length < candidate.length) { - if (index > 0 && isUpperCaseLetter(candidate.charCodeAt(index))) { - return createPatternMatch(PatternMatchKind.substring, punctuationStripped, false); - } - } - } - return undefined; - } - function containsSpaceOrAsterisk(text) { - for (var i = 0; i < text.length; i++) { - var ch = text.charCodeAt(i); - if (ch === 32 || ch === 42) { - return true; - } - } - return false; - } - function matchSegment(candidate, segment) { - if (!containsSpaceOrAsterisk(segment.totalTextChunk.text)) { - var match = matchTextChunk(candidate, segment.totalTextChunk, false); - if (match) { - return [match]; - } - } - var subWordTextChunks = segment.subWordTextChunks; - var matches = undefined; - for (var _i = 0; _i < subWordTextChunks.length; _i++) { - var subWordTextChunk = subWordTextChunks[_i]; - var result = matchTextChunk(candidate, subWordTextChunk, true); - if (!result) { - return undefined; - } - matches = matches || []; - matches.push(result); - } - return matches; - } - function partStartsWith(candidate, candidateSpan, pattern, ignoreCase, patternSpan) { - var patternPartStart = patternSpan ? patternSpan.start : 0; - var patternPartLength = patternSpan ? patternSpan.length : pattern.length; - if (patternPartLength > candidateSpan.length) { - return false; - } - if (ignoreCase) { - for (var i = 0; i < patternPartLength; i++) { - var ch1 = pattern.charCodeAt(patternPartStart + i); - var ch2 = candidate.charCodeAt(candidateSpan.start + i); - if (toLowerCase(ch1) !== toLowerCase(ch2)) { - return false; - } - } - } - else { - for (var i = 0; i < patternPartLength; i++) { - var ch1 = pattern.charCodeAt(patternPartStart + i); - var ch2 = candidate.charCodeAt(candidateSpan.start + i); - if (ch1 !== ch2) { - return false; - } - } - } - return true; - } - function tryCamelCaseMatch(candidate, candidateParts, chunk, ignoreCase) { - var chunkCharacterSpans = chunk.characterSpans; - var currentCandidate = 0; - var currentChunkSpan = 0; - var firstMatch = undefined; - var contiguous = undefined; - while (true) { - if (currentChunkSpan === chunkCharacterSpans.length) { - var weight = 0; - if (contiguous) { - weight += 1; - } - if (firstMatch === 0) { - weight += 2; - } - return weight; - } - else if (currentCandidate === candidateParts.length) { - return undefined; - } - var candidatePart = candidateParts[currentCandidate]; - var gotOneMatchThisCandidate = false; - for (; currentChunkSpan < chunkCharacterSpans.length; currentChunkSpan++) { - var chunkCharacterSpan = chunkCharacterSpans[currentChunkSpan]; - if (gotOneMatchThisCandidate) { - if (!isUpperCaseLetter(chunk.text.charCodeAt(chunkCharacterSpans[currentChunkSpan - 1].start)) || - !isUpperCaseLetter(chunk.text.charCodeAt(chunkCharacterSpans[currentChunkSpan].start))) { - break; - } - } - if (!partStartsWith(candidate, candidatePart, chunk.text, ignoreCase, chunkCharacterSpan)) { - break; - } - gotOneMatchThisCandidate = true; - firstMatch = firstMatch === undefined ? currentCandidate : firstMatch; - contiguous = contiguous === undefined ? true : contiguous; - candidatePart = ts.createTextSpan(candidatePart.start + chunkCharacterSpan.length, candidatePart.length - chunkCharacterSpan.length); - } - if (!gotOneMatchThisCandidate && contiguous !== undefined) { - contiguous = false; - } - currentCandidate++; - } - } - } - ts.createPatternMatcher = createPatternMatcher; - function patternMatchCompareTo(match1, match2) { - return compareType(match1, match2) || - compareCamelCase(match1, match2) || - compareCase(match1, match2) || - comparePunctuation(match1, match2); - } - function comparePunctuation(result1, result2) { - if (result1.punctuationStripped !== result2.punctuationStripped) { - return result1.punctuationStripped ? 1 : -1; - } - return 0; - } - function compareCase(result1, result2) { - if (result1.isCaseSensitive !== result2.isCaseSensitive) { - return result1.isCaseSensitive ? -1 : 1; - } - return 0; - } - function compareType(result1, result2) { - return result1.kind - result2.kind; - } - function compareCamelCase(result1, result2) { - if (result1.kind === PatternMatchKind.camelCase && result2.kind === PatternMatchKind.camelCase) { - return result2.camelCaseWeight - result1.camelCaseWeight; - } - return 0; - } - function createSegment(text) { - return { - totalTextChunk: createTextChunk(text), - subWordTextChunks: breakPatternIntoTextChunks(text) - }; - } - function segmentIsInvalid(segment) { - return segment.subWordTextChunks.length === 0; - } - function isUpperCaseLetter(ch) { - if (ch >= 65 && ch <= 90) { - return true; - } - if (ch < 127 || !ts.isUnicodeIdentifierStart(ch, 2)) { - return false; - } - var str = String.fromCharCode(ch); - return str === str.toUpperCase(); - } - function isLowerCaseLetter(ch) { - if (ch >= 97 && ch <= 122) { - return true; - } - if (ch < 127 || !ts.isUnicodeIdentifierStart(ch, 2)) { - return false; - } - var str = String.fromCharCode(ch); - return str === str.toLowerCase(); - } - function containsUpperCaseLetter(string) { - for (var i = 0, n = string.length; i < n; i++) { - if (isUpperCaseLetter(string.charCodeAt(i))) { - return true; - } - } - return false; - } - function startsWith(string, search) { - for (var i = 0, n = search.length; i < n; i++) { - if (string.charCodeAt(i) !== search.charCodeAt(i)) { - return false; - } - } - return true; - } - function indexOfIgnoringCase(string, value) { - for (var i = 0, n = string.length - value.length; i <= n; i++) { - if (startsWithIgnoringCase(string, value, i)) { - return i; - } - } - return -1; - } - function startsWithIgnoringCase(string, value, start) { - for (var i = 0, n = value.length; i < n; i++) { - var ch1 = toLowerCase(string.charCodeAt(i + start)); - var ch2 = value.charCodeAt(i); - if (ch1 !== ch2) { - return false; - } - } - return true; - } - function toLowerCase(ch) { - if (ch >= 65 && ch <= 90) { - return 97 + (ch - 65); - } - if (ch < 127) { - return ch; - } - return String.fromCharCode(ch).toLowerCase().charCodeAt(0); - } - function isDigit(ch) { - return ch >= 48 && ch <= 57; - } - function isWordChar(ch) { - return isUpperCaseLetter(ch) || isLowerCaseLetter(ch) || isDigit(ch) || ch === 95 || ch === 36; - } - function breakPatternIntoTextChunks(pattern) { - var result = []; - var wordStart = 0; - var wordLength = 0; - for (var i = 0; i < pattern.length; i++) { - var ch = pattern.charCodeAt(i); - if (isWordChar(ch)) { - if (wordLength++ === 0) { - wordStart = i; - } - } - else { - if (wordLength > 0) { - result.push(createTextChunk(pattern.substr(wordStart, wordLength))); - wordLength = 0; - } - } - } - if (wordLength > 0) { - result.push(createTextChunk(pattern.substr(wordStart, wordLength))); - } - return result; - } - function createTextChunk(text) { - var textLowerCase = text.toLowerCase(); - return { - text: text, - textLowerCase: textLowerCase, - isLowerCase: text === textLowerCase, - characterSpans: breakIntoCharacterSpans(text) - }; - } - function breakIntoCharacterSpans(identifier) { - return breakIntoSpans(identifier, false); - } - ts.breakIntoCharacterSpans = breakIntoCharacterSpans; - function breakIntoWordSpans(identifier) { - return breakIntoSpans(identifier, true); - } - ts.breakIntoWordSpans = breakIntoWordSpans; - function breakIntoSpans(identifier, word) { - var result = []; - var wordStart = 0; - for (var i = 1, n = identifier.length; i < n; i++) { - var lastIsDigit = isDigit(identifier.charCodeAt(i - 1)); - var currentIsDigit = isDigit(identifier.charCodeAt(i)); - var hasTransitionFromLowerToUpper = transitionFromLowerToUpper(identifier, word, i); - var hasTransitionFromUpperToLower = transitionFromUpperToLower(identifier, word, i, wordStart); - if (charIsPunctuation(identifier.charCodeAt(i - 1)) || - charIsPunctuation(identifier.charCodeAt(i)) || - lastIsDigit !== currentIsDigit || - hasTransitionFromLowerToUpper || - hasTransitionFromUpperToLower) { - if (!isAllPunctuation(identifier, wordStart, i)) { - result.push(ts.createTextSpan(wordStart, i - wordStart)); - } - wordStart = i; - } - } - if (!isAllPunctuation(identifier, wordStart, identifier.length)) { - result.push(ts.createTextSpan(wordStart, identifier.length - wordStart)); - } - return result; - } - function charIsPunctuation(ch) { - switch (ch) { - case 33: - case 34: - case 35: - case 37: - case 38: - case 39: - case 40: - case 41: - case 42: - case 44: - case 45: - case 46: - case 47: - case 58: - case 59: - case 63: - case 64: - case 91: - case 92: - case 93: - case 95: - case 123: - case 125: - return true; - } - return false; - } - function isAllPunctuation(identifier, start, end) { - for (var i = start; i < end; i++) { - var ch = identifier.charCodeAt(i); - if (!charIsPunctuation(ch) || ch === 95 || ch === 36) { - return false; - } - } - return true; - } - function transitionFromUpperToLower(identifier, word, index, wordStart) { - if (word) { - if (index !== wordStart && - index + 1 < identifier.length) { - var currentIsUpper = isUpperCaseLetter(identifier.charCodeAt(index)); - var nextIsLower = isLowerCaseLetter(identifier.charCodeAt(index + 1)); - if (currentIsUpper && nextIsLower) { - for (var i = wordStart; i < index; i++) { - if (!isUpperCaseLetter(identifier.charCodeAt(i))) { - return false; - } - } - return true; - } - } - } - return false; - } - function transitionFromLowerToUpper(identifier, word, index) { - var lastIsUpper = isUpperCaseLetter(identifier.charCodeAt(index - 1)); - var currentIsUpper = isUpperCaseLetter(identifier.charCodeAt(index)); - var transition = word - ? (currentIsUpper && !lastIsUpper) - : currentIsUpper; - return transition; - } -})(ts || (ts = {})); -var ts; -(function (ts) { - var SignatureHelp; - (function (SignatureHelp) { - var emptyArray = []; - function getSignatureHelpItems(program, sourceFile, position, cancellationToken) { - var typeChecker = program.getTypeChecker(); - var startingToken = ts.findTokenOnLeftOfPosition(sourceFile, position); - if (!startingToken) { - return undefined; - } - var argumentInfo = getContainingArgumentInfo(startingToken); - cancellationToken.throwIfCancellationRequested(); - if (!argumentInfo) { - return undefined; - } - var call = argumentInfo.invocation; - var candidates = []; - var resolvedSignature = typeChecker.getResolvedSignature(call, candidates); - cancellationToken.throwIfCancellationRequested(); - if (!candidates.length) { - if (ts.isJavaScript(sourceFile.fileName)) { - return createJavaScriptSignatureHelpItems(argumentInfo); - } - return undefined; - } - return createSignatureHelpItems(candidates, resolvedSignature, argumentInfo); - function createJavaScriptSignatureHelpItems(argumentInfo) { - if (argumentInfo.invocation.kind !== 168) { - return undefined; - } - var callExpression = argumentInfo.invocation; - var expression = callExpression.expression; - var name = expression.kind === 69 - ? expression - : expression.kind === 166 - ? expression.name - : undefined; - if (!name || !name.text) { - return undefined; - } - var typeChecker = program.getTypeChecker(); - for (var _i = 0, _a = program.getSourceFiles(); _i < _a.length; _i++) { - var sourceFile_1 = _a[_i]; - var nameToDeclarations = sourceFile_1.getNamedDeclarations(); - var declarations = ts.getProperty(nameToDeclarations, name.text); - if (declarations) { - for (var _b = 0; _b < declarations.length; _b++) { - var declaration = declarations[_b]; - var symbol = declaration.symbol; - if (symbol) { - var type = typeChecker.getTypeOfSymbolAtLocation(symbol, declaration); - if (type) { - var callSignatures = type.getCallSignatures(); - if (callSignatures && callSignatures.length) { - return createSignatureHelpItems(callSignatures, callSignatures[0], argumentInfo); - } - } - } - } - } - } - } - function getImmediatelyContainingArgumentInfo(node) { - if (node.parent.kind === 168 || node.parent.kind === 169) { - var callExpression = node.parent; - if (node.kind === 25 || - node.kind === 17) { - var list = getChildListThatStartsWithOpenerToken(callExpression, node, sourceFile); - var isTypeArgList = callExpression.typeArguments && callExpression.typeArguments.pos === list.pos; - ts.Debug.assert(list !== undefined); - return { - kind: isTypeArgList ? 0 : 1, - invocation: callExpression, - argumentsSpan: getApplicableSpanForArguments(list), - argumentIndex: 0, - argumentCount: getArgumentCount(list) - }; - } - var listItemInfo = ts.findListItemInfo(node); - if (listItemInfo) { - var list = listItemInfo.list; - var isTypeArgList = callExpression.typeArguments && callExpression.typeArguments.pos === list.pos; - var argumentIndex = getArgumentIndex(list, node); - var argumentCount = getArgumentCount(list); - ts.Debug.assert(argumentIndex === 0 || argumentIndex < argumentCount, "argumentCount < argumentIndex, " + argumentCount + " < " + argumentIndex); - return { - kind: isTypeArgList ? 0 : 1, - invocation: callExpression, - argumentsSpan: getApplicableSpanForArguments(list), - argumentIndex: argumentIndex, - argumentCount: argumentCount - }; - } - } - else if (node.kind === 11 && node.parent.kind === 170) { - if (ts.isInsideTemplateLiteral(node, position)) { - return getArgumentListInfoForTemplate(node.parent, 0); - } - } - else if (node.kind === 12 && node.parent.parent.kind === 170) { - var templateExpression = node.parent; - var tagExpression = templateExpression.parent; - ts.Debug.assert(templateExpression.kind === 183); - var argumentIndex = ts.isInsideTemplateLiteral(node, position) ? 0 : 1; - return getArgumentListInfoForTemplate(tagExpression, argumentIndex); - } - else if (node.parent.kind === 190 && node.parent.parent.parent.kind === 170) { - var templateSpan = node.parent; - var templateExpression = templateSpan.parent; - var tagExpression = templateExpression.parent; - ts.Debug.assert(templateExpression.kind === 183); - if (node.kind === 14 && !ts.isInsideTemplateLiteral(node, position)) { - return undefined; - } - var spanIndex = templateExpression.templateSpans.indexOf(templateSpan); - var argumentIndex = getArgumentIndexForTemplatePiece(spanIndex, node); - return getArgumentListInfoForTemplate(tagExpression, argumentIndex); - } - return undefined; - } - function getArgumentIndex(argumentsList, node) { - var argumentIndex = 0; - var listChildren = argumentsList.getChildren(); - for (var _i = 0; _i < listChildren.length; _i++) { - var child = listChildren[_i]; - if (child === node) { - break; - } - if (child.kind !== 24) { - argumentIndex++; - } - } - return argumentIndex; - } - 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) { - argumentCount++; - } - return argumentCount; - } - function getArgumentIndexForTemplatePiece(spanIndex, node) { - ts.Debug.assert(position >= node.getStart(), "Assumed 'position' could not occur before node."); - if (ts.isTemplateLiteralKind(node.kind)) { - if (ts.isInsideTemplateLiteral(node, position)) { - return 0; - } - return spanIndex + 2; - } - return spanIndex + 1; - } - function getArgumentListInfoForTemplate(tagExpression, argumentIndex) { - var argumentCount = tagExpression.template.kind === 11 - ? 1 - : tagExpression.template.templateSpans.length + 1; - ts.Debug.assert(argumentIndex === 0 || argumentIndex < argumentCount, "argumentCount < argumentIndex, " + argumentCount + " < " + argumentIndex); - return { - kind: 2, - invocation: tagExpression, - argumentsSpan: getApplicableSpanForTaggedTemplate(tagExpression), - argumentIndex: argumentIndex, - argumentCount: argumentCount - }; - } - function getApplicableSpanForArguments(argumentsList) { - var applicableSpanStart = argumentsList.getFullStart(); - var applicableSpanEnd = ts.skipTrivia(sourceFile.text, argumentsList.getEnd(), false); - return ts.createTextSpan(applicableSpanStart, applicableSpanEnd - applicableSpanStart); - } - function getApplicableSpanForTaggedTemplate(taggedTemplate) { - var template = taggedTemplate.template; - var applicableSpanStart = template.getStart(); - var applicableSpanEnd = template.getEnd(); - if (template.kind === 183) { - var lastSpan = ts.lastOrUndefined(template.templateSpans); - if (lastSpan.literal.getFullWidth() === 0) { - applicableSpanEnd = ts.skipTrivia(sourceFile.text, applicableSpanEnd, false); - } - } - return ts.createTextSpan(applicableSpanStart, applicableSpanEnd - applicableSpanStart); - } - function getContainingArgumentInfo(node) { - for (var n = node; n.kind !== 248; n = n.parent) { - if (ts.isFunctionBlock(n)) { - return undefined; - } - if (n.pos < n.parent.pos || n.end > n.parent.end) { - ts.Debug.fail("Node of kind " + n.kind + " is not a subspan of its parent of kind " + n.parent.kind); - } - var argumentInfo_1 = getImmediatelyContainingArgumentInfo(n); - if (argumentInfo_1) { - return argumentInfo_1; - } - } - return undefined; - } - function getChildListThatStartsWithOpenerToken(parent, openerToken, sourceFile) { - var children = parent.getChildren(sourceFile); - var indexOfOpenerToken = children.indexOf(openerToken); - ts.Debug.assert(indexOfOpenerToken >= 0 && children.length > indexOfOpenerToken + 1); - return children[indexOfOpenerToken + 1]; - } - function selectBestInvalidOverloadIndex(candidates, argumentCount) { - var maxParamsSignatureIndex = -1; - var maxParams = -1; - for (var i = 0; i < candidates.length; i++) { - var candidate = candidates[i]; - if (candidate.hasRestParameter || candidate.parameters.length >= argumentCount) { - return i; - } - if (candidate.parameters.length > maxParams) { - maxParams = candidate.parameters.length; - maxParamsSignatureIndex = i; - } - } - return maxParamsSignatureIndex; - } - function createSignatureHelpItems(candidates, bestSignature, argumentListInfo) { - var applicableSpan = argumentListInfo.argumentsSpan; - var isTypeParameterList = argumentListInfo.kind === 0; - var invocation = argumentListInfo.invocation; - var callTarget = ts.getInvokedExpression(invocation); - var callTargetSymbol = typeChecker.getSymbolAtLocation(callTarget); - var callTargetDisplayParts = callTargetSymbol && ts.symbolToDisplayParts(typeChecker, callTargetSymbol, undefined, undefined); - var items = ts.map(candidates, function (candidateSignature) { - var signatureHelpParameters; - var prefixDisplayParts = []; - var suffixDisplayParts = []; - if (callTargetDisplayParts) { - ts.addRange(prefixDisplayParts, callTargetDisplayParts); - } - if (isTypeParameterList) { - prefixDisplayParts.push(ts.punctuationPart(25)); - var typeParameters = candidateSignature.typeParameters; - signatureHelpParameters = typeParameters && typeParameters.length > 0 ? ts.map(typeParameters, createSignatureHelpParameterForTypeParameter) : emptyArray; - suffixDisplayParts.push(ts.punctuationPart(27)); - var parameterParts = ts.mapToDisplayParts(function (writer) { - return typeChecker.getSymbolDisplayBuilder().buildDisplayForParametersAndDelimiters(candidateSignature.parameters, writer, invocation); - }); - ts.addRange(suffixDisplayParts, parameterParts); - } - else { - var typeParameterParts = ts.mapToDisplayParts(function (writer) { - return typeChecker.getSymbolDisplayBuilder().buildDisplayForTypeParametersAndDelimiters(candidateSignature.typeParameters, writer, invocation); - }); - ts.addRange(prefixDisplayParts, typeParameterParts); - prefixDisplayParts.push(ts.punctuationPart(17)); - var parameters = candidateSignature.parameters; - signatureHelpParameters = parameters.length > 0 ? ts.map(parameters, createSignatureHelpParameterForParameter) : emptyArray; - suffixDisplayParts.push(ts.punctuationPart(18)); - } - var returnTypeParts = ts.mapToDisplayParts(function (writer) { - return typeChecker.getSymbolDisplayBuilder().buildReturnTypeDisplay(candidateSignature, writer, invocation); - }); - ts.addRange(suffixDisplayParts, returnTypeParts); - return { - isVariadic: candidateSignature.hasRestParameter, - prefixDisplayParts: prefixDisplayParts, - suffixDisplayParts: suffixDisplayParts, - separatorDisplayParts: [ts.punctuationPart(24), ts.spacePart()], - parameters: signatureHelpParameters, - documentation: candidateSignature.getDocumentationComment() - }; - }); - var argumentIndex = argumentListInfo.argumentIndex; - var argumentCount = argumentListInfo.argumentCount; - var selectedItemIndex = candidates.indexOf(bestSignature); - if (selectedItemIndex < 0) { - selectedItemIndex = selectBestInvalidOverloadIndex(candidates, argumentCount); - } - ts.Debug.assert(argumentIndex === 0 || argumentIndex < argumentCount, "argumentCount < argumentIndex, " + argumentCount + " < " + argumentIndex); - return { - items: items, - applicableSpan: applicableSpan, - selectedItemIndex: selectedItemIndex, - argumentIndex: argumentIndex, - argumentCount: argumentCount - }; - function createSignatureHelpParameterForParameter(parameter) { - var displayParts = ts.mapToDisplayParts(function (writer) { - return typeChecker.getSymbolDisplayBuilder().buildParameterDisplay(parameter, writer, invocation); - }); - return { - name: parameter.name, - documentation: parameter.getDocumentationComment(), - displayParts: displayParts, - isOptional: typeChecker.isOptionalParameter(parameter.valueDeclaration) - }; - } - function createSignatureHelpParameterForTypeParameter(typeParameter) { - var displayParts = ts.mapToDisplayParts(function (writer) { - return typeChecker.getSymbolDisplayBuilder().buildTypeParameterDisplay(typeParameter, writer, invocation); - }); - return { - name: typeParameter.symbol.name, - documentation: emptyArray, - displayParts: displayParts, - isOptional: false - }; - } - } - } - SignatureHelp.getSignatureHelpItems = getSignatureHelpItems; - })(SignatureHelp = ts.SignatureHelp || (ts.SignatureHelp = {})); -})(ts || (ts = {})); -var ts; -(function (ts) { - function getEndLinePosition(line, sourceFile) { - ts.Debug.assert(line >= 0); - var lineStarts = sourceFile.getLineStarts(); - var lineIndex = line; - if (lineIndex + 1 === lineStarts.length) { - return sourceFile.text.length - 1; - } - else { - var start = lineStarts[lineIndex]; - var pos = lineStarts[lineIndex + 1] - 1; - ts.Debug.assert(ts.isLineBreak(sourceFile.text.charCodeAt(pos))); - while (start <= pos && ts.isLineBreak(sourceFile.text.charCodeAt(pos))) { - pos--; - } - return pos; - } - } - ts.getEndLinePosition = getEndLinePosition; - function getLineStartPositionForPosition(position, sourceFile) { - var lineStarts = sourceFile.getLineStarts(); - var line = sourceFile.getLineAndCharacterOfPosition(position).line; - return lineStarts[line]; - } - ts.getLineStartPositionForPosition = getLineStartPositionForPosition; - function rangeContainsRange(r1, r2) { - return startEndContainsRange(r1.pos, r1.end, r2); - } - ts.rangeContainsRange = rangeContainsRange; - function startEndContainsRange(start, end, range) { - return start <= range.pos && end >= range.end; - } - ts.startEndContainsRange = startEndContainsRange; - function rangeContainsStartEnd(range, start, end) { - return range.pos <= start && range.end >= end; - } - ts.rangeContainsStartEnd = rangeContainsStartEnd; - function rangeOverlapsWithStartEnd(r1, start, end) { - return startEndOverlapsWithStartEnd(r1.pos, r1.end, start, end); - } - ts.rangeOverlapsWithStartEnd = rangeOverlapsWithStartEnd; - function startEndOverlapsWithStartEnd(start1, end1, start2, end2) { - var start = Math.max(start1, start2); - var end = Math.min(end1, end2); - return start < end; - } - ts.startEndOverlapsWithStartEnd = startEndOverlapsWithStartEnd; - function positionBelongsToNode(candidate, position, sourceFile) { - return candidate.end > position || !isCompletedNode(candidate, sourceFile); - } - ts.positionBelongsToNode = positionBelongsToNode; - function isCompletedNode(n, sourceFile) { - if (ts.nodeIsMissing(n)) { - return false; - } - switch (n.kind) { - case 214: - case 215: - case 217: - case 165: - case 161: - case 155: - case 192: - case 219: - case 220: - return nodeEndsWith(n, 16, sourceFile); - case 244: - return isCompletedNode(n.block, sourceFile); - case 169: - if (!n.arguments) { - return true; - } - case 168: - case 172: - case 160: - return nodeEndsWith(n, 18, sourceFile); - case 152: - case 153: - return isCompletedNode(n.type, sourceFile); - case 144: - case 145: - case 146: - case 213: - case 173: - case 143: - case 142: - case 148: - case 147: - case 174: - if (n.body) { - return isCompletedNode(n.body, sourceFile); - } - if (n.type) { - return isCompletedNode(n.type, sourceFile); - } - return hasChildOfKind(n, 18, sourceFile); - case 218: - return n.body && isCompletedNode(n.body, sourceFile); - case 196: - if (n.elseStatement) { - return isCompletedNode(n.elseStatement, sourceFile); - } - return isCompletedNode(n.thenStatement, sourceFile); - case 195: - return isCompletedNode(n.expression, sourceFile) || - hasChildOfKind(n, 23); - case 164: - case 162: - case 167: - case 136: - case 157: - return nodeEndsWith(n, 20, sourceFile); - case 149: - if (n.type) { - return isCompletedNode(n.type, sourceFile); - } - return hasChildOfKind(n, 20, sourceFile); - case 241: - case 242: - return false; - case 199: - case 200: - case 201: - case 198: - return isCompletedNode(n.statement, sourceFile); - case 197: - var hasWhileKeyword = findChildOfKind(n, 104, sourceFile); - if (hasWhileKeyword) { - return nodeEndsWith(n, 18, sourceFile); - } - return isCompletedNode(n.statement, sourceFile); - case 154: - return isCompletedNode(n.exprName, sourceFile); - case 176: - case 175: - case 177: - case 184: - case 185: - var unaryWordExpression = n; - return isCompletedNode(unaryWordExpression.expression, sourceFile); - case 170: - return isCompletedNode(n.template, sourceFile); - case 183: - var lastSpan = ts.lastOrUndefined(n.templateSpans); - return isCompletedNode(lastSpan, sourceFile); - case 190: - return ts.nodeIsPresent(n.literal); - case 179: - return isCompletedNode(n.operand, sourceFile); - case 181: - return isCompletedNode(n.right, sourceFile); - case 182: - return isCompletedNode(n.whenFalse, sourceFile); - default: - return true; - } - } - ts.isCompletedNode = isCompletedNode; - function nodeEndsWith(n, expectedLastToken, sourceFile) { - var children = n.getChildren(sourceFile); - if (children.length) { - var last = ts.lastOrUndefined(children); - if (last.kind === expectedLastToken) { - return true; - } - else if (last.kind === 23 && children.length !== 1) { - return children[children.length - 2].kind === expectedLastToken; - } - } - return false; - } - function findListItemInfo(node) { - var list = findContainingList(node); - if (!list) { - return undefined; - } - var children = list.getChildren(); - var listItemIndex = ts.indexOf(children, node); - return { - listItemIndex: listItemIndex, - list: list - }; - } - ts.findListItemInfo = findListItemInfo; - function hasChildOfKind(n, kind, sourceFile) { - return !!findChildOfKind(n, kind, sourceFile); - } - ts.hasChildOfKind = hasChildOfKind; - function findChildOfKind(n, kind, sourceFile) { - return ts.forEach(n.getChildren(sourceFile), function (c) { return c.kind === kind && c; }); - } - ts.findChildOfKind = findChildOfKind; - function findContainingList(node) { - var syntaxList = ts.forEach(node.parent.getChildren(), function (c) { - if (c.kind === 271 && c.pos <= node.pos && c.end >= node.end) { - return c; - } - }); - ts.Debug.assert(!syntaxList || ts.contains(syntaxList.getChildren(), node)); - return syntaxList; - } - ts.findContainingList = findContainingList; - function getTouchingWord(sourceFile, position) { - return getTouchingToken(sourceFile, position, function (n) { return isWord(n.kind); }); - } - ts.getTouchingWord = getTouchingWord; - function getTouchingPropertyName(sourceFile, position) { - return getTouchingToken(sourceFile, position, function (n) { return isPropertyName(n.kind); }); - } - ts.getTouchingPropertyName = getTouchingPropertyName; - function getTouchingToken(sourceFile, position, includeItemAtEndPosition) { - return getTokenAtPositionWorker(sourceFile, position, false, includeItemAtEndPosition); - } - ts.getTouchingToken = getTouchingToken; - function getTokenAtPosition(sourceFile, position) { - return getTokenAtPositionWorker(sourceFile, position, true, undefined); - } - ts.getTokenAtPosition = getTokenAtPosition; - function getTokenAtPositionWorker(sourceFile, position, allowPositionInLeadingTrivia, includeItemAtEndPosition) { - var current = sourceFile; - outer: while (true) { - if (isToken(current)) { - return current; - } - for (var i = 0, n = current.getChildCount(sourceFile); i < n; i++) { - var child = current.getChildAt(i); - var start = allowPositionInLeadingTrivia ? child.getFullStart() : child.getStart(sourceFile); - if (start <= position) { - var end = child.getEnd(); - if (position < end || (position === end && child.kind === 1)) { - current = child; - continue outer; - } - else if (includeItemAtEndPosition && end === position) { - var previousToken = findPrecedingToken(position, sourceFile, child); - if (previousToken && includeItemAtEndPosition(previousToken)) { - return previousToken; - } - } - } - } - return current; - } - } - function findTokenOnLeftOfPosition(file, position) { - var tokenAtPosition = getTokenAtPosition(file, position); - if (isToken(tokenAtPosition) && position > tokenAtPosition.getStart(file) && position < tokenAtPosition.getEnd()) { - return tokenAtPosition; - } - return findPrecedingToken(position, file); - } - ts.findTokenOnLeftOfPosition = findTokenOnLeftOfPosition; - function findNextToken(previousToken, parent) { - return find(parent); - function find(n) { - if (isToken(n) && n.pos === previousToken.end) { - return n; - } - var children = n.getChildren(); - for (var _i = 0; _i < children.length; _i++) { - var child = children[_i]; - var shouldDiveInChildNode = (child.pos <= previousToken.pos && child.end > previousToken.end) || - (child.pos === previousToken.end); - if (shouldDiveInChildNode && nodeHasTokens(child)) { - return find(child); - } - } - return undefined; - } - } - ts.findNextToken = findNextToken; - function findPrecedingToken(position, sourceFile, startNode) { - return find(startNode || sourceFile); - function findRightmostToken(n) { - if (isToken(n) || n.kind === 236) { - return n; - } - var children = n.getChildren(); - var candidate = findRightmostChildNodeWithTokens(children, children.length); - return candidate && findRightmostToken(candidate); - } - function find(n) { - if (isToken(n) || n.kind === 236) { - return n; - } - var children = n.getChildren(); - for (var i = 0, len = children.length; i < len; i++) { - var child = children[i]; - if (position < child.end && (nodeHasTokens(child) || child.kind === 236)) { - var start = child.getStart(sourceFile); - var lookInPreviousChild = (start >= position) || - (child.kind === 236 && start === child.end); - if (lookInPreviousChild) { - var candidate = findRightmostChildNodeWithTokens(children, i); - return candidate && findRightmostToken(candidate); - } - else { - return find(child); - } - } - } - ts.Debug.assert(startNode !== undefined || n.kind === 248); - if (children.length) { - var candidate = findRightmostChildNodeWithTokens(children, children.length); - return candidate && findRightmostToken(candidate); - } - } - function findRightmostChildNodeWithTokens(children, exclusiveStartPosition) { - for (var i = exclusiveStartPosition - 1; i >= 0; --i) { - if (nodeHasTokens(children[i])) { - return children[i]; - } - } - } - } - ts.findPrecedingToken = findPrecedingToken; - function isInString(sourceFile, position) { - var token = getTokenAtPosition(sourceFile, position); - return token && token.kind === 9 && position > token.getStart(); - } - ts.isInString = isInString; - function isInComment(sourceFile, position) { - return isInCommentHelper(sourceFile, position, undefined); - } - ts.isInComment = isInComment; - function isInCommentHelper(sourceFile, position, predicate) { - var token = getTokenAtPosition(sourceFile, position); - if (token && position <= token.getStart()) { - var commentRanges = ts.getLeadingCommentRanges(sourceFile.text, token.pos); - return predicate ? - ts.forEach(commentRanges, function (c) { return c.pos < position && - (c.kind == 2 ? position <= c.end : position < c.end) && - predicate(c); }) : - ts.forEach(commentRanges, function (c) { return c.pos < position && - (c.kind == 2 ? position <= c.end : position < c.end); }); - } - return false; - } - ts.isInCommentHelper = isInCommentHelper; - function hasDocComment(sourceFile, position) { - var token = getTokenAtPosition(sourceFile, position); - var commentRanges = ts.getLeadingCommentRanges(sourceFile.text, token.pos); - return ts.forEach(commentRanges, jsDocPrefix); - function jsDocPrefix(c) { - var text = sourceFile.text; - return text.length >= c.pos + 3 && text[c.pos] === '/' && text[c.pos + 1] === '*' && text[c.pos + 2] === '*'; - } - } - ts.hasDocComment = hasDocComment; - function getJsDocTagAtPosition(sourceFile, position) { - var node = ts.getTokenAtPosition(sourceFile, position); - if (isToken(node)) { - switch (node.kind) { - case 102: - case 108: - case 74: - node = node.parent === undefined ? undefined : node.parent.parent; - break; - default: - node = node.parent; - break; - } - } - if (node) { - var jsDocComment = node.jsDocComment; - if (jsDocComment) { - for (var _i = 0, _a = jsDocComment.tags; _i < _a.length; _i++) { - var tag = _a[_i]; - if (tag.pos <= position && position <= tag.end) { - return tag; - } - } - } - } - return undefined; - } - ts.getJsDocTagAtPosition = getJsDocTagAtPosition; - function nodeHasTokens(n) { - return n.getWidth() !== 0; - } - function getNodeModifiers(node) { - var flags = ts.getCombinedNodeFlags(node); - var result = []; - if (flags & 32) - result.push(ts.ScriptElementKindModifier.privateMemberModifier); - if (flags & 64) - result.push(ts.ScriptElementKindModifier.protectedMemberModifier); - if (flags & 16) - result.push(ts.ScriptElementKindModifier.publicMemberModifier); - if (flags & 128) - result.push(ts.ScriptElementKindModifier.staticModifier); - if (flags & 256) - result.push(ts.ScriptElementKindModifier.abstractModifier); - if (flags & 1) - result.push(ts.ScriptElementKindModifier.exportedModifier); - if (ts.isInAmbientContext(node)) - result.push(ts.ScriptElementKindModifier.ambientModifier); - return result.length > 0 ? result.join(',') : ts.ScriptElementKindModifier.none; - } - ts.getNodeModifiers = getNodeModifiers; - function getTypeArgumentOrTypeParameterList(node) { - if (node.kind === 151 || node.kind === 168) { - return node.typeArguments; - } - if (ts.isFunctionLike(node) || node.kind === 214 || node.kind === 215) { - return node.typeParameters; - } - return undefined; - } - ts.getTypeArgumentOrTypeParameterList = getTypeArgumentOrTypeParameterList; - function isToken(n) { - return n.kind >= 0 && n.kind <= 134; - } - ts.isToken = isToken; - function isWord(kind) { - return kind === 69 || ts.isKeyword(kind); - } - ts.isWord = isWord; - function isPropertyName(kind) { - return kind === 9 || kind === 8 || isWord(kind); - } - function isComment(kind) { - return kind === 2 || kind === 3; - } - ts.isComment = isComment; - function isStringOrRegularExpressionOrTemplateLiteral(kind) { - if (kind === 9 - || kind === 10 - || ts.isTemplateLiteralKind(kind)) { - return true; - } - return false; - } - ts.isStringOrRegularExpressionOrTemplateLiteral = isStringOrRegularExpressionOrTemplateLiteral; - function isPunctuation(kind) { - return 15 <= kind && kind <= 68; - } - ts.isPunctuation = isPunctuation; - function isInsideTemplateLiteral(node, position) { - return ts.isTemplateLiteralKind(node.kind) - && (node.getStart() < position && position < node.getEnd()) || (!!node.isUnterminated && position === node.getEnd()); - } - ts.isInsideTemplateLiteral = isInsideTemplateLiteral; - function isAccessibilityModifier(kind) { - switch (kind) { - case 112: - case 110: - case 111: - return true; - } - return false; - } - ts.isAccessibilityModifier = isAccessibilityModifier; - function compareDataObjects(dst, src) { - for (var e in dst) { - if (typeof dst[e] === "object") { - if (!compareDataObjects(dst[e], src[e])) { - return false; - } - } - else if (typeof dst[e] !== "function") { - if (dst[e] !== src[e]) { - return false; - } - } - } - return true; - } - ts.compareDataObjects = compareDataObjects; -})(ts || (ts = {})); -var ts; -(function (ts) { - function isFirstDeclarationOfSymbolParameter(symbol) { - return symbol.declarations && symbol.declarations.length > 0 && symbol.declarations[0].kind === 138; - } - ts.isFirstDeclarationOfSymbolParameter = isFirstDeclarationOfSymbolParameter; - var displayPartWriter = getDisplayPartWriter(); - function getDisplayPartWriter() { - var displayParts; - var lineStart; - var indent; - resetWriter(); - return { - displayParts: function () { return displayParts; }, - writeKeyword: function (text) { return writeKind(text, ts.SymbolDisplayPartKind.keyword); }, - writeOperator: function (text) { return writeKind(text, ts.SymbolDisplayPartKind.operator); }, - writePunctuation: function (text) { return writeKind(text, ts.SymbolDisplayPartKind.punctuation); }, - writeSpace: function (text) { return writeKind(text, ts.SymbolDisplayPartKind.space); }, - writeStringLiteral: function (text) { return writeKind(text, ts.SymbolDisplayPartKind.stringLiteral); }, - writeParameter: function (text) { return writeKind(text, ts.SymbolDisplayPartKind.parameterName); }, - writeSymbol: writeSymbol, - writeLine: writeLine, - increaseIndent: function () { indent++; }, - decreaseIndent: function () { indent--; }, - clear: resetWriter, - trackSymbol: function () { }, - reportInaccessibleThisError: function () { } - }; - function writeIndent() { - if (lineStart) { - var indentString = ts.getIndentString(indent); - if (indentString) { - displayParts.push(displayPart(indentString, ts.SymbolDisplayPartKind.space)); - } - lineStart = false; - } - } - function writeKind(text, kind) { - writeIndent(); - displayParts.push(displayPart(text, kind)); - } - function writeSymbol(text, symbol) { - writeIndent(); - displayParts.push(symbolPart(text, symbol)); - } - function writeLine() { - displayParts.push(lineBreakPart()); - lineStart = true; - } - function resetWriter() { - displayParts = []; - lineStart = true; - indent = 0; - } - } - function symbolPart(text, symbol) { - return displayPart(text, displayPartKind(symbol), symbol); - function displayPartKind(symbol) { - var flags = symbol.flags; - if (flags & 3) { - return isFirstDeclarationOfSymbolParameter(symbol) ? ts.SymbolDisplayPartKind.parameterName : ts.SymbolDisplayPartKind.localName; - } - else if (flags & 4) { - return ts.SymbolDisplayPartKind.propertyName; - } - else if (flags & 32768) { - return ts.SymbolDisplayPartKind.propertyName; - } - else if (flags & 65536) { - return ts.SymbolDisplayPartKind.propertyName; - } - else if (flags & 8) { - return ts.SymbolDisplayPartKind.enumMemberName; - } - else if (flags & 16) { - return ts.SymbolDisplayPartKind.functionName; - } - else if (flags & 32) { - return ts.SymbolDisplayPartKind.className; - } - else if (flags & 64) { - return ts.SymbolDisplayPartKind.interfaceName; - } - else if (flags & 384) { - return ts.SymbolDisplayPartKind.enumName; - } - else if (flags & 1536) { - return ts.SymbolDisplayPartKind.moduleName; - } - else if (flags & 8192) { - return ts.SymbolDisplayPartKind.methodName; - } - else if (flags & 262144) { - return ts.SymbolDisplayPartKind.typeParameterName; - } - else if (flags & 524288) { - return ts.SymbolDisplayPartKind.aliasName; - } - else if (flags & 8388608) { - return ts.SymbolDisplayPartKind.aliasName; - } - return ts.SymbolDisplayPartKind.text; - } - } - ts.symbolPart = symbolPart; - function displayPart(text, kind, symbol) { - return { - text: text, - kind: ts.SymbolDisplayPartKind[kind] - }; - } - ts.displayPart = displayPart; - function spacePart() { - return displayPart(" ", ts.SymbolDisplayPartKind.space); - } - ts.spacePart = spacePart; - function keywordPart(kind) { - return displayPart(ts.tokenToString(kind), ts.SymbolDisplayPartKind.keyword); - } - ts.keywordPart = keywordPart; - function punctuationPart(kind) { - return displayPart(ts.tokenToString(kind), ts.SymbolDisplayPartKind.punctuation); - } - ts.punctuationPart = punctuationPart; - function operatorPart(kind) { - return displayPart(ts.tokenToString(kind), ts.SymbolDisplayPartKind.operator); - } - ts.operatorPart = operatorPart; - function textOrKeywordPart(text) { - var kind = ts.stringToToken(text); - return kind === undefined - ? textPart(text) - : keywordPart(kind); - } - ts.textOrKeywordPart = textOrKeywordPart; - function textPart(text) { - return displayPart(text, ts.SymbolDisplayPartKind.text); - } - ts.textPart = textPart; - var carriageReturnLineFeed = "\r\n"; - function getNewLineOrDefaultFromHost(host) { - return host.getNewLine ? host.getNewLine() : carriageReturnLineFeed; - } - ts.getNewLineOrDefaultFromHost = getNewLineOrDefaultFromHost; - function lineBreakPart() { - return displayPart("\n", ts.SymbolDisplayPartKind.lineBreak); - } - ts.lineBreakPart = lineBreakPart; - function mapToDisplayParts(writeDisplayParts) { - writeDisplayParts(displayPartWriter); - var result = displayPartWriter.displayParts(); - displayPartWriter.clear(); - return result; - } - ts.mapToDisplayParts = mapToDisplayParts; - function typeToDisplayParts(typechecker, type, enclosingDeclaration, flags) { - return mapToDisplayParts(function (writer) { - typechecker.getSymbolDisplayBuilder().buildTypeDisplay(type, writer, enclosingDeclaration, flags); - }); - } - ts.typeToDisplayParts = typeToDisplayParts; - function symbolToDisplayParts(typeChecker, symbol, enclosingDeclaration, meaning, flags) { - return mapToDisplayParts(function (writer) { - typeChecker.getSymbolDisplayBuilder().buildSymbolDisplay(symbol, writer, enclosingDeclaration, meaning, flags); - }); - } - ts.symbolToDisplayParts = symbolToDisplayParts; - function signatureToDisplayParts(typechecker, signature, enclosingDeclaration, flags) { - return mapToDisplayParts(function (writer) { - typechecker.getSymbolDisplayBuilder().buildSignatureDisplay(signature, writer, enclosingDeclaration, flags); - }); - } - ts.signatureToDisplayParts = signatureToDisplayParts; - function getDeclaredName(typeChecker, symbol, location) { - if (isImportOrExportSpecifierName(location)) { - return location.getText(); - } - var localExportDefaultSymbol = ts.getLocalSymbolForExportDefault(symbol); - var name = typeChecker.symbolToString(localExportDefaultSymbol || symbol); - return name; - } - ts.getDeclaredName = getDeclaredName; - function isImportOrExportSpecifierName(location) { - return location.parent && - (location.parent.kind === 226 || location.parent.kind === 230) && - location.parent.propertyName === location; - } - ts.isImportOrExportSpecifierName = isImportOrExportSpecifierName; - function stripQuotes(name) { - var length = name.length; - if (length >= 2 && - name.charCodeAt(0) === name.charCodeAt(length - 1) && - (name.charCodeAt(0) === 34 || name.charCodeAt(0) === 39)) { - return name.substring(1, length - 1); - } - ; - return name; - } - ts.stripQuotes = stripQuotes; -})(ts || (ts = {})); -var ts; -(function (ts) { - var formatting; - (function (formatting) { - var standardScanner = ts.createScanner(2, false, 0); - var jsxScanner = ts.createScanner(2, false, 1); - var scanner; - function getFormattingScanner(sourceFile, startPos, endPos) { - ts.Debug.assert(scanner === undefined); - scanner = sourceFile.languageVariant === 1 ? jsxScanner : standardScanner; - scanner.setText(sourceFile.text); - scanner.setTextPos(startPos); - var wasNewLine = true; - var leadingTrivia; - var trailingTrivia; - var savedPos; - var lastScanAction; - var lastTokenInfo; - return { - advance: advance, - readTokenInfo: readTokenInfo, - isOnToken: isOnToken, - lastTrailingTriviaWasNewLine: function () { return wasNewLine; }, - close: function () { - ts.Debug.assert(scanner !== undefined); - lastTokenInfo = undefined; - scanner.setText(undefined); - scanner = undefined; - } - }; - function advance() { - ts.Debug.assert(scanner !== undefined); - lastTokenInfo = undefined; - var isStarted = scanner.getStartPos() !== startPos; - if (isStarted) { - if (trailingTrivia) { - ts.Debug.assert(trailingTrivia.length !== 0); - wasNewLine = ts.lastOrUndefined(trailingTrivia).kind === 4; - } - else { - wasNewLine = false; - } - } - leadingTrivia = undefined; - trailingTrivia = undefined; - if (!isStarted) { - scanner.scan(); - } - var t; - var pos = scanner.getStartPos(); - while (pos < endPos) { - var t_1 = scanner.getToken(); - if (!ts.isTrivia(t_1)) { - break; - } - scanner.scan(); - var item = { - pos: pos, - end: scanner.getStartPos(), - kind: t_1 - }; - pos = scanner.getStartPos(); - if (!leadingTrivia) { - leadingTrivia = []; - } - leadingTrivia.push(item); - } - savedPos = scanner.getStartPos(); - } - function shouldRescanGreaterThanToken(node) { - if (node) { - switch (node.kind) { - case 29: - case 64: - case 65: - case 45: - case 44: - return true; - } - } - return false; - } - function shouldRescanJsxIdentifier(node) { - if (node.parent) { - switch (node.parent.kind) { - case 238: - case 235: - case 237: - case 234: - return node.kind === 69; - } - } - return false; - } - function shouldRescanSlashToken(container) { - return container.kind === 10; - } - function shouldRescanTemplateToken(container) { - return container.kind === 13 || - container.kind === 14; - } - function startsWithSlashToken(t) { - return t === 39 || t === 61; - } - function readTokenInfo(n) { - ts.Debug.assert(scanner !== undefined); - if (!isOnToken()) { - return { - leadingTrivia: leadingTrivia, - trailingTrivia: undefined, - token: undefined - }; - } - var expectedScanAction = shouldRescanGreaterThanToken(n) - ? 1 - : shouldRescanSlashToken(n) - ? 2 - : shouldRescanTemplateToken(n) - ? 3 - : shouldRescanJsxIdentifier(n) - ? 4 - : 0; - if (lastTokenInfo && expectedScanAction === lastScanAction) { - return fixTokenKind(lastTokenInfo, n); - } - if (scanner.getStartPos() !== savedPos) { - ts.Debug.assert(lastTokenInfo !== undefined); - scanner.setTextPos(savedPos); - scanner.scan(); - } - var currentToken = scanner.getToken(); - if (expectedScanAction === 1 && currentToken === 27) { - currentToken = scanner.reScanGreaterToken(); - ts.Debug.assert(n.kind === currentToken); - lastScanAction = 1; - } - else if (expectedScanAction === 2 && startsWithSlashToken(currentToken)) { - currentToken = scanner.reScanSlashToken(); - ts.Debug.assert(n.kind === currentToken); - lastScanAction = 2; - } - else if (expectedScanAction === 3 && currentToken === 16) { - currentToken = scanner.reScanTemplateToken(); - lastScanAction = 3; - } - else if (expectedScanAction === 4 && currentToken === 69) { - currentToken = scanner.scanJsxIdentifier(); - lastScanAction = 4; - } - else { - lastScanAction = 0; - } - var token = { - pos: scanner.getStartPos(), - end: scanner.getTextPos(), - kind: currentToken - }; - if (trailingTrivia) { - trailingTrivia = undefined; - } - while (scanner.getStartPos() < endPos) { - currentToken = scanner.scan(); - if (!ts.isTrivia(currentToken)) { - break; - } - var trivia = { - pos: scanner.getStartPos(), - end: scanner.getTextPos(), - kind: currentToken - }; - if (!trailingTrivia) { - trailingTrivia = []; - } - trailingTrivia.push(trivia); - if (currentToken === 4) { - scanner.scan(); - break; - } - } - lastTokenInfo = { - leadingTrivia: leadingTrivia, - trailingTrivia: trailingTrivia, - token: token - }; - return fixTokenKind(lastTokenInfo, n); - } - function isOnToken() { - ts.Debug.assert(scanner !== undefined); - var current = (lastTokenInfo && lastTokenInfo.token.kind) || scanner.getToken(); - var startPos = (lastTokenInfo && lastTokenInfo.token.pos) || scanner.getStartPos(); - return startPos < endPos && current !== 1 && !ts.isTrivia(current); - } - function fixTokenKind(tokenInfo, container) { - if (ts.isToken(container) && tokenInfo.token.kind !== container.kind) { - tokenInfo.token.kind = container.kind; - } - return tokenInfo; - } - } - formatting.getFormattingScanner = getFormattingScanner; - })(formatting = ts.formatting || (ts.formatting = {})); -})(ts || (ts = {})); -var ts; -(function (ts) { - var formatting; - (function (formatting) { - var FormattingContext = (function () { - function FormattingContext(sourceFile, formattingRequestKind) { - this.sourceFile = sourceFile; - this.formattingRequestKind = formattingRequestKind; - } - FormattingContext.prototype.updateContext = function (currentRange, currentTokenParent, nextRange, nextTokenParent, commonParent) { - ts.Debug.assert(currentRange !== undefined, "currentTokenSpan is null"); - ts.Debug.assert(currentTokenParent !== undefined, "currentTokenParent is null"); - ts.Debug.assert(nextRange !== undefined, "nextTokenSpan is null"); - ts.Debug.assert(nextTokenParent !== undefined, "nextTokenParent is null"); - ts.Debug.assert(commonParent !== undefined, "commonParent is null"); - this.currentTokenSpan = currentRange; - this.currentTokenParent = currentTokenParent; - this.nextTokenSpan = nextRange; - this.nextTokenParent = nextTokenParent; - this.contextNode = commonParent; - this.contextNodeAllOnSameLine = undefined; - this.nextNodeAllOnSameLine = undefined; - this.tokensAreOnSameLine = undefined; - this.contextNodeBlockIsOnOneLine = undefined; - this.nextNodeBlockIsOnOneLine = undefined; - }; - FormattingContext.prototype.ContextNodeAllOnSameLine = function () { - if (this.contextNodeAllOnSameLine === undefined) { - this.contextNodeAllOnSameLine = this.NodeIsOnOneLine(this.contextNode); - } - return this.contextNodeAllOnSameLine; - }; - FormattingContext.prototype.NextNodeAllOnSameLine = function () { - if (this.nextNodeAllOnSameLine === undefined) { - this.nextNodeAllOnSameLine = this.NodeIsOnOneLine(this.nextTokenParent); - } - return this.nextNodeAllOnSameLine; - }; - FormattingContext.prototype.TokensAreOnSameLine = function () { - if (this.tokensAreOnSameLine === undefined) { - var startLine = this.sourceFile.getLineAndCharacterOfPosition(this.currentTokenSpan.pos).line; - var endLine = this.sourceFile.getLineAndCharacterOfPosition(this.nextTokenSpan.pos).line; - this.tokensAreOnSameLine = (startLine === endLine); - } - return this.tokensAreOnSameLine; - }; - FormattingContext.prototype.ContextNodeBlockIsOnOneLine = function () { - if (this.contextNodeBlockIsOnOneLine === undefined) { - this.contextNodeBlockIsOnOneLine = this.BlockIsOnOneLine(this.contextNode); - } - return this.contextNodeBlockIsOnOneLine; - }; - FormattingContext.prototype.NextNodeBlockIsOnOneLine = function () { - if (this.nextNodeBlockIsOnOneLine === undefined) { - this.nextNodeBlockIsOnOneLine = this.BlockIsOnOneLine(this.nextTokenParent); - } - return this.nextNodeBlockIsOnOneLine; - }; - FormattingContext.prototype.NodeIsOnOneLine = function (node) { - var startLine = this.sourceFile.getLineAndCharacterOfPosition(node.getStart(this.sourceFile)).line; - var endLine = this.sourceFile.getLineAndCharacterOfPosition(node.getEnd()).line; - return startLine === endLine; - }; - FormattingContext.prototype.BlockIsOnOneLine = function (node) { - var openBrace = ts.findChildOfKind(node, 15, this.sourceFile); - var closeBrace = ts.findChildOfKind(node, 16, this.sourceFile); - if (openBrace && closeBrace) { - var startLine = this.sourceFile.getLineAndCharacterOfPosition(openBrace.getEnd()).line; - var endLine = this.sourceFile.getLineAndCharacterOfPosition(closeBrace.getStart(this.sourceFile)).line; - return startLine === endLine; - } - return false; - }; - return FormattingContext; - })(); - formatting.FormattingContext = FormattingContext; - })(formatting = ts.formatting || (ts.formatting = {})); -})(ts || (ts = {})); -var ts; -(function (ts) { - var formatting; - (function (formatting) { - var Rule = (function () { - function Rule(Descriptor, Operation, Flag) { - if (Flag === void 0) { Flag = 0; } - this.Descriptor = Descriptor; - this.Operation = Operation; - this.Flag = Flag; - } - Rule.prototype.toString = function () { - return "[desc=" + this.Descriptor + "," + - "operation=" + this.Operation + "," + - "flag=" + this.Flag + "]"; - }; - return Rule; - })(); - formatting.Rule = Rule; - })(formatting = ts.formatting || (ts.formatting = {})); -})(ts || (ts = {})); -var ts; -(function (ts) { - var formatting; - (function (formatting) { - var RuleDescriptor = (function () { - function RuleDescriptor(LeftTokenRange, RightTokenRange) { - this.LeftTokenRange = LeftTokenRange; - this.RightTokenRange = RightTokenRange; - } - RuleDescriptor.prototype.toString = function () { - return "[leftRange=" + this.LeftTokenRange + "," + - "rightRange=" + this.RightTokenRange + "]"; - }; - RuleDescriptor.create1 = function (left, right) { - return RuleDescriptor.create4(formatting.Shared.TokenRange.FromToken(left), formatting.Shared.TokenRange.FromToken(right)); - }; - RuleDescriptor.create2 = function (left, right) { - return RuleDescriptor.create4(left, formatting.Shared.TokenRange.FromToken(right)); - }; - RuleDescriptor.create3 = function (left, right) { - return RuleDescriptor.create4(formatting.Shared.TokenRange.FromToken(left), right); - }; - RuleDescriptor.create4 = function (left, right) { - return new RuleDescriptor(left, right); - }; - return RuleDescriptor; - })(); - formatting.RuleDescriptor = RuleDescriptor; - })(formatting = ts.formatting || (ts.formatting = {})); -})(ts || (ts = {})); -var ts; -(function (ts) { - var formatting; - (function (formatting) { - var RuleOperation = (function () { - function RuleOperation() { - this.Context = null; - this.Action = null; - } - RuleOperation.prototype.toString = function () { - return "[context=" + this.Context + "," + - "action=" + this.Action + "]"; - }; - RuleOperation.create1 = function (action) { - return RuleOperation.create2(formatting.RuleOperationContext.Any, action); - }; - RuleOperation.create2 = function (context, action) { - var result = new RuleOperation(); - result.Context = context; - result.Action = action; - return result; - }; - return RuleOperation; - })(); - formatting.RuleOperation = RuleOperation; - })(formatting = ts.formatting || (ts.formatting = {})); -})(ts || (ts = {})); -var ts; -(function (ts) { - var formatting; - (function (formatting) { - var RuleOperationContext = (function () { - function RuleOperationContext() { - var funcs = []; - for (var _i = 0; _i < arguments.length; _i++) { - funcs[_i - 0] = arguments[_i]; - } - this.customContextChecks = funcs; - } - RuleOperationContext.prototype.IsAny = function () { - return this === RuleOperationContext.Any; - }; - RuleOperationContext.prototype.InContext = function (context) { - if (this.IsAny()) { - return true; - } - for (var _i = 0, _a = this.customContextChecks; _i < _a.length; _i++) { - var check = _a[_i]; - if (!check(context)) { - return false; - } - } - return true; - }; - RuleOperationContext.Any = new RuleOperationContext(); - return RuleOperationContext; - })(); - formatting.RuleOperationContext = RuleOperationContext; - })(formatting = ts.formatting || (ts.formatting = {})); -})(ts || (ts = {})); -var ts; -(function (ts) { - var formatting; - (function (formatting) { - var Rules = (function () { - 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.IsSameLineTokenContext), 8)); - this.NoSpaceBeforeColon = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 54), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 8)); - this.NoSpaceBeforeQuestionMark = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 53), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 8)); - this.SpaceAfterColon = new formatting.Rule(formatting.RuleDescriptor.create3(54, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 2)); - this.SpaceAfterQuestionMarkInConditionalOperator = new formatting.Rule(formatting.RuleDescriptor.create3(53, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsConditionalOperatorContext), 2)); - this.NoSpaceAfterQuestionMark = new formatting.Rule(formatting.RuleDescriptor.create3(53, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); - this.SpaceAfterSemicolon = new formatting.Rule(formatting.RuleDescriptor.create3(23, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); - this.SpaceAfterCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create3(16, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsAfterCodeBlockContext), 2)); - this.SpaceBetweenCloseBraceAndElse = new formatting.Rule(formatting.RuleDescriptor.create1(16, 80), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); - this.SpaceBetweenCloseBraceAndWhile = new formatting.Rule(formatting.RuleDescriptor.create1(16, 104), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); - this.NoSpaceAfterCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create3(16, formatting.Shared.TokenRange.FromTokens([18, 20, 24, 23])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); - this.NoSpaceBeforeDot = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 21), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); - this.NoSpaceAfterDot = new formatting.Rule(formatting.RuleDescriptor.create3(21, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); - this.NoSpaceBeforeOpenBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 19), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); - this.NoSpaceAfterCloseBracket = new formatting.Rule(formatting.RuleDescriptor.create3(20, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBeforeBlockInFunctionDeclarationContext), 8)); - this.FunctionOpenBraceLeftTokenRange = formatting.Shared.TokenRange.AnyIncludingMultilineComments; - this.SpaceBeforeOpenBraceInFunction = new formatting.Rule(formatting.RuleDescriptor.create2(this.FunctionOpenBraceLeftTokenRange, 15), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext, Rules.IsBeforeBlockContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), 2), 1); - this.TypeScriptOpenBraceLeftTokenRange = formatting.Shared.TokenRange.FromTokens([69, 3, 73]); - this.SpaceBeforeOpenBraceInTypeScriptDeclWithBlock = new formatting.Rule(formatting.RuleDescriptor.create2(this.TypeScriptOpenBraceLeftTokenRange, 15), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsTypeScriptDeclWithBlockContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), 2), 1); - this.ControlOpenBraceLeftTokenRange = formatting.Shared.TokenRange.FromTokens([18, 3, 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.NoSpaceBetweenEmptyBraceBrackets = new formatting.Rule(formatting.RuleDescriptor.create1(15, 16), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, 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.NoSpaceAfterUnaryPrefixOperator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.UnaryPrefixOperators, formatting.Shared.TokenRange.UnaryPrefixExpressions), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 8)); - this.NoSpaceAfterUnaryPreincrementOperator = new formatting.Rule(formatting.RuleDescriptor.create3(41, formatting.Shared.TokenRange.UnaryPreincrementExpressions), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); - this.NoSpaceAfterUnaryPredecrementOperator = new formatting.Rule(formatting.RuleDescriptor.create3(42, formatting.Shared.TokenRange.UnaryPredecrementExpressions), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); - this.NoSpaceBeforeUnaryPostincrementOperator = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.UnaryPostincrementExpressions, 41), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); - this.NoSpaceBeforeUnaryPostdecrementOperator = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.UnaryPostdecrementExpressions, 42), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); - this.SpaceAfterPostincrementWhenFollowedByAdd = new formatting.Rule(formatting.RuleDescriptor.create1(41, 35), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2)); - this.SpaceAfterAddWhenFollowedByUnaryPlus = new formatting.Rule(formatting.RuleDescriptor.create1(35, 35), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2)); - this.SpaceAfterAddWhenFollowedByPreincrement = new formatting.Rule(formatting.RuleDescriptor.create1(35, 41), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2)); - this.SpaceAfterPostdecrementWhenFollowedBySubtract = new formatting.Rule(formatting.RuleDescriptor.create1(42, 36), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2)); - this.SpaceAfterSubtractWhenFollowedByUnaryMinus = new formatting.Rule(formatting.RuleDescriptor.create1(36, 36), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2)); - this.SpaceAfterSubtractWhenFollowedByPredecrement = new formatting.Rule(formatting.RuleDescriptor.create1(36, 42), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2)); - this.NoSpaceBeforeComma = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 24), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); - this.SpaceAfterCertainKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([102, 98, 92, 78, 94, 101, 119]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); - this.SpaceAfterLetConstInVariableDeclaration = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([108, 74]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsStartOfVariableDeclarationList), 2)); - this.NoSpaceBeforeOpenParenInFuncCall = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsFunctionCallOrNewContext, Rules.IsPreviousTokenNotComma), 8)); - this.SpaceAfterFunctionInFuncDecl = new formatting.Rule(formatting.RuleDescriptor.create3(87, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2)); - this.NoSpaceBeforeOpenParenInFuncDecl = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsFunctionDeclContext), 8)); - this.SpaceAfterVoidOperator = new formatting.Rule(formatting.RuleDescriptor.create3(103, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsVoidOpContext), 2)); - this.NoSpaceBetweenReturnAndSemicolon = new formatting.Rule(formatting.RuleDescriptor.create1(94, 23), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); - this.SpaceBetweenStatements = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([18, 79, 80, 71]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotForContext), 2)); - this.SpaceAfterTryFinally = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([100, 85]), 15), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); - this.SpaceAfterGetSetInMember = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([123, 129]), 69), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2)); - this.SpaceBeforeBinaryKeywordOperator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.BinaryKeywordOperators), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2)); - this.SpaceAfterBinaryKeywordOperator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.BinaryKeywordOperators, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2)); - this.NoSpaceAfterConstructor = new formatting.Rule(formatting.RuleDescriptor.create1(121, 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); - this.NoSpaceAfterModuleImport = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([125, 127]), 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); - this.SpaceAfterCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([115, 73, 122, 77, 81, 82, 83, 123, 106, 89, 107, 125, 126, 110, 112, 111, 129, 113, 132]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); - this.SpaceBeforeCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([83, 106])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); - this.SpaceAfterModuleName = new formatting.Rule(formatting.RuleDescriptor.create1(9, 15), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsModuleDeclContext), 2)); - this.SpaceAfterArrow = new formatting.Rule(formatting.RuleDescriptor.create3(34, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); - this.NoSpaceAfterEllipsis = new formatting.Rule(formatting.RuleDescriptor.create1(22, 69), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); - this.NoSpaceAfterOptionalParameters = new formatting.Rule(formatting.RuleDescriptor.create3(53, formatting.Shared.TokenRange.FromTokens([18, 24])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 8)); - this.NoSpaceBeforeOpenAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.TypeNames, 25), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), 8)); - this.NoSpaceBetweenCloseParenAndAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create1(18, 25), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), 8)); - this.NoSpaceAfterOpenAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create3(25, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), 8)); - this.NoSpaceBeforeCloseAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 27), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, 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.IsSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), 8)); - this.NoSpaceAfterTypeAssertion = new formatting.Rule(formatting.RuleDescriptor.create3(27, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsTypeAssertionContext), 8)); - this.NoSpaceBetweenEmptyInterfaceBraceBrackets = new formatting.Rule(formatting.RuleDescriptor.create1(15, 16), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsObjectTypeContext), 8)); - this.SpaceBeforeAt = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 55), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); - this.NoSpaceAfterAt = new formatting.Rule(formatting.RuleDescriptor.create3(55, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); - this.SpaceAfterDecorator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([115, 69, 82, 77, 73, 113, 112, 110, 111, 123, 129, 19, 37])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsEndOfDecoratorContextOnSameLine), 2)); - this.NoSpaceBetweenFunctionKeywordAndStar = new formatting.Rule(formatting.RuleDescriptor.create1(87, 37), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclarationOrFunctionExpressionContext), 8)); - this.SpaceAfterStarInGeneratorDeclaration = new formatting.Rule(formatting.RuleDescriptor.create3(37, formatting.Shared.TokenRange.FromTokens([69, 17])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclarationOrFunctionExpressionContext), 2)); - this.NoSpaceBetweenYieldKeywordAndStar = new formatting.Rule(formatting.RuleDescriptor.create1(114, 37), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsYieldOrYieldStarWithOperand), 8)); - this.SpaceBetweenYieldOrYieldStarAndOperand = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([114, 37]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsYieldOrYieldStarWithOperand), 2)); - this.SpaceBetweenAsyncAndOpenParen = new formatting.Rule(formatting.RuleDescriptor.create1(118, 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsArrowFunctionContext, Rules.IsSameLineTokenContext), 2)); - this.SpaceBetweenAsyncAndFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(118, 87), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); - this.SpaceBetweenTagAndTemplateString = new formatting.Rule(formatting.RuleDescriptor.create3(69, formatting.Shared.TokenRange.FromTokens([11, 12])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); - this.NoSpaceAfterTemplateHeadAndMiddle = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([12, 13]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); - this.NoSpaceBeforeTemplateMiddleAndTail = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([13, 14])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); - this.HighPriorityCommonRules = - [ - this.IgnoreBeforeComment, this.IgnoreAfterLineComment, - this.NoSpaceBeforeColon, this.SpaceAfterColon, this.NoSpaceBeforeQuestionMark, this.SpaceAfterQuestionMarkInConditionalOperator, - this.NoSpaceAfterQuestionMark, - this.NoSpaceBeforeDot, this.NoSpaceAfterDot, - this.NoSpaceAfterUnaryPrefixOperator, - this.NoSpaceAfterUnaryPreincrementOperator, this.NoSpaceAfterUnaryPredecrementOperator, - this.NoSpaceBeforeUnaryPostincrementOperator, this.NoSpaceBeforeUnaryPostdecrementOperator, - this.SpaceAfterPostincrementWhenFollowedByAdd, - this.SpaceAfterAddWhenFollowedByUnaryPlus, this.SpaceAfterAddWhenFollowedByPreincrement, - this.SpaceAfterPostdecrementWhenFollowedBySubtract, - this.SpaceAfterSubtractWhenFollowedByUnaryMinus, this.SpaceAfterSubtractWhenFollowedByPredecrement, - this.NoSpaceAfterCloseBrace, - this.SpaceAfterOpenBrace, this.SpaceBeforeCloseBrace, this.NewLineBeforeCloseBraceInBlockContext, - this.SpaceAfterCloseBrace, this.SpaceBetweenCloseBraceAndElse, this.SpaceBetweenCloseBraceAndWhile, this.NoSpaceBetweenEmptyBraceBrackets, - this.NoSpaceBetweenFunctionKeywordAndStar, this.SpaceAfterStarInGeneratorDeclaration, - this.SpaceAfterFunctionInFuncDecl, this.NewLineAfterOpenBraceInBlockContext, this.SpaceAfterGetSetInMember, - this.NoSpaceBetweenYieldKeywordAndStar, this.SpaceBetweenYieldOrYieldStarAndOperand, - this.NoSpaceBetweenReturnAndSemicolon, - this.SpaceAfterCertainKeywords, - this.SpaceAfterLetConstInVariableDeclaration, - this.NoSpaceBeforeOpenParenInFuncCall, - this.SpaceBeforeBinaryKeywordOperator, this.SpaceAfterBinaryKeywordOperator, - this.SpaceAfterVoidOperator, - this.SpaceBetweenAsyncAndOpenParen, this.SpaceBetweenAsyncAndFunctionKeyword, - this.SpaceBetweenTagAndTemplateString, this.NoSpaceAfterTemplateHeadAndMiddle, this.NoSpaceBeforeTemplateMiddleAndTail, - this.NoSpaceAfterConstructor, this.NoSpaceAfterModuleImport, - this.SpaceAfterCertainTypeScriptKeywords, this.SpaceBeforeCertainTypeScriptKeywords, - this.SpaceAfterModuleName, - this.SpaceAfterArrow, - this.NoSpaceAfterEllipsis, - this.NoSpaceAfterOptionalParameters, - this.NoSpaceBetweenEmptyInterfaceBraceBrackets, - this.NoSpaceBeforeOpenAngularBracket, - this.NoSpaceBetweenCloseParenAndAngularBracket, - this.NoSpaceAfterOpenAngularBracket, - this.NoSpaceBeforeCloseAngularBracket, - this.NoSpaceAfterCloseAngularBracket, - this.NoSpaceAfterTypeAssertion, - this.SpaceBeforeAt, - this.NoSpaceAfterAt, - this.SpaceAfterDecorator, - ]; - this.LowPriorityCommonRules = - [ - this.NoSpaceBeforeSemicolon, - this.SpaceBeforeOpenBraceInControl, this.SpaceBeforeOpenBraceInFunction, this.SpaceBeforeOpenBraceInTypeScriptDeclWithBlock, - this.NoSpaceBeforeComma, - this.NoSpaceBeforeOpenBracket, - this.NoSpaceAfterCloseBracket, - this.SpaceAfterSemicolon, - 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.IsSameLineTokenContext), 2)); - this.NoSpaceAfterComma = new formatting.Rule(formatting.RuleDescriptor.create3(24, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); - this.SpaceBeforeBinaryOperator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.BinaryOperators), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, 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.IsSameLineTokenContext, 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.IsSameLineTokenContext, 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.IsSameLineTokenContext, 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.IsSameLineTokenContext, Rules.IsForContext), 2)); - this.NoSpaceAfterSemicolonInFor = new formatting.Rule(formatting.RuleDescriptor.create3(23, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsForContext), 8)); - this.SpaceAfterOpenParen = new formatting.Rule(formatting.RuleDescriptor.create3(17, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); - this.SpaceBeforeCloseParen = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 18), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); - this.NoSpaceBetweenParens = new formatting.Rule(formatting.RuleDescriptor.create1(17, 18), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); - this.NoSpaceAfterOpenParen = new formatting.Rule(formatting.RuleDescriptor.create3(17, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); - this.NoSpaceBeforeCloseParen = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 18), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); - this.SpaceAfterOpenBracket = new formatting.Rule(formatting.RuleDescriptor.create3(19, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); - this.SpaceBeforeCloseBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 20), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); - this.NoSpaceBetweenBrackets = new formatting.Rule(formatting.RuleDescriptor.create1(19, 20), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); - this.NoSpaceAfterOpenBracket = new formatting.Rule(formatting.RuleDescriptor.create3(19, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); - this.NoSpaceBeforeCloseBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 20), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); - this.SpaceAfterAnonymousFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(87, 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2)); - this.NoSpaceAfterAnonymousFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(87, 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 8)); - } - Rules.prototype.getRuleName = function (rule) { - var o = this; - for (var name_31 in o) { - if (o[name_31] === rule) { - return name_31; - } - } - throw new Error("Unknown rule"); - }; - Rules.IsForContext = function (context) { - return context.contextNode.kind === 199; - }; - Rules.IsNotForContext = function (context) { - return !Rules.IsForContext(context); - }; - Rules.IsBinaryOpContext = function (context) { - switch (context.contextNode.kind) { - case 181: - case 182: - case 189: - case 150: - case 158: - case 159: - return true; - case 163: - case 216: - case 221: - case 211: - case 138: - case 247: - case 141: - case 140: - return context.currentTokenSpan.kind === 56 || context.nextTokenSpan.kind === 56; - case 200: - return context.currentTokenSpan.kind === 90 || context.nextTokenSpan.kind === 90; - case 201: - return context.currentTokenSpan.kind === 134 || context.nextTokenSpan.kind === 134; - } - return false; - }; - Rules.IsNotBinaryOpContext = function (context) { - return !Rules.IsBinaryOpContext(context); - }; - Rules.IsConditionalOperatorContext = function (context) { - return context.contextNode.kind === 182; - }; - Rules.IsSameLineTokenOrBeforeMultilineBlockContext = function (context) { - return context.TokensAreOnSameLine() || Rules.IsBeforeMultilineBlockContext(context); - }; - Rules.IsBeforeMultilineBlockContext = function (context) { - return Rules.IsBeforeBlockContext(context) && !(context.NextNodeAllOnSameLine() || context.NextNodeBlockIsOnOneLine()); - }; - Rules.IsMultilineBlockContext = function (context) { - return Rules.IsBlockContext(context) && !(context.ContextNodeAllOnSameLine() || context.ContextNodeBlockIsOnOneLine()); - }; - Rules.IsSingleLineBlockContext = function (context) { - return Rules.IsBlockContext(context) && (context.ContextNodeAllOnSameLine() || context.ContextNodeBlockIsOnOneLine()); - }; - Rules.IsBlockContext = function (context) { - return Rules.NodeIsBlockContext(context.contextNode); - }; - Rules.IsBeforeBlockContext = function (context) { - return Rules.NodeIsBlockContext(context.nextTokenParent); - }; - Rules.NodeIsBlockContext = function (node) { - if (Rules.NodeIsTypeScriptDeclWithBlockContext(node)) { - return true; - } - switch (node.kind) { - case 192: - case 220: - case 165: - case 219: - return true; - } - return false; - }; - Rules.IsFunctionDeclContext = function (context) { - switch (context.contextNode.kind) { - case 213: - case 143: - case 142: - case 145: - case 146: - case 147: - case 173: - case 144: - case 174: - case 215: - return true; - } - return false; - }; - Rules.IsFunctionDeclarationOrFunctionExpressionContext = function (context) { - return context.contextNode.kind === 213 || context.contextNode.kind === 173; - }; - Rules.IsTypeScriptDeclWithBlockContext = function (context) { - return Rules.NodeIsTypeScriptDeclWithBlockContext(context.contextNode); - }; - Rules.NodeIsTypeScriptDeclWithBlockContext = function (node) { - switch (node.kind) { - case 214: - case 186: - case 215: - case 217: - case 155: - case 218: - return true; - } - return false; - }; - Rules.IsAfterCodeBlockContext = function (context) { - switch (context.currentTokenParent.kind) { - case 214: - case 218: - case 217: - case 192: - case 244: - case 219: - case 206: - return true; - } - return false; - }; - Rules.IsControlDeclContext = function (context) { - switch (context.contextNode.kind) { - case 196: - case 206: - case 199: - case 200: - case 201: - case 198: - case 209: - case 197: - case 205: - case 244: - return true; - default: - return false; - } - }; - Rules.IsObjectContext = function (context) { - return context.contextNode.kind === 165; - }; - Rules.IsFunctionCallContext = function (context) { - return context.contextNode.kind === 168; - }; - Rules.IsNewContext = function (context) { - return context.contextNode.kind === 169; - }; - Rules.IsFunctionCallOrNewContext = function (context) { - return Rules.IsFunctionCallContext(context) || Rules.IsNewContext(context); - }; - Rules.IsPreviousTokenNotComma = function (context) { - return context.currentTokenSpan.kind !== 24; - }; - Rules.IsArrowFunctionContext = function (context) { - return context.contextNode.kind === 174; - }; - Rules.IsSameLineTokenContext = function (context) { - return context.TokensAreOnSameLine(); - }; - Rules.IsNotBeforeBlockInFunctionDeclarationContext = function (context) { - return !Rules.IsFunctionDeclContext(context) && !Rules.IsBeforeBlockContext(context); - }; - Rules.IsEndOfDecoratorContextOnSameLine = function (context) { - return context.TokensAreOnSameLine() && - context.contextNode.decorators && - Rules.NodeIsInDecoratorContext(context.currentTokenParent) && - !Rules.NodeIsInDecoratorContext(context.nextTokenParent); - }; - Rules.NodeIsInDecoratorContext = function (node) { - while (ts.isExpression(node)) { - node = node.parent; - } - return node.kind === 139; - }; - Rules.IsStartOfVariableDeclarationList = function (context) { - return context.currentTokenParent.kind === 212 && - context.currentTokenParent.getStart(context.sourceFile) === context.currentTokenSpan.pos; - }; - Rules.IsNotFormatOnEnter = function (context) { - return context.formattingRequestKind !== 2; - }; - Rules.IsModuleDeclContext = function (context) { - return context.contextNode.kind === 218; - }; - Rules.IsObjectTypeContext = function (context) { - return context.contextNode.kind === 155; - }; - Rules.IsTypeArgumentOrParameterOrAssertion = function (token, parent) { - if (token.kind !== 25 && token.kind !== 27) { - return false; - } - switch (parent.kind) { - case 151: - case 171: - case 214: - case 186: - case 215: - case 213: - case 173: - case 174: - case 143: - case 142: - case 147: - case 148: - case 168: - case 169: - case 188: - return true; - default: - return false; - } - }; - Rules.IsTypeArgumentOrParameterOrAssertionContext = function (context) { - return Rules.IsTypeArgumentOrParameterOrAssertion(context.currentTokenSpan, context.currentTokenParent) || - Rules.IsTypeArgumentOrParameterOrAssertion(context.nextTokenSpan, context.nextTokenParent); - }; - Rules.IsTypeAssertionContext = function (context) { - return context.contextNode.kind === 171; - }; - Rules.IsVoidOpContext = function (context) { - return context.currentTokenSpan.kind === 103 && context.currentTokenParent.kind === 177; - }; - Rules.IsYieldOrYieldStarWithOperand = function (context) { - return context.contextNode.kind === 184 && context.contextNode.expression !== undefined; - }; - return Rules; - })(); - formatting.Rules = Rules; - })(formatting = ts.formatting || (ts.formatting = {})); -})(ts || (ts = {})); -var ts; -(function (ts) { - var formatting; - (function (formatting) { - var RulesMap = (function () { - function RulesMap() { - this.map = []; - this.mapRowLength = 0; - } - RulesMap.create = function (rules) { - var result = new RulesMap(); - result.Initialize(rules); - return result; - }; - RulesMap.prototype.Initialize = function (rules) { - this.mapRowLength = 134 + 1; - this.map = new Array(this.mapRowLength * this.mapRowLength); - var rulesBucketConstructionStateList = new Array(this.map.length); - this.FillRules(rules, rulesBucketConstructionStateList); - return this.map; - }; - RulesMap.prototype.FillRules = function (rules, rulesBucketConstructionStateList) { - var _this = this; - rules.forEach(function (rule) { - _this.FillRule(rule, rulesBucketConstructionStateList); - }); - }; - RulesMap.prototype.GetRuleBucketIndex = function (row, column) { - var rulesBucketIndex = (row * this.mapRowLength) + column; - return rulesBucketIndex; - }; - RulesMap.prototype.FillRule = function (rule, rulesBucketConstructionStateList) { - var _this = this; - var specificRule = rule.Descriptor.LeftTokenRange !== formatting.Shared.TokenRange.Any && - rule.Descriptor.RightTokenRange !== formatting.Shared.TokenRange.Any; - rule.Descriptor.LeftTokenRange.GetTokens().forEach(function (left) { - rule.Descriptor.RightTokenRange.GetTokens().forEach(function (right) { - var rulesBucketIndex = _this.GetRuleBucketIndex(left, right); - var rulesBucket = _this.map[rulesBucketIndex]; - if (rulesBucket === undefined) { - rulesBucket = _this.map[rulesBucketIndex] = new RulesBucket(); - } - rulesBucket.AddRule(rule, specificRule, rulesBucketConstructionStateList, rulesBucketIndex); - }); - }); - }; - RulesMap.prototype.GetRule = function (context) { - var bucketIndex = this.GetRuleBucketIndex(context.currentTokenSpan.kind, context.nextTokenSpan.kind); - var bucket = this.map[bucketIndex]; - if (bucket != null) { - for (var _i = 0, _a = bucket.Rules(); _i < _a.length; _i++) { - var rule = _a[_i]; - if (rule.Operation.Context.InContext(context)) { - return rule; - } - } - } - return null; - }; - return RulesMap; - })(); - formatting.RulesMap = RulesMap; - var MaskBitSize = 5; - var Mask = 0x1f; - (function (RulesPosition) { - RulesPosition[RulesPosition["IgnoreRulesSpecific"] = 0] = "IgnoreRulesSpecific"; - RulesPosition[RulesPosition["IgnoreRulesAny"] = MaskBitSize * 1] = "IgnoreRulesAny"; - RulesPosition[RulesPosition["ContextRulesSpecific"] = MaskBitSize * 2] = "ContextRulesSpecific"; - RulesPosition[RulesPosition["ContextRulesAny"] = MaskBitSize * 3] = "ContextRulesAny"; - RulesPosition[RulesPosition["NoContextRulesSpecific"] = MaskBitSize * 4] = "NoContextRulesSpecific"; - RulesPosition[RulesPosition["NoContextRulesAny"] = MaskBitSize * 5] = "NoContextRulesAny"; - })(formatting.RulesPosition || (formatting.RulesPosition = {})); - var RulesPosition = formatting.RulesPosition; - var RulesBucketConstructionState = (function () { - function RulesBucketConstructionState() { - this.rulesInsertionIndexBitmap = 0; - } - RulesBucketConstructionState.prototype.GetInsertionIndex = function (maskPosition) { - var index = 0; - var pos = 0; - var indexBitmap = this.rulesInsertionIndexBitmap; - while (pos <= maskPosition) { - index += (indexBitmap & Mask); - indexBitmap >>= MaskBitSize; - pos += MaskBitSize; - } - return index; - }; - RulesBucketConstructionState.prototype.IncreaseInsertionIndex = function (maskPosition) { - var value = (this.rulesInsertionIndexBitmap >> maskPosition) & Mask; - value++; - ts.Debug.assert((value & Mask) === value, "Adding more rules into the sub-bucket than allowed. Maximum allowed is 32 rules."); - var temp = this.rulesInsertionIndexBitmap & ~(Mask << maskPosition); - temp |= value << maskPosition; - this.rulesInsertionIndexBitmap = temp; - }; - return RulesBucketConstructionState; - })(); - formatting.RulesBucketConstructionState = RulesBucketConstructionState; - var RulesBucket = (function () { - function RulesBucket() { - this.rules = []; - } - RulesBucket.prototype.Rules = function () { - return this.rules; - }; - RulesBucket.prototype.AddRule = function (rule, specificTokens, constructionState, rulesBucketIndex) { - var position; - if (rule.Operation.Action === 1) { - position = specificTokens ? - RulesPosition.IgnoreRulesSpecific : - RulesPosition.IgnoreRulesAny; - } - else if (!rule.Operation.Context.IsAny()) { - position = specificTokens ? - RulesPosition.ContextRulesSpecific : - RulesPosition.ContextRulesAny; - } - else { - position = specificTokens ? - RulesPosition.NoContextRulesSpecific : - RulesPosition.NoContextRulesAny; - } - var state = constructionState[rulesBucketIndex]; - if (state === undefined) { - state = constructionState[rulesBucketIndex] = new RulesBucketConstructionState(); - } - var index = state.GetInsertionIndex(position); - this.rules.splice(index, 0, rule); - state.IncreaseInsertionIndex(position); - }; - return RulesBucket; - })(); - formatting.RulesBucket = RulesBucket; - })(formatting = ts.formatting || (ts.formatting = {})); -})(ts || (ts = {})); -var ts; -(function (ts) { - var formatting; - (function (formatting) { - var Shared; - (function (Shared) { - var TokenRangeAccess = (function () { - function TokenRangeAccess(from, to, except) { - this.tokens = []; - for (var token = from; token <= to; token++) { - if (except.indexOf(token) < 0) { - this.tokens.push(token); - } - } - } - TokenRangeAccess.prototype.GetTokens = function () { - return this.tokens; - }; - TokenRangeAccess.prototype.Contains = function (token) { - return this.tokens.indexOf(token) >= 0; - }; - return TokenRangeAccess; - })(); - Shared.TokenRangeAccess = TokenRangeAccess; - var TokenValuesAccess = (function () { - function TokenValuesAccess(tks) { - this.tokens = tks && tks.length ? tks : []; - } - TokenValuesAccess.prototype.GetTokens = function () { - return this.tokens; - }; - TokenValuesAccess.prototype.Contains = function (token) { - return this.tokens.indexOf(token) >= 0; - }; - return TokenValuesAccess; - })(); - Shared.TokenValuesAccess = TokenValuesAccess; - var TokenSingleValueAccess = (function () { - function TokenSingleValueAccess(token) { - this.token = token; - } - TokenSingleValueAccess.prototype.GetTokens = function () { - return [this.token]; - }; - TokenSingleValueAccess.prototype.Contains = function (tokenValue) { - return tokenValue === this.token; - }; - return TokenSingleValueAccess; - })(); - Shared.TokenSingleValueAccess = TokenSingleValueAccess; - var TokenAllAccess = (function () { - function TokenAllAccess() { - } - TokenAllAccess.prototype.GetTokens = function () { - var result = []; - for (var token = 0; token <= 134; token++) { - result.push(token); - } - return result; - }; - TokenAllAccess.prototype.Contains = function (tokenValue) { - return true; - }; - TokenAllAccess.prototype.toString = function () { - return "[allTokens]"; - }; - return TokenAllAccess; - })(); - Shared.TokenAllAccess = TokenAllAccess; - var TokenRange = (function () { - function TokenRange(tokenAccess) { - this.tokenAccess = tokenAccess; - } - TokenRange.FromToken = function (token) { - return new TokenRange(new TokenSingleValueAccess(token)); - }; - TokenRange.FromTokens = function (tokens) { - return new TokenRange(new TokenValuesAccess(tokens)); - }; - TokenRange.FromRange = function (f, to, except) { - if (except === void 0) { except = []; } - return new TokenRange(new TokenRangeAccess(f, to, except)); - }; - TokenRange.AllTokens = function () { - return new TokenRange(new TokenAllAccess()); - }; - TokenRange.prototype.GetTokens = function () { - return this.tokenAccess.GetTokens(); - }; - TokenRange.prototype.Contains = function (token) { - return this.tokenAccess.Contains(token); - }; - TokenRange.prototype.toString = function () { - return this.tokenAccess.toString(); - }; - TokenRange.Any = TokenRange.AllTokens(); - TokenRange.AnyIncludingMultilineComments = TokenRange.FromTokens(TokenRange.Any.GetTokens().concat([3])); - TokenRange.Keywords = TokenRange.FromRange(70, 134); - TokenRange.BinaryOperators = TokenRange.FromRange(25, 68); - TokenRange.BinaryKeywordOperators = TokenRange.FromTokens([90, 91, 134, 116, 124]); - TokenRange.UnaryPrefixOperators = TokenRange.FromTokens([41, 42, 50, 49]); - TokenRange.UnaryPrefixExpressions = TokenRange.FromTokens([8, 69, 17, 19, 15, 97, 92]); - TokenRange.UnaryPreincrementExpressions = TokenRange.FromTokens([69, 17, 97, 92]); - TokenRange.UnaryPostincrementExpressions = TokenRange.FromTokens([69, 18, 20, 92]); - TokenRange.UnaryPredecrementExpressions = TokenRange.FromTokens([69, 17, 97, 92]); - TokenRange.UnaryPostdecrementExpressions = TokenRange.FromTokens([69, 18, 20, 92]); - TokenRange.Comments = TokenRange.FromTokens([2, 3]); - TokenRange.TypeNames = TokenRange.FromTokens([69, 128, 130, 120, 131, 103, 117]); - return TokenRange; - })(); - Shared.TokenRange = TokenRange; - })(Shared = formatting.Shared || (formatting.Shared = {})); - })(formatting = ts.formatting || (ts.formatting = {})); -})(ts || (ts = {})); -var ts; -(function (ts) { - var formatting; - (function (formatting) { - var RulesProvider = (function () { - function RulesProvider() { - this.globalRules = new formatting.Rules(); - } - RulesProvider.prototype.getRuleName = function (rule) { - return this.globalRules.getRuleName(rule); - }; - RulesProvider.prototype.getRuleByName = function (name) { - return this.globalRules[name]; - }; - RulesProvider.prototype.getRulesMap = function () { - return this.rulesMap; - }; - RulesProvider.prototype.ensureUpToDate = function (options) { - if (this.options == null || !ts.compareDataObjects(this.options, options)) { - var activeRules = this.createActiveRules(options); - var rulesMap = formatting.RulesMap.create(activeRules); - this.activeRules = activeRules; - this.rulesMap = rulesMap; - this.options = ts.clone(options); - } - }; - RulesProvider.prototype.createActiveRules = function (options) { - var rules = this.globalRules.HighPriorityCommonRules.slice(0); - if (options.InsertSpaceAfterCommaDelimiter) { - rules.push(this.globalRules.SpaceAfterComma); - } - else { - rules.push(this.globalRules.NoSpaceAfterComma); - } - if (options.InsertSpaceAfterFunctionKeywordForAnonymousFunctions) { - rules.push(this.globalRules.SpaceAfterAnonymousFunctionKeyword); - } - else { - rules.push(this.globalRules.NoSpaceAfterAnonymousFunctionKeyword); - } - if (options.InsertSpaceAfterKeywordsInControlFlowStatements) { - rules.push(this.globalRules.SpaceAfterKeywordInControl); - } - else { - rules.push(this.globalRules.NoSpaceAfterKeywordInControl); - } - if (options.InsertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis) { - rules.push(this.globalRules.SpaceAfterOpenParen); - rules.push(this.globalRules.SpaceBeforeCloseParen); - rules.push(this.globalRules.NoSpaceBetweenParens); - } - else { - rules.push(this.globalRules.NoSpaceAfterOpenParen); - rules.push(this.globalRules.NoSpaceBeforeCloseParen); - rules.push(this.globalRules.NoSpaceBetweenParens); - } - if (options.InsertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets) { - rules.push(this.globalRules.SpaceAfterOpenBracket); - rules.push(this.globalRules.SpaceBeforeCloseBracket); - rules.push(this.globalRules.NoSpaceBetweenBrackets); - } - else { - rules.push(this.globalRules.NoSpaceAfterOpenBracket); - rules.push(this.globalRules.NoSpaceBeforeCloseBracket); - rules.push(this.globalRules.NoSpaceBetweenBrackets); - } - if (options.InsertSpaceAfterSemicolonInForStatements) { - rules.push(this.globalRules.SpaceAfterSemicolonInFor); - } - else { - rules.push(this.globalRules.NoSpaceAfterSemicolonInFor); - } - if (options.InsertSpaceBeforeAndAfterBinaryOperators) { - rules.push(this.globalRules.SpaceBeforeBinaryOperator); - rules.push(this.globalRules.SpaceAfterBinaryOperator); - } - else { - rules.push(this.globalRules.NoSpaceBeforeBinaryOperator); - rules.push(this.globalRules.NoSpaceAfterBinaryOperator); - } - if (options.PlaceOpenBraceOnNewLineForControlBlocks) { - rules.push(this.globalRules.NewLineBeforeOpenBraceInControl); - } - if (options.PlaceOpenBraceOnNewLineForFunctions) { - rules.push(this.globalRules.NewLineBeforeOpenBraceInFunction); - rules.push(this.globalRules.NewLineBeforeOpenBraceInTypeScriptDeclWithBlock); - } - rules = rules.concat(this.globalRules.LowPriorityCommonRules); - return rules; - }; - return RulesProvider; - })(); - formatting.RulesProvider = RulesProvider; - })(formatting = ts.formatting || (ts.formatting = {})); -})(ts || (ts = {})); -var ts; -(function (ts) { - var formatting; - (function (formatting) { - function formatOnEnter(position, sourceFile, rulesProvider, options) { - var line = sourceFile.getLineAndCharacterOfPosition(position).line; - if (line === 0) { - return []; - } - var span = { - pos: ts.getStartPositionOfLine(line - 1, sourceFile), - end: ts.getEndLinePosition(line, sourceFile) + 1 - }; - return formatSpan(span, sourceFile, options, rulesProvider, 2); - } - formatting.formatOnEnter = formatOnEnter; - function formatOnSemicolon(position, sourceFile, rulesProvider, options) { - return formatOutermostParent(position, 23, sourceFile, options, rulesProvider, 3); - } - formatting.formatOnSemicolon = formatOnSemicolon; - function formatOnClosingCurly(position, sourceFile, rulesProvider, options) { - return formatOutermostParent(position, 16, sourceFile, options, rulesProvider, 4); - } - formatting.formatOnClosingCurly = formatOnClosingCurly; - function formatDocument(sourceFile, rulesProvider, options) { - var span = { - pos: 0, - end: sourceFile.text.length - }; - return formatSpan(span, sourceFile, options, rulesProvider, 0); - } - formatting.formatDocument = formatDocument; - function formatSelection(start, end, sourceFile, rulesProvider, options) { - var span = { - pos: ts.getLineStartPositionForPosition(start, sourceFile), - end: end - }; - return formatSpan(span, sourceFile, options, rulesProvider, 1); - } - formatting.formatSelection = formatSelection; - function formatOutermostParent(position, expectedLastToken, sourceFile, options, rulesProvider, requestKind) { - var parent = findOutermostParent(position, expectedLastToken, sourceFile); - if (!parent) { - return []; - } - var span = { - pos: ts.getLineStartPositionForPosition(parent.getStart(sourceFile), sourceFile), - end: parent.end - }; - return formatSpan(span, sourceFile, options, rulesProvider, requestKind); - } - function findOutermostParent(position, expectedTokenKind, sourceFile) { - var precedingToken = ts.findPrecedingToken(position, sourceFile); - if (!precedingToken || - precedingToken.kind !== expectedTokenKind || - position !== precedingToken.getEnd()) { - return undefined; - } - var current = precedingToken; - while (current && - current.parent && - current.parent.end === precedingToken.end && - !isListElement(current.parent, current)) { - current = current.parent; - } - return current; - } - function isListElement(parent, node) { - switch (parent.kind) { - case 214: - case 215: - return ts.rangeContainsRange(parent.members, node); - case 218: - var body = parent.body; - return body && body.kind === 192 && ts.rangeContainsRange(body.statements, node); - case 248: - case 192: - case 219: - return ts.rangeContainsRange(parent.statements, node); - case 244: - return ts.rangeContainsRange(parent.block.statements, node); - } - return false; - } - function findEnclosingNode(range, sourceFile) { - return find(sourceFile); - function find(n) { - var candidate = ts.forEachChild(n, function (c) { return ts.startEndContainsRange(c.getStart(sourceFile), c.end, range) && c; }); - if (candidate) { - var result = find(candidate); - if (result) { - return result; - } - } - return n; - } - } - function prepareRangeContainsErrorFunction(errors, originalRange) { - if (!errors.length) { - return rangeHasNoErrors; - } - var sorted = errors - .filter(function (d) { return ts.rangeOverlapsWithStartEnd(originalRange, d.start, d.start + d.length); }) - .sort(function (e1, e2) { return e1.start - e2.start; }); - if (!sorted.length) { - return rangeHasNoErrors; - } - var index = 0; - return function (r) { - while (true) { - if (index >= sorted.length) { - return false; - } - var error = sorted[index]; - if (r.end <= error.start) { - return false; - } - if (ts.startEndOverlapsWithStartEnd(r.pos, r.end, error.start, error.start + error.length)) { - return true; - } - index++; - } - }; - function rangeHasNoErrors(r) { - return false; - } - } - function getScanStartPosition(enclosingNode, originalRange, sourceFile) { - var start = enclosingNode.getStart(sourceFile); - if (start === originalRange.pos && enclosingNode.end === originalRange.end) { - return start; - } - var precedingToken = ts.findPrecedingToken(originalRange.pos, sourceFile); - if (!precedingToken) { - return enclosingNode.pos; - } - if (precedingToken.end >= originalRange.pos) { - return enclosingNode.pos; - } - return precedingToken.end; - } - function getOwnOrInheritedDelta(n, options, sourceFile) { - var previousLine = -1; - var childKind = 0; - while (n) { - var line = sourceFile.getLineAndCharacterOfPosition(n.getStart(sourceFile)).line; - if (previousLine !== -1 && line !== previousLine) { - break; - } - if (formatting.SmartIndenter.shouldIndentChildNode(n.kind, childKind)) { - return options.IndentSize; - } - previousLine = line; - childKind = n.kind; - n = n.parent; - } - return 0; - } - function formatSpan(originalRange, sourceFile, options, rulesProvider, requestKind) { - var rangeContainsError = prepareRangeContainsErrorFunction(sourceFile.parseDiagnostics, originalRange); - var formattingContext = new formatting.FormattingContext(sourceFile, requestKind); - var enclosingNode = findEnclosingNode(originalRange, sourceFile); - var formattingScanner = formatting.getFormattingScanner(sourceFile, getScanStartPosition(enclosingNode, originalRange, sourceFile), originalRange.end); - var initialIndentation = formatting.SmartIndenter.getIndentationForNode(enclosingNode, originalRange, sourceFile, options); - var previousRangeHasError; - var previousRange; - var previousParent; - var previousRangeStartLine; - var lastIndentedLine; - var indentationOnLastIndentedLine; - var edits = []; - formattingScanner.advance(); - if (formattingScanner.isOnToken()) { - var startLine = sourceFile.getLineAndCharacterOfPosition(enclosingNode.getStart(sourceFile)).line; - var undecoratedStartLine = startLine; - if (enclosingNode.decorators) { - undecoratedStartLine = sourceFile.getLineAndCharacterOfPosition(ts.getNonDecoratorTokenPosOfNode(enclosingNode, sourceFile)).line; - } - var delta = getOwnOrInheritedDelta(enclosingNode, options, sourceFile); - processNode(enclosingNode, enclosingNode, startLine, undecoratedStartLine, initialIndentation, delta); - } - formattingScanner.close(); - return edits; - function tryComputeIndentationForListItem(startPos, endPos, parentStartLine, range, inheritedIndentation) { - if (ts.rangeOverlapsWithStartEnd(range, startPos, endPos)) { - if (inheritedIndentation !== -1) { - return inheritedIndentation; - } - } - else { - var startLine = sourceFile.getLineAndCharacterOfPosition(startPos).line; - var startLinePosition = ts.getLineStartPositionForPosition(startPos, sourceFile); - var column = formatting.SmartIndenter.findFirstNonWhitespaceColumn(startLinePosition, startPos, sourceFile, options); - if (startLine !== parentStartLine || startPos === column) { - return column; - } - } - return -1; - } - function computeIndentation(node, startLine, inheritedIndentation, parent, parentDynamicIndentation, effectiveParentStartLine) { - var indentation = inheritedIndentation; - if (indentation === -1) { - if (isSomeBlock(node.kind)) { - if (isSomeBlock(parent.kind) || - parent.kind === 248 || - parent.kind === 241 || - parent.kind === 242) { - indentation = parentDynamicIndentation.getIndentation() + parentDynamicIndentation.getDelta(); - } - else { - indentation = parentDynamicIndentation.getIndentation(); - } - } - else { - if (formatting.SmartIndenter.childStartsOnTheSameLineWithElseInIfStatement(parent, node, startLine, sourceFile)) { - indentation = parentDynamicIndentation.getIndentation(); - } - else { - indentation = parentDynamicIndentation.getIndentation() + parentDynamicIndentation.getDelta(); - } - } - } - var delta = formatting.SmartIndenter.shouldIndentChildNode(node.kind, 0) ? options.IndentSize : 0; - if (effectiveParentStartLine === startLine) { - indentation = startLine === lastIndentedLine - ? indentationOnLastIndentedLine - : parentDynamicIndentation.getIndentation(); - delta = Math.min(options.IndentSize, parentDynamicIndentation.getDelta() + delta); - } - return { - indentation: indentation, - delta: delta - }; - } - function getFirstNonDecoratorTokenOfNode(node) { - if (node.modifiers && node.modifiers.length) { - return node.modifiers[0].kind; - } - switch (node.kind) { - case 214: return 73; - case 215: return 107; - case 213: return 87; - case 217: return 217; - case 145: return 123; - case 146: return 129; - case 143: - if (node.asteriskToken) { - return 37; - } - case 141: - case 138: - return node.name.kind; - } - } - function getDynamicIndentation(node, nodeStartLine, indentation, delta) { - return { - getIndentationForComment: function (kind, tokenIndentation) { - switch (kind) { - case 16: - case 20: - case 18: - return indentation + delta; - } - return tokenIndentation !== -1 ? tokenIndentation : indentation; - }, - getIndentationForToken: function (line, kind) { - if (nodeStartLine !== line && node.decorators) { - if (kind === getFirstNonDecoratorTokenOfNode(node)) { - return indentation; - } - } - switch (kind) { - case 15: - case 16: - case 19: - case 20: - case 17: - case 18: - case 80: - case 104: - case 55: - return indentation; - default: - return nodeStartLine !== line ? indentation + delta : indentation; - } - }, - getIndentation: function () { return indentation; }, - getDelta: function () { return delta; }, - recomputeIndentation: function (lineAdded) { - if (node.parent && formatting.SmartIndenter.shouldIndentChildNode(node.parent.kind, node.kind)) { - if (lineAdded) { - indentation += options.IndentSize; - } - else { - indentation -= options.IndentSize; - } - if (formatting.SmartIndenter.shouldIndentChildNode(node.kind, 0)) { - delta = options.IndentSize; - } - else { - delta = 0; - } - } - } - }; - } - function processNode(node, contextNode, nodeStartLine, undecoratedNodeStartLine, indentation, delta) { - if (!ts.rangeOverlapsWithStartEnd(originalRange, node.getStart(sourceFile), node.getEnd())) { - return; - } - var nodeDynamicIndentation = getDynamicIndentation(node, nodeStartLine, indentation, delta); - var childContextNode = contextNode; - ts.forEachChild(node, function (child) { - processChildNode(child, -1, node, nodeDynamicIndentation, nodeStartLine, undecoratedNodeStartLine, false); - }, function (nodes) { - processChildNodes(nodes, node, nodeStartLine, nodeDynamicIndentation); - }); - while (formattingScanner.isOnToken()) { - var tokenInfo = formattingScanner.readTokenInfo(node); - if (tokenInfo.token.end > node.end) { - break; - } - consumeTokenAndAdvanceScanner(tokenInfo, node, nodeDynamicIndentation); - } - function processChildNode(child, inheritedIndentation, parent, parentDynamicIndentation, parentStartLine, undecoratedParentStartLine, isListItem) { - var childStartPos = child.getStart(sourceFile); - var childStartLine = sourceFile.getLineAndCharacterOfPosition(childStartPos).line; - var undecoratedChildStartLine = childStartLine; - if (child.decorators) { - undecoratedChildStartLine = sourceFile.getLineAndCharacterOfPosition(ts.getNonDecoratorTokenPosOfNode(child, sourceFile)).line; - } - var childIndentationAmount = -1; - if (isListItem) { - childIndentationAmount = tryComputeIndentationForListItem(childStartPos, child.end, parentStartLine, originalRange, inheritedIndentation); - if (childIndentationAmount !== -1) { - inheritedIndentation = childIndentationAmount; - } - } - if (!ts.rangeOverlapsWithStartEnd(originalRange, child.pos, child.end)) { - return inheritedIndentation; - } - if (child.getFullWidth() === 0) { - return inheritedIndentation; - } - while (formattingScanner.isOnToken()) { - var tokenInfo = formattingScanner.readTokenInfo(node); - if (tokenInfo.token.end > childStartPos) { - break; - } - consumeTokenAndAdvanceScanner(tokenInfo, node, parentDynamicIndentation); - } - if (!formattingScanner.isOnToken()) { - return inheritedIndentation; - } - if (ts.isToken(child)) { - var tokenInfo = formattingScanner.readTokenInfo(child); - ts.Debug.assert(tokenInfo.token.end === child.end); - consumeTokenAndAdvanceScanner(tokenInfo, node, parentDynamicIndentation); - return inheritedIndentation; - } - var effectiveParentStartLine = child.kind === 139 ? childStartLine : undecoratedParentStartLine; - var childIndentation = computeIndentation(child, childStartLine, childIndentationAmount, node, parentDynamicIndentation, effectiveParentStartLine); - processNode(child, childContextNode, childStartLine, undecoratedChildStartLine, childIndentation.indentation, childIndentation.delta); - childContextNode = node; - return inheritedIndentation; - } - function processChildNodes(nodes, parent, parentStartLine, parentDynamicIndentation) { - var listStartToken = getOpenTokenForList(parent, nodes); - var listEndToken = getCloseTokenForOpenToken(listStartToken); - var listDynamicIndentation = parentDynamicIndentation; - var startLine = parentStartLine; - if (listStartToken !== 0) { - while (formattingScanner.isOnToken()) { - var tokenInfo = formattingScanner.readTokenInfo(parent); - if (tokenInfo.token.end > nodes.pos) { - break; - } - else if (tokenInfo.token.kind === listStartToken) { - startLine = sourceFile.getLineAndCharacterOfPosition(tokenInfo.token.pos).line; - var indentation_1 = computeIndentation(tokenInfo.token, startLine, -1, parent, parentDynamicIndentation, parentStartLine); - listDynamicIndentation = getDynamicIndentation(parent, parentStartLine, indentation_1.indentation, indentation_1.delta); - consumeTokenAndAdvanceScanner(tokenInfo, parent, listDynamicIndentation); - } - else { - consumeTokenAndAdvanceScanner(tokenInfo, parent, parentDynamicIndentation); - } - } - } - var inheritedIndentation = -1; - for (var _i = 0; _i < nodes.length; _i++) { - var child = nodes[_i]; - inheritedIndentation = processChildNode(child, inheritedIndentation, node, listDynamicIndentation, startLine, startLine, true); - } - if (listEndToken !== 0) { - if (formattingScanner.isOnToken()) { - var tokenInfo = formattingScanner.readTokenInfo(parent); - if (tokenInfo.token.kind === listEndToken && ts.rangeContainsRange(parent, tokenInfo.token)) { - consumeTokenAndAdvanceScanner(tokenInfo, parent, listDynamicIndentation); - } - } - } - } - function consumeTokenAndAdvanceScanner(currentTokenInfo, parent, dynamicIndentation) { - ts.Debug.assert(ts.rangeContainsRange(parent, currentTokenInfo.token)); - var lastTriviaWasNewLine = formattingScanner.lastTrailingTriviaWasNewLine(); - var indentToken = false; - if (currentTokenInfo.leadingTrivia) { - processTrivia(currentTokenInfo.leadingTrivia, parent, childContextNode, dynamicIndentation); - } - var lineAdded; - var isTokenInRange = ts.rangeContainsRange(originalRange, currentTokenInfo.token); - var tokenStart = sourceFile.getLineAndCharacterOfPosition(currentTokenInfo.token.pos); - if (isTokenInRange) { - var rangeHasError = rangeContainsError(currentTokenInfo.token); - var savePreviousRange = previousRange; - lineAdded = processRange(currentTokenInfo.token, tokenStart, parent, childContextNode, dynamicIndentation); - if (rangeHasError) { - indentToken = false; - } - else { - if (lineAdded !== undefined) { - indentToken = lineAdded; - } - else { - var prevEndLine = savePreviousRange && sourceFile.getLineAndCharacterOfPosition(savePreviousRange.end).line; - indentToken = lastTriviaWasNewLine && tokenStart.line !== prevEndLine; - } - } - } - if (currentTokenInfo.trailingTrivia) { - processTrivia(currentTokenInfo.trailingTrivia, parent, childContextNode, dynamicIndentation); - } - if (indentToken) { - var tokenIndentation = (isTokenInRange && !rangeContainsError(currentTokenInfo.token)) ? - dynamicIndentation.getIndentationForToken(tokenStart.line, currentTokenInfo.token.kind) : - -1; - if (currentTokenInfo.leadingTrivia) { - var commentIndentation = dynamicIndentation.getIndentationForComment(currentTokenInfo.token.kind, tokenIndentation); - var indentNextTokenOrTrivia = true; - for (var _i = 0, _a = currentTokenInfo.leadingTrivia; _i < _a.length; _i++) { - var triviaItem = _a[_i]; - if (!ts.rangeContainsRange(originalRange, triviaItem)) { - continue; - } - switch (triviaItem.kind) { - case 3: - indentMultilineComment(triviaItem, commentIndentation, !indentNextTokenOrTrivia); - indentNextTokenOrTrivia = false; - break; - case 2: - if (indentNextTokenOrTrivia) { - insertIndentation(triviaItem.pos, commentIndentation, false); - indentNextTokenOrTrivia = false; - } - break; - case 4: - indentNextTokenOrTrivia = true; - break; - } - } - } - if (tokenIndentation !== -1) { - insertIndentation(currentTokenInfo.token.pos, tokenIndentation, lineAdded); - lastIndentedLine = tokenStart.line; - indentationOnLastIndentedLine = tokenIndentation; - } - } - formattingScanner.advance(); - childContextNode = parent; - } - } - function processTrivia(trivia, parent, contextNode, dynamicIndentation) { - for (var _i = 0; _i < trivia.length; _i++) { - var triviaItem = trivia[_i]; - if (ts.isComment(triviaItem.kind) && ts.rangeContainsRange(originalRange, triviaItem)) { - var triviaItemStart = sourceFile.getLineAndCharacterOfPosition(triviaItem.pos); - processRange(triviaItem, triviaItemStart, parent, contextNode, dynamicIndentation); - } - } - } - function processRange(range, rangeStart, parent, contextNode, dynamicIndentation) { - var rangeHasError = rangeContainsError(range); - var lineAdded; - if (!rangeHasError && !previousRangeHasError) { - if (!previousRange) { - var originalStart = sourceFile.getLineAndCharacterOfPosition(originalRange.pos); - trimTrailingWhitespacesForLines(originalStart.line, rangeStart.line); - } - else { - lineAdded = - processPair(range, rangeStart.line, parent, previousRange, previousRangeStartLine, previousParent, contextNode, dynamicIndentation); - } - } - previousRange = range; - previousParent = parent; - previousRangeStartLine = rangeStart.line; - previousRangeHasError = rangeHasError; - return lineAdded; - } - function processPair(currentItem, currentStartLine, currentParent, previousItem, previousStartLine, previousParent, contextNode, dynamicIndentation) { - formattingContext.updateContext(previousItem, previousParent, currentItem, currentParent, contextNode); - var rule = rulesProvider.getRulesMap().GetRule(formattingContext); - var trimTrailingWhitespaces; - var lineAdded; - if (rule) { - applyRuleEdits(rule, previousItem, previousStartLine, currentItem, currentStartLine); - if (rule.Operation.Action & (2 | 8) && currentStartLine !== previousStartLine) { - lineAdded = false; - if (currentParent.getStart(sourceFile) === currentItem.pos) { - dynamicIndentation.recomputeIndentation(false); - } - } - else if (rule.Operation.Action & 4 && currentStartLine === previousStartLine) { - lineAdded = true; - if (currentParent.getStart(sourceFile) === currentItem.pos) { - dynamicIndentation.recomputeIndentation(true); - } - } - trimTrailingWhitespaces = - (rule.Operation.Action & (4 | 2)) && - rule.Flag !== 1; - } - else { - trimTrailingWhitespaces = true; - } - if (currentStartLine !== previousStartLine && trimTrailingWhitespaces) { - trimTrailingWhitespacesForLines(previousStartLine, currentStartLine, previousItem); - } - return lineAdded; - } - function insertIndentation(pos, indentation, lineAdded) { - var indentationString = getIndentationString(indentation, options); - if (lineAdded) { - recordReplace(pos, 0, indentationString); - } - else { - var tokenStart = sourceFile.getLineAndCharacterOfPosition(pos); - if (indentation !== tokenStart.character) { - var startLinePosition = ts.getStartPositionOfLine(tokenStart.line, sourceFile); - recordReplace(startLinePosition, tokenStart.character, indentationString); - } - } - } - function indentMultilineComment(commentRange, indentation, firstLineIsIndented) { - var startLine = sourceFile.getLineAndCharacterOfPosition(commentRange.pos).line; - var endLine = sourceFile.getLineAndCharacterOfPosition(commentRange.end).line; - var parts; - if (startLine === endLine) { - if (!firstLineIsIndented) { - insertIndentation(commentRange.pos, indentation, false); - } - return; - } - else { - parts = []; - var startPos = commentRange.pos; - for (var line = startLine; line < endLine; ++line) { - var endOfLine = ts.getEndLinePosition(line, sourceFile); - parts.push({ pos: startPos, end: endOfLine }); - startPos = ts.getStartPositionOfLine(line + 1, sourceFile); - } - parts.push({ pos: startPos, end: commentRange.end }); - } - var startLinePos = ts.getStartPositionOfLine(startLine, sourceFile); - var nonWhitespaceColumnInFirstPart = formatting.SmartIndenter.findFirstNonWhitespaceCharacterAndColumn(startLinePos, parts[0].pos, sourceFile, options); - if (indentation === nonWhitespaceColumnInFirstPart.column) { - return; - } - var startIndex = 0; - if (firstLineIsIndented) { - startIndex = 1; - startLine++; - } - var delta = indentation - nonWhitespaceColumnInFirstPart.column; - for (var i = startIndex, len = parts.length; i < len; ++i, ++startLine) { - var startLinePos_1 = ts.getStartPositionOfLine(startLine, sourceFile); - var nonWhitespaceCharacterAndColumn = i === 0 - ? nonWhitespaceColumnInFirstPart - : formatting.SmartIndenter.findFirstNonWhitespaceCharacterAndColumn(parts[i].pos, parts[i].end, sourceFile, options); - var newIndentation = nonWhitespaceCharacterAndColumn.column + delta; - if (newIndentation > 0) { - var indentationString = getIndentationString(newIndentation, options); - recordReplace(startLinePos_1, nonWhitespaceCharacterAndColumn.character, indentationString); - } - else { - recordDelete(startLinePos_1, nonWhitespaceCharacterAndColumn.character); - } - } - } - function trimTrailingWhitespacesForLines(line1, line2, range) { - for (var line = line1; line < line2; ++line) { - var lineStartPosition = ts.getStartPositionOfLine(line, sourceFile); - var lineEndPosition = ts.getEndLinePosition(line, sourceFile); - if (range && (ts.isComment(range.kind) || ts.isStringOrRegularExpressionOrTemplateLiteral(range.kind)) && range.pos <= lineEndPosition && range.end > lineEndPosition) { - continue; - } - var pos = lineEndPosition; - while (pos >= lineStartPosition && ts.isWhiteSpace(sourceFile.text.charCodeAt(pos))) { - pos--; - } - if (pos !== lineEndPosition) { - ts.Debug.assert(pos === lineStartPosition || !ts.isWhiteSpace(sourceFile.text.charCodeAt(pos))); - recordDelete(pos + 1, lineEndPosition - pos); - } - } - } - function newTextChange(start, len, newText) { - return { span: ts.createTextSpan(start, len), newText: newText }; - } - function recordDelete(start, len) { - if (len) { - edits.push(newTextChange(start, len, "")); - } - } - function recordReplace(start, len, newText) { - if (len || newText) { - edits.push(newTextChange(start, len, newText)); - } - } - function applyRuleEdits(rule, previousRange, previousStartLine, currentRange, currentStartLine) { - var between; - switch (rule.Operation.Action) { - case 1: - return; - case 8: - if (previousRange.end !== currentRange.pos) { - recordDelete(previousRange.end, currentRange.pos - previousRange.end); - } - break; - case 4: - if (rule.Flag !== 1 && previousStartLine !== currentStartLine) { - return; - } - var lineDelta = currentStartLine - previousStartLine; - if (lineDelta !== 1) { - recordReplace(previousRange.end, currentRange.pos - previousRange.end, options.NewLineCharacter); - } - break; - case 2: - if (rule.Flag !== 1 && previousStartLine !== currentStartLine) { - return; - } - var posDelta = currentRange.pos - previousRange.end; - if (posDelta !== 1 || sourceFile.text.charCodeAt(previousRange.end) !== 32) { - recordReplace(previousRange.end, currentRange.pos - previousRange.end, " "); - } - break; - } - } - } - function isSomeBlock(kind) { - switch (kind) { - case 192: - case 219: - return true; - } - return false; - } - function getOpenTokenForList(node, list) { - switch (node.kind) { - case 144: - case 213: - case 173: - case 143: - case 142: - case 174: - if (node.typeParameters === list) { - return 25; - } - else if (node.parameters === list) { - return 17; - } - break; - case 168: - case 169: - if (node.typeArguments === list) { - return 25; - } - else if (node.arguments === list) { - return 17; - } - break; - case 151: - if (node.typeArguments === list) { - return 25; - } - } - return 0; - } - function getCloseTokenForOpenToken(kind) { - switch (kind) { - case 17: - return 18; - case 25: - return 27; - } - return 0; - } - var internedSizes; - var internedTabsIndentation; - var internedSpacesIndentation; - function getIndentationString(indentation, options) { - var resetInternedStrings = !internedSizes || (internedSizes.tabSize !== options.TabSize || internedSizes.indentSize !== options.IndentSize); - if (resetInternedStrings) { - internedSizes = { tabSize: options.TabSize, indentSize: options.IndentSize }; - internedTabsIndentation = internedSpacesIndentation = undefined; - } - if (!options.ConvertTabsToSpaces) { - var tabs = Math.floor(indentation / options.TabSize); - var spaces = indentation - tabs * options.TabSize; - var tabString; - if (!internedTabsIndentation) { - internedTabsIndentation = []; - } - if (internedTabsIndentation[tabs] === undefined) { - internedTabsIndentation[tabs] = tabString = repeat('\t', tabs); - } - else { - tabString = internedTabsIndentation[tabs]; - } - return spaces ? tabString + repeat(" ", spaces) : tabString; - } - else { - var spacesString; - var quotient = Math.floor(indentation / options.IndentSize); - var remainder = indentation % options.IndentSize; - if (!internedSpacesIndentation) { - internedSpacesIndentation = []; - } - if (internedSpacesIndentation[quotient] === undefined) { - spacesString = repeat(" ", options.IndentSize * quotient); - internedSpacesIndentation[quotient] = spacesString; - } - else { - spacesString = internedSpacesIndentation[quotient]; - } - return remainder ? spacesString + repeat(" ", remainder) : spacesString; - } - function repeat(value, count) { - var s = ""; - for (var i = 0; i < count; ++i) { - s += value; - } - return s; - } - } - formatting.getIndentationString = getIndentationString; - })(formatting = ts.formatting || (ts.formatting = {})); -})(ts || (ts = {})); -var ts; -(function (ts) { - var formatting; - (function (formatting) { - var SmartIndenter; - (function (SmartIndenter) { - function getIndentation(position, sourceFile, options) { - if (position > sourceFile.text.length) { - return 0; - } - if (options.IndentStyle === ts.IndentStyle.None) { - return 0; - } - var precedingToken = ts.findPrecedingToken(position, sourceFile); - if (!precedingToken) { - return 0; - } - var precedingTokenIsLiteral = ts.isStringOrRegularExpressionOrTemplateLiteral(precedingToken.kind); - if (precedingTokenIsLiteral && precedingToken.getStart(sourceFile) <= position && precedingToken.end > position) { - return 0; - } - var lineAtPosition = sourceFile.getLineAndCharacterOfPosition(position).line; - if (options.IndentStyle === ts.IndentStyle.Block) { - var current_1 = position; - while (current_1 > 0) { - var char = sourceFile.text.charCodeAt(current_1); - if (!ts.isWhiteSpace(char) && !ts.isLineBreak(char)) { - break; - } - current_1--; - } - var lineStart = ts.getLineStartPositionForPosition(current_1, sourceFile); - return SmartIndenter.findFirstNonWhitespaceColumn(lineStart, current_1, sourceFile, options); - } - if (precedingToken.kind === 24 && precedingToken.parent.kind !== 181) { - var actualIndentation = getActualIndentationForListItemBeforeComma(precedingToken, sourceFile, options); - if (actualIndentation !== -1) { - return actualIndentation; - } - } - var previous; - var current = precedingToken; - var currentStart; - var indentationDelta; - while (current) { - if (ts.positionBelongsToNode(current, position, sourceFile) && shouldIndentChildNode(current.kind, previous ? previous.kind : 0)) { - currentStart = getStartLineAndCharacterForNode(current, sourceFile); - if (nextTokenIsCurlyBraceOnSameLineAsCursor(precedingToken, current, lineAtPosition, sourceFile)) { - indentationDelta = 0; - } - else { - indentationDelta = lineAtPosition !== currentStart.line ? options.IndentSize : 0; - } - break; - } - var actualIndentation = getActualIndentationForListItem(current, sourceFile, options); - if (actualIndentation !== -1) { - return actualIndentation; - } - actualIndentation = getLineIndentationWhenExpressionIsInMultiLine(current, sourceFile, options); - if (actualIndentation !== -1) { - return actualIndentation + options.IndentSize; - } - previous = current; - current = current.parent; - } - if (!current) { - return 0; - } - return getIndentationForNodeWorker(current, currentStart, undefined, indentationDelta, sourceFile, options); - } - SmartIndenter.getIndentation = getIndentation; - 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 getIndentationForNodeWorker(current, currentStart, ignoreActualIndentationRange, indentationDelta, sourceFile, options) { - var parent = current.parent; - var parentStart; - while (parent) { - var useActualIndentation = true; - if (ignoreActualIndentationRange) { - var start = current.getStart(sourceFile); - useActualIndentation = start < ignoreActualIndentationRange.pos || start > ignoreActualIndentationRange.end; - } - if (useActualIndentation) { - var actualIndentation = getActualIndentationForListItem(current, sourceFile, options); - if (actualIndentation !== -1) { - return actualIndentation + indentationDelta; - } - } - parentStart = getParentStart(parent, current, sourceFile); - var parentAndChildShareLine = parentStart.line === currentStart.line || - childStartsOnTheSameLineWithElseInIfStatement(parent, current, currentStart.line, sourceFile); - if (useActualIndentation) { - var actualIndentation = getActualIndentationForNode(current, parent, currentStart, parentAndChildShareLine, sourceFile, options); - if (actualIndentation !== -1) { - return actualIndentation + indentationDelta; - } - actualIndentation = getLineIndentationWhenExpressionIsInMultiLine(current, sourceFile, options); - if (actualIndentation !== -1) { - return actualIndentation + indentationDelta; - } - } - if (shouldIndentChildNode(parent.kind, current.kind) && !parentAndChildShareLine) { - indentationDelta += options.IndentSize; - } - current = parent; - currentStart = parentStart; - parent = current.parent; - } - return indentationDelta; - } - function getParentStart(parent, child, sourceFile) { - var containingList = getContainingList(child, sourceFile); - if (containingList) { - return sourceFile.getLineAndCharacterOfPosition(containingList.pos); - } - return sourceFile.getLineAndCharacterOfPosition(parent.getStart(sourceFile)); - } - function getActualIndentationForListItemBeforeComma(commaToken, sourceFile, options) { - var commaItemInfo = ts.findListItemInfo(commaToken); - if (commaItemInfo && commaItemInfo.listItemIndex > 0) { - return deriveActualIndentationFromList(commaItemInfo.list.getChildren(), commaItemInfo.listItemIndex - 1, sourceFile, options); - } - else { - return -1; - } - } - function getActualIndentationForNode(current, parent, currentLineAndChar, parentAndChildShareLine, sourceFile, options) { - var useActualIndentation = (ts.isDeclaration(current) || ts.isStatement(current)) && - (parent.kind === 248 || !parentAndChildShareLine); - if (!useActualIndentation) { - return -1; - } - return findColumnForFirstNonWhitespaceCharacterInLine(currentLineAndChar, sourceFile, options); - } - function nextTokenIsCurlyBraceOnSameLineAsCursor(precedingToken, current, lineAtPosition, sourceFile) { - var nextToken = ts.findNextToken(precedingToken, current); - if (!nextToken) { - return false; - } - if (nextToken.kind === 15) { - return true; - } - else if (nextToken.kind === 16) { - var nextTokenStartLine = getStartLineAndCharacterForNode(nextToken, sourceFile).line; - return lineAtPosition === nextTokenStartLine; - } - return false; - } - function getStartLineAndCharacterForNode(n, sourceFile) { - return sourceFile.getLineAndCharacterOfPosition(n.getStart(sourceFile)); - } - function childStartsOnTheSameLineWithElseInIfStatement(parent, child, childStartLine, sourceFile) { - if (parent.kind === 196 && parent.elseStatement === child) { - var elseKeyword = ts.findChildOfKind(parent, 80, sourceFile); - ts.Debug.assert(elseKeyword !== undefined); - var elseKeywordStartLine = getStartLineAndCharacterForNode(elseKeyword, sourceFile).line; - return elseKeywordStartLine === childStartLine; - } - return false; - } - SmartIndenter.childStartsOnTheSameLineWithElseInIfStatement = childStartsOnTheSameLineWithElseInIfStatement; - function getContainingList(node, sourceFile) { - if (node.parent) { - switch (node.parent.kind) { - case 151: - if (node.parent.typeArguments && - ts.rangeContainsStartEnd(node.parent.typeArguments, node.getStart(sourceFile), node.getEnd())) { - return node.parent.typeArguments; - } - break; - case 165: - return node.parent.properties; - case 164: - return node.parent.elements; - case 213: - case 173: - case 174: - case 143: - case 142: - case 147: - case 148: { - var start = node.getStart(sourceFile); - if (node.parent.typeParameters && - ts.rangeContainsStartEnd(node.parent.typeParameters, start, node.getEnd())) { - return node.parent.typeParameters; - } - if (ts.rangeContainsStartEnd(node.parent.parameters, start, node.getEnd())) { - return node.parent.parameters; - } - break; - } - case 169: - case 168: { - var start = node.getStart(sourceFile); - if (node.parent.typeArguments && - ts.rangeContainsStartEnd(node.parent.typeArguments, start, node.getEnd())) { - return node.parent.typeArguments; - } - if (node.parent.arguments && - ts.rangeContainsStartEnd(node.parent.arguments, start, node.getEnd())) { - return node.parent.arguments; - } - break; - } - } - } - return undefined; - } - function getActualIndentationForListItem(node, sourceFile, options) { - var containingList = getContainingList(node, sourceFile); - return containingList ? getActualIndentationFromList(containingList) : -1; - function getActualIndentationFromList(list) { - var index = ts.indexOf(list, node); - return index !== -1 ? deriveActualIndentationFromList(list, index, sourceFile, options) : -1; - } - } - function getLineIndentationWhenExpressionIsInMultiLine(node, sourceFile, options) { - if (node.kind === 18) { - return -1; - } - if (node.parent && (node.parent.kind === 168 || - node.parent.kind === 169) && - node.parent.expression !== node) { - var fullCallOrNewExpression = node.parent.expression; - var startingExpression = getStartingExpression(fullCallOrNewExpression); - if (fullCallOrNewExpression === startingExpression) { - return -1; - } - var fullCallOrNewExpressionEnd = sourceFile.getLineAndCharacterOfPosition(fullCallOrNewExpression.end); - var startingExpressionEnd = sourceFile.getLineAndCharacterOfPosition(startingExpression.end); - if (fullCallOrNewExpressionEnd.line === startingExpressionEnd.line) { - return -1; - } - return findColumnForFirstNonWhitespaceCharacterInLine(fullCallOrNewExpressionEnd, sourceFile, options); - } - return -1; - function getStartingExpression(node) { - while (true) { - switch (node.kind) { - case 168: - case 169: - case 166: - case 167: - node = node.expression; - break; - default: - return node; - } - } - return node; - } - } - function deriveActualIndentationFromList(list, index, sourceFile, options) { - ts.Debug.assert(index >= 0 && index < list.length); - var node = list[index]; - var lineAndCharacter = getStartLineAndCharacterForNode(node, sourceFile); - for (var i = index - 1; i >= 0; --i) { - if (list[i].kind === 24) { - continue; - } - var prevEndLine = sourceFile.getLineAndCharacterOfPosition(list[i].end).line; - if (prevEndLine !== lineAndCharacter.line) { - return findColumnForFirstNonWhitespaceCharacterInLine(lineAndCharacter, sourceFile, options); - } - lineAndCharacter = getStartLineAndCharacterForNode(list[i], sourceFile); - } - return -1; - } - function findColumnForFirstNonWhitespaceCharacterInLine(lineAndCharacter, sourceFile, options) { - var lineStart = sourceFile.getPositionOfLineAndCharacter(lineAndCharacter.line, 0); - return findFirstNonWhitespaceColumn(lineStart, lineStart + lineAndCharacter.character, sourceFile, options); - } - function findFirstNonWhitespaceCharacterAndColumn(startPos, endPos, sourceFile, options) { - var character = 0; - var column = 0; - for (var pos = startPos; pos < endPos; ++pos) { - var ch = sourceFile.text.charCodeAt(pos); - if (!ts.isWhiteSpace(ch)) { - break; - } - if (ch === 9) { - column += options.TabSize + (column % options.TabSize); - } - else { - column++; - } - character++; - } - return { column: column, character: character }; - } - SmartIndenter.findFirstNonWhitespaceCharacterAndColumn = findFirstNonWhitespaceCharacterAndColumn; - function findFirstNonWhitespaceColumn(startPos, endPos, sourceFile, options) { - return findFirstNonWhitespaceCharacterAndColumn(startPos, endPos, sourceFile, options).column; - } - SmartIndenter.findFirstNonWhitespaceColumn = findFirstNonWhitespaceColumn; - function nodeContentIsAlwaysIndented(kind) { - switch (kind) { - case 195: - case 214: - case 186: - case 215: - case 217: - case 216: - case 164: - case 192: - case 219: - case 165: - case 155: - case 157: - case 220: - case 242: - case 241: - case 172: - case 166: - case 168: - case 169: - case 193: - case 211: - case 227: - case 204: - case 182: - case 162: - case 161: - case 233: - case 234: - case 142: - case 147: - case 148: - case 138: - case 152: - case 153: - case 160: - case 170: - case 178: - return true; - } - return false; - } - function shouldIndentChildNode(parent, child) { - if (nodeContentIsAlwaysIndented(parent)) { - return true; - } - switch (parent) { - case 197: - case 198: - case 200: - case 201: - case 199: - case 196: - case 213: - case 173: - case 143: - case 174: - case 144: - case 145: - case 146: - return child !== 192; - default: - return false; - } - } - SmartIndenter.shouldIndentChildNode = shouldIndentChildNode; - })(SmartIndenter = formatting.SmartIndenter || (formatting.SmartIndenter = {})); - })(formatting = ts.formatting || (ts.formatting = {})); -})(ts || (ts = {})); -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 ts; -(function (ts) { - ts.servicesVersion = "0.4"; - var ScriptSnapshot; - (function (ScriptSnapshot) { - var StringScriptSnapshot = (function () { - function StringScriptSnapshot(text) { - this.text = text; - } - StringScriptSnapshot.prototype.getText = function (start, end) { - return this.text.substring(start, end); - }; - StringScriptSnapshot.prototype.getLength = function () { - return this.text.length; - }; - StringScriptSnapshot.prototype.getChangeRange = function (oldSnapshot) { - return undefined; - }; - return StringScriptSnapshot; - })(); - function fromString(text) { - return new StringScriptSnapshot(text); - } - ScriptSnapshot.fromString = fromString; - })(ScriptSnapshot = ts.ScriptSnapshot || (ts.ScriptSnapshot = {})); - var scanner = ts.createScanner(2, true); - var emptyArray = []; - var jsDocTagNames = [ - "augments", - "author", - "argument", - "borrows", - "class", - "constant", - "constructor", - "constructs", - "default", - "deprecated", - "description", - "event", - "example", - "extends", - "field", - "fileOverview", - "function", - "ignore", - "inner", - "lends", - "link", - "memberOf", - "name", - "namespace", - "param", - "private", - "property", - "public", - "requires", - "returns", - "see", - "since", - "static", - "throws", - "type", - "version" - ]; - var jsDocCompletionEntries; - function createNode(kind, pos, end, flags, parent) { - var node = new (ts.getNodeConstructor(kind))(pos, end); - node.flags = flags; - node.parent = parent; - return node; - } - var NodeObject = (function () { - function NodeObject() { - } - NodeObject.prototype.getSourceFile = function () { - return ts.getSourceFileOfNode(this); - }; - NodeObject.prototype.getStart = function (sourceFile) { - return ts.getTokenPosOfNode(this, sourceFile); - }; - NodeObject.prototype.getFullStart = function () { - return this.pos; - }; - NodeObject.prototype.getEnd = function () { - return this.end; - }; - NodeObject.prototype.getWidth = function (sourceFile) { - return this.getEnd() - this.getStart(sourceFile); - }; - NodeObject.prototype.getFullWidth = function () { - return this.end - this.pos; - }; - NodeObject.prototype.getLeadingTriviaWidth = function (sourceFile) { - return this.getStart(sourceFile) - this.pos; - }; - NodeObject.prototype.getFullText = function (sourceFile) { - return (sourceFile || this.getSourceFile()).text.substring(this.pos, this.end); - }; - NodeObject.prototype.getText = function (sourceFile) { - return (sourceFile || this.getSourceFile()).text.substring(this.getStart(), this.getEnd()); - }; - NodeObject.prototype.addSyntheticNodes = function (nodes, pos, end) { - scanner.setTextPos(pos); - while (pos < end) { - var token = scanner.scan(); - var textPos = scanner.getTextPos(); - nodes.push(createNode(token, pos, textPos, 4096, this)); - pos = textPos; - } - return pos; - }; - NodeObject.prototype.createSyntaxList = function (nodes) { - var list = createNode(271, nodes.pos, nodes.end, 4096, this); - list._children = []; - var pos = nodes.pos; - for (var _i = 0; _i < nodes.length; _i++) { - var node = nodes[_i]; - if (pos < node.pos) { - pos = this.addSyntheticNodes(list._children, pos, node.pos); - } - list._children.push(node); - pos = node.end; - } - if (pos < nodes.end) { - this.addSyntheticNodes(list._children, pos, nodes.end); - } - return list; - }; - NodeObject.prototype.createChildren = function (sourceFile) { - var _this = this; - var children; - if (this.kind >= 135) { - scanner.setText((sourceFile || this.getSourceFile()).text); - children = []; - var pos = this.pos; - var processNode = function (node) { - if (pos < node.pos) { - pos = _this.addSyntheticNodes(children, pos, node.pos); - } - children.push(node); - pos = node.end; - }; - var processNodes = function (nodes) { - if (pos < nodes.pos) { - pos = _this.addSyntheticNodes(children, pos, nodes.pos); - } - children.push(_this.createSyntaxList(nodes)); - pos = nodes.end; - }; - ts.forEachChild(this, processNode, processNodes); - if (pos < this.end) { - this.addSyntheticNodes(children, pos, this.end); - } - scanner.setText(undefined); - } - this._children = children || emptyArray; - }; - NodeObject.prototype.getChildCount = function (sourceFile) { - if (!this._children) - this.createChildren(sourceFile); - return this._children.length; - }; - NodeObject.prototype.getChildAt = function (index, sourceFile) { - if (!this._children) - this.createChildren(sourceFile); - return this._children[index]; - }; - NodeObject.prototype.getChildren = function (sourceFile) { - if (!this._children) - this.createChildren(sourceFile); - return this._children; - }; - NodeObject.prototype.getFirstToken = function (sourceFile) { - var children = this.getChildren(sourceFile); - if (!children.length) { - return undefined; - } - var child = children[0]; - return child.kind < 135 ? child : child.getFirstToken(sourceFile); - }; - NodeObject.prototype.getLastToken = function (sourceFile) { - var children = this.getChildren(sourceFile); - var child = ts.lastOrUndefined(children); - if (!child) { - return undefined; - } - return child.kind < 135 ? child : child.getLastToken(sourceFile); - }; - return NodeObject; - })(); - var SymbolObject = (function () { - function SymbolObject(flags, name) { - this.flags = flags; - this.name = name; - } - SymbolObject.prototype.getFlags = function () { - return this.flags; - }; - SymbolObject.prototype.getName = function () { - return this.name; - }; - SymbolObject.prototype.getDeclarations = function () { - return this.declarations; - }; - SymbolObject.prototype.getDocumentationComment = function () { - if (this.documentationComment === undefined) { - this.documentationComment = getJsDocCommentsFromDeclarations(this.declarations, this.name, !(this.flags & 4)); - } - return this.documentationComment; - }; - return SymbolObject; - })(); - function getJsDocCommentsFromDeclarations(declarations, name, canUseParsedParamTagComments) { - var documentationComment = []; - var docComments = getJsDocCommentsSeparatedByNewLines(); - ts.forEach(docComments, function (docComment) { - if (documentationComment.length) { - documentationComment.push(ts.lineBreakPart()); - } - documentationComment.push(docComment); - }); - return documentationComment; - function getJsDocCommentsSeparatedByNewLines() { - var paramTag = "@param"; - var jsDocCommentParts = []; - ts.forEach(declarations, function (declaration, indexOfDeclaration) { - if (ts.indexOf(declarations, declaration) === indexOfDeclaration) { - var sourceFileOfDeclaration = ts.getSourceFileOfNode(declaration); - if (canUseParsedParamTagComments && declaration.kind === 138) { - ts.forEach(getJsDocCommentTextRange(declaration.parent, sourceFileOfDeclaration), function (jsDocCommentTextRange) { - var cleanedParamJsDocComment = getCleanedParamJsDocComment(jsDocCommentTextRange.pos, jsDocCommentTextRange.end, sourceFileOfDeclaration); - if (cleanedParamJsDocComment) { - ts.addRange(jsDocCommentParts, cleanedParamJsDocComment); - } - }); - } - if (declaration.kind === 218 && declaration.body.kind === 218) { - return; - } - while (declaration.kind === 218 && declaration.parent.kind === 218) { - declaration = declaration.parent; - } - ts.forEach(getJsDocCommentTextRange(declaration.kind === 211 ? declaration.parent.parent : declaration, sourceFileOfDeclaration), function (jsDocCommentTextRange) { - var cleanedJsDocComment = getCleanedJsDocComment(jsDocCommentTextRange.pos, jsDocCommentTextRange.end, sourceFileOfDeclaration); - if (cleanedJsDocComment) { - ts.addRange(jsDocCommentParts, cleanedJsDocComment); - } - }); - } - }); - return jsDocCommentParts; - function getJsDocCommentTextRange(node, sourceFile) { - return ts.map(ts.getJsDocComments(node, sourceFile), function (jsDocComment) { - return { - pos: jsDocComment.pos + "/*".length, - end: jsDocComment.end - "*/".length - }; - }); - } - function consumeWhiteSpacesOnTheLine(pos, end, sourceFile, maxSpacesToRemove) { - if (maxSpacesToRemove !== undefined) { - end = Math.min(end, pos + maxSpacesToRemove); - } - for (; pos < end; pos++) { - var ch = sourceFile.text.charCodeAt(pos); - if (!ts.isWhiteSpace(ch) || ts.isLineBreak(ch)) { - return pos; - } - } - return end; - } - function consumeLineBreaks(pos, end, sourceFile) { - while (pos < end && ts.isLineBreak(sourceFile.text.charCodeAt(pos))) { - pos++; - } - return pos; - } - function isName(pos, end, sourceFile, name) { - return pos + name.length < end && - sourceFile.text.substr(pos, name.length) === name && - (ts.isWhiteSpace(sourceFile.text.charCodeAt(pos + name.length)) || - ts.isLineBreak(sourceFile.text.charCodeAt(pos + name.length))); - } - function isParamTag(pos, end, sourceFile) { - return isName(pos, end, sourceFile, paramTag); - } - function pushDocCommentLineText(docComments, text, blankLineCount) { - while (blankLineCount--) { - docComments.push(ts.textPart("")); - } - docComments.push(ts.textPart(text)); - } - function getCleanedJsDocComment(pos, end, sourceFile) { - var spacesToRemoveAfterAsterisk; - var docComments = []; - var blankLineCount = 0; - var isInParamTag = false; - while (pos < end) { - var docCommentTextOfLine = ""; - pos = consumeWhiteSpacesOnTheLine(pos, end, sourceFile); - if (pos < end && sourceFile.text.charCodeAt(pos) === 42) { - var lineStartPos = pos + 1; - pos = consumeWhiteSpacesOnTheLine(pos + 1, end, sourceFile, spacesToRemoveAfterAsterisk); - if (spacesToRemoveAfterAsterisk === undefined && pos < end && !ts.isLineBreak(sourceFile.text.charCodeAt(pos))) { - spacesToRemoveAfterAsterisk = pos - lineStartPos; - } - } - else if (spacesToRemoveAfterAsterisk === undefined) { - spacesToRemoveAfterAsterisk = 0; - } - while (pos < end && !ts.isLineBreak(sourceFile.text.charCodeAt(pos))) { - var ch = sourceFile.text.charAt(pos); - if (ch === "@") { - if (isParamTag(pos, end, sourceFile)) { - isInParamTag = true; - pos += paramTag.length; - continue; - } - else { - isInParamTag = false; - } - } - if (!isInParamTag) { - docCommentTextOfLine += ch; - } - pos++; - } - pos = consumeLineBreaks(pos, end, sourceFile); - if (docCommentTextOfLine) { - pushDocCommentLineText(docComments, docCommentTextOfLine, blankLineCount); - blankLineCount = 0; - } - else if (!isInParamTag && docComments.length) { - blankLineCount++; - } - } - return docComments; - } - function getCleanedParamJsDocComment(pos, end, sourceFile) { - var paramHelpStringMargin; - var paramDocComments = []; - while (pos < end) { - if (isParamTag(pos, end, sourceFile)) { - var blankLineCount = 0; - var recordedParamTag = false; - pos = consumeWhiteSpaces(pos + paramTag.length); - if (pos >= end) { - break; - } - if (sourceFile.text.charCodeAt(pos) === 123) { - pos++; - for (var curlies = 1; pos < end; pos++) { - var charCode = sourceFile.text.charCodeAt(pos); - if (charCode === 123) { - curlies++; - continue; - } - if (charCode === 125) { - curlies--; - if (curlies === 0) { - pos++; - break; - } - else { - continue; - } - } - if (charCode === 64) { - break; - } - } - pos = consumeWhiteSpaces(pos); - if (pos >= end) { - break; - } - } - if (isName(pos, end, sourceFile, name)) { - pos = consumeWhiteSpaces(pos + name.length); - if (pos >= end) { - break; - } - var paramHelpString = ""; - var firstLineParamHelpStringPos = pos; - while (pos < end) { - var ch = sourceFile.text.charCodeAt(pos); - if (ts.isLineBreak(ch)) { - if (paramHelpString) { - pushDocCommentLineText(paramDocComments, paramHelpString, blankLineCount); - paramHelpString = ""; - blankLineCount = 0; - recordedParamTag = true; - } - else if (recordedParamTag) { - blankLineCount++; - } - setPosForParamHelpStringOnNextLine(firstLineParamHelpStringPos); - continue; - } - if (ch === 64) { - break; - } - paramHelpString += sourceFile.text.charAt(pos); - pos++; - } - if (paramHelpString) { - pushDocCommentLineText(paramDocComments, paramHelpString, blankLineCount); - } - paramHelpStringMargin = undefined; - } - if (sourceFile.text.charCodeAt(pos) === 64) { - continue; - } - } - pos++; - } - return paramDocComments; - function consumeWhiteSpaces(pos) { - while (pos < end && ts.isWhiteSpace(sourceFile.text.charCodeAt(pos))) { - pos++; - } - return pos; - } - function setPosForParamHelpStringOnNextLine(firstLineParamHelpStringPos) { - pos = consumeLineBreaks(pos, end, sourceFile); - if (pos >= end) { - return; - } - if (paramHelpStringMargin === undefined) { - paramHelpStringMargin = sourceFile.getLineAndCharacterOfPosition(firstLineParamHelpStringPos).character; - } - var startOfLinePos = pos; - pos = consumeWhiteSpacesOnTheLine(pos, end, sourceFile, paramHelpStringMargin); - if (pos >= end) { - return; - } - var consumedSpaces = pos - startOfLinePos; - if (consumedSpaces < paramHelpStringMargin) { - var ch = sourceFile.text.charCodeAt(pos); - if (ch === 42) { - pos = consumeWhiteSpacesOnTheLine(pos + 1, end, sourceFile, paramHelpStringMargin - consumedSpaces - 1); - } - } - } - } - } - } - var TypeObject = (function () { - function TypeObject(checker, flags) { - this.checker = checker; - this.flags = flags; - } - TypeObject.prototype.getFlags = function () { - return this.flags; - }; - TypeObject.prototype.getSymbol = function () { - return this.symbol; - }; - TypeObject.prototype.getProperties = function () { - return this.checker.getPropertiesOfType(this); - }; - TypeObject.prototype.getProperty = function (propertyName) { - return this.checker.getPropertyOfType(this, propertyName); - }; - TypeObject.prototype.getApparentProperties = function () { - return this.checker.getAugmentedPropertiesOfType(this); - }; - TypeObject.prototype.getCallSignatures = function () { - return this.checker.getSignaturesOfType(this, 0); - }; - TypeObject.prototype.getConstructSignatures = function () { - return this.checker.getSignaturesOfType(this, 1); - }; - TypeObject.prototype.getStringIndexType = function () { - return this.checker.getIndexTypeOfType(this, 0); - }; - TypeObject.prototype.getNumberIndexType = function () { - return this.checker.getIndexTypeOfType(this, 1); - }; - TypeObject.prototype.getBaseTypes = function () { - return this.flags & (1024 | 2048) - ? this.checker.getBaseTypes(this) - : undefined; - }; - return TypeObject; - })(); - var SignatureObject = (function () { - function SignatureObject(checker) { - this.checker = checker; - } - SignatureObject.prototype.getDeclaration = function () { - return this.declaration; - }; - SignatureObject.prototype.getTypeParameters = function () { - return this.typeParameters; - }; - SignatureObject.prototype.getParameters = function () { - return this.parameters; - }; - SignatureObject.prototype.getReturnType = function () { - return this.checker.getReturnTypeOfSignature(this); - }; - SignatureObject.prototype.getDocumentationComment = function () { - if (this.documentationComment === undefined) { - this.documentationComment = this.declaration ? getJsDocCommentsFromDeclarations([this.declaration], undefined, false) : []; - } - return this.documentationComment; - }; - return SignatureObject; - })(); - var SourceFileObject = (function (_super) { - __extends(SourceFileObject, _super); - function SourceFileObject() { - _super.apply(this, arguments); - } - SourceFileObject.prototype.update = function (newText, textChangeRange) { - return ts.updateSourceFile(this, newText, textChangeRange); - }; - SourceFileObject.prototype.getLineAndCharacterOfPosition = function (position) { - return ts.getLineAndCharacterOfPosition(this, position); - }; - SourceFileObject.prototype.getLineStarts = function () { - return ts.getLineStarts(this); - }; - SourceFileObject.prototype.getPositionOfLineAndCharacter = function (line, character) { - return ts.getPositionOfLineAndCharacter(this, line, character); - }; - SourceFileObject.prototype.getNamedDeclarations = function () { - if (!this.namedDeclarations) { - this.namedDeclarations = this.computeNamedDeclarations(); - } - return this.namedDeclarations; - }; - SourceFileObject.prototype.computeNamedDeclarations = function () { - var result = {}; - ts.forEachChild(this, visit); - return result; - function addDeclaration(declaration) { - var name = getDeclarationName(declaration); - if (name) { - var declarations = getDeclarations(name); - declarations.push(declaration); - } - } - function getDeclarations(name) { - return ts.getProperty(result, name) || (result[name] = []); - } - function getDeclarationName(declaration) { - if (declaration.name) { - var result_2 = getTextOfIdentifierOrLiteral(declaration.name); - if (result_2 !== undefined) { - return result_2; - } - if (declaration.name.kind === 136) { - var expr = declaration.name.expression; - if (expr.kind === 166) { - return expr.name.text; - } - return getTextOfIdentifierOrLiteral(expr); - } - } - return undefined; - } - function getTextOfIdentifierOrLiteral(node) { - if (node) { - if (node.kind === 69 || - node.kind === 9 || - node.kind === 8) { - return node.text; - } - } - return undefined; - } - function visit(node) { - switch (node.kind) { - case 213: - case 143: - case 142: - var functionDeclaration = node; - var declarationName = getDeclarationName(functionDeclaration); - if (declarationName) { - var declarations = getDeclarations(declarationName); - var lastDeclaration = ts.lastOrUndefined(declarations); - if (lastDeclaration && functionDeclaration.parent === lastDeclaration.parent && functionDeclaration.symbol === lastDeclaration.symbol) { - if (functionDeclaration.body && !lastDeclaration.body) { - declarations[declarations.length - 1] = functionDeclaration; - } - } - else { - declarations.push(functionDeclaration); - } - ts.forEachChild(node, visit); - } - break; - case 214: - case 215: - case 216: - case 217: - case 218: - case 221: - case 230: - case 226: - case 221: - case 223: - case 224: - case 145: - case 146: - case 155: - addDeclaration(node); - case 144: - case 193: - case 212: - case 161: - case 162: - case 219: - ts.forEachChild(node, visit); - break; - case 192: - if (ts.isFunctionBlock(node)) { - ts.forEachChild(node, visit); - } - break; - case 138: - if (!(node.flags & 112)) { - break; - } - case 211: - case 163: - if (ts.isBindingPattern(node.name)) { - ts.forEachChild(node.name, visit); - break; - } - case 247: - case 141: - case 140: - addDeclaration(node); - break; - case 228: - if (node.exportClause) { - ts.forEach(node.exportClause.elements, visit); - } - break; - case 222: - var importClause = node.importClause; - if (importClause) { - if (importClause.name) { - addDeclaration(importClause); - } - if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 224) { - addDeclaration(importClause.namedBindings); - } - else { - ts.forEach(importClause.namedBindings.elements, visit); - } - } - } - break; - } - } - }; - return SourceFileObject; - })(NodeObject); - var TextChange = (function () { - function TextChange() { - } - return TextChange; - })(); - ts.TextChange = TextChange; - var HighlightSpanKind; - (function (HighlightSpanKind) { - HighlightSpanKind.none = "none"; - HighlightSpanKind.definition = "definition"; - HighlightSpanKind.reference = "reference"; - HighlightSpanKind.writtenReference = "writtenReference"; - })(HighlightSpanKind = ts.HighlightSpanKind || (ts.HighlightSpanKind = {})); - (function (IndentStyle) { - IndentStyle[IndentStyle["None"] = 0] = "None"; - IndentStyle[IndentStyle["Block"] = 1] = "Block"; - IndentStyle[IndentStyle["Smart"] = 2] = "Smart"; - })(ts.IndentStyle || (ts.IndentStyle = {})); - var IndentStyle = ts.IndentStyle; - (function (SymbolDisplayPartKind) { - SymbolDisplayPartKind[SymbolDisplayPartKind["aliasName"] = 0] = "aliasName"; - SymbolDisplayPartKind[SymbolDisplayPartKind["className"] = 1] = "className"; - SymbolDisplayPartKind[SymbolDisplayPartKind["enumName"] = 2] = "enumName"; - SymbolDisplayPartKind[SymbolDisplayPartKind["fieldName"] = 3] = "fieldName"; - SymbolDisplayPartKind[SymbolDisplayPartKind["interfaceName"] = 4] = "interfaceName"; - SymbolDisplayPartKind[SymbolDisplayPartKind["keyword"] = 5] = "keyword"; - SymbolDisplayPartKind[SymbolDisplayPartKind["lineBreak"] = 6] = "lineBreak"; - SymbolDisplayPartKind[SymbolDisplayPartKind["numericLiteral"] = 7] = "numericLiteral"; - SymbolDisplayPartKind[SymbolDisplayPartKind["stringLiteral"] = 8] = "stringLiteral"; - SymbolDisplayPartKind[SymbolDisplayPartKind["localName"] = 9] = "localName"; - SymbolDisplayPartKind[SymbolDisplayPartKind["methodName"] = 10] = "methodName"; - SymbolDisplayPartKind[SymbolDisplayPartKind["moduleName"] = 11] = "moduleName"; - SymbolDisplayPartKind[SymbolDisplayPartKind["operator"] = 12] = "operator"; - SymbolDisplayPartKind[SymbolDisplayPartKind["parameterName"] = 13] = "parameterName"; - SymbolDisplayPartKind[SymbolDisplayPartKind["propertyName"] = 14] = "propertyName"; - SymbolDisplayPartKind[SymbolDisplayPartKind["punctuation"] = 15] = "punctuation"; - SymbolDisplayPartKind[SymbolDisplayPartKind["space"] = 16] = "space"; - SymbolDisplayPartKind[SymbolDisplayPartKind["text"] = 17] = "text"; - SymbolDisplayPartKind[SymbolDisplayPartKind["typeParameterName"] = 18] = "typeParameterName"; - SymbolDisplayPartKind[SymbolDisplayPartKind["enumMemberName"] = 19] = "enumMemberName"; - SymbolDisplayPartKind[SymbolDisplayPartKind["functionName"] = 20] = "functionName"; - SymbolDisplayPartKind[SymbolDisplayPartKind["regularExpressionLiteral"] = 21] = "regularExpressionLiteral"; - })(ts.SymbolDisplayPartKind || (ts.SymbolDisplayPartKind = {})); - var SymbolDisplayPartKind = ts.SymbolDisplayPartKind; - (function (TokenClass) { - TokenClass[TokenClass["Punctuation"] = 0] = "Punctuation"; - TokenClass[TokenClass["Keyword"] = 1] = "Keyword"; - TokenClass[TokenClass["Operator"] = 2] = "Operator"; - TokenClass[TokenClass["Comment"] = 3] = "Comment"; - TokenClass[TokenClass["Whitespace"] = 4] = "Whitespace"; - TokenClass[TokenClass["Identifier"] = 5] = "Identifier"; - TokenClass[TokenClass["NumberLiteral"] = 6] = "NumberLiteral"; - TokenClass[TokenClass["StringLiteral"] = 7] = "StringLiteral"; - TokenClass[TokenClass["RegExpLiteral"] = 8] = "RegExpLiteral"; - })(ts.TokenClass || (ts.TokenClass = {})); - var TokenClass = ts.TokenClass; - var ScriptElementKind; - (function (ScriptElementKind) { - ScriptElementKind.unknown = ""; - ScriptElementKind.warning = "warning"; - ScriptElementKind.keyword = "keyword"; - ScriptElementKind.scriptElement = "script"; - ScriptElementKind.moduleElement = "module"; - ScriptElementKind.classElement = "class"; - ScriptElementKind.localClassElement = "local class"; - ScriptElementKind.interfaceElement = "interface"; - ScriptElementKind.typeElement = "type"; - ScriptElementKind.enumElement = "enum"; - ScriptElementKind.variableElement = "var"; - ScriptElementKind.localVariableElement = "local var"; - ScriptElementKind.functionElement = "function"; - ScriptElementKind.localFunctionElement = "local function"; - ScriptElementKind.memberFunctionElement = "method"; - ScriptElementKind.memberGetAccessorElement = "getter"; - ScriptElementKind.memberSetAccessorElement = "setter"; - ScriptElementKind.memberVariableElement = "property"; - ScriptElementKind.constructorImplementationElement = "constructor"; - ScriptElementKind.callSignatureElement = "call"; - ScriptElementKind.indexSignatureElement = "index"; - ScriptElementKind.constructSignatureElement = "construct"; - ScriptElementKind.parameterElement = "parameter"; - ScriptElementKind.typeParameterElement = "type parameter"; - ScriptElementKind.primitiveType = "primitive type"; - ScriptElementKind.label = "label"; - ScriptElementKind.alias = "alias"; - ScriptElementKind.constElement = "const"; - ScriptElementKind.letElement = "let"; - })(ScriptElementKind = ts.ScriptElementKind || (ts.ScriptElementKind = {})); - var ScriptElementKindModifier; - (function (ScriptElementKindModifier) { - ScriptElementKindModifier.none = ""; - ScriptElementKindModifier.publicMemberModifier = "public"; - ScriptElementKindModifier.privateMemberModifier = "private"; - ScriptElementKindModifier.protectedMemberModifier = "protected"; - ScriptElementKindModifier.exportedModifier = "export"; - ScriptElementKindModifier.ambientModifier = "declare"; - ScriptElementKindModifier.staticModifier = "static"; - ScriptElementKindModifier.abstractModifier = "abstract"; - })(ScriptElementKindModifier = ts.ScriptElementKindModifier || (ts.ScriptElementKindModifier = {})); - var ClassificationTypeNames = (function () { - function ClassificationTypeNames() { - } - ClassificationTypeNames.comment = "comment"; - ClassificationTypeNames.identifier = "identifier"; - ClassificationTypeNames.keyword = "keyword"; - ClassificationTypeNames.numericLiteral = "number"; - ClassificationTypeNames.operator = "operator"; - ClassificationTypeNames.stringLiteral = "string"; - ClassificationTypeNames.whiteSpace = "whitespace"; - ClassificationTypeNames.text = "text"; - ClassificationTypeNames.punctuation = "punctuation"; - ClassificationTypeNames.className = "class name"; - ClassificationTypeNames.enumName = "enum name"; - ClassificationTypeNames.interfaceName = "interface name"; - ClassificationTypeNames.moduleName = "module name"; - ClassificationTypeNames.typeParameterName = "type parameter name"; - ClassificationTypeNames.typeAliasName = "type alias name"; - ClassificationTypeNames.parameterName = "parameter name"; - ClassificationTypeNames.docCommentTagName = "doc comment tag name"; - return ClassificationTypeNames; - })(); - ts.ClassificationTypeNames = ClassificationTypeNames; - function displayPartsToString(displayParts) { - if (displayParts) { - return ts.map(displayParts, function (displayPart) { return displayPart.text; }).join(""); - } - return ""; - } - ts.displayPartsToString = displayPartsToString; - function isLocalVariableOrFunction(symbol) { - if (symbol.parent) { - return false; - } - return ts.forEach(symbol.declarations, function (declaration) { - if (declaration.kind === 173) { - return true; - } - if (declaration.kind !== 211 && declaration.kind !== 213) { - return false; - } - for (var parent_8 = declaration.parent; !ts.isFunctionBlock(parent_8); parent_8 = parent_8.parent) { - if (parent_8.kind === 248 || parent_8.kind === 219) { - return false; - } - } - return true; - }); - } - function getDefaultCompilerOptions() { - return { - target: 1, - module: 0, - jsx: 1 - }; - } - ts.getDefaultCompilerOptions = getDefaultCompilerOptions; - var HostCache = (function () { - function HostCache(host, getCanonicalFileName) { - this.host = host; - this.fileNameToEntry = ts.createFileMap(getCanonicalFileName); - var rootFileNames = host.getScriptFileNames(); - for (var _i = 0; _i < rootFileNames.length; _i++) { - var fileName = rootFileNames[_i]; - this.createEntry(fileName); - } - this._compilationSettings = host.getCompilationSettings() || getDefaultCompilerOptions(); - } - HostCache.prototype.compilationSettings = function () { - return this._compilationSettings; - }; - HostCache.prototype.createEntry = function (fileName) { - var entry; - var scriptSnapshot = this.host.getScriptSnapshot(fileName); - if (scriptSnapshot) { - entry = { - hostFileName: fileName, - version: this.host.getScriptVersion(fileName), - scriptSnapshot: scriptSnapshot - }; - } - this.fileNameToEntry.set(fileName, entry); - return entry; - }; - HostCache.prototype.getEntry = function (fileName) { - return this.fileNameToEntry.get(fileName); - }; - HostCache.prototype.contains = function (fileName) { - return this.fileNameToEntry.contains(fileName); - }; - HostCache.prototype.getOrCreateEntry = function (fileName) { - if (this.contains(fileName)) { - return this.getEntry(fileName); - } - return this.createEntry(fileName); - }; - HostCache.prototype.getRootFileNames = function () { - var fileNames = []; - this.fileNameToEntry.forEachValue(function (value) { - if (value) { - fileNames.push(value.hostFileName); - } - }); - return fileNames; - }; - HostCache.prototype.getVersion = function (fileName) { - var file = this.getEntry(fileName); - return file && file.version; - }; - HostCache.prototype.getScriptSnapshot = function (fileName) { - var file = this.getEntry(fileName); - return file && file.scriptSnapshot; - }; - return HostCache; - })(); - var SyntaxTreeCache = (function () { - function SyntaxTreeCache(host) { - this.host = host; - } - SyntaxTreeCache.prototype.getCurrentSourceFile = function (fileName) { - var scriptSnapshot = this.host.getScriptSnapshot(fileName); - if (!scriptSnapshot) { - throw new Error("Could not find file: '" + fileName + "'."); - } - var version = this.host.getScriptVersion(fileName); - var sourceFile; - if (this.currentFileName !== fileName) { - sourceFile = createLanguageServiceSourceFile(fileName, scriptSnapshot, 2, version, true); - } - else if (this.currentFileVersion !== version) { - var editRange = scriptSnapshot.getChangeRange(this.currentFileScriptSnapshot); - sourceFile = updateLanguageServiceSourceFile(this.currentSourceFile, scriptSnapshot, version, editRange); - } - if (sourceFile) { - this.currentFileVersion = version; - this.currentFileName = fileName; - this.currentFileScriptSnapshot = scriptSnapshot; - this.currentSourceFile = sourceFile; - } - return this.currentSourceFile; - }; - return SyntaxTreeCache; - })(); - function setSourceFileFields(sourceFile, scriptSnapshot, version) { - sourceFile.version = version; - sourceFile.scriptSnapshot = scriptSnapshot; - } - function transpileModule(input, transpileOptions) { - var options = transpileOptions.compilerOptions ? ts.clone(transpileOptions.compilerOptions) : getDefaultCompilerOptions(); - options.isolatedModules = true; - options.allowNonTsExtensions = true; - options.noLib = true; - options.noResolve = true; - var inputFileName = transpileOptions.fileName || (options.jsx ? "module.tsx" : "module.ts"); - var sourceFile = ts.createSourceFile(inputFileName, input, options.target); - if (transpileOptions.moduleName) { - sourceFile.moduleName = transpileOptions.moduleName; - } - sourceFile.renamedDependencies = transpileOptions.renamedDependencies; - var newLine = ts.getNewLineCharacter(options); - var outputText; - var sourceMapText; - var compilerHost = { - getSourceFile: function (fileName, target) { return fileName === ts.normalizeSlashes(inputFileName) ? sourceFile : undefined; }, - writeFile: function (name, text, writeByteOrderMark) { - if (ts.fileExtensionIs(name, ".map")) { - ts.Debug.assert(sourceMapText === undefined, "Unexpected multiple source map outputs for the file '" + name + "'"); - sourceMapText = text; - } - else { - ts.Debug.assert(outputText === undefined, "Unexpected multiple outputs for the file: " + name); - outputText = text; - } - }, - getDefaultLibFileName: function () { return "lib.d.ts"; }, - useCaseSensitiveFileNames: function () { return false; }, - getCanonicalFileName: function (fileName) { return fileName; }, - getCurrentDirectory: function () { return ""; }, - getNewLine: function () { return newLine; }, - fileExists: function (fileName) { return fileName === inputFileName; }, - readFile: function (fileName) { return ""; } - }; - var program = ts.createProgram([inputFileName], options, compilerHost); - var diagnostics; - if (transpileOptions.reportDiagnostics) { - diagnostics = []; - ts.addRange(diagnostics, program.getSyntacticDiagnostics(sourceFile)); - ts.addRange(diagnostics, program.getOptionsDiagnostics()); - } - program.emit(); - ts.Debug.assert(outputText !== undefined, "Output generation failed"); - return { outputText: outputText, diagnostics: diagnostics, sourceMapText: sourceMapText }; - } - ts.transpileModule = transpileModule; - function transpile(input, compilerOptions, fileName, diagnostics, moduleName) { - var output = transpileModule(input, { compilerOptions: compilerOptions, fileName: fileName, reportDiagnostics: !!diagnostics, moduleName: moduleName }); - ts.addRange(diagnostics, output.diagnostics); - return output.outputText; - } - ts.transpile = transpile; - function createLanguageServiceSourceFile(fileName, scriptSnapshot, scriptTarget, version, setNodeParents) { - var text = scriptSnapshot.getText(0, scriptSnapshot.getLength()); - var sourceFile = ts.createSourceFile(fileName, text, scriptTarget, setNodeParents); - setSourceFileFields(sourceFile, scriptSnapshot, version); - sourceFile.nameTable = sourceFile.identifiers; - return sourceFile; - } - ts.createLanguageServiceSourceFile = createLanguageServiceSourceFile; - ts.disableIncrementalParsing = false; - function updateLanguageServiceSourceFile(sourceFile, scriptSnapshot, version, textChangeRange, aggressiveChecks) { - if (textChangeRange) { - if (version !== sourceFile.version) { - if (!ts.disableIncrementalParsing) { - var newText; - var prefix = textChangeRange.span.start !== 0 - ? sourceFile.text.substr(0, textChangeRange.span.start) - : ""; - var suffix = ts.textSpanEnd(textChangeRange.span) !== sourceFile.text.length - ? sourceFile.text.substr(ts.textSpanEnd(textChangeRange.span)) - : ""; - if (textChangeRange.newLength === 0) { - newText = prefix && suffix ? prefix + suffix : prefix || suffix; - } - else { - var changedText = scriptSnapshot.getText(textChangeRange.span.start, textChangeRange.span.start + textChangeRange.newLength); - newText = prefix && suffix - ? prefix + changedText + suffix - : prefix - ? (prefix + changedText) - : (changedText + suffix); - } - var newSourceFile = ts.updateSourceFile(sourceFile, newText, textChangeRange, aggressiveChecks); - setSourceFileFields(newSourceFile, scriptSnapshot, version); - newSourceFile.nameTable = undefined; - if (sourceFile !== newSourceFile && sourceFile.scriptSnapshot) { - if (sourceFile.scriptSnapshot.dispose) { - sourceFile.scriptSnapshot.dispose(); - } - sourceFile.scriptSnapshot = undefined; - } - return newSourceFile; - } - } - } - return createLanguageServiceSourceFile(sourceFile.fileName, scriptSnapshot, sourceFile.languageVersion, version, true); - } - ts.updateLanguageServiceSourceFile = updateLanguageServiceSourceFile; - function createGetCanonicalFileName(useCaseSensitivefileNames) { - return useCaseSensitivefileNames - ? (function (fileName) { return fileName; }) - : (function (fileName) { return fileName.toLowerCase(); }); - } - ts.createGetCanonicalFileName = createGetCanonicalFileName; - function createDocumentRegistry(useCaseSensitiveFileNames) { - var buckets = {}; - var getCanonicalFileName = createGetCanonicalFileName(!!useCaseSensitiveFileNames); - function getKeyFromCompilationSettings(settings) { - return "_" + settings.target + "|" + settings.module + "|" + settings.noResolve + "|" + settings.jsx; - } - function getBucketForCompilationSettings(settings, createIfMissing) { - var key = getKeyFromCompilationSettings(settings); - var bucket = ts.lookUp(buckets, key); - if (!bucket && createIfMissing) { - buckets[key] = bucket = ts.createFileMap(getCanonicalFileName); - } - return bucket; - } - function reportStats() { - var bucketInfoArray = Object.keys(buckets).filter(function (name) { return name && name.charAt(0) === '_'; }).map(function (name) { - var entries = ts.lookUp(buckets, name); - var sourceFiles = []; - for (var i in entries) { - var entry = entries.get(i); - sourceFiles.push({ - name: i, - refCount: entry.languageServiceRefCount, - references: entry.owners.slice(0) - }); - } - sourceFiles.sort(function (x, y) { return y.refCount - x.refCount; }); - return { - bucket: name, - sourceFiles: sourceFiles - }; - }); - return JSON.stringify(bucketInfoArray, null, 2); - } - function acquireDocument(fileName, compilationSettings, scriptSnapshot, version) { - return acquireOrUpdateDocument(fileName, compilationSettings, scriptSnapshot, version, true); - } - function updateDocument(fileName, compilationSettings, scriptSnapshot, version) { - return acquireOrUpdateDocument(fileName, compilationSettings, scriptSnapshot, version, false); - } - function acquireOrUpdateDocument(fileName, compilationSettings, scriptSnapshot, version, acquiring) { - var bucket = getBucketForCompilationSettings(compilationSettings, true); - var entry = bucket.get(fileName); - if (!entry) { - ts.Debug.assert(acquiring, "How could we be trying to update a document that the registry doesn't have?"); - var sourceFile = createLanguageServiceSourceFile(fileName, scriptSnapshot, compilationSettings.target, version, false); - entry = { - sourceFile: sourceFile, - languageServiceRefCount: 0, - owners: [] - }; - bucket.set(fileName, entry); - } - else { - if (entry.sourceFile.version !== version) { - entry.sourceFile = updateLanguageServiceSourceFile(entry.sourceFile, scriptSnapshot, version, scriptSnapshot.getChangeRange(entry.sourceFile.scriptSnapshot)); - } - } - if (acquiring) { - entry.languageServiceRefCount++; - } - return entry.sourceFile; - } - function releaseDocument(fileName, compilationSettings) { - var bucket = getBucketForCompilationSettings(compilationSettings, false); - ts.Debug.assert(bucket !== undefined); - var entry = bucket.get(fileName); - entry.languageServiceRefCount--; - ts.Debug.assert(entry.languageServiceRefCount >= 0); - if (entry.languageServiceRefCount === 0) { - bucket.remove(fileName); - } - } - return { - acquireDocument: acquireDocument, - updateDocument: updateDocument, - releaseDocument: releaseDocument, - reportStats: reportStats - }; - } - ts.createDocumentRegistry = createDocumentRegistry; - function preProcessFile(sourceText, readImportFiles) { - if (readImportFiles === void 0) { readImportFiles = true; } - var referencedFiles = []; - var importedFiles = []; - var ambientExternalModules; - var isNoDefaultLib = false; - function processTripleSlashDirectives() { - var commentRanges = ts.getLeadingCommentRanges(sourceText, 0); - ts.forEach(commentRanges, function (commentRange) { - var comment = sourceText.substring(commentRange.pos, commentRange.end); - var referencePathMatchResult = ts.getFileReferenceFromReferencePath(comment, commentRange); - if (referencePathMatchResult) { - isNoDefaultLib = referencePathMatchResult.isNoDefaultLib; - var fileReference = referencePathMatchResult.fileReference; - if (fileReference) { - referencedFiles.push(fileReference); - } - } - }); - } - function recordAmbientExternalModule() { - if (!ambientExternalModules) { - ambientExternalModules = []; - } - ambientExternalModules.push(scanner.getTokenValue()); - } - function recordModuleName() { - var importPath = scanner.getTokenValue(); - var pos = scanner.getTokenPos(); - importedFiles.push({ - fileName: importPath, - pos: pos, - end: pos + importPath.length - }); - } - function processImport() { - scanner.setText(sourceText); - var token = scanner.scan(); - while (token !== 1) { - if (token === 122) { - token = scanner.scan(); - if (token === 125) { - token = scanner.scan(); - if (token === 9) { - recordAmbientExternalModule(); - continue; - } - } - } - else if (token === 89) { - token = scanner.scan(); - if (token === 9) { - recordModuleName(); - continue; - } - else { - if (token === 69 || ts.isKeyword(token)) { - token = scanner.scan(); - if (token === 133) { - token = scanner.scan(); - if (token === 9) { - recordModuleName(); - continue; - } - } - else if (token === 56) { - token = scanner.scan(); - if (token === 127) { - token = scanner.scan(); - if (token === 17) { - token = scanner.scan(); - if (token === 9) { - recordModuleName(); - continue; - } - } - } - } - else if (token === 24) { - token = scanner.scan(); - } - else { - continue; - } - } - if (token === 15) { - token = scanner.scan(); - while (token !== 16) { - token = scanner.scan(); - } - if (token === 16) { - token = scanner.scan(); - if (token === 133) { - token = scanner.scan(); - if (token === 9) { - recordModuleName(); - } - } - } - } - else if (token === 37) { - token = scanner.scan(); - if (token === 116) { - token = scanner.scan(); - if (token === 69 || ts.isKeyword(token)) { - token = scanner.scan(); - if (token === 133) { - token = scanner.scan(); - if (token === 9) { - recordModuleName(); - } - } - } - } - } - } - } - else if (token === 82) { - token = scanner.scan(); - if (token === 15) { - token = scanner.scan(); - while (token !== 16) { - token = scanner.scan(); - } - if (token === 16) { - token = scanner.scan(); - if (token === 133) { - token = scanner.scan(); - if (token === 9) { - recordModuleName(); - } - } - } - } - else if (token === 37) { - token = scanner.scan(); - if (token === 133) { - token = scanner.scan(); - if (token === 9) { - recordModuleName(); - } - } - } - else if (token === 89) { - token = scanner.scan(); - if (token === 69 || ts.isKeyword(token)) { - token = scanner.scan(); - if (token === 56) { - token = scanner.scan(); - if (token === 127) { - token = scanner.scan(); - if (token === 17) { - token = scanner.scan(); - if (token === 9) { - recordModuleName(); - } - } - } - } - } - } - } - token = scanner.scan(); - } - scanner.setText(undefined); - } - if (readImportFiles) { - processImport(); - } - processTripleSlashDirectives(); - return { referencedFiles: referencedFiles, importedFiles: importedFiles, isLibFile: isNoDefaultLib, ambientExternalModules: ambientExternalModules }; - } - ts.preProcessFile = preProcessFile; - function getTargetLabel(referenceNode, labelName) { - while (referenceNode) { - if (referenceNode.kind === 207 && referenceNode.label.text === labelName) { - return referenceNode.label; - } - referenceNode = referenceNode.parent; - } - return undefined; - } - function isJumpStatementTarget(node) { - return node.kind === 69 && - (node.parent.kind === 203 || node.parent.kind === 202) && - node.parent.label === node; - } - function isLabelOfLabeledStatement(node) { - return node.kind === 69 && - node.parent.kind === 207 && - node.parent.label === node; - } - function isLabeledBy(node, labelName) { - for (var owner = node.parent; owner.kind === 207; owner = owner.parent) { - if (owner.label.text === labelName) { - return true; - } - } - return false; - } - function isLabelName(node) { - return isLabelOfLabeledStatement(node) || isJumpStatementTarget(node); - } - function isRightSideOfQualifiedName(node) { - return node.parent.kind === 135 && node.parent.right === node; - } - function isRightSideOfPropertyAccess(node) { - return node && node.parent && node.parent.kind === 166 && node.parent.name === node; - } - function isCallExpressionTarget(node) { - if (isRightSideOfPropertyAccess(node)) { - node = node.parent; - } - return node && node.parent && node.parent.kind === 168 && node.parent.expression === node; - } - function isNewExpressionTarget(node) { - if (isRightSideOfPropertyAccess(node)) { - node = node.parent; - } - return node && node.parent && node.parent.kind === 169 && node.parent.expression === node; - } - function isNameOfModuleDeclaration(node) { - return node.parent.kind === 218 && node.parent.name === node; - } - function isNameOfFunctionDeclaration(node) { - return node.kind === 69 && - ts.isFunctionLike(node.parent) && node.parent.name === node; - } - function isNameOfPropertyAssignment(node) { - return (node.kind === 69 || node.kind === 9 || node.kind === 8) && - (node.parent.kind === 245 || node.parent.kind === 246) && node.parent.name === node; - } - function isLiteralNameOfPropertyDeclarationOrIndexAccess(node) { - if (node.kind === 9 || node.kind === 8) { - switch (node.parent.kind) { - case 141: - case 140: - case 245: - case 247: - case 143: - case 142: - case 145: - case 146: - case 218: - return node.parent.name === node; - case 167: - return node.parent.argumentExpression === node; - } - } - return false; - } - function isNameOfExternalModuleImportOrDeclaration(node) { - if (node.kind === 9) { - return isNameOfModuleDeclaration(node) || - (ts.isExternalModuleImportEqualsDeclaration(node.parent.parent) && ts.getExternalModuleImportEqualsDeclarationExpression(node.parent.parent) === node); - } - return false; - } - function isInsideComment(sourceFile, token, position) { - return position <= token.getStart(sourceFile) && - (isInsideCommentRange(ts.getTrailingCommentRanges(sourceFile.text, token.getFullStart())) || - isInsideCommentRange(ts.getLeadingCommentRanges(sourceFile.text, token.getFullStart()))); - function isInsideCommentRange(comments) { - return ts.forEach(comments, function (comment) { - if (comment.pos < position && position < comment.end) { - return true; - } - else if (position === comment.end) { - var text = sourceFile.text; - var width = comment.end - comment.pos; - if (width <= 2 || text.charCodeAt(comment.pos + 1) === 47) { - return true; - } - else { - return !(text.charCodeAt(comment.end - 1) === 47 && - text.charCodeAt(comment.end - 2) === 42); - } - } - return false; - }); - } - } - var keywordCompletions = []; - for (var i = 70; i <= 134; i++) { - keywordCompletions.push({ - name: ts.tokenToString(i), - kind: ScriptElementKind.keyword, - kindModifiers: ScriptElementKindModifier.none, - sortText: "0" - }); - } - function getContainerNode(node) { - while (true) { - node = node.parent; - if (!node) { - return undefined; - } - switch (node.kind) { - case 248: - case 143: - case 142: - case 213: - case 173: - case 145: - case 146: - case 214: - case 215: - case 217: - case 218: - return node; - } - } - } - ts.getContainerNode = getContainerNode; - function getNodeKind(node) { - switch (node.kind) { - case 218: return ScriptElementKind.moduleElement; - case 214: return ScriptElementKind.classElement; - case 215: return ScriptElementKind.interfaceElement; - case 216: return ScriptElementKind.typeElement; - case 217: return ScriptElementKind.enumElement; - case 211: - return ts.isConst(node) - ? ScriptElementKind.constElement - : ts.isLet(node) - ? ScriptElementKind.letElement - : ScriptElementKind.variableElement; - case 213: return ScriptElementKind.functionElement; - case 145: return ScriptElementKind.memberGetAccessorElement; - case 146: return ScriptElementKind.memberSetAccessorElement; - case 143: - case 142: - return ScriptElementKind.memberFunctionElement; - case 141: - case 140: - return ScriptElementKind.memberVariableElement; - case 149: return ScriptElementKind.indexSignatureElement; - case 148: return ScriptElementKind.constructSignatureElement; - case 147: return ScriptElementKind.callSignatureElement; - case 144: return ScriptElementKind.constructorImplementationElement; - case 137: return ScriptElementKind.typeParameterElement; - case 247: return ScriptElementKind.variableElement; - case 138: return (node.flags & 112) ? ScriptElementKind.memberVariableElement : ScriptElementKind.parameterElement; - case 221: - case 226: - case 223: - case 230: - case 224: - return ScriptElementKind.alias; - } - return ScriptElementKind.unknown; - } - ts.getNodeKind = getNodeKind; - var CancellationTokenObject = (function () { - function CancellationTokenObject(cancellationToken) { - this.cancellationToken = cancellationToken; - } - CancellationTokenObject.prototype.isCancellationRequested = function () { - return this.cancellationToken && this.cancellationToken.isCancellationRequested(); - }; - CancellationTokenObject.prototype.throwIfCancellationRequested = function () { - if (this.isCancellationRequested()) { - throw new ts.OperationCanceledException(); - } - }; - return CancellationTokenObject; - })(); - function createLanguageService(host, documentRegistry) { - if (documentRegistry === void 0) { documentRegistry = createDocumentRegistry(); } - var syntaxTreeCache = new SyntaxTreeCache(host); - var ruleProvider; - var program; - var lastProjectVersion; - var useCaseSensitivefileNames = false; - var cancellationToken = new CancellationTokenObject(host.getCancellationToken && host.getCancellationToken()); - if (!ts.localizedDiagnosticMessages && host.getLocalizedDiagnosticMessages) { - ts.localizedDiagnosticMessages = host.getLocalizedDiagnosticMessages(); - } - function log(message) { - if (host.log) { - host.log(message); - } - } - var getCanonicalFileName = createGetCanonicalFileName(useCaseSensitivefileNames); - function getValidSourceFile(fileName) { - fileName = ts.normalizeSlashes(fileName); - var sourceFile = program.getSourceFile(getCanonicalFileName(fileName)); - if (!sourceFile) { - throw new Error("Could not find file: '" + fileName + "'."); - } - return sourceFile; - } - function getRuleProvider(options) { - if (!ruleProvider) { - ruleProvider = new ts.formatting.RulesProvider(); - } - ruleProvider.ensureUpToDate(options); - return ruleProvider; - } - function synchronizeHostData() { - if (host.getProjectVersion) { - var hostProjectVersion = host.getProjectVersion(); - if (hostProjectVersion) { - if (lastProjectVersion === hostProjectVersion) { - return; - } - lastProjectVersion = hostProjectVersion; - } - } - var hostCache = new HostCache(host, getCanonicalFileName); - if (programUpToDate()) { - return; - } - var oldSettings = program && program.getCompilerOptions(); - var newSettings = hostCache.compilationSettings(); - var changesInCompilationSettingsAffectSyntax = oldSettings && - (oldSettings.target !== newSettings.target || - oldSettings.module !== newSettings.module || - oldSettings.noResolve !== newSettings.noResolve || - oldSettings.jsx !== newSettings.jsx); - var compilerHost = { - getSourceFile: getOrCreateSourceFile, - getCancellationToken: function () { return cancellationToken; }, - getCanonicalFileName: getCanonicalFileName, - useCaseSensitiveFileNames: function () { return useCaseSensitivefileNames; }, - getNewLine: function () { return ts.getNewLineOrDefaultFromHost(host); }, - getDefaultLibFileName: function (options) { return host.getDefaultLibFileName(options); }, - writeFile: function (fileName, data, writeByteOrderMark) { }, - getCurrentDirectory: function () { return host.getCurrentDirectory(); }, - fileExists: function (fileName) { - ts.Debug.assert(!host.resolveModuleNames); - return hostCache.getOrCreateEntry(fileName) !== undefined; - }, - readFile: function (fileName) { - var entry = hostCache.getOrCreateEntry(fileName); - return entry && entry.scriptSnapshot.getText(0, entry.scriptSnapshot.getLength()); - } - }; - if (host.resolveModuleNames) { - compilerHost.resolveModuleNames = function (moduleNames, containingFile) { return host.resolveModuleNames(moduleNames, containingFile); }; - } - var newProgram = ts.createProgram(hostCache.getRootFileNames(), newSettings, compilerHost, program); - if (program) { - var oldSourceFiles = program.getSourceFiles(); - for (var _i = 0; _i < oldSourceFiles.length; _i++) { - var oldSourceFile = oldSourceFiles[_i]; - var fileName = oldSourceFile.fileName; - if (!newProgram.getSourceFile(fileName) || changesInCompilationSettingsAffectSyntax) { - documentRegistry.releaseDocument(fileName, oldSettings); - } - } - } - hostCache = undefined; - program = newProgram; - program.getTypeChecker(); - return; - function getOrCreateSourceFile(fileName) { - ts.Debug.assert(hostCache !== undefined); - var hostFileInformation = hostCache.getOrCreateEntry(fileName); - if (!hostFileInformation) { - return undefined; - } - if (!changesInCompilationSettingsAffectSyntax) { - var oldSourceFile = program && program.getSourceFile(fileName); - if (oldSourceFile) { - return documentRegistry.updateDocument(fileName, newSettings, hostFileInformation.scriptSnapshot, hostFileInformation.version); - } - } - return documentRegistry.acquireDocument(fileName, newSettings, hostFileInformation.scriptSnapshot, hostFileInformation.version); - } - function sourceFileUpToDate(sourceFile) { - return sourceFile && sourceFile.version === hostCache.getVersion(sourceFile.fileName); - } - function programUpToDate() { - if (!program) { - return false; - } - var rootFileNames = hostCache.getRootFileNames(); - if (program.getSourceFiles().length !== rootFileNames.length) { - return false; - } - for (var _i = 0; _i < rootFileNames.length; _i++) { - var fileName = rootFileNames[_i]; - if (!sourceFileUpToDate(program.getSourceFile(fileName))) { - return false; - } - } - return ts.compareDataObjects(program.getCompilerOptions(), hostCache.compilationSettings()); - } - } - function getProgram() { - synchronizeHostData(); - return program; - } - function cleanupSemanticCache() { - } - function dispose() { - if (program) { - ts.forEach(program.getSourceFiles(), function (f) { - return documentRegistry.releaseDocument(f.fileName, program.getCompilerOptions()); - }); - } - } - function getSyntacticDiagnostics(fileName) { - synchronizeHostData(); - return program.getSyntacticDiagnostics(getValidSourceFile(fileName), cancellationToken); - } - function getSemanticDiagnostics(fileName) { - synchronizeHostData(); - var targetSourceFile = getValidSourceFile(fileName); - if (ts.isJavaScript(fileName)) { - return getJavaScriptSemanticDiagnostics(targetSourceFile); - } - var semanticDiagnostics = program.getSemanticDiagnostics(targetSourceFile, cancellationToken); - if (!program.getCompilerOptions().declaration) { - return semanticDiagnostics; - } - var declarationDiagnostics = program.getDeclarationDiagnostics(targetSourceFile, cancellationToken); - return ts.concatenate(semanticDiagnostics, declarationDiagnostics); - } - function getJavaScriptSemanticDiagnostics(sourceFile) { - var diagnostics = []; - walk(sourceFile); - return diagnostics; - function walk(node) { - if (!node) { - return false; - } - switch (node.kind) { - case 221: - diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.import_can_only_be_used_in_a_ts_file)); - return true; - case 227: - diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.export_can_only_be_used_in_a_ts_file)); - return true; - case 214: - var classDeclaration = node; - if (checkModifiers(classDeclaration.modifiers) || - checkTypeParameters(classDeclaration.typeParameters)) { - return true; - } - break; - case 243: - var heritageClause = node; - if (heritageClause.token === 106) { - diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.implements_clauses_can_only_be_used_in_a_ts_file)); - return true; - } - break; - case 215: - diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.interface_declarations_can_only_be_used_in_a_ts_file)); - return true; - case 218: - diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.module_declarations_can_only_be_used_in_a_ts_file)); - return true; - case 216: - diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.type_aliases_can_only_be_used_in_a_ts_file)); - return true; - case 143: - case 142: - case 144: - case 145: - case 146: - case 173: - case 213: - case 174: - case 213: - var functionDeclaration = node; - if (checkModifiers(functionDeclaration.modifiers) || - checkTypeParameters(functionDeclaration.typeParameters) || - checkTypeAnnotation(functionDeclaration.type)) { - return true; - } - break; - case 193: - var variableStatement = node; - if (checkModifiers(variableStatement.modifiers)) { - return true; - } - break; - case 211: - var variableDeclaration = node; - if (checkTypeAnnotation(variableDeclaration.type)) { - return true; - } - break; - case 168: - case 169: - var expression = node; - if (expression.typeArguments && expression.typeArguments.length > 0) { - var start = expression.typeArguments.pos; - diagnostics.push(ts.createFileDiagnostic(sourceFile, start, expression.typeArguments.end - start, ts.Diagnostics.type_arguments_can_only_be_used_in_a_ts_file)); - return true; - } - break; - case 138: - var parameter = node; - if (parameter.modifiers) { - var start = parameter.modifiers.pos; - diagnostics.push(ts.createFileDiagnostic(sourceFile, start, parameter.modifiers.end - start, ts.Diagnostics.parameter_modifiers_can_only_be_used_in_a_ts_file)); - return true; - } - if (parameter.questionToken) { - diagnostics.push(ts.createDiagnosticForNode(parameter.questionToken, ts.Diagnostics._0_can_only_be_used_in_a_ts_file, '?')); - return true; - } - if (parameter.type) { - diagnostics.push(ts.createDiagnosticForNode(parameter.type, ts.Diagnostics.types_can_only_be_used_in_a_ts_file)); - return true; - } - break; - case 141: - diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.property_declarations_can_only_be_used_in_a_ts_file)); - return true; - case 217: - diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.enum_declarations_can_only_be_used_in_a_ts_file)); - return true; - case 171: - var typeAssertionExpression = node; - diagnostics.push(ts.createDiagnosticForNode(typeAssertionExpression.type, ts.Diagnostics.type_assertion_expressions_can_only_be_used_in_a_ts_file)); - return true; - case 139: - diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.decorators_can_only_be_used_in_a_ts_file)); - return true; - } - return ts.forEachChild(node, walk); - } - function checkTypeParameters(typeParameters) { - if (typeParameters) { - var start = typeParameters.pos; - diagnostics.push(ts.createFileDiagnostic(sourceFile, start, typeParameters.end - start, ts.Diagnostics.type_parameter_declarations_can_only_be_used_in_a_ts_file)); - return true; - } - return false; - } - function checkTypeAnnotation(type) { - if (type) { - diagnostics.push(ts.createDiagnosticForNode(type, ts.Diagnostics.types_can_only_be_used_in_a_ts_file)); - return true; - } - return false; - } - function checkModifiers(modifiers) { - if (modifiers) { - for (var _i = 0; _i < modifiers.length; _i++) { - var modifier = modifiers[_i]; - switch (modifier.kind) { - case 112: - case 110: - case 111: - case 122: - diagnostics.push(ts.createDiagnosticForNode(modifier, ts.Diagnostics._0_can_only_be_used_in_a_ts_file, ts.tokenToString(modifier.kind))); - return true; - case 113: - case 82: - case 74: - case 77: - case 115: - } - } - } - return false; - } - } - function getCompilerOptionsDiagnostics() { - synchronizeHostData(); - return program.getOptionsDiagnostics(cancellationToken).concat(program.getGlobalDiagnostics(cancellationToken)); - } - function getCompletionEntryDisplayNameForSymbol(symbol, target, performCharacterChecks, location) { - var displayName = ts.getDeclaredName(program.getTypeChecker(), symbol, location); - if (displayName) { - var firstCharCode = displayName.charCodeAt(0); - if ((symbol.flags & 1536) && (firstCharCode === 39 || firstCharCode === 34)) { - return undefined; - } - } - return getCompletionEntryDisplayName(displayName, target, performCharacterChecks); - } - function getCompletionEntryDisplayName(name, target, performCharacterChecks) { - if (!name) { - return undefined; - } - name = ts.stripQuotes(name); - if (!name) { - return undefined; - } - if (performCharacterChecks) { - if (!ts.isIdentifierStart(name.charCodeAt(0), target)) { - return undefined; - } - for (var i = 1, n = name.length; i < n; i++) { - if (!ts.isIdentifierPart(name.charCodeAt(i), target)) { - return undefined; - } - } - } - return name; - } - function getCompletionData(fileName, position) { - var typeChecker = program.getTypeChecker(); - var syntacticStart = new Date().getTime(); - var sourceFile = getValidSourceFile(fileName); - var isJavaScriptFile = ts.isJavaScript(fileName); - var isJsDocTagName = false; - var start = new Date().getTime(); - var currentToken = ts.getTokenAtPosition(sourceFile, position); - log("getCompletionData: Get current token: " + (new Date().getTime() - start)); - start = new Date().getTime(); - var insideComment = isInsideComment(sourceFile, currentToken, position); - log("getCompletionData: Is inside comment: " + (new Date().getTime() - start)); - if (insideComment) { - if (ts.hasDocComment(sourceFile, position) && sourceFile.text.charCodeAt(position - 1) === 64) { - isJsDocTagName = true; - } - var insideJsDocTagExpression = false; - var tag = ts.getJsDocTagAtPosition(sourceFile, position); - if (tag) { - if (tag.tagName.pos <= position && position <= tag.tagName.end) { - isJsDocTagName = true; - } - switch (tag.kind) { - case 269: - case 267: - case 268: - var tagWithExpression = tag; - if (tagWithExpression.typeExpression) { - insideJsDocTagExpression = tagWithExpression.typeExpression.pos < position && position < tagWithExpression.typeExpression.end; - } - break; - } - } - if (isJsDocTagName) { - return { symbols: undefined, 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."); - return undefined; - } - } - start = new Date().getTime(); - var previousToken = ts.findPrecedingToken(position, sourceFile); - log("getCompletionData: Get previous token 1: " + (new Date().getTime() - start)); - var contextToken = previousToken; - if (contextToken && position <= contextToken.end && ts.isWord(contextToken.kind)) { - var start_4 = new Date().getTime(); - contextToken = ts.findPrecedingToken(contextToken.getFullStart(), sourceFile); - log("getCompletionData: Get previous token 2: " + (new Date().getTime() - start_4)); - } - var node = currentToken; - var isRightOfDot = false; - var isRightOfOpenTag = false; - var isStartingCloseTag = false; - var location = ts.getTouchingPropertyName(sourceFile, position); - if (contextToken) { - if (isCompletionListBlocker(contextToken)) { - log("Returning an empty list because completion was requested in an invalid position."); - return undefined; - } - var parent_9 = contextToken.parent, kind = contextToken.kind; - if (kind === 21) { - if (parent_9.kind === 166) { - node = contextToken.parent.expression; - isRightOfDot = true; - } - else if (parent_9.kind === 135) { - node = contextToken.parent.left; - isRightOfDot = true; - } - else { - return undefined; - } - } - else if (sourceFile.languageVariant === 1) { - if (kind === 25) { - isRightOfOpenTag = true; - location = contextToken; - } - else if (kind === 39 && contextToken.parent.kind === 237) { - isStartingCloseTag = true; - } - } - } - var semanticStart = new Date().getTime(); - var isMemberCompletion; - var isNewIdentifierLocation; - var symbols = []; - if (isRightOfDot) { - getTypeScriptMemberSymbols(); - } - else if (isRightOfOpenTag) { - var tagSymbols = typeChecker.getJsxIntrinsicTagNames(); - if (tryGetGlobalSymbols()) { - symbols = tagSymbols.concat(symbols.filter(function (s) { return !!(s.flags & 107455); })); - } - else { - symbols = tagSymbols; - } - isMemberCompletion = true; - isNewIdentifierLocation = false; - } - else if (isStartingCloseTag) { - var tagName = contextToken.parent.parent.openingElement.tagName; - symbols = [typeChecker.getSymbolAtLocation(tagName)]; - isMemberCompletion = true; - isNewIdentifierLocation = false; - } - else { - if (!tryGetGlobalSymbols()) { - return undefined; - } - } - log("getCompletionData: Semantic work: " + (new Date().getTime() - semanticStart)); - return { symbols: symbols, isMemberCompletion: isMemberCompletion, isNewIdentifierLocation: isNewIdentifierLocation, location: location, isRightOfDot: (isRightOfDot || isRightOfOpenTag), isJsDocTagName: isJsDocTagName }; - function getTypeScriptMemberSymbols() { - isMemberCompletion = true; - isNewIdentifierLocation = false; - if (node.kind === 69 || node.kind === 135 || node.kind === 166) { - var symbol = typeChecker.getSymbolAtLocation(node); - if (symbol && symbol.flags & 8388608) { - symbol = typeChecker.getAliasedSymbol(symbol); - } - if (symbol && symbol.flags & 1952) { - var exportedSymbols = typeChecker.getExportsOfModule(symbol); - ts.forEach(exportedSymbols, function (symbol) { - if (typeChecker.isValidPropertyAccess((node.parent), symbol.name)) { - symbols.push(symbol); - } - }); - } - } - var type = typeChecker.getTypeAtLocation(node); - addTypeProperties(type); - } - function addTypeProperties(type) { - if (type) { - for (var _i = 0, _a = type.getApparentProperties(); _i < _a.length; _i++) { - var symbol = _a[_i]; - if (typeChecker.isValidPropertyAccess((node.parent), symbol.name)) { - symbols.push(symbol); - } - } - if (isJavaScriptFile && type.flags & 16384) { - var unionType = type; - for (var _b = 0, _c = unionType.types; _b < _c.length; _b++) { - var elementType = _c[_b]; - addTypeProperties(elementType); - } - } - } - } - function tryGetGlobalSymbols() { - var objectLikeContainer; - var namedImportsOrExports; - var jsxContainer; - if (objectLikeContainer = tryGetObjectLikeCompletionContainer(contextToken)) { - return tryGetObjectLikeCompletionSymbols(objectLikeContainer); - } - if (namedImportsOrExports = tryGetNamedImportsOrExportsForCompletion(contextToken)) { - return tryGetImportOrExportClauseCompletionSymbols(namedImportsOrExports); - } - if (jsxContainer = tryGetContainingJsxElement(contextToken)) { - var attrsType; - if ((jsxContainer.kind === 234) || (jsxContainer.kind === 235)) { - attrsType = typeChecker.getJsxElementAttributesType(jsxContainer); - if (attrsType) { - symbols = filterJsxAttributes(typeChecker.getPropertiesOfType(attrsType), jsxContainer.attributes); - isMemberCompletion = true; - isNewIdentifierLocation = false; - return true; - } - } - } - isMemberCompletion = false; - isNewIdentifierLocation = isNewIdentifierDefinitionLocation(contextToken); - if (previousToken !== contextToken) { - ts.Debug.assert(!!previousToken, "Expected 'contextToken' to be defined when different from 'previousToken'."); - } - var adjustedPosition = previousToken !== contextToken ? - previousToken.getStart() : - position; - var scopeNode = getScopeNode(contextToken, adjustedPosition, sourceFile) || sourceFile; - var symbolMeanings = 793056 | 107455 | 1536 | 8388608; - symbols = typeChecker.getSymbolsInScope(scopeNode, symbolMeanings); - return true; - } - function getScopeNode(initialToken, position, sourceFile) { - var scope = initialToken; - while (scope && !ts.positionBelongsToNode(scope, position, sourceFile)) { - scope = scope.parent; - } - return scope; - } - function isCompletionListBlocker(contextToken) { - var start = new Date().getTime(); - var result = isInStringOrRegularExpressionOrTemplateLiteral(contextToken) || - isSolelyIdentifierDefinitionLocation(contextToken) || - isDotOfNumericLiteral(contextToken) || - isInJsxText(contextToken); - log("getCompletionsAtPosition: isCompletionListBlocker: " + (new Date().getTime() - start)); - return result; - } - function isInJsxText(contextToken) { - if (contextToken.kind === 236) { - return true; - } - if (contextToken.kind === 27 && contextToken.parent) { - if (contextToken.parent.kind === 235) { - return true; - } - if (contextToken.parent.kind === 237 || contextToken.parent.kind === 234) { - return contextToken.parent.parent && contextToken.parent.parent.kind === 233; - } - } - return false; - } - function isNewIdentifierDefinitionLocation(previousToken) { - if (previousToken) { - var containingNodeKind = previousToken.parent.kind; - switch (previousToken.kind) { - case 24: - return containingNodeKind === 168 - || containingNodeKind === 144 - || containingNodeKind === 169 - || containingNodeKind === 164 - || containingNodeKind === 181 - || containingNodeKind === 152; - case 17: - return containingNodeKind === 168 - || containingNodeKind === 144 - || containingNodeKind === 169 - || containingNodeKind === 172 - || containingNodeKind === 160; - case 19: - return containingNodeKind === 164 - || containingNodeKind === 149 - || containingNodeKind === 136; - case 125: - case 126: - return true; - case 21: - return containingNodeKind === 218; - case 15: - return containingNodeKind === 214; - case 56: - return containingNodeKind === 211 - || containingNodeKind === 181; - case 12: - return containingNodeKind === 183; - case 13: - return containingNodeKind === 190; - case 112: - case 110: - case 111: - return containingNodeKind === 141; - } - switch (previousToken.getText()) { - case "public": - case "protected": - case "private": - return true; - } - } - return false; - } - function isInStringOrRegularExpressionOrTemplateLiteral(contextToken) { - if (contextToken.kind === 9 - || contextToken.kind === 10 - || ts.isTemplateLiteralKind(contextToken.kind)) { - var start_5 = contextToken.getStart(); - var end = contextToken.getEnd(); - if (start_5 < position && position < end) { - return true; - } - if (position === end) { - return !!contextToken.isUnterminated - || contextToken.kind === 10; - } - } - return false; - } - function tryGetObjectLikeCompletionSymbols(objectLikeContainer) { - isMemberCompletion = true; - var typeForObject; - var existingMembers; - if (objectLikeContainer.kind === 165) { - isNewIdentifierLocation = true; - typeForObject = typeChecker.getContextualType(objectLikeContainer); - existingMembers = objectLikeContainer.properties; - } - else if (objectLikeContainer.kind === 161) { - isNewIdentifierLocation = false; - var rootDeclaration = ts.getRootDeclaration(objectLikeContainer.parent); - if (ts.isVariableLike(rootDeclaration)) { - if (rootDeclaration.initializer || rootDeclaration.type) { - typeForObject = typeChecker.getTypeAtLocation(objectLikeContainer); - existingMembers = objectLikeContainer.elements; - } - } - else { - ts.Debug.fail("Root declaration is not variable-like."); - } - } - else { - ts.Debug.fail("Expected object literal or binding pattern, got " + objectLikeContainer.kind); - } - if (!typeForObject) { - return false; - } - var typeMembers = typeChecker.getPropertiesOfType(typeForObject); - if (typeMembers && typeMembers.length > 0) { - symbols = filterObjectMembersList(typeMembers, existingMembers); - } - return true; - } - function tryGetImportOrExportClauseCompletionSymbols(namedImportsOrExports) { - var declarationKind = namedImportsOrExports.kind === 225 ? - 222 : - 228; - var importOrExportDeclaration = ts.getAncestor(namedImportsOrExports, declarationKind); - var moduleSpecifier = importOrExportDeclaration.moduleSpecifier; - if (!moduleSpecifier) { - return false; - } - isMemberCompletion = true; - isNewIdentifierLocation = false; - var exports; - var moduleSpecifierSymbol = typeChecker.getSymbolAtLocation(importOrExportDeclaration.moduleSpecifier); - if (moduleSpecifierSymbol) { - exports = typeChecker.getExportsOfModule(moduleSpecifierSymbol); - } - symbols = exports ? filterNamedImportOrExportCompletionItems(exports, namedImportsOrExports.elements) : emptyArray; - return true; - } - function tryGetObjectLikeCompletionContainer(contextToken) { - if (contextToken) { - switch (contextToken.kind) { - case 15: - case 24: - var parent_10 = contextToken.parent; - if (parent_10 && (parent_10.kind === 165 || parent_10.kind === 161)) { - return parent_10; - } - break; - } - } - return undefined; - } - function tryGetNamedImportsOrExportsForCompletion(contextToken) { - if (contextToken) { - switch (contextToken.kind) { - case 15: - case 24: - switch (contextToken.parent.kind) { - case 225: - case 229: - return contextToken.parent; - } - } - } - return undefined; - } - function tryGetContainingJsxElement(contextToken) { - if (contextToken) { - var parent_11 = contextToken.parent; - switch (contextToken.kind) { - case 26: - case 39: - case 69: - case 238: - case 239: - if (parent_11 && (parent_11.kind === 234 || parent_11.kind === 235)) { - return parent_11; - } - else if (parent_11.kind === 238) { - return parent_11.parent; - } - break; - case 9: - if (parent_11 && ((parent_11.kind === 238) || (parent_11.kind === 239))) { - return parent_11.parent; - } - break; - case 16: - if (parent_11 && - parent_11.kind === 240 && - parent_11.parent && - (parent_11.parent.kind === 238)) { - return parent_11.parent.parent; - } - if (parent_11 && parent_11.kind === 239) { - return parent_11.parent; - } - break; - } - } - return undefined; - } - function isFunction(kind) { - switch (kind) { - case 173: - case 174: - case 213: - case 143: - case 142: - case 145: - case 146: - case 147: - case 148: - case 149: - return true; - } - return false; - } - function isSolelyIdentifierDefinitionLocation(contextToken) { - var containingNodeKind = contextToken.parent.kind; - switch (contextToken.kind) { - case 24: - return containingNodeKind === 211 || - containingNodeKind === 212 || - containingNodeKind === 193 || - containingNodeKind === 217 || - isFunction(containingNodeKind) || - containingNodeKind === 214 || - containingNodeKind === 186 || - containingNodeKind === 215 || - containingNodeKind === 162 || - containingNodeKind === 216; - case 21: - return containingNodeKind === 162; - case 54: - return containingNodeKind === 163; - case 19: - return containingNodeKind === 162; - case 17: - return containingNodeKind === 244 || - isFunction(containingNodeKind); - case 15: - return containingNodeKind === 217 || - containingNodeKind === 215 || - containingNodeKind === 155; - case 23: - return containingNodeKind === 140 && - contextToken.parent && contextToken.parent.parent && - (contextToken.parent.parent.kind === 215 || - contextToken.parent.parent.kind === 155); - case 25: - return containingNodeKind === 214 || - containingNodeKind === 186 || - containingNodeKind === 215 || - containingNodeKind === 216 || - isFunction(containingNodeKind); - case 113: - return containingNodeKind === 141; - case 22: - return containingNodeKind === 138 || - (contextToken.parent && contextToken.parent.parent && - contextToken.parent.parent.kind === 162); - case 112: - case 110: - case 111: - return containingNodeKind === 138; - case 116: - return containingNodeKind === 226 || - containingNodeKind === 230 || - containingNodeKind === 224; - case 73: - case 81: - case 107: - case 87: - case 102: - case 123: - case 129: - case 89: - case 108: - case 74: - case 114: - case 132: - return true; - } - switch (contextToken.getText()) { - case "abstract": - case "async": - case "class": - case "const": - case "declare": - case "enum": - case "function": - case "interface": - case "let": - case "private": - case "protected": - case "public": - case "static": - case "var": - case "yield": - return true; - } - return false; - } - function isDotOfNumericLiteral(contextToken) { - if (contextToken.kind === 8) { - var text = contextToken.getFullText(); - return text.charAt(text.length - 1) === "."; - } - return false; - } - function filterNamedImportOrExportCompletionItems(exportsOfModule, namedImportsOrExports) { - var exisingImportsOrExports = {}; - for (var _i = 0; _i < namedImportsOrExports.length; _i++) { - var element = namedImportsOrExports[_i]; - if (element.getStart() <= position && position <= element.getEnd()) { - continue; - } - var name_32 = element.propertyName || element.name; - exisingImportsOrExports[name_32.text] = true; - } - if (ts.isEmpty(exisingImportsOrExports)) { - return exportsOfModule; - } - return ts.filter(exportsOfModule, function (e) { return !ts.lookUp(exisingImportsOrExports, e.name); }); - } - function filterObjectMembersList(contextualMemberSymbols, existingMembers) { - if (!existingMembers || existingMembers.length === 0) { - return contextualMemberSymbols; - } - var existingMemberNames = {}; - for (var _i = 0; _i < existingMembers.length; _i++) { - var m = existingMembers[_i]; - if (m.kind !== 245 && - m.kind !== 246 && - m.kind !== 163) { - continue; - } - if (m.getStart() <= position && position <= m.getEnd()) { - continue; - } - var existingName = void 0; - if (m.kind === 163 && m.propertyName) { - existingName = m.propertyName.text; - } - else { - existingName = m.name.text; - } - existingMemberNames[existingName] = true; - } - return ts.filter(contextualMemberSymbols, function (m) { return !ts.lookUp(existingMemberNames, m.name); }); - } - function filterJsxAttributes(symbols, attributes) { - var seenNames = {}; - for (var _i = 0; _i < attributes.length; _i++) { - var attr = attributes[_i]; - if (attr.getStart() <= position && position <= attr.getEnd()) { - continue; - } - if (attr.kind === 238) { - seenNames[attr.name.text] = true; - } - } - return ts.filter(symbols, function (a) { return !ts.lookUp(seenNames, a.name); }); - } - } - function getCompletionsAtPosition(fileName, position) { - synchronizeHostData(); - var completionData = getCompletionData(fileName, position); - if (!completionData) { - return undefined; - } - var symbols = completionData.symbols, isMemberCompletion = completionData.isMemberCompletion, isNewIdentifierLocation = completionData.isNewIdentifierLocation, location = completionData.location, isRightOfDot = completionData.isRightOfDot, isJsDocTagName = completionData.isJsDocTagName; - var entries; - if (isJsDocTagName) { - return { isMemberCompletion: false, isNewIdentifierLocation: false, entries: getAllJsDocCompletionEntries() }; - } - if (isRightOfDot && ts.isJavaScript(fileName)) { - entries = getCompletionEntriesFromSymbols(symbols); - ts.addRange(entries, getJavaScriptCompletionEntries()); - } - else { - if (!symbols || symbols.length === 0) { - return undefined; - } - entries = getCompletionEntriesFromSymbols(symbols); - } - if (!isMemberCompletion && !isJsDocTagName) { - ts.addRange(entries, keywordCompletions); - } - return { isMemberCompletion: isMemberCompletion, isNewIdentifierLocation: isNewIdentifierLocation, entries: entries }; - function getJavaScriptCompletionEntries() { - var entries = []; - var allNames = {}; - var target = program.getCompilerOptions().target; - for (var _i = 0, _a = program.getSourceFiles(); _i < _a.length; _i++) { - var sourceFile = _a[_i]; - var nameTable = getNameTable(sourceFile); - for (var name_33 in nameTable) { - if (!allNames[name_33]) { - allNames[name_33] = name_33; - var displayName = getCompletionEntryDisplayName(name_33, target, true); - if (displayName) { - var entry = { - name: displayName, - kind: ScriptElementKind.warning, - kindModifiers: "", - sortText: "1" - }; - entries.push(entry); - } - } - } - } - return entries; - } - function getAllJsDocCompletionEntries() { - return jsDocCompletionEntries || (jsDocCompletionEntries = ts.map(jsDocTagNames, function (tagName) { - return { - name: tagName, - kind: ScriptElementKind.keyword, - kindModifiers: "", - sortText: "0" - }; - })); - } - function createCompletionEntry(symbol, location) { - var displayName = getCompletionEntryDisplayNameForSymbol(symbol, program.getCompilerOptions().target, true, location); - if (!displayName) { - return undefined; - } - return { - name: displayName, - kind: getSymbolKind(symbol, location), - kindModifiers: getSymbolModifiers(symbol), - sortText: "0" - }; - } - function getCompletionEntriesFromSymbols(symbols) { - var start = new Date().getTime(); - var entries = []; - if (symbols) { - var nameToSymbol = {}; - for (var _i = 0; _i < symbols.length; _i++) { - var symbol = symbols[_i]; - var entry = createCompletionEntry(symbol, location); - if (entry) { - var id = ts.escapeIdentifier(entry.name); - if (!ts.lookUp(nameToSymbol, id)) { - entries.push(entry); - nameToSymbol[id] = symbol; - } - } - } - } - log("getCompletionsAtPosition: getCompletionEntriesFromSymbols: " + (new Date().getTime() - start)); - return entries; - } - } - function getCompletionEntryDetails(fileName, position, entryName) { - synchronizeHostData(); - var completionData = getCompletionData(fileName, position); - if (completionData) { - var symbols = completionData.symbols, location_2 = completionData.location; - var target = program.getCompilerOptions().target; - var symbol = ts.forEach(symbols, function (s) { return getCompletionEntryDisplayNameForSymbol(s, target, false, location_2) === entryName ? s : undefined; }); - if (symbol) { - var _a = getSymbolDisplayPartsDocumentationAndSymbolKind(symbol, getValidSourceFile(fileName), location_2, location_2, 7), displayParts = _a.displayParts, documentation = _a.documentation, symbolKind = _a.symbolKind; - return { - name: entryName, - kindModifiers: getSymbolModifiers(symbol), - kind: symbolKind, - displayParts: displayParts, - documentation: documentation - }; - } - } - var keywordCompletion = ts.forEach(keywordCompletions, function (c) { return c.name === entryName; }); - if (keywordCompletion) { - return { - name: entryName, - kind: ScriptElementKind.keyword, - kindModifiers: ScriptElementKindModifier.none, - displayParts: [ts.displayPart(entryName, SymbolDisplayPartKind.keyword)], - documentation: undefined - }; - } - return undefined; - } - function getSymbolKind(symbol, location) { - var flags = symbol.getFlags(); - if (flags & 32) - return ts.getDeclarationOfKind(symbol, 186) ? - ScriptElementKind.localClassElement : ScriptElementKind.classElement; - if (flags & 384) - return ScriptElementKind.enumElement; - if (flags & 524288) - return ScriptElementKind.typeElement; - if (flags & 64) - return ScriptElementKind.interfaceElement; - if (flags & 262144) - return ScriptElementKind.typeParameterElement; - var result = getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar(symbol, flags, location); - if (result === ScriptElementKind.unknown) { - if (flags & 262144) - return ScriptElementKind.typeParameterElement; - if (flags & 8) - return ScriptElementKind.variableElement; - if (flags & 8388608) - return ScriptElementKind.alias; - if (flags & 1536) - return ScriptElementKind.moduleElement; - } - return result; - } - function getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar(symbol, flags, location) { - var typeChecker = program.getTypeChecker(); - if (typeChecker.isUndefinedSymbol(symbol)) { - return ScriptElementKind.variableElement; - } - if (typeChecker.isArgumentsSymbol(symbol)) { - return ScriptElementKind.localVariableElement; - } - if (flags & 3) { - if (ts.isFirstDeclarationOfSymbolParameter(symbol)) { - return ScriptElementKind.parameterElement; - } - else if (symbol.valueDeclaration && ts.isConst(symbol.valueDeclaration)) { - return ScriptElementKind.constElement; - } - else if (ts.forEach(symbol.declarations, ts.isLet)) { - return ScriptElementKind.letElement; - } - return isLocalVariableOrFunction(symbol) ? ScriptElementKind.localVariableElement : ScriptElementKind.variableElement; - } - if (flags & 16) - return isLocalVariableOrFunction(symbol) ? ScriptElementKind.localFunctionElement : ScriptElementKind.functionElement; - if (flags & 32768) - return ScriptElementKind.memberGetAccessorElement; - if (flags & 65536) - return ScriptElementKind.memberSetAccessorElement; - if (flags & 8192) - return ScriptElementKind.memberFunctionElement; - if (flags & 16384) - return ScriptElementKind.constructorImplementationElement; - if (flags & 4) { - if (flags & 268435456) { - var unionPropertyKind = ts.forEach(typeChecker.getRootSymbols(symbol), function (rootSymbol) { - var rootSymbolFlags = rootSymbol.getFlags(); - if (rootSymbolFlags & (98308 | 3)) { - return ScriptElementKind.memberVariableElement; - } - ts.Debug.assert(!!(rootSymbolFlags & 8192)); - }); - if (!unionPropertyKind) { - var typeOfUnionProperty = typeChecker.getTypeOfSymbolAtLocation(symbol, location); - if (typeOfUnionProperty.getCallSignatures().length) { - return ScriptElementKind.memberFunctionElement; - } - return ScriptElementKind.memberVariableElement; - } - return unionPropertyKind; - } - return ScriptElementKind.memberVariableElement; - } - return ScriptElementKind.unknown; - } - function getSymbolModifiers(symbol) { - return symbol && symbol.declarations && symbol.declarations.length > 0 - ? ts.getNodeModifiers(symbol.declarations[0]) - : ScriptElementKindModifier.none; - } - function getSymbolDisplayPartsDocumentationAndSymbolKind(symbol, sourceFile, enclosingDeclaration, location, semanticMeaning) { - if (semanticMeaning === void 0) { semanticMeaning = getMeaningFromLocation(location); } - var typeChecker = program.getTypeChecker(); - var displayParts = []; - var documentation; - var symbolFlags = symbol.flags; - var symbolKind = getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar(symbol, symbolFlags, location); - var hasAddedSymbolInfo; - var type; - if (symbolKind !== ScriptElementKind.unknown || symbolFlags & 32 || symbolFlags & 8388608) { - if (symbolKind === ScriptElementKind.memberGetAccessorElement || symbolKind === ScriptElementKind.memberSetAccessorElement) { - symbolKind = ScriptElementKind.memberVariableElement; - } - var signature; - type = typeChecker.getTypeOfSymbolAtLocation(symbol, location); - if (type) { - if (location.parent && location.parent.kind === 166) { - var right = location.parent.name; - if (right === location || (right && right.getFullWidth() === 0)) { - location = location.parent; - } - } - var callExpression; - if (location.kind === 168 || location.kind === 169) { - callExpression = location; - } - else if (isCallExpressionTarget(location) || isNewExpressionTarget(location)) { - callExpression = location.parent; - } - if (callExpression) { - var candidateSignatures = []; - signature = typeChecker.getResolvedSignature(callExpression, candidateSignatures); - if (!signature && candidateSignatures.length) { - signature = candidateSignatures[0]; - } - var useConstructSignatures = callExpression.kind === 169 || callExpression.expression.kind === 95; - var allSignatures = useConstructSignatures ? type.getConstructSignatures() : type.getCallSignatures(); - if (!ts.contains(allSignatures, signature.target) && !ts.contains(allSignatures, signature)) { - signature = allSignatures.length ? allSignatures[0] : undefined; - } - if (signature) { - if (useConstructSignatures && (symbolFlags & 32)) { - symbolKind = ScriptElementKind.constructorImplementationElement; - addPrefixForAnyFunctionOrVar(type.symbol, symbolKind); - } - else if (symbolFlags & 8388608) { - symbolKind = ScriptElementKind.alias; - pushTypePart(symbolKind); - displayParts.push(ts.spacePart()); - if (useConstructSignatures) { - displayParts.push(ts.keywordPart(92)); - displayParts.push(ts.spacePart()); - } - addFullSymbolName(symbol); - } - else { - addPrefixForAnyFunctionOrVar(symbol, symbolKind); - } - switch (symbolKind) { - case ScriptElementKind.memberVariableElement: - case ScriptElementKind.variableElement: - case ScriptElementKind.constElement: - case ScriptElementKind.letElement: - case ScriptElementKind.parameterElement: - case ScriptElementKind.localVariableElement: - displayParts.push(ts.punctuationPart(54)); - displayParts.push(ts.spacePart()); - if (useConstructSignatures) { - displayParts.push(ts.keywordPart(92)); - displayParts.push(ts.spacePart()); - } - if (!(type.flags & 65536)) { - ts.addRange(displayParts, ts.symbolToDisplayParts(typeChecker, type.symbol, enclosingDeclaration, undefined, 1)); - } - addSignatureDisplayParts(signature, allSignatures, 8); - break; - default: - addSignatureDisplayParts(signature, allSignatures); - } - hasAddedSymbolInfo = true; - } - } - else if ((isNameOfFunctionDeclaration(location) && !(symbol.flags & 98304)) || - (location.kind === 121 && location.parent.kind === 144)) { - var functionDeclaration = location.parent; - var allSignatures = functionDeclaration.kind === 144 ? type.getConstructSignatures() : type.getCallSignatures(); - if (!typeChecker.isImplementationOfOverload(functionDeclaration)) { - signature = typeChecker.getSignatureFromDeclaration(functionDeclaration); - } - else { - signature = allSignatures[0]; - } - if (functionDeclaration.kind === 144) { - symbolKind = ScriptElementKind.constructorImplementationElement; - addPrefixForAnyFunctionOrVar(type.symbol, symbolKind); - } - else { - addPrefixForAnyFunctionOrVar(functionDeclaration.kind === 147 && - !(type.symbol.flags & 2048 || type.symbol.flags & 4096) ? type.symbol : symbol, symbolKind); - } - addSignatureDisplayParts(signature, allSignatures); - hasAddedSymbolInfo = true; - } - } - } - if (symbolFlags & 32 && !hasAddedSymbolInfo) { - if (ts.getDeclarationOfKind(symbol, 186)) { - pushTypePart(ScriptElementKind.localClassElement); - } - else { - displayParts.push(ts.keywordPart(73)); - } - displayParts.push(ts.spacePart()); - addFullSymbolName(symbol); - writeTypeParametersOfSymbol(symbol, sourceFile); - } - if ((symbolFlags & 64) && (semanticMeaning & 2)) { - addNewLineIfDisplayPartsExist(); - displayParts.push(ts.keywordPart(107)); - displayParts.push(ts.spacePart()); - addFullSymbolName(symbol); - writeTypeParametersOfSymbol(symbol, sourceFile); - } - if (symbolFlags & 524288) { - addNewLineIfDisplayPartsExist(); - displayParts.push(ts.keywordPart(132)); - displayParts.push(ts.spacePart()); - addFullSymbolName(symbol); - writeTypeParametersOfSymbol(symbol, sourceFile); - displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(56)); - displayParts.push(ts.spacePart()); - ts.addRange(displayParts, ts.typeToDisplayParts(typeChecker, typeChecker.getDeclaredTypeOfSymbol(symbol), enclosingDeclaration)); - } - if (symbolFlags & 384) { - addNewLineIfDisplayPartsExist(); - if (ts.forEach(symbol.declarations, ts.isConstEnumDeclaration)) { - displayParts.push(ts.keywordPart(74)); - displayParts.push(ts.spacePart()); - } - displayParts.push(ts.keywordPart(81)); - displayParts.push(ts.spacePart()); - addFullSymbolName(symbol); - } - if (symbolFlags & 1536) { - addNewLineIfDisplayPartsExist(); - var declaration = ts.getDeclarationOfKind(symbol, 218); - var isNamespace = declaration && declaration.name && declaration.name.kind === 69; - displayParts.push(ts.keywordPart(isNamespace ? 126 : 125)); - displayParts.push(ts.spacePart()); - addFullSymbolName(symbol); - } - 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.spacePart()); - addFullSymbolName(symbol); - displayParts.push(ts.spacePart()); - displayParts.push(ts.keywordPart(90)); - displayParts.push(ts.spacePart()); - if (symbol.parent) { - addFullSymbolName(symbol.parent, enclosingDeclaration); - writeTypeParametersOfSymbol(symbol.parent, enclosingDeclaration); - } - else { - var container = ts.getContainingFunction(location); - if (container) { - var signatureDeclaration = ts.getDeclarationOfKind(symbol, 137).parent; - var signature = typeChecker.getSignatureFromDeclaration(signatureDeclaration); - if (signatureDeclaration.kind === 148) { - displayParts.push(ts.keywordPart(92)); - displayParts.push(ts.spacePart()); - } - else if (signatureDeclaration.kind !== 147 && signatureDeclaration.name) { - addFullSymbolName(signatureDeclaration.symbol); - } - ts.addRange(displayParts, ts.signatureToDisplayParts(typeChecker, signature, sourceFile, 32)); - } - else { - var declaration = ts.getDeclarationOfKind(symbol, 137).parent; - displayParts.push(ts.keywordPart(132)); - displayParts.push(ts.spacePart()); - addFullSymbolName(declaration.symbol); - writeTypeParametersOfSymbol(declaration.symbol, sourceFile); - } - } - } - if (symbolFlags & 8) { - addPrefixForAnyFunctionOrVar(symbol, "enum member"); - var declaration = symbol.declarations[0]; - if (declaration.kind === 247) { - var constantValue = typeChecker.getConstantValue(declaration); - if (constantValue !== undefined) { - displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(56)); - displayParts.push(ts.spacePart()); - displayParts.push(ts.displayPart(constantValue.toString(), SymbolDisplayPartKind.numericLiteral)); - } - } - } - if (symbolFlags & 8388608) { - addNewLineIfDisplayPartsExist(); - displayParts.push(ts.keywordPart(89)); - displayParts.push(ts.spacePart()); - addFullSymbolName(symbol); - ts.forEach(symbol.declarations, function (declaration) { - if (declaration.kind === 221) { - var importEqualsDeclaration = declaration; - if (ts.isExternalModuleImportEqualsDeclaration(importEqualsDeclaration)) { - displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(56)); - displayParts.push(ts.spacePart()); - displayParts.push(ts.keywordPart(127)); - displayParts.push(ts.punctuationPart(17)); - displayParts.push(ts.displayPart(ts.getTextOfNode(ts.getExternalModuleImportEqualsDeclarationExpression(importEqualsDeclaration)), SymbolDisplayPartKind.stringLiteral)); - displayParts.push(ts.punctuationPart(18)); - } - else { - var internalAliasSymbol = typeChecker.getSymbolAtLocation(importEqualsDeclaration.moduleReference); - if (internalAliasSymbol) { - displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(56)); - displayParts.push(ts.spacePart()); - addFullSymbolName(internalAliasSymbol, enclosingDeclaration); - } - } - return true; - } - }); - } - if (!hasAddedSymbolInfo) { - if (symbolKind !== ScriptElementKind.unknown) { - if (type) { - addPrefixForAnyFunctionOrVar(symbol, symbolKind); - if (symbolKind === ScriptElementKind.memberVariableElement || - symbolFlags & 3 || - symbolKind === ScriptElementKind.localVariableElement) { - displayParts.push(ts.punctuationPart(54)); - displayParts.push(ts.spacePart()); - if (type.symbol && type.symbol.flags & 262144) { - var typeParameterParts = ts.mapToDisplayParts(function (writer) { - typeChecker.getSymbolDisplayBuilder().buildTypeParameterDisplay(type, writer, enclosingDeclaration); - }); - ts.addRange(displayParts, typeParameterParts); - } - else { - ts.addRange(displayParts, ts.typeToDisplayParts(typeChecker, type, enclosingDeclaration)); - } - } - else if (symbolFlags & 16 || - symbolFlags & 8192 || - symbolFlags & 16384 || - symbolFlags & 131072 || - symbolFlags & 98304 || - symbolKind === ScriptElementKind.memberFunctionElement) { - var allSignatures = type.getCallSignatures(); - addSignatureDisplayParts(allSignatures[0], allSignatures); - } - } - } - else { - symbolKind = getSymbolKind(symbol, location); - } - } - if (!documentation) { - documentation = symbol.getDocumentationComment(); - } - return { displayParts: displayParts, documentation: documentation, symbolKind: symbolKind }; - function addNewLineIfDisplayPartsExist() { - if (displayParts.length) { - displayParts.push(ts.lineBreakPart()); - } - } - function addFullSymbolName(symbol, enclosingDeclaration) { - var fullSymbolDisplayParts = ts.symbolToDisplayParts(typeChecker, symbol, enclosingDeclaration || sourceFile, undefined, 1 | 2); - ts.addRange(displayParts, fullSymbolDisplayParts); - } - function addPrefixForAnyFunctionOrVar(symbol, symbolKind) { - addNewLineIfDisplayPartsExist(); - if (symbolKind) { - pushTypePart(symbolKind); - displayParts.push(ts.spacePart()); - addFullSymbolName(symbol); - } - } - function pushTypePart(symbolKind) { - switch (symbolKind) { - case ScriptElementKind.variableElement: - case ScriptElementKind.functionElement: - case ScriptElementKind.letElement: - case ScriptElementKind.constElement: - case ScriptElementKind.constructorImplementationElement: - displayParts.push(ts.textOrKeywordPart(symbolKind)); - return; - default: - displayParts.push(ts.punctuationPart(17)); - displayParts.push(ts.textOrKeywordPart(symbolKind)); - displayParts.push(ts.punctuationPart(18)); - return; - } - } - function addSignatureDisplayParts(signature, allSignatures, flags) { - 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.displayPart((allSignatures.length - 1).toString(), SymbolDisplayPartKind.numericLiteral)); - displayParts.push(ts.spacePart()); - displayParts.push(ts.textPart(allSignatures.length === 2 ? "overload" : "overloads")); - displayParts.push(ts.punctuationPart(18)); - } - documentation = signature.getDocumentationComment(); - } - function writeTypeParametersOfSymbol(symbol, enclosingDeclaration) { - var typeParameterParts = ts.mapToDisplayParts(function (writer) { - typeChecker.getSymbolDisplayBuilder().buildTypeParameterDisplayFromSymbol(symbol, writer, enclosingDeclaration); - }); - ts.addRange(displayParts, typeParameterParts); - } - } - function getQuickInfoAtPosition(fileName, position) { - synchronizeHostData(); - var sourceFile = getValidSourceFile(fileName); - var node = ts.getTouchingPropertyName(sourceFile, position); - if (!node) { - return undefined; - } - if (isLabelName(node)) { - return undefined; - } - var typeChecker = program.getTypeChecker(); - var symbol = typeChecker.getSymbolAtLocation(node); - if (!symbol) { - switch (node.kind) { - case 69: - case 166: - case 135: - case 97: - case 95: - var type = typeChecker.getTypeAtLocation(node); - if (type) { - return { - kind: ScriptElementKind.unknown, - kindModifiers: ScriptElementKindModifier.none, - textSpan: ts.createTextSpan(node.getStart(), node.getWidth()), - displayParts: ts.typeToDisplayParts(typeChecker, type, getContainerNode(node)), - documentation: type.symbol ? type.symbol.getDocumentationComment() : undefined - }; - } - } - return undefined; - } - var displayPartsDocumentationsAndKind = getSymbolDisplayPartsDocumentationAndSymbolKind(symbol, sourceFile, getContainerNode(node), node); - return { - kind: displayPartsDocumentationsAndKind.symbolKind, - kindModifiers: getSymbolModifiers(symbol), - textSpan: ts.createTextSpan(node.getStart(), node.getWidth()), - displayParts: displayPartsDocumentationsAndKind.displayParts, - documentation: displayPartsDocumentationsAndKind.documentation - }; - } - function createDefinitionInfo(node, symbolKind, symbolName, containerName) { - return { - fileName: node.getSourceFile().fileName, - textSpan: ts.createTextSpanFromBounds(node.getStart(), node.getEnd()), - kind: symbolKind, - name: symbolName, - containerKind: undefined, - containerName: containerName - }; - } - function getDefinitionFromSymbol(symbol, node) { - var typeChecker = program.getTypeChecker(); - var result = []; - var declarations = symbol.getDeclarations(); - var symbolName = typeChecker.symbolToString(symbol); - var symbolKind = getSymbolKind(symbol, node); - var containerSymbol = symbol.parent; - var containerName = containerSymbol ? typeChecker.symbolToString(containerSymbol, node) : ""; - if (!tryAddConstructSignature(symbol, node, symbolKind, symbolName, containerName, result) && - !tryAddCallSignature(symbol, node, symbolKind, symbolName, containerName, result)) { - ts.forEach(declarations, function (declaration) { - result.push(createDefinitionInfo(declaration, symbolKind, symbolName, containerName)); - }); - } - return result; - function tryAddConstructSignature(symbol, location, symbolKind, symbolName, containerName, result) { - if (isNewExpressionTarget(location) || location.kind === 121) { - if (symbol.flags & 32) { - for (var _i = 0, _a = symbol.getDeclarations(); _i < _a.length; _i++) { - var declaration = _a[_i]; - if (ts.isClassLike(declaration)) { - return tryAddSignature(declaration.members, true, symbolKind, symbolName, containerName, result); - } - } - ts.Debug.fail("Expected declaration to have at least one class-like declaration"); - } - } - return false; - } - function tryAddCallSignature(symbol, location, symbolKind, symbolName, containerName, result) { - if (isCallExpressionTarget(location) || isNewExpressionTarget(location) || isNameOfFunctionDeclaration(location)) { - return tryAddSignature(symbol.declarations, false, symbolKind, symbolName, containerName, result); - } - return false; - } - function tryAddSignature(signatureDeclarations, selectConstructors, symbolKind, symbolName, containerName, result) { - var declarations = []; - var definition; - ts.forEach(signatureDeclarations, function (d) { - if ((selectConstructors && d.kind === 144) || - (!selectConstructors && (d.kind === 213 || d.kind === 143 || d.kind === 142))) { - declarations.push(d); - if (d.body) - definition = d; - } - }); - if (definition) { - result.push(createDefinitionInfo(definition, symbolKind, symbolName, containerName)); - return true; - } - else if (declarations.length) { - result.push(createDefinitionInfo(ts.lastOrUndefined(declarations), symbolKind, symbolName, containerName)); - return true; - } - return false; - } - } - function getDefinitionAtPosition(fileName, position) { - synchronizeHostData(); - var sourceFile = getValidSourceFile(fileName); - var node = ts.getTouchingPropertyName(sourceFile, position); - if (!node) { - return undefined; - } - if (isJumpStatementTarget(node)) { - var labelName = node.text; - var label = getTargetLabel(node.parent, node.text); - return label ? [createDefinitionInfo(label, ScriptElementKind.label, labelName, undefined)] : undefined; - } - var comment = ts.forEach(sourceFile.referencedFiles, function (r) { return (r.pos <= position && position < r.end) ? r : undefined; }); - if (comment) { - var referenceFile = ts.tryResolveScriptReference(program, sourceFile, comment); - if (referenceFile) { - return [{ - fileName: referenceFile.fileName, - textSpan: ts.createTextSpanFromBounds(0, 0), - kind: ScriptElementKind.scriptElement, - name: comment.fileName, - containerName: undefined, - containerKind: undefined - }]; - } - return undefined; - } - var typeChecker = program.getTypeChecker(); - var symbol = typeChecker.getSymbolAtLocation(node); - if (!symbol) { - return undefined; - } - if (symbol.flags & 8388608) { - var declaration = symbol.declarations[0]; - if (node.kind === 69 && node.parent === declaration) { - symbol = typeChecker.getAliasedSymbol(symbol); - } - } - if (node.parent.kind === 246) { - var shorthandSymbol = typeChecker.getShorthandAssignmentValueSymbol(symbol.valueDeclaration); - if (!shorthandSymbol) { - return []; - } - var shorthandDeclarations = shorthandSymbol.getDeclarations(); - var shorthandSymbolKind = getSymbolKind(shorthandSymbol, node); - var shorthandSymbolName = typeChecker.symbolToString(shorthandSymbol); - var shorthandContainerName = typeChecker.symbolToString(symbol.parent, node); - return ts.map(shorthandDeclarations, function (declaration) { return createDefinitionInfo(declaration, shorthandSymbolKind, shorthandSymbolName, shorthandContainerName); }); - } - return getDefinitionFromSymbol(symbol, node); - } - function getTypeDefinitionAtPosition(fileName, position) { - synchronizeHostData(); - var sourceFile = getValidSourceFile(fileName); - var node = ts.getTouchingPropertyName(sourceFile, position); - if (!node) { - return undefined; - } - var typeChecker = program.getTypeChecker(); - var symbol = typeChecker.getSymbolAtLocation(node); - if (!symbol) { - return undefined; - } - var type = typeChecker.getTypeOfSymbolAtLocation(symbol, node); - if (!type) { - return undefined; - } - if (type.flags & 16384) { - var result = []; - ts.forEach(type.types, function (t) { - if (t.symbol) { - ts.addRange(result, getDefinitionFromSymbol(t.symbol, node)); - } - }); - return result; - } - if (!type.symbol) { - return undefined; - } - return getDefinitionFromSymbol(type.symbol, node); - } - function getOccurrencesAtPosition(fileName, position) { - var results = getOccurrencesAtPositionCore(fileName, position); - if (results) { - var sourceFile = getCanonicalFileName(ts.normalizeSlashes(fileName)); - results = ts.filter(results, function (r) { return getCanonicalFileName(ts.normalizeSlashes(r.fileName)) === sourceFile; }); - } - return results; - } - function getDocumentHighlights(fileName, position, filesToSearch) { - synchronizeHostData(); - filesToSearch = ts.map(filesToSearch, ts.normalizeSlashes); - var sourceFilesToSearch = ts.filter(program.getSourceFiles(), function (f) { return ts.contains(filesToSearch, f.fileName); }); - var sourceFile = getValidSourceFile(fileName); - var node = ts.getTouchingWord(sourceFile, position); - if (!node) { - return undefined; - } - return getSemanticDocumentHighlights(node) || getSyntacticDocumentHighlights(node); - function getHighlightSpanForNode(node) { - var start = node.getStart(); - var end = node.getEnd(); - return { - fileName: sourceFile.fileName, - textSpan: ts.createTextSpanFromBounds(start, end), - kind: HighlightSpanKind.none - }; - } - function getSemanticDocumentHighlights(node) { - if (node.kind === 69 || - node.kind === 97 || - node.kind === 95 || - isLiteralNameOfPropertyDeclarationOrIndexAccess(node) || - isNameOfExternalModuleImportOrDeclaration(node)) { - var referencedSymbols = getReferencedSymbolsForNode(node, sourceFilesToSearch, false, false); - return convertReferencedSymbols(referencedSymbols); - } - return undefined; - function convertReferencedSymbols(referencedSymbols) { - if (!referencedSymbols) { - return undefined; - } - var fileNameToDocumentHighlights = {}; - var result = []; - for (var _i = 0; _i < referencedSymbols.length; _i++) { - var referencedSymbol = referencedSymbols[_i]; - for (var _a = 0, _b = referencedSymbol.references; _a < _b.length; _a++) { - var referenceEntry = _b[_a]; - var fileName_1 = referenceEntry.fileName; - var documentHighlights = ts.getProperty(fileNameToDocumentHighlights, fileName_1); - if (!documentHighlights) { - documentHighlights = { fileName: fileName_1, highlightSpans: [] }; - fileNameToDocumentHighlights[fileName_1] = documentHighlights; - result.push(documentHighlights); - } - documentHighlights.highlightSpans.push({ - textSpan: referenceEntry.textSpan, - kind: referenceEntry.isWriteAccess ? HighlightSpanKind.writtenReference : HighlightSpanKind.reference - }); - } - } - return result; - } - } - function getSyntacticDocumentHighlights(node) { - var fileName = sourceFile.fileName; - var highlightSpans = getHighlightSpans(node); - if (!highlightSpans || highlightSpans.length === 0) { - return undefined; - } - return [{ fileName: fileName, highlightSpans: highlightSpans }]; - function hasKind(node, kind) { - return node !== undefined && node.kind === kind; - } - function parent(node) { - return node && node.parent; - } - function getHighlightSpans(node) { - if (node) { - switch (node.kind) { - case 88: - case 80: - if (hasKind(node.parent, 196)) { - return getIfElseOccurrences(node.parent); - } - break; - case 94: - if (hasKind(node.parent, 204)) { - return getReturnOccurrences(node.parent); - } - break; - case 98: - if (hasKind(node.parent, 208)) { - return getThrowOccurrences(node.parent); - } - break; - case 72: - if (hasKind(parent(parent(node)), 209)) { - return getTryCatchFinallyOccurrences(node.parent.parent); - } - break; - case 100: - case 85: - if (hasKind(parent(node), 209)) { - return getTryCatchFinallyOccurrences(node.parent); - } - break; - case 96: - if (hasKind(node.parent, 206)) { - return getSwitchCaseDefaultOccurrences(node.parent); - } - break; - case 71: - case 77: - if (hasKind(parent(parent(parent(node))), 206)) { - return getSwitchCaseDefaultOccurrences(node.parent.parent.parent); - } - break; - case 70: - case 75: - if (hasKind(node.parent, 203) || hasKind(node.parent, 202)) { - return getBreakOrContinueStatementOccurrences(node.parent); - } - break; - case 86: - if (hasKind(node.parent, 199) || - hasKind(node.parent, 200) || - hasKind(node.parent, 201)) { - return getLoopBreakContinueOccurrences(node.parent); - } - break; - case 104: - case 79: - if (hasKind(node.parent, 198) || hasKind(node.parent, 197)) { - return getLoopBreakContinueOccurrences(node.parent); - } - break; - case 121: - if (hasKind(node.parent, 144)) { - return getConstructorOccurrences(node.parent); - } - break; - case 123: - case 129: - if (hasKind(node.parent, 145) || hasKind(node.parent, 146)) { - return getGetAndSetOccurrences(node.parent); - } - break; - default: - if (ts.isModifier(node.kind) && node.parent && - (ts.isDeclaration(node.parent) || node.parent.kind === 193)) { - return getModifierOccurrences(node.kind, node.parent); - } - } - } - return undefined; - } - function aggregateOwnedThrowStatements(node) { - var statementAccumulator = []; - aggregate(node); - return statementAccumulator; - function aggregate(node) { - if (node.kind === 208) { - statementAccumulator.push(node); - } - else if (node.kind === 209) { - var tryStatement = node; - if (tryStatement.catchClause) { - aggregate(tryStatement.catchClause); - } - else { - aggregate(tryStatement.tryBlock); - } - if (tryStatement.finallyBlock) { - aggregate(tryStatement.finallyBlock); - } - } - else if (!ts.isFunctionLike(node)) { - ts.forEachChild(node, aggregate); - } - } - ; - } - function getThrowStatementOwner(throwStatement) { - var child = throwStatement; - while (child.parent) { - var parent_12 = child.parent; - if (ts.isFunctionBlock(parent_12) || parent_12.kind === 248) { - return parent_12; - } - if (parent_12.kind === 209) { - var tryStatement = parent_12; - if (tryStatement.tryBlock === child && tryStatement.catchClause) { - return child; - } - } - child = parent_12; - } - return undefined; - } - function aggregateAllBreakAndContinueStatements(node) { - var statementAccumulator = []; - aggregate(node); - return statementAccumulator; - function aggregate(node) { - if (node.kind === 203 || node.kind === 202) { - statementAccumulator.push(node); - } - else if (!ts.isFunctionLike(node)) { - ts.forEachChild(node, aggregate); - } - } - ; - } - function ownsBreakOrContinueStatement(owner, statement) { - var actualOwner = getBreakOrContinueOwner(statement); - return actualOwner && actualOwner === owner; - } - function getBreakOrContinueOwner(statement) { - for (var node_2 = statement.parent; node_2; node_2 = node_2.parent) { - switch (node_2.kind) { - case 206: - if (statement.kind === 202) { - continue; - } - case 199: - case 200: - case 201: - case 198: - case 197: - if (!statement.label || isLabeledBy(node_2, statement.label.text)) { - return node_2; - } - break; - default: - if (ts.isFunctionLike(node_2)) { - return undefined; - } - break; - } - } - return undefined; - } - function getModifierOccurrences(modifier, declaration) { - var container = declaration.parent; - if (ts.isAccessibilityModifier(modifier)) { - if (!(container.kind === 214 || - container.kind === 186 || - (declaration.kind === 138 && hasKind(container, 144)))) { - return undefined; - } - } - else if (modifier === 113) { - if (!(container.kind === 214 || container.kind === 186)) { - return undefined; - } - } - else if (modifier === 82 || modifier === 122) { - if (!(container.kind === 219 || container.kind === 248)) { - return undefined; - } - } - else if (modifier === 115) { - if (!(container.kind === 214 || declaration.kind === 214)) { - return undefined; - } - } - else { - return undefined; - } - var keywords = []; - var modifierFlag = getFlagFromModifier(modifier); - var nodes; - switch (container.kind) { - case 219: - case 248: - if (modifierFlag & 256) { - nodes = declaration.members.concat(declaration); - } - else { - nodes = container.statements; - } - break; - case 144: - nodes = container.parameters.concat(container.parent.members); - break; - case 214: - case 186: - nodes = container.members; - if (modifierFlag & 112) { - var constructor = ts.forEach(container.members, function (member) { - return member.kind === 144 && member; - }); - if (constructor) { - nodes = nodes.concat(constructor.parameters); - } - } - else if (modifierFlag & 256) { - nodes = nodes.concat(container); - } - break; - default: - ts.Debug.fail("Invalid container kind."); - } - ts.forEach(nodes, function (node) { - if (node.modifiers && node.flags & modifierFlag) { - ts.forEach(node.modifiers, function (child) { return pushKeywordIf(keywords, child, modifier); }); - } - }); - return ts.map(keywords, getHighlightSpanForNode); - function getFlagFromModifier(modifier) { - switch (modifier) { - case 112: - return 16; - case 110: - return 32; - case 111: - return 64; - case 113: - return 128; - case 82: - return 1; - case 122: - return 2; - case 115: - return 256; - default: - ts.Debug.fail(); - } - } - } - function pushKeywordIf(keywordList, token) { - var expected = []; - for (var _i = 2; _i < arguments.length; _i++) { - expected[_i - 2] = arguments[_i]; - } - if (token && ts.contains(expected, token.kind)) { - keywordList.push(token); - return true; - } - return false; - } - function getGetAndSetOccurrences(accessorDeclaration) { - var keywords = []; - tryPushAccessorKeyword(accessorDeclaration.symbol, 145); - tryPushAccessorKeyword(accessorDeclaration.symbol, 146); - return ts.map(keywords, getHighlightSpanForNode); - function tryPushAccessorKeyword(accessorSymbol, accessorKind) { - var accessor = ts.getDeclarationOfKind(accessorSymbol, accessorKind); - if (accessor) { - ts.forEach(accessor.getChildren(), function (child) { return pushKeywordIf(keywords, child, 123, 129); }); - } - } - } - function getConstructorOccurrences(constructorDeclaration) { - var declarations = constructorDeclaration.symbol.getDeclarations(); - var keywords = []; - ts.forEach(declarations, function (declaration) { - ts.forEach(declaration.getChildren(), function (token) { - return pushKeywordIf(keywords, token, 121); - }); - }); - return ts.map(keywords, getHighlightSpanForNode); - } - function getLoopBreakContinueOccurrences(loopNode) { - var keywords = []; - if (pushKeywordIf(keywords, loopNode.getFirstToken(), 86, 104, 79)) { - if (loopNode.kind === 197) { - var loopTokens = loopNode.getChildren(); - for (var i = loopTokens.length - 1; i >= 0; i--) { - if (pushKeywordIf(keywords, loopTokens[i], 104)) { - break; - } - } - } - } - var breaksAndContinues = aggregateAllBreakAndContinueStatements(loopNode.statement); - ts.forEach(breaksAndContinues, function (statement) { - if (ownsBreakOrContinueStatement(loopNode, statement)) { - pushKeywordIf(keywords, statement.getFirstToken(), 70, 75); - } - }); - return ts.map(keywords, getHighlightSpanForNode); - } - function getBreakOrContinueStatementOccurrences(breakOrContinueStatement) { - var owner = getBreakOrContinueOwner(breakOrContinueStatement); - if (owner) { - switch (owner.kind) { - case 199: - case 200: - case 201: - case 197: - case 198: - return getLoopBreakContinueOccurrences(owner); - case 206: - return getSwitchCaseDefaultOccurrences(owner); - } - } - return undefined; - } - function getSwitchCaseDefaultOccurrences(switchStatement) { - var keywords = []; - pushKeywordIf(keywords, switchStatement.getFirstToken(), 96); - ts.forEach(switchStatement.caseBlock.clauses, function (clause) { - pushKeywordIf(keywords, clause.getFirstToken(), 71, 77); - var breaksAndContinues = aggregateAllBreakAndContinueStatements(clause); - ts.forEach(breaksAndContinues, function (statement) { - if (ownsBreakOrContinueStatement(switchStatement, statement)) { - pushKeywordIf(keywords, statement.getFirstToken(), 70); - } - }); - }); - return ts.map(keywords, getHighlightSpanForNode); - } - function getTryCatchFinallyOccurrences(tryStatement) { - var keywords = []; - pushKeywordIf(keywords, tryStatement.getFirstToken(), 100); - if (tryStatement.catchClause) { - pushKeywordIf(keywords, tryStatement.catchClause.getFirstToken(), 72); - } - if (tryStatement.finallyBlock) { - var finallyKeyword = ts.findChildOfKind(tryStatement, 85, sourceFile); - pushKeywordIf(keywords, finallyKeyword, 85); - } - return ts.map(keywords, getHighlightSpanForNode); - } - function getThrowOccurrences(throwStatement) { - var owner = getThrowStatementOwner(throwStatement); - if (!owner) { - return undefined; - } - var keywords = []; - ts.forEach(aggregateOwnedThrowStatements(owner), function (throwStatement) { - pushKeywordIf(keywords, throwStatement.getFirstToken(), 98); - }); - if (ts.isFunctionBlock(owner)) { - ts.forEachReturnStatement(owner, function (returnStatement) { - pushKeywordIf(keywords, returnStatement.getFirstToken(), 94); - }); - } - return ts.map(keywords, getHighlightSpanForNode); - } - function getReturnOccurrences(returnStatement) { - var func = ts.getContainingFunction(returnStatement); - if (!(func && hasKind(func.body, 192))) { - return undefined; - } - var keywords = []; - ts.forEachReturnStatement(func.body, function (returnStatement) { - pushKeywordIf(keywords, returnStatement.getFirstToken(), 94); - }); - ts.forEach(aggregateOwnedThrowStatements(func.body), function (throwStatement) { - pushKeywordIf(keywords, throwStatement.getFirstToken(), 98); - }); - return ts.map(keywords, getHighlightSpanForNode); - } - function getIfElseOccurrences(ifStatement) { - var keywords = []; - while (hasKind(ifStatement.parent, 196) && ifStatement.parent.elseStatement === ifStatement) { - ifStatement = ifStatement.parent; - } - while (ifStatement) { - var children = ifStatement.getChildren(); - pushKeywordIf(keywords, children[0], 88); - for (var i = children.length - 1; i >= 0; i--) { - if (pushKeywordIf(keywords, children[i], 80)) { - break; - } - } - if (!hasKind(ifStatement.elseStatement, 196)) { - break; - } - ifStatement = ifStatement.elseStatement; - } - var result = []; - for (var i = 0; i < keywords.length; i++) { - if (keywords[i].kind === 80 && i < keywords.length - 1) { - var elseKeyword = keywords[i]; - var ifKeyword = keywords[i + 1]; - var shouldCombindElseAndIf = true; - for (var j = ifKeyword.getStart() - 1; j >= elseKeyword.end; j--) { - if (!ts.isWhiteSpace(sourceFile.text.charCodeAt(j))) { - shouldCombindElseAndIf = false; - break; - } - } - if (shouldCombindElseAndIf) { - result.push({ - fileName: fileName, - textSpan: ts.createTextSpanFromBounds(elseKeyword.getStart(), ifKeyword.end), - kind: HighlightSpanKind.reference - }); - i++; - continue; - } - } - result.push(getHighlightSpanForNode(keywords[i])); - } - return result; - } - } - } - function getOccurrencesAtPositionCore(fileName, position) { - synchronizeHostData(); - return convertDocumentHighlights(getDocumentHighlights(fileName, position, [fileName])); - function convertDocumentHighlights(documentHighlights) { - if (!documentHighlights) { - return undefined; - } - var result = []; - for (var _i = 0; _i < documentHighlights.length; _i++) { - var entry = documentHighlights[_i]; - for (var _a = 0, _b = entry.highlightSpans; _a < _b.length; _a++) { - var highlightSpan = _b[_a]; - result.push({ - fileName: entry.fileName, - textSpan: highlightSpan.textSpan, - isWriteAccess: highlightSpan.kind === HighlightSpanKind.writtenReference - }); - } - } - return result; - } - } - function convertReferences(referenceSymbols) { - if (!referenceSymbols) { - return undefined; - } - var referenceEntries = []; - for (var _i = 0; _i < referenceSymbols.length; _i++) { - var referenceSymbol = referenceSymbols[_i]; - ts.addRange(referenceEntries, referenceSymbol.references); - } - return referenceEntries; - } - function findRenameLocations(fileName, position, findInStrings, findInComments) { - var referencedSymbols = findReferencedSymbols(fileName, position, findInStrings, findInComments); - return convertReferences(referencedSymbols); - } - function getReferencesAtPosition(fileName, position) { - var referencedSymbols = findReferencedSymbols(fileName, position, false, false); - return convertReferences(referencedSymbols); - } - function findReferences(fileName, position) { - var referencedSymbols = findReferencedSymbols(fileName, position, false, false); - return ts.filter(referencedSymbols, function (rs) { return !!rs.definition; }); - } - function findReferencedSymbols(fileName, position, findInStrings, findInComments) { - synchronizeHostData(); - var sourceFile = getValidSourceFile(fileName); - var node = ts.getTouchingPropertyName(sourceFile, position); - if (!node) { - return undefined; - } - if (node.kind !== 69 && - !isLiteralNameOfPropertyDeclarationOrIndexAccess(node) && - !isNameOfExternalModuleImportOrDeclaration(node)) { - return undefined; - } - ts.Debug.assert(node.kind === 69 || node.kind === 8 || node.kind === 9); - return getReferencedSymbolsForNode(node, program.getSourceFiles(), findInStrings, findInComments); - } - function getReferencedSymbolsForNode(node, sourceFiles, findInStrings, findInComments) { - var typeChecker = program.getTypeChecker(); - if (isLabelName(node)) { - if (isJumpStatementTarget(node)) { - var labelDefinition = getTargetLabel(node.parent, node.text); - return labelDefinition ? getLabelReferencesInNode(labelDefinition.parent, labelDefinition) : undefined; - } - else { - return getLabelReferencesInNode(node.parent, node); - } - } - if (node.kind === 97) { - return getReferencesForThisKeyword(node, sourceFiles); - } - if (node.kind === 95) { - return getReferencesForSuperKeyword(node); - } - var symbol = typeChecker.getSymbolAtLocation(node); - if (!symbol) { - return undefined; - } - var declarations = symbol.declarations; - if (!declarations || !declarations.length) { - return undefined; - } - var result; - var searchMeaning = getIntersectingMeaningFromDeclarations(getMeaningFromLocation(node), declarations); - var declaredName = ts.stripQuotes(ts.getDeclaredName(typeChecker, symbol, node)); - var scope = getSymbolScope(symbol); - var symbolToIndex = []; - if (scope) { - result = []; - getReferencesInNode(scope, symbol, declaredName, node, searchMeaning, findInStrings, findInComments, result, symbolToIndex); - } - else { - var internedName = getInternedName(symbol, node, declarations); - for (var _i = 0; _i < sourceFiles.length; _i++) { - var sourceFile = sourceFiles[_i]; - cancellationToken.throwIfCancellationRequested(); - var nameTable = getNameTable(sourceFile); - if (ts.lookUp(nameTable, internedName)) { - result = result || []; - getReferencesInNode(sourceFile, symbol, declaredName, node, searchMeaning, findInStrings, findInComments, result, symbolToIndex); - } - } - } - return result; - function getDefinition(symbol) { - var info = getSymbolDisplayPartsDocumentationAndSymbolKind(symbol, node.getSourceFile(), getContainerNode(node), node); - var name = ts.map(info.displayParts, function (p) { return p.text; }).join(""); - var declarations = symbol.declarations; - if (!declarations || declarations.length === 0) { - return undefined; - } - return { - containerKind: "", - containerName: "", - name: name, - kind: info.symbolKind, - fileName: declarations[0].getSourceFile().fileName, - textSpan: ts.createTextSpan(declarations[0].getStart(), 0) - }; - } - function isImportOrExportSpecifierImportSymbol(symbol) { - return (symbol.flags & 8388608) && ts.forEach(symbol.declarations, function (declaration) { - return declaration.kind === 226 || declaration.kind === 230; - }); - } - function getInternedName(symbol, location, declarations) { - if (ts.isImportOrExportSpecifierName(location)) { - return location.getText(); - } - var localExportDefaultSymbol = ts.getLocalSymbolForExportDefault(symbol); - symbol = localExportDefaultSymbol || symbol; - return ts.stripQuotes(symbol.name); - } - function getSymbolScope(symbol) { - var valueDeclaration = symbol.valueDeclaration; - if (valueDeclaration && (valueDeclaration.kind === 173 || valueDeclaration.kind === 186)) { - return valueDeclaration; - } - if (symbol.flags & (4 | 8192)) { - var privateDeclaration = ts.forEach(symbol.getDeclarations(), function (d) { return (d.flags & 32) ? d : undefined; }); - if (privateDeclaration) { - return ts.getAncestor(privateDeclaration, 214); - } - } - if (symbol.flags & 8388608) { - return undefined; - } - if (symbol.parent || (symbol.flags & 268435456)) { - return undefined; - } - var scope = undefined; - var declarations = symbol.getDeclarations(); - if (declarations) { - for (var _i = 0; _i < declarations.length; _i++) { - var declaration = declarations[_i]; - var container = getContainerNode(declaration); - if (!container) { - return undefined; - } - if (scope && scope !== container) { - return undefined; - } - if (container.kind === 248 && !ts.isExternalModule(container)) { - return undefined; - } - scope = container; - } - } - return scope; - } - function getPossibleSymbolReferencePositions(sourceFile, symbolName, start, end) { - var positions = []; - if (!symbolName || !symbolName.length) { - return positions; - } - var text = sourceFile.text; - var sourceLength = text.length; - var symbolNameLength = symbolName.length; - var position = text.indexOf(symbolName, start); - while (position >= 0) { - cancellationToken.throwIfCancellationRequested(); - 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))) { - positions.push(position); - } - position = text.indexOf(symbolName, position + symbolNameLength + 1); - } - return positions; - } - function getLabelReferencesInNode(container, targetLabel) { - var references = []; - var sourceFile = container.getSourceFile(); - var labelName = targetLabel.text; - var possiblePositions = getPossibleSymbolReferencePositions(sourceFile, labelName, container.getStart(), container.getEnd()); - ts.forEach(possiblePositions, function (position) { - cancellationToken.throwIfCancellationRequested(); - var node = ts.getTouchingWord(sourceFile, position); - if (!node || node.getWidth() !== labelName.length) { - return; - } - if (node === targetLabel || - (isJumpStatementTarget(node) && getTargetLabel(node, labelName) === targetLabel)) { - references.push(getReferenceEntryFromNode(node)); - } - }); - var definition = { - containerKind: "", - containerName: "", - fileName: targetLabel.getSourceFile().fileName, - kind: ScriptElementKind.label, - name: labelName, - textSpan: ts.createTextSpanFromBounds(targetLabel.getStart(), targetLabel.getEnd()) - }; - return [{ definition: definition, references: references }]; - } - function isValidReferencePosition(node, searchSymbolName) { - if (node) { - switch (node.kind) { - case 69: - return node.getWidth() === searchSymbolName.length; - case 9: - if (isLiteralNameOfPropertyDeclarationOrIndexAccess(node) || - isNameOfExternalModuleImportOrDeclaration(node)) { - return node.getWidth() === searchSymbolName.length + 2; - } - break; - case 8: - if (isLiteralNameOfPropertyDeclarationOrIndexAccess(node)) { - return node.getWidth() === searchSymbolName.length; - } - break; - } - } - return false; - } - function getReferencesInNode(container, searchSymbol, searchText, searchLocation, searchMeaning, findInStrings, findInComments, result, symbolToIndex) { - var sourceFile = container.getSourceFile(); - var tripleSlashDirectivePrefixRegex = /^\/\/\/\s*= 0) { - var referencedSymbol = getReferencedSymbol(shorthandValueSymbol); - referencedSymbol.references.push(getReferenceEntryFromNode(referenceSymbolDeclaration.name)); - } - } - }); - } - return; - function getReferencedSymbol(symbol) { - var symbolId = ts.getSymbolId(symbol); - var index = symbolToIndex[symbolId]; - if (index === undefined) { - index = result.length; - symbolToIndex[symbolId] = index; - result.push({ - definition: getDefinition(symbol), - references: [] - }); - } - return result[index]; - } - function isInNonReferenceComment(sourceFile, position) { - return ts.isInCommentHelper(sourceFile, position, isNonReferenceComment); - function isNonReferenceComment(c) { - var commentText = sourceFile.text.substring(c.pos, c.end); - return !tripleSlashDirectivePrefixRegex.test(commentText); - } - } - } - function getReferencesForSuperKeyword(superKeyword) { - var searchSpaceNode = ts.getSuperContainer(superKeyword, false); - if (!searchSpaceNode) { - return undefined; - } - var staticFlag = 128; - switch (searchSpaceNode.kind) { - case 141: - case 140: - case 143: - case 142: - case 144: - case 145: - case 146: - staticFlag &= searchSpaceNode.flags; - searchSpaceNode = searchSpaceNode.parent; - break; - default: - return undefined; - } - var references = []; - var sourceFile = searchSpaceNode.getSourceFile(); - var possiblePositions = getPossibleSymbolReferencePositions(sourceFile, "super", searchSpaceNode.getStart(), searchSpaceNode.getEnd()); - ts.forEach(possiblePositions, function (position) { - cancellationToken.throwIfCancellationRequested(); - var node = ts.getTouchingWord(sourceFile, position); - if (!node || node.kind !== 95) { - return; - } - var container = ts.getSuperContainer(node, false); - if (container && (128 & container.flags) === staticFlag && container.parent.symbol === searchSpaceNode.symbol) { - references.push(getReferenceEntryFromNode(node)); - } - }); - var definition = getDefinition(searchSpaceNode.symbol); - return [{ definition: definition, references: references }]; - } - function getReferencesForThisKeyword(thisOrSuperKeyword, sourceFiles) { - var searchSpaceNode = ts.getThisContainer(thisOrSuperKeyword, false); - var staticFlag = 128; - switch (searchSpaceNode.kind) { - case 143: - case 142: - if (ts.isObjectLiteralMethod(searchSpaceNode)) { - break; - } - case 141: - case 140: - case 144: - case 145: - case 146: - staticFlag &= searchSpaceNode.flags; - searchSpaceNode = searchSpaceNode.parent; - break; - case 248: - if (ts.isExternalModule(searchSpaceNode)) { - return undefined; - } - case 213: - case 173: - break; - default: - return undefined; - } - var references = []; - var possiblePositions; - if (searchSpaceNode.kind === 248) { - ts.forEach(sourceFiles, function (sourceFile) { - possiblePositions = getPossibleSymbolReferencePositions(sourceFile, "this", sourceFile.getStart(), sourceFile.getEnd()); - getThisReferencesInFile(sourceFile, sourceFile, possiblePositions, references); - }); - } - else { - var sourceFile = searchSpaceNode.getSourceFile(); - possiblePositions = getPossibleSymbolReferencePositions(sourceFile, "this", searchSpaceNode.getStart(), searchSpaceNode.getEnd()); - getThisReferencesInFile(sourceFile, searchSpaceNode, possiblePositions, references); - } - return [{ - definition: { - containerKind: "", - containerName: "", - fileName: node.getSourceFile().fileName, - kind: ScriptElementKind.variableElement, - name: "this", - textSpan: ts.createTextSpanFromBounds(node.getStart(), node.getEnd()) - }, - references: references - }]; - function getThisReferencesInFile(sourceFile, searchSpaceNode, possiblePositions, result) { - ts.forEach(possiblePositions, function (position) { - cancellationToken.throwIfCancellationRequested(); - var node = ts.getTouchingWord(sourceFile, position); - if (!node || node.kind !== 97) { - return; - } - var container = ts.getThisContainer(node, false); - switch (searchSpaceNode.kind) { - case 173: - case 213: - if (searchSpaceNode.symbol === container.symbol) { - result.push(getReferenceEntryFromNode(node)); - } - break; - case 143: - case 142: - if (ts.isObjectLiteralMethod(searchSpaceNode) && searchSpaceNode.symbol === container.symbol) { - result.push(getReferenceEntryFromNode(node)); - } - break; - case 186: - case 214: - if (container.parent && searchSpaceNode.symbol === container.parent.symbol && (container.flags & 128) === staticFlag) { - result.push(getReferenceEntryFromNode(node)); - } - break; - case 248: - if (container.kind === 248 && !ts.isExternalModule(container)) { - result.push(getReferenceEntryFromNode(node)); - } - break; - } - }); - } - } - function populateSearchSymbolSet(symbol, location) { - var result = [symbol]; - if (isImportOrExportSpecifierImportSymbol(symbol)) { - result.push(typeChecker.getAliasedSymbol(symbol)); - } - if (isNameOfPropertyAssignment(location)) { - ts.forEach(getPropertySymbolsFromContextualType(location), function (contextualSymbol) { - ts.addRange(result, typeChecker.getRootSymbols(contextualSymbol)); - }); - var shorthandValueSymbol = typeChecker.getShorthandAssignmentValueSymbol(location.parent); - if (shorthandValueSymbol) { - result.push(shorthandValueSymbol); - } - } - ts.forEach(typeChecker.getRootSymbols(symbol), function (rootSymbol) { - if (rootSymbol !== symbol) { - result.push(rootSymbol); - } - if (rootSymbol.parent && rootSymbol.parent.flags & (32 | 64)) { - getPropertySymbolsFromBaseTypes(rootSymbol.parent, rootSymbol.getName(), result); - } - }); - return result; - } - function getPropertySymbolsFromBaseTypes(symbol, propertyName, result) { - if (symbol && symbol.flags & (32 | 64)) { - ts.forEach(symbol.getDeclarations(), function (declaration) { - if (declaration.kind === 214) { - getPropertySymbolFromTypeReference(ts.getClassExtendsHeritageClauseElement(declaration)); - ts.forEach(ts.getClassImplementsHeritageClauseElements(declaration), getPropertySymbolFromTypeReference); - } - else if (declaration.kind === 215) { - ts.forEach(ts.getInterfaceBaseTypeNodes(declaration), getPropertySymbolFromTypeReference); - } - }); - } - return; - function getPropertySymbolFromTypeReference(typeReference) { - if (typeReference) { - var type = typeChecker.getTypeAtLocation(typeReference); - if (type) { - var propertySymbol = typeChecker.getPropertyOfType(type, propertyName); - if (propertySymbol) { - result.push(propertySymbol); - } - getPropertySymbolsFromBaseTypes(type.symbol, propertyName, result); - } - } - } - } - function getRelatedSymbol(searchSymbols, referenceSymbol, referenceLocation) { - if (searchSymbols.indexOf(referenceSymbol) >= 0) { - return referenceSymbol; - } - if (isImportOrExportSpecifierImportSymbol(referenceSymbol)) { - var aliasedSymbol = typeChecker.getAliasedSymbol(referenceSymbol); - if (searchSymbols.indexOf(aliasedSymbol) >= 0) { - return aliasedSymbol; - } - } - if (isNameOfPropertyAssignment(referenceLocation)) { - return ts.forEach(getPropertySymbolsFromContextualType(referenceLocation), function (contextualSymbol) { - return ts.forEach(typeChecker.getRootSymbols(contextualSymbol), function (s) { return searchSymbols.indexOf(s) >= 0 ? s : undefined; }); - }); - } - return ts.forEach(typeChecker.getRootSymbols(referenceSymbol), function (rootSymbol) { - if (searchSymbols.indexOf(rootSymbol) >= 0) { - return rootSymbol; - } - if (rootSymbol.parent && rootSymbol.parent.flags & (32 | 64)) { - var result_3 = []; - getPropertySymbolsFromBaseTypes(rootSymbol.parent, rootSymbol.getName(), result_3); - return ts.forEach(result_3, function (s) { return searchSymbols.indexOf(s) >= 0 ? s : undefined; }); - } - return undefined; - }); - } - function getPropertySymbolsFromContextualType(node) { - if (isNameOfPropertyAssignment(node)) { - var objectLiteral = node.parent.parent; - var contextualType = typeChecker.getContextualType(objectLiteral); - var name_34 = node.text; - if (contextualType) { - if (contextualType.flags & 16384) { - var unionProperty = contextualType.getProperty(name_34); - if (unionProperty) { - return [unionProperty]; - } - else { - var result_4 = []; - ts.forEach(contextualType.types, function (t) { - var symbol = t.getProperty(name_34); - if (symbol) { - result_4.push(symbol); - } - }); - return result_4; - } - } - else { - var symbol_1 = contextualType.getProperty(name_34); - if (symbol_1) { - return [symbol_1]; - } - } - } - } - return undefined; - } - function getIntersectingMeaningFromDeclarations(meaning, declarations) { - if (declarations) { - var lastIterationMeaning; - do { - lastIterationMeaning = meaning; - for (var _i = 0; _i < declarations.length; _i++) { - var declaration = declarations[_i]; - var declarationMeaning = getMeaningFromDeclaration(declaration); - if (declarationMeaning & meaning) { - meaning |= declarationMeaning; - } - } - } while (meaning !== lastIterationMeaning); - } - return meaning; - } - } - function getReferenceEntryFromNode(node) { - var start = node.getStart(); - var end = node.getEnd(); - if (node.kind === 9) { - start += 1; - end -= 1; - } - return { - fileName: node.getSourceFile().fileName, - textSpan: ts.createTextSpanFromBounds(start, end), - isWriteAccess: isWriteAccess(node) - }; - } - function isWriteAccess(node) { - if (node.kind === 69 && ts.isDeclarationName(node)) { - return true; - } - var parent = node.parent; - if (parent) { - if (parent.kind === 180 || parent.kind === 179) { - return true; - } - else if (parent.kind === 181 && parent.left === node) { - var operator = parent.operatorToken.kind; - return 56 <= operator && operator <= 68; - } - } - return false; - } - function getNavigateToItems(searchValue, maxResultCount) { - synchronizeHostData(); - return ts.NavigateTo.getNavigateToItems(program, cancellationToken, searchValue, maxResultCount); - } - function containErrors(diagnostics) { - return ts.forEach(diagnostics, function (diagnostic) { return diagnostic.category === ts.DiagnosticCategory.Error; }); - } - function getEmitOutput(fileName) { - synchronizeHostData(); - var sourceFile = getValidSourceFile(fileName); - var outputFiles = []; - function writeFile(fileName, data, writeByteOrderMark) { - outputFiles.push({ - name: fileName, - writeByteOrderMark: writeByteOrderMark, - text: data - }); - } - var emitOutput = program.emit(sourceFile, writeFile, cancellationToken); - return { - outputFiles: outputFiles, - emitSkipped: emitOutput.emitSkipped - }; - } - function getMeaningFromDeclaration(node) { - switch (node.kind) { - case 138: - case 211: - case 163: - case 141: - case 140: - case 245: - case 246: - case 247: - case 143: - case 142: - case 144: - case 145: - case 146: - case 213: - case 173: - case 174: - case 244: - return 1; - case 137: - case 215: - case 216: - case 155: - return 2; - case 214: - case 217: - return 1 | 2; - case 218: - if (node.name.kind === 9) { - return 4 | 1; - } - else if (ts.getModuleInstanceState(node) === 1) { - return 4 | 1; - } - else { - return 4; - } - case 225: - case 226: - case 221: - case 222: - case 227: - case 228: - return 1 | 2 | 4; - case 248: - return 4 | 1; - } - return 1 | 2 | 4; - ts.Debug.fail("Unknown declaration type"); - } - function isTypeReference(node) { - if (ts.isRightSideOfQualifiedNameOrPropertyAccess(node)) { - node = node.parent; - } - return node.parent.kind === 151 || - (node.parent.kind === 188 && !ts.isExpressionWithTypeArgumentsInClassExtendsClause(node.parent)) || - node.kind === 97 && !ts.isExpression(node); - } - function isNamespaceReference(node) { - return isQualifiedNameNamespaceReference(node) || isPropertyAccessNamespaceReference(node); - } - function isPropertyAccessNamespaceReference(node) { - var root = node; - var isLastClause = true; - if (root.parent.kind === 166) { - while (root.parent && root.parent.kind === 166) { - root = root.parent; - } - isLastClause = root.name === node; - } - if (!isLastClause && root.parent.kind === 188 && root.parent.parent.kind === 243) { - var decl = root.parent.parent.parent; - return (decl.kind === 214 && root.parent.parent.token === 106) || - (decl.kind === 215 && root.parent.parent.token === 83); - } - return false; - } - function isQualifiedNameNamespaceReference(node) { - var root = node; - var isLastClause = true; - if (root.parent.kind === 135) { - while (root.parent && root.parent.kind === 135) { - root = root.parent; - } - isLastClause = root.right === node; - } - return root.parent.kind === 151 && !isLastClause; - } - function isInRightSideOfImport(node) { - while (node.parent.kind === 135) { - node = node.parent; - } - return ts.isInternalModuleImportEqualsDeclaration(node.parent) && node.parent.moduleReference === node; - } - function getMeaningFromRightHandSideOfImportEquals(node) { - ts.Debug.assert(node.kind === 69); - if (node.parent.kind === 135 && - node.parent.right === node && - node.parent.parent.kind === 221) { - return 1 | 2 | 4; - } - return 4; - } - function getMeaningFromLocation(node) { - if (node.parent.kind === 227) { - return 1 | 2 | 4; - } - else if (isInRightSideOfImport(node)) { - return getMeaningFromRightHandSideOfImportEquals(node); - } - else if (ts.isDeclarationName(node)) { - return getMeaningFromDeclaration(node.parent); - } - else if (isTypeReference(node)) { - return 2; - } - else if (isNamespaceReference(node)) { - return 4; - } - else { - return 1; - } - } - function getSignatureHelpItems(fileName, position) { - synchronizeHostData(); - var sourceFile = getValidSourceFile(fileName); - return ts.SignatureHelp.getSignatureHelpItems(program, sourceFile, position, cancellationToken); - } - function getSourceFile(fileName) { - return syntaxTreeCache.getCurrentSourceFile(fileName); - } - function getNameOrDottedNameSpan(fileName, startPos, endPos) { - var sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName); - var node = ts.getTouchingPropertyName(sourceFile, startPos); - if (!node) { - return; - } - switch (node.kind) { - case 166: - case 135: - case 9: - case 84: - case 99: - case 93: - case 95: - case 97: - case 69: - break; - default: - return; - } - var nodeForStartPos = node; - while (true) { - if (isRightSideOfPropertyAccess(nodeForStartPos) || isRightSideOfQualifiedName(nodeForStartPos)) { - nodeForStartPos = nodeForStartPos.parent; - } - else if (isNameOfModuleDeclaration(nodeForStartPos)) { - if (nodeForStartPos.parent.parent.kind === 218 && - nodeForStartPos.parent.parent.body === nodeForStartPos.parent) { - nodeForStartPos = nodeForStartPos.parent.parent.name; - } - else { - break; - } - } - else { - break; - } - } - return ts.createTextSpanFromBounds(nodeForStartPos.getStart(), node.getEnd()); - } - function getBreakpointStatementAtPosition(fileName, position) { - var sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName); - return ts.BreakpointResolver.spanInSourceFileAtLocation(sourceFile, position); - } - function getNavigationBarItems(fileName) { - var sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName); - return ts.NavigationBar.getNavigationBarItems(sourceFile); - } - function getSemanticClassifications(fileName, span) { - return convertClassifications(getEncodedSemanticClassifications(fileName, span)); - } - function checkForClassificationCancellation(kind) { - switch (kind) { - case 218: - case 214: - case 215: - case 213: - cancellationToken.throwIfCancellationRequested(); - } - } - function getEncodedSemanticClassifications(fileName, span) { - synchronizeHostData(); - var sourceFile = getValidSourceFile(fileName); - var typeChecker = program.getTypeChecker(); - var result = []; - var classifiableNames = program.getClassifiableNames(); - processNode(sourceFile); - return { spans: result, endOfLineState: 0 }; - function pushClassification(start, length, type) { - result.push(start); - result.push(length); - result.push(type); - } - function classifySymbol(symbol, meaningAtPosition) { - var flags = symbol.getFlags(); - if ((flags & 788448) === 0) { - return; - } - if (flags & 32) { - return 11; - } - else if (flags & 384) { - return 12; - } - else if (flags & 524288) { - return 16; - } - else if (meaningAtPosition & 2) { - if (flags & 64) { - return 13; - } - else if (flags & 262144) { - return 15; - } - } - else if (flags & 1536) { - if (meaningAtPosition & 4 || - (meaningAtPosition & 1 && hasValueSideModule(symbol))) { - return 14; - } - } - return undefined; - function hasValueSideModule(symbol) { - return ts.forEach(symbol.declarations, function (declaration) { - return declaration.kind === 218 && - ts.getModuleInstanceState(declaration) === 1; - }); - } - } - function processNode(node) { - if (node && ts.textSpanIntersectsWith(span, node.getFullStart(), node.getFullWidth())) { - var kind = node.kind; - checkForClassificationCancellation(kind); - if (kind === 69 && !ts.nodeIsMissing(node)) { - var identifier = node; - if (classifiableNames[identifier.text]) { - var symbol = typeChecker.getSymbolAtLocation(node); - if (symbol) { - var type = classifySymbol(symbol, getMeaningFromLocation(node)); - if (type) { - pushClassification(node.getStart(), node.getWidth(), type); - } - } - } - } - ts.forEachChild(node, processNode); - } - } - } - function getClassificationTypeName(type) { - switch (type) { - case 1: return ClassificationTypeNames.comment; - case 2: return ClassificationTypeNames.identifier; - case 3: return ClassificationTypeNames.keyword; - case 4: return ClassificationTypeNames.numericLiteral; - case 5: return ClassificationTypeNames.operator; - case 6: return ClassificationTypeNames.stringLiteral; - case 8: return ClassificationTypeNames.whiteSpace; - case 9: return ClassificationTypeNames.text; - case 10: return ClassificationTypeNames.punctuation; - case 11: return ClassificationTypeNames.className; - case 12: return ClassificationTypeNames.enumName; - case 13: return ClassificationTypeNames.interfaceName; - case 14: return ClassificationTypeNames.moduleName; - case 15: return ClassificationTypeNames.typeParameterName; - case 16: return ClassificationTypeNames.typeAliasName; - case 17: return ClassificationTypeNames.parameterName; - case 18: return ClassificationTypeNames.docCommentTagName; - } - } - function convertClassifications(classifications) { - ts.Debug.assert(classifications.spans.length % 3 === 0); - var dense = classifications.spans; - var result = []; - for (var i = 0, n = dense.length; i < n; i += 3) { - result.push({ - textSpan: ts.createTextSpan(dense[i], dense[i + 1]), - classificationType: getClassificationTypeName(dense[i + 2]) - }); - } - return result; - } - function getSyntacticClassifications(fileName, span) { - return convertClassifications(getEncodedSyntacticClassifications(fileName, span)); - } - function getEncodedSyntacticClassifications(fileName, span) { - var sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName); - 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 result = []; - processElement(sourceFile); - return { spans: result, endOfLineState: 0 }; - function pushClassification(start, length, type) { - result.push(start); - result.push(length); - result.push(type); - } - function classifyLeadingTriviaAndGetTokenStart(token) { - triviaScanner.setTextPos(token.pos); - while (true) { - var start = triviaScanner.getTextPos(); - if (!ts.couldStartTrivia(sourceFile.text, start)) { - return start; - } - var kind = triviaScanner.scan(); - var end = triviaScanner.getTextPos(); - var width = end - start; - if (!ts.isTrivia(kind)) { - return start; - } - if (kind === 4 || kind === 5) { - continue; - } - if (ts.isComment(kind)) { - classifyComment(token, kind, start, width); - triviaScanner.setTextPos(end); - continue; - } - if (kind === 7) { - var text = sourceFile.text; - var ch = text.charCodeAt(start); - if (ch === 60 || ch === 62) { - pushClassification(start, width, 1); - continue; - } - ts.Debug.assert(ch === 61); - classifyDisabledMergeCode(text, start, end); - } - } - } - function classifyComment(token, kind, start, width) { - if (kind === 3) { - var docCommentAndDiagnostics = ts.parseIsolatedJSDocComment(sourceFile.text, start, width); - if (docCommentAndDiagnostics && docCommentAndDiagnostics.jsDocComment) { - docCommentAndDiagnostics.jsDocComment.parent = token; - classifyJSDocComment(docCommentAndDiagnostics.jsDocComment); - return; - } - } - pushCommentRange(start, width); - } - function pushCommentRange(start, width) { - pushClassification(start, width, 1); - } - function classifyJSDocComment(docComment) { - var pos = docComment.pos; - for (var _i = 0, _a = docComment.tags; _i < _a.length; _i++) { - var tag = _a[_i]; - if (tag.pos !== pos) { - pushCommentRange(pos, tag.pos - pos); - } - pushClassification(tag.atToken.pos, tag.atToken.end - tag.atToken.pos, 10); - pushClassification(tag.tagName.pos, tag.tagName.end - tag.tagName.pos, 18); - pos = tag.tagName.end; - switch (tag.kind) { - case 267: - processJSDocParameterTag(tag); - break; - case 270: - processJSDocTemplateTag(tag); - break; - case 269: - processElement(tag.typeExpression); - break; - case 268: - processElement(tag.typeExpression); - break; - } - pos = tag.end; - } - if (pos !== docComment.end) { - pushCommentRange(pos, docComment.end - pos); - } - return; - function processJSDocParameterTag(tag) { - if (tag.preParameterName) { - pushCommentRange(pos, tag.preParameterName.pos - pos); - pushClassification(tag.preParameterName.pos, tag.preParameterName.end - tag.preParameterName.pos, 17); - pos = tag.preParameterName.end; - } - if (tag.typeExpression) { - pushCommentRange(pos, tag.typeExpression.pos - pos); - processElement(tag.typeExpression); - pos = tag.typeExpression.end; - } - if (tag.postParameterName) { - pushCommentRange(pos, tag.postParameterName.pos - pos); - pushClassification(tag.postParameterName.pos, tag.postParameterName.end - tag.postParameterName.pos, 17); - pos = tag.postParameterName.end; - } - } - } - function processJSDocTemplateTag(tag) { - for (var _i = 0, _a = tag.getChildren(); _i < _a.length; _i++) { - var child = _a[_i]; - processElement(child); - } - } - function classifyDisabledMergeCode(text, start, end) { - for (var i = start; i < end; i++) { - if (ts.isLineBreak(text.charCodeAt(i))) { - break; - } - } - pushClassification(start, i - start, 1); - mergeConflictScanner.setTextPos(i); - while (mergeConflictScanner.getTextPos() < end) { - classifyDisabledCodeToken(); - } - } - function classifyDisabledCodeToken() { - var start = mergeConflictScanner.getTextPos(); - var tokenKind = mergeConflictScanner.scan(); - var end = mergeConflictScanner.getTextPos(); - var type = classifyTokenType(tokenKind); - if (type) { - pushClassification(start, end - start, type); - } - } - function classifyToken(token) { - if (ts.nodeIsMissing(token)) { - return; - } - var tokenStart = classifyLeadingTriviaAndGetTokenStart(token); - var tokenWidth = token.end - tokenStart; - ts.Debug.assert(tokenWidth >= 0); - if (tokenWidth > 0) { - var type = classifyTokenType(token.kind, token); - if (type) { - pushClassification(tokenStart, tokenWidth, type); - } - } - } - function classifyTokenType(tokenKind, token) { - if (ts.isKeyword(tokenKind)) { - return 3; - } - if (tokenKind === 25 || tokenKind === 27) { - if (token && ts.getTypeArgumentOrTypeParameterList(token.parent)) { - return 10; - } - } - if (ts.isPunctuation(tokenKind)) { - if (token) { - if (tokenKind === 56) { - if (token.parent.kind === 211 || - token.parent.kind === 141 || - token.parent.kind === 138) { - return 5; - } - } - if (token.parent.kind === 181 || - token.parent.kind === 179 || - token.parent.kind === 180 || - token.parent.kind === 182) { - return 5; - } - } - return 10; - } - else if (tokenKind === 8) { - return 4; - } - else if (tokenKind === 9) { - return 6; - } - else if (tokenKind === 10) { - return 6; - } - else if (ts.isTemplateLiteralKind(tokenKind)) { - return 6; - } - else if (tokenKind === 69) { - if (token) { - switch (token.parent.kind) { - case 214: - if (token.parent.name === token) { - return 11; - } - return; - case 137: - if (token.parent.name === token) { - return 15; - } - return; - case 215: - if (token.parent.name === token) { - return 13; - } - return; - case 217: - if (token.parent.name === token) { - return 12; - } - return; - case 218: - if (token.parent.name === token) { - return 14; - } - return; - case 138: - if (token.parent.name === token) { - return 17; - } - return; - } - } - return 2; - } - } - function processElement(element) { - if (!element) { - return; - } - if (ts.decodedTextSpanIntersectsWith(spanStart, spanLength, element.pos, element.getFullWidth())) { - checkForClassificationCancellation(element.kind); - var children = element.getChildren(sourceFile); - for (var i = 0, n = children.length; i < n; i++) { - var child = children[i]; - if (ts.isToken(child)) { - classifyToken(child); - } - else { - processElement(child); - } - } - } - } - } - function getOutliningSpans(fileName) { - var sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName); - return ts.OutliningElementsCollector.collectElements(sourceFile); - } - function getBraceMatchingAtPosition(fileName, position) { - var sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName); - var result = []; - var token = ts.getTouchingToken(sourceFile, position); - if (token.getStart(sourceFile) === position) { - var matchKind = getMatchingTokenKind(token); - if (matchKind) { - var parentElement = token.parent; - var childNodes = parentElement.getChildren(sourceFile); - for (var _i = 0; _i < childNodes.length; _i++) { - var current = childNodes[_i]; - if (current.kind === matchKind) { - var range1 = ts.createTextSpan(token.getStart(sourceFile), token.getWidth(sourceFile)); - var range2 = ts.createTextSpan(current.getStart(sourceFile), current.getWidth(sourceFile)); - if (range1.start < range2.start) { - result.push(range1, range2); - } - else { - result.push(range2, range1); - } - break; - } - } - } - } - 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; - } - return undefined; - } - } - function getIndentationAtPosition(fileName, position, editorOptions) { - var start = new Date().getTime(); - var sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName); - log("getIndentationAtPosition: getCurrentSourceFile: " + (new Date().getTime() - start)); - start = new Date().getTime(); - var result = ts.formatting.SmartIndenter.getIndentation(position, sourceFile, editorOptions); - log("getIndentationAtPosition: computeIndentation : " + (new Date().getTime() - start)); - return result; - } - function getFormattingEditsForRange(fileName, start, end, options) { - var sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName); - return ts.formatting.formatSelection(start, end, sourceFile, getRuleProvider(options), options); - } - function getFormattingEditsForDocument(fileName, options) { - var sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName); - return ts.formatting.formatDocument(sourceFile, getRuleProvider(options), options); - } - function getFormattingEditsAfterKeystroke(fileName, position, key, options) { - var sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName); - if (key === "}") { - return ts.formatting.formatOnClosingCurly(position, sourceFile, getRuleProvider(options), options); - } - else if (key === ";") { - return ts.formatting.formatOnSemicolon(position, sourceFile, getRuleProvider(options), options); - } - else if (key === "\n") { - return ts.formatting.formatOnEnter(position, sourceFile, getRuleProvider(options), options); - } - return []; - } - function getDocCommentTemplateAtPosition(fileName, position) { - var start = new Date().getTime(); - var sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName); - if (ts.isInString(sourceFile, position) || ts.isInComment(sourceFile, position) || ts.hasDocComment(sourceFile, position)) { - return undefined; - } - var tokenAtPos = ts.getTokenAtPosition(sourceFile, position); - var tokenStart = tokenAtPos.getStart(); - if (!tokenAtPos || tokenStart < position) { - return undefined; - } - var commentOwner; - findOwner: for (commentOwner = tokenAtPos; commentOwner; commentOwner = commentOwner.parent) { - switch (commentOwner.kind) { - case 213: - case 143: - case 144: - case 214: - case 193: - break findOwner; - case 248: - return undefined; - case 218: - if (commentOwner.parent.kind === 218) { - return undefined; - } - break findOwner; - } - } - if (!commentOwner || commentOwner.getStart() < position) { - return undefined; - } - var parameters = getParametersForJsDocOwningNode(commentOwner); - var posLineAndChar = sourceFile.getLineAndCharacterOfPosition(position); - var lineStart = sourceFile.getLineStarts()[posLineAndChar.line]; - var indentationStr = sourceFile.text.substr(lineStart, posLineAndChar.character); - var newLine = host.getNewLine ? host.getNewLine() : "\r\n"; - var docParams = ""; - for (var i = 0, numParams = parameters.length; i < numParams; i++) { - var currentName = parameters[i].name; - var paramName = currentName.kind === 69 ? - currentName.text : - "param" + i; - docParams += indentationStr + " * @param " + paramName + newLine; - } - var preamble = "/**" + newLine + - indentationStr + " * "; - var result = preamble + newLine + - docParams + - indentationStr + " */" + - (tokenStart === position ? newLine + indentationStr : ""); - return { newText: result, caretOffset: preamble.length }; - } - function getParametersForJsDocOwningNode(commentOwner) { - if (ts.isFunctionLike(commentOwner)) { - return commentOwner.parameters; - } - if (commentOwner.kind === 193) { - var varStatement = commentOwner; - var varDeclarations = varStatement.declarationList.declarations; - if (varDeclarations.length === 1 && varDeclarations[0].initializer) { - return getParametersFromRightHandSideOfAssignment(varDeclarations[0].initializer); - } - } - return emptyArray; - } - function getParametersFromRightHandSideOfAssignment(rightHandSide) { - while (rightHandSide.kind === 172) { - rightHandSide = rightHandSide.expression; - } - switch (rightHandSide.kind) { - case 173: - case 174: - return rightHandSide.parameters; - case 186: - for (var _i = 0, _a = rightHandSide.members; _i < _a.length; _i++) { - var member = _a[_i]; - if (member.kind === 144) { - return member.parameters; - } - } - break; - } - return emptyArray; - } - function getTodoComments(fileName, descriptors) { - synchronizeHostData(); - var sourceFile = getValidSourceFile(fileName); - cancellationToken.throwIfCancellationRequested(); - var fileContents = sourceFile.text; - var result = []; - if (descriptors.length > 0) { - var regExp = getTodoCommentsRegExp(); - var matchArray; - while (matchArray = regExp.exec(fileContents)) { - cancellationToken.throwIfCancellationRequested(); - var firstDescriptorCaptureIndex = 3; - ts.Debug.assert(matchArray.length === descriptors.length + firstDescriptorCaptureIndex); - var preamble = matchArray[1]; - var matchPosition = matchArray.index + preamble.length; - var token = ts.getTokenAtPosition(sourceFile, matchPosition); - if (!isInsideComment(sourceFile, token, matchPosition)) { - continue; - } - var descriptor = undefined; - for (var i = 0, n = descriptors.length; i < n; i++) { - if (matchArray[i + firstDescriptorCaptureIndex]) { - descriptor = descriptors[i]; - } - } - ts.Debug.assert(descriptor !== undefined); - if (isLetterOrDigit(fileContents.charCodeAt(matchPosition + descriptor.text.length))) { - continue; - } - var message = matchArray[2]; - result.push({ - descriptor: descriptor, - message: message, - position: matchPosition - }); - } - } - return result; - function escapeRegExp(str) { - return str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&"); - } - function getTodoCommentsRegExp() { - var singleLineCommentStart = /(?:\/\/+\s*)/.source; - var multiLineCommentStart = /(?:\/\*+\s*)/.source; - var anyNumberOfSpacesAndAsterixesAtStartOfLine = /(?:^(?:\s|\*)*)/.source; - var preamble = "(" + anyNumberOfSpacesAndAsterixesAtStartOfLine + "|" + singleLineCommentStart + "|" + multiLineCommentStart + ")"; - var literals = "(?:" + ts.map(descriptors, function (d) { return "(" + escapeRegExp(d.text) + ")"; }).join("|") + ")"; - var endOfLineOrEndOfComment = /(?:$|\*\/)/.source; - var messageRemainder = /(?:.*?)/.source; - var messagePortion = "(" + literals + messageRemainder + ")"; - var regExpString = preamble + messagePortion + endOfLineOrEndOfComment; - return new RegExp(regExpString, "gim"); - } - function isLetterOrDigit(char) { - return (char >= 97 && char <= 122) || - (char >= 65 && char <= 90) || - (char >= 48 && char <= 57); - } - } - function getRenameInfo(fileName, position) { - synchronizeHostData(); - var sourceFile = getValidSourceFile(fileName); - var typeChecker = program.getTypeChecker(); - var node = ts.getTouchingWord(sourceFile, position); - if (node && node.kind === 69) { - var symbol = typeChecker.getSymbolAtLocation(node); - if (symbol) { - var declarations = symbol.getDeclarations(); - if (declarations && declarations.length > 0) { - var defaultLibFileName = host.getDefaultLibFileName(host.getCompilationSettings()); - if (defaultLibFileName) { - for (var _i = 0; _i < declarations.length; _i++) { - var current = declarations[_i]; - var sourceFile_2 = current.getSourceFile(); - var canonicalName = getCanonicalFileName(ts.normalizePath(sourceFile_2.fileName)); - if (sourceFile_2 && getCanonicalFileName(ts.normalizePath(sourceFile_2.fileName)) === getCanonicalFileName(ts.normalizePath(defaultLibFileName))) { - return getRenameInfoError(ts.getLocaleSpecificMessage(ts.Diagnostics.You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library.key)); - } - } - } - var displayName = ts.stripQuotes(ts.getDeclaredName(typeChecker, symbol, node)); - var kind = getSymbolKind(symbol, node); - if (kind) { - return { - canRename: true, - localizedErrorMessage: undefined, - displayName: displayName, - fullDisplayName: typeChecker.getFullyQualifiedName(symbol), - kind: kind, - kindModifiers: getSymbolModifiers(symbol), - triggerSpan: ts.createTextSpan(node.getStart(), node.getWidth()) - }; - } - } - } - } - return getRenameInfoError(ts.getLocaleSpecificMessage(ts.Diagnostics.You_cannot_rename_this_element.key)); - function getRenameInfoError(localizedErrorMessage) { - return { - canRename: false, - localizedErrorMessage: localizedErrorMessage, - displayName: undefined, - fullDisplayName: undefined, - kind: undefined, - kindModifiers: undefined, - triggerSpan: undefined - }; - } - } - return { - dispose: dispose, - cleanupSemanticCache: cleanupSemanticCache, - getSyntacticDiagnostics: getSyntacticDiagnostics, - getSemanticDiagnostics: getSemanticDiagnostics, - getCompilerOptionsDiagnostics: getCompilerOptionsDiagnostics, - getSyntacticClassifications: getSyntacticClassifications, - getSemanticClassifications: getSemanticClassifications, - getEncodedSyntacticClassifications: getEncodedSyntacticClassifications, - getEncodedSemanticClassifications: getEncodedSemanticClassifications, - getCompletionsAtPosition: getCompletionsAtPosition, - getCompletionEntryDetails: getCompletionEntryDetails, - getSignatureHelpItems: getSignatureHelpItems, - getQuickInfoAtPosition: getQuickInfoAtPosition, - getDefinitionAtPosition: getDefinitionAtPosition, - getTypeDefinitionAtPosition: getTypeDefinitionAtPosition, - getReferencesAtPosition: getReferencesAtPosition, - findReferences: findReferences, - getOccurrencesAtPosition: getOccurrencesAtPosition, - getDocumentHighlights: getDocumentHighlights, - getNameOrDottedNameSpan: getNameOrDottedNameSpan, - getBreakpointStatementAtPosition: getBreakpointStatementAtPosition, - getNavigateToItems: getNavigateToItems, - getRenameInfo: getRenameInfo, - findRenameLocations: findRenameLocations, - getNavigationBarItems: getNavigationBarItems, - getOutliningSpans: getOutliningSpans, - getTodoComments: getTodoComments, - getBraceMatchingAtPosition: getBraceMatchingAtPosition, - getIndentationAtPosition: getIndentationAtPosition, - getFormattingEditsForRange: getFormattingEditsForRange, - getFormattingEditsForDocument: getFormattingEditsForDocument, - getFormattingEditsAfterKeystroke: getFormattingEditsAfterKeystroke, - getDocCommentTemplateAtPosition: getDocCommentTemplateAtPosition, - getEmitOutput: getEmitOutput, - getSourceFile: getSourceFile, - getProgram: getProgram - }; - } - ts.createLanguageService = createLanguageService; - function getNameTable(sourceFile) { - if (!sourceFile.nameTable) { - initializeNameTable(sourceFile); - } - return sourceFile.nameTable; - } - ts.getNameTable = getNameTable; - function initializeNameTable(sourceFile) { - var nameTable = {}; - walk(sourceFile); - sourceFile.nameTable = nameTable; - function walk(node) { - switch (node.kind) { - case 69: - nameTable[node.text] = node.text; - break; - case 9: - case 8: - if (ts.isDeclarationName(node) || - node.parent.kind === 232 || - isArgumentOfElementAccessExpression(node)) { - nameTable[node.text] = node.text; - } - break; - default: - ts.forEachChild(node, walk); - } - } - } - function isArgumentOfElementAccessExpression(node) { - return node && - node.parent && - node.parent.kind === 167 && - node.parent.argumentExpression === node; - } - function createClassifier() { - var scanner = ts.createScanner(2, false); - var noRegexTable = []; - noRegexTable[69] = true; - noRegexTable[9] = true; - noRegexTable[8] = true; - noRegexTable[10] = true; - noRegexTable[97] = true; - noRegexTable[41] = true; - noRegexTable[42] = true; - noRegexTable[18] = true; - noRegexTable[20] = true; - noRegexTable[16] = true; - noRegexTable[99] = true; - noRegexTable[84] = true; - var templateStack = []; - function canFollow(keyword1, keyword2) { - if (ts.isAccessibilityModifier(keyword1)) { - if (keyword2 === 123 || - keyword2 === 129 || - keyword2 === 121 || - keyword2 === 113) { - return true; - } - return false; - } - return true; - } - function convertClassifications(classifications, text) { - var entries = []; - var dense = classifications.spans; - var lastEnd = 0; - for (var i = 0, n = dense.length; i < n; i += 3) { - var start = dense[i]; - var length_3 = dense[i + 1]; - var type = dense[i + 2]; - if (lastEnd >= 0) { - var whitespaceLength_1 = start - lastEnd; - if (whitespaceLength_1 > 0) { - entries.push({ length: whitespaceLength_1, classification: TokenClass.Whitespace }); - } - } - entries.push({ length: length_3, classification: convertClassification(type) }); - lastEnd = start + length_3; - } - var whitespaceLength = text.length - lastEnd; - if (whitespaceLength > 0) { - entries.push({ length: whitespaceLength, classification: TokenClass.Whitespace }); - } - return { entries: entries, finalLexState: classifications.endOfLineState }; - } - function convertClassification(type) { - switch (type) { - case 1: return TokenClass.Comment; - case 3: return TokenClass.Keyword; - case 4: return TokenClass.NumberLiteral; - case 5: return TokenClass.Operator; - case 6: return TokenClass.StringLiteral; - case 8: return TokenClass.Whitespace; - case 10: return TokenClass.Punctuation; - case 2: - case 11: - case 12: - case 13: - case 14: - case 15: - case 16: - case 9: - case 17: - default: - return TokenClass.Identifier; - } - } - function getClassificationsForLine(text, lexState, syntacticClassifierAbsent) { - return convertClassifications(getEncodedLexicalClassifications(text, lexState, syntacticClassifierAbsent), text); - } - function getEncodedLexicalClassifications(text, lexState, syntacticClassifierAbsent) { - var offset = 0; - var token = 0; - var lastNonTriviaToken = 0; - while (templateStack.length > 0) { - templateStack.pop(); - } - switch (lexState) { - case 3: - text = '"\\\n' + text; - offset = 3; - break; - case 2: - text = "'\\\n" + text; - offset = 3; - break; - case 1: - text = "/*\n" + text; - offset = 3; - break; - case 4: - text = "`\n" + text; - offset = 2; - break; - case 5: - text = "}\n" + text; - offset = 2; - case 6: - templateStack.push(12); - break; - } - scanner.setText(text); - var result = { - endOfLineState: 0, - spans: [] - }; - var angleBracketStack = 0; - do { - token = scanner.scan(); - if (!ts.isTrivia(token)) { - if ((token === 39 || token === 61) && !noRegexTable[lastNonTriviaToken]) { - if (scanner.reScanSlashToken() === 10) { - token = 10; - } - } - else if (lastNonTriviaToken === 21 && isKeyword(token)) { - token = 69; - } - else if (isKeyword(lastNonTriviaToken) && isKeyword(token) && !canFollow(lastNonTriviaToken, token)) { - token = 69; - } - else if (lastNonTriviaToken === 69 && - token === 25) { - angleBracketStack++; - } - else if (token === 27 && angleBracketStack > 0) { - angleBracketStack--; - } - else if (token === 117 || - token === 130 || - token === 128 || - token === 120 || - token === 131) { - if (angleBracketStack > 0 && !syntacticClassifierAbsent) { - token = 69; - } - } - else if (token === 12) { - templateStack.push(token); - } - else if (token === 15) { - if (templateStack.length > 0) { - templateStack.push(token); - } - } - else if (token === 16) { - if (templateStack.length > 0) { - var lastTemplateStackToken = ts.lastOrUndefined(templateStack); - if (lastTemplateStackToken === 12) { - token = scanner.reScanTemplateToken(); - if (token === 14) { - templateStack.pop(); - } - else { - ts.Debug.assert(token === 13, "Should have been a template middle. Was " + token); - } - } - else { - ts.Debug.assert(lastTemplateStackToken === 15, "Should have been an open brace. Was: " + token); - templateStack.pop(); - } - } - } - lastNonTriviaToken = token; - } - processToken(); - } while (token !== 1); - return result; - function processToken() { - var start = scanner.getTokenPos(); - var end = scanner.getTextPos(); - addResult(start, end, classFromKind(token)); - if (end >= text.length) { - if (token === 9) { - var tokenText = scanner.getTokenText(); - if (scanner.isUnterminated()) { - var lastCharIndex = tokenText.length - 1; - var numBackslashes = 0; - while (tokenText.charCodeAt(lastCharIndex - numBackslashes) === 92) { - numBackslashes++; - } - if (numBackslashes & 1) { - var quoteChar = tokenText.charCodeAt(0); - result.endOfLineState = quoteChar === 34 - ? 3 - : 2; - } - } - } - else if (token === 3) { - if (scanner.isUnterminated()) { - result.endOfLineState = 1; - } - } - else if (ts.isTemplateLiteralKind(token)) { - if (scanner.isUnterminated()) { - if (token === 14) { - result.endOfLineState = 5; - } - else if (token === 11) { - result.endOfLineState = 4; - } - else { - ts.Debug.fail("Only 'NoSubstitutionTemplateLiteral's and 'TemplateTail's can be unterminated; got SyntaxKind #" + token); - } - } - } - else if (templateStack.length > 0 && ts.lastOrUndefined(templateStack) === 12) { - result.endOfLineState = 6; - } - } - } - function addResult(start, end, classification) { - if (classification === 8) { - return; - } - if (start === 0 && offset > 0) { - start += offset; - } - start -= offset; - end -= offset; - var length = end - start; - if (length > 0) { - result.spans.push(start); - result.spans.push(length); - result.spans.push(classification); - } - } - } - function isBinaryExpressionOperatorToken(token) { - switch (token) { - case 37: - case 39: - case 40: - case 35: - case 36: - case 43: - case 44: - case 45: - case 25: - case 27: - case 28: - case 29: - case 91: - case 90: - case 116: - case 30: - case 31: - case 32: - case 33: - case 46: - case 48: - case 47: - case 51: - case 52: - case 67: - case 66: - case 68: - case 63: - case 64: - case 65: - case 57: - case 58: - case 59: - case 61: - case 62: - case 56: - case 24: - return true; - default: - return false; - } - } - function isPrefixUnaryExpressionOperatorToken(token) { - switch (token) { - case 35: - case 36: - case 50: - case 49: - case 41: - case 42: - return true; - default: - return false; - } - } - function isKeyword(token) { - return token >= 70 && token <= 134; - } - function classFromKind(token) { - if (isKeyword(token)) { - return 3; - } - else if (isBinaryExpressionOperatorToken(token) || isPrefixUnaryExpressionOperatorToken(token)) { - return 5; - } - else if (token >= 15 && token <= 68) { - return 10; - } - switch (token) { - case 8: - return 4; - case 9: - return 6; - case 10: - return 7; - case 7: - case 3: - case 2: - return 1; - case 5: - case 4: - return 8; - case 69: - default: - if (ts.isTemplateLiteralKind(token)) { - return 6; - } - return 2; - } - } - return { - getClassificationsForLine: getClassificationsForLine, - getEncodedLexicalClassifications: getEncodedLexicalClassifications - }; - } - ts.createClassifier = createClassifier; - function getDefaultLibFilePath(options) { - if (typeof __dirname !== "undefined") { - return __dirname + ts.directorySeparator + ts.getDefaultLibFileName(options); - } - throw new Error("getDefaultLibFilePath is only supported when consumed as a node module. "); - } - ts.getDefaultLibFilePath = getDefaultLibFilePath; - function initializeServices() { - ts.objectAllocator = { - getNodeConstructor: function (kind) { - function Node(pos, end) { - this.pos = pos; - this.end = end; - this.flags = 0; - this.parent = undefined; - } - var proto = kind === 248 ? new SourceFileObject() : new NodeObject(); - proto.kind = kind; - Node.prototype = proto; - return Node; - }, - getSymbolConstructor: function () { return SymbolObject; }, - getTypeConstructor: function () { return TypeObject; }, - getSignatureConstructor: function () { return SignatureObject; } - }; - } - initializeServices(); -})(ts || (ts = {})); -var ts; -(function (ts) { - var server; - (function (server) { - var spaceCache = []; - function generateSpaces(n) { - if (!spaceCache[n]) { - var strBuilder = ""; - for (var i = 0; i < n; i++) { - strBuilder += " "; - } - spaceCache[n] = strBuilder; - } - return spaceCache[n]; - } - server.generateSpaces = generateSpaces; - function generateIndentString(n, editorOptions) { - if (editorOptions.ConvertTabsToSpaces) { - return generateSpaces(n); - } - else { - var result = ""; - for (var i = 0; i < Math.floor(n / editorOptions.TabSize); i++) { - result += "\t"; - } - for (var i = 0; i < n % editorOptions.TabSize; i++) { - result += " "; - } - return result; - } - } - server.generateIndentString = generateIndentString; - function compareNumber(a, b) { - if (a < b) { - return -1; - } - else if (a === b) { - return 0; - } - else - return 1; - } - function compareFileStart(a, b) { - if (a.file < b.file) { - return -1; - } - else if (a.file == b.file) { - var n = compareNumber(a.start.line, b.start.line); - if (n === 0) { - return compareNumber(a.start.offset, b.start.offset); - } - else - return n; - } - else { - return 1; - } - } - function formatDiag(fileName, project, diag) { - return { - start: project.compilerService.host.positionToLineOffset(fileName, diag.start), - end: project.compilerService.host.positionToLineOffset(fileName, diag.start + diag.length), - text: ts.flattenDiagnosticMessageText(diag.messageText, "\n") - }; - } - function allEditsBeforePos(edits, pos) { - for (var i = 0, len = edits.length; i < len; i++) { - if (ts.textSpanEnd(edits[i].span) >= pos) { - return false; - } - } - return true; - } - var CommandNames; - (function (CommandNames) { - CommandNames.Brace = "brace"; - CommandNames.Change = "change"; - CommandNames.Close = "close"; - CommandNames.Completions = "completions"; - CommandNames.CompletionDetails = "completionEntryDetails"; - CommandNames.Configure = "configure"; - CommandNames.Definition = "definition"; - CommandNames.Exit = "exit"; - CommandNames.Format = "format"; - CommandNames.Formatonkey = "formatonkey"; - CommandNames.Geterr = "geterr"; - CommandNames.GeterrForProject = "geterrForProject"; - CommandNames.NavBar = "navbar"; - CommandNames.Navto = "navto"; - CommandNames.Occurrences = "occurrences"; - CommandNames.DocumentHighlights = "documentHighlights"; - CommandNames.Open = "open"; - CommandNames.Quickinfo = "quickinfo"; - CommandNames.References = "references"; - CommandNames.Reload = "reload"; - CommandNames.Rename = "rename"; - CommandNames.Saveto = "saveto"; - CommandNames.SignatureHelp = "signatureHelp"; - CommandNames.TypeDefinition = "typeDefinition"; - CommandNames.ProjectInfo = "projectInfo"; - CommandNames.ReloadProjects = "reloadProjects"; - CommandNames.Unknown = "unknown"; - })(CommandNames = server.CommandNames || (server.CommandNames = {})); - var Errors; - (function (Errors) { - Errors.NoProject = new Error("No Project."); - })(Errors || (Errors = {})); - var Session = (function () { - function Session(host, byteLength, hrtime, logger) { - var _this = this; - this.host = host; - this.byteLength = byteLength; - this.hrtime = hrtime; - this.logger = logger; - this.pendingOperation = false; - this.fileHash = {}; - this.nextFileId = 1; - this.changeSeq = 0; - this.handlers = (_a = {}, - _a[CommandNames.Exit] = function () { - _this.exit(); - return { responseRequired: false }; - }, - _a[CommandNames.Definition] = function (request) { - var defArgs = request.arguments; - return { response: _this.getDefinition(defArgs.line, defArgs.offset, defArgs.file), responseRequired: true }; - }, - _a[CommandNames.TypeDefinition] = function (request) { - var defArgs = request.arguments; - return { response: _this.getTypeDefinition(defArgs.line, defArgs.offset, defArgs.file), responseRequired: true }; - }, - _a[CommandNames.References] = function (request) { - var defArgs = request.arguments; - return { response: _this.getReferences(defArgs.line, defArgs.offset, defArgs.file), responseRequired: true }; - }, - _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 }; - }, - _a[CommandNames.Open] = function (request) { - var openArgs = request.arguments; - _this.openClientFile(openArgs.file); - return { responseRequired: false }; - }, - _a[CommandNames.Quickinfo] = function (request) { - var quickinfoArgs = request.arguments; - return { response: _this.getQuickInfo(quickinfoArgs.line, quickinfoArgs.offset, quickinfoArgs.file), responseRequired: true }; - }, - _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 }; - }, - _a[CommandNames.Formatonkey] = function (request) { - var formatOnKeyArgs = request.arguments; - return { response: _this.getFormattingEditsAfterKeystroke(formatOnKeyArgs.line, formatOnKeyArgs.offset, formatOnKeyArgs.key, formatOnKeyArgs.file), responseRequired: true }; - }, - _a[CommandNames.Completions] = function (request) { - var completionsArgs = request.arguments; - return { response: _this.getCompletions(completionsArgs.line, completionsArgs.offset, completionsArgs.prefix, completionsArgs.file), responseRequired: true }; - }, - _a[CommandNames.CompletionDetails] = function (request) { - var completionDetailsArgs = request.arguments; - return { response: _this.getCompletionEntryDetails(completionDetailsArgs.line, completionDetailsArgs.offset, completionDetailsArgs.entryNames, completionDetailsArgs.file), responseRequired: true }; - }, - _a[CommandNames.SignatureHelp] = function (request) { - var signatureHelpArgs = request.arguments; - return { response: _this.getSignatureHelpItems(signatureHelpArgs.line, signatureHelpArgs.offset, signatureHelpArgs.file), responseRequired: true }; - }, - _a[CommandNames.Geterr] = function (request) { - var geterrArgs = request.arguments; - return { response: _this.getDiagnostics(geterrArgs.delay, geterrArgs.files), responseRequired: false }; - }, - _a[CommandNames.GeterrForProject] = function (request) { - var _a = request.arguments, file = _a.file, delay = _a.delay; - 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 }; - }, - _a[CommandNames.Configure] = function (request) { - var configureArgs = request.arguments; - _this.projectService.setHostConfiguration(configureArgs); - _this.output(undefined, CommandNames.Configure, request.seq); - return { responseRequired: false }; - }, - _a[CommandNames.Reload] = function (request) { - var reloadArgs = request.arguments; - _this.reload(reloadArgs.file, reloadArgs.tmpfile, request.seq); - return { responseRequired: false }; - }, - _a[CommandNames.Saveto] = function (request) { - var savetoArgs = request.arguments; - _this.saveToTmp(savetoArgs.file, savetoArgs.tmpfile); - return { responseRequired: false }; - }, - _a[CommandNames.Close] = function (request) { - var closeArgs = request.arguments; - _this.closeClientFile(closeArgs.file); - return { responseRequired: false }; - }, - _a[CommandNames.Navto] = function (request) { - var navtoArgs = request.arguments; - return { response: _this.getNavigateToItems(navtoArgs.searchValue, navtoArgs.file, navtoArgs.maxResultCount), responseRequired: true }; - }, - _a[CommandNames.Brace] = function (request) { - var braceArguments = request.arguments; - return { response: _this.getBraceMatching(braceArguments.line, braceArguments.offset, braceArguments.file), responseRequired: true }; - }, - _a[CommandNames.NavBar] = function (request) { - var navBarArgs = request.arguments; - return { response: _this.getNavigationBarItems(navBarArgs.file), responseRequired: true }; - }, - _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 }; - }, - _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 }; - }, - _a[CommandNames.ProjectInfo] = function (request) { - var _a = request.arguments, file = _a.file, needFileNameList = _a.needFileNameList; - return { response: _this.getProjectInfo(file, needFileNameList), responseRequired: true }; - }, - _a[CommandNames.ReloadProjects] = function (request) { - _this.reloadProjects(); - return { responseRequired: false }; - }, - _a - ); - this.projectService = - new server.ProjectService(host, logger, function (eventName, project, fileName) { - _this.handleEvent(eventName, project, fileName); - }); - var _a; - } - Session.prototype.handleEvent = function (eventName, project, fileName) { - var _this = this; - if (eventName == "context") { - this.projectService.log("got context event, updating diagnostics for" + fileName, "Info"); - this.updateErrorCheck([{ fileName: fileName, project: project }], this.changeSeq, function (n) { return n === _this.changeSeq; }, 100); - } - }; - Session.prototype.logError = function (err, cmd) { - var typedErr = err; - var msg = "Exception on executing command " + cmd; - if (typedErr.message) { - msg += ":\n" + typedErr.message; - if (typedErr.stack) { - msg += "\n" + typedErr.stack; - } - } - this.projectService.log(msg); - }; - Session.prototype.sendLineToClient = function (line) { - this.host.write(line + this.host.newLine); - }; - Session.prototype.send = function (msg) { - var json = JSON.stringify(msg); - if (this.logger.isVerbose()) { - this.logger.info(msg.type + ": " + json); - } - this.sendLineToClient('Content-Length: ' + (1 + this.byteLength(json, 'utf8')) + - '\r\n\r\n' + json); - }; - Session.prototype.event = function (info, eventName) { - var ev = { - seq: 0, - type: "event", - event: eventName, - body: info - }; - this.send(ev); - }; - Session.prototype.response = function (info, cmdName, reqSeq, errorMsg) { - if (reqSeq === void 0) { reqSeq = 0; } - var res = { - seq: 0, - type: "response", - command: cmdName, - request_seq: reqSeq, - success: !errorMsg - }; - if (!errorMsg) { - res.body = info; - } - else { - res.message = errorMsg; - } - this.send(res); - }; - Session.prototype.output = function (body, commandName, requestSequence, errorMessage) { - if (requestSequence === void 0) { requestSequence = 0; } - this.response(body, commandName, requestSequence, errorMessage); - }; - Session.prototype.semanticCheck = function (file, project) { - try { - var diags = project.compilerService.languageService.getSemanticDiagnostics(file); - if (diags) { - var bakedDiags = diags.map(function (diag) { return formatDiag(file, project, diag); }); - this.event({ file: file, diagnostics: bakedDiags }, "semanticDiag"); - } - } - catch (err) { - this.logError(err, "semantic check"); - } - }; - Session.prototype.syntacticCheck = function (file, project) { - try { - var diags = project.compilerService.languageService.getSyntacticDiagnostics(file); - if (diags) { - var bakedDiags = diags.map(function (diag) { return formatDiag(file, project, diag); }); - this.event({ file: file, diagnostics: bakedDiags }, "syntaxDiag"); - } - } - catch (err) { - this.logError(err, "syntactic check"); - } - }; - Session.prototype.errorCheck = function (file, project) { - this.syntacticCheck(file, project); - this.semanticCheck(file, project); - }; - Session.prototype.reloadProjects = function () { - this.projectService.reloadProjects(); - }; - Session.prototype.updateProjectStructure = function (seq, matchSeq, ms) { - var _this = this; - if (ms === void 0) { ms = 1500; } - setTimeout(function () { - if (matchSeq(seq)) { - _this.projectService.updateProjectStructure(); - } - }, ms); - }; - Session.prototype.updateErrorCheck = function (checkList, seq, matchSeq, ms, followMs, requireOpen) { - var _this = this; - if (ms === void 0) { ms = 1500; } - if (followMs === void 0) { followMs = 200; } - if (requireOpen === void 0) { requireOpen = true; } - if (followMs > ms) { - followMs = ms; - } - if (this.errorTimer) { - clearTimeout(this.errorTimer); - } - if (this.immediateId) { - clearImmediate(this.immediateId); - this.immediateId = undefined; - } - var index = 0; - var checkOne = function () { - if (matchSeq(seq)) { - var checkSpec = checkList[index++]; - if (checkSpec.project.getSourceFileFromName(checkSpec.fileName, requireOpen)) { - _this.syntacticCheck(checkSpec.fileName, checkSpec.project); - _this.immediateId = setImmediate(function () { - _this.semanticCheck(checkSpec.fileName, checkSpec.project); - _this.immediateId = undefined; - if (checkList.length > index) { - _this.errorTimer = setTimeout(checkOne, followMs); - } - else { - _this.errorTimer = undefined; - } - }); - } - } - }; - if ((checkList.length > index) && (matchSeq(seq))) { - this.errorTimer = setTimeout(checkOne, ms); - } - }; - Session.prototype.getDefinition = function (line, offset, fileName) { - var file = ts.normalizePath(fileName); - var project = this.projectService.getProjectForFile(file); - if (!project) { - throw Errors.NoProject; - } - var compilerService = project.compilerService; - var position = compilerService.host.lineOffsetToPosition(file, line, offset); - var definitions = compilerService.languageService.getDefinitionAtPosition(file, position); - if (!definitions) { - return undefined; - } - return definitions.map(function (def) { return ({ - file: def.fileName, - start: compilerService.host.positionToLineOffset(def.fileName, def.textSpan.start), - end: compilerService.host.positionToLineOffset(def.fileName, ts.textSpanEnd(def.textSpan)) - }); }); - }; - Session.prototype.getTypeDefinition = function (line, offset, fileName) { - var file = ts.normalizePath(fileName); - var project = this.projectService.getProjectForFile(file); - if (!project) { - throw Errors.NoProject; - } - var compilerService = project.compilerService; - var position = compilerService.host.lineOffsetToPosition(file, line, offset); - var definitions = compilerService.languageService.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)) - }); }); - }; - Session.prototype.getOccurrences = function (line, offset, fileName) { - fileName = ts.normalizePath(fileName); - var project = this.projectService.getProjectForFile(fileName); - if (!project) { - throw Errors.NoProject; - } - var compilerService = project.compilerService; - var position = compilerService.host.lineOffsetToPosition(fileName, line, offset); - var occurrences = compilerService.languageService.getOccurrencesAtPosition(fileName, 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)); - return { - start: start, - end: end, - file: fileName, - isWriteAccess: isWriteAccess - }; - }); - }; - Session.prototype.getDocumentHighlights = function (line, offset, fileName, filesToSearch) { - fileName = ts.normalizePath(fileName); - var project = this.projectService.getProjectForFile(fileName); - if (!project) { - throw Errors.NoProject; - } - var compilerService = project.compilerService; - var position = compilerService.host.lineOffsetToPosition(fileName, line, offset); - var documentHighlights = compilerService.languageService.getDocumentHighlights(fileName, position, filesToSearch); - if (!documentHighlights) { - return undefined; - } - return documentHighlights.map(convertToDocumentHighlightsItem); - function convertToDocumentHighlightsItem(documentHighlights) { - var fileName = documentHighlights.fileName, highlightSpans = documentHighlights.highlightSpans; - 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)); - return { start: start, end: end, kind: kind }; - } - } - }; - Session.prototype.getProjectInfo = function (fileName, needFileNameList) { - fileName = ts.normalizePath(fileName); - var project = this.projectService.getProjectForFile(fileName); - var projectInfo = { - configFileName: project.projectFilename - }; - if (needFileNameList) { - projectInfo.fileNames = project.getFileNames(); - } - return projectInfo; - }; - Session.prototype.getRenameLocations = function (line, offset, fileName, findInComments, findInStrings) { - var file = ts.normalizePath(fileName); - var project = this.projectService.getProjectForFile(file); - if (!project) { - throw Errors.NoProject; - } - var compilerService = project.compilerService; - var position = compilerService.host.lineOffsetToPosition(file, line, offset); - var renameInfo = compilerService.languageService.getRenameInfo(file, position); - if (!renameInfo) { - return undefined; - } - if (!renameInfo.canRename) { - return { - info: renameInfo, - locs: [] - }; - } - var renameLocations = compilerService.languageService.findRenameLocations(file, position, findInStrings, findInComments); - if (!renameLocations) { - return undefined; - } - var bakedRenameLocs = renameLocations.map(function (location) { return ({ - file: location.fileName, - start: compilerService.host.positionToLineOffset(location.fileName, location.textSpan.start), - end: compilerService.host.positionToLineOffset(location.fileName, ts.textSpanEnd(location.textSpan)) - }); }).sort(function (a, b) { - if (a.file < b.file) { - return -1; - } - else if (a.file > b.file) { - return 1; - } - else { - if (a.start.line < b.start.line) { - return 1; - } - else if (a.start.line > b.start.line) { - return -1; - } - else { - return b.start.offset - a.start.offset; - } - } - }).reduce(function (accum, cur) { - var curFileAccum; - if (accum.length > 0) { - curFileAccum = accum[accum.length - 1]; - if (curFileAccum.file != cur.file) { - curFileAccum = undefined; - } - } - if (!curFileAccum) { - curFileAccum = { file: cur.file, locs: [] }; - accum.push(curFileAccum); - } - curFileAccum.locs.push({ start: cur.start, end: cur.end }); - return accum; - }, []); - return { info: renameInfo, locs: bakedRenameLocs }; - }; - Session.prototype.getReferences = function (line, offset, fileName) { - var file = ts.normalizePath(fileName); - var project = this.projectService.getProjectForFile(file); - if (!project) { - throw Errors.NoProject; - } - var compilerService = project.compilerService; - var position = compilerService.host.lineOffsetToPosition(file, line, offset); - var references = compilerService.languageService.getReferencesAtPosition(file, position); - if (!references) { - return undefined; - } - var nameInfo = compilerService.languageService.getQuickInfoAtPosition(file, position); - if (!nameInfo) { - return undefined; - } - var displayString = ts.displayPartsToString(nameInfo.displayParts); - var nameSpan = nameInfo.textSpan; - var nameColStart = compilerService.host.positionToLineOffset(file, nameSpan.start).offset; - var nameText = compilerService.host.getScriptSnapshot(file).getText(nameSpan.start, ts.textSpanEnd(nameSpan)); - var bakedRefs = references.map(function (ref) { - var start = compilerService.host.positionToLineOffset(ref.fileName, ref.textSpan.start); - var refLineSpan = compilerService.host.lineToTextSpan(ref.fileName, start.line - 1); - var snap = compilerService.host.getScriptSnapshot(ref.fileName); - var lineText = snap.getText(refLineSpan.start, ts.textSpanEnd(refLineSpan)).replace(/\r|\n/g, ""); - return { - file: ref.fileName, - start: start, - lineText: lineText, - end: compilerService.host.positionToLineOffset(ref.fileName, ts.textSpanEnd(ref.textSpan)), - isWriteAccess: ref.isWriteAccess - }; - }).sort(compareFileStart); - return { - refs: bakedRefs, - symbolName: nameText, - symbolStartOffset: nameColStart, - symbolDisplayString: displayString - }; - }; - Session.prototype.openClientFile = function (fileName) { - var file = ts.normalizePath(fileName); - this.projectService.openClientFile(file); - }; - Session.prototype.getQuickInfo = function (line, offset, fileName) { - var file = ts.normalizePath(fileName); - var project = this.projectService.getProjectForFile(file); - if (!project) { - throw Errors.NoProject; - } - var compilerService = project.compilerService; - var position = compilerService.host.lineOffsetToPosition(file, line, offset); - var quickInfo = compilerService.languageService.getQuickInfoAtPosition(file, position); - if (!quickInfo) { - return undefined; - } - var displayString = ts.displayPartsToString(quickInfo.displayParts); - var docString = ts.displayPartsToString(quickInfo.documentation); - return { - kind: quickInfo.kind, - kindModifiers: quickInfo.kindModifiers, - start: compilerService.host.positionToLineOffset(file, quickInfo.textSpan.start), - end: compilerService.host.positionToLineOffset(file, ts.textSpanEnd(quickInfo.textSpan)), - displayString: displayString, - documentation: docString - }; - }; - Session.prototype.getFormattingEditsForRange = function (line, offset, endLine, endOffset, fileName) { - var file = ts.normalizePath(fileName); - var project = this.projectService.getProjectForFile(file); - if (!project) { - throw Errors.NoProject; - } - var compilerService = project.compilerService; - var startPosition = compilerService.host.lineOffsetToPosition(file, line, offset); - var endPosition = compilerService.host.lineOffsetToPosition(file, endLine, endOffset); - var edits = compilerService.languageService.getFormattingEditsForRange(file, startPosition, endPosition, this.projectService.getFormatCodeOptions(file)); - if (!edits) { - return undefined; - } - return edits.map(function (edit) { - return { - start: compilerService.host.positionToLineOffset(file, edit.span.start), - end: compilerService.host.positionToLineOffset(file, ts.textSpanEnd(edit.span)), - newText: edit.newText ? edit.newText : "" - }; - }); - }; - Session.prototype.getFormattingEditsAfterKeystroke = function (line, offset, key, fileName) { - var file = ts.normalizePath(fileName); - var project = this.projectService.getProjectForFile(file); - if (!project) { - throw Errors.NoProject; - } - var compilerService = project.compilerService; - var position = compilerService.host.lineOffsetToPosition(file, line, offset); - var formatOptions = this.projectService.getFormatCodeOptions(file); - var edits = compilerService.languageService.getFormattingEditsAfterKeystroke(file, position, key, formatOptions); - if ((key == "\n") && ((!edits) || (edits.length === 0) || allEditsBeforePos(edits, position))) { - var scriptInfo = compilerService.host.getScriptInfo(file); - if (scriptInfo) { - var lineInfo = scriptInfo.getLineInfo(line); - if (lineInfo && (lineInfo.leaf) && (lineInfo.leaf.text)) { - var lineText = lineInfo.leaf.text; - if (lineText.search("\\S") < 0) { - var editorOptions = { - IndentSize: formatOptions.IndentSize, - TabSize: formatOptions.TabSize, - NewLineCharacter: "\n", - ConvertTabsToSpaces: formatOptions.ConvertTabsToSpaces, - IndentStyle: ts.IndentStyle.Smart - }; - var preferredIndent = compilerService.languageService.getIndentationAtPosition(file, position, editorOptions); - var hasIndent = 0; - for (var i = 0, len = lineText.length; i < len; i++) { - if (lineText.charAt(i) == " ") { - hasIndent++; - } - else if (lineText.charAt(i) == "\t") { - hasIndent += editorOptions.TabSize; - } - else { - break; - } - } - if (preferredIndent !== hasIndent) { - var firstNoWhiteSpacePosition = lineInfo.offset + i; - edits.push({ - span: ts.createTextSpanFromBounds(lineInfo.offset, firstNoWhiteSpacePosition), - newText: generateIndentString(preferredIndent, editorOptions) - }); - } - } - } - } - } - if (!edits) { - return undefined; - } - return edits.map(function (edit) { - return { - start: compilerService.host.positionToLineOffset(file, edit.span.start), - end: compilerService.host.positionToLineOffset(file, ts.textSpanEnd(edit.span)), - newText: edit.newText ? edit.newText : "" - }; - }); - }; - Session.prototype.getCompletions = function (line, offset, prefix, fileName) { - if (!prefix) { - prefix = ""; - } - var file = ts.normalizePath(fileName); - var project = this.projectService.getProjectForFile(file); - if (!project) { - throw Errors.NoProject; - } - var compilerService = project.compilerService; - var position = compilerService.host.lineOffsetToPosition(file, line, offset); - var completions = compilerService.languageService.getCompletionsAtPosition(file, position); - if (!completions) { - return undefined; - } - return completions.entries.reduce(function (result, entry) { - if (completions.isMemberCompletion || (entry.name.toLowerCase().indexOf(prefix.toLowerCase()) === 0)) { - result.push(entry); - } - return result; - }, []).sort(function (a, b) { return a.name.localeCompare(b.name); }); - }; - Session.prototype.getCompletionEntryDetails = function (line, offset, entryNames, fileName) { - var file = ts.normalizePath(fileName); - var project = this.projectService.getProjectForFile(file); - if (!project) { - throw Errors.NoProject; - } - var compilerService = project.compilerService; - var position = compilerService.host.lineOffsetToPosition(file, line, offset); - return entryNames.reduce(function (accum, entryName) { - var details = compilerService.languageService.getCompletionEntryDetails(file, position, entryName); - if (details) { - accum.push(details); - } - return accum; - }, []); - }; - Session.prototype.getSignatureHelpItems = function (line, offset, fileName) { - var file = ts.normalizePath(fileName); - var project = this.projectService.getProjectForFile(file); - if (!project) { - throw Errors.NoProject; - } - var compilerService = project.compilerService; - var position = compilerService.host.lineOffsetToPosition(file, line, offset); - var helpItems = compilerService.languageService.getSignatureHelpItems(file, position); - if (!helpItems) { - return undefined; - } - var span = helpItems.applicableSpan; - var result = { - items: helpItems.items, - applicableSpan: { - start: compilerService.host.positionToLineOffset(file, span.start), - end: compilerService.host.positionToLineOffset(file, span.start + span.length) - }, - selectedItemIndex: helpItems.selectedItemIndex, - argumentIndex: helpItems.argumentIndex, - argumentCount: helpItems.argumentCount - }; - return result; - }; - Session.prototype.getDiagnostics = function (delay, fileNames) { - var _this = this; - var checkList = fileNames.reduce(function (accum, fileName) { - fileName = ts.normalizePath(fileName); - var project = _this.projectService.getProjectForFile(fileName); - if (project) { - accum.push({ fileName: fileName, project: project }); - } - return accum; - }, []); - if (checkList.length > 0) { - this.updateErrorCheck(checkList, this.changeSeq, function (n) { return n === _this.changeSeq; }, delay); - } - }; - Session.prototype.change = function (line, offset, endLine, endOffset, insertString, fileName) { - var _this = this; - var file = ts.normalizePath(fileName); - var project = this.projectService.getProjectForFile(file); - if (project) { - var compilerService = project.compilerService; - var start = compilerService.host.lineOffsetToPosition(file, line, offset); - var end = compilerService.host.lineOffsetToPosition(file, endLine, endOffset); - if (start >= 0) { - compilerService.host.editScript(file, start, end, insertString); - this.changeSeq++; - } - this.updateProjectStructure(this.changeSeq, function (n) { return n === _this.changeSeq; }); - } - }; - Session.prototype.reload = function (fileName, tempFileName, reqSeq) { - var _this = this; - if (reqSeq === void 0) { reqSeq = 0; } - var file = ts.normalizePath(fileName); - var tmpfile = ts.normalizePath(tempFileName); - var project = this.projectService.getProjectForFile(file); - if (project) { - this.changeSeq++; - project.compilerService.host.reloadScript(file, tmpfile, function () { - _this.output(undefined, CommandNames.Reload, reqSeq); - }); - } - }; - Session.prototype.saveToTmp = function (fileName, tempFileName) { - var file = ts.normalizePath(fileName); - var tmpfile = ts.normalizePath(tempFileName); - var project = this.projectService.getProjectForFile(file); - if (project) { - project.compilerService.host.saveTo(file, tmpfile); - } - }; - Session.prototype.closeClientFile = function (fileName) { - if (!fileName) { - return; - } - var file = ts.normalizePath(fileName); - this.projectService.closeClientFile(file); - }; - Session.prototype.decorateNavigationBarItem = function (project, fileName, items) { - var _this = this; - if (!items) { - return undefined; - } - var compilerService = project.compilerService; - return items.map(function (item) { return ({ - text: item.text, - kind: item.kind, - kindModifiers: item.kindModifiers, - spans: item.spans.map(function (span) { return ({ - start: compilerService.host.positionToLineOffset(fileName, span.start), - end: compilerService.host.positionToLineOffset(fileName, ts.textSpanEnd(span)) - }); }), - childItems: _this.decorateNavigationBarItem(project, fileName, item.childItems) - }); }); - }; - Session.prototype.getNavigationBarItems = function (fileName) { - var file = ts.normalizePath(fileName); - var project = this.projectService.getProjectForFile(file); - if (!project) { - throw Errors.NoProject; - } - var compilerService = project.compilerService; - var items = compilerService.languageService.getNavigationBarItems(file); - if (!items) { - return undefined; - } - return this.decorateNavigationBarItem(project, fileName, items); - }; - Session.prototype.getNavigateToItems = function (searchValue, fileName, maxResultCount) { - var file = ts.normalizePath(fileName); - var project = this.projectService.getProjectForFile(file); - if (!project) { - throw Errors.NoProject; - } - var compilerService = project.compilerService; - var navItems = compilerService.languageService.getNavigateToItems(searchValue, maxResultCount); - if (!navItems) { - return undefined; - } - return navItems.map(function (navItem) { - var start = compilerService.host.positionToLineOffset(navItem.fileName, navItem.textSpan.start); - var end = compilerService.host.positionToLineOffset(navItem.fileName, ts.textSpanEnd(navItem.textSpan)); - var bakedItem = { - name: navItem.name, - kind: navItem.kind, - file: navItem.fileName, - start: start, - end: end - }; - if (navItem.kindModifiers && (navItem.kindModifiers != "")) { - bakedItem.kindModifiers = navItem.kindModifiers; - } - if (navItem.matchKind != 'none') { - bakedItem.matchKind = navItem.matchKind; - } - if (navItem.containerName && (navItem.containerName.length > 0)) { - bakedItem.containerName = navItem.containerName; - } - if (navItem.containerKind && (navItem.containerKind.length > 0)) { - bakedItem.containerKind = navItem.containerKind; - } - return bakedItem; - }); - }; - Session.prototype.getBraceMatching = function (line, offset, fileName) { - var file = ts.normalizePath(fileName); - var project = this.projectService.getProjectForFile(file); - if (!project) { - throw Errors.NoProject; - } - var compilerService = project.compilerService; - var position = compilerService.host.lineOffsetToPosition(file, line, offset); - var spans = compilerService.languageService.getBraceMatchingAtPosition(file, position); - if (!spans) { - return undefined; - } - return spans.map(function (span) { return ({ - start: compilerService.host.positionToLineOffset(file, span.start), - end: compilerService.host.positionToLineOffset(file, span.start + span.length) - }); }); - }; - Session.prototype.getDiagnosticsForProject = function (delay, fileName) { - var _this = this; - var _a = this.getProjectInfo(fileName, true), configFileName = _a.configFileName, fileNamesInProject = _a.fileNames; - fileNamesInProject = fileNamesInProject.filter(function (value, index, array) { return value.indexOf("lib.d.ts") < 0; }); - var highPriorityFiles = []; - var mediumPriorityFiles = []; - var lowPriorityFiles = []; - var veryLowPriorityFiles = []; - var normalizedFileName = ts.normalizePath(fileName); - var project = this.projectService.getProjectForFile(normalizedFileName); - for (var _i = 0; _i < fileNamesInProject.length; _i++) { - var fileNameInProject = fileNamesInProject[_i]; - if (this.getCanonicalFileName(fileNameInProject) == this.getCanonicalFileName(fileName)) - highPriorityFiles.push(fileNameInProject); - else { - var info = this.projectService.getScriptInfo(fileNameInProject); - if (!info.isOpen) { - if (fileNameInProject.indexOf(".d.ts") > 0) - veryLowPriorityFiles.push(fileNameInProject); - else - lowPriorityFiles.push(fileNameInProject); - } - else - mediumPriorityFiles.push(fileNameInProject); - } - } - 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 }; - }); - this.updateErrorCheck(checkList, this.changeSeq, function (n) { return n == _this.changeSeq; }, delay, 200, false); - } - }; - Session.prototype.getCanonicalFileName = function (fileName) { - var name = this.host.useCaseSensitiveFileNames ? fileName : fileName.toLowerCase(); - return ts.normalizePath(name); - }; - Session.prototype.exit = function () { - }; - Session.prototype.addProtocolHandler = function (command, handler) { - if (this.handlers[command]) { - throw new Error("Protocol handler already exists for command \"" + command + "\""); - } - this.handlers[command] = handler; - }; - Session.prototype.executeCommand = function (request) { - var handler = this.handlers[request.command]; - if (handler) { - return handler(request); - } - else { - this.projectService.log("Unrecognized JSON command: " + JSON.stringify(request)); - this.output(undefined, CommandNames.Unknown, request.seq, "Unrecognized JSON command: " + request.command); - return { responseRequired: false }; - } - }; - Session.prototype.onMessage = function (message) { - if (this.logger.isVerbose()) { - this.logger.info("request: " + message); - var start = this.hrtime(); - } - try { - var 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)"; - } - this.logger.msg(leader + ": " + elapsedMs.toFixed(4).toString(), "Perf"); - } - if (response) { - this.output(response, request.command, request.seq); - } - else if (responseRequired) { - this.output(undefined, request.command, request.seq, "No content available."); - } - } - catch (err) { - if (err instanceof ts.OperationCanceledException) { - } - this.logError(err, message); - this.output(undefined, request ? request.command : CommandNames.Unknown, request ? request.seq : 0, "Error processing request. " + err.message); - } - }; - return Session; - })(); - server.Session = Session; - })(server = ts.server || (ts.server = {})); -})(ts || (ts = {})); -var ts; -(function (ts) { - var server; - (function (server) { - var lineCollectionCapacity = 4; - function mergeFormatOptions(formatCodeOptions, formatOptions) { - var hasOwnProperty = Object.prototype.hasOwnProperty; - Object.keys(formatOptions).forEach(function (key) { - var codeKey = key.charAt(0).toUpperCase() + key.substring(1); - if (hasOwnProperty.call(formatCodeOptions, codeKey)) { - formatCodeOptions[codeKey] = formatOptions[key]; - } - }); - } - var ScriptInfo = (function () { - function ScriptInfo(host, fileName, content, isOpen) { - if (isOpen === void 0) { isOpen = false; } - this.host = host; - this.fileName = fileName; - this.content = content; - this.isOpen = isOpen; - this.children = []; - this.formatCodeOptions = ts.clone(CompilerService.defaultFormatCodeOptions); - 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.ls = null; - this.filenameToScript = {}; - this.roots = []; - this.resolvedModuleNames = ts.createFileMap(ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames)); - this.moduleResolutionHost = { - fileExists: function (fileName) { return _this.fileExists(fileName); }, - readFile: function (fileName) { return _this.host.readFile(fileName); } - }; - } - LSHost.prototype.resolveModuleNames = function (moduleNames, containingFile) { - var currentResolutionsInFile = this.resolvedModuleNames.get(containingFile); - var newResolutions = {}; - var resolvedModules = []; - var compilerOptions = this.getCompilationSettings(); - for (var _i = 0; _i < moduleNames.length; _i++) { - var moduleName = moduleNames[_i]; - var resolution = ts.lookUp(newResolutions, moduleName); - if (!resolution) { - var existingResolution = currentResolutionsInFile && ts.lookUp(currentResolutionsInFile, moduleName); - if (moduleResolutionIsValid(existingResolution)) { - resolution = existingResolution; - } - else { - resolution = ts.resolveModuleName(moduleName, containingFile, compilerOptions, this.moduleResolutionHost); - resolution.lastCheckTime = Date.now(); - newResolutions[moduleName] = resolution; - } - } - ts.Debug.assert(resolution !== undefined); - resolvedModules.push(resolution.resolvedModule); - } - this.resolvedModuleNames.set(containingFile, newResolutions); - return resolvedModules; - function moduleResolutionIsValid(resolution) { - if (!resolution) { - return false; - } - if (resolution.resolvedModule) { - return true; - } - return resolution.failedLookupLocations.length === 0; - } - }; - 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(); - }; - 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.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[info.fileName] = undefined; - this.resolvedModuleNames.remove(info.fileName); - } - }; - LSHost.prototype.getScriptInfo = function (filename) { - var scriptInfo = ts.lookUp(this.filenameToScript, filename); - if (!scriptInfo) { - scriptInfo = this.project.openReferencedFile(filename); - if (scriptInfo) { - this.filenameToScript[scriptInfo.fileName] = scriptInfo; - } - } - else { - } - return scriptInfo; - }; - LSHost.prototype.addRoot = function (info) { - var scriptInfo = ts.lookUp(this.filenameToScript, info.fileName); - if (!scriptInfo) { - this.filenameToScript[info.fileName] = info; - this.roots.push(info); - } - }; - LSHost.prototype.removeRoot = function (info) { - var scriptInfo = ts.lookUp(this.filenameToScript, info.fileName); - if (scriptInfo) { - this.filenameToScript[info.fileName] = undefined; - this.roots = copyListRemovingItem(info, this.roots); - this.resolvedModuleNames.remove(info.fileName); - } - }; - 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.resolvePath = function (path) { - var start = new Date().getTime(); - var result = this.host.resolvePath(path); - return result; - }; - LSHost.prototype.fileExists = function (path) { - var start = new Date().getTime(); - var result = this.host.fileExists(path); - return result; - }; - LSHost.prototype.directoryExists = function (path) { - return this.host.directoryExists(path); - }; - LSHost.prototype.lineToTextSpan = function (filename, line) { - var script = this.filenameToScript[filename]; - 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 script = this.filenameToScript[filename]; - var index = script.snap().index; - var lineInfo = index.lineNumberToInfo(line); - return (lineInfo.offset + offset - 1); - }; - LSHost.prototype.positionToLineOffset = function (filename, position) { - var script = this.filenameToScript[filename]; - var index = script.snap().index; - var lineOffset = index.charOffsetToLineNumberAndPos(position); - return { line: lineOffset.line, offset: lineOffset.offset + 1 }; - }; - return LSHost; - })(); - server.LSHost = LSHost; - function getAbsolutePath(filename, directory) { - var rootLength = ts.getRootLength(filename); - if (rootLength > 0) { - return filename; - } - else { - var splitFilename = filename.split('/'); - var splitDir = directory.split('/'); - var i = 0; - var dirTail = 0; - var sflen = splitFilename.length; - while ((i < sflen) && (splitFilename[i].charAt(0) == '.')) { - var dots = splitFilename[i]; - if (dots == '..') { - dirTail++; - } - else if (dots != '.') { - return undefined; - } - i++; - } - return splitDir.slice(0, splitDir.length - dirTail).concat(splitFilename.slice(i)).join('/'); - } - } - var Project = (function () { - function Project(projectService, projectOptions) { - this.projectService = projectService; - this.projectOptions = projectOptions; - this.directoriesWatchedForTsconfig = []; - this.filenameToSourceFile = {}; - this.updateGraphSeq = 0; - this.openRefCount = 0; - this.compilerService = new CompilerService(this, projectOptions && projectOptions.compilerOptions); - } - Project.prototype.addOpenRef = function () { - this.openRefCount++; - }; - Project.prototype.deleteOpenRef = function () { - this.openRefCount--; - return this.openRefCount; - }; - Project.prototype.openReferencedFile = function (filename) { - return this.projectService.openFile(filename, false); - }; - Project.prototype.getRootFiles = function () { - return this.compilerService.host.roots.map(function (info) { return info.fileName; }); - }; - Project.prototype.getFileNames = function () { - var sourceFiles = this.program.getSourceFiles(); - return sourceFiles.map(function (sourceFile) { return sourceFile.fileName; }); - }; - Project.prototype.getSourceFile = function (info) { - return this.filenameToSourceFile[info.fileName]; - }; - Project.prototype.getSourceFileFromName = function (filename, requireOpen) { - var info = this.projectService.getScriptInfo(filename); - if (info) { - if ((!requireOpen) || info.isOpen) { - return this.getSourceFile(info); - } - } - }; - Project.prototype.isRoot = function (info) { - return this.compilerService.host.roots.some(function (root) { return root === info; }); - }; - Project.prototype.removeReferencedFile = function (info) { - this.compilerService.host.removeReferencedFile(info); - this.updateGraph(); - }; - Project.prototype.updateFileMap = function () { - this.filenameToSourceFile = {}; - 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 () { - this.updateGraph(); - this.compilerService.languageService.getNavigateToItems(".*"); - }; - Project.prototype.updateGraph = function () { - this.program = this.compilerService.languageService.getProgram(); - this.updateFileMap(); - }; - Project.prototype.isConfiguredProject = function () { - return this.projectFilename; - }; - Project.prototype.addRoot = function (info) { - this.compilerService.host.addRoot(info); - }; - Project.prototype.removeRoot = function (info) { - this.compilerService.host.removeRoot(info); - }; - Project.prototype.filesToString = function () { - var strBuilder = ""; - ts.forEachValue(this.filenameToSourceFile, function (sourceFile) { strBuilder += sourceFile.fileName + "\n"; }); - return strBuilder; - }; - Project.prototype.setProjectOptions = function (projectOptions) { - this.projectOptions = projectOptions; - if (projectOptions.compilerOptions) { - this.compilerService.setCompilerOptions(projectOptions.compilerOptions); - } - }; - return Project; - })(); - server.Project = Project; - function copyListRemovingItem(item, list) { - var copiedList = []; - for (var i = 0, len = list.length; i < len; i++) { - if (list[i] != item) { - copiedList.push(list[i]); - } - } - return copiedList; - } - var ProjectService = (function () { - function ProjectService(host, psLogger, eventHandler) { - this.host = host; - this.psLogger = psLogger; - this.eventHandler = eventHandler; - this.filenameToScriptInfo = {}; - this.openFileRoots = []; - this.inferredProjects = []; - this.configuredProjects = []; - this.openFilesReferenced = []; - this.openFileRootsConfigured = []; - this.directoryWatchersForTsconfig = {}; - this.directoryWatchersRefCount = {}; - this.timerForDetectingProjectFilelistChanges = {}; - this.addDefaultHostConfiguration(); - } - ProjectService.prototype.addDefaultHostConfiguration = function () { - this.hostConfiguration = { - formatCodeOptions: ts.clone(CompilerService.defaultFormatCodeOptions), - hostInfo: "Unknown host" - }; - }; - ProjectService.prototype.getFormatCodeOptions = function (file) { - if (file) { - var info = this.filenameToScriptInfo[file]; - if (info) { - return info.formatCodeOptions; - } - } - return this.hostConfiguration.formatCodeOptions; - }; - ProjectService.prototype.watchedFileChanged = function (fileName) { - var info = this.filenameToScriptInfo[fileName]; - if (!info) { - 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)) { - return; - } - this.log("Detected source file changes: " + fileName); - this.startTimerForDetectingProjectFilelistChanges(project); - }; - ProjectService.prototype.startTimerForDetectingProjectFilelistChanges = function (project) { - var _this = this; - if (this.timerForDetectingProjectFilelistChanges[project.projectFilename]) { - clearTimeout(this.timerForDetectingProjectFilelistChanges[project.projectFilename]); - } - this.timerForDetectingProjectFilelistChanges[project.projectFilename] = setTimeout(function () { return _this.handleProjectFilelistChanges(project); }, 250); - }; - ProjectService.prototype.handleProjectFilelistChanges = function (project) { - var _this = this; - var _a = this.configFileToProjectOptions(project.projectFilename), succeeded = _a.succeeded, projectOptions = _a.projectOptions, error = _a.error; - 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.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), succeeded = _a.succeeded, projectOptions = _a.projectOptions, error = _a.error; - 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; _i < openFileRoots.length; _i++) { - var openFileRoot = openFileRoots[_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); - this.updateConfiguredProject(project); - this.updateProjectStructure(); - }; - 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("context", openFile.defaultProject, openFile.fileName); - } - } - for (var j = 0, flen = this.openFilesReferenced.length; j < flen; j++) { - var openFile = this.openFilesReferenced[j]; - if (this.eventHandler) { - this.eventHandler("context", openFile.defaultProject, 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(); - this.configuredProjects = copyListRemovingItem(project, this.configuredProjects); - } - else { - for (var _i = 0, _a = project.directoriesWatchedForTsconfig; _i < _a.length; _i++) { - var directory = _a[_i]; - if (!(--project.projectService.directoryWatchersRefCount[directory])) { - this.log("Close directory watcher for: " + directory); - project.projectService.directoryWatchersForTsconfig[directory].close(); - delete project.projectService.directoryWatchersForTsconfig[directory]; - } - } - this.inferredProjects = copyListRemovingItem(project, this.inferredProjects); - } - var fileNames = project.getFileNames(); - for (var _b = 0; _b < fileNames.length; _b++) { - var fileName = fileNames[_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) { - 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 { - this.openFilesReferenced = copyListRemovingItem(info, this.openFilesReferenced); - } - 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; - } - } - 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 ts.lookUp(this.filenameToScriptInfo, filename); - }; - ProjectService.prototype.openFile = function (fileName, openedByClient) { - var _this = this; - fileName = ts.normalizePath(fileName); - var info = ts.lookUp(this.filenameToScriptInfo, fileName); - if (!info) { - var content; - if (this.host.fileExists(fileName)) { - content = this.host.readFile(fileName); - } - if (!content) { - if (openedByClient) { - content = ""; - } - } - if (content !== undefined) { - var indentSize; - info = new ScriptInfo(this.host, fileName, content, openedByClient); - info.setFormatOptions(this.getFormatCodeOptions()); - this.filenameToScriptInfo[fileName] = info; - if (!info.isOpen) { - info.fileWatcher = this.host.watchFile(fileName, function (_) { _this.watchedFileChanged(fileName); }); - } - } - } - if (info) { - if (openedByClient) { - info.isOpen = true; - } - } - return info; - }; - ProjectService.prototype.findConfigFile = function (searchPath) { - while (true) { - var fileName = ts.combinePaths(searchPath, "tsconfig.json"); - if (this.host.fileExists(fileName)) { - return fileName; - } - var parentPath = ts.getDirectoryPath(searchPath); - if (parentPath === searchPath) { - break; - } - searchPath = parentPath; - } - return undefined; - }; - ProjectService.prototype.openClientFile = function (fileName) { - this.openOrUpdateConfiguredProjectForFile(fileName); - var info = this.openFile(fileName, true); - this.addOpenFile(info); - this.printProjects(); - return info; - }; - 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.success) { - this.log("Error opening config file " + configFileName + " " + configResult.errorMsg); - } - else { - this.log("Opened configuration file " + configFileName, "Info"); - this.configuredProjects.push(configResult.project); - } - } - else { - this.updateConfiguredProject(project); - } - } - else { - this.log("No config files found."); - } - }; - ProjectService.prototype.closeClientFile = function (filename) { - var info = ts.lookUp(this.filenameToScriptInfo, filename); - if (info) { - this.closeOpenFile(info); - info.isOpen = false; - } - this.printProjects(); - }; - ProjectService.prototype.getProjectForFile = function (filename) { - var scriptInfo = ts.lookUp(this.filenameToScriptInfo, filename); - if (scriptInfo) { - return scriptInfo.defaultProject; - } - }; - ProjectService.prototype.printProjectsForFile = function (filename) { - var scriptInfo = ts.lookUp(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 dirPath = ts.getDirectoryPath(configFilename); - var contents = this.host.readFile(configFilename); - var rawConfig = ts.parseConfigFileTextToJson(configFilename, contents); - if (rawConfig.error) { - return { succeeded: false, error: rawConfig.error }; - } - else { - var parsedCommandLine = ts.parseJsonConfigFileContent(rawConfig.config, this.host, dirPath); - if (parsedCommandLine.errors && (parsedCommandLine.errors.length > 0)) { - return { succeeded: false, error: { errorMsg: "tsconfig option errors" } }; - } - else if (parsedCommandLine.fileNames == null) { - return { succeeded: false, error: { errorMsg: "no files found" } }; - } - else { - var projectOptions = { - files: parsedCommandLine.fileNames, - compilerOptions: parsedCommandLine.options - }; - return { succeeded: true, projectOptions: projectOptions }; - } - } - }; - ProjectService.prototype.openConfigFile = function (configFilename, clientFileName) { - var _this = this; - var _a = this.configFileToProjectOptions(configFilename), succeeded = _a.succeeded, projectOptions = _a.projectOptions, error = _a.error; - if (!succeeded) { - return error; - } - else { - var project = this.createProject(configFilename, projectOptions); - 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, clientFileName == rootFilename); - project.addRoot(info); - } - else { - return { errorMsg: "specified file " + rootFilename + " not found" }; - } - } - project.finishGraph(); - project.projectFileWatcher = this.host.watchFile(configFilename, function (_) { return _this.watchedProjectConfigFileChanged(project); }); - this.log("Add recursive watcher for: " + ts.getDirectoryPath(configFilename)); - project.directoryWatcher = this.host.watchDirectory(ts.getDirectoryPath(configFilename), function (path) { return _this.directoryWatchedForSourceFilesChanged(project, path); }, true); - return { success: true, project: project }; - } - }; - ProjectService.prototype.updateConfiguredProject = function (project) { - if (!this.host.fileExists(project.projectFilename)) { - this.log("Config file deleted"); - this.removeProject(project); - } - else { - var _a = this.configFileToProjectOptions(project.projectFilename), succeeded = _a.succeeded, projectOptions = _a.projectOptions, error = _a.error; - if (!succeeded) { - return error; - } - else { - var oldFileNames = project.compilerService.host.roots.map(function (info) { return info.fileName; }); - var newFileNames = projectOptions.files; - var fileNamesToRemove = oldFileNames.filter(function (f) { return newFileNames.indexOf(f) < 0; }); - var fileNamesToAdd = newFileNames.filter(function (f) { return oldFileNames.indexOf(f) < 0; }); - for (var _i = 0; _i < fileNamesToRemove.length; _i++) { - var fileName = fileNamesToRemove[_i]; - var info = this.getScriptInfo(fileName); - if (info) { - project.removeRoot(info); - } - } - for (var _b = 0; _b < fileNamesToAdd.length; _b++) { - var fileName = fileNamesToAdd[_b]; - var info = this.getScriptInfo(fileName); - if (!info) { - info = this.openFile(fileName, false); - } - else { - if (info.isOpen) { - if (this.openFileRoots.indexOf(info) >= 0) { - this.openFileRoots = copyListRemovingItem(info, this.openFileRoots); - if (info.defaultProject && !info.defaultProject.isConfiguredProject()) { - this.removeProject(info.defaultProject); - } - } - if (this.openFilesReferenced.indexOf(info) >= 0) { - this.openFilesReferenced = copyListRemovingItem(info, this.openFilesReferenced); - } - this.openFileRootsConfigured.push(info); - info.defaultProject = project; - } - } - project.addRoot(info); - } - project.setProjectOptions(projectOptions); - project.finishGraph(); - } - } - }; - ProjectService.prototype.createProject = function (projectFilename, projectOptions) { - var project = new Project(this, projectOptions); - project.projectFilename = projectFilename; - return project; - }; - return ProjectService; - })(); - server.ProjectService = ProjectService; - var CompilerService = (function () { - function CompilerService(project, opt) { - this.project = project; - this.documentRegistry = ts.createDocumentRegistry(); - this.host = new LSHost(project.projectService.host, project); - if (opt) { - this.setCompilerOptions(opt); - } - else { - this.setCompilerOptions(ts.getDefaultCompilerOptions()); - } - 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.getSourceFile(filename); - return ts.isExternalModule(sourceFile); - }; - CompilerService.defaultFormatCodeOptions = { - IndentSize: 4, - TabSize: 4, - NewLineCharacter: ts.sys ? ts.sys.newLine : '\n', - ConvertTabsToSpaces: true, - IndentStyle: ts.IndentStyle.Smart, - InsertSpaceAfterCommaDelimiter: true, - InsertSpaceAfterSemicolonInForStatements: true, - InsertSpaceBeforeAndAfterBinaryOperators: true, - InsertSpaceAfterKeywordsInControlFlowStatements: true, - InsertSpaceAfterFunctionKeywordForAnonymousFunctions: false, - InsertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis: false, - InsertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets: false, - PlaceOpenBraceOnNewLineForFunctions: false, - PlaceOpenBraceOnNewLineForControlBlocks: false - }; - return CompilerService; - })(); - server.CompilerService = CompilerService; - (function (CharRangeSection) { - CharRangeSection[CharRangeSection["PreStart"] = 0] = "PreStart"; - CharRangeSection[CharRangeSection["Start"] = 1] = "Start"; - CharRangeSection[CharRangeSection["Entire"] = 2] = "Entire"; - CharRangeSection[CharRangeSection["Mid"] = 3] = "Mid"; - CharRangeSection[CharRangeSection["End"] = 4] = "End"; - CharRangeSection[CharRangeSection["PostEnd"] = 5] = "PostEnd"; - })(server.CharRangeSection || (server.CharRangeSection = {})); - var CharRangeSection = server.CharRangeSection; - var BaseLineIndexWalker = (function () { - function BaseLineIndexWalker() { - this.goSubtree = true; - this.done = false; - } - BaseLineIndexWalker.prototype.leaf = function (rangeStart, rangeLength, ll) { - }; - return BaseLineIndexWalker; - })(); - 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]; - } - EditWalker.prototype.insertLines = function (insertedText) { - if (this.suppressTrailingText) { - this.trailingText = ""; - } - if (insertedText) { - insertedText = this.initialText + insertedText + this.trailingText; - } - else { - insertedText = this.initialText + this.trailingText; - } - var lm = LineIndex.linesFromText(insertedText); - var lines = lm.lines; - if (lines.length > 1) { - if (lines[lines.length - 1] == "") { - lines.length--; - } - } - var branchParent; - var lastZeroCount; - for (var k = this.endBranch.length - 1; k >= 0; k--) { - this.endBranch[k].updateCounts(); - if (this.endBranch[k].charCount() === 0) { - lastZeroCount = this.endBranch[k]; - if (k > 0) { - branchParent = this.endBranch[k - 1]; - } - else { - branchParent = this.branchNode; - } - } - } - if (lastZeroCount) { - branchParent.remove(lastZeroCount); - } - var insertionNode = this.startPath[this.startPath.length - 2]; - var leafNode = this.startPath[this.startPath.length - 1]; - var len = lines.length; - if (len > 0) { - leafNode.text = lines[0]; - if (len > 1) { - var insertedNodes = new Array(len - 1); - var startNode = leafNode; - for (var i = 1, len = lines.length; i < len; i++) { - insertedNodes[i - 1] = new LineLeaf(lines[i]); - } - var pathIndex = this.startPath.length - 2; - while (pathIndex >= 0) { - insertionNode = this.startPath[pathIndex]; - insertedNodes = insertionNode.insertAt(startNode, insertedNodes); - pathIndex--; - startNode = insertionNode; - } - var insertedNodesLen = insertedNodes.length; - while (insertedNodesLen > 0) { - var newRoot = new LineNode(); - newRoot.add(this.lineIndex.root); - insertedNodes = newRoot.insertAt(this.lineIndex.root, insertedNodes); - insertedNodesLen = insertedNodes.length; - this.lineIndex.root = newRoot; - } - this.lineIndex.root.updateCounts(); - } - else { - for (var j = this.startPath.length - 2; j >= 0; j--) { - this.startPath[j].updateCounts(); - } - } - } - else { - insertionNode.remove(leafNode); - for (var j = this.startPath.length - 2; j >= 0; j--) { - this.startPath[j].updateCounts(); - } - } - return this.lineIndex; - }; - EditWalker.prototype.post = function (relativeStart, relativeLength, lineCollection, parent, nodeType) { - if (lineCollection === this.lineCollectionAtBranch) { - this.state = CharRangeSection.End; - } - this.stack.length--; - return undefined; - }; - EditWalker.prototype.pre = function (relativeStart, relativeLength, lineCollection, parent, nodeType) { - var currentNode = this.stack[this.stack.length - 1]; - if ((this.state === CharRangeSection.Entire) && (nodeType === CharRangeSection.Start)) { - this.state = CharRangeSection.Start; - this.branchNode = currentNode; - this.lineCollectionAtBranch = lineCollection; - } - var child; - function fresh(node) { - if (node.isLeaf()) { - return new LineLeaf(""); - } - else - return new LineNode(); - } - switch (nodeType) { - case CharRangeSection.PreStart: - this.goSubtree = false; - if (this.state !== CharRangeSection.End) { - currentNode.add(lineCollection); - } - break; - case CharRangeSection.Start: - if (this.state === CharRangeSection.End) { - this.goSubtree = false; - } - else { - child = fresh(lineCollection); - currentNode.add(child); - this.startPath[this.startPath.length] = child; - } - break; - case CharRangeSection.Entire: - if (this.state !== CharRangeSection.End) { - child = fresh(lineCollection); - currentNode.add(child); - this.startPath[this.startPath.length] = child; - } - else { - if (!lineCollection.isLeaf()) { - child = fresh(lineCollection); - currentNode.add(child); - this.endBranch[this.endBranch.length] = child; - } - } - break; - case CharRangeSection.Mid: - this.goSubtree = false; - break; - case CharRangeSection.End: - if (this.state !== CharRangeSection.End) { - this.goSubtree = false; - } - else { - if (!lineCollection.isLeaf()) { - child = fresh(lineCollection); - currentNode.add(child); - this.endBranch[this.endBranch.length] = child; - } - } - break; - case CharRangeSection.PostEnd: - this.goSubtree = false; - if (this.state !== CharRangeSection.Start) { - currentNode.add(lineCollection); - } - break; - } - if (this.goSubtree) { - this.stack[this.stack.length] = child; - } - return lineCollection; - }; - EditWalker.prototype.leaf = function (relativeStart, relativeLength, ll) { - if (this.state === CharRangeSection.Start) { - this.initialText = ll.text.substring(0, relativeStart); - } - else if (this.state === CharRangeSection.Entire) { - this.initialText = ll.text.substring(0, relativeStart); - this.trailingText = ll.text.substring(relativeStart + relativeLength); - } - else { - this.trailingText = ll.text.substring(relativeStart + relativeLength); - } - }; - return EditWalker; - })(BaseLineIndexWalker); - var TextChange = (function () { - function TextChange(pos, deleteLen, insertedText) { - this.pos = pos; - this.deleteLen = deleteLen; - this.insertedText = insertedText; - } - TextChange.prototype.getTextChangeRange = function () { - return ts.createTextChangeRange(ts.createTextSpan(this.pos, this.deleteLen), this.insertedText ? this.insertedText.length : 0); - }; - return TextChange; - })(); - server.TextChange = TextChange; - var ScriptVersionCache = (function () { - function ScriptVersionCache() { - this.changes = []; - this.versions = []; - this.minVersion = 0; - this.currentVersion = 0; - } - ScriptVersionCache.prototype.edit = function (pos, deleteLen, insertedText) { - this.changes[this.changes.length] = new TextChange(pos, deleteLen, insertedText); - if ((this.changes.length > ScriptVersionCache.changeNumberThreshold) || - (deleteLen > ScriptVersionCache.changeLengthThreshold) || - (insertedText && (insertedText.length > ScriptVersionCache.changeLengthThreshold))) { - this.getSnapshot(); - } - }; - ScriptVersionCache.prototype.latest = function () { - return this.versions[this.currentVersion]; - }; - ScriptVersionCache.prototype.latestVersion = function () { - if (this.changes.length > 0) { - this.getSnapshot(); - } - return this.currentVersion; - }; - ScriptVersionCache.prototype.reloadFromFile = function (filename, cb) { - var content = this.host.readFile(filename); - 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; - 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]; - if (this.changes.length > 0) { - var snapIndex = this.latest().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); - } - snap = new LineIndexSnapshot(this.currentVersion + 1, this); - snap.index = snapIndex; - snap.changesSincePreviousVersion = this.changes; - this.currentVersion = snap.version; - this.versions[snap.version] = 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; - }; - ScriptVersionCache.prototype.getTextChangesBetweenVersions = function (oldVersion, newVersion) { - if (oldVersion < newVersion) { - if (oldVersion >= this.minVersion) { - var textChangeRanges = []; - for (var i = oldVersion + 1; i <= newVersion; i++) { - var snap = this.versions[i]; - for (var j = 0, len = snap.changesSincePreviousVersion.length; j < len; j++) { - var textChange = snap.changesSincePreviousVersion[j]; - textChangeRanges[textChangeRanges.length] = textChange.getTextChangeRange(); - } - } - return ts.collapseTextChangeRangesAcrossMultipleVersions(textChangeRanges); - } - else { - return undefined; - } - } - else { - return ts.unchangedTextChangeRange; - } - }; - ScriptVersionCache.fromString = function (host, script) { - var svc = new ScriptVersionCache(); - var snap = new LineIndexSnapshot(0, svc); - svc.versions[svc.currentVersion] = snap; - svc.host = host; - snap.index = new LineIndex(); - var lm = LineIndex.linesFromText(script); - snap.index.load(lm.lines); - return svc; - }; - ScriptVersionCache.changeNumberThreshold = 8; - ScriptVersionCache.changeLengthThreshold = 256; - ScriptVersionCache.maxVersions = 8; - return ScriptVersionCache; - })(); - server.ScriptVersionCache = ScriptVersionCache; - var LineIndexSnapshot = (function () { - function LineIndexSnapshot(version, cache) { - this.version = version; - this.cache = cache; - this.changesSincePreviousVersion = []; - } - LineIndexSnapshot.prototype.getText = function (rangeStart, rangeEnd) { - return this.index.getText(rangeStart, rangeEnd - rangeStart); - }; - LineIndexSnapshot.prototype.getLength = function () { - return this.index.root.charCount(); - }; - LineIndexSnapshot.prototype.getLineStartPositions = function () { - var starts = [-1]; - var count = 1; - var pos = 0; - this.index.every(function (ll, s, len) { - starts[count++] = pos; - pos += ll.text.length; - return true; - }, 0); - return starts; - }; - LineIndexSnapshot.prototype.getLineMapper = function () { - var _this = this; - return (function (line) { - return _this.index.lineNumberToInfo(line).offset; - }); - }; - LineIndexSnapshot.prototype.getTextChangeRangeSinceVersion = function (scriptVersion) { - if (this.version <= scriptVersion) { - return ts.unchangedTextChangeRange; - } - else { - return this.cache.getTextChangesBetweenVersions(scriptVersion, this.version); - } - }; - LineIndexSnapshot.prototype.getChangeRange = function (oldSnapshot) { - var oldSnap = oldSnapshot; - return this.getTextChangeRangeSinceVersion(oldSnap.version); - }; - return LineIndexSnapshot; - })(); - server.LineIndexSnapshot = LineIndexSnapshot; - var LineIndex = (function () { - function LineIndex() { - this.checkEdits = false; - } - LineIndex.prototype.charOffsetToLineNumberAndPos = function (charOffset) { - return this.root.charOffsetToLineNumberAndPos(1, charOffset); - }; - LineIndex.prototype.lineNumberToInfo = function (lineNumber) { - var lineCount = this.root.lineCount(); - if (lineNumber <= lineCount) { - var lineInfo = this.root.lineNumberToInfo(lineNumber, 0); - lineInfo.line = lineNumber; - return lineInfo; - } - else { - return { - line: lineNumber, - offset: this.root.charCount() - }; - } - }; - LineIndex.prototype.load = function (lines) { - if (lines.length > 0) { - var leaves = []; - for (var i = 0, len = lines.length; i < len; i++) { - leaves[i] = new LineLeaf(lines[i]); - } - this.root = LineIndex.buildTreeFromBottom(leaves); - } - else { - this.root = new LineNode(); - } - }; - LineIndex.prototype.walk = function (rangeStart, rangeLength, walkFns) { - this.root.walk(rangeStart, rangeLength, walkFns); - }; - LineIndex.prototype.getText = function (rangeStart, rangeLength) { - var accum = ""; - if ((rangeLength > 0) && (rangeStart < this.root.charCount())) { - this.walk(rangeStart, rangeLength, { - goSubtree: true, - done: false, - leaf: function (relativeStart, relativeLength, ll) { - accum = accum.concat(ll.text.substring(relativeStart, relativeStart + relativeLength)); - } - }); - } - return accum; - }; - LineIndex.prototype.getLength = function () { - return this.root.charCount(); - }; - LineIndex.prototype.every = function (f, rangeStart, rangeEnd) { - if (!rangeEnd) { - rangeEnd = this.root.charCount(); - } - var walkFns = { - goSubtree: true, - done: false, - leaf: function (relativeStart, relativeLength, ll) { - if (!f(ll, relativeStart, relativeLength)) { - this.done = true; - } - } - }; - this.walk(rangeStart, rangeEnd - rangeStart, walkFns); - return !walkFns.done; - }; - LineIndex.prototype.edit = function (pos, deleteLength, newText) { - function editFlat(source, s, dl, nt) { - if (nt === void 0) { nt = ""; } - return source.substring(0, s) + nt + source.substring(s + dl, source.length); - } - if (this.root.charCount() === 0) { - if (newText) { - this.load(LineIndex.linesFromText(newText).lines); - return this; - } - } - else { - if (this.checkEdits) { - var checkText = editFlat(this.getText(0, this.root.charCount()), pos, deleteLength, newText); - } - var walker = new EditWalker(); - if (pos >= this.root.charCount()) { - pos = this.root.charCount() - 1; - var endString = this.getText(pos, 1); - if (newText) { - newText = endString + newText; - } - else { - newText = endString; - } - deleteLength = 0; - walker.suppressTrailingText = true; - } - else if (deleteLength > 0) { - var e = pos + deleteLength; - var lineInfo = this.charOffsetToLineNumberAndPos(e); - if ((lineInfo && (lineInfo.offset === 0))) { - deleteLength += lineInfo.text.length; - if (newText) { - newText = newText + lineInfo.text; - } - else { - newText = lineInfo.text; - } - } - } - if (pos < this.root.charCount()) { - this.root.walk(pos, deleteLength, walker); - walker.insertLines(newText); - } - if (this.checkEdits) { - var updatedText = this.getText(0, this.root.charCount()); - ts.Debug.assert(checkText == updatedText, "buffer edit mismatch"); - } - return walker.lineIndex; - } - }; - LineIndex.buildTreeFromBottom = function (nodes) { - var nodeCount = Math.ceil(nodes.length / lineCollectionCapacity); - var interiorNodes = []; - var nodeIndex = 0; - for (var i = 0; i < nodeCount; i++) { - interiorNodes[i] = new LineNode(); - var charCount = 0; - var lineCount = 0; - for (var j = 0; j < lineCollectionCapacity; j++) { - if (nodeIndex < nodes.length) { - interiorNodes[i].add(nodes[nodeIndex]); - charCount += nodes[nodeIndex].charCount(); - lineCount += nodes[nodeIndex].lineCount(); - } - else { - break; - } - nodeIndex++; - } - interiorNodes[i].totalChars = charCount; - interiorNodes[i].totalLines = lineCount; - } - if (interiorNodes.length === 1) { - return interiorNodes[0]; - } - else { - return this.buildTreeFromBottom(interiorNodes); - } - }; - LineIndex.linesFromText = function (text) { - var lineStarts = ts.computeLineStarts(text); - if (lineStarts.length === 0) { - return { lines: [], lineMap: lineStarts }; - } - var lines = new Array(lineStarts.length); - var lc = lineStarts.length - 1; - for (var lmi = 0; lmi < lc; lmi++) { - lines[lmi] = text.substring(lineStarts[lmi], lineStarts[lmi + 1]); - } - var endText = text.substring(lineStarts[lc]); - if (endText.length > 0) { - lines[lc] = endText; - } - else { - lines.length--; - } - return { lines: lines, lineMap: lineStarts }; - }; - return LineIndex; - })(); - server.LineIndex = LineIndex; - var LineNode = (function () { - function LineNode() { - this.totalChars = 0; - this.totalLines = 0; - this.children = []; - } - LineNode.prototype.isLeaf = function () { - return false; - }; - LineNode.prototype.updateCounts = function () { - this.totalChars = 0; - this.totalLines = 0; - for (var i = 0, len = this.children.length; i < len; i++) { - var child = this.children[i]; - this.totalChars += child.charCount(); - this.totalLines += child.lineCount(); - } - }; - LineNode.prototype.execWalk = function (rangeStart, rangeLength, walkFns, childIndex, nodeType) { - if (walkFns.pre) { - walkFns.pre(rangeStart, rangeLength, this.children[childIndex], this, nodeType); - } - if (walkFns.goSubtree) { - this.children[childIndex].walk(rangeStart, rangeLength, walkFns); - if (walkFns.post) { - walkFns.post(rangeStart, rangeLength, this.children[childIndex], this, nodeType); - } - } - else { - walkFns.goSubtree = true; - } - return walkFns.done; - }; - LineNode.prototype.skipChild = function (relativeStart, relativeLength, childIndex, walkFns, nodeType) { - if (walkFns.pre && (!walkFns.done)) { - walkFns.pre(relativeStart, relativeLength, this.children[childIndex], this, nodeType); - walkFns.goSubtree = true; - } - }; - LineNode.prototype.walk = function (rangeStart, rangeLength, walkFns) { - var childIndex = 0; - var child = this.children[0]; - var childCharCount = child.charCount(); - var adjustedStart = rangeStart; - while (adjustedStart >= childCharCount) { - this.skipChild(adjustedStart, rangeLength, childIndex, walkFns, CharRangeSection.PreStart); - adjustedStart -= childCharCount; - child = this.children[++childIndex]; - childCharCount = child.charCount(); - } - if ((adjustedStart + rangeLength) <= childCharCount) { - if (this.execWalk(adjustedStart, rangeLength, walkFns, childIndex, CharRangeSection.Entire)) { - return; - } - } - else { - if (this.execWalk(adjustedStart, childCharCount - adjustedStart, walkFns, childIndex, CharRangeSection.Start)) { - return; - } - var adjustedLength = rangeLength - (childCharCount - adjustedStart); - child = this.children[++childIndex]; - childCharCount = child.charCount(); - while (adjustedLength > childCharCount) { - if (this.execWalk(0, childCharCount, walkFns, childIndex, CharRangeSection.Mid)) { - return; - } - adjustedLength -= childCharCount; - child = this.children[++childIndex]; - childCharCount = child.charCount(); - } - if (adjustedLength > 0) { - if (this.execWalk(0, adjustedLength, walkFns, childIndex, CharRangeSection.End)) { - return; - } - } - } - if (walkFns.pre) { - var clen = this.children.length; - if (childIndex < (clen - 1)) { - for (var ej = childIndex + 1; ej < clen; ej++) { - this.skipChild(0, 0, ej, walkFns, CharRangeSection.PostEnd); - } - } - } - }; - LineNode.prototype.charOffsetToLineNumberAndPos = function (lineNumber, charOffset) { - var childInfo = this.childFromCharOffset(lineNumber, charOffset); - if (!childInfo.child) { - return { - line: lineNumber, - offset: charOffset - }; - } - else if (childInfo.childIndex < this.children.length) { - if (childInfo.child.isLeaf()) { - return { - line: childInfo.lineNumber, - offset: childInfo.charOffset, - text: (childInfo.child).text, - leaf: (childInfo.child) - }; - } - else { - var lineNode = (childInfo.child); - return lineNode.charOffsetToLineNumberAndPos(childInfo.lineNumber, childInfo.charOffset); - } - } - else { - var lineInfo = this.lineNumberToInfo(this.lineCount(), 0); - return { line: this.lineCount(), offset: lineInfo.leaf.charCount() }; - } - }; - LineNode.prototype.lineNumberToInfo = function (lineNumber, charOffset) { - var childInfo = this.childFromLineNumber(lineNumber, charOffset); - if (!childInfo.child) { - return { - line: lineNumber, - offset: charOffset - }; - } - else if (childInfo.child.isLeaf()) { - return { - line: lineNumber, - offset: childInfo.charOffset, - text: (childInfo.child).text, - leaf: (childInfo.child) - }; - } - else { - var lineNode = (childInfo.child); - return lineNode.lineNumberToInfo(childInfo.relativeLineNumber, childInfo.charOffset); - } - }; - LineNode.prototype.childFromLineNumber = function (lineNumber, charOffset) { - var child; - var relativeLineNumber = lineNumber; - for (var i = 0, len = this.children.length; i < len; i++) { - child = this.children[i]; - var childLineCount = child.lineCount(); - if (childLineCount >= relativeLineNumber) { - break; - } - else { - relativeLineNumber -= childLineCount; - charOffset += child.charCount(); - } - } - return { - child: child, - childIndex: i, - relativeLineNumber: relativeLineNumber, - charOffset: charOffset - }; - }; - LineNode.prototype.childFromCharOffset = function (lineNumber, charOffset) { - var child; - for (var i = 0, len = this.children.length; i < len; i++) { - child = this.children[i]; - if (child.charCount() > charOffset) { - break; - } - else { - charOffset -= child.charCount(); - lineNumber += child.lineCount(); - } - } - return { - child: child, - childIndex: i, - charOffset: charOffset, - lineNumber: lineNumber - }; - }; - LineNode.prototype.splitAfter = function (childIndex) { - var splitNode; - var clen = this.children.length; - childIndex++; - var endLength = childIndex; - if (childIndex < clen) { - splitNode = new LineNode(); - while (childIndex < clen) { - splitNode.add(this.children[childIndex++]); - } - splitNode.updateCounts(); - } - this.children.length = endLength; - return splitNode; - }; - LineNode.prototype.remove = function (child) { - var childIndex = this.findChildIndex(child); - var clen = this.children.length; - if (childIndex < (clen - 1)) { - for (var i = childIndex; i < (clen - 1); i++) { - this.children[i] = this.children[i + 1]; - } - } - this.children.length--; - }; - LineNode.prototype.findChildIndex = function (child) { - var childIndex = 0; - var clen = this.children.length; - while ((this.children[childIndex] !== child) && (childIndex < clen)) - childIndex++; - return childIndex; - }; - LineNode.prototype.insertAt = function (child, nodes) { - var childIndex = this.findChildIndex(child); - var clen = this.children.length; - var nodeCount = nodes.length; - if ((clen < lineCollectionCapacity) && (childIndex === (clen - 1)) && (nodeCount === 1)) { - this.add(nodes[0]); - this.updateCounts(); - return []; - } - else { - var shiftNode = this.splitAfter(childIndex); - var nodeIndex = 0; - childIndex++; - while ((childIndex < lineCollectionCapacity) && (nodeIndex < nodeCount)) { - this.children[childIndex++] = nodes[nodeIndex++]; - } - var splitNodes = []; - var splitNodeCount = 0; - if (nodeIndex < nodeCount) { - splitNodeCount = Math.ceil((nodeCount - nodeIndex) / lineCollectionCapacity); - splitNodes = new Array(splitNodeCount); - var splitNodeIndex = 0; - for (var i = 0; i < splitNodeCount; i++) { - splitNodes[i] = new LineNode(); - } - var splitNode = splitNodes[0]; - while (nodeIndex < nodeCount) { - splitNode.add(nodes[nodeIndex++]); - if (splitNode.children.length === lineCollectionCapacity) { - splitNodeIndex++; - splitNode = splitNodes[splitNodeIndex]; - } - } - for (i = splitNodes.length - 1; i >= 0; i--) { - if (splitNodes[i].children.length === 0) { - splitNodes.length--; - } - } - } - if (shiftNode) { - splitNodes[splitNodes.length] = shiftNode; - } - this.updateCounts(); - for (i = 0; i < splitNodeCount; i++) { - splitNodes[i].updateCounts(); - } - return splitNodes; - } - }; - LineNode.prototype.add = function (collection) { - this.children[this.children.length] = collection; - return (this.children.length < lineCollectionCapacity); - }; - LineNode.prototype.charCount = function () { - return this.totalChars; - }; - LineNode.prototype.lineCount = function () { - return this.totalLines; - }; - return LineNode; - })(); - server.LineNode = LineNode; - var LineLeaf = (function () { - 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; - }; - LineLeaf.prototype.walk = function (rangeStart, rangeLength, walkFns) { - walkFns.leaf(rangeStart, rangeLength, this); - }; - LineLeaf.prototype.charCount = function () { - return this.text.length; - }; - LineLeaf.prototype.lineCount = function () { - return 1; - }; - return LineLeaf; - })(); - server.LineLeaf = LineLeaf; - })(server = ts.server || (ts.server = {})); -})(ts || (ts = {})); -var ts; -(function (ts) { - var server; - (function (server) { - var nodeproto = require('_debugger'); - var readline = require('readline'); - var path = require('path'); - var fs = require('fs'); - var rl = readline.createInterface({ - input: process.stdin, - output: process.stdout, - terminal: false - }); - var Logger = (function () { - function Logger(logFilename, level) { - this.logFilename = logFilename; - this.level = level; - this.fd = -1; - this.seq = 0; - this.inGroup = false; - this.firstInGroup = true; - } - Logger.padStringRight = function (str, padding) { - return (str + padding).slice(0, padding.length); - }; - Logger.prototype.close = function () { - if (this.fd >= 0) { - fs.close(this.fd); - } - }; - Logger.prototype.perftrc = function (s) { - this.msg(s, "Perf"); - }; - Logger.prototype.info = function (s) { - this.msg(s, "Info"); - }; - Logger.prototype.startGroup = function () { - this.inGroup = true; - this.firstInGroup = true; - }; - Logger.prototype.endGroup = function () { - this.inGroup = false; - this.seq++; - this.firstInGroup = true; - }; - Logger.prototype.loggingEnabled = function () { - return !!this.logFilename; - }; - Logger.prototype.isVerbose = function () { - return this.loggingEnabled() && (this.level == "verbose"); - }; - Logger.prototype.msg = function (s, type) { - if (type === void 0) { type = "Err"; } - if (this.fd < 0) { - if (this.logFilename) { - this.fd = fs.openSync(this.logFilename, "w"); - } - } - if (this.fd >= 0) { - s = s + "\n"; - var prefix = Logger.padStringRight(type + " " + this.seq.toString(), " "); - if (this.firstInGroup) { - s = prefix + s; - this.firstInGroup = false; - } - if (!this.inGroup) { - this.seq++; - this.firstInGroup = true; - } - var buf = new Buffer(s); - fs.writeSync(this.fd, buf, 0, buf.length, null); - } - }; - return Logger; - })(); - var IOSession = (function (_super) { - __extends(IOSession, _super); - function IOSession(host, logger) { - _super.call(this, host, Buffer.byteLength, process.hrtime, logger); - } - IOSession.prototype.exit = function () { - this.projectService.log("Exiting...", "Info"); - this.projectService.closeLog(); - process.exit(0); - }; - IOSession.prototype.listen = function () { - var _this = this; - rl.on('line', function (input) { - var message = input.trim(); - _this.onMessage(message); - }); - rl.on('close', function () { - _this.exit(); - }); - }; - return IOSession; - })(server.Session); - function parseLoggingEnvironmentString(logEnvStr) { - var logEnv = {}; - var args = logEnvStr.split(' '); - for (var i = 0, len = args.length; i < (len - 1); i += 2) { - var option = args[i]; - var value = args[i + 1]; - if (option && value) { - switch (option) { - case "-file": - logEnv.file = value; - break; - case "-level": - logEnv.detailLevel = value; - break; - } - } - } - return logEnv; - } - function createLoggerFromEnv() { - var fileName = undefined; - var detailLevel = "normal"; - 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.detailLevel) { - detailLevel = logEnv.detailLevel; - } - } - return new Logger(fileName, detailLevel); - } - var logger = createLoggerFromEnv(); - var ioSession = new IOSession(ts.sys, logger); - process.on('uncaughtException', function (err) { - ioSession.logError(err, "unknown"); - }); - ioSession.listen(); - })(server = ts.server || (ts.server = {})); -})(ts || (ts = {})); -var debugObjectHost = 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; - this.lineStartPositions = null; - } - 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.lookUp(resolutionsInFile, name); - return result ? { resolvedFileName: result } : undefined; - }); - }; - } - } - 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.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 null; - } - return JSON.parse(settingsJson); - }; - LanguageServiceShimHostAdapter.prototype.getScriptFileNames = function () { - var encoded = this.shimHost.getScriptFileNames(); - return this.files = JSON.parse(encoded); - }; - LanguageServiceShimHostAdapter.prototype.getScriptSnapshot = function (fileName) { - if (this.files && this.files.indexOf(fileName) < 0) { - return undefined; - } - var scriptSnapshot = this.shimHost.getScriptSnapshot(fileName); - return scriptSnapshot && new ScriptSnapshotShimAdapter(scriptSnapshot); - }; - 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.getDefaultLibFileName = function (options) { - try { - return this.shimHost.getDefaultLibFileName(JSON.stringify(options)); - } - catch (e) { - return ""; - } - }; - return LanguageServiceShimHostAdapter; - })(); - ts.LanguageServiceShimHostAdapter = LanguageServiceShimHostAdapter; - var ThrottledCancellationToken = (function () { - function ThrottledCancellationToken(hostCancellationToken) { - this.hostCancellationToken = hostCancellationToken; - this.lastCancellationCheckTime = 0; - } - ThrottledCancellationToken.prototype.isCancellationRequested = function () { - var time = Date.now(); - 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) { - this.shimHost = shimHost; - } - CoreServicesShimHostAdapter.prototype.readDirectory = function (rootDir, extension, exclude) { - var encoded; - try { - encoded = this.shimHost.readDirectory(rootDir, extension, JSON.stringify(exclude)); - } - catch (e) { - encoded = this.shimHost.readDirectory(rootDir, extension); - } - return JSON.parse(encoded); - }; - CoreServicesShimHostAdapter.prototype.fileExists = function (fileName) { - return this.shimHost.fileExists(fileName); - }; - CoreServicesShimHostAdapter.prototype.readFile = function (fileName) { - return this.shimHost.readFile(fileName); - }; - return CoreServicesShimHostAdapter; - })(); - ts.CoreServicesShimHostAdapter = CoreServicesShimHostAdapter; - function simpleForwardCall(logger, actionDescription, action, logPerformance) { - if (logPerformance) { - logger.log(actionDescription); - var start = Date.now(); - } - var result = action(); - if (logPerformance) { - var end = Date.now(); - 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) { - try { - var result = simpleForwardCall(logger, actionDescription, action, logPerformance); - return JSON.stringify({ 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) { - _super.call(this, factory); - this.host = host; - this.languageService = languageService; - this.logPerformance = false; - this.logger = this.host; - } - 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 () { - var classifications = _this.languageService.getSyntacticClassifications(fileName, ts.createTextSpan(start, length)); - return classifications; - }); - }; - LanguageServiceShimObject.prototype.getSemanticClassifications = function (fileName, start, length) { - var _this = this; - return this.forwardJSONCall("getSemanticClassifications('" + fileName + "', " + start + ", " + length + ")", function () { - var classifications = _this.languageService.getSemanticClassifications(fileName, ts.createTextSpan(start, length)); - return classifications; - }); - }; - 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 () { - var quickInfo = _this.languageService.getQuickInfoAtPosition(fileName, position); - return quickInfo; - }); - }; - LanguageServiceShimObject.prototype.getNameOrDottedNameSpan = function (fileName, startPos, endPos) { - var _this = this; - return this.forwardJSONCall("getNameOrDottedNameSpan('" + fileName + "', " + startPos + ", " + endPos + ")", function () { - var spanInfo = _this.languageService.getNameOrDottedNameSpan(fileName, startPos, endPos); - return spanInfo; - }); - }; - LanguageServiceShimObject.prototype.getBreakpointStatementAtPosition = function (fileName, position) { - var _this = this; - return this.forwardJSONCall("getBreakpointStatementAtPosition('" + fileName + "', " + position + ")", function () { - var spanInfo = _this.languageService.getBreakpointStatementAtPosition(fileName, position); - return spanInfo; - }); - }; - LanguageServiceShimObject.prototype.getSignatureHelpItems = function (fileName, position) { - var _this = this; - return this.forwardJSONCall("getSignatureHelpItems('" + fileName + "', " + position + ")", function () { - var signatureInfo = _this.languageService.getSignatureHelpItems(fileName, position); - return signatureInfo; - }); - }; - 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.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 () { - var textRanges = _this.languageService.getBraceMatchingAtPosition(fileName, position); - return textRanges; - }); - }; - 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 () { - var completion = _this.languageService.getCompletionsAtPosition(fileName, position); - return completion; - }); - }; - LanguageServiceShimObject.prototype.getCompletionEntryDetails = function (fileName, position, entryName) { - var _this = this; - return this.forwardJSONCall("getCompletionEntryDetails('" + fileName + "', " + position + ", " + entryName + ")", function () { - var details = _this.languageService.getCompletionEntryDetails(fileName, position, entryName); - return details; - }); - }; - LanguageServiceShimObject.prototype.getFormattingEditsForRange = function (fileName, start, end, options) { - var _this = this; - return this.forwardJSONCall("getFormattingEditsForRange('" + fileName + "', " + start + ", " + end + ")", function () { - var localOptions = JSON.parse(options); - var edits = _this.languageService.getFormattingEditsForRange(fileName, start, end, localOptions); - return edits; - }); - }; - LanguageServiceShimObject.prototype.getFormattingEditsForDocument = function (fileName, options) { - var _this = this; - return this.forwardJSONCall("getFormattingEditsForDocument('" + fileName + "')", function () { - var localOptions = JSON.parse(options); - var edits = _this.languageService.getFormattingEditsForDocument(fileName, localOptions); - return edits; - }); - }; - LanguageServiceShimObject.prototype.getFormattingEditsAfterKeystroke = function (fileName, position, key, options) { - var _this = this; - return this.forwardJSONCall("getFormattingEditsAfterKeystroke('" + fileName + "', " + position + ", '" + key + "')", function () { - var localOptions = JSON.parse(options); - var edits = _this.languageService.getFormattingEditsAfterKeystroke(fileName, position, key, localOptions); - return edits; - }); - }; - 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) { - var _this = this; - return this.forwardJSONCall("getNavigateToItems('" + searchValue + "', " + maxResultCount + ")", function () { - var items = _this.languageService.getNavigateToItems(searchValue, maxResultCount); - return items; - }); - }; - LanguageServiceShimObject.prototype.getNavigationBarItems = function (fileName) { - var _this = this; - return this.forwardJSONCall("getNavigationBarItems('" + fileName + "')", function () { - var items = _this.languageService.getNavigationBarItems(fileName); - return items; - }); - }; - LanguageServiceShimObject.prototype.getOutliningSpans = function (fileName) { - var _this = this; - return this.forwardJSONCall("getOutliningSpans('" + fileName + "')", function () { - var items = _this.languageService.getOutliningSpans(fileName); - return items; - }); - }; - LanguageServiceShimObject.prototype.getTodoComments = function (fileName, descriptors) { - var _this = this; - return this.forwardJSONCall("getTodoComments('" + fileName + "')", function () { - var items = _this.languageService.getTodoComments(fileName, JSON.parse(descriptors)); - return items; - }); - }; - LanguageServiceShimObject.prototype.getEmitOutput = function (fileName) { - var _this = this; - return this.forwardJSONCall("getEmitOutput('" + fileName + "')", function () { - var output = _this.languageService.getEmitOutput(fileName); - output.emitOutputStatus = output.emitSkipped ? 1 : 0; - return output; - }); - }; - 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) { - _super.call(this, factory); - this.logger = logger; - this.logPerformance = false; - this.classifier = ts.createClassifier(); - } - 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 items = classification.entries; - var result = ""; - for (var i = 0; i < items.length; i++) { - result += items[i].length + "\n"; - result += items[i].classification + "\n"; - } - result += classification.finalLexState; - return result; - }; - return ClassifierShimObject; - })(ShimBase); - 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; - } - 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.getPreProcessedFileInfo = function (fileName, sourceTextSnapshot) { - return this.forwardJSONCall("getPreProcessedFileInfo('" + fileName + "')", function () { - var result = ts.preProcessFile(sourceTextSnapshot.getText(0, sourceTextSnapshot.getLength())); - var convertResult = { - referencedFiles: [], - importedFiles: [], - ambientExternalModules: result.ambientExternalModules, - isLibFile: result.isLibFile - }; - ts.forEach(result.referencedFiles, function (refFile) { - convertResult.referencedFiles.push({ - path: ts.normalizePath(refFile.fileName), - position: refFile.pos, - length: refFile.end - refFile.pos - }); - }); - ts.forEach(result.importedFiles, function (importedFile) { - convertResult.importedFiles.push({ - path: ts.normalizeSlashes(importedFile.fileName), - position: importedFile.pos, - length: importedFile.end - importedFile.pos - }); - }); - return convertResult; - }); - }; - 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: {}, - files: [], - errors: [realizeDiagnostic(result.error, '\r\n')] - }; - } - var configFile = ts.parseJsonConfigFileContent(result.config, _this.host, ts.getDirectoryPath(ts.normalizeSlashes(fileName))); - return { - options: configFile.options, - files: configFile.fileNames, - errors: realizeDiagnostics(configFile.errors, '\r\n') - }; - }); - }; - CoreServicesShimObject.prototype.getDefaultCompilationSettings = function () { - return this.forwardJSONCall("getDefaultCompilationSettings()", function () { - return ts.getDefaultCompilerOptions(); - }); - }; - 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()); - } - 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 = ts.createDocumentRegistry(); - }; - 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 = "1.6"; +var ts; +(function (ts) { + var OperationCanceledException = (function () { + function OperationCanceledException() { + } + return OperationCanceledException; + })(); + ts.OperationCanceledException = OperationCanceledException; + (function (ExitStatus) { + ExitStatus[ExitStatus["Success"] = 0] = "Success"; + ExitStatus[ExitStatus["DiagnosticsPresent_OutputsSkipped"] = 1] = "DiagnosticsPresent_OutputsSkipped"; + ExitStatus[ExitStatus["DiagnosticsPresent_OutputsGenerated"] = 2] = "DiagnosticsPresent_OutputsGenerated"; + })(ts.ExitStatus || (ts.ExitStatus = {})); + var ExitStatus = ts.ExitStatus; + (function (TypeReferenceSerializationKind) { + TypeReferenceSerializationKind[TypeReferenceSerializationKind["Unknown"] = 0] = "Unknown"; + TypeReferenceSerializationKind[TypeReferenceSerializationKind["TypeWithConstructSignatureAndValue"] = 1] = "TypeWithConstructSignatureAndValue"; + TypeReferenceSerializationKind[TypeReferenceSerializationKind["VoidType"] = 2] = "VoidType"; + TypeReferenceSerializationKind[TypeReferenceSerializationKind["NumberLikeType"] = 3] = "NumberLikeType"; + TypeReferenceSerializationKind[TypeReferenceSerializationKind["StringLikeType"] = 4] = "StringLikeType"; + TypeReferenceSerializationKind[TypeReferenceSerializationKind["BooleanType"] = 5] = "BooleanType"; + TypeReferenceSerializationKind[TypeReferenceSerializationKind["ArrayLikeType"] = 6] = "ArrayLikeType"; + TypeReferenceSerializationKind[TypeReferenceSerializationKind["ESSymbolType"] = 7] = "ESSymbolType"; + TypeReferenceSerializationKind[TypeReferenceSerializationKind["TypeWithCallSignature"] = 8] = "TypeWithCallSignature"; + TypeReferenceSerializationKind[TypeReferenceSerializationKind["ObjectType"] = 9] = "ObjectType"; + })(ts.TypeReferenceSerializationKind || (ts.TypeReferenceSerializationKind = {})); + var TypeReferenceSerializationKind = ts.TypeReferenceSerializationKind; + (function (DiagnosticCategory) { + DiagnosticCategory[DiagnosticCategory["Warning"] = 0] = "Warning"; + DiagnosticCategory[DiagnosticCategory["Error"] = 1] = "Error"; + DiagnosticCategory[DiagnosticCategory["Message"] = 2] = "Message"; + })(ts.DiagnosticCategory || (ts.DiagnosticCategory = {})); + var DiagnosticCategory = ts.DiagnosticCategory; +})(ts || (ts = {})); +var ts; +(function (ts) { + function createFileMap(getCanonicalFileName) { + var files = {}; + return { + get: get, + set: set, + contains: contains, + remove: remove, + clear: clear, + forEachValue: forEachValueInMap + }; + function set(fileName, value) { + files[normalizeKey(fileName)] = value; + } + function get(fileName) { + return files[normalizeKey(fileName)]; + } + function contains(fileName) { + return hasProperty(files, normalizeKey(fileName)); + } + function remove(fileName) { + var key = normalizeKey(fileName); + delete files[key]; + } + function forEachValueInMap(f) { + forEachValue(files, f); + } + function normalizeKey(key) { + return getCanonicalFileName(normalizeSlashes(key)); + } + function clear() { + files = {}; + } + } + ts.createFileMap = createFileMap; + function forEach(array, callback) { + if (array) { + for (var i = 0, len = array.length; i < len; i++) { + var result = callback(array[i], i); + if (result) { + return result; + } + } + } + return undefined; + } + ts.forEach = forEach; + function contains(array, value) { + if (array) { + for (var _i = 0; _i < array.length; _i++) { + var v = array[_i]; + if (v === value) { + return true; + } + } + } + return false; + } + ts.contains = contains; + function indexOf(array, value) { + if (array) { + for (var i = 0, len = array.length; i < len; i++) { + if (array[i] === value) { + return i; + } + } + } + return -1; + } + ts.indexOf = indexOf; + function countWhere(array, predicate) { + var count = 0; + if (array) { + for (var _i = 0; _i < array.length; _i++) { + var v = array[_i]; + if (predicate(v)) { + count++; + } + } + } + return count; + } + ts.countWhere = countWhere; + function filter(array, f) { + var result; + if (array) { + result = []; + for (var _i = 0; _i < array.length; _i++) { + var item = array[_i]; + if (f(item)) { + result.push(item); + } + } + } + return result; + } + ts.filter = filter; + function map(array, f) { + var result; + if (array) { + result = []; + for (var _i = 0; _i < array.length; _i++) { + var v = array[_i]; + result.push(f(v)); + } + } + return result; + } + ts.map = map; + function concatenate(array1, array2) { + if (!array2 || !array2.length) + return array1; + if (!array1 || !array1.length) + return array2; + return array1.concat(array2); + } + ts.concatenate = concatenate; + function deduplicate(array) { + var result; + if (array) { + result = []; + for (var _i = 0; _i < array.length; _i++) { + var item = array[_i]; + if (!contains(result, item)) { + result.push(item); + } + } + } + return result; + } + ts.deduplicate = deduplicate; + function sum(array, prop) { + var result = 0; + for (var _i = 0; _i < array.length; _i++) { + var v = array[_i]; + result += v[prop]; + } + return result; + } + ts.sum = sum; + function addRange(to, from) { + if (to && from) { + for (var _i = 0; _i < from.length; _i++) { + var v = from[_i]; + to.push(v); + } + } + } + ts.addRange = addRange; + function rangeEquals(array1, array2, pos, end) { + while (pos < end) { + if (array1[pos] !== array2[pos]) { + return false; + } + pos++; + } + return true; + } + ts.rangeEquals = rangeEquals; + function lastOrUndefined(array) { + if (array.length === 0) { + return undefined; + } + return array[array.length - 1]; + } + ts.lastOrUndefined = lastOrUndefined; + function binarySearch(array, value) { + var low = 0; + var high = array.length - 1; + while (low <= high) { + var middle = low + ((high - low) >> 1); + var midValue = array[middle]; + if (midValue === value) { + return middle; + } + else if (midValue > value) { + high = middle - 1; + } + else { + low = middle + 1; + } + } + return ~low; + } + ts.binarySearch = binarySearch; + function reduceLeft(array, f, initial) { + if (array) { + var count = array.length; + if (count > 0) { + var pos = 0; + var result = arguments.length <= 2 ? array[pos++] : initial; + while (pos < count) { + result = f(result, array[pos++]); + } + return result; + } + } + return initial; + } + ts.reduceLeft = reduceLeft; + function reduceRight(array, f, initial) { + if (array) { + var pos = array.length - 1; + if (pos >= 0) { + var result = arguments.length <= 2 ? array[pos--] : initial; + while (pos >= 0) { + result = f(result, array[pos--]); + } + return result; + } + } + return initial; + } + ts.reduceRight = reduceRight; + var hasOwnProperty = Object.prototype.hasOwnProperty; + function hasProperty(map, key) { + return hasOwnProperty.call(map, key); + } + ts.hasProperty = hasProperty; + function getProperty(map, key) { + return hasOwnProperty.call(map, key) ? map[key] : undefined; + } + ts.getProperty = getProperty; + function isEmpty(map) { + for (var id in map) { + if (hasProperty(map, id)) { + return false; + } + } + return true; + } + ts.isEmpty = isEmpty; + function clone(object) { + var result = {}; + for (var id in object) { + result[id] = object[id]; + } + return result; + } + ts.clone = clone; + function extend(first, second) { + var result = {}; + for (var id in first) { + result[id] = first[id]; + } + for (var id in second) { + if (!hasProperty(result, id)) { + result[id] = second[id]; + } + } + return result; + } + ts.extend = extend; + function forEachValue(map, callback) { + var result; + for (var id in map) { + if (result = callback(map[id])) + break; + } + return result; + } + ts.forEachValue = forEachValue; + function forEachKey(map, callback) { + var result; + for (var id in map) { + if (result = callback(id)) + break; + } + return result; + } + ts.forEachKey = forEachKey; + function lookUp(map, key) { + return hasProperty(map, key) ? map[key] : undefined; + } + ts.lookUp = lookUp; + function copyMap(source, target) { + for (var p in source) { + target[p] = source[p]; + } + } + ts.copyMap = copyMap; + function arrayToMap(array, makeKey) { + var result = {}; + forEach(array, function (value) { + result[makeKey(value)] = value; + }); + return result; + } + ts.arrayToMap = arrayToMap; + function memoize(callback) { + var value; + return function () { + if (callback) { + value = callback(); + callback = undefined; + } + return value; + }; + } + ts.memoize = memoize; + function formatStringFromArgs(text, args, baseIndex) { + baseIndex = baseIndex || 0; + return text.replace(/{(\d+)}/g, function (match, index) { return args[+index + baseIndex]; }); + } + ts.localizedDiagnosticMessages = undefined; + function getLocaleSpecificMessage(message) { + return ts.localizedDiagnosticMessages && ts.localizedDiagnosticMessages[message.key] + ? ts.localizedDiagnosticMessages[message.key] + : message.message; + } + ts.getLocaleSpecificMessage = getLocaleSpecificMessage; + function createFileDiagnostic(file, start, length, message) { + var end = start + length; + Debug.assert(start >= 0, "start must be non-negative, is " + start); + Debug.assert(length >= 0, "length must be non-negative, is " + length); + if (file) { + Debug.assert(start <= file.text.length, "start must be within the bounds of the file. " + start + " > " + file.text.length); + Debug.assert(end <= file.text.length, "end must be the bounds of the file. " + end + " > " + file.text.length); + } + var text = getLocaleSpecificMessage(message); + if (arguments.length > 4) { + text = formatStringFromArgs(text, arguments, 4); + } + return { + file: file, + start: start, + length: length, + messageText: text, + category: message.category, + code: message.code + }; + } + ts.createFileDiagnostic = createFileDiagnostic; + function createCompilerDiagnostic(message) { + var text = getLocaleSpecificMessage(message); + if (arguments.length > 1) { + text = formatStringFromArgs(text, arguments, 1); + } + return { + file: undefined, + start: undefined, + length: undefined, + messageText: text, + category: message.category, + code: message.code + }; + } + ts.createCompilerDiagnostic = createCompilerDiagnostic; + function chainDiagnosticMessages(details, message) { + var text = getLocaleSpecificMessage(message); + if (arguments.length > 2) { + text = formatStringFromArgs(text, arguments, 2); + } + return { + messageText: text, + category: message.category, + code: message.code, + next: details + }; + } + ts.chainDiagnosticMessages = chainDiagnosticMessages; + function concatenateDiagnosticMessageChains(headChain, tailChain) { + var lastChain = headChain; + while (lastChain.next) { + lastChain = lastChain.next; + } + lastChain.next = tailChain; + return headChain; + } + ts.concatenateDiagnosticMessageChains = concatenateDiagnosticMessageChains; + function compareValues(a, b) { + if (a === b) + return 0; + if (a === undefined) + return -1; + if (b === undefined) + return 1; + return a < b ? -1 : 1; + } + ts.compareValues = compareValues; + function getDiagnosticFileName(diagnostic) { + return diagnostic.file ? diagnostic.file.fileName : undefined; + } + function compareDiagnostics(d1, d2) { + return compareValues(getDiagnosticFileName(d1), getDiagnosticFileName(d2)) || + compareValues(d1.start, d2.start) || + compareValues(d1.length, d2.length) || + compareValues(d1.code, d2.code) || + compareMessageText(d1.messageText, d2.messageText) || + 0; + } + ts.compareDiagnostics = compareDiagnostics; + function compareMessageText(text1, text2) { + while (text1 && text2) { + var string1 = typeof text1 === "string" ? text1 : text1.messageText; + var string2 = typeof text2 === "string" ? text2 : text2.messageText; + var res = compareValues(string1, string2); + if (res) { + return res; + } + text1 = typeof text1 === "string" ? undefined : text1.next; + text2 = typeof text2 === "string" ? undefined : text2.next; + } + if (!text1 && !text2) { + return 0; + } + return text1 ? 1 : -1; + } + function sortAndDeduplicateDiagnostics(diagnostics) { + return deduplicateSortedDiagnostics(diagnostics.sort(compareDiagnostics)); + } + ts.sortAndDeduplicateDiagnostics = sortAndDeduplicateDiagnostics; + function deduplicateSortedDiagnostics(diagnostics) { + if (diagnostics.length < 2) { + return diagnostics; + } + var newDiagnostics = [diagnostics[0]]; + var previousDiagnostic = diagnostics[0]; + for (var i = 1; i < diagnostics.length; i++) { + var currentDiagnostic = diagnostics[i]; + var isDupe = compareDiagnostics(currentDiagnostic, previousDiagnostic) === 0; + if (!isDupe) { + newDiagnostics.push(currentDiagnostic); + previousDiagnostic = currentDiagnostic; + } + } + return newDiagnostics; + } + ts.deduplicateSortedDiagnostics = deduplicateSortedDiagnostics; + function normalizeSlashes(path) { + return path.replace(/\\/g, "/"); + } + ts.normalizeSlashes = normalizeSlashes; + function getRootLength(path) { + if (path.charCodeAt(0) === 47) { + if (path.charCodeAt(1) !== 47) + return 1; + var p1 = path.indexOf("/", 2); + if (p1 < 0) + return 2; + var p2 = path.indexOf("/", p1 + 1); + if (p2 < 0) + return p1 + 1; + return p2 + 1; + } + if (path.charCodeAt(1) === 58) { + if (path.charCodeAt(2) === 47) + return 3; + return 2; + } + if (path.lastIndexOf("file:///", 0) === 0) { + return "file:///".length; + } + var idx = path.indexOf("://"); + if (idx !== -1) { + return idx + "://".length; + } + return 0; + } + ts.getRootLength = getRootLength; + ts.directorySeparator = "/"; + function getNormalizedParts(normalizedSlashedPath, rootLength) { + var parts = normalizedSlashedPath.substr(rootLength).split(ts.directorySeparator); + var normalized = []; + for (var _i = 0; _i < parts.length; _i++) { + var part = parts[_i]; + if (part !== ".") { + if (part === ".." && normalized.length > 0 && lastOrUndefined(normalized) !== "..") { + normalized.pop(); + } + else { + if (part) { + normalized.push(part); + } + } + } + } + return normalized; + } + function normalizePath(path) { + path = normalizeSlashes(path); + var rootLength = getRootLength(path); + var normalized = getNormalizedParts(path, rootLength); + return path.substr(0, rootLength) + normalized.join(ts.directorySeparator); + } + ts.normalizePath = normalizePath; + function getDirectoryPath(path) { + return path.substr(0, Math.max(getRootLength(path), path.lastIndexOf(ts.directorySeparator))); + } + ts.getDirectoryPath = getDirectoryPath; + function isUrl(path) { + return path && !isRootedDiskPath(path) && path.indexOf("://") !== -1; + } + ts.isUrl = isUrl; + function isRootedDiskPath(path) { + return getRootLength(path) !== 0; + } + ts.isRootedDiskPath = isRootedDiskPath; + function normalizedPathComponents(path, rootLength) { + var normalizedParts = getNormalizedParts(path, rootLength); + return [path.substr(0, rootLength)].concat(normalizedParts); + } + function getNormalizedPathComponents(path, currentDirectory) { + path = normalizeSlashes(path); + var rootLength = getRootLength(path); + if (rootLength === 0) { + path = combinePaths(normalizeSlashes(currentDirectory), path); + rootLength = getRootLength(path); + } + return normalizedPathComponents(path, rootLength); + } + ts.getNormalizedPathComponents = getNormalizedPathComponents; + function getNormalizedAbsolutePath(fileName, currentDirectory) { + return getNormalizedPathFromPathComponents(getNormalizedPathComponents(fileName, currentDirectory)); + } + ts.getNormalizedAbsolutePath = getNormalizedAbsolutePath; + function getNormalizedPathFromPathComponents(pathComponents) { + if (pathComponents && pathComponents.length) { + return pathComponents[0] + pathComponents.slice(1).join(ts.directorySeparator); + } + } + ts.getNormalizedPathFromPathComponents = getNormalizedPathFromPathComponents; + function getNormalizedPathComponentsOfUrl(url) { + var urlLength = url.length; + var rootLength = url.indexOf("://") + "://".length; + while (rootLength < urlLength) { + if (url.charCodeAt(rootLength) === 47) { + rootLength++; + } + else { + break; + } + } + if (rootLength === urlLength) { + return [url]; + } + var indexOfNextSlash = url.indexOf(ts.directorySeparator, rootLength); + if (indexOfNextSlash !== -1) { + rootLength = indexOfNextSlash + 1; + return normalizedPathComponents(url, rootLength); + } + else { + return [url + ts.directorySeparator]; + } + } + function getNormalizedPathOrUrlComponents(pathOrUrl, currentDirectory) { + if (isUrl(pathOrUrl)) { + return getNormalizedPathComponentsOfUrl(pathOrUrl); + } + else { + return getNormalizedPathComponents(pathOrUrl, currentDirectory); + } + } + function getRelativePathToDirectoryOrUrl(directoryPathOrUrl, relativeOrAbsolutePath, currentDirectory, getCanonicalFileName, isAbsolutePathAnUrl) { + var pathComponents = getNormalizedPathOrUrlComponents(relativeOrAbsolutePath, currentDirectory); + var directoryComponents = getNormalizedPathOrUrlComponents(directoryPathOrUrl, currentDirectory); + if (directoryComponents.length > 1 && lastOrUndefined(directoryComponents) === "") { + directoryComponents.length--; + } + for (var joinStartIndex = 0; joinStartIndex < pathComponents.length && joinStartIndex < directoryComponents.length; joinStartIndex++) { + if (getCanonicalFileName(directoryComponents[joinStartIndex]) !== getCanonicalFileName(pathComponents[joinStartIndex])) { + break; + } + } + if (joinStartIndex) { + var relativePath = ""; + var relativePathComponents = pathComponents.slice(joinStartIndex, pathComponents.length); + for (; joinStartIndex < directoryComponents.length; joinStartIndex++) { + if (directoryComponents[joinStartIndex] !== "") { + relativePath = relativePath + ".." + ts.directorySeparator; + } + } + return relativePath + relativePathComponents.join(ts.directorySeparator); + } + var absolutePath = getNormalizedPathFromPathComponents(pathComponents); + if (isAbsolutePathAnUrl && isRootedDiskPath(absolutePath)) { + absolutePath = "file:///" + absolutePath; + } + return absolutePath; + } + ts.getRelativePathToDirectoryOrUrl = getRelativePathToDirectoryOrUrl; + function getBaseFileName(path) { + if (!path) { + return undefined; + } + var i = path.lastIndexOf(ts.directorySeparator); + return i < 0 ? path : path.substring(i + 1); + } + ts.getBaseFileName = getBaseFileName; + function combinePaths(path1, path2) { + if (!(path1 && path1.length)) + return path2; + if (!(path2 && path2.length)) + return path1; + if (getRootLength(path2) !== 0) + return path2; + if (path1.charAt(path1.length - 1) === ts.directorySeparator) + return path1 + path2; + return path1 + ts.directorySeparator + path2; + } + ts.combinePaths = combinePaths; + function fileExtensionIs(path, extension) { + var pathLen = path.length; + var extLen = extension.length; + return pathLen > extLen && path.substr(pathLen - extLen, extLen) === extension; + } + ts.fileExtensionIs = fileExtensionIs; + ts.supportedExtensions = [".ts", ".tsx", ".d.ts"]; + ts.moduleFileExtensions = ts.supportedExtensions; + function isSupportedSourceFileName(fileName) { + if (!fileName) { + return false; + } + for (var _i = 0; _i < ts.supportedExtensions.length; _i++) { + var extension = ts.supportedExtensions[_i]; + if (fileExtensionIs(fileName, extension)) { + return true; + } + } + return false; + } + ts.isSupportedSourceFileName = isSupportedSourceFileName; + var extensionsToRemove = [".d.ts", ".ts", ".js", ".tsx", ".jsx"]; + function removeFileExtension(path) { + for (var _i = 0; _i < extensionsToRemove.length; _i++) { + var ext = extensionsToRemove[_i]; + if (fileExtensionIs(path, ext)) { + return path.substr(0, path.length - ext.length); + } + } + return path; + } + ts.removeFileExtension = removeFileExtension; + var backslashOrDoubleQuote = /[\"\\]/g; + var escapedCharsRegExp = /[\u0000-\u001f\t\v\f\b\r\n\u2028\u2029\u0085]/g; + var escapedCharsMap = { + "\0": "\\0", + "\t": "\\t", + "\v": "\\v", + "\f": "\\f", + "\b": "\\b", + "\r": "\\r", + "\n": "\\n", + "\\": "\\\\", + "\"": "\\\"", + "\u2028": "\\u2028", + "\u2029": "\\u2029", + "\u0085": "\\u0085" + }; + function Symbol(flags, name) { + this.flags = flags; + this.name = name; + this.declarations = undefined; + } + function Type(checker, flags) { + this.flags = flags; + } + function Signature(checker) { + } + ts.objectAllocator = { + getNodeConstructor: function (kind) { + function Node(pos, end) { + this.pos = pos; + this.end = end; + this.flags = 0; + this.parent = undefined; + } + Node.prototype = { kind: kind }; + return Node; + }, + getSymbolConstructor: function () { return Symbol; }, + getTypeConstructor: function () { return Type; }, + getSignatureConstructor: function () { return Signature; } + }; + var Debug; + (function (Debug) { + var currentAssertionLevel = 0; + function shouldAssert(level) { + return currentAssertionLevel >= level; + } + Debug.shouldAssert = shouldAssert; + function assert(expression, message, verboseDebugInfo) { + if (!expression) { + var verboseDebugString = ""; + if (verboseDebugInfo) { + verboseDebugString = "\r\nVerbose Debug Information: " + verboseDebugInfo(); + } + debugger; + throw new Error("Debug Failure. False expression: " + (message || "") + verboseDebugString); + } + } + Debug.assert = assert; + function fail(message) { + Debug.assert(false, message); + } + Debug.fail = fail; + })(Debug = ts.Debug || (ts.Debug = {})); + function copyListRemovingItem(item, list) { + var copiedList = []; + for (var _i = 0; _i < list.length; _i++) { + var e = list[_i]; + if (e !== item) { + copiedList.push(e); + } + } + return copiedList; + } + ts.copyListRemovingItem = copyListRemovingItem; +})(ts || (ts = {})); +var ts; +(function (ts) { + ts.sys = (function () { + function getWScriptSystem() { + var fso = new ActiveXObject("Scripting.FileSystemObject"); + var fileStream = new ActiveXObject("ADODB.Stream"); + fileStream.Type = 2; + var binaryStream = new ActiveXObject("ADODB.Stream"); + binaryStream.Type = 1; + var args = []; + for (var i = 0; i < WScript.Arguments.length; i++) { + args[i] = WScript.Arguments.Item(i); + } + function readFile(fileName, encoding) { + if (!fso.FileExists(fileName)) { + return undefined; + } + fileStream.Open(); + try { + if (encoding) { + fileStream.Charset = encoding; + fileStream.LoadFromFile(fileName); + } + else { + fileStream.Charset = "x-ansi"; + fileStream.LoadFromFile(fileName); + var bom = fileStream.ReadText(2) || ""; + fileStream.Position = 0; + fileStream.Charset = bom.length >= 2 && (bom.charCodeAt(0) === 0xFF && bom.charCodeAt(1) === 0xFE || bom.charCodeAt(0) === 0xFE && bom.charCodeAt(1) === 0xFF) ? "unicode" : "utf-8"; + } + return fileStream.ReadText(); + } + catch (e) { + throw e; + } + finally { + fileStream.Close(); + } + } + function writeFile(fileName, data, writeByteOrderMark) { + fileStream.Open(); + binaryStream.Open(); + try { + fileStream.Charset = "utf-8"; + fileStream.WriteText(data); + if (writeByteOrderMark) { + fileStream.Position = 0; + } + else { + fileStream.Position = 3; + } + fileStream.CopyTo(binaryStream); + binaryStream.SaveToFile(fileName, 2); + } + finally { + binaryStream.Close(); + fileStream.Close(); + } + } + function getCanonicalPath(path) { + return path.toLowerCase(); + } + function getNames(collection) { + var result = []; + for (var e = new Enumerator(collection); !e.atEnd(); e.moveNext()) { + result.push(e.item().Name); + } + return result.sort(); + } + function readDirectory(path, extension, exclude) { + var result = []; + exclude = ts.map(exclude, function (s) { return getCanonicalPath(ts.combinePaths(path, s)); }); + visitDirectory(path); + return result; + function visitDirectory(path) { + var folder = fso.GetFolder(path || "."); + var files = getNames(folder.files); + for (var _i = 0; _i < files.length; _i++) { + var current = files[_i]; + var name_1 = ts.combinePaths(path, current); + if ((!extension || ts.fileExtensionIs(name_1, extension)) && !ts.contains(exclude, getCanonicalPath(name_1))) { + result.push(name_1); + } + } + var subfolders = getNames(folder.subfolders); + for (var _a = 0; _a < subfolders.length; _a++) { + var current = subfolders[_a]; + var name_2 = ts.combinePaths(path, current); + if (!ts.contains(exclude, getCanonicalPath(name_2))) { + visitDirectory(name_2); + } + } + } + } + return { + args: args, + newLine: "\r\n", + useCaseSensitiveFileNames: false, + write: function (s) { + WScript.StdOut.Write(s); + }, + readFile: readFile, + writeFile: writeFile, + resolvePath: function (path) { + return fso.GetAbsolutePathName(path); + }, + fileExists: function (path) { + return fso.FileExists(path); + }, + directoryExists: function (path) { + return fso.FolderExists(path); + }, + createDirectory: function (directoryName) { + if (!this.directoryExists(directoryName)) { + fso.CreateFolder(directoryName); + } + }, + getExecutingFilePath: function () { + return WScript.ScriptFullName; + }, + getCurrentDirectory: function () { + return new ActiveXObject("WScript.Shell").CurrentDirectory; + }, + readDirectory: readDirectory, + exit: function (exitCode) { + try { + WScript.Quit(exitCode); + } + catch (e) { + } + } + }; + } + function getNodeSystem() { + var _fs = require("fs"); + var _path = require("path"); + var _os = require("os"); + function createWatchedFileSet(interval, chunkSize) { + if (interval === void 0) { interval = 2500; } + if (chunkSize === void 0) { chunkSize = 30; } + var watchedFiles = []; + var nextFileToCheck = 0; + var watchTimer; + function getModifiedTime(fileName) { + return _fs.statSync(fileName).mtime; + } + function poll(checkedIndex) { + var watchedFile = watchedFiles[checkedIndex]; + if (!watchedFile) { + return; + } + _fs.stat(watchedFile.fileName, function (err, stats) { + if (err) { + watchedFile.callback(watchedFile.fileName); + } + else if (watchedFile.mtime.getTime() !== stats.mtime.getTime()) { + watchedFile.mtime = getModifiedTime(watchedFile.fileName); + watchedFile.callback(watchedFile.fileName, watchedFile.mtime.getTime() === 0); + } + }); + } + function startWatchTimer() { + watchTimer = setInterval(function () { + var count = 0; + var nextToCheck = nextFileToCheck; + var firstCheck = -1; + while ((count < chunkSize) && (nextToCheck !== firstCheck)) { + poll(nextToCheck); + if (firstCheck < 0) { + firstCheck = nextToCheck; + } + nextToCheck++; + if (nextToCheck === watchedFiles.length) { + nextToCheck = 0; + } + count++; + } + nextFileToCheck = nextToCheck; + }, interval); + } + function addFile(fileName, callback) { + var file = { + fileName: fileName, + callback: callback, + mtime: getModifiedTime(fileName) + }; + watchedFiles.push(file); + if (watchedFiles.length === 1) { + startWatchTimer(); + } + return file; + } + function removeFile(file) { + watchedFiles = ts.copyListRemovingItem(file, watchedFiles); + } + return { + getModifiedTime: getModifiedTime, + poll: poll, + startWatchTimer: startWatchTimer, + addFile: addFile, + removeFile: removeFile + }; + } + var watchedFileSet = createWatchedFileSet(); + function isNode4OrLater() { + return parseInt(process.version.charAt(1)) >= 4; + } + var platform = _os.platform(); + var useCaseSensitiveFileNames = platform !== "win32" && platform !== "win64" && platform !== "darwin"; + function readFile(fileName, encoding) { + if (!_fs.existsSync(fileName)) { + return undefined; + } + var buffer = _fs.readFileSync(fileName); + var len = buffer.length; + if (len >= 2 && buffer[0] === 0xFE && buffer[1] === 0xFF) { + len &= ~1; + for (var i = 0; i < len; i += 2) { + var temp = buffer[i]; + buffer[i] = buffer[i + 1]; + buffer[i + 1] = temp; + } + return buffer.toString("utf16le", 2); + } + if (len >= 2 && buffer[0] === 0xFF && buffer[1] === 0xFE) { + return buffer.toString("utf16le", 2); + } + if (len >= 3 && buffer[0] === 0xEF && buffer[1] === 0xBB && buffer[2] === 0xBF) { + return buffer.toString("utf8", 3); + } + return buffer.toString("utf8"); + } + function writeFile(fileName, data, writeByteOrderMark) { + if (writeByteOrderMark) { + data = "\uFEFF" + data; + } + _fs.writeFileSync(fileName, data, "utf8"); + } + function getCanonicalPath(path) { + return useCaseSensitiveFileNames ? path.toLowerCase() : path; + } + function readDirectory(path, extension, exclude) { + var result = []; + exclude = ts.map(exclude, function (s) { return getCanonicalPath(ts.combinePaths(path, s)); }); + visitDirectory(path); + return result; + function visitDirectory(path) { + var files = _fs.readdirSync(path || ".").sort(); + var directories = []; + for (var _i = 0; _i < files.length; _i++) { + var current = files[_i]; + var name_3 = ts.combinePaths(path, current); + if (!ts.contains(exclude, getCanonicalPath(name_3))) { + var stat = _fs.statSync(name_3); + if (stat.isFile()) { + if (!extension || ts.fileExtensionIs(name_3, extension)) { + result.push(name_3); + } + } + else if (stat.isDirectory()) { + directories.push(name_3); + } + } + } + for (var _a = 0; _a < directories.length; _a++) { + var current = directories[_a]; + visitDirectory(current); + } + } + } + return { + args: process.argv.slice(2), + newLine: _os.EOL, + useCaseSensitiveFileNames: useCaseSensitiveFileNames, + write: function (s) { + var buffer = new Buffer(s, "utf8"); + var offset = 0; + var toWrite = buffer.length; + var written = 0; + while ((written = _fs.writeSync(1, buffer, offset, toWrite)) < toWrite) { + offset += written; + toWrite -= written; + } + }, + readFile: readFile, + writeFile: writeFile, + watchFile: function (fileName, callback) { + if (isNode4OrLater()) { + return _fs.watch(fileName, function (eventName, relativeFileName) { return callback(fileName); }); + } + var watchedFile = watchedFileSet.addFile(fileName, callback); + return { + close: function () { return watchedFileSet.removeFile(watchedFile); } + }; + }, + watchDirectory: function (path, callback, recursive) { + return _fs.watch(path, { persistent: true, recursive: !!recursive }, function (eventName, relativeFileName) { + if (eventName === "rename") { + callback(!relativeFileName ? relativeFileName : ts.normalizePath(ts.combinePaths(path, relativeFileName))); + } + ; + }); + }, + resolvePath: function (path) { + return _path.resolve(path); + }, + fileExists: function (path) { + return _fs.existsSync(path); + }, + directoryExists: function (path) { + return _fs.existsSync(path) && _fs.statSync(path).isDirectory(); + }, + createDirectory: function (directoryName) { + if (!this.directoryExists(directoryName)) { + _fs.mkdirSync(directoryName); + } + }, + getExecutingFilePath: function () { + return __filename; + }, + getCurrentDirectory: function () { + return process.cwd(); + }, + readDirectory: readDirectory, + getMemoryUsage: function () { + if (global.gc) { + global.gc(); + } + return process.memoryUsage().heapUsed; + }, + exit: function (exitCode) { + process.exit(exitCode); + } + }; + } + if (typeof WScript !== "undefined" && typeof ActiveXObject === "function") { + return getWScriptSystem(); + } + else if (typeof process !== "undefined" && process.nextTick && !process.browser && typeof require !== "undefined") { + return getNodeSystem(); + } + else { + return undefined; + } + })(); +})(ts || (ts = {})); +var ts; +(function (ts) { + ts.Diagnostics = { + Unterminated_string_literal: { code: 1002, category: ts.DiagnosticCategory.Error, key: "Unterminated_string_literal_1002", message: "Unterminated string literal." }, + Identifier_expected: { code: 1003, category: ts.DiagnosticCategory.Error, key: "Identifier_expected_1003", message: "Identifier expected." }, + _0_expected: { code: 1005, category: ts.DiagnosticCategory.Error, key: "_0_expected_1005", message: "'{0}' expected." }, + A_file_cannot_have_a_reference_to_itself: { code: 1006, category: ts.DiagnosticCategory.Error, key: "A_file_cannot_have_a_reference_to_itself_1006", message: "A file cannot have a reference to itself." }, + Trailing_comma_not_allowed: { code: 1009, category: ts.DiagnosticCategory.Error, key: "Trailing_comma_not_allowed_1009", message: "Trailing comma not allowed." }, + Asterisk_Slash_expected: { code: 1010, category: ts.DiagnosticCategory.Error, key: "Asterisk_Slash_expected_1010", message: "'*/' expected." }, + Unexpected_token: { code: 1012, category: ts.DiagnosticCategory.Error, key: "Unexpected_token_1012", message: "Unexpected token." }, + A_rest_parameter_must_be_last_in_a_parameter_list: { code: 1014, category: ts.DiagnosticCategory.Error, key: "A_rest_parameter_must_be_last_in_a_parameter_list_1014", message: "A rest parameter must be last in a parameter list." }, + Parameter_cannot_have_question_mark_and_initializer: { code: 1015, category: ts.DiagnosticCategory.Error, key: "Parameter_cannot_have_question_mark_and_initializer_1015", message: "Parameter cannot have question mark and initializer." }, + A_required_parameter_cannot_follow_an_optional_parameter: { code: 1016, category: ts.DiagnosticCategory.Error, key: "A_required_parameter_cannot_follow_an_optional_parameter_1016", message: "A required parameter cannot follow an optional parameter." }, + An_index_signature_cannot_have_a_rest_parameter: { code: 1017, category: ts.DiagnosticCategory.Error, key: "An_index_signature_cannot_have_a_rest_parameter_1017", message: "An index signature cannot have a rest parameter." }, + An_index_signature_parameter_cannot_have_an_accessibility_modifier: { code: 1018, category: ts.DiagnosticCategory.Error, key: "An_index_signature_parameter_cannot_have_an_accessibility_modifier_1018", message: "An index signature parameter cannot have an accessibility modifier." }, + An_index_signature_parameter_cannot_have_a_question_mark: { code: 1019, category: ts.DiagnosticCategory.Error, key: "An_index_signature_parameter_cannot_have_a_question_mark_1019", message: "An index signature parameter cannot have a question mark." }, + An_index_signature_parameter_cannot_have_an_initializer: { code: 1020, category: ts.DiagnosticCategory.Error, key: "An_index_signature_parameter_cannot_have_an_initializer_1020", message: "An index signature parameter cannot have an initializer." }, + An_index_signature_must_have_a_type_annotation: { code: 1021, category: ts.DiagnosticCategory.Error, key: "An_index_signature_must_have_a_type_annotation_1021", message: "An index signature must have a type annotation." }, + An_index_signature_parameter_must_have_a_type_annotation: { code: 1022, category: ts.DiagnosticCategory.Error, key: "An_index_signature_parameter_must_have_a_type_annotation_1022", message: "An index signature parameter must have a type annotation." }, + An_index_signature_parameter_type_must_be_string_or_number: { code: 1023, category: ts.DiagnosticCategory.Error, key: "An_index_signature_parameter_type_must_be_string_or_number_1023", message: "An index signature parameter type must be 'string' or 'number'." }, + Accessibility_modifier_already_seen: { code: 1028, category: ts.DiagnosticCategory.Error, key: "Accessibility_modifier_already_seen_1028", message: "Accessibility modifier already seen." }, + _0_modifier_must_precede_1_modifier: { code: 1029, category: ts.DiagnosticCategory.Error, key: "_0_modifier_must_precede_1_modifier_1029", message: "'{0}' modifier must precede '{1}' modifier." }, + _0_modifier_already_seen: { code: 1030, category: ts.DiagnosticCategory.Error, key: "_0_modifier_already_seen_1030", message: "'{0}' modifier already seen." }, + _0_modifier_cannot_appear_on_a_class_element: { code: 1031, category: ts.DiagnosticCategory.Error, key: "_0_modifier_cannot_appear_on_a_class_element_1031", message: "'{0}' modifier cannot appear on a class element." }, + super_must_be_followed_by_an_argument_list_or_member_access: { code: 1034, category: ts.DiagnosticCategory.Error, key: "super_must_be_followed_by_an_argument_list_or_member_access_1034", message: "'super' must be followed by an argument list or member access." }, + Only_ambient_modules_can_use_quoted_names: { code: 1035, category: ts.DiagnosticCategory.Error, key: "Only_ambient_modules_can_use_quoted_names_1035", message: "Only ambient modules can use quoted names." }, + Statements_are_not_allowed_in_ambient_contexts: { code: 1036, category: ts.DiagnosticCategory.Error, key: "Statements_are_not_allowed_in_ambient_contexts_1036", message: "Statements are not allowed in ambient contexts." }, + A_declare_modifier_cannot_be_used_in_an_already_ambient_context: { code: 1038, category: ts.DiagnosticCategory.Error, key: "A_declare_modifier_cannot_be_used_in_an_already_ambient_context_1038", message: "A 'declare' modifier cannot be used in an already ambient context." }, + Initializers_are_not_allowed_in_ambient_contexts: { code: 1039, category: ts.DiagnosticCategory.Error, key: "Initializers_are_not_allowed_in_ambient_contexts_1039", message: "Initializers are not allowed in ambient contexts." }, + _0_modifier_cannot_be_used_in_an_ambient_context: { code: 1040, category: ts.DiagnosticCategory.Error, key: "_0_modifier_cannot_be_used_in_an_ambient_context_1040", message: "'{0}' modifier cannot be used in an ambient context." }, + _0_modifier_cannot_be_used_with_a_class_declaration: { code: 1041, category: ts.DiagnosticCategory.Error, key: "_0_modifier_cannot_be_used_with_a_class_declaration_1041", message: "'{0}' modifier cannot be used with a class declaration." }, + _0_modifier_cannot_be_used_here: { code: 1042, category: ts.DiagnosticCategory.Error, key: "_0_modifier_cannot_be_used_here_1042", message: "'{0}' modifier cannot be used here." }, + _0_modifier_cannot_appear_on_a_data_property: { code: 1043, category: ts.DiagnosticCategory.Error, key: "_0_modifier_cannot_appear_on_a_data_property_1043", message: "'{0}' modifier cannot appear on a data property." }, + _0_modifier_cannot_appear_on_a_module_element: { code: 1044, category: ts.DiagnosticCategory.Error, key: "_0_modifier_cannot_appear_on_a_module_element_1044", message: "'{0}' modifier cannot appear on a module element." }, + A_0_modifier_cannot_be_used_with_an_interface_declaration: { code: 1045, category: ts.DiagnosticCategory.Error, key: "A_0_modifier_cannot_be_used_with_an_interface_declaration_1045", message: "A '{0}' modifier cannot be used with an interface declaration." }, + A_declare_modifier_is_required_for_a_top_level_declaration_in_a_d_ts_file: { code: 1046, category: ts.DiagnosticCategory.Error, key: "A_declare_modifier_is_required_for_a_top_level_declaration_in_a_d_ts_file_1046", message: "A 'declare' modifier is required for a top level declaration in a .d.ts file." }, + A_rest_parameter_cannot_be_optional: { code: 1047, category: ts.DiagnosticCategory.Error, key: "A_rest_parameter_cannot_be_optional_1047", message: "A rest parameter cannot be optional." }, + A_rest_parameter_cannot_have_an_initializer: { code: 1048, category: ts.DiagnosticCategory.Error, key: "A_rest_parameter_cannot_have_an_initializer_1048", message: "A rest parameter cannot have an initializer." }, + A_set_accessor_must_have_exactly_one_parameter: { code: 1049, category: ts.DiagnosticCategory.Error, key: "A_set_accessor_must_have_exactly_one_parameter_1049", message: "A 'set' accessor must have exactly one parameter." }, + A_set_accessor_cannot_have_an_optional_parameter: { code: 1051, category: ts.DiagnosticCategory.Error, key: "A_set_accessor_cannot_have_an_optional_parameter_1051", message: "A 'set' accessor cannot have an optional parameter." }, + A_set_accessor_parameter_cannot_have_an_initializer: { code: 1052, category: ts.DiagnosticCategory.Error, key: "A_set_accessor_parameter_cannot_have_an_initializer_1052", message: "A 'set' accessor parameter cannot have an initializer." }, + A_set_accessor_cannot_have_rest_parameter: { code: 1053, category: ts.DiagnosticCategory.Error, key: "A_set_accessor_cannot_have_rest_parameter_1053", message: "A 'set' accessor cannot have rest parameter." }, + A_get_accessor_cannot_have_parameters: { code: 1054, category: ts.DiagnosticCategory.Error, key: "A_get_accessor_cannot_have_parameters_1054", message: "A 'get' accessor cannot have parameters." }, + Type_0_is_not_a_valid_async_function_return_type: { code: 1055, category: ts.DiagnosticCategory.Error, key: "Type_0_is_not_a_valid_async_function_return_type_1055", message: "Type '{0}' is not a valid async function return type." }, + Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher: { code: 1056, category: ts.DiagnosticCategory.Error, key: "Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher_1056", message: "Accessors are only available when targeting ECMAScript 5 and higher." }, + An_async_function_or_method_must_have_a_valid_awaitable_return_type: { code: 1057, category: ts.DiagnosticCategory.Error, key: "An_async_function_or_method_must_have_a_valid_awaitable_return_type_1057", message: "An async function or method must have a valid awaitable return type." }, + Operand_for_await_does_not_have_a_valid_callable_then_member: { code: 1058, category: ts.DiagnosticCategory.Error, key: "Operand_for_await_does_not_have_a_valid_callable_then_member_1058", message: "Operand for 'await' does not have a valid callable 'then' member." }, + Return_expression_in_async_function_does_not_have_a_valid_callable_then_member: { code: 1059, category: ts.DiagnosticCategory.Error, key: "Return_expression_in_async_function_does_not_have_a_valid_callable_then_member_1059", message: "Return expression in async function does not have a valid callable 'then' member." }, + Expression_body_for_async_arrow_function_does_not_have_a_valid_callable_then_member: { code: 1060, category: ts.DiagnosticCategory.Error, key: "Expression_body_for_async_arrow_function_does_not_have_a_valid_callable_then_member_1060", message: "Expression body for async arrow function does not have a valid callable 'then' member." }, + Enum_member_must_have_initializer: { code: 1061, category: ts.DiagnosticCategory.Error, key: "Enum_member_must_have_initializer_1061", message: "Enum member must have initializer." }, + _0_is_referenced_directly_or_indirectly_in_the_fulfillment_callback_of_its_own_then_method: { code: 1062, category: ts.DiagnosticCategory.Error, key: "_0_is_referenced_directly_or_indirectly_in_the_fulfillment_callback_of_its_own_then_method_1062", message: "{0} is referenced directly or indirectly in the fulfillment callback of its own 'then' method." }, + An_export_assignment_cannot_be_used_in_a_namespace: { code: 1063, category: ts.DiagnosticCategory.Error, key: "An_export_assignment_cannot_be_used_in_a_namespace_1063", message: "An export assignment cannot be used in a namespace." }, + In_ambient_enum_declarations_member_initializer_must_be_constant_expression: { code: 1066, category: ts.DiagnosticCategory.Error, key: "In_ambient_enum_declarations_member_initializer_must_be_constant_expression_1066", message: "In ambient enum declarations member initializer must be constant expression." }, + Unexpected_token_A_constructor_method_accessor_or_property_was_expected: { code: 1068, category: ts.DiagnosticCategory.Error, key: "Unexpected_token_A_constructor_method_accessor_or_property_was_expected_1068", message: "Unexpected token. A constructor, method, accessor, or property was expected." }, + A_0_modifier_cannot_be_used_with_an_import_declaration: { code: 1079, category: ts.DiagnosticCategory.Error, key: "A_0_modifier_cannot_be_used_with_an_import_declaration_1079", message: "A '{0}' modifier cannot be used with an import declaration." }, + Invalid_reference_directive_syntax: { code: 1084, category: ts.DiagnosticCategory.Error, key: "Invalid_reference_directive_syntax_1084", message: "Invalid 'reference' directive syntax." }, + Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher: { code: 1085, category: ts.DiagnosticCategory.Error, key: "Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher_1085", message: "Octal literals are not available when targeting ECMAScript 5 and higher." }, + An_accessor_cannot_be_declared_in_an_ambient_context: { code: 1086, category: ts.DiagnosticCategory.Error, key: "An_accessor_cannot_be_declared_in_an_ambient_context_1086", message: "An accessor cannot be declared in an ambient context." }, + _0_modifier_cannot_appear_on_a_constructor_declaration: { code: 1089, category: ts.DiagnosticCategory.Error, key: "_0_modifier_cannot_appear_on_a_constructor_declaration_1089", message: "'{0}' modifier cannot appear on a constructor declaration." }, + _0_modifier_cannot_appear_on_a_parameter: { code: 1090, category: ts.DiagnosticCategory.Error, key: "_0_modifier_cannot_appear_on_a_parameter_1090", message: "'{0}' modifier cannot appear on a parameter." }, + Only_a_single_variable_declaration_is_allowed_in_a_for_in_statement: { code: 1091, category: ts.DiagnosticCategory.Error, key: "Only_a_single_variable_declaration_is_allowed_in_a_for_in_statement_1091", message: "Only a single variable declaration is allowed in a 'for...in' statement." }, + Type_parameters_cannot_appear_on_a_constructor_declaration: { code: 1092, category: ts.DiagnosticCategory.Error, key: "Type_parameters_cannot_appear_on_a_constructor_declaration_1092", message: "Type parameters cannot appear on a constructor declaration." }, + Type_annotation_cannot_appear_on_a_constructor_declaration: { code: 1093, category: ts.DiagnosticCategory.Error, key: "Type_annotation_cannot_appear_on_a_constructor_declaration_1093", message: "Type annotation cannot appear on a constructor declaration." }, + An_accessor_cannot_have_type_parameters: { code: 1094, category: ts.DiagnosticCategory.Error, key: "An_accessor_cannot_have_type_parameters_1094", message: "An accessor cannot have type parameters." }, + A_set_accessor_cannot_have_a_return_type_annotation: { code: 1095, category: ts.DiagnosticCategory.Error, key: "A_set_accessor_cannot_have_a_return_type_annotation_1095", message: "A 'set' accessor cannot have a return type annotation." }, + An_index_signature_must_have_exactly_one_parameter: { code: 1096, category: ts.DiagnosticCategory.Error, key: "An_index_signature_must_have_exactly_one_parameter_1096", message: "An index signature must have exactly one parameter." }, + _0_list_cannot_be_empty: { code: 1097, category: ts.DiagnosticCategory.Error, key: "_0_list_cannot_be_empty_1097", message: "'{0}' list cannot be empty." }, + Type_parameter_list_cannot_be_empty: { code: 1098, category: ts.DiagnosticCategory.Error, key: "Type_parameter_list_cannot_be_empty_1098", message: "Type parameter list cannot be empty." }, + Type_argument_list_cannot_be_empty: { code: 1099, category: ts.DiagnosticCategory.Error, key: "Type_argument_list_cannot_be_empty_1099", message: "Type argument list cannot be empty." }, + Invalid_use_of_0_in_strict_mode: { code: 1100, category: ts.DiagnosticCategory.Error, key: "Invalid_use_of_0_in_strict_mode_1100", message: "Invalid use of '{0}' in strict mode." }, + with_statements_are_not_allowed_in_strict_mode: { code: 1101, category: ts.DiagnosticCategory.Error, key: "with_statements_are_not_allowed_in_strict_mode_1101", message: "'with' statements are not allowed in strict mode." }, + delete_cannot_be_called_on_an_identifier_in_strict_mode: { code: 1102, category: ts.DiagnosticCategory.Error, key: "delete_cannot_be_called_on_an_identifier_in_strict_mode_1102", message: "'delete' cannot be called on an identifier in strict mode." }, + A_continue_statement_can_only_be_used_within_an_enclosing_iteration_statement: { code: 1104, category: ts.DiagnosticCategory.Error, key: "A_continue_statement_can_only_be_used_within_an_enclosing_iteration_statement_1104", message: "A 'continue' statement can only be used within an enclosing iteration statement." }, + A_break_statement_can_only_be_used_within_an_enclosing_iteration_or_switch_statement: { code: 1105, category: ts.DiagnosticCategory.Error, key: "A_break_statement_can_only_be_used_within_an_enclosing_iteration_or_switch_statement_1105", message: "A 'break' statement can only be used within an enclosing iteration or switch statement." }, + Jump_target_cannot_cross_function_boundary: { code: 1107, category: ts.DiagnosticCategory.Error, key: "Jump_target_cannot_cross_function_boundary_1107", message: "Jump target cannot cross function boundary." }, + A_return_statement_can_only_be_used_within_a_function_body: { code: 1108, category: ts.DiagnosticCategory.Error, key: "A_return_statement_can_only_be_used_within_a_function_body_1108", message: "A 'return' statement can only be used within a function body." }, + Expression_expected: { code: 1109, category: ts.DiagnosticCategory.Error, key: "Expression_expected_1109", message: "Expression expected." }, + Type_expected: { code: 1110, category: ts.DiagnosticCategory.Error, key: "Type_expected_1110", message: "Type expected." }, + A_class_member_cannot_be_declared_optional: { code: 1112, category: ts.DiagnosticCategory.Error, key: "A_class_member_cannot_be_declared_optional_1112", message: "A class member cannot be declared optional." }, + A_default_clause_cannot_appear_more_than_once_in_a_switch_statement: { code: 1113, category: ts.DiagnosticCategory.Error, key: "A_default_clause_cannot_appear_more_than_once_in_a_switch_statement_1113", message: "A 'default' clause cannot appear more than once in a 'switch' statement." }, + Duplicate_label_0: { code: 1114, category: ts.DiagnosticCategory.Error, key: "Duplicate_label_0_1114", message: "Duplicate label '{0}'" }, + A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement: { code: 1115, category: ts.DiagnosticCategory.Error, key: "A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement_1115", message: "A 'continue' statement can only jump to a label of an enclosing iteration statement." }, + A_break_statement_can_only_jump_to_a_label_of_an_enclosing_statement: { code: 1116, category: ts.DiagnosticCategory.Error, key: "A_break_statement_can_only_jump_to_a_label_of_an_enclosing_statement_1116", message: "A 'break' statement can only jump to a label of an enclosing statement." }, + An_object_literal_cannot_have_multiple_properties_with_the_same_name_in_strict_mode: { code: 1117, category: ts.DiagnosticCategory.Error, key: "An_object_literal_cannot_have_multiple_properties_with_the_same_name_in_strict_mode_1117", message: "An object literal cannot have multiple properties with the same name in strict mode." }, + An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name: { code: 1118, category: ts.DiagnosticCategory.Error, key: "An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name_1118", message: "An object literal cannot have multiple get/set accessors with the same name." }, + An_object_literal_cannot_have_property_and_accessor_with_the_same_name: { code: 1119, category: ts.DiagnosticCategory.Error, key: "An_object_literal_cannot_have_property_and_accessor_with_the_same_name_1119", message: "An object literal cannot have property and accessor with the same name." }, + An_export_assignment_cannot_have_modifiers: { code: 1120, category: ts.DiagnosticCategory.Error, key: "An_export_assignment_cannot_have_modifiers_1120", message: "An export assignment cannot have modifiers." }, + Octal_literals_are_not_allowed_in_strict_mode: { code: 1121, category: ts.DiagnosticCategory.Error, key: "Octal_literals_are_not_allowed_in_strict_mode_1121", message: "Octal literals are not allowed in strict mode." }, + A_tuple_type_element_list_cannot_be_empty: { code: 1122, category: ts.DiagnosticCategory.Error, key: "A_tuple_type_element_list_cannot_be_empty_1122", message: "A tuple type element list cannot be empty." }, + Variable_declaration_list_cannot_be_empty: { code: 1123, category: ts.DiagnosticCategory.Error, key: "Variable_declaration_list_cannot_be_empty_1123", message: "Variable declaration list cannot be empty." }, + Digit_expected: { code: 1124, category: ts.DiagnosticCategory.Error, key: "Digit_expected_1124", message: "Digit expected." }, + Hexadecimal_digit_expected: { code: 1125, category: ts.DiagnosticCategory.Error, key: "Hexadecimal_digit_expected_1125", message: "Hexadecimal digit expected." }, + Unexpected_end_of_text: { code: 1126, category: ts.DiagnosticCategory.Error, key: "Unexpected_end_of_text_1126", message: "Unexpected end of text." }, + Invalid_character: { code: 1127, category: ts.DiagnosticCategory.Error, key: "Invalid_character_1127", message: "Invalid character." }, + Declaration_or_statement_expected: { code: 1128, category: ts.DiagnosticCategory.Error, key: "Declaration_or_statement_expected_1128", message: "Declaration or statement expected." }, + Statement_expected: { code: 1129, category: ts.DiagnosticCategory.Error, key: "Statement_expected_1129", message: "Statement expected." }, + case_or_default_expected: { code: 1130, category: ts.DiagnosticCategory.Error, key: "case_or_default_expected_1130", message: "'case' or 'default' expected." }, + Property_or_signature_expected: { code: 1131, category: ts.DiagnosticCategory.Error, key: "Property_or_signature_expected_1131", message: "Property or signature expected." }, + Enum_member_expected: { code: 1132, category: ts.DiagnosticCategory.Error, key: "Enum_member_expected_1132", message: "Enum member expected." }, + Variable_declaration_expected: { code: 1134, category: ts.DiagnosticCategory.Error, key: "Variable_declaration_expected_1134", message: "Variable declaration expected." }, + Argument_expression_expected: { code: 1135, category: ts.DiagnosticCategory.Error, key: "Argument_expression_expected_1135", message: "Argument expression expected." }, + Property_assignment_expected: { code: 1136, category: ts.DiagnosticCategory.Error, key: "Property_assignment_expected_1136", message: "Property assignment expected." }, + Expression_or_comma_expected: { code: 1137, category: ts.DiagnosticCategory.Error, key: "Expression_or_comma_expected_1137", message: "Expression or comma expected." }, + Parameter_declaration_expected: { code: 1138, category: ts.DiagnosticCategory.Error, key: "Parameter_declaration_expected_1138", message: "Parameter declaration expected." }, + Type_parameter_declaration_expected: { code: 1139, category: ts.DiagnosticCategory.Error, key: "Type_parameter_declaration_expected_1139", message: "Type parameter declaration expected." }, + Type_argument_expected: { code: 1140, category: ts.DiagnosticCategory.Error, key: "Type_argument_expected_1140", message: "Type argument expected." }, + String_literal_expected: { code: 1141, category: ts.DiagnosticCategory.Error, key: "String_literal_expected_1141", message: "String literal expected." }, + Line_break_not_permitted_here: { code: 1142, category: ts.DiagnosticCategory.Error, key: "Line_break_not_permitted_here_1142", message: "Line break not permitted here." }, + or_expected: { code: 1144, category: ts.DiagnosticCategory.Error, key: "or_expected_1144", message: "'{' or ';' expected." }, + Modifiers_not_permitted_on_index_signature_members: { code: 1145, category: ts.DiagnosticCategory.Error, key: "Modifiers_not_permitted_on_index_signature_members_1145", message: "Modifiers not permitted on index signature members." }, + Declaration_expected: { code: 1146, category: ts.DiagnosticCategory.Error, key: "Declaration_expected_1146", message: "Declaration expected." }, + Import_declarations_in_a_namespace_cannot_reference_a_module: { code: 1147, category: ts.DiagnosticCategory.Error, key: "Import_declarations_in_a_namespace_cannot_reference_a_module_1147", message: "Import declarations in a namespace cannot reference a module." }, + Cannot_compile_modules_unless_the_module_flag_is_provided: { code: 1148, category: ts.DiagnosticCategory.Error, key: "Cannot_compile_modules_unless_the_module_flag_is_provided_1148", message: "Cannot compile modules unless the '--module' flag is provided." }, + File_name_0_differs_from_already_included_file_name_1_only_in_casing: { code: 1149, category: ts.DiagnosticCategory.Error, key: "File_name_0_differs_from_already_included_file_name_1_only_in_casing_1149", message: "File name '{0}' differs from already included file name '{1}' only in casing" }, + new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead: { code: 1150, category: ts.DiagnosticCategory.Error, key: "new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead_1150", message: "'new T[]' cannot be used to create an array. Use 'new Array()' instead." }, + const_declarations_must_be_initialized: { code: 1155, category: ts.DiagnosticCategory.Error, key: "const_declarations_must_be_initialized_1155", message: "'const' declarations must be initialized" }, + const_declarations_can_only_be_declared_inside_a_block: { code: 1156, category: ts.DiagnosticCategory.Error, key: "const_declarations_can_only_be_declared_inside_a_block_1156", message: "'const' declarations can only be declared inside a block." }, + let_declarations_can_only_be_declared_inside_a_block: { code: 1157, category: ts.DiagnosticCategory.Error, key: "let_declarations_can_only_be_declared_inside_a_block_1157", message: "'let' declarations can only be declared inside a block." }, + Unterminated_template_literal: { code: 1160, category: ts.DiagnosticCategory.Error, key: "Unterminated_template_literal_1160", message: "Unterminated template literal." }, + Unterminated_regular_expression_literal: { code: 1161, category: ts.DiagnosticCategory.Error, key: "Unterminated_regular_expression_literal_1161", message: "Unterminated regular expression literal." }, + An_object_member_cannot_be_declared_optional: { code: 1162, category: ts.DiagnosticCategory.Error, key: "An_object_member_cannot_be_declared_optional_1162", message: "An object member cannot be declared optional." }, + A_yield_expression_is_only_allowed_in_a_generator_body: { code: 1163, category: ts.DiagnosticCategory.Error, key: "A_yield_expression_is_only_allowed_in_a_generator_body_1163", message: "A 'yield' expression is only allowed in a generator body." }, + Computed_property_names_are_not_allowed_in_enums: { code: 1164, category: ts.DiagnosticCategory.Error, key: "Computed_property_names_are_not_allowed_in_enums_1164", message: "Computed property names are not allowed in enums." }, + A_computed_property_name_in_an_ambient_context_must_directly_refer_to_a_built_in_symbol: { code: 1165, category: ts.DiagnosticCategory.Error, key: "A_computed_property_name_in_an_ambient_context_must_directly_refer_to_a_built_in_symbol_1165", message: "A computed property name in an ambient context must directly refer to a built-in symbol." }, + A_computed_property_name_in_a_class_property_declaration_must_directly_refer_to_a_built_in_symbol: { code: 1166, category: ts.DiagnosticCategory.Error, key: "A_computed_property_name_in_a_class_property_declaration_must_directly_refer_to_a_built_in_symbol_1166", message: "A computed property name in a class property declaration must directly refer to a built-in symbol." }, + A_computed_property_name_in_a_method_overload_must_directly_refer_to_a_built_in_symbol: { code: 1168, category: ts.DiagnosticCategory.Error, key: "A_computed_property_name_in_a_method_overload_must_directly_refer_to_a_built_in_symbol_1168", message: "A computed property name in a method overload must directly refer to a built-in symbol." }, + A_computed_property_name_in_an_interface_must_directly_refer_to_a_built_in_symbol: { code: 1169, category: ts.DiagnosticCategory.Error, key: "A_computed_property_name_in_an_interface_must_directly_refer_to_a_built_in_symbol_1169", message: "A computed property name in an interface must directly refer to a built-in symbol." }, + A_computed_property_name_in_a_type_literal_must_directly_refer_to_a_built_in_symbol: { code: 1170, category: ts.DiagnosticCategory.Error, key: "A_computed_property_name_in_a_type_literal_must_directly_refer_to_a_built_in_symbol_1170", message: "A computed property name in a type literal must directly refer to a built-in symbol." }, + A_comma_expression_is_not_allowed_in_a_computed_property_name: { code: 1171, category: ts.DiagnosticCategory.Error, key: "A_comma_expression_is_not_allowed_in_a_computed_property_name_1171", message: "A comma expression is not allowed in a computed property name." }, + extends_clause_already_seen: { code: 1172, category: ts.DiagnosticCategory.Error, key: "extends_clause_already_seen_1172", message: "'extends' clause already seen." }, + extends_clause_must_precede_implements_clause: { code: 1173, category: ts.DiagnosticCategory.Error, key: "extends_clause_must_precede_implements_clause_1173", message: "'extends' clause must precede 'implements' clause." }, + Classes_can_only_extend_a_single_class: { code: 1174, category: ts.DiagnosticCategory.Error, key: "Classes_can_only_extend_a_single_class_1174", message: "Classes can only extend a single class." }, + implements_clause_already_seen: { code: 1175, category: ts.DiagnosticCategory.Error, key: "implements_clause_already_seen_1175", message: "'implements' clause already seen." }, + Interface_declaration_cannot_have_implements_clause: { code: 1176, category: ts.DiagnosticCategory.Error, key: "Interface_declaration_cannot_have_implements_clause_1176", message: "Interface declaration cannot have 'implements' clause." }, + Binary_digit_expected: { code: 1177, category: ts.DiagnosticCategory.Error, key: "Binary_digit_expected_1177", message: "Binary digit expected." }, + Octal_digit_expected: { code: 1178, category: ts.DiagnosticCategory.Error, key: "Octal_digit_expected_1178", message: "Octal digit expected." }, + Unexpected_token_expected: { code: 1179, category: ts.DiagnosticCategory.Error, key: "Unexpected_token_expected_1179", message: "Unexpected token. '{' expected." }, + Property_destructuring_pattern_expected: { code: 1180, category: ts.DiagnosticCategory.Error, key: "Property_destructuring_pattern_expected_1180", message: "Property destructuring pattern expected." }, + Array_element_destructuring_pattern_expected: { code: 1181, category: ts.DiagnosticCategory.Error, key: "Array_element_destructuring_pattern_expected_1181", message: "Array element destructuring pattern expected." }, + A_destructuring_declaration_must_have_an_initializer: { code: 1182, category: ts.DiagnosticCategory.Error, key: "A_destructuring_declaration_must_have_an_initializer_1182", message: "A destructuring declaration must have an initializer." }, + An_implementation_cannot_be_declared_in_ambient_contexts: { code: 1183, category: ts.DiagnosticCategory.Error, key: "An_implementation_cannot_be_declared_in_ambient_contexts_1183", message: "An implementation cannot be declared in ambient contexts." }, + Modifiers_cannot_appear_here: { code: 1184, category: ts.DiagnosticCategory.Error, key: "Modifiers_cannot_appear_here_1184", message: "Modifiers cannot appear here." }, + Merge_conflict_marker_encountered: { code: 1185, category: ts.DiagnosticCategory.Error, key: "Merge_conflict_marker_encountered_1185", message: "Merge conflict marker encountered." }, + A_rest_element_cannot_have_an_initializer: { code: 1186, category: ts.DiagnosticCategory.Error, key: "A_rest_element_cannot_have_an_initializer_1186", message: "A rest element cannot have an initializer." }, + A_parameter_property_may_not_be_a_binding_pattern: { code: 1187, category: ts.DiagnosticCategory.Error, key: "A_parameter_property_may_not_be_a_binding_pattern_1187", message: "A parameter property may not be a binding pattern." }, + Only_a_single_variable_declaration_is_allowed_in_a_for_of_statement: { code: 1188, category: ts.DiagnosticCategory.Error, key: "Only_a_single_variable_declaration_is_allowed_in_a_for_of_statement_1188", message: "Only a single variable declaration is allowed in a 'for...of' statement." }, + The_variable_declaration_of_a_for_in_statement_cannot_have_an_initializer: { code: 1189, category: ts.DiagnosticCategory.Error, key: "The_variable_declaration_of_a_for_in_statement_cannot_have_an_initializer_1189", message: "The variable declaration of a 'for...in' statement cannot have an initializer." }, + The_variable_declaration_of_a_for_of_statement_cannot_have_an_initializer: { code: 1190, category: ts.DiagnosticCategory.Error, key: "The_variable_declaration_of_a_for_of_statement_cannot_have_an_initializer_1190", message: "The variable declaration of a 'for...of' statement cannot have an initializer." }, + An_import_declaration_cannot_have_modifiers: { code: 1191, category: ts.DiagnosticCategory.Error, key: "An_import_declaration_cannot_have_modifiers_1191", message: "An import declaration cannot have modifiers." }, + Module_0_has_no_default_export: { code: 1192, category: ts.DiagnosticCategory.Error, key: "Module_0_has_no_default_export_1192", message: "Module '{0}' has no default export." }, + An_export_declaration_cannot_have_modifiers: { code: 1193, category: ts.DiagnosticCategory.Error, key: "An_export_declaration_cannot_have_modifiers_1193", message: "An export declaration cannot have modifiers." }, + Export_declarations_are_not_permitted_in_a_namespace: { code: 1194, category: ts.DiagnosticCategory.Error, key: "Export_declarations_are_not_permitted_in_a_namespace_1194", message: "Export declarations are not permitted in a namespace." }, + Catch_clause_variable_name_must_be_an_identifier: { code: 1195, category: ts.DiagnosticCategory.Error, key: "Catch_clause_variable_name_must_be_an_identifier_1195", message: "Catch clause variable name must be an identifier." }, + Catch_clause_variable_cannot_have_a_type_annotation: { code: 1196, category: ts.DiagnosticCategory.Error, key: "Catch_clause_variable_cannot_have_a_type_annotation_1196", message: "Catch clause variable cannot have a type annotation." }, + Catch_clause_variable_cannot_have_an_initializer: { code: 1197, category: ts.DiagnosticCategory.Error, key: "Catch_clause_variable_cannot_have_an_initializer_1197", message: "Catch clause variable cannot have an initializer." }, + An_extended_Unicode_escape_value_must_be_between_0x0_and_0x10FFFF_inclusive: { code: 1198, category: ts.DiagnosticCategory.Error, key: "An_extended_Unicode_escape_value_must_be_between_0x0_and_0x10FFFF_inclusive_1198", message: "An extended Unicode escape value must be between 0x0 and 0x10FFFF inclusive." }, + Unterminated_Unicode_escape_sequence: { code: 1199, category: ts.DiagnosticCategory.Error, key: "Unterminated_Unicode_escape_sequence_1199", message: "Unterminated Unicode escape sequence." }, + Line_terminator_not_permitted_before_arrow: { code: 1200, category: ts.DiagnosticCategory.Error, key: "Line_terminator_not_permitted_before_arrow_1200", message: "Line terminator not permitted before arrow." }, + Import_assignment_cannot_be_used_when_targeting_ECMAScript_6_modules_Consider_using_import_Asterisk_as_ns_from_mod_import_a_from_mod_import_d_from_mod_or_another_module_format_instead: { code: 1202, category: ts.DiagnosticCategory.Error, key: "Import_assignment_cannot_be_used_when_targeting_ECMAScript_6_modules_Consider_using_import_Asterisk__1202", message: "Import assignment cannot be used when targeting ECMAScript 6 modules. Consider using 'import * as ns from \"mod\"', 'import {a} from \"mod\"', 'import d from \"mod\"', or another module format instead." }, + Export_assignment_cannot_be_used_when_targeting_ECMAScript_6_modules_Consider_using_export_default_or_another_module_format_instead: { code: 1203, category: ts.DiagnosticCategory.Error, key: "Export_assignment_cannot_be_used_when_targeting_ECMAScript_6_modules_Consider_using_export_default_o_1203", message: "Export assignment cannot be used when targeting ECMAScript 6 modules. Consider using 'export default' or another module format instead." }, + Cannot_compile_modules_into_es2015_when_targeting_ES5_or_lower: { code: 1204, category: ts.DiagnosticCategory.Error, key: "Cannot_compile_modules_into_es2015_when_targeting_ES5_or_lower_1204", message: "Cannot compile modules into 'es2015' when targeting 'ES5' or lower." }, + Decorators_are_not_valid_here: { code: 1206, category: ts.DiagnosticCategory.Error, key: "Decorators_are_not_valid_here_1206", message: "Decorators are not valid here." }, + Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name: { code: 1207, category: ts.DiagnosticCategory.Error, key: "Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name_1207", message: "Decorators cannot be applied to multiple get/set accessors of the same name." }, + Cannot_compile_namespaces_when_the_isolatedModules_flag_is_provided: { code: 1208, category: ts.DiagnosticCategory.Error, key: "Cannot_compile_namespaces_when_the_isolatedModules_flag_is_provided_1208", message: "Cannot compile namespaces when the '--isolatedModules' flag is provided." }, + Ambient_const_enums_are_not_allowed_when_the_isolatedModules_flag_is_provided: { code: 1209, category: ts.DiagnosticCategory.Error, key: "Ambient_const_enums_are_not_allowed_when_the_isolatedModules_flag_is_provided_1209", message: "Ambient const enums are not allowed when the '--isolatedModules' flag is provided." }, + Invalid_use_of_0_Class_definitions_are_automatically_in_strict_mode: { code: 1210, category: ts.DiagnosticCategory.Error, key: "Invalid_use_of_0_Class_definitions_are_automatically_in_strict_mode_1210", message: "Invalid use of '{0}'. Class definitions are automatically in strict mode." }, + A_class_declaration_without_the_default_modifier_must_have_a_name: { code: 1211, category: ts.DiagnosticCategory.Error, key: "A_class_declaration_without_the_default_modifier_must_have_a_name_1211", message: "A class declaration without the 'default' modifier must have a name" }, + Identifier_expected_0_is_a_reserved_word_in_strict_mode: { code: 1212, category: ts.DiagnosticCategory.Error, key: "Identifier_expected_0_is_a_reserved_word_in_strict_mode_1212", message: "Identifier expected. '{0}' is a reserved word in strict mode" }, + Identifier_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_strict_mode: { code: 1213, category: ts.DiagnosticCategory.Error, key: "Identifier_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_stric_1213", message: "Identifier expected. '{0}' is a reserved word in strict mode. Class definitions are automatically in strict mode." }, + Identifier_expected_0_is_a_reserved_word_in_strict_mode_Modules_are_automatically_in_strict_mode: { code: 1214, category: ts.DiagnosticCategory.Error, key: "Identifier_expected_0_is_a_reserved_word_in_strict_mode_Modules_are_automatically_in_strict_mode_1214", message: "Identifier expected. '{0}' is a reserved word in strict mode. Modules are automatically in strict mode." }, + Invalid_use_of_0_Modules_are_automatically_in_strict_mode: { code: 1215, category: ts.DiagnosticCategory.Error, key: "Invalid_use_of_0_Modules_are_automatically_in_strict_mode_1215", message: "Invalid use of '{0}'. Modules are automatically in strict mode." }, + Export_assignment_is_not_supported_when_module_flag_is_system: { code: 1218, category: ts.DiagnosticCategory.Error, key: "Export_assignment_is_not_supported_when_module_flag_is_system_1218", message: "Export assignment is not supported when '--module' flag is 'system'." }, + Experimental_support_for_decorators_is_a_feature_that_is_subject_to_change_in_a_future_release_Specify_experimentalDecorators_to_remove_this_warning: { code: 1219, category: ts.DiagnosticCategory.Error, key: "Experimental_support_for_decorators_is_a_feature_that_is_subject_to_change_in_a_future_release_Speci_1219", message: "Experimental support for decorators is a feature that is subject to change in a future release. Specify '--experimentalDecorators' to remove this warning." }, + Generators_are_only_available_when_targeting_ECMAScript_6_or_higher: { code: 1220, category: ts.DiagnosticCategory.Error, key: "Generators_are_only_available_when_targeting_ECMAScript_6_or_higher_1220", message: "Generators are only available when targeting ECMAScript 6 or higher." }, + Generators_are_not_allowed_in_an_ambient_context: { code: 1221, category: ts.DiagnosticCategory.Error, key: "Generators_are_not_allowed_in_an_ambient_context_1221", message: "Generators are not allowed in an ambient context." }, + An_overload_signature_cannot_be_declared_as_a_generator: { code: 1222, category: ts.DiagnosticCategory.Error, key: "An_overload_signature_cannot_be_declared_as_a_generator_1222", message: "An overload signature cannot be declared as a generator." }, + _0_tag_already_specified: { code: 1223, category: ts.DiagnosticCategory.Error, key: "_0_tag_already_specified_1223", message: "'{0}' tag already specified." }, + Signature_0_must_have_a_type_predicate: { code: 1224, category: ts.DiagnosticCategory.Error, key: "Signature_0_must_have_a_type_predicate_1224", message: "Signature '{0}' must have a type predicate." }, + Cannot_find_parameter_0: { code: 1225, category: ts.DiagnosticCategory.Error, key: "Cannot_find_parameter_0_1225", message: "Cannot find parameter '{0}'." }, + Type_predicate_0_is_not_assignable_to_1: { code: 1226, category: ts.DiagnosticCategory.Error, key: "Type_predicate_0_is_not_assignable_to_1_1226", message: "Type predicate '{0}' is not assignable to '{1}'." }, + Parameter_0_is_not_in_the_same_position_as_parameter_1: { code: 1227, category: ts.DiagnosticCategory.Error, key: "Parameter_0_is_not_in_the_same_position_as_parameter_1_1227", message: "Parameter '{0}' is not in the same position as parameter '{1}'." }, + A_type_predicate_is_only_allowed_in_return_type_position_for_functions_and_methods: { code: 1228, category: ts.DiagnosticCategory.Error, key: "A_type_predicate_is_only_allowed_in_return_type_position_for_functions_and_methods_1228", message: "A type predicate is only allowed in return type position for functions and methods." }, + A_type_predicate_cannot_reference_a_rest_parameter: { code: 1229, category: ts.DiagnosticCategory.Error, key: "A_type_predicate_cannot_reference_a_rest_parameter_1229", message: "A type predicate cannot reference a rest parameter." }, + A_type_predicate_cannot_reference_element_0_in_a_binding_pattern: { code: 1230, category: ts.DiagnosticCategory.Error, key: "A_type_predicate_cannot_reference_element_0_in_a_binding_pattern_1230", message: "A type predicate cannot reference element '{0}' in a binding pattern." }, + An_export_assignment_can_only_be_used_in_a_module: { code: 1231, category: ts.DiagnosticCategory.Error, key: "An_export_assignment_can_only_be_used_in_a_module_1231", message: "An export assignment can only be used in a module." }, + An_import_declaration_can_only_be_used_in_a_namespace_or_module: { code: 1232, category: ts.DiagnosticCategory.Error, key: "An_import_declaration_can_only_be_used_in_a_namespace_or_module_1232", message: "An import declaration can only be used in a namespace or module." }, + An_export_declaration_can_only_be_used_in_a_module: { code: 1233, category: ts.DiagnosticCategory.Error, key: "An_export_declaration_can_only_be_used_in_a_module_1233", message: "An export declaration can only be used in a module." }, + An_ambient_module_declaration_is_only_allowed_at_the_top_level_in_a_file: { code: 1234, category: ts.DiagnosticCategory.Error, key: "An_ambient_module_declaration_is_only_allowed_at_the_top_level_in_a_file_1234", message: "An ambient module declaration is only allowed at the top level in a file." }, + A_namespace_declaration_is_only_allowed_in_a_namespace_or_module: { code: 1235, category: ts.DiagnosticCategory.Error, key: "A_namespace_declaration_is_only_allowed_in_a_namespace_or_module_1235", message: "A namespace declaration is only allowed in a namespace or module." }, + The_return_type_of_a_property_decorator_function_must_be_either_void_or_any: { code: 1236, category: ts.DiagnosticCategory.Error, key: "The_return_type_of_a_property_decorator_function_must_be_either_void_or_any_1236", message: "The return type of a property decorator function must be either 'void' or 'any'." }, + The_return_type_of_a_parameter_decorator_function_must_be_either_void_or_any: { code: 1237, category: ts.DiagnosticCategory.Error, key: "The_return_type_of_a_parameter_decorator_function_must_be_either_void_or_any_1237", message: "The return type of a parameter decorator function must be either 'void' or 'any'." }, + Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression: { code: 1238, category: ts.DiagnosticCategory.Error, key: "Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression_1238", message: "Unable to resolve signature of class decorator when called as an expression." }, + Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression: { code: 1239, category: ts.DiagnosticCategory.Error, key: "Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression_1239", message: "Unable to resolve signature of parameter decorator when called as an expression." }, + Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression: { code: 1240, category: ts.DiagnosticCategory.Error, key: "Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression_1240", message: "Unable to resolve signature of property decorator when called as an expression." }, + Unable_to_resolve_signature_of_method_decorator_when_called_as_an_expression: { code: 1241, category: ts.DiagnosticCategory.Error, key: "Unable_to_resolve_signature_of_method_decorator_when_called_as_an_expression_1241", message: "Unable to resolve signature of method decorator when called as an expression." }, + abstract_modifier_can_only_appear_on_a_class_or_method_declaration: { code: 1242, category: ts.DiagnosticCategory.Error, key: "abstract_modifier_can_only_appear_on_a_class_or_method_declaration_1242", message: "'abstract' modifier can only appear on a class or method declaration." }, + _0_modifier_cannot_be_used_with_1_modifier: { code: 1243, category: ts.DiagnosticCategory.Error, key: "_0_modifier_cannot_be_used_with_1_modifier_1243", message: "'{0}' modifier cannot be used with '{1}' modifier." }, + Abstract_methods_can_only_appear_within_an_abstract_class: { code: 1244, category: ts.DiagnosticCategory.Error, key: "Abstract_methods_can_only_appear_within_an_abstract_class_1244", message: "Abstract methods can only appear within an abstract class." }, + Method_0_cannot_have_an_implementation_because_it_is_marked_abstract: { code: 1245, category: ts.DiagnosticCategory.Error, key: "Method_0_cannot_have_an_implementation_because_it_is_marked_abstract_1245", message: "Method '{0}' cannot have an implementation because it is marked abstract." }, + with_statements_are_not_allowed_in_an_async_function_block: { code: 1300, category: ts.DiagnosticCategory.Error, key: "with_statements_are_not_allowed_in_an_async_function_block_1300", message: "'with' statements are not allowed in an async function block." }, + await_expression_is_only_allowed_within_an_async_function: { code: 1308, category: ts.DiagnosticCategory.Error, key: "await_expression_is_only_allowed_within_an_async_function_1308", message: "'await' expression is only allowed within an async function." }, + Async_functions_are_only_available_when_targeting_ECMAScript_6_and_higher: { code: 1311, category: ts.DiagnosticCategory.Error, key: "Async_functions_are_only_available_when_targeting_ECMAScript_6_and_higher_1311", message: "Async functions are only available when targeting ECMAScript 6 and higher." }, + can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment: { code: 1312, category: ts.DiagnosticCategory.Error, key: "can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment_1312", message: "'=' can only be used in an object literal property inside a destructuring assignment." }, + Duplicate_identifier_0: { code: 2300, category: ts.DiagnosticCategory.Error, key: "Duplicate_identifier_0_2300", message: "Duplicate identifier '{0}'." }, + Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor: { code: 2301, category: ts.DiagnosticCategory.Error, key: "Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor_2301", message: "Initializer of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor." }, + Static_members_cannot_reference_class_type_parameters: { code: 2302, category: ts.DiagnosticCategory.Error, key: "Static_members_cannot_reference_class_type_parameters_2302", message: "Static members cannot reference class type parameters." }, + Circular_definition_of_import_alias_0: { code: 2303, category: ts.DiagnosticCategory.Error, key: "Circular_definition_of_import_alias_0_2303", message: "Circular definition of import alias '{0}'." }, + Cannot_find_name_0: { code: 2304, category: ts.DiagnosticCategory.Error, key: "Cannot_find_name_0_2304", message: "Cannot find name '{0}'." }, + Module_0_has_no_exported_member_1: { code: 2305, category: ts.DiagnosticCategory.Error, key: "Module_0_has_no_exported_member_1_2305", message: "Module '{0}' has no exported member '{1}'." }, + File_0_is_not_a_module: { code: 2306, category: ts.DiagnosticCategory.Error, key: "File_0_is_not_a_module_2306", message: "File '{0}' is not a module." }, + Cannot_find_module_0: { code: 2307, category: ts.DiagnosticCategory.Error, key: "Cannot_find_module_0_2307", message: "Cannot find module '{0}'." }, + An_export_assignment_cannot_be_used_in_a_module_with_other_exported_elements: { code: 2309, category: ts.DiagnosticCategory.Error, key: "An_export_assignment_cannot_be_used_in_a_module_with_other_exported_elements_2309", message: "An export assignment cannot be used in a module with other exported elements." }, + Type_0_recursively_references_itself_as_a_base_type: { code: 2310, category: ts.DiagnosticCategory.Error, key: "Type_0_recursively_references_itself_as_a_base_type_2310", message: "Type '{0}' recursively references itself as a base type." }, + A_class_may_only_extend_another_class: { code: 2311, category: ts.DiagnosticCategory.Error, key: "A_class_may_only_extend_another_class_2311", message: "A class may only extend another class." }, + An_interface_may_only_extend_a_class_or_another_interface: { code: 2312, category: ts.DiagnosticCategory.Error, key: "An_interface_may_only_extend_a_class_or_another_interface_2312", message: "An interface may only extend a class or another interface." }, + Constraint_of_a_type_parameter_cannot_reference_any_type_parameter_from_the_same_type_parameter_list: { code: 2313, category: ts.DiagnosticCategory.Error, key: "Constraint_of_a_type_parameter_cannot_reference_any_type_parameter_from_the_same_type_parameter_list_2313", message: "Constraint of a type parameter cannot reference any type parameter from the same type parameter list." }, + Generic_type_0_requires_1_type_argument_s: { code: 2314, category: ts.DiagnosticCategory.Error, key: "Generic_type_0_requires_1_type_argument_s_2314", message: "Generic type '{0}' requires {1} type argument(s)." }, + Type_0_is_not_generic: { code: 2315, category: ts.DiagnosticCategory.Error, key: "Type_0_is_not_generic_2315", message: "Type '{0}' is not generic." }, + Global_type_0_must_be_a_class_or_interface_type: { code: 2316, category: ts.DiagnosticCategory.Error, key: "Global_type_0_must_be_a_class_or_interface_type_2316", message: "Global type '{0}' must be a class or interface type." }, + Global_type_0_must_have_1_type_parameter_s: { code: 2317, category: ts.DiagnosticCategory.Error, key: "Global_type_0_must_have_1_type_parameter_s_2317", message: "Global type '{0}' must have {1} type parameter(s)." }, + Cannot_find_global_type_0: { code: 2318, category: ts.DiagnosticCategory.Error, key: "Cannot_find_global_type_0_2318", message: "Cannot find global type '{0}'." }, + Named_property_0_of_types_1_and_2_are_not_identical: { code: 2319, category: ts.DiagnosticCategory.Error, key: "Named_property_0_of_types_1_and_2_are_not_identical_2319", message: "Named property '{0}' of types '{1}' and '{2}' are not identical." }, + Interface_0_cannot_simultaneously_extend_types_1_and_2: { code: 2320, category: ts.DiagnosticCategory.Error, key: "Interface_0_cannot_simultaneously_extend_types_1_and_2_2320", message: "Interface '{0}' cannot simultaneously extend types '{1}' and '{2}'." }, + Excessive_stack_depth_comparing_types_0_and_1: { code: 2321, category: ts.DiagnosticCategory.Error, key: "Excessive_stack_depth_comparing_types_0_and_1_2321", message: "Excessive stack depth comparing types '{0}' and '{1}'." }, + Type_0_is_not_assignable_to_type_1: { code: 2322, category: ts.DiagnosticCategory.Error, key: "Type_0_is_not_assignable_to_type_1_2322", message: "Type '{0}' is not assignable to type '{1}'." }, + Property_0_is_missing_in_type_1: { code: 2324, category: ts.DiagnosticCategory.Error, key: "Property_0_is_missing_in_type_1_2324", message: "Property '{0}' is missing in type '{1}'." }, + Property_0_is_private_in_type_1_but_not_in_type_2: { code: 2325, category: ts.DiagnosticCategory.Error, key: "Property_0_is_private_in_type_1_but_not_in_type_2_2325", message: "Property '{0}' is private in type '{1}' but not in type '{2}'." }, + Types_of_property_0_are_incompatible: { code: 2326, category: ts.DiagnosticCategory.Error, key: "Types_of_property_0_are_incompatible_2326", message: "Types of property '{0}' are incompatible." }, + Property_0_is_optional_in_type_1_but_required_in_type_2: { code: 2327, category: ts.DiagnosticCategory.Error, key: "Property_0_is_optional_in_type_1_but_required_in_type_2_2327", message: "Property '{0}' is optional in type '{1}' but required in type '{2}'." }, + Types_of_parameters_0_and_1_are_incompatible: { code: 2328, category: ts.DiagnosticCategory.Error, key: "Types_of_parameters_0_and_1_are_incompatible_2328", message: "Types of parameters '{0}' and '{1}' are incompatible." }, + Index_signature_is_missing_in_type_0: { code: 2329, category: ts.DiagnosticCategory.Error, key: "Index_signature_is_missing_in_type_0_2329", message: "Index signature is missing in type '{0}'." }, + Index_signatures_are_incompatible: { code: 2330, category: ts.DiagnosticCategory.Error, key: "Index_signatures_are_incompatible_2330", message: "Index signatures are incompatible." }, + this_cannot_be_referenced_in_a_module_or_namespace_body: { code: 2331, category: ts.DiagnosticCategory.Error, key: "this_cannot_be_referenced_in_a_module_or_namespace_body_2331", message: "'this' cannot be referenced in a module or namespace body." }, + this_cannot_be_referenced_in_current_location: { code: 2332, category: ts.DiagnosticCategory.Error, key: "this_cannot_be_referenced_in_current_location_2332", message: "'this' cannot be referenced in current location." }, + this_cannot_be_referenced_in_constructor_arguments: { code: 2333, category: ts.DiagnosticCategory.Error, key: "this_cannot_be_referenced_in_constructor_arguments_2333", message: "'this' cannot be referenced in constructor arguments." }, + this_cannot_be_referenced_in_a_static_property_initializer: { code: 2334, category: ts.DiagnosticCategory.Error, key: "this_cannot_be_referenced_in_a_static_property_initializer_2334", message: "'this' cannot be referenced in a static property initializer." }, + super_can_only_be_referenced_in_a_derived_class: { code: 2335, category: ts.DiagnosticCategory.Error, key: "super_can_only_be_referenced_in_a_derived_class_2335", message: "'super' can only be referenced in a derived class." }, + super_cannot_be_referenced_in_constructor_arguments: { code: 2336, category: ts.DiagnosticCategory.Error, key: "super_cannot_be_referenced_in_constructor_arguments_2336", message: "'super' cannot be referenced in constructor arguments." }, + Super_calls_are_not_permitted_outside_constructors_or_in_nested_functions_inside_constructors: { code: 2337, category: ts.DiagnosticCategory.Error, key: "Super_calls_are_not_permitted_outside_constructors_or_in_nested_functions_inside_constructors_2337", message: "Super calls are not permitted outside constructors or in nested functions inside constructors." }, + super_property_access_is_permitted_only_in_a_constructor_member_function_or_member_accessor_of_a_derived_class: { code: 2338, category: ts.DiagnosticCategory.Error, key: "super_property_access_is_permitted_only_in_a_constructor_member_function_or_member_accessor_of_a_der_2338", message: "'super' property access is permitted only in a constructor, member function, or member accessor of a derived class." }, + Property_0_does_not_exist_on_type_1: { code: 2339, category: ts.DiagnosticCategory.Error, key: "Property_0_does_not_exist_on_type_1_2339", message: "Property '{0}' does not exist on type '{1}'." }, + Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword: { code: 2340, category: ts.DiagnosticCategory.Error, key: "Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword_2340", message: "Only public and protected methods of the base class are accessible via the 'super' keyword." }, + Property_0_is_private_and_only_accessible_within_class_1: { code: 2341, category: ts.DiagnosticCategory.Error, key: "Property_0_is_private_and_only_accessible_within_class_1_2341", message: "Property '{0}' is private and only accessible within class '{1}'." }, + An_index_expression_argument_must_be_of_type_string_number_symbol_or_any: { code: 2342, category: ts.DiagnosticCategory.Error, key: "An_index_expression_argument_must_be_of_type_string_number_symbol_or_any_2342", message: "An index expression argument must be of type 'string', 'number', 'symbol', or 'any'." }, + Type_0_does_not_satisfy_the_constraint_1: { code: 2344, category: ts.DiagnosticCategory.Error, key: "Type_0_does_not_satisfy_the_constraint_1_2344", message: "Type '{0}' does not satisfy the constraint '{1}'." }, + Argument_of_type_0_is_not_assignable_to_parameter_of_type_1: { code: 2345, category: ts.DiagnosticCategory.Error, key: "Argument_of_type_0_is_not_assignable_to_parameter_of_type_1_2345", message: "Argument of type '{0}' is not assignable to parameter of type '{1}'." }, + Supplied_parameters_do_not_match_any_signature_of_call_target: { code: 2346, category: ts.DiagnosticCategory.Error, key: "Supplied_parameters_do_not_match_any_signature_of_call_target_2346", message: "Supplied parameters do not match any signature of call target." }, + Untyped_function_calls_may_not_accept_type_arguments: { code: 2347, category: ts.DiagnosticCategory.Error, key: "Untyped_function_calls_may_not_accept_type_arguments_2347", message: "Untyped function calls may not accept type arguments." }, + Value_of_type_0_is_not_callable_Did_you_mean_to_include_new: { code: 2348, category: ts.DiagnosticCategory.Error, key: "Value_of_type_0_is_not_callable_Did_you_mean_to_include_new_2348", message: "Value of type '{0}' is not callable. Did you mean to include 'new'?" }, + Cannot_invoke_an_expression_whose_type_lacks_a_call_signature: { code: 2349, category: ts.DiagnosticCategory.Error, key: "Cannot_invoke_an_expression_whose_type_lacks_a_call_signature_2349", message: "Cannot invoke an expression whose type lacks a call signature." }, + Only_a_void_function_can_be_called_with_the_new_keyword: { code: 2350, category: ts.DiagnosticCategory.Error, key: "Only_a_void_function_can_be_called_with_the_new_keyword_2350", message: "Only a void function can be called with the 'new' keyword." }, + Cannot_use_new_with_an_expression_whose_type_lacks_a_call_or_construct_signature: { code: 2351, category: ts.DiagnosticCategory.Error, key: "Cannot_use_new_with_an_expression_whose_type_lacks_a_call_or_construct_signature_2351", message: "Cannot use 'new' with an expression whose type lacks a call or construct signature." }, + Neither_type_0_nor_type_1_is_assignable_to_the_other: { code: 2352, category: ts.DiagnosticCategory.Error, key: "Neither_type_0_nor_type_1_is_assignable_to_the_other_2352", message: "Neither type '{0}' nor type '{1}' is assignable to the other." }, + Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1: { code: 2353, category: ts.DiagnosticCategory.Error, key: "Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1_2353", message: "Object literal may only specify known properties, and '{0}' does not exist in type '{1}'." }, + No_best_common_type_exists_among_return_expressions: { code: 2354, category: ts.DiagnosticCategory.Error, key: "No_best_common_type_exists_among_return_expressions_2354", message: "No best common type exists among return expressions." }, + A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value_or_consist_of_a_single_throw_statement: { code: 2355, category: ts.DiagnosticCategory.Error, key: "A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value_or_consist_of_a_single_th_2355", message: "A function whose declared type is neither 'void' nor 'any' must return a value or consist of a single 'throw' statement." }, + An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type: { code: 2356, category: ts.DiagnosticCategory.Error, key: "An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type_2356", message: "An arithmetic operand must be of type 'any', 'number' or an enum type." }, + The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_property_or_indexer: { code: 2357, category: ts.DiagnosticCategory.Error, key: "The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_property_or_indexer_2357", message: "The operand of an increment or decrement operator must be a variable, property or indexer." }, + The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_parameter: { code: 2358, category: ts.DiagnosticCategory.Error, key: "The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_paramete_2358", message: "The left-hand side of an 'instanceof' expression must be of type 'any', an object type or a type parameter." }, + The_right_hand_side_of_an_instanceof_expression_must_be_of_type_any_or_of_a_type_assignable_to_the_Function_interface_type: { code: 2359, category: ts.DiagnosticCategory.Error, key: "The_right_hand_side_of_an_instanceof_expression_must_be_of_type_any_or_of_a_type_assignable_to_the_F_2359", message: "The right-hand side of an 'instanceof' expression must be of type 'any' or of a type assignable to the 'Function' interface type." }, + The_left_hand_side_of_an_in_expression_must_be_of_type_any_string_number_or_symbol: { code: 2360, category: ts.DiagnosticCategory.Error, key: "The_left_hand_side_of_an_in_expression_must_be_of_type_any_string_number_or_symbol_2360", message: "The left-hand side of an 'in' expression must be of type 'any', 'string', 'number', or 'symbol'." }, + The_right_hand_side_of_an_in_expression_must_be_of_type_any_an_object_type_or_a_type_parameter: { code: 2361, category: ts.DiagnosticCategory.Error, key: "The_right_hand_side_of_an_in_expression_must_be_of_type_any_an_object_type_or_a_type_parameter_2361", message: "The right-hand side of an 'in' expression must be of type 'any', an object type or a type parameter" }, + The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type: { code: 2362, category: ts.DiagnosticCategory.Error, key: "The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type_2362", message: "The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type." }, + The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type: { code: 2363, category: ts.DiagnosticCategory.Error, key: "The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type_2363", message: "The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type." }, + Invalid_left_hand_side_of_assignment_expression: { code: 2364, category: ts.DiagnosticCategory.Error, key: "Invalid_left_hand_side_of_assignment_expression_2364", message: "Invalid left-hand side of assignment expression." }, + Operator_0_cannot_be_applied_to_types_1_and_2: { code: 2365, category: ts.DiagnosticCategory.Error, key: "Operator_0_cannot_be_applied_to_types_1_and_2_2365", message: "Operator '{0}' cannot be applied to types '{1}' and '{2}'." }, + Type_parameter_name_cannot_be_0: { code: 2368, category: ts.DiagnosticCategory.Error, key: "Type_parameter_name_cannot_be_0_2368", message: "Type parameter name cannot be '{0}'" }, + A_parameter_property_is_only_allowed_in_a_constructor_implementation: { code: 2369, category: ts.DiagnosticCategory.Error, key: "A_parameter_property_is_only_allowed_in_a_constructor_implementation_2369", message: "A parameter property is only allowed in a constructor implementation." }, + A_rest_parameter_must_be_of_an_array_type: { code: 2370, category: ts.DiagnosticCategory.Error, key: "A_rest_parameter_must_be_of_an_array_type_2370", message: "A rest parameter must be of an array type." }, + A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation: { code: 2371, category: ts.DiagnosticCategory.Error, key: "A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation_2371", message: "A parameter initializer is only allowed in a function or constructor implementation." }, + Parameter_0_cannot_be_referenced_in_its_initializer: { code: 2372, category: ts.DiagnosticCategory.Error, key: "Parameter_0_cannot_be_referenced_in_its_initializer_2372", message: "Parameter '{0}' cannot be referenced in its initializer." }, + Initializer_of_parameter_0_cannot_reference_identifier_1_declared_after_it: { code: 2373, category: ts.DiagnosticCategory.Error, key: "Initializer_of_parameter_0_cannot_reference_identifier_1_declared_after_it_2373", message: "Initializer of parameter '{0}' cannot reference identifier '{1}' declared after it." }, + Duplicate_string_index_signature: { code: 2374, category: ts.DiagnosticCategory.Error, key: "Duplicate_string_index_signature_2374", message: "Duplicate string index signature." }, + Duplicate_number_index_signature: { code: 2375, category: ts.DiagnosticCategory.Error, key: "Duplicate_number_index_signature_2375", message: "Duplicate number index signature." }, + A_super_call_must_be_the_first_statement_in_the_constructor_when_a_class_contains_initialized_properties_or_has_parameter_properties: { code: 2376, category: ts.DiagnosticCategory.Error, key: "A_super_call_must_be_the_first_statement_in_the_constructor_when_a_class_contains_initialized_proper_2376", message: "A 'super' call must be the first statement in the constructor when a class contains initialized properties or has parameter properties." }, + Constructors_for_derived_classes_must_contain_a_super_call: { code: 2377, category: ts.DiagnosticCategory.Error, key: "Constructors_for_derived_classes_must_contain_a_super_call_2377", message: "Constructors for derived classes must contain a 'super' call." }, + A_get_accessor_must_return_a_value_or_consist_of_a_single_throw_statement: { code: 2378, category: ts.DiagnosticCategory.Error, key: "A_get_accessor_must_return_a_value_or_consist_of_a_single_throw_statement_2378", message: "A 'get' accessor must return a value or consist of a single 'throw' statement." }, + Getter_and_setter_accessors_do_not_agree_in_visibility: { code: 2379, category: ts.DiagnosticCategory.Error, key: "Getter_and_setter_accessors_do_not_agree_in_visibility_2379", message: "Getter and setter accessors do not agree in visibility." }, + get_and_set_accessor_must_have_the_same_type: { code: 2380, category: ts.DiagnosticCategory.Error, key: "get_and_set_accessor_must_have_the_same_type_2380", message: "'get' and 'set' accessor must have the same type." }, + A_signature_with_an_implementation_cannot_use_a_string_literal_type: { code: 2381, category: ts.DiagnosticCategory.Error, key: "A_signature_with_an_implementation_cannot_use_a_string_literal_type_2381", message: "A signature with an implementation cannot use a string literal type." }, + Specialized_overload_signature_is_not_assignable_to_any_non_specialized_signature: { code: 2382, category: ts.DiagnosticCategory.Error, key: "Specialized_overload_signature_is_not_assignable_to_any_non_specialized_signature_2382", message: "Specialized overload signature is not assignable to any non-specialized signature." }, + Overload_signatures_must_all_be_exported_or_not_exported: { code: 2383, category: ts.DiagnosticCategory.Error, key: "Overload_signatures_must_all_be_exported_or_not_exported_2383", message: "Overload signatures must all be exported or not exported." }, + Overload_signatures_must_all_be_ambient_or_non_ambient: { code: 2384, category: ts.DiagnosticCategory.Error, key: "Overload_signatures_must_all_be_ambient_or_non_ambient_2384", message: "Overload signatures must all be ambient or non-ambient." }, + Overload_signatures_must_all_be_public_private_or_protected: { code: 2385, category: ts.DiagnosticCategory.Error, key: "Overload_signatures_must_all_be_public_private_or_protected_2385", message: "Overload signatures must all be public, private or protected." }, + Overload_signatures_must_all_be_optional_or_required: { code: 2386, category: ts.DiagnosticCategory.Error, key: "Overload_signatures_must_all_be_optional_or_required_2386", message: "Overload signatures must all be optional or required." }, + Function_overload_must_be_static: { code: 2387, category: ts.DiagnosticCategory.Error, key: "Function_overload_must_be_static_2387", message: "Function overload must be static." }, + Function_overload_must_not_be_static: { code: 2388, category: ts.DiagnosticCategory.Error, key: "Function_overload_must_not_be_static_2388", message: "Function overload must not be static." }, + Function_implementation_name_must_be_0: { code: 2389, category: ts.DiagnosticCategory.Error, key: "Function_implementation_name_must_be_0_2389", message: "Function implementation name must be '{0}'." }, + Constructor_implementation_is_missing: { code: 2390, category: ts.DiagnosticCategory.Error, key: "Constructor_implementation_is_missing_2390", message: "Constructor implementation is missing." }, + Function_implementation_is_missing_or_not_immediately_following_the_declaration: { code: 2391, category: ts.DiagnosticCategory.Error, key: "Function_implementation_is_missing_or_not_immediately_following_the_declaration_2391", message: "Function implementation is missing or not immediately following the declaration." }, + Multiple_constructor_implementations_are_not_allowed: { code: 2392, category: ts.DiagnosticCategory.Error, key: "Multiple_constructor_implementations_are_not_allowed_2392", message: "Multiple constructor implementations are not allowed." }, + Duplicate_function_implementation: { code: 2393, category: ts.DiagnosticCategory.Error, key: "Duplicate_function_implementation_2393", message: "Duplicate function implementation." }, + Overload_signature_is_not_compatible_with_function_implementation: { code: 2394, category: ts.DiagnosticCategory.Error, key: "Overload_signature_is_not_compatible_with_function_implementation_2394", message: "Overload signature is not compatible with function implementation." }, + Individual_declarations_in_merged_declaration_0_must_be_all_exported_or_all_local: { code: 2395, category: ts.DiagnosticCategory.Error, key: "Individual_declarations_in_merged_declaration_0_must_be_all_exported_or_all_local_2395", message: "Individual declarations in merged declaration '{0}' must be all exported or all local." }, + Duplicate_identifier_arguments_Compiler_uses_arguments_to_initialize_rest_parameters: { code: 2396, category: ts.DiagnosticCategory.Error, key: "Duplicate_identifier_arguments_Compiler_uses_arguments_to_initialize_rest_parameters_2396", message: "Duplicate identifier 'arguments'. Compiler uses 'arguments' to initialize rest parameters." }, + Duplicate_identifier_this_Compiler_uses_variable_declaration_this_to_capture_this_reference: { code: 2399, category: ts.DiagnosticCategory.Error, key: "Duplicate_identifier_this_Compiler_uses_variable_declaration_this_to_capture_this_reference_2399", message: "Duplicate identifier '_this'. Compiler uses variable declaration '_this' to capture 'this' reference." }, + Expression_resolves_to_variable_declaration_this_that_compiler_uses_to_capture_this_reference: { code: 2400, category: ts.DiagnosticCategory.Error, key: "Expression_resolves_to_variable_declaration_this_that_compiler_uses_to_capture_this_reference_2400", message: "Expression resolves to variable declaration '_this' that compiler uses to capture 'this' reference." }, + Duplicate_identifier_super_Compiler_uses_super_to_capture_base_class_reference: { code: 2401, category: ts.DiagnosticCategory.Error, key: "Duplicate_identifier_super_Compiler_uses_super_to_capture_base_class_reference_2401", message: "Duplicate identifier '_super'. Compiler uses '_super' to capture base class reference." }, + Expression_resolves_to_super_that_compiler_uses_to_capture_base_class_reference: { code: 2402, category: ts.DiagnosticCategory.Error, key: "Expression_resolves_to_super_that_compiler_uses_to_capture_base_class_reference_2402", message: "Expression resolves to '_super' that compiler uses to capture base class reference." }, + Subsequent_variable_declarations_must_have_the_same_type_Variable_0_must_be_of_type_1_but_here_has_type_2: { code: 2403, category: ts.DiagnosticCategory.Error, key: "Subsequent_variable_declarations_must_have_the_same_type_Variable_0_must_be_of_type_1_but_here_has_t_2403", message: "Subsequent variable declarations must have the same type. Variable '{0}' must be of type '{1}', but here has type '{2}'." }, + The_left_hand_side_of_a_for_in_statement_cannot_use_a_type_annotation: { code: 2404, category: ts.DiagnosticCategory.Error, key: "The_left_hand_side_of_a_for_in_statement_cannot_use_a_type_annotation_2404", message: "The left-hand side of a 'for...in' statement cannot use a type annotation." }, + The_left_hand_side_of_a_for_in_statement_must_be_of_type_string_or_any: { code: 2405, category: ts.DiagnosticCategory.Error, key: "The_left_hand_side_of_a_for_in_statement_must_be_of_type_string_or_any_2405", message: "The left-hand side of a 'for...in' statement must be of type 'string' or 'any'." }, + Invalid_left_hand_side_in_for_in_statement: { code: 2406, category: ts.DiagnosticCategory.Error, key: "Invalid_left_hand_side_in_for_in_statement_2406", message: "Invalid left-hand side in 'for...in' statement." }, + The_right_hand_side_of_a_for_in_statement_must_be_of_type_any_an_object_type_or_a_type_parameter: { code: 2407, category: ts.DiagnosticCategory.Error, key: "The_right_hand_side_of_a_for_in_statement_must_be_of_type_any_an_object_type_or_a_type_parameter_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'." }, + 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}'." }, + Class_name_cannot_be_0: { code: 2414, category: ts.DiagnosticCategory.Error, key: "Class_name_cannot_be_0_2414", message: "Class name cannot be '{0}'" }, + Class_0_incorrectly_extends_base_class_1: { code: 2415, category: ts.DiagnosticCategory.Error, key: "Class_0_incorrectly_extends_base_class_1_2415", message: "Class '{0}' incorrectly extends base class '{1}'." }, + Class_static_side_0_incorrectly_extends_base_class_static_side_1: { code: 2417, category: ts.DiagnosticCategory.Error, key: "Class_static_side_0_incorrectly_extends_base_class_static_side_1_2417", message: "Class static side '{0}' incorrectly extends base class static side '{1}'." }, + Type_name_0_in_extends_clause_does_not_reference_constructor_function_for_0: { code: 2419, category: ts.DiagnosticCategory.Error, key: "Type_name_0_in_extends_clause_does_not_reference_constructor_function_for_0_2419", message: "Type name '{0}' in extends clause does not reference constructor function for '{0}'." }, + Class_0_incorrectly_implements_interface_1: { code: 2420, category: ts.DiagnosticCategory.Error, key: "Class_0_incorrectly_implements_interface_1_2420", message: "Class '{0}' incorrectly implements interface '{1}'." }, + A_class_may_only_implement_another_class_or_interface: { code: 2422, category: ts.DiagnosticCategory.Error, key: "A_class_may_only_implement_another_class_or_interface_2422", message: "A class may only implement another class or interface." }, + Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_accessor: { code: 2423, category: ts.DiagnosticCategory.Error, key: "Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_access_2423", message: "Class '{0}' defines instance member function '{1}', but extended class '{2}' defines it as instance member accessor." }, + Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_property: { code: 2424, category: ts.DiagnosticCategory.Error, key: "Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_proper_2424", message: "Class '{0}' defines instance member function '{1}', but extended class '{2}' defines it as instance member property." }, + Class_0_defines_instance_member_property_1_but_extended_class_2_defines_it_as_instance_member_function: { code: 2425, category: ts.DiagnosticCategory.Error, key: "Class_0_defines_instance_member_property_1_but_extended_class_2_defines_it_as_instance_member_functi_2425", message: "Class '{0}' defines instance member property '{1}', but extended class '{2}' defines it as instance member function." }, + Class_0_defines_instance_member_accessor_1_but_extended_class_2_defines_it_as_instance_member_function: { code: 2426, category: ts.DiagnosticCategory.Error, key: "Class_0_defines_instance_member_accessor_1_but_extended_class_2_defines_it_as_instance_member_functi_2426", message: "Class '{0}' defines instance member accessor '{1}', but extended class '{2}' defines it as instance member function." }, + Interface_name_cannot_be_0: { code: 2427, category: ts.DiagnosticCategory.Error, key: "Interface_name_cannot_be_0_2427", message: "Interface name cannot be '{0}'" }, + All_declarations_of_an_interface_must_have_identical_type_parameters: { code: 2428, category: ts.DiagnosticCategory.Error, key: "All_declarations_of_an_interface_must_have_identical_type_parameters_2428", message: "All declarations of an interface must have identical type parameters." }, + Interface_0_incorrectly_extends_interface_1: { code: 2430, category: ts.DiagnosticCategory.Error, key: "Interface_0_incorrectly_extends_interface_1_2430", message: "Interface '{0}' incorrectly extends interface '{1}'." }, + Enum_name_cannot_be_0: { code: 2431, category: ts.DiagnosticCategory.Error, key: "Enum_name_cannot_be_0_2431", message: "Enum name cannot be '{0}'" }, + In_an_enum_with_multiple_declarations_only_one_declaration_can_omit_an_initializer_for_its_first_enum_element: { code: 2432, category: ts.DiagnosticCategory.Error, key: "In_an_enum_with_multiple_declarations_only_one_declaration_can_omit_an_initializer_for_its_first_enu_2432", message: "In an enum with multiple declarations, only one declaration can omit an initializer for its first enum element." }, + A_namespace_declaration_cannot_be_in_a_different_file_from_a_class_or_function_with_which_it_is_merged: { code: 2433, category: ts.DiagnosticCategory.Error, key: "A_namespace_declaration_cannot_be_in_a_different_file_from_a_class_or_function_with_which_it_is_merg_2433", message: "A namespace declaration cannot be in a different file from a class or function with which it is merged" }, + A_namespace_declaration_cannot_be_located_prior_to_a_class_or_function_with_which_it_is_merged: { code: 2434, category: ts.DiagnosticCategory.Error, key: "A_namespace_declaration_cannot_be_located_prior_to_a_class_or_function_with_which_it_is_merged_2434", message: "A namespace declaration cannot be located prior to a class or function with which it is merged" }, + Ambient_modules_cannot_be_nested_in_other_modules_or_namespaces: { code: 2435, category: ts.DiagnosticCategory.Error, key: "Ambient_modules_cannot_be_nested_in_other_modules_or_namespaces_2435", message: "Ambient modules cannot be nested in other modules or namespaces." }, + Ambient_module_declaration_cannot_specify_relative_module_name: { code: 2436, category: ts.DiagnosticCategory.Error, key: "Ambient_module_declaration_cannot_specify_relative_module_name_2436", message: "Ambient module declaration cannot specify relative module name." }, + Module_0_is_hidden_by_a_local_declaration_with_the_same_name: { code: 2437, category: ts.DiagnosticCategory.Error, key: "Module_0_is_hidden_by_a_local_declaration_with_the_same_name_2437", message: "Module '{0}' is hidden by a local declaration with the same name" }, + Import_name_cannot_be_0: { code: 2438, category: ts.DiagnosticCategory.Error, key: "Import_name_cannot_be_0_2438", message: "Import name cannot be '{0}'" }, + Import_or_export_declaration_in_an_ambient_module_declaration_cannot_reference_module_through_relative_module_name: { code: 2439, category: ts.DiagnosticCategory.Error, key: "Import_or_export_declaration_in_an_ambient_module_declaration_cannot_reference_module_through_relati_2439", message: "Import or export declaration in an ambient module declaration cannot reference module through relative module name." }, + Import_declaration_conflicts_with_local_declaration_of_0: { code: 2440, category: ts.DiagnosticCategory.Error, key: "Import_declaration_conflicts_with_local_declaration_of_0_2440", message: "Import declaration conflicts with local declaration of '{0}'" }, + Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module: { code: 2441, category: ts.DiagnosticCategory.Error, key: "Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module_2441", message: "Duplicate identifier '{0}'. Compiler reserves name '{1}' in top level scope of a module." }, + Types_have_separate_declarations_of_a_private_property_0: { code: 2442, category: ts.DiagnosticCategory.Error, key: "Types_have_separate_declarations_of_a_private_property_0_2442", message: "Types have separate declarations of a private property '{0}'." }, + Property_0_is_protected_but_type_1_is_not_a_class_derived_from_2: { code: 2443, category: ts.DiagnosticCategory.Error, key: "Property_0_is_protected_but_type_1_is_not_a_class_derived_from_2_2443", message: "Property '{0}' is protected but type '{1}' is not a class derived from '{2}'." }, + Property_0_is_protected_in_type_1_but_public_in_type_2: { code: 2444, category: ts.DiagnosticCategory.Error, key: "Property_0_is_protected_in_type_1_but_public_in_type_2_2444", message: "Property '{0}' is protected in type '{1}' but public in type '{2}'." }, + Property_0_is_protected_and_only_accessible_within_class_1_and_its_subclasses: { code: 2445, category: ts.DiagnosticCategory.Error, key: "Property_0_is_protected_and_only_accessible_within_class_1_and_its_subclasses_2445", message: "Property '{0}' is protected and only accessible within class '{1}' and its subclasses." }, + Property_0_is_protected_and_only_accessible_through_an_instance_of_class_1: { code: 2446, category: ts.DiagnosticCategory.Error, key: "Property_0_is_protected_and_only_accessible_through_an_instance_of_class_1_2446", message: "Property '{0}' is protected and only accessible through an instance of class '{1}'." }, + The_0_operator_is_not_allowed_for_boolean_types_Consider_using_1_instead: { code: 2447, category: ts.DiagnosticCategory.Error, key: "The_0_operator_is_not_allowed_for_boolean_types_Consider_using_1_instead_2447", message: "The '{0}' operator is not allowed for boolean types. Consider using '{1}' instead." }, + Block_scoped_variable_0_used_before_its_declaration: { code: 2448, category: ts.DiagnosticCategory.Error, key: "Block_scoped_variable_0_used_before_its_declaration_2448", message: "Block-scoped variable '{0}' used before its declaration." }, + The_operand_of_an_increment_or_decrement_operator_cannot_be_a_constant: { code: 2449, category: ts.DiagnosticCategory.Error, key: "The_operand_of_an_increment_or_decrement_operator_cannot_be_a_constant_2449", message: "The operand of an increment or decrement operator cannot be a constant." }, + Left_hand_side_of_assignment_expression_cannot_be_a_constant: { code: 2450, category: ts.DiagnosticCategory.Error, key: "Left_hand_side_of_assignment_expression_cannot_be_a_constant_2450", message: "Left-hand side of assignment expression cannot be a constant." }, + Cannot_redeclare_block_scoped_variable_0: { code: 2451, category: ts.DiagnosticCategory.Error, key: "Cannot_redeclare_block_scoped_variable_0_2451", message: "Cannot redeclare block-scoped variable '{0}'." }, + An_enum_member_cannot_have_a_numeric_name: { code: 2452, category: ts.DiagnosticCategory.Error, key: "An_enum_member_cannot_have_a_numeric_name_2452", message: "An enum member cannot have a numeric name." }, + The_type_argument_for_type_parameter_0_cannot_be_inferred_from_the_usage_Consider_specifying_the_type_arguments_explicitly: { code: 2453, category: ts.DiagnosticCategory.Error, key: "The_type_argument_for_type_parameter_0_cannot_be_inferred_from_the_usage_Consider_specifying_the_typ_2453", message: "The type argument for type parameter '{0}' cannot be inferred from the usage. Consider specifying the type arguments explicitly." }, + Type_argument_candidate_1_is_not_a_valid_type_argument_because_it_is_not_a_supertype_of_candidate_0: { code: 2455, category: ts.DiagnosticCategory.Error, key: "Type_argument_candidate_1_is_not_a_valid_type_argument_because_it_is_not_a_supertype_of_candidate_0_2455", message: "Type argument candidate '{1}' is not a valid type argument because it is not a supertype of candidate '{0}'." }, + Type_alias_0_circularly_references_itself: { code: 2456, category: ts.DiagnosticCategory.Error, key: "Type_alias_0_circularly_references_itself_2456", message: "Type alias '{0}' circularly references itself." }, + Type_alias_name_cannot_be_0: { code: 2457, category: ts.DiagnosticCategory.Error, key: "Type_alias_name_cannot_be_0_2457", message: "Type alias name cannot be '{0}'" }, + An_AMD_module_cannot_have_multiple_name_assignments: { code: 2458, category: ts.DiagnosticCategory.Error, key: "An_AMD_module_cannot_have_multiple_name_assignments_2458", message: "An AMD module cannot have multiple name assignments." }, + Type_0_has_no_property_1_and_no_string_index_signature: { code: 2459, category: ts.DiagnosticCategory.Error, key: "Type_0_has_no_property_1_and_no_string_index_signature_2459", message: "Type '{0}' has no property '{1}' and no string index signature." }, + Type_0_has_no_property_1: { code: 2460, category: ts.DiagnosticCategory.Error, key: "Type_0_has_no_property_1_2460", message: "Type '{0}' has no property '{1}'." }, + Type_0_is_not_an_array_type: { code: 2461, category: ts.DiagnosticCategory.Error, key: "Type_0_is_not_an_array_type_2461", message: "Type '{0}' is not an array type." }, + A_rest_element_must_be_last_in_an_array_destructuring_pattern: { code: 2462, category: ts.DiagnosticCategory.Error, key: "A_rest_element_must_be_last_in_an_array_destructuring_pattern_2462", message: "A rest element must be last in an array destructuring pattern" }, + A_binding_pattern_parameter_cannot_be_optional_in_an_implementation_signature: { code: 2463, category: ts.DiagnosticCategory.Error, key: "A_binding_pattern_parameter_cannot_be_optional_in_an_implementation_signature_2463", message: "A binding pattern parameter cannot be optional in an implementation signature." }, + A_computed_property_name_must_be_of_type_string_number_symbol_or_any: { code: 2464, category: ts.DiagnosticCategory.Error, key: "A_computed_property_name_must_be_of_type_string_number_symbol_or_any_2464", message: "A computed property name must be of type 'string', 'number', 'symbol', or 'any'." }, + this_cannot_be_referenced_in_a_computed_property_name: { code: 2465, category: ts.DiagnosticCategory.Error, key: "this_cannot_be_referenced_in_a_computed_property_name_2465", message: "'this' cannot be referenced in a computed property name." }, + super_cannot_be_referenced_in_a_computed_property_name: { code: 2466, category: ts.DiagnosticCategory.Error, key: "super_cannot_be_referenced_in_a_computed_property_name_2466", message: "'super' cannot be referenced in a computed property name." }, + A_computed_property_name_cannot_reference_a_type_parameter_from_its_containing_type: { code: 2467, category: ts.DiagnosticCategory.Error, key: "A_computed_property_name_cannot_reference_a_type_parameter_from_its_containing_type_2467", message: "A computed property name cannot reference a type parameter from its containing type." }, + Cannot_find_global_value_0: { code: 2468, category: ts.DiagnosticCategory.Error, key: "Cannot_find_global_value_0_2468", message: "Cannot find global value '{0}'." }, + The_0_operator_cannot_be_applied_to_type_symbol: { code: 2469, category: ts.DiagnosticCategory.Error, key: "The_0_operator_cannot_be_applied_to_type_symbol_2469", message: "The '{0}' operator cannot be applied to type 'symbol'." }, + Symbol_reference_does_not_refer_to_the_global_Symbol_constructor_object: { code: 2470, category: ts.DiagnosticCategory.Error, key: "Symbol_reference_does_not_refer_to_the_global_Symbol_constructor_object_2470", message: "'Symbol' reference does not refer to the global Symbol constructor object." }, + A_computed_property_name_of_the_form_0_must_be_of_type_symbol: { code: 2471, category: ts.DiagnosticCategory.Error, key: "A_computed_property_name_of_the_form_0_must_be_of_type_symbol_2471", message: "A computed property name of the form '{0}' must be of type 'symbol'." }, + Spread_operator_in_new_expressions_is_only_available_when_targeting_ECMAScript_5_and_higher: { code: 2472, category: ts.DiagnosticCategory.Error, key: "Spread_operator_in_new_expressions_is_only_available_when_targeting_ECMAScript_5_and_higher_2472", message: "Spread operator in 'new' expressions is only available when targeting ECMAScript 5 and higher." }, + Enum_declarations_must_all_be_const_or_non_const: { code: 2473, category: ts.DiagnosticCategory.Error, key: "Enum_declarations_must_all_be_const_or_non_const_2473", message: "Enum declarations must all be const or non-const." }, + In_const_enum_declarations_member_initializer_must_be_constant_expression: { code: 2474, category: ts.DiagnosticCategory.Error, key: "In_const_enum_declarations_member_initializer_must_be_constant_expression_2474", message: "In 'const' enum declarations member initializer must be constant expression." }, + const_enums_can_only_be_used_in_property_or_index_access_expressions_or_the_right_hand_side_of_an_import_declaration_or_export_assignment: { code: 2475, category: ts.DiagnosticCategory.Error, key: "const_enums_can_only_be_used_in_property_or_index_access_expressions_or_the_right_hand_side_of_an_im_2475", message: "'const' enums can only be used in property or index access expressions or the right hand side of an import declaration or export assignment." }, + A_const_enum_member_can_only_be_accessed_using_a_string_literal: { code: 2476, category: ts.DiagnosticCategory.Error, key: "A_const_enum_member_can_only_be_accessed_using_a_string_literal_2476", message: "A const enum member can only be accessed using a string literal." }, + const_enum_member_initializer_was_evaluated_to_a_non_finite_value: { code: 2477, category: ts.DiagnosticCategory.Error, key: "const_enum_member_initializer_was_evaluated_to_a_non_finite_value_2477", message: "'const' enum member initializer was evaluated to a non-finite value." }, + const_enum_member_initializer_was_evaluated_to_disallowed_value_NaN: { code: 2478, category: ts.DiagnosticCategory.Error, key: "const_enum_member_initializer_was_evaluated_to_disallowed_value_NaN_2478", message: "'const' enum member initializer was evaluated to disallowed value 'NaN'." }, + Property_0_does_not_exist_on_const_enum_1: { code: 2479, category: ts.DiagnosticCategory.Error, key: "Property_0_does_not_exist_on_const_enum_1_2479", message: "Property '{0}' does not exist on 'const' enum '{1}'." }, + let_is_not_allowed_to_be_used_as_a_name_in_let_or_const_declarations: { code: 2480, category: ts.DiagnosticCategory.Error, key: "let_is_not_allowed_to_be_used_as_a_name_in_let_or_const_declarations_2480", message: "'let' is not allowed to be used as a name in 'let' or 'const' declarations." }, + Cannot_initialize_outer_scoped_variable_0_in_the_same_scope_as_block_scoped_declaration_1: { code: 2481, category: ts.DiagnosticCategory.Error, key: "Cannot_initialize_outer_scoped_variable_0_in_the_same_scope_as_block_scoped_declaration_1_2481", message: "Cannot initialize outer scoped variable '{0}' in the same scope as block scoped declaration '{1}'." }, + The_left_hand_side_of_a_for_of_statement_cannot_use_a_type_annotation: { code: 2483, category: ts.DiagnosticCategory.Error, key: "The_left_hand_side_of_a_for_of_statement_cannot_use_a_type_annotation_2483", message: "The left-hand side of a 'for...of' statement cannot use a type annotation." }, + Export_declaration_conflicts_with_exported_declaration_of_0: { code: 2484, category: ts.DiagnosticCategory.Error, key: "Export_declaration_conflicts_with_exported_declaration_of_0_2484", message: "Export declaration conflicts with exported declaration of '{0}'" }, + The_left_hand_side_of_a_for_of_statement_cannot_be_a_previously_defined_constant: { code: 2485, category: ts.DiagnosticCategory.Error, key: "The_left_hand_side_of_a_for_of_statement_cannot_be_a_previously_defined_constant_2485", message: "The left-hand side of a 'for...of' statement cannot be a previously defined constant." }, + The_left_hand_side_of_a_for_in_statement_cannot_be_a_previously_defined_constant: { code: 2486, category: ts.DiagnosticCategory.Error, key: "The_left_hand_side_of_a_for_in_statement_cannot_be_a_previously_defined_constant_2486", message: "The left-hand side of a 'for...in' statement cannot be a previously defined constant." }, + Invalid_left_hand_side_in_for_of_statement: { code: 2487, category: ts.DiagnosticCategory.Error, key: "Invalid_left_hand_side_in_for_of_statement_2487", message: "Invalid left-hand side in 'for...of' statement." }, + Type_must_have_a_Symbol_iterator_method_that_returns_an_iterator: { code: 2488, category: ts.DiagnosticCategory.Error, key: "Type_must_have_a_Symbol_iterator_method_that_returns_an_iterator_2488", message: "Type must have a '[Symbol.iterator]()' method that returns an iterator." }, + An_iterator_must_have_a_next_method: { code: 2489, category: ts.DiagnosticCategory.Error, key: "An_iterator_must_have_a_next_method_2489", message: "An iterator must have a 'next()' method." }, + The_type_returned_by_the_next_method_of_an_iterator_must_have_a_value_property: { code: 2490, category: ts.DiagnosticCategory.Error, key: "The_type_returned_by_the_next_method_of_an_iterator_must_have_a_value_property_2490", message: "The type returned by the 'next()' method of an iterator must have a 'value' property." }, + The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern: { code: 2491, category: ts.DiagnosticCategory.Error, key: "The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern_2491", message: "The left-hand side of a 'for...in' statement cannot be a destructuring pattern." }, + Cannot_redeclare_identifier_0_in_catch_clause: { code: 2492, category: ts.DiagnosticCategory.Error, key: "Cannot_redeclare_identifier_0_in_catch_clause_2492", message: "Cannot redeclare identifier '{0}' in catch clause" }, + Tuple_type_0_with_length_1_cannot_be_assigned_to_tuple_with_length_2: { code: 2493, category: ts.DiagnosticCategory.Error, key: "Tuple_type_0_with_length_1_cannot_be_assigned_to_tuple_with_length_2_2493", message: "Tuple type '{0}' with length '{1}' cannot be assigned to tuple with length '{2}'." }, + Using_a_string_in_a_for_of_statement_is_only_supported_in_ECMAScript_5_and_higher: { code: 2494, category: ts.DiagnosticCategory.Error, key: "Using_a_string_in_a_for_of_statement_is_only_supported_in_ECMAScript_5_and_higher_2494", message: "Using a string in a 'for...of' statement is only supported in ECMAScript 5 and higher." }, + Type_0_is_not_an_array_type_or_a_string_type: { code: 2495, category: ts.DiagnosticCategory.Error, key: "Type_0_is_not_an_array_type_or_a_string_type_2495", message: "Type '{0}' is not an array type or a string type." }, + The_arguments_object_cannot_be_referenced_in_an_arrow_function_in_ES3_and_ES5_Consider_using_a_standard_function_expression: { code: 2496, category: ts.DiagnosticCategory.Error, key: "The_arguments_object_cannot_be_referenced_in_an_arrow_function_in_ES3_and_ES5_Consider_using_a_stand_2496", message: "The 'arguments' object cannot be referenced in an arrow function in ES3 and ES5. Consider using a standard function expression." }, + Module_0_resolves_to_a_non_module_entity_and_cannot_be_imported_using_this_construct: { code: 2497, category: ts.DiagnosticCategory.Error, key: "Module_0_resolves_to_a_non_module_entity_and_cannot_be_imported_using_this_construct_2497", message: "Module '{0}' resolves to a non-module entity and cannot be imported using this construct." }, + Module_0_uses_export_and_cannot_be_used_with_export_Asterisk: { code: 2498, category: ts.DiagnosticCategory.Error, key: "Module_0_uses_export_and_cannot_be_used_with_export_Asterisk_2498", message: "Module '{0}' uses 'export =' and cannot be used with 'export *'." }, + An_interface_can_only_extend_an_identifier_Slashqualified_name_with_optional_type_arguments: { code: 2499, category: ts.DiagnosticCategory.Error, key: "An_interface_can_only_extend_an_identifier_Slashqualified_name_with_optional_type_arguments_2499", message: "An interface can only extend an identifier/qualified-name with optional type arguments." }, + A_class_can_only_implement_an_identifier_Slashqualified_name_with_optional_type_arguments: { code: 2500, category: ts.DiagnosticCategory.Error, key: "A_class_can_only_implement_an_identifier_Slashqualified_name_with_optional_type_arguments_2500", message: "A class can only implement an identifier/qualified-name with optional type arguments." }, + A_rest_element_cannot_contain_a_binding_pattern: { code: 2501, category: ts.DiagnosticCategory.Error, key: "A_rest_element_cannot_contain_a_binding_pattern_2501", message: "A rest element cannot contain a binding pattern." }, + _0_is_referenced_directly_or_indirectly_in_its_own_type_annotation: { code: 2502, category: ts.DiagnosticCategory.Error, key: "_0_is_referenced_directly_or_indirectly_in_its_own_type_annotation_2502", message: "'{0}' is referenced directly or indirectly in its own type annotation." }, + Cannot_find_namespace_0: { code: 2503, category: ts.DiagnosticCategory.Error, key: "Cannot_find_namespace_0_2503", message: "Cannot find namespace '{0}'." }, + No_best_common_type_exists_among_yield_expressions: { code: 2504, category: ts.DiagnosticCategory.Error, key: "No_best_common_type_exists_among_yield_expressions_2504", message: "No best common type exists among yield expressions." }, + A_generator_cannot_have_a_void_type_annotation: { code: 2505, category: ts.DiagnosticCategory.Error, key: "A_generator_cannot_have_a_void_type_annotation_2505", message: "A generator cannot have a 'void' type annotation." }, + _0_is_referenced_directly_or_indirectly_in_its_own_base_expression: { code: 2506, category: ts.DiagnosticCategory.Error, key: "_0_is_referenced_directly_or_indirectly_in_its_own_base_expression_2506", message: "'{0}' is referenced directly or indirectly in its own base expression." }, + Type_0_is_not_a_constructor_function_type: { code: 2507, category: ts.DiagnosticCategory.Error, key: "Type_0_is_not_a_constructor_function_type_2507", message: "Type '{0}' is not a constructor function type." }, + No_base_constructor_has_the_specified_number_of_type_arguments: { code: 2508, category: ts.DiagnosticCategory.Error, key: "No_base_constructor_has_the_specified_number_of_type_arguments_2508", message: "No base constructor has the specified number of type arguments." }, + Base_constructor_return_type_0_is_not_a_class_or_interface_type: { code: 2509, category: ts.DiagnosticCategory.Error, key: "Base_constructor_return_type_0_is_not_a_class_or_interface_type_2509", message: "Base constructor return type '{0}' is not a class or interface type." }, + Base_constructors_must_all_have_the_same_return_type: { code: 2510, category: ts.DiagnosticCategory.Error, key: "Base_constructors_must_all_have_the_same_return_type_2510", message: "Base constructors must all have the same return type." }, + Cannot_create_an_instance_of_the_abstract_class_0: { code: 2511, category: ts.DiagnosticCategory.Error, key: "Cannot_create_an_instance_of_the_abstract_class_0_2511", message: "Cannot create an instance of the abstract class '{0}'." }, + Overload_signatures_must_all_be_abstract_or_not_abstract: { code: 2512, category: ts.DiagnosticCategory.Error, key: "Overload_signatures_must_all_be_abstract_or_not_abstract_2512", message: "Overload signatures must all be abstract or not abstract." }, + Abstract_method_0_in_class_1_cannot_be_accessed_via_super_expression: { code: 2513, category: ts.DiagnosticCategory.Error, key: "Abstract_method_0_in_class_1_cannot_be_accessed_via_super_expression_2513", message: "Abstract method '{0}' in class '{1}' cannot be accessed via super expression." }, + Classes_containing_abstract_methods_must_be_marked_abstract: { code: 2514, category: ts.DiagnosticCategory.Error, key: "Classes_containing_abstract_methods_must_be_marked_abstract_2514", message: "Classes containing abstract methods must be marked abstract." }, + Non_abstract_class_0_does_not_implement_inherited_abstract_member_1_from_class_2: { code: 2515, category: ts.DiagnosticCategory.Error, key: "Non_abstract_class_0_does_not_implement_inherited_abstract_member_1_from_class_2_2515", message: "Non-abstract class '{0}' does not implement inherited abstract member '{1}' from class '{2}'." }, + All_declarations_of_an_abstract_method_must_be_consecutive: { code: 2516, category: ts.DiagnosticCategory.Error, key: "All_declarations_of_an_abstract_method_must_be_consecutive_2516", message: "All declarations of an abstract method must be consecutive." }, + Cannot_assign_an_abstract_constructor_type_to_a_non_abstract_constructor_type: { code: 2517, category: ts.DiagnosticCategory.Error, key: "Cannot_assign_an_abstract_constructor_type_to_a_non_abstract_constructor_type_2517", message: "Cannot assign an abstract constructor type to a non-abstract constructor type." }, + Duplicate_identifier_0_Compiler_uses_declaration_1_to_support_async_functions: { code: 2520, category: ts.DiagnosticCategory.Error, key: "Duplicate_identifier_0_Compiler_uses_declaration_1_to_support_async_functions_2520", message: "Duplicate identifier '{0}'. Compiler uses declaration '{1}' to support async functions." }, + Expression_resolves_to_variable_declaration_0_that_compiler_uses_to_support_async_functions: { code: 2521, category: ts.DiagnosticCategory.Error, key: "Expression_resolves_to_variable_declaration_0_that_compiler_uses_to_support_async_functions_2521", message: "Expression resolves to variable declaration '{0}' that compiler uses to support async functions." }, + The_arguments_object_cannot_be_referenced_in_an_async_arrow_function_Consider_using_a_standard_async_function_expression: { code: 2522, category: ts.DiagnosticCategory.Error, key: "The_arguments_object_cannot_be_referenced_in_an_async_arrow_function_Consider_using_a_standard_async_2522", message: "The 'arguments' object cannot be referenced in an async arrow function. Consider using a standard async function expression." }, + yield_expressions_cannot_be_used_in_a_parameter_initializer: { code: 2523, category: ts.DiagnosticCategory.Error, key: "yield_expressions_cannot_be_used_in_a_parameter_initializer_2523", message: "'yield' expressions cannot be used in a parameter initializer." }, + await_expressions_cannot_be_used_in_a_parameter_initializer: { code: 2524, category: ts.DiagnosticCategory.Error, key: "await_expressions_cannot_be_used_in_a_parameter_initializer_2524", message: "'await' expressions cannot be used in a parameter initializer." }, + Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value: { code: 2525, category: ts.DiagnosticCategory.Error, key: "Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value_2525", message: "Initializer provides no value for this binding element and the binding element has no default value." }, + A_this_type_is_available_only_in_a_non_static_member_of_a_class_or_interface: { code: 2526, category: ts.DiagnosticCategory.Error, key: "A_this_type_is_available_only_in_a_non_static_member_of_a_class_or_interface_2526", message: "A 'this' type is available only in a non-static member of a class or interface." }, + The_inferred_type_of_0_references_an_inaccessible_this_type_A_type_annotation_is_necessary: { code: 2527, category: ts.DiagnosticCategory.Error, key: "The_inferred_type_of_0_references_an_inaccessible_this_type_A_type_annotation_is_necessary_2527", message: "The inferred type of '{0}' references an inaccessible 'this' type. A type annotation is necessary." }, + A_module_cannot_have_multiple_default_exports: { code: 2528, category: ts.DiagnosticCategory.Error, key: "A_module_cannot_have_multiple_default_exports_2528", message: "A module cannot have multiple default exports." }, + JSX_element_attributes_type_0_must_be_an_object_type: { code: 2600, category: ts.DiagnosticCategory.Error, key: "JSX_element_attributes_type_0_must_be_an_object_type_2600", message: "JSX element attributes type '{0}' must be an object type." }, + The_return_type_of_a_JSX_element_constructor_must_return_an_object_type: { code: 2601, category: ts.DiagnosticCategory.Error, key: "The_return_type_of_a_JSX_element_constructor_must_return_an_object_type_2601", message: "The return type of a JSX element constructor must return an object type." }, + JSX_element_implicitly_has_type_any_because_the_global_type_JSX_Element_does_not_exist: { code: 2602, category: ts.DiagnosticCategory.Error, key: "JSX_element_implicitly_has_type_any_because_the_global_type_JSX_Element_does_not_exist_2602", message: "JSX element implicitly has type 'any' because the global type 'JSX.Element' does not exist." }, + Property_0_in_type_1_is_not_assignable_to_type_2: { code: 2603, category: ts.DiagnosticCategory.Error, key: "Property_0_in_type_1_is_not_assignable_to_type_2_2603", message: "Property '{0}' in type '{1}' is not assignable to type '{2}'" }, + JSX_element_type_0_does_not_have_any_construct_or_call_signatures: { code: 2604, category: ts.DiagnosticCategory.Error, key: "JSX_element_type_0_does_not_have_any_construct_or_call_signatures_2604", message: "JSX element type '{0}' does not have any construct or call signatures." }, + JSX_element_type_0_is_not_a_constructor_function_for_JSX_elements: { code: 2605, category: ts.DiagnosticCategory.Error, key: "JSX_element_type_0_is_not_a_constructor_function_for_JSX_elements_2605", message: "JSX element type '{0}' is not a constructor function for JSX elements." }, + Property_0_of_JSX_spread_attribute_is_not_assignable_to_target_property: { code: 2606, category: ts.DiagnosticCategory.Error, key: "Property_0_of_JSX_spread_attribute_is_not_assignable_to_target_property_2606", message: "Property '{0}' of JSX spread attribute is not assignable to target property." }, + JSX_element_class_does_not_support_attributes_because_it_does_not_have_a_0_property: { code: 2607, category: ts.DiagnosticCategory.Error, key: "JSX_element_class_does_not_support_attributes_because_it_does_not_have_a_0_property_2607", message: "JSX element class does not support attributes because it does not have a '{0}' property" }, + The_global_type_JSX_0_may_not_have_more_than_one_property: { code: 2608, category: ts.DiagnosticCategory.Error, key: "The_global_type_JSX_0_may_not_have_more_than_one_property_2608", message: "The global type 'JSX.{0}' may not have more than one property" }, + Cannot_emit_namespaced_JSX_elements_in_React: { code: 2650, category: ts.DiagnosticCategory.Error, key: "Cannot_emit_namespaced_JSX_elements_in_React_2650", message: "Cannot emit namespaced JSX elements in React" }, + A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_enums: { code: 2651, category: ts.DiagnosticCategory.Error, key: "A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_memb_2651", message: "A member initializer in a enum declaration cannot reference members declared after it, including members defined in other enums." }, + Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_default_0_declaration_instead: { code: 2652, category: ts.DiagnosticCategory.Error, key: "Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_d_2652", message: "Merged declaration '{0}' cannot include a default export declaration. Consider adding a separate 'export default {0}' declaration instead." }, + Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1: { code: 2653, category: ts.DiagnosticCategory.Error, key: "Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1_2653", message: "Non-abstract class expression does not implement inherited abstract member '{0}' from class '{1}'." }, + Exported_external_package_typings_file_cannot_contain_tripleslash_references_Please_contact_the_package_author_to_update_the_package_definition: { code: 2654, category: ts.DiagnosticCategory.Error, key: "Exported_external_package_typings_file_cannot_contain_tripleslash_references_Please_contact_the_pack_2654", message: "Exported external package typings file cannot contain tripleslash references. Please contact the package author to update the package definition." }, + Exported_external_package_typings_file_0_is_not_a_module_Please_contact_the_package_author_to_update_the_package_definition: { code: 2656, category: ts.DiagnosticCategory.Error, key: "Exported_external_package_typings_file_0_is_not_a_module_Please_contact_the_package_author_to_update_2656", message: "Exported external package typings file '{0}' is not a module. Please contact the package author to update the package definition." }, + JSX_expressions_must_have_one_parent_element: { code: 2657, category: ts.DiagnosticCategory.Error, key: "JSX_expressions_must_have_one_parent_element_2657", message: "JSX expressions must have one parent element" }, + Import_declaration_0_is_using_private_name_1: { code: 4000, category: ts.DiagnosticCategory.Error, key: "Import_declaration_0_is_using_private_name_1_4000", message: "Import declaration '{0}' is using private name '{1}'." }, + Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: { code: 4002, category: ts.DiagnosticCategory.Error, key: "Type_parameter_0_of_exported_class_has_or_is_using_private_name_1_4002", message: "Type parameter '{0}' of exported class has or is using private name '{1}'." }, + Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1: { code: 4004, category: ts.DiagnosticCategory.Error, key: "Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1_4004", message: "Type parameter '{0}' of exported interface has or is using private name '{1}'." }, + Type_parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1: { code: 4006, category: ts.DiagnosticCategory.Error, key: "Type_parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1_4006", message: "Type parameter '{0}' of constructor signature from exported interface has or is using private name '{1}'." }, + Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1: { code: 4008, category: ts.DiagnosticCategory.Error, key: "Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1_4008", message: "Type parameter '{0}' of call signature from exported interface has or is using private name '{1}'." }, + Type_parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1: { code: 4010, category: ts.DiagnosticCategory.Error, key: "Type_parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1_4010", message: "Type parameter '{0}' of public static method from exported class has or is using private name '{1}'." }, + Type_parameter_0_of_public_method_from_exported_class_has_or_is_using_private_name_1: { code: 4012, category: ts.DiagnosticCategory.Error, key: "Type_parameter_0_of_public_method_from_exported_class_has_or_is_using_private_name_1_4012", message: "Type parameter '{0}' of public method from exported class has or is using private name '{1}'." }, + Type_parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1: { code: 4014, category: ts.DiagnosticCategory.Error, key: "Type_parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1_4014", message: "Type parameter '{0}' of method from exported interface has or is using private name '{1}'." }, + Type_parameter_0_of_exported_function_has_or_is_using_private_name_1: { code: 4016, category: ts.DiagnosticCategory.Error, key: "Type_parameter_0_of_exported_function_has_or_is_using_private_name_1_4016", message: "Type parameter '{0}' of exported function has or is using private name '{1}'." }, + Implements_clause_of_exported_class_0_has_or_is_using_private_name_1: { code: 4019, category: ts.DiagnosticCategory.Error, key: "Implements_clause_of_exported_class_0_has_or_is_using_private_name_1_4019", message: "Implements clause of exported class '{0}' has or is using private name '{1}'." }, + Extends_clause_of_exported_class_0_has_or_is_using_private_name_1: { code: 4020, category: ts.DiagnosticCategory.Error, key: "Extends_clause_of_exported_class_0_has_or_is_using_private_name_1_4020", message: "Extends clause of exported class '{0}' has or is using private name '{1}'." }, + Extends_clause_of_exported_interface_0_has_or_is_using_private_name_1: { code: 4022, category: ts.DiagnosticCategory.Error, key: "Extends_clause_of_exported_interface_0_has_or_is_using_private_name_1_4022", message: "Extends clause of exported interface '{0}' has or is using private name '{1}'." }, + Exported_variable_0_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: { code: 4023, category: ts.DiagnosticCategory.Error, key: "Exported_variable_0_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named_4023", message: "Exported variable '{0}' has or is using name '{1}' from external module {2} but cannot be named." }, + Exported_variable_0_has_or_is_using_name_1_from_private_module_2: { code: 4024, category: ts.DiagnosticCategory.Error, key: "Exported_variable_0_has_or_is_using_name_1_from_private_module_2_4024", message: "Exported variable '{0}' has or is using name '{1}' from private module '{2}'." }, + Exported_variable_0_has_or_is_using_private_name_1: { code: 4025, category: ts.DiagnosticCategory.Error, key: "Exported_variable_0_has_or_is_using_private_name_1_4025", message: "Exported variable '{0}' has or is using private name '{1}'." }, + Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: { code: 4026, category: ts.DiagnosticCategory.Error, key: "Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot__4026", message: "Public static property '{0}' of exported class has or is using name '{1}' from external module {2} but cannot be named." }, + Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2: { code: 4027, category: ts.DiagnosticCategory.Error, key: "Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2_4027", message: "Public static property '{0}' of exported class has or is using name '{1}' from private module '{2}'." }, + Public_static_property_0_of_exported_class_has_or_is_using_private_name_1: { code: 4028, category: ts.DiagnosticCategory.Error, key: "Public_static_property_0_of_exported_class_has_or_is_using_private_name_1_4028", message: "Public static property '{0}' of exported class has or is using private name '{1}'." }, + Public_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: { code: 4029, category: ts.DiagnosticCategory.Error, key: "Public_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_name_4029", message: "Public property '{0}' of exported class has or is using name '{1}' from external module {2} but cannot be named." }, + Public_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2: { code: 4030, category: ts.DiagnosticCategory.Error, key: "Public_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2_4030", message: "Public property '{0}' of exported class has or is using name '{1}' from private module '{2}'." }, + Public_property_0_of_exported_class_has_or_is_using_private_name_1: { code: 4031, category: ts.DiagnosticCategory.Error, key: "Public_property_0_of_exported_class_has_or_is_using_private_name_1_4031", message: "Public property '{0}' of exported class has or is using private name '{1}'." }, + Property_0_of_exported_interface_has_or_is_using_name_1_from_private_module_2: { code: 4032, category: ts.DiagnosticCategory.Error, key: "Property_0_of_exported_interface_has_or_is_using_name_1_from_private_module_2_4032", message: "Property '{0}' of exported interface has or is using name '{1}' from private module '{2}'." }, + Property_0_of_exported_interface_has_or_is_using_private_name_1: { code: 4033, category: ts.DiagnosticCategory.Error, key: "Property_0_of_exported_interface_has_or_is_using_private_name_1_4033", message: "Property '{0}' of exported interface has or is using private name '{1}'." }, + Parameter_0_of_public_static_property_setter_from_exported_class_has_or_is_using_name_1_from_private_module_2: { code: 4034, category: ts.DiagnosticCategory.Error, key: "Parameter_0_of_public_static_property_setter_from_exported_class_has_or_is_using_name_1_from_private_4034", message: "Parameter '{0}' of public static property setter from exported class has or is using name '{1}' from private module '{2}'." }, + Parameter_0_of_public_static_property_setter_from_exported_class_has_or_is_using_private_name_1: { code: 4035, category: ts.DiagnosticCategory.Error, key: "Parameter_0_of_public_static_property_setter_from_exported_class_has_or_is_using_private_name_1_4035", message: "Parameter '{0}' of public static property setter from exported class has or is using private name '{1}'." }, + Parameter_0_of_public_property_setter_from_exported_class_has_or_is_using_name_1_from_private_module_2: { code: 4036, category: ts.DiagnosticCategory.Error, key: "Parameter_0_of_public_property_setter_from_exported_class_has_or_is_using_name_1_from_private_module_4036", message: "Parameter '{0}' of public property setter from exported class has or is using name '{1}' from private module '{2}'." }, + Parameter_0_of_public_property_setter_from_exported_class_has_or_is_using_private_name_1: { code: 4037, category: ts.DiagnosticCategory.Error, key: "Parameter_0_of_public_property_setter_from_exported_class_has_or_is_using_private_name_1_4037", message: "Parameter '{0}' of public property setter from exported class has or is using private name '{1}'." }, + Return_type_of_public_static_property_getter_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named: { code: 4038, category: ts.DiagnosticCategory.Error, key: "Return_type_of_public_static_property_getter_from_exported_class_has_or_is_using_name_0_from_externa_4038", message: "Return type of public static property getter from exported class has or is using name '{0}' from external module {1} but cannot be named." }, + Return_type_of_public_static_property_getter_from_exported_class_has_or_is_using_name_0_from_private_module_1: { code: 4039, category: ts.DiagnosticCategory.Error, key: "Return_type_of_public_static_property_getter_from_exported_class_has_or_is_using_name_0_from_private_4039", message: "Return type of public static property getter from exported class has or is using name '{0}' from private module '{1}'." }, + Return_type_of_public_static_property_getter_from_exported_class_has_or_is_using_private_name_0: { code: 4040, category: ts.DiagnosticCategory.Error, key: "Return_type_of_public_static_property_getter_from_exported_class_has_or_is_using_private_name_0_4040", message: "Return type of public static property getter from exported class has or is using private name '{0}'." }, + Return_type_of_public_property_getter_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named: { code: 4041, category: ts.DiagnosticCategory.Error, key: "Return_type_of_public_property_getter_from_exported_class_has_or_is_using_name_0_from_external_modul_4041", message: "Return type of public property getter from exported class has or is using name '{0}' from external module {1} but cannot be named." }, + Return_type_of_public_property_getter_from_exported_class_has_or_is_using_name_0_from_private_module_1: { code: 4042, category: ts.DiagnosticCategory.Error, key: "Return_type_of_public_property_getter_from_exported_class_has_or_is_using_name_0_from_private_module_4042", message: "Return type of public property getter from exported class has or is using name '{0}' from private module '{1}'." }, + Return_type_of_public_property_getter_from_exported_class_has_or_is_using_private_name_0: { code: 4043, category: ts.DiagnosticCategory.Error, key: "Return_type_of_public_property_getter_from_exported_class_has_or_is_using_private_name_0_4043", message: "Return type of public property getter from exported class has or is using private name '{0}'." }, + Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1: { code: 4044, category: ts.DiagnosticCategory.Error, key: "Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_name_0_from_private_mod_4044", message: "Return type of constructor signature from exported interface has or is using name '{0}' from private module '{1}'." }, + Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_0: { code: 4045, category: ts.DiagnosticCategory.Error, key: "Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_0_4045", message: "Return type of constructor signature from exported interface has or is using private name '{0}'." }, + Return_type_of_call_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1: { code: 4046, category: ts.DiagnosticCategory.Error, key: "Return_type_of_call_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1_4046", message: "Return type of call signature from exported interface has or is using name '{0}' from private module '{1}'." }, + Return_type_of_call_signature_from_exported_interface_has_or_is_using_private_name_0: { code: 4047, category: ts.DiagnosticCategory.Error, key: "Return_type_of_call_signature_from_exported_interface_has_or_is_using_private_name_0_4047", message: "Return type of call signature from exported interface has or is using private name '{0}'." }, + Return_type_of_index_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1: { code: 4048, category: ts.DiagnosticCategory.Error, key: "Return_type_of_index_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1_4048", message: "Return type of index signature from exported interface has or is using name '{0}' from private module '{1}'." }, + Return_type_of_index_signature_from_exported_interface_has_or_is_using_private_name_0: { code: 4049, category: ts.DiagnosticCategory.Error, key: "Return_type_of_index_signature_from_exported_interface_has_or_is_using_private_name_0_4049", message: "Return type of index signature from exported interface has or is using private name '{0}'." }, + Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named: { code: 4050, category: ts.DiagnosticCategory.Error, key: "Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_external_module__4050", message: "Return type of public static method from exported class has or is using name '{0}' from external module {1} but cannot be named." }, + Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_private_module_1: { code: 4051, category: ts.DiagnosticCategory.Error, key: "Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_private_module_1_4051", message: "Return type of public static method from exported class has or is using name '{0}' from private module '{1}'." }, + Return_type_of_public_static_method_from_exported_class_has_or_is_using_private_name_0: { code: 4052, category: ts.DiagnosticCategory.Error, key: "Return_type_of_public_static_method_from_exported_class_has_or_is_using_private_name_0_4052", message: "Return type of public static method from exported class has or is using private name '{0}'." }, + Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named: { code: 4053, category: ts.DiagnosticCategory.Error, key: "Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_c_4053", message: "Return type of public method from exported class has or is using name '{0}' from external module {1} but cannot be named." }, + Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_private_module_1: { code: 4054, category: ts.DiagnosticCategory.Error, key: "Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_private_module_1_4054", message: "Return type of public method from exported class has or is using name '{0}' from private module '{1}'." }, + Return_type_of_public_method_from_exported_class_has_or_is_using_private_name_0: { code: 4055, category: ts.DiagnosticCategory.Error, key: "Return_type_of_public_method_from_exported_class_has_or_is_using_private_name_0_4055", message: "Return type of public method from exported class has or is using private name '{0}'." }, + Return_type_of_method_from_exported_interface_has_or_is_using_name_0_from_private_module_1: { code: 4056, category: ts.DiagnosticCategory.Error, key: "Return_type_of_method_from_exported_interface_has_or_is_using_name_0_from_private_module_1_4056", message: "Return type of method from exported interface has or is using name '{0}' from private module '{1}'." }, + Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0: { code: 4057, category: ts.DiagnosticCategory.Error, key: "Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0_4057", message: "Return type of method from exported interface has or is using private name '{0}'." }, + Return_type_of_exported_function_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named: { code: 4058, category: ts.DiagnosticCategory.Error, key: "Return_type_of_exported_function_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named_4058", message: "Return type of exported function has or is using name '{0}' from external module {1} but cannot be named." }, + Return_type_of_exported_function_has_or_is_using_name_0_from_private_module_1: { code: 4059, category: ts.DiagnosticCategory.Error, key: "Return_type_of_exported_function_has_or_is_using_name_0_from_private_module_1_4059", message: "Return type of exported function has or is using name '{0}' from private module '{1}'." }, + Return_type_of_exported_function_has_or_is_using_private_name_0: { code: 4060, category: ts.DiagnosticCategory.Error, key: "Return_type_of_exported_function_has_or_is_using_private_name_0_4060", message: "Return type of exported function has or is using private name '{0}'." }, + Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: { code: 4061, category: ts.DiagnosticCategory.Error, key: "Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_can_4061", message: "Parameter '{0}' of constructor from exported class has or is using name '{1}' from external module {2} but cannot be named." }, + Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_private_module_2: { code: 4062, category: ts.DiagnosticCategory.Error, key: "Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_private_module_2_4062", message: "Parameter '{0}' of constructor from exported class has or is using name '{1}' from private module '{2}'." }, + Parameter_0_of_constructor_from_exported_class_has_or_is_using_private_name_1: { code: 4063, category: ts.DiagnosticCategory.Error, key: "Parameter_0_of_constructor_from_exported_class_has_or_is_using_private_name_1_4063", message: "Parameter '{0}' of constructor from exported class has or is using private name '{1}'." }, + Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2: { code: 4064, category: ts.DiagnosticCategory.Error, key: "Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_name_1_from_private_mod_4064", message: "Parameter '{0}' of constructor signature from exported interface has or is using name '{1}' from private module '{2}'." }, + Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1: { code: 4065, category: ts.DiagnosticCategory.Error, key: "Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1_4065", message: "Parameter '{0}' of constructor signature from exported interface has or is using private name '{1}'." }, + Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2: { code: 4066, category: ts.DiagnosticCategory.Error, key: "Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2_4066", message: "Parameter '{0}' of call signature from exported interface has or is using name '{1}' from private module '{2}'." }, + Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1: { code: 4067, category: ts.DiagnosticCategory.Error, key: "Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1_4067", message: "Parameter '{0}' of call signature from exported interface has or is using private name '{1}'." }, + Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: { code: 4068, category: ts.DiagnosticCategory.Error, key: "Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_external_module__4068", message: "Parameter '{0}' of public static method from exported class has or is using name '{1}' from external module {2} but cannot be named." }, + Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_private_module_2: { code: 4069, category: ts.DiagnosticCategory.Error, key: "Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_private_module_2_4069", message: "Parameter '{0}' of public static method from exported class has or is using name '{1}' from private module '{2}'." }, + Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1: { code: 4070, category: ts.DiagnosticCategory.Error, key: "Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1_4070", message: "Parameter '{0}' of public static method from exported class has or is using private name '{1}'." }, + Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: { code: 4071, category: ts.DiagnosticCategory.Error, key: "Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_c_4071", message: "Parameter '{0}' of public method from exported class has or is using name '{1}' from external module {2} but cannot be named." }, + Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_private_module_2: { code: 4072, category: ts.DiagnosticCategory.Error, key: "Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_private_module_2_4072", message: "Parameter '{0}' of public method from exported class has or is using name '{1}' from private module '{2}'." }, + Parameter_0_of_public_method_from_exported_class_has_or_is_using_private_name_1: { code: 4073, category: ts.DiagnosticCategory.Error, key: "Parameter_0_of_public_method_from_exported_class_has_or_is_using_private_name_1_4073", message: "Parameter '{0}' of public method from exported class has or is using private name '{1}'." }, + Parameter_0_of_method_from_exported_interface_has_or_is_using_name_1_from_private_module_2: { code: 4074, category: ts.DiagnosticCategory.Error, key: "Parameter_0_of_method_from_exported_interface_has_or_is_using_name_1_from_private_module_2_4074", message: "Parameter '{0}' of method from exported interface has or is using name '{1}' from private module '{2}'." }, + Parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1: { code: 4075, category: ts.DiagnosticCategory.Error, key: "Parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1_4075", message: "Parameter '{0}' of method from exported interface has or is using private name '{1}'." }, + Parameter_0_of_exported_function_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: { code: 4076, category: ts.DiagnosticCategory.Error, key: "Parameter_0_of_exported_function_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named_4076", message: "Parameter '{0}' of exported function has or is using name '{1}' from external module {2} but cannot be named." }, + Parameter_0_of_exported_function_has_or_is_using_name_1_from_private_module_2: { code: 4077, category: ts.DiagnosticCategory.Error, key: "Parameter_0_of_exported_function_has_or_is_using_name_1_from_private_module_2_4077", message: "Parameter '{0}' of exported function has or is using name '{1}' from private module '{2}'." }, + Parameter_0_of_exported_function_has_or_is_using_private_name_1: { code: 4078, category: ts.DiagnosticCategory.Error, key: "Parameter_0_of_exported_function_has_or_is_using_private_name_1_4078", message: "Parameter '{0}' of exported function has or is using private name '{1}'." }, + Exported_type_alias_0_has_or_is_using_private_name_1: { code: 4081, category: ts.DiagnosticCategory.Error, key: "Exported_type_alias_0_has_or_is_using_private_name_1_4081", message: "Exported type alias '{0}' has or is using private name '{1}'." }, + Default_export_of_the_module_has_or_is_using_private_name_0: { code: 4082, category: ts.DiagnosticCategory.Error, key: "Default_export_of_the_module_has_or_is_using_private_name_0_4082", message: "Default export of the module has or is using private name '{0}'." }, + The_current_host_does_not_support_the_0_option: { code: 5001, category: ts.DiagnosticCategory.Error, key: "The_current_host_does_not_support_the_0_option_5001", message: "The current host does not support the '{0}' option." }, + Cannot_find_the_common_subdirectory_path_for_the_input_files: { code: 5009, category: ts.DiagnosticCategory.Error, key: "Cannot_find_the_common_subdirectory_path_for_the_input_files_5009", message: "Cannot find the common subdirectory path for the input files." }, + Cannot_read_file_0_Colon_1: { code: 5012, category: ts.DiagnosticCategory.Error, key: "Cannot_read_file_0_Colon_1_5012", message: "Cannot read file '{0}': {1}" }, + Unsupported_file_encoding: { code: 5013, category: ts.DiagnosticCategory.Error, key: "Unsupported_file_encoding_5013", message: "Unsupported file encoding." }, + Failed_to_parse_file_0_Colon_1: { code: 5014, category: ts.DiagnosticCategory.Error, key: "Failed_to_parse_file_0_Colon_1_5014", message: "Failed to parse file '{0}': {1}." }, + Unknown_compiler_option_0: { code: 5023, category: ts.DiagnosticCategory.Error, key: "Unknown_compiler_option_0_5023", message: "Unknown compiler option '{0}'." }, + Compiler_option_0_requires_a_value_of_type_1: { code: 5024, category: ts.DiagnosticCategory.Error, key: "Compiler_option_0_requires_a_value_of_type_1_5024", message: "Compiler option '{0}' requires a value of type {1}." }, + Could_not_write_file_0_Colon_1: { code: 5033, category: ts.DiagnosticCategory.Error, key: "Could_not_write_file_0_Colon_1_5033", message: "Could not write file '{0}': {1}" }, + Option_project_cannot_be_mixed_with_source_files_on_a_command_line: { code: 5042, category: ts.DiagnosticCategory.Error, key: "Option_project_cannot_be_mixed_with_source_files_on_a_command_line_5042", message: "Option 'project' cannot be mixed with source files on a command line." }, + Option_isolatedModules_can_only_be_used_when_either_option_module_is_provided_or_option_target_is_ES2015_or_higher: { code: 5047, category: ts.DiagnosticCategory.Error, key: "Option_isolatedModules_can_only_be_used_when_either_option_module_is_provided_or_option_target_is_ES_5047", message: "Option 'isolatedModules' can only be used when either option '--module' is provided or option 'target' is 'ES2015' or higher." }, + Option_inlineSources_can_only_be_used_when_either_option_inlineSourceMap_or_option_sourceMap_is_provided: { code: 5051, category: ts.DiagnosticCategory.Error, key: "Option_inlineSources_can_only_be_used_when_either_option_inlineSourceMap_or_option_sourceMap_is_prov_5051", message: "Option 'inlineSources' can only be used when either option '--inlineSourceMap' or option '--sourceMap' is provided." }, + Option_0_cannot_be_specified_without_specifying_option_1: { code: 5052, category: ts.DiagnosticCategory.Error, key: "Option_0_cannot_be_specified_without_specifying_option_1_5052", message: "Option '{0}' cannot be specified without specifying option '{1}'." }, + Option_0_cannot_be_specified_with_option_1: { code: 5053, category: ts.DiagnosticCategory.Error, key: "Option_0_cannot_be_specified_with_option_1_5053", message: "Option '{0}' cannot be specified with option '{1}'." }, + A_tsconfig_json_file_is_already_defined_at_Colon_0: { code: 5054, category: ts.DiagnosticCategory.Error, key: "A_tsconfig_json_file_is_already_defined_at_Colon_0_5054", message: "A 'tsconfig.json' file is already defined at: '{0}'." }, + Concatenate_and_emit_output_to_single_file: { code: 6001, category: ts.DiagnosticCategory.Message, key: "Concatenate_and_emit_output_to_single_file_6001", message: "Concatenate and emit output to single file." }, + Generates_corresponding_d_ts_file: { code: 6002, category: ts.DiagnosticCategory.Message, key: "Generates_corresponding_d_ts_file_6002", message: "Generates corresponding '.d.ts' file." }, + Specifies_the_location_where_debugger_should_locate_map_files_instead_of_generated_locations: { code: 6003, category: ts.DiagnosticCategory.Message, key: "Specifies_the_location_where_debugger_should_locate_map_files_instead_of_generated_locations_6003", message: "Specifies the location where debugger should locate map files instead of generated locations." }, + Specifies_the_location_where_debugger_should_locate_TypeScript_files_instead_of_source_locations: { code: 6004, category: ts.DiagnosticCategory.Message, key: "Specifies_the_location_where_debugger_should_locate_TypeScript_files_instead_of_source_locations_6004", message: "Specifies the location where debugger should locate TypeScript files instead of source locations." }, + Watch_input_files: { code: 6005, category: ts.DiagnosticCategory.Message, key: "Watch_input_files_6005", message: "Watch input files." }, + Redirect_output_structure_to_the_directory: { code: 6006, category: ts.DiagnosticCategory.Message, key: "Redirect_output_structure_to_the_directory_6006", message: "Redirect output structure to the directory." }, + Do_not_erase_const_enum_declarations_in_generated_code: { code: 6007, category: ts.DiagnosticCategory.Message, key: "Do_not_erase_const_enum_declarations_in_generated_code_6007", message: "Do not erase const enum declarations in generated code." }, + Do_not_emit_outputs_if_any_errors_were_reported: { code: 6008, category: ts.DiagnosticCategory.Message, key: "Do_not_emit_outputs_if_any_errors_were_reported_6008", message: "Do not emit outputs if any errors were reported." }, + Do_not_emit_comments_to_output: { code: 6009, category: ts.DiagnosticCategory.Message, key: "Do_not_emit_comments_to_output_6009", message: "Do not emit comments to output." }, + Do_not_emit_outputs: { code: 6010, category: ts.DiagnosticCategory.Message, key: "Do_not_emit_outputs_6010", message: "Do not emit outputs." }, + Specify_ECMAScript_target_version_Colon_ES3_default_ES5_or_ES2015_experimental: { code: 6015, category: ts.DiagnosticCategory.Message, key: "Specify_ECMAScript_target_version_Colon_ES3_default_ES5_or_ES2015_experimental_6015", message: "Specify ECMAScript target version: 'ES3' (default), 'ES5', or 'ES2015' (experimental)" }, + Specify_module_code_generation_Colon_commonjs_amd_system_umd_or_es2015: { code: 6016, category: ts.DiagnosticCategory.Message, key: "Specify_module_code_generation_Colon_commonjs_amd_system_umd_or_es2015_6016", message: "Specify module code generation: 'commonjs', 'amd', 'system', 'umd' or 'es2015'" }, + Print_this_message: { code: 6017, category: ts.DiagnosticCategory.Message, key: "Print_this_message_6017", message: "Print this message." }, + Print_the_compiler_s_version: { code: 6019, category: ts.DiagnosticCategory.Message, key: "Print_the_compiler_s_version_6019", message: "Print the compiler's version." }, + Compile_the_project_in_the_given_directory: { code: 6020, category: ts.DiagnosticCategory.Message, key: "Compile_the_project_in_the_given_directory_6020", message: "Compile the project in the given directory." }, + Syntax_Colon_0: { code: 6023, category: ts.DiagnosticCategory.Message, key: "Syntax_Colon_0_6023", message: "Syntax: {0}" }, + options: { code: 6024, category: ts.DiagnosticCategory.Message, key: "options_6024", message: "options" }, + file: { code: 6025, category: ts.DiagnosticCategory.Message, key: "file_6025", message: "file" }, + Examples_Colon_0: { code: 6026, category: ts.DiagnosticCategory.Message, key: "Examples_Colon_0_6026", message: "Examples: {0}" }, + Options_Colon: { code: 6027, category: ts.DiagnosticCategory.Message, key: "Options_Colon_6027", message: "Options:" }, + Version_0: { code: 6029, category: ts.DiagnosticCategory.Message, key: "Version_0_6029", message: "Version {0}" }, + Insert_command_line_options_and_files_from_a_file: { code: 6030, category: ts.DiagnosticCategory.Message, key: "Insert_command_line_options_and_files_from_a_file_6030", message: "Insert command line options and files from a file." }, + File_change_detected_Starting_incremental_compilation: { code: 6032, category: ts.DiagnosticCategory.Message, key: "File_change_detected_Starting_incremental_compilation_6032", message: "File change detected. Starting incremental compilation..." }, + KIND: { code: 6034, category: ts.DiagnosticCategory.Message, key: "KIND_6034", message: "KIND" }, + FILE: { code: 6035, category: ts.DiagnosticCategory.Message, key: "FILE_6035", message: "FILE" }, + VERSION: { code: 6036, category: ts.DiagnosticCategory.Message, key: "VERSION_6036", message: "VERSION" }, + LOCATION: { code: 6037, category: ts.DiagnosticCategory.Message, key: "LOCATION_6037", message: "LOCATION" }, + DIRECTORY: { code: 6038, category: ts.DiagnosticCategory.Message, key: "DIRECTORY_6038", message: "DIRECTORY" }, + Compilation_complete_Watching_for_file_changes: { code: 6042, category: ts.DiagnosticCategory.Message, key: "Compilation_complete_Watching_for_file_changes_6042", message: "Compilation complete. Watching for file changes." }, + Generates_corresponding_map_file: { code: 6043, category: ts.DiagnosticCategory.Message, key: "Generates_corresponding_map_file_6043", message: "Generates corresponding '.map' file." }, + Compiler_option_0_expects_an_argument: { code: 6044, category: ts.DiagnosticCategory.Error, key: "Compiler_option_0_expects_an_argument_6044", message: "Compiler option '{0}' expects an argument." }, + Unterminated_quoted_string_in_response_file_0: { code: 6045, category: ts.DiagnosticCategory.Error, key: "Unterminated_quoted_string_in_response_file_0_6045", message: "Unterminated quoted string in response file '{0}'." }, + Argument_for_module_option_must_be_commonjs_amd_system_umd_or_es2015: { code: 6046, category: ts.DiagnosticCategory.Error, key: "Argument_for_module_option_must_be_commonjs_amd_system_umd_or_es2015_6046", message: "Argument for '--module' option must be 'commonjs', 'amd', 'system', 'umd', or 'es2015'." }, + Argument_for_target_option_must_be_ES3_ES5_or_ES2015: { code: 6047, category: ts.DiagnosticCategory.Error, key: "Argument_for_target_option_must_be_ES3_ES5_or_ES2015_6047", message: "Argument for '--target' option must be 'ES3', 'ES5', or 'ES2015'." }, + Locale_must_be_of_the_form_language_or_language_territory_For_example_0_or_1: { code: 6048, category: ts.DiagnosticCategory.Error, key: "Locale_must_be_of_the_form_language_or_language_territory_For_example_0_or_1_6048", message: "Locale must be of the form or -. For example '{0}' or '{1}'." }, + Unsupported_locale_0: { code: 6049, category: ts.DiagnosticCategory.Error, key: "Unsupported_locale_0_6049", message: "Unsupported locale '{0}'." }, + Unable_to_open_file_0: { code: 6050, category: ts.DiagnosticCategory.Error, key: "Unable_to_open_file_0_6050", message: "Unable to open file '{0}'." }, + Corrupted_locale_file_0: { code: 6051, category: ts.DiagnosticCategory.Error, key: "Corrupted_locale_file_0_6051", message: "Corrupted locale file {0}." }, + Raise_error_on_expressions_and_declarations_with_an_implied_any_type: { code: 6052, category: ts.DiagnosticCategory.Message, key: "Raise_error_on_expressions_and_declarations_with_an_implied_any_type_6052", message: "Raise error on expressions and declarations with an implied 'any' type." }, + File_0_not_found: { code: 6053, category: ts.DiagnosticCategory.Error, key: "File_0_not_found_6053", message: "File '{0}' not found." }, + File_0_has_unsupported_extension_The_only_supported_extensions_are_1: { code: 6054, category: ts.DiagnosticCategory.Error, key: "File_0_has_unsupported_extension_The_only_supported_extensions_are_1_6054", message: "File '{0}' has unsupported extension. The only supported extensions are {1}." }, + Suppress_noImplicitAny_errors_for_indexing_objects_lacking_index_signatures: { code: 6055, category: ts.DiagnosticCategory.Message, key: "Suppress_noImplicitAny_errors_for_indexing_objects_lacking_index_signatures_6055", message: "Suppress noImplicitAny errors for indexing objects lacking index signatures." }, + Do_not_emit_declarations_for_code_that_has_an_internal_annotation: { code: 6056, category: ts.DiagnosticCategory.Message, key: "Do_not_emit_declarations_for_code_that_has_an_internal_annotation_6056", message: "Do not emit declarations for code that has an '@internal' annotation." }, + Specifies_the_root_directory_of_input_files_Use_to_control_the_output_directory_structure_with_outDir: { code: 6058, category: ts.DiagnosticCategory.Message, key: "Specifies_the_root_directory_of_input_files_Use_to_control_the_output_directory_structure_with_outDi_6058", message: "Specifies the root directory of input files. Use to control the output directory structure with --outDir." }, + File_0_is_not_under_rootDir_1_rootDir_is_expected_to_contain_all_source_files: { code: 6059, category: ts.DiagnosticCategory.Error, key: "File_0_is_not_under_rootDir_1_rootDir_is_expected_to_contain_all_source_files_6059", message: "File '{0}' is not under 'rootDir' '{1}'. 'rootDir' is expected to contain all source files." }, + Specifies_the_end_of_line_sequence_to_be_used_when_emitting_files_Colon_CRLF_dos_or_LF_unix: { code: 6060, category: ts.DiagnosticCategory.Message, key: "Specifies_the_end_of_line_sequence_to_be_used_when_emitting_files_Colon_CRLF_dos_or_LF_unix_6060", message: "Specifies the end of line sequence to be used when emitting files: 'CRLF' (dos) or 'LF' (unix)." }, + NEWLINE: { code: 6061, category: ts.DiagnosticCategory.Message, key: "NEWLINE_6061", message: "NEWLINE" }, + Argument_for_newLine_option_must_be_CRLF_or_LF: { code: 6062, category: ts.DiagnosticCategory.Error, key: "Argument_for_newLine_option_must_be_CRLF_or_LF_6062", message: "Argument for '--newLine' option must be 'CRLF' or 'LF'." }, + Argument_for_moduleResolution_option_must_be_node_or_classic: { code: 6063, category: ts.DiagnosticCategory.Error, key: "Argument_for_moduleResolution_option_must_be_node_or_classic_6063", message: "Argument for '--moduleResolution' option must be 'node' or 'classic'." }, + Specify_JSX_code_generation_Colon_preserve_or_react: { code: 6080, category: ts.DiagnosticCategory.Message, key: "Specify_JSX_code_generation_Colon_preserve_or_react_6080", message: "Specify JSX code generation: 'preserve' or 'react'" }, + Argument_for_jsx_must_be_preserve_or_react: { code: 6081, category: ts.DiagnosticCategory.Message, key: "Argument_for_jsx_must_be_preserve_or_react_6081", message: "Argument for '--jsx' must be 'preserve' or 'react'." }, + Enables_experimental_support_for_ES7_decorators: { code: 6065, category: ts.DiagnosticCategory.Message, key: "Enables_experimental_support_for_ES7_decorators_6065", message: "Enables experimental support for ES7 decorators." }, + Enables_experimental_support_for_emitting_type_metadata_for_decorators: { code: 6066, category: ts.DiagnosticCategory.Message, key: "Enables_experimental_support_for_emitting_type_metadata_for_decorators_6066", message: "Enables experimental support for emitting type metadata for decorators." }, + Enables_experimental_support_for_ES7_async_functions: { code: 6068, category: ts.DiagnosticCategory.Message, key: "Enables_experimental_support_for_ES7_async_functions_6068", message: "Enables experimental support for ES7 async functions." }, + Specifies_module_resolution_strategy_Colon_node_Node_js_or_classic_TypeScript_pre_1_6: { code: 6069, category: ts.DiagnosticCategory.Message, key: "Specifies_module_resolution_strategy_Colon_node_Node_js_or_classic_TypeScript_pre_1_6_6069", message: "Specifies module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6)." }, + Initializes_a_TypeScript_project_and_creates_a_tsconfig_json_file: { code: 6070, category: ts.DiagnosticCategory.Message, key: "Initializes_a_TypeScript_project_and_creates_a_tsconfig_json_file_6070", message: "Initializes a TypeScript project and creates a tsconfig.json file." }, + Successfully_created_a_tsconfig_json_file: { code: 6071, category: ts.DiagnosticCategory.Message, key: "Successfully_created_a_tsconfig_json_file_6071", message: "Successfully created a tsconfig.json file." }, + Suppress_excess_property_checks_for_object_literals: { code: 6072, category: ts.DiagnosticCategory.Message, key: "Suppress_excess_property_checks_for_object_literals_6072", message: "Suppress excess property checks for object literals." }, + Disallow_inconsistently_cased_references_to_the_same_file: { code: 6073, category: ts.DiagnosticCategory.Message, key: "Disallow_inconsistently_cased_references_to_the_same_file_6073", message: "Disallow inconsistently-cased references to the same 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." }, + new_expression_whose_target_lacks_a_construct_signature_implicitly_has_an_any_type: { code: 7009, category: ts.DiagnosticCategory.Error, key: "new_expression_whose_target_lacks_a_construct_signature_implicitly_has_an_any_type_7009", message: "'new' expression, whose target lacks a construct signature, implicitly has an 'any' type." }, + _0_which_lacks_return_type_annotation_implicitly_has_an_1_return_type: { code: 7010, category: ts.DiagnosticCategory.Error, key: "_0_which_lacks_return_type_annotation_implicitly_has_an_1_return_type_7010", message: "'{0}', which lacks return-type annotation, implicitly has an '{1}' return type." }, + Function_expression_which_lacks_return_type_annotation_implicitly_has_an_0_return_type: { code: 7011, category: ts.DiagnosticCategory.Error, key: "Function_expression_which_lacks_return_type_annotation_implicitly_has_an_0_return_type_7011", message: "Function expression, which lacks return-type annotation, implicitly has an '{0}' return type." }, + Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type: { code: 7013, category: ts.DiagnosticCategory.Error, key: "Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type_7013", message: "Construct signature, which lacks return-type annotation, implicitly has an 'any' return type." }, + Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_type_annotation: { code: 7016, category: ts.DiagnosticCategory.Error, key: "Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_type_annotation_7016", message: "Property '{0}' implicitly has type 'any', because its 'set' accessor lacks a type annotation." }, + Index_signature_of_object_type_implicitly_has_an_any_type: { code: 7017, category: ts.DiagnosticCategory.Error, key: "Index_signature_of_object_type_implicitly_has_an_any_type_7017", message: "Index signature of object type implicitly has an 'any' type." }, + Object_literal_s_property_0_implicitly_has_an_1_type: { code: 7018, category: ts.DiagnosticCategory.Error, key: "Object_literal_s_property_0_implicitly_has_an_1_type_7018", message: "Object literal's property '{0}' implicitly has an '{1}' type." }, + Rest_parameter_0_implicitly_has_an_any_type: { code: 7019, category: ts.DiagnosticCategory.Error, key: "Rest_parameter_0_implicitly_has_an_any_type_7019", message: "Rest parameter '{0}' implicitly has an 'any[]' type." }, + Call_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type: { code: 7020, category: ts.DiagnosticCategory.Error, key: "Call_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type_7020", message: "Call signature, which lacks return-type annotation, implicitly has an 'any' return type." }, + _0_implicitly_has_type_any_because_it_does_not_have_a_type_annotation_and_is_referenced_directly_or_indirectly_in_its_own_initializer: { code: 7022, category: ts.DiagnosticCategory.Error, key: "_0_implicitly_has_type_any_because_it_does_not_have_a_type_annotation_and_is_referenced_directly_or__7022", message: "'{0}' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer." }, + _0_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions: { code: 7023, category: ts.DiagnosticCategory.Error, key: "_0_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_reference_7023", message: "'{0}' implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions." }, + Function_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions: { code: 7024, category: ts.DiagnosticCategory.Error, key: "Function_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_ref_7024", message: "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." }, + Generator_implicitly_has_type_0_because_it_does_not_yield_any_values_Consider_supplying_a_return_type: { code: 7025, category: ts.DiagnosticCategory.Error, key: "Generator_implicitly_has_type_0_because_it_does_not_yield_any_values_Consider_supplying_a_return_typ_7025", message: "Generator implicitly has type '{0}' because it does not yield any values. Consider supplying a return type." }, + JSX_element_implicitly_has_type_any_because_no_interface_JSX_0_exists: { code: 7026, category: ts.DiagnosticCategory.Error, key: "JSX_element_implicitly_has_type_any_because_no_interface_JSX_0_exists_7026", message: "JSX element implicitly has type 'any' because no interface 'JSX.{0}' exists" }, + 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." }, + export_can_only_be_used_in_a_ts_file: { code: 8003, category: ts.DiagnosticCategory.Error, key: "export_can_only_be_used_in_a_ts_file_8003", message: "'export=' can only be used in a .ts file." }, + type_parameter_declarations_can_only_be_used_in_a_ts_file: { code: 8004, category: ts.DiagnosticCategory.Error, key: "type_parameter_declarations_can_only_be_used_in_a_ts_file_8004", message: "'type parameter declarations' can only be used in a .ts file." }, + implements_clauses_can_only_be_used_in_a_ts_file: { code: 8005, category: ts.DiagnosticCategory.Error, key: "implements_clauses_can_only_be_used_in_a_ts_file_8005", message: "'implements clauses' can only be used in a .ts file." }, + interface_declarations_can_only_be_used_in_a_ts_file: { code: 8006, category: ts.DiagnosticCategory.Error, key: "interface_declarations_can_only_be_used_in_a_ts_file_8006", message: "'interface declarations' can only be used in a .ts file." }, + module_declarations_can_only_be_used_in_a_ts_file: { code: 8007, category: ts.DiagnosticCategory.Error, key: "module_declarations_can_only_be_used_in_a_ts_file_8007", message: "'module declarations' can only be used in a .ts file." }, + type_aliases_can_only_be_used_in_a_ts_file: { code: 8008, category: ts.DiagnosticCategory.Error, key: "type_aliases_can_only_be_used_in_a_ts_file_8008", message: "'type aliases' can only be used in a .ts file." }, + _0_can_only_be_used_in_a_ts_file: { code: 8009, category: ts.DiagnosticCategory.Error, key: "_0_can_only_be_used_in_a_ts_file_8009", message: "'{0}' can only be used in a .ts file." }, + types_can_only_be_used_in_a_ts_file: { code: 8010, category: ts.DiagnosticCategory.Error, key: "types_can_only_be_used_in_a_ts_file_8010", message: "'types' can only be used in a .ts file." }, + type_arguments_can_only_be_used_in_a_ts_file: { code: 8011, category: ts.DiagnosticCategory.Error, key: "type_arguments_can_only_be_used_in_a_ts_file_8011", message: "'type arguments' can only be used in a .ts file." }, + parameter_modifiers_can_only_be_used_in_a_ts_file: { code: 8012, category: ts.DiagnosticCategory.Error, key: "parameter_modifiers_can_only_be_used_in_a_ts_file_8012", message: "'parameter modifiers' can only be used in a .ts file." }, + property_declarations_can_only_be_used_in_a_ts_file: { code: 8014, category: ts.DiagnosticCategory.Error, key: "property_declarations_can_only_be_used_in_a_ts_file_8014", message: "'property declarations' can only be used in a .ts file." }, + enum_declarations_can_only_be_used_in_a_ts_file: { code: 8015, category: ts.DiagnosticCategory.Error, key: "enum_declarations_can_only_be_used_in_a_ts_file_8015", message: "'enum declarations' can only be used in a .ts file." }, + type_assertion_expressions_can_only_be_used_in_a_ts_file: { code: 8016, category: ts.DiagnosticCategory.Error, key: "type_assertion_expressions_can_only_be_used_in_a_ts_file_8016", message: "'type assertion expressions' can only be used in a .ts file." }, + decorators_can_only_be_used_in_a_ts_file: { code: 8017, category: ts.DiagnosticCategory.Error, key: "decorators_can_only_be_used_in_a_ts_file_8017", message: "'decorators' can only be used in a .ts file." }, + Only_identifiers_Slashqualified_names_with_optional_type_arguments_are_currently_supported_in_a_class_extends_clauses: { code: 9002, category: ts.DiagnosticCategory.Error, key: "Only_identifiers_Slashqualified_names_with_optional_type_arguments_are_currently_supported_in_a_clas_9002", message: "Only identifiers/qualified-names with optional type arguments are currently supported in a class 'extends' clauses." }, + class_expressions_are_not_currently_supported: { code: 9003, category: ts.DiagnosticCategory.Error, key: "class_expressions_are_not_currently_supported_9003", message: "'class' expressions are not currently supported." }, + JSX_attributes_must_only_be_assigned_a_non_empty_expression: { code: 17000, category: ts.DiagnosticCategory.Error, key: "JSX_attributes_must_only_be_assigned_a_non_empty_expression_17000", message: "JSX attributes must only be assigned a non-empty 'expression'." }, + JSX_elements_cannot_have_multiple_attributes_with_the_same_name: { code: 17001, category: ts.DiagnosticCategory.Error, key: "JSX_elements_cannot_have_multiple_attributes_with_the_same_name_17001", message: "JSX elements cannot have multiple attributes with the same name." }, + Expected_corresponding_JSX_closing_tag_for_0: { code: 17002, category: ts.DiagnosticCategory.Error, key: "Expected_corresponding_JSX_closing_tag_for_0_17002", message: "Expected corresponding JSX closing tag for '{0}'." }, + JSX_attribute_expected: { code: 17003, category: ts.DiagnosticCategory.Error, key: "JSX_attribute_expected_17003", message: "JSX attribute expected." }, + Cannot_use_JSX_unless_the_jsx_flag_is_provided: { code: 17004, category: ts.DiagnosticCategory.Error, key: "Cannot_use_JSX_unless_the_jsx_flag_is_provided_17004", message: "Cannot use JSX unless the '--jsx' flag is provided." }, + A_constructor_cannot_contain_a_super_call_when_its_class_extends_null: { code: 17005, category: ts.DiagnosticCategory.Error, key: "A_constructor_cannot_contain_a_super_call_when_its_class_extends_null_17005", message: "A constructor cannot contain a 'super' call when its class extends 'null'" }, + An_unary_expression_with_the_0_operator_is_not_allowed_in_the_left_hand_side_of_an_exponentiation_expression_Consider_enclosing_the_expression_in_parentheses: { code: 17006, category: ts.DiagnosticCategory.Error, key: "An_unary_expression_with_the_0_operator_is_not_allowed_in_the_left_hand_side_of_an_exponentiation_ex_17006", message: "An unary expression with the '{0}' operator is not allowed in the left-hand side of an exponentiation expression. Consider enclosing the expression in parentheses." }, + A_type_assertion_expression_is_not_allowed_in_the_left_hand_side_of_an_exponentiation_expression_Consider_enclosing_the_expression_in_parentheses: { code: 17007, category: ts.DiagnosticCategory.Error, key: "A_type_assertion_expression_is_not_allowed_in_the_left_hand_side_of_an_exponentiation_expression_Con_17007", message: "A type assertion expression is not allowed in the left-hand side of an exponentiation expression. Consider enclosing the expression in parentheses." } + }; +})(ts || (ts = {})); +var ts; +(function (ts) { + function tokenIsIdentifierOrKeyword(token) { + return token >= 69; + } + ts.tokenIsIdentifierOrKeyword = tokenIsIdentifierOrKeyword; + var textToToken = { + "abstract": 115, + "any": 117, + "as": 116, + "boolean": 120, + "break": 70, + "case": 71, + "catch": 72, + "class": 73, + "continue": 75, + "const": 74, + "constructor": 121, + "debugger": 76, + "declare": 122, + "default": 77, + "delete": 78, + "do": 79, + "else": 80, + "enum": 81, + "export": 82, + "extends": 83, + "false": 84, + "finally": 85, + "for": 86, + "from": 133, + "function": 87, + "get": 123, + "if": 88, + "implements": 106, + "import": 89, + "in": 90, + "instanceof": 91, + "interface": 107, + "is": 124, + "let": 108, + "module": 125, + "namespace": 126, + "new": 92, + "null": 93, + "number": 128, + "package": 109, + "private": 110, + "protected": 111, + "public": 112, + "require": 127, + "return": 94, + "set": 129, + "static": 113, + "string": 130, + "super": 95, + "switch": 96, + "symbol": 131, + "this": 97, + "throw": 98, + "true": 99, + "try": 100, + "type": 132, + "typeof": 101, + "var": 102, + "void": 103, + "while": 104, + "with": 105, + "yield": 114, + "async": 118, + "await": 119, + "of": 134, + "{": 15, + "}": 16, + "(": 17, + ")": 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) { + if (source.hasOwnProperty(name_4)) { + 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++); + 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 ch === 32 || + ch === 9 || + ch === 11 || + ch === 12 || + ch === 160 || + ch === 133 || + ch === 5760 || + ch >= 8192 && ch <= 8203 || + ch === 8239 || + ch === 8287 || + ch === 12288 || + ch === 65279; + } + ts.isWhiteSpace = isWhiteSpace; + function isLineBreak(ch) { + return ch === 10 || + ch === 13 || + ch === 8232 || + ch === 8233; + } + 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) { + 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 (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) || isLineBreak(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 getCommentRanges(text, pos, trailing) { + var result; + var collecting = trailing || pos === 0; + while (true) { + var ch = text.charCodeAt(pos); + switch (ch) { + case 13: + if (text.charCodeAt(pos + 1) === 10) { + pos++; + } + case 10: + pos++; + if (trailing) { + return result; + } + collecting = true; + if (result && result.length) { + ts.lastOrUndefined(result).hasTrailingNewLine = 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 (!result) { + result = []; + } + result.push({ pos: startPos, end: pos, hasTrailingNewLine: hasTrailingNewLine, kind: kind }); + } + continue; + } + break; + default: + if (ch > 127 && (isWhiteSpace(ch) || isLineBreak(ch))) { + if (result && result.length && isLineBreak(ch)) { + ts.lastOrUndefined(result).hasTrailingNewLine = true; + } + pos++; + continue; + } + break; + } + return result; + } + } + function getLeadingCommentRanges(text, pos) { + return getCommentRanges(text, pos, false); + } + ts.getLeadingCommentRanges = getLeadingCommentRanges; + function getTrailingCommentRanges(text, pos) { + return getCommentRanges(text, pos, true); + } + 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 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, + reScanJsxToken: reScanJsxToken, + scanJsxToken: scanJsxToken, + scan: scan, + setText: setText, + setScriptTarget: setScriptTarget, + setLanguageVariant: setLanguageVariant, + setOnError: setOnError, + setTextPos: setTextPos, + tryScan: tryScan, + lookAhead: lookAhead + }; + 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() { + var quote = text.charCodeAt(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) { + 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++); + 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 && isWhiteSpace(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; + } + return pos++, 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; + } + return pos++, 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; + } + return pos++, token = 46; + case 40: + return pos++, token = 17; + case 41: + return pos++, token = 18; + case 42: + if (text.charCodeAt(pos + 1) === 61) { + return pos += 2, token = 59; + } + if (text.charCodeAt(pos + 1) === 42) { + if (text.charCodeAt(pos + 2) === 61) { + return pos += 3, token = 60; + } + return pos += 2, token = 38; + } + return pos++, token = 37; + case 43: + if (text.charCodeAt(pos + 1) === 43) { + return pos += 2, token = 41; + } + if (text.charCodeAt(pos + 1) === 61) { + return pos += 2, token = 57; + } + return pos++, token = 35; + case 44: + return pos++, token = 24; + case 45: + if (text.charCodeAt(pos + 1) === 45) { + return pos += 2, token = 42; + } + if (text.charCodeAt(pos + 1) === 61) { + return pos += 2, token = 58; + } + return pos++, 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; + } + return pos++, 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; + } + return pos++, 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: + return pos++, token = 54; + case 59: + return pos++, 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; + } + return pos++, 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; + } + return pos++, token = 56; + case 62: + if (isConflictMarkerTrivia(text, pos)) { + pos = scanConflictMarkerTrivia(text, pos, error); + if (skipTrivia) { + continue; + } + else { + return token = 7; + } + } + return pos++, token = 27; + case 63: + return pos++, token = 53; + case 91: + return pos++, token = 19; + case 93: + return pos++, token = 20; + case 94: + if (text.charCodeAt(pos + 1) === 61) { + return pos += 2, token = 68; + } + return pos++, token = 48; + case 123: + return pos++, 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; + } + return pos++, token = 47; + case 125: + return pos++, token = 16; + case 126: + return pos++, token = 50; + case 64: + return pos++, 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); + return pos++, 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 (isWhiteSpace(ch)) { + pos++; + continue; + } + else if (isLineBreak(ch)) { + precedingLineBreak = true; + pos++; + continue; + } + error(ts.Diagnostics.Invalid_character); + return pos++, 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; + } + return pos++, token = 44; + } + if (text.charCodeAt(pos) === 61) { + return pos++, 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 = 236; + } + 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 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 lookAhead(callback) { + return speculationHelper(callback, true); + } + function tryScan(callback) { + return speculationHelper(callback, false); + } + 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.optionDeclarations = [ + { + name: "charset", + type: "string" + }, + { + name: "declaration", + shortName: "d", + type: "boolean", + description: ts.Diagnostics.Generates_corresponding_d_ts_file + }, + { + name: "diagnostics", + type: "boolean" + }, + { + name: "emitBOM", + type: "boolean" + }, + { + name: "help", + shortName: "h", + type: "boolean", + description: ts.Diagnostics.Print_this_message + }, + { + 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: { + "preserve": 1, + "react": 2 + }, + paramType: ts.Diagnostics.KIND, + description: ts.Diagnostics.Specify_JSX_code_generation_Colon_preserve_or_react, + error: ts.Diagnostics.Argument_for_jsx_must_be_preserve_or_react + }, + { + name: "listFiles", + type: "boolean" + }, + { + name: "locale", + type: "string" + }, + { + name: "mapRoot", + type: "string", + isFilePath: true, + description: ts.Diagnostics.Specifies_the_location_where_debugger_should_locate_map_files_instead_of_generated_locations, + paramType: ts.Diagnostics.LOCATION + }, + { + name: "module", + shortName: "m", + type: { + "commonjs": 1, + "amd": 2, + "system": 4, + "umd": 3, + "es6": 5, + "es2015": 5 + }, + description: ts.Diagnostics.Specify_module_code_generation_Colon_commonjs_amd_system_umd_or_es2015, + paramType: ts.Diagnostics.KIND, + error: ts.Diagnostics.Argument_for_module_option_must_be_commonjs_amd_system_umd_or_es2015 + }, + { + name: "newLine", + type: { + "crlf": 0, + "lf": 1 + }, + description: ts.Diagnostics.Specifies_the_end_of_line_sequence_to_be_used_when_emitting_files_Colon_CRLF_dos_or_LF_unix, + paramType: ts.Diagnostics.NEWLINE, + error: ts.Diagnostics.Argument_for_newLine_option_must_be_CRLF_or_LF + }, + { + 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: "noImplicitAny", + type: "boolean", + description: ts.Diagnostics.Raise_error_on_expressions_and_declarations_with_an_implied_any_type + }, + { + name: "noLib", + type: "boolean" + }, + { + name: "noResolve", + type: "boolean" + }, + { + name: "skipDefaultLibCheck", + type: "boolean" + }, + { + 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: "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, + description: ts.Diagnostics.Specifies_the_root_directory_of_input_files_Use_to_control_the_output_directory_structure_with_outDir, + paramType: ts.Diagnostics.LOCATION + }, + { + name: "isolatedModules", + type: "boolean" + }, + { + name: "sourceMap", + type: "boolean", + description: ts.Diagnostics.Generates_corresponding_map_file + }, + { + name: "sourceRoot", + type: "string", + isFilePath: true, + description: ts.Diagnostics.Specifies_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: { + "es3": 0, + "es5": 1, + "es6": 2, + "es2015": 2 + }, + description: ts.Diagnostics.Specify_ECMAScript_target_version_Colon_ES3_default_ES5_or_ES2015_experimental, + paramType: ts.Diagnostics.VERSION, + error: ts.Diagnostics.Argument_for_target_option_must_be_ES3_ES5_or_ES2015 + }, + { + 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: { + "node": 2, + "classic": 1 + }, + description: ts.Diagnostics.Specifies_module_resolution_strategy_Colon_node_Node_js_or_classic_TypeScript_pre_1_6, + error: ts.Diagnostics.Argument_for_moduleResolution_option_must_be_node_or_classic + }, + { + name: "forceConsistentCasingInFileNames", + type: "boolean", + description: ts.Diagnostics.Disallow_inconsistently_cased_references_to_the_same_file + }, + ]; + var optionNameMapCache; + function getOptionNameMap() { + if (optionNameMapCache) { + return optionNameMapCache; + } + var optionNameMap = {}; + var shortOptionNames = {}; + 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 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++]; + 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 (ts.hasProperty(shortOptionNames, s)) { + s = shortOptionNames[s]; + } + if (ts.hasProperty(optionNameMap, s)) { + var opt = optionNameMap[s]; + 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++]); + break; + case "boolean": + options[opt.name] = true; + break; + case "string": + options[opt.name] = args[i++] || ""; + break; + default: + var map_1 = opt.type; + var key = (args[i++] || "").toLowerCase(); + if (ts.hasProperty(map_1, key)) { + options[opt.name] = map_1[key]; + } + else { + errors.push(ts.createCompilerDiagnostic(opt.error)); + } + } + } + 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) { + try { + return { config: /\S/.test(jsonText) ? JSON.parse(jsonText) : {} }; + } + catch (e) { + return { error: ts.createCompilerDiagnostic(ts.Diagnostics.Failed_to_parse_file_0_Colon_1, fileName, e.message) }; + } + } + ts.parseConfigFileTextToJson = parseConfigFileTextToJson; + function parseJsonConfigFileContent(json, host, basePath) { + var _a = convertCompilerOptionsFromJson(json["compilerOptions"], basePath), options = _a.options, errors = _a.errors; + return { + options: options, + fileNames: getFileNames(), + errors: errors + }; + function getFileNames() { + var fileNames = []; + if (ts.hasProperty(json, "files")) { + if (json["files"] instanceof Array) { + fileNames = ts.map(json["files"], function (s) { return ts.combinePaths(basePath, s); }); + } + else { + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Compiler_option_0_requires_a_value_of_type_1, "files", "Array")); + } + } + else { + var exclude = json["exclude"] instanceof Array ? ts.map(json["exclude"], ts.normalizeSlashes) : undefined; + var sysFiles = host.readDirectory(basePath, ".ts", exclude).concat(host.readDirectory(basePath, ".tsx", exclude)); + for (var i = 0; i < sysFiles.length; i++) { + var name_5 = sysFiles[i]; + if (ts.fileExtensionIs(name_5, ".d.ts")) { + var baseName = name_5.substr(0, name_5.length - ".d.ts".length); + if (!ts.contains(sysFiles, baseName + ".tsx") && !ts.contains(sysFiles, baseName + ".ts")) { + fileNames.push(name_5); + } + } + else if (ts.fileExtensionIs(name_5, ".ts")) { + if (!ts.contains(sysFiles, name_5 + "x")) { + fileNames.push(name_5); + } + } + else { + fileNames.push(name_5); + } + } + } + return fileNames; + } + } + ts.parseJsonConfigFileContent = parseJsonConfigFileContent; + function convertCompilerOptionsFromJson(jsonOptions, basePath) { + var options = {}; + var errors = []; + if (!jsonOptions) { + return { options: options, errors: errors }; + } + var optionNameMap = ts.arrayToMap(ts.optionDeclarations, function (opt) { return opt.name; }); + for (var id in jsonOptions) { + if (ts.hasProperty(optionNameMap, id)) { + var opt = optionNameMap[id]; + var optType = opt.type; + var value = jsonOptions[id]; + var expectedType = typeof optType === "string" ? optType : "string"; + if (typeof value === expectedType) { + if (typeof optType !== "string") { + var key = value.toLowerCase(); + if (ts.hasProperty(optType, key)) { + value = optType[key]; + } + else { + errors.push(ts.createCompilerDiagnostic(opt.error)); + value = 0; + } + } + if (opt.isFilePath) { + value = ts.normalizePath(ts.combinePaths(basePath, value)); + if (value === "") { + value = "."; + } + } + options[opt.name] = value; + } + else { + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Compiler_option_0_requires_a_value_of_type_1, id, expectedType)); + } + } + else { + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Unknown_compiler_option_0, id)); + } + } + return { options: options, errors: errors }; + } + ts.convertCompilerOptionsFromJson = convertCompilerOptionsFromJson; +})(ts || (ts = {})); +var ts; +(function (ts) { + function getDeclarationOfKind(symbol, kind) { + var declarations = symbol.declarations; + if (declarations) { + for (var _i = 0; _i < declarations.length; _i++) { + var declaration = declarations[_i]; + if (declaration.kind === kind) { + return declaration; + } + } + } + return undefined; + } + ts.getDeclarationOfKind = getDeclarationOfKind; + var stringWriters = []; + function getSingleLineStringWriter() { + if (stringWriters.length === 0) { + var str = ""; + var writeText = function (text) { return str += text; }; + return { + string: function () { return str; }, + writeKeyword: writeText, + writeOperator: writeText, + writePunctuation: writeText, + writeSpace: writeText, + writeStringLiteral: writeText, + writeParameter: writeText, + writeSymbol: writeText, + writeLine: function () { return str += " "; }, + increaseIndent: function () { }, + decreaseIndent: function () { }, + clear: function () { return str = ""; }, + trackSymbol: function () { }, + reportInaccessibleThisError: function () { } + }; + } + return stringWriters.pop(); + } + ts.getSingleLineStringWriter = getSingleLineStringWriter; + function releaseStringWriter(writer) { + writer.clear(); + stringWriters.push(writer); + } + ts.releaseStringWriter = releaseStringWriter; + function getFullWidth(node) { + return node.end - node.pos; + } + ts.getFullWidth = getFullWidth; + function arrayIsEqualTo(array1, array2, equaler) { + if (!array1 || !array2) { + return array1 === array2; + } + if (array1.length !== array2.length) { + return false; + } + for (var i = 0; i < array1.length; ++i) { + var equals = equaler ? equaler(array1[i], array2[i]) : array1[i] === array2[i]; + if (!equals) { + return false; + } + } + return true; + } + ts.arrayIsEqualTo = arrayIsEqualTo; + function hasResolvedModule(sourceFile, moduleNameText) { + return sourceFile.resolvedModules && ts.hasProperty(sourceFile.resolvedModules, moduleNameText); + } + ts.hasResolvedModule = hasResolvedModule; + function getResolvedModule(sourceFile, moduleNameText) { + return hasResolvedModule(sourceFile, moduleNameText) ? sourceFile.resolvedModules[moduleNameText] : undefined; + } + ts.getResolvedModule = getResolvedModule; + function setResolvedModule(sourceFile, moduleNameText, resolvedModule) { + if (!sourceFile.resolvedModules) { + sourceFile.resolvedModules = {}; + } + sourceFile.resolvedModules[moduleNameText] = resolvedModule; + } + ts.setResolvedModule = setResolvedModule; + function containsParseError(node) { + aggregateChildData(node); + return (node.parserContextFlags & 64) !== 0; + } + ts.containsParseError = containsParseError; + function aggregateChildData(node) { + if (!(node.parserContextFlags & 128)) { + var thisNodeOrAnySubNodesHasError = ((node.parserContextFlags & 16) !== 0) || + ts.forEachChild(node, containsParseError); + if (thisNodeOrAnySubNodesHasError) { + node.parserContextFlags |= 64; + } + node.parserContextFlags |= 128; + } + } + function getSourceFileOfNode(node) { + while (node && node.kind !== 248) { + node = node.parent; + } + return node; + } + ts.getSourceFileOfNode = getSourceFileOfNode; + function getStartPositionOfLine(line, sourceFile) { + ts.Debug.assert(line >= 0); + return ts.getLineStarts(sourceFile)[line]; + } + ts.getStartPositionOfLine = getStartPositionOfLine; + function nodePosToString(node) { + var file = getSourceFileOfNode(node); + var loc = ts.getLineAndCharacterOfPosition(file, node.pos); + return file.fileName + "(" + (loc.line + 1) + "," + (loc.character + 1) + ")"; + } + ts.nodePosToString = nodePosToString; + function getStartPosOfNode(node) { + return node.pos; + } + ts.getStartPosOfNode = getStartPosOfNode; + function nodeIsMissing(node) { + if (!node) { + return true; + } + return node.pos === node.end && node.pos >= 0 && node.kind !== 1; + } + ts.nodeIsMissing = nodeIsMissing; + function nodeIsPresent(node) { + return !nodeIsMissing(node); + } + ts.nodeIsPresent = nodeIsPresent; + function getTokenPosOfNode(node, sourceFile) { + if (nodeIsMissing(node)) { + return node.pos; + } + return ts.skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.pos); + } + ts.getTokenPosOfNode = getTokenPosOfNode; + function getNonDecoratorTokenPosOfNode(node, sourceFile) { + if (nodeIsMissing(node) || !node.decorators) { + return getTokenPosOfNode(node, sourceFile); + } + return ts.skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.decorators.end); + } + ts.getNonDecoratorTokenPosOfNode = getNonDecoratorTokenPosOfNode; + function getSourceTextOfNodeFromSourceFile(sourceFile, node, includeTrivia) { + if (includeTrivia === void 0) { includeTrivia = false; } + if (nodeIsMissing(node)) { + return ""; + } + var text = sourceFile.text; + return text.substring(includeTrivia ? node.pos : ts.skipTrivia(text, node.pos), node.end); + } + ts.getSourceTextOfNodeFromSourceFile = getSourceTextOfNodeFromSourceFile; + function getTextOfNodeFromSourceText(sourceText, node) { + if (nodeIsMissing(node)) { + return ""; + } + return sourceText.substring(ts.skipTrivia(sourceText, node.pos), node.end); + } + ts.getTextOfNodeFromSourceText = getTextOfNodeFromSourceText; + function getTextOfNode(node, includeTrivia) { + if (includeTrivia === void 0) { includeTrivia = false; } + return getSourceTextOfNodeFromSourceFile(getSourceFileOfNode(node), node, includeTrivia); + } + ts.getTextOfNode = getTextOfNode; + function escapeIdentifier(identifier) { + return identifier.length >= 2 && identifier.charCodeAt(0) === 95 && identifier.charCodeAt(1) === 95 ? "_" + identifier : identifier; + } + ts.escapeIdentifier = escapeIdentifier; + function unescapeIdentifier(identifier) { + return identifier.length >= 3 && identifier.charCodeAt(0) === 95 && identifier.charCodeAt(1) === 95 && identifier.charCodeAt(2) === 95 ? identifier.substr(1) : identifier; + } + ts.unescapeIdentifier = unescapeIdentifier; + function makeIdentifierFromModuleName(moduleName) { + return ts.getBaseFileName(moduleName).replace(/^(\d)/, "_$1").replace(/\W/g, "_"); + } + ts.makeIdentifierFromModuleName = makeIdentifierFromModuleName; + function isBlockOrCatchScoped(declaration) { + return (getCombinedNodeFlags(declaration) & 49152) !== 0 || + isCatchClauseVariableDeclaration(declaration); + } + ts.isBlockOrCatchScoped = isBlockOrCatchScoped; + function getEnclosingBlockScopeContainer(node) { + var current = node.parent; + while (current) { + if (isFunctionLike(current)) { + return current; + } + switch (current.kind) { + case 248: + case 220: + case 244: + case 218: + case 199: + case 200: + case 201: + return current; + case 192: + if (!isFunctionLike(current.parent)) { + return current; + } + } + current = current.parent; + } + } + ts.getEnclosingBlockScopeContainer = getEnclosingBlockScopeContainer; + function isCatchClauseVariableDeclaration(declaration) { + return declaration && + declaration.kind === 211 && + declaration.parent && + declaration.parent.kind === 244; + } + ts.isCatchClauseVariableDeclaration = isCatchClauseVariableDeclaration; + function declarationNameToString(name) { + return getFullWidth(name) === 0 ? "(Missing)" : getTextOfNode(name); + } + ts.declarationNameToString = declarationNameToString; + function createDiagnosticForNode(node, message, arg0, arg1, arg2) { + var sourceFile = getSourceFileOfNode(node); + var span = getErrorSpanForNode(sourceFile, node); + return ts.createFileDiagnostic(sourceFile, span.start, span.length, message, arg0, arg1, arg2); + } + ts.createDiagnosticForNode = createDiagnosticForNode; + function createDiagnosticForNodeFromMessageChain(node, messageChain) { + var sourceFile = getSourceFileOfNode(node); + var span = getErrorSpanForNode(sourceFile, node); + return { + file: sourceFile, + start: span.start, + length: span.length, + code: messageChain.code, + category: messageChain.category, + messageText: messageChain.next ? messageChain : messageChain.messageText + }; + } + ts.createDiagnosticForNodeFromMessageChain = createDiagnosticForNodeFromMessageChain; + function getSpanOfTokenAtPosition(sourceFile, pos) { + var scanner = ts.createScanner(sourceFile.languageVersion, true, sourceFile.languageVariant, sourceFile.text, undefined, pos); + scanner.scan(); + var start = scanner.getTokenPos(); + return ts.createTextSpanFromBounds(start, scanner.getTextPos()); + } + ts.getSpanOfTokenAtPosition = getSpanOfTokenAtPosition; + function getErrorSpanForNode(sourceFile, node) { + var errorNode = node; + switch (node.kind) { + case 248: + var pos_1 = ts.skipTrivia(sourceFile.text, 0, false); + if (pos_1 === sourceFile.text.length) { + return ts.createTextSpan(0, 0); + } + return getSpanOfTokenAtPosition(sourceFile, pos_1); + case 211: + case 163: + case 214: + case 186: + case 215: + case 218: + case 217: + case 247: + case 213: + case 173: + errorNode = node.name; + break; + } + if (errorNode === undefined) { + return getSpanOfTokenAtPosition(sourceFile, node.pos); + } + var pos = nodeIsMissing(errorNode) + ? errorNode.pos + : ts.skipTrivia(sourceFile.text, errorNode.pos); + return ts.createTextSpanFromBounds(pos, errorNode.end); + } + ts.getErrorSpanForNode = getErrorSpanForNode; + function isExternalModule(file) { + return file.externalModuleIndicator !== undefined; + } + ts.isExternalModule = isExternalModule; + function isDeclarationFile(file) { + return (file.flags & 8192) !== 0; + } + ts.isDeclarationFile = isDeclarationFile; + function isConstEnumDeclaration(node) { + return node.kind === 217 && isConst(node); + } + ts.isConstEnumDeclaration = isConstEnumDeclaration; + function walkUpBindingElementsAndPatterns(node) { + while (node && (node.kind === 163 || isBindingPattern(node))) { + node = node.parent; + } + return node; + } + function getCombinedNodeFlags(node) { + node = walkUpBindingElementsAndPatterns(node); + var flags = node.flags; + if (node.kind === 211) { + node = node.parent; + } + if (node && node.kind === 212) { + flags |= node.flags; + node = node.parent; + } + if (node && node.kind === 193) { + flags |= node.flags; + } + return flags; + } + ts.getCombinedNodeFlags = getCombinedNodeFlags; + function isConst(node) { + return !!(getCombinedNodeFlags(node) & 32768); + } + ts.isConst = isConst; + function isLet(node) { + return !!(getCombinedNodeFlags(node) & 16384); + } + ts.isLet = isLet; + function isPrologueDirective(node) { + return node.kind === 195 && node.expression.kind === 9; + } + ts.isPrologueDirective = isPrologueDirective; + function getLeadingCommentRangesOfNode(node, sourceFileOfNode) { + return ts.getLeadingCommentRanges(sourceFileOfNode.text, node.pos); + } + ts.getLeadingCommentRangesOfNode = getLeadingCommentRangesOfNode; + function getJsDocComments(node, sourceFileOfNode) { + var commentRanges = (node.kind === 138 || node.kind === 137) ? + ts.concatenate(ts.getTrailingCommentRanges(sourceFileOfNode.text, node.pos), ts.getLeadingCommentRanges(sourceFileOfNode.text, node.pos)) : + getLeadingCommentRangesOfNode(node, sourceFileOfNode); + return ts.filter(commentRanges, isJsDocComment); + function isJsDocComment(comment) { + return sourceFileOfNode.text.charCodeAt(comment.pos + 1) === 42 && + sourceFileOfNode.text.charCodeAt(comment.pos + 2) === 42 && + sourceFileOfNode.text.charCodeAt(comment.pos + 3) !== 47; + } + } + ts.getJsDocComments = getJsDocComments; + ts.fullTripleSlashReferencePathRegEx = /^(\/\/\/\s*/; + ts.fullTripleSlashAMDReferencePathRegEx = /^(\/\/\/\s*/; + function isTypeNode(node) { + if (151 <= node.kind && node.kind <= 160) { + return true; + } + switch (node.kind) { + case 117: + case 128: + case 130: + case 120: + case 131: + return true; + case 103: + return node.parent.kind !== 177; + case 9: + return node.parent.kind === 138; + case 188: + return !isExpressionWithTypeArgumentsInClassExtendsClause(node); + case 69: + if (node.parent.kind === 135 && node.parent.right === node) { + node = node.parent; + } + else if (node.parent.kind === 166 && node.parent.name === node) { + node = node.parent; + } + ts.Debug.assert(node.kind === 69 || node.kind === 135 || node.kind === 166, "'node' was expected to be a qualified name, identifier or property access in 'isTypeNode'."); + case 135: + case 166: + case 97: + var parent_1 = node.parent; + if (parent_1.kind === 154) { + return false; + } + if (151 <= parent_1.kind && parent_1.kind <= 160) { + return true; + } + switch (parent_1.kind) { + case 188: + return !isExpressionWithTypeArgumentsInClassExtendsClause(parent_1); + case 137: + return node === parent_1.constraint; + case 141: + case 140: + case 138: + case 211: + return node === parent_1.type; + case 213: + case 173: + case 174: + case 144: + case 143: + case 142: + case 145: + case 146: + return node === parent_1.type; + case 147: + case 148: + case 149: + return node === parent_1.type; + case 171: + return node === parent_1.type; + case 168: + case 169: + return parent_1.typeArguments && ts.indexOf(parent_1.typeArguments, node) >= 0; + case 170: + return false; + } + } + return false; + } + ts.isTypeNode = isTypeNode; + function forEachReturnStatement(body, visitor) { + return traverse(body); + function traverse(node) { + switch (node.kind) { + case 204: + return visitor(node); + case 220: + case 192: + case 196: + case 197: + case 198: + case 199: + case 200: + case 201: + case 205: + case 206: + case 241: + case 242: + case 207: + case 209: + case 244: + return ts.forEachChild(node, traverse); + } + } + } + ts.forEachReturnStatement = forEachReturnStatement; + function forEachYieldExpression(body, visitor) { + return traverse(body); + function traverse(node) { + switch (node.kind) { + case 184: + visitor(node); + var operand = node.expression; + if (operand) { + traverse(operand); + } + case 217: + case 215: + case 218: + case 216: + case 214: + case 186: + return; + default: + if (isFunctionLike(node)) { + var name_6 = node.name; + if (name_6 && name_6.kind === 136) { + traverse(name_6.expression); + return; + } + } + else if (!isTypeNode(node)) { + ts.forEachChild(node, traverse); + } + } + } + } + ts.forEachYieldExpression = forEachYieldExpression; + function isVariableLike(node) { + if (node) { + switch (node.kind) { + case 163: + case 247: + case 138: + case 245: + case 141: + case 140: + case 246: + case 211: + return true; + } + } + return false; + } + ts.isVariableLike = isVariableLike; + function isAccessor(node) { + return node && (node.kind === 145 || node.kind === 146); + } + ts.isAccessor = isAccessor; + function isClassLike(node) { + return node && (node.kind === 214 || node.kind === 186); + } + ts.isClassLike = isClassLike; + function isFunctionLike(node) { + if (node) { + switch (node.kind) { + case 144: + case 173: + case 213: + case 174: + case 143: + case 142: + case 145: + case 146: + case 147: + case 148: + case 149: + case 152: + case 153: + return true; + } + } + return false; + } + ts.isFunctionLike = isFunctionLike; + function introducesArgumentsExoticObject(node) { + switch (node.kind) { + case 143: + case 142: + case 144: + case 145: + case 146: + case 213: + case 173: + return true; + } + return false; + } + ts.introducesArgumentsExoticObject = introducesArgumentsExoticObject; + function isIterationStatement(node, lookInLabeledStatements) { + switch (node.kind) { + case 199: + case 200: + case 201: + case 197: + case 198: + return true; + case 207: + return lookInLabeledStatements && isIterationStatement(node.statement, lookInLabeledStatements); + } + return false; + } + ts.isIterationStatement = isIterationStatement; + function isFunctionBlock(node) { + return node && node.kind === 192 && isFunctionLike(node.parent); + } + ts.isFunctionBlock = isFunctionBlock; + function isObjectLiteralMethod(node) { + return node && node.kind === 143 && node.parent.kind === 165; + } + ts.isObjectLiteralMethod = isObjectLiteralMethod; + function getContainingFunction(node) { + while (true) { + node = node.parent; + if (!node || isFunctionLike(node)) { + return node; + } + } + } + ts.getContainingFunction = getContainingFunction; + function getContainingClass(node) { + while (true) { + node = node.parent; + if (!node || isClassLike(node)) { + return node; + } + } + } + ts.getContainingClass = getContainingClass; + function getThisContainer(node, includeArrowFunctions) { + while (true) { + node = node.parent; + if (!node) { + return undefined; + } + switch (node.kind) { + case 136: + if (isClassLike(node.parent.parent)) { + return node; + } + node = node.parent; + break; + case 139: + if (node.parent.kind === 138 && isClassElement(node.parent.parent)) { + node = node.parent.parent; + } + else if (isClassElement(node.parent)) { + node = node.parent; + } + break; + case 174: + if (!includeArrowFunctions) { + continue; + } + case 213: + case 173: + case 218: + case 141: + case 140: + case 143: + case 142: + case 144: + case 145: + case 146: + case 147: + case 148: + case 149: + case 217: + case 248: + return node; + } + } + } + ts.getThisContainer = getThisContainer; + function getSuperContainer(node, includeFunctions) { + while (true) { + node = node.parent; + if (!node) + return node; + switch (node.kind) { + case 136: + if (isClassLike(node.parent.parent)) { + return node; + } + node = node.parent; + break; + case 139: + if (node.parent.kind === 138 && isClassElement(node.parent.parent)) { + node = node.parent.parent; + } + else if (isClassElement(node.parent)) { + node = node.parent; + } + break; + case 213: + case 173: + case 174: + if (!includeFunctions) { + continue; + } + case 141: + case 140: + case 143: + case 142: + case 144: + case 145: + case 146: + return node; + } + } + } + ts.getSuperContainer = getSuperContainer; + function getEntityNameFromTypeNode(node) { + if (node) { + switch (node.kind) { + case 151: + return node.typeName; + case 188: + return node.expression; + case 69: + case 135: + return node; + } + } + return undefined; + } + ts.getEntityNameFromTypeNode = getEntityNameFromTypeNode; + function getInvokedExpression(node) { + if (node.kind === 170) { + return node.tag; + } + return node.expression; + } + ts.getInvokedExpression = getInvokedExpression; + function nodeCanBeDecorated(node) { + switch (node.kind) { + case 214: + return true; + case 141: + return node.parent.kind === 214; + case 138: + return node.parent.body && node.parent.parent.kind === 214; + case 145: + case 146: + case 143: + return node.body && node.parent.kind === 214; + } + return false; + } + ts.nodeCanBeDecorated = nodeCanBeDecorated; + function nodeIsDecorated(node) { + switch (node.kind) { + case 214: + if (node.decorators) { + return true; + } + return false; + case 141: + case 138: + if (node.decorators) { + return true; + } + return false; + case 145: + if (node.body && node.decorators) { + return true; + } + return false; + case 143: + case 146: + if (node.body && node.decorators) { + return true; + } + return false; + } + return false; + } + ts.nodeIsDecorated = nodeIsDecorated; + function childIsDecorated(node) { + switch (node.kind) { + case 214: + return ts.forEach(node.members, nodeOrChildIsDecorated); + case 143: + case 146: + return ts.forEach(node.parameters, nodeIsDecorated); + } + return false; + } + ts.childIsDecorated = childIsDecorated; + function nodeOrChildIsDecorated(node) { + return nodeIsDecorated(node) || childIsDecorated(node); + } + ts.nodeOrChildIsDecorated = nodeOrChildIsDecorated; + function isPropertyAccessExpression(node) { + return node.kind === 166; + } + ts.isPropertyAccessExpression = isPropertyAccessExpression; + function isElementAccessExpression(node) { + return node.kind === 167; + } + ts.isElementAccessExpression = isElementAccessExpression; + function isExpression(node) { + switch (node.kind) { + case 95: + case 93: + case 99: + case 84: + case 10: + case 164: + case 165: + case 166: + case 167: + case 168: + case 169: + case 170: + case 189: + case 171: + case 172: + case 173: + case 186: + case 174: + case 177: + case 175: + case 176: + case 179: + case 180: + case 181: + case 182: + case 185: + case 183: + case 11: + case 187: + case 233: + case 234: + case 184: + case 178: + return true; + case 135: + while (node.parent.kind === 135) { + node = node.parent; + } + return node.parent.kind === 154; + case 69: + if (node.parent.kind === 154) { + return true; + } + case 8: + case 9: + case 97: + var parent_2 = node.parent; + switch (parent_2.kind) { + case 211: + case 138: + case 141: + case 140: + case 247: + case 245: + case 163: + return parent_2.initializer === node; + case 195: + case 196: + case 197: + case 198: + case 204: + case 205: + case 206: + case 241: + case 208: + case 206: + return parent_2.expression === node; + case 199: + var forStatement = parent_2; + return (forStatement.initializer === node && forStatement.initializer.kind !== 212) || + forStatement.condition === node || + forStatement.incrementor === node; + case 200: + case 201: + var forInStatement = parent_2; + return (forInStatement.initializer === node && forInStatement.initializer.kind !== 212) || + forInStatement.expression === node; + case 171: + case 189: + return node === parent_2.expression; + case 190: + return node === parent_2.expression; + case 136: + return node === parent_2.expression; + case 139: + case 240: + case 239: + return true; + case 188: + return parent_2.expression === node && isExpressionWithTypeArgumentsInClassExtendsClause(parent_2); + default: + if (isExpression(parent_2)) { + return true; + } + } + } + return false; + } + ts.isExpression = isExpression; + function isExternalModuleNameRelative(moduleName) { + return moduleName.substr(0, 2) === "./" || moduleName.substr(0, 3) === "../" || moduleName.substr(0, 2) === ".\\" || moduleName.substr(0, 3) === "..\\"; + } + ts.isExternalModuleNameRelative = isExternalModuleNameRelative; + function isInstantiatedModule(node, preserveConstEnums) { + var moduleState = ts.getModuleInstanceState(node); + return moduleState === 1 || + (preserveConstEnums && moduleState === 2); + } + ts.isInstantiatedModule = isInstantiatedModule; + function isExternalModuleImportEqualsDeclaration(node) { + return node.kind === 221 && node.moduleReference.kind === 232; + } + ts.isExternalModuleImportEqualsDeclaration = isExternalModuleImportEqualsDeclaration; + function getExternalModuleImportEqualsDeclarationExpression(node) { + ts.Debug.assert(isExternalModuleImportEqualsDeclaration(node)); + return node.moduleReference.expression; + } + ts.getExternalModuleImportEqualsDeclarationExpression = getExternalModuleImportEqualsDeclarationExpression; + function isInternalModuleImportEqualsDeclaration(node) { + return node.kind === 221 && node.moduleReference.kind !== 232; + } + ts.isInternalModuleImportEqualsDeclaration = isInternalModuleImportEqualsDeclaration; + function getExternalModuleName(node) { + if (node.kind === 222) { + return node.moduleSpecifier; + } + if (node.kind === 221) { + var reference = node.moduleReference; + if (reference.kind === 232) { + return reference.expression; + } + } + if (node.kind === 228) { + return node.moduleSpecifier; + } + } + ts.getExternalModuleName = getExternalModuleName; + function hasQuestionToken(node) { + if (node) { + switch (node.kind) { + case 138: + case 143: + case 142: + case 246: + case 245: + case 141: + case 140: + return node.questionToken !== undefined; + } + } + return false; + } + ts.hasQuestionToken = hasQuestionToken; + function isJSDocConstructSignature(node) { + return node.kind === 261 && + node.parameters.length > 0 && + node.parameters[0].type.kind === 263; + } + ts.isJSDocConstructSignature = isJSDocConstructSignature; + function getJSDocTag(node, kind) { + if (node && node.jsDocComment) { + for (var _i = 0, _a = node.jsDocComment.tags; _i < _a.length; _i++) { + var tag = _a[_i]; + if (tag.kind === kind) { + return tag; + } + } + } + } + function getJSDocTypeTag(node) { + return getJSDocTag(node, 269); + } + ts.getJSDocTypeTag = getJSDocTypeTag; + function getJSDocReturnTag(node) { + return getJSDocTag(node, 268); + } + ts.getJSDocReturnTag = getJSDocReturnTag; + function getJSDocTemplateTag(node) { + return getJSDocTag(node, 270); + } + ts.getJSDocTemplateTag = getJSDocTemplateTag; + function getCorrespondingJSDocParameterTag(parameter) { + if (parameter.name && parameter.name.kind === 69) { + var parameterName = parameter.name.text; + var docComment = parameter.parent.jsDocComment; + if (docComment) { + return ts.forEach(docComment.tags, function (t) { + if (t.kind === 267) { + var parameterTag = t; + var name_7 = parameterTag.preParameterName || parameterTag.postParameterName; + if (name_7.text === parameterName) { + return t; + } + } + }); + } + } + } + ts.getCorrespondingJSDocParameterTag = getCorrespondingJSDocParameterTag; + function hasRestParameter(s) { + return isRestParameter(ts.lastOrUndefined(s.parameters)); + } + ts.hasRestParameter = hasRestParameter; + function isRestParameter(node) { + if (node) { + if (node.parserContextFlags & 32) { + if (node.type && node.type.kind === 262) { + return true; + } + var paramTag = getCorrespondingJSDocParameterTag(node); + if (paramTag && paramTag.typeExpression) { + return paramTag.typeExpression.type.kind === 262; + } + } + return node.dotDotDotToken !== undefined; + } + return false; + } + ts.isRestParameter = isRestParameter; + function isLiteralKind(kind) { + return 8 <= kind && kind <= 11; + } + ts.isLiteralKind = isLiteralKind; + function isTextualLiteralKind(kind) { + return kind === 9 || kind === 11; + } + ts.isTextualLiteralKind = isTextualLiteralKind; + function isTemplateLiteralKind(kind) { + return 11 <= kind && kind <= 14; + } + ts.isTemplateLiteralKind = isTemplateLiteralKind; + function isBindingPattern(node) { + return !!node && (node.kind === 162 || node.kind === 161); + } + ts.isBindingPattern = isBindingPattern; + function isInAmbientContext(node) { + while (node) { + if (node.flags & (2 | 8192)) { + return true; + } + node = node.parent; + } + return false; + } + ts.isInAmbientContext = isInAmbientContext; + function isDeclaration(node) { + switch (node.kind) { + case 174: + case 163: + case 214: + case 186: + case 144: + case 217: + case 247: + case 230: + case 213: + case 173: + case 145: + case 223: + case 221: + case 226: + case 215: + case 143: + case 142: + case 218: + case 224: + case 138: + case 245: + case 141: + case 140: + case 146: + case 246: + case 216: + case 137: + case 211: + return true; + } + return false; + } + ts.isDeclaration = isDeclaration; + function isStatement(n) { + switch (n.kind) { + case 203: + case 202: + case 210: + case 197: + case 195: + case 194: + case 200: + case 201: + case 199: + case 196: + case 207: + case 204: + case 206: + case 98: + case 209: + case 193: + case 198: + case 205: + case 227: + return true; + default: + return false; + } + } + ts.isStatement = isStatement; + function isClassElement(n) { + switch (n.kind) { + case 144: + case 141: + case 143: + case 145: + case 146: + case 142: + case 149: + return true; + default: + return false; + } + } + ts.isClassElement = isClassElement; + function isDeclarationName(name) { + if (name.kind !== 69 && name.kind !== 9 && name.kind !== 8) { + return false; + } + var parent = name.parent; + if (parent.kind === 226 || parent.kind === 230) { + if (parent.propertyName) { + return true; + } + } + if (isDeclaration(parent)) { + return parent.name === name; + } + return false; + } + ts.isDeclarationName = isDeclarationName; + function isIdentifierName(node) { + var parent = node.parent; + switch (parent.kind) { + case 141: + case 140: + case 143: + case 142: + case 145: + case 146: + case 247: + case 245: + case 166: + return parent.name === node; + case 135: + if (parent.right === node) { + while (parent.kind === 135) { + parent = parent.parent; + } + return parent.kind === 154; + } + return false; + case 163: + case 226: + return parent.propertyName === node; + case 230: + return true; + } + return false; + } + ts.isIdentifierName = isIdentifierName; + function isAliasSymbolDeclaration(node) { + return node.kind === 221 || + node.kind === 223 && !!node.name || + node.kind === 224 || + node.kind === 226 || + node.kind === 230 || + node.kind === 227 && node.expression.kind === 69; + } + ts.isAliasSymbolDeclaration = isAliasSymbolDeclaration; + function getClassExtendsHeritageClauseElement(node) { + var heritageClause = getHeritageClause(node.heritageClauses, 83); + return heritageClause && heritageClause.types.length > 0 ? heritageClause.types[0] : undefined; + } + ts.getClassExtendsHeritageClauseElement = getClassExtendsHeritageClauseElement; + function getClassImplementsHeritageClauseElements(node) { + var heritageClause = getHeritageClause(node.heritageClauses, 106); + return heritageClause ? heritageClause.types : undefined; + } + ts.getClassImplementsHeritageClauseElements = getClassImplementsHeritageClauseElements; + function getInterfaceBaseTypeNodes(node) { + var heritageClause = getHeritageClause(node.heritageClauses, 83); + return heritageClause ? heritageClause.types : undefined; + } + ts.getInterfaceBaseTypeNodes = getInterfaceBaseTypeNodes; + function getHeritageClause(clauses, kind) { + if (clauses) { + for (var _i = 0; _i < clauses.length; _i++) { + var clause = clauses[_i]; + if (clause.token === kind) { + return clause; + } + } + } + return undefined; + } + ts.getHeritageClause = getHeritageClause; + function tryResolveScriptReference(host, sourceFile, reference) { + if (!host.getCompilerOptions().noResolve) { + var referenceFileName = ts.isRootedDiskPath(reference.fileName) ? reference.fileName : ts.combinePaths(ts.getDirectoryPath(sourceFile.fileName), reference.fileName); + referenceFileName = ts.getNormalizedAbsolutePath(referenceFileName, host.getCurrentDirectory()); + return host.getSourceFile(referenceFileName); + } + } + ts.tryResolveScriptReference = tryResolveScriptReference; + function getAncestor(node, kind) { + while (node) { + if (node.kind === kind) { + return node; + } + node = node.parent; + } + return undefined; + } + ts.getAncestor = getAncestor; + function getFileReferenceFromReferencePath(comment, commentRange) { + var simpleReferenceRegEx = /^\/\/\/\s*/gim; + if (simpleReferenceRegEx.exec(comment)) { + if (isNoDefaultLibRegEx.exec(comment)) { + return { + isNoDefaultLib: true + }; + } + else { + var matchResult = ts.fullTripleSlashReferencePathRegEx.exec(comment); + if (matchResult) { + var start = commentRange.pos; + var end = commentRange.end; + return { + fileReference: { + pos: start, + end: end, + fileName: matchResult[3] + }, + isNoDefaultLib: false + }; + } + else { + return { + diagnosticMessage: ts.Diagnostics.Invalid_reference_directive_syntax, + isNoDefaultLib: false + }; + } + } + } + return undefined; + } + ts.getFileReferenceFromReferencePath = getFileReferenceFromReferencePath; + function isKeyword(token) { + return 70 <= token && token <= 134; + } + ts.isKeyword = isKeyword; + function isTrivia(token) { + return 2 <= token && token <= 7; + } + ts.isTrivia = isTrivia; + function isAsyncFunctionLike(node) { + return isFunctionLike(node) && (node.flags & 512) !== 0 && !isAccessor(node); + } + ts.isAsyncFunctionLike = isAsyncFunctionLike; + function hasDynamicName(declaration) { + return declaration.name && + declaration.name.kind === 136 && + !isWellKnownSymbolSyntactically(declaration.name.expression); + } + ts.hasDynamicName = hasDynamicName; + function isWellKnownSymbolSyntactically(node) { + return isPropertyAccessExpression(node) && isESSymbolIdentifier(node.expression); + } + ts.isWellKnownSymbolSyntactically = isWellKnownSymbolSyntactically; + function getPropertyNameForPropertyNameNode(name) { + if (name.kind === 69 || name.kind === 9 || name.kind === 8) { + return name.text; + } + if (name.kind === 136) { + var nameExpression = name.expression; + if (isWellKnownSymbolSyntactically(nameExpression)) { + var rightHandSideName = nameExpression.name.text; + return getPropertyNameForKnownSymbolName(rightHandSideName); + } + } + return undefined; + } + ts.getPropertyNameForPropertyNameNode = getPropertyNameForPropertyNameNode; + function getPropertyNameForKnownSymbolName(symbolName) { + return "__@" + symbolName; + } + ts.getPropertyNameForKnownSymbolName = getPropertyNameForKnownSymbolName; + function isESSymbolIdentifier(node) { + return node.kind === 69 && node.text === "Symbol"; + } + ts.isESSymbolIdentifier = isESSymbolIdentifier; + function isModifier(token) { + switch (token) { + case 115: + case 118: + case 74: + case 122: + case 77: + case 82: + case 112: + case 110: + case 111: + case 113: + return true; + } + return false; + } + ts.isModifier = isModifier; + function isParameterDeclaration(node) { + var root = getRootDeclaration(node); + return root.kind === 138; + } + ts.isParameterDeclaration = isParameterDeclaration; + function getRootDeclaration(node) { + while (node.kind === 163) { + node = node.parent.parent; + } + return node; + } + ts.getRootDeclaration = getRootDeclaration; + function nodeStartsNewLexicalEnvironment(n) { + return isFunctionLike(n) || n.kind === 218 || n.kind === 248; + } + ts.nodeStartsNewLexicalEnvironment = nodeStartsNewLexicalEnvironment; + function cloneEntityName(node) { + if (node.kind === 69) { + var clone_1 = createSynthesizedNode(69); + clone_1.text = node.text; + return clone_1; + } + else { + var clone_2 = createSynthesizedNode(135); + clone_2.left = cloneEntityName(node.left); + clone_2.left.parent = clone_2; + clone_2.right = cloneEntityName(node.right); + clone_2.right.parent = clone_2; + return clone_2; + } + } + ts.cloneEntityName = cloneEntityName; + function nodeIsSynthesized(node) { + return node.pos === -1; + } + ts.nodeIsSynthesized = nodeIsSynthesized; + function createSynthesizedNode(kind, startsOnNewLine) { + var node = ts.createNode(kind, -1, -1); + node.startsOnNewLine = startsOnNewLine; + return node; + } + ts.createSynthesizedNode = createSynthesizedNode; + function createSynthesizedNodeArray() { + var array = []; + array.pos = -1; + array.end = -1; + return array; + } + ts.createSynthesizedNodeArray = createSynthesizedNodeArray; + function createDiagnosticCollection() { + var nonFileDiagnostics = []; + var fileDiagnostics = {}; + var diagnosticsModified = false; + var modificationCount = 0; + return { + add: add, + getGlobalDiagnostics: getGlobalDiagnostics, + getDiagnostics: getDiagnostics, + getModificationCount: getModificationCount, + reattachFileDiagnostics: reattachFileDiagnostics + }; + function getModificationCount() { + return modificationCount; + } + function reattachFileDiagnostics(newFile) { + if (!ts.hasProperty(fileDiagnostics, newFile.fileName)) { + return; + } + for (var _i = 0, _a = fileDiagnostics[newFile.fileName]; _i < _a.length; _i++) { + var diagnostic = _a[_i]; + diagnostic.file = newFile; + } + } + function add(diagnostic) { + var diagnostics; + if (diagnostic.file) { + diagnostics = fileDiagnostics[diagnostic.file.fileName]; + if (!diagnostics) { + diagnostics = []; + fileDiagnostics[diagnostic.file.fileName] = diagnostics; + } + } + else { + diagnostics = nonFileDiagnostics; + } + diagnostics.push(diagnostic); + diagnosticsModified = true; + modificationCount++; + } + function getGlobalDiagnostics() { + sortAndDeduplicate(); + return nonFileDiagnostics; + } + function getDiagnostics(fileName) { + sortAndDeduplicate(); + if (fileName) { + return fileDiagnostics[fileName] || []; + } + var allDiagnostics = []; + function pushDiagnostic(d) { + allDiagnostics.push(d); + } + ts.forEach(nonFileDiagnostics, pushDiagnostic); + for (var key in fileDiagnostics) { + if (ts.hasProperty(fileDiagnostics, key)) { + ts.forEach(fileDiagnostics[key], pushDiagnostic); + } + } + return ts.sortAndDeduplicateDiagnostics(allDiagnostics); + } + function sortAndDeduplicate() { + if (!diagnosticsModified) { + return; + } + diagnosticsModified = false; + nonFileDiagnostics = ts.sortAndDeduplicateDiagnostics(nonFileDiagnostics); + for (var key in fileDiagnostics) { + if (ts.hasProperty(fileDiagnostics, key)) { + fileDiagnostics[key] = ts.sortAndDeduplicateDiagnostics(fileDiagnostics[key]); + } + } + } + } + ts.createDiagnosticCollection = createDiagnosticCollection; + var escapedCharsRegExp = /[\\\"\u0000-\u001f\t\v\f\b\r\n\u2028\u2029\u0085]/g; + var escapedCharsMap = { + "\0": "\\0", + "\t": "\\t", + "\v": "\\v", + "\f": "\\f", + "\b": "\\b", + "\r": "\\r", + "\n": "\\n", + "\\": "\\\\", + "\"": "\\\"", + "\u2028": "\\u2028", + "\u2029": "\\u2029", + "\u0085": "\\u0085" + }; + function escapeString(s) { + s = escapedCharsRegExp.test(s) ? s.replace(escapedCharsRegExp, getReplacement) : s; + return s; + function getReplacement(c) { + return escapedCharsMap[c] || get16BitUnicodeEscapeSequence(c.charCodeAt(0)); + } + } + ts.escapeString = escapeString; + function isIntrinsicJsxName(name) { + var ch = name.substr(0, 1); + return ch.toLowerCase() === ch; + } + ts.isIntrinsicJsxName = isIntrinsicJsxName; + function get16BitUnicodeEscapeSequence(charCode) { + var hexCharCode = charCode.toString(16).toUpperCase(); + var paddedHexCode = ("0000" + hexCharCode).slice(-4); + return "\\u" + paddedHexCode; + } + var nonAsciiCharacters = /[^\u0000-\u007F]/g; + function escapeNonAsciiCharacters(s) { + return nonAsciiCharacters.test(s) ? + s.replace(nonAsciiCharacters, function (c) { return get16BitUnicodeEscapeSequence(c.charCodeAt(0)); }) : + s; + } + ts.escapeNonAsciiCharacters = escapeNonAsciiCharacters; + var indentStrings = ["", " "]; + function getIndentString(level) { + if (indentStrings[level] === undefined) { + indentStrings[level] = getIndentString(level - 1) + indentStrings[1]; + } + return indentStrings[level]; + } + ts.getIndentString = getIndentString; + function getIndentSize() { + return indentStrings[1].length; + } + ts.getIndentSize = getIndentSize; + function createTextWriter(newLine) { + var output = ""; + var indent = 0; + var lineStart = true; + var lineCount = 0; + var linePos = 0; + function write(s) { + if (s && s.length) { + if (lineStart) { + output += getIndentString(indent); + lineStart = false; + } + output += s; + } + } + function rawWrite(s) { + if (s !== undefined) { + if (lineStart) { + lineStart = false; + } + output += s; + } + } + function writeLiteral(s) { + if (s && s.length) { + write(s); + var lineStartsOfS = ts.computeLineStarts(s); + if (lineStartsOfS.length > 1) { + lineCount = lineCount + lineStartsOfS.length - 1; + linePos = output.length - s.length + ts.lastOrUndefined(lineStartsOfS); + } + } + } + function writeLine() { + if (!lineStart) { + output += newLine; + lineCount++; + linePos = output.length; + lineStart = true; + } + } + function writeTextOfNode(sourceFile, node) { + write(getSourceTextOfNodeFromSourceFile(sourceFile, node)); + } + return { + write: write, + rawWrite: rawWrite, + writeTextOfNode: writeTextOfNode, + writeLiteral: writeLiteral, + writeLine: writeLine, + increaseIndent: function () { return indent++; }, + decreaseIndent: function () { return indent--; }, + getIndent: function () { return indent; }, + getTextPos: function () { return output.length; }, + getLine: function () { return lineCount + 1; }, + getColumn: function () { return lineStart ? indent * getIndentSize() + 1 : output.length - linePos + 1; }, + getText: function () { return output; } + }; + } + ts.createTextWriter = createTextWriter; + function getOwnEmitOutputFilePath(sourceFile, host, extension) { + var compilerOptions = host.getCompilerOptions(); + var emitOutputFilePathWithoutExtension; + if (compilerOptions.outDir) { + emitOutputFilePathWithoutExtension = ts.removeFileExtension(getSourceFilePathInNewDir(sourceFile, host, compilerOptions.outDir)); + } + else { + emitOutputFilePathWithoutExtension = ts.removeFileExtension(sourceFile.fileName); + } + return emitOutputFilePathWithoutExtension + extension; + } + ts.getOwnEmitOutputFilePath = getOwnEmitOutputFilePath; + function getSourceFilePathInNewDir(sourceFile, host, newDirPath) { + var sourceFilePath = ts.getNormalizedAbsolutePath(sourceFile.fileName, host.getCurrentDirectory()); + sourceFilePath = sourceFilePath.replace(host.getCommonSourceDirectory(), ""); + return ts.combinePaths(newDirPath, sourceFilePath); + } + ts.getSourceFilePathInNewDir = getSourceFilePathInNewDir; + function writeFile(host, diagnostics, fileName, data, writeByteOrderMark) { + host.writeFile(fileName, data, writeByteOrderMark, function (hostErrorMessage) { + diagnostics.push(ts.createCompilerDiagnostic(ts.Diagnostics.Could_not_write_file_0_Colon_1, fileName, hostErrorMessage)); + }); + } + ts.writeFile = writeFile; + function getLineOfLocalPosition(currentSourceFile, pos) { + return ts.getLineAndCharacterOfPosition(currentSourceFile, pos).line; + } + ts.getLineOfLocalPosition = getLineOfLocalPosition; + function getFirstConstructorWithBody(node) { + return ts.forEach(node.members, function (member) { + if (member.kind === 144 && nodeIsPresent(member.body)) { + return member; + } + }); + } + ts.getFirstConstructorWithBody = getFirstConstructorWithBody; + function getSetAccessorTypeAnnotationNode(accessor) { + return accessor && accessor.parameters.length > 0 && accessor.parameters[0].type; + } + ts.getSetAccessorTypeAnnotationNode = getSetAccessorTypeAnnotationNode; + function shouldEmitToOwnFile(sourceFile, compilerOptions) { + if (!isDeclarationFile(sourceFile)) { + if ((isExternalModule(sourceFile) || !(compilerOptions.outFile || compilerOptions.out))) { + return compilerOptions.isolatedModules || !ts.fileExtensionIs(sourceFile.fileName, ".js"); + } + return false; + } + return false; + } + ts.shouldEmitToOwnFile = shouldEmitToOwnFile; + function getAllAccessorDeclarations(declarations, accessor) { + var firstAccessor; + var secondAccessor; + var getAccessor; + var setAccessor; + if (hasDynamicName(accessor)) { + firstAccessor = accessor; + if (accessor.kind === 145) { + getAccessor = accessor; + } + else if (accessor.kind === 146) { + setAccessor = accessor; + } + else { + ts.Debug.fail("Accessor has wrong kind"); + } + } + else { + ts.forEach(declarations, function (member) { + if ((member.kind === 145 || member.kind === 146) + && (member.flags & 128) === (accessor.flags & 128)) { + var memberName = getPropertyNameForPropertyNameNode(member.name); + var accessorName = getPropertyNameForPropertyNameNode(accessor.name); + if (memberName === accessorName) { + if (!firstAccessor) { + firstAccessor = member; + } + else if (!secondAccessor) { + secondAccessor = member; + } + if (member.kind === 145 && !getAccessor) { + getAccessor = member; + } + if (member.kind === 146 && !setAccessor) { + setAccessor = member; + } + } + } + }); + } + return { + firstAccessor: firstAccessor, + secondAccessor: secondAccessor, + getAccessor: getAccessor, + setAccessor: setAccessor + }; + } + ts.getAllAccessorDeclarations = getAllAccessorDeclarations; + function emitNewLineBeforeLeadingComments(currentSourceFile, writer, node, leadingComments) { + if (leadingComments && leadingComments.length && node.pos !== leadingComments[0].pos && + getLineOfLocalPosition(currentSourceFile, node.pos) !== getLineOfLocalPosition(currentSourceFile, leadingComments[0].pos)) { + writer.writeLine(); + } + } + ts.emitNewLineBeforeLeadingComments = emitNewLineBeforeLeadingComments; + function emitComments(currentSourceFile, writer, comments, trailingSeparator, newLine, writeComment) { + var emitLeadingSpace = !trailingSeparator; + ts.forEach(comments, function (comment) { + if (emitLeadingSpace) { + writer.write(" "); + emitLeadingSpace = false; + } + writeComment(currentSourceFile, writer, comment, newLine); + if (comment.hasTrailingNewLine) { + writer.writeLine(); + } + else if (trailingSeparator) { + writer.write(" "); + } + else { + emitLeadingSpace = true; + } + }); + } + ts.emitComments = emitComments; + function writeCommentRange(currentSourceFile, writer, comment, newLine) { + if (currentSourceFile.text.charCodeAt(comment.pos + 1) === 42) { + var firstCommentLineAndCharacter = ts.getLineAndCharacterOfPosition(currentSourceFile, comment.pos); + var lineCount = ts.getLineStarts(currentSourceFile).length; + var firstCommentLineIndent; + for (var pos = comment.pos, currentLine = firstCommentLineAndCharacter.line; pos < comment.end; currentLine++) { + var nextLineStart = (currentLine + 1) === lineCount + ? currentSourceFile.text.length + 1 + : getStartPositionOfLine(currentLine + 1, currentSourceFile); + if (pos !== comment.pos) { + if (firstCommentLineIndent === undefined) { + firstCommentLineIndent = calculateIndent(getStartPositionOfLine(firstCommentLineAndCharacter.line, currentSourceFile), comment.pos); + } + var currentWriterIndentSpacing = writer.getIndent() * getIndentSize(); + var spacesToEmit = currentWriterIndentSpacing - firstCommentLineIndent + calculateIndent(pos, nextLineStart); + if (spacesToEmit > 0) { + var numberOfSingleSpacesToEmit = spacesToEmit % getIndentSize(); + var indentSizeSpaceString = getIndentString((spacesToEmit - numberOfSingleSpacesToEmit) / getIndentSize()); + writer.rawWrite(indentSizeSpaceString); + while (numberOfSingleSpacesToEmit) { + writer.rawWrite(" "); + numberOfSingleSpacesToEmit--; + } + } + else { + writer.rawWrite(""); + } + } + writeTrimmedCurrentLine(pos, nextLineStart); + pos = nextLineStart; + } + } + else { + writer.write(currentSourceFile.text.substring(comment.pos, comment.end)); + } + function writeTrimmedCurrentLine(pos, nextLineStart) { + var end = Math.min(comment.end, nextLineStart - 1); + var currentLineText = currentSourceFile.text.substring(pos, end).replace(/^\s+|\s+$/g, ""); + if (currentLineText) { + writer.write(currentLineText); + if (end !== comment.end) { + writer.writeLine(); + } + } + else { + writer.writeLiteral(newLine); + } + } + function calculateIndent(pos, end) { + var currentLineIndent = 0; + for (; pos < end && ts.isWhiteSpace(currentSourceFile.text.charCodeAt(pos)); pos++) { + if (currentSourceFile.text.charCodeAt(pos) === 9) { + currentLineIndent += getIndentSize() - (currentLineIndent % getIndentSize()); + } + else { + currentLineIndent++; + } + } + return currentLineIndent; + } + } + ts.writeCommentRange = writeCommentRange; + function modifierToFlag(token) { + switch (token) { + case 113: return 128; + case 112: return 16; + case 111: return 64; + case 110: return 32; + case 115: return 256; + case 82: return 1; + case 122: return 2; + case 74: return 32768; + case 77: return 1024; + case 118: return 512; + } + return 0; + } + ts.modifierToFlag = modifierToFlag; + function isLeftHandSideExpression(expr) { + if (expr) { + switch (expr.kind) { + case 166: + case 167: + case 169: + case 168: + case 233: + case 234: + case 170: + case 164: + case 172: + case 165: + case 186: + case 173: + case 69: + case 10: + case 8: + case 9: + case 11: + case 183: + case 84: + case 93: + case 97: + case 99: + case 95: + return true; + } + } + return false; + } + ts.isLeftHandSideExpression = isLeftHandSideExpression; + function isAssignmentOperator(token) { + return token >= 56 && token <= 68; + } + ts.isAssignmentOperator = isAssignmentOperator; + function isExpressionWithTypeArgumentsInClassExtendsClause(node) { + return node.kind === 188 && + node.parent.token === 83 && + isClassLike(node.parent.parent); + } + ts.isExpressionWithTypeArgumentsInClassExtendsClause = isExpressionWithTypeArgumentsInClassExtendsClause; + function isSupportedExpressionWithTypeArguments(node) { + return isSupportedExpressionWithTypeArgumentsRest(node.expression); + } + ts.isSupportedExpressionWithTypeArguments = isSupportedExpressionWithTypeArguments; + function isSupportedExpressionWithTypeArgumentsRest(node) { + if (node.kind === 69) { + return true; + } + else if (isPropertyAccessExpression(node)) { + return isSupportedExpressionWithTypeArgumentsRest(node.expression); + } + else { + return false; + } + } + function isRightSideOfQualifiedNameOrPropertyAccess(node) { + return (node.parent.kind === 135 && node.parent.right === node) || + (node.parent.kind === 166 && node.parent.name === node); + } + ts.isRightSideOfQualifiedNameOrPropertyAccess = isRightSideOfQualifiedNameOrPropertyAccess; + function isEmptyObjectLiteralOrArrayLiteral(expression) { + var kind = expression.kind; + if (kind === 165) { + return expression.properties.length === 0; + } + if (kind === 164) { + return expression.elements.length === 0; + } + return false; + } + ts.isEmptyObjectLiteralOrArrayLiteral = isEmptyObjectLiteralOrArrayLiteral; + function getLocalSymbolForExportDefault(symbol) { + return symbol && symbol.valueDeclaration && (symbol.valueDeclaration.flags & 1024) ? symbol.valueDeclaration.localSymbol : undefined; + } + ts.getLocalSymbolForExportDefault = getLocalSymbolForExportDefault; + function isJavaScript(fileName) { + return ts.fileExtensionIs(fileName, ".js"); + } + ts.isJavaScript = isJavaScript; + function isTsx(fileName) { + return ts.fileExtensionIs(fileName, ".tsx"); + } + ts.isTsx = isTsx; + function getExpandedCharCodes(input) { + var output = []; + var length = input.length; + for (var i = 0; i < length; i++) { + var charCode = input.charCodeAt(i); + if (charCode < 0x80) { + output.push(charCode); + } + else if (charCode < 0x800) { + output.push((charCode >> 6) | 192); + output.push((charCode & 63) | 128); + } + else if (charCode < 0x10000) { + output.push((charCode >> 12) | 224); + output.push(((charCode >> 6) & 63) | 128); + output.push((charCode & 63) | 128); + } + else if (charCode < 0x20000) { + output.push((charCode >> 18) | 240); + output.push(((charCode >> 12) & 63) | 128); + output.push(((charCode >> 6) & 63) | 128); + output.push((charCode & 63) | 128); + } + else { + ts.Debug.assert(false, "Unexpected code point"); + } + } + return output; + } + var base64Digits = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="; + function convertToBase64(input) { + var result = ""; + var charCodes = getExpandedCharCodes(input); + var i = 0; + var length = charCodes.length; + var byte1, byte2, byte3, byte4; + while (i < length) { + byte1 = charCodes[i] >> 2; + byte2 = (charCodes[i] & 3) << 4 | charCodes[i + 1] >> 4; + byte3 = (charCodes[i + 1] & 15) << 2 | charCodes[i + 2] >> 6; + byte4 = charCodes[i + 2] & 63; + if (i + 1 >= length) { + byte3 = byte4 = 64; + } + else if (i + 2 >= length) { + byte4 = 64; + } + result += base64Digits.charAt(byte1) + base64Digits.charAt(byte2) + base64Digits.charAt(byte3) + base64Digits.charAt(byte4); + i += 3; + } + return result; + } + ts.convertToBase64 = convertToBase64; + var carriageReturnLineFeed = "\r\n"; + var lineFeed = "\n"; + function getNewLineCharacter(options) { + if (options.newLine === 0) { + return carriageReturnLineFeed; + } + else if (options.newLine === 1) { + return lineFeed; + } + else if (ts.sys) { + return ts.sys.newLine; + } + return carriageReturnLineFeed; + } + ts.getNewLineCharacter = getNewLineCharacter; +})(ts || (ts = {})); +var ts; +(function (ts) { + function getDefaultLibFileName(options) { + return options.target === 2 ? "lib.es6.d.ts" : "lib.d.ts"; + } + ts.getDefaultLibFileName = getDefaultLibFileName; + function textSpanEnd(span) { + return span.start + span.length; + } + ts.textSpanEnd = textSpanEnd; + function textSpanIsEmpty(span) { + return span.length === 0; + } + ts.textSpanIsEmpty = textSpanIsEmpty; + function textSpanContainsPosition(span, position) { + return position >= span.start && position < textSpanEnd(span); + } + ts.textSpanContainsPosition = textSpanContainsPosition; + function textSpanContainsTextSpan(span, other) { + return other.start >= span.start && textSpanEnd(other) <= textSpanEnd(span); + } + ts.textSpanContainsTextSpan = textSpanContainsTextSpan; + function textSpanOverlapsWith(span, other) { + var overlapStart = Math.max(span.start, other.start); + var overlapEnd = Math.min(textSpanEnd(span), textSpanEnd(other)); + return overlapStart < overlapEnd; + } + ts.textSpanOverlapsWith = textSpanOverlapsWith; + function textSpanOverlap(span1, span2) { + var overlapStart = Math.max(span1.start, span2.start); + var overlapEnd = Math.min(textSpanEnd(span1), textSpanEnd(span2)); + if (overlapStart < overlapEnd) { + return createTextSpanFromBounds(overlapStart, overlapEnd); + } + return undefined; + } + ts.textSpanOverlap = textSpanOverlap; + function textSpanIntersectsWithTextSpan(span, other) { + return other.start <= textSpanEnd(span) && textSpanEnd(other) >= span.start; + } + ts.textSpanIntersectsWithTextSpan = textSpanIntersectsWithTextSpan; + function textSpanIntersectsWith(span, start, length) { + var end = start + length; + return start <= textSpanEnd(span) && end >= span.start; + } + ts.textSpanIntersectsWith = textSpanIntersectsWith; + function decodedTextSpanIntersectsWith(start1, length1, start2, length2) { + var end1 = start1 + length1; + var end2 = start2 + length2; + return start2 <= end1 && end2 >= start1; + } + ts.decodedTextSpanIntersectsWith = decodedTextSpanIntersectsWith; + function textSpanIntersectsWithPosition(span, position) { + return position <= textSpanEnd(span) && position >= span.start; + } + ts.textSpanIntersectsWithPosition = textSpanIntersectsWithPosition; + function textSpanIntersection(span1, span2) { + var intersectStart = Math.max(span1.start, span2.start); + var intersectEnd = Math.min(textSpanEnd(span1), textSpanEnd(span2)); + if (intersectStart <= intersectEnd) { + return createTextSpanFromBounds(intersectStart, intersectEnd); + } + return undefined; + } + ts.textSpanIntersection = textSpanIntersection; + function createTextSpan(start, length) { + if (start < 0) { + throw new Error("start < 0"); + } + if (length < 0) { + throw new Error("length < 0"); + } + return { start: start, length: length }; + } + ts.createTextSpan = createTextSpan; + function createTextSpanFromBounds(start, end) { + return createTextSpan(start, end - start); + } + ts.createTextSpanFromBounds = createTextSpanFromBounds; + function textChangeRangeNewSpan(range) { + return createTextSpan(range.span.start, range.newLength); + } + ts.textChangeRangeNewSpan = textChangeRangeNewSpan; + function textChangeRangeIsUnchanged(range) { + return textSpanIsEmpty(range.span) && range.newLength === 0; + } + ts.textChangeRangeIsUnchanged = textChangeRangeIsUnchanged; + function createTextChangeRange(span, newLength) { + if (newLength < 0) { + throw new Error("newLength < 0"); + } + return { span: span, newLength: newLength }; + } + ts.createTextChangeRange = createTextChangeRange; + ts.unchangedTextChangeRange = createTextChangeRange(createTextSpan(0, 0), 0); + function collapseTextChangeRangesAcrossMultipleVersions(changes) { + if (changes.length === 0) { + return ts.unchangedTextChangeRange; + } + if (changes.length === 1) { + return changes[0]; + } + var change0 = changes[0]; + var oldStartN = change0.span.start; + var oldEndN = textSpanEnd(change0.span); + var newEndN = oldStartN + change0.newLength; + for (var i = 1; i < changes.length; i++) { + var nextChange = changes[i]; + var oldStart1 = oldStartN; + var oldEnd1 = oldEndN; + var newEnd1 = newEndN; + var oldStart2 = nextChange.span.start; + var oldEnd2 = textSpanEnd(nextChange.span); + var newEnd2 = oldStart2 + nextChange.newLength; + oldStartN = Math.min(oldStart1, oldStart2); + oldEndN = Math.max(oldEnd1, oldEnd1 + (oldEnd2 - newEnd1)); + newEndN = Math.max(newEnd2, newEnd2 + (newEnd1 - oldEnd2)); + } + return createTextChangeRange(createTextSpanFromBounds(oldStartN, oldEndN), newEndN - oldStartN); + } + ts.collapseTextChangeRangesAcrossMultipleVersions = collapseTextChangeRangesAcrossMultipleVersions; + function getTypeParameterOwner(d) { + if (d && d.kind === 137) { + for (var current = d; current; current = current.parent) { + if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 215) { + return current; + } + } + } + } + ts.getTypeParameterOwner = getTypeParameterOwner; +})(ts || (ts = {})); +var ts; +(function (ts) { + var nodeConstructors = new Array(272); + ts.parseTime = 0; + function getNodeConstructor(kind) { + return nodeConstructors[kind] || (nodeConstructors[kind] = ts.objectAllocator.getNodeConstructor(kind)); + } + ts.getNodeConstructor = getNodeConstructor; + function createNode(kind, pos, end) { + return new (getNodeConstructor(kind))(pos, end); + } + ts.createNode = createNode; + function visitNode(cbNode, node) { + if (node) { + return cbNode(node); + } + } + function visitNodeArray(cbNodes, nodes) { + if (nodes) { + return cbNodes(nodes); + } + } + function visitEachNode(cbNode, nodes) { + if (nodes) { + for (var _i = 0; _i < nodes.length; _i++) { + var node = nodes[_i]; + var result = cbNode(node); + if (result) { + return result; + } + } + } + } + function forEachChild(node, cbNode, cbNodeArray) { + if (!node) { + return; + } + var visitNodes = cbNodeArray ? visitNodeArray : visitEachNode; + var cbNodes = cbNodeArray || cbNode; + switch (node.kind) { + case 135: + return visitNode(cbNode, node.left) || + visitNode(cbNode, node.right); + case 137: + return visitNode(cbNode, node.name) || + visitNode(cbNode, node.constraint) || + visitNode(cbNode, node.expression); + case 246: + return visitNodes(cbNodes, node.decorators) || + visitNodes(cbNodes, node.modifiers) || + visitNode(cbNode, node.name) || + visitNode(cbNode, node.questionToken) || + visitNode(cbNode, node.equalsToken) || + visitNode(cbNode, node.objectAssignmentInitializer); + case 138: + case 141: + case 140: + case 245: + case 211: + case 163: + return visitNodes(cbNodes, node.decorators) || + visitNodes(cbNodes, node.modifiers) || + visitNode(cbNode, node.propertyName) || + visitNode(cbNode, node.dotDotDotToken) || + visitNode(cbNode, node.name) || + visitNode(cbNode, node.questionToken) || + visitNode(cbNode, node.type) || + visitNode(cbNode, node.initializer); + case 152: + case 153: + case 147: + case 148: + case 149: + return visitNodes(cbNodes, node.decorators) || + visitNodes(cbNodes, node.modifiers) || + visitNodes(cbNodes, node.typeParameters) || + visitNodes(cbNodes, node.parameters) || + visitNode(cbNode, node.type); + case 143: + case 142: + case 144: + case 145: + case 146: + case 173: + case 213: + case 174: + return visitNodes(cbNodes, node.decorators) || + visitNodes(cbNodes, node.modifiers) || + visitNode(cbNode, node.asteriskToken) || + visitNode(cbNode, node.name) || + visitNode(cbNode, node.questionToken) || + visitNodes(cbNodes, node.typeParameters) || + visitNodes(cbNodes, node.parameters) || + visitNode(cbNode, node.type) || + visitNode(cbNode, node.equalsGreaterThanToken) || + visitNode(cbNode, node.body); + case 151: + return visitNode(cbNode, node.typeName) || + visitNodes(cbNodes, node.typeArguments); + case 150: + return visitNode(cbNode, node.parameterName) || + visitNode(cbNode, node.type); + case 154: + return visitNode(cbNode, node.exprName); + case 155: + return visitNodes(cbNodes, node.members); + case 156: + return visitNode(cbNode, node.elementType); + case 157: + return visitNodes(cbNodes, node.elementTypes); + case 158: + case 159: + return visitNodes(cbNodes, node.types); + case 160: + return visitNode(cbNode, node.type); + case 161: + case 162: + return visitNodes(cbNodes, node.elements); + case 164: + return visitNodes(cbNodes, node.elements); + case 165: + return visitNodes(cbNodes, node.properties); + case 166: + return visitNode(cbNode, node.expression) || + visitNode(cbNode, node.dotToken) || + visitNode(cbNode, node.name); + case 167: + return visitNode(cbNode, node.expression) || + visitNode(cbNode, node.argumentExpression); + case 168: + case 169: + return visitNode(cbNode, node.expression) || + visitNodes(cbNodes, node.typeArguments) || + visitNodes(cbNodes, node.arguments); + case 170: + return visitNode(cbNode, node.tag) || + visitNode(cbNode, node.template); + case 171: + return visitNode(cbNode, node.type) || + visitNode(cbNode, node.expression); + case 172: + return visitNode(cbNode, node.expression); + case 175: + return visitNode(cbNode, node.expression); + case 176: + return visitNode(cbNode, node.expression); + case 177: + return visitNode(cbNode, node.expression); + case 179: + return visitNode(cbNode, node.operand); + case 184: + return visitNode(cbNode, node.asteriskToken) || + visitNode(cbNode, node.expression); + case 178: + return visitNode(cbNode, node.expression); + case 180: + return visitNode(cbNode, node.operand); + case 181: + return visitNode(cbNode, node.left) || + visitNode(cbNode, node.operatorToken) || + visitNode(cbNode, node.right); + case 189: + return visitNode(cbNode, node.expression) || + visitNode(cbNode, node.type); + case 182: + return visitNode(cbNode, node.condition) || + visitNode(cbNode, node.questionToken) || + visitNode(cbNode, node.whenTrue) || + visitNode(cbNode, node.colonToken) || + visitNode(cbNode, node.whenFalse); + case 185: + return visitNode(cbNode, node.expression); + case 192: + case 219: + return visitNodes(cbNodes, node.statements); + case 248: + return visitNodes(cbNodes, node.statements) || + visitNode(cbNode, node.endOfFileToken); + case 193: + return visitNodes(cbNodes, node.decorators) || + visitNodes(cbNodes, node.modifiers) || + visitNode(cbNode, node.declarationList); + case 212: + return visitNodes(cbNodes, node.declarations); + case 195: + return visitNode(cbNode, node.expression); + case 196: + return visitNode(cbNode, node.expression) || + visitNode(cbNode, node.thenStatement) || + visitNode(cbNode, node.elseStatement); + case 197: + return visitNode(cbNode, node.statement) || + visitNode(cbNode, node.expression); + case 198: + return visitNode(cbNode, node.expression) || + visitNode(cbNode, node.statement); + case 199: + return visitNode(cbNode, node.initializer) || + visitNode(cbNode, node.condition) || + visitNode(cbNode, node.incrementor) || + visitNode(cbNode, node.statement); + case 200: + return visitNode(cbNode, node.initializer) || + visitNode(cbNode, node.expression) || + visitNode(cbNode, node.statement); + case 201: + return visitNode(cbNode, node.initializer) || + visitNode(cbNode, node.expression) || + visitNode(cbNode, node.statement); + case 202: + case 203: + return visitNode(cbNode, node.label); + case 204: + return visitNode(cbNode, node.expression); + case 205: + return visitNode(cbNode, node.expression) || + visitNode(cbNode, node.statement); + case 206: + return visitNode(cbNode, node.expression) || + visitNode(cbNode, node.caseBlock); + case 220: + return visitNodes(cbNodes, node.clauses); + case 241: + return visitNode(cbNode, node.expression) || + visitNodes(cbNodes, node.statements); + case 242: + return visitNodes(cbNodes, node.statements); + case 207: + return visitNode(cbNode, node.label) || + visitNode(cbNode, node.statement); + case 208: + return visitNode(cbNode, node.expression); + case 209: + return visitNode(cbNode, node.tryBlock) || + visitNode(cbNode, node.catchClause) || + visitNode(cbNode, node.finallyBlock); + case 244: + return visitNode(cbNode, node.variableDeclaration) || + visitNode(cbNode, node.block); + case 139: + return visitNode(cbNode, node.expression); + case 214: + case 186: + return visitNodes(cbNodes, node.decorators) || + visitNodes(cbNodes, node.modifiers) || + visitNode(cbNode, node.name) || + visitNodes(cbNodes, node.typeParameters) || + visitNodes(cbNodes, node.heritageClauses) || + visitNodes(cbNodes, node.members); + case 215: + return visitNodes(cbNodes, node.decorators) || + visitNodes(cbNodes, node.modifiers) || + visitNode(cbNode, node.name) || + visitNodes(cbNodes, node.typeParameters) || + visitNodes(cbNodes, node.heritageClauses) || + visitNodes(cbNodes, node.members); + case 216: + return visitNodes(cbNodes, node.decorators) || + visitNodes(cbNodes, node.modifiers) || + visitNode(cbNode, node.name) || + visitNodes(cbNodes, node.typeParameters) || + visitNode(cbNode, node.type); + case 217: + return visitNodes(cbNodes, node.decorators) || + visitNodes(cbNodes, node.modifiers) || + visitNode(cbNode, node.name) || + visitNodes(cbNodes, node.members); + case 247: + return visitNode(cbNode, node.name) || + visitNode(cbNode, node.initializer); + case 218: + return visitNodes(cbNodes, node.decorators) || + visitNodes(cbNodes, node.modifiers) || + visitNode(cbNode, node.name) || + visitNode(cbNode, node.body); + case 221: + return visitNodes(cbNodes, node.decorators) || + visitNodes(cbNodes, node.modifiers) || + visitNode(cbNode, node.name) || + visitNode(cbNode, node.moduleReference); + case 222: + return visitNodes(cbNodes, node.decorators) || + visitNodes(cbNodes, node.modifiers) || + visitNode(cbNode, node.importClause) || + visitNode(cbNode, node.moduleSpecifier); + case 223: + return visitNode(cbNode, node.name) || + visitNode(cbNode, node.namedBindings); + case 224: + return visitNode(cbNode, node.name); + case 225: + case 229: + return visitNodes(cbNodes, node.elements); + case 228: + return visitNodes(cbNodes, node.decorators) || + visitNodes(cbNodes, node.modifiers) || + visitNode(cbNode, node.exportClause) || + visitNode(cbNode, node.moduleSpecifier); + case 226: + case 230: + return visitNode(cbNode, node.propertyName) || + visitNode(cbNode, node.name); + case 227: + return visitNodes(cbNodes, node.decorators) || + visitNodes(cbNodes, node.modifiers) || + visitNode(cbNode, node.expression); + case 183: + return visitNode(cbNode, node.head) || visitNodes(cbNodes, node.templateSpans); + case 190: + return visitNode(cbNode, node.expression) || visitNode(cbNode, node.literal); + case 136: + return visitNode(cbNode, node.expression); + case 243: + return visitNodes(cbNodes, node.types); + case 188: + return visitNode(cbNode, node.expression) || + visitNodes(cbNodes, node.typeArguments); + case 232: + return visitNode(cbNode, node.expression); + case 231: + return visitNodes(cbNodes, node.decorators); + case 233: + return visitNode(cbNode, node.openingElement) || + visitNodes(cbNodes, node.children) || + visitNode(cbNode, node.closingElement); + case 234: + case 235: + return visitNode(cbNode, node.tagName) || + visitNodes(cbNodes, node.attributes); + case 238: + return visitNode(cbNode, node.name) || + visitNode(cbNode, node.initializer); + case 239: + return visitNode(cbNode, node.expression); + case 240: + return visitNode(cbNode, node.expression); + case 237: + return visitNode(cbNode, node.tagName); + case 249: + return visitNode(cbNode, node.type); + case 253: + return visitNodes(cbNodes, node.types); + case 254: + return visitNodes(cbNodes, node.types); + case 252: + return visitNode(cbNode, node.elementType); + case 256: + return visitNode(cbNode, node.type); + case 255: + return visitNode(cbNode, node.type); + case 257: + return visitNodes(cbNodes, node.members); + case 259: + return visitNode(cbNode, node.name) || + visitNodes(cbNodes, node.typeArguments); + case 260: + return visitNode(cbNode, node.type); + case 261: + return visitNodes(cbNodes, node.parameters) || + visitNode(cbNode, node.type); + case 262: + return visitNode(cbNode, node.type); + case 263: + return visitNode(cbNode, node.type); + case 264: + return visitNode(cbNode, node.type); + case 258: + return visitNode(cbNode, node.name) || + visitNode(cbNode, node.type); + case 265: + return visitNodes(cbNodes, node.tags); + case 267: + return visitNode(cbNode, node.preParameterName) || + visitNode(cbNode, node.typeExpression) || + visitNode(cbNode, node.postParameterName); + case 268: + return visitNode(cbNode, node.typeExpression); + case 269: + return visitNode(cbNode, node.typeExpression); + case 270: + return visitNodes(cbNodes, node.typeParameters); + } + } + ts.forEachChild = forEachChild; + function createSourceFile(fileName, sourceText, languageVersion, setParentNodes) { + if (setParentNodes === void 0) { setParentNodes = false; } + var start = new Date().getTime(); + var result = Parser.parseSourceFile(fileName, sourceText, languageVersion, undefined, setParentNodes); + ts.parseTime += new Date().getTime() - start; + return result; + } + ts.createSourceFile = createSourceFile; + function updateSourceFile(sourceFile, newText, textChangeRange, aggressiveChecks) { + return IncrementalParser.updateSourceFile(sourceFile, newText, textChangeRange, aggressiveChecks); + } + ts.updateSourceFile = updateSourceFile; + function parseIsolatedJSDocComment(content, start, length) { + return Parser.JSDocParser.parseIsolatedJSDocComment(content, start, length); + } + ts.parseIsolatedJSDocComment = parseIsolatedJSDocComment; + function parseJSDocTypeExpressionForTests(content, start, length) { + return Parser.JSDocParser.parseJSDocTypeExpressionForTests(content, start, length); + } + ts.parseJSDocTypeExpressionForTests = parseJSDocTypeExpressionForTests; + var Parser; + (function (Parser) { + var scanner = ts.createScanner(2, true); + var disallowInAndDecoratorContext = 1 | 4; + var sourceFile; + var parseDiagnostics; + var syntaxCursor; + var token; + var sourceText; + var nodeCount; + var identifiers; + var identifierCount; + var parsingContext; + var contextFlags; + var parseErrorBeforeNextFinishedNode = false; + function parseSourceFile(fileName, _sourceText, languageVersion, _syntaxCursor, setParentNodes) { + initializeState(fileName, _sourceText, languageVersion, _syntaxCursor); + var result = parseSourceFileWorker(fileName, languageVersion, setParentNodes); + clearState(); + return result; + } + Parser.parseSourceFile = parseSourceFile; + function initializeState(fileName, _sourceText, languageVersion, _syntaxCursor) { + sourceText = _sourceText; + syntaxCursor = _syntaxCursor; + parseDiagnostics = []; + parsingContext = 0; + identifiers = {}; + identifierCount = 0; + nodeCount = 0; + contextFlags = ts.isJavaScript(fileName) ? 32 : 0; + parseErrorBeforeNextFinishedNode = false; + scanner.setText(sourceText); + scanner.setOnError(scanError); + scanner.setScriptTarget(languageVersion); + scanner.setLanguageVariant(ts.isTsx(fileName) ? 1 : 0); + } + function clearState() { + scanner.setText(""); + scanner.setOnError(undefined); + parseDiagnostics = undefined; + sourceFile = undefined; + identifiers = undefined; + syntaxCursor = undefined; + sourceText = undefined; + } + function parseSourceFileWorker(fileName, languageVersion, setParentNodes) { + sourceFile = createSourceFile(fileName, languageVersion); + token = nextToken(); + processReferenceComments(sourceFile); + sourceFile.statements = parseList(0, parseStatement); + ts.Debug.assert(token === 1); + sourceFile.endOfFileToken = parseTokenNode(); + setExternalModuleIndicator(sourceFile); + sourceFile.nodeCount = nodeCount; + sourceFile.identifierCount = identifierCount; + sourceFile.identifiers = identifiers; + sourceFile.parseDiagnostics = parseDiagnostics; + if (setParentNodes) { + fixupParentReferences(sourceFile); + } + if (ts.isJavaScript(fileName)) { + addJSDocComments(); + } + return sourceFile; + } + function addJSDocComments() { + forEachChild(sourceFile, visit); + return; + function visit(node) { + switch (node.kind) { + case 193: + case 213: + case 138: + addJSDocComment(node); + } + forEachChild(node, visit); + } + } + function addJSDocComment(node) { + var comments = ts.getLeadingCommentRangesOfNode(node, sourceFile); + if (comments) { + for (var _i = 0; _i < comments.length; _i++) { + var comment = comments[_i]; + var jsDocComment = JSDocParser.parseJSDocComment(node, comment.pos, comment.end - comment.pos); + if (jsDocComment) { + node.jsDocComment = jsDocComment; + } + } + } + } + function fixupParentReferences(sourceFile) { + var parent = sourceFile; + forEachChild(sourceFile, visitNode); + return; + function visitNode(n) { + if (n.parent !== parent) { + n.parent = parent; + var saveParent = parent; + parent = n; + forEachChild(n, visitNode); + parent = saveParent; + } + } + } + Parser.fixupParentReferences = fixupParentReferences; + function createSourceFile(fileName, languageVersion) { + var sourceFile = createNode(248, 0); + sourceFile.pos = 0; + sourceFile.end = sourceText.length; + sourceFile.text = sourceText; + sourceFile.bindDiagnostics = []; + sourceFile.languageVersion = languageVersion; + sourceFile.fileName = ts.normalizePath(fileName); + sourceFile.flags = ts.fileExtensionIs(sourceFile.fileName, ".d.ts") ? 8192 : 0; + sourceFile.languageVariant = ts.isTsx(sourceFile.fileName) ? 1 : 0; + return sourceFile; + } + function setContextFlag(val, flag) { + if (val) { + contextFlags |= flag; + } + else { + contextFlags &= ~flag; + } + } + function setDisallowInContext(val) { + setContextFlag(val, 1); + } + function setYieldContext(val) { + setContextFlag(val, 2); + } + function setDecoratorContext(val) { + setContextFlag(val, 4); + } + function setAwaitContext(val) { + setContextFlag(val, 8); + } + function doOutsideOfContext(context, func) { + var contextFlagsToClear = context & contextFlags; + if (contextFlagsToClear) { + setContextFlag(false, contextFlagsToClear); + var result = func(); + setContextFlag(true, contextFlagsToClear); + return result; + } + return func(); + } + function doInsideOfContext(context, func) { + var contextFlagsToSet = context & ~contextFlags; + if (contextFlagsToSet) { + setContextFlag(true, contextFlagsToSet); + var result = func(); + setContextFlag(false, contextFlagsToSet); + return result; + } + return func(); + } + function allowInAnd(func) { + return doOutsideOfContext(1, func); + } + function disallowInAnd(func) { + return doInsideOfContext(1, func); + } + function doInYieldContext(func) { + return doInsideOfContext(2, func); + } + function doOutsideOfYieldContext(func) { + return doOutsideOfContext(2, func); + } + function doInDecoratorContext(func) { + return doInsideOfContext(4, func); + } + function doInAwaitContext(func) { + return doInsideOfContext(8, func); + } + function doOutsideOfAwaitContext(func) { + return doOutsideOfContext(8, func); + } + function doInYieldAndAwaitContext(func) { + return doInsideOfContext(2 | 8, func); + } + function doOutsideOfYieldAndAwaitContext(func) { + return doOutsideOfContext(2 | 8, func); + } + function inContext(flags) { + return (contextFlags & flags) !== 0; + } + function inYieldContext() { + return inContext(2); + } + function inDisallowInContext() { + return inContext(1); + } + function inDecoratorContext() { + return inContext(4); + } + function inAwaitContext() { + return inContext(8); + } + function parseErrorAtCurrentToken(message, arg0) { + var start = scanner.getTokenPos(); + var length = scanner.getTextPos() - start; + parseErrorAtPosition(start, length, message, arg0); + } + function parseErrorAtPosition(start, length, message, arg0) { + var lastError = ts.lastOrUndefined(parseDiagnostics); + if (!lastError || start !== lastError.start) { + parseDiagnostics.push(ts.createFileDiagnostic(sourceFile, start, length, message, arg0)); + } + parseErrorBeforeNextFinishedNode = true; + } + function scanError(message, length) { + var pos = scanner.getTextPos(); + parseErrorAtPosition(pos, length || 0, message); + } + function getNodePos() { + return scanner.getStartPos(); + } + function getNodeEnd() { + return scanner.getStartPos(); + } + function nextToken() { + return token = scanner.scan(); + } + function getTokenPos(pos) { + return ts.skipTrivia(sourceText, pos); + } + function reScanGreaterToken() { + return token = scanner.reScanGreaterToken(); + } + function reScanSlashToken() { + return token = scanner.reScanSlashToken(); + } + function reScanTemplateToken() { + return token = scanner.reScanTemplateToken(); + } + function scanJsxIdentifier() { + return token = scanner.scanJsxIdentifier(); + } + function scanJsxText() { + return token = scanner.scanJsxToken(); + } + function speculationHelper(callback, isLookAhead) { + var saveToken = token; + var saveParseDiagnosticsLength = parseDiagnostics.length; + var saveParseErrorBeforeNextFinishedNode = parseErrorBeforeNextFinishedNode; + var saveContextFlags = contextFlags; + var result = isLookAhead + ? scanner.lookAhead(callback) + : scanner.tryScan(callback); + ts.Debug.assert(saveContextFlags === contextFlags); + if (!result || isLookAhead) { + token = saveToken; + parseDiagnostics.length = saveParseDiagnosticsLength; + parseErrorBeforeNextFinishedNode = saveParseErrorBeforeNextFinishedNode; + } + return result; + } + function lookAhead(callback) { + return speculationHelper(callback, true); + } + function tryParse(callback) { + return speculationHelper(callback, false); + } + function isIdentifier() { + if (token === 69) { + return true; + } + if (token === 114 && inYieldContext()) { + return false; + } + if (token === 119 && inAwaitContext()) { + return false; + } + return token > 105; + } + function parseExpected(kind, diagnosticMessage, shouldAdvance) { + if (shouldAdvance === void 0) { shouldAdvance = true; } + if (token === kind) { + if (shouldAdvance) { + nextToken(); + } + return true; + } + if (diagnosticMessage) { + parseErrorAtCurrentToken(diagnosticMessage); + } + else { + parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(kind)); + } + return false; + } + function parseOptional(t) { + if (token === t) { + nextToken(); + return true; + } + return false; + } + function parseOptionalToken(t) { + if (token === t) { + return parseTokenNode(); + } + return undefined; + } + function parseExpectedToken(t, reportAtCurrentPosition, diagnosticMessage, arg0) { + return parseOptionalToken(t) || + createMissingNode(t, reportAtCurrentPosition, diagnosticMessage, arg0); + } + function parseTokenNode() { + var node = createNode(token); + nextToken(); + return finishNode(node); + } + function canParseSemicolon() { + if (token === 23) { + return true; + } + return token === 16 || token === 1 || scanner.hasPrecedingLineBreak(); + } + function parseSemicolon() { + if (canParseSemicolon()) { + if (token === 23) { + nextToken(); + } + return true; + } + else { + return parseExpected(23); + } + } + function createNode(kind, pos) { + nodeCount++; + if (!(pos >= 0)) { + pos = scanner.getStartPos(); + } + return new (nodeConstructors[kind] || (nodeConstructors[kind] = ts.objectAllocator.getNodeConstructor(kind)))(pos, pos); + } + function finishNode(node, end) { + node.end = end === undefined ? scanner.getStartPos() : end; + if (contextFlags) { + node.parserContextFlags = contextFlags; + } + if (parseErrorBeforeNextFinishedNode) { + parseErrorBeforeNextFinishedNode = false; + node.parserContextFlags |= 16; + } + return node; + } + function createMissingNode(kind, reportAtCurrentPosition, diagnosticMessage, arg0) { + if (reportAtCurrentPosition) { + parseErrorAtPosition(scanner.getStartPos(), 0, diagnosticMessage, arg0); + } + else { + parseErrorAtCurrentToken(diagnosticMessage, arg0); + } + var result = createNode(kind, scanner.getStartPos()); + result.text = ""; + return finishNode(result); + } + function internIdentifier(text) { + text = ts.escapeIdentifier(text); + return ts.hasProperty(identifiers, text) ? identifiers[text] : (identifiers[text] = text); + } + function createIdentifier(isIdentifier, diagnosticMessage) { + identifierCount++; + if (isIdentifier) { + var node = createNode(69); + if (token !== 69) { + node.originalKeywordKind = token; + } + node.text = internIdentifier(scanner.getTokenValue()); + nextToken(); + return finishNode(node); + } + return createMissingNode(69, false, diagnosticMessage || ts.Diagnostics.Identifier_expected); + } + function parseIdentifier(diagnosticMessage) { + return createIdentifier(isIdentifier(), diagnosticMessage); + } + function parseIdentifierName() { + return createIdentifier(ts.tokenIsIdentifierOrKeyword(token)); + } + function isLiteralPropertyName() { + return ts.tokenIsIdentifierOrKeyword(token) || + token === 9 || + token === 8; + } + function parsePropertyNameWorker(allowComputedPropertyNames) { + if (token === 9 || token === 8) { + return parseLiteralNode(true); + } + if (allowComputedPropertyNames && token === 19) { + return parseComputedPropertyName(); + } + return parseIdentifierName(); + } + function parsePropertyName() { + return parsePropertyNameWorker(true); + } + function parseSimplePropertyName() { + return parsePropertyNameWorker(false); + } + function isSimplePropertyName() { + return token === 9 || token === 8 || ts.tokenIsIdentifierOrKeyword(token); + } + function parseComputedPropertyName() { + var node = createNode(136); + parseExpected(19); + node.expression = allowInAnd(parseExpression); + parseExpected(20); + return finishNode(node); + } + function parseContextualModifier(t) { + return token === t && tryParse(nextTokenCanFollowModifier); + } + function nextTokenCanFollowModifier() { + if (token === 74) { + return nextToken() === 81; + } + if (token === 82) { + nextToken(); + if (token === 77) { + return lookAhead(nextTokenIsClassOrFunction); + } + return token !== 37 && token !== 15 && canFollowModifier(); + } + if (token === 77) { + return nextTokenIsClassOrFunction(); + } + if (token === 113) { + nextToken(); + return canFollowModifier(); + } + nextToken(); + if (scanner.hasPrecedingLineBreak()) { + return false; + } + return canFollowModifier(); + } + function parseAnyContextualModifier() { + return ts.isModifier(token) && tryParse(nextTokenCanFollowModifier); + } + function canFollowModifier() { + return token === 19 + || token === 15 + || token === 37 + || isLiteralPropertyName(); + } + function nextTokenIsClassOrFunction() { + nextToken(); + return token === 73 || token === 87; + } + function isListElement(parsingContext, inErrorRecovery) { + var node = currentNode(parsingContext); + if (node) { + return true; + } + switch (parsingContext) { + case 0: + case 1: + case 3: + return !(token === 23 && inErrorRecovery) && isStartOfStatement(); + case 2: + return token === 71 || token === 77; + case 4: + return isStartOfTypeMember(); + case 5: + return lookAhead(isClassMemberStart) || (token === 23 && !inErrorRecovery); + case 6: + return token === 19 || isLiteralPropertyName(); + case 12: + return token === 19 || token === 37 || isLiteralPropertyName(); + case 9: + return isLiteralPropertyName(); + case 7: + if (token === 15) { + return lookAhead(isValidHeritageClauseObjectLiteral); + } + if (!inErrorRecovery) { + return isStartOfLeftHandSideExpression() && !isHeritageClauseExtendsOrImplementsKeyword(); + } + else { + return isIdentifier() && !isHeritageClauseExtendsOrImplementsKeyword(); + } + case 8: + return isIdentifierOrPattern(); + case 10: + return token === 24 || token === 22 || isIdentifierOrPattern(); + case 17: + return isIdentifier(); + case 11: + case 15: + return token === 24 || token === 22 || isStartOfExpression(); + case 16: + return isStartOfParameter(); + case 18: + case 19: + return token === 24 || isStartOfType(); + case 20: + return isHeritageClause(); + case 21: + return ts.tokenIsIdentifierOrKeyword(token); + case 13: + return ts.tokenIsIdentifierOrKeyword(token) || token === 15; + case 14: + return true; + case 22: + case 23: + case 25: + return JSDocParser.isJSDocType(); + case 24: + return isSimplePropertyName(); + } + ts.Debug.fail("Non-exhaustive case in 'isListElement'."); + } + function isValidHeritageClauseObjectLiteral() { + ts.Debug.assert(token === 15); + if (nextToken() === 16) { + var next = nextToken(); + return next === 24 || next === 15 || next === 83 || next === 106; + } + return true; + } + function nextTokenIsIdentifier() { + nextToken(); + return isIdentifier(); + } + function nextTokenIsIdentifierOrKeyword() { + nextToken(); + return ts.tokenIsIdentifierOrKeyword(token); + } + function isHeritageClauseExtendsOrImplementsKeyword() { + if (token === 106 || + token === 83) { + return lookAhead(nextTokenIsStartOfExpression); + } + return false; + } + function nextTokenIsStartOfExpression() { + nextToken(); + return isStartOfExpression(); + } + function isListTerminator(kind) { + if (token === 1) { + return true; + } + switch (kind) { + case 1: + case 2: + case 4: + case 5: + case 6: + case 12: + case 9: + case 21: + return token === 16; + case 3: + return token === 16 || token === 71 || token === 77; + case 7: + return token === 15 || token === 83 || token === 106; + case 8: + return isVariableDeclaratorListTerminator(); + case 17: + return token === 27 || token === 17 || token === 15 || token === 83 || token === 106; + case 11: + return token === 18 || token === 23; + case 15: + case 19: + case 10: + return token === 20; + case 16: + return token === 18 || token === 20; + case 18: + return token === 27 || token === 17; + case 20: + return token === 15 || token === 16; + case 13: + return token === 27 || token === 39; + case 14: + return token === 25 && lookAhead(nextTokenIsSlash); + case 22: + return token === 18 || token === 54 || token === 16; + case 23: + return token === 27 || token === 16; + case 25: + return token === 20 || token === 16; + case 24: + return token === 16; + } + } + function isVariableDeclaratorListTerminator() { + if (canParseSemicolon()) { + return true; + } + if (isInOrOfKeyword(token)) { + return true; + } + if (token === 34) { + return true; + } + return false; + } + function isInSomeParsingContext() { + for (var kind = 0; kind < 26; kind++) { + if (parsingContext & (1 << kind)) { + if (isListElement(kind, true) || isListTerminator(kind)) { + return true; + } + } + } + return false; + } + function parseList(kind, parseElement) { + var saveParsingContext = parsingContext; + parsingContext |= 1 << kind; + var result = []; + result.pos = getNodePos(); + while (!isListTerminator(kind)) { + if (isListElement(kind, false)) { + var element = parseListElement(kind, parseElement); + result.push(element); + continue; + } + if (abortParsingListOrMoveToNextToken(kind)) { + break; + } + } + result.end = getNodeEnd(); + parsingContext = saveParsingContext; + return result; + } + function parseListElement(parsingContext, parseElement) { + var node = currentNode(parsingContext); + if (node) { + return consumeNode(node); + } + return parseElement(); + } + function currentNode(parsingContext) { + if (parseErrorBeforeNextFinishedNode) { + return undefined; + } + if (!syntaxCursor) { + return undefined; + } + var node = syntaxCursor.currentNode(scanner.getStartPos()); + if (ts.nodeIsMissing(node)) { + return undefined; + } + if (node.intersectsChange) { + return undefined; + } + if (ts.containsParseError(node)) { + return undefined; + } + var nodeContextFlags = node.parserContextFlags & 31; + if (nodeContextFlags !== contextFlags) { + return undefined; + } + if (!canReuseNode(node, parsingContext)) { + return undefined; + } + return node; + } + function consumeNode(node) { + scanner.setTextPos(node.end); + nextToken(); + return node; + } + function canReuseNode(node, parsingContext) { + switch (parsingContext) { + case 5: + return isReusableClassMember(node); + case 2: + return isReusableSwitchClause(node); + case 0: + case 1: + case 3: + return isReusableStatement(node); + case 6: + return isReusableEnumMember(node); + case 4: + return isReusableTypeMember(node); + case 8: + return isReusableVariableDeclaration(node); + case 16: + return isReusableParameter(node); + case 20: + case 17: + case 19: + case 18: + case 11: + case 12: + case 7: + case 13: + case 14: + } + return false; + } + function isReusableClassMember(node) { + if (node) { + switch (node.kind) { + case 144: + case 149: + case 145: + case 146: + case 141: + case 191: + return true; + case 143: + var methodDeclaration = node; + var nameIsConstructor = methodDeclaration.name.kind === 69 && + methodDeclaration.name.originalKeywordKind === 121; + return !nameIsConstructor; + } + } + return false; + } + function isReusableSwitchClause(node) { + if (node) { + switch (node.kind) { + case 241: + case 242: + return true; + } + } + return false; + } + function isReusableStatement(node) { + if (node) { + switch (node.kind) { + case 213: + case 193: + case 192: + case 196: + case 195: + case 208: + case 204: + case 206: + case 203: + case 202: + case 200: + case 201: + case 199: + case 198: + case 205: + case 194: + case 209: + case 207: + case 197: + case 210: + case 222: + case 221: + case 228: + case 227: + case 218: + case 214: + case 215: + case 217: + case 216: + return true; + } + } + return false; + } + function isReusableEnumMember(node) { + return node.kind === 247; + } + function isReusableTypeMember(node) { + if (node) { + switch (node.kind) { + case 148: + case 142: + case 149: + case 140: + case 147: + return true; + } + } + return false; + } + function isReusableVariableDeclaration(node) { + if (node.kind !== 211) { + return false; + } + var variableDeclarator = node; + return variableDeclarator.initializer === undefined; + } + function isReusableParameter(node) { + if (node.kind !== 138) { + return false; + } + var parameter = node; + return parameter.initializer === undefined; + } + function abortParsingListOrMoveToNextToken(kind) { + parseErrorAtCurrentToken(parsingContextErrors(kind)); + if (isInSomeParsingContext()) { + return true; + } + nextToken(); + return false; + } + function parsingContextErrors(context) { + switch (context) { + case 0: return ts.Diagnostics.Declaration_or_statement_expected; + case 1: return ts.Diagnostics.Declaration_or_statement_expected; + case 2: return ts.Diagnostics.case_or_default_expected; + case 3: return ts.Diagnostics.Statement_expected; + case 4: return ts.Diagnostics.Property_or_signature_expected; + case 5: return ts.Diagnostics.Unexpected_token_A_constructor_method_accessor_or_property_was_expected; + case 6: return ts.Diagnostics.Enum_member_expected; + case 7: return ts.Diagnostics.Expression_expected; + case 8: return ts.Diagnostics.Variable_declaration_expected; + case 9: return ts.Diagnostics.Property_destructuring_pattern_expected; + case 10: return ts.Diagnostics.Array_element_destructuring_pattern_expected; + case 11: return ts.Diagnostics.Argument_expression_expected; + case 12: return ts.Diagnostics.Property_assignment_expected; + case 15: return ts.Diagnostics.Expression_or_comma_expected; + case 16: return ts.Diagnostics.Parameter_declaration_expected; + case 17: return ts.Diagnostics.Type_parameter_declaration_expected; + case 18: return ts.Diagnostics.Type_argument_expected; + case 19: return ts.Diagnostics.Type_expected; + case 20: return ts.Diagnostics.Unexpected_token_expected; + case 21: return ts.Diagnostics.Identifier_expected; + case 13: return ts.Diagnostics.Identifier_expected; + case 14: return ts.Diagnostics.Identifier_expected; + case 22: return ts.Diagnostics.Parameter_declaration_expected; + case 23: return ts.Diagnostics.Type_argument_expected; + case 25: return ts.Diagnostics.Type_expected; + case 24: return ts.Diagnostics.Property_assignment_expected; + } + } + ; + function parseDelimitedList(kind, parseElement, considerSemicolonAsDelimeter) { + var saveParsingContext = parsingContext; + parsingContext |= 1 << kind; + var result = []; + result.pos = getNodePos(); + var commaStart = -1; + while (true) { + if (isListElement(kind, false)) { + result.push(parseListElement(kind, parseElement)); + commaStart = scanner.getTokenPos(); + if (parseOptional(24)) { + continue; + } + commaStart = -1; + if (isListTerminator(kind)) { + break; + } + parseExpected(24); + if (considerSemicolonAsDelimeter && token === 23 && !scanner.hasPrecedingLineBreak()) { + nextToken(); + } + continue; + } + if (isListTerminator(kind)) { + break; + } + if (abortParsingListOrMoveToNextToken(kind)) { + break; + } + } + if (commaStart >= 0) { + result.hasTrailingComma = true; + } + result.end = getNodeEnd(); + parsingContext = saveParsingContext; + return result; + } + function createMissingList() { + var pos = getNodePos(); + var result = []; + result.pos = pos; + result.end = pos; + return result; + } + function parseBracketedList(kind, parseElement, open, close) { + if (parseExpected(open)) { + var result = parseDelimitedList(kind, parseElement); + parseExpected(close); + return result; + } + return createMissingList(); + } + function parseEntityName(allowReservedWords, diagnosticMessage) { + var entity = parseIdentifier(diagnosticMessage); + while (parseOptional(21)) { + var node = createNode(135, entity.pos); + node.left = entity; + node.right = parseRightSideOfDot(allowReservedWords); + entity = finishNode(node); + } + return entity; + } + function parseRightSideOfDot(allowIdentifierNames) { + if (scanner.hasPrecedingLineBreak() && ts.tokenIsIdentifierOrKeyword(token)) { + var matchesPattern = lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine); + if (matchesPattern) { + return createMissingNode(69, true, ts.Diagnostics.Identifier_expected); + } + } + return allowIdentifierNames ? parseIdentifierName() : parseIdentifier(); + } + function parseTemplateExpression() { + var template = createNode(183); + template.head = parseLiteralNode(); + ts.Debug.assert(template.head.kind === 12, "Template head has wrong token kind"); + var templateSpans = []; + templateSpans.pos = getNodePos(); + do { + templateSpans.push(parseTemplateSpan()); + } while (ts.lastOrUndefined(templateSpans).literal.kind === 13); + templateSpans.end = getNodeEnd(); + template.templateSpans = templateSpans; + return finishNode(template); + } + function parseTemplateSpan() { + var span = createNode(190); + span.expression = allowInAnd(parseExpression); + var literal; + if (token === 16) { + reScanTemplateToken(); + literal = parseLiteralNode(); + } + else { + literal = parseExpectedToken(14, false, ts.Diagnostics._0_expected, ts.tokenToString(16)); + } + span.literal = literal; + return finishNode(span); + } + function parseLiteralNode(internName) { + var node = createNode(token); + var text = scanner.getTokenValue(); + node.text = internName ? internIdentifier(text) : text; + if (scanner.hasExtendedUnicodeEscape()) { + node.hasExtendedUnicodeEscape = true; + } + if (scanner.isUnterminated()) { + node.isUnterminated = true; + } + var tokenPos = scanner.getTokenPos(); + nextToken(); + finishNode(node); + if (node.kind === 8 + && sourceText.charCodeAt(tokenPos) === 48 + && ts.isOctalDigit(sourceText.charCodeAt(tokenPos + 1))) { + node.flags |= 65536; + } + return node; + } + function parseTypeReferenceOrTypePredicate() { + var typeName = parseEntityName(false, ts.Diagnostics.Type_expected); + if (typeName.kind === 69 && token === 124 && !scanner.hasPrecedingLineBreak()) { + nextToken(); + var node_1 = createNode(150, typeName.pos); + node_1.parameterName = typeName; + node_1.type = parseType(); + return finishNode(node_1); + } + var node = createNode(151, typeName.pos); + node.typeName = typeName; + if (!scanner.hasPrecedingLineBreak() && token === 25) { + node.typeArguments = parseBracketedList(18, parseType, 25, 27); + } + return finishNode(node); + } + function parseTypeQuery() { + var node = createNode(154); + parseExpected(101); + node.exprName = parseEntityName(true); + return finishNode(node); + } + function parseTypeParameter() { + var node = createNode(137); + node.name = parseIdentifier(); + if (parseOptional(83)) { + if (isStartOfType() || !isStartOfExpression()) { + node.constraint = parseType(); + } + else { + node.expression = parseUnaryExpressionOrHigher(); + } + } + return finishNode(node); + } + function parseTypeParameters() { + if (token === 25) { + return parseBracketedList(17, parseTypeParameter, 25, 27); + } + } + function parseParameterType() { + if (parseOptional(54)) { + return token === 9 + ? parseLiteralNode(true) + : parseType(); + } + return undefined; + } + function isStartOfParameter() { + return token === 22 || isIdentifierOrPattern() || ts.isModifier(token) || token === 55; + } + function setModifiers(node, modifiers) { + if (modifiers) { + node.flags |= modifiers.flags; + node.modifiers = modifiers; + } + } + function parseParameter() { + var node = createNode(138); + node.decorators = parseDecorators(); + setModifiers(node, parseModifiers()); + node.dotDotDotToken = parseOptionalToken(22); + node.name = parseIdentifierOrPattern(); + if (ts.getFullWidth(node.name) === 0 && node.flags === 0 && ts.isModifier(token)) { + nextToken(); + } + node.questionToken = parseOptionalToken(53); + node.type = parseParameterType(); + node.initializer = parseBindingElementInitializer(true); + return finishNode(node); + } + function parseBindingElementInitializer(inParameter) { + return inParameter ? parseParameterInitializer() : parseNonParameterInitializer(); + } + function parseParameterInitializer() { + return parseInitializer(true); + } + function fillSignature(returnToken, yieldContext, awaitContext, requireCompleteParameterList, signature) { + var returnTokenRequired = returnToken === 34; + signature.typeParameters = parseTypeParameters(); + signature.parameters = parseParameterList(yieldContext, awaitContext, requireCompleteParameterList); + if (returnTokenRequired) { + parseExpected(returnToken); + signature.type = parseType(); + } + else if (parseOptional(returnToken)) { + signature.type = parseType(); + } + } + function parseParameterList(yieldContext, awaitContext, requireCompleteParameterList) { + if (parseExpected(17)) { + var savedYieldContext = inYieldContext(); + var savedAwaitContext = inAwaitContext(); + setYieldContext(yieldContext); + setAwaitContext(awaitContext); + var result = parseDelimitedList(16, parseParameter); + setYieldContext(savedYieldContext); + setAwaitContext(savedAwaitContext); + if (!parseExpected(18) && requireCompleteParameterList) { + return undefined; + } + return result; + } + return requireCompleteParameterList ? undefined : createMissingList(); + } + function parseTypeMemberSemicolon() { + if (parseOptional(24)) { + return; + } + parseSemicolon(); + } + function parseSignatureMember(kind) { + var node = createNode(kind); + if (kind === 148) { + parseExpected(92); + } + fillSignature(54, false, false, false, node); + parseTypeMemberSemicolon(); + return finishNode(node); + } + function isIndexSignature() { + if (token !== 19) { + return false; + } + return lookAhead(isUnambiguouslyIndexSignature); + } + function isUnambiguouslyIndexSignature() { + nextToken(); + if (token === 22 || token === 20) { + return true; + } + if (ts.isModifier(token)) { + nextToken(); + if (isIdentifier()) { + return true; + } + } + else if (!isIdentifier()) { + return false; + } + else { + nextToken(); + } + if (token === 54 || token === 24) { + return true; + } + if (token !== 53) { + return false; + } + nextToken(); + return token === 54 || token === 24 || token === 20; + } + function parseIndexSignatureDeclaration(fullStart, decorators, modifiers) { + var node = createNode(149, fullStart); + node.decorators = decorators; + setModifiers(node, modifiers); + node.parameters = parseBracketedList(16, parseParameter, 19, 20); + node.type = parseTypeAnnotation(); + parseTypeMemberSemicolon(); + return finishNode(node); + } + function parsePropertyOrMethodSignature() { + var fullStart = scanner.getStartPos(); + var name = parsePropertyName(); + var questionToken = parseOptionalToken(53); + if (token === 17 || token === 25) { + var method = createNode(142, fullStart); + method.name = name; + method.questionToken = questionToken; + fillSignature(54, false, false, false, method); + parseTypeMemberSemicolon(); + return finishNode(method); + } + else { + var property = createNode(140, fullStart); + property.name = name; + property.questionToken = questionToken; + property.type = parseTypeAnnotation(); + parseTypeMemberSemicolon(); + return finishNode(property); + } + } + function isStartOfTypeMember() { + switch (token) { + case 17: + case 25: + case 19: + return true; + default: + if (ts.isModifier(token)) { + var result = lookAhead(isStartOfIndexSignatureDeclaration); + if (result) { + return result; + } + } + return isLiteralPropertyName() && lookAhead(isTypeMemberWithLiteralPropertyName); + } + } + function isStartOfIndexSignatureDeclaration() { + while (ts.isModifier(token)) { + nextToken(); + } + return isIndexSignature(); + } + function isTypeMemberWithLiteralPropertyName() { + nextToken(); + return token === 17 || + token === 25 || + token === 53 || + token === 54 || + canParseSemicolon(); + } + function parseTypeMember() { + switch (token) { + case 17: + case 25: + return parseSignatureMember(147); + case 19: + return isIndexSignature() + ? parseIndexSignatureDeclaration(scanner.getStartPos(), undefined, undefined) + : parsePropertyOrMethodSignature(); + case 92: + if (lookAhead(isStartOfConstructSignature)) { + return parseSignatureMember(148); + } + case 9: + case 8: + return parsePropertyOrMethodSignature(); + default: + if (ts.isModifier(token)) { + var result = tryParse(parseIndexSignatureWithModifiers); + if (result) { + return result; + } + } + if (ts.tokenIsIdentifierOrKeyword(token)) { + return parsePropertyOrMethodSignature(); + } + } + } + function parseIndexSignatureWithModifiers() { + var fullStart = scanner.getStartPos(); + var decorators = parseDecorators(); + var modifiers = parseModifiers(); + return isIndexSignature() + ? parseIndexSignatureDeclaration(fullStart, decorators, modifiers) + : undefined; + } + function isStartOfConstructSignature() { + nextToken(); + return token === 17 || token === 25; + } + function parseTypeLiteral() { + var node = createNode(155); + node.members = parseObjectTypeMembers(); + return finishNode(node); + } + function parseObjectTypeMembers() { + var members; + if (parseExpected(15)) { + members = parseList(4, parseTypeMember); + parseExpected(16); + } + else { + members = createMissingList(); + } + return members; + } + function parseTupleType() { + var node = createNode(157); + node.elementTypes = parseBracketedList(19, parseType, 19, 20); + return finishNode(node); + } + function parseParenthesizedType() { + var node = createNode(160); + parseExpected(17); + node.type = parseType(); + parseExpected(18); + return finishNode(node); + } + function parseFunctionOrConstructorType(kind) { + var node = createNode(kind); + if (kind === 153) { + parseExpected(92); + } + fillSignature(34, false, false, false, node); + return finishNode(node); + } + function parseKeywordAndNoDot() { + var node = parseTokenNode(); + return token === 21 ? undefined : node; + } + function parseNonArrayType() { + switch (token) { + case 117: + case 130: + case 128: + case 120: + case 131: + var node = tryParse(parseKeywordAndNoDot); + return node || parseTypeReferenceOrTypePredicate(); + case 103: + case 97: + return parseTokenNode(); + case 101: + return parseTypeQuery(); + case 15: + return parseTypeLiteral(); + case 19: + return parseTupleType(); + case 17: + return parseParenthesizedType(); + default: + return parseTypeReferenceOrTypePredicate(); + } + } + function isStartOfType() { + switch (token) { + case 117: + case 130: + case 128: + case 120: + case 131: + case 103: + case 97: + case 101: + case 15: + case 19: + case 25: + case 92: + return true; + case 17: + return lookAhead(isStartOfParenthesizedOrFunctionType); + default: + return isIdentifier(); + } + } + function isStartOfParenthesizedOrFunctionType() { + nextToken(); + return token === 18 || isStartOfParameter() || isStartOfType(); + } + function parseArrayTypeOrHigher() { + var type = parseNonArrayType(); + while (!scanner.hasPrecedingLineBreak() && parseOptional(19)) { + parseExpected(20); + var node = createNode(156, type.pos); + node.elementType = type; + type = finishNode(node); + } + return type; + } + function parseUnionOrIntersectionType(kind, parseConstituentType, operator) { + var type = parseConstituentType(); + if (token === operator) { + var types = [type]; + types.pos = type.pos; + while (parseOptional(operator)) { + types.push(parseConstituentType()); + } + types.end = getNodeEnd(); + var node = createNode(kind, type.pos); + node.types = types; + type = finishNode(node); + } + return type; + } + function parseIntersectionTypeOrHigher() { + return parseUnionOrIntersectionType(159, parseArrayTypeOrHigher, 46); + } + function parseUnionTypeOrHigher() { + return parseUnionOrIntersectionType(158, parseIntersectionTypeOrHigher, 47); + } + function isStartOfFunctionType() { + if (token === 25) { + return true; + } + return token === 17 && lookAhead(isUnambiguouslyStartOfFunctionType); + } + function isUnambiguouslyStartOfFunctionType() { + nextToken(); + if (token === 18 || token === 22) { + return true; + } + if (isIdentifier() || ts.isModifier(token)) { + nextToken(); + if (token === 54 || token === 24 || + token === 53 || token === 56 || + isIdentifier() || ts.isModifier(token)) { + return true; + } + if (token === 18) { + nextToken(); + if (token === 34) { + return true; + } + } + } + return false; + } + function parseType() { + return doOutsideOfContext(10, parseTypeWorker); + } + function parseTypeWorker() { + if (isStartOfFunctionType()) { + return parseFunctionOrConstructorType(152); + } + if (token === 92) { + return parseFunctionOrConstructorType(153); + } + return parseUnionTypeOrHigher(); + } + function parseTypeAnnotation() { + return parseOptional(54) ? parseType() : undefined; + } + function isStartOfLeftHandSideExpression() { + switch (token) { + case 97: + case 95: + case 93: + case 99: + case 84: + 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: + return true; + default: + return isIdentifier(); + } + } + function isStartOfExpression() { + if (isStartOfLeftHandSideExpression()) { + return true; + } + switch (token) { + case 35: + case 36: + case 50: + case 49: + case 78: + case 101: + case 103: + case 41: + case 42: + case 25: + case 119: + case 114: + return true; + default: + if (isBinaryOperator()) { + return true; + } + return isIdentifier(); + } + } + function isStartOfExpressionStatement() { + return token !== 15 && + token !== 87 && + token !== 73 && + token !== 55 && + isStartOfExpression(); + } + function allowInAndParseExpression() { + return allowInAnd(parseExpression); + } + function parseExpression() { + var saveDecoratorContext = inDecoratorContext(); + if (saveDecoratorContext) { + setDecoratorContext(false); + } + var expr = parseAssignmentExpressionOrHigher(); + var operatorToken; + while ((operatorToken = parseOptionalToken(24))) { + expr = makeBinaryExpression(expr, operatorToken, parseAssignmentExpressionOrHigher()); + } + if (saveDecoratorContext) { + setDecoratorContext(true); + } + return expr; + } + function parseInitializer(inParameter) { + if (token !== 56) { + if (scanner.hasPrecedingLineBreak() || (inParameter && token === 15) || !isStartOfExpression()) { + return undefined; + } + } + parseExpected(56); + return parseAssignmentExpressionOrHigher(); + } + function parseAssignmentExpressionOrHigher() { + if (isYieldExpression()) { + return parseYieldExpression(); + } + var arrowExpression = tryParseParenthesizedArrowFunctionExpression(); + if (arrowExpression) { + return arrowExpression; + } + var expr = parseBinaryExpressionOrHigher(0); + if (expr.kind === 69 && token === 34) { + return parseSimpleArrowFunctionExpression(expr); + } + if (ts.isLeftHandSideExpression(expr) && ts.isAssignmentOperator(reScanGreaterToken())) { + return makeBinaryExpression(expr, parseTokenNode(), parseAssignmentExpressionOrHigher()); + } + return parseConditionalExpressionRest(expr); + } + function isYieldExpression() { + if (token === 114) { + if (inYieldContext()) { + return true; + } + return lookAhead(nextTokenIsIdentifierOrKeywordOrNumberOnSameLine); + } + return false; + } + function nextTokenIsIdentifierOnSameLine() { + nextToken(); + return !scanner.hasPrecedingLineBreak() && isIdentifier(); + } + function parseYieldExpression() { + var node = createNode(184); + nextToken(); + if (!scanner.hasPrecedingLineBreak() && + (token === 37 || isStartOfExpression())) { + node.asteriskToken = parseOptionalToken(37); + node.expression = parseAssignmentExpressionOrHigher(); + return finishNode(node); + } + else { + return finishNode(node); + } + } + function parseSimpleArrowFunctionExpression(identifier) { + ts.Debug.assert(token === 34, "parseSimpleArrowFunctionExpression should only have been called if we had a =>"); + var node = createNode(174, identifier.pos); + var parameter = createNode(138, identifier.pos); + parameter.name = identifier; + finishNode(parameter); + node.parameters = [parameter]; + node.parameters.pos = parameter.pos; + node.parameters.end = parameter.end; + node.equalsGreaterThanToken = parseExpectedToken(34, false, ts.Diagnostics._0_expected, "=>"); + node.body = parseArrowFunctionExpressionBody(false); + return finishNode(node); + } + function tryParseParenthesizedArrowFunctionExpression() { + var triState = isParenthesizedArrowFunctionExpression(); + if (triState === 0) { + return undefined; + } + var arrowFunction = triState === 1 + ? parseParenthesizedArrowFunctionExpressionHead(true) + : tryParse(parsePossibleParenthesizedArrowFunctionExpressionHead); + if (!arrowFunction) { + return undefined; + } + var isAsync = !!(arrowFunction.flags & 512); + var lastToken = token; + arrowFunction.equalsGreaterThanToken = parseExpectedToken(34, false, ts.Diagnostics._0_expected, "=>"); + arrowFunction.body = (lastToken === 34 || lastToken === 15) + ? parseArrowFunctionExpressionBody(isAsync) + : parseIdentifier(); + return finishNode(arrowFunction); + } + function isParenthesizedArrowFunctionExpression() { + if (token === 17 || token === 25 || token === 118) { + return lookAhead(isParenthesizedArrowFunctionExpressionWorker); + } + if (token === 34) { + return 1; + } + return 0; + } + function isParenthesizedArrowFunctionExpressionWorker() { + if (token === 118) { + nextToken(); + if (scanner.hasPrecedingLineBreak()) { + return 0; + } + if (token !== 17 && token !== 25) { + return 0; + } + } + var first = token; + var second = nextToken(); + if (first === 17) { + if (second === 18) { + var third = nextToken(); + switch (third) { + case 34: + case 54: + case 15: + return 1; + default: + return 0; + } + } + if (second === 19 || second === 15) { + return 2; + } + if (second === 22) { + return 1; + } + if (!isIdentifier()) { + return 0; + } + if (nextToken() === 54) { + return 1; + } + return 2; + } + else { + ts.Debug.assert(first === 25); + if (!isIdentifier()) { + return 0; + } + if (sourceFile.languageVariant === 1) { + var isArrowFunctionInJsx = lookAhead(function () { + var third = nextToken(); + if (third === 83) { + var fourth = nextToken(); + switch (fourth) { + case 56: + case 27: + return false; + default: + return true; + } + } + else if (third === 24) { + return true; + } + return false; + }); + if (isArrowFunctionInJsx) { + return 1; + } + return 0; + } + return 2; + } + } + function parsePossibleParenthesizedArrowFunctionExpressionHead() { + return parseParenthesizedArrowFunctionExpressionHead(false); + } + function parseParenthesizedArrowFunctionExpressionHead(allowAmbiguity) { + var node = createNode(174); + setModifiers(node, parseModifiersForArrowFunction()); + var isAsync = !!(node.flags & 512); + fillSignature(54, false, isAsync, !allowAmbiguity, node); + if (!node.parameters) { + return undefined; + } + if (!allowAmbiguity && token !== 34 && token !== 15) { + return undefined; + } + return node; + } + function parseArrowFunctionExpressionBody(isAsync) { + if (token === 15) { + return parseFunctionBlock(false, isAsync, false); + } + if (token !== 23 && + token !== 87 && + token !== 73 && + isStartOfStatement() && + !isStartOfExpressionStatement()) { + return parseFunctionBlock(false, isAsync, true); + } + return isAsync + ? doInAwaitContext(parseAssignmentExpressionOrHigher) + : doOutsideOfAwaitContext(parseAssignmentExpressionOrHigher); + } + function parseConditionalExpressionRest(leftOperand) { + var questionToken = parseOptionalToken(53); + if (!questionToken) { + return leftOperand; + } + var node = createNode(182, 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.whenFalse = parseAssignmentExpressionOrHigher(); + return finishNode(node); + } + function parseBinaryExpressionOrHigher(precedence) { + var leftOperand = parseUnaryExpressionOrHigher(); + return parseBinaryExpressionRest(precedence, leftOperand); + } + function isInOrOfKeyword(t) { + return t === 90 || t === 134; + } + function parseBinaryExpressionRest(precedence, leftOperand) { + while (true) { + reScanGreaterToken(); + var newPrecedence = getBinaryOperatorPrecedence(); + var consumeCurrentOperator = token === 38 ? + newPrecedence >= precedence : + newPrecedence > precedence; + if (!consumeCurrentOperator) { + break; + } + if (token === 90 && inDisallowInContext()) { + break; + } + if (token === 116) { + if (scanner.hasPrecedingLineBreak()) { + break; + } + else { + nextToken(); + leftOperand = makeAsExpression(leftOperand, parseType()); + } + } + else { + leftOperand = makeBinaryExpression(leftOperand, parseTokenNode(), parseBinaryExpressionOrHigher(newPrecedence)); + } + } + return leftOperand; + } + function isBinaryOperator() { + if (inDisallowInContext() && token === 90) { + return false; + } + return getBinaryOperatorPrecedence() > 0; + } + function getBinaryOperatorPrecedence() { + switch (token) { + case 52: + return 1; + case 51: + return 2; + case 47: + return 3; + case 48: + return 4; + case 46: + return 5; + case 30: + case 31: + case 32: + case 33: + return 6; + case 25: + case 27: + case 28: + case 29: + case 91: + case 90: + case 116: + return 7; + case 43: + case 44: + case 45: + return 8; + case 35: + case 36: + return 9; + case 37: + case 39: + case 40: + return 10; + case 38: + return 11; + } + return -1; + } + function makeBinaryExpression(left, operatorToken, right) { + var node = createNode(181, left.pos); + node.left = left; + node.operatorToken = operatorToken; + node.right = right; + return finishNode(node); + } + function makeAsExpression(left, right) { + var node = createNode(189, left.pos); + node.expression = left; + node.type = right; + return finishNode(node); + } + function parsePrefixUnaryExpression() { + var node = createNode(179); + node.operator = token; + nextToken(); + node.operand = parseSimpleUnaryExpression(); + return finishNode(node); + } + function parseDeleteExpression() { + var node = createNode(175); + nextToken(); + node.expression = parseSimpleUnaryExpression(); + return finishNode(node); + } + function parseTypeOfExpression() { + var node = createNode(176); + nextToken(); + node.expression = parseSimpleUnaryExpression(); + return finishNode(node); + } + function parseVoidExpression() { + var node = createNode(177); + nextToken(); + node.expression = parseSimpleUnaryExpression(); + return finishNode(node); + } + function isAwaitExpression() { + if (token === 119) { + if (inAwaitContext()) { + return true; + } + return lookAhead(nextTokenIsIdentifierOnSameLine); + } + return false; + } + function parseAwaitExpression() { + var node = createNode(178); + nextToken(); + node.expression = parseSimpleUnaryExpression(); + return finishNode(node); + } + function parseUnaryExpressionOrHigher() { + if (isAwaitExpression()) { + return parseAwaitExpression(); + } + if (isIncrementExpression()) { + var incrementExpression = parseIncrementExpression(); + return token === 38 ? + parseBinaryExpressionRest(getBinaryOperatorPrecedence(), incrementExpression) : + incrementExpression; + } + var unaryOperator = token; + var simpleUnaryExpression = parseSimpleUnaryExpression(); + if (token === 38) { + var diagnostic; + var start = ts.skipTrivia(sourceText, simpleUnaryExpression.pos); + if (simpleUnaryExpression.kind === 171) { + parseErrorAtPosition(start, simpleUnaryExpression.end - start, ts.Diagnostics.A_type_assertion_expression_is_not_allowed_in_the_left_hand_side_of_an_exponentiation_expression_Consider_enclosing_the_expression_in_parentheses); + } + else { + parseErrorAtPosition(start, simpleUnaryExpression.end - start, ts.Diagnostics.An_unary_expression_with_the_0_operator_is_not_allowed_in_the_left_hand_side_of_an_exponentiation_expression_Consider_enclosing_the_expression_in_parentheses, ts.tokenToString(unaryOperator)); + } + } + return simpleUnaryExpression; + } + function parseSimpleUnaryExpression() { + switch (token) { + case 35: + case 36: + case 50: + case 49: + return parsePrefixUnaryExpression(); + case 78: + return parseDeleteExpression(); + case 101: + return parseTypeOfExpression(); + case 103: + return parseVoidExpression(); + case 25: + return parseTypeAssertion(); + default: + return parseIncrementExpression(); + } + } + function isIncrementExpression() { + switch (token) { + case 35: + case 36: + case 50: + case 49: + case 78: + case 101: + case 103: + return false; + case 25: + if (sourceFile.languageVariant !== 1) { + return false; + } + default: + return true; + } + } + function parseIncrementExpression() { + if (token === 41 || token === 42) { + var node = createNode(179); + node.operator = token; + nextToken(); + node.operand = parseLeftHandSideExpressionOrHigher(); + return finishNode(node); + } + else if (sourceFile.languageVariant === 1 && token === 25 && lookAhead(nextTokenIsIdentifierOrKeyword)) { + return parseJsxElementOrSelfClosingElement(true); + } + var expression = parseLeftHandSideExpressionOrHigher(); + ts.Debug.assert(ts.isLeftHandSideExpression(expression)); + if ((token === 41 || token === 42) && !scanner.hasPrecedingLineBreak()) { + var node = createNode(180, expression.pos); + node.operand = expression; + node.operator = token; + nextToken(); + return finishNode(node); + } + return expression; + } + function parseLeftHandSideExpressionOrHigher() { + var expression = token === 95 + ? parseSuperExpression() + : parseMemberExpressionOrHigher(); + return parseCallExpressionRest(expression); + } + function parseMemberExpressionOrHigher() { + var expression = parsePrimaryExpression(); + return parseMemberExpressionRest(expression); + } + function parseSuperExpression() { + var expression = parseTokenNode(); + if (token === 17 || token === 21 || token === 19) { + return expression; + } + var node = createNode(166, expression.pos); + node.expression = expression; + node.dotToken = parseExpectedToken(21, false, ts.Diagnostics.super_must_be_followed_by_an_argument_list_or_member_access); + node.name = parseRightSideOfDot(true); + return finishNode(node); + } + function parseJsxElementOrSelfClosingElement(inExpressionContext) { + var opening = parseJsxOpeningOrSelfClosingElement(inExpressionContext); + var result; + if (opening.kind === 235) { + var node = createNode(233, opening.pos); + node.openingElement = opening; + node.children = parseJsxChildren(node.openingElement.tagName); + node.closingElement = parseJsxClosingElement(inExpressionContext); + result = finishNode(node); + } + else { + ts.Debug.assert(opening.kind === 234); + result = opening; + } + if (inExpressionContext && token === 25) { + var invalidElement = tryParse(function () { return parseJsxElementOrSelfClosingElement(true); }); + if (invalidElement) { + parseErrorAtCurrentToken(ts.Diagnostics.JSX_expressions_must_have_one_parent_element); + var badNode = createNode(181, result.pos); + badNode.end = invalidElement.end; + badNode.left = result; + badNode.right = invalidElement; + badNode.operatorToken = createMissingNode(24, false, undefined); + badNode.operatorToken.pos = badNode.operatorToken.end = badNode.right.pos; + return badNode; + } + } + return result; + } + function parseJsxText() { + var node = createNode(236, scanner.getStartPos()); + token = scanner.scanJsxToken(); + return finishNode(node); + } + function parseJsxChild() { + switch (token) { + case 236: + return parseJsxText(); + case 15: + return parseJsxExpression(false); + case 25: + return parseJsxElementOrSelfClosingElement(false); + } + ts.Debug.fail("Unknown JSX child kind " + token); + } + function parseJsxChildren(openingTagName) { + var result = []; + result.pos = scanner.getStartPos(); + var saveParsingContext = parsingContext; + parsingContext |= 1 << 14; + while (true) { + token = scanner.reScanJsxToken(); + if (token === 26) { + break; + } + else if (token === 1) { + parseErrorAtCurrentToken(ts.Diagnostics.Expected_corresponding_JSX_closing_tag_for_0, ts.getTextOfNodeFromSourceText(sourceText, openingTagName)); + break; + } + result.push(parseJsxChild()); + } + result.end = scanner.getTokenPos(); + parsingContext = saveParsingContext; + return result; + } + function parseJsxOpeningOrSelfClosingElement(inExpressionContext) { + var fullStart = scanner.getStartPos(); + parseExpected(25); + var tagName = parseJsxElementName(); + var attributes = parseList(13, parseJsxAttribute); + var node; + if (token === 27) { + node = createNode(235, fullStart); + scanJsxText(); + } + else { + parseExpected(39); + if (inExpressionContext) { + parseExpected(27); + } + else { + parseExpected(27, undefined, false); + scanJsxText(); + } + node = createNode(234, fullStart); + } + node.tagName = tagName; + node.attributes = attributes; + return finishNode(node); + } + function parseJsxElementName() { + scanJsxIdentifier(); + var elementName = parseIdentifierName(); + while (parseOptional(21)) { + scanJsxIdentifier(); + var node = createNode(135, elementName.pos); + node.left = elementName; + node.right = parseIdentifierName(); + elementName = finishNode(node); + } + return elementName; + } + function parseJsxExpression(inExpressionContext) { + var node = createNode(240); + parseExpected(15); + if (token !== 16) { + node.expression = parseExpression(); + } + if (inExpressionContext) { + parseExpected(16); + } + else { + parseExpected(16, undefined, false); + scanJsxText(); + } + return finishNode(node); + } + function parseJsxAttribute() { + if (token === 15) { + return parseJsxSpreadAttribute(); + } + scanJsxIdentifier(); + var node = createNode(238); + node.name = parseIdentifierName(); + if (parseOptional(56)) { + switch (token) { + case 9: + node.initializer = parseLiteralNode(); + break; + default: + node.initializer = parseJsxExpression(true); + break; + } + } + return finishNode(node); + } + function parseJsxSpreadAttribute() { + var node = createNode(239); + parseExpected(15); + parseExpected(22); + node.expression = parseExpression(); + parseExpected(16); + return finishNode(node); + } + function parseJsxClosingElement(inExpressionContext) { + var node = createNode(237); + parseExpected(26); + node.tagName = parseJsxElementName(); + if (inExpressionContext) { + parseExpected(27); + } + else { + parseExpected(27, undefined, false); + scanJsxText(); + } + return finishNode(node); + } + function parseTypeAssertion() { + var node = createNode(171); + parseExpected(25); + node.type = parseType(); + parseExpected(27); + node.expression = parseSimpleUnaryExpression(); + return finishNode(node); + } + function parseMemberExpressionRest(expression) { + while (true) { + var dotToken = parseOptionalToken(21); + if (dotToken) { + var propertyAccess = createNode(166, expression.pos); + propertyAccess.expression = expression; + propertyAccess.dotToken = dotToken; + propertyAccess.name = parseRightSideOfDot(true); + expression = finishNode(propertyAccess); + continue; + } + if (!inDecoratorContext() && parseOptional(19)) { + var indexedAccess = createNode(167, expression.pos); + indexedAccess.expression = expression; + if (token !== 20) { + indexedAccess.argumentExpression = allowInAnd(parseExpression); + if (indexedAccess.argumentExpression.kind === 9 || indexedAccess.argumentExpression.kind === 8) { + var literal = indexedAccess.argumentExpression; + literal.text = internIdentifier(literal.text); + } + } + parseExpected(20); + expression = finishNode(indexedAccess); + continue; + } + if (token === 11 || token === 12) { + var tagExpression = createNode(170, expression.pos); + tagExpression.tag = expression; + tagExpression.template = token === 11 + ? parseLiteralNode() + : parseTemplateExpression(); + expression = finishNode(tagExpression); + continue; + } + return expression; + } + } + function parseCallExpressionRest(expression) { + while (true) { + expression = parseMemberExpressionRest(expression); + if (token === 25) { + var typeArguments = tryParse(parseTypeArgumentsInExpression); + if (!typeArguments) { + return expression; + } + var callExpr = createNode(168, expression.pos); + callExpr.expression = expression; + callExpr.typeArguments = typeArguments; + callExpr.arguments = parseArgumentList(); + expression = finishNode(callExpr); + continue; + } + else if (token === 17) { + var callExpr = createNode(168, expression.pos); + callExpr.expression = expression; + callExpr.arguments = parseArgumentList(); + expression = finishNode(callExpr); + continue; + } + return expression; + } + } + function parseArgumentList() { + parseExpected(17); + var result = parseDelimitedList(11, parseArgumentExpression); + parseExpected(18); + return result; + } + function parseTypeArgumentsInExpression() { + if (!parseOptional(25)) { + return undefined; + } + var typeArguments = parseDelimitedList(18, parseType); + if (!parseExpected(27)) { + return undefined; + } + return typeArguments && canFollowTypeArgumentsInExpression() + ? typeArguments + : undefined; + } + function canFollowTypeArgumentsInExpression() { + switch (token) { + case 17: + case 21: + case 18: + case 20: + case 54: + case 23: + case 53: + case 30: + case 32: + case 31: + case 33: + case 51: + case 52: + case 48: + case 46: + case 47: + case 16: + case 1: + return true; + case 24: + case 15: + default: + return false; + } + } + function parsePrimaryExpression() { + switch (token) { + case 8: + case 9: + case 11: + return parseLiteralNode(); + case 97: + case 95: + case 93: + case 99: + case 84: + return parseTokenNode(); + case 17: + return parseParenthesizedExpression(); + case 19: + return parseArrayLiteralExpression(); + case 15: + return parseObjectLiteralExpression(); + case 118: + if (!lookAhead(nextTokenIsFunctionKeywordOnSameLine)) { + break; + } + return parseFunctionExpression(); + case 73: + return parseClassExpression(); + case 87: + return parseFunctionExpression(); + case 92: + return parseNewExpression(); + case 39: + case 61: + if (reScanSlashToken() === 10) { + return parseLiteralNode(); + } + break; + case 12: + return parseTemplateExpression(); + } + return parseIdentifier(ts.Diagnostics.Expression_expected); + } + function parseParenthesizedExpression() { + var node = createNode(172); + parseExpected(17); + node.expression = allowInAnd(parseExpression); + parseExpected(18); + return finishNode(node); + } + function parseSpreadElement() { + var node = createNode(185); + parseExpected(22); + node.expression = parseAssignmentExpressionOrHigher(); + return finishNode(node); + } + function parseArgumentOrArrayLiteralElement() { + return token === 22 ? parseSpreadElement() : + token === 24 ? createNode(187) : + parseAssignmentExpressionOrHigher(); + } + function parseArgumentExpression() { + return doOutsideOfContext(disallowInAndDecoratorContext, parseArgumentOrArrayLiteralElement); + } + function parseArrayLiteralExpression() { + var node = createNode(164); + parseExpected(19); + if (scanner.hasPrecedingLineBreak()) + node.flags |= 2048; + node.elements = parseDelimitedList(15, parseArgumentOrArrayLiteralElement); + parseExpected(20); + return finishNode(node); + } + function tryParseAccessorDeclaration(fullStart, decorators, modifiers) { + if (parseContextualModifier(123)) { + return parseAccessorDeclaration(145, fullStart, decorators, modifiers); + } + else if (parseContextualModifier(129)) { + return parseAccessorDeclaration(146, fullStart, decorators, modifiers); + } + return undefined; + } + function parseObjectLiteralElement() { + var fullStart = scanner.getStartPos(); + var decorators = parseDecorators(); + var modifiers = parseModifiers(); + var accessor = tryParseAccessorDeclaration(fullStart, decorators, modifiers); + if (accessor) { + return accessor; + } + var asteriskToken = parseOptionalToken(37); + var tokenIsIdentifier = isIdentifier(); + var nameToken = token; + var propertyName = parsePropertyName(); + var questionToken = parseOptionalToken(53); + if (asteriskToken || token === 17 || token === 25) { + return parseMethodDeclaration(fullStart, decorators, modifiers, asteriskToken, propertyName, questionToken); + } + var isShorthandPropertyAssignment = tokenIsIdentifier && (token === 24 || token === 16 || token === 56); + if (isShorthandPropertyAssignment) { + var shorthandDeclaration = createNode(246, fullStart); + shorthandDeclaration.name = propertyName; + shorthandDeclaration.questionToken = questionToken; + var equalsToken = parseOptionalToken(56); + if (equalsToken) { + shorthandDeclaration.equalsToken = equalsToken; + shorthandDeclaration.objectAssignmentInitializer = allowInAnd(parseAssignmentExpressionOrHigher); + } + return finishNode(shorthandDeclaration); + } + else { + var propertyAssignment = createNode(245, fullStart); + propertyAssignment.name = propertyName; + propertyAssignment.questionToken = questionToken; + parseExpected(54); + propertyAssignment.initializer = allowInAnd(parseAssignmentExpressionOrHigher); + return finishNode(propertyAssignment); + } + } + function parseObjectLiteralExpression() { + var node = createNode(165); + parseExpected(15); + if (scanner.hasPrecedingLineBreak()) { + node.flags |= 2048; + } + node.properties = parseDelimitedList(12, parseObjectLiteralElement, true); + parseExpected(16); + return finishNode(node); + } + function parseFunctionExpression() { + var saveDecoratorContext = inDecoratorContext(); + if (saveDecoratorContext) { + setDecoratorContext(false); + } + var node = createNode(173); + setModifiers(node, parseModifiers()); + parseExpected(87); + node.asteriskToken = parseOptionalToken(37); + var isGenerator = !!node.asteriskToken; + var isAsync = !!(node.flags & 512); + node.name = + isGenerator && isAsync ? doInYieldAndAwaitContext(parseOptionalIdentifier) : + isGenerator ? doInYieldContext(parseOptionalIdentifier) : + isAsync ? doInAwaitContext(parseOptionalIdentifier) : + parseOptionalIdentifier(); + fillSignature(54, isGenerator, isAsync, false, node); + node.body = parseFunctionBlock(isGenerator, isAsync, false); + if (saveDecoratorContext) { + setDecoratorContext(true); + } + return finishNode(node); + } + function parseOptionalIdentifier() { + return isIdentifier() ? parseIdentifier() : undefined; + } + function parseNewExpression() { + var node = createNode(169); + parseExpected(92); + node.expression = parseMemberExpressionOrHigher(); + node.typeArguments = tryParse(parseTypeArgumentsInExpression); + if (node.typeArguments || token === 17) { + node.arguments = parseArgumentList(); + } + return finishNode(node); + } + function parseBlock(ignoreMissingOpenBrace, diagnosticMessage) { + var node = createNode(192); + if (parseExpected(15, diagnosticMessage) || ignoreMissingOpenBrace) { + node.statements = parseList(1, parseStatement); + parseExpected(16); + } + else { + node.statements = createMissingList(); + } + return finishNode(node); + } + function parseFunctionBlock(allowYield, allowAwait, ignoreMissingOpenBrace, diagnosticMessage) { + var savedYieldContext = inYieldContext(); + setYieldContext(allowYield); + var savedAwaitContext = inAwaitContext(); + setAwaitContext(allowAwait); + var saveDecoratorContext = inDecoratorContext(); + if (saveDecoratorContext) { + setDecoratorContext(false); + } + var block = parseBlock(ignoreMissingOpenBrace, diagnosticMessage); + if (saveDecoratorContext) { + setDecoratorContext(true); + } + setYieldContext(savedYieldContext); + setAwaitContext(savedAwaitContext); + return block; + } + function parseEmptyStatement() { + var node = createNode(194); + parseExpected(23); + return finishNode(node); + } + function parseIfStatement() { + var node = createNode(196); + parseExpected(88); + parseExpected(17); + node.expression = allowInAnd(parseExpression); + parseExpected(18); + node.thenStatement = parseStatement(); + node.elseStatement = parseOptional(80) ? parseStatement() : undefined; + return finishNode(node); + } + function parseDoStatement() { + var node = createNode(197); + parseExpected(79); + node.statement = parseStatement(); + parseExpected(104); + parseExpected(17); + node.expression = allowInAnd(parseExpression); + parseExpected(18); + parseOptional(23); + return finishNode(node); + } + function parseWhileStatement() { + var node = createNode(198); + parseExpected(104); + parseExpected(17); + node.expression = allowInAnd(parseExpression); + parseExpected(18); + node.statement = parseStatement(); + return finishNode(node); + } + function parseForOrForInOrForOfStatement() { + var pos = getNodePos(); + parseExpected(86); + parseExpected(17); + var initializer = undefined; + if (token !== 23) { + if (token === 102 || token === 108 || token === 74) { + initializer = parseVariableDeclarationList(true); + } + else { + initializer = disallowInAnd(parseExpression); + } + } + var forOrForInOrForOfStatement; + if (parseOptional(90)) { + var forInStatement = createNode(200, pos); + forInStatement.initializer = initializer; + forInStatement.expression = allowInAnd(parseExpression); + parseExpected(18); + forOrForInOrForOfStatement = forInStatement; + } + else if (parseOptional(134)) { + var forOfStatement = createNode(201, pos); + forOfStatement.initializer = initializer; + forOfStatement.expression = allowInAnd(parseAssignmentExpressionOrHigher); + parseExpected(18); + forOrForInOrForOfStatement = forOfStatement; + } + else { + var forStatement = createNode(199, pos); + forStatement.initializer = initializer; + parseExpected(23); + if (token !== 23 && token !== 18) { + forStatement.condition = allowInAnd(parseExpression); + } + parseExpected(23); + if (token !== 18) { + forStatement.incrementor = allowInAnd(parseExpression); + } + parseExpected(18); + forOrForInOrForOfStatement = forStatement; + } + forOrForInOrForOfStatement.statement = parseStatement(); + return finishNode(forOrForInOrForOfStatement); + } + function parseBreakOrContinueStatement(kind) { + var node = createNode(kind); + parseExpected(kind === 203 ? 70 : 75); + if (!canParseSemicolon()) { + node.label = parseIdentifier(); + } + parseSemicolon(); + return finishNode(node); + } + function parseReturnStatement() { + var node = createNode(204); + parseExpected(94); + if (!canParseSemicolon()) { + node.expression = allowInAnd(parseExpression); + } + parseSemicolon(); + return finishNode(node); + } + function parseWithStatement() { + var node = createNode(205); + parseExpected(105); + parseExpected(17); + node.expression = allowInAnd(parseExpression); + parseExpected(18); + node.statement = parseStatement(); + return finishNode(node); + } + function parseCaseClause() { + var node = createNode(241); + parseExpected(71); + node.expression = allowInAnd(parseExpression); + parseExpected(54); + node.statements = parseList(3, parseStatement); + return finishNode(node); + } + function parseDefaultClause() { + var node = createNode(242); + parseExpected(77); + parseExpected(54); + node.statements = parseList(3, parseStatement); + return finishNode(node); + } + function parseCaseOrDefaultClause() { + return token === 71 ? parseCaseClause() : parseDefaultClause(); + } + function parseSwitchStatement() { + var node = createNode(206); + parseExpected(96); + parseExpected(17); + node.expression = allowInAnd(parseExpression); + parseExpected(18); + var caseBlock = createNode(220, scanner.getStartPos()); + parseExpected(15); + caseBlock.clauses = parseList(2, parseCaseOrDefaultClause); + parseExpected(16); + node.caseBlock = finishNode(caseBlock); + return finishNode(node); + } + function parseThrowStatement() { + var node = createNode(208); + parseExpected(98); + node.expression = scanner.hasPrecedingLineBreak() ? undefined : allowInAnd(parseExpression); + parseSemicolon(); + return finishNode(node); + } + function parseTryStatement() { + var node = createNode(209); + parseExpected(100); + node.tryBlock = parseBlock(false); + node.catchClause = token === 72 ? parseCatchClause() : undefined; + if (!node.catchClause || token === 85) { + parseExpected(85); + node.finallyBlock = parseBlock(false); + } + return finishNode(node); + } + function parseCatchClause() { + var result = createNode(244); + parseExpected(72); + if (parseExpected(17)) { + result.variableDeclaration = parseVariableDeclaration(); + } + parseExpected(18); + result.block = parseBlock(false); + return finishNode(result); + } + function parseDebuggerStatement() { + var node = createNode(210); + parseExpected(76); + parseSemicolon(); + return finishNode(node); + } + function parseExpressionOrLabeledStatement() { + var fullStart = scanner.getStartPos(); + var expression = allowInAnd(parseExpression); + if (expression.kind === 69 && parseOptional(54)) { + var labeledStatement = createNode(207, fullStart); + labeledStatement.label = expression; + labeledStatement.statement = parseStatement(); + return finishNode(labeledStatement); + } + else { + var expressionStatement = createNode(195, fullStart); + expressionStatement.expression = expression; + parseSemicolon(); + return finishNode(expressionStatement); + } + } + function nextTokenIsIdentifierOrKeywordOnSameLine() { + nextToken(); + return ts.tokenIsIdentifierOrKeyword(token) && !scanner.hasPrecedingLineBreak(); + } + function nextTokenIsFunctionKeywordOnSameLine() { + nextToken(); + return token === 87 && !scanner.hasPrecedingLineBreak(); + } + function nextTokenIsIdentifierOrKeywordOrNumberOnSameLine() { + nextToken(); + return (ts.tokenIsIdentifierOrKeyword(token) || token === 8) && !scanner.hasPrecedingLineBreak(); + } + function isDeclaration() { + while (true) { + switch (token) { + case 102: + case 108: + case 74: + case 87: + case 73: + case 81: + return true; + case 107: + case 132: + return nextTokenIsIdentifierOnSameLine(); + case 125: + case 126: + return nextTokenIsIdentifierOrStringLiteralOnSameLine(); + case 115: + case 118: + case 122: + case 110: + case 111: + case 112: + nextToken(); + if (scanner.hasPrecedingLineBreak()) { + return false; + } + continue; + case 89: + nextToken(); + return token === 9 || token === 37 || + token === 15 || ts.tokenIsIdentifierOrKeyword(token); + case 82: + nextToken(); + if (token === 56 || token === 37 || + token === 15 || token === 77) { + return true; + } + continue; + case 113: + nextToken(); + continue; + default: + return false; + } + } + } + function isStartOfDeclaration() { + return lookAhead(isDeclaration); + } + function isStartOfStatement() { + switch (token) { + case 55: + case 23: + case 15: + case 102: + case 108: + case 87: + case 73: + case 81: + 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: + return isStartOfDeclaration(); + case 118: + case 122: + case 107: + case 125: + case 126: + case 132: + return true; + case 112: + case 110: + case 111: + case 113: + return isStartOfDeclaration() || !lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine); + default: + return isStartOfExpression(); + } + } + function nextTokenIsIdentifierOrStartOfDestructuring() { + nextToken(); + return isIdentifier() || token === 15 || token === 19; + } + function isLetDeclaration() { + return lookAhead(nextTokenIsIdentifierOrStartOfDestructuring); + } + function parseStatement() { + switch (token) { + case 23: + return parseEmptyStatement(); + case 15: + return parseBlock(false); + case 102: + return parseVariableStatement(scanner.getStartPos(), undefined, undefined); + case 108: + 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(202); + case 70: + return parseBreakOrContinueStatement(203); + 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 132: + case 125: + case 126: + case 122: + case 74: + case 81: + case 82: + case 89: + case 110: + case 111: + case 112: + case 115: + case 113: + if (isStartOfDeclaration()) { + return parseDeclaration(); + } + break; + } + return parseExpressionOrLabeledStatement(); + } + function parseDeclaration() { + var fullStart = getNodePos(); + var decorators = parseDecorators(); + var modifiers = parseModifiers(); + switch (token) { + case 102: + case 108: + case 74: + return parseVariableStatement(fullStart, decorators, modifiers); + case 87: + return parseFunctionDeclaration(fullStart, decorators, modifiers); + case 73: + return parseClassDeclaration(fullStart, decorators, modifiers); + case 107: + return parseInterfaceDeclaration(fullStart, decorators, modifiers); + case 132: + return parseTypeAliasDeclaration(fullStart, decorators, modifiers); + case 81: + return parseEnumDeclaration(fullStart, decorators, modifiers); + case 125: + case 126: + return parseModuleDeclaration(fullStart, decorators, modifiers); + case 89: + return parseImportDeclarationOrImportEqualsDeclaration(fullStart, decorators, modifiers); + case 82: + nextToken(); + return token === 77 || token === 56 ? + parseExportAssignment(fullStart, decorators, modifiers) : + parseExportDeclaration(fullStart, decorators, modifiers); + default: + if (decorators || modifiers) { + var node = createMissingNode(231, true, ts.Diagnostics.Declaration_expected); + node.pos = fullStart; + node.decorators = decorators; + setModifiers(node, modifiers); + return finishNode(node); + } + } + } + function nextTokenIsIdentifierOrStringLiteralOnSameLine() { + nextToken(); + return !scanner.hasPrecedingLineBreak() && (isIdentifier() || token === 9); + } + function parseFunctionBlockOrSemicolon(isGenerator, isAsync, diagnosticMessage) { + if (token !== 15 && canParseSemicolon()) { + parseSemicolon(); + return; + } + return parseFunctionBlock(isGenerator, isAsync, false, diagnosticMessage); + } + function parseArrayBindingElement() { + if (token === 24) { + return createNode(187); + } + var node = createNode(163); + node.dotDotDotToken = parseOptionalToken(22); + node.name = parseIdentifierOrPattern(); + node.initializer = parseBindingElementInitializer(false); + return finishNode(node); + } + function parseObjectBindingElement() { + var node = createNode(163); + var tokenIsIdentifier = isIdentifier(); + var propertyName = parsePropertyName(); + if (tokenIsIdentifier && token !== 54) { + node.name = propertyName; + } + else { + parseExpected(54); + node.propertyName = propertyName; + node.name = parseIdentifierOrPattern(); + } + node.initializer = parseBindingElementInitializer(false); + return finishNode(node); + } + function parseObjectBindingPattern() { + var node = createNode(161); + parseExpected(15); + node.elements = parseDelimitedList(9, parseObjectBindingElement); + parseExpected(16); + return finishNode(node); + } + function parseArrayBindingPattern() { + var node = createNode(162); + parseExpected(19); + node.elements = parseDelimitedList(10, parseArrayBindingElement); + parseExpected(20); + return finishNode(node); + } + function isIdentifierOrPattern() { + return token === 15 || token === 19 || isIdentifier(); + } + function parseIdentifierOrPattern() { + if (token === 19) { + return parseArrayBindingPattern(); + } + if (token === 15) { + return parseObjectBindingPattern(); + } + return parseIdentifier(); + } + function parseVariableDeclaration() { + var node = createNode(211); + node.name = parseIdentifierOrPattern(); + node.type = parseTypeAnnotation(); + if (!isInOrOfKeyword(token)) { + node.initializer = parseInitializer(false); + } + return finishNode(node); + } + function parseVariableDeclarationList(inForStatementInitializer) { + var node = createNode(212); + switch (token) { + case 102: + break; + case 108: + node.flags |= 16384; + break; + case 74: + node.flags |= 32768; + break; + default: + ts.Debug.fail(); + } + nextToken(); + if (token === 134 && lookAhead(canFollowContextualOfKeyword)) { + node.declarations = createMissingList(); + } + else { + var savedDisallowIn = inDisallowInContext(); + setDisallowInContext(inForStatementInitializer); + node.declarations = parseDelimitedList(8, parseVariableDeclaration); + setDisallowInContext(savedDisallowIn); + } + return finishNode(node); + } + function canFollowContextualOfKeyword() { + return nextTokenIsIdentifier() && nextToken() === 18; + } + function parseVariableStatement(fullStart, decorators, modifiers) { + var node = createNode(193, fullStart); + node.decorators = decorators; + setModifiers(node, modifiers); + node.declarationList = parseVariableDeclarationList(false); + parseSemicolon(); + return finishNode(node); + } + function parseFunctionDeclaration(fullStart, decorators, modifiers) { + var node = createNode(213, fullStart); + node.decorators = decorators; + setModifiers(node, modifiers); + parseExpected(87); + node.asteriskToken = parseOptionalToken(37); + node.name = node.flags & 1024 ? parseOptionalIdentifier() : parseIdentifier(); + var isGenerator = !!node.asteriskToken; + var isAsync = !!(node.flags & 512); + fillSignature(54, isGenerator, isAsync, false, node); + node.body = parseFunctionBlockOrSemicolon(isGenerator, isAsync, ts.Diagnostics.or_expected); + return finishNode(node); + } + function parseConstructorDeclaration(pos, decorators, modifiers) { + var node = createNode(144, pos); + node.decorators = decorators; + setModifiers(node, modifiers); + parseExpected(121); + fillSignature(54, false, false, false, node); + node.body = parseFunctionBlockOrSemicolon(false, false, ts.Diagnostics.or_expected); + return finishNode(node); + } + function parseMethodDeclaration(fullStart, decorators, modifiers, asteriskToken, name, questionToken, diagnosticMessage) { + var method = createNode(143, fullStart); + method.decorators = decorators; + setModifiers(method, modifiers); + method.asteriskToken = asteriskToken; + method.name = name; + method.questionToken = questionToken; + var isGenerator = !!asteriskToken; + var isAsync = !!(method.flags & 512); + fillSignature(54, isGenerator, isAsync, false, method); + method.body = parseFunctionBlockOrSemicolon(isGenerator, isAsync, diagnosticMessage); + return finishNode(method); + } + function parsePropertyDeclaration(fullStart, decorators, modifiers, name, questionToken) { + var property = createNode(141, fullStart); + property.decorators = decorators; + setModifiers(property, modifiers); + property.name = name; + property.questionToken = questionToken; + property.type = parseTypeAnnotation(); + property.initializer = modifiers && modifiers.flags & 128 + ? allowInAnd(parseNonParameterInitializer) + : doOutsideOfContext(2 | 1, parseNonParameterInitializer); + parseSemicolon(); + return finishNode(property); + } + function parsePropertyOrMethodDeclaration(fullStart, decorators, modifiers) { + var asteriskToken = parseOptionalToken(37); + var name = parsePropertyName(); + var questionToken = parseOptionalToken(53); + if (asteriskToken || token === 17 || token === 25) { + return parseMethodDeclaration(fullStart, decorators, modifiers, asteriskToken, name, questionToken, ts.Diagnostics.or_expected); + } + else { + return parsePropertyDeclaration(fullStart, decorators, modifiers, name, questionToken); + } + } + function parseNonParameterInitializer() { + return parseInitializer(false); + } + function parseAccessorDeclaration(kind, fullStart, decorators, modifiers) { + var node = createNode(kind, fullStart); + node.decorators = decorators; + setModifiers(node, modifiers); + node.name = parsePropertyName(); + fillSignature(54, false, false, false, node); + node.body = parseFunctionBlockOrSemicolon(false, false); + return finishNode(node); + } + function isClassMemberModifier(idToken) { + switch (idToken) { + case 112: + case 110: + case 111: + case 113: + return true; + default: + return false; + } + } + function isClassMemberStart() { + var idToken; + if (token === 55) { + return true; + } + while (ts.isModifier(token)) { + idToken = token; + if (isClassMemberModifier(idToken)) { + return true; + } + nextToken(); + } + if (token === 37) { + return true; + } + if (isLiteralPropertyName()) { + idToken = token; + nextToken(); + } + if (token === 19) { + return true; + } + if (idToken !== undefined) { + if (!ts.isKeyword(idToken) || idToken === 129 || idToken === 123) { + return true; + } + switch (token) { + case 17: + case 25: + case 54: + case 56: + case 53: + return true; + default: + return canParseSemicolon(); + } + } + return false; + } + function parseDecorators() { + var decorators; + while (true) { + var decoratorStart = getNodePos(); + if (!parseOptional(55)) { + break; + } + if (!decorators) { + decorators = []; + decorators.pos = scanner.getStartPos(); + } + var decorator = createNode(139, decoratorStart); + decorator.expression = doInDecoratorContext(parseLeftHandSideExpressionOrHigher); + decorators.push(finishNode(decorator)); + } + if (decorators) { + decorators.end = getNodeEnd(); + } + return decorators; + } + function parseModifiers() { + var flags = 0; + var modifiers; + while (true) { + var modifierStart = scanner.getStartPos(); + var modifierKind = token; + if (!parseAnyContextualModifier()) { + break; + } + if (!modifiers) { + modifiers = []; + modifiers.pos = modifierStart; + } + flags |= ts.modifierToFlag(modifierKind); + modifiers.push(finishNode(createNode(modifierKind, modifierStart))); + } + if (modifiers) { + modifiers.flags = flags; + modifiers.end = scanner.getStartPos(); + } + return modifiers; + } + function parseModifiersForArrowFunction() { + var flags = 0; + var modifiers; + if (token === 118) { + var modifierStart = scanner.getStartPos(); + var modifierKind = token; + nextToken(); + modifiers = []; + modifiers.pos = modifierStart; + flags |= ts.modifierToFlag(modifierKind); + modifiers.push(finishNode(createNode(modifierKind, modifierStart))); + modifiers.flags = flags; + modifiers.end = scanner.getStartPos(); + } + return modifiers; + } + function parseClassElement() { + if (token === 23) { + var result = createNode(191); + nextToken(); + return finishNode(result); + } + var fullStart = getNodePos(); + var decorators = parseDecorators(); + var modifiers = parseModifiers(); + var accessor = tryParseAccessorDeclaration(fullStart, decorators, modifiers); + if (accessor) { + return accessor; + } + if (token === 121) { + return parseConstructorDeclaration(fullStart, decorators, modifiers); + } + if (isIndexSignature()) { + return parseIndexSignatureDeclaration(fullStart, decorators, modifiers); + } + if (ts.tokenIsIdentifierOrKeyword(token) || + token === 9 || + token === 8 || + token === 37 || + token === 19) { + return parsePropertyOrMethodDeclaration(fullStart, decorators, modifiers); + } + if (decorators || modifiers) { + var name_8 = createMissingNode(69, true, ts.Diagnostics.Declaration_expected); + return parsePropertyDeclaration(fullStart, decorators, modifiers, name_8, undefined); + } + ts.Debug.fail("Should not have attempted to parse class member declaration."); + } + function parseClassExpression() { + return parseClassDeclarationOrExpression(scanner.getStartPos(), undefined, undefined, 186); + } + function parseClassDeclaration(fullStart, decorators, modifiers) { + return parseClassDeclarationOrExpression(fullStart, decorators, modifiers, 214); + } + function parseClassDeclarationOrExpression(fullStart, decorators, modifiers, kind) { + var node = createNode(kind, fullStart); + node.decorators = decorators; + setModifiers(node, modifiers); + parseExpected(73); + node.name = parseNameOfClassDeclarationOrExpression(); + node.typeParameters = parseTypeParameters(); + node.heritageClauses = parseHeritageClauses(true); + if (parseExpected(15)) { + node.members = parseClassMembers(); + parseExpected(16); + } + else { + node.members = createMissingList(); + } + return finishNode(node); + } + function parseNameOfClassDeclarationOrExpression() { + return isIdentifier() && !isImplementsClause() + ? parseIdentifier() + : undefined; + } + function isImplementsClause() { + return token === 106 && lookAhead(nextTokenIsIdentifierOrKeyword); + } + function parseHeritageClauses(isClassHeritageClause) { + if (isHeritageClause()) { + return parseList(20, parseHeritageClause); + } + return undefined; + } + function parseHeritageClausesWorker() { + return parseList(20, parseHeritageClause); + } + function parseHeritageClause() { + if (token === 83 || token === 106) { + var node = createNode(243); + node.token = token; + nextToken(); + node.types = parseDelimitedList(7, parseExpressionWithTypeArguments); + return finishNode(node); + } + return undefined; + } + function parseExpressionWithTypeArguments() { + var node = createNode(188); + node.expression = parseLeftHandSideExpressionOrHigher(); + if (token === 25) { + node.typeArguments = parseBracketedList(18, parseType, 25, 27); + } + return finishNode(node); + } + function isHeritageClause() { + return token === 83 || token === 106; + } + function parseClassMembers() { + return parseList(5, parseClassElement); + } + function parseInterfaceDeclaration(fullStart, decorators, modifiers) { + var node = createNode(215, fullStart); + node.decorators = decorators; + setModifiers(node, modifiers); + parseExpected(107); + node.name = parseIdentifier(); + node.typeParameters = parseTypeParameters(); + node.heritageClauses = parseHeritageClauses(false); + node.members = parseObjectTypeMembers(); + return finishNode(node); + } + function parseTypeAliasDeclaration(fullStart, decorators, modifiers) { + var node = createNode(216, fullStart); + node.decorators = decorators; + setModifiers(node, modifiers); + parseExpected(132); + node.name = parseIdentifier(); + node.typeParameters = parseTypeParameters(); + parseExpected(56); + node.type = parseType(); + parseSemicolon(); + return finishNode(node); + } + function parseEnumMember() { + var node = createNode(247, scanner.getStartPos()); + node.name = parsePropertyName(); + node.initializer = allowInAnd(parseNonParameterInitializer); + return finishNode(node); + } + function parseEnumDeclaration(fullStart, decorators, modifiers) { + var node = createNode(217, fullStart); + node.decorators = decorators; + setModifiers(node, modifiers); + parseExpected(81); + node.name = parseIdentifier(); + if (parseExpected(15)) { + node.members = parseDelimitedList(6, parseEnumMember); + parseExpected(16); + } + else { + node.members = createMissingList(); + } + return finishNode(node); + } + function parseModuleBlock() { + var node = createNode(219, scanner.getStartPos()); + if (parseExpected(15)) { + node.statements = parseList(1, parseStatement); + parseExpected(16); + } + else { + node.statements = createMissingList(); + } + return finishNode(node); + } + function parseModuleOrNamespaceDeclaration(fullStart, decorators, modifiers, flags) { + var node = createNode(218, fullStart); + var namespaceFlag = flags & 131072; + node.decorators = decorators; + setModifiers(node, modifiers); + node.flags |= flags; + node.name = parseIdentifier(); + node.body = parseOptional(21) + ? parseModuleOrNamespaceDeclaration(getNodePos(), undefined, undefined, 1 | namespaceFlag) + : parseModuleBlock(); + return finishNode(node); + } + function parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers) { + var node = createNode(218, fullStart); + node.decorators = decorators; + setModifiers(node, modifiers); + node.name = parseLiteralNode(true); + node.body = parseModuleBlock(); + return finishNode(node); + } + function parseModuleDeclaration(fullStart, decorators, modifiers) { + var flags = modifiers ? modifiers.flags : 0; + if (parseOptional(126)) { + flags |= 131072; + } + else { + parseExpected(125); + if (token === 9) { + return parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers); + } + } + return parseModuleOrNamespaceDeclaration(fullStart, decorators, modifiers, flags); + } + function isExternalModuleReference() { + return token === 127 && + lookAhead(nextTokenIsOpenParen); + } + function nextTokenIsOpenParen() { + return nextToken() === 17; + } + function nextTokenIsSlash() { + return nextToken() === 39; + } + function nextTokenIsCommaOrFromKeyword() { + nextToken(); + return token === 24 || + token === 133; + } + function parseImportDeclarationOrImportEqualsDeclaration(fullStart, decorators, modifiers) { + parseExpected(89); + var afterImportPos = scanner.getStartPos(); + var identifier; + if (isIdentifier()) { + identifier = parseIdentifier(); + if (token !== 24 && token !== 133) { + var importEqualsDeclaration = createNode(221, fullStart); + importEqualsDeclaration.decorators = decorators; + setModifiers(importEqualsDeclaration, modifiers); + importEqualsDeclaration.name = identifier; + parseExpected(56); + importEqualsDeclaration.moduleReference = parseModuleReference(); + parseSemicolon(); + return finishNode(importEqualsDeclaration); + } + } + var importDeclaration = createNode(222, fullStart); + importDeclaration.decorators = decorators; + setModifiers(importDeclaration, modifiers); + if (identifier || + token === 37 || + token === 15) { + importDeclaration.importClause = parseImportClause(identifier, afterImportPos); + parseExpected(133); + } + importDeclaration.moduleSpecifier = parseModuleSpecifier(); + parseSemicolon(); + return finishNode(importDeclaration); + } + function parseImportClause(identifier, fullStart) { + var importClause = createNode(223, fullStart); + if (identifier) { + importClause.name = identifier; + } + if (!importClause.name || + parseOptional(24)) { + importClause.namedBindings = token === 37 ? parseNamespaceImport() : parseNamedImportsOrExports(225); + } + return finishNode(importClause); + } + function parseModuleReference() { + return isExternalModuleReference() + ? parseExternalModuleReference() + : parseEntityName(false); + } + function parseExternalModuleReference() { + var node = createNode(232); + parseExpected(127); + parseExpected(17); + node.expression = parseModuleSpecifier(); + parseExpected(18); + return finishNode(node); + } + function parseModuleSpecifier() { + var result = parseExpression(); + if (result.kind === 9) { + internIdentifier(result.text); + } + return result; + } + function parseNamespaceImport() { + var namespaceImport = createNode(224); + parseExpected(37); + parseExpected(116); + namespaceImport.name = parseIdentifier(); + return finishNode(namespaceImport); + } + function parseNamedImportsOrExports(kind) { + var node = createNode(kind); + node.elements = parseBracketedList(21, kind === 225 ? parseImportSpecifier : parseExportSpecifier, 15, 16); + return finishNode(node); + } + function parseExportSpecifier() { + return parseImportOrExportSpecifier(230); + } + function parseImportSpecifier() { + return parseImportOrExportSpecifier(226); + } + function parseImportOrExportSpecifier(kind) { + var node = createNode(kind); + var checkIdentifierIsKeyword = ts.isKeyword(token) && !isIdentifier(); + var checkIdentifierStart = scanner.getTokenPos(); + var checkIdentifierEnd = scanner.getTextPos(); + var identifierName = parseIdentifierName(); + if (token === 116) { + node.propertyName = identifierName; + parseExpected(116); + checkIdentifierIsKeyword = ts.isKeyword(token) && !isIdentifier(); + checkIdentifierStart = scanner.getTokenPos(); + checkIdentifierEnd = scanner.getTextPos(); + node.name = parseIdentifierName(); + } + else { + node.name = identifierName; + } + if (kind === 226 && checkIdentifierIsKeyword) { + parseErrorAtPosition(checkIdentifierStart, checkIdentifierEnd - checkIdentifierStart, ts.Diagnostics.Identifier_expected); + } + return finishNode(node); + } + function parseExportDeclaration(fullStart, decorators, modifiers) { + var node = createNode(228, fullStart); + node.decorators = decorators; + setModifiers(node, modifiers); + if (parseOptional(37)) { + parseExpected(133); + node.moduleSpecifier = parseModuleSpecifier(); + } + else { + node.exportClause = parseNamedImportsOrExports(229); + if (token === 133 || (token === 9 && !scanner.hasPrecedingLineBreak())) { + parseExpected(133); + node.moduleSpecifier = parseModuleSpecifier(); + } + } + parseSemicolon(); + return finishNode(node); + } + function parseExportAssignment(fullStart, decorators, modifiers) { + var node = createNode(227, fullStart); + node.decorators = decorators; + setModifiers(node, modifiers); + if (parseOptional(56)) { + node.isExportEquals = true; + } + else { + parseExpected(77); + } + node.expression = parseAssignmentExpressionOrHigher(); + parseSemicolon(); + return finishNode(node); + } + function processReferenceComments(sourceFile) { + var triviaScanner = ts.createScanner(sourceFile.languageVersion, false, 0, sourceText); + var referencedFiles = []; + var amdDependencies = []; + var amdModuleName; + while (true) { + var kind = triviaScanner.scan(); + if (kind === 5 || kind === 4 || kind === 3) { + continue; + } + if (kind !== 2) { + break; + } + var range = { pos: triviaScanner.getTokenPos(), end: triviaScanner.getTextPos(), kind: triviaScanner.getToken() }; + var comment = sourceText.substring(range.pos, range.end); + var referencePathMatchResult = ts.getFileReferenceFromReferencePath(comment, range); + if (referencePathMatchResult) { + var fileReference = referencePathMatchResult.fileReference; + sourceFile.hasNoDefaultLib = referencePathMatchResult.isNoDefaultLib; + var diagnosticMessage = referencePathMatchResult.diagnosticMessage; + if (fileReference) { + referencedFiles.push(fileReference); + } + if (diagnosticMessage) { + parseDiagnostics.push(ts.createFileDiagnostic(sourceFile, range.pos, range.end - range.pos, diagnosticMessage)); + } + } + else { + var amdModuleNameRegEx = /^\/\/\/\s*".length; + return parseErrorAtPosition(start, end - start, ts.Diagnostics.Type_argument_list_cannot_be_empty); + } + } + function parseQualifiedName(left) { + var result = createNode(135, left.pos); + result.left = left; + result.right = parseIdentifierName(); + return finishNode(result); + } + function parseJSDocRecordType() { + var result = createNode(257); + nextToken(); + result.members = parseDelimitedList(24, parseJSDocRecordMember); + checkForTrailingComma(result.members); + parseExpected(16); + return finishNode(result); + } + function parseJSDocRecordMember() { + var result = createNode(258); + result.name = parseSimplePropertyName(); + if (token === 54) { + nextToken(); + result.type = parseJSDocType(); + } + return finishNode(result); + } + function parseJSDocNonNullableType() { + var result = createNode(256); + nextToken(); + result.type = parseJSDocType(); + return finishNode(result); + } + function parseJSDocTupleType() { + var result = createNode(254); + nextToken(); + result.types = parseDelimitedList(25, parseJSDocType); + checkForTrailingComma(result.types); + parseExpected(20); + return finishNode(result); + } + function checkForTrailingComma(list) { + if (parseDiagnostics.length === 0 && list.hasTrailingComma) { + var start = list.end - ",".length; + parseErrorAtPosition(start, ",".length, ts.Diagnostics.Trailing_comma_not_allowed); + } + } + function parseJSDocUnionType() { + var result = createNode(253); + nextToken(); + result.types = parseJSDocTypeList(parseJSDocType()); + parseExpected(18); + return finishNode(result); + } + function parseJSDocTypeList(firstType) { + ts.Debug.assert(!!firstType); + var types = []; + types.pos = firstType.pos; + types.push(firstType); + while (parseOptional(47)) { + types.push(parseJSDocType()); + } + types.end = scanner.getStartPos(); + return types; + } + function parseJSDocAllType() { + var result = createNode(250); + nextToken(); + return finishNode(result); + } + function parseJSDocUnknownOrNullableType() { + var pos = scanner.getStartPos(); + nextToken(); + if (token === 24 || + token === 16 || + token === 18 || + token === 27 || + token === 56 || + token === 47) { + var result = createNode(251, pos); + return finishNode(result); + } + else { + var result = createNode(255, pos); + result.type = parseJSDocType(); + return finishNode(result); + } + } + function parseIsolatedJSDocComment(content, start, length) { + initializeState("file.js", content, 2, undefined); + var jsDocComment = parseJSDocComment(undefined, start, length); + var diagnostics = parseDiagnostics; + clearState(); + return jsDocComment ? { jsDocComment: jsDocComment, diagnostics: diagnostics } : undefined; + } + JSDocParser.parseIsolatedJSDocComment = parseIsolatedJSDocComment; + function parseJSDocComment(parent, start, length) { + var comment = parseJSDocCommentWorker(start, length); + if (comment) { + fixupParentReferences(comment); + comment.parent = parent; + } + return comment; + } + JSDocParser.parseJSDocComment = parseJSDocComment; + function parseJSDocCommentWorker(start, length) { + var content = sourceText; + start = start || 0; + var end = length === undefined ? content.length : start + length; + length = end - start; + ts.Debug.assert(start >= 0); + ts.Debug.assert(start <= end); + ts.Debug.assert(end <= content.length); + var tags; + var pos; + if (length >= "/** */".length) { + if (content.charCodeAt(start) === 47 && + content.charCodeAt(start + 1) === 42 && + content.charCodeAt(start + 2) === 42 && + content.charCodeAt(start + 3) !== 42) { + var canParseTag = true; + var seenAsterisk = true; + for (pos = start + "/**".length; pos < end;) { + var ch = content.charCodeAt(pos); + pos++; + if (ch === 64 && canParseTag) { + parseTag(); + canParseTag = false; + continue; + } + if (ts.isLineBreak(ch)) { + canParseTag = true; + seenAsterisk = false; + continue; + } + if (ts.isWhiteSpace(ch)) { + continue; + } + if (ch === 42) { + if (seenAsterisk) { + canParseTag = false; + } + seenAsterisk = true; + continue; + } + canParseTag = false; + } + } + } + return createJSDocComment(); + function createJSDocComment() { + if (!tags) { + return undefined; + } + var result = createNode(265, start); + result.tags = tags; + return finishNode(result, end); + } + function skipWhitespace() { + while (pos < end && ts.isWhiteSpace(content.charCodeAt(pos))) { + pos++; + } + } + function parseTag() { + ts.Debug.assert(content.charCodeAt(pos - 1) === 64); + var atToken = createNode(55, pos - 1); + atToken.end = pos; + var tagName = scanIdentifier(); + if (!tagName) { + return; + } + var tag = handleTag(atToken, tagName) || handleUnknownTag(atToken, tagName); + addTag(tag); + } + function handleTag(atToken, tagName) { + if (tagName) { + switch (tagName.text) { + case "param": + return handleParamTag(atToken, tagName); + case "return": + case "returns": + return handleReturnTag(atToken, tagName); + case "template": + return handleTemplateTag(atToken, tagName); + case "type": + return handleTypeTag(atToken, tagName); + } + } + return undefined; + } + function handleUnknownTag(atToken, tagName) { + var result = createNode(266, atToken.pos); + result.atToken = atToken; + result.tagName = tagName; + return finishNode(result, pos); + } + function addTag(tag) { + if (tag) { + if (!tags) { + tags = []; + tags.pos = tag.pos; + } + tags.push(tag); + tags.end = tag.end; + } + } + function tryParseTypeExpression() { + skipWhitespace(); + if (content.charCodeAt(pos) !== 123) { + return undefined; + } + var typeExpression = parseJSDocTypeExpression(pos, end - pos); + pos = typeExpression.end; + return typeExpression; + } + function handleParamTag(atToken, tagName) { + var typeExpression = tryParseTypeExpression(); + skipWhitespace(); + var name; + var isBracketed; + if (content.charCodeAt(pos) === 91) { + pos++; + skipWhitespace(); + name = scanIdentifier(); + isBracketed = true; + } + else { + name = scanIdentifier(); + } + if (!name) { + parseErrorAtPosition(pos, 0, ts.Diagnostics.Identifier_expected); + } + var preName, postName; + if (typeExpression) { + postName = name; + } + else { + preName = name; + } + if (!typeExpression) { + typeExpression = tryParseTypeExpression(); + } + var result = createNode(267, atToken.pos); + result.atToken = atToken; + result.tagName = tagName; + result.preParameterName = preName; + result.typeExpression = typeExpression; + result.postParameterName = postName; + result.isBracketed = isBracketed; + return finishNode(result, pos); + } + function handleReturnTag(atToken, tagName) { + if (ts.forEach(tags, function (t) { return t.kind === 268; })) { + parseErrorAtPosition(tagName.pos, pos - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); + } + var result = createNode(268, atToken.pos); + result.atToken = atToken; + result.tagName = tagName; + result.typeExpression = tryParseTypeExpression(); + return finishNode(result, pos); + } + function handleTypeTag(atToken, tagName) { + if (ts.forEach(tags, function (t) { return t.kind === 269; })) { + parseErrorAtPosition(tagName.pos, pos - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); + } + var result = createNode(269, atToken.pos); + result.atToken = atToken; + result.tagName = tagName; + result.typeExpression = tryParseTypeExpression(); + return finishNode(result, pos); + } + function handleTemplateTag(atToken, tagName) { + if (ts.forEach(tags, function (t) { return t.kind === 270; })) { + parseErrorAtPosition(tagName.pos, pos - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); + } + var typeParameters = []; + typeParameters.pos = pos; + while (true) { + skipWhitespace(); + var startPos = pos; + var name_9 = scanIdentifier(); + if (!name_9) { + parseErrorAtPosition(startPos, 0, ts.Diagnostics.Identifier_expected); + return undefined; + } + var typeParameter = createNode(137, name_9.pos); + typeParameter.name = name_9; + finishNode(typeParameter, pos); + typeParameters.push(typeParameter); + skipWhitespace(); + if (content.charCodeAt(pos) !== 44) { + break; + } + pos++; + } + typeParameters.end = pos; + var result = createNode(270, atToken.pos); + result.atToken = atToken; + result.tagName = tagName; + result.typeParameters = typeParameters; + return finishNode(result, pos); + } + function scanIdentifier() { + var startPos = pos; + for (; pos < end; pos++) { + var ch = content.charCodeAt(pos); + if (pos === startPos && ts.isIdentifierStart(ch, 2)) { + continue; + } + else if (pos > startPos && ts.isIdentifierPart(ch, 2)) { + continue; + } + break; + } + if (startPos === pos) { + return undefined; + } + var result = createNode(69, startPos); + result.text = content.substring(startPos, pos); + return finishNode(result, pos); + } + } + JSDocParser.parseJSDocCommentWorker = parseJSDocCommentWorker; + })(JSDocParser = Parser.JSDocParser || (Parser.JSDocParser = {})); + })(Parser || (Parser = {})); + var IncrementalParser; + (function (IncrementalParser) { + function updateSourceFile(sourceFile, newText, textChangeRange, aggressiveChecks) { + aggressiveChecks = aggressiveChecks || ts.Debug.shouldAssert(2); + checkChangeRange(sourceFile, newText, textChangeRange, aggressiveChecks); + if (ts.textChangeRangeIsUnchanged(textChangeRange)) { + return sourceFile; + } + if (sourceFile.statements.length === 0) { + return Parser.parseSourceFile(sourceFile.fileName, newText, sourceFile.languageVersion, undefined, true); + } + var incrementalSourceFile = sourceFile; + ts.Debug.assert(!incrementalSourceFile.hasBeenIncrementallyParsed); + incrementalSourceFile.hasBeenIncrementallyParsed = true; + var oldText = sourceFile.text; + var syntaxCursor = createSyntaxCursor(sourceFile); + var changeRange = extendToAffectedRange(sourceFile, textChangeRange); + checkChangeRange(sourceFile, newText, changeRange, aggressiveChecks); + ts.Debug.assert(changeRange.span.start <= textChangeRange.span.start); + ts.Debug.assert(ts.textSpanEnd(changeRange.span) === ts.textSpanEnd(textChangeRange.span)); + ts.Debug.assert(ts.textSpanEnd(ts.textChangeRangeNewSpan(changeRange)) === ts.textSpanEnd(ts.textChangeRangeNewSpan(textChangeRange))); + var delta = ts.textChangeRangeNewSpan(changeRange).length - changeRange.span.length; + updateTokenPositionsAndMarkElements(incrementalSourceFile, changeRange.span.start, ts.textSpanEnd(changeRange.span), ts.textSpanEnd(ts.textChangeRangeNewSpan(changeRange)), delta, oldText, newText, aggressiveChecks); + var result = Parser.parseSourceFile(sourceFile.fileName, newText, sourceFile.languageVersion, syntaxCursor, true); + return result; + } + IncrementalParser.updateSourceFile = updateSourceFile; + function moveElementEntirelyPastChangeRange(element, isArray, delta, oldText, newText, aggressiveChecks) { + if (isArray) { + visitArray(element); + } + else { + visitNode(element); + } + return; + function visitNode(node) { + var text = ""; + if (aggressiveChecks && shouldCheckNode(node)) { + text = oldText.substring(node.pos, node.end); + } + if (node._children) { + node._children = undefined; + } + if (node.jsDocComment) { + node.jsDocComment = undefined; + } + node.pos += delta; + node.end += delta; + if (aggressiveChecks && shouldCheckNode(node)) { + ts.Debug.assert(text === newText.substring(node.pos, node.end)); + } + forEachChild(node, visitNode, visitArray); + checkNodePositions(node, aggressiveChecks); + } + function visitArray(array) { + array._children = undefined; + array.pos += delta; + array.end += delta; + for (var _i = 0; _i < array.length; _i++) { + var node = array[_i]; + visitNode(node); + } + } + } + function shouldCheckNode(node) { + switch (node.kind) { + case 9: + case 8: + case 69: + return true; + } + return false; + } + function adjustIntersectingElement(element, changeStart, changeRangeOldEnd, changeRangeNewEnd, delta) { + ts.Debug.assert(element.end >= changeStart, "Adjusting an element that was entirely before the change range"); + ts.Debug.assert(element.pos <= changeRangeOldEnd, "Adjusting an element that was entirely after the change range"); + ts.Debug.assert(element.pos <= element.end); + element.pos = Math.min(element.pos, changeRangeNewEnd); + if (element.end >= changeRangeOldEnd) { + element.end += delta; + } + else { + element.end = Math.min(element.end, changeRangeNewEnd); + } + ts.Debug.assert(element.pos <= element.end); + if (element.parent) { + ts.Debug.assert(element.pos >= element.parent.pos); + ts.Debug.assert(element.end <= element.parent.end); + } + } + function checkNodePositions(node, aggressiveChecks) { + if (aggressiveChecks) { + var pos = node.pos; + forEachChild(node, function (child) { + ts.Debug.assert(child.pos >= pos); + pos = child.end; + }); + ts.Debug.assert(pos <= node.end); + } + } + function updateTokenPositionsAndMarkElements(sourceFile, changeStart, changeRangeOldEnd, changeRangeNewEnd, delta, oldText, newText, aggressiveChecks) { + visitNode(sourceFile); + return; + function visitNode(child) { + ts.Debug.assert(child.pos <= child.end); + if (child.pos > changeRangeOldEnd) { + moveElementEntirelyPastChangeRange(child, false, delta, oldText, newText, aggressiveChecks); + return; + } + var fullEnd = child.end; + if (fullEnd >= changeStart) { + child.intersectsChange = true; + child._children = undefined; + adjustIntersectingElement(child, changeStart, changeRangeOldEnd, changeRangeNewEnd, delta); + forEachChild(child, visitNode, visitArray); + checkNodePositions(child, aggressiveChecks); + return; + } + ts.Debug.assert(fullEnd < changeStart); + } + function visitArray(array) { + ts.Debug.assert(array.pos <= array.end); + if (array.pos > changeRangeOldEnd) { + moveElementEntirelyPastChangeRange(array, true, delta, oldText, newText, aggressiveChecks); + return; + } + var fullEnd = array.end; + if (fullEnd >= changeStart) { + array.intersectsChange = true; + array._children = undefined; + adjustIntersectingElement(array, changeStart, changeRangeOldEnd, changeRangeNewEnd, delta); + for (var _i = 0; _i < array.length; _i++) { + var node = array[_i]; + visitNode(node); + } + return; + } + ts.Debug.assert(fullEnd < changeStart); + } + } + function extendToAffectedRange(sourceFile, changeRange) { + var maxLookahead = 1; + var start = changeRange.span.start; + for (var i = 0; start > 0 && i <= maxLookahead; i++) { + var nearestNode = findNearestNodeStartingBeforeOrAtPosition(sourceFile, start); + ts.Debug.assert(nearestNode.pos <= start); + var position = nearestNode.pos; + start = Math.max(0, position - 1); + } + var finalSpan = ts.createTextSpanFromBounds(start, ts.textSpanEnd(changeRange.span)); + var finalLength = changeRange.newLength + (changeRange.span.start - start); + return ts.createTextChangeRange(finalSpan, finalLength); + } + function findNearestNodeStartingBeforeOrAtPosition(sourceFile, position) { + var bestResult = sourceFile; + var lastNodeEntirelyBeforePosition; + forEachChild(sourceFile, visit); + if (lastNodeEntirelyBeforePosition) { + var lastChildOfLastEntireNodeBeforePosition = getLastChild(lastNodeEntirelyBeforePosition); + if (lastChildOfLastEntireNodeBeforePosition.pos > bestResult.pos) { + bestResult = lastChildOfLastEntireNodeBeforePosition; + } + } + return bestResult; + function getLastChild(node) { + while (true) { + var lastChild = getLastChildWorker(node); + if (lastChild) { + node = lastChild; + } + else { + return node; + } + } + } + function getLastChildWorker(node) { + var last = undefined; + forEachChild(node, function (child) { + if (ts.nodeIsPresent(child)) { + last = child; + } + }); + return last; + } + function visit(child) { + if (ts.nodeIsMissing(child)) { + return; + } + if (child.pos <= position) { + if (child.pos >= bestResult.pos) { + bestResult = child; + } + if (position < child.end) { + forEachChild(child, visit); + return true; + } + else { + ts.Debug.assert(child.end <= position); + lastNodeEntirelyBeforePosition = child; + } + } + else { + ts.Debug.assert(child.pos > position); + return true; + } + } + } + function checkChangeRange(sourceFile, newText, textChangeRange, aggressiveChecks) { + var oldText = sourceFile.text; + if (textChangeRange) { + ts.Debug.assert((oldText.length - textChangeRange.span.length + textChangeRange.newLength) === newText.length); + if (aggressiveChecks || ts.Debug.shouldAssert(3)) { + var oldTextPrefix = oldText.substr(0, textChangeRange.span.start); + var newTextPrefix = newText.substr(0, textChangeRange.span.start); + ts.Debug.assert(oldTextPrefix === newTextPrefix); + var oldTextSuffix = oldText.substring(ts.textSpanEnd(textChangeRange.span), oldText.length); + var newTextSuffix = newText.substring(ts.textSpanEnd(ts.textChangeRangeNewSpan(textChangeRange)), newText.length); + ts.Debug.assert(oldTextSuffix === newTextSuffix); + } + } + } + function createSyntaxCursor(sourceFile) { + var currentArray = sourceFile.statements; + var currentArrayIndex = 0; + ts.Debug.assert(currentArrayIndex < currentArray.length); + var current = currentArray[currentArrayIndex]; + var lastQueriedPosition = -1; + return { + currentNode: function (position) { + if (position !== lastQueriedPosition) { + if (current && current.end === position && currentArrayIndex < (currentArray.length - 1)) { + currentArrayIndex++; + current = currentArray[currentArrayIndex]; + } + if (!current || current.pos !== position) { + findHighestListElementThatStartsAtPosition(position); + } + } + lastQueriedPosition = position; + ts.Debug.assert(!current || current.pos === position); + return current; + } + }; + function findHighestListElementThatStartsAtPosition(position) { + currentArray = undefined; + currentArrayIndex = -1; + current = undefined; + forEachChild(sourceFile, visitNode, visitArray); + return; + function visitNode(node) { + if (position >= node.pos && position < node.end) { + forEachChild(node, visitNode, visitArray); + return true; + } + return false; + } + function visitArray(array) { + if (position >= array.pos && position < array.end) { + for (var i = 0, n = array.length; i < n; i++) { + var child = array[i]; + if (child) { + if (child.pos === position) { + currentArray = array; + currentArrayIndex = i; + current = child; + return true; + } + else { + if (child.pos < position && position < child.end) { + forEachChild(child, visitNode, visitArray); + return true; + } + } + } + } + } + return false; + } + } + } + })(IncrementalParser || (IncrementalParser = {})); +})(ts || (ts = {})); +var ts; +(function (ts) { + ts.bindTime = 0; + function getModuleInstanceState(node) { + if (node.kind === 215 || node.kind === 216) { + return 0; + } + else if (ts.isConstEnumDeclaration(node)) { + return 2; + } + else if ((node.kind === 222 || node.kind === 221) && !(node.flags & 1)) { + return 0; + } + else if (node.kind === 219) { + var state = 0; + ts.forEachChild(node, function (n) { + switch (getModuleInstanceState(n)) { + case 0: + return false; + case 2: + state = 2; + return false; + case 1: + state = 1; + return true; + } + }); + return state; + } + else if (node.kind === 218) { + return getModuleInstanceState(node.body); + } + else { + return 1; + } + } + ts.getModuleInstanceState = getModuleInstanceState; + function bindSourceFile(file) { + var start = new Date().getTime(); + bindSourceFileWorker(file); + ts.bindTime += new Date().getTime() - start; + } + ts.bindSourceFile = bindSourceFile; + function bindSourceFileWorker(file) { + var parent; + var container; + var blockScopeContainer; + var lastContainer; + var seenThisKeyword; + var inStrictMode = !!file.externalModuleIndicator; + var symbolCount = 0; + var Symbol = ts.objectAllocator.getSymbolConstructor(); + var classifiableNames = {}; + if (!file.locals) { + bind(file); + file.symbolCount = symbolCount; + file.classifiableNames = classifiableNames; + } + return; + function createSymbol(flags, name) { + symbolCount++; + return new Symbol(flags, name); + } + function addDeclarationToSymbol(symbol, node, symbolFlags) { + symbol.flags |= symbolFlags; + node.symbol = symbol; + if (!symbol.declarations) { + symbol.declarations = []; + } + symbol.declarations.push(node); + if (symbolFlags & 1952 && !symbol.exports) { + symbol.exports = {}; + } + if (symbolFlags & 6240 && !symbol.members) { + symbol.members = {}; + } + if (symbolFlags & 107455 && !symbol.valueDeclaration) { + symbol.valueDeclaration = node; + } + } + function getDeclarationName(node) { + if (node.name) { + if (node.kind === 218 && node.name.kind === 9) { + return "\"" + node.name.text + "\""; + } + if (node.name.kind === 136) { + var nameExpression = node.name.expression; + ts.Debug.assert(ts.isWellKnownSymbolSyntactically(nameExpression)); + return ts.getPropertyNameForKnownSymbolName(nameExpression.name.text); + } + return node.name.text; + } + switch (node.kind) { + case 144: + return "__constructor"; + case 152: + case 147: + return "__call"; + case 153: + case 148: + return "__new"; + case 149: + return "__index"; + case 228: + return "__export"; + case 227: + return node.isExportEquals ? "export=" : "default"; + case 213: + case 214: + return node.flags & 1024 ? "default" : undefined; + } + } + function getDisplayName(node) { + return node.name ? ts.declarationNameToString(node.name) : getDeclarationName(node); + } + function declareSymbol(symbolTable, parent, node, includes, excludes) { + ts.Debug.assert(!ts.hasDynamicName(node)); + var isDefaultExport = node.flags & 1024; + var name = isDefaultExport && parent ? "default" : getDeclarationName(node); + var symbol; + if (name !== undefined) { + symbol = ts.hasProperty(symbolTable, name) + ? symbolTable[name] + : (symbolTable[name] = createSymbol(0, name)); + if (name && (includes & 788448)) { + classifiableNames[name] = name; + } + if (symbol.flags & excludes) { + if (node.name) { + node.name.parent = node; + } + var message = symbol.flags & 2 + ? ts.Diagnostics.Cannot_redeclare_block_scoped_variable_0 + : ts.Diagnostics.Duplicate_identifier_0; + ts.forEach(symbol.declarations, function (declaration) { + if (declaration.flags & 1024) { + message = ts.Diagnostics.A_module_cannot_have_multiple_default_exports; + } + }); + ts.forEach(symbol.declarations, function (declaration) { + file.bindDiagnostics.push(ts.createDiagnosticForNode(declaration.name || declaration, message, getDisplayName(declaration))); + }); + file.bindDiagnostics.push(ts.createDiagnosticForNode(node.name || node, message, getDisplayName(node))); + symbol = createSymbol(0, name); + } + } + else { + symbol = createSymbol(0, "__missing"); + } + addDeclarationToSymbol(symbol, node, includes); + symbol.parent = parent; + return symbol; + } + function declareModuleMember(node, symbolFlags, symbolExcludes) { + var hasExportModifier = ts.getCombinedNodeFlags(node) & 1; + if (symbolFlags & 8388608) { + if (node.kind === 230 || (node.kind === 221 && hasExportModifier)) { + return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); + } + else { + return declareSymbol(container.locals, undefined, node, symbolFlags, symbolExcludes); + } + } + else { + if (hasExportModifier || container.flags & 262144) { + var exportKind = (symbolFlags & 107455 ? 1048576 : 0) | + (symbolFlags & 793056 ? 2097152 : 0) | + (symbolFlags & 1536 ? 4194304 : 0); + var 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); + } + } + } + function bindChildren(node) { + var saveParent = parent; + var saveContainer = container; + var savedBlockScopeContainer = blockScopeContainer; + parent = node; + var containerFlags = getContainerFlags(node); + if (containerFlags & 1) { + container = blockScopeContainer = node; + if (containerFlags & 4) { + container.locals = {}; + } + addToContainerChain(container); + } + else if (containerFlags & 2) { + blockScopeContainer = node; + blockScopeContainer.locals = undefined; + } + if (node.kind === 215) { + seenThisKeyword = false; + ts.forEachChild(node, bind); + node.flags = seenThisKeyword ? node.flags | 524288 : node.flags & ~524288; + } + else { + ts.forEachChild(node, bind); + } + container = saveContainer; + parent = saveParent; + blockScopeContainer = savedBlockScopeContainer; + } + function getContainerFlags(node) { + switch (node.kind) { + case 186: + case 214: + case 215: + case 217: + case 155: + case 165: + return 1; + case 147: + case 148: + case 149: + case 143: + case 142: + case 213: + case 144: + case 145: + case 146: + case 152: + case 153: + case 173: + case 174: + case 218: + case 248: + case 216: + return 5; + case 244: + case 199: + case 200: + case 201: + case 220: + return 2; + case 192: + return ts.isFunctionLike(node.parent) ? 0 : 2; + } + return 0; + } + function addToContainerChain(next) { + if (lastContainer) { + lastContainer.nextContainer = next; + } + lastContainer = next; + } + function declareSymbolAndAddToSymbolTable(node, symbolFlags, symbolExcludes) { + declareSymbolAndAddToSymbolTableWorker(node, symbolFlags, symbolExcludes); + } + function declareSymbolAndAddToSymbolTableWorker(node, symbolFlags, symbolExcludes) { + switch (container.kind) { + case 218: + return declareModuleMember(node, symbolFlags, symbolExcludes); + case 248: + return declareSourceFileMember(node, symbolFlags, symbolExcludes); + case 186: + case 214: + return declareClassMember(node, symbolFlags, symbolExcludes); + case 217: + return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); + case 155: + case 165: + case 215: + return declareSymbol(container.symbol.members, container.symbol, node, symbolFlags, symbolExcludes); + case 152: + case 153: + case 147: + case 148: + case 149: + case 143: + case 142: + case 144: + case 145: + case 146: + case 213: + case 173: + case 174: + case 216: + return declareSymbol(container.locals, undefined, node, symbolFlags, symbolExcludes); + } + } + function declareClassMember(node, symbolFlags, symbolExcludes) { + return node.flags & 128 + ? declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes) + : declareSymbol(container.symbol.members, container.symbol, node, symbolFlags, symbolExcludes); + } + function declareSourceFileMember(node, symbolFlags, symbolExcludes) { + return ts.isExternalModule(file) + ? declareModuleMember(node, symbolFlags, symbolExcludes) + : declareSymbol(file.locals, undefined, node, symbolFlags, symbolExcludes); + } + function isAmbientContext(node) { + while (node) { + if (node.flags & 2) { + return true; + } + node = node.parent; + } + return false; + } + function hasExportDeclarations(node) { + var body = node.kind === 248 ? node : node.body; + if (body.kind === 248 || body.kind === 219) { + for (var _i = 0, _a = body.statements; _i < _a.length; _i++) { + var stat = _a[_i]; + if (stat.kind === 228 || stat.kind === 227) { + return true; + } + } + } + return false; + } + function setExportContextFlag(node) { + if (isAmbientContext(node) && !hasExportDeclarations(node)) { + node.flags |= 262144; + } + else { + node.flags &= ~262144; + } + } + function bindModuleDeclaration(node) { + setExportContextFlag(node); + if (node.name.kind === 9) { + declareSymbolAndAddToSymbolTable(node, 512, 106639); + } + else { + var state = getModuleInstanceState(node); + if (state === 0) { + declareSymbolAndAddToSymbolTable(node, 1024, 0); + } + else { + declareSymbolAndAddToSymbolTable(node, 512, 106639); + if (node.symbol.flags & (16 | 32 | 256)) { + node.symbol.constEnumOnlyModule = false; + } + else { + var currentModuleIsConstEnumOnly = state === 2; + if (node.symbol.constEnumOnlyModule === undefined) { + node.symbol.constEnumOnlyModule = currentModuleIsConstEnumOnly; + } + else { + node.symbol.constEnumOnlyModule = node.symbol.constEnumOnlyModule && currentModuleIsConstEnumOnly; + } + } + } + } + } + function bindFunctionOrConstructorType(node) { + var symbol = createSymbol(131072, getDeclarationName(node)); + addDeclarationToSymbol(symbol, node, 131072); + var typeLiteralSymbol = createSymbol(2048, "__type"); + addDeclarationToSymbol(typeLiteralSymbol, node, 2048); + typeLiteralSymbol.members = (_a = {}, _a[symbol.name] = symbol, _a); + var _a; + } + function bindObjectLiteralExpression(node) { + if (inStrictMode) { + var seen = {}; + for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { + var prop = _a[_i]; + if (prop.name.kind !== 69) { + continue; + } + var identifier = prop.name; + var currentKind = prop.kind === 245 || prop.kind === 246 || prop.kind === 143 + ? 1 + : 2; + var existingKind = seen[identifier.text]; + if (!existingKind) { + seen[identifier.text] = currentKind; + continue; + } + if (currentKind === 1 && existingKind === 1) { + var span = ts.getErrorSpanForNode(file, identifier); + file.bindDiagnostics.push(ts.createFileDiagnostic(file, span.start, span.length, ts.Diagnostics.An_object_literal_cannot_have_multiple_properties_with_the_same_name_in_strict_mode)); + } + } + } + return bindAnonymousDeclaration(node, 4096, "__object"); + } + function bindAnonymousDeclaration(node, symbolFlags, name) { + var symbol = createSymbol(symbolFlags, name); + addDeclarationToSymbol(symbol, node, symbolFlags); + } + function bindBlockScopedDeclaration(node, symbolFlags, symbolExcludes) { + switch (blockScopeContainer.kind) { + case 218: + declareModuleMember(node, symbolFlags, symbolExcludes); + break; + case 248: + if (ts.isExternalModule(container)) { + declareModuleMember(node, symbolFlags, symbolExcludes); + break; + } + default: + if (!blockScopeContainer.locals) { + blockScopeContainer.locals = {}; + addToContainerChain(blockScopeContainer); + } + declareSymbol(blockScopeContainer.locals, undefined, node, symbolFlags, symbolExcludes); + } + } + function bindBlockScopedVariableDeclaration(node) { + bindBlockScopedDeclaration(node, 2, 107455); + } + function checkStrictModeIdentifier(node) { + if (inStrictMode && + node.originalKeywordKind >= 106 && + node.originalKeywordKind <= 114 && + !ts.isIdentifierName(node)) { + if (!file.parseDiagnostics.length) { + file.bindDiagnostics.push(ts.createDiagnosticForNode(node, getStrictModeIdentifierMessage(node), ts.declarationNameToString(node))); + } + } + } + function getStrictModeIdentifierMessage(node) { + if (ts.getContainingClass(node)) { + return ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_strict_mode; + } + if (file.externalModuleIndicator) { + return ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode_Modules_are_automatically_in_strict_mode; + } + return ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode; + } + function checkStrictModeBinaryExpression(node) { + if (inStrictMode && ts.isLeftHandSideExpression(node.left) && ts.isAssignmentOperator(node.operatorToken.kind)) { + checkStrictModeEvalOrArguments(node, node.left); + } + } + function checkStrictModeCatchClause(node) { + if (inStrictMode && node.variableDeclaration) { + checkStrictModeEvalOrArguments(node, node.variableDeclaration.name); + } + } + function checkStrictModeDeleteExpression(node) { + if (inStrictMode && node.expression.kind === 69) { + var span = ts.getErrorSpanForNode(file, node.expression); + file.bindDiagnostics.push(ts.createFileDiagnostic(file, span.start, span.length, ts.Diagnostics.delete_cannot_be_called_on_an_identifier_in_strict_mode)); + } + } + function isEvalOrArgumentsIdentifier(node) { + return node.kind === 69 && + (node.text === "eval" || node.text === "arguments"); + } + function checkStrictModeEvalOrArguments(contextNode, name) { + if (name && name.kind === 69) { + var identifier = name; + if (isEvalOrArgumentsIdentifier(identifier)) { + var span = ts.getErrorSpanForNode(file, name); + file.bindDiagnostics.push(ts.createFileDiagnostic(file, span.start, span.length, getStrictModeEvalOrArgumentsMessage(contextNode), identifier.text)); + } + } + } + function getStrictModeEvalOrArgumentsMessage(node) { + if (ts.getContainingClass(node)) { + return ts.Diagnostics.Invalid_use_of_0_Class_definitions_are_automatically_in_strict_mode; + } + if (file.externalModuleIndicator) { + return ts.Diagnostics.Invalid_use_of_0_Modules_are_automatically_in_strict_mode; + } + return ts.Diagnostics.Invalid_use_of_0_in_strict_mode; + } + function checkStrictModeFunctionName(node) { + if (inStrictMode) { + checkStrictModeEvalOrArguments(node, node.name); + } + } + function checkStrictModeNumericLiteral(node) { + if (inStrictMode && node.flags & 65536) { + file.bindDiagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.Octal_literals_are_not_allowed_in_strict_mode)); + } + } + function checkStrictModePostfixUnaryExpression(node) { + if (inStrictMode) { + checkStrictModeEvalOrArguments(node, node.operand); + } + } + function checkStrictModePrefixUnaryExpression(node) { + if (inStrictMode) { + if (node.operator === 41 || node.operator === 42) { + checkStrictModeEvalOrArguments(node, node.operand); + } + } + } + function checkStrictModeWithStatement(node) { + if (inStrictMode) { + grammarErrorOnFirstToken(node, ts.Diagnostics.with_statements_are_not_allowed_in_strict_mode); + } + } + function grammarErrorOnFirstToken(node, message, arg0, arg1, arg2) { + var span = ts.getSpanOfTokenAtPosition(file, node.pos); + file.bindDiagnostics.push(ts.createFileDiagnostic(file, span.start, span.length, message, arg0, arg1, arg2)); + } + function getDestructuringParameterName(node) { + return "__" + ts.indexOf(node.parent.parameters, node); + } + function bind(node) { + node.parent = parent; + var savedInStrictMode = inStrictMode; + if (!savedInStrictMode) { + updateStrictMode(node); + } + bindWorker(node); + bindChildren(node); + inStrictMode = savedInStrictMode; + } + function updateStrictMode(node) { + switch (node.kind) { + case 248: + case 219: + updateStrictModeStatementList(node.statements); + return; + case 192: + if (ts.isFunctionLike(node.parent)) { + updateStrictModeStatementList(node.statements); + } + return; + case 214: + case 186: + inStrictMode = true; + return; + } + } + function updateStrictModeStatementList(statements) { + for (var _i = 0; _i < statements.length; _i++) { + var statement = statements[_i]; + if (!ts.isPrologueDirective(statement)) { + return; + } + if (isUseStrictPrologueDirective(statement)) { + inStrictMode = true; + return; + } + } + } + function isUseStrictPrologueDirective(node) { + var nodeText = ts.getTextOfNodeFromSourceText(file.text, node.expression); + return nodeText === "\"use strict\"" || nodeText === "'use strict'"; + } + function bindWorker(node) { + switch (node.kind) { + case 69: + return checkStrictModeIdentifier(node); + case 181: + return checkStrictModeBinaryExpression(node); + case 244: + return checkStrictModeCatchClause(node); + case 175: + return checkStrictModeDeleteExpression(node); + case 8: + return checkStrictModeNumericLiteral(node); + case 180: + return checkStrictModePostfixUnaryExpression(node); + case 179: + return checkStrictModePrefixUnaryExpression(node); + case 205: + return checkStrictModeWithStatement(node); + case 97: + seenThisKeyword = true; + return; + case 137: + return declareSymbolAndAddToSymbolTable(node, 262144, 530912); + case 138: + return bindParameter(node); + case 211: + case 163: + return bindVariableDeclarationOrBindingElement(node); + case 141: + case 140: + return bindPropertyOrMethodOrAccessor(node, 4 | (node.questionToken ? 536870912 : 0), 107455); + case 245: + case 246: + return bindPropertyOrMethodOrAccessor(node, 4, 107455); + case 247: + return bindPropertyOrMethodOrAccessor(node, 8, 107455); + case 147: + case 148: + case 149: + return declareSymbolAndAddToSymbolTable(node, 131072, 0); + case 143: + case 142: + return bindPropertyOrMethodOrAccessor(node, 8192 | (node.questionToken ? 536870912 : 0), ts.isObjectLiteralMethod(node) ? 107455 : 99263); + case 213: + checkStrictModeFunctionName(node); + return declareSymbolAndAddToSymbolTable(node, 16, 106927); + case 144: + return declareSymbolAndAddToSymbolTable(node, 16384, 0); + case 145: + return bindPropertyOrMethodOrAccessor(node, 32768, 41919); + case 146: + return bindPropertyOrMethodOrAccessor(node, 65536, 74687); + case 152: + case 153: + return bindFunctionOrConstructorType(node); + case 155: + return bindAnonymousDeclaration(node, 2048, "__type"); + case 165: + return bindObjectLiteralExpression(node); + case 173: + case 174: + checkStrictModeFunctionName(node); + var bindingName = node.name ? node.name.text : "__function"; + return bindAnonymousDeclaration(node, 16, bindingName); + case 186: + case 214: + return bindClassLikeDeclaration(node); + case 215: + return bindBlockScopedDeclaration(node, 64, 792960); + case 216: + return bindBlockScopedDeclaration(node, 524288, 793056); + case 217: + return bindEnumDeclaration(node); + case 218: + return bindModuleDeclaration(node); + case 221: + case 224: + case 226: + case 230: + return declareSymbolAndAddToSymbolTable(node, 8388608, 8388608); + case 223: + return bindImportClause(node); + case 228: + return bindExportDeclaration(node); + case 227: + return bindExportAssignment(node); + case 248: + return bindSourceFileIfExternalModule(); + } + } + function bindSourceFileIfExternalModule() { + setExportContextFlag(file); + if (ts.isExternalModule(file)) { + bindAnonymousDeclaration(file, 512, "\"" + ts.removeFileExtension(file.fileName) + "\""); + } + } + function bindExportAssignment(node) { + if (!container.symbol || !container.symbol.exports) { + bindAnonymousDeclaration(node, 8388608, getDeclarationName(node)); + } + else if (node.expression.kind === 69) { + declareSymbol(container.symbol.exports, container.symbol, node, 8388608, 107455 | 8388608); + } + else { + declareSymbol(container.symbol.exports, container.symbol, node, 4, 107455 | 8388608); + } + } + function bindExportDeclaration(node) { + if (!container.symbol || !container.symbol.exports) { + bindAnonymousDeclaration(node, 1073741824, getDeclarationName(node)); + } + else if (!node.exportClause) { + declareSymbol(container.symbol.exports, container.symbol, node, 1073741824, 0); + } + } + function bindImportClause(node) { + if (node.name) { + declareSymbolAndAddToSymbolTable(node, 8388608, 8388608); + } + } + function bindClassLikeDeclaration(node) { + if (node.kind === 214) { + bindBlockScopedDeclaration(node, 32, 899519); + } + else { + var bindingName = node.name ? node.name.text : "__class"; + bindAnonymousDeclaration(node, 32, bindingName); + if (node.name) { + classifiableNames[node.name.text] = node.name.text; + } + } + var symbol = node.symbol; + var prototypeSymbol = createSymbol(4 | 134217728, "prototype"); + if (ts.hasProperty(symbol.exports, prototypeSymbol.name)) { + if (node.name) { + node.name.parent = node; + } + file.bindDiagnostics.push(ts.createDiagnosticForNode(symbol.exports[prototypeSymbol.name].declarations[0], ts.Diagnostics.Duplicate_identifier_0, prototypeSymbol.name)); + } + symbol.exports[prototypeSymbol.name] = prototypeSymbol; + prototypeSymbol.parent = symbol; + } + function bindEnumDeclaration(node) { + return ts.isConst(node) + ? bindBlockScopedDeclaration(node, 128, 899967) + : bindBlockScopedDeclaration(node, 256, 899327); + } + function bindVariableDeclarationOrBindingElement(node) { + if (inStrictMode) { + checkStrictModeEvalOrArguments(node, node.name); + } + if (!ts.isBindingPattern(node.name)) { + if (ts.isBlockOrCatchScoped(node)) { + bindBlockScopedVariableDeclaration(node); + } + else if (ts.isParameterDeclaration(node)) { + declareSymbolAndAddToSymbolTable(node, 1, 107455); + } + else { + declareSymbolAndAddToSymbolTable(node, 1, 107454); + } + } + } + function bindParameter(node) { + if (inStrictMode) { + checkStrictModeEvalOrArguments(node, node.name); + } + if (ts.isBindingPattern(node.name)) { + bindAnonymousDeclaration(node, 1, getDestructuringParameterName(node)); + } + else { + declareSymbolAndAddToSymbolTable(node, 1, 107455); + } + if (node.flags & 112 && + node.parent.kind === 144 && + ts.isClassLike(node.parent.parent)) { + var classDeclaration = node.parent.parent; + declareSymbol(classDeclaration.symbol.members, classDeclaration.symbol, node, 4, 107455); + } + } + function bindPropertyOrMethodOrAccessor(node, symbolFlags, symbolExcludes) { + return ts.hasDynamicName(node) + ? bindAnonymousDeclaration(node, symbolFlags, "__computed") + : declareSymbolAndAddToSymbolTable(node, symbolFlags, symbolExcludes); + } + } +})(ts || (ts = {})); +var ts; +(function (ts) { + var nextSymbolId = 1; + var nextNodeId = 1; + var nextMergeId = 1; + function getNodeId(node) { + if (!node.id) + node.id = nextNodeId++; + return node.id; + } + ts.getNodeId = getNodeId; + ts.checkTime = 0; + function getSymbolId(symbol) { + if (!symbol.id) { + symbol.id = nextSymbolId++; + } + return symbol.id; + } + ts.getSymbolId = getSymbolId; + function createTypeChecker(host, produceDiagnostics) { + var cancellationToken; + var Symbol = ts.objectAllocator.getSymbolConstructor(); + var Type = ts.objectAllocator.getTypeConstructor(); + var Signature = ts.objectAllocator.getSignatureConstructor(); + var typeCount = 0; + var symbolCount = 0; + var emptyArray = []; + var emptySymbols = {}; + var compilerOptions = host.getCompilerOptions(); + var languageVersion = compilerOptions.target || 0; + var modulekind = compilerOptions.module ? compilerOptions.module : languageVersion === 2 ? 5 : 0; + var emitResolver = createResolver(); + var undefinedSymbol = createSymbol(4 | 67108864, "undefined"); + var argumentsSymbol = createSymbol(4 | 67108864, "arguments"); + var checker = { + getNodeCount: function () { return ts.sum(host.getSourceFiles(), "nodeCount"); }, + getIdentifierCount: function () { return ts.sum(host.getSourceFiles(), "identifierCount"); }, + getSymbolCount: function () { return ts.sum(host.getSourceFiles(), "symbolCount") + symbolCount; }, + getTypeCount: function () { return typeCount; }, + isUndefinedSymbol: function (symbol) { return symbol === undefinedSymbol; }, + isArgumentsSymbol: function (symbol) { return symbol === argumentsSymbol; }, + getDiagnostics: getDiagnostics, + getGlobalDiagnostics: getGlobalDiagnostics, + getTypeOfSymbolAtLocation: getNarrowedTypeOfSymbol, + getDeclaredTypeOfSymbol: getDeclaredTypeOfSymbol, + getPropertiesOfType: getPropertiesOfType, + getPropertyOfType: getPropertyOfType, + getSignaturesOfType: getSignaturesOfType, + getIndexTypeOfType: getIndexTypeOfType, + getBaseTypes: getBaseTypes, + getReturnTypeOfSignature: getReturnTypeOfSignature, + getSymbolsInScope: getSymbolsInScope, + getSymbolAtLocation: getSymbolAtLocation, + getShorthandAssignmentValueSymbol: getShorthandAssignmentValueSymbol, + getTypeAtLocation: getTypeOfNode, + typeToString: typeToString, + getSymbolDisplayBuilder: getSymbolDisplayBuilder, + symbolToString: symbolToString, + getAugmentedPropertiesOfType: getAugmentedPropertiesOfType, + getRootSymbols: getRootSymbols, + getContextualType: getContextualType, + getFullyQualifiedName: getFullyQualifiedName, + getResolvedSignature: getResolvedSignature, + getConstantValue: getConstantValue, + isValidPropertyAccess: isValidPropertyAccess, + getSignatureFromDeclaration: getSignatureFromDeclaration, + isImplementationOfOverload: isImplementationOfOverload, + getAliasedSymbol: resolveAlias, + getEmitResolver: getEmitResolver, + getExportsOfModule: getExportsOfModuleAsArray, + getJsxElementAttributesType: getJsxElementAttributesType, + getJsxIntrinsicTagNames: getJsxIntrinsicTagNames, + isOptionalParameter: isOptionalParameter + }; + var unknownSymbol = createSymbol(4 | 67108864, "unknown"); + var resolvingSymbol = createSymbol(67108864, "__resolving__"); + var anyType = createIntrinsicType(1, "any"); + var stringType = createIntrinsicType(2, "string"); + var numberType = createIntrinsicType(4, "number"); + var booleanType = createIntrinsicType(8, "boolean"); + var esSymbolType = createIntrinsicType(16777216, "symbol"); + var voidType = createIntrinsicType(16, "void"); + var undefinedType = createIntrinsicType(32 | 2097152, "undefined"); + var nullType = createIntrinsicType(64 | 2097152, "null"); + var unknownType = createIntrinsicType(1, "unknown"); + var circularType = createIntrinsicType(1, "__circular__"); + var emptyObjectType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); + var emptyGenericType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); + emptyGenericType.instantiations = {}; + var anyFunctionType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); + anyFunctionType.flags |= 8388608; + var noConstraintType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); + var anySignature = createSignature(undefined, undefined, emptyArray, anyType, undefined, 0, false, false); + var unknownSignature = createSignature(undefined, undefined, emptyArray, unknownType, undefined, 0, false, false); + var globals = {}; + var globalESSymbolConstructorSymbol; + var getGlobalPromiseConstructorSymbol; + var globalObjectType; + var globalFunctionType; + var globalArrayType; + var globalStringType; + var globalNumberType; + var globalBooleanType; + var globalRegExpType; + var globalTemplateStringsArrayType; + var globalESSymbolType; + var jsxElementType; + var jsxIntrinsicElementsType; + var globalIterableType; + var globalIteratorType; + var globalIterableIteratorType; + var anyArrayType; + var getGlobalClassDecoratorType; + var getGlobalParameterDecoratorType; + var getGlobalPropertyDecoratorType; + var getGlobalMethodDecoratorType; + var getGlobalTypedPropertyDescriptorType; + var getGlobalPromiseType; + var tryGetGlobalPromiseType; + var getGlobalPromiseLikeType; + var getInstantiatedGlobalPromiseLikeType; + var getGlobalPromiseConstructorLikeType; + var getGlobalThenableType; + var tupleTypes = {}; + var unionTypes = {}; + var intersectionTypes = {}; + var stringLiteralTypes = {}; + var emitExtends = false; + var emitDecorate = false; + var emitParam = false; + var emitAwaiter = false; + var emitGenerator = false; + var resolutionTargets = []; + var resolutionResults = []; + var resolutionPropertyNames = []; + var mergedSymbols = []; + var symbolLinks = []; + var nodeLinks = []; + var potentialThisCollisions = []; + var awaitedTypeStack = []; + var diagnostics = ts.createDiagnosticCollection(); + var primitiveTypeInfo = { + "string": { + type: stringType, + flags: 258 + }, + "number": { + type: numberType, + flags: 132 + }, + "boolean": { + type: booleanType, + flags: 8 + }, + "symbol": { + type: esSymbolType, + flags: 16777216 + } + }; + var JsxNames = { + JSX: "JSX", + IntrinsicElements: "IntrinsicElements", + ElementClass: "ElementClass", + ElementAttributesPropertyNameContainer: "ElementAttributesProperty", + Element: "Element" + }; + var subtypeRelation = {}; + var assignableRelation = {}; + var identityRelation = {}; + var _displayBuilder; + initializeTypeChecker(); + return checker; + function getEmitResolver(sourceFile, cancellationToken) { + getDiagnostics(sourceFile, cancellationToken); + return emitResolver; + } + function error(location, message, arg0, arg1, arg2) { + var diagnostic = location + ? ts.createDiagnosticForNode(location, message, arg0, arg1, arg2) + : ts.createCompilerDiagnostic(message, arg0, arg1, arg2); + diagnostics.add(diagnostic); + } + function createSymbol(flags, name) { + symbolCount++; + return new Symbol(flags, name); + } + function getExcludedSymbolFlags(flags) { + var result = 0; + if (flags & 2) + result |= 107455; + if (flags & 1) + result |= 107454; + if (flags & 4) + result |= 107455; + if (flags & 8) + result |= 107455; + if (flags & 16) + result |= 106927; + if (flags & 32) + result |= 899519; + if (flags & 64) + result |= 792960; + if (flags & 256) + result |= 899327; + if (flags & 128) + result |= 899967; + if (flags & 512) + result |= 106639; + if (flags & 8192) + result |= 99263; + if (flags & 32768) + result |= 41919; + if (flags & 65536) + result |= 74687; + if (flags & 262144) + result |= 530912; + if (flags & 524288) + result |= 793056; + if (flags & 8388608) + result |= 8388608; + return result; + } + function recordMergedSymbol(target, source) { + if (!source.mergeId) + source.mergeId = nextMergeId++; + mergedSymbols[source.mergeId] = target; + } + function cloneSymbol(symbol) { + var result = createSymbol(symbol.flags | 33554432, symbol.name); + result.declarations = symbol.declarations.slice(0); + result.parent = symbol.parent; + if (symbol.valueDeclaration) + result.valueDeclaration = symbol.valueDeclaration; + if (symbol.constEnumOnlyModule) + result.constEnumOnlyModule = true; + if (symbol.members) + result.members = cloneSymbolTable(symbol.members); + if (symbol.exports) + result.exports = cloneSymbolTable(symbol.exports); + recordMergedSymbol(result, symbol); + return result; + } + function mergeSymbol(target, source) { + if (!(target.flags & getExcludedSymbolFlags(source.flags))) { + if (source.flags & 512 && target.flags & 512 && target.constEnumOnlyModule && !source.constEnumOnlyModule) { + target.constEnumOnlyModule = false; + } + target.flags |= source.flags; + if (!target.valueDeclaration && source.valueDeclaration) + target.valueDeclaration = source.valueDeclaration; + ts.forEach(source.declarations, function (node) { + target.declarations.push(node); + }); + if (source.members) { + if (!target.members) + target.members = {}; + mergeSymbolTable(target.members, source.members); + } + if (source.exports) { + if (!target.exports) + target.exports = {}; + mergeSymbolTable(target.exports, source.exports); + } + recordMergedSymbol(target, source); + } + else { + var message = target.flags & 2 || source.flags & 2 + ? ts.Diagnostics.Cannot_redeclare_block_scoped_variable_0 : ts.Diagnostics.Duplicate_identifier_0; + ts.forEach(source.declarations, function (node) { + error(node.name ? node.name : node, message, symbolToString(source)); + }); + ts.forEach(target.declarations, function (node) { + error(node.name ? node.name : node, message, symbolToString(source)); + }); + } + } + function cloneSymbolTable(symbolTable) { + var result = {}; + for (var id in symbolTable) { + if (ts.hasProperty(symbolTable, id)) { + result[id] = symbolTable[id]; + } + } + return result; + } + function mergeSymbolTable(target, source) { + for (var id in source) { + if (ts.hasProperty(source, id)) { + if (!ts.hasProperty(target, id)) { + target[id] = source[id]; + } + else { + var symbol = target[id]; + if (!(symbol.flags & 33554432)) { + target[id] = symbol = cloneSymbol(symbol); + } + mergeSymbol(symbol, source[id]); + } + } + } + } + function getSymbolLinks(symbol) { + if (symbol.flags & 67108864) + return symbol; + var id = getSymbolId(symbol); + return symbolLinks[id] || (symbolLinks[id] = {}); + } + function getNodeLinks(node) { + var nodeId = getNodeId(node); + return nodeLinks[nodeId] || (nodeLinks[nodeId] = {}); + } + function getSourceFile(node) { + return ts.getAncestor(node, 248); + } + function isGlobalSourceFile(node) { + return node.kind === 248 && !ts.isExternalModule(node); + } + function getSymbol(symbols, name, meaning) { + if (meaning && ts.hasProperty(symbols, name)) { + var symbol = symbols[name]; + ts.Debug.assert((symbol.flags & 16777216) === 0, "Should never get an instantiated symbol here."); + if (symbol.flags & meaning) { + return symbol; + } + if (symbol.flags & 8388608) { + var target = resolveAlias(symbol); + if (target === unknownSymbol || target.flags & meaning) { + return symbol; + } + } + } + } + function isBlockScopedNameDeclaredBeforeUse(declaration, usage) { + var declarationFile = ts.getSourceFileOfNode(declaration); + var useFile = ts.getSourceFileOfNode(usage); + if (declarationFile !== useFile) { + if (modulekind || (!compilerOptions.outFile && !compilerOptions.out)) { + return true; + } + var sourceFiles = host.getSourceFiles(); + return ts.indexOf(sourceFiles, declarationFile) <= ts.indexOf(sourceFiles, useFile); + } + if (declaration.pos <= usage.pos) { + return declaration.kind !== 211 || + !isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage); + } + return isUsedInFunctionOrNonStaticProperty(declaration, usage); + function isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage) { + var container = ts.getEnclosingBlockScopeContainer(declaration); + if (declaration.parent.parent.kind === 193 || + declaration.parent.parent.kind === 199) { + return isSameScopeDescendentOf(usage, declaration, container); + } + else if (declaration.parent.parent.kind === 201 || + declaration.parent.parent.kind === 200) { + var expression = declaration.parent.parent.expression; + return isSameScopeDescendentOf(usage, expression, container); + } + } + function isUsedInFunctionOrNonStaticProperty(declaration, usage) { + var container = ts.getEnclosingBlockScopeContainer(declaration); + var current = usage; + while (current) { + if (current === container) { + return false; + } + if (ts.isFunctionLike(current)) { + return true; + } + var initializerOfNonStaticProperty = current.parent && + current.parent.kind === 141 && + (current.parent.flags & 128) === 0 && + current.parent.initializer === current; + if (initializerOfNonStaticProperty) { + return true; + } + current = current.parent; + } + return false; + } + } + function resolveName(location, name, meaning, nameNotFoundMessage, nameArg) { + var result; + var lastLocation; + var propertyWithInvalidInitializer; + var errorLocation = location; + var grandparent; + loop: while (location) { + if (location.locals && !isGlobalSourceFile(location)) { + if (result = getSymbol(location.locals, name, meaning)) { + if (!(meaning & 793056) || + !(result.flags & (793056 & ~262144)) || + !ts.isFunctionLike(location) || + lastLocation === location.body) { + break loop; + } + result = undefined; + } + } + switch (location.kind) { + case 248: + if (!ts.isExternalModule(location)) + break; + case 218: + var moduleExports = getSymbolOfNode(location).exports; + if (location.kind === 248 || + (location.kind === 218 && location.name.kind === 9)) { + if (ts.hasProperty(moduleExports, name) && + moduleExports[name].flags === 8388608 && + ts.getDeclarationOfKind(moduleExports[name], 230)) { + break; + } + result = moduleExports["default"]; + var localSymbol = ts.getLocalSymbolForExportDefault(result); + if (result && localSymbol && (result.flags & meaning) && localSymbol.name === name) { + break loop; + } + result = undefined; + } + if (result = getSymbol(moduleExports, name, meaning & 8914931)) { + break loop; + } + break; + case 217: + if (result = getSymbol(getSymbolOfNode(location).exports, name, meaning & 8)) { + break loop; + } + break; + case 141: + case 140: + if (ts.isClassLike(location.parent) && !(location.flags & 128)) { + var ctor = findConstructorDeclaration(location.parent); + if (ctor && ctor.locals) { + if (getSymbol(ctor.locals, name, meaning & 107455)) { + propertyWithInvalidInitializer = location; + } + } + } + break; + case 214: + case 186: + case 215: + if (result = getSymbol(getSymbolOfNode(location).members, name, meaning & 793056)) { + if (lastLocation && lastLocation.flags & 128) { + error(errorLocation, ts.Diagnostics.Static_members_cannot_reference_class_type_parameters); + return undefined; + } + break loop; + } + if (location.kind === 186 && meaning & 32) { + var className = location.name; + if (className && name === className.text) { + result = location.symbol; + break loop; + } + } + break; + case 136: + grandparent = location.parent.parent; + if (ts.isClassLike(grandparent) || grandparent.kind === 215) { + if (result = getSymbol(getSymbolOfNode(grandparent).members, name, meaning & 793056)) { + error(errorLocation, ts.Diagnostics.A_computed_property_name_cannot_reference_a_type_parameter_from_its_containing_type); + return undefined; + } + } + break; + case 143: + case 142: + case 144: + case 145: + case 146: + case 213: + case 174: + if (meaning & 3 && name === "arguments") { + result = argumentsSymbol; + break loop; + } + break; + case 173: + if (meaning & 3 && name === "arguments") { + result = argumentsSymbol; + break loop; + } + if (meaning & 16) { + var functionName = location.name; + if (functionName && name === functionName.text) { + result = location.symbol; + break loop; + } + } + break; + case 139: + if (location.parent && location.parent.kind === 138) { + location = location.parent; + } + if (location.parent && ts.isClassElement(location.parent)) { + location = location.parent; + } + break; + } + lastLocation = location; + location = location.parent; + } + if (!result) { + result = getSymbol(globals, name, meaning); + } + if (!result) { + if (nameNotFoundMessage) { + error(errorLocation, nameNotFoundMessage, typeof nameArg === "string" ? nameArg : ts.declarationNameToString(nameArg)); + } + return undefined; + } + if (nameNotFoundMessage) { + if (propertyWithInvalidInitializer) { + var propertyName = propertyWithInvalidInitializer.name; + error(errorLocation, ts.Diagnostics.Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor, ts.declarationNameToString(propertyName), typeof nameArg === "string" ? nameArg : ts.declarationNameToString(nameArg)); + return undefined; + } + if (meaning & 2) { + var exportOrLocalSymbol = getExportSymbolOfValueSymbolIfExported(result); + if (exportOrLocalSymbol.flags & 2) { + checkResolvedBlockScopedVariable(exportOrLocalSymbol, errorLocation); + } + } + } + return result; + } + function checkResolvedBlockScopedVariable(result, errorLocation) { + 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 (!isBlockScopedNameDeclaredBeforeUse(ts.getAncestor(declaration, 211), errorLocation)) { + error(errorLocation, ts.Diagnostics.Block_scoped_variable_0_used_before_its_declaration, ts.declarationNameToString(declaration.name)); + } + } + function isSameScopeDescendentOf(initial, parent, stopAt) { + if (!parent) { + return false; + } + for (var current = initial; current && current !== stopAt && !ts.isFunctionLike(current); current = current.parent) { + if (current === parent) { + return true; + } + } + return false; + } + function getAnyImportSyntax(node) { + if (ts.isAliasSymbolDeclaration(node)) { + if (node.kind === 221) { + return node; + } + while (node && node.kind !== 222) { + node = node.parent; + } + return node; + } + } + function getDeclarationOfAliasSymbol(symbol) { + return ts.forEach(symbol.declarations, function (d) { return ts.isAliasSymbolDeclaration(d) ? d : undefined; }); + } + function getTargetOfImportEqualsDeclaration(node) { + if (node.moduleReference.kind === 232) { + return resolveExternalModuleSymbol(resolveExternalModuleName(node, ts.getExternalModuleImportEqualsDeclarationExpression(node))); + } + return getSymbolOfPartOfRightHandSideOfImportEquals(node.moduleReference, node); + } + function getTargetOfImportClause(node) { + var moduleSymbol = resolveExternalModuleName(node, node.parent.moduleSpecifier); + if (moduleSymbol) { + var exportDefaultSymbol = resolveSymbol(moduleSymbol.exports["default"]); + if (!exportDefaultSymbol) { + error(node.name, ts.Diagnostics.Module_0_has_no_default_export, symbolToString(moduleSymbol)); + } + return exportDefaultSymbol; + } + } + function getTargetOfNamespaceImport(node) { + var moduleSpecifier = node.parent.parent.moduleSpecifier; + return resolveESModuleSymbol(resolveExternalModuleName(node, moduleSpecifier), moduleSpecifier); + } + function getMemberOfModuleVariable(moduleSymbol, name) { + if (moduleSymbol.flags & 3) { + var typeAnnotation = moduleSymbol.valueDeclaration.type; + if (typeAnnotation) { + return getPropertyOfType(getTypeFromTypeNode(typeAnnotation), name); + } + } + } + function combineValueAndTypeSymbols(valueSymbol, typeSymbol) { + if (valueSymbol.flags & (793056 | 1536)) { + return valueSymbol; + } + var result = createSymbol(valueSymbol.flags | typeSymbol.flags, valueSymbol.name); + result.declarations = ts.concatenate(valueSymbol.declarations, typeSymbol.declarations); + result.parent = valueSymbol.parent || typeSymbol.parent; + if (valueSymbol.valueDeclaration) + result.valueDeclaration = valueSymbol.valueDeclaration; + if (typeSymbol.members) + result.members = typeSymbol.members; + if (valueSymbol.exports) + result.exports = valueSymbol.exports; + return result; + } + function getExportOfModule(symbol, name) { + if (symbol.flags & 1536) { + var exports_1 = getExportsOfSymbol(symbol); + if (ts.hasProperty(exports_1, name)) { + return resolveSymbol(exports_1[name]); + } + } + } + function getPropertyOfVariable(symbol, name) { + if (symbol.flags & 3) { + var typeAnnotation = symbol.valueDeclaration.type; + if (typeAnnotation) { + return resolveSymbol(getPropertyOfType(getTypeFromTypeNode(typeAnnotation), name)); + } + } + } + function getExternalModuleMember(node, specifier) { + var moduleSymbol = resolveExternalModuleName(node, node.moduleSpecifier); + var targetSymbol = resolveESModuleSymbol(moduleSymbol, node.moduleSpecifier); + if (targetSymbol) { + var name_10 = specifier.propertyName || specifier.name; + if (name_10.text) { + var symbolFromModule = getExportOfModule(targetSymbol, name_10.text); + var symbolFromVariable = getPropertyOfVariable(targetSymbol, name_10.text); + var symbol = symbolFromModule && symbolFromVariable ? + combineValueAndTypeSymbols(symbolFromVariable, symbolFromModule) : + symbolFromModule || symbolFromVariable; + if (!symbol) { + error(name_10, ts.Diagnostics.Module_0_has_no_exported_member_1, getFullyQualifiedName(moduleSymbol), ts.declarationNameToString(name_10)); + } + return symbol; + } + } + } + function getTargetOfImportSpecifier(node) { + return getExternalModuleMember(node.parent.parent.parent, node); + } + function getTargetOfExportSpecifier(node) { + return node.parent.parent.moduleSpecifier ? + getExternalModuleMember(node.parent.parent, node) : + resolveEntityName(node.propertyName || node.name, 107455 | 793056 | 1536); + } + function getTargetOfExportAssignment(node) { + return resolveEntityName(node.expression, 107455 | 793056 | 1536); + } + function getTargetOfAliasDeclaration(node) { + switch (node.kind) { + case 221: + return getTargetOfImportEqualsDeclaration(node); + case 223: + return getTargetOfImportClause(node); + case 224: + return getTargetOfNamespaceImport(node); + case 226: + return getTargetOfImportSpecifier(node); + case 230: + return getTargetOfExportSpecifier(node); + case 227: + return getTargetOfExportAssignment(node); + } + } + function resolveSymbol(symbol) { + return symbol && symbol.flags & 8388608 && !(symbol.flags & (107455 | 793056 | 1536)) ? resolveAlias(symbol) : symbol; + } + function resolveAlias(symbol) { + ts.Debug.assert((symbol.flags & 8388608) !== 0, "Should only get Alias here."); + var links = getSymbolLinks(symbol); + if (!links.target) { + links.target = resolvingSymbol; + var node = getDeclarationOfAliasSymbol(symbol); + var target = getTargetOfAliasDeclaration(node); + if (links.target === resolvingSymbol) { + links.target = target || unknownSymbol; + } + else { + error(node, ts.Diagnostics.Circular_definition_of_import_alias_0, symbolToString(symbol)); + } + } + else if (links.target === resolvingSymbol) { + links.target = unknownSymbol; + } + return links.target; + } + function markExportAsReferenced(node) { + var symbol = getSymbolOfNode(node); + var target = resolveAlias(symbol); + if (target) { + var markAlias = (target === unknownSymbol && compilerOptions.isolatedModules) || + (target !== unknownSymbol && (target.flags & 107455) && !isConstEnumOrConstEnumOnlyModule(target)); + if (markAlias) { + markAliasSymbolAsReferenced(symbol); + } + } + } + function markAliasSymbolAsReferenced(symbol) { + var links = getSymbolLinks(symbol); + if (!links.referenced) { + links.referenced = true; + var node = getDeclarationOfAliasSymbol(symbol); + if (node.kind === 227) { + checkExpressionCached(node.expression); + } + else if (node.kind === 230) { + checkExpressionCached(node.propertyName || node.name); + } + else if (ts.isInternalModuleImportEqualsDeclaration(node)) { + checkExpressionCached(node.moduleReference); + } + } + } + function getSymbolOfPartOfRightHandSideOfImportEquals(entityName, importDeclaration) { + if (!importDeclaration) { + importDeclaration = ts.getAncestor(entityName, 221); + ts.Debug.assert(importDeclaration !== undefined); + } + if (entityName.kind === 69 && ts.isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { + entityName = entityName.parent; + } + if (entityName.kind === 69 || entityName.parent.kind === 135) { + return resolveEntityName(entityName, 1536); + } + else { + ts.Debug.assert(entityName.parent.kind === 221); + return resolveEntityName(entityName, 107455 | 793056 | 1536); + } + } + function getFullyQualifiedName(symbol) { + return symbol.parent ? getFullyQualifiedName(symbol.parent) + "." + symbolToString(symbol) : symbolToString(symbol); + } + function resolveEntityName(name, meaning, ignoreErrors) { + if (ts.nodeIsMissing(name)) { + return undefined; + } + var symbol; + if (name.kind === 69) { + var message = meaning === 1536 ? ts.Diagnostics.Cannot_find_namespace_0 : ts.Diagnostics.Cannot_find_name_0; + symbol = resolveName(name, name.text, meaning, ignoreErrors ? undefined : message, name); + if (!symbol) { + return undefined; + } + } + else if (name.kind === 135 || name.kind === 166) { + var left = name.kind === 135 ? name.left : name.expression; + var right = name.kind === 135 ? name.right : name.name; + var namespace = resolveEntityName(left, 1536, ignoreErrors); + if (!namespace || namespace === unknownSymbol || ts.nodeIsMissing(right)) { + return undefined; + } + symbol = getSymbol(getExportsOfSymbol(namespace), right.text, meaning); + if (!symbol) { + if (!ignoreErrors) { + error(right, ts.Diagnostics.Module_0_has_no_exported_member_1, getFullyQualifiedName(namespace), ts.declarationNameToString(right)); + } + return undefined; + } + } + else { + ts.Debug.fail("Unknown entity name kind."); + } + ts.Debug.assert((symbol.flags & 16777216) === 0, "Should never get an instantiated symbol here."); + return symbol.flags & meaning ? symbol : resolveAlias(symbol); + } + function resolveExternalModuleName(location, moduleReferenceExpression) { + if (moduleReferenceExpression.kind !== 9) { + return; + } + var moduleReferenceLiteral = moduleReferenceExpression; + var searchPath = ts.getDirectoryPath(getSourceFile(location).fileName); + var moduleName = ts.escapeIdentifier(moduleReferenceLiteral.text); + if (moduleName === undefined) { + return; + } + var isRelative = ts.isExternalModuleNameRelative(moduleName); + if (!isRelative) { + var symbol = getSymbol(globals, "\"" + moduleName + "\"", 512); + if (symbol) { + return symbol; + } + } + var resolvedModule = ts.getResolvedModule(getSourceFile(location), moduleReferenceLiteral.text); + var sourceFile = resolvedModule && host.getSourceFile(resolvedModule.resolvedFileName); + if (sourceFile) { + if (sourceFile.symbol) { + return sourceFile.symbol; + } + error(moduleReferenceLiteral, ts.Diagnostics.File_0_is_not_a_module, sourceFile.fileName); + return; + } + error(moduleReferenceLiteral, ts.Diagnostics.Cannot_find_module_0, moduleName); + } + function resolveExternalModuleSymbol(moduleSymbol) { + return moduleSymbol && resolveSymbol(moduleSymbol.exports["export="]) || moduleSymbol; + } + function resolveESModuleSymbol(moduleSymbol, moduleReferenceExpression) { + var symbol = resolveExternalModuleSymbol(moduleSymbol); + if (symbol && !(symbol.flags & (1536 | 3))) { + error(moduleReferenceExpression, ts.Diagnostics.Module_0_resolves_to_a_non_module_entity_and_cannot_be_imported_using_this_construct, symbolToString(moduleSymbol)); + symbol = undefined; + } + return symbol; + } + function getExportAssignmentSymbol(moduleSymbol) { + return moduleSymbol.exports["export="]; + } + function getExportsOfModuleAsArray(moduleSymbol) { + return symbolsToArray(getExportsOfModule(moduleSymbol)); + } + function getExportsOfSymbol(symbol) { + return symbol.flags & 1536 ? getExportsOfModule(symbol) : symbol.exports || emptySymbols; + } + function getExportsOfModule(moduleSymbol) { + var links = getSymbolLinks(moduleSymbol); + return links.resolvedExports || (links.resolvedExports = getExportsForModule(moduleSymbol)); + } + function extendExportSymbols(target, source) { + for (var id in source) { + if (id !== "default" && !ts.hasProperty(target, id)) { + target[id] = source[id]; + } + } + } + function getExportsForModule(moduleSymbol) { + var result; + var visitedSymbols = []; + visit(moduleSymbol); + return result || moduleSymbol.exports; + function visit(symbol) { + if (symbol && symbol.flags & 1952 && !ts.contains(visitedSymbols, symbol)) { + visitedSymbols.push(symbol); + if (symbol !== moduleSymbol) { + if (!result) { + result = cloneSymbolTable(moduleSymbol.exports); + } + extendExportSymbols(result, symbol.exports); + } + var exportStars = symbol.exports["__export"]; + if (exportStars) { + for (var _i = 0, _a = exportStars.declarations; _i < _a.length; _i++) { + var node = _a[_i]; + visit(resolveExternalModuleName(node, node.moduleSpecifier)); + } + } + } + } + } + function getMergedSymbol(symbol) { + var merged; + return symbol && symbol.mergeId && (merged = mergedSymbols[symbol.mergeId]) ? merged : symbol; + } + function getSymbolOfNode(node) { + return getMergedSymbol(node.symbol); + } + function getParentOfSymbol(symbol) { + return getMergedSymbol(symbol.parent); + } + function getExportSymbolOfValueSymbolIfExported(symbol) { + return symbol && (symbol.flags & 1048576) !== 0 + ? getMergedSymbol(symbol.exportSymbol) + : symbol; + } + function symbolIsValue(symbol) { + if (symbol.flags & 16777216) { + return symbolIsValue(getSymbolLinks(symbol).target); + } + if (symbol.flags & 107455) { + return true; + } + if (symbol.flags & 8388608) { + return (resolveAlias(symbol).flags & 107455) !== 0; + } + return false; + } + function findConstructorDeclaration(node) { + var members = node.members; + for (var _i = 0; _i < members.length; _i++) { + var member = members[_i]; + if (member.kind === 144 && ts.nodeIsPresent(member.body)) { + return member; + } + } + } + function createType(flags) { + var result = new Type(checker, flags); + result.id = typeCount++; + return result; + } + function createIntrinsicType(kind, intrinsicName) { + var type = createType(kind); + type.intrinsicName = intrinsicName; + return type; + } + function createObjectType(kind, symbol) { + var type = createType(kind); + type.symbol = symbol; + return type; + } + function isReservedMemberName(name) { + return name.charCodeAt(0) === 95 && + name.charCodeAt(1) === 95 && + name.charCodeAt(2) !== 95 && + name.charCodeAt(2) !== 64; + } + function getNamedMembers(members) { + var result; + for (var id in members) { + if (ts.hasProperty(members, id)) { + if (!isReservedMemberName(id)) { + if (!result) + result = []; + var symbol = members[id]; + if (symbolIsValue(symbol)) { + result.push(symbol); + } + } + } + } + return result || emptyArray; + } + function setObjectTypeMembers(type, members, callSignatures, constructSignatures, stringIndexType, numberIndexType) { + type.members = members; + type.properties = getNamedMembers(members); + type.callSignatures = callSignatures; + type.constructSignatures = constructSignatures; + if (stringIndexType) + type.stringIndexType = stringIndexType; + if (numberIndexType) + type.numberIndexType = numberIndexType; + return type; + } + function createAnonymousType(symbol, members, callSignatures, constructSignatures, stringIndexType, numberIndexType) { + return setObjectTypeMembers(createObjectType(65536, symbol), members, callSignatures, constructSignatures, stringIndexType, numberIndexType); + } + function forEachSymbolTableInScope(enclosingDeclaration, callback) { + var result; + for (var location_1 = enclosingDeclaration; location_1; location_1 = location_1.parent) { + if (location_1.locals && !isGlobalSourceFile(location_1)) { + if (result = callback(location_1.locals)) { + return result; + } + } + switch (location_1.kind) { + case 248: + if (!ts.isExternalModule(location_1)) { + break; + } + case 218: + if (result = callback(getSymbolOfNode(location_1).exports)) { + return result; + } + break; + case 214: + case 215: + if (result = callback(getSymbolOfNode(location_1).members)) { + return result; + } + break; + } + } + return callback(globals); + } + function getQualifiedLeftMeaning(rightMeaning) { + return rightMeaning === 107455 ? 107455 : 1536; + } + function getAccessibleSymbolChain(symbol, enclosingDeclaration, meaning, useOnlyExternalAliasing) { + function getAccessibleSymbolChainFromSymbolTable(symbols) { + function canQualifySymbol(symbolFromSymbolTable, meaning) { + if (!needsQualification(symbolFromSymbolTable, enclosingDeclaration, meaning)) { + return true; + } + var accessibleParent = getAccessibleSymbolChain(symbolFromSymbolTable.parent, enclosingDeclaration, getQualifiedLeftMeaning(meaning), useOnlyExternalAliasing); + return !!accessibleParent; + } + function isAccessible(symbolFromSymbolTable, resolvedAliasSymbol) { + if (symbol === (resolvedAliasSymbol || symbolFromSymbolTable)) { + return !ts.forEach(symbolFromSymbolTable.declarations, hasExternalModuleSymbol) && + canQualifySymbol(symbolFromSymbolTable, meaning); + } + } + if (isAccessible(ts.lookUp(symbols, symbol.name))) { + return [symbol]; + } + return ts.forEachValue(symbols, function (symbolFromSymbolTable) { + if (symbolFromSymbolTable.flags & 8388608 + && symbolFromSymbolTable.name !== "export=" + && !ts.getDeclarationOfKind(symbolFromSymbolTable, 230)) { + if (!useOnlyExternalAliasing || + ts.forEach(symbolFromSymbolTable.declarations, ts.isExternalModuleImportEqualsDeclaration)) { + var resolvedImportedSymbol = resolveAlias(symbolFromSymbolTable); + if (isAccessible(symbolFromSymbolTable, resolveAlias(symbolFromSymbolTable))) { + return [symbolFromSymbolTable]; + } + var accessibleSymbolsFromExports = resolvedImportedSymbol.exports ? getAccessibleSymbolChainFromSymbolTable(resolvedImportedSymbol.exports) : undefined; + if (accessibleSymbolsFromExports && canQualifySymbol(symbolFromSymbolTable, getQualifiedLeftMeaning(meaning))) { + return [symbolFromSymbolTable].concat(accessibleSymbolsFromExports); + } + } + } + }); + } + if (symbol) { + return forEachSymbolTableInScope(enclosingDeclaration, getAccessibleSymbolChainFromSymbolTable); + } + } + function needsQualification(symbol, enclosingDeclaration, meaning) { + var qualify = false; + forEachSymbolTableInScope(enclosingDeclaration, function (symbolTable) { + if (!ts.hasProperty(symbolTable, symbol.name)) { + return false; + } + var symbolFromSymbolTable = symbolTable[symbol.name]; + if (symbolFromSymbolTable === symbol) { + return true; + } + symbolFromSymbolTable = (symbolFromSymbolTable.flags & 8388608 && !ts.getDeclarationOfKind(symbolFromSymbolTable, 230)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; + if (symbolFromSymbolTable.flags & meaning) { + qualify = true; + return true; + } + return false; + }); + return qualify; + } + function isSymbolAccessible(symbol, enclosingDeclaration, meaning) { + if (symbol && enclosingDeclaration && !(symbol.flags & 262144)) { + var initialSymbol = symbol; + var meaningToLook = meaning; + while (symbol) { + var accessibleSymbolChain = getAccessibleSymbolChain(symbol, enclosingDeclaration, meaningToLook, false); + if (accessibleSymbolChain) { + var hasAccessibleDeclarations = hasVisibleDeclarations(accessibleSymbolChain[0]); + if (!hasAccessibleDeclarations) { + return { + accessibility: 1, + errorSymbolName: symbolToString(initialSymbol, enclosingDeclaration, meaning), + errorModuleName: symbol !== initialSymbol ? symbolToString(symbol, enclosingDeclaration, 1536) : undefined + }; + } + return hasAccessibleDeclarations; + } + meaningToLook = getQualifiedLeftMeaning(meaning); + symbol = getParentOfSymbol(symbol); + } + var symbolExternalModule = ts.forEach(initialSymbol.declarations, getExternalModuleContainer); + if (symbolExternalModule) { + var enclosingExternalModule = getExternalModuleContainer(enclosingDeclaration); + if (symbolExternalModule !== enclosingExternalModule) { + return { + accessibility: 2, + errorSymbolName: symbolToString(initialSymbol, enclosingDeclaration, meaning), + errorModuleName: symbolToString(symbolExternalModule) + }; + } + } + return { + accessibility: 1, + errorSymbolName: symbolToString(initialSymbol, enclosingDeclaration, meaning) + }; + } + return { accessibility: 0 }; + function getExternalModuleContainer(declaration) { + for (; declaration; declaration = declaration.parent) { + if (hasExternalModuleSymbol(declaration)) { + return getSymbolOfNode(declaration); + } + } + } + } + function hasExternalModuleSymbol(declaration) { + return (declaration.kind === 218 && declaration.name.kind === 9) || + (declaration.kind === 248 && ts.isExternalModule(declaration)); + } + function hasVisibleDeclarations(symbol) { + var aliasesToMakeVisible; + if (ts.forEach(symbol.declarations, function (declaration) { return !getIsDeclarationVisible(declaration); })) { + return undefined; + } + return { accessibility: 0, aliasesToMakeVisible: aliasesToMakeVisible }; + function getIsDeclarationVisible(declaration) { + if (!isDeclarationVisible(declaration)) { + var anyImportSyntax = getAnyImportSyntax(declaration); + if (anyImportSyntax && + !(anyImportSyntax.flags & 1) && + isDeclarationVisible(anyImportSyntax.parent)) { + getNodeLinks(declaration).isVisible = true; + if (aliasesToMakeVisible) { + if (!ts.contains(aliasesToMakeVisible, anyImportSyntax)) { + aliasesToMakeVisible.push(anyImportSyntax); + } + } + else { + aliasesToMakeVisible = [anyImportSyntax]; + } + return true; + } + return false; + } + return true; + } + } + function isEntityNameVisible(entityName, enclosingDeclaration) { + var meaning; + if (entityName.parent.kind === 154) { + meaning = 107455 | 1048576; + } + else if (entityName.kind === 135 || entityName.kind === 166 || + entityName.parent.kind === 221) { + meaning = 1536; + } + else { + meaning = 793056; + } + var firstIdentifier = getFirstIdentifier(entityName); + var symbol = resolveName(enclosingDeclaration, firstIdentifier.text, meaning, undefined, undefined); + return (symbol && hasVisibleDeclarations(symbol)) || { + accessibility: 1, + errorSymbolName: ts.getTextOfNode(firstIdentifier), + errorNode: firstIdentifier + }; + } + function writeKeyword(writer, kind) { + writer.writeKeyword(ts.tokenToString(kind)); + } + function writePunctuation(writer, kind) { + writer.writePunctuation(ts.tokenToString(kind)); + } + function writeSpace(writer) { + writer.writeSpace(" "); + } + function symbolToString(symbol, enclosingDeclaration, meaning) { + var writer = ts.getSingleLineStringWriter(); + getSymbolDisplayBuilder().buildSymbolDisplay(symbol, writer, enclosingDeclaration, meaning); + var result = writer.string(); + ts.releaseStringWriter(writer); + return result; + } + function signatureToString(signature, enclosingDeclaration, flags) { + var writer = ts.getSingleLineStringWriter(); + getSymbolDisplayBuilder().buildSignatureDisplay(signature, writer, enclosingDeclaration, flags); + var result = writer.string(); + ts.releaseStringWriter(writer); + return result; + } + function typeToString(type, enclosingDeclaration, flags) { + var writer = ts.getSingleLineStringWriter(); + getSymbolDisplayBuilder().buildTypeDisplay(type, writer, enclosingDeclaration, flags); + var result = writer.string(); + ts.releaseStringWriter(writer); + var maxLength = compilerOptions.noErrorTruncation || flags & 4 ? undefined : 100; + if (maxLength && result.length >= maxLength) { + result = result.substr(0, maxLength - "...".length) + "..."; + } + return result; + } + function getTypeAliasForTypeLiteral(type) { + if (type.symbol && type.symbol.flags & 2048) { + var node = type.symbol.declarations[0].parent; + while (node.kind === 160) { + node = node.parent; + } + if (node.kind === 216) { + return getSymbolOfNode(node); + } + } + return undefined; + } + function getSymbolDisplayBuilder() { + function getNameOfSymbol(symbol) { + if (symbol.declarations && symbol.declarations.length) { + var declaration = symbol.declarations[0]; + if (declaration.name) { + return ts.declarationNameToString(declaration.name); + } + switch (declaration.kind) { + case 186: + return "(Anonymous class)"; + case 173: + case 174: + return "(Anonymous function)"; + } + } + return symbol.name; + } + function appendSymbolNameOnly(symbol, writer) { + writer.writeSymbol(getNameOfSymbol(symbol), symbol); + } + function buildSymbolDisplay(symbol, writer, enclosingDeclaration, meaning, flags, typeFlags) { + var parentSymbol; + function appendParentTypeArgumentsAndSymbolName(symbol) { + if (parentSymbol) { + if (flags & 1) { + if (symbol.flags & 16777216) { + buildDisplayForTypeArgumentsAndDelimiters(getTypeParametersOfClassOrInterface(parentSymbol), symbol.mapper, writer, enclosingDeclaration); + } + else { + buildTypeParameterDisplayFromSymbol(parentSymbol, writer, enclosingDeclaration); + } + } + writePunctuation(writer, 21); + } + parentSymbol = symbol; + appendSymbolNameOnly(symbol, writer); + } + writer.trackSymbol(symbol, enclosingDeclaration, meaning); + function walkSymbol(symbol, meaning) { + if (symbol) { + var accessibleSymbolChain = getAccessibleSymbolChain(symbol, enclosingDeclaration, meaning, !!(flags & 2)); + if (!accessibleSymbolChain || + needsQualification(accessibleSymbolChain[0], enclosingDeclaration, accessibleSymbolChain.length === 1 ? meaning : getQualifiedLeftMeaning(meaning))) { + walkSymbol(getParentOfSymbol(accessibleSymbolChain ? accessibleSymbolChain[0] : symbol), getQualifiedLeftMeaning(meaning)); + } + if (accessibleSymbolChain) { + for (var _i = 0; _i < accessibleSymbolChain.length; _i++) { + var accessibleSymbol = accessibleSymbolChain[_i]; + appendParentTypeArgumentsAndSymbolName(accessibleSymbol); + } + } + else { + if (!parentSymbol && ts.forEach(symbol.declarations, hasExternalModuleSymbol)) { + return; + } + if (symbol.flags & 2048 || symbol.flags & 4096) { + return; + } + appendParentTypeArgumentsAndSymbolName(symbol); + } + } + } + var isTypeParameter = symbol.flags & 262144; + var typeFormatFlag = 128 & typeFlags; + if (!isTypeParameter && (enclosingDeclaration || typeFormatFlag)) { + walkSymbol(symbol, meaning); + return; + } + return appendParentTypeArgumentsAndSymbolName(symbol); + } + function buildTypeDisplay(type, writer, enclosingDeclaration, globalFlags, symbolStack) { + var globalFlagsToPass = globalFlags & 16; + var inObjectTypeLiteral = false; + return writeType(type, globalFlags); + function writeType(type, flags) { + if (type.flags & 16777343) { + writer.writeKeyword(!(globalFlags & 16) && isTypeAny(type) + ? "any" + : type.intrinsicName); + } + else if (type.flags & 33554432) { + if (inObjectTypeLiteral) { + writer.reportInaccessibleThisError(); + } + writer.writeKeyword("this"); + } + else if (type.flags & 4096) { + writeTypeReference(type, flags); + } + else if (type.flags & (1024 | 2048 | 128 | 512)) { + buildSymbolDisplay(type.symbol, writer, enclosingDeclaration, 793056, 0, flags); + } + else if (type.flags & 8192) { + writeTupleType(type); + } + else if (type.flags & 49152) { + writeUnionOrIntersectionType(type, flags); + } + else if (type.flags & 65536) { + writeAnonymousType(type, flags); + } + else if (type.flags & 256) { + writer.writeStringLiteral(type.text); + } + else { + writePunctuation(writer, 15); + writeSpace(writer); + writePunctuation(writer, 22); + writeSpace(writer); + writePunctuation(writer, 16); + } + } + function writeTypeList(types, delimiter) { + for (var i = 0; i < types.length; i++) { + if (i > 0) { + if (delimiter !== 24) { + writeSpace(writer); + } + writePunctuation(writer, delimiter); + writeSpace(writer); + } + writeType(types[i], delimiter === 24 ? 0 : 64); + } + } + function writeSymbolTypeReference(symbol, typeArguments, pos, end, flags) { + if (symbol.flags & 32 || !isReservedMemberName(symbol.name)) { + buildSymbolDisplay(symbol, writer, enclosingDeclaration, 793056, 0, flags); + } + if (pos < end) { + writePunctuation(writer, 25); + writeType(typeArguments[pos++], 0); + while (pos < end) { + writePunctuation(writer, 24); + writeSpace(writer); + writeType(typeArguments[pos++], 0); + } + writePunctuation(writer, 27); + } + } + 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); + } + else { + var outerTypeParameters = type.target.outerTypeParameters; + var i = 0; + if (outerTypeParameters) { + var length_1 = outerTypeParameters.length; + while (i < length_1) { + var start = i; + var parent_3 = getParentSymbolOfTypeParameter(outerTypeParameters[i]); + do { + i++; + } while (i < length_1 && getParentSymbolOfTypeParameter(outerTypeParameters[i]) === parent_3); + if (!ts.rangeEquals(outerTypeParameters, typeArguments, start, i)) { + writeSymbolTypeReference(parent_3, typeArguments, start, i, flags); + writePunctuation(writer, 21); + } + } + } + var typeParameterCount = (type.target.typeParameters || emptyArray).length; + writeSymbolTypeReference(type.symbol, typeArguments, i, typeParameterCount, flags); + } + } + function writeTupleType(type) { + writePunctuation(writer, 19); + writeTypeList(type.elementTypes, 24); + writePunctuation(writer, 20); + } + function writeUnionOrIntersectionType(type, flags) { + if (flags & 64) { + writePunctuation(writer, 17); + } + writeTypeList(type.types, type.flags & 16384 ? 47 : 46); + if (flags & 64) { + writePunctuation(writer, 18); + } + } + function writeAnonymousType(type, flags) { + var symbol = type.symbol; + if (symbol) { + if (symbol.flags & (32 | 384 | 512)) { + writeTypeofSymbol(type, flags); + } + else if (shouldWriteTypeOfFunctionSymbol()) { + writeTypeofSymbol(type, flags); + } + else if (ts.contains(symbolStack, symbol)) { + var typeAlias = getTypeAliasForTypeLiteral(type); + if (typeAlias) { + buildSymbolDisplay(typeAlias, writer, enclosingDeclaration, 793056, 0, flags); + } + else { + writeKeyword(writer, 117); + } + } + else { + if (!symbolStack) { + symbolStack = []; + } + symbolStack.push(symbol); + writeLiteralType(type, flags); + symbolStack.pop(); + } + } + else { + writeLiteralType(type, flags); + } + function shouldWriteTypeOfFunctionSymbol() { + var isStaticMethodSymbol = !!(symbol.flags & 8192 && + ts.forEach(symbol.declarations, function (declaration) { return declaration.flags & 128; })); + var isNonLocalFunctionSymbol = !!(symbol.flags & 16) && + (symbol.parent || + ts.forEach(symbol.declarations, function (declaration) { + return declaration.parent.kind === 248 || declaration.parent.kind === 219; + })); + if (isStaticMethodSymbol || isNonLocalFunctionSymbol) { + return !!(flags & 2) || + (ts.contains(symbolStack, symbol)); + } + } + } + function writeTypeofSymbol(type, typeFormatFlags) { + writeKeyword(writer, 101); + writeSpace(writer); + buildSymbolDisplay(type.symbol, writer, enclosingDeclaration, 107455, 0, typeFormatFlags); + } + function getIndexerParameterName(type, indexKind, fallbackName) { + var declaration = getIndexDeclarationOfSymbol(type.symbol, indexKind); + if (!declaration) { + return fallbackName; + } + ts.Debug.assert(declaration.parameters.length !== 0); + return ts.declarationNameToString(declaration.parameters[0].name); + } + function writeLiteralType(type, flags) { + var resolved = resolveStructuredTypeMembers(type); + if (!resolved.properties.length && !resolved.stringIndexType && !resolved.numberIndexType) { + if (!resolved.callSignatures.length && !resolved.constructSignatures.length) { + writePunctuation(writer, 15); + writePunctuation(writer, 16); + return; + } + if (resolved.callSignatures.length === 1 && !resolved.constructSignatures.length) { + if (flags & 64) { + writePunctuation(writer, 17); + } + buildSignatureDisplay(resolved.callSignatures[0], writer, enclosingDeclaration, globalFlagsToPass | 8, symbolStack); + if (flags & 64) { + writePunctuation(writer, 18); + } + return; + } + if (resolved.constructSignatures.length === 1 && !resolved.callSignatures.length) { + if (flags & 64) { + writePunctuation(writer, 17); + } + writeKeyword(writer, 92); + writeSpace(writer); + buildSignatureDisplay(resolved.constructSignatures[0], writer, enclosingDeclaration, globalFlagsToPass | 8, symbolStack); + if (flags & 64) { + writePunctuation(writer, 18); + } + return; + } + } + var saveInObjectTypeLiteral = inObjectTypeLiteral; + inObjectTypeLiteral = true; + writePunctuation(writer, 15); + writer.writeLine(); + writer.increaseIndent(); + for (var _i = 0, _a = resolved.callSignatures; _i < _a.length; _i++) { + var signature = _a[_i]; + buildSignatureDisplay(signature, writer, enclosingDeclaration, globalFlagsToPass, symbolStack); + writePunctuation(writer, 23); + writer.writeLine(); + } + for (var _b = 0, _c = resolved.constructSignatures; _b < _c.length; _b++) { + var signature = _c[_b]; + writeKeyword(writer, 92); + writeSpace(writer); + buildSignatureDisplay(signature, writer, enclosingDeclaration, globalFlagsToPass, symbolStack); + writePunctuation(writer, 23); + writer.writeLine(); + } + if (resolved.stringIndexType) { + writePunctuation(writer, 19); + writer.writeParameter(getIndexerParameterName(resolved, 0, "x")); + writePunctuation(writer, 54); + writeSpace(writer); + writeKeyword(writer, 130); + writePunctuation(writer, 20); + writePunctuation(writer, 54); + writeSpace(writer); + writeType(resolved.stringIndexType, 0); + writePunctuation(writer, 23); + writer.writeLine(); + } + if (resolved.numberIndexType) { + writePunctuation(writer, 19); + writer.writeParameter(getIndexerParameterName(resolved, 1, "x")); + writePunctuation(writer, 54); + writeSpace(writer); + writeKeyword(writer, 128); + writePunctuation(writer, 20); + writePunctuation(writer, 54); + writeSpace(writer); + writeType(resolved.numberIndexType, 0); + writePunctuation(writer, 23); + writer.writeLine(); + } + for (var _d = 0, _e = resolved.properties; _d < _e.length; _d++) { + var p = _e[_d]; + var t = getTypeOfSymbol(p); + if (p.flags & (16 | 8192) && !getPropertiesOfObjectType(t).length) { + var signatures = getSignaturesOfType(t, 0); + for (var _f = 0; _f < signatures.length; _f++) { + var signature = signatures[_f]; + buildSymbolDisplay(p, writer); + if (p.flags & 536870912) { + writePunctuation(writer, 53); + } + buildSignatureDisplay(signature, writer, enclosingDeclaration, globalFlagsToPass, symbolStack); + writePunctuation(writer, 23); + writer.writeLine(); + } + } + else { + buildSymbolDisplay(p, writer); + if (p.flags & 536870912) { + writePunctuation(writer, 53); + } + writePunctuation(writer, 54); + writeSpace(writer); + writeType(t, 0); + writePunctuation(writer, 23); + writer.writeLine(); + } + } + writer.decreaseIndent(); + writePunctuation(writer, 16); + inObjectTypeLiteral = saveInObjectTypeLiteral; + } + } + function buildTypeParameterDisplayFromSymbol(symbol, writer, enclosingDeclaraiton, flags) { + var targetSymbol = getTargetSymbol(symbol); + if (targetSymbol.flags & 32 || targetSymbol.flags & 64 || targetSymbol.flags & 524288) { + buildDisplayForTypeParametersAndDelimiters(getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol), writer, enclosingDeclaraiton, flags); + } + } + function buildTypeParameterDisplay(tp, writer, enclosingDeclaration, flags, symbolStack) { + appendSymbolNameOnly(tp.symbol, writer); + var constraint = getConstraintOfTypeParameter(tp); + if (constraint) { + writeSpace(writer); + writeKeyword(writer, 83); + writeSpace(writer); + buildTypeDisplay(constraint, writer, enclosingDeclaration, flags, symbolStack); + } + } + function buildParameterDisplay(p, writer, enclosingDeclaration, flags, symbolStack) { + var parameterNode = p.valueDeclaration; + if (ts.isRestParameter(parameterNode)) { + writePunctuation(writer, 22); + } + appendSymbolNameOnly(p, writer); + if (isOptionalParameter(parameterNode)) { + writePunctuation(writer, 53); + } + writePunctuation(writer, 54); + writeSpace(writer); + buildTypeDisplay(getTypeOfSymbol(p), writer, enclosingDeclaration, flags, symbolStack); + } + function buildDisplayForTypeParametersAndDelimiters(typeParameters, writer, enclosingDeclaration, flags, symbolStack) { + if (typeParameters && typeParameters.length) { + writePunctuation(writer, 25); + for (var i = 0; i < typeParameters.length; i++) { + if (i > 0) { + writePunctuation(writer, 24); + writeSpace(writer); + } + buildTypeParameterDisplay(typeParameters[i], writer, enclosingDeclaration, flags, symbolStack); + } + writePunctuation(writer, 27); + } + } + function buildDisplayForTypeArgumentsAndDelimiters(typeParameters, mapper, writer, enclosingDeclaration, flags, symbolStack) { + if (typeParameters && typeParameters.length) { + writePunctuation(writer, 25); + for (var i = 0; i < typeParameters.length; i++) { + if (i > 0) { + writePunctuation(writer, 24); + writeSpace(writer); + } + buildTypeDisplay(mapper(typeParameters[i]), writer, enclosingDeclaration, 0); + } + writePunctuation(writer, 27); + } + } + function buildDisplayForParametersAndDelimiters(parameters, writer, enclosingDeclaration, flags, symbolStack) { + writePunctuation(writer, 17); + for (var i = 0; i < parameters.length; i++) { + if (i > 0) { + writePunctuation(writer, 24); + writeSpace(writer); + } + buildParameterDisplay(parameters[i], writer, enclosingDeclaration, flags, symbolStack); + } + writePunctuation(writer, 18); + } + function buildReturnTypeDisplay(signature, writer, enclosingDeclaration, flags, symbolStack) { + if (flags & 8) { + writeSpace(writer); + writePunctuation(writer, 34); + } + else { + writePunctuation(writer, 54); + } + writeSpace(writer); + var returnType; + if (signature.typePredicate) { + writer.writeParameter(signature.typePredicate.parameterName); + writeSpace(writer); + writeKeyword(writer, 124); + writeSpace(writer); + returnType = signature.typePredicate.type; + } + else { + returnType = getReturnTypeOfSignature(signature); + } + buildTypeDisplay(returnType, writer, enclosingDeclaration, flags, symbolStack); + } + function buildSignatureDisplay(signature, writer, enclosingDeclaration, flags, symbolStack) { + if (signature.target && (flags & 32)) { + buildDisplayForTypeArgumentsAndDelimiters(signature.target.typeParameters, signature.mapper, writer, enclosingDeclaration); + } + else { + buildDisplayForTypeParametersAndDelimiters(signature.typeParameters, writer, enclosingDeclaration, flags, symbolStack); + } + buildDisplayForParametersAndDelimiters(signature.parameters, writer, enclosingDeclaration, flags, symbolStack); + buildReturnTypeDisplay(signature, writer, enclosingDeclaration, flags, symbolStack); + } + return _displayBuilder || (_displayBuilder = { + buildSymbolDisplay: buildSymbolDisplay, + buildTypeDisplay: buildTypeDisplay, + buildTypeParameterDisplay: buildTypeParameterDisplay, + buildParameterDisplay: buildParameterDisplay, + buildDisplayForParametersAndDelimiters: buildDisplayForParametersAndDelimiters, + buildDisplayForTypeParametersAndDelimiters: buildDisplayForTypeParametersAndDelimiters, + buildTypeParameterDisplayFromSymbol: buildTypeParameterDisplayFromSymbol, + buildSignatureDisplay: buildSignatureDisplay, + buildReturnTypeDisplay: buildReturnTypeDisplay + }); + } + function isDeclarationVisible(node) { + function getContainingExternalModule(node) { + for (; node; node = node.parent) { + if (node.kind === 218) { + if (node.name.kind === 9) { + return node; + } + } + else if (node.kind === 248) { + return ts.isExternalModule(node) ? node : undefined; + } + } + ts.Debug.fail("getContainingModule cant reach here"); + } + function isUsedInExportAssignment(node) { + var externalModule = getContainingExternalModule(node); + var exportAssignmentSymbol; + var resolvedExportSymbol; + if (externalModule) { + var externalModuleSymbol = getSymbolOfNode(externalModule); + exportAssignmentSymbol = getExportAssignmentSymbol(externalModuleSymbol); + var symbolOfNode = getSymbolOfNode(node); + if (isSymbolUsedInExportAssignment(symbolOfNode)) { + return true; + } + if (symbolOfNode.flags & 8388608) { + return isSymbolUsedInExportAssignment(resolveAlias(symbolOfNode)); + } + } + function isSymbolUsedInExportAssignment(symbol) { + if (exportAssignmentSymbol === symbol) { + return true; + } + if (exportAssignmentSymbol && !!(exportAssignmentSymbol.flags & 8388608)) { + resolvedExportSymbol = resolvedExportSymbol || resolveAlias(exportAssignmentSymbol); + if (resolvedExportSymbol === symbol) { + return true; + } + return ts.forEach(resolvedExportSymbol.declarations, function (current) { + while (current) { + if (current === node) { + return true; + } + current = current.parent; + } + }); + } + } + } + function determineIfDeclarationIsVisible() { + switch (node.kind) { + case 163: + return isDeclarationVisible(node.parent.parent); + case 211: + if (ts.isBindingPattern(node.name) && + !node.name.elements.length) { + return false; + } + case 218: + case 214: + case 215: + case 216: + case 213: + case 217: + case 221: + var parent_4 = getDeclarationContainer(node); + if (!(ts.getCombinedNodeFlags(node) & 1) && + !(node.kind !== 221 && parent_4.kind !== 248 && ts.isInAmbientContext(parent_4))) { + return isGlobalSourceFile(parent_4); + } + return isDeclarationVisible(parent_4); + case 141: + case 140: + case 145: + case 146: + case 143: + case 142: + if (node.flags & (32 | 64)) { + return false; + } + case 144: + case 148: + case 147: + case 149: + case 138: + case 219: + case 152: + case 153: + case 155: + case 151: + case 156: + case 157: + case 158: + case 159: + case 160: + return isDeclarationVisible(node.parent); + case 223: + case 224: + case 226: + return false; + case 137: + case 248: + return true; + case 227: + return false; + default: + ts.Debug.fail("isDeclarationVisible unknown: SyntaxKind: " + node.kind); + } + } + if (node) { + var links = getNodeLinks(node); + if (links.isVisible === undefined) { + links.isVisible = !!determineIfDeclarationIsVisible(); + } + return links.isVisible; + } + } + function collectLinkedAliases(node) { + var exportSymbol; + if (node.parent && node.parent.kind === 227) { + exportSymbol = resolveName(node.parent, node.text, 107455 | 793056 | 1536 | 8388608, ts.Diagnostics.Cannot_find_name_0, node); + } + else if (node.parent.kind === 230) { + var exportSpecifier = node.parent; + exportSymbol = exportSpecifier.parent.parent.moduleSpecifier ? + getExternalModuleMember(exportSpecifier.parent.parent, exportSpecifier) : + resolveEntityName(exportSpecifier.propertyName || exportSpecifier.name, 107455 | 793056 | 1536 | 8388608); + } + var result = []; + if (exportSymbol) { + buildVisibleNodeList(exportSymbol.declarations); + } + return result; + function buildVisibleNodeList(declarations) { + ts.forEach(declarations, function (declaration) { + getNodeLinks(declaration).isVisible = true; + var resultNode = getAnyImportSyntax(declaration) || declaration; + if (!ts.contains(result, resultNode)) { + result.push(resultNode); + } + if (ts.isInternalModuleImportEqualsDeclaration(declaration)) { + var internalModuleReference = declaration.moduleReference; + var firstIdentifier = getFirstIdentifier(internalModuleReference); + var importSymbol = resolveName(declaration, firstIdentifier.text, 107455 | 793056 | 1536, ts.Diagnostics.Cannot_find_name_0, firstIdentifier); + buildVisibleNodeList(importSymbol.declarations); + } + }); + } + } + function pushTypeResolution(target, propertyName) { + var resolutionCycleStartIndex = findResolutionCycleStartIndex(target, propertyName); + if (resolutionCycleStartIndex >= 0) { + var length_2 = resolutionTargets.length; + for (var i = resolutionCycleStartIndex; i < length_2; i++) { + resolutionResults[i] = false; + } + return false; + } + resolutionTargets.push(target); + resolutionResults.push(true); + resolutionPropertyNames.push(propertyName); + return true; + } + function findResolutionCycleStartIndex(target, propertyName) { + for (var i = resolutionTargets.length - 1; i >= 0; i--) { + if (hasType(resolutionTargets[i], resolutionPropertyNames[i])) { + return -1; + } + if (resolutionTargets[i] === target && resolutionPropertyNames[i] === propertyName) { + return i; + } + } + return -1; + } + function hasType(target, propertyName) { + if (propertyName === 0) { + return getSymbolLinks(target).type; + } + if (propertyName === 2) { + return getSymbolLinks(target).declaredType; + } + if (propertyName === 1) { + ts.Debug.assert(!!(target.flags & 1024)); + return target.resolvedBaseConstructorType; + } + if (propertyName === 3) { + return target.resolvedReturnType; + } + ts.Debug.fail("Unhandled TypeSystemPropertyName " + propertyName); + } + function popTypeResolution() { + resolutionTargets.pop(); + resolutionPropertyNames.pop(); + return resolutionResults.pop(); + } + function getDeclarationContainer(node) { + node = ts.getRootDeclaration(node); + return node.kind === 211 ? node.parent.parent.parent : node.parent; + } + function getTypeOfPrototypeProperty(prototype) { + var classType = getDeclaredTypeOfSymbol(prototype.parent); + return classType.typeParameters ? createTypeReference(classType, ts.map(classType.typeParameters, function (_) { return anyType; })) : classType; + } + function getTypeOfPropertyOfType(type, name) { + var prop = getPropertyOfType(type, name); + return prop ? getTypeOfSymbol(prop) : undefined; + } + function isTypeAny(type) { + return type && (type.flags & 1) !== 0; + } + function getTypeForBindingElementParent(node) { + var symbol = getSymbolOfNode(node); + return symbol && getSymbolLinks(symbol).type || getTypeForVariableLikeDeclaration(node); + } + function getTypeForBindingElement(declaration) { + var pattern = declaration.parent; + var parentType = getTypeForBindingElementParent(pattern.parent); + if (parentType === unknownType) { + return unknownType; + } + if (!parentType || isTypeAny(parentType)) { + if (declaration.initializer) { + return checkExpressionCached(declaration.initializer); + } + return parentType; + } + var type; + if (pattern.kind === 161) { + var name_11 = declaration.propertyName || declaration.name; + type = getTypeOfPropertyOfType(parentType, name_11.text) || + isNumericLiteralName(name_11.text) && getIndexTypeOfType(parentType, 1) || + getIndexTypeOfType(parentType, 0); + if (!type) { + error(name_11, ts.Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(parentType), ts.declarationNameToString(name_11)); + return unknownType; + } + } + else { + var elementType = checkIteratedTypeOrElementType(parentType, pattern, false); + if (!declaration.dotDotDotToken) { + var propName = "" + ts.indexOf(pattern.elements, declaration); + type = isTupleLikeType(parentType) + ? getTypeOfPropertyOfType(parentType, propName) + : elementType; + if (!type) { + if (isTupleType(parentType)) { + error(declaration, ts.Diagnostics.Tuple_type_0_with_length_1_cannot_be_assigned_to_tuple_with_length_2, typeToString(parentType), parentType.elementTypes.length, pattern.elements.length); + } + else { + error(declaration, ts.Diagnostics.Type_0_has_no_property_1, typeToString(parentType), propName); + } + return unknownType; + } + } + else { + type = createArrayType(elementType); + } + } + return type; + } + function getTypeForVariableLikeDeclaration(declaration) { + if (declaration.parent.parent.kind === 200) { + return anyType; + } + if (declaration.parent.parent.kind === 201) { + return checkRightHandSideOfForOf(declaration.parent.parent.expression) || anyType; + } + if (ts.isBindingPattern(declaration.parent)) { + return getTypeForBindingElement(declaration); + } + if (declaration.type) { + return getTypeFromTypeNode(declaration.type); + } + if (declaration.kind === 138) { + var func = declaration.parent; + if (func.kind === 146 && !ts.hasDynamicName(func)) { + var getter = ts.getDeclarationOfKind(declaration.parent.symbol, 145); + if (getter) { + return getReturnTypeOfSignature(getSignatureFromDeclaration(getter)); + } + } + var type = getContextuallyTypedParameterType(declaration); + if (type) { + return type; + } + } + if (declaration.initializer) { + return checkExpressionCached(declaration.initializer); + } + if (declaration.kind === 246) { + return checkIdentifier(declaration.name); + } + if (ts.isBindingPattern(declaration.name)) { + return getTypeFromBindingPattern(declaration.name, false); + } + return undefined; + } + function getTypeFromBindingElement(element, includePatternInType) { + if (element.initializer) { + return getWidenedType(checkExpressionCached(element.initializer)); + } + if (ts.isBindingPattern(element.name)) { + return getTypeFromBindingPattern(element.name, includePatternInType); + } + return anyType; + } + function getTypeFromObjectBindingPattern(pattern, includePatternInType) { + var members = {}; + ts.forEach(pattern.elements, function (e) { + var flags = 4 | 67108864 | (e.initializer ? 536870912 : 0); + var name = e.propertyName || e.name; + var symbol = createSymbol(flags, name.text); + symbol.type = getTypeFromBindingElement(e, includePatternInType); + symbol.bindingElement = e; + members[symbol.name] = symbol; + }); + var result = createAnonymousType(undefined, members, emptyArray, emptyArray, undefined, undefined); + if (includePatternInType) { + result.pattern = pattern; + } + return result; + } + function getTypeFromArrayBindingPattern(pattern, includePatternInType) { + var elements = pattern.elements; + if (elements.length === 0 || elements[elements.length - 1].dotDotDotToken) { + return languageVersion >= 2 ? createIterableType(anyType) : anyArrayType; + } + var elementTypes = ts.map(elements, function (e) { return e.kind === 187 ? anyType : getTypeFromBindingElement(e, includePatternInType); }); + if (includePatternInType) { + var result = createNewTupleType(elementTypes); + result.pattern = pattern; + return result; + } + return createTupleType(elementTypes); + } + function getTypeFromBindingPattern(pattern, includePatternInType) { + return pattern.kind === 161 + ? getTypeFromObjectBindingPattern(pattern, includePatternInType) + : getTypeFromArrayBindingPattern(pattern, includePatternInType); + } + function getWidenedTypeForVariableLikeDeclaration(declaration, reportErrors) { + var type = getTypeForVariableLikeDeclaration(declaration); + if (type) { + if (reportErrors) { + reportErrorsFromWidening(declaration, type); + } + return declaration.kind !== 245 ? getWidenedType(type) : type; + } + type = declaration.dotDotDotToken ? anyArrayType : anyType; + if (reportErrors && compilerOptions.noImplicitAny) { + var root = ts.getRootDeclaration(declaration); + if (!isPrivateWithinAmbient(root) && !(root.kind === 138 && isPrivateWithinAmbient(root.parent))) { + reportImplicitAnyError(declaration, type); + } + } + return type; + } + function getTypeOfVariableOrParameterOrProperty(symbol) { + var links = getSymbolLinks(symbol); + if (!links.type) { + if (symbol.flags & 134217728) { + return links.type = getTypeOfPrototypeProperty(symbol); + } + var declaration = symbol.valueDeclaration; + if (declaration.parent.kind === 244) { + return links.type = anyType; + } + if (declaration.kind === 227) { + return links.type = checkExpression(declaration.expression); + } + if (!pushTypeResolution(symbol, 0)) { + return unknownType; + } + var type = getWidenedTypeForVariableLikeDeclaration(declaration, true); + if (!popTypeResolution()) { + if (symbol.valueDeclaration.type) { + type = unknownType; + error(symbol.valueDeclaration, ts.Diagnostics._0_is_referenced_directly_or_indirectly_in_its_own_type_annotation, symbolToString(symbol)); + } + else { + type = anyType; + if (compilerOptions.noImplicitAny) { + error(symbol.valueDeclaration, ts.Diagnostics._0_implicitly_has_type_any_because_it_does_not_have_a_type_annotation_and_is_referenced_directly_or_indirectly_in_its_own_initializer, symbolToString(symbol)); + } + } + } + links.type = type; + } + return links.type; + } + function getAnnotatedAccessorType(accessor) { + if (accessor) { + if (accessor.kind === 145) { + return accessor.type && getTypeFromTypeNode(accessor.type); + } + else { + var setterTypeAnnotation = ts.getSetAccessorTypeAnnotationNode(accessor); + return setterTypeAnnotation && getTypeFromTypeNode(setterTypeAnnotation); + } + } + return undefined; + } + function getTypeOfAccessors(symbol) { + var links = getSymbolLinks(symbol); + if (!links.type) { + if (!pushTypeResolution(symbol, 0)) { + return unknownType; + } + var getter = ts.getDeclarationOfKind(symbol, 145); + var setter = ts.getDeclarationOfKind(symbol, 146); + var type; + var getterReturnType = getAnnotatedAccessorType(getter); + if (getterReturnType) { + type = getterReturnType; + } + else { + var setterParameterType = getAnnotatedAccessorType(setter); + if (setterParameterType) { + type = setterParameterType; + } + else { + if (getter && getter.body) { + type = getReturnTypeFromBody(getter); + } + else { + if (compilerOptions.noImplicitAny) { + error(setter, ts.Diagnostics.Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_type_annotation, symbolToString(symbol)); + } + type = anyType; + } + } + } + if (!popTypeResolution()) { + type = anyType; + if (compilerOptions.noImplicitAny) { + var getter_1 = ts.getDeclarationOfKind(symbol, 145); + error(getter_1, ts.Diagnostics._0_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions, symbolToString(symbol)); + } + } + links.type = type; + } + return links.type; + } + function getTypeOfFuncClassEnumModule(symbol) { + var links = getSymbolLinks(symbol); + if (!links.type) { + links.type = createObjectType(65536, symbol); + } + return links.type; + } + function getTypeOfEnumMember(symbol) { + var links = getSymbolLinks(symbol); + if (!links.type) { + links.type = getDeclaredTypeOfEnum(getParentOfSymbol(symbol)); + } + return links.type; + } + function getTypeOfAlias(symbol) { + var links = getSymbolLinks(symbol); + if (!links.type) { + var targetSymbol = resolveAlias(symbol); + links.type = targetSymbol.flags & 107455 + ? getTypeOfSymbol(targetSymbol) + : unknownType; + } + return links.type; + } + function getTypeOfInstantiatedSymbol(symbol) { + var links = getSymbolLinks(symbol); + if (!links.type) { + links.type = instantiateType(getTypeOfSymbol(links.target), links.mapper); + } + return links.type; + } + function getTypeOfSymbol(symbol) { + if (symbol.flags & 16777216) { + return getTypeOfInstantiatedSymbol(symbol); + } + if (symbol.flags & (3 | 4)) { + return getTypeOfVariableOrParameterOrProperty(symbol); + } + if (symbol.flags & (16 | 8192 | 32 | 384 | 512)) { + return getTypeOfFuncClassEnumModule(symbol); + } + if (symbol.flags & 8) { + return getTypeOfEnumMember(symbol); + } + if (symbol.flags & 98304) { + return getTypeOfAccessors(symbol); + } + if (symbol.flags & 8388608) { + return getTypeOfAlias(symbol); + } + return unknownType; + } + function getTargetType(type) { + return type.flags & 4096 ? type.target : type; + } + function hasBaseType(type, checkBase) { + return check(type); + function check(type) { + var target = getTargetType(type); + return target === checkBase || ts.forEach(getBaseTypes(target), check); + } + } + function appendTypeParameters(typeParameters, declarations) { + for (var _i = 0; _i < declarations.length; _i++) { + var declaration = declarations[_i]; + var tp = getDeclaredTypeOfTypeParameter(getSymbolOfNode(declaration)); + if (!typeParameters) { + typeParameters = [tp]; + } + else if (!ts.contains(typeParameters, tp)) { + typeParameters.push(tp); + } + } + return typeParameters; + } + function appendOuterTypeParameters(typeParameters, node) { + while (true) { + node = node.parent; + if (!node) { + return typeParameters; + } + if (node.kind === 214 || node.kind === 186 || + node.kind === 213 || node.kind === 173 || + node.kind === 143 || node.kind === 174) { + var declarations = node.typeParameters; + if (declarations) { + return appendTypeParameters(appendOuterTypeParameters(typeParameters, node), declarations); + } + } + } + } + function getOuterTypeParametersOfClassOrInterface(symbol) { + var declaration = symbol.flags & 32 ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 215); + return appendOuterTypeParameters(undefined, declaration); + } + function getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol) { + var result; + for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { + var node = _a[_i]; + if (node.kind === 215 || node.kind === 214 || + node.kind === 186 || node.kind === 216) { + var declaration = node; + if (declaration.typeParameters) { + result = appendTypeParameters(result, declaration.typeParameters); + } + } + } + return result; + } + function getTypeParametersOfClassOrInterface(symbol) { + return ts.concatenate(getOuterTypeParametersOfClassOrInterface(symbol), getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol)); + } + function isConstructorType(type) { + return type.flags & 80896 && getSignaturesOfType(type, 1).length > 0; + } + function getBaseTypeNodeOfClass(type) { + return ts.getClassExtendsHeritageClauseElement(type.symbol.valueDeclaration); + } + function getConstructorsForTypeArguments(type, typeArgumentNodes) { + var typeArgCount = typeArgumentNodes ? typeArgumentNodes.length : 0; + return ts.filter(getSignaturesOfType(type, 1), function (sig) { return (sig.typeParameters ? sig.typeParameters.length : 0) === typeArgCount; }); + } + function getInstantiatedConstructorsForTypeArguments(type, typeArgumentNodes) { + var signatures = getConstructorsForTypeArguments(type, typeArgumentNodes); + if (typeArgumentNodes) { + var typeArguments = ts.map(typeArgumentNodes, getTypeFromTypeNode); + signatures = ts.map(signatures, function (sig) { return getSignatureInstantiation(sig, typeArguments); }); + } + return signatures; + } + function getBaseConstructorTypeOfClass(type) { + if (!type.resolvedBaseConstructorType) { + var baseTypeNode = getBaseTypeNodeOfClass(type); + if (!baseTypeNode) { + return type.resolvedBaseConstructorType = undefinedType; + } + if (!pushTypeResolution(type, 1)) { + return unknownType; + } + var baseConstructorType = checkExpression(baseTypeNode.expression); + if (baseConstructorType.flags & 80896) { + resolveStructuredTypeMembers(baseConstructorType); + } + if (!popTypeResolution()) { + error(type.symbol.valueDeclaration, ts.Diagnostics._0_is_referenced_directly_or_indirectly_in_its_own_base_expression, symbolToString(type.symbol)); + return type.resolvedBaseConstructorType = unknownType; + } + if (baseConstructorType !== unknownType && baseConstructorType !== nullType && !isConstructorType(baseConstructorType)) { + error(baseTypeNode.expression, ts.Diagnostics.Type_0_is_not_a_constructor_function_type, typeToString(baseConstructorType)); + return type.resolvedBaseConstructorType = unknownType; + } + type.resolvedBaseConstructorType = baseConstructorType; + } + return type.resolvedBaseConstructorType; + } + function hasClassBaseType(type) { + return !!ts.forEach(getBaseTypes(type), function (t) { return !!(t.symbol.flags & 32); }); + } + function getBaseTypes(type) { + var isClass = type.symbol.flags & 32; + var isInterface = type.symbol.flags & 64; + if (!type.resolvedBaseTypes) { + if (!isClass && !isInterface) { + ts.Debug.fail("type must be class or interface"); + } + if (isClass) { + resolveBaseTypesOfClass(type); + } + if (isInterface) { + resolveBaseTypesOfInterface(type); + } + } + return type.resolvedBaseTypes; + } + function resolveBaseTypesOfClass(type) { + type.resolvedBaseTypes = type.resolvedBaseTypes || emptyArray; + var baseContructorType = getBaseConstructorTypeOfClass(type); + if (!(baseContructorType.flags & 80896)) { + return; + } + var baseTypeNode = getBaseTypeNodeOfClass(type); + var baseType; + if (baseContructorType.symbol && baseContructorType.symbol.flags & 32) { + baseType = getTypeFromClassOrInterfaceReference(baseTypeNode, baseContructorType.symbol); + } + else { + var constructors = getInstantiatedConstructorsForTypeArguments(baseContructorType, baseTypeNode.typeArguments); + if (!constructors.length) { + error(baseTypeNode.expression, ts.Diagnostics.No_base_constructor_has_the_specified_number_of_type_arguments); + return; + } + baseType = getReturnTypeOfSignature(constructors[0]); + } + if (baseType === unknownType) { + return; + } + if (!(getTargetType(baseType).flags & (1024 | 2048))) { + error(baseTypeNode.expression, ts.Diagnostics.Base_constructor_return_type_0_is_not_a_class_or_interface_type, typeToString(baseType)); + return; + } + if (type === baseType || hasBaseType(baseType, type)) { + error(type.symbol.valueDeclaration, ts.Diagnostics.Type_0_recursively_references_itself_as_a_base_type, typeToString(type, undefined, 1)); + return; + } + if (type.resolvedBaseTypes === emptyArray) { + type.resolvedBaseTypes = [baseType]; + } + else { + type.resolvedBaseTypes.push(baseType); + } + } + function resolveBaseTypesOfInterface(type) { + type.resolvedBaseTypes = type.resolvedBaseTypes || emptyArray; + for (var _i = 0, _a = type.symbol.declarations; _i < _a.length; _i++) { + var declaration = _a[_i]; + if (declaration.kind === 215 && ts.getInterfaceBaseTypeNodes(declaration)) { + for (var _b = 0, _c = ts.getInterfaceBaseTypeNodes(declaration); _b < _c.length; _b++) { + var node = _c[_b]; + var baseType = getTypeFromTypeNode(node); + if (baseType !== unknownType) { + if (getTargetType(baseType).flags & (1024 | 2048)) { + if (type !== baseType && !hasBaseType(baseType, type)) { + if (type.resolvedBaseTypes === emptyArray) { + type.resolvedBaseTypes = [baseType]; + } + else { + type.resolvedBaseTypes.push(baseType); + } + } + else { + error(declaration, ts.Diagnostics.Type_0_recursively_references_itself_as_a_base_type, typeToString(type, undefined, 1)); + } + } + else { + error(node, ts.Diagnostics.An_interface_may_only_extend_a_class_or_another_interface); + } + } + } + } + } + } + function isIndependentInterface(symbol) { + for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { + var declaration = _a[_i]; + if (declaration.kind === 215) { + if (declaration.flags & 524288) { + return false; + } + var baseTypeNodes = ts.getInterfaceBaseTypeNodes(declaration); + if (baseTypeNodes) { + for (var _b = 0; _b < baseTypeNodes.length; _b++) { + var node = baseTypeNodes[_b]; + if (ts.isSupportedExpressionWithTypeArguments(node)) { + var baseSymbol = resolveEntityName(node.expression, 793056, true); + if (!baseSymbol || !(baseSymbol.flags & 64) || getDeclaredTypeOfClassOrInterface(baseSymbol).thisType) { + return false; + } + } + } + } + } + } + return true; + } + function getDeclaredTypeOfClassOrInterface(symbol) { + var links = getSymbolLinks(symbol); + if (!links.declaredType) { + var kind = symbol.flags & 32 ? 1024 : 2048; + var type = links.declaredType = createObjectType(kind, symbol); + var outerTypeParameters = getOuterTypeParametersOfClassOrInterface(symbol); + var localTypeParameters = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol); + if (outerTypeParameters || localTypeParameters || kind === 1024 || !isIndependentInterface(symbol)) { + type.flags |= 4096; + type.typeParameters = ts.concatenate(outerTypeParameters, localTypeParameters); + type.outerTypeParameters = outerTypeParameters; + type.localTypeParameters = localTypeParameters; + type.instantiations = {}; + type.instantiations[getTypeListId(type.typeParameters)] = type; + type.target = type; + type.typeArguments = type.typeParameters; + type.thisType = createType(512 | 33554432); + type.thisType.symbol = symbol; + type.thisType.constraint = getTypeWithThisArgument(type); + } + } + return links.declaredType; + } + function getDeclaredTypeOfTypeAlias(symbol) { + var links = getSymbolLinks(symbol); + if (!links.declaredType) { + if (!pushTypeResolution(symbol, 2)) { + return unknownType; + } + var declaration = ts.getDeclarationOfKind(symbol, 216); + var type = getTypeFromTypeNode(declaration.type); + if (popTypeResolution()) { + links.typeParameters = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol); + if (links.typeParameters) { + links.instantiations = {}; + links.instantiations[getTypeListId(links.typeParameters)] = type; + } + } + else { + type = unknownType; + error(declaration.name, ts.Diagnostics.Type_alias_0_circularly_references_itself, symbolToString(symbol)); + } + links.declaredType = type; + } + return links.declaredType; + } + function getDeclaredTypeOfEnum(symbol) { + var links = getSymbolLinks(symbol); + if (!links.declaredType) { + var type = createType(128); + type.symbol = symbol; + links.declaredType = type; + } + return links.declaredType; + } + function getDeclaredTypeOfTypeParameter(symbol) { + var links = getSymbolLinks(symbol); + if (!links.declaredType) { + var type = createType(512); + type.symbol = symbol; + if (!ts.getDeclarationOfKind(symbol, 137).constraint) { + type.constraint = noConstraintType; + } + links.declaredType = type; + } + return links.declaredType; + } + function getDeclaredTypeOfAlias(symbol) { + var links = getSymbolLinks(symbol); + if (!links.declaredType) { + links.declaredType = getDeclaredTypeOfSymbol(resolveAlias(symbol)); + } + return links.declaredType; + } + function getDeclaredTypeOfSymbol(symbol) { + ts.Debug.assert((symbol.flags & 16777216) === 0); + if (symbol.flags & (32 | 64)) { + return getDeclaredTypeOfClassOrInterface(symbol); + } + if (symbol.flags & 524288) { + return getDeclaredTypeOfTypeAlias(symbol); + } + if (symbol.flags & 384) { + return getDeclaredTypeOfEnum(symbol); + } + if (symbol.flags & 262144) { + return getDeclaredTypeOfTypeParameter(symbol); + } + if (symbol.flags & 8388608) { + return getDeclaredTypeOfAlias(symbol); + } + return unknownType; + } + function isIndependentTypeReference(node) { + if (node.typeArguments) { + for (var _i = 0, _a = node.typeArguments; _i < _a.length; _i++) { + var typeNode = _a[_i]; + if (!isIndependentType(typeNode)) { + return false; + } + } + } + return true; + } + function isIndependentType(node) { + switch (node.kind) { + case 117: + case 130: + case 128: + case 120: + case 131: + case 103: + case 9: + return true; + case 156: + return isIndependentType(node.elementType); + case 151: + return isIndependentTypeReference(node); + } + return false; + } + function isIndependentVariableLikeDeclaration(node) { + return node.type && isIndependentType(node.type) || !node.type && !node.initializer; + } + function isIndependentFunctionLikeDeclaration(node) { + if (node.kind !== 144 && (!node.type || !isIndependentType(node.type))) { + return false; + } + for (var _i = 0, _a = node.parameters; _i < _a.length; _i++) { + var parameter = _a[_i]; + if (!isIndependentVariableLikeDeclaration(parameter)) { + return false; + } + } + return true; + } + function isIndependentMember(symbol) { + if (symbol.declarations && symbol.declarations.length === 1) { + var declaration = symbol.declarations[0]; + if (declaration) { + switch (declaration.kind) { + case 141: + case 140: + return isIndependentVariableLikeDeclaration(declaration); + case 143: + case 142: + case 144: + return isIndependentFunctionLikeDeclaration(declaration); + } + } + } + return false; + } + function createSymbolTable(symbols) { + var result = {}; + for (var _i = 0; _i < symbols.length; _i++) { + var symbol = symbols[_i]; + result[symbol.name] = symbol; + } + return result; + } + function createInstantiatedSymbolTable(symbols, mapper, mappingThisOnly) { + var result = {}; + for (var _i = 0; _i < symbols.length; _i++) { + var symbol = symbols[_i]; + result[symbol.name] = mappingThisOnly && isIndependentMember(symbol) ? symbol : instantiateSymbol(symbol, mapper); + } + return result; + } + function addInheritedMembers(symbols, baseSymbols) { + for (var _i = 0; _i < baseSymbols.length; _i++) { + var s = baseSymbols[_i]; + if (!ts.hasProperty(symbols, s.name)) { + symbols[s.name] = s; + } + } + } + function addInheritedSignatures(signatures, baseSignatures) { + if (baseSignatures) { + for (var _i = 0; _i < baseSignatures.length; _i++) { + var signature = baseSignatures[_i]; + signatures.push(signature); + } + } + } + function resolveDeclaredMembers(type) { + if (!type.declaredProperties) { + var symbol = type.symbol; + type.declaredProperties = getNamedMembers(symbol.members); + type.declaredCallSignatures = getSignaturesOfSymbol(symbol.members["__call"]); + type.declaredConstructSignatures = getSignaturesOfSymbol(symbol.members["__new"]); + type.declaredStringIndexType = getIndexTypeOfSymbol(symbol, 0); + type.declaredNumberIndexType = getIndexTypeOfSymbol(symbol, 1); + } + return type; + } + function getTypeWithThisArgument(type, thisArgument) { + if (type.flags & 4096) { + return createTypeReference(type.target, ts.concatenate(type.typeArguments, [thisArgument || type.target.thisType])); + } + return type; + } + function resolveObjectTypeMembers(type, source, typeParameters, typeArguments) { + var mapper = identityMapper; + var members = source.symbol.members; + var callSignatures = source.declaredCallSignatures; + var constructSignatures = source.declaredConstructSignatures; + var stringIndexType = source.declaredStringIndexType; + var numberIndexType = source.declaredNumberIndexType; + if (!ts.rangeEquals(typeParameters, typeArguments, 0, typeParameters.length)) { + mapper = createTypeMapper(typeParameters, typeArguments); + members = createInstantiatedSymbolTable(source.declaredProperties, mapper, typeParameters.length === 1); + callSignatures = instantiateList(source.declaredCallSignatures, mapper, instantiateSignature); + constructSignatures = instantiateList(source.declaredConstructSignatures, mapper, instantiateSignature); + stringIndexType = instantiateType(source.declaredStringIndexType, mapper); + numberIndexType = instantiateType(source.declaredNumberIndexType, mapper); + } + var baseTypes = getBaseTypes(source); + if (baseTypes.length) { + if (members === source.symbol.members) { + members = createSymbolTable(source.declaredProperties); + } + var thisArgument = ts.lastOrUndefined(typeArguments); + for (var _i = 0; _i < baseTypes.length; _i++) { + var baseType = baseTypes[_i]; + var instantiatedBaseType = thisArgument ? getTypeWithThisArgument(instantiateType(baseType, mapper), thisArgument) : baseType; + addInheritedMembers(members, getPropertiesOfObjectType(instantiatedBaseType)); + callSignatures = ts.concatenate(callSignatures, getSignaturesOfType(instantiatedBaseType, 0)); + constructSignatures = ts.concatenate(constructSignatures, getSignaturesOfType(instantiatedBaseType, 1)); + stringIndexType = stringIndexType || getIndexTypeOfType(instantiatedBaseType, 0); + numberIndexType = numberIndexType || getIndexTypeOfType(instantiatedBaseType, 1); + } + } + setObjectTypeMembers(type, members, callSignatures, constructSignatures, stringIndexType, numberIndexType); + } + function resolveClassOrInterfaceMembers(type) { + resolveObjectTypeMembers(type, resolveDeclaredMembers(type), emptyArray, emptyArray); + } + function resolveTypeReferenceMembers(type) { + var source = resolveDeclaredMembers(type.target); + var typeParameters = ts.concatenate(source.typeParameters, [source.thisType]); + var typeArguments = type.typeArguments && type.typeArguments.length === typeParameters.length ? + type.typeArguments : ts.concatenate(type.typeArguments, [type]); + resolveObjectTypeMembers(type, source, typeParameters, typeArguments); + } + function createSignature(declaration, typeParameters, parameters, resolvedReturnType, typePredicate, minArgumentCount, hasRestParameter, hasStringLiterals) { + var sig = new Signature(checker); + sig.declaration = declaration; + sig.typeParameters = typeParameters; + sig.parameters = parameters; + sig.resolvedReturnType = resolvedReturnType; + sig.typePredicate = typePredicate; + sig.minArgumentCount = minArgumentCount; + sig.hasRestParameter = hasRestParameter; + sig.hasStringLiterals = hasStringLiterals; + return sig; + } + function cloneSignature(sig) { + return createSignature(sig.declaration, sig.typeParameters, sig.parameters, sig.resolvedReturnType, sig.typePredicate, sig.minArgumentCount, sig.hasRestParameter, sig.hasStringLiterals); + } + function getDefaultConstructSignatures(classType) { + if (!hasClassBaseType(classType)) { + return [createSignature(undefined, classType.localTypeParameters, emptyArray, classType, undefined, 0, false, false)]; + } + var baseConstructorType = getBaseConstructorTypeOfClass(classType); + var baseSignatures = getSignaturesOfType(baseConstructorType, 1); + var baseTypeNode = getBaseTypeNodeOfClass(classType); + var typeArguments = ts.map(baseTypeNode.typeArguments, getTypeFromTypeNode); + var typeArgCount = typeArguments ? typeArguments.length : 0; + var result = []; + for (var _i = 0; _i < baseSignatures.length; _i++) { + var baseSig = baseSignatures[_i]; + var typeParamCount = baseSig.typeParameters ? baseSig.typeParameters.length : 0; + if (typeParamCount === typeArgCount) { + var sig = typeParamCount ? getSignatureInstantiation(baseSig, typeArguments) : cloneSignature(baseSig); + sig.typeParameters = classType.localTypeParameters; + sig.resolvedReturnType = classType; + result.push(sig); + } + } + return result; + } + function createTupleTypeMemberSymbols(memberTypes) { + var members = {}; + for (var i = 0; i < memberTypes.length; i++) { + var symbol = createSymbol(4 | 67108864, "" + i); + symbol.type = memberTypes[i]; + members[i] = symbol; + } + return members; + } + function resolveTupleTypeMembers(type) { + var arrayElementType = getUnionType(type.elementTypes, true); + var arrayType = resolveStructuredTypeMembers(createTypeFromGenericGlobalType(globalArrayType, [arrayElementType, type])); + var members = createTupleTypeMemberSymbols(type.elementTypes); + addInheritedMembers(members, arrayType.properties); + setObjectTypeMembers(type, members, arrayType.callSignatures, arrayType.constructSignatures, arrayType.stringIndexType, arrayType.numberIndexType); + } + function findMatchingSignature(signatureList, signature, partialMatch, ignoreReturnTypes) { + for (var _i = 0; _i < signatureList.length; _i++) { + var s = signatureList[_i]; + if (compareSignatures(s, signature, partialMatch, ignoreReturnTypes, compareTypes)) { + return s; + } + } + } + function findMatchingSignatures(signatureLists, signature, listIndex) { + if (signature.typeParameters) { + if (listIndex > 0) { + return undefined; + } + for (var i = 1; i < signatureLists.length; i++) { + if (!findMatchingSignature(signatureLists[i], signature, false, false)) { + return undefined; + } + } + return [signature]; + } + var result = undefined; + for (var i = 0; i < signatureLists.length; i++) { + var match = i === listIndex ? signature : findMatchingSignature(signatureLists[i], signature, true, true); + if (!match) { + return undefined; + } + if (!ts.contains(result, match)) { + (result || (result = [])).push(match); + } + } + return result; + } + function getUnionSignatures(types, kind) { + var signatureLists = ts.map(types, function (t) { return getSignaturesOfType(t, kind); }); + var result = undefined; + for (var i = 0; i < signatureLists.length; i++) { + for (var _i = 0, _a = signatureLists[i]; _i < _a.length; _i++) { + var signature = _a[_i]; + if (!result || !findMatchingSignature(result, signature, false, true)) { + var unionSignatures = findMatchingSignatures(signatureLists, signature, i); + if (unionSignatures) { + var s = signature; + if (unionSignatures.length > 1) { + s = cloneSignature(signature); + s.resolvedReturnType = undefined; + s.unionSignatures = unionSignatures; + } + (result || (result = [])).push(s); + } + } + } + } + return result || emptyArray; + } + function getUnionIndexType(types, kind) { + var indexTypes = []; + for (var _i = 0; _i < types.length; _i++) { + var type = types[_i]; + var indexType = getIndexTypeOfType(type, kind); + if (!indexType) { + return undefined; + } + indexTypes.push(indexType); + } + return getUnionType(indexTypes); + } + function resolveUnionTypeMembers(type) { + var callSignatures = getUnionSignatures(type.types, 0); + var constructSignatures = getUnionSignatures(type.types, 1); + var stringIndexType = getUnionIndexType(type.types, 0); + var numberIndexType = getUnionIndexType(type.types, 1); + setObjectTypeMembers(type, emptySymbols, callSignatures, constructSignatures, stringIndexType, numberIndexType); + } + function intersectTypes(type1, type2) { + return !type1 ? type2 : !type2 ? type1 : getIntersectionType([type1, type2]); + } + function resolveIntersectionTypeMembers(type) { + var callSignatures = emptyArray; + var constructSignatures = emptyArray; + var stringIndexType = undefined; + var numberIndexType = undefined; + for (var _i = 0, _a = type.types; _i < _a.length; _i++) { + var t = _a[_i]; + callSignatures = ts.concatenate(callSignatures, getSignaturesOfType(t, 0)); + constructSignatures = ts.concatenate(constructSignatures, getSignaturesOfType(t, 1)); + stringIndexType = intersectTypes(stringIndexType, getIndexTypeOfType(t, 0)); + numberIndexType = intersectTypes(numberIndexType, getIndexTypeOfType(t, 1)); + } + setObjectTypeMembers(type, emptySymbols, callSignatures, constructSignatures, stringIndexType, numberIndexType); + } + function resolveAnonymousTypeMembers(type) { + var symbol = type.symbol; + var members; + var callSignatures; + var constructSignatures; + var stringIndexType; + var numberIndexType; + if (type.target) { + members = createInstantiatedSymbolTable(getPropertiesOfObjectType(type.target), type.mapper, false); + callSignatures = instantiateList(getSignaturesOfType(type.target, 0), type.mapper, instantiateSignature); + constructSignatures = instantiateList(getSignaturesOfType(type.target, 1), type.mapper, instantiateSignature); + stringIndexType = instantiateType(getIndexTypeOfType(type.target, 0), type.mapper); + numberIndexType = instantiateType(getIndexTypeOfType(type.target, 1), type.mapper); + } + else if (symbol.flags & 2048) { + members = symbol.members; + callSignatures = getSignaturesOfSymbol(members["__call"]); + constructSignatures = getSignaturesOfSymbol(members["__new"]); + stringIndexType = getIndexTypeOfSymbol(symbol, 0); + numberIndexType = getIndexTypeOfSymbol(symbol, 1); + } + else { + members = emptySymbols; + callSignatures = emptyArray; + constructSignatures = emptyArray; + if (symbol.flags & 1952) { + members = getExportsOfSymbol(symbol); + } + if (symbol.flags & (16 | 8192)) { + callSignatures = getSignaturesOfSymbol(symbol); + } + if (symbol.flags & 32) { + var classType = getDeclaredTypeOfClassOrInterface(symbol); + constructSignatures = getSignaturesOfSymbol(symbol.members["__constructor"]); + if (!constructSignatures.length) { + constructSignatures = getDefaultConstructSignatures(classType); + } + var baseConstructorType = getBaseConstructorTypeOfClass(classType); + if (baseConstructorType.flags & 80896) { + members = createSymbolTable(getNamedMembers(members)); + addInheritedMembers(members, getPropertiesOfObjectType(baseConstructorType)); + } + } + stringIndexType = undefined; + numberIndexType = (symbol.flags & 384) ? stringType : undefined; + } + setObjectTypeMembers(type, members, callSignatures, constructSignatures, stringIndexType, numberIndexType); + } + function resolveStructuredTypeMembers(type) { + if (!type.members) { + if (type.flags & 4096) { + resolveTypeReferenceMembers(type); + } + else if (type.flags & (1024 | 2048)) { + resolveClassOrInterfaceMembers(type); + } + else if (type.flags & 65536) { + resolveAnonymousTypeMembers(type); + } + else if (type.flags & 8192) { + resolveTupleTypeMembers(type); + } + else if (type.flags & 16384) { + resolveUnionTypeMembers(type); + } + else if (type.flags & 32768) { + resolveIntersectionTypeMembers(type); + } + } + return type; + } + function getPropertiesOfObjectType(type) { + if (type.flags & 80896) { + return resolveStructuredTypeMembers(type).properties; + } + return emptyArray; + } + function getPropertyOfObjectType(type, name) { + if (type.flags & 80896) { + var resolved = resolveStructuredTypeMembers(type); + if (ts.hasProperty(resolved.members, name)) { + var symbol = resolved.members[name]; + if (symbolIsValue(symbol)) { + return symbol; + } + } + } + } + function getPropertiesOfUnionOrIntersectionType(type) { + for (var _i = 0, _a = type.types; _i < _a.length; _i++) { + var current = _a[_i]; + for (var _b = 0, _c = getPropertiesOfType(current); _b < _c.length; _b++) { + var prop = _c[_b]; + getPropertyOfUnionOrIntersectionType(type, prop.name); + } + if (type.flags & 16384) { + break; + } + } + return type.resolvedProperties ? symbolsToArray(type.resolvedProperties) : emptyArray; + } + function getPropertiesOfType(type) { + type = getApparentType(type); + return type.flags & 49152 ? getPropertiesOfUnionOrIntersectionType(type) : getPropertiesOfObjectType(type); + } + function getApparentType(type) { + if (type.flags & 512) { + do { + type = getConstraintOfTypeParameter(type); + } while (type && type.flags & 512); + if (!type) { + type = emptyObjectType; + } + } + if (type.flags & 258) { + type = globalStringType; + } + else if (type.flags & 132) { + type = globalNumberType; + } + else if (type.flags & 8) { + type = globalBooleanType; + } + else if (type.flags & 16777216) { + type = globalESSymbolType; + } + return type; + } + function createUnionOrIntersectionProperty(containingType, name) { + var types = containingType.types; + var props; + for (var _i = 0; _i < types.length; _i++) { + var current = types[_i]; + var type = getApparentType(current); + if (type !== unknownType) { + var prop = getPropertyOfType(type, name); + if (prop && !(getDeclarationFlagsFromSymbol(prop) & (32 | 64))) { + if (!props) { + props = [prop]; + } + else if (!ts.contains(props, prop)) { + props.push(prop); + } + } + else if (containingType.flags & 16384) { + return undefined; + } + } + } + if (!props) { + return undefined; + } + if (props.length === 1) { + return props[0]; + } + var propTypes = []; + var declarations = []; + for (var _a = 0; _a < props.length; _a++) { + var prop = props[_a]; + if (prop.declarations) { + ts.addRange(declarations, prop.declarations); + } + propTypes.push(getTypeOfSymbol(prop)); + } + var result = createSymbol(4 | 67108864 | 268435456, name); + result.containingType = containingType; + result.declarations = declarations; + result.type = containingType.flags & 16384 ? getUnionType(propTypes) : getIntersectionType(propTypes); + return result; + } + function getPropertyOfUnionOrIntersectionType(type, name) { + var properties = type.resolvedProperties || (type.resolvedProperties = {}); + if (ts.hasProperty(properties, name)) { + return properties[name]; + } + var property = createUnionOrIntersectionProperty(type, name); + if (property) { + properties[name] = property; + } + return property; + } + function getPropertyOfType(type, name) { + type = getApparentType(type); + if (type.flags & 80896) { + var resolved = resolveStructuredTypeMembers(type); + if (ts.hasProperty(resolved.members, name)) { + var symbol = resolved.members[name]; + if (symbolIsValue(symbol)) { + return symbol; + } + } + if (resolved === anyFunctionType || resolved.callSignatures.length || resolved.constructSignatures.length) { + var symbol = getPropertyOfObjectType(globalFunctionType, name); + if (symbol) { + return symbol; + } + } + return getPropertyOfObjectType(globalObjectType, name); + } + if (type.flags & 49152) { + return getPropertyOfUnionOrIntersectionType(type, name); + } + return undefined; + } + function getSignaturesOfStructuredType(type, kind) { + if (type.flags & 130048) { + var resolved = resolveStructuredTypeMembers(type); + return kind === 0 ? resolved.callSignatures : resolved.constructSignatures; + } + return emptyArray; + } + function getSignaturesOfType(type, kind) { + return getSignaturesOfStructuredType(getApparentType(type), kind); + } + function typeHasConstructSignatures(type) { + var apparentType = getApparentType(type); + if (apparentType.flags & (80896 | 16384)) { + var resolved = resolveStructuredTypeMembers(type); + return resolved.constructSignatures.length > 0; + } + return false; + } + function typeHasCallOrConstructSignatures(type) { + var apparentType = getApparentType(type); + if (apparentType.flags & 130048) { + var resolved = resolveStructuredTypeMembers(type); + return resolved.callSignatures.length > 0 || resolved.constructSignatures.length > 0; + } + return false; + } + function getIndexTypeOfStructuredType(type, kind) { + if (type.flags & 130048) { + var resolved = resolveStructuredTypeMembers(type); + return kind === 0 ? resolved.stringIndexType : resolved.numberIndexType; + } + } + function getIndexTypeOfType(type, kind) { + return getIndexTypeOfStructuredType(getApparentType(type), kind); + } + function getTypeParametersFromDeclaration(typeParameterDeclarations) { + var result = []; + ts.forEach(typeParameterDeclarations, function (node) { + var tp = getDeclaredTypeOfTypeParameter(node.symbol); + if (!ts.contains(result, tp)) { + result.push(tp); + } + }); + return result; + } + function symbolsToArray(symbols) { + var result = []; + for (var id in symbols) { + if (!isReservedMemberName(id)) { + result.push(symbols[id]); + } + } + return result; + } + function isOptionalParameter(node) { + if (ts.hasQuestionToken(node)) { + return true; + } + if (node.initializer) { + var signatureDeclaration = node.parent; + var signature = getSignatureFromDeclaration(signatureDeclaration); + var parameterIndex = signatureDeclaration.parameters.indexOf(node); + ts.Debug.assert(parameterIndex >= 0); + return parameterIndex >= signature.minArgumentCount; + } + return false; + } + function getSignatureFromDeclaration(declaration) { + var links = getNodeLinks(declaration); + if (!links.resolvedSignature) { + var classType = declaration.kind === 144 ? + getDeclaredTypeOfClassOrInterface(getMergedSymbol(declaration.parent.symbol)) + : undefined; + var typeParameters = classType ? classType.localTypeParameters : + declaration.typeParameters ? getTypeParametersFromDeclaration(declaration.typeParameters) : undefined; + var parameters = []; + var hasStringLiterals = false; + var minArgumentCount = -1; + for (var i = 0, n = declaration.parameters.length; i < n; i++) { + var param = declaration.parameters[i]; + parameters.push(param.symbol); + if (param.type && param.type.kind === 9) { + hasStringLiterals = true; + } + if (param.initializer || param.questionToken || param.dotDotDotToken) { + if (minArgumentCount < 0) { + minArgumentCount = i; + } + } + else { + minArgumentCount = -1; + } + } + if (minArgumentCount < 0) { + minArgumentCount = declaration.parameters.length; + } + var returnType; + var typePredicate; + if (classType) { + returnType = classType; + } + else if (declaration.type) { + returnType = getTypeFromTypeNode(declaration.type); + if (declaration.type.kind === 150) { + var typePredicateNode = declaration.type; + typePredicate = { + parameterName: typePredicateNode.parameterName ? typePredicateNode.parameterName.text : undefined, + parameterIndex: typePredicateNode.parameterName ? getTypePredicateParameterIndex(declaration.parameters, typePredicateNode.parameterName) : undefined, + type: getTypeFromTypeNode(typePredicateNode.type) + }; + } + } + else { + if (declaration.kind === 145 && !ts.hasDynamicName(declaration)) { + var setter = ts.getDeclarationOfKind(declaration.symbol, 146); + returnType = getAnnotatedAccessorType(setter); + } + if (!returnType && ts.nodeIsMissing(declaration.body)) { + returnType = anyType; + } + } + links.resolvedSignature = createSignature(declaration, typeParameters, parameters, returnType, typePredicate, minArgumentCount, ts.hasRestParameter(declaration), hasStringLiterals); + } + return links.resolvedSignature; + } + function getSignaturesOfSymbol(symbol) { + if (!symbol) + return emptyArray; + var result = []; + for (var i = 0, len = symbol.declarations.length; i < len; i++) { + var node = symbol.declarations[i]; + switch (node.kind) { + case 152: + case 153: + case 213: + case 143: + case 142: + case 144: + case 147: + case 148: + case 149: + case 145: + case 146: + case 173: + case 174: + if (i > 0 && node.body) { + var previous = symbol.declarations[i - 1]; + if (node.parent === previous.parent && node.kind === previous.kind && node.pos === previous.end) { + break; + } + } + result.push(getSignatureFromDeclaration(node)); + } + } + return result; + } + function getReturnTypeOfSignature(signature) { + if (!signature.resolvedReturnType) { + if (!pushTypeResolution(signature, 3)) { + return unknownType; + } + var type; + if (signature.target) { + type = instantiateType(getReturnTypeOfSignature(signature.target), signature.mapper); + } + else if (signature.unionSignatures) { + type = getUnionType(ts.map(signature.unionSignatures, getReturnTypeOfSignature)); + } + else { + type = getReturnTypeFromBody(signature.declaration); + } + if (!popTypeResolution()) { + type = anyType; + if (compilerOptions.noImplicitAny) { + var declaration = signature.declaration; + if (declaration.name) { + error(declaration.name, 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, ts.declarationNameToString(declaration.name)); + } + else { + error(declaration, ts.Diagnostics.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); + } + } + } + signature.resolvedReturnType = type; + } + return signature.resolvedReturnType; + } + function getRestTypeOfSignature(signature) { + if (signature.hasRestParameter) { + var type = getTypeOfSymbol(ts.lastOrUndefined(signature.parameters)); + if (type.flags & 4096 && type.target === globalArrayType) { + return type.typeArguments[0]; + } + } + return anyType; + } + function getSignatureInstantiation(signature, typeArguments) { + return instantiateSignature(signature, createTypeMapper(signature.typeParameters, typeArguments), true); + } + function getErasedSignature(signature) { + if (!signature.typeParameters) + return signature; + if (!signature.erasedSignatureCache) { + if (signature.target) { + signature.erasedSignatureCache = instantiateSignature(getErasedSignature(signature.target), signature.mapper); + } + else { + signature.erasedSignatureCache = instantiateSignature(signature, createTypeEraser(signature.typeParameters), true); + } + } + return signature.erasedSignatureCache; + } + function getOrCreateTypeFromSignature(signature) { + if (!signature.isolatedSignatureType) { + var isConstructor = signature.declaration.kind === 144 || signature.declaration.kind === 148; + var type = createObjectType(65536 | 262144); + type.members = emptySymbols; + type.properties = emptyArray; + type.callSignatures = !isConstructor ? [signature] : emptyArray; + type.constructSignatures = isConstructor ? [signature] : emptyArray; + signature.isolatedSignatureType = type; + } + return signature.isolatedSignatureType; + } + function getIndexSymbol(symbol) { + return symbol.members["__index"]; + } + function getIndexDeclarationOfSymbol(symbol, kind) { + var syntaxKind = kind === 1 ? 128 : 130; + var indexSymbol = getIndexSymbol(symbol); + if (indexSymbol) { + for (var _i = 0, _a = indexSymbol.declarations; _i < _a.length; _i++) { + var decl = _a[_i]; + var node = decl; + if (node.parameters.length === 1) { + var parameter = node.parameters[0]; + if (parameter && parameter.type && parameter.type.kind === syntaxKind) { + return node; + } + } + } + } + return undefined; + } + function getIndexTypeOfSymbol(symbol, kind) { + var declaration = getIndexDeclarationOfSymbol(symbol, kind); + return declaration + ? declaration.type ? getTypeFromTypeNode(declaration.type) : anyType + : undefined; + } + function getConstraintOfTypeParameter(type) { + if (!type.constraint) { + if (type.target) { + var targetConstraint = getConstraintOfTypeParameter(type.target); + type.constraint = targetConstraint ? instantiateType(targetConstraint, type.mapper) : noConstraintType; + } + else { + type.constraint = getTypeFromTypeNode(ts.getDeclarationOfKind(type.symbol, 137).constraint); + } + } + return type.constraint === noConstraintType ? undefined : type.constraint; + } + function getParentSymbolOfTypeParameter(typeParameter) { + return getSymbolOfNode(ts.getDeclarationOfKind(typeParameter.symbol, 137).parent); + } + function getTypeListId(types) { + if (types) { + switch (types.length) { + case 1: + return "" + types[0].id; + case 2: + return types[0].id + "," + types[1].id; + default: + var result = ""; + for (var i = 0; i < types.length; i++) { + if (i > 0) { + result += ","; + } + result += types[i].id; + } + return result; + } + } + return ""; + } + function getPropagatingFlagsOfTypes(types) { + var result = 0; + for (var _i = 0; _i < types.length; _i++) { + var type = types[_i]; + result |= type.flags; + } + return result & 14680064; + } + function createTypeReference(target, typeArguments) { + var id = getTypeListId(typeArguments); + var type = target.instantiations[id]; + if (!type) { + var flags = 4096 | (typeArguments ? getPropagatingFlagsOfTypes(typeArguments) : 0); + type = target.instantiations[id] = createObjectType(flags, target.symbol); + type.target = target; + type.typeArguments = typeArguments; + } + return type; + } + function isTypeParameterReferenceIllegalInConstraint(typeReferenceNode, typeParameterSymbol) { + var links = getNodeLinks(typeReferenceNode); + if (links.isIllegalTypeReferenceInConstraint !== undefined) { + return links.isIllegalTypeReferenceInConstraint; + } + var currentNode = typeReferenceNode; + while (!ts.forEach(typeParameterSymbol.declarations, function (d) { return d.parent === currentNode.parent; })) { + currentNode = currentNode.parent; + } + links.isIllegalTypeReferenceInConstraint = currentNode.kind === 137; + return links.isIllegalTypeReferenceInConstraint; + } + function checkTypeParameterHasIllegalReferencesInConstraint(typeParameter) { + var typeParameterSymbol; + function check(n) { + if (n.kind === 151 && n.typeName.kind === 69) { + var links = getNodeLinks(n); + if (links.isIllegalTypeReferenceInConstraint === undefined) { + var symbol = resolveName(typeParameter, n.typeName.text, 793056, undefined, undefined); + if (symbol && (symbol.flags & 262144)) { + links.isIllegalTypeReferenceInConstraint = ts.forEach(symbol.declarations, function (d) { return d.parent === typeParameter.parent; }); + } + } + if (links.isIllegalTypeReferenceInConstraint) { + error(typeParameter, ts.Diagnostics.Constraint_of_a_type_parameter_cannot_reference_any_type_parameter_from_the_same_type_parameter_list); + } + } + ts.forEachChild(n, check); + } + if (typeParameter.constraint) { + typeParameterSymbol = getSymbolOfNode(typeParameter); + check(typeParameter.constraint); + } + } + function getTypeFromClassOrInterfaceReference(node, symbol) { + var type = getDeclaredTypeOfSymbol(symbol); + var typeParameters = type.localTypeParameters; + if (typeParameters) { + if (!node.typeArguments || node.typeArguments.length !== typeParameters.length) { + error(node, ts.Diagnostics.Generic_type_0_requires_1_type_argument_s, typeToString(type, undefined, 1), typeParameters.length); + return unknownType; + } + return createTypeReference(type, ts.concatenate(type.outerTypeParameters, ts.map(node.typeArguments, getTypeFromTypeNode))); + } + if (node.typeArguments) { + error(node, ts.Diagnostics.Type_0_is_not_generic, typeToString(type)); + return unknownType; + } + return type; + } + function getTypeFromTypeAliasReference(node, symbol) { + var type = getDeclaredTypeOfSymbol(symbol); + var links = getSymbolLinks(symbol); + var typeParameters = links.typeParameters; + if (typeParameters) { + if (!node.typeArguments || node.typeArguments.length !== typeParameters.length) { + error(node, ts.Diagnostics.Generic_type_0_requires_1_type_argument_s, symbolToString(symbol), typeParameters.length); + return unknownType; + } + var typeArguments = ts.map(node.typeArguments, getTypeFromTypeNode); + var id = getTypeListId(typeArguments); + return links.instantiations[id] || (links.instantiations[id] = instantiateType(type, createTypeMapper(typeParameters, typeArguments))); + } + if (node.typeArguments) { + error(node, ts.Diagnostics.Type_0_is_not_generic, symbolToString(symbol)); + return unknownType; + } + return type; + } + function getTypeFromNonGenericTypeReference(node, symbol) { + if (symbol.flags & 262144 && isTypeParameterReferenceIllegalInConstraint(node, symbol)) { + return unknownType; + } + if (node.typeArguments) { + error(node, ts.Diagnostics.Type_0_is_not_generic, symbolToString(symbol)); + return unknownType; + } + return getDeclaredTypeOfSymbol(symbol); + } + function getTypeFromTypeReference(node) { + var links = getNodeLinks(node); + if (!links.resolvedType) { + var typeNameOrExpression = node.kind === 151 ? node.typeName : + ts.isSupportedExpressionWithTypeArguments(node) ? node.expression : + undefined; + var symbol = typeNameOrExpression && resolveEntityName(typeNameOrExpression, 793056) || unknownSymbol; + var type = symbol === unknownSymbol ? unknownType : + symbol.flags & (32 | 64) ? getTypeFromClassOrInterfaceReference(node, symbol) : + symbol.flags & 524288 ? getTypeFromTypeAliasReference(node, symbol) : + getTypeFromNonGenericTypeReference(node, symbol); + links.resolvedSymbol = symbol; + links.resolvedType = type; + } + return links.resolvedType; + } + function getTypeFromTypeQueryNode(node) { + var links = getNodeLinks(node); + if (!links.resolvedType) { + links.resolvedType = getWidenedType(checkExpression(node.exprName)); + } + return links.resolvedType; + } + function getTypeOfGlobalSymbol(symbol, arity) { + function getTypeDeclaration(symbol) { + var declarations = symbol.declarations; + for (var _i = 0; _i < declarations.length; _i++) { + var declaration = declarations[_i]; + switch (declaration.kind) { + case 214: + case 215: + case 217: + return declaration; + } + } + } + if (!symbol) { + return arity ? emptyGenericType : emptyObjectType; + } + var type = getDeclaredTypeOfSymbol(symbol); + if (!(type.flags & 80896)) { + error(getTypeDeclaration(symbol), ts.Diagnostics.Global_type_0_must_be_a_class_or_interface_type, symbol.name); + return arity ? emptyGenericType : emptyObjectType; + } + if ((type.typeParameters ? type.typeParameters.length : 0) !== arity) { + error(getTypeDeclaration(symbol), ts.Diagnostics.Global_type_0_must_have_1_type_parameter_s, symbol.name, arity); + return arity ? emptyGenericType : emptyObjectType; + } + return type; + } + function getGlobalValueSymbol(name) { + return getGlobalSymbol(name, 107455, ts.Diagnostics.Cannot_find_global_value_0); + } + function getGlobalTypeSymbol(name) { + return getGlobalSymbol(name, 793056, ts.Diagnostics.Cannot_find_global_type_0); + } + function getGlobalSymbol(name, meaning, diagnostic) { + return resolveName(undefined, name, meaning, diagnostic, name); + } + function getGlobalType(name, arity) { + if (arity === void 0) { arity = 0; } + return getTypeOfGlobalSymbol(getGlobalTypeSymbol(name), arity); + } + function tryGetGlobalType(name, arity) { + if (arity === void 0) { arity = 0; } + return getTypeOfGlobalSymbol(getGlobalSymbol(name, 793056, undefined), arity); + } + function getExportedTypeFromNamespace(namespace, name) { + var namespaceSymbol = getGlobalSymbol(namespace, 1536, undefined); + var typeSymbol = namespaceSymbol && getSymbol(namespaceSymbol.exports, name, 793056); + return typeSymbol && getDeclaredTypeOfSymbol(typeSymbol); + } + function getGlobalESSymbolConstructorSymbol() { + return globalESSymbolConstructorSymbol || (globalESSymbolConstructorSymbol = getGlobalValueSymbol("Symbol")); + } + function createTypedPropertyDescriptorType(propertyType) { + var globalTypedPropertyDescriptorType = getGlobalTypedPropertyDescriptorType(); + return globalTypedPropertyDescriptorType !== emptyGenericType + ? createTypeReference(globalTypedPropertyDescriptorType, [propertyType]) + : emptyObjectType; + } + function createTypeFromGenericGlobalType(genericGlobalType, typeArguments) { + return genericGlobalType !== emptyGenericType ? createTypeReference(genericGlobalType, typeArguments) : emptyObjectType; + } + function createIterableType(elementType) { + return createTypeFromGenericGlobalType(globalIterableType, [elementType]); + } + function createIterableIteratorType(elementType) { + return createTypeFromGenericGlobalType(globalIterableIteratorType, [elementType]); + } + function createArrayType(elementType) { + return createTypeFromGenericGlobalType(globalArrayType, [elementType]); + } + function getTypeFromArrayTypeNode(node) { + var links = getNodeLinks(node); + if (!links.resolvedType) { + links.resolvedType = createArrayType(getTypeFromTypeNode(node.elementType)); + } + return links.resolvedType; + } + function createTupleType(elementTypes) { + var id = getTypeListId(elementTypes); + return tupleTypes[id] || (tupleTypes[id] = createNewTupleType(elementTypes)); + } + function createNewTupleType(elementTypes) { + var type = createObjectType(8192 | getPropagatingFlagsOfTypes(elementTypes)); + type.elementTypes = elementTypes; + return type; + } + function getTypeFromTupleTypeNode(node) { + var links = getNodeLinks(node); + if (!links.resolvedType) { + links.resolvedType = createTupleType(ts.map(node.elementTypes, getTypeFromTypeNode)); + } + return links.resolvedType; + } + function addTypeToSet(typeSet, type, typeSetKind) { + if (type.flags & typeSetKind) { + addTypesToSet(typeSet, type.types, typeSetKind); + } + else if (!ts.contains(typeSet, type)) { + typeSet.push(type); + } + } + function addTypesToSet(typeSet, types, typeSetKind) { + for (var _i = 0; _i < types.length; _i++) { + var type = types[_i]; + addTypeToSet(typeSet, type, typeSetKind); + } + } + function isSubtypeOfAny(candidate, types) { + for (var i = 0, len = types.length; i < len; i++) { + if (candidate !== types[i] && isTypeSubtypeOf(candidate, types[i])) { + return true; + } + } + return false; + } + function removeSubtypes(types) { + var i = types.length; + while (i > 0) { + i--; + if (isSubtypeOfAny(types[i], types)) { + types.splice(i, 1); + } + } + } + function containsTypeAny(types) { + for (var _i = 0; _i < types.length; _i++) { + var type = types[_i]; + if (isTypeAny(type)) { + return true; + } + } + return false; + } + function removeAllButLast(types, typeToRemove) { + var i = types.length; + while (i > 0 && types.length > 1) { + i--; + if (types[i] === typeToRemove) { + types.splice(i, 1); + } + } + } + function getUnionType(types, noSubtypeReduction) { + if (types.length === 0) { + return emptyObjectType; + } + var typeSet = []; + addTypesToSet(typeSet, types, 16384); + if (containsTypeAny(typeSet)) { + return anyType; + } + if (noSubtypeReduction) { + removeAllButLast(typeSet, undefinedType); + removeAllButLast(typeSet, nullType); + } + else { + removeSubtypes(typeSet); + } + if (typeSet.length === 1) { + return typeSet[0]; + } + var id = getTypeListId(typeSet); + var type = unionTypes[id]; + if (!type) { + type = unionTypes[id] = createObjectType(16384 | getPropagatingFlagsOfTypes(typeSet)); + type.types = typeSet; + } + return type; + } + function getTypeFromUnionTypeNode(node) { + var links = getNodeLinks(node); + if (!links.resolvedType) { + links.resolvedType = getUnionType(ts.map(node.types, getTypeFromTypeNode), true); + } + return links.resolvedType; + } + function getIntersectionType(types) { + if (types.length === 0) { + return emptyObjectType; + } + var typeSet = []; + addTypesToSet(typeSet, types, 32768); + if (containsTypeAny(typeSet)) { + return anyType; + } + if (typeSet.length === 1) { + return typeSet[0]; + } + var id = getTypeListId(typeSet); + var type = intersectionTypes[id]; + if (!type) { + type = intersectionTypes[id] = createObjectType(32768 | getPropagatingFlagsOfTypes(typeSet)); + type.types = typeSet; + } + return type; + } + function getTypeFromIntersectionTypeNode(node) { + var links = getNodeLinks(node); + if (!links.resolvedType) { + links.resolvedType = getIntersectionType(ts.map(node.types, getTypeFromTypeNode)); + } + return links.resolvedType; + } + function getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node) { + var links = getNodeLinks(node); + if (!links.resolvedType) { + links.resolvedType = createObjectType(65536, node.symbol); + } + return links.resolvedType; + } + function getStringLiteralType(node) { + if (ts.hasProperty(stringLiteralTypes, node.text)) { + return stringLiteralTypes[node.text]; + } + var type = stringLiteralTypes[node.text] = createType(256); + type.text = ts.getTextOfNode(node); + return type; + } + function getTypeFromStringLiteral(node) { + var links = getNodeLinks(node); + if (!links.resolvedType) { + links.resolvedType = getStringLiteralType(node); + } + return links.resolvedType; + } + function getThisType(node) { + var container = ts.getThisContainer(node, false); + var parent = container && container.parent; + if (parent && (ts.isClassLike(parent) || parent.kind === 215)) { + if (!(container.flags & 128)) { + return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(parent)).thisType; + } + } + error(node, ts.Diagnostics.A_this_type_is_available_only_in_a_non_static_member_of_a_class_or_interface); + return unknownType; + } + function getTypeFromThisTypeNode(node) { + var links = getNodeLinks(node); + if (!links.resolvedType) { + links.resolvedType = getThisType(node); + } + return links.resolvedType; + } + function getTypeFromTypeNode(node) { + switch (node.kind) { + case 117: + return anyType; + case 130: + return stringType; + case 128: + return numberType; + case 120: + return booleanType; + case 131: + return esSymbolType; + case 103: + return voidType; + case 97: + return getTypeFromThisTypeNode(node); + case 9: + return getTypeFromStringLiteral(node); + case 151: + return getTypeFromTypeReference(node); + case 150: + return booleanType; + case 188: + return getTypeFromTypeReference(node); + case 154: + return getTypeFromTypeQueryNode(node); + case 156: + return getTypeFromArrayTypeNode(node); + case 157: + return getTypeFromTupleTypeNode(node); + case 158: + return getTypeFromUnionTypeNode(node); + case 159: + return getTypeFromIntersectionTypeNode(node); + case 160: + return getTypeFromTypeNode(node.type); + case 152: + case 153: + case 155: + return getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node); + case 69: + case 135: + var symbol = getSymbolAtLocation(node); + return symbol && getDeclaredTypeOfSymbol(symbol); + default: + return unknownType; + } + } + function instantiateList(items, mapper, instantiator) { + if (items && items.length) { + var result = []; + for (var _i = 0; _i < items.length; _i++) { + var v = items[_i]; + result.push(instantiator(v, mapper)); + } + return result; + } + return items; + } + function createUnaryTypeMapper(source, target) { + return function (t) { return t === source ? target : t; }; + } + function createBinaryTypeMapper(source1, target1, source2, target2) { + return function (t) { return t === source1 ? target1 : t === source2 ? target2 : t; }; + } + function createTypeMapper(sources, targets) { + switch (sources.length) { + case 1: return createUnaryTypeMapper(sources[0], targets[0]); + case 2: return createBinaryTypeMapper(sources[0], targets[0], sources[1], targets[1]); + } + return function (t) { + for (var i = 0; i < sources.length; i++) { + if (t === sources[i]) { + return targets[i]; + } + } + return t; + }; + } + function createUnaryTypeEraser(source) { + return function (t) { return t === source ? anyType : t; }; + } + function createBinaryTypeEraser(source1, source2) { + return function (t) { return t === source1 || t === source2 ? anyType : t; }; + } + function createTypeEraser(sources) { + switch (sources.length) { + case 1: return createUnaryTypeEraser(sources[0]); + case 2: return createBinaryTypeEraser(sources[0], sources[1]); + } + return function (t) { + for (var _i = 0; _i < sources.length; _i++) { + var source = sources[_i]; + if (t === source) { + return anyType; + } + } + return t; + }; + } + function createInferenceMapper(context) { + var mapper = function (t) { + for (var i = 0; i < context.typeParameters.length; i++) { + if (t === context.typeParameters[i]) { + context.inferences[i].isFixed = true; + return getInferredType(context, i); + } + } + return t; + }; + mapper.context = context; + return mapper; + } + function identityMapper(type) { + return type; + } + function combineTypeMappers(mapper1, mapper2) { + return function (t) { return instantiateType(mapper1(t), mapper2); }; + } + function instantiateTypeParameter(typeParameter, mapper) { + var result = createType(512); + result.symbol = typeParameter.symbol; + if (typeParameter.constraint) { + result.constraint = instantiateType(typeParameter.constraint, mapper); + } + else { + result.target = typeParameter; + result.mapper = mapper; + } + return result; + } + function instantiateSignature(signature, mapper, eraseTypeParameters) { + var freshTypeParameters; + var freshTypePredicate; + if (signature.typeParameters && !eraseTypeParameters) { + freshTypeParameters = instantiateList(signature.typeParameters, mapper, instantiateTypeParameter); + mapper = combineTypeMappers(createTypeMapper(signature.typeParameters, freshTypeParameters), mapper); + } + if (signature.typePredicate) { + freshTypePredicate = { + parameterName: signature.typePredicate.parameterName, + parameterIndex: signature.typePredicate.parameterIndex, + type: instantiateType(signature.typePredicate.type, mapper) + }; + } + var result = createSignature(signature.declaration, freshTypeParameters, instantiateList(signature.parameters, mapper, instantiateSymbol), instantiateType(signature.resolvedReturnType, mapper), freshTypePredicate, signature.minArgumentCount, signature.hasRestParameter, signature.hasStringLiterals); + result.target = signature; + result.mapper = mapper; + return result; + } + function instantiateSymbol(symbol, mapper) { + if (symbol.flags & 16777216) { + var links = getSymbolLinks(symbol); + symbol = links.target; + mapper = combineTypeMappers(links.mapper, mapper); + } + var result = createSymbol(16777216 | 67108864 | symbol.flags, symbol.name); + result.declarations = symbol.declarations; + result.parent = symbol.parent; + result.target = symbol; + result.mapper = mapper; + if (symbol.valueDeclaration) { + result.valueDeclaration = symbol.valueDeclaration; + } + return result; + } + function instantiateAnonymousType(type, mapper) { + if (mapper.instantiations) { + var cachedType = mapper.instantiations[type.id]; + if (cachedType) { + return cachedType; + } + } + else { + mapper.instantiations = []; + } + var result = createObjectType(65536 | 131072, type.symbol); + result.target = type; + result.mapper = mapper; + mapper.instantiations[type.id] = result; + return result; + } + function instantiateType(type, mapper) { + if (type && mapper !== identityMapper) { + if (type.flags & 512) { + return mapper(type); + } + if (type.flags & 65536) { + return type.symbol && type.symbol.flags & (16 | 8192 | 32 | 2048 | 4096) ? + instantiateAnonymousType(type, mapper) : type; + } + if (type.flags & 4096) { + return createTypeReference(type.target, instantiateList(type.typeArguments, mapper, instantiateType)); + } + if (type.flags & 8192) { + return createTupleType(instantiateList(type.elementTypes, mapper, instantiateType)); + } + if (type.flags & 16384) { + return getUnionType(instantiateList(type.types, mapper, instantiateType), true); + } + if (type.flags & 32768) { + return getIntersectionType(instantiateList(type.types, mapper, instantiateType)); + } + } + return type; + } + function isContextSensitive(node) { + ts.Debug.assert(node.kind !== 143 || ts.isObjectLiteralMethod(node)); + switch (node.kind) { + case 173: + case 174: + return isContextSensitiveFunctionLikeDeclaration(node); + case 165: + return ts.forEach(node.properties, isContextSensitive); + case 164: + return ts.forEach(node.elements, isContextSensitive); + case 182: + return isContextSensitive(node.whenTrue) || + isContextSensitive(node.whenFalse); + case 181: + return node.operatorToken.kind === 52 && + (isContextSensitive(node.left) || isContextSensitive(node.right)); + case 245: + return isContextSensitive(node.initializer); + case 143: + case 142: + return isContextSensitiveFunctionLikeDeclaration(node); + case 172: + return isContextSensitive(node.expression); + } + return false; + } + function isContextSensitiveFunctionLikeDeclaration(node) { + return !node.typeParameters && node.parameters.length && !ts.forEach(node.parameters, function (p) { return p.type; }); + } + function getTypeWithoutSignatures(type) { + if (type.flags & 80896) { + var resolved = resolveStructuredTypeMembers(type); + if (resolved.constructSignatures.length) { + var result = createObjectType(65536, type.symbol); + result.members = resolved.members; + result.properties = resolved.properties; + result.callSignatures = emptyArray; + result.constructSignatures = emptyArray; + type = result; + } + } + return type; + } + function isTypeIdenticalTo(source, target) { + return checkTypeRelatedTo(source, target, identityRelation, undefined); + } + function compareTypes(source, target) { + return checkTypeRelatedTo(source, target, identityRelation, undefined) ? -1 : 0; + } + function isTypeSubtypeOf(source, target) { + return checkTypeSubtypeOf(source, target, undefined); + } + function isTypeAssignableTo(source, target) { + return checkTypeAssignableTo(source, target, undefined); + } + function checkTypeSubtypeOf(source, target, errorNode, headMessage, containingMessageChain) { + return checkTypeRelatedTo(source, target, subtypeRelation, errorNode, headMessage, containingMessageChain); + } + function checkTypeAssignableTo(source, target, errorNode, headMessage, containingMessageChain) { + return checkTypeRelatedTo(source, target, assignableRelation, errorNode, headMessage, containingMessageChain); + } + function isSignatureAssignableTo(source, target) { + var sourceType = getOrCreateTypeFromSignature(source); + var targetType = getOrCreateTypeFromSignature(target); + return checkTypeRelatedTo(sourceType, targetType, assignableRelation, undefined); + } + function checkTypeRelatedTo(source, target, relation, errorNode, headMessage, containingMessageChain) { + var errorInfo; + var sourceStack; + var targetStack; + var maybeStack; + var expandingFlags; + var depth = 0; + var overflow = false; + var elaborateErrors = false; + ts.Debug.assert(relation !== identityRelation || !errorNode, "no error reporting in identity checking"); + var result = isRelatedTo(source, target, errorNode !== undefined, headMessage); + if (overflow) { + error(errorNode, ts.Diagnostics.Excessive_stack_depth_comparing_types_0_and_1, typeToString(source), typeToString(target)); + } + else if (errorInfo) { + if (errorInfo.next === undefined) { + errorInfo = undefined; + elaborateErrors = true; + isRelatedTo(source, target, errorNode !== undefined, headMessage); + } + if (containingMessageChain) { + errorInfo = ts.concatenateDiagnosticMessageChains(containingMessageChain, errorInfo); + } + diagnostics.add(ts.createDiagnosticForNodeFromMessageChain(errorNode, errorInfo)); + } + return result !== 0; + function reportError(message, arg0, arg1, arg2) { + errorInfo = ts.chainDiagnosticMessages(errorInfo, message, arg0, arg1, arg2); + } + function reportRelationError(message, source, target) { + var sourceType = typeToString(source); + var targetType = typeToString(target); + if (sourceType === targetType) { + sourceType = typeToString(source, undefined, 128); + targetType = typeToString(target, undefined, 128); + } + reportError(message || ts.Diagnostics.Type_0_is_not_assignable_to_type_1, sourceType, targetType); + } + function isRelatedTo(source, target, reportErrors, headMessage) { + var result; + if (source === target) + return -1; + if (relation === identityRelation) { + return isIdenticalTo(source, target); + } + if (isTypeAny(target)) + return -1; + if (source === undefinedType) + return -1; + if (source === nullType && target !== undefinedType) + return -1; + if (source.flags & 128 && target === numberType) + return -1; + if (source.flags & 256 && target === stringType) + return -1; + if (relation === assignableRelation) { + if (isTypeAny(source)) + return -1; + if (source === numberType && target.flags & 128) + return -1; + } + if (source.flags & 1048576) { + if (hasExcessProperties(source, target, reportErrors)) { + if (reportErrors) { + reportRelationError(headMessage, source, target); + } + return 0; + } + if (target.flags & 49152) { + source = getRegularTypeOfObjectLiteral(source); + } + } + var saveErrorInfo = errorInfo; + if (source.flags & 16384) { + if (result = eachTypeRelatedToType(source, target, reportErrors)) { + return result; + } + } + else if (target.flags & 32768) { + if (result = typeRelatedToEachType(source, target, reportErrors)) { + return result; + } + } + else { + if (source.flags & 32768) { + if (result = someTypeRelatedToType(source, target, reportErrors && !(target.flags & 16384))) { + return result; + } + } + if (target.flags & 16384) { + if (result = typeRelatedToSomeType(source, target, reportErrors)) { + return result; + } + } + } + if (source.flags & 512) { + var constraint = getConstraintOfTypeParameter(source); + if (!constraint || constraint.flags & 1) { + constraint = emptyObjectType; + } + var reportConstraintErrors = reportErrors && constraint !== emptyObjectType; + if (result = isRelatedTo(constraint, target, reportConstraintErrors)) { + errorInfo = saveErrorInfo; + return result; + } + } + else { + if (source.flags & 4096 && target.flags & 4096 && source.target === target.target) { + if (result = typeArgumentsRelatedTo(source, target, reportErrors)) { + return result; + } + } + var apparentType = getApparentType(source); + if (apparentType.flags & (80896 | 32768) && target.flags & 80896) { + var reportStructuralErrors = reportErrors && errorInfo === saveErrorInfo; + if (result = objectTypeRelatedTo(apparentType, source, target, reportStructuralErrors)) { + errorInfo = saveErrorInfo; + return result; + } + } + } + if (reportErrors) { + reportRelationError(headMessage, source, target); + } + return 0; + } + function isIdenticalTo(source, target) { + var result; + if (source.flags & 80896 && target.flags & 80896) { + if (source.flags & 4096 && target.flags & 4096 && source.target === target.target) { + if (result = typeArgumentsRelatedTo(source, target, false)) { + return result; + } + } + return objectTypeRelatedTo(source, source, target, false); + } + if (source.flags & 512 && target.flags & 512) { + return typeParameterIdenticalTo(source, target); + } + if (source.flags & 16384 && target.flags & 16384 || + source.flags & 32768 && target.flags & 32768) { + if (result = eachTypeRelatedToSomeType(source, target)) { + if (result &= eachTypeRelatedToSomeType(target, source)) { + return result; + } + } + } + return 0; + } + function isKnownProperty(type, name) { + if (type.flags & 80896) { + var resolved = resolveStructuredTypeMembers(type); + if (relation === assignableRelation && (type === globalObjectType || resolved.properties.length === 0) || + resolved.stringIndexType || resolved.numberIndexType || getPropertyOfType(type, name)) { + return true; + } + } + else if (type.flags & 49152) { + for (var _i = 0, _a = type.types; _i < _a.length; _i++) { + var t = _a[_i]; + if (isKnownProperty(t, name)) { + return true; + } + } + } + return false; + } + function hasExcessProperties(source, target, reportErrors) { + if (someConstituentTypeHasKind(target, 80896)) { + for (var _i = 0, _a = getPropertiesOfObjectType(source); _i < _a.length; _i++) { + var prop = _a[_i]; + if (!isKnownProperty(target, prop.name)) { + if (reportErrors) { + errorNode = prop.valueDeclaration; + reportError(ts.Diagnostics.Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1, symbolToString(prop), typeToString(target)); + } + return true; + } + } + } + return false; + } + function eachTypeRelatedToSomeType(source, target) { + var result = -1; + var sourceTypes = source.types; + for (var _i = 0; _i < sourceTypes.length; _i++) { + var sourceType = sourceTypes[_i]; + var related = typeRelatedToSomeType(sourceType, target, false); + if (!related) { + return 0; + } + result &= related; + } + return result; + } + function typeRelatedToSomeType(source, target, reportErrors) { + var targetTypes = target.types; + for (var i = 0, len = targetTypes.length; i < len; i++) { + var related = isRelatedTo(source, targetTypes[i], reportErrors && i === len - 1); + if (related) { + return related; + } + } + return 0; + } + function typeRelatedToEachType(source, target, reportErrors) { + var result = -1; + var targetTypes = target.types; + for (var _i = 0; _i < targetTypes.length; _i++) { + var targetType = targetTypes[_i]; + var related = isRelatedTo(source, targetType, reportErrors); + if (!related) { + return 0; + } + result &= related; + } + return result; + } + function someTypeRelatedToType(source, target, reportErrors) { + var sourceTypes = source.types; + for (var i = 0, len = sourceTypes.length; i < len; i++) { + var related = isRelatedTo(sourceTypes[i], target, reportErrors && i === len - 1); + if (related) { + return related; + } + } + return 0; + } + function eachTypeRelatedToType(source, target, reportErrors) { + var result = -1; + var sourceTypes = source.types; + for (var _i = 0; _i < sourceTypes.length; _i++) { + var sourceType = sourceTypes[_i]; + var related = isRelatedTo(sourceType, target, reportErrors); + if (!related) { + return 0; + } + result &= related; + } + return result; + } + function typeArgumentsRelatedTo(source, target, reportErrors) { + var sources = source.typeArguments || emptyArray; + var targets = target.typeArguments || emptyArray; + if (sources.length !== targets.length && relation === identityRelation) { + return 0; + } + var result = -1; + for (var i = 0; i < targets.length; i++) { + var related = isRelatedTo(sources[i], targets[i], reportErrors); + if (!related) { + return 0; + } + result &= related; + } + return result; + } + function typeParameterIdenticalTo(source, target) { + if (source.symbol.name !== target.symbol.name) { + return 0; + } + if (source.constraint === target.constraint) { + return -1; + } + if (source.constraint === noConstraintType || target.constraint === noConstraintType) { + return 0; + } + return isIdenticalTo(source.constraint, target.constraint); + } + function objectTypeRelatedTo(apparentSource, originalSource, target, reportErrors) { + if (overflow) { + return 0; + } + var id = relation !== identityRelation || apparentSource.id < target.id ? apparentSource.id + "," + target.id : target.id + "," + apparentSource.id; + var related = relation[id]; + if (related !== undefined) { + if (!elaborateErrors || (related === 3)) { + return related === 1 ? -1 : 0; + } + } + if (depth > 0) { + for (var i = 0; i < depth; i++) { + if (maybeStack[i][id]) { + return 1; + } + } + if (depth === 100) { + overflow = true; + return 0; + } + } + else { + sourceStack = []; + targetStack = []; + maybeStack = []; + expandingFlags = 0; + } + sourceStack[depth] = apparentSource; + targetStack[depth] = target; + maybeStack[depth] = {}; + maybeStack[depth][id] = 1; + depth++; + var saveExpandingFlags = expandingFlags; + if (!(expandingFlags & 1) && isDeeplyNestedGeneric(apparentSource, sourceStack, depth)) + expandingFlags |= 1; + if (!(expandingFlags & 2) && isDeeplyNestedGeneric(target, targetStack, depth)) + expandingFlags |= 2; + var result; + if (expandingFlags === 3) { + result = 1; + } + else { + result = propertiesRelatedTo(apparentSource, target, reportErrors); + if (result) { + result &= signaturesRelatedTo(apparentSource, target, 0, reportErrors); + if (result) { + result &= signaturesRelatedTo(apparentSource, target, 1, reportErrors); + if (result) { + result &= stringIndexTypesRelatedTo(apparentSource, originalSource, target, reportErrors); + if (result) { + result &= numberIndexTypesRelatedTo(apparentSource, originalSource, target, reportErrors); + } + } + } + } + } + expandingFlags = saveExpandingFlags; + depth--; + if (result) { + var maybeCache = maybeStack[depth]; + var destinationCache = (result === -1 || depth === 0) ? relation : maybeStack[depth - 1]; + ts.copyMap(maybeCache, destinationCache); + } + else { + relation[id] = reportErrors ? 3 : 2; + } + return result; + } + function propertiesRelatedTo(source, target, reportErrors) { + if (relation === identityRelation) { + return propertiesIdenticalTo(source, target); + } + var result = -1; + var properties = getPropertiesOfObjectType(target); + var requireOptionalProperties = relation === subtypeRelation && !(source.flags & 524288); + for (var _i = 0; _i < properties.length; _i++) { + var targetProp = properties[_i]; + var sourceProp = getPropertyOfType(source, targetProp.name); + if (sourceProp !== targetProp) { + if (!sourceProp) { + if (!(targetProp.flags & 536870912) || requireOptionalProperties) { + if (reportErrors) { + reportError(ts.Diagnostics.Property_0_is_missing_in_type_1, symbolToString(targetProp), typeToString(source)); + } + return 0; + } + } + else if (!(targetProp.flags & 134217728)) { + var sourcePropFlags = getDeclarationFlagsFromSymbol(sourceProp); + var targetPropFlags = getDeclarationFlagsFromSymbol(targetProp); + if (sourcePropFlags & 32 || targetPropFlags & 32) { + if (sourceProp.valueDeclaration !== targetProp.valueDeclaration) { + if (reportErrors) { + if (sourcePropFlags & 32 && targetPropFlags & 32) { + reportError(ts.Diagnostics.Types_have_separate_declarations_of_a_private_property_0, symbolToString(targetProp)); + } + else { + reportError(ts.Diagnostics.Property_0_is_private_in_type_1_but_not_in_type_2, symbolToString(targetProp), typeToString(sourcePropFlags & 32 ? source : target), typeToString(sourcePropFlags & 32 ? target : source)); + } + } + return 0; + } + } + else if (targetPropFlags & 64) { + var sourceDeclaredInClass = sourceProp.parent && sourceProp.parent.flags & 32; + var sourceClass = sourceDeclaredInClass ? getDeclaredTypeOfSymbol(sourceProp.parent) : undefined; + var targetClass = getDeclaredTypeOfSymbol(targetProp.parent); + if (!sourceClass || !hasBaseType(sourceClass, targetClass)) { + if (reportErrors) { + reportError(ts.Diagnostics.Property_0_is_protected_but_type_1_is_not_a_class_derived_from_2, symbolToString(targetProp), typeToString(sourceClass || source), typeToString(targetClass)); + } + return 0; + } + } + else if (sourcePropFlags & 64) { + if (reportErrors) { + reportError(ts.Diagnostics.Property_0_is_protected_in_type_1_but_public_in_type_2, symbolToString(targetProp), typeToString(source), typeToString(target)); + } + return 0; + } + var related = isRelatedTo(getTypeOfSymbol(sourceProp), getTypeOfSymbol(targetProp), reportErrors); + if (!related) { + if (reportErrors) { + reportError(ts.Diagnostics.Types_of_property_0_are_incompatible, symbolToString(targetProp)); + } + return 0; + } + result &= related; + if (sourceProp.flags & 536870912 && !(targetProp.flags & 536870912)) { + if (reportErrors) { + reportError(ts.Diagnostics.Property_0_is_optional_in_type_1_but_required_in_type_2, symbolToString(targetProp), typeToString(source), typeToString(target)); + } + return 0; + } + } + } + } + return result; + } + function propertiesIdenticalTo(source, target) { + if (!(source.flags & 80896 && target.flags & 80896)) { + return 0; + } + var sourceProperties = getPropertiesOfObjectType(source); + var targetProperties = getPropertiesOfObjectType(target); + if (sourceProperties.length !== targetProperties.length) { + return 0; + } + var result = -1; + for (var _i = 0; _i < sourceProperties.length; _i++) { + var sourceProp = sourceProperties[_i]; + var targetProp = getPropertyOfObjectType(target, sourceProp.name); + if (!targetProp) { + return 0; + } + var related = compareProperties(sourceProp, targetProp, isRelatedTo); + if (!related) { + return 0; + } + result &= related; + } + return result; + } + function signaturesRelatedTo(source, target, kind, reportErrors) { + if (relation === identityRelation) { + return signaturesIdenticalTo(source, target, kind); + } + if (target === anyFunctionType || source === anyFunctionType) { + return -1; + } + var sourceSignatures = getSignaturesOfType(source, kind); + var targetSignatures = getSignaturesOfType(target, kind); + var result = -1; + var saveErrorInfo = errorInfo; + if (kind === 1) { + var sourceSig = sourceSignatures[0]; + var targetSig = targetSignatures[0]; + result &= abstractSignatureRelatedTo(source, sourceSig, target, targetSig); + if (result !== -1) { + return result; + } + } + outer: for (var _i = 0; _i < targetSignatures.length; _i++) { + var t = targetSignatures[_i]; + if (!t.hasStringLiterals || target.flags & 262144) { + var localErrors = reportErrors; + var checkedAbstractAssignability = false; + for (var _a = 0; _a < sourceSignatures.length; _a++) { + var s = sourceSignatures[_a]; + if (!s.hasStringLiterals || source.flags & 262144) { + var related = signatureRelatedTo(s, t, localErrors); + if (related) { + result &= related; + errorInfo = saveErrorInfo; + continue outer; + } + localErrors = false; + } + } + return 0; + } + } + return result; + function abstractSignatureRelatedTo(source, sourceSig, target, targetSig) { + if (sourceSig && targetSig) { + var sourceDecl = source.symbol && getClassLikeDeclarationOfSymbol(source.symbol); + var targetDecl = target.symbol && getClassLikeDeclarationOfSymbol(target.symbol); + if (!sourceDecl) { + return -1; + } + var sourceErasedSignature = getErasedSignature(sourceSig); + var targetErasedSignature = getErasedSignature(targetSig); + var sourceReturnType = sourceErasedSignature && getReturnTypeOfSignature(sourceErasedSignature); + var targetReturnType = targetErasedSignature && getReturnTypeOfSignature(targetErasedSignature); + var sourceReturnDecl = sourceReturnType && sourceReturnType.symbol && getClassLikeDeclarationOfSymbol(sourceReturnType.symbol); + var targetReturnDecl = targetReturnType && targetReturnType.symbol && getClassLikeDeclarationOfSymbol(targetReturnType.symbol); + var sourceIsAbstract = sourceReturnDecl && sourceReturnDecl.flags & 256; + var targetIsAbstract = targetReturnDecl && targetReturnDecl.flags & 256; + if (sourceIsAbstract && !(targetIsAbstract && targetDecl)) { + if (reportErrors) { + reportError(ts.Diagnostics.Cannot_assign_an_abstract_constructor_type_to_a_non_abstract_constructor_type); + } + return 0; + } + } + return -1; + } + } + function signatureRelatedTo(source, target, reportErrors) { + if (source === target) { + return -1; + } + if (!target.hasRestParameter && source.minArgumentCount > target.parameters.length) { + return 0; + } + var sourceMax = source.parameters.length; + var targetMax = target.parameters.length; + var checkCount; + if (source.hasRestParameter && target.hasRestParameter) { + checkCount = sourceMax > targetMax ? sourceMax : targetMax; + sourceMax--; + targetMax--; + } + else if (source.hasRestParameter) { + sourceMax--; + checkCount = targetMax; + } + else if (target.hasRestParameter) { + targetMax--; + checkCount = sourceMax; + } + else { + checkCount = sourceMax < targetMax ? sourceMax : targetMax; + } + source = getErasedSignature(source); + target = getErasedSignature(target); + var result = -1; + for (var i = 0; i < checkCount; i++) { + var s = i < sourceMax ? getTypeOfSymbol(source.parameters[i]) : getRestTypeOfSignature(source); + var t = i < targetMax ? getTypeOfSymbol(target.parameters[i]) : getRestTypeOfSignature(target); + var saveErrorInfo = errorInfo; + var related = isRelatedTo(s, t, reportErrors); + if (!related) { + related = isRelatedTo(t, s, false); + if (!related) { + if (reportErrors) { + reportError(ts.Diagnostics.Types_of_parameters_0_and_1_are_incompatible, source.parameters[i < sourceMax ? i : sourceMax].name, target.parameters[i < targetMax ? i : targetMax].name); + } + return 0; + } + errorInfo = saveErrorInfo; + } + result &= related; + } + if (source.typePredicate && target.typePredicate) { + var hasDifferentParameterIndex = source.typePredicate.parameterIndex !== target.typePredicate.parameterIndex; + var hasDifferentTypes; + if (hasDifferentParameterIndex || + (hasDifferentTypes = !isTypeIdenticalTo(source.typePredicate.type, target.typePredicate.type))) { + if (reportErrors) { + var sourceParamText = source.typePredicate.parameterName; + var targetParamText = target.typePredicate.parameterName; + var sourceTypeText = typeToString(source.typePredicate.type); + var targetTypeText = typeToString(target.typePredicate.type); + if (hasDifferentParameterIndex) { + reportError(ts.Diagnostics.Parameter_0_is_not_in_the_same_position_as_parameter_1, sourceParamText, targetParamText); + } + else if (hasDifferentTypes) { + reportError(ts.Diagnostics.Type_0_is_not_assignable_to_type_1, sourceTypeText, targetTypeText); + } + reportError(ts.Diagnostics.Type_predicate_0_is_not_assignable_to_1, sourceParamText + " is " + sourceTypeText, targetParamText + " is " + targetTypeText); + } + return 0; + } + } + else if (!source.typePredicate && target.typePredicate) { + if (reportErrors) { + reportError(ts.Diagnostics.Signature_0_must_have_a_type_predicate, signatureToString(source)); + } + return 0; + } + var targetReturnType = getReturnTypeOfSignature(target); + if (targetReturnType === voidType) + return result; + var sourceReturnType = getReturnTypeOfSignature(source); + return result & isRelatedTo(sourceReturnType, targetReturnType, reportErrors); + } + function signaturesIdenticalTo(source, target, kind) { + var sourceSignatures = getSignaturesOfType(source, kind); + var targetSignatures = getSignaturesOfType(target, kind); + if (sourceSignatures.length !== targetSignatures.length) { + return 0; + } + var result = -1; + for (var i = 0, len = sourceSignatures.length; i < len; ++i) { + var related = compareSignatures(sourceSignatures[i], targetSignatures[i], false, false, isRelatedTo); + if (!related) { + return 0; + } + result &= related; + } + return result; + } + function stringIndexTypesRelatedTo(source, originalSource, target, reportErrors) { + if (relation === identityRelation) { + return indexTypesIdenticalTo(0, source, target); + } + var targetType = getIndexTypeOfType(target, 0); + if (targetType) { + if ((targetType.flags & 1) && !(originalSource.flags & 16777726)) { + return -1; + } + var sourceType = getIndexTypeOfType(source, 0); + if (!sourceType) { + if (reportErrors) { + reportError(ts.Diagnostics.Index_signature_is_missing_in_type_0, typeToString(source)); + } + return 0; + } + var related = isRelatedTo(sourceType, targetType, reportErrors); + if (!related) { + if (reportErrors) { + reportError(ts.Diagnostics.Index_signatures_are_incompatible); + } + return 0; + } + return related; + } + return -1; + } + function numberIndexTypesRelatedTo(source, originalSource, target, reportErrors) { + if (relation === identityRelation) { + return indexTypesIdenticalTo(1, source, target); + } + var targetType = getIndexTypeOfType(target, 1); + if (targetType) { + if ((targetType.flags & 1) && !(originalSource.flags & 16777726)) { + return -1; + } + var sourceStringType = getIndexTypeOfType(source, 0); + var sourceNumberType = getIndexTypeOfType(source, 1); + if (!(sourceStringType || sourceNumberType)) { + if (reportErrors) { + reportError(ts.Diagnostics.Index_signature_is_missing_in_type_0, typeToString(source)); + } + return 0; + } + var related; + if (sourceStringType && sourceNumberType) { + related = isRelatedTo(sourceStringType, targetType, false) || isRelatedTo(sourceNumberType, targetType, reportErrors); + } + else { + related = isRelatedTo(sourceStringType || sourceNumberType, targetType, reportErrors); + } + if (!related) { + if (reportErrors) { + reportError(ts.Diagnostics.Index_signatures_are_incompatible); + } + return 0; + } + return related; + } + return -1; + } + function indexTypesIdenticalTo(indexKind, source, target) { + var targetType = getIndexTypeOfType(target, indexKind); + var sourceType = getIndexTypeOfType(source, indexKind); + if (!sourceType && !targetType) { + return -1; + } + if (sourceType && targetType) { + return isRelatedTo(sourceType, targetType); + } + return 0; + } + } + function isDeeplyNestedGeneric(type, stack, depth) { + if (type.flags & (4096 | 131072) && depth >= 5) { + var symbol = type.symbol; + var count = 0; + for (var i = 0; i < depth; i++) { + var t = stack[i]; + if (t.flags & (4096 | 131072) && t.symbol === symbol) { + count++; + if (count >= 5) + return true; + } + } + } + return false; + } + function isPropertyIdenticalTo(sourceProp, targetProp) { + return compareProperties(sourceProp, targetProp, compareTypes) !== 0; + } + function compareProperties(sourceProp, targetProp, compareTypes) { + if (sourceProp === targetProp) { + return -1; + } + var sourcePropAccessibility = getDeclarationFlagsFromSymbol(sourceProp) & (32 | 64); + var targetPropAccessibility = getDeclarationFlagsFromSymbol(targetProp) & (32 | 64); + if (sourcePropAccessibility !== targetPropAccessibility) { + return 0; + } + if (sourcePropAccessibility) { + if (getTargetSymbol(sourceProp) !== getTargetSymbol(targetProp)) { + return 0; + } + } + else { + if ((sourceProp.flags & 536870912) !== (targetProp.flags & 536870912)) { + return 0; + } + } + return compareTypes(getTypeOfSymbol(sourceProp), getTypeOfSymbol(targetProp)); + } + function compareSignatures(source, target, partialMatch, ignoreReturnTypes, compareTypes) { + if (source === target) { + return -1; + } + if (source.parameters.length !== target.parameters.length || + source.minArgumentCount !== target.minArgumentCount || + source.hasRestParameter !== target.hasRestParameter) { + if (!partialMatch || + source.parameters.length < target.parameters.length && !source.hasRestParameter || + source.minArgumentCount > target.minArgumentCount) { + return 0; + } + } + var result = -1; + if (source.typeParameters && target.typeParameters) { + if (source.typeParameters.length !== target.typeParameters.length) { + return 0; + } + for (var i = 0, len = source.typeParameters.length; i < len; ++i) { + var related = compareTypes(source.typeParameters[i], target.typeParameters[i]); + if (!related) { + return 0; + } + result &= related; + } + } + else if (source.typeParameters || target.typeParameters) { + return 0; + } + source = getErasedSignature(source); + target = getErasedSignature(target); + var targetLen = target.parameters.length; + for (var i = 0; i < targetLen; i++) { + var s = isRestParameterIndex(source, i) ? getRestTypeOfSignature(source) : getTypeOfSymbol(source.parameters[i]); + var t = isRestParameterIndex(target, i) ? getRestTypeOfSignature(target) : getTypeOfSymbol(target.parameters[i]); + var related = compareTypes(s, t); + if (!related) { + return 0; + } + result &= related; + } + if (!ignoreReturnTypes) { + result &= compareTypes(getReturnTypeOfSignature(source), getReturnTypeOfSignature(target)); + } + return result; + } + function isRestParameterIndex(signature, parameterIndex) { + return signature.hasRestParameter && parameterIndex >= signature.parameters.length - 1; + } + function isSupertypeOfEach(candidate, types) { + for (var _i = 0; _i < types.length; _i++) { + var type = types[_i]; + if (candidate !== type && !isTypeSubtypeOf(type, candidate)) + return false; + } + return true; + } + function getCommonSupertype(types) { + return ts.forEach(types, function (t) { return isSupertypeOfEach(t, types) ? t : undefined; }); + } + function reportNoCommonSupertypeError(types, errorLocation, errorMessageChainHead) { + var bestSupertype; + var bestSupertypeDownfallType; + var bestSupertypeScore = 0; + for (var i = 0; i < types.length; i++) { + var score = 0; + var downfallType = undefined; + for (var j = 0; j < types.length; j++) { + if (isTypeSubtypeOf(types[j], types[i])) { + score++; + } + else if (!downfallType) { + downfallType = types[j]; + } + } + ts.Debug.assert(!!downfallType, "If there is no common supertype, each type should have a downfallType"); + if (score > bestSupertypeScore) { + bestSupertype = types[i]; + bestSupertypeDownfallType = downfallType; + bestSupertypeScore = score; + } + if (bestSupertypeScore === types.length - 1) { + break; + } + } + checkTypeSubtypeOf(bestSupertypeDownfallType, bestSupertype, errorLocation, ts.Diagnostics.Type_argument_candidate_1_is_not_a_valid_type_argument_because_it_is_not_a_supertype_of_candidate_0, errorMessageChainHead); + } + function isArrayType(type) { + return type.flags & 4096 && type.target === globalArrayType; + } + function isArrayLikeType(type) { + return !(type.flags & (32 | 64)) && isTypeAssignableTo(type, anyArrayType); + } + function isTupleLikeType(type) { + return !!getPropertyOfType(type, "0"); + } + function isTupleType(type) { + return !!(type.flags & 8192); + } + function getRegularTypeOfObjectLiteral(type) { + if (type.flags & 1048576) { + var regularType = type.regularType; + if (!regularType) { + regularType = createType(type.flags & ~1048576); + regularType.symbol = type.symbol; + regularType.members = type.members; + regularType.properties = type.properties; + regularType.callSignatures = type.callSignatures; + regularType.constructSignatures = type.constructSignatures; + regularType.stringIndexType = type.stringIndexType; + regularType.numberIndexType = type.numberIndexType; + type.regularType = regularType; + } + return regularType; + } + return type; + } + function getWidenedTypeOfObjectLiteral(type) { + var properties = getPropertiesOfObjectType(type); + var members = {}; + ts.forEach(properties, function (p) { + var propType = getTypeOfSymbol(p); + var widenedType = getWidenedType(propType); + if (propType !== widenedType) { + var symbol = createSymbol(p.flags | 67108864, p.name); + symbol.declarations = p.declarations; + symbol.parent = p.parent; + symbol.type = widenedType; + symbol.target = p; + if (p.valueDeclaration) + symbol.valueDeclaration = p.valueDeclaration; + p = symbol; + } + members[p.name] = p; + }); + var stringIndexType = getIndexTypeOfType(type, 0); + var numberIndexType = getIndexTypeOfType(type, 1); + if (stringIndexType) + stringIndexType = getWidenedType(stringIndexType); + if (numberIndexType) + numberIndexType = getWidenedType(numberIndexType); + return createAnonymousType(type.symbol, members, emptyArray, emptyArray, stringIndexType, numberIndexType); + } + function getWidenedType(type) { + if (type.flags & 6291456) { + if (type.flags & (32 | 64)) { + return anyType; + } + if (type.flags & 524288) { + return getWidenedTypeOfObjectLiteral(type); + } + if (type.flags & 16384) { + return getUnionType(ts.map(type.types, getWidenedType), true); + } + if (isArrayType(type)) { + return createArrayType(getWidenedType(type.typeArguments[0])); + } + if (isTupleType(type)) { + return createTupleType(ts.map(type.elementTypes, getWidenedType)); + } + } + return type; + } + function reportWideningErrorsInType(type) { + var errorReported = false; + if (type.flags & 16384) { + for (var _i = 0, _a = type.types; _i < _a.length; _i++) { + var t = _a[_i]; + if (reportWideningErrorsInType(t)) { + errorReported = true; + } + } + } + if (isArrayType(type)) { + return reportWideningErrorsInType(type.typeArguments[0]); + } + if (isTupleType(type)) { + for (var _b = 0, _c = type.elementTypes; _b < _c.length; _b++) { + var t = _c[_b]; + if (reportWideningErrorsInType(t)) { + errorReported = true; + } + } + } + if (type.flags & 524288) { + for (var _d = 0, _e = getPropertiesOfObjectType(type); _d < _e.length; _d++) { + var p = _e[_d]; + var t = getTypeOfSymbol(p); + if (t.flags & 2097152) { + if (!reportWideningErrorsInType(t)) { + error(p.valueDeclaration, ts.Diagnostics.Object_literal_s_property_0_implicitly_has_an_1_type, p.name, typeToString(getWidenedType(t))); + } + errorReported = true; + } + } + } + return errorReported; + } + function reportImplicitAnyError(declaration, type) { + var typeAsString = typeToString(getWidenedType(type)); + var diagnostic; + switch (declaration.kind) { + case 141: + case 140: + diagnostic = ts.Diagnostics.Member_0_implicitly_has_an_1_type; + break; + case 138: + diagnostic = declaration.dotDotDotToken ? + ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type : + ts.Diagnostics.Parameter_0_implicitly_has_an_1_type; + break; + case 213: + case 143: + case 142: + case 145: + case 146: + case 173: + case 174: + if (!declaration.name) { + error(declaration, ts.Diagnostics.Function_expression_which_lacks_return_type_annotation_implicitly_has_an_0_return_type, typeAsString); + return; + } + diagnostic = ts.Diagnostics._0_which_lacks_return_type_annotation_implicitly_has_an_1_return_type; + break; + default: + diagnostic = ts.Diagnostics.Variable_0_implicitly_has_an_1_type; + } + error(declaration, diagnostic, ts.declarationNameToString(declaration.name), typeAsString); + } + function reportErrorsFromWidening(declaration, type) { + if (produceDiagnostics && compilerOptions.noImplicitAny && type.flags & 2097152) { + if (!reportWideningErrorsInType(type)) { + reportImplicitAnyError(declaration, type); + } + } + } + function forEachMatchingParameterType(source, target, callback) { + var sourceMax = source.parameters.length; + var targetMax = target.parameters.length; + var count; + if (source.hasRestParameter && target.hasRestParameter) { + count = sourceMax > targetMax ? sourceMax : targetMax; + sourceMax--; + targetMax--; + } + else if (source.hasRestParameter) { + sourceMax--; + count = targetMax; + } + else if (target.hasRestParameter) { + targetMax--; + count = sourceMax; + } + else { + count = sourceMax < targetMax ? sourceMax : targetMax; + } + for (var i = 0; i < count; i++) { + var s = i < sourceMax ? getTypeOfSymbol(source.parameters[i]) : getRestTypeOfSignature(source); + var t = i < targetMax ? getTypeOfSymbol(target.parameters[i]) : getRestTypeOfSignature(target); + callback(s, t); + } + } + function createInferenceContext(typeParameters, inferUnionTypes) { + var inferences = []; + for (var _i = 0; _i < typeParameters.length; _i++) { + var unused = typeParameters[_i]; + inferences.push({ + primary: undefined, secondary: undefined, isFixed: false + }); + } + return { + typeParameters: typeParameters, + inferUnionTypes: inferUnionTypes, + inferences: inferences, + inferredTypes: new Array(typeParameters.length) + }; + } + function inferTypes(context, source, target) { + var sourceStack; + var targetStack; + var depth = 0; + var inferiority = 0; + inferFromTypes(source, target); + function isInProcess(source, target) { + for (var i = 0; i < depth; i++) { + if (source === sourceStack[i] && target === targetStack[i]) { + return true; + } + } + return false; + } + function inferFromTypes(source, target) { + if (target.flags & 512) { + if (source.flags & 8388608) { + return; + } + var typeParameters = context.typeParameters; + for (var i = 0; i < typeParameters.length; i++) { + if (target === typeParameters[i]) { + var inferences = context.inferences[i]; + if (!inferences.isFixed) { + var candidates = inferiority ? + inferences.secondary || (inferences.secondary = []) : + inferences.primary || (inferences.primary = []); + if (!ts.contains(candidates, source)) { + candidates.push(source); + } + } + return; + } + } + } + else if (source.flags & 4096 && target.flags & 4096 && source.target === target.target) { + var sourceTypes = source.typeArguments || emptyArray; + var targetTypes = target.typeArguments || emptyArray; + var count = sourceTypes.length < targetTypes.length ? sourceTypes.length : targetTypes.length; + for (var i = 0; i < count; i++) { + inferFromTypes(sourceTypes[i], targetTypes[i]); + } + } + else if (source.flags & 8192 && target.flags & 8192 && source.elementTypes.length === target.elementTypes.length) { + var sourceTypes = source.elementTypes; + var targetTypes = target.elementTypes; + for (var i = 0; i < sourceTypes.length; i++) { + inferFromTypes(sourceTypes[i], targetTypes[i]); + } + } + else if (target.flags & 49152) { + var targetTypes = target.types; + var typeParameterCount = 0; + var typeParameter; + for (var _i = 0; _i < targetTypes.length; _i++) { + var t = targetTypes[_i]; + if (t.flags & 512 && ts.contains(context.typeParameters, t)) { + typeParameter = t; + typeParameterCount++; + } + else { + inferFromTypes(source, t); + } + } + if (target.flags & 16384 && typeParameterCount === 1) { + inferiority++; + inferFromTypes(source, typeParameter); + inferiority--; + } + } + else if (source.flags & 49152) { + var sourceTypes = source.types; + for (var _a = 0; _a < sourceTypes.length; _a++) { + var sourceType = sourceTypes[_a]; + inferFromTypes(sourceType, target); + } + } + else { + source = getApparentType(source); + if (source.flags & 80896 && (target.flags & (4096 | 8192) || + (target.flags & 65536) && target.symbol && target.symbol.flags & (8192 | 2048 | 32))) { + if (isInProcess(source, target)) { + return; + } + if (isDeeplyNestedGeneric(source, sourceStack, depth) && isDeeplyNestedGeneric(target, targetStack, depth)) { + return; + } + if (depth === 0) { + sourceStack = []; + targetStack = []; + } + sourceStack[depth] = source; + targetStack[depth] = target; + depth++; + inferFromProperties(source, target); + inferFromSignatures(source, target, 0); + inferFromSignatures(source, target, 1); + inferFromIndexTypes(source, target, 0, 0); + inferFromIndexTypes(source, target, 1, 1); + inferFromIndexTypes(source, target, 0, 1); + depth--; + } + } + } + function inferFromProperties(source, target) { + var properties = getPropertiesOfObjectType(target); + for (var _i = 0; _i < properties.length; _i++) { + var targetProp = properties[_i]; + var sourceProp = getPropertyOfObjectType(source, targetProp.name); + if (sourceProp) { + inferFromTypes(getTypeOfSymbol(sourceProp), getTypeOfSymbol(targetProp)); + } + } + } + function inferFromSignatures(source, target, kind) { + var sourceSignatures = getSignaturesOfType(source, kind); + var targetSignatures = getSignaturesOfType(target, kind); + var sourceLen = sourceSignatures.length; + var targetLen = targetSignatures.length; + var len = sourceLen < targetLen ? sourceLen : targetLen; + for (var i = 0; i < len; i++) { + inferFromSignature(getErasedSignature(sourceSignatures[sourceLen - len + i]), getErasedSignature(targetSignatures[targetLen - len + i])); + } + } + function inferFromSignature(source, target) { + forEachMatchingParameterType(source, target, inferFromTypes); + if (source.typePredicate && target.typePredicate) { + if (target.typePredicate.parameterIndex === source.typePredicate.parameterIndex) { + inferFromTypes(source.typePredicate.type, target.typePredicate.type); + } + } + else { + inferFromTypes(getReturnTypeOfSignature(source), getReturnTypeOfSignature(target)); + } + } + function inferFromIndexTypes(source, target, sourceKind, targetKind) { + var targetIndexType = getIndexTypeOfType(target, targetKind); + if (targetIndexType) { + var sourceIndexType = getIndexTypeOfType(source, sourceKind); + if (sourceIndexType) { + inferFromTypes(sourceIndexType, targetIndexType); + } + } + } + } + function getInferenceCandidates(context, index) { + var inferences = context.inferences[index]; + return inferences.primary || inferences.secondary || emptyArray; + } + function getInferredType(context, index) { + var inferredType = context.inferredTypes[index]; + var inferenceSucceeded; + if (!inferredType) { + var inferences = getInferenceCandidates(context, index); + if (inferences.length) { + var unionOrSuperType = context.inferUnionTypes ? getUnionType(inferences) : getCommonSupertype(inferences); + inferredType = unionOrSuperType ? getWidenedType(unionOrSuperType) : unknownType; + inferenceSucceeded = !!unionOrSuperType; + } + else { + inferredType = emptyObjectType; + inferenceSucceeded = true; + } + if (inferenceSucceeded) { + var constraint = getConstraintOfTypeParameter(context.typeParameters[index]); + inferredType = constraint && !isTypeAssignableTo(inferredType, constraint) ? constraint : inferredType; + } + else if (context.failedTypeParameterIndex === undefined || context.failedTypeParameterIndex > index) { + context.failedTypeParameterIndex = index; + } + context.inferredTypes[index] = inferredType; + } + return inferredType; + } + function getInferredTypes(context) { + for (var i = 0; i < context.inferredTypes.length; i++) { + getInferredType(context, i); + } + return context.inferredTypes; + } + function hasAncestor(node, kind) { + return ts.getAncestor(node, kind) !== undefined; + } + function getResolvedSymbol(node) { + var links = getNodeLinks(node); + if (!links.resolvedSymbol) { + links.resolvedSymbol = (!ts.nodeIsMissing(node) && resolveName(node, node.text, 107455 | 1048576, ts.Diagnostics.Cannot_find_name_0, node)) || unknownSymbol; + } + return links.resolvedSymbol; + } + function isInTypeQuery(node) { + while (node) { + switch (node.kind) { + case 154: + return true; + case 69: + case 135: + node = node.parent; + continue; + default: + return false; + } + } + ts.Debug.fail("should not get here"); + } + function removeTypesFromUnionType(type, typeKind, isOfTypeKind, allowEmptyUnionResult) { + if (type.flags & 16384) { + var types = type.types; + if (ts.forEach(types, function (t) { return !!(t.flags & typeKind) === isOfTypeKind; })) { + var narrowedType = getUnionType(ts.filter(types, function (t) { return !(t.flags & typeKind) === isOfTypeKind; })); + if (allowEmptyUnionResult || narrowedType !== emptyObjectType) { + return narrowedType; + } + } + } + else if (allowEmptyUnionResult && !!(type.flags & typeKind) === isOfTypeKind) { + return getUnionType(emptyArray); + } + return type; + } + function hasInitializer(node) { + return !!(node.initializer || ts.isBindingPattern(node.parent) && hasInitializer(node.parent.parent)); + } + function isVariableAssignedWithin(symbol, node) { + var links = getNodeLinks(node); + if (links.assignmentChecks) { + var cachedResult = links.assignmentChecks[symbol.id]; + if (cachedResult !== undefined) { + return cachedResult; + } + } + else { + links.assignmentChecks = {}; + } + return links.assignmentChecks[symbol.id] = isAssignedIn(node); + function isAssignedInBinaryExpression(node) { + if (node.operatorToken.kind >= 56 && node.operatorToken.kind <= 68) { + var n = node.left; + while (n.kind === 172) { + n = n.expression; + } + if (n.kind === 69 && getResolvedSymbol(n) === symbol) { + return true; + } + } + return ts.forEachChild(node, isAssignedIn); + } + function isAssignedInVariableDeclaration(node) { + if (!ts.isBindingPattern(node.name) && getSymbolOfNode(node) === symbol && hasInitializer(node)) { + return true; + } + return ts.forEachChild(node, isAssignedIn); + } + function isAssignedIn(node) { + switch (node.kind) { + case 181: + return isAssignedInBinaryExpression(node); + case 211: + case 163: + return isAssignedInVariableDeclaration(node); + case 161: + case 162: + case 164: + case 165: + case 166: + case 167: + case 168: + case 169: + case 171: + case 189: + case 172: + case 179: + case 175: + case 178: + case 176: + case 177: + case 180: + case 184: + case 182: + case 185: + case 192: + case 193: + case 195: + case 196: + case 197: + case 198: + case 199: + case 200: + case 201: + case 204: + case 205: + case 206: + case 241: + case 242: + case 207: + case 208: + case 209: + case 244: + case 233: + case 234: + case 238: + case 239: + case 235: + case 240: + return ts.forEachChild(node, isAssignedIn); + } + return false; + } + } + function getNarrowedTypeOfSymbol(symbol, node) { + var type = getTypeOfSymbol(symbol); + if (node && symbol.flags & 3) { + if (isTypeAny(type) || type.flags & (80896 | 16384 | 512)) { + loop: while (node.parent) { + var child = node; + node = node.parent; + var narrowedType = type; + switch (node.kind) { + case 196: + if (child !== node.expression) { + narrowedType = narrowType(type, node.expression, child === node.thenStatement); + } + break; + case 182: + if (child !== node.condition) { + narrowedType = narrowType(type, node.condition, child === node.whenTrue); + } + break; + case 181: + if (child === node.right) { + if (node.operatorToken.kind === 51) { + narrowedType = narrowType(type, node.left, true); + } + else if (node.operatorToken.kind === 52) { + narrowedType = narrowType(type, node.left, false); + } + } + break; + case 248: + case 218: + case 213: + case 143: + case 142: + case 145: + case 146: + case 144: + break loop; + } + if (narrowedType !== type) { + if (isVariableAssignedWithin(symbol, node)) { + break; + } + type = narrowedType; + } + } + } + } + return type; + function narrowTypeByEquality(type, expr, assumeTrue) { + if (expr.left.kind !== 176 || expr.right.kind !== 9) { + return type; + } + var left = expr.left; + var right = expr.right; + if (left.expression.kind !== 69 || getResolvedSymbol(left.expression) !== symbol) { + return type; + } + var typeInfo = primitiveTypeInfo[right.text]; + if (expr.operatorToken.kind === 33) { + assumeTrue = !assumeTrue; + } + if (assumeTrue) { + if (!typeInfo) { + return removeTypesFromUnionType(type, 258 | 132 | 8 | 16777216, true, false); + } + if (isTypeSubtypeOf(typeInfo.type, type)) { + return typeInfo.type; + } + return removeTypesFromUnionType(type, typeInfo.flags, false, false); + } + else { + if (typeInfo) { + return removeTypesFromUnionType(type, typeInfo.flags, true, false); + } + return type; + } + } + function narrowTypeByAnd(type, expr, assumeTrue) { + if (assumeTrue) { + return narrowType(narrowType(type, expr.left, true), expr.right, true); + } + else { + return getUnionType([ + narrowType(type, expr.left, false), + narrowType(narrowType(type, expr.left, true), expr.right, false) + ]); + } + } + function narrowTypeByOr(type, expr, assumeTrue) { + if (assumeTrue) { + return getUnionType([ + narrowType(type, expr.left, true), + narrowType(narrowType(type, expr.left, false), expr.right, true) + ]); + } + else { + return narrowType(narrowType(type, expr.left, false), expr.right, false); + } + } + function narrowTypeByInstanceof(type, expr, assumeTrue) { + if (isTypeAny(type) || !assumeTrue || expr.left.kind !== 69 || getResolvedSymbol(expr.left) !== symbol) { + return type; + } + var rightType = checkExpression(expr.right); + if (!isTypeSubtypeOf(rightType, globalFunctionType)) { + return type; + } + var targetType; + var prototypeProperty = getPropertyOfType(rightType, "prototype"); + if (prototypeProperty) { + var prototypePropertyType = getTypeOfSymbol(prototypeProperty); + if (!isTypeAny(prototypePropertyType)) { + targetType = prototypePropertyType; + } + } + if (!targetType) { + var constructSignatures; + if (rightType.flags & 2048) { + constructSignatures = resolveDeclaredMembers(rightType).declaredConstructSignatures; + } + else if (rightType.flags & 65536) { + constructSignatures = getSignaturesOfType(rightType, 1); + } + if (constructSignatures && constructSignatures.length) { + targetType = getUnionType(ts.map(constructSignatures, function (signature) { return getReturnTypeOfSignature(getErasedSignature(signature)); })); + } + } + if (targetType) { + return getNarrowedType(type, targetType); + } + return type; + } + function getNarrowedType(originalType, narrowedTypeCandidate) { + if (originalType.flags & 16384) { + var assignableConstituents = ts.filter(originalType.types, function (t) { return isTypeAssignableTo(t, narrowedTypeCandidate); }); + if (assignableConstituents.length) { + return getUnionType(assignableConstituents); + } + } + if (isTypeAssignableTo(narrowedTypeCandidate, originalType)) { + return narrowedTypeCandidate; + } + return originalType; + } + function narrowTypeByTypePredicate(type, expr, assumeTrue) { + if (type.flags & 1) { + return type; + } + var signature = getResolvedSignature(expr); + if (signature.typePredicate && + expr.arguments[signature.typePredicate.parameterIndex] && + getSymbolAtLocation(expr.arguments[signature.typePredicate.parameterIndex]) === symbol) { + if (!assumeTrue) { + if (type.flags & 16384) { + return getUnionType(ts.filter(type.types, function (t) { return !isTypeSubtypeOf(t, signature.typePredicate.type); })); + } + return type; + } + return getNarrowedType(type, signature.typePredicate.type); + } + return type; + } + function narrowType(type, expr, assumeTrue) { + switch (expr.kind) { + case 168: + return narrowTypeByTypePredicate(type, expr, assumeTrue); + case 172: + return narrowType(type, expr.expression, assumeTrue); + case 181: + var operator = expr.operatorToken.kind; + if (operator === 32 || operator === 33) { + return narrowTypeByEquality(type, expr, assumeTrue); + } + else if (operator === 51) { + return narrowTypeByAnd(type, expr, assumeTrue); + } + else if (operator === 52) { + return narrowTypeByOr(type, expr, assumeTrue); + } + else if (operator === 91) { + return narrowTypeByInstanceof(type, expr, assumeTrue); + } + break; + case 179: + if (expr.operator === 49) { + return narrowType(type, expr.operand, !assumeTrue); + } + break; + } + return type; + } + } + function checkIdentifier(node) { + var symbol = getResolvedSymbol(node); + if (symbol === argumentsSymbol) { + var container = ts.getContainingFunction(node); + if (container.kind === 174) { + if (languageVersion < 2) { + error(node, ts.Diagnostics.The_arguments_object_cannot_be_referenced_in_an_arrow_function_in_ES3_and_ES5_Consider_using_a_standard_function_expression); + } + } + if (node.parserContextFlags & 8) { + getNodeLinks(container).flags |= 4096; + getNodeLinks(node).flags |= 2048; + } + } + if (symbol.flags & 8388608 && !isInTypeQuery(node) && !isConstEnumOrConstEnumOnlyModule(resolveAlias(symbol))) { + markAliasSymbolAsReferenced(symbol); + } + checkCollisionWithCapturedSuperVariable(node, node); + checkCollisionWithCapturedThisVariable(node, node); + checkBlockScopedBindingCapturedInLoop(node, symbol); + return getNarrowedTypeOfSymbol(getExportSymbolOfValueSymbolIfExported(symbol), node); + } + function isInsideFunction(node, threshold) { + var current = node; + while (current && current !== threshold) { + if (ts.isFunctionLike(current)) { + return true; + } + current = current.parent; + } + return false; + } + function checkBlockScopedBindingCapturedInLoop(node, symbol) { + if (languageVersion >= 2 || + (symbol.flags & (2 | 32)) === 0 || + symbol.valueDeclaration.parent.kind === 244) { + return; + } + var container; + if (symbol.flags & 32) { + container = getClassLikeDeclarationOfSymbol(symbol).parent; + } + else { + container = symbol.valueDeclaration; + while (container.kind !== 212) { + container = container.parent; + } + container = container.parent; + if (container.kind === 193) { + container = container.parent; + } + } + var inFunction = isInsideFunction(node.parent, container); + var current = container; + while (current && !ts.nodeStartsNewLexicalEnvironment(current)) { + if (ts.isIterationStatement(current, false)) { + if (inFunction) { + getNodeLinks(current).flags |= 65536; + } + getNodeLinks(symbol.valueDeclaration).flags |= 16384; + break; + } + current = current.parent; + } + } + function captureLexicalThis(node, container) { + getNodeLinks(node).flags |= 2; + if (container.kind === 141 || container.kind === 144) { + var classNode = container.parent; + getNodeLinks(classNode).flags |= 4; + } + else { + getNodeLinks(container).flags |= 4; + } + } + function checkThisExpression(node) { + var container = ts.getThisContainer(node, true); + var needToCaptureLexicalThis = false; + if (container.kind === 174) { + container = ts.getThisContainer(container, false); + needToCaptureLexicalThis = (languageVersion < 2); + } + switch (container.kind) { + case 218: + error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_module_or_namespace_body); + break; + case 217: + error(node, ts.Diagnostics.this_cannot_be_referenced_in_current_location); + break; + case 144: + if (isInConstructorArgumentInitializer(node, container)) { + error(node, ts.Diagnostics.this_cannot_be_referenced_in_constructor_arguments); + } + break; + case 141: + case 140: + if (container.flags & 128) { + error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_static_property_initializer); + } + break; + case 136: + error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_computed_property_name); + break; + } + if (needToCaptureLexicalThis) { + captureLexicalThis(node, container); + } + if (ts.isClassLike(container.parent)) { + var symbol = getSymbolOfNode(container.parent); + return container.flags & 128 ? getTypeOfSymbol(symbol) : getDeclaredTypeOfSymbol(symbol).thisType; + } + return anyType; + } + function isInConstructorArgumentInitializer(node, constructorDecl) { + for (var n = node; n && n !== constructorDecl; n = n.parent) { + if (n.kind === 138) { + return true; + } + } + return false; + } + function checkSuperExpression(node) { + var isCallExpression = node.parent.kind === 168 && node.parent.expression === node; + var classDeclaration = ts.getContainingClass(node); + var classType = classDeclaration && getDeclaredTypeOfSymbol(getSymbolOfNode(classDeclaration)); + var baseClassType = classType && getBaseTypes(classType)[0]; + var container = ts.getSuperContainer(node, true); + var needToCaptureLexicalThis = false; + if (!isCallExpression) { + while (container && container.kind === 174) { + container = ts.getSuperContainer(container, true); + needToCaptureLexicalThis = languageVersion < 2; + } + } + var canUseSuperExpression = isLegalUsageOfSuperExpression(container); + var nodeCheckFlag = 0; + if (canUseSuperExpression) { + if ((container.flags & 128) || isCallExpression) { + nodeCheckFlag = 512; + } + else { + nodeCheckFlag = 256; + } + getNodeLinks(node).flags |= nodeCheckFlag; + if (needToCaptureLexicalThis) { + captureLexicalThis(node.parent, container); + } + } + if (!baseClassType) { + if (!classDeclaration || !ts.getClassExtendsHeritageClauseElement(classDeclaration)) { + error(node, ts.Diagnostics.super_can_only_be_referenced_in_a_derived_class); + } + return unknownType; + } + if (!canUseSuperExpression) { + if (container && container.kind === 136) { + 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 { + error(node, ts.Diagnostics.super_property_access_is_permitted_only_in_a_constructor_member_function_or_member_accessor_of_a_derived_class); + } + return unknownType; + } + if (container.kind === 144 && isInConstructorArgumentInitializer(node, container)) { + error(node, ts.Diagnostics.super_cannot_be_referenced_in_constructor_arguments); + return unknownType; + } + return nodeCheckFlag === 512 + ? getBaseConstructorTypeOfClass(classType) + : baseClassType; + function isLegalUsageOfSuperExpression(container) { + if (!container) { + return false; + } + if (isCallExpression) { + return container.kind === 144; + } + else { + if (container && ts.isClassLike(container.parent)) { + if (container.flags & 128) { + return container.kind === 143 || + container.kind === 142 || + container.kind === 145 || + container.kind === 146; + } + else { + return container.kind === 143 || + container.kind === 142 || + container.kind === 145 || + container.kind === 146 || + container.kind === 141 || + container.kind === 140 || + container.kind === 144; + } + } + } + return false; + } + } + function getContextuallyTypedParameterType(parameter) { + var func = parameter.parent; + if (isFunctionExpressionOrArrowFunction(func) || ts.isObjectLiteralMethod(func)) { + if (isContextSensitive(func)) { + var contextualSignature = getContextualSignature(func); + if (contextualSignature) { + var funcHasRestParameters = ts.hasRestParameter(func); + var len = func.parameters.length - (funcHasRestParameters ? 1 : 0); + var indexOfParameter = ts.indexOf(func.parameters, parameter); + if (indexOfParameter < len) { + return getTypeAtPosition(contextualSignature, indexOfParameter); + } + if (funcHasRestParameters && + indexOfParameter === (func.parameters.length - 1) && + isRestParameterIndex(contextualSignature, func.parameters.length - 1)) { + return getTypeOfSymbol(ts.lastOrUndefined(contextualSignature.parameters)); + } + } + } + } + return undefined; + } + function getContextualTypeForInitializerExpression(node) { + var declaration = node.parent; + if (node === declaration.initializer) { + if (declaration.type) { + return getTypeFromTypeNode(declaration.type); + } + if (declaration.kind === 138) { + var type = getContextuallyTypedParameterType(declaration); + if (type) { + return type; + } + } + if (ts.isBindingPattern(declaration.name)) { + return getTypeFromBindingPattern(declaration.name, true); + } + } + return undefined; + } + function getContextualTypeForReturnExpression(node) { + var func = ts.getContainingFunction(node); + if (func && !func.asteriskToken) { + return getContextualReturnType(func); + } + return undefined; + } + function getContextualTypeForYieldOperand(node) { + var func = ts.getContainingFunction(node); + if (func) { + var contextualReturnType = getContextualReturnType(func); + if (contextualReturnType) { + return node.asteriskToken + ? contextualReturnType + : getElementTypeOfIterableIterator(contextualReturnType); + } + } + return undefined; + } + function isInParameterInitializerBeforeContainingFunction(node) { + while (node.parent && !ts.isFunctionLike(node.parent)) { + if (node.parent.kind === 138 && node.parent.initializer === node) { + return true; + } + node = node.parent; + } + return false; + } + function getContextualReturnType(functionDecl) { + if (functionDecl.type || + functionDecl.kind === 144 || + functionDecl.kind === 145 && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(functionDecl.symbol, 146))) { + return getReturnTypeOfSignature(getSignatureFromDeclaration(functionDecl)); + } + var signature = getContextualSignatureForFunctionLikeDeclaration(functionDecl); + if (signature) { + return getReturnTypeOfSignature(signature); + } + return undefined; + } + function getContextualTypeForArgument(callTarget, arg) { + var args = getEffectiveCallArguments(callTarget); + var argIndex = ts.indexOf(args, arg); + if (argIndex >= 0) { + var signature = getResolvedSignature(callTarget); + return getTypeAtPosition(signature, argIndex); + } + return undefined; + } + function getContextualTypeForSubstitutionExpression(template, substitutionExpression) { + if (template.parent.kind === 170) { + return getContextualTypeForArgument(template.parent, substitutionExpression); + } + return undefined; + } + function getContextualTypeForBinaryOperand(node) { + var binaryExpression = node.parent; + var operator = binaryExpression.operatorToken.kind; + if (operator >= 56 && operator <= 68) { + if (node === binaryExpression.right) { + return checkExpression(binaryExpression.left); + } + } + else if (operator === 52) { + var type = getContextualType(binaryExpression); + if (!type && node === binaryExpression.right) { + type = checkExpression(binaryExpression.left); + } + return type; + } + return undefined; + } + function applyToContextualType(type, mapper) { + if (!(type.flags & 16384)) { + return mapper(type); + } + var types = type.types; + var mappedType; + var mappedTypes; + for (var _i = 0; _i < types.length; _i++) { + var current = types[_i]; + var t = mapper(current); + if (t) { + if (!mappedType) { + mappedType = t; + } + else if (!mappedTypes) { + mappedTypes = [mappedType, t]; + } + else { + mappedTypes.push(t); + } + } + } + return mappedTypes ? getUnionType(mappedTypes) : mappedType; + } + function getTypeOfPropertyOfContextualType(type, name) { + return applyToContextualType(type, function (t) { + var prop = t.flags & 130048 ? getPropertyOfType(t, name) : undefined; + return prop ? getTypeOfSymbol(prop) : undefined; + }); + } + function getIndexTypeOfContextualType(type, kind) { + return applyToContextualType(type, function (t) { return getIndexTypeOfStructuredType(t, kind); }); + } + function contextualTypeIsTupleLikeType(type) { + return !!(type.flags & 16384 ? ts.forEach(type.types, isTupleLikeType) : isTupleLikeType(type)); + } + function contextualTypeHasIndexSignature(type, kind) { + return !!(type.flags & 16384 ? ts.forEach(type.types, function (t) { return getIndexTypeOfStructuredType(t, kind); }) : getIndexTypeOfStructuredType(type, kind)); + } + function getContextualTypeForObjectLiteralMethod(node) { + ts.Debug.assert(ts.isObjectLiteralMethod(node)); + if (isInsideWithStatementBody(node)) { + return undefined; + } + return getContextualTypeForObjectLiteralElement(node); + } + function getContextualTypeForObjectLiteralElement(element) { + var objectLiteral = element.parent; + var type = getContextualType(objectLiteral); + if (type) { + if (!ts.hasDynamicName(element)) { + var symbolName = getSymbolOfNode(element).name; + var propertyType = getTypeOfPropertyOfContextualType(type, symbolName); + if (propertyType) { + return propertyType; + } + } + return isNumericName(element.name) && getIndexTypeOfContextualType(type, 1) || + getIndexTypeOfContextualType(type, 0); + } + return undefined; + } + function getContextualTypeForElementExpression(node) { + var arrayLiteral = node.parent; + var type = getContextualType(arrayLiteral); + if (type) { + var index = ts.indexOf(arrayLiteral.elements, node); + return getTypeOfPropertyOfContextualType(type, "" + index) + || getIndexTypeOfContextualType(type, 1) + || (languageVersion >= 2 ? getElementTypeOfIterable(type, undefined) : undefined); + } + return undefined; + } + function getContextualTypeForConditionalOperand(node) { + var conditional = node.parent; + return node === conditional.whenTrue || node === conditional.whenFalse ? getContextualType(conditional) : undefined; + } + function getContextualTypeForJsxExpression(expr) { + if (expr.parent.kind === 238) { + var attrib = expr.parent; + var attrsType = getJsxElementAttributesType(attrib.parent); + if (!attrsType || isTypeAny(attrsType)) { + return undefined; + } + else { + return getTypeOfPropertyOfType(attrsType, attrib.name.text); + } + } + if (expr.kind === 239) { + return getJsxElementAttributesType(expr.parent); + } + return undefined; + } + function getContextualType(node) { + var type = getContextualTypeWorker(node); + return type && getApparentType(type); + } + function getContextualTypeWorker(node) { + if (isInsideWithStatementBody(node)) { + return undefined; + } + if (node.contextualType) { + return node.contextualType; + } + var parent = node.parent; + switch (parent.kind) { + case 211: + case 138: + case 141: + case 140: + case 163: + return getContextualTypeForInitializerExpression(node); + case 174: + case 204: + return getContextualTypeForReturnExpression(node); + case 184: + return getContextualTypeForYieldOperand(parent); + case 168: + case 169: + return getContextualTypeForArgument(parent, node); + case 171: + case 189: + return getTypeFromTypeNode(parent.type); + case 181: + return getContextualTypeForBinaryOperand(node); + case 245: + return getContextualTypeForObjectLiteralElement(parent); + case 164: + return getContextualTypeForElementExpression(node); + case 182: + return getContextualTypeForConditionalOperand(node); + case 190: + ts.Debug.assert(parent.parent.kind === 183); + return getContextualTypeForSubstitutionExpression(parent.parent, node); + case 172: + return getContextualType(parent); + case 240: + case 239: + return getContextualTypeForJsxExpression(parent); + } + return undefined; + } + function getNonGenericSignature(type) { + var signatures = getSignaturesOfStructuredType(type, 0); + if (signatures.length === 1) { + var signature = signatures[0]; + if (!signature.typeParameters) { + return signature; + } + } + } + function isFunctionExpressionOrArrowFunction(node) { + return node.kind === 173 || node.kind === 174; + } + function getContextualSignatureForFunctionLikeDeclaration(node) { + return isFunctionExpressionOrArrowFunction(node) || ts.isObjectLiteralMethod(node) + ? getContextualSignature(node) + : undefined; + } + function getContextualSignature(node) { + ts.Debug.assert(node.kind !== 143 || ts.isObjectLiteralMethod(node)); + var type = ts.isObjectLiteralMethod(node) + ? getContextualTypeForObjectLiteralMethod(node) + : getContextualType(node); + if (!type) { + return undefined; + } + if (!(type.flags & 16384)) { + return getNonGenericSignature(type); + } + var signatureList; + var types = type.types; + for (var _i = 0; _i < types.length; _i++) { + var current = types[_i]; + var signature = getNonGenericSignature(current); + if (signature) { + if (!signatureList) { + signatureList = [signature]; + } + else if (!compareSignatures(signatureList[0], signature, false, true, compareTypes)) { + return undefined; + } + else { + signatureList.push(signature); + } + } + } + var result; + if (signatureList) { + result = cloneSignature(signatureList[0]); + result.resolvedReturnType = undefined; + result.unionSignatures = signatureList; + } + return result; + } + function isInferentialContext(mapper) { + return mapper && mapper.context; + } + function isAssignmentTarget(node) { + var parent = node.parent; + if (parent.kind === 181 && parent.operatorToken.kind === 56 && parent.left === node) { + return true; + } + if (parent.kind === 245) { + return isAssignmentTarget(parent.parent); + } + if (parent.kind === 164) { + return isAssignmentTarget(parent); + } + return false; + } + function checkSpreadElementExpression(node, contextualMapper) { + var arrayOrIterableType = checkExpressionCached(node.expression, contextualMapper); + return checkIteratedTypeOrElementType(arrayOrIterableType, node.expression, false); + } + function hasDefaultValue(node) { + return (node.kind === 163 && !!node.initializer) || + (node.kind === 181 && node.operatorToken.kind === 56); + } + function checkArrayLiteral(node, contextualMapper) { + var elements = node.elements; + var hasSpreadElement = false; + var elementTypes = []; + var inDestructuringPattern = isAssignmentTarget(node); + for (var _i = 0; _i < elements.length; _i++) { + var e = elements[_i]; + if (inDestructuringPattern && e.kind === 185) { + var restArrayType = checkExpression(e.expression, contextualMapper); + var restElementType = getIndexTypeOfType(restArrayType, 1) || + (languageVersion >= 2 ? getElementTypeOfIterable(restArrayType, undefined) : undefined); + if (restElementType) { + elementTypes.push(restElementType); + } + } + else { + var type = checkExpression(e, contextualMapper); + elementTypes.push(type); + } + hasSpreadElement = hasSpreadElement || e.kind === 185; + } + if (!hasSpreadElement) { + if (inDestructuringPattern && elementTypes.length) { + var type = createNewTupleType(elementTypes); + type.pattern = node; + return type; + } + var contextualType = getContextualType(node); + if (contextualType && contextualTypeIsTupleLikeType(contextualType)) { + var pattern = contextualType.pattern; + if (pattern && (pattern.kind === 162 || pattern.kind === 164)) { + var patternElements = pattern.elements; + for (var i = elementTypes.length; i < patternElements.length; i++) { + var patternElement = patternElements[i]; + if (hasDefaultValue(patternElement)) { + elementTypes.push(contextualType.elementTypes[i]); + } + else { + if (patternElement.kind !== 187) { + error(patternElement, ts.Diagnostics.Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value); + } + elementTypes.push(unknownType); + } + } + } + if (elementTypes.length) { + return createTupleType(elementTypes); + } + } + } + return createArrayType(elementTypes.length ? getUnionType(elementTypes) : undefinedType); + } + function isNumericName(name) { + return name.kind === 136 ? isNumericComputedName(name) : isNumericLiteralName(name.text); + } + function isNumericComputedName(name) { + return isTypeAnyOrAllConstituentTypesHaveKind(checkComputedPropertyName(name), 132); + } + function isTypeAnyOrAllConstituentTypesHaveKind(type, kind) { + return isTypeAny(type) || allConstituentTypesHaveKind(type, kind); + } + function isNumericLiteralName(name) { + return (+name).toString() === name; + } + function checkComputedPropertyName(node) { + var links = getNodeLinks(node.expression); + if (!links.resolvedType) { + links.resolvedType = checkExpression(node.expression); + if (!isTypeAnyOrAllConstituentTypesHaveKind(links.resolvedType, 132 | 258 | 16777216)) { + error(node, ts.Diagnostics.A_computed_property_name_must_be_of_type_string_number_symbol_or_any); + } + else { + checkThatExpressionIsProperSymbolReference(node.expression, links.resolvedType, true); + } + } + return links.resolvedType; + } + function checkObjectLiteral(node, contextualMapper) { + var inDestructuringPattern = isAssignmentTarget(node); + checkGrammarObjectLiteralExpression(node, inDestructuringPattern); + var propertiesTable = {}; + var propertiesArray = []; + var contextualType = getContextualType(node); + var contextualTypeHasPattern = contextualType && contextualType.pattern && + (contextualType.pattern.kind === 161 || contextualType.pattern.kind === 165); + var typeFlags = 0; + for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { + var memberDecl = _a[_i]; + var member = memberDecl.symbol; + if (memberDecl.kind === 245 || + memberDecl.kind === 246 || + ts.isObjectLiteralMethod(memberDecl)) { + var type = void 0; + if (memberDecl.kind === 245) { + type = checkPropertyAssignment(memberDecl, contextualMapper); + } + else if (memberDecl.kind === 143) { + type = checkObjectLiteralMethod(memberDecl, contextualMapper); + } + else { + ts.Debug.assert(memberDecl.kind === 246); + type = checkExpression(memberDecl.name, contextualMapper); + } + typeFlags |= type.flags; + var prop = createSymbol(4 | 67108864 | member.flags, member.name); + if (inDestructuringPattern) { + var isOptional = (memberDecl.kind === 245 && hasDefaultValue(memberDecl.initializer)) || + (memberDecl.kind === 246 && memberDecl.objectAssignmentInitializer); + if (isOptional) { + prop.flags |= 536870912; + } + } + else if (contextualTypeHasPattern) { + var impliedProp = getPropertyOfType(contextualType, member.name); + if (impliedProp) { + prop.flags |= impliedProp.flags & 536870912; + } + else if (!compilerOptions.suppressExcessPropertyErrors) { + error(memberDecl.name, ts.Diagnostics.Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1, symbolToString(member), typeToString(contextualType)); + } + } + prop.declarations = member.declarations; + prop.parent = member.parent; + if (member.valueDeclaration) { + prop.valueDeclaration = member.valueDeclaration; + } + prop.type = type; + prop.target = member; + member = prop; + } + else { + ts.Debug.assert(memberDecl.kind === 145 || memberDecl.kind === 146); + checkAccessorDeclaration(memberDecl); + } + if (!ts.hasDynamicName(memberDecl)) { + propertiesTable[member.name] = member; + } + propertiesArray.push(member); + } + if (contextualTypeHasPattern) { + for (var _b = 0, _c = getPropertiesOfType(contextualType); _b < _c.length; _b++) { + var prop = _c[_b]; + if (!ts.hasProperty(propertiesTable, prop.name)) { + if (!(prop.flags & 536870912)) { + error(prop.valueDeclaration || prop.bindingElement, ts.Diagnostics.Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value); + } + propertiesTable[prop.name] = prop; + propertiesArray.push(prop); + } + } + } + var stringIndexType = getIndexType(0); + var numberIndexType = getIndexType(1); + var result = createAnonymousType(node.symbol, propertiesTable, emptyArray, emptyArray, stringIndexType, numberIndexType); + var freshObjectLiteralFlag = compilerOptions.suppressExcessPropertyErrors ? 0 : 1048576; + result.flags |= 524288 | 4194304 | freshObjectLiteralFlag | (typeFlags & 14680064); + if (inDestructuringPattern) { + result.pattern = node; + } + return result; + function getIndexType(kind) { + if (contextualType && contextualTypeHasIndexSignature(contextualType, kind)) { + var propTypes = []; + for (var i = 0; i < propertiesArray.length; i++) { + var propertyDecl = node.properties[i]; + if (kind === 0 || isNumericName(propertyDecl.name)) { + var type = getTypeOfSymbol(propertiesArray[i]); + if (!ts.contains(propTypes, type)) { + propTypes.push(type); + } + } + } + var result_1 = propTypes.length ? getUnionType(propTypes) : undefinedType; + typeFlags |= result_1.flags; + return result_1; + } + return undefined; + } + } + function checkJsxSelfClosingElement(node) { + checkJsxOpeningLikeElement(node); + return jsxElementType || anyType; + } + function tagNamesAreEquivalent(lhs, rhs) { + if (lhs.kind !== rhs.kind) { + return false; + } + if (lhs.kind === 69) { + return lhs.text === rhs.text; + } + return lhs.right.text === rhs.right.text && + tagNamesAreEquivalent(lhs.left, rhs.left); + } + function checkJsxElement(node) { + checkJsxOpeningLikeElement(node.openingElement); + if (!tagNamesAreEquivalent(node.openingElement.tagName, node.closingElement.tagName)) { + error(node.closingElement, ts.Diagnostics.Expected_corresponding_JSX_closing_tag_for_0, ts.getTextOfNode(node.openingElement.tagName)); + } + else { + getJsxElementTagSymbol(node.closingElement); + } + for (var _i = 0, _a = node.children; _i < _a.length; _i++) { + var child = _a[_i]; + switch (child.kind) { + case 240: + checkJsxExpression(child); + break; + case 233: + checkJsxElement(child); + break; + case 234: + checkJsxSelfClosingElement(child); + break; + } + } + return jsxElementType || anyType; + } + function isUnhyphenatedJsxName(name) { + return name.indexOf("-") < 0; + } + function isJsxIntrinsicIdentifier(tagName) { + if (tagName.kind === 135) { + return false; + } + else { + return ts.isIntrinsicJsxName(tagName.text); + } + } + function checkJsxAttribute(node, elementAttributesType, nameTable) { + var correspondingPropType = undefined; + if (elementAttributesType === emptyObjectType && isUnhyphenatedJsxName(node.name.text)) { + error(node.parent, ts.Diagnostics.JSX_element_class_does_not_support_attributes_because_it_does_not_have_a_0_property, getJsxElementPropertiesName()); + } + else if (elementAttributesType && !isTypeAny(elementAttributesType)) { + var correspondingPropSymbol = getPropertyOfType(elementAttributesType, node.name.text); + correspondingPropType = correspondingPropSymbol && getTypeOfSymbol(correspondingPropSymbol); + if (isUnhyphenatedJsxName(node.name.text)) { + var indexerType = getIndexTypeOfType(elementAttributesType, 0); + if (indexerType) { + correspondingPropType = indexerType; + } + else { + if (!correspondingPropType) { + error(node.name, ts.Diagnostics.Property_0_does_not_exist_on_type_1, node.name.text, typeToString(elementAttributesType)); + return unknownType; + } + } + } + } + var exprType; + if (node.initializer) { + exprType = checkExpression(node.initializer); + } + else { + exprType = booleanType; + } + if (correspondingPropType) { + checkTypeAssignableTo(exprType, correspondingPropType, node); + } + nameTable[node.name.text] = true; + return exprType; + } + function checkJsxSpreadAttribute(node, elementAttributesType, nameTable) { + var type = checkExpression(node.expression); + var props = getPropertiesOfType(type); + for (var _i = 0; _i < props.length; _i++) { + var prop = props[_i]; + if (!nameTable[prop.name]) { + var targetPropSym = getPropertyOfType(elementAttributesType, prop.name); + if (targetPropSym) { + var msg = ts.chainDiagnosticMessages(undefined, ts.Diagnostics.Property_0_of_JSX_spread_attribute_is_not_assignable_to_target_property, prop.name); + checkTypeAssignableTo(getTypeOfSymbol(prop), getTypeOfSymbol(targetPropSym), node, undefined, msg); + } + nameTable[prop.name] = true; + } + } + return type; + } + function getJsxIntrinsicElementsType() { + if (!jsxIntrinsicElementsType) { + jsxIntrinsicElementsType = getExportedTypeFromNamespace(JsxNames.JSX, JsxNames.IntrinsicElements) || unknownType; + } + return jsxIntrinsicElementsType; + } + function getJsxElementTagSymbol(node) { + var flags = 8; + var links = getNodeLinks(node); + if (!links.resolvedSymbol) { + if (isJsxIntrinsicIdentifier(node.tagName)) { + links.resolvedSymbol = lookupIntrinsicTag(node); + } + else { + links.resolvedSymbol = lookupClassTag(node); + } + } + return links.resolvedSymbol; + function lookupIntrinsicTag(node) { + var intrinsicElementsType = getJsxIntrinsicElementsType(); + if (intrinsicElementsType !== unknownType) { + var intrinsicProp = getPropertyOfType(intrinsicElementsType, node.tagName.text); + if (intrinsicProp) { + links.jsxFlags |= 1; + return intrinsicProp; + } + var indexSignatureType = getIndexTypeOfType(intrinsicElementsType, 0); + if (indexSignatureType) { + links.jsxFlags |= 2; + return intrinsicElementsType.symbol; + } + error(node, ts.Diagnostics.Property_0_does_not_exist_on_type_1, node.tagName.text, "JSX." + JsxNames.IntrinsicElements); + return unknownSymbol; + } + else { + if (compilerOptions.noImplicitAny) { + error(node, ts.Diagnostics.JSX_element_implicitly_has_type_any_because_no_interface_JSX_0_exists, JsxNames.IntrinsicElements); + } + } + } + function lookupClassTag(node) { + var valueSymbol = resolveJsxTagName(node); + if (valueSymbol && valueSymbol !== unknownSymbol) { + links.jsxFlags |= 4; + if (valueSymbol.flags & 8388608) { + markAliasSymbolAsReferenced(valueSymbol); + } + } + return valueSymbol || unknownSymbol; + } + function resolveJsxTagName(node) { + if (node.tagName.kind === 69) { + var tag = node.tagName; + var sym = getResolvedSymbol(tag); + return sym.exportSymbol || sym; + } + else { + return checkQualifiedName(node.tagName).symbol; + } + } + } + function getJsxElementInstanceType(node) { + ts.Debug.assert(!!(getNodeLinks(node).jsxFlags & 4), "Should not call getJsxElementInstanceType on non-class Element"); + var classSymbol = getJsxElementTagSymbol(node); + if (classSymbol === unknownSymbol) { + return anyType; + } + var valueType = getTypeOfSymbol(classSymbol); + if (isTypeAny(valueType)) { + return anyType; + } + var signatures = getSignaturesOfType(valueType, 1); + if (signatures.length === 0) { + signatures = getSignaturesOfType(valueType, 0); + if (signatures.length === 0) { + error(node.tagName, ts.Diagnostics.JSX_element_type_0_does_not_have_any_construct_or_call_signatures, ts.getTextOfNode(node.tagName)); + return unknownType; + } + } + var returnType = getUnionType(signatures.map(getReturnTypeOfSignature)); + var elemClassType = getJsxGlobalElementClassType(); + if (elemClassType) { + checkTypeRelatedTo(returnType, elemClassType, assignableRelation, node, ts.Diagnostics.JSX_element_type_0_is_not_a_constructor_function_for_JSX_elements); + } + return returnType; + } + function getJsxElementPropertiesName() { + var jsxNamespace = getGlobalSymbol(JsxNames.JSX, 1536, undefined); + var attribsPropTypeSym = jsxNamespace && getSymbol(jsxNamespace.exports, JsxNames.ElementAttributesPropertyNameContainer, 793056); + var attribPropType = attribsPropTypeSym && getDeclaredTypeOfSymbol(attribsPropTypeSym); + var attribProperties = attribPropType && getPropertiesOfType(attribPropType); + if (attribProperties) { + if (attribProperties.length === 0) { + return ""; + } + else if (attribProperties.length === 1) { + return attribProperties[0].name; + } + else { + error(attribsPropTypeSym.declarations[0], ts.Diagnostics.The_global_type_JSX_0_may_not_have_more_than_one_property, JsxNames.ElementAttributesPropertyNameContainer); + return undefined; + } + } + else { + return undefined; + } + } + function getJsxElementAttributesType(node) { + var links = getNodeLinks(node); + if (!links.resolvedJsxType) { + var sym = getJsxElementTagSymbol(node); + if (links.jsxFlags & 4) { + var elemInstanceType = getJsxElementInstanceType(node); + if (isTypeAny(elemInstanceType)) { + return links.resolvedJsxType = elemInstanceType; + } + var propsName = getJsxElementPropertiesName(); + if (propsName === undefined) { + return links.resolvedJsxType = anyType; + } + else if (propsName === "") { + return links.resolvedJsxType = elemInstanceType; + } + else { + var attributesType = getTypeOfPropertyOfType(elemInstanceType, propsName); + if (!attributesType) { + return links.resolvedJsxType = emptyObjectType; + } + else if (isTypeAny(attributesType) || (attributesType === unknownType)) { + return links.resolvedJsxType = attributesType; + } + else if (!(attributesType.flags & 80896)) { + error(node.tagName, ts.Diagnostics.JSX_element_attributes_type_0_must_be_an_object_type, typeToString(attributesType)); + return links.resolvedJsxType = anyType; + } + else { + return links.resolvedJsxType = attributesType; + } + } + } + else if (links.jsxFlags & 1) { + return links.resolvedJsxType = getTypeOfSymbol(sym); + } + else if (links.jsxFlags & 2) { + return links.resolvedJsxType = getIndexTypeOfSymbol(sym, 0); + } + else { + return links.resolvedJsxType = anyType; + } + } + return links.resolvedJsxType; + } + function getJsxAttributePropertySymbol(attrib) { + var attributesType = getJsxElementAttributesType(attrib.parent); + var prop = getPropertyOfType(attributesType, attrib.name.text); + return prop || unknownSymbol; + } + var jsxElementClassType = undefined; + function getJsxGlobalElementClassType() { + if (!jsxElementClassType) { + jsxElementClassType = getExportedTypeFromNamespace(JsxNames.JSX, JsxNames.ElementClass); + } + return jsxElementClassType; + } + function getJsxIntrinsicTagNames() { + var intrinsics = getJsxIntrinsicElementsType(); + return intrinsics ? getPropertiesOfType(intrinsics) : emptyArray; + } + function checkJsxPreconditions(errorNode) { + if ((compilerOptions.jsx || 0) === 0) { + error(errorNode, ts.Diagnostics.Cannot_use_JSX_unless_the_jsx_flag_is_provided); + } + if (jsxElementType === undefined) { + if (compilerOptions.noImplicitAny) { + error(errorNode, ts.Diagnostics.JSX_element_implicitly_has_type_any_because_the_global_type_JSX_Element_does_not_exist); + } + } + } + function checkJsxOpeningLikeElement(node) { + checkGrammarJsxElement(node); + checkJsxPreconditions(node); + if (compilerOptions.jsx === 2) { + var reactSym = resolveName(node.tagName, "React", 107455, ts.Diagnostics.Cannot_find_name_0, "React"); + if (reactSym) { + getSymbolLinks(reactSym).referenced = true; + } + } + var targetAttributesType = getJsxElementAttributesType(node); + var nameTable = {}; + var sawSpreadedAny = false; + for (var i = node.attributes.length - 1; i >= 0; i--) { + if (node.attributes[i].kind === 238) { + checkJsxAttribute((node.attributes[i]), targetAttributesType, nameTable); + } + else { + ts.Debug.assert(node.attributes[i].kind === 239); + var spreadType = checkJsxSpreadAttribute((node.attributes[i]), targetAttributesType, nameTable); + if (isTypeAny(spreadType)) { + sawSpreadedAny = true; + } + } + } + if (targetAttributesType && !sawSpreadedAny) { + var targetProperties = getPropertiesOfType(targetAttributesType); + for (var i = 0; i < targetProperties.length; i++) { + if (!(targetProperties[i].flags & 536870912) && + nameTable[targetProperties[i].name] === undefined) { + error(node, ts.Diagnostics.Property_0_is_missing_in_type_1, targetProperties[i].name, typeToString(targetAttributesType)); + } + } + } + } + function checkJsxExpression(node) { + if (node.expression) { + return checkExpression(node.expression); + } + else { + return unknownType; + } + } + function getDeclarationKindFromSymbol(s) { + return s.valueDeclaration ? s.valueDeclaration.kind : 141; + } + function getDeclarationFlagsFromSymbol(s) { + return s.valueDeclaration ? ts.getCombinedNodeFlags(s.valueDeclaration) : s.flags & 134217728 ? 16 | 128 : 0; + } + function checkClassPropertyAccess(node, left, type, prop) { + var flags = getDeclarationFlagsFromSymbol(prop); + var declaringClass = getDeclaredTypeOfSymbol(prop.parent); + if (left.kind === 95) { + var errorNode = node.kind === 166 ? + node.name : + node.right; + if (getDeclarationKindFromSymbol(prop) !== 143) { + error(errorNode, ts.Diagnostics.Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword); + return false; + } + if (flags & 256) { + error(errorNode, ts.Diagnostics.Abstract_method_0_in_class_1_cannot_be_accessed_via_super_expression, symbolToString(prop), typeToString(declaringClass)); + return false; + } + } + if (!(flags & (32 | 64))) { + return true; + } + var enclosingClassDeclaration = ts.getContainingClass(node); + var enclosingClass = enclosingClassDeclaration ? getDeclaredTypeOfSymbol(getSymbolOfNode(enclosingClassDeclaration)) : undefined; + if (flags & 32) { + if (declaringClass !== enclosingClass) { + error(node, ts.Diagnostics.Property_0_is_private_and_only_accessible_within_class_1, symbolToString(prop), typeToString(declaringClass)); + return false; + } + return true; + } + if (left.kind === 95) { + return true; + } + if (!enclosingClass || !hasBaseType(enclosingClass, declaringClass)) { + error(node, ts.Diagnostics.Property_0_is_protected_and_only_accessible_within_class_1_and_its_subclasses, symbolToString(prop), typeToString(declaringClass)); + return false; + } + if (flags & 128) { + return true; + } + if (type.flags & 33554432) { + type = getConstraintOfTypeParameter(type); + } + if (!(getTargetType(type).flags & (1024 | 2048) && hasBaseType(type, enclosingClass))) { + error(node, ts.Diagnostics.Property_0_is_protected_and_only_accessible_through_an_instance_of_class_1, symbolToString(prop), typeToString(enclosingClass)); + return false; + } + return true; + } + function checkPropertyAccessExpression(node) { + return checkPropertyAccessExpressionOrQualifiedName(node, node.expression, node.name); + } + function checkQualifiedName(node) { + return checkPropertyAccessExpressionOrQualifiedName(node, node.left, node.right); + } + function checkPropertyAccessExpressionOrQualifiedName(node, left, right) { + var type = checkExpression(left); + if (isTypeAny(type)) { + return type; + } + var apparentType = getApparentType(getWidenedType(type)); + if (apparentType === unknownType) { + return unknownType; + } + var prop = getPropertyOfType(apparentType, right.text); + if (!prop) { + if (right.text) { + error(right, ts.Diagnostics.Property_0_does_not_exist_on_type_1, ts.declarationNameToString(right), typeToString(type.flags & 33554432 ? apparentType : type)); + } + return unknownType; + } + getNodeLinks(node).resolvedSymbol = prop; + if (prop.parent && prop.parent.flags & 32) { + checkClassPropertyAccess(node, left, apparentType, prop); + } + return getTypeOfSymbol(prop); + } + function isValidPropertyAccess(node, propertyName) { + var left = node.kind === 166 + ? node.expression + : node.left; + var type = checkExpression(left); + if (type !== unknownType && !isTypeAny(type)) { + var prop = getPropertyOfType(getWidenedType(type), propertyName); + if (prop && prop.parent && prop.parent.flags & 32) { + return checkClassPropertyAccess(node, left, type, prop); + } + } + return true; + } + function checkIndexedAccess(node) { + if (!node.argumentExpression) { + var sourceFile = getSourceFile(node); + if (node.parent.kind === 169 && node.parent.expression === node) { + var start = ts.skipTrivia(sourceFile.text, node.expression.end); + var end = node.end; + grammarErrorAtPos(sourceFile, start, end - start, ts.Diagnostics.new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead); + } + else { + var start = node.end - "]".length; + var end = node.end; + grammarErrorAtPos(sourceFile, start, end - start, ts.Diagnostics.Expression_expected); + } + } + var objectType = getApparentType(checkExpression(node.expression)); + var indexType = node.argumentExpression ? checkExpression(node.argumentExpression) : unknownType; + if (objectType === unknownType) { + return unknownType; + } + var isConstEnum = isConstEnumObjectType(objectType); + if (isConstEnum && + (!node.argumentExpression || node.argumentExpression.kind !== 9)) { + error(node.argumentExpression, ts.Diagnostics.A_const_enum_member_can_only_be_accessed_using_a_string_literal); + return unknownType; + } + if (node.argumentExpression) { + var name_12 = getPropertyNameForIndexedAccess(node.argumentExpression, indexType); + if (name_12 !== undefined) { + var prop = getPropertyOfType(objectType, name_12); + 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_12, symbolToString(objectType.symbol)); + return unknownType; + } + } + } + if (isTypeAnyOrAllConstituentTypesHaveKind(indexType, 258 | 132 | 16777216)) { + if (isTypeAnyOrAllConstituentTypesHaveKind(indexType, 132)) { + var numberIndexType = getIndexTypeOfType(objectType, 1); + if (numberIndexType) { + return numberIndexType; + } + } + var stringIndexType = getIndexTypeOfType(objectType, 0); + if (stringIndexType) { + return stringIndexType; + } + if (compilerOptions.noImplicitAny && !compilerOptions.suppressImplicitAnyIndexErrors && !isTypeAny(objectType)) { + error(node, ts.Diagnostics.Index_signature_of_object_type_implicitly_has_an_any_type); + } + return anyType; + } + error(node, ts.Diagnostics.An_index_expression_argument_must_be_of_type_string_number_symbol_or_any); + return unknownType; + } + function getPropertyNameForIndexedAccess(indexArgumentExpression, indexArgumentType) { + if (indexArgumentExpression.kind === 9 || indexArgumentExpression.kind === 8) { + return indexArgumentExpression.text; + } + if (indexArgumentExpression.kind === 167 || indexArgumentExpression.kind === 166) { + var value = getConstantValue(indexArgumentExpression); + if (value !== undefined) { + return value.toString(); + } + } + if (checkThatExpressionIsProperSymbolReference(indexArgumentExpression, indexArgumentType, false)) { + var rightHandSideName = indexArgumentExpression.name.text; + return ts.getPropertyNameForKnownSymbolName(rightHandSideName); + } + return undefined; + } + function checkThatExpressionIsProperSymbolReference(expression, expressionType, reportError) { + if (expressionType === unknownType) { + return false; + } + if (!ts.isWellKnownSymbolSyntactically(expression)) { + return false; + } + if ((expressionType.flags & 16777216) === 0) { + if (reportError) { + error(expression, ts.Diagnostics.A_computed_property_name_of_the_form_0_must_be_of_type_symbol, ts.getTextOfNode(expression)); + } + return false; + } + var leftHandSide = expression.expression; + var leftHandSideSymbol = getResolvedSymbol(leftHandSide); + if (!leftHandSideSymbol) { + return false; + } + var globalESSymbol = getGlobalESSymbolConstructorSymbol(); + if (!globalESSymbol) { + return false; + } + if (leftHandSideSymbol !== globalESSymbol) { + if (reportError) { + error(leftHandSide, ts.Diagnostics.Symbol_reference_does_not_refer_to_the_global_Symbol_constructor_object); + } + return false; + } + return true; + } + function resolveUntypedCall(node) { + if (node.kind === 170) { + checkExpression(node.template); + } + else if (node.kind !== 139) { + ts.forEach(node.arguments, function (argument) { + checkExpression(argument); + }); + } + return anySignature; + } + function resolveErrorCall(node) { + resolveUntypedCall(node); + return unknownSignature; + } + function reorderCandidates(signatures, result) { + var lastParent; + var lastSymbol; + var cutoffIndex = 0; + var index; + var specializedIndex = -1; + var spliceIndex; + ts.Debug.assert(!result.length); + for (var _i = 0; _i < signatures.length; _i++) { + var signature = signatures[_i]; + var symbol = signature.declaration && getSymbolOfNode(signature.declaration); + var parent_5 = signature.declaration && signature.declaration.parent; + if (!lastSymbol || symbol === lastSymbol) { + if (lastParent && parent_5 === lastParent) { + index++; + } + else { + lastParent = parent_5; + index = cutoffIndex; + } + } + else { + index = cutoffIndex = result.length; + lastParent = parent_5; + } + lastSymbol = symbol; + if (signature.hasStringLiterals) { + specializedIndex++; + spliceIndex = specializedIndex; + cutoffIndex++; + } + else { + spliceIndex = index; + } + result.splice(spliceIndex, 0, signature); + } + } + function getSpreadArgumentIndex(args) { + for (var i = 0; i < args.length; i++) { + var arg = args[i]; + if (arg && arg.kind === 185) { + return i; + } + } + return -1; + } + function hasCorrectArity(node, args, signature) { + var adjustedArgCount; + var typeArguments; + var callIsIncomplete; + var isDecorator; + var spreadArgIndex = -1; + if (node.kind === 170) { + var tagExpression = node; + adjustedArgCount = args.length; + typeArguments = undefined; + if (tagExpression.template.kind === 183) { + var templateExpression = tagExpression.template; + var lastSpan = ts.lastOrUndefined(templateExpression.templateSpans); + ts.Debug.assert(lastSpan !== undefined); + callIsIncomplete = ts.nodeIsMissing(lastSpan.literal) || !!lastSpan.literal.isUnterminated; + } + else { + var templateLiteral = tagExpression.template; + ts.Debug.assert(templateLiteral.kind === 11); + callIsIncomplete = !!templateLiteral.isUnterminated; + } + } + else if (node.kind === 139) { + isDecorator = true; + typeArguments = undefined; + adjustedArgCount = getEffectiveArgumentCount(node, undefined, signature); + } + else { + var callExpression = node; + if (!callExpression.arguments) { + ts.Debug.assert(callExpression.kind === 169); + return signature.minArgumentCount === 0; + } + adjustedArgCount = callExpression.arguments.hasTrailingComma ? args.length + 1 : args.length; + callIsIncomplete = callExpression.arguments.end === callExpression.end; + typeArguments = callExpression.typeArguments; + spreadArgIndex = getSpreadArgumentIndex(args); + } + var hasRightNumberOfTypeArgs = !typeArguments || + (signature.typeParameters && typeArguments.length === signature.typeParameters.length); + if (!hasRightNumberOfTypeArgs) { + return false; + } + if (spreadArgIndex >= 0) { + return isRestParameterIndex(signature, spreadArgIndex); + } + if (!signature.hasRestParameter && adjustedArgCount > signature.parameters.length) { + return false; + } + var hasEnoughArguments = adjustedArgCount >= signature.minArgumentCount; + return callIsIncomplete || hasEnoughArguments; + } + function getSingleCallSignature(type) { + if (type.flags & 80896) { + var resolved = resolveStructuredTypeMembers(type); + if (resolved.callSignatures.length === 1 && resolved.constructSignatures.length === 0 && + resolved.properties.length === 0 && !resolved.stringIndexType && !resolved.numberIndexType) { + return resolved.callSignatures[0]; + } + } + return undefined; + } + function instantiateSignatureInContextOf(signature, contextualSignature, contextualMapper) { + var context = createInferenceContext(signature.typeParameters, true); + forEachMatchingParameterType(contextualSignature, signature, function (source, target) { + inferTypes(context, instantiateType(source, contextualMapper), target); + }); + return getSignatureInstantiation(signature, getInferredTypes(context)); + } + function inferTypeArguments(node, signature, args, excludeArgument, context) { + var typeParameters = signature.typeParameters; + var inferenceMapper = createInferenceMapper(context); + for (var i = 0; i < typeParameters.length; i++) { + if (!context.inferences[i].isFixed) { + context.inferredTypes[i] = undefined; + } + } + if (context.failedTypeParameterIndex !== undefined && !context.inferences[context.failedTypeParameterIndex].isFixed) { + context.failedTypeParameterIndex = undefined; + } + var argCount = getEffectiveArgumentCount(node, args, signature); + for (var i = 0; i < argCount; i++) { + var arg = getEffectiveArgument(node, args, i); + if (arg === undefined || arg.kind !== 187) { + var paramType = getTypeAtPosition(signature, i); + var argType = getEffectiveArgumentType(node, i, arg); + if (argType === undefined) { + var mapper = excludeArgument && excludeArgument[i] !== undefined ? identityMapper : inferenceMapper; + argType = checkExpressionWithContextualType(arg, paramType, mapper); + } + inferTypes(context, argType, paramType); + } + } + if (excludeArgument) { + for (var i = 0; i < argCount; i++) { + if (excludeArgument[i] === false) { + var arg = args[i]; + var paramType = getTypeAtPosition(signature, i); + inferTypes(context, checkExpressionWithContextualType(arg, paramType, inferenceMapper), paramType); + } + } + } + getInferredTypes(context); + } + function checkTypeArguments(signature, typeArguments, typeArgumentResultTypes, reportErrors, headMessage) { + var typeParameters = signature.typeParameters; + var typeArgumentsAreAssignable = true; + for (var i = 0; i < typeParameters.length; i++) { + var typeArgNode = typeArguments[i]; + var typeArgument = getTypeFromTypeNode(typeArgNode); + typeArgumentResultTypes[i] = typeArgument; + if (typeArgumentsAreAssignable) { + var constraint = getConstraintOfTypeParameter(typeParameters[i]); + if (constraint) { + var errorInfo = void 0; + var typeArgumentHeadMessage = ts.Diagnostics.Type_0_does_not_satisfy_the_constraint_1; + if (reportErrors && headMessage) { + errorInfo = ts.chainDiagnosticMessages(errorInfo, typeArgumentHeadMessage); + typeArgumentHeadMessage = headMessage; + } + typeArgumentsAreAssignable = checkTypeAssignableTo(typeArgument, constraint, reportErrors ? typeArgNode : undefined, typeArgumentHeadMessage, errorInfo); + } + } + } + return typeArgumentsAreAssignable; + } + function checkApplicableSignature(node, args, signature, relation, excludeArgument, reportErrors) { + var argCount = getEffectiveArgumentCount(node, args, signature); + for (var i = 0; i < argCount; i++) { + var arg = getEffectiveArgument(node, args, i); + if (arg === undefined || arg.kind !== 187) { + var paramType = getTypeAtPosition(signature, i); + var argType = getEffectiveArgumentType(node, i, arg); + if (argType === undefined) { + argType = arg.kind === 9 && !reportErrors + ? getStringLiteralType(arg) + : checkExpressionWithContextualType(arg, paramType, excludeArgument && excludeArgument[i] ? identityMapper : undefined); + } + var errorNode = reportErrors ? getEffectiveArgumentErrorNode(node, i, arg) : undefined; + var headMessage = ts.Diagnostics.Argument_of_type_0_is_not_assignable_to_parameter_of_type_1; + if (!checkTypeRelatedTo(argType, paramType, relation, errorNode, headMessage)) { + return false; + } + } + } + return true; + } + function getEffectiveCallArguments(node) { + var args; + if (node.kind === 170) { + var template = node.template; + args = [undefined]; + if (template.kind === 183) { + ts.forEach(template.templateSpans, function (span) { + args.push(span.expression); + }); + } + } + else if (node.kind === 139) { + return undefined; + } + else { + args = node.arguments || emptyArray; + } + return args; + } + function getEffectiveArgumentCount(node, args, signature) { + if (node.kind === 139) { + switch (node.parent.kind) { + case 214: + case 186: + return 1; + case 141: + return 2; + case 143: + case 145: + case 146: + if (languageVersion === 0) { + return 2; + } + return signature.parameters.length >= 3 ? 3 : 2; + case 138: + return 3; + } + } + else { + return args.length; + } + } + function getEffectiveDecoratorFirstArgumentType(node) { + if (node.kind === 214) { + var classSymbol = getSymbolOfNode(node); + return getTypeOfSymbol(classSymbol); + } + if (node.kind === 138) { + node = node.parent; + if (node.kind === 144) { + var classSymbol = getSymbolOfNode(node); + return getTypeOfSymbol(classSymbol); + } + } + if (node.kind === 141 || + node.kind === 143 || + node.kind === 145 || + node.kind === 146) { + return getParentTypeOfClassElement(node); + } + ts.Debug.fail("Unsupported decorator target."); + return unknownType; + } + function getEffectiveDecoratorSecondArgumentType(node) { + if (node.kind === 214) { + ts.Debug.fail("Class decorators should not have a second synthetic argument."); + return unknownType; + } + if (node.kind === 138) { + node = node.parent; + if (node.kind === 144) { + return anyType; + } + } + if (node.kind === 141 || + node.kind === 143 || + node.kind === 145 || + node.kind === 146) { + var element = node; + switch (element.name.kind) { + case 69: + case 8: + case 9: + return getStringLiteralType(element.name); + case 136: + var nameType = checkComputedPropertyName(element.name); + if (allConstituentTypesHaveKind(nameType, 16777216)) { + return nameType; + } + else { + return stringType; + } + default: + ts.Debug.fail("Unsupported property name."); + return unknownType; + } + } + ts.Debug.fail("Unsupported decorator target."); + return unknownType; + } + function getEffectiveDecoratorThirdArgumentType(node) { + if (node.kind === 214) { + ts.Debug.fail("Class decorators should not have a third synthetic argument."); + return unknownType; + } + if (node.kind === 138) { + return numberType; + } + if (node.kind === 141) { + ts.Debug.fail("Property decorators should not have a third synthetic argument."); + return unknownType; + } + if (node.kind === 143 || + node.kind === 145 || + node.kind === 146) { + var propertyType = getTypeOfNode(node); + return createTypedPropertyDescriptorType(propertyType); + } + ts.Debug.fail("Unsupported decorator target."); + return unknownType; + } + function getEffectiveDecoratorArgumentType(node, argIndex) { + if (argIndex === 0) { + return getEffectiveDecoratorFirstArgumentType(node.parent); + } + else if (argIndex === 1) { + return getEffectiveDecoratorSecondArgumentType(node.parent); + } + else if (argIndex === 2) { + return getEffectiveDecoratorThirdArgumentType(node.parent); + } + ts.Debug.fail("Decorators should not have a fourth synthetic argument."); + return unknownType; + } + function getEffectiveArgumentType(node, argIndex, arg) { + if (node.kind === 139) { + return getEffectiveDecoratorArgumentType(node, argIndex); + } + else if (argIndex === 0 && node.kind === 170) { + return globalTemplateStringsArrayType; + } + return undefined; + } + function getEffectiveArgument(node, args, argIndex) { + if (node.kind === 139 || + (argIndex === 0 && node.kind === 170)) { + return undefined; + } + return args[argIndex]; + } + function getEffectiveArgumentErrorNode(node, argIndex, arg) { + if (node.kind === 139) { + return node.expression; + } + else if (argIndex === 0 && node.kind === 170) { + return node.template; + } + else { + return arg; + } + } + function resolveCall(node, signatures, candidatesOutArray, headMessage) { + var isTaggedTemplate = node.kind === 170; + var isDecorator = node.kind === 139; + var typeArguments; + if (!isTaggedTemplate && !isDecorator) { + typeArguments = node.typeArguments; + if (node.expression.kind !== 95) { + ts.forEach(typeArguments, checkSourceElement); + } + } + var candidates = candidatesOutArray || []; + reorderCandidates(signatures, candidates); + if (!candidates.length) { + reportError(ts.Diagnostics.Supplied_parameters_do_not_match_any_signature_of_call_target); + return resolveErrorCall(node); + } + var args = getEffectiveCallArguments(node); + var excludeArgument; + if (!isDecorator) { + for (var i = isTaggedTemplate ? 1 : 0; i < args.length; i++) { + if (isContextSensitive(args[i])) { + if (!excludeArgument) { + excludeArgument = new Array(args.length); + } + excludeArgument[i] = true; + } + } + } + var candidateForArgumentError; + var candidateForTypeArgumentError; + var resultOfFailedInference; + var result; + if (candidates.length > 1) { + result = chooseOverload(candidates, subtypeRelation); + } + if (!result) { + candidateForArgumentError = undefined; + candidateForTypeArgumentError = undefined; + resultOfFailedInference = undefined; + result = chooseOverload(candidates, assignableRelation); + } + if (result) { + return result; + } + if (candidateForArgumentError) { + checkApplicableSignature(node, args, candidateForArgumentError, assignableRelation, undefined, true); + } + else if (candidateForTypeArgumentError) { + if (!isTaggedTemplate && !isDecorator && typeArguments) { + checkTypeArguments(candidateForTypeArgumentError, node.typeArguments, [], true, headMessage); + } + else { + ts.Debug.assert(resultOfFailedInference.failedTypeParameterIndex >= 0); + var failedTypeParameter = candidateForTypeArgumentError.typeParameters[resultOfFailedInference.failedTypeParameterIndex]; + var inferenceCandidates = getInferenceCandidates(resultOfFailedInference, resultOfFailedInference.failedTypeParameterIndex); + var diagnosticChainHead = ts.chainDiagnosticMessages(undefined, ts.Diagnostics.The_type_argument_for_type_parameter_0_cannot_be_inferred_from_the_usage_Consider_specifying_the_type_arguments_explicitly, typeToString(failedTypeParameter)); + if (headMessage) { + diagnosticChainHead = ts.chainDiagnosticMessages(diagnosticChainHead, headMessage); + } + reportNoCommonSupertypeError(inferenceCandidates, node.expression || node.tag, diagnosticChainHead); + } + } + else { + reportError(ts.Diagnostics.Supplied_parameters_do_not_match_any_signature_of_call_target); + } + if (!produceDiagnostics) { + for (var _i = 0; _i < candidates.length; _i++) { + var candidate = candidates[_i]; + if (hasCorrectArity(node, args, candidate)) { + if (candidate.typeParameters && typeArguments) { + candidate = getSignatureInstantiation(candidate, ts.map(typeArguments, getTypeFromTypeNode)); + } + return candidate; + } + } + } + return resolveErrorCall(node); + function reportError(message, arg0, arg1, arg2) { + var errorInfo; + errorInfo = ts.chainDiagnosticMessages(errorInfo, message, arg0, arg1, arg2); + if (headMessage) { + errorInfo = ts.chainDiagnosticMessages(errorInfo, headMessage); + } + diagnostics.add(ts.createDiagnosticForNodeFromMessageChain(node, errorInfo)); + } + function chooseOverload(candidates, relation) { + for (var _i = 0; _i < candidates.length; _i++) { + var originalCandidate = candidates[_i]; + if (!hasCorrectArity(node, args, originalCandidate)) { + continue; + } + var candidate = void 0; + var typeArgumentsAreValid = void 0; + var inferenceContext = originalCandidate.typeParameters + ? createInferenceContext(originalCandidate.typeParameters, false) + : undefined; + while (true) { + candidate = originalCandidate; + if (candidate.typeParameters) { + var typeArgumentTypes = void 0; + if (typeArguments) { + typeArgumentTypes = new Array(candidate.typeParameters.length); + typeArgumentsAreValid = checkTypeArguments(candidate, typeArguments, typeArgumentTypes, false); + } + else { + inferTypeArguments(node, candidate, args, excludeArgument, inferenceContext); + typeArgumentsAreValid = inferenceContext.failedTypeParameterIndex === undefined; + typeArgumentTypes = inferenceContext.inferredTypes; + } + if (!typeArgumentsAreValid) { + break; + } + candidate = getSignatureInstantiation(candidate, typeArgumentTypes); + } + if (!checkApplicableSignature(node, args, candidate, relation, excludeArgument, false)) { + break; + } + var index = excludeArgument ? ts.indexOf(excludeArgument, true) : -1; + if (index < 0) { + return candidate; + } + excludeArgument[index] = false; + } + if (originalCandidate.typeParameters) { + var instantiatedCandidate = candidate; + if (typeArgumentsAreValid) { + candidateForArgumentError = instantiatedCandidate; + } + else { + candidateForTypeArgumentError = originalCandidate; + if (!typeArguments) { + resultOfFailedInference = inferenceContext; + } + } + } + else { + ts.Debug.assert(originalCandidate === candidate); + candidateForArgumentError = originalCandidate; + } + } + return undefined; + } + } + function resolveCallExpression(node, candidatesOutArray) { + if (node.expression.kind === 95) { + var superType = checkSuperExpression(node.expression); + if (superType !== unknownType) { + var baseTypeNode = ts.getClassExtendsHeritageClauseElement(ts.getContainingClass(node)); + var baseConstructors = getInstantiatedConstructorsForTypeArguments(superType, baseTypeNode.typeArguments); + return resolveCall(node, baseConstructors, candidatesOutArray); + } + return resolveUntypedCall(node); + } + var funcType = checkExpression(node.expression); + var apparentType = getApparentType(funcType); + if (apparentType === unknownType) { + return resolveErrorCall(node); + } + var callSignatures = getSignaturesOfType(apparentType, 0); + var constructSignatures = getSignaturesOfType(apparentType, 1); + if (isTypeAny(funcType) || (!callSignatures.length && !constructSignatures.length && !(funcType.flags & 16384) && isTypeAssignableTo(funcType, globalFunctionType))) { + if (funcType !== unknownType && node.typeArguments) { + error(node, ts.Diagnostics.Untyped_function_calls_may_not_accept_type_arguments); + } + return resolveUntypedCall(node); + } + if (!callSignatures.length) { + if (constructSignatures.length) { + error(node, ts.Diagnostics.Value_of_type_0_is_not_callable_Did_you_mean_to_include_new, typeToString(funcType)); + } + else { + error(node, ts.Diagnostics.Cannot_invoke_an_expression_whose_type_lacks_a_call_signature); + } + return resolveErrorCall(node); + } + return resolveCall(node, callSignatures, candidatesOutArray); + } + function resolveNewExpression(node, candidatesOutArray) { + if (node.arguments && languageVersion < 1) { + var spreadIndex = getSpreadArgumentIndex(node.arguments); + if (spreadIndex >= 0) { + error(node.arguments[spreadIndex], ts.Diagnostics.Spread_operator_in_new_expressions_is_only_available_when_targeting_ECMAScript_5_and_higher); + } + } + var expressionType = checkExpression(node.expression); + expressionType = getApparentType(expressionType); + if (expressionType === unknownType) { + return resolveErrorCall(node); + } + var valueDecl = expressionType.symbol && getClassLikeDeclarationOfSymbol(expressionType.symbol); + if (valueDecl && valueDecl.flags & 256) { + error(node, ts.Diagnostics.Cannot_create_an_instance_of_the_abstract_class_0, ts.declarationNameToString(valueDecl.name)); + return resolveErrorCall(node); + } + if (isTypeAny(expressionType)) { + if (node.typeArguments) { + error(node, ts.Diagnostics.Untyped_function_calls_may_not_accept_type_arguments); + } + return resolveUntypedCall(node); + } + var constructSignatures = getSignaturesOfType(expressionType, 1); + if (constructSignatures.length) { + return resolveCall(node, constructSignatures, candidatesOutArray); + } + var callSignatures = getSignaturesOfType(expressionType, 0); + if (callSignatures.length) { + var signature = resolveCall(node, callSignatures, candidatesOutArray); + if (getReturnTypeOfSignature(signature) !== voidType) { + error(node, ts.Diagnostics.Only_a_void_function_can_be_called_with_the_new_keyword); + } + return signature; + } + error(node, ts.Diagnostics.Cannot_use_new_with_an_expression_whose_type_lacks_a_call_or_construct_signature); + return resolveErrorCall(node); + } + function resolveTaggedTemplateExpression(node, candidatesOutArray) { + var tagType = checkExpression(node.tag); + var apparentType = getApparentType(tagType); + if (apparentType === unknownType) { + return resolveErrorCall(node); + } + var callSignatures = getSignaturesOfType(apparentType, 0); + if (isTypeAny(tagType) || (!callSignatures.length && !(tagType.flags & 16384) && isTypeAssignableTo(tagType, globalFunctionType))) { + return resolveUntypedCall(node); + } + if (!callSignatures.length) { + error(node, ts.Diagnostics.Cannot_invoke_an_expression_whose_type_lacks_a_call_signature); + return resolveErrorCall(node); + } + return resolveCall(node, callSignatures, candidatesOutArray); + } + function getDiagnosticHeadMessageForDecoratorResolution(node) { + switch (node.parent.kind) { + case 214: + case 186: + return ts.Diagnostics.Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression; + case 138: + return ts.Diagnostics.Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression; + case 141: + return ts.Diagnostics.Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression; + case 143: + case 145: + case 146: + return ts.Diagnostics.Unable_to_resolve_signature_of_method_decorator_when_called_as_an_expression; + } + } + function resolveDecorator(node, candidatesOutArray) { + var funcType = checkExpression(node.expression); + var apparentType = getApparentType(funcType); + if (apparentType === unknownType) { + return resolveErrorCall(node); + } + var callSignatures = getSignaturesOfType(apparentType, 0); + if (funcType === anyType || (!callSignatures.length && !(funcType.flags & 16384) && isTypeAssignableTo(funcType, globalFunctionType))) { + return resolveUntypedCall(node); + } + var headMessage = getDiagnosticHeadMessageForDecoratorResolution(node); + if (!callSignatures.length) { + var errorInfo; + errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.Cannot_invoke_an_expression_whose_type_lacks_a_call_signature); + errorInfo = ts.chainDiagnosticMessages(errorInfo, headMessage); + diagnostics.add(ts.createDiagnosticForNodeFromMessageChain(node, errorInfo)); + return resolveErrorCall(node); + } + return resolveCall(node, callSignatures, candidatesOutArray, headMessage); + } + function getResolvedSignature(node, candidatesOutArray) { + var links = getNodeLinks(node); + if (!links.resolvedSignature || candidatesOutArray) { + links.resolvedSignature = anySignature; + if (node.kind === 168) { + links.resolvedSignature = resolveCallExpression(node, candidatesOutArray); + } + else if (node.kind === 169) { + links.resolvedSignature = resolveNewExpression(node, candidatesOutArray); + } + else if (node.kind === 170) { + links.resolvedSignature = resolveTaggedTemplateExpression(node, candidatesOutArray); + } + else if (node.kind === 139) { + links.resolvedSignature = resolveDecorator(node, candidatesOutArray); + } + else { + ts.Debug.fail("Branch in 'getResolvedSignature' should be unreachable."); + } + } + return links.resolvedSignature; + } + function checkCallExpression(node) { + checkGrammarTypeArguments(node, node.typeArguments) || checkGrammarArguments(node, node.arguments); + var signature = getResolvedSignature(node); + if (node.expression.kind === 95) { + return voidType; + } + if (node.kind === 169) { + var declaration = signature.declaration; + if (declaration && + declaration.kind !== 144 && + declaration.kind !== 148 && + declaration.kind !== 153) { + if (compilerOptions.noImplicitAny) { + error(node, ts.Diagnostics.new_expression_whose_target_lacks_a_construct_signature_implicitly_has_an_any_type); + } + return anyType; + } + } + return getReturnTypeOfSignature(signature); + } + function checkTaggedTemplateExpression(node) { + return getReturnTypeOfSignature(getResolvedSignature(node)); + } + function checkAssertion(node) { + var exprType = getRegularTypeOfObjectLiteral(checkExpression(node.expression)); + var targetType = getTypeFromTypeNode(node.type); + if (produceDiagnostics && targetType !== unknownType) { + var widenedType = getWidenedType(exprType); + if (!(isTypeAssignableTo(targetType, widenedType))) { + checkTypeAssignableTo(exprType, targetType, node, ts.Diagnostics.Neither_type_0_nor_type_1_is_assignable_to_the_other); + } + } + return targetType; + } + function getTypeAtPosition(signature, pos) { + return signature.hasRestParameter ? + pos < signature.parameters.length - 1 ? getTypeOfSymbol(signature.parameters[pos]) : getRestTypeOfSignature(signature) : + pos < signature.parameters.length ? getTypeOfSymbol(signature.parameters[pos]) : anyType; + } + function assignContextualParameterTypes(signature, context, mapper) { + var len = signature.parameters.length - (signature.hasRestParameter ? 1 : 0); + for (var i = 0; i < len; i++) { + var parameter = signature.parameters[i]; + 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); + } + } + function assignBindingElementTypes(node) { + if (ts.isBindingPattern(node.name)) { + for (var _i = 0, _a = node.name.elements; _i < _a.length; _i++) { + var element = _a[_i]; + if (element.kind !== 187) { + if (element.name.kind === 69) { + getSymbolLinks(getSymbolOfNode(element)).type = getTypeForBindingElement(element); + } + assignBindingElementTypes(element); + } + } + } + } + function assignTypeToParameterAndFixTypeParameters(parameter, contextualType, mapper) { + var links = getSymbolLinks(parameter); + if (!links.type) { + links.type = instantiateType(contextualType, mapper); + assignBindingElementTypes(parameter.valueDeclaration); + } + else if (isInferentialContext(mapper)) { + inferTypes(mapper.context, links.type, instantiateType(contextualType, mapper)); + } + } + function createPromiseType(promisedType) { + var globalPromiseType = getGlobalPromiseType(); + if (globalPromiseType !== emptyGenericType) { + promisedType = getAwaitedType(promisedType); + return createTypeReference(globalPromiseType, [promisedType]); + } + return emptyObjectType; + } + function getReturnTypeFromBody(func, contextualMapper) { + var contextualSignature = getContextualSignatureForFunctionLikeDeclaration(func); + if (!func.body) { + return unknownType; + } + var isAsync = ts.isAsyncFunctionLike(func); + var type; + if (func.body.kind !== 192) { + type = checkExpressionCached(func.body, contextualMapper); + if (isAsync) { + type = checkAwaitedType(type, func, ts.Diagnostics.Return_expression_in_async_function_does_not_have_a_valid_callable_then_member); + } + } + else { + var types; + var funcIsGenerator = !!func.asteriskToken; + if (funcIsGenerator) { + types = checkAndAggregateYieldOperandTypes(func.body, contextualMapper); + if (types.length === 0) { + var iterableIteratorAny = createIterableIteratorType(anyType); + if (compilerOptions.noImplicitAny) { + error(func.asteriskToken, ts.Diagnostics.Generator_implicitly_has_type_0_because_it_does_not_yield_any_values_Consider_supplying_a_return_type, typeToString(iterableIteratorAny)); + } + return iterableIteratorAny; + } + } + else { + types = checkAndAggregateReturnExpressionTypes(func.body, contextualMapper, isAsync); + if (types.length === 0) { + if (isAsync) { + var promiseType = createPromiseType(voidType); + if (promiseType === emptyObjectType) { + error(func, ts.Diagnostics.An_async_function_or_method_must_have_a_valid_awaitable_return_type); + return unknownType; + } + return promiseType; + } + else { + return voidType; + } + } + } + type = contextualSignature ? getUnionType(types) : getCommonSupertype(types); + if (!type) { + if (funcIsGenerator) { + error(func, ts.Diagnostics.No_best_common_type_exists_among_yield_expressions); + return createIterableIteratorType(unknownType); + } + else { + error(func, ts.Diagnostics.No_best_common_type_exists_among_return_expressions); + return unknownType; + } + } + if (funcIsGenerator) { + type = createIterableIteratorType(type); + } + } + if (!contextualSignature) { + reportErrorsFromWidening(func, type); + } + var widenedType = getWidenedType(type); + if (isAsync) { + var promiseType = createPromiseType(widenedType); + if (promiseType === emptyObjectType) { + error(func, ts.Diagnostics.An_async_function_or_method_must_have_a_valid_awaitable_return_type); + return unknownType; + } + return promiseType; + } + else { + return widenedType; + } + } + function checkAndAggregateYieldOperandTypes(body, contextualMapper) { + var aggregatedTypes = []; + ts.forEachYieldExpression(body, function (yieldExpression) { + var expr = yieldExpression.expression; + if (expr) { + var type = checkExpressionCached(expr, contextualMapper); + if (yieldExpression.asteriskToken) { + type = checkElementTypeOfIterable(type, yieldExpression.expression); + } + if (!ts.contains(aggregatedTypes, type)) { + aggregatedTypes.push(type); + } + } + }); + return aggregatedTypes; + } + function checkAndAggregateReturnExpressionTypes(body, contextualMapper, isAsync) { + var aggregatedTypes = []; + ts.forEachReturnStatement(body, function (returnStatement) { + var expr = returnStatement.expression; + if (expr) { + var type = checkExpressionCached(expr, contextualMapper); + if (isAsync) { + type = checkAwaitedType(type, body.parent, ts.Diagnostics.Return_expression_in_async_function_does_not_have_a_valid_callable_then_member); + } + if (!ts.contains(aggregatedTypes, type)) { + aggregatedTypes.push(type); + } + } + }); + return aggregatedTypes; + } + function bodyContainsAReturnStatement(funcBody) { + return ts.forEachReturnStatement(funcBody, function (returnStatement) { + return true; + }); + } + function bodyContainsSingleThrowStatement(body) { + return (body.statements.length === 1) && (body.statements[0].kind === 208); + } + function checkIfNonVoidFunctionHasReturnExpressionsOrSingleThrowStatment(func, returnType) { + if (!produceDiagnostics) { + return; + } + if (returnType === voidType || isTypeAny(returnType)) { + return; + } + if (ts.nodeIsMissing(func.body) || func.body.kind !== 192) { + return; + } + var bodyBlock = func.body; + if (bodyContainsAReturnStatement(bodyBlock)) { + return; + } + if (bodyContainsSingleThrowStatement(bodyBlock)) { + return; + } + error(func.type, ts.Diagnostics.A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value_or_consist_of_a_single_throw_statement); + } + function checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper) { + ts.Debug.assert(node.kind !== 143 || ts.isObjectLiteralMethod(node)); + var hasGrammarError = checkGrammarFunctionLikeDeclaration(node); + if (!hasGrammarError && node.kind === 173) { + checkGrammarForGenerator(node); + } + if (contextualMapper === identityMapper && isContextSensitive(node)) { + return anyFunctionType; + } + var isAsync = ts.isAsyncFunctionLike(node); + if (isAsync) { + emitAwaiter = true; + } + var links = getNodeLinks(node); + var type = getTypeOfSymbol(node.symbol); + var contextSensitive = isContextSensitive(node); + var mightFixTypeParameters = contextSensitive && isInferentialContext(contextualMapper); + if (mightFixTypeParameters || !(links.flags & 1024)) { + var contextualSignature = getContextualSignature(node); + var contextChecked = !!(links.flags & 1024); + if (mightFixTypeParameters || !contextChecked) { + links.flags |= 1024; + if (contextualSignature) { + var signature = getSignaturesOfType(type, 0)[0]; + if (contextSensitive) { + assignContextualParameterTypes(signature, contextualSignature, contextualMapper || identityMapper); + } + if (mightFixTypeParameters || !node.type && !signature.resolvedReturnType) { + var returnType = getReturnTypeFromBody(node, contextualMapper); + if (!signature.resolvedReturnType) { + signature.resolvedReturnType = returnType; + } + } + } + if (!contextChecked) { + checkSignatureDeclaration(node); + } + } + } + if (produceDiagnostics && node.kind !== 143 && node.kind !== 142) { + checkCollisionWithCapturedSuperVariable(node, node.name); + checkCollisionWithCapturedThisVariable(node, node.name); + } + return type; + } + function checkFunctionExpressionOrObjectLiteralMethodBody(node) { + ts.Debug.assert(node.kind !== 143 || ts.isObjectLiteralMethod(node)); + var isAsync = ts.isAsyncFunctionLike(node); + if (isAsync) { + emitAwaiter = true; + } + var returnType = node.type && getTypeFromTypeNode(node.type); + var promisedType; + if (returnType && isAsync) { + promisedType = checkAsyncFunctionReturnType(node); + } + if (returnType && !node.asteriskToken) { + checkIfNonVoidFunctionHasReturnExpressionsOrSingleThrowStatment(node, isAsync ? promisedType : returnType); + } + if (node.body) { + if (!node.type) { + getReturnTypeOfSignature(getSignatureFromDeclaration(node)); + } + if (node.body.kind === 192) { + checkSourceElement(node.body); + } + else { + var exprType = checkExpression(node.body); + if (returnType) { + if (isAsync) { + var awaitedType = checkAwaitedType(exprType, node.body, ts.Diagnostics.Expression_body_for_async_arrow_function_does_not_have_a_valid_callable_then_member); + checkTypeAssignableTo(awaitedType, promisedType, node.body); + } + else { + checkTypeAssignableTo(exprType, returnType, node.body); + } + } + checkFunctionAndClassExpressionBodies(node.body); + } + } + } + function checkArithmeticOperandType(operand, type, diagnostic) { + if (!isTypeAnyOrAllConstituentTypesHaveKind(type, 132)) { + error(operand, diagnostic); + return false; + } + return true; + } + function checkReferenceExpression(n, invalidReferenceMessage, constantVariableMessage) { + function findSymbol(n) { + var symbol = getNodeLinks(n).resolvedSymbol; + return symbol && getExportSymbolOfValueSymbolIfExported(symbol); + } + function isReferenceOrErrorExpression(n) { + switch (n.kind) { + case 69: { + var symbol = findSymbol(n); + return !symbol || symbol === unknownSymbol || symbol === argumentsSymbol || (symbol.flags & 3) !== 0; + } + case 166: { + var symbol = findSymbol(n); + return !symbol || symbol === unknownSymbol || (symbol.flags & ~8) !== 0; + } + case 167: + return true; + case 172: + return isReferenceOrErrorExpression(n.expression); + default: + return false; + } + } + function isConstVariableReference(n) { + switch (n.kind) { + case 69: + case 166: { + var symbol = findSymbol(n); + return symbol && (symbol.flags & 3) !== 0 && (getDeclarationFlagsFromSymbol(symbol) & 32768) !== 0; + } + case 167: { + var index = n.argumentExpression; + var symbol = findSymbol(n.expression); + if (symbol && index && index.kind === 9) { + var name_13 = index.text; + var prop = getPropertyOfType(getTypeOfSymbol(symbol), name_13); + return prop && (prop.flags & 3) !== 0 && (getDeclarationFlagsFromSymbol(prop) & 32768) !== 0; + } + return false; + } + case 172: + return isConstVariableReference(n.expression); + default: + return false; + } + } + if (!isReferenceOrErrorExpression(n)) { + error(n, invalidReferenceMessage); + return false; + } + if (isConstVariableReference(n)) { + error(n, constantVariableMessage); + return false; + } + return true; + } + function checkDeleteExpression(node) { + checkExpression(node.expression); + return booleanType; + } + function checkTypeOfExpression(node) { + checkExpression(node.expression); + return stringType; + } + function checkVoidExpression(node) { + checkExpression(node.expression); + return undefinedType; + } + function checkAwaitExpression(node) { + if (produceDiagnostics) { + if (!(node.parserContextFlags & 8)) { + grammarErrorOnFirstToken(node, ts.Diagnostics.await_expression_is_only_allowed_within_an_async_function); + } + if (isInParameterInitializerBeforeContainingFunction(node)) { + error(node, ts.Diagnostics.await_expressions_cannot_be_used_in_a_parameter_initializer); + } + } + var operandType = checkExpression(node.expression); + return checkAwaitedType(operandType, node); + } + function checkPrefixUnaryExpression(node) { + var operandType = checkExpression(node.operand); + switch (node.operator) { + case 35: + case 36: + case 50: + if (someConstituentTypeHasKind(operandType, 16777216)) { + error(node.operand, ts.Diagnostics.The_0_operator_cannot_be_applied_to_type_symbol, ts.tokenToString(node.operator)); + } + return numberType; + case 49: + return booleanType; + case 41: + case 42: + var ok = checkArithmeticOperandType(node.operand, operandType, ts.Diagnostics.An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type); + if (ok) { + checkReferenceExpression(node.operand, ts.Diagnostics.The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_property_or_indexer, ts.Diagnostics.The_operand_of_an_increment_or_decrement_operator_cannot_be_a_constant); + } + return numberType; + } + return unknownType; + } + function checkPostfixUnaryExpression(node) { + var operandType = checkExpression(node.operand); + var ok = checkArithmeticOperandType(node.operand, operandType, ts.Diagnostics.An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type); + if (ok) { + checkReferenceExpression(node.operand, ts.Diagnostics.The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_property_or_indexer, ts.Diagnostics.The_operand_of_an_increment_or_decrement_operator_cannot_be_a_constant); + } + return numberType; + } + function someConstituentTypeHasKind(type, kind) { + if (type.flags & kind) { + return true; + } + if (type.flags & 49152) { + var types = type.types; + for (var _i = 0; _i < types.length; _i++) { + var current = types[_i]; + if (current.flags & kind) { + return true; + } + } + return false; + } + return false; + } + function allConstituentTypesHaveKind(type, kind) { + if (type.flags & kind) { + return true; + } + if (type.flags & 49152) { + var types = type.types; + for (var _i = 0; _i < types.length; _i++) { + var current = types[_i]; + if (!(current.flags & kind)) { + return false; + } + } + return true; + } + return false; + } + function isConstEnumObjectType(type) { + return type.flags & (80896 | 65536) && type.symbol && isConstEnumSymbol(type.symbol); + } + function isConstEnumSymbol(symbol) { + return (symbol.flags & 128) !== 0; + } + function checkInstanceOfExpression(left, right, leftType, rightType) { + if (allConstituentTypesHaveKind(leftType, 16777726)) { + error(left, ts.Diagnostics.The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_parameter); + } + if (!(isTypeAny(rightType) || isTypeSubtypeOf(rightType, globalFunctionType))) { + error(right, ts.Diagnostics.The_right_hand_side_of_an_instanceof_expression_must_be_of_type_any_or_of_a_type_assignable_to_the_Function_interface_type); + } + return booleanType; + } + function checkInExpression(left, right, leftType, rightType) { + if (!isTypeAnyOrAllConstituentTypesHaveKind(leftType, 258 | 132 | 16777216)) { + error(left, ts.Diagnostics.The_left_hand_side_of_an_in_expression_must_be_of_type_any_string_number_or_symbol); + } + if (!isTypeAnyOrAllConstituentTypesHaveKind(rightType, 80896 | 512)) { + error(right, ts.Diagnostics.The_right_hand_side_of_an_in_expression_must_be_of_type_any_an_object_type_or_a_type_parameter); + } + return booleanType; + } + function checkObjectLiteralAssignment(node, sourceType, contextualMapper) { + var properties = node.properties; + for (var _i = 0; _i < properties.length; _i++) { + var p = properties[_i]; + if (p.kind === 245 || p.kind === 246) { + var name_14 = p.name; + var type = isTypeAny(sourceType) + ? sourceType + : getTypeOfPropertyOfType(sourceType, name_14.text) || + isNumericLiteralName(name_14.text) && getIndexTypeOfType(sourceType, 1) || + getIndexTypeOfType(sourceType, 0); + if (type) { + if (p.kind === 246) { + checkDestructuringAssignment(p, type); + } + else { + checkDestructuringAssignment(p.initializer || name_14, type); + } + } + else { + error(name_14, ts.Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(sourceType), ts.declarationNameToString(name_14)); + } + } + else { + error(p, ts.Diagnostics.Property_assignment_expected); + } + } + return sourceType; + } + function checkArrayLiteralAssignment(node, sourceType, contextualMapper) { + var elementType = checkIteratedTypeOrElementType(sourceType, node, false) || unknownType; + var elements = node.elements; + for (var i = 0; i < elements.length; i++) { + var e = elements[i]; + if (e.kind !== 187) { + if (e.kind !== 185) { + var propName = "" + i; + var type = isTypeAny(sourceType) + ? sourceType + : isTupleLikeType(sourceType) + ? getTypeOfPropertyOfType(sourceType, propName) + : elementType; + if (type) { + checkDestructuringAssignment(e, type, contextualMapper); + } + else { + if (isTupleType(sourceType)) { + error(e, ts.Diagnostics.Tuple_type_0_with_length_1_cannot_be_assigned_to_tuple_with_length_2, typeToString(sourceType), sourceType.elementTypes.length, elements.length); + } + else { + error(e, ts.Diagnostics.Type_0_has_no_property_1, typeToString(sourceType), propName); + } + } + } + else { + if (i < elements.length - 1) { + error(e, ts.Diagnostics.A_rest_element_must_be_last_in_an_array_destructuring_pattern); + } + else { + var restExpression = e.expression; + if (restExpression.kind === 181 && restExpression.operatorToken.kind === 56) { + error(restExpression.operatorToken, ts.Diagnostics.A_rest_element_cannot_have_an_initializer); + } + else { + checkDestructuringAssignment(restExpression, createArrayType(elementType), contextualMapper); + } + } + } + } + } + return sourceType; + } + function checkDestructuringAssignment(exprOrAssignment, sourceType, contextualMapper) { + var target; + if (exprOrAssignment.kind === 246) { + var prop = exprOrAssignment; + if (prop.objectAssignmentInitializer) { + checkBinaryLikeExpression(prop.name, prop.equalsToken, prop.objectAssignmentInitializer, contextualMapper); + } + target = exprOrAssignment.name; + } + else { + target = exprOrAssignment; + } + if (target.kind === 181 && target.operatorToken.kind === 56) { + checkBinaryExpression(target, contextualMapper); + target = target.left; + } + if (target.kind === 165) { + return checkObjectLiteralAssignment(target, sourceType, contextualMapper); + } + if (target.kind === 164) { + return checkArrayLiteralAssignment(target, sourceType, contextualMapper); + } + return checkReferenceAssignment(target, sourceType, contextualMapper); + } + function checkReferenceAssignment(target, sourceType, contextualMapper) { + var targetType = checkExpression(target, contextualMapper); + if (checkReferenceExpression(target, ts.Diagnostics.Invalid_left_hand_side_of_assignment_expression, ts.Diagnostics.Left_hand_side_of_assignment_expression_cannot_be_a_constant)) { + checkTypeAssignableTo(sourceType, targetType, target, undefined); + } + return sourceType; + } + function checkBinaryExpression(node, contextualMapper) { + return checkBinaryLikeExpression(node.left, node.operatorToken, node.right, contextualMapper, node); + } + function checkBinaryLikeExpression(left, operatorToken, right, contextualMapper, errorNode) { + var operator = operatorToken.kind; + if (operator === 56 && (left.kind === 165 || left.kind === 164)) { + return checkDestructuringAssignment(left, checkExpression(right, contextualMapper), contextualMapper); + } + var leftType = checkExpression(left, contextualMapper); + var rightType = checkExpression(right, contextualMapper); + switch (operator) { + case 37: + case 38: + case 59: + case 60: + case 39: + case 61: + case 40: + case 62: + case 36: + case 58: + case 43: + case 63: + case 44: + case 64: + case 45: + case 65: + case 47: + case 67: + case 48: + case 68: + case 46: + case 66: + if (leftType.flags & (32 | 64)) + leftType = rightType; + if (rightType.flags & (32 | 64)) + rightType = leftType; + var suggestedOperator; + if ((leftType.flags & 8) && + (rightType.flags & 8) && + (suggestedOperator = getSuggestedBooleanOperator(operatorToken.kind)) !== undefined) { + error(errorNode || operatorToken, ts.Diagnostics.The_0_operator_is_not_allowed_for_boolean_types_Consider_using_1_instead, ts.tokenToString(operatorToken.kind), ts.tokenToString(suggestedOperator)); + } + else { + var leftOk = checkArithmeticOperandType(left, leftType, ts.Diagnostics.The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type); + var rightOk = checkArithmeticOperandType(right, rightType, ts.Diagnostics.The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type); + if (leftOk && rightOk) { + checkAssignmentOperator(numberType); + } + } + return numberType; + case 35: + case 57: + if (leftType.flags & (32 | 64)) + leftType = rightType; + if (rightType.flags & (32 | 64)) + rightType = leftType; + var resultType; + if (allConstituentTypesHaveKind(leftType, 132) && allConstituentTypesHaveKind(rightType, 132)) { + resultType = numberType; + } + else { + if (allConstituentTypesHaveKind(leftType, 258) || allConstituentTypesHaveKind(rightType, 258)) { + resultType = stringType; + } + else if (isTypeAny(leftType) || isTypeAny(rightType)) { + resultType = leftType === unknownType || rightType === unknownType ? unknownType : anyType; + } + if (resultType && !checkForDisallowedESSymbolOperand(operator)) { + return resultType; + } + } + if (!resultType) { + reportOperatorError(); + return anyType; + } + if (operator === 57) { + checkAssignmentOperator(resultType); + } + return resultType; + case 25: + case 27: + case 28: + case 29: + if (!checkForDisallowedESSymbolOperand(operator)) { + return booleanType; + } + case 30: + case 31: + case 32: + case 33: + if (!isTypeAssignableTo(leftType, rightType) && !isTypeAssignableTo(rightType, leftType)) { + reportOperatorError(); + } + return booleanType; + case 91: + return checkInstanceOfExpression(left, right, leftType, rightType); + case 90: + return checkInExpression(left, right, leftType, rightType); + case 51: + return rightType; + case 52: + return getUnionType([leftType, rightType]); + case 56: + checkAssignmentOperator(rightType); + return getRegularTypeOfObjectLiteral(rightType); + case 24: + return rightType; + } + function checkForDisallowedESSymbolOperand(operator) { + var offendingSymbolOperand = someConstituentTypeHasKind(leftType, 16777216) ? left : + someConstituentTypeHasKind(rightType, 16777216) ? right : + undefined; + if (offendingSymbolOperand) { + error(offendingSymbolOperand, ts.Diagnostics.The_0_operator_cannot_be_applied_to_type_symbol, ts.tokenToString(operator)); + return false; + } + return true; + } + function getSuggestedBooleanOperator(operator) { + switch (operator) { + 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) { + var ok = checkReferenceExpression(left, ts.Diagnostics.Invalid_left_hand_side_of_assignment_expression, ts.Diagnostics.Left_hand_side_of_assignment_expression_cannot_be_a_constant); + if (ok) { + checkTypeAssignableTo(valueType, leftType, left, undefined); + } + } + } + function reportOperatorError() { + error(errorNode || operatorToken, ts.Diagnostics.Operator_0_cannot_be_applied_to_types_1_and_2, ts.tokenToString(operatorToken.kind), typeToString(leftType), typeToString(rightType)); + } + } + function isYieldExpressionInClass(node) { + var current = node; + var parent = node.parent; + while (parent) { + if (ts.isFunctionLike(parent) && current === parent.body) { + return false; + } + else if (ts.isClassLike(current)) { + return true; + } + current = parent; + parent = parent.parent; + } + return false; + } + function checkYieldExpression(node) { + if (produceDiagnostics) { + if (!(node.parserContextFlags & 2) || isYieldExpressionInClass(node)) { + grammarErrorOnFirstToken(node, ts.Diagnostics.A_yield_expression_is_only_allowed_in_a_generator_body); + } + if (isInParameterInitializerBeforeContainingFunction(node)) { + error(node, ts.Diagnostics.yield_expressions_cannot_be_used_in_a_parameter_initializer); + } + } + if (node.expression) { + var func = ts.getContainingFunction(node); + if (func && func.asteriskToken) { + var expressionType = checkExpressionCached(node.expression, undefined); + var expressionElementType; + var nodeIsYieldStar = !!node.asteriskToken; + if (nodeIsYieldStar) { + expressionElementType = checkElementTypeOfIterable(expressionType, node.expression); + } + if (func.type) { + var signatureElementType = getElementTypeOfIterableIterator(getTypeFromTypeNode(func.type)) || anyType; + if (nodeIsYieldStar) { + checkTypeAssignableTo(expressionElementType, signatureElementType, node.expression, undefined); + } + else { + checkTypeAssignableTo(expressionType, signatureElementType, node.expression, undefined); + } + } + } + } + return anyType; + } + function checkConditionalExpression(node, contextualMapper) { + checkExpression(node.condition); + var type1 = checkExpression(node.whenTrue, contextualMapper); + var type2 = checkExpression(node.whenFalse, contextualMapper); + return getUnionType([type1, type2]); + } + function checkTemplateExpression(node) { + ts.forEach(node.templateSpans, function (templateSpan) { + checkExpression(templateSpan.expression); + }); + return stringType; + } + function checkExpressionWithContextualType(node, contextualType, contextualMapper) { + var saveContextualType = node.contextualType; + node.contextualType = contextualType; + var result = checkExpression(node, contextualMapper); + node.contextualType = saveContextualType; + return result; + } + function checkExpressionCached(node, contextualMapper) { + var links = getNodeLinks(node); + if (!links.resolvedType) { + links.resolvedType = checkExpression(node, contextualMapper); + } + return links.resolvedType; + } + function checkPropertyAssignment(node, contextualMapper) { + if (node.name.kind === 136) { + checkComputedPropertyName(node.name); + } + return checkExpression(node.initializer, contextualMapper); + } + function checkObjectLiteralMethod(node, contextualMapper) { + checkGrammarMethod(node); + if (node.name.kind === 136) { + checkComputedPropertyName(node.name); + } + var uninstantiatedType = checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); + return instantiateTypeWithSingleGenericCallSignature(node, uninstantiatedType, contextualMapper); + } + function instantiateTypeWithSingleGenericCallSignature(node, type, contextualMapper) { + if (isInferentialContext(contextualMapper)) { + var signature = getSingleCallSignature(type); + if (signature && signature.typeParameters) { + var contextualType = getContextualType(node); + if (contextualType) { + var contextualSignature = getSingleCallSignature(contextualType); + if (contextualSignature && !contextualSignature.typeParameters) { + return getOrCreateTypeFromSignature(instantiateSignatureInContextOf(signature, contextualSignature, contextualMapper)); + } + } + } + } + return type; + } + function checkExpression(node, contextualMapper) { + var type; + if (node.kind === 135) { + type = checkQualifiedName(node); + } + else { + var uninstantiatedType = checkExpressionWorker(node, contextualMapper); + type = instantiateTypeWithSingleGenericCallSignature(node, uninstantiatedType, contextualMapper); + } + if (isConstEnumObjectType(type)) { + var ok = (node.parent.kind === 166 && node.parent.expression === node) || + (node.parent.kind === 167 && node.parent.expression === node) || + ((node.kind === 69 || node.kind === 135) && isInRightSideOfImportOrExportAssignment(node)); + if (!ok) { + error(node, ts.Diagnostics.const_enums_can_only_be_used_in_property_or_index_access_expressions_or_the_right_hand_side_of_an_import_declaration_or_export_assignment); + } + } + return type; + } + function checkNumericLiteral(node) { + checkGrammarNumericLiteral(node); + return numberType; + } + function checkExpressionWorker(node, contextualMapper) { + switch (node.kind) { + case 69: + return checkIdentifier(node); + case 97: + return checkThisExpression(node); + case 95: + return checkSuperExpression(node); + case 93: + return nullType; + case 99: + case 84: + return booleanType; + case 8: + return checkNumericLiteral(node); + case 183: + return checkTemplateExpression(node); + case 9: + case 11: + return stringType; + case 10: + return globalRegExpType; + case 164: + return checkArrayLiteral(node, contextualMapper); + case 165: + return checkObjectLiteral(node, contextualMapper); + case 166: + return checkPropertyAccessExpression(node); + case 167: + return checkIndexedAccess(node); + case 168: + case 169: + return checkCallExpression(node); + case 170: + return checkTaggedTemplateExpression(node); + case 172: + return checkExpression(node.expression, contextualMapper); + case 186: + return checkClassExpression(node); + case 173: + case 174: + return checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); + case 176: + return checkTypeOfExpression(node); + case 171: + case 189: + return checkAssertion(node); + case 175: + return checkDeleteExpression(node); + case 177: + return checkVoidExpression(node); + case 178: + return checkAwaitExpression(node); + case 179: + return checkPrefixUnaryExpression(node); + case 180: + return checkPostfixUnaryExpression(node); + case 181: + return checkBinaryExpression(node, contextualMapper); + case 182: + return checkConditionalExpression(node, contextualMapper); + case 185: + return checkSpreadElementExpression(node, contextualMapper); + case 187: + return undefinedType; + case 184: + return checkYieldExpression(node); + case 240: + return checkJsxExpression(node); + case 233: + return checkJsxElement(node); + case 234: + return checkJsxSelfClosingElement(node); + case 235: + ts.Debug.fail("Shouldn't ever directly check a JsxOpeningElement"); + } + return unknownType; + } + function checkTypeParameter(node) { + if (node.expression) { + grammarErrorOnFirstToken(node.expression, ts.Diagnostics.Type_expected); + } + checkSourceElement(node.constraint); + if (produceDiagnostics) { + checkTypeParameterHasIllegalReferencesInConstraint(node); + checkTypeNameIsReserved(node.name, ts.Diagnostics.Type_parameter_name_cannot_be_0); + } + } + function checkParameter(node) { + checkGrammarDecorators(node) || checkGrammarModifiers(node); + checkVariableLikeDeclaration(node); + var func = ts.getContainingFunction(node); + if (node.flags & 112) { + func = ts.getContainingFunction(node); + if (!(func.kind === 144 && ts.nodeIsPresent(func.body))) { + error(node, ts.Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation); + } + } + if (node.questionToken && ts.isBindingPattern(node.name) && func.body) { + error(node, ts.Diagnostics.A_binding_pattern_parameter_cannot_be_optional_in_an_implementation_signature); + } + if (node.dotDotDotToken && !ts.isBindingPattern(node.name) && !isArrayType(getTypeOfSymbol(node.symbol))) { + error(node, ts.Diagnostics.A_rest_parameter_must_be_of_an_array_type); + } + } + function isSyntacticallyValidGenerator(node) { + if (!node.asteriskToken || !node.body) { + return false; + } + return node.kind === 143 || + node.kind === 213 || + node.kind === 173; + } + function getTypePredicateParameterIndex(parameterList, parameter) { + if (parameterList) { + for (var i = 0; i < parameterList.length; i++) { + var param = parameterList[i]; + if (param.name.kind === 69 && + param.name.text === parameter.text) { + return i; + } + } + } + return -1; + } + function isInLegalTypePredicatePosition(node) { + switch (node.parent.kind) { + case 174: + case 147: + case 213: + case 173: + case 152: + case 143: + case 142: + return node === node.parent.type; + } + return false; + } + function checkSignatureDeclaration(node) { + if (node.kind === 149) { + checkGrammarIndexSignature(node); + } + else if (node.kind === 152 || node.kind === 213 || node.kind === 153 || + node.kind === 147 || node.kind === 144 || + node.kind === 148) { + checkGrammarFunctionLikeDeclaration(node); + } + checkTypeParameters(node.typeParameters); + ts.forEach(node.parameters, checkParameter); + if (node.type) { + if (node.type.kind === 150) { + var typePredicate = getSignatureFromDeclaration(node).typePredicate; + var typePredicateNode = node.type; + if (isInLegalTypePredicatePosition(typePredicateNode)) { + if (typePredicate.parameterIndex >= 0) { + if (node.parameters[typePredicate.parameterIndex].dotDotDotToken) { + error(typePredicateNode.parameterName, ts.Diagnostics.A_type_predicate_cannot_reference_a_rest_parameter); + } + else { + checkTypeAssignableTo(typePredicate.type, getTypeOfNode(node.parameters[typePredicate.parameterIndex]), typePredicateNode.type); + } + } + else if (typePredicateNode.parameterName) { + var hasReportedError = false; + for (var _i = 0, _a = node.parameters; _i < _a.length; _i++) { + var param = _a[_i]; + if (hasReportedError) { + break; + } + if (param.name.kind === 161 || + param.name.kind === 162) { + (function checkBindingPattern(pattern) { + for (var _i = 0, _a = pattern.elements; _i < _a.length; _i++) { + var element = _a[_i]; + if (element.name.kind === 69 && + element.name.text === typePredicate.parameterName) { + error(typePredicateNode.parameterName, ts.Diagnostics.A_type_predicate_cannot_reference_element_0_in_a_binding_pattern, typePredicate.parameterName); + hasReportedError = true; + break; + } + else if (element.name.kind === 162 || + element.name.kind === 161) { + checkBindingPattern(element.name); + } + } + })(param.name); + } + } + if (!hasReportedError) { + error(typePredicateNode.parameterName, ts.Diagnostics.Cannot_find_parameter_0, typePredicate.parameterName); + } + } + } + else { + error(typePredicateNode, ts.Diagnostics.A_type_predicate_is_only_allowed_in_return_type_position_for_functions_and_methods); + } + } + else { + checkSourceElement(node.type); + } + } + if (produceDiagnostics) { + checkCollisionWithArgumentsInGeneratedCode(node); + if (compilerOptions.noImplicitAny && !node.type) { + switch (node.kind) { + case 148: + error(node, ts.Diagnostics.Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); + break; + case 147: + error(node, ts.Diagnostics.Call_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); + break; + } + } + if (node.type) { + if (languageVersion >= 2 && isSyntacticallyValidGenerator(node)) { + var returnType = getTypeFromTypeNode(node.type); + if (returnType === voidType) { + error(node.type, ts.Diagnostics.A_generator_cannot_have_a_void_type_annotation); + } + else { + var generatorElementType = getElementTypeOfIterableIterator(returnType) || anyType; + var iterableIteratorInstantiation = createIterableIteratorType(generatorElementType); + checkTypeAssignableTo(iterableIteratorInstantiation, returnType, node.type); + } + } + } + } + checkSpecializedSignatureDeclaration(node); + } + function checkTypeForDuplicateIndexSignatures(node) { + if (node.kind === 215) { + var nodeSymbol = getSymbolOfNode(node); + if (nodeSymbol.declarations.length > 0 && nodeSymbol.declarations[0] !== node) { + return; + } + } + var indexSymbol = getIndexSymbol(getSymbolOfNode(node)); + if (indexSymbol) { + var seenNumericIndexer = false; + var seenStringIndexer = false; + for (var _i = 0, _a = indexSymbol.declarations; _i < _a.length; _i++) { + var decl = _a[_i]; + var declaration = decl; + if (declaration.parameters.length === 1 && declaration.parameters[0].type) { + switch (declaration.parameters[0].type.kind) { + case 130: + if (!seenStringIndexer) { + seenStringIndexer = true; + } + else { + error(declaration, ts.Diagnostics.Duplicate_string_index_signature); + } + break; + case 128: + if (!seenNumericIndexer) { + seenNumericIndexer = true; + } + else { + error(declaration, ts.Diagnostics.Duplicate_number_index_signature); + } + break; + } + } + } + } + } + function checkPropertyDeclaration(node) { + checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarProperty(node) || checkGrammarComputedPropertyName(node.name); + checkVariableLikeDeclaration(node); + } + function checkMethodDeclaration(node) { + checkGrammarMethod(node) || checkGrammarComputedPropertyName(node.name); + checkFunctionLikeDeclaration(node); + if (node.flags & 256 && node.body) { + error(node, ts.Diagnostics.Method_0_cannot_have_an_implementation_because_it_is_marked_abstract, ts.declarationNameToString(node.name)); + } + } + function checkConstructorDeclaration(node) { + checkSignatureDeclaration(node); + checkGrammarConstructorTypeParameters(node) || checkGrammarConstructorTypeAnnotation(node); + checkSourceElement(node.body); + var symbol = getSymbolOfNode(node); + var firstDeclaration = ts.getDeclarationOfKind(symbol, node.kind); + if (node === firstDeclaration) { + checkFunctionOrConstructorSymbol(symbol); + } + if (ts.nodeIsMissing(node.body)) { + return; + } + if (!produceDiagnostics) { + return; + } + function isSuperCallExpression(n) { + return n.kind === 168 && n.expression.kind === 95; + } + function containsSuperCallAsComputedPropertyName(n) { + return n.name && containsSuperCall(n.name); + } + function containsSuperCall(n) { + if (isSuperCallExpression(n)) { + return true; + } + else if (ts.isFunctionLike(n)) { + return false; + } + else if (ts.isClassLike(n)) { + return ts.forEach(n.members, containsSuperCallAsComputedPropertyName); + } + return ts.forEachChild(n, containsSuperCall); + } + function markThisReferencesAsErrors(n) { + if (n.kind === 97) { + error(n, ts.Diagnostics.this_cannot_be_referenced_in_current_location); + } + else if (n.kind !== 173 && n.kind !== 213) { + ts.forEachChild(n, markThisReferencesAsErrors); + } + } + function isInstancePropertyWithInitializer(n) { + return n.kind === 141 && + !(n.flags & 128) && + !!n.initializer; + } + var containingClassDecl = node.parent; + if (ts.getClassExtendsHeritageClauseElement(containingClassDecl)) { + var containingClassSymbol = getSymbolOfNode(containingClassDecl); + var containingClassInstanceType = getDeclaredTypeOfSymbol(containingClassSymbol); + var baseConstructorType = getBaseConstructorTypeOfClass(containingClassInstanceType); + if (containsSuperCall(node.body)) { + if (baseConstructorType === nullType) { + error(node, ts.Diagnostics.A_constructor_cannot_contain_a_super_call_when_its_class_extends_null); + } + var superCallShouldBeFirst = ts.forEach(node.parent.members, isInstancePropertyWithInitializer) || + ts.forEach(node.parameters, function (p) { return p.flags & (16 | 32 | 64); }); + if (superCallShouldBeFirst) { + var statements = node.body.statements; + var superCallStatement; + for (var _i = 0; _i < statements.length; _i++) { + var statement = statements[_i]; + if (statement.kind === 195 && isSuperCallExpression(statement.expression)) { + superCallStatement = statement; + break; + } + if (!ts.isPrologueDirective(statement)) { + break; + } + } + if (!superCallStatement) { + error(node, ts.Diagnostics.A_super_call_must_be_the_first_statement_in_the_constructor_when_a_class_contains_initialized_properties_or_has_parameter_properties); + } + else { + markThisReferencesAsErrors(superCallStatement.expression); + } + } + } + else if (baseConstructorType !== nullType) { + error(node, ts.Diagnostics.Constructors_for_derived_classes_must_contain_a_super_call); + } + } + } + function checkAccessorDeclaration(node) { + if (produceDiagnostics) { + checkGrammarFunctionLikeDeclaration(node) || checkGrammarAccessor(node) || checkGrammarComputedPropertyName(node.name); + if (node.kind === 145) { + if (!ts.isInAmbientContext(node) && ts.nodeIsPresent(node.body) && !(bodyContainsAReturnStatement(node.body) || bodyContainsSingleThrowStatement(node.body))) { + error(node.name, ts.Diagnostics.A_get_accessor_must_return_a_value_or_consist_of_a_single_throw_statement); + } + } + if (!ts.hasDynamicName(node)) { + var otherKind = node.kind === 145 ? 146 : 145; + var otherAccessor = ts.getDeclarationOfKind(node.symbol, otherKind); + if (otherAccessor) { + if (((node.flags & 112) !== (otherAccessor.flags & 112))) { + error(node.name, ts.Diagnostics.Getter_and_setter_accessors_do_not_agree_in_visibility); + } + var currentAccessorType = getAnnotatedAccessorType(node); + var otherAccessorType = getAnnotatedAccessorType(otherAccessor); + if (currentAccessorType && otherAccessorType) { + if (!isTypeIdenticalTo(currentAccessorType, otherAccessorType)) { + error(node, ts.Diagnostics.get_and_set_accessor_must_have_the_same_type); + } + } + } + } + getTypeOfAccessors(getSymbolOfNode(node)); + } + checkFunctionLikeDeclaration(node); + } + function checkMissingDeclaration(node) { + checkDecorators(node); + } + function checkTypeArgumentConstraints(typeParameters, typeArguments) { + var result = true; + for (var i = 0; i < typeParameters.length; i++) { + var constraint = getConstraintOfTypeParameter(typeParameters[i]); + if (constraint) { + var typeArgument = typeArguments[i]; + result = result && checkTypeAssignableTo(getTypeFromTypeNode(typeArgument), constraint, typeArgument, ts.Diagnostics.Type_0_does_not_satisfy_the_constraint_1); + } + } + return result; + } + function checkTypeReferenceNode(node) { + checkGrammarTypeArguments(node, node.typeArguments); + var type = getTypeFromTypeReference(node); + if (type !== unknownType && node.typeArguments) { + ts.forEach(node.typeArguments, checkSourceElement); + if (produceDiagnostics) { + var symbol = getNodeLinks(node).resolvedSymbol; + var typeParameters = symbol.flags & 524288 ? getSymbolLinks(symbol).typeParameters : type.target.localTypeParameters; + checkTypeArgumentConstraints(typeParameters, node.typeArguments); + } + } + } + function checkTypeQuery(node) { + getTypeFromTypeQueryNode(node); + } + function checkTypeLiteral(node) { + ts.forEach(node.members, checkSourceElement); + if (produceDiagnostics) { + var type = getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node); + checkIndexConstraints(type); + checkTypeForDuplicateIndexSignatures(node); + } + } + function checkArrayType(node) { + checkSourceElement(node.elementType); + } + function checkTupleType(node) { + var hasErrorFromDisallowedTrailingComma = checkGrammarForDisallowedTrailingComma(node.elementTypes); + if (!hasErrorFromDisallowedTrailingComma && node.elementTypes.length === 0) { + grammarErrorOnNode(node, ts.Diagnostics.A_tuple_type_element_list_cannot_be_empty); + } + ts.forEach(node.elementTypes, checkSourceElement); + } + function checkUnionOrIntersectionType(node) { + ts.forEach(node.types, checkSourceElement); + } + function isPrivateWithinAmbient(node) { + return (node.flags & 32) && ts.isInAmbientContext(node); + } + function checkSpecializedSignatureDeclaration(signatureDeclarationNode) { + if (!produceDiagnostics) { + return; + } + var signature = getSignatureFromDeclaration(signatureDeclarationNode); + if (!signature.hasStringLiterals) { + return; + } + if (ts.nodeIsPresent(signatureDeclarationNode.body)) { + error(signatureDeclarationNode, ts.Diagnostics.A_signature_with_an_implementation_cannot_use_a_string_literal_type); + return; + } + var signaturesToCheck; + if (!signatureDeclarationNode.name && signatureDeclarationNode.parent && signatureDeclarationNode.parent.kind === 215) { + ts.Debug.assert(signatureDeclarationNode.kind === 147 || signatureDeclarationNode.kind === 148); + var signatureKind = signatureDeclarationNode.kind === 147 ? 0 : 1; + var containingSymbol = getSymbolOfNode(signatureDeclarationNode.parent); + var containingType = getDeclaredTypeOfSymbol(containingSymbol); + signaturesToCheck = getSignaturesOfType(containingType, signatureKind); + } + else { + signaturesToCheck = getSignaturesOfSymbol(getSymbolOfNode(signatureDeclarationNode)); + } + for (var _i = 0; _i < signaturesToCheck.length; _i++) { + var otherSignature = signaturesToCheck[_i]; + if (!otherSignature.hasStringLiterals && isSignatureAssignableTo(signature, otherSignature)) { + return; + } + } + error(signatureDeclarationNode, ts.Diagnostics.Specialized_overload_signature_is_not_assignable_to_any_non_specialized_signature); + } + function getEffectiveDeclarationFlags(n, flagsToCheck) { + var flags = ts.getCombinedNodeFlags(n); + if (n.parent.kind !== 215 && + n.parent.kind !== 214 && + n.parent.kind !== 186 && + ts.isInAmbientContext(n)) { + if (!(flags & 2)) { + flags |= 1; + } + flags |= 2; + } + return flags & flagsToCheck; + } + function checkFunctionOrConstructorSymbol(symbol) { + if (!produceDiagnostics) { + return; + } + function getCanonicalOverload(overloads, implementation) { + var implementationSharesContainerWithFirstOverload = implementation !== undefined && implementation.parent === overloads[0].parent; + return implementationSharesContainerWithFirstOverload ? implementation : overloads[0]; + } + function checkFlagAgreementBetweenOverloads(overloads, implementation, flagsToCheck, someOverloadFlags, allOverloadFlags) { + var someButNotAllOverloadFlags = someOverloadFlags ^ allOverloadFlags; + if (someButNotAllOverloadFlags !== 0) { + var canonicalFlags = getEffectiveDeclarationFlags(getCanonicalOverload(overloads, implementation), flagsToCheck); + ts.forEach(overloads, function (o) { + var deviation = getEffectiveDeclarationFlags(o, flagsToCheck) ^ canonicalFlags; + if (deviation & 1) { + error(o.name, ts.Diagnostics.Overload_signatures_must_all_be_exported_or_not_exported); + } + else if (deviation & 2) { + error(o.name, ts.Diagnostics.Overload_signatures_must_all_be_ambient_or_non_ambient); + } + else if (deviation & (32 | 64)) { + error(o.name, ts.Diagnostics.Overload_signatures_must_all_be_public_private_or_protected); + } + else if (deviation & 256) { + error(o.name, ts.Diagnostics.Overload_signatures_must_all_be_abstract_or_not_abstract); + } + }); + } + } + function checkQuestionTokenAgreementBetweenOverloads(overloads, implementation, someHaveQuestionToken, allHaveQuestionToken) { + if (someHaveQuestionToken !== allHaveQuestionToken) { + var canonicalHasQuestionToken = ts.hasQuestionToken(getCanonicalOverload(overloads, implementation)); + ts.forEach(overloads, function (o) { + var deviation = ts.hasQuestionToken(o) !== canonicalHasQuestionToken; + if (deviation) { + error(o.name, ts.Diagnostics.Overload_signatures_must_all_be_optional_or_required); + } + }); + } + } + var flagsToCheck = 1 | 2 | 32 | 64 | 256; + var someNodeFlags = 0; + var allNodeFlags = flagsToCheck; + var someHaveQuestionToken = false; + var allHaveQuestionToken = true; + var hasOverloads = false; + var bodyDeclaration; + var lastSeenNonAmbientDeclaration; + var previousDeclaration; + var declarations = symbol.declarations; + var isConstructor = (symbol.flags & 16384) !== 0; + function reportImplementationExpectedError(node) { + if (node.name && ts.nodeIsMissing(node.name)) { + return; + } + var seen = false; + var subsequentNode = ts.forEachChild(node.parent, function (c) { + if (seen) { + return c; + } + else { + seen = c === node; + } + }); + if (subsequentNode) { + if (subsequentNode.kind === node.kind) { + var errorNode_1 = subsequentNode.name || subsequentNode; + if (node.name && subsequentNode.name && node.name.text === subsequentNode.name.text) { + ts.Debug.assert(node.kind === 143 || node.kind === 142); + ts.Debug.assert((node.flags & 128) !== (subsequentNode.flags & 128)); + var diagnostic = node.flags & 128 ? ts.Diagnostics.Function_overload_must_be_static : ts.Diagnostics.Function_overload_must_not_be_static; + error(errorNode_1, diagnostic); + return; + } + else if (ts.nodeIsPresent(subsequentNode.body)) { + error(errorNode_1, ts.Diagnostics.Function_implementation_name_must_be_0, ts.declarationNameToString(node.name)); + return; + } + } + } + var errorNode = node.name || node; + if (isConstructor) { + error(errorNode, ts.Diagnostics.Constructor_implementation_is_missing); + } + else { + if (node.flags & 256) { + error(errorNode, ts.Diagnostics.All_declarations_of_an_abstract_method_must_be_consecutive); + } + else { + error(errorNode, ts.Diagnostics.Function_implementation_is_missing_or_not_immediately_following_the_declaration); + } + } + } + var isExportSymbolInsideModule = symbol.parent && symbol.parent.flags & 1536; + var duplicateFunctionDeclaration = false; + var multipleConstructorImplementation = false; + for (var _i = 0; _i < declarations.length; _i++) { + var current = declarations[_i]; + var node = current; + var inAmbientContext = ts.isInAmbientContext(node); + var inAmbientContextOrInterface = node.parent.kind === 215 || node.parent.kind === 155 || inAmbientContext; + if (inAmbientContextOrInterface) { + previousDeclaration = undefined; + } + if (node.kind === 213 || node.kind === 143 || node.kind === 142 || node.kind === 144) { + var currentNodeFlags = getEffectiveDeclarationFlags(node, flagsToCheck); + someNodeFlags |= currentNodeFlags; + allNodeFlags &= currentNodeFlags; + someHaveQuestionToken = someHaveQuestionToken || ts.hasQuestionToken(node); + allHaveQuestionToken = allHaveQuestionToken && ts.hasQuestionToken(node); + if (ts.nodeIsPresent(node.body) && bodyDeclaration) { + if (isConstructor) { + multipleConstructorImplementation = true; + } + else { + duplicateFunctionDeclaration = true; + } + } + else if (!isExportSymbolInsideModule && previousDeclaration && previousDeclaration.parent === node.parent && previousDeclaration.end !== node.pos) { + reportImplementationExpectedError(previousDeclaration); + } + if (ts.nodeIsPresent(node.body)) { + if (!bodyDeclaration) { + bodyDeclaration = node; + } + } + else { + hasOverloads = true; + } + previousDeclaration = node; + if (!inAmbientContextOrInterface) { + lastSeenNonAmbientDeclaration = node; + } + } + } + if (multipleConstructorImplementation) { + ts.forEach(declarations, function (declaration) { + error(declaration, ts.Diagnostics.Multiple_constructor_implementations_are_not_allowed); + }); + } + if (duplicateFunctionDeclaration) { + ts.forEach(declarations, function (declaration) { + error(declaration.name, ts.Diagnostics.Duplicate_function_implementation); + }); + } + if (!isExportSymbolInsideModule && lastSeenNonAmbientDeclaration && !lastSeenNonAmbientDeclaration.body && + !(lastSeenNonAmbientDeclaration.flags & 256)) { + reportImplementationExpectedError(lastSeenNonAmbientDeclaration); + } + if (hasOverloads) { + checkFlagAgreementBetweenOverloads(declarations, bodyDeclaration, flagsToCheck, someNodeFlags, allNodeFlags); + checkQuestionTokenAgreementBetweenOverloads(declarations, bodyDeclaration, someHaveQuestionToken, allHaveQuestionToken); + if (bodyDeclaration) { + var signatures = getSignaturesOfSymbol(symbol); + var bodySignature = getSignatureFromDeclaration(bodyDeclaration); + if (!bodySignature.hasStringLiterals) { + for (var _a = 0; _a < signatures.length; _a++) { + var signature = signatures[_a]; + if (!signature.hasStringLiterals && !isSignatureAssignableTo(bodySignature, signature)) { + error(signature.declaration, ts.Diagnostics.Overload_signature_is_not_compatible_with_function_implementation); + break; + } + } + } + } + } + } + function checkExportsOnMergedDeclarations(node) { + if (!produceDiagnostics) { + return; + } + var symbol = node.localSymbol; + if (!symbol) { + symbol = getSymbolOfNode(node); + if (!(symbol.flags & 7340032)) { + return; + } + } + if (ts.getDeclarationOfKind(symbol, node.kind) !== node) { + return; + } + var exportedDeclarationSpaces = 0; + var nonExportedDeclarationSpaces = 0; + var defaultExportedDeclarationSpaces = 0; + for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { + var d = _a[_i]; + var declarationSpaces = getDeclarationSpaces(d); + var effectiveDeclarationFlags = getEffectiveDeclarationFlags(d, 1 | 1024); + if (effectiveDeclarationFlags & 1) { + if (effectiveDeclarationFlags & 1024) { + defaultExportedDeclarationSpaces |= declarationSpaces; + } + else { + exportedDeclarationSpaces |= declarationSpaces; + } + } + else { + nonExportedDeclarationSpaces |= declarationSpaces; + } + } + var nonDefaultExportedDeclarationSpaces = exportedDeclarationSpaces | nonExportedDeclarationSpaces; + var commonDeclarationSpacesForExportsAndLocals = exportedDeclarationSpaces & nonExportedDeclarationSpaces; + var commonDeclarationSpacesForDefaultAndNonDefault = defaultExportedDeclarationSpaces & nonDefaultExportedDeclarationSpaces; + if (commonDeclarationSpacesForExportsAndLocals || commonDeclarationSpacesForDefaultAndNonDefault) { + for (var _b = 0, _c = symbol.declarations; _b < _c.length; _b++) { + var d = _c[_b]; + var declarationSpaces = getDeclarationSpaces(d); + if (declarationSpaces & commonDeclarationSpacesForDefaultAndNonDefault) { + error(d.name, ts.Diagnostics.Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_default_0_declaration_instead, ts.declarationNameToString(d.name)); + } + else if (declarationSpaces & commonDeclarationSpacesForExportsAndLocals) { + error(d.name, ts.Diagnostics.Individual_declarations_in_merged_declaration_0_must_be_all_exported_or_all_local, ts.declarationNameToString(d.name)); + } + } + } + function getDeclarationSpaces(d) { + switch (d.kind) { + case 215: + return 2097152; + case 218: + return d.name.kind === 9 || ts.getModuleInstanceState(d) !== 0 + ? 4194304 | 1048576 + : 4194304; + case 214: + case 217: + return 2097152 | 1048576; + case 221: + var result = 0; + var target = resolveAlias(getSymbolOfNode(d)); + ts.forEach(target.declarations, function (d) { result |= getDeclarationSpaces(d); }); + return result; + default: + return 1048576; + } + } + } + function checkNonThenableType(type, location, message) { + type = getWidenedType(type); + if (!isTypeAny(type) && isTypeAssignableTo(type, getGlobalThenableType())) { + if (location) { + if (!message) { + message = ts.Diagnostics.Operand_for_await_does_not_have_a_valid_callable_then_member; + } + error(location, message); + } + return unknownType; + } + return type; + } + function getPromisedType(promise) { + if (promise.flags & 1) { + return undefined; + } + if ((promise.flags & 4096) && promise.target === tryGetGlobalPromiseType()) { + return promise.typeArguments[0]; + } + var globalPromiseLikeType = getInstantiatedGlobalPromiseLikeType(); + if (globalPromiseLikeType === emptyObjectType || !isTypeAssignableTo(promise, globalPromiseLikeType)) { + return undefined; + } + var thenFunction = getTypeOfPropertyOfType(promise, "then"); + if (thenFunction && (thenFunction.flags & 1)) { + return undefined; + } + var thenSignatures = thenFunction ? getSignaturesOfType(thenFunction, 0) : emptyArray; + if (thenSignatures.length === 0) { + return undefined; + } + var onfulfilledParameterType = getUnionType(ts.map(thenSignatures, getTypeOfFirstParameterOfSignature)); + if (onfulfilledParameterType.flags & 1) { + return undefined; + } + var onfulfilledParameterSignatures = getSignaturesOfType(onfulfilledParameterType, 0); + if (onfulfilledParameterSignatures.length === 0) { + return undefined; + } + var valueParameterType = getUnionType(ts.map(onfulfilledParameterSignatures, getTypeOfFirstParameterOfSignature)); + return valueParameterType; + } + function getTypeOfFirstParameterOfSignature(signature) { + return getTypeAtPosition(signature, 0); + } + function getAwaitedType(type) { + return checkAwaitedType(type, undefined, undefined); + } + function checkAwaitedType(type, location, message) { + return checkAwaitedTypeWorker(type); + function checkAwaitedTypeWorker(type) { + if (type.flags & 16384) { + var types = []; + for (var _i = 0, _a = type.types; _i < _a.length; _i++) { + var constituentType = _a[_i]; + types.push(checkAwaitedTypeWorker(constituentType)); + } + return getUnionType(types); + } + else { + var promisedType = getPromisedType(type); + if (promisedType === undefined) { + return checkNonThenableType(type, location, message); + } + else { + if (type.id === promisedType.id || awaitedTypeStack.indexOf(promisedType.id) >= 0) { + if (location) { + error(location, ts.Diagnostics._0_is_referenced_directly_or_indirectly_in_the_fulfillment_callback_of_its_own_then_method, symbolToString(type.symbol)); + } + return unknownType; + } + awaitedTypeStack.push(type.id); + var awaitedType = checkAwaitedTypeWorker(promisedType); + awaitedTypeStack.pop(); + return awaitedType; + } + } + } + } + function checkAsyncFunctionReturnType(node) { + var globalPromiseConstructorLikeType = getGlobalPromiseConstructorLikeType(); + if (globalPromiseConstructorLikeType === emptyObjectType) { + return unknownType; + } + var promiseType = getTypeFromTypeNode(node.type); + if (promiseType === unknownType && compilerOptions.isolatedModules) { + return unknownType; + } + var promiseConstructor = getMergedSymbol(promiseType.symbol); + if (!promiseConstructor || !symbolIsValue(promiseConstructor)) { + error(node, ts.Diagnostics.Type_0_is_not_a_valid_async_function_return_type, typeToString(promiseType)); + return unknownType; + } + var promiseConstructorType = getTypeOfSymbol(promiseConstructor); + if (!checkTypeAssignableTo(promiseConstructorType, globalPromiseConstructorLikeType, node, ts.Diagnostics.Type_0_is_not_a_valid_async_function_return_type)) { + return unknownType; + } + var promiseName = ts.getEntityNameFromTypeNode(node.type); + var root = getFirstIdentifier(promiseName); + var rootSymbol = getSymbol(node.locals, root.text, 107455); + if (rootSymbol) { + error(rootSymbol.valueDeclaration, ts.Diagnostics.Duplicate_identifier_0_Compiler_uses_declaration_1_to_support_async_functions, root.text, getFullyQualifiedName(promiseConstructor)); + return unknownType; + } + return checkAwaitedType(promiseType, node, ts.Diagnostics.An_async_function_or_method_must_have_a_valid_awaitable_return_type); + } + function checkDecorator(node) { + var signature = getResolvedSignature(node); + var returnType = getReturnTypeOfSignature(signature); + if (returnType.flags & 1) { + return; + } + var expectedReturnType; + var headMessage = getDiagnosticHeadMessageForDecoratorResolution(node); + var errorInfo; + switch (node.parent.kind) { + case 214: + var classSymbol = getSymbolOfNode(node.parent); + var classConstructorType = getTypeOfSymbol(classSymbol); + expectedReturnType = getUnionType([classConstructorType, voidType]); + break; + case 138: + expectedReturnType = voidType; + errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.The_return_type_of_a_parameter_decorator_function_must_be_either_void_or_any); + break; + case 141: + expectedReturnType = voidType; + errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.The_return_type_of_a_property_decorator_function_must_be_either_void_or_any); + break; + case 143: + case 145: + case 146: + var methodType = getTypeOfNode(node.parent); + var descriptorType = createTypedPropertyDescriptorType(methodType); + expectedReturnType = getUnionType([descriptorType, voidType]); + break; + } + checkTypeAssignableTo(returnType, expectedReturnType, node, headMessage, errorInfo); + } + function checkTypeNodeAsExpression(node) { + if (node && node.kind === 151) { + var root = getFirstIdentifier(node.typeName); + var meaning = root.parent.kind === 151 ? 793056 : 1536; + var rootSymbol = resolveName(root, root.text, meaning | 8388608, undefined, undefined); + if (rootSymbol && rootSymbol.flags & 8388608) { + var aliasTarget = resolveAlias(rootSymbol); + if (aliasTarget.flags & 107455 && !isConstEnumOrConstEnumOnlyModule(resolveAlias(rootSymbol))) { + markAliasSymbolAsReferenced(rootSymbol); + } + } + } + } + function checkTypeAnnotationAsExpression(node) { + switch (node.kind) { + case 141: + checkTypeNodeAsExpression(node.type); + break; + case 138: + checkTypeNodeAsExpression(node.type); + break; + case 143: + checkTypeNodeAsExpression(node.type); + break; + case 145: + checkTypeNodeAsExpression(node.type); + break; + case 146: + checkTypeNodeAsExpression(ts.getSetAccessorTypeAnnotationNode(node)); + break; + } + } + function checkParameterTypeAnnotationsAsExpressions(node) { + for (var _i = 0, _a = node.parameters; _i < _a.length; _i++) { + var parameter = _a[_i]; + checkTypeAnnotationAsExpression(parameter); + } + } + function checkDecorators(node) { + if (!node.decorators) { + return; + } + if (!ts.nodeCanBeDecorated(node)) { + return; + } + if (!compilerOptions.experimentalDecorators) { + error(node, ts.Diagnostics.Experimental_support_for_decorators_is_a_feature_that_is_subject_to_change_in_a_future_release_Specify_experimentalDecorators_to_remove_this_warning); + } + if (compilerOptions.emitDecoratorMetadata) { + switch (node.kind) { + case 214: + var constructor = ts.getFirstConstructorWithBody(node); + if (constructor) { + checkParameterTypeAnnotationsAsExpressions(constructor); + } + break; + case 143: + checkParameterTypeAnnotationsAsExpressions(node); + case 146: + case 145: + case 141: + case 138: + checkTypeAnnotationAsExpression(node); + break; + } + } + emitDecorate = true; + if (node.kind === 138) { + emitParam = true; + } + ts.forEach(node.decorators, checkDecorator); + } + function checkFunctionDeclaration(node) { + if (produceDiagnostics) { + checkFunctionLikeDeclaration(node) || checkGrammarForGenerator(node); + checkCollisionWithCapturedSuperVariable(node, node.name); + checkCollisionWithCapturedThisVariable(node, node.name); + checkCollisionWithRequireExportsInGeneratedCode(node, node.name); + } + } + function checkFunctionLikeDeclaration(node) { + checkDecorators(node); + checkSignatureDeclaration(node); + var isAsync = ts.isAsyncFunctionLike(node); + if (isAsync) { + emitAwaiter = true; + } + if (node.name && node.name.kind === 136) { + checkComputedPropertyName(node.name); + } + if (!ts.hasDynamicName(node)) { + var symbol = getSymbolOfNode(node); + var localSymbol = node.localSymbol || symbol; + var firstDeclaration = ts.getDeclarationOfKind(localSymbol, node.kind); + if (node === firstDeclaration) { + checkFunctionOrConstructorSymbol(localSymbol); + } + if (symbol.parent) { + if (ts.getDeclarationOfKind(symbol, node.kind) === node) { + checkFunctionOrConstructorSymbol(symbol); + } + } + } + checkSourceElement(node.body); + if (node.type && !isAccessor(node.kind) && !node.asteriskToken) { + var returnType = getTypeFromTypeNode(node.type); + var promisedType; + if (isAsync) { + promisedType = checkAsyncFunctionReturnType(node); + } + checkIfNonVoidFunctionHasReturnExpressionsOrSingleThrowStatment(node, isAsync ? promisedType : returnType); + } + if (produceDiagnostics && !node.type) { + if (compilerOptions.noImplicitAny && ts.nodeIsMissing(node.body) && !isPrivateWithinAmbient(node)) { + reportImplicitAnyError(node, anyType); + } + if (node.asteriskToken && ts.nodeIsPresent(node.body)) { + getReturnTypeOfSignature(getSignatureFromDeclaration(node)); + } + } + } + function checkBlock(node) { + if (node.kind === 192) { + checkGrammarStatementInAmbientContext(node); + } + ts.forEach(node.statements, checkSourceElement); + if (ts.isFunctionBlock(node) || node.kind === 219) { + checkFunctionAndClassExpressionBodies(node); + } + } + function checkCollisionWithArgumentsInGeneratedCode(node) { + if (!ts.hasRestParameter(node) || ts.isInAmbientContext(node) || ts.nodeIsMissing(node.body)) { + return; + } + ts.forEach(node.parameters, function (p) { + if (p.name && !ts.isBindingPattern(p.name) && p.name.text === argumentsSymbol.name) { + error(p, ts.Diagnostics.Duplicate_identifier_arguments_Compiler_uses_arguments_to_initialize_rest_parameters); + } + }); + } + function needCollisionCheckForIdentifier(node, identifier, name) { + if (!(identifier && identifier.text === name)) { + return false; + } + if (node.kind === 141 || + node.kind === 140 || + node.kind === 143 || + node.kind === 142 || + node.kind === 145 || + node.kind === 146) { + return false; + } + if (ts.isInAmbientContext(node)) { + return false; + } + var root = ts.getRootDeclaration(node); + if (root.kind === 138 && ts.nodeIsMissing(root.parent.body)) { + return false; + } + return true; + } + function checkCollisionWithCapturedThisVariable(node, name) { + if (needCollisionCheckForIdentifier(node, name, "_this")) { + potentialThisCollisions.push(node); + } + } + function checkIfThisIsCapturedInEnclosingScope(node) { + var current = node; + while (current) { + if (getNodeCheckFlags(current) & 4) { + var isDeclaration_1 = node.kind !== 69; + if (isDeclaration_1) { + error(node.name, ts.Diagnostics.Duplicate_identifier_this_Compiler_uses_variable_declaration_this_to_capture_this_reference); + } + else { + error(node, ts.Diagnostics.Expression_resolves_to_variable_declaration_this_that_compiler_uses_to_capture_this_reference); + } + return; + } + current = current.parent; + } + } + function checkCollisionWithCapturedSuperVariable(node, name) { + if (!needCollisionCheckForIdentifier(node, name, "_super")) { + return; + } + var enclosingClass = ts.getContainingClass(node); + if (!enclosingClass || ts.isInAmbientContext(enclosingClass)) { + return; + } + if (ts.getClassExtendsHeritageClauseElement(enclosingClass)) { + var isDeclaration_2 = node.kind !== 69; + if (isDeclaration_2) { + error(node, ts.Diagnostics.Duplicate_identifier_super_Compiler_uses_super_to_capture_base_class_reference); + } + else { + error(node, ts.Diagnostics.Expression_resolves_to_super_that_compiler_uses_to_capture_base_class_reference); + } + } + } + function checkCollisionWithRequireExportsInGeneratedCode(node, name) { + if (!needCollisionCheckForIdentifier(node, name, "require") && !needCollisionCheckForIdentifier(node, name, "exports")) { + return; + } + if (node.kind === 218 && ts.getModuleInstanceState(node) !== 1) { + return; + } + var parent = getDeclarationContainer(node); + if (parent.kind === 248 && ts.isExternalModule(parent)) { + error(name, ts.Diagnostics.Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module, ts.declarationNameToString(name), ts.declarationNameToString(name)); + } + } + function checkVarDeclaredNamesNotShadowed(node) { + if ((ts.getCombinedNodeFlags(node) & 49152) !== 0 || ts.isParameterDeclaration(node)) { + return; + } + if (node.kind === 211 && !node.initializer) { + return; + } + var symbol = getSymbolOfNode(node); + if (symbol.flags & 1) { + var localDeclarationSymbol = resolveName(node, node.name.text, 3, undefined, undefined); + if (localDeclarationSymbol && + localDeclarationSymbol !== symbol && + localDeclarationSymbol.flags & 2) { + if (getDeclarationFlagsFromSymbol(localDeclarationSymbol) & 49152) { + var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 212); + var container = varDeclList.parent.kind === 193 && varDeclList.parent.parent + ? varDeclList.parent.parent + : undefined; + var namesShareScope = container && + (container.kind === 192 && ts.isFunctionLike(container.parent) || + container.kind === 219 || + container.kind === 218 || + container.kind === 248); + if (!namesShareScope) { + var name_15 = symbolToString(localDeclarationSymbol); + error(node, ts.Diagnostics.Cannot_initialize_outer_scoped_variable_0_in_the_same_scope_as_block_scoped_declaration_1, name_15, name_15); + } + } + } + } + } + function checkParameterInitializer(node) { + if (ts.getRootDeclaration(node).kind !== 138) { + return; + } + var func = ts.getContainingFunction(node); + visit(node.initializer); + function visit(n) { + if (n.kind === 69) { + var referencedSymbol = getNodeLinks(n).resolvedSymbol; + if (referencedSymbol && referencedSymbol !== unknownSymbol && getSymbol(func.locals, referencedSymbol.name, 107455) === referencedSymbol) { + if (referencedSymbol.valueDeclaration.kind === 138) { + if (referencedSymbol.valueDeclaration === node) { + error(n, ts.Diagnostics.Parameter_0_cannot_be_referenced_in_its_initializer, ts.declarationNameToString(node.name)); + return; + } + if (referencedSymbol.valueDeclaration.pos < node.pos) { + return; + } + } + error(n, ts.Diagnostics.Initializer_of_parameter_0_cannot_reference_identifier_1_declared_after_it, ts.declarationNameToString(node.name), ts.declarationNameToString(n)); + } + } + else { + ts.forEachChild(n, visit); + } + } + } + function checkVariableLikeDeclaration(node) { + checkDecorators(node); + checkSourceElement(node.type); + if (node.name.kind === 136) { + checkComputedPropertyName(node.name); + if (node.initializer) { + checkExpressionCached(node.initializer); + } + } + if (ts.isBindingPattern(node.name)) { + ts.forEach(node.name.elements, checkSourceElement); + } + if (node.initializer && ts.getRootDeclaration(node).kind === 138 && ts.nodeIsMissing(ts.getContainingFunction(node).body)) { + error(node, ts.Diagnostics.A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation); + return; + } + if (ts.isBindingPattern(node.name)) { + if (node.initializer) { + checkTypeAssignableTo(checkExpressionCached(node.initializer), getWidenedTypeForVariableLikeDeclaration(node), node, undefined); + checkParameterInitializer(node); + } + return; + } + var symbol = getSymbolOfNode(node); + var type = getTypeOfVariableOrParameterOrProperty(symbol); + if (node === symbol.valueDeclaration) { + if (node.initializer) { + checkTypeAssignableTo(checkExpressionCached(node.initializer), type, node, undefined); + checkParameterInitializer(node); + } + } + else { + var declarationType = 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)); + } + if (node.initializer) { + checkTypeAssignableTo(checkExpressionCached(node.initializer), declarationType, node, undefined); + } + } + if (node.kind !== 141 && node.kind !== 140) { + checkExportsOnMergedDeclarations(node); + if (node.kind === 211 || node.kind === 163) { + checkVarDeclaredNamesNotShadowed(node); + } + checkCollisionWithCapturedSuperVariable(node, node.name); + checkCollisionWithCapturedThisVariable(node, node.name); + checkCollisionWithRequireExportsInGeneratedCode(node, node.name); + } + } + function checkVariableDeclaration(node) { + checkGrammarVariableDeclaration(node); + return checkVariableLikeDeclaration(node); + } + function checkBindingElement(node) { + checkGrammarBindingElement(node); + return checkVariableLikeDeclaration(node); + } + function checkVariableStatement(node) { + checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarVariableDeclarationList(node.declarationList) || checkGrammarForDisallowedLetOrConstStatement(node); + ts.forEach(node.declarationList.declarations, checkSourceElement); + } + function checkGrammarDisallowedModifiersOnObjectLiteralExpressionMethod(node) { + if (node.modifiers && node.parent.kind === 165) { + if (ts.isAsyncFunctionLike(node)) { + if (node.modifiers.length > 1) { + return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); + } + } + else { + return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); + } + } + } + function checkExpressionStatement(node) { + checkGrammarStatementInAmbientContext(node); + checkExpression(node.expression); + } + function checkIfStatement(node) { + checkGrammarStatementInAmbientContext(node); + checkExpression(node.expression); + checkSourceElement(node.thenStatement); + checkSourceElement(node.elseStatement); + } + function checkDoStatement(node) { + checkGrammarStatementInAmbientContext(node); + checkSourceElement(node.statement); + checkExpression(node.expression); + } + function checkWhileStatement(node) { + checkGrammarStatementInAmbientContext(node); + checkExpression(node.expression); + checkSourceElement(node.statement); + } + function checkForStatement(node) { + if (!checkGrammarStatementInAmbientContext(node)) { + if (node.initializer && node.initializer.kind === 212) { + checkGrammarVariableDeclarationList(node.initializer); + } + } + if (node.initializer) { + if (node.initializer.kind === 212) { + ts.forEach(node.initializer.declarations, checkVariableDeclaration); + } + else { + checkExpression(node.initializer); + } + } + if (node.condition) + checkExpression(node.condition); + if (node.incrementor) + checkExpression(node.incrementor); + checkSourceElement(node.statement); + } + function checkForOfStatement(node) { + checkGrammarForInOrForOfStatement(node); + if (node.initializer.kind === 212) { + checkForInOrForOfVariableDeclaration(node); + } + else { + var varExpr = node.initializer; + var iteratedType = checkRightHandSideOfForOf(node.expression); + if (varExpr.kind === 164 || varExpr.kind === 165) { + checkDestructuringAssignment(varExpr, iteratedType || unknownType); + } + else { + var leftType = checkExpression(varExpr); + checkReferenceExpression(varExpr, ts.Diagnostics.Invalid_left_hand_side_in_for_of_statement, ts.Diagnostics.The_left_hand_side_of_a_for_of_statement_cannot_be_a_previously_defined_constant); + if (iteratedType) { + checkTypeAssignableTo(iteratedType, leftType, varExpr, undefined); + } + } + } + checkSourceElement(node.statement); + } + function checkForInStatement(node) { + checkGrammarForInOrForOfStatement(node); + if (node.initializer.kind === 212) { + var variable = node.initializer.declarations[0]; + if (variable && ts.isBindingPattern(variable.name)) { + error(variable.name, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern); + } + checkForInOrForOfVariableDeclaration(node); + } + else { + var varExpr = node.initializer; + var leftType = checkExpression(varExpr); + if (varExpr.kind === 164 || varExpr.kind === 165) { + error(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern); + } + else if (!isTypeAnyOrAllConstituentTypesHaveKind(leftType, 258)) { + error(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_must_be_of_type_string_or_any); + } + else { + checkReferenceExpression(varExpr, ts.Diagnostics.Invalid_left_hand_side_in_for_in_statement, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_previously_defined_constant); + } + } + var rightType = checkExpression(node.expression); + if (!isTypeAnyOrAllConstituentTypesHaveKind(rightType, 80896 | 512)) { + error(node.expression, ts.Diagnostics.The_right_hand_side_of_a_for_in_statement_must_be_of_type_any_an_object_type_or_a_type_parameter); + } + checkSourceElement(node.statement); + } + function checkForInOrForOfVariableDeclaration(iterationStatement) { + var variableDeclarationList = iterationStatement.initializer; + if (variableDeclarationList.declarations.length >= 1) { + var decl = variableDeclarationList.declarations[0]; + checkVariableDeclaration(decl); + } + } + function checkRightHandSideOfForOf(rhsExpression) { + var expressionType = getTypeOfExpression(rhsExpression); + return checkIteratedTypeOrElementType(expressionType, rhsExpression, true); + } + function checkIteratedTypeOrElementType(inputType, errorNode, allowStringInput) { + if (isTypeAny(inputType)) { + return inputType; + } + if (languageVersion >= 2) { + return checkElementTypeOfIterable(inputType, errorNode); + } + if (allowStringInput) { + return checkElementTypeOfArrayOrString(inputType, errorNode); + } + if (isArrayLikeType(inputType)) { + var indexType = getIndexTypeOfType(inputType, 1); + if (indexType) { + return indexType; + } + } + error(errorNode, ts.Diagnostics.Type_0_is_not_an_array_type, typeToString(inputType)); + return unknownType; + } + function checkElementTypeOfIterable(iterable, errorNode) { + var elementType = getElementTypeOfIterable(iterable, errorNode); + if (errorNode && elementType) { + checkTypeAssignableTo(iterable, createIterableType(elementType), errorNode); + } + return elementType || anyType; + } + function getElementTypeOfIterable(type, errorNode) { + if (isTypeAny(type)) { + return undefined; + } + var typeAsIterable = type; + if (!typeAsIterable.iterableElementType) { + if ((type.flags & 4096) && type.target === globalIterableType) { + typeAsIterable.iterableElementType = type.typeArguments[0]; + } + else { + var iteratorFunction = getTypeOfPropertyOfType(type, ts.getPropertyNameForKnownSymbolName("iterator")); + if (isTypeAny(iteratorFunction)) { + return undefined; + } + var iteratorFunctionSignatures = iteratorFunction ? getSignaturesOfType(iteratorFunction, 0) : emptyArray; + if (iteratorFunctionSignatures.length === 0) { + if (errorNode) { + error(errorNode, ts.Diagnostics.Type_must_have_a_Symbol_iterator_method_that_returns_an_iterator); + } + return undefined; + } + typeAsIterable.iterableElementType = getElementTypeOfIterator(getUnionType(ts.map(iteratorFunctionSignatures, getReturnTypeOfSignature)), errorNode); + } + } + return typeAsIterable.iterableElementType; + } + function getElementTypeOfIterator(type, errorNode) { + if (isTypeAny(type)) { + return undefined; + } + var typeAsIterator = type; + if (!typeAsIterator.iteratorElementType) { + if ((type.flags & 4096) && type.target === globalIteratorType) { + typeAsIterator.iteratorElementType = type.typeArguments[0]; + } + else { + var iteratorNextFunction = getTypeOfPropertyOfType(type, "next"); + if (isTypeAny(iteratorNextFunction)) { + return undefined; + } + var iteratorNextFunctionSignatures = iteratorNextFunction ? getSignaturesOfType(iteratorNextFunction, 0) : emptyArray; + if (iteratorNextFunctionSignatures.length === 0) { + if (errorNode) { + error(errorNode, ts.Diagnostics.An_iterator_must_have_a_next_method); + } + return undefined; + } + var iteratorNextResult = getUnionType(ts.map(iteratorNextFunctionSignatures, getReturnTypeOfSignature)); + if (isTypeAny(iteratorNextResult)) { + return undefined; + } + var iteratorNextValue = getTypeOfPropertyOfType(iteratorNextResult, "value"); + if (!iteratorNextValue) { + if (errorNode) { + error(errorNode, ts.Diagnostics.The_type_returned_by_the_next_method_of_an_iterator_must_have_a_value_property); + } + return undefined; + } + typeAsIterator.iteratorElementType = iteratorNextValue; + } + } + return typeAsIterator.iteratorElementType; + } + function getElementTypeOfIterableIterator(type) { + if (isTypeAny(type)) { + return undefined; + } + if ((type.flags & 4096) && type.target === globalIterableIteratorType) { + return type.typeArguments[0]; + } + return getElementTypeOfIterable(type, undefined) || + getElementTypeOfIterator(type, undefined); + } + function checkElementTypeOfArrayOrString(arrayOrStringType, errorNode) { + ts.Debug.assert(languageVersion < 2); + var arrayType = removeTypesFromUnionType(arrayOrStringType, 258, true, true); + var hasStringConstituent = arrayOrStringType !== arrayType; + var reportedError = false; + if (hasStringConstituent) { + if (languageVersion < 1) { + error(errorNode, ts.Diagnostics.Using_a_string_in_a_for_of_statement_is_only_supported_in_ECMAScript_5_and_higher); + reportedError = true; + } + if (arrayType === emptyObjectType) { + return stringType; + } + } + if (!isArrayLikeType(arrayType)) { + if (!reportedError) { + var diagnostic = hasStringConstituent + ? ts.Diagnostics.Type_0_is_not_an_array_type + : ts.Diagnostics.Type_0_is_not_an_array_type_or_a_string_type; + error(errorNode, diagnostic, typeToString(arrayType)); + } + return hasStringConstituent ? stringType : unknownType; + } + var arrayElementType = getIndexTypeOfType(arrayType, 1) || unknownType; + if (hasStringConstituent) { + if (arrayElementType.flags & 258) { + return stringType; + } + return getUnionType([arrayElementType, stringType]); + } + return arrayElementType; + } + function checkBreakOrContinueStatement(node) { + checkGrammarStatementInAmbientContext(node) || checkGrammarBreakOrContinueStatement(node); + } + function isGetAccessorWithAnnotatatedSetAccessor(node) { + return !!(node.kind === 145 && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(node.symbol, 146))); + } + function checkReturnStatement(node) { + if (!checkGrammarStatementInAmbientContext(node)) { + var functionBlock = ts.getContainingFunction(node); + if (!functionBlock) { + grammarErrorOnFirstToken(node, ts.Diagnostics.A_return_statement_can_only_be_used_within_a_function_body); + } + } + if (node.expression) { + var func = ts.getContainingFunction(node); + if (func) { + var signature = getSignatureFromDeclaration(func); + var returnType = getReturnTypeOfSignature(signature); + var exprType = checkExpressionCached(node.expression); + if (func.asteriskToken) { + return; + } + if (func.kind === 146) { + error(node.expression, ts.Diagnostics.Setters_cannot_return_a_value); + } + else if (func.kind === 144) { + if (!isTypeAssignableTo(exprType, returnType)) { + error(node.expression, ts.Diagnostics.Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class); + } + } + else if (func.type || isGetAccessorWithAnnotatatedSetAccessor(func) || signature.typePredicate) { + if (ts.isAsyncFunctionLike(func)) { + var promisedType = getPromisedType(returnType); + var awaitedType = checkAwaitedType(exprType, node.expression, ts.Diagnostics.Return_expression_in_async_function_does_not_have_a_valid_callable_then_member); + if (promisedType) { + checkTypeAssignableTo(awaitedType, promisedType, node.expression); + } + } + else { + checkTypeAssignableTo(exprType, returnType, node.expression); + } + } + } + } + } + function checkWithStatement(node) { + if (!checkGrammarStatementInAmbientContext(node)) { + if (node.parserContextFlags & 8) { + grammarErrorOnFirstToken(node, ts.Diagnostics.with_statements_are_not_allowed_in_an_async_function_block); + } + } + checkExpression(node.expression); + error(node.expression, ts.Diagnostics.All_symbols_within_a_with_block_will_be_resolved_to_any); + } + function checkSwitchStatement(node) { + checkGrammarStatementInAmbientContext(node); + var firstDefaultClause; + var hasDuplicateDefaultClause = false; + var expressionType = checkExpression(node.expression); + ts.forEach(node.caseBlock.clauses, function (clause) { + if (clause.kind === 242 && !hasDuplicateDefaultClause) { + if (firstDefaultClause === undefined) { + firstDefaultClause = clause; + } + else { + var sourceFile = ts.getSourceFileOfNode(node); + var start = ts.skipTrivia(sourceFile.text, clause.pos); + var end = clause.statements.length > 0 ? clause.statements[0].pos : clause.end; + grammarErrorAtPos(sourceFile, start, end - start, ts.Diagnostics.A_default_clause_cannot_appear_more_than_once_in_a_switch_statement); + hasDuplicateDefaultClause = true; + } + } + if (produceDiagnostics && clause.kind === 241) { + var caseClause = clause; + var caseType = checkExpression(caseClause.expression); + if (!isTypeAssignableTo(expressionType, caseType)) { + checkTypeAssignableTo(caseType, expressionType, caseClause.expression, undefined); + } + } + ts.forEach(clause.statements, checkSourceElement); + }); + } + function checkLabeledStatement(node) { + if (!checkGrammarStatementInAmbientContext(node)) { + var current = node.parent; + while (current) { + if (ts.isFunctionLike(current)) { + break; + } + if (current.kind === 207 && current.label.text === node.label.text) { + var sourceFile = ts.getSourceFileOfNode(node); + grammarErrorOnNode(node.label, ts.Diagnostics.Duplicate_label_0, ts.getTextOfNodeFromSourceText(sourceFile.text, node.label)); + break; + } + current = current.parent; + } + } + checkSourceElement(node.statement); + } + function checkThrowStatement(node) { + if (!checkGrammarStatementInAmbientContext(node)) { + if (node.expression === undefined) { + grammarErrorAfterFirstToken(node, ts.Diagnostics.Line_break_not_permitted_here); + } + } + if (node.expression) { + checkExpression(node.expression); + } + } + function checkTryStatement(node) { + checkGrammarStatementInAmbientContext(node); + checkBlock(node.tryBlock); + var catchClause = node.catchClause; + if (catchClause) { + if (catchClause.variableDeclaration) { + if (catchClause.variableDeclaration.name.kind !== 69) { + grammarErrorOnFirstToken(catchClause.variableDeclaration.name, ts.Diagnostics.Catch_clause_variable_name_must_be_an_identifier); + } + else if (catchClause.variableDeclaration.type) { + grammarErrorOnFirstToken(catchClause.variableDeclaration.type, ts.Diagnostics.Catch_clause_variable_cannot_have_a_type_annotation); + } + else if (catchClause.variableDeclaration.initializer) { + grammarErrorOnFirstToken(catchClause.variableDeclaration.initializer, ts.Diagnostics.Catch_clause_variable_cannot_have_an_initializer); + } + else { + var identifierName = catchClause.variableDeclaration.name.text; + var locals = catchClause.block.locals; + if (locals && ts.hasProperty(locals, identifierName)) { + var localSymbol = locals[identifierName]; + if (localSymbol && (localSymbol.flags & 2) !== 0) { + grammarErrorOnNode(localSymbol.valueDeclaration, ts.Diagnostics.Cannot_redeclare_identifier_0_in_catch_clause, identifierName); + } + } + } + } + checkBlock(catchClause.block); + } + if (node.finallyBlock) { + checkBlock(node.finallyBlock); + } + } + function checkIndexConstraints(type) { + var declaredNumberIndexer = getIndexDeclarationOfSymbol(type.symbol, 1); + var declaredStringIndexer = getIndexDeclarationOfSymbol(type.symbol, 0); + var stringIndexType = getIndexTypeOfType(type, 0); + var numberIndexType = getIndexTypeOfType(type, 1); + if (stringIndexType || numberIndexType) { + ts.forEach(getPropertiesOfObjectType(type), function (prop) { + var propType = getTypeOfSymbol(prop); + checkIndexConstraintForProperty(prop, propType, type, declaredStringIndexer, stringIndexType, 0); + checkIndexConstraintForProperty(prop, propType, type, declaredNumberIndexer, numberIndexType, 1); + }); + if (type.flags & 1024 && ts.isClassLike(type.symbol.valueDeclaration)) { + var classDeclaration = type.symbol.valueDeclaration; + for (var _i = 0, _a = classDeclaration.members; _i < _a.length; _i++) { + var member = _a[_i]; + if (!(member.flags & 128) && ts.hasDynamicName(member)) { + var propType = getTypeOfSymbol(member.symbol); + checkIndexConstraintForProperty(member.symbol, propType, type, declaredStringIndexer, stringIndexType, 0); + checkIndexConstraintForProperty(member.symbol, propType, type, declaredNumberIndexer, numberIndexType, 1); + } + } + } + } + var errorNode; + if (stringIndexType && numberIndexType) { + errorNode = declaredNumberIndexer || declaredStringIndexer; + if (!errorNode && (type.flags & 2048)) { + var someBaseTypeHasBothIndexers = ts.forEach(getBaseTypes(type), function (base) { return getIndexTypeOfType(base, 0) && getIndexTypeOfType(base, 1); }); + errorNode = someBaseTypeHasBothIndexers ? undefined : type.symbol.declarations[0]; + } + } + if (errorNode && !isTypeAssignableTo(numberIndexType, stringIndexType)) { + error(errorNode, ts.Diagnostics.Numeric_index_type_0_is_not_assignable_to_string_index_type_1, typeToString(numberIndexType), typeToString(stringIndexType)); + } + function checkIndexConstraintForProperty(prop, propertyType, containingType, indexDeclaration, indexType, indexKind) { + if (!indexType) { + return; + } + if (indexKind === 1 && !isNumericName(prop.valueDeclaration.name)) { + return; + } + var errorNode; + if (prop.valueDeclaration.name.kind === 136 || prop.parent === containingType.symbol) { + errorNode = prop.valueDeclaration; + } + else if (indexDeclaration) { + errorNode = indexDeclaration; + } + else if (containingType.flags & 2048) { + var someBaseClassHasBothPropertyAndIndexer = ts.forEach(getBaseTypes(containingType), function (base) { return getPropertyOfObjectType(base, prop.name) && getIndexTypeOfType(base, indexKind); }); + errorNode = someBaseClassHasBothPropertyAndIndexer ? undefined : containingType.symbol.declarations[0]; + } + if (errorNode && !isTypeAssignableTo(propertyType, indexType)) { + var errorMessage = indexKind === 0 + ? ts.Diagnostics.Property_0_of_type_1_is_not_assignable_to_string_index_type_2 + : ts.Diagnostics.Property_0_of_type_1_is_not_assignable_to_numeric_index_type_2; + error(errorNode, errorMessage, symbolToString(prop), typeToString(propertyType), typeToString(indexType)); + } + } + } + function checkTypeNameIsReserved(name, message) { + switch (name.text) { + case "any": + case "number": + case "boolean": + case "string": + case "symbol": + case "void": + error(name, message, name.text); + } + } + function checkTypeParameters(typeParameterDeclarations) { + if (typeParameterDeclarations) { + for (var i = 0, n = typeParameterDeclarations.length; i < n; i++) { + var node = typeParameterDeclarations[i]; + checkTypeParameter(node); + if (produceDiagnostics) { + for (var j = 0; j < i; j++) { + if (typeParameterDeclarations[j].symbol === node.symbol) { + error(node.name, ts.Diagnostics.Duplicate_identifier_0, ts.declarationNameToString(node.name)); + } + } + } + } + } + } + function checkClassExpression(node) { + checkClassLikeDeclaration(node); + return getTypeOfSymbol(getSymbolOfNode(node)); + } + function checkClassDeclaration(node) { + if (!node.name && !(node.flags & 1024)) { + grammarErrorOnFirstToken(node, ts.Diagnostics.A_class_declaration_without_the_default_modifier_must_have_a_name); + } + checkClassLikeDeclaration(node); + ts.forEach(node.members, checkSourceElement); + } + function checkClassLikeDeclaration(node) { + checkGrammarClassDeclarationHeritageClauses(node); + checkDecorators(node); + if (node.name) { + checkTypeNameIsReserved(node.name, ts.Diagnostics.Class_name_cannot_be_0); + checkCollisionWithCapturedThisVariable(node, node.name); + checkCollisionWithRequireExportsInGeneratedCode(node, node.name); + } + checkTypeParameters(node.typeParameters); + checkExportsOnMergedDeclarations(node); + var symbol = getSymbolOfNode(node); + var type = getDeclaredTypeOfSymbol(symbol); + var typeWithThis = getTypeWithThisArgument(type); + var staticType = getTypeOfSymbol(symbol); + var baseTypeNode = ts.getClassExtendsHeritageClauseElement(node); + if (baseTypeNode) { + emitExtends = emitExtends || !ts.isInAmbientContext(node); + var baseTypes = getBaseTypes(type); + if (baseTypes.length && produceDiagnostics) { + var baseType = baseTypes[0]; + var staticBaseType = getBaseConstructorTypeOfClass(type); + checkSourceElement(baseTypeNode.expression); + if (baseTypeNode.typeArguments) { + ts.forEach(baseTypeNode.typeArguments, checkSourceElement); + for (var _i = 0, _a = getConstructorsForTypeArguments(staticBaseType, baseTypeNode.typeArguments); _i < _a.length; _i++) { + var constructor = _a[_i]; + if (!checkTypeArgumentConstraints(constructor.typeParameters, baseTypeNode.typeArguments)) { + break; + } + } + } + checkTypeAssignableTo(typeWithThis, getTypeWithThisArgument(baseType, type.thisType), node.name || node, ts.Diagnostics.Class_0_incorrectly_extends_base_class_1); + checkTypeAssignableTo(staticType, getTypeWithoutSignatures(staticBaseType), node.name || node, ts.Diagnostics.Class_static_side_0_incorrectly_extends_base_class_static_side_1); + if (!(staticBaseType.symbol && staticBaseType.symbol.flags & 32)) { + var constructors = getInstantiatedConstructorsForTypeArguments(staticBaseType, baseTypeNode.typeArguments); + if (ts.forEach(constructors, function (sig) { return getReturnTypeOfSignature(sig) !== baseType; })) { + error(baseTypeNode.expression, ts.Diagnostics.Base_constructors_must_all_have_the_same_return_type); + } + } + checkKindsOfPropertyMemberOverrides(type, baseType); + } + } + var implementedTypeNodes = ts.getClassImplementsHeritageClauseElements(node); + if (implementedTypeNodes) { + for (var _b = 0; _b < implementedTypeNodes.length; _b++) { + var typeRefNode = implementedTypeNodes[_b]; + if (!ts.isSupportedExpressionWithTypeArguments(typeRefNode)) { + error(typeRefNode.expression, ts.Diagnostics.A_class_can_only_implement_an_identifier_Slashqualified_name_with_optional_type_arguments); + } + checkTypeReferenceNode(typeRefNode); + if (produceDiagnostics) { + var t = getTypeFromTypeNode(typeRefNode); + if (t !== unknownType) { + var declaredType = (t.flags & 4096) ? t.target : t; + if (declaredType.flags & (1024 | 2048)) { + checkTypeAssignableTo(typeWithThis, getTypeWithThisArgument(t, type.thisType), node.name || node, ts.Diagnostics.Class_0_incorrectly_implements_interface_1); + } + else { + error(typeRefNode, ts.Diagnostics.A_class_may_only_implement_another_class_or_interface); + } + } + } + } + } + if (produceDiagnostics) { + checkIndexConstraints(type); + checkTypeForDuplicateIndexSignatures(node); + } + } + function getTargetSymbol(s) { + return s.flags & 16777216 ? getSymbolLinks(s).target : s; + } + function getClassLikeDeclarationOfSymbol(symbol) { + return ts.forEach(symbol.declarations, function (d) { return ts.isClassLike(d) ? d : undefined; }); + } + function checkKindsOfPropertyMemberOverrides(type, baseType) { + var baseProperties = getPropertiesOfObjectType(baseType); + for (var _i = 0; _i < baseProperties.length; _i++) { + var baseProperty = baseProperties[_i]; + var base = getTargetSymbol(baseProperty); + if (base.flags & 134217728) { + continue; + } + var derived = getTargetSymbol(getPropertyOfObjectType(type, base.name)); + var baseDeclarationFlags = getDeclarationFlagsFromSymbol(base); + ts.Debug.assert(!!derived, "derived should point to something, even if it is the base class' declaration."); + if (derived) { + if (derived === base) { + var derivedClassDecl = getClassLikeDeclarationOfSymbol(type.symbol); + if (baseDeclarationFlags & 256 && (!derivedClassDecl || !(derivedClassDecl.flags & 256))) { + if (derivedClassDecl.kind === 186) { + error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1, symbolToString(baseProperty), typeToString(baseType)); + } + else { + error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_0_does_not_implement_inherited_abstract_member_1_from_class_2, typeToString(type), symbolToString(baseProperty), typeToString(baseType)); + } + } + } + else { + var derivedDeclarationFlags = getDeclarationFlagsFromSymbol(derived); + if ((baseDeclarationFlags & 32) || (derivedDeclarationFlags & 32)) { + continue; + } + if ((baseDeclarationFlags & 128) !== (derivedDeclarationFlags & 128)) { + continue; + } + if ((base.flags & derived.flags & 8192) || ((base.flags & 98308) && (derived.flags & 98308))) { + continue; + } + var errorMessage = void 0; + if (base.flags & 8192) { + if (derived.flags & 98304) { + errorMessage = ts.Diagnostics.Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_accessor; + } + else { + ts.Debug.assert((derived.flags & 4) !== 0); + errorMessage = ts.Diagnostics.Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_property; + } + } + else if (base.flags & 4) { + ts.Debug.assert((derived.flags & 8192) !== 0); + errorMessage = ts.Diagnostics.Class_0_defines_instance_member_property_1_but_extended_class_2_defines_it_as_instance_member_function; + } + else { + ts.Debug.assert((base.flags & 98304) !== 0); + ts.Debug.assert((derived.flags & 8192) !== 0); + errorMessage = ts.Diagnostics.Class_0_defines_instance_member_accessor_1_but_extended_class_2_defines_it_as_instance_member_function; + } + error(derived.valueDeclaration.name, errorMessage, typeToString(baseType), symbolToString(base), typeToString(type)); + } + } + } + } + function isAccessor(kind) { + return kind === 145 || kind === 146; + } + function areTypeParametersIdentical(list1, list2) { + if (!list1 && !list2) { + return true; + } + if (!list1 || !list2 || list1.length !== list2.length) { + return false; + } + for (var i = 0, len = list1.length; i < len; i++) { + var tp1 = list1[i]; + var tp2 = list2[i]; + if (tp1.name.text !== tp2.name.text) { + return false; + } + if (!tp1.constraint && !tp2.constraint) { + continue; + } + if (!tp1.constraint || !tp2.constraint) { + return false; + } + if (!isTypeIdenticalTo(getTypeFromTypeNode(tp1.constraint), getTypeFromTypeNode(tp2.constraint))) { + return false; + } + } + return true; + } + function checkInheritedPropertiesAreIdentical(type, typeNode) { + var baseTypes = getBaseTypes(type); + if (baseTypes.length < 2) { + return true; + } + var seen = {}; + ts.forEach(resolveDeclaredMembers(type).declaredProperties, function (p) { seen[p.name] = { prop: p, containingType: type }; }); + var ok = true; + for (var _i = 0; _i < baseTypes.length; _i++) { + var base = baseTypes[_i]; + var properties = getPropertiesOfObjectType(getTypeWithThisArgument(base, type.thisType)); + for (var _a = 0; _a < properties.length; _a++) { + var prop = properties[_a]; + if (!ts.hasProperty(seen, prop.name)) { + seen[prop.name] = { prop: prop, containingType: base }; + } + else { + var existing = seen[prop.name]; + var isInheritedProperty = existing.containingType !== type; + if (isInheritedProperty && !isPropertyIdenticalTo(existing.prop, prop)) { + ok = false; + var typeName1 = typeToString(existing.containingType); + var typeName2 = typeToString(base); + var errorInfo = ts.chainDiagnosticMessages(undefined, ts.Diagnostics.Named_property_0_of_types_1_and_2_are_not_identical, symbolToString(prop), typeName1, typeName2); + errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.Interface_0_cannot_simultaneously_extend_types_1_and_2, typeToString(type), typeName1, typeName2); + diagnostics.add(ts.createDiagnosticForNodeFromMessageChain(typeNode, errorInfo)); + } + } + } + } + return ok; + } + function checkInterfaceDeclaration(node) { + checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarInterfaceDeclaration(node); + checkTypeParameters(node.typeParameters); + if (produceDiagnostics) { + checkTypeNameIsReserved(node.name, ts.Diagnostics.Interface_name_cannot_be_0); + checkExportsOnMergedDeclarations(node); + var symbol = getSymbolOfNode(node); + var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 215); + if (symbol.declarations.length > 1) { + if (node !== firstInterfaceDecl && !areTypeParametersIdentical(firstInterfaceDecl.typeParameters, node.typeParameters)) { + error(node.name, ts.Diagnostics.All_declarations_of_an_interface_must_have_identical_type_parameters); + } + } + if (node === firstInterfaceDecl) { + var type = getDeclaredTypeOfSymbol(symbol); + var typeWithThis = getTypeWithThisArgument(type); + if (checkInheritedPropertiesAreIdentical(type, node.name)) { + for (var _i = 0, _a = getBaseTypes(type); _i < _a.length; _i++) { + var baseType = _a[_i]; + checkTypeAssignableTo(typeWithThis, getTypeWithThisArgument(baseType, type.thisType), node.name, ts.Diagnostics.Interface_0_incorrectly_extends_interface_1); + } + checkIndexConstraints(type); + } + } + } + ts.forEach(ts.getInterfaceBaseTypeNodes(node), function (heritageElement) { + if (!ts.isSupportedExpressionWithTypeArguments(heritageElement)) { + error(heritageElement.expression, ts.Diagnostics.An_interface_can_only_extend_an_identifier_Slashqualified_name_with_optional_type_arguments); + } + checkTypeReferenceNode(heritageElement); + }); + ts.forEach(node.members, checkSourceElement); + if (produceDiagnostics) { + checkTypeForDuplicateIndexSignatures(node); + } + } + function checkTypeAliasDeclaration(node) { + checkGrammarDecorators(node) || checkGrammarModifiers(node); + checkTypeNameIsReserved(node.name, ts.Diagnostics.Type_alias_name_cannot_be_0); + checkSourceElement(node.type); + } + function computeEnumMemberValues(node) { + var nodeLinks = getNodeLinks(node); + if (!(nodeLinks.flags & 8192)) { + var enumSymbol = getSymbolOfNode(node); + var enumType = getDeclaredTypeOfSymbol(enumSymbol); + var autoValue = 0; + var ambient = ts.isInAmbientContext(node); + var enumIsConst = ts.isConst(node); + for (var _i = 0, _a = node.members; _i < _a.length; _i++) { + var member = _a[_i]; + if (member.name.kind === 136) { + error(member.name, ts.Diagnostics.Computed_property_names_are_not_allowed_in_enums); + } + else if (isNumericLiteralName(member.name.text)) { + error(member.name, ts.Diagnostics.An_enum_member_cannot_have_a_numeric_name); + } + var previousEnumMemberIsNonConstant = autoValue === undefined; + var initializer = member.initializer; + if (initializer) { + autoValue = computeConstantValueForEnumMemberInitializer(initializer, enumType, enumIsConst, ambient); + } + else if (ambient && !enumIsConst) { + autoValue = undefined; + } + else if (previousEnumMemberIsNonConstant) { + error(member.name, ts.Diagnostics.Enum_member_must_have_initializer); + } + if (autoValue !== undefined) { + getNodeLinks(member).enumMemberValue = autoValue++; + } + } + nodeLinks.flags |= 8192; + } + function computeConstantValueForEnumMemberInitializer(initializer, enumType, enumIsConst, ambient) { + var reportError = true; + var value = evalConstant(initializer); + if (reportError) { + if (value === undefined) { + if (enumIsConst) { + error(initializer, ts.Diagnostics.In_const_enum_declarations_member_initializer_must_be_constant_expression); + } + else if (ambient) { + error(initializer, ts.Diagnostics.In_ambient_enum_declarations_member_initializer_must_be_constant_expression); + } + else { + checkTypeAssignableTo(checkExpression(initializer), enumType, initializer, undefined); + } + } + else if (enumIsConst) { + if (isNaN(value)) { + error(initializer, ts.Diagnostics.const_enum_member_initializer_was_evaluated_to_disallowed_value_NaN); + } + else if (!isFinite(value)) { + error(initializer, ts.Diagnostics.const_enum_member_initializer_was_evaluated_to_a_non_finite_value); + } + } + } + return value; + function evalConstant(e) { + switch (e.kind) { + case 179: + 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; + } + return undefined; + case 181: + var left = evalConstant(e.left); + if (left === undefined) { + return undefined; + } + var right = evalConstant(e.right); + if (right === undefined) { + 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; + } + return undefined; + case 8: + return +e.text; + case 172: + return evalConstant(e.expression); + case 69: + case 167: + case 166: + var member = initializer.parent; + var currentType = getTypeOfSymbol(getSymbolOfNode(member.parent)); + var enumType_1; + var propertyName; + if (e.kind === 69) { + enumType_1 = currentType; + propertyName = e.text; + } + else { + var expression; + if (e.kind === 167) { + if (e.argumentExpression === undefined || + e.argumentExpression.kind !== 9) { + return undefined; + } + expression = e.expression; + propertyName = e.argumentExpression.text; + } + else { + expression = e.expression; + propertyName = e.name.text; + } + var current = expression; + while (current) { + if (current.kind === 69) { + break; + } + else if (current.kind === 166) { + current = current.expression; + } + else { + return undefined; + } + } + enumType_1 = checkExpression(expression); + if (!(enumType_1.symbol && (enumType_1.symbol.flags & 384))) { + return undefined; + } + } + if (propertyName === undefined) { + return undefined; + } + var property = getPropertyOfObjectType(enumType_1, propertyName); + if (!property || !(property.flags & 8)) { + return undefined; + } + var propertyDecl = property.valueDeclaration; + if (member === propertyDecl) { + return undefined; + } + if (!isBlockScopedNameDeclaredBeforeUse(propertyDecl, member)) { + reportError = false; + error(e, ts.Diagnostics.A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_enums); + return undefined; + } + return getNodeLinks(propertyDecl).enumMemberValue; + } + } + } + } + function checkEnumDeclaration(node) { + if (!produceDiagnostics) { + return; + } + checkGrammarDecorators(node) || checkGrammarModifiers(node); + checkTypeNameIsReserved(node.name, ts.Diagnostics.Enum_name_cannot_be_0); + checkCollisionWithCapturedThisVariable(node, node.name); + checkCollisionWithRequireExportsInGeneratedCode(node, node.name); + checkExportsOnMergedDeclarations(node); + computeEnumMemberValues(node); + var enumIsConst = ts.isConst(node); + if (compilerOptions.isolatedModules && enumIsConst && ts.isInAmbientContext(node)) { + error(node.name, ts.Diagnostics.Ambient_const_enums_are_not_allowed_when_the_isolatedModules_flag_is_provided); + } + var enumSymbol = getSymbolOfNode(node); + var firstDeclaration = ts.getDeclarationOfKind(enumSymbol, node.kind); + if (node === firstDeclaration) { + if (enumSymbol.declarations.length > 1) { + ts.forEach(enumSymbol.declarations, function (decl) { + if (ts.isConstEnumDeclaration(decl) !== enumIsConst) { + error(decl.name, ts.Diagnostics.Enum_declarations_must_all_be_const_or_non_const); + } + }); + } + var seenEnumMissingInitialInitializer = false; + ts.forEach(enumSymbol.declarations, function (declaration) { + if (declaration.kind !== 217) { + return false; + } + var enumDeclaration = declaration; + if (!enumDeclaration.members.length) { + return false; + } + var firstEnumMember = enumDeclaration.members[0]; + if (!firstEnumMember.initializer) { + if (seenEnumMissingInitialInitializer) { + error(firstEnumMember.name, ts.Diagnostics.In_an_enum_with_multiple_declarations_only_one_declaration_can_omit_an_initializer_for_its_first_enum_element); + } + else { + seenEnumMissingInitialInitializer = true; + } + } + }); + } + } + function getFirstNonAmbientClassOrFunctionDeclaration(symbol) { + var declarations = symbol.declarations; + for (var _i = 0; _i < declarations.length; _i++) { + var declaration = declarations[_i]; + if ((declaration.kind === 214 || + (declaration.kind === 213 && ts.nodeIsPresent(declaration.body))) && + !ts.isInAmbientContext(declaration)) { + return declaration; + } + } + return undefined; + } + function inSameLexicalScope(node1, node2) { + var container1 = ts.getEnclosingBlockScopeContainer(node1); + var container2 = ts.getEnclosingBlockScopeContainer(node2); + if (isGlobalSourceFile(container1)) { + return isGlobalSourceFile(container2); + } + else if (isGlobalSourceFile(container2)) { + return false; + } + else { + return container1 === container2; + } + } + function checkModuleDeclaration(node) { + if (produceDiagnostics) { + var isAmbientExternalModule = node.name.kind === 9; + var contextErrorMessage = isAmbientExternalModule + ? ts.Diagnostics.An_ambient_module_declaration_is_only_allowed_at_the_top_level_in_a_file + : ts.Diagnostics.A_namespace_declaration_is_only_allowed_in_a_namespace_or_module; + if (checkGrammarModuleElementContext(node, contextErrorMessage)) { + return; + } + if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node)) { + if (!ts.isInAmbientContext(node) && node.name.kind === 9) { + grammarErrorOnNode(node.name, ts.Diagnostics.Only_ambient_modules_can_use_quoted_names); + } + } + checkCollisionWithCapturedThisVariable(node, node.name); + checkCollisionWithRequireExportsInGeneratedCode(node, node.name); + checkExportsOnMergedDeclarations(node); + var symbol = getSymbolOfNode(node); + if (symbol.flags & 512 + && symbol.declarations.length > 1 + && !ts.isInAmbientContext(node) + && ts.isInstantiatedModule(node, compilerOptions.preserveConstEnums || compilerOptions.isolatedModules)) { + var firstNonAmbientClassOrFunc = getFirstNonAmbientClassOrFunctionDeclaration(symbol); + if (firstNonAmbientClassOrFunc) { + if (ts.getSourceFileOfNode(node) !== ts.getSourceFileOfNode(firstNonAmbientClassOrFunc)) { + error(node.name, ts.Diagnostics.A_namespace_declaration_cannot_be_in_a_different_file_from_a_class_or_function_with_which_it_is_merged); + } + else if (node.pos < firstNonAmbientClassOrFunc.pos) { + 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, 214); + if (mergedClass && + inSameLexicalScope(node, mergedClass)) { + getNodeLinks(node).flags |= 32768; + } + } + if (isAmbientExternalModule) { + if (!isGlobalSourceFile(node.parent)) { + error(node.name, ts.Diagnostics.Ambient_modules_cannot_be_nested_in_other_modules_or_namespaces); + } + if (ts.isExternalModuleNameRelative(node.name.text)) { + error(node.name, ts.Diagnostics.Ambient_module_declaration_cannot_specify_relative_module_name); + } + } + } + checkSourceElement(node.body); + } + function getFirstIdentifier(node) { + while (true) { + if (node.kind === 135) { + node = node.left; + } + else if (node.kind === 166) { + node = node.expression; + } + else { + break; + } + } + ts.Debug.assert(node.kind === 69); + return node; + } + function checkExternalImportOrExportDeclaration(node) { + var moduleName = ts.getExternalModuleName(node); + if (!ts.nodeIsMissing(moduleName) && moduleName.kind !== 9) { + error(moduleName, ts.Diagnostics.String_literal_expected); + return false; + } + var inAmbientExternalModule = node.parent.kind === 219 && node.parent.parent.name.kind === 9; + if (node.parent.kind !== 248 && !inAmbientExternalModule) { + error(moduleName, node.kind === 228 ? + ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace : + ts.Diagnostics.Import_declarations_in_a_namespace_cannot_reference_a_module); + return false; + } + if (inAmbientExternalModule && ts.isExternalModuleNameRelative(moduleName.text)) { + error(node, ts.Diagnostics.Import_or_export_declaration_in_an_ambient_module_declaration_cannot_reference_module_through_relative_module_name); + return false; + } + return true; + } + function checkAliasSymbol(node) { + var symbol = getSymbolOfNode(node); + var target = resolveAlias(symbol); + if (target !== unknownSymbol) { + var excludedMeanings = (symbol.flags & 107455 ? 107455 : 0) | + (symbol.flags & 793056 ? 793056 : 0) | + (symbol.flags & 1536 ? 1536 : 0); + if (target.flags & excludedMeanings) { + var message = node.kind === 230 ? + ts.Diagnostics.Export_declaration_conflicts_with_exported_declaration_of_0 : + ts.Diagnostics.Import_declaration_conflicts_with_local_declaration_of_0; + error(node, message, symbolToString(symbol)); + } + } + } + function checkImportBinding(node) { + checkCollisionWithCapturedThisVariable(node, node.name); + checkCollisionWithRequireExportsInGeneratedCode(node, node.name); + checkAliasSymbol(node); + } + function checkImportDeclaration(node) { + if (checkGrammarModuleElementContext(node, ts.Diagnostics.An_import_declaration_can_only_be_used_in_a_namespace_or_module)) { + return; + } + if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && (node.flags & 2035)) { + grammarErrorOnFirstToken(node, ts.Diagnostics.An_import_declaration_cannot_have_modifiers); + } + if (checkExternalImportOrExportDeclaration(node)) { + var importClause = node.importClause; + if (importClause) { + if (importClause.name) { + checkImportBinding(importClause); + } + if (importClause.namedBindings) { + if (importClause.namedBindings.kind === 224) { + checkImportBinding(importClause.namedBindings); + } + else { + ts.forEach(importClause.namedBindings.elements, checkImportBinding); + } + } + } + } + } + function checkImportEqualsDeclaration(node) { + if (checkGrammarModuleElementContext(node, ts.Diagnostics.An_import_declaration_can_only_be_used_in_a_namespace_or_module)) { + return; + } + checkGrammarDecorators(node) || checkGrammarModifiers(node); + if (ts.isInternalModuleImportEqualsDeclaration(node) || checkExternalImportOrExportDeclaration(node)) { + checkImportBinding(node); + if (node.flags & 1) { + markExportAsReferenced(node); + } + if (ts.isInternalModuleImportEqualsDeclaration(node)) { + var target = resolveAlias(getSymbolOfNode(node)); + if (target !== unknownSymbol) { + if (target.flags & 107455) { + var moduleName = getFirstIdentifier(node.moduleReference); + if (!(resolveEntityName(moduleName, 107455 | 1536).flags & 1536)) { + error(moduleName, ts.Diagnostics.Module_0_is_hidden_by_a_local_declaration_with_the_same_name, ts.declarationNameToString(moduleName)); + } + } + if (target.flags & 793056) { + checkTypeNameIsReserved(node.name, ts.Diagnostics.Import_name_cannot_be_0); + } + } + } + else { + if (modulekind === 5 && !ts.isInAmbientContext(node)) { + grammarErrorOnNode(node, ts.Diagnostics.Import_assignment_cannot_be_used_when_targeting_ECMAScript_6_modules_Consider_using_import_Asterisk_as_ns_from_mod_import_a_from_mod_import_d_from_mod_or_another_module_format_instead); + } + } + } + } + function checkExportDeclaration(node) { + if (checkGrammarModuleElementContext(node, ts.Diagnostics.An_export_declaration_can_only_be_used_in_a_module)) { + return; + } + if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && (node.flags & 2035)) { + grammarErrorOnFirstToken(node, ts.Diagnostics.An_export_declaration_cannot_have_modifiers); + } + if (!node.moduleSpecifier || checkExternalImportOrExportDeclaration(node)) { + if (node.exportClause) { + ts.forEach(node.exportClause.elements, checkExportSpecifier); + var inAmbientExternalModule = node.parent.kind === 219 && node.parent.parent.name.kind === 9; + if (node.parent.kind !== 248 && !inAmbientExternalModule) { + error(node, ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace); + } + } + else { + var moduleSymbol = resolveExternalModuleName(node, node.moduleSpecifier); + if (moduleSymbol && moduleSymbol.exports["export="]) { + error(node.moduleSpecifier, ts.Diagnostics.Module_0_uses_export_and_cannot_be_used_with_export_Asterisk, symbolToString(moduleSymbol)); + } + } + } + } + function checkGrammarModuleElementContext(node, errorMessage) { + if (node.parent.kind !== 248 && node.parent.kind !== 219 && node.parent.kind !== 218) { + return grammarErrorOnFirstToken(node, errorMessage); + } + } + function checkExportSpecifier(node) { + checkAliasSymbol(node); + if (!node.parent.parent.moduleSpecifier) { + markExportAsReferenced(node); + } + } + function checkExportAssignment(node) { + if (checkGrammarModuleElementContext(node, ts.Diagnostics.An_export_assignment_can_only_be_used_in_a_module)) { + return; + } + var container = node.parent.kind === 248 ? node.parent : node.parent.parent; + if (container.kind === 218 && container.name.kind === 69) { + error(node, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_namespace); + return; + } + if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && (node.flags & 2035)) { + grammarErrorOnFirstToken(node, ts.Diagnostics.An_export_assignment_cannot_have_modifiers); + } + if (node.expression.kind === 69) { + markExportAsReferenced(node); + } + else { + checkExpressionCached(node.expression); + } + checkExternalModuleExports(container); + if (node.isExportEquals && !ts.isInAmbientContext(node)) { + if (modulekind === 5) { + grammarErrorOnNode(node, ts.Diagnostics.Export_assignment_cannot_be_used_when_targeting_ECMAScript_6_modules_Consider_using_export_default_or_another_module_format_instead); + } + else if (modulekind === 4) { + grammarErrorOnNode(node, ts.Diagnostics.Export_assignment_is_not_supported_when_module_flag_is_system); + } + } + } + function getModuleStatements(node) { + if (node.kind === 248) { + return node.statements; + } + if (node.kind === 218 && node.body.kind === 219) { + return node.body.statements; + } + return emptyArray; + } + function hasExportedMembers(moduleSymbol) { + for (var id in moduleSymbol.exports) { + if (id !== "export=") { + return true; + } + } + return false; + } + function checkExternalModuleExports(node) { + var moduleSymbol = getSymbolOfNode(node); + var links = getSymbolLinks(moduleSymbol); + if (!links.exportsChecked) { + var exportEqualsSymbol = moduleSymbol.exports["export="]; + if (exportEqualsSymbol && hasExportedMembers(moduleSymbol)) { + var declaration = getDeclarationOfAliasSymbol(exportEqualsSymbol) || exportEqualsSymbol.valueDeclaration; + error(declaration, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_module_with_other_exported_elements); + } + links.exportsChecked = true; + } + } + function checkTypePredicate(node) { + if (!isInLegalTypePredicatePosition(node)) { + error(node, ts.Diagnostics.A_type_predicate_is_only_allowed_in_return_type_position_for_functions_and_methods); + } + } + function checkSourceElement(node) { + if (!node) { + return; + } + var kind = node.kind; + if (cancellationToken) { + switch (kind) { + case 218: + case 214: + case 215: + case 213: + cancellationToken.throwIfCancellationRequested(); + } + } + switch (kind) { + case 137: + return checkTypeParameter(node); + case 138: + return checkParameter(node); + case 141: + case 140: + return checkPropertyDeclaration(node); + case 152: + case 153: + case 147: + case 148: + return checkSignatureDeclaration(node); + case 149: + return checkSignatureDeclaration(node); + case 143: + case 142: + return checkMethodDeclaration(node); + case 144: + return checkConstructorDeclaration(node); + case 145: + case 146: + return checkAccessorDeclaration(node); + case 151: + return checkTypeReferenceNode(node); + case 150: + return checkTypePredicate(node); + case 154: + return checkTypeQuery(node); + case 155: + return checkTypeLiteral(node); + case 156: + return checkArrayType(node); + case 157: + return checkTupleType(node); + case 158: + case 159: + return checkUnionOrIntersectionType(node); + case 160: + return checkSourceElement(node.type); + case 213: + return checkFunctionDeclaration(node); + case 192: + case 219: + return checkBlock(node); + case 193: + return checkVariableStatement(node); + case 195: + return checkExpressionStatement(node); + case 196: + return checkIfStatement(node); + case 197: + return checkDoStatement(node); + case 198: + return checkWhileStatement(node); + case 199: + return checkForStatement(node); + case 200: + return checkForInStatement(node); + case 201: + return checkForOfStatement(node); + case 202: + case 203: + return checkBreakOrContinueStatement(node); + case 204: + return checkReturnStatement(node); + case 205: + return checkWithStatement(node); + case 206: + return checkSwitchStatement(node); + case 207: + return checkLabeledStatement(node); + case 208: + return checkThrowStatement(node); + case 209: + return checkTryStatement(node); + case 211: + return checkVariableDeclaration(node); + case 163: + return checkBindingElement(node); + case 214: + return checkClassDeclaration(node); + case 215: + return checkInterfaceDeclaration(node); + case 216: + return checkTypeAliasDeclaration(node); + case 217: + return checkEnumDeclaration(node); + case 218: + return checkModuleDeclaration(node); + case 222: + return checkImportDeclaration(node); + case 221: + return checkImportEqualsDeclaration(node); + case 228: + return checkExportDeclaration(node); + case 227: + return checkExportAssignment(node); + case 194: + checkGrammarStatementInAmbientContext(node); + return; + case 210: + checkGrammarStatementInAmbientContext(node); + return; + case 231: + return checkMissingDeclaration(node); + } + } + function checkFunctionAndClassExpressionBodies(node) { + switch (node.kind) { + case 173: + case 174: + ts.forEach(node.parameters, checkFunctionAndClassExpressionBodies); + checkFunctionExpressionOrObjectLiteralMethodBody(node); + break; + case 186: + ts.forEach(node.members, checkSourceElement); + ts.forEachChild(node, checkFunctionAndClassExpressionBodies); + break; + case 143: + case 142: + ts.forEach(node.decorators, checkFunctionAndClassExpressionBodies); + ts.forEach(node.parameters, checkFunctionAndClassExpressionBodies); + if (ts.isObjectLiteralMethod(node)) { + checkFunctionExpressionOrObjectLiteralMethodBody(node); + } + break; + case 144: + case 145: + case 146: + case 213: + ts.forEach(node.parameters, checkFunctionAndClassExpressionBodies); + break; + case 205: + checkFunctionAndClassExpressionBodies(node.expression); + break; + case 139: + case 138: + case 141: + case 140: + case 161: + case 162: + case 163: + case 164: + case 165: + case 245: + case 166: + case 167: + case 168: + case 169: + case 170: + case 183: + case 190: + case 171: + case 189: + case 172: + case 176: + case 177: + case 178: + case 175: + case 179: + case 180: + case 181: + case 182: + case 185: + case 184: + case 192: + case 219: + case 193: + case 195: + case 196: + case 197: + case 198: + case 199: + case 200: + case 201: + case 202: + case 203: + case 204: + case 206: + case 220: + case 241: + case 242: + case 207: + case 208: + case 209: + case 244: + case 211: + case 212: + case 214: + case 243: + case 188: + case 217: + case 247: + case 227: + case 248: + case 240: + case 233: + case 234: + case 238: + case 239: + case 235: + ts.forEachChild(node, checkFunctionAndClassExpressionBodies); + break; + } + } + function checkSourceFile(node) { + var start = new Date().getTime(); + checkSourceFileWorker(node); + ts.checkTime += new Date().getTime() - start; + } + function checkSourceFileWorker(node) { + var links = getNodeLinks(node); + if (!(links.flags & 1)) { + if (node.isDefaultLib && compilerOptions.skipDefaultLibCheck) { + return; + } + checkGrammarSourceFile(node); + emitExtends = false; + emitDecorate = false; + emitParam = false; + potentialThisCollisions.length = 0; + ts.forEach(node.statements, checkSourceElement); + checkFunctionAndClassExpressionBodies(node); + if (ts.isExternalModule(node)) { + checkExternalModuleExports(node); + } + if (potentialThisCollisions.length) { + ts.forEach(potentialThisCollisions, checkIfThisIsCapturedInEnclosingScope); + potentialThisCollisions.length = 0; + } + if (emitExtends) { + links.flags |= 8; + } + if (emitDecorate) { + links.flags |= 16; + } + if (emitParam) { + links.flags |= 32; + } + if (emitAwaiter) { + links.flags |= 64; + } + if (emitGenerator || (emitAwaiter && languageVersion < 2)) { + links.flags |= 128; + } + links.flags |= 1; + } + } + function getDiagnostics(sourceFile, ct) { + try { + cancellationToken = ct; + return getDiagnosticsWorker(sourceFile); + } + finally { + cancellationToken = undefined; + } + } + function getDiagnosticsWorker(sourceFile) { + throwIfNonDiagnosticsProducing(); + if (sourceFile) { + checkSourceFile(sourceFile); + return diagnostics.getDiagnostics(sourceFile.fileName); + } + ts.forEach(host.getSourceFiles(), checkSourceFile); + return diagnostics.getDiagnostics(); + } + function getGlobalDiagnostics() { + throwIfNonDiagnosticsProducing(); + return diagnostics.getGlobalDiagnostics(); + } + function throwIfNonDiagnosticsProducing() { + if (!produceDiagnostics) { + throw new Error("Trying to get diagnostics from a type checker that does not produce them."); + } + } + function isInsideWithStatementBody(node) { + if (node) { + while (node.parent) { + if (node.parent.kind === 205 && node.parent.statement === node) { + return true; + } + node = node.parent; + } + } + return false; + } + function getSymbolsInScope(location, meaning) { + var symbols = {}; + var memberFlags = 0; + if (isInsideWithStatementBody(location)) { + return []; + } + populateSymbols(); + return symbolsToArray(symbols); + function populateSymbols() { + while (location) { + if (location.locals && !isGlobalSourceFile(location)) { + copySymbols(location.locals, meaning); + } + switch (location.kind) { + case 248: + if (!ts.isExternalModule(location)) { + break; + } + case 218: + copySymbols(getSymbolOfNode(location).exports, meaning & 8914931); + break; + case 217: + copySymbols(getSymbolOfNode(location).exports, meaning & 8); + break; + case 186: + var className = location.name; + if (className) { + copySymbol(location.symbol, meaning); + } + case 214: + case 215: + if (!(memberFlags & 128)) { + copySymbols(getSymbolOfNode(location).members, meaning & 793056); + } + break; + case 173: + var funcName = location.name; + if (funcName) { + copySymbol(location.symbol, meaning); + } + break; + } + if (ts.introducesArgumentsExoticObject(location)) { + copySymbol(argumentsSymbol, meaning); + } + memberFlags = location.flags; + location = location.parent; + } + copySymbols(globals, meaning); + } + function copySymbol(symbol, meaning) { + if (symbol.flags & meaning) { + var id = symbol.name; + if (!ts.hasProperty(symbols, id)) { + symbols[id] = symbol; + } + } + } + function copySymbols(source, meaning) { + if (meaning) { + for (var id in source) { + var symbol = source[id]; + copySymbol(symbol, meaning); + } + } + } + } + function isTypeDeclarationName(name) { + return name.kind === 69 && + isTypeDeclaration(name.parent) && + name.parent.name === name; + } + function isTypeDeclaration(node) { + switch (node.kind) { + case 137: + case 214: + case 215: + case 216: + case 217: + return true; + } + } + function isTypeReferenceIdentifier(entityName) { + var node = entityName; + while (node.parent && node.parent.kind === 135) { + node = node.parent; + } + return node.parent && node.parent.kind === 151; + } + function isHeritageClauseElementIdentifier(entityName) { + var node = entityName; + while (node.parent && node.parent.kind === 166) { + node = node.parent; + } + return node.parent && node.parent.kind === 188; + } + function getLeftSideOfImportEqualsOrExportAssignment(nodeOnRightSide) { + while (nodeOnRightSide.parent.kind === 135) { + nodeOnRightSide = nodeOnRightSide.parent; + } + if (nodeOnRightSide.parent.kind === 221) { + return nodeOnRightSide.parent.moduleReference === nodeOnRightSide && nodeOnRightSide.parent; + } + if (nodeOnRightSide.parent.kind === 227) { + return nodeOnRightSide.parent.expression === nodeOnRightSide && nodeOnRightSide.parent; + } + return undefined; + } + function isInRightSideOfImportOrExportAssignment(node) { + return getLeftSideOfImportEqualsOrExportAssignment(node) !== undefined; + } + function getSymbolOfEntityNameOrPropertyAccessExpression(entityName) { + if (ts.isDeclarationName(entityName)) { + return getSymbolOfNode(entityName.parent); + } + if (entityName.parent.kind === 227) { + return resolveEntityName(entityName, 107455 | 793056 | 1536 | 8388608); + } + if (entityName.kind !== 166) { + if (isInRightSideOfImportOrExportAssignment(entityName)) { + return getSymbolOfPartOfRightHandSideOfImportEquals(entityName); + } + } + if (ts.isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { + entityName = entityName.parent; + } + if (isHeritageClauseElementIdentifier(entityName)) { + var meaning = 0; + if (entityName.parent.kind === 188) { + meaning = 793056; + if (ts.isExpressionWithTypeArgumentsInClassExtendsClause(entityName.parent)) { + meaning |= 107455; + } + } + else { + meaning = 1536; + } + meaning |= 8388608; + return resolveEntityName(entityName, meaning); + } + else if ((entityName.parent.kind === 235) || + (entityName.parent.kind === 234) || + (entityName.parent.kind === 237)) { + return getJsxElementTagSymbol(entityName.parent); + } + else if (ts.isExpression(entityName)) { + if (ts.nodeIsMissing(entityName)) { + return undefined; + } + if (entityName.kind === 69) { + var meaning = 107455 | 8388608; + return resolveEntityName(entityName, meaning); + } + else if (entityName.kind === 166) { + var symbol = getNodeLinks(entityName).resolvedSymbol; + if (!symbol) { + checkPropertyAccessExpression(entityName); + } + return getNodeLinks(entityName).resolvedSymbol; + } + else if (entityName.kind === 135) { + var symbol = getNodeLinks(entityName).resolvedSymbol; + if (!symbol) { + checkQualifiedName(entityName); + } + return getNodeLinks(entityName).resolvedSymbol; + } + } + else if (isTypeReferenceIdentifier(entityName)) { + var meaning = entityName.parent.kind === 151 ? 793056 : 1536; + meaning |= 8388608; + return resolveEntityName(entityName, meaning); + } + else if (entityName.parent.kind === 238) { + return getJsxAttributePropertySymbol(entityName.parent); + } + if (entityName.parent.kind === 150) { + return resolveEntityName(entityName, 1); + } + return undefined; + } + function getSymbolAtLocation(node) { + if (isInsideWithStatementBody(node)) { + return undefined; + } + if (ts.isDeclarationName(node)) { + return getSymbolOfNode(node.parent); + } + if (node.kind === 69) { + if (isInRightSideOfImportOrExportAssignment(node)) { + return node.parent.kind === 227 + ? getSymbolOfEntityNameOrPropertyAccessExpression(node) + : getSymbolOfPartOfRightHandSideOfImportEquals(node); + } + else if (node.parent.kind === 163 && + node.parent.parent.kind === 161 && + node === node.parent.propertyName) { + var typeOfPattern = getTypeOfNode(node.parent.parent); + var propertyDeclaration = typeOfPattern && getPropertyOfType(typeOfPattern, node.text); + if (propertyDeclaration) { + return propertyDeclaration; + } + } + } + switch (node.kind) { + case 69: + case 166: + case 135: + return getSymbolOfEntityNameOrPropertyAccessExpression(node); + case 97: + case 95: + var type = ts.isExpression(node) ? checkExpression(node) : getTypeFromTypeNode(node); + return type.symbol; + case 121: + var constructorDeclaration = node.parent; + if (constructorDeclaration && constructorDeclaration.kind === 144) { + return constructorDeclaration.parent.symbol; + } + return undefined; + case 9: + if ((ts.isExternalModuleImportEqualsDeclaration(node.parent.parent) && + ts.getExternalModuleImportEqualsDeclarationExpression(node.parent.parent) === node) || + ((node.parent.kind === 222 || node.parent.kind === 228) && + node.parent.moduleSpecifier === node)) { + return resolveExternalModuleName(node, node); + } + case 8: + if (node.parent.kind === 167 && node.parent.argumentExpression === node) { + var objectType = checkExpression(node.parent.expression); + if (objectType === unknownType) + return undefined; + var apparentType = getApparentType(objectType); + if (apparentType === unknownType) + return undefined; + return getPropertyOfType(apparentType, node.text); + } + break; + } + return undefined; + } + function getShorthandAssignmentValueSymbol(location) { + if (location && location.kind === 246) { + return resolveEntityName(location.name, 107455); + } + return undefined; + } + function getTypeOfNode(node) { + if (isInsideWithStatementBody(node)) { + return unknownType; + } + if (ts.isTypeNode(node)) { + return getTypeFromTypeNode(node); + } + if (ts.isExpression(node)) { + return getTypeOfExpression(node); + } + if (ts.isExpressionWithTypeArgumentsInClassExtendsClause(node)) { + return getBaseTypes(getDeclaredTypeOfSymbol(getSymbolOfNode(node.parent.parent)))[0]; + } + if (isTypeDeclaration(node)) { + var symbol = getSymbolOfNode(node); + return getDeclaredTypeOfSymbol(symbol); + } + if (isTypeDeclarationName(node)) { + var symbol = getSymbolAtLocation(node); + return symbol && getDeclaredTypeOfSymbol(symbol); + } + if (ts.isDeclaration(node)) { + var symbol = getSymbolOfNode(node); + return getTypeOfSymbol(symbol); + } + if (ts.isDeclarationName(node)) { + var symbol = getSymbolAtLocation(node); + return symbol && getTypeOfSymbol(symbol); + } + if (ts.isBindingPattern(node)) { + return getTypeForVariableLikeDeclaration(node.parent); + } + if (isInRightSideOfImportOrExportAssignment(node)) { + var symbol = getSymbolAtLocation(node); + var declaredType = symbol && getDeclaredTypeOfSymbol(symbol); + return declaredType !== unknownType ? declaredType : getTypeOfSymbol(symbol); + } + return unknownType; + } + function getTypeOfExpression(expr) { + if (ts.isRightSideOfQualifiedNameOrPropertyAccess(expr)) { + expr = expr.parent; + } + return checkExpression(expr); + } + function getParentTypeOfClassElement(node) { + var classSymbol = getSymbolOfNode(node.parent); + return node.flags & 128 + ? getTypeOfSymbol(classSymbol) + : getDeclaredTypeOfSymbol(classSymbol); + } + function getAugmentedPropertiesOfType(type) { + type = getApparentType(type); + var propsByName = createSymbolTable(getPropertiesOfType(type)); + if (getSignaturesOfType(type, 0).length || getSignaturesOfType(type, 1).length) { + ts.forEach(getPropertiesOfType(globalFunctionType), function (p) { + if (!ts.hasProperty(propsByName, p.name)) { + propsByName[p.name] = p; + } + }); + } + return getNamedMembers(propsByName); + } + function getRootSymbols(symbol) { + if (symbol.flags & 268435456) { + var symbols = []; + var name_16 = symbol.name; + ts.forEach(getSymbolLinks(symbol).containingType.types, function (t) { + var symbol = getPropertyOfType(t, name_16); + if (symbol) { + symbols.push(symbol); + } + }); + return symbols; + } + else if (symbol.flags & 67108864) { + var target = getSymbolLinks(symbol).target; + if (target) { + return [target]; + } + } + return [symbol]; + } + function isArgumentsLocalBinding(node) { + return getReferencedValueSymbol(node) === argumentsSymbol; + } + function getReferencedExportContainer(node) { + var symbol = getReferencedValueSymbol(node); + if (symbol) { + if (symbol.flags & 1048576) { + var exportSymbol = getMergedSymbol(symbol.exportSymbol); + if (exportSymbol.flags & 944) { + return undefined; + } + symbol = exportSymbol; + } + var parentSymbol = getParentOfSymbol(symbol); + if (parentSymbol) { + if (parentSymbol.flags & 512 && parentSymbol.valueDeclaration.kind === 248) { + return parentSymbol.valueDeclaration; + } + for (var n = node.parent; n; n = n.parent) { + if ((n.kind === 218 || n.kind === 217) && getSymbolOfNode(n) === parentSymbol) { + return n; + } + } + } + } + } + function getReferencedImportDeclaration(node) { + var symbol = getReferencedValueSymbol(node); + return symbol && symbol.flags & 8388608 ? getDeclarationOfAliasSymbol(symbol) : undefined; + } + function isStatementWithLocals(node) { + switch (node.kind) { + case 192: + case 220: + case 199: + case 200: + case 201: + return true; + } + return false; + } + function isNestedRedeclarationSymbol(symbol) { + if (symbol.flags & 418) { + var links = getSymbolLinks(symbol); + if (links.isNestedRedeclaration === undefined) { + var container = ts.getEnclosingBlockScopeContainer(symbol.valueDeclaration); + links.isNestedRedeclaration = isStatementWithLocals(container) && + !!resolveName(container.parent, symbol.name, 107455, undefined, undefined); + } + return links.isNestedRedeclaration; + } + return false; + } + function getReferencedNestedRedeclaration(node) { + var symbol = getReferencedValueSymbol(node); + return symbol && isNestedRedeclarationSymbol(symbol) ? symbol.valueDeclaration : undefined; + } + function isNestedRedeclaration(node) { + return isNestedRedeclarationSymbol(getSymbolOfNode(node)); + } + function isValueAliasDeclaration(node) { + switch (node.kind) { + case 221: + case 223: + case 224: + case 226: + case 230: + return isAliasResolvedToValue(getSymbolOfNode(node)); + case 228: + var exportClause = node.exportClause; + return exportClause && ts.forEach(exportClause.elements, isValueAliasDeclaration); + case 227: + return node.expression && node.expression.kind === 69 ? isAliasResolvedToValue(getSymbolOfNode(node)) : true; + } + return false; + } + function isTopLevelValueImportEqualsWithEntityName(node) { + if (node.parent.kind !== 248 || !ts.isInternalModuleImportEqualsDeclaration(node)) { + return false; + } + var isValue = isAliasResolvedToValue(getSymbolOfNode(node)); + return isValue && node.moduleReference && !ts.nodeIsMissing(node.moduleReference); + } + function isAliasResolvedToValue(symbol) { + var target = resolveAlias(symbol); + if (target === unknownSymbol && compilerOptions.isolatedModules) { + return true; + } + return target !== unknownSymbol && + target && + target.flags & 107455 && + (compilerOptions.preserveConstEnums || !isConstEnumOrConstEnumOnlyModule(target)); + } + function isConstEnumOrConstEnumOnlyModule(s) { + return isConstEnumSymbol(s) || s.constEnumOnlyModule; + } + function isReferencedAliasDeclaration(node, checkChildren) { + if (ts.isAliasSymbolDeclaration(node)) { + var symbol = getSymbolOfNode(node); + if (getSymbolLinks(symbol).referenced) { + return true; + } + } + if (checkChildren) { + return ts.forEachChild(node, function (node) { return isReferencedAliasDeclaration(node, checkChildren); }); + } + return false; + } + function isImplementationOfOverload(node) { + if (ts.nodeIsPresent(node.body)) { + var symbol = getSymbolOfNode(node); + var signaturesOfSymbol = getSignaturesOfSymbol(symbol); + return signaturesOfSymbol.length > 1 || + (signaturesOfSymbol.length === 1 && signaturesOfSymbol[0].declaration !== node); + } + return false; + } + function getNodeCheckFlags(node) { + return getNodeLinks(node).flags; + } + function getEnumMemberValue(node) { + computeEnumMemberValues(node.parent); + return getNodeLinks(node).enumMemberValue; + } + function getConstantValue(node) { + if (node.kind === 247) { + return getEnumMemberValue(node); + } + var symbol = getNodeLinks(node).resolvedSymbol; + if (symbol && (symbol.flags & 8)) { + if (ts.isConstEnumDeclaration(symbol.valueDeclaration.parent)) { + return getEnumMemberValue(symbol.valueDeclaration); + } + } + return undefined; + } + function isFunctionType(type) { + return type.flags & 80896 && getSignaturesOfType(type, 0).length > 0; + } + function getTypeReferenceSerializationKind(typeName) { + var valueSymbol = resolveEntityName(typeName, 107455, true); + var constructorType = valueSymbol ? getTypeOfSymbol(valueSymbol) : undefined; + if (constructorType && isConstructorType(constructorType)) { + return ts.TypeReferenceSerializationKind.TypeWithConstructSignatureAndValue; + } + var typeSymbol = resolveEntityName(typeName, 793056, true); + if (!typeSymbol) { + return ts.TypeReferenceSerializationKind.ObjectType; + } + var type = getDeclaredTypeOfSymbol(typeSymbol); + if (type === unknownType) { + return ts.TypeReferenceSerializationKind.Unknown; + } + else if (type.flags & 1) { + return ts.TypeReferenceSerializationKind.ObjectType; + } + else if (allConstituentTypesHaveKind(type, 16)) { + return ts.TypeReferenceSerializationKind.VoidType; + } + else if (allConstituentTypesHaveKind(type, 8)) { + return ts.TypeReferenceSerializationKind.BooleanType; + } + else if (allConstituentTypesHaveKind(type, 132)) { + return ts.TypeReferenceSerializationKind.NumberLikeType; + } + else if (allConstituentTypesHaveKind(type, 258)) { + return ts.TypeReferenceSerializationKind.StringLikeType; + } + else if (allConstituentTypesHaveKind(type, 8192)) { + return ts.TypeReferenceSerializationKind.ArrayLikeType; + } + else if (allConstituentTypesHaveKind(type, 16777216)) { + return ts.TypeReferenceSerializationKind.ESSymbolType; + } + else if (isFunctionType(type)) { + return ts.TypeReferenceSerializationKind.TypeWithCallSignature; + } + else if (isArrayType(type)) { + return ts.TypeReferenceSerializationKind.ArrayLikeType; + } + else { + return ts.TypeReferenceSerializationKind.ObjectType; + } + } + function writeTypeOfDeclaration(declaration, enclosingDeclaration, flags, writer) { + var symbol = getSymbolOfNode(declaration); + var type = symbol && !(symbol.flags & (2048 | 131072)) + ? getTypeOfSymbol(symbol) + : unknownType; + getSymbolDisplayBuilder().buildTypeDisplay(type, writer, enclosingDeclaration, flags); + } + function writeReturnTypeOfSignatureDeclaration(signatureDeclaration, enclosingDeclaration, flags, writer) { + var signature = getSignatureFromDeclaration(signatureDeclaration); + getSymbolDisplayBuilder().buildTypeDisplay(getReturnTypeOfSignature(signature), writer, enclosingDeclaration, flags); + } + function writeTypeOfExpression(expr, enclosingDeclaration, flags, writer) { + var type = getTypeOfExpression(expr); + getSymbolDisplayBuilder().buildTypeDisplay(type, writer, enclosingDeclaration, flags); + } + function hasGlobalName(name) { + return ts.hasProperty(globals, name); + } + function getReferencedValueSymbol(reference) { + return getNodeLinks(reference).resolvedSymbol || + resolveName(reference, reference.text, 107455 | 1048576 | 8388608, undefined, undefined); + } + function getReferencedValueDeclaration(reference) { + ts.Debug.assert(!ts.nodeIsSynthesized(reference)); + var symbol = getReferencedValueSymbol(reference); + return symbol && getExportSymbolOfValueSymbolIfExported(symbol).valueDeclaration; + } + function instantiateSingleCallFunctionType(functionType, typeArguments) { + if (functionType === unknownType) { + return unknownType; + } + var signature = getSingleCallSignature(functionType); + if (!signature) { + return unknownType; + } + var instantiatedSignature = getSignatureInstantiation(signature, typeArguments); + return getOrCreateTypeFromSignature(instantiatedSignature); + } + function createResolver() { + return { + getReferencedExportContainer: getReferencedExportContainer, + getReferencedImportDeclaration: getReferencedImportDeclaration, + getReferencedNestedRedeclaration: getReferencedNestedRedeclaration, + isNestedRedeclaration: isNestedRedeclaration, + isValueAliasDeclaration: isValueAliasDeclaration, + hasGlobalName: hasGlobalName, + isReferencedAliasDeclaration: isReferencedAliasDeclaration, + getNodeCheckFlags: getNodeCheckFlags, + isTopLevelValueImportEqualsWithEntityName: isTopLevelValueImportEqualsWithEntityName, + isDeclarationVisible: isDeclarationVisible, + isImplementationOfOverload: isImplementationOfOverload, + writeTypeOfDeclaration: writeTypeOfDeclaration, + writeReturnTypeOfSignatureDeclaration: writeReturnTypeOfSignatureDeclaration, + writeTypeOfExpression: writeTypeOfExpression, + isSymbolAccessible: isSymbolAccessible, + isEntityNameVisible: isEntityNameVisible, + getConstantValue: getConstantValue, + collectLinkedAliases: collectLinkedAliases, + getReferencedValueDeclaration: getReferencedValueDeclaration, + getTypeReferenceSerializationKind: getTypeReferenceSerializationKind, + isOptionalParameter: isOptionalParameter, + isArgumentsLocalBinding: isArgumentsLocalBinding + }; + } + function initializeTypeChecker() { + ts.forEach(host.getSourceFiles(), function (file) { + ts.bindSourceFile(file); + }); + ts.forEach(host.getSourceFiles(), function (file) { + if (!ts.isExternalModule(file)) { + mergeSymbolTable(globals, file.locals); + } + }); + getSymbolLinks(undefinedSymbol).type = undefinedType; + getSymbolLinks(argumentsSymbol).type = getGlobalType("IArguments"); + getSymbolLinks(unknownSymbol).type = unknownType; + globals[undefinedSymbol.name] = undefinedSymbol; + globalArrayType = getGlobalType("Array", 1); + globalObjectType = getGlobalType("Object"); + globalFunctionType = getGlobalType("Function"); + globalStringType = getGlobalType("String"); + globalNumberType = getGlobalType("Number"); + globalBooleanType = getGlobalType("Boolean"); + globalRegExpType = getGlobalType("RegExp"); + jsxElementType = getExportedTypeFromNamespace("JSX", JsxNames.Element); + getGlobalClassDecoratorType = ts.memoize(function () { return getGlobalType("ClassDecorator"); }); + getGlobalPropertyDecoratorType = ts.memoize(function () { return getGlobalType("PropertyDecorator"); }); + getGlobalMethodDecoratorType = ts.memoize(function () { return getGlobalType("MethodDecorator"); }); + getGlobalParameterDecoratorType = ts.memoize(function () { return getGlobalType("ParameterDecorator"); }); + getGlobalTypedPropertyDescriptorType = ts.memoize(function () { return getGlobalType("TypedPropertyDescriptor", 1); }); + getGlobalPromiseType = ts.memoize(function () { return getGlobalType("Promise", 1); }); + tryGetGlobalPromiseType = ts.memoize(function () { return getGlobalSymbol("Promise", 793056, undefined) && getGlobalPromiseType(); }); + getGlobalPromiseLikeType = ts.memoize(function () { return getGlobalType("PromiseLike", 1); }); + getInstantiatedGlobalPromiseLikeType = ts.memoize(createInstantiatedPromiseLikeType); + getGlobalPromiseConstructorSymbol = ts.memoize(function () { return getGlobalValueSymbol("Promise"); }); + getGlobalPromiseConstructorLikeType = ts.memoize(function () { return getGlobalType("PromiseConstructorLike"); }); + getGlobalThenableType = ts.memoize(createThenableType); + if (languageVersion >= 2) { + globalTemplateStringsArrayType = getGlobalType("TemplateStringsArray"); + globalESSymbolType = getGlobalType("Symbol"); + globalESSymbolConstructorSymbol = getGlobalValueSymbol("Symbol"); + globalIterableType = getGlobalType("Iterable", 1); + globalIteratorType = getGlobalType("Iterator", 1); + globalIterableIteratorType = getGlobalType("IterableIterator", 1); + } + else { + globalTemplateStringsArrayType = unknownType; + globalESSymbolType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); + globalESSymbolConstructorSymbol = undefined; + globalIterableType = emptyGenericType; + globalIteratorType = emptyGenericType; + globalIterableIteratorType = emptyGenericType; + } + anyArrayType = createArrayType(anyType); + } + function createInstantiatedPromiseLikeType() { + var promiseLikeType = getGlobalPromiseLikeType(); + if (promiseLikeType !== emptyGenericType) { + return createTypeReference(promiseLikeType, [anyType]); + } + return emptyObjectType; + } + function createThenableType() { + var thenPropertySymbol = createSymbol(67108864 | 4, "then"); + getSymbolLinks(thenPropertySymbol).type = globalFunctionType; + var thenableType = createObjectType(65536); + thenableType.properties = [thenPropertySymbol]; + thenableType.members = createSymbolTable(thenableType.properties); + thenableType.callSignatures = []; + thenableType.constructSignatures = []; + return thenableType; + } + function checkGrammarDecorators(node) { + if (!node.decorators) { + return false; + } + if (!ts.nodeCanBeDecorated(node)) { + return grammarErrorOnFirstToken(node, ts.Diagnostics.Decorators_are_not_valid_here); + } + else if (node.kind === 145 || node.kind === 146) { + var accessors = ts.getAllAccessorDeclarations(node.parent.members, node); + if (accessors.firstAccessor.decorators && node === accessors.secondAccessor) { + return grammarErrorOnFirstToken(node, ts.Diagnostics.Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name); + } + } + return false; + } + function checkGrammarModifiers(node) { + switch (node.kind) { + case 145: + case 146: + case 144: + case 141: + case 140: + case 143: + case 142: + case 149: + case 218: + case 222: + case 221: + case 228: + case 227: + case 138: + break; + case 213: + if (node.modifiers && (node.modifiers.length > 1 || node.modifiers[0].kind !== 118) && + node.parent.kind !== 219 && node.parent.kind !== 248) { + return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); + } + break; + case 214: + case 215: + case 193: + case 216: + if (node.modifiers && node.parent.kind !== 219 && node.parent.kind !== 248) { + return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); + } + break; + case 217: + if (node.modifiers && (node.modifiers.length > 1 || node.modifiers[0].kind !== 74) && + node.parent.kind !== 219 && node.parent.kind !== 248) { + return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); + } + break; + default: + return false; + } + if (!node.modifiers) { + return; + } + var lastStatic, lastPrivate, lastProtected, lastDeclare, lastAsync; + var flags = 0; + for (var _i = 0, _a = node.modifiers; _i < _a.length; _i++) { + var modifier = _a[_i]; + switch (modifier.kind) { + case 112: + case 111: + case 110: + var text = void 0; + if (modifier.kind === 112) { + text = "public"; + } + else if (modifier.kind === 111) { + text = "protected"; + lastProtected = modifier; + } + else { + text = "private"; + lastPrivate = modifier; + } + if (flags & 112) { + return grammarErrorOnNode(modifier, ts.Diagnostics.Accessibility_modifier_already_seen); + } + else if (flags & 128) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "static"); + } + else if (flags & 512) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "async"); + } + else if (node.parent.kind === 219 || node.parent.kind === 248) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_element, text); + } + else if (flags & 256) { + if (modifier.kind === 110) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, text, "abstract"); + } + else { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "abstract"); + } + } + flags |= ts.modifierToFlag(modifier.kind); + break; + case 113: + if (flags & 128) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "static"); + } + else if (flags & 512) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "static", "async"); + } + else if (node.parent.kind === 219 || node.parent.kind === 248) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_element, "static"); + } + else if (node.kind === 138) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "static"); + } + else if (flags & 256) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "static", "abstract"); + } + flags |= 128; + lastStatic = modifier; + break; + case 82: + if (flags & 1) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "export"); + } + else if (flags & 2) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "declare"); + } + else if (flags & 256) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "abstract"); + } + else if (flags & 512) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "async"); + } + else if (node.parent.kind === 214) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "export"); + } + else if (node.kind === 138) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "export"); + } + flags |= 1; + break; + case 122: + if (flags & 2) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "declare"); + } + else if (flags & 512) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); + } + else if (node.parent.kind === 214) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "declare"); + } + else if (node.kind === 138) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "declare"); + } + else if (ts.isInAmbientContext(node.parent) && node.parent.kind === 219) { + return grammarErrorOnNode(modifier, ts.Diagnostics.A_declare_modifier_cannot_be_used_in_an_already_ambient_context); + } + flags |= 2; + lastDeclare = modifier; + break; + case 115: + if (flags & 256) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "abstract"); + } + if (node.kind !== 214) { + if (node.kind !== 143) { + return grammarErrorOnNode(modifier, ts.Diagnostics.abstract_modifier_can_only_appear_on_a_class_or_method_declaration); + } + if (!(node.parent.kind === 214 && node.parent.flags & 256)) { + return grammarErrorOnNode(modifier, ts.Diagnostics.Abstract_methods_can_only_appear_within_an_abstract_class); + } + if (flags & 128) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "static", "abstract"); + } + if (flags & 32) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "private", "abstract"); + } + } + flags |= 256; + break; + case 118: + if (flags & 512) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "async"); + } + else if (flags & 2 || ts.isInAmbientContext(node.parent)) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); + } + else if (node.kind === 138) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "async"); + } + flags |= 512; + lastAsync = modifier; + break; + } + } + if (node.kind === 144) { + if (flags & 128) { + return grammarErrorOnNode(lastStatic, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "static"); + } + if (flags & 256) { + return grammarErrorOnNode(lastStatic, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "abstract"); + } + else if (flags & 64) { + return grammarErrorOnNode(lastProtected, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "protected"); + } + else if (flags & 32) { + return grammarErrorOnNode(lastPrivate, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "private"); + } + else if (flags & 512) { + return grammarErrorOnNode(lastAsync, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "async"); + } + return; + } + else if ((node.kind === 222 || node.kind === 221) && flags & 2) { + return grammarErrorOnNode(lastDeclare, ts.Diagnostics.A_0_modifier_cannot_be_used_with_an_import_declaration, "declare"); + } + else if (node.kind === 138 && (flags & 112) && ts.isBindingPattern(node.name)) { + return grammarErrorOnNode(node, ts.Diagnostics.A_parameter_property_may_not_be_a_binding_pattern); + } + if (flags & 512) { + return checkGrammarAsyncModifier(node, lastAsync); + } + } + function checkGrammarAsyncModifier(node, asyncModifier) { + if (languageVersion < 2) { + return grammarErrorOnNode(asyncModifier, ts.Diagnostics.Async_functions_are_only_available_when_targeting_ECMAScript_6_and_higher); + } + switch (node.kind) { + case 143: + case 213: + case 173: + case 174: + if (!node.asteriskToken) { + return false; + } + break; + } + return grammarErrorOnNode(asyncModifier, ts.Diagnostics._0_modifier_cannot_be_used_here, "async"); + } + function checkGrammarForDisallowedTrailingComma(list) { + if (list && list.hasTrailingComma) { + var start = list.end - ",".length; + var end = list.end; + var sourceFile = ts.getSourceFileOfNode(list[0]); + return grammarErrorAtPos(sourceFile, start, end - start, ts.Diagnostics.Trailing_comma_not_allowed); + } + } + function checkGrammarTypeParameterList(node, typeParameters, file) { + if (checkGrammarForDisallowedTrailingComma(typeParameters)) { + return true; + } + if (typeParameters && typeParameters.length === 0) { + var start = typeParameters.pos - "<".length; + var end = ts.skipTrivia(file.text, typeParameters.end) + ">".length; + return grammarErrorAtPos(file, start, end - start, ts.Diagnostics.Type_parameter_list_cannot_be_empty); + } + } + function checkGrammarParameterList(parameters) { + if (checkGrammarForDisallowedTrailingComma(parameters)) { + return true; + } + var seenOptionalParameter = false; + var parameterCount = parameters.length; + for (var i = 0; i < parameterCount; i++) { + var parameter = parameters[i]; + if (parameter.dotDotDotToken) { + if (i !== (parameterCount - 1)) { + return grammarErrorOnNode(parameter.dotDotDotToken, ts.Diagnostics.A_rest_parameter_must_be_last_in_a_parameter_list); + } + if (ts.isBindingPattern(parameter.name)) { + return grammarErrorOnNode(parameter.name, ts.Diagnostics.A_rest_element_cannot_contain_a_binding_pattern); + } + if (parameter.questionToken) { + return grammarErrorOnNode(parameter.questionToken, ts.Diagnostics.A_rest_parameter_cannot_be_optional); + } + if (parameter.initializer) { + return grammarErrorOnNode(parameter.name, ts.Diagnostics.A_rest_parameter_cannot_have_an_initializer); + } + } + else if (parameter.questionToken) { + seenOptionalParameter = true; + if (parameter.initializer) { + return grammarErrorOnNode(parameter.name, ts.Diagnostics.Parameter_cannot_have_question_mark_and_initializer); + } + } + else if (seenOptionalParameter && !parameter.initializer) { + return grammarErrorOnNode(parameter.name, ts.Diagnostics.A_required_parameter_cannot_follow_an_optional_parameter); + } + } + } + function checkGrammarFunctionLikeDeclaration(node) { + var file = ts.getSourceFileOfNode(node); + return checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarTypeParameterList(node, node.typeParameters, file) || + checkGrammarParameterList(node.parameters) || checkGrammarArrowFunction(node, file); + } + function checkGrammarArrowFunction(node, file) { + if (node.kind === 174) { + var arrowFunction = node; + var startLine = ts.getLineAndCharacterOfPosition(file, arrowFunction.equalsGreaterThanToken.pos).line; + var endLine = ts.getLineAndCharacterOfPosition(file, arrowFunction.equalsGreaterThanToken.end).line; + if (startLine !== endLine) { + return grammarErrorOnNode(arrowFunction.equalsGreaterThanToken, ts.Diagnostics.Line_terminator_not_permitted_before_arrow); + } + } + return false; + } + function checkGrammarIndexSignatureParameters(node) { + var parameter = node.parameters[0]; + if (node.parameters.length !== 1) { + if (parameter) { + return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_must_have_exactly_one_parameter); + } + else { + return grammarErrorOnNode(node, ts.Diagnostics.An_index_signature_must_have_exactly_one_parameter); + } + } + if (parameter.dotDotDotToken) { + return grammarErrorOnNode(parameter.dotDotDotToken, ts.Diagnostics.An_index_signature_cannot_have_a_rest_parameter); + } + if (parameter.flags & 2035) { + return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_cannot_have_an_accessibility_modifier); + } + if (parameter.questionToken) { + return grammarErrorOnNode(parameter.questionToken, ts.Diagnostics.An_index_signature_parameter_cannot_have_a_question_mark); + } + if (parameter.initializer) { + return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_cannot_have_an_initializer); + } + if (!parameter.type) { + return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_must_have_a_type_annotation); + } + if (parameter.type.kind !== 130 && parameter.type.kind !== 128) { + return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_type_must_be_string_or_number); + } + if (!node.type) { + return grammarErrorOnNode(node, ts.Diagnostics.An_index_signature_must_have_a_type_annotation); + } + } + function checkGrammarForIndexSignatureModifier(node) { + if (node.flags & 2035) { + grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_not_permitted_on_index_signature_members); + } + } + function checkGrammarIndexSignature(node) { + return checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarIndexSignatureParameters(node) || checkGrammarForIndexSignatureModifier(node); + } + function checkGrammarForAtLeastOneTypeArgument(node, typeArguments) { + if (typeArguments && typeArguments.length === 0) { + var sourceFile = ts.getSourceFileOfNode(node); + var start = typeArguments.pos - "<".length; + var end = ts.skipTrivia(sourceFile.text, typeArguments.end) + ">".length; + return grammarErrorAtPos(sourceFile, start, end - start, ts.Diagnostics.Type_argument_list_cannot_be_empty); + } + } + function checkGrammarTypeArguments(node, typeArguments) { + return checkGrammarForDisallowedTrailingComma(typeArguments) || + checkGrammarForAtLeastOneTypeArgument(node, typeArguments); + } + function checkGrammarForOmittedArgument(node, args) { + if (args) { + var sourceFile = ts.getSourceFileOfNode(node); + for (var _i = 0; _i < args.length; _i++) { + var arg = args[_i]; + if (arg.kind === 187) { + return grammarErrorAtPos(sourceFile, arg.pos, 0, ts.Diagnostics.Argument_expression_expected); + } + } + } + } + function checkGrammarArguments(node, args) { + return checkGrammarForDisallowedTrailingComma(args) || + checkGrammarForOmittedArgument(node, args); + } + function checkGrammarHeritageClause(node) { + var types = node.types; + if (checkGrammarForDisallowedTrailingComma(types)) { + return true; + } + if (types && types.length === 0) { + var listType = ts.tokenToString(node.token); + var sourceFile = ts.getSourceFileOfNode(node); + return grammarErrorAtPos(sourceFile, types.pos, 0, ts.Diagnostics._0_list_cannot_be_empty, listType); + } + } + function checkGrammarClassDeclarationHeritageClauses(node) { + var seenExtendsClause = false; + var seenImplementsClause = false; + 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 (seenExtendsClause) { + return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_already_seen); + } + if (seenImplementsClause) { + return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_must_precede_implements_clause); + } + if (heritageClause.types.length > 1) { + return grammarErrorOnFirstToken(heritageClause.types[1], ts.Diagnostics.Classes_can_only_extend_a_single_class); + } + seenExtendsClause = true; + } + else { + ts.Debug.assert(heritageClause.token === 106); + if (seenImplementsClause) { + return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.implements_clause_already_seen); + } + seenImplementsClause = true; + } + checkGrammarHeritageClause(heritageClause); + } + } + } + function checkGrammarInterfaceDeclaration(node) { + var seenExtendsClause = false; + if (node.heritageClauses) { + for (var _i = 0, _a = node.heritageClauses; _i < _a.length; _i++) { + var heritageClause = _a[_i]; + if (heritageClause.token === 83) { + if (seenExtendsClause) { + return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_already_seen); + } + seenExtendsClause = true; + } + else { + ts.Debug.assert(heritageClause.token === 106); + return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.Interface_declaration_cannot_have_implements_clause); + } + checkGrammarHeritageClause(heritageClause); + } + } + return false; + } + function checkGrammarComputedPropertyName(node) { + if (node.kind !== 136) { + return false; + } + var computedPropertyName = node; + if (computedPropertyName.expression.kind === 181 && computedPropertyName.expression.operatorToken.kind === 24) { + return grammarErrorOnNode(computedPropertyName.expression, ts.Diagnostics.A_comma_expression_is_not_allowed_in_a_computed_property_name); + } + } + function checkGrammarForGenerator(node) { + if (node.asteriskToken) { + ts.Debug.assert(node.kind === 213 || + node.kind === 173 || + node.kind === 143); + if (ts.isInAmbientContext(node)) { + return grammarErrorOnNode(node.asteriskToken, ts.Diagnostics.Generators_are_not_allowed_in_an_ambient_context); + } + if (!node.body) { + return grammarErrorOnNode(node.asteriskToken, ts.Diagnostics.An_overload_signature_cannot_be_declared_as_a_generator); + } + if (languageVersion < 2) { + return grammarErrorOnNode(node.asteriskToken, ts.Diagnostics.Generators_are_only_available_when_targeting_ECMAScript_6_or_higher); + } + } + } + function checkGrammarForInvalidQuestionMark(node, questionToken, message) { + if (questionToken) { + return grammarErrorOnNode(questionToken, message); + } + } + function checkGrammarObjectLiteralExpression(node, inDestructuring) { + var seen = {}; + var Property = 1; + var GetAccessor = 2; + var SetAccesor = 4; + var GetOrSetAccessor = GetAccessor | SetAccesor; + for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { + var prop = _a[_i]; + var name_17 = prop.name; + if (prop.kind === 187 || + name_17.kind === 136) { + checkGrammarComputedPropertyName(name_17); + continue; + } + if (prop.kind === 246 && !inDestructuring && prop.objectAssignmentInitializer) { + return grammarErrorOnNode(prop.equalsToken, ts.Diagnostics.can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment); + } + var currentKind = void 0; + if (prop.kind === 245 || prop.kind === 246) { + checkGrammarForInvalidQuestionMark(prop, prop.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional); + if (name_17.kind === 8) { + checkGrammarNumericLiteral(name_17); + } + currentKind = Property; + } + else if (prop.kind === 143) { + currentKind = Property; + } + else if (prop.kind === 145) { + currentKind = GetAccessor; + } + else if (prop.kind === 146) { + currentKind = SetAccesor; + } + else { + ts.Debug.fail("Unexpected syntax kind:" + prop.kind); + } + if (!ts.hasProperty(seen, name_17.text)) { + seen[name_17.text] = currentKind; + } + else { + var existingKind = seen[name_17.text]; + if (currentKind === Property && existingKind === Property) { + continue; + } + else if ((currentKind & GetOrSetAccessor) && (existingKind & GetOrSetAccessor)) { + if (existingKind !== GetOrSetAccessor && currentKind !== existingKind) { + seen[name_17.text] = currentKind | existingKind; + } + else { + return grammarErrorOnNode(name_17, ts.Diagnostics.An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name); + } + } + else { + return grammarErrorOnNode(name_17, ts.Diagnostics.An_object_literal_cannot_have_property_and_accessor_with_the_same_name); + } + } + } + } + function checkGrammarJsxElement(node) { + var seen = {}; + for (var _i = 0, _a = node.attributes; _i < _a.length; _i++) { + var attr = _a[_i]; + if (attr.kind === 239) { + continue; + } + var jsxAttr = attr; + var name_18 = jsxAttr.name; + if (!ts.hasProperty(seen, name_18.text)) { + seen[name_18.text] = true; + } + else { + return grammarErrorOnNode(name_18, ts.Diagnostics.JSX_elements_cannot_have_multiple_attributes_with_the_same_name); + } + var initializer = jsxAttr.initializer; + if (initializer && initializer.kind === 240 && !initializer.expression) { + return grammarErrorOnNode(jsxAttr.initializer, ts.Diagnostics.JSX_attributes_must_only_be_assigned_a_non_empty_expression); + } + } + } + function checkGrammarForInOrForOfStatement(forInOrOfStatement) { + if (checkGrammarStatementInAmbientContext(forInOrOfStatement)) { + return true; + } + if (forInOrOfStatement.initializer.kind === 212) { + var variableList = forInOrOfStatement.initializer; + if (!checkGrammarVariableDeclarationList(variableList)) { + if (variableList.declarations.length > 1) { + var diagnostic = forInOrOfStatement.kind === 200 + ? ts.Diagnostics.Only_a_single_variable_declaration_is_allowed_in_a_for_in_statement + : ts.Diagnostics.Only_a_single_variable_declaration_is_allowed_in_a_for_of_statement; + return grammarErrorOnFirstToken(variableList.declarations[1], diagnostic); + } + var firstDeclaration = variableList.declarations[0]; + if (firstDeclaration.initializer) { + var diagnostic = forInOrOfStatement.kind === 200 + ? ts.Diagnostics.The_variable_declaration_of_a_for_in_statement_cannot_have_an_initializer + : ts.Diagnostics.The_variable_declaration_of_a_for_of_statement_cannot_have_an_initializer; + return grammarErrorOnNode(firstDeclaration.name, diagnostic); + } + if (firstDeclaration.type) { + var diagnostic = forInOrOfStatement.kind === 200 + ? ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_use_a_type_annotation + : ts.Diagnostics.The_left_hand_side_of_a_for_of_statement_cannot_use_a_type_annotation; + return grammarErrorOnNode(firstDeclaration, diagnostic); + } + } + } + return false; + } + function checkGrammarAccessor(accessor) { + var kind = accessor.kind; + if (languageVersion < 1) { + return grammarErrorOnNode(accessor.name, ts.Diagnostics.Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher); + } + else if (ts.isInAmbientContext(accessor)) { + return grammarErrorOnNode(accessor.name, ts.Diagnostics.An_accessor_cannot_be_declared_in_an_ambient_context); + } + else if (accessor.body === undefined) { + return grammarErrorAtPos(ts.getSourceFileOfNode(accessor), accessor.end - 1, ";".length, ts.Diagnostics._0_expected, "{"); + } + else if (accessor.typeParameters) { + return grammarErrorOnNode(accessor.name, ts.Diagnostics.An_accessor_cannot_have_type_parameters); + } + else if (kind === 145 && accessor.parameters.length) { + return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_get_accessor_cannot_have_parameters); + } + else if (kind === 146) { + if (accessor.type) { + return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_set_accessor_cannot_have_a_return_type_annotation); + } + else if (accessor.parameters.length !== 1) { + return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_set_accessor_must_have_exactly_one_parameter); + } + else { + var parameter = accessor.parameters[0]; + if (parameter.dotDotDotToken) { + return grammarErrorOnNode(parameter.dotDotDotToken, ts.Diagnostics.A_set_accessor_cannot_have_rest_parameter); + } + else if (parameter.flags & 2035) { + return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation); + } + else if (parameter.questionToken) { + return grammarErrorOnNode(parameter.questionToken, ts.Diagnostics.A_set_accessor_cannot_have_an_optional_parameter); + } + else if (parameter.initializer) { + return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_set_accessor_parameter_cannot_have_an_initializer); + } + } + } + } + function checkGrammarForNonSymbolComputedProperty(node, message) { + if (node.kind === 136 && !ts.isWellKnownSymbolSyntactically(node.expression)) { + return grammarErrorOnNode(node, message); + } + } + function checkGrammarMethod(node) { + if (checkGrammarDisallowedModifiersOnObjectLiteralExpressionMethod(node) || + checkGrammarFunctionLikeDeclaration(node) || + checkGrammarForGenerator(node)) { + return true; + } + if (node.parent.kind === 165) { + if (checkGrammarForInvalidQuestionMark(node, node.questionToken, ts.Diagnostics.A_class_member_cannot_be_declared_optional)) { + return true; + } + else if (node.body === undefined) { + return grammarErrorAtPos(getSourceFile(node), node.end - 1, ";".length, ts.Diagnostics._0_expected, "{"); + } + } + if (ts.isClassLike(node.parent)) { + if (checkGrammarForInvalidQuestionMark(node, node.questionToken, ts.Diagnostics.A_class_member_cannot_be_declared_optional)) { + return true; + } + if (ts.isInAmbientContext(node)) { + return checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_an_ambient_context_must_directly_refer_to_a_built_in_symbol); + } + else if (!node.body) { + 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 === 215) { + return checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_an_interface_must_directly_refer_to_a_built_in_symbol); + } + else if (node.parent.kind === 155) { + return checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_type_literal_must_directly_refer_to_a_built_in_symbol); + } + } + function checkGrammarBreakOrContinueStatement(node) { + var current = node; + while (current) { + if (ts.isFunctionLike(current)) { + return grammarErrorOnNode(node, ts.Diagnostics.Jump_target_cannot_cross_function_boundary); + } + switch (current.kind) { + case 207: + if (node.label && current.label.text === node.label.text) { + var isMisplacedContinueLabel = node.kind === 202 + && !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); + } + return false; + } + break; + case 206: + if (node.kind === 203 && !node.label) { + return false; + } + break; + default: + if (ts.isIterationStatement(current, false) && !node.label) { + return false; + } + break; + } + current = current.parent; + } + if (node.label) { + var message = node.kind === 203 + ? ts.Diagnostics.A_break_statement_can_only_jump_to_a_label_of_an_enclosing_statement + : ts.Diagnostics.A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement; + return grammarErrorOnNode(node, message); + } + else { + var message = node.kind === 203 + ? ts.Diagnostics.A_break_statement_can_only_be_used_within_an_enclosing_iteration_or_switch_statement + : ts.Diagnostics.A_continue_statement_can_only_be_used_within_an_enclosing_iteration_statement; + return grammarErrorOnNode(node, message); + } + } + function checkGrammarBindingElement(node) { + if (node.dotDotDotToken) { + var elements = node.parent.elements; + 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 === 162 || node.name.kind === 161) { + return grammarErrorOnNode(node.name, ts.Diagnostics.A_rest_element_cannot_contain_a_binding_pattern); + } + if (node.initializer) { + return grammarErrorAtPos(ts.getSourceFileOfNode(node), node.initializer.pos - 1, 1, ts.Diagnostics.A_rest_element_cannot_have_an_initializer); + } + } + } + function checkGrammarVariableDeclaration(node) { + if (node.parent.parent.kind !== 200 && node.parent.parent.kind !== 201) { + if (ts.isInAmbientContext(node)) { + if (node.initializer) { + var equalsTokenLength = "=".length; + return grammarErrorAtPos(ts.getSourceFileOfNode(node), node.initializer.pos - equalsTokenLength, equalsTokenLength, ts.Diagnostics.Initializers_are_not_allowed_in_ambient_contexts); + } + } + else if (!node.initializer) { + if (ts.isBindingPattern(node.name) && !ts.isBindingPattern(node.parent)) { + return grammarErrorOnNode(node, ts.Diagnostics.A_destructuring_declaration_must_have_an_initializer); + } + if (ts.isConst(node)) { + return grammarErrorOnNode(node, ts.Diagnostics.const_declarations_must_be_initialized); + } + } + } + var checkLetConstNames = languageVersion >= 2 && (ts.isLet(node) || ts.isConst(node)); + return checkLetConstNames && checkGrammarNameInLetOrConstDeclarations(node.name); + } + function checkGrammarNameInLetOrConstDeclarations(name) { + if (name.kind === 69) { + if (name.text === "let") { + return grammarErrorOnNode(name, ts.Diagnostics.let_is_not_allowed_to_be_used_as_a_name_in_let_or_const_declarations); + } + } + else { + var elements = name.elements; + for (var _i = 0; _i < elements.length; _i++) { + var element = elements[_i]; + if (element.kind !== 187) { + checkGrammarNameInLetOrConstDeclarations(element.name); + } + } + } + } + function checkGrammarVariableDeclarationList(declarationList) { + var declarations = declarationList.declarations; + if (checkGrammarForDisallowedTrailingComma(declarationList.declarations)) { + return true; + } + if (!declarationList.declarations.length) { + return grammarErrorAtPos(ts.getSourceFileOfNode(declarationList), declarations.pos, declarations.end - declarations.pos, ts.Diagnostics.Variable_declaration_list_cannot_be_empty); + } + } + function allowLetAndConstDeclarations(parent) { + switch (parent.kind) { + case 196: + case 197: + case 198: + case 205: + case 199: + case 200: + case 201: + return false; + case 207: + return allowLetAndConstDeclarations(parent.parent); + } + return true; + } + function checkGrammarForDisallowedLetOrConstStatement(node) { + if (!allowLetAndConstDeclarations(node.parent)) { + if (ts.isLet(node.declarationList)) { + return grammarErrorOnNode(node, ts.Diagnostics.let_declarations_can_only_be_declared_inside_a_block); + } + else if (ts.isConst(node.declarationList)) { + return grammarErrorOnNode(node, ts.Diagnostics.const_declarations_can_only_be_declared_inside_a_block); + } + } + } + function isIntegerLiteral(expression) { + if (expression.kind === 179) { + var unaryExpression = expression; + if (unaryExpression.operator === 35 || unaryExpression.operator === 36) { + expression = unaryExpression.operand; + } + } + if (expression.kind === 8) { + return /^[0-9]+([eE]\+?[0-9]+)?$/.test(expression.text); + } + return false; + } + function hasParseDiagnostics(sourceFile) { + return sourceFile.parseDiagnostics.length > 0; + } + function grammarErrorOnFirstToken(node, message, arg0, arg1, arg2) { + var sourceFile = ts.getSourceFileOfNode(node); + if (!hasParseDiagnostics(sourceFile)) { + var span = ts.getSpanOfTokenAtPosition(sourceFile, node.pos); + diagnostics.add(ts.createFileDiagnostic(sourceFile, span.start, span.length, message, arg0, arg1, arg2)); + return true; + } + } + function grammarErrorAtPos(sourceFile, start, length, message, arg0, arg1, arg2) { + if (!hasParseDiagnostics(sourceFile)) { + diagnostics.add(ts.createFileDiagnostic(sourceFile, start, length, message, arg0, arg1, arg2)); + return true; + } + } + function grammarErrorOnNode(node, message, arg0, arg1, arg2) { + var sourceFile = ts.getSourceFileOfNode(node); + if (!hasParseDiagnostics(sourceFile)) { + diagnostics.add(ts.createDiagnosticForNode(node, message, arg0, arg1, arg2)); + return true; + } + } + function isEvalOrArgumentsIdentifier(node) { + return node.kind === 69 && + (node.text === "eval" || node.text === "arguments"); + } + function checkGrammarConstructorTypeParameters(node) { + if (node.typeParameters) { + return grammarErrorAtPos(ts.getSourceFileOfNode(node), node.typeParameters.pos, node.typeParameters.end - node.typeParameters.pos, ts.Diagnostics.Type_parameters_cannot_appear_on_a_constructor_declaration); + } + } + function checkGrammarConstructorTypeAnnotation(node) { + if (node.type) { + return grammarErrorOnNode(node.type, ts.Diagnostics.Type_annotation_cannot_appear_on_a_constructor_declaration); + } + } + function checkGrammarProperty(node) { + if (ts.isClassLike(node.parent)) { + if (checkGrammarForInvalidQuestionMark(node, node.questionToken, ts.Diagnostics.A_class_member_cannot_be_declared_optional) || + checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_class_property_declaration_must_directly_refer_to_a_built_in_symbol)) { + return true; + } + } + else if (node.parent.kind === 215) { + if (checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_an_interface_must_directly_refer_to_a_built_in_symbol)) { + return true; + } + } + else if (node.parent.kind === 155) { + if (checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_type_literal_must_directly_refer_to_a_built_in_symbol)) { + return true; + } + } + if (ts.isInAmbientContext(node) && node.initializer) { + return grammarErrorOnFirstToken(node.initializer, ts.Diagnostics.Initializers_are_not_allowed_in_ambient_contexts); + } + } + function checkGrammarTopLevelElementForRequiredDeclareModifier(node) { + if (node.kind === 215 || + node.kind === 216 || + node.kind === 222 || + node.kind === 221 || + node.kind === 228 || + node.kind === 227 || + (node.flags & 2) || + (node.flags & (1 | 1024))) { + return false; + } + return grammarErrorOnFirstToken(node, ts.Diagnostics.A_declare_modifier_is_required_for_a_top_level_declaration_in_a_d_ts_file); + } + function checkGrammarTopLevelElementsForRequiredDeclareModifier(file) { + for (var _i = 0, _a = file.statements; _i < _a.length; _i++) { + var decl = _a[_i]; + if (ts.isDeclaration(decl) || decl.kind === 193) { + if (checkGrammarTopLevelElementForRequiredDeclareModifier(decl)) { + return true; + } + } + } + } + function checkGrammarSourceFile(node) { + return ts.isInAmbientContext(node) && checkGrammarTopLevelElementsForRequiredDeclareModifier(node); + } + function checkGrammarStatementInAmbientContext(node) { + if (ts.isInAmbientContext(node)) { + if (isAccessor(node.parent.kind)) { + return getNodeLinks(node).hasReportedStatementInAmbientContext = true; + } + var links = getNodeLinks(node); + 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 === 192 || node.parent.kind === 219 || node.parent.kind === 248) { + var links_1 = getNodeLinks(node.parent); + if (!links_1.hasReportedStatementInAmbientContext) { + return links_1.hasReportedStatementInAmbientContext = grammarErrorOnFirstToken(node, ts.Diagnostics.Statements_are_not_allowed_in_ambient_contexts); + } + } + else { + } + } + } + function checkGrammarNumericLiteral(node) { + if (node.flags & 65536 && languageVersion >= 1) { + return grammarErrorOnNode(node, ts.Diagnostics.Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher); + } + } + function grammarErrorAfterFirstToken(node, message, arg0, arg1, arg2) { + var sourceFile = ts.getSourceFileOfNode(node); + if (!hasParseDiagnostics(sourceFile)) { + var span = ts.getSpanOfTokenAtPosition(sourceFile, node.pos); + diagnostics.add(ts.createFileDiagnostic(sourceFile, ts.textSpanEnd(span), 0, message, arg0, arg1, arg2)); + return true; + } + } + } + ts.createTypeChecker = createTypeChecker; +})(ts || (ts = {})); +var ts; +(function (ts) { + function getDeclarationDiagnostics(host, resolver, targetSourceFile) { + var diagnostics = []; + var jsFilePath = ts.getOwnEmitOutputFilePath(targetSourceFile, host, ".js"); + emitDeclarations(host, resolver, diagnostics, jsFilePath, targetSourceFile); + return diagnostics; + } + ts.getDeclarationDiagnostics = getDeclarationDiagnostics; + function emitDeclarations(host, resolver, diagnostics, jsFilePath, root) { + var newLine = host.getNewLine(); + var compilerOptions = host.getCompilerOptions(); + var write; + var writeLine; + var increaseIndent; + var decreaseIndent; + var writeTextOfNode; + var writer = createAndSetNewTextWriterWithSymbolWriter(); + var enclosingDeclaration; + var currentSourceFile; + var reportedDeclarationError = false; + var errorNameNode; + var emitJsDocComments = compilerOptions.removeComments ? function (declaration) { } : writeJsDocComments; + var emit = compilerOptions.stripInternal ? stripInternal : emitNode; + var moduleElementDeclarationEmitInfo = []; + var asynchronousSubModuleDeclarationEmitInfo; + var referencePathsOutput = ""; + if (root) { + if (!compilerOptions.noResolve) { + var addedGlobalFileReference = false; + ts.forEach(root.referencedFiles, function (fileReference) { + var referencedFile = ts.tryResolveScriptReference(host, root, fileReference); + if (referencedFile && ((referencedFile.flags & 8192) || + ts.shouldEmitToOwnFile(referencedFile, compilerOptions) || + !addedGlobalFileReference)) { + writeReferencePath(referencedFile); + if (!ts.isExternalModuleOrDeclarationFile(referencedFile)) { + addedGlobalFileReference = true; + } + } + }); + } + emitSourceFile(root); + if (moduleElementDeclarationEmitInfo.length) { + var oldWriter = writer; + ts.forEach(moduleElementDeclarationEmitInfo, function (aliasEmitInfo) { + if (aliasEmitInfo.isVisible) { + ts.Debug.assert(aliasEmitInfo.node.kind === 222); + createAndSetNewTextWriterWithSymbolWriter(); + ts.Debug.assert(aliasEmitInfo.indent === 0); + writeImportDeclaration(aliasEmitInfo.node); + aliasEmitInfo.asynchronousOutput = writer.getText(); + } + }); + setWriter(oldWriter); + } + } + else { + var emittedReferencedFiles = []; + ts.forEach(host.getSourceFiles(), function (sourceFile) { + if (!ts.isExternalModuleOrDeclarationFile(sourceFile)) { + if (!compilerOptions.noResolve) { + ts.forEach(sourceFile.referencedFiles, function (fileReference) { + var referencedFile = ts.tryResolveScriptReference(host, sourceFile, fileReference); + if (referencedFile && (ts.isExternalModuleOrDeclarationFile(referencedFile) && + !ts.contains(emittedReferencedFiles, referencedFile))) { + writeReferencePath(referencedFile); + emittedReferencedFiles.push(referencedFile); + } + }); + } + emitSourceFile(sourceFile); + } + }); + } + return { + reportedDeclarationError: reportedDeclarationError, + moduleElementDeclarationEmitInfo: moduleElementDeclarationEmitInfo, + synchronousDeclarationOutput: writer.getText(), + referencePathsOutput: referencePathsOutput + }; + function hasInternalAnnotation(range) { + var text = currentSourceFile.text; + var comment = text.substring(range.pos, range.end); + return comment.indexOf("@internal") >= 0; + } + function stripInternal(node) { + if (node) { + var leadingCommentRanges = ts.getLeadingCommentRanges(currentSourceFile.text, node.pos); + if (ts.forEach(leadingCommentRanges, hasInternalAnnotation)) { + return; + } + emitNode(node); + } + } + function createAndSetNewTextWriterWithSymbolWriter() { + var writer = ts.createTextWriter(newLine); + writer.trackSymbol = trackSymbol; + writer.reportInaccessibleThisError = reportInaccessibleThisError; + writer.writeKeyword = writer.write; + writer.writeOperator = writer.write; + writer.writePunctuation = writer.write; + writer.writeSpace = writer.write; + writer.writeStringLiteral = writer.writeLiteral; + writer.writeParameter = writer.write; + writer.writeSymbol = writer.write; + setWriter(writer); + return writer; + } + function setWriter(newWriter) { + writer = newWriter; + write = newWriter.write; + writeTextOfNode = newWriter.writeTextOfNode; + writeLine = newWriter.writeLine; + increaseIndent = newWriter.increaseIndent; + decreaseIndent = newWriter.decreaseIndent; + } + function writeAsynchronousModuleElements(nodes) { + var oldWriter = writer; + ts.forEach(nodes, function (declaration) { + var nodeToCheck; + if (declaration.kind === 211) { + nodeToCheck = declaration.parent.parent; + } + else if (declaration.kind === 225 || declaration.kind === 226 || declaration.kind === 223) { + ts.Debug.fail("We should be getting ImportDeclaration instead to write"); + } + else { + nodeToCheck = declaration; + } + var moduleElementEmitInfo = ts.forEach(moduleElementDeclarationEmitInfo, function (declEmitInfo) { return declEmitInfo.node === nodeToCheck ? declEmitInfo : undefined; }); + if (!moduleElementEmitInfo && asynchronousSubModuleDeclarationEmitInfo) { + moduleElementEmitInfo = ts.forEach(asynchronousSubModuleDeclarationEmitInfo, function (declEmitInfo) { return declEmitInfo.node === nodeToCheck ? declEmitInfo : undefined; }); + } + if (moduleElementEmitInfo) { + if (moduleElementEmitInfo.node.kind === 222) { + moduleElementEmitInfo.isVisible = true; + } + else { + createAndSetNewTextWriterWithSymbolWriter(); + for (var declarationIndent = moduleElementEmitInfo.indent; declarationIndent; declarationIndent--) { + increaseIndent(); + } + if (nodeToCheck.kind === 218) { + ts.Debug.assert(asynchronousSubModuleDeclarationEmitInfo === undefined); + asynchronousSubModuleDeclarationEmitInfo = []; + } + writeModuleElement(nodeToCheck); + if (nodeToCheck.kind === 218) { + moduleElementEmitInfo.subModuleElementDeclarationEmitInfo = asynchronousSubModuleDeclarationEmitInfo; + asynchronousSubModuleDeclarationEmitInfo = undefined; + } + moduleElementEmitInfo.asynchronousOutput = writer.getText(); + } + } + }); + setWriter(oldWriter); + } + function handleSymbolAccessibilityError(symbolAccesibilityResult) { + if (symbolAccesibilityResult.accessibility === 0) { + if (symbolAccesibilityResult && symbolAccesibilityResult.aliasesToMakeVisible) { + writeAsynchronousModuleElements(symbolAccesibilityResult.aliasesToMakeVisible); + } + } + else { + reportedDeclarationError = true; + var errorInfo = writer.getSymbolAccessibilityDiagnostic(symbolAccesibilityResult); + if (errorInfo) { + if (errorInfo.typeName) { + diagnostics.push(ts.createDiagnosticForNode(symbolAccesibilityResult.errorNode || errorInfo.errorNode, errorInfo.diagnosticMessage, ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, errorInfo.typeName), symbolAccesibilityResult.errorSymbolName, symbolAccesibilityResult.errorModuleName)); + } + else { + diagnostics.push(ts.createDiagnosticForNode(symbolAccesibilityResult.errorNode || errorInfo.errorNode, errorInfo.diagnosticMessage, symbolAccesibilityResult.errorSymbolName, symbolAccesibilityResult.errorModuleName)); + } + } + } + } + function trackSymbol(symbol, enclosingDeclaration, meaning) { + handleSymbolAccessibilityError(resolver.isSymbolAccessible(symbol, enclosingDeclaration, meaning)); + } + function reportInaccessibleThisError() { + if (errorNameNode) { + diagnostics.push(ts.createDiagnosticForNode(errorNameNode, ts.Diagnostics.The_inferred_type_of_0_references_an_inaccessible_this_type_A_type_annotation_is_necessary, ts.declarationNameToString(errorNameNode))); + } + } + function writeTypeOfDeclaration(declaration, type, getSymbolAccessibilityDiagnostic) { + writer.getSymbolAccessibilityDiagnostic = getSymbolAccessibilityDiagnostic; + write(": "); + if (type) { + emitType(type); + } + else { + errorNameNode = declaration.name; + resolver.writeTypeOfDeclaration(declaration, enclosingDeclaration, 2, writer); + errorNameNode = undefined; + } + } + function writeReturnTypeAtSignature(signature, getSymbolAccessibilityDiagnostic) { + writer.getSymbolAccessibilityDiagnostic = getSymbolAccessibilityDiagnostic; + write(": "); + if (signature.type) { + emitType(signature.type); + } + else { + errorNameNode = signature.name; + resolver.writeReturnTypeOfSignatureDeclaration(signature, enclosingDeclaration, 2, writer); + errorNameNode = undefined; + } + } + function emitLines(nodes) { + for (var _i = 0; _i < nodes.length; _i++) { + var node = nodes[_i]; + emit(node); + } + } + function emitSeparatedList(nodes, separator, eachNodeEmitFn, canEmitFn) { + var currentWriterPos = writer.getTextPos(); + for (var _i = 0; _i < nodes.length; _i++) { + var node = nodes[_i]; + if (!canEmitFn || canEmitFn(node)) { + if (currentWriterPos !== writer.getTextPos()) { + write(separator); + } + currentWriterPos = writer.getTextPos(); + eachNodeEmitFn(node); + } + } + } + function emitCommaList(nodes, eachNodeEmitFn, canEmitFn) { + emitSeparatedList(nodes, ", ", eachNodeEmitFn, canEmitFn); + } + function writeJsDocComments(declaration) { + if (declaration) { + var jsDocComments = ts.getJsDocComments(declaration, currentSourceFile); + ts.emitNewLineBeforeLeadingComments(currentSourceFile, writer, declaration, jsDocComments); + ts.emitComments(currentSourceFile, writer, jsDocComments, true, newLine, ts.writeCommentRange); + } + } + function emitTypeWithNewGetSymbolAccessibilityDiagnostic(type, getSymbolAccessibilityDiagnostic) { + writer.getSymbolAccessibilityDiagnostic = getSymbolAccessibilityDiagnostic; + emitType(type); + } + function emitType(type) { + switch (type.kind) { + case 117: + case 130: + case 128: + case 120: + case 131: + case 103: + case 97: + case 9: + return writeTextOfNode(currentSourceFile, type); + case 188: + return emitExpressionWithTypeArguments(type); + case 151: + return emitTypeReference(type); + case 154: + return emitTypeQuery(type); + case 156: + return emitArrayType(type); + case 157: + return emitTupleType(type); + case 158: + return emitUnionType(type); + case 159: + return emitIntersectionType(type); + case 160: + return emitParenType(type); + case 152: + case 153: + return emitSignatureDeclarationWithJsDocComments(type); + case 155: + return emitTypeLiteral(type); + case 69: + return emitEntityName(type); + case 135: + return emitEntityName(type); + case 150: + return emitTypePredicate(type); + } + function writeEntityName(entityName) { + if (entityName.kind === 69) { + writeTextOfNode(currentSourceFile, entityName); + } + else { + var left = entityName.kind === 135 ? entityName.left : entityName.expression; + var right = entityName.kind === 135 ? entityName.right : entityName.name; + writeEntityName(left); + write("."); + writeTextOfNode(currentSourceFile, right); + } + } + function emitEntityName(entityName) { + var visibilityResult = resolver.isEntityNameVisible(entityName, entityName.parent.kind === 221 ? entityName.parent : enclosingDeclaration); + handleSymbolAccessibilityError(visibilityResult); + writeEntityName(entityName); + } + function emitExpressionWithTypeArguments(node) { + if (ts.isSupportedExpressionWithTypeArguments(node)) { + ts.Debug.assert(node.expression.kind === 69 || node.expression.kind === 166); + emitEntityName(node.expression); + if (node.typeArguments) { + write("<"); + emitCommaList(node.typeArguments, emitType); + write(">"); + } + } + } + function emitTypeReference(type) { + emitEntityName(type.typeName); + if (type.typeArguments) { + write("<"); + emitCommaList(type.typeArguments, emitType); + write(">"); + } + } + function emitTypePredicate(type) { + writeTextOfNode(currentSourceFile, type.parameterName); + write(" is "); + emitType(type.type); + } + function emitTypeQuery(type) { + write("typeof "); + emitEntityName(type.exprName); + } + function emitArrayType(type) { + emitType(type.elementType); + write("[]"); + } + function emitTupleType(type) { + write("["); + emitCommaList(type.elementTypes, emitType); + write("]"); + } + function emitUnionType(type) { + emitSeparatedList(type.types, " | ", emitType); + } + function emitIntersectionType(type) { + emitSeparatedList(type.types, " & ", emitType); + } + function emitParenType(type) { + write("("); + emitType(type.type); + write(")"); + } + function emitTypeLiteral(type) { + write("{"); + if (type.members.length) { + writeLine(); + increaseIndent(); + emitLines(type.members); + decreaseIndent(); + } + write("}"); + } + } + function emitSourceFile(node) { + currentSourceFile = node; + enclosingDeclaration = node; + emitLines(node.statements); + } + function getExportDefaultTempVariableName() { + var baseName = "_default"; + if (!ts.hasProperty(currentSourceFile.identifiers, baseName)) { + return baseName; + } + var count = 0; + while (true) { + var name_19 = baseName + "_" + (++count); + if (!ts.hasProperty(currentSourceFile.identifiers, name_19)) { + return name_19; + } + } + } + function emitExportAssignment(node) { + if (node.expression.kind === 69) { + write(node.isExportEquals ? "export = " : "export default "); + writeTextOfNode(currentSourceFile, node.expression); + } + else { + var tempVarName = getExportDefaultTempVariableName(); + write("declare var "); + write(tempVarName); + write(": "); + writer.getSymbolAccessibilityDiagnostic = getDefaultExportAccessibilityDiagnostic; + resolver.writeTypeOfExpression(node.expression, enclosingDeclaration, 2, writer); + write(";"); + writeLine(); + write(node.isExportEquals ? "export = " : "export default "); + write(tempVarName); + } + write(";"); + writeLine(); + if (node.expression.kind === 69) { + var nodes = resolver.collectLinkedAliases(node.expression); + writeAsynchronousModuleElements(nodes); + } + function getDefaultExportAccessibilityDiagnostic(diagnostic) { + return { + diagnosticMessage: ts.Diagnostics.Default_export_of_the_module_has_or_is_using_private_name_0, + errorNode: node + }; + } + } + function isModuleElementVisible(node) { + return resolver.isDeclarationVisible(node); + } + function emitModuleElement(node, isModuleElementVisible) { + if (isModuleElementVisible) { + writeModuleElement(node); + } + else if (node.kind === 221 || + (node.parent.kind === 248 && ts.isExternalModule(currentSourceFile))) { + var isVisible; + if (asynchronousSubModuleDeclarationEmitInfo && node.parent.kind !== 248) { + asynchronousSubModuleDeclarationEmitInfo.push({ + node: node, + outputPos: writer.getTextPos(), + indent: writer.getIndent(), + isVisible: isVisible + }); + } + else { + if (node.kind === 222) { + var importDeclaration = node; + if (importDeclaration.importClause) { + isVisible = (importDeclaration.importClause.name && resolver.isDeclarationVisible(importDeclaration.importClause)) || + isVisibleNamedBinding(importDeclaration.importClause.namedBindings); + } + } + moduleElementDeclarationEmitInfo.push({ + node: node, + outputPos: writer.getTextPos(), + indent: writer.getIndent(), + isVisible: isVisible + }); + } + } + } + function writeModuleElement(node) { + switch (node.kind) { + case 213: + return writeFunctionDeclaration(node); + case 193: + return writeVariableStatement(node); + case 215: + return writeInterfaceDeclaration(node); + case 214: + return writeClassDeclaration(node); + case 216: + return writeTypeAliasDeclaration(node); + case 217: + return writeEnumDeclaration(node); + case 218: + return writeModuleDeclaration(node); + case 221: + return writeImportEqualsDeclaration(node); + case 222: + return writeImportDeclaration(node); + default: + ts.Debug.fail("Unknown symbol kind"); + } + } + function emitModuleElementDeclarationFlags(node) { + if (node.parent === currentSourceFile) { + if (node.flags & 1) { + write("export "); + } + if (node.flags & 1024) { + write("default "); + } + else if (node.kind !== 215) { + write("declare "); + } + } + } + function emitClassMemberDeclarationFlags(node) { + if (node.flags & 32) { + write("private "); + } + else if (node.flags & 64) { + write("protected "); + } + if (node.flags & 128) { + write("static "); + } + if (node.flags & 256) { + write("abstract "); + } + } + function writeImportEqualsDeclaration(node) { + emitJsDocComments(node); + if (node.flags & 1) { + write("export "); + } + write("import "); + writeTextOfNode(currentSourceFile, node.name); + write(" = "); + if (ts.isInternalModuleImportEqualsDeclaration(node)) { + emitTypeWithNewGetSymbolAccessibilityDiagnostic(node.moduleReference, getImportEntityNameVisibilityError); + write(";"); + } + else { + write("require("); + writeTextOfNode(currentSourceFile, ts.getExternalModuleImportEqualsDeclarationExpression(node)); + write(");"); + } + writer.writeLine(); + function getImportEntityNameVisibilityError(symbolAccesibilityResult) { + return { + diagnosticMessage: ts.Diagnostics.Import_declaration_0_is_using_private_name_1, + errorNode: node, + typeName: node.name + }; + } + } + function isVisibleNamedBinding(namedBindings) { + if (namedBindings) { + if (namedBindings.kind === 224) { + return resolver.isDeclarationVisible(namedBindings); + } + else { + return ts.forEach(namedBindings.elements, function (namedImport) { return resolver.isDeclarationVisible(namedImport); }); + } + } + } + function writeImportDeclaration(node) { + if (!node.importClause && !(node.flags & 1)) { + return; + } + emitJsDocComments(node); + if (node.flags & 1) { + write("export "); + } + write("import "); + if (node.importClause) { + var currentWriterPos = writer.getTextPos(); + if (node.importClause.name && resolver.isDeclarationVisible(node.importClause)) { + writeTextOfNode(currentSourceFile, node.importClause.name); + } + if (node.importClause.namedBindings && isVisibleNamedBinding(node.importClause.namedBindings)) { + if (currentWriterPos !== writer.getTextPos()) { + write(", "); + } + if (node.importClause.namedBindings.kind === 224) { + write("* as "); + writeTextOfNode(currentSourceFile, node.importClause.namedBindings.name); + } + else { + write("{ "); + emitCommaList(node.importClause.namedBindings.elements, emitImportOrExportSpecifier, resolver.isDeclarationVisible); + write(" }"); + } + } + write(" from "); + } + writeTextOfNode(currentSourceFile, node.moduleSpecifier); + write(";"); + writer.writeLine(); + } + function emitImportOrExportSpecifier(node) { + if (node.propertyName) { + writeTextOfNode(currentSourceFile, node.propertyName); + write(" as "); + } + writeTextOfNode(currentSourceFile, node.name); + } + function emitExportSpecifier(node) { + emitImportOrExportSpecifier(node); + var nodes = resolver.collectLinkedAliases(node.propertyName || node.name); + writeAsynchronousModuleElements(nodes); + } + function emitExportDeclaration(node) { + emitJsDocComments(node); + write("export "); + if (node.exportClause) { + write("{ "); + emitCommaList(node.exportClause.elements, emitExportSpecifier); + write(" }"); + } + else { + write("*"); + } + if (node.moduleSpecifier) { + write(" from "); + writeTextOfNode(currentSourceFile, node.moduleSpecifier); + } + write(";"); + writer.writeLine(); + } + function writeModuleDeclaration(node) { + emitJsDocComments(node); + emitModuleElementDeclarationFlags(node); + if (node.flags & 131072) { + write("namespace "); + } + else { + write("module "); + } + writeTextOfNode(currentSourceFile, node.name); + while (node.body.kind !== 219) { + node = node.body; + write("."); + writeTextOfNode(currentSourceFile, node.name); + } + var prevEnclosingDeclaration = enclosingDeclaration; + enclosingDeclaration = node; + write(" {"); + writeLine(); + increaseIndent(); + emitLines(node.body.statements); + decreaseIndent(); + write("}"); + writeLine(); + enclosingDeclaration = prevEnclosingDeclaration; + } + function writeTypeAliasDeclaration(node) { + var prevEnclosingDeclaration = enclosingDeclaration; + enclosingDeclaration = node; + emitJsDocComments(node); + emitModuleElementDeclarationFlags(node); + write("type "); + writeTextOfNode(currentSourceFile, node.name); + emitTypeParameters(node.typeParameters); + write(" = "); + emitTypeWithNewGetSymbolAccessibilityDiagnostic(node.type, getTypeAliasDeclarationVisibilityError); + write(";"); + writeLine(); + enclosingDeclaration = prevEnclosingDeclaration; + function getTypeAliasDeclarationVisibilityError(symbolAccesibilityResult) { + return { + diagnosticMessage: ts.Diagnostics.Exported_type_alias_0_has_or_is_using_private_name_1, + errorNode: node.type, + typeName: node.name + }; + } + } + function writeEnumDeclaration(node) { + emitJsDocComments(node); + emitModuleElementDeclarationFlags(node); + if (ts.isConst(node)) { + write("const "); + } + write("enum "); + writeTextOfNode(currentSourceFile, node.name); + write(" {"); + writeLine(); + increaseIndent(); + emitLines(node.members); + decreaseIndent(); + write("}"); + writeLine(); + } + function emitEnumMemberDeclaration(node) { + emitJsDocComments(node); + writeTextOfNode(currentSourceFile, node.name); + var enumMemberValue = resolver.getConstantValue(node); + if (enumMemberValue !== undefined) { + write(" = "); + write(enumMemberValue.toString()); + } + write(","); + writeLine(); + } + function isPrivateMethodTypeParameter(node) { + return node.parent.kind === 143 && (node.parent.flags & 32); + } + function emitTypeParameters(typeParameters) { + function emitTypeParameter(node) { + increaseIndent(); + emitJsDocComments(node); + decreaseIndent(); + writeTextOfNode(currentSourceFile, node.name); + if (node.constraint && !isPrivateMethodTypeParameter(node)) { + write(" extends "); + if (node.parent.kind === 152 || + node.parent.kind === 153 || + (node.parent.parent && node.parent.parent.kind === 155)) { + ts.Debug.assert(node.parent.kind === 143 || + node.parent.kind === 142 || + node.parent.kind === 152 || + node.parent.kind === 153 || + node.parent.kind === 147 || + node.parent.kind === 148); + emitType(node.constraint); + } + else { + emitTypeWithNewGetSymbolAccessibilityDiagnostic(node.constraint, getTypeParameterConstraintVisibilityError); + } + } + function getTypeParameterConstraintVisibilityError(symbolAccesibilityResult) { + var diagnosticMessage; + switch (node.parent.kind) { + case 214: + diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_class_has_or_is_using_private_name_1; + break; + case 215: + diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1; + break; + case 148: + diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; + break; + case 147: + diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; + break; + case 143: + case 142: + if (node.parent.flags & 128) { + diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1; + } + else if (node.parent.parent.kind === 214) { + diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_public_method_from_exported_class_has_or_is_using_private_name_1; + } + else { + diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1; + } + break; + case 213: + diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_function_has_or_is_using_private_name_1; + break; + default: + ts.Debug.fail("This is unknown parent for type parameter: " + node.parent.kind); + } + return { + diagnosticMessage: diagnosticMessage, + errorNode: node, + typeName: node.name + }; + } + } + if (typeParameters) { + write("<"); + emitCommaList(typeParameters, emitTypeParameter); + write(">"); + } + } + function emitHeritageClause(typeReferences, isImplementsList) { + if (typeReferences) { + write(isImplementsList ? " implements " : " extends "); + emitCommaList(typeReferences, emitTypeOfTypeReference); + } + function emitTypeOfTypeReference(node) { + if (ts.isSupportedExpressionWithTypeArguments(node)) { + emitTypeWithNewGetSymbolAccessibilityDiagnostic(node, getHeritageClauseVisibilityError); + } + else if (!isImplementsList && node.expression.kind === 93) { + write("null"); + } + function getHeritageClauseVisibilityError(symbolAccesibilityResult) { + var diagnosticMessage; + if (node.parent.parent.kind === 214) { + diagnosticMessage = isImplementsList ? + ts.Diagnostics.Implements_clause_of_exported_class_0_has_or_is_using_private_name_1 : + ts.Diagnostics.Extends_clause_of_exported_class_0_has_or_is_using_private_name_1; + } + else { + diagnosticMessage = ts.Diagnostics.Extends_clause_of_exported_interface_0_has_or_is_using_private_name_1; + } + return { + diagnosticMessage: diagnosticMessage, + errorNode: node, + typeName: node.parent.parent.name + }; + } + } + } + function writeClassDeclaration(node) { + function emitParameterProperties(constructorDeclaration) { + if (constructorDeclaration) { + ts.forEach(constructorDeclaration.parameters, function (param) { + if (param.flags & 112) { + emitPropertyDeclaration(param); + } + }); + } + } + emitJsDocComments(node); + emitModuleElementDeclarationFlags(node); + if (node.flags & 256) { + write("abstract "); + } + write("class "); + writeTextOfNode(currentSourceFile, node.name); + var prevEnclosingDeclaration = enclosingDeclaration; + enclosingDeclaration = node; + emitTypeParameters(node.typeParameters); + var baseTypeNode = ts.getClassExtendsHeritageClauseElement(node); + if (baseTypeNode) { + emitHeritageClause([baseTypeNode], false); + } + emitHeritageClause(ts.getClassImplementsHeritageClauseElements(node), true); + write(" {"); + writeLine(); + increaseIndent(); + emitParameterProperties(ts.getFirstConstructorWithBody(node)); + emitLines(node.members); + decreaseIndent(); + write("}"); + writeLine(); + enclosingDeclaration = prevEnclosingDeclaration; + } + function writeInterfaceDeclaration(node) { + emitJsDocComments(node); + emitModuleElementDeclarationFlags(node); + write("interface "); + writeTextOfNode(currentSourceFile, node.name); + var prevEnclosingDeclaration = enclosingDeclaration; + enclosingDeclaration = node; + emitTypeParameters(node.typeParameters); + emitHeritageClause(ts.getInterfaceBaseTypeNodes(node), false); + write(" {"); + writeLine(); + increaseIndent(); + emitLines(node.members); + decreaseIndent(); + write("}"); + writeLine(); + enclosingDeclaration = prevEnclosingDeclaration; + } + function emitPropertyDeclaration(node) { + if (ts.hasDynamicName(node)) { + return; + } + emitJsDocComments(node); + emitClassMemberDeclarationFlags(node); + emitVariableDeclaration(node); + write(";"); + writeLine(); + } + function emitVariableDeclaration(node) { + if (node.kind !== 211 || resolver.isDeclarationVisible(node)) { + if (ts.isBindingPattern(node.name)) { + emitBindingPattern(node.name); + } + else { + writeTextOfNode(currentSourceFile, node.name); + if ((node.kind === 141 || node.kind === 140) && ts.hasQuestionToken(node)) { + write("?"); + } + if ((node.kind === 141 || node.kind === 140) && node.parent.kind === 155) { + emitTypeOfVariableDeclarationFromTypeLiteral(node); + } + else if (!(node.flags & 32)) { + writeTypeOfDeclaration(node, node.type, getVariableDeclarationTypeVisibilityError); + } + } + } + function getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccesibilityResult) { + if (node.kind === 211) { + return symbolAccesibilityResult.errorModuleName ? + symbolAccesibilityResult.accessibility === 2 ? + ts.Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : + ts.Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_private_module_2 : + ts.Diagnostics.Exported_variable_0_has_or_is_using_private_name_1; + } + else if (node.kind === 141 || node.kind === 140) { + if (node.flags & 128) { + return symbolAccesibilityResult.errorModuleName ? + symbolAccesibilityResult.accessibility === 2 ? + ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : + ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : + ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_private_name_1; + } + else if (node.parent.kind === 214) { + return symbolAccesibilityResult.errorModuleName ? + symbolAccesibilityResult.accessibility === 2 ? + ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : + ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : + ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_private_name_1; + } + else { + return symbolAccesibilityResult.errorModuleName ? + ts.Diagnostics.Property_0_of_exported_interface_has_or_is_using_name_1_from_private_module_2 : + ts.Diagnostics.Property_0_of_exported_interface_has_or_is_using_private_name_1; + } + } + } + function getVariableDeclarationTypeVisibilityError(symbolAccesibilityResult) { + var diagnosticMessage = getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccesibilityResult); + return diagnosticMessage !== undefined ? { + diagnosticMessage: diagnosticMessage, + errorNode: node, + typeName: node.name + } : undefined; + } + function emitBindingPattern(bindingPattern) { + var elements = []; + for (var _i = 0, _a = bindingPattern.elements; _i < _a.length; _i++) { + var element = _a[_i]; + if (element.kind !== 187) { + elements.push(element); + } + } + emitCommaList(elements, emitBindingElement); + } + function emitBindingElement(bindingElement) { + function getBindingElementTypeVisibilityError(symbolAccesibilityResult) { + var diagnosticMessage = getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccesibilityResult); + return diagnosticMessage !== undefined ? { + diagnosticMessage: diagnosticMessage, + errorNode: bindingElement, + typeName: bindingElement.name + } : undefined; + } + if (bindingElement.name) { + if (ts.isBindingPattern(bindingElement.name)) { + emitBindingPattern(bindingElement.name); + } + else { + writeTextOfNode(currentSourceFile, bindingElement.name); + writeTypeOfDeclaration(bindingElement, undefined, getBindingElementTypeVisibilityError); + } + } + } + } + function emitTypeOfVariableDeclarationFromTypeLiteral(node) { + if (node.type) { + write(": "); + emitType(node.type); + } + } + function isVariableStatementVisible(node) { + return ts.forEach(node.declarationList.declarations, function (varDeclaration) { return resolver.isDeclarationVisible(varDeclaration); }); + } + function writeVariableStatement(node) { + emitJsDocComments(node); + emitModuleElementDeclarationFlags(node); + if (ts.isLet(node.declarationList)) { + write("let "); + } + else if (ts.isConst(node.declarationList)) { + write("const "); + } + else { + write("var "); + } + emitCommaList(node.declarationList.declarations, emitVariableDeclaration, resolver.isDeclarationVisible); + write(";"); + writeLine(); + } + function emitAccessorDeclaration(node) { + if (ts.hasDynamicName(node)) { + return; + } + var accessors = ts.getAllAccessorDeclarations(node.parent.members, node); + var accessorWithTypeAnnotation; + if (node === accessors.firstAccessor) { + emitJsDocComments(accessors.getAccessor); + emitJsDocComments(accessors.setAccessor); + emitClassMemberDeclarationFlags(node); + writeTextOfNode(currentSourceFile, node.name); + if (!(node.flags & 32)) { + accessorWithTypeAnnotation = node; + var type = getTypeAnnotationFromAccessor(node); + if (!type) { + var anotherAccessor = node.kind === 145 ? accessors.setAccessor : accessors.getAccessor; + type = getTypeAnnotationFromAccessor(anotherAccessor); + if (type) { + accessorWithTypeAnnotation = anotherAccessor; + } + } + writeTypeOfDeclaration(node, type, getAccessorDeclarationTypeVisibilityError); + } + write(";"); + writeLine(); + } + function getTypeAnnotationFromAccessor(accessor) { + if (accessor) { + return accessor.kind === 145 + ? accessor.type + : accessor.parameters.length > 0 + ? accessor.parameters[0].type + : undefined; + } + } + function getAccessorDeclarationTypeVisibilityError(symbolAccesibilityResult) { + var diagnosticMessage; + if (accessorWithTypeAnnotation.kind === 146) { + if (accessorWithTypeAnnotation.parent.flags & 128) { + diagnosticMessage = symbolAccesibilityResult.errorModuleName ? + ts.Diagnostics.Parameter_0_of_public_static_property_setter_from_exported_class_has_or_is_using_name_1_from_private_module_2 : + ts.Diagnostics.Parameter_0_of_public_static_property_setter_from_exported_class_has_or_is_using_private_name_1; + } + else { + diagnosticMessage = symbolAccesibilityResult.errorModuleName ? + ts.Diagnostics.Parameter_0_of_public_property_setter_from_exported_class_has_or_is_using_name_1_from_private_module_2 : + ts.Diagnostics.Parameter_0_of_public_property_setter_from_exported_class_has_or_is_using_private_name_1; + } + return { + diagnosticMessage: diagnosticMessage, + errorNode: accessorWithTypeAnnotation.parameters[0], + typeName: accessorWithTypeAnnotation.name + }; + } + else { + if (accessorWithTypeAnnotation.flags & 128) { + diagnosticMessage = symbolAccesibilityResult.errorModuleName ? + symbolAccesibilityResult.accessibility === 2 ? + ts.Diagnostics.Return_type_of_public_static_property_getter_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : + ts.Diagnostics.Return_type_of_public_static_property_getter_from_exported_class_has_or_is_using_name_0_from_private_module_1 : + ts.Diagnostics.Return_type_of_public_static_property_getter_from_exported_class_has_or_is_using_private_name_0; + } + else { + diagnosticMessage = symbolAccesibilityResult.errorModuleName ? + symbolAccesibilityResult.accessibility === 2 ? + ts.Diagnostics.Return_type_of_public_property_getter_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : + ts.Diagnostics.Return_type_of_public_property_getter_from_exported_class_has_or_is_using_name_0_from_private_module_1 : + ts.Diagnostics.Return_type_of_public_property_getter_from_exported_class_has_or_is_using_private_name_0; + } + return { + diagnosticMessage: diagnosticMessage, + errorNode: accessorWithTypeAnnotation.name, + typeName: undefined + }; + } + } + } + function writeFunctionDeclaration(node) { + if (ts.hasDynamicName(node)) { + return; + } + if (!resolver.isImplementationOfOverload(node)) { + emitJsDocComments(node); + if (node.kind === 213) { + emitModuleElementDeclarationFlags(node); + } + else if (node.kind === 143) { + emitClassMemberDeclarationFlags(node); + } + if (node.kind === 213) { + write("function "); + writeTextOfNode(currentSourceFile, node.name); + } + else if (node.kind === 144) { + write("constructor"); + } + else { + writeTextOfNode(currentSourceFile, node.name); + if (ts.hasQuestionToken(node)) { + write("?"); + } + } + emitSignatureDeclaration(node); + } + } + function emitSignatureDeclarationWithJsDocComments(node) { + emitJsDocComments(node); + emitSignatureDeclaration(node); + } + function emitSignatureDeclaration(node) { + if (node.kind === 148 || node.kind === 153) { + write("new "); + } + emitTypeParameters(node.typeParameters); + if (node.kind === 149) { + write("["); + } + else { + write("("); + } + var prevEnclosingDeclaration = enclosingDeclaration; + enclosingDeclaration = node; + emitCommaList(node.parameters, emitParameterDeclaration); + if (node.kind === 149) { + write("]"); + } + else { + write(")"); + } + var isFunctionTypeOrConstructorType = node.kind === 152 || node.kind === 153; + if (isFunctionTypeOrConstructorType || node.parent.kind === 155) { + if (node.type) { + write(isFunctionTypeOrConstructorType ? " => " : ": "); + emitType(node.type); + } + } + else if (node.kind !== 144 && !(node.flags & 32)) { + writeReturnTypeAtSignature(node, getReturnTypeVisibilityError); + } + enclosingDeclaration = prevEnclosingDeclaration; + if (!isFunctionTypeOrConstructorType) { + write(";"); + writeLine(); + } + function getReturnTypeVisibilityError(symbolAccesibilityResult) { + var diagnosticMessage; + switch (node.kind) { + case 148: + diagnosticMessage = symbolAccesibilityResult.errorModuleName ? + ts.Diagnostics.Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : + ts.Diagnostics.Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_0; + break; + case 147: + diagnosticMessage = symbolAccesibilityResult.errorModuleName ? + ts.Diagnostics.Return_type_of_call_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : + ts.Diagnostics.Return_type_of_call_signature_from_exported_interface_has_or_is_using_private_name_0; + break; + case 149: + diagnosticMessage = symbolAccesibilityResult.errorModuleName ? + ts.Diagnostics.Return_type_of_index_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : + ts.Diagnostics.Return_type_of_index_signature_from_exported_interface_has_or_is_using_private_name_0; + break; + case 143: + case 142: + if (node.flags & 128) { + diagnosticMessage = symbolAccesibilityResult.errorModuleName ? + symbolAccesibilityResult.accessibility === 2 ? + ts.Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : + 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 === 214) { + diagnosticMessage = symbolAccesibilityResult.errorModuleName ? + symbolAccesibilityResult.accessibility === 2 ? + ts.Diagnostics.Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : + ts.Diagnostics.Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_private_module_1 : + ts.Diagnostics.Return_type_of_public_method_from_exported_class_has_or_is_using_private_name_0; + } + else { + diagnosticMessage = symbolAccesibilityResult.errorModuleName ? + ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : + ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0; + } + break; + case 213: + diagnosticMessage = symbolAccesibilityResult.errorModuleName ? + symbolAccesibilityResult.accessibility === 2 ? + ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : + ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_name_0_from_private_module_1 : + ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_private_name_0; + break; + default: + ts.Debug.fail("This is unknown kind for signature: " + node.kind); + } + return { + diagnosticMessage: diagnosticMessage, + errorNode: node.name || node + }; + } + } + function emitParameterDeclaration(node) { + increaseIndent(); + emitJsDocComments(node); + if (node.dotDotDotToken) { + write("..."); + } + if (ts.isBindingPattern(node.name)) { + emitBindingPattern(node.name); + } + else { + writeTextOfNode(currentSourceFile, node.name); + } + if (resolver.isOptionalParameter(node)) { + write("?"); + } + decreaseIndent(); + if (node.parent.kind === 152 || + node.parent.kind === 153 || + node.parent.parent.kind === 155) { + emitTypeOfVariableDeclarationFromTypeLiteral(node); + } + else if (!(node.parent.flags & 32)) { + writeTypeOfDeclaration(node, node.type, getParameterDeclarationTypeVisibilityError); + } + function getParameterDeclarationTypeVisibilityError(symbolAccesibilityResult) { + var diagnosticMessage = getParameterDeclarationTypeVisibilityDiagnosticMessage(symbolAccesibilityResult); + return diagnosticMessage !== undefined ? { + diagnosticMessage: diagnosticMessage, + errorNode: node, + typeName: node.name + } : undefined; + } + function getParameterDeclarationTypeVisibilityDiagnosticMessage(symbolAccesibilityResult) { + switch (node.parent.kind) { + case 144: + return symbolAccesibilityResult.errorModuleName ? + symbolAccesibilityResult.accessibility === 2 ? + ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : + ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_private_module_2 : + ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_private_name_1; + case 148: + return symbolAccesibilityResult.errorModuleName ? + ts.Diagnostics.Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : + ts.Diagnostics.Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; + case 147: + return symbolAccesibilityResult.errorModuleName ? + ts.Diagnostics.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : + ts.Diagnostics.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; + case 143: + case 142: + if (node.parent.flags & 128) { + return symbolAccesibilityResult.errorModuleName ? + symbolAccesibilityResult.accessibility === 2 ? + ts.Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : + 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 === 214) { + return symbolAccesibilityResult.errorModuleName ? + symbolAccesibilityResult.accessibility === 2 ? + ts.Diagnostics.Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : + ts.Diagnostics.Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_private_module_2 : + ts.Diagnostics.Parameter_0_of_public_method_from_exported_class_has_or_is_using_private_name_1; + } + else { + return symbolAccesibilityResult.errorModuleName ? + 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 213: + return symbolAccesibilityResult.errorModuleName ? + symbolAccesibilityResult.accessibility === 2 ? + ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : + ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_name_1_from_private_module_2 : + ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_private_name_1; + default: + ts.Debug.fail("This is unknown parent for parameter: " + node.parent.kind); + } + } + function emitBindingPattern(bindingPattern) { + if (bindingPattern.kind === 161) { + write("{"); + emitCommaList(bindingPattern.elements, emitBindingElement); + write("}"); + } + else if (bindingPattern.kind === 162) { + write("["); + var elements = bindingPattern.elements; + emitCommaList(elements, emitBindingElement); + if (elements && elements.hasTrailingComma) { + write(", "); + } + write("]"); + } + } + function emitBindingElement(bindingElement) { + function getBindingElementTypeVisibilityError(symbolAccesibilityResult) { + var diagnosticMessage = getParameterDeclarationTypeVisibilityDiagnosticMessage(symbolAccesibilityResult); + return diagnosticMessage !== undefined ? { + diagnosticMessage: diagnosticMessage, + errorNode: bindingElement, + typeName: bindingElement.name + } : undefined; + } + if (bindingElement.kind === 187) { + write(" "); + } + else if (bindingElement.kind === 163) { + if (bindingElement.propertyName) { + writeTextOfNode(currentSourceFile, bindingElement.propertyName); + write(": "); + } + if (bindingElement.name) { + if (ts.isBindingPattern(bindingElement.name)) { + emitBindingPattern(bindingElement.name); + } + else { + ts.Debug.assert(bindingElement.name.kind === 69); + if (bindingElement.dotDotDotToken) { + write("..."); + } + writeTextOfNode(currentSourceFile, bindingElement.name); + } + } + } + } + } + function emitNode(node) { + switch (node.kind) { + case 213: + case 218: + case 221: + case 215: + case 214: + case 216: + case 217: + return emitModuleElement(node, isModuleElementVisible(node)); + case 193: + return emitModuleElement(node, isVariableStatementVisible(node)); + case 222: + return emitModuleElement(node, !node.importClause); + case 228: + return emitExportDeclaration(node); + case 144: + case 143: + case 142: + return writeFunctionDeclaration(node); + case 148: + case 147: + case 149: + return emitSignatureDeclarationWithJsDocComments(node); + case 145: + case 146: + return emitAccessorDeclaration(node); + case 141: + case 140: + return emitPropertyDeclaration(node); + case 247: + return emitEnumMemberDeclaration(node); + case 227: + return emitExportAssignment(node); + case 248: + return emitSourceFile(node); + } + } + function writeReferencePath(referencedFile) { + var declFileName = referencedFile.flags & 8192 + ? referencedFile.fileName + : ts.shouldEmitToOwnFile(referencedFile, compilerOptions) + ? ts.getOwnEmitOutputFilePath(referencedFile, host, ".d.ts") + : ts.removeFileExtension(compilerOptions.outFile || compilerOptions.out) + ".d.ts"; + declFileName = ts.getRelativePathToDirectoryOrUrl(ts.getDirectoryPath(ts.normalizeSlashes(jsFilePath)), declFileName, host.getCurrentDirectory(), host.getCanonicalFileName, false); + referencePathsOutput += "/// " + newLine; + } + } + function writeDeclarationFile(jsFilePath, sourceFile, host, resolver, diagnostics) { + var emitDeclarationResult = emitDeclarations(host, resolver, diagnostics, jsFilePath, sourceFile); + if (!emitDeclarationResult.reportedDeclarationError) { + var declarationOutput = emitDeclarationResult.referencePathsOutput + + getDeclarationOutput(emitDeclarationResult.synchronousDeclarationOutput, emitDeclarationResult.moduleElementDeclarationEmitInfo); + ts.writeFile(host, diagnostics, ts.removeFileExtension(jsFilePath) + ".d.ts", declarationOutput, host.getCompilerOptions().emitBOM); + } + function getDeclarationOutput(synchronousDeclarationOutput, moduleElementDeclarationEmitInfo) { + var appliedSyncOutputPos = 0; + var declarationOutput = ""; + ts.forEach(moduleElementDeclarationEmitInfo, function (aliasEmitInfo) { + if (aliasEmitInfo.asynchronousOutput) { + declarationOutput += synchronousDeclarationOutput.substring(appliedSyncOutputPos, aliasEmitInfo.outputPos); + declarationOutput += getDeclarationOutput(aliasEmitInfo.asynchronousOutput, aliasEmitInfo.subModuleElementDeclarationEmitInfo); + appliedSyncOutputPos = aliasEmitInfo.outputPos; + } + }); + declarationOutput += synchronousDeclarationOutput.substring(appliedSyncOutputPos); + return declarationOutput; + } + } + ts.writeDeclarationFile = writeDeclarationFile; +})(ts || (ts = {})); +var ts; +(function (ts) { + function isExternalModuleOrDeclarationFile(sourceFile) { + return ts.isExternalModule(sourceFile) || ts.isDeclarationFile(sourceFile); + } + ts.isExternalModuleOrDeclarationFile = isExternalModuleOrDeclarationFile; + var entities = { + "quot": 0x0022, + "amp": 0x0026, + "apos": 0x0027, + "lt": 0x003C, + "gt": 0x003E, + "nbsp": 0x00A0, + "iexcl": 0x00A1, + "cent": 0x00A2, + "pound": 0x00A3, + "curren": 0x00A4, + "yen": 0x00A5, + "brvbar": 0x00A6, + "sect": 0x00A7, + "uml": 0x00A8, + "copy": 0x00A9, + "ordf": 0x00AA, + "laquo": 0x00AB, + "not": 0x00AC, + "shy": 0x00AD, + "reg": 0x00AE, + "macr": 0x00AF, + "deg": 0x00B0, + "plusmn": 0x00B1, + "sup2": 0x00B2, + "sup3": 0x00B3, + "acute": 0x00B4, + "micro": 0x00B5, + "para": 0x00B6, + "middot": 0x00B7, + "cedil": 0x00B8, + "sup1": 0x00B9, + "ordm": 0x00BA, + "raquo": 0x00BB, + "frac14": 0x00BC, + "frac12": 0x00BD, + "frac34": 0x00BE, + "iquest": 0x00BF, + "Agrave": 0x00C0, + "Aacute": 0x00C1, + "Acirc": 0x00C2, + "Atilde": 0x00C3, + "Auml": 0x00C4, + "Aring": 0x00C5, + "AElig": 0x00C6, + "Ccedil": 0x00C7, + "Egrave": 0x00C8, + "Eacute": 0x00C9, + "Ecirc": 0x00CA, + "Euml": 0x00CB, + "Igrave": 0x00CC, + "Iacute": 0x00CD, + "Icirc": 0x00CE, + "Iuml": 0x00CF, + "ETH": 0x00D0, + "Ntilde": 0x00D1, + "Ograve": 0x00D2, + "Oacute": 0x00D3, + "Ocirc": 0x00D4, + "Otilde": 0x00D5, + "Ouml": 0x00D6, + "times": 0x00D7, + "Oslash": 0x00D8, + "Ugrave": 0x00D9, + "Uacute": 0x00DA, + "Ucirc": 0x00DB, + "Uuml": 0x00DC, + "Yacute": 0x00DD, + "THORN": 0x00DE, + "szlig": 0x00DF, + "agrave": 0x00E0, + "aacute": 0x00E1, + "acirc": 0x00E2, + "atilde": 0x00E3, + "auml": 0x00E4, + "aring": 0x00E5, + "aelig": 0x00E6, + "ccedil": 0x00E7, + "egrave": 0x00E8, + "eacute": 0x00E9, + "ecirc": 0x00EA, + "euml": 0x00EB, + "igrave": 0x00EC, + "iacute": 0x00ED, + "icirc": 0x00EE, + "iuml": 0x00EF, + "eth": 0x00F0, + "ntilde": 0x00F1, + "ograve": 0x00F2, + "oacute": 0x00F3, + "ocirc": 0x00F4, + "otilde": 0x00F5, + "ouml": 0x00F6, + "divide": 0x00F7, + "oslash": 0x00F8, + "ugrave": 0x00F9, + "uacute": 0x00FA, + "ucirc": 0x00FB, + "uuml": 0x00FC, + "yacute": 0x00FD, + "thorn": 0x00FE, + "yuml": 0x00FF, + "OElig": 0x0152, + "oelig": 0x0153, + "Scaron": 0x0160, + "scaron": 0x0161, + "Yuml": 0x0178, + "fnof": 0x0192, + "circ": 0x02C6, + "tilde": 0x02DC, + "Alpha": 0x0391, + "Beta": 0x0392, + "Gamma": 0x0393, + "Delta": 0x0394, + "Epsilon": 0x0395, + "Zeta": 0x0396, + "Eta": 0x0397, + "Theta": 0x0398, + "Iota": 0x0399, + "Kappa": 0x039A, + "Lambda": 0x039B, + "Mu": 0x039C, + "Nu": 0x039D, + "Xi": 0x039E, + "Omicron": 0x039F, + "Pi": 0x03A0, + "Rho": 0x03A1, + "Sigma": 0x03A3, + "Tau": 0x03A4, + "Upsilon": 0x03A5, + "Phi": 0x03A6, + "Chi": 0x03A7, + "Psi": 0x03A8, + "Omega": 0x03A9, + "alpha": 0x03B1, + "beta": 0x03B2, + "gamma": 0x03B3, + "delta": 0x03B4, + "epsilon": 0x03B5, + "zeta": 0x03B6, + "eta": 0x03B7, + "theta": 0x03B8, + "iota": 0x03B9, + "kappa": 0x03BA, + "lambda": 0x03BB, + "mu": 0x03BC, + "nu": 0x03BD, + "xi": 0x03BE, + "omicron": 0x03BF, + "pi": 0x03C0, + "rho": 0x03C1, + "sigmaf": 0x03C2, + "sigma": 0x03C3, + "tau": 0x03C4, + "upsilon": 0x03C5, + "phi": 0x03C6, + "chi": 0x03C7, + "psi": 0x03C8, + "omega": 0x03C9, + "thetasym": 0x03D1, + "upsih": 0x03D2, + "piv": 0x03D6, + "ensp": 0x2002, + "emsp": 0x2003, + "thinsp": 0x2009, + "zwnj": 0x200C, + "zwj": 0x200D, + "lrm": 0x200E, + "rlm": 0x200F, + "ndash": 0x2013, + "mdash": 0x2014, + "lsquo": 0x2018, + "rsquo": 0x2019, + "sbquo": 0x201A, + "ldquo": 0x201C, + "rdquo": 0x201D, + "bdquo": 0x201E, + "dagger": 0x2020, + "Dagger": 0x2021, + "bull": 0x2022, + "hellip": 0x2026, + "permil": 0x2030, + "prime": 0x2032, + "Prime": 0x2033, + "lsaquo": 0x2039, + "rsaquo": 0x203A, + "oline": 0x203E, + "frasl": 0x2044, + "euro": 0x20AC, + "image": 0x2111, + "weierp": 0x2118, + "real": 0x211C, + "trade": 0x2122, + "alefsym": 0x2135, + "larr": 0x2190, + "uarr": 0x2191, + "rarr": 0x2192, + "darr": 0x2193, + "harr": 0x2194, + "crarr": 0x21B5, + "lArr": 0x21D0, + "uArr": 0x21D1, + "rArr": 0x21D2, + "dArr": 0x21D3, + "hArr": 0x21D4, + "forall": 0x2200, + "part": 0x2202, + "exist": 0x2203, + "empty": 0x2205, + "nabla": 0x2207, + "isin": 0x2208, + "notin": 0x2209, + "ni": 0x220B, + "prod": 0x220F, + "sum": 0x2211, + "minus": 0x2212, + "lowast": 0x2217, + "radic": 0x221A, + "prop": 0x221D, + "infin": 0x221E, + "ang": 0x2220, + "and": 0x2227, + "or": 0x2228, + "cap": 0x2229, + "cup": 0x222A, + "int": 0x222B, + "there4": 0x2234, + "sim": 0x223C, + "cong": 0x2245, + "asymp": 0x2248, + "ne": 0x2260, + "equiv": 0x2261, + "le": 0x2264, + "ge": 0x2265, + "sub": 0x2282, + "sup": 0x2283, + "nsub": 0x2284, + "sube": 0x2286, + "supe": 0x2287, + "oplus": 0x2295, + "otimes": 0x2297, + "perp": 0x22A5, + "sdot": 0x22C5, + "lceil": 0x2308, + "rceil": 0x2309, + "lfloor": 0x230A, + "rfloor": 0x230B, + "lang": 0x2329, + "rang": 0x232A, + "loz": 0x25CA, + "spades": 0x2660, + "clubs": 0x2663, + "hearts": 0x2665, + "diams": 0x2666 + }; + function emitFiles(resolver, host, targetSourceFile) { + var extendsHelper = "\nvar __extends = (this && this.__extends) || function (d, b) {\n for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];\n function __() { this.constructor = d; }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n};"; + var decorateHelper = "\nvar __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\n return c > 3 && r && Object.defineProperty(target, key, r), r;\n};"; + var metadataHelper = "\nvar __metadata = (this && this.__metadata) || function (k, v) {\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(k, v);\n};"; + var paramHelper = "\nvar __param = (this && this.__param) || function (paramIndex, decorator) {\n return function (target, key) { decorator(target, key, paramIndex); }\n};"; + var awaiterHelper = "\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promise, generator) {\n return new Promise(function (resolve, reject) {\n generator = generator.call(thisArg, _arguments);\n function cast(value) { return value instanceof Promise && value.constructor === Promise ? value : new Promise(function (resolve) { resolve(value); }); }\n function onfulfill(value) { try { step(\"next\", value); } catch (e) { reject(e); } }\n function onreject(value) { try { step(\"throw\", value); } catch (e) { reject(e); } }\n function step(verb, value) {\n var result = generator[verb](value);\n result.done ? resolve(result.value) : cast(result.value).then(onfulfill, onreject);\n }\n step(\"next\", void 0);\n });\n};"; + var compilerOptions = host.getCompilerOptions(); + var languageVersion = compilerOptions.target || 0; + var modulekind = compilerOptions.module ? compilerOptions.module : languageVersion === 2 ? 5 : 0; + var sourceMapDataList = compilerOptions.sourceMap || compilerOptions.inlineSourceMap ? [] : undefined; + var diagnostics = []; + var newLine = host.getNewLine(); + var jsxDesugaring = host.getCompilerOptions().jsx !== 1; + var shouldEmitJsx = function (s) { return (s.languageVariant === 1 && !jsxDesugaring); }; + if (targetSourceFile === undefined) { + ts.forEach(host.getSourceFiles(), function (sourceFile) { + if (ts.shouldEmitToOwnFile(sourceFile, compilerOptions)) { + var jsFilePath = ts.getOwnEmitOutputFilePath(sourceFile, host, shouldEmitJsx(sourceFile) ? ".jsx" : ".js"); + emitFile(jsFilePath, sourceFile); + } + }); + if (compilerOptions.outFile || compilerOptions.out) { + emitFile(compilerOptions.outFile || compilerOptions.out); + } + } + else { + if (ts.shouldEmitToOwnFile(targetSourceFile, compilerOptions)) { + var jsFilePath = ts.getOwnEmitOutputFilePath(targetSourceFile, host, shouldEmitJsx(targetSourceFile) ? ".jsx" : ".js"); + emitFile(jsFilePath, targetSourceFile); + } + else if (!ts.isDeclarationFile(targetSourceFile) && (compilerOptions.outFile || compilerOptions.out)) { + emitFile(compilerOptions.outFile || compilerOptions.out); + } + } + diagnostics = ts.sortAndDeduplicateDiagnostics(diagnostics); + return { + emitSkipped: false, + diagnostics: diagnostics, + sourceMaps: sourceMapDataList + }; + function isNodeDescendentOf(node, ancestor) { + while (node) { + if (node === ancestor) + return true; + node = node.parent; + } + return false; + } + function isUniqueLocalName(name, container) { + for (var node = container; isNodeDescendentOf(node, container); node = node.nextContainer) { + if (node.locals && ts.hasProperty(node.locals, name)) { + if (node.locals[name].flags & (107455 | 1048576 | 8388608)) { + return false; + } + } + } + return true; + } + function setLabeledJump(state, isBreak, labelText, labelMarker) { + if (isBreak) { + if (!state.labeledNonLocalBreaks) { + state.labeledNonLocalBreaks = {}; + } + state.labeledNonLocalBreaks[labelText] = labelMarker; + } + else { + if (!state.labeledNonLocalContinues) { + state.labeledNonLocalContinues = {}; + } + state.labeledNonLocalContinues[labelText] = labelMarker; + } + } + function hoistVariableDeclarationFromLoop(state, declaration) { + if (!state.hoistedLocalVariables) { + state.hoistedLocalVariables = []; + } + visit(declaration.name); + function visit(node) { + if (node.kind === 69) { + state.hoistedLocalVariables.push(node); + } + else { + for (var _a = 0, _b = node.elements; _a < _b.length; _a++) { + var element = _b[_a]; + visit(element.name); + } + } + } + } + function emitJavaScript(jsFilePath, root) { + var writer = ts.createTextWriter(newLine); + var write = writer.write, writeTextOfNode = writer.writeTextOfNode, writeLine = writer.writeLine, increaseIndent = writer.increaseIndent, decreaseIndent = writer.decreaseIndent; + var currentSourceFile; + var exportFunctionForFile; + var generatedNameSet = {}; + var nodeToGeneratedName = []; + var computedPropertyNamesToGeneratedNames; + var convertedLoopState; + var extendsEmitted = false; + var decorateEmitted = false; + var paramEmitted = false; + var awaiterEmitted = false; + var tempFlags = 0; + var tempVariables; + var tempParameters; + var externalImports; + var exportSpecifiers; + var exportEquals; + var hasExportStars; + var writeEmittedFiles = writeJavaScriptFile; + var detachedCommentsInfo; + var writeComment = ts.writeCommentRange; + var emit = emitNodeWithCommentsAndWithoutSourcemap; + var emitStart = function (node) { }; + var emitEnd = function (node) { }; + var emitToken = emitTokenText; + var scopeEmitStart = function (scopeDeclaration, scopeName) { }; + var scopeEmitEnd = function () { }; + var sourceMapData; + var emitLeadingCommentsOfPosition = compilerOptions.removeComments ? function (pos) { } : emitLeadingCommentsOfPositionWorker; + var moduleEmitDelegates = (_a = {}, + _a[5] = emitES6Module, + _a[2] = emitAMDModule, + _a[4] = emitSystemModule, + _a[3] = emitUMDModule, + _a[1] = emitCommonJSModule, + _a + ); + if (compilerOptions.sourceMap || compilerOptions.inlineSourceMap) { + initializeEmitterWithSourceMaps(); + } + if (root) { + emitSourceFile(root); + } + else { + ts.forEach(host.getSourceFiles(), function (sourceFile) { + if (!isExternalModuleOrDeclarationFile(sourceFile)) { + emitSourceFile(sourceFile); + } + }); + } + writeLine(); + writeEmittedFiles(writer.getText(), compilerOptions.emitBOM); + return; + function emitSourceFile(sourceFile) { + currentSourceFile = sourceFile; + exportFunctionForFile = undefined; + emit(sourceFile); + } + function isUniqueName(name) { + return !resolver.hasGlobalName(name) && + !ts.hasProperty(currentSourceFile.identifiers, name) && + !ts.hasProperty(generatedNameSet, name); + } + function makeTempVariableName(flags) { + if (flags && !(tempFlags & flags)) { + var name_20 = flags === 268435456 ? "_i" : "_n"; + if (isUniqueName(name_20)) { + tempFlags |= flags; + return name_20; + } + } + while (true) { + var count = tempFlags & 268435455; + tempFlags++; + if (count !== 8 && count !== 13) { + var name_21 = count < 26 ? "_" + String.fromCharCode(97 + count) : "_" + (count - 26); + if (isUniqueName(name_21)) { + return name_21; + } + } + } + } + function makeUniqueName(baseName) { + if (baseName.charCodeAt(baseName.length - 1) !== 95) { + baseName += "_"; + } + var i = 1; + while (true) { + var generatedName = baseName + i; + if (isUniqueName(generatedName)) { + return generatedNameSet[generatedName] = generatedName; + } + i++; + } + } + function generateNameForModuleOrEnum(node) { + var name = node.name.text; + return isUniqueLocalName(name, node) ? name : makeUniqueName(name); + } + function generateNameForImportOrExportDeclaration(node) { + var expr = ts.getExternalModuleName(node); + var baseName = expr.kind === 9 ? + ts.escapeIdentifier(ts.makeIdentifierFromModuleName(expr.text)) : "module"; + return makeUniqueName(baseName); + } + function generateNameForExportDefault() { + return makeUniqueName("default"); + } + function generateNameForClassExpression() { + return makeUniqueName("class"); + } + function generateNameForNode(node) { + switch (node.kind) { + case 69: + return makeUniqueName(node.text); + case 218: + case 217: + return generateNameForModuleOrEnum(node); + case 222: + case 228: + return generateNameForImportOrExportDeclaration(node); + case 213: + case 214: + case 227: + return generateNameForExportDefault(); + case 186: + return generateNameForClassExpression(); + } + } + function getGeneratedNameForNode(node) { + var id = ts.getNodeId(node); + return nodeToGeneratedName[id] || (nodeToGeneratedName[id] = ts.unescapeIdentifier(generateNameForNode(node))); + } + function initializeEmitterWithSourceMaps() { + var sourceMapDir; + var sourceMapSourceIndex = -1; + var sourceMapNameIndexMap = {}; + var sourceMapNameIndices = []; + function getSourceMapNameIndex() { + return sourceMapNameIndices.length ? ts.lastOrUndefined(sourceMapNameIndices) : -1; + } + var lastRecordedSourceMapSpan; + var lastEncodedSourceMapSpan = { + emittedLine: 1, + emittedColumn: 1, + sourceLine: 1, + sourceColumn: 1, + sourceIndex: 0 + }; + var lastEncodedNameIndex = 0; + function encodeLastRecordedSourceMapSpan() { + if (!lastRecordedSourceMapSpan || lastRecordedSourceMapSpan === lastEncodedSourceMapSpan) { + return; + } + var prevEncodedEmittedColumn = lastEncodedSourceMapSpan.emittedColumn; + if (lastEncodedSourceMapSpan.emittedLine === lastRecordedSourceMapSpan.emittedLine) { + if (sourceMapData.sourceMapMappings) { + sourceMapData.sourceMapMappings += ","; + } + } + else { + for (var encodedLine = lastEncodedSourceMapSpan.emittedLine; encodedLine < lastRecordedSourceMapSpan.emittedLine; encodedLine++) { + sourceMapData.sourceMapMappings += ";"; + } + prevEncodedEmittedColumn = 1; + } + sourceMapData.sourceMapMappings += base64VLQFormatEncode(lastRecordedSourceMapSpan.emittedColumn - prevEncodedEmittedColumn); + sourceMapData.sourceMapMappings += base64VLQFormatEncode(lastRecordedSourceMapSpan.sourceIndex - lastEncodedSourceMapSpan.sourceIndex); + sourceMapData.sourceMapMappings += base64VLQFormatEncode(lastRecordedSourceMapSpan.sourceLine - lastEncodedSourceMapSpan.sourceLine); + sourceMapData.sourceMapMappings += base64VLQFormatEncode(lastRecordedSourceMapSpan.sourceColumn - lastEncodedSourceMapSpan.sourceColumn); + if (lastRecordedSourceMapSpan.nameIndex >= 0) { + sourceMapData.sourceMapMappings += base64VLQFormatEncode(lastRecordedSourceMapSpan.nameIndex - lastEncodedNameIndex); + lastEncodedNameIndex = lastRecordedSourceMapSpan.nameIndex; + } + lastEncodedSourceMapSpan = lastRecordedSourceMapSpan; + sourceMapData.sourceMapDecodedMappings.push(lastEncodedSourceMapSpan); + function base64VLQFormatEncode(inValue) { + function base64FormatEncode(inValue) { + if (inValue < 64) { + return "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(inValue); + } + throw TypeError(inValue + ": not a 64 based value"); + } + if (inValue < 0) { + inValue = ((-inValue) << 1) + 1; + } + else { + inValue = inValue << 1; + } + var encodedStr = ""; + do { + var currentDigit = inValue & 31; + inValue = inValue >> 5; + if (inValue > 0) { + currentDigit = currentDigit | 32; + } + encodedStr = encodedStr + base64FormatEncode(currentDigit); + } while (inValue > 0); + return encodedStr; + } + } + function recordSourceMapSpan(pos) { + var sourceLinePos = ts.getLineAndCharacterOfPosition(currentSourceFile, pos); + sourceLinePos.line++; + sourceLinePos.character++; + var emittedLine = writer.getLine(); + var emittedColumn = writer.getColumn(); + if (!lastRecordedSourceMapSpan || + lastRecordedSourceMapSpan.emittedLine !== emittedLine || + lastRecordedSourceMapSpan.emittedColumn !== emittedColumn || + (lastRecordedSourceMapSpan.sourceIndex === sourceMapSourceIndex && + (lastRecordedSourceMapSpan.sourceLine > sourceLinePos.line || + (lastRecordedSourceMapSpan.sourceLine === sourceLinePos.line && lastRecordedSourceMapSpan.sourceColumn > sourceLinePos.character)))) { + encodeLastRecordedSourceMapSpan(); + lastRecordedSourceMapSpan = { + emittedLine: emittedLine, + emittedColumn: emittedColumn, + sourceLine: sourceLinePos.line, + sourceColumn: sourceLinePos.character, + nameIndex: getSourceMapNameIndex(), + sourceIndex: sourceMapSourceIndex + }; + } + else { + lastRecordedSourceMapSpan.sourceLine = sourceLinePos.line; + lastRecordedSourceMapSpan.sourceColumn = sourceLinePos.character; + lastRecordedSourceMapSpan.sourceIndex = sourceMapSourceIndex; + } + } + function recordEmitNodeStartSpan(node) { + recordSourceMapSpan(ts.skipTrivia(currentSourceFile.text, node.pos)); + } + function recordEmitNodeEndSpan(node) { + recordSourceMapSpan(node.end); + } + function writeTextWithSpanRecord(tokenKind, startPos, emitFn) { + var tokenStartPos = ts.skipTrivia(currentSourceFile.text, startPos); + recordSourceMapSpan(tokenStartPos); + var tokenEndPos = emitTokenText(tokenKind, tokenStartPos, emitFn); + recordSourceMapSpan(tokenEndPos); + return tokenEndPos; + } + function recordNewSourceFileStart(node) { + var sourcesDirectoryPath = compilerOptions.sourceRoot ? host.getCommonSourceDirectory() : sourceMapDir; + sourceMapData.sourceMapSources.push(ts.getRelativePathToDirectoryOrUrl(sourcesDirectoryPath, node.fileName, host.getCurrentDirectory(), host.getCanonicalFileName, true)); + sourceMapSourceIndex = sourceMapData.sourceMapSources.length - 1; + sourceMapData.inputSourceFileNames.push(node.fileName); + if (compilerOptions.inlineSources) { + if (!sourceMapData.sourceMapSourcesContent) { + sourceMapData.sourceMapSourcesContent = []; + } + sourceMapData.sourceMapSourcesContent.push(node.text); + } + } + function recordScopeNameOfNode(node, scopeName) { + function recordScopeNameIndex(scopeNameIndex) { + sourceMapNameIndices.push(scopeNameIndex); + } + function recordScopeNameStart(scopeName) { + var scopeNameIndex = -1; + if (scopeName) { + var parentIndex = getSourceMapNameIndex(); + if (parentIndex !== -1) { + var name_22 = node.name; + if (!name_22 || name_22.kind !== 136) { + scopeName = "." + scopeName; + } + scopeName = sourceMapData.sourceMapNames[parentIndex] + scopeName; + } + scopeNameIndex = ts.getProperty(sourceMapNameIndexMap, scopeName); + if (scopeNameIndex === undefined) { + scopeNameIndex = sourceMapData.sourceMapNames.length; + sourceMapData.sourceMapNames.push(scopeName); + sourceMapNameIndexMap[scopeName] = scopeNameIndex; + } + } + recordScopeNameIndex(scopeNameIndex); + } + if (scopeName) { + recordScopeNameStart(scopeName); + } + else if (node.kind === 213 || + node.kind === 173 || + node.kind === 143 || + node.kind === 142 || + node.kind === 145 || + node.kind === 146 || + node.kind === 218 || + node.kind === 214 || + node.kind === 217) { + if (node.name) { + var name_23 = node.name; + scopeName = name_23.kind === 136 + ? ts.getTextOfNode(name_23) + : node.name.text; + } + recordScopeNameStart(scopeName); + } + else { + recordScopeNameIndex(getSourceMapNameIndex()); + } + } + function recordScopeNameEnd() { + sourceMapNameIndices.pop(); + } + ; + function writeCommentRangeWithMap(curentSourceFile, writer, comment, newLine) { + recordSourceMapSpan(comment.pos); + ts.writeCommentRange(currentSourceFile, writer, comment, newLine); + recordSourceMapSpan(comment.end); + } + function serializeSourceMapContents(version, file, sourceRoot, sources, names, mappings, sourcesContent) { + if (typeof JSON !== "undefined") { + var map_2 = { + version: version, + file: file, + sourceRoot: sourceRoot, + sources: sources, + names: names, + mappings: mappings + }; + if (sourcesContent !== undefined) { + map_2.sourcesContent = sourcesContent; + } + return JSON.stringify(map_2); + } + return "{\"version\":" + version + ",\"file\":\"" + ts.escapeString(file) + "\",\"sourceRoot\":\"" + ts.escapeString(sourceRoot) + "\",\"sources\":[" + serializeStringArray(sources) + "],\"names\":[" + serializeStringArray(names) + "],\"mappings\":\"" + ts.escapeString(mappings) + "\" " + (sourcesContent !== undefined ? ",\"sourcesContent\":[" + serializeStringArray(sourcesContent) + "]" : "") + "}"; + function serializeStringArray(list) { + var output = ""; + for (var i = 0, n = list.length; i < n; i++) { + if (i) { + output += ","; + } + output += "\"" + ts.escapeString(list[i]) + "\""; + } + return output; + } + } + function writeJavaScriptAndSourceMapFile(emitOutput, writeByteOrderMark) { + encodeLastRecordedSourceMapSpan(); + var sourceMapText = serializeSourceMapContents(3, sourceMapData.sourceMapFile, sourceMapData.sourceMapSourceRoot, sourceMapData.sourceMapSources, sourceMapData.sourceMapNames, sourceMapData.sourceMapMappings, sourceMapData.sourceMapSourcesContent); + sourceMapDataList.push(sourceMapData); + var sourceMapUrl; + if (compilerOptions.inlineSourceMap) { + var base64SourceMapText = ts.convertToBase64(sourceMapText); + sourceMapUrl = "//# sourceMappingURL=data:application/json;base64," + base64SourceMapText; + } + else { + ts.writeFile(host, diagnostics, sourceMapData.sourceMapFilePath, sourceMapText, false); + sourceMapUrl = "//# sourceMappingURL=" + sourceMapData.jsSourceMappingURL; + } + writeJavaScriptFile(emitOutput + sourceMapUrl, writeByteOrderMark); + } + var sourceMapJsFile = ts.getBaseFileName(ts.normalizeSlashes(jsFilePath)); + sourceMapData = { + sourceMapFilePath: jsFilePath + ".map", + jsSourceMappingURL: sourceMapJsFile + ".map", + sourceMapFile: sourceMapJsFile, + sourceMapSourceRoot: compilerOptions.sourceRoot || "", + sourceMapSources: [], + inputSourceFileNames: [], + sourceMapNames: [], + sourceMapMappings: "", + sourceMapSourcesContent: undefined, + sourceMapDecodedMappings: [] + }; + sourceMapData.sourceMapSourceRoot = ts.normalizeSlashes(sourceMapData.sourceMapSourceRoot); + if (sourceMapData.sourceMapSourceRoot.length && sourceMapData.sourceMapSourceRoot.charCodeAt(sourceMapData.sourceMapSourceRoot.length - 1) !== 47) { + sourceMapData.sourceMapSourceRoot += ts.directorySeparator; + } + if (compilerOptions.mapRoot) { + sourceMapDir = ts.normalizeSlashes(compilerOptions.mapRoot); + if (root) { + sourceMapDir = ts.getDirectoryPath(ts.getSourceFilePathInNewDir(root, host, sourceMapDir)); + } + if (!ts.isRootedDiskPath(sourceMapDir) && !ts.isUrl(sourceMapDir)) { + sourceMapDir = ts.combinePaths(host.getCommonSourceDirectory(), sourceMapDir); + sourceMapData.jsSourceMappingURL = ts.getRelativePathToDirectoryOrUrl(ts.getDirectoryPath(ts.normalizePath(jsFilePath)), ts.combinePaths(sourceMapDir, sourceMapData.jsSourceMappingURL), host.getCurrentDirectory(), host.getCanonicalFileName, true); + } + else { + sourceMapData.jsSourceMappingURL = ts.combinePaths(sourceMapDir, sourceMapData.jsSourceMappingURL); + } + } + else { + sourceMapDir = ts.getDirectoryPath(ts.normalizePath(jsFilePath)); + } + function emitNodeWithSourceMap(node) { + if (node) { + if (ts.nodeIsSynthesized(node)) { + return emitNodeWithoutSourceMap(node); + } + if (node.kind !== 248) { + recordEmitNodeStartSpan(node); + emitNodeWithoutSourceMap(node); + recordEmitNodeEndSpan(node); + } + else { + recordNewSourceFileStart(node); + emitNodeWithoutSourceMap(node); + } + } + } + function emitNodeWithCommentsAndWithSourcemap(node) { + emitNodeConsideringCommentsOption(node, emitNodeWithSourceMap); + } + writeEmittedFiles = writeJavaScriptAndSourceMapFile; + emit = emitNodeWithCommentsAndWithSourcemap; + emitStart = recordEmitNodeStartSpan; + emitEnd = recordEmitNodeEndSpan; + emitToken = writeTextWithSpanRecord; + scopeEmitStart = recordScopeNameOfNode; + scopeEmitEnd = recordScopeNameEnd; + writeComment = writeCommentRangeWithMap; + } + function writeJavaScriptFile(emitOutput, writeByteOrderMark) { + ts.writeFile(host, diagnostics, jsFilePath, emitOutput, writeByteOrderMark); + } + function createTempVariable(flags) { + var result = ts.createSynthesizedNode(69); + result.text = makeTempVariableName(flags); + return result; + } + function recordTempDeclaration(name) { + if (!tempVariables) { + tempVariables = []; + } + tempVariables.push(name); + } + function createAndRecordTempVariable(flags) { + var temp = createTempVariable(flags); + recordTempDeclaration(temp); + return temp; + } + function emitTempDeclarations(newLine) { + if (tempVariables) { + if (newLine) { + writeLine(); + } + else { + write(" "); + } + write("var "); + emitCommaList(tempVariables); + write(";"); + } + } + function emitTokenText(tokenKind, startPos, emitFn) { + var tokenString = ts.tokenToString(tokenKind); + if (emitFn) { + emitFn(); + } + else { + write(tokenString); + } + return startPos + tokenString.length; + } + function emitOptional(prefix, node) { + if (node) { + write(prefix); + emit(node); + } + } + function emitParenthesizedIf(node, parenthesized) { + if (parenthesized) { + write("("); + } + emit(node); + if (parenthesized) { + write(")"); + } + } + function emitTrailingCommaIfPresent(nodeList) { + if (nodeList.hasTrailingComma) { + write(","); + } + } + function emitLinePreservingList(parent, nodes, allowTrailingComma, spacesBetweenBraces) { + ts.Debug.assert(nodes.length > 0); + increaseIndent(); + if (nodeStartPositionsAreOnSameLine(parent, nodes[0])) { + if (spacesBetweenBraces) { + write(" "); + } + } + else { + writeLine(); + } + for (var i = 0, n = nodes.length; i < n; i++) { + if (i) { + if (nodeEndIsOnSameLineAsNodeStart(nodes[i - 1], nodes[i])) { + write(", "); + } + else { + write(","); + writeLine(); + } + } + emit(nodes[i]); + } + if (nodes.hasTrailingComma && allowTrailingComma) { + write(","); + } + decreaseIndent(); + if (nodeEndPositionsAreOnSameLine(parent, ts.lastOrUndefined(nodes))) { + if (spacesBetweenBraces) { + write(" "); + } + } + else { + writeLine(); + } + } + function emitList(nodes, start, count, multiLine, trailingComma, leadingComma, noTrailingNewLine, emitNode) { + if (!emitNode) { + emitNode = emit; + } + for (var i = 0; i < count; i++) { + if (multiLine) { + if (i || leadingComma) { + write(","); + } + writeLine(); + } + else { + if (i || leadingComma) { + write(", "); + } + } + var node = nodes[start + i]; + emitTrailingCommentsOfPosition(node.pos); + emitNode(node); + leadingComma = true; + } + if (trailingComma) { + write(","); + } + if (multiLine && !noTrailingNewLine) { + writeLine(); + } + return count; + } + function emitCommaList(nodes) { + if (nodes) { + emitList(nodes, 0, nodes.length, false, false); + } + } + function emitLines(nodes) { + emitLinesStartingAt(nodes, 0); + } + function emitLinesStartingAt(nodes, startIndex) { + for (var i = startIndex; i < nodes.length; i++) { + writeLine(); + emit(nodes[i]); + } + } + function isBinaryOrOctalIntegerLiteral(node, text) { + if (node.kind === 8 && text.length > 1) { + switch (text.charCodeAt(1)) { + case 98: + case 66: + case 111: + case 79: + return true; + } + } + return false; + } + function emitLiteral(node) { + var text = getLiteralText(node); + if ((compilerOptions.sourceMap || compilerOptions.inlineSourceMap) && (node.kind === 9 || ts.isTemplateLiteralKind(node.kind))) { + writer.writeLiteral(text); + } + else if (languageVersion < 2 && isBinaryOrOctalIntegerLiteral(node, text)) { + write(node.text); + } + else { + write(text); + } + } + function getLiteralText(node) { + if (languageVersion < 2 && (ts.isTemplateLiteralKind(node.kind) || node.hasExtendedUnicodeEscape)) { + return getQuotedEscapedLiteralText("\"", node.text, "\""); + } + if (node.parent) { + return ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, node); + } + switch (node.kind) { + case 9: + return getQuotedEscapedLiteralText("\"", node.text, "\""); + case 11: + return getQuotedEscapedLiteralText("`", node.text, "`"); + case 12: + return getQuotedEscapedLiteralText("`", node.text, "${"); + case 13: + return getQuotedEscapedLiteralText("}", node.text, "${"); + case 14: + return getQuotedEscapedLiteralText("}", node.text, "`"); + case 8: + return node.text; + } + ts.Debug.fail("Literal kind '" + node.kind + "' not accounted for."); + } + function getQuotedEscapedLiteralText(leftQuote, text, rightQuote) { + return leftQuote + ts.escapeNonAsciiCharacters(ts.escapeString(text)) + rightQuote; + } + function emitDownlevelRawTemplateLiteral(node) { + var text = ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, node); + var isLast = node.kind === 11 || node.kind === 14; + text = text.substring(1, text.length - (isLast ? 1 : 2)); + text = text.replace(/\r\n?/g, "\n"); + text = ts.escapeString(text); + write("\"" + text + "\""); + } + function emitDownlevelTaggedTemplateArray(node, literalEmitter) { + write("["); + if (node.template.kind === 11) { + literalEmitter(node.template); + } + else { + literalEmitter(node.template.head); + ts.forEach(node.template.templateSpans, function (child) { + write(", "); + literalEmitter(child.literal); + }); + } + write("]"); + } + function emitDownlevelTaggedTemplate(node) { + var tempVariable = createAndRecordTempVariable(0); + write("("); + emit(tempVariable); + write(" = "); + emitDownlevelTaggedTemplateArray(node, emit); + write(", "); + emit(tempVariable); + write(".raw = "); + emitDownlevelTaggedTemplateArray(node, emitDownlevelRawTemplateLiteral); + write(", "); + emitParenthesizedIf(node.tag, needsParenthesisForPropertyAccessOrInvocation(node.tag)); + write("("); + emit(tempVariable); + if (node.template.kind === 183) { + ts.forEach(node.template.templateSpans, function (templateSpan) { + write(", "); + var needsParens = templateSpan.expression.kind === 181 + && templateSpan.expression.operatorToken.kind === 24; + emitParenthesizedIf(templateSpan.expression, needsParens); + }); + } + write("))"); + } + function emitTemplateExpression(node) { + if (languageVersion >= 2) { + ts.forEachChild(node, emit); + return; + } + var emitOuterParens = ts.isExpression(node.parent) + && templateNeedsParens(node, node.parent); + if (emitOuterParens) { + write("("); + } + var headEmitted = false; + if (shouldEmitTemplateHead()) { + emitLiteral(node.head); + headEmitted = true; + } + for (var i = 0, n = node.templateSpans.length; i < n; i++) { + var templateSpan = node.templateSpans[i]; + var needsParens = templateSpan.expression.kind !== 172 + && comparePrecedenceToBinaryPlus(templateSpan.expression) !== 1; + if (i > 0 || headEmitted) { + write(" + "); + } + emitParenthesizedIf(templateSpan.expression, needsParens); + if (templateSpan.literal.text.length !== 0) { + write(" + "); + emitLiteral(templateSpan.literal); + } + } + if (emitOuterParens) { + write(")"); + } + function shouldEmitTemplateHead() { + ts.Debug.assert(node.templateSpans.length !== 0); + return node.head.text.length !== 0 || node.templateSpans[0].literal.text.length === 0; + } + function templateNeedsParens(template, parent) { + switch (parent.kind) { + case 168: + case 169: + return parent.expression === template; + case 170: + case 172: + return false; + default: + return comparePrecedenceToBinaryPlus(parent) !== -1; + } + } + function comparePrecedenceToBinaryPlus(expression) { + switch (expression.kind) { + case 181: + switch (expression.operatorToken.kind) { + case 37: + case 39: + case 40: + return 1; + case 35: + case 36: + return 0; + default: + return -1; + } + case 184: + case 182: + return -1; + default: + return 1; + } + } + } + function emitTemplateSpan(span) { + emit(span.expression); + emit(span.literal); + } + function jsxEmitReact(node) { + function emitTagName(name) { + if (name.kind === 69 && ts.isIntrinsicJsxName(name.text)) { + write("\""); + emit(name); + write("\""); + } + else { + emit(name); + } + } + function emitAttributeName(name) { + if (/[A-Za-z_]+[\w*]/.test(name.text)) { + write("\""); + emit(name); + write("\""); + } + else { + emit(name); + } + } + function emitJsxAttribute(node) { + emitAttributeName(node.name); + write(": "); + if (node.initializer) { + emit(node.initializer); + } + else { + write("true"); + } + } + function emitJsxElement(openingNode, children) { + var syntheticReactRef = ts.createSynthesizedNode(69); + syntheticReactRef.text = "React"; + syntheticReactRef.parent = openingNode; + emitLeadingComments(openingNode); + emitExpressionIdentifier(syntheticReactRef); + write(".createElement("); + emitTagName(openingNode.tagName); + write(", "); + if (openingNode.attributes.length === 0) { + write("null"); + } + else { + var attrs = openingNode.attributes; + if (ts.forEach(attrs, function (attr) { return attr.kind === 239; })) { + emitExpressionIdentifier(syntheticReactRef); + write(".__spread("); + var haveOpenedObjectLiteral = false; + for (var i_1 = 0; i_1 < attrs.length; i_1++) { + if (attrs[i_1].kind === 239) { + if (i_1 === 0) { + write("{}, "); + } + if (haveOpenedObjectLiteral) { + write("}"); + haveOpenedObjectLiteral = false; + } + if (i_1 > 0) { + write(", "); + } + emit(attrs[i_1].expression); + } + else { + ts.Debug.assert(attrs[i_1].kind === 238); + if (haveOpenedObjectLiteral) { + write(", "); + } + else { + haveOpenedObjectLiteral = true; + if (i_1 > 0) { + write(", "); + } + write("{"); + } + emitJsxAttribute(attrs[i_1]); + } + } + if (haveOpenedObjectLiteral) + write("}"); + write(")"); + } + else { + write("{"); + for (var i = 0; i < attrs.length; i++) { + if (i > 0) { + write(", "); + } + emitJsxAttribute(attrs[i]); + } + write("}"); + } + } + if (children) { + for (var i = 0; i < children.length; i++) { + if (children[i].kind === 240 && !(children[i].expression)) { + continue; + } + if (children[i].kind === 236) { + var text = getTextToEmit(children[i]); + if (text !== undefined) { + write(", \""); + write(text); + write("\""); + } + } + else { + write(", "); + emit(children[i]); + } + } + } + write(")"); + emitTrailingComments(openingNode); + } + if (node.kind === 233) { + emitJsxElement(node.openingElement, node.children); + } + else { + ts.Debug.assert(node.kind === 234); + emitJsxElement(node); + } + } + function jsxEmitPreserve(node) { + function emitJsxAttribute(node) { + emit(node.name); + if (node.initializer) { + write("="); + emit(node.initializer); + } + } + function emitJsxSpreadAttribute(node) { + write("{..."); + emit(node.expression); + write("}"); + } + function emitAttributes(attribs) { + for (var i = 0, n = attribs.length; i < n; i++) { + if (i > 0) { + write(" "); + } + if (attribs[i].kind === 239) { + emitJsxSpreadAttribute(attribs[i]); + } + else { + ts.Debug.assert(attribs[i].kind === 238); + emitJsxAttribute(attribs[i]); + } + } + } + function emitJsxOpeningOrSelfClosingElement(node) { + write("<"); + emit(node.tagName); + if (node.attributes.length > 0 || (node.kind === 234)) { + write(" "); + } + emitAttributes(node.attributes); + if (node.kind === 234) { + write("/>"); + } + else { + write(">"); + } + } + function emitJsxClosingElement(node) { + write(""); + } + function emitJsxElement(node) { + emitJsxOpeningOrSelfClosingElement(node.openingElement); + for (var i = 0, n = node.children.length; i < n; i++) { + emit(node.children[i]); + } + emitJsxClosingElement(node.closingElement); + } + if (node.kind === 233) { + emitJsxElement(node); + } + else { + ts.Debug.assert(node.kind === 234); + emitJsxOpeningOrSelfClosingElement(node); + } + } + function emitExpressionForPropertyName(node) { + ts.Debug.assert(node.kind !== 163); + if (node.kind === 9) { + emitLiteral(node); + } + else if (node.kind === 136) { + if (ts.nodeIsDecorated(node.parent)) { + if (!computedPropertyNamesToGeneratedNames) { + computedPropertyNamesToGeneratedNames = []; + } + var generatedName = computedPropertyNamesToGeneratedNames[ts.getNodeId(node)]; + if (generatedName) { + write(generatedName); + return; + } + generatedName = createAndRecordTempVariable(0).text; + computedPropertyNamesToGeneratedNames[ts.getNodeId(node)] = generatedName; + write(generatedName); + write(" = "); + } + emit(node.expression); + } + else { + write("\""); + if (node.kind === 8) { + write(node.text); + } + else { + writeTextOfNode(currentSourceFile, node); + } + write("\""); + } + } + function isExpressionIdentifier(node) { + var parent = node.parent; + switch (parent.kind) { + case 164: + case 189: + case 181: + case 168: + case 241: + case 136: + case 182: + case 139: + case 175: + case 197: + case 167: + case 227: + case 195: + case 188: + case 199: + case 200: + case 201: + case 196: + case 234: + case 235: + case 239: + case 240: + case 169: + case 172: + case 180: + case 179: + case 204: + case 246: + case 185: + case 206: + case 170: + case 190: + case 208: + case 171: + case 176: + case 177: + case 198: + case 205: + case 184: + return true; + case 163: + case 247: + case 138: + case 245: + case 141: + case 211: + return parent.initializer === node; + case 166: + return parent.expression === node; + case 174: + case 173: + return parent.body === node; + case 221: + return parent.moduleReference === node; + case 135: + return parent.left === node; + } + return false; + } + function emitExpressionIdentifier(node) { + if (resolver.getNodeCheckFlags(node) & 2048) { + write("_arguments"); + return; + } + var container = resolver.getReferencedExportContainer(node); + if (container) { + if (container.kind === 248) { + if (modulekind !== 5 && modulekind !== 4) { + write("exports."); + } + } + else { + write(getGeneratedNameForNode(container)); + write("."); + } + } + else { + if (modulekind !== 5) { + var declaration = resolver.getReferencedImportDeclaration(node); + if (declaration) { + if (declaration.kind === 223) { + write(getGeneratedNameForNode(declaration.parent)); + write(languageVersion === 0 ? "[\"default\"]" : ".default"); + return; + } + else if (declaration.kind === 226) { + write(getGeneratedNameForNode(declaration.parent.parent.parent)); + var name_24 = declaration.propertyName || declaration.name; + var identifier = ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, name_24); + if (languageVersion === 0 && identifier === "default") { + write("[\"default\"]"); + } + else { + write("."); + write(identifier); + } + return; + } + } + } + if (languageVersion !== 2) { + var declaration = resolver.getReferencedNestedRedeclaration(node); + if (declaration) { + write(getGeneratedNameForNode(declaration.name)); + return; + } + } + } + if (ts.nodeIsSynthesized(node)) { + write(node.text); + } + else { + writeTextOfNode(currentSourceFile, node); + } + } + function isNameOfNestedRedeclaration(node) { + if (languageVersion < 2) { + var parent_6 = node.parent; + switch (parent_6.kind) { + case 163: + case 214: + case 217: + case 211: + return parent_6.name === node && resolver.isNestedRedeclaration(parent_6); + } + } + return false; + } + function emitIdentifier(node) { + if (convertedLoopState) { + if (node.text == "arguments" && resolver.isArgumentsLocalBinding(node)) { + var name_25 = convertedLoopState.argumentsName || (convertedLoopState.argumentsName = makeUniqueName("arguments")); + write(name_25); + return; + } + } + if (!node.parent) { + write(node.text); + } + else if (isExpressionIdentifier(node)) { + emitExpressionIdentifier(node); + } + else if (isNameOfNestedRedeclaration(node)) { + write(getGeneratedNameForNode(node)); + } + else if (ts.nodeIsSynthesized(node)) { + write(node.text); + } + else { + writeTextOfNode(currentSourceFile, node); + } + } + function emitThis(node) { + if (resolver.getNodeCheckFlags(node) & 2) { + write("_this"); + } + else { + write("this"); + } + } + function emitSuper(node) { + if (languageVersion >= 2) { + write("super"); + } + else { + var flags = resolver.getNodeCheckFlags(node); + if (flags & 256) { + write("_super.prototype"); + } + else { + write("_super"); + } + } + } + function emitObjectBindingPattern(node) { + write("{ "); + var elements = node.elements; + emitList(elements, 0, elements.length, false, elements.hasTrailingComma); + write(" }"); + } + function emitArrayBindingPattern(node) { + write("["); + var elements = node.elements; + emitList(elements, 0, elements.length, false, elements.hasTrailingComma); + write("]"); + } + function emitBindingElement(node) { + if (node.propertyName) { + emit(node.propertyName); + write(": "); + } + if (node.dotDotDotToken) { + write("..."); + } + if (ts.isBindingPattern(node.name)) { + emit(node.name); + } + else { + emitModuleMemberName(node); + } + emitOptional(" = ", node.initializer); + } + function emitSpreadElementExpression(node) { + write("..."); + emit(node.expression); + } + function emitYieldExpression(node) { + write(ts.tokenToString(114)); + if (node.asteriskToken) { + write("*"); + } + if (node.expression) { + write(" "); + emit(node.expression); + } + } + function emitAwaitExpression(node) { + var needsParenthesis = needsParenthesisForAwaitExpressionAsYield(node); + if (needsParenthesis) { + write("("); + } + write(ts.tokenToString(114)); + write(" "); + emit(node.expression); + if (needsParenthesis) { + write(")"); + } + } + function needsParenthesisForAwaitExpressionAsYield(node) { + if (node.parent.kind === 181 && !ts.isAssignmentOperator(node.parent.operatorToken.kind)) { + return true; + } + else if (node.parent.kind === 182 && node.parent.condition === node) { + return true; + } + return false; + } + function needsParenthesisForPropertyAccessOrInvocation(node) { + switch (node.kind) { + case 69: + case 164: + case 166: + case 167: + case 168: + case 172: + return false; + } + return true; + } + function emitListWithSpread(elements, needsUniqueCopy, multiLine, trailingComma, useConcat) { + var pos = 0; + var group = 0; + var length = elements.length; + while (pos < length) { + if (group === 1 && useConcat) { + write(".concat("); + } + else if (group > 0) { + write(", "); + } + var e = elements[pos]; + if (e.kind === 185) { + e = e.expression; + emitParenthesizedIf(e, group === 0 && needsParenthesisForPropertyAccessOrInvocation(e)); + pos++; + if (pos === length && group === 0 && needsUniqueCopy && e.kind !== 164) { + write(".slice()"); + } + } + else { + var i = pos; + while (i < length && elements[i].kind !== 185) { + i++; + } + write("["); + if (multiLine) { + increaseIndent(); + } + emitList(elements, pos, i - pos, multiLine, trailingComma && i === length); + if (multiLine) { + decreaseIndent(); + } + write("]"); + pos = i; + } + group++; + } + if (group > 1) { + if (useConcat) { + write(")"); + } + } + } + function isSpreadElementExpression(node) { + return node.kind === 185; + } + function emitArrayLiteral(node) { + var elements = node.elements; + if (elements.length === 0) { + write("[]"); + } + else if (languageVersion >= 2 || !ts.forEach(elements, isSpreadElementExpression)) { + write("["); + emitLinePreservingList(node, node.elements, elements.hasTrailingComma, false); + write("]"); + } + else { + emitListWithSpread(elements, true, (node.flags & 2048) !== 0, elements.hasTrailingComma, true); + } + } + function emitObjectLiteralBody(node, numElements) { + if (numElements === 0) { + write("{}"); + return; + } + write("{"); + if (numElements > 0) { + var properties = node.properties; + if (numElements === properties.length) { + emitLinePreservingList(node, properties, languageVersion >= 1, true); + } + else { + var multiLine = (node.flags & 2048) !== 0; + if (!multiLine) { + write(" "); + } + else { + increaseIndent(); + } + emitList(properties, 0, numElements, multiLine, false); + if (!multiLine) { + write(" "); + } + else { + decreaseIndent(); + } + } + } + write("}"); + } + function emitDownlevelObjectLiteralWithComputedProperties(node, firstComputedPropertyIndex) { + var multiLine = (node.flags & 2048) !== 0; + var properties = node.properties; + write("("); + if (multiLine) { + increaseIndent(); + } + var tempVar = createAndRecordTempVariable(0); + emit(tempVar); + write(" = "); + emitObjectLiteralBody(node, firstComputedPropertyIndex); + for (var i = firstComputedPropertyIndex, n = properties.length; i < n; i++) { + writeComma(); + var property = properties[i]; + emitStart(property); + if (property.kind === 145 || property.kind === 146) { + var accessors = ts.getAllAccessorDeclarations(node.properties, property); + if (property !== accessors.firstAccessor) { + continue; + } + write("Object.defineProperty("); + emit(tempVar); + write(", "); + emitStart(node.name); + emitExpressionForPropertyName(property.name); + emitEnd(property.name); + write(", {"); + increaseIndent(); + if (accessors.getAccessor) { + writeLine(); + emitLeadingComments(accessors.getAccessor); + write("get: "); + emitStart(accessors.getAccessor); + write("function "); + emitSignatureAndBody(accessors.getAccessor); + emitEnd(accessors.getAccessor); + emitTrailingComments(accessors.getAccessor); + write(","); + } + if (accessors.setAccessor) { + writeLine(); + emitLeadingComments(accessors.setAccessor); + write("set: "); + emitStart(accessors.setAccessor); + write("function "); + emitSignatureAndBody(accessors.setAccessor); + emitEnd(accessors.setAccessor); + emitTrailingComments(accessors.setAccessor); + write(","); + } + writeLine(); + write("enumerable: true,"); + writeLine(); + write("configurable: true"); + decreaseIndent(); + writeLine(); + write("})"); + emitEnd(property); + } + else { + emitLeadingComments(property); + emitStart(property.name); + emit(tempVar); + emitMemberAccessForPropertyName(property.name); + emitEnd(property.name); + write(" = "); + if (property.kind === 245) { + emit(property.initializer); + } + else if (property.kind === 246) { + emitExpressionIdentifier(property.name); + } + else if (property.kind === 143) { + emitFunctionDeclaration(property); + } + else { + ts.Debug.fail("ObjectLiteralElement type not accounted for: " + property.kind); + } + } + emitEnd(property); + } + writeComma(); + emit(tempVar); + if (multiLine) { + decreaseIndent(); + writeLine(); + } + write(")"); + function writeComma() { + if (multiLine) { + write(","); + writeLine(); + } + else { + write(", "); + } + } + } + function emitObjectLiteral(node) { + var properties = node.properties; + if (languageVersion < 2) { + var numProperties = properties.length; + var numInitialNonComputedProperties = numProperties; + for (var i = 0, n = properties.length; i < n; i++) { + if (properties[i].name.kind === 136) { + numInitialNonComputedProperties = i; + break; + } + } + var hasComputedProperty = numInitialNonComputedProperties !== properties.length; + if (hasComputedProperty) { + emitDownlevelObjectLiteralWithComputedProperties(node, numInitialNonComputedProperties); + return; + } + } + emitObjectLiteralBody(node, properties.length); + } + function createBinaryExpression(left, operator, right, startsOnNewLine) { + var result = ts.createSynthesizedNode(181, startsOnNewLine); + result.operatorToken = ts.createSynthesizedNode(operator); + result.left = left; + result.right = right; + return result; + } + function createPropertyAccessExpression(expression, name) { + var result = ts.createSynthesizedNode(166); + result.expression = parenthesizeForAccess(expression); + result.dotToken = ts.createSynthesizedNode(21); + result.name = name; + return result; + } + function createElementAccessExpression(expression, argumentExpression) { + var result = ts.createSynthesizedNode(167); + result.expression = parenthesizeForAccess(expression); + result.argumentExpression = argumentExpression; + return result; + } + function parenthesizeForAccess(expr) { + while (expr.kind === 171 || expr.kind === 189) { + expr = expr.expression; + } + if (ts.isLeftHandSideExpression(expr) && + expr.kind !== 169 && + expr.kind !== 8) { + return expr; + } + var node = ts.createSynthesizedNode(172); + node.expression = expr; + return node; + } + function emitComputedPropertyName(node) { + write("["); + emitExpressionForPropertyName(node); + write("]"); + } + function emitMethod(node) { + if (languageVersion >= 2 && node.asteriskToken) { + write("*"); + } + emit(node.name); + if (languageVersion < 2) { + write(": function "); + } + emitSignatureAndBody(node); + } + function emitPropertyAssignment(node) { + emit(node.name); + write(": "); + emitTrailingCommentsOfPosition(node.initializer.pos); + emit(node.initializer); + } + function isNamespaceExportReference(node) { + var container = resolver.getReferencedExportContainer(node); + return container && container.kind !== 248; + } + function emitShorthandPropertyAssignment(node) { + writeTextOfNode(currentSourceFile, node.name); + if (languageVersion < 2 || isNamespaceExportReference(node.name)) { + write(": "); + emit(node.name); + } + if (languageVersion >= 2 && node.objectAssignmentInitializer) { + write(" = "); + emit(node.objectAssignmentInitializer); + } + } + function tryEmitConstantValue(node) { + var constantValue = tryGetConstEnumValue(node); + if (constantValue !== undefined) { + write(constantValue.toString()); + if (!compilerOptions.removeComments) { + var propertyName = node.kind === 166 ? ts.declarationNameToString(node.name) : ts.getTextOfNode(node.argumentExpression); + write(" /* " + propertyName + " */"); + } + return true; + } + return false; + } + function tryGetConstEnumValue(node) { + if (compilerOptions.isolatedModules) { + return undefined; + } + return node.kind === 166 || node.kind === 167 + ? resolver.getConstantValue(node) + : undefined; + } + function indentIfOnDifferentLines(parent, node1, node2, valueToWriteWhenNotIndenting) { + var realNodesAreOnDifferentLines = !ts.nodeIsSynthesized(parent) && !nodeEndIsOnSameLineAsNodeStart(node1, node2); + var synthesizedNodeIsOnDifferentLine = synthesizedNodeStartsOnNewLine(node2); + if (realNodesAreOnDifferentLines || synthesizedNodeIsOnDifferentLine) { + increaseIndent(); + writeLine(); + return true; + } + else { + if (valueToWriteWhenNotIndenting) { + write(valueToWriteWhenNotIndenting); + } + return false; + } + } + function emitPropertyAccess(node) { + if (tryEmitConstantValue(node)) { + return; + } + emit(node.expression); + var indentedBeforeDot = indentIfOnDifferentLines(node, node.expression, node.dotToken); + var shouldEmitSpace; + if (!indentedBeforeDot) { + if (node.expression.kind === 8) { + var text = ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, node.expression); + shouldEmitSpace = text.indexOf(ts.tokenToString(21)) < 0; + } + else { + var constantValue = tryGetConstEnumValue(node.expression); + shouldEmitSpace = isFinite(constantValue) && Math.floor(constantValue) === constantValue; + } + } + if (shouldEmitSpace) { + write(" ."); + } + else { + write("."); + } + var indentedAfterDot = indentIfOnDifferentLines(node, node.dotToken, node.name); + emit(node.name); + decreaseIndentIf(indentedBeforeDot, indentedAfterDot); + } + function emitQualifiedName(node) { + emit(node.left); + write("."); + emit(node.right); + } + function emitQualifiedNameAsExpression(node, useFallback) { + if (node.left.kind === 69) { + emitEntityNameAsExpression(node.left, useFallback); + } + else if (useFallback) { + var temp = createAndRecordTempVariable(0); + write("("); + emitNodeWithoutSourceMap(temp); + write(" = "); + emitEntityNameAsExpression(node.left, true); + write(") && "); + emitNodeWithoutSourceMap(temp); + } + else { + emitEntityNameAsExpression(node.left, false); + } + write("."); + emit(node.right); + } + function emitEntityNameAsExpression(node, useFallback) { + switch (node.kind) { + case 69: + if (useFallback) { + write("typeof "); + emitExpressionIdentifier(node); + write(" !== 'undefined' && "); + } + emitExpressionIdentifier(node); + break; + case 135: + emitQualifiedNameAsExpression(node, useFallback); + break; + } + } + function emitIndexedAccess(node) { + if (tryEmitConstantValue(node)) { + return; + } + emit(node.expression); + write("["); + emit(node.argumentExpression); + write("]"); + } + function hasSpreadElement(elements) { + return ts.forEach(elements, function (e) { return e.kind === 185; }); + } + function skipParentheses(node) { + while (node.kind === 172 || node.kind === 171 || node.kind === 189) { + node = node.expression; + } + return node; + } + function emitCallTarget(node) { + if (node.kind === 69 || node.kind === 97 || node.kind === 95) { + emit(node); + return node; + } + var temp = createAndRecordTempVariable(0); + write("("); + emit(temp); + write(" = "); + emit(node); + write(")"); + return temp; + } + function emitCallWithSpread(node) { + var target; + var expr = skipParentheses(node.expression); + if (expr.kind === 166) { + target = emitCallTarget(expr.expression); + write("."); + emit(expr.name); + } + else if (expr.kind === 167) { + target = emitCallTarget(expr.expression); + write("["); + emit(expr.argumentExpression); + write("]"); + } + else if (expr.kind === 95) { + target = expr; + write("_super"); + } + else { + emit(node.expression); + } + write(".apply("); + if (target) { + if (target.kind === 95) { + emitThis(target); + } + else { + emit(target); + } + } + else { + write("void 0"); + } + write(", "); + emitListWithSpread(node.arguments, false, false, false, true); + write(")"); + } + function emitCallExpression(node) { + if (languageVersion < 2 && hasSpreadElement(node.arguments)) { + emitCallWithSpread(node); + return; + } + var superCall = false; + if (node.expression.kind === 95) { + emitSuper(node.expression); + superCall = true; + } + else { + emit(node.expression); + superCall = node.expression.kind === 166 && node.expression.expression.kind === 95; + } + if (superCall && languageVersion < 2) { + write(".call("); + emitThis(node.expression); + if (node.arguments.length) { + write(", "); + emitCommaList(node.arguments); + } + write(")"); + } + else { + write("("); + emitCommaList(node.arguments); + write(")"); + } + } + function emitNewExpression(node) { + write("new "); + if (languageVersion === 1 && + node.arguments && + hasSpreadElement(node.arguments)) { + write("("); + var target = emitCallTarget(node.expression); + write(".bind.apply("); + emit(target); + write(", [void 0].concat("); + emitListWithSpread(node.arguments, false, false, false, false); + write(")))"); + write("()"); + } + else { + emit(node.expression); + if (node.arguments) { + write("("); + emitCommaList(node.arguments); + write(")"); + } + } + } + function emitTaggedTemplateExpression(node) { + if (languageVersion >= 2) { + emit(node.tag); + write(" "); + emit(node.template); + } + else { + emitDownlevelTaggedTemplate(node); + } + } + function emitParenExpression(node) { + if (!ts.nodeIsSynthesized(node) && node.parent.kind !== 174) { + if (node.expression.kind === 171 || node.expression.kind === 189) { + var operand = node.expression.expression; + while (operand.kind === 171 || operand.kind === 189) { + operand = operand.expression; + } + if (operand.kind !== 179 && + operand.kind !== 177 && + operand.kind !== 176 && + operand.kind !== 175 && + operand.kind !== 180 && + operand.kind !== 169 && + !(operand.kind === 168 && node.parent.kind === 169) && + !(operand.kind === 173 && node.parent.kind === 168) && + !(operand.kind === 8 && node.parent.kind === 166)) { + emit(operand); + return; + } + } + } + write("("); + emit(node.expression); + write(")"); + } + function emitDeleteExpression(node) { + write(ts.tokenToString(78)); + write(" "); + emit(node.expression); + } + function emitVoidExpression(node) { + write(ts.tokenToString(103)); + write(" "); + emit(node.expression); + } + function emitTypeOfExpression(node) { + write(ts.tokenToString(101)); + write(" "); + emit(node.expression); + } + function isNameOfExportedSourceLevelDeclarationInSystemExternalModule(node) { + if (!isCurrentFileSystemExternalModule() || node.kind !== 69 || ts.nodeIsSynthesized(node)) { + return false; + } + var isVariableDeclarationOrBindingElement = node.parent && (node.parent.kind === 211 || node.parent.kind === 163); + var targetDeclaration = isVariableDeclarationOrBindingElement + ? node.parent + : resolver.getReferencedValueDeclaration(node); + return isSourceFileLevelDeclarationInSystemJsModule(targetDeclaration, true); + } + function emitPrefixUnaryExpression(node) { + var exportChanged = isNameOfExportedSourceLevelDeclarationInSystemExternalModule(node.operand); + if (exportChanged) { + write(exportFunctionForFile + "(\""); + emitNodeWithoutSourceMap(node.operand); + write("\", "); + } + write(ts.tokenToString(node.operator)); + if (node.operand.kind === 179) { + var operand = node.operand; + if (node.operator === 35 && (operand.operator === 35 || operand.operator === 41)) { + write(" "); + } + else if (node.operator === 36 && (operand.operator === 36 || operand.operator === 42)) { + write(" "); + } + } + emit(node.operand); + if (exportChanged) { + write(")"); + } + } + function emitPostfixUnaryExpression(node) { + var exportChanged = isNameOfExportedSourceLevelDeclarationInSystemExternalModule(node.operand); + if (exportChanged) { + write("(" + exportFunctionForFile + "(\""); + emitNodeWithoutSourceMap(node.operand); + write("\", "); + write(ts.tokenToString(node.operator)); + emit(node.operand); + if (node.operator === 41) { + write(") - 1)"); + } + else { + write(") + 1)"); + } + } + else { + emit(node.operand); + write(ts.tokenToString(node.operator)); + } + } + function shouldHoistDeclarationInSystemJsModule(node) { + return isSourceFileLevelDeclarationInSystemJsModule(node, false); + } + function isSourceFileLevelDeclarationInSystemJsModule(node, isExported) { + if (!node || !isCurrentFileSystemExternalModule()) { + return false; + } + var current = node; + while (current) { + if (current.kind === 248) { + return !isExported || ((ts.getCombinedNodeFlags(node) & 1) !== 0); + } + else if (ts.isFunctionLike(current) || current.kind === 219) { + return false; + } + else { + current = current.parent; + } + } + } + function emitExponentiationOperator(node) { + var leftHandSideExpression = node.left; + if (node.operatorToken.kind === 60) { + var synthesizedLHS; + var shouldEmitParentheses = false; + if (ts.isElementAccessExpression(leftHandSideExpression)) { + shouldEmitParentheses = true; + write("("); + synthesizedLHS = ts.createSynthesizedNode(167, false); + var identifier = emitTempVariableAssignment(leftHandSideExpression.expression, false, false); + synthesizedLHS.expression = identifier; + if (leftHandSideExpression.argumentExpression.kind !== 8 && + leftHandSideExpression.argumentExpression.kind !== 9) { + var tempArgumentExpression = createAndRecordTempVariable(268435456); + synthesizedLHS.argumentExpression = tempArgumentExpression; + emitAssignment(tempArgumentExpression, leftHandSideExpression.argumentExpression, true); + } + else { + synthesizedLHS.argumentExpression = leftHandSideExpression.argumentExpression; + } + write(", "); + } + else if (ts.isPropertyAccessExpression(leftHandSideExpression)) { + shouldEmitParentheses = true; + write("("); + synthesizedLHS = ts.createSynthesizedNode(166, false); + var identifier = emitTempVariableAssignment(leftHandSideExpression.expression, false, false); + synthesizedLHS.expression = identifier; + synthesizedLHS.dotToken = leftHandSideExpression.dotToken; + synthesizedLHS.name = leftHandSideExpression.name; + write(", "); + } + emit(synthesizedLHS || leftHandSideExpression); + write(" = "); + write("Math.pow("); + emit(synthesizedLHS || leftHandSideExpression); + write(", "); + emit(node.right); + write(")"); + if (shouldEmitParentheses) { + write(")"); + } + } + else { + write("Math.pow("); + emit(leftHandSideExpression); + write(", "); + emit(node.right); + write(")"); + } + } + function emitBinaryExpression(node) { + if (languageVersion < 2 && node.operatorToken.kind === 56 && + (node.left.kind === 165 || node.left.kind === 164)) { + emitDestructuring(node, node.parent.kind === 195); + } + else { + var exportChanged = node.operatorToken.kind >= 56 && + node.operatorToken.kind <= 68 && + isNameOfExportedSourceLevelDeclarationInSystemExternalModule(node.left); + if (exportChanged) { + write(exportFunctionForFile + "(\""); + emitNodeWithoutSourceMap(node.left); + write("\", "); + } + if (node.operatorToken.kind === 38 || node.operatorToken.kind === 60) { + emitExponentiationOperator(node); + } + else { + emit(node.left); + var indentedBeforeOperator = indentIfOnDifferentLines(node, node.left, node.operatorToken, node.operatorToken.kind !== 24 ? " " : undefined); + write(ts.tokenToString(node.operatorToken.kind)); + var indentedAfterOperator = indentIfOnDifferentLines(node, node.operatorToken, node.right, " "); + emit(node.right); + decreaseIndentIf(indentedBeforeOperator, indentedAfterOperator); + } + if (exportChanged) { + write(")"); + } + } + } + function synthesizedNodeStartsOnNewLine(node) { + return ts.nodeIsSynthesized(node) && node.startsOnNewLine; + } + function emitConditionalExpression(node) { + emit(node.condition); + var indentedBeforeQuestion = indentIfOnDifferentLines(node, node.condition, node.questionToken, " "); + write("?"); + var indentedAfterQuestion = indentIfOnDifferentLines(node, node.questionToken, node.whenTrue, " "); + emit(node.whenTrue); + decreaseIndentIf(indentedBeforeQuestion, indentedAfterQuestion); + var indentedBeforeColon = indentIfOnDifferentLines(node, node.whenTrue, node.colonToken, " "); + write(":"); + var indentedAfterColon = indentIfOnDifferentLines(node, node.colonToken, node.whenFalse, " "); + emit(node.whenFalse); + decreaseIndentIf(indentedBeforeColon, indentedAfterColon); + } + function decreaseIndentIf(value1, value2) { + if (value1) { + decreaseIndent(); + } + if (value2) { + decreaseIndent(); + } + } + function isSingleLineEmptyBlock(node) { + if (node && node.kind === 192) { + var block = node; + return block.statements.length === 0 && nodeEndIsOnSameLineAsNodeStart(block, block); + } + } + function emitBlock(node) { + if (isSingleLineEmptyBlock(node)) { + emitToken(15, node.pos); + write(" "); + emitToken(16, node.statements.end); + return; + } + emitToken(15, node.pos); + increaseIndent(); + scopeEmitStart(node.parent); + if (node.kind === 219) { + ts.Debug.assert(node.parent.kind === 218); + emitCaptureThisForNodeIfNecessary(node.parent); + } + emitLines(node.statements); + if (node.kind === 219) { + emitTempDeclarations(true); + } + decreaseIndent(); + writeLine(); + emitToken(16, node.statements.end); + scopeEmitEnd(); + } + function emitEmbeddedStatement(node) { + if (node.kind === 192) { + write(" "); + emit(node); + } + else { + increaseIndent(); + writeLine(); + emit(node); + decreaseIndent(); + } + } + function emitExpressionStatement(node) { + emitParenthesizedIf(node.expression, node.expression.kind === 174); + write(";"); + } + function emitIfStatement(node) { + var endPos = emitToken(88, node.pos); + write(" "); + endPos = emitToken(17, endPos); + emit(node.expression); + emitToken(18, node.expression.end); + emitEmbeddedStatement(node.thenStatement); + if (node.elseStatement) { + writeLine(); + emitToken(80, node.thenStatement.end); + if (node.elseStatement.kind === 196) { + write(" "); + emit(node.elseStatement); + } + else { + emitEmbeddedStatement(node.elseStatement); + } + } + } + function emitDoStatement(node) { + emitLoop(node, emitDoStatementWorker); + } + function emitDoStatementWorker(node, loop) { + write("do"); + if (loop) { + emitConvertedLoopCall(loop, true); + } + else { + emitNormalLoopBody(node, true); + } + if (node.statement.kind === 192) { + write(" "); + } + else { + writeLine(); + } + write("while ("); + emit(node.expression); + write(");"); + } + function emitWhileStatement(node) { + emitLoop(node, emitWhileStatementWorker); + } + function emitWhileStatementWorker(node, loop) { + write("while ("); + emit(node.expression); + write(")"); + if (loop) { + emitConvertedLoopCall(loop, true); + } + else { + emitNormalLoopBody(node, true); + } + } + function tryEmitStartOfVariableDeclarationList(decl, startPos) { + if (shouldHoistVariable(decl, true)) { + return false; + } + if (convertedLoopState && (ts.getCombinedNodeFlags(decl) & 49152) === 0) { + for (var _a = 0, _b = decl.declarations; _a < _b.length; _a++) { + var varDecl = _b[_a]; + hoistVariableDeclarationFromLoop(convertedLoopState, varDecl); + } + return false; + } + var tokenKind = 102; + if (decl && languageVersion >= 2) { + if (ts.isLet(decl)) { + tokenKind = 108; + } + else if (ts.isConst(decl)) { + tokenKind = 74; + } + } + if (startPos !== undefined) { + emitToken(tokenKind, startPos); + write(" "); + } + else { + switch (tokenKind) { + case 102: + write("var "); + break; + case 108: + write("let "); + break; + case 74: + write("const "); + break; + } + } + return true; + } + function emitVariableDeclarationListSkippingUninitializedEntries(list) { + var started = false; + for (var _a = 0, _b = list.declarations; _a < _b.length; _a++) { + var decl = _b[_a]; + if (!decl.initializer) { + continue; + } + if (!started) { + started = true; + } + else { + write(", "); + } + emit(decl); + } + return started; + } + function shouldConvertLoopBody(node) { + return languageVersion < 2 && + (resolver.getNodeCheckFlags(node) & 65536) !== 0; + } + function emitLoop(node, loopEmitter) { + var shouldConvert = shouldConvertLoopBody(node); + if (!shouldConvert) { + loopEmitter(node, undefined); + } + else { + var loop = convertLoopBody(node); + if (node.parent.kind === 207) { + emitLabelAndColon(node.parent); + } + loopEmitter(node, loop); + } + } + function convertLoopBody(node) { + var functionName = makeUniqueName("_loop"); + var loopInitializer; + switch (node.kind) { + case 199: + case 200: + case 201: + if (node.initializer.kind === 212) { + loopInitializer = node.initializer; + } + break; + } + var loopParameters; + if (loopInitializer && (ts.getCombinedNodeFlags(loopInitializer) & 49152)) { + loopParameters = []; + for (var _a = 0, _b = loopInitializer.declarations; _a < _b.length; _a++) { + var varDeclaration = _b[_a]; + collectNames(varDeclaration.name); + } + } + var bodyIsBlock = node.statement.kind === 192; + var paramList = loopParameters ? loopParameters.join(", ") : ""; + writeLine(); + write("var " + functionName + " = function(" + paramList + ")"); + if (!bodyIsBlock) { + write(" {"); + writeLine(); + increaseIndent(); + } + var convertedOuterLoopState = convertedLoopState; + convertedLoopState = {}; + if (convertedOuterLoopState) { + if (convertedOuterLoopState.argumentsName) { + convertedLoopState.argumentsName = convertedOuterLoopState.argumentsName; + } + if (convertedOuterLoopState.hoistedLocalVariables) { + convertedLoopState.hoistedLocalVariables = convertedOuterLoopState.hoistedLocalVariables; + } + } + emitEmbeddedStatement(node.statement); + if (!bodyIsBlock) { + decreaseIndent(); + writeLine(); + write("}"); + } + write(";"); + writeLine(); + if (convertedLoopState.argumentsName) { + if (convertedOuterLoopState) { + convertedOuterLoopState.argumentsName = convertedLoopState.argumentsName; + } + else { + write("var " + convertedLoopState.argumentsName + " = arguments;"); + writeLine(); + } + } + if (convertedLoopState.hoistedLocalVariables) { + if (convertedOuterLoopState) { + convertedOuterLoopState.hoistedLocalVariables = convertedLoopState.hoistedLocalVariables; + } + else { + write("var "); + var seen; + for (var _c = 0, _d = convertedLoopState.hoistedLocalVariables; _c < _d.length; _c++) { + var id = _d[_c]; + if (!seen) { + seen = {}; + } + else { + write(", "); + } + if (!ts.hasProperty(seen, id.text)) { + emit(id); + seen[id.text] = id.text; + } + } + write(";"); + writeLine(); + } + } + var currentLoopState = convertedLoopState; + convertedLoopState = convertedOuterLoopState; + return { functionName: functionName, paramList: paramList, state: currentLoopState }; + function collectNames(name) { + if (name.kind === 69) { + var nameText = isNameOfNestedRedeclaration(name) ? getGeneratedNameForNode(name) : name.text; + loopParameters.push(nameText); + } + else { + for (var _a = 0, _b = name.elements; _a < _b.length; _a++) { + var element = _b[_a]; + collectNames(element.name); + } + } + } + } + function emitNormalLoopBody(node, emitAsEmbeddedStatement) { + var saveAllowedNonLabeledJumps; + if (convertedLoopState) { + saveAllowedNonLabeledJumps = convertedLoopState.allowedNonLabeledJumps; + convertedLoopState.allowedNonLabeledJumps = 2 | 4; + } + if (emitAsEmbeddedStatement) { + emitEmbeddedStatement(node.statement); + } + else if (node.statement.kind === 192) { + emitLines(node.statement.statements); + } + else { + writeLine(); + emit(node.statement); + } + if (convertedLoopState) { + convertedLoopState.allowedNonLabeledJumps = saveAllowedNonLabeledJumps; + } + } + function emitConvertedLoopCall(loop, emitAsBlock) { + if (emitAsBlock) { + write(" {"); + writeLine(); + increaseIndent(); + } + var isSimpleLoop = !loop.state.nonLocalJumps && + !loop.state.labeledNonLocalBreaks && + !loop.state.labeledNonLocalContinues; + var loopResult = makeUniqueName("state"); + if (!isSimpleLoop) { + write("var " + loopResult + " = "); + } + write(loop.functionName + "(" + loop.paramList + ");"); + if (!isSimpleLoop) { + writeLine(); + if (loop.state.nonLocalJumps & 8) { + write("if (typeof " + loopResult + " === \"object\") "); + if (convertedLoopState) { + write("return " + loopResult + ";"); + convertedLoopState.nonLocalJumps |= 8; + } + else { + write("return " + loopResult + ".value"); + } + writeLine(); + } + if (loop.state.nonLocalJumps & 2) { + write("if (" + loopResult + " === \"break\") break;"); + writeLine(); + } + if (loop.state.nonLocalJumps & 4) { + write("if (" + loopResult + " === \"continue\") continue;"); + writeLine(); + } + emitDispatchTableForLabeledJumps(loopResult, loop.state, convertedLoopState); + } + if (emitAsBlock) { + writeLine(); + decreaseIndent(); + write("}"); + } + function emitDispatchTableForLabeledJumps(loopResultVariable, currentLoop, outerLoop) { + if (!currentLoop.labeledNonLocalBreaks && !currentLoop.labeledNonLocalContinues) { + return; + } + write("switch(" + loopResultVariable + ") {"); + increaseIndent(); + emitDispatchEntriesForLabeledJumps(currentLoop.labeledNonLocalBreaks, true, loopResultVariable, outerLoop); + emitDispatchEntriesForLabeledJumps(currentLoop.labeledNonLocalContinues, false, loopResultVariable, outerLoop); + decreaseIndent(); + writeLine(); + write("}"); + } + function emitDispatchEntriesForLabeledJumps(table, isBreak, loopResultVariable, outerLoop) { + if (!table) { + return; + } + for (var labelText in table) { + var labelMarker = table[labelText]; + writeLine(); + write("case \"" + labelMarker + "\": "); + if (!outerLoop || (outerLoop.labels && outerLoop.labels[labelText])) { + if (isBreak) { + write("break "); + } + else { + write("continue "); + } + write(labelText + ";"); + } + else { + setLabeledJump(outerLoop, isBreak, labelText, labelMarker); + write("return " + loopResultVariable + ";"); + } + } + } + } + function emitForStatement(node) { + emitLoop(node, emitForStatementWorker); + } + function emitForStatementWorker(node, loop) { + var endPos = emitToken(86, node.pos); + write(" "); + endPos = emitToken(17, endPos); + if (node.initializer && node.initializer.kind === 212) { + var variableDeclarationList = node.initializer; + var startIsEmitted = tryEmitStartOfVariableDeclarationList(variableDeclarationList, endPos); + if (startIsEmitted) { + emitCommaList(variableDeclarationList.declarations); + } + else { + emitVariableDeclarationListSkippingUninitializedEntries(variableDeclarationList); + } + } + else if (node.initializer) { + emit(node.initializer); + } + write(";"); + emitOptional(" ", node.condition); + write(";"); + emitOptional(" ", node.incrementor); + write(")"); + if (loop) { + emitConvertedLoopCall(loop, true); + } + else { + emitNormalLoopBody(node, true); + } + } + function emitForInOrForOfStatement(node) { + if (languageVersion < 2 && node.kind === 201) { + emitLoop(node, emitDownLevelForOfStatementWorker); + } + else { + emitLoop(node, emitForInOrForOfStatementWorker); + } + } + function emitForInOrForOfStatementWorker(node, loop) { + var endPos = emitToken(86, node.pos); + write(" "); + endPos = emitToken(17, endPos); + if (node.initializer.kind === 212) { + var variableDeclarationList = node.initializer; + if (variableDeclarationList.declarations.length >= 1) { + tryEmitStartOfVariableDeclarationList(variableDeclarationList, endPos); + emit(variableDeclarationList.declarations[0]); + } + } + else { + emit(node.initializer); + } + if (node.kind === 200) { + write(" in "); + } + else { + write(" of "); + } + emit(node.expression); + emitToken(18, node.expression.end); + if (loop) { + emitConvertedLoopCall(loop, true); + } + else { + emitNormalLoopBody(node, true); + } + } + function emitDownLevelForOfStatement(node) { + emitLoop(node, emitDownLevelForOfStatementWorker); + } + function emitDownLevelForOfStatementWorker(node, loop) { + var endPos = emitToken(86, node.pos); + write(" "); + endPos = emitToken(17, endPos); + var rhsIsIdentifier = node.expression.kind === 69; + var counter = createTempVariable(268435456); + var rhsReference = rhsIsIdentifier ? node.expression : createTempVariable(0); + emitStart(node.expression); + write("var "); + emitNodeWithoutSourceMap(counter); + write(" = 0"); + emitEnd(node.expression); + if (!rhsIsIdentifier) { + write(", "); + emitStart(node.expression); + emitNodeWithoutSourceMap(rhsReference); + write(" = "); + emitNodeWithoutSourceMap(node.expression); + emitEnd(node.expression); + } + write("; "); + emitStart(node.initializer); + emitNodeWithoutSourceMap(counter); + write(" < "); + emitNodeWithCommentsAndWithoutSourcemap(rhsReference); + write(".length"); + emitEnd(node.initializer); + write("; "); + emitStart(node.initializer); + emitNodeWithoutSourceMap(counter); + write("++"); + emitEnd(node.initializer); + emitToken(18, node.expression.end); + write(" {"); + writeLine(); + increaseIndent(); + var rhsIterationValue = createElementAccessExpression(rhsReference, counter); + emitStart(node.initializer); + if (node.initializer.kind === 212) { + write("var "); + var variableDeclarationList = node.initializer; + if (variableDeclarationList.declarations.length > 0) { + var declaration = variableDeclarationList.declarations[0]; + if (ts.isBindingPattern(declaration.name)) { + emitDestructuring(declaration, false, rhsIterationValue); + } + else { + emitNodeWithCommentsAndWithoutSourcemap(declaration); + write(" = "); + emitNodeWithoutSourceMap(rhsIterationValue); + } + } + else { + emitNodeWithoutSourceMap(createTempVariable(0)); + write(" = "); + emitNodeWithoutSourceMap(rhsIterationValue); + } + } + else { + var assignmentExpression = createBinaryExpression(node.initializer, 56, rhsIterationValue, false); + if (node.initializer.kind === 164 || node.initializer.kind === 165) { + emitDestructuring(assignmentExpression, true, undefined); + } + else { + emitNodeWithCommentsAndWithoutSourcemap(assignmentExpression); + } + } + emitEnd(node.initializer); + write(";"); + if (loop) { + writeLine(); + emitConvertedLoopCall(loop, false); + } + else { + emitNormalLoopBody(node, false); + } + writeLine(); + decreaseIndent(); + write("}"); + } + function emitBreakOrContinueStatement(node) { + if (convertedLoopState) { + var jump = node.kind === 203 ? 2 : 4; + var canUseBreakOrContinue = (node.label && convertedLoopState.labels && convertedLoopState.labels[node.label.text]) || + (!node.label && (convertedLoopState.allowedNonLabeledJumps & jump)); + if (!canUseBreakOrContinue) { + if (!node.label) { + if (node.kind === 203) { + convertedLoopState.nonLocalJumps |= 2; + write("return \"break\";"); + } + else { + convertedLoopState.nonLocalJumps |= 4; + write("return \"continue\";"); + } + } + else { + var labelMarker; + if (node.kind === 203) { + 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); + } + write("return \"" + labelMarker + "\";"); + } + return; + } + } + emitToken(node.kind === 203 ? 70 : 75, node.pos); + emitOptional(" ", node.label); + write(";"); + } + function emitReturnStatement(node) { + if (convertedLoopState) { + convertedLoopState.nonLocalJumps |= 8; + write("return { value: "); + if (node.expression) { + emit(node.expression); + } + else { + write("void 0"); + } + write(" };"); + return; + } + emitToken(94, node.pos); + emitOptional(" ", node.expression); + write(";"); + } + function emitWithStatement(node) { + write("with ("); + emit(node.expression); + write(")"); + emitEmbeddedStatement(node.statement); + } + function emitSwitchStatement(node) { + var endPos = emitToken(96, node.pos); + write(" "); + emitToken(17, endPos); + emit(node.expression); + endPos = emitToken(18, node.expression.end); + write(" "); + var saveAllowedNonLabeledJumps; + if (convertedLoopState) { + saveAllowedNonLabeledJumps = convertedLoopState.allowedNonLabeledJumps; + convertedLoopState.allowedNonLabeledJumps |= 2; + } + emitCaseBlock(node.caseBlock, endPos); + if (convertedLoopState) { + convertedLoopState.allowedNonLabeledJumps = saveAllowedNonLabeledJumps; + } + } + function emitCaseBlock(node, startPos) { + emitToken(15, startPos); + increaseIndent(); + emitLines(node.clauses); + decreaseIndent(); + writeLine(); + emitToken(16, node.clauses.end); + } + function nodeStartPositionsAreOnSameLine(node1, node2) { + return ts.getLineOfLocalPosition(currentSourceFile, ts.skipTrivia(currentSourceFile.text, node1.pos)) === + ts.getLineOfLocalPosition(currentSourceFile, ts.skipTrivia(currentSourceFile.text, node2.pos)); + } + function nodeEndPositionsAreOnSameLine(node1, node2) { + return ts.getLineOfLocalPosition(currentSourceFile, node1.end) === + ts.getLineOfLocalPosition(currentSourceFile, node2.end); + } + function nodeEndIsOnSameLineAsNodeStart(node1, node2) { + return ts.getLineOfLocalPosition(currentSourceFile, node1.end) === + ts.getLineOfLocalPosition(currentSourceFile, ts.skipTrivia(currentSourceFile.text, node2.pos)); + } + function emitCaseOrDefaultClause(node) { + if (node.kind === 241) { + write("case "); + emit(node.expression); + write(":"); + } + else { + write("default:"); + } + if (node.statements.length === 1 && nodeStartPositionsAreOnSameLine(node, node.statements[0])) { + write(" "); + emit(node.statements[0]); + } + else { + increaseIndent(); + emitLines(node.statements); + decreaseIndent(); + } + } + function emitThrowStatement(node) { + write("throw "); + emit(node.expression); + write(";"); + } + function emitTryStatement(node) { + write("try "); + emit(node.tryBlock); + emit(node.catchClause); + if (node.finallyBlock) { + writeLine(); + write("finally "); + emit(node.finallyBlock); + } + } + function emitCatchClause(node) { + writeLine(); + var endPos = emitToken(72, node.pos); + write(" "); + emitToken(17, endPos); + emit(node.variableDeclaration); + emitToken(18, node.variableDeclaration ? node.variableDeclaration.end : endPos); + write(" "); + emitBlock(node.block); + } + function emitDebuggerStatement(node) { + emitToken(76, node.pos); + write(";"); + } + function emitLabelAndColon(node) { + emit(node.label); + write(": "); + } + function emitLabeledStatement(node) { + if (!ts.isIterationStatement(node.statement, false) || !shouldConvertLoopBody(node.statement)) { + emitLabelAndColon(node); + } + if (convertedLoopState) { + if (!convertedLoopState.labels) { + convertedLoopState.labels = {}; + } + convertedLoopState.labels[node.label.text] = node.label.text; + } + emit(node.statement); + if (convertedLoopState) { + convertedLoopState.labels[node.label.text] = undefined; + } + } + function getContainingModule(node) { + do { + node = node.parent; + } while (node && node.kind !== 218); + return node; + } + function emitContainingModuleName(node) { + var container = getContainingModule(node); + write(container ? getGeneratedNameForNode(container) : "exports"); + } + function emitModuleMemberName(node) { + emitStart(node.name); + if (ts.getCombinedNodeFlags(node) & 1) { + var container = getContainingModule(node); + if (container) { + write(getGeneratedNameForNode(container)); + write("."); + } + else if (modulekind !== 5 && modulekind !== 4) { + write("exports."); + } + } + emitNodeWithCommentsAndWithoutSourcemap(node.name); + emitEnd(node.name); + } + function createVoidZero() { + var zero = ts.createSynthesizedNode(8); + zero.text = "0"; + var result = ts.createSynthesizedNode(177); + result.expression = zero; + return result; + } + function emitEs6ExportDefaultCompat(node) { + if (node.parent.kind === 248) { + ts.Debug.assert(!!(node.flags & 1024) || node.kind === 227); + if (modulekind === 1 || modulekind === 2 || modulekind === 3) { + if (!currentSourceFile.symbol.exports["___esModule"]) { + if (languageVersion === 1) { + write("Object.defineProperty(exports, \"__esModule\", { value: true });"); + writeLine(); + } + else if (languageVersion === 0) { + write("exports.__esModule = true;"); + writeLine(); + } + } + } + } + } + function emitExportMemberAssignment(node) { + if (node.flags & 1) { + writeLine(); + emitStart(node); + if (modulekind === 4 && node.parent === currentSourceFile) { + write(exportFunctionForFile + "(\""); + if (node.flags & 1024) { + write("default"); + } + else { + emitNodeWithCommentsAndWithoutSourcemap(node.name); + } + write("\", "); + emitDeclarationName(node); + write(")"); + } + else { + if (node.flags & 1024) { + emitEs6ExportDefaultCompat(node); + if (languageVersion === 0) { + write("exports[\"default\"]"); + } + else { + write("exports.default"); + } + } + else { + emitModuleMemberName(node); + } + write(" = "); + emitDeclarationName(node); + } + emitEnd(node); + write(";"); + } + } + function emitExportMemberAssignments(name) { + if (modulekind === 4) { + return; + } + if (!exportEquals && exportSpecifiers && ts.hasProperty(exportSpecifiers, name.text)) { + for (var _a = 0, _b = exportSpecifiers[name.text]; _a < _b.length; _a++) { + var specifier = _b[_a]; + writeLine(); + emitStart(specifier.name); + emitContainingModuleName(specifier); + write("."); + emitNodeWithCommentsAndWithoutSourcemap(specifier.name); + emitEnd(specifier.name); + write(" = "); + emitExpressionIdentifier(name); + write(";"); + } + } + } + function emitExportSpecifierInSystemModule(specifier) { + ts.Debug.assert(modulekind === 4); + if (!resolver.getReferencedValueDeclaration(specifier.propertyName || specifier.name) && !resolver.isValueAliasDeclaration(specifier)) { + return; + } + writeLine(); + emitStart(specifier.name); + write(exportFunctionForFile + "(\""); + emitNodeWithCommentsAndWithoutSourcemap(specifier.name); + write("\", "); + emitExpressionIdentifier(specifier.propertyName || specifier.name); + write(")"); + emitEnd(specifier.name); + write(";"); + } + function emitAssignment(name, value, shouldEmitCommaBeforeAssignment) { + if (shouldEmitCommaBeforeAssignment) { + write(", "); + } + var exportChanged = isNameOfExportedSourceLevelDeclarationInSystemExternalModule(name); + if (exportChanged) { + write(exportFunctionForFile + "(\""); + emitNodeWithCommentsAndWithoutSourcemap(name); + write("\", "); + } + var isVariableDeclarationOrBindingElement = name.parent && (name.parent.kind === 211 || name.parent.kind === 163); + if (isVariableDeclarationOrBindingElement) { + emitModuleMemberName(name.parent); + } + else { + emit(name); + } + write(" = "); + emit(value); + if (exportChanged) { + write(")"); + } + } + function emitTempVariableAssignment(expression, canDefineTempVariablesInPlace, shouldEmitCommaBeforeAssignment) { + var identifier = createTempVariable(0); + if (!canDefineTempVariablesInPlace) { + recordTempDeclaration(identifier); + } + emitAssignment(identifier, expression, shouldEmitCommaBeforeAssignment); + return identifier; + } + function emitDestructuring(root, isAssignmentExpressionStatement, value) { + var emitCount = 0; + var canDefineTempVariablesInPlace = false; + if (root.kind === 211) { + var isExported = ts.getCombinedNodeFlags(root) & 1; + var isSourceLevelForSystemModuleKind = shouldHoistDeclarationInSystemJsModule(root); + canDefineTempVariablesInPlace = !isExported && !isSourceLevelForSystemModuleKind; + } + else if (root.kind === 138) { + canDefineTempVariablesInPlace = true; + } + if (root.kind === 181) { + emitAssignmentExpression(root); + } + else { + ts.Debug.assert(!isAssignmentExpressionStatement); + emitBindingElement(root, value); + } + function ensureIdentifier(expr, reuseIdentifierExpressions) { + if (expr.kind === 69 && reuseIdentifierExpressions) { + return expr; + } + var identifier = emitTempVariableAssignment(expr, canDefineTempVariablesInPlace, emitCount > 0); + emitCount++; + return identifier; + } + function createDefaultValueCheck(value, defaultValue) { + value = ensureIdentifier(value, true); + var equals = ts.createSynthesizedNode(181); + equals.left = value; + equals.operatorToken = ts.createSynthesizedNode(32); + equals.right = createVoidZero(); + return createConditionalExpression(equals, defaultValue, value); + } + function createConditionalExpression(condition, whenTrue, whenFalse) { + var cond = ts.createSynthesizedNode(182); + cond.condition = condition; + cond.questionToken = ts.createSynthesizedNode(53); + cond.whenTrue = whenTrue; + cond.colonToken = ts.createSynthesizedNode(54); + cond.whenFalse = whenFalse; + return cond; + } + function createNumericLiteral(value) { + var node = ts.createSynthesizedNode(8); + node.text = "" + value; + return node; + } + function createPropertyAccessForDestructuringProperty(object, propName) { + var syntheticName = ts.createSynthesizedNode(propName.kind); + syntheticName.text = propName.text; + if (syntheticName.kind !== 69) { + return createElementAccessExpression(object, syntheticName); + } + return createPropertyAccessExpression(object, syntheticName); + } + function createSliceCall(value, sliceIndex) { + var call = ts.createSynthesizedNode(168); + var sliceIdentifier = ts.createSynthesizedNode(69); + sliceIdentifier.text = "slice"; + call.expression = createPropertyAccessExpression(value, sliceIdentifier); + call.arguments = ts.createSynthesizedNodeArray(); + call.arguments[0] = createNumericLiteral(sliceIndex); + return call; + } + function emitObjectLiteralAssignment(target, value) { + var properties = target.properties; + if (properties.length !== 1) { + value = ensureIdentifier(value, true); + } + for (var _a = 0; _a < properties.length; _a++) { + var p = properties[_a]; + if (p.kind === 245 || p.kind === 246) { + var propName = p.name; + var target_1 = p.kind === 246 ? p : p.initializer || propName; + emitDestructuringAssignment(target_1, createPropertyAccessForDestructuringProperty(value, propName)); + } + } + } + function emitArrayLiteralAssignment(target, value) { + var elements = target.elements; + if (elements.length !== 1) { + value = ensureIdentifier(value, true); + } + for (var i = 0; i < elements.length; i++) { + var e = elements[i]; + if (e.kind !== 187) { + if (e.kind !== 185) { + emitDestructuringAssignment(e, createElementAccessExpression(value, createNumericLiteral(i))); + } + else if (i === elements.length - 1) { + emitDestructuringAssignment(e.expression, createSliceCall(value, i)); + } + } + } + } + function emitDestructuringAssignment(target, value) { + if (target.kind === 246) { + if (target.objectAssignmentInitializer) { + value = createDefaultValueCheck(value, target.objectAssignmentInitializer); + } + target = target.name; + } + else if (target.kind === 181 && target.operatorToken.kind === 56) { + value = createDefaultValueCheck(value, target.right); + target = target.left; + } + if (target.kind === 165) { + emitObjectLiteralAssignment(target, value); + } + else if (target.kind === 164) { + emitArrayLiteralAssignment(target, value); + } + else { + emitAssignment(target, value, emitCount > 0); + emitCount++; + } + } + function emitAssignmentExpression(root) { + var target = root.left; + var value = root.right; + if (ts.isEmptyObjectLiteralOrArrayLiteral(target)) { + emit(value); + } + else if (isAssignmentExpressionStatement) { + emitDestructuringAssignment(target, value); + } + else { + if (root.parent.kind !== 172) { + write("("); + } + value = ensureIdentifier(value, true); + emitDestructuringAssignment(target, value); + write(", "); + emit(value); + if (root.parent.kind !== 172) { + write(")"); + } + } + } + function emitBindingElement(target, value) { + if (target.initializer) { + value = value ? createDefaultValueCheck(value, target.initializer) : target.initializer; + } + else if (!value) { + value = createVoidZero(); + } + if (ts.isBindingPattern(target.name)) { + var pattern = target.name; + var elements = pattern.elements; + var numElements = elements.length; + if (numElements !== 1) { + value = ensureIdentifier(value, numElements !== 0); + } + for (var i = 0; i < numElements; i++) { + var element = elements[i]; + if (pattern.kind === 161) { + var propName = element.propertyName || element.name; + emitBindingElement(element, createPropertyAccessForDestructuringProperty(value, propName)); + } + else if (element.kind !== 187) { + if (!element.dotDotDotToken) { + emitBindingElement(element, createElementAccessExpression(value, createNumericLiteral(i))); + } + else if (i === numElements - 1) { + emitBindingElement(element, createSliceCall(value, i)); + } + } + } + } + else { + emitAssignment(target.name, value, emitCount > 0); + emitCount++; + } + } + } + function emitVariableDeclaration(node) { + if (ts.isBindingPattern(node.name)) { + if (languageVersion < 2) { + emitDestructuring(node, false); + } + else { + emit(node.name); + emitOptional(" = ", node.initializer); + } + } + else { + var initializer = node.initializer; + if (!initializer && languageVersion < 2) { + var isLetDefinedInLoop = (resolver.getNodeCheckFlags(node) & 16384) && + (getCombinedFlagsForIdentifier(node.name) & 16384); + if (isLetDefinedInLoop && + node.parent.parent.kind !== 200 && + node.parent.parent.kind !== 201) { + initializer = createVoidZero(); + } + } + var exportChanged = isNameOfExportedSourceLevelDeclarationInSystemExternalModule(node.name); + if (exportChanged) { + write(exportFunctionForFile + "(\""); + emitNodeWithCommentsAndWithoutSourcemap(node.name); + write("\", "); + } + emitModuleMemberName(node); + emitOptional(" = ", initializer); + if (exportChanged) { + write(")"); + } + } + } + function emitExportVariableAssignments(node) { + if (node.kind === 187) { + return; + } + var name = node.name; + if (name.kind === 69) { + emitExportMemberAssignments(name); + } + else if (ts.isBindingPattern(name)) { + ts.forEach(name.elements, emitExportVariableAssignments); + } + } + function getCombinedFlagsForIdentifier(node) { + if (!node.parent || (node.parent.kind !== 211 && node.parent.kind !== 163)) { + return 0; + } + return ts.getCombinedNodeFlags(node.parent); + } + function isES6ExportedDeclaration(node) { + return !!(node.flags & 1) && + modulekind === 5 && + node.parent.kind === 248; + } + function emitVariableStatement(node) { + var startIsEmitted = false; + if (node.flags & 1) { + if (isES6ExportedDeclaration(node)) { + write("export "); + startIsEmitted = tryEmitStartOfVariableDeclarationList(node.declarationList); + } + } + else { + startIsEmitted = tryEmitStartOfVariableDeclarationList(node.declarationList); + } + if (startIsEmitted) { + emitCommaList(node.declarationList.declarations); + write(";"); + } + else { + var atLeastOneItem = emitVariableDeclarationListSkippingUninitializedEntries(node.declarationList); + if (atLeastOneItem) { + write(";"); + } + } + if (modulekind !== 5 && node.parent === currentSourceFile) { + ts.forEach(node.declarationList.declarations, emitExportVariableAssignments); + } + } + function shouldEmitLeadingAndTrailingCommentsForVariableStatement(node) { + if (!(node.flags & 1)) { + return true; + } + if (isES6ExportedDeclaration(node)) { + return true; + } + for (var _a = 0, _b = node.declarationList.declarations; _a < _b.length; _a++) { + var declaration = _b[_a]; + if (declaration.initializer) { + return true; + } + } + return false; + } + function emitParameter(node) { + if (languageVersion < 2) { + if (ts.isBindingPattern(node.name)) { + var name_26 = createTempVariable(0); + if (!tempParameters) { + tempParameters = []; + } + tempParameters.push(name_26); + emit(name_26); + } + else { + emit(node.name); + } + } + else { + if (node.dotDotDotToken) { + write("..."); + } + emit(node.name); + emitOptional(" = ", node.initializer); + } + } + function emitDefaultValueAssignments(node) { + if (languageVersion < 2) { + var tempIndex = 0; + ts.forEach(node.parameters, function (parameter) { + if (parameter.dotDotDotToken) { + return; + } + var paramName = parameter.name, initializer = parameter.initializer; + if (ts.isBindingPattern(paramName)) { + var hasBindingElements = paramName.elements.length > 0; + if (hasBindingElements || initializer) { + writeLine(); + write("var "); + if (hasBindingElements) { + emitDestructuring(parameter, false, tempParameters[tempIndex]); + } + else { + emit(tempParameters[tempIndex]); + write(" = "); + emit(initializer); + } + write(";"); + tempIndex++; + } + } + else if (initializer) { + writeLine(); + emitStart(parameter); + write("if ("); + emitNodeWithoutSourceMap(paramName); + write(" === void 0)"); + emitEnd(parameter); + write(" { "); + emitStart(parameter); + emitNodeWithCommentsAndWithoutSourcemap(paramName); + write(" = "); + emitNodeWithCommentsAndWithoutSourcemap(initializer); + emitEnd(parameter); + write("; }"); + } + }); + } + } + function emitRestParameter(node) { + if (languageVersion < 2 && ts.hasRestParameter(node)) { + var restIndex = node.parameters.length - 1; + var restParam = node.parameters[restIndex]; + if (ts.isBindingPattern(restParam.name)) { + return; + } + var tempName = createTempVariable(268435456).text; + writeLine(); + emitLeadingComments(restParam); + emitStart(restParam); + write("var "); + emitNodeWithCommentsAndWithoutSourcemap(restParam.name); + write(" = [];"); + emitEnd(restParam); + emitTrailingComments(restParam); + writeLine(); + write("for ("); + emitStart(restParam); + write("var " + tempName + " = " + restIndex + ";"); + emitEnd(restParam); + write(" "); + emitStart(restParam); + write(tempName + " < arguments.length;"); + emitEnd(restParam); + write(" "); + emitStart(restParam); + write(tempName + "++"); + emitEnd(restParam); + write(") {"); + increaseIndent(); + writeLine(); + emitStart(restParam); + emitNodeWithCommentsAndWithoutSourcemap(restParam.name); + write("[" + tempName + " - " + restIndex + "] = arguments[" + tempName + "];"); + emitEnd(restParam); + decreaseIndent(); + writeLine(); + write("}"); + } + } + function emitAccessor(node) { + write(node.kind === 145 ? "get " : "set "); + emit(node.name); + emitSignatureAndBody(node); + } + function shouldEmitAsArrowFunction(node) { + return node.kind === 174 && languageVersion >= 2; + } + function emitDeclarationName(node) { + if (node.name) { + emitNodeWithCommentsAndWithoutSourcemap(node.name); + } + else { + write(getGeneratedNameForNode(node)); + } + } + function shouldEmitFunctionName(node) { + if (node.kind === 173) { + return !!node.name; + } + if (node.kind === 213) { + return !!node.name || languageVersion < 2; + } + } + function emitFunctionDeclaration(node) { + if (ts.nodeIsMissing(node.body)) { + return emitCommentsOnNotEmittedNode(node); + } + if (node.kind !== 143 && node.kind !== 142 && + node.parent && node.parent.kind !== 245 && + node.parent.kind !== 168) { + emitLeadingComments(node); + } + emitStart(node); + if (!shouldEmitAsArrowFunction(node)) { + if (isES6ExportedDeclaration(node)) { + write("export "); + if (node.flags & 1024) { + write("default "); + } + } + write("function"); + if (languageVersion >= 2 && node.asteriskToken) { + write("*"); + } + write(" "); + } + if (shouldEmitFunctionName(node)) { + emitDeclarationName(node); + } + emitSignatureAndBody(node); + if (modulekind !== 5 && node.kind === 213 && node.parent === currentSourceFile && node.name) { + emitExportMemberAssignments(node.name); + } + emitEnd(node); + if (node.kind !== 143 && node.kind !== 142) { + emitTrailingComments(node); + } + } + function emitCaptureThisForNodeIfNecessary(node) { + if (resolver.getNodeCheckFlags(node) & 4) { + writeLine(); + emitStart(node); + write("var _this = this;"); + emitEnd(node); + } + } + function emitSignatureParameters(node) { + increaseIndent(); + write("("); + if (node) { + var parameters = node.parameters; + var omitCount = languageVersion < 2 && ts.hasRestParameter(node) ? 1 : 0; + emitList(parameters, 0, parameters.length - omitCount, false, false); + } + write(")"); + decreaseIndent(); + } + function emitSignatureParametersForArrow(node) { + if (node.parameters.length === 1 && node.pos === node.parameters[0].pos) { + emit(node.parameters[0]); + return; + } + emitSignatureParameters(node); + } + function emitAsyncFunctionBodyForES6(node) { + var promiseConstructor = ts.getEntityNameFromTypeNode(node.type); + var isArrowFunction = node.kind === 174; + var hasLexicalArguments = (resolver.getNodeCheckFlags(node) & 4096) !== 0; + var args; + if (!isArrowFunction) { + write(" {"); + increaseIndent(); + writeLine(); + write("return"); + } + write(" __awaiter(this"); + if (hasLexicalArguments) { + write(", arguments"); + } + else { + write(", void 0"); + } + if (promiseConstructor) { + write(", "); + emitNodeWithoutSourceMap(promiseConstructor); + } + else { + write(", Promise"); + } + if (hasLexicalArguments) { + write(", function* (_arguments)"); + } + else { + write(", function* ()"); + } + emitFunctionBody(node); + write(")"); + if (!isArrowFunction) { + write(";"); + decreaseIndent(); + writeLine(); + write("}"); + } + } + function emitFunctionBody(node) { + if (!node.body) { + write(" { }"); + } + else { + if (node.body.kind === 192) { + emitBlockFunctionBody(node, node.body); + } + else { + emitExpressionFunctionBody(node, node.body); + } + } + } + function emitSignatureAndBody(node) { + var saveConvertedLoopState = convertedLoopState; + var saveTempFlags = tempFlags; + var saveTempVariables = tempVariables; + var saveTempParameters = tempParameters; + convertedLoopState = undefined; + tempFlags = 0; + tempVariables = undefined; + tempParameters = undefined; + if (shouldEmitAsArrowFunction(node)) { + emitSignatureParametersForArrow(node); + write(" =>"); + } + else { + emitSignatureParameters(node); + } + var isAsync = ts.isAsyncFunctionLike(node); + if (isAsync && languageVersion === 2) { + emitAsyncFunctionBodyForES6(node); + } + else { + emitFunctionBody(node); + } + if (!isES6ExportedDeclaration(node)) { + emitExportMemberAssignment(node); + } + ts.Debug.assert(convertedLoopState === undefined); + convertedLoopState = saveConvertedLoopState; + tempFlags = saveTempFlags; + tempVariables = saveTempVariables; + tempParameters = saveTempParameters; + } + function emitFunctionBodyPreamble(node) { + emitCaptureThisForNodeIfNecessary(node); + emitDefaultValueAssignments(node); + emitRestParameter(node); + } + function emitExpressionFunctionBody(node, body) { + if (languageVersion < 2 || node.flags & 512) { + emitDownLevelExpressionFunctionBody(node, body); + return; + } + write(" "); + var current = body; + while (current.kind === 171) { + current = current.expression; + } + emitParenthesizedIf(body, current.kind === 165); + } + function emitDownLevelExpressionFunctionBody(node, body) { + write(" {"); + scopeEmitStart(node); + increaseIndent(); + var outPos = writer.getTextPos(); + emitDetachedComments(node.body); + emitFunctionBodyPreamble(node); + var preambleEmitted = writer.getTextPos() !== outPos; + decreaseIndent(); + if (!preambleEmitted && nodeStartPositionsAreOnSameLine(node, body)) { + write(" "); + emitStart(body); + write("return "); + emit(body); + emitEnd(body); + write(";"); + emitTempDeclarations(false); + write(" "); + } + else { + increaseIndent(); + writeLine(); + emitLeadingComments(node.body); + write("return "); + emit(body); + write(";"); + emitTrailingComments(node.body); + emitTempDeclarations(true); + decreaseIndent(); + writeLine(); + } + emitStart(node.body); + write("}"); + emitEnd(node.body); + scopeEmitEnd(); + } + function emitBlockFunctionBody(node, body) { + write(" {"); + scopeEmitStart(node); + var initialTextPos = writer.getTextPos(); + increaseIndent(); + emitDetachedComments(body.statements); + var startIndex = emitDirectivePrologues(body.statements, true); + emitFunctionBodyPreamble(node); + decreaseIndent(); + var preambleEmitted = writer.getTextPos() !== initialTextPos; + if (!preambleEmitted && nodeEndIsOnSameLineAsNodeStart(body, body)) { + for (var _a = 0, _b = body.statements; _a < _b.length; _a++) { + var statement = _b[_a]; + write(" "); + emit(statement); + } + emitTempDeclarations(false); + write(" "); + emitLeadingCommentsOfPosition(body.statements.end); + } + else { + increaseIndent(); + emitLinesStartingAt(body.statements, startIndex); + emitTempDeclarations(true); + writeLine(); + emitLeadingCommentsOfPosition(body.statements.end); + decreaseIndent(); + } + emitToken(16, body.statements.end); + scopeEmitEnd(); + } + function findInitialSuperCall(ctor) { + if (ctor.body) { + var statement = ctor.body.statements[0]; + if (statement && statement.kind === 195) { + var expr = statement.expression; + if (expr && expr.kind === 168) { + var func = expr.expression; + if (func && func.kind === 95) { + return statement; + } + } + } + } + } + function emitParameterPropertyAssignments(node) { + ts.forEach(node.parameters, function (param) { + if (param.flags & 112) { + writeLine(); + emitStart(param); + emitStart(param.name); + write("this."); + emitNodeWithoutSourceMap(param.name); + emitEnd(param.name); + write(" = "); + emit(param.name); + write(";"); + emitEnd(param); + } + }); + } + function emitMemberAccessForPropertyName(memberName) { + if (memberName.kind === 9 || memberName.kind === 8) { + write("["); + emitNodeWithCommentsAndWithoutSourcemap(memberName); + write("]"); + } + else if (memberName.kind === 136) { + emitComputedPropertyName(memberName); + } + else { + write("."); + emitNodeWithCommentsAndWithoutSourcemap(memberName); + } + } + function getInitializedProperties(node, isStatic) { + var properties = []; + for (var _a = 0, _b = node.members; _a < _b.length; _a++) { + var member = _b[_a]; + if (member.kind === 141 && isStatic === ((member.flags & 128) !== 0) && member.initializer) { + properties.push(member); + } + } + return properties; + } + function emitPropertyDeclarations(node, properties) { + for (var _a = 0; _a < properties.length; _a++) { + var property = properties[_a]; + emitPropertyDeclaration(node, property); + } + } + function emitPropertyDeclaration(node, property, receiver, isExpression) { + writeLine(); + emitLeadingComments(property); + emitStart(property); + emitStart(property.name); + if (receiver) { + emit(receiver); + } + else { + if (property.flags & 128) { + emitDeclarationName(node); + } + else { + write("this"); + } + } + emitMemberAccessForPropertyName(property.name); + emitEnd(property.name); + write(" = "); + emit(property.initializer); + if (!isExpression) { + write(";"); + } + emitEnd(property); + emitTrailingComments(property); + } + function emitMemberFunctionsForES5AndLower(node) { + ts.forEach(node.members, function (member) { + if (member.kind === 191) { + writeLine(); + write(";"); + } + else if (member.kind === 143 || node.kind === 142) { + if (!member.body) { + return emitCommentsOnNotEmittedNode(member); + } + writeLine(); + emitLeadingComments(member); + emitStart(member); + emitStart(member.name); + emitClassMemberPrefix(node, member); + emitMemberAccessForPropertyName(member.name); + emitEnd(member.name); + write(" = "); + emitFunctionDeclaration(member); + emitEnd(member); + write(";"); + emitTrailingComments(member); + } + else if (member.kind === 145 || member.kind === 146) { + var accessors = ts.getAllAccessorDeclarations(node.members, member); + if (member === accessors.firstAccessor) { + writeLine(); + emitStart(member); + write("Object.defineProperty("); + emitStart(member.name); + emitClassMemberPrefix(node, member); + write(", "); + emitExpressionForPropertyName(member.name); + emitEnd(member.name); + write(", {"); + increaseIndent(); + if (accessors.getAccessor) { + writeLine(); + emitLeadingComments(accessors.getAccessor); + write("get: "); + emitStart(accessors.getAccessor); + write("function "); + emitSignatureAndBody(accessors.getAccessor); + emitEnd(accessors.getAccessor); + emitTrailingComments(accessors.getAccessor); + write(","); + } + if (accessors.setAccessor) { + writeLine(); + emitLeadingComments(accessors.setAccessor); + write("set: "); + emitStart(accessors.setAccessor); + write("function "); + emitSignatureAndBody(accessors.setAccessor); + emitEnd(accessors.setAccessor); + emitTrailingComments(accessors.setAccessor); + write(","); + } + writeLine(); + write("enumerable: true,"); + writeLine(); + write("configurable: true"); + decreaseIndent(); + writeLine(); + write("});"); + emitEnd(member); + } + } + }); + } + function emitMemberFunctionsForES6AndHigher(node) { + for (var _a = 0, _b = node.members; _a < _b.length; _a++) { + var member = _b[_a]; + if ((member.kind === 143 || node.kind === 142) && !member.body) { + emitCommentsOnNotEmittedNode(member); + } + else if (member.kind === 143 || + member.kind === 145 || + member.kind === 146) { + writeLine(); + emitLeadingComments(member); + emitStart(member); + if (member.flags & 128) { + write("static "); + } + if (member.kind === 145) { + write("get "); + } + else if (member.kind === 146) { + write("set "); + } + if (member.asteriskToken) { + write("*"); + } + emit(member.name); + emitSignatureAndBody(member); + emitEnd(member); + emitTrailingComments(member); + } + else if (member.kind === 191) { + writeLine(); + write(";"); + } + } + } + function emitConstructor(node, baseTypeElement) { + var saveConvertedLoopState = convertedLoopState; + var saveTempFlags = tempFlags; + var saveTempVariables = tempVariables; + var saveTempParameters = tempParameters; + convertedLoopState = undefined; + tempFlags = 0; + tempVariables = undefined; + tempParameters = undefined; + emitConstructorWorker(node, baseTypeElement); + ts.Debug.assert(convertedLoopState === undefined); + convertedLoopState = saveConvertedLoopState; + tempFlags = saveTempFlags; + tempVariables = saveTempVariables; + tempParameters = saveTempParameters; + } + function emitConstructorWorker(node, baseTypeElement) { + var hasInstancePropertyWithInitializer = false; + ts.forEach(node.members, function (member) { + if (member.kind === 144 && !member.body) { + emitCommentsOnNotEmittedNode(member); + } + if (member.kind === 141 && member.initializer && (member.flags & 128) === 0) { + hasInstancePropertyWithInitializer = true; + } + }); + var ctor = ts.getFirstConstructorWithBody(node); + if (languageVersion >= 2 && !ctor && !hasInstancePropertyWithInitializer) { + return; + } + if (ctor) { + emitLeadingComments(ctor); + } + emitStart(ctor || node); + if (languageVersion < 2) { + write("function "); + emitDeclarationName(node); + emitSignatureParameters(ctor); + } + else { + write("constructor"); + if (ctor) { + emitSignatureParameters(ctor); + } + else { + if (baseTypeElement) { + write("(...args)"); + } + else { + write("()"); + } + } + } + var startIndex = 0; + write(" {"); + scopeEmitStart(node, "constructor"); + increaseIndent(); + if (ctor) { + startIndex = emitDirectivePrologues(ctor.body.statements, true); + emitDetachedComments(ctor.body.statements); + } + emitCaptureThisForNodeIfNecessary(node); + var superCall; + if (ctor) { + emitDefaultValueAssignments(ctor); + emitRestParameter(ctor); + if (baseTypeElement) { + superCall = findInitialSuperCall(ctor); + if (superCall) { + writeLine(); + emit(superCall); + } + } + emitParameterPropertyAssignments(ctor); + } + else { + if (baseTypeElement) { + writeLine(); + emitStart(baseTypeElement); + if (languageVersion < 2) { + write("_super.apply(this, arguments);"); + } + else { + write("super(...args);"); + } + emitEnd(baseTypeElement); + } + } + emitPropertyDeclarations(node, getInitializedProperties(node, false)); + if (ctor) { + var statements = ctor.body.statements; + if (superCall) { + statements = statements.slice(1); + } + emitLinesStartingAt(statements, startIndex); + } + emitTempDeclarations(true); + writeLine(); + if (ctor) { + emitLeadingCommentsOfPosition(ctor.body.statements.end); + } + decreaseIndent(); + emitToken(16, ctor ? ctor.body.statements.end : node.members.end); + scopeEmitEnd(); + emitEnd(ctor || node); + if (ctor) { + emitTrailingComments(ctor); + } + } + function emitClassExpression(node) { + return emitClassLikeDeclaration(node); + } + function emitClassDeclaration(node) { + return emitClassLikeDeclaration(node); + } + function emitClassLikeDeclaration(node) { + if (languageVersion < 2) { + emitClassLikeDeclarationBelowES6(node); + } + else { + emitClassLikeDeclarationForES6AndHigher(node); + } + if (modulekind !== 5 && node.parent === currentSourceFile && node.name) { + emitExportMemberAssignments(node.name); + } + } + function emitClassLikeDeclarationForES6AndHigher(node) { + var thisNodeIsDecorated = ts.nodeIsDecorated(node); + if (node.kind === 214) { + if (thisNodeIsDecorated) { + if (isES6ExportedDeclaration(node) && !(node.flags & 1024)) { + write("export "); + } + write("let "); + emitDeclarationName(node); + write(" = "); + } + else if (isES6ExportedDeclaration(node)) { + write("export "); + if (node.flags & 1024) { + write("default "); + } + } + } + var staticProperties = getInitializedProperties(node, true); + var isClassExpressionWithStaticProperties = staticProperties.length > 0 && node.kind === 186; + var tempVariable; + if (isClassExpressionWithStaticProperties) { + tempVariable = createAndRecordTempVariable(0); + write("("); + increaseIndent(); + emit(tempVariable); + write(" = "); + } + write("class"); + if ((node.name || (node.flags & 1024 && staticProperties.length > 0)) && !thisNodeIsDecorated) { + write(" "); + emitDeclarationName(node); + } + var baseTypeNode = ts.getClassExtendsHeritageClauseElement(node); + if (baseTypeNode) { + write(" extends "); + emit(baseTypeNode.expression); + } + write(" {"); + increaseIndent(); + scopeEmitStart(node); + writeLine(); + emitConstructor(node, baseTypeNode); + emitMemberFunctionsForES6AndHigher(node); + decreaseIndent(); + writeLine(); + emitToken(16, node.members.end); + scopeEmitEnd(); + if (thisNodeIsDecorated) { + write(";"); + } + if (isClassExpressionWithStaticProperties) { + for (var _a = 0; _a < staticProperties.length; _a++) { + var property = staticProperties[_a]; + write(","); + writeLine(); + emitPropertyDeclaration(node, property, tempVariable, true); + } + write(","); + writeLine(); + emit(tempVariable); + decreaseIndent(); + write(")"); + } + else { + writeLine(); + emitPropertyDeclarations(node, staticProperties); + emitDecoratorsOfClass(node); + } + if (!isES6ExportedDeclaration(node) && (node.flags & 1)) { + writeLine(); + emitStart(node); + emitModuleMemberName(node); + write(" = "); + emitDeclarationName(node); + emitEnd(node); + write(";"); + } + else if (isES6ExportedDeclaration(node) && (node.flags & 1024) && thisNodeIsDecorated) { + writeLine(); + write("export default "); + emitDeclarationName(node); + write(";"); + } + } + function emitClassLikeDeclarationBelowES6(node) { + if (node.kind === 214) { + if (!shouldHoistDeclarationInSystemJsModule(node)) { + write("var "); + } + emitDeclarationName(node); + write(" = "); + } + write("(function ("); + var baseTypeNode = ts.getClassExtendsHeritageClauseElement(node); + if (baseTypeNode) { + write("_super"); + } + write(") {"); + var saveTempFlags = tempFlags; + var saveTempVariables = tempVariables; + var saveTempParameters = tempParameters; + var saveComputedPropertyNamesToGeneratedNames = computedPropertyNamesToGeneratedNames; + var saveConvertedLoopState = convertedLoopState; + convertedLoopState = undefined; + tempFlags = 0; + tempVariables = undefined; + tempParameters = undefined; + computedPropertyNamesToGeneratedNames = undefined; + increaseIndent(); + scopeEmitStart(node); + if (baseTypeNode) { + writeLine(); + emitStart(baseTypeNode); + write("__extends("); + emitDeclarationName(node); + write(", _super);"); + emitEnd(baseTypeNode); + } + writeLine(); + emitConstructor(node, baseTypeNode); + emitMemberFunctionsForES5AndLower(node); + emitPropertyDeclarations(node, getInitializedProperties(node, true)); + writeLine(); + emitDecoratorsOfClass(node); + writeLine(); + emitToken(16, node.members.end, function () { + write("return "); + emitDeclarationName(node); + }); + write(";"); + emitTempDeclarations(true); + ts.Debug.assert(convertedLoopState === undefined); + convertedLoopState = saveConvertedLoopState; + tempFlags = saveTempFlags; + tempVariables = saveTempVariables; + tempParameters = saveTempParameters; + computedPropertyNamesToGeneratedNames = saveComputedPropertyNamesToGeneratedNames; + decreaseIndent(); + writeLine(); + emitToken(16, node.members.end); + scopeEmitEnd(); + emitStart(node); + write(")("); + if (baseTypeNode) { + emit(baseTypeNode.expression); + } + write(")"); + if (node.kind === 214) { + write(";"); + } + emitEnd(node); + if (node.kind === 214) { + emitExportMemberAssignment(node); + } + } + function emitClassMemberPrefix(node, member) { + emitDeclarationName(node); + if (!(member.flags & 128)) { + write(".prototype"); + } + } + function emitDecoratorsOfClass(node) { + emitDecoratorsOfMembers(node, 0); + emitDecoratorsOfMembers(node, 128); + emitDecoratorsOfConstructor(node); + } + function emitDecoratorsOfConstructor(node) { + var decorators = node.decorators; + var constructor = ts.getFirstConstructorWithBody(node); + var hasDecoratedParameters = constructor && ts.forEach(constructor.parameters, ts.nodeIsDecorated); + if (!decorators && !hasDecoratedParameters) { + return; + } + writeLine(); + emitStart(node); + emitDeclarationName(node); + write(" = __decorate(["); + increaseIndent(); + writeLine(); + var decoratorCount = decorators ? decorators.length : 0; + var argumentsWritten = emitList(decorators, 0, decoratorCount, true, false, false, true, function (decorator) { + emitStart(decorator); + emit(decorator.expression); + emitEnd(decorator); + }); + argumentsWritten += emitDecoratorsOfParameters(constructor, argumentsWritten > 0); + emitSerializedTypeMetadata(node, argumentsWritten >= 0); + decreaseIndent(); + writeLine(); + write("], "); + emitDeclarationName(node); + write(");"); + emitEnd(node); + writeLine(); + } + function emitDecoratorsOfMembers(node, staticFlag) { + for (var _a = 0, _b = node.members; _a < _b.length; _a++) { + var member = _b[_a]; + if ((member.flags & 128) !== staticFlag) { + continue; + } + if (!ts.nodeCanBeDecorated(member)) { + continue; + } + if (!ts.nodeOrChildIsDecorated(member)) { + continue; + } + var decorators = void 0; + var functionLikeMember = void 0; + if (ts.isAccessor(member)) { + var accessors = ts.getAllAccessorDeclarations(node.members, member); + if (member !== accessors.firstAccessor) { + continue; + } + decorators = accessors.firstAccessor.decorators; + if (!decorators && accessors.secondAccessor) { + decorators = accessors.secondAccessor.decorators; + } + functionLikeMember = accessors.setAccessor; + } + else { + decorators = member.decorators; + if (member.kind === 143) { + functionLikeMember = member; + } + } + writeLine(); + emitStart(member); + write("__decorate(["); + increaseIndent(); + writeLine(); + var decoratorCount = decorators ? decorators.length : 0; + var argumentsWritten = emitList(decorators, 0, decoratorCount, true, false, false, true, function (decorator) { + emitStart(decorator); + emit(decorator.expression); + emitEnd(decorator); + }); + argumentsWritten += emitDecoratorsOfParameters(functionLikeMember, argumentsWritten > 0); + emitSerializedTypeMetadata(member, argumentsWritten > 0); + decreaseIndent(); + writeLine(); + write("], "); + emitStart(member.name); + emitClassMemberPrefix(node, member); + write(", "); + emitExpressionForPropertyName(member.name); + emitEnd(member.name); + if (languageVersion > 0) { + if (member.kind !== 141) { + write(", null"); + } + else { + write(", void 0"); + } + } + write(");"); + emitEnd(member); + writeLine(); + } + } + function emitDecoratorsOfParameters(node, leadingComma) { + var argumentsWritten = 0; + if (node) { + var parameterIndex = 0; + for (var _a = 0, _b = node.parameters; _a < _b.length; _a++) { + var parameter = _b[_a]; + if (ts.nodeIsDecorated(parameter)) { + var decorators = parameter.decorators; + argumentsWritten += emitList(decorators, 0, decorators.length, true, false, leadingComma, true, function (decorator) { + emitStart(decorator); + write("__param(" + parameterIndex + ", "); + emit(decorator.expression); + write(")"); + emitEnd(decorator); + }); + leadingComma = true; + } + ++parameterIndex; + } + } + return argumentsWritten; + } + function shouldEmitTypeMetadata(node) { + switch (node.kind) { + case 143: + case 145: + case 146: + case 141: + return true; + } + return false; + } + function shouldEmitReturnTypeMetadata(node) { + switch (node.kind) { + case 143: + return true; + } + return false; + } + function shouldEmitParamTypesMetadata(node) { + switch (node.kind) { + case 214: + case 143: + case 146: + return true; + } + return false; + } + function emitSerializedTypeOfNode(node) { + switch (node.kind) { + case 214: + write("Function"); + return; + case 141: + emitSerializedTypeNode(node.type); + return; + case 138: + emitSerializedTypeNode(node.type); + return; + case 145: + emitSerializedTypeNode(node.type); + return; + case 146: + emitSerializedTypeNode(ts.getSetAccessorTypeAnnotationNode(node)); + return; + } + if (ts.isFunctionLike(node)) { + write("Function"); + return; + } + write("void 0"); + } + function emitSerializedTypeNode(node) { + if (node) { + switch (node.kind) { + case 103: + write("void 0"); + return; + case 160: + emitSerializedTypeNode(node.type); + return; + case 152: + case 153: + write("Function"); + return; + case 156: + case 157: + write("Array"); + return; + case 150: + case 120: + write("Boolean"); + return; + case 130: + case 9: + write("String"); + return; + case 128: + write("Number"); + return; + case 131: + write("Symbol"); + return; + case 151: + emitSerializedTypeReferenceNode(node); + return; + case 154: + case 155: + case 158: + case 159: + case 117: + break; + default: + ts.Debug.fail("Cannot serialize unexpected type node."); + break; + } + } + write("Object"); + } + function emitSerializedTypeReferenceNode(node) { + var location = node.parent; + while (ts.isDeclaration(location) || ts.isTypeNode(location)) { + location = location.parent; + } + var typeName = ts.cloneEntityName(node.typeName); + typeName.parent = location; + var result = resolver.getTypeReferenceSerializationKind(typeName); + switch (result) { + case ts.TypeReferenceSerializationKind.Unknown: + var temp = createAndRecordTempVariable(0); + write("(typeof ("); + emitNodeWithoutSourceMap(temp); + write(" = "); + emitEntityNameAsExpression(typeName, true); + write(") === 'function' && "); + emitNodeWithoutSourceMap(temp); + write(") || Object"); + break; + case ts.TypeReferenceSerializationKind.TypeWithConstructSignatureAndValue: + emitEntityNameAsExpression(typeName, false); + break; + case ts.TypeReferenceSerializationKind.VoidType: + write("void 0"); + break; + case ts.TypeReferenceSerializationKind.BooleanType: + write("Boolean"); + break; + case ts.TypeReferenceSerializationKind.NumberLikeType: + write("Number"); + break; + case ts.TypeReferenceSerializationKind.StringLikeType: + write("String"); + break; + case ts.TypeReferenceSerializationKind.ArrayLikeType: + write("Array"); + break; + case ts.TypeReferenceSerializationKind.ESSymbolType: + if (languageVersion < 2) { + write("typeof Symbol === 'function' ? Symbol : Object"); + } + else { + write("Symbol"); + } + break; + case ts.TypeReferenceSerializationKind.TypeWithCallSignature: + write("Function"); + break; + case ts.TypeReferenceSerializationKind.ObjectType: + write("Object"); + break; + } + } + function emitSerializedParameterTypesOfNode(node) { + if (node) { + var valueDeclaration; + if (node.kind === 214) { + valueDeclaration = ts.getFirstConstructorWithBody(node); + } + else if (ts.isFunctionLike(node) && ts.nodeIsPresent(node.body)) { + valueDeclaration = node; + } + if (valueDeclaration) { + var parameters = valueDeclaration.parameters; + var parameterCount = parameters.length; + if (parameterCount > 0) { + for (var i = 0; i < parameterCount; i++) { + if (i > 0) { + write(", "); + } + if (parameters[i].dotDotDotToken) { + var parameterType = parameters[i].type; + if (parameterType.kind === 156) { + parameterType = parameterType.elementType; + } + else if (parameterType.kind === 151 && parameterType.typeArguments && parameterType.typeArguments.length === 1) { + parameterType = parameterType.typeArguments[0]; + } + else { + parameterType = undefined; + } + emitSerializedTypeNode(parameterType); + } + else { + emitSerializedTypeOfNode(parameters[i]); + } + } + } + } + } + } + function emitSerializedReturnTypeOfNode(node) { + if (node && ts.isFunctionLike(node) && node.type) { + emitSerializedTypeNode(node.type); + return; + } + write("void 0"); + } + function emitSerializedTypeMetadata(node, writeComma) { + var argumentsWritten = 0; + if (compilerOptions.emitDecoratorMetadata) { + if (shouldEmitTypeMetadata(node)) { + if (writeComma) { + write(", "); + } + writeLine(); + write("__metadata('design:type', "); + emitSerializedTypeOfNode(node); + write(")"); + argumentsWritten++; + } + if (shouldEmitParamTypesMetadata(node)) { + if (writeComma || argumentsWritten) { + write(", "); + } + writeLine(); + write("__metadata('design:paramtypes', ["); + emitSerializedParameterTypesOfNode(node); + write("])"); + argumentsWritten++; + } + if (shouldEmitReturnTypeMetadata(node)) { + if (writeComma || argumentsWritten) { + write(", "); + } + writeLine(); + write("__metadata('design:returntype', "); + emitSerializedReturnTypeOfNode(node); + write(")"); + argumentsWritten++; + } + } + return argumentsWritten; + } + function emitInterfaceDeclaration(node) { + emitCommentsOnNotEmittedNode(node); + } + function shouldEmitEnumDeclaration(node) { + var isConstEnum = ts.isConst(node); + return !isConstEnum || compilerOptions.preserveConstEnums || compilerOptions.isolatedModules; + } + function emitEnumDeclaration(node) { + if (!shouldEmitEnumDeclaration(node)) { + return; + } + if (!shouldHoistDeclarationInSystemJsModule(node)) { + if (!(node.flags & 1) || isES6ExportedDeclaration(node)) { + emitStart(node); + if (isES6ExportedDeclaration(node)) { + write("export "); + } + write("var "); + emit(node.name); + emitEnd(node); + write(";"); + } + } + writeLine(); + emitStart(node); + write("(function ("); + emitStart(node.name); + write(getGeneratedNameForNode(node)); + emitEnd(node.name); + write(") {"); + increaseIndent(); + scopeEmitStart(node); + emitLines(node.members); + decreaseIndent(); + writeLine(); + emitToken(16, node.members.end); + scopeEmitEnd(); + write(")("); + emitModuleMemberName(node); + write(" || ("); + emitModuleMemberName(node); + write(" = {}));"); + emitEnd(node); + if (!isES6ExportedDeclaration(node) && node.flags & 1 && !shouldHoistDeclarationInSystemJsModule(node)) { + writeLine(); + emitStart(node); + write("var "); + emit(node.name); + write(" = "); + emitModuleMemberName(node); + emitEnd(node); + write(";"); + } + if (modulekind !== 5 && node.parent === currentSourceFile) { + if (modulekind === 4 && (node.flags & 1)) { + writeLine(); + write(exportFunctionForFile + "(\""); + emitDeclarationName(node); + write("\", "); + emitDeclarationName(node); + write(");"); + } + emitExportMemberAssignments(node.name); + } + } + function emitEnumMember(node) { + var enumParent = node.parent; + emitStart(node); + write(getGeneratedNameForNode(enumParent)); + write("["); + write(getGeneratedNameForNode(enumParent)); + write("["); + emitExpressionForPropertyName(node.name); + write("] = "); + writeEnumMemberDeclarationValue(node); + write("] = "); + emitExpressionForPropertyName(node.name); + emitEnd(node); + write(";"); + } + function writeEnumMemberDeclarationValue(member) { + var value = resolver.getConstantValue(member); + if (value !== undefined) { + write(value.toString()); + return; + } + else if (member.initializer) { + emit(member.initializer); + } + else { + write("undefined"); + } + } + function getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration) { + if (moduleDeclaration.body.kind === 218) { + var recursiveInnerModule = getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration.body); + return recursiveInnerModule || moduleDeclaration.body; + } + } + function shouldEmitModuleDeclaration(node) { + return ts.isInstantiatedModule(node, compilerOptions.preserveConstEnums || compilerOptions.isolatedModules); + } + function isModuleMergedWithES6Class(node) { + return languageVersion === 2 && !!(resolver.getNodeCheckFlags(node) & 32768); + } + function emitModuleDeclaration(node) { + var shouldEmit = shouldEmitModuleDeclaration(node); + if (!shouldEmit) { + return emitCommentsOnNotEmittedNode(node); + } + var hoistedInDeclarationScope = shouldHoistDeclarationInSystemJsModule(node); + var emitVarForModule = !hoistedInDeclarationScope && !isModuleMergedWithES6Class(node); + if (emitVarForModule) { + emitStart(node); + if (isES6ExportedDeclaration(node)) { + write("export "); + } + write("var "); + emit(node.name); + write(";"); + emitEnd(node); + writeLine(); + } + emitStart(node); + write("(function ("); + emitStart(node.name); + write(getGeneratedNameForNode(node)); + emitEnd(node.name); + write(") "); + if (node.body.kind === 219) { + var saveConvertedLoopState = convertedLoopState; + var saveTempFlags = tempFlags; + var saveTempVariables = tempVariables; + convertedLoopState = undefined; + tempFlags = 0; + tempVariables = undefined; + emit(node.body); + ts.Debug.assert(convertedLoopState === undefined); + convertedLoopState = saveConvertedLoopState; + tempFlags = saveTempFlags; + tempVariables = saveTempVariables; + } + else { + write("{"); + increaseIndent(); + scopeEmitStart(node); + emitCaptureThisForNodeIfNecessary(node); + writeLine(); + emit(node.body); + decreaseIndent(); + writeLine(); + var moduleBlock = getInnerMostModuleDeclarationFromDottedModule(node).body; + emitToken(16, moduleBlock.statements.end); + scopeEmitEnd(); + } + write(")("); + if ((node.flags & 1) && !isES6ExportedDeclaration(node)) { + emit(node.name); + write(" = "); + } + emitModuleMemberName(node); + write(" || ("); + emitModuleMemberName(node); + write(" = {}));"); + emitEnd(node); + if (!isES6ExportedDeclaration(node) && node.name.kind === 69 && node.parent === currentSourceFile) { + if (modulekind === 4 && (node.flags & 1)) { + writeLine(); + write(exportFunctionForFile + "(\""); + emitDeclarationName(node); + write("\", "); + emitDeclarationName(node); + write(");"); + } + emitExportMemberAssignments(node.name); + } + } + function tryRenameExternalModule(moduleName) { + if (currentSourceFile.renamedDependencies && ts.hasProperty(currentSourceFile.renamedDependencies, moduleName.text)) { + return "\"" + currentSourceFile.renamedDependencies[moduleName.text] + "\""; + } + return undefined; + } + function emitRequire(moduleName) { + if (moduleName.kind === 9) { + write("require("); + var text = tryRenameExternalModule(moduleName); + if (text) { + write(text); + } + else { + emitStart(moduleName); + emitLiteral(moduleName); + emitEnd(moduleName); + } + emitToken(18, moduleName.end); + } + else { + write("require()"); + } + } + function getNamespaceDeclarationNode(node) { + if (node.kind === 221) { + return node; + } + var importClause = node.importClause; + if (importClause && importClause.namedBindings && importClause.namedBindings.kind === 224) { + return importClause.namedBindings; + } + } + function isDefaultImport(node) { + return node.kind === 222 && node.importClause && !!node.importClause.name; + } + function emitExportImportAssignments(node) { + if (ts.isAliasSymbolDeclaration(node) && resolver.isValueAliasDeclaration(node)) { + emitExportMemberAssignments(node.name); + } + ts.forEachChild(node, emitExportImportAssignments); + } + function emitImportDeclaration(node) { + if (modulekind !== 5) { + return emitExternalImportDeclaration(node); + } + if (node.importClause) { + var shouldEmitDefaultBindings = resolver.isReferencedAliasDeclaration(node.importClause); + var shouldEmitNamedBindings = node.importClause.namedBindings && resolver.isReferencedAliasDeclaration(node.importClause.namedBindings, true); + if (shouldEmitDefaultBindings || shouldEmitNamedBindings) { + write("import "); + emitStart(node.importClause); + if (shouldEmitDefaultBindings) { + emit(node.importClause.name); + if (shouldEmitNamedBindings) { + write(", "); + } + } + if (shouldEmitNamedBindings) { + emitLeadingComments(node.importClause.namedBindings); + emitStart(node.importClause.namedBindings); + if (node.importClause.namedBindings.kind === 224) { + write("* as "); + emit(node.importClause.namedBindings.name); + } + else { + write("{ "); + emitExportOrImportSpecifierList(node.importClause.namedBindings.elements, resolver.isReferencedAliasDeclaration); + write(" }"); + } + emitEnd(node.importClause.namedBindings); + emitTrailingComments(node.importClause.namedBindings); + } + emitEnd(node.importClause); + write(" from "); + emit(node.moduleSpecifier); + write(";"); + } + } + else { + write("import "); + emit(node.moduleSpecifier); + write(";"); + } + } + function emitExternalImportDeclaration(node) { + if (ts.contains(externalImports, node)) { + var isExportedImport = node.kind === 221 && (node.flags & 1) !== 0; + var namespaceDeclaration = getNamespaceDeclarationNode(node); + if (modulekind !== 2) { + emitLeadingComments(node); + emitStart(node); + if (namespaceDeclaration && !isDefaultImport(node)) { + if (!isExportedImport) + write("var "); + emitModuleMemberName(namespaceDeclaration); + write(" = "); + } + else { + var isNakedImport = 222 && !node.importClause; + if (!isNakedImport) { + write("var "); + write(getGeneratedNameForNode(node)); + write(" = "); + } + } + emitRequire(ts.getExternalModuleName(node)); + if (namespaceDeclaration && isDefaultImport(node)) { + write(", "); + emitModuleMemberName(namespaceDeclaration); + write(" = "); + write(getGeneratedNameForNode(node)); + } + write(";"); + emitEnd(node); + emitExportImportAssignments(node); + emitTrailingComments(node); + } + else { + if (isExportedImport) { + emitModuleMemberName(namespaceDeclaration); + write(" = "); + emit(namespaceDeclaration.name); + write(";"); + } + else if (namespaceDeclaration && isDefaultImport(node)) { + write("var "); + emitModuleMemberName(namespaceDeclaration); + write(" = "); + write(getGeneratedNameForNode(node)); + write(";"); + } + emitExportImportAssignments(node); + } + } + } + function emitImportEqualsDeclaration(node) { + if (ts.isExternalModuleImportEqualsDeclaration(node)) { + emitExternalImportDeclaration(node); + return; + } + if (resolver.isReferencedAliasDeclaration(node) || + (!ts.isExternalModule(currentSourceFile) && resolver.isTopLevelValueImportEqualsWithEntityName(node))) { + emitLeadingComments(node); + emitStart(node); + var variableDeclarationIsHoisted = shouldHoistVariable(node, true); + var isExported = isSourceFileLevelDeclarationInSystemJsModule(node, true); + if (!variableDeclarationIsHoisted) { + ts.Debug.assert(!isExported); + if (isES6ExportedDeclaration(node)) { + write("export "); + write("var "); + } + else if (!(node.flags & 1)) { + write("var "); + } + } + if (isExported) { + write(exportFunctionForFile + "(\""); + emitNodeWithoutSourceMap(node.name); + write("\", "); + } + emitModuleMemberName(node); + write(" = "); + emit(node.moduleReference); + if (isExported) { + write(")"); + } + write(";"); + emitEnd(node); + emitExportImportAssignments(node); + emitTrailingComments(node); + } + } + function emitExportDeclaration(node) { + ts.Debug.assert(modulekind !== 4); + if (modulekind !== 5) { + if (node.moduleSpecifier && (!node.exportClause || resolver.isValueAliasDeclaration(node))) { + emitStart(node); + var generatedName = getGeneratedNameForNode(node); + if (node.exportClause) { + if (modulekind !== 2) { + write("var "); + write(generatedName); + write(" = "); + emitRequire(ts.getExternalModuleName(node)); + write(";"); + } + for (var _a = 0, _b = node.exportClause.elements; _a < _b.length; _a++) { + var specifier = _b[_a]; + if (resolver.isValueAliasDeclaration(specifier)) { + writeLine(); + emitStart(specifier); + emitContainingModuleName(specifier); + write("."); + emitNodeWithCommentsAndWithoutSourcemap(specifier.name); + write(" = "); + write(generatedName); + write("."); + emitNodeWithCommentsAndWithoutSourcemap(specifier.propertyName || specifier.name); + write(";"); + emitEnd(specifier); + } + } + } + else { + writeLine(); + write("__export("); + if (modulekind !== 2) { + emitRequire(ts.getExternalModuleName(node)); + } + else { + write(generatedName); + } + write(");"); + } + emitEnd(node); + } + } + else { + if (!node.exportClause || resolver.isValueAliasDeclaration(node)) { + write("export "); + if (node.exportClause) { + write("{ "); + emitExportOrImportSpecifierList(node.exportClause.elements, resolver.isValueAliasDeclaration); + write(" }"); + } + else { + write("*"); + } + if (node.moduleSpecifier) { + write(" from "); + emit(node.moduleSpecifier); + } + write(";"); + } + } + } + function emitExportOrImportSpecifierList(specifiers, shouldEmit) { + ts.Debug.assert(modulekind === 5); + var needsComma = false; + for (var _a = 0; _a < specifiers.length; _a++) { + var specifier = specifiers[_a]; + if (shouldEmit(specifier)) { + if (needsComma) { + write(", "); + } + if (specifier.propertyName) { + emit(specifier.propertyName); + write(" as "); + } + emit(specifier.name); + needsComma = true; + } + } + } + function emitExportAssignment(node) { + if (!node.isExportEquals && resolver.isValueAliasDeclaration(node)) { + if (modulekind === 5) { + writeLine(); + emitStart(node); + write("export default "); + var expression = node.expression; + emit(expression); + if (expression.kind !== 213 && + expression.kind !== 214) { + write(";"); + } + emitEnd(node); + } + else { + writeLine(); + emitStart(node); + if (modulekind === 4) { + write(exportFunctionForFile + "(\"default\","); + emit(node.expression); + write(")"); + } + else { + emitEs6ExportDefaultCompat(node); + emitContainingModuleName(node); + if (languageVersion === 0) { + write("[\"default\"] = "); + } + else { + write(".default = "); + } + emit(node.expression); + } + write(";"); + emitEnd(node); + } + } + } + function collectExternalModuleInfo(sourceFile) { + externalImports = []; + exportSpecifiers = {}; + exportEquals = undefined; + hasExportStars = false; + for (var _a = 0, _b = sourceFile.statements; _a < _b.length; _a++) { + var node = _b[_a]; + switch (node.kind) { + case 222: + if (!node.importClause || + resolver.isReferencedAliasDeclaration(node.importClause, true)) { + externalImports.push(node); + } + break; + case 221: + if (node.moduleReference.kind === 232 && resolver.isReferencedAliasDeclaration(node)) { + externalImports.push(node); + } + break; + case 228: + if (node.moduleSpecifier) { + if (!node.exportClause) { + externalImports.push(node); + hasExportStars = true; + } + else if (resolver.isValueAliasDeclaration(node)) { + externalImports.push(node); + } + } + else { + for (var _c = 0, _d = node.exportClause.elements; _c < _d.length; _c++) { + var specifier = _d[_c]; + var name_27 = (specifier.propertyName || specifier.name).text; + (exportSpecifiers[name_27] || (exportSpecifiers[name_27] = [])).push(specifier); + } + } + break; + case 227: + if (node.isExportEquals && !exportEquals) { + exportEquals = node; + } + break; + } + } + } + function emitExportStarHelper() { + if (hasExportStars) { + writeLine(); + write("function __export(m) {"); + increaseIndent(); + writeLine(); + write("for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];"); + decreaseIndent(); + writeLine(); + write("}"); + } + } + function getLocalNameForExternalImport(node) { + var namespaceDeclaration = getNamespaceDeclarationNode(node); + if (namespaceDeclaration && !isDefaultImport(node)) { + return ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, namespaceDeclaration.name); + } + if (node.kind === 222 && node.importClause) { + return getGeneratedNameForNode(node); + } + if (node.kind === 228 && node.moduleSpecifier) { + return getGeneratedNameForNode(node); + } + } + function getExternalModuleNameText(importNode) { + var moduleName = ts.getExternalModuleName(importNode); + if (moduleName.kind === 9) { + return tryRenameExternalModule(moduleName) || getLiteralText(moduleName); + } + return undefined; + } + function emitVariableDeclarationsForImports() { + if (externalImports.length === 0) { + return; + } + writeLine(); + var started = false; + for (var _a = 0; _a < externalImports.length; _a++) { + var importNode = externalImports[_a]; + var skipNode = importNode.kind === 228 || + (importNode.kind === 222 && !importNode.importClause); + if (skipNode) { + continue; + } + if (!started) { + write("var "); + started = true; + } + else { + write(", "); + } + write(getLocalNameForExternalImport(importNode)); + } + if (started) { + write(";"); + } + } + function emitLocalStorageForExportedNamesIfNecessary(exportedDeclarations) { + if (!hasExportStars) { + return undefined; + } + if (!exportedDeclarations && ts.isEmpty(exportSpecifiers)) { + var hasExportDeclarationWithExportClause = false; + for (var _a = 0; _a < externalImports.length; _a++) { + var externalImport = externalImports[_a]; + if (externalImport.kind === 228 && externalImport.exportClause) { + hasExportDeclarationWithExportClause = true; + break; + } + } + if (!hasExportDeclarationWithExportClause) { + return emitExportStarFunction(undefined); + } + } + var exportedNamesStorageRef = makeUniqueName("exportedNames"); + writeLine(); + write("var " + exportedNamesStorageRef + " = {"); + increaseIndent(); + var started = false; + if (exportedDeclarations) { + for (var i = 0; i < exportedDeclarations.length; ++i) { + writeExportedName(exportedDeclarations[i]); + } + } + if (exportSpecifiers) { + for (var n in exportSpecifiers) { + for (var _b = 0, _c = exportSpecifiers[n]; _b < _c.length; _b++) { + var specifier = _c[_b]; + writeExportedName(specifier.name); + } + } + } + for (var _d = 0; _d < externalImports.length; _d++) { + var externalImport = externalImports[_d]; + if (externalImport.kind !== 228) { + continue; + } + var exportDecl = externalImport; + if (!exportDecl.exportClause) { + continue; + } + for (var _e = 0, _f = exportDecl.exportClause.elements; _e < _f.length; _e++) { + var element = _f[_e]; + writeExportedName(element.name || element.propertyName); + } + } + decreaseIndent(); + writeLine(); + write("};"); + return emitExportStarFunction(exportedNamesStorageRef); + function emitExportStarFunction(localNames) { + var exportStarFunction = makeUniqueName("exportStar"); + writeLine(); + write("function " + exportStarFunction + "(m) {"); + increaseIndent(); + writeLine(); + write("var exports = {};"); + writeLine(); + write("for(var n in m) {"); + increaseIndent(); + writeLine(); + write("if (n !== \"default\""); + if (localNames) { + write("&& !" + localNames + ".hasOwnProperty(n)"); + } + write(") exports[n] = m[n];"); + decreaseIndent(); + writeLine(); + write("}"); + writeLine(); + write(exportFunctionForFile + "(exports);"); + decreaseIndent(); + writeLine(); + write("}"); + return exportStarFunction; + } + function writeExportedName(node) { + if (node.kind !== 69 && node.flags & 1024) { + return; + } + if (started) { + write(","); + } + else { + started = true; + } + writeLine(); + write("'"); + if (node.kind === 69) { + emitNodeWithCommentsAndWithoutSourcemap(node); + } + else { + emitDeclarationName(node); + } + write("': true"); + } + } + function processTopLevelVariableAndFunctionDeclarations(node) { + var hoistedVars; + var hoistedFunctionDeclarations; + var exportedDeclarations; + visit(node); + if (hoistedVars) { + writeLine(); + write("var "); + var seen = {}; + for (var i = 0; i < hoistedVars.length; ++i) { + var local = hoistedVars[i]; + var name_28 = local.kind === 69 + ? local + : local.name; + if (name_28) { + var text = ts.unescapeIdentifier(name_28.text); + if (ts.hasProperty(seen, text)) { + continue; + } + else { + seen[text] = text; + } + } + if (i !== 0) { + write(", "); + } + if (local.kind === 214 || local.kind === 218 || local.kind === 217) { + emitDeclarationName(local); + } + else { + emit(local); + } + var flags = ts.getCombinedNodeFlags(local.kind === 69 ? local.parent : local); + if (flags & 1) { + if (!exportedDeclarations) { + exportedDeclarations = []; + } + exportedDeclarations.push(local); + } + } + write(";"); + } + if (hoistedFunctionDeclarations) { + for (var _a = 0; _a < hoistedFunctionDeclarations.length; _a++) { + var f = hoistedFunctionDeclarations[_a]; + writeLine(); + emit(f); + if (f.flags & 1) { + if (!exportedDeclarations) { + exportedDeclarations = []; + } + exportedDeclarations.push(f); + } + } + } + return exportedDeclarations; + function visit(node) { + if (node.flags & 2) { + return; + } + if (node.kind === 213) { + if (!hoistedFunctionDeclarations) { + hoistedFunctionDeclarations = []; + } + hoistedFunctionDeclarations.push(node); + return; + } + if (node.kind === 214) { + if (!hoistedVars) { + hoistedVars = []; + } + hoistedVars.push(node); + return; + } + if (node.kind === 217) { + if (shouldEmitEnumDeclaration(node)) { + if (!hoistedVars) { + hoistedVars = []; + } + hoistedVars.push(node); + } + return; + } + if (node.kind === 218) { + if (shouldEmitModuleDeclaration(node)) { + if (!hoistedVars) { + hoistedVars = []; + } + hoistedVars.push(node); + } + return; + } + if (node.kind === 211 || node.kind === 163) { + if (shouldHoistVariable(node, false)) { + var name_29 = node.name; + if (name_29.kind === 69) { + if (!hoistedVars) { + hoistedVars = []; + } + hoistedVars.push(name_29); + } + else { + ts.forEachChild(name_29, visit); + } + } + return; + } + if (ts.isInternalModuleImportEqualsDeclaration(node) && resolver.isValueAliasDeclaration(node)) { + if (!hoistedVars) { + hoistedVars = []; + } + hoistedVars.push(node.name); + return; + } + if (ts.isBindingPattern(node)) { + ts.forEach(node.elements, visit); + return; + } + if (!ts.isDeclaration(node)) { + ts.forEachChild(node, visit); + } + } + } + function shouldHoistVariable(node, checkIfSourceFileLevelDecl) { + if (checkIfSourceFileLevelDecl && !shouldHoistDeclarationInSystemJsModule(node)) { + return false; + } + return (ts.getCombinedNodeFlags(node) & 49152) === 0 || + ts.getEnclosingBlockScopeContainer(node).kind === 248; + } + function isCurrentFileSystemExternalModule() { + return modulekind === 4 && ts.isExternalModule(currentSourceFile); + } + function emitSystemModuleBody(node, dependencyGroups, startIndex) { + emitVariableDeclarationsForImports(); + writeLine(); + var exportedDeclarations = processTopLevelVariableAndFunctionDeclarations(node); + var exportStarFunction = emitLocalStorageForExportedNamesIfNecessary(exportedDeclarations); + writeLine(); + write("return {"); + increaseIndent(); + writeLine(); + emitSetters(exportStarFunction, dependencyGroups); + writeLine(); + emitExecute(node, startIndex); + decreaseIndent(); + writeLine(); + write("}"); + emitTempDeclarations(true); + } + function emitSetters(exportStarFunction, dependencyGroups) { + write("setters:["); + for (var i = 0; i < dependencyGroups.length; ++i) { + if (i !== 0) { + write(","); + } + writeLine(); + increaseIndent(); + var group = dependencyGroups[i]; + var parameterName = makeUniqueName(ts.forEach(group, getLocalNameForExternalImport) || ""); + write("function (" + parameterName + ") {"); + increaseIndent(); + for (var _a = 0; _a < group.length; _a++) { + var entry = group[_a]; + var importVariableName = getLocalNameForExternalImport(entry) || ""; + switch (entry.kind) { + case 222: + if (!entry.importClause) { + break; + } + case 221: + ts.Debug.assert(importVariableName !== ""); + writeLine(); + write(importVariableName + " = " + parameterName + ";"); + writeLine(); + break; + case 228: + ts.Debug.assert(importVariableName !== ""); + if (entry.exportClause) { + writeLine(); + write(exportFunctionForFile + "({"); + writeLine(); + increaseIndent(); + for (var i_2 = 0, len = entry.exportClause.elements.length; i_2 < len; ++i_2) { + if (i_2 !== 0) { + write(","); + writeLine(); + } + var e = entry.exportClause.elements[i_2]; + write("\""); + emitNodeWithCommentsAndWithoutSourcemap(e.name); + write("\": " + parameterName + "[\""); + emitNodeWithCommentsAndWithoutSourcemap(e.propertyName || e.name); + write("\"]"); + } + decreaseIndent(); + writeLine(); + write("});"); + } + else { + writeLine(); + write(exportStarFunction + "(" + parameterName + ");"); + } + writeLine(); + break; + } + } + decreaseIndent(); + write("}"); + decreaseIndent(); + } + write("],"); + } + function emitExecute(node, startIndex) { + write("execute: function() {"); + increaseIndent(); + writeLine(); + for (var i = startIndex; i < node.statements.length; ++i) { + var statement = node.statements[i]; + switch (statement.kind) { + case 213: + case 222: + continue; + case 228: + if (!statement.moduleSpecifier) { + for (var _a = 0, _b = statement.exportClause.elements; _a < _b.length; _a++) { + var element = _b[_a]; + emitExportSpecifierInSystemModule(element); + } + } + continue; + case 221: + if (!ts.isInternalModuleImportEqualsDeclaration(statement)) { + continue; + } + default: + writeLine(); + emit(statement); + } + } + decreaseIndent(); + writeLine(); + write("}"); + } + function emitSystemModule(node) { + collectExternalModuleInfo(node); + ts.Debug.assert(!exportFunctionForFile); + exportFunctionForFile = makeUniqueName("exports"); + writeLine(); + write("System.register("); + if (node.moduleName) { + write("\"" + node.moduleName + "\", "); + } + write("["); + var groupIndices = {}; + var dependencyGroups = []; + for (var i = 0; i < externalImports.length; ++i) { + var text = getExternalModuleNameText(externalImports[i]); + if (ts.hasProperty(groupIndices, text)) { + var groupIndex = groupIndices[text]; + dependencyGroups[groupIndex].push(externalImports[i]); + continue; + } + else { + groupIndices[text] = dependencyGroups.length; + dependencyGroups.push([externalImports[i]]); + } + if (i !== 0) { + write(", "); + } + write(text); + } + write("], function(" + exportFunctionForFile + ") {"); + writeLine(); + increaseIndent(); + var startIndex = emitDirectivePrologues(node.statements, true); + emitEmitHelpers(node); + emitCaptureThisForNodeIfNecessary(node); + emitSystemModuleBody(node, dependencyGroups, startIndex); + decreaseIndent(); + writeLine(); + write("});"); + } + function getAMDDependencyNames(node, includeNonAmdDependencies) { + var aliasedModuleNames = []; + var unaliasedModuleNames = []; + var importAliasNames = []; + for (var _a = 0, _b = node.amdDependencies; _a < _b.length; _a++) { + var amdDependency = _b[_a]; + if (amdDependency.name) { + aliasedModuleNames.push("\"" + amdDependency.path + "\""); + importAliasNames.push(amdDependency.name); + } + else { + unaliasedModuleNames.push("\"" + amdDependency.path + "\""); + } + } + for (var _c = 0; _c < externalImports.length; _c++) { + var importNode = externalImports[_c]; + var externalModuleName = getExternalModuleNameText(importNode); + var importAliasName = getLocalNameForExternalImport(importNode); + if (includeNonAmdDependencies && importAliasName) { + aliasedModuleNames.push(externalModuleName); + importAliasNames.push(importAliasName); + } + else { + unaliasedModuleNames.push(externalModuleName); + } + } + return { aliasedModuleNames: aliasedModuleNames, unaliasedModuleNames: unaliasedModuleNames, importAliasNames: importAliasNames }; + } + function emitAMDDependencies(node, includeNonAmdDependencies) { + var dependencyNames = getAMDDependencyNames(node, includeNonAmdDependencies); + emitAMDDependencyList(dependencyNames); + write(", "); + emitAMDFactoryHeader(dependencyNames); + } + function emitAMDDependencyList(_a) { + var aliasedModuleNames = _a.aliasedModuleNames, unaliasedModuleNames = _a.unaliasedModuleNames; + write("[\"require\", \"exports\""); + if (aliasedModuleNames.length) { + write(", "); + write(aliasedModuleNames.join(", ")); + } + if (unaliasedModuleNames.length) { + write(", "); + write(unaliasedModuleNames.join(", ")); + } + write("]"); + } + function emitAMDFactoryHeader(_a) { + var importAliasNames = _a.importAliasNames; + write("function (require, exports"); + if (importAliasNames.length) { + write(", "); + write(importAliasNames.join(", ")); + } + write(") {"); + } + function emitAMDModule(node) { + emitEmitHelpers(node); + collectExternalModuleInfo(node); + writeLine(); + write("define("); + if (node.moduleName) { + write("\"" + node.moduleName + "\", "); + } + emitAMDDependencies(node, true); + increaseIndent(); + var startIndex = emitDirectivePrologues(node.statements, true); + emitExportStarHelper(); + emitCaptureThisForNodeIfNecessary(node); + emitLinesStartingAt(node.statements, startIndex); + emitTempDeclarations(true); + emitExportEquals(true); + decreaseIndent(); + writeLine(); + write("});"); + } + function emitCommonJSModule(node) { + var startIndex = emitDirectivePrologues(node.statements, false); + emitEmitHelpers(node); + collectExternalModuleInfo(node); + emitExportStarHelper(); + emitCaptureThisForNodeIfNecessary(node); + emitLinesStartingAt(node.statements, startIndex); + emitTempDeclarations(true); + emitExportEquals(false); + } + function emitUMDModule(node) { + emitEmitHelpers(node); + collectExternalModuleInfo(node); + var dependencyNames = getAMDDependencyNames(node, false); + writeLines("(function (factory) {\n if (typeof module === 'object' && typeof module.exports === 'object') {\n var v = factory(require, exports); if (v !== undefined) module.exports = v;\n }\n else if (typeof define === 'function' && define.amd) {\n define("); + emitAMDDependencyList(dependencyNames); + write(", factory);"); + writeLines(" }\n})("); + emitAMDFactoryHeader(dependencyNames); + increaseIndent(); + var startIndex = emitDirectivePrologues(node.statements, true); + emitExportStarHelper(); + emitCaptureThisForNodeIfNecessary(node); + emitLinesStartingAt(node.statements, startIndex); + emitTempDeclarations(true); + emitExportEquals(true); + decreaseIndent(); + writeLine(); + write("});"); + } + function emitES6Module(node) { + externalImports = undefined; + exportSpecifiers = undefined; + exportEquals = undefined; + hasExportStars = false; + var startIndex = emitDirectivePrologues(node.statements, false); + emitEmitHelpers(node); + emitCaptureThisForNodeIfNecessary(node); + emitLinesStartingAt(node.statements, startIndex); + emitTempDeclarations(true); + } + function emitExportEquals(emitAsReturn) { + if (exportEquals && resolver.isValueAliasDeclaration(exportEquals)) { + writeLine(); + emitStart(exportEquals); + write(emitAsReturn ? "return " : "module.exports = "); + emit(exportEquals.expression); + write(";"); + emitEnd(exportEquals); + } + } + function emitJsxElement(node) { + switch (compilerOptions.jsx) { + case 2: + jsxEmitReact(node); + break; + case 1: + default: + jsxEmitPreserve(node); + break; + } + } + function trimReactWhitespaceAndApplyEntities(node) { + var result = undefined; + var text = ts.getTextOfNode(node, true); + var firstNonWhitespace = 0; + var lastNonWhitespace = -1; + for (var i = 0; i < text.length; i++) { + var c = text.charCodeAt(i); + if (ts.isLineBreak(c)) { + if (firstNonWhitespace !== -1 && (lastNonWhitespace - firstNonWhitespace + 1 > 0)) { + var part = text.substr(firstNonWhitespace, lastNonWhitespace - firstNonWhitespace + 1); + result = (result ? result + "\" + ' ' + \"" : "") + ts.escapeString(part); + } + firstNonWhitespace = -1; + } + else if (!ts.isWhiteSpace(c)) { + lastNonWhitespace = i; + if (firstNonWhitespace === -1) { + firstNonWhitespace = i; + } + } + } + if (firstNonWhitespace !== -1) { + var part = text.substr(firstNonWhitespace); + result = (result ? result + "\" + ' ' + \"" : "") + ts.escapeString(part); + } + if (result) { + result = result.replace(/&(\w+);/g, function (s, m) { + if (entities[m] !== undefined) { + return String.fromCharCode(entities[m]); + } + else { + return s; + } + }); + } + return result; + } + function getTextToEmit(node) { + switch (compilerOptions.jsx) { + case 2: + var text = trimReactWhitespaceAndApplyEntities(node); + if (text === undefined || text.length === 0) { + return undefined; + } + else { + return text; + } + case 1: + default: + return ts.getTextOfNode(node, true); + } + } + function emitJsxText(node) { + switch (compilerOptions.jsx) { + case 2: + write("\""); + write(trimReactWhitespaceAndApplyEntities(node)); + write("\""); + break; + case 1: + default: + writer.writeLiteral(ts.getTextOfNode(node, true)); + break; + } + } + function emitJsxExpression(node) { + if (node.expression) { + switch (compilerOptions.jsx) { + case 1: + default: + write("{"); + emit(node.expression); + write("}"); + break; + case 2: + emit(node.expression); + break; + } + } + } + function emitDirectivePrologues(statements, startWithNewLine) { + for (var i = 0; i < statements.length; ++i) { + if (ts.isPrologueDirective(statements[i])) { + if (startWithNewLine || i > 0) { + writeLine(); + } + emit(statements[i]); + } + else { + return i; + } + } + return statements.length; + } + function writeLines(text) { + var lines = text.split(/\r\n|\r|\n/g); + for (var i = 0; i < lines.length; ++i) { + var line = lines[i]; + if (line.length) { + writeLine(); + write(line); + } + } + } + function emitEmitHelpers(node) { + if (!compilerOptions.noEmitHelpers) { + if ((languageVersion < 2) && (!extendsEmitted && resolver.getNodeCheckFlags(node) & 8)) { + writeLines(extendsHelper); + extendsEmitted = true; + } + if (!decorateEmitted && resolver.getNodeCheckFlags(node) & 16) { + writeLines(decorateHelper); + if (compilerOptions.emitDecoratorMetadata) { + writeLines(metadataHelper); + } + decorateEmitted = true; + } + if (!paramEmitted && resolver.getNodeCheckFlags(node) & 32) { + writeLines(paramHelper); + paramEmitted = true; + } + if (!awaiterEmitted && resolver.getNodeCheckFlags(node) & 64) { + writeLines(awaiterHelper); + awaiterEmitted = true; + } + } + } + function emitSourceFileNode(node) { + writeLine(); + emitShebang(); + emitDetachedComments(node); + if (ts.isExternalModule(node) || compilerOptions.isolatedModules) { + var emitModule = moduleEmitDelegates[modulekind] || moduleEmitDelegates[1]; + emitModule(node); + } + else { + var startIndex = emitDirectivePrologues(node.statements, false); + externalImports = undefined; + exportSpecifiers = undefined; + exportEquals = undefined; + hasExportStars = false; + emitEmitHelpers(node); + emitCaptureThisForNodeIfNecessary(node); + emitLinesStartingAt(node.statements, startIndex); + emitTempDeclarations(true); + } + emitLeadingComments(node.endOfFileToken); + } + function emitNodeWithCommentsAndWithoutSourcemap(node) { + emitNodeConsideringCommentsOption(node, emitNodeWithoutSourceMap); + } + function emitNodeConsideringCommentsOption(node, emitNodeConsideringSourcemap) { + if (node) { + if (node.flags & 2) { + return emitCommentsOnNotEmittedNode(node); + } + if (isSpecializedCommentHandling(node)) { + return emitNodeWithoutSourceMap(node); + } + var emitComments_1 = shouldEmitLeadingAndTrailingComments(node); + if (emitComments_1) { + emitLeadingComments(node); + } + emitNodeConsideringSourcemap(node); + if (emitComments_1) { + emitTrailingComments(node); + } + } + } + function emitNodeWithoutSourceMap(node) { + if (node) { + emitJavaScriptWorker(node); + } + } + function isSpecializedCommentHandling(node) { + switch (node.kind) { + case 215: + case 213: + case 222: + case 221: + case 216: + case 227: + return true; + } + } + function shouldEmitLeadingAndTrailingComments(node) { + switch (node.kind) { + case 193: + return shouldEmitLeadingAndTrailingCommentsForVariableStatement(node); + case 218: + return shouldEmitModuleDeclaration(node); + case 217: + return shouldEmitEnumDeclaration(node); + } + ts.Debug.assert(!isSpecializedCommentHandling(node)); + if (node.kind !== 192 && + node.parent && + node.parent.kind === 174 && + node.parent.body === node && + compilerOptions.target <= 1) { + return false; + } + return true; + } + function emitJavaScriptWorker(node) { + switch (node.kind) { + case 69: + return emitIdentifier(node); + case 138: + return emitParameter(node); + case 143: + case 142: + return emitMethod(node); + case 145: + case 146: + return emitAccessor(node); + case 97: + return emitThis(node); + case 95: + return emitSuper(node); + case 93: + return write("null"); + case 99: + return write("true"); + case 84: + return write("false"); + case 8: + case 9: + case 10: + case 11: + case 12: + case 13: + case 14: + return emitLiteral(node); + case 183: + return emitTemplateExpression(node); + case 190: + return emitTemplateSpan(node); + case 233: + case 234: + return emitJsxElement(node); + case 236: + return emitJsxText(node); + case 240: + return emitJsxExpression(node); + case 135: + return emitQualifiedName(node); + case 161: + return emitObjectBindingPattern(node); + case 162: + return emitArrayBindingPattern(node); + case 163: + return emitBindingElement(node); + case 164: + return emitArrayLiteral(node); + case 165: + return emitObjectLiteral(node); + case 245: + return emitPropertyAssignment(node); + case 246: + return emitShorthandPropertyAssignment(node); + case 136: + return emitComputedPropertyName(node); + case 166: + return emitPropertyAccess(node); + case 167: + return emitIndexedAccess(node); + case 168: + return emitCallExpression(node); + case 169: + return emitNewExpression(node); + case 170: + return emitTaggedTemplateExpression(node); + case 171: + return emit(node.expression); + case 189: + return emit(node.expression); + case 172: + return emitParenExpression(node); + case 213: + case 173: + case 174: + return emitFunctionDeclaration(node); + case 175: + return emitDeleteExpression(node); + case 176: + return emitTypeOfExpression(node); + case 177: + return emitVoidExpression(node); + case 178: + return emitAwaitExpression(node); + case 179: + return emitPrefixUnaryExpression(node); + case 180: + return emitPostfixUnaryExpression(node); + case 181: + return emitBinaryExpression(node); + case 182: + return emitConditionalExpression(node); + case 185: + return emitSpreadElementExpression(node); + case 184: + return emitYieldExpression(node); + case 187: + return; + case 192: + case 219: + return emitBlock(node); + case 193: + return emitVariableStatement(node); + case 194: + return write(";"); + case 195: + return emitExpressionStatement(node); + case 196: + return emitIfStatement(node); + case 197: + return emitDoStatement(node); + case 198: + return emitWhileStatement(node); + case 199: + return emitForStatement(node); + case 201: + case 200: + return emitForInOrForOfStatement(node); + case 202: + case 203: + return emitBreakOrContinueStatement(node); + case 204: + return emitReturnStatement(node); + case 205: + return emitWithStatement(node); + case 206: + return emitSwitchStatement(node); + case 241: + case 242: + return emitCaseOrDefaultClause(node); + case 207: + return emitLabeledStatement(node); + case 208: + return emitThrowStatement(node); + case 209: + return emitTryStatement(node); + case 244: + return emitCatchClause(node); + case 210: + return emitDebuggerStatement(node); + case 211: + return emitVariableDeclaration(node); + case 186: + return emitClassExpression(node); + case 214: + return emitClassDeclaration(node); + case 215: + return emitInterfaceDeclaration(node); + case 217: + return emitEnumDeclaration(node); + case 247: + return emitEnumMember(node); + case 218: + return emitModuleDeclaration(node); + case 222: + return emitImportDeclaration(node); + case 221: + return emitImportEqualsDeclaration(node); + case 228: + return emitExportDeclaration(node); + case 227: + return emitExportAssignment(node); + case 248: + return emitSourceFileNode(node); + } + } + function hasDetachedComments(pos) { + return detachedCommentsInfo !== undefined && ts.lastOrUndefined(detachedCommentsInfo).nodePos === pos; + } + function getLeadingCommentsWithoutDetachedComments() { + var leadingComments = ts.getLeadingCommentRanges(currentSourceFile.text, ts.lastOrUndefined(detachedCommentsInfo).detachedCommentEndPos); + if (detachedCommentsInfo.length - 1) { + detachedCommentsInfo.pop(); + } + else { + detachedCommentsInfo = undefined; + } + return leadingComments; + } + function isPinnedComments(comment) { + return currentSourceFile.text.charCodeAt(comment.pos + 1) === 42 && + currentSourceFile.text.charCodeAt(comment.pos + 2) === 33; + } + function isTripleSlashComment(comment) { + if (currentSourceFile.text.charCodeAt(comment.pos + 1) === 47 && + comment.pos + 2 < comment.end && + currentSourceFile.text.charCodeAt(comment.pos + 2) === 47) { + var textSubStr = currentSourceFile.text.substring(comment.pos, comment.end); + return textSubStr.match(ts.fullTripleSlashReferencePathRegEx) || + textSubStr.match(ts.fullTripleSlashAMDReferencePathRegEx) ? + true : false; + } + return false; + } + function getLeadingCommentsToEmit(node) { + if (node.parent) { + if (node.parent.kind === 248 || node.pos !== node.parent.pos) { + if (hasDetachedComments(node.pos)) { + return getLeadingCommentsWithoutDetachedComments(); + } + else { + return ts.getLeadingCommentRangesOfNode(node, currentSourceFile); + } + } + } + } + function getTrailingCommentsToEmit(node) { + if (node.parent) { + if (node.parent.kind === 248 || node.end !== node.parent.end) { + return ts.getTrailingCommentRanges(currentSourceFile.text, node.end); + } + } + } + function emitCommentsOnNotEmittedNode(node) { + emitLeadingCommentsWorker(node, false); + } + function emitLeadingComments(node) { + return emitLeadingCommentsWorker(node, true); + } + function emitLeadingCommentsWorker(node, isEmittedNode) { + if (compilerOptions.removeComments) { + return; + } + var leadingComments; + if (isEmittedNode) { + leadingComments = getLeadingCommentsToEmit(node); + } + else { + if (node.pos === 0) { + leadingComments = ts.filter(getLeadingCommentsToEmit(node), isTripleSlashComment); + } + } + ts.emitNewLineBeforeLeadingComments(currentSourceFile, writer, node, leadingComments); + ts.emitComments(currentSourceFile, writer, leadingComments, true, newLine, writeComment); + } + function emitTrailingComments(node) { + if (compilerOptions.removeComments) { + return; + } + var trailingComments = getTrailingCommentsToEmit(node); + ts.emitComments(currentSourceFile, writer, trailingComments, false, newLine, writeComment); + } + function emitTrailingCommentsOfPosition(pos) { + if (compilerOptions.removeComments) { + return; + } + var trailingComments = ts.getTrailingCommentRanges(currentSourceFile.text, pos); + ts.emitComments(currentSourceFile, writer, trailingComments, true, newLine, writeComment); + } + function emitLeadingCommentsOfPositionWorker(pos) { + if (compilerOptions.removeComments) { + return; + } + var leadingComments; + if (hasDetachedComments(pos)) { + leadingComments = getLeadingCommentsWithoutDetachedComments(); + } + else { + leadingComments = ts.getLeadingCommentRanges(currentSourceFile.text, pos); + } + ts.emitNewLineBeforeLeadingComments(currentSourceFile, writer, { pos: pos, end: pos }, leadingComments); + ts.emitComments(currentSourceFile, writer, leadingComments, true, newLine, writeComment); + } + function emitDetachedComments(node) { + var leadingComments; + if (compilerOptions.removeComments) { + if (node.pos === 0) { + leadingComments = ts.filter(ts.getLeadingCommentRanges(currentSourceFile.text, node.pos), isPinnedComments); + } + } + else { + leadingComments = ts.getLeadingCommentRanges(currentSourceFile.text, node.pos); + } + if (leadingComments) { + var detachedComments = []; + var lastComment; + ts.forEach(leadingComments, function (comment) { + if (lastComment) { + var lastCommentLine = ts.getLineOfLocalPosition(currentSourceFile, lastComment.end); + var commentLine = ts.getLineOfLocalPosition(currentSourceFile, comment.pos); + if (commentLine >= lastCommentLine + 2) { + return detachedComments; + } + } + detachedComments.push(comment); + lastComment = comment; + }); + if (detachedComments.length) { + var lastCommentLine = ts.getLineOfLocalPosition(currentSourceFile, ts.lastOrUndefined(detachedComments).end); + var nodeLine = ts.getLineOfLocalPosition(currentSourceFile, ts.skipTrivia(currentSourceFile.text, node.pos)); + if (nodeLine >= lastCommentLine + 2) { + ts.emitNewLineBeforeLeadingComments(currentSourceFile, writer, node, leadingComments); + ts.emitComments(currentSourceFile, writer, detachedComments, true, newLine, writeComment); + var currentDetachedCommentInfo = { nodePos: node.pos, detachedCommentEndPos: ts.lastOrUndefined(detachedComments).end }; + if (detachedCommentsInfo) { + detachedCommentsInfo.push(currentDetachedCommentInfo); + } + else { + detachedCommentsInfo = [currentDetachedCommentInfo]; + } + } + } + } + } + function emitShebang() { + var shebang = ts.getShebang(currentSourceFile.text); + if (shebang) { + write(shebang); + } + } + var _a; + } + function emitFile(jsFilePath, sourceFile) { + emitJavaScript(jsFilePath, sourceFile); + if (compilerOptions.declaration) { + ts.writeDeclarationFile(jsFilePath, sourceFile, host, resolver, diagnostics); + } + } + } + ts.emitFiles = emitFiles; +})(ts || (ts = {})); +var ts; +(function (ts) { + ts.programTime = 0; + ts.emitTime = 0; + ts.ioReadTime = 0; + ts.ioWriteTime = 0; + var emptyArray = []; + ts.version = "1.8.0"; + function findConfigFile(searchPath) { + var fileName = "tsconfig.json"; + while (true) { + if (ts.sys.fileExists(fileName)) { + return fileName; + } + var parentPath = ts.getDirectoryPath(searchPath); + if (parentPath === searchPath) { + break; + } + searchPath = parentPath; + fileName = "../" + fileName; + } + return undefined; + } + ts.findConfigFile = findConfigFile; + function resolveTripleslashReference(moduleName, containingFile) { + var basePath = ts.getDirectoryPath(containingFile); + var referencedFileName = ts.isRootedDiskPath(moduleName) ? moduleName : ts.combinePaths(basePath, moduleName); + return ts.normalizePath(referencedFileName); + } + ts.resolveTripleslashReference = resolveTripleslashReference; + function resolveModuleName(moduleName, containingFile, compilerOptions, host) { + var moduleResolution = compilerOptions.moduleResolution !== undefined + ? compilerOptions.moduleResolution + : compilerOptions.module === 1 ? 2 : 1; + switch (moduleResolution) { + case 2: return nodeModuleNameResolver(moduleName, containingFile, host); + case 1: return classicNameResolver(moduleName, containingFile, compilerOptions, host); + } + } + ts.resolveModuleName = resolveModuleName; + function nodeModuleNameResolver(moduleName, containingFile, host) { + var containingDirectory = ts.getDirectoryPath(containingFile); + if (ts.getRootLength(moduleName) !== 0 || nameStartsWithDotSlashOrDotDotSlash(moduleName)) { + var failedLookupLocations = []; + var candidate = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName)); + var resolvedFileName = loadNodeModuleFromFile(candidate, failedLookupLocations, host); + if (resolvedFileName) { + return { resolvedModule: { resolvedFileName: resolvedFileName }, failedLookupLocations: failedLookupLocations }; + } + resolvedFileName = loadNodeModuleFromDirectory(candidate, failedLookupLocations, host); + return resolvedFileName + ? { resolvedModule: { resolvedFileName: resolvedFileName }, failedLookupLocations: failedLookupLocations } + : { resolvedModule: undefined, failedLookupLocations: failedLookupLocations }; + } + else { + return loadModuleFromNodeModules(moduleName, containingDirectory, host); + } + } + ts.nodeModuleNameResolver = nodeModuleNameResolver; + function loadNodeModuleFromFile(candidate, failedLookupLocation, host) { + return ts.forEach(ts.moduleFileExtensions, tryLoad); + function tryLoad(ext) { + var fileName = ts.fileExtensionIs(candidate, ext) ? candidate : candidate + ext; + if (host.fileExists(fileName)) { + return fileName; + } + else { + failedLookupLocation.push(fileName); + return undefined; + } + } + } + function loadNodeModuleFromDirectory(candidate, failedLookupLocation, host) { + var packageJsonPath = ts.combinePaths(candidate, "package.json"); + if (host.fileExists(packageJsonPath)) { + var jsonContent; + try { + var jsonText = host.readFile(packageJsonPath); + jsonContent = jsonText ? JSON.parse(jsonText) : { typings: undefined }; + } + catch (e) { + jsonContent = { typings: undefined }; + } + if (jsonContent.typings) { + var result = loadNodeModuleFromFile(ts.normalizePath(ts.combinePaths(candidate, jsonContent.typings)), failedLookupLocation, host); + if (result) { + return result; + } + } + } + else { + failedLookupLocation.push(packageJsonPath); + } + return loadNodeModuleFromFile(ts.combinePaths(candidate, "index"), failedLookupLocation, host); + } + function loadModuleFromNodeModules(moduleName, directory, host) { + var failedLookupLocations = []; + directory = ts.normalizeSlashes(directory); + while (true) { + var baseName = ts.getBaseFileName(directory); + if (baseName !== "node_modules") { + var nodeModulesFolder = ts.combinePaths(directory, "node_modules"); + var candidate = ts.normalizePath(ts.combinePaths(nodeModulesFolder, moduleName)); + var result = loadNodeModuleFromFile(candidate, failedLookupLocations, host); + if (result) { + return { resolvedModule: { resolvedFileName: result, isExternalLibraryImport: true }, failedLookupLocations: failedLookupLocations }; + } + result = loadNodeModuleFromDirectory(candidate, failedLookupLocations, host); + if (result) { + return { resolvedModule: { resolvedFileName: result, isExternalLibraryImport: true }, failedLookupLocations: failedLookupLocations }; + } + } + var parentPath = ts.getDirectoryPath(directory); + if (parentPath === directory) { + break; + } + directory = parentPath; + } + return { resolvedModule: undefined, failedLookupLocations: failedLookupLocations }; + } + function nameStartsWithDotSlashOrDotDotSlash(name) { + var i = name.lastIndexOf("./", 1); + return i === 0 || (i === 1 && name.charCodeAt(0) === 46); + } + function classicNameResolver(moduleName, containingFile, compilerOptions, host) { + if (moduleName.indexOf("!") != -1) { + return { resolvedModule: undefined, failedLookupLocations: [] }; + } + var searchPath = ts.getDirectoryPath(containingFile); + var searchName; + var failedLookupLocations = []; + var referencedSourceFile; + while (true) { + searchName = ts.normalizePath(ts.combinePaths(searchPath, moduleName)); + referencedSourceFile = ts.forEach(ts.supportedExtensions, function (extension) { + if (extension === ".tsx" && !compilerOptions.jsx) { + return undefined; + } + var candidate = searchName + extension; + if (host.fileExists(candidate)) { + return candidate; + } + else { + failedLookupLocations.push(candidate); + } + }); + if (referencedSourceFile) { + break; + } + var parentPath = ts.getDirectoryPath(searchPath); + if (parentPath === searchPath) { + break; + } + searchPath = parentPath; + } + return referencedSourceFile + ? { resolvedModule: { resolvedFileName: referencedSourceFile }, failedLookupLocations: failedLookupLocations } + : { resolvedModule: undefined, failedLookupLocations: failedLookupLocations }; + } + ts.classicNameResolver = classicNameResolver; + ts.defaultInitCompilerOptions = { + module: 1, + target: 0, + noImplicitAny: false, + outDir: "built", + rootDir: ".", + sourceMap: false + }; + function createCompilerHost(options, setParentNodes) { + var existingDirectories = {}; + function getCanonicalFileName(fileName) { + return ts.sys.useCaseSensitiveFileNames ? fileName : fileName.toLowerCase(); + } + var unsupportedFileEncodingErrorCode = -2147024809; + function getSourceFile(fileName, languageVersion, onError) { + var text; + try { + var start = new Date().getTime(); + text = ts.sys.readFile(fileName, options.charset); + ts.ioReadTime += new Date().getTime() - start; + } + catch (e) { + if (onError) { + onError(e.number === unsupportedFileEncodingErrorCode + ? ts.createCompilerDiagnostic(ts.Diagnostics.Unsupported_file_encoding).messageText + : e.message); + } + text = ""; + } + return text !== undefined ? ts.createSourceFile(fileName, text, languageVersion, setParentNodes) : undefined; + } + function directoryExists(directoryPath) { + if (ts.hasProperty(existingDirectories, directoryPath)) { + return true; + } + if (ts.sys.directoryExists(directoryPath)) { + existingDirectories[directoryPath] = true; + return true; + } + return false; + } + function ensureDirectoriesExist(directoryPath) { + if (directoryPath.length > ts.getRootLength(directoryPath) && !directoryExists(directoryPath)) { + var parentDirectory = ts.getDirectoryPath(directoryPath); + ensureDirectoriesExist(parentDirectory); + ts.sys.createDirectory(directoryPath); + } + } + function writeFile(fileName, data, writeByteOrderMark, onError) { + try { + var start = new Date().getTime(); + ensureDirectoriesExist(ts.getDirectoryPath(ts.normalizePath(fileName))); + ts.sys.writeFile(fileName, data, writeByteOrderMark); + ts.ioWriteTime += new Date().getTime() - start; + } + catch (e) { + if (onError) { + onError(e.message); + } + } + } + var newLine = ts.getNewLineCharacter(options); + return { + getSourceFile: getSourceFile, + getDefaultLibFileName: function (options) { return ts.combinePaths(ts.getDirectoryPath(ts.normalizePath(ts.sys.getExecutingFilePath())), ts.getDefaultLibFileName(options)); }, + writeFile: writeFile, + getCurrentDirectory: ts.memoize(function () { return ts.sys.getCurrentDirectory(); }), + useCaseSensitiveFileNames: function () { return ts.sys.useCaseSensitiveFileNames; }, + getCanonicalFileName: getCanonicalFileName, + getNewLine: function () { return newLine; }, + fileExists: function (fileName) { return ts.sys.fileExists(fileName); }, + readFile: function (fileName) { return ts.sys.readFile(fileName); } + }; + } + ts.createCompilerHost = createCompilerHost; + function getPreEmitDiagnostics(program, sourceFile, cancellationToken) { + var diagnostics = program.getOptionsDiagnostics(cancellationToken).concat(program.getSyntacticDiagnostics(sourceFile, cancellationToken), program.getGlobalDiagnostics(cancellationToken), program.getSemanticDiagnostics(sourceFile, cancellationToken)); + if (program.getCompilerOptions().declaration) { + diagnostics.concat(program.getDeclarationDiagnostics(sourceFile, cancellationToken)); + } + return ts.sortAndDeduplicateDiagnostics(diagnostics); + } + ts.getPreEmitDiagnostics = getPreEmitDiagnostics; + function flattenDiagnosticMessageText(messageText, newLine) { + if (typeof messageText === "string") { + return messageText; + } + else { + var diagnosticChain = messageText; + var result = ""; + var indent = 0; + while (diagnosticChain) { + if (indent) { + result += newLine; + for (var i = 0; i < indent; i++) { + result += " "; + } + } + result += diagnosticChain.messageText; + indent++; + diagnosticChain = diagnosticChain.next; + } + return result; + } + } + ts.flattenDiagnosticMessageText = flattenDiagnosticMessageText; + function createProgram(rootNames, options, host, oldProgram) { + var program; + var files = []; + var fileProcessingDiagnostics = ts.createDiagnosticCollection(); + var programDiagnostics = ts.createDiagnosticCollection(); + var commonSourceDirectory; + var diagnosticsProducingTypeChecker; + var noDiagnosticsTypeChecker; + var classifiableNames; + var skipDefaultLib = options.noLib; + var start = new Date().getTime(); + host = host || createCompilerHost(options); + var currentDirectory = host.getCurrentDirectory(); + var resolveModuleNamesWorker = host.resolveModuleNames + ? (function (moduleNames, containingFile) { return host.resolveModuleNames(moduleNames, containingFile); }) + : (function (moduleNames, containingFile) { return ts.map(moduleNames, function (moduleName) { return resolveModuleName(moduleName, containingFile, options, host).resolvedModule; }); }); + var filesByName = ts.createFileMap(getCanonicalFileName); + var filesByNameIgnoreCase = host.useCaseSensitiveFileNames() ? ts.createFileMap(function (fileName) { return fileName.toLowerCase(); }) : undefined; + if (oldProgram) { + var oldOptions = oldProgram.getCompilerOptions(); + if ((oldOptions.module !== options.module) || + (oldOptions.noResolve !== options.noResolve) || + (oldOptions.target !== options.target) || + (oldOptions.noLib !== options.noLib) || + (oldOptions.jsx !== options.jsx)) { + oldProgram = undefined; + } + } + if (!tryReuseStructureFromOldProgram()) { + ts.forEach(rootNames, function (name) { return processRootFile(name, false); }); + if (!skipDefaultLib) { + processRootFile(host.getDefaultLibFileName(options), true); + } + } + verifyCompilerOptions(); + oldProgram = undefined; + ts.programTime += new Date().getTime() - start; + program = { + getRootFileNames: function () { return rootNames; }, + getSourceFile: getSourceFile, + getSourceFiles: function () { return files; }, + getCompilerOptions: function () { return options; }, + getSyntacticDiagnostics: getSyntacticDiagnostics, + getOptionsDiagnostics: getOptionsDiagnostics, + getGlobalDiagnostics: getGlobalDiagnostics, + getSemanticDiagnostics: getSemanticDiagnostics, + getDeclarationDiagnostics: getDeclarationDiagnostics, + getTypeChecker: getTypeChecker, + getClassifiableNames: getClassifiableNames, + getDiagnosticsProducingTypeChecker: getDiagnosticsProducingTypeChecker, + getCommonSourceDirectory: function () { return commonSourceDirectory; }, + emit: emit, + getCurrentDirectory: function () { return currentDirectory; }, + getNodeCount: function () { return getDiagnosticsProducingTypeChecker().getNodeCount(); }, + getIdentifierCount: function () { return getDiagnosticsProducingTypeChecker().getIdentifierCount(); }, + getSymbolCount: function () { return getDiagnosticsProducingTypeChecker().getSymbolCount(); }, + getTypeCount: function () { return getDiagnosticsProducingTypeChecker().getTypeCount(); }, + getFileProcessingDiagnostics: function () { return fileProcessingDiagnostics; } + }; + return program; + function getClassifiableNames() { + if (!classifiableNames) { + getTypeChecker(); + classifiableNames = {}; + for (var _i = 0; _i < files.length; _i++) { + var sourceFile = files[_i]; + ts.copyMap(sourceFile.classifiableNames, classifiableNames); + } + } + return classifiableNames; + } + function tryReuseStructureFromOldProgram() { + if (!oldProgram) { + return false; + } + ts.Debug.assert(!oldProgram.structureIsReused); + var oldRootNames = oldProgram.getRootFileNames(); + if (!ts.arrayIsEqualTo(oldRootNames, rootNames)) { + return false; + } + var newSourceFiles = []; + var normalizedAbsoluteFileNames = []; + var modifiedSourceFiles = []; + for (var _i = 0, _a = oldProgram.getSourceFiles(); _i < _a.length; _i++) { + var oldSourceFile = _a[_i]; + var newSourceFile = host.getSourceFile(oldSourceFile.fileName, options.target); + if (!newSourceFile) { + return false; + } + var normalizedAbsolutePath = ts.getNormalizedAbsolutePath(newSourceFile.fileName, currentDirectory); + normalizedAbsoluteFileNames.push(normalizedAbsolutePath); + if (oldSourceFile !== newSourceFile) { + if (oldSourceFile.hasNoDefaultLib !== newSourceFile.hasNoDefaultLib) { + return false; + } + if (!ts.arrayIsEqualTo(oldSourceFile.referencedFiles, newSourceFile.referencedFiles, fileReferenceIsEqualTo)) { + return false; + } + collectExternalModuleReferences(newSourceFile); + if (!ts.arrayIsEqualTo(oldSourceFile.imports, newSourceFile.imports, moduleNameIsEqualTo)) { + return false; + } + if (resolveModuleNamesWorker) { + var moduleNames = ts.map(newSourceFile.imports, function (name) { return name.text; }); + var resolutions = resolveModuleNamesWorker(moduleNames, normalizedAbsolutePath); + for (var i = 0; i < moduleNames.length; ++i) { + var newResolution = resolutions[i]; + var oldResolution = ts.getResolvedModule(oldSourceFile, moduleNames[i]); + var resolutionChanged = oldResolution + ? !newResolution || + oldResolution.resolvedFileName !== newResolution.resolvedFileName || + !!oldResolution.isExternalLibraryImport !== !!newResolution.isExternalLibraryImport + : newResolution; + if (resolutionChanged) { + return false; + } + } + } + newSourceFile.resolvedModules = oldSourceFile.resolvedModules; + modifiedSourceFiles.push(newSourceFile); + } + else { + newSourceFile = oldSourceFile; + } + newSourceFiles.push(newSourceFile); + } + for (var i = 0, len = newSourceFiles.length; i < len; ++i) { + filesByName.set(normalizedAbsoluteFileNames[i], newSourceFiles[i]); + } + files = newSourceFiles; + fileProcessingDiagnostics = oldProgram.getFileProcessingDiagnostics(); + for (var _b = 0; _b < modifiedSourceFiles.length; _b++) { + var modifiedFile = modifiedSourceFiles[_b]; + fileProcessingDiagnostics.reattachFileDiagnostics(modifiedFile); + } + oldProgram.structureIsReused = true; + return true; + } + function getEmitHost(writeFileCallback) { + return { + getCanonicalFileName: getCanonicalFileName, + getCommonSourceDirectory: program.getCommonSourceDirectory, + getCompilerOptions: program.getCompilerOptions, + getCurrentDirectory: function () { return currentDirectory; }, + getNewLine: function () { return host.getNewLine(); }, + getSourceFile: program.getSourceFile, + getSourceFiles: program.getSourceFiles, + writeFile: writeFileCallback || (function (fileName, data, writeByteOrderMark, onError) { return host.writeFile(fileName, data, writeByteOrderMark, onError); }) + }; + } + function getDiagnosticsProducingTypeChecker() { + return diagnosticsProducingTypeChecker || (diagnosticsProducingTypeChecker = ts.createTypeChecker(program, true)); + } + function getTypeChecker() { + return noDiagnosticsTypeChecker || (noDiagnosticsTypeChecker = ts.createTypeChecker(program, false)); + } + function emit(sourceFile, writeFileCallback, cancellationToken) { + var _this = this; + return runWithCancellationToken(function () { return emitWorker(_this, sourceFile, writeFileCallback, cancellationToken); }); + } + function emitWorker(program, sourceFile, writeFileCallback, cancellationToken) { + if (options.noEmitOnError && getPreEmitDiagnostics(program, undefined, cancellationToken).length > 0) { + return { diagnostics: [], sourceMaps: undefined, emitSkipped: true }; + } + var emitResolver = getDiagnosticsProducingTypeChecker().getEmitResolver((options.outFile || options.out) ? undefined : sourceFile); + var start = new Date().getTime(); + var emitResult = ts.emitFiles(emitResolver, getEmitHost(writeFileCallback), sourceFile); + ts.emitTime += new Date().getTime() - start; + return emitResult; + } + function getSourceFile(fileName) { + return filesByName.get(ts.getNormalizedAbsolutePath(fileName, currentDirectory)); + } + function getDiagnosticsHelper(sourceFile, getDiagnostics, cancellationToken) { + if (sourceFile) { + return getDiagnostics(sourceFile, cancellationToken); + } + var allDiagnostics = []; + ts.forEach(program.getSourceFiles(), function (sourceFile) { + if (cancellationToken) { + cancellationToken.throwIfCancellationRequested(); + } + ts.addRange(allDiagnostics, getDiagnostics(sourceFile, cancellationToken)); + }); + return ts.sortAndDeduplicateDiagnostics(allDiagnostics); + } + function getSyntacticDiagnostics(sourceFile, cancellationToken) { + return getDiagnosticsHelper(sourceFile, getSyntacticDiagnosticsForFile, cancellationToken); + } + function getSemanticDiagnostics(sourceFile, cancellationToken) { + return getDiagnosticsHelper(sourceFile, getSemanticDiagnosticsForFile, cancellationToken); + } + function getDeclarationDiagnostics(sourceFile, cancellationToken) { + return getDiagnosticsHelper(sourceFile, getDeclarationDiagnosticsForFile, cancellationToken); + } + function getSyntacticDiagnosticsForFile(sourceFile, cancellationToken) { + return sourceFile.parseDiagnostics; + } + function runWithCancellationToken(func) { + try { + return func(); + } + catch (e) { + if (e instanceof ts.OperationCanceledException) { + noDiagnosticsTypeChecker = undefined; + diagnosticsProducingTypeChecker = undefined; + } + throw e; + } + } + function getSemanticDiagnosticsForFile(sourceFile, cancellationToken) { + return runWithCancellationToken(function () { + var typeChecker = getDiagnosticsProducingTypeChecker(); + ts.Debug.assert(!!sourceFile.bindDiagnostics); + var bindDiagnostics = sourceFile.bindDiagnostics; + var checkDiagnostics = typeChecker.getDiagnostics(sourceFile, cancellationToken); + var fileProcessingDiagnosticsInFile = fileProcessingDiagnostics.getDiagnostics(sourceFile.fileName); + var programDiagnosticsInFile = programDiagnostics.getDiagnostics(sourceFile.fileName); + return bindDiagnostics.concat(checkDiagnostics).concat(fileProcessingDiagnosticsInFile).concat(programDiagnosticsInFile); + }); + } + function getDeclarationDiagnosticsForFile(sourceFile, cancellationToken) { + return runWithCancellationToken(function () { + if (!ts.isDeclarationFile(sourceFile)) { + var resolver = getDiagnosticsProducingTypeChecker().getEmitResolver(sourceFile, cancellationToken); + var writeFile_1 = function () { }; + return ts.getDeclarationDiagnostics(getEmitHost(writeFile_1), resolver, sourceFile); + } + }); + } + function getOptionsDiagnostics() { + var allDiagnostics = []; + ts.addRange(allDiagnostics, fileProcessingDiagnostics.getGlobalDiagnostics()); + ts.addRange(allDiagnostics, programDiagnostics.getGlobalDiagnostics()); + return ts.sortAndDeduplicateDiagnostics(allDiagnostics); + } + function getGlobalDiagnostics() { + var allDiagnostics = []; + ts.addRange(allDiagnostics, getDiagnosticsProducingTypeChecker().getGlobalDiagnostics()); + return ts.sortAndDeduplicateDiagnostics(allDiagnostics); + } + function hasExtension(fileName) { + return ts.getBaseFileName(fileName).indexOf(".") >= 0; + } + function processRootFile(fileName, isDefaultLib) { + processSourceFile(ts.normalizePath(fileName), isDefaultLib); + } + function fileReferenceIsEqualTo(a, b) { + return a.fileName === b.fileName; + } + function moduleNameIsEqualTo(a, b) { + return a.text === b.text; + } + function collectExternalModuleReferences(file) { + if (file.imports) { + return; + } + var imports; + for (var _i = 0, _a = file.statements; _i < _a.length; _i++) { + var node = _a[_i]; + collect(node, true); + } + file.imports = imports || emptyArray; + function collect(node, allowRelativeModuleNames) { + switch (node.kind) { + case 222: + case 221: + case 228: + var moduleNameExpr = ts.getExternalModuleName(node); + if (!moduleNameExpr || moduleNameExpr.kind !== 9) { + break; + } + if (!moduleNameExpr.text) { + break; + } + if (allowRelativeModuleNames || !ts.isExternalModuleNameRelative(moduleNameExpr.text)) { + (imports || (imports = [])).push(moduleNameExpr); + } + break; + case 218: + if (node.name.kind === 9 && (node.flags & 2 || ts.isDeclarationFile(file))) { + ts.forEachChild(node.body, function (node) { + collect(node, false); + }); + } + break; + } + } + } + function processSourceFile(fileName, isDefaultLib, refFile, refPos, refEnd) { + var diagnosticArgument; + var diagnostic; + if (hasExtension(fileName)) { + if (!options.allowNonTsExtensions && !ts.forEach(ts.supportedExtensions, function (extension) { return ts.fileExtensionIs(host.getCanonicalFileName(fileName), extension); })) { + diagnostic = ts.Diagnostics.File_0_has_unsupported_extension_The_only_supported_extensions_are_1; + diagnosticArgument = [fileName, "'" + ts.supportedExtensions.join("', '") + "'"]; + } + else if (!findSourceFile(fileName, ts.getNormalizedAbsolutePath(fileName, currentDirectory), isDefaultLib, refFile, refPos, refEnd)) { + diagnostic = ts.Diagnostics.File_0_not_found; + diagnosticArgument = [fileName]; + } + else if (refFile && host.getCanonicalFileName(fileName) === host.getCanonicalFileName(refFile.fileName)) { + diagnostic = ts.Diagnostics.A_file_cannot_have_a_reference_to_itself; + diagnosticArgument = [fileName]; + } + } + else { + var nonTsFile = options.allowNonTsExtensions && findSourceFile(fileName, ts.getNormalizedAbsolutePath(fileName, currentDirectory), isDefaultLib, refFile, refPos, refEnd); + if (!nonTsFile) { + if (options.allowNonTsExtensions) { + diagnostic = ts.Diagnostics.File_0_not_found; + diagnosticArgument = [fileName]; + } + else if (!ts.forEach(ts.supportedExtensions, function (extension) { return findSourceFile(fileName + extension, ts.getNormalizedAbsolutePath(fileName + extension, currentDirectory), isDefaultLib, refFile, refPos, refEnd); })) { + diagnostic = ts.Diagnostics.File_0_not_found; + fileName += ".ts"; + diagnosticArgument = [fileName]; + } + } + } + if (diagnostic) { + if (refFile !== undefined && refEnd !== undefined && refPos !== undefined) { + fileProcessingDiagnostics.add(ts.createFileDiagnostic.apply(void 0, [refFile, refPos, refEnd - refPos, diagnostic].concat(diagnosticArgument))); + } + else { + fileProcessingDiagnostics.add(ts.createCompilerDiagnostic.apply(void 0, [diagnostic].concat(diagnosticArgument))); + } + } + } + function reportFileNamesDifferOnlyInCasingError(fileName, existingFileName, refFile, refPos, refEnd) { + if (refFile !== undefined && refPos !== undefined && refEnd !== undefined) { + fileProcessingDiagnostics.add(ts.createFileDiagnostic(refFile, refPos, refEnd - refPos, ts.Diagnostics.File_name_0_differs_from_already_included_file_name_1_only_in_casing, fileName, existingFileName)); + } + else { + fileProcessingDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.File_name_0_differs_from_already_included_file_name_1_only_in_casing, fileName, existingFileName)); + } + } + function findSourceFile(fileName, normalizedAbsolutePath, isDefaultLib, refFile, refPos, refEnd) { + if (filesByName.contains(normalizedAbsolutePath)) { + var file_1 = filesByName.get(normalizedAbsolutePath); + if (file_1 && options.forceConsistentCasingInFileNames && ts.getNormalizedAbsolutePath(file_1.fileName, currentDirectory) !== normalizedAbsolutePath) { + reportFileNamesDifferOnlyInCasingError(fileName, file_1.fileName, refFile, refPos, refEnd); + } + return file_1; + } + var file = host.getSourceFile(fileName, options.target, function (hostErrorMessage) { + if (refFile !== undefined && refPos !== undefined && refEnd !== undefined) { + fileProcessingDiagnostics.add(ts.createFileDiagnostic(refFile, refPos, refEnd - refPos, ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage)); + } + else { + fileProcessingDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage)); + } + }); + filesByName.set(normalizedAbsolutePath, file); + if (file) { + if (host.useCaseSensitiveFileNames()) { + var existingFile = filesByNameIgnoreCase.get(normalizedAbsolutePath); + if (existingFile) { + reportFileNamesDifferOnlyInCasingError(fileName, existingFile.fileName, refFile, refPos, refEnd); + } + else { + filesByNameIgnoreCase.set(normalizedAbsolutePath, file); + } + } + skipDefaultLib = skipDefaultLib || file.hasNoDefaultLib; + var basePath = ts.getDirectoryPath(fileName); + if (!options.noResolve) { + processReferencedFiles(file, basePath); + } + processImportedModules(file, basePath); + if (isDefaultLib) { + file.isDefaultLib = true; + files.unshift(file); + } + else { + files.push(file); + } + } + return file; + } + function processReferencedFiles(file, basePath) { + ts.forEach(file.referencedFiles, function (ref) { + var referencedFileName = resolveTripleslashReference(ref.fileName, file.fileName); + processSourceFile(referencedFileName, false, file, ref.pos, ref.end); + }); + } + function getCanonicalFileName(fileName) { + return host.getCanonicalFileName(fileName); + } + function processImportedModules(file, basePath) { + collectExternalModuleReferences(file); + if (file.imports.length) { + file.resolvedModules = {}; + var moduleNames = ts.map(file.imports, function (name) { return name.text; }); + var resolutions = resolveModuleNamesWorker(moduleNames, ts.getNormalizedAbsolutePath(file.fileName, currentDirectory)); + for (var i = 0; i < file.imports.length; ++i) { + var resolution = resolutions[i]; + ts.setResolvedModule(file, moduleNames[i], resolution); + if (resolution && !options.noResolve) { + var absoluteImportPath = ts.isRootedDiskPath(resolution.resolvedFileName) + ? resolution.resolvedFileName + : ts.getNormalizedAbsolutePath(resolution.resolvedFileName, currentDirectory); + var relativePath = ts.getRelativePathToDirectoryOrUrl(currentDirectory, absoluteImportPath, currentDirectory, getCanonicalFileName, false); + var importedFile = findSourceFile(relativePath, absoluteImportPath, false, file, ts.skipTrivia(file.text, file.imports[i].pos), file.imports[i].end); + if (importedFile && resolution.isExternalLibraryImport) { + if (!ts.isExternalModule(importedFile)) { + var start_2 = ts.getTokenPosOfNode(file.imports[i], file); + fileProcessingDiagnostics.add(ts.createFileDiagnostic(file, start_2, file.imports[i].end - start_2, ts.Diagnostics.Exported_external_package_typings_file_0_is_not_a_module_Please_contact_the_package_author_to_update_the_package_definition, importedFile.fileName)); + } + else if (importedFile.referencedFiles.length) { + var firstRef = importedFile.referencedFiles[0]; + fileProcessingDiagnostics.add(ts.createFileDiagnostic(importedFile, firstRef.pos, firstRef.end - firstRef.pos, ts.Diagnostics.Exported_external_package_typings_file_cannot_contain_tripleslash_references_Please_contact_the_package_author_to_update_the_package_definition)); + } + } + } + } + } + else { + file.resolvedModules = undefined; + } + return; + } + function computeCommonSourceDirectory(sourceFiles) { + var commonPathComponents; + ts.forEach(files, function (sourceFile) { + if (ts.isDeclarationFile(sourceFile)) { + return; + } + var sourcePathComponents = ts.getNormalizedPathComponents(sourceFile.fileName, currentDirectory); + sourcePathComponents.pop(); + if (!commonPathComponents) { + commonPathComponents = sourcePathComponents; + return; + } + for (var i = 0, n = Math.min(commonPathComponents.length, sourcePathComponents.length); i < n; i++) { + if (commonPathComponents[i] !== sourcePathComponents[i]) { + if (i === 0) { + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_find_the_common_subdirectory_path_for_the_input_files)); + return; + } + commonPathComponents.length = i; + break; + } + } + if (sourcePathComponents.length < commonPathComponents.length) { + commonPathComponents.length = sourcePathComponents.length; + } + }); + return ts.getNormalizedPathFromPathComponents(commonPathComponents); + } + function checkSourceFilesBelongToPath(sourceFiles, rootDirectory) { + var allFilesBelongToPath = true; + if (sourceFiles) { + var absoluteRootDirectoryPath = host.getCanonicalFileName(ts.getNormalizedAbsolutePath(rootDirectory, currentDirectory)); + for (var _i = 0; _i < sourceFiles.length; _i++) { + var sourceFile = sourceFiles[_i]; + if (!ts.isDeclarationFile(sourceFile)) { + var absoluteSourceFilePath = host.getCanonicalFileName(ts.getNormalizedAbsolutePath(sourceFile.fileName, currentDirectory)); + if (absoluteSourceFilePath.indexOf(absoluteRootDirectoryPath) !== 0) { + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.File_0_is_not_under_rootDir_1_rootDir_is_expected_to_contain_all_source_files, sourceFile.fileName, options.rootDir)); + allFilesBelongToPath = false; + } + } + } + } + return allFilesBelongToPath; + } + function verifyCompilerOptions() { + if (options.isolatedModules) { + if (options.declaration) { + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "declaration", "isolatedModules")); + } + if (options.noEmitOnError) { + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "noEmitOnError", "isolatedModules")); + } + if (options.out) { + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "out", "isolatedModules")); + } + if (options.outFile) { + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "outFile", "isolatedModules")); + } + } + if (options.inlineSourceMap) { + if (options.sourceMap) { + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "sourceMap", "inlineSourceMap")); + } + if (options.mapRoot) { + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "mapRoot", "inlineSourceMap")); + } + if (options.sourceRoot) { + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "sourceRoot", "inlineSourceMap")); + } + } + if (options.inlineSources) { + if (!options.sourceMap && !options.inlineSourceMap) { + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_inlineSources_can_only_be_used_when_either_option_inlineSourceMap_or_option_sourceMap_is_provided)); + } + } + if (options.out && options.outFile) { + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "out", "outFile")); + } + if (!options.sourceMap && (options.mapRoot || options.sourceRoot)) { + if (options.mapRoot) { + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "mapRoot", "sourceMap")); + } + if (options.sourceRoot) { + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "sourceRoot", "sourceMap")); + } + return; + } + var languageVersion = options.target || 0; + var outFile = options.outFile || options.out; + var firstExternalModuleSourceFile = ts.forEach(files, function (f) { return ts.isExternalModule(f) ? f : undefined; }); + if (options.isolatedModules) { + if (!options.module && languageVersion < 2) { + 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; }); + if (firstNonExternalModuleSourceFile) { + var span = ts.getErrorSpanForNode(firstNonExternalModuleSourceFile, firstNonExternalModuleSourceFile); + programDiagnostics.add(ts.createFileDiagnostic(firstNonExternalModuleSourceFile, span.start, span.length, ts.Diagnostics.Cannot_compile_namespaces_when_the_isolatedModules_flag_is_provided)); + } + } + else if (firstExternalModuleSourceFile && languageVersion < 2 && !options.module) { + var span = ts.getErrorSpanForNode(firstExternalModuleSourceFile, firstExternalModuleSourceFile.externalModuleIndicator); + programDiagnostics.add(ts.createFileDiagnostic(firstExternalModuleSourceFile, span.start, span.length, ts.Diagnostics.Cannot_compile_modules_unless_the_module_flag_is_provided)); + } + if (options.module === 5 && languageVersion < 2) { + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_compile_modules_into_es2015_when_targeting_ES5_or_lower)); + } + if (options.outDir || + options.sourceRoot || + (options.mapRoot && + (!outFile || firstExternalModuleSourceFile !== undefined))) { + if (options.rootDir && checkSourceFilesBelongToPath(files, options.rootDir)) { + commonSourceDirectory = ts.getNormalizedAbsolutePath(options.rootDir, currentDirectory); + } + else { + commonSourceDirectory = computeCommonSourceDirectory(files); + } + if (commonSourceDirectory && commonSourceDirectory[commonSourceDirectory.length - 1] !== ts.directorySeparator) { + commonSourceDirectory += ts.directorySeparator; + } + } + if (options.noEmit) { + if (options.out) { + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "noEmit", "out")); + } + if (options.outFile) { + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "noEmit", "outFile")); + } + if (options.outDir) { + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "noEmit", "outDir")); + } + if (options.declaration) { + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "noEmit", "declaration")); + } + } + if (options.emitDecoratorMetadata && + !options.experimentalDecorators) { + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "emitDecoratorMetadata", "experimentalDecorators")); + } + } + } + ts.createProgram = createProgram; +})(ts || (ts = {})); +var ts; +(function (ts) { + var BreakpointResolver; + (function (BreakpointResolver) { + function spanInSourceFileAtLocation(sourceFile, position) { + if (sourceFile.flags & 8192) { + return undefined; + } + var tokenAtLocation = ts.getTokenAtPosition(sourceFile, position); + var lineOfPosition = sourceFile.getLineAndCharacterOfPosition(position).line; + if (sourceFile.getLineAndCharacterOfPosition(tokenAtLocation.getStart()).line > lineOfPosition) { + tokenAtLocation = ts.findPrecedingToken(tokenAtLocation.pos, sourceFile); + if (!tokenAtLocation || sourceFile.getLineAndCharacterOfPosition(tokenAtLocation.getEnd()).line !== lineOfPosition) { + return undefined; + } + } + if (ts.isInAmbientContext(tokenAtLocation)) { + return undefined; + } + return spanInNode(tokenAtLocation); + function textSpan(startNode, endNode) { + return ts.createTextSpanFromBounds(startNode.getStart(), (endNode || startNode).getEnd()); + } + function spanInNodeIfStartsOnSameLine(node, otherwiseOnNode) { + if (node && lineOfPosition === sourceFile.getLineAndCharacterOfPosition(node.getStart()).line) { + return spanInNode(node); + } + return spanInNode(otherwiseOnNode); + } + function spanInPreviousNode(node) { + return spanInNode(ts.findPrecedingToken(node.pos, sourceFile)); + } + function spanInNextNode(node) { + return spanInNode(ts.findNextToken(node, node.parent)); + } + function spanInNode(node) { + if (node) { + if (ts.isExpression(node)) { + if (node.parent.kind === 197) { + return spanInPreviousNode(node); + } + if (node.parent.kind === 199) { + return textSpan(node); + } + if (node.parent.kind === 181 && node.parent.operatorToken.kind === 24) { + return textSpan(node); + } + if (node.parent.kind === 174 && node.parent.body === node) { + return textSpan(node); + } + } + switch (node.kind) { + case 193: + return spanInVariableDeclaration(node.declarationList.declarations[0]); + case 211: + case 141: + case 140: + return spanInVariableDeclaration(node); + case 138: + return spanInParameterDeclaration(node); + case 213: + case 143: + case 142: + case 145: + case 146: + case 144: + case 173: + case 174: + return spanInFunctionDeclaration(node); + case 192: + if (ts.isFunctionBlock(node)) { + return spanInFunctionBlock(node); + } + case 219: + return spanInBlock(node); + case 244: + return spanInBlock(node.block); + case 195: + return textSpan(node.expression); + case 204: + return textSpan(node.getChildAt(0), node.expression); + case 198: + return textSpan(node, ts.findNextToken(node.expression, node)); + case 197: + return spanInNode(node.statement); + case 210: + return textSpan(node.getChildAt(0)); + case 196: + return textSpan(node, ts.findNextToken(node.expression, node)); + case 207: + return spanInNode(node.statement); + case 203: + case 202: + return textSpan(node.getChildAt(0), node.label); + case 199: + return spanInForStatement(node); + case 200: + case 201: + return textSpan(node, ts.findNextToken(node.expression, node)); + case 206: + return textSpan(node, ts.findNextToken(node.expression, node)); + case 241: + case 242: + return spanInNode(node.statements[0]); + case 209: + return spanInBlock(node.tryBlock); + case 208: + return textSpan(node, node.expression); + case 227: + return textSpan(node, node.expression); + case 221: + return textSpan(node, node.moduleReference); + case 222: + return textSpan(node, node.moduleSpecifier); + case 228: + return textSpan(node, node.moduleSpecifier); + case 218: + if (ts.getModuleInstanceState(node) !== 1) { + return undefined; + } + case 214: + case 217: + case 247: + case 168: + case 169: + return textSpan(node); + case 205: + return spanInNode(node.statement); + case 215: + case 216: + return undefined; + case 23: + 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 17: + return spanInOpenParenToken(node); + case 18: + return spanInCloseParenToken(node); + case 54: + return spanInColonToken(node); + case 27: + case 25: + return spanInGreaterThanOrLessThanToken(node); + case 104: + return spanInWhileKeyword(node); + case 80: + case 72: + case 85: + return spanInNextNode(node); + default: + if (node.parent.kind === 245 && node.parent.name === node) { + return spanInNode(node.parent.initializer); + } + if (node.parent.kind === 171 && node.parent.type === node) { + return spanInNode(node.parent.expression); + } + if (ts.isFunctionLike(node.parent) && node.parent.type === node) { + return spanInPreviousNode(node); + } + return spanInNode(node.parent); + } + } + function spanInVariableDeclaration(variableDeclaration) { + if (variableDeclaration.parent.parent.kind === 200 || + variableDeclaration.parent.parent.kind === 201) { + return spanInNode(variableDeclaration.parent.parent); + } + var isParentVariableStatement = variableDeclaration.parent.parent.kind === 193; + var isDeclarationOfForStatement = variableDeclaration.parent.parent.kind === 199 && ts.contains(variableDeclaration.parent.parent.initializer.declarations, variableDeclaration); + var declarations = isParentVariableStatement + ? variableDeclaration.parent.parent.declarationList.declarations + : isDeclarationOfForStatement + ? variableDeclaration.parent.parent.initializer.declarations + : undefined; + if (variableDeclaration.initializer || (variableDeclaration.flags & 1)) { + if (declarations && declarations[0] === variableDeclaration) { + if (isParentVariableStatement) { + return textSpan(variableDeclaration.parent, variableDeclaration); + } + else { + ts.Debug.assert(isDeclarationOfForStatement); + return textSpan(ts.findPrecedingToken(variableDeclaration.pos, sourceFile, variableDeclaration.parent), variableDeclaration); + } + } + else { + return textSpan(variableDeclaration); + } + } + else if (declarations && declarations[0] !== variableDeclaration) { + var indexOfCurrentDeclaration = ts.indexOf(declarations, variableDeclaration); + return spanInVariableDeclaration(declarations[indexOfCurrentDeclaration - 1]); + } + } + function canHaveSpanInParameterDeclaration(parameter) { + return !!parameter.initializer || parameter.dotDotDotToken !== undefined || + !!(parameter.flags & 16) || !!(parameter.flags & 32); + } + function spanInParameterDeclaration(parameter) { + if (canHaveSpanInParameterDeclaration(parameter)) { + return textSpan(parameter); + } + else { + var functionDeclaration = parameter.parent; + var indexOfParameter = ts.indexOf(functionDeclaration.parameters, parameter); + if (indexOfParameter) { + return spanInParameterDeclaration(functionDeclaration.parameters[indexOfParameter - 1]); + } + else { + return spanInNode(functionDeclaration.body); + } + } + } + function canFunctionHaveSpanInWholeDeclaration(functionDeclaration) { + return !!(functionDeclaration.flags & 1) || + (functionDeclaration.parent.kind === 214 && functionDeclaration.kind !== 144); + } + function spanInFunctionDeclaration(functionDeclaration) { + if (!functionDeclaration.body) { + return undefined; + } + if (canFunctionHaveSpanInWholeDeclaration(functionDeclaration)) { + return textSpan(functionDeclaration); + } + return spanInNode(functionDeclaration.body); + } + function spanInFunctionBlock(block) { + var nodeForSpanInBlock = block.statements.length ? block.statements[0] : block.getLastToken(); + if (canFunctionHaveSpanInWholeDeclaration(block.parent)) { + return spanInNodeIfStartsOnSameLine(block.parent, nodeForSpanInBlock); + } + return spanInNode(nodeForSpanInBlock); + } + function spanInBlock(block) { + switch (block.parent.kind) { + case 218: + if (ts.getModuleInstanceState(block.parent) !== 1) { + return undefined; + } + case 198: + case 196: + case 200: + case 201: + return spanInNodeIfStartsOnSameLine(block.parent, block.statements[0]); + case 199: + return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(block.pos, sourceFile, block.parent), block.statements[0]); + } + return spanInNode(block.statements[0]); + } + function spanInForStatement(forStatement) { + if (forStatement.initializer) { + if (forStatement.initializer.kind === 212) { + var variableDeclarationList = forStatement.initializer; + if (variableDeclarationList.declarations.length > 0) { + return spanInNode(variableDeclarationList.declarations[0]); + } + } + else { + return spanInNode(forStatement.initializer); + } + } + if (forStatement.condition) { + return textSpan(forStatement.condition); + } + if (forStatement.incrementor) { + return textSpan(forStatement.incrementor); + } + } + function spanInOpenBraceToken(node) { + switch (node.parent.kind) { + case 217: + var enumDeclaration = node.parent; + return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), enumDeclaration.members.length ? enumDeclaration.members[0] : enumDeclaration.getLastToken(sourceFile)); + case 214: + var classDeclaration = node.parent; + return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), classDeclaration.members.length ? classDeclaration.members[0] : classDeclaration.getLastToken(sourceFile)); + case 220: + return spanInNodeIfStartsOnSameLine(node.parent.parent, node.parent.clauses[0]); + } + return spanInNode(node.parent); + } + function spanInCloseBraceToken(node) { + switch (node.parent.kind) { + case 219: + if (ts.getModuleInstanceState(node.parent.parent) !== 1) { + return undefined; + } + case 217: + case 214: + return textSpan(node); + case 192: + if (ts.isFunctionBlock(node.parent)) { + return textSpan(node); + } + case 244: + return spanInNode(ts.lastOrUndefined(node.parent.statements)); + ; + case 220: + var caseBlock = node.parent; + var lastClause = ts.lastOrUndefined(caseBlock.clauses); + if (lastClause) { + return spanInNode(ts.lastOrUndefined(lastClause.statements)); + } + return undefined; + default: + return spanInNode(node.parent); + } + } + function spanInOpenParenToken(node) { + if (node.parent.kind === 197) { + return spanInPreviousNode(node); + } + return spanInNode(node.parent); + } + function spanInCloseParenToken(node) { + switch (node.parent.kind) { + case 173: + case 213: + case 174: + case 143: + case 142: + case 145: + case 146: + case 144: + case 198: + case 197: + case 199: + return spanInPreviousNode(node); + default: + return spanInNode(node.parent); + } + return spanInNode(node.parent); + } + function spanInColonToken(node) { + if (ts.isFunctionLike(node.parent) || node.parent.kind === 245) { + return spanInPreviousNode(node); + } + return spanInNode(node.parent); + } + function spanInGreaterThanOrLessThanToken(node) { + if (node.parent.kind === 171) { + return spanInNode(node.parent.expression); + } + return spanInNode(node.parent); + } + function spanInWhileKeyword(node) { + if (node.parent.kind === 197) { + return textSpan(node, ts.findNextToken(node.parent.expression, node.parent)); + } + return spanInNode(node.parent); + } + } + } + BreakpointResolver.spanInSourceFileAtLocation = spanInSourceFileAtLocation; + })(BreakpointResolver = ts.BreakpointResolver || (ts.BreakpointResolver = {})); +})(ts || (ts = {})); +var ts; +(function (ts) { + var OutliningElementsCollector; + (function (OutliningElementsCollector) { + function collectElements(sourceFile) { + var elements = []; + var collapseText = "..."; + function addOutliningSpan(hintSpanNode, startElement, endElement, autoCollapse) { + if (hintSpanNode && startElement && endElement) { + var span = { + textSpan: ts.createTextSpanFromBounds(startElement.pos, endElement.end), + hintSpan: ts.createTextSpanFromBounds(hintSpanNode.getStart(), hintSpanNode.end), + bannerText: collapseText, + autoCollapse: autoCollapse + }; + elements.push(span); + } + } + function addOutliningSpanComments(commentSpan, autoCollapse) { + if (commentSpan) { + var span = { + textSpan: ts.createTextSpanFromBounds(commentSpan.pos, commentSpan.end), + hintSpan: ts.createTextSpanFromBounds(commentSpan.pos, commentSpan.end), + bannerText: collapseText, + autoCollapse: autoCollapse + }; + elements.push(span); + } + } + function addOutliningForLeadingCommentsForNode(n) { + var comments = ts.getLeadingCommentRangesOfNode(n, sourceFile); + if (comments) { + var firstSingleLineCommentStart = -1; + var lastSingleLineCommentEnd = -1; + var isFirstSingleLineComment = true; + var singleLineCommentCount = 0; + for (var _i = 0; _i < comments.length; _i++) { + var currentComment = comments[_i]; + if (currentComment.kind === 2) { + if (isFirstSingleLineComment) { + firstSingleLineCommentStart = currentComment.pos; + } + isFirstSingleLineComment = false; + lastSingleLineCommentEnd = currentComment.end; + singleLineCommentCount++; + } + else if (currentComment.kind === 3) { + combineAndAddMultipleSingleLineComments(singleLineCommentCount, firstSingleLineCommentStart, lastSingleLineCommentEnd); + addOutliningSpanComments(currentComment, false); + singleLineCommentCount = 0; + lastSingleLineCommentEnd = -1; + isFirstSingleLineComment = true; + } + } + combineAndAddMultipleSingleLineComments(singleLineCommentCount, firstSingleLineCommentStart, lastSingleLineCommentEnd); + } + } + function combineAndAddMultipleSingleLineComments(count, start, end) { + if (count > 1) { + var multipleSingleLineComments = { + pos: start, + end: end, + kind: 2 + }; + addOutliningSpanComments(multipleSingleLineComments, false); + } + } + function autoCollapse(node) { + return ts.isFunctionBlock(node) && node.parent.kind !== 174; + } + var depth = 0; + var maxDepth = 20; + function walk(n) { + if (depth > maxDepth) { + return; + } + if (ts.isDeclaration(n)) { + addOutliningForLeadingCommentsForNode(n); + } + switch (n.kind) { + case 192: + if (!ts.isFunctionBlock(n)) { + var parent_7 = n.parent; + var openBrace = ts.findChildOfKind(n, 15, sourceFile); + var closeBrace = ts.findChildOfKind(n, 16, sourceFile); + if (parent_7.kind === 197 || + parent_7.kind === 200 || + parent_7.kind === 201 || + parent_7.kind === 199 || + parent_7.kind === 196 || + parent_7.kind === 198 || + parent_7.kind === 205 || + parent_7.kind === 244) { + addOutliningSpan(parent_7, openBrace, closeBrace, autoCollapse(n)); + break; + } + if (parent_7.kind === 209) { + var tryStatement = parent_7; + if (tryStatement.tryBlock === n) { + addOutliningSpan(parent_7, openBrace, closeBrace, autoCollapse(n)); + break; + } + else if (tryStatement.finallyBlock === n) { + var finallyKeyword = ts.findChildOfKind(tryStatement, 85, sourceFile); + if (finallyKeyword) { + addOutliningSpan(finallyKeyword, openBrace, closeBrace, autoCollapse(n)); + break; + } + } + } + var span = ts.createTextSpanFromBounds(n.getStart(), n.end); + elements.push({ + textSpan: span, + hintSpan: span, + bannerText: collapseText, + autoCollapse: autoCollapse(n) + }); + break; + } + case 219: { + var openBrace = ts.findChildOfKind(n, 15, sourceFile); + var closeBrace = ts.findChildOfKind(n, 16, sourceFile); + addOutliningSpan(n.parent, openBrace, closeBrace, autoCollapse(n)); + break; + } + case 214: + case 215: + case 217: + case 165: + case 220: { + var openBrace = ts.findChildOfKind(n, 15, sourceFile); + var closeBrace = ts.findChildOfKind(n, 16, sourceFile); + addOutliningSpan(n, openBrace, closeBrace, autoCollapse(n)); + break; + } + case 164: + var openBracket = ts.findChildOfKind(n, 19, sourceFile); + var closeBracket = ts.findChildOfKind(n, 20, sourceFile); + addOutliningSpan(n, openBracket, closeBracket, autoCollapse(n)); + break; + } + depth++; + ts.forEachChild(n, walk); + depth--; + } + walk(sourceFile); + return elements; + } + OutliningElementsCollector.collectElements = collectElements; + })(OutliningElementsCollector = ts.OutliningElementsCollector || (ts.OutliningElementsCollector = {})); +})(ts || (ts = {})); +var ts; +(function (ts) { + var NavigateTo; + (function (NavigateTo) { + function getNavigateToItems(program, cancellationToken, searchValue, maxResultCount) { + var patternMatcher = ts.createPatternMatcher(searchValue); + var rawItems = []; + ts.forEach(program.getSourceFiles(), function (sourceFile) { + cancellationToken.throwIfCancellationRequested(); + var nameToDeclarations = sourceFile.getNamedDeclarations(); + for (var name_30 in nameToDeclarations) { + var declarations = ts.getProperty(nameToDeclarations, name_30); + if (declarations) { + var matches = patternMatcher.getMatchesForLastSegmentOfPattern(name_30); + if (!matches) { + continue; + } + for (var _i = 0; _i < declarations.length; _i++) { + var declaration = declarations[_i]; + if (patternMatcher.patternContainsDots) { + var containers = getContainers(declaration); + if (!containers) { + return undefined; + } + matches = patternMatcher.getMatches(containers, name_30); + if (!matches) { + continue; + } + } + var fileName = sourceFile.fileName; + var matchKind = bestMatchKind(matches); + rawItems.push({ name: name_30, fileName: fileName, matchKind: matchKind, isCaseSensitive: allMatchesAreCaseSensitive(matches), declaration: declaration }); + } + } + } + }); + rawItems.sort(compareNavigateToItems); + if (maxResultCount !== undefined) { + rawItems = rawItems.slice(0, maxResultCount); + } + var items = ts.map(rawItems, createNavigateToItem); + return items; + function allMatchesAreCaseSensitive(matches) { + ts.Debug.assert(matches.length > 0); + for (var _i = 0; _i < matches.length; _i++) { + var match = matches[_i]; + if (!match.isCaseSensitive) { + return false; + } + } + return true; + } + function getTextOfIdentifierOrLiteral(node) { + if (node) { + if (node.kind === 69 || + node.kind === 9 || + node.kind === 8) { + return node.text; + } + } + return undefined; + } + function tryAddSingleDeclarationName(declaration, containers) { + if (declaration && declaration.name) { + var text = getTextOfIdentifierOrLiteral(declaration.name); + if (text !== undefined) { + containers.unshift(text); + } + else if (declaration.name.kind === 136) { + return tryAddComputedPropertyName(declaration.name.expression, containers, true); + } + else { + return false; + } + } + return true; + } + function tryAddComputedPropertyName(expression, containers, includeLastPortion) { + var text = getTextOfIdentifierOrLiteral(expression); + if (text !== undefined) { + if (includeLastPortion) { + containers.unshift(text); + } + return true; + } + if (expression.kind === 166) { + var propertyAccess = expression; + if (includeLastPortion) { + containers.unshift(propertyAccess.name.text); + } + return tryAddComputedPropertyName(propertyAccess.expression, containers, true); + } + return false; + } + function getContainers(declaration) { + var containers = []; + if (declaration.name.kind === 136) { + if (!tryAddComputedPropertyName(declaration.name.expression, containers, false)) { + return undefined; + } + } + declaration = ts.getContainerNode(declaration); + while (declaration) { + if (!tryAddSingleDeclarationName(declaration, containers)) { + return undefined; + } + declaration = ts.getContainerNode(declaration); + } + return containers; + } + function bestMatchKind(matches) { + ts.Debug.assert(matches.length > 0); + var bestMatchKind = ts.PatternMatchKind.camelCase; + for (var _i = 0; _i < matches.length; _i++) { + var match = matches[_i]; + var kind = match.kind; + if (kind < bestMatchKind) { + bestMatchKind = kind; + } + } + return bestMatchKind; + } + var baseSensitivity = { sensitivity: "base" }; + function compareNavigateToItems(i1, i2) { + return i1.matchKind - i2.matchKind || + i1.name.localeCompare(i2.name, undefined, baseSensitivity) || + i1.name.localeCompare(i2.name); + } + function createNavigateToItem(rawItem) { + var declaration = rawItem.declaration; + var container = ts.getContainerNode(declaration); + return { + name: rawItem.name, + kind: ts.getNodeKind(declaration), + kindModifiers: ts.getNodeModifiers(declaration), + matchKind: ts.PatternMatchKind[rawItem.matchKind], + isCaseSensitive: rawItem.isCaseSensitive, + fileName: rawItem.fileName, + textSpan: ts.createTextSpanFromBounds(declaration.getStart(), declaration.getEnd()), + containerName: container && container.name ? container.name.text : "", + containerKind: container && container.name ? ts.getNodeKind(container) : "" + }; + } + } + NavigateTo.getNavigateToItems = getNavigateToItems; + })(NavigateTo = ts.NavigateTo || (ts.NavigateTo = {})); +})(ts || (ts = {})); +var ts; +(function (ts) { + var NavigationBar; + (function (NavigationBar) { + function getNavigationBarItems(sourceFile) { + var hasGlobalNode = false; + return getItemsWorker(getTopLevelNodes(sourceFile), createTopLevelItem); + function getIndent(node) { + var indent = hasGlobalNode ? 1 : 0; + var current = node.parent; + while (current) { + switch (current.kind) { + case 218: + do { + current = current.parent; + } while (current.kind === 218); + case 214: + case 217: + case 215: + case 213: + indent++; + } + current = current.parent; + } + return indent; + } + function getChildNodes(nodes) { + var childNodes = []; + function visit(node) { + switch (node.kind) { + case 193: + ts.forEach(node.declarationList.declarations, visit); + break; + case 161: + case 162: + ts.forEach(node.elements, visit); + break; + case 228: + if (node.exportClause) { + ts.forEach(node.exportClause.elements, visit); + } + break; + case 222: + var importClause = node.importClause; + if (importClause) { + if (importClause.name) { + childNodes.push(importClause); + } + if (importClause.namedBindings) { + if (importClause.namedBindings.kind === 224) { + childNodes.push(importClause.namedBindings); + } + else { + ts.forEach(importClause.namedBindings.elements, visit); + } + } + } + break; + case 163: + case 211: + if (ts.isBindingPattern(node.name)) { + visit(node.name); + break; + } + case 214: + case 217: + case 215: + case 218: + case 213: + case 221: + case 226: + case 230: + childNodes.push(node); + break; + } + } + ts.forEach(nodes, visit); + return sortNodes(childNodes); + } + function getTopLevelNodes(node) { + var topLevelNodes = []; + topLevelNodes.push(node); + addTopLevelNodes(node.statements, topLevelNodes); + return topLevelNodes; + } + function sortNodes(nodes) { + return nodes.slice(0).sort(function (n1, n2) { + if (n1.name && n2.name) { + return ts.getPropertyNameForPropertyNameNode(n1.name).localeCompare(ts.getPropertyNameForPropertyNameNode(n2.name)); + } + else if (n1.name) { + return 1; + } + else if (n2.name) { + return -1; + } + else { + return n1.kind - n2.kind; + } + }); + } + function addTopLevelNodes(nodes, topLevelNodes) { + nodes = sortNodes(nodes); + for (var _i = 0; _i < nodes.length; _i++) { + var node = nodes[_i]; + switch (node.kind) { + case 214: + case 217: + case 215: + topLevelNodes.push(node); + break; + case 218: + var moduleDeclaration = node; + topLevelNodes.push(node); + addTopLevelNodes(getInnermostModule(moduleDeclaration).body.statements, topLevelNodes); + break; + case 213: + var functionDeclaration = node; + if (isTopLevelFunctionDeclaration(functionDeclaration)) { + topLevelNodes.push(node); + addTopLevelNodes(functionDeclaration.body.statements, topLevelNodes); + } + break; + } + } + } + function isTopLevelFunctionDeclaration(functionDeclaration) { + if (functionDeclaration.kind === 213) { + if (functionDeclaration.body && functionDeclaration.body.kind === 192) { + if (ts.forEach(functionDeclaration.body.statements, function (s) { return s.kind === 213 && !isEmpty(s.name.text); })) { + return true; + } + if (!ts.isFunctionBlock(functionDeclaration.parent)) { + return true; + } + } + } + return false; + } + function getItemsWorker(nodes, createItem) { + var items = []; + var keyToItem = {}; + for (var _i = 0; _i < nodes.length; _i++) { + var child = nodes[_i]; + var item = createItem(child); + if (item !== undefined) { + if (item.text.length > 0) { + var key = item.text + "-" + item.kind + "-" + item.indent; + var itemWithSameName = keyToItem[key]; + if (itemWithSameName) { + merge(itemWithSameName, item); + } + else { + keyToItem[key] = item; + items.push(item); + } + } + } + } + return items; + } + function merge(target, source) { + ts.addRange(target.spans, source.spans); + if (source.childItems) { + if (!target.childItems) { + target.childItems = []; + } + outer: for (var _i = 0, _a = source.childItems; _i < _a.length; _i++) { + var sourceChild = _a[_i]; + for (var _b = 0, _c = target.childItems; _b < _c.length; _b++) { + var targetChild = _c[_b]; + if (targetChild.text === sourceChild.text && targetChild.kind === sourceChild.kind) { + merge(targetChild, sourceChild); + continue outer; + } + } + target.childItems.push(sourceChild); + } + } + } + function createChildItem(node) { + switch (node.kind) { + case 138: + if (ts.isBindingPattern(node.name)) { + break; + } + if ((node.flags & 2035) === 0) { + return undefined; + } + return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberVariableElement); + case 143: + case 142: + return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberFunctionElement); + case 145: + return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberGetAccessorElement); + case 146: + return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberSetAccessorElement); + case 149: + return createItem(node, "[]", ts.ScriptElementKind.indexSignatureElement); + case 247: + return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberVariableElement); + case 147: + return createItem(node, "()", ts.ScriptElementKind.callSignatureElement); + case 148: + return createItem(node, "new()", ts.ScriptElementKind.constructSignatureElement); + case 141: + case 140: + return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberVariableElement); + case 213: + return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.functionElement); + case 211: + case 163: + var variableDeclarationNode; + var name_31; + if (node.kind === 163) { + name_31 = node.name; + variableDeclarationNode = node; + while (variableDeclarationNode && variableDeclarationNode.kind !== 211) { + variableDeclarationNode = variableDeclarationNode.parent; + } + ts.Debug.assert(variableDeclarationNode !== undefined); + } + else { + ts.Debug.assert(!ts.isBindingPattern(node.name)); + variableDeclarationNode = node; + name_31 = node.name; + } + if (ts.isConst(variableDeclarationNode)) { + return createItem(node, getTextOfNode(name_31), ts.ScriptElementKind.constElement); + } + else if (ts.isLet(variableDeclarationNode)) { + return createItem(node, getTextOfNode(name_31), ts.ScriptElementKind.letElement); + } + else { + return createItem(node, getTextOfNode(name_31), ts.ScriptElementKind.variableElement); + } + case 144: + return createItem(node, "constructor", ts.ScriptElementKind.constructorImplementationElement); + case 230: + case 226: + case 221: + case 223: + case 224: + return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.alias); + } + return undefined; + function createItem(node, name, scriptElementKind) { + return getNavigationBarItem(name, scriptElementKind, ts.getNodeModifiers(node), [getNodeSpan(node)]); + } + } + function isEmpty(text) { + return !text || text.trim() === ""; + } + function getNavigationBarItem(text, kind, kindModifiers, spans, childItems, indent) { + if (childItems === void 0) { childItems = []; } + if (indent === void 0) { indent = 0; } + if (isEmpty(text)) { + return undefined; + } + return { + text: text, + kind: kind, + kindModifiers: kindModifiers, + spans: spans, + childItems: childItems, + indent: indent, + bolded: false, + grayed: false + }; + } + function createTopLevelItem(node) { + switch (node.kind) { + case 248: + return createSourceFileItem(node); + case 214: + return createClassItem(node); + case 217: + return createEnumItem(node); + case 215: + return createIterfaceItem(node); + case 218: + return createModuleItem(node); + case 213: + return createFunctionItem(node); + } + return undefined; + function getModuleName(moduleDeclaration) { + if (moduleDeclaration.name.kind === 9) { + return getTextOfNode(moduleDeclaration.name); + } + var result = []; + result.push(moduleDeclaration.name.text); + while (moduleDeclaration.body && moduleDeclaration.body.kind === 218) { + moduleDeclaration = moduleDeclaration.body; + result.push(moduleDeclaration.name.text); + } + return result.join("."); + } + function createModuleItem(node) { + var moduleName = getModuleName(node); + var childItems = getItemsWorker(getChildNodes(getInnermostModule(node).body.statements), createChildItem); + return getNavigationBarItem(moduleName, ts.ScriptElementKind.moduleElement, ts.getNodeModifiers(node), [getNodeSpan(node)], childItems, getIndent(node)); + } + function createFunctionItem(node) { + if (node.body && node.body.kind === 192) { + var childItems = getItemsWorker(sortNodes(node.body.statements), createChildItem); + return getNavigationBarItem(!node.name ? "default" : node.name.text, ts.ScriptElementKind.functionElement, ts.getNodeModifiers(node), [getNodeSpan(node)], childItems, getIndent(node)); + } + return undefined; + } + function createSourceFileItem(node) { + var childItems = getItemsWorker(getChildNodes(node.statements), createChildItem); + if (childItems === undefined || childItems.length === 0) { + return undefined; + } + hasGlobalNode = true; + var rootName = ts.isExternalModule(node) + ? "\"" + ts.escapeString(ts.getBaseFileName(ts.removeFileExtension(ts.normalizePath(node.fileName)))) + "\"" + : ""; + return getNavigationBarItem(rootName, ts.ScriptElementKind.moduleElement, ts.ScriptElementKindModifier.none, [getNodeSpan(node)], childItems); + } + function createClassItem(node) { + var childItems; + if (node.members) { + var constructor = ts.forEach(node.members, function (member) { + return member.kind === 144 && member; + }); + var nodes = removeDynamicallyNamedProperties(node); + if (constructor) { + ts.addRange(nodes, ts.filter(constructor.parameters, function (p) { return !ts.isBindingPattern(p.name); })); + } + childItems = getItemsWorker(sortNodes(nodes), createChildItem); + } + var nodeName = !node.name ? "default" : node.name.text; + return getNavigationBarItem(nodeName, ts.ScriptElementKind.classElement, ts.getNodeModifiers(node), [getNodeSpan(node)], childItems, getIndent(node)); + } + function createEnumItem(node) { + var childItems = getItemsWorker(sortNodes(removeComputedProperties(node)), createChildItem); + return getNavigationBarItem(node.name.text, ts.ScriptElementKind.enumElement, ts.getNodeModifiers(node), [getNodeSpan(node)], childItems, getIndent(node)); + } + function createIterfaceItem(node) { + var childItems = getItemsWorker(sortNodes(removeDynamicallyNamedProperties(node)), createChildItem); + return getNavigationBarItem(node.name.text, ts.ScriptElementKind.interfaceElement, ts.getNodeModifiers(node), [getNodeSpan(node)], childItems, getIndent(node)); + } + } + function removeComputedProperties(node) { + return ts.filter(node.members, function (member) { return member.name === undefined || member.name.kind !== 136; }); + } + function removeDynamicallyNamedProperties(node) { + return ts.filter(node.members, function (member) { return !ts.hasDynamicName(member); }); + } + function getInnermostModule(node) { + while (node.body.kind === 218) { + node = node.body; + } + return node; + } + function getNodeSpan(node) { + return node.kind === 248 + ? ts.createTextSpanFromBounds(node.getFullStart(), node.getEnd()) + : ts.createTextSpanFromBounds(node.getStart(), node.getEnd()); + } + function getTextOfNode(node) { + return ts.getTextOfNodeFromSourceText(sourceFile.text, node); + } + } + NavigationBar.getNavigationBarItems = getNavigationBarItems; + })(NavigationBar = ts.NavigationBar || (ts.NavigationBar = {})); +})(ts || (ts = {})); +var ts; +(function (ts) { + (function (PatternMatchKind) { + PatternMatchKind[PatternMatchKind["exact"] = 0] = "exact"; + PatternMatchKind[PatternMatchKind["prefix"] = 1] = "prefix"; + PatternMatchKind[PatternMatchKind["substring"] = 2] = "substring"; + PatternMatchKind[PatternMatchKind["camelCase"] = 3] = "camelCase"; + })(ts.PatternMatchKind || (ts.PatternMatchKind = {})); + var PatternMatchKind = ts.PatternMatchKind; + function createPatternMatch(kind, punctuationStripped, isCaseSensitive, camelCaseWeight) { + return { + kind: kind, + punctuationStripped: punctuationStripped, + isCaseSensitive: isCaseSensitive, + camelCaseWeight: camelCaseWeight + }; + } + function createPatternMatcher(pattern) { + var stringToWordSpans = {}; + pattern = pattern.trim(); + var fullPatternSegment = createSegment(pattern); + var dotSeparatedSegments = pattern.split(".").map(function (p) { return createSegment(p.trim()); }); + var invalidPattern = dotSeparatedSegments.length === 0 || ts.forEach(dotSeparatedSegments, segmentIsInvalid); + return { + getMatches: getMatches, + getMatchesForLastSegmentOfPattern: getMatchesForLastSegmentOfPattern, + patternContainsDots: dotSeparatedSegments.length > 1 + }; + function skipMatch(candidate) { + return invalidPattern || !candidate; + } + function getMatchesForLastSegmentOfPattern(candidate) { + if (skipMatch(candidate)) { + return undefined; + } + return matchSegment(candidate, ts.lastOrUndefined(dotSeparatedSegments)); + } + function getMatches(candidateContainers, candidate) { + if (skipMatch(candidate)) { + return undefined; + } + var candidateMatch = matchSegment(candidate, ts.lastOrUndefined(dotSeparatedSegments)); + if (!candidateMatch) { + return undefined; + } + candidateContainers = candidateContainers || []; + if (dotSeparatedSegments.length - 1 > candidateContainers.length) { + return undefined; + } + var totalMatch = candidateMatch; + for (var i = dotSeparatedSegments.length - 2, j = candidateContainers.length - 1; i >= 0; i--, j--) { + var segment = dotSeparatedSegments[i]; + var containerName = candidateContainers[j]; + var containerMatch = matchSegment(containerName, segment); + if (!containerMatch) { + return undefined; + } + ts.addRange(totalMatch, containerMatch); + } + return totalMatch; + } + function getWordSpans(word) { + if (!ts.hasProperty(stringToWordSpans, word)) { + stringToWordSpans[word] = breakIntoWordSpans(word); + } + return stringToWordSpans[word]; + } + function matchTextChunk(candidate, chunk, punctuationStripped) { + var index = indexOfIgnoringCase(candidate, chunk.textLowerCase); + if (index === 0) { + if (chunk.text.length === candidate.length) { + return createPatternMatch(PatternMatchKind.exact, punctuationStripped, candidate === chunk.text); + } + else { + return createPatternMatch(PatternMatchKind.prefix, punctuationStripped, startsWith(candidate, chunk.text)); + } + } + var isLowercase = chunk.isLowerCase; + if (isLowercase) { + if (index > 0) { + var wordSpans = getWordSpans(candidate); + for (var _i = 0; _i < wordSpans.length; _i++) { + var span = wordSpans[_i]; + if (partStartsWith(candidate, span, chunk.text, true)) { + return createPatternMatch(PatternMatchKind.substring, punctuationStripped, partStartsWith(candidate, span, chunk.text, false)); + } + } + } + } + else { + if (candidate.indexOf(chunk.text) > 0) { + return createPatternMatch(PatternMatchKind.substring, punctuationStripped, true); + } + } + if (!isLowercase) { + if (chunk.characterSpans.length > 0) { + var candidateParts = getWordSpans(candidate); + var camelCaseWeight = tryCamelCaseMatch(candidate, candidateParts, chunk, false); + if (camelCaseWeight !== undefined) { + return createPatternMatch(PatternMatchKind.camelCase, punctuationStripped, true, camelCaseWeight); + } + camelCaseWeight = tryCamelCaseMatch(candidate, candidateParts, chunk, true); + if (camelCaseWeight !== undefined) { + return createPatternMatch(PatternMatchKind.camelCase, punctuationStripped, false, camelCaseWeight); + } + } + } + if (isLowercase) { + if (chunk.text.length < candidate.length) { + if (index > 0 && isUpperCaseLetter(candidate.charCodeAt(index))) { + return createPatternMatch(PatternMatchKind.substring, punctuationStripped, false); + } + } + } + return undefined; + } + function containsSpaceOrAsterisk(text) { + for (var i = 0; i < text.length; i++) { + var ch = text.charCodeAt(i); + if (ch === 32 || ch === 42) { + return true; + } + } + return false; + } + function matchSegment(candidate, segment) { + if (!containsSpaceOrAsterisk(segment.totalTextChunk.text)) { + var match = matchTextChunk(candidate, segment.totalTextChunk, false); + if (match) { + return [match]; + } + } + var subWordTextChunks = segment.subWordTextChunks; + var matches = undefined; + for (var _i = 0; _i < subWordTextChunks.length; _i++) { + var subWordTextChunk = subWordTextChunks[_i]; + var result = matchTextChunk(candidate, subWordTextChunk, true); + if (!result) { + return undefined; + } + matches = matches || []; + matches.push(result); + } + return matches; + } + function partStartsWith(candidate, candidateSpan, pattern, ignoreCase, patternSpan) { + var patternPartStart = patternSpan ? patternSpan.start : 0; + var patternPartLength = patternSpan ? patternSpan.length : pattern.length; + if (patternPartLength > candidateSpan.length) { + return false; + } + if (ignoreCase) { + for (var i = 0; i < patternPartLength; i++) { + var ch1 = pattern.charCodeAt(patternPartStart + i); + var ch2 = candidate.charCodeAt(candidateSpan.start + i); + if (toLowerCase(ch1) !== toLowerCase(ch2)) { + return false; + } + } + } + else { + for (var i = 0; i < patternPartLength; i++) { + var ch1 = pattern.charCodeAt(patternPartStart + i); + var ch2 = candidate.charCodeAt(candidateSpan.start + i); + if (ch1 !== ch2) { + return false; + } + } + } + return true; + } + function tryCamelCaseMatch(candidate, candidateParts, chunk, ignoreCase) { + var chunkCharacterSpans = chunk.characterSpans; + var currentCandidate = 0; + var currentChunkSpan = 0; + var firstMatch = undefined; + var contiguous = undefined; + while (true) { + if (currentChunkSpan === chunkCharacterSpans.length) { + var weight = 0; + if (contiguous) { + weight += 1; + } + if (firstMatch === 0) { + weight += 2; + } + return weight; + } + else if (currentCandidate === candidateParts.length) { + return undefined; + } + var candidatePart = candidateParts[currentCandidate]; + var gotOneMatchThisCandidate = false; + for (; currentChunkSpan < chunkCharacterSpans.length; currentChunkSpan++) { + var chunkCharacterSpan = chunkCharacterSpans[currentChunkSpan]; + if (gotOneMatchThisCandidate) { + if (!isUpperCaseLetter(chunk.text.charCodeAt(chunkCharacterSpans[currentChunkSpan - 1].start)) || + !isUpperCaseLetter(chunk.text.charCodeAt(chunkCharacterSpans[currentChunkSpan].start))) { + break; + } + } + if (!partStartsWith(candidate, candidatePart, chunk.text, ignoreCase, chunkCharacterSpan)) { + break; + } + gotOneMatchThisCandidate = true; + firstMatch = firstMatch === undefined ? currentCandidate : firstMatch; + contiguous = contiguous === undefined ? true : contiguous; + candidatePart = ts.createTextSpan(candidatePart.start + chunkCharacterSpan.length, candidatePart.length - chunkCharacterSpan.length); + } + if (!gotOneMatchThisCandidate && contiguous !== undefined) { + contiguous = false; + } + currentCandidate++; + } + } + } + ts.createPatternMatcher = createPatternMatcher; + function patternMatchCompareTo(match1, match2) { + return compareType(match1, match2) || + compareCamelCase(match1, match2) || + compareCase(match1, match2) || + comparePunctuation(match1, match2); + } + function comparePunctuation(result1, result2) { + if (result1.punctuationStripped !== result2.punctuationStripped) { + return result1.punctuationStripped ? 1 : -1; + } + return 0; + } + function compareCase(result1, result2) { + if (result1.isCaseSensitive !== result2.isCaseSensitive) { + return result1.isCaseSensitive ? -1 : 1; + } + return 0; + } + function compareType(result1, result2) { + return result1.kind - result2.kind; + } + function compareCamelCase(result1, result2) { + if (result1.kind === PatternMatchKind.camelCase && result2.kind === PatternMatchKind.camelCase) { + return result2.camelCaseWeight - result1.camelCaseWeight; + } + return 0; + } + function createSegment(text) { + return { + totalTextChunk: createTextChunk(text), + subWordTextChunks: breakPatternIntoTextChunks(text) + }; + } + function segmentIsInvalid(segment) { + return segment.subWordTextChunks.length === 0; + } + function isUpperCaseLetter(ch) { + if (ch >= 65 && ch <= 90) { + return true; + } + if (ch < 127 || !ts.isUnicodeIdentifierStart(ch, 2)) { + return false; + } + var str = String.fromCharCode(ch); + return str === str.toUpperCase(); + } + function isLowerCaseLetter(ch) { + if (ch >= 97 && ch <= 122) { + return true; + } + if (ch < 127 || !ts.isUnicodeIdentifierStart(ch, 2)) { + return false; + } + var str = String.fromCharCode(ch); + return str === str.toLowerCase(); + } + function containsUpperCaseLetter(string) { + for (var i = 0, n = string.length; i < n; i++) { + if (isUpperCaseLetter(string.charCodeAt(i))) { + return true; + } + } + return false; + } + function startsWith(string, search) { + for (var i = 0, n = search.length; i < n; i++) { + if (string.charCodeAt(i) !== search.charCodeAt(i)) { + return false; + } + } + return true; + } + function indexOfIgnoringCase(string, value) { + for (var i = 0, n = string.length - value.length; i <= n; i++) { + if (startsWithIgnoringCase(string, value, i)) { + return i; + } + } + return -1; + } + function startsWithIgnoringCase(string, value, start) { + for (var i = 0, n = value.length; i < n; i++) { + var ch1 = toLowerCase(string.charCodeAt(i + start)); + var ch2 = value.charCodeAt(i); + if (ch1 !== ch2) { + return false; + } + } + return true; + } + function toLowerCase(ch) { + if (ch >= 65 && ch <= 90) { + return 97 + (ch - 65); + } + if (ch < 127) { + return ch; + } + return String.fromCharCode(ch).toLowerCase().charCodeAt(0); + } + function isDigit(ch) { + return ch >= 48 && ch <= 57; + } + function isWordChar(ch) { + return isUpperCaseLetter(ch) || isLowerCaseLetter(ch) || isDigit(ch) || ch === 95 || ch === 36; + } + function breakPatternIntoTextChunks(pattern) { + var result = []; + var wordStart = 0; + var wordLength = 0; + for (var i = 0; i < pattern.length; i++) { + var ch = pattern.charCodeAt(i); + if (isWordChar(ch)) { + if (wordLength++ === 0) { + wordStart = i; + } + } + else { + if (wordLength > 0) { + result.push(createTextChunk(pattern.substr(wordStart, wordLength))); + wordLength = 0; + } + } + } + if (wordLength > 0) { + result.push(createTextChunk(pattern.substr(wordStart, wordLength))); + } + return result; + } + function createTextChunk(text) { + var textLowerCase = text.toLowerCase(); + return { + text: text, + textLowerCase: textLowerCase, + isLowerCase: text === textLowerCase, + characterSpans: breakIntoCharacterSpans(text) + }; + } + function breakIntoCharacterSpans(identifier) { + return breakIntoSpans(identifier, false); + } + ts.breakIntoCharacterSpans = breakIntoCharacterSpans; + function breakIntoWordSpans(identifier) { + return breakIntoSpans(identifier, true); + } + ts.breakIntoWordSpans = breakIntoWordSpans; + function breakIntoSpans(identifier, word) { + var result = []; + var wordStart = 0; + for (var i = 1, n = identifier.length; i < n; i++) { + var lastIsDigit = isDigit(identifier.charCodeAt(i - 1)); + var currentIsDigit = isDigit(identifier.charCodeAt(i)); + var hasTransitionFromLowerToUpper = transitionFromLowerToUpper(identifier, word, i); + var hasTransitionFromUpperToLower = transitionFromUpperToLower(identifier, word, i, wordStart); + if (charIsPunctuation(identifier.charCodeAt(i - 1)) || + charIsPunctuation(identifier.charCodeAt(i)) || + lastIsDigit !== currentIsDigit || + hasTransitionFromLowerToUpper || + hasTransitionFromUpperToLower) { + if (!isAllPunctuation(identifier, wordStart, i)) { + result.push(ts.createTextSpan(wordStart, i - wordStart)); + } + wordStart = i; + } + } + if (!isAllPunctuation(identifier, wordStart, identifier.length)) { + result.push(ts.createTextSpan(wordStart, identifier.length - wordStart)); + } + return result; + } + function charIsPunctuation(ch) { + switch (ch) { + case 33: + case 34: + case 35: + case 37: + case 38: + case 39: + case 40: + case 41: + case 42: + case 44: + case 45: + case 46: + case 47: + case 58: + case 59: + case 63: + case 64: + case 91: + case 92: + case 93: + case 95: + case 123: + case 125: + return true; + } + return false; + } + function isAllPunctuation(identifier, start, end) { + for (var i = start; i < end; i++) { + var ch = identifier.charCodeAt(i); + if (!charIsPunctuation(ch) || ch === 95 || ch === 36) { + return false; + } + } + return true; + } + function transitionFromUpperToLower(identifier, word, index, wordStart) { + if (word) { + if (index !== wordStart && + index + 1 < identifier.length) { + var currentIsUpper = isUpperCaseLetter(identifier.charCodeAt(index)); + var nextIsLower = isLowerCaseLetter(identifier.charCodeAt(index + 1)); + if (currentIsUpper && nextIsLower) { + for (var i = wordStart; i < index; i++) { + if (!isUpperCaseLetter(identifier.charCodeAt(i))) { + return false; + } + } + return true; + } + } + } + return false; + } + function transitionFromLowerToUpper(identifier, word, index) { + var lastIsUpper = isUpperCaseLetter(identifier.charCodeAt(index - 1)); + var currentIsUpper = isUpperCaseLetter(identifier.charCodeAt(index)); + var transition = word + ? (currentIsUpper && !lastIsUpper) + : currentIsUpper; + return transition; + } +})(ts || (ts = {})); +var ts; +(function (ts) { + var SignatureHelp; + (function (SignatureHelp) { + var emptyArray = []; + function getSignatureHelpItems(program, sourceFile, position, cancellationToken) { + var typeChecker = program.getTypeChecker(); + var startingToken = ts.findTokenOnLeftOfPosition(sourceFile, position); + if (!startingToken) { + return undefined; + } + var argumentInfo = getContainingArgumentInfo(startingToken); + cancellationToken.throwIfCancellationRequested(); + if (!argumentInfo) { + return undefined; + } + var call = argumentInfo.invocation; + var candidates = []; + var resolvedSignature = typeChecker.getResolvedSignature(call, candidates); + cancellationToken.throwIfCancellationRequested(); + if (!candidates.length) { + if (ts.isJavaScript(sourceFile.fileName)) { + return createJavaScriptSignatureHelpItems(argumentInfo); + } + return undefined; + } + return createSignatureHelpItems(candidates, resolvedSignature, argumentInfo); + function createJavaScriptSignatureHelpItems(argumentInfo) { + if (argumentInfo.invocation.kind !== 168) { + return undefined; + } + var callExpression = argumentInfo.invocation; + var expression = callExpression.expression; + var name = expression.kind === 69 + ? expression + : expression.kind === 166 + ? expression.name + : undefined; + if (!name || !name.text) { + return undefined; + } + var typeChecker = program.getTypeChecker(); + for (var _i = 0, _a = program.getSourceFiles(); _i < _a.length; _i++) { + var sourceFile_1 = _a[_i]; + var nameToDeclarations = sourceFile_1.getNamedDeclarations(); + var declarations = ts.getProperty(nameToDeclarations, name.text); + if (declarations) { + for (var _b = 0; _b < declarations.length; _b++) { + var declaration = declarations[_b]; + var symbol = declaration.symbol; + if (symbol) { + var type = typeChecker.getTypeOfSymbolAtLocation(symbol, declaration); + if (type) { + var callSignatures = type.getCallSignatures(); + if (callSignatures && callSignatures.length) { + return createSignatureHelpItems(callSignatures, callSignatures[0], argumentInfo); + } + } + } + } + } + } + } + function getImmediatelyContainingArgumentInfo(node) { + if (node.parent.kind === 168 || node.parent.kind === 169) { + var callExpression = node.parent; + if (node.kind === 25 || + node.kind === 17) { + var list = getChildListThatStartsWithOpenerToken(callExpression, node, sourceFile); + var isTypeArgList = callExpression.typeArguments && callExpression.typeArguments.pos === list.pos; + ts.Debug.assert(list !== undefined); + return { + kind: isTypeArgList ? 0 : 1, + invocation: callExpression, + argumentsSpan: getApplicableSpanForArguments(list), + argumentIndex: 0, + argumentCount: getArgumentCount(list) + }; + } + var listItemInfo = ts.findListItemInfo(node); + if (listItemInfo) { + var list = listItemInfo.list; + var isTypeArgList = callExpression.typeArguments && callExpression.typeArguments.pos === list.pos; + var argumentIndex = getArgumentIndex(list, node); + var argumentCount = getArgumentCount(list); + ts.Debug.assert(argumentIndex === 0 || argumentIndex < argumentCount, "argumentCount < argumentIndex, " + argumentCount + " < " + argumentIndex); + return { + kind: isTypeArgList ? 0 : 1, + invocation: callExpression, + argumentsSpan: getApplicableSpanForArguments(list), + argumentIndex: argumentIndex, + argumentCount: argumentCount + }; + } + } + else if (node.kind === 11 && node.parent.kind === 170) { + if (ts.isInsideTemplateLiteral(node, position)) { + return getArgumentListInfoForTemplate(node.parent, 0); + } + } + else if (node.kind === 12 && node.parent.parent.kind === 170) { + var templateExpression = node.parent; + var tagExpression = templateExpression.parent; + ts.Debug.assert(templateExpression.kind === 183); + var argumentIndex = ts.isInsideTemplateLiteral(node, position) ? 0 : 1; + return getArgumentListInfoForTemplate(tagExpression, argumentIndex); + } + else if (node.parent.kind === 190 && node.parent.parent.parent.kind === 170) { + var templateSpan = node.parent; + var templateExpression = templateSpan.parent; + var tagExpression = templateExpression.parent; + ts.Debug.assert(templateExpression.kind === 183); + if (node.kind === 14 && !ts.isInsideTemplateLiteral(node, position)) { + return undefined; + } + var spanIndex = templateExpression.templateSpans.indexOf(templateSpan); + var argumentIndex = getArgumentIndexForTemplatePiece(spanIndex, node); + return getArgumentListInfoForTemplate(tagExpression, argumentIndex); + } + return undefined; + } + function getArgumentIndex(argumentsList, node) { + var argumentIndex = 0; + var listChildren = argumentsList.getChildren(); + for (var _i = 0; _i < listChildren.length; _i++) { + var child = listChildren[_i]; + if (child === node) { + break; + } + if (child.kind !== 24) { + argumentIndex++; + } + } + return argumentIndex; + } + 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) { + argumentCount++; + } + return argumentCount; + } + function getArgumentIndexForTemplatePiece(spanIndex, node) { + ts.Debug.assert(position >= node.getStart(), "Assumed 'position' could not occur before node."); + if (ts.isTemplateLiteralKind(node.kind)) { + if (ts.isInsideTemplateLiteral(node, position)) { + return 0; + } + return spanIndex + 2; + } + return spanIndex + 1; + } + function getArgumentListInfoForTemplate(tagExpression, argumentIndex) { + var argumentCount = tagExpression.template.kind === 11 + ? 1 + : tagExpression.template.templateSpans.length + 1; + ts.Debug.assert(argumentIndex === 0 || argumentIndex < argumentCount, "argumentCount < argumentIndex, " + argumentCount + " < " + argumentIndex); + return { + kind: 2, + invocation: tagExpression, + argumentsSpan: getApplicableSpanForTaggedTemplate(tagExpression), + argumentIndex: argumentIndex, + argumentCount: argumentCount + }; + } + function getApplicableSpanForArguments(argumentsList) { + var applicableSpanStart = argumentsList.getFullStart(); + var applicableSpanEnd = ts.skipTrivia(sourceFile.text, argumentsList.getEnd(), false); + return ts.createTextSpan(applicableSpanStart, applicableSpanEnd - applicableSpanStart); + } + function getApplicableSpanForTaggedTemplate(taggedTemplate) { + var template = taggedTemplate.template; + var applicableSpanStart = template.getStart(); + var applicableSpanEnd = template.getEnd(); + if (template.kind === 183) { + var lastSpan = ts.lastOrUndefined(template.templateSpans); + if (lastSpan.literal.getFullWidth() === 0) { + applicableSpanEnd = ts.skipTrivia(sourceFile.text, applicableSpanEnd, false); + } + } + return ts.createTextSpan(applicableSpanStart, applicableSpanEnd - applicableSpanStart); + } + function getContainingArgumentInfo(node) { + for (var n = node; n.kind !== 248; n = n.parent) { + if (ts.isFunctionBlock(n)) { + return undefined; + } + if (n.pos < n.parent.pos || n.end > n.parent.end) { + ts.Debug.fail("Node of kind " + n.kind + " is not a subspan of its parent of kind " + n.parent.kind); + } + var argumentInfo_1 = getImmediatelyContainingArgumentInfo(n); + if (argumentInfo_1) { + return argumentInfo_1; + } + } + return undefined; + } + function getChildListThatStartsWithOpenerToken(parent, openerToken, sourceFile) { + var children = parent.getChildren(sourceFile); + var indexOfOpenerToken = children.indexOf(openerToken); + ts.Debug.assert(indexOfOpenerToken >= 0 && children.length > indexOfOpenerToken + 1); + return children[indexOfOpenerToken + 1]; + } + function selectBestInvalidOverloadIndex(candidates, argumentCount) { + var maxParamsSignatureIndex = -1; + var maxParams = -1; + for (var i = 0; i < candidates.length; i++) { + var candidate = candidates[i]; + if (candidate.hasRestParameter || candidate.parameters.length >= argumentCount) { + return i; + } + if (candidate.parameters.length > maxParams) { + maxParams = candidate.parameters.length; + maxParamsSignatureIndex = i; + } + } + return maxParamsSignatureIndex; + } + function createSignatureHelpItems(candidates, bestSignature, argumentListInfo) { + var applicableSpan = argumentListInfo.argumentsSpan; + var isTypeParameterList = argumentListInfo.kind === 0; + var invocation = argumentListInfo.invocation; + var callTarget = ts.getInvokedExpression(invocation); + var callTargetSymbol = typeChecker.getSymbolAtLocation(callTarget); + var callTargetDisplayParts = callTargetSymbol && ts.symbolToDisplayParts(typeChecker, callTargetSymbol, undefined, undefined); + var items = ts.map(candidates, function (candidateSignature) { + var signatureHelpParameters; + var prefixDisplayParts = []; + var suffixDisplayParts = []; + if (callTargetDisplayParts) { + ts.addRange(prefixDisplayParts, callTargetDisplayParts); + } + if (isTypeParameterList) { + prefixDisplayParts.push(ts.punctuationPart(25)); + var typeParameters = candidateSignature.typeParameters; + signatureHelpParameters = typeParameters && typeParameters.length > 0 ? ts.map(typeParameters, createSignatureHelpParameterForTypeParameter) : emptyArray; + suffixDisplayParts.push(ts.punctuationPart(27)); + var parameterParts = ts.mapToDisplayParts(function (writer) { + return typeChecker.getSymbolDisplayBuilder().buildDisplayForParametersAndDelimiters(candidateSignature.parameters, writer, invocation); + }); + ts.addRange(suffixDisplayParts, parameterParts); + } + else { + var typeParameterParts = ts.mapToDisplayParts(function (writer) { + return typeChecker.getSymbolDisplayBuilder().buildDisplayForTypeParametersAndDelimiters(candidateSignature.typeParameters, writer, invocation); + }); + ts.addRange(prefixDisplayParts, typeParameterParts); + prefixDisplayParts.push(ts.punctuationPart(17)); + var parameters = candidateSignature.parameters; + signatureHelpParameters = parameters.length > 0 ? ts.map(parameters, createSignatureHelpParameterForParameter) : emptyArray; + suffixDisplayParts.push(ts.punctuationPart(18)); + } + var returnTypeParts = ts.mapToDisplayParts(function (writer) { + return typeChecker.getSymbolDisplayBuilder().buildReturnTypeDisplay(candidateSignature, writer, invocation); + }); + ts.addRange(suffixDisplayParts, returnTypeParts); + return { + isVariadic: candidateSignature.hasRestParameter, + prefixDisplayParts: prefixDisplayParts, + suffixDisplayParts: suffixDisplayParts, + separatorDisplayParts: [ts.punctuationPart(24), ts.spacePart()], + parameters: signatureHelpParameters, + documentation: candidateSignature.getDocumentationComment() + }; + }); + var argumentIndex = argumentListInfo.argumentIndex; + var argumentCount = argumentListInfo.argumentCount; + var selectedItemIndex = candidates.indexOf(bestSignature); + if (selectedItemIndex < 0) { + selectedItemIndex = selectBestInvalidOverloadIndex(candidates, argumentCount); + } + ts.Debug.assert(argumentIndex === 0 || argumentIndex < argumentCount, "argumentCount < argumentIndex, " + argumentCount + " < " + argumentIndex); + return { + items: items, + applicableSpan: applicableSpan, + selectedItemIndex: selectedItemIndex, + argumentIndex: argumentIndex, + argumentCount: argumentCount + }; + function createSignatureHelpParameterForParameter(parameter) { + var displayParts = ts.mapToDisplayParts(function (writer) { + return typeChecker.getSymbolDisplayBuilder().buildParameterDisplay(parameter, writer, invocation); + }); + return { + name: parameter.name, + documentation: parameter.getDocumentationComment(), + displayParts: displayParts, + isOptional: typeChecker.isOptionalParameter(parameter.valueDeclaration) + }; + } + function createSignatureHelpParameterForTypeParameter(typeParameter) { + var displayParts = ts.mapToDisplayParts(function (writer) { + return typeChecker.getSymbolDisplayBuilder().buildTypeParameterDisplay(typeParameter, writer, invocation); + }); + return { + name: typeParameter.symbol.name, + documentation: emptyArray, + displayParts: displayParts, + isOptional: false + }; + } + } + } + SignatureHelp.getSignatureHelpItems = getSignatureHelpItems; + })(SignatureHelp = ts.SignatureHelp || (ts.SignatureHelp = {})); +})(ts || (ts = {})); +var ts; +(function (ts) { + function getEndLinePosition(line, sourceFile) { + ts.Debug.assert(line >= 0); + var lineStarts = sourceFile.getLineStarts(); + var lineIndex = line; + if (lineIndex + 1 === lineStarts.length) { + return sourceFile.text.length - 1; + } + else { + var start = lineStarts[lineIndex]; + var pos = lineStarts[lineIndex + 1] - 1; + ts.Debug.assert(ts.isLineBreak(sourceFile.text.charCodeAt(pos))); + while (start <= pos && ts.isLineBreak(sourceFile.text.charCodeAt(pos))) { + pos--; + } + return pos; + } + } + ts.getEndLinePosition = getEndLinePosition; + function getLineStartPositionForPosition(position, sourceFile) { + var lineStarts = sourceFile.getLineStarts(); + var line = sourceFile.getLineAndCharacterOfPosition(position).line; + return lineStarts[line]; + } + ts.getLineStartPositionForPosition = getLineStartPositionForPosition; + function rangeContainsRange(r1, r2) { + return startEndContainsRange(r1.pos, r1.end, r2); + } + ts.rangeContainsRange = rangeContainsRange; + function startEndContainsRange(start, end, range) { + return start <= range.pos && end >= range.end; + } + ts.startEndContainsRange = startEndContainsRange; + function rangeContainsStartEnd(range, start, end) { + return range.pos <= start && range.end >= end; + } + ts.rangeContainsStartEnd = rangeContainsStartEnd; + function rangeOverlapsWithStartEnd(r1, start, end) { + return startEndOverlapsWithStartEnd(r1.pos, r1.end, start, end); + } + ts.rangeOverlapsWithStartEnd = rangeOverlapsWithStartEnd; + function startEndOverlapsWithStartEnd(start1, end1, start2, end2) { + var start = Math.max(start1, start2); + var end = Math.min(end1, end2); + return start < end; + } + ts.startEndOverlapsWithStartEnd = startEndOverlapsWithStartEnd; + function positionBelongsToNode(candidate, position, sourceFile) { + return candidate.end > position || !isCompletedNode(candidate, sourceFile); + } + ts.positionBelongsToNode = positionBelongsToNode; + function isCompletedNode(n, sourceFile) { + if (ts.nodeIsMissing(n)) { + return false; + } + switch (n.kind) { + case 214: + case 215: + case 217: + case 165: + case 161: + case 155: + case 192: + case 219: + case 220: + return nodeEndsWith(n, 16, sourceFile); + case 244: + return isCompletedNode(n.block, sourceFile); + case 169: + if (!n.arguments) { + return true; + } + case 168: + case 172: + case 160: + return nodeEndsWith(n, 18, sourceFile); + case 152: + case 153: + return isCompletedNode(n.type, sourceFile); + case 144: + case 145: + case 146: + case 213: + case 173: + case 143: + case 142: + case 148: + case 147: + case 174: + if (n.body) { + return isCompletedNode(n.body, sourceFile); + } + if (n.type) { + return isCompletedNode(n.type, sourceFile); + } + return hasChildOfKind(n, 18, sourceFile); + case 218: + return n.body && isCompletedNode(n.body, sourceFile); + case 196: + if (n.elseStatement) { + return isCompletedNode(n.elseStatement, sourceFile); + } + return isCompletedNode(n.thenStatement, sourceFile); + case 195: + return isCompletedNode(n.expression, sourceFile) || + hasChildOfKind(n, 23); + case 164: + case 162: + case 167: + case 136: + case 157: + return nodeEndsWith(n, 20, sourceFile); + case 149: + if (n.type) { + return isCompletedNode(n.type, sourceFile); + } + return hasChildOfKind(n, 20, sourceFile); + case 241: + case 242: + return false; + case 199: + case 200: + case 201: + case 198: + return isCompletedNode(n.statement, sourceFile); + case 197: + var hasWhileKeyword = findChildOfKind(n, 104, sourceFile); + if (hasWhileKeyword) { + return nodeEndsWith(n, 18, sourceFile); + } + return isCompletedNode(n.statement, sourceFile); + case 154: + return isCompletedNode(n.exprName, sourceFile); + case 176: + case 175: + case 177: + case 184: + case 185: + var unaryWordExpression = n; + return isCompletedNode(unaryWordExpression.expression, sourceFile); + case 170: + return isCompletedNode(n.template, sourceFile); + case 183: + var lastSpan = ts.lastOrUndefined(n.templateSpans); + return isCompletedNode(lastSpan, sourceFile); + case 190: + return ts.nodeIsPresent(n.literal); + case 179: + return isCompletedNode(n.operand, sourceFile); + case 181: + return isCompletedNode(n.right, sourceFile); + case 182: + return isCompletedNode(n.whenFalse, sourceFile); + default: + return true; + } + } + ts.isCompletedNode = isCompletedNode; + function nodeEndsWith(n, expectedLastToken, sourceFile) { + var children = n.getChildren(sourceFile); + if (children.length) { + var last = ts.lastOrUndefined(children); + if (last.kind === expectedLastToken) { + return true; + } + else if (last.kind === 23 && children.length !== 1) { + return children[children.length - 2].kind === expectedLastToken; + } + } + return false; + } + function findListItemInfo(node) { + var list = findContainingList(node); + if (!list) { + return undefined; + } + var children = list.getChildren(); + var listItemIndex = ts.indexOf(children, node); + return { + listItemIndex: listItemIndex, + list: list + }; + } + ts.findListItemInfo = findListItemInfo; + function hasChildOfKind(n, kind, sourceFile) { + return !!findChildOfKind(n, kind, sourceFile); + } + ts.hasChildOfKind = hasChildOfKind; + function findChildOfKind(n, kind, sourceFile) { + return ts.forEach(n.getChildren(sourceFile), function (c) { return c.kind === kind && c; }); + } + ts.findChildOfKind = findChildOfKind; + function findContainingList(node) { + var syntaxList = ts.forEach(node.parent.getChildren(), function (c) { + if (c.kind === 271 && c.pos <= node.pos && c.end >= node.end) { + return c; + } + }); + ts.Debug.assert(!syntaxList || ts.contains(syntaxList.getChildren(), node)); + return syntaxList; + } + ts.findContainingList = findContainingList; + function getTouchingWord(sourceFile, position) { + return getTouchingToken(sourceFile, position, function (n) { return isWord(n.kind); }); + } + ts.getTouchingWord = getTouchingWord; + function getTouchingPropertyName(sourceFile, position) { + return getTouchingToken(sourceFile, position, function (n) { return isPropertyName(n.kind); }); + } + ts.getTouchingPropertyName = getTouchingPropertyName; + function getTouchingToken(sourceFile, position, includeItemAtEndPosition) { + return getTokenAtPositionWorker(sourceFile, position, false, includeItemAtEndPosition); + } + ts.getTouchingToken = getTouchingToken; + function getTokenAtPosition(sourceFile, position) { + return getTokenAtPositionWorker(sourceFile, position, true, undefined); + } + ts.getTokenAtPosition = getTokenAtPosition; + function getTokenAtPositionWorker(sourceFile, position, allowPositionInLeadingTrivia, includeItemAtEndPosition) { + var current = sourceFile; + outer: while (true) { + if (isToken(current)) { + return current; + } + for (var i = 0, n = current.getChildCount(sourceFile); i < n; i++) { + var child = current.getChildAt(i); + var start = allowPositionInLeadingTrivia ? child.getFullStart() : child.getStart(sourceFile); + if (start <= position) { + var end = child.getEnd(); + if (position < end || (position === end && child.kind === 1)) { + current = child; + continue outer; + } + else if (includeItemAtEndPosition && end === position) { + var previousToken = findPrecedingToken(position, sourceFile, child); + if (previousToken && includeItemAtEndPosition(previousToken)) { + return previousToken; + } + } + } + } + return current; + } + } + function findTokenOnLeftOfPosition(file, position) { + var tokenAtPosition = getTokenAtPosition(file, position); + if (isToken(tokenAtPosition) && position > tokenAtPosition.getStart(file) && position < tokenAtPosition.getEnd()) { + return tokenAtPosition; + } + return findPrecedingToken(position, file); + } + ts.findTokenOnLeftOfPosition = findTokenOnLeftOfPosition; + function findNextToken(previousToken, parent) { + return find(parent); + function find(n) { + if (isToken(n) && n.pos === previousToken.end) { + return n; + } + var children = n.getChildren(); + for (var _i = 0; _i < children.length; _i++) { + var child = children[_i]; + var shouldDiveInChildNode = (child.pos <= previousToken.pos && child.end > previousToken.end) || + (child.pos === previousToken.end); + if (shouldDiveInChildNode && nodeHasTokens(child)) { + return find(child); + } + } + return undefined; + } + } + ts.findNextToken = findNextToken; + function findPrecedingToken(position, sourceFile, startNode) { + return find(startNode || sourceFile); + function findRightmostToken(n) { + if (isToken(n) || n.kind === 236) { + return n; + } + var children = n.getChildren(); + var candidate = findRightmostChildNodeWithTokens(children, children.length); + return candidate && findRightmostToken(candidate); + } + function find(n) { + if (isToken(n) || n.kind === 236) { + return n; + } + var children = n.getChildren(); + for (var i = 0, len = children.length; i < len; i++) { + var child = children[i]; + if (position < child.end && (nodeHasTokens(child) || child.kind === 236)) { + var start = child.getStart(sourceFile); + var lookInPreviousChild = (start >= position) || + (child.kind === 236 && start === child.end); + if (lookInPreviousChild) { + var candidate = findRightmostChildNodeWithTokens(children, i); + return candidate && findRightmostToken(candidate); + } + else { + return find(child); + } + } + } + ts.Debug.assert(startNode !== undefined || n.kind === 248); + if (children.length) { + var candidate = findRightmostChildNodeWithTokens(children, children.length); + return candidate && findRightmostToken(candidate); + } + } + function findRightmostChildNodeWithTokens(children, exclusiveStartPosition) { + for (var i = exclusiveStartPosition - 1; i >= 0; --i) { + if (nodeHasTokens(children[i])) { + return children[i]; + } + } + } + } + ts.findPrecedingToken = findPrecedingToken; + function isInString(sourceFile, position) { + var token = getTokenAtPosition(sourceFile, position); + return token && token.kind === 9 && position > token.getStart(); + } + ts.isInString = isInString; + function isInComment(sourceFile, position) { + return isInCommentHelper(sourceFile, position, undefined); + } + ts.isInComment = isInComment; + function isInCommentHelper(sourceFile, position, predicate) { + var token = getTokenAtPosition(sourceFile, position); + if (token && position <= token.getStart()) { + var commentRanges = ts.getLeadingCommentRanges(sourceFile.text, token.pos); + return predicate ? + ts.forEach(commentRanges, function (c) { return c.pos < position && + (c.kind == 2 ? position <= c.end : position < c.end) && + predicate(c); }) : + ts.forEach(commentRanges, function (c) { return c.pos < position && + (c.kind == 2 ? position <= c.end : position < c.end); }); + } + return false; + } + ts.isInCommentHelper = isInCommentHelper; + function hasDocComment(sourceFile, position) { + var token = getTokenAtPosition(sourceFile, position); + var commentRanges = ts.getLeadingCommentRanges(sourceFile.text, token.pos); + return ts.forEach(commentRanges, jsDocPrefix); + function jsDocPrefix(c) { + var text = sourceFile.text; + return text.length >= c.pos + 3 && text[c.pos] === '/' && text[c.pos + 1] === '*' && text[c.pos + 2] === '*'; + } + } + ts.hasDocComment = hasDocComment; + function getJsDocTagAtPosition(sourceFile, position) { + var node = ts.getTokenAtPosition(sourceFile, position); + if (isToken(node)) { + switch (node.kind) { + case 102: + case 108: + case 74: + node = node.parent === undefined ? undefined : node.parent.parent; + break; + default: + node = node.parent; + break; + } + } + if (node) { + var jsDocComment = node.jsDocComment; + if (jsDocComment) { + for (var _i = 0, _a = jsDocComment.tags; _i < _a.length; _i++) { + var tag = _a[_i]; + if (tag.pos <= position && position <= tag.end) { + return tag; + } + } + } + } + return undefined; + } + ts.getJsDocTagAtPosition = getJsDocTagAtPosition; + function nodeHasTokens(n) { + return n.getWidth() !== 0; + } + function getNodeModifiers(node) { + var flags = ts.getCombinedNodeFlags(node); + var result = []; + if (flags & 32) + result.push(ts.ScriptElementKindModifier.privateMemberModifier); + if (flags & 64) + result.push(ts.ScriptElementKindModifier.protectedMemberModifier); + if (flags & 16) + result.push(ts.ScriptElementKindModifier.publicMemberModifier); + if (flags & 128) + result.push(ts.ScriptElementKindModifier.staticModifier); + if (flags & 256) + result.push(ts.ScriptElementKindModifier.abstractModifier); + if (flags & 1) + result.push(ts.ScriptElementKindModifier.exportedModifier); + if (ts.isInAmbientContext(node)) + result.push(ts.ScriptElementKindModifier.ambientModifier); + return result.length > 0 ? result.join(',') : ts.ScriptElementKindModifier.none; + } + ts.getNodeModifiers = getNodeModifiers; + function getTypeArgumentOrTypeParameterList(node) { + if (node.kind === 151 || node.kind === 168) { + return node.typeArguments; + } + if (ts.isFunctionLike(node) || node.kind === 214 || node.kind === 215) { + return node.typeParameters; + } + return undefined; + } + ts.getTypeArgumentOrTypeParameterList = getTypeArgumentOrTypeParameterList; + function isToken(n) { + return n.kind >= 0 && n.kind <= 134; + } + ts.isToken = isToken; + function isWord(kind) { + return kind === 69 || ts.isKeyword(kind); + } + ts.isWord = isWord; + function isPropertyName(kind) { + return kind === 9 || kind === 8 || isWord(kind); + } + function isComment(kind) { + return kind === 2 || kind === 3; + } + ts.isComment = isComment; + function isStringOrRegularExpressionOrTemplateLiteral(kind) { + if (kind === 9 + || kind === 10 + || ts.isTemplateLiteralKind(kind)) { + return true; + } + return false; + } + ts.isStringOrRegularExpressionOrTemplateLiteral = isStringOrRegularExpressionOrTemplateLiteral; + function isPunctuation(kind) { + return 15 <= kind && kind <= 68; + } + ts.isPunctuation = isPunctuation; + function isInsideTemplateLiteral(node, position) { + return ts.isTemplateLiteralKind(node.kind) + && (node.getStart() < position && position < node.getEnd()) || (!!node.isUnterminated && position === node.getEnd()); + } + ts.isInsideTemplateLiteral = isInsideTemplateLiteral; + function isAccessibilityModifier(kind) { + switch (kind) { + case 112: + case 110: + case 111: + return true; + } + return false; + } + ts.isAccessibilityModifier = isAccessibilityModifier; + function compareDataObjects(dst, src) { + for (var e in dst) { + if (typeof dst[e] === "object") { + if (!compareDataObjects(dst[e], src[e])) { + return false; + } + } + else if (typeof dst[e] !== "function") { + if (dst[e] !== src[e]) { + return false; + } + } + } + return true; + } + ts.compareDataObjects = compareDataObjects; +})(ts || (ts = {})); +var ts; +(function (ts) { + function isFirstDeclarationOfSymbolParameter(symbol) { + return symbol.declarations && symbol.declarations.length > 0 && symbol.declarations[0].kind === 138; + } + ts.isFirstDeclarationOfSymbolParameter = isFirstDeclarationOfSymbolParameter; + var displayPartWriter = getDisplayPartWriter(); + function getDisplayPartWriter() { + var displayParts; + var lineStart; + var indent; + resetWriter(); + return { + displayParts: function () { return displayParts; }, + writeKeyword: function (text) { return writeKind(text, ts.SymbolDisplayPartKind.keyword); }, + writeOperator: function (text) { return writeKind(text, ts.SymbolDisplayPartKind.operator); }, + writePunctuation: function (text) { return writeKind(text, ts.SymbolDisplayPartKind.punctuation); }, + writeSpace: function (text) { return writeKind(text, ts.SymbolDisplayPartKind.space); }, + writeStringLiteral: function (text) { return writeKind(text, ts.SymbolDisplayPartKind.stringLiteral); }, + writeParameter: function (text) { return writeKind(text, ts.SymbolDisplayPartKind.parameterName); }, + writeSymbol: writeSymbol, + writeLine: writeLine, + increaseIndent: function () { indent++; }, + decreaseIndent: function () { indent--; }, + clear: resetWriter, + trackSymbol: function () { }, + reportInaccessibleThisError: function () { } + }; + function writeIndent() { + if (lineStart) { + var indentString = ts.getIndentString(indent); + if (indentString) { + displayParts.push(displayPart(indentString, ts.SymbolDisplayPartKind.space)); + } + lineStart = false; + } + } + function writeKind(text, kind) { + writeIndent(); + displayParts.push(displayPart(text, kind)); + } + function writeSymbol(text, symbol) { + writeIndent(); + displayParts.push(symbolPart(text, symbol)); + } + function writeLine() { + displayParts.push(lineBreakPart()); + lineStart = true; + } + function resetWriter() { + displayParts = []; + lineStart = true; + indent = 0; + } + } + function symbolPart(text, symbol) { + return displayPart(text, displayPartKind(symbol), symbol); + function displayPartKind(symbol) { + var flags = symbol.flags; + if (flags & 3) { + return isFirstDeclarationOfSymbolParameter(symbol) ? ts.SymbolDisplayPartKind.parameterName : ts.SymbolDisplayPartKind.localName; + } + else if (flags & 4) { + return ts.SymbolDisplayPartKind.propertyName; + } + else if (flags & 32768) { + return ts.SymbolDisplayPartKind.propertyName; + } + else if (flags & 65536) { + return ts.SymbolDisplayPartKind.propertyName; + } + else if (flags & 8) { + return ts.SymbolDisplayPartKind.enumMemberName; + } + else if (flags & 16) { + return ts.SymbolDisplayPartKind.functionName; + } + else if (flags & 32) { + return ts.SymbolDisplayPartKind.className; + } + else if (flags & 64) { + return ts.SymbolDisplayPartKind.interfaceName; + } + else if (flags & 384) { + return ts.SymbolDisplayPartKind.enumName; + } + else if (flags & 1536) { + return ts.SymbolDisplayPartKind.moduleName; + } + else if (flags & 8192) { + return ts.SymbolDisplayPartKind.methodName; + } + else if (flags & 262144) { + return ts.SymbolDisplayPartKind.typeParameterName; + } + else if (flags & 524288) { + return ts.SymbolDisplayPartKind.aliasName; + } + else if (flags & 8388608) { + return ts.SymbolDisplayPartKind.aliasName; + } + return ts.SymbolDisplayPartKind.text; + } + } + ts.symbolPart = symbolPart; + function displayPart(text, kind, symbol) { + return { + text: text, + kind: ts.SymbolDisplayPartKind[kind] + }; + } + ts.displayPart = displayPart; + function spacePart() { + return displayPart(" ", ts.SymbolDisplayPartKind.space); + } + ts.spacePart = spacePart; + function keywordPart(kind) { + return displayPart(ts.tokenToString(kind), ts.SymbolDisplayPartKind.keyword); + } + ts.keywordPart = keywordPart; + function punctuationPart(kind) { + return displayPart(ts.tokenToString(kind), ts.SymbolDisplayPartKind.punctuation); + } + ts.punctuationPart = punctuationPart; + function operatorPart(kind) { + return displayPart(ts.tokenToString(kind), ts.SymbolDisplayPartKind.operator); + } + ts.operatorPart = operatorPart; + function textOrKeywordPart(text) { + var kind = ts.stringToToken(text); + return kind === undefined + ? textPart(text) + : keywordPart(kind); + } + ts.textOrKeywordPart = textOrKeywordPart; + function textPart(text) { + return displayPart(text, ts.SymbolDisplayPartKind.text); + } + ts.textPart = textPart; + var carriageReturnLineFeed = "\r\n"; + function getNewLineOrDefaultFromHost(host) { + return host.getNewLine ? host.getNewLine() : carriageReturnLineFeed; + } + ts.getNewLineOrDefaultFromHost = getNewLineOrDefaultFromHost; + function lineBreakPart() { + return displayPart("\n", ts.SymbolDisplayPartKind.lineBreak); + } + ts.lineBreakPart = lineBreakPart; + function mapToDisplayParts(writeDisplayParts) { + writeDisplayParts(displayPartWriter); + var result = displayPartWriter.displayParts(); + displayPartWriter.clear(); + return result; + } + ts.mapToDisplayParts = mapToDisplayParts; + function typeToDisplayParts(typechecker, type, enclosingDeclaration, flags) { + return mapToDisplayParts(function (writer) { + typechecker.getSymbolDisplayBuilder().buildTypeDisplay(type, writer, enclosingDeclaration, flags); + }); + } + ts.typeToDisplayParts = typeToDisplayParts; + function symbolToDisplayParts(typeChecker, symbol, enclosingDeclaration, meaning, flags) { + return mapToDisplayParts(function (writer) { + typeChecker.getSymbolDisplayBuilder().buildSymbolDisplay(symbol, writer, enclosingDeclaration, meaning, flags); + }); + } + ts.symbolToDisplayParts = symbolToDisplayParts; + function signatureToDisplayParts(typechecker, signature, enclosingDeclaration, flags) { + return mapToDisplayParts(function (writer) { + typechecker.getSymbolDisplayBuilder().buildSignatureDisplay(signature, writer, enclosingDeclaration, flags); + }); + } + ts.signatureToDisplayParts = signatureToDisplayParts; + function getDeclaredName(typeChecker, symbol, location) { + if (isImportOrExportSpecifierName(location)) { + return location.getText(); + } + var localExportDefaultSymbol = ts.getLocalSymbolForExportDefault(symbol); + var name = typeChecker.symbolToString(localExportDefaultSymbol || symbol); + return name; + } + ts.getDeclaredName = getDeclaredName; + function isImportOrExportSpecifierName(location) { + return location.parent && + (location.parent.kind === 226 || location.parent.kind === 230) && + location.parent.propertyName === location; + } + ts.isImportOrExportSpecifierName = isImportOrExportSpecifierName; + function stripQuotes(name) { + var length = name.length; + if (length >= 2 && + name.charCodeAt(0) === name.charCodeAt(length - 1) && + (name.charCodeAt(0) === 34 || name.charCodeAt(0) === 39)) { + return name.substring(1, length - 1); + } + ; + return name; + } + ts.stripQuotes = stripQuotes; +})(ts || (ts = {})); +var ts; +(function (ts) { + var formatting; + (function (formatting) { + var standardScanner = ts.createScanner(2, false, 0); + var jsxScanner = ts.createScanner(2, false, 1); + var scanner; + function getFormattingScanner(sourceFile, startPos, endPos) { + ts.Debug.assert(scanner === undefined); + scanner = sourceFile.languageVariant === 1 ? jsxScanner : standardScanner; + scanner.setText(sourceFile.text); + scanner.setTextPos(startPos); + var wasNewLine = true; + var leadingTrivia; + var trailingTrivia; + var savedPos; + var lastScanAction; + var lastTokenInfo; + return { + advance: advance, + readTokenInfo: readTokenInfo, + isOnToken: isOnToken, + lastTrailingTriviaWasNewLine: function () { return wasNewLine; }, + close: function () { + ts.Debug.assert(scanner !== undefined); + lastTokenInfo = undefined; + scanner.setText(undefined); + scanner = undefined; + } + }; + function advance() { + ts.Debug.assert(scanner !== undefined); + lastTokenInfo = undefined; + var isStarted = scanner.getStartPos() !== startPos; + if (isStarted) { + if (trailingTrivia) { + ts.Debug.assert(trailingTrivia.length !== 0); + wasNewLine = ts.lastOrUndefined(trailingTrivia).kind === 4; + } + else { + wasNewLine = false; + } + } + leadingTrivia = undefined; + trailingTrivia = undefined; + if (!isStarted) { + scanner.scan(); + } + var t; + var pos = scanner.getStartPos(); + while (pos < endPos) { + var t_1 = scanner.getToken(); + if (!ts.isTrivia(t_1)) { + break; + } + scanner.scan(); + var item = { + pos: pos, + end: scanner.getStartPos(), + kind: t_1 + }; + pos = scanner.getStartPos(); + if (!leadingTrivia) { + leadingTrivia = []; + } + leadingTrivia.push(item); + } + savedPos = scanner.getStartPos(); + } + function shouldRescanGreaterThanToken(node) { + if (node) { + switch (node.kind) { + case 29: + case 64: + case 65: + case 45: + case 44: + return true; + } + } + return false; + } + function shouldRescanJsxIdentifier(node) { + if (node.parent) { + switch (node.parent.kind) { + case 238: + case 235: + case 237: + case 234: + return node.kind === 69; + } + } + return false; + } + function shouldRescanSlashToken(container) { + return container.kind === 10; + } + function shouldRescanTemplateToken(container) { + return container.kind === 13 || + container.kind === 14; + } + function startsWithSlashToken(t) { + return t === 39 || t === 61; + } + function readTokenInfo(n) { + ts.Debug.assert(scanner !== undefined); + if (!isOnToken()) { + return { + leadingTrivia: leadingTrivia, + trailingTrivia: undefined, + token: undefined + }; + } + var expectedScanAction = shouldRescanGreaterThanToken(n) + ? 1 + : shouldRescanSlashToken(n) + ? 2 + : shouldRescanTemplateToken(n) + ? 3 + : shouldRescanJsxIdentifier(n) + ? 4 + : 0; + if (lastTokenInfo && expectedScanAction === lastScanAction) { + return fixTokenKind(lastTokenInfo, n); + } + if (scanner.getStartPos() !== savedPos) { + ts.Debug.assert(lastTokenInfo !== undefined); + scanner.setTextPos(savedPos); + scanner.scan(); + } + var currentToken = scanner.getToken(); + if (expectedScanAction === 1 && currentToken === 27) { + currentToken = scanner.reScanGreaterToken(); + ts.Debug.assert(n.kind === currentToken); + lastScanAction = 1; + } + else if (expectedScanAction === 2 && startsWithSlashToken(currentToken)) { + currentToken = scanner.reScanSlashToken(); + ts.Debug.assert(n.kind === currentToken); + lastScanAction = 2; + } + else if (expectedScanAction === 3 && currentToken === 16) { + currentToken = scanner.reScanTemplateToken(); + lastScanAction = 3; + } + else if (expectedScanAction === 4 && currentToken === 69) { + currentToken = scanner.scanJsxIdentifier(); + lastScanAction = 4; + } + else { + lastScanAction = 0; + } + var token = { + pos: scanner.getStartPos(), + end: scanner.getTextPos(), + kind: currentToken + }; + if (trailingTrivia) { + trailingTrivia = undefined; + } + while (scanner.getStartPos() < endPos) { + currentToken = scanner.scan(); + if (!ts.isTrivia(currentToken)) { + break; + } + var trivia = { + pos: scanner.getStartPos(), + end: scanner.getTextPos(), + kind: currentToken + }; + if (!trailingTrivia) { + trailingTrivia = []; + } + trailingTrivia.push(trivia); + if (currentToken === 4) { + scanner.scan(); + break; + } + } + lastTokenInfo = { + leadingTrivia: leadingTrivia, + trailingTrivia: trailingTrivia, + token: token + }; + return fixTokenKind(lastTokenInfo, n); + } + function isOnToken() { + ts.Debug.assert(scanner !== undefined); + var current = (lastTokenInfo && lastTokenInfo.token.kind) || scanner.getToken(); + var startPos = (lastTokenInfo && lastTokenInfo.token.pos) || scanner.getStartPos(); + return startPos < endPos && current !== 1 && !ts.isTrivia(current); + } + function fixTokenKind(tokenInfo, container) { + if (ts.isToken(container) && tokenInfo.token.kind !== container.kind) { + tokenInfo.token.kind = container.kind; + } + return tokenInfo; + } + } + formatting.getFormattingScanner = getFormattingScanner; + })(formatting = ts.formatting || (ts.formatting = {})); +})(ts || (ts = {})); +var ts; +(function (ts) { + var formatting; + (function (formatting) { + var FormattingContext = (function () { + function FormattingContext(sourceFile, formattingRequestKind) { + this.sourceFile = sourceFile; + this.formattingRequestKind = formattingRequestKind; + } + FormattingContext.prototype.updateContext = function (currentRange, currentTokenParent, nextRange, nextTokenParent, commonParent) { + ts.Debug.assert(currentRange !== undefined, "currentTokenSpan is null"); + ts.Debug.assert(currentTokenParent !== undefined, "currentTokenParent is null"); + ts.Debug.assert(nextRange !== undefined, "nextTokenSpan is null"); + ts.Debug.assert(nextTokenParent !== undefined, "nextTokenParent is null"); + ts.Debug.assert(commonParent !== undefined, "commonParent is null"); + this.currentTokenSpan = currentRange; + this.currentTokenParent = currentTokenParent; + this.nextTokenSpan = nextRange; + this.nextTokenParent = nextTokenParent; + this.contextNode = commonParent; + this.contextNodeAllOnSameLine = undefined; + this.nextNodeAllOnSameLine = undefined; + this.tokensAreOnSameLine = undefined; + this.contextNodeBlockIsOnOneLine = undefined; + this.nextNodeBlockIsOnOneLine = undefined; + }; + FormattingContext.prototype.ContextNodeAllOnSameLine = function () { + if (this.contextNodeAllOnSameLine === undefined) { + this.contextNodeAllOnSameLine = this.NodeIsOnOneLine(this.contextNode); + } + return this.contextNodeAllOnSameLine; + }; + FormattingContext.prototype.NextNodeAllOnSameLine = function () { + if (this.nextNodeAllOnSameLine === undefined) { + this.nextNodeAllOnSameLine = this.NodeIsOnOneLine(this.nextTokenParent); + } + return this.nextNodeAllOnSameLine; + }; + FormattingContext.prototype.TokensAreOnSameLine = function () { + if (this.tokensAreOnSameLine === undefined) { + var startLine = this.sourceFile.getLineAndCharacterOfPosition(this.currentTokenSpan.pos).line; + var endLine = this.sourceFile.getLineAndCharacterOfPosition(this.nextTokenSpan.pos).line; + this.tokensAreOnSameLine = (startLine === endLine); + } + return this.tokensAreOnSameLine; + }; + FormattingContext.prototype.ContextNodeBlockIsOnOneLine = function () { + if (this.contextNodeBlockIsOnOneLine === undefined) { + this.contextNodeBlockIsOnOneLine = this.BlockIsOnOneLine(this.contextNode); + } + return this.contextNodeBlockIsOnOneLine; + }; + FormattingContext.prototype.NextNodeBlockIsOnOneLine = function () { + if (this.nextNodeBlockIsOnOneLine === undefined) { + this.nextNodeBlockIsOnOneLine = this.BlockIsOnOneLine(this.nextTokenParent); + } + return this.nextNodeBlockIsOnOneLine; + }; + FormattingContext.prototype.NodeIsOnOneLine = function (node) { + var startLine = this.sourceFile.getLineAndCharacterOfPosition(node.getStart(this.sourceFile)).line; + var endLine = this.sourceFile.getLineAndCharacterOfPosition(node.getEnd()).line; + return startLine === endLine; + }; + FormattingContext.prototype.BlockIsOnOneLine = function (node) { + var openBrace = ts.findChildOfKind(node, 15, this.sourceFile); + var closeBrace = ts.findChildOfKind(node, 16, this.sourceFile); + if (openBrace && closeBrace) { + var startLine = this.sourceFile.getLineAndCharacterOfPosition(openBrace.getEnd()).line; + var endLine = this.sourceFile.getLineAndCharacterOfPosition(closeBrace.getStart(this.sourceFile)).line; + return startLine === endLine; + } + return false; + }; + return FormattingContext; + })(); + formatting.FormattingContext = FormattingContext; + })(formatting = ts.formatting || (ts.formatting = {})); +})(ts || (ts = {})); +var ts; +(function (ts) { + var formatting; + (function (formatting) { + var Rule = (function () { + function Rule(Descriptor, Operation, Flag) { + if (Flag === void 0) { Flag = 0; } + this.Descriptor = Descriptor; + this.Operation = Operation; + this.Flag = Flag; + } + Rule.prototype.toString = function () { + return "[desc=" + this.Descriptor + "," + + "operation=" + this.Operation + "," + + "flag=" + this.Flag + "]"; + }; + return Rule; + })(); + formatting.Rule = Rule; + })(formatting = ts.formatting || (ts.formatting = {})); +})(ts || (ts = {})); +var ts; +(function (ts) { + var formatting; + (function (formatting) { + var RuleDescriptor = (function () { + function RuleDescriptor(LeftTokenRange, RightTokenRange) { + this.LeftTokenRange = LeftTokenRange; + this.RightTokenRange = RightTokenRange; + } + RuleDescriptor.prototype.toString = function () { + return "[leftRange=" + this.LeftTokenRange + "," + + "rightRange=" + this.RightTokenRange + "]"; + }; + RuleDescriptor.create1 = function (left, right) { + return RuleDescriptor.create4(formatting.Shared.TokenRange.FromToken(left), formatting.Shared.TokenRange.FromToken(right)); + }; + RuleDescriptor.create2 = function (left, right) { + return RuleDescriptor.create4(left, formatting.Shared.TokenRange.FromToken(right)); + }; + RuleDescriptor.create3 = function (left, right) { + return RuleDescriptor.create4(formatting.Shared.TokenRange.FromToken(left), right); + }; + RuleDescriptor.create4 = function (left, right) { + return new RuleDescriptor(left, right); + }; + return RuleDescriptor; + })(); + formatting.RuleDescriptor = RuleDescriptor; + })(formatting = ts.formatting || (ts.formatting = {})); +})(ts || (ts = {})); +var ts; +(function (ts) { + var formatting; + (function (formatting) { + var RuleOperation = (function () { + function RuleOperation() { + this.Context = null; + this.Action = null; + } + RuleOperation.prototype.toString = function () { + return "[context=" + this.Context + "," + + "action=" + this.Action + "]"; + }; + RuleOperation.create1 = function (action) { + return RuleOperation.create2(formatting.RuleOperationContext.Any, action); + }; + RuleOperation.create2 = function (context, action) { + var result = new RuleOperation(); + result.Context = context; + result.Action = action; + return result; + }; + return RuleOperation; + })(); + formatting.RuleOperation = RuleOperation; + })(formatting = ts.formatting || (ts.formatting = {})); +})(ts || (ts = {})); +var ts; +(function (ts) { + var formatting; + (function (formatting) { + var RuleOperationContext = (function () { + function RuleOperationContext() { + var funcs = []; + for (var _i = 0; _i < arguments.length; _i++) { + funcs[_i - 0] = arguments[_i]; + } + this.customContextChecks = funcs; + } + RuleOperationContext.prototype.IsAny = function () { + return this === RuleOperationContext.Any; + }; + RuleOperationContext.prototype.InContext = function (context) { + if (this.IsAny()) { + return true; + } + for (var _i = 0, _a = this.customContextChecks; _i < _a.length; _i++) { + var check = _a[_i]; + if (!check(context)) { + return false; + } + } + return true; + }; + RuleOperationContext.Any = new RuleOperationContext(); + return RuleOperationContext; + })(); + formatting.RuleOperationContext = RuleOperationContext; + })(formatting = ts.formatting || (ts.formatting = {})); +})(ts || (ts = {})); +var ts; +(function (ts) { + var formatting; + (function (formatting) { + var Rules = (function () { + 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.IsSameLineTokenContext), 8)); + this.NoSpaceBeforeColon = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 54), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 8)); + this.NoSpaceBeforeQuestionMark = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 53), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 8)); + this.SpaceAfterColon = new formatting.Rule(formatting.RuleDescriptor.create3(54, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 2)); + this.SpaceAfterQuestionMarkInConditionalOperator = new formatting.Rule(formatting.RuleDescriptor.create3(53, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsConditionalOperatorContext), 2)); + this.NoSpaceAfterQuestionMark = new formatting.Rule(formatting.RuleDescriptor.create3(53, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); + this.SpaceAfterSemicolon = new formatting.Rule(formatting.RuleDescriptor.create3(23, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); + this.SpaceAfterCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create3(16, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsAfterCodeBlockContext), 2)); + this.SpaceBetweenCloseBraceAndElse = new formatting.Rule(formatting.RuleDescriptor.create1(16, 80), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); + this.SpaceBetweenCloseBraceAndWhile = new formatting.Rule(formatting.RuleDescriptor.create1(16, 104), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); + this.NoSpaceAfterCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create3(16, formatting.Shared.TokenRange.FromTokens([18, 20, 24, 23])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); + this.NoSpaceBeforeDot = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 21), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); + this.NoSpaceAfterDot = new formatting.Rule(formatting.RuleDescriptor.create3(21, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); + this.NoSpaceBeforeOpenBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 19), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); + this.NoSpaceAfterCloseBracket = new formatting.Rule(formatting.RuleDescriptor.create3(20, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBeforeBlockInFunctionDeclarationContext), 8)); + this.FunctionOpenBraceLeftTokenRange = formatting.Shared.TokenRange.AnyIncludingMultilineComments; + this.SpaceBeforeOpenBraceInFunction = new formatting.Rule(formatting.RuleDescriptor.create2(this.FunctionOpenBraceLeftTokenRange, 15), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext, Rules.IsBeforeBlockContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), 2), 1); + this.TypeScriptOpenBraceLeftTokenRange = formatting.Shared.TokenRange.FromTokens([69, 3, 73]); + this.SpaceBeforeOpenBraceInTypeScriptDeclWithBlock = new formatting.Rule(formatting.RuleDescriptor.create2(this.TypeScriptOpenBraceLeftTokenRange, 15), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsTypeScriptDeclWithBlockContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), 2), 1); + this.ControlOpenBraceLeftTokenRange = formatting.Shared.TokenRange.FromTokens([18, 3, 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.NoSpaceBetweenEmptyBraceBrackets = new formatting.Rule(formatting.RuleDescriptor.create1(15, 16), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, 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.NoSpaceAfterUnaryPrefixOperator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.UnaryPrefixOperators, formatting.Shared.TokenRange.UnaryPrefixExpressions), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 8)); + this.NoSpaceAfterUnaryPreincrementOperator = new formatting.Rule(formatting.RuleDescriptor.create3(41, formatting.Shared.TokenRange.UnaryPreincrementExpressions), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); + this.NoSpaceAfterUnaryPredecrementOperator = new formatting.Rule(formatting.RuleDescriptor.create3(42, formatting.Shared.TokenRange.UnaryPredecrementExpressions), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); + this.NoSpaceBeforeUnaryPostincrementOperator = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.UnaryPostincrementExpressions, 41), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); + this.NoSpaceBeforeUnaryPostdecrementOperator = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.UnaryPostdecrementExpressions, 42), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); + this.SpaceAfterPostincrementWhenFollowedByAdd = new formatting.Rule(formatting.RuleDescriptor.create1(41, 35), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2)); + this.SpaceAfterAddWhenFollowedByUnaryPlus = new formatting.Rule(formatting.RuleDescriptor.create1(35, 35), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2)); + this.SpaceAfterAddWhenFollowedByPreincrement = new formatting.Rule(formatting.RuleDescriptor.create1(35, 41), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2)); + this.SpaceAfterPostdecrementWhenFollowedBySubtract = new formatting.Rule(formatting.RuleDescriptor.create1(42, 36), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2)); + this.SpaceAfterSubtractWhenFollowedByUnaryMinus = new formatting.Rule(formatting.RuleDescriptor.create1(36, 36), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2)); + this.SpaceAfterSubtractWhenFollowedByPredecrement = new formatting.Rule(formatting.RuleDescriptor.create1(36, 42), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2)); + this.NoSpaceBeforeComma = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 24), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); + this.SpaceAfterCertainKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([102, 98, 92, 78, 94, 101, 119]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); + this.SpaceAfterLetConstInVariableDeclaration = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([108, 74]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsStartOfVariableDeclarationList), 2)); + this.NoSpaceBeforeOpenParenInFuncCall = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsFunctionCallOrNewContext, Rules.IsPreviousTokenNotComma), 8)); + this.SpaceAfterFunctionInFuncDecl = new formatting.Rule(formatting.RuleDescriptor.create3(87, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2)); + this.NoSpaceBeforeOpenParenInFuncDecl = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsFunctionDeclContext), 8)); + this.SpaceAfterVoidOperator = new formatting.Rule(formatting.RuleDescriptor.create3(103, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsVoidOpContext), 2)); + this.NoSpaceBetweenReturnAndSemicolon = new formatting.Rule(formatting.RuleDescriptor.create1(94, 23), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); + this.SpaceBetweenStatements = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([18, 79, 80, 71]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotForContext), 2)); + this.SpaceAfterTryFinally = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([100, 85]), 15), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); + this.SpaceAfterGetSetInMember = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([123, 129]), 69), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2)); + this.SpaceBeforeBinaryKeywordOperator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.BinaryKeywordOperators), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2)); + this.SpaceAfterBinaryKeywordOperator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.BinaryKeywordOperators, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2)); + this.NoSpaceAfterConstructor = new formatting.Rule(formatting.RuleDescriptor.create1(121, 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); + this.NoSpaceAfterModuleImport = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([125, 127]), 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); + this.SpaceAfterCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([115, 73, 122, 77, 81, 82, 83, 123, 106, 89, 107, 125, 126, 110, 112, 111, 129, 113, 132]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); + this.SpaceBeforeCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([83, 106])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); + this.SpaceAfterModuleName = new formatting.Rule(formatting.RuleDescriptor.create1(9, 15), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsModuleDeclContext), 2)); + this.SpaceAfterArrow = new formatting.Rule(formatting.RuleDescriptor.create3(34, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); + this.NoSpaceAfterEllipsis = new formatting.Rule(formatting.RuleDescriptor.create1(22, 69), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); + this.NoSpaceAfterOptionalParameters = new formatting.Rule(formatting.RuleDescriptor.create3(53, formatting.Shared.TokenRange.FromTokens([18, 24])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 8)); + this.NoSpaceBeforeOpenAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.TypeNames, 25), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), 8)); + this.NoSpaceBetweenCloseParenAndAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create1(18, 25), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), 8)); + this.NoSpaceAfterOpenAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create3(25, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), 8)); + this.NoSpaceBeforeCloseAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 27), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, 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.IsSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), 8)); + this.NoSpaceAfterTypeAssertion = new formatting.Rule(formatting.RuleDescriptor.create3(27, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsTypeAssertionContext), 8)); + this.NoSpaceBetweenEmptyInterfaceBraceBrackets = new formatting.Rule(formatting.RuleDescriptor.create1(15, 16), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsObjectTypeContext), 8)); + this.SpaceBeforeAt = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 55), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); + this.NoSpaceAfterAt = new formatting.Rule(formatting.RuleDescriptor.create3(55, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); + this.SpaceAfterDecorator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([115, 69, 82, 77, 73, 113, 112, 110, 111, 123, 129, 19, 37])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsEndOfDecoratorContextOnSameLine), 2)); + this.NoSpaceBetweenFunctionKeywordAndStar = new formatting.Rule(formatting.RuleDescriptor.create1(87, 37), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclarationOrFunctionExpressionContext), 8)); + this.SpaceAfterStarInGeneratorDeclaration = new formatting.Rule(formatting.RuleDescriptor.create3(37, formatting.Shared.TokenRange.FromTokens([69, 17])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclarationOrFunctionExpressionContext), 2)); + this.NoSpaceBetweenYieldKeywordAndStar = new formatting.Rule(formatting.RuleDescriptor.create1(114, 37), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsYieldOrYieldStarWithOperand), 8)); + this.SpaceBetweenYieldOrYieldStarAndOperand = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([114, 37]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsYieldOrYieldStarWithOperand), 2)); + this.SpaceBetweenAsyncAndOpenParen = new formatting.Rule(formatting.RuleDescriptor.create1(118, 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsArrowFunctionContext, Rules.IsSameLineTokenContext), 2)); + this.SpaceBetweenAsyncAndFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(118, 87), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); + this.SpaceBetweenTagAndTemplateString = new formatting.Rule(formatting.RuleDescriptor.create3(69, formatting.Shared.TokenRange.FromTokens([11, 12])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); + this.NoSpaceAfterTemplateHeadAndMiddle = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([12, 13]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); + this.NoSpaceBeforeTemplateMiddleAndTail = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([13, 14])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); + this.HighPriorityCommonRules = + [ + this.IgnoreBeforeComment, this.IgnoreAfterLineComment, + this.NoSpaceBeforeColon, this.SpaceAfterColon, this.NoSpaceBeforeQuestionMark, this.SpaceAfterQuestionMarkInConditionalOperator, + this.NoSpaceAfterQuestionMark, + this.NoSpaceBeforeDot, this.NoSpaceAfterDot, + this.NoSpaceAfterUnaryPrefixOperator, + this.NoSpaceAfterUnaryPreincrementOperator, this.NoSpaceAfterUnaryPredecrementOperator, + this.NoSpaceBeforeUnaryPostincrementOperator, this.NoSpaceBeforeUnaryPostdecrementOperator, + this.SpaceAfterPostincrementWhenFollowedByAdd, + this.SpaceAfterAddWhenFollowedByUnaryPlus, this.SpaceAfterAddWhenFollowedByPreincrement, + this.SpaceAfterPostdecrementWhenFollowedBySubtract, + this.SpaceAfterSubtractWhenFollowedByUnaryMinus, this.SpaceAfterSubtractWhenFollowedByPredecrement, + this.NoSpaceAfterCloseBrace, + this.SpaceAfterOpenBrace, this.SpaceBeforeCloseBrace, this.NewLineBeforeCloseBraceInBlockContext, + this.SpaceAfterCloseBrace, this.SpaceBetweenCloseBraceAndElse, this.SpaceBetweenCloseBraceAndWhile, this.NoSpaceBetweenEmptyBraceBrackets, + this.NoSpaceBetweenFunctionKeywordAndStar, this.SpaceAfterStarInGeneratorDeclaration, + this.SpaceAfterFunctionInFuncDecl, this.NewLineAfterOpenBraceInBlockContext, this.SpaceAfterGetSetInMember, + this.NoSpaceBetweenYieldKeywordAndStar, this.SpaceBetweenYieldOrYieldStarAndOperand, + this.NoSpaceBetweenReturnAndSemicolon, + this.SpaceAfterCertainKeywords, + this.SpaceAfterLetConstInVariableDeclaration, + this.NoSpaceBeforeOpenParenInFuncCall, + this.SpaceBeforeBinaryKeywordOperator, this.SpaceAfterBinaryKeywordOperator, + this.SpaceAfterVoidOperator, + this.SpaceBetweenAsyncAndOpenParen, this.SpaceBetweenAsyncAndFunctionKeyword, + this.SpaceBetweenTagAndTemplateString, this.NoSpaceAfterTemplateHeadAndMiddle, this.NoSpaceBeforeTemplateMiddleAndTail, + this.NoSpaceAfterConstructor, this.NoSpaceAfterModuleImport, + this.SpaceAfterCertainTypeScriptKeywords, this.SpaceBeforeCertainTypeScriptKeywords, + this.SpaceAfterModuleName, + this.SpaceAfterArrow, + this.NoSpaceAfterEllipsis, + this.NoSpaceAfterOptionalParameters, + this.NoSpaceBetweenEmptyInterfaceBraceBrackets, + this.NoSpaceBeforeOpenAngularBracket, + this.NoSpaceBetweenCloseParenAndAngularBracket, + this.NoSpaceAfterOpenAngularBracket, + this.NoSpaceBeforeCloseAngularBracket, + this.NoSpaceAfterCloseAngularBracket, + this.NoSpaceAfterTypeAssertion, + this.SpaceBeforeAt, + this.NoSpaceAfterAt, + this.SpaceAfterDecorator, + ]; + this.LowPriorityCommonRules = + [ + this.NoSpaceBeforeSemicolon, + this.SpaceBeforeOpenBraceInControl, this.SpaceBeforeOpenBraceInFunction, this.SpaceBeforeOpenBraceInTypeScriptDeclWithBlock, + this.NoSpaceBeforeComma, + this.NoSpaceBeforeOpenBracket, + this.NoSpaceAfterCloseBracket, + this.SpaceAfterSemicolon, + 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.IsSameLineTokenContext), 2)); + this.NoSpaceAfterComma = new formatting.Rule(formatting.RuleDescriptor.create3(24, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); + this.SpaceBeforeBinaryOperator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.BinaryOperators), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, 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.IsSameLineTokenContext, 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.IsSameLineTokenContext, 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.IsSameLineTokenContext, 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.IsSameLineTokenContext, Rules.IsForContext), 2)); + this.NoSpaceAfterSemicolonInFor = new formatting.Rule(formatting.RuleDescriptor.create3(23, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsForContext), 8)); + this.SpaceAfterOpenParen = new formatting.Rule(formatting.RuleDescriptor.create3(17, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); + this.SpaceBeforeCloseParen = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 18), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); + this.NoSpaceBetweenParens = new formatting.Rule(formatting.RuleDescriptor.create1(17, 18), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); + this.NoSpaceAfterOpenParen = new formatting.Rule(formatting.RuleDescriptor.create3(17, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); + this.NoSpaceBeforeCloseParen = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 18), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); + this.SpaceAfterOpenBracket = new formatting.Rule(formatting.RuleDescriptor.create3(19, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); + this.SpaceBeforeCloseBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 20), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); + this.NoSpaceBetweenBrackets = new formatting.Rule(formatting.RuleDescriptor.create1(19, 20), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); + this.NoSpaceAfterOpenBracket = new formatting.Rule(formatting.RuleDescriptor.create3(19, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); + this.NoSpaceBeforeCloseBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 20), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); + this.SpaceAfterAnonymousFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(87, 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2)); + this.NoSpaceAfterAnonymousFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(87, 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 8)); + } + Rules.prototype.getRuleName = function (rule) { + var o = this; + for (var name_32 in o) { + if (o[name_32] === rule) { + return name_32; + } + } + throw new Error("Unknown rule"); + }; + Rules.IsForContext = function (context) { + return context.contextNode.kind === 199; + }; + Rules.IsNotForContext = function (context) { + return !Rules.IsForContext(context); + }; + Rules.IsBinaryOpContext = function (context) { + switch (context.contextNode.kind) { + case 181: + case 182: + case 189: + case 150: + case 158: + case 159: + return true; + case 163: + case 216: + case 221: + case 211: + case 138: + case 247: + case 141: + case 140: + return context.currentTokenSpan.kind === 56 || context.nextTokenSpan.kind === 56; + case 200: + return context.currentTokenSpan.kind === 90 || context.nextTokenSpan.kind === 90; + case 201: + return context.currentTokenSpan.kind === 134 || context.nextTokenSpan.kind === 134; + } + return false; + }; + Rules.IsNotBinaryOpContext = function (context) { + return !Rules.IsBinaryOpContext(context); + }; + Rules.IsConditionalOperatorContext = function (context) { + return context.contextNode.kind === 182; + }; + Rules.IsSameLineTokenOrBeforeMultilineBlockContext = function (context) { + return context.TokensAreOnSameLine() || Rules.IsBeforeMultilineBlockContext(context); + }; + Rules.IsBeforeMultilineBlockContext = function (context) { + return Rules.IsBeforeBlockContext(context) && !(context.NextNodeAllOnSameLine() || context.NextNodeBlockIsOnOneLine()); + }; + Rules.IsMultilineBlockContext = function (context) { + return Rules.IsBlockContext(context) && !(context.ContextNodeAllOnSameLine() || context.ContextNodeBlockIsOnOneLine()); + }; + Rules.IsSingleLineBlockContext = function (context) { + return Rules.IsBlockContext(context) && (context.ContextNodeAllOnSameLine() || context.ContextNodeBlockIsOnOneLine()); + }; + Rules.IsBlockContext = function (context) { + return Rules.NodeIsBlockContext(context.contextNode); + }; + Rules.IsBeforeBlockContext = function (context) { + return Rules.NodeIsBlockContext(context.nextTokenParent); + }; + Rules.NodeIsBlockContext = function (node) { + if (Rules.NodeIsTypeScriptDeclWithBlockContext(node)) { + return true; + } + switch (node.kind) { + case 192: + case 220: + case 165: + case 219: + return true; + } + return false; + }; + Rules.IsFunctionDeclContext = function (context) { + switch (context.contextNode.kind) { + case 213: + case 143: + case 142: + case 145: + case 146: + case 147: + case 173: + case 144: + case 174: + case 215: + return true; + } + return false; + }; + Rules.IsFunctionDeclarationOrFunctionExpressionContext = function (context) { + return context.contextNode.kind === 213 || context.contextNode.kind === 173; + }; + Rules.IsTypeScriptDeclWithBlockContext = function (context) { + return Rules.NodeIsTypeScriptDeclWithBlockContext(context.contextNode); + }; + Rules.NodeIsTypeScriptDeclWithBlockContext = function (node) { + switch (node.kind) { + case 214: + case 186: + case 215: + case 217: + case 155: + case 218: + return true; + } + return false; + }; + Rules.IsAfterCodeBlockContext = function (context) { + switch (context.currentTokenParent.kind) { + case 214: + case 218: + case 217: + case 192: + case 244: + case 219: + case 206: + return true; + } + return false; + }; + Rules.IsControlDeclContext = function (context) { + switch (context.contextNode.kind) { + case 196: + case 206: + case 199: + case 200: + case 201: + case 198: + case 209: + case 197: + case 205: + case 244: + return true; + default: + return false; + } + }; + Rules.IsObjectContext = function (context) { + return context.contextNode.kind === 165; + }; + Rules.IsFunctionCallContext = function (context) { + return context.contextNode.kind === 168; + }; + Rules.IsNewContext = function (context) { + return context.contextNode.kind === 169; + }; + Rules.IsFunctionCallOrNewContext = function (context) { + return Rules.IsFunctionCallContext(context) || Rules.IsNewContext(context); + }; + Rules.IsPreviousTokenNotComma = function (context) { + return context.currentTokenSpan.kind !== 24; + }; + Rules.IsArrowFunctionContext = function (context) { + return context.contextNode.kind === 174; + }; + Rules.IsSameLineTokenContext = function (context) { + return context.TokensAreOnSameLine(); + }; + Rules.IsNotBeforeBlockInFunctionDeclarationContext = function (context) { + return !Rules.IsFunctionDeclContext(context) && !Rules.IsBeforeBlockContext(context); + }; + Rules.IsEndOfDecoratorContextOnSameLine = function (context) { + return context.TokensAreOnSameLine() && + context.contextNode.decorators && + Rules.NodeIsInDecoratorContext(context.currentTokenParent) && + !Rules.NodeIsInDecoratorContext(context.nextTokenParent); + }; + Rules.NodeIsInDecoratorContext = function (node) { + while (ts.isExpression(node)) { + node = node.parent; + } + return node.kind === 139; + }; + Rules.IsStartOfVariableDeclarationList = function (context) { + return context.currentTokenParent.kind === 212 && + context.currentTokenParent.getStart(context.sourceFile) === context.currentTokenSpan.pos; + }; + Rules.IsNotFormatOnEnter = function (context) { + return context.formattingRequestKind !== 2; + }; + Rules.IsModuleDeclContext = function (context) { + return context.contextNode.kind === 218; + }; + Rules.IsObjectTypeContext = function (context) { + return context.contextNode.kind === 155; + }; + Rules.IsTypeArgumentOrParameterOrAssertion = function (token, parent) { + if (token.kind !== 25 && token.kind !== 27) { + return false; + } + switch (parent.kind) { + case 151: + case 171: + case 214: + case 186: + case 215: + case 213: + case 173: + case 174: + case 143: + case 142: + case 147: + case 148: + case 168: + case 169: + case 188: + return true; + default: + return false; + } + }; + Rules.IsTypeArgumentOrParameterOrAssertionContext = function (context) { + return Rules.IsTypeArgumentOrParameterOrAssertion(context.currentTokenSpan, context.currentTokenParent) || + Rules.IsTypeArgumentOrParameterOrAssertion(context.nextTokenSpan, context.nextTokenParent); + }; + Rules.IsTypeAssertionContext = function (context) { + return context.contextNode.kind === 171; + }; + Rules.IsVoidOpContext = function (context) { + return context.currentTokenSpan.kind === 103 && context.currentTokenParent.kind === 177; + }; + Rules.IsYieldOrYieldStarWithOperand = function (context) { + return context.contextNode.kind === 184 && context.contextNode.expression !== undefined; + }; + return Rules; + })(); + formatting.Rules = Rules; + })(formatting = ts.formatting || (ts.formatting = {})); +})(ts || (ts = {})); +var ts; +(function (ts) { + var formatting; + (function (formatting) { + var RulesMap = (function () { + function RulesMap() { + this.map = []; + this.mapRowLength = 0; + } + RulesMap.create = function (rules) { + var result = new RulesMap(); + result.Initialize(rules); + return result; + }; + RulesMap.prototype.Initialize = function (rules) { + this.mapRowLength = 134 + 1; + this.map = new Array(this.mapRowLength * this.mapRowLength); + var rulesBucketConstructionStateList = new Array(this.map.length); + this.FillRules(rules, rulesBucketConstructionStateList); + return this.map; + }; + RulesMap.prototype.FillRules = function (rules, rulesBucketConstructionStateList) { + var _this = this; + rules.forEach(function (rule) { + _this.FillRule(rule, rulesBucketConstructionStateList); + }); + }; + RulesMap.prototype.GetRuleBucketIndex = function (row, column) { + var rulesBucketIndex = (row * this.mapRowLength) + column; + return rulesBucketIndex; + }; + RulesMap.prototype.FillRule = function (rule, rulesBucketConstructionStateList) { + var _this = this; + var specificRule = rule.Descriptor.LeftTokenRange !== formatting.Shared.TokenRange.Any && + rule.Descriptor.RightTokenRange !== formatting.Shared.TokenRange.Any; + rule.Descriptor.LeftTokenRange.GetTokens().forEach(function (left) { + rule.Descriptor.RightTokenRange.GetTokens().forEach(function (right) { + var rulesBucketIndex = _this.GetRuleBucketIndex(left, right); + var rulesBucket = _this.map[rulesBucketIndex]; + if (rulesBucket === undefined) { + rulesBucket = _this.map[rulesBucketIndex] = new RulesBucket(); + } + rulesBucket.AddRule(rule, specificRule, rulesBucketConstructionStateList, rulesBucketIndex); + }); + }); + }; + RulesMap.prototype.GetRule = function (context) { + var bucketIndex = this.GetRuleBucketIndex(context.currentTokenSpan.kind, context.nextTokenSpan.kind); + var bucket = this.map[bucketIndex]; + if (bucket != null) { + for (var _i = 0, _a = bucket.Rules(); _i < _a.length; _i++) { + var rule = _a[_i]; + if (rule.Operation.Context.InContext(context)) { + return rule; + } + } + } + return null; + }; + return RulesMap; + })(); + formatting.RulesMap = RulesMap; + var MaskBitSize = 5; + var Mask = 0x1f; + (function (RulesPosition) { + RulesPosition[RulesPosition["IgnoreRulesSpecific"] = 0] = "IgnoreRulesSpecific"; + RulesPosition[RulesPosition["IgnoreRulesAny"] = MaskBitSize * 1] = "IgnoreRulesAny"; + RulesPosition[RulesPosition["ContextRulesSpecific"] = MaskBitSize * 2] = "ContextRulesSpecific"; + RulesPosition[RulesPosition["ContextRulesAny"] = MaskBitSize * 3] = "ContextRulesAny"; + RulesPosition[RulesPosition["NoContextRulesSpecific"] = MaskBitSize * 4] = "NoContextRulesSpecific"; + RulesPosition[RulesPosition["NoContextRulesAny"] = MaskBitSize * 5] = "NoContextRulesAny"; + })(formatting.RulesPosition || (formatting.RulesPosition = {})); + var RulesPosition = formatting.RulesPosition; + var RulesBucketConstructionState = (function () { + function RulesBucketConstructionState() { + this.rulesInsertionIndexBitmap = 0; + } + RulesBucketConstructionState.prototype.GetInsertionIndex = function (maskPosition) { + var index = 0; + var pos = 0; + var indexBitmap = this.rulesInsertionIndexBitmap; + while (pos <= maskPosition) { + index += (indexBitmap & Mask); + indexBitmap >>= MaskBitSize; + pos += MaskBitSize; + } + return index; + }; + RulesBucketConstructionState.prototype.IncreaseInsertionIndex = function (maskPosition) { + var value = (this.rulesInsertionIndexBitmap >> maskPosition) & Mask; + value++; + ts.Debug.assert((value & Mask) === value, "Adding more rules into the sub-bucket than allowed. Maximum allowed is 32 rules."); + var temp = this.rulesInsertionIndexBitmap & ~(Mask << maskPosition); + temp |= value << maskPosition; + this.rulesInsertionIndexBitmap = temp; + }; + return RulesBucketConstructionState; + })(); + formatting.RulesBucketConstructionState = RulesBucketConstructionState; + var RulesBucket = (function () { + function RulesBucket() { + this.rules = []; + } + RulesBucket.prototype.Rules = function () { + return this.rules; + }; + RulesBucket.prototype.AddRule = function (rule, specificTokens, constructionState, rulesBucketIndex) { + var position; + if (rule.Operation.Action === 1) { + position = specificTokens ? + RulesPosition.IgnoreRulesSpecific : + RulesPosition.IgnoreRulesAny; + } + else if (!rule.Operation.Context.IsAny()) { + position = specificTokens ? + RulesPosition.ContextRulesSpecific : + RulesPosition.ContextRulesAny; + } + else { + position = specificTokens ? + RulesPosition.NoContextRulesSpecific : + RulesPosition.NoContextRulesAny; + } + var state = constructionState[rulesBucketIndex]; + if (state === undefined) { + state = constructionState[rulesBucketIndex] = new RulesBucketConstructionState(); + } + var index = state.GetInsertionIndex(position); + this.rules.splice(index, 0, rule); + state.IncreaseInsertionIndex(position); + }; + return RulesBucket; + })(); + formatting.RulesBucket = RulesBucket; + })(formatting = ts.formatting || (ts.formatting = {})); +})(ts || (ts = {})); +var ts; +(function (ts) { + var formatting; + (function (formatting) { + var Shared; + (function (Shared) { + var TokenRangeAccess = (function () { + function TokenRangeAccess(from, to, except) { + this.tokens = []; + for (var token = from; token <= to; token++) { + if (except.indexOf(token) < 0) { + this.tokens.push(token); + } + } + } + TokenRangeAccess.prototype.GetTokens = function () { + return this.tokens; + }; + TokenRangeAccess.prototype.Contains = function (token) { + return this.tokens.indexOf(token) >= 0; + }; + return TokenRangeAccess; + })(); + Shared.TokenRangeAccess = TokenRangeAccess; + var TokenValuesAccess = (function () { + function TokenValuesAccess(tks) { + this.tokens = tks && tks.length ? tks : []; + } + TokenValuesAccess.prototype.GetTokens = function () { + return this.tokens; + }; + TokenValuesAccess.prototype.Contains = function (token) { + return this.tokens.indexOf(token) >= 0; + }; + return TokenValuesAccess; + })(); + Shared.TokenValuesAccess = TokenValuesAccess; + var TokenSingleValueAccess = (function () { + function TokenSingleValueAccess(token) { + this.token = token; + } + TokenSingleValueAccess.prototype.GetTokens = function () { + return [this.token]; + }; + TokenSingleValueAccess.prototype.Contains = function (tokenValue) { + return tokenValue === this.token; + }; + return TokenSingleValueAccess; + })(); + Shared.TokenSingleValueAccess = TokenSingleValueAccess; + var TokenAllAccess = (function () { + function TokenAllAccess() { + } + TokenAllAccess.prototype.GetTokens = function () { + var result = []; + for (var token = 0; token <= 134; token++) { + result.push(token); + } + return result; + }; + TokenAllAccess.prototype.Contains = function (tokenValue) { + return true; + }; + TokenAllAccess.prototype.toString = function () { + return "[allTokens]"; + }; + return TokenAllAccess; + })(); + Shared.TokenAllAccess = TokenAllAccess; + var TokenRange = (function () { + function TokenRange(tokenAccess) { + this.tokenAccess = tokenAccess; + } + TokenRange.FromToken = function (token) { + return new TokenRange(new TokenSingleValueAccess(token)); + }; + TokenRange.FromTokens = function (tokens) { + return new TokenRange(new TokenValuesAccess(tokens)); + }; + TokenRange.FromRange = function (f, to, except) { + if (except === void 0) { except = []; } + return new TokenRange(new TokenRangeAccess(f, to, except)); + }; + TokenRange.AllTokens = function () { + return new TokenRange(new TokenAllAccess()); + }; + TokenRange.prototype.GetTokens = function () { + return this.tokenAccess.GetTokens(); + }; + TokenRange.prototype.Contains = function (token) { + return this.tokenAccess.Contains(token); + }; + TokenRange.prototype.toString = function () { + return this.tokenAccess.toString(); + }; + TokenRange.Any = TokenRange.AllTokens(); + TokenRange.AnyIncludingMultilineComments = TokenRange.FromTokens(TokenRange.Any.GetTokens().concat([3])); + TokenRange.Keywords = TokenRange.FromRange(70, 134); + TokenRange.BinaryOperators = TokenRange.FromRange(25, 68); + TokenRange.BinaryKeywordOperators = TokenRange.FromTokens([90, 91, 134, 116, 124]); + TokenRange.UnaryPrefixOperators = TokenRange.FromTokens([41, 42, 50, 49]); + TokenRange.UnaryPrefixExpressions = TokenRange.FromTokens([8, 69, 17, 19, 15, 97, 92]); + TokenRange.UnaryPreincrementExpressions = TokenRange.FromTokens([69, 17, 97, 92]); + TokenRange.UnaryPostincrementExpressions = TokenRange.FromTokens([69, 18, 20, 92]); + TokenRange.UnaryPredecrementExpressions = TokenRange.FromTokens([69, 17, 97, 92]); + TokenRange.UnaryPostdecrementExpressions = TokenRange.FromTokens([69, 18, 20, 92]); + TokenRange.Comments = TokenRange.FromTokens([2, 3]); + TokenRange.TypeNames = TokenRange.FromTokens([69, 128, 130, 120, 131, 103, 117]); + return TokenRange; + })(); + Shared.TokenRange = TokenRange; + })(Shared = formatting.Shared || (formatting.Shared = {})); + })(formatting = ts.formatting || (ts.formatting = {})); +})(ts || (ts = {})); +var ts; +(function (ts) { + var formatting; + (function (formatting) { + var RulesProvider = (function () { + function RulesProvider() { + this.globalRules = new formatting.Rules(); + } + RulesProvider.prototype.getRuleName = function (rule) { + return this.globalRules.getRuleName(rule); + }; + RulesProvider.prototype.getRuleByName = function (name) { + return this.globalRules[name]; + }; + RulesProvider.prototype.getRulesMap = function () { + return this.rulesMap; + }; + RulesProvider.prototype.ensureUpToDate = function (options) { + if (this.options == null || !ts.compareDataObjects(this.options, options)) { + var activeRules = this.createActiveRules(options); + var rulesMap = formatting.RulesMap.create(activeRules); + this.activeRules = activeRules; + this.rulesMap = rulesMap; + this.options = ts.clone(options); + } + }; + RulesProvider.prototype.createActiveRules = function (options) { + var rules = this.globalRules.HighPriorityCommonRules.slice(0); + if (options.InsertSpaceAfterCommaDelimiter) { + rules.push(this.globalRules.SpaceAfterComma); + } + else { + rules.push(this.globalRules.NoSpaceAfterComma); + } + if (options.InsertSpaceAfterFunctionKeywordForAnonymousFunctions) { + rules.push(this.globalRules.SpaceAfterAnonymousFunctionKeyword); + } + else { + rules.push(this.globalRules.NoSpaceAfterAnonymousFunctionKeyword); + } + if (options.InsertSpaceAfterKeywordsInControlFlowStatements) { + rules.push(this.globalRules.SpaceAfterKeywordInControl); + } + else { + rules.push(this.globalRules.NoSpaceAfterKeywordInControl); + } + if (options.InsertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis) { + rules.push(this.globalRules.SpaceAfterOpenParen); + rules.push(this.globalRules.SpaceBeforeCloseParen); + rules.push(this.globalRules.NoSpaceBetweenParens); + } + else { + rules.push(this.globalRules.NoSpaceAfterOpenParen); + rules.push(this.globalRules.NoSpaceBeforeCloseParen); + rules.push(this.globalRules.NoSpaceBetweenParens); + } + if (options.InsertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets) { + rules.push(this.globalRules.SpaceAfterOpenBracket); + rules.push(this.globalRules.SpaceBeforeCloseBracket); + rules.push(this.globalRules.NoSpaceBetweenBrackets); + } + else { + rules.push(this.globalRules.NoSpaceAfterOpenBracket); + rules.push(this.globalRules.NoSpaceBeforeCloseBracket); + rules.push(this.globalRules.NoSpaceBetweenBrackets); + } + if (options.InsertSpaceAfterSemicolonInForStatements) { + rules.push(this.globalRules.SpaceAfterSemicolonInFor); + } + else { + rules.push(this.globalRules.NoSpaceAfterSemicolonInFor); + } + if (options.InsertSpaceBeforeAndAfterBinaryOperators) { + rules.push(this.globalRules.SpaceBeforeBinaryOperator); + rules.push(this.globalRules.SpaceAfterBinaryOperator); + } + else { + rules.push(this.globalRules.NoSpaceBeforeBinaryOperator); + rules.push(this.globalRules.NoSpaceAfterBinaryOperator); + } + if (options.PlaceOpenBraceOnNewLineForControlBlocks) { + rules.push(this.globalRules.NewLineBeforeOpenBraceInControl); + } + if (options.PlaceOpenBraceOnNewLineForFunctions) { + rules.push(this.globalRules.NewLineBeforeOpenBraceInFunction); + rules.push(this.globalRules.NewLineBeforeOpenBraceInTypeScriptDeclWithBlock); + } + rules = rules.concat(this.globalRules.LowPriorityCommonRules); + return rules; + }; + return RulesProvider; + })(); + formatting.RulesProvider = RulesProvider; + })(formatting = ts.formatting || (ts.formatting = {})); +})(ts || (ts = {})); +var ts; +(function (ts) { + var formatting; + (function (formatting) { + function formatOnEnter(position, sourceFile, rulesProvider, options) { + var line = sourceFile.getLineAndCharacterOfPosition(position).line; + if (line === 0) { + return []; + } + var span = { + pos: ts.getStartPositionOfLine(line - 1, sourceFile), + end: ts.getEndLinePosition(line, sourceFile) + 1 + }; + return formatSpan(span, sourceFile, options, rulesProvider, 2); + } + formatting.formatOnEnter = formatOnEnter; + function formatOnSemicolon(position, sourceFile, rulesProvider, options) { + return formatOutermostParent(position, 23, sourceFile, options, rulesProvider, 3); + } + formatting.formatOnSemicolon = formatOnSemicolon; + function formatOnClosingCurly(position, sourceFile, rulesProvider, options) { + return formatOutermostParent(position, 16, sourceFile, options, rulesProvider, 4); + } + formatting.formatOnClosingCurly = formatOnClosingCurly; + function formatDocument(sourceFile, rulesProvider, options) { + var span = { + pos: 0, + end: sourceFile.text.length + }; + return formatSpan(span, sourceFile, options, rulesProvider, 0); + } + formatting.formatDocument = formatDocument; + function formatSelection(start, end, sourceFile, rulesProvider, options) { + var span = { + pos: ts.getLineStartPositionForPosition(start, sourceFile), + end: end + }; + return formatSpan(span, sourceFile, options, rulesProvider, 1); + } + formatting.formatSelection = formatSelection; + function formatOutermostParent(position, expectedLastToken, sourceFile, options, rulesProvider, requestKind) { + var parent = findOutermostParent(position, expectedLastToken, sourceFile); + if (!parent) { + return []; + } + var span = { + pos: ts.getLineStartPositionForPosition(parent.getStart(sourceFile), sourceFile), + end: parent.end + }; + return formatSpan(span, sourceFile, options, rulesProvider, requestKind); + } + function findOutermostParent(position, expectedTokenKind, sourceFile) { + var precedingToken = ts.findPrecedingToken(position, sourceFile); + if (!precedingToken || + precedingToken.kind !== expectedTokenKind || + position !== precedingToken.getEnd()) { + return undefined; + } + var current = precedingToken; + while (current && + current.parent && + current.parent.end === precedingToken.end && + !isListElement(current.parent, current)) { + current = current.parent; + } + return current; + } + function isListElement(parent, node) { + switch (parent.kind) { + case 214: + case 215: + return ts.rangeContainsRange(parent.members, node); + case 218: + var body = parent.body; + return body && body.kind === 192 && ts.rangeContainsRange(body.statements, node); + case 248: + case 192: + case 219: + return ts.rangeContainsRange(parent.statements, node); + case 244: + return ts.rangeContainsRange(parent.block.statements, node); + } + return false; + } + function findEnclosingNode(range, sourceFile) { + return find(sourceFile); + function find(n) { + var candidate = ts.forEachChild(n, function (c) { return ts.startEndContainsRange(c.getStart(sourceFile), c.end, range) && c; }); + if (candidate) { + var result = find(candidate); + if (result) { + return result; + } + } + return n; + } + } + function prepareRangeContainsErrorFunction(errors, originalRange) { + if (!errors.length) { + return rangeHasNoErrors; + } + var sorted = errors + .filter(function (d) { return ts.rangeOverlapsWithStartEnd(originalRange, d.start, d.start + d.length); }) + .sort(function (e1, e2) { return e1.start - e2.start; }); + if (!sorted.length) { + return rangeHasNoErrors; + } + var index = 0; + return function (r) { + while (true) { + if (index >= sorted.length) { + return false; + } + var error = sorted[index]; + if (r.end <= error.start) { + return false; + } + if (ts.startEndOverlapsWithStartEnd(r.pos, r.end, error.start, error.start + error.length)) { + return true; + } + index++; + } + }; + function rangeHasNoErrors(r) { + return false; + } + } + function getScanStartPosition(enclosingNode, originalRange, sourceFile) { + var start = enclosingNode.getStart(sourceFile); + if (start === originalRange.pos && enclosingNode.end === originalRange.end) { + return start; + } + var precedingToken = ts.findPrecedingToken(originalRange.pos, sourceFile); + if (!precedingToken) { + return enclosingNode.pos; + } + if (precedingToken.end >= originalRange.pos) { + return enclosingNode.pos; + } + return precedingToken.end; + } + function getOwnOrInheritedDelta(n, options, sourceFile) { + var previousLine = -1; + var childKind = 0; + while (n) { + var line = sourceFile.getLineAndCharacterOfPosition(n.getStart(sourceFile)).line; + if (previousLine !== -1 && line !== previousLine) { + break; + } + if (formatting.SmartIndenter.shouldIndentChildNode(n.kind, childKind)) { + return options.IndentSize; + } + previousLine = line; + childKind = n.kind; + n = n.parent; + } + return 0; + } + function formatSpan(originalRange, sourceFile, options, rulesProvider, requestKind) { + var rangeContainsError = prepareRangeContainsErrorFunction(sourceFile.parseDiagnostics, originalRange); + var formattingContext = new formatting.FormattingContext(sourceFile, requestKind); + var enclosingNode = findEnclosingNode(originalRange, sourceFile); + var formattingScanner = formatting.getFormattingScanner(sourceFile, getScanStartPosition(enclosingNode, originalRange, sourceFile), originalRange.end); + var initialIndentation = formatting.SmartIndenter.getIndentationForNode(enclosingNode, originalRange, sourceFile, options); + var previousRangeHasError; + var previousRange; + var previousParent; + var previousRangeStartLine; + var lastIndentedLine; + var indentationOnLastIndentedLine; + var edits = []; + formattingScanner.advance(); + if (formattingScanner.isOnToken()) { + var startLine = sourceFile.getLineAndCharacterOfPosition(enclosingNode.getStart(sourceFile)).line; + var undecoratedStartLine = startLine; + if (enclosingNode.decorators) { + undecoratedStartLine = sourceFile.getLineAndCharacterOfPosition(ts.getNonDecoratorTokenPosOfNode(enclosingNode, sourceFile)).line; + } + var delta = getOwnOrInheritedDelta(enclosingNode, options, sourceFile); + processNode(enclosingNode, enclosingNode, startLine, undecoratedStartLine, initialIndentation, delta); + } + formattingScanner.close(); + return edits; + function tryComputeIndentationForListItem(startPos, endPos, parentStartLine, range, inheritedIndentation) { + if (ts.rangeOverlapsWithStartEnd(range, startPos, endPos)) { + if (inheritedIndentation !== -1) { + return inheritedIndentation; + } + } + else { + var startLine = sourceFile.getLineAndCharacterOfPosition(startPos).line; + var startLinePosition = ts.getLineStartPositionForPosition(startPos, sourceFile); + var column = formatting.SmartIndenter.findFirstNonWhitespaceColumn(startLinePosition, startPos, sourceFile, options); + if (startLine !== parentStartLine || startPos === column) { + return column; + } + } + return -1; + } + function computeIndentation(node, startLine, inheritedIndentation, parent, parentDynamicIndentation, effectiveParentStartLine) { + var indentation = inheritedIndentation; + if (indentation === -1) { + if (isSomeBlock(node.kind)) { + if (isSomeBlock(parent.kind) || + parent.kind === 248 || + parent.kind === 241 || + parent.kind === 242) { + indentation = parentDynamicIndentation.getIndentation() + parentDynamicIndentation.getDelta(); + } + else { + indentation = parentDynamicIndentation.getIndentation(); + } + } + else { + if (formatting.SmartIndenter.childStartsOnTheSameLineWithElseInIfStatement(parent, node, startLine, sourceFile)) { + indentation = parentDynamicIndentation.getIndentation(); + } + else { + indentation = parentDynamicIndentation.getIndentation() + parentDynamicIndentation.getDelta(); + } + } + } + var delta = formatting.SmartIndenter.shouldIndentChildNode(node.kind, 0) ? options.IndentSize : 0; + if (effectiveParentStartLine === startLine) { + indentation = startLine === lastIndentedLine + ? indentationOnLastIndentedLine + : parentDynamicIndentation.getIndentation(); + delta = Math.min(options.IndentSize, parentDynamicIndentation.getDelta() + delta); + } + return { + indentation: indentation, + delta: delta + }; + } + function getFirstNonDecoratorTokenOfNode(node) { + if (node.modifiers && node.modifiers.length) { + return node.modifiers[0].kind; + } + switch (node.kind) { + case 214: return 73; + case 215: return 107; + case 213: return 87; + case 217: return 217; + case 145: return 123; + case 146: return 129; + case 143: + if (node.asteriskToken) { + return 37; + } + case 141: + case 138: + return node.name.kind; + } + } + function getDynamicIndentation(node, nodeStartLine, indentation, delta) { + return { + getIndentationForComment: function (kind, tokenIndentation) { + switch (kind) { + case 16: + case 20: + case 18: + return indentation + delta; + } + return tokenIndentation !== -1 ? tokenIndentation : indentation; + }, + getIndentationForToken: function (line, kind) { + if (nodeStartLine !== line && node.decorators) { + if (kind === getFirstNonDecoratorTokenOfNode(node)) { + return indentation; + } + } + switch (kind) { + case 15: + case 16: + case 19: + case 20: + case 17: + case 18: + case 80: + case 104: + case 55: + return indentation; + default: + return nodeStartLine !== line ? indentation + delta : indentation; + } + }, + getIndentation: function () { return indentation; }, + getDelta: function () { return delta; }, + recomputeIndentation: function (lineAdded) { + if (node.parent && formatting.SmartIndenter.shouldIndentChildNode(node.parent.kind, node.kind)) { + if (lineAdded) { + indentation += options.IndentSize; + } + else { + indentation -= options.IndentSize; + } + if (formatting.SmartIndenter.shouldIndentChildNode(node.kind, 0)) { + delta = options.IndentSize; + } + else { + delta = 0; + } + } + } + }; + } + function processNode(node, contextNode, nodeStartLine, undecoratedNodeStartLine, indentation, delta) { + if (!ts.rangeOverlapsWithStartEnd(originalRange, node.getStart(sourceFile), node.getEnd())) { + return; + } + var nodeDynamicIndentation = getDynamicIndentation(node, nodeStartLine, indentation, delta); + var childContextNode = contextNode; + ts.forEachChild(node, function (child) { + processChildNode(child, -1, node, nodeDynamicIndentation, nodeStartLine, undecoratedNodeStartLine, false); + }, function (nodes) { + processChildNodes(nodes, node, nodeStartLine, nodeDynamicIndentation); + }); + while (formattingScanner.isOnToken()) { + var tokenInfo = formattingScanner.readTokenInfo(node); + if (tokenInfo.token.end > node.end) { + break; + } + consumeTokenAndAdvanceScanner(tokenInfo, node, nodeDynamicIndentation); + } + function processChildNode(child, inheritedIndentation, parent, parentDynamicIndentation, parentStartLine, undecoratedParentStartLine, isListItem) { + var childStartPos = child.getStart(sourceFile); + var childStartLine = sourceFile.getLineAndCharacterOfPosition(childStartPos).line; + var undecoratedChildStartLine = childStartLine; + if (child.decorators) { + undecoratedChildStartLine = sourceFile.getLineAndCharacterOfPosition(ts.getNonDecoratorTokenPosOfNode(child, sourceFile)).line; + } + var childIndentationAmount = -1; + if (isListItem) { + childIndentationAmount = tryComputeIndentationForListItem(childStartPos, child.end, parentStartLine, originalRange, inheritedIndentation); + if (childIndentationAmount !== -1) { + inheritedIndentation = childIndentationAmount; + } + } + if (!ts.rangeOverlapsWithStartEnd(originalRange, child.pos, child.end)) { + return inheritedIndentation; + } + if (child.getFullWidth() === 0) { + return inheritedIndentation; + } + while (formattingScanner.isOnToken()) { + var tokenInfo = formattingScanner.readTokenInfo(node); + if (tokenInfo.token.end > childStartPos) { + break; + } + consumeTokenAndAdvanceScanner(tokenInfo, node, parentDynamicIndentation); + } + if (!formattingScanner.isOnToken()) { + return inheritedIndentation; + } + if (ts.isToken(child)) { + var tokenInfo = formattingScanner.readTokenInfo(child); + ts.Debug.assert(tokenInfo.token.end === child.end); + consumeTokenAndAdvanceScanner(tokenInfo, node, parentDynamicIndentation); + return inheritedIndentation; + } + var effectiveParentStartLine = child.kind === 139 ? childStartLine : undecoratedParentStartLine; + var childIndentation = computeIndentation(child, childStartLine, childIndentationAmount, node, parentDynamicIndentation, effectiveParentStartLine); + processNode(child, childContextNode, childStartLine, undecoratedChildStartLine, childIndentation.indentation, childIndentation.delta); + childContextNode = node; + return inheritedIndentation; + } + function processChildNodes(nodes, parent, parentStartLine, parentDynamicIndentation) { + var listStartToken = getOpenTokenForList(parent, nodes); + var listEndToken = getCloseTokenForOpenToken(listStartToken); + var listDynamicIndentation = parentDynamicIndentation; + var startLine = parentStartLine; + if (listStartToken !== 0) { + while (formattingScanner.isOnToken()) { + var tokenInfo = formattingScanner.readTokenInfo(parent); + if (tokenInfo.token.end > nodes.pos) { + break; + } + else if (tokenInfo.token.kind === listStartToken) { + startLine = sourceFile.getLineAndCharacterOfPosition(tokenInfo.token.pos).line; + var indentation_1 = computeIndentation(tokenInfo.token, startLine, -1, parent, parentDynamicIndentation, parentStartLine); + listDynamicIndentation = getDynamicIndentation(parent, parentStartLine, indentation_1.indentation, indentation_1.delta); + consumeTokenAndAdvanceScanner(tokenInfo, parent, listDynamicIndentation); + } + else { + consumeTokenAndAdvanceScanner(tokenInfo, parent, parentDynamicIndentation); + } + } + } + var inheritedIndentation = -1; + for (var _i = 0; _i < nodes.length; _i++) { + var child = nodes[_i]; + inheritedIndentation = processChildNode(child, inheritedIndentation, node, listDynamicIndentation, startLine, startLine, true); + } + if (listEndToken !== 0) { + if (formattingScanner.isOnToken()) { + var tokenInfo = formattingScanner.readTokenInfo(parent); + if (tokenInfo.token.kind === listEndToken && ts.rangeContainsRange(parent, tokenInfo.token)) { + consumeTokenAndAdvanceScanner(tokenInfo, parent, listDynamicIndentation); + } + } + } + } + function consumeTokenAndAdvanceScanner(currentTokenInfo, parent, dynamicIndentation) { + ts.Debug.assert(ts.rangeContainsRange(parent, currentTokenInfo.token)); + var lastTriviaWasNewLine = formattingScanner.lastTrailingTriviaWasNewLine(); + var indentToken = false; + if (currentTokenInfo.leadingTrivia) { + processTrivia(currentTokenInfo.leadingTrivia, parent, childContextNode, dynamicIndentation); + } + var lineAdded; + var isTokenInRange = ts.rangeContainsRange(originalRange, currentTokenInfo.token); + var tokenStart = sourceFile.getLineAndCharacterOfPosition(currentTokenInfo.token.pos); + if (isTokenInRange) { + var rangeHasError = rangeContainsError(currentTokenInfo.token); + var savePreviousRange = previousRange; + lineAdded = processRange(currentTokenInfo.token, tokenStart, parent, childContextNode, dynamicIndentation); + if (rangeHasError) { + indentToken = false; + } + else { + if (lineAdded !== undefined) { + indentToken = lineAdded; + } + else { + var prevEndLine = savePreviousRange && sourceFile.getLineAndCharacterOfPosition(savePreviousRange.end).line; + indentToken = lastTriviaWasNewLine && tokenStart.line !== prevEndLine; + } + } + } + if (currentTokenInfo.trailingTrivia) { + processTrivia(currentTokenInfo.trailingTrivia, parent, childContextNode, dynamicIndentation); + } + if (indentToken) { + var tokenIndentation = (isTokenInRange && !rangeContainsError(currentTokenInfo.token)) ? + dynamicIndentation.getIndentationForToken(tokenStart.line, currentTokenInfo.token.kind) : + -1; + if (currentTokenInfo.leadingTrivia) { + var commentIndentation = dynamicIndentation.getIndentationForComment(currentTokenInfo.token.kind, tokenIndentation); + var indentNextTokenOrTrivia = true; + for (var _i = 0, _a = currentTokenInfo.leadingTrivia; _i < _a.length; _i++) { + var triviaItem = _a[_i]; + if (!ts.rangeContainsRange(originalRange, triviaItem)) { + continue; + } + switch (triviaItem.kind) { + case 3: + indentMultilineComment(triviaItem, commentIndentation, !indentNextTokenOrTrivia); + indentNextTokenOrTrivia = false; + break; + case 2: + if (indentNextTokenOrTrivia) { + insertIndentation(triviaItem.pos, commentIndentation, false); + indentNextTokenOrTrivia = false; + } + break; + case 4: + indentNextTokenOrTrivia = true; + break; + } + } + } + if (tokenIndentation !== -1) { + insertIndentation(currentTokenInfo.token.pos, tokenIndentation, lineAdded); + lastIndentedLine = tokenStart.line; + indentationOnLastIndentedLine = tokenIndentation; + } + } + formattingScanner.advance(); + childContextNode = parent; + } + } + function processTrivia(trivia, parent, contextNode, dynamicIndentation) { + for (var _i = 0; _i < trivia.length; _i++) { + var triviaItem = trivia[_i]; + if (ts.isComment(triviaItem.kind) && ts.rangeContainsRange(originalRange, triviaItem)) { + var triviaItemStart = sourceFile.getLineAndCharacterOfPosition(triviaItem.pos); + processRange(triviaItem, triviaItemStart, parent, contextNode, dynamicIndentation); + } + } + } + function processRange(range, rangeStart, parent, contextNode, dynamicIndentation) { + var rangeHasError = rangeContainsError(range); + var lineAdded; + if (!rangeHasError && !previousRangeHasError) { + if (!previousRange) { + var originalStart = sourceFile.getLineAndCharacterOfPosition(originalRange.pos); + trimTrailingWhitespacesForLines(originalStart.line, rangeStart.line); + } + else { + lineAdded = + processPair(range, rangeStart.line, parent, previousRange, previousRangeStartLine, previousParent, contextNode, dynamicIndentation); + } + } + previousRange = range; + previousParent = parent; + previousRangeStartLine = rangeStart.line; + previousRangeHasError = rangeHasError; + return lineAdded; + } + function processPair(currentItem, currentStartLine, currentParent, previousItem, previousStartLine, previousParent, contextNode, dynamicIndentation) { + formattingContext.updateContext(previousItem, previousParent, currentItem, currentParent, contextNode); + var rule = rulesProvider.getRulesMap().GetRule(formattingContext); + var trimTrailingWhitespaces; + var lineAdded; + if (rule) { + applyRuleEdits(rule, previousItem, previousStartLine, currentItem, currentStartLine); + if (rule.Operation.Action & (2 | 8) && currentStartLine !== previousStartLine) { + lineAdded = false; + if (currentParent.getStart(sourceFile) === currentItem.pos) { + dynamicIndentation.recomputeIndentation(false); + } + } + else if (rule.Operation.Action & 4 && currentStartLine === previousStartLine) { + lineAdded = true; + if (currentParent.getStart(sourceFile) === currentItem.pos) { + dynamicIndentation.recomputeIndentation(true); + } + } + trimTrailingWhitespaces = + (rule.Operation.Action & (4 | 2)) && + rule.Flag !== 1; + } + else { + trimTrailingWhitespaces = true; + } + if (currentStartLine !== previousStartLine && trimTrailingWhitespaces) { + trimTrailingWhitespacesForLines(previousStartLine, currentStartLine, previousItem); + } + return lineAdded; + } + function insertIndentation(pos, indentation, lineAdded) { + var indentationString = getIndentationString(indentation, options); + if (lineAdded) { + recordReplace(pos, 0, indentationString); + } + else { + var tokenStart = sourceFile.getLineAndCharacterOfPosition(pos); + if (indentation !== tokenStart.character) { + var startLinePosition = ts.getStartPositionOfLine(tokenStart.line, sourceFile); + recordReplace(startLinePosition, tokenStart.character, indentationString); + } + } + } + function indentMultilineComment(commentRange, indentation, firstLineIsIndented) { + var startLine = sourceFile.getLineAndCharacterOfPosition(commentRange.pos).line; + var endLine = sourceFile.getLineAndCharacterOfPosition(commentRange.end).line; + var parts; + if (startLine === endLine) { + if (!firstLineIsIndented) { + insertIndentation(commentRange.pos, indentation, false); + } + return; + } + else { + parts = []; + var startPos = commentRange.pos; + for (var line = startLine; line < endLine; ++line) { + var endOfLine = ts.getEndLinePosition(line, sourceFile); + parts.push({ pos: startPos, end: endOfLine }); + startPos = ts.getStartPositionOfLine(line + 1, sourceFile); + } + parts.push({ pos: startPos, end: commentRange.end }); + } + var startLinePos = ts.getStartPositionOfLine(startLine, sourceFile); + var nonWhitespaceColumnInFirstPart = formatting.SmartIndenter.findFirstNonWhitespaceCharacterAndColumn(startLinePos, parts[0].pos, sourceFile, options); + if (indentation === nonWhitespaceColumnInFirstPart.column) { + return; + } + var startIndex = 0; + if (firstLineIsIndented) { + startIndex = 1; + startLine++; + } + var delta = indentation - nonWhitespaceColumnInFirstPart.column; + for (var i = startIndex, len = parts.length; i < len; ++i, ++startLine) { + var startLinePos_1 = ts.getStartPositionOfLine(startLine, sourceFile); + var nonWhitespaceCharacterAndColumn = i === 0 + ? nonWhitespaceColumnInFirstPart + : formatting.SmartIndenter.findFirstNonWhitespaceCharacterAndColumn(parts[i].pos, parts[i].end, sourceFile, options); + var newIndentation = nonWhitespaceCharacterAndColumn.column + delta; + if (newIndentation > 0) { + var indentationString = getIndentationString(newIndentation, options); + recordReplace(startLinePos_1, nonWhitespaceCharacterAndColumn.character, indentationString); + } + else { + recordDelete(startLinePos_1, nonWhitespaceCharacterAndColumn.character); + } + } + } + function trimTrailingWhitespacesForLines(line1, line2, range) { + for (var line = line1; line < line2; ++line) { + var lineStartPosition = ts.getStartPositionOfLine(line, sourceFile); + var lineEndPosition = ts.getEndLinePosition(line, sourceFile); + if (range && (ts.isComment(range.kind) || ts.isStringOrRegularExpressionOrTemplateLiteral(range.kind)) && range.pos <= lineEndPosition && range.end > lineEndPosition) { + continue; + } + var pos = lineEndPosition; + while (pos >= lineStartPosition && ts.isWhiteSpace(sourceFile.text.charCodeAt(pos))) { + pos--; + } + if (pos !== lineEndPosition) { + ts.Debug.assert(pos === lineStartPosition || !ts.isWhiteSpace(sourceFile.text.charCodeAt(pos))); + recordDelete(pos + 1, lineEndPosition - pos); + } + } + } + function newTextChange(start, len, newText) { + return { span: ts.createTextSpan(start, len), newText: newText }; + } + function recordDelete(start, len) { + if (len) { + edits.push(newTextChange(start, len, "")); + } + } + function recordReplace(start, len, newText) { + if (len || newText) { + edits.push(newTextChange(start, len, newText)); + } + } + function applyRuleEdits(rule, previousRange, previousStartLine, currentRange, currentStartLine) { + var between; + switch (rule.Operation.Action) { + case 1: + return; + case 8: + if (previousRange.end !== currentRange.pos) { + recordDelete(previousRange.end, currentRange.pos - previousRange.end); + } + break; + case 4: + if (rule.Flag !== 1 && previousStartLine !== currentStartLine) { + return; + } + var lineDelta = currentStartLine - previousStartLine; + if (lineDelta !== 1) { + recordReplace(previousRange.end, currentRange.pos - previousRange.end, options.NewLineCharacter); + } + break; + case 2: + if (rule.Flag !== 1 && previousStartLine !== currentStartLine) { + return; + } + var posDelta = currentRange.pos - previousRange.end; + if (posDelta !== 1 || sourceFile.text.charCodeAt(previousRange.end) !== 32) { + recordReplace(previousRange.end, currentRange.pos - previousRange.end, " "); + } + break; + } + } + } + function isSomeBlock(kind) { + switch (kind) { + case 192: + case 219: + return true; + } + return false; + } + function getOpenTokenForList(node, list) { + switch (node.kind) { + case 144: + case 213: + case 173: + case 143: + case 142: + case 174: + if (node.typeParameters === list) { + return 25; + } + else if (node.parameters === list) { + return 17; + } + break; + case 168: + case 169: + if (node.typeArguments === list) { + return 25; + } + else if (node.arguments === list) { + return 17; + } + break; + case 151: + if (node.typeArguments === list) { + return 25; + } + } + return 0; + } + function getCloseTokenForOpenToken(kind) { + switch (kind) { + case 17: + return 18; + case 25: + return 27; + } + return 0; + } + var internedSizes; + var internedTabsIndentation; + var internedSpacesIndentation; + function getIndentationString(indentation, options) { + var resetInternedStrings = !internedSizes || (internedSizes.tabSize !== options.TabSize || internedSizes.indentSize !== options.IndentSize); + if (resetInternedStrings) { + internedSizes = { tabSize: options.TabSize, indentSize: options.IndentSize }; + internedTabsIndentation = internedSpacesIndentation = undefined; + } + if (!options.ConvertTabsToSpaces) { + var tabs = Math.floor(indentation / options.TabSize); + var spaces = indentation - tabs * options.TabSize; + var tabString; + if (!internedTabsIndentation) { + internedTabsIndentation = []; + } + if (internedTabsIndentation[tabs] === undefined) { + internedTabsIndentation[tabs] = tabString = repeat('\t', tabs); + } + else { + tabString = internedTabsIndentation[tabs]; + } + return spaces ? tabString + repeat(" ", spaces) : tabString; + } + else { + var spacesString; + var quotient = Math.floor(indentation / options.IndentSize); + var remainder = indentation % options.IndentSize; + if (!internedSpacesIndentation) { + internedSpacesIndentation = []; + } + if (internedSpacesIndentation[quotient] === undefined) { + spacesString = repeat(" ", options.IndentSize * quotient); + internedSpacesIndentation[quotient] = spacesString; + } + else { + spacesString = internedSpacesIndentation[quotient]; + } + return remainder ? spacesString + repeat(" ", remainder) : spacesString; + } + function repeat(value, count) { + var s = ""; + for (var i = 0; i < count; ++i) { + s += value; + } + return s; + } + } + formatting.getIndentationString = getIndentationString; + })(formatting = ts.formatting || (ts.formatting = {})); +})(ts || (ts = {})); +var ts; +(function (ts) { + var formatting; + (function (formatting) { + var SmartIndenter; + (function (SmartIndenter) { + function getIndentation(position, sourceFile, options) { + if (position > sourceFile.text.length) { + return 0; + } + if (options.IndentStyle === ts.IndentStyle.None) { + return 0; + } + var precedingToken = ts.findPrecedingToken(position, sourceFile); + if (!precedingToken) { + return 0; + } + var precedingTokenIsLiteral = ts.isStringOrRegularExpressionOrTemplateLiteral(precedingToken.kind); + if (precedingTokenIsLiteral && precedingToken.getStart(sourceFile) <= position && precedingToken.end > position) { + return 0; + } + var lineAtPosition = sourceFile.getLineAndCharacterOfPosition(position).line; + if (options.IndentStyle === ts.IndentStyle.Block) { + var current_1 = position; + while (current_1 > 0) { + var char = sourceFile.text.charCodeAt(current_1); + if (!ts.isWhiteSpace(char) && !ts.isLineBreak(char)) { + break; + } + current_1--; + } + var lineStart = ts.getLineStartPositionForPosition(current_1, sourceFile); + return SmartIndenter.findFirstNonWhitespaceColumn(lineStart, current_1, sourceFile, options); + } + if (precedingToken.kind === 24 && precedingToken.parent.kind !== 181) { + var actualIndentation = getActualIndentationForListItemBeforeComma(precedingToken, sourceFile, options); + if (actualIndentation !== -1) { + return actualIndentation; + } + } + var previous; + var current = precedingToken; + var currentStart; + var indentationDelta; + while (current) { + if (ts.positionBelongsToNode(current, position, sourceFile) && shouldIndentChildNode(current.kind, previous ? previous.kind : 0)) { + currentStart = getStartLineAndCharacterForNode(current, sourceFile); + if (nextTokenIsCurlyBraceOnSameLineAsCursor(precedingToken, current, lineAtPosition, sourceFile)) { + indentationDelta = 0; + } + else { + indentationDelta = lineAtPosition !== currentStart.line ? options.IndentSize : 0; + } + break; + } + var actualIndentation = getActualIndentationForListItem(current, sourceFile, options); + if (actualIndentation !== -1) { + return actualIndentation; + } + actualIndentation = getLineIndentationWhenExpressionIsInMultiLine(current, sourceFile, options); + if (actualIndentation !== -1) { + return actualIndentation + options.IndentSize; + } + previous = current; + current = current.parent; + } + if (!current) { + return 0; + } + return getIndentationForNodeWorker(current, currentStart, undefined, indentationDelta, sourceFile, options); + } + SmartIndenter.getIndentation = getIndentation; + 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 getIndentationForNodeWorker(current, currentStart, ignoreActualIndentationRange, indentationDelta, sourceFile, options) { + var parent = current.parent; + var parentStart; + while (parent) { + var useActualIndentation = true; + if (ignoreActualIndentationRange) { + var start = current.getStart(sourceFile); + useActualIndentation = start < ignoreActualIndentationRange.pos || start > ignoreActualIndentationRange.end; + } + if (useActualIndentation) { + var actualIndentation = getActualIndentationForListItem(current, sourceFile, options); + if (actualIndentation !== -1) { + return actualIndentation + indentationDelta; + } + } + parentStart = getParentStart(parent, current, sourceFile); + var parentAndChildShareLine = parentStart.line === currentStart.line || + childStartsOnTheSameLineWithElseInIfStatement(parent, current, currentStart.line, sourceFile); + if (useActualIndentation) { + var actualIndentation = getActualIndentationForNode(current, parent, currentStart, parentAndChildShareLine, sourceFile, options); + if (actualIndentation !== -1) { + return actualIndentation + indentationDelta; + } + actualIndentation = getLineIndentationWhenExpressionIsInMultiLine(current, sourceFile, options); + if (actualIndentation !== -1) { + return actualIndentation + indentationDelta; + } + } + if (shouldIndentChildNode(parent.kind, current.kind) && !parentAndChildShareLine) { + indentationDelta += options.IndentSize; + } + current = parent; + currentStart = parentStart; + parent = current.parent; + } + return indentationDelta; + } + function getParentStart(parent, child, sourceFile) { + var containingList = getContainingList(child, sourceFile); + if (containingList) { + return sourceFile.getLineAndCharacterOfPosition(containingList.pos); + } + return sourceFile.getLineAndCharacterOfPosition(parent.getStart(sourceFile)); + } + function getActualIndentationForListItemBeforeComma(commaToken, sourceFile, options) { + var commaItemInfo = ts.findListItemInfo(commaToken); + if (commaItemInfo && commaItemInfo.listItemIndex > 0) { + return deriveActualIndentationFromList(commaItemInfo.list.getChildren(), commaItemInfo.listItemIndex - 1, sourceFile, options); + } + else { + return -1; + } + } + function getActualIndentationForNode(current, parent, currentLineAndChar, parentAndChildShareLine, sourceFile, options) { + var useActualIndentation = (ts.isDeclaration(current) || ts.isStatement(current)) && + (parent.kind === 248 || !parentAndChildShareLine); + if (!useActualIndentation) { + return -1; + } + return findColumnForFirstNonWhitespaceCharacterInLine(currentLineAndChar, sourceFile, options); + } + function nextTokenIsCurlyBraceOnSameLineAsCursor(precedingToken, current, lineAtPosition, sourceFile) { + var nextToken = ts.findNextToken(precedingToken, current); + if (!nextToken) { + return false; + } + if (nextToken.kind === 15) { + return true; + } + else if (nextToken.kind === 16) { + var nextTokenStartLine = getStartLineAndCharacterForNode(nextToken, sourceFile).line; + return lineAtPosition === nextTokenStartLine; + } + return false; + } + function getStartLineAndCharacterForNode(n, sourceFile) { + return sourceFile.getLineAndCharacterOfPosition(n.getStart(sourceFile)); + } + function childStartsOnTheSameLineWithElseInIfStatement(parent, child, childStartLine, sourceFile) { + if (parent.kind === 196 && parent.elseStatement === child) { + var elseKeyword = ts.findChildOfKind(parent, 80, sourceFile); + ts.Debug.assert(elseKeyword !== undefined); + var elseKeywordStartLine = getStartLineAndCharacterForNode(elseKeyword, sourceFile).line; + return elseKeywordStartLine === childStartLine; + } + return false; + } + SmartIndenter.childStartsOnTheSameLineWithElseInIfStatement = childStartsOnTheSameLineWithElseInIfStatement; + function getContainingList(node, sourceFile) { + if (node.parent) { + switch (node.parent.kind) { + case 151: + if (node.parent.typeArguments && + ts.rangeContainsStartEnd(node.parent.typeArguments, node.getStart(sourceFile), node.getEnd())) { + return node.parent.typeArguments; + } + break; + case 165: + return node.parent.properties; + case 164: + return node.parent.elements; + case 213: + case 173: + case 174: + case 143: + case 142: + case 147: + case 148: { + var start = node.getStart(sourceFile); + if (node.parent.typeParameters && + ts.rangeContainsStartEnd(node.parent.typeParameters, start, node.getEnd())) { + return node.parent.typeParameters; + } + if (ts.rangeContainsStartEnd(node.parent.parameters, start, node.getEnd())) { + return node.parent.parameters; + } + break; + } + case 169: + case 168: { + var start = node.getStart(sourceFile); + if (node.parent.typeArguments && + ts.rangeContainsStartEnd(node.parent.typeArguments, start, node.getEnd())) { + return node.parent.typeArguments; + } + if (node.parent.arguments && + ts.rangeContainsStartEnd(node.parent.arguments, start, node.getEnd())) { + return node.parent.arguments; + } + break; + } + } + } + return undefined; + } + function getActualIndentationForListItem(node, sourceFile, options) { + var containingList = getContainingList(node, sourceFile); + return containingList ? getActualIndentationFromList(containingList) : -1; + function getActualIndentationFromList(list) { + var index = ts.indexOf(list, node); + return index !== -1 ? deriveActualIndentationFromList(list, index, sourceFile, options) : -1; + } + } + function getLineIndentationWhenExpressionIsInMultiLine(node, sourceFile, options) { + if (node.kind === 18) { + return -1; + } + if (node.parent && (node.parent.kind === 168 || + node.parent.kind === 169) && + node.parent.expression !== node) { + var fullCallOrNewExpression = node.parent.expression; + var startingExpression = getStartingExpression(fullCallOrNewExpression); + if (fullCallOrNewExpression === startingExpression) { + return -1; + } + var fullCallOrNewExpressionEnd = sourceFile.getLineAndCharacterOfPosition(fullCallOrNewExpression.end); + var startingExpressionEnd = sourceFile.getLineAndCharacterOfPosition(startingExpression.end); + if (fullCallOrNewExpressionEnd.line === startingExpressionEnd.line) { + return -1; + } + return findColumnForFirstNonWhitespaceCharacterInLine(fullCallOrNewExpressionEnd, sourceFile, options); + } + return -1; + function getStartingExpression(node) { + while (true) { + switch (node.kind) { + case 168: + case 169: + case 166: + case 167: + node = node.expression; + break; + default: + return node; + } + } + return node; + } + } + function deriveActualIndentationFromList(list, index, sourceFile, options) { + ts.Debug.assert(index >= 0 && index < list.length); + var node = list[index]; + var lineAndCharacter = getStartLineAndCharacterForNode(node, sourceFile); + for (var i = index - 1; i >= 0; --i) { + if (list[i].kind === 24) { + continue; + } + var prevEndLine = sourceFile.getLineAndCharacterOfPosition(list[i].end).line; + if (prevEndLine !== lineAndCharacter.line) { + return findColumnForFirstNonWhitespaceCharacterInLine(lineAndCharacter, sourceFile, options); + } + lineAndCharacter = getStartLineAndCharacterForNode(list[i], sourceFile); + } + return -1; + } + function findColumnForFirstNonWhitespaceCharacterInLine(lineAndCharacter, sourceFile, options) { + var lineStart = sourceFile.getPositionOfLineAndCharacter(lineAndCharacter.line, 0); + return findFirstNonWhitespaceColumn(lineStart, lineStart + lineAndCharacter.character, sourceFile, options); + } + function findFirstNonWhitespaceCharacterAndColumn(startPos, endPos, sourceFile, options) { + var character = 0; + var column = 0; + for (var pos = startPos; pos < endPos; ++pos) { + var ch = sourceFile.text.charCodeAt(pos); + if (!ts.isWhiteSpace(ch)) { + break; + } + if (ch === 9) { + column += options.TabSize + (column % options.TabSize); + } + else { + column++; + } + character++; + } + return { column: column, character: character }; + } + SmartIndenter.findFirstNonWhitespaceCharacterAndColumn = findFirstNonWhitespaceCharacterAndColumn; + function findFirstNonWhitespaceColumn(startPos, endPos, sourceFile, options) { + return findFirstNonWhitespaceCharacterAndColumn(startPos, endPos, sourceFile, options).column; + } + SmartIndenter.findFirstNonWhitespaceColumn = findFirstNonWhitespaceColumn; + function nodeContentIsAlwaysIndented(kind) { + switch (kind) { + case 195: + case 214: + case 186: + case 215: + case 217: + case 216: + case 164: + case 192: + case 219: + case 165: + case 155: + case 157: + case 220: + case 242: + case 241: + case 172: + case 166: + case 168: + case 169: + case 193: + case 211: + case 227: + case 204: + case 182: + case 162: + case 161: + case 233: + case 234: + case 142: + case 147: + case 148: + case 138: + case 152: + case 153: + case 160: + case 170: + case 178: + return true; + } + return false; + } + function shouldIndentChildNode(parent, child) { + if (nodeContentIsAlwaysIndented(parent)) { + return true; + } + switch (parent) { + case 197: + case 198: + case 200: + case 201: + case 199: + case 196: + case 213: + case 173: + case 143: + case 174: + case 144: + case 145: + case 146: + return child !== 192; + default: + return false; + } + } + SmartIndenter.shouldIndentChildNode = shouldIndentChildNode; + })(SmartIndenter = formatting.SmartIndenter || (formatting.SmartIndenter = {})); + })(formatting = ts.formatting || (ts.formatting = {})); +})(ts || (ts = {})); +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 ts; +(function (ts) { + ts.servicesVersion = "0.4"; + var ScriptSnapshot; + (function (ScriptSnapshot) { + var StringScriptSnapshot = (function () { + function StringScriptSnapshot(text) { + this.text = text; + } + StringScriptSnapshot.prototype.getText = function (start, end) { + return this.text.substring(start, end); + }; + StringScriptSnapshot.prototype.getLength = function () { + return this.text.length; + }; + StringScriptSnapshot.prototype.getChangeRange = function (oldSnapshot) { + return undefined; + }; + return StringScriptSnapshot; + })(); + function fromString(text) { + return new StringScriptSnapshot(text); + } + ScriptSnapshot.fromString = fromString; + })(ScriptSnapshot = ts.ScriptSnapshot || (ts.ScriptSnapshot = {})); + var scanner = ts.createScanner(2, true); + var emptyArray = []; + var jsDocTagNames = [ + "augments", + "author", + "argument", + "borrows", + "class", + "constant", + "constructor", + "constructs", + "default", + "deprecated", + "description", + "event", + "example", + "extends", + "field", + "fileOverview", + "function", + "ignore", + "inner", + "lends", + "link", + "memberOf", + "name", + "namespace", + "param", + "private", + "property", + "public", + "requires", + "returns", + "see", + "since", + "static", + "throws", + "type", + "version" + ]; + var jsDocCompletionEntries; + function createNode(kind, pos, end, flags, parent) { + var node = new (ts.getNodeConstructor(kind))(pos, end); + node.flags = flags; + node.parent = parent; + return node; + } + var NodeObject = (function () { + function NodeObject() { + } + NodeObject.prototype.getSourceFile = function () { + return ts.getSourceFileOfNode(this); + }; + NodeObject.prototype.getStart = function (sourceFile) { + return ts.getTokenPosOfNode(this, sourceFile); + }; + NodeObject.prototype.getFullStart = function () { + return this.pos; + }; + NodeObject.prototype.getEnd = function () { + return this.end; + }; + NodeObject.prototype.getWidth = function (sourceFile) { + return this.getEnd() - this.getStart(sourceFile); + }; + NodeObject.prototype.getFullWidth = function () { + return this.end - this.pos; + }; + NodeObject.prototype.getLeadingTriviaWidth = function (sourceFile) { + return this.getStart(sourceFile) - this.pos; + }; + NodeObject.prototype.getFullText = function (sourceFile) { + return (sourceFile || this.getSourceFile()).text.substring(this.pos, this.end); + }; + NodeObject.prototype.getText = function (sourceFile) { + return (sourceFile || this.getSourceFile()).text.substring(this.getStart(), this.getEnd()); + }; + NodeObject.prototype.addSyntheticNodes = function (nodes, pos, end) { + scanner.setTextPos(pos); + while (pos < end) { + var token = scanner.scan(); + var textPos = scanner.getTextPos(); + nodes.push(createNode(token, pos, textPos, 4096, this)); + pos = textPos; + } + return pos; + }; + NodeObject.prototype.createSyntaxList = function (nodes) { + var list = createNode(271, nodes.pos, nodes.end, 4096, this); + list._children = []; + var pos = nodes.pos; + for (var _i = 0; _i < nodes.length; _i++) { + var node = nodes[_i]; + if (pos < node.pos) { + pos = this.addSyntheticNodes(list._children, pos, node.pos); + } + list._children.push(node); + pos = node.end; + } + if (pos < nodes.end) { + this.addSyntheticNodes(list._children, pos, nodes.end); + } + return list; + }; + NodeObject.prototype.createChildren = function (sourceFile) { + var _this = this; + var children; + if (this.kind >= 135) { + scanner.setText((sourceFile || this.getSourceFile()).text); + children = []; + var pos = this.pos; + var processNode = function (node) { + if (pos < node.pos) { + pos = _this.addSyntheticNodes(children, pos, node.pos); + } + children.push(node); + pos = node.end; + }; + var processNodes = function (nodes) { + if (pos < nodes.pos) { + pos = _this.addSyntheticNodes(children, pos, nodes.pos); + } + children.push(_this.createSyntaxList(nodes)); + pos = nodes.end; + }; + ts.forEachChild(this, processNode, processNodes); + if (pos < this.end) { + this.addSyntheticNodes(children, pos, this.end); + } + scanner.setText(undefined); + } + this._children = children || emptyArray; + }; + NodeObject.prototype.getChildCount = function (sourceFile) { + if (!this._children) + this.createChildren(sourceFile); + return this._children.length; + }; + NodeObject.prototype.getChildAt = function (index, sourceFile) { + if (!this._children) + this.createChildren(sourceFile); + return this._children[index]; + }; + NodeObject.prototype.getChildren = function (sourceFile) { + if (!this._children) + this.createChildren(sourceFile); + return this._children; + }; + NodeObject.prototype.getFirstToken = function (sourceFile) { + var children = this.getChildren(sourceFile); + if (!children.length) { + return undefined; + } + var child = children[0]; + return child.kind < 135 ? child : child.getFirstToken(sourceFile); + }; + NodeObject.prototype.getLastToken = function (sourceFile) { + var children = this.getChildren(sourceFile); + var child = ts.lastOrUndefined(children); + if (!child) { + return undefined; + } + return child.kind < 135 ? child : child.getLastToken(sourceFile); + }; + return NodeObject; + })(); + var SymbolObject = (function () { + function SymbolObject(flags, name) { + this.flags = flags; + this.name = name; + } + SymbolObject.prototype.getFlags = function () { + return this.flags; + }; + SymbolObject.prototype.getName = function () { + return this.name; + }; + SymbolObject.prototype.getDeclarations = function () { + return this.declarations; + }; + SymbolObject.prototype.getDocumentationComment = function () { + if (this.documentationComment === undefined) { + this.documentationComment = getJsDocCommentsFromDeclarations(this.declarations, this.name, !(this.flags & 4)); + } + return this.documentationComment; + }; + return SymbolObject; + })(); + function getJsDocCommentsFromDeclarations(declarations, name, canUseParsedParamTagComments) { + var documentationComment = []; + var docComments = getJsDocCommentsSeparatedByNewLines(); + ts.forEach(docComments, function (docComment) { + if (documentationComment.length) { + documentationComment.push(ts.lineBreakPart()); + } + documentationComment.push(docComment); + }); + return documentationComment; + function getJsDocCommentsSeparatedByNewLines() { + var paramTag = "@param"; + var jsDocCommentParts = []; + ts.forEach(declarations, function (declaration, indexOfDeclaration) { + if (ts.indexOf(declarations, declaration) === indexOfDeclaration) { + var sourceFileOfDeclaration = ts.getSourceFileOfNode(declaration); + if (canUseParsedParamTagComments && declaration.kind === 138) { + ts.forEach(getJsDocCommentTextRange(declaration.parent, sourceFileOfDeclaration), function (jsDocCommentTextRange) { + var cleanedParamJsDocComment = getCleanedParamJsDocComment(jsDocCommentTextRange.pos, jsDocCommentTextRange.end, sourceFileOfDeclaration); + if (cleanedParamJsDocComment) { + ts.addRange(jsDocCommentParts, cleanedParamJsDocComment); + } + }); + } + if (declaration.kind === 218 && declaration.body.kind === 218) { + return; + } + while (declaration.kind === 218 && declaration.parent.kind === 218) { + declaration = declaration.parent; + } + ts.forEach(getJsDocCommentTextRange(declaration.kind === 211 ? declaration.parent.parent : declaration, sourceFileOfDeclaration), function (jsDocCommentTextRange) { + var cleanedJsDocComment = getCleanedJsDocComment(jsDocCommentTextRange.pos, jsDocCommentTextRange.end, sourceFileOfDeclaration); + if (cleanedJsDocComment) { + ts.addRange(jsDocCommentParts, cleanedJsDocComment); + } + }); + } + }); + return jsDocCommentParts; + function getJsDocCommentTextRange(node, sourceFile) { + return ts.map(ts.getJsDocComments(node, sourceFile), function (jsDocComment) { + return { + pos: jsDocComment.pos + "/*".length, + end: jsDocComment.end - "*/".length + }; + }); + } + function consumeWhiteSpacesOnTheLine(pos, end, sourceFile, maxSpacesToRemove) { + if (maxSpacesToRemove !== undefined) { + end = Math.min(end, pos + maxSpacesToRemove); + } + for (; pos < end; pos++) { + var ch = sourceFile.text.charCodeAt(pos); + if (!ts.isWhiteSpace(ch) || ts.isLineBreak(ch)) { + return pos; + } + } + return end; + } + function consumeLineBreaks(pos, end, sourceFile) { + while (pos < end && ts.isLineBreak(sourceFile.text.charCodeAt(pos))) { + pos++; + } + return pos; + } + function isName(pos, end, sourceFile, name) { + return pos + name.length < end && + sourceFile.text.substr(pos, name.length) === name && + (ts.isWhiteSpace(sourceFile.text.charCodeAt(pos + name.length)) || + ts.isLineBreak(sourceFile.text.charCodeAt(pos + name.length))); + } + function isParamTag(pos, end, sourceFile) { + return isName(pos, end, sourceFile, paramTag); + } + function pushDocCommentLineText(docComments, text, blankLineCount) { + while (blankLineCount--) { + docComments.push(ts.textPart("")); + } + docComments.push(ts.textPart(text)); + } + function getCleanedJsDocComment(pos, end, sourceFile) { + var spacesToRemoveAfterAsterisk; + var docComments = []; + var blankLineCount = 0; + var isInParamTag = false; + while (pos < end) { + var docCommentTextOfLine = ""; + pos = consumeWhiteSpacesOnTheLine(pos, end, sourceFile); + if (pos < end && sourceFile.text.charCodeAt(pos) === 42) { + var lineStartPos = pos + 1; + pos = consumeWhiteSpacesOnTheLine(pos + 1, end, sourceFile, spacesToRemoveAfterAsterisk); + if (spacesToRemoveAfterAsterisk === undefined && pos < end && !ts.isLineBreak(sourceFile.text.charCodeAt(pos))) { + spacesToRemoveAfterAsterisk = pos - lineStartPos; + } + } + else if (spacesToRemoveAfterAsterisk === undefined) { + spacesToRemoveAfterAsterisk = 0; + } + while (pos < end && !ts.isLineBreak(sourceFile.text.charCodeAt(pos))) { + var ch = sourceFile.text.charAt(pos); + if (ch === "@") { + if (isParamTag(pos, end, sourceFile)) { + isInParamTag = true; + pos += paramTag.length; + continue; + } + else { + isInParamTag = false; + } + } + if (!isInParamTag) { + docCommentTextOfLine += ch; + } + pos++; + } + pos = consumeLineBreaks(pos, end, sourceFile); + if (docCommentTextOfLine) { + pushDocCommentLineText(docComments, docCommentTextOfLine, blankLineCount); + blankLineCount = 0; + } + else if (!isInParamTag && docComments.length) { + blankLineCount++; + } + } + return docComments; + } + function getCleanedParamJsDocComment(pos, end, sourceFile) { + var paramHelpStringMargin; + var paramDocComments = []; + while (pos < end) { + if (isParamTag(pos, end, sourceFile)) { + var blankLineCount = 0; + var recordedParamTag = false; + pos = consumeWhiteSpaces(pos + paramTag.length); + if (pos >= end) { + break; + } + if (sourceFile.text.charCodeAt(pos) === 123) { + pos++; + for (var curlies = 1; pos < end; pos++) { + var charCode = sourceFile.text.charCodeAt(pos); + if (charCode === 123) { + curlies++; + continue; + } + if (charCode === 125) { + curlies--; + if (curlies === 0) { + pos++; + break; + } + else { + continue; + } + } + if (charCode === 64) { + break; + } + } + pos = consumeWhiteSpaces(pos); + if (pos >= end) { + break; + } + } + if (isName(pos, end, sourceFile, name)) { + pos = consumeWhiteSpaces(pos + name.length); + if (pos >= end) { + break; + } + var paramHelpString = ""; + var firstLineParamHelpStringPos = pos; + while (pos < end) { + var ch = sourceFile.text.charCodeAt(pos); + if (ts.isLineBreak(ch)) { + if (paramHelpString) { + pushDocCommentLineText(paramDocComments, paramHelpString, blankLineCount); + paramHelpString = ""; + blankLineCount = 0; + recordedParamTag = true; + } + else if (recordedParamTag) { + blankLineCount++; + } + setPosForParamHelpStringOnNextLine(firstLineParamHelpStringPos); + continue; + } + if (ch === 64) { + break; + } + paramHelpString += sourceFile.text.charAt(pos); + pos++; + } + if (paramHelpString) { + pushDocCommentLineText(paramDocComments, paramHelpString, blankLineCount); + } + paramHelpStringMargin = undefined; + } + if (sourceFile.text.charCodeAt(pos) === 64) { + continue; + } + } + pos++; + } + return paramDocComments; + function consumeWhiteSpaces(pos) { + while (pos < end && ts.isWhiteSpace(sourceFile.text.charCodeAt(pos))) { + pos++; + } + return pos; + } + function setPosForParamHelpStringOnNextLine(firstLineParamHelpStringPos) { + pos = consumeLineBreaks(pos, end, sourceFile); + if (pos >= end) { + return; + } + if (paramHelpStringMargin === undefined) { + paramHelpStringMargin = sourceFile.getLineAndCharacterOfPosition(firstLineParamHelpStringPos).character; + } + var startOfLinePos = pos; + pos = consumeWhiteSpacesOnTheLine(pos, end, sourceFile, paramHelpStringMargin); + if (pos >= end) { + return; + } + var consumedSpaces = pos - startOfLinePos; + if (consumedSpaces < paramHelpStringMargin) { + var ch = sourceFile.text.charCodeAt(pos); + if (ch === 42) { + pos = consumeWhiteSpacesOnTheLine(pos + 1, end, sourceFile, paramHelpStringMargin - consumedSpaces - 1); + } + } + } + } + } + } + var TypeObject = (function () { + function TypeObject(checker, flags) { + this.checker = checker; + this.flags = flags; + } + TypeObject.prototype.getFlags = function () { + return this.flags; + }; + TypeObject.prototype.getSymbol = function () { + return this.symbol; + }; + TypeObject.prototype.getProperties = function () { + return this.checker.getPropertiesOfType(this); + }; + TypeObject.prototype.getProperty = function (propertyName) { + return this.checker.getPropertyOfType(this, propertyName); + }; + TypeObject.prototype.getApparentProperties = function () { + return this.checker.getAugmentedPropertiesOfType(this); + }; + TypeObject.prototype.getCallSignatures = function () { + return this.checker.getSignaturesOfType(this, 0); + }; + TypeObject.prototype.getConstructSignatures = function () { + return this.checker.getSignaturesOfType(this, 1); + }; + TypeObject.prototype.getStringIndexType = function () { + return this.checker.getIndexTypeOfType(this, 0); + }; + TypeObject.prototype.getNumberIndexType = function () { + return this.checker.getIndexTypeOfType(this, 1); + }; + TypeObject.prototype.getBaseTypes = function () { + return this.flags & (1024 | 2048) + ? this.checker.getBaseTypes(this) + : undefined; + }; + return TypeObject; + })(); + var SignatureObject = (function () { + function SignatureObject(checker) { + this.checker = checker; + } + SignatureObject.prototype.getDeclaration = function () { + return this.declaration; + }; + SignatureObject.prototype.getTypeParameters = function () { + return this.typeParameters; + }; + SignatureObject.prototype.getParameters = function () { + return this.parameters; + }; + SignatureObject.prototype.getReturnType = function () { + return this.checker.getReturnTypeOfSignature(this); + }; + SignatureObject.prototype.getDocumentationComment = function () { + if (this.documentationComment === undefined) { + this.documentationComment = this.declaration ? getJsDocCommentsFromDeclarations([this.declaration], undefined, false) : []; + } + return this.documentationComment; + }; + return SignatureObject; + })(); + var SourceFileObject = (function (_super) { + __extends(SourceFileObject, _super); + function SourceFileObject() { + _super.apply(this, arguments); + } + SourceFileObject.prototype.update = function (newText, textChangeRange) { + return ts.updateSourceFile(this, newText, textChangeRange); + }; + SourceFileObject.prototype.getLineAndCharacterOfPosition = function (position) { + return ts.getLineAndCharacterOfPosition(this, position); + }; + SourceFileObject.prototype.getLineStarts = function () { + return ts.getLineStarts(this); + }; + SourceFileObject.prototype.getPositionOfLineAndCharacter = function (line, character) { + return ts.getPositionOfLineAndCharacter(this, line, character); + }; + SourceFileObject.prototype.getNamedDeclarations = function () { + if (!this.namedDeclarations) { + this.namedDeclarations = this.computeNamedDeclarations(); + } + return this.namedDeclarations; + }; + SourceFileObject.prototype.computeNamedDeclarations = function () { + var result = {}; + ts.forEachChild(this, visit); + return result; + function addDeclaration(declaration) { + var name = getDeclarationName(declaration); + if (name) { + var declarations = getDeclarations(name); + declarations.push(declaration); + } + } + function getDeclarations(name) { + return ts.getProperty(result, name) || (result[name] = []); + } + function getDeclarationName(declaration) { + if (declaration.name) { + var result_2 = getTextOfIdentifierOrLiteral(declaration.name); + if (result_2 !== undefined) { + return result_2; + } + if (declaration.name.kind === 136) { + var expr = declaration.name.expression; + if (expr.kind === 166) { + return expr.name.text; + } + return getTextOfIdentifierOrLiteral(expr); + } + } + return undefined; + } + function getTextOfIdentifierOrLiteral(node) { + if (node) { + if (node.kind === 69 || + node.kind === 9 || + node.kind === 8) { + return node.text; + } + } + return undefined; + } + function visit(node) { + switch (node.kind) { + case 213: + case 143: + case 142: + var functionDeclaration = node; + var declarationName = getDeclarationName(functionDeclaration); + if (declarationName) { + var declarations = getDeclarations(declarationName); + var lastDeclaration = ts.lastOrUndefined(declarations); + if (lastDeclaration && functionDeclaration.parent === lastDeclaration.parent && functionDeclaration.symbol === lastDeclaration.symbol) { + if (functionDeclaration.body && !lastDeclaration.body) { + declarations[declarations.length - 1] = functionDeclaration; + } + } + else { + declarations.push(functionDeclaration); + } + ts.forEachChild(node, visit); + } + break; + case 214: + case 215: + case 216: + case 217: + case 218: + case 221: + case 230: + case 226: + case 221: + case 223: + case 224: + case 145: + case 146: + case 155: + addDeclaration(node); + case 144: + case 193: + case 212: + case 161: + case 162: + case 219: + ts.forEachChild(node, visit); + break; + case 192: + if (ts.isFunctionBlock(node)) { + ts.forEachChild(node, visit); + } + break; + case 138: + if (!(node.flags & 112)) { + break; + } + case 211: + case 163: + if (ts.isBindingPattern(node.name)) { + ts.forEachChild(node.name, visit); + break; + } + case 247: + case 141: + case 140: + addDeclaration(node); + break; + case 228: + if (node.exportClause) { + ts.forEach(node.exportClause.elements, visit); + } + break; + case 222: + var importClause = node.importClause; + if (importClause) { + if (importClause.name) { + addDeclaration(importClause); + } + if (importClause.namedBindings) { + if (importClause.namedBindings.kind === 224) { + addDeclaration(importClause.namedBindings); + } + else { + ts.forEach(importClause.namedBindings.elements, visit); + } + } + } + break; + } + } + }; + return SourceFileObject; + })(NodeObject); + var TextChange = (function () { + function TextChange() { + } + return TextChange; + })(); + ts.TextChange = TextChange; + var HighlightSpanKind; + (function (HighlightSpanKind) { + HighlightSpanKind.none = "none"; + HighlightSpanKind.definition = "definition"; + HighlightSpanKind.reference = "reference"; + HighlightSpanKind.writtenReference = "writtenReference"; + })(HighlightSpanKind = ts.HighlightSpanKind || (ts.HighlightSpanKind = {})); + (function (IndentStyle) { + IndentStyle[IndentStyle["None"] = 0] = "None"; + IndentStyle[IndentStyle["Block"] = 1] = "Block"; + IndentStyle[IndentStyle["Smart"] = 2] = "Smart"; + })(ts.IndentStyle || (ts.IndentStyle = {})); + var IndentStyle = ts.IndentStyle; + (function (SymbolDisplayPartKind) { + SymbolDisplayPartKind[SymbolDisplayPartKind["aliasName"] = 0] = "aliasName"; + SymbolDisplayPartKind[SymbolDisplayPartKind["className"] = 1] = "className"; + SymbolDisplayPartKind[SymbolDisplayPartKind["enumName"] = 2] = "enumName"; + SymbolDisplayPartKind[SymbolDisplayPartKind["fieldName"] = 3] = "fieldName"; + SymbolDisplayPartKind[SymbolDisplayPartKind["interfaceName"] = 4] = "interfaceName"; + SymbolDisplayPartKind[SymbolDisplayPartKind["keyword"] = 5] = "keyword"; + SymbolDisplayPartKind[SymbolDisplayPartKind["lineBreak"] = 6] = "lineBreak"; + SymbolDisplayPartKind[SymbolDisplayPartKind["numericLiteral"] = 7] = "numericLiteral"; + SymbolDisplayPartKind[SymbolDisplayPartKind["stringLiteral"] = 8] = "stringLiteral"; + SymbolDisplayPartKind[SymbolDisplayPartKind["localName"] = 9] = "localName"; + SymbolDisplayPartKind[SymbolDisplayPartKind["methodName"] = 10] = "methodName"; + SymbolDisplayPartKind[SymbolDisplayPartKind["moduleName"] = 11] = "moduleName"; + SymbolDisplayPartKind[SymbolDisplayPartKind["operator"] = 12] = "operator"; + SymbolDisplayPartKind[SymbolDisplayPartKind["parameterName"] = 13] = "parameterName"; + SymbolDisplayPartKind[SymbolDisplayPartKind["propertyName"] = 14] = "propertyName"; + SymbolDisplayPartKind[SymbolDisplayPartKind["punctuation"] = 15] = "punctuation"; + SymbolDisplayPartKind[SymbolDisplayPartKind["space"] = 16] = "space"; + SymbolDisplayPartKind[SymbolDisplayPartKind["text"] = 17] = "text"; + SymbolDisplayPartKind[SymbolDisplayPartKind["typeParameterName"] = 18] = "typeParameterName"; + SymbolDisplayPartKind[SymbolDisplayPartKind["enumMemberName"] = 19] = "enumMemberName"; + SymbolDisplayPartKind[SymbolDisplayPartKind["functionName"] = 20] = "functionName"; + SymbolDisplayPartKind[SymbolDisplayPartKind["regularExpressionLiteral"] = 21] = "regularExpressionLiteral"; + })(ts.SymbolDisplayPartKind || (ts.SymbolDisplayPartKind = {})); + var SymbolDisplayPartKind = ts.SymbolDisplayPartKind; + (function (TokenClass) { + TokenClass[TokenClass["Punctuation"] = 0] = "Punctuation"; + TokenClass[TokenClass["Keyword"] = 1] = "Keyword"; + TokenClass[TokenClass["Operator"] = 2] = "Operator"; + TokenClass[TokenClass["Comment"] = 3] = "Comment"; + TokenClass[TokenClass["Whitespace"] = 4] = "Whitespace"; + TokenClass[TokenClass["Identifier"] = 5] = "Identifier"; + TokenClass[TokenClass["NumberLiteral"] = 6] = "NumberLiteral"; + TokenClass[TokenClass["StringLiteral"] = 7] = "StringLiteral"; + TokenClass[TokenClass["RegExpLiteral"] = 8] = "RegExpLiteral"; + })(ts.TokenClass || (ts.TokenClass = {})); + var TokenClass = ts.TokenClass; + var ScriptElementKind; + (function (ScriptElementKind) { + ScriptElementKind.unknown = ""; + ScriptElementKind.warning = "warning"; + ScriptElementKind.keyword = "keyword"; + ScriptElementKind.scriptElement = "script"; + ScriptElementKind.moduleElement = "module"; + ScriptElementKind.classElement = "class"; + ScriptElementKind.localClassElement = "local class"; + ScriptElementKind.interfaceElement = "interface"; + ScriptElementKind.typeElement = "type"; + ScriptElementKind.enumElement = "enum"; + ScriptElementKind.variableElement = "var"; + ScriptElementKind.localVariableElement = "local var"; + ScriptElementKind.functionElement = "function"; + ScriptElementKind.localFunctionElement = "local function"; + ScriptElementKind.memberFunctionElement = "method"; + ScriptElementKind.memberGetAccessorElement = "getter"; + ScriptElementKind.memberSetAccessorElement = "setter"; + ScriptElementKind.memberVariableElement = "property"; + ScriptElementKind.constructorImplementationElement = "constructor"; + ScriptElementKind.callSignatureElement = "call"; + ScriptElementKind.indexSignatureElement = "index"; + ScriptElementKind.constructSignatureElement = "construct"; + ScriptElementKind.parameterElement = "parameter"; + ScriptElementKind.typeParameterElement = "type parameter"; + ScriptElementKind.primitiveType = "primitive type"; + ScriptElementKind.label = "label"; + ScriptElementKind.alias = "alias"; + ScriptElementKind.constElement = "const"; + ScriptElementKind.letElement = "let"; + })(ScriptElementKind = ts.ScriptElementKind || (ts.ScriptElementKind = {})); + var ScriptElementKindModifier; + (function (ScriptElementKindModifier) { + ScriptElementKindModifier.none = ""; + ScriptElementKindModifier.publicMemberModifier = "public"; + ScriptElementKindModifier.privateMemberModifier = "private"; + ScriptElementKindModifier.protectedMemberModifier = "protected"; + ScriptElementKindModifier.exportedModifier = "export"; + ScriptElementKindModifier.ambientModifier = "declare"; + ScriptElementKindModifier.staticModifier = "static"; + ScriptElementKindModifier.abstractModifier = "abstract"; + })(ScriptElementKindModifier = ts.ScriptElementKindModifier || (ts.ScriptElementKindModifier = {})); + var ClassificationTypeNames = (function () { + function ClassificationTypeNames() { + } + ClassificationTypeNames.comment = "comment"; + ClassificationTypeNames.identifier = "identifier"; + ClassificationTypeNames.keyword = "keyword"; + ClassificationTypeNames.numericLiteral = "number"; + ClassificationTypeNames.operator = "operator"; + ClassificationTypeNames.stringLiteral = "string"; + ClassificationTypeNames.whiteSpace = "whitespace"; + ClassificationTypeNames.text = "text"; + ClassificationTypeNames.punctuation = "punctuation"; + ClassificationTypeNames.className = "class name"; + ClassificationTypeNames.enumName = "enum name"; + ClassificationTypeNames.interfaceName = "interface name"; + ClassificationTypeNames.moduleName = "module name"; + ClassificationTypeNames.typeParameterName = "type parameter name"; + ClassificationTypeNames.typeAliasName = "type alias name"; + ClassificationTypeNames.parameterName = "parameter name"; + ClassificationTypeNames.docCommentTagName = "doc comment tag name"; + return ClassificationTypeNames; + })(); + ts.ClassificationTypeNames = ClassificationTypeNames; + function displayPartsToString(displayParts) { + if (displayParts) { + return ts.map(displayParts, function (displayPart) { return displayPart.text; }).join(""); + } + return ""; + } + ts.displayPartsToString = displayPartsToString; + function isLocalVariableOrFunction(symbol) { + if (symbol.parent) { + return false; + } + return ts.forEach(symbol.declarations, function (declaration) { + if (declaration.kind === 173) { + return true; + } + if (declaration.kind !== 211 && declaration.kind !== 213) { + return false; + } + for (var parent_8 = declaration.parent; !ts.isFunctionBlock(parent_8); parent_8 = parent_8.parent) { + if (parent_8.kind === 248 || parent_8.kind === 219) { + return false; + } + } + return true; + }); + } + function getDefaultCompilerOptions() { + return { + target: 1, + module: 0, + jsx: 1 + }; + } + ts.getDefaultCompilerOptions = getDefaultCompilerOptions; + var HostCache = (function () { + function HostCache(host, getCanonicalFileName) { + this.host = host; + this.fileNameToEntry = ts.createFileMap(getCanonicalFileName); + var rootFileNames = host.getScriptFileNames(); + for (var _i = 0; _i < rootFileNames.length; _i++) { + var fileName = rootFileNames[_i]; + this.createEntry(fileName); + } + this._compilationSettings = host.getCompilationSettings() || getDefaultCompilerOptions(); + } + HostCache.prototype.compilationSettings = function () { + return this._compilationSettings; + }; + HostCache.prototype.createEntry = function (fileName) { + var entry; + var scriptSnapshot = this.host.getScriptSnapshot(fileName); + if (scriptSnapshot) { + entry = { + hostFileName: fileName, + version: this.host.getScriptVersion(fileName), + scriptSnapshot: scriptSnapshot + }; + } + this.fileNameToEntry.set(fileName, entry); + return entry; + }; + HostCache.prototype.getEntry = function (fileName) { + return this.fileNameToEntry.get(fileName); + }; + HostCache.prototype.contains = function (fileName) { + return this.fileNameToEntry.contains(fileName); + }; + HostCache.prototype.getOrCreateEntry = function (fileName) { + if (this.contains(fileName)) { + return this.getEntry(fileName); + } + return this.createEntry(fileName); + }; + HostCache.prototype.getRootFileNames = function () { + var fileNames = []; + this.fileNameToEntry.forEachValue(function (value) { + if (value) { + fileNames.push(value.hostFileName); + } + }); + return fileNames; + }; + HostCache.prototype.getVersion = function (fileName) { + var file = this.getEntry(fileName); + return file && file.version; + }; + HostCache.prototype.getScriptSnapshot = function (fileName) { + var file = this.getEntry(fileName); + return file && file.scriptSnapshot; + }; + return HostCache; + })(); + var SyntaxTreeCache = (function () { + function SyntaxTreeCache(host) { + this.host = host; + } + SyntaxTreeCache.prototype.getCurrentSourceFile = function (fileName) { + var scriptSnapshot = this.host.getScriptSnapshot(fileName); + if (!scriptSnapshot) { + throw new Error("Could not find file: '" + fileName + "'."); + } + var version = this.host.getScriptVersion(fileName); + var sourceFile; + if (this.currentFileName !== fileName) { + sourceFile = createLanguageServiceSourceFile(fileName, scriptSnapshot, 2, version, true); + } + else if (this.currentFileVersion !== version) { + var editRange = scriptSnapshot.getChangeRange(this.currentFileScriptSnapshot); + sourceFile = updateLanguageServiceSourceFile(this.currentSourceFile, scriptSnapshot, version, editRange); + } + if (sourceFile) { + this.currentFileVersion = version; + this.currentFileName = fileName; + this.currentFileScriptSnapshot = scriptSnapshot; + this.currentSourceFile = sourceFile; + } + return this.currentSourceFile; + }; + return SyntaxTreeCache; + })(); + function setSourceFileFields(sourceFile, scriptSnapshot, version) { + sourceFile.version = version; + sourceFile.scriptSnapshot = scriptSnapshot; + } + function transpileModule(input, transpileOptions) { + var options = transpileOptions.compilerOptions ? ts.clone(transpileOptions.compilerOptions) : getDefaultCompilerOptions(); + options.isolatedModules = true; + options.allowNonTsExtensions = true; + options.noLib = true; + options.noResolve = true; + var inputFileName = transpileOptions.fileName || (options.jsx ? "module.tsx" : "module.ts"); + var sourceFile = ts.createSourceFile(inputFileName, input, options.target); + if (transpileOptions.moduleName) { + sourceFile.moduleName = transpileOptions.moduleName; + } + sourceFile.renamedDependencies = transpileOptions.renamedDependencies; + var newLine = ts.getNewLineCharacter(options); + var outputText; + var sourceMapText; + var compilerHost = { + getSourceFile: function (fileName, target) { return fileName === ts.normalizeSlashes(inputFileName) ? sourceFile : undefined; }, + writeFile: function (name, text, writeByteOrderMark) { + if (ts.fileExtensionIs(name, ".map")) { + ts.Debug.assert(sourceMapText === undefined, "Unexpected multiple source map outputs for the file '" + name + "'"); + sourceMapText = text; + } + else { + ts.Debug.assert(outputText === undefined, "Unexpected multiple outputs for the file: " + name); + outputText = text; + } + }, + getDefaultLibFileName: function () { return "lib.d.ts"; }, + useCaseSensitiveFileNames: function () { return false; }, + getCanonicalFileName: function (fileName) { return fileName; }, + getCurrentDirectory: function () { return ""; }, + getNewLine: function () { return newLine; }, + fileExists: function (fileName) { return fileName === inputFileName; }, + readFile: function (fileName) { return ""; } + }; + var program = ts.createProgram([inputFileName], options, compilerHost); + var diagnostics; + if (transpileOptions.reportDiagnostics) { + diagnostics = []; + ts.addRange(diagnostics, program.getSyntacticDiagnostics(sourceFile)); + ts.addRange(diagnostics, program.getOptionsDiagnostics()); + } + program.emit(); + ts.Debug.assert(outputText !== undefined, "Output generation failed"); + return { outputText: outputText, diagnostics: diagnostics, sourceMapText: sourceMapText }; + } + ts.transpileModule = transpileModule; + function transpile(input, compilerOptions, fileName, diagnostics, moduleName) { + var output = transpileModule(input, { compilerOptions: compilerOptions, fileName: fileName, reportDiagnostics: !!diagnostics, moduleName: moduleName }); + ts.addRange(diagnostics, output.diagnostics); + return output.outputText; + } + ts.transpile = transpile; + function createLanguageServiceSourceFile(fileName, scriptSnapshot, scriptTarget, version, setNodeParents) { + var text = scriptSnapshot.getText(0, scriptSnapshot.getLength()); + var sourceFile = ts.createSourceFile(fileName, text, scriptTarget, setNodeParents); + setSourceFileFields(sourceFile, scriptSnapshot, version); + sourceFile.nameTable = sourceFile.identifiers; + return sourceFile; + } + ts.createLanguageServiceSourceFile = createLanguageServiceSourceFile; + ts.disableIncrementalParsing = false; + function updateLanguageServiceSourceFile(sourceFile, scriptSnapshot, version, textChangeRange, aggressiveChecks) { + if (textChangeRange) { + if (version !== sourceFile.version) { + if (!ts.disableIncrementalParsing) { + var newText; + var prefix = textChangeRange.span.start !== 0 + ? sourceFile.text.substr(0, textChangeRange.span.start) + : ""; + var suffix = ts.textSpanEnd(textChangeRange.span) !== sourceFile.text.length + ? sourceFile.text.substr(ts.textSpanEnd(textChangeRange.span)) + : ""; + if (textChangeRange.newLength === 0) { + newText = prefix && suffix ? prefix + suffix : prefix || suffix; + } + else { + var changedText = scriptSnapshot.getText(textChangeRange.span.start, textChangeRange.span.start + textChangeRange.newLength); + newText = prefix && suffix + ? prefix + changedText + suffix + : prefix + ? (prefix + changedText) + : (changedText + suffix); + } + var newSourceFile = ts.updateSourceFile(sourceFile, newText, textChangeRange, aggressiveChecks); + setSourceFileFields(newSourceFile, scriptSnapshot, version); + newSourceFile.nameTable = undefined; + if (sourceFile !== newSourceFile && sourceFile.scriptSnapshot) { + if (sourceFile.scriptSnapshot.dispose) { + sourceFile.scriptSnapshot.dispose(); + } + sourceFile.scriptSnapshot = undefined; + } + return newSourceFile; + } + } + } + return createLanguageServiceSourceFile(sourceFile.fileName, scriptSnapshot, sourceFile.languageVersion, version, true); + } + ts.updateLanguageServiceSourceFile = updateLanguageServiceSourceFile; + function createGetCanonicalFileName(useCaseSensitivefileNames) { + return useCaseSensitivefileNames + ? (function (fileName) { return fileName; }) + : (function (fileName) { return fileName.toLowerCase(); }); + } + ts.createGetCanonicalFileName = createGetCanonicalFileName; + function createDocumentRegistry(useCaseSensitiveFileNames) { + var buckets = {}; + var getCanonicalFileName = createGetCanonicalFileName(!!useCaseSensitiveFileNames); + function getKeyFromCompilationSettings(settings) { + return "_" + settings.target + "|" + settings.module + "|" + settings.noResolve + "|" + settings.jsx; + } + function getBucketForCompilationSettings(settings, createIfMissing) { + var key = getKeyFromCompilationSettings(settings); + var bucket = ts.lookUp(buckets, key); + if (!bucket && createIfMissing) { + buckets[key] = bucket = ts.createFileMap(getCanonicalFileName); + } + return bucket; + } + function reportStats() { + var bucketInfoArray = Object.keys(buckets).filter(function (name) { return name && name.charAt(0) === '_'; }).map(function (name) { + var entries = ts.lookUp(buckets, name); + var sourceFiles = []; + for (var i in entries) { + var entry = entries.get(i); + sourceFiles.push({ + name: i, + refCount: entry.languageServiceRefCount, + references: entry.owners.slice(0) + }); + } + sourceFiles.sort(function (x, y) { return y.refCount - x.refCount; }); + return { + bucket: name, + sourceFiles: sourceFiles + }; + }); + return JSON.stringify(bucketInfoArray, null, 2); + } + function acquireDocument(fileName, compilationSettings, scriptSnapshot, version) { + return acquireOrUpdateDocument(fileName, compilationSettings, scriptSnapshot, version, true); + } + function updateDocument(fileName, compilationSettings, scriptSnapshot, version) { + return acquireOrUpdateDocument(fileName, compilationSettings, scriptSnapshot, version, false); + } + function acquireOrUpdateDocument(fileName, compilationSettings, scriptSnapshot, version, acquiring) { + var bucket = getBucketForCompilationSettings(compilationSettings, true); + var entry = bucket.get(fileName); + if (!entry) { + ts.Debug.assert(acquiring, "How could we be trying to update a document that the registry doesn't have?"); + var sourceFile = createLanguageServiceSourceFile(fileName, scriptSnapshot, compilationSettings.target, version, false); + entry = { + sourceFile: sourceFile, + languageServiceRefCount: 0, + owners: [] + }; + bucket.set(fileName, entry); + } + else { + if (entry.sourceFile.version !== version) { + entry.sourceFile = updateLanguageServiceSourceFile(entry.sourceFile, scriptSnapshot, version, scriptSnapshot.getChangeRange(entry.sourceFile.scriptSnapshot)); + } + } + if (acquiring) { + entry.languageServiceRefCount++; + } + return entry.sourceFile; + } + function releaseDocument(fileName, compilationSettings) { + var bucket = getBucketForCompilationSettings(compilationSettings, false); + ts.Debug.assert(bucket !== undefined); + var entry = bucket.get(fileName); + entry.languageServiceRefCount--; + ts.Debug.assert(entry.languageServiceRefCount >= 0); + if (entry.languageServiceRefCount === 0) { + bucket.remove(fileName); + } + } + return { + acquireDocument: acquireDocument, + updateDocument: updateDocument, + releaseDocument: releaseDocument, + reportStats: reportStats + }; + } + ts.createDocumentRegistry = createDocumentRegistry; + function preProcessFile(sourceText, readImportFiles) { + if (readImportFiles === void 0) { readImportFiles = true; } + var referencedFiles = []; + var importedFiles = []; + var ambientExternalModules; + var isNoDefaultLib = false; + function processTripleSlashDirectives() { + var commentRanges = ts.getLeadingCommentRanges(sourceText, 0); + ts.forEach(commentRanges, function (commentRange) { + var comment = sourceText.substring(commentRange.pos, commentRange.end); + var referencePathMatchResult = ts.getFileReferenceFromReferencePath(comment, commentRange); + if (referencePathMatchResult) { + isNoDefaultLib = referencePathMatchResult.isNoDefaultLib; + var fileReference = referencePathMatchResult.fileReference; + if (fileReference) { + referencedFiles.push(fileReference); + } + } + }); + } + function recordAmbientExternalModule() { + if (!ambientExternalModules) { + ambientExternalModules = []; + } + ambientExternalModules.push(scanner.getTokenValue()); + } + function recordModuleName() { + var importPath = scanner.getTokenValue(); + var pos = scanner.getTokenPos(); + importedFiles.push({ + fileName: importPath, + pos: pos, + end: pos + importPath.length + }); + } + function processImport() { + scanner.setText(sourceText); + var token = scanner.scan(); + while (token !== 1) { + if (token === 122) { + token = scanner.scan(); + if (token === 125) { + token = scanner.scan(); + if (token === 9) { + recordAmbientExternalModule(); + continue; + } + } + } + else if (token === 89) { + token = scanner.scan(); + if (token === 9) { + recordModuleName(); + continue; + } + else { + if (token === 69 || ts.isKeyword(token)) { + token = scanner.scan(); + if (token === 133) { + token = scanner.scan(); + if (token === 9) { + recordModuleName(); + continue; + } + } + else if (token === 56) { + token = scanner.scan(); + if (token === 127) { + token = scanner.scan(); + if (token === 17) { + token = scanner.scan(); + if (token === 9) { + recordModuleName(); + continue; + } + } + } + } + else if (token === 24) { + token = scanner.scan(); + } + else { + continue; + } + } + if (token === 15) { + token = scanner.scan(); + while (token !== 16) { + token = scanner.scan(); + } + if (token === 16) { + token = scanner.scan(); + if (token === 133) { + token = scanner.scan(); + if (token === 9) { + recordModuleName(); + } + } + } + } + else if (token === 37) { + token = scanner.scan(); + if (token === 116) { + token = scanner.scan(); + if (token === 69 || ts.isKeyword(token)) { + token = scanner.scan(); + if (token === 133) { + token = scanner.scan(); + if (token === 9) { + recordModuleName(); + } + } + } + } + } + } + } + else if (token === 82) { + token = scanner.scan(); + if (token === 15) { + token = scanner.scan(); + while (token !== 16) { + token = scanner.scan(); + } + if (token === 16) { + token = scanner.scan(); + if (token === 133) { + token = scanner.scan(); + if (token === 9) { + recordModuleName(); + } + } + } + } + else if (token === 37) { + token = scanner.scan(); + if (token === 133) { + token = scanner.scan(); + if (token === 9) { + recordModuleName(); + } + } + } + else if (token === 89) { + token = scanner.scan(); + if (token === 69 || ts.isKeyword(token)) { + token = scanner.scan(); + if (token === 56) { + token = scanner.scan(); + if (token === 127) { + token = scanner.scan(); + if (token === 17) { + token = scanner.scan(); + if (token === 9) { + recordModuleName(); + } + } + } + } + } + } + } + token = scanner.scan(); + } + scanner.setText(undefined); + } + if (readImportFiles) { + processImport(); + } + processTripleSlashDirectives(); + return { referencedFiles: referencedFiles, importedFiles: importedFiles, isLibFile: isNoDefaultLib, ambientExternalModules: ambientExternalModules }; + } + ts.preProcessFile = preProcessFile; + function getTargetLabel(referenceNode, labelName) { + while (referenceNode) { + if (referenceNode.kind === 207 && referenceNode.label.text === labelName) { + return referenceNode.label; + } + referenceNode = referenceNode.parent; + } + return undefined; + } + function isJumpStatementTarget(node) { + return node.kind === 69 && + (node.parent.kind === 203 || node.parent.kind === 202) && + node.parent.label === node; + } + function isLabelOfLabeledStatement(node) { + return node.kind === 69 && + node.parent.kind === 207 && + node.parent.label === node; + } + function isLabeledBy(node, labelName) { + for (var owner = node.parent; owner.kind === 207; owner = owner.parent) { + if (owner.label.text === labelName) { + return true; + } + } + return false; + } + function isLabelName(node) { + return isLabelOfLabeledStatement(node) || isJumpStatementTarget(node); + } + function isRightSideOfQualifiedName(node) { + return node.parent.kind === 135 && node.parent.right === node; + } + function isRightSideOfPropertyAccess(node) { + return node && node.parent && node.parent.kind === 166 && node.parent.name === node; + } + function isCallExpressionTarget(node) { + if (isRightSideOfPropertyAccess(node)) { + node = node.parent; + } + return node && node.parent && node.parent.kind === 168 && node.parent.expression === node; + } + function isNewExpressionTarget(node) { + if (isRightSideOfPropertyAccess(node)) { + node = node.parent; + } + return node && node.parent && node.parent.kind === 169 && node.parent.expression === node; + } + function isNameOfModuleDeclaration(node) { + return node.parent.kind === 218 && node.parent.name === node; + } + function isNameOfFunctionDeclaration(node) { + return node.kind === 69 && + ts.isFunctionLike(node.parent) && node.parent.name === node; + } + function isNameOfPropertyAssignment(node) { + return (node.kind === 69 || node.kind === 9 || node.kind === 8) && + (node.parent.kind === 245 || node.parent.kind === 246) && node.parent.name === node; + } + function isLiteralNameOfPropertyDeclarationOrIndexAccess(node) { + if (node.kind === 9 || node.kind === 8) { + switch (node.parent.kind) { + case 141: + case 140: + case 245: + case 247: + case 143: + case 142: + case 145: + case 146: + case 218: + return node.parent.name === node; + case 167: + return node.parent.argumentExpression === node; + } + } + return false; + } + function isNameOfExternalModuleImportOrDeclaration(node) { + if (node.kind === 9) { + return isNameOfModuleDeclaration(node) || + (ts.isExternalModuleImportEqualsDeclaration(node.parent.parent) && ts.getExternalModuleImportEqualsDeclarationExpression(node.parent.parent) === node); + } + return false; + } + function isInsideComment(sourceFile, token, position) { + return position <= token.getStart(sourceFile) && + (isInsideCommentRange(ts.getTrailingCommentRanges(sourceFile.text, token.getFullStart())) || + isInsideCommentRange(ts.getLeadingCommentRanges(sourceFile.text, token.getFullStart()))); + function isInsideCommentRange(comments) { + return ts.forEach(comments, function (comment) { + if (comment.pos < position && position < comment.end) { + return true; + } + else if (position === comment.end) { + var text = sourceFile.text; + var width = comment.end - comment.pos; + if (width <= 2 || text.charCodeAt(comment.pos + 1) === 47) { + return true; + } + else { + return !(text.charCodeAt(comment.end - 1) === 47 && + text.charCodeAt(comment.end - 2) === 42); + } + } + return false; + }); + } + } + var keywordCompletions = []; + for (var i = 70; i <= 134; i++) { + keywordCompletions.push({ + name: ts.tokenToString(i), + kind: ScriptElementKind.keyword, + kindModifiers: ScriptElementKindModifier.none, + sortText: "0" + }); + } + function getContainerNode(node) { + while (true) { + node = node.parent; + if (!node) { + return undefined; + } + switch (node.kind) { + case 248: + case 143: + case 142: + case 213: + case 173: + case 145: + case 146: + case 214: + case 215: + case 217: + case 218: + return node; + } + } + } + ts.getContainerNode = getContainerNode; + function getNodeKind(node) { + switch (node.kind) { + case 218: return ScriptElementKind.moduleElement; + case 214: return ScriptElementKind.classElement; + case 215: return ScriptElementKind.interfaceElement; + case 216: return ScriptElementKind.typeElement; + case 217: return ScriptElementKind.enumElement; + case 211: + return ts.isConst(node) + ? ScriptElementKind.constElement + : ts.isLet(node) + ? ScriptElementKind.letElement + : ScriptElementKind.variableElement; + case 213: return ScriptElementKind.functionElement; + case 145: return ScriptElementKind.memberGetAccessorElement; + case 146: return ScriptElementKind.memberSetAccessorElement; + case 143: + case 142: + return ScriptElementKind.memberFunctionElement; + case 141: + case 140: + return ScriptElementKind.memberVariableElement; + case 149: return ScriptElementKind.indexSignatureElement; + case 148: return ScriptElementKind.constructSignatureElement; + case 147: return ScriptElementKind.callSignatureElement; + case 144: return ScriptElementKind.constructorImplementationElement; + case 137: return ScriptElementKind.typeParameterElement; + case 247: return ScriptElementKind.variableElement; + case 138: return (node.flags & 112) ? ScriptElementKind.memberVariableElement : ScriptElementKind.parameterElement; + case 221: + case 226: + case 223: + case 230: + case 224: + return ScriptElementKind.alias; + } + return ScriptElementKind.unknown; + } + ts.getNodeKind = getNodeKind; + var CancellationTokenObject = (function () { + function CancellationTokenObject(cancellationToken) { + this.cancellationToken = cancellationToken; + } + CancellationTokenObject.prototype.isCancellationRequested = function () { + return this.cancellationToken && this.cancellationToken.isCancellationRequested(); + }; + CancellationTokenObject.prototype.throwIfCancellationRequested = function () { + if (this.isCancellationRequested()) { + throw new ts.OperationCanceledException(); + } + }; + return CancellationTokenObject; + })(); + function createLanguageService(host, documentRegistry) { + if (documentRegistry === void 0) { documentRegistry = createDocumentRegistry(); } + var syntaxTreeCache = new SyntaxTreeCache(host); + var ruleProvider; + var program; + var lastProjectVersion; + var useCaseSensitivefileNames = false; + var cancellationToken = new CancellationTokenObject(host.getCancellationToken && host.getCancellationToken()); + if (!ts.localizedDiagnosticMessages && host.getLocalizedDiagnosticMessages) { + ts.localizedDiagnosticMessages = host.getLocalizedDiagnosticMessages(); + } + function log(message) { + if (host.log) { + host.log(message); + } + } + var getCanonicalFileName = createGetCanonicalFileName(useCaseSensitivefileNames); + function getValidSourceFile(fileName) { + fileName = ts.normalizeSlashes(fileName); + var sourceFile = program.getSourceFile(getCanonicalFileName(fileName)); + if (!sourceFile) { + throw new Error("Could not find file: '" + fileName + "'."); + } + return sourceFile; + } + function getRuleProvider(options) { + if (!ruleProvider) { + ruleProvider = new ts.formatting.RulesProvider(); + } + ruleProvider.ensureUpToDate(options); + return ruleProvider; + } + function synchronizeHostData() { + if (host.getProjectVersion) { + var hostProjectVersion = host.getProjectVersion(); + if (hostProjectVersion) { + if (lastProjectVersion === hostProjectVersion) { + return; + } + lastProjectVersion = hostProjectVersion; + } + } + var hostCache = new HostCache(host, getCanonicalFileName); + if (programUpToDate()) { + return; + } + var oldSettings = program && program.getCompilerOptions(); + var newSettings = hostCache.compilationSettings(); + var changesInCompilationSettingsAffectSyntax = oldSettings && + (oldSettings.target !== newSettings.target || + oldSettings.module !== newSettings.module || + oldSettings.noResolve !== newSettings.noResolve || + oldSettings.jsx !== newSettings.jsx); + var compilerHost = { + getSourceFile: getOrCreateSourceFile, + getCancellationToken: function () { return cancellationToken; }, + getCanonicalFileName: getCanonicalFileName, + useCaseSensitiveFileNames: function () { return useCaseSensitivefileNames; }, + getNewLine: function () { return ts.getNewLineOrDefaultFromHost(host); }, + getDefaultLibFileName: function (options) { return host.getDefaultLibFileName(options); }, + writeFile: function (fileName, data, writeByteOrderMark) { }, + getCurrentDirectory: function () { return host.getCurrentDirectory(); }, + fileExists: function (fileName) { + ts.Debug.assert(!host.resolveModuleNames); + return hostCache.getOrCreateEntry(fileName) !== undefined; + }, + readFile: function (fileName) { + var entry = hostCache.getOrCreateEntry(fileName); + return entry && entry.scriptSnapshot.getText(0, entry.scriptSnapshot.getLength()); + } + }; + if (host.resolveModuleNames) { + compilerHost.resolveModuleNames = function (moduleNames, containingFile) { return host.resolveModuleNames(moduleNames, containingFile); }; + } + var newProgram = ts.createProgram(hostCache.getRootFileNames(), newSettings, compilerHost, program); + if (program) { + var oldSourceFiles = program.getSourceFiles(); + for (var _i = 0; _i < oldSourceFiles.length; _i++) { + var oldSourceFile = oldSourceFiles[_i]; + var fileName = oldSourceFile.fileName; + if (!newProgram.getSourceFile(fileName) || changesInCompilationSettingsAffectSyntax) { + documentRegistry.releaseDocument(fileName, oldSettings); + } + } + } + hostCache = undefined; + program = newProgram; + program.getTypeChecker(); + return; + function getOrCreateSourceFile(fileName) { + ts.Debug.assert(hostCache !== undefined); + var hostFileInformation = hostCache.getOrCreateEntry(fileName); + if (!hostFileInformation) { + return undefined; + } + if (!changesInCompilationSettingsAffectSyntax) { + var oldSourceFile = program && program.getSourceFile(fileName); + if (oldSourceFile) { + return documentRegistry.updateDocument(fileName, newSettings, hostFileInformation.scriptSnapshot, hostFileInformation.version); + } + } + return documentRegistry.acquireDocument(fileName, newSettings, hostFileInformation.scriptSnapshot, hostFileInformation.version); + } + function sourceFileUpToDate(sourceFile) { + return sourceFile && sourceFile.version === hostCache.getVersion(sourceFile.fileName); + } + function programUpToDate() { + if (!program) { + return false; + } + var rootFileNames = hostCache.getRootFileNames(); + if (program.getSourceFiles().length !== rootFileNames.length) { + return false; + } + for (var _i = 0; _i < rootFileNames.length; _i++) { + var fileName = rootFileNames[_i]; + if (!sourceFileUpToDate(program.getSourceFile(fileName))) { + return false; + } + } + return ts.compareDataObjects(program.getCompilerOptions(), hostCache.compilationSettings()); + } + } + function getProgram() { + synchronizeHostData(); + return program; + } + function cleanupSemanticCache() { + } + function dispose() { + if (program) { + ts.forEach(program.getSourceFiles(), function (f) { + return documentRegistry.releaseDocument(f.fileName, program.getCompilerOptions()); + }); + } + } + function getSyntacticDiagnostics(fileName) { + synchronizeHostData(); + return program.getSyntacticDiagnostics(getValidSourceFile(fileName), cancellationToken); + } + function getSemanticDiagnostics(fileName) { + synchronizeHostData(); + var targetSourceFile = getValidSourceFile(fileName); + if (ts.isJavaScript(fileName)) { + return getJavaScriptSemanticDiagnostics(targetSourceFile); + } + var semanticDiagnostics = program.getSemanticDiagnostics(targetSourceFile, cancellationToken); + if (!program.getCompilerOptions().declaration) { + return semanticDiagnostics; + } + var declarationDiagnostics = program.getDeclarationDiagnostics(targetSourceFile, cancellationToken); + return ts.concatenate(semanticDiagnostics, declarationDiagnostics); + } + function getJavaScriptSemanticDiagnostics(sourceFile) { + var diagnostics = []; + walk(sourceFile); + return diagnostics; + function walk(node) { + if (!node) { + return false; + } + switch (node.kind) { + case 221: + diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.import_can_only_be_used_in_a_ts_file)); + return true; + case 227: + diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.export_can_only_be_used_in_a_ts_file)); + return true; + case 214: + var classDeclaration = node; + if (checkModifiers(classDeclaration.modifiers) || + checkTypeParameters(classDeclaration.typeParameters)) { + return true; + } + break; + case 243: + var heritageClause = node; + if (heritageClause.token === 106) { + diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.implements_clauses_can_only_be_used_in_a_ts_file)); + return true; + } + break; + case 215: + diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.interface_declarations_can_only_be_used_in_a_ts_file)); + return true; + case 218: + diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.module_declarations_can_only_be_used_in_a_ts_file)); + return true; + case 216: + diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.type_aliases_can_only_be_used_in_a_ts_file)); + return true; + case 143: + case 142: + case 144: + case 145: + case 146: + case 173: + case 213: + case 174: + case 213: + var functionDeclaration = node; + if (checkModifiers(functionDeclaration.modifiers) || + checkTypeParameters(functionDeclaration.typeParameters) || + checkTypeAnnotation(functionDeclaration.type)) { + return true; + } + break; + case 193: + var variableStatement = node; + if (checkModifiers(variableStatement.modifiers)) { + return true; + } + break; + case 211: + var variableDeclaration = node; + if (checkTypeAnnotation(variableDeclaration.type)) { + return true; + } + break; + case 168: + case 169: + var expression = node; + if (expression.typeArguments && expression.typeArguments.length > 0) { + var start = expression.typeArguments.pos; + diagnostics.push(ts.createFileDiagnostic(sourceFile, start, expression.typeArguments.end - start, ts.Diagnostics.type_arguments_can_only_be_used_in_a_ts_file)); + return true; + } + break; + case 138: + var parameter = node; + if (parameter.modifiers) { + var start = parameter.modifiers.pos; + diagnostics.push(ts.createFileDiagnostic(sourceFile, start, parameter.modifiers.end - start, ts.Diagnostics.parameter_modifiers_can_only_be_used_in_a_ts_file)); + return true; + } + if (parameter.questionToken) { + diagnostics.push(ts.createDiagnosticForNode(parameter.questionToken, ts.Diagnostics._0_can_only_be_used_in_a_ts_file, '?')); + return true; + } + if (parameter.type) { + diagnostics.push(ts.createDiagnosticForNode(parameter.type, ts.Diagnostics.types_can_only_be_used_in_a_ts_file)); + return true; + } + break; + case 141: + diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.property_declarations_can_only_be_used_in_a_ts_file)); + return true; + case 217: + diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.enum_declarations_can_only_be_used_in_a_ts_file)); + return true; + case 171: + var typeAssertionExpression = node; + diagnostics.push(ts.createDiagnosticForNode(typeAssertionExpression.type, ts.Diagnostics.type_assertion_expressions_can_only_be_used_in_a_ts_file)); + return true; + case 139: + diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.decorators_can_only_be_used_in_a_ts_file)); + return true; + } + return ts.forEachChild(node, walk); + } + function checkTypeParameters(typeParameters) { + if (typeParameters) { + var start = typeParameters.pos; + diagnostics.push(ts.createFileDiagnostic(sourceFile, start, typeParameters.end - start, ts.Diagnostics.type_parameter_declarations_can_only_be_used_in_a_ts_file)); + return true; + } + return false; + } + function checkTypeAnnotation(type) { + if (type) { + diagnostics.push(ts.createDiagnosticForNode(type, ts.Diagnostics.types_can_only_be_used_in_a_ts_file)); + return true; + } + return false; + } + function checkModifiers(modifiers) { + if (modifiers) { + for (var _i = 0; _i < modifiers.length; _i++) { + var modifier = modifiers[_i]; + switch (modifier.kind) { + case 112: + case 110: + case 111: + case 122: + diagnostics.push(ts.createDiagnosticForNode(modifier, ts.Diagnostics._0_can_only_be_used_in_a_ts_file, ts.tokenToString(modifier.kind))); + return true; + case 113: + case 82: + case 74: + case 77: + case 115: + } + } + } + return false; + } + } + function getCompilerOptionsDiagnostics() { + synchronizeHostData(); + return program.getOptionsDiagnostics(cancellationToken).concat(program.getGlobalDiagnostics(cancellationToken)); + } + function getCompletionEntryDisplayNameForSymbol(symbol, target, performCharacterChecks, location) { + var displayName = ts.getDeclaredName(program.getTypeChecker(), symbol, location); + if (displayName) { + var firstCharCode = displayName.charCodeAt(0); + if ((symbol.flags & 1536) && (firstCharCode === 39 || firstCharCode === 34)) { + return undefined; + } + } + return getCompletionEntryDisplayName(displayName, target, performCharacterChecks); + } + function getCompletionEntryDisplayName(name, target, performCharacterChecks) { + if (!name) { + return undefined; + } + name = ts.stripQuotes(name); + if (!name) { + return undefined; + } + if (performCharacterChecks) { + if (!ts.isIdentifierStart(name.charCodeAt(0), target)) { + return undefined; + } + for (var i = 1, n = name.length; i < n; i++) { + if (!ts.isIdentifierPart(name.charCodeAt(i), target)) { + return undefined; + } + } + } + return name; + } + function getCompletionData(fileName, position) { + var typeChecker = program.getTypeChecker(); + var syntacticStart = new Date().getTime(); + var sourceFile = getValidSourceFile(fileName); + var isJavaScriptFile = ts.isJavaScript(fileName); + var isJsDocTagName = false; + var start = new Date().getTime(); + var currentToken = ts.getTokenAtPosition(sourceFile, position); + log("getCompletionData: Get current token: " + (new Date().getTime() - start)); + start = new Date().getTime(); + var insideComment = isInsideComment(sourceFile, currentToken, position); + log("getCompletionData: Is inside comment: " + (new Date().getTime() - start)); + if (insideComment) { + if (ts.hasDocComment(sourceFile, position) && sourceFile.text.charCodeAt(position - 1) === 64) { + isJsDocTagName = true; + } + var insideJsDocTagExpression = false; + var tag = ts.getJsDocTagAtPosition(sourceFile, position); + if (tag) { + if (tag.tagName.pos <= position && position <= tag.tagName.end) { + isJsDocTagName = true; + } + switch (tag.kind) { + case 269: + case 267: + case 268: + var tagWithExpression = tag; + if (tagWithExpression.typeExpression) { + insideJsDocTagExpression = tagWithExpression.typeExpression.pos < position && position < tagWithExpression.typeExpression.end; + } + break; + } + } + if (isJsDocTagName) { + return { symbols: undefined, 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."); + return undefined; + } + } + start = new Date().getTime(); + var previousToken = ts.findPrecedingToken(position, sourceFile); + log("getCompletionData: Get previous token 1: " + (new Date().getTime() - start)); + var contextToken = previousToken; + if (contextToken && position <= contextToken.end && ts.isWord(contextToken.kind)) { + var start_3 = new Date().getTime(); + contextToken = ts.findPrecedingToken(contextToken.getFullStart(), sourceFile); + log("getCompletionData: Get previous token 2: " + (new Date().getTime() - start_3)); + } + var node = currentToken; + var isRightOfDot = false; + var isRightOfOpenTag = false; + var isStartingCloseTag = false; + var location = ts.getTouchingPropertyName(sourceFile, position); + if (contextToken) { + if (isCompletionListBlocker(contextToken)) { + log("Returning an empty list because completion was requested in an invalid position."); + return undefined; + } + var parent_9 = contextToken.parent, kind = contextToken.kind; + if (kind === 21) { + if (parent_9.kind === 166) { + node = contextToken.parent.expression; + isRightOfDot = true; + } + else if (parent_9.kind === 135) { + node = contextToken.parent.left; + isRightOfDot = true; + } + else { + return undefined; + } + } + else if (sourceFile.languageVariant === 1) { + if (kind === 25) { + isRightOfOpenTag = true; + location = contextToken; + } + else if (kind === 39 && contextToken.parent.kind === 237) { + isStartingCloseTag = true; + } + } + } + var semanticStart = new Date().getTime(); + var isMemberCompletion; + var isNewIdentifierLocation; + var symbols = []; + if (isRightOfDot) { + getTypeScriptMemberSymbols(); + } + else if (isRightOfOpenTag) { + var tagSymbols = typeChecker.getJsxIntrinsicTagNames(); + if (tryGetGlobalSymbols()) { + symbols = tagSymbols.concat(symbols.filter(function (s) { return !!(s.flags & 107455); })); + } + else { + symbols = tagSymbols; + } + isMemberCompletion = true; + isNewIdentifierLocation = false; + } + else if (isStartingCloseTag) { + var tagName = contextToken.parent.parent.openingElement.tagName; + symbols = [typeChecker.getSymbolAtLocation(tagName)]; + isMemberCompletion = true; + isNewIdentifierLocation = false; + } + else { + if (!tryGetGlobalSymbols()) { + return undefined; + } + } + log("getCompletionData: Semantic work: " + (new Date().getTime() - semanticStart)); + return { symbols: symbols, isMemberCompletion: isMemberCompletion, isNewIdentifierLocation: isNewIdentifierLocation, location: location, isRightOfDot: (isRightOfDot || isRightOfOpenTag), isJsDocTagName: isJsDocTagName }; + function getTypeScriptMemberSymbols() { + isMemberCompletion = true; + isNewIdentifierLocation = false; + if (node.kind === 69 || node.kind === 135 || node.kind === 166) { + var symbol = typeChecker.getSymbolAtLocation(node); + if (symbol && symbol.flags & 8388608) { + symbol = typeChecker.getAliasedSymbol(symbol); + } + if (symbol && symbol.flags & 1952) { + var exportedSymbols = typeChecker.getExportsOfModule(symbol); + ts.forEach(exportedSymbols, function (symbol) { + if (typeChecker.isValidPropertyAccess((node.parent), symbol.name)) { + symbols.push(symbol); + } + }); + } + } + var type = typeChecker.getTypeAtLocation(node); + addTypeProperties(type); + } + function addTypeProperties(type) { + if (type) { + for (var _i = 0, _a = type.getApparentProperties(); _i < _a.length; _i++) { + var symbol = _a[_i]; + if (typeChecker.isValidPropertyAccess((node.parent), symbol.name)) { + symbols.push(symbol); + } + } + if (isJavaScriptFile && type.flags & 16384) { + var unionType = type; + for (var _b = 0, _c = unionType.types; _b < _c.length; _b++) { + var elementType = _c[_b]; + addTypeProperties(elementType); + } + } + } + } + function tryGetGlobalSymbols() { + var objectLikeContainer; + var namedImportsOrExports; + var jsxContainer; + if (objectLikeContainer = tryGetObjectLikeCompletionContainer(contextToken)) { + return tryGetObjectLikeCompletionSymbols(objectLikeContainer); + } + if (namedImportsOrExports = tryGetNamedImportsOrExportsForCompletion(contextToken)) { + return tryGetImportOrExportClauseCompletionSymbols(namedImportsOrExports); + } + if (jsxContainer = tryGetContainingJsxElement(contextToken)) { + var attrsType; + if ((jsxContainer.kind === 234) || (jsxContainer.kind === 235)) { + attrsType = typeChecker.getJsxElementAttributesType(jsxContainer); + if (attrsType) { + symbols = filterJsxAttributes(typeChecker.getPropertiesOfType(attrsType), jsxContainer.attributes); + isMemberCompletion = true; + isNewIdentifierLocation = false; + return true; + } + } + } + isMemberCompletion = false; + isNewIdentifierLocation = isNewIdentifierDefinitionLocation(contextToken); + if (previousToken !== contextToken) { + ts.Debug.assert(!!previousToken, "Expected 'contextToken' to be defined when different from 'previousToken'."); + } + var adjustedPosition = previousToken !== contextToken ? + previousToken.getStart() : + position; + var scopeNode = getScopeNode(contextToken, adjustedPosition, sourceFile) || sourceFile; + var symbolMeanings = 793056 | 107455 | 1536 | 8388608; + symbols = typeChecker.getSymbolsInScope(scopeNode, symbolMeanings); + return true; + } + function getScopeNode(initialToken, position, sourceFile) { + var scope = initialToken; + while (scope && !ts.positionBelongsToNode(scope, position, sourceFile)) { + scope = scope.parent; + } + return scope; + } + function isCompletionListBlocker(contextToken) { + var start = new Date().getTime(); + var result = isInStringOrRegularExpressionOrTemplateLiteral(contextToken) || + isSolelyIdentifierDefinitionLocation(contextToken) || + isDotOfNumericLiteral(contextToken) || + isInJsxText(contextToken); + log("getCompletionsAtPosition: isCompletionListBlocker: " + (new Date().getTime() - start)); + return result; + } + function isInJsxText(contextToken) { + if (contextToken.kind === 236) { + return true; + } + if (contextToken.kind === 27 && contextToken.parent) { + if (contextToken.parent.kind === 235) { + return true; + } + if (contextToken.parent.kind === 237 || contextToken.parent.kind === 234) { + return contextToken.parent.parent && contextToken.parent.parent.kind === 233; + } + } + return false; + } + function isNewIdentifierDefinitionLocation(previousToken) { + if (previousToken) { + var containingNodeKind = previousToken.parent.kind; + switch (previousToken.kind) { + case 24: + return containingNodeKind === 168 + || containingNodeKind === 144 + || containingNodeKind === 169 + || containingNodeKind === 164 + || containingNodeKind === 181 + || containingNodeKind === 152; + case 17: + return containingNodeKind === 168 + || containingNodeKind === 144 + || containingNodeKind === 169 + || containingNodeKind === 172 + || containingNodeKind === 160; + case 19: + return containingNodeKind === 164 + || containingNodeKind === 149 + || containingNodeKind === 136; + case 125: + case 126: + return true; + case 21: + return containingNodeKind === 218; + case 15: + return containingNodeKind === 214; + case 56: + return containingNodeKind === 211 + || containingNodeKind === 181; + case 12: + return containingNodeKind === 183; + case 13: + return containingNodeKind === 190; + case 112: + case 110: + case 111: + return containingNodeKind === 141; + } + switch (previousToken.getText()) { + case "public": + case "protected": + case "private": + return true; + } + } + return false; + } + function isInStringOrRegularExpressionOrTemplateLiteral(contextToken) { + if (contextToken.kind === 9 + || contextToken.kind === 10 + || ts.isTemplateLiteralKind(contextToken.kind)) { + var start_4 = contextToken.getStart(); + var end = contextToken.getEnd(); + if (start_4 < position && position < end) { + return true; + } + if (position === end) { + return !!contextToken.isUnterminated + || contextToken.kind === 10; + } + } + return false; + } + function tryGetObjectLikeCompletionSymbols(objectLikeContainer) { + isMemberCompletion = true; + var typeForObject; + var existingMembers; + if (objectLikeContainer.kind === 165) { + isNewIdentifierLocation = true; + typeForObject = typeChecker.getContextualType(objectLikeContainer); + existingMembers = objectLikeContainer.properties; + } + else if (objectLikeContainer.kind === 161) { + isNewIdentifierLocation = false; + var rootDeclaration = ts.getRootDeclaration(objectLikeContainer.parent); + if (ts.isVariableLike(rootDeclaration)) { + if (rootDeclaration.initializer || rootDeclaration.type) { + typeForObject = typeChecker.getTypeAtLocation(objectLikeContainer); + existingMembers = objectLikeContainer.elements; + } + } + else { + ts.Debug.fail("Root declaration is not variable-like."); + } + } + else { + ts.Debug.fail("Expected object literal or binding pattern, got " + objectLikeContainer.kind); + } + if (!typeForObject) { + return false; + } + var typeMembers = typeChecker.getPropertiesOfType(typeForObject); + if (typeMembers && typeMembers.length > 0) { + symbols = filterObjectMembersList(typeMembers, existingMembers); + } + return true; + } + function tryGetImportOrExportClauseCompletionSymbols(namedImportsOrExports) { + var declarationKind = namedImportsOrExports.kind === 225 ? + 222 : + 228; + var importOrExportDeclaration = ts.getAncestor(namedImportsOrExports, declarationKind); + var moduleSpecifier = importOrExportDeclaration.moduleSpecifier; + if (!moduleSpecifier) { + return false; + } + isMemberCompletion = true; + isNewIdentifierLocation = false; + var exports; + var moduleSpecifierSymbol = typeChecker.getSymbolAtLocation(importOrExportDeclaration.moduleSpecifier); + if (moduleSpecifierSymbol) { + exports = typeChecker.getExportsOfModule(moduleSpecifierSymbol); + } + symbols = exports ? filterNamedImportOrExportCompletionItems(exports, namedImportsOrExports.elements) : emptyArray; + return true; + } + function tryGetObjectLikeCompletionContainer(contextToken) { + if (contextToken) { + switch (contextToken.kind) { + case 15: + case 24: + var parent_10 = contextToken.parent; + if (parent_10 && (parent_10.kind === 165 || parent_10.kind === 161)) { + return parent_10; + } + break; + } + } + return undefined; + } + function tryGetNamedImportsOrExportsForCompletion(contextToken) { + if (contextToken) { + switch (contextToken.kind) { + case 15: + case 24: + switch (contextToken.parent.kind) { + case 225: + case 229: + return contextToken.parent; + } + } + } + return undefined; + } + function tryGetContainingJsxElement(contextToken) { + if (contextToken) { + var parent_11 = contextToken.parent; + switch (contextToken.kind) { + case 26: + case 39: + case 69: + case 238: + case 239: + if (parent_11 && (parent_11.kind === 234 || parent_11.kind === 235)) { + return parent_11; + } + else if (parent_11.kind === 238) { + return parent_11.parent; + } + break; + case 9: + if (parent_11 && ((parent_11.kind === 238) || (parent_11.kind === 239))) { + return parent_11.parent; + } + break; + case 16: + if (parent_11 && + parent_11.kind === 240 && + parent_11.parent && + (parent_11.parent.kind === 238)) { + return parent_11.parent.parent; + } + if (parent_11 && parent_11.kind === 239) { + return parent_11.parent; + } + break; + } + } + return undefined; + } + function isFunction(kind) { + switch (kind) { + case 173: + case 174: + case 213: + case 143: + case 142: + case 145: + case 146: + case 147: + case 148: + case 149: + return true; + } + return false; + } + function isSolelyIdentifierDefinitionLocation(contextToken) { + var containingNodeKind = contextToken.parent.kind; + switch (contextToken.kind) { + case 24: + return containingNodeKind === 211 || + containingNodeKind === 212 || + containingNodeKind === 193 || + containingNodeKind === 217 || + isFunction(containingNodeKind) || + containingNodeKind === 214 || + containingNodeKind === 186 || + containingNodeKind === 215 || + containingNodeKind === 162 || + containingNodeKind === 216; + case 21: + return containingNodeKind === 162; + case 54: + return containingNodeKind === 163; + case 19: + return containingNodeKind === 162; + case 17: + return containingNodeKind === 244 || + isFunction(containingNodeKind); + case 15: + return containingNodeKind === 217 || + containingNodeKind === 215 || + containingNodeKind === 155; + case 23: + return containingNodeKind === 140 && + contextToken.parent && contextToken.parent.parent && + (contextToken.parent.parent.kind === 215 || + contextToken.parent.parent.kind === 155); + case 25: + return containingNodeKind === 214 || + containingNodeKind === 186 || + containingNodeKind === 215 || + containingNodeKind === 216 || + isFunction(containingNodeKind); + case 113: + return containingNodeKind === 141; + case 22: + return containingNodeKind === 138 || + (contextToken.parent && contextToken.parent.parent && + contextToken.parent.parent.kind === 162); + case 112: + case 110: + case 111: + return containingNodeKind === 138; + case 116: + return containingNodeKind === 226 || + containingNodeKind === 230 || + containingNodeKind === 224; + case 73: + case 81: + case 107: + case 87: + case 102: + case 123: + case 129: + case 89: + case 108: + case 74: + case 114: + case 132: + return true; + } + switch (contextToken.getText()) { + case "abstract": + case "async": + case "class": + case "const": + case "declare": + case "enum": + case "function": + case "interface": + case "let": + case "private": + case "protected": + case "public": + case "static": + case "var": + case "yield": + return true; + } + return false; + } + function isDotOfNumericLiteral(contextToken) { + if (contextToken.kind === 8) { + var text = contextToken.getFullText(); + return text.charAt(text.length - 1) === "."; + } + return false; + } + function filterNamedImportOrExportCompletionItems(exportsOfModule, namedImportsOrExports) { + var exisingImportsOrExports = {}; + for (var _i = 0; _i < namedImportsOrExports.length; _i++) { + var element = namedImportsOrExports[_i]; + if (element.getStart() <= position && position <= element.getEnd()) { + continue; + } + var name_33 = element.propertyName || element.name; + exisingImportsOrExports[name_33.text] = true; + } + if (ts.isEmpty(exisingImportsOrExports)) { + return exportsOfModule; + } + return ts.filter(exportsOfModule, function (e) { return !ts.lookUp(exisingImportsOrExports, e.name); }); + } + function filterObjectMembersList(contextualMemberSymbols, existingMembers) { + if (!existingMembers || existingMembers.length === 0) { + return contextualMemberSymbols; + } + var existingMemberNames = {}; + for (var _i = 0; _i < existingMembers.length; _i++) { + var m = existingMembers[_i]; + if (m.kind !== 245 && + m.kind !== 246 && + m.kind !== 163) { + continue; + } + if (m.getStart() <= position && position <= m.getEnd()) { + continue; + } + var existingName = void 0; + if (m.kind === 163 && m.propertyName) { + existingName = m.propertyName.text; + } + else { + existingName = m.name.text; + } + existingMemberNames[existingName] = true; + } + return ts.filter(contextualMemberSymbols, function (m) { return !ts.lookUp(existingMemberNames, m.name); }); + } + function filterJsxAttributes(symbols, attributes) { + var seenNames = {}; + for (var _i = 0; _i < attributes.length; _i++) { + var attr = attributes[_i]; + if (attr.getStart() <= position && position <= attr.getEnd()) { + continue; + } + if (attr.kind === 238) { + seenNames[attr.name.text] = true; + } + } + return ts.filter(symbols, function (a) { return !ts.lookUp(seenNames, a.name); }); + } + } + function getCompletionsAtPosition(fileName, position) { + synchronizeHostData(); + var completionData = getCompletionData(fileName, position); + if (!completionData) { + return undefined; + } + var symbols = completionData.symbols, isMemberCompletion = completionData.isMemberCompletion, isNewIdentifierLocation = completionData.isNewIdentifierLocation, location = completionData.location, isRightOfDot = completionData.isRightOfDot, isJsDocTagName = completionData.isJsDocTagName; + var entries; + if (isJsDocTagName) { + return { isMemberCompletion: false, isNewIdentifierLocation: false, entries: getAllJsDocCompletionEntries() }; + } + if (isRightOfDot && ts.isJavaScript(fileName)) { + entries = getCompletionEntriesFromSymbols(symbols); + ts.addRange(entries, getJavaScriptCompletionEntries()); + } + else { + if (!symbols || symbols.length === 0) { + return undefined; + } + entries = getCompletionEntriesFromSymbols(symbols); + } + if (!isMemberCompletion && !isJsDocTagName) { + ts.addRange(entries, keywordCompletions); + } + return { isMemberCompletion: isMemberCompletion, isNewIdentifierLocation: isNewIdentifierLocation, entries: entries }; + function getJavaScriptCompletionEntries() { + var entries = []; + var allNames = {}; + var target = program.getCompilerOptions().target; + for (var _i = 0, _a = program.getSourceFiles(); _i < _a.length; _i++) { + var sourceFile = _a[_i]; + var nameTable = getNameTable(sourceFile); + for (var name_34 in nameTable) { + if (!allNames[name_34]) { + allNames[name_34] = name_34; + var displayName = getCompletionEntryDisplayName(name_34, target, true); + if (displayName) { + var entry = { + name: displayName, + kind: ScriptElementKind.warning, + kindModifiers: "", + sortText: "1" + }; + entries.push(entry); + } + } + } + } + return entries; + } + function getAllJsDocCompletionEntries() { + return jsDocCompletionEntries || (jsDocCompletionEntries = ts.map(jsDocTagNames, function (tagName) { + return { + name: tagName, + kind: ScriptElementKind.keyword, + kindModifiers: "", + sortText: "0" + }; + })); + } + function createCompletionEntry(symbol, location) { + var displayName = getCompletionEntryDisplayNameForSymbol(symbol, program.getCompilerOptions().target, true, location); + if (!displayName) { + return undefined; + } + return { + name: displayName, + kind: getSymbolKind(symbol, location), + kindModifiers: getSymbolModifiers(symbol), + sortText: "0" + }; + } + function getCompletionEntriesFromSymbols(symbols) { + var start = new Date().getTime(); + var entries = []; + if (symbols) { + var nameToSymbol = {}; + for (var _i = 0; _i < symbols.length; _i++) { + var symbol = symbols[_i]; + var entry = createCompletionEntry(symbol, location); + if (entry) { + var id = ts.escapeIdentifier(entry.name); + if (!ts.lookUp(nameToSymbol, id)) { + entries.push(entry); + nameToSymbol[id] = symbol; + } + } + } + } + log("getCompletionsAtPosition: getCompletionEntriesFromSymbols: " + (new Date().getTime() - start)); + return entries; + } + } + function getCompletionEntryDetails(fileName, position, entryName) { + synchronizeHostData(); + var completionData = getCompletionData(fileName, position); + if (completionData) { + var symbols = completionData.symbols, location_2 = completionData.location; + var target = program.getCompilerOptions().target; + var symbol = ts.forEach(symbols, function (s) { return getCompletionEntryDisplayNameForSymbol(s, target, false, location_2) === entryName ? s : undefined; }); + if (symbol) { + var _a = getSymbolDisplayPartsDocumentationAndSymbolKind(symbol, getValidSourceFile(fileName), location_2, location_2, 7), displayParts = _a.displayParts, documentation = _a.documentation, symbolKind = _a.symbolKind; + return { + name: entryName, + kindModifiers: getSymbolModifiers(symbol), + kind: symbolKind, + displayParts: displayParts, + documentation: documentation + }; + } + } + var keywordCompletion = ts.forEach(keywordCompletions, function (c) { return c.name === entryName; }); + if (keywordCompletion) { + return { + name: entryName, + kind: ScriptElementKind.keyword, + kindModifiers: ScriptElementKindModifier.none, + displayParts: [ts.displayPart(entryName, SymbolDisplayPartKind.keyword)], + documentation: undefined + }; + } + return undefined; + } + function getSymbolKind(symbol, location) { + var flags = symbol.getFlags(); + if (flags & 32) + return ts.getDeclarationOfKind(symbol, 186) ? + ScriptElementKind.localClassElement : ScriptElementKind.classElement; + if (flags & 384) + return ScriptElementKind.enumElement; + if (flags & 524288) + return ScriptElementKind.typeElement; + if (flags & 64) + return ScriptElementKind.interfaceElement; + if (flags & 262144) + return ScriptElementKind.typeParameterElement; + var result = getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar(symbol, flags, location); + if (result === ScriptElementKind.unknown) { + if (flags & 262144) + return ScriptElementKind.typeParameterElement; + if (flags & 8) + return ScriptElementKind.variableElement; + if (flags & 8388608) + return ScriptElementKind.alias; + if (flags & 1536) + return ScriptElementKind.moduleElement; + } + return result; + } + function getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar(symbol, flags, location) { + var typeChecker = program.getTypeChecker(); + if (typeChecker.isUndefinedSymbol(symbol)) { + return ScriptElementKind.variableElement; + } + if (typeChecker.isArgumentsSymbol(symbol)) { + return ScriptElementKind.localVariableElement; + } + if (flags & 3) { + if (ts.isFirstDeclarationOfSymbolParameter(symbol)) { + return ScriptElementKind.parameterElement; + } + else if (symbol.valueDeclaration && ts.isConst(symbol.valueDeclaration)) { + return ScriptElementKind.constElement; + } + else if (ts.forEach(symbol.declarations, ts.isLet)) { + return ScriptElementKind.letElement; + } + return isLocalVariableOrFunction(symbol) ? ScriptElementKind.localVariableElement : ScriptElementKind.variableElement; + } + if (flags & 16) + return isLocalVariableOrFunction(symbol) ? ScriptElementKind.localFunctionElement : ScriptElementKind.functionElement; + if (flags & 32768) + return ScriptElementKind.memberGetAccessorElement; + if (flags & 65536) + return ScriptElementKind.memberSetAccessorElement; + if (flags & 8192) + return ScriptElementKind.memberFunctionElement; + if (flags & 16384) + return ScriptElementKind.constructorImplementationElement; + if (flags & 4) { + if (flags & 268435456) { + var unionPropertyKind = ts.forEach(typeChecker.getRootSymbols(symbol), function (rootSymbol) { + var rootSymbolFlags = rootSymbol.getFlags(); + if (rootSymbolFlags & (98308 | 3)) { + return ScriptElementKind.memberVariableElement; + } + ts.Debug.assert(!!(rootSymbolFlags & 8192)); + }); + if (!unionPropertyKind) { + var typeOfUnionProperty = typeChecker.getTypeOfSymbolAtLocation(symbol, location); + if (typeOfUnionProperty.getCallSignatures().length) { + return ScriptElementKind.memberFunctionElement; + } + return ScriptElementKind.memberVariableElement; + } + return unionPropertyKind; + } + return ScriptElementKind.memberVariableElement; + } + return ScriptElementKind.unknown; + } + function getSymbolModifiers(symbol) { + return symbol && symbol.declarations && symbol.declarations.length > 0 + ? ts.getNodeModifiers(symbol.declarations[0]) + : ScriptElementKindModifier.none; + } + function getSymbolDisplayPartsDocumentationAndSymbolKind(symbol, sourceFile, enclosingDeclaration, location, semanticMeaning) { + if (semanticMeaning === void 0) { semanticMeaning = getMeaningFromLocation(location); } + var typeChecker = program.getTypeChecker(); + var displayParts = []; + var documentation; + var symbolFlags = symbol.flags; + var symbolKind = getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar(symbol, symbolFlags, location); + var hasAddedSymbolInfo; + var type; + if (symbolKind !== ScriptElementKind.unknown || symbolFlags & 32 || symbolFlags & 8388608) { + if (symbolKind === ScriptElementKind.memberGetAccessorElement || symbolKind === ScriptElementKind.memberSetAccessorElement) { + symbolKind = ScriptElementKind.memberVariableElement; + } + var signature; + type = typeChecker.getTypeOfSymbolAtLocation(symbol, location); + if (type) { + if (location.parent && location.parent.kind === 166) { + var right = location.parent.name; + if (right === location || (right && right.getFullWidth() === 0)) { + location = location.parent; + } + } + var callExpression; + if (location.kind === 168 || location.kind === 169) { + callExpression = location; + } + else if (isCallExpressionTarget(location) || isNewExpressionTarget(location)) { + callExpression = location.parent; + } + if (callExpression) { + var candidateSignatures = []; + signature = typeChecker.getResolvedSignature(callExpression, candidateSignatures); + if (!signature && candidateSignatures.length) { + signature = candidateSignatures[0]; + } + var useConstructSignatures = callExpression.kind === 169 || callExpression.expression.kind === 95; + var allSignatures = useConstructSignatures ? type.getConstructSignatures() : type.getCallSignatures(); + if (!ts.contains(allSignatures, signature.target) && !ts.contains(allSignatures, signature)) { + signature = allSignatures.length ? allSignatures[0] : undefined; + } + if (signature) { + if (useConstructSignatures && (symbolFlags & 32)) { + symbolKind = ScriptElementKind.constructorImplementationElement; + addPrefixForAnyFunctionOrVar(type.symbol, symbolKind); + } + else if (symbolFlags & 8388608) { + symbolKind = ScriptElementKind.alias; + pushTypePart(symbolKind); + displayParts.push(ts.spacePart()); + if (useConstructSignatures) { + displayParts.push(ts.keywordPart(92)); + displayParts.push(ts.spacePart()); + } + addFullSymbolName(symbol); + } + else { + addPrefixForAnyFunctionOrVar(symbol, symbolKind); + } + switch (symbolKind) { + case ScriptElementKind.memberVariableElement: + case ScriptElementKind.variableElement: + case ScriptElementKind.constElement: + case ScriptElementKind.letElement: + case ScriptElementKind.parameterElement: + case ScriptElementKind.localVariableElement: + displayParts.push(ts.punctuationPart(54)); + displayParts.push(ts.spacePart()); + if (useConstructSignatures) { + displayParts.push(ts.keywordPart(92)); + displayParts.push(ts.spacePart()); + } + if (!(type.flags & 65536)) { + ts.addRange(displayParts, ts.symbolToDisplayParts(typeChecker, type.symbol, enclosingDeclaration, undefined, 1)); + } + addSignatureDisplayParts(signature, allSignatures, 8); + break; + default: + addSignatureDisplayParts(signature, allSignatures); + } + hasAddedSymbolInfo = true; + } + } + else if ((isNameOfFunctionDeclaration(location) && !(symbol.flags & 98304)) || + (location.kind === 121 && location.parent.kind === 144)) { + var functionDeclaration = location.parent; + var allSignatures = functionDeclaration.kind === 144 ? type.getConstructSignatures() : type.getCallSignatures(); + if (!typeChecker.isImplementationOfOverload(functionDeclaration)) { + signature = typeChecker.getSignatureFromDeclaration(functionDeclaration); + } + else { + signature = allSignatures[0]; + } + if (functionDeclaration.kind === 144) { + symbolKind = ScriptElementKind.constructorImplementationElement; + addPrefixForAnyFunctionOrVar(type.symbol, symbolKind); + } + else { + addPrefixForAnyFunctionOrVar(functionDeclaration.kind === 147 && + !(type.symbol.flags & 2048 || type.symbol.flags & 4096) ? type.symbol : symbol, symbolKind); + } + addSignatureDisplayParts(signature, allSignatures); + hasAddedSymbolInfo = true; + } + } + } + if (symbolFlags & 32 && !hasAddedSymbolInfo) { + if (ts.getDeclarationOfKind(symbol, 186)) { + pushTypePart(ScriptElementKind.localClassElement); + } + else { + displayParts.push(ts.keywordPart(73)); + } + displayParts.push(ts.spacePart()); + addFullSymbolName(symbol); + writeTypeParametersOfSymbol(symbol, sourceFile); + } + if ((symbolFlags & 64) && (semanticMeaning & 2)) { + addNewLineIfDisplayPartsExist(); + displayParts.push(ts.keywordPart(107)); + displayParts.push(ts.spacePart()); + addFullSymbolName(symbol); + writeTypeParametersOfSymbol(symbol, sourceFile); + } + if (symbolFlags & 524288) { + addNewLineIfDisplayPartsExist(); + displayParts.push(ts.keywordPart(132)); + displayParts.push(ts.spacePart()); + addFullSymbolName(symbol); + writeTypeParametersOfSymbol(symbol, sourceFile); + displayParts.push(ts.spacePart()); + displayParts.push(ts.operatorPart(56)); + displayParts.push(ts.spacePart()); + ts.addRange(displayParts, ts.typeToDisplayParts(typeChecker, typeChecker.getDeclaredTypeOfSymbol(symbol), enclosingDeclaration)); + } + if (symbolFlags & 384) { + addNewLineIfDisplayPartsExist(); + if (ts.forEach(symbol.declarations, ts.isConstEnumDeclaration)) { + displayParts.push(ts.keywordPart(74)); + displayParts.push(ts.spacePart()); + } + displayParts.push(ts.keywordPart(81)); + displayParts.push(ts.spacePart()); + addFullSymbolName(symbol); + } + if (symbolFlags & 1536) { + addNewLineIfDisplayPartsExist(); + var declaration = ts.getDeclarationOfKind(symbol, 218); + var isNamespace = declaration && declaration.name && declaration.name.kind === 69; + displayParts.push(ts.keywordPart(isNamespace ? 126 : 125)); + displayParts.push(ts.spacePart()); + addFullSymbolName(symbol); + } + 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.spacePart()); + addFullSymbolName(symbol); + displayParts.push(ts.spacePart()); + displayParts.push(ts.keywordPart(90)); + displayParts.push(ts.spacePart()); + if (symbol.parent) { + addFullSymbolName(symbol.parent, enclosingDeclaration); + writeTypeParametersOfSymbol(symbol.parent, enclosingDeclaration); + } + else { + var container = ts.getContainingFunction(location); + if (container) { + var signatureDeclaration = ts.getDeclarationOfKind(symbol, 137).parent; + var signature = typeChecker.getSignatureFromDeclaration(signatureDeclaration); + if (signatureDeclaration.kind === 148) { + displayParts.push(ts.keywordPart(92)); + displayParts.push(ts.spacePart()); + } + else if (signatureDeclaration.kind !== 147 && signatureDeclaration.name) { + addFullSymbolName(signatureDeclaration.symbol); + } + ts.addRange(displayParts, ts.signatureToDisplayParts(typeChecker, signature, sourceFile, 32)); + } + else { + var declaration = ts.getDeclarationOfKind(symbol, 137).parent; + displayParts.push(ts.keywordPart(132)); + displayParts.push(ts.spacePart()); + addFullSymbolName(declaration.symbol); + writeTypeParametersOfSymbol(declaration.symbol, sourceFile); + } + } + } + if (symbolFlags & 8) { + addPrefixForAnyFunctionOrVar(symbol, "enum member"); + var declaration = symbol.declarations[0]; + if (declaration.kind === 247) { + var constantValue = typeChecker.getConstantValue(declaration); + if (constantValue !== undefined) { + displayParts.push(ts.spacePart()); + displayParts.push(ts.operatorPart(56)); + displayParts.push(ts.spacePart()); + displayParts.push(ts.displayPart(constantValue.toString(), SymbolDisplayPartKind.numericLiteral)); + } + } + } + if (symbolFlags & 8388608) { + addNewLineIfDisplayPartsExist(); + displayParts.push(ts.keywordPart(89)); + displayParts.push(ts.spacePart()); + addFullSymbolName(symbol); + ts.forEach(symbol.declarations, function (declaration) { + if (declaration.kind === 221) { + var importEqualsDeclaration = declaration; + if (ts.isExternalModuleImportEqualsDeclaration(importEqualsDeclaration)) { + displayParts.push(ts.spacePart()); + displayParts.push(ts.operatorPart(56)); + displayParts.push(ts.spacePart()); + displayParts.push(ts.keywordPart(127)); + displayParts.push(ts.punctuationPart(17)); + displayParts.push(ts.displayPart(ts.getTextOfNode(ts.getExternalModuleImportEqualsDeclarationExpression(importEqualsDeclaration)), SymbolDisplayPartKind.stringLiteral)); + displayParts.push(ts.punctuationPart(18)); + } + else { + var internalAliasSymbol = typeChecker.getSymbolAtLocation(importEqualsDeclaration.moduleReference); + if (internalAliasSymbol) { + displayParts.push(ts.spacePart()); + displayParts.push(ts.operatorPart(56)); + displayParts.push(ts.spacePart()); + addFullSymbolName(internalAliasSymbol, enclosingDeclaration); + } + } + return true; + } + }); + } + if (!hasAddedSymbolInfo) { + if (symbolKind !== ScriptElementKind.unknown) { + if (type) { + addPrefixForAnyFunctionOrVar(symbol, symbolKind); + if (symbolKind === ScriptElementKind.memberVariableElement || + symbolFlags & 3 || + symbolKind === ScriptElementKind.localVariableElement) { + displayParts.push(ts.punctuationPart(54)); + displayParts.push(ts.spacePart()); + if (type.symbol && type.symbol.flags & 262144) { + var typeParameterParts = ts.mapToDisplayParts(function (writer) { + typeChecker.getSymbolDisplayBuilder().buildTypeParameterDisplay(type, writer, enclosingDeclaration); + }); + ts.addRange(displayParts, typeParameterParts); + } + else { + ts.addRange(displayParts, ts.typeToDisplayParts(typeChecker, type, enclosingDeclaration)); + } + } + else if (symbolFlags & 16 || + symbolFlags & 8192 || + symbolFlags & 16384 || + symbolFlags & 131072 || + symbolFlags & 98304 || + symbolKind === ScriptElementKind.memberFunctionElement) { + var allSignatures = type.getCallSignatures(); + addSignatureDisplayParts(allSignatures[0], allSignatures); + } + } + } + else { + symbolKind = getSymbolKind(symbol, location); + } + } + if (!documentation) { + documentation = symbol.getDocumentationComment(); + } + return { displayParts: displayParts, documentation: documentation, symbolKind: symbolKind }; + function addNewLineIfDisplayPartsExist() { + if (displayParts.length) { + displayParts.push(ts.lineBreakPart()); + } + } + function addFullSymbolName(symbol, enclosingDeclaration) { + var fullSymbolDisplayParts = ts.symbolToDisplayParts(typeChecker, symbol, enclosingDeclaration || sourceFile, undefined, 1 | 2); + ts.addRange(displayParts, fullSymbolDisplayParts); + } + function addPrefixForAnyFunctionOrVar(symbol, symbolKind) { + addNewLineIfDisplayPartsExist(); + if (symbolKind) { + pushTypePart(symbolKind); + displayParts.push(ts.spacePart()); + addFullSymbolName(symbol); + } + } + function pushTypePart(symbolKind) { + switch (symbolKind) { + case ScriptElementKind.variableElement: + case ScriptElementKind.functionElement: + case ScriptElementKind.letElement: + case ScriptElementKind.constElement: + case ScriptElementKind.constructorImplementationElement: + displayParts.push(ts.textOrKeywordPart(symbolKind)); + return; + default: + displayParts.push(ts.punctuationPart(17)); + displayParts.push(ts.textOrKeywordPart(symbolKind)); + displayParts.push(ts.punctuationPart(18)); + return; + } + } + function addSignatureDisplayParts(signature, allSignatures, flags) { + 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.displayPart((allSignatures.length - 1).toString(), SymbolDisplayPartKind.numericLiteral)); + displayParts.push(ts.spacePart()); + displayParts.push(ts.textPart(allSignatures.length === 2 ? "overload" : "overloads")); + displayParts.push(ts.punctuationPart(18)); + } + documentation = signature.getDocumentationComment(); + } + function writeTypeParametersOfSymbol(symbol, enclosingDeclaration) { + var typeParameterParts = ts.mapToDisplayParts(function (writer) { + typeChecker.getSymbolDisplayBuilder().buildTypeParameterDisplayFromSymbol(symbol, writer, enclosingDeclaration); + }); + ts.addRange(displayParts, typeParameterParts); + } + } + function getQuickInfoAtPosition(fileName, position) { + synchronizeHostData(); + var sourceFile = getValidSourceFile(fileName); + var node = ts.getTouchingPropertyName(sourceFile, position); + if (!node) { + return undefined; + } + if (isLabelName(node)) { + return undefined; + } + var typeChecker = program.getTypeChecker(); + var symbol = typeChecker.getSymbolAtLocation(node); + if (!symbol) { + switch (node.kind) { + case 69: + case 166: + case 135: + case 97: + case 95: + var type = typeChecker.getTypeAtLocation(node); + if (type) { + return { + kind: ScriptElementKind.unknown, + kindModifiers: ScriptElementKindModifier.none, + textSpan: ts.createTextSpan(node.getStart(), node.getWidth()), + displayParts: ts.typeToDisplayParts(typeChecker, type, getContainerNode(node)), + documentation: type.symbol ? type.symbol.getDocumentationComment() : undefined + }; + } + } + return undefined; + } + var displayPartsDocumentationsAndKind = getSymbolDisplayPartsDocumentationAndSymbolKind(symbol, sourceFile, getContainerNode(node), node); + return { + kind: displayPartsDocumentationsAndKind.symbolKind, + kindModifiers: getSymbolModifiers(symbol), + textSpan: ts.createTextSpan(node.getStart(), node.getWidth()), + displayParts: displayPartsDocumentationsAndKind.displayParts, + documentation: displayPartsDocumentationsAndKind.documentation + }; + } + function createDefinitionInfo(node, symbolKind, symbolName, containerName) { + return { + fileName: node.getSourceFile().fileName, + textSpan: ts.createTextSpanFromBounds(node.getStart(), node.getEnd()), + kind: symbolKind, + name: symbolName, + containerKind: undefined, + containerName: containerName + }; + } + function getDefinitionFromSymbol(symbol, node) { + var typeChecker = program.getTypeChecker(); + var result = []; + var declarations = symbol.getDeclarations(); + var symbolName = typeChecker.symbolToString(symbol); + var symbolKind = getSymbolKind(symbol, node); + var containerSymbol = symbol.parent; + var containerName = containerSymbol ? typeChecker.symbolToString(containerSymbol, node) : ""; + if (!tryAddConstructSignature(symbol, node, symbolKind, symbolName, containerName, result) && + !tryAddCallSignature(symbol, node, symbolKind, symbolName, containerName, result)) { + ts.forEach(declarations, function (declaration) { + result.push(createDefinitionInfo(declaration, symbolKind, symbolName, containerName)); + }); + } + return result; + function tryAddConstructSignature(symbol, location, symbolKind, symbolName, containerName, result) { + if (isNewExpressionTarget(location) || location.kind === 121) { + if (symbol.flags & 32) { + for (var _i = 0, _a = symbol.getDeclarations(); _i < _a.length; _i++) { + var declaration = _a[_i]; + if (ts.isClassLike(declaration)) { + return tryAddSignature(declaration.members, true, symbolKind, symbolName, containerName, result); + } + } + ts.Debug.fail("Expected declaration to have at least one class-like declaration"); + } + } + return false; + } + function tryAddCallSignature(symbol, location, symbolKind, symbolName, containerName, result) { + if (isCallExpressionTarget(location) || isNewExpressionTarget(location) || isNameOfFunctionDeclaration(location)) { + return tryAddSignature(symbol.declarations, false, symbolKind, symbolName, containerName, result); + } + return false; + } + function tryAddSignature(signatureDeclarations, selectConstructors, symbolKind, symbolName, containerName, result) { + var declarations = []; + var definition; + ts.forEach(signatureDeclarations, function (d) { + if ((selectConstructors && d.kind === 144) || + (!selectConstructors && (d.kind === 213 || d.kind === 143 || d.kind === 142))) { + declarations.push(d); + if (d.body) + definition = d; + } + }); + if (definition) { + result.push(createDefinitionInfo(definition, symbolKind, symbolName, containerName)); + return true; + } + else if (declarations.length) { + result.push(createDefinitionInfo(ts.lastOrUndefined(declarations), symbolKind, symbolName, containerName)); + return true; + } + return false; + } + } + function getDefinitionAtPosition(fileName, position) { + synchronizeHostData(); + var sourceFile = getValidSourceFile(fileName); + var node = ts.getTouchingPropertyName(sourceFile, position); + if (!node) { + return undefined; + } + if (isJumpStatementTarget(node)) { + var labelName = node.text; + var label = getTargetLabel(node.parent, node.text); + return label ? [createDefinitionInfo(label, ScriptElementKind.label, labelName, undefined)] : undefined; + } + var comment = ts.forEach(sourceFile.referencedFiles, function (r) { return (r.pos <= position && position < r.end) ? r : undefined; }); + if (comment) { + var referenceFile = ts.tryResolveScriptReference(program, sourceFile, comment); + if (referenceFile) { + return [{ + fileName: referenceFile.fileName, + textSpan: ts.createTextSpanFromBounds(0, 0), + kind: ScriptElementKind.scriptElement, + name: comment.fileName, + containerName: undefined, + containerKind: undefined + }]; + } + return undefined; + } + var typeChecker = program.getTypeChecker(); + var symbol = typeChecker.getSymbolAtLocation(node); + if (!symbol) { + return undefined; + } + if (symbol.flags & 8388608) { + var declaration = symbol.declarations[0]; + if (node.kind === 69 && node.parent === declaration) { + symbol = typeChecker.getAliasedSymbol(symbol); + } + } + if (node.parent.kind === 246) { + var shorthandSymbol = typeChecker.getShorthandAssignmentValueSymbol(symbol.valueDeclaration); + if (!shorthandSymbol) { + return []; + } + var shorthandDeclarations = shorthandSymbol.getDeclarations(); + var shorthandSymbolKind = getSymbolKind(shorthandSymbol, node); + var shorthandSymbolName = typeChecker.symbolToString(shorthandSymbol); + var shorthandContainerName = typeChecker.symbolToString(symbol.parent, node); + return ts.map(shorthandDeclarations, function (declaration) { return createDefinitionInfo(declaration, shorthandSymbolKind, shorthandSymbolName, shorthandContainerName); }); + } + return getDefinitionFromSymbol(symbol, node); + } + function getTypeDefinitionAtPosition(fileName, position) { + synchronizeHostData(); + var sourceFile = getValidSourceFile(fileName); + var node = ts.getTouchingPropertyName(sourceFile, position); + if (!node) { + return undefined; + } + var typeChecker = program.getTypeChecker(); + var symbol = typeChecker.getSymbolAtLocation(node); + if (!symbol) { + return undefined; + } + var type = typeChecker.getTypeOfSymbolAtLocation(symbol, node); + if (!type) { + return undefined; + } + if (type.flags & 16384) { + var result = []; + ts.forEach(type.types, function (t) { + if (t.symbol) { + ts.addRange(result, getDefinitionFromSymbol(t.symbol, node)); + } + }); + return result; + } + if (!type.symbol) { + return undefined; + } + return getDefinitionFromSymbol(type.symbol, node); + } + function getOccurrencesAtPosition(fileName, position) { + var results = getOccurrencesAtPositionCore(fileName, position); + if (results) { + var sourceFile = getCanonicalFileName(ts.normalizeSlashes(fileName)); + results = ts.filter(results, function (r) { return getCanonicalFileName(ts.normalizeSlashes(r.fileName)) === sourceFile; }); + } + return results; + } + function getDocumentHighlights(fileName, position, filesToSearch) { + synchronizeHostData(); + filesToSearch = ts.map(filesToSearch, ts.normalizeSlashes); + var sourceFilesToSearch = ts.filter(program.getSourceFiles(), function (f) { return ts.contains(filesToSearch, f.fileName); }); + var sourceFile = getValidSourceFile(fileName); + var node = ts.getTouchingWord(sourceFile, position); + if (!node) { + return undefined; + } + return getSemanticDocumentHighlights(node) || getSyntacticDocumentHighlights(node); + function getHighlightSpanForNode(node) { + var start = node.getStart(); + var end = node.getEnd(); + return { + fileName: sourceFile.fileName, + textSpan: ts.createTextSpanFromBounds(start, end), + kind: HighlightSpanKind.none + }; + } + function getSemanticDocumentHighlights(node) { + if (node.kind === 69 || + node.kind === 97 || + node.kind === 95 || + isLiteralNameOfPropertyDeclarationOrIndexAccess(node) || + isNameOfExternalModuleImportOrDeclaration(node)) { + var referencedSymbols = getReferencedSymbolsForNode(node, sourceFilesToSearch, false, false); + return convertReferencedSymbols(referencedSymbols); + } + return undefined; + function convertReferencedSymbols(referencedSymbols) { + if (!referencedSymbols) { + return undefined; + } + var fileNameToDocumentHighlights = {}; + var result = []; + for (var _i = 0; _i < referencedSymbols.length; _i++) { + var referencedSymbol = referencedSymbols[_i]; + for (var _a = 0, _b = referencedSymbol.references; _a < _b.length; _a++) { + var referenceEntry = _b[_a]; + var fileName_1 = referenceEntry.fileName; + var documentHighlights = ts.getProperty(fileNameToDocumentHighlights, fileName_1); + if (!documentHighlights) { + documentHighlights = { fileName: fileName_1, highlightSpans: [] }; + fileNameToDocumentHighlights[fileName_1] = documentHighlights; + result.push(documentHighlights); + } + documentHighlights.highlightSpans.push({ + textSpan: referenceEntry.textSpan, + kind: referenceEntry.isWriteAccess ? HighlightSpanKind.writtenReference : HighlightSpanKind.reference + }); + } + } + return result; + } + } + function getSyntacticDocumentHighlights(node) { + var fileName = sourceFile.fileName; + var highlightSpans = getHighlightSpans(node); + if (!highlightSpans || highlightSpans.length === 0) { + return undefined; + } + return [{ fileName: fileName, highlightSpans: highlightSpans }]; + function hasKind(node, kind) { + return node !== undefined && node.kind === kind; + } + function parent(node) { + return node && node.parent; + } + function getHighlightSpans(node) { + if (node) { + switch (node.kind) { + case 88: + case 80: + if (hasKind(node.parent, 196)) { + return getIfElseOccurrences(node.parent); + } + break; + case 94: + if (hasKind(node.parent, 204)) { + return getReturnOccurrences(node.parent); + } + break; + case 98: + if (hasKind(node.parent, 208)) { + return getThrowOccurrences(node.parent); + } + break; + case 72: + if (hasKind(parent(parent(node)), 209)) { + return getTryCatchFinallyOccurrences(node.parent.parent); + } + break; + case 100: + case 85: + if (hasKind(parent(node), 209)) { + return getTryCatchFinallyOccurrences(node.parent); + } + break; + case 96: + if (hasKind(node.parent, 206)) { + return getSwitchCaseDefaultOccurrences(node.parent); + } + break; + case 71: + case 77: + if (hasKind(parent(parent(parent(node))), 206)) { + return getSwitchCaseDefaultOccurrences(node.parent.parent.parent); + } + break; + case 70: + case 75: + if (hasKind(node.parent, 203) || hasKind(node.parent, 202)) { + return getBreakOrContinueStatementOccurrences(node.parent); + } + break; + case 86: + if (hasKind(node.parent, 199) || + hasKind(node.parent, 200) || + hasKind(node.parent, 201)) { + return getLoopBreakContinueOccurrences(node.parent); + } + break; + case 104: + case 79: + if (hasKind(node.parent, 198) || hasKind(node.parent, 197)) { + return getLoopBreakContinueOccurrences(node.parent); + } + break; + case 121: + if (hasKind(node.parent, 144)) { + return getConstructorOccurrences(node.parent); + } + break; + case 123: + case 129: + if (hasKind(node.parent, 145) || hasKind(node.parent, 146)) { + return getGetAndSetOccurrences(node.parent); + } + break; + default: + if (ts.isModifier(node.kind) && node.parent && + (ts.isDeclaration(node.parent) || node.parent.kind === 193)) { + return getModifierOccurrences(node.kind, node.parent); + } + } + } + return undefined; + } + function aggregateOwnedThrowStatements(node) { + var statementAccumulator = []; + aggregate(node); + return statementAccumulator; + function aggregate(node) { + if (node.kind === 208) { + statementAccumulator.push(node); + } + else if (node.kind === 209) { + var tryStatement = node; + if (tryStatement.catchClause) { + aggregate(tryStatement.catchClause); + } + else { + aggregate(tryStatement.tryBlock); + } + if (tryStatement.finallyBlock) { + aggregate(tryStatement.finallyBlock); + } + } + else if (!ts.isFunctionLike(node)) { + ts.forEachChild(node, aggregate); + } + } + ; + } + function getThrowStatementOwner(throwStatement) { + var child = throwStatement; + while (child.parent) { + var parent_12 = child.parent; + if (ts.isFunctionBlock(parent_12) || parent_12.kind === 248) { + return parent_12; + } + if (parent_12.kind === 209) { + var tryStatement = parent_12; + if (tryStatement.tryBlock === child && tryStatement.catchClause) { + return child; + } + } + child = parent_12; + } + return undefined; + } + function aggregateAllBreakAndContinueStatements(node) { + var statementAccumulator = []; + aggregate(node); + return statementAccumulator; + function aggregate(node) { + if (node.kind === 203 || node.kind === 202) { + statementAccumulator.push(node); + } + else if (!ts.isFunctionLike(node)) { + ts.forEachChild(node, aggregate); + } + } + ; + } + function ownsBreakOrContinueStatement(owner, statement) { + var actualOwner = getBreakOrContinueOwner(statement); + return actualOwner && actualOwner === owner; + } + function getBreakOrContinueOwner(statement) { + for (var node_2 = statement.parent; node_2; node_2 = node_2.parent) { + switch (node_2.kind) { + case 206: + if (statement.kind === 202) { + continue; + } + case 199: + case 200: + case 201: + case 198: + case 197: + if (!statement.label || isLabeledBy(node_2, statement.label.text)) { + return node_2; + } + break; + default: + if (ts.isFunctionLike(node_2)) { + return undefined; + } + break; + } + } + return undefined; + } + function getModifierOccurrences(modifier, declaration) { + var container = declaration.parent; + if (ts.isAccessibilityModifier(modifier)) { + if (!(container.kind === 214 || + container.kind === 186 || + (declaration.kind === 138 && hasKind(container, 144)))) { + return undefined; + } + } + else if (modifier === 113) { + if (!(container.kind === 214 || container.kind === 186)) { + return undefined; + } + } + else if (modifier === 82 || modifier === 122) { + if (!(container.kind === 219 || container.kind === 248)) { + return undefined; + } + } + else if (modifier === 115) { + if (!(container.kind === 214 || declaration.kind === 214)) { + return undefined; + } + } + else { + return undefined; + } + var keywords = []; + var modifierFlag = getFlagFromModifier(modifier); + var nodes; + switch (container.kind) { + case 219: + case 248: + if (modifierFlag & 256) { + nodes = declaration.members.concat(declaration); + } + else { + nodes = container.statements; + } + break; + case 144: + nodes = container.parameters.concat(container.parent.members); + break; + case 214: + case 186: + nodes = container.members; + if (modifierFlag & 112) { + var constructor = ts.forEach(container.members, function (member) { + return member.kind === 144 && member; + }); + if (constructor) { + nodes = nodes.concat(constructor.parameters); + } + } + else if (modifierFlag & 256) { + nodes = nodes.concat(container); + } + break; + default: + ts.Debug.fail("Invalid container kind."); + } + ts.forEach(nodes, function (node) { + if (node.modifiers && node.flags & modifierFlag) { + ts.forEach(node.modifiers, function (child) { return pushKeywordIf(keywords, child, modifier); }); + } + }); + return ts.map(keywords, getHighlightSpanForNode); + function getFlagFromModifier(modifier) { + switch (modifier) { + case 112: + return 16; + case 110: + return 32; + case 111: + return 64; + case 113: + return 128; + case 82: + return 1; + case 122: + return 2; + case 115: + return 256; + default: + ts.Debug.fail(); + } + } + } + function pushKeywordIf(keywordList, token) { + var expected = []; + for (var _i = 2; _i < arguments.length; _i++) { + expected[_i - 2] = arguments[_i]; + } + if (token && ts.contains(expected, token.kind)) { + keywordList.push(token); + return true; + } + return false; + } + function getGetAndSetOccurrences(accessorDeclaration) { + var keywords = []; + tryPushAccessorKeyword(accessorDeclaration.symbol, 145); + tryPushAccessorKeyword(accessorDeclaration.symbol, 146); + return ts.map(keywords, getHighlightSpanForNode); + function tryPushAccessorKeyword(accessorSymbol, accessorKind) { + var accessor = ts.getDeclarationOfKind(accessorSymbol, accessorKind); + if (accessor) { + ts.forEach(accessor.getChildren(), function (child) { return pushKeywordIf(keywords, child, 123, 129); }); + } + } + } + function getConstructorOccurrences(constructorDeclaration) { + var declarations = constructorDeclaration.symbol.getDeclarations(); + var keywords = []; + ts.forEach(declarations, function (declaration) { + ts.forEach(declaration.getChildren(), function (token) { + return pushKeywordIf(keywords, token, 121); + }); + }); + return ts.map(keywords, getHighlightSpanForNode); + } + function getLoopBreakContinueOccurrences(loopNode) { + var keywords = []; + if (pushKeywordIf(keywords, loopNode.getFirstToken(), 86, 104, 79)) { + if (loopNode.kind === 197) { + var loopTokens = loopNode.getChildren(); + for (var i = loopTokens.length - 1; i >= 0; i--) { + if (pushKeywordIf(keywords, loopTokens[i], 104)) { + break; + } + } + } + } + var breaksAndContinues = aggregateAllBreakAndContinueStatements(loopNode.statement); + ts.forEach(breaksAndContinues, function (statement) { + if (ownsBreakOrContinueStatement(loopNode, statement)) { + pushKeywordIf(keywords, statement.getFirstToken(), 70, 75); + } + }); + return ts.map(keywords, getHighlightSpanForNode); + } + function getBreakOrContinueStatementOccurrences(breakOrContinueStatement) { + var owner = getBreakOrContinueOwner(breakOrContinueStatement); + if (owner) { + switch (owner.kind) { + case 199: + case 200: + case 201: + case 197: + case 198: + return getLoopBreakContinueOccurrences(owner); + case 206: + return getSwitchCaseDefaultOccurrences(owner); + } + } + return undefined; + } + function getSwitchCaseDefaultOccurrences(switchStatement) { + var keywords = []; + pushKeywordIf(keywords, switchStatement.getFirstToken(), 96); + ts.forEach(switchStatement.caseBlock.clauses, function (clause) { + pushKeywordIf(keywords, clause.getFirstToken(), 71, 77); + var breaksAndContinues = aggregateAllBreakAndContinueStatements(clause); + ts.forEach(breaksAndContinues, function (statement) { + if (ownsBreakOrContinueStatement(switchStatement, statement)) { + pushKeywordIf(keywords, statement.getFirstToken(), 70); + } + }); + }); + return ts.map(keywords, getHighlightSpanForNode); + } + function getTryCatchFinallyOccurrences(tryStatement) { + var keywords = []; + pushKeywordIf(keywords, tryStatement.getFirstToken(), 100); + if (tryStatement.catchClause) { + pushKeywordIf(keywords, tryStatement.catchClause.getFirstToken(), 72); + } + if (tryStatement.finallyBlock) { + var finallyKeyword = ts.findChildOfKind(tryStatement, 85, sourceFile); + pushKeywordIf(keywords, finallyKeyword, 85); + } + return ts.map(keywords, getHighlightSpanForNode); + } + function getThrowOccurrences(throwStatement) { + var owner = getThrowStatementOwner(throwStatement); + if (!owner) { + return undefined; + } + var keywords = []; + ts.forEach(aggregateOwnedThrowStatements(owner), function (throwStatement) { + pushKeywordIf(keywords, throwStatement.getFirstToken(), 98); + }); + if (ts.isFunctionBlock(owner)) { + ts.forEachReturnStatement(owner, function (returnStatement) { + pushKeywordIf(keywords, returnStatement.getFirstToken(), 94); + }); + } + return ts.map(keywords, getHighlightSpanForNode); + } + function getReturnOccurrences(returnStatement) { + var func = ts.getContainingFunction(returnStatement); + if (!(func && hasKind(func.body, 192))) { + return undefined; + } + var keywords = []; + ts.forEachReturnStatement(func.body, function (returnStatement) { + pushKeywordIf(keywords, returnStatement.getFirstToken(), 94); + }); + ts.forEach(aggregateOwnedThrowStatements(func.body), function (throwStatement) { + pushKeywordIf(keywords, throwStatement.getFirstToken(), 98); + }); + return ts.map(keywords, getHighlightSpanForNode); + } + function getIfElseOccurrences(ifStatement) { + var keywords = []; + while (hasKind(ifStatement.parent, 196) && ifStatement.parent.elseStatement === ifStatement) { + ifStatement = ifStatement.parent; + } + while (ifStatement) { + var children = ifStatement.getChildren(); + pushKeywordIf(keywords, children[0], 88); + for (var i = children.length - 1; i >= 0; i--) { + if (pushKeywordIf(keywords, children[i], 80)) { + break; + } + } + if (!hasKind(ifStatement.elseStatement, 196)) { + break; + } + ifStatement = ifStatement.elseStatement; + } + var result = []; + for (var i = 0; i < keywords.length; i++) { + if (keywords[i].kind === 80 && i < keywords.length - 1) { + var elseKeyword = keywords[i]; + var ifKeyword = keywords[i + 1]; + var shouldCombindElseAndIf = true; + for (var j = ifKeyword.getStart() - 1; j >= elseKeyword.end; j--) { + if (!ts.isWhiteSpace(sourceFile.text.charCodeAt(j))) { + shouldCombindElseAndIf = false; + break; + } + } + if (shouldCombindElseAndIf) { + result.push({ + fileName: fileName, + textSpan: ts.createTextSpanFromBounds(elseKeyword.getStart(), ifKeyword.end), + kind: HighlightSpanKind.reference + }); + i++; + continue; + } + } + result.push(getHighlightSpanForNode(keywords[i])); + } + return result; + } + } + } + function getOccurrencesAtPositionCore(fileName, position) { + synchronizeHostData(); + return convertDocumentHighlights(getDocumentHighlights(fileName, position, [fileName])); + function convertDocumentHighlights(documentHighlights) { + if (!documentHighlights) { + return undefined; + } + var result = []; + for (var _i = 0; _i < documentHighlights.length; _i++) { + var entry = documentHighlights[_i]; + for (var _a = 0, _b = entry.highlightSpans; _a < _b.length; _a++) { + var highlightSpan = _b[_a]; + result.push({ + fileName: entry.fileName, + textSpan: highlightSpan.textSpan, + isWriteAccess: highlightSpan.kind === HighlightSpanKind.writtenReference + }); + } + } + return result; + } + } + function convertReferences(referenceSymbols) { + if (!referenceSymbols) { + return undefined; + } + var referenceEntries = []; + for (var _i = 0; _i < referenceSymbols.length; _i++) { + var referenceSymbol = referenceSymbols[_i]; + ts.addRange(referenceEntries, referenceSymbol.references); + } + return referenceEntries; + } + function findRenameLocations(fileName, position, findInStrings, findInComments) { + var referencedSymbols = findReferencedSymbols(fileName, position, findInStrings, findInComments); + return convertReferences(referencedSymbols); + } + function getReferencesAtPosition(fileName, position) { + var referencedSymbols = findReferencedSymbols(fileName, position, false, false); + return convertReferences(referencedSymbols); + } + function findReferences(fileName, position) { + var referencedSymbols = findReferencedSymbols(fileName, position, false, false); + return ts.filter(referencedSymbols, function (rs) { return !!rs.definition; }); + } + function findReferencedSymbols(fileName, position, findInStrings, findInComments) { + synchronizeHostData(); + var sourceFile = getValidSourceFile(fileName); + var node = ts.getTouchingPropertyName(sourceFile, position); + if (!node) { + return undefined; + } + if (node.kind !== 69 && + !isLiteralNameOfPropertyDeclarationOrIndexAccess(node) && + !isNameOfExternalModuleImportOrDeclaration(node)) { + return undefined; + } + ts.Debug.assert(node.kind === 69 || node.kind === 8 || node.kind === 9); + return getReferencedSymbolsForNode(node, program.getSourceFiles(), findInStrings, findInComments); + } + function getReferencedSymbolsForNode(node, sourceFiles, findInStrings, findInComments) { + var typeChecker = program.getTypeChecker(); + if (isLabelName(node)) { + if (isJumpStatementTarget(node)) { + var labelDefinition = getTargetLabel(node.parent, node.text); + return labelDefinition ? getLabelReferencesInNode(labelDefinition.parent, labelDefinition) : undefined; + } + else { + return getLabelReferencesInNode(node.parent, node); + } + } + if (node.kind === 97) { + return getReferencesForThisKeyword(node, sourceFiles); + } + if (node.kind === 95) { + return getReferencesForSuperKeyword(node); + } + var symbol = typeChecker.getSymbolAtLocation(node); + if (!symbol) { + return undefined; + } + var declarations = symbol.declarations; + if (!declarations || !declarations.length) { + return undefined; + } + var result; + var searchMeaning = getIntersectingMeaningFromDeclarations(getMeaningFromLocation(node), declarations); + var declaredName = ts.stripQuotes(ts.getDeclaredName(typeChecker, symbol, node)); + var scope = getSymbolScope(symbol); + var symbolToIndex = []; + if (scope) { + result = []; + getReferencesInNode(scope, symbol, declaredName, node, searchMeaning, findInStrings, findInComments, result, symbolToIndex); + } + else { + var internedName = getInternedName(symbol, node, declarations); + for (var _i = 0; _i < sourceFiles.length; _i++) { + var sourceFile = sourceFiles[_i]; + cancellationToken.throwIfCancellationRequested(); + var nameTable = getNameTable(sourceFile); + if (ts.lookUp(nameTable, internedName)) { + result = result || []; + getReferencesInNode(sourceFile, symbol, declaredName, node, searchMeaning, findInStrings, findInComments, result, symbolToIndex); + } + } + } + return result; + function getDefinition(symbol) { + var info = getSymbolDisplayPartsDocumentationAndSymbolKind(symbol, node.getSourceFile(), getContainerNode(node), node); + var name = ts.map(info.displayParts, function (p) { return p.text; }).join(""); + var declarations = symbol.declarations; + if (!declarations || declarations.length === 0) { + return undefined; + } + return { + containerKind: "", + containerName: "", + name: name, + kind: info.symbolKind, + fileName: declarations[0].getSourceFile().fileName, + textSpan: ts.createTextSpan(declarations[0].getStart(), 0) + }; + } + function isImportOrExportSpecifierImportSymbol(symbol) { + return (symbol.flags & 8388608) && ts.forEach(symbol.declarations, function (declaration) { + return declaration.kind === 226 || declaration.kind === 230; + }); + } + function getInternedName(symbol, location, declarations) { + if (ts.isImportOrExportSpecifierName(location)) { + return location.getText(); + } + var localExportDefaultSymbol = ts.getLocalSymbolForExportDefault(symbol); + symbol = localExportDefaultSymbol || symbol; + return ts.stripQuotes(symbol.name); + } + function getSymbolScope(symbol) { + var valueDeclaration = symbol.valueDeclaration; + if (valueDeclaration && (valueDeclaration.kind === 173 || valueDeclaration.kind === 186)) { + return valueDeclaration; + } + if (symbol.flags & (4 | 8192)) { + var privateDeclaration = ts.forEach(symbol.getDeclarations(), function (d) { return (d.flags & 32) ? d : undefined; }); + if (privateDeclaration) { + return ts.getAncestor(privateDeclaration, 214); + } + } + if (symbol.flags & 8388608) { + return undefined; + } + if (symbol.parent || (symbol.flags & 268435456)) { + return undefined; + } + var scope = undefined; + var declarations = symbol.getDeclarations(); + if (declarations) { + for (var _i = 0; _i < declarations.length; _i++) { + var declaration = declarations[_i]; + var container = getContainerNode(declaration); + if (!container) { + return undefined; + } + if (scope && scope !== container) { + return undefined; + } + if (container.kind === 248 && !ts.isExternalModule(container)) { + return undefined; + } + scope = container; + } + } + return scope; + } + function getPossibleSymbolReferencePositions(sourceFile, symbolName, start, end) { + var positions = []; + if (!symbolName || !symbolName.length) { + return positions; + } + var text = sourceFile.text; + var sourceLength = text.length; + var symbolNameLength = symbolName.length; + var position = text.indexOf(symbolName, start); + while (position >= 0) { + cancellationToken.throwIfCancellationRequested(); + 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))) { + positions.push(position); + } + position = text.indexOf(symbolName, position + symbolNameLength + 1); + } + return positions; + } + function getLabelReferencesInNode(container, targetLabel) { + var references = []; + var sourceFile = container.getSourceFile(); + var labelName = targetLabel.text; + var possiblePositions = getPossibleSymbolReferencePositions(sourceFile, labelName, container.getStart(), container.getEnd()); + ts.forEach(possiblePositions, function (position) { + cancellationToken.throwIfCancellationRequested(); + var node = ts.getTouchingWord(sourceFile, position); + if (!node || node.getWidth() !== labelName.length) { + return; + } + if (node === targetLabel || + (isJumpStatementTarget(node) && getTargetLabel(node, labelName) === targetLabel)) { + references.push(getReferenceEntryFromNode(node)); + } + }); + var definition = { + containerKind: "", + containerName: "", + fileName: targetLabel.getSourceFile().fileName, + kind: ScriptElementKind.label, + name: labelName, + textSpan: ts.createTextSpanFromBounds(targetLabel.getStart(), targetLabel.getEnd()) + }; + return [{ definition: definition, references: references }]; + } + function isValidReferencePosition(node, searchSymbolName) { + if (node) { + switch (node.kind) { + case 69: + return node.getWidth() === searchSymbolName.length; + case 9: + if (isLiteralNameOfPropertyDeclarationOrIndexAccess(node) || + isNameOfExternalModuleImportOrDeclaration(node)) { + return node.getWidth() === searchSymbolName.length + 2; + } + break; + case 8: + if (isLiteralNameOfPropertyDeclarationOrIndexAccess(node)) { + return node.getWidth() === searchSymbolName.length; + } + break; + } + } + return false; + } + function getReferencesInNode(container, searchSymbol, searchText, searchLocation, searchMeaning, findInStrings, findInComments, result, symbolToIndex) { + var sourceFile = container.getSourceFile(); + var tripleSlashDirectivePrefixRegex = /^\/\/\/\s*= 0) { + var referencedSymbol = getReferencedSymbol(shorthandValueSymbol); + referencedSymbol.references.push(getReferenceEntryFromNode(referenceSymbolDeclaration.name)); + } + } + }); + } + return; + function getReferencedSymbol(symbol) { + var symbolId = ts.getSymbolId(symbol); + var index = symbolToIndex[symbolId]; + if (index === undefined) { + index = result.length; + symbolToIndex[symbolId] = index; + result.push({ + definition: getDefinition(symbol), + references: [] + }); + } + return result[index]; + } + function isInNonReferenceComment(sourceFile, position) { + return ts.isInCommentHelper(sourceFile, position, isNonReferenceComment); + function isNonReferenceComment(c) { + var commentText = sourceFile.text.substring(c.pos, c.end); + return !tripleSlashDirectivePrefixRegex.test(commentText); + } + } + } + function getReferencesForSuperKeyword(superKeyword) { + var searchSpaceNode = ts.getSuperContainer(superKeyword, false); + if (!searchSpaceNode) { + return undefined; + } + var staticFlag = 128; + switch (searchSpaceNode.kind) { + case 141: + case 140: + case 143: + case 142: + case 144: + case 145: + case 146: + staticFlag &= searchSpaceNode.flags; + searchSpaceNode = searchSpaceNode.parent; + break; + default: + return undefined; + } + var references = []; + var sourceFile = searchSpaceNode.getSourceFile(); + var possiblePositions = getPossibleSymbolReferencePositions(sourceFile, "super", searchSpaceNode.getStart(), searchSpaceNode.getEnd()); + ts.forEach(possiblePositions, function (position) { + cancellationToken.throwIfCancellationRequested(); + var node = ts.getTouchingWord(sourceFile, position); + if (!node || node.kind !== 95) { + return; + } + var container = ts.getSuperContainer(node, false); + if (container && (128 & container.flags) === staticFlag && container.parent.symbol === searchSpaceNode.symbol) { + references.push(getReferenceEntryFromNode(node)); + } + }); + var definition = getDefinition(searchSpaceNode.symbol); + return [{ definition: definition, references: references }]; + } + function getReferencesForThisKeyword(thisOrSuperKeyword, sourceFiles) { + var searchSpaceNode = ts.getThisContainer(thisOrSuperKeyword, false); + var staticFlag = 128; + switch (searchSpaceNode.kind) { + case 143: + case 142: + if (ts.isObjectLiteralMethod(searchSpaceNode)) { + break; + } + case 141: + case 140: + case 144: + case 145: + case 146: + staticFlag &= searchSpaceNode.flags; + searchSpaceNode = searchSpaceNode.parent; + break; + case 248: + if (ts.isExternalModule(searchSpaceNode)) { + return undefined; + } + case 213: + case 173: + break; + default: + return undefined; + } + var references = []; + var possiblePositions; + if (searchSpaceNode.kind === 248) { + ts.forEach(sourceFiles, function (sourceFile) { + possiblePositions = getPossibleSymbolReferencePositions(sourceFile, "this", sourceFile.getStart(), sourceFile.getEnd()); + getThisReferencesInFile(sourceFile, sourceFile, possiblePositions, references); + }); + } + else { + var sourceFile = searchSpaceNode.getSourceFile(); + possiblePositions = getPossibleSymbolReferencePositions(sourceFile, "this", searchSpaceNode.getStart(), searchSpaceNode.getEnd()); + getThisReferencesInFile(sourceFile, searchSpaceNode, possiblePositions, references); + } + return [{ + definition: { + containerKind: "", + containerName: "", + fileName: node.getSourceFile().fileName, + kind: ScriptElementKind.variableElement, + name: "this", + textSpan: ts.createTextSpanFromBounds(node.getStart(), node.getEnd()) + }, + references: references + }]; + function getThisReferencesInFile(sourceFile, searchSpaceNode, possiblePositions, result) { + ts.forEach(possiblePositions, function (position) { + cancellationToken.throwIfCancellationRequested(); + var node = ts.getTouchingWord(sourceFile, position); + if (!node || node.kind !== 97) { + return; + } + var container = ts.getThisContainer(node, false); + switch (searchSpaceNode.kind) { + case 173: + case 213: + if (searchSpaceNode.symbol === container.symbol) { + result.push(getReferenceEntryFromNode(node)); + } + break; + case 143: + case 142: + if (ts.isObjectLiteralMethod(searchSpaceNode) && searchSpaceNode.symbol === container.symbol) { + result.push(getReferenceEntryFromNode(node)); + } + break; + case 186: + case 214: + if (container.parent && searchSpaceNode.symbol === container.parent.symbol && (container.flags & 128) === staticFlag) { + result.push(getReferenceEntryFromNode(node)); + } + break; + case 248: + if (container.kind === 248 && !ts.isExternalModule(container)) { + result.push(getReferenceEntryFromNode(node)); + } + break; + } + }); + } + } + function populateSearchSymbolSet(symbol, location) { + var result = [symbol]; + if (isImportOrExportSpecifierImportSymbol(symbol)) { + result.push(typeChecker.getAliasedSymbol(symbol)); + } + if (isNameOfPropertyAssignment(location)) { + ts.forEach(getPropertySymbolsFromContextualType(location), function (contextualSymbol) { + ts.addRange(result, typeChecker.getRootSymbols(contextualSymbol)); + }); + var shorthandValueSymbol = typeChecker.getShorthandAssignmentValueSymbol(location.parent); + if (shorthandValueSymbol) { + result.push(shorthandValueSymbol); + } + } + ts.forEach(typeChecker.getRootSymbols(symbol), function (rootSymbol) { + if (rootSymbol !== symbol) { + result.push(rootSymbol); + } + if (rootSymbol.parent && rootSymbol.parent.flags & (32 | 64)) { + getPropertySymbolsFromBaseTypes(rootSymbol.parent, rootSymbol.getName(), result); + } + }); + return result; + } + function getPropertySymbolsFromBaseTypes(symbol, propertyName, result) { + if (symbol && symbol.flags & (32 | 64)) { + ts.forEach(symbol.getDeclarations(), function (declaration) { + if (declaration.kind === 214) { + getPropertySymbolFromTypeReference(ts.getClassExtendsHeritageClauseElement(declaration)); + ts.forEach(ts.getClassImplementsHeritageClauseElements(declaration), getPropertySymbolFromTypeReference); + } + else if (declaration.kind === 215) { + ts.forEach(ts.getInterfaceBaseTypeNodes(declaration), getPropertySymbolFromTypeReference); + } + }); + } + return; + function getPropertySymbolFromTypeReference(typeReference) { + if (typeReference) { + var type = typeChecker.getTypeAtLocation(typeReference); + if (type) { + var propertySymbol = typeChecker.getPropertyOfType(type, propertyName); + if (propertySymbol) { + result.push(propertySymbol); + } + getPropertySymbolsFromBaseTypes(type.symbol, propertyName, result); + } + } + } + } + function getRelatedSymbol(searchSymbols, referenceSymbol, referenceLocation) { + if (searchSymbols.indexOf(referenceSymbol) >= 0) { + return referenceSymbol; + } + if (isImportOrExportSpecifierImportSymbol(referenceSymbol)) { + var aliasedSymbol = typeChecker.getAliasedSymbol(referenceSymbol); + if (searchSymbols.indexOf(aliasedSymbol) >= 0) { + return aliasedSymbol; + } + } + if (isNameOfPropertyAssignment(referenceLocation)) { + return ts.forEach(getPropertySymbolsFromContextualType(referenceLocation), function (contextualSymbol) { + return ts.forEach(typeChecker.getRootSymbols(contextualSymbol), function (s) { return searchSymbols.indexOf(s) >= 0 ? s : undefined; }); + }); + } + return ts.forEach(typeChecker.getRootSymbols(referenceSymbol), function (rootSymbol) { + if (searchSymbols.indexOf(rootSymbol) >= 0) { + return rootSymbol; + } + if (rootSymbol.parent && rootSymbol.parent.flags & (32 | 64)) { + var result_3 = []; + getPropertySymbolsFromBaseTypes(rootSymbol.parent, rootSymbol.getName(), result_3); + return ts.forEach(result_3, function (s) { return searchSymbols.indexOf(s) >= 0 ? s : undefined; }); + } + return undefined; + }); + } + function getPropertySymbolsFromContextualType(node) { + if (isNameOfPropertyAssignment(node)) { + var objectLiteral = node.parent.parent; + var contextualType = typeChecker.getContextualType(objectLiteral); + var name_35 = node.text; + if (contextualType) { + if (contextualType.flags & 16384) { + var unionProperty = contextualType.getProperty(name_35); + if (unionProperty) { + return [unionProperty]; + } + else { + var result_4 = []; + ts.forEach(contextualType.types, function (t) { + var symbol = t.getProperty(name_35); + if (symbol) { + result_4.push(symbol); + } + }); + return result_4; + } + } + else { + var symbol_1 = contextualType.getProperty(name_35); + if (symbol_1) { + return [symbol_1]; + } + } + } + } + return undefined; + } + function getIntersectingMeaningFromDeclarations(meaning, declarations) { + if (declarations) { + var lastIterationMeaning; + do { + lastIterationMeaning = meaning; + for (var _i = 0; _i < declarations.length; _i++) { + var declaration = declarations[_i]; + var declarationMeaning = getMeaningFromDeclaration(declaration); + if (declarationMeaning & meaning) { + meaning |= declarationMeaning; + } + } + } while (meaning !== lastIterationMeaning); + } + return meaning; + } + } + function getReferenceEntryFromNode(node) { + var start = node.getStart(); + var end = node.getEnd(); + if (node.kind === 9) { + start += 1; + end -= 1; + } + return { + fileName: node.getSourceFile().fileName, + textSpan: ts.createTextSpanFromBounds(start, end), + isWriteAccess: isWriteAccess(node) + }; + } + function isWriteAccess(node) { + if (node.kind === 69 && ts.isDeclarationName(node)) { + return true; + } + var parent = node.parent; + if (parent) { + if (parent.kind === 180 || parent.kind === 179) { + return true; + } + else if (parent.kind === 181 && parent.left === node) { + var operator = parent.operatorToken.kind; + return 56 <= operator && operator <= 68; + } + } + return false; + } + function getNavigateToItems(searchValue, maxResultCount) { + synchronizeHostData(); + return ts.NavigateTo.getNavigateToItems(program, cancellationToken, searchValue, maxResultCount); + } + function containErrors(diagnostics) { + return ts.forEach(diagnostics, function (diagnostic) { return diagnostic.category === ts.DiagnosticCategory.Error; }); + } + function getEmitOutput(fileName) { + synchronizeHostData(); + var sourceFile = getValidSourceFile(fileName); + var outputFiles = []; + function writeFile(fileName, data, writeByteOrderMark) { + outputFiles.push({ + name: fileName, + writeByteOrderMark: writeByteOrderMark, + text: data + }); + } + var emitOutput = program.emit(sourceFile, writeFile, cancellationToken); + return { + outputFiles: outputFiles, + emitSkipped: emitOutput.emitSkipped + }; + } + function getMeaningFromDeclaration(node) { + switch (node.kind) { + case 138: + case 211: + case 163: + case 141: + case 140: + case 245: + case 246: + case 247: + case 143: + case 142: + case 144: + case 145: + case 146: + case 213: + case 173: + case 174: + case 244: + return 1; + case 137: + case 215: + case 216: + case 155: + return 2; + case 214: + case 217: + return 1 | 2; + case 218: + if (node.name.kind === 9) { + return 4 | 1; + } + else if (ts.getModuleInstanceState(node) === 1) { + return 4 | 1; + } + else { + return 4; + } + case 225: + case 226: + case 221: + case 222: + case 227: + case 228: + return 1 | 2 | 4; + case 248: + return 4 | 1; + } + return 1 | 2 | 4; + ts.Debug.fail("Unknown declaration type"); + } + function isTypeReference(node) { + if (ts.isRightSideOfQualifiedNameOrPropertyAccess(node)) { + node = node.parent; + } + return node.parent.kind === 151 || + (node.parent.kind === 188 && !ts.isExpressionWithTypeArgumentsInClassExtendsClause(node.parent)) || + node.kind === 97 && !ts.isExpression(node); + } + function isNamespaceReference(node) { + return isQualifiedNameNamespaceReference(node) || isPropertyAccessNamespaceReference(node); + } + function isPropertyAccessNamespaceReference(node) { + var root = node; + var isLastClause = true; + if (root.parent.kind === 166) { + while (root.parent && root.parent.kind === 166) { + root = root.parent; + } + isLastClause = root.name === node; + } + if (!isLastClause && root.parent.kind === 188 && root.parent.parent.kind === 243) { + var decl = root.parent.parent.parent; + return (decl.kind === 214 && root.parent.parent.token === 106) || + (decl.kind === 215 && root.parent.parent.token === 83); + } + return false; + } + function isQualifiedNameNamespaceReference(node) { + var root = node; + var isLastClause = true; + if (root.parent.kind === 135) { + while (root.parent && root.parent.kind === 135) { + root = root.parent; + } + isLastClause = root.right === node; + } + return root.parent.kind === 151 && !isLastClause; + } + function isInRightSideOfImport(node) { + while (node.parent.kind === 135) { + node = node.parent; + } + return ts.isInternalModuleImportEqualsDeclaration(node.parent) && node.parent.moduleReference === node; + } + function getMeaningFromRightHandSideOfImportEquals(node) { + ts.Debug.assert(node.kind === 69); + if (node.parent.kind === 135 && + node.parent.right === node && + node.parent.parent.kind === 221) { + return 1 | 2 | 4; + } + return 4; + } + function getMeaningFromLocation(node) { + if (node.parent.kind === 227) { + return 1 | 2 | 4; + } + else if (isInRightSideOfImport(node)) { + return getMeaningFromRightHandSideOfImportEquals(node); + } + else if (ts.isDeclarationName(node)) { + return getMeaningFromDeclaration(node.parent); + } + else if (isTypeReference(node)) { + return 2; + } + else if (isNamespaceReference(node)) { + return 4; + } + else { + return 1; + } + } + function getSignatureHelpItems(fileName, position) { + synchronizeHostData(); + var sourceFile = getValidSourceFile(fileName); + return ts.SignatureHelp.getSignatureHelpItems(program, sourceFile, position, cancellationToken); + } + function getSourceFile(fileName) { + return syntaxTreeCache.getCurrentSourceFile(fileName); + } + function getNameOrDottedNameSpan(fileName, startPos, endPos) { + var sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName); + var node = ts.getTouchingPropertyName(sourceFile, startPos); + if (!node) { + return; + } + switch (node.kind) { + case 166: + case 135: + case 9: + case 84: + case 99: + case 93: + case 95: + case 97: + case 69: + break; + default: + return; + } + var nodeForStartPos = node; + while (true) { + if (isRightSideOfPropertyAccess(nodeForStartPos) || isRightSideOfQualifiedName(nodeForStartPos)) { + nodeForStartPos = nodeForStartPos.parent; + } + else if (isNameOfModuleDeclaration(nodeForStartPos)) { + if (nodeForStartPos.parent.parent.kind === 218 && + nodeForStartPos.parent.parent.body === nodeForStartPos.parent) { + nodeForStartPos = nodeForStartPos.parent.parent.name; + } + else { + break; + } + } + else { + break; + } + } + return ts.createTextSpanFromBounds(nodeForStartPos.getStart(), node.getEnd()); + } + function getBreakpointStatementAtPosition(fileName, position) { + var sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName); + return ts.BreakpointResolver.spanInSourceFileAtLocation(sourceFile, position); + } + function getNavigationBarItems(fileName) { + var sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName); + return ts.NavigationBar.getNavigationBarItems(sourceFile); + } + function getSemanticClassifications(fileName, span) { + return convertClassifications(getEncodedSemanticClassifications(fileName, span)); + } + function checkForClassificationCancellation(kind) { + switch (kind) { + case 218: + case 214: + case 215: + case 213: + cancellationToken.throwIfCancellationRequested(); + } + } + function getEncodedSemanticClassifications(fileName, span) { + synchronizeHostData(); + var sourceFile = getValidSourceFile(fileName); + var typeChecker = program.getTypeChecker(); + var result = []; + var classifiableNames = program.getClassifiableNames(); + processNode(sourceFile); + return { spans: result, endOfLineState: 0 }; + function pushClassification(start, length, type) { + result.push(start); + result.push(length); + result.push(type); + } + function classifySymbol(symbol, meaningAtPosition) { + var flags = symbol.getFlags(); + if ((flags & 788448) === 0) { + return; + } + if (flags & 32) { + return 11; + } + else if (flags & 384) { + return 12; + } + else if (flags & 524288) { + return 16; + } + else if (meaningAtPosition & 2) { + if (flags & 64) { + return 13; + } + else if (flags & 262144) { + return 15; + } + } + else if (flags & 1536) { + if (meaningAtPosition & 4 || + (meaningAtPosition & 1 && hasValueSideModule(symbol))) { + return 14; + } + } + return undefined; + function hasValueSideModule(symbol) { + return ts.forEach(symbol.declarations, function (declaration) { + return declaration.kind === 218 && + ts.getModuleInstanceState(declaration) === 1; + }); + } + } + function processNode(node) { + if (node && ts.textSpanIntersectsWith(span, node.getFullStart(), node.getFullWidth())) { + var kind = node.kind; + checkForClassificationCancellation(kind); + if (kind === 69 && !ts.nodeIsMissing(node)) { + var identifier = node; + if (classifiableNames[identifier.text]) { + var symbol = typeChecker.getSymbolAtLocation(node); + if (symbol) { + var type = classifySymbol(symbol, getMeaningFromLocation(node)); + if (type) { + pushClassification(node.getStart(), node.getWidth(), type); + } + } + } + } + ts.forEachChild(node, processNode); + } + } + } + function getClassificationTypeName(type) { + switch (type) { + case 1: return ClassificationTypeNames.comment; + case 2: return ClassificationTypeNames.identifier; + case 3: return ClassificationTypeNames.keyword; + case 4: return ClassificationTypeNames.numericLiteral; + case 5: return ClassificationTypeNames.operator; + case 6: return ClassificationTypeNames.stringLiteral; + case 8: return ClassificationTypeNames.whiteSpace; + case 9: return ClassificationTypeNames.text; + case 10: return ClassificationTypeNames.punctuation; + case 11: return ClassificationTypeNames.className; + case 12: return ClassificationTypeNames.enumName; + case 13: return ClassificationTypeNames.interfaceName; + case 14: return ClassificationTypeNames.moduleName; + case 15: return ClassificationTypeNames.typeParameterName; + case 16: return ClassificationTypeNames.typeAliasName; + case 17: return ClassificationTypeNames.parameterName; + case 18: return ClassificationTypeNames.docCommentTagName; + } + } + function convertClassifications(classifications) { + ts.Debug.assert(classifications.spans.length % 3 === 0); + var dense = classifications.spans; + var result = []; + for (var i = 0, n = dense.length; i < n; i += 3) { + result.push({ + textSpan: ts.createTextSpan(dense[i], dense[i + 1]), + classificationType: getClassificationTypeName(dense[i + 2]) + }); + } + return result; + } + function getSyntacticClassifications(fileName, span) { + return convertClassifications(getEncodedSyntacticClassifications(fileName, span)); + } + function getEncodedSyntacticClassifications(fileName, span) { + var sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName); + 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 result = []; + processElement(sourceFile); + return { spans: result, endOfLineState: 0 }; + function pushClassification(start, length, type) { + result.push(start); + result.push(length); + result.push(type); + } + function classifyLeadingTriviaAndGetTokenStart(token) { + triviaScanner.setTextPos(token.pos); + while (true) { + var start = triviaScanner.getTextPos(); + if (!ts.couldStartTrivia(sourceFile.text, start)) { + return start; + } + var kind = triviaScanner.scan(); + var end = triviaScanner.getTextPos(); + var width = end - start; + if (!ts.isTrivia(kind)) { + return start; + } + if (kind === 4 || kind === 5) { + continue; + } + if (ts.isComment(kind)) { + classifyComment(token, kind, start, width); + triviaScanner.setTextPos(end); + continue; + } + if (kind === 7) { + var text = sourceFile.text; + var ch = text.charCodeAt(start); + if (ch === 60 || ch === 62) { + pushClassification(start, width, 1); + continue; + } + ts.Debug.assert(ch === 61); + classifyDisabledMergeCode(text, start, end); + } + } + } + function classifyComment(token, kind, start, width) { + if (kind === 3) { + var docCommentAndDiagnostics = ts.parseIsolatedJSDocComment(sourceFile.text, start, width); + if (docCommentAndDiagnostics && docCommentAndDiagnostics.jsDocComment) { + docCommentAndDiagnostics.jsDocComment.parent = token; + classifyJSDocComment(docCommentAndDiagnostics.jsDocComment); + return; + } + } + pushCommentRange(start, width); + } + function pushCommentRange(start, width) { + pushClassification(start, width, 1); + } + function classifyJSDocComment(docComment) { + var pos = docComment.pos; + for (var _i = 0, _a = docComment.tags; _i < _a.length; _i++) { + var tag = _a[_i]; + if (tag.pos !== pos) { + pushCommentRange(pos, tag.pos - pos); + } + pushClassification(tag.atToken.pos, tag.atToken.end - tag.atToken.pos, 10); + pushClassification(tag.tagName.pos, tag.tagName.end - tag.tagName.pos, 18); + pos = tag.tagName.end; + switch (tag.kind) { + case 267: + processJSDocParameterTag(tag); + break; + case 270: + processJSDocTemplateTag(tag); + break; + case 269: + processElement(tag.typeExpression); + break; + case 268: + processElement(tag.typeExpression); + break; + } + pos = tag.end; + } + if (pos !== docComment.end) { + pushCommentRange(pos, docComment.end - pos); + } + return; + function processJSDocParameterTag(tag) { + if (tag.preParameterName) { + pushCommentRange(pos, tag.preParameterName.pos - pos); + pushClassification(tag.preParameterName.pos, tag.preParameterName.end - tag.preParameterName.pos, 17); + pos = tag.preParameterName.end; + } + if (tag.typeExpression) { + pushCommentRange(pos, tag.typeExpression.pos - pos); + processElement(tag.typeExpression); + pos = tag.typeExpression.end; + } + if (tag.postParameterName) { + pushCommentRange(pos, tag.postParameterName.pos - pos); + pushClassification(tag.postParameterName.pos, tag.postParameterName.end - tag.postParameterName.pos, 17); + pos = tag.postParameterName.end; + } + } + } + function processJSDocTemplateTag(tag) { + for (var _i = 0, _a = tag.getChildren(); _i < _a.length; _i++) { + var child = _a[_i]; + processElement(child); + } + } + function classifyDisabledMergeCode(text, start, end) { + for (var i = start; i < end; i++) { + if (ts.isLineBreak(text.charCodeAt(i))) { + break; + } + } + pushClassification(start, i - start, 1); + mergeConflictScanner.setTextPos(i); + while (mergeConflictScanner.getTextPos() < end) { + classifyDisabledCodeToken(); + } + } + function classifyDisabledCodeToken() { + var start = mergeConflictScanner.getTextPos(); + var tokenKind = mergeConflictScanner.scan(); + var end = mergeConflictScanner.getTextPos(); + var type = classifyTokenType(tokenKind); + if (type) { + pushClassification(start, end - start, type); + } + } + function classifyToken(token) { + if (ts.nodeIsMissing(token)) { + return; + } + var tokenStart = classifyLeadingTriviaAndGetTokenStart(token); + var tokenWidth = token.end - tokenStart; + ts.Debug.assert(tokenWidth >= 0); + if (tokenWidth > 0) { + var type = classifyTokenType(token.kind, token); + if (type) { + pushClassification(tokenStart, tokenWidth, type); + } + } + } + function classifyTokenType(tokenKind, token) { + if (ts.isKeyword(tokenKind)) { + return 3; + } + if (tokenKind === 25 || tokenKind === 27) { + if (token && ts.getTypeArgumentOrTypeParameterList(token.parent)) { + return 10; + } + } + if (ts.isPunctuation(tokenKind)) { + if (token) { + if (tokenKind === 56) { + if (token.parent.kind === 211 || + token.parent.kind === 141 || + token.parent.kind === 138) { + return 5; + } + } + if (token.parent.kind === 181 || + token.parent.kind === 179 || + token.parent.kind === 180 || + token.parent.kind === 182) { + return 5; + } + } + return 10; + } + else if (tokenKind === 8) { + return 4; + } + else if (tokenKind === 9) { + return 6; + } + else if (tokenKind === 10) { + return 6; + } + else if (ts.isTemplateLiteralKind(tokenKind)) { + return 6; + } + else if (tokenKind === 69) { + if (token) { + switch (token.parent.kind) { + case 214: + if (token.parent.name === token) { + return 11; + } + return; + case 137: + if (token.parent.name === token) { + return 15; + } + return; + case 215: + if (token.parent.name === token) { + return 13; + } + return; + case 217: + if (token.parent.name === token) { + return 12; + } + return; + case 218: + if (token.parent.name === token) { + return 14; + } + return; + case 138: + if (token.parent.name === token) { + return 17; + } + return; + } + } + return 2; + } + } + function processElement(element) { + if (!element) { + return; + } + if (ts.decodedTextSpanIntersectsWith(spanStart, spanLength, element.pos, element.getFullWidth())) { + checkForClassificationCancellation(element.kind); + var children = element.getChildren(sourceFile); + for (var i = 0, n = children.length; i < n; i++) { + var child = children[i]; + if (ts.isToken(child)) { + classifyToken(child); + } + else { + processElement(child); + } + } + } + } + } + function getOutliningSpans(fileName) { + var sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName); + return ts.OutliningElementsCollector.collectElements(sourceFile); + } + function getBraceMatchingAtPosition(fileName, position) { + var sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName); + var result = []; + var token = ts.getTouchingToken(sourceFile, position); + if (token.getStart(sourceFile) === position) { + var matchKind = getMatchingTokenKind(token); + if (matchKind) { + var parentElement = token.parent; + var childNodes = parentElement.getChildren(sourceFile); + for (var _i = 0; _i < childNodes.length; _i++) { + var current = childNodes[_i]; + if (current.kind === matchKind) { + var range1 = ts.createTextSpan(token.getStart(sourceFile), token.getWidth(sourceFile)); + var range2 = ts.createTextSpan(current.getStart(sourceFile), current.getWidth(sourceFile)); + if (range1.start < range2.start) { + result.push(range1, range2); + } + else { + result.push(range2, range1); + } + break; + } + } + } + } + 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; + } + return undefined; + } + } + function getIndentationAtPosition(fileName, position, editorOptions) { + var start = new Date().getTime(); + var sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName); + log("getIndentationAtPosition: getCurrentSourceFile: " + (new Date().getTime() - start)); + start = new Date().getTime(); + var result = ts.formatting.SmartIndenter.getIndentation(position, sourceFile, editorOptions); + log("getIndentationAtPosition: computeIndentation : " + (new Date().getTime() - start)); + return result; + } + function getFormattingEditsForRange(fileName, start, end, options) { + var sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName); + return ts.formatting.formatSelection(start, end, sourceFile, getRuleProvider(options), options); + } + function getFormattingEditsForDocument(fileName, options) { + var sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName); + return ts.formatting.formatDocument(sourceFile, getRuleProvider(options), options); + } + function getFormattingEditsAfterKeystroke(fileName, position, key, options) { + var sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName); + if (key === "}") { + return ts.formatting.formatOnClosingCurly(position, sourceFile, getRuleProvider(options), options); + } + else if (key === ";") { + return ts.formatting.formatOnSemicolon(position, sourceFile, getRuleProvider(options), options); + } + else if (key === "\n") { + return ts.formatting.formatOnEnter(position, sourceFile, getRuleProvider(options), options); + } + return []; + } + function getDocCommentTemplateAtPosition(fileName, position) { + var start = new Date().getTime(); + var sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName); + if (ts.isInString(sourceFile, position) || ts.isInComment(sourceFile, position) || ts.hasDocComment(sourceFile, position)) { + return undefined; + } + var tokenAtPos = ts.getTokenAtPosition(sourceFile, position); + var tokenStart = tokenAtPos.getStart(); + if (!tokenAtPos || tokenStart < position) { + return undefined; + } + var commentOwner; + findOwner: for (commentOwner = tokenAtPos; commentOwner; commentOwner = commentOwner.parent) { + switch (commentOwner.kind) { + case 213: + case 143: + case 144: + case 214: + case 193: + break findOwner; + case 248: + return undefined; + case 218: + if (commentOwner.parent.kind === 218) { + return undefined; + } + break findOwner; + } + } + if (!commentOwner || commentOwner.getStart() < position) { + return undefined; + } + var parameters = getParametersForJsDocOwningNode(commentOwner); + var posLineAndChar = sourceFile.getLineAndCharacterOfPosition(position); + var lineStart = sourceFile.getLineStarts()[posLineAndChar.line]; + var indentationStr = sourceFile.text.substr(lineStart, posLineAndChar.character); + var newLine = host.getNewLine ? host.getNewLine() : "\r\n"; + var docParams = ""; + for (var i = 0, numParams = parameters.length; i < numParams; i++) { + var currentName = parameters[i].name; + var paramName = currentName.kind === 69 ? + currentName.text : + "param" + i; + docParams += indentationStr + " * @param " + paramName + newLine; + } + var preamble = "/**" + newLine + + indentationStr + " * "; + var result = preamble + newLine + + docParams + + indentationStr + " */" + + (tokenStart === position ? newLine + indentationStr : ""); + return { newText: result, caretOffset: preamble.length }; + } + function getParametersForJsDocOwningNode(commentOwner) { + if (ts.isFunctionLike(commentOwner)) { + return commentOwner.parameters; + } + if (commentOwner.kind === 193) { + var varStatement = commentOwner; + var varDeclarations = varStatement.declarationList.declarations; + if (varDeclarations.length === 1 && varDeclarations[0].initializer) { + return getParametersFromRightHandSideOfAssignment(varDeclarations[0].initializer); + } + } + return emptyArray; + } + function getParametersFromRightHandSideOfAssignment(rightHandSide) { + while (rightHandSide.kind === 172) { + rightHandSide = rightHandSide.expression; + } + switch (rightHandSide.kind) { + case 173: + case 174: + return rightHandSide.parameters; + case 186: + for (var _i = 0, _a = rightHandSide.members; _i < _a.length; _i++) { + var member = _a[_i]; + if (member.kind === 144) { + return member.parameters; + } + } + break; + } + return emptyArray; + } + function getTodoComments(fileName, descriptors) { + synchronizeHostData(); + var sourceFile = getValidSourceFile(fileName); + cancellationToken.throwIfCancellationRequested(); + var fileContents = sourceFile.text; + var result = []; + if (descriptors.length > 0) { + var regExp = getTodoCommentsRegExp(); + var matchArray; + while (matchArray = regExp.exec(fileContents)) { + cancellationToken.throwIfCancellationRequested(); + var firstDescriptorCaptureIndex = 3; + ts.Debug.assert(matchArray.length === descriptors.length + firstDescriptorCaptureIndex); + var preamble = matchArray[1]; + var matchPosition = matchArray.index + preamble.length; + var token = ts.getTokenAtPosition(sourceFile, matchPosition); + if (!isInsideComment(sourceFile, token, matchPosition)) { + continue; + } + var descriptor = undefined; + for (var i = 0, n = descriptors.length; i < n; i++) { + if (matchArray[i + firstDescriptorCaptureIndex]) { + descriptor = descriptors[i]; + } + } + ts.Debug.assert(descriptor !== undefined); + if (isLetterOrDigit(fileContents.charCodeAt(matchPosition + descriptor.text.length))) { + continue; + } + var message = matchArray[2]; + result.push({ + descriptor: descriptor, + message: message, + position: matchPosition + }); + } + } + return result; + function escapeRegExp(str) { + return str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&"); + } + function getTodoCommentsRegExp() { + var singleLineCommentStart = /(?:\/\/+\s*)/.source; + var multiLineCommentStart = /(?:\/\*+\s*)/.source; + var anyNumberOfSpacesAndAsterixesAtStartOfLine = /(?:^(?:\s|\*)*)/.source; + var preamble = "(" + anyNumberOfSpacesAndAsterixesAtStartOfLine + "|" + singleLineCommentStart + "|" + multiLineCommentStart + ")"; + var literals = "(?:" + ts.map(descriptors, function (d) { return "(" + escapeRegExp(d.text) + ")"; }).join("|") + ")"; + var endOfLineOrEndOfComment = /(?:$|\*\/)/.source; + var messageRemainder = /(?:.*?)/.source; + var messagePortion = "(" + literals + messageRemainder + ")"; + var regExpString = preamble + messagePortion + endOfLineOrEndOfComment; + return new RegExp(regExpString, "gim"); + } + function isLetterOrDigit(char) { + return (char >= 97 && char <= 122) || + (char >= 65 && char <= 90) || + (char >= 48 && char <= 57); + } + } + function getRenameInfo(fileName, position) { + synchronizeHostData(); + var sourceFile = getValidSourceFile(fileName); + var typeChecker = program.getTypeChecker(); + var node = ts.getTouchingWord(sourceFile, position); + if (node && node.kind === 69) { + var symbol = typeChecker.getSymbolAtLocation(node); + if (symbol) { + var declarations = symbol.getDeclarations(); + if (declarations && declarations.length > 0) { + var defaultLibFileName = host.getDefaultLibFileName(host.getCompilationSettings()); + if (defaultLibFileName) { + for (var _i = 0; _i < declarations.length; _i++) { + var current = declarations[_i]; + var sourceFile_2 = current.getSourceFile(); + var canonicalName = getCanonicalFileName(ts.normalizePath(sourceFile_2.fileName)); + if (sourceFile_2 && getCanonicalFileName(ts.normalizePath(sourceFile_2.fileName)) === getCanonicalFileName(ts.normalizePath(defaultLibFileName))) { + return getRenameInfoError(ts.getLocaleSpecificMessage(ts.Diagnostics.You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library)); + } + } + } + var displayName = ts.stripQuotes(ts.getDeclaredName(typeChecker, symbol, node)); + var kind = getSymbolKind(symbol, node); + if (kind) { + return { + canRename: true, + localizedErrorMessage: undefined, + displayName: displayName, + fullDisplayName: typeChecker.getFullyQualifiedName(symbol), + kind: kind, + kindModifiers: getSymbolModifiers(symbol), + triggerSpan: ts.createTextSpan(node.getStart(), node.getWidth()) + }; + } + } + } + } + return getRenameInfoError(ts.getLocaleSpecificMessage(ts.Diagnostics.You_cannot_rename_this_element)); + function getRenameInfoError(localizedErrorMessage) { + return { + canRename: false, + localizedErrorMessage: localizedErrorMessage, + displayName: undefined, + fullDisplayName: undefined, + kind: undefined, + kindModifiers: undefined, + triggerSpan: undefined + }; + } + } + return { + dispose: dispose, + cleanupSemanticCache: cleanupSemanticCache, + getSyntacticDiagnostics: getSyntacticDiagnostics, + getSemanticDiagnostics: getSemanticDiagnostics, + getCompilerOptionsDiagnostics: getCompilerOptionsDiagnostics, + getSyntacticClassifications: getSyntacticClassifications, + getSemanticClassifications: getSemanticClassifications, + getEncodedSyntacticClassifications: getEncodedSyntacticClassifications, + getEncodedSemanticClassifications: getEncodedSemanticClassifications, + getCompletionsAtPosition: getCompletionsAtPosition, + getCompletionEntryDetails: getCompletionEntryDetails, + getSignatureHelpItems: getSignatureHelpItems, + getQuickInfoAtPosition: getQuickInfoAtPosition, + getDefinitionAtPosition: getDefinitionAtPosition, + getTypeDefinitionAtPosition: getTypeDefinitionAtPosition, + getReferencesAtPosition: getReferencesAtPosition, + findReferences: findReferences, + getOccurrencesAtPosition: getOccurrencesAtPosition, + getDocumentHighlights: getDocumentHighlights, + getNameOrDottedNameSpan: getNameOrDottedNameSpan, + getBreakpointStatementAtPosition: getBreakpointStatementAtPosition, + getNavigateToItems: getNavigateToItems, + getRenameInfo: getRenameInfo, + findRenameLocations: findRenameLocations, + getNavigationBarItems: getNavigationBarItems, + getOutliningSpans: getOutliningSpans, + getTodoComments: getTodoComments, + getBraceMatchingAtPosition: getBraceMatchingAtPosition, + getIndentationAtPosition: getIndentationAtPosition, + getFormattingEditsForRange: getFormattingEditsForRange, + getFormattingEditsForDocument: getFormattingEditsForDocument, + getFormattingEditsAfterKeystroke: getFormattingEditsAfterKeystroke, + getDocCommentTemplateAtPosition: getDocCommentTemplateAtPosition, + getEmitOutput: getEmitOutput, + getSourceFile: getSourceFile, + getProgram: getProgram + }; + } + ts.createLanguageService = createLanguageService; + function getNameTable(sourceFile) { + if (!sourceFile.nameTable) { + initializeNameTable(sourceFile); + } + return sourceFile.nameTable; + } + ts.getNameTable = getNameTable; + function initializeNameTable(sourceFile) { + var nameTable = {}; + walk(sourceFile); + sourceFile.nameTable = nameTable; + function walk(node) { + switch (node.kind) { + case 69: + nameTable[node.text] = node.text; + break; + case 9: + case 8: + if (ts.isDeclarationName(node) || + node.parent.kind === 232 || + isArgumentOfElementAccessExpression(node)) { + nameTable[node.text] = node.text; + } + break; + default: + ts.forEachChild(node, walk); + } + } + } + function isArgumentOfElementAccessExpression(node) { + return node && + node.parent && + node.parent.kind === 167 && + node.parent.argumentExpression === node; + } + function createClassifier() { + var scanner = ts.createScanner(2, false); + var noRegexTable = []; + noRegexTable[69] = true; + noRegexTable[9] = true; + noRegexTable[8] = true; + noRegexTable[10] = true; + noRegexTable[97] = true; + noRegexTable[41] = true; + noRegexTable[42] = true; + noRegexTable[18] = true; + noRegexTable[20] = true; + noRegexTable[16] = true; + noRegexTable[99] = true; + noRegexTable[84] = true; + var templateStack = []; + function canFollow(keyword1, keyword2) { + if (ts.isAccessibilityModifier(keyword1)) { + if (keyword2 === 123 || + keyword2 === 129 || + keyword2 === 121 || + keyword2 === 113) { + return true; + } + return false; + } + return true; + } + function convertClassifications(classifications, text) { + var entries = []; + var dense = classifications.spans; + var lastEnd = 0; + for (var i = 0, n = dense.length; i < n; i += 3) { + var start = dense[i]; + var length_3 = dense[i + 1]; + var type = dense[i + 2]; + if (lastEnd >= 0) { + var whitespaceLength_1 = start - lastEnd; + if (whitespaceLength_1 > 0) { + entries.push({ length: whitespaceLength_1, classification: TokenClass.Whitespace }); + } + } + entries.push({ length: length_3, classification: convertClassification(type) }); + lastEnd = start + length_3; + } + var whitespaceLength = text.length - lastEnd; + if (whitespaceLength > 0) { + entries.push({ length: whitespaceLength, classification: TokenClass.Whitespace }); + } + return { entries: entries, finalLexState: classifications.endOfLineState }; + } + function convertClassification(type) { + switch (type) { + case 1: return TokenClass.Comment; + case 3: return TokenClass.Keyword; + case 4: return TokenClass.NumberLiteral; + case 5: return TokenClass.Operator; + case 6: return TokenClass.StringLiteral; + case 8: return TokenClass.Whitespace; + case 10: return TokenClass.Punctuation; + case 2: + case 11: + case 12: + case 13: + case 14: + case 15: + case 16: + case 9: + case 17: + default: + return TokenClass.Identifier; + } + } + function getClassificationsForLine(text, lexState, syntacticClassifierAbsent) { + return convertClassifications(getEncodedLexicalClassifications(text, lexState, syntacticClassifierAbsent), text); + } + function getEncodedLexicalClassifications(text, lexState, syntacticClassifierAbsent) { + var offset = 0; + var token = 0; + var lastNonTriviaToken = 0; + while (templateStack.length > 0) { + templateStack.pop(); + } + switch (lexState) { + case 3: + text = '"\\\n' + text; + offset = 3; + break; + case 2: + text = "'\\\n" + text; + offset = 3; + break; + case 1: + text = "/*\n" + text; + offset = 3; + break; + case 4: + text = "`\n" + text; + offset = 2; + break; + case 5: + text = "}\n" + text; + offset = 2; + case 6: + templateStack.push(12); + break; + } + scanner.setText(text); + var result = { + endOfLineState: 0, + spans: [] + }; + var angleBracketStack = 0; + do { + token = scanner.scan(); + if (!ts.isTrivia(token)) { + if ((token === 39 || token === 61) && !noRegexTable[lastNonTriviaToken]) { + if (scanner.reScanSlashToken() === 10) { + token = 10; + } + } + else if (lastNonTriviaToken === 21 && isKeyword(token)) { + token = 69; + } + else if (isKeyword(lastNonTriviaToken) && isKeyword(token) && !canFollow(lastNonTriviaToken, token)) { + token = 69; + } + else if (lastNonTriviaToken === 69 && + token === 25) { + angleBracketStack++; + } + else if (token === 27 && angleBracketStack > 0) { + angleBracketStack--; + } + else if (token === 117 || + token === 130 || + token === 128 || + token === 120 || + token === 131) { + if (angleBracketStack > 0 && !syntacticClassifierAbsent) { + token = 69; + } + } + else if (token === 12) { + templateStack.push(token); + } + else if (token === 15) { + if (templateStack.length > 0) { + templateStack.push(token); + } + } + else if (token === 16) { + if (templateStack.length > 0) { + var lastTemplateStackToken = ts.lastOrUndefined(templateStack); + if (lastTemplateStackToken === 12) { + token = scanner.reScanTemplateToken(); + if (token === 14) { + templateStack.pop(); + } + else { + ts.Debug.assert(token === 13, "Should have been a template middle. Was " + token); + } + } + else { + ts.Debug.assert(lastTemplateStackToken === 15, "Should have been an open brace. Was: " + token); + templateStack.pop(); + } + } + } + lastNonTriviaToken = token; + } + processToken(); + } while (token !== 1); + return result; + function processToken() { + var start = scanner.getTokenPos(); + var end = scanner.getTextPos(); + addResult(start, end, classFromKind(token)); + if (end >= text.length) { + if (token === 9) { + var tokenText = scanner.getTokenText(); + if (scanner.isUnterminated()) { + var lastCharIndex = tokenText.length - 1; + var numBackslashes = 0; + while (tokenText.charCodeAt(lastCharIndex - numBackslashes) === 92) { + numBackslashes++; + } + if (numBackslashes & 1) { + var quoteChar = tokenText.charCodeAt(0); + result.endOfLineState = quoteChar === 34 + ? 3 + : 2; + } + } + } + else if (token === 3) { + if (scanner.isUnterminated()) { + result.endOfLineState = 1; + } + } + else if (ts.isTemplateLiteralKind(token)) { + if (scanner.isUnterminated()) { + if (token === 14) { + result.endOfLineState = 5; + } + else if (token === 11) { + result.endOfLineState = 4; + } + else { + ts.Debug.fail("Only 'NoSubstitutionTemplateLiteral's and 'TemplateTail's can be unterminated; got SyntaxKind #" + token); + } + } + } + else if (templateStack.length > 0 && ts.lastOrUndefined(templateStack) === 12) { + result.endOfLineState = 6; + } + } + } + function addResult(start, end, classification) { + if (classification === 8) { + return; + } + if (start === 0 && offset > 0) { + start += offset; + } + start -= offset; + end -= offset; + var length = end - start; + if (length > 0) { + result.spans.push(start); + result.spans.push(length); + result.spans.push(classification); + } + } + } + function isBinaryExpressionOperatorToken(token) { + switch (token) { + case 37: + case 39: + case 40: + case 35: + case 36: + case 43: + case 44: + case 45: + case 25: + case 27: + case 28: + case 29: + case 91: + case 90: + case 116: + case 30: + case 31: + case 32: + case 33: + case 46: + case 48: + case 47: + case 51: + case 52: + case 67: + case 66: + case 68: + case 63: + case 64: + case 65: + case 57: + case 58: + case 59: + case 61: + case 62: + case 56: + case 24: + return true; + default: + return false; + } + } + function isPrefixUnaryExpressionOperatorToken(token) { + switch (token) { + case 35: + case 36: + case 50: + case 49: + case 41: + case 42: + return true; + default: + return false; + } + } + function isKeyword(token) { + return token >= 70 && token <= 134; + } + function classFromKind(token) { + if (isKeyword(token)) { + return 3; + } + else if (isBinaryExpressionOperatorToken(token) || isPrefixUnaryExpressionOperatorToken(token)) { + return 5; + } + else if (token >= 15 && token <= 68) { + return 10; + } + switch (token) { + case 8: + return 4; + case 9: + return 6; + case 10: + return 7; + case 7: + case 3: + case 2: + return 1; + case 5: + case 4: + return 8; + case 69: + default: + if (ts.isTemplateLiteralKind(token)) { + return 6; + } + return 2; + } + } + return { + getClassificationsForLine: getClassificationsForLine, + getEncodedLexicalClassifications: getEncodedLexicalClassifications + }; + } + ts.createClassifier = createClassifier; + function getDefaultLibFilePath(options) { + if (typeof __dirname !== "undefined") { + return __dirname + ts.directorySeparator + ts.getDefaultLibFileName(options); + } + throw new Error("getDefaultLibFilePath is only supported when consumed as a node module. "); + } + ts.getDefaultLibFilePath = getDefaultLibFilePath; + function initializeServices() { + ts.objectAllocator = { + getNodeConstructor: function (kind) { + function Node(pos, end) { + this.pos = pos; + this.end = end; + this.flags = 0; + this.parent = undefined; + } + var proto = kind === 248 ? new SourceFileObject() : new NodeObject(); + proto.kind = kind; + Node.prototype = proto; + return Node; + }, + getSymbolConstructor: function () { return SymbolObject; }, + getTypeConstructor: function () { return TypeObject; }, + getSignatureConstructor: function () { return SignatureObject; } + }; + } + initializeServices(); +})(ts || (ts = {})); +var ts; +(function (ts) { + var server; + (function (server) { + var spaceCache = []; + function generateSpaces(n) { + if (!spaceCache[n]) { + var strBuilder = ""; + for (var i = 0; i < n; i++) { + strBuilder += " "; + } + spaceCache[n] = strBuilder; + } + return spaceCache[n]; + } + server.generateSpaces = generateSpaces; + function generateIndentString(n, editorOptions) { + if (editorOptions.ConvertTabsToSpaces) { + return generateSpaces(n); + } + else { + var result = ""; + for (var i = 0; i < Math.floor(n / editorOptions.TabSize); i++) { + result += "\t"; + } + for (var i = 0; i < n % editorOptions.TabSize; i++) { + result += " "; + } + return result; + } + } + server.generateIndentString = generateIndentString; + function compareNumber(a, b) { + if (a < b) { + return -1; + } + else if (a === b) { + return 0; + } + else + return 1; + } + function compareFileStart(a, b) { + if (a.file < b.file) { + return -1; + } + else if (a.file == b.file) { + var n = compareNumber(a.start.line, b.start.line); + if (n === 0) { + return compareNumber(a.start.offset, b.start.offset); + } + else + return n; + } + else { + return 1; + } + } + function formatDiag(fileName, project, diag) { + return { + start: project.compilerService.host.positionToLineOffset(fileName, diag.start), + end: project.compilerService.host.positionToLineOffset(fileName, diag.start + diag.length), + text: ts.flattenDiagnosticMessageText(diag.messageText, "\n") + }; + } + function allEditsBeforePos(edits, pos) { + for (var i = 0, len = edits.length; i < len; i++) { + if (ts.textSpanEnd(edits[i].span) >= pos) { + return false; + } + } + return true; + } + var CommandNames; + (function (CommandNames) { + CommandNames.Brace = "brace"; + CommandNames.Change = "change"; + CommandNames.Close = "close"; + CommandNames.Completions = "completions"; + CommandNames.CompletionDetails = "completionEntryDetails"; + CommandNames.Configure = "configure"; + CommandNames.Definition = "definition"; + CommandNames.Exit = "exit"; + CommandNames.Format = "format"; + CommandNames.Formatonkey = "formatonkey"; + CommandNames.Geterr = "geterr"; + CommandNames.GeterrForProject = "geterrForProject"; + CommandNames.NavBar = "navbar"; + CommandNames.Navto = "navto"; + CommandNames.Occurrences = "occurrences"; + CommandNames.DocumentHighlights = "documentHighlights"; + CommandNames.Open = "open"; + CommandNames.Quickinfo = "quickinfo"; + CommandNames.References = "references"; + CommandNames.Reload = "reload"; + CommandNames.Rename = "rename"; + CommandNames.Saveto = "saveto"; + CommandNames.SignatureHelp = "signatureHelp"; + CommandNames.TypeDefinition = "typeDefinition"; + CommandNames.ProjectInfo = "projectInfo"; + CommandNames.ReloadProjects = "reloadProjects"; + CommandNames.Unknown = "unknown"; + })(CommandNames = server.CommandNames || (server.CommandNames = {})); + var Errors; + (function (Errors) { + Errors.NoProject = new Error("No Project."); + })(Errors || (Errors = {})); + var Session = (function () { + function Session(host, byteLength, hrtime, logger) { + var _this = this; + this.host = host; + this.byteLength = byteLength; + this.hrtime = hrtime; + this.logger = logger; + this.pendingOperation = false; + this.fileHash = {}; + this.nextFileId = 1; + this.changeSeq = 0; + this.handlers = (_a = {}, + _a[CommandNames.Exit] = function () { + _this.exit(); + return { responseRequired: false }; + }, + _a[CommandNames.Definition] = function (request) { + var defArgs = request.arguments; + return { response: _this.getDefinition(defArgs.line, defArgs.offset, defArgs.file), responseRequired: true }; + }, + _a[CommandNames.TypeDefinition] = function (request) { + var defArgs = request.arguments; + return { response: _this.getTypeDefinition(defArgs.line, defArgs.offset, defArgs.file), responseRequired: true }; + }, + _a[CommandNames.References] = function (request) { + var defArgs = request.arguments; + return { response: _this.getReferences(defArgs.line, defArgs.offset, defArgs.file), responseRequired: true }; + }, + _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 }; + }, + _a[CommandNames.Open] = function (request) { + var openArgs = request.arguments; + _this.openClientFile(openArgs.file); + return { responseRequired: false }; + }, + _a[CommandNames.Quickinfo] = function (request) { + var quickinfoArgs = request.arguments; + return { response: _this.getQuickInfo(quickinfoArgs.line, quickinfoArgs.offset, quickinfoArgs.file), responseRequired: true }; + }, + _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 }; + }, + _a[CommandNames.Formatonkey] = function (request) { + var formatOnKeyArgs = request.arguments; + return { response: _this.getFormattingEditsAfterKeystroke(formatOnKeyArgs.line, formatOnKeyArgs.offset, formatOnKeyArgs.key, formatOnKeyArgs.file), responseRequired: true }; + }, + _a[CommandNames.Completions] = function (request) { + var completionsArgs = request.arguments; + return { response: _this.getCompletions(completionsArgs.line, completionsArgs.offset, completionsArgs.prefix, completionsArgs.file), responseRequired: true }; + }, + _a[CommandNames.CompletionDetails] = function (request) { + var completionDetailsArgs = request.arguments; + return { response: _this.getCompletionEntryDetails(completionDetailsArgs.line, completionDetailsArgs.offset, completionDetailsArgs.entryNames, completionDetailsArgs.file), responseRequired: true }; + }, + _a[CommandNames.SignatureHelp] = function (request) { + var signatureHelpArgs = request.arguments; + return { response: _this.getSignatureHelpItems(signatureHelpArgs.line, signatureHelpArgs.offset, signatureHelpArgs.file), responseRequired: true }; + }, + _a[CommandNames.Geterr] = function (request) { + var geterrArgs = request.arguments; + return { response: _this.getDiagnostics(geterrArgs.delay, geterrArgs.files), responseRequired: false }; + }, + _a[CommandNames.GeterrForProject] = function (request) { + var _a = request.arguments, file = _a.file, delay = _a.delay; + 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 }; + }, + _a[CommandNames.Configure] = function (request) { + var configureArgs = request.arguments; + _this.projectService.setHostConfiguration(configureArgs); + _this.output(undefined, CommandNames.Configure, request.seq); + return { responseRequired: false }; + }, + _a[CommandNames.Reload] = function (request) { + var reloadArgs = request.arguments; + _this.reload(reloadArgs.file, reloadArgs.tmpfile, request.seq); + return { responseRequired: false }; + }, + _a[CommandNames.Saveto] = function (request) { + var savetoArgs = request.arguments; + _this.saveToTmp(savetoArgs.file, savetoArgs.tmpfile); + return { responseRequired: false }; + }, + _a[CommandNames.Close] = function (request) { + var closeArgs = request.arguments; + _this.closeClientFile(closeArgs.file); + return { responseRequired: false }; + }, + _a[CommandNames.Navto] = function (request) { + var navtoArgs = request.arguments; + return { response: _this.getNavigateToItems(navtoArgs.searchValue, navtoArgs.file, navtoArgs.maxResultCount), responseRequired: true }; + }, + _a[CommandNames.Brace] = function (request) { + var braceArguments = request.arguments; + return { response: _this.getBraceMatching(braceArguments.line, braceArguments.offset, braceArguments.file), responseRequired: true }; + }, + _a[CommandNames.NavBar] = function (request) { + var navBarArgs = request.arguments; + return { response: _this.getNavigationBarItems(navBarArgs.file), responseRequired: true }; + }, + _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 }; + }, + _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 }; + }, + _a[CommandNames.ProjectInfo] = function (request) { + var _a = request.arguments, file = _a.file, needFileNameList = _a.needFileNameList; + return { response: _this.getProjectInfo(file, needFileNameList), responseRequired: true }; + }, + _a[CommandNames.ReloadProjects] = function (request) { + _this.reloadProjects(); + return { responseRequired: false }; + }, + _a + ); + this.projectService = + new server.ProjectService(host, logger, function (eventName, project, fileName) { + _this.handleEvent(eventName, project, fileName); + }); + var _a; + } + Session.prototype.handleEvent = function (eventName, project, fileName) { + var _this = this; + if (eventName == "context") { + this.projectService.log("got context event, updating diagnostics for" + fileName, "Info"); + this.updateErrorCheck([{ fileName: fileName, project: project }], this.changeSeq, function (n) { return n === _this.changeSeq; }, 100); + } + }; + Session.prototype.logError = function (err, cmd) { + var typedErr = err; + var msg = "Exception on executing command " + cmd; + if (typedErr.message) { + msg += ":\n" + typedErr.message; + if (typedErr.stack) { + msg += "\n" + typedErr.stack; + } + } + this.projectService.log(msg); + }; + Session.prototype.sendLineToClient = function (line) { + this.host.write(line + this.host.newLine); + }; + Session.prototype.send = function (msg) { + var json = JSON.stringify(msg); + if (this.logger.isVerbose()) { + this.logger.info(msg.type + ": " + json); + } + this.sendLineToClient('Content-Length: ' + (1 + this.byteLength(json, 'utf8')) + + '\r\n\r\n' + json); + }; + Session.prototype.event = function (info, eventName) { + var ev = { + seq: 0, + type: "event", + event: eventName, + body: info + }; + this.send(ev); + }; + Session.prototype.response = function (info, cmdName, reqSeq, errorMsg) { + if (reqSeq === void 0) { reqSeq = 0; } + var res = { + seq: 0, + type: "response", + command: cmdName, + request_seq: reqSeq, + success: !errorMsg + }; + if (!errorMsg) { + res.body = info; + } + else { + res.message = errorMsg; + } + this.send(res); + }; + Session.prototype.output = function (body, commandName, requestSequence, errorMessage) { + if (requestSequence === void 0) { requestSequence = 0; } + this.response(body, commandName, requestSequence, errorMessage); + }; + Session.prototype.semanticCheck = function (file, project) { + try { + var diags = project.compilerService.languageService.getSemanticDiagnostics(file); + if (diags) { + var bakedDiags = diags.map(function (diag) { return formatDiag(file, project, diag); }); + this.event({ file: file, diagnostics: bakedDiags }, "semanticDiag"); + } + } + catch (err) { + this.logError(err, "semantic check"); + } + }; + Session.prototype.syntacticCheck = function (file, project) { + try { + var diags = project.compilerService.languageService.getSyntacticDiagnostics(file); + if (diags) { + var bakedDiags = diags.map(function (diag) { return formatDiag(file, project, diag); }); + this.event({ file: file, diagnostics: bakedDiags }, "syntaxDiag"); + } + } + catch (err) { + this.logError(err, "syntactic check"); + } + }; + Session.prototype.errorCheck = function (file, project) { + this.syntacticCheck(file, project); + this.semanticCheck(file, project); + }; + Session.prototype.reloadProjects = function () { + this.projectService.reloadProjects(); + }; + Session.prototype.updateProjectStructure = function (seq, matchSeq, ms) { + var _this = this; + if (ms === void 0) { ms = 1500; } + setTimeout(function () { + if (matchSeq(seq)) { + _this.projectService.updateProjectStructure(); + } + }, ms); + }; + Session.prototype.updateErrorCheck = function (checkList, seq, matchSeq, ms, followMs, requireOpen) { + var _this = this; + if (ms === void 0) { ms = 1500; } + if (followMs === void 0) { followMs = 200; } + if (requireOpen === void 0) { requireOpen = true; } + if (followMs > ms) { + followMs = ms; + } + if (this.errorTimer) { + clearTimeout(this.errorTimer); + } + if (this.immediateId) { + clearImmediate(this.immediateId); + this.immediateId = undefined; + } + var index = 0; + var checkOne = function () { + if (matchSeq(seq)) { + var checkSpec = checkList[index++]; + if (checkSpec.project.getSourceFileFromName(checkSpec.fileName, requireOpen)) { + _this.syntacticCheck(checkSpec.fileName, checkSpec.project); + _this.immediateId = setImmediate(function () { + _this.semanticCheck(checkSpec.fileName, checkSpec.project); + _this.immediateId = undefined; + if (checkList.length > index) { + _this.errorTimer = setTimeout(checkOne, followMs); + } + else { + _this.errorTimer = undefined; + } + }); + } + } + }; + if ((checkList.length > index) && (matchSeq(seq))) { + this.errorTimer = setTimeout(checkOne, ms); + } + }; + Session.prototype.getDefinition = function (line, offset, fileName) { + var file = ts.normalizePath(fileName); + var project = this.projectService.getProjectForFile(file); + if (!project) { + throw Errors.NoProject; + } + var compilerService = project.compilerService; + var position = compilerService.host.lineOffsetToPosition(file, line, offset); + var definitions = compilerService.languageService.getDefinitionAtPosition(file, position); + if (!definitions) { + return undefined; + } + return definitions.map(function (def) { return ({ + file: def.fileName, + start: compilerService.host.positionToLineOffset(def.fileName, def.textSpan.start), + end: compilerService.host.positionToLineOffset(def.fileName, ts.textSpanEnd(def.textSpan)) + }); }); + }; + Session.prototype.getTypeDefinition = function (line, offset, fileName) { + var file = ts.normalizePath(fileName); + var project = this.projectService.getProjectForFile(file); + if (!project) { + throw Errors.NoProject; + } + var compilerService = project.compilerService; + var position = compilerService.host.lineOffsetToPosition(file, line, offset); + var definitions = compilerService.languageService.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)) + }); }); + }; + Session.prototype.getOccurrences = function (line, offset, fileName) { + fileName = ts.normalizePath(fileName); + var project = this.projectService.getProjectForFile(fileName); + if (!project) { + throw Errors.NoProject; + } + var compilerService = project.compilerService; + var position = compilerService.host.lineOffsetToPosition(fileName, line, offset); + var occurrences = compilerService.languageService.getOccurrencesAtPosition(fileName, 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)); + return { + start: start, + end: end, + file: fileName, + isWriteAccess: isWriteAccess + }; + }); + }; + Session.prototype.getDocumentHighlights = function (line, offset, fileName, filesToSearch) { + fileName = ts.normalizePath(fileName); + var project = this.projectService.getProjectForFile(fileName); + if (!project) { + throw Errors.NoProject; + } + var compilerService = project.compilerService; + var position = compilerService.host.lineOffsetToPosition(fileName, line, offset); + var documentHighlights = compilerService.languageService.getDocumentHighlights(fileName, position, filesToSearch); + if (!documentHighlights) { + return undefined; + } + return documentHighlights.map(convertToDocumentHighlightsItem); + function convertToDocumentHighlightsItem(documentHighlights) { + var fileName = documentHighlights.fileName, highlightSpans = documentHighlights.highlightSpans; + 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)); + return { start: start, end: end, kind: kind }; + } + } + }; + Session.prototype.getProjectInfo = function (fileName, needFileNameList) { + fileName = ts.normalizePath(fileName); + var project = this.projectService.getProjectForFile(fileName); + var projectInfo = { + configFileName: project.projectFilename + }; + if (needFileNameList) { + projectInfo.fileNames = project.getFileNames(); + } + return projectInfo; + }; + Session.prototype.getRenameLocations = function (line, offset, fileName, findInComments, findInStrings) { + var file = ts.normalizePath(fileName); + var project = this.projectService.getProjectForFile(file); + if (!project) { + throw Errors.NoProject; + } + var compilerService = project.compilerService; + var position = compilerService.host.lineOffsetToPosition(file, line, offset); + var renameInfo = compilerService.languageService.getRenameInfo(file, position); + if (!renameInfo) { + return undefined; + } + if (!renameInfo.canRename) { + return { + info: renameInfo, + locs: [] + }; + } + var renameLocations = compilerService.languageService.findRenameLocations(file, position, findInStrings, findInComments); + if (!renameLocations) { + return undefined; + } + var bakedRenameLocs = renameLocations.map(function (location) { return ({ + file: location.fileName, + start: compilerService.host.positionToLineOffset(location.fileName, location.textSpan.start), + end: compilerService.host.positionToLineOffset(location.fileName, ts.textSpanEnd(location.textSpan)) + }); }).sort(function (a, b) { + if (a.file < b.file) { + return -1; + } + else if (a.file > b.file) { + return 1; + } + else { + if (a.start.line < b.start.line) { + return 1; + } + else if (a.start.line > b.start.line) { + return -1; + } + else { + return b.start.offset - a.start.offset; + } + } + }).reduce(function (accum, cur) { + var curFileAccum; + if (accum.length > 0) { + curFileAccum = accum[accum.length - 1]; + if (curFileAccum.file != cur.file) { + curFileAccum = undefined; + } + } + if (!curFileAccum) { + curFileAccum = { file: cur.file, locs: [] }; + accum.push(curFileAccum); + } + curFileAccum.locs.push({ start: cur.start, end: cur.end }); + return accum; + }, []); + return { info: renameInfo, locs: bakedRenameLocs }; + }; + Session.prototype.getReferences = function (line, offset, fileName) { + var file = ts.normalizePath(fileName); + var project = this.projectService.getProjectForFile(file); + if (!project) { + throw Errors.NoProject; + } + var compilerService = project.compilerService; + var position = compilerService.host.lineOffsetToPosition(file, line, offset); + var references = compilerService.languageService.getReferencesAtPosition(file, position); + if (!references) { + return undefined; + } + var nameInfo = compilerService.languageService.getQuickInfoAtPosition(file, position); + if (!nameInfo) { + return undefined; + } + var displayString = ts.displayPartsToString(nameInfo.displayParts); + var nameSpan = nameInfo.textSpan; + var nameColStart = compilerService.host.positionToLineOffset(file, nameSpan.start).offset; + var nameText = compilerService.host.getScriptSnapshot(file).getText(nameSpan.start, ts.textSpanEnd(nameSpan)); + var bakedRefs = references.map(function (ref) { + var start = compilerService.host.positionToLineOffset(ref.fileName, ref.textSpan.start); + var refLineSpan = compilerService.host.lineToTextSpan(ref.fileName, start.line - 1); + var snap = compilerService.host.getScriptSnapshot(ref.fileName); + var lineText = snap.getText(refLineSpan.start, ts.textSpanEnd(refLineSpan)).replace(/\r|\n/g, ""); + return { + file: ref.fileName, + start: start, + lineText: lineText, + end: compilerService.host.positionToLineOffset(ref.fileName, ts.textSpanEnd(ref.textSpan)), + isWriteAccess: ref.isWriteAccess + }; + }).sort(compareFileStart); + return { + refs: bakedRefs, + symbolName: nameText, + symbolStartOffset: nameColStart, + symbolDisplayString: displayString + }; + }; + Session.prototype.openClientFile = function (fileName) { + var file = ts.normalizePath(fileName); + this.projectService.openClientFile(file); + }; + Session.prototype.getQuickInfo = function (line, offset, fileName) { + var file = ts.normalizePath(fileName); + var project = this.projectService.getProjectForFile(file); + if (!project) { + throw Errors.NoProject; + } + var compilerService = project.compilerService; + var position = compilerService.host.lineOffsetToPosition(file, line, offset); + var quickInfo = compilerService.languageService.getQuickInfoAtPosition(file, position); + if (!quickInfo) { + return undefined; + } + var displayString = ts.displayPartsToString(quickInfo.displayParts); + var docString = ts.displayPartsToString(quickInfo.documentation); + return { + kind: quickInfo.kind, + kindModifiers: quickInfo.kindModifiers, + start: compilerService.host.positionToLineOffset(file, quickInfo.textSpan.start), + end: compilerService.host.positionToLineOffset(file, ts.textSpanEnd(quickInfo.textSpan)), + displayString: displayString, + documentation: docString + }; + }; + Session.prototype.getFormattingEditsForRange = function (line, offset, endLine, endOffset, fileName) { + var file = ts.normalizePath(fileName); + var project = this.projectService.getProjectForFile(file); + if (!project) { + throw Errors.NoProject; + } + var compilerService = project.compilerService; + var startPosition = compilerService.host.lineOffsetToPosition(file, line, offset); + var endPosition = compilerService.host.lineOffsetToPosition(file, endLine, endOffset); + var edits = compilerService.languageService.getFormattingEditsForRange(file, startPosition, endPosition, this.projectService.getFormatCodeOptions(file)); + if (!edits) { + return undefined; + } + return edits.map(function (edit) { + return { + start: compilerService.host.positionToLineOffset(file, edit.span.start), + end: compilerService.host.positionToLineOffset(file, ts.textSpanEnd(edit.span)), + newText: edit.newText ? edit.newText : "" + }; + }); + }; + Session.prototype.getFormattingEditsAfterKeystroke = function (line, offset, key, fileName) { + var file = ts.normalizePath(fileName); + var project = this.projectService.getProjectForFile(file); + if (!project) { + throw Errors.NoProject; + } + var compilerService = project.compilerService; + var position = compilerService.host.lineOffsetToPosition(file, line, offset); + var formatOptions = this.projectService.getFormatCodeOptions(file); + var edits = compilerService.languageService.getFormattingEditsAfterKeystroke(file, position, key, formatOptions); + if ((key == "\n") && ((!edits) || (edits.length === 0) || allEditsBeforePos(edits, position))) { + var scriptInfo = compilerService.host.getScriptInfo(file); + if (scriptInfo) { + var lineInfo = scriptInfo.getLineInfo(line); + if (lineInfo && (lineInfo.leaf) && (lineInfo.leaf.text)) { + var lineText = lineInfo.leaf.text; + if (lineText.search("\\S") < 0) { + var editorOptions = { + IndentSize: formatOptions.IndentSize, + TabSize: formatOptions.TabSize, + NewLineCharacter: "\n", + ConvertTabsToSpaces: formatOptions.ConvertTabsToSpaces, + IndentStyle: ts.IndentStyle.Smart + }; + var preferredIndent = compilerService.languageService.getIndentationAtPosition(file, position, editorOptions); + var hasIndent = 0; + for (var i = 0, len = lineText.length; i < len; i++) { + if (lineText.charAt(i) == " ") { + hasIndent++; + } + else if (lineText.charAt(i) == "\t") { + hasIndent += editorOptions.TabSize; + } + else { + break; + } + } + if (preferredIndent !== hasIndent) { + var firstNoWhiteSpacePosition = lineInfo.offset + i; + edits.push({ + span: ts.createTextSpanFromBounds(lineInfo.offset, firstNoWhiteSpacePosition), + newText: generateIndentString(preferredIndent, editorOptions) + }); + } + } + } + } + } + if (!edits) { + return undefined; + } + return edits.map(function (edit) { + return { + start: compilerService.host.positionToLineOffset(file, edit.span.start), + end: compilerService.host.positionToLineOffset(file, ts.textSpanEnd(edit.span)), + newText: edit.newText ? edit.newText : "" + }; + }); + }; + Session.prototype.getCompletions = function (line, offset, prefix, fileName) { + if (!prefix) { + prefix = ""; + } + var file = ts.normalizePath(fileName); + var project = this.projectService.getProjectForFile(file); + if (!project) { + throw Errors.NoProject; + } + var compilerService = project.compilerService; + var position = compilerService.host.lineOffsetToPosition(file, line, offset); + var completions = compilerService.languageService.getCompletionsAtPosition(file, position); + if (!completions) { + return undefined; + } + return completions.entries.reduce(function (result, entry) { + if (completions.isMemberCompletion || (entry.name.toLowerCase().indexOf(prefix.toLowerCase()) === 0)) { + result.push(entry); + } + return result; + }, []).sort(function (a, b) { return a.name.localeCompare(b.name); }); + }; + Session.prototype.getCompletionEntryDetails = function (line, offset, entryNames, fileName) { + var file = ts.normalizePath(fileName); + var project = this.projectService.getProjectForFile(file); + if (!project) { + throw Errors.NoProject; + } + var compilerService = project.compilerService; + var position = compilerService.host.lineOffsetToPosition(file, line, offset); + return entryNames.reduce(function (accum, entryName) { + var details = compilerService.languageService.getCompletionEntryDetails(file, position, entryName); + if (details) { + accum.push(details); + } + return accum; + }, []); + }; + Session.prototype.getSignatureHelpItems = function (line, offset, fileName) { + var file = ts.normalizePath(fileName); + var project = this.projectService.getProjectForFile(file); + if (!project) { + throw Errors.NoProject; + } + var compilerService = project.compilerService; + var position = compilerService.host.lineOffsetToPosition(file, line, offset); + var helpItems = compilerService.languageService.getSignatureHelpItems(file, position); + if (!helpItems) { + return undefined; + } + var span = helpItems.applicableSpan; + var result = { + items: helpItems.items, + applicableSpan: { + start: compilerService.host.positionToLineOffset(file, span.start), + end: compilerService.host.positionToLineOffset(file, span.start + span.length) + }, + selectedItemIndex: helpItems.selectedItemIndex, + argumentIndex: helpItems.argumentIndex, + argumentCount: helpItems.argumentCount + }; + return result; + }; + Session.prototype.getDiagnostics = function (delay, fileNames) { + var _this = this; + var checkList = fileNames.reduce(function (accum, fileName) { + fileName = ts.normalizePath(fileName); + var project = _this.projectService.getProjectForFile(fileName); + if (project) { + accum.push({ fileName: fileName, project: project }); + } + return accum; + }, []); + if (checkList.length > 0) { + this.updateErrorCheck(checkList, this.changeSeq, function (n) { return n === _this.changeSeq; }, delay); + } + }; + Session.prototype.change = function (line, offset, endLine, endOffset, insertString, fileName) { + var _this = this; + var file = ts.normalizePath(fileName); + var project = this.projectService.getProjectForFile(file); + if (project) { + var compilerService = project.compilerService; + var start = compilerService.host.lineOffsetToPosition(file, line, offset); + var end = compilerService.host.lineOffsetToPosition(file, endLine, endOffset); + if (start >= 0) { + compilerService.host.editScript(file, start, end, insertString); + this.changeSeq++; + } + this.updateProjectStructure(this.changeSeq, function (n) { return n === _this.changeSeq; }); + } + }; + Session.prototype.reload = function (fileName, tempFileName, reqSeq) { + var _this = this; + if (reqSeq === void 0) { reqSeq = 0; } + var file = ts.normalizePath(fileName); + var tmpfile = ts.normalizePath(tempFileName); + var project = this.projectService.getProjectForFile(file); + if (project) { + this.changeSeq++; + project.compilerService.host.reloadScript(file, tmpfile, function () { + _this.output(undefined, CommandNames.Reload, reqSeq); + }); + } + }; + Session.prototype.saveToTmp = function (fileName, tempFileName) { + var file = ts.normalizePath(fileName); + var tmpfile = ts.normalizePath(tempFileName); + var project = this.projectService.getProjectForFile(file); + if (project) { + project.compilerService.host.saveTo(file, tmpfile); + } + }; + Session.prototype.closeClientFile = function (fileName) { + if (!fileName) { + return; + } + var file = ts.normalizePath(fileName); + this.projectService.closeClientFile(file); + }; + Session.prototype.decorateNavigationBarItem = function (project, fileName, items) { + var _this = this; + if (!items) { + return undefined; + } + var compilerService = project.compilerService; + return items.map(function (item) { return ({ + text: item.text, + kind: item.kind, + kindModifiers: item.kindModifiers, + spans: item.spans.map(function (span) { return ({ + start: compilerService.host.positionToLineOffset(fileName, span.start), + end: compilerService.host.positionToLineOffset(fileName, ts.textSpanEnd(span)) + }); }), + childItems: _this.decorateNavigationBarItem(project, fileName, item.childItems) + }); }); + }; + Session.prototype.getNavigationBarItems = function (fileName) { + var file = ts.normalizePath(fileName); + var project = this.projectService.getProjectForFile(file); + if (!project) { + throw Errors.NoProject; + } + var compilerService = project.compilerService; + var items = compilerService.languageService.getNavigationBarItems(file); + if (!items) { + return undefined; + } + return this.decorateNavigationBarItem(project, fileName, items); + }; + Session.prototype.getNavigateToItems = function (searchValue, fileName, maxResultCount) { + var file = ts.normalizePath(fileName); + var project = this.projectService.getProjectForFile(file); + if (!project) { + throw Errors.NoProject; + } + var compilerService = project.compilerService; + var navItems = compilerService.languageService.getNavigateToItems(searchValue, maxResultCount); + if (!navItems) { + return undefined; + } + return navItems.map(function (navItem) { + var start = compilerService.host.positionToLineOffset(navItem.fileName, navItem.textSpan.start); + var end = compilerService.host.positionToLineOffset(navItem.fileName, ts.textSpanEnd(navItem.textSpan)); + var bakedItem = { + name: navItem.name, + kind: navItem.kind, + file: navItem.fileName, + start: start, + end: end + }; + if (navItem.kindModifiers && (navItem.kindModifiers != "")) { + bakedItem.kindModifiers = navItem.kindModifiers; + } + if (navItem.matchKind != 'none') { + bakedItem.matchKind = navItem.matchKind; + } + if (navItem.containerName && (navItem.containerName.length > 0)) { + bakedItem.containerName = navItem.containerName; + } + if (navItem.containerKind && (navItem.containerKind.length > 0)) { + bakedItem.containerKind = navItem.containerKind; + } + return bakedItem; + }); + }; + Session.prototype.getBraceMatching = function (line, offset, fileName) { + var file = ts.normalizePath(fileName); + var project = this.projectService.getProjectForFile(file); + if (!project) { + throw Errors.NoProject; + } + var compilerService = project.compilerService; + var position = compilerService.host.lineOffsetToPosition(file, line, offset); + var spans = compilerService.languageService.getBraceMatchingAtPosition(file, position); + if (!spans) { + return undefined; + } + return spans.map(function (span) { return ({ + start: compilerService.host.positionToLineOffset(file, span.start), + end: compilerService.host.positionToLineOffset(file, span.start + span.length) + }); }); + }; + Session.prototype.getDiagnosticsForProject = function (delay, fileName) { + var _this = this; + var _a = this.getProjectInfo(fileName, true), configFileName = _a.configFileName, fileNamesInProject = _a.fileNames; + fileNamesInProject = fileNamesInProject.filter(function (value, index, array) { return value.indexOf("lib.d.ts") < 0; }); + var highPriorityFiles = []; + var mediumPriorityFiles = []; + var lowPriorityFiles = []; + var veryLowPriorityFiles = []; + var normalizedFileName = ts.normalizePath(fileName); + var project = this.projectService.getProjectForFile(normalizedFileName); + for (var _i = 0; _i < fileNamesInProject.length; _i++) { + var fileNameInProject = fileNamesInProject[_i]; + if (this.getCanonicalFileName(fileNameInProject) == this.getCanonicalFileName(fileName)) + highPriorityFiles.push(fileNameInProject); + else { + var info = this.projectService.getScriptInfo(fileNameInProject); + if (!info.isOpen) { + if (fileNameInProject.indexOf(".d.ts") > 0) + veryLowPriorityFiles.push(fileNameInProject); + else + lowPriorityFiles.push(fileNameInProject); + } + else + mediumPriorityFiles.push(fileNameInProject); + } + } + 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 }; + }); + this.updateErrorCheck(checkList, this.changeSeq, function (n) { return n == _this.changeSeq; }, delay, 200, false); + } + }; + Session.prototype.getCanonicalFileName = function (fileName) { + var name = this.host.useCaseSensitiveFileNames ? fileName : fileName.toLowerCase(); + return ts.normalizePath(name); + }; + Session.prototype.exit = function () { + }; + Session.prototype.addProtocolHandler = function (command, handler) { + if (this.handlers[command]) { + throw new Error("Protocol handler already exists for command \"" + command + "\""); + } + this.handlers[command] = handler; + }; + Session.prototype.executeCommand = function (request) { + var handler = this.handlers[request.command]; + if (handler) { + return handler(request); + } + else { + this.projectService.log("Unrecognized JSON command: " + JSON.stringify(request)); + this.output(undefined, CommandNames.Unknown, request.seq, "Unrecognized JSON command: " + request.command); + return { responseRequired: false }; + } + }; + Session.prototype.onMessage = function (message) { + if (this.logger.isVerbose()) { + this.logger.info("request: " + message); + var start = this.hrtime(); + } + try { + var 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)"; + } + this.logger.msg(leader + ": " + elapsedMs.toFixed(4).toString(), "Perf"); + } + if (response) { + this.output(response, request.command, request.seq); + } + else if (responseRequired) { + this.output(undefined, request.command, request.seq, "No content available."); + } + } + catch (err) { + if (err instanceof ts.OperationCanceledException) { + } + this.logError(err, message); + this.output(undefined, request ? request.command : CommandNames.Unknown, request ? request.seq : 0, "Error processing request. " + err.message); + } + }; + return Session; + })(); + server.Session = Session; + })(server = ts.server || (ts.server = {})); +})(ts || (ts = {})); +var ts; +(function (ts) { + var server; + (function (server) { + var lineCollectionCapacity = 4; + function mergeFormatOptions(formatCodeOptions, formatOptions) { + var hasOwnProperty = Object.prototype.hasOwnProperty; + Object.keys(formatOptions).forEach(function (key) { + var codeKey = key.charAt(0).toUpperCase() + key.substring(1); + if (hasOwnProperty.call(formatCodeOptions, codeKey)) { + formatCodeOptions[codeKey] = formatOptions[key]; + } + }); + } + var ScriptInfo = (function () { + function ScriptInfo(host, fileName, content, isOpen) { + if (isOpen === void 0) { isOpen = false; } + this.host = host; + this.fileName = fileName; + this.content = content; + this.isOpen = isOpen; + this.children = []; + this.formatCodeOptions = ts.clone(CompilerService.defaultFormatCodeOptions); + 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.ls = null; + this.filenameToScript = {}; + this.roots = []; + this.resolvedModuleNames = ts.createFileMap(ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames)); + this.moduleResolutionHost = { + fileExists: function (fileName) { return _this.fileExists(fileName); }, + readFile: function (fileName) { return _this.host.readFile(fileName); } + }; + } + LSHost.prototype.resolveModuleNames = function (moduleNames, containingFile) { + var currentResolutionsInFile = this.resolvedModuleNames.get(containingFile); + var newResolutions = {}; + var resolvedModules = []; + var compilerOptions = this.getCompilationSettings(); + for (var _i = 0; _i < moduleNames.length; _i++) { + var moduleName = moduleNames[_i]; + var resolution = ts.lookUp(newResolutions, moduleName); + if (!resolution) { + var existingResolution = currentResolutionsInFile && ts.lookUp(currentResolutionsInFile, moduleName); + if (moduleResolutionIsValid(existingResolution)) { + resolution = existingResolution; + } + else { + resolution = ts.resolveModuleName(moduleName, containingFile, compilerOptions, this.moduleResolutionHost); + resolution.lastCheckTime = Date.now(); + newResolutions[moduleName] = resolution; + } + } + ts.Debug.assert(resolution !== undefined); + resolvedModules.push(resolution.resolvedModule); + } + this.resolvedModuleNames.set(containingFile, newResolutions); + return resolvedModules; + function moduleResolutionIsValid(resolution) { + if (!resolution) { + return false; + } + if (resolution.resolvedModule) { + return true; + } + return resolution.failedLookupLocations.length === 0; + } + }; + 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(); + }; + 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.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[info.fileName] = undefined; + this.resolvedModuleNames.remove(info.fileName); + } + }; + LSHost.prototype.getScriptInfo = function (filename) { + var scriptInfo = ts.lookUp(this.filenameToScript, filename); + if (!scriptInfo) { + scriptInfo = this.project.openReferencedFile(filename); + if (scriptInfo) { + this.filenameToScript[scriptInfo.fileName] = scriptInfo; + } + } + else { + } + return scriptInfo; + }; + LSHost.prototype.addRoot = function (info) { + var scriptInfo = ts.lookUp(this.filenameToScript, info.fileName); + if (!scriptInfo) { + this.filenameToScript[info.fileName] = info; + this.roots.push(info); + } + }; + LSHost.prototype.removeRoot = function (info) { + var scriptInfo = ts.lookUp(this.filenameToScript, info.fileName); + if (scriptInfo) { + this.filenameToScript[info.fileName] = undefined; + this.roots = copyListRemovingItem(info, this.roots); + this.resolvedModuleNames.remove(info.fileName); + } + }; + 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.resolvePath = function (path) { + var start = new Date().getTime(); + var result = this.host.resolvePath(path); + return result; + }; + LSHost.prototype.fileExists = function (path) { + var start = new Date().getTime(); + var result = this.host.fileExists(path); + return result; + }; + LSHost.prototype.directoryExists = function (path) { + return this.host.directoryExists(path); + }; + LSHost.prototype.lineToTextSpan = function (filename, line) { + var script = this.filenameToScript[filename]; + 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 script = this.filenameToScript[filename]; + var index = script.snap().index; + var lineInfo = index.lineNumberToInfo(line); + return (lineInfo.offset + offset - 1); + }; + LSHost.prototype.positionToLineOffset = function (filename, position) { + var script = this.filenameToScript[filename]; + var index = script.snap().index; + var lineOffset = index.charOffsetToLineNumberAndPos(position); + return { line: lineOffset.line, offset: lineOffset.offset + 1 }; + }; + return LSHost; + })(); + server.LSHost = LSHost; + function getAbsolutePath(filename, directory) { + var rootLength = ts.getRootLength(filename); + if (rootLength > 0) { + return filename; + } + else { + var splitFilename = filename.split('/'); + var splitDir = directory.split('/'); + var i = 0; + var dirTail = 0; + var sflen = splitFilename.length; + while ((i < sflen) && (splitFilename[i].charAt(0) == '.')) { + var dots = splitFilename[i]; + if (dots == '..') { + dirTail++; + } + else if (dots != '.') { + return undefined; + } + i++; + } + return splitDir.slice(0, splitDir.length - dirTail).concat(splitFilename.slice(i)).join('/'); + } + } + var Project = (function () { + function Project(projectService, projectOptions) { + this.projectService = projectService; + this.projectOptions = projectOptions; + this.directoriesWatchedForTsconfig = []; + this.filenameToSourceFile = {}; + this.updateGraphSeq = 0; + this.openRefCount = 0; + this.compilerService = new CompilerService(this, projectOptions && projectOptions.compilerOptions); + } + Project.prototype.addOpenRef = function () { + this.openRefCount++; + }; + Project.prototype.deleteOpenRef = function () { + this.openRefCount--; + return this.openRefCount; + }; + Project.prototype.openReferencedFile = function (filename) { + return this.projectService.openFile(filename, false); + }; + Project.prototype.getRootFiles = function () { + return this.compilerService.host.roots.map(function (info) { return info.fileName; }); + }; + Project.prototype.getFileNames = function () { + var sourceFiles = this.program.getSourceFiles(); + return sourceFiles.map(function (sourceFile) { return sourceFile.fileName; }); + }; + Project.prototype.getSourceFile = function (info) { + return this.filenameToSourceFile[info.fileName]; + }; + Project.prototype.getSourceFileFromName = function (filename, requireOpen) { + var info = this.projectService.getScriptInfo(filename); + if (info) { + if ((!requireOpen) || info.isOpen) { + return this.getSourceFile(info); + } + } + }; + Project.prototype.isRoot = function (info) { + return this.compilerService.host.roots.some(function (root) { return root === info; }); + }; + Project.prototype.removeReferencedFile = function (info) { + this.compilerService.host.removeReferencedFile(info); + this.updateGraph(); + }; + Project.prototype.updateFileMap = function () { + this.filenameToSourceFile = {}; + 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 () { + this.updateGraph(); + this.compilerService.languageService.getNavigateToItems(".*"); + }; + Project.prototype.updateGraph = function () { + this.program = this.compilerService.languageService.getProgram(); + this.updateFileMap(); + }; + Project.prototype.isConfiguredProject = function () { + return this.projectFilename; + }; + Project.prototype.addRoot = function (info) { + this.compilerService.host.addRoot(info); + }; + Project.prototype.removeRoot = function (info) { + this.compilerService.host.removeRoot(info); + }; + Project.prototype.filesToString = function () { + var strBuilder = ""; + ts.forEachValue(this.filenameToSourceFile, function (sourceFile) { strBuilder += sourceFile.fileName + "\n"; }); + return strBuilder; + }; + Project.prototype.setProjectOptions = function (projectOptions) { + this.projectOptions = projectOptions; + if (projectOptions.compilerOptions) { + this.compilerService.setCompilerOptions(projectOptions.compilerOptions); + } + }; + return Project; + })(); + server.Project = Project; + function copyListRemovingItem(item, list) { + var copiedList = []; + for (var i = 0, len = list.length; i < len; i++) { + if (list[i] != item) { + copiedList.push(list[i]); + } + } + return copiedList; + } + var ProjectService = (function () { + function ProjectService(host, psLogger, eventHandler) { + this.host = host; + this.psLogger = psLogger; + this.eventHandler = eventHandler; + this.filenameToScriptInfo = {}; + this.openFileRoots = []; + this.inferredProjects = []; + this.configuredProjects = []; + this.openFilesReferenced = []; + this.openFileRootsConfigured = []; + this.directoryWatchersForTsconfig = {}; + this.directoryWatchersRefCount = {}; + this.timerForDetectingProjectFilelistChanges = {}; + this.addDefaultHostConfiguration(); + } + ProjectService.prototype.addDefaultHostConfiguration = function () { + this.hostConfiguration = { + formatCodeOptions: ts.clone(CompilerService.defaultFormatCodeOptions), + hostInfo: "Unknown host" + }; + }; + ProjectService.prototype.getFormatCodeOptions = function (file) { + if (file) { + var info = this.filenameToScriptInfo[file]; + if (info) { + return info.formatCodeOptions; + } + } + return this.hostConfiguration.formatCodeOptions; + }; + ProjectService.prototype.watchedFileChanged = function (fileName) { + var info = this.filenameToScriptInfo[fileName]; + if (!info) { + 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)) { + return; + } + this.log("Detected source file changes: " + fileName); + this.startTimerForDetectingProjectFilelistChanges(project); + }; + ProjectService.prototype.startTimerForDetectingProjectFilelistChanges = function (project) { + var _this = this; + if (this.timerForDetectingProjectFilelistChanges[project.projectFilename]) { + clearTimeout(this.timerForDetectingProjectFilelistChanges[project.projectFilename]); + } + this.timerForDetectingProjectFilelistChanges[project.projectFilename] = setTimeout(function () { return _this.handleProjectFilelistChanges(project); }, 250); + }; + ProjectService.prototype.handleProjectFilelistChanges = function (project) { + var _this = this; + var _a = this.configFileToProjectOptions(project.projectFilename), succeeded = _a.succeeded, projectOptions = _a.projectOptions, error = _a.error; + 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.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), succeeded = _a.succeeded, projectOptions = _a.projectOptions, error = _a.error; + 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; _i < openFileRoots.length; _i++) { + var openFileRoot = openFileRoots[_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); + this.updateConfiguredProject(project); + this.updateProjectStructure(); + }; + 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("context", openFile.defaultProject, openFile.fileName); + } + } + for (var j = 0, flen = this.openFilesReferenced.length; j < flen; j++) { + var openFile = this.openFilesReferenced[j]; + if (this.eventHandler) { + this.eventHandler("context", openFile.defaultProject, 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(); + this.configuredProjects = copyListRemovingItem(project, this.configuredProjects); + } + else { + for (var _i = 0, _a = project.directoriesWatchedForTsconfig; _i < _a.length; _i++) { + var directory = _a[_i]; + if (!(--project.projectService.directoryWatchersRefCount[directory])) { + this.log("Close directory watcher for: " + directory); + project.projectService.directoryWatchersForTsconfig[directory].close(); + delete project.projectService.directoryWatchersForTsconfig[directory]; + } + } + this.inferredProjects = copyListRemovingItem(project, this.inferredProjects); + } + var fileNames = project.getFileNames(); + for (var _b = 0; _b < fileNames.length; _b++) { + var fileName = fileNames[_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) { + 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 { + this.openFilesReferenced = copyListRemovingItem(info, this.openFilesReferenced); + } + 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; + } + } + 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 ts.lookUp(this.filenameToScriptInfo, filename); + }; + ProjectService.prototype.openFile = function (fileName, openedByClient) { + var _this = this; + fileName = ts.normalizePath(fileName); + var info = ts.lookUp(this.filenameToScriptInfo, fileName); + if (!info) { + var content; + if (this.host.fileExists(fileName)) { + content = this.host.readFile(fileName); + } + if (!content) { + if (openedByClient) { + content = ""; + } + } + if (content !== undefined) { + var indentSize; + info = new ScriptInfo(this.host, fileName, content, openedByClient); + info.setFormatOptions(this.getFormatCodeOptions()); + this.filenameToScriptInfo[fileName] = info; + if (!info.isOpen) { + info.fileWatcher = this.host.watchFile(fileName, function (_) { _this.watchedFileChanged(fileName); }); + } + } + } + if (info) { + if (openedByClient) { + info.isOpen = true; + } + } + return info; + }; + ProjectService.prototype.findConfigFile = function (searchPath) { + while (true) { + var fileName = ts.combinePaths(searchPath, "tsconfig.json"); + if (this.host.fileExists(fileName)) { + return fileName; + } + var parentPath = ts.getDirectoryPath(searchPath); + if (parentPath === searchPath) { + break; + } + searchPath = parentPath; + } + return undefined; + }; + ProjectService.prototype.openClientFile = function (fileName) { + this.openOrUpdateConfiguredProjectForFile(fileName); + var info = this.openFile(fileName, true); + this.addOpenFile(info); + this.printProjects(); + return info; + }; + 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.success) { + this.log("Error opening config file " + configFileName + " " + configResult.errorMsg); + } + else { + this.log("Opened configuration file " + configFileName, "Info"); + this.configuredProjects.push(configResult.project); + } + } + else { + this.updateConfiguredProject(project); + } + } + else { + this.log("No config files found."); + } + }; + ProjectService.prototype.closeClientFile = function (filename) { + var info = ts.lookUp(this.filenameToScriptInfo, filename); + if (info) { + this.closeOpenFile(info); + info.isOpen = false; + } + this.printProjects(); + }; + ProjectService.prototype.getProjectForFile = function (filename) { + var scriptInfo = ts.lookUp(this.filenameToScriptInfo, filename); + if (scriptInfo) { + return scriptInfo.defaultProject; + } + }; + ProjectService.prototype.printProjectsForFile = function (filename) { + var scriptInfo = ts.lookUp(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 dirPath = ts.getDirectoryPath(configFilename); + var contents = this.host.readFile(configFilename); + var rawConfig = ts.parseConfigFileTextToJson(configFilename, contents); + if (rawConfig.error) { + return { succeeded: false, error: rawConfig.error }; + } + else { + var parsedCommandLine = ts.parseJsonConfigFileContent(rawConfig.config, this.host, dirPath); + if (parsedCommandLine.errors && (parsedCommandLine.errors.length > 0)) { + return { succeeded: false, error: { errorMsg: "tsconfig option errors" } }; + } + else if (parsedCommandLine.fileNames == null) { + return { succeeded: false, error: { errorMsg: "no files found" } }; + } + else { + var projectOptions = { + files: parsedCommandLine.fileNames, + compilerOptions: parsedCommandLine.options + }; + return { succeeded: true, projectOptions: projectOptions }; + } + } + }; + ProjectService.prototype.openConfigFile = function (configFilename, clientFileName) { + var _this = this; + var _a = this.configFileToProjectOptions(configFilename), succeeded = _a.succeeded, projectOptions = _a.projectOptions, error = _a.error; + if (!succeeded) { + return error; + } + else { + var project = this.createProject(configFilename, projectOptions); + 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, clientFileName == rootFilename); + project.addRoot(info); + } + else { + return { errorMsg: "specified file " + rootFilename + " not found" }; + } + } + project.finishGraph(); + project.projectFileWatcher = this.host.watchFile(configFilename, function (_) { return _this.watchedProjectConfigFileChanged(project); }); + this.log("Add recursive watcher for: " + ts.getDirectoryPath(configFilename)); + project.directoryWatcher = this.host.watchDirectory(ts.getDirectoryPath(configFilename), function (path) { return _this.directoryWatchedForSourceFilesChanged(project, path); }, true); + return { success: true, project: project }; + } + }; + ProjectService.prototype.updateConfiguredProject = function (project) { + if (!this.host.fileExists(project.projectFilename)) { + this.log("Config file deleted"); + this.removeProject(project); + } + else { + var _a = this.configFileToProjectOptions(project.projectFilename), succeeded = _a.succeeded, projectOptions = _a.projectOptions, error = _a.error; + if (!succeeded) { + return error; + } + else { + var oldFileNames = project.compilerService.host.roots.map(function (info) { return info.fileName; }); + var newFileNames = projectOptions.files; + var fileNamesToRemove = oldFileNames.filter(function (f) { return newFileNames.indexOf(f) < 0; }); + var fileNamesToAdd = newFileNames.filter(function (f) { return oldFileNames.indexOf(f) < 0; }); + for (var _i = 0; _i < fileNamesToRemove.length; _i++) { + var fileName = fileNamesToRemove[_i]; + var info = this.getScriptInfo(fileName); + if (info) { + project.removeRoot(info); + } + } + for (var _b = 0; _b < fileNamesToAdd.length; _b++) { + var fileName = fileNamesToAdd[_b]; + var info = this.getScriptInfo(fileName); + if (!info) { + info = this.openFile(fileName, false); + } + else { + if (info.isOpen) { + if (this.openFileRoots.indexOf(info) >= 0) { + this.openFileRoots = copyListRemovingItem(info, this.openFileRoots); + if (info.defaultProject && !info.defaultProject.isConfiguredProject()) { + this.removeProject(info.defaultProject); + } + } + if (this.openFilesReferenced.indexOf(info) >= 0) { + this.openFilesReferenced = copyListRemovingItem(info, this.openFilesReferenced); + } + this.openFileRootsConfigured.push(info); + info.defaultProject = project; + } + } + project.addRoot(info); + } + project.setProjectOptions(projectOptions); + project.finishGraph(); + } + } + }; + ProjectService.prototype.createProject = function (projectFilename, projectOptions) { + var project = new Project(this, projectOptions); + project.projectFilename = projectFilename; + return project; + }; + return ProjectService; + })(); + server.ProjectService = ProjectService; + var CompilerService = (function () { + function CompilerService(project, opt) { + this.project = project; + this.documentRegistry = ts.createDocumentRegistry(); + this.host = new LSHost(project.projectService.host, project); + if (opt) { + this.setCompilerOptions(opt); + } + else { + this.setCompilerOptions(ts.getDefaultCompilerOptions()); + } + 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.getSourceFile(filename); + return ts.isExternalModule(sourceFile); + }; + CompilerService.defaultFormatCodeOptions = { + IndentSize: 4, + TabSize: 4, + NewLineCharacter: ts.sys ? ts.sys.newLine : '\n', + ConvertTabsToSpaces: true, + IndentStyle: ts.IndentStyle.Smart, + InsertSpaceAfterCommaDelimiter: true, + InsertSpaceAfterSemicolonInForStatements: true, + InsertSpaceBeforeAndAfterBinaryOperators: true, + InsertSpaceAfterKeywordsInControlFlowStatements: true, + InsertSpaceAfterFunctionKeywordForAnonymousFunctions: false, + InsertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis: false, + InsertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets: false, + PlaceOpenBraceOnNewLineForFunctions: false, + PlaceOpenBraceOnNewLineForControlBlocks: false + }; + return CompilerService; + })(); + server.CompilerService = CompilerService; + (function (CharRangeSection) { + CharRangeSection[CharRangeSection["PreStart"] = 0] = "PreStart"; + CharRangeSection[CharRangeSection["Start"] = 1] = "Start"; + CharRangeSection[CharRangeSection["Entire"] = 2] = "Entire"; + CharRangeSection[CharRangeSection["Mid"] = 3] = "Mid"; + CharRangeSection[CharRangeSection["End"] = 4] = "End"; + CharRangeSection[CharRangeSection["PostEnd"] = 5] = "PostEnd"; + })(server.CharRangeSection || (server.CharRangeSection = {})); + var CharRangeSection = server.CharRangeSection; + var BaseLineIndexWalker = (function () { + function BaseLineIndexWalker() { + this.goSubtree = true; + this.done = false; + } + BaseLineIndexWalker.prototype.leaf = function (rangeStart, rangeLength, ll) { + }; + return BaseLineIndexWalker; + })(); + 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]; + } + EditWalker.prototype.insertLines = function (insertedText) { + if (this.suppressTrailingText) { + this.trailingText = ""; + } + if (insertedText) { + insertedText = this.initialText + insertedText + this.trailingText; + } + else { + insertedText = this.initialText + this.trailingText; + } + var lm = LineIndex.linesFromText(insertedText); + var lines = lm.lines; + if (lines.length > 1) { + if (lines[lines.length - 1] == "") { + lines.length--; + } + } + var branchParent; + var lastZeroCount; + for (var k = this.endBranch.length - 1; k >= 0; k--) { + this.endBranch[k].updateCounts(); + if (this.endBranch[k].charCount() === 0) { + lastZeroCount = this.endBranch[k]; + if (k > 0) { + branchParent = this.endBranch[k - 1]; + } + else { + branchParent = this.branchNode; + } + } + } + if (lastZeroCount) { + branchParent.remove(lastZeroCount); + } + var insertionNode = this.startPath[this.startPath.length - 2]; + var leafNode = this.startPath[this.startPath.length - 1]; + var len = lines.length; + if (len > 0) { + leafNode.text = lines[0]; + if (len > 1) { + var insertedNodes = new Array(len - 1); + var startNode = leafNode; + for (var i = 1, len = lines.length; i < len; i++) { + insertedNodes[i - 1] = new LineLeaf(lines[i]); + } + var pathIndex = this.startPath.length - 2; + while (pathIndex >= 0) { + insertionNode = this.startPath[pathIndex]; + insertedNodes = insertionNode.insertAt(startNode, insertedNodes); + pathIndex--; + startNode = insertionNode; + } + var insertedNodesLen = insertedNodes.length; + while (insertedNodesLen > 0) { + var newRoot = new LineNode(); + newRoot.add(this.lineIndex.root); + insertedNodes = newRoot.insertAt(this.lineIndex.root, insertedNodes); + insertedNodesLen = insertedNodes.length; + this.lineIndex.root = newRoot; + } + this.lineIndex.root.updateCounts(); + } + else { + for (var j = this.startPath.length - 2; j >= 0; j--) { + this.startPath[j].updateCounts(); + } + } + } + else { + insertionNode.remove(leafNode); + for (var j = this.startPath.length - 2; j >= 0; j--) { + this.startPath[j].updateCounts(); + } + } + return this.lineIndex; + }; + EditWalker.prototype.post = function (relativeStart, relativeLength, lineCollection, parent, nodeType) { + if (lineCollection === this.lineCollectionAtBranch) { + this.state = CharRangeSection.End; + } + this.stack.length--; + return undefined; + }; + EditWalker.prototype.pre = function (relativeStart, relativeLength, lineCollection, parent, nodeType) { + var currentNode = this.stack[this.stack.length - 1]; + if ((this.state === CharRangeSection.Entire) && (nodeType === CharRangeSection.Start)) { + this.state = CharRangeSection.Start; + this.branchNode = currentNode; + this.lineCollectionAtBranch = lineCollection; + } + var child; + function fresh(node) { + if (node.isLeaf()) { + return new LineLeaf(""); + } + else + return new LineNode(); + } + switch (nodeType) { + case CharRangeSection.PreStart: + this.goSubtree = false; + if (this.state !== CharRangeSection.End) { + currentNode.add(lineCollection); + } + break; + case CharRangeSection.Start: + if (this.state === CharRangeSection.End) { + this.goSubtree = false; + } + else { + child = fresh(lineCollection); + currentNode.add(child); + this.startPath[this.startPath.length] = child; + } + break; + case CharRangeSection.Entire: + if (this.state !== CharRangeSection.End) { + child = fresh(lineCollection); + currentNode.add(child); + this.startPath[this.startPath.length] = child; + } + else { + if (!lineCollection.isLeaf()) { + child = fresh(lineCollection); + currentNode.add(child); + this.endBranch[this.endBranch.length] = child; + } + } + break; + case CharRangeSection.Mid: + this.goSubtree = false; + break; + case CharRangeSection.End: + if (this.state !== CharRangeSection.End) { + this.goSubtree = false; + } + else { + if (!lineCollection.isLeaf()) { + child = fresh(lineCollection); + currentNode.add(child); + this.endBranch[this.endBranch.length] = child; + } + } + break; + case CharRangeSection.PostEnd: + this.goSubtree = false; + if (this.state !== CharRangeSection.Start) { + currentNode.add(lineCollection); + } + break; + } + if (this.goSubtree) { + this.stack[this.stack.length] = child; + } + return lineCollection; + }; + EditWalker.prototype.leaf = function (relativeStart, relativeLength, ll) { + if (this.state === CharRangeSection.Start) { + this.initialText = ll.text.substring(0, relativeStart); + } + else if (this.state === CharRangeSection.Entire) { + this.initialText = ll.text.substring(0, relativeStart); + this.trailingText = ll.text.substring(relativeStart + relativeLength); + } + else { + this.trailingText = ll.text.substring(relativeStart + relativeLength); + } + }; + return EditWalker; + })(BaseLineIndexWalker); + var TextChange = (function () { + function TextChange(pos, deleteLen, insertedText) { + this.pos = pos; + this.deleteLen = deleteLen; + this.insertedText = insertedText; + } + TextChange.prototype.getTextChangeRange = function () { + return ts.createTextChangeRange(ts.createTextSpan(this.pos, this.deleteLen), this.insertedText ? this.insertedText.length : 0); + }; + return TextChange; + })(); + server.TextChange = TextChange; + var ScriptVersionCache = (function () { + function ScriptVersionCache() { + this.changes = []; + this.versions = []; + this.minVersion = 0; + this.currentVersion = 0; + } + ScriptVersionCache.prototype.edit = function (pos, deleteLen, insertedText) { + this.changes[this.changes.length] = new TextChange(pos, deleteLen, insertedText); + if ((this.changes.length > ScriptVersionCache.changeNumberThreshold) || + (deleteLen > ScriptVersionCache.changeLengthThreshold) || + (insertedText && (insertedText.length > ScriptVersionCache.changeLengthThreshold))) { + this.getSnapshot(); + } + }; + ScriptVersionCache.prototype.latest = function () { + return this.versions[this.currentVersion]; + }; + ScriptVersionCache.prototype.latestVersion = function () { + if (this.changes.length > 0) { + this.getSnapshot(); + } + return this.currentVersion; + }; + ScriptVersionCache.prototype.reloadFromFile = function (filename, cb) { + var content = this.host.readFile(filename); + 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; + 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]; + if (this.changes.length > 0) { + var snapIndex = this.latest().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); + } + snap = new LineIndexSnapshot(this.currentVersion + 1, this); + snap.index = snapIndex; + snap.changesSincePreviousVersion = this.changes; + this.currentVersion = snap.version; + this.versions[snap.version] = 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; + }; + ScriptVersionCache.prototype.getTextChangesBetweenVersions = function (oldVersion, newVersion) { + if (oldVersion < newVersion) { + if (oldVersion >= this.minVersion) { + var textChangeRanges = []; + for (var i = oldVersion + 1; i <= newVersion; i++) { + var snap = this.versions[i]; + for (var j = 0, len = snap.changesSincePreviousVersion.length; j < len; j++) { + var textChange = snap.changesSincePreviousVersion[j]; + textChangeRanges[textChangeRanges.length] = textChange.getTextChangeRange(); + } + } + return ts.collapseTextChangeRangesAcrossMultipleVersions(textChangeRanges); + } + else { + return undefined; + } + } + else { + return ts.unchangedTextChangeRange; + } + }; + ScriptVersionCache.fromString = function (host, script) { + var svc = new ScriptVersionCache(); + var snap = new LineIndexSnapshot(0, svc); + svc.versions[svc.currentVersion] = snap; + svc.host = host; + snap.index = new LineIndex(); + var lm = LineIndex.linesFromText(script); + snap.index.load(lm.lines); + return svc; + }; + ScriptVersionCache.changeNumberThreshold = 8; + ScriptVersionCache.changeLengthThreshold = 256; + ScriptVersionCache.maxVersions = 8; + return ScriptVersionCache; + })(); + server.ScriptVersionCache = ScriptVersionCache; + var LineIndexSnapshot = (function () { + function LineIndexSnapshot(version, cache) { + this.version = version; + this.cache = cache; + this.changesSincePreviousVersion = []; + } + LineIndexSnapshot.prototype.getText = function (rangeStart, rangeEnd) { + return this.index.getText(rangeStart, rangeEnd - rangeStart); + }; + LineIndexSnapshot.prototype.getLength = function () { + return this.index.root.charCount(); + }; + LineIndexSnapshot.prototype.getLineStartPositions = function () { + var starts = [-1]; + var count = 1; + var pos = 0; + this.index.every(function (ll, s, len) { + starts[count++] = pos; + pos += ll.text.length; + return true; + }, 0); + return starts; + }; + LineIndexSnapshot.prototype.getLineMapper = function () { + var _this = this; + return (function (line) { + return _this.index.lineNumberToInfo(line).offset; + }); + }; + LineIndexSnapshot.prototype.getTextChangeRangeSinceVersion = function (scriptVersion) { + if (this.version <= scriptVersion) { + return ts.unchangedTextChangeRange; + } + else { + return this.cache.getTextChangesBetweenVersions(scriptVersion, this.version); + } + }; + LineIndexSnapshot.prototype.getChangeRange = function (oldSnapshot) { + var oldSnap = oldSnapshot; + return this.getTextChangeRangeSinceVersion(oldSnap.version); + }; + return LineIndexSnapshot; + })(); + server.LineIndexSnapshot = LineIndexSnapshot; + var LineIndex = (function () { + function LineIndex() { + this.checkEdits = false; + } + LineIndex.prototype.charOffsetToLineNumberAndPos = function (charOffset) { + return this.root.charOffsetToLineNumberAndPos(1, charOffset); + }; + LineIndex.prototype.lineNumberToInfo = function (lineNumber) { + var lineCount = this.root.lineCount(); + if (lineNumber <= lineCount) { + var lineInfo = this.root.lineNumberToInfo(lineNumber, 0); + lineInfo.line = lineNumber; + return lineInfo; + } + else { + return { + line: lineNumber, + offset: this.root.charCount() + }; + } + }; + LineIndex.prototype.load = function (lines) { + if (lines.length > 0) { + var leaves = []; + for (var i = 0, len = lines.length; i < len; i++) { + leaves[i] = new LineLeaf(lines[i]); + } + this.root = LineIndex.buildTreeFromBottom(leaves); + } + else { + this.root = new LineNode(); + } + }; + LineIndex.prototype.walk = function (rangeStart, rangeLength, walkFns) { + this.root.walk(rangeStart, rangeLength, walkFns); + }; + LineIndex.prototype.getText = function (rangeStart, rangeLength) { + var accum = ""; + if ((rangeLength > 0) && (rangeStart < this.root.charCount())) { + this.walk(rangeStart, rangeLength, { + goSubtree: true, + done: false, + leaf: function (relativeStart, relativeLength, ll) { + accum = accum.concat(ll.text.substring(relativeStart, relativeStart + relativeLength)); + } + }); + } + return accum; + }; + LineIndex.prototype.getLength = function () { + return this.root.charCount(); + }; + LineIndex.prototype.every = function (f, rangeStart, rangeEnd) { + if (!rangeEnd) { + rangeEnd = this.root.charCount(); + } + var walkFns = { + goSubtree: true, + done: false, + leaf: function (relativeStart, relativeLength, ll) { + if (!f(ll, relativeStart, relativeLength)) { + this.done = true; + } + } + }; + this.walk(rangeStart, rangeEnd - rangeStart, walkFns); + return !walkFns.done; + }; + LineIndex.prototype.edit = function (pos, deleteLength, newText) { + function editFlat(source, s, dl, nt) { + if (nt === void 0) { nt = ""; } + return source.substring(0, s) + nt + source.substring(s + dl, source.length); + } + if (this.root.charCount() === 0) { + if (newText) { + this.load(LineIndex.linesFromText(newText).lines); + return this; + } + } + else { + if (this.checkEdits) { + var checkText = editFlat(this.getText(0, this.root.charCount()), pos, deleteLength, newText); + } + var walker = new EditWalker(); + if (pos >= this.root.charCount()) { + pos = this.root.charCount() - 1; + var endString = this.getText(pos, 1); + if (newText) { + newText = endString + newText; + } + else { + newText = endString; + } + deleteLength = 0; + walker.suppressTrailingText = true; + } + else if (deleteLength > 0) { + var e = pos + deleteLength; + var lineInfo = this.charOffsetToLineNumberAndPos(e); + if ((lineInfo && (lineInfo.offset === 0))) { + deleteLength += lineInfo.text.length; + if (newText) { + newText = newText + lineInfo.text; + } + else { + newText = lineInfo.text; + } + } + } + if (pos < this.root.charCount()) { + this.root.walk(pos, deleteLength, walker); + walker.insertLines(newText); + } + if (this.checkEdits) { + var updatedText = this.getText(0, this.root.charCount()); + ts.Debug.assert(checkText == updatedText, "buffer edit mismatch"); + } + return walker.lineIndex; + } + }; + LineIndex.buildTreeFromBottom = function (nodes) { + var nodeCount = Math.ceil(nodes.length / lineCollectionCapacity); + var interiorNodes = []; + var nodeIndex = 0; + for (var i = 0; i < nodeCount; i++) { + interiorNodes[i] = new LineNode(); + var charCount = 0; + var lineCount = 0; + for (var j = 0; j < lineCollectionCapacity; j++) { + if (nodeIndex < nodes.length) { + interiorNodes[i].add(nodes[nodeIndex]); + charCount += nodes[nodeIndex].charCount(); + lineCount += nodes[nodeIndex].lineCount(); + } + else { + break; + } + nodeIndex++; + } + interiorNodes[i].totalChars = charCount; + interiorNodes[i].totalLines = lineCount; + } + if (interiorNodes.length === 1) { + return interiorNodes[0]; + } + else { + return this.buildTreeFromBottom(interiorNodes); + } + }; + LineIndex.linesFromText = function (text) { + var lineStarts = ts.computeLineStarts(text); + if (lineStarts.length === 0) { + return { lines: [], lineMap: lineStarts }; + } + var lines = new Array(lineStarts.length); + var lc = lineStarts.length - 1; + for (var lmi = 0; lmi < lc; lmi++) { + lines[lmi] = text.substring(lineStarts[lmi], lineStarts[lmi + 1]); + } + var endText = text.substring(lineStarts[lc]); + if (endText.length > 0) { + lines[lc] = endText; + } + else { + lines.length--; + } + return { lines: lines, lineMap: lineStarts }; + }; + return LineIndex; + })(); + server.LineIndex = LineIndex; + var LineNode = (function () { + function LineNode() { + this.totalChars = 0; + this.totalLines = 0; + this.children = []; + } + LineNode.prototype.isLeaf = function () { + return false; + }; + LineNode.prototype.updateCounts = function () { + this.totalChars = 0; + this.totalLines = 0; + for (var i = 0, len = this.children.length; i < len; i++) { + var child = this.children[i]; + this.totalChars += child.charCount(); + this.totalLines += child.lineCount(); + } + }; + LineNode.prototype.execWalk = function (rangeStart, rangeLength, walkFns, childIndex, nodeType) { + if (walkFns.pre) { + walkFns.pre(rangeStart, rangeLength, this.children[childIndex], this, nodeType); + } + if (walkFns.goSubtree) { + this.children[childIndex].walk(rangeStart, rangeLength, walkFns); + if (walkFns.post) { + walkFns.post(rangeStart, rangeLength, this.children[childIndex], this, nodeType); + } + } + else { + walkFns.goSubtree = true; + } + return walkFns.done; + }; + LineNode.prototype.skipChild = function (relativeStart, relativeLength, childIndex, walkFns, nodeType) { + if (walkFns.pre && (!walkFns.done)) { + walkFns.pre(relativeStart, relativeLength, this.children[childIndex], this, nodeType); + walkFns.goSubtree = true; + } + }; + LineNode.prototype.walk = function (rangeStart, rangeLength, walkFns) { + var childIndex = 0; + var child = this.children[0]; + var childCharCount = child.charCount(); + var adjustedStart = rangeStart; + while (adjustedStart >= childCharCount) { + this.skipChild(adjustedStart, rangeLength, childIndex, walkFns, CharRangeSection.PreStart); + adjustedStart -= childCharCount; + child = this.children[++childIndex]; + childCharCount = child.charCount(); + } + if ((adjustedStart + rangeLength) <= childCharCount) { + if (this.execWalk(adjustedStart, rangeLength, walkFns, childIndex, CharRangeSection.Entire)) { + return; + } + } + else { + if (this.execWalk(adjustedStart, childCharCount - adjustedStart, walkFns, childIndex, CharRangeSection.Start)) { + return; + } + var adjustedLength = rangeLength - (childCharCount - adjustedStart); + child = this.children[++childIndex]; + childCharCount = child.charCount(); + while (adjustedLength > childCharCount) { + if (this.execWalk(0, childCharCount, walkFns, childIndex, CharRangeSection.Mid)) { + return; + } + adjustedLength -= childCharCount; + child = this.children[++childIndex]; + childCharCount = child.charCount(); + } + if (adjustedLength > 0) { + if (this.execWalk(0, adjustedLength, walkFns, childIndex, CharRangeSection.End)) { + return; + } + } + } + if (walkFns.pre) { + var clen = this.children.length; + if (childIndex < (clen - 1)) { + for (var ej = childIndex + 1; ej < clen; ej++) { + this.skipChild(0, 0, ej, walkFns, CharRangeSection.PostEnd); + } + } + } + }; + LineNode.prototype.charOffsetToLineNumberAndPos = function (lineNumber, charOffset) { + var childInfo = this.childFromCharOffset(lineNumber, charOffset); + if (!childInfo.child) { + return { + line: lineNumber, + offset: charOffset + }; + } + else if (childInfo.childIndex < this.children.length) { + if (childInfo.child.isLeaf()) { + return { + line: childInfo.lineNumber, + offset: childInfo.charOffset, + text: (childInfo.child).text, + leaf: (childInfo.child) + }; + } + else { + var lineNode = (childInfo.child); + return lineNode.charOffsetToLineNumberAndPos(childInfo.lineNumber, childInfo.charOffset); + } + } + else { + var lineInfo = this.lineNumberToInfo(this.lineCount(), 0); + return { line: this.lineCount(), offset: lineInfo.leaf.charCount() }; + } + }; + LineNode.prototype.lineNumberToInfo = function (lineNumber, charOffset) { + var childInfo = this.childFromLineNumber(lineNumber, charOffset); + if (!childInfo.child) { + return { + line: lineNumber, + offset: charOffset + }; + } + else if (childInfo.child.isLeaf()) { + return { + line: lineNumber, + offset: childInfo.charOffset, + text: (childInfo.child).text, + leaf: (childInfo.child) + }; + } + else { + var lineNode = (childInfo.child); + return lineNode.lineNumberToInfo(childInfo.relativeLineNumber, childInfo.charOffset); + } + }; + LineNode.prototype.childFromLineNumber = function (lineNumber, charOffset) { + var child; + var relativeLineNumber = lineNumber; + for (var i = 0, len = this.children.length; i < len; i++) { + child = this.children[i]; + var childLineCount = child.lineCount(); + if (childLineCount >= relativeLineNumber) { + break; + } + else { + relativeLineNumber -= childLineCount; + charOffset += child.charCount(); + } + } + return { + child: child, + childIndex: i, + relativeLineNumber: relativeLineNumber, + charOffset: charOffset + }; + }; + LineNode.prototype.childFromCharOffset = function (lineNumber, charOffset) { + var child; + for (var i = 0, len = this.children.length; i < len; i++) { + child = this.children[i]; + if (child.charCount() > charOffset) { + break; + } + else { + charOffset -= child.charCount(); + lineNumber += child.lineCount(); + } + } + return { + child: child, + childIndex: i, + charOffset: charOffset, + lineNumber: lineNumber + }; + }; + LineNode.prototype.splitAfter = function (childIndex) { + var splitNode; + var clen = this.children.length; + childIndex++; + var endLength = childIndex; + if (childIndex < clen) { + splitNode = new LineNode(); + while (childIndex < clen) { + splitNode.add(this.children[childIndex++]); + } + splitNode.updateCounts(); + } + this.children.length = endLength; + return splitNode; + }; + LineNode.prototype.remove = function (child) { + var childIndex = this.findChildIndex(child); + var clen = this.children.length; + if (childIndex < (clen - 1)) { + for (var i = childIndex; i < (clen - 1); i++) { + this.children[i] = this.children[i + 1]; + } + } + this.children.length--; + }; + LineNode.prototype.findChildIndex = function (child) { + var childIndex = 0; + var clen = this.children.length; + while ((this.children[childIndex] !== child) && (childIndex < clen)) + childIndex++; + return childIndex; + }; + LineNode.prototype.insertAt = function (child, nodes) { + var childIndex = this.findChildIndex(child); + var clen = this.children.length; + var nodeCount = nodes.length; + if ((clen < lineCollectionCapacity) && (childIndex === (clen - 1)) && (nodeCount === 1)) { + this.add(nodes[0]); + this.updateCounts(); + return []; + } + else { + var shiftNode = this.splitAfter(childIndex); + var nodeIndex = 0; + childIndex++; + while ((childIndex < lineCollectionCapacity) && (nodeIndex < nodeCount)) { + this.children[childIndex++] = nodes[nodeIndex++]; + } + var splitNodes = []; + var splitNodeCount = 0; + if (nodeIndex < nodeCount) { + splitNodeCount = Math.ceil((nodeCount - nodeIndex) / lineCollectionCapacity); + splitNodes = new Array(splitNodeCount); + var splitNodeIndex = 0; + for (var i = 0; i < splitNodeCount; i++) { + splitNodes[i] = new LineNode(); + } + var splitNode = splitNodes[0]; + while (nodeIndex < nodeCount) { + splitNode.add(nodes[nodeIndex++]); + if (splitNode.children.length === lineCollectionCapacity) { + splitNodeIndex++; + splitNode = splitNodes[splitNodeIndex]; + } + } + for (i = splitNodes.length - 1; i >= 0; i--) { + if (splitNodes[i].children.length === 0) { + splitNodes.length--; + } + } + } + if (shiftNode) { + splitNodes[splitNodes.length] = shiftNode; + } + this.updateCounts(); + for (i = 0; i < splitNodeCount; i++) { + splitNodes[i].updateCounts(); + } + return splitNodes; + } + }; + LineNode.prototype.add = function (collection) { + this.children[this.children.length] = collection; + return (this.children.length < lineCollectionCapacity); + }; + LineNode.prototype.charCount = function () { + return this.totalChars; + }; + LineNode.prototype.lineCount = function () { + return this.totalLines; + }; + return LineNode; + })(); + server.LineNode = LineNode; + var LineLeaf = (function () { + 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; + }; + LineLeaf.prototype.walk = function (rangeStart, rangeLength, walkFns) { + walkFns.leaf(rangeStart, rangeLength, this); + }; + LineLeaf.prototype.charCount = function () { + return this.text.length; + }; + LineLeaf.prototype.lineCount = function () { + return 1; + }; + return LineLeaf; + })(); + server.LineLeaf = LineLeaf; + })(server = ts.server || (ts.server = {})); +})(ts || (ts = {})); +var ts; +(function (ts) { + var server; + (function (server) { + var nodeproto = require('_debugger'); + var readline = require('readline'); + var path = require('path'); + var fs = require('fs'); + var rl = readline.createInterface({ + input: process.stdin, + output: process.stdout, + terminal: false + }); + var Logger = (function () { + function Logger(logFilename, level) { + this.logFilename = logFilename; + this.level = level; + this.fd = -1; + this.seq = 0; + this.inGroup = false; + this.firstInGroup = true; + } + Logger.padStringRight = function (str, padding) { + return (str + padding).slice(0, padding.length); + }; + Logger.prototype.close = function () { + if (this.fd >= 0) { + fs.close(this.fd); + } + }; + Logger.prototype.perftrc = function (s) { + this.msg(s, "Perf"); + }; + Logger.prototype.info = function (s) { + this.msg(s, "Info"); + }; + Logger.prototype.startGroup = function () { + this.inGroup = true; + this.firstInGroup = true; + }; + Logger.prototype.endGroup = function () { + this.inGroup = false; + this.seq++; + this.firstInGroup = true; + }; + Logger.prototype.loggingEnabled = function () { + return !!this.logFilename; + }; + Logger.prototype.isVerbose = function () { + return this.loggingEnabled() && (this.level == "verbose"); + }; + Logger.prototype.msg = function (s, type) { + if (type === void 0) { type = "Err"; } + if (this.fd < 0) { + if (this.logFilename) { + this.fd = fs.openSync(this.logFilename, "w"); + } + } + if (this.fd >= 0) { + s = s + "\n"; + var prefix = Logger.padStringRight(type + " " + this.seq.toString(), " "); + if (this.firstInGroup) { + s = prefix + s; + this.firstInGroup = false; + } + if (!this.inGroup) { + this.seq++; + this.firstInGroup = true; + } + var buf = new Buffer(s); + fs.writeSync(this.fd, buf, 0, buf.length, null); + } + }; + return Logger; + })(); + var IOSession = (function (_super) { + __extends(IOSession, _super); + function IOSession(host, logger) { + _super.call(this, host, Buffer.byteLength, process.hrtime, logger); + } + IOSession.prototype.exit = function () { + this.projectService.log("Exiting...", "Info"); + this.projectService.closeLog(); + process.exit(0); + }; + IOSession.prototype.listen = function () { + var _this = this; + rl.on('line', function (input) { + var message = input.trim(); + _this.onMessage(message); + }); + rl.on('close', function () { + _this.exit(); + }); + }; + return IOSession; + })(server.Session); + function parseLoggingEnvironmentString(logEnvStr) { + var logEnv = {}; + var args = logEnvStr.split(' '); + for (var i = 0, len = args.length; i < (len - 1); i += 2) { + var option = args[i]; + var value = args[i + 1]; + if (option && value) { + switch (option) { + case "-file": + logEnv.file = value; + break; + case "-level": + logEnv.detailLevel = value; + break; + } + } + } + return logEnv; + } + function createLoggerFromEnv() { + var fileName = undefined; + var detailLevel = "normal"; + 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.detailLevel) { + detailLevel = logEnv.detailLevel; + } + } + return new Logger(fileName, detailLevel); + } + var logger = createLoggerFromEnv(); + var pending = []; + var canWrite = true; + function writeMessage(s) { + if (!canWrite) { + pending.push(s); + } + else { + canWrite = false; + process.stdout.write(new Buffer(s, "utf8"), setCanWriteFlagAndWriteMessageIfNecessary); + } + } + function setCanWriteFlagAndWriteMessageIfNecessary() { + canWrite = true; + if (pending.length) { + writeMessage(pending.shift()); + } + } + ts.sys.write = function (s) { return writeMessage(s); }; + var ioSession = new IOSession(ts.sys, logger); + process.on('uncaughtException', function (err) { + ioSession.logError(err, "unknown"); + }); + ioSession.listen(); + })(server = ts.server || (ts.server = {})); +})(ts || (ts = {})); +var debugObjectHost = 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; + this.lineStartPositions = null; + } + 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.lookUp(resolutionsInFile, name); + return result ? { resolvedFileName: result } : undefined; + }); + }; + } + } + 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.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 null; + } + return JSON.parse(settingsJson); + }; + LanguageServiceShimHostAdapter.prototype.getScriptFileNames = function () { + var encoded = this.shimHost.getScriptFileNames(); + return this.files = JSON.parse(encoded); + }; + LanguageServiceShimHostAdapter.prototype.getScriptSnapshot = function (fileName) { + if (this.files && this.files.indexOf(fileName) < 0) { + return undefined; + } + var scriptSnapshot = this.shimHost.getScriptSnapshot(fileName); + return scriptSnapshot && new ScriptSnapshotShimAdapter(scriptSnapshot); + }; + 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.getDefaultLibFileName = function (options) { + try { + return this.shimHost.getDefaultLibFileName(JSON.stringify(options)); + } + catch (e) { + return ""; + } + }; + return LanguageServiceShimHostAdapter; + })(); + ts.LanguageServiceShimHostAdapter = LanguageServiceShimHostAdapter; + var ThrottledCancellationToken = (function () { + function ThrottledCancellationToken(hostCancellationToken) { + this.hostCancellationToken = hostCancellationToken; + this.lastCancellationCheckTime = 0; + } + ThrottledCancellationToken.prototype.isCancellationRequested = function () { + var time = Date.now(); + 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) { + this.shimHost = shimHost; + } + CoreServicesShimHostAdapter.prototype.readDirectory = function (rootDir, extension, exclude) { + var encoded; + try { + encoded = this.shimHost.readDirectory(rootDir, extension, JSON.stringify(exclude)); + } + catch (e) { + encoded = this.shimHost.readDirectory(rootDir, extension); + } + return JSON.parse(encoded); + }; + CoreServicesShimHostAdapter.prototype.fileExists = function (fileName) { + return this.shimHost.fileExists(fileName); + }; + CoreServicesShimHostAdapter.prototype.readFile = function (fileName) { + return this.shimHost.readFile(fileName); + }; + return CoreServicesShimHostAdapter; + })(); + ts.CoreServicesShimHostAdapter = CoreServicesShimHostAdapter; + function simpleForwardCall(logger, actionDescription, action, logPerformance) { + if (logPerformance) { + logger.log(actionDescription); + var start = Date.now(); + } + var result = action(); + if (logPerformance) { + var end = Date.now(); + 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) { + try { + var result = simpleForwardCall(logger, actionDescription, action, logPerformance); + return JSON.stringify({ 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) { + _super.call(this, factory); + this.host = host; + this.languageService = languageService; + this.logPerformance = false; + this.logger = this.host; + } + 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 () { + var classifications = _this.languageService.getSyntacticClassifications(fileName, ts.createTextSpan(start, length)); + return classifications; + }); + }; + LanguageServiceShimObject.prototype.getSemanticClassifications = function (fileName, start, length) { + var _this = this; + return this.forwardJSONCall("getSemanticClassifications('" + fileName + "', " + start + ", " + length + ")", function () { + var classifications = _this.languageService.getSemanticClassifications(fileName, ts.createTextSpan(start, length)); + return classifications; + }); + }; + 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 () { + var quickInfo = _this.languageService.getQuickInfoAtPosition(fileName, position); + return quickInfo; + }); + }; + LanguageServiceShimObject.prototype.getNameOrDottedNameSpan = function (fileName, startPos, endPos) { + var _this = this; + return this.forwardJSONCall("getNameOrDottedNameSpan('" + fileName + "', " + startPos + ", " + endPos + ")", function () { + var spanInfo = _this.languageService.getNameOrDottedNameSpan(fileName, startPos, endPos); + return spanInfo; + }); + }; + LanguageServiceShimObject.prototype.getBreakpointStatementAtPosition = function (fileName, position) { + var _this = this; + return this.forwardJSONCall("getBreakpointStatementAtPosition('" + fileName + "', " + position + ")", function () { + var spanInfo = _this.languageService.getBreakpointStatementAtPosition(fileName, position); + return spanInfo; + }); + }; + LanguageServiceShimObject.prototype.getSignatureHelpItems = function (fileName, position) { + var _this = this; + return this.forwardJSONCall("getSignatureHelpItems('" + fileName + "', " + position + ")", function () { + var signatureInfo = _this.languageService.getSignatureHelpItems(fileName, position); + return signatureInfo; + }); + }; + 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.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 () { + var textRanges = _this.languageService.getBraceMatchingAtPosition(fileName, position); + return textRanges; + }); + }; + 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 () { + var completion = _this.languageService.getCompletionsAtPosition(fileName, position); + return completion; + }); + }; + LanguageServiceShimObject.prototype.getCompletionEntryDetails = function (fileName, position, entryName) { + var _this = this; + return this.forwardJSONCall("getCompletionEntryDetails('" + fileName + "', " + position + ", " + entryName + ")", function () { + var details = _this.languageService.getCompletionEntryDetails(fileName, position, entryName); + return details; + }); + }; + LanguageServiceShimObject.prototype.getFormattingEditsForRange = function (fileName, start, end, options) { + var _this = this; + return this.forwardJSONCall("getFormattingEditsForRange('" + fileName + "', " + start + ", " + end + ")", function () { + var localOptions = JSON.parse(options); + var edits = _this.languageService.getFormattingEditsForRange(fileName, start, end, localOptions); + return edits; + }); + }; + LanguageServiceShimObject.prototype.getFormattingEditsForDocument = function (fileName, options) { + var _this = this; + return this.forwardJSONCall("getFormattingEditsForDocument('" + fileName + "')", function () { + var localOptions = JSON.parse(options); + var edits = _this.languageService.getFormattingEditsForDocument(fileName, localOptions); + return edits; + }); + }; + LanguageServiceShimObject.prototype.getFormattingEditsAfterKeystroke = function (fileName, position, key, options) { + var _this = this; + return this.forwardJSONCall("getFormattingEditsAfterKeystroke('" + fileName + "', " + position + ", '" + key + "')", function () { + var localOptions = JSON.parse(options); + var edits = _this.languageService.getFormattingEditsAfterKeystroke(fileName, position, key, localOptions); + return edits; + }); + }; + 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) { + var _this = this; + return this.forwardJSONCall("getNavigateToItems('" + searchValue + "', " + maxResultCount + ")", function () { + var items = _this.languageService.getNavigateToItems(searchValue, maxResultCount); + return items; + }); + }; + LanguageServiceShimObject.prototype.getNavigationBarItems = function (fileName) { + var _this = this; + return this.forwardJSONCall("getNavigationBarItems('" + fileName + "')", function () { + var items = _this.languageService.getNavigationBarItems(fileName); + return items; + }); + }; + LanguageServiceShimObject.prototype.getOutliningSpans = function (fileName) { + var _this = this; + return this.forwardJSONCall("getOutliningSpans('" + fileName + "')", function () { + var items = _this.languageService.getOutliningSpans(fileName); + return items; + }); + }; + LanguageServiceShimObject.prototype.getTodoComments = function (fileName, descriptors) { + var _this = this; + return this.forwardJSONCall("getTodoComments('" + fileName + "')", function () { + var items = _this.languageService.getTodoComments(fileName, JSON.parse(descriptors)); + return items; + }); + }; + LanguageServiceShimObject.prototype.getEmitOutput = function (fileName) { + var _this = this; + return this.forwardJSONCall("getEmitOutput('" + fileName + "')", function () { + var output = _this.languageService.getEmitOutput(fileName); + output.emitOutputStatus = output.emitSkipped ? 1 : 0; + return output; + }); + }; + 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) { + _super.call(this, factory); + this.logger = logger; + this.logPerformance = false; + this.classifier = ts.createClassifier(); + } + 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 items = classification.entries; + var result = ""; + for (var i = 0; i < items.length; i++) { + result += items[i].length + "\n"; + result += items[i].classification + "\n"; + } + result += classification.finalLexState; + return result; + }; + return ClassifierShimObject; + })(ShimBase); + 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; + } + 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.getPreProcessedFileInfo = function (fileName, sourceTextSnapshot) { + return this.forwardJSONCall("getPreProcessedFileInfo('" + fileName + "')", function () { + var result = ts.preProcessFile(sourceTextSnapshot.getText(0, sourceTextSnapshot.getLength())); + var convertResult = { + referencedFiles: [], + importedFiles: [], + ambientExternalModules: result.ambientExternalModules, + isLibFile: result.isLibFile + }; + ts.forEach(result.referencedFiles, function (refFile) { + convertResult.referencedFiles.push({ + path: ts.normalizePath(refFile.fileName), + position: refFile.pos, + length: refFile.end - refFile.pos + }); + }); + ts.forEach(result.importedFiles, function (importedFile) { + convertResult.importedFiles.push({ + path: ts.normalizeSlashes(importedFile.fileName), + position: importedFile.pos, + length: importedFile.end - importedFile.pos + }); + }); + return convertResult; + }); + }; + 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: {}, + files: [], + errors: [realizeDiagnostic(result.error, '\r\n')] + }; + } + var configFile = ts.parseJsonConfigFileContent(result.config, _this.host, ts.getDirectoryPath(ts.normalizeSlashes(fileName))); + return { + options: configFile.options, + files: configFile.fileNames, + errors: realizeDiagnostics(configFile.errors, '\r\n') + }; + }); + }; + CoreServicesShimObject.prototype.getDefaultCompilationSettings = function () { + return this.forwardJSONCall("getDefaultCompilationSettings()", function () { + return ts.getDefaultCompilerOptions(); + }); + }; + 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()); + } + 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 = ts.createDocumentRegistry(); + }; + 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 = "1.6"; diff --git a/lib/typescript.d.ts b/lib/typescript.d.ts index 2adff1bf8a6..d94e55eb48f 100644 --- a/lib/typescript.d.ts +++ b/lib/typescript.d.ts @@ -13,2160 +13,2162 @@ See the Apache Version 2.0 License for specific language governing permissions and limitations under the License. ***************************************************************************** */ -declare namespace ts { - interface Map { - [index: string]: T; - } - interface FileMap { - get(fileName: string): T; - set(fileName: string, value: T): void; - contains(fileName: string): boolean; - remove(fileName: string): void; - forEachValue(f: (v: T) => void): void; - clear(): void; - } - interface TextRange { - pos: number; - end: number; - } - const enum SyntaxKind { - Unknown = 0, - EndOfFileToken = 1, - SingleLineCommentTrivia = 2, - MultiLineCommentTrivia = 3, - NewLineTrivia = 4, - WhitespaceTrivia = 5, - ShebangTrivia = 6, - 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, - RequireKeyword = 127, - NumberKeyword = 128, - SetKeyword = 129, - StringKeyword = 130, - SymbolKeyword = 131, - TypeKeyword = 132, - FromKeyword = 133, - OfKeyword = 134, - QualifiedName = 135, - ComputedPropertyName = 136, - TypeParameter = 137, - Parameter = 138, - Decorator = 139, - PropertySignature = 140, - PropertyDeclaration = 141, - MethodSignature = 142, - MethodDeclaration = 143, - Constructor = 144, - GetAccessor = 145, - SetAccessor = 146, - CallSignature = 147, - ConstructSignature = 148, - IndexSignature = 149, - TypePredicate = 150, - TypeReference = 151, - FunctionType = 152, - ConstructorType = 153, - TypeQuery = 154, - TypeLiteral = 155, - ArrayType = 156, - TupleType = 157, - UnionType = 158, - IntersectionType = 159, - ParenthesizedType = 160, - ObjectBindingPattern = 161, - ArrayBindingPattern = 162, - BindingElement = 163, - ArrayLiteralExpression = 164, - ObjectLiteralExpression = 165, - PropertyAccessExpression = 166, - ElementAccessExpression = 167, - CallExpression = 168, - NewExpression = 169, - TaggedTemplateExpression = 170, - TypeAssertionExpression = 171, - ParenthesizedExpression = 172, - FunctionExpression = 173, - ArrowFunction = 174, - DeleteExpression = 175, - TypeOfExpression = 176, - VoidExpression = 177, - AwaitExpression = 178, - PrefixUnaryExpression = 179, - PostfixUnaryExpression = 180, - BinaryExpression = 181, - ConditionalExpression = 182, - TemplateExpression = 183, - YieldExpression = 184, - SpreadElementExpression = 185, - ClassExpression = 186, - OmittedExpression = 187, - ExpressionWithTypeArguments = 188, - AsExpression = 189, - TemplateSpan = 190, - SemicolonClassElement = 191, - Block = 192, - VariableStatement = 193, - EmptyStatement = 194, - ExpressionStatement = 195, - IfStatement = 196, - DoStatement = 197, - WhileStatement = 198, - ForStatement = 199, - ForInStatement = 200, - ForOfStatement = 201, - ContinueStatement = 202, - BreakStatement = 203, - ReturnStatement = 204, - WithStatement = 205, - SwitchStatement = 206, - LabeledStatement = 207, - ThrowStatement = 208, - TryStatement = 209, - DebuggerStatement = 210, - VariableDeclaration = 211, - VariableDeclarationList = 212, - FunctionDeclaration = 213, - ClassDeclaration = 214, - InterfaceDeclaration = 215, - TypeAliasDeclaration = 216, - EnumDeclaration = 217, - ModuleDeclaration = 218, - ModuleBlock = 219, - CaseBlock = 220, - ImportEqualsDeclaration = 221, - ImportDeclaration = 222, - ImportClause = 223, - NamespaceImport = 224, - NamedImports = 225, - ImportSpecifier = 226, - ExportAssignment = 227, - ExportDeclaration = 228, - NamedExports = 229, - ExportSpecifier = 230, - MissingDeclaration = 231, - ExternalModuleReference = 232, - JsxElement = 233, - JsxSelfClosingElement = 234, - JsxOpeningElement = 235, - JsxText = 236, - JsxClosingElement = 237, - JsxAttribute = 238, - JsxSpreadAttribute = 239, - JsxExpression = 240, - CaseClause = 241, - DefaultClause = 242, - HeritageClause = 243, - CatchClause = 244, - PropertyAssignment = 245, - ShorthandPropertyAssignment = 246, - EnumMember = 247, - SourceFile = 248, - JSDocTypeExpression = 249, - JSDocAllType = 250, - JSDocUnknownType = 251, - JSDocArrayType = 252, - JSDocUnionType = 253, - JSDocTupleType = 254, - JSDocNullableType = 255, - JSDocNonNullableType = 256, - JSDocRecordType = 257, - JSDocRecordMember = 258, - JSDocTypeReference = 259, - JSDocOptionalType = 260, - JSDocFunctionType = 261, - JSDocVariadicType = 262, - JSDocConstructorType = 263, - JSDocThisType = 264, - JSDocComment = 265, - JSDocTag = 266, - JSDocParameterTag = 267, - JSDocReturnTag = 268, - JSDocTypeTag = 269, - JSDocTemplateTag = 270, - SyntaxList = 271, - Count = 272, - FirstAssignment = 56, - LastAssignment = 68, - FirstReservedWord = 70, - LastReservedWord = 105, - FirstKeyword = 70, - LastKeyword = 134, - FirstFutureReservedWord = 106, - LastFutureReservedWord = 114, - FirstTypeNode = 151, - LastTypeNode = 160, - FirstPunctuation = 15, - LastPunctuation = 68, - FirstToken = 0, - LastToken = 134, - FirstTriviaToken = 2, - LastTriviaToken = 7, - FirstLiteralToken = 8, - LastLiteralToken = 11, - FirstTemplateToken = 11, - LastTemplateToken = 14, - FirstBinaryOperator = 25, - LastBinaryOperator = 68, - FirstNode = 135, - } - const enum NodeFlags { - None = 0, - Export = 1, - Ambient = 2, - Public = 16, - Private = 32, - Protected = 64, - Static = 128, - Abstract = 256, - Async = 512, - Default = 1024, - MultiLine = 2048, - Synthetic = 4096, - DeclarationFile = 8192, - Let = 16384, - Const = 32768, - OctalLiteral = 65536, - Namespace = 131072, - ExportContext = 262144, - ContainsThis = 524288, - Modifier = 2035, - AccessibilityModifier = 112, - BlockScoped = 49152, - } - const enum JsxFlags { - None = 0, - IntrinsicNamedElement = 1, - IntrinsicIndexedElement = 2, - ClassElement = 4, - UnknownElement = 8, - IntrinsicElement = 3, - } - interface Node extends TextRange { - kind: SyntaxKind; - flags: NodeFlags; - decorators?: NodeArray; - modifiers?: ModifiersArray; - parent?: Node; - } - interface NodeArray extends Array, TextRange { - hasTrailingComma?: boolean; - } - interface ModifiersArray extends NodeArray { - flags: number; - } - interface Identifier extends PrimaryExpression { - text: string; - originalKeywordKind?: SyntaxKind; - } - interface QualifiedName extends Node { - left: EntityName; - right: Identifier; - } - type EntityName = Identifier | QualifiedName; - type DeclarationName = Identifier | LiteralExpression | ComputedPropertyName | BindingPattern; - interface Declaration extends Node { - _declarationBrand: any; - name?: DeclarationName; - } - interface ComputedPropertyName extends Node { - expression: Expression; - } - interface Decorator extends Node { - expression: LeftHandSideExpression; - } - interface TypeParameterDeclaration extends Declaration { - name: Identifier; - constraint?: TypeNode; - expression?: Expression; - } - interface SignatureDeclaration extends Declaration { - typeParameters?: NodeArray; - parameters: NodeArray; - type?: TypeNode; - } - interface VariableDeclaration extends Declaration { - parent?: VariableDeclarationList; - name: Identifier | BindingPattern; - type?: TypeNode; - initializer?: Expression; - } - interface VariableDeclarationList extends Node { - declarations: NodeArray; - } - interface ParameterDeclaration extends Declaration { - dotDotDotToken?: Node; - name: Identifier | BindingPattern; - questionToken?: Node; - type?: TypeNode; - initializer?: Expression; - } - interface BindingElement extends Declaration { - propertyName?: Identifier; - dotDotDotToken?: Node; - name: Identifier | BindingPattern; - initializer?: Expression; - } - interface PropertyDeclaration extends Declaration, ClassElement { - name: DeclarationName; - questionToken?: Node; - type?: TypeNode; - initializer?: Expression; - } - interface ObjectLiteralElement extends Declaration { - _objectLiteralBrandBrand: any; - } - interface PropertyAssignment extends ObjectLiteralElement { - _propertyAssignmentBrand: any; - name: DeclarationName; - questionToken?: Node; - initializer: Expression; - } - interface ShorthandPropertyAssignment extends ObjectLiteralElement { - name: Identifier; - questionToken?: Node; - equalsToken?: Node; - objectAssignmentInitializer?: Expression; - } - interface VariableLikeDeclaration extends Declaration { - propertyName?: Identifier; - dotDotDotToken?: Node; - name: DeclarationName; - questionToken?: Node; - type?: TypeNode; - initializer?: Expression; - } - interface BindingPattern extends Node { - elements: NodeArray; - } - /** - * Several node kinds share function-like features such as a signature, - * a name, and a body. These nodes should extend FunctionLikeDeclaration. - * Examples: - * - FunctionDeclaration - * - MethodDeclaration - * - AccessorDeclaration - */ - interface FunctionLikeDeclaration extends SignatureDeclaration { - _functionLikeDeclarationBrand: any; - asteriskToken?: Node; - questionToken?: Node; - body?: Block | Expression; - } - interface FunctionDeclaration extends FunctionLikeDeclaration, Statement { - name?: Identifier; - body?: Block; - } - interface MethodDeclaration extends FunctionLikeDeclaration, ClassElement, ObjectLiteralElement { - body?: Block; - } - interface ConstructorDeclaration extends FunctionLikeDeclaration, ClassElement { - body?: Block; - } - interface SemicolonClassElement extends ClassElement { - _semicolonClassElementBrand: any; - } - interface AccessorDeclaration extends FunctionLikeDeclaration, ClassElement, ObjectLiteralElement { - _accessorDeclarationBrand: any; - body: Block; - } - interface IndexSignatureDeclaration extends SignatureDeclaration, ClassElement { - _indexSignatureDeclarationBrand: any; - } - interface TypeNode extends Node { - _typeNodeBrand: any; - } - interface FunctionOrConstructorTypeNode extends TypeNode, SignatureDeclaration { - _functionOrConstructorTypeNodeBrand: any; - } - interface TypeReferenceNode extends TypeNode { - typeName: EntityName; - typeArguments?: NodeArray; - } - interface TypePredicateNode extends TypeNode { - parameterName: Identifier; - type: TypeNode; - } - interface TypeQueryNode extends TypeNode { - exprName: EntityName; - } - interface TypeLiteralNode extends TypeNode, Declaration { - members: NodeArray; - } - interface ArrayTypeNode extends TypeNode { - elementType: TypeNode; - } - interface TupleTypeNode extends TypeNode { - elementTypes: NodeArray; - } - interface UnionOrIntersectionTypeNode extends TypeNode { - types: NodeArray; - } - interface UnionTypeNode extends UnionOrIntersectionTypeNode { - } - interface IntersectionTypeNode extends UnionOrIntersectionTypeNode { - } - interface ParenthesizedTypeNode extends TypeNode { - type: TypeNode; - } - interface StringLiteral extends LiteralExpression, TypeNode { - _stringLiteralBrand: any; - } - interface Expression extends Node { - _expressionBrand: any; - contextualType?: Type; - } - interface UnaryExpression extends Expression { - _unaryExpressionBrand: any; - } - interface IncrementExpression extends UnaryExpression { - _incrementExpressionBrand: any; - } - interface PrefixUnaryExpression extends IncrementExpression { - operator: SyntaxKind; - operand: UnaryExpression; - } - interface PostfixUnaryExpression extends IncrementExpression { - operand: LeftHandSideExpression; - operator: SyntaxKind; - } - interface PostfixExpression extends UnaryExpression { - _postfixExpressionBrand: any; - } - interface LeftHandSideExpression extends IncrementExpression { - _leftHandSideExpressionBrand: any; - } - interface MemberExpression extends LeftHandSideExpression { - _memberExpressionBrand: any; - } - interface PrimaryExpression extends MemberExpression { - _primaryExpressionBrand: any; - } - interface DeleteExpression extends UnaryExpression { - expression: UnaryExpression; - } - interface TypeOfExpression extends UnaryExpression { - expression: UnaryExpression; - } - interface VoidExpression extends UnaryExpression { - expression: UnaryExpression; - } - interface AwaitExpression extends UnaryExpression { - expression: UnaryExpression; - } - interface YieldExpression extends Expression { - asteriskToken?: Node; - expression?: Expression; - } - interface BinaryExpression extends Expression { - left: Expression; - operatorToken: Node; - right: Expression; - } - interface ConditionalExpression extends Expression { - condition: Expression; - questionToken: Node; - whenTrue: Expression; - colonToken: Node; - whenFalse: Expression; - } - interface FunctionExpression extends PrimaryExpression, FunctionLikeDeclaration { - name?: Identifier; - body: Block | Expression; - } - interface ArrowFunction extends Expression, FunctionLikeDeclaration { - equalsGreaterThanToken: Node; - } - interface LiteralExpression extends PrimaryExpression { - text: string; - isUnterminated?: boolean; - hasExtendedUnicodeEscape?: boolean; - } - interface TemplateExpression extends PrimaryExpression { - head: LiteralExpression; - templateSpans: NodeArray; - } - interface TemplateSpan extends Node { - expression: Expression; - literal: LiteralExpression; - } - interface ParenthesizedExpression extends PrimaryExpression { - expression: Expression; - } - interface ArrayLiteralExpression extends PrimaryExpression { - elements: NodeArray; - } - interface SpreadElementExpression extends Expression { - expression: Expression; - } - interface ObjectLiteralExpression extends PrimaryExpression, Declaration { - properties: NodeArray; - } - interface PropertyAccessExpression extends MemberExpression { - expression: LeftHandSideExpression; - dotToken: Node; - name: Identifier; - } - interface ElementAccessExpression extends MemberExpression { - expression: LeftHandSideExpression; - argumentExpression?: Expression; - } - interface CallExpression extends LeftHandSideExpression { - expression: LeftHandSideExpression; - typeArguments?: NodeArray; - arguments: NodeArray; - } - interface ExpressionWithTypeArguments extends TypeNode { - expression: LeftHandSideExpression; - typeArguments?: NodeArray; - } - interface NewExpression extends CallExpression, PrimaryExpression { - } - interface TaggedTemplateExpression extends MemberExpression { - tag: LeftHandSideExpression; - template: LiteralExpression | TemplateExpression; - } - type CallLikeExpression = CallExpression | NewExpression | TaggedTemplateExpression | Decorator; - interface AsExpression extends Expression { - expression: Expression; - type: TypeNode; - } - interface TypeAssertion extends UnaryExpression { - type: TypeNode; - expression: UnaryExpression; - } - type AssertionExpression = TypeAssertion | AsExpression; - interface JsxElement extends PrimaryExpression { - openingElement: JsxOpeningElement; - children: NodeArray; - closingElement: JsxClosingElement; - } - interface JsxOpeningElement extends Expression { - _openingElementBrand?: any; - tagName: EntityName; - attributes: NodeArray; - } - interface JsxSelfClosingElement extends PrimaryExpression, JsxOpeningElement { - _selfClosingElementBrand?: any; - } - type JsxOpeningLikeElement = JsxSelfClosingElement | JsxOpeningElement; - interface JsxAttribute extends Node { - name: Identifier; - initializer?: Expression; - } - interface JsxSpreadAttribute extends Node { - expression: Expression; - } - interface JsxClosingElement extends Node { - tagName: EntityName; - } - interface JsxExpression extends Expression { - expression?: Expression; - } - interface JsxText extends Node { - _jsxTextExpressionBrand: any; - } - type JsxChild = JsxText | JsxExpression | JsxElement | JsxSelfClosingElement; - interface Statement extends Node { - _statementBrand: any; - } - interface Block extends Statement { - statements: NodeArray; - } - interface VariableStatement extends Statement { - declarationList: VariableDeclarationList; - } - interface ExpressionStatement extends Statement { - expression: Expression; - } - interface IfStatement extends Statement { - expression: Expression; - thenStatement: Statement; - elseStatement?: Statement; - } - interface IterationStatement extends Statement { - statement: Statement; - } - interface DoStatement extends IterationStatement { - expression: Expression; - } - interface WhileStatement extends IterationStatement { - expression: Expression; - } - interface ForStatement extends IterationStatement { - initializer?: VariableDeclarationList | Expression; - condition?: Expression; - incrementor?: Expression; - } - interface ForInStatement extends IterationStatement { - initializer: VariableDeclarationList | Expression; - expression: Expression; - } - interface ForOfStatement extends IterationStatement { - initializer: VariableDeclarationList | Expression; - expression: Expression; - } - interface BreakOrContinueStatement extends Statement { - label?: Identifier; - } - interface ReturnStatement extends Statement { - expression?: Expression; - } - interface WithStatement extends Statement { - expression: Expression; - statement: Statement; - } - interface SwitchStatement extends Statement { - expression: Expression; - caseBlock: CaseBlock; - } - interface CaseBlock extends Node { - clauses: NodeArray; - } - interface CaseClause extends Node { - expression?: Expression; - statements: NodeArray; - } - interface DefaultClause extends Node { - statements: NodeArray; - } - type CaseOrDefaultClause = CaseClause | DefaultClause; - interface LabeledStatement extends Statement { - label: Identifier; - statement: Statement; - } - interface ThrowStatement extends Statement { - expression: Expression; - } - interface TryStatement extends Statement { - tryBlock: Block; - catchClause?: CatchClause; - finallyBlock?: Block; - } - interface CatchClause extends Node { - variableDeclaration: VariableDeclaration; - block: Block; - } - interface ClassLikeDeclaration extends Declaration { - name?: Identifier; - typeParameters?: NodeArray; - heritageClauses?: NodeArray; - members: NodeArray; - } - interface ClassDeclaration extends ClassLikeDeclaration, Statement { - } - interface ClassExpression extends ClassLikeDeclaration, PrimaryExpression { - } - interface ClassElement extends Declaration { - _classElementBrand: any; - } - interface InterfaceDeclaration extends Declaration, Statement { - name: Identifier; - typeParameters?: NodeArray; - heritageClauses?: NodeArray; - members: NodeArray; - } - interface HeritageClause extends Node { - token: SyntaxKind; - types?: NodeArray; - } - interface TypeAliasDeclaration extends Declaration, Statement { - name: Identifier; - typeParameters?: NodeArray; - type: TypeNode; - } - interface EnumMember extends Declaration { - name: DeclarationName; - initializer?: Expression; - } - interface EnumDeclaration extends Declaration, Statement { - name: Identifier; - members: NodeArray; - } - interface ModuleDeclaration extends Declaration, Statement { - name: Identifier | LiteralExpression; - body: ModuleBlock | ModuleDeclaration; - } - interface ModuleBlock extends Node, Statement { - statements: NodeArray; - } - interface ImportEqualsDeclaration extends Declaration, Statement { - name: Identifier; - moduleReference: EntityName | ExternalModuleReference; - } - interface ExternalModuleReference extends Node { - expression?: Expression; - } - interface ImportDeclaration extends Statement { - importClause?: ImportClause; - moduleSpecifier: Expression; - } - interface ImportClause extends Declaration { - name?: Identifier; - namedBindings?: NamespaceImport | NamedImports; - } - interface NamespaceImport extends Declaration { - name: Identifier; - } - interface ExportDeclaration extends Declaration, Statement { - exportClause?: NamedExports; - moduleSpecifier?: Expression; - } - interface NamedImportsOrExports extends Node { - elements: NodeArray; - } - type NamedImports = NamedImportsOrExports; - type NamedExports = NamedImportsOrExports; - interface ImportOrExportSpecifier extends Declaration { - propertyName?: Identifier; - name: Identifier; - } - type ImportSpecifier = ImportOrExportSpecifier; - type ExportSpecifier = ImportOrExportSpecifier; - interface ExportAssignment extends Declaration, Statement { - isExportEquals?: boolean; - expression: Expression; - } - interface FileReference extends TextRange { - fileName: string; - } - interface CommentRange extends TextRange { - hasTrailingNewLine?: boolean; - kind: SyntaxKind; - } - interface JSDocTypeExpression extends Node { - type: JSDocType; - } - interface JSDocType extends TypeNode { - _jsDocTypeBrand: any; - } - interface JSDocAllType extends JSDocType { - _JSDocAllTypeBrand: any; - } - interface JSDocUnknownType extends JSDocType { - _JSDocUnknownTypeBrand: any; - } - interface JSDocArrayType extends JSDocType { - elementType: JSDocType; - } - interface JSDocUnionType extends JSDocType { - types: NodeArray; - } - interface JSDocTupleType extends JSDocType { - types: NodeArray; - } - interface JSDocNonNullableType extends JSDocType { - type: JSDocType; - } - interface JSDocNullableType extends JSDocType { - type: JSDocType; - } - interface JSDocRecordType extends JSDocType, TypeLiteralNode { - members: NodeArray; - } - interface JSDocTypeReference extends JSDocType { - name: EntityName; - typeArguments: NodeArray; - } - interface JSDocOptionalType extends JSDocType { - type: JSDocType; - } - interface JSDocFunctionType extends JSDocType, SignatureDeclaration { - parameters: NodeArray; - type: JSDocType; - } - interface JSDocVariadicType extends JSDocType { - type: JSDocType; - } - interface JSDocConstructorType extends JSDocType { - type: JSDocType; - } - interface JSDocThisType extends JSDocType { - type: JSDocType; - } - interface JSDocRecordMember extends PropertyDeclaration { - name: Identifier | LiteralExpression; - type?: JSDocType; - } - interface JSDocComment extends Node { - tags: NodeArray; - } - interface JSDocTag extends Node { - atToken: Node; - tagName: Identifier; - } - interface JSDocTemplateTag extends JSDocTag { - typeParameters: NodeArray; - } - interface JSDocReturnTag extends JSDocTag { - typeExpression: JSDocTypeExpression; - } - interface JSDocTypeTag extends JSDocTag { - typeExpression: JSDocTypeExpression; - } - interface JSDocParameterTag extends JSDocTag { - preParameterName?: Identifier; - typeExpression?: JSDocTypeExpression; - postParameterName?: Identifier; - isBracketed: boolean; - } - interface SourceFile extends Declaration { - statements: NodeArray; - endOfFileToken: Node; - fileName: string; - text: string; - amdDependencies: { - path: string; - name: string; - }[]; - moduleName: string; - referencedFiles: FileReference[]; - languageVariant: LanguageVariant; - /** - * lib.d.ts should have a reference comment like - * - * /// - * - * If any other file has this comment, it signals not to include lib.d.ts - * because this containing file is intended to act as a default library. - */ - hasNoDefaultLib: boolean; - languageVersion: ScriptTarget; - } - interface ScriptReferenceHost { - getCompilerOptions(): CompilerOptions; - getSourceFile(fileName: string): SourceFile; - getCurrentDirectory(): string; - } - interface ParseConfigHost { - readDirectory(rootDir: string, extension: string, exclude: string[]): string[]; - } - interface WriteFileCallback { - (fileName: string, data: string, writeByteOrderMark: boolean, onError?: (message: string) => void): void; - } - class OperationCanceledException { - } - interface CancellationToken { - isCancellationRequested(): boolean; - /** @throws OperationCanceledException if isCancellationRequested is true */ - throwIfCancellationRequested(): void; - } - interface Program extends ScriptReferenceHost { - /** - * Get a list of root file names that were passed to a 'createProgram' - */ - getRootFileNames(): string[]; - /** - * Get a list of files in the program - */ - getSourceFiles(): SourceFile[]; - /** - * Emits the JavaScript and declaration files. If targetSourceFile is not specified, then - * the JavaScript and declaration files will be produced for all the files in this program. - * If targetSourceFile is specified, then only the JavaScript and declaration for that - * specific file will be generated. - * - * If writeFile is not specified then the writeFile callback from the compiler host will be - * used for writing the JavaScript and declaration files. Otherwise, the writeFile parameter - * will be invoked when writing the JavaScript and declaration files. - */ - emit(targetSourceFile?: SourceFile, writeFile?: WriteFileCallback, cancellationToken?: CancellationToken): EmitResult; - getOptionsDiagnostics(cancellationToken?: CancellationToken): Diagnostic[]; - getGlobalDiagnostics(cancellationToken?: CancellationToken): Diagnostic[]; - getSyntacticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): Diagnostic[]; - getSemanticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): Diagnostic[]; - getDeclarationDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): Diagnostic[]; - /** - * Gets a type checker that can be used to semantically analyze source fils in the program. - */ - getTypeChecker(): TypeChecker; - } - interface SourceMapSpan { - /** Line number in the .js file. */ - emittedLine: number; - /** Column number in the .js file. */ - emittedColumn: number; - /** Line number in the .ts file. */ - sourceLine: number; - /** Column number in the .ts file. */ - sourceColumn: number; - /** Optional name (index into names array) associated with this span. */ - nameIndex?: number; - /** .ts file (index into sources array) associated with this span */ - sourceIndex: number; - } - interface SourceMapData { - sourceMapFilePath: string; - jsSourceMappingURL: string; - sourceMapFile: string; - sourceMapSourceRoot: string; - sourceMapSources: string[]; - sourceMapSourcesContent?: string[]; - inputSourceFileNames: string[]; - sourceMapNames?: string[]; - sourceMapMappings: string; - sourceMapDecodedMappings: SourceMapSpan[]; - } - /** Return code used by getEmitOutput function to indicate status of the function */ - enum ExitStatus { - Success = 0, - DiagnosticsPresent_OutputsSkipped = 1, - DiagnosticsPresent_OutputsGenerated = 2, - } - interface EmitResult { - emitSkipped: boolean; - diagnostics: Diagnostic[]; - } - interface TypeChecker { - getTypeOfSymbolAtLocation(symbol: Symbol, node: Node): Type; - getDeclaredTypeOfSymbol(symbol: Symbol): Type; - getPropertiesOfType(type: Type): Symbol[]; - getPropertyOfType(type: Type, propertyName: string): Symbol; - getSignaturesOfType(type: Type, kind: SignatureKind): Signature[]; - getIndexTypeOfType(type: Type, kind: IndexKind): Type; - getBaseTypes(type: InterfaceType): ObjectType[]; - getReturnTypeOfSignature(signature: Signature): Type; - getSymbolsInScope(location: Node, meaning: SymbolFlags): Symbol[]; - getSymbolAtLocation(node: Node): Symbol; - getShorthandAssignmentValueSymbol(location: Node): Symbol; - getTypeAtLocation(node: Node): Type; - typeToString(type: Type, enclosingDeclaration?: Node, flags?: TypeFormatFlags): string; - symbolToString(symbol: Symbol, enclosingDeclaration?: Node, meaning?: SymbolFlags): string; - getSymbolDisplayBuilder(): SymbolDisplayBuilder; - getFullyQualifiedName(symbol: Symbol): string; - getAugmentedPropertiesOfType(type: Type): Symbol[]; - getRootSymbols(symbol: Symbol): Symbol[]; - getContextualType(node: Expression): Type; - getResolvedSignature(node: CallLikeExpression, candidatesOutArray?: Signature[]): Signature; - getSignatureFromDeclaration(declaration: SignatureDeclaration): Signature; - isImplementationOfOverload(node: FunctionLikeDeclaration): boolean; - isUndefinedSymbol(symbol: Symbol): boolean; - isArgumentsSymbol(symbol: Symbol): boolean; - getConstantValue(node: EnumMember | PropertyAccessExpression | ElementAccessExpression): number; - isValidPropertyAccess(node: PropertyAccessExpression | QualifiedName, propertyName: string): boolean; - getAliasedSymbol(symbol: Symbol): Symbol; - getExportsOfModule(moduleSymbol: Symbol): Symbol[]; - getJsxElementAttributesType(elementNode: JsxOpeningLikeElement): Type; - getJsxIntrinsicTagNames(): Symbol[]; - isOptionalParameter(node: ParameterDeclaration): boolean; - } - interface SymbolDisplayBuilder { - buildTypeDisplay(type: Type, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; - buildSymbolDisplay(symbol: Symbol, writer: SymbolWriter, enclosingDeclaration?: Node, meaning?: SymbolFlags, flags?: SymbolFormatFlags): void; - buildSignatureDisplay(signatures: Signature, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; - buildParameterDisplay(parameter: Symbol, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; - buildTypeParameterDisplay(tp: TypeParameter, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; - buildTypeParameterDisplayFromSymbol(symbol: Symbol, writer: SymbolWriter, enclosingDeclaraiton?: Node, flags?: TypeFormatFlags): void; - buildDisplayForParametersAndDelimiters(parameters: Symbol[], writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; - buildDisplayForTypeParametersAndDelimiters(typeParameters: TypeParameter[], writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; - buildReturnTypeDisplay(signature: Signature, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; - } - interface SymbolWriter { - writeKeyword(text: string): void; - writeOperator(text: string): void; - writePunctuation(text: string): void; - writeSpace(text: string): void; - writeStringLiteral(text: string): void; - writeParameter(text: string): void; - writeSymbol(text: string, symbol: Symbol): void; - writeLine(): void; - increaseIndent(): void; - decreaseIndent(): void; - clear(): void; - trackSymbol(symbol: Symbol, enclosingDeclaration?: Node, meaning?: SymbolFlags): void; - reportInaccessibleThisError(): void; - } - const enum TypeFormatFlags { - None = 0, - WriteArrayAsGenericType = 1, - UseTypeOfFunction = 2, - NoTruncation = 4, - WriteArrowStyleSignature = 8, - WriteOwnNameForAnyLike = 16, - WriteTypeArgumentsOfSignature = 32, - InElementType = 64, - UseFullyQualifiedType = 128, - } - const enum SymbolFormatFlags { - None = 0, - WriteTypeParametersOrArguments = 1, - UseOnlyExternalAliasing = 2, - } - interface TypePredicate { - parameterName: string; - parameterIndex: number; - type: Type; - } - const enum SymbolFlags { - None = 0, - FunctionScopedVariable = 1, - BlockScopedVariable = 2, - Property = 4, - EnumMember = 8, - Function = 16, - Class = 32, - Interface = 64, - ConstEnum = 128, - RegularEnum = 256, - ValueModule = 512, - NamespaceModule = 1024, - TypeLiteral = 2048, - ObjectLiteral = 4096, - Method = 8192, - Constructor = 16384, - GetAccessor = 32768, - SetAccessor = 65536, - Signature = 131072, - TypeParameter = 262144, - TypeAlias = 524288, - ExportValue = 1048576, - ExportType = 2097152, - ExportNamespace = 4194304, - Alias = 8388608, - Instantiated = 16777216, - Merged = 33554432, - Transient = 67108864, - Prototype = 134217728, - SyntheticProperty = 268435456, - Optional = 536870912, - ExportStar = 1073741824, - Enum = 384, - Variable = 3, - Value = 107455, - Type = 793056, - Namespace = 1536, - Module = 1536, - Accessor = 98304, - FunctionScopedVariableExcludes = 107454, - BlockScopedVariableExcludes = 107455, - ParameterExcludes = 107455, - PropertyExcludes = 107455, - EnumMemberExcludes = 107455, - FunctionExcludes = 106927, - ClassExcludes = 899519, - InterfaceExcludes = 792960, - RegularEnumExcludes = 899327, - ConstEnumExcludes = 899967, - ValueModuleExcludes = 106639, - NamespaceModuleExcludes = 0, - MethodExcludes = 99263, - GetAccessorExcludes = 41919, - SetAccessorExcludes = 74687, - TypeParameterExcludes = 530912, - TypeAliasExcludes = 793056, - AliasExcludes = 8388608, - ModuleMember = 8914931, - ExportHasLocal = 944, - HasExports = 1952, - HasMembers = 6240, - BlockScoped = 418, - PropertyOrAccessor = 98308, - Export = 7340032, - } - interface Symbol { - flags: SymbolFlags; - name: string; - declarations?: Declaration[]; - valueDeclaration?: Declaration; - members?: SymbolTable; - exports?: SymbolTable; - } - interface SymbolTable { - [index: string]: Symbol; - } - const enum TypeFlags { - Any = 1, - String = 2, - Number = 4, - Boolean = 8, - Void = 16, - Undefined = 32, - Null = 64, - Enum = 128, - StringLiteral = 256, - TypeParameter = 512, - Class = 1024, - Interface = 2048, - Reference = 4096, - Tuple = 8192, - Union = 16384, - Intersection = 32768, - Anonymous = 65536, - Instantiated = 131072, - ObjectLiteral = 524288, - ESSymbol = 16777216, - ThisType = 33554432, - StringLike = 258, - NumberLike = 132, - ObjectType = 80896, - UnionOrIntersection = 49152, - StructuredType = 130048, - } - type DestructuringPattern = BindingPattern | ObjectLiteralExpression | ArrayLiteralExpression; - interface Type { - flags: TypeFlags; - symbol?: Symbol; - pattern?: DestructuringPattern; - } - interface StringLiteralType extends Type { - text: string; - } - interface ObjectType extends Type { - } - interface InterfaceType extends ObjectType { - typeParameters: TypeParameter[]; - outerTypeParameters: TypeParameter[]; - localTypeParameters: TypeParameter[]; - thisType: TypeParameter; - } - interface InterfaceTypeWithDeclaredMembers extends InterfaceType { - declaredProperties: Symbol[]; - declaredCallSignatures: Signature[]; - declaredConstructSignatures: Signature[]; - declaredStringIndexType: Type; - declaredNumberIndexType: Type; - } - interface TypeReference extends ObjectType { - target: GenericType; - typeArguments: Type[]; - } - interface GenericType extends InterfaceType, TypeReference { - } - interface TupleType extends ObjectType { - elementTypes: Type[]; - } - interface UnionOrIntersectionType extends Type { - types: Type[]; - } - interface UnionType extends UnionOrIntersectionType { - } - interface IntersectionType extends UnionOrIntersectionType { - } - interface TypeParameter extends Type { - constraint: Type; - } - const enum SignatureKind { - Call = 0, - Construct = 1, - } - interface Signature { - declaration: SignatureDeclaration; - typeParameters: TypeParameter[]; - parameters: Symbol[]; - typePredicate?: TypePredicate; - } - const enum IndexKind { - String = 0, - Number = 1, - } - interface DiagnosticMessage { - key: string; - category: DiagnosticCategory; - code: number; - } - /** - * A linked list of formatted diagnostic messages to be used as part of a multiline message. - * It is built from the bottom up, leaving the head to be the "main" diagnostic. - * While it seems that DiagnosticMessageChain is structurally similar to DiagnosticMessage, - * the difference is that messages are all preformatted in DMC. - */ - interface DiagnosticMessageChain { - messageText: string; - category: DiagnosticCategory; - code: number; - next?: DiagnosticMessageChain; - } - interface Diagnostic { - file: SourceFile; - start: number; - length: number; - messageText: string | DiagnosticMessageChain; - category: DiagnosticCategory; - code: number; - } - enum DiagnosticCategory { - Warning = 0, - Error = 1, - Message = 2, - } - const enum ModuleResolutionKind { - Classic = 1, - NodeJs = 2, - } - interface CompilerOptions { - allowNonTsExtensions?: boolean; - charset?: string; - declaration?: boolean; - diagnostics?: boolean; - emitBOM?: boolean; - help?: boolean; - init?: boolean; - inlineSourceMap?: boolean; - inlineSources?: boolean; - jsx?: JsxEmit; - listFiles?: boolean; - locale?: string; - mapRoot?: string; - module?: ModuleKind; - newLine?: NewLineKind; - noEmit?: boolean; - noEmitHelpers?: boolean; - noEmitOnError?: boolean; - noErrorTruncation?: boolean; - noImplicitAny?: boolean; - noLib?: boolean; - noResolve?: boolean; - out?: string; - outFile?: string; - outDir?: string; - preserveConstEnums?: boolean; - project?: string; - removeComments?: boolean; - rootDir?: string; - sourceMap?: boolean; - sourceRoot?: string; - suppressExcessPropertyErrors?: boolean; - suppressImplicitAnyIndexErrors?: boolean; - target?: ScriptTarget; - version?: boolean; - watch?: boolean; - isolatedModules?: boolean; - experimentalDecorators?: boolean; - emitDecoratorMetadata?: boolean; - moduleResolution?: ModuleResolutionKind; - [option: string]: string | number | boolean; - } - const enum ModuleKind { - None = 0, - CommonJS = 1, - AMD = 2, - UMD = 3, - System = 4, - ES6 = 5, - ES2015 = 5, - } - const enum JsxEmit { - None = 0, - Preserve = 1, - React = 2, - } - const enum NewLineKind { - CarriageReturnLineFeed = 0, - LineFeed = 1, - } - interface LineAndCharacter { - line: number; - character: number; - } - const enum ScriptTarget { - ES3 = 0, - ES5 = 1, - ES6 = 2, - ES2015 = 2, - Latest = 2, - } - const enum LanguageVariant { - Standard = 0, - JSX = 1, - } - interface ParsedCommandLine { - options: CompilerOptions; - fileNames: string[]; - errors: Diagnostic[]; - } - interface ModuleResolutionHost { - fileExists(fileName: string): boolean; - readFile(fileName: string): string; - } - interface ResolvedModule { - resolvedFileName: string; - isExternalLibraryImport?: boolean; - } - interface ResolvedModuleWithFailedLookupLocations { - resolvedModule: ResolvedModule; - failedLookupLocations: string[]; - } - interface CompilerHost extends ModuleResolutionHost { - getSourceFile(fileName: string, languageVersion: ScriptTarget, onError?: (message: string) => void): SourceFile; - getCancellationToken?(): CancellationToken; - getDefaultLibFileName(options: CompilerOptions): string; - writeFile: WriteFileCallback; - getCurrentDirectory(): string; - getCanonicalFileName(fileName: string): string; - useCaseSensitiveFileNames(): boolean; - getNewLine(): string; - resolveModuleNames?(moduleNames: string[], containingFile: string): ResolvedModule[]; - } - interface TextSpan { - start: number; - length: number; - } - interface TextChangeRange { - span: TextSpan; - newLength: number; - } -} -declare namespace ts { - interface System { - args: string[]; - newLine: string; - useCaseSensitiveFileNames: boolean; - write(s: string): void; - readFile(path: string, encoding?: string): string; - writeFile(path: string, data: string, writeByteOrderMark?: boolean): void; - watchFile?(path: string, callback: (path: string, removed?: boolean) => void): FileWatcher; - watchDirectory?(path: string, callback: (path: string) => void, recursive?: boolean): FileWatcher; - resolvePath(path: string): string; - fileExists(path: string): boolean; - directoryExists(path: string): boolean; - createDirectory(path: string): void; - getExecutingFilePath(): string; - getCurrentDirectory(): string; - readDirectory(path: string, extension?: string, exclude?: string[]): string[]; - getMemoryUsage?(): number; - exit(exitCode?: number): void; - } - interface FileWatcher { - close(): void; - } - var sys: System; -} -declare namespace ts { - interface ErrorCallback { - (message: DiagnosticMessage, length: number): void; - } - interface Scanner { - getStartPos(): number; - getToken(): SyntaxKind; - getTextPos(): number; - getTokenPos(): number; - getTokenText(): string; - getTokenValue(): string; - hasExtendedUnicodeEscape(): boolean; - hasPrecedingLineBreak(): boolean; - isIdentifier(): boolean; - isReservedWord(): boolean; - isUnterminated(): boolean; - reScanGreaterToken(): SyntaxKind; - reScanSlashToken(): SyntaxKind; - reScanTemplateToken(): SyntaxKind; - scanJsxIdentifier(): SyntaxKind; - reScanJsxToken(): SyntaxKind; - scanJsxToken(): SyntaxKind; - scan(): SyntaxKind; - setText(text: string, start?: number, length?: number): void; - setOnError(onError: ErrorCallback): void; - setScriptTarget(scriptTarget: ScriptTarget): void; - setLanguageVariant(variant: LanguageVariant): void; - setTextPos(textPos: number): void; - lookAhead(callback: () => T): T; - tryScan(callback: () => T): T; - } - function tokenToString(t: SyntaxKind): string; - function getPositionOfLineAndCharacter(sourceFile: SourceFile, line: number, character: number): number; - function getLineAndCharacterOfPosition(sourceFile: SourceFile, position: number): LineAndCharacter; - function isWhiteSpace(ch: number): boolean; - function isLineBreak(ch: number): boolean; - function couldStartTrivia(text: string, pos: number): boolean; - function getLeadingCommentRanges(text: string, pos: number): CommentRange[]; - function getTrailingCommentRanges(text: string, pos: number): CommentRange[]; - /** Optionally, get the shebang */ - function getShebang(text: string): string; - function isIdentifierStart(ch: number, languageVersion: ScriptTarget): boolean; - function isIdentifierPart(ch: number, languageVersion: ScriptTarget): boolean; - function createScanner(languageVersion: ScriptTarget, skipTrivia: boolean, languageVariant?: LanguageVariant, text?: string, onError?: ErrorCallback, start?: number, length?: number): Scanner; -} -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; - /** - * Called to merge all the changes that occurred across several versions of a script snapshot - * into a single change. i.e. if a user keeps making successive edits to a script we will - * have a text change from V1 to V2, V2 to V3, ..., Vn. - * - * This function will then merge those changes into a single change range valid between V1 and - * Vn. - */ - function collapseTextChangeRangesAcrossMultipleVersions(changes: TextChangeRange[]): TextChangeRange; - function getTypeParameterOwner(d: Declaration): Declaration; -} -declare namespace ts { - function getNodeConstructor(kind: SyntaxKind): new (pos?: number, end?: number) => Node; - 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): SourceFile; - function updateSourceFile(sourceFile: SourceFile, newText: string, textChangeRange: TextChangeRange, aggressiveChecks?: boolean): SourceFile; -} -declare namespace ts { - const version: string; - function findConfigFile(searchPath: string): string; - function resolveTripleslashReference(moduleName: string, containingFile: string): string; - function resolveModuleName(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost): ResolvedModuleWithFailedLookupLocations; - function nodeModuleNameResolver(moduleName: string, containingFile: string, 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[]; - function flattenDiagnosticMessageText(messageText: string | DiagnosticMessageChain, newLine: string): string; - function createProgram(rootNames: string[], options: CompilerOptions, host?: CompilerHost, oldProgram?: Program): Program; -} -declare namespace ts { - function parseCommandLine(commandLine: string[], readFile?: (path: string) => string): ParsedCommandLine; - /** - * Read tsconfig.json file - * @param fileName The path to the config file - */ - function readConfigFile(fileName: string, readFile: (path: string) => string): { - config?: any; - error?: Diagnostic; - }; - /** - * Parse the text of the tsconfig.json file - * @param fileName The path to the config file - * @param jsonText The text of the config file - */ - function parseConfigFileTextToJson(fileName: string, jsonText: string): { - config?: any; - error?: Diagnostic; - }; - /** - * Parse the contents of a config file (tsconfig.json). - * @param json The contents of the config file to parse - * @param host Instance of ParseConfigHost used to enumerate files in folder. - * @param basePath A root directory to resolve relative path entries in the config - * file to. e.g. outDir - */ - function parseJsonConfigFileContent(json: any, host: ParseConfigHost, basePath: string): ParsedCommandLine; - function convertCompilerOptionsFromJson(jsonOptions: any, basePath: string): { - options: CompilerOptions; - errors: Diagnostic[]; - }; -} -declare namespace ts { - /** The version of the language service API */ - let servicesVersion: string; - interface Node { - getSourceFile(): SourceFile; - getChildCount(sourceFile?: SourceFile): number; - getChildAt(index: number, sourceFile?: SourceFile): Node; - getChildren(sourceFile?: SourceFile): Node[]; - getStart(sourceFile?: SourceFile): number; - getFullStart(): number; - getEnd(): number; - getWidth(sourceFile?: SourceFile): number; - getFullWidth(): number; - getLeadingTriviaWidth(sourceFile?: SourceFile): number; - getFullText(sourceFile?: SourceFile): string; - getText(sourceFile?: SourceFile): string; - getFirstToken(sourceFile?: SourceFile): Node; - getLastToken(sourceFile?: SourceFile): Node; - } - interface Symbol { - getFlags(): SymbolFlags; - getName(): string; - getDeclarations(): Declaration[]; - getDocumentationComment(): SymbolDisplayPart[]; - } - interface Type { - getFlags(): TypeFlags; - getSymbol(): Symbol; - getProperties(): Symbol[]; - getProperty(propertyName: string): Symbol; - getApparentProperties(): Symbol[]; - getCallSignatures(): Signature[]; - getConstructSignatures(): Signature[]; - getStringIndexType(): Type; - getNumberIndexType(): Type; - getBaseTypes(): ObjectType[]; - } - interface Signature { - getDeclaration(): SignatureDeclaration; - getTypeParameters(): Type[]; - getParameters(): Symbol[]; - getReturnType(): Type; - getDocumentationComment(): SymbolDisplayPart[]; - } - interface SourceFile { - getLineAndCharacterOfPosition(pos: number): LineAndCharacter; - getLineStarts(): number[]; - getPositionOfLineAndCharacter(line: number, character: number): number; - update(newText: string, textChangeRange: TextChangeRange): SourceFile; - } - /** - * Represents an immutable snapshot of a script at a specified time.Once acquired, the - * snapshot is observably immutable. i.e. the same calls with the same parameters will return - * the same values. - */ - interface IScriptSnapshot { - /** Gets a portion of the script snapshot specified by [start, end). */ - getText(start: number, end: number): string; - /** Gets the length of this script snapshot. */ - getLength(): number; - /** - * Gets the TextChangeRange that describe how the text changed between this text and - * an older version. This information is used by the incremental parser to determine - * what sections of the script need to be re-parsed. 'undefined' can be returned if the - * change range cannot be determined. However, in that case, incremental parsing will - * not happen and the entire document will be re - parsed. - */ - getChangeRange(oldSnapshot: IScriptSnapshot): TextChangeRange; - /** Releases all resources held by this script snapshot */ - dispose?(): void; - } - module ScriptSnapshot { - function fromString(text: string): IScriptSnapshot; - } - interface PreProcessedFileInfo { - referencedFiles: FileReference[]; - importedFiles: FileReference[]; - ambientExternalModules: string[]; - isLibFile: boolean; - } - interface HostCancellationToken { - isCancellationRequested(): boolean; - } - interface LanguageServiceHost { - getCompilationSettings(): CompilerOptions; - getNewLine?(): string; - getProjectVersion?(): string; - getScriptFileNames(): string[]; - getScriptVersion(fileName: string): string; - getScriptSnapshot(fileName: string): IScriptSnapshot; - getLocalizedDiagnosticMessages?(): any; - getCancellationToken?(): HostCancellationToken; - getCurrentDirectory(): string; - getDefaultLibFileName(options: CompilerOptions): string; - log?(s: string): void; - trace?(s: string): void; - error?(s: string): void; - useCaseSensitiveFileNames?(): boolean; - resolveModuleNames?(moduleNames: string[], containingFile: string): ResolvedModule[]; - } - interface LanguageService { - cleanupSemanticCache(): void; - getSyntacticDiagnostics(fileName: string): Diagnostic[]; - getSemanticDiagnostics(fileName: string): Diagnostic[]; - getCompilerOptionsDiagnostics(): Diagnostic[]; - /** - * @deprecated Use getEncodedSyntacticClassifications instead. - */ - getSyntacticClassifications(fileName: string, span: TextSpan): ClassifiedSpan[]; - /** - * @deprecated Use getEncodedSemanticClassifications instead. - */ - getSemanticClassifications(fileName: string, span: TextSpan): ClassifiedSpan[]; - getEncodedSyntacticClassifications(fileName: string, span: TextSpan): Classifications; - getEncodedSemanticClassifications(fileName: string, span: TextSpan): Classifications; - getCompletionsAtPosition(fileName: string, position: number): CompletionInfo; - getCompletionEntryDetails(fileName: string, position: number, entryName: string): CompletionEntryDetails; - getQuickInfoAtPosition(fileName: string, position: number): QuickInfo; - getNameOrDottedNameSpan(fileName: string, startPos: number, endPos: number): TextSpan; - getBreakpointStatementAtPosition(fileName: string, position: number): TextSpan; - getSignatureHelpItems(fileName: string, position: number): SignatureHelpItems; - getRenameInfo(fileName: string, position: number): RenameInfo; - findRenameLocations(fileName: string, position: number, findInStrings: boolean, findInComments: boolean): RenameLocation[]; - getDefinitionAtPosition(fileName: string, position: number): DefinitionInfo[]; - getTypeDefinitionAtPosition(fileName: string, position: number): DefinitionInfo[]; - getReferencesAtPosition(fileName: string, position: number): ReferenceEntry[]; - findReferences(fileName: string, position: number): ReferencedSymbol[]; - getDocumentHighlights(fileName: string, position: number, filesToSearch: string[]): DocumentHighlights[]; - /** @deprecated */ - getOccurrencesAtPosition(fileName: string, position: number): ReferenceEntry[]; - getNavigateToItems(searchValue: string, maxResultCount?: number): NavigateToItem[]; - getNavigationBarItems(fileName: string): NavigationBarItem[]; - 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[]; - getDocCommentTemplateAtPosition(fileName: string, position: number): TextInsertion; - getEmitOutput(fileName: string): EmitOutput; - getProgram(): Program; - getSourceFile(fileName: string): SourceFile; - dispose(): void; - } - interface Classifications { - spans: number[]; - endOfLineState: EndOfLineState; - } - interface ClassifiedSpan { - textSpan: TextSpan; - classificationType: string; - } - interface NavigationBarItem { - text: string; - kind: string; - kindModifiers: string; - spans: TextSpan[]; - childItems: NavigationBarItem[]; - indent: number; - bolded: boolean; - grayed: boolean; - } - interface TodoCommentDescriptor { - text: string; - priority: number; - } - interface TodoComment { - descriptor: TodoCommentDescriptor; - message: string; - position: number; - } - class TextChange { - span: TextSpan; - newText: string; - } - interface TextInsertion { - newText: string; - /** The position in newText the caret should point to after the insertion. */ - caretOffset: number; - } - interface RenameLocation { - textSpan: TextSpan; - fileName: string; - } - interface ReferenceEntry { - textSpan: TextSpan; - fileName: string; - isWriteAccess: boolean; - } - interface DocumentHighlights { - fileName: string; - highlightSpans: HighlightSpan[]; - } - module HighlightSpanKind { - const none: string; - const definition: string; - const reference: string; - const writtenReference: string; - } - interface HighlightSpan { - fileName?: string; - textSpan: TextSpan; - kind: string; - } - interface NavigateToItem { - name: string; - kind: string; - kindModifiers: string; - matchKind: string; - isCaseSensitive: boolean; - fileName: string; - textSpan: TextSpan; - containerName: string; - containerKind: string; - } - interface EditorOptions { - IndentSize: number; - TabSize: number; - NewLineCharacter: string; - ConvertTabsToSpaces: boolean; - IndentStyle: IndentStyle; - } - enum IndentStyle { - None = 0, - Block = 1, - Smart = 2, - } - interface FormatCodeOptions extends EditorOptions { - InsertSpaceAfterCommaDelimiter: boolean; - InsertSpaceAfterSemicolonInForStatements: boolean; - InsertSpaceBeforeAndAfterBinaryOperators: boolean; - InsertSpaceAfterKeywordsInControlFlowStatements: boolean; - InsertSpaceAfterFunctionKeywordForAnonymousFunctions: boolean; - InsertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis: boolean; - InsertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets: boolean; - PlaceOpenBraceOnNewLineForFunctions: boolean; - PlaceOpenBraceOnNewLineForControlBlocks: boolean; - [s: string]: boolean | number | string; - } - interface DefinitionInfo { - fileName: string; - textSpan: TextSpan; - kind: string; - name: string; - containerKind: string; - containerName: string; - } - interface ReferencedSymbol { - definition: DefinitionInfo; - references: ReferenceEntry[]; - } - enum SymbolDisplayPartKind { - aliasName = 0, - className = 1, - enumName = 2, - fieldName = 3, - interfaceName = 4, - keyword = 5, - lineBreak = 6, - numericLiteral = 7, - stringLiteral = 8, - localName = 9, - methodName = 10, - moduleName = 11, - operator = 12, - parameterName = 13, - propertyName = 14, - punctuation = 15, - space = 16, - text = 17, - typeParameterName = 18, - enumMemberName = 19, - functionName = 20, - regularExpressionLiteral = 21, - } - interface SymbolDisplayPart { - text: string; - kind: string; - } - interface QuickInfo { - kind: string; - kindModifiers: string; - textSpan: TextSpan; - displayParts: SymbolDisplayPart[]; - documentation: SymbolDisplayPart[]; - } - interface RenameInfo { - canRename: boolean; - localizedErrorMessage: string; - displayName: string; - fullDisplayName: string; - kind: string; - kindModifiers: string; - triggerSpan: TextSpan; - } - interface SignatureHelpParameter { - name: string; - documentation: SymbolDisplayPart[]; - displayParts: SymbolDisplayPart[]; - isOptional: boolean; - } - /** - * Represents a single signature to show in signature help. - * The id is used for subsequent calls into the language service to ask questions about the - * signature help item in the context of any documents that have been updated. i.e. after - * an edit has happened, while signature help is still active, the host can ask important - * questions like 'what parameter is the user currently contained within?'. - */ - interface SignatureHelpItem { - isVariadic: boolean; - prefixDisplayParts: SymbolDisplayPart[]; - suffixDisplayParts: SymbolDisplayPart[]; - separatorDisplayParts: SymbolDisplayPart[]; - parameters: SignatureHelpParameter[]; - documentation: SymbolDisplayPart[]; - } - /** - * Represents a set of signature help items, and the preferred item that should be selected. - */ - interface SignatureHelpItems { - items: SignatureHelpItem[]; - applicableSpan: TextSpan; - selectedItemIndex: number; - argumentIndex: number; - argumentCount: number; - } - interface CompletionInfo { - isMemberCompletion: boolean; - isNewIdentifierLocation: boolean; - entries: CompletionEntry[]; - } - interface CompletionEntry { - name: string; - kind: string; - kindModifiers: string; - sortText: string; - } - interface CompletionEntryDetails { - name: string; - kind: string; - kindModifiers: string; - displayParts: SymbolDisplayPart[]; - documentation: SymbolDisplayPart[]; - } - interface OutliningSpan { - /** The span of the document to actually collapse. */ - textSpan: TextSpan; - /** The span of the document to display when the user hovers over the collapsed span. */ - hintSpan: TextSpan; - /** The text to display in the editor for the collapsed region. */ - bannerText: string; - /** - * Whether or not this region should be automatically collapsed when - * the 'Collapse to Definitions' command is invoked. - */ - autoCollapse: boolean; - } - interface EmitOutput { - outputFiles: OutputFile[]; - emitSkipped: boolean; - } - const enum OutputFileType { - JavaScript = 0, - SourceMap = 1, - Declaration = 2, - } - interface OutputFile { - name: string; - writeByteOrderMark: boolean; - text: string; - } - const enum EndOfLineState { - None = 0, - InMultiLineCommentTrivia = 1, - InSingleQuoteStringLiteral = 2, - InDoubleQuoteStringLiteral = 3, - InTemplateHeadOrNoSubstitutionTemplate = 4, - InTemplateMiddleOrTail = 5, - InTemplateSubstitutionPosition = 6, - } - enum TokenClass { - Punctuation = 0, - Keyword = 1, - Operator = 2, - Comment = 3, - Whitespace = 4, - Identifier = 5, - NumberLiteral = 6, - StringLiteral = 7, - RegExpLiteral = 8, - } - interface ClassificationResult { - finalLexState: EndOfLineState; - entries: ClassificationInfo[]; - } - interface ClassificationInfo { - length: number; - classification: TokenClass; - } - interface Classifier { - /** - * Gives lexical classifications of tokens on a line without any syntactic context. - * For instance, a token consisting of the text 'string' can be either an identifier - * named 'string' or the keyword 'string', however, because this classifier is not aware, - * it relies on certain heuristics to give acceptable results. For classifications where - * speed trumps accuracy, this function is preferable; however, for true accuracy, the - * syntactic classifier is ideal. In fact, in certain editing scenarios, combining the - * lexical, syntactic, and semantic classifiers may issue the best user experience. - * - * @param text The text of a line to classify. - * @param lexState The state of the lexical classifier at the end of the previous line. - * @param syntacticClassifierAbsent Whether the client is *not* using a syntactic classifier. - * If there is no syntactic classifier (syntacticClassifierAbsent=true), - * certain heuristics may be used in its place; however, if there is a - * syntactic classifier (syntacticClassifierAbsent=false), certain - * classifications which may be incorrectly categorized will be given - * back as Identifiers in order to allow the syntactic classifier to - * subsume the classification. - * @deprecated Use getLexicalClassifications instead. - */ - getClassificationsForLine(text: string, lexState: EndOfLineState, syntacticClassifierAbsent: boolean): ClassificationResult; - getEncodedLexicalClassifications(text: string, endOfLineState: EndOfLineState, syntacticClassifierAbsent: boolean): Classifications; - } - /** - * The document registry represents a store of SourceFile objects that can be shared between - * multiple LanguageService instances. A LanguageService instance holds on the SourceFile (AST) - * of files in the context. - * SourceFile objects account for most of the memory usage by the language service. Sharing - * the same DocumentRegistry instance between different instances of LanguageService allow - * for more efficient memory utilization since all projects will share at least the library - * file (lib.d.ts). - * - * A more advanced use of the document registry is to serialize sourceFile objects to disk - * and re-hydrate them when needed. - * - * To create a default DocumentRegistry, use createDocumentRegistry to create one, and pass it - * to all subsequent createLanguageService calls. - */ - interface DocumentRegistry { - /** - * Request a stored SourceFile with a given fileName and compilationSettings. - * The first call to acquire will call createLanguageServiceSourceFile to generate - * the SourceFile if was not found in the registry. - * - * @param fileName The name of the file requested - * @param compilationSettings Some compilation settings like target affects the - * shape of a the resulting SourceFile. This allows the DocumentRegistry to store - * multiple copies of the same file for different compilation settings. - * @parm scriptSnapshot Text of the file. Only used if the file was not found - * in the registry and a new one was created. - * @parm version Current version of the file. Only used if the file was not found - * in the registry and a new one was created. - */ - acquireDocument(fileName: string, compilationSettings: CompilerOptions, scriptSnapshot: IScriptSnapshot, version: string): SourceFile; - /** - * Request an updated version of an already existing SourceFile with a given fileName - * and compilationSettings. The update will in-turn call updateLanguageServiceSourceFile - * to get an updated SourceFile. - * - * @param fileName The name of the file requested - * @param compilationSettings Some compilation settings like target affects the - * shape of a the resulting SourceFile. This allows the DocumentRegistry to store - * multiple copies of the same file for different compilation settings. - * @param scriptSnapshot Text of the file. - * @param version Current version of the file. - */ - updateDocument(fileName: string, compilationSettings: CompilerOptions, scriptSnapshot: IScriptSnapshot, version: string): SourceFile; - /** - * Informs the DocumentRegistry that a file is not needed any longer. - * - * Note: It is not allowed to call release on a SourceFile that was not acquired from - * this registry originally. - * - * @param fileName The name of the file to be released - * @param compilationSettings The compilation settings used to acquire the file - */ - releaseDocument(fileName: string, compilationSettings: CompilerOptions): void; - reportStats(): string; - } - module ScriptElementKind { - const unknown: string; - const warning: string; - const keyword: string; - const scriptElement: string; - const moduleElement: string; - const classElement: string; - const localClassElement: string; - const interfaceElement: string; - const typeElement: string; - const enumElement: string; - const variableElement: string; - const localVariableElement: string; - const functionElement: string; - const localFunctionElement: string; - const memberFunctionElement: string; - const memberGetAccessorElement: string; - const memberSetAccessorElement: string; - const memberVariableElement: string; - const constructorImplementationElement: string; - const callSignatureElement: string; - const indexSignatureElement: string; - const constructSignatureElement: string; - const parameterElement: string; - const typeParameterElement: string; - const primitiveType: string; - const label: string; - const alias: string; - const constElement: string; - const letElement: string; - } - module ScriptElementKindModifier { - const none: string; - const publicMemberModifier: string; - const privateMemberModifier: string; - const protectedMemberModifier: string; - const exportedModifier: string; - const ambientModifier: string; - const staticModifier: string; - const abstractModifier: string; - } - class ClassificationTypeNames { - static comment: string; - static identifier: string; - static keyword: string; - static numericLiteral: string; - static operator: string; - static stringLiteral: string; - static whiteSpace: string; - static text: string; - static punctuation: string; - static className: string; - static enumName: string; - static interfaceName: string; - static moduleName: string; - static typeParameterName: string; - static typeAliasName: string; - static parameterName: string; - static docCommentTagName: string; - } - const enum ClassificationType { - comment = 1, - identifier = 2, - keyword = 3, - numericLiteral = 4, - operator = 5, - stringLiteral = 6, - regularExpressionLiteral = 7, - whiteSpace = 8, - text = 9, - punctuation = 10, - className = 11, - enumName = 12, - interfaceName = 13, - moduleName = 14, - typeParameterName = 15, - typeAliasName = 16, - parameterName = 17, - docCommentTagName = 18, - } - interface DisplayPartsSymbolWriter extends SymbolWriter { - displayParts(): SymbolDisplayPart[]; - } - function displayPartsToString(displayParts: SymbolDisplayPart[]): string; - function getDefaultCompilerOptions(): CompilerOptions; - interface TranspileOptions { - compilerOptions?: CompilerOptions; - fileName?: string; - reportDiagnostics?: boolean; - moduleName?: string; - renamedDependencies?: Map; - } - interface TranspileOutput { - outputText: string; - diagnostics?: Diagnostic[]; - sourceMapText?: string; - } - function transpileModule(input: string, transpileOptions: TranspileOptions): TranspileOutput; - function transpile(input: string, compilerOptions?: CompilerOptions, fileName?: string, diagnostics?: Diagnostic[], moduleName?: string): string; - function createLanguageServiceSourceFile(fileName: string, scriptSnapshot: IScriptSnapshot, scriptTarget: ScriptTarget, version: string, setNodeParents: boolean): SourceFile; - let disableIncrementalParsing: boolean; - function updateLanguageServiceSourceFile(sourceFile: SourceFile, scriptSnapshot: IScriptSnapshot, version: string, textChangeRange: TextChangeRange, aggressiveChecks?: boolean): SourceFile; - function createGetCanonicalFileName(useCaseSensitivefileNames: boolean): (fileName: string) => string; - function createDocumentRegistry(useCaseSensitiveFileNames?: boolean): DocumentRegistry; - function preProcessFile(sourceText: string, readImportFiles?: boolean): PreProcessedFileInfo; - function createLanguageService(host: LanguageServiceHost, documentRegistry?: DocumentRegistry): LanguageService; - function createClassifier(): Classifier; - /** - * Get the path of the default library files (lib.d.ts) as distributed with the typescript - * node package. - * The functionality is not supported if the ts module is consumed outside of a node module. - */ - function getDefaultLibFilePath(options: CompilerOptions): string; -} +declare namespace ts { + interface Map { + [index: string]: T; + } + interface FileMap { + get(fileName: string): T; + set(fileName: string, value: T): void; + contains(fileName: string): boolean; + remove(fileName: string): void; + forEachValue(f: (v: T) => void): void; + clear(): void; + } + interface TextRange { + pos: number; + end: number; + } + const enum SyntaxKind { + Unknown = 0, + EndOfFileToken = 1, + SingleLineCommentTrivia = 2, + MultiLineCommentTrivia = 3, + NewLineTrivia = 4, + WhitespaceTrivia = 5, + ShebangTrivia = 6, + 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, + RequireKeyword = 127, + NumberKeyword = 128, + SetKeyword = 129, + StringKeyword = 130, + SymbolKeyword = 131, + TypeKeyword = 132, + FromKeyword = 133, + OfKeyword = 134, + QualifiedName = 135, + ComputedPropertyName = 136, + TypeParameter = 137, + Parameter = 138, + Decorator = 139, + PropertySignature = 140, + PropertyDeclaration = 141, + MethodSignature = 142, + MethodDeclaration = 143, + Constructor = 144, + GetAccessor = 145, + SetAccessor = 146, + CallSignature = 147, + ConstructSignature = 148, + IndexSignature = 149, + TypePredicate = 150, + TypeReference = 151, + FunctionType = 152, + ConstructorType = 153, + TypeQuery = 154, + TypeLiteral = 155, + ArrayType = 156, + TupleType = 157, + UnionType = 158, + IntersectionType = 159, + ParenthesizedType = 160, + ObjectBindingPattern = 161, + ArrayBindingPattern = 162, + BindingElement = 163, + ArrayLiteralExpression = 164, + ObjectLiteralExpression = 165, + PropertyAccessExpression = 166, + ElementAccessExpression = 167, + CallExpression = 168, + NewExpression = 169, + TaggedTemplateExpression = 170, + TypeAssertionExpression = 171, + ParenthesizedExpression = 172, + FunctionExpression = 173, + ArrowFunction = 174, + DeleteExpression = 175, + TypeOfExpression = 176, + VoidExpression = 177, + AwaitExpression = 178, + PrefixUnaryExpression = 179, + PostfixUnaryExpression = 180, + BinaryExpression = 181, + ConditionalExpression = 182, + TemplateExpression = 183, + YieldExpression = 184, + SpreadElementExpression = 185, + ClassExpression = 186, + OmittedExpression = 187, + ExpressionWithTypeArguments = 188, + AsExpression = 189, + TemplateSpan = 190, + SemicolonClassElement = 191, + Block = 192, + VariableStatement = 193, + EmptyStatement = 194, + ExpressionStatement = 195, + IfStatement = 196, + DoStatement = 197, + WhileStatement = 198, + ForStatement = 199, + ForInStatement = 200, + ForOfStatement = 201, + ContinueStatement = 202, + BreakStatement = 203, + ReturnStatement = 204, + WithStatement = 205, + SwitchStatement = 206, + LabeledStatement = 207, + ThrowStatement = 208, + TryStatement = 209, + DebuggerStatement = 210, + VariableDeclaration = 211, + VariableDeclarationList = 212, + FunctionDeclaration = 213, + ClassDeclaration = 214, + InterfaceDeclaration = 215, + TypeAliasDeclaration = 216, + EnumDeclaration = 217, + ModuleDeclaration = 218, + ModuleBlock = 219, + CaseBlock = 220, + ImportEqualsDeclaration = 221, + ImportDeclaration = 222, + ImportClause = 223, + NamespaceImport = 224, + NamedImports = 225, + ImportSpecifier = 226, + ExportAssignment = 227, + ExportDeclaration = 228, + NamedExports = 229, + ExportSpecifier = 230, + MissingDeclaration = 231, + ExternalModuleReference = 232, + JsxElement = 233, + JsxSelfClosingElement = 234, + JsxOpeningElement = 235, + JsxText = 236, + JsxClosingElement = 237, + JsxAttribute = 238, + JsxSpreadAttribute = 239, + JsxExpression = 240, + CaseClause = 241, + DefaultClause = 242, + HeritageClause = 243, + CatchClause = 244, + PropertyAssignment = 245, + ShorthandPropertyAssignment = 246, + EnumMember = 247, + SourceFile = 248, + JSDocTypeExpression = 249, + JSDocAllType = 250, + JSDocUnknownType = 251, + JSDocArrayType = 252, + JSDocUnionType = 253, + JSDocTupleType = 254, + JSDocNullableType = 255, + JSDocNonNullableType = 256, + JSDocRecordType = 257, + JSDocRecordMember = 258, + JSDocTypeReference = 259, + JSDocOptionalType = 260, + JSDocFunctionType = 261, + JSDocVariadicType = 262, + JSDocConstructorType = 263, + JSDocThisType = 264, + JSDocComment = 265, + JSDocTag = 266, + JSDocParameterTag = 267, + JSDocReturnTag = 268, + JSDocTypeTag = 269, + JSDocTemplateTag = 270, + SyntaxList = 271, + Count = 272, + FirstAssignment = 56, + LastAssignment = 68, + FirstReservedWord = 70, + LastReservedWord = 105, + FirstKeyword = 70, + LastKeyword = 134, + FirstFutureReservedWord = 106, + LastFutureReservedWord = 114, + FirstTypeNode = 151, + LastTypeNode = 160, + FirstPunctuation = 15, + LastPunctuation = 68, + FirstToken = 0, + LastToken = 134, + FirstTriviaToken = 2, + LastTriviaToken = 7, + FirstLiteralToken = 8, + LastLiteralToken = 11, + FirstTemplateToken = 11, + LastTemplateToken = 14, + FirstBinaryOperator = 25, + LastBinaryOperator = 68, + FirstNode = 135, + } + const enum NodeFlags { + None = 0, + Export = 1, + Ambient = 2, + Public = 16, + Private = 32, + Protected = 64, + Static = 128, + Abstract = 256, + Async = 512, + Default = 1024, + MultiLine = 2048, + Synthetic = 4096, + DeclarationFile = 8192, + Let = 16384, + Const = 32768, + OctalLiteral = 65536, + Namespace = 131072, + ExportContext = 262144, + ContainsThis = 524288, + Modifier = 2035, + AccessibilityModifier = 112, + BlockScoped = 49152, + } + const enum JsxFlags { + None = 0, + IntrinsicNamedElement = 1, + IntrinsicIndexedElement = 2, + ClassElement = 4, + UnknownElement = 8, + IntrinsicElement = 3, + } + interface Node extends TextRange { + kind: SyntaxKind; + flags: NodeFlags; + decorators?: NodeArray; + modifiers?: ModifiersArray; + parent?: Node; + } + interface NodeArray extends Array, TextRange { + hasTrailingComma?: boolean; + } + interface ModifiersArray extends NodeArray { + flags: number; + } + interface Identifier extends PrimaryExpression { + text: string; + originalKeywordKind?: SyntaxKind; + } + interface QualifiedName extends Node { + left: EntityName; + right: Identifier; + } + type EntityName = Identifier | QualifiedName; + type DeclarationName = Identifier | LiteralExpression | ComputedPropertyName | BindingPattern; + interface Declaration extends Node { + _declarationBrand: any; + name?: DeclarationName; + } + interface ComputedPropertyName extends Node { + expression: Expression; + } + interface Decorator extends Node { + expression: LeftHandSideExpression; + } + interface TypeParameterDeclaration extends Declaration { + name: Identifier; + constraint?: TypeNode; + expression?: Expression; + } + interface SignatureDeclaration extends Declaration { + typeParameters?: NodeArray; + parameters: NodeArray; + type?: TypeNode; + } + interface VariableDeclaration extends Declaration { + parent?: VariableDeclarationList; + name: Identifier | BindingPattern; + type?: TypeNode; + initializer?: Expression; + } + interface VariableDeclarationList extends Node { + declarations: NodeArray; + } + interface ParameterDeclaration extends Declaration { + dotDotDotToken?: Node; + name: Identifier | BindingPattern; + questionToken?: Node; + type?: TypeNode; + initializer?: Expression; + } + interface BindingElement extends Declaration { + propertyName?: Identifier; + dotDotDotToken?: Node; + name: Identifier | BindingPattern; + initializer?: Expression; + } + interface PropertyDeclaration extends Declaration, ClassElement { + name: DeclarationName; + questionToken?: Node; + type?: TypeNode; + initializer?: Expression; + } + interface ObjectLiteralElement extends Declaration { + _objectLiteralBrandBrand: any; + } + interface PropertyAssignment extends ObjectLiteralElement { + _propertyAssignmentBrand: any; + name: DeclarationName; + questionToken?: Node; + initializer: Expression; + } + interface ShorthandPropertyAssignment extends ObjectLiteralElement { + name: Identifier; + questionToken?: Node; + equalsToken?: Node; + objectAssignmentInitializer?: Expression; + } + interface VariableLikeDeclaration extends Declaration { + propertyName?: Identifier; + dotDotDotToken?: Node; + name: DeclarationName; + questionToken?: Node; + type?: TypeNode; + initializer?: Expression; + } + interface BindingPattern extends Node { + elements: NodeArray; + } + /** + * Several node kinds share function-like features such as a signature, + * a name, and a body. These nodes should extend FunctionLikeDeclaration. + * Examples: + * - FunctionDeclaration + * - MethodDeclaration + * - AccessorDeclaration + */ + interface FunctionLikeDeclaration extends SignatureDeclaration { + _functionLikeDeclarationBrand: any; + asteriskToken?: Node; + questionToken?: Node; + body?: Block | Expression; + } + interface FunctionDeclaration extends FunctionLikeDeclaration, Statement { + name?: Identifier; + body?: Block; + } + interface MethodDeclaration extends FunctionLikeDeclaration, ClassElement, ObjectLiteralElement { + body?: Block; + } + interface ConstructorDeclaration extends FunctionLikeDeclaration, ClassElement { + body?: Block; + } + interface SemicolonClassElement extends ClassElement { + _semicolonClassElementBrand: any; + } + interface AccessorDeclaration extends FunctionLikeDeclaration, ClassElement, ObjectLiteralElement { + _accessorDeclarationBrand: any; + body: Block; + } + interface IndexSignatureDeclaration extends SignatureDeclaration, ClassElement { + _indexSignatureDeclarationBrand: any; + } + interface TypeNode extends Node { + _typeNodeBrand: any; + } + interface FunctionOrConstructorTypeNode extends TypeNode, SignatureDeclaration { + _functionOrConstructorTypeNodeBrand: any; + } + interface TypeReferenceNode extends TypeNode { + typeName: EntityName; + typeArguments?: NodeArray; + } + interface TypePredicateNode extends TypeNode { + parameterName: Identifier; + type: TypeNode; + } + interface TypeQueryNode extends TypeNode { + exprName: EntityName; + } + interface TypeLiteralNode extends TypeNode, Declaration { + members: NodeArray; + } + interface ArrayTypeNode extends TypeNode { + elementType: TypeNode; + } + interface TupleTypeNode extends TypeNode { + elementTypes: NodeArray; + } + interface UnionOrIntersectionTypeNode extends TypeNode { + types: NodeArray; + } + interface UnionTypeNode extends UnionOrIntersectionTypeNode { + } + interface IntersectionTypeNode extends UnionOrIntersectionTypeNode { + } + interface ParenthesizedTypeNode extends TypeNode { + type: TypeNode; + } + interface StringLiteral extends LiteralExpression, TypeNode { + _stringLiteralBrand: any; + } + interface Expression extends Node { + _expressionBrand: any; + contextualType?: Type; + } + interface UnaryExpression extends Expression { + _unaryExpressionBrand: any; + } + interface IncrementExpression extends UnaryExpression { + _incrementExpressionBrand: any; + } + interface PrefixUnaryExpression extends IncrementExpression { + operator: SyntaxKind; + operand: UnaryExpression; + } + interface PostfixUnaryExpression extends IncrementExpression { + operand: LeftHandSideExpression; + operator: SyntaxKind; + } + interface PostfixExpression extends UnaryExpression { + _postfixExpressionBrand: any; + } + interface LeftHandSideExpression extends IncrementExpression { + _leftHandSideExpressionBrand: any; + } + interface MemberExpression extends LeftHandSideExpression { + _memberExpressionBrand: any; + } + interface PrimaryExpression extends MemberExpression { + _primaryExpressionBrand: any; + } + interface DeleteExpression extends UnaryExpression { + expression: UnaryExpression; + } + interface TypeOfExpression extends UnaryExpression { + expression: UnaryExpression; + } + interface VoidExpression extends UnaryExpression { + expression: UnaryExpression; + } + interface AwaitExpression extends UnaryExpression { + expression: UnaryExpression; + } + interface YieldExpression extends Expression { + asteriskToken?: Node; + expression?: Expression; + } + interface BinaryExpression extends Expression { + left: Expression; + operatorToken: Node; + right: Expression; + } + interface ConditionalExpression extends Expression { + condition: Expression; + questionToken: Node; + whenTrue: Expression; + colonToken: Node; + whenFalse: Expression; + } + interface FunctionExpression extends PrimaryExpression, FunctionLikeDeclaration { + name?: Identifier; + body: Block | Expression; + } + interface ArrowFunction extends Expression, FunctionLikeDeclaration { + equalsGreaterThanToken: Node; + } + interface LiteralExpression extends PrimaryExpression { + text: string; + isUnterminated?: boolean; + hasExtendedUnicodeEscape?: boolean; + } + interface TemplateExpression extends PrimaryExpression { + head: LiteralExpression; + templateSpans: NodeArray; + } + interface TemplateSpan extends Node { + expression: Expression; + literal: LiteralExpression; + } + interface ParenthesizedExpression extends PrimaryExpression { + expression: Expression; + } + interface ArrayLiteralExpression extends PrimaryExpression { + elements: NodeArray; + } + interface SpreadElementExpression extends Expression { + expression: Expression; + } + interface ObjectLiteralExpression extends PrimaryExpression, Declaration { + properties: NodeArray; + } + interface PropertyAccessExpression extends MemberExpression { + expression: LeftHandSideExpression; + dotToken: Node; + name: Identifier; + } + interface ElementAccessExpression extends MemberExpression { + expression: LeftHandSideExpression; + argumentExpression?: Expression; + } + interface CallExpression extends LeftHandSideExpression { + expression: LeftHandSideExpression; + typeArguments?: NodeArray; + arguments: NodeArray; + } + interface ExpressionWithTypeArguments extends TypeNode { + expression: LeftHandSideExpression; + typeArguments?: NodeArray; + } + interface NewExpression extends CallExpression, PrimaryExpression { + } + interface TaggedTemplateExpression extends MemberExpression { + tag: LeftHandSideExpression; + template: LiteralExpression | TemplateExpression; + } + type CallLikeExpression = CallExpression | NewExpression | TaggedTemplateExpression | Decorator; + interface AsExpression extends Expression { + expression: Expression; + type: TypeNode; + } + interface TypeAssertion extends UnaryExpression { + type: TypeNode; + expression: UnaryExpression; + } + type AssertionExpression = TypeAssertion | AsExpression; + interface JsxElement extends PrimaryExpression { + openingElement: JsxOpeningElement; + children: NodeArray; + closingElement: JsxClosingElement; + } + interface JsxOpeningElement extends Expression { + _openingElementBrand?: any; + tagName: EntityName; + attributes: NodeArray; + } + interface JsxSelfClosingElement extends PrimaryExpression, JsxOpeningElement { + _selfClosingElementBrand?: any; + } + type JsxOpeningLikeElement = JsxSelfClosingElement | JsxOpeningElement; + interface JsxAttribute extends Node { + name: Identifier; + initializer?: Expression; + } + interface JsxSpreadAttribute extends Node { + expression: Expression; + } + interface JsxClosingElement extends Node { + tagName: EntityName; + } + interface JsxExpression extends Expression { + expression?: Expression; + } + interface JsxText extends Node { + _jsxTextExpressionBrand: any; + } + type JsxChild = JsxText | JsxExpression | JsxElement | JsxSelfClosingElement; + interface Statement extends Node { + _statementBrand: any; + } + interface Block extends Statement { + statements: NodeArray; + } + interface VariableStatement extends Statement { + declarationList: VariableDeclarationList; + } + interface ExpressionStatement extends Statement { + expression: Expression; + } + interface IfStatement extends Statement { + expression: Expression; + thenStatement: Statement; + elseStatement?: Statement; + } + interface IterationStatement extends Statement { + statement: Statement; + } + interface DoStatement extends IterationStatement { + expression: Expression; + } + interface WhileStatement extends IterationStatement { + expression: Expression; + } + interface ForStatement extends IterationStatement { + initializer?: VariableDeclarationList | Expression; + condition?: Expression; + incrementor?: Expression; + } + interface ForInStatement extends IterationStatement { + initializer: VariableDeclarationList | Expression; + expression: Expression; + } + interface ForOfStatement extends IterationStatement { + initializer: VariableDeclarationList | Expression; + expression: Expression; + } + interface BreakOrContinueStatement extends Statement { + label?: Identifier; + } + interface ReturnStatement extends Statement { + expression?: Expression; + } + interface WithStatement extends Statement { + expression: Expression; + statement: Statement; + } + interface SwitchStatement extends Statement { + expression: Expression; + caseBlock: CaseBlock; + } + interface CaseBlock extends Node { + clauses: NodeArray; + } + interface CaseClause extends Node { + expression?: Expression; + statements: NodeArray; + } + interface DefaultClause extends Node { + statements: NodeArray; + } + type CaseOrDefaultClause = CaseClause | DefaultClause; + interface LabeledStatement extends Statement { + label: Identifier; + statement: Statement; + } + interface ThrowStatement extends Statement { + expression: Expression; + } + interface TryStatement extends Statement { + tryBlock: Block; + catchClause?: CatchClause; + finallyBlock?: Block; + } + interface CatchClause extends Node { + variableDeclaration: VariableDeclaration; + block: Block; + } + interface ClassLikeDeclaration extends Declaration { + name?: Identifier; + typeParameters?: NodeArray; + heritageClauses?: NodeArray; + members: NodeArray; + } + interface ClassDeclaration extends ClassLikeDeclaration, Statement { + } + interface ClassExpression extends ClassLikeDeclaration, PrimaryExpression { + } + interface ClassElement extends Declaration { + _classElementBrand: any; + } + interface InterfaceDeclaration extends Declaration, Statement { + name: Identifier; + typeParameters?: NodeArray; + heritageClauses?: NodeArray; + members: NodeArray; + } + interface HeritageClause extends Node { + token: SyntaxKind; + types?: NodeArray; + } + interface TypeAliasDeclaration extends Declaration, Statement { + name: Identifier; + typeParameters?: NodeArray; + type: TypeNode; + } + interface EnumMember extends Declaration { + name: DeclarationName; + initializer?: Expression; + } + interface EnumDeclaration extends Declaration, Statement { + name: Identifier; + members: NodeArray; + } + interface ModuleDeclaration extends Declaration, Statement { + name: Identifier | LiteralExpression; + body: ModuleBlock | ModuleDeclaration; + } + interface ModuleBlock extends Node, Statement { + statements: NodeArray; + } + interface ImportEqualsDeclaration extends Declaration, Statement { + name: Identifier; + moduleReference: EntityName | ExternalModuleReference; + } + interface ExternalModuleReference extends Node { + expression?: Expression; + } + interface ImportDeclaration extends Statement { + importClause?: ImportClause; + moduleSpecifier: Expression; + } + interface ImportClause extends Declaration { + name?: Identifier; + namedBindings?: NamespaceImport | NamedImports; + } + interface NamespaceImport extends Declaration { + name: Identifier; + } + interface ExportDeclaration extends Declaration, Statement { + exportClause?: NamedExports; + moduleSpecifier?: Expression; + } + interface NamedImportsOrExports extends Node { + elements: NodeArray; + } + type NamedImports = NamedImportsOrExports; + type NamedExports = NamedImportsOrExports; + interface ImportOrExportSpecifier extends Declaration { + propertyName?: Identifier; + name: Identifier; + } + type ImportSpecifier = ImportOrExportSpecifier; + type ExportSpecifier = ImportOrExportSpecifier; + interface ExportAssignment extends Declaration, Statement { + isExportEquals?: boolean; + expression: Expression; + } + interface FileReference extends TextRange { + fileName: string; + } + interface CommentRange extends TextRange { + hasTrailingNewLine?: boolean; + kind: SyntaxKind; + } + interface JSDocTypeExpression extends Node { + type: JSDocType; + } + interface JSDocType extends TypeNode { + _jsDocTypeBrand: any; + } + interface JSDocAllType extends JSDocType { + _JSDocAllTypeBrand: any; + } + interface JSDocUnknownType extends JSDocType { + _JSDocUnknownTypeBrand: any; + } + interface JSDocArrayType extends JSDocType { + elementType: JSDocType; + } + interface JSDocUnionType extends JSDocType { + types: NodeArray; + } + interface JSDocTupleType extends JSDocType { + types: NodeArray; + } + interface JSDocNonNullableType extends JSDocType { + type: JSDocType; + } + interface JSDocNullableType extends JSDocType { + type: JSDocType; + } + interface JSDocRecordType extends JSDocType, TypeLiteralNode { + members: NodeArray; + } + interface JSDocTypeReference extends JSDocType { + name: EntityName; + typeArguments: NodeArray; + } + interface JSDocOptionalType extends JSDocType { + type: JSDocType; + } + interface JSDocFunctionType extends JSDocType, SignatureDeclaration { + parameters: NodeArray; + type: JSDocType; + } + interface JSDocVariadicType extends JSDocType { + type: JSDocType; + } + interface JSDocConstructorType extends JSDocType { + type: JSDocType; + } + interface JSDocThisType extends JSDocType { + type: JSDocType; + } + interface JSDocRecordMember extends PropertyDeclaration { + name: Identifier | LiteralExpression; + type?: JSDocType; + } + interface JSDocComment extends Node { + tags: NodeArray; + } + interface JSDocTag extends Node { + atToken: Node; + tagName: Identifier; + } + interface JSDocTemplateTag extends JSDocTag { + typeParameters: NodeArray; + } + interface JSDocReturnTag extends JSDocTag { + typeExpression: JSDocTypeExpression; + } + interface JSDocTypeTag extends JSDocTag { + typeExpression: JSDocTypeExpression; + } + interface JSDocParameterTag extends JSDocTag { + preParameterName?: Identifier; + typeExpression?: JSDocTypeExpression; + postParameterName?: Identifier; + isBracketed: boolean; + } + interface SourceFile extends Declaration { + statements: NodeArray; + endOfFileToken: Node; + fileName: string; + text: string; + amdDependencies: { + path: string; + name: string; + }[]; + moduleName: string; + referencedFiles: FileReference[]; + languageVariant: LanguageVariant; + /** + * lib.d.ts should have a reference comment like + * + * /// + * + * If any other file has this comment, it signals not to include lib.d.ts + * because this containing file is intended to act as a default library. + */ + hasNoDefaultLib: boolean; + languageVersion: ScriptTarget; + } + interface ScriptReferenceHost { + getCompilerOptions(): CompilerOptions; + getSourceFile(fileName: string): SourceFile; + getCurrentDirectory(): string; + } + interface ParseConfigHost { + readDirectory(rootDir: string, extension: string, exclude: string[]): string[]; + } + interface WriteFileCallback { + (fileName: string, data: string, writeByteOrderMark: boolean, onError?: (message: string) => void): void; + } + class OperationCanceledException { + } + interface CancellationToken { + isCancellationRequested(): boolean; + /** @throws OperationCanceledException if isCancellationRequested is true */ + throwIfCancellationRequested(): void; + } + interface Program extends ScriptReferenceHost { + /** + * Get a list of root file names that were passed to a 'createProgram' + */ + getRootFileNames(): string[]; + /** + * Get a list of files in the program + */ + getSourceFiles(): SourceFile[]; + /** + * Emits the JavaScript and declaration files. If targetSourceFile is not specified, then + * the JavaScript and declaration files will be produced for all the files in this program. + * If targetSourceFile is specified, then only the JavaScript and declaration for that + * specific file will be generated. + * + * If writeFile is not specified then the writeFile callback from the compiler host will be + * used for writing the JavaScript and declaration files. Otherwise, the writeFile parameter + * will be invoked when writing the JavaScript and declaration files. + */ + emit(targetSourceFile?: SourceFile, writeFile?: WriteFileCallback, cancellationToken?: CancellationToken): EmitResult; + getOptionsDiagnostics(cancellationToken?: CancellationToken): Diagnostic[]; + getGlobalDiagnostics(cancellationToken?: CancellationToken): Diagnostic[]; + getSyntacticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): Diagnostic[]; + getSemanticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): Diagnostic[]; + getDeclarationDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): Diagnostic[]; + /** + * Gets a type checker that can be used to semantically analyze source fils in the program. + */ + getTypeChecker(): TypeChecker; + } + interface SourceMapSpan { + /** Line number in the .js file. */ + emittedLine: number; + /** Column number in the .js file. */ + emittedColumn: number; + /** Line number in the .ts file. */ + sourceLine: number; + /** Column number in the .ts file. */ + sourceColumn: number; + /** Optional name (index into names array) associated with this span. */ + nameIndex?: number; + /** .ts file (index into sources array) associated with this span */ + sourceIndex: number; + } + interface SourceMapData { + sourceMapFilePath: string; + jsSourceMappingURL: string; + sourceMapFile: string; + sourceMapSourceRoot: string; + sourceMapSources: string[]; + sourceMapSourcesContent?: string[]; + inputSourceFileNames: string[]; + sourceMapNames?: string[]; + sourceMapMappings: string; + sourceMapDecodedMappings: SourceMapSpan[]; + } + /** Return code used by getEmitOutput function to indicate status of the function */ + enum ExitStatus { + Success = 0, + DiagnosticsPresent_OutputsSkipped = 1, + DiagnosticsPresent_OutputsGenerated = 2, + } + interface EmitResult { + emitSkipped: boolean; + diagnostics: Diagnostic[]; + } + interface TypeChecker { + getTypeOfSymbolAtLocation(symbol: Symbol, node: Node): Type; + getDeclaredTypeOfSymbol(symbol: Symbol): Type; + getPropertiesOfType(type: Type): Symbol[]; + getPropertyOfType(type: Type, propertyName: string): Symbol; + getSignaturesOfType(type: Type, kind: SignatureKind): Signature[]; + getIndexTypeOfType(type: Type, kind: IndexKind): Type; + getBaseTypes(type: InterfaceType): ObjectType[]; + getReturnTypeOfSignature(signature: Signature): Type; + getSymbolsInScope(location: Node, meaning: SymbolFlags): Symbol[]; + getSymbolAtLocation(node: Node): Symbol; + getShorthandAssignmentValueSymbol(location: Node): Symbol; + getTypeAtLocation(node: Node): Type; + typeToString(type: Type, enclosingDeclaration?: Node, flags?: TypeFormatFlags): string; + symbolToString(symbol: Symbol, enclosingDeclaration?: Node, meaning?: SymbolFlags): string; + getSymbolDisplayBuilder(): SymbolDisplayBuilder; + getFullyQualifiedName(symbol: Symbol): string; + getAugmentedPropertiesOfType(type: Type): Symbol[]; + getRootSymbols(symbol: Symbol): Symbol[]; + getContextualType(node: Expression): Type; + getResolvedSignature(node: CallLikeExpression, candidatesOutArray?: Signature[]): Signature; + getSignatureFromDeclaration(declaration: SignatureDeclaration): Signature; + isImplementationOfOverload(node: FunctionLikeDeclaration): boolean; + isUndefinedSymbol(symbol: Symbol): boolean; + isArgumentsSymbol(symbol: Symbol): boolean; + getConstantValue(node: EnumMember | PropertyAccessExpression | ElementAccessExpression): number; + isValidPropertyAccess(node: PropertyAccessExpression | QualifiedName, propertyName: string): boolean; + getAliasedSymbol(symbol: Symbol): Symbol; + getExportsOfModule(moduleSymbol: Symbol): Symbol[]; + getJsxElementAttributesType(elementNode: JsxOpeningLikeElement): Type; + getJsxIntrinsicTagNames(): Symbol[]; + isOptionalParameter(node: ParameterDeclaration): boolean; + } + interface SymbolDisplayBuilder { + buildTypeDisplay(type: Type, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; + buildSymbolDisplay(symbol: Symbol, writer: SymbolWriter, enclosingDeclaration?: Node, meaning?: SymbolFlags, flags?: SymbolFormatFlags): void; + buildSignatureDisplay(signatures: Signature, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; + buildParameterDisplay(parameter: Symbol, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; + buildTypeParameterDisplay(tp: TypeParameter, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; + buildTypeParameterDisplayFromSymbol(symbol: Symbol, writer: SymbolWriter, enclosingDeclaraiton?: Node, flags?: TypeFormatFlags): void; + buildDisplayForParametersAndDelimiters(parameters: Symbol[], writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; + buildDisplayForTypeParametersAndDelimiters(typeParameters: TypeParameter[], writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; + buildReturnTypeDisplay(signature: Signature, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; + } + interface SymbolWriter { + writeKeyword(text: string): void; + writeOperator(text: string): void; + writePunctuation(text: string): void; + writeSpace(text: string): void; + writeStringLiteral(text: string): void; + writeParameter(text: string): void; + writeSymbol(text: string, symbol: Symbol): void; + writeLine(): void; + increaseIndent(): void; + decreaseIndent(): void; + clear(): void; + trackSymbol(symbol: Symbol, enclosingDeclaration?: Node, meaning?: SymbolFlags): void; + reportInaccessibleThisError(): void; + } + const enum TypeFormatFlags { + None = 0, + WriteArrayAsGenericType = 1, + UseTypeOfFunction = 2, + NoTruncation = 4, + WriteArrowStyleSignature = 8, + WriteOwnNameForAnyLike = 16, + WriteTypeArgumentsOfSignature = 32, + InElementType = 64, + UseFullyQualifiedType = 128, + } + const enum SymbolFormatFlags { + None = 0, + WriteTypeParametersOrArguments = 1, + UseOnlyExternalAliasing = 2, + } + interface TypePredicate { + parameterName: string; + parameterIndex: number; + type: Type; + } + const enum SymbolFlags { + None = 0, + FunctionScopedVariable = 1, + BlockScopedVariable = 2, + Property = 4, + EnumMember = 8, + Function = 16, + Class = 32, + Interface = 64, + ConstEnum = 128, + RegularEnum = 256, + ValueModule = 512, + NamespaceModule = 1024, + TypeLiteral = 2048, + ObjectLiteral = 4096, + Method = 8192, + Constructor = 16384, + GetAccessor = 32768, + SetAccessor = 65536, + Signature = 131072, + TypeParameter = 262144, + TypeAlias = 524288, + ExportValue = 1048576, + ExportType = 2097152, + ExportNamespace = 4194304, + Alias = 8388608, + Instantiated = 16777216, + Merged = 33554432, + Transient = 67108864, + Prototype = 134217728, + SyntheticProperty = 268435456, + Optional = 536870912, + ExportStar = 1073741824, + Enum = 384, + Variable = 3, + Value = 107455, + Type = 793056, + Namespace = 1536, + Module = 1536, + Accessor = 98304, + FunctionScopedVariableExcludes = 107454, + BlockScopedVariableExcludes = 107455, + ParameterExcludes = 107455, + PropertyExcludes = 107455, + EnumMemberExcludes = 107455, + FunctionExcludes = 106927, + ClassExcludes = 899519, + InterfaceExcludes = 792960, + RegularEnumExcludes = 899327, + ConstEnumExcludes = 899967, + ValueModuleExcludes = 106639, + NamespaceModuleExcludes = 0, + MethodExcludes = 99263, + GetAccessorExcludes = 41919, + SetAccessorExcludes = 74687, + TypeParameterExcludes = 530912, + TypeAliasExcludes = 793056, + AliasExcludes = 8388608, + ModuleMember = 8914931, + ExportHasLocal = 944, + HasExports = 1952, + HasMembers = 6240, + BlockScoped = 418, + PropertyOrAccessor = 98308, + Export = 7340032, + } + interface Symbol { + flags: SymbolFlags; + name: string; + declarations?: Declaration[]; + valueDeclaration?: Declaration; + members?: SymbolTable; + exports?: SymbolTable; + } + interface SymbolTable { + [index: string]: Symbol; + } + const enum TypeFlags { + Any = 1, + String = 2, + Number = 4, + Boolean = 8, + Void = 16, + Undefined = 32, + Null = 64, + Enum = 128, + StringLiteral = 256, + TypeParameter = 512, + Class = 1024, + Interface = 2048, + Reference = 4096, + Tuple = 8192, + Union = 16384, + Intersection = 32768, + Anonymous = 65536, + Instantiated = 131072, + ObjectLiteral = 524288, + ESSymbol = 16777216, + ThisType = 33554432, + StringLike = 258, + NumberLike = 132, + ObjectType = 80896, + UnionOrIntersection = 49152, + StructuredType = 130048, + } + type DestructuringPattern = BindingPattern | ObjectLiteralExpression | ArrayLiteralExpression; + interface Type { + flags: TypeFlags; + symbol?: Symbol; + pattern?: DestructuringPattern; + } + interface StringLiteralType extends Type { + text: string; + } + interface ObjectType extends Type { + } + interface InterfaceType extends ObjectType { + typeParameters: TypeParameter[]; + outerTypeParameters: TypeParameter[]; + localTypeParameters: TypeParameter[]; + thisType: TypeParameter; + } + interface InterfaceTypeWithDeclaredMembers extends InterfaceType { + declaredProperties: Symbol[]; + declaredCallSignatures: Signature[]; + declaredConstructSignatures: Signature[]; + declaredStringIndexType: Type; + declaredNumberIndexType: Type; + } + interface TypeReference extends ObjectType { + target: GenericType; + typeArguments: Type[]; + } + interface GenericType extends InterfaceType, TypeReference { + } + interface TupleType extends ObjectType { + elementTypes: Type[]; + } + interface UnionOrIntersectionType extends Type { + types: Type[]; + } + interface UnionType extends UnionOrIntersectionType { + } + interface IntersectionType extends UnionOrIntersectionType { + } + interface TypeParameter extends Type { + constraint: Type; + } + const enum SignatureKind { + Call = 0, + Construct = 1, + } + interface Signature { + declaration: SignatureDeclaration; + typeParameters: TypeParameter[]; + parameters: Symbol[]; + typePredicate?: TypePredicate; + } + const enum IndexKind { + String = 0, + Number = 1, + } + interface DiagnosticMessage { + key: string; + category: DiagnosticCategory; + code: number; + message: string; + } + /** + * A linked list of formatted diagnostic messages to be used as part of a multiline message. + * It is built from the bottom up, leaving the head to be the "main" diagnostic. + * While it seems that DiagnosticMessageChain is structurally similar to DiagnosticMessage, + * the difference is that messages are all preformatted in DMC. + */ + interface DiagnosticMessageChain { + messageText: string; + category: DiagnosticCategory; + code: number; + next?: DiagnosticMessageChain; + } + interface Diagnostic { + file: SourceFile; + start: number; + length: number; + messageText: string | DiagnosticMessageChain; + category: DiagnosticCategory; + code: number; + } + enum DiagnosticCategory { + Warning = 0, + Error = 1, + Message = 2, + } + const enum ModuleResolutionKind { + Classic = 1, + NodeJs = 2, + } + interface CompilerOptions { + allowNonTsExtensions?: boolean; + charset?: string; + declaration?: boolean; + diagnostics?: boolean; + emitBOM?: boolean; + help?: boolean; + init?: boolean; + inlineSourceMap?: boolean; + inlineSources?: boolean; + jsx?: JsxEmit; + listFiles?: boolean; + locale?: string; + mapRoot?: string; + module?: ModuleKind; + newLine?: NewLineKind; + noEmit?: boolean; + noEmitHelpers?: boolean; + noEmitOnError?: boolean; + noErrorTruncation?: boolean; + noImplicitAny?: boolean; + noLib?: boolean; + noResolve?: boolean; + out?: string; + outFile?: string; + outDir?: string; + preserveConstEnums?: boolean; + project?: string; + removeComments?: boolean; + rootDir?: string; + sourceMap?: boolean; + sourceRoot?: string; + suppressExcessPropertyErrors?: boolean; + suppressImplicitAnyIndexErrors?: boolean; + target?: ScriptTarget; + version?: boolean; + watch?: boolean; + isolatedModules?: boolean; + experimentalDecorators?: boolean; + emitDecoratorMetadata?: boolean; + moduleResolution?: ModuleResolutionKind; + forceConsistentCasingInFileNames?: boolean; + [option: string]: string | number | boolean; + } + const enum ModuleKind { + None = 0, + CommonJS = 1, + AMD = 2, + UMD = 3, + System = 4, + ES6 = 5, + ES2015 = 5, + } + const enum JsxEmit { + None = 0, + Preserve = 1, + React = 2, + } + const enum NewLineKind { + CarriageReturnLineFeed = 0, + LineFeed = 1, + } + interface LineAndCharacter { + line: number; + character: number; + } + const enum ScriptTarget { + ES3 = 0, + ES5 = 1, + ES6 = 2, + ES2015 = 2, + Latest = 2, + } + const enum LanguageVariant { + Standard = 0, + JSX = 1, + } + interface ParsedCommandLine { + options: CompilerOptions; + fileNames: string[]; + errors: Diagnostic[]; + } + interface ModuleResolutionHost { + fileExists(fileName: string): boolean; + readFile(fileName: string): string; + } + interface ResolvedModule { + resolvedFileName: string; + isExternalLibraryImport?: boolean; + } + interface ResolvedModuleWithFailedLookupLocations { + resolvedModule: ResolvedModule; + failedLookupLocations: string[]; + } + interface CompilerHost extends ModuleResolutionHost { + getSourceFile(fileName: string, languageVersion: ScriptTarget, onError?: (message: string) => void): SourceFile; + getCancellationToken?(): CancellationToken; + getDefaultLibFileName(options: CompilerOptions): string; + writeFile: WriteFileCallback; + getCurrentDirectory(): string; + getCanonicalFileName(fileName: string): string; + useCaseSensitiveFileNames(): boolean; + getNewLine(): string; + resolveModuleNames?(moduleNames: string[], containingFile: string): ResolvedModule[]; + } + interface TextSpan { + start: number; + length: number; + } + interface TextChangeRange { + span: TextSpan; + newLength: number; + } +} +declare namespace ts { + interface System { + args: string[]; + newLine: string; + useCaseSensitiveFileNames: boolean; + write(s: string): void; + readFile(path: string, encoding?: string): string; + writeFile(path: string, data: string, writeByteOrderMark?: boolean): void; + watchFile?(path: string, callback: (path: string, removed?: boolean) => void): FileWatcher; + watchDirectory?(path: string, callback: (path: string) => void, recursive?: boolean): FileWatcher; + resolvePath(path: string): string; + fileExists(path: string): boolean; + directoryExists(path: string): boolean; + createDirectory(path: string): void; + getExecutingFilePath(): string; + getCurrentDirectory(): string; + readDirectory(path: string, extension?: string, exclude?: string[]): string[]; + getMemoryUsage?(): number; + exit(exitCode?: number): void; + } + interface FileWatcher { + close(): void; + } + var sys: System; +} +declare namespace ts { + interface ErrorCallback { + (message: DiagnosticMessage, length: number): void; + } + interface Scanner { + getStartPos(): number; + getToken(): SyntaxKind; + getTextPos(): number; + getTokenPos(): number; + getTokenText(): string; + getTokenValue(): string; + hasExtendedUnicodeEscape(): boolean; + hasPrecedingLineBreak(): boolean; + isIdentifier(): boolean; + isReservedWord(): boolean; + isUnterminated(): boolean; + reScanGreaterToken(): SyntaxKind; + reScanSlashToken(): SyntaxKind; + reScanTemplateToken(): SyntaxKind; + scanJsxIdentifier(): SyntaxKind; + reScanJsxToken(): SyntaxKind; + scanJsxToken(): SyntaxKind; + scan(): SyntaxKind; + setText(text: string, start?: number, length?: number): void; + setOnError(onError: ErrorCallback): void; + setScriptTarget(scriptTarget: ScriptTarget): void; + setLanguageVariant(variant: LanguageVariant): void; + setTextPos(textPos: number): void; + lookAhead(callback: () => T): T; + tryScan(callback: () => T): T; + } + function tokenToString(t: SyntaxKind): string; + function getPositionOfLineAndCharacter(sourceFile: SourceFile, line: number, character: number): number; + function getLineAndCharacterOfPosition(sourceFile: SourceFile, position: number): LineAndCharacter; + function isWhiteSpace(ch: number): boolean; + function isLineBreak(ch: number): boolean; + function couldStartTrivia(text: string, pos: number): boolean; + function getLeadingCommentRanges(text: string, pos: number): CommentRange[]; + function getTrailingCommentRanges(text: string, pos: number): CommentRange[]; + /** Optionally, get the shebang */ + function getShebang(text: string): string; + function isIdentifierStart(ch: number, languageVersion: ScriptTarget): boolean; + function isIdentifierPart(ch: number, languageVersion: ScriptTarget): boolean; + function createScanner(languageVersion: ScriptTarget, skipTrivia: boolean, languageVariant?: LanguageVariant, text?: string, onError?: ErrorCallback, start?: number, length?: number): Scanner; +} +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; + /** + * Called to merge all the changes that occurred across several versions of a script snapshot + * into a single change. i.e. if a user keeps making successive edits to a script we will + * have a text change from V1 to V2, V2 to V3, ..., Vn. + * + * This function will then merge those changes into a single change range valid between V1 and + * Vn. + */ + function collapseTextChangeRangesAcrossMultipleVersions(changes: TextChangeRange[]): TextChangeRange; + function getTypeParameterOwner(d: Declaration): Declaration; +} +declare namespace ts { + function getNodeConstructor(kind: SyntaxKind): new (pos?: number, end?: number) => Node; + 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): SourceFile; + function updateSourceFile(sourceFile: SourceFile, newText: string, textChangeRange: TextChangeRange, aggressiveChecks?: boolean): SourceFile; +} +declare namespace ts { + const version: string; + function findConfigFile(searchPath: string): string; + function resolveTripleslashReference(moduleName: string, containingFile: string): string; + function resolveModuleName(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost): ResolvedModuleWithFailedLookupLocations; + function nodeModuleNameResolver(moduleName: string, containingFile: string, 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[]; + function flattenDiagnosticMessageText(messageText: string | DiagnosticMessageChain, newLine: string): string; + function createProgram(rootNames: string[], options: CompilerOptions, host?: CompilerHost, oldProgram?: Program): Program; +} +declare namespace ts { + function parseCommandLine(commandLine: string[], readFile?: (path: string) => string): ParsedCommandLine; + /** + * Read tsconfig.json file + * @param fileName The path to the config file + */ + function readConfigFile(fileName: string, readFile: (path: string) => string): { + config?: any; + error?: Diagnostic; + }; + /** + * Parse the text of the tsconfig.json file + * @param fileName The path to the config file + * @param jsonText The text of the config file + */ + function parseConfigFileTextToJson(fileName: string, jsonText: string): { + config?: any; + error?: Diagnostic; + }; + /** + * Parse the contents of a config file (tsconfig.json). + * @param json The contents of the config file to parse + * @param host Instance of ParseConfigHost used to enumerate files in folder. + * @param basePath A root directory to resolve relative path entries in the config + * file to. e.g. outDir + */ + function parseJsonConfigFileContent(json: any, host: ParseConfigHost, basePath: string): ParsedCommandLine; + function convertCompilerOptionsFromJson(jsonOptions: any, basePath: string): { + options: CompilerOptions; + errors: Diagnostic[]; + }; +} +declare namespace ts { + /** The version of the language service API */ + let servicesVersion: string; + interface Node { + getSourceFile(): SourceFile; + getChildCount(sourceFile?: SourceFile): number; + getChildAt(index: number, sourceFile?: SourceFile): Node; + getChildren(sourceFile?: SourceFile): Node[]; + getStart(sourceFile?: SourceFile): number; + getFullStart(): number; + getEnd(): number; + getWidth(sourceFile?: SourceFile): number; + getFullWidth(): number; + getLeadingTriviaWidth(sourceFile?: SourceFile): number; + getFullText(sourceFile?: SourceFile): string; + getText(sourceFile?: SourceFile): string; + getFirstToken(sourceFile?: SourceFile): Node; + getLastToken(sourceFile?: SourceFile): Node; + } + interface Symbol { + getFlags(): SymbolFlags; + getName(): string; + getDeclarations(): Declaration[]; + getDocumentationComment(): SymbolDisplayPart[]; + } + interface Type { + getFlags(): TypeFlags; + getSymbol(): Symbol; + getProperties(): Symbol[]; + getProperty(propertyName: string): Symbol; + getApparentProperties(): Symbol[]; + getCallSignatures(): Signature[]; + getConstructSignatures(): Signature[]; + getStringIndexType(): Type; + getNumberIndexType(): Type; + getBaseTypes(): ObjectType[]; + } + interface Signature { + getDeclaration(): SignatureDeclaration; + getTypeParameters(): Type[]; + getParameters(): Symbol[]; + getReturnType(): Type; + getDocumentationComment(): SymbolDisplayPart[]; + } + interface SourceFile { + getLineAndCharacterOfPosition(pos: number): LineAndCharacter; + getLineStarts(): number[]; + getPositionOfLineAndCharacter(line: number, character: number): number; + update(newText: string, textChangeRange: TextChangeRange): SourceFile; + } + /** + * Represents an immutable snapshot of a script at a specified time.Once acquired, the + * snapshot is observably immutable. i.e. the same calls with the same parameters will return + * the same values. + */ + interface IScriptSnapshot { + /** Gets a portion of the script snapshot specified by [start, end). */ + getText(start: number, end: number): string; + /** Gets the length of this script snapshot. */ + getLength(): number; + /** + * Gets the TextChangeRange that describe how the text changed between this text and + * an older version. This information is used by the incremental parser to determine + * what sections of the script need to be re-parsed. 'undefined' can be returned if the + * change range cannot be determined. However, in that case, incremental parsing will + * not happen and the entire document will be re - parsed. + */ + getChangeRange(oldSnapshot: IScriptSnapshot): TextChangeRange; + /** Releases all resources held by this script snapshot */ + dispose?(): void; + } + module ScriptSnapshot { + function fromString(text: string): IScriptSnapshot; + } + interface PreProcessedFileInfo { + referencedFiles: FileReference[]; + importedFiles: FileReference[]; + ambientExternalModules: string[]; + isLibFile: boolean; + } + interface HostCancellationToken { + isCancellationRequested(): boolean; + } + interface LanguageServiceHost { + getCompilationSettings(): CompilerOptions; + getNewLine?(): string; + getProjectVersion?(): string; + getScriptFileNames(): string[]; + getScriptVersion(fileName: string): string; + getScriptSnapshot(fileName: string): IScriptSnapshot; + getLocalizedDiagnosticMessages?(): any; + getCancellationToken?(): HostCancellationToken; + getCurrentDirectory(): string; + getDefaultLibFileName(options: CompilerOptions): string; + log?(s: string): void; + trace?(s: string): void; + error?(s: string): void; + useCaseSensitiveFileNames?(): boolean; + resolveModuleNames?(moduleNames: string[], containingFile: string): ResolvedModule[]; + } + interface LanguageService { + cleanupSemanticCache(): void; + getSyntacticDiagnostics(fileName: string): Diagnostic[]; + getSemanticDiagnostics(fileName: string): Diagnostic[]; + getCompilerOptionsDiagnostics(): Diagnostic[]; + /** + * @deprecated Use getEncodedSyntacticClassifications instead. + */ + getSyntacticClassifications(fileName: string, span: TextSpan): ClassifiedSpan[]; + /** + * @deprecated Use getEncodedSemanticClassifications instead. + */ + getSemanticClassifications(fileName: string, span: TextSpan): ClassifiedSpan[]; + getEncodedSyntacticClassifications(fileName: string, span: TextSpan): Classifications; + getEncodedSemanticClassifications(fileName: string, span: TextSpan): Classifications; + getCompletionsAtPosition(fileName: string, position: number): CompletionInfo; + getCompletionEntryDetails(fileName: string, position: number, entryName: string): CompletionEntryDetails; + getQuickInfoAtPosition(fileName: string, position: number): QuickInfo; + getNameOrDottedNameSpan(fileName: string, startPos: number, endPos: number): TextSpan; + getBreakpointStatementAtPosition(fileName: string, position: number): TextSpan; + getSignatureHelpItems(fileName: string, position: number): SignatureHelpItems; + getRenameInfo(fileName: string, position: number): RenameInfo; + findRenameLocations(fileName: string, position: number, findInStrings: boolean, findInComments: boolean): RenameLocation[]; + getDefinitionAtPosition(fileName: string, position: number): DefinitionInfo[]; + getTypeDefinitionAtPosition(fileName: string, position: number): DefinitionInfo[]; + getReferencesAtPosition(fileName: string, position: number): ReferenceEntry[]; + findReferences(fileName: string, position: number): ReferencedSymbol[]; + getDocumentHighlights(fileName: string, position: number, filesToSearch: string[]): DocumentHighlights[]; + /** @deprecated */ + getOccurrencesAtPosition(fileName: string, position: number): ReferenceEntry[]; + getNavigateToItems(searchValue: string, maxResultCount?: number): NavigateToItem[]; + getNavigationBarItems(fileName: string): NavigationBarItem[]; + 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[]; + getDocCommentTemplateAtPosition(fileName: string, position: number): TextInsertion; + getEmitOutput(fileName: string): EmitOutput; + getProgram(): Program; + getSourceFile(fileName: string): SourceFile; + dispose(): void; + } + interface Classifications { + spans: number[]; + endOfLineState: EndOfLineState; + } + interface ClassifiedSpan { + textSpan: TextSpan; + classificationType: string; + } + interface NavigationBarItem { + text: string; + kind: string; + kindModifiers: string; + spans: TextSpan[]; + childItems: NavigationBarItem[]; + indent: number; + bolded: boolean; + grayed: boolean; + } + interface TodoCommentDescriptor { + text: string; + priority: number; + } + interface TodoComment { + descriptor: TodoCommentDescriptor; + message: string; + position: number; + } + class TextChange { + span: TextSpan; + newText: string; + } + interface TextInsertion { + newText: string; + /** The position in newText the caret should point to after the insertion. */ + caretOffset: number; + } + interface RenameLocation { + textSpan: TextSpan; + fileName: string; + } + interface ReferenceEntry { + textSpan: TextSpan; + fileName: string; + isWriteAccess: boolean; + } + interface DocumentHighlights { + fileName: string; + highlightSpans: HighlightSpan[]; + } + module HighlightSpanKind { + const none: string; + const definition: string; + const reference: string; + const writtenReference: string; + } + interface HighlightSpan { + fileName?: string; + textSpan: TextSpan; + kind: string; + } + interface NavigateToItem { + name: string; + kind: string; + kindModifiers: string; + matchKind: string; + isCaseSensitive: boolean; + fileName: string; + textSpan: TextSpan; + containerName: string; + containerKind: string; + } + interface EditorOptions { + IndentSize: number; + TabSize: number; + NewLineCharacter: string; + ConvertTabsToSpaces: boolean; + IndentStyle: IndentStyle; + } + enum IndentStyle { + None = 0, + Block = 1, + Smart = 2, + } + interface FormatCodeOptions extends EditorOptions { + InsertSpaceAfterCommaDelimiter: boolean; + InsertSpaceAfterSemicolonInForStatements: boolean; + InsertSpaceBeforeAndAfterBinaryOperators: boolean; + InsertSpaceAfterKeywordsInControlFlowStatements: boolean; + InsertSpaceAfterFunctionKeywordForAnonymousFunctions: boolean; + InsertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis: boolean; + InsertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets: boolean; + PlaceOpenBraceOnNewLineForFunctions: boolean; + PlaceOpenBraceOnNewLineForControlBlocks: boolean; + [s: string]: boolean | number | string; + } + interface DefinitionInfo { + fileName: string; + textSpan: TextSpan; + kind: string; + name: string; + containerKind: string; + containerName: string; + } + interface ReferencedSymbol { + definition: DefinitionInfo; + references: ReferenceEntry[]; + } + enum SymbolDisplayPartKind { + aliasName = 0, + className = 1, + enumName = 2, + fieldName = 3, + interfaceName = 4, + keyword = 5, + lineBreak = 6, + numericLiteral = 7, + stringLiteral = 8, + localName = 9, + methodName = 10, + moduleName = 11, + operator = 12, + parameterName = 13, + propertyName = 14, + punctuation = 15, + space = 16, + text = 17, + typeParameterName = 18, + enumMemberName = 19, + functionName = 20, + regularExpressionLiteral = 21, + } + interface SymbolDisplayPart { + text: string; + kind: string; + } + interface QuickInfo { + kind: string; + kindModifiers: string; + textSpan: TextSpan; + displayParts: SymbolDisplayPart[]; + documentation: SymbolDisplayPart[]; + } + interface RenameInfo { + canRename: boolean; + localizedErrorMessage: string; + displayName: string; + fullDisplayName: string; + kind: string; + kindModifiers: string; + triggerSpan: TextSpan; + } + interface SignatureHelpParameter { + name: string; + documentation: SymbolDisplayPart[]; + displayParts: SymbolDisplayPart[]; + isOptional: boolean; + } + /** + * Represents a single signature to show in signature help. + * The id is used for subsequent calls into the language service to ask questions about the + * signature help item in the context of any documents that have been updated. i.e. after + * an edit has happened, while signature help is still active, the host can ask important + * questions like 'what parameter is the user currently contained within?'. + */ + interface SignatureHelpItem { + isVariadic: boolean; + prefixDisplayParts: SymbolDisplayPart[]; + suffixDisplayParts: SymbolDisplayPart[]; + separatorDisplayParts: SymbolDisplayPart[]; + parameters: SignatureHelpParameter[]; + documentation: SymbolDisplayPart[]; + } + /** + * Represents a set of signature help items, and the preferred item that should be selected. + */ + interface SignatureHelpItems { + items: SignatureHelpItem[]; + applicableSpan: TextSpan; + selectedItemIndex: number; + argumentIndex: number; + argumentCount: number; + } + interface CompletionInfo { + isMemberCompletion: boolean; + isNewIdentifierLocation: boolean; + entries: CompletionEntry[]; + } + interface CompletionEntry { + name: string; + kind: string; + kindModifiers: string; + sortText: string; + } + interface CompletionEntryDetails { + name: string; + kind: string; + kindModifiers: string; + displayParts: SymbolDisplayPart[]; + documentation: SymbolDisplayPart[]; + } + interface OutliningSpan { + /** The span of the document to actually collapse. */ + textSpan: TextSpan; + /** The span of the document to display when the user hovers over the collapsed span. */ + hintSpan: TextSpan; + /** The text to display in the editor for the collapsed region. */ + bannerText: string; + /** + * Whether or not this region should be automatically collapsed when + * the 'Collapse to Definitions' command is invoked. + */ + autoCollapse: boolean; + } + interface EmitOutput { + outputFiles: OutputFile[]; + emitSkipped: boolean; + } + const enum OutputFileType { + JavaScript = 0, + SourceMap = 1, + Declaration = 2, + } + interface OutputFile { + name: string; + writeByteOrderMark: boolean; + text: string; + } + const enum EndOfLineState { + None = 0, + InMultiLineCommentTrivia = 1, + InSingleQuoteStringLiteral = 2, + InDoubleQuoteStringLiteral = 3, + InTemplateHeadOrNoSubstitutionTemplate = 4, + InTemplateMiddleOrTail = 5, + InTemplateSubstitutionPosition = 6, + } + enum TokenClass { + Punctuation = 0, + Keyword = 1, + Operator = 2, + Comment = 3, + Whitespace = 4, + Identifier = 5, + NumberLiteral = 6, + StringLiteral = 7, + RegExpLiteral = 8, + } + interface ClassificationResult { + finalLexState: EndOfLineState; + entries: ClassificationInfo[]; + } + interface ClassificationInfo { + length: number; + classification: TokenClass; + } + interface Classifier { + /** + * Gives lexical classifications of tokens on a line without any syntactic context. + * For instance, a token consisting of the text 'string' can be either an identifier + * named 'string' or the keyword 'string', however, because this classifier is not aware, + * it relies on certain heuristics to give acceptable results. For classifications where + * speed trumps accuracy, this function is preferable; however, for true accuracy, the + * syntactic classifier is ideal. In fact, in certain editing scenarios, combining the + * lexical, syntactic, and semantic classifiers may issue the best user experience. + * + * @param text The text of a line to classify. + * @param lexState The state of the lexical classifier at the end of the previous line. + * @param syntacticClassifierAbsent Whether the client is *not* using a syntactic classifier. + * If there is no syntactic classifier (syntacticClassifierAbsent=true), + * certain heuristics may be used in its place; however, if there is a + * syntactic classifier (syntacticClassifierAbsent=false), certain + * classifications which may be incorrectly categorized will be given + * back as Identifiers in order to allow the syntactic classifier to + * subsume the classification. + * @deprecated Use getLexicalClassifications instead. + */ + getClassificationsForLine(text: string, lexState: EndOfLineState, syntacticClassifierAbsent: boolean): ClassificationResult; + getEncodedLexicalClassifications(text: string, endOfLineState: EndOfLineState, syntacticClassifierAbsent: boolean): Classifications; + } + /** + * The document registry represents a store of SourceFile objects that can be shared between + * multiple LanguageService instances. A LanguageService instance holds on the SourceFile (AST) + * of files in the context. + * SourceFile objects account for most of the memory usage by the language service. Sharing + * the same DocumentRegistry instance between different instances of LanguageService allow + * for more efficient memory utilization since all projects will share at least the library + * file (lib.d.ts). + * + * A more advanced use of the document registry is to serialize sourceFile objects to disk + * and re-hydrate them when needed. + * + * To create a default DocumentRegistry, use createDocumentRegistry to create one, and pass it + * to all subsequent createLanguageService calls. + */ + interface DocumentRegistry { + /** + * Request a stored SourceFile with a given fileName and compilationSettings. + * The first call to acquire will call createLanguageServiceSourceFile to generate + * the SourceFile if was not found in the registry. + * + * @param fileName The name of the file requested + * @param compilationSettings Some compilation settings like target affects the + * shape of a the resulting SourceFile. This allows the DocumentRegistry to store + * multiple copies of the same file for different compilation settings. + * @parm scriptSnapshot Text of the file. Only used if the file was not found + * in the registry and a new one was created. + * @parm version Current version of the file. Only used if the file was not found + * in the registry and a new one was created. + */ + acquireDocument(fileName: string, compilationSettings: CompilerOptions, scriptSnapshot: IScriptSnapshot, version: string): SourceFile; + /** + * Request an updated version of an already existing SourceFile with a given fileName + * and compilationSettings. The update will in-turn call updateLanguageServiceSourceFile + * to get an updated SourceFile. + * + * @param fileName The name of the file requested + * @param compilationSettings Some compilation settings like target affects the + * shape of a the resulting SourceFile. This allows the DocumentRegistry to store + * multiple copies of the same file for different compilation settings. + * @param scriptSnapshot Text of the file. + * @param version Current version of the file. + */ + updateDocument(fileName: string, compilationSettings: CompilerOptions, scriptSnapshot: IScriptSnapshot, version: string): SourceFile; + /** + * Informs the DocumentRegistry that a file is not needed any longer. + * + * Note: It is not allowed to call release on a SourceFile that was not acquired from + * this registry originally. + * + * @param fileName The name of the file to be released + * @param compilationSettings The compilation settings used to acquire the file + */ + releaseDocument(fileName: string, compilationSettings: CompilerOptions): void; + reportStats(): string; + } + module ScriptElementKind { + const unknown: string; + const warning: string; + const keyword: string; + const scriptElement: string; + const moduleElement: string; + const classElement: string; + const localClassElement: string; + const interfaceElement: string; + const typeElement: string; + const enumElement: string; + const variableElement: string; + const localVariableElement: string; + const functionElement: string; + const localFunctionElement: string; + const memberFunctionElement: string; + const memberGetAccessorElement: string; + const memberSetAccessorElement: string; + const memberVariableElement: string; + const constructorImplementationElement: string; + const callSignatureElement: string; + const indexSignatureElement: string; + const constructSignatureElement: string; + const parameterElement: string; + const typeParameterElement: string; + const primitiveType: string; + const label: string; + const alias: string; + const constElement: string; + const letElement: string; + } + module ScriptElementKindModifier { + const none: string; + const publicMemberModifier: string; + const privateMemberModifier: string; + const protectedMemberModifier: string; + const exportedModifier: string; + const ambientModifier: string; + const staticModifier: string; + const abstractModifier: string; + } + class ClassificationTypeNames { + static comment: string; + static identifier: string; + static keyword: string; + static numericLiteral: string; + static operator: string; + static stringLiteral: string; + static whiteSpace: string; + static text: string; + static punctuation: string; + static className: string; + static enumName: string; + static interfaceName: string; + static moduleName: string; + static typeParameterName: string; + static typeAliasName: string; + static parameterName: string; + static docCommentTagName: string; + } + const enum ClassificationType { + comment = 1, + identifier = 2, + keyword = 3, + numericLiteral = 4, + operator = 5, + stringLiteral = 6, + regularExpressionLiteral = 7, + whiteSpace = 8, + text = 9, + punctuation = 10, + className = 11, + enumName = 12, + interfaceName = 13, + moduleName = 14, + typeParameterName = 15, + typeAliasName = 16, + parameterName = 17, + docCommentTagName = 18, + } + interface DisplayPartsSymbolWriter extends SymbolWriter { + displayParts(): SymbolDisplayPart[]; + } + function displayPartsToString(displayParts: SymbolDisplayPart[]): string; + function getDefaultCompilerOptions(): CompilerOptions; + interface TranspileOptions { + compilerOptions?: CompilerOptions; + fileName?: string; + reportDiagnostics?: boolean; + moduleName?: string; + renamedDependencies?: Map; + } + interface TranspileOutput { + outputText: string; + diagnostics?: Diagnostic[]; + sourceMapText?: string; + } + function transpileModule(input: string, transpileOptions: TranspileOptions): TranspileOutput; + function transpile(input: string, compilerOptions?: CompilerOptions, fileName?: string, diagnostics?: Diagnostic[], moduleName?: string): string; + function createLanguageServiceSourceFile(fileName: string, scriptSnapshot: IScriptSnapshot, scriptTarget: ScriptTarget, version: string, setNodeParents: boolean): SourceFile; + let disableIncrementalParsing: boolean; + function updateLanguageServiceSourceFile(sourceFile: SourceFile, scriptSnapshot: IScriptSnapshot, version: string, textChangeRange: TextChangeRange, aggressiveChecks?: boolean): SourceFile; + function createGetCanonicalFileName(useCaseSensitivefileNames: boolean): (fileName: string) => string; + function createDocumentRegistry(useCaseSensitiveFileNames?: boolean): DocumentRegistry; + function preProcessFile(sourceText: string, readImportFiles?: boolean): PreProcessedFileInfo; + function createLanguageService(host: LanguageServiceHost, documentRegistry?: DocumentRegistry): LanguageService; + function createClassifier(): Classifier; + /** + * Get the path of the default library files (lib.d.ts) as distributed with the typescript + * node package. + * The functionality is not supported if the ts module is consumed outside of a node module. + */ + function getDefaultLibFilePath(options: CompilerOptions): string; +} export = ts; \ No newline at end of file diff --git a/lib/typescript.js b/lib/typescript.js index 6551e1be180..1e0c0edad05 100644 --- a/lib/typescript.js +++ b/lib/typescript.js @@ -13,50336 +13,50781 @@ See the Apache Version 2.0 License for specific language governing permissions and limitations under the License. ***************************************************************************** */ -var ts; -(function (ts) { - // token > SyntaxKind.Identifer => token is a keyword - // Also, If you add a new SyntaxKind be sure to keep the `Markers` section at the bottom in sync - (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"; - // We detect and preserve #! on the first line - SyntaxKind[SyntaxKind["ShebangTrivia"] = 6] = "ShebangTrivia"; - // We detect and provide better error recovery when we encounter a git merge marker. This - // allows us to edit files with git-conflict markers in them in a much more pleasant manner. - SyntaxKind[SyntaxKind["ConflictMarkerTrivia"] = 7] = "ConflictMarkerTrivia"; - // Literals - SyntaxKind[SyntaxKind["NumericLiteral"] = 8] = "NumericLiteral"; - SyntaxKind[SyntaxKind["StringLiteral"] = 9] = "StringLiteral"; - SyntaxKind[SyntaxKind["RegularExpressionLiteral"] = 10] = "RegularExpressionLiteral"; - SyntaxKind[SyntaxKind["NoSubstitutionTemplateLiteral"] = 11] = "NoSubstitutionTemplateLiteral"; - // Pseudo-literals - SyntaxKind[SyntaxKind["TemplateHead"] = 12] = "TemplateHead"; - SyntaxKind[SyntaxKind["TemplateMiddle"] = 13] = "TemplateMiddle"; - SyntaxKind[SyntaxKind["TemplateTail"] = 14] = "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"; - // 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"; - // Identifiers - SyntaxKind[SyntaxKind["Identifier"] = 69] = "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"; - // 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"; - // 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["RequireKeyword"] = 127] = "RequireKeyword"; - SyntaxKind[SyntaxKind["NumberKeyword"] = 128] = "NumberKeyword"; - SyntaxKind[SyntaxKind["SetKeyword"] = 129] = "SetKeyword"; - SyntaxKind[SyntaxKind["StringKeyword"] = 130] = "StringKeyword"; - SyntaxKind[SyntaxKind["SymbolKeyword"] = 131] = "SymbolKeyword"; - SyntaxKind[SyntaxKind["TypeKeyword"] = 132] = "TypeKeyword"; - SyntaxKind[SyntaxKind["FromKeyword"] = 133] = "FromKeyword"; - SyntaxKind[SyntaxKind["OfKeyword"] = 134] = "OfKeyword"; - // Parse tree nodes - // Names - SyntaxKind[SyntaxKind["QualifiedName"] = 135] = "QualifiedName"; - SyntaxKind[SyntaxKind["ComputedPropertyName"] = 136] = "ComputedPropertyName"; - // Signature elements - SyntaxKind[SyntaxKind["TypeParameter"] = 137] = "TypeParameter"; - SyntaxKind[SyntaxKind["Parameter"] = 138] = "Parameter"; - SyntaxKind[SyntaxKind["Decorator"] = 139] = "Decorator"; - // TypeMember - SyntaxKind[SyntaxKind["PropertySignature"] = 140] = "PropertySignature"; - SyntaxKind[SyntaxKind["PropertyDeclaration"] = 141] = "PropertyDeclaration"; - SyntaxKind[SyntaxKind["MethodSignature"] = 142] = "MethodSignature"; - SyntaxKind[SyntaxKind["MethodDeclaration"] = 143] = "MethodDeclaration"; - SyntaxKind[SyntaxKind["Constructor"] = 144] = "Constructor"; - SyntaxKind[SyntaxKind["GetAccessor"] = 145] = "GetAccessor"; - SyntaxKind[SyntaxKind["SetAccessor"] = 146] = "SetAccessor"; - SyntaxKind[SyntaxKind["CallSignature"] = 147] = "CallSignature"; - SyntaxKind[SyntaxKind["ConstructSignature"] = 148] = "ConstructSignature"; - SyntaxKind[SyntaxKind["IndexSignature"] = 149] = "IndexSignature"; - // Type - SyntaxKind[SyntaxKind["TypePredicate"] = 150] = "TypePredicate"; - SyntaxKind[SyntaxKind["TypeReference"] = 151] = "TypeReference"; - SyntaxKind[SyntaxKind["FunctionType"] = 152] = "FunctionType"; - SyntaxKind[SyntaxKind["ConstructorType"] = 153] = "ConstructorType"; - SyntaxKind[SyntaxKind["TypeQuery"] = 154] = "TypeQuery"; - SyntaxKind[SyntaxKind["TypeLiteral"] = 155] = "TypeLiteral"; - SyntaxKind[SyntaxKind["ArrayType"] = 156] = "ArrayType"; - SyntaxKind[SyntaxKind["TupleType"] = 157] = "TupleType"; - SyntaxKind[SyntaxKind["UnionType"] = 158] = "UnionType"; - SyntaxKind[SyntaxKind["IntersectionType"] = 159] = "IntersectionType"; - SyntaxKind[SyntaxKind["ParenthesizedType"] = 160] = "ParenthesizedType"; - // Binding patterns - SyntaxKind[SyntaxKind["ObjectBindingPattern"] = 161] = "ObjectBindingPattern"; - SyntaxKind[SyntaxKind["ArrayBindingPattern"] = 162] = "ArrayBindingPattern"; - SyntaxKind[SyntaxKind["BindingElement"] = 163] = "BindingElement"; - // Expression - SyntaxKind[SyntaxKind["ArrayLiteralExpression"] = 164] = "ArrayLiteralExpression"; - SyntaxKind[SyntaxKind["ObjectLiteralExpression"] = 165] = "ObjectLiteralExpression"; - SyntaxKind[SyntaxKind["PropertyAccessExpression"] = 166] = "PropertyAccessExpression"; - SyntaxKind[SyntaxKind["ElementAccessExpression"] = 167] = "ElementAccessExpression"; - SyntaxKind[SyntaxKind["CallExpression"] = 168] = "CallExpression"; - SyntaxKind[SyntaxKind["NewExpression"] = 169] = "NewExpression"; - SyntaxKind[SyntaxKind["TaggedTemplateExpression"] = 170] = "TaggedTemplateExpression"; - SyntaxKind[SyntaxKind["TypeAssertionExpression"] = 171] = "TypeAssertionExpression"; - SyntaxKind[SyntaxKind["ParenthesizedExpression"] = 172] = "ParenthesizedExpression"; - SyntaxKind[SyntaxKind["FunctionExpression"] = 173] = "FunctionExpression"; - SyntaxKind[SyntaxKind["ArrowFunction"] = 174] = "ArrowFunction"; - SyntaxKind[SyntaxKind["DeleteExpression"] = 175] = "DeleteExpression"; - SyntaxKind[SyntaxKind["TypeOfExpression"] = 176] = "TypeOfExpression"; - SyntaxKind[SyntaxKind["VoidExpression"] = 177] = "VoidExpression"; - SyntaxKind[SyntaxKind["AwaitExpression"] = 178] = "AwaitExpression"; - SyntaxKind[SyntaxKind["PrefixUnaryExpression"] = 179] = "PrefixUnaryExpression"; - SyntaxKind[SyntaxKind["PostfixUnaryExpression"] = 180] = "PostfixUnaryExpression"; - SyntaxKind[SyntaxKind["BinaryExpression"] = 181] = "BinaryExpression"; - SyntaxKind[SyntaxKind["ConditionalExpression"] = 182] = "ConditionalExpression"; - SyntaxKind[SyntaxKind["TemplateExpression"] = 183] = "TemplateExpression"; - SyntaxKind[SyntaxKind["YieldExpression"] = 184] = "YieldExpression"; - SyntaxKind[SyntaxKind["SpreadElementExpression"] = 185] = "SpreadElementExpression"; - SyntaxKind[SyntaxKind["ClassExpression"] = 186] = "ClassExpression"; - SyntaxKind[SyntaxKind["OmittedExpression"] = 187] = "OmittedExpression"; - SyntaxKind[SyntaxKind["ExpressionWithTypeArguments"] = 188] = "ExpressionWithTypeArguments"; - SyntaxKind[SyntaxKind["AsExpression"] = 189] = "AsExpression"; - // Misc - SyntaxKind[SyntaxKind["TemplateSpan"] = 190] = "TemplateSpan"; - SyntaxKind[SyntaxKind["SemicolonClassElement"] = 191] = "SemicolonClassElement"; - // Element - SyntaxKind[SyntaxKind["Block"] = 192] = "Block"; - SyntaxKind[SyntaxKind["VariableStatement"] = 193] = "VariableStatement"; - SyntaxKind[SyntaxKind["EmptyStatement"] = 194] = "EmptyStatement"; - SyntaxKind[SyntaxKind["ExpressionStatement"] = 195] = "ExpressionStatement"; - SyntaxKind[SyntaxKind["IfStatement"] = 196] = "IfStatement"; - SyntaxKind[SyntaxKind["DoStatement"] = 197] = "DoStatement"; - SyntaxKind[SyntaxKind["WhileStatement"] = 198] = "WhileStatement"; - SyntaxKind[SyntaxKind["ForStatement"] = 199] = "ForStatement"; - SyntaxKind[SyntaxKind["ForInStatement"] = 200] = "ForInStatement"; - SyntaxKind[SyntaxKind["ForOfStatement"] = 201] = "ForOfStatement"; - SyntaxKind[SyntaxKind["ContinueStatement"] = 202] = "ContinueStatement"; - SyntaxKind[SyntaxKind["BreakStatement"] = 203] = "BreakStatement"; - SyntaxKind[SyntaxKind["ReturnStatement"] = 204] = "ReturnStatement"; - SyntaxKind[SyntaxKind["WithStatement"] = 205] = "WithStatement"; - SyntaxKind[SyntaxKind["SwitchStatement"] = 206] = "SwitchStatement"; - SyntaxKind[SyntaxKind["LabeledStatement"] = 207] = "LabeledStatement"; - SyntaxKind[SyntaxKind["ThrowStatement"] = 208] = "ThrowStatement"; - SyntaxKind[SyntaxKind["TryStatement"] = 209] = "TryStatement"; - SyntaxKind[SyntaxKind["DebuggerStatement"] = 210] = "DebuggerStatement"; - SyntaxKind[SyntaxKind["VariableDeclaration"] = 211] = "VariableDeclaration"; - SyntaxKind[SyntaxKind["VariableDeclarationList"] = 212] = "VariableDeclarationList"; - SyntaxKind[SyntaxKind["FunctionDeclaration"] = 213] = "FunctionDeclaration"; - SyntaxKind[SyntaxKind["ClassDeclaration"] = 214] = "ClassDeclaration"; - SyntaxKind[SyntaxKind["InterfaceDeclaration"] = 215] = "InterfaceDeclaration"; - SyntaxKind[SyntaxKind["TypeAliasDeclaration"] = 216] = "TypeAliasDeclaration"; - SyntaxKind[SyntaxKind["EnumDeclaration"] = 217] = "EnumDeclaration"; - SyntaxKind[SyntaxKind["ModuleDeclaration"] = 218] = "ModuleDeclaration"; - SyntaxKind[SyntaxKind["ModuleBlock"] = 219] = "ModuleBlock"; - SyntaxKind[SyntaxKind["CaseBlock"] = 220] = "CaseBlock"; - SyntaxKind[SyntaxKind["ImportEqualsDeclaration"] = 221] = "ImportEqualsDeclaration"; - SyntaxKind[SyntaxKind["ImportDeclaration"] = 222] = "ImportDeclaration"; - SyntaxKind[SyntaxKind["ImportClause"] = 223] = "ImportClause"; - SyntaxKind[SyntaxKind["NamespaceImport"] = 224] = "NamespaceImport"; - SyntaxKind[SyntaxKind["NamedImports"] = 225] = "NamedImports"; - SyntaxKind[SyntaxKind["ImportSpecifier"] = 226] = "ImportSpecifier"; - SyntaxKind[SyntaxKind["ExportAssignment"] = 227] = "ExportAssignment"; - SyntaxKind[SyntaxKind["ExportDeclaration"] = 228] = "ExportDeclaration"; - SyntaxKind[SyntaxKind["NamedExports"] = 229] = "NamedExports"; - SyntaxKind[SyntaxKind["ExportSpecifier"] = 230] = "ExportSpecifier"; - SyntaxKind[SyntaxKind["MissingDeclaration"] = 231] = "MissingDeclaration"; - // Module references - SyntaxKind[SyntaxKind["ExternalModuleReference"] = 232] = "ExternalModuleReference"; - // JSX - SyntaxKind[SyntaxKind["JsxElement"] = 233] = "JsxElement"; - SyntaxKind[SyntaxKind["JsxSelfClosingElement"] = 234] = "JsxSelfClosingElement"; - SyntaxKind[SyntaxKind["JsxOpeningElement"] = 235] = "JsxOpeningElement"; - SyntaxKind[SyntaxKind["JsxText"] = 236] = "JsxText"; - SyntaxKind[SyntaxKind["JsxClosingElement"] = 237] = "JsxClosingElement"; - SyntaxKind[SyntaxKind["JsxAttribute"] = 238] = "JsxAttribute"; - SyntaxKind[SyntaxKind["JsxSpreadAttribute"] = 239] = "JsxSpreadAttribute"; - SyntaxKind[SyntaxKind["JsxExpression"] = 240] = "JsxExpression"; - // Clauses - SyntaxKind[SyntaxKind["CaseClause"] = 241] = "CaseClause"; - SyntaxKind[SyntaxKind["DefaultClause"] = 242] = "DefaultClause"; - SyntaxKind[SyntaxKind["HeritageClause"] = 243] = "HeritageClause"; - SyntaxKind[SyntaxKind["CatchClause"] = 244] = "CatchClause"; - // Property assignments - SyntaxKind[SyntaxKind["PropertyAssignment"] = 245] = "PropertyAssignment"; - SyntaxKind[SyntaxKind["ShorthandPropertyAssignment"] = 246] = "ShorthandPropertyAssignment"; - // Enum - SyntaxKind[SyntaxKind["EnumMember"] = 247] = "EnumMember"; - // Top-level nodes - SyntaxKind[SyntaxKind["SourceFile"] = 248] = "SourceFile"; - // JSDoc nodes. - SyntaxKind[SyntaxKind["JSDocTypeExpression"] = 249] = "JSDocTypeExpression"; - // The * type. - SyntaxKind[SyntaxKind["JSDocAllType"] = 250] = "JSDocAllType"; - // The ? type. - SyntaxKind[SyntaxKind["JSDocUnknownType"] = 251] = "JSDocUnknownType"; - SyntaxKind[SyntaxKind["JSDocArrayType"] = 252] = "JSDocArrayType"; - SyntaxKind[SyntaxKind["JSDocUnionType"] = 253] = "JSDocUnionType"; - SyntaxKind[SyntaxKind["JSDocTupleType"] = 254] = "JSDocTupleType"; - SyntaxKind[SyntaxKind["JSDocNullableType"] = 255] = "JSDocNullableType"; - SyntaxKind[SyntaxKind["JSDocNonNullableType"] = 256] = "JSDocNonNullableType"; - SyntaxKind[SyntaxKind["JSDocRecordType"] = 257] = "JSDocRecordType"; - SyntaxKind[SyntaxKind["JSDocRecordMember"] = 258] = "JSDocRecordMember"; - SyntaxKind[SyntaxKind["JSDocTypeReference"] = 259] = "JSDocTypeReference"; - SyntaxKind[SyntaxKind["JSDocOptionalType"] = 260] = "JSDocOptionalType"; - SyntaxKind[SyntaxKind["JSDocFunctionType"] = 261] = "JSDocFunctionType"; - SyntaxKind[SyntaxKind["JSDocVariadicType"] = 262] = "JSDocVariadicType"; - SyntaxKind[SyntaxKind["JSDocConstructorType"] = 263] = "JSDocConstructorType"; - SyntaxKind[SyntaxKind["JSDocThisType"] = 264] = "JSDocThisType"; - SyntaxKind[SyntaxKind["JSDocComment"] = 265] = "JSDocComment"; - SyntaxKind[SyntaxKind["JSDocTag"] = 266] = "JSDocTag"; - SyntaxKind[SyntaxKind["JSDocParameterTag"] = 267] = "JSDocParameterTag"; - SyntaxKind[SyntaxKind["JSDocReturnTag"] = 268] = "JSDocReturnTag"; - SyntaxKind[SyntaxKind["JSDocTypeTag"] = 269] = "JSDocTypeTag"; - SyntaxKind[SyntaxKind["JSDocTemplateTag"] = 270] = "JSDocTemplateTag"; - // Synthesized list - SyntaxKind[SyntaxKind["SyntaxList"] = 271] = "SyntaxList"; - // Enum value count - SyntaxKind[SyntaxKind["Count"] = 272] = "Count"; - // Markers - SyntaxKind[SyntaxKind["FirstAssignment"] = 56] = "FirstAssignment"; - SyntaxKind[SyntaxKind["LastAssignment"] = 68] = "LastAssignment"; - SyntaxKind[SyntaxKind["FirstReservedWord"] = 70] = "FirstReservedWord"; - SyntaxKind[SyntaxKind["LastReservedWord"] = 105] = "LastReservedWord"; - SyntaxKind[SyntaxKind["FirstKeyword"] = 70] = "FirstKeyword"; - SyntaxKind[SyntaxKind["LastKeyword"] = 134] = "LastKeyword"; - SyntaxKind[SyntaxKind["FirstFutureReservedWord"] = 106] = "FirstFutureReservedWord"; - SyntaxKind[SyntaxKind["LastFutureReservedWord"] = 114] = "LastFutureReservedWord"; - SyntaxKind[SyntaxKind["FirstTypeNode"] = 151] = "FirstTypeNode"; - SyntaxKind[SyntaxKind["LastTypeNode"] = 160] = "LastTypeNode"; - SyntaxKind[SyntaxKind["FirstPunctuation"] = 15] = "FirstPunctuation"; - SyntaxKind[SyntaxKind["LastPunctuation"] = 68] = "LastPunctuation"; - SyntaxKind[SyntaxKind["FirstToken"] = 0] = "FirstToken"; - SyntaxKind[SyntaxKind["LastToken"] = 134] = "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"] = 135] = "FirstNode"; - })(ts.SyntaxKind || (ts.SyntaxKind = {})); - var SyntaxKind = ts.SyntaxKind; - (function (NodeFlags) { - NodeFlags[NodeFlags["None"] = 0] = "None"; - NodeFlags[NodeFlags["Export"] = 1] = "Export"; - NodeFlags[NodeFlags["Ambient"] = 2] = "Ambient"; - NodeFlags[NodeFlags["Public"] = 16] = "Public"; - NodeFlags[NodeFlags["Private"] = 32] = "Private"; - NodeFlags[NodeFlags["Protected"] = 64] = "Protected"; - NodeFlags[NodeFlags["Static"] = 128] = "Static"; - NodeFlags[NodeFlags["Abstract"] = 256] = "Abstract"; - NodeFlags[NodeFlags["Async"] = 512] = "Async"; - NodeFlags[NodeFlags["Default"] = 1024] = "Default"; - NodeFlags[NodeFlags["MultiLine"] = 2048] = "MultiLine"; - NodeFlags[NodeFlags["Synthetic"] = 4096] = "Synthetic"; - NodeFlags[NodeFlags["DeclarationFile"] = 8192] = "DeclarationFile"; - NodeFlags[NodeFlags["Let"] = 16384] = "Let"; - NodeFlags[NodeFlags["Const"] = 32768] = "Const"; - NodeFlags[NodeFlags["OctalLiteral"] = 65536] = "OctalLiteral"; - NodeFlags[NodeFlags["Namespace"] = 131072] = "Namespace"; - NodeFlags[NodeFlags["ExportContext"] = 262144] = "ExportContext"; - NodeFlags[NodeFlags["ContainsThis"] = 524288] = "ContainsThis"; - NodeFlags[NodeFlags["Modifier"] = 2035] = "Modifier"; - NodeFlags[NodeFlags["AccessibilityModifier"] = 112] = "AccessibilityModifier"; - NodeFlags[NodeFlags["BlockScoped"] = 49152] = "BlockScoped"; - })(ts.NodeFlags || (ts.NodeFlags = {})); - var NodeFlags = ts.NodeFlags; - /* @internal */ - (function (ParserContextFlags) { - ParserContextFlags[ParserContextFlags["None"] = 0] = "None"; - // If this node was parsed in a context where 'in-expressions' are not allowed. - ParserContextFlags[ParserContextFlags["DisallowIn"] = 1] = "DisallowIn"; - // If this node was parsed in the 'yield' context created when parsing a generator. - ParserContextFlags[ParserContextFlags["Yield"] = 2] = "Yield"; - // If this node was parsed as part of a decorator - ParserContextFlags[ParserContextFlags["Decorator"] = 4] = "Decorator"; - // If this node was parsed in the 'await' context created when parsing an async function. - ParserContextFlags[ParserContextFlags["Await"] = 8] = "Await"; - // If the parser encountered an error when parsing the code that created this node. Note - // the parser only sets this directly on the node it creates right after encountering the - // error. - ParserContextFlags[ParserContextFlags["ThisNodeHasError"] = 16] = "ThisNodeHasError"; - // This node was parsed in a JavaScript file and can be processed differently. For example - // its type can be specified usign a JSDoc comment. - ParserContextFlags[ParserContextFlags["JavaScriptFile"] = 32] = "JavaScriptFile"; - // Context flags set directly by the parser. - ParserContextFlags[ParserContextFlags["ParserGeneratedFlags"] = 31] = "ParserGeneratedFlags"; - // Exclude these flags when parsing a Type - ParserContextFlags[ParserContextFlags["TypeExcludesFlags"] = 10] = "TypeExcludesFlags"; - // Context flags computed by aggregating child flags upwards. - // Used during incremental parsing to determine if this node or any of its children had an - // error. Computed only once and then cached. - ParserContextFlags[ParserContextFlags["ThisNodeOrAnySubNodesHasError"] = 64] = "ThisNodeOrAnySubNodesHasError"; - // Used to know if we've computed data from children and cached it in this node. - ParserContextFlags[ParserContextFlags["HasAggregatedChildData"] = 128] = "HasAggregatedChildData"; - })(ts.ParserContextFlags || (ts.ParserContextFlags = {})); - var ParserContextFlags = ts.ParserContextFlags; - (function (JsxFlags) { - JsxFlags[JsxFlags["None"] = 0] = "None"; - JsxFlags[JsxFlags["IntrinsicNamedElement"] = 1] = "IntrinsicNamedElement"; - JsxFlags[JsxFlags["IntrinsicIndexedElement"] = 2] = "IntrinsicIndexedElement"; - JsxFlags[JsxFlags["ClassElement"] = 4] = "ClassElement"; - JsxFlags[JsxFlags["UnknownElement"] = 8] = "UnknownElement"; - JsxFlags[JsxFlags["IntrinsicElement"] = 3] = "IntrinsicElement"; - })(ts.JsxFlags || (ts.JsxFlags = {})); - var JsxFlags = ts.JsxFlags; - /* @internal */ - (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; - var OperationCanceledException = (function () { - function OperationCanceledException() { - } - return OperationCanceledException; - })(); - ts.OperationCanceledException = OperationCanceledException; - /** Return code used by getEmitOutput function to indicate status of the function */ - (function (ExitStatus) { - // Compiler ran successfully. Either this was a simple do-nothing compilation (for example, - // when -version or -help was provided, or this was a normal compilation, no diagnostics - // were produced, and all outputs were generated successfully. - ExitStatus[ExitStatus["Success"] = 0] = "Success"; - // Diagnostics were produced and because of them no code was generated. - ExitStatus[ExitStatus["DiagnosticsPresent_OutputsSkipped"] = 1] = "DiagnosticsPresent_OutputsSkipped"; - // Diagnostics were produced and outputs were generated in spite of them. - 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"; - })(ts.TypeFormatFlags || (ts.TypeFormatFlags = {})); - var TypeFormatFlags = ts.TypeFormatFlags; - (function (SymbolFormatFlags) { - SymbolFormatFlags[SymbolFormatFlags["None"] = 0] = "None"; - // Write symbols's type argument if it is instantiated symbol - // eg. class C { p: T } <-- Show p as C.p here - // var a: C; - // var p = a.p; <--- Here p is property of C so show it as C.p instead of just C.p - SymbolFormatFlags[SymbolFormatFlags["WriteTypeParametersOrArguments"] = 1] = "WriteTypeParametersOrArguments"; - // Use only external alias information to get the symbol name in the given context - // eg. module m { export class c { } } import x = m.c; - // When this flag is specified m.c will be used to refer to the class instead of alias symbol x - SymbolFormatFlags[SymbolFormatFlags["UseOnlyExternalAliasing"] = 2] = "UseOnlyExternalAliasing"; - })(ts.SymbolFormatFlags || (ts.SymbolFormatFlags = {})); - var SymbolFormatFlags = ts.SymbolFormatFlags; - /* @internal */ - (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; - /** Indicates how to serialize the name for a TypeReferenceNode when emitting decorator - * metadata */ - /* @internal */ - (function (TypeReferenceSerializationKind) { - TypeReferenceSerializationKind[TypeReferenceSerializationKind["Unknown"] = 0] = "Unknown"; - // should be emitted using a safe fallback. - TypeReferenceSerializationKind[TypeReferenceSerializationKind["TypeWithConstructSignatureAndValue"] = 1] = "TypeWithConstructSignatureAndValue"; - // function that can be reached at runtime (e.g. a `class` - // declaration or a `var` declaration for the static side - // of a type, such as the global `Promise` type in lib.d.ts). - TypeReferenceSerializationKind[TypeReferenceSerializationKind["VoidType"] = 2] = "VoidType"; - TypeReferenceSerializationKind[TypeReferenceSerializationKind["NumberLikeType"] = 3] = "NumberLikeType"; - TypeReferenceSerializationKind[TypeReferenceSerializationKind["StringLikeType"] = 4] = "StringLikeType"; - TypeReferenceSerializationKind[TypeReferenceSerializationKind["BooleanType"] = 5] = "BooleanType"; - TypeReferenceSerializationKind[TypeReferenceSerializationKind["ArrayLikeType"] = 6] = "ArrayLikeType"; - TypeReferenceSerializationKind[TypeReferenceSerializationKind["ESSymbolType"] = 7] = "ESSymbolType"; - TypeReferenceSerializationKind[TypeReferenceSerializationKind["TypeWithCallSignature"] = 8] = "TypeWithCallSignature"; - // with call signatures. - TypeReferenceSerializationKind[TypeReferenceSerializationKind["ObjectType"] = 9] = "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"] = 793056] = "Type"; - SymbolFlags[SymbolFlags["Namespace"] = 1536] = "Namespace"; - SymbolFlags[SymbolFlags["Module"] = 1536] = "Module"; - SymbolFlags[SymbolFlags["Accessor"] = 98304] = "Accessor"; - // Variables can be redeclared, but can not redeclare a block-scoped declaration with the - // same name, or any other value that is not a variable, e.g. ValueModule or Class - SymbolFlags[SymbolFlags["FunctionScopedVariableExcludes"] = 107454] = "FunctionScopedVariableExcludes"; - // Block-scoped declarations are not allowed to be re-declared - // they can not merge with anything in the value space - SymbolFlags[SymbolFlags["BlockScopedVariableExcludes"] = 107455] = "BlockScopedVariableExcludes"; - SymbolFlags[SymbolFlags["ParameterExcludes"] = 107455] = "ParameterExcludes"; - SymbolFlags[SymbolFlags["PropertyExcludes"] = 107455] = "PropertyExcludes"; - SymbolFlags[SymbolFlags["EnumMemberExcludes"] = 107455] = "EnumMemberExcludes"; - SymbolFlags[SymbolFlags["FunctionExcludes"] = 106927] = "FunctionExcludes"; - SymbolFlags[SymbolFlags["ClassExcludes"] = 899519] = "ClassExcludes"; - SymbolFlags[SymbolFlags["InterfaceExcludes"] = 792960] = "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"] = 530912] = "TypeParameterExcludes"; - SymbolFlags[SymbolFlags["TypeAliasExcludes"] = 793056] = "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"; - /* @internal */ - // The set of things we consider semantically classifiable. Used to speed up the LS during - // classification. - SymbolFlags[SymbolFlags["Classifiable"] = 788448] = "Classifiable"; - })(ts.SymbolFlags || (ts.SymbolFlags = {})); - var SymbolFlags = ts.SymbolFlags; - /* @internal */ - (function (NodeCheckFlags) { - NodeCheckFlags[NodeCheckFlags["TypeChecked"] = 1] = "TypeChecked"; - NodeCheckFlags[NodeCheckFlags["LexicalThis"] = 2] = "LexicalThis"; - NodeCheckFlags[NodeCheckFlags["CaptureThis"] = 4] = "CaptureThis"; - NodeCheckFlags[NodeCheckFlags["EmitExtends"] = 8] = "EmitExtends"; - NodeCheckFlags[NodeCheckFlags["EmitDecorate"] = 16] = "EmitDecorate"; - NodeCheckFlags[NodeCheckFlags["EmitParam"] = 32] = "EmitParam"; - NodeCheckFlags[NodeCheckFlags["EmitAwaiter"] = 64] = "EmitAwaiter"; - NodeCheckFlags[NodeCheckFlags["EmitGenerator"] = 128] = "EmitGenerator"; - NodeCheckFlags[NodeCheckFlags["SuperInstance"] = 256] = "SuperInstance"; - NodeCheckFlags[NodeCheckFlags["SuperStatic"] = 512] = "SuperStatic"; - NodeCheckFlags[NodeCheckFlags["ContextChecked"] = 1024] = "ContextChecked"; - NodeCheckFlags[NodeCheckFlags["LexicalArguments"] = 2048] = "LexicalArguments"; - NodeCheckFlags[NodeCheckFlags["CaptureArguments"] = 4096] = "CaptureArguments"; - // Values for enum members have been computed, and any errors have been reported for them. - NodeCheckFlags[NodeCheckFlags["EnumValuesComputed"] = 8192] = "EnumValuesComputed"; - NodeCheckFlags[NodeCheckFlags["BlockScopedBindingInLoop"] = 16384] = "BlockScopedBindingInLoop"; - NodeCheckFlags[NodeCheckFlags["LexicalModuleMergesWithClass"] = 32768] = "LexicalModuleMergesWithClass"; - })(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["Void"] = 16] = "Void"; - TypeFlags[TypeFlags["Undefined"] = 32] = "Undefined"; - TypeFlags[TypeFlags["Null"] = 64] = "Null"; - TypeFlags[TypeFlags["Enum"] = 128] = "Enum"; - TypeFlags[TypeFlags["StringLiteral"] = 256] = "StringLiteral"; - TypeFlags[TypeFlags["TypeParameter"] = 512] = "TypeParameter"; - TypeFlags[TypeFlags["Class"] = 1024] = "Class"; - TypeFlags[TypeFlags["Interface"] = 2048] = "Interface"; - TypeFlags[TypeFlags["Reference"] = 4096] = "Reference"; - TypeFlags[TypeFlags["Tuple"] = 8192] = "Tuple"; - TypeFlags[TypeFlags["Union"] = 16384] = "Union"; - TypeFlags[TypeFlags["Intersection"] = 32768] = "Intersection"; - TypeFlags[TypeFlags["Anonymous"] = 65536] = "Anonymous"; - TypeFlags[TypeFlags["Instantiated"] = 131072] = "Instantiated"; - /* @internal */ - TypeFlags[TypeFlags["FromSignature"] = 262144] = "FromSignature"; - TypeFlags[TypeFlags["ObjectLiteral"] = 524288] = "ObjectLiteral"; - /* @internal */ - TypeFlags[TypeFlags["FreshObjectLiteral"] = 1048576] = "FreshObjectLiteral"; - /* @internal */ - TypeFlags[TypeFlags["ContainsUndefinedOrNull"] = 2097152] = "ContainsUndefinedOrNull"; - /* @internal */ - TypeFlags[TypeFlags["ContainsObjectLiteral"] = 4194304] = "ContainsObjectLiteral"; - /* @internal */ - TypeFlags[TypeFlags["ContainsAnyFunctionType"] = 8388608] = "ContainsAnyFunctionType"; - TypeFlags[TypeFlags["ESSymbol"] = 16777216] = "ESSymbol"; - TypeFlags[TypeFlags["ThisType"] = 33554432] = "ThisType"; - /* @internal */ - TypeFlags[TypeFlags["Intrinsic"] = 16777343] = "Intrinsic"; - /* @internal */ - TypeFlags[TypeFlags["Primitive"] = 16777726] = "Primitive"; - TypeFlags[TypeFlags["StringLike"] = 258] = "StringLike"; - TypeFlags[TypeFlags["NumberLike"] = 132] = "NumberLike"; - TypeFlags[TypeFlags["ObjectType"] = 80896] = "ObjectType"; - TypeFlags[TypeFlags["UnionOrIntersection"] = 49152] = "UnionOrIntersection"; - TypeFlags[TypeFlags["StructuredType"] = 130048] = "StructuredType"; - /* @internal */ - TypeFlags[TypeFlags["RequiresWidening"] = 6291456] = "RequiresWidening"; - /* @internal */ - TypeFlags[TypeFlags["PropagatingFlags"] = 14680064] = "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 (DiagnosticCategory) { - DiagnosticCategory[DiagnosticCategory["Warning"] = 0] = "Warning"; - DiagnosticCategory[DiagnosticCategory["Error"] = 1] = "Error"; - DiagnosticCategory[DiagnosticCategory["Message"] = 2] = "Message"; - })(ts.DiagnosticCategory || (ts.DiagnosticCategory = {})); - var DiagnosticCategory = ts.DiagnosticCategory; - (function (ModuleResolutionKind) { - ModuleResolutionKind[ModuleResolutionKind["Classic"] = 1] = "Classic"; - ModuleResolutionKind[ModuleResolutionKind["NodeJs"] = 2] = "NodeJs"; - })(ts.ModuleResolutionKind || (ts.ModuleResolutionKind = {})); - var ModuleResolutionKind = ts.ModuleResolutionKind; - (function (ModuleKind) { - ModuleKind[ModuleKind["None"] = 0] = "None"; - ModuleKind[ModuleKind["CommonJS"] = 1] = "CommonJS"; - 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 (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"; - })(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; - /* @internal */ - (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"; - // Unicode 3.0 space characters - 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; -})(ts || (ts = {})); -/// -/* @internal */ -var ts; -(function (ts) { - /** - * Ternary values are defined such that - * x & y is False if either x or y is False. - * x & y is Maybe if either x or y is Maybe, but neither x or y is False. - * x & y is True if both x and y are True. - * x | y is False if both x and y are False. - * x | y is Maybe if either x or y is Maybe, but neither x or y is True. - * x | y is True if either x or y is True. - */ - (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; - function createFileMap(getCanonicalFileName) { - var files = {}; - return { - get: get, - set: set, - contains: contains, - remove: remove, - clear: clear, - forEachValue: forEachValueInMap - }; - function set(fileName, value) { - files[normalizeKey(fileName)] = value; - } - function get(fileName) { - return files[normalizeKey(fileName)]; - } - function contains(fileName) { - return hasProperty(files, normalizeKey(fileName)); - } - function remove(fileName) { - var key = normalizeKey(fileName); - delete files[key]; - } - function forEachValueInMap(f) { - forEachValue(files, f); - } - function normalizeKey(key) { - return getCanonicalFileName(normalizeSlashes(key)); - } - function clear() { - files = {}; - } - } - ts.createFileMap = createFileMap; - (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; - /** - * Iterates through 'array' by index and performs the callback on each element of array until the callback - * returns a truthy value, then returns that value. - * If no such value is found, the callback is applied to each element of array and undefined is returned. - */ - function forEach(array, callback) { - if (array) { - for (var i = 0, len = array.length; i < len; i++) { - var result = callback(array[i], i); - if (result) { - return result; - } - } - } - return undefined; - } - ts.forEach = forEach; - function contains(array, value) { - if (array) { - for (var _i = 0; _i < array.length; _i++) { - var v = array[_i]; - if (v === value) { - return true; - } - } - } - return false; - } - ts.contains = contains; - function indexOf(array, value) { - if (array) { - for (var i = 0, len = array.length; i < len; i++) { - if (array[i] === value) { - return i; - } - } - } - return -1; - } - ts.indexOf = indexOf; - function countWhere(array, predicate) { - var count = 0; - if (array) { - for (var _i = 0; _i < array.length; _i++) { - var v = array[_i]; - if (predicate(v)) { - count++; - } - } - } - return count; - } - ts.countWhere = countWhere; - function filter(array, f) { - var result; - if (array) { - result = []; - for (var _i = 0; _i < array.length; _i++) { - var item = array[_i]; - if (f(item)) { - result.push(item); - } - } - } - return result; - } - ts.filter = filter; - function map(array, f) { - var result; - if (array) { - result = []; - for (var _i = 0; _i < array.length; _i++) { - var v = array[_i]; - result.push(f(v)); - } - } - return result; - } - ts.map = map; - function concatenate(array1, array2) { - if (!array2 || !array2.length) - return array1; - if (!array1 || !array1.length) - return array2; - return array1.concat(array2); - } - ts.concatenate = concatenate; - function deduplicate(array) { - var result; - if (array) { - result = []; - for (var _i = 0; _i < array.length; _i++) { - var item = array[_i]; - if (!contains(result, item)) { - result.push(item); - } - } - } - return result; - } - ts.deduplicate = deduplicate; - function sum(array, prop) { - var result = 0; - for (var _i = 0; _i < array.length; _i++) { - var v = array[_i]; - result += v[prop]; - } - return result; - } - ts.sum = sum; - function addRange(to, from) { - if (to && from) { - for (var _i = 0; _i < from.length; _i++) { - var v = from[_i]; - to.push(v); - } - } - } - ts.addRange = addRange; - function rangeEquals(array1, array2, pos, end) { - while (pos < end) { - if (array1[pos] !== array2[pos]) { - return false; - } - pos++; - } - return true; - } - ts.rangeEquals = rangeEquals; - /** - * Returns the last element of an array if non-empty, undefined otherwise. - */ - function lastOrUndefined(array) { - if (array.length === 0) { - return undefined; - } - return array[array.length - 1]; - } - ts.lastOrUndefined = lastOrUndefined; - /** - * 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 - * number[index] exceeds number. - * @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) { - var low = 0; - var high = array.length - 1; - while (low <= high) { - var middle = low + ((high - low) >> 1); - var midValue = array[middle]; - if (midValue === value) { - return middle; - } - else if (midValue > value) { - high = middle - 1; - } - else { - low = middle + 1; - } - } - return ~low; - } - ts.binarySearch = binarySearch; - function reduceLeft(array, f, initial) { - if (array) { - var count = array.length; - if (count > 0) { - var pos = 0; - var result = arguments.length <= 2 ? array[pos++] : initial; - while (pos < count) { - result = f(result, array[pos++]); - } - return result; - } - } - return initial; - } - ts.reduceLeft = reduceLeft; - function reduceRight(array, f, initial) { - if (array) { - var pos = array.length - 1; - if (pos >= 0) { - var result = arguments.length <= 2 ? array[pos--] : initial; - while (pos >= 0) { - result = f(result, array[pos--]); - } - return result; - } - } - return initial; - } - ts.reduceRight = reduceRight; - var hasOwnProperty = Object.prototype.hasOwnProperty; - function hasProperty(map, key) { - return hasOwnProperty.call(map, key); - } - ts.hasProperty = hasProperty; - function getProperty(map, key) { - return hasOwnProperty.call(map, key) ? map[key] : undefined; - } - ts.getProperty = getProperty; - function isEmpty(map) { - for (var id in map) { - if (hasProperty(map, id)) { - return false; - } - } - return true; - } - ts.isEmpty = isEmpty; - function clone(object) { - var result = {}; - for (var id in object) { - result[id] = object[id]; - } - return result; - } - ts.clone = clone; - function extend(first, second) { - var result = {}; - for (var id in first) { - result[id] = first[id]; - } - for (var id in second) { - if (!hasProperty(result, id)) { - result[id] = second[id]; - } - } - return result; - } - ts.extend = extend; - function forEachValue(map, callback) { - var result; - for (var id in map) { - if (result = callback(map[id])) - break; - } - return result; - } - ts.forEachValue = forEachValue; - function forEachKey(map, callback) { - var result; - for (var id in map) { - if (result = callback(id)) - break; - } - return result; - } - ts.forEachKey = forEachKey; - function lookUp(map, key) { - return hasProperty(map, key) ? map[key] : undefined; - } - ts.lookUp = lookUp; - function copyMap(source, target) { - for (var p in source) { - target[p] = source[p]; - } - } - ts.copyMap = copyMap; - /** - * Creates a map from the elements of an array. - * - * @param array the array of input elements. - * @param makeKey a function that produces a key for a given element. - * - * This function makes no effort to avoid collisions; if any two elements produce - * the same key with the given 'makeKey' function, then the element with the higher - * index in the array will be the one associated with the produced key. - */ - function arrayToMap(array, makeKey) { - var result = {}; - forEach(array, function (value) { - result[makeKey(value)] = value; - }); - return result; - } - ts.arrayToMap = arrayToMap; - function memoize(callback) { - var value; - return function () { - if (callback) { - value = callback(); - callback = undefined; - } - return value; - }; - } - ts.memoize = memoize; - function formatStringFromArgs(text, args, baseIndex) { - baseIndex = baseIndex || 0; - return text.replace(/{(\d+)}/g, function (match, index) { return args[+index + baseIndex]; }); - } - ts.localizedDiagnosticMessages = undefined; - function getLocaleSpecificMessage(message) { - return ts.localizedDiagnosticMessages && ts.localizedDiagnosticMessages[message] - ? ts.localizedDiagnosticMessages[message] - : message; - } - ts.getLocaleSpecificMessage = getLocaleSpecificMessage; - function createFileDiagnostic(file, start, length, message) { - var end = start + length; - Debug.assert(start >= 0, "start must be non-negative, is " + start); - Debug.assert(length >= 0, "length must be non-negative, is " + length); - if (file) { - Debug.assert(start <= file.text.length, "start must be within the bounds of the file. " + start + " > " + file.text.length); - Debug.assert(end <= file.text.length, "end must be the bounds of the file. " + end + " > " + file.text.length); - } - var text = getLocaleSpecificMessage(message.key); - if (arguments.length > 4) { - text = formatStringFromArgs(text, arguments, 4); - } - return { - file: file, - start: start, - length: length, - messageText: text, - category: message.category, - code: message.code - }; - } - ts.createFileDiagnostic = createFileDiagnostic; - function createCompilerDiagnostic(message) { - var text = getLocaleSpecificMessage(message.key); - if (arguments.length > 1) { - text = formatStringFromArgs(text, arguments, 1); - } - return { - file: undefined, - start: undefined, - length: undefined, - messageText: text, - category: message.category, - code: message.code - }; - } - ts.createCompilerDiagnostic = createCompilerDiagnostic; - function chainDiagnosticMessages(details, message) { - var text = getLocaleSpecificMessage(message.key); - if (arguments.length > 2) { - text = formatStringFromArgs(text, arguments, 2); - } - return { - messageText: text, - category: message.category, - code: message.code, - next: details - }; - } - ts.chainDiagnosticMessages = chainDiagnosticMessages; - function concatenateDiagnosticMessageChains(headChain, tailChain) { - var lastChain = headChain; - while (lastChain.next) { - lastChain = lastChain.next; - } - lastChain.next = tailChain; - return headChain; - } - ts.concatenateDiagnosticMessageChains = concatenateDiagnosticMessageChains; - function compareValues(a, b) { - if (a === b) - return 0 /* EqualTo */; - if (a === undefined) - return -1 /* LessThan */; - if (b === undefined) - return 1 /* GreaterThan */; - return a < b ? -1 /* LessThan */ : 1 /* GreaterThan */; - } - ts.compareValues = compareValues; - function getDiagnosticFileName(diagnostic) { - return diagnostic.file ? diagnostic.file.fileName : undefined; - } - function compareDiagnostics(d1, d2) { - return compareValues(getDiagnosticFileName(d1), getDiagnosticFileName(d2)) || - compareValues(d1.start, d2.start) || - compareValues(d1.length, d2.length) || - compareValues(d1.code, d2.code) || - compareMessageText(d1.messageText, d2.messageText) || - 0 /* EqualTo */; - } - ts.compareDiagnostics = compareDiagnostics; - function compareMessageText(text1, text2) { - while (text1 && text2) { - // We still have both chains. - var string1 = typeof text1 === "string" ? text1 : text1.messageText; - var string2 = typeof text2 === "string" ? text2 : text2.messageText; - var res = compareValues(string1, string2); - if (res) { - return res; - } - text1 = typeof text1 === "string" ? undefined : text1.next; - text2 = typeof text2 === "string" ? undefined : text2.next; - } - if (!text1 && !text2) { - // if the chains are done, then these messages are the same. - return 0 /* EqualTo */; - } - // We still have one chain remaining. The shorter chain should come first. - return text1 ? 1 /* GreaterThan */ : -1 /* LessThan */; - } - function sortAndDeduplicateDiagnostics(diagnostics) { - return deduplicateSortedDiagnostics(diagnostics.sort(compareDiagnostics)); - } - ts.sortAndDeduplicateDiagnostics = sortAndDeduplicateDiagnostics; - function deduplicateSortedDiagnostics(diagnostics) { - if (diagnostics.length < 2) { - return diagnostics; - } - var newDiagnostics = [diagnostics[0]]; - var previousDiagnostic = diagnostics[0]; - for (var i = 1; i < diagnostics.length; i++) { - var currentDiagnostic = diagnostics[i]; - var isDupe = compareDiagnostics(currentDiagnostic, previousDiagnostic) === 0 /* EqualTo */; - if (!isDupe) { - newDiagnostics.push(currentDiagnostic); - previousDiagnostic = currentDiagnostic; - } - } - return newDiagnostics; - } - ts.deduplicateSortedDiagnostics = deduplicateSortedDiagnostics; - function normalizeSlashes(path) { - return path.replace(/\\/g, "/"); - } - ts.normalizeSlashes = normalizeSlashes; - // 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 */) - return 1; - var p1 = path.indexOf("/", 2); - if (p1 < 0) - return 2; - var p2 = path.indexOf("/", p1 + 1); - if (p2 < 0) - return p1 + 1; - return p2 + 1; - } - if (path.charCodeAt(1) === 58 /* colon */) { - if (path.charCodeAt(2) === 47 /* slash */) - return 3; - return 2; - } - // Per RFC 1738 'file' URI schema has the shape file:/// - // if is omitted then it is assumed that host value is 'localhost', - // however slash after the omitted is not removed. - // file:///folder1/file1 - this is a correct URI - // file://folder2/file2 - this is an incorrect URI - if (path.lastIndexOf("file:///", 0) === 0) { - return "file:///".length; - } - var idx = path.indexOf("://"); - if (idx !== -1) { - return idx + "://".length; - } - return 0; - } - ts.getRootLength = getRootLength; - ts.directorySeparator = "/"; - function getNormalizedParts(normalizedSlashedPath, rootLength) { - var parts = normalizedSlashedPath.substr(rootLength).split(ts.directorySeparator); - var normalized = []; - for (var _i = 0; _i < parts.length; _i++) { - var part = parts[_i]; - if (part !== ".") { - if (part === ".." && normalized.length > 0 && lastOrUndefined(normalized) !== "..") { - normalized.pop(); - } - else { - // A part may be an empty string (which is 'falsy') if the path had consecutive slashes, - // e.g. "path//file.ts". Drop these before re-joining the parts. - if (part) { - normalized.push(part); - } - } - } - } - return normalized; - } - function normalizePath(path) { - path = normalizeSlashes(path); - var rootLength = getRootLength(path); - var normalized = getNormalizedParts(path, rootLength); - return path.substr(0, rootLength) + normalized.join(ts.directorySeparator); - } - ts.normalizePath = normalizePath; - function getDirectoryPath(path) { - return path.substr(0, Math.max(getRootLength(path), path.lastIndexOf(ts.directorySeparator))); - } - ts.getDirectoryPath = getDirectoryPath; - function isUrl(path) { - return path && !isRootedDiskPath(path) && path.indexOf("://") !== -1; - } - ts.isUrl = isUrl; - function isRootedDiskPath(path) { - return getRootLength(path) !== 0; - } - ts.isRootedDiskPath = isRootedDiskPath; - function normalizedPathComponents(path, rootLength) { - var normalizedParts = getNormalizedParts(path, rootLength); - return [path.substr(0, rootLength)].concat(normalizedParts); - } - function getNormalizedPathComponents(path, currentDirectory) { - path = normalizeSlashes(path); - var rootLength = getRootLength(path); - if (rootLength === 0) { - // If the path is not rooted it is relative to current directory - path = combinePaths(normalizeSlashes(currentDirectory), path); - rootLength = getRootLength(path); - } - return normalizedPathComponents(path, rootLength); - } - ts.getNormalizedPathComponents = getNormalizedPathComponents; - function getNormalizedAbsolutePath(fileName, currentDirectory) { - return getNormalizedPathFromPathComponents(getNormalizedPathComponents(fileName, currentDirectory)); - } - ts.getNormalizedAbsolutePath = getNormalizedAbsolutePath; - function getNormalizedPathFromPathComponents(pathComponents) { - if (pathComponents && pathComponents.length) { - return pathComponents[0] + pathComponents.slice(1).join(ts.directorySeparator); - } - } - ts.getNormalizedPathFromPathComponents = getNormalizedPathFromPathComponents; - function getNormalizedPathComponentsOfUrl(url) { - // Get root length of http://www.website.com/folder1/foler2/ - // In this example the root is: http://www.website.com/ - // normalized path components should be ["http://www.website.com/", "folder1", "folder2"] - var urlLength = url.length; - // Initial root length is http:// part - var rootLength = url.indexOf("://") + "://".length; - while (rootLength < urlLength) { - // Consume all immediate slashes in the protocol - // eg.initial rootlength is just file:// but it needs to consume another "/" in file:/// - if (url.charCodeAt(rootLength) === 47 /* slash */) { - rootLength++; - } - else { - // non slash character means we continue proceeding to next component of root search - break; - } - } - // there are no parts after http:// just return current string as the pathComponent - if (rootLength === urlLength) { - return [url]; - } - // Find the index of "/" after website.com so the root can be http://www.website.com/ (from existing http://) - var indexOfNextSlash = url.indexOf(ts.directorySeparator, rootLength); - if (indexOfNextSlash !== -1) { - // Found the "/" after the website.com so the root is length of http://www.website.com/ - // and get components afetr the root normally like any other folder components - rootLength = indexOfNextSlash + 1; - return normalizedPathComponents(url, rootLength); - } - else { - // Can't find the host assume the rest of the string as component - // but make sure we append "/" to it as root is not joined using "/" - // eg. if url passed in was http://website.com we want to use root as [http://website.com/] - // so that other path manipulations will be correct and it can be merged with relative paths correctly - return [url + ts.directorySeparator]; - } - } - function getNormalizedPathOrUrlComponents(pathOrUrl, currentDirectory) { - if (isUrl(pathOrUrl)) { - return getNormalizedPathComponentsOfUrl(pathOrUrl); - } - else { - return getNormalizedPathComponents(pathOrUrl, currentDirectory); - } - } - function getRelativePathToDirectoryOrUrl(directoryPathOrUrl, relativeOrAbsolutePath, currentDirectory, getCanonicalFileName, isAbsolutePathAnUrl) { - var pathComponents = getNormalizedPathOrUrlComponents(relativeOrAbsolutePath, currentDirectory); - var directoryComponents = getNormalizedPathOrUrlComponents(directoryPathOrUrl, currentDirectory); - if (directoryComponents.length > 1 && lastOrUndefined(directoryComponents) === "") { - // If the directory path given was of type test/cases/ then we really need components of directory to be only till its name - // that is ["test", "cases", ""] needs to be actually ["test", "cases"] - directoryComponents.length--; - } - // Find the component that differs - for (var joinStartIndex = 0; joinStartIndex < pathComponents.length && joinStartIndex < directoryComponents.length; joinStartIndex++) { - if (getCanonicalFileName(directoryComponents[joinStartIndex]) !== getCanonicalFileName(pathComponents[joinStartIndex])) { - break; - } - } - // Get the relative path - if (joinStartIndex) { - var relativePath = ""; - var relativePathComponents = pathComponents.slice(joinStartIndex, pathComponents.length); - for (; joinStartIndex < directoryComponents.length; joinStartIndex++) { - if (directoryComponents[joinStartIndex] !== "") { - relativePath = relativePath + ".." + ts.directorySeparator; - } - } - return relativePath + relativePathComponents.join(ts.directorySeparator); - } - // Cant find the relative path, get the absolute path - var absolutePath = getNormalizedPathFromPathComponents(pathComponents); - if (isAbsolutePathAnUrl && isRootedDiskPath(absolutePath)) { - absolutePath = "file:///" + absolutePath; - } - return absolutePath; - } - ts.getRelativePathToDirectoryOrUrl = getRelativePathToDirectoryOrUrl; - function getBaseFileName(path) { - if (!path) { - return undefined; - } - var i = path.lastIndexOf(ts.directorySeparator); - return i < 0 ? path : path.substring(i + 1); - } - ts.getBaseFileName = getBaseFileName; - function combinePaths(path1, path2) { - if (!(path1 && path1.length)) - return path2; - if (!(path2 && path2.length)) - return path1; - if (getRootLength(path2) !== 0) - return path2; - if (path1.charAt(path1.length - 1) === ts.directorySeparator) - return path1 + path2; - return path1 + ts.directorySeparator + path2; - } - ts.combinePaths = combinePaths; - function fileExtensionIs(path, extension) { - var pathLen = path.length; - var extLen = extension.length; - return pathLen > extLen && path.substr(pathLen - extLen, extLen) === extension; - } - ts.fileExtensionIs = fileExtensionIs; - /** - * List of supported extensions in order of file resolution precedence. - */ - ts.supportedExtensions = [".ts", ".tsx", ".d.ts"]; - /** - * List of extensions that will be used to look for external modules. - * This list is kept separate from supportedExtensions to for cases when we'll allow to include .js files in compilation, - * but still would like to load only TypeScript files as modules - */ - ts.moduleFileExtensions = ts.supportedExtensions; - function isSupportedSourceFileName(fileName) { - if (!fileName) { - return false; - } - for (var _i = 0; _i < ts.supportedExtensions.length; _i++) { - var extension = ts.supportedExtensions[_i]; - if (fileExtensionIs(fileName, extension)) { - return true; - } - } - return false; - } - ts.isSupportedSourceFileName = isSupportedSourceFileName; - var extensionsToRemove = [".d.ts", ".ts", ".js", ".tsx", ".jsx"]; - function removeFileExtension(path) { - for (var _i = 0; _i < extensionsToRemove.length; _i++) { - var ext = extensionsToRemove[_i]; - if (fileExtensionIs(path, ext)) { - return path.substr(0, path.length - ext.length); - } - } - return path; - } - ts.removeFileExtension = removeFileExtension; - var backslashOrDoubleQuote = /[\"\\]/g; - var escapedCharsRegExp = /[\u0000-\u001f\t\v\f\b\r\n\u2028\u2029\u0085]/g; - var escapedCharsMap = { - "\0": "\\0", - "\t": "\\t", - "\v": "\\v", - "\f": "\\f", - "\b": "\\b", - "\r": "\\r", - "\n": "\\n", - "\\": "\\\\", - "\"": "\\\"", - "\u2028": "\\u2028", - "\u2029": "\\u2029", - "\u0085": "\\u0085" // nextLine - }; - function Symbol(flags, name) { - this.flags = flags; - this.name = name; - this.declarations = undefined; - } - function Type(checker, flags) { - this.flags = flags; - } - function Signature(checker) { - } - ts.objectAllocator = { - getNodeConstructor: function (kind) { - function Node(pos, end) { - this.pos = pos; - this.end = end; - this.flags = 0 /* None */; - this.parent = undefined; - } - Node.prototype = { kind: kind }; - return Node; - }, - getSymbolConstructor: function () { return Symbol; }, - 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) { - var currentAssertionLevel = 0 /* None */; - function shouldAssert(level) { - return currentAssertionLevel >= level; - } - Debug.shouldAssert = shouldAssert; - function assert(expression, message, verboseDebugInfo) { - if (!expression) { - var verboseDebugString = ""; - if (verboseDebugInfo) { - verboseDebugString = "\r\nVerbose Debug Information: " + verboseDebugInfo(); - } - throw new Error("Debug Failure. False expression: " + (message || "") + verboseDebugString); - } - } - Debug.assert = assert; - function fail(message) { - Debug.assert(false, message); - } - Debug.fail = fail; - })(Debug = ts.Debug || (ts.Debug = {})); - function copyListRemovingItem(item, list) { - var copiedList = []; - for (var _i = 0; _i < list.length; _i++) { - var e = list[_i]; - if (e !== item) { - copiedList.push(e); - } - } - return copiedList; - } - ts.copyListRemovingItem = copyListRemovingItem; -})(ts || (ts = {})); -/// -var ts; -(function (ts) { - ts.sys = (function () { - function getWScriptSystem() { - var fso = new ActiveXObject("Scripting.FileSystemObject"); - var fileStream = new ActiveXObject("ADODB.Stream"); - fileStream.Type = 2 /*text*/; - var binaryStream = new ActiveXObject("ADODB.Stream"); - binaryStream.Type = 1 /*binary*/; - var args = []; - for (var i = 0; i < WScript.Arguments.length; i++) { - args[i] = WScript.Arguments.Item(i); - } - function readFile(fileName, encoding) { - if (!fso.FileExists(fileName)) { - return undefined; - } - fileStream.Open(); - try { - if (encoding) { - fileStream.Charset = encoding; - fileStream.LoadFromFile(fileName); - } - else { - // Load file and read the first two bytes into a string with no interpretation - fileStream.Charset = "x-ansi"; - fileStream.LoadFromFile(fileName); - var bom = fileStream.ReadText(2) || ""; - // Position must be at 0 before encoding can be changed - fileStream.Position = 0; - // [0xFF,0xFE] and [0xFE,0xFF] mean utf-16 (little or big endian), otherwise default to utf-8 - fileStream.Charset = bom.length >= 2 && (bom.charCodeAt(0) === 0xFF && bom.charCodeAt(1) === 0xFE || bom.charCodeAt(0) === 0xFE && bom.charCodeAt(1) === 0xFF) ? "unicode" : "utf-8"; - } - // ReadText method always strips byte order mark from resulting string - return fileStream.ReadText(); - } - catch (e) { - throw e; - } - finally { - fileStream.Close(); - } - } - function writeFile(fileName, data, writeByteOrderMark) { - fileStream.Open(); - binaryStream.Open(); - try { - // Write characters in UTF-8 encoding - fileStream.Charset = "utf-8"; - fileStream.WriteText(data); - // If we don't want the BOM, then skip it by setting the starting location to 3 (size of BOM). - // If not, start from position 0, as the BOM will be added automatically when charset==utf8. - if (writeByteOrderMark) { - fileStream.Position = 0; - } - else { - fileStream.Position = 3; - } - fileStream.CopyTo(binaryStream); - binaryStream.SaveToFile(fileName, 2 /*overwrite*/); - } - finally { - binaryStream.Close(); - fileStream.Close(); - } - } - function getCanonicalPath(path) { - return path.toLowerCase(); - } - function getNames(collection) { - var result = []; - for (var e = new Enumerator(collection); !e.atEnd(); e.moveNext()) { - result.push(e.item().Name); - } - return result.sort(); - } - function readDirectory(path, extension, exclude) { - var result = []; - exclude = ts.map(exclude, function (s) { return getCanonicalPath(ts.combinePaths(path, s)); }); - visitDirectory(path); - return result; - function visitDirectory(path) { - var folder = fso.GetFolder(path || "."); - var files = getNames(folder.files); - for (var _i = 0; _i < files.length; _i++) { - var current = files[_i]; - var name_1 = ts.combinePaths(path, current); - if ((!extension || ts.fileExtensionIs(name_1, extension)) && !ts.contains(exclude, getCanonicalPath(name_1))) { - result.push(name_1); - } - } - var subfolders = getNames(folder.subfolders); - for (var _a = 0; _a < subfolders.length; _a++) { - var current = subfolders[_a]; - var name_2 = ts.combinePaths(path, current); - if (!ts.contains(exclude, getCanonicalPath(name_2))) { - visitDirectory(name_2); - } - } - } - } - return { - args: args, - newLine: "\r\n", - useCaseSensitiveFileNames: false, - write: function (s) { - WScript.StdOut.Write(s); - }, - readFile: readFile, - writeFile: writeFile, - resolvePath: function (path) { - return fso.GetAbsolutePathName(path); - }, - fileExists: function (path) { - return fso.FileExists(path); - }, - directoryExists: function (path) { - return fso.FolderExists(path); - }, - createDirectory: function (directoryName) { - if (!this.directoryExists(directoryName)) { - fso.CreateFolder(directoryName); - } - }, - getExecutingFilePath: function () { - return WScript.ScriptFullName; - }, - getCurrentDirectory: function () { - return new ActiveXObject("WScript.Shell").CurrentDirectory; - }, - readDirectory: readDirectory, - exit: function (exitCode) { - try { - WScript.Quit(exitCode); - } - catch (e) { - } - } - }; - } - function getNodeSystem() { - var _fs = require("fs"); - var _path = require("path"); - var _os = require("os"); - // average async stat takes about 30 microseconds - // set chunk size to do 30 files in < 1 millisecond - function createWatchedFileSet(interval, chunkSize) { - if (interval === void 0) { interval = 2500; } - if (chunkSize === void 0) { chunkSize = 30; } - var watchedFiles = []; - var nextFileToCheck = 0; - var watchTimer; - function getModifiedTime(fileName) { - return _fs.statSync(fileName).mtime; - } - function poll(checkedIndex) { - var watchedFile = watchedFiles[checkedIndex]; - if (!watchedFile) { - return; - } - _fs.stat(watchedFile.fileName, function (err, stats) { - if (err) { - watchedFile.callback(watchedFile.fileName); - } - else if (watchedFile.mtime.getTime() !== stats.mtime.getTime()) { - watchedFile.mtime = getModifiedTime(watchedFile.fileName); - watchedFile.callback(watchedFile.fileName, watchedFile.mtime.getTime() === 0); - } - }); - } - // this implementation uses polling and - // stat due to inconsistencies of fs.watch - // and efficiency of stat on modern filesystems - function startWatchTimer() { - watchTimer = setInterval(function () { - var count = 0; - var nextToCheck = nextFileToCheck; - var firstCheck = -1; - while ((count < chunkSize) && (nextToCheck !== firstCheck)) { - poll(nextToCheck); - if (firstCheck < 0) { - firstCheck = nextToCheck; - } - nextToCheck++; - if (nextToCheck === watchedFiles.length) { - nextToCheck = 0; - } - count++; - } - nextFileToCheck = nextToCheck; - }, interval); - } - function addFile(fileName, callback) { - var file = { - fileName: fileName, - callback: callback, - mtime: getModifiedTime(fileName) - }; - watchedFiles.push(file); - if (watchedFiles.length === 1) { - startWatchTimer(); - } - return file; - } - function removeFile(file) { - watchedFiles = ts.copyListRemovingItem(file, watchedFiles); - } - return { - getModifiedTime: getModifiedTime, - poll: poll, - startWatchTimer: startWatchTimer, - addFile: addFile, - removeFile: removeFile - }; - } - // REVIEW: for now this implementation uses polling. - // The advantage of polling is that it works reliably - // on all os and with network mounted files. - // For 90 referenced files, the average time to detect - // changes is 2*msInterval (by default 5 seconds). - // The overhead of this is .04 percent (1/2500) with - // average pause of < 1 millisecond (and max - // pause less than 1.5 milliseconds); question is - // do we anticipate reference sets in the 100s and - // do we care about waiting 10-20 seconds to detect - // changes for large reference sets? If so, do we want - // to increase the chunk size or decrease the interval - // time dynamically to match the large reference set? - var watchedFileSet = createWatchedFileSet(); - function isNode4OrLater() { - return parseInt(process.version.charAt(1)) >= 4; - } - 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"; - function readFile(fileName, encoding) { - if (!_fs.existsSync(fileName)) { - return undefined; - } - var buffer = _fs.readFileSync(fileName); - var len = buffer.length; - if (len >= 2 && buffer[0] === 0xFE && buffer[1] === 0xFF) { - // Big endian UTF-16 byte order mark detected. Since big endian is not supported by node.js, - // flip all byte pairs and treat as little endian. - len &= ~1; - for (var i = 0; i < len; i += 2) { - var temp = buffer[i]; - buffer[i] = buffer[i + 1]; - buffer[i + 1] = temp; - } - return buffer.toString("utf16le", 2); - } - if (len >= 2 && buffer[0] === 0xFF && buffer[1] === 0xFE) { - // Little endian UTF-16 byte order mark detected - return buffer.toString("utf16le", 2); - } - if (len >= 3 && buffer[0] === 0xEF && buffer[1] === 0xBB && buffer[2] === 0xBF) { - // UTF-8 byte order mark detected - return buffer.toString("utf8", 3); - } - // Default is UTF-8 with no byte order mark - return buffer.toString("utf8"); - } - function writeFile(fileName, data, writeByteOrderMark) { - // If a BOM is required, emit one - if (writeByteOrderMark) { - data = "\uFEFF" + data; - } - _fs.writeFileSync(fileName, data, "utf8"); - } - function getCanonicalPath(path) { - return useCaseSensitiveFileNames ? path.toLowerCase() : path; - } - function readDirectory(path, extension, exclude) { - var result = []; - exclude = ts.map(exclude, function (s) { return getCanonicalPath(ts.combinePaths(path, s)); }); - visitDirectory(path); - return result; - function visitDirectory(path) { - var files = _fs.readdirSync(path || ".").sort(); - var directories = []; - for (var _i = 0; _i < files.length; _i++) { - var current = files[_i]; - var name_3 = ts.combinePaths(path, current); - if (!ts.contains(exclude, getCanonicalPath(name_3))) { - var stat = _fs.statSync(name_3); - if (stat.isFile()) { - if (!extension || ts.fileExtensionIs(name_3, extension)) { - result.push(name_3); - } - } - else if (stat.isDirectory()) { - directories.push(name_3); - } - } - } - for (var _a = 0; _a < directories.length; _a++) { - var current = directories[_a]; - visitDirectory(current); - } - } - } - return { - args: process.argv.slice(2), - newLine: _os.EOL, - useCaseSensitiveFileNames: useCaseSensitiveFileNames, - write: function (s) { - var buffer = new Buffer(s, "utf8"); - var offset = 0; - var toWrite = buffer.length; - var written = 0; - // 1 is a standard descriptor for stdout - while ((written = _fs.writeSync(1, buffer, offset, toWrite)) < toWrite) { - offset += written; - toWrite -= written; - } - }, - readFile: readFile, - writeFile: writeFile, - watchFile: function (fileName, callback) { - // Node 4.0 stablized the `fs.watch` function on Windows which avoids polling - // and is more efficient than `fs.watchFile` (ref: https://github.com/nodejs/node/pull/2649 - // and https://github.com/Microsoft/TypeScript/issues/4643), therefore - // if the current node.js version is newer than 4, use `fs.watch` instead. - if (isNode4OrLater()) { - // Note: in node the callback of fs.watch is given only the relative file name as a parameter - return _fs.watch(fileName, function (eventName, relativeFileName) { return callback(fileName); }); - } - var watchedFile = watchedFileSet.addFile(fileName, callback); - return { - close: function () { return watchedFileSet.removeFile(watchedFile); } - }; - }, - watchDirectory: function (path, callback, recursive) { - // 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) - return _fs.watch(path, { persistent: true, recursive: !!recursive }, function (eventName, relativeFileName) { - // In watchDirectory we only care about adding and removing files (when event name is - // "rename"); changes made within files are handled by corresponding fileWatchers (when - // event name is "change") - if (eventName === "rename") { - // When deleting a file, the passed baseFileName is null - callback(!relativeFileName ? relativeFileName : ts.normalizePath(ts.combinePaths(path, relativeFileName))); - } - ; - }); - }, - resolvePath: function (path) { - return _path.resolve(path); - }, - fileExists: function (path) { - return _fs.existsSync(path); - }, - directoryExists: function (path) { - return _fs.existsSync(path) && _fs.statSync(path).isDirectory(); - }, - createDirectory: function (directoryName) { - if (!this.directoryExists(directoryName)) { - _fs.mkdirSync(directoryName); - } - }, - getExecutingFilePath: function () { - return __filename; - }, - getCurrentDirectory: function () { - return process.cwd(); - }, - readDirectory: readDirectory, - getMemoryUsage: function () { - if (global.gc) { - global.gc(); - } - return process.memoryUsage().heapUsed; - }, - exit: function (exitCode) { - process.exit(exitCode); - } - }; - } - if (typeof WScript !== "undefined" && typeof ActiveXObject === "function") { - return 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(); - } - else { - return undefined; // Unsupported host - } - })(); -})(ts || (ts = {})); -// -/// -/* @internal */ -var ts; -(function (ts) { - ts.Diagnostics = { - Unterminated_string_literal: { code: 1002, category: ts.DiagnosticCategory.Error, key: "Unterminated string literal." }, - Identifier_expected: { code: 1003, category: ts.DiagnosticCategory.Error, key: "Identifier expected." }, - _0_expected: { code: 1005, category: ts.DiagnosticCategory.Error, key: "'{0}' expected." }, - A_file_cannot_have_a_reference_to_itself: { code: 1006, category: ts.DiagnosticCategory.Error, key: "A file cannot have a reference to itself." }, - Trailing_comma_not_allowed: { code: 1009, category: ts.DiagnosticCategory.Error, key: "Trailing comma not allowed." }, - Asterisk_Slash_expected: { code: 1010, category: ts.DiagnosticCategory.Error, key: "'*/' expected." }, - Unexpected_token: { code: 1012, category: ts.DiagnosticCategory.Error, key: "Unexpected token." }, - A_rest_parameter_must_be_last_in_a_parameter_list: { code: 1014, category: ts.DiagnosticCategory.Error, key: "A rest parameter must be last in a parameter list." }, - Parameter_cannot_have_question_mark_and_initializer: { code: 1015, category: ts.DiagnosticCategory.Error, key: "Parameter cannot have question mark and initializer." }, - A_required_parameter_cannot_follow_an_optional_parameter: { code: 1016, category: ts.DiagnosticCategory.Error, key: "A required parameter cannot follow an optional parameter." }, - An_index_signature_cannot_have_a_rest_parameter: { code: 1017, category: ts.DiagnosticCategory.Error, key: "An index signature cannot have a rest parameter." }, - An_index_signature_parameter_cannot_have_an_accessibility_modifier: { code: 1018, category: ts.DiagnosticCategory.Error, key: "An index signature parameter cannot have an accessibility modifier." }, - An_index_signature_parameter_cannot_have_a_question_mark: { code: 1019, category: ts.DiagnosticCategory.Error, key: "An index signature parameter cannot have a question mark." }, - An_index_signature_parameter_cannot_have_an_initializer: { code: 1020, category: ts.DiagnosticCategory.Error, key: "An index signature parameter cannot have an initializer." }, - An_index_signature_must_have_a_type_annotation: { code: 1021, category: ts.DiagnosticCategory.Error, key: "An index signature must have a type annotation." }, - An_index_signature_parameter_must_have_a_type_annotation: { code: 1022, category: ts.DiagnosticCategory.Error, key: "An index signature parameter must have a type annotation." }, - An_index_signature_parameter_type_must_be_string_or_number: { code: 1023, category: ts.DiagnosticCategory.Error, key: "An index signature parameter type must be 'string' or 'number'." }, - Accessibility_modifier_already_seen: { code: 1028, category: ts.DiagnosticCategory.Error, key: "Accessibility modifier already seen." }, - _0_modifier_must_precede_1_modifier: { code: 1029, category: ts.DiagnosticCategory.Error, key: "'{0}' modifier must precede '{1}' modifier." }, - _0_modifier_already_seen: { code: 1030, category: ts.DiagnosticCategory.Error, key: "'{0}' modifier already seen." }, - _0_modifier_cannot_appear_on_a_class_element: { code: 1031, category: ts.DiagnosticCategory.Error, key: "'{0}' modifier cannot appear on a class element." }, - super_must_be_followed_by_an_argument_list_or_member_access: { code: 1034, category: ts.DiagnosticCategory.Error, key: "'super' must be followed by an argument list or member access." }, - Only_ambient_modules_can_use_quoted_names: { code: 1035, category: ts.DiagnosticCategory.Error, key: "Only ambient modules can use quoted names." }, - Statements_are_not_allowed_in_ambient_contexts: { code: 1036, category: ts.DiagnosticCategory.Error, key: "Statements are not allowed in ambient contexts." }, - A_declare_modifier_cannot_be_used_in_an_already_ambient_context: { code: 1038, category: ts.DiagnosticCategory.Error, key: "A 'declare' modifier cannot be used in an already ambient context." }, - Initializers_are_not_allowed_in_ambient_contexts: { code: 1039, category: ts.DiagnosticCategory.Error, key: "Initializers are not allowed in ambient contexts." }, - _0_modifier_cannot_be_used_in_an_ambient_context: { code: 1040, category: ts.DiagnosticCategory.Error, key: "'{0}' modifier cannot be used in an ambient context." }, - _0_modifier_cannot_be_used_with_a_class_declaration: { code: 1041, category: ts.DiagnosticCategory.Error, key: "'{0}' modifier cannot be used with a class declaration." }, - _0_modifier_cannot_be_used_here: { code: 1042, category: ts.DiagnosticCategory.Error, key: "'{0}' modifier cannot be used here." }, - _0_modifier_cannot_appear_on_a_data_property: { code: 1043, category: ts.DiagnosticCategory.Error, key: "'{0}' modifier cannot appear on a data property." }, - _0_modifier_cannot_appear_on_a_module_element: { code: 1044, category: ts.DiagnosticCategory.Error, key: "'{0}' modifier cannot appear on a module element." }, - A_0_modifier_cannot_be_used_with_an_interface_declaration: { code: 1045, category: ts.DiagnosticCategory.Error, key: "A '{0}' modifier cannot be used with an interface declaration." }, - A_declare_modifier_is_required_for_a_top_level_declaration_in_a_d_ts_file: { code: 1046, category: ts.DiagnosticCategory.Error, key: "A 'declare' modifier is required for a top level declaration in a .d.ts file." }, - A_rest_parameter_cannot_be_optional: { code: 1047, category: ts.DiagnosticCategory.Error, key: "A rest parameter cannot be optional." }, - A_rest_parameter_cannot_have_an_initializer: { code: 1048, category: ts.DiagnosticCategory.Error, key: "A rest parameter cannot have an initializer." }, - A_set_accessor_must_have_exactly_one_parameter: { code: 1049, category: ts.DiagnosticCategory.Error, key: "A 'set' accessor must have exactly one parameter." }, - A_set_accessor_cannot_have_an_optional_parameter: { code: 1051, category: ts.DiagnosticCategory.Error, key: "A 'set' accessor cannot have an optional parameter." }, - A_set_accessor_parameter_cannot_have_an_initializer: { code: 1052, category: ts.DiagnosticCategory.Error, key: "A 'set' accessor parameter cannot have an initializer." }, - A_set_accessor_cannot_have_rest_parameter: { code: 1053, category: ts.DiagnosticCategory.Error, key: "A 'set' accessor cannot have rest parameter." }, - A_get_accessor_cannot_have_parameters: { code: 1054, category: ts.DiagnosticCategory.Error, key: "A 'get' accessor cannot have parameters." }, - Type_0_is_not_a_valid_async_function_return_type: { code: 1055, category: ts.DiagnosticCategory.Error, key: "Type '{0}' is not a valid async function return type." }, - Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher: { code: 1056, category: ts.DiagnosticCategory.Error, key: "Accessors are only available when targeting ECMAScript 5 and higher." }, - An_async_function_or_method_must_have_a_valid_awaitable_return_type: { code: 1057, category: ts.DiagnosticCategory.Error, key: "An async function or method must have a valid awaitable return type." }, - Operand_for_await_does_not_have_a_valid_callable_then_member: { code: 1058, category: ts.DiagnosticCategory.Error, key: "Operand for 'await' does not have a valid callable 'then' member." }, - Return_expression_in_async_function_does_not_have_a_valid_callable_then_member: { code: 1059, category: ts.DiagnosticCategory.Error, key: "Return expression in async function does not have a valid callable 'then' member." }, - Expression_body_for_async_arrow_function_does_not_have_a_valid_callable_then_member: { code: 1060, category: ts.DiagnosticCategory.Error, key: "Expression body for async arrow function does not have a valid callable 'then' member." }, - Enum_member_must_have_initializer: { code: 1061, category: ts.DiagnosticCategory.Error, key: "Enum member must have initializer." }, - _0_is_referenced_directly_or_indirectly_in_the_fulfillment_callback_of_its_own_then_method: { code: 1062, category: ts.DiagnosticCategory.Error, key: "{0} is referenced directly or indirectly in the fulfillment callback of its own 'then' method." }, - An_export_assignment_cannot_be_used_in_a_namespace: { code: 1063, category: ts.DiagnosticCategory.Error, key: "An export assignment cannot be used in a namespace." }, - In_ambient_enum_declarations_member_initializer_must_be_constant_expression: { code: 1066, category: ts.DiagnosticCategory.Error, key: "In ambient enum declarations member initializer must be constant expression." }, - Unexpected_token_A_constructor_method_accessor_or_property_was_expected: { code: 1068, category: ts.DiagnosticCategory.Error, key: "Unexpected token. A constructor, method, accessor, or property was expected." }, - A_0_modifier_cannot_be_used_with_an_import_declaration: { code: 1079, category: ts.DiagnosticCategory.Error, key: "A '{0}' modifier cannot be used with an import declaration." }, - Invalid_reference_directive_syntax: { code: 1084, category: ts.DiagnosticCategory.Error, key: "Invalid 'reference' directive syntax." }, - Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher: { code: 1085, category: ts.DiagnosticCategory.Error, key: "Octal literals are not available when targeting ECMAScript 5 and higher." }, - An_accessor_cannot_be_declared_in_an_ambient_context: { code: 1086, category: ts.DiagnosticCategory.Error, key: "An accessor cannot be declared in an ambient context." }, - _0_modifier_cannot_appear_on_a_constructor_declaration: { code: 1089, category: ts.DiagnosticCategory.Error, key: "'{0}' modifier cannot appear on a constructor declaration." }, - _0_modifier_cannot_appear_on_a_parameter: { code: 1090, category: ts.DiagnosticCategory.Error, key: "'{0}' modifier cannot appear on a parameter." }, - Only_a_single_variable_declaration_is_allowed_in_a_for_in_statement: { code: 1091, category: ts.DiagnosticCategory.Error, key: "Only a single variable declaration is allowed in a 'for...in' statement." }, - Type_parameters_cannot_appear_on_a_constructor_declaration: { code: 1092, category: ts.DiagnosticCategory.Error, key: "Type parameters cannot appear on a constructor declaration." }, - Type_annotation_cannot_appear_on_a_constructor_declaration: { code: 1093, category: ts.DiagnosticCategory.Error, key: "Type annotation cannot appear on a constructor declaration." }, - An_accessor_cannot_have_type_parameters: { code: 1094, category: ts.DiagnosticCategory.Error, key: "An accessor cannot have type parameters." }, - A_set_accessor_cannot_have_a_return_type_annotation: { code: 1095, category: ts.DiagnosticCategory.Error, key: "A 'set' accessor cannot have a return type annotation." }, - An_index_signature_must_have_exactly_one_parameter: { code: 1096, category: ts.DiagnosticCategory.Error, key: "An index signature must have exactly one parameter." }, - _0_list_cannot_be_empty: { code: 1097, category: ts.DiagnosticCategory.Error, key: "'{0}' list cannot be empty." }, - Type_parameter_list_cannot_be_empty: { code: 1098, category: ts.DiagnosticCategory.Error, key: "Type parameter list cannot be empty." }, - Type_argument_list_cannot_be_empty: { code: 1099, category: ts.DiagnosticCategory.Error, key: "Type argument list cannot be empty." }, - Invalid_use_of_0_in_strict_mode: { code: 1100, category: ts.DiagnosticCategory.Error, key: "Invalid use of '{0}' in strict mode." }, - with_statements_are_not_allowed_in_strict_mode: { code: 1101, category: ts.DiagnosticCategory.Error, key: "'with' statements are not allowed in strict mode." }, - delete_cannot_be_called_on_an_identifier_in_strict_mode: { code: 1102, category: ts.DiagnosticCategory.Error, key: "'delete' cannot be called on an identifier in strict mode." }, - A_continue_statement_can_only_be_used_within_an_enclosing_iteration_statement: { code: 1104, category: ts.DiagnosticCategory.Error, key: "A 'continue' statement can only be used within an enclosing iteration statement." }, - A_break_statement_can_only_be_used_within_an_enclosing_iteration_or_switch_statement: { code: 1105, category: ts.DiagnosticCategory.Error, key: "A 'break' statement can only be used within an enclosing iteration or switch statement." }, - Jump_target_cannot_cross_function_boundary: { code: 1107, category: ts.DiagnosticCategory.Error, key: "Jump target cannot cross function boundary." }, - A_return_statement_can_only_be_used_within_a_function_body: { code: 1108, category: ts.DiagnosticCategory.Error, key: "A 'return' statement can only be used within a function body." }, - Expression_expected: { code: 1109, category: ts.DiagnosticCategory.Error, key: "Expression expected." }, - Type_expected: { code: 1110, category: ts.DiagnosticCategory.Error, key: "Type expected." }, - A_class_member_cannot_be_declared_optional: { code: 1112, category: ts.DiagnosticCategory.Error, key: "A class member cannot be declared optional." }, - A_default_clause_cannot_appear_more_than_once_in_a_switch_statement: { code: 1113, category: ts.DiagnosticCategory.Error, key: "A 'default' clause cannot appear more than once in a 'switch' statement." }, - Duplicate_label_0: { code: 1114, category: ts.DiagnosticCategory.Error, key: "Duplicate label '{0}'" }, - A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement: { code: 1115, category: ts.DiagnosticCategory.Error, key: "A 'continue' statement can only jump to a label of an enclosing iteration statement." }, - A_break_statement_can_only_jump_to_a_label_of_an_enclosing_statement: { code: 1116, category: ts.DiagnosticCategory.Error, key: "A 'break' statement can only jump to a label of an enclosing statement." }, - An_object_literal_cannot_have_multiple_properties_with_the_same_name_in_strict_mode: { code: 1117, category: ts.DiagnosticCategory.Error, key: "An object literal cannot have multiple properties with the same name in strict mode." }, - An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name: { code: 1118, category: ts.DiagnosticCategory.Error, key: "An object literal cannot have multiple get/set accessors with the same name." }, - An_object_literal_cannot_have_property_and_accessor_with_the_same_name: { code: 1119, category: ts.DiagnosticCategory.Error, key: "An object literal cannot have property and accessor with the same name." }, - An_export_assignment_cannot_have_modifiers: { code: 1120, category: ts.DiagnosticCategory.Error, key: "An export assignment cannot have modifiers." }, - Octal_literals_are_not_allowed_in_strict_mode: { code: 1121, category: ts.DiagnosticCategory.Error, key: "Octal literals are not allowed in strict mode." }, - A_tuple_type_element_list_cannot_be_empty: { code: 1122, category: ts.DiagnosticCategory.Error, key: "A tuple type element list cannot be empty." }, - Variable_declaration_list_cannot_be_empty: { code: 1123, category: ts.DiagnosticCategory.Error, key: "Variable declaration list cannot be empty." }, - Digit_expected: { code: 1124, category: ts.DiagnosticCategory.Error, key: "Digit expected." }, - Hexadecimal_digit_expected: { code: 1125, category: ts.DiagnosticCategory.Error, key: "Hexadecimal digit expected." }, - Unexpected_end_of_text: { code: 1126, category: ts.DiagnosticCategory.Error, key: "Unexpected end of text." }, - Invalid_character: { code: 1127, category: ts.DiagnosticCategory.Error, key: "Invalid character." }, - Declaration_or_statement_expected: { code: 1128, category: ts.DiagnosticCategory.Error, key: "Declaration or statement expected." }, - Statement_expected: { code: 1129, category: ts.DiagnosticCategory.Error, key: "Statement expected." }, - case_or_default_expected: { code: 1130, category: ts.DiagnosticCategory.Error, key: "'case' or 'default' expected." }, - Property_or_signature_expected: { code: 1131, category: ts.DiagnosticCategory.Error, key: "Property or signature expected." }, - Enum_member_expected: { code: 1132, category: ts.DiagnosticCategory.Error, key: "Enum member expected." }, - Variable_declaration_expected: { code: 1134, category: ts.DiagnosticCategory.Error, key: "Variable declaration expected." }, - Argument_expression_expected: { code: 1135, category: ts.DiagnosticCategory.Error, key: "Argument expression expected." }, - Property_assignment_expected: { code: 1136, category: ts.DiagnosticCategory.Error, key: "Property assignment expected." }, - Expression_or_comma_expected: { code: 1137, category: ts.DiagnosticCategory.Error, key: "Expression or comma expected." }, - Parameter_declaration_expected: { code: 1138, category: ts.DiagnosticCategory.Error, key: "Parameter declaration expected." }, - Type_parameter_declaration_expected: { code: 1139, category: ts.DiagnosticCategory.Error, key: "Type parameter declaration expected." }, - Type_argument_expected: { code: 1140, category: ts.DiagnosticCategory.Error, key: "Type argument expected." }, - String_literal_expected: { code: 1141, category: ts.DiagnosticCategory.Error, key: "String literal expected." }, - Line_break_not_permitted_here: { code: 1142, category: ts.DiagnosticCategory.Error, key: "Line break not permitted here." }, - or_expected: { code: 1144, category: ts.DiagnosticCategory.Error, key: "'{' or ';' expected." }, - Modifiers_not_permitted_on_index_signature_members: { code: 1145, category: ts.DiagnosticCategory.Error, key: "Modifiers not permitted on index signature members." }, - Declaration_expected: { code: 1146, category: ts.DiagnosticCategory.Error, key: "Declaration expected." }, - Import_declarations_in_a_namespace_cannot_reference_a_module: { code: 1147, category: ts.DiagnosticCategory.Error, key: "Import declarations in a namespace cannot reference a module." }, - Cannot_compile_modules_unless_the_module_flag_is_provided: { code: 1148, category: ts.DiagnosticCategory.Error, key: "Cannot compile modules unless the '--module' flag is provided." }, - File_name_0_differs_from_already_included_file_name_1_only_in_casing: { code: 1149, category: ts.DiagnosticCategory.Error, key: "File name '{0}' differs from already included file name '{1}' only in casing" }, - new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead: { code: 1150, category: ts.DiagnosticCategory.Error, key: "'new T[]' cannot be used to create an array. Use 'new Array()' instead." }, - const_declarations_must_be_initialized: { code: 1155, category: ts.DiagnosticCategory.Error, key: "'const' declarations must be initialized" }, - const_declarations_can_only_be_declared_inside_a_block: { code: 1156, category: ts.DiagnosticCategory.Error, key: "'const' declarations can only be declared inside a block." }, - let_declarations_can_only_be_declared_inside_a_block: { code: 1157, category: ts.DiagnosticCategory.Error, key: "'let' declarations can only be declared inside a block." }, - Unterminated_template_literal: { code: 1160, category: ts.DiagnosticCategory.Error, key: "Unterminated template literal." }, - Unterminated_regular_expression_literal: { code: 1161, category: ts.DiagnosticCategory.Error, key: "Unterminated regular expression literal." }, - An_object_member_cannot_be_declared_optional: { code: 1162, category: ts.DiagnosticCategory.Error, key: "An object member cannot be declared optional." }, - A_yield_expression_is_only_allowed_in_a_generator_body: { code: 1163, category: ts.DiagnosticCategory.Error, key: "A 'yield' expression is only allowed in a generator body." }, - Computed_property_names_are_not_allowed_in_enums: { code: 1164, category: ts.DiagnosticCategory.Error, key: "Computed property names are not allowed in enums." }, - A_computed_property_name_in_an_ambient_context_must_directly_refer_to_a_built_in_symbol: { code: 1165, category: ts.DiagnosticCategory.Error, key: "A computed property name in an ambient context must directly refer to a built-in symbol." }, - A_computed_property_name_in_a_class_property_declaration_must_directly_refer_to_a_built_in_symbol: { code: 1166, category: ts.DiagnosticCategory.Error, key: "A computed property name in a class property declaration must directly refer to a built-in symbol." }, - A_computed_property_name_in_a_method_overload_must_directly_refer_to_a_built_in_symbol: { code: 1168, category: ts.DiagnosticCategory.Error, key: "A computed property name in a method overload must directly refer to a built-in symbol." }, - A_computed_property_name_in_an_interface_must_directly_refer_to_a_built_in_symbol: { code: 1169, category: ts.DiagnosticCategory.Error, key: "A computed property name in an interface must directly refer to a built-in symbol." }, - A_computed_property_name_in_a_type_literal_must_directly_refer_to_a_built_in_symbol: { code: 1170, category: ts.DiagnosticCategory.Error, key: "A computed property name in a type literal must directly refer to a built-in symbol." }, - A_comma_expression_is_not_allowed_in_a_computed_property_name: { code: 1171, category: ts.DiagnosticCategory.Error, key: "A comma expression is not allowed in a computed property name." }, - extends_clause_already_seen: { code: 1172, category: ts.DiagnosticCategory.Error, key: "'extends' clause already seen." }, - extends_clause_must_precede_implements_clause: { code: 1173, category: ts.DiagnosticCategory.Error, key: "'extends' clause must precede 'implements' clause." }, - Classes_can_only_extend_a_single_class: { code: 1174, category: ts.DiagnosticCategory.Error, key: "Classes can only extend a single class." }, - implements_clause_already_seen: { code: 1175, category: ts.DiagnosticCategory.Error, key: "'implements' clause already seen." }, - Interface_declaration_cannot_have_implements_clause: { code: 1176, category: ts.DiagnosticCategory.Error, key: "Interface declaration cannot have 'implements' clause." }, - Binary_digit_expected: { code: 1177, category: ts.DiagnosticCategory.Error, key: "Binary digit expected." }, - Octal_digit_expected: { code: 1178, category: ts.DiagnosticCategory.Error, key: "Octal digit expected." }, - Unexpected_token_expected: { code: 1179, category: ts.DiagnosticCategory.Error, key: "Unexpected token. '{' expected." }, - Property_destructuring_pattern_expected: { code: 1180, category: ts.DiagnosticCategory.Error, key: "Property destructuring pattern expected." }, - Array_element_destructuring_pattern_expected: { code: 1181, category: ts.DiagnosticCategory.Error, key: "Array element destructuring pattern expected." }, - A_destructuring_declaration_must_have_an_initializer: { code: 1182, category: ts.DiagnosticCategory.Error, key: "A destructuring declaration must have an initializer." }, - An_implementation_cannot_be_declared_in_ambient_contexts: { code: 1183, category: ts.DiagnosticCategory.Error, key: "An implementation cannot be declared in ambient contexts." }, - Modifiers_cannot_appear_here: { code: 1184, category: ts.DiagnosticCategory.Error, key: "Modifiers cannot appear here." }, - Merge_conflict_marker_encountered: { code: 1185, category: ts.DiagnosticCategory.Error, key: "Merge conflict marker encountered." }, - A_rest_element_cannot_have_an_initializer: { code: 1186, category: ts.DiagnosticCategory.Error, key: "A rest element cannot have an initializer." }, - A_parameter_property_may_not_be_a_binding_pattern: { code: 1187, category: ts.DiagnosticCategory.Error, key: "A parameter property may not be a binding pattern." }, - Only_a_single_variable_declaration_is_allowed_in_a_for_of_statement: { code: 1188, category: ts.DiagnosticCategory.Error, key: "Only a single variable declaration is allowed in a 'for...of' statement." }, - The_variable_declaration_of_a_for_in_statement_cannot_have_an_initializer: { code: 1189, category: ts.DiagnosticCategory.Error, key: "The variable declaration of a 'for...in' statement cannot have an initializer." }, - The_variable_declaration_of_a_for_of_statement_cannot_have_an_initializer: { code: 1190, category: ts.DiagnosticCategory.Error, key: "The variable declaration of a 'for...of' statement cannot have an initializer." }, - An_import_declaration_cannot_have_modifiers: { code: 1191, category: ts.DiagnosticCategory.Error, key: "An import declaration cannot have modifiers." }, - Module_0_has_no_default_export: { code: 1192, category: ts.DiagnosticCategory.Error, key: "Module '{0}' has no default export." }, - An_export_declaration_cannot_have_modifiers: { code: 1193, category: ts.DiagnosticCategory.Error, key: "An export declaration cannot have modifiers." }, - Export_declarations_are_not_permitted_in_a_namespace: { code: 1194, category: ts.DiagnosticCategory.Error, key: "Export declarations are not permitted in a namespace." }, - Catch_clause_variable_name_must_be_an_identifier: { code: 1195, category: ts.DiagnosticCategory.Error, key: "Catch clause variable name must be an identifier." }, - Catch_clause_variable_cannot_have_a_type_annotation: { code: 1196, category: ts.DiagnosticCategory.Error, key: "Catch clause variable cannot have a type annotation." }, - Catch_clause_variable_cannot_have_an_initializer: { code: 1197, category: ts.DiagnosticCategory.Error, key: "Catch clause variable cannot have an initializer." }, - An_extended_Unicode_escape_value_must_be_between_0x0_and_0x10FFFF_inclusive: { code: 1198, category: ts.DiagnosticCategory.Error, key: "An extended Unicode escape value must be between 0x0 and 0x10FFFF inclusive." }, - Unterminated_Unicode_escape_sequence: { code: 1199, category: ts.DiagnosticCategory.Error, key: "Unterminated Unicode escape sequence." }, - Line_terminator_not_permitted_before_arrow: { code: 1200, category: ts.DiagnosticCategory.Error, key: "Line terminator not permitted before arrow." }, - Import_assignment_cannot_be_used_when_targeting_ECMAScript_6_modules_Consider_using_import_Asterisk_as_ns_from_mod_import_a_from_mod_import_d_from_mod_or_another_module_format_instead: { code: 1202, category: ts.DiagnosticCategory.Error, key: "Import assignment cannot be used when targeting ECMAScript 6 modules. Consider using 'import * as ns from \"mod\"', 'import {a} from \"mod\"', 'import d from \"mod\"', or another module format instead." }, - Export_assignment_cannot_be_used_when_targeting_ECMAScript_6_modules_Consider_using_export_default_or_another_module_format_instead: { code: 1203, category: ts.DiagnosticCategory.Error, key: "Export assignment cannot be used when targeting ECMAScript 6 modules. Consider using 'export default' or another module format instead." }, - Cannot_compile_modules_into_es2015_when_targeting_ES5_or_lower: { code: 1204, category: ts.DiagnosticCategory.Error, key: "Cannot compile modules into 'es2015' when targeting 'ES5' or lower." }, - Decorators_are_not_valid_here: { code: 1206, category: ts.DiagnosticCategory.Error, key: "Decorators are not valid here." }, - Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name: { code: 1207, category: ts.DiagnosticCategory.Error, key: "Decorators cannot be applied to multiple get/set accessors of the same name." }, - Cannot_compile_namespaces_when_the_isolatedModules_flag_is_provided: { code: 1208, category: ts.DiagnosticCategory.Error, key: "Cannot compile namespaces when the '--isolatedModules' flag is provided." }, - Ambient_const_enums_are_not_allowed_when_the_isolatedModules_flag_is_provided: { code: 1209, category: ts.DiagnosticCategory.Error, key: "Ambient const enums are not allowed when the '--isolatedModules' flag is provided." }, - Invalid_use_of_0_Class_definitions_are_automatically_in_strict_mode: { code: 1210, category: ts.DiagnosticCategory.Error, key: "Invalid use of '{0}'. Class definitions are automatically in strict mode." }, - A_class_declaration_without_the_default_modifier_must_have_a_name: { code: 1211, category: ts.DiagnosticCategory.Error, key: "A class declaration without the 'default' modifier must have a name" }, - Identifier_expected_0_is_a_reserved_word_in_strict_mode: { code: 1212, category: ts.DiagnosticCategory.Error, key: "Identifier expected. '{0}' is a reserved word in strict mode" }, - Identifier_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_strict_mode: { code: 1213, category: ts.DiagnosticCategory.Error, key: "Identifier expected. '{0}' is a reserved word in strict mode. Class definitions are automatically in strict mode." }, - Identifier_expected_0_is_a_reserved_word_in_strict_mode_Modules_are_automatically_in_strict_mode: { code: 1214, category: ts.DiagnosticCategory.Error, key: "Identifier expected. '{0}' is a reserved word in strict mode. Modules are automatically in strict mode." }, - Invalid_use_of_0_Modules_are_automatically_in_strict_mode: { code: 1215, category: ts.DiagnosticCategory.Error, key: "Invalid use of '{0}'. Modules are automatically in strict mode." }, - Export_assignment_is_not_supported_when_module_flag_is_system: { code: 1218, category: ts.DiagnosticCategory.Error, key: "Export assignment is not supported when '--module' flag is 'system'." }, - Experimental_support_for_decorators_is_a_feature_that_is_subject_to_change_in_a_future_release_Specify_experimentalDecorators_to_remove_this_warning: { code: 1219, category: ts.DiagnosticCategory.Error, key: "Experimental support for decorators is a feature that is subject to change in a future release. Specify '--experimentalDecorators' to remove this warning." }, - Generators_are_only_available_when_targeting_ECMAScript_6_or_higher: { code: 1220, category: ts.DiagnosticCategory.Error, key: "Generators are only available when targeting ECMAScript 6 or higher." }, - Generators_are_not_allowed_in_an_ambient_context: { code: 1221, category: ts.DiagnosticCategory.Error, key: "Generators are not allowed in an ambient context." }, - An_overload_signature_cannot_be_declared_as_a_generator: { code: 1222, category: ts.DiagnosticCategory.Error, key: "An overload signature cannot be declared as a generator." }, - _0_tag_already_specified: { code: 1223, category: ts.DiagnosticCategory.Error, key: "'{0}' tag already specified." }, - Signature_0_must_have_a_type_predicate: { code: 1224, category: ts.DiagnosticCategory.Error, key: "Signature '{0}' must have a type predicate." }, - Cannot_find_parameter_0: { code: 1225, category: ts.DiagnosticCategory.Error, key: "Cannot find parameter '{0}'." }, - Type_predicate_0_is_not_assignable_to_1: { code: 1226, category: ts.DiagnosticCategory.Error, key: "Type predicate '{0}' is not assignable to '{1}'." }, - Parameter_0_is_not_in_the_same_position_as_parameter_1: { code: 1227, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' is not in the same position as parameter '{1}'." }, - A_type_predicate_is_only_allowed_in_return_type_position_for_functions_and_methods: { code: 1228, category: ts.DiagnosticCategory.Error, key: "A type predicate is only allowed in return type position for functions and methods." }, - A_type_predicate_cannot_reference_a_rest_parameter: { code: 1229, category: ts.DiagnosticCategory.Error, key: "A type predicate cannot reference a rest parameter." }, - A_type_predicate_cannot_reference_element_0_in_a_binding_pattern: { code: 1230, category: ts.DiagnosticCategory.Error, key: "A type predicate cannot reference element '{0}' in a binding pattern." }, - An_export_assignment_can_only_be_used_in_a_module: { code: 1231, category: ts.DiagnosticCategory.Error, key: "An export assignment can only be used in a module." }, - An_import_declaration_can_only_be_used_in_a_namespace_or_module: { code: 1232, category: ts.DiagnosticCategory.Error, key: "An import declaration can only be used in a namespace or module." }, - An_export_declaration_can_only_be_used_in_a_module: { code: 1233, category: ts.DiagnosticCategory.Error, key: "An export declaration can only be used in a module." }, - An_ambient_module_declaration_is_only_allowed_at_the_top_level_in_a_file: { code: 1234, category: ts.DiagnosticCategory.Error, key: "An ambient module declaration is only allowed at the top level in a file." }, - A_namespace_declaration_is_only_allowed_in_a_namespace_or_module: { code: 1235, category: ts.DiagnosticCategory.Error, key: "A namespace declaration is only allowed in a namespace or module." }, - The_return_type_of_a_property_decorator_function_must_be_either_void_or_any: { code: 1236, category: ts.DiagnosticCategory.Error, key: "The return type of a property decorator function must be either 'void' or 'any'." }, - The_return_type_of_a_parameter_decorator_function_must_be_either_void_or_any: { code: 1237, category: ts.DiagnosticCategory.Error, key: "The return type of a parameter decorator function must be either 'void' or 'any'." }, - Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression: { code: 1238, category: ts.DiagnosticCategory.Error, key: "Unable to resolve signature of class decorator when called as an expression." }, - Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression: { code: 1239, category: ts.DiagnosticCategory.Error, key: "Unable to resolve signature of parameter decorator when called as an expression." }, - Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression: { code: 1240, category: ts.DiagnosticCategory.Error, key: "Unable to resolve signature of property decorator when called as an expression." }, - Unable_to_resolve_signature_of_method_decorator_when_called_as_an_expression: { code: 1241, category: ts.DiagnosticCategory.Error, key: "Unable to resolve signature of method decorator when called as an expression." }, - abstract_modifier_can_only_appear_on_a_class_or_method_declaration: { code: 1242, category: ts.DiagnosticCategory.Error, key: "'abstract' modifier can only appear on a class or method declaration." }, - _0_modifier_cannot_be_used_with_1_modifier: { code: 1243, category: ts.DiagnosticCategory.Error, key: "'{0}' modifier cannot be used with '{1}' modifier." }, - Abstract_methods_can_only_appear_within_an_abstract_class: { code: 1244, category: ts.DiagnosticCategory.Error, key: "Abstract methods can only appear within an abstract class." }, - Method_0_cannot_have_an_implementation_because_it_is_marked_abstract: { code: 1245, category: ts.DiagnosticCategory.Error, key: "Method '{0}' cannot have an implementation because it is marked abstract." }, - with_statements_are_not_allowed_in_an_async_function_block: { code: 1300, category: ts.DiagnosticCategory.Error, key: "'with' statements are not allowed in an async function block." }, - await_expression_is_only_allowed_within_an_async_function: { code: 1308, category: ts.DiagnosticCategory.Error, key: "'await' expression is only allowed within an async function." }, - Async_functions_are_only_available_when_targeting_ECMAScript_6_and_higher: { code: 1311, category: ts.DiagnosticCategory.Error, key: "Async functions are only available when targeting ECMAScript 6 and higher." }, - can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment: { code: 1312, category: ts.DiagnosticCategory.Error, key: "'=' can only be used in an object literal property inside a destructuring assignment." }, - Duplicate_identifier_0: { code: 2300, category: ts.DiagnosticCategory.Error, key: "Duplicate identifier '{0}'." }, - Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor: { code: 2301, category: ts.DiagnosticCategory.Error, key: "Initializer of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor." }, - Static_members_cannot_reference_class_type_parameters: { code: 2302, category: ts.DiagnosticCategory.Error, key: "Static members cannot reference class type parameters." }, - Circular_definition_of_import_alias_0: { code: 2303, category: ts.DiagnosticCategory.Error, key: "Circular definition of import alias '{0}'." }, - Cannot_find_name_0: { code: 2304, category: ts.DiagnosticCategory.Error, key: "Cannot find name '{0}'." }, - Module_0_has_no_exported_member_1: { code: 2305, category: ts.DiagnosticCategory.Error, key: "Module '{0}' has no exported member '{1}'." }, - File_0_is_not_a_module: { code: 2306, category: ts.DiagnosticCategory.Error, key: "File '{0}' is not a module." }, - Cannot_find_module_0: { code: 2307, category: ts.DiagnosticCategory.Error, key: "Cannot find module '{0}'." }, - An_export_assignment_cannot_be_used_in_a_module_with_other_exported_elements: { code: 2309, category: ts.DiagnosticCategory.Error, key: "An export assignment cannot be used in a module with other exported elements." }, - Type_0_recursively_references_itself_as_a_base_type: { code: 2310, category: ts.DiagnosticCategory.Error, key: "Type '{0}' recursively references itself as a base type." }, - A_class_may_only_extend_another_class: { code: 2311, category: ts.DiagnosticCategory.Error, key: "A class may only extend another class." }, - An_interface_may_only_extend_a_class_or_another_interface: { code: 2312, category: ts.DiagnosticCategory.Error, key: "An interface may only extend a class or another interface." }, - Constraint_of_a_type_parameter_cannot_reference_any_type_parameter_from_the_same_type_parameter_list: { code: 2313, category: ts.DiagnosticCategory.Error, key: "Constraint of a type parameter cannot reference any type parameter from the same type parameter list." }, - Generic_type_0_requires_1_type_argument_s: { code: 2314, category: ts.DiagnosticCategory.Error, key: "Generic type '{0}' requires {1} type argument(s)." }, - Type_0_is_not_generic: { code: 2315, category: ts.DiagnosticCategory.Error, key: "Type '{0}' is not generic." }, - Global_type_0_must_be_a_class_or_interface_type: { code: 2316, category: ts.DiagnosticCategory.Error, key: "Global type '{0}' must be a class or interface type." }, - Global_type_0_must_have_1_type_parameter_s: { code: 2317, category: ts.DiagnosticCategory.Error, key: "Global type '{0}' must have {1} type parameter(s)." }, - Cannot_find_global_type_0: { code: 2318, category: ts.DiagnosticCategory.Error, key: "Cannot find global type '{0}'." }, - Named_property_0_of_types_1_and_2_are_not_identical: { code: 2319, category: ts.DiagnosticCategory.Error, key: "Named property '{0}' of types '{1}' and '{2}' are not identical." }, - Interface_0_cannot_simultaneously_extend_types_1_and_2: { code: 2320, category: ts.DiagnosticCategory.Error, key: "Interface '{0}' cannot simultaneously extend types '{1}' and '{2}'." }, - Excessive_stack_depth_comparing_types_0_and_1: { code: 2321, category: ts.DiagnosticCategory.Error, key: "Excessive stack depth comparing types '{0}' and '{1}'." }, - Type_0_is_not_assignable_to_type_1: { code: 2322, category: ts.DiagnosticCategory.Error, key: "Type '{0}' is not assignable to type '{1}'." }, - Property_0_is_missing_in_type_1: { code: 2324, category: ts.DiagnosticCategory.Error, key: "Property '{0}' is missing in type '{1}'." }, - Property_0_is_private_in_type_1_but_not_in_type_2: { code: 2325, category: ts.DiagnosticCategory.Error, key: "Property '{0}' is private in type '{1}' but not in type '{2}'." }, - Types_of_property_0_are_incompatible: { code: 2326, category: ts.DiagnosticCategory.Error, key: "Types of property '{0}' are incompatible." }, - Property_0_is_optional_in_type_1_but_required_in_type_2: { code: 2327, category: ts.DiagnosticCategory.Error, key: "Property '{0}' is optional in type '{1}' but required in type '{2}'." }, - Types_of_parameters_0_and_1_are_incompatible: { code: 2328, category: ts.DiagnosticCategory.Error, key: "Types of parameters '{0}' and '{1}' are incompatible." }, - Index_signature_is_missing_in_type_0: { code: 2329, category: ts.DiagnosticCategory.Error, key: "Index signature is missing in type '{0}'." }, - Index_signatures_are_incompatible: { code: 2330, category: ts.DiagnosticCategory.Error, key: "Index signatures are incompatible." }, - this_cannot_be_referenced_in_a_module_or_namespace_body: { code: 2331, category: ts.DiagnosticCategory.Error, key: "'this' cannot be referenced in a module or namespace body." }, - this_cannot_be_referenced_in_current_location: { code: 2332, category: ts.DiagnosticCategory.Error, key: "'this' cannot be referenced in current location." }, - this_cannot_be_referenced_in_constructor_arguments: { code: 2333, category: ts.DiagnosticCategory.Error, key: "'this' cannot be referenced in constructor arguments." }, - this_cannot_be_referenced_in_a_static_property_initializer: { code: 2334, category: ts.DiagnosticCategory.Error, key: "'this' cannot be referenced in a static property initializer." }, - super_can_only_be_referenced_in_a_derived_class: { code: 2335, category: ts.DiagnosticCategory.Error, key: "'super' can only be referenced in a derived class." }, - super_cannot_be_referenced_in_constructor_arguments: { code: 2336, category: ts.DiagnosticCategory.Error, key: "'super' cannot be referenced in constructor arguments." }, - Super_calls_are_not_permitted_outside_constructors_or_in_nested_functions_inside_constructors: { code: 2337, category: ts.DiagnosticCategory.Error, key: "Super calls are not permitted outside constructors or in nested functions inside constructors." }, - super_property_access_is_permitted_only_in_a_constructor_member_function_or_member_accessor_of_a_derived_class: { code: 2338, category: ts.DiagnosticCategory.Error, key: "'super' property access is permitted only in a constructor, member function, or member accessor of a derived class." }, - Property_0_does_not_exist_on_type_1: { code: 2339, category: ts.DiagnosticCategory.Error, key: "Property '{0}' does not exist on type '{1}'." }, - Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword: { code: 2340, category: ts.DiagnosticCategory.Error, key: "Only public and protected methods of the base class are accessible via the 'super' keyword." }, - Property_0_is_private_and_only_accessible_within_class_1: { code: 2341, category: ts.DiagnosticCategory.Error, key: "Property '{0}' is private and only accessible within class '{1}'." }, - An_index_expression_argument_must_be_of_type_string_number_symbol_or_any: { code: 2342, category: ts.DiagnosticCategory.Error, key: "An index expression argument must be of type 'string', 'number', 'symbol', or 'any'." }, - Type_0_does_not_satisfy_the_constraint_1: { code: 2344, category: ts.DiagnosticCategory.Error, key: "Type '{0}' does not satisfy the constraint '{1}'." }, - Argument_of_type_0_is_not_assignable_to_parameter_of_type_1: { code: 2345, category: ts.DiagnosticCategory.Error, key: "Argument of type '{0}' is not assignable to parameter of type '{1}'." }, - Supplied_parameters_do_not_match_any_signature_of_call_target: { code: 2346, category: ts.DiagnosticCategory.Error, key: "Supplied parameters do not match any signature of call target." }, - Untyped_function_calls_may_not_accept_type_arguments: { code: 2347, category: ts.DiagnosticCategory.Error, key: "Untyped function calls may not accept type arguments." }, - Value_of_type_0_is_not_callable_Did_you_mean_to_include_new: { code: 2348, category: ts.DiagnosticCategory.Error, key: "Value of type '{0}' is not callable. Did you mean to include 'new'?" }, - Cannot_invoke_an_expression_whose_type_lacks_a_call_signature: { code: 2349, category: ts.DiagnosticCategory.Error, key: "Cannot invoke an expression whose type lacks a call signature." }, - Only_a_void_function_can_be_called_with_the_new_keyword: { code: 2350, category: ts.DiagnosticCategory.Error, key: "Only a void function can be called with the 'new' keyword." }, - Cannot_use_new_with_an_expression_whose_type_lacks_a_call_or_construct_signature: { code: 2351, category: ts.DiagnosticCategory.Error, key: "Cannot use 'new' with an expression whose type lacks a call or construct signature." }, - Neither_type_0_nor_type_1_is_assignable_to_the_other: { code: 2352, category: ts.DiagnosticCategory.Error, key: "Neither type '{0}' nor type '{1}' is assignable to the other." }, - Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1: { code: 2353, category: ts.DiagnosticCategory.Error, key: "Object literal may only specify known properties, and '{0}' does not exist in type '{1}'." }, - No_best_common_type_exists_among_return_expressions: { code: 2354, category: ts.DiagnosticCategory.Error, key: "No best common type exists among return expressions." }, - A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value_or_consist_of_a_single_throw_statement: { code: 2355, category: ts.DiagnosticCategory.Error, key: "A function whose declared type is neither 'void' nor 'any' must return a value or consist of a single 'throw' statement." }, - An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type: { code: 2356, category: ts.DiagnosticCategory.Error, key: "An arithmetic operand must be of type 'any', 'number' or an enum type." }, - The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_property_or_indexer: { code: 2357, category: ts.DiagnosticCategory.Error, key: "The operand of an increment or decrement operator must be a variable, property or indexer." }, - The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_parameter: { code: 2358, category: ts.DiagnosticCategory.Error, key: "The left-hand side of an 'instanceof' expression must be of type 'any', an object type or a type parameter." }, - The_right_hand_side_of_an_instanceof_expression_must_be_of_type_any_or_of_a_type_assignable_to_the_Function_interface_type: { code: 2359, category: ts.DiagnosticCategory.Error, key: "The right-hand side of an 'instanceof' expression must be of type 'any' or of a type assignable to the 'Function' interface type." }, - The_left_hand_side_of_an_in_expression_must_be_of_type_any_string_number_or_symbol: { code: 2360, category: ts.DiagnosticCategory.Error, key: "The left-hand side of an 'in' expression must be of type 'any', 'string', 'number', or 'symbol'." }, - The_right_hand_side_of_an_in_expression_must_be_of_type_any_an_object_type_or_a_type_parameter: { code: 2361, category: ts.DiagnosticCategory.Error, key: "The right-hand side of an 'in' expression must be of type 'any', an object type or a type parameter" }, - The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type: { code: 2362, category: ts.DiagnosticCategory.Error, key: "The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type." }, - The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type: { code: 2363, category: ts.DiagnosticCategory.Error, key: "The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type." }, - Invalid_left_hand_side_of_assignment_expression: { code: 2364, category: ts.DiagnosticCategory.Error, key: "Invalid left-hand side of assignment expression." }, - Operator_0_cannot_be_applied_to_types_1_and_2: { code: 2365, category: ts.DiagnosticCategory.Error, key: "Operator '{0}' cannot be applied to types '{1}' and '{2}'." }, - Type_parameter_name_cannot_be_0: { code: 2368, category: ts.DiagnosticCategory.Error, key: "Type parameter name cannot be '{0}'" }, - A_parameter_property_is_only_allowed_in_a_constructor_implementation: { code: 2369, category: ts.DiagnosticCategory.Error, key: "A parameter property is only allowed in a constructor implementation." }, - A_rest_parameter_must_be_of_an_array_type: { code: 2370, category: ts.DiagnosticCategory.Error, key: "A rest parameter must be of an array type." }, - A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation: { code: 2371, category: ts.DiagnosticCategory.Error, key: "A parameter initializer is only allowed in a function or constructor implementation." }, - Parameter_0_cannot_be_referenced_in_its_initializer: { code: 2372, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' cannot be referenced in its initializer." }, - Initializer_of_parameter_0_cannot_reference_identifier_1_declared_after_it: { code: 2373, category: ts.DiagnosticCategory.Error, key: "Initializer of parameter '{0}' cannot reference identifier '{1}' declared after it." }, - Duplicate_string_index_signature: { code: 2374, category: ts.DiagnosticCategory.Error, key: "Duplicate string index signature." }, - Duplicate_number_index_signature: { code: 2375, category: ts.DiagnosticCategory.Error, key: "Duplicate number index signature." }, - A_super_call_must_be_the_first_statement_in_the_constructor_when_a_class_contains_initialized_properties_or_has_parameter_properties: { code: 2376, category: ts.DiagnosticCategory.Error, key: "A 'super' call must be the first statement in the constructor when a class contains initialized properties or has parameter properties." }, - Constructors_for_derived_classes_must_contain_a_super_call: { code: 2377, category: ts.DiagnosticCategory.Error, key: "Constructors for derived classes must contain a 'super' call." }, - A_get_accessor_must_return_a_value_or_consist_of_a_single_throw_statement: { code: 2378, category: ts.DiagnosticCategory.Error, key: "A 'get' accessor must return a value or consist of a single 'throw' statement." }, - Getter_and_setter_accessors_do_not_agree_in_visibility: { code: 2379, category: ts.DiagnosticCategory.Error, key: "Getter and setter accessors do not agree in visibility." }, - get_and_set_accessor_must_have_the_same_type: { code: 2380, category: ts.DiagnosticCategory.Error, key: "'get' and 'set' accessor must have the same type." }, - A_signature_with_an_implementation_cannot_use_a_string_literal_type: { code: 2381, category: ts.DiagnosticCategory.Error, key: "A signature with an implementation cannot use a string literal type." }, - Specialized_overload_signature_is_not_assignable_to_any_non_specialized_signature: { code: 2382, category: ts.DiagnosticCategory.Error, key: "Specialized overload signature is not assignable to any non-specialized signature." }, - Overload_signatures_must_all_be_exported_or_not_exported: { code: 2383, category: ts.DiagnosticCategory.Error, key: "Overload signatures must all be exported or not exported." }, - Overload_signatures_must_all_be_ambient_or_non_ambient: { code: 2384, category: ts.DiagnosticCategory.Error, key: "Overload signatures must all be ambient or non-ambient." }, - Overload_signatures_must_all_be_public_private_or_protected: { code: 2385, category: ts.DiagnosticCategory.Error, key: "Overload signatures must all be public, private or protected." }, - Overload_signatures_must_all_be_optional_or_required: { code: 2386, category: ts.DiagnosticCategory.Error, key: "Overload signatures must all be optional or required." }, - Function_overload_must_be_static: { code: 2387, category: ts.DiagnosticCategory.Error, key: "Function overload must be static." }, - Function_overload_must_not_be_static: { code: 2388, category: ts.DiagnosticCategory.Error, key: "Function overload must not be static." }, - Function_implementation_name_must_be_0: { code: 2389, category: ts.DiagnosticCategory.Error, key: "Function implementation name must be '{0}'." }, - Constructor_implementation_is_missing: { code: 2390, category: ts.DiagnosticCategory.Error, key: "Constructor implementation is missing." }, - Function_implementation_is_missing_or_not_immediately_following_the_declaration: { code: 2391, category: ts.DiagnosticCategory.Error, key: "Function implementation is missing or not immediately following the declaration." }, - Multiple_constructor_implementations_are_not_allowed: { code: 2392, category: ts.DiagnosticCategory.Error, key: "Multiple constructor implementations are not allowed." }, - Duplicate_function_implementation: { code: 2393, category: ts.DiagnosticCategory.Error, key: "Duplicate function implementation." }, - Overload_signature_is_not_compatible_with_function_implementation: { code: 2394, category: ts.DiagnosticCategory.Error, key: "Overload signature is not compatible with function implementation." }, - Individual_declarations_in_merged_declaration_0_must_be_all_exported_or_all_local: { code: 2395, category: ts.DiagnosticCategory.Error, key: "Individual declarations in merged declaration '{0}' must be all exported or all local." }, - Duplicate_identifier_arguments_Compiler_uses_arguments_to_initialize_rest_parameters: { code: 2396, category: ts.DiagnosticCategory.Error, key: "Duplicate identifier 'arguments'. Compiler uses 'arguments' to initialize rest parameters." }, - Duplicate_identifier_this_Compiler_uses_variable_declaration_this_to_capture_this_reference: { code: 2399, category: ts.DiagnosticCategory.Error, key: "Duplicate identifier '_this'. Compiler uses variable declaration '_this' to capture 'this' reference." }, - Expression_resolves_to_variable_declaration_this_that_compiler_uses_to_capture_this_reference: { code: 2400, category: ts.DiagnosticCategory.Error, key: "Expression resolves to variable declaration '_this' that compiler uses to capture 'this' reference." }, - Duplicate_identifier_super_Compiler_uses_super_to_capture_base_class_reference: { code: 2401, category: ts.DiagnosticCategory.Error, key: "Duplicate identifier '_super'. Compiler uses '_super' to capture base class reference." }, - Expression_resolves_to_super_that_compiler_uses_to_capture_base_class_reference: { code: 2402, category: ts.DiagnosticCategory.Error, key: "Expression resolves to '_super' that compiler uses to capture base class reference." }, - Subsequent_variable_declarations_must_have_the_same_type_Variable_0_must_be_of_type_1_but_here_has_type_2: { code: 2403, category: ts.DiagnosticCategory.Error, key: "Subsequent variable declarations must have the same type. Variable '{0}' must be of type '{1}', but here has type '{2}'." }, - The_left_hand_side_of_a_for_in_statement_cannot_use_a_type_annotation: { code: 2404, category: ts.DiagnosticCategory.Error, key: "The left-hand side of a 'for...in' statement cannot use a type annotation." }, - The_left_hand_side_of_a_for_in_statement_must_be_of_type_string_or_any: { code: 2405, category: ts.DiagnosticCategory.Error, key: "The left-hand side of a 'for...in' statement must be of type 'string' or 'any'." }, - Invalid_left_hand_side_in_for_in_statement: { code: 2406, category: ts.DiagnosticCategory.Error, key: "Invalid left-hand side in 'for...in' statement." }, - The_right_hand_side_of_a_for_in_statement_must_be_of_type_any_an_object_type_or_a_type_parameter: { code: 2407, category: ts.DiagnosticCategory.Error, key: "The right-hand side of a 'for...in' statement must be of type 'any', an object type or a type parameter." }, - Setters_cannot_return_a_value: { code: 2408, category: ts.DiagnosticCategory.Error, key: "Setters cannot return a value." }, - Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class: { code: 2409, category: ts.DiagnosticCategory.Error, key: "Return type of constructor signature must be assignable to the instance type of the class" }, - All_symbols_within_a_with_block_will_be_resolved_to_any: { code: 2410, category: ts.DiagnosticCategory.Error, key: "All symbols within a 'with' block will be resolved to 'any'." }, - Property_0_of_type_1_is_not_assignable_to_string_index_type_2: { code: 2411, category: ts.DiagnosticCategory.Error, key: "Property '{0}' of type '{1}' is not assignable to string index type '{2}'." }, - Property_0_of_type_1_is_not_assignable_to_numeric_index_type_2: { code: 2412, category: ts.DiagnosticCategory.Error, key: "Property '{0}' of type '{1}' is not assignable to numeric index type '{2}'." }, - Numeric_index_type_0_is_not_assignable_to_string_index_type_1: { code: 2413, category: ts.DiagnosticCategory.Error, key: "Numeric index type '{0}' is not assignable to string index type '{1}'." }, - Class_name_cannot_be_0: { code: 2414, category: ts.DiagnosticCategory.Error, key: "Class name cannot be '{0}'" }, - Class_0_incorrectly_extends_base_class_1: { code: 2415, category: ts.DiagnosticCategory.Error, key: "Class '{0}' incorrectly extends base class '{1}'." }, - Class_static_side_0_incorrectly_extends_base_class_static_side_1: { code: 2417, category: ts.DiagnosticCategory.Error, key: "Class static side '{0}' incorrectly extends base class static side '{1}'." }, - Type_name_0_in_extends_clause_does_not_reference_constructor_function_for_0: { code: 2419, category: ts.DiagnosticCategory.Error, key: "Type name '{0}' in extends clause does not reference constructor function for '{0}'." }, - Class_0_incorrectly_implements_interface_1: { code: 2420, category: ts.DiagnosticCategory.Error, key: "Class '{0}' incorrectly implements interface '{1}'." }, - A_class_may_only_implement_another_class_or_interface: { code: 2422, category: ts.DiagnosticCategory.Error, key: "A class may only implement another class or interface." }, - Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_accessor: { code: 2423, category: ts.DiagnosticCategory.Error, key: "Class '{0}' defines instance member function '{1}', but extended class '{2}' defines it as instance member accessor." }, - Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_property: { code: 2424, category: ts.DiagnosticCategory.Error, key: "Class '{0}' defines instance member function '{1}', but extended class '{2}' defines it as instance member property." }, - Class_0_defines_instance_member_property_1_but_extended_class_2_defines_it_as_instance_member_function: { code: 2425, category: ts.DiagnosticCategory.Error, key: "Class '{0}' defines instance member property '{1}', but extended class '{2}' defines it as instance member function." }, - Class_0_defines_instance_member_accessor_1_but_extended_class_2_defines_it_as_instance_member_function: { code: 2426, category: ts.DiagnosticCategory.Error, key: "Class '{0}' defines instance member accessor '{1}', but extended class '{2}' defines it as instance member function." }, - Interface_name_cannot_be_0: { code: 2427, category: ts.DiagnosticCategory.Error, key: "Interface name cannot be '{0}'" }, - All_declarations_of_an_interface_must_have_identical_type_parameters: { code: 2428, category: ts.DiagnosticCategory.Error, key: "All declarations of an interface must have identical type parameters." }, - Interface_0_incorrectly_extends_interface_1: { code: 2430, category: ts.DiagnosticCategory.Error, key: "Interface '{0}' incorrectly extends interface '{1}'." }, - Enum_name_cannot_be_0: { code: 2431, category: ts.DiagnosticCategory.Error, key: "Enum name cannot be '{0}'" }, - In_an_enum_with_multiple_declarations_only_one_declaration_can_omit_an_initializer_for_its_first_enum_element: { code: 2432, category: ts.DiagnosticCategory.Error, key: "In an enum with multiple declarations, only one declaration can omit an initializer for its first enum element." }, - A_namespace_declaration_cannot_be_in_a_different_file_from_a_class_or_function_with_which_it_is_merged: { code: 2433, category: ts.DiagnosticCategory.Error, key: "A namespace declaration cannot be in a different file from a class or function with which it is merged" }, - A_namespace_declaration_cannot_be_located_prior_to_a_class_or_function_with_which_it_is_merged: { code: 2434, category: ts.DiagnosticCategory.Error, key: "A namespace declaration cannot be located prior to a class or function with which it is merged" }, - Ambient_modules_cannot_be_nested_in_other_modules_or_namespaces: { code: 2435, category: ts.DiagnosticCategory.Error, key: "Ambient modules cannot be nested in other modules or namespaces." }, - Ambient_module_declaration_cannot_specify_relative_module_name: { code: 2436, category: ts.DiagnosticCategory.Error, key: "Ambient module declaration cannot specify relative module name." }, - Module_0_is_hidden_by_a_local_declaration_with_the_same_name: { code: 2437, category: ts.DiagnosticCategory.Error, key: "Module '{0}' is hidden by a local declaration with the same name" }, - Import_name_cannot_be_0: { code: 2438, category: ts.DiagnosticCategory.Error, key: "Import name cannot be '{0}'" }, - Import_or_export_declaration_in_an_ambient_module_declaration_cannot_reference_module_through_relative_module_name: { code: 2439, category: ts.DiagnosticCategory.Error, key: "Import or export declaration in an ambient module declaration cannot reference module through relative module name." }, - Import_declaration_conflicts_with_local_declaration_of_0: { code: 2440, category: ts.DiagnosticCategory.Error, key: "Import declaration conflicts with local declaration of '{0}'" }, - Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module: { code: 2441, category: ts.DiagnosticCategory.Error, key: "Duplicate identifier '{0}'. Compiler reserves name '{1}' in top level scope of a module." }, - Types_have_separate_declarations_of_a_private_property_0: { code: 2442, category: ts.DiagnosticCategory.Error, key: "Types have separate declarations of a private property '{0}'." }, - Property_0_is_protected_but_type_1_is_not_a_class_derived_from_2: { code: 2443, category: ts.DiagnosticCategory.Error, key: "Property '{0}' is protected but type '{1}' is not a class derived from '{2}'." }, - Property_0_is_protected_in_type_1_but_public_in_type_2: { code: 2444, category: ts.DiagnosticCategory.Error, key: "Property '{0}' is protected in type '{1}' but public in type '{2}'." }, - Property_0_is_protected_and_only_accessible_within_class_1_and_its_subclasses: { code: 2445, category: ts.DiagnosticCategory.Error, key: "Property '{0}' is protected and only accessible within class '{1}' and its subclasses." }, - Property_0_is_protected_and_only_accessible_through_an_instance_of_class_1: { code: 2446, category: ts.DiagnosticCategory.Error, key: "Property '{0}' is protected and only accessible through an instance of class '{1}'." }, - The_0_operator_is_not_allowed_for_boolean_types_Consider_using_1_instead: { code: 2447, category: ts.DiagnosticCategory.Error, key: "The '{0}' operator is not allowed for boolean types. Consider using '{1}' instead." }, - Block_scoped_variable_0_used_before_its_declaration: { code: 2448, category: ts.DiagnosticCategory.Error, key: "Block-scoped variable '{0}' used before its declaration." }, - The_operand_of_an_increment_or_decrement_operator_cannot_be_a_constant: { code: 2449, category: ts.DiagnosticCategory.Error, key: "The operand of an increment or decrement operator cannot be a constant." }, - Left_hand_side_of_assignment_expression_cannot_be_a_constant: { code: 2450, category: ts.DiagnosticCategory.Error, key: "Left-hand side of assignment expression cannot be a constant." }, - Cannot_redeclare_block_scoped_variable_0: { code: 2451, category: ts.DiagnosticCategory.Error, key: "Cannot redeclare block-scoped variable '{0}'." }, - An_enum_member_cannot_have_a_numeric_name: { code: 2452, category: ts.DiagnosticCategory.Error, key: "An enum member cannot have a numeric name." }, - The_type_argument_for_type_parameter_0_cannot_be_inferred_from_the_usage_Consider_specifying_the_type_arguments_explicitly: { code: 2453, category: ts.DiagnosticCategory.Error, key: "The type argument for type parameter '{0}' cannot be inferred from the usage. Consider specifying the type arguments explicitly." }, - Type_argument_candidate_1_is_not_a_valid_type_argument_because_it_is_not_a_supertype_of_candidate_0: { code: 2455, category: ts.DiagnosticCategory.Error, key: "Type argument candidate '{1}' is not a valid type argument because it is not a supertype of candidate '{0}'." }, - Type_alias_0_circularly_references_itself: { code: 2456, category: ts.DiagnosticCategory.Error, key: "Type alias '{0}' circularly references itself." }, - Type_alias_name_cannot_be_0: { code: 2457, category: ts.DiagnosticCategory.Error, key: "Type alias name cannot be '{0}'" }, - An_AMD_module_cannot_have_multiple_name_assignments: { code: 2458, category: ts.DiagnosticCategory.Error, key: "An AMD module cannot have multiple name assignments." }, - Type_0_has_no_property_1_and_no_string_index_signature: { code: 2459, category: ts.DiagnosticCategory.Error, key: "Type '{0}' has no property '{1}' and no string index signature." }, - Type_0_has_no_property_1: { code: 2460, category: ts.DiagnosticCategory.Error, key: "Type '{0}' has no property '{1}'." }, - Type_0_is_not_an_array_type: { code: 2461, category: ts.DiagnosticCategory.Error, key: "Type '{0}' is not an array type." }, - A_rest_element_must_be_last_in_an_array_destructuring_pattern: { code: 2462, category: ts.DiagnosticCategory.Error, key: "A rest element must be last in an array destructuring pattern" }, - A_binding_pattern_parameter_cannot_be_optional_in_an_implementation_signature: { code: 2463, category: ts.DiagnosticCategory.Error, key: "A binding pattern parameter cannot be optional in an implementation signature." }, - A_computed_property_name_must_be_of_type_string_number_symbol_or_any: { code: 2464, category: ts.DiagnosticCategory.Error, key: "A computed property name must be of type 'string', 'number', 'symbol', or 'any'." }, - this_cannot_be_referenced_in_a_computed_property_name: { code: 2465, category: ts.DiagnosticCategory.Error, key: "'this' cannot be referenced in a computed property name." }, - super_cannot_be_referenced_in_a_computed_property_name: { code: 2466, category: ts.DiagnosticCategory.Error, key: "'super' cannot be referenced in a computed property name." }, - A_computed_property_name_cannot_reference_a_type_parameter_from_its_containing_type: { code: 2467, category: ts.DiagnosticCategory.Error, key: "A computed property name cannot reference a type parameter from its containing type." }, - Cannot_find_global_value_0: { code: 2468, category: ts.DiagnosticCategory.Error, key: "Cannot find global value '{0}'." }, - The_0_operator_cannot_be_applied_to_type_symbol: { code: 2469, category: ts.DiagnosticCategory.Error, key: "The '{0}' operator cannot be applied to type 'symbol'." }, - Symbol_reference_does_not_refer_to_the_global_Symbol_constructor_object: { code: 2470, category: ts.DiagnosticCategory.Error, key: "'Symbol' reference does not refer to the global Symbol constructor object." }, - A_computed_property_name_of_the_form_0_must_be_of_type_symbol: { code: 2471, category: ts.DiagnosticCategory.Error, key: "A computed property name of the form '{0}' must be of type 'symbol'." }, - Spread_operator_in_new_expressions_is_only_available_when_targeting_ECMAScript_5_and_higher: { code: 2472, category: ts.DiagnosticCategory.Error, key: "Spread operator in 'new' expressions is only available when targeting ECMAScript 5 and higher." }, - Enum_declarations_must_all_be_const_or_non_const: { code: 2473, category: ts.DiagnosticCategory.Error, key: "Enum declarations must all be const or non-const." }, - In_const_enum_declarations_member_initializer_must_be_constant_expression: { code: 2474, category: ts.DiagnosticCategory.Error, key: "In 'const' enum declarations member initializer must be constant expression." }, - const_enums_can_only_be_used_in_property_or_index_access_expressions_or_the_right_hand_side_of_an_import_declaration_or_export_assignment: { code: 2475, category: ts.DiagnosticCategory.Error, key: "'const' enums can only be used in property or index access expressions or the right hand side of an import declaration or export assignment." }, - A_const_enum_member_can_only_be_accessed_using_a_string_literal: { code: 2476, category: ts.DiagnosticCategory.Error, key: "A const enum member can only be accessed using a string literal." }, - const_enum_member_initializer_was_evaluated_to_a_non_finite_value: { code: 2477, category: ts.DiagnosticCategory.Error, key: "'const' enum member initializer was evaluated to a non-finite value." }, - const_enum_member_initializer_was_evaluated_to_disallowed_value_NaN: { code: 2478, category: ts.DiagnosticCategory.Error, key: "'const' enum member initializer was evaluated to disallowed value 'NaN'." }, - Property_0_does_not_exist_on_const_enum_1: { code: 2479, category: ts.DiagnosticCategory.Error, key: "Property '{0}' does not exist on 'const' enum '{1}'." }, - let_is_not_allowed_to_be_used_as_a_name_in_let_or_const_declarations: { code: 2480, category: ts.DiagnosticCategory.Error, key: "'let' is not allowed to be used as a name in 'let' or 'const' declarations." }, - Cannot_initialize_outer_scoped_variable_0_in_the_same_scope_as_block_scoped_declaration_1: { code: 2481, category: ts.DiagnosticCategory.Error, key: "Cannot initialize outer scoped variable '{0}' in the same scope as block scoped declaration '{1}'." }, - The_left_hand_side_of_a_for_of_statement_cannot_use_a_type_annotation: { code: 2483, category: ts.DiagnosticCategory.Error, key: "The left-hand side of a 'for...of' statement cannot use a type annotation." }, - Export_declaration_conflicts_with_exported_declaration_of_0: { code: 2484, category: ts.DiagnosticCategory.Error, key: "Export declaration conflicts with exported declaration of '{0}'" }, - The_left_hand_side_of_a_for_of_statement_cannot_be_a_previously_defined_constant: { code: 2485, category: ts.DiagnosticCategory.Error, key: "The left-hand side of a 'for...of' statement cannot be a previously defined constant." }, - The_left_hand_side_of_a_for_in_statement_cannot_be_a_previously_defined_constant: { code: 2486, category: ts.DiagnosticCategory.Error, key: "The left-hand side of a 'for...in' statement cannot be a previously defined constant." }, - Invalid_left_hand_side_in_for_of_statement: { code: 2487, category: ts.DiagnosticCategory.Error, key: "Invalid left-hand side in 'for...of' statement." }, - Type_must_have_a_Symbol_iterator_method_that_returns_an_iterator: { code: 2488, category: ts.DiagnosticCategory.Error, key: "Type must have a '[Symbol.iterator]()' method that returns an iterator." }, - An_iterator_must_have_a_next_method: { code: 2489, category: ts.DiagnosticCategory.Error, key: "An iterator must have a 'next()' method." }, - The_type_returned_by_the_next_method_of_an_iterator_must_have_a_value_property: { code: 2490, category: ts.DiagnosticCategory.Error, key: "The type returned by the 'next()' method of an iterator must have a 'value' property." }, - The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern: { code: 2491, category: ts.DiagnosticCategory.Error, key: "The left-hand side of a 'for...in' statement cannot be a destructuring pattern." }, - Cannot_redeclare_identifier_0_in_catch_clause: { code: 2492, category: ts.DiagnosticCategory.Error, key: "Cannot redeclare identifier '{0}' in catch clause" }, - Tuple_type_0_with_length_1_cannot_be_assigned_to_tuple_with_length_2: { code: 2493, category: ts.DiagnosticCategory.Error, key: "Tuple type '{0}' with length '{1}' cannot be assigned to tuple with length '{2}'." }, - Using_a_string_in_a_for_of_statement_is_only_supported_in_ECMAScript_5_and_higher: { code: 2494, category: ts.DiagnosticCategory.Error, key: "Using a string in a 'for...of' statement is only supported in ECMAScript 5 and higher." }, - Type_0_is_not_an_array_type_or_a_string_type: { code: 2495, category: ts.DiagnosticCategory.Error, key: "Type '{0}' is not an array type or a string type." }, - The_arguments_object_cannot_be_referenced_in_an_arrow_function_in_ES3_and_ES5_Consider_using_a_standard_function_expression: { code: 2496, category: ts.DiagnosticCategory.Error, key: "The 'arguments' object cannot be referenced in an arrow function in ES3 and ES5. Consider using a standard function expression." }, - Module_0_resolves_to_a_non_module_entity_and_cannot_be_imported_using_this_construct: { code: 2497, category: ts.DiagnosticCategory.Error, key: "Module '{0}' resolves to a non-module entity and cannot be imported using this construct." }, - Module_0_uses_export_and_cannot_be_used_with_export_Asterisk: { code: 2498, category: ts.DiagnosticCategory.Error, key: "Module '{0}' uses 'export =' and cannot be used with 'export *'." }, - An_interface_can_only_extend_an_identifier_Slashqualified_name_with_optional_type_arguments: { code: 2499, category: ts.DiagnosticCategory.Error, key: "An interface can only extend an identifier/qualified-name with optional type arguments." }, - A_class_can_only_implement_an_identifier_Slashqualified_name_with_optional_type_arguments: { code: 2500, category: ts.DiagnosticCategory.Error, key: "A class can only implement an identifier/qualified-name with optional type arguments." }, - A_rest_element_cannot_contain_a_binding_pattern: { code: 2501, category: ts.DiagnosticCategory.Error, key: "A rest element cannot contain a binding pattern." }, - _0_is_referenced_directly_or_indirectly_in_its_own_type_annotation: { code: 2502, category: ts.DiagnosticCategory.Error, key: "'{0}' is referenced directly or indirectly in its own type annotation." }, - Cannot_find_namespace_0: { code: 2503, category: ts.DiagnosticCategory.Error, key: "Cannot find namespace '{0}'." }, - No_best_common_type_exists_among_yield_expressions: { code: 2504, category: ts.DiagnosticCategory.Error, key: "No best common type exists among yield expressions." }, - A_generator_cannot_have_a_void_type_annotation: { code: 2505, category: ts.DiagnosticCategory.Error, key: "A generator cannot have a 'void' type annotation." }, - _0_is_referenced_directly_or_indirectly_in_its_own_base_expression: { code: 2506, category: ts.DiagnosticCategory.Error, key: "'{0}' is referenced directly or indirectly in its own base expression." }, - Type_0_is_not_a_constructor_function_type: { code: 2507, category: ts.DiagnosticCategory.Error, key: "Type '{0}' is not a constructor function type." }, - No_base_constructor_has_the_specified_number_of_type_arguments: { code: 2508, category: ts.DiagnosticCategory.Error, key: "No base constructor has the specified number of type arguments." }, - Base_constructor_return_type_0_is_not_a_class_or_interface_type: { code: 2509, category: ts.DiagnosticCategory.Error, key: "Base constructor return type '{0}' is not a class or interface type." }, - Base_constructors_must_all_have_the_same_return_type: { code: 2510, category: ts.DiagnosticCategory.Error, key: "Base constructors must all have the same return type." }, - Cannot_create_an_instance_of_the_abstract_class_0: { code: 2511, category: ts.DiagnosticCategory.Error, key: "Cannot create an instance of the abstract class '{0}'." }, - Overload_signatures_must_all_be_abstract_or_not_abstract: { code: 2512, category: ts.DiagnosticCategory.Error, key: "Overload signatures must all be abstract or not abstract." }, - Abstract_method_0_in_class_1_cannot_be_accessed_via_super_expression: { code: 2513, category: ts.DiagnosticCategory.Error, key: "Abstract method '{0}' in class '{1}' cannot be accessed via super expression." }, - Classes_containing_abstract_methods_must_be_marked_abstract: { code: 2514, category: ts.DiagnosticCategory.Error, key: "Classes containing abstract methods must be marked abstract." }, - Non_abstract_class_0_does_not_implement_inherited_abstract_member_1_from_class_2: { code: 2515, category: ts.DiagnosticCategory.Error, key: "Non-abstract class '{0}' does not implement inherited abstract member '{1}' from class '{2}'." }, - All_declarations_of_an_abstract_method_must_be_consecutive: { code: 2516, category: ts.DiagnosticCategory.Error, key: "All declarations of an abstract method must be consecutive." }, - Cannot_assign_an_abstract_constructor_type_to_a_non_abstract_constructor_type: { code: 2517, category: ts.DiagnosticCategory.Error, key: "Cannot assign an abstract constructor type to a non-abstract constructor type." }, - Duplicate_identifier_0_Compiler_uses_declaration_1_to_support_async_functions: { code: 2520, category: ts.DiagnosticCategory.Error, key: "Duplicate identifier '{0}'. Compiler uses declaration '{1}' to support async functions." }, - Expression_resolves_to_variable_declaration_0_that_compiler_uses_to_support_async_functions: { code: 2521, category: ts.DiagnosticCategory.Error, key: "Expression resolves to variable declaration '{0}' that compiler uses to support async functions." }, - The_arguments_object_cannot_be_referenced_in_an_async_arrow_function_Consider_using_a_standard_async_function_expression: { code: 2522, category: ts.DiagnosticCategory.Error, key: "The 'arguments' object cannot be referenced in an async arrow function. Consider using a standard async function expression." }, - yield_expressions_cannot_be_used_in_a_parameter_initializer: { code: 2523, category: ts.DiagnosticCategory.Error, key: "'yield' expressions cannot be used in a parameter initializer." }, - await_expressions_cannot_be_used_in_a_parameter_initializer: { code: 2524, category: ts.DiagnosticCategory.Error, key: "'await' expressions cannot be used in a parameter initializer." }, - Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value: { code: 2525, category: ts.DiagnosticCategory.Error, key: "Initializer provides no value for this binding element and the binding element has no default value." }, - A_this_type_is_available_only_in_a_non_static_member_of_a_class_or_interface: { code: 2526, category: ts.DiagnosticCategory.Error, key: "A 'this' type is available only in a non-static member of a class or interface." }, - The_inferred_type_of_0_references_an_inaccessible_this_type_A_type_annotation_is_necessary: { code: 2527, category: ts.DiagnosticCategory.Error, key: "The inferred type of '{0}' references an inaccessible 'this' type. A type annotation is necessary." }, - A_module_cannot_have_multiple_default_exports: { code: 2528, category: ts.DiagnosticCategory.Error, key: "A module cannot have multiple default exports." }, - JSX_element_attributes_type_0_must_be_an_object_type: { code: 2600, category: ts.DiagnosticCategory.Error, key: "JSX element attributes type '{0}' must be an object type." }, - The_return_type_of_a_JSX_element_constructor_must_return_an_object_type: { code: 2601, category: ts.DiagnosticCategory.Error, key: "The return type of a JSX element constructor must return an object type." }, - JSX_element_implicitly_has_type_any_because_the_global_type_JSX_Element_does_not_exist: { code: 2602, category: ts.DiagnosticCategory.Error, key: "JSX element implicitly has type 'any' because the global type 'JSX.Element' does not exist." }, - Property_0_in_type_1_is_not_assignable_to_type_2: { code: 2603, category: ts.DiagnosticCategory.Error, key: "Property '{0}' in type '{1}' is not assignable to type '{2}'" }, - JSX_element_type_0_does_not_have_any_construct_or_call_signatures: { code: 2604, category: ts.DiagnosticCategory.Error, key: "JSX element type '{0}' does not have any construct or call signatures." }, - JSX_element_type_0_is_not_a_constructor_function_for_JSX_elements: { code: 2605, category: ts.DiagnosticCategory.Error, key: "JSX element type '{0}' is not a constructor function for JSX elements." }, - Property_0_of_JSX_spread_attribute_is_not_assignable_to_target_property: { code: 2606, category: ts.DiagnosticCategory.Error, key: "Property '{0}' of JSX spread attribute is not assignable to target property." }, - JSX_element_class_does_not_support_attributes_because_it_does_not_have_a_0_property: { code: 2607, category: ts.DiagnosticCategory.Error, key: "JSX element class does not support attributes because it does not have a '{0}' property" }, - The_global_type_JSX_0_may_not_have_more_than_one_property: { code: 2608, category: ts.DiagnosticCategory.Error, key: "The global type 'JSX.{0}' may not have more than one property" }, - Cannot_emit_namespaced_JSX_elements_in_React: { code: 2650, category: ts.DiagnosticCategory.Error, key: "Cannot emit namespaced JSX elements in React" }, - A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_enums: { code: 2651, category: ts.DiagnosticCategory.Error, key: "A member initializer in a enum declaration cannot reference members declared after it, including members defined in other enums." }, - Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_default_0_declaration_instead: { code: 2652, category: ts.DiagnosticCategory.Error, key: "Merged declaration '{0}' cannot include a default export declaration. Consider adding a separate 'export default {0}' declaration instead." }, - Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1: { code: 2653, category: ts.DiagnosticCategory.Error, key: "Non-abstract class expression does not implement inherited abstract member '{0}' from class '{1}'." }, - Exported_external_package_typings_file_cannot_contain_tripleslash_references_Please_contact_the_package_author_to_update_the_package_definition: { code: 2654, category: ts.DiagnosticCategory.Error, key: "Exported external package typings file cannot contain tripleslash references. Please contact the package author to update the package definition." }, - Exported_external_package_typings_can_only_be_in_d_ts_files_Please_contact_the_package_author_to_update_the_package_definition: { code: 2655, category: ts.DiagnosticCategory.Error, key: "Exported external package typings can only be in '.d.ts' files. Please contact the package author to update the package definition." }, - Exported_external_package_typings_file_0_is_not_a_module_Please_contact_the_package_author_to_update_the_package_definition: { code: 2656, category: ts.DiagnosticCategory.Error, key: "Exported external package typings file '{0}' is not a module. Please contact the package author to update the package definition." }, - JSX_expressions_must_have_one_parent_element: { code: 2657, category: ts.DiagnosticCategory.Error, key: "JSX expressions must have one parent element" }, - Import_declaration_0_is_using_private_name_1: { code: 4000, category: ts.DiagnosticCategory.Error, key: "Import declaration '{0}' is using private name '{1}'." }, - Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: { code: 4002, category: ts.DiagnosticCategory.Error, key: "Type parameter '{0}' of exported class has or is using private name '{1}'." }, - Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1: { code: 4004, category: ts.DiagnosticCategory.Error, key: "Type parameter '{0}' of exported interface has or is using private name '{1}'." }, - Type_parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1: { code: 4006, category: ts.DiagnosticCategory.Error, key: "Type parameter '{0}' of constructor signature from exported interface has or is using private name '{1}'." }, - Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1: { code: 4008, category: ts.DiagnosticCategory.Error, key: "Type parameter '{0}' of call signature from exported interface has or is using private name '{1}'." }, - Type_parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1: { code: 4010, category: ts.DiagnosticCategory.Error, key: "Type parameter '{0}' of public static method from exported class has or is using private name '{1}'." }, - Type_parameter_0_of_public_method_from_exported_class_has_or_is_using_private_name_1: { code: 4012, category: ts.DiagnosticCategory.Error, key: "Type parameter '{0}' of public method from exported class has or is using private name '{1}'." }, - Type_parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1: { code: 4014, category: ts.DiagnosticCategory.Error, key: "Type parameter '{0}' of method from exported interface has or is using private name '{1}'." }, - Type_parameter_0_of_exported_function_has_or_is_using_private_name_1: { code: 4016, category: ts.DiagnosticCategory.Error, key: "Type parameter '{0}' of exported function has or is using private name '{1}'." }, - Implements_clause_of_exported_class_0_has_or_is_using_private_name_1: { code: 4019, category: ts.DiagnosticCategory.Error, key: "Implements clause of exported class '{0}' has or is using private name '{1}'." }, - Extends_clause_of_exported_class_0_has_or_is_using_private_name_1: { code: 4020, category: ts.DiagnosticCategory.Error, key: "Extends clause of exported class '{0}' has or is using private name '{1}'." }, - Extends_clause_of_exported_interface_0_has_or_is_using_private_name_1: { code: 4022, category: ts.DiagnosticCategory.Error, key: "Extends clause of exported interface '{0}' has or is using private name '{1}'." }, - Exported_variable_0_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: { code: 4023, category: ts.DiagnosticCategory.Error, key: "Exported variable '{0}' has or is using name '{1}' from external module {2} but cannot be named." }, - Exported_variable_0_has_or_is_using_name_1_from_private_module_2: { code: 4024, category: ts.DiagnosticCategory.Error, key: "Exported variable '{0}' has or is using name '{1}' from private module '{2}'." }, - Exported_variable_0_has_or_is_using_private_name_1: { code: 4025, category: ts.DiagnosticCategory.Error, key: "Exported variable '{0}' has or is using private name '{1}'." }, - Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: { code: 4026, category: ts.DiagnosticCategory.Error, key: "Public static property '{0}' of exported class has or is using name '{1}' from external module {2} but cannot be named." }, - Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2: { code: 4027, category: ts.DiagnosticCategory.Error, key: "Public static property '{0}' of exported class has or is using name '{1}' from private module '{2}'." }, - Public_static_property_0_of_exported_class_has_or_is_using_private_name_1: { code: 4028, category: ts.DiagnosticCategory.Error, key: "Public static property '{0}' of exported class has or is using private name '{1}'." }, - Public_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: { code: 4029, category: ts.DiagnosticCategory.Error, key: "Public property '{0}' of exported class has or is using name '{1}' from external module {2} but cannot be named." }, - Public_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2: { code: 4030, category: ts.DiagnosticCategory.Error, key: "Public property '{0}' of exported class has or is using name '{1}' from private module '{2}'." }, - Public_property_0_of_exported_class_has_or_is_using_private_name_1: { code: 4031, category: ts.DiagnosticCategory.Error, key: "Public property '{0}' of exported class has or is using private name '{1}'." }, - Property_0_of_exported_interface_has_or_is_using_name_1_from_private_module_2: { code: 4032, category: ts.DiagnosticCategory.Error, key: "Property '{0}' of exported interface has or is using name '{1}' from private module '{2}'." }, - Property_0_of_exported_interface_has_or_is_using_private_name_1: { code: 4033, category: ts.DiagnosticCategory.Error, key: "Property '{0}' of exported interface has or is using private name '{1}'." }, - Parameter_0_of_public_static_property_setter_from_exported_class_has_or_is_using_name_1_from_private_module_2: { code: 4034, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' of public static property setter from exported class has or is using name '{1}' from private module '{2}'." }, - Parameter_0_of_public_static_property_setter_from_exported_class_has_or_is_using_private_name_1: { code: 4035, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' of public static property setter from exported class has or is using private name '{1}'." }, - Parameter_0_of_public_property_setter_from_exported_class_has_or_is_using_name_1_from_private_module_2: { code: 4036, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' of public property setter from exported class has or is using name '{1}' from private module '{2}'." }, - Parameter_0_of_public_property_setter_from_exported_class_has_or_is_using_private_name_1: { code: 4037, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' of public property setter from exported class has or is using private name '{1}'." }, - Return_type_of_public_static_property_getter_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named: { code: 4038, category: ts.DiagnosticCategory.Error, key: "Return type of public static property getter from exported class has or is using name '{0}' from external module {1} but cannot be named." }, - Return_type_of_public_static_property_getter_from_exported_class_has_or_is_using_name_0_from_private_module_1: { code: 4039, category: ts.DiagnosticCategory.Error, key: "Return type of public static property getter from exported class has or is using name '{0}' from private module '{1}'." }, - Return_type_of_public_static_property_getter_from_exported_class_has_or_is_using_private_name_0: { code: 4040, category: ts.DiagnosticCategory.Error, key: "Return type of public static property getter from exported class has or is using private name '{0}'." }, - Return_type_of_public_property_getter_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named: { code: 4041, category: ts.DiagnosticCategory.Error, key: "Return type of public property getter from exported class has or is using name '{0}' from external module {1} but cannot be named." }, - Return_type_of_public_property_getter_from_exported_class_has_or_is_using_name_0_from_private_module_1: { code: 4042, category: ts.DiagnosticCategory.Error, key: "Return type of public property getter from exported class has or is using name '{0}' from private module '{1}'." }, - Return_type_of_public_property_getter_from_exported_class_has_or_is_using_private_name_0: { code: 4043, category: ts.DiagnosticCategory.Error, key: "Return type of public property getter from exported class has or is using private name '{0}'." }, - Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1: { code: 4044, category: ts.DiagnosticCategory.Error, key: "Return type of constructor signature from exported interface has or is using name '{0}' from private module '{1}'." }, - Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_0: { code: 4045, category: ts.DiagnosticCategory.Error, key: "Return type of constructor signature from exported interface has or is using private name '{0}'." }, - Return_type_of_call_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1: { code: 4046, category: ts.DiagnosticCategory.Error, key: "Return type of call signature from exported interface has or is using name '{0}' from private module '{1}'." }, - Return_type_of_call_signature_from_exported_interface_has_or_is_using_private_name_0: { code: 4047, category: ts.DiagnosticCategory.Error, key: "Return type of call signature from exported interface has or is using private name '{0}'." }, - Return_type_of_index_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1: { code: 4048, category: ts.DiagnosticCategory.Error, key: "Return type of index signature from exported interface has or is using name '{0}' from private module '{1}'." }, - Return_type_of_index_signature_from_exported_interface_has_or_is_using_private_name_0: { code: 4049, category: ts.DiagnosticCategory.Error, key: "Return type of index signature from exported interface has or is using private name '{0}'." }, - Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named: { code: 4050, category: ts.DiagnosticCategory.Error, key: "Return type of public static method from exported class has or is using name '{0}' from external module {1} but cannot be named." }, - Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_private_module_1: { code: 4051, category: ts.DiagnosticCategory.Error, key: "Return type of public static method from exported class has or is using name '{0}' from private module '{1}'." }, - Return_type_of_public_static_method_from_exported_class_has_or_is_using_private_name_0: { code: 4052, category: ts.DiagnosticCategory.Error, key: "Return type of public static method from exported class has or is using private name '{0}'." }, - Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named: { code: 4053, category: ts.DiagnosticCategory.Error, key: "Return type of public method from exported class has or is using name '{0}' from external module {1} but cannot be named." }, - Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_private_module_1: { code: 4054, category: ts.DiagnosticCategory.Error, key: "Return type of public method from exported class has or is using name '{0}' from private module '{1}'." }, - Return_type_of_public_method_from_exported_class_has_or_is_using_private_name_0: { code: 4055, category: ts.DiagnosticCategory.Error, key: "Return type of public method from exported class has or is using private name '{0}'." }, - Return_type_of_method_from_exported_interface_has_or_is_using_name_0_from_private_module_1: { code: 4056, category: ts.DiagnosticCategory.Error, key: "Return type of method from exported interface has or is using name '{0}' from private module '{1}'." }, - Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0: { code: 4057, category: ts.DiagnosticCategory.Error, key: "Return type of method from exported interface has or is using private name '{0}'." }, - Return_type_of_exported_function_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named: { code: 4058, category: ts.DiagnosticCategory.Error, key: "Return type of exported function has or is using name '{0}' from external module {1} but cannot be named." }, - Return_type_of_exported_function_has_or_is_using_name_0_from_private_module_1: { code: 4059, category: ts.DiagnosticCategory.Error, key: "Return type of exported function has or is using name '{0}' from private module '{1}'." }, - Return_type_of_exported_function_has_or_is_using_private_name_0: { code: 4060, category: ts.DiagnosticCategory.Error, key: "Return type of exported function has or is using private name '{0}'." }, - Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: { code: 4061, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' of constructor from exported class has or is using name '{1}' from external module {2} but cannot be named." }, - Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_private_module_2: { code: 4062, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' of constructor from exported class has or is using name '{1}' from private module '{2}'." }, - Parameter_0_of_constructor_from_exported_class_has_or_is_using_private_name_1: { code: 4063, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' of constructor from exported class has or is using private name '{1}'." }, - Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2: { code: 4064, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' of constructor signature from exported interface has or is using name '{1}' from private module '{2}'." }, - Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1: { code: 4065, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' of constructor signature from exported interface has or is using private name '{1}'." }, - Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2: { code: 4066, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' of call signature from exported interface has or is using name '{1}' from private module '{2}'." }, - Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1: { code: 4067, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' of call signature from exported interface has or is using private name '{1}'." }, - Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: { code: 4068, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' of public static method from exported class has or is using name '{1}' from external module {2} but cannot be named." }, - Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_private_module_2: { code: 4069, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' of public static method from exported class has or is using name '{1}' from private module '{2}'." }, - Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1: { code: 4070, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' of public static method from exported class has or is using private name '{1}'." }, - Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: { code: 4071, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' of public method from exported class has or is using name '{1}' from external module {2} but cannot be named." }, - Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_private_module_2: { code: 4072, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' of public method from exported class has or is using name '{1}' from private module '{2}'." }, - Parameter_0_of_public_method_from_exported_class_has_or_is_using_private_name_1: { code: 4073, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' of public method from exported class has or is using private name '{1}'." }, - Parameter_0_of_method_from_exported_interface_has_or_is_using_name_1_from_private_module_2: { code: 4074, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' of method from exported interface has or is using name '{1}' from private module '{2}'." }, - Parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1: { code: 4075, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' of method from exported interface has or is using private name '{1}'." }, - Parameter_0_of_exported_function_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: { code: 4076, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' of exported function has or is using name '{1}' from external module {2} but cannot be named." }, - Parameter_0_of_exported_function_has_or_is_using_name_1_from_private_module_2: { code: 4077, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' of exported function has or is using name '{1}' from private module '{2}'." }, - Parameter_0_of_exported_function_has_or_is_using_private_name_1: { code: 4078, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' of exported function has or is using private name '{1}'." }, - Exported_type_alias_0_has_or_is_using_private_name_1: { code: 4081, category: ts.DiagnosticCategory.Error, key: "Exported type alias '{0}' has or is using private name '{1}'." }, - Default_export_of_the_module_has_or_is_using_private_name_0: { code: 4082, category: ts.DiagnosticCategory.Error, key: "Default export of the module has or is using private name '{0}'." }, - Loop_contains_block_scoped_variable_0_referenced_by_a_function_in_the_loop_This_is_only_supported_in_ECMAScript_6_or_higher: { code: 4091, category: ts.DiagnosticCategory.Error, key: "Loop contains block-scoped variable '{0}' referenced by a function in the loop. This is only supported in ECMAScript 6 or higher." }, - The_current_host_does_not_support_the_0_option: { code: 5001, category: ts.DiagnosticCategory.Error, key: "The current host does not support the '{0}' option." }, - Cannot_find_the_common_subdirectory_path_for_the_input_files: { code: 5009, category: ts.DiagnosticCategory.Error, key: "Cannot find the common subdirectory path for the input files." }, - Cannot_read_file_0_Colon_1: { code: 5012, category: ts.DiagnosticCategory.Error, key: "Cannot read file '{0}': {1}" }, - Unsupported_file_encoding: { code: 5013, category: ts.DiagnosticCategory.Error, key: "Unsupported file encoding." }, - Failed_to_parse_file_0_Colon_1: { code: 5014, category: ts.DiagnosticCategory.Error, key: "Failed to parse file '{0}': {1}." }, - Unknown_compiler_option_0: { code: 5023, category: ts.DiagnosticCategory.Error, key: "Unknown compiler option '{0}'." }, - Compiler_option_0_requires_a_value_of_type_1: { code: 5024, category: ts.DiagnosticCategory.Error, key: "Compiler option '{0}' requires a value of type {1}." }, - Could_not_write_file_0_Colon_1: { code: 5033, category: ts.DiagnosticCategory.Error, key: "Could not write file '{0}': {1}" }, - Option_project_cannot_be_mixed_with_source_files_on_a_command_line: { code: 5042, category: ts.DiagnosticCategory.Error, key: "Option 'project' cannot be mixed with source files on a command line." }, - Option_isolatedModules_can_only_be_used_when_either_option_module_is_provided_or_option_target_is_ES2015_or_higher: { code: 5047, category: ts.DiagnosticCategory.Error, key: "Option 'isolatedModules' can only be used when either option '--module' is provided or option 'target' is 'ES2015' or higher." }, - Option_inlineSources_can_only_be_used_when_either_option_inlineSourceMap_or_option_sourceMap_is_provided: { code: 5051, category: ts.DiagnosticCategory.Error, key: "Option 'inlineSources' can only be used when either option '--inlineSourceMap' or option '--sourceMap' is provided." }, - Option_0_cannot_be_specified_without_specifying_option_1: { code: 5052, category: ts.DiagnosticCategory.Error, key: "Option '{0}' cannot be specified without specifying option '{1}'." }, - Option_0_cannot_be_specified_with_option_1: { code: 5053, category: ts.DiagnosticCategory.Error, key: "Option '{0}' cannot be specified with option '{1}'." }, - A_tsconfig_json_file_is_already_defined_at_Colon_0: { code: 5054, category: ts.DiagnosticCategory.Error, key: "A 'tsconfig.json' file is already defined at: '{0}'." }, - Concatenate_and_emit_output_to_single_file: { code: 6001, category: ts.DiagnosticCategory.Message, key: "Concatenate and emit output to single file." }, - Generates_corresponding_d_ts_file: { code: 6002, category: ts.DiagnosticCategory.Message, key: "Generates corresponding '.d.ts' file." }, - Specifies_the_location_where_debugger_should_locate_map_files_instead_of_generated_locations: { code: 6003, category: ts.DiagnosticCategory.Message, key: "Specifies the location where debugger should locate map files instead of generated locations." }, - Specifies_the_location_where_debugger_should_locate_TypeScript_files_instead_of_source_locations: { code: 6004, category: ts.DiagnosticCategory.Message, key: "Specifies the location where debugger should locate TypeScript files instead of source locations." }, - Watch_input_files: { code: 6005, category: ts.DiagnosticCategory.Message, key: "Watch input files." }, - Redirect_output_structure_to_the_directory: { code: 6006, category: ts.DiagnosticCategory.Message, key: "Redirect output structure to the directory." }, - Do_not_erase_const_enum_declarations_in_generated_code: { code: 6007, category: ts.DiagnosticCategory.Message, key: "Do not erase const enum declarations in generated code." }, - Do_not_emit_outputs_if_any_errors_were_reported: { code: 6008, category: ts.DiagnosticCategory.Message, key: "Do not emit outputs if any errors were reported." }, - Do_not_emit_comments_to_output: { code: 6009, category: ts.DiagnosticCategory.Message, key: "Do not emit comments to output." }, - Do_not_emit_outputs: { code: 6010, category: ts.DiagnosticCategory.Message, key: "Do not emit outputs." }, - Specify_ECMAScript_target_version_Colon_ES3_default_ES5_or_ES2015_experimental: { code: 6015, category: ts.DiagnosticCategory.Message, key: "Specify ECMAScript target version: 'ES3' (default), 'ES5', or 'ES2015' (experimental)" }, - Specify_module_code_generation_Colon_commonjs_amd_system_umd_or_es2015: { code: 6016, category: ts.DiagnosticCategory.Message, key: "Specify module code generation: 'commonjs', 'amd', 'system', 'umd' or 'es2015'" }, - Print_this_message: { code: 6017, category: ts.DiagnosticCategory.Message, key: "Print this message." }, - Print_the_compiler_s_version: { code: 6019, category: ts.DiagnosticCategory.Message, key: "Print the compiler's version." }, - Compile_the_project_in_the_given_directory: { code: 6020, category: ts.DiagnosticCategory.Message, key: "Compile the project in the given directory." }, - Syntax_Colon_0: { code: 6023, category: ts.DiagnosticCategory.Message, key: "Syntax: {0}" }, - options: { code: 6024, category: ts.DiagnosticCategory.Message, key: "options" }, - file: { code: 6025, category: ts.DiagnosticCategory.Message, key: "file" }, - Examples_Colon_0: { code: 6026, category: ts.DiagnosticCategory.Message, key: "Examples: {0}" }, - Options_Colon: { code: 6027, category: ts.DiagnosticCategory.Message, key: "Options:" }, - Version_0: { code: 6029, category: ts.DiagnosticCategory.Message, key: "Version {0}" }, - Insert_command_line_options_and_files_from_a_file: { code: 6030, category: ts.DiagnosticCategory.Message, key: "Insert command line options and files from a file." }, - File_change_detected_Starting_incremental_compilation: { code: 6032, category: ts.DiagnosticCategory.Message, key: "File change detected. Starting incremental compilation..." }, - KIND: { code: 6034, category: ts.DiagnosticCategory.Message, key: "KIND" }, - FILE: { code: 6035, category: ts.DiagnosticCategory.Message, key: "FILE" }, - VERSION: { code: 6036, category: ts.DiagnosticCategory.Message, key: "VERSION" }, - LOCATION: { code: 6037, category: ts.DiagnosticCategory.Message, key: "LOCATION" }, - DIRECTORY: { code: 6038, category: ts.DiagnosticCategory.Message, key: "DIRECTORY" }, - Compilation_complete_Watching_for_file_changes: { code: 6042, category: ts.DiagnosticCategory.Message, key: "Compilation complete. Watching for file changes." }, - Generates_corresponding_map_file: { code: 6043, category: ts.DiagnosticCategory.Message, key: "Generates corresponding '.map' file." }, - Compiler_option_0_expects_an_argument: { code: 6044, category: ts.DiagnosticCategory.Error, key: "Compiler option '{0}' expects an argument." }, - Unterminated_quoted_string_in_response_file_0: { code: 6045, category: ts.DiagnosticCategory.Error, key: "Unterminated quoted string in response file '{0}'." }, - Argument_for_module_option_must_be_commonjs_amd_system_umd_or_es2015: { code: 6046, category: ts.DiagnosticCategory.Error, key: "Argument for '--module' option must be 'commonjs', 'amd', 'system', 'umd', or 'es2015'." }, - Argument_for_target_option_must_be_ES3_ES5_or_ES2015: { code: 6047, category: ts.DiagnosticCategory.Error, key: "Argument for '--target' option must be 'ES3', 'ES5', or 'ES2015'." }, - Locale_must_be_of_the_form_language_or_language_territory_For_example_0_or_1: { code: 6048, category: ts.DiagnosticCategory.Error, key: "Locale must be of the form or -. For example '{0}' or '{1}'." }, - Unsupported_locale_0: { code: 6049, category: ts.DiagnosticCategory.Error, key: "Unsupported locale '{0}'." }, - Unable_to_open_file_0: { code: 6050, category: ts.DiagnosticCategory.Error, key: "Unable to open file '{0}'." }, - Corrupted_locale_file_0: { code: 6051, category: ts.DiagnosticCategory.Error, key: "Corrupted locale file {0}." }, - Raise_error_on_expressions_and_declarations_with_an_implied_any_type: { code: 6052, category: ts.DiagnosticCategory.Message, key: "Raise error on expressions and declarations with an implied 'any' type." }, - File_0_not_found: { code: 6053, category: ts.DiagnosticCategory.Error, key: "File '{0}' not found." }, - File_0_has_unsupported_extension_The_only_supported_extensions_are_1: { code: 6054, category: ts.DiagnosticCategory.Error, key: "File '{0}' has unsupported extension. The only supported extensions are {1}." }, - Suppress_noImplicitAny_errors_for_indexing_objects_lacking_index_signatures: { code: 6055, category: ts.DiagnosticCategory.Message, key: "Suppress noImplicitAny errors for indexing objects lacking index signatures." }, - Do_not_emit_declarations_for_code_that_has_an_internal_annotation: { code: 6056, category: ts.DiagnosticCategory.Message, key: "Do not emit declarations for code that has an '@internal' annotation." }, - Specifies_the_root_directory_of_input_files_Use_to_control_the_output_directory_structure_with_outDir: { code: 6058, category: ts.DiagnosticCategory.Message, key: "Specifies the root directory of input files. Use to control the output directory structure with --outDir." }, - File_0_is_not_under_rootDir_1_rootDir_is_expected_to_contain_all_source_files: { code: 6059, category: ts.DiagnosticCategory.Error, key: "File '{0}' is not under 'rootDir' '{1}'. 'rootDir' is expected to contain all source files." }, - Specifies_the_end_of_line_sequence_to_be_used_when_emitting_files_Colon_CRLF_dos_or_LF_unix: { code: 6060, category: ts.DiagnosticCategory.Message, key: "Specifies the end of line sequence to be used when emitting files: 'CRLF' (dos) or 'LF' (unix)." }, - NEWLINE: { code: 6061, category: ts.DiagnosticCategory.Message, key: "NEWLINE" }, - Argument_for_newLine_option_must_be_CRLF_or_LF: { code: 6062, category: ts.DiagnosticCategory.Error, key: "Argument for '--newLine' option must be 'CRLF' or 'LF'." }, - Argument_for_moduleResolution_option_must_be_node_or_classic: { code: 6063, category: ts.DiagnosticCategory.Error, key: "Argument for '--moduleResolution' option must be 'node' or 'classic'." }, - Specify_JSX_code_generation_Colon_preserve_or_react: { code: 6080, category: ts.DiagnosticCategory.Message, key: "Specify JSX code generation: 'preserve' or 'react'" }, - Argument_for_jsx_must_be_preserve_or_react: { code: 6081, category: ts.DiagnosticCategory.Message, key: "Argument for '--jsx' must be 'preserve' or 'react'." }, - Enables_experimental_support_for_ES7_decorators: { code: 6065, category: ts.DiagnosticCategory.Message, key: "Enables experimental support for ES7 decorators." }, - Enables_experimental_support_for_emitting_type_metadata_for_decorators: { code: 6066, category: ts.DiagnosticCategory.Message, key: "Enables experimental support for emitting type metadata for decorators." }, - Enables_experimental_support_for_ES7_async_functions: { code: 6068, category: ts.DiagnosticCategory.Message, key: "Enables experimental support for ES7 async functions." }, - Specifies_module_resolution_strategy_Colon_node_Node_js_or_classic_TypeScript_pre_1_6: { code: 6069, category: ts.DiagnosticCategory.Message, key: "Specifies module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6)." }, - Initializes_a_TypeScript_project_and_creates_a_tsconfig_json_file: { code: 6070, category: ts.DiagnosticCategory.Message, key: "Initializes a TypeScript project and creates a tsconfig.json file." }, - Successfully_created_a_tsconfig_json_file: { code: 6071, category: ts.DiagnosticCategory.Message, key: "Successfully created a tsconfig.json file." }, - Suppress_excess_property_checks_for_object_literals: { code: 6072, category: ts.DiagnosticCategory.Message, key: "Suppress excess property checks for object literals." }, - Variable_0_implicitly_has_an_1_type: { code: 7005, category: ts.DiagnosticCategory.Error, key: "Variable '{0}' implicitly has an '{1}' type." }, - Parameter_0_implicitly_has_an_1_type: { code: 7006, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' implicitly has an '{1}' type." }, - Member_0_implicitly_has_an_1_type: { code: 7008, category: ts.DiagnosticCategory.Error, key: "Member '{0}' implicitly has an '{1}' type." }, - new_expression_whose_target_lacks_a_construct_signature_implicitly_has_an_any_type: { code: 7009, category: ts.DiagnosticCategory.Error, key: "'new' expression, whose target lacks a construct signature, implicitly has an 'any' type." }, - _0_which_lacks_return_type_annotation_implicitly_has_an_1_return_type: { code: 7010, category: ts.DiagnosticCategory.Error, key: "'{0}', which lacks return-type annotation, implicitly has an '{1}' return type." }, - Function_expression_which_lacks_return_type_annotation_implicitly_has_an_0_return_type: { code: 7011, category: ts.DiagnosticCategory.Error, key: "Function expression, which lacks return-type annotation, implicitly has an '{0}' return type." }, - Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type: { code: 7013, category: ts.DiagnosticCategory.Error, key: "Construct signature, which lacks return-type annotation, implicitly has an 'any' return type." }, - Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_type_annotation: { code: 7016, category: ts.DiagnosticCategory.Error, key: "Property '{0}' implicitly has type 'any', because its 'set' accessor lacks a type annotation." }, - Index_signature_of_object_type_implicitly_has_an_any_type: { code: 7017, category: ts.DiagnosticCategory.Error, key: "Index signature of object type implicitly has an 'any' type." }, - Object_literal_s_property_0_implicitly_has_an_1_type: { code: 7018, category: ts.DiagnosticCategory.Error, key: "Object literal's property '{0}' implicitly has an '{1}' type." }, - Rest_parameter_0_implicitly_has_an_any_type: { code: 7019, category: ts.DiagnosticCategory.Error, key: "Rest parameter '{0}' implicitly has an 'any[]' type." }, - Call_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type: { code: 7020, category: ts.DiagnosticCategory.Error, key: "Call signature, which lacks return-type annotation, implicitly has an 'any' return type." }, - _0_implicitly_has_type_any_because_it_does_not_have_a_type_annotation_and_is_referenced_directly_or_indirectly_in_its_own_initializer: { code: 7022, category: ts.DiagnosticCategory.Error, key: "'{0}' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer." }, - _0_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions: { code: 7023, category: ts.DiagnosticCategory.Error, key: "'{0}' implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions." }, - Function_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions: { code: 7024, category: ts.DiagnosticCategory.Error, key: "Function implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions." }, - Generator_implicitly_has_type_0_because_it_does_not_yield_any_values_Consider_supplying_a_return_type: { code: 7025, category: ts.DiagnosticCategory.Error, key: "Generator implicitly has type '{0}' because it does not yield any values. Consider supplying a return type." }, - JSX_element_implicitly_has_type_any_because_no_interface_JSX_0_exists: { code: 7026, category: ts.DiagnosticCategory.Error, key: "JSX element implicitly has type 'any' because no interface 'JSX.{0}' exists" }, - You_cannot_rename_this_element: { code: 8000, category: ts.DiagnosticCategory.Error, key: "You cannot rename this element." }, - You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library: { code: 8001, category: ts.DiagnosticCategory.Error, key: "You cannot rename elements that are defined in the standard TypeScript library." }, - 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." }, - export_can_only_be_used_in_a_ts_file: { code: 8003, category: ts.DiagnosticCategory.Error, key: "'export=' can only be used in a .ts file." }, - type_parameter_declarations_can_only_be_used_in_a_ts_file: { code: 8004, category: ts.DiagnosticCategory.Error, key: "'type parameter declarations' can only be used in a .ts file." }, - implements_clauses_can_only_be_used_in_a_ts_file: { code: 8005, category: ts.DiagnosticCategory.Error, key: "'implements clauses' can only be used in a .ts file." }, - interface_declarations_can_only_be_used_in_a_ts_file: { code: 8006, category: ts.DiagnosticCategory.Error, key: "'interface declarations' can only be used in a .ts file." }, - module_declarations_can_only_be_used_in_a_ts_file: { code: 8007, category: ts.DiagnosticCategory.Error, key: "'module declarations' can only be used in a .ts file." }, - type_aliases_can_only_be_used_in_a_ts_file: { code: 8008, category: ts.DiagnosticCategory.Error, key: "'type aliases' can only be used in a .ts file." }, - _0_can_only_be_used_in_a_ts_file: { code: 8009, category: ts.DiagnosticCategory.Error, key: "'{0}' can only be used in a .ts file." }, - types_can_only_be_used_in_a_ts_file: { code: 8010, category: ts.DiagnosticCategory.Error, key: "'types' can only be used in a .ts file." }, - type_arguments_can_only_be_used_in_a_ts_file: { code: 8011, category: ts.DiagnosticCategory.Error, key: "'type arguments' can only be used in a .ts file." }, - parameter_modifiers_can_only_be_used_in_a_ts_file: { code: 8012, category: ts.DiagnosticCategory.Error, key: "'parameter modifiers' can only be used in a .ts file." }, - property_declarations_can_only_be_used_in_a_ts_file: { code: 8014, category: ts.DiagnosticCategory.Error, key: "'property declarations' can only be used in a .ts file." }, - enum_declarations_can_only_be_used_in_a_ts_file: { code: 8015, category: ts.DiagnosticCategory.Error, key: "'enum declarations' can only be used in a .ts file." }, - type_assertion_expressions_can_only_be_used_in_a_ts_file: { code: 8016, category: ts.DiagnosticCategory.Error, key: "'type assertion expressions' can only be used in a .ts file." }, - decorators_can_only_be_used_in_a_ts_file: { code: 8017, category: ts.DiagnosticCategory.Error, key: "'decorators' can only be used in a .ts file." }, - Only_identifiers_Slashqualified_names_with_optional_type_arguments_are_currently_supported_in_a_class_extends_clauses: { code: 9002, category: ts.DiagnosticCategory.Error, key: "Only identifiers/qualified-names with optional type arguments are currently supported in a class 'extends' clauses." }, - class_expressions_are_not_currently_supported: { code: 9003, category: ts.DiagnosticCategory.Error, key: "'class' expressions are not currently supported." }, - JSX_attributes_must_only_be_assigned_a_non_empty_expression: { code: 17000, category: ts.DiagnosticCategory.Error, key: "JSX attributes must only be assigned a non-empty 'expression'." }, - JSX_elements_cannot_have_multiple_attributes_with_the_same_name: { code: 17001, category: ts.DiagnosticCategory.Error, key: "JSX elements cannot have multiple attributes with the same name." }, - Expected_corresponding_JSX_closing_tag_for_0: { code: 17002, category: ts.DiagnosticCategory.Error, key: "Expected corresponding JSX closing tag for '{0}'." }, - JSX_attribute_expected: { code: 17003, category: ts.DiagnosticCategory.Error, key: "JSX attribute expected." }, - Cannot_use_JSX_unless_the_jsx_flag_is_provided: { code: 17004, category: ts.DiagnosticCategory.Error, key: "Cannot use JSX unless the '--jsx' flag is provided." }, - A_constructor_cannot_contain_a_super_call_when_its_class_extends_null: { code: 17005, category: ts.DiagnosticCategory.Error, key: "A constructor cannot contain a 'super' call when its class extends 'null'" }, - An_unary_expression_with_the_0_operator_is_not_allowed_in_the_left_hand_side_of_an_exponentiation_expression_Consider_enclosing_the_expression_in_parentheses: { code: 17006, category: ts.DiagnosticCategory.Error, key: "An unary expression with the '{0}' operator is not allowed in the left-hand side of an exponentiation expression. Consider enclosing the expression in parentheses." }, - A_type_assertion_expression_is_not_allowed_in_the_left_hand_side_of_an_exponentiation_expression_Consider_enclosing_the_expression_in_parentheses: { code: 17007, category: ts.DiagnosticCategory.Error, key: "A type assertion expression is not allowed in the left-hand side of an exponentiation expression. Consider enclosing the expression in parentheses." } - }; -})(ts || (ts = {})); -/// -/// -var ts; -(function (ts) { - /* @internal */ - function tokenIsIdentifierOrKeyword(token) { - return token >= 69 /* Identifier */; - } - ts.tokenIsIdentifierOrKeyword = tokenIsIdentifierOrKeyword; - var textToToken = { - "abstract": 115 /* AbstractKeyword */, - "any": 117 /* AnyKeyword */, - "as": 116 /* AsKeyword */, - "boolean": 120 /* BooleanKeyword */, - "break": 70 /* BreakKeyword */, - "case": 71 /* CaseKeyword */, - "catch": 72 /* CatchKeyword */, - "class": 73 /* ClassKeyword */, - "continue": 75 /* ContinueKeyword */, - "const": 74 /* ConstKeyword */, - "constructor": 121 /* ConstructorKeyword */, - "debugger": 76 /* DebuggerKeyword */, - "declare": 122 /* DeclareKeyword */, - "default": 77 /* DefaultKeyword */, - "delete": 78 /* DeleteKeyword */, - "do": 79 /* DoKeyword */, - "else": 80 /* ElseKeyword */, - "enum": 81 /* EnumKeyword */, - "export": 82 /* ExportKeyword */, - "extends": 83 /* ExtendsKeyword */, - "false": 84 /* FalseKeyword */, - "finally": 85 /* FinallyKeyword */, - "for": 86 /* ForKeyword */, - "from": 133 /* FromKeyword */, - "function": 87 /* FunctionKeyword */, - "get": 123 /* GetKeyword */, - "if": 88 /* IfKeyword */, - "implements": 106 /* ImplementsKeyword */, - "import": 89 /* ImportKeyword */, - "in": 90 /* InKeyword */, - "instanceof": 91 /* InstanceOfKeyword */, - "interface": 107 /* InterfaceKeyword */, - "is": 124 /* IsKeyword */, - "let": 108 /* LetKeyword */, - "module": 125 /* ModuleKeyword */, - "namespace": 126 /* NamespaceKeyword */, - "new": 92 /* NewKeyword */, - "null": 93 /* NullKeyword */, - "number": 128 /* NumberKeyword */, - "package": 109 /* PackageKeyword */, - "private": 110 /* PrivateKeyword */, - "protected": 111 /* ProtectedKeyword */, - "public": 112 /* PublicKeyword */, - "require": 127 /* RequireKeyword */, - "return": 94 /* ReturnKeyword */, - "set": 129 /* SetKeyword */, - "static": 113 /* StaticKeyword */, - "string": 130 /* StringKeyword */, - "super": 95 /* SuperKeyword */, - "switch": 96 /* SwitchKeyword */, - "symbol": 131 /* SymbolKeyword */, - "this": 97 /* ThisKeyword */, - "throw": 98 /* ThrowKeyword */, - "true": 99 /* TrueKeyword */, - "try": 100 /* TryKeyword */, - "type": 132 /* TypeKeyword */, - "typeof": 101 /* TypeOfKeyword */, - "var": 102 /* VarKeyword */, - "void": 103 /* VoidKeyword */, - "while": 104 /* WhileKeyword */, - "with": 105 /* WithKeyword */, - "yield": 114 /* YieldKeyword */, - "async": 118 /* AsyncKeyword */, - "await": 119 /* AwaitKeyword */, - "of": 134 /* OfKeyword */, - "{": 15 /* OpenBraceToken */, - "}": 16 /* CloseBraceToken */, - "(": 17 /* OpenParenToken */, - ")": 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 */ - }; - /* - As per ECMAScript Language Specification 3th Edition, Section 7.6: Identifiers - IdentifierStart :: - Can contain Unicode 3.0.0 categories: - Uppercase letter (Lu), - Lowercase letter (Ll), - Titlecase letter (Lt), - Modifier letter (Lm), - Other letter (Lo), or - Letter number (Nl). - IdentifierPart :: = - Can contain IdentifierStart + Unicode 3.0.0 categories: - Non-spacing mark (Mn), - Combining spacing mark (Mc), - Decimal number (Nd), or - Connector punctuation (Pc). - - Codepoint ranges for ES3 Identifiers are extracted from the Unicode 3.0.0 specification at: - http://www.unicode.org/Public/3.0-Update/UnicodeData-3.0.0.txt - */ - 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,]; - /* - As per ECMAScript Language Specification 5th Edition, Section 7.6: ISyntaxToken Names and Identifiers - IdentifierStart :: - Can contain Unicode 6.2 categories: - Uppercase letter (Lu), - Lowercase letter (Ll), - Titlecase letter (Lt), - Modifier letter (Lm), - Other letter (Lo), or - Letter number (Nl). - IdentifierPart :: - Can contain IdentifierStart + Unicode 6.2 categories: - Non-spacing mark (Mn), - Combining spacing mark (Mc), - Decimal number (Nd), - Connector punctuation (Pc), - , or - . - - Codepoint ranges for ES5 Identifiers are extracted from the Unicode 6.2 specification at: - http://www.unicode.org/Public/6.2.0/ucd/UnicodeData.txt - */ - 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) { - // Bail out quickly if it couldn't possibly be in the map. - if (code < map[0]) { - return false; - } - // Perform binary search in one of the Unicode range maps - var lo = 0; - var hi = map.length; - var mid; - while (lo + 1 < hi) { - mid = lo + (hi - lo) / 2; - // mid has to be even to catch a range's beginning - 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; - } - /* @internal */ function isUnicodeIdentifierStart(code, languageVersion) { - return languageVersion >= 1 /* ES5 */ ? - lookupInUnicodeMap(code, unicodeES5IdentifierStart) : - lookupInUnicodeMap(code, unicodeES3IdentifierStart); - } - ts.isUnicodeIdentifierStart = isUnicodeIdentifierStart; - function isUnicodeIdentifierPart(code, languageVersion) { - return languageVersion >= 1 /* ES5 */ ? - lookupInUnicodeMap(code, unicodeES5IdentifierPart) : - lookupInUnicodeMap(code, unicodeES3IdentifierPart); - } - function makeReverseMap(source) { - var result = []; - for (var name_4 in source) { - if (source.hasOwnProperty(name_4)) { - result[source[name_4]] = name_4; - } - } - return result; - } - var tokenStrings = makeReverseMap(textToToken); - function tokenToString(t) { - return tokenStrings[t]; - } - ts.tokenToString = tokenToString; - /* @internal */ - function stringToToken(s) { - return textToToken[s]; - } - ts.stringToToken = stringToToken; - /* @internal */ - function computeLineStarts(text) { - var result = new Array(); - var pos = 0; - var lineStart = 0; - while (pos < text.length) { - var ch = text.charCodeAt(pos++); - switch (ch) { - case 13 /* carriageReturn */: - if (text.charCodeAt(pos) === 10 /* lineFeed */) { - pos++; - } - case 10 /* lineFeed */: - result.push(lineStart); - lineStart = pos; - break; - default: - if (ch > 127 /* maxAsciiCharacter */ && 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; - /* @internal */ - function computePositionOfLineAndCharacter(lineStarts, line, character) { - ts.Debug.assert(line >= 0 && line < lineStarts.length); - return lineStarts[line] + character; - } - ts.computePositionOfLineAndCharacter = computePositionOfLineAndCharacter; - /* @internal */ - function getLineStarts(sourceFile) { - return sourceFile.lineMap || (sourceFile.lineMap = computeLineStarts(sourceFile.text)); - } - ts.getLineStarts = getLineStarts; - /* @internal */ - /** - * We assume the first line starts at position 0 and 'position' is non-negative. - */ - function computeLineAndCharacterOfPosition(lineStarts, position) { - var lineNumber = ts.binarySearch(lineStarts, position); - if (lineNumber < 0) { - // If the actual position was not found, - // the binary search returns the 2's-complement of the next line start - // e.g. if the line starts at [5, 10, 23, 80] and the position requested was 20 - // then the search will return -2. - // - // We want the index of the previous line start, so we subtract 1. - // Review 2's-complement if this is confusing. - 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) { - // Note: nextLine is in the Zs space, and should be considered to be a whitespace. - // It is explicitly not a line-break as it isn't in the exact set specified by EcmaScript. - return ch === 32 /* space */ || - ch === 9 /* tab */ || - ch === 11 /* verticalTab */ || - ch === 12 /* formFeed */ || - ch === 160 /* nonBreakingSpace */ || - ch === 133 /* nextLine */ || - ch === 5760 /* ogham */ || - ch >= 8192 /* enQuad */ && ch <= 8203 /* zeroWidthSpace */ || - ch === 8239 /* narrowNoBreakSpace */ || - ch === 8287 /* mathematicalSpace */ || - ch === 12288 /* ideographicSpace */ || - ch === 65279 /* byteOrderMark */; - } - ts.isWhiteSpace = isWhiteSpace; - function isLineBreak(ch) { - // ES5 7.3: - // The ECMAScript line terminator characters are listed in Table 3. - // Table 3: Line Terminator Characters - // Code Unit Value Name Formal Name - // \u000A Line Feed - // \u000D Carriage Return - // \u2028 Line separator - // \u2029 Paragraph separator - // Only the characters in Table 3 are treated as line terminators. Other new line or line - // breaking characters are treated as white space but not as line terminators. - return ch === 10 /* lineFeed */ || - ch === 13 /* carriageReturn */ || - ch === 8232 /* lineSeparator */ || - ch === 8233 /* paragraphSeparator */; - } - ts.isLineBreak = isLineBreak; - function isDigit(ch) { - return ch >= 48 /* _0 */ && ch <= 57 /* _9 */; - } - /* @internal */ - function isOctalDigit(ch) { - return ch >= 48 /* _0 */ && ch <= 55 /* _7 */; - } - ts.isOctalDigit = isOctalDigit; - function couldStartTrivia(text, pos) { - // Keep in sync with skipTrivia - var ch = text.charCodeAt(pos); - switch (ch) { - case 13 /* carriageReturn */: - case 10 /* lineFeed */: - case 9 /* tab */: - case 11 /* verticalTab */: - case 12 /* formFeed */: - case 32 /* space */: - case 47 /* slash */: - // starts of normal trivia - case 60 /* lessThan */: - case 61 /* equals */: - case 62 /* greaterThan */: - // Starts of conflict marker trivia - return true; - case 35 /* hash */: - // Only if its the beginning can we have #! trivia - return pos === 0; - default: - return ch > 127 /* maxAsciiCharacter */; - } - } - ts.couldStartTrivia = couldStartTrivia; - /* @internal */ - function skipTrivia(text, pos, stopAfterLineBreak) { - // Keep in sync with couldStartTrivia - while (true) { - var ch = text.charCodeAt(pos); - switch (ch) { - case 13 /* carriageReturn */: - if (text.charCodeAt(pos + 1) === 10 /* lineFeed */) { - pos++; - } - case 10 /* lineFeed */: - pos++; - if (stopAfterLineBreak) { - return pos; - } - continue; - case 9 /* tab */: - case 11 /* verticalTab */: - case 12 /* formFeed */: - case 32 /* space */: - pos++; - continue; - case 47 /* slash */: - if (text.charCodeAt(pos + 1) === 47 /* slash */) { - pos += 2; - while (pos < text.length) { - if (isLineBreak(text.charCodeAt(pos))) { - break; - } - pos++; - } - continue; - } - if (text.charCodeAt(pos + 1) === 42 /* asterisk */) { - pos += 2; - while (pos < text.length) { - if (text.charCodeAt(pos) === 42 /* asterisk */ && text.charCodeAt(pos + 1) === 47 /* slash */) { - pos += 2; - break; - } - pos++; - } - continue; - } - break; - case 60 /* lessThan */: - case 61 /* equals */: - case 62 /* greaterThan */: - if (isConflictMarkerTrivia(text, pos)) { - pos = scanConflictMarkerTrivia(text, pos); - continue; - } - break; - case 35 /* hash */: - if (pos === 0 && isShebangTrivia(text, pos)) { - pos = scanShebangTrivia(text, pos); - continue; - } - break; - default: - if (ch > 127 /* maxAsciiCharacter */ && (isWhiteSpace(ch) || isLineBreak(ch))) { - pos++; - continue; - } - break; - } - return pos; - } - } - ts.skipTrivia = skipTrivia; - // All conflict markers consist of the same character repeated seven times. If it is - // a <<<<<<< or >>>>>>> marker then it is also followd by a space. - var mergeConflictMarkerLength = "<<<<<<<".length; - function isConflictMarkerTrivia(text, pos) { - ts.Debug.assert(pos >= 0); - // Conflict markers must be at the start of a line. - 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 /* equals */ || - text.charCodeAt(pos + mergeConflictMarkerLength) === 32 /* space */; - } - } - 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 /* lessThan */ || ch === 62 /* greaterThan */) { - while (pos < len && !isLineBreak(text.charCodeAt(pos))) { - pos++; - } - } - else { - ts.Debug.assert(ch === 61 /* equals */); - // Consume everything from the start of the mid-conlict marker to the start of the next - // end-conflict marker. - while (pos < len) { - var ch_1 = text.charCodeAt(pos); - if (ch_1 === 62 /* greaterThan */ && isConflictMarkerTrivia(text, pos)) { - break; - } - pos++; - } - } - return pos; - } - var shebangTriviaRegex = /^#!.*/; - function isShebangTrivia(text, pos) { - // Shebangs check must only be done at the start of the file - 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; - } - /** - * Extract comments from text prefixing the token closest following `pos`. - * The return value is an array containing a TextRange for each comment. - * Single-line comment ranges include the beginning '//' characters but not the ending line break. - * Multi - line comment ranges include the beginning '/* and ending '/' characters. - * The return value is undefined if no comments were found. - * @param trailing - * If false, whitespace is skipped until the first line break and comments between that location - * and the next token are returned. - * If true, comments occurring between the given position and the next line break are returned. - */ - function getCommentRanges(text, pos, trailing) { - var result; - var collecting = trailing || pos === 0; - while (true) { - var ch = text.charCodeAt(pos); - switch (ch) { - case 13 /* carriageReturn */: - if (text.charCodeAt(pos + 1) === 10 /* lineFeed */) { - pos++; - } - case 10 /* lineFeed */: - pos++; - if (trailing) { - return result; - } - collecting = true; - if (result && result.length) { - ts.lastOrUndefined(result).hasTrailingNewLine = true; - } - continue; - case 9 /* tab */: - case 11 /* verticalTab */: - case 12 /* formFeed */: - case 32 /* space */: - pos++; - continue; - case 47 /* slash */: - var nextChar = text.charCodeAt(pos + 1); - var hasTrailingNewLine = false; - if (nextChar === 47 /* slash */ || nextChar === 42 /* asterisk */) { - var kind = nextChar === 47 /* slash */ ? 2 /* SingleLineCommentTrivia */ : 3 /* MultiLineCommentTrivia */; - var startPos = pos; - pos += 2; - if (nextChar === 47 /* slash */) { - while (pos < text.length) { - if (isLineBreak(text.charCodeAt(pos))) { - hasTrailingNewLine = true; - break; - } - pos++; - } - } - else { - while (pos < text.length) { - if (text.charCodeAt(pos) === 42 /* asterisk */ && text.charCodeAt(pos + 1) === 47 /* slash */) { - pos += 2; - break; - } - pos++; - } - } - if (collecting) { - if (!result) { - result = []; - } - result.push({ pos: startPos, end: pos, hasTrailingNewLine: hasTrailingNewLine, kind: kind }); - } - continue; - } - break; - default: - if (ch > 127 /* maxAsciiCharacter */ && (isWhiteSpace(ch) || isLineBreak(ch))) { - if (result && result.length && isLineBreak(ch)) { - ts.lastOrUndefined(result).hasTrailingNewLine = true; - } - pos++; - continue; - } - break; - } - return result; - } - } - function getLeadingCommentRanges(text, pos) { - return getCommentRanges(text, pos, /*trailing*/ false); - } - ts.getLeadingCommentRanges = getLeadingCommentRanges; - function getTrailingCommentRanges(text, pos) { - return getCommentRanges(text, pos, /*trailing*/ true); - } - ts.getTrailingCommentRanges = getTrailingCommentRanges; - /** Optionally, get the shebang */ - function getShebang(text) { - return shebangTriviaRegex.test(text) - ? shebangTriviaRegex.exec(text)[0] - : undefined; - } - ts.getShebang = getShebang; - function isIdentifierStart(ch, languageVersion) { - return ch >= 65 /* A */ && ch <= 90 /* Z */ || ch >= 97 /* a */ && ch <= 122 /* z */ || - ch === 36 /* $ */ || ch === 95 /* _ */ || - ch > 127 /* maxAsciiCharacter */ && isUnicodeIdentifierStart(ch, languageVersion); - } - ts.isIdentifierStart = isIdentifierStart; - function isIdentifierPart(ch, languageVersion) { - return ch >= 65 /* A */ && ch <= 90 /* Z */ || ch >= 97 /* a */ && ch <= 122 /* z */ || - ch >= 48 /* _0 */ && ch <= 57 /* _9 */ || ch === 36 /* $ */ || ch === 95 /* _ */ || - ch > 127 /* maxAsciiCharacter */ && isUnicodeIdentifierPart(ch, languageVersion); - } - ts.isIdentifierPart = isIdentifierPart; - // Creates a scanner over a (possibly unspecified) range of a piece of text. - function createScanner(languageVersion, skipTrivia, languageVariant, text, onError, start, length) { - if (languageVariant === void 0) { languageVariant = 0 /* Standard */; } - // Current position (end position of text of current token) - var pos; - // end of text - var end; - // Start position of whitespace before current token - var startPos; - // Start position of text of current token - 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 /* Identifier */ || token > 105 /* LastReservedWord */; }, - isReservedWord: function () { return token >= 70 /* FirstReservedWord */ && token <= 105 /* LastReservedWord */; }, - isUnterminated: function () { return tokenIsUnterminated; }, - reScanGreaterToken: reScanGreaterToken, - reScanSlashToken: reScanSlashToken, - reScanTemplateToken: reScanTemplateToken, - scanJsxIdentifier: scanJsxIdentifier, - reScanJsxToken: reScanJsxToken, - scanJsxToken: scanJsxToken, - scan: scan, - setText: setText, - setScriptTarget: setScriptTarget, - setLanguageVariant: setLanguageVariant, - setOnError: setOnError, - setTextPos: setTextPos, - tryScan: tryScan, - lookAhead: lookAhead - }; - 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 /* dot */) { - pos++; - while (isDigit(text.charCodeAt(pos))) - pos++; - } - var end = pos; - if (text.charCodeAt(pos) === 69 /* E */ || text.charCodeAt(pos) === 101 /* e */) { - pos++; - if (text.charCodeAt(pos) === 43 /* plus */ || text.charCodeAt(pos) === 45 /* minus */) - 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)); - } - /** - * Scans the given number of hexadecimal digits in the text, - * returning -1 if the given number is unavailable. - */ - function scanExactNumberOfHexDigits(count) { - return scanHexDigits(/*minCount*/ count, /*scanAsManyAsPossible*/ false); - } - /** - * Scans as many hexadecimal digits as are available in the text, - * returning -1 if the given number of digits was unavailable. - */ - function scanMinimumNumberOfHexDigits(count) { - return scanHexDigits(/*minCount*/ count, /*scanAsManyAsPossible*/ true); - } - function scanHexDigits(minCount, scanAsManyAsPossible) { - var digits = 0; - var value = 0; - while (digits < minCount || scanAsManyAsPossible) { - var ch = text.charCodeAt(pos); - if (ch >= 48 /* _0 */ && ch <= 57 /* _9 */) { - value = value * 16 + ch - 48 /* _0 */; - } - else if (ch >= 65 /* A */ && ch <= 70 /* F */) { - value = value * 16 + ch - 65 /* A */ + 10; - } - else if (ch >= 97 /* a */ && ch <= 102 /* f */) { - value = value * 16 + ch - 97 /* a */ + 10; - } - else { - break; - } - pos++; - digits++; - } - if (digits < minCount) { - value = -1; - } - return value; - } - function scanString() { - var quote = text.charCodeAt(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 /* backslash */) { - 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; - } - /** - * Sets the current 'tokenValue' and returns a NoSubstitutionTemplateLiteral or - * a literal component of a TemplateExpression. - */ - function scanTemplateAndSetTokenValue() { - var startedWithBacktick = text.charCodeAt(pos) === 96 /* backtick */; - 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 /* NoSubstitutionTemplateLiteral */ : 14 /* TemplateTail */; - break; - } - var currChar = text.charCodeAt(pos); - // '`' - if (currChar === 96 /* backtick */) { - contents += text.substring(start, pos); - pos++; - resultingToken = startedWithBacktick ? 11 /* NoSubstitutionTemplateLiteral */ : 14 /* 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 */; - break; - } - // Escape character - if (currChar === 92 /* backslash */) { - contents += text.substring(start, pos); - contents += scanEscapeSequence(); - start = pos; - continue; - } - // Speculated ECMAScript 6 Spec 11.8.6.1: - // and LineTerminatorSequences are normalized to for Template Values - if (currChar === 13 /* carriageReturn */) { - contents += text.substring(start, pos); - pos++; - if (pos < end && text.charCodeAt(pos) === 10 /* lineFeed */) { - 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++); - switch (ch) { - case 48 /* _0 */: - return "\0"; - case 98 /* b */: - return "\b"; - case 116 /* t */: - return "\t"; - case 110 /* n */: - return "\n"; - case 118 /* v */: - return "\v"; - case 102 /* f */: - return "\f"; - case 114 /* r */: - return "\r"; - case 39 /* singleQuote */: - return "\'"; - case 34 /* doubleQuote */: - return "\""; - case 117 /* u */: - // '\u{DDDDDDDD}' - if (pos < end && text.charCodeAt(pos) === 123 /* openBrace */) { - hasExtendedUnicodeEscape = true; - pos++; - return scanExtendedUnicodeEscape(); - } - // '\uDDDD' - return scanHexadecimalEscape(/*numDigits*/ 4); - case 120 /* x */: - // '\xDD' - return scanHexadecimalEscape(/*numDigits*/ 2); - // when encountering a LineContinuation (i.e. a backslash and a line terminator sequence), - // the line terminator is interpreted to be "the empty code unit sequence". - case 13 /* carriageReturn */: - if (pos < end && text.charCodeAt(pos) === 10 /* lineFeed */) { - pos++; - } - // fall through - case 10 /* lineFeed */: - case 8232 /* lineSeparator */: - case 8233 /* paragraphSeparator */: - 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; - // Validate the value of the digit - 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 /* closeBrace */) { - // Only swallow the following character up if it's a '}'. - pos++; - } - else { - error(ts.Diagnostics.Unterminated_Unicode_escape_sequence); - isInvalidExtendedEscape = true; - } - if (isInvalidExtendedEscape) { - return ""; - } - return utf16EncodeAsString(escapedValue); - } - // Derived from the 10.1.1 UTF16Encoding of the ES6 Spec. - 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); - } - // Current character is known to be a backslash. Check for Unicode escape of the form '\uXXXX' - // and return code point value if valid Unicode escape is found. Otherwise return -1. - function peekUnicodeEscape() { - if (pos + 5 < end && text.charCodeAt(pos + 1) === 117 /* u */) { - 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 /* backslash */) { - ch = peekUnicodeEscape(); - if (!(ch >= 0 && isIdentifierPart(ch, languageVersion))) { - break; - } - result += text.substring(start, pos); - result += String.fromCharCode(ch); - // Valid Unicode escape is always six characters - pos += 6; - start = pos; - } - else { - break; - } - } - result += text.substring(start, pos); - return result; - } - function getIdentifierToken() { - // Reserved words are between 2 and 11 characters long and start with a lowercase letter - var len = tokenValue.length; - if (len >= 2 && len <= 11) { - var ch = tokenValue.charCodeAt(0); - if (ch >= 97 /* a */ && ch <= 122 /* z */ && hasOwnProperty.call(textToToken, tokenValue)) { - return token = textToToken[tokenValue]; - } - } - return token = 69 /* Identifier */; - } - function scanBinaryOrOctalDigits(base) { - 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. - var numberOfDigits = 0; - while (true) { - var ch = text.charCodeAt(pos); - var valueOfCh = ch - 48 /* _0 */; - if (!isDigit(ch) || valueOfCh >= base) { - break; - } - value = value * base + valueOfCh; - pos++; - numberOfDigits++; - } - // Invalid binaryIntegerLiteral or octalIntegerLiteral - 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 /* EndOfFileToken */; - } - var ch = text.charCodeAt(pos); - // Special handling for shebang - if (ch === 35 /* hash */ && pos === 0 && isShebangTrivia(text, pos)) { - pos = scanShebangTrivia(text, pos); - if (skipTrivia) { - continue; - } - else { - return token = 6 /* ShebangTrivia */; - } - } - switch (ch) { - case 10 /* lineFeed */: - case 13 /* carriageReturn */: - precedingLineBreak = true; - if (skipTrivia) { - pos++; - continue; - } - else { - if (ch === 13 /* carriageReturn */ && pos + 1 < end && text.charCodeAt(pos + 1) === 10 /* lineFeed */) { - // consume both CR and LF - pos += 2; - } - else { - pos++; - } - return token = 4 /* NewLineTrivia */; - } - case 9 /* tab */: - case 11 /* verticalTab */: - case 12 /* formFeed */: - case 32 /* space */: - if (skipTrivia) { - pos++; - continue; - } - else { - while (pos < end && isWhiteSpace(text.charCodeAt(pos))) { - pos++; - } - return token = 5 /* WhitespaceTrivia */; - } - 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 += 2, token = 31 /* ExclamationEqualsToken */; - } - return pos++, token = 49 /* ExclamationToken */; - case 34 /* doubleQuote */: - case 39 /* singleQuote */: - tokenValue = scanString(); - return token = 9 /* StringLiteral */; - case 96 /* backtick */: - return token = scanTemplateAndSetTokenValue(); - case 37 /* percent */: - if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 62 /* PercentEqualsToken */; - } - return pos++, token = 40 /* PercentToken */; - case 38 /* ampersand */: - if (text.charCodeAt(pos + 1) === 38 /* ampersand */) { - return pos += 2, token = 51 /* AmpersandAmpersandToken */; - } - if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 66 /* AmpersandEqualsToken */; - } - return pos++, token = 46 /* AmpersandToken */; - case 40 /* openParen */: - return pos++, token = 17 /* OpenParenToken */; - case 41 /* closeParen */: - return pos++, token = 18 /* CloseParenToken */; - case 42 /* asterisk */: - if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 59 /* AsteriskEqualsToken */; - } - if (text.charCodeAt(pos + 1) === 42 /* asterisk */) { - if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 60 /* AsteriskAsteriskEqualsToken */; - } - return pos += 2, token = 38 /* AsteriskAsteriskToken */; - } - return pos++, token = 37 /* AsteriskToken */; - case 43 /* plus */: - if (text.charCodeAt(pos + 1) === 43 /* plus */) { - return pos += 2, token = 41 /* PlusPlusToken */; - } - if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 57 /* PlusEqualsToken */; - } - return pos++, token = 35 /* PlusToken */; - case 44 /* comma */: - return pos++, token = 24 /* CommaToken */; - case 45 /* minus */: - if (text.charCodeAt(pos + 1) === 45 /* minus */) { - return pos += 2, token = 42 /* MinusMinusToken */; - } - if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 58 /* MinusEqualsToken */; - } - return pos++, token = 36 /* 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++, token = 21 /* DotToken */; - case 47 /* slash */: - // Single-line comment - if (text.charCodeAt(pos + 1) === 47 /* slash */) { - pos += 2; - while (pos < end) { - if (isLineBreak(text.charCodeAt(pos))) { - break; - } - pos++; - } - if (skipTrivia) { - continue; - } - else { - return token = 2 /* SingleLineCommentTrivia */; - } - } - // Multi-line comment - if (text.charCodeAt(pos + 1) === 42 /* asterisk */) { - pos += 2; - var commentClosed = false; - while (pos < end) { - var ch_2 = text.charCodeAt(pos); - if (ch_2 === 42 /* asterisk */ && text.charCodeAt(pos + 1) === 47 /* slash */) { - 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 /* MultiLineCommentTrivia */; - } - } - if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 61 /* SlashEqualsToken */; - } - return pos++, token = 39 /* SlashToken */; - case 48 /* _0 */: - if (pos + 2 < end && (text.charCodeAt(pos + 1) === 88 /* X */ || text.charCodeAt(pos + 1) === 120 /* x */)) { - pos += 2; - var value = scanMinimumNumberOfHexDigits(1); - if (value < 0) { - error(ts.Diagnostics.Hexadecimal_digit_expected); - value = 0; - } - tokenValue = "" + value; - return token = 8 /* NumericLiteral */; - } - else if (pos + 2 < end && (text.charCodeAt(pos + 1) === 66 /* B */ || text.charCodeAt(pos + 1) === 98 /* b */)) { - pos += 2; - var value = scanBinaryOrOctalDigits(/* base */ 2); - if (value < 0) { - error(ts.Diagnostics.Binary_digit_expected); - value = 0; - } - tokenValue = "" + value; - return token = 8 /* NumericLiteral */; - } - else if (pos + 2 < end && (text.charCodeAt(pos + 1) === 79 /* O */ || text.charCodeAt(pos + 1) === 111 /* o */)) { - pos += 2; - var value = scanBinaryOrOctalDigits(/* base */ 8); - if (value < 0) { - error(ts.Diagnostics.Octal_digit_expected); - value = 0; - } - tokenValue = "" + value; - return token = 8 /* NumericLiteral */; - } - // Try to parse as an octal - if (pos + 1 < end && isOctalDigit(text.charCodeAt(pos + 1))) { - tokenValue = "" + scanOctalDigits(); - return token = 8 /* NumericLiteral */; - } - // This fall-through is a deviation from the EcmaScript grammar. The grammar says that a leading zero - // can only be followed by an octal digit, a dot, or the end of the number literal. However, we are being - // permissive and allowing decimal digits of the form 08* and 09* (which many browsers also do). - case 49 /* _1 */: - case 50 /* _2 */: - case 51 /* _3 */: - case 52 /* _4 */: - case 53 /* _5 */: - case 54 /* _6 */: - case 55 /* _7 */: - case 56 /* _8 */: - case 57 /* _9 */: - tokenValue = "" + scanNumber(); - return token = 8 /* NumericLiteral */; - case 58 /* colon */: - return pos++, token = 54 /* ColonToken */; - case 59 /* semicolon */: - return pos++, token = 23 /* SemicolonToken */; - case 60 /* lessThan */: - if (isConflictMarkerTrivia(text, pos)) { - pos = scanConflictMarkerTrivia(text, pos, error); - if (skipTrivia) { - continue; - } - else { - return token = 7 /* ConflictMarkerTrivia */; - } - } - if (text.charCodeAt(pos + 1) === 60 /* lessThan */) { - if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 63 /* LessThanLessThanEqualsToken */; - } - return pos += 2, token = 43 /* LessThanLessThanToken */; - } - if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 28 /* 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++, token = 25 /* LessThanToken */; - case 61 /* equals */: - if (isConflictMarkerTrivia(text, pos)) { - pos = scanConflictMarkerTrivia(text, pos, error); - if (skipTrivia) { - continue; - } - else { - return token = 7 /* ConflictMarkerTrivia */; - } - } - if (text.charCodeAt(pos + 1) === 61 /* equals */) { - if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 32 /* EqualsEqualsEqualsToken */; - } - return pos += 2, token = 30 /* EqualsEqualsToken */; - } - if (text.charCodeAt(pos + 1) === 62 /* greaterThan */) { - return pos += 2, token = 34 /* EqualsGreaterThanToken */; - } - return pos++, token = 56 /* EqualsToken */; - case 62 /* greaterThan */: - if (isConflictMarkerTrivia(text, pos)) { - pos = scanConflictMarkerTrivia(text, pos, error); - if (skipTrivia) { - continue; - } - else { - return token = 7 /* ConflictMarkerTrivia */; - } - } - return pos++, token = 27 /* GreaterThanToken */; - case 63 /* question */: - return pos++, token = 53 /* QuestionToken */; - case 91 /* openBracket */: - return pos++, token = 19 /* OpenBracketToken */; - case 93 /* closeBracket */: - return pos++, token = 20 /* CloseBracketToken */; - case 94 /* caret */: - if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 68 /* CaretEqualsToken */; - } - return pos++, token = 48 /* CaretToken */; - case 123 /* openBrace */: - return pos++, token = 15 /* OpenBraceToken */; - case 124 /* bar */: - if (text.charCodeAt(pos + 1) === 124 /* bar */) { - return pos += 2, token = 52 /* BarBarToken */; - } - if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 67 /* BarEqualsToken */; - } - return pos++, token = 47 /* BarToken */; - case 125 /* closeBrace */: - return pos++, token = 16 /* CloseBraceToken */; - case 126 /* tilde */: - return pos++, token = 50 /* TildeToken */; - case 64 /* at */: - return pos++, token = 55 /* AtToken */; - case 92 /* backslash */: - var cookedChar = peekUnicodeEscape(); - if (cookedChar >= 0 && isIdentifierStart(cookedChar, languageVersion)) { - pos += 6; - tokenValue = String.fromCharCode(cookedChar) + scanIdentifierParts(); - return token = getIdentifierToken(); - } - error(ts.Diagnostics.Invalid_character); - return pos++, token = 0 /* Unknown */; - default: - if (isIdentifierStart(ch, languageVersion)) { - pos++; - while (pos < end && isIdentifierPart(ch = text.charCodeAt(pos), languageVersion)) - pos++; - tokenValue = text.substring(tokenPos, pos); - if (ch === 92 /* backslash */) { - tokenValue += scanIdentifierParts(); - } - return token = getIdentifierToken(); - } - else if (isWhiteSpace(ch)) { - pos++; - continue; - } - else if (isLineBreak(ch)) { - precedingLineBreak = true; - pos++; - continue; - } - error(ts.Diagnostics.Invalid_character); - return pos++, token = 0 /* Unknown */; - } - } - } - function reScanGreaterToken() { - if (token === 27 /* 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 += 2, token = 45 /* GreaterThanGreaterThanGreaterThanToken */; - } - if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 64 /* GreaterThanGreaterThanEqualsToken */; - } - return pos++, token = 44 /* GreaterThanGreaterThanToken */; - } - if (text.charCodeAt(pos) === 61 /* equals */) { - return pos++, token = 29 /* GreaterThanEqualsToken */; - } - } - return token; - } - function reScanSlashToken() { - if (token === 39 /* SlashToken */ || token === 61 /* SlashEqualsToken */) { - var p = tokenPos + 1; - var inEscape = false; - var inCharacterClass = false; - while (true) { - // If we reach the end of a file, or hit a newline, then this is an unterminated - // regex. Report error and return what we have so far. - 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) { - // Parsing an escape character; - // reset the flag and just advance to the next char. - inEscape = false; - } - else if (ch === 47 /* slash */ && !inCharacterClass) { - // A slash within a character class is permissible, - // but in general it signals the end of the regexp literal. - p++; - break; - } - else if (ch === 91 /* openBracket */) { - inCharacterClass = true; - } - else if (ch === 92 /* backslash */) { - inEscape = true; - } - else if (ch === 93 /* closeBracket */) { - inCharacterClass = false; - } - p++; - } - while (p < end && isIdentifierPart(text.charCodeAt(p), languageVersion)) { - p++; - } - pos = p; - tokenValue = text.substring(tokenPos, pos); - token = 10 /* RegularExpressionLiteral */; - } - return token; - } - /** - * Unconditionally back up and scan a template expression portion. - */ - function reScanTemplateToken() { - ts.Debug.assert(token === 16 /* CloseBraceToken */, "'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 /* EndOfFileToken */; - } - var char = text.charCodeAt(pos); - if (char === 60 /* lessThan */) { - if (text.charCodeAt(pos + 1) === 47 /* slash */) { - pos += 2; - return token = 26 /* LessThanSlashToken */; - } - pos++; - return token = 25 /* LessThanToken */; - } - if (char === 123 /* openBrace */) { - pos++; - return token = 15 /* OpenBraceToken */; - } - while (pos < end) { - pos++; - char = text.charCodeAt(pos); - if ((char === 123 /* openBrace */) || (char === 60 /* lessThan */)) { - break; - } - } - return token = 236 /* JsxText */; - } - // Scans a JSX identifier; these differ from normal identifiers in that - // they allow dashes - function scanJsxIdentifier() { - if (tokenIsIdentifierOrKeyword(token)) { - var firstCharPosition = pos; - while (pos < end) { - var ch = text.charCodeAt(pos); - if (ch === 45 /* minus */ || ((firstCharPosition === pos) ? isIdentifierStart(ch, languageVersion) : isIdentifierPart(ch, languageVersion))) { - pos++; - } - else { - break; - } - } - tokenValue += text.substr(firstCharPosition, pos - firstCharPosition); - } - return token; - } - 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 our callback returned something 'falsy' or we're just looking ahead, - // then unconditionally restore us to where we were. - if (!result || isLookahead) { - pos = savePos; - startPos = saveStartPos; - tokenPos = saveTokenPos; - token = saveToken; - tokenValue = saveTokenValue; - precedingLineBreak = savePrecedingLineBreak; - } - return result; - } - function lookAhead(callback) { - return speculationHelper(callback, /*isLookahead:*/ true); - } - function tryScan(callback) { - return speculationHelper(callback, /*isLookahead:*/ false); - } - 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 /* Unknown */; - precedingLineBreak = false; - tokenValue = undefined; - hasExtendedUnicodeEscape = false; - tokenIsUnterminated = false; - } - } - ts.createScanner = createScanner; -})(ts || (ts = {})); -/// -/* @internal */ -var ts; -(function (ts) { - ts.bindTime = 0; - (function (ModuleInstanceState) { - ModuleInstanceState[ModuleInstanceState["NonInstantiated"] = 0] = "NonInstantiated"; - ModuleInstanceState[ModuleInstanceState["Instantiated"] = 1] = "Instantiated"; - ModuleInstanceState[ModuleInstanceState["ConstEnumOnly"] = 2] = "ConstEnumOnly"; - })(ts.ModuleInstanceState || (ts.ModuleInstanceState = {})); - var ModuleInstanceState = ts.ModuleInstanceState; - function getModuleInstanceState(node) { - // A module is uninstantiated if it contains only - // 1. interface declarations, type alias declarations - if (node.kind === 215 /* InterfaceDeclaration */ || node.kind === 216 /* TypeAliasDeclaration */) { - return 0 /* NonInstantiated */; - } - else if (ts.isConstEnumDeclaration(node)) { - return 2 /* ConstEnumOnly */; - } - else if ((node.kind === 222 /* ImportDeclaration */ || node.kind === 221 /* ImportEqualsDeclaration */) && !(node.flags & 1 /* Export */)) { - return 0 /* NonInstantiated */; - } - else if (node.kind === 219 /* ModuleBlock */) { - var state = 0 /* NonInstantiated */; - ts.forEachChild(node, function (n) { - switch (getModuleInstanceState(n)) { - case 0 /* NonInstantiated */: - // child is non-instantiated - continue searching - return false; - case 2 /* ConstEnumOnly */: - // child is const enum only - record state and continue searching - state = 2 /* ConstEnumOnly */; - return false; - case 1 /* Instantiated */: - // child is instantiated - record state and stop - state = 1 /* Instantiated */; - return true; - } - }); - return state; - } - else if (node.kind === 218 /* ModuleDeclaration */) { - return getModuleInstanceState(node.body); - } - else { - return 1 /* Instantiated */; - } - } - ts.getModuleInstanceState = getModuleInstanceState; - var ContainerFlags; - (function (ContainerFlags) { - // The current node is not a container, and no container manipulation should happen before - // recursing into it. - ContainerFlags[ContainerFlags["None"] = 0] = "None"; - // 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... - ContainerFlags[ContainerFlags["IsContainer"] = 1] = "IsContainer"; - // 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... - ContainerFlags[ContainerFlags["IsBlockScopedContainer"] = 2] = "IsBlockScopedContainer"; - ContainerFlags[ContainerFlags["HasLocals"] = 4] = "HasLocals"; - // If the current node is a container that also container that also contains locals. Examples: - // - // Functions, Methods, Modules, Source-files. - ContainerFlags[ContainerFlags["IsContainerWithLocals"] = 5] = "IsContainerWithLocals"; - })(ContainerFlags || (ContainerFlags = {})); - function bindSourceFile(file) { - var start = new Date().getTime(); - bindSourceFileWorker(file); - ts.bindTime += new Date().getTime() - start; - } - ts.bindSourceFile = bindSourceFile; - function bindSourceFileWorker(file) { - var parent; - var container; - var blockScopeContainer; - var lastContainer; - var seenThisKeyword; - // 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). - var inStrictMode = !!file.externalModuleIndicator; - var symbolCount = 0; - var Symbol = ts.objectAllocator.getSymbolConstructor(); - var classifiableNames = {}; - if (!file.locals) { - bind(file); - file.symbolCount = symbolCount; - file.classifiableNames = classifiableNames; - } - return; - function createSymbol(flags, name) { - symbolCount++; - return new Symbol(flags, name); - } - function addDeclarationToSymbol(symbol, node, symbolFlags) { - symbol.flags |= symbolFlags; - node.symbol = symbol; - if (!symbol.declarations) { - symbol.declarations = []; - } - symbol.declarations.push(node); - if (symbolFlags & 1952 /* HasExports */ && !symbol.exports) { - symbol.exports = {}; - } - if (symbolFlags & 6240 /* HasMembers */ && !symbol.members) { - symbol.members = {}; - } - if (symbolFlags & 107455 /* Value */ && !symbol.valueDeclaration) { - 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) { - if (node.name) { - if (node.kind === 218 /* ModuleDeclaration */ && node.name.kind === 9 /* StringLiteral */) { - return "\"" + node.name.text + "\""; - } - if (node.name.kind === 136 /* ComputedPropertyName */) { - var nameExpression = node.name.expression; - ts.Debug.assert(ts.isWellKnownSymbolSyntactically(nameExpression)); - return ts.getPropertyNameForKnownSymbolName(nameExpression.name.text); - } - return node.name.text; - } - switch (node.kind) { - case 144 /* Constructor */: - return "__constructor"; - case 152 /* FunctionType */: - case 147 /* CallSignature */: - return "__call"; - case 153 /* ConstructorType */: - case 148 /* ConstructSignature */: - return "__new"; - case 149 /* IndexSignature */: - return "__index"; - case 228 /* ExportDeclaration */: - return "__export"; - case 227 /* ExportAssignment */: - return node.isExportEquals ? "export=" : "default"; - case 213 /* FunctionDeclaration */: - case 214 /* ClassDeclaration */: - return node.flags & 1024 /* Default */ ? "default" : undefined; - } - } - function getDisplayName(node) { - return node.name ? ts.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, parent, node, includes, excludes) { - ts.Debug.assert(!ts.hasDynamicName(node)); - var isDefaultExport = node.flags & 1024 /* Default */; - // The exported symbol for an export default function/class node is always named "default" - var name = isDefaultExport && parent ? "default" : getDeclarationName(node); - var symbol; - if (name !== undefined) { - // Check and see if the symbol table already has a symbol with this name. If not, - // 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. - // - // 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 = ts.hasProperty(symbolTable, name) - ? symbolTable[name] - : (symbolTable[name] = createSymbol(0 /* None */, name)); - if (name && (includes & 788448 /* Classifiable */)) { - classifiableNames[name] = name; - } - if (symbol.flags & excludes) { - if (node.name) { - node.name.parent = node; - } - // Report errors every position with duplicate declaration - // Report errors on previous encountered declarations - var message = symbol.flags & 2 /* BlockScopedVariable */ - ? ts.Diagnostics.Cannot_redeclare_block_scoped_variable_0 - : ts.Diagnostics.Duplicate_identifier_0; - ts.forEach(symbol.declarations, function (declaration) { - if (declaration.flags & 1024 /* Default */) { - message = ts.Diagnostics.A_module_cannot_have_multiple_default_exports; - } - }); - ts.forEach(symbol.declarations, function (declaration) { - file.bindDiagnostics.push(ts.createDiagnosticForNode(declaration.name || declaration, message, getDisplayName(declaration))); - }); - file.bindDiagnostics.push(ts.createDiagnosticForNode(node.name || node, message, getDisplayName(node))); - symbol = createSymbol(0 /* None */, name); - } - } - else { - symbol = createSymbol(0 /* None */, "__missing"); - } - addDeclarationToSymbol(symbol, node, includes); - symbol.parent = parent; - return symbol; - } - function declareModuleMember(node, symbolFlags, symbolExcludes) { - var hasExportModifier = ts.getCombinedNodeFlags(node) & 1 /* Export */; - if (symbolFlags & 8388608 /* Alias */) { - if (node.kind === 230 /* ExportSpecifier */ || (node.kind === 221 /* 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. - if (hasExportModifier || container.flags & 262144 /* ExportContext */) { - var exportKind = (symbolFlags & 107455 /* Value */ ? 1048576 /* ExportValue */ : 0) | - (symbolFlags & 793056 /* Type */ ? 2097152 /* ExportType */ : 0) | - (symbolFlags & 1536 /* Namespace */ ? 4194304 /* ExportNamespace */ : 0); - var 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 bindChildren(node) { - // Before we recurse into a node's chilren, we first save the existing parent, container - // and block-container. Then after we pop out of processing the children, we restore - // these saved values. - var saveParent = parent; - var saveContainer = container; - var savedBlockScopeContainer = blockScopeContainer; - // This node will now be set as the parent of all of its children as we recurse into them. - parent = node; - // 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 accidently move any stale data forward from - // a previous compilation. - var containerFlags = getContainerFlags(node); - if (containerFlags & 1 /* IsContainer */) { - container = blockScopeContainer = node; - if (containerFlags & 4 /* HasLocals */) { - container.locals = {}; - } - addToContainerChain(container); - } - else if (containerFlags & 2 /* IsBlockScopedContainer */) { - blockScopeContainer = node; - blockScopeContainer.locals = undefined; - } - if (node.kind === 215 /* InterfaceDeclaration */) { - seenThisKeyword = false; - ts.forEachChild(node, bind); - node.flags = seenThisKeyword ? node.flags | 524288 /* ContainsThis */ : node.flags & ~524288 /* ContainsThis */; - } - else { - ts.forEachChild(node, bind); - } - container = saveContainer; - parent = saveParent; - blockScopeContainer = savedBlockScopeContainer; - } - function getContainerFlags(node) { - switch (node.kind) { - case 186 /* ClassExpression */: - case 214 /* ClassDeclaration */: - case 215 /* InterfaceDeclaration */: - case 217 /* EnumDeclaration */: - case 155 /* TypeLiteral */: - case 165 /* ObjectLiteralExpression */: - return 1 /* IsContainer */; - case 147 /* CallSignature */: - case 148 /* ConstructSignature */: - case 149 /* IndexSignature */: - case 143 /* MethodDeclaration */: - case 142 /* MethodSignature */: - case 213 /* FunctionDeclaration */: - case 144 /* Constructor */: - case 145 /* GetAccessor */: - case 146 /* SetAccessor */: - case 152 /* FunctionType */: - case 153 /* ConstructorType */: - case 173 /* FunctionExpression */: - case 174 /* ArrowFunction */: - case 218 /* ModuleDeclaration */: - case 248 /* SourceFile */: - case 216 /* TypeAliasDeclaration */: - return 5 /* IsContainerWithLocals */; - case 244 /* CatchClause */: - case 199 /* ForStatement */: - case 200 /* ForInStatement */: - case 201 /* ForOfStatement */: - case 220 /* CaseBlock */: - return 2 /* IsBlockScopedContainer */; - case 192 /* Block */: - // do not treat blocks directly inside a function as a block-scoped-container. - // Locals that reside in this block should go to the function locals. Othewise 'x' - // would not appear to be a redeclaration of a block scoped local in the following - // 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 ts.isFunctionLike(node.parent) ? 0 /* None */ : 2 /* IsBlockScopedContainer */; - } - return 0 /* None */; - } - function addToContainerChain(next) { - if (lastContainer) { - lastContainer.nextContainer = next; - } - lastContainer = next; - } - function declareSymbolAndAddToSymbolTable(node, symbolFlags, symbolExcludes) { - // Just call this directly so that the return type of this function stays "void". - declareSymbolAndAddToSymbolTableWorker(node, symbolFlags, symbolExcludes); - } - function declareSymbolAndAddToSymbolTableWorker(node, symbolFlags, symbolExcludes) { - 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 218 /* ModuleDeclaration */: - return declareModuleMember(node, symbolFlags, symbolExcludes); - case 248 /* SourceFile */: - return declareSourceFileMember(node, symbolFlags, symbolExcludes); - case 186 /* ClassExpression */: - case 214 /* ClassDeclaration */: - return declareClassMember(node, symbolFlags, symbolExcludes); - case 217 /* EnumDeclaration */: - return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); - case 155 /* TypeLiteral */: - case 165 /* ObjectLiteralExpression */: - case 215 /* InterfaceDeclaration */: - // Interface/Object-types always have their children added to the 'members' of - // their container. They are only accessible through an instance of their - // container, and are never in scope otherwise (even inside the body of the - // object / type / interface declaring them). An exception is type parameters, - // which are in scope without qualification (similar to 'locals'). - return declareSymbol(container.symbol.members, container.symbol, node, symbolFlags, symbolExcludes); - case 152 /* FunctionType */: - case 153 /* ConstructorType */: - case 147 /* CallSignature */: - case 148 /* ConstructSignature */: - case 149 /* IndexSignature */: - case 143 /* MethodDeclaration */: - case 142 /* MethodSignature */: - case 144 /* Constructor */: - case 145 /* GetAccessor */: - case 146 /* SetAccessor */: - case 213 /* FunctionDeclaration */: - case 173 /* FunctionExpression */: - case 174 /* ArrowFunction */: - case 216 /* TypeAliasDeclaration */: - // All the children of these container types are never visible through another - // symbol (i.e. through another symbol's 'exports' or 'members'). Instead, - // they're only accessed 'lexically' (i.e. from code that exists underneath - // 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, undefined, node, symbolFlags, symbolExcludes); - } - } - function declareClassMember(node, symbolFlags, symbolExcludes) { - return node.flags & 128 /* Static */ - ? declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes) - : declareSymbol(container.symbol.members, container.symbol, node, symbolFlags, symbolExcludes); - } - function declareSourceFileMember(node, symbolFlags, symbolExcludes) { - return ts.isExternalModule(file) - ? declareModuleMember(node, symbolFlags, symbolExcludes) - : declareSymbol(file.locals, undefined, node, symbolFlags, symbolExcludes); - } - function isAmbientContext(node) { - while (node) { - if (node.flags & 2 /* Ambient */) { - return true; - } - node = node.parent; - } - return false; - } - function hasExportDeclarations(node) { - var body = node.kind === 248 /* SourceFile */ ? node : node.body; - if (body.kind === 248 /* SourceFile */ || body.kind === 219 /* ModuleBlock */) { - for (var _i = 0, _a = body.statements; _i < _a.length; _i++) { - var stat = _a[_i]; - if (stat.kind === 228 /* ExportDeclaration */ || stat.kind === 227 /* ExportAssignment */) { - return true; - } - } - } - return false; - } - function setExportContextFlag(node) { - // 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 (isAmbientContext(node) && !hasExportDeclarations(node)) { - node.flags |= 262144 /* ExportContext */; - } - else { - node.flags &= ~262144 /* ExportContext */; - } - } - function bindModuleDeclaration(node) { - setExportContextFlag(node); - if (node.name.kind === 9 /* StringLiteral */) { - declareSymbolAndAddToSymbolTable(node, 512 /* ValueModule */, 106639 /* ValueModuleExcludes */); - } - else { - var state = getModuleInstanceState(node); - if (state === 0 /* NonInstantiated */) { - declareSymbolAndAddToSymbolTable(node, 1024 /* NamespaceModule */, 0 /* NamespaceModuleExcludes */); - } - else { - declareSymbolAndAddToSymbolTable(node, 512 /* ValueModule */, 106639 /* ValueModuleExcludes */); - if (node.symbol.flags & (16 /* Function */ | 32 /* Class */ | 256 /* 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 { - var currentModuleIsConstEnumOnly = state === 2 /* 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) { - // For a given function symbol "<...>(...) => T" we want to generate a symbol identical - // to the one we would get for: { <...>(...): T } - // - // We do that by making an anonymous type literal symbol, and then setting the function - // symbol as its sole member. To the rest of the system, this symbol will be indistinguishable - // from an actual type literal symbol you would have gotten had you used the long form. - var symbol = createSymbol(131072 /* Signature */, getDeclarationName(node)); - addDeclarationToSymbol(symbol, node, 131072 /* Signature */); - var typeLiteralSymbol = createSymbol(2048 /* TypeLiteral */, "__type"); - addDeclarationToSymbol(typeLiteralSymbol, node, 2048 /* TypeLiteral */); - typeLiteralSymbol.members = (_a = {}, _a[symbol.name] = symbol, _a); - var _a; - } - function bindObjectLiteralExpression(node) { - var ElementKind; - (function (ElementKind) { - ElementKind[ElementKind["Property"] = 1] = "Property"; - ElementKind[ElementKind["Accessor"] = 2] = "Accessor"; - })(ElementKind || (ElementKind = {})); - if (inStrictMode) { - var seen = {}; - for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { - var prop = _a[_i]; - if (prop.name.kind !== 69 /* Identifier */) { - continue; - } - var identifier = prop.name; - // ECMA-262 11.1.5 Object Initialiser - // If previous is not undefined then throw a SyntaxError exception if any of the following conditions are true - // a.This production is contained in strict code and IsDataDescriptor(previous) is true and - // 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 - var currentKind = prop.kind === 245 /* PropertyAssignment */ || prop.kind === 246 /* ShorthandPropertyAssignment */ || prop.kind === 143 /* MethodDeclaration */ - ? 1 /* Property */ - : 2 /* Accessor */; - var existingKind = seen[identifier.text]; - if (!existingKind) { - seen[identifier.text] = currentKind; - continue; - } - if (currentKind === 1 /* Property */ && existingKind === 1 /* Property */) { - var span = ts.getErrorSpanForNode(file, identifier); - file.bindDiagnostics.push(ts.createFileDiagnostic(file, span.start, span.length, ts.Diagnostics.An_object_literal_cannot_have_multiple_properties_with_the_same_name_in_strict_mode)); - } - } - } - return bindAnonymousDeclaration(node, 4096 /* ObjectLiteral */, "__object"); - } - function bindAnonymousDeclaration(node, symbolFlags, name) { - var symbol = createSymbol(symbolFlags, name); - addDeclarationToSymbol(symbol, node, symbolFlags); - } - function bindBlockScopedDeclaration(node, symbolFlags, symbolExcludes) { - switch (blockScopeContainer.kind) { - case 218 /* ModuleDeclaration */: - declareModuleMember(node, symbolFlags, symbolExcludes); - break; - case 248 /* SourceFile */: - if (ts.isExternalModule(container)) { - declareModuleMember(node, symbolFlags, symbolExcludes); - break; - } - // fall through. - default: - if (!blockScopeContainer.locals) { - blockScopeContainer.locals = {}; - addToContainerChain(blockScopeContainer); - } - declareSymbol(blockScopeContainer.locals, undefined, node, symbolFlags, symbolExcludes); - } - } - function bindBlockScopedVariableDeclaration(node) { - bindBlockScopedDeclaration(node, 2 /* BlockScopedVariable */, 107455 /* 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) { - if (inStrictMode && - node.originalKeywordKind >= 106 /* FirstFutureReservedWord */ && - node.originalKeywordKind <= 114 /* LastFutureReservedWord */ && - !ts.isIdentifierName(node)) { - // Report error only if there are no parse errors in file - if (!file.parseDiagnostics.length) { - file.bindDiagnostics.push(ts.createDiagnosticForNode(node, getStrictModeIdentifierMessage(node), ts.declarationNameToString(node))); - } - } - } - function getStrictModeIdentifierMessage(node) { - // Provide specialized messages to help the user understand why we think they're in - // strict mode. - if (ts.getContainingClass(node)) { - return ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_strict_mode; - } - if (file.externalModuleIndicator) { - return ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode_Modules_are_automatically_in_strict_mode; - } - return ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode; - } - function checkStrictModeBinaryExpression(node) { - if (inStrictMode && ts.isLeftHandSideExpression(node.left) && ts.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) { - // 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) { - // Grammar checking - if (inStrictMode && node.expression.kind === 69 /* Identifier */) { - // When a delete operator occurs within strict mode code, a SyntaxError is thrown if its - // UnaryExpression is a direct reference to a variable, function argument, or function name - var span = ts.getErrorSpanForNode(file, node.expression); - file.bindDiagnostics.push(ts.createFileDiagnostic(file, span.start, span.length, ts.Diagnostics.delete_cannot_be_called_on_an_identifier_in_strict_mode)); - } - } - function isEvalOrArgumentsIdentifier(node) { - return node.kind === 69 /* Identifier */ && - (node.text === "eval" || node.text === "arguments"); - } - function checkStrictModeEvalOrArguments(contextNode, name) { - if (name && name.kind === 69 /* Identifier */) { - var identifier = name; - if (isEvalOrArgumentsIdentifier(identifier)) { - // We check first if the name is inside class declaration or class expression; if so give explicit message - // otherwise report generic error message. - var span = ts.getErrorSpanForNode(file, name); - file.bindDiagnostics.push(ts.createFileDiagnostic(file, span.start, span.length, getStrictModeEvalOrArgumentsMessage(contextNode), identifier.text)); - } - } - } - function getStrictModeEvalOrArgumentsMessage(node) { - // Provide specialized messages to help the user understand why we think they're in - // strict mode. - if (ts.getContainingClass(node)) { - return ts.Diagnostics.Invalid_use_of_0_Class_definitions_are_automatically_in_strict_mode; - } - if (file.externalModuleIndicator) { - return ts.Diagnostics.Invalid_use_of_0_Modules_are_automatically_in_strict_mode; - } - return ts.Diagnostics.Invalid_use_of_0_in_strict_mode; - } - function checkStrictModeFunctionName(node) { - 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 checkStrictModeNumericLiteral(node) { - if (inStrictMode && node.flags & 65536 /* OctalLiteral */) { - file.bindDiagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.Octal_literals_are_not_allowed_in_strict_mode)); - } - } - function checkStrictModePostfixUnaryExpression(node) { - // 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) { - // Grammar checking - if (inStrictMode) { - if (node.operator === 41 /* PlusPlusToken */ || node.operator === 42 /* MinusMinusToken */) { - checkStrictModeEvalOrArguments(node, node.operand); - } - } - } - function checkStrictModeWithStatement(node) { - // Grammar checking for withStatement - if (inStrictMode) { - grammarErrorOnFirstToken(node, ts.Diagnostics.with_statements_are_not_allowed_in_strict_mode); - } - } - function grammarErrorOnFirstToken(node, message, arg0, arg1, arg2) { - var span = ts.getSpanOfTokenAtPosition(file, node.pos); - file.bindDiagnostics.push(ts.createFileDiagnostic(file, span.start, span.length, message, arg0, arg1, arg2)); - } - function getDestructuringParameterName(node) { - return "__" + ts.indexOf(node.parent.parameters, node); - } - function bind(node) { - node.parent = parent; - var savedInStrictMode = inStrictMode; - if (!savedInStrictMode) { - updateStrictMode(node); - } - // 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. - bindChildren(node); - inStrictMode = savedInStrictMode; - } - function updateStrictMode(node) { - switch (node.kind) { - case 248 /* SourceFile */: - case 219 /* ModuleBlock */: - updateStrictModeStatementList(node.statements); - return; - case 192 /* Block */: - if (ts.isFunctionLike(node.parent)) { - updateStrictModeStatementList(node.statements); - } - return; - case 214 /* ClassDeclaration */: - case 186 /* ClassExpression */: - // All classes are automatically in strict mode in ES6. - inStrictMode = true; - return; - } - } - function updateStrictModeStatementList(statements) { - for (var _i = 0; _i < statements.length; _i++) { - var statement = statements[_i]; - if (!ts.isPrologueDirective(statement)) { - return; - } - if (isUseStrictPrologueDirective(statement)) { - inStrictMode = true; - return; - } - } - } - /// Should be called only on prologue directives (isPrologueDirective(node) should be true) - function isUseStrictPrologueDirective(node) { - var nodeText = ts.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) { - switch (node.kind) { - case 69 /* Identifier */: - return checkStrictModeIdentifier(node); - case 181 /* BinaryExpression */: - return checkStrictModeBinaryExpression(node); - case 244 /* CatchClause */: - return checkStrictModeCatchClause(node); - case 175 /* DeleteExpression */: - return checkStrictModeDeleteExpression(node); - case 8 /* NumericLiteral */: - return checkStrictModeNumericLiteral(node); - case 180 /* PostfixUnaryExpression */: - return checkStrictModePostfixUnaryExpression(node); - case 179 /* PrefixUnaryExpression */: - return checkStrictModePrefixUnaryExpression(node); - case 205 /* WithStatement */: - return checkStrictModeWithStatement(node); - case 97 /* ThisKeyword */: - seenThisKeyword = true; - return; - case 137 /* TypeParameter */: - return declareSymbolAndAddToSymbolTable(node, 262144 /* TypeParameter */, 530912 /* TypeParameterExcludes */); - case 138 /* Parameter */: - return bindParameter(node); - case 211 /* VariableDeclaration */: - case 163 /* BindingElement */: - return bindVariableDeclarationOrBindingElement(node); - case 141 /* PropertyDeclaration */: - case 140 /* PropertySignature */: - return bindPropertyOrMethodOrAccessor(node, 4 /* Property */ | (node.questionToken ? 536870912 /* Optional */ : 0 /* None */), 107455 /* PropertyExcludes */); - case 245 /* PropertyAssignment */: - case 246 /* ShorthandPropertyAssignment */: - return bindPropertyOrMethodOrAccessor(node, 4 /* Property */, 107455 /* PropertyExcludes */); - case 247 /* EnumMember */: - return bindPropertyOrMethodOrAccessor(node, 8 /* EnumMember */, 107455 /* EnumMemberExcludes */); - case 147 /* CallSignature */: - case 148 /* ConstructSignature */: - case 149 /* IndexSignature */: - return declareSymbolAndAddToSymbolTable(node, 131072 /* Signature */, 0 /* None */); - case 143 /* MethodDeclaration */: - case 142 /* MethodSignature */: - // If this is an ObjectLiteralExpression method, then it sits in the same space - // as other properties in the object literal. So we use SymbolFlags.PropertyExcludes - // so that it will conflict with any other object literal members with the same - // name. - return bindPropertyOrMethodOrAccessor(node, 8192 /* Method */ | (node.questionToken ? 536870912 /* Optional */ : 0 /* None */), ts.isObjectLiteralMethod(node) ? 107455 /* PropertyExcludes */ : 99263 /* MethodExcludes */); - case 213 /* FunctionDeclaration */: - checkStrictModeFunctionName(node); - return declareSymbolAndAddToSymbolTable(node, 16 /* Function */, 106927 /* FunctionExcludes */); - case 144 /* Constructor */: - return declareSymbolAndAddToSymbolTable(node, 16384 /* Constructor */, /*symbolExcludes:*/ 0 /* None */); - case 145 /* GetAccessor */: - return bindPropertyOrMethodOrAccessor(node, 32768 /* GetAccessor */, 41919 /* GetAccessorExcludes */); - case 146 /* SetAccessor */: - return bindPropertyOrMethodOrAccessor(node, 65536 /* SetAccessor */, 74687 /* SetAccessorExcludes */); - case 152 /* FunctionType */: - case 153 /* ConstructorType */: - return bindFunctionOrConstructorType(node); - case 155 /* TypeLiteral */: - return bindAnonymousDeclaration(node, 2048 /* TypeLiteral */, "__type"); - case 165 /* ObjectLiteralExpression */: - return bindObjectLiteralExpression(node); - case 173 /* FunctionExpression */: - case 174 /* ArrowFunction */: - checkStrictModeFunctionName(node); - var bindingName = node.name ? node.name.text : "__function"; - return bindAnonymousDeclaration(node, 16 /* Function */, bindingName); - case 186 /* ClassExpression */: - case 214 /* ClassDeclaration */: - return bindClassLikeDeclaration(node); - case 215 /* InterfaceDeclaration */: - return bindBlockScopedDeclaration(node, 64 /* Interface */, 792960 /* InterfaceExcludes */); - case 216 /* TypeAliasDeclaration */: - return bindBlockScopedDeclaration(node, 524288 /* TypeAlias */, 793056 /* TypeAliasExcludes */); - case 217 /* EnumDeclaration */: - return bindEnumDeclaration(node); - case 218 /* ModuleDeclaration */: - return bindModuleDeclaration(node); - case 221 /* ImportEqualsDeclaration */: - case 224 /* NamespaceImport */: - case 226 /* ImportSpecifier */: - case 230 /* ExportSpecifier */: - return declareSymbolAndAddToSymbolTable(node, 8388608 /* Alias */, 8388608 /* AliasExcludes */); - case 223 /* ImportClause */: - return bindImportClause(node); - case 228 /* ExportDeclaration */: - return bindExportDeclaration(node); - case 227 /* ExportAssignment */: - return bindExportAssignment(node); - case 248 /* SourceFile */: - return bindSourceFileIfExternalModule(); - } - } - function bindSourceFileIfExternalModule() { - setExportContextFlag(file); - if (ts.isExternalModule(file)) { - bindAnonymousDeclaration(file, 512 /* ValueModule */, "\"" + ts.removeFileExtension(file.fileName) + "\""); - } - } - function bindExportAssignment(node) { - if (!container.symbol || !container.symbol.exports) { - // Export assignment in some sort of block construct - bindAnonymousDeclaration(node, 8388608 /* Alias */, getDeclarationName(node)); - } - else if (node.expression.kind === 69 /* Identifier */) { - // An export default clause with an identifier exports all meanings of that identifier - declareSymbol(container.symbol.exports, container.symbol, node, 8388608 /* Alias */, 107455 /* PropertyExcludes */ | 8388608 /* AliasExcludes */); - } - else { - // An export default clause with an expression exports a value - declareSymbol(container.symbol.exports, container.symbol, node, 4 /* Property */, 107455 /* PropertyExcludes */ | 8388608 /* AliasExcludes */); - } - } - function bindExportDeclaration(node) { - if (!container.symbol || !container.symbol.exports) { - // Export * in some sort of block construct - bindAnonymousDeclaration(node, 1073741824 /* ExportStar */, getDeclarationName(node)); - } - else if (!node.exportClause) { - // All export * declarations are collected in an __export symbol - declareSymbol(container.symbol.exports, container.symbol, node, 1073741824 /* ExportStar */, 0 /* None */); - } - } - function bindImportClause(node) { - if (node.name) { - declareSymbolAndAddToSymbolTable(node, 8388608 /* Alias */, 8388608 /* AliasExcludes */); - } - } - function bindClassLikeDeclaration(node) { - if (node.kind === 214 /* ClassDeclaration */) { - bindBlockScopedDeclaration(node, 32 /* Class */, 899519 /* ClassExcludes */); - } - else { - var bindingName = node.name ? node.name.text : "__class"; - bindAnonymousDeclaration(node, 32 /* Class */, bindingName); - // Add name of class expression into the map for semantic classifier - if (node.name) { - classifiableNames[node.name.text] = node.name.text; - } - } - var 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. - var prototypeSymbol = createSymbol(4 /* Property */ | 134217728 /* Prototype */, "prototype"); - if (ts.hasProperty(symbol.exports, prototypeSymbol.name)) { - if (node.name) { - node.name.parent = node; - } - file.bindDiagnostics.push(ts.createDiagnosticForNode(symbol.exports[prototypeSymbol.name].declarations[0], ts.Diagnostics.Duplicate_identifier_0, prototypeSymbol.name)); - } - symbol.exports[prototypeSymbol.name] = prototypeSymbol; - prototypeSymbol.parent = symbol; - } - function bindEnumDeclaration(node) { - return ts.isConst(node) - ? bindBlockScopedDeclaration(node, 128 /* ConstEnum */, 899967 /* ConstEnumExcludes */) - : bindBlockScopedDeclaration(node, 256 /* RegularEnum */, 899327 /* RegularEnumExcludes */); - } - function bindVariableDeclarationOrBindingElement(node) { - if (inStrictMode) { - checkStrictModeEvalOrArguments(node, node.name); - } - if (!ts.isBindingPattern(node.name)) { - if (ts.isBlockOrCatchScoped(node)) { - bindBlockScopedVariableDeclaration(node); - } - else if (ts.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, 1 /* FunctionScopedVariable */, 107455 /* ParameterExcludes */); - } - else { - declareSymbolAndAddToSymbolTable(node, 1 /* FunctionScopedVariable */, 107454 /* FunctionScopedVariableExcludes */); - } - } - } - function bindParameter(node) { - 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 (ts.isBindingPattern(node.name)) { - bindAnonymousDeclaration(node, 1 /* FunctionScopedVariable */, getDestructuringParameterName(node)); - } - else { - declareSymbolAndAddToSymbolTable(node, 1 /* FunctionScopedVariable */, 107455 /* ParameterExcludes */); - } - // If this is a property-parameter, then also declare the property symbol into the - // containing class. - if (node.flags & 112 /* AccessibilityModifier */ && - node.parent.kind === 144 /* Constructor */ && - ts.isClassLike(node.parent.parent)) { - var classDeclaration = node.parent.parent; - declareSymbol(classDeclaration.symbol.members, classDeclaration.symbol, node, 4 /* Property */, 107455 /* PropertyExcludes */); - } - } - function bindPropertyOrMethodOrAccessor(node, symbolFlags, symbolExcludes) { - return ts.hasDynamicName(node) - ? bindAnonymousDeclaration(node, symbolFlags, "__computed") - : declareSymbolAndAddToSymbolTable(node, symbolFlags, symbolExcludes); - } - } -})(ts || (ts = {})); -/// -/// -/* @internal */ -var ts; -(function (ts) { - function getDeclarationOfKind(symbol, kind) { - var declarations = symbol.declarations; - if (declarations) { - for (var _i = 0; _i < declarations.length; _i++) { - var declaration = declarations[_i]; - if (declaration.kind === kind) { - return declaration; - } - } - } - return undefined; - } - ts.getDeclarationOfKind = getDeclarationOfKind; - // Pool writers to avoid needing to allocate them for every symbol we write. - var stringWriters = []; - function getSingleLineStringWriter() { - if (stringWriters.length === 0) { - var str = ""; - var writeText = function (text) { return str += text; }; - return { - string: function () { return str; }, - writeKeyword: writeText, - writeOperator: writeText, - writePunctuation: writeText, - writeSpace: writeText, - writeStringLiteral: writeText, - writeParameter: writeText, - writeSymbol: writeText, - // Completely ignore indentation for string writers. And map newlines to - // a single space. - writeLine: function () { return str += " "; }, - increaseIndent: function () { }, - decreaseIndent: function () { }, - clear: function () { return str = ""; }, - trackSymbol: function () { }, - reportInaccessibleThisError: function () { } - }; - } - return stringWriters.pop(); - } - ts.getSingleLineStringWriter = getSingleLineStringWriter; - function releaseStringWriter(writer) { - writer.clear(); - stringWriters.push(writer); - } - ts.releaseStringWriter = releaseStringWriter; - function getFullWidth(node) { - return node.end - node.pos; - } - ts.getFullWidth = getFullWidth; - function arrayIsEqualTo(array1, array2, equaler) { - if (!array1 || !array2) { - return array1 === array2; - } - if (array1.length !== array2.length) { - return false; - } - for (var i = 0; i < array1.length; ++i) { - var equals = equaler ? equaler(array1[i], array2[i]) : array1[i] === array2[i]; - if (!equals) { - return false; - } - } - return true; - } - ts.arrayIsEqualTo = arrayIsEqualTo; - function hasResolvedModule(sourceFile, moduleNameText) { - return sourceFile.resolvedModules && ts.hasProperty(sourceFile.resolvedModules, moduleNameText); - } - ts.hasResolvedModule = hasResolvedModule; - function getResolvedModule(sourceFile, moduleNameText) { - return hasResolvedModule(sourceFile, moduleNameText) ? sourceFile.resolvedModules[moduleNameText] : undefined; - } - ts.getResolvedModule = getResolvedModule; - function setResolvedModule(sourceFile, moduleNameText, resolvedModule) { - if (!sourceFile.resolvedModules) { - sourceFile.resolvedModules = {}; - } - sourceFile.resolvedModules[moduleNameText] = resolvedModule; - } - ts.setResolvedModule = setResolvedModule; - // Returns true if this node contains a parse error anywhere underneath it. - function containsParseError(node) { - aggregateChildData(node); - return (node.parserContextFlags & 64 /* ThisNodeOrAnySubNodesHasError */) !== 0; - } - ts.containsParseError = containsParseError; - function aggregateChildData(node) { - if (!(node.parserContextFlags & 128 /* HasAggregatedChildData */)) { - // A node is considered to contain a parse error if: - // a) the parser explicitly marked that it had an error - // b) any of it's children reported that it had an error. - var thisNodeOrAnySubNodesHasError = ((node.parserContextFlags & 16 /* ThisNodeHasError */) !== 0) || - ts.forEachChild(node, containsParseError); - // If so, mark ourselves accordingly. - if (thisNodeOrAnySubNodesHasError) { - node.parserContextFlags |= 64 /* ThisNodeOrAnySubNodesHasError */; - } - // Also mark that we've propogated the child information to this node. This way we can - // always consult the bit directly on this node without needing to check its children - // again. - node.parserContextFlags |= 128 /* HasAggregatedChildData */; - } - } - function getSourceFileOfNode(node) { - while (node && node.kind !== 248 /* SourceFile */) { - node = node.parent; - } - return node; - } - ts.getSourceFileOfNode = getSourceFileOfNode; - function getStartPositionOfLine(line, sourceFile) { - ts.Debug.assert(line >= 0); - return ts.getLineStarts(sourceFile)[line]; - } - ts.getStartPositionOfLine = getStartPositionOfLine; - // This is a useful function for debugging purposes. - function nodePosToString(node) { - var file = getSourceFileOfNode(node); - var loc = ts.getLineAndCharacterOfPosition(file, node.pos); - return file.fileName + "(" + (loc.line + 1) + "," + (loc.character + 1) + ")"; - } - ts.nodePosToString = nodePosToString; - function getStartPosOfNode(node) { - return node.pos; - } - ts.getStartPosOfNode = getStartPosOfNode; - // Returns true if this node is missing from the actual source code. A 'missing' node is different - // from 'undefined/defined'. When a node is undefined (which can happen for optional nodes - // in the tree), it is definitely missing. However, a node may be defined, but still be - // missing. This happens whenever the parser knows it needs to parse something, but can't - // get anything in the source code that it expects at that location. For example: - // - // let a: ; - // - // Here, the Type in the Type-Annotation is not-optional (as there is a colon in the source - // code). So the parser will attempt to parse out a type, and will create an actual node. - // However, this node will be 'missing' in the sense that no actual source-code/tokens are - // contained within it. - function nodeIsMissing(node) { - if (!node) { - return true; - } - return node.pos === node.end && node.pos >= 0 && node.kind !== 1 /* EndOfFileToken */; - } - ts.nodeIsMissing = nodeIsMissing; - function nodeIsPresent(node) { - return !nodeIsMissing(node); - } - ts.nodeIsPresent = nodeIsPresent; - function getTokenPosOfNode(node, sourceFile) { - // With nodes that have no width (i.e. 'Missing' nodes), we actually *don't* - // want to skip trivia because this will launch us forward to the next token. - if (nodeIsMissing(node)) { - return node.pos; - } - return ts.skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.pos); - } - ts.getTokenPosOfNode = getTokenPosOfNode; - function getNonDecoratorTokenPosOfNode(node, sourceFile) { - if (nodeIsMissing(node) || !node.decorators) { - return getTokenPosOfNode(node, sourceFile); - } - return ts.skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.decorators.end); - } - ts.getNonDecoratorTokenPosOfNode = getNonDecoratorTokenPosOfNode; - function getSourceTextOfNodeFromSourceFile(sourceFile, node, includeTrivia) { - if (includeTrivia === void 0) { includeTrivia = false; } - if (nodeIsMissing(node)) { - return ""; - } - var text = sourceFile.text; - return text.substring(includeTrivia ? node.pos : ts.skipTrivia(text, node.pos), node.end); - } - ts.getSourceTextOfNodeFromSourceFile = getSourceTextOfNodeFromSourceFile; - function getTextOfNodeFromSourceText(sourceText, node) { - if (nodeIsMissing(node)) { - return ""; - } - return sourceText.substring(ts.skipTrivia(sourceText, node.pos), node.end); - } - ts.getTextOfNodeFromSourceText = getTextOfNodeFromSourceText; - function getTextOfNode(node, includeTrivia) { - if (includeTrivia === void 0) { includeTrivia = false; } - return getSourceTextOfNodeFromSourceFile(getSourceFileOfNode(node), node, includeTrivia); - } - ts.getTextOfNode = getTextOfNode; - // Add an extra underscore to identifiers that start with two underscores to avoid issues with magic names like '__proto__' - function escapeIdentifier(identifier) { - return identifier.length >= 2 && identifier.charCodeAt(0) === 95 /* _ */ && identifier.charCodeAt(1) === 95 /* _ */ ? "_" + identifier : identifier; - } - ts.escapeIdentifier = escapeIdentifier; - // Remove extra underscore from escaped identifier - function unescapeIdentifier(identifier) { - return identifier.length >= 3 && identifier.charCodeAt(0) === 95 /* _ */ && identifier.charCodeAt(1) === 95 /* _ */ && identifier.charCodeAt(2) === 95 /* _ */ ? identifier.substr(1) : identifier; - } - ts.unescapeIdentifier = unescapeIdentifier; - // Make an identifier from an external module name by extracting the string after the last "/" and replacing - // all non-alphanumeric characters with underscores - function makeIdentifierFromModuleName(moduleName) { - return ts.getBaseFileName(moduleName).replace(/^(\d)/, "_$1").replace(/\W/g, "_"); - } - ts.makeIdentifierFromModuleName = makeIdentifierFromModuleName; - function isBlockOrCatchScoped(declaration) { - return (getCombinedNodeFlags(declaration) & 49152 /* BlockScoped */) !== 0 || - isCatchClauseVariableDeclaration(declaration); - } - ts.isBlockOrCatchScoped = isBlockOrCatchScoped; - // Gets the nearest enclosing block scope container that has the provided node - // as a descendant, that is not the provided node. - function getEnclosingBlockScopeContainer(node) { - var current = node.parent; - while (current) { - if (isFunctionLike(current)) { - return current; - } - switch (current.kind) { - case 248 /* SourceFile */: - case 220 /* CaseBlock */: - case 244 /* CatchClause */: - case 218 /* ModuleDeclaration */: - case 199 /* ForStatement */: - case 200 /* ForInStatement */: - case 201 /* ForOfStatement */: - return current; - case 192 /* Block */: - // function block is not considered block-scope container - // see comment in binder.ts: bind(...), case for SyntaxKind.Block - if (!isFunctionLike(current.parent)) { - return current; - } - } - current = current.parent; - } - } - ts.getEnclosingBlockScopeContainer = getEnclosingBlockScopeContainer; - function isCatchClauseVariableDeclaration(declaration) { - return declaration && - declaration.kind === 211 /* VariableDeclaration */ && - declaration.parent && - declaration.parent.kind === 244 /* CatchClause */; - } - ts.isCatchClauseVariableDeclaration = isCatchClauseVariableDeclaration; - // 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. - function declarationNameToString(name) { - return getFullWidth(name) === 0 ? "(Missing)" : getTextOfNode(name); - } - ts.declarationNameToString = declarationNameToString; - function createDiagnosticForNode(node, message, arg0, arg1, arg2) { - var sourceFile = getSourceFileOfNode(node); - var span = getErrorSpanForNode(sourceFile, node); - return ts.createFileDiagnostic(sourceFile, span.start, span.length, message, arg0, arg1, arg2); - } - ts.createDiagnosticForNode = createDiagnosticForNode; - function createDiagnosticForNodeFromMessageChain(node, messageChain) { - var sourceFile = getSourceFileOfNode(node); - var span = getErrorSpanForNode(sourceFile, node); - return { - file: sourceFile, - start: span.start, - length: span.length, - code: messageChain.code, - category: messageChain.category, - messageText: messageChain.next ? messageChain : messageChain.messageText - }; - } - ts.createDiagnosticForNodeFromMessageChain = createDiagnosticForNodeFromMessageChain; - function getSpanOfTokenAtPosition(sourceFile, pos) { - var scanner = ts.createScanner(sourceFile.languageVersion, /*skipTrivia*/ true, sourceFile.languageVariant, sourceFile.text, /*onError:*/ undefined, pos); - scanner.scan(); - var start = scanner.getTokenPos(); - return ts.createTextSpanFromBounds(start, scanner.getTextPos()); - } - ts.getSpanOfTokenAtPosition = getSpanOfTokenAtPosition; - function getErrorSpanForNode(sourceFile, node) { - var errorNode = node; - switch (node.kind) { - case 248 /* SourceFile */: - var pos_1 = ts.skipTrivia(sourceFile.text, 0, /*stopAfterLineBreak*/ false); - if (pos_1 === sourceFile.text.length) { - // file is empty - return span for the beginning of the file - return ts.createTextSpan(0, 0); - } - return getSpanOfTokenAtPosition(sourceFile, pos_1); - // This list is a work in progress. Add missing node kinds to improve their error - // spans. - case 211 /* VariableDeclaration */: - case 163 /* BindingElement */: - case 214 /* ClassDeclaration */: - case 186 /* ClassExpression */: - case 215 /* InterfaceDeclaration */: - case 218 /* ModuleDeclaration */: - case 217 /* EnumDeclaration */: - case 247 /* EnumMember */: - case 213 /* FunctionDeclaration */: - case 173 /* FunctionExpression */: - errorNode = node.name; - break; - } - if (errorNode === undefined) { - // If we don't have a better node, then just set the error on the first token of - // construct. - return getSpanOfTokenAtPosition(sourceFile, node.pos); - } - var pos = nodeIsMissing(errorNode) - ? errorNode.pos - : ts.skipTrivia(sourceFile.text, errorNode.pos); - return ts.createTextSpanFromBounds(pos, errorNode.end); - } - ts.getErrorSpanForNode = getErrorSpanForNode; - function isExternalModule(file) { - return file.externalModuleIndicator !== undefined; - } - ts.isExternalModule = isExternalModule; - function isDeclarationFile(file) { - return (file.flags & 8192 /* DeclarationFile */) !== 0; - } - ts.isDeclarationFile = isDeclarationFile; - function isConstEnumDeclaration(node) { - return node.kind === 217 /* EnumDeclaration */ && isConst(node); - } - ts.isConstEnumDeclaration = isConstEnumDeclaration; - function walkUpBindingElementsAndPatterns(node) { - while (node && (node.kind === 163 /* BindingElement */ || isBindingPattern(node))) { - node = node.parent; - } - return node; - } - // Returns the node flags for this node and all relevant parent nodes. This is done so that - // nodes like variable declarations and binding elements can returned a view of their flags - // that includes the modifiers from their container. i.e. flags like export/declare aren't - // stored on the variable declaration directly, but on the containing variable statement - // (if it has one). Similarly, flags for let/const are store on the variable declaration - // list. By calling this function, all those flags are combined so that the client can treat - // the node as if it actually had those flags. - function getCombinedNodeFlags(node) { - node = walkUpBindingElementsAndPatterns(node); - var flags = node.flags; - if (node.kind === 211 /* VariableDeclaration */) { - node = node.parent; - } - if (node && node.kind === 212 /* VariableDeclarationList */) { - flags |= node.flags; - node = node.parent; - } - if (node && node.kind === 193 /* VariableStatement */) { - flags |= node.flags; - } - return flags; - } - ts.getCombinedNodeFlags = getCombinedNodeFlags; - function isConst(node) { - return !!(getCombinedNodeFlags(node) & 32768 /* Const */); - } - ts.isConst = isConst; - function isLet(node) { - return !!(getCombinedNodeFlags(node) & 16384 /* Let */); - } - ts.isLet = isLet; - function isPrologueDirective(node) { - return node.kind === 195 /* ExpressionStatement */ && node.expression.kind === 9 /* StringLiteral */; - } - ts.isPrologueDirective = isPrologueDirective; - function getLeadingCommentRangesOfNode(node, sourceFileOfNode) { - return ts.getLeadingCommentRanges(sourceFileOfNode.text, node.pos); - } - ts.getLeadingCommentRangesOfNode = getLeadingCommentRangesOfNode; - function getJsDocComments(node, sourceFileOfNode) { - var commentRanges = (node.kind === 138 /* Parameter */ || node.kind === 137 /* TypeParameter */) ? - ts.concatenate(ts.getTrailingCommentRanges(sourceFileOfNode.text, node.pos), ts.getLeadingCommentRanges(sourceFileOfNode.text, node.pos)) : - getLeadingCommentRangesOfNode(node, sourceFileOfNode); - return ts.filter(commentRanges, isJsDocComment); - function isJsDocComment(comment) { - // True if the comment starts with '/**' but not if it is '/**/' - return sourceFileOfNode.text.charCodeAt(comment.pos + 1) === 42 /* asterisk */ && - sourceFileOfNode.text.charCodeAt(comment.pos + 2) === 42 /* asterisk */ && - sourceFileOfNode.text.charCodeAt(comment.pos + 3) !== 47 /* slash */; - } - } - ts.getJsDocComments = getJsDocComments; - ts.fullTripleSlashReferencePathRegEx = /^(\/\/\/\s*/; - ts.fullTripleSlashAMDReferencePathRegEx = /^(\/\/\/\s*/; - function isTypeNode(node) { - if (151 /* FirstTypeNode */ <= node.kind && node.kind <= 160 /* LastTypeNode */) { - return true; - } - switch (node.kind) { - case 117 /* AnyKeyword */: - case 128 /* NumberKeyword */: - case 130 /* StringKeyword */: - case 120 /* BooleanKeyword */: - case 131 /* SymbolKeyword */: - return true; - case 103 /* VoidKeyword */: - return node.parent.kind !== 177 /* VoidExpression */; - case 9 /* StringLiteral */: - // Specialized signatures can have string literals as their parameters' type names - return node.parent.kind === 138 /* Parameter */; - case 188 /* ExpressionWithTypeArguments */: - return !isExpressionWithTypeArgumentsInClassExtendsClause(node); - // Identifiers and qualified names may be type nodes, depending on their context. Climb - // above them to find the lowest container - case 69 /* Identifier */: - // If the identifier is the RHS of a qualified name, then it's a type iff its parent is. - if (node.parent.kind === 135 /* QualifiedName */ && node.parent.right === node) { - node = node.parent; - } - else if (node.parent.kind === 166 /* 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 === 135 /* QualifiedName */ || node.kind === 166 /* PropertyAccessExpression */, "'node' was expected to be a qualified name, identifier or property access in 'isTypeNode'."); - case 135 /* QualifiedName */: - case 166 /* PropertyAccessExpression */: - case 97 /* ThisKeyword */: - var parent_1 = node.parent; - if (parent_1.kind === 154 /* TypeQuery */) { - return false; - } - // Do not recursively call isTypeNode on the parent. In the example: - // - // let a: A.B.C; - // - // Calling isTypeNode would consider the qualified name A.B a type node. Only C or - // A.B.C is a type node. - if (151 /* FirstTypeNode */ <= parent_1.kind && parent_1.kind <= 160 /* LastTypeNode */) { - return true; - } - switch (parent_1.kind) { - case 188 /* ExpressionWithTypeArguments */: - return !isExpressionWithTypeArgumentsInClassExtendsClause(parent_1); - case 137 /* TypeParameter */: - return node === parent_1.constraint; - case 141 /* PropertyDeclaration */: - case 140 /* PropertySignature */: - case 138 /* Parameter */: - case 211 /* VariableDeclaration */: - return node === parent_1.type; - case 213 /* FunctionDeclaration */: - case 173 /* FunctionExpression */: - case 174 /* ArrowFunction */: - case 144 /* Constructor */: - case 143 /* MethodDeclaration */: - case 142 /* MethodSignature */: - case 145 /* GetAccessor */: - case 146 /* SetAccessor */: - return node === parent_1.type; - case 147 /* CallSignature */: - case 148 /* ConstructSignature */: - case 149 /* IndexSignature */: - return node === parent_1.type; - case 171 /* TypeAssertionExpression */: - return node === parent_1.type; - case 168 /* CallExpression */: - case 169 /* NewExpression */: - return parent_1.typeArguments && ts.indexOf(parent_1.typeArguments, node) >= 0; - case 170 /* TaggedTemplateExpression */: - // TODO (drosen): TaggedTemplateExpressions may eventually support type arguments. - return false; - } - } - return false; - } - ts.isTypeNode = isTypeNode; - // Warning: This has the same semantics as the forEach family of functions, - // in that traversal terminates in the event that 'visitor' supplies a truthy value. - function forEachReturnStatement(body, visitor) { - return traverse(body); - function traverse(node) { - switch (node.kind) { - case 204 /* ReturnStatement */: - return visitor(node); - case 220 /* CaseBlock */: - case 192 /* Block */: - case 196 /* IfStatement */: - case 197 /* DoStatement */: - case 198 /* WhileStatement */: - case 199 /* ForStatement */: - case 200 /* ForInStatement */: - case 201 /* ForOfStatement */: - case 205 /* WithStatement */: - case 206 /* SwitchStatement */: - case 241 /* CaseClause */: - case 242 /* DefaultClause */: - case 207 /* LabeledStatement */: - case 209 /* TryStatement */: - case 244 /* CatchClause */: - return ts.forEachChild(node, traverse); - } - } - } - ts.forEachReturnStatement = forEachReturnStatement; - function forEachYieldExpression(body, visitor) { - return traverse(body); - function traverse(node) { - switch (node.kind) { - case 184 /* YieldExpression */: - visitor(node); - var operand = node.expression; - if (operand) { - traverse(operand); - } - case 217 /* EnumDeclaration */: - case 215 /* InterfaceDeclaration */: - case 218 /* ModuleDeclaration */: - case 216 /* TypeAliasDeclaration */: - case 214 /* ClassDeclaration */: - case 186 /* ClassExpression */: - // These are not allowed inside a generator now, but eventually they may be allowed - // as local types. Regardless, any yield statements contained within them should be - // skipped in this traversal. - return; - default: - if (isFunctionLike(node)) { - var name_5 = node.name; - if (name_5 && name_5.kind === 136 /* ComputedPropertyName */) { - // Note that we will not include methods/accessors of a class because they would require - // first descending into the class. This is by design. - traverse(name_5.expression); - return; - } - } - else if (!isTypeNode(node)) { - // This is the general case, which should include mostly expressions and statements. - // Also includes NodeArrays. - ts.forEachChild(node, traverse); - } - } - } - } - ts.forEachYieldExpression = forEachYieldExpression; - function isVariableLike(node) { - if (node) { - switch (node.kind) { - case 163 /* BindingElement */: - case 247 /* EnumMember */: - case 138 /* Parameter */: - case 245 /* PropertyAssignment */: - case 141 /* PropertyDeclaration */: - case 140 /* PropertySignature */: - case 246 /* ShorthandPropertyAssignment */: - case 211 /* VariableDeclaration */: - return true; - } - } - return false; - } - ts.isVariableLike = isVariableLike; - function isAccessor(node) { - return node && (node.kind === 145 /* GetAccessor */ || node.kind === 146 /* SetAccessor */); - } - ts.isAccessor = isAccessor; - function isClassLike(node) { - return node && (node.kind === 214 /* ClassDeclaration */ || node.kind === 186 /* ClassExpression */); - } - ts.isClassLike = isClassLike; - function isFunctionLike(node) { - if (node) { - switch (node.kind) { - case 144 /* Constructor */: - case 173 /* FunctionExpression */: - case 213 /* FunctionDeclaration */: - case 174 /* ArrowFunction */: - case 143 /* MethodDeclaration */: - case 142 /* MethodSignature */: - case 145 /* GetAccessor */: - case 146 /* SetAccessor */: - case 147 /* CallSignature */: - case 148 /* ConstructSignature */: - case 149 /* IndexSignature */: - case 152 /* FunctionType */: - case 153 /* ConstructorType */: - return true; - } - } - return false; - } - ts.isFunctionLike = isFunctionLike; - function introducesArgumentsExoticObject(node) { - switch (node.kind) { - case 143 /* MethodDeclaration */: - case 142 /* MethodSignature */: - case 144 /* Constructor */: - case 145 /* GetAccessor */: - case 146 /* SetAccessor */: - case 213 /* FunctionDeclaration */: - case 173 /* FunctionExpression */: - return true; - } - return false; - } - ts.introducesArgumentsExoticObject = introducesArgumentsExoticObject; - function isFunctionBlock(node) { - return node && node.kind === 192 /* Block */ && isFunctionLike(node.parent); - } - ts.isFunctionBlock = isFunctionBlock; - function isObjectLiteralMethod(node) { - return node && node.kind === 143 /* MethodDeclaration */ && node.parent.kind === 165 /* ObjectLiteralExpression */; - } - ts.isObjectLiteralMethod = isObjectLiteralMethod; - function getContainingFunction(node) { - while (true) { - node = node.parent; - if (!node || isFunctionLike(node)) { - return node; - } - } - } - ts.getContainingFunction = getContainingFunction; - function getContainingClass(node) { - while (true) { - node = node.parent; - if (!node || isClassLike(node)) { - return node; - } - } - } - ts.getContainingClass = getContainingClass; - function getThisContainer(node, includeArrowFunctions) { - while (true) { - node = node.parent; - if (!node) { - return undefined; - } - switch (node.kind) { - case 136 /* ComputedPropertyName */: - // If the grandparent node is an object literal (as opposed to a class), - // then the computed property is not a 'this' container. - // A computed property name in a class needs to be a this container - // so that we can error on it. - if (isClassLike(node.parent.parent)) { - return node; - } - // If this is a computed property, then the parent should not - // make it a this container. The parent might be a property - // in an object literal, like a method or accessor. But in order for - // such a parent to be a this container, the reference must be in - // the *body* of the container. - node = node.parent; - break; - case 139 /* Decorator */: - // Decorators are always applied outside of the body of a class or method. - if (node.parent.kind === 138 /* Parameter */ && isClassElement(node.parent.parent)) { - // If the decorator's parent is a Parameter, we resolve the this container from - // the grandparent class declaration. - node = node.parent.parent; - } - else if (isClassElement(node.parent)) { - // If the decorator's parent is a class element, we resolve the 'this' container - // from the parent class declaration. - node = node.parent; - } - break; - case 174 /* ArrowFunction */: - if (!includeArrowFunctions) { - continue; - } - // Fall through - case 213 /* FunctionDeclaration */: - case 173 /* FunctionExpression */: - case 218 /* ModuleDeclaration */: - case 141 /* PropertyDeclaration */: - case 140 /* PropertySignature */: - case 143 /* MethodDeclaration */: - case 142 /* MethodSignature */: - case 144 /* Constructor */: - case 145 /* GetAccessor */: - case 146 /* SetAccessor */: - case 147 /* CallSignature */: - case 148 /* ConstructSignature */: - case 149 /* IndexSignature */: - case 217 /* EnumDeclaration */: - case 248 /* SourceFile */: - return node; - } - } - } - ts.getThisContainer = getThisContainer; - function getSuperContainer(node, includeFunctions) { - while (true) { - node = node.parent; - if (!node) - return node; - switch (node.kind) { - case 136 /* ComputedPropertyName */: - // If the grandparent node is an object literal (as opposed to a class), - // then the computed property is not a 'super' container. - // A computed property name in a class needs to be a super container - // so that we can error on it. - if (isClassLike(node.parent.parent)) { - return node; - } - // If this is a computed property, then the parent should not - // make it a super container. The parent might be a property - // in an object literal, like a method or accessor. But in order for - // such a parent to be a super container, the reference must be in - // the *body* of the container. - node = node.parent; - break; - case 139 /* Decorator */: - // Decorators are always applied outside of the body of a class or method. - if (node.parent.kind === 138 /* Parameter */ && isClassElement(node.parent.parent)) { - // If the decorator's parent is a Parameter, we resolve the this container from - // the grandparent class declaration. - node = node.parent.parent; - } - else if (isClassElement(node.parent)) { - // If the decorator's parent is a class element, we resolve the 'this' container - // from the parent class declaration. - node = node.parent; - } - break; - case 213 /* FunctionDeclaration */: - case 173 /* FunctionExpression */: - case 174 /* ArrowFunction */: - if (!includeFunctions) { - continue; - } - case 141 /* PropertyDeclaration */: - case 140 /* PropertySignature */: - case 143 /* MethodDeclaration */: - case 142 /* MethodSignature */: - case 144 /* Constructor */: - case 145 /* GetAccessor */: - case 146 /* SetAccessor */: - return node; - } - } - } - ts.getSuperContainer = getSuperContainer; - function getEntityNameFromTypeNode(node) { - if (node) { - switch (node.kind) { - case 151 /* TypeReference */: - return node.typeName; - case 188 /* ExpressionWithTypeArguments */: - return node.expression; - case 69 /* Identifier */: - case 135 /* QualifiedName */: - return node; - } - } - return undefined; - } - ts.getEntityNameFromTypeNode = getEntityNameFromTypeNode; - function getInvokedExpression(node) { - if (node.kind === 170 /* TaggedTemplateExpression */) { - return node.tag; - } - // Will either be a CallExpression, NewExpression, or Decorator. - return node.expression; - } - ts.getInvokedExpression = getInvokedExpression; - function nodeCanBeDecorated(node) { - switch (node.kind) { - case 214 /* ClassDeclaration */: - // classes are valid targets - return true; - case 141 /* PropertyDeclaration */: - // property declarations are valid if their parent is a class declaration. - return node.parent.kind === 214 /* ClassDeclaration */; - case 138 /* Parameter */: - // if the parameter's parent has a body and its grandparent is a class declaration, this is a valid target; - return node.parent.body && node.parent.parent.kind === 214 /* ClassDeclaration */; - case 145 /* GetAccessor */: - case 146 /* SetAccessor */: - case 143 /* MethodDeclaration */: - // if this method has a body and its parent is a class declaration, this is a valid target. - return node.body && node.parent.kind === 214 /* ClassDeclaration */; - } - return false; - } - ts.nodeCanBeDecorated = nodeCanBeDecorated; - function nodeIsDecorated(node) { - switch (node.kind) { - case 214 /* ClassDeclaration */: - if (node.decorators) { - return true; - } - return false; - case 141 /* PropertyDeclaration */: - case 138 /* Parameter */: - if (node.decorators) { - return true; - } - return false; - case 145 /* GetAccessor */: - if (node.body && node.decorators) { - return true; - } - return false; - case 143 /* MethodDeclaration */: - case 146 /* SetAccessor */: - if (node.body && node.decorators) { - return true; - } - return false; - } - return false; - } - ts.nodeIsDecorated = nodeIsDecorated; - function childIsDecorated(node) { - switch (node.kind) { - case 214 /* ClassDeclaration */: - return ts.forEach(node.members, nodeOrChildIsDecorated); - case 143 /* MethodDeclaration */: - case 146 /* SetAccessor */: - return ts.forEach(node.parameters, nodeIsDecorated); - } - return false; - } - ts.childIsDecorated = childIsDecorated; - function nodeOrChildIsDecorated(node) { - return nodeIsDecorated(node) || childIsDecorated(node); - } - ts.nodeOrChildIsDecorated = nodeOrChildIsDecorated; - function isPropertyAccessExpression(node) { - return node.kind === 166 /* PropertyAccessExpression */; - } - ts.isPropertyAccessExpression = isPropertyAccessExpression; - function isElementAccessExpression(node) { - return node.kind === 167 /* ElementAccessExpression */; - } - ts.isElementAccessExpression = isElementAccessExpression; - function isExpression(node) { - switch (node.kind) { - case 95 /* SuperKeyword */: - case 93 /* NullKeyword */: - case 99 /* TrueKeyword */: - case 84 /* FalseKeyword */: - case 10 /* RegularExpressionLiteral */: - case 164 /* ArrayLiteralExpression */: - case 165 /* ObjectLiteralExpression */: - case 166 /* PropertyAccessExpression */: - case 167 /* ElementAccessExpression */: - case 168 /* CallExpression */: - case 169 /* NewExpression */: - case 170 /* TaggedTemplateExpression */: - case 189 /* AsExpression */: - case 171 /* TypeAssertionExpression */: - case 172 /* ParenthesizedExpression */: - case 173 /* FunctionExpression */: - case 186 /* ClassExpression */: - case 174 /* ArrowFunction */: - case 177 /* VoidExpression */: - case 175 /* DeleteExpression */: - case 176 /* TypeOfExpression */: - case 179 /* PrefixUnaryExpression */: - case 180 /* PostfixUnaryExpression */: - case 181 /* BinaryExpression */: - case 182 /* ConditionalExpression */: - case 185 /* SpreadElementExpression */: - case 183 /* TemplateExpression */: - case 11 /* NoSubstitutionTemplateLiteral */: - case 187 /* OmittedExpression */: - case 233 /* JsxElement */: - case 234 /* JsxSelfClosingElement */: - case 184 /* YieldExpression */: - case 178 /* AwaitExpression */: - return true; - case 135 /* QualifiedName */: - while (node.parent.kind === 135 /* QualifiedName */) { - node = node.parent; - } - return node.parent.kind === 154 /* TypeQuery */; - case 69 /* Identifier */: - if (node.parent.kind === 154 /* TypeQuery */) { - return true; - } - // fall through - case 8 /* NumericLiteral */: - case 9 /* StringLiteral */: - case 97 /* ThisKeyword */: - var parent_2 = node.parent; - switch (parent_2.kind) { - case 211 /* VariableDeclaration */: - case 138 /* Parameter */: - case 141 /* PropertyDeclaration */: - case 140 /* PropertySignature */: - case 247 /* EnumMember */: - case 245 /* PropertyAssignment */: - case 163 /* BindingElement */: - return parent_2.initializer === node; - case 195 /* ExpressionStatement */: - case 196 /* IfStatement */: - case 197 /* DoStatement */: - case 198 /* WhileStatement */: - case 204 /* ReturnStatement */: - case 205 /* WithStatement */: - case 206 /* SwitchStatement */: - case 241 /* CaseClause */: - case 208 /* ThrowStatement */: - case 206 /* SwitchStatement */: - return parent_2.expression === node; - case 199 /* ForStatement */: - var forStatement = parent_2; - return (forStatement.initializer === node && forStatement.initializer.kind !== 212 /* VariableDeclarationList */) || - forStatement.condition === node || - forStatement.incrementor === node; - case 200 /* ForInStatement */: - case 201 /* ForOfStatement */: - var forInStatement = parent_2; - return (forInStatement.initializer === node && forInStatement.initializer.kind !== 212 /* VariableDeclarationList */) || - forInStatement.expression === node; - case 171 /* TypeAssertionExpression */: - case 189 /* AsExpression */: - return node === parent_2.expression; - case 190 /* TemplateSpan */: - return node === parent_2.expression; - case 136 /* ComputedPropertyName */: - return node === parent_2.expression; - case 139 /* Decorator */: - case 240 /* JsxExpression */: - case 239 /* JsxSpreadAttribute */: - return true; - case 188 /* ExpressionWithTypeArguments */: - return parent_2.expression === node && isExpressionWithTypeArgumentsInClassExtendsClause(parent_2); - default: - if (isExpression(parent_2)) { - return true; - } - } - } - return false; - } - ts.isExpression = isExpression; - function isExternalModuleNameRelative(moduleName) { - // TypeScript 1.0 spec (April 2014): 11.2.1 - // An external module name is "relative" if the first term is "." or "..". - return moduleName.substr(0, 2) === "./" || moduleName.substr(0, 3) === "../" || moduleName.substr(0, 2) === ".\\" || moduleName.substr(0, 3) === "..\\"; - } - ts.isExternalModuleNameRelative = isExternalModuleNameRelative; - function isInstantiatedModule(node, preserveConstEnums) { - var moduleState = ts.getModuleInstanceState(node); - return moduleState === 1 /* Instantiated */ || - (preserveConstEnums && moduleState === 2 /* ConstEnumOnly */); - } - ts.isInstantiatedModule = isInstantiatedModule; - function isExternalModuleImportEqualsDeclaration(node) { - return node.kind === 221 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 232 /* ExternalModuleReference */; - } - ts.isExternalModuleImportEqualsDeclaration = isExternalModuleImportEqualsDeclaration; - function getExternalModuleImportEqualsDeclarationExpression(node) { - ts.Debug.assert(isExternalModuleImportEqualsDeclaration(node)); - return node.moduleReference.expression; - } - ts.getExternalModuleImportEqualsDeclarationExpression = getExternalModuleImportEqualsDeclarationExpression; - function isInternalModuleImportEqualsDeclaration(node) { - return node.kind === 221 /* ImportEqualsDeclaration */ && node.moduleReference.kind !== 232 /* ExternalModuleReference */; - } - ts.isInternalModuleImportEqualsDeclaration = isInternalModuleImportEqualsDeclaration; - function getExternalModuleName(node) { - if (node.kind === 222 /* ImportDeclaration */) { - return node.moduleSpecifier; - } - if (node.kind === 221 /* ImportEqualsDeclaration */) { - var reference = node.moduleReference; - if (reference.kind === 232 /* ExternalModuleReference */) { - return reference.expression; - } - } - if (node.kind === 228 /* ExportDeclaration */) { - return node.moduleSpecifier; - } - } - ts.getExternalModuleName = getExternalModuleName; - function hasQuestionToken(node) { - if (node) { - switch (node.kind) { - case 138 /* Parameter */: - case 143 /* MethodDeclaration */: - case 142 /* MethodSignature */: - case 246 /* ShorthandPropertyAssignment */: - case 245 /* PropertyAssignment */: - case 141 /* PropertyDeclaration */: - case 140 /* PropertySignature */: - return node.questionToken !== undefined; - } - } - return false; - } - ts.hasQuestionToken = hasQuestionToken; - function isJSDocConstructSignature(node) { - return node.kind === 261 /* JSDocFunctionType */ && - node.parameters.length > 0 && - node.parameters[0].type.kind === 263 /* JSDocConstructorType */; - } - ts.isJSDocConstructSignature = isJSDocConstructSignature; - function getJSDocTag(node, kind) { - if (node && node.jsDocComment) { - for (var _i = 0, _a = node.jsDocComment.tags; _i < _a.length; _i++) { - var tag = _a[_i]; - if (tag.kind === kind) { - return tag; - } - } - } - } - function getJSDocTypeTag(node) { - return getJSDocTag(node, 269 /* JSDocTypeTag */); - } - ts.getJSDocTypeTag = getJSDocTypeTag; - function getJSDocReturnTag(node) { - return getJSDocTag(node, 268 /* JSDocReturnTag */); - } - ts.getJSDocReturnTag = getJSDocReturnTag; - function getJSDocTemplateTag(node) { - return getJSDocTag(node, 270 /* JSDocTemplateTag */); - } - ts.getJSDocTemplateTag = getJSDocTemplateTag; - function getCorrespondingJSDocParameterTag(parameter) { - if (parameter.name && parameter.name.kind === 69 /* Identifier */) { - // If it's a parameter, see if the parent has a jsdoc comment with an @param - // annotation. - var parameterName = parameter.name.text; - var docComment = parameter.parent.jsDocComment; - if (docComment) { - return ts.forEach(docComment.tags, function (t) { - if (t.kind === 267 /* JSDocParameterTag */) { - var parameterTag = t; - var name_6 = parameterTag.preParameterName || parameterTag.postParameterName; - if (name_6.text === parameterName) { - return t; - } - } - }); - } - } - } - ts.getCorrespondingJSDocParameterTag = getCorrespondingJSDocParameterTag; - function hasRestParameter(s) { - return isRestParameter(ts.lastOrUndefined(s.parameters)); - } - ts.hasRestParameter = hasRestParameter; - function isRestParameter(node) { - if (node) { - if (node.parserContextFlags & 32 /* JavaScriptFile */) { - if (node.type && node.type.kind === 262 /* JSDocVariadicType */) { - return true; - } - var paramTag = getCorrespondingJSDocParameterTag(node); - if (paramTag && paramTag.typeExpression) { - return paramTag.typeExpression.type.kind === 262 /* JSDocVariadicType */; - } - } - return node.dotDotDotToken !== undefined; - } - return false; - } - ts.isRestParameter = isRestParameter; - function isLiteralKind(kind) { - return 8 /* FirstLiteralToken */ <= kind && kind <= 11 /* LastLiteralToken */; - } - ts.isLiteralKind = isLiteralKind; - function isTextualLiteralKind(kind) { - return kind === 9 /* StringLiteral */ || kind === 11 /* NoSubstitutionTemplateLiteral */; - } - ts.isTextualLiteralKind = isTextualLiteralKind; - function isTemplateLiteralKind(kind) { - return 11 /* FirstTemplateToken */ <= kind && kind <= 14 /* LastTemplateToken */; - } - ts.isTemplateLiteralKind = isTemplateLiteralKind; - function isBindingPattern(node) { - return !!node && (node.kind === 162 /* ArrayBindingPattern */ || node.kind === 161 /* ObjectBindingPattern */); - } - ts.isBindingPattern = isBindingPattern; - function isInAmbientContext(node) { - while (node) { - if (node.flags & (2 /* Ambient */ | 8192 /* DeclarationFile */)) { - return true; - } - node = node.parent; - } - return false; - } - ts.isInAmbientContext = isInAmbientContext; - function isDeclaration(node) { - switch (node.kind) { - case 174 /* ArrowFunction */: - case 163 /* BindingElement */: - case 214 /* ClassDeclaration */: - case 186 /* ClassExpression */: - case 144 /* Constructor */: - case 217 /* EnumDeclaration */: - case 247 /* EnumMember */: - case 230 /* ExportSpecifier */: - case 213 /* FunctionDeclaration */: - case 173 /* FunctionExpression */: - case 145 /* GetAccessor */: - case 223 /* ImportClause */: - case 221 /* ImportEqualsDeclaration */: - case 226 /* ImportSpecifier */: - case 215 /* InterfaceDeclaration */: - case 143 /* MethodDeclaration */: - case 142 /* MethodSignature */: - case 218 /* ModuleDeclaration */: - case 224 /* NamespaceImport */: - case 138 /* Parameter */: - case 245 /* PropertyAssignment */: - case 141 /* PropertyDeclaration */: - case 140 /* PropertySignature */: - case 146 /* SetAccessor */: - case 246 /* ShorthandPropertyAssignment */: - case 216 /* TypeAliasDeclaration */: - case 137 /* TypeParameter */: - case 211 /* VariableDeclaration */: - return true; - } - return false; - } - ts.isDeclaration = isDeclaration; - function isStatement(n) { - switch (n.kind) { - case 203 /* BreakStatement */: - case 202 /* ContinueStatement */: - case 210 /* DebuggerStatement */: - case 197 /* DoStatement */: - case 195 /* ExpressionStatement */: - case 194 /* EmptyStatement */: - case 200 /* ForInStatement */: - case 201 /* ForOfStatement */: - case 199 /* ForStatement */: - case 196 /* IfStatement */: - case 207 /* LabeledStatement */: - case 204 /* ReturnStatement */: - case 206 /* SwitchStatement */: - case 98 /* ThrowKeyword */: - case 209 /* TryStatement */: - case 193 /* VariableStatement */: - case 198 /* WhileStatement */: - case 205 /* WithStatement */: - case 227 /* ExportAssignment */: - return true; - default: - return false; - } - } - ts.isStatement = isStatement; - function isClassElement(n) { - switch (n.kind) { - case 144 /* Constructor */: - case 141 /* PropertyDeclaration */: - case 143 /* MethodDeclaration */: - case 145 /* GetAccessor */: - case 146 /* SetAccessor */: - case 142 /* MethodSignature */: - case 149 /* IndexSignature */: - return true; - default: - return false; - } - } - ts.isClassElement = isClassElement; - // True if the given identifier, string literal, or number literal is the name of a declaration node - function isDeclarationName(name) { - if (name.kind !== 69 /* Identifier */ && name.kind !== 9 /* StringLiteral */ && name.kind !== 8 /* NumericLiteral */) { - return false; - } - var parent = name.parent; - if (parent.kind === 226 /* ImportSpecifier */ || parent.kind === 230 /* ExportSpecifier */) { - if (parent.propertyName) { - return true; - } - } - if (isDeclaration(parent)) { - return parent.name === name; - } - return false; - } - ts.isDeclarationName = isDeclarationName; - // Return true if the given identifier is classified as an IdentifierName - function isIdentifierName(node) { - var parent = node.parent; - switch (parent.kind) { - case 141 /* PropertyDeclaration */: - case 140 /* PropertySignature */: - case 143 /* MethodDeclaration */: - case 142 /* MethodSignature */: - case 145 /* GetAccessor */: - case 146 /* SetAccessor */: - case 247 /* EnumMember */: - case 245 /* PropertyAssignment */: - case 166 /* PropertyAccessExpression */: - // Name in member declaration or property name in property access - return parent.name === node; - case 135 /* QualifiedName */: - // Name on right hand side of dot in a type query - if (parent.right === node) { - while (parent.kind === 135 /* QualifiedName */) { - parent = parent.parent; - } - return parent.kind === 154 /* TypeQuery */; - } - return false; - case 163 /* BindingElement */: - case 226 /* ImportSpecifier */: - // Property name in binding element or import specifier - return parent.propertyName === node; - case 230 /* ExportSpecifier */: - // Any name in an export specifier - return true; - } - return false; - } - ts.isIdentifierName = isIdentifierName; - // An alias symbol is created by one of the following declarations: - // import = ... - // import from ... - // import * as from ... - // import { x as } from ... - // export { x as } from ... - // export = ... - // export default ... - function isAliasSymbolDeclaration(node) { - return node.kind === 221 /* ImportEqualsDeclaration */ || - node.kind === 223 /* ImportClause */ && !!node.name || - node.kind === 224 /* NamespaceImport */ || - node.kind === 226 /* ImportSpecifier */ || - node.kind === 230 /* ExportSpecifier */ || - node.kind === 227 /* ExportAssignment */ && node.expression.kind === 69 /* Identifier */; - } - ts.isAliasSymbolDeclaration = isAliasSymbolDeclaration; - function getClassExtendsHeritageClauseElement(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 83 /* ExtendsKeyword */); - return heritageClause && heritageClause.types.length > 0 ? heritageClause.types[0] : undefined; - } - ts.getClassExtendsHeritageClauseElement = getClassExtendsHeritageClauseElement; - function getClassImplementsHeritageClauseElements(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 106 /* ImplementsKeyword */); - return heritageClause ? heritageClause.types : undefined; - } - ts.getClassImplementsHeritageClauseElements = getClassImplementsHeritageClauseElements; - function getInterfaceBaseTypeNodes(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 83 /* ExtendsKeyword */); - return heritageClause ? heritageClause.types : undefined; - } - ts.getInterfaceBaseTypeNodes = getInterfaceBaseTypeNodes; - function getHeritageClause(clauses, kind) { - if (clauses) { - for (var _i = 0; _i < clauses.length; _i++) { - var clause = clauses[_i]; - if (clause.token === kind) { - return clause; - } - } - } - return undefined; - } - ts.getHeritageClause = getHeritageClause; - function tryResolveScriptReference(host, sourceFile, reference) { - if (!host.getCompilerOptions().noResolve) { - var referenceFileName = ts.isRootedDiskPath(reference.fileName) ? reference.fileName : ts.combinePaths(ts.getDirectoryPath(sourceFile.fileName), reference.fileName); - referenceFileName = ts.getNormalizedAbsolutePath(referenceFileName, host.getCurrentDirectory()); - return host.getSourceFile(referenceFileName); - } - } - ts.tryResolveScriptReference = tryResolveScriptReference; - function getAncestor(node, kind) { - while (node) { - if (node.kind === kind) { - return node; - } - node = node.parent; - } - return undefined; - } - ts.getAncestor = getAncestor; - function getFileReferenceFromReferencePath(comment, commentRange) { - var simpleReferenceRegEx = /^\/\/\/\s*/gim; - if (simpleReferenceRegEx.exec(comment)) { - if (isNoDefaultLibRegEx.exec(comment)) { - return { - isNoDefaultLib: true - }; - } - else { - var matchResult = ts.fullTripleSlashReferencePathRegEx.exec(comment); - if (matchResult) { - var start = commentRange.pos; - var end = commentRange.end; - return { - fileReference: { - pos: start, - end: end, - fileName: matchResult[3] - }, - isNoDefaultLib: false - }; - } - else { - return { - diagnosticMessage: ts.Diagnostics.Invalid_reference_directive_syntax, - isNoDefaultLib: false - }; - } - } - } - return undefined; - } - ts.getFileReferenceFromReferencePath = getFileReferenceFromReferencePath; - function isKeyword(token) { - return 70 /* FirstKeyword */ <= token && token <= 134 /* LastKeyword */; - } - ts.isKeyword = isKeyword; - function isTrivia(token) { - return 2 /* FirstTriviaToken */ <= token && token <= 7 /* LastTriviaToken */; - } - ts.isTrivia = isTrivia; - function isAsyncFunctionLike(node) { - return isFunctionLike(node) && (node.flags & 512 /* Async */) !== 0 && !isAccessor(node); - } - ts.isAsyncFunctionLike = isAsyncFunctionLike; - /** - * A declaration has a dynamic name if both of the following are true: - * 1. The declaration has a computed property name - * 2. The computed name is *not* expressed as Symbol., where name - * is a property of the Symbol constructor that denotes a built in - * Symbol. - */ - function hasDynamicName(declaration) { - return declaration.name && - declaration.name.kind === 136 /* ComputedPropertyName */ && - !isWellKnownSymbolSyntactically(declaration.name.expression); - } - ts.hasDynamicName = hasDynamicName; - /** - * Checks if the expression is of the form: - * Symbol.name - * where Symbol is literally the word "Symbol", and name is any identifierName - */ - function isWellKnownSymbolSyntactically(node) { - return isPropertyAccessExpression(node) && isESSymbolIdentifier(node.expression); - } - ts.isWellKnownSymbolSyntactically = isWellKnownSymbolSyntactically; - function getPropertyNameForPropertyNameNode(name) { - if (name.kind === 69 /* Identifier */ || name.kind === 9 /* StringLiteral */ || name.kind === 8 /* NumericLiteral */) { - return name.text; - } - if (name.kind === 136 /* ComputedPropertyName */) { - var nameExpression = name.expression; - if (isWellKnownSymbolSyntactically(nameExpression)) { - var rightHandSideName = nameExpression.name.text; - return getPropertyNameForKnownSymbolName(rightHandSideName); - } - } - return undefined; - } - ts.getPropertyNameForPropertyNameNode = getPropertyNameForPropertyNameNode; - function getPropertyNameForKnownSymbolName(symbolName) { - return "__@" + symbolName; - } - ts.getPropertyNameForKnownSymbolName = getPropertyNameForKnownSymbolName; - /** - * Includes the word "Symbol" with unicode escapes - */ - function isESSymbolIdentifier(node) { - return node.kind === 69 /* Identifier */ && node.text === "Symbol"; - } - ts.isESSymbolIdentifier = isESSymbolIdentifier; - function isModifier(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 113 /* StaticKeyword */: - return true; - } - return false; - } - ts.isModifier = isModifier; - function isParameterDeclaration(node) { - var root = getRootDeclaration(node); - return root.kind === 138 /* Parameter */; - } - ts.isParameterDeclaration = isParameterDeclaration; - function getRootDeclaration(node) { - while (node.kind === 163 /* BindingElement */) { - node = node.parent.parent; - } - return node; - } - ts.getRootDeclaration = getRootDeclaration; - function nodeStartsNewLexicalEnvironment(n) { - return isFunctionLike(n) || n.kind === 218 /* ModuleDeclaration */ || n.kind === 248 /* SourceFile */; - } - ts.nodeStartsNewLexicalEnvironment = nodeStartsNewLexicalEnvironment; - function cloneEntityName(node) { - if (node.kind === 69 /* Identifier */) { - var clone_1 = createSynthesizedNode(69 /* Identifier */); - clone_1.text = node.text; - return clone_1; - } - else { - var clone_2 = createSynthesizedNode(135 /* QualifiedName */); - clone_2.left = cloneEntityName(node.left); - clone_2.left.parent = clone_2; - clone_2.right = cloneEntityName(node.right); - clone_2.right.parent = clone_2; - return clone_2; - } - } - ts.cloneEntityName = cloneEntityName; - function nodeIsSynthesized(node) { - return node.pos === -1; - } - ts.nodeIsSynthesized = nodeIsSynthesized; - function createSynthesizedNode(kind, startsOnNewLine) { - var node = ts.createNode(kind, /* pos */ -1, /* end */ -1); - node.startsOnNewLine = startsOnNewLine; - return node; - } - ts.createSynthesizedNode = createSynthesizedNode; - function createSynthesizedNodeArray() { - var array = []; - array.pos = -1; - array.end = -1; - return array; - } - ts.createSynthesizedNodeArray = createSynthesizedNodeArray; - function createDiagnosticCollection() { - var nonFileDiagnostics = []; - var fileDiagnostics = {}; - var diagnosticsModified = false; - var modificationCount = 0; - return { - add: add, - getGlobalDiagnostics: getGlobalDiagnostics, - getDiagnostics: getDiagnostics, - getModificationCount: getModificationCount, - reattachFileDiagnostics: reattachFileDiagnostics - }; - function getModificationCount() { - return modificationCount; - } - function reattachFileDiagnostics(newFile) { - if (!ts.hasProperty(fileDiagnostics, newFile.fileName)) { - return; - } - for (var _i = 0, _a = fileDiagnostics[newFile.fileName]; _i < _a.length; _i++) { - var diagnostic = _a[_i]; - diagnostic.file = newFile; - } - } - function add(diagnostic) { - var diagnostics; - if (diagnostic.file) { - diagnostics = fileDiagnostics[diagnostic.file.fileName]; - if (!diagnostics) { - diagnostics = []; - fileDiagnostics[diagnostic.file.fileName] = diagnostics; - } - } - else { - diagnostics = nonFileDiagnostics; - } - diagnostics.push(diagnostic); - diagnosticsModified = true; - modificationCount++; - } - function getGlobalDiagnostics() { - sortAndDeduplicate(); - return nonFileDiagnostics; - } - function getDiagnostics(fileName) { - sortAndDeduplicate(); - if (fileName) { - return fileDiagnostics[fileName] || []; - } - var allDiagnostics = []; - function pushDiagnostic(d) { - allDiagnostics.push(d); - } - ts.forEach(nonFileDiagnostics, pushDiagnostic); - for (var key in fileDiagnostics) { - if (ts.hasProperty(fileDiagnostics, key)) { - ts.forEach(fileDiagnostics[key], pushDiagnostic); - } - } - return ts.sortAndDeduplicateDiagnostics(allDiagnostics); - } - function sortAndDeduplicate() { - if (!diagnosticsModified) { - return; - } - diagnosticsModified = false; - nonFileDiagnostics = ts.sortAndDeduplicateDiagnostics(nonFileDiagnostics); - for (var key in fileDiagnostics) { - if (ts.hasProperty(fileDiagnostics, key)) { - fileDiagnostics[key] = ts.sortAndDeduplicateDiagnostics(fileDiagnostics[key]); - } - } - } - } - ts.createDiagnosticCollection = createDiagnosticCollection; - // This consists of the first 19 unprintable ASCII characters, canonical escapes, lineSeparator, - // paragraphSeparator, and nextLine. The latter three are just desirable to suppress new lines in - // the language service. These characters should be escaped when printing, and if any characters are added, - // the map below must be updated. Note that this regexp *does not* include the 'delete' character. - // There is no reason for this other than that JSON.stringify does not handle it either. - var escapedCharsRegExp = /[\\\"\u0000-\u001f\t\v\f\b\r\n\u2028\u2029\u0085]/g; - var escapedCharsMap = { - "\0": "\\0", - "\t": "\\t", - "\v": "\\v", - "\f": "\\f", - "\b": "\\b", - "\r": "\\r", - "\n": "\\n", - "\\": "\\\\", - "\"": "\\\"", - "\u2028": "\\u2028", - "\u2029": "\\u2029", - "\u0085": "\\u0085" // nextLine - }; - /** - * Based heavily on the abstract 'Quote'/'QuoteJSONString' operation from ECMA-262 (24.3.2.2), - * but augmented for a few select characters (e.g. lineSeparator, paragraphSeparator, nextLine) - * Note that this doesn't actually wrap the input in double quotes. - */ - function escapeString(s) { - s = escapedCharsRegExp.test(s) ? s.replace(escapedCharsRegExp, getReplacement) : s; - return s; - function getReplacement(c) { - return escapedCharsMap[c] || get16BitUnicodeEscapeSequence(c.charCodeAt(0)); - } - } - ts.escapeString = escapeString; - function isIntrinsicJsxName(name) { - var ch = name.substr(0, 1); - return ch.toLowerCase() === ch; - } - ts.isIntrinsicJsxName = isIntrinsicJsxName; - function get16BitUnicodeEscapeSequence(charCode) { - var hexCharCode = charCode.toString(16).toUpperCase(); - var paddedHexCode = ("0000" + hexCharCode).slice(-4); - return "\\u" + paddedHexCode; - } - var nonAsciiCharacters = /[^\u0000-\u007F]/g; - function escapeNonAsciiCharacters(s) { - // Replace non-ASCII characters with '\uNNNN' escapes if any exist. - // Otherwise just return the original string. - return nonAsciiCharacters.test(s) ? - s.replace(nonAsciiCharacters, function (c) { return get16BitUnicodeEscapeSequence(c.charCodeAt(0)); }) : - s; - } - ts.escapeNonAsciiCharacters = escapeNonAsciiCharacters; - var indentStrings = ["", " "]; - function getIndentString(level) { - if (indentStrings[level] === undefined) { - indentStrings[level] = getIndentString(level - 1) + indentStrings[1]; - } - return indentStrings[level]; - } - ts.getIndentString = getIndentString; - function getIndentSize() { - return indentStrings[1].length; - } - ts.getIndentSize = getIndentSize; - function createTextWriter(newLine) { - var output = ""; - var indent = 0; - var lineStart = true; - var lineCount = 0; - var linePos = 0; - function write(s) { - if (s && s.length) { - if (lineStart) { - output += getIndentString(indent); - lineStart = false; - } - output += s; - } - } - function rawWrite(s) { - if (s !== undefined) { - if (lineStart) { - lineStart = false; - } - output += s; - } - } - function writeLiteral(s) { - if (s && s.length) { - write(s); - var lineStartsOfS = ts.computeLineStarts(s); - if (lineStartsOfS.length > 1) { - lineCount = lineCount + lineStartsOfS.length - 1; - linePos = output.length - s.length + ts.lastOrUndefined(lineStartsOfS); - } - } - } - function writeLine() { - if (!lineStart) { - output += newLine; - lineCount++; - linePos = output.length; - lineStart = true; - } - } - function writeTextOfNode(sourceFile, node) { - write(getSourceTextOfNodeFromSourceFile(sourceFile, node)); - } - return { - write: write, - rawWrite: rawWrite, - writeTextOfNode: writeTextOfNode, - writeLiteral: writeLiteral, - writeLine: writeLine, - increaseIndent: function () { return indent++; }, - decreaseIndent: function () { return indent--; }, - getIndent: function () { return indent; }, - getTextPos: function () { return output.length; }, - getLine: function () { return lineCount + 1; }, - getColumn: function () { return lineStart ? indent * getIndentSize() + 1 : output.length - linePos + 1; }, - getText: function () { return output; } - }; - } - ts.createTextWriter = createTextWriter; - function getOwnEmitOutputFilePath(sourceFile, host, extension) { - var compilerOptions = host.getCompilerOptions(); - var emitOutputFilePathWithoutExtension; - if (compilerOptions.outDir) { - emitOutputFilePathWithoutExtension = ts.removeFileExtension(getSourceFilePathInNewDir(sourceFile, host, compilerOptions.outDir)); - } - else { - emitOutputFilePathWithoutExtension = ts.removeFileExtension(sourceFile.fileName); - } - return emitOutputFilePathWithoutExtension + extension; - } - ts.getOwnEmitOutputFilePath = getOwnEmitOutputFilePath; - function getSourceFilePathInNewDir(sourceFile, host, newDirPath) { - var sourceFilePath = ts.getNormalizedAbsolutePath(sourceFile.fileName, host.getCurrentDirectory()); - sourceFilePath = sourceFilePath.replace(host.getCommonSourceDirectory(), ""); - return ts.combinePaths(newDirPath, sourceFilePath); - } - ts.getSourceFilePathInNewDir = getSourceFilePathInNewDir; - function writeFile(host, diagnostics, fileName, data, writeByteOrderMark) { - host.writeFile(fileName, data, writeByteOrderMark, function (hostErrorMessage) { - diagnostics.push(ts.createCompilerDiagnostic(ts.Diagnostics.Could_not_write_file_0_Colon_1, fileName, hostErrorMessage)); - }); - } - ts.writeFile = writeFile; - function getLineOfLocalPosition(currentSourceFile, pos) { - return ts.getLineAndCharacterOfPosition(currentSourceFile, pos).line; - } - ts.getLineOfLocalPosition = getLineOfLocalPosition; - function getFirstConstructorWithBody(node) { - return ts.forEach(node.members, function (member) { - if (member.kind === 144 /* Constructor */ && nodeIsPresent(member.body)) { - return member; - } - }); - } - ts.getFirstConstructorWithBody = getFirstConstructorWithBody; - function getSetAccessorTypeAnnotationNode(accessor) { - return accessor && accessor.parameters.length > 0 && accessor.parameters[0].type; - } - ts.getSetAccessorTypeAnnotationNode = getSetAccessorTypeAnnotationNode; - function shouldEmitToOwnFile(sourceFile, compilerOptions) { - if (!isDeclarationFile(sourceFile)) { - if ((isExternalModule(sourceFile) || !(compilerOptions.outFile || compilerOptions.out))) { - // 1. in-browser single file compilation scenario - // 2. non .js file - return compilerOptions.isolatedModules || !ts.fileExtensionIs(sourceFile.fileName, ".js"); - } - return false; - } - return false; - } - ts.shouldEmitToOwnFile = shouldEmitToOwnFile; - function getAllAccessorDeclarations(declarations, accessor) { - var firstAccessor; - var secondAccessor; - var getAccessor; - var setAccessor; - if (hasDynamicName(accessor)) { - firstAccessor = accessor; - if (accessor.kind === 145 /* GetAccessor */) { - getAccessor = accessor; - } - else if (accessor.kind === 146 /* SetAccessor */) { - setAccessor = accessor; - } - else { - ts.Debug.fail("Accessor has wrong kind"); - } - } - else { - ts.forEach(declarations, function (member) { - if ((member.kind === 145 /* GetAccessor */ || member.kind === 146 /* SetAccessor */) - && (member.flags & 128 /* Static */) === (accessor.flags & 128 /* Static */)) { - var memberName = getPropertyNameForPropertyNameNode(member.name); - var accessorName = getPropertyNameForPropertyNameNode(accessor.name); - if (memberName === accessorName) { - if (!firstAccessor) { - firstAccessor = member; - } - else if (!secondAccessor) { - secondAccessor = member; - } - if (member.kind === 145 /* GetAccessor */ && !getAccessor) { - getAccessor = member; - } - if (member.kind === 146 /* SetAccessor */ && !setAccessor) { - setAccessor = member; - } - } - } - }); - } - return { - firstAccessor: firstAccessor, - secondAccessor: secondAccessor, - getAccessor: getAccessor, - setAccessor: setAccessor - }; - } - ts.getAllAccessorDeclarations = getAllAccessorDeclarations; - function emitNewLineBeforeLeadingComments(currentSourceFile, writer, node, leadingComments) { - // If the leading comments start on different line than the start of node, write new line - if (leadingComments && leadingComments.length && node.pos !== leadingComments[0].pos && - getLineOfLocalPosition(currentSourceFile, node.pos) !== getLineOfLocalPosition(currentSourceFile, leadingComments[0].pos)) { - writer.writeLine(); - } - } - ts.emitNewLineBeforeLeadingComments = emitNewLineBeforeLeadingComments; - function emitComments(currentSourceFile, writer, comments, trailingSeparator, newLine, writeComment) { - var emitLeadingSpace = !trailingSeparator; - ts.forEach(comments, function (comment) { - if (emitLeadingSpace) { - writer.write(" "); - emitLeadingSpace = false; - } - writeComment(currentSourceFile, writer, comment, newLine); - if (comment.hasTrailingNewLine) { - writer.writeLine(); - } - else if (trailingSeparator) { - writer.write(" "); - } - else { - // Emit leading space to separate comment during next comment emit - emitLeadingSpace = true; - } - }); - } - ts.emitComments = emitComments; - function writeCommentRange(currentSourceFile, writer, comment, newLine) { - if (currentSourceFile.text.charCodeAt(comment.pos + 1) === 42 /* asterisk */) { - var firstCommentLineAndCharacter = ts.getLineAndCharacterOfPosition(currentSourceFile, comment.pos); - var lineCount = ts.getLineStarts(currentSourceFile).length; - var firstCommentLineIndent; - for (var pos = comment.pos, currentLine = firstCommentLineAndCharacter.line; pos < comment.end; currentLine++) { - var nextLineStart = (currentLine + 1) === lineCount - ? currentSourceFile.text.length + 1 - : getStartPositionOfLine(currentLine + 1, currentSourceFile); - if (pos !== comment.pos) { - // If we are not emitting first line, we need to write the spaces to adjust the alignment - if (firstCommentLineIndent === undefined) { - firstCommentLineIndent = calculateIndent(getStartPositionOfLine(firstCommentLineAndCharacter.line, currentSourceFile), comment.pos); - } - // These are number of spaces writer is going to write at current indent - var currentWriterIndentSpacing = writer.getIndent() * getIndentSize(); - // Number of spaces we want to be writing - // eg: Assume writer indent - // module m { - // /* starts at character 9 this is line 1 - // * starts at character pos 4 line --1 = 8 - 8 + 3 - // More left indented comment */ --2 = 8 - 8 + 2 - // class c { } - // } - // module m { - // /* this is line 1 -- Assume current writer indent 8 - // * line --3 = 8 - 4 + 5 - // More right indented comment */ --4 = 8 - 4 + 11 - // class c { } - // } - var spacesToEmit = currentWriterIndentSpacing - firstCommentLineIndent + calculateIndent(pos, nextLineStart); - if (spacesToEmit > 0) { - var numberOfSingleSpacesToEmit = spacesToEmit % getIndentSize(); - var indentSizeSpaceString = getIndentString((spacesToEmit - numberOfSingleSpacesToEmit) / getIndentSize()); - // Write indent size string ( in eg 1: = "", 2: "" , 3: string with 8 spaces 4: string with 12 spaces - writer.rawWrite(indentSizeSpaceString); - // Emit the single spaces (in eg: 1: 3 spaces, 2: 2 spaces, 3: 1 space, 4: 3 spaces) - while (numberOfSingleSpacesToEmit) { - writer.rawWrite(" "); - numberOfSingleSpacesToEmit--; - } - } - else { - // No spaces to emit write empty string - writer.rawWrite(""); - } - } - // Write the comment line text - writeTrimmedCurrentLine(pos, nextLineStart); - pos = nextLineStart; - } - } - else { - // Single line comment of style //.... - writer.write(currentSourceFile.text.substring(comment.pos, comment.end)); - } - function writeTrimmedCurrentLine(pos, nextLineStart) { - var end = Math.min(comment.end, nextLineStart - 1); - var currentLineText = currentSourceFile.text.substring(pos, end).replace(/^\s+|\s+$/g, ""); - if (currentLineText) { - // trimmed forward and ending spaces text - writer.write(currentLineText); - if (end !== comment.end) { - writer.writeLine(); - } - } - else { - // Empty string - make sure we write empty line - writer.writeLiteral(newLine); - } - } - function calculateIndent(pos, end) { - var currentLineIndent = 0; - for (; pos < end && ts.isWhiteSpace(currentSourceFile.text.charCodeAt(pos)); pos++) { - if (currentSourceFile.text.charCodeAt(pos) === 9 /* tab */) { - // Tabs = TabSize = indent size and go to next tabStop - currentLineIndent += getIndentSize() - (currentLineIndent % getIndentSize()); - } - else { - // Single space - currentLineIndent++; - } - } - return currentLineIndent; - } - } - ts.writeCommentRange = writeCommentRange; - function modifierToFlag(token) { - switch (token) { - case 113 /* StaticKeyword */: return 128 /* Static */; - case 112 /* PublicKeyword */: return 16 /* Public */; - case 111 /* ProtectedKeyword */: return 64 /* Protected */; - case 110 /* PrivateKeyword */: return 32 /* Private */; - case 115 /* AbstractKeyword */: return 256 /* Abstract */; - case 82 /* ExportKeyword */: return 1 /* Export */; - case 122 /* DeclareKeyword */: return 2 /* Ambient */; - case 74 /* ConstKeyword */: return 32768 /* Const */; - case 77 /* DefaultKeyword */: return 1024 /* Default */; - case 118 /* AsyncKeyword */: return 512 /* Async */; - } - return 0; - } - ts.modifierToFlag = modifierToFlag; - function isLeftHandSideExpression(expr) { - if (expr) { - switch (expr.kind) { - case 166 /* PropertyAccessExpression */: - case 167 /* ElementAccessExpression */: - case 169 /* NewExpression */: - case 168 /* CallExpression */: - case 233 /* JsxElement */: - case 234 /* JsxSelfClosingElement */: - case 170 /* TaggedTemplateExpression */: - case 164 /* ArrayLiteralExpression */: - case 172 /* ParenthesizedExpression */: - case 165 /* ObjectLiteralExpression */: - case 186 /* ClassExpression */: - case 173 /* FunctionExpression */: - case 69 /* Identifier */: - case 10 /* RegularExpressionLiteral */: - case 8 /* NumericLiteral */: - case 9 /* StringLiteral */: - case 11 /* NoSubstitutionTemplateLiteral */: - case 183 /* TemplateExpression */: - case 84 /* FalseKeyword */: - case 93 /* NullKeyword */: - case 97 /* ThisKeyword */: - case 99 /* TrueKeyword */: - case 95 /* SuperKeyword */: - return true; - } - } - return false; - } - ts.isLeftHandSideExpression = isLeftHandSideExpression; - function isAssignmentOperator(token) { - return token >= 56 /* FirstAssignment */ && token <= 68 /* LastAssignment */; - } - ts.isAssignmentOperator = isAssignmentOperator; - function isExpressionWithTypeArgumentsInClassExtendsClause(node) { - return node.kind === 188 /* ExpressionWithTypeArguments */ && - node.parent.token === 83 /* ExtendsKeyword */ && - isClassLike(node.parent.parent); - } - ts.isExpressionWithTypeArgumentsInClassExtendsClause = isExpressionWithTypeArgumentsInClassExtendsClause; - // Returns false if this heritage clause element's expression contains something unsupported - // (i.e. not a name or dotted name). - function isSupportedExpressionWithTypeArguments(node) { - return isSupportedExpressionWithTypeArgumentsRest(node.expression); - } - ts.isSupportedExpressionWithTypeArguments = isSupportedExpressionWithTypeArguments; - function isSupportedExpressionWithTypeArgumentsRest(node) { - if (node.kind === 69 /* Identifier */) { - return true; - } - else if (isPropertyAccessExpression(node)) { - return isSupportedExpressionWithTypeArgumentsRest(node.expression); - } - else { - return false; - } - } - function isRightSideOfQualifiedNameOrPropertyAccess(node) { - return (node.parent.kind === 135 /* QualifiedName */ && node.parent.right === node) || - (node.parent.kind === 166 /* PropertyAccessExpression */ && node.parent.name === node); - } - ts.isRightSideOfQualifiedNameOrPropertyAccess = isRightSideOfQualifiedNameOrPropertyAccess; - function isEmptyObjectLiteralOrArrayLiteral(expression) { - var kind = expression.kind; - if (kind === 165 /* ObjectLiteralExpression */) { - return expression.properties.length === 0; - } - if (kind === 164 /* ArrayLiteralExpression */) { - return expression.elements.length === 0; - } - return false; - } - ts.isEmptyObjectLiteralOrArrayLiteral = isEmptyObjectLiteralOrArrayLiteral; - function getLocalSymbolForExportDefault(symbol) { - return symbol && symbol.valueDeclaration && (symbol.valueDeclaration.flags & 1024 /* Default */) ? symbol.valueDeclaration.localSymbol : undefined; - } - ts.getLocalSymbolForExportDefault = getLocalSymbolForExportDefault; - function isJavaScript(fileName) { - return ts.fileExtensionIs(fileName, ".js"); - } - ts.isJavaScript = isJavaScript; - function isTsx(fileName) { - return ts.fileExtensionIs(fileName, ".tsx"); - } - ts.isTsx = isTsx; - /** - * Replace each instance of non-ascii characters by one, two, three, or four escape sequences - * representing the UTF-8 encoding of the character, and return the expanded char code list. - */ - function getExpandedCharCodes(input) { - var output = []; - var length = input.length; - for (var i = 0; i < length; i++) { - var charCode = input.charCodeAt(i); - // handel utf8 - if (charCode < 0x80) { - output.push(charCode); - } - else if (charCode < 0x800) { - output.push((charCode >> 6) | 192); - output.push((charCode & 63) | 128); - } - else if (charCode < 0x10000) { - output.push((charCode >> 12) | 224); - output.push(((charCode >> 6) & 63) | 128); - output.push((charCode & 63) | 128); - } - else if (charCode < 0x20000) { - output.push((charCode >> 18) | 240); - output.push(((charCode >> 12) & 63) | 128); - output.push(((charCode >> 6) & 63) | 128); - output.push((charCode & 63) | 128); - } - else { - ts.Debug.assert(false, "Unexpected code point"); - } - } - return output; - } - var base64Digits = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="; - /** - * Converts a string to a base-64 encoded ASCII string. - */ - function convertToBase64(input) { - var result = ""; - var charCodes = getExpandedCharCodes(input); - var i = 0; - var length = charCodes.length; - var byte1, byte2, byte3, byte4; - while (i < length) { - // Convert every 6-bits in the input 3 character points - // into a base64 digit - byte1 = charCodes[i] >> 2; - byte2 = (charCodes[i] & 3) << 4 | charCodes[i + 1] >> 4; - byte3 = (charCodes[i + 1] & 15) << 2 | charCodes[i + 2] >> 6; - byte4 = charCodes[i + 2] & 63; - // We are out of characters in the input, set the extra - // digits to 64 (padding character). - if (i + 1 >= length) { - byte3 = byte4 = 64; - } - else if (i + 2 >= length) { - byte4 = 64; - } - // Write to the ouput - result += base64Digits.charAt(byte1) + base64Digits.charAt(byte2) + base64Digits.charAt(byte3) + base64Digits.charAt(byte4); - i += 3; - } - return result; - } - ts.convertToBase64 = convertToBase64; - var carriageReturnLineFeed = "\r\n"; - var lineFeed = "\n"; - function getNewLineCharacter(options) { - if (options.newLine === 0 /* CarriageReturnLineFeed */) { - return carriageReturnLineFeed; - } - else if (options.newLine === 1 /* LineFeed */) { - return lineFeed; - } - else if (ts.sys) { - return ts.sys.newLine; - } - return carriageReturnLineFeed; - } - ts.getNewLineCharacter = getNewLineCharacter; -})(ts || (ts = {})); -var ts; -(function (ts) { - function getDefaultLibFileName(options) { - return options.target === 2 /* ES6 */ ? "lib.es6.d.ts" : "lib.d.ts"; - } - ts.getDefaultLibFileName = getDefaultLibFileName; - function textSpanEnd(span) { - return span.start + span.length; - } - ts.textSpanEnd = textSpanEnd; - function textSpanIsEmpty(span) { - return span.length === 0; - } - ts.textSpanIsEmpty = textSpanIsEmpty; - function textSpanContainsPosition(span, position) { - return position >= span.start && position < textSpanEnd(span); - } - ts.textSpanContainsPosition = textSpanContainsPosition; - // Returns true if 'span' contains 'other'. - function textSpanContainsTextSpan(span, other) { - return other.start >= span.start && textSpanEnd(other) <= textSpanEnd(span); - } - ts.textSpanContainsTextSpan = textSpanContainsTextSpan; - function textSpanOverlapsWith(span, other) { - var overlapStart = Math.max(span.start, other.start); - var overlapEnd = Math.min(textSpanEnd(span), textSpanEnd(other)); - return overlapStart < overlapEnd; - } - ts.textSpanOverlapsWith = textSpanOverlapsWith; - function textSpanOverlap(span1, span2) { - var overlapStart = Math.max(span1.start, span2.start); - var overlapEnd = Math.min(textSpanEnd(span1), textSpanEnd(span2)); - if (overlapStart < overlapEnd) { - return createTextSpanFromBounds(overlapStart, overlapEnd); - } - return undefined; - } - ts.textSpanOverlap = textSpanOverlap; - function textSpanIntersectsWithTextSpan(span, other) { - return other.start <= textSpanEnd(span) && textSpanEnd(other) >= span.start; - } - ts.textSpanIntersectsWithTextSpan = textSpanIntersectsWithTextSpan; - function textSpanIntersectsWith(span, start, length) { - var end = start + length; - return start <= textSpanEnd(span) && end >= span.start; - } - ts.textSpanIntersectsWith = textSpanIntersectsWith; - function decodedTextSpanIntersectsWith(start1, length1, start2, length2) { - var end1 = start1 + length1; - var end2 = start2 + length2; - return start2 <= end1 && end2 >= start1; - } - ts.decodedTextSpanIntersectsWith = decodedTextSpanIntersectsWith; - function textSpanIntersectsWithPosition(span, position) { - return position <= textSpanEnd(span) && position >= span.start; - } - ts.textSpanIntersectsWithPosition = textSpanIntersectsWithPosition; - function textSpanIntersection(span1, span2) { - var intersectStart = Math.max(span1.start, span2.start); - var intersectEnd = Math.min(textSpanEnd(span1), textSpanEnd(span2)); - if (intersectStart <= intersectEnd) { - return createTextSpanFromBounds(intersectStart, intersectEnd); - } - return undefined; - } - ts.textSpanIntersection = textSpanIntersection; - function createTextSpan(start, length) { - if (start < 0) { - throw new Error("start < 0"); - } - if (length < 0) { - throw new Error("length < 0"); - } - return { start: start, length: length }; - } - ts.createTextSpan = createTextSpan; - function createTextSpanFromBounds(start, end) { - return createTextSpan(start, end - start); - } - ts.createTextSpanFromBounds = createTextSpanFromBounds; - function textChangeRangeNewSpan(range) { - return createTextSpan(range.span.start, range.newLength); - } - ts.textChangeRangeNewSpan = textChangeRangeNewSpan; - function textChangeRangeIsUnchanged(range) { - return textSpanIsEmpty(range.span) && range.newLength === 0; - } - ts.textChangeRangeIsUnchanged = textChangeRangeIsUnchanged; - function createTextChangeRange(span, newLength) { - if (newLength < 0) { - throw new Error("newLength < 0"); - } - return { span: span, newLength: newLength }; - } - ts.createTextChangeRange = createTextChangeRange; - ts.unchangedTextChangeRange = createTextChangeRange(createTextSpan(0, 0), 0); - /** - * Called to merge all the changes that occurred across several versions of a script snapshot - * into a single change. i.e. if a user keeps making successive edits to a script we will - * have a text change from V1 to V2, V2 to V3, ..., Vn. - * - * This function will then merge those changes into a single change range valid between V1 and - * Vn. - */ - function collapseTextChangeRangesAcrossMultipleVersions(changes) { - if (changes.length === 0) { - return ts.unchangedTextChangeRange; - } - if (changes.length === 1) { - return changes[0]; - } - // We change from talking about { { oldStart, oldLength }, newLength } to { oldStart, oldEnd, newEnd } - // as it makes things much easier to reason about. - var change0 = changes[0]; - var oldStartN = change0.span.start; - var oldEndN = textSpanEnd(change0.span); - var newEndN = oldStartN + change0.newLength; - for (var i = 1; i < changes.length; i++) { - var nextChange = changes[i]; - // Consider the following case: - // i.e. two edits. The first represents the text change range { { 10, 50 }, 30 }. i.e. The span starting - // at 10, with length 50 is reduced to length 30. The second represents the text change range { { 30, 30 }, 40 }. - // i.e. the span starting at 30 with length 30 is increased to length 40. - // - // 0 10 20 30 40 50 60 70 80 90 100 - // ------------------------------------------------------------------------------------------------------- - // | / - // | /---- - // T1 | /---- - // | /---- - // | /---- - // ------------------------------------------------------------------------------------------------------- - // | \ - // | \ - // T2 | \ - // | \ - // | \ - // ------------------------------------------------------------------------------------------------------- - // - // Merging these turns out to not be too difficult. First, determining the new start of the change is trivial - // it's just the min of the old and new starts. i.e.: - // - // 0 10 20 30 40 50 60 70 80 90 100 - // ------------------------------------------------------------*------------------------------------------ - // | / - // | /---- - // T1 | /---- - // | /---- - // | /---- - // ----------------------------------------$-------------------$------------------------------------------ - // . | \ - // . | \ - // T2 . | \ - // . | \ - // . | \ - // ----------------------------------------------------------------------*-------------------------------- - // - // (Note the dots represent the newly inferrred start. - // Determining the new and old end is also pretty simple. Basically it boils down to paying attention to the - // absolute positions at the asterixes, and the relative change between the dollar signs. Basically, we see - // which if the two $'s precedes the other, and we move that one forward until they line up. in this case that - // means: - // - // 0 10 20 30 40 50 60 70 80 90 100 - // --------------------------------------------------------------------------------*---------------------- - // | / - // | /---- - // T1 | /---- - // | /---- - // | /---- - // ------------------------------------------------------------$------------------------------------------ - // . | \ - // . | \ - // T2 . | \ - // . | \ - // . | \ - // ----------------------------------------------------------------------*-------------------------------- - // - // In other words (in this case), we're recognizing that the second edit happened after where the first edit - // ended with a delta of 20 characters (60 - 40). Thus, if we go back in time to where the first edit started - // that's the same as if we started at char 80 instead of 60. - // - // As it so happens, the same logic applies if the second edit precedes the first edit. In that case rahter - // than pusing the first edit forward to match the second, we'll push the second edit forward to match the - // first. - // - // In this case that means we have { oldStart: 10, oldEnd: 80, newEnd: 70 } or, in TextChangeRange - // semantics: { { start: 10, length: 70 }, newLength: 60 } - // - // The math then works out as follows. - // If we have { oldStart1, oldEnd1, newEnd1 } and { oldStart2, oldEnd2, newEnd2 } then we can compute the - // final result like so: - // - // { - // oldStart3: Min(oldStart1, oldStart2), - // oldEnd3 : Max(oldEnd1, oldEnd1 + (oldEnd2 - newEnd1)), - // newEnd3 : Max(newEnd2, newEnd2 + (newEnd1 - oldEnd2)) - // } - var oldStart1 = oldStartN; - var oldEnd1 = oldEndN; - var newEnd1 = newEndN; - var oldStart2 = nextChange.span.start; - var oldEnd2 = textSpanEnd(nextChange.span); - var newEnd2 = oldStart2 + nextChange.newLength; - oldStartN = Math.min(oldStart1, oldStart2); - oldEndN = Math.max(oldEnd1, oldEnd1 + (oldEnd2 - newEnd1)); - newEndN = Math.max(newEnd2, newEnd2 + (newEnd1 - oldEnd2)); - } - return createTextChangeRange(createTextSpanFromBounds(oldStartN, oldEndN), /*newLength:*/ newEndN - oldStartN); - } - ts.collapseTextChangeRangesAcrossMultipleVersions = collapseTextChangeRangesAcrossMultipleVersions; - function getTypeParameterOwner(d) { - if (d && d.kind === 137 /* TypeParameter */) { - for (var current = d; current; current = current.parent) { - if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 215 /* InterfaceDeclaration */) { - return current; - } - } - } - } - ts.getTypeParameterOwner = getTypeParameterOwner; -})(ts || (ts = {})); -/// -/// -var ts; -(function (ts) { - var nodeConstructors = new Array(272 /* Count */); - /* @internal */ ts.parseTime = 0; - function getNodeConstructor(kind) { - return nodeConstructors[kind] || (nodeConstructors[kind] = ts.objectAllocator.getNodeConstructor(kind)); - } - ts.getNodeConstructor = getNodeConstructor; - function createNode(kind, pos, end) { - return new (getNodeConstructor(kind))(pos, end); - } - ts.createNode = createNode; - function visitNode(cbNode, node) { - if (node) { - return cbNode(node); - } - } - function visitNodeArray(cbNodes, nodes) { - if (nodes) { - return cbNodes(nodes); - } - } - function visitEachNode(cbNode, nodes) { - if (nodes) { - for (var _i = 0; _i < nodes.length; _i++) { - var node = nodes[_i]; - var result = cbNode(node); - if (result) { - return result; - } - } - } - } - // Invokes a callback for each child of the given node. The 'cbNode' callback is invoked for all child nodes - // stored in properties. If a 'cbNodes' callback is specified, it is invoked for embedded arrays; otherwise, - // embedded arrays are flattened and the 'cbNode' callback is invoked for each element. If a callback returns - // a truthy value, iteration stops and that value is returned. Otherwise, undefined is returned. - function forEachChild(node, cbNode, cbNodeArray) { - if (!node) { - return; - } - // The visitXXX functions could be written as local functions that close over the cbNode and cbNodeArray - // callback parameters, but that causes a closure allocation for each invocation with noticeable effects - // on performance. - var visitNodes = cbNodeArray ? visitNodeArray : visitEachNode; - var cbNodes = cbNodeArray || cbNode; - switch (node.kind) { - case 135 /* QualifiedName */: - return visitNode(cbNode, node.left) || - visitNode(cbNode, node.right); - case 137 /* TypeParameter */: - return visitNode(cbNode, node.name) || - visitNode(cbNode, node.constraint) || - visitNode(cbNode, node.expression); - case 246 /* ShorthandPropertyAssignment */: - return visitNodes(cbNodes, node.decorators) || - visitNodes(cbNodes, node.modifiers) || - visitNode(cbNode, node.name) || - visitNode(cbNode, node.questionToken) || - visitNode(cbNode, node.equalsToken) || - visitNode(cbNode, node.objectAssignmentInitializer); - case 138 /* Parameter */: - case 141 /* PropertyDeclaration */: - case 140 /* PropertySignature */: - case 245 /* PropertyAssignment */: - case 211 /* VariableDeclaration */: - case 163 /* BindingElement */: - return visitNodes(cbNodes, node.decorators) || - visitNodes(cbNodes, node.modifiers) || - visitNode(cbNode, node.propertyName) || - visitNode(cbNode, node.dotDotDotToken) || - visitNode(cbNode, node.name) || - visitNode(cbNode, node.questionToken) || - visitNode(cbNode, node.type) || - visitNode(cbNode, node.initializer); - case 152 /* FunctionType */: - case 153 /* ConstructorType */: - case 147 /* CallSignature */: - case 148 /* ConstructSignature */: - case 149 /* IndexSignature */: - return visitNodes(cbNodes, node.decorators) || - visitNodes(cbNodes, node.modifiers) || - visitNodes(cbNodes, node.typeParameters) || - visitNodes(cbNodes, node.parameters) || - visitNode(cbNode, node.type); - case 143 /* MethodDeclaration */: - case 142 /* MethodSignature */: - case 144 /* Constructor */: - case 145 /* GetAccessor */: - case 146 /* SetAccessor */: - case 173 /* FunctionExpression */: - case 213 /* FunctionDeclaration */: - case 174 /* ArrowFunction */: - return visitNodes(cbNodes, node.decorators) || - visitNodes(cbNodes, node.modifiers) || - visitNode(cbNode, node.asteriskToken) || - visitNode(cbNode, node.name) || - visitNode(cbNode, node.questionToken) || - visitNodes(cbNodes, node.typeParameters) || - visitNodes(cbNodes, node.parameters) || - visitNode(cbNode, node.type) || - visitNode(cbNode, node.equalsGreaterThanToken) || - visitNode(cbNode, node.body); - case 151 /* TypeReference */: - return visitNode(cbNode, node.typeName) || - visitNodes(cbNodes, node.typeArguments); - case 150 /* TypePredicate */: - return visitNode(cbNode, node.parameterName) || - visitNode(cbNode, node.type); - case 154 /* TypeQuery */: - return visitNode(cbNode, node.exprName); - case 155 /* TypeLiteral */: - return visitNodes(cbNodes, node.members); - case 156 /* ArrayType */: - return visitNode(cbNode, node.elementType); - case 157 /* TupleType */: - return visitNodes(cbNodes, node.elementTypes); - case 158 /* UnionType */: - case 159 /* IntersectionType */: - return visitNodes(cbNodes, node.types); - case 160 /* ParenthesizedType */: - return visitNode(cbNode, node.type); - case 161 /* ObjectBindingPattern */: - case 162 /* ArrayBindingPattern */: - return visitNodes(cbNodes, node.elements); - case 164 /* ArrayLiteralExpression */: - return visitNodes(cbNodes, node.elements); - case 165 /* ObjectLiteralExpression */: - return visitNodes(cbNodes, node.properties); - case 166 /* PropertyAccessExpression */: - return visitNode(cbNode, node.expression) || - visitNode(cbNode, node.dotToken) || - visitNode(cbNode, node.name); - case 167 /* ElementAccessExpression */: - return visitNode(cbNode, node.expression) || - visitNode(cbNode, node.argumentExpression); - case 168 /* CallExpression */: - case 169 /* NewExpression */: - return visitNode(cbNode, node.expression) || - visitNodes(cbNodes, node.typeArguments) || - visitNodes(cbNodes, node.arguments); - case 170 /* TaggedTemplateExpression */: - return visitNode(cbNode, node.tag) || - visitNode(cbNode, node.template); - case 171 /* TypeAssertionExpression */: - return visitNode(cbNode, node.type) || - visitNode(cbNode, node.expression); - case 172 /* ParenthesizedExpression */: - return visitNode(cbNode, node.expression); - case 175 /* DeleteExpression */: - return visitNode(cbNode, node.expression); - case 176 /* TypeOfExpression */: - return visitNode(cbNode, node.expression); - case 177 /* VoidExpression */: - return visitNode(cbNode, node.expression); - case 179 /* PrefixUnaryExpression */: - return visitNode(cbNode, node.operand); - case 184 /* YieldExpression */: - return visitNode(cbNode, node.asteriskToken) || - visitNode(cbNode, node.expression); - case 178 /* AwaitExpression */: - return visitNode(cbNode, node.expression); - case 180 /* PostfixUnaryExpression */: - return visitNode(cbNode, node.operand); - case 181 /* BinaryExpression */: - return visitNode(cbNode, node.left) || - visitNode(cbNode, node.operatorToken) || - visitNode(cbNode, node.right); - case 189 /* AsExpression */: - return visitNode(cbNode, node.expression) || - visitNode(cbNode, node.type); - case 182 /* ConditionalExpression */: - return visitNode(cbNode, node.condition) || - visitNode(cbNode, node.questionToken) || - visitNode(cbNode, node.whenTrue) || - visitNode(cbNode, node.colonToken) || - visitNode(cbNode, node.whenFalse); - case 185 /* SpreadElementExpression */: - return visitNode(cbNode, node.expression); - case 192 /* Block */: - case 219 /* ModuleBlock */: - return visitNodes(cbNodes, node.statements); - case 248 /* SourceFile */: - return visitNodes(cbNodes, node.statements) || - visitNode(cbNode, node.endOfFileToken); - case 193 /* VariableStatement */: - return visitNodes(cbNodes, node.decorators) || - visitNodes(cbNodes, node.modifiers) || - visitNode(cbNode, node.declarationList); - case 212 /* VariableDeclarationList */: - return visitNodes(cbNodes, node.declarations); - case 195 /* ExpressionStatement */: - return visitNode(cbNode, node.expression); - case 196 /* IfStatement */: - return visitNode(cbNode, node.expression) || - visitNode(cbNode, node.thenStatement) || - visitNode(cbNode, node.elseStatement); - case 197 /* DoStatement */: - return visitNode(cbNode, node.statement) || - visitNode(cbNode, node.expression); - case 198 /* WhileStatement */: - return visitNode(cbNode, node.expression) || - visitNode(cbNode, node.statement); - case 199 /* ForStatement */: - return visitNode(cbNode, node.initializer) || - visitNode(cbNode, node.condition) || - visitNode(cbNode, node.incrementor) || - visitNode(cbNode, node.statement); - case 200 /* ForInStatement */: - return visitNode(cbNode, node.initializer) || - visitNode(cbNode, node.expression) || - visitNode(cbNode, node.statement); - case 201 /* ForOfStatement */: - return visitNode(cbNode, node.initializer) || - visitNode(cbNode, node.expression) || - visitNode(cbNode, node.statement); - case 202 /* ContinueStatement */: - case 203 /* BreakStatement */: - return visitNode(cbNode, node.label); - case 204 /* ReturnStatement */: - return visitNode(cbNode, node.expression); - case 205 /* WithStatement */: - return visitNode(cbNode, node.expression) || - visitNode(cbNode, node.statement); - case 206 /* SwitchStatement */: - return visitNode(cbNode, node.expression) || - visitNode(cbNode, node.caseBlock); - case 220 /* CaseBlock */: - return visitNodes(cbNodes, node.clauses); - case 241 /* CaseClause */: - return visitNode(cbNode, node.expression) || - visitNodes(cbNodes, node.statements); - case 242 /* DefaultClause */: - return visitNodes(cbNodes, node.statements); - case 207 /* LabeledStatement */: - return visitNode(cbNode, node.label) || - visitNode(cbNode, node.statement); - case 208 /* ThrowStatement */: - return visitNode(cbNode, node.expression); - case 209 /* TryStatement */: - return visitNode(cbNode, node.tryBlock) || - visitNode(cbNode, node.catchClause) || - visitNode(cbNode, node.finallyBlock); - case 244 /* CatchClause */: - return visitNode(cbNode, node.variableDeclaration) || - visitNode(cbNode, node.block); - case 139 /* Decorator */: - return visitNode(cbNode, node.expression); - case 214 /* ClassDeclaration */: - case 186 /* ClassExpression */: - return visitNodes(cbNodes, node.decorators) || - visitNodes(cbNodes, node.modifiers) || - visitNode(cbNode, node.name) || - visitNodes(cbNodes, node.typeParameters) || - visitNodes(cbNodes, node.heritageClauses) || - visitNodes(cbNodes, node.members); - case 215 /* InterfaceDeclaration */: - return visitNodes(cbNodes, node.decorators) || - visitNodes(cbNodes, node.modifiers) || - visitNode(cbNode, node.name) || - visitNodes(cbNodes, node.typeParameters) || - visitNodes(cbNodes, node.heritageClauses) || - visitNodes(cbNodes, node.members); - case 216 /* TypeAliasDeclaration */: - return visitNodes(cbNodes, node.decorators) || - visitNodes(cbNodes, node.modifiers) || - visitNode(cbNode, node.name) || - visitNodes(cbNodes, node.typeParameters) || - visitNode(cbNode, node.type); - case 217 /* EnumDeclaration */: - return visitNodes(cbNodes, node.decorators) || - visitNodes(cbNodes, node.modifiers) || - visitNode(cbNode, node.name) || - visitNodes(cbNodes, node.members); - case 247 /* EnumMember */: - return visitNode(cbNode, node.name) || - visitNode(cbNode, node.initializer); - case 218 /* ModuleDeclaration */: - return visitNodes(cbNodes, node.decorators) || - visitNodes(cbNodes, node.modifiers) || - visitNode(cbNode, node.name) || - visitNode(cbNode, node.body); - case 221 /* ImportEqualsDeclaration */: - return visitNodes(cbNodes, node.decorators) || - visitNodes(cbNodes, node.modifiers) || - visitNode(cbNode, node.name) || - visitNode(cbNode, node.moduleReference); - case 222 /* ImportDeclaration */: - return visitNodes(cbNodes, node.decorators) || - visitNodes(cbNodes, node.modifiers) || - visitNode(cbNode, node.importClause) || - visitNode(cbNode, node.moduleSpecifier); - case 223 /* ImportClause */: - return visitNode(cbNode, node.name) || - visitNode(cbNode, node.namedBindings); - case 224 /* NamespaceImport */: - return visitNode(cbNode, node.name); - case 225 /* NamedImports */: - case 229 /* NamedExports */: - return visitNodes(cbNodes, node.elements); - case 228 /* ExportDeclaration */: - return visitNodes(cbNodes, node.decorators) || - visitNodes(cbNodes, node.modifiers) || - visitNode(cbNode, node.exportClause) || - visitNode(cbNode, node.moduleSpecifier); - case 226 /* ImportSpecifier */: - case 230 /* ExportSpecifier */: - return visitNode(cbNode, node.propertyName) || - visitNode(cbNode, node.name); - case 227 /* ExportAssignment */: - return visitNodes(cbNodes, node.decorators) || - visitNodes(cbNodes, node.modifiers) || - visitNode(cbNode, node.expression); - case 183 /* TemplateExpression */: - return visitNode(cbNode, node.head) || visitNodes(cbNodes, node.templateSpans); - case 190 /* TemplateSpan */: - return visitNode(cbNode, node.expression) || visitNode(cbNode, node.literal); - case 136 /* ComputedPropertyName */: - return visitNode(cbNode, node.expression); - case 243 /* HeritageClause */: - return visitNodes(cbNodes, node.types); - case 188 /* ExpressionWithTypeArguments */: - return visitNode(cbNode, node.expression) || - visitNodes(cbNodes, node.typeArguments); - case 232 /* ExternalModuleReference */: - return visitNode(cbNode, node.expression); - case 231 /* MissingDeclaration */: - return visitNodes(cbNodes, node.decorators); - case 233 /* JsxElement */: - return visitNode(cbNode, node.openingElement) || - visitNodes(cbNodes, node.children) || - visitNode(cbNode, node.closingElement); - case 234 /* JsxSelfClosingElement */: - case 235 /* JsxOpeningElement */: - return visitNode(cbNode, node.tagName) || - visitNodes(cbNodes, node.attributes); - case 238 /* JsxAttribute */: - return visitNode(cbNode, node.name) || - visitNode(cbNode, node.initializer); - case 239 /* JsxSpreadAttribute */: - return visitNode(cbNode, node.expression); - case 240 /* JsxExpression */: - return visitNode(cbNode, node.expression); - case 237 /* JsxClosingElement */: - return visitNode(cbNode, node.tagName); - case 249 /* JSDocTypeExpression */: - return visitNode(cbNode, node.type); - case 253 /* JSDocUnionType */: - return visitNodes(cbNodes, node.types); - case 254 /* JSDocTupleType */: - return visitNodes(cbNodes, node.types); - case 252 /* JSDocArrayType */: - return visitNode(cbNode, node.elementType); - case 256 /* JSDocNonNullableType */: - return visitNode(cbNode, node.type); - case 255 /* JSDocNullableType */: - return visitNode(cbNode, node.type); - case 257 /* JSDocRecordType */: - return visitNodes(cbNodes, node.members); - case 259 /* JSDocTypeReference */: - return visitNode(cbNode, node.name) || - visitNodes(cbNodes, node.typeArguments); - case 260 /* JSDocOptionalType */: - return visitNode(cbNode, node.type); - case 261 /* JSDocFunctionType */: - return visitNodes(cbNodes, node.parameters) || - visitNode(cbNode, node.type); - case 262 /* JSDocVariadicType */: - return visitNode(cbNode, node.type); - case 263 /* JSDocConstructorType */: - return visitNode(cbNode, node.type); - case 264 /* JSDocThisType */: - return visitNode(cbNode, node.type); - case 258 /* JSDocRecordMember */: - return visitNode(cbNode, node.name) || - visitNode(cbNode, node.type); - case 265 /* JSDocComment */: - return visitNodes(cbNodes, node.tags); - case 267 /* JSDocParameterTag */: - return visitNode(cbNode, node.preParameterName) || - visitNode(cbNode, node.typeExpression) || - visitNode(cbNode, node.postParameterName); - case 268 /* JSDocReturnTag */: - return visitNode(cbNode, node.typeExpression); - case 269 /* JSDocTypeTag */: - return visitNode(cbNode, node.typeExpression); - case 270 /* JSDocTemplateTag */: - return visitNodes(cbNodes, node.typeParameters); - } - } - ts.forEachChild = forEachChild; - function createSourceFile(fileName, sourceText, languageVersion, setParentNodes) { - if (setParentNodes === void 0) { setParentNodes = false; } - var start = new Date().getTime(); - var result = Parser.parseSourceFile(fileName, sourceText, languageVersion, /*syntaxCursor*/ undefined, setParentNodes); - ts.parseTime += new Date().getTime() - start; - return result; - } - ts.createSourceFile = createSourceFile; - // Produces a new SourceFile for the 'newText' provided. The 'textChangeRange' parameter - // indicates what changed between the 'text' that this SourceFile has and the 'newText'. - // The SourceFile will be created with the compiler attempting to reuse as many nodes from - // this file as possible. - // - // Note: this function mutates nodes from this SourceFile. That means any existing nodes - // from this SourceFile that are being held onto may change as a result (including - // becoming detached from any SourceFile). It is recommended that this SourceFile not - // be used once 'update' is called on it. - function updateSourceFile(sourceFile, newText, textChangeRange, aggressiveChecks) { - return IncrementalParser.updateSourceFile(sourceFile, newText, textChangeRange, aggressiveChecks); - } - ts.updateSourceFile = updateSourceFile; - /* @internal */ - function parseIsolatedJSDocComment(content, start, length) { - return Parser.JSDocParser.parseIsolatedJSDocComment(content, start, length); - } - ts.parseIsolatedJSDocComment = parseIsolatedJSDocComment; - /* @internal */ - // Exposed only for testing. - function parseJSDocTypeExpressionForTests(content, start, length) { - return Parser.JSDocParser.parseJSDocTypeExpressionForTests(content, start, length); - } - ts.parseJSDocTypeExpressionForTests = parseJSDocTypeExpressionForTests; - // Implement the parser as a singleton module. We do this for perf reasons because creating - // parser instances can actually be expensive enough to impact us on projects with many source - // files. - var Parser; - (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 disallowInAndDecoratorContext = 1 /* DisallowIn */ | 4 /* Decorator */; - var sourceFile; - var parseDiagnostics; - var syntaxCursor; - var token; - var sourceText; - var nodeCount; - var identifiers; - var identifierCount; - var parsingContext; - // Flags that dictate what parsing context we're in. For example: - // Whether or not we are in strict parsing mode. All that changes in strict parsing mode is - // that some tokens that would be considered identifiers may be considered keywords. - // - // When adding more parser context flags, consider which is the more common case that the - // flag will be in. This should be the 'false' state for that flag. The reason for this is - // that we don't store data in our nodes unless the value is in the *non-default* state. So, - // for example, more often than code 'allows-in' (or doesn't 'disallow-in'). We opt for - // 'disallow-in' set to 'false'. Otherwise, if we had 'allowsIn' set to 'true', then almost - // all nodes would need extra state on them to store this info. - // - // Note: 'allowIn' and 'allowYield' track 1:1 with the [in] and [yield] concepts in the ES6 - // grammar specification. - // - // An important thing about these context concepts. By default they are effectively inherited - // while parsing through every grammar production. i.e. if you don't change them, then when - // you parse a sub-production, it will have the same context values as the parent production. - // This is great most of the time. After all, consider all the 'expression' grammar productions - // and how nearly all of them pass along the 'in' and 'yield' context values: - // - // EqualityExpression[In, Yield] : - // RelationalExpression[?In, ?Yield] - // EqualityExpression[?In, ?Yield] == RelationalExpression[?In, ?Yield] - // EqualityExpression[?In, ?Yield] != RelationalExpression[?In, ?Yield] - // EqualityExpression[?In, ?Yield] === RelationalExpression[?In, ?Yield] - // EqualityExpression[?In, ?Yield] !== RelationalExpression[?In, ?Yield] - // - // Where you have to be careful is then understanding what the points are in the grammar - // where the values are *not* passed along. For example: - // - // SingleNameBinding[Yield,GeneratorParameter] - // [+GeneratorParameter]BindingIdentifier[Yield] Initializer[In]opt - // [~GeneratorParameter]BindingIdentifier[?Yield]Initializer[In, ?Yield]opt - // - // Here this is saying that if the GeneratorParameter context flag is set, that we should - // explicitly set the 'yield' context flag to false before calling into the BindingIdentifier - // and we should explicitly unset the 'yield' context flag before calling into the Initializer. - // production. Conversely, if the GeneratorParameter context flag is not set, then we - // should leave the 'yield' context flag alone. - // - // Getting this all correct is tricky and requires careful reading of the grammar to - // understand when these values should be changed versus when they should be inherited. - // - // Note: it should not be necessary to save/restore these flags during speculative/lookahead - // parsing. These context flags are naturally stored and restored through normal recursive - // descent parsing and unwinding. - var contextFlags; - // Whether or not we've had a parse error since creating the last AST node. If we have - // encountered an error, it will be stored on the next AST node we create. Parse errors - // can be broken down into three categories: - // - // 1) An error that occurred during scanning. For example, an unterminated literal, or a - // character that was completely not understood. - // - // 2) A token was expected, but was not present. This type of error is commonly produced - // by the 'parseExpected' function. - // - // 3) A token was present that no parsing function was able to consume. This type of error - // only occurs in the 'abortParsingListOrMoveToNextToken' function when the parser - // decides to skip the token. - // - // In all of these cases, we want to mark the next node as having had an error before it. - // With this mark, we can know in incremental settings if this node can be reused, or if - // we have to reparse it. If we don't keep this information around, we may just reuse the - // node. in that event we would then not produce the same errors as we did before, causing - // significant confusion problems. - // - // Note: it is necessary that this value be saved/restored during speculative/lookahead - // parsing. During lookahead parsing, we will often create a node. That node will have - // this value attached, and then this value will be set back to 'false'. If we decide to - // rewind, we must get back to the same value we had prior to the lookahead. - // - // 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) { - initializeState(fileName, _sourceText, languageVersion, _syntaxCursor); - var result = parseSourceFileWorker(fileName, languageVersion, setParentNodes); - clearState(); - return result; - } - Parser.parseSourceFile = parseSourceFile; - function initializeState(fileName, _sourceText, languageVersion, _syntaxCursor) { - sourceText = _sourceText; - syntaxCursor = _syntaxCursor; - parseDiagnostics = []; - parsingContext = 0; - identifiers = {}; - identifierCount = 0; - nodeCount = 0; - contextFlags = ts.isJavaScript(fileName) ? 32 /* JavaScriptFile */ : 0 /* None */; - parseErrorBeforeNextFinishedNode = false; - // Initialize and prime the scanner before parsing the source elements. - scanner.setText(sourceText); - scanner.setOnError(scanError); - scanner.setScriptTarget(languageVersion); - scanner.setLanguageVariant(ts.isTsx(fileName) ? 1 /* JSX */ : 0 /* Standard */); - } - function clearState() { - // Clear out the text the scanner is pointing at, so it doesn't keep anything alive unnecessarily. - scanner.setText(""); - scanner.setOnError(undefined); - // Clear any data. We don't want to accidently hold onto it for too long. - parseDiagnostics = undefined; - sourceFile = undefined; - identifiers = undefined; - syntaxCursor = undefined; - sourceText = undefined; - } - function parseSourceFileWorker(fileName, languageVersion, setParentNodes) { - sourceFile = createSourceFile(fileName, languageVersion); - // Prime the scanner. - token = nextToken(); - processReferenceComments(sourceFile); - sourceFile.statements = parseList(0 /* SourceElements */, parseStatement); - ts.Debug.assert(token === 1 /* EndOfFileToken */); - sourceFile.endOfFileToken = parseTokenNode(); - setExternalModuleIndicator(sourceFile); - sourceFile.nodeCount = nodeCount; - sourceFile.identifierCount = identifierCount; - sourceFile.identifiers = identifiers; - sourceFile.parseDiagnostics = parseDiagnostics; - if (setParentNodes) { - fixupParentReferences(sourceFile); - } - // If this is a javascript file, proactively see if we can get JSDoc comments for - // relevant nodes in the file. We'll use these to provide typing informaion if they're - // available. - if (ts.isJavaScript(fileName)) { - addJSDocComments(); - } - return sourceFile; - } - function addJSDocComments() { - forEachChild(sourceFile, visit); - return; - function visit(node) { - // Add additional cases as necessary depending on how we see JSDoc comments used - // in the wild. - switch (node.kind) { - case 193 /* VariableStatement */: - case 213 /* FunctionDeclaration */: - case 138 /* Parameter */: - addJSDocComment(node); - } - forEachChild(node, visit); - } - } - function addJSDocComment(node) { - var comments = ts.getLeadingCommentRangesOfNode(node, sourceFile); - if (comments) { - for (var _i = 0; _i < comments.length; _i++) { - var comment = comments[_i]; - var jsDocComment = JSDocParser.parseJSDocComment(node, comment.pos, comment.end - comment.pos); - if (jsDocComment) { - node.jsDocComment = jsDocComment; - } - } - } - } - function fixupParentReferences(sourceFile) { - // normally parent references are set during binding. However, for clients that only need - // a syntax tree, and no semantic features, then the binding process is an unnecessary - // overhead. This functions allows us to set all the parents, without all the expense of - // binding. - var parent = sourceFile; - forEachChild(sourceFile, visitNode); - return; - function visitNode(n) { - // walk down setting parents that differ from the parent we think it should be. This - // allows us to quickly bail out of setting parents for subtrees during incremental - // parsing - if (n.parent !== parent) { - n.parent = parent; - var saveParent = parent; - parent = n; - forEachChild(n, visitNode); - parent = saveParent; - } - } - } - Parser.fixupParentReferences = fixupParentReferences; - function createSourceFile(fileName, languageVersion) { - var sourceFile = createNode(248 /* SourceFile */, /*pos*/ 0); - sourceFile.pos = 0; - sourceFile.end = sourceText.length; - sourceFile.text = sourceText; - sourceFile.bindDiagnostics = []; - sourceFile.languageVersion = languageVersion; - sourceFile.fileName = ts.normalizePath(fileName); - sourceFile.flags = ts.fileExtensionIs(sourceFile.fileName, ".d.ts") ? 8192 /* DeclarationFile */ : 0; - sourceFile.languageVariant = ts.isTsx(sourceFile.fileName) ? 1 /* JSX */ : 0 /* Standard */; - return sourceFile; - } - function setContextFlag(val, flag) { - if (val) { - contextFlags |= flag; - } - else { - contextFlags &= ~flag; - } - } - function setDisallowInContext(val) { - setContextFlag(val, 1 /* DisallowIn */); - } - function setYieldContext(val) { - setContextFlag(val, 2 /* Yield */); - } - function setDecoratorContext(val) { - setContextFlag(val, 4 /* Decorator */); - } - function setAwaitContext(val) { - setContextFlag(val, 8 /* Await */); - } - function doOutsideOfContext(context, func) { - // contextFlagsToClear will contain only the context flags that are - // currently set that we need to temporarily clear - // We don't just blindly reset to the previous flags to ensure - // that we do not mutate cached flags for the incremental - // parser (ThisNodeHasError, ThisNodeOrAnySubNodesHasError, and - // HasAggregatedChildData). - var contextFlagsToClear = context & contextFlags; - if (contextFlagsToClear) { - // clear the requested context flags - setContextFlag(false, contextFlagsToClear); - var result = func(); - // restore the context flags we just cleared - setContextFlag(true, contextFlagsToClear); - return result; - } - // no need to do anything special as we are not in any of the requested contexts - return func(); - } - function doInsideOfContext(context, func) { - // contextFlagsToSet will contain only the context flags that - // are not currently set that we need to temporarily enable. - // We don't just blindly reset to the previous flags to ensure - // that we do not mutate cached flags for the incremental - // parser (ThisNodeHasError, ThisNodeOrAnySubNodesHasError, and - // HasAggregatedChildData). - var contextFlagsToSet = context & ~contextFlags; - if (contextFlagsToSet) { - // set the requested context flags - setContextFlag(true, contextFlagsToSet); - var result = func(); - // reset the context flags we just set - setContextFlag(false, contextFlagsToSet); - return result; - } - // no need to do anything special as we are already in all of the requested contexts - return func(); - } - function allowInAnd(func) { - return doOutsideOfContext(1 /* DisallowIn */, func); - } - function disallowInAnd(func) { - return doInsideOfContext(1 /* DisallowIn */, func); - } - function doInYieldContext(func) { - return doInsideOfContext(2 /* Yield */, func); - } - function doOutsideOfYieldContext(func) { - return doOutsideOfContext(2 /* Yield */, func); - } - function doInDecoratorContext(func) { - return doInsideOfContext(4 /* Decorator */, func); - } - function doInAwaitContext(func) { - return doInsideOfContext(8 /* Await */, func); - } - function doOutsideOfAwaitContext(func) { - return doOutsideOfContext(8 /* Await */, func); - } - function doInYieldAndAwaitContext(func) { - return doInsideOfContext(2 /* Yield */ | 8 /* Await */, func); - } - function doOutsideOfYieldAndAwaitContext(func) { - return doOutsideOfContext(2 /* Yield */ | 8 /* Await */, func); - } - function inContext(flags) { - return (contextFlags & flags) !== 0; - } - function inYieldContext() { - return inContext(2 /* Yield */); - } - function inDisallowInContext() { - return inContext(1 /* DisallowIn */); - } - function inDecoratorContext() { - return inContext(4 /* Decorator */); - } - function inAwaitContext() { - return inContext(8 /* Await */); - } - function parseErrorAtCurrentToken(message, arg0) { - var start = scanner.getTokenPos(); - var length = scanner.getTextPos() - start; - parseErrorAtPosition(start, length, message, arg0); - } - function parseErrorAtPosition(start, length, message, arg0) { - // Don't report another error if it would just be at the same position as the last error. - var lastError = ts.lastOrUndefined(parseDiagnostics); - if (!lastError || start !== lastError.start) { - parseDiagnostics.push(ts.createFileDiagnostic(sourceFile, start, length, message, arg0)); - } - // Mark that we've encountered an error. We'll set an appropriate bit on the next - // node we finish so that it can't be reused incrementally. - parseErrorBeforeNextFinishedNode = true; - } - function scanError(message, length) { - var pos = scanner.getTextPos(); - parseErrorAtPosition(pos, length || 0, message); - } - function getNodePos() { - return scanner.getStartPos(); - } - function getNodeEnd() { - return scanner.getStartPos(); - } - function nextToken() { - return token = scanner.scan(); - } - function getTokenPos(pos) { - return ts.skipTrivia(sourceText, pos); - } - function reScanGreaterToken() { - return token = scanner.reScanGreaterToken(); - } - function reScanSlashToken() { - return token = scanner.reScanSlashToken(); - } - function reScanTemplateToken() { - return token = scanner.reScanTemplateToken(); - } - function scanJsxIdentifier() { - return token = scanner.scanJsxIdentifier(); - } - function scanJsxText() { - return token = scanner.scanJsxToken(); - } - function speculationHelper(callback, isLookAhead) { - // Keep track of the state we'll need to rollback to if lookahead fails (or if the - // caller asked us to always reset our state). - var saveToken = token; - var saveParseDiagnosticsLength = parseDiagnostics.length; - var saveParseErrorBeforeNextFinishedNode = parseErrorBeforeNextFinishedNode; - // Note: it is not actually necessary to save/restore the context flags here. That's - // because the saving/restoring of these flags happens naturally through the recursive - // descent nature of our parser. However, we still store this here just so we can - // assert that that invariant holds. - var saveContextFlags = contextFlags; - // If we're only looking ahead, then tell the scanner to only lookahead as well. - // Otherwise, if we're actually speculatively parsing, then tell the scanner to do the - // same. - var result = isLookAhead - ? scanner.lookAhead(callback) - : scanner.tryScan(callback); - ts.Debug.assert(saveContextFlags === contextFlags); - // If our callback returned something 'falsy' or we're just looking ahead, - // then unconditionally restore us to where we were. - if (!result || isLookAhead) { - token = saveToken; - parseDiagnostics.length = saveParseDiagnosticsLength; - parseErrorBeforeNextFinishedNode = saveParseErrorBeforeNextFinishedNode; - } - return result; - } - // Invokes the provided callback then unconditionally restores the parser to the state it - // was in immediately prior to invoking the callback. The result of invoking the callback - // is returned from this function. - function lookAhead(callback) { - return speculationHelper(callback, /*isLookAhead*/ true); - } - // Invokes the provided callback. If the callback returns something falsy, then it restores - // the parser to the state it was in immediately prior to invoking the callback. If the - // callback returns something truthy, then the parser state is not rolled back. The result - // of invoking the callback is returned from this function. - function tryParse(callback) { - return speculationHelper(callback, /*isLookAhead*/ false); - } - // Ignore strict mode flag because we will report an error in type checker instead. - function isIdentifier() { - if (token === 69 /* Identifier */) { - return true; - } - // If we have a 'yield' keyword, and we're in the [yield] context, then 'yield' is - // considered a keyword and is not an identifier. - if (token === 114 /* YieldKeyword */ && inYieldContext()) { - return false; - } - // If we have a 'await' keyword, and we're in the [Await] context, then 'await' is - // considered a keyword and is not an identifier. - if (token === 119 /* AwaitKeyword */ && inAwaitContext()) { - return false; - } - return token > 105 /* LastReservedWord */; - } - function parseExpected(kind, diagnosticMessage, shouldAdvance) { - if (shouldAdvance === void 0) { shouldAdvance = true; } - if (token === kind) { - if (shouldAdvance) { - nextToken(); - } - return true; - } - // Report specific message if provided with one. Otherwise, report generic fallback message. - if (diagnosticMessage) { - parseErrorAtCurrentToken(diagnosticMessage); - } - else { - parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(kind)); - } - return false; - } - function parseOptional(t) { - if (token === t) { - nextToken(); - return true; - } - return false; - } - function parseOptionalToken(t) { - if (token === t) { - return parseTokenNode(); - } - return undefined; - } - function parseExpectedToken(t, reportAtCurrentPosition, diagnosticMessage, arg0) { - return parseOptionalToken(t) || - createMissingNode(t, reportAtCurrentPosition, diagnosticMessage, arg0); - } - function parseTokenNode() { - var node = createNode(token); - nextToken(); - return finishNode(node); - } - function canParseSemicolon() { - // If there's a real semicolon, then we can always parse it out. - if (token === 23 /* 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(); - } - function parseSemicolon() { - if (canParseSemicolon()) { - if (token === 23 /* SemicolonToken */) { - // consume the semicolon if it was explicitly provided. - nextToken(); - } - return true; - } - else { - return parseExpected(23 /* SemicolonToken */); - } - } - function createNode(kind, pos) { - nodeCount++; - if (!(pos >= 0)) { - pos = scanner.getStartPos(); - } - return new (nodeConstructors[kind] || (nodeConstructors[kind] = ts.objectAllocator.getNodeConstructor(kind)))(pos, pos); - } - function finishNode(node, end) { - node.end = end === undefined ? scanner.getStartPos() : end; - if (contextFlags) { - node.parserContextFlags = contextFlags; - } - // Keep track on the node if we encountered an error while parsing it. If we did, then - // we cannot reuse the node incrementally. Once we've marked this node, clear out the - // flag so that we don't mark any subsequent nodes. - if (parseErrorBeforeNextFinishedNode) { - parseErrorBeforeNextFinishedNode = false; - node.parserContextFlags |= 16 /* ThisNodeHasError */; - } - return node; - } - function createMissingNode(kind, reportAtCurrentPosition, diagnosticMessage, arg0) { - if (reportAtCurrentPosition) { - parseErrorAtPosition(scanner.getStartPos(), 0, diagnosticMessage, arg0); - } - else { - parseErrorAtCurrentToken(diagnosticMessage, arg0); - } - var result = createNode(kind, scanner.getStartPos()); - result.text = ""; - return finishNode(result); - } - function internIdentifier(text) { - text = ts.escapeIdentifier(text); - return ts.hasProperty(identifiers, text) ? identifiers[text] : (identifiers[text] = text); - } - // An identifier that starts with two underscores has an extra underscore character prepended to it to avoid issues - // with magic property names like '__proto__'. The 'identifiers' object is used to share a single string instance for - // each identifier in order to reduce memory consumption. - function createIdentifier(isIdentifier, diagnosticMessage) { - identifierCount++; - if (isIdentifier) { - var node = createNode(69 /* Identifier */); - // Store original token kind if it is not just an Identifier so we can report appropriate error later in type checker - if (token !== 69 /* Identifier */) { - node.originalKeywordKind = token; - } - node.text = internIdentifier(scanner.getTokenValue()); - nextToken(); - return finishNode(node); - } - return createMissingNode(69 /* Identifier */, /*reportAtCurrentPosition*/ false, diagnosticMessage || ts.Diagnostics.Identifier_expected); - } - function parseIdentifier(diagnosticMessage) { - return createIdentifier(isIdentifier(), diagnosticMessage); - } - function parseIdentifierName() { - return createIdentifier(ts.tokenIsIdentifierOrKeyword(token)); - } - function isLiteralPropertyName() { - return ts.tokenIsIdentifierOrKeyword(token) || - token === 9 /* StringLiteral */ || - token === 8 /* NumericLiteral */; - } - function parsePropertyNameWorker(allowComputedPropertyNames) { - if (token === 9 /* StringLiteral */ || token === 8 /* NumericLiteral */) { - return parseLiteralNode(/*internName*/ true); - } - if (allowComputedPropertyNames && token === 19 /* OpenBracketToken */) { - return parseComputedPropertyName(); - } - return parseIdentifierName(); - } - function parsePropertyName() { - return parsePropertyNameWorker(/*allowComputedPropertyNames:*/ true); - } - function parseSimplePropertyName() { - return parsePropertyNameWorker(/*allowComputedPropertyNames:*/ false); - } - function isSimplePropertyName() { - return token === 9 /* StringLiteral */ || token === 8 /* NumericLiteral */ || ts.tokenIsIdentifierOrKeyword(token); - } - function parseComputedPropertyName() { - // PropertyName [Yield]: - // LiteralPropertyName - // ComputedPropertyName[?Yield] - var node = createNode(136 /* ComputedPropertyName */); - parseExpected(19 /* OpenBracketToken */); - // We parse any expression (including a comma expression). But the grammar - // says that only an assignment expression is allowed, so the grammar checker - // will error if it sees a comma expression. - node.expression = allowInAnd(parseExpression); - parseExpected(20 /* CloseBracketToken */); - return finishNode(node); - } - function parseContextualModifier(t) { - return token === t && tryParse(nextTokenCanFollowModifier); - } - function nextTokenCanFollowModifier() { - if (token === 74 /* ConstKeyword */) { - // 'const' is only a modifier if followed by 'enum'. - return nextToken() === 81 /* EnumKeyword */; - } - if (token === 82 /* ExportKeyword */) { - nextToken(); - if (token === 77 /* DefaultKeyword */) { - return lookAhead(nextTokenIsClassOrFunction); - } - return token !== 37 /* AsteriskToken */ && token !== 15 /* OpenBraceToken */ && canFollowModifier(); - } - if (token === 77 /* DefaultKeyword */) { - return nextTokenIsClassOrFunction(); - } - if (token === 113 /* StaticKeyword */) { - nextToken(); - return canFollowModifier(); - } - nextToken(); - if (scanner.hasPrecedingLineBreak()) { - return false; - } - return canFollowModifier(); - } - function parseAnyContextualModifier() { - return ts.isModifier(token) && tryParse(nextTokenCanFollowModifier); - } - function canFollowModifier() { - return token === 19 /* OpenBracketToken */ - || token === 15 /* OpenBraceToken */ - || token === 37 /* AsteriskToken */ - || isLiteralPropertyName(); - } - function nextTokenIsClassOrFunction() { - nextToken(); - return token === 73 /* ClassKeyword */ || token === 87 /* FunctionKeyword */; - } - // True if positioned at the start of a list element - function isListElement(parsingContext, inErrorRecovery) { - var node = currentNode(parsingContext); - if (node) { - return true; - } - switch (parsingContext) { - case 0 /* SourceElements */: - case 1 /* BlockStatements */: - case 3 /* SwitchClauseStatements */: - // If we're in error recovery, then we don't want to treat ';' as an empty statement. - // The problem is that ';' can show up in far too many contexts, and if we see one - // and assume it's a statement, then we may bail out inappropriately from whatever - // 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(); - case 2 /* SwitchClauses */: - return token === 71 /* CaseKeyword */ || token === 77 /* DefaultKeyword */; - case 4 /* TypeMembers */: - return isStartOfTypeMember(); - case 5 /* ClassMembers */: - // We allow semicolons as class elements (as specified by ES6) as long as we're - // 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); - 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(); - case 12 /* ObjectLiteralMembers */: - return token === 19 /* OpenBracketToken */ || token === 37 /* AsteriskToken */ || isLiteralPropertyName(); - case 9 /* ObjectBindingElements */: - return 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 */) { - return lookAhead(isValidHeritageClauseObjectLiteral); - } - if (!inErrorRecovery) { - return isStartOfLeftHandSideExpression() && !isHeritageClauseExtendsOrImplementsKeyword(); - } - else { - // If we're in error recovery we tighten up what we're willing to match. - // That way we don't treat something like "this" as a valid heritage clause - // element during recovery. - return isIdentifier() && !isHeritageClauseExtendsOrImplementsKeyword(); - } - case 8 /* VariableDeclarations */: - return isIdentifierOrPattern(); - case 10 /* ArrayBindingElements */: - return token === 24 /* CommaToken */ || token === 22 /* DotDotDotToken */ || isIdentifierOrPattern(); - case 17 /* TypeParameters */: - return isIdentifier(); - case 11 /* ArgumentExpressions */: - case 15 /* ArrayLiteralMembers */: - return token === 24 /* CommaToken */ || token === 22 /* DotDotDotToken */ || isStartOfExpression(); - case 16 /* Parameters */: - return isStartOfParameter(); - case 18 /* TypeArguments */: - case 19 /* TupleElementTypes */: - return token === 24 /* CommaToken */ || isStartOfType(); - case 20 /* HeritageClauses */: - return isHeritageClause(); - case 21 /* ImportOrExportSpecifiers */: - return ts.tokenIsIdentifierOrKeyword(token); - case 13 /* JsxAttributes */: - return ts.tokenIsIdentifierOrKeyword(token) || token === 15 /* OpenBraceToken */; - case 14 /* JsxChildren */: - return true; - case 22 /* JSDocFunctionParameters */: - case 23 /* JSDocTypeArguments */: - case 25 /* JSDocTupleTypes */: - return JSDocParser.isJSDocType(); - case 24 /* JSDocRecordMembers */: - return isSimplePropertyName(); - } - ts.Debug.fail("Non-exhaustive case in 'isListElement'."); - } - function isValidHeritageClauseObjectLiteral() { - ts.Debug.assert(token === 15 /* OpenBraceToken */); - if (nextToken() === 16 /* CloseBraceToken */) { - // if we see "extends {}" then only treat the {} as what we're extending (and not - // the class body) if we have: - // - // extends {} { - // extends {}, - // extends {} extends - // extends {} implements - var next = nextToken(); - return next === 24 /* CommaToken */ || next === 15 /* OpenBraceToken */ || next === 83 /* ExtendsKeyword */ || next === 106 /* ImplementsKeyword */; - } - return true; - } - function nextTokenIsIdentifier() { - nextToken(); - return isIdentifier(); - } - function nextTokenIsIdentifierOrKeyword() { - nextToken(); - return ts.tokenIsIdentifierOrKeyword(token); - } - function isHeritageClauseExtendsOrImplementsKeyword() { - if (token === 106 /* ImplementsKeyword */ || - token === 83 /* ExtendsKeyword */) { - return lookAhead(nextTokenIsStartOfExpression); - } - return false; - } - function nextTokenIsStartOfExpression() { - nextToken(); - return isStartOfExpression(); - } - // True if positioned at a list terminator - function isListTerminator(kind) { - if (token === 1 /* EndOfFileToken */) { - // Being at the end of the file ends all lists. - return true; - } - switch (kind) { - case 1 /* BlockStatements */: - case 2 /* SwitchClauses */: - case 4 /* TypeMembers */: - case 5 /* ClassMembers */: - case 6 /* EnumMembers */: - case 12 /* ObjectLiteralMembers */: - case 9 /* ObjectBindingElements */: - case 21 /* ImportOrExportSpecifiers */: - return token === 16 /* CloseBraceToken */; - case 3 /* SwitchClauseStatements */: - return token === 16 /* CloseBraceToken */ || token === 71 /* CaseKeyword */ || token === 77 /* DefaultKeyword */; - case 7 /* HeritageClauseElement */: - return token === 15 /* OpenBraceToken */ || token === 83 /* ExtendsKeyword */ || token === 106 /* ImplementsKeyword */; - case 8 /* VariableDeclarations */: - return isVariableDeclaratorListTerminator(); - case 17 /* TypeParameters */: - // Tokens other than '>' are here for better error recovery - return token === 27 /* GreaterThanToken */ || token === 17 /* OpenParenToken */ || token === 15 /* OpenBraceToken */ || token === 83 /* ExtendsKeyword */ || token === 106 /* ImplementsKeyword */; - case 11 /* ArgumentExpressions */: - // Tokens other than ')' are here for better error recovery - return token === 18 /* CloseParenToken */ || token === 23 /* SemicolonToken */; - case 15 /* ArrayLiteralMembers */: - case 19 /* TupleElementTypes */: - case 10 /* ArrayBindingElements */: - return token === 20 /* 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*/; - case 18 /* TypeArguments */: - // Tokens other than '>' are here for better error recovery - return token === 27 /* GreaterThanToken */ || token === 17 /* OpenParenToken */; - case 20 /* HeritageClauses */: - return token === 15 /* OpenBraceToken */ || token === 16 /* CloseBraceToken */; - case 13 /* JsxAttributes */: - return token === 27 /* GreaterThanToken */ || token === 39 /* SlashToken */; - case 14 /* JsxChildren */: - return token === 25 /* LessThanToken */ && lookAhead(nextTokenIsSlash); - case 22 /* JSDocFunctionParameters */: - return token === 18 /* CloseParenToken */ || token === 54 /* ColonToken */ || token === 16 /* CloseBraceToken */; - case 23 /* JSDocTypeArguments */: - return token === 27 /* GreaterThanToken */ || token === 16 /* CloseBraceToken */; - case 25 /* JSDocTupleTypes */: - return token === 20 /* CloseBracketToken */ || token === 16 /* CloseBraceToken */; - case 24 /* JSDocRecordMembers */: - return token === 16 /* CloseBraceToken */; - } - } - function isVariableDeclaratorListTerminator() { - // If we can consume a semicolon (either explicitly, or with ASI), then consider us done - // with parsing the list of variable declarators. - if (canParseSemicolon()) { - return true; - } - // in the case where we're parsing the variable declarator of a 'for-in' statement, we - // are done if we see an 'in' keyword in front of us. Same with for-of - if (isInOrOfKeyword(token)) { - return true; - } - // ERROR RECOVERY TWEAK: - // 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 */) { - return true; - } - // Keep trying to parse out variable declarators. - return false; - } - // True if positioned at element or terminator of the current list or any enclosing list - function isInSomeParsingContext() { - for (var kind = 0; kind < 26 /* Count */; kind++) { - if (parsingContext & (1 << kind)) { - if (isListElement(kind, /* inErrorRecovery */ true) || isListTerminator(kind)) { - return true; - } - } - } - return false; - } - // Parses a list of elements - function parseList(kind, parseElement) { - var saveParsingContext = parsingContext; - parsingContext |= 1 << kind; - var result = []; - result.pos = getNodePos(); - while (!isListTerminator(kind)) { - if (isListElement(kind, /* inErrorRecovery */ false)) { - var element = parseListElement(kind, parseElement); - result.push(element); - continue; - } - if (abortParsingListOrMoveToNextToken(kind)) { - break; - } - } - result.end = getNodeEnd(); - parsingContext = saveParsingContext; - return result; - } - function parseListElement(parsingContext, parseElement) { - var node = currentNode(parsingContext); - if (node) { - return consumeNode(node); - } - return parseElement(); - } - function currentNode(parsingContext) { - // If there is an outstanding parse error that we've encountered, but not attached to - // some node, then we cannot get a node from the old source tree. This is because we - // want to mark the next node we encounter as being unusable. - // - // Note: This may be too conservative. Perhaps we could reuse the node and set the bit - // on it (or its leftmost child) as having the error. For now though, being conservative - // is nice and likely won't ever affect perf. - if (parseErrorBeforeNextFinishedNode) { - return undefined; - } - if (!syntaxCursor) { - // if we don't have a cursor, we could never return a node from the old tree. - return undefined; - } - var node = syntaxCursor.currentNode(scanner.getStartPos()); - // Can't reuse a missing node. - if (ts.nodeIsMissing(node)) { - return undefined; - } - // Can't reuse a node that intersected the change range. - if (node.intersectsChange) { - return undefined; - } - // Can't reuse a node that contains a parse error. This is necessary so that we - // produce the same set of errors again. - if (ts.containsParseError(node)) { - return undefined; - } - // We can only reuse a node if it was parsed under the same strict mode that we're - // currently in. i.e. if we originally parsed a node in non-strict mode, but then - // the user added 'using strict' at the top of the file, then we can't use that node - // again as the presense of strict mode may cause us to parse the tokens in the file - // differetly. - // - // Note: we *can* reuse tokens when the strict mode changes. That's because tokens - // are unaffected by strict mode. It's just the parser will decide what to do with it - // differently depending on what mode it is in. - // - // This also applies to all our other context flags as well. - var nodeContextFlags = node.parserContextFlags & 31 /* ParserGeneratedFlags */; - if (nodeContextFlags !== contextFlags) { - return undefined; - } - // Ok, we have a node that looks like it could be reused. Now verify that it is valid - // in the currest list parsing context that we're currently at. - if (!canReuseNode(node, parsingContext)) { - return undefined; - } - return node; - } - function consumeNode(node) { - // Move the scanner so it is after the node we just consumed. - scanner.setTextPos(node.end); - nextToken(); - return node; - } - function canReuseNode(node, parsingContext) { - switch (parsingContext) { - case 5 /* ClassMembers */: - return isReusableClassMember(node); - case 2 /* SwitchClauses */: - return isReusableSwitchClause(node); - case 0 /* SourceElements */: - case 1 /* BlockStatements */: - case 3 /* SwitchClauseStatements */: - return isReusableStatement(node); - case 6 /* EnumMembers */: - return isReusableEnumMember(node); - case 4 /* TypeMembers */: - return isReusableTypeMember(node); - case 8 /* VariableDeclarations */: - return isReusableVariableDeclaration(node); - case 16 /* Parameters */: - return isReusableParameter(node); - // Any other lists we do not care about reusing nodes in. But feel free to add if - // you can do so safely. Danger areas involve nodes that may involve speculative - // parsing. If speculative parsing is involved with the node, then the range the - // parser reached while looking ahead might be in the edited range (see the example - // in canReuseVariableDeclaratorNode for a good case of this). - case 20 /* HeritageClauses */: - // This would probably be safe to reuse. There is no speculative parsing with - // heritage clauses. - case 17 /* TypeParameters */: - // This would probably be safe to reuse. There is no speculative parsing with - // type parameters. Note that that's because type *parameters* only occur in - // unambiguous *type* contexts. While type *arguments* occur in very ambiguous - // *expression* contexts. - case 19 /* TupleElementTypes */: - // This would probably be safe to reuse. There is no speculative parsing with - // tuple types. - // Technically, type argument list types are probably safe to reuse. While - // speculative parsing is involved with them (since type argument lists are only - // produced from speculative parsing a < as a type argument list), we only have - // the types because speculative parsing succeeded. Thus, the lookahead never - // went past the end of the list and rewound. - case 18 /* TypeArguments */: - // Note: these are almost certainly not safe to ever reuse. Expressions commonly - // need a large amount of lookahead, and we should not reuse them as they may - // have actually intersected the edit. - case 11 /* ArgumentExpressions */: - // This is not safe to reuse for the same reason as the 'AssignmentExpression' - // cases. i.e. a property assignment may end with an expression, and thus might - // have lookahead far beyond it's old node. - case 12 /* ObjectLiteralMembers */: - // This is probably not safe to reuse. There can be speculative parsing with - // type names in a heritage clause. There can be generic names in the type - // name list, and there can be left hand side expressions (which can have type - // arguments.) - case 7 /* HeritageClauseElement */: - // Perhaps safe to reuse, but it's unlikely we'd see more than a dozen attributes - // on any given element. Same for children. - case 13 /* JsxAttributes */: - case 14 /* JsxChildren */: - } - return false; - } - function isReusableClassMember(node) { - if (node) { - switch (node.kind) { - case 144 /* Constructor */: - case 149 /* IndexSignature */: - case 145 /* GetAccessor */: - case 146 /* SetAccessor */: - case 141 /* PropertyDeclaration */: - case 191 /* SemicolonClassElement */: - return true; - case 143 /* MethodDeclaration */: - // Method declarations are not necessarily reusable. An object-literal - // may have a method calls "constructor(...)" and we must reparse that - // into an actual .ConstructorDeclaration. - var methodDeclaration = node; - var nameIsConstructor = methodDeclaration.name.kind === 69 /* Identifier */ && - methodDeclaration.name.originalKeywordKind === 121 /* ConstructorKeyword */; - return !nameIsConstructor; - } - } - return false; - } - function isReusableSwitchClause(node) { - if (node) { - switch (node.kind) { - case 241 /* CaseClause */: - case 242 /* DefaultClause */: - return true; - } - } - return false; - } - function isReusableStatement(node) { - if (node) { - switch (node.kind) { - case 213 /* FunctionDeclaration */: - case 193 /* VariableStatement */: - case 192 /* Block */: - case 196 /* IfStatement */: - case 195 /* ExpressionStatement */: - case 208 /* ThrowStatement */: - case 204 /* ReturnStatement */: - case 206 /* SwitchStatement */: - case 203 /* BreakStatement */: - case 202 /* ContinueStatement */: - case 200 /* ForInStatement */: - case 201 /* ForOfStatement */: - case 199 /* ForStatement */: - case 198 /* WhileStatement */: - case 205 /* WithStatement */: - case 194 /* EmptyStatement */: - case 209 /* TryStatement */: - case 207 /* LabeledStatement */: - case 197 /* DoStatement */: - case 210 /* DebuggerStatement */: - case 222 /* ImportDeclaration */: - case 221 /* ImportEqualsDeclaration */: - case 228 /* ExportDeclaration */: - case 227 /* ExportAssignment */: - case 218 /* ModuleDeclaration */: - case 214 /* ClassDeclaration */: - case 215 /* InterfaceDeclaration */: - case 217 /* EnumDeclaration */: - case 216 /* TypeAliasDeclaration */: - return true; - } - } - return false; - } - function isReusableEnumMember(node) { - return node.kind === 247 /* EnumMember */; - } - function isReusableTypeMember(node) { - if (node) { - switch (node.kind) { - case 148 /* ConstructSignature */: - case 142 /* MethodSignature */: - case 149 /* IndexSignature */: - case 140 /* PropertySignature */: - case 147 /* CallSignature */: - return true; - } - } - return false; - } - function isReusableVariableDeclaration(node) { - if (node.kind !== 211 /* VariableDeclaration */) { - return false; - } - // Very subtle incremental parsing bug. Consider the following code: - // - // let v = new List < A, B - // - // This is actually legal code. It's a list of variable declarators "v = new List() - // - // then we have a problem. "v = new List= 0) { - // Always preserve a trailing comma by marking it on the NodeArray - result.hasTrailingComma = true; - } - result.end = getNodeEnd(); - parsingContext = saveParsingContext; - return result; - } - function createMissingList() { - var pos = getNodePos(); - var result = []; - result.pos = pos; - result.end = pos; - return result; - } - function parseBracketedList(kind, parseElement, open, close) { - if (parseExpected(open)) { - var result = parseDelimitedList(kind, parseElement); - parseExpected(close); - return result; - } - return createMissingList(); - } - // 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(135 /* QualifiedName */, entity.pos); - node.left = entity; - node.right = parseRightSideOfDot(allowReservedWords); - entity = finishNode(node); - } - return entity; - } - function parseRightSideOfDot(allowIdentifierNames) { - // Technically a keyword is valid here as all identifiers and keywords are identifier names. - // However, often we'll encounter this in error situations when the identifier or keyword - // is actually starting another valid construct. - // - // So, we check for the following specific case: - // - // name. - // identifierOrKeyword identifierNameOrKeyword - // - // Note: the newlines are important here. For example, if that above code - // were rewritten into: - // - // name.identifierOrKeyword - // identifierNameOrKeyword - // - // Then we would consider it valid. That's because ASI would take effect and - // the code would be implicitly: "name.identifierOrKeyword; identifierNameOrKeyword". - // In the first case though, ASI will not take effect because there is not a - // line terminator after the identifier or keyword. - if (scanner.hasPrecedingLineBreak() && ts.tokenIsIdentifierOrKeyword(token)) { - var matchesPattern = lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine); - if (matchesPattern) { - // 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 */, /*reportAtCurrentToken*/ true, ts.Diagnostics.Identifier_expected); - } - } - return allowIdentifierNames ? parseIdentifierName() : parseIdentifier(); - } - function parseTemplateExpression() { - var template = createNode(183 /* TemplateExpression */); - template.head = parseLiteralNode(); - ts.Debug.assert(template.head.kind === 12 /* TemplateHead */, "Template head has wrong token kind"); - var templateSpans = []; - templateSpans.pos = getNodePos(); - do { - templateSpans.push(parseTemplateSpan()); - } while (ts.lastOrUndefined(templateSpans).literal.kind === 13 /* TemplateMiddle */); - templateSpans.end = getNodeEnd(); - template.templateSpans = templateSpans; - return finishNode(template); - } - function parseTemplateSpan() { - var span = createNode(190 /* TemplateSpan */); - span.expression = allowInAnd(parseExpression); - var literal; - if (token === 16 /* CloseBraceToken */) { - reScanTemplateToken(); - literal = parseLiteralNode(); - } - else { - literal = parseExpectedToken(14 /* TemplateTail */, /*reportAtCurrentPosition*/ false, ts.Diagnostics._0_expected, ts.tokenToString(16 /* CloseBraceToken */)); - } - span.literal = literal; - return finishNode(span); - } - function parseLiteralNode(internName) { - var node = createNode(token); - var text = scanner.getTokenValue(); - node.text = internName ? internIdentifier(text) : text; - if (scanner.hasExtendedUnicodeEscape()) { - node.hasExtendedUnicodeEscape = true; - } - if (scanner.isUnterminated()) { - node.isUnterminated = true; - } - var tokenPos = scanner.getTokenPos(); - nextToken(); - finishNode(node); - // Octal literals are not allowed in strict mode or ES5 - // Note that theoretically the following condition would hold true literals like 009, - // which is not octal.But because of how the scanner separates the tokens, we would - // never get a token like this. Instead, we would get 00 and 9 as two separate tokens. - // We also do not need to check for negatives because any prefix operator would be part of a - // parent unary expression. - if (node.kind === 8 /* NumericLiteral */ - && sourceText.charCodeAt(tokenPos) === 48 /* _0 */ - && ts.isOctalDigit(sourceText.charCodeAt(tokenPos + 1))) { - node.flags |= 65536 /* OctalLiteral */; - } - return node; - } - // TYPES - function parseTypeReferenceOrTypePredicate() { - var typeName = parseEntityName(/*allowReservedWords*/ false, ts.Diagnostics.Type_expected); - if (typeName.kind === 69 /* Identifier */ && token === 124 /* IsKeyword */ && !scanner.hasPrecedingLineBreak()) { - nextToken(); - var node_1 = createNode(150 /* TypePredicate */, typeName.pos); - node_1.parameterName = typeName; - node_1.type = parseType(); - return finishNode(node_1); - } - var node = createNode(151 /* TypeReference */, typeName.pos); - node.typeName = typeName; - if (!scanner.hasPrecedingLineBreak() && token === 25 /* LessThanToken */) { - node.typeArguments = parseBracketedList(18 /* TypeArguments */, parseType, 25 /* LessThanToken */, 27 /* GreaterThanToken */); - } - return finishNode(node); - } - function parseTypeQuery() { - var node = createNode(154 /* TypeQuery */); - parseExpected(101 /* TypeOfKeyword */); - node.exprName = parseEntityName(/*allowReservedWords*/ true); - return finishNode(node); - } - function parseTypeParameter() { - var node = createNode(137 /* TypeParameter */); - node.name = parseIdentifier(); - if (parseOptional(83 /* ExtendsKeyword */)) { - // It's not uncommon for people to write improper constraints to a generic. If the - // user writes a constraint that is an expression and not an actual type, then parse - // it out as an expression (so we can recover well), but report that a type is needed - // instead. - if (isStartOfType() || !isStartOfExpression()) { - node.constraint = parseType(); - } - else { - // It was not a type, and it looked like an expression. Parse out an expression - // here so we recover well. Note: it is important that we call parseUnaryExpression - // and not parseExpression here. If the user has: - // - // - // - // We do *not* want to consume the > as we're consuming the expression for "". - node.expression = parseUnaryExpressionOrHigher(); - } - } - return finishNode(node); - } - function parseTypeParameters() { - if (token === 25 /* LessThanToken */) { - return parseBracketedList(17 /* TypeParameters */, parseTypeParameter, 25 /* LessThanToken */, 27 /* GreaterThanToken */); - } - } - function parseParameterType() { - if (parseOptional(54 /* ColonToken */)) { - return token === 9 /* StringLiteral */ - ? parseLiteralNode(/*internName*/ true) - : parseType(); - } - return undefined; - } - function isStartOfParameter() { - return token === 22 /* DotDotDotToken */ || isIdentifierOrPattern() || ts.isModifier(token) || token === 55 /* AtToken */; - } - function setModifiers(node, modifiers) { - if (modifiers) { - node.flags |= modifiers.flags; - node.modifiers = modifiers; - } - } - function parseParameter() { - var node = createNode(138 /* Parameter */); - node.decorators = parseDecorators(); - setModifiers(node, parseModifiers()); - node.dotDotDotToken = parseOptionalToken(22 /* DotDotDotToken */); - // FormalParameter [Yield,Await]: - // BindingElement[?Yield,?Await] - node.name = parseIdentifierOrPattern(); - if (ts.getFullWidth(node.name) === 0 && node.flags === 0 && ts.isModifier(token)) { - // in cases like - // 'use strict' - // function foo(static) - // isParameter('static') === true, because of isModifier('static') - // however 'static' is not a legal identifier in a strict mode. - // so result of this function will be ParameterDeclaration (flags = 0, name = missing, type = undefined, initializer = undefined) - // and current token will not change => parsing of the enclosing parameter list will last till the end of time (or OOM) - // to avoid this we'll advance cursor to the next token. - nextToken(); - } - node.questionToken = parseOptionalToken(53 /* QuestionToken */); - node.type = parseParameterType(); - node.initializer = parseBindingElementInitializer(/*inParameter*/ true); - // Do not check for initializers in an ambient context for parameters. This is not - // a grammar error because the grammar allows arbitrary call signatures in - // an ambient context. - // It is actually not necessary for this to be an error at all. The reason is that - // function/constructor implementations are syntactically disallowed in ambient - // contexts. In addition, parameter initializers are semantically disallowed in - // overload signatures. So parameter initializers are transitively disallowed in - // ambient contexts. - return finishNode(node); - } - function parseBindingElementInitializer(inParameter) { - return inParameter ? parseParameterInitializer() : parseNonParameterInitializer(); - } - function parseParameterInitializer() { - return parseInitializer(/*inParameter*/ true); - } - function fillSignature(returnToken, yieldContext, awaitContext, requireCompleteParameterList, signature) { - var returnTokenRequired = returnToken === 34 /* EqualsGreaterThanToken */; - signature.typeParameters = parseTypeParameters(); - signature.parameters = parseParameterList(yieldContext, awaitContext, requireCompleteParameterList); - if (returnTokenRequired) { - parseExpected(returnToken); - signature.type = parseType(); - } - else if (parseOptional(returnToken)) { - signature.type = parseType(); - } - } - function parseParameterList(yieldContext, awaitContext, requireCompleteParameterList) { - // FormalParameters [Yield,Await]: (modified) - // [empty] - // FormalParameterList[?Yield,Await] - // - // FormalParameter[Yield,Await]: (modified) - // BindingElement[?Yield,Await] - // - // BindingElement [Yield,Await]: (modified) - // SingleNameBinding[?Yield,?Await] - // BindingPattern[?Yield,?Await]Initializer [In, ?Yield,?Await] opt - // - // SingleNameBinding [Yield,Await]: - // BindingIdentifier[?Yield,?Await]Initializer [In, ?Yield,?Await] opt - if (parseExpected(17 /* OpenParenToken */)) { - var savedYieldContext = inYieldContext(); - var savedAwaitContext = inAwaitContext(); - setYieldContext(yieldContext); - setAwaitContext(awaitContext); - var result = parseDelimitedList(16 /* Parameters */, parseParameter); - setYieldContext(savedYieldContext); - setAwaitContext(savedAwaitContext); - if (!parseExpected(18 /* CloseParenToken */) && requireCompleteParameterList) { - // Caller insisted that we had to end with a ) We didn't. So just return - // undefined here. - return undefined; - } - return result; - } - // We didn't even have an open paren. If the caller requires a complete parameter list, - // we definitely can't provide that. However, if they're ok with an incomplete one, - // then just return an empty set of parameters. - return requireCompleteParameterList ? undefined : createMissingList(); - } - 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 */)) { - return; - } - // Didn't have a comma. We must have a (possible ASI) semicolon. - parseSemicolon(); - } - function parseSignatureMember(kind) { - var node = createNode(kind); - if (kind === 148 /* ConstructSignature */) { - parseExpected(92 /* NewKeyword */); - } - fillSignature(54 /* ColonToken */, /*yieldContext*/ false, /*awaitContext*/ false, /*requireCompleteParameterList*/ false, node); - parseTypeMemberSemicolon(); - return finishNode(node); - } - function isIndexSignature() { - if (token !== 19 /* OpenBracketToken */) { - return false; - } - return lookAhead(isUnambiguouslyIndexSignature); - } - function isUnambiguouslyIndexSignature() { - // The only allowed sequence is: - // - // [id: - // - // However, for error recovery, we also check the following cases: - // - // [... - // [id, - // [id?, - // [id?: - // [id?] - // [public id - // [private id - // [protected id - // [] - // - nextToken(); - if (token === 22 /* DotDotDotToken */ || token === 20 /* CloseBracketToken */) { - return true; - } - if (ts.isModifier(token)) { - nextToken(); - if (isIdentifier()) { - return true; - } - } - else if (!isIdentifier()) { - return false; - } - else { - // Skip the identifier - nextToken(); - } - // 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 */) { - 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 */) { - 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 */; - } - function parseIndexSignatureDeclaration(fullStart, decorators, modifiers) { - var node = createNode(149 /* IndexSignature */, fullStart); - node.decorators = decorators; - setModifiers(node, modifiers); - node.parameters = parseBracketedList(16 /* Parameters */, parseParameter, 19 /* OpenBracketToken */, 20 /* CloseBracketToken */); - node.type = parseTypeAnnotation(); - parseTypeMemberSemicolon(); - return finishNode(node); - } - function parsePropertyOrMethodSignature() { - var fullStart = scanner.getStartPos(); - var name = parsePropertyName(); - var questionToken = parseOptionalToken(53 /* QuestionToken */); - if (token === 17 /* OpenParenToken */ || token === 25 /* LessThanToken */) { - var method = createNode(142 /* MethodSignature */, fullStart); - method.name = name; - method.questionToken = questionToken; - // Method signatues don't exist in expression contexts. So they have neither - // [Yield] nor [Await] - fillSignature(54 /* ColonToken */, /*yieldContext*/ false, /*awaitContext*/ false, /*requireCompleteParameterList*/ false, method); - parseTypeMemberSemicolon(); - return finishNode(method); - } - else { - var property = createNode(140 /* PropertySignature */, fullStart); - property.name = name; - property.questionToken = questionToken; - property.type = parseTypeAnnotation(); - parseTypeMemberSemicolon(); - return finishNode(property); - } - } - function isStartOfTypeMember() { - switch (token) { - case 17 /* OpenParenToken */: - case 25 /* LessThanToken */: - case 19 /* OpenBracketToken */: - return true; - default: - if (ts.isModifier(token)) { - var result = lookAhead(isStartOfIndexSignatureDeclaration); - if (result) { - return result; - } - } - return isLiteralPropertyName() && lookAhead(isTypeMemberWithLiteralPropertyName); - } - } - function isStartOfIndexSignatureDeclaration() { - while (ts.isModifier(token)) { - nextToken(); - } - return isIndexSignature(); - } - function isTypeMemberWithLiteralPropertyName() { - nextToken(); - return token === 17 /* OpenParenToken */ || - token === 25 /* LessThanToken */ || - token === 53 /* QuestionToken */ || - token === 54 /* ColonToken */ || - canParseSemicolon(); - } - function parseTypeMember() { - switch (token) { - case 17 /* OpenParenToken */: - case 25 /* LessThanToken */: - return parseSignatureMember(147 /* CallSignature */); - case 19 /* OpenBracketToken */: - // Indexer or computed property - return isIndexSignature() - ? parseIndexSignatureDeclaration(scanner.getStartPos(), /*decorators*/ undefined, /*modifiers*/ undefined) - : parsePropertyOrMethodSignature(); - case 92 /* NewKeyword */: - if (lookAhead(isStartOfConstructSignature)) { - return parseSignatureMember(148 /* ConstructSignature */); - } - // fall through. - case 9 /* StringLiteral */: - case 8 /* NumericLiteral */: - return parsePropertyOrMethodSignature(); - default: - // Index declaration as allowed as a type member. But as per the grammar, - // they also allow modifiers. So we have to check for an index declaration - // that might be following modifiers. This ensures that things work properly - // when incrementally parsing as the parser will produce the Index declaration - // if it has the same text regardless of whether it is inside a class or an - // object type. - if (ts.isModifier(token)) { - var result = tryParse(parseIndexSignatureWithModifiers); - if (result) { - return result; - } - } - if (ts.tokenIsIdentifierOrKeyword(token)) { - return parsePropertyOrMethodSignature(); - } - } - } - function parseIndexSignatureWithModifiers() { - var fullStart = scanner.getStartPos(); - var decorators = parseDecorators(); - var modifiers = parseModifiers(); - return isIndexSignature() - ? parseIndexSignatureDeclaration(fullStart, decorators, modifiers) - : undefined; - } - function isStartOfConstructSignature() { - nextToken(); - return token === 17 /* OpenParenToken */ || token === 25 /* LessThanToken */; - } - function parseTypeLiteral() { - var node = createNode(155 /* TypeLiteral */); - node.members = parseObjectTypeMembers(); - return finishNode(node); - } - function parseObjectTypeMembers() { - var members; - if (parseExpected(15 /* OpenBraceToken */)) { - members = parseList(4 /* TypeMembers */, parseTypeMember); - parseExpected(16 /* CloseBraceToken */); - } - else { - members = createMissingList(); - } - return members; - } - function parseTupleType() { - var node = createNode(157 /* TupleType */); - node.elementTypes = parseBracketedList(19 /* TupleElementTypes */, parseType, 19 /* OpenBracketToken */, 20 /* CloseBracketToken */); - return finishNode(node); - } - function parseParenthesizedType() { - var node = createNode(160 /* ParenthesizedType */); - parseExpected(17 /* OpenParenToken */); - node.type = parseType(); - parseExpected(18 /* CloseParenToken */); - return finishNode(node); - } - function parseFunctionOrConstructorType(kind) { - var node = createNode(kind); - if (kind === 153 /* ConstructorType */) { - parseExpected(92 /* NewKeyword */); - } - fillSignature(34 /* EqualsGreaterThanToken */, /*yieldContext*/ false, /*awaitContext*/ false, /*requireCompleteParameterList*/ false, node); - return finishNode(node); - } - function parseKeywordAndNoDot() { - var node = parseTokenNode(); - return token === 21 /* DotToken */ ? undefined : node; - } - function parseNonArrayType() { - switch (token) { - case 117 /* AnyKeyword */: - case 130 /* StringKeyword */: - case 128 /* NumberKeyword */: - case 120 /* BooleanKeyword */: - case 131 /* SymbolKeyword */: - // If these are followed by a dot, then parse these out as a dotted type reference instead. - var node = tryParse(parseKeywordAndNoDot); - return node || parseTypeReferenceOrTypePredicate(); - case 103 /* VoidKeyword */: - case 97 /* ThisKeyword */: - return parseTokenNode(); - case 101 /* TypeOfKeyword */: - return parseTypeQuery(); - case 15 /* OpenBraceToken */: - return parseTypeLiteral(); - case 19 /* OpenBracketToken */: - return parseTupleType(); - case 17 /* OpenParenToken */: - return parseParenthesizedType(); - default: - return parseTypeReferenceOrTypePredicate(); - } - } - function isStartOfType() { - switch (token) { - case 117 /* AnyKeyword */: - case 130 /* StringKeyword */: - case 128 /* NumberKeyword */: - case 120 /* BooleanKeyword */: - case 131 /* SymbolKeyword */: - case 103 /* VoidKeyword */: - case 97 /* ThisKeyword */: - case 101 /* TypeOfKeyword */: - case 15 /* OpenBraceToken */: - case 19 /* OpenBracketToken */: - case 25 /* LessThanToken */: - case 92 /* NewKeyword */: - return true; - case 17 /* 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); - default: - return isIdentifier(); - } - } - function isStartOfParenthesizedOrFunctionType() { - nextToken(); - return token === 18 /* CloseParenToken */ || isStartOfParameter() || isStartOfType(); - } - function parseArrayTypeOrHigher() { - var type = parseNonArrayType(); - while (!scanner.hasPrecedingLineBreak() && parseOptional(19 /* OpenBracketToken */)) { - parseExpected(20 /* CloseBracketToken */); - var node = createNode(156 /* ArrayType */, type.pos); - node.elementType = type; - type = finishNode(node); - } - return type; - } - function parseUnionOrIntersectionType(kind, parseConstituentType, operator) { - var type = parseConstituentType(); - if (token === operator) { - var types = [type]; - types.pos = type.pos; - while (parseOptional(operator)) { - types.push(parseConstituentType()); - } - types.end = getNodeEnd(); - var node = createNode(kind, type.pos); - node.types = types; - type = finishNode(node); - } - return type; - } - function parseIntersectionTypeOrHigher() { - return parseUnionOrIntersectionType(159 /* IntersectionType */, parseArrayTypeOrHigher, 46 /* AmpersandToken */); - } - function parseUnionTypeOrHigher() { - return parseUnionOrIntersectionType(158 /* UnionType */, parseIntersectionTypeOrHigher, 47 /* BarToken */); - } - function isStartOfFunctionType() { - if (token === 25 /* LessThanToken */) { - return true; - } - return token === 17 /* OpenParenToken */ && lookAhead(isUnambiguouslyStartOfFunctionType); - } - function isUnambiguouslyStartOfFunctionType() { - nextToken(); - if (token === 18 /* CloseParenToken */ || token === 22 /* DotDotDotToken */) { - // ( ) - // ( ... - return true; - } - if (isIdentifier() || ts.isModifier(token)) { - nextToken(); - if (token === 54 /* ColonToken */ || token === 24 /* CommaToken */ || - token === 53 /* QuestionToken */ || token === 56 /* EqualsToken */ || - isIdentifier() || ts.isModifier(token)) { - // ( id : - // ( id , - // ( id ? - // ( id = - // ( modifier id - return true; - } - if (token === 18 /* CloseParenToken */) { - nextToken(); - if (token === 34 /* EqualsGreaterThanToken */) { - // ( id ) => - return true; - } - } - } - return false; - } - function parseType() { - // The rules about 'yield' only apply to actual code/expression contexts. They don't - // apply to 'type' contexts. So we disable these parameters here before moving on. - return doOutsideOfContext(10 /* TypeExcludesFlags */, parseTypeWorker); - } - function parseTypeWorker() { - if (isStartOfFunctionType()) { - return parseFunctionOrConstructorType(152 /* FunctionType */); - } - if (token === 92 /* NewKeyword */) { - return parseFunctionOrConstructorType(153 /* ConstructorType */); - } - return parseUnionTypeOrHigher(); - } - function parseTypeAnnotation() { - return parseOptional(54 /* ColonToken */) ? parseType() : undefined; - } - // EXPRESSIONS - function isStartOfLeftHandSideExpression() { - switch (token) { - case 97 /* ThisKeyword */: - case 95 /* SuperKeyword */: - case 93 /* NullKeyword */: - case 99 /* TrueKeyword */: - case 84 /* 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 */: - return true; - default: - return isIdentifier(); - } - } - function isStartOfExpression() { - if (isStartOfLeftHandSideExpression()) { - 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 */: - // 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. - return true; - default: - // Error tolerance. If we see the start of some binary operator, we consider - // that the start of an expression. That way we'll parse out a missing identifier, - // give a good message about an identifier being missing, and then consume the - // rest of the binary expression. - if (isBinaryOperator()) { - return true; - } - return isIdentifier(); - } - } - 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 */ && - isStartOfExpression(); - } - function allowInAndParseExpression() { - return allowInAnd(parseExpression); - } - function parseExpression() { - // Expression[in]: - // AssignmentExpression[in] - // Expression[in] , AssignmentExpression[in] - // clear the decorator context when parsing Expression, as it should be unambiguous when parsing a decorator - var saveDecoratorContext = inDecoratorContext(); - if (saveDecoratorContext) { - setDecoratorContext(false); - } - var expr = parseAssignmentExpressionOrHigher(); - var operatorToken; - while ((operatorToken = parseOptionalToken(24 /* CommaToken */))) { - expr = makeBinaryExpression(expr, operatorToken, parseAssignmentExpressionOrHigher()); - } - if (saveDecoratorContext) { - setDecoratorContext(true); - } - return expr; - } - function parseInitializer(inParameter) { - if (token !== 56 /* EqualsToken */) { - // It's not uncommon during typing for the user to miss writing the '=' token. Check if - // there is no newline after the last token and if we're on an expression. If so, parse - // this as an equals-value clause with a missing equals. - // NOTE: There are two places where we allow equals-value clauses. The first is in a - // variable declarator. The second is with a parameter. For variable declarators - // 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()) { - // 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; - } - } - // Initializer[In, Yield] : - // = AssignmentExpression[?In, ?Yield] - parseExpected(56 /* EqualsToken */); - return parseAssignmentExpressionOrHigher(); - } - function parseAssignmentExpressionOrHigher() { - // AssignmentExpression[in,yield]: - // 1) ConditionalExpression[?in,?yield] - // 2) LeftHandSideExpression = AssignmentExpression[?in,?yield] - // 3) LeftHandSideExpression AssignmentOperator AssignmentExpression[?in,?yield] - // 4) ArrowFunctionExpression[?in,?yield] - // 5) [+Yield] YieldExpression[?In] - // - // Note: for ease of implementation we treat productions '2' and '3' as the same thing. - // (i.e. they're both BinaryExpressions with an assignment operator in it). - // First, do the simple check if we have a YieldExpression (production '5'). - if (isYieldExpression()) { - return parseYieldExpression(); - } - // Then, check if we have an arrow function (production '4') that starts with a parenthesized - // parameter list. If we do, we must *not* recurse for productions 1, 2 or 3. An ArrowFunction is - // not a LeftHandSideExpression, nor does it start a ConditionalExpression. So we are done - // with AssignmentExpression if we see one. - var arrowExpression = tryParseParenthesizedArrowFunctionExpression(); - if (arrowExpression) { - return arrowExpression; - } - // Now try to see if we're in production '1', '2' or '3'. A conditional expression can - // start with a LogicalOrExpression, while the assignment productions can only start with - // LeftHandSideExpressions. - // - // So, first, we try to just parse out a BinaryExpression. If we get something that is a - // LeftHandSide or higher, then we can try to parse out the assignment expression part. - // Otherwise, we try to parse out the conditional expression bit. We want to allow any - // binary expression here, so we pass in the 'lowest' precedence here so that it matches - // and consumes anything. - var expr = parseBinaryExpressionOrHigher(/*precedence*/ 0); - // 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 */) { - return parseSimpleArrowFunctionExpression(expr); - } - // Now see if we might be in cases '2' or '3'. - // If the expression was a LHS expression, and we have an assignment operator, then - // we're in '2' or '3'. Consume the assignment and return. - // - // Note: we call reScanGreaterToken so that we get an appropriately merged token - // for cases like > > = becoming >>= - if (ts.isLeftHandSideExpression(expr) && ts.isAssignmentOperator(reScanGreaterToken())) { - return makeBinaryExpression(expr, parseTokenNode(), parseAssignmentExpressionOrHigher()); - } - // It wasn't an assignment or a lambda. This is a conditional expression: - return parseConditionalExpressionRest(expr); - } - function isYieldExpression() { - if (token === 114 /* YieldKeyword */) { - // If we have a 'yield' keyword, and htis is a context where yield expressions are - // allowed, then definitely parse out a yield expression. - if (inYieldContext()) { - return true; - } - // We're in a context where 'yield expr' is not allowed. However, if we can - // definitely tell that the user was trying to parse a 'yield expr' and not - // just a normal expr that start with a 'yield' identifier, then parse out - // a 'yield expr'. We can then report an error later that they are only - // allowed in generator expressions. - // - // for example, if we see 'yield(foo)', then we'll have to treat that as an - // invocation expression of something called 'yield'. However, if we have - // 'yield foo' then that is not legal as a normal expression, so we can - // definitely recognize this as a yield expression. - // - // for now we just check if the next token is an identifier. More heuristics - // can be added here later as necessary. We just need to make sure that we - // don't accidently consume something legal. - return lookAhead(nextTokenIsIdentifierOrKeywordOrNumberOnSameLine); - } - return false; - } - function nextTokenIsIdentifierOnSameLine() { - nextToken(); - return !scanner.hasPrecedingLineBreak() && isIdentifier(); - } - function parseYieldExpression() { - var node = createNode(184 /* 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 */); - node.expression = parseAssignmentExpressionOrHigher(); - return finishNode(node); - } - else { - // if the next token is not on the same line as yield. or we don't have an '*' or - // the start of an expressin, then this is just a simple "yield" expression. - return finishNode(node); - } - } - function parseSimpleArrowFunctionExpression(identifier) { - ts.Debug.assert(token === 34 /* EqualsGreaterThanToken */, "parseSimpleArrowFunctionExpression should only have been called if we had a =>"); - var node = createNode(174 /* ArrowFunction */, identifier.pos); - var parameter = createNode(138 /* Parameter */, identifier.pos); - parameter.name = identifier; - finishNode(parameter); - node.parameters = [parameter]; - node.parameters.pos = parameter.pos; - node.parameters.end = parameter.end; - node.equalsGreaterThanToken = parseExpectedToken(34 /* EqualsGreaterThanToken */, false, ts.Diagnostics._0_expected, "=>"); - node.body = parseArrowFunctionExpressionBody(/*isAsync*/ false); - return finishNode(node); - } - function tryParseParenthesizedArrowFunctionExpression() { - var triState = isParenthesizedArrowFunctionExpression(); - if (triState === 0 /* False */) { - // It's definitely not a parenthesized arrow function expression. - return undefined; - } - // If we definitely have an arrow function, then we can just parse one, not requiring a - // following => or { token. Otherwise, we *might* have an arrow function. Try to parse - // it out, but don't allow any ambiguity, and return 'undefined' if this could be an - // expression instead. - var arrowFunction = triState === 1 /* True */ - ? parseParenthesizedArrowFunctionExpressionHead(/*allowAmbiguity*/ true) - : tryParse(parsePossibleParenthesizedArrowFunctionExpressionHead); - if (!arrowFunction) { - // Didn't appear to actually be a parenthesized arrow function. Just bail out. - return undefined; - } - var isAsync = !!(arrowFunction.flags & 512 /* Async */); - // 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 */) - ? parseArrowFunctionExpressionBody(isAsync) - : parseIdentifier(); - return finishNode(arrowFunction); - } - // True -> We definitely expect a parenthesized arrow function here. - // False -> There *cannot* be a parenthesized arrow function here. - // 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 */) { - return lookAhead(isParenthesizedArrowFunctionExpressionWorker); - } - if (token === 34 /* 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. - return 1 /* True */; - } - // Definitely not a parenthesized arrow function. - return 0 /* False */; - } - function isParenthesizedArrowFunctionExpressionWorker() { - if (token === 118 /* AsyncKeyword */) { - nextToken(); - if (scanner.hasPrecedingLineBreak()) { - return 0 /* False */; - } - if (token !== 17 /* OpenParenToken */ && token !== 25 /* LessThanToken */) { - return 0 /* False */; - } - } - var first = token; - var second = nextToken(); - if (first === 17 /* OpenParenToken */) { - if (second === 18 /* 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 */: - return 1 /* True */; - default: - return 0 /* False */; - } - } - // If encounter "([" or "({", this could be the start of a binding pattern. - // Examples: - // ([ x ]) => { } - // ({ x }) => { } - // ([ x ]) - // ({ x }) - if (second === 19 /* OpenBracketToken */ || second === 15 /* OpenBraceToken */) { - return 2 /* Unknown */; - } - // Simple case: "(..." - // This is an arrow function with a rest parameter. - if (second === 22 /* DotDotDotToken */) { - return 1 /* True */; - } - // If we had "(" followed by something that's not an identifier, - // then this definitely doesn't look like a lambda. - // Note: we could be a little more lenient and allow - // "(public" or "(private". These would not ever actually be allowed, - // but we could provide a good error message instead of bailing out. - if (!isIdentifier()) { - return 0 /* False */; - } - // If we have something like "(a:", then we must have a - // type-annotated parameter in an arrow function expression. - if (nextToken() === 54 /* ColonToken */) { - return 1 /* True */; - } - // This *could* be a parenthesized arrow function. - // Return Unknown to let the caller know. - return 2 /* Unknown */; - } - else { - ts.Debug.assert(first === 25 /* LessThanToken */); - // If we have "<" not followed by an identifier, - // then this definitely is not an arrow function. - if (!isIdentifier()) { - return 0 /* False */; - } - // JSX overrides - if (sourceFile.languageVariant === 1 /* JSX */) { - var isArrowFunctionInJsx = lookAhead(function () { - var third = nextToken(); - if (third === 83 /* ExtendsKeyword */) { - var fourth = nextToken(); - switch (fourth) { - case 56 /* EqualsToken */: - case 27 /* GreaterThanToken */: - return false; - default: - return true; - } - } - else if (third === 24 /* CommaToken */) { - return true; - } - return false; - }); - if (isArrowFunctionInJsx) { - return 1 /* True */; - } - return 0 /* False */; - } - // This *could* be a parenthesized arrow function. - return 2 /* Unknown */; - } - } - function parsePossibleParenthesizedArrowFunctionExpressionHead() { - return parseParenthesizedArrowFunctionExpressionHead(/*allowAmbiguity*/ false); - } - function parseParenthesizedArrowFunctionExpressionHead(allowAmbiguity) { - var node = createNode(174 /* ArrowFunction */); - setModifiers(node, parseModifiersForArrowFunction()); - var isAsync = !!(node.flags & 512 /* Async */); - // Arrow functions are never generators. - // - // If we're speculatively parsing a signature for a parenthesized arrow function, then - // we have to have a complete parameter list. Otherwise we might see something like - // 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); - // If we couldn't get parameters, we definitely could not parse out an arrow function. - if (!node.parameters) { - return undefined; - } - // Parsing a signature isn't enough. - // Parenthesized arrow signatures often look like other valid expressions. - // For instance: - // - "(x = 10)" is an assignment expression parsed as a signature with a default parameter value. - // - "(x,y)" is a comma expression parsed as a signature with two parameters. - // - "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 */) { - // 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 */) { - return parseFunctionBlock(/*allowYield*/ false, /*allowAwait*/ isAsync, /*ignoreMissingOpenBrace*/ false); - } - if (token !== 23 /* SemicolonToken */ && - token !== 87 /* FunctionKeyword */ && - token !== 73 /* ClassKeyword */ && - isStartOfStatement() && - !isStartOfExpressionStatement()) { - // Check if we got a plain statement (i.e. no expression-statements, no function/class expressions/declarations) - // - // Here we try to recover from a potential error situation in the case where the - // user meant to supply a block. For example, if the user wrote: - // - // a => - // let v = 0; - // } - // - // they may be missing an open brace. Check to see if that's the case so we can - // try to recover better. If we don't do this, then the next close curly we see may end - // up preemptively closing the containing construct. - // - // Note: even when 'ignoreMissingOpenBrace' is passed as true, parseBody will still error. - return parseFunctionBlock(/*allowYield*/ false, /*allowAwait*/ isAsync, /*ignoreMissingOpenBrace*/ true); - } - return isAsync - ? doInAwaitContext(parseAssignmentExpressionOrHigher) - : doOutsideOfAwaitContext(parseAssignmentExpressionOrHigher); - } - function parseConditionalExpressionRest(leftOperand) { - // Note: we are passed in an expression which was produced from parseBinaryExpressionOrHigher. - var questionToken = parseOptionalToken(53 /* QuestionToken */); - if (!questionToken) { - return leftOperand; - } - // Note: we explicitly 'allowIn' in the whenTrue part of the condition expression, and - // we do not that for the 'whenFalse' part. - var node = createNode(182 /* 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.whenFalse = parseAssignmentExpressionOrHigher(); - return finishNode(node); - } - function parseBinaryExpressionOrHigher(precedence) { - var leftOperand = parseUnaryExpressionOrHigher(); - return parseBinaryExpressionRest(precedence, leftOperand); - } - function isInOrOfKeyword(t) { - return t === 90 /* InKeyword */ || t === 134 /* OfKeyword */; - } - function parseBinaryExpressionRest(precedence, leftOperand) { - while (true) { - // We either have a binary operator here, or we're finished. We call - // reScanGreaterToken so that we merge token sequences like > and = into >= - reScanGreaterToken(); - var newPrecedence = getBinaryOperatorPrecedence(); - // Check the precedence to see if we should "take" this operator - // - For left associative operator (all operator but **), consume the operator, - // recursively call the function below, and parse binaryExpression as a rightOperand - // of the caller if the new precendence of the operator is greater then or equal to the current precendence. - // For example: - // a - b - c; - // ^token; leftOperand = b. Return b to the caller as a rightOperand - // a * b - c - // ^token; leftOperand = b. Return b to the caller as a rightOperand - // a - b * c; - // ^token; leftOperand = b. Return b * c to the caller as a rightOperand - // - For right associative operator (**), consume the operator, recursively call the function - // and parse binaryExpression as a rightOperand of the caller if the new precendence of - // the operator is strictly grater than the current precendence - // For example: - // a ** b ** c; - // ^^token; leftOperand = b. Return b ** c to the caller as a rightOperand - // a - b ** c; - // ^^token; leftOperand = b. Return b ** c to the caller as a rightOperand - // a ** b - c - // ^token; leftOperand = b. Return b to the caller as a rightOperand - var consumeCurrentOperator = token === 38 /* AsteriskAsteriskToken */ ? - newPrecedence >= precedence : - newPrecedence > precedence; - if (!consumeCurrentOperator) { - break; - } - if (token === 90 /* InKeyword */ && inDisallowInContext()) { - break; - } - if (token === 116 /* AsKeyword */) { - // Make sure we *do* perform ASI for constructs like this: - // var x = foo - // as (Bar) - // This should be parsed as an initialized variable, followed - // by a function call to 'as' with the argument 'Bar' - if (scanner.hasPrecedingLineBreak()) { - break; - } - else { - nextToken(); - leftOperand = makeAsExpression(leftOperand, parseType()); - } - } - else { - leftOperand = makeBinaryExpression(leftOperand, parseTokenNode(), parseBinaryExpressionOrHigher(newPrecedence)); - } - } - return leftOperand; - } - function isBinaryOperator() { - if (inDisallowInContext() && token === 90 /* InKeyword */) { - return false; - } - return getBinaryOperatorPrecedence() > 0; - } - function getBinaryOperatorPrecedence() { - switch (token) { - case 52 /* BarBarToken */: - return 1; - case 51 /* AmpersandAmpersandToken */: - return 2; - case 47 /* BarToken */: - return 3; - case 48 /* CaretToken */: - return 4; - case 46 /* AmpersandToken */: - return 5; - case 30 /* EqualsEqualsToken */: - case 31 /* ExclamationEqualsToken */: - case 32 /* EqualsEqualsEqualsToken */: - case 33 /* ExclamationEqualsEqualsToken */: - return 6; - case 25 /* LessThanToken */: - case 27 /* GreaterThanToken */: - case 28 /* LessThanEqualsToken */: - case 29 /* GreaterThanEqualsToken */: - case 91 /* InstanceOfKeyword */: - case 90 /* InKeyword */: - case 116 /* AsKeyword */: - return 7; - case 43 /* LessThanLessThanToken */: - case 44 /* GreaterThanGreaterThanToken */: - case 45 /* GreaterThanGreaterThanGreaterThanToken */: - return 8; - case 35 /* PlusToken */: - case 36 /* MinusToken */: - return 9; - case 37 /* AsteriskToken */: - case 39 /* SlashToken */: - case 40 /* PercentToken */: - return 10; - case 38 /* AsteriskAsteriskToken */: - return 11; - } - // -1 is lower than all other precedences. Returning it will cause binary expression - // parsing to stop. - return -1; - } - function makeBinaryExpression(left, operatorToken, right) { - var node = createNode(181 /* BinaryExpression */, left.pos); - node.left = left; - node.operatorToken = operatorToken; - node.right = right; - return finishNode(node); - } - function makeAsExpression(left, right) { - var node = createNode(189 /* AsExpression */, left.pos); - node.expression = left; - node.type = right; - return finishNode(node); - } - function parsePrefixUnaryExpression() { - var node = createNode(179 /* PrefixUnaryExpression */); - node.operator = token; - nextToken(); - node.operand = parseSimpleUnaryExpression(); - return finishNode(node); - } - function parseDeleteExpression() { - var node = createNode(175 /* DeleteExpression */); - nextToken(); - node.expression = parseSimpleUnaryExpression(); - return finishNode(node); - } - function parseTypeOfExpression() { - var node = createNode(176 /* TypeOfExpression */); - nextToken(); - node.expression = parseSimpleUnaryExpression(); - return finishNode(node); - } - function parseVoidExpression() { - var node = createNode(177 /* VoidExpression */); - nextToken(); - node.expression = parseSimpleUnaryExpression(); - return finishNode(node); - } - function isAwaitExpression() { - if (token === 119 /* AwaitKeyword */) { - if (inAwaitContext()) { - return true; - } - // here we are using similar heuristics as 'isYieldExpression' - return lookAhead(nextTokenIsIdentifierOnSameLine); - } - return false; - } - function parseAwaitExpression() { - var node = createNode(178 /* AwaitExpression */); - nextToken(); - node.expression = parseSimpleUnaryExpression(); - return finishNode(node); - } - /** - * Parse ES7 unary expression and await expression - * - * ES7 UnaryExpression: - * 1) SimpleUnaryExpression[?yield] - * 2) IncrementExpression[?yield] ** UnaryExpression[?yield] - */ - function parseUnaryExpressionOrHigher() { - if (isAwaitExpression()) { - return parseAwaitExpression(); - } - if (isIncrementExpression()) { - var incrementExpression = parseIncrementExpression(); - return token === 38 /* AsteriskAsteriskToken */ ? - parseBinaryExpressionRest(getBinaryOperatorPrecedence(), incrementExpression) : - incrementExpression; - } - var unaryOperator = token; - var simpleUnaryExpression = parseSimpleUnaryExpression(); - if (token === 38 /* AsteriskAsteriskToken */) { - var diagnostic; - var start = ts.skipTrivia(sourceText, simpleUnaryExpression.pos); - if (simpleUnaryExpression.kind === 171 /* TypeAssertionExpression */) { - parseErrorAtPosition(start, simpleUnaryExpression.end - start, ts.Diagnostics.A_type_assertion_expression_is_not_allowed_in_the_left_hand_side_of_an_exponentiation_expression_Consider_enclosing_the_expression_in_parentheses); - } - else { - parseErrorAtPosition(start, simpleUnaryExpression.end - start, ts.Diagnostics.An_unary_expression_with_the_0_operator_is_not_allowed_in_the_left_hand_side_of_an_exponentiation_expression_Consider_enclosing_the_expression_in_parentheses, ts.tokenToString(unaryOperator)); - } - } - return simpleUnaryExpression; - } - /** - * Parse ES7 simple-unary expression or higher: - * - * ES7 SimpleUnaryExpression: - * 1) IncrementExpression[?yield] - * 2) delete UnaryExpression[?yield] - * 3) void UnaryExpression[?yield] - * 4) typeof UnaryExpression[?yield] - * 5) + UnaryExpression[?yield] - * 6) - UnaryExpression[?yield] - * 7) ~ UnaryExpression[?yield] - * 8) ! UnaryExpression[?yield] - */ - function parseSimpleUnaryExpression() { - switch (token) { - case 35 /* PlusToken */: - case 36 /* MinusToken */: - case 50 /* TildeToken */: - case 49 /* ExclamationToken */: - return parsePrefixUnaryExpression(); - case 78 /* DeleteKeyword */: - return parseDeleteExpression(); - case 101 /* TypeOfKeyword */: - return parseTypeOfExpression(); - case 103 /* VoidKeyword */: - return parseVoidExpression(); - case 25 /* LessThanToken */: - // This is modified UnaryExpression grammar in TypeScript - // UnaryExpression (modified): - // < type > UnaryExpression - return parseTypeAssertion(); - default: - return parseIncrementExpression(); - } - } - /** - * Check if the current token can possibly be an ES7 increment expression. - * - * ES7 IncrementExpression: - * LeftHandSideExpression[?Yield] - * LeftHandSideExpression[?Yield][no LineTerminator here]++ - * LeftHandSideExpression[?Yield][no LineTerminator here]-- - * ++LeftHandSideExpression[?Yield] - * --LeftHandSideExpression[?Yield] - */ - function isIncrementExpression() { - // This function is called inside parseUnaryExpression to decide - // whether to call parseSimpleUnaryExpression or call parseIncrmentExpression directly - switch (token) { - case 35 /* PlusToken */: - case 36 /* MinusToken */: - case 50 /* TildeToken */: - case 49 /* ExclamationToken */: - case 78 /* DeleteKeyword */: - case 101 /* TypeOfKeyword */: - case 103 /* VoidKeyword */: - return false; - case 25 /* LessThanToken */: - // If we are not in JSX context, we are parsing TypeAssertion which is an UnaryExpression - if (sourceFile.languageVariant !== 1 /* JSX */) { - return false; - } - // We are in JSX context and the token is part of JSXElement. - // Fall through - default: - return true; - } - } - /** - * Parse ES7 IncrementExpression. IncrementExpression is used instead of ES6's PostFixExpression. - * - * ES7 IncrementExpression[yield]: - * 1) LeftHandSideExpression[?yield] - * 2) LeftHandSideExpression[?yield] [[no LineTerminator here]]++ - * 3) LeftHandSideExpression[?yield] [[no LineTerminator here]]-- - * 4) ++LeftHandSideExpression[?yield] - * 5) --LeftHandSideExpression[?yield] - * In TypeScript (2), (3) are parsed as PostfixUnaryExpression. (4), (5) are parsed as PrefixUnaryExpression - */ - function parseIncrementExpression() { - if (token === 41 /* PlusPlusToken */ || token === 42 /* MinusMinusToken */) { - var node = createNode(179 /* PrefixUnaryExpression */); - node.operator = token; - nextToken(); - node.operand = parseLeftHandSideExpressionOrHigher(); - return finishNode(node); - } - else if (sourceFile.languageVariant === 1 /* JSX */ && token === 25 /* LessThanToken */ && lookAhead(nextTokenIsIdentifierOrKeyword)) { - // JSXElement is part of primaryExpression - return parseJsxElementOrSelfClosingElement(/*inExpressionContext*/ true); - } - var expression = parseLeftHandSideExpressionOrHigher(); - ts.Debug.assert(ts.isLeftHandSideExpression(expression)); - if ((token === 41 /* PlusPlusToken */ || token === 42 /* MinusMinusToken */) && !scanner.hasPrecedingLineBreak()) { - var node = createNode(180 /* PostfixUnaryExpression */, expression.pos); - node.operand = expression; - node.operator = token; - nextToken(); - return finishNode(node); - } - return expression; - } - function parseLeftHandSideExpressionOrHigher() { - // Original Ecma: - // LeftHandSideExpression: See 11.2 - // NewExpression - // CallExpression - // - // Our simplification: - // - // LeftHandSideExpression: See 11.2 - // MemberExpression - // CallExpression - // - // See comment in parseMemberExpressionOrHigher on how we replaced NewExpression with - // MemberExpression to make our lives easier. - // - // to best understand the below code, it's important to see how CallExpression expands - // out into its own productions: - // - // CallExpression: - // MemberExpression Arguments - // CallExpression Arguments - // CallExpression[Expression] - // CallExpression.IdentifierName - // super ( ArgumentListopt ) - // super.IdentifierName - // - // Because of the recursion in these calls, we need to bottom out first. There are two - // bottom out states we can run into. Either we see 'super' which must start either of - // 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 */ - ? parseSuperExpression() - : parseMemberExpressionOrHigher(); - // Now, we *may* be complete. However, we might have consumed the start of a - // CallExpression. As such, we need to consume the rest of it here to be complete. - return parseCallExpressionRest(expression); - } - function parseMemberExpressionOrHigher() { - // Note: to make our lives simpler, we decompose the the NewExpression productions and - // place ObjectCreationExpression and FunctionExpression into PrimaryExpression. - // like so: - // - // PrimaryExpression : See 11.1 - // this - // Identifier - // Literal - // ArrayLiteral - // ObjectLiteral - // (Expression) - // FunctionExpression - // new MemberExpression Arguments? - // - // MemberExpression : See 11.2 - // PrimaryExpression - // MemberExpression[Expression] - // MemberExpression.IdentifierName - // - // CallExpression : See 11.2 - // MemberExpression - // CallExpression Arguments - // CallExpression[Expression] - // CallExpression.IdentifierName - // - // Technically this is ambiguous. i.e. CallExpression defines: - // - // CallExpression: - // CallExpression Arguments - // - // If you see: "new Foo()" - // - // Then that could be treated as a single ObjectCreationExpression, or it could be - // treated as the invocation of "new Foo". We disambiguate that in code (to match - // the original grammar) by making sure that if we see an ObjectCreationExpression - // we always consume arguments if they are there. So we treat "new Foo()" as an - // object creation only, and not at all as an invocation) Another way to think - // about this is that for every "new" that we see, we will consume an argument list if - // it is there as part of the *associated* object creation node. Any additional - // argument lists we see, will become invocation expressions. - // - // Because there are no other places in the grammar now that refer to FunctionExpression - // or ObjectCreationExpression, it is safe to push down into the PrimaryExpression - // production. - // - // Because CallExpression and MemberExpression are left recursive, we need to bottom out - // of the recursion immediately. So we parse out a primary expression to start with. - var expression = parsePrimaryExpression(); - return parseMemberExpressionRest(expression); - } - function parseSuperExpression() { - var expression = parseTokenNode(); - if (token === 17 /* OpenParenToken */ || token === 21 /* DotToken */ || token === 19 /* 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(166 /* PropertyAccessExpression */, expression.pos); - node.expression = expression; - node.dotToken = parseExpectedToken(21 /* DotToken */, /*reportAtCurrentPosition*/ false, ts.Diagnostics.super_must_be_followed_by_an_argument_list_or_member_access); - node.name = parseRightSideOfDot(/*allowIdentifierNames*/ true); - return finishNode(node); - } - function parseJsxElementOrSelfClosingElement(inExpressionContext) { - var opening = parseJsxOpeningOrSelfClosingElement(inExpressionContext); - var result; - if (opening.kind === 235 /* JsxOpeningElement */) { - var node = createNode(233 /* JsxElement */, opening.pos); - node.openingElement = opening; - node.children = parseJsxChildren(node.openingElement.tagName); - node.closingElement = parseJsxClosingElement(inExpressionContext); - result = finishNode(node); - } - else { - ts.Debug.assert(opening.kind === 234 /* JsxSelfClosingElement */); - // Nothing else to do for self-closing elements - result = opening; - } - // If the user writes the invalid code '
' in an expression context (i.e. not wrapped in - // an enclosing tag), we'll naively try to parse ^ this as a 'less than' operator and the remainder of the tag - // as garbage, which will cause the formatter to badly mangle the JSX. Perform a speculative parse of a JSX - // element if we see a < token so that we can wrap it in a synthetic binary expression so the formatter - // 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 */) { - var invalidElement = tryParse(function () { return parseJsxElementOrSelfClosingElement(/*inExpressionContext*/ true); }); - if (invalidElement) { - parseErrorAtCurrentToken(ts.Diagnostics.JSX_expressions_must_have_one_parent_element); - var badNode = createNode(181 /* BinaryExpression */, result.pos); - badNode.end = invalidElement.end; - badNode.left = result; - badNode.right = invalidElement; - badNode.operatorToken = createMissingNode(24 /* CommaToken */, /*reportAtCurrentPosition*/ false, /*diagnosticMessage*/ undefined); - badNode.operatorToken.pos = badNode.operatorToken.end = badNode.right.pos; - return badNode; - } - } - return result; - } - function parseJsxText() { - var node = createNode(236 /* JsxText */, scanner.getStartPos()); - token = scanner.scanJsxToken(); - return finishNode(node); - } - function parseJsxChild() { - switch (token) { - case 236 /* JsxText */: - return parseJsxText(); - case 15 /* OpenBraceToken */: - return parseJsxExpression(/*inExpressionContext*/ false); - case 25 /* LessThanToken */: - return parseJsxElementOrSelfClosingElement(/*inExpressionContext*/ false); - } - ts.Debug.fail("Unknown JSX child kind " + token); - } - function parseJsxChildren(openingTagName) { - var result = []; - result.pos = scanner.getStartPos(); - var saveParsingContext = parsingContext; - parsingContext |= 1 << 14 /* JsxChildren */; - while (true) { - token = scanner.reScanJsxToken(); - if (token === 26 /* LessThanSlashToken */) { - break; - } - else if (token === 1 /* EndOfFileToken */) { - parseErrorAtCurrentToken(ts.Diagnostics.Expected_corresponding_JSX_closing_tag_for_0, ts.getTextOfNodeFromSourceText(sourceText, openingTagName)); - break; - } - result.push(parseJsxChild()); - } - result.end = scanner.getTokenPos(); - parsingContext = saveParsingContext; - return result; - } - function parseJsxOpeningOrSelfClosingElement(inExpressionContext) { - var fullStart = scanner.getStartPos(); - parseExpected(25 /* LessThanToken */); - var tagName = parseJsxElementName(); - var attributes = parseList(13 /* JsxAttributes */, parseJsxAttribute); - var node; - if (token === 27 /* 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(235 /* JsxOpeningElement */, fullStart); - scanJsxText(); - } - else { - parseExpected(39 /* SlashToken */); - if (inExpressionContext) { - parseExpected(27 /* GreaterThanToken */); - } - else { - parseExpected(27 /* GreaterThanToken */, /*diagnostic*/ undefined, /*advance*/ false); - scanJsxText(); - } - node = createNode(234 /* JsxSelfClosingElement */, fullStart); - } - node.tagName = tagName; - node.attributes = attributes; - return finishNode(node); - } - function parseJsxElementName() { - scanJsxIdentifier(); - var elementName = parseIdentifierName(); - while (parseOptional(21 /* DotToken */)) { - scanJsxIdentifier(); - var node = createNode(135 /* QualifiedName */, elementName.pos); - node.left = elementName; - node.right = parseIdentifierName(); - elementName = finishNode(node); - } - return elementName; - } - function parseJsxExpression(inExpressionContext) { - var node = createNode(240 /* JsxExpression */); - parseExpected(15 /* OpenBraceToken */); - if (token !== 16 /* CloseBraceToken */) { - node.expression = parseExpression(); - } - if (inExpressionContext) { - parseExpected(16 /* CloseBraceToken */); - } - else { - parseExpected(16 /* CloseBraceToken */, /*message*/ undefined, /*advance*/ false); - scanJsxText(); - } - return finishNode(node); - } - function parseJsxAttribute() { - if (token === 15 /* OpenBraceToken */) { - return parseJsxSpreadAttribute(); - } - scanJsxIdentifier(); - var node = createNode(238 /* JsxAttribute */); - node.name = parseIdentifierName(); - if (parseOptional(56 /* EqualsToken */)) { - switch (token) { - case 9 /* StringLiteral */: - node.initializer = parseLiteralNode(); - break; - default: - node.initializer = parseJsxExpression(/*inExpressionContext*/ true); - break; - } - } - return finishNode(node); - } - function parseJsxSpreadAttribute() { - var node = createNode(239 /* JsxSpreadAttribute */); - parseExpected(15 /* OpenBraceToken */); - parseExpected(22 /* DotDotDotToken */); - node.expression = parseExpression(); - parseExpected(16 /* CloseBraceToken */); - return finishNode(node); - } - function parseJsxClosingElement(inExpressionContext) { - var node = createNode(237 /* JsxClosingElement */); - parseExpected(26 /* LessThanSlashToken */); - node.tagName = parseJsxElementName(); - if (inExpressionContext) { - parseExpected(27 /* GreaterThanToken */); - } - else { - parseExpected(27 /* GreaterThanToken */, /*diagnostic*/ undefined, /*advance*/ false); - scanJsxText(); - } - return finishNode(node); - } - function parseTypeAssertion() { - var node = createNode(171 /* TypeAssertionExpression */); - parseExpected(25 /* LessThanToken */); - node.type = parseType(); - parseExpected(27 /* GreaterThanToken */); - node.expression = parseSimpleUnaryExpression(); - return finishNode(node); - } - function parseMemberExpressionRest(expression) { - while (true) { - var dotToken = parseOptionalToken(21 /* DotToken */); - if (dotToken) { - var propertyAccess = createNode(166 /* PropertyAccessExpression */, expression.pos); - propertyAccess.expression = expression; - propertyAccess.dotToken = dotToken; - propertyAccess.name = parseRightSideOfDot(/*allowIdentifierNames*/ true); - expression = finishNode(propertyAccess); - 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(167 /* ElementAccessExpression */, expression.pos); - indexedAccess.expression = expression; - // It's not uncommon for a user to write: "new Type[]". - // Check for that common pattern and report a better error message. - if (token !== 20 /* 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 */); - expression = finishNode(indexedAccess); - continue; - } - if (token === 11 /* NoSubstitutionTemplateLiteral */ || token === 12 /* TemplateHead */) { - var tagExpression = createNode(170 /* TaggedTemplateExpression */, expression.pos); - tagExpression.tag = expression; - tagExpression.template = token === 11 /* NoSubstitutionTemplateLiteral */ - ? parseLiteralNode() - : parseTemplateExpression(); - expression = finishNode(tagExpression); - continue; - } - return expression; - } - } - function parseCallExpressionRest(expression) { - while (true) { - expression = parseMemberExpressionRest(expression); - if (token === 25 /* 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 - // stack. - var typeArguments = tryParse(parseTypeArgumentsInExpression); - if (!typeArguments) { - return expression; - } - var callExpr = createNode(168 /* CallExpression */, expression.pos); - callExpr.expression = expression; - callExpr.typeArguments = typeArguments; - callExpr.arguments = parseArgumentList(); - expression = finishNode(callExpr); - continue; - } - else if (token === 17 /* OpenParenToken */) { - var callExpr = createNode(168 /* CallExpression */, expression.pos); - callExpr.expression = expression; - callExpr.arguments = parseArgumentList(); - expression = finishNode(callExpr); - continue; - } - return expression; - } - } - function parseArgumentList() { - parseExpected(17 /* OpenParenToken */); - var result = parseDelimitedList(11 /* ArgumentExpressions */, parseArgumentExpression); - parseExpected(18 /* CloseParenToken */); - return result; - } - function parseTypeArgumentsInExpression() { - if (!parseOptional(25 /* LessThanToken */)) { - return undefined; - } - var typeArguments = parseDelimitedList(18 /* TypeArguments */, parseType); - if (!parseExpected(27 /* GreaterThanToken */)) { - // If it doesn't have the closing > then it's definitely not an type argument list. - return undefined; - } - // If we have a '<', then only parse this as a arugment list if the type arguments - // are complete and we have an open paren. if we don't, rewind and return nothing. - return typeArguments && canFollowTypeArgumentsInExpression() - ? typeArguments - : undefined; - } - function canFollowTypeArgumentsInExpression() { - switch (token) { - case 17 /* 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 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 { - // 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. - default: - // Anything else treat as an expression. - return false; - } - } - function parsePrimaryExpression() { - switch (token) { - case 8 /* NumericLiteral */: - case 9 /* StringLiteral */: - case 11 /* NoSubstitutionTemplateLiteral */: - return parseLiteralNode(); - case 97 /* ThisKeyword */: - case 95 /* SuperKeyword */: - case 93 /* NullKeyword */: - case 99 /* TrueKeyword */: - case 84 /* FalseKeyword */: - return parseTokenNode(); - case 17 /* OpenParenToken */: - return parseParenthesizedExpression(); - case 19 /* OpenBracketToken */: - return parseArrayLiteralExpression(); - case 15 /* OpenBraceToken */: - return parseObjectLiteralExpression(); - case 118 /* AsyncKeyword */: - // Async arrow functions are parsed earlier in parseAssignmentExpressionOrHigher. - // If we encounter `async [no LineTerminator here] function` then this is an async - // function; otherwise, its an identifier. - if (!lookAhead(nextTokenIsFunctionKeywordOnSameLine)) { - break; - } - return parseFunctionExpression(); - case 73 /* ClassKeyword */: - return parseClassExpression(); - case 87 /* FunctionKeyword */: - return parseFunctionExpression(); - case 92 /* NewKeyword */: - return parseNewExpression(); - case 39 /* SlashToken */: - case 61 /* SlashEqualsToken */: - if (reScanSlashToken() === 10 /* RegularExpressionLiteral */) { - return parseLiteralNode(); - } - break; - case 12 /* TemplateHead */: - return parseTemplateExpression(); - } - return parseIdentifier(ts.Diagnostics.Expression_expected); - } - function parseParenthesizedExpression() { - var node = createNode(172 /* ParenthesizedExpression */); - parseExpected(17 /* OpenParenToken */); - node.expression = allowInAnd(parseExpression); - parseExpected(18 /* CloseParenToken */); - return finishNode(node); - } - function parseSpreadElement() { - var node = createNode(185 /* SpreadElementExpression */); - parseExpected(22 /* DotDotDotToken */); - node.expression = parseAssignmentExpressionOrHigher(); - return finishNode(node); - } - function parseArgumentOrArrayLiteralElement() { - return token === 22 /* DotDotDotToken */ ? parseSpreadElement() : - token === 24 /* CommaToken */ ? createNode(187 /* OmittedExpression */) : - parseAssignmentExpressionOrHigher(); - } - function parseArgumentExpression() { - return doOutsideOfContext(disallowInAndDecoratorContext, parseArgumentOrArrayLiteralElement); - } - function parseArrayLiteralExpression() { - var node = createNode(164 /* ArrayLiteralExpression */); - parseExpected(19 /* OpenBracketToken */); - if (scanner.hasPrecedingLineBreak()) - node.flags |= 2048 /* MultiLine */; - node.elements = parseDelimitedList(15 /* ArrayLiteralMembers */, parseArgumentOrArrayLiteralElement); - parseExpected(20 /* CloseBracketToken */); - return finishNode(node); - } - function tryParseAccessorDeclaration(fullStart, decorators, modifiers) { - if (parseContextualModifier(123 /* GetKeyword */)) { - return parseAccessorDeclaration(145 /* GetAccessor */, fullStart, decorators, modifiers); - } - else if (parseContextualModifier(129 /* SetKeyword */)) { - return parseAccessorDeclaration(146 /* SetAccessor */, fullStart, decorators, modifiers); - } - return undefined; - } - function parseObjectLiteralElement() { - var fullStart = scanner.getStartPos(); - var decorators = parseDecorators(); - var modifiers = parseModifiers(); - var accessor = tryParseAccessorDeclaration(fullStart, decorators, modifiers); - if (accessor) { - return accessor; - } - var asteriskToken = parseOptionalToken(37 /* AsteriskToken */); - var tokenIsIdentifier = isIdentifier(); - var nameToken = token; - 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 */) { - return parseMethodDeclaration(fullStart, decorators, modifiers, asteriskToken, propertyName, questionToken); - } - // check if it is short-hand property assignment or normal property assignment - // NOTE: if token is EqualsToken it is interpreted as CoverInitializedName production - // CoverInitializedName[Yield] : - // IdentifierReference[?Yield] Initializer[In, ?Yield] - // this is necessary because ObjectLiteral productions are also used to cover grammar for ObjectAssignmentPattern - var isShorthandPropertyAssignment = tokenIsIdentifier && (token === 24 /* CommaToken */ || token === 16 /* CloseBraceToken */ || token === 56 /* EqualsToken */); - if (isShorthandPropertyAssignment) { - var shorthandDeclaration = createNode(246 /* ShorthandPropertyAssignment */, fullStart); - shorthandDeclaration.name = propertyName; - shorthandDeclaration.questionToken = questionToken; - var equalsToken = parseOptionalToken(56 /* EqualsToken */); - if (equalsToken) { - shorthandDeclaration.equalsToken = equalsToken; - shorthandDeclaration.objectAssignmentInitializer = allowInAnd(parseAssignmentExpressionOrHigher); - } - return finishNode(shorthandDeclaration); - } - else { - var propertyAssignment = createNode(245 /* PropertyAssignment */, fullStart); - propertyAssignment.name = propertyName; - propertyAssignment.questionToken = questionToken; - parseExpected(54 /* ColonToken */); - propertyAssignment.initializer = allowInAnd(parseAssignmentExpressionOrHigher); - return finishNode(propertyAssignment); - } - } - function parseObjectLiteralExpression() { - var node = createNode(165 /* ObjectLiteralExpression */); - parseExpected(15 /* OpenBraceToken */); - if (scanner.hasPrecedingLineBreak()) { - node.flags |= 2048 /* MultiLine */; - } - node.properties = parseDelimitedList(12 /* ObjectLiteralMembers */, parseObjectLiteralElement, /*considerSemicolonAsDelimeter*/ true); - parseExpected(16 /* CloseBraceToken */); - return finishNode(node); - } - function parseFunctionExpression() { - // GeneratorExpression: - // function* BindingIdentifier [Yield][opt](FormalParameters[Yield]){ GeneratorBody } - // - // FunctionExpression: - // function BindingIdentifier[opt](FormalParameters){ FunctionBody } - var saveDecoratorContext = inDecoratorContext(); - if (saveDecoratorContext) { - setDecoratorContext(false); - } - var node = createNode(173 /* FunctionExpression */); - setModifiers(node, parseModifiers()); - parseExpected(87 /* FunctionKeyword */); - node.asteriskToken = parseOptionalToken(37 /* AsteriskToken */); - var isGenerator = !!node.asteriskToken; - var isAsync = !!(node.flags & 512 /* Async */); - node.name = - isGenerator && isAsync ? doInYieldAndAwaitContext(parseOptionalIdentifier) : - isGenerator ? doInYieldContext(parseOptionalIdentifier) : - isAsync ? doInAwaitContext(parseOptionalIdentifier) : - parseOptionalIdentifier(); - fillSignature(54 /* ColonToken */, /*yieldContext*/ isGenerator, /*awaitContext*/ isAsync, /*requireCompleteParameterList*/ false, node); - node.body = parseFunctionBlock(/*allowYield*/ isGenerator, /*allowAwait*/ isAsync, /*ignoreMissingOpenBrace*/ false); - if (saveDecoratorContext) { - setDecoratorContext(true); - } - return finishNode(node); - } - function parseOptionalIdentifier() { - return isIdentifier() ? parseIdentifier() : undefined; - } - function parseNewExpression() { - var node = createNode(169 /* NewExpression */); - parseExpected(92 /* NewKeyword */); - node.expression = parseMemberExpressionOrHigher(); - node.typeArguments = tryParse(parseTypeArgumentsInExpression); - if (node.typeArguments || token === 17 /* OpenParenToken */) { - node.arguments = parseArgumentList(); - } - return finishNode(node); - } - // STATEMENTS - function parseBlock(ignoreMissingOpenBrace, diagnosticMessage) { - var node = createNode(192 /* Block */); - if (parseExpected(15 /* OpenBraceToken */, diagnosticMessage) || ignoreMissingOpenBrace) { - node.statements = parseList(1 /* BlockStatements */, parseStatement); - parseExpected(16 /* CloseBraceToken */); - } - else { - node.statements = createMissingList(); - } - return finishNode(node); - } - function parseFunctionBlock(allowYield, allowAwait, ignoreMissingOpenBrace, diagnosticMessage) { - var savedYieldContext = inYieldContext(); - setYieldContext(allowYield); - var savedAwaitContext = inAwaitContext(); - setAwaitContext(allowAwait); - // We may be in a [Decorator] context when parsing a function expression or - // arrow function. The body of the function is not in [Decorator] context. - var saveDecoratorContext = inDecoratorContext(); - if (saveDecoratorContext) { - setDecoratorContext(false); - } - var block = parseBlock(ignoreMissingOpenBrace, diagnosticMessage); - if (saveDecoratorContext) { - setDecoratorContext(true); - } - setYieldContext(savedYieldContext); - setAwaitContext(savedAwaitContext); - return block; - } - function parseEmptyStatement() { - var node = createNode(194 /* EmptyStatement */); - parseExpected(23 /* SemicolonToken */); - return finishNode(node); - } - function parseIfStatement() { - var node = createNode(196 /* IfStatement */); - parseExpected(88 /* IfKeyword */); - parseExpected(17 /* OpenParenToken */); - node.expression = allowInAnd(parseExpression); - parseExpected(18 /* CloseParenToken */); - node.thenStatement = parseStatement(); - node.elseStatement = parseOptional(80 /* ElseKeyword */) ? parseStatement() : undefined; - return finishNode(node); - } - function parseDoStatement() { - var node = createNode(197 /* DoStatement */); - parseExpected(79 /* DoKeyword */); - node.statement = parseStatement(); - parseExpected(104 /* WhileKeyword */); - parseExpected(17 /* OpenParenToken */); - node.expression = allowInAnd(parseExpression); - parseExpected(18 /* 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 */); - return finishNode(node); - } - function parseWhileStatement() { - var node = createNode(198 /* WhileStatement */); - parseExpected(104 /* WhileKeyword */); - parseExpected(17 /* OpenParenToken */); - node.expression = allowInAnd(parseExpression); - parseExpected(18 /* CloseParenToken */); - node.statement = parseStatement(); - return finishNode(node); - } - function parseForOrForInOrForOfStatement() { - var pos = getNodePos(); - parseExpected(86 /* ForKeyword */); - parseExpected(17 /* OpenParenToken */); - var initializer = undefined; - if (token !== 23 /* SemicolonToken */) { - if (token === 102 /* VarKeyword */ || token === 108 /* LetKeyword */ || token === 74 /* ConstKeyword */) { - initializer = parseVariableDeclarationList(/*inForStatementInitializer*/ true); - } - else { - initializer = disallowInAnd(parseExpression); - } - } - var forOrForInOrForOfStatement; - if (parseOptional(90 /* InKeyword */)) { - var forInStatement = createNode(200 /* ForInStatement */, pos); - forInStatement.initializer = initializer; - forInStatement.expression = allowInAnd(parseExpression); - parseExpected(18 /* CloseParenToken */); - forOrForInOrForOfStatement = forInStatement; - } - else if (parseOptional(134 /* OfKeyword */)) { - var forOfStatement = createNode(201 /* ForOfStatement */, pos); - forOfStatement.initializer = initializer; - forOfStatement.expression = allowInAnd(parseAssignmentExpressionOrHigher); - parseExpected(18 /* CloseParenToken */); - forOrForInOrForOfStatement = forOfStatement; - } - else { - var forStatement = createNode(199 /* ForStatement */, pos); - forStatement.initializer = initializer; - parseExpected(23 /* SemicolonToken */); - if (token !== 23 /* SemicolonToken */ && token !== 18 /* CloseParenToken */) { - forStatement.condition = allowInAnd(parseExpression); - } - parseExpected(23 /* SemicolonToken */); - if (token !== 18 /* CloseParenToken */) { - forStatement.incrementor = allowInAnd(parseExpression); - } - parseExpected(18 /* CloseParenToken */); - forOrForInOrForOfStatement = forStatement; - } - forOrForInOrForOfStatement.statement = parseStatement(); - return finishNode(forOrForInOrForOfStatement); - } - function parseBreakOrContinueStatement(kind) { - var node = createNode(kind); - parseExpected(kind === 203 /* BreakStatement */ ? 70 /* BreakKeyword */ : 75 /* ContinueKeyword */); - if (!canParseSemicolon()) { - node.label = parseIdentifier(); - } - parseSemicolon(); - return finishNode(node); - } - function parseReturnStatement() { - var node = createNode(204 /* ReturnStatement */); - parseExpected(94 /* ReturnKeyword */); - if (!canParseSemicolon()) { - node.expression = allowInAnd(parseExpression); - } - parseSemicolon(); - return finishNode(node); - } - function parseWithStatement() { - var node = createNode(205 /* WithStatement */); - parseExpected(105 /* WithKeyword */); - parseExpected(17 /* OpenParenToken */); - node.expression = allowInAnd(parseExpression); - parseExpected(18 /* CloseParenToken */); - node.statement = parseStatement(); - return finishNode(node); - } - function parseCaseClause() { - var node = createNode(241 /* CaseClause */); - parseExpected(71 /* CaseKeyword */); - node.expression = allowInAnd(parseExpression); - parseExpected(54 /* ColonToken */); - node.statements = parseList(3 /* SwitchClauseStatements */, parseStatement); - return finishNode(node); - } - function parseDefaultClause() { - var node = createNode(242 /* DefaultClause */); - parseExpected(77 /* DefaultKeyword */); - parseExpected(54 /* ColonToken */); - node.statements = parseList(3 /* SwitchClauseStatements */, parseStatement); - return finishNode(node); - } - function parseCaseOrDefaultClause() { - return token === 71 /* CaseKeyword */ ? parseCaseClause() : parseDefaultClause(); - } - function parseSwitchStatement() { - var node = createNode(206 /* SwitchStatement */); - parseExpected(96 /* SwitchKeyword */); - parseExpected(17 /* OpenParenToken */); - node.expression = allowInAnd(parseExpression); - parseExpected(18 /* CloseParenToken */); - var caseBlock = createNode(220 /* CaseBlock */, scanner.getStartPos()); - parseExpected(15 /* OpenBraceToken */); - caseBlock.clauses = parseList(2 /* SwitchClauses */, parseCaseOrDefaultClause); - parseExpected(16 /* CloseBraceToken */); - node.caseBlock = finishNode(caseBlock); - return finishNode(node); - } - function parseThrowStatement() { - // ThrowStatement[Yield] : - // throw [no LineTerminator here]Expression[In, ?Yield]; - // Because of automatic semicolon insertion, we need to report error if this - // throw could be terminated with a semicolon. Note: we can't call 'parseExpression' - // 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(208 /* ThrowStatement */); - parseExpected(98 /* ThrowKeyword */); - node.expression = scanner.hasPrecedingLineBreak() ? undefined : allowInAnd(parseExpression); - parseSemicolon(); - return finishNode(node); - } - // TODO: Review for error recovery - function parseTryStatement() { - var node = createNode(209 /* TryStatement */); - parseExpected(100 /* TryKeyword */); - node.tryBlock = parseBlock(/*ignoreMissingOpenBrace*/ false); - node.catchClause = token === 72 /* CatchKeyword */ ? parseCatchClause() : undefined; - // If we don't have a catch clause, then we must have a finally clause. Try to parse - // one out no matter what. - if (!node.catchClause || token === 85 /* FinallyKeyword */) { - parseExpected(85 /* FinallyKeyword */); - node.finallyBlock = parseBlock(/*ignoreMissingOpenBrace*/ false); - } - return finishNode(node); - } - function parseCatchClause() { - var result = createNode(244 /* CatchClause */); - parseExpected(72 /* CatchKeyword */); - if (parseExpected(17 /* OpenParenToken */)) { - result.variableDeclaration = parseVariableDeclaration(); - } - parseExpected(18 /* CloseParenToken */); - result.block = parseBlock(/*ignoreMissingOpenBrace*/ false); - return finishNode(result); - } - function parseDebuggerStatement() { - var node = createNode(210 /* DebuggerStatement */); - parseExpected(76 /* DebuggerKeyword */); - parseSemicolon(); - return finishNode(node); - } - function parseExpressionOrLabeledStatement() { - // Avoiding having to do the lookahead for a labeled statement by just trying to parse - // out an expression, seeing if it is identifier and then seeing if it is followed by - // a colon. - var fullStart = scanner.getStartPos(); - var expression = allowInAnd(parseExpression); - if (expression.kind === 69 /* Identifier */ && parseOptional(54 /* ColonToken */)) { - var labeledStatement = createNode(207 /* LabeledStatement */, fullStart); - labeledStatement.label = expression; - labeledStatement.statement = parseStatement(); - return finishNode(labeledStatement); - } - else { - var expressionStatement = createNode(195 /* ExpressionStatement */, fullStart); - expressionStatement.expression = expression; - parseSemicolon(); - return finishNode(expressionStatement); - } - } - function nextTokenIsIdentifierOrKeywordOnSameLine() { - nextToken(); - return ts.tokenIsIdentifierOrKeyword(token) && !scanner.hasPrecedingLineBreak(); - } - function nextTokenIsFunctionKeywordOnSameLine() { - nextToken(); - return token === 87 /* FunctionKeyword */ && !scanner.hasPrecedingLineBreak(); - } - function nextTokenIsIdentifierOrKeywordOrNumberOnSameLine() { - nextToken(); - return (ts.tokenIsIdentifierOrKeyword(token) || token === 8 /* NumericLiteral */) && !scanner.hasPrecedingLineBreak(); - } - function isDeclaration() { - while (true) { - switch (token) { - case 102 /* VarKeyword */: - case 108 /* LetKeyword */: - case 74 /* ConstKeyword */: - case 87 /* FunctionKeyword */: - case 73 /* ClassKeyword */: - case 81 /* EnumKeyword */: - return true; - // 'declare', 'module', 'namespace', 'interface'* and 'type' are all legal JavaScript identifiers; - // however, an identifier cannot be followed by another identifier on the same line. This is what we - // count on to parse out the respective declarations. For instance, we exploit this to say that - // - // namespace n - // - // can be none other than the beginning of a namespace declaration, but need to respect that JavaScript sees - // - // namespace - // n - // - // as the identifier 'namespace' on one line followed by the identifier 'n' on another. - // We need to look one token ahead to see if it permissible to try parsing a declaration. - // - // *Note*: 'interface' is actually a strict mode reserved word. So while - // - // "use strict" - // interface - // I {} - // - // could be legal, it would add complexity for very little gain. - case 107 /* InterfaceKeyword */: - case 132 /* TypeKeyword */: - return nextTokenIsIdentifierOnSameLine(); - case 125 /* ModuleKeyword */: - case 126 /* NamespaceKeyword */: - return nextTokenIsIdentifierOrStringLiteralOnSameLine(); - case 115 /* AbstractKeyword */: - case 118 /* AsyncKeyword */: - case 122 /* DeclareKeyword */: - case 110 /* PrivateKeyword */: - case 111 /* ProtectedKeyword */: - case 112 /* PublicKeyword */: - nextToken(); - // ASI takes effect for this modifier. - if (scanner.hasPrecedingLineBreak()) { - return false; - } - continue; - case 89 /* ImportKeyword */: - nextToken(); - return token === 9 /* StringLiteral */ || token === 37 /* AsteriskToken */ || - token === 15 /* OpenBraceToken */ || ts.tokenIsIdentifierOrKeyword(token); - case 82 /* ExportKeyword */: - nextToken(); - if (token === 56 /* EqualsToken */ || token === 37 /* AsteriskToken */ || - token === 15 /* OpenBraceToken */ || token === 77 /* DefaultKeyword */) { - return true; - } - continue; - case 113 /* StaticKeyword */: - nextToken(); - continue; - default: - return false; - } - } - } - function isStartOfDeclaration() { - return lookAhead(isDeclaration); - } - 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 */: - // '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 */: - return true; - case 74 /* ConstKeyword */: - case 82 /* ExportKeyword */: - case 89 /* ImportKeyword */: - return isStartOfDeclaration(); - case 118 /* AsyncKeyword */: - case 122 /* DeclareKeyword */: - case 107 /* InterfaceKeyword */: - case 125 /* ModuleKeyword */: - case 126 /* NamespaceKeyword */: - case 132 /* TypeKeyword */: - // When these don't start a declaration, they're an identifier in an expression statement - return true; - case 112 /* PublicKeyword */: - case 110 /* PrivateKeyword */: - case 111 /* ProtectedKeyword */: - case 113 /* StaticKeyword */: - // When these don't start a declaration, they may be the start of a class member if an identifier - // immediately follows. Otherwise they're an identifier in an expression statement. - return isStartOfDeclaration() || !lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine); - default: - return isStartOfExpression(); - } - } - function nextTokenIsIdentifierOrStartOfDestructuring() { - nextToken(); - return isIdentifier() || token === 15 /* OpenBraceToken */ || token === 19 /* OpenBracketToken */; - } - function isLetDeclaration() { - // In ES6 'let' always starts a lexical declaration if followed by an identifier or { - // or [. - return lookAhead(nextTokenIsIdentifierOrStartOfDestructuring); - } - function parseStatement() { - switch (token) { - case 23 /* SemicolonToken */: - return parseEmptyStatement(); - case 15 /* OpenBraceToken */: - return parseBlock(/*ignoreMissingOpenBrace*/ false); - case 102 /* VarKeyword */: - return parseVariableStatement(scanner.getStartPos(), /*decorators*/ undefined, /*modifiers*/ undefined); - case 108 /* LetKeyword */: - if (isLetDeclaration()) { - return parseVariableStatement(scanner.getStartPos(), /*decorators*/ undefined, /*modifiers*/ undefined); - } - break; - case 87 /* FunctionKeyword */: - return parseFunctionDeclaration(scanner.getStartPos(), /*decorators*/ undefined, /*modifiers*/ undefined); - case 73 /* ClassKeyword */: - return parseClassDeclaration(scanner.getStartPos(), /*decorators*/ undefined, /*modifiers*/ undefined); - case 88 /* IfKeyword */: - return parseIfStatement(); - case 79 /* DoKeyword */: - return parseDoStatement(); - case 104 /* WhileKeyword */: - return parseWhileStatement(); - case 86 /* ForKeyword */: - return parseForOrForInOrForOfStatement(); - case 75 /* ContinueKeyword */: - return parseBreakOrContinueStatement(202 /* ContinueStatement */); - case 70 /* BreakKeyword */: - return parseBreakOrContinueStatement(203 /* BreakStatement */); - case 94 /* ReturnKeyword */: - return parseReturnStatement(); - case 105 /* WithKeyword */: - return parseWithStatement(); - case 96 /* SwitchKeyword */: - return parseSwitchStatement(); - case 98 /* ThrowKeyword */: - return parseThrowStatement(); - case 100 /* TryKeyword */: - // Include 'catch' and 'finally' for error recovery. - case 72 /* CatchKeyword */: - case 85 /* FinallyKeyword */: - return parseTryStatement(); - case 76 /* DebuggerKeyword */: - return parseDebuggerStatement(); - case 55 /* AtToken */: - return parseDeclaration(); - case 118 /* AsyncKeyword */: - case 107 /* InterfaceKeyword */: - case 132 /* TypeKeyword */: - case 125 /* ModuleKeyword */: - case 126 /* NamespaceKeyword */: - case 122 /* DeclareKeyword */: - case 74 /* ConstKeyword */: - case 81 /* EnumKeyword */: - case 82 /* ExportKeyword */: - case 89 /* ImportKeyword */: - case 110 /* PrivateKeyword */: - case 111 /* ProtectedKeyword */: - case 112 /* PublicKeyword */: - case 115 /* AbstractKeyword */: - case 113 /* StaticKeyword */: - if (isStartOfDeclaration()) { - return parseDeclaration(); - } - break; - } - return parseExpressionOrLabeledStatement(); - } - function parseDeclaration() { - var fullStart = getNodePos(); - var decorators = parseDecorators(); - var modifiers = parseModifiers(); - switch (token) { - case 102 /* VarKeyword */: - case 108 /* LetKeyword */: - case 74 /* ConstKeyword */: - return parseVariableStatement(fullStart, decorators, modifiers); - case 87 /* FunctionKeyword */: - return parseFunctionDeclaration(fullStart, decorators, modifiers); - case 73 /* ClassKeyword */: - return parseClassDeclaration(fullStart, decorators, modifiers); - case 107 /* InterfaceKeyword */: - return parseInterfaceDeclaration(fullStart, decorators, modifiers); - case 132 /* TypeKeyword */: - return parseTypeAliasDeclaration(fullStart, decorators, modifiers); - case 81 /* EnumKeyword */: - return parseEnumDeclaration(fullStart, decorators, modifiers); - case 125 /* ModuleKeyword */: - case 126 /* NamespaceKeyword */: - return parseModuleDeclaration(fullStart, decorators, modifiers); - case 89 /* ImportKeyword */: - return parseImportDeclarationOrImportEqualsDeclaration(fullStart, decorators, modifiers); - case 82 /* ExportKeyword */: - nextToken(); - return token === 77 /* DefaultKeyword */ || token === 56 /* EqualsToken */ ? - parseExportAssignment(fullStart, decorators, modifiers) : - parseExportDeclaration(fullStart, decorators, modifiers); - default: - if (decorators || modifiers) { - // We reached this point because we encountered decorators and/or modifiers and assumed a declaration - // would follow. For recovery and error reporting purposes, return an incomplete declaration. - var node = createMissingNode(231 /* MissingDeclaration */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); - node.pos = fullStart; - node.decorators = decorators; - setModifiers(node, modifiers); - return finishNode(node); - } - } - } - function nextTokenIsIdentifierOrStringLiteralOnSameLine() { - nextToken(); - return !scanner.hasPrecedingLineBreak() && (isIdentifier() || token === 9 /* StringLiteral */); - } - function parseFunctionBlockOrSemicolon(isGenerator, isAsync, diagnosticMessage) { - if (token !== 15 /* OpenBraceToken */ && canParseSemicolon()) { - parseSemicolon(); - return; - } - return parseFunctionBlock(isGenerator, isAsync, /*ignoreMissingOpenBrace*/ false, diagnosticMessage); - } - // DECLARATIONS - function parseArrayBindingElement() { - if (token === 24 /* CommaToken */) { - return createNode(187 /* OmittedExpression */); - } - var node = createNode(163 /* BindingElement */); - node.dotDotDotToken = parseOptionalToken(22 /* DotDotDotToken */); - node.name = parseIdentifierOrPattern(); - node.initializer = parseBindingElementInitializer(/*inParameter*/ false); - return finishNode(node); - } - function parseObjectBindingElement() { - var node = createNode(163 /* BindingElement */); - // TODO(andersh): Handle computed properties - var tokenIsIdentifier = isIdentifier(); - var propertyName = parsePropertyName(); - if (tokenIsIdentifier && token !== 54 /* ColonToken */) { - node.name = propertyName; - } - else { - parseExpected(54 /* ColonToken */); - node.propertyName = propertyName; - node.name = parseIdentifierOrPattern(); - } - node.initializer = parseBindingElementInitializer(/*inParameter*/ false); - return finishNode(node); - } - function parseObjectBindingPattern() { - var node = createNode(161 /* ObjectBindingPattern */); - parseExpected(15 /* OpenBraceToken */); - node.elements = parseDelimitedList(9 /* ObjectBindingElements */, parseObjectBindingElement); - parseExpected(16 /* CloseBraceToken */); - return finishNode(node); - } - function parseArrayBindingPattern() { - var node = createNode(162 /* ArrayBindingPattern */); - parseExpected(19 /* OpenBracketToken */); - node.elements = parseDelimitedList(10 /* ArrayBindingElements */, parseArrayBindingElement); - parseExpected(20 /* CloseBracketToken */); - return finishNode(node); - } - function isIdentifierOrPattern() { - return token === 15 /* OpenBraceToken */ || token === 19 /* OpenBracketToken */ || isIdentifier(); - } - function parseIdentifierOrPattern() { - if (token === 19 /* OpenBracketToken */) { - return parseArrayBindingPattern(); - } - if (token === 15 /* OpenBraceToken */) { - return parseObjectBindingPattern(); - } - return parseIdentifier(); - } - function parseVariableDeclaration() { - var node = createNode(211 /* VariableDeclaration */); - node.name = parseIdentifierOrPattern(); - node.type = parseTypeAnnotation(); - if (!isInOrOfKeyword(token)) { - node.initializer = parseInitializer(/*inParameter*/ false); - } - return finishNode(node); - } - function parseVariableDeclarationList(inForStatementInitializer) { - var node = createNode(212 /* VariableDeclarationList */); - switch (token) { - case 102 /* VarKeyword */: - break; - case 108 /* LetKeyword */: - node.flags |= 16384 /* Let */; - break; - case 74 /* ConstKeyword */: - node.flags |= 32768 /* Const */; - break; - default: - ts.Debug.fail(); - } - nextToken(); - // The user may have written the following: - // - // for (let of X) { } - // - // In this case, we want to parse an empty declaration list, and then parse 'of' - // as a keyword. The reason this is not automatic is that 'of' is a valid identifier. - // 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 === 134 /* OfKeyword */ && lookAhead(canFollowContextualOfKeyword)) { - node.declarations = createMissingList(); - } - else { - var savedDisallowIn = inDisallowInContext(); - setDisallowInContext(inForStatementInitializer); - node.declarations = parseDelimitedList(8 /* VariableDeclarations */, parseVariableDeclaration); - setDisallowInContext(savedDisallowIn); - } - return finishNode(node); - } - function canFollowContextualOfKeyword() { - return nextTokenIsIdentifier() && nextToken() === 18 /* CloseParenToken */; - } - function parseVariableStatement(fullStart, decorators, modifiers) { - var node = createNode(193 /* VariableStatement */, fullStart); - node.decorators = decorators; - setModifiers(node, modifiers); - node.declarationList = parseVariableDeclarationList(/*inForStatementInitializer*/ false); - parseSemicolon(); - return finishNode(node); - } - function parseFunctionDeclaration(fullStart, decorators, modifiers) { - var node = createNode(213 /* FunctionDeclaration */, fullStart); - node.decorators = decorators; - setModifiers(node, modifiers); - parseExpected(87 /* FunctionKeyword */); - node.asteriskToken = parseOptionalToken(37 /* AsteriskToken */); - node.name = node.flags & 1024 /* Default */ ? parseOptionalIdentifier() : parseIdentifier(); - var isGenerator = !!node.asteriskToken; - var isAsync = !!(node.flags & 512 /* Async */); - fillSignature(54 /* ColonToken */, /*yieldContext*/ isGenerator, /*awaitContext*/ isAsync, /*requireCompleteParameterList*/ false, node); - node.body = parseFunctionBlockOrSemicolon(isGenerator, isAsync, ts.Diagnostics.or_expected); - return finishNode(node); - } - function parseConstructorDeclaration(pos, decorators, modifiers) { - var node = createNode(144 /* Constructor */, pos); - node.decorators = decorators; - setModifiers(node, modifiers); - parseExpected(121 /* ConstructorKeyword */); - fillSignature(54 /* ColonToken */, /*yieldContext*/ false, /*awaitContext*/ false, /*requireCompleteParameterList*/ false, node); - node.body = parseFunctionBlockOrSemicolon(/*isGenerator*/ false, /*isAsync*/ false, ts.Diagnostics.or_expected); - return finishNode(node); - } - function parseMethodDeclaration(fullStart, decorators, modifiers, asteriskToken, name, questionToken, diagnosticMessage) { - var method = createNode(143 /* MethodDeclaration */, fullStart); - method.decorators = decorators; - setModifiers(method, modifiers); - method.asteriskToken = asteriskToken; - method.name = name; - method.questionToken = questionToken; - var isGenerator = !!asteriskToken; - var isAsync = !!(method.flags & 512 /* Async */); - fillSignature(54 /* ColonToken */, /*yieldContext*/ isGenerator, /*awaitContext*/ isAsync, /*requireCompleteParameterList*/ false, method); - method.body = parseFunctionBlockOrSemicolon(isGenerator, isAsync, diagnosticMessage); - return finishNode(method); - } - function parsePropertyDeclaration(fullStart, decorators, modifiers, name, questionToken) { - var property = createNode(141 /* PropertyDeclaration */, fullStart); - property.decorators = decorators; - setModifiers(property, modifiers); - property.name = name; - property.questionToken = questionToken; - property.type = parseTypeAnnotation(); - // For instance properties specifically, since they are evaluated inside the constructor, - // we do *not * want to parse yield expressions, so we specifically turn the yield context - // off. The grammar would look something like this: - // - // MemberVariableDeclaration[Yield]: - // AccessibilityModifier_opt PropertyName TypeAnnotation_opt Initialiser_opt[In]; - // AccessibilityModifier_opt static_opt PropertyName TypeAnnotation_opt Initialiser_opt[In, ?Yield]; - // - // The checker may still error in the static case to explicitly disallow the yield expression. - property.initializer = modifiers && modifiers.flags & 128 /* Static */ - ? allowInAnd(parseNonParameterInitializer) - : doOutsideOfContext(2 /* Yield */ | 1 /* DisallowIn */, parseNonParameterInitializer); - parseSemicolon(); - return finishNode(property); - } - function parsePropertyOrMethodDeclaration(fullStart, decorators, modifiers) { - var asteriskToken = parseOptionalToken(37 /* 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 */) { - return parseMethodDeclaration(fullStart, decorators, modifiers, asteriskToken, name, questionToken, ts.Diagnostics.or_expected); - } - else { - return parsePropertyDeclaration(fullStart, decorators, modifiers, name, questionToken); - } - } - function parseNonParameterInitializer() { - return parseInitializer(/*inParameter*/ false); - } - function parseAccessorDeclaration(kind, fullStart, decorators, modifiers) { - var node = createNode(kind, fullStart); - node.decorators = decorators; - setModifiers(node, modifiers); - node.name = parsePropertyName(); - fillSignature(54 /* ColonToken */, /*yieldContext*/ false, /*awaitContext*/ false, /*requireCompleteParameterList*/ false, node); - node.body = parseFunctionBlockOrSemicolon(/*isGenerator*/ false, /*isAsync*/ false); - return finishNode(node); - } - function isClassMemberModifier(idToken) { - switch (idToken) { - case 112 /* PublicKeyword */: - case 110 /* PrivateKeyword */: - case 111 /* ProtectedKeyword */: - case 113 /* StaticKeyword */: - return true; - default: - return false; - } - } - function isClassMemberStart() { - var idToken; - if (token === 55 /* AtToken */) { - return true; - } - // Eat up all modifiers, but hold on to the last one in case it is actually an identifier. - while (ts.isModifier(token)) { - idToken = token; - // If the idToken is a class modifier (protected, private, public, and static), it is - // certain that we are starting to parse class member. This allows better error recovery - // Example: - // public foo() ... // true - // public @dec blah ... // true; we will then report an error later - // export public ... // true; we will then report an error later - if (isClassMemberModifier(idToken)) { - return true; - } - nextToken(); - } - if (token === 37 /* AsteriskToken */) { - return true; - } - // Try to get the first property-like token following all modifiers. - // This can either be an identifier or the 'get' or 'set' keywords. - if (isLiteralPropertyName()) { - idToken = token; - nextToken(); - } - // Index signatures and computed properties are class members; we can parse. - if (token === 19 /* 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 === 129 /* SetKeyword */ || idToken === 123 /* 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 */: - return true; - default: - // Covers - // - Semicolons (declaration termination) - // - Closing braces (end-of-class, must be declaration) - // - End-of-files (not valid, but permitted so that it gets caught later on) - // - Line-breaks (enabling *automatic semicolon insertion*) - return canParseSemicolon(); - } - } - return false; - } - function parseDecorators() { - var decorators; - while (true) { - var decoratorStart = getNodePos(); - if (!parseOptional(55 /* AtToken */)) { - break; - } - if (!decorators) { - decorators = []; - decorators.pos = scanner.getStartPos(); - } - var decorator = createNode(139 /* Decorator */, decoratorStart); - decorator.expression = doInDecoratorContext(parseLeftHandSideExpressionOrHigher); - decorators.push(finishNode(decorator)); - } - if (decorators) { - decorators.end = getNodeEnd(); - } - return decorators; - } - function parseModifiers() { - var flags = 0; - var modifiers; - while (true) { - var modifierStart = scanner.getStartPos(); - var modifierKind = token; - if (!parseAnyContextualModifier()) { - break; - } - if (!modifiers) { - modifiers = []; - modifiers.pos = modifierStart; - } - flags |= ts.modifierToFlag(modifierKind); - modifiers.push(finishNode(createNode(modifierKind, modifierStart))); - } - if (modifiers) { - modifiers.flags = flags; - modifiers.end = scanner.getStartPos(); - } - return modifiers; - } - function parseModifiersForArrowFunction() { - var flags = 0; - var modifiers; - if (token === 118 /* AsyncKeyword */) { - var modifierStart = scanner.getStartPos(); - var modifierKind = token; - nextToken(); - modifiers = []; - modifiers.pos = modifierStart; - flags |= ts.modifierToFlag(modifierKind); - modifiers.push(finishNode(createNode(modifierKind, modifierStart))); - modifiers.flags = flags; - modifiers.end = scanner.getStartPos(); - } - return modifiers; - } - function parseClassElement() { - if (token === 23 /* SemicolonToken */) { - var result = createNode(191 /* SemicolonClassElement */); - nextToken(); - return finishNode(result); - } - var fullStart = getNodePos(); - var decorators = parseDecorators(); - var modifiers = parseModifiers(); - var accessor = tryParseAccessorDeclaration(fullStart, decorators, modifiers); - if (accessor) { - return accessor; - } - if (token === 121 /* ConstructorKeyword */) { - return parseConstructorDeclaration(fullStart, decorators, modifiers); - } - if (isIndexSignature()) { - return parseIndexSignatureDeclaration(fullStart, decorators, modifiers); - } - // It is very important that we check this *after* checking indexers because - // the [ token can start an index signature or a computed property name - if (ts.tokenIsIdentifierOrKeyword(token) || - token === 9 /* StringLiteral */ || - token === 8 /* NumericLiteral */ || - token === 37 /* AsteriskToken */ || - token === 19 /* OpenBracketToken */) { - return parsePropertyOrMethodDeclaration(fullStart, decorators, modifiers); - } - if (decorators || modifiers) { - // treat this as a property declaration with a missing name. - var name_7 = createMissingNode(69 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); - return parsePropertyDeclaration(fullStart, decorators, modifiers, name_7, /*questionToken*/ undefined); - } - // 'isClassMemberStart' should have hinted not to attempt parsing. - ts.Debug.fail("Should not have attempted to parse class member declaration."); - } - function parseClassExpression() { - return parseClassDeclarationOrExpression( - /*fullStart*/ scanner.getStartPos(), - /*decorators*/ undefined, - /*modifiers*/ undefined, 186 /* ClassExpression */); - } - function parseClassDeclaration(fullStart, decorators, modifiers) { - return parseClassDeclarationOrExpression(fullStart, decorators, modifiers, 214 /* ClassDeclaration */); - } - function parseClassDeclarationOrExpression(fullStart, decorators, modifiers, kind) { - var node = createNode(kind, fullStart); - node.decorators = decorators; - setModifiers(node, modifiers); - parseExpected(73 /* ClassKeyword */); - node.name = parseNameOfClassDeclarationOrExpression(); - node.typeParameters = parseTypeParameters(); - node.heritageClauses = parseHeritageClauses(/*isClassHeritageClause*/ true); - if (parseExpected(15 /* OpenBraceToken */)) { - // ClassTail[Yield,Await] : (Modified) See 14.5 - // ClassHeritage[?Yield,?Await]opt { ClassBody[?Yield,?Await]opt } - node.members = parseClassMembers(); - parseExpected(16 /* CloseBraceToken */); - } - else { - node.members = createMissingList(); - } - return finishNode(node); - } - function parseNameOfClassDeclarationOrExpression() { - // implements is a future reserved word so - // 'class implements' might mean either - // - class expression with omitted name, 'implements' starts heritage clause - // - class with name 'implements' - // 'isImplementsClause' helps to disambiguate between these two cases - return isIdentifier() && !isImplementsClause() - ? parseIdentifier() - : undefined; - } - function isImplementsClause() { - return token === 106 /* ImplementsKeyword */ && lookAhead(nextTokenIsIdentifierOrKeyword); - } - function parseHeritageClauses(isClassHeritageClause) { - // ClassTail[Yield,Await] : (Modified) See 14.5 - // ClassHeritage[?Yield,?Await]opt { ClassBody[?Yield,?Await]opt } - if (isHeritageClause()) { - return parseList(20 /* HeritageClauses */, parseHeritageClause); - } - return undefined; - } - function parseHeritageClausesWorker() { - return parseList(20 /* HeritageClauses */, parseHeritageClause); - } - function parseHeritageClause() { - if (token === 83 /* ExtendsKeyword */ || token === 106 /* ImplementsKeyword */) { - var node = createNode(243 /* HeritageClause */); - node.token = token; - nextToken(); - node.types = parseDelimitedList(7 /* HeritageClauseElement */, parseExpressionWithTypeArguments); - return finishNode(node); - } - return undefined; - } - function parseExpressionWithTypeArguments() { - var node = createNode(188 /* ExpressionWithTypeArguments */); - node.expression = parseLeftHandSideExpressionOrHigher(); - if (token === 25 /* LessThanToken */) { - node.typeArguments = parseBracketedList(18 /* TypeArguments */, parseType, 25 /* LessThanToken */, 27 /* GreaterThanToken */); - } - return finishNode(node); - } - function isHeritageClause() { - return token === 83 /* ExtendsKeyword */ || token === 106 /* ImplementsKeyword */; - } - function parseClassMembers() { - return parseList(5 /* ClassMembers */, parseClassElement); - } - function parseInterfaceDeclaration(fullStart, decorators, modifiers) { - var node = createNode(215 /* InterfaceDeclaration */, fullStart); - node.decorators = decorators; - setModifiers(node, modifiers); - parseExpected(107 /* InterfaceKeyword */); - node.name = parseIdentifier(); - node.typeParameters = parseTypeParameters(); - node.heritageClauses = parseHeritageClauses(/*isClassHeritageClause*/ false); - node.members = parseObjectTypeMembers(); - return finishNode(node); - } - function parseTypeAliasDeclaration(fullStart, decorators, modifiers) { - var node = createNode(216 /* TypeAliasDeclaration */, fullStart); - node.decorators = decorators; - setModifiers(node, modifiers); - parseExpected(132 /* TypeKeyword */); - node.name = parseIdentifier(); - node.typeParameters = parseTypeParameters(); - parseExpected(56 /* EqualsToken */); - node.type = parseType(); - parseSemicolon(); - return 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 - // ConstantEnumMemberSection, which starts at the beginning of an enum declaration - // or any time an integer literal initializer is encountered. - function parseEnumMember() { - var node = createNode(247 /* EnumMember */, scanner.getStartPos()); - node.name = parsePropertyName(); - node.initializer = allowInAnd(parseNonParameterInitializer); - return finishNode(node); - } - function parseEnumDeclaration(fullStart, decorators, modifiers) { - var node = createNode(217 /* EnumDeclaration */, fullStart); - node.decorators = decorators; - setModifiers(node, modifiers); - parseExpected(81 /* EnumKeyword */); - node.name = parseIdentifier(); - if (parseExpected(15 /* OpenBraceToken */)) { - node.members = parseDelimitedList(6 /* EnumMembers */, parseEnumMember); - parseExpected(16 /* CloseBraceToken */); - } - else { - node.members = createMissingList(); - } - return finishNode(node); - } - function parseModuleBlock() { - var node = createNode(219 /* ModuleBlock */, scanner.getStartPos()); - if (parseExpected(15 /* OpenBraceToken */)) { - node.statements = parseList(1 /* BlockStatements */, parseStatement); - parseExpected(16 /* CloseBraceToken */); - } - else { - node.statements = createMissingList(); - } - return finishNode(node); - } - function parseModuleOrNamespaceDeclaration(fullStart, decorators, modifiers, flags) { - var node = createNode(218 /* ModuleDeclaration */, fullStart); - // If we are parsing a dotted namespace name, we want to - // propagate the 'Namespace' flag across the names if set. - var namespaceFlag = flags & 131072 /* Namespace */; - node.decorators = decorators; - setModifiers(node, modifiers); - node.flags |= flags; - node.name = parseIdentifier(); - node.body = parseOptional(21 /* DotToken */) - ? parseModuleOrNamespaceDeclaration(getNodePos(), /*decorators*/ undefined, /*modifiers*/ undefined, 1 /* Export */ | namespaceFlag) - : parseModuleBlock(); - return finishNode(node); - } - function parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers) { - var node = createNode(218 /* ModuleDeclaration */, fullStart); - node.decorators = decorators; - setModifiers(node, modifiers); - node.name = parseLiteralNode(/*internName*/ true); - node.body = parseModuleBlock(); - return finishNode(node); - } - function parseModuleDeclaration(fullStart, decorators, modifiers) { - var flags = modifiers ? modifiers.flags : 0; - if (parseOptional(126 /* NamespaceKeyword */)) { - flags |= 131072 /* Namespace */; - } - else { - parseExpected(125 /* ModuleKeyword */); - if (token === 9 /* StringLiteral */) { - return parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers); - } - } - return parseModuleOrNamespaceDeclaration(fullStart, decorators, modifiers, flags); - } - function isExternalModuleReference() { - return token === 127 /* RequireKeyword */ && - lookAhead(nextTokenIsOpenParen); - } - function nextTokenIsOpenParen() { - return nextToken() === 17 /* OpenParenToken */; - } - function nextTokenIsSlash() { - return nextToken() === 39 /* SlashToken */; - } - function nextTokenIsCommaOrFromKeyword() { - nextToken(); - return token === 24 /* CommaToken */ || - token === 133 /* FromKeyword */; - } - function parseImportDeclarationOrImportEqualsDeclaration(fullStart, decorators, modifiers) { - parseExpected(89 /* ImportKeyword */); - var afterImportPos = scanner.getStartPos(); - var identifier; - if (isIdentifier()) { - identifier = parseIdentifier(); - if (token !== 24 /* CommaToken */ && token !== 133 /* FromKeyword */) { - // ImportEquals declaration of type: - // import x = require("mod"); or - // import x = M.x; - var importEqualsDeclaration = createNode(221 /* ImportEqualsDeclaration */, fullStart); - importEqualsDeclaration.decorators = decorators; - setModifiers(importEqualsDeclaration, modifiers); - importEqualsDeclaration.name = identifier; - parseExpected(56 /* EqualsToken */); - importEqualsDeclaration.moduleReference = parseModuleReference(); - parseSemicolon(); - return finishNode(importEqualsDeclaration); - } - } - // Import statement - var importDeclaration = createNode(222 /* ImportDeclaration */, fullStart); - importDeclaration.decorators = decorators; - setModifiers(importDeclaration, modifiers); - // ImportDeclaration: - // import ImportClause from ModuleSpecifier ; - // import ModuleSpecifier; - if (identifier || - token === 37 /* AsteriskToken */ || - token === 15 /* OpenBraceToken */) { - importDeclaration.importClause = parseImportClause(identifier, afterImportPos); - parseExpected(133 /* FromKeyword */); - } - importDeclaration.moduleSpecifier = parseModuleSpecifier(); - parseSemicolon(); - return finishNode(importDeclaration); - } - function parseImportClause(identifier, fullStart) { - // ImportClause: - // ImportedDefaultBinding - // NameSpaceImport - // NamedImports - // ImportedDefaultBinding, NameSpaceImport - // ImportedDefaultBinding, NamedImports - var importClause = createNode(223 /* ImportClause */, fullStart); - if (identifier) { - // ImportedDefaultBinding: - // ImportedBinding - importClause.name = identifier; - } - // 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(225 /* NamedImports */); - } - return finishNode(importClause); - } - function parseModuleReference() { - return isExternalModuleReference() - ? parseExternalModuleReference() - : parseEntityName(/*allowReservedWords*/ false); - } - function parseExternalModuleReference() { - var node = createNode(232 /* ExternalModuleReference */); - parseExpected(127 /* RequireKeyword */); - parseExpected(17 /* OpenParenToken */); - node.expression = parseModuleSpecifier(); - parseExpected(18 /* CloseParenToken */); - return finishNode(node); - } - function parseModuleSpecifier() { - // We allow arbitrary expressions here, even though the grammar only allows string - // literals. We check to ensure that it is only a string literal later in the grammar - // walker. - var result = parseExpression(); - // Ensure the string being required is in our 'identifier' table. This will ensure - // that features like 'find refs' will look inside this file when search for its name. - if (result.kind === 9 /* StringLiteral */) { - internIdentifier(result.text); - } - return result; - } - function parseNamespaceImport() { - // NameSpaceImport: - // * as ImportedBinding - var namespaceImport = createNode(224 /* NamespaceImport */); - parseExpected(37 /* AsteriskToken */); - parseExpected(116 /* AsKeyword */); - namespaceImport.name = parseIdentifier(); - return finishNode(namespaceImport); - } - function parseNamedImportsOrExports(kind) { - var node = createNode(kind); - // NamedImports: - // { } - // { ImportsList } - // { ImportsList, } - // ImportsList: - // ImportSpecifier - // ImportsList, ImportSpecifier - node.elements = parseBracketedList(21 /* ImportOrExportSpecifiers */, kind === 225 /* NamedImports */ ? parseImportSpecifier : parseExportSpecifier, 15 /* OpenBraceToken */, 16 /* CloseBraceToken */); - return finishNode(node); - } - function parseExportSpecifier() { - return parseImportOrExportSpecifier(230 /* ExportSpecifier */); - } - function parseImportSpecifier() { - return parseImportOrExportSpecifier(226 /* ImportSpecifier */); - } - function parseImportOrExportSpecifier(kind) { - var node = createNode(kind); - // ImportSpecifier: - // BindingIdentifier - // IdentifierName as BindingIdentifier - // ExportSpecififer: - // IdentifierName - // IdentifierName as IdentifierName - var checkIdentifierIsKeyword = ts.isKeyword(token) && !isIdentifier(); - var checkIdentifierStart = scanner.getTokenPos(); - var checkIdentifierEnd = scanner.getTextPos(); - var identifierName = parseIdentifierName(); - if (token === 116 /* AsKeyword */) { - node.propertyName = identifierName; - parseExpected(116 /* AsKeyword */); - checkIdentifierIsKeyword = ts.isKeyword(token) && !isIdentifier(); - checkIdentifierStart = scanner.getTokenPos(); - checkIdentifierEnd = scanner.getTextPos(); - node.name = parseIdentifierName(); - } - else { - node.name = identifierName; - } - if (kind === 226 /* ImportSpecifier */ && checkIdentifierIsKeyword) { - // Report error identifier expected - parseErrorAtPosition(checkIdentifierStart, checkIdentifierEnd - checkIdentifierStart, ts.Diagnostics.Identifier_expected); - } - return finishNode(node); - } - function parseExportDeclaration(fullStart, decorators, modifiers) { - var node = createNode(228 /* ExportDeclaration */, fullStart); - node.decorators = decorators; - setModifiers(node, modifiers); - if (parseOptional(37 /* AsteriskToken */)) { - parseExpected(133 /* FromKeyword */); - node.moduleSpecifier = parseModuleSpecifier(); - } - else { - node.exportClause = parseNamedImportsOrExports(229 /* NamedExports */); - // It is not uncommon to accidentally omit the 'from' keyword. Additionally, in editing scenarios, - // the 'from' keyword can be parsed as a named export when the export clause is unterminated (i.e. `export { from "moduleName";`) - // If we don't have a 'from' keyword, see if we have a string literal such that ASI won't take effect. - if (token === 133 /* FromKeyword */ || (token === 9 /* StringLiteral */ && !scanner.hasPrecedingLineBreak())) { - parseExpected(133 /* FromKeyword */); - node.moduleSpecifier = parseModuleSpecifier(); - } - } - parseSemicolon(); - return finishNode(node); - } - function parseExportAssignment(fullStart, decorators, modifiers) { - var node = createNode(227 /* ExportAssignment */, fullStart); - node.decorators = decorators; - setModifiers(node, modifiers); - if (parseOptional(56 /* EqualsToken */)) { - node.isExportEquals = true; - } - else { - parseExpected(77 /* DefaultKeyword */); - } - node.expression = parseAssignmentExpressionOrHigher(); - parseSemicolon(); - return finishNode(node); - } - function processReferenceComments(sourceFile) { - var triviaScanner = ts.createScanner(sourceFile.languageVersion, /*skipTrivia*/ false, 0 /* Standard */, sourceText); - var referencedFiles = []; - var amdDependencies = []; - var amdModuleName; - // Keep scanning all the leading trivia in the file until we get to something that - // isn't trivia. Any single line comment will be analyzed to see if it is a - // reference comment. - while (true) { - var kind = triviaScanner.scan(); - if (kind === 5 /* WhitespaceTrivia */ || kind === 4 /* NewLineTrivia */ || kind === 3 /* MultiLineCommentTrivia */) { - continue; - } - if (kind !== 2 /* SingleLineCommentTrivia */) { - break; - } - var range = { pos: triviaScanner.getTokenPos(), end: triviaScanner.getTextPos(), kind: triviaScanner.getToken() }; - var comment = sourceText.substring(range.pos, range.end); - var referencePathMatchResult = ts.getFileReferenceFromReferencePath(comment, range); - if (referencePathMatchResult) { - var fileReference = referencePathMatchResult.fileReference; - sourceFile.hasNoDefaultLib = referencePathMatchResult.isNoDefaultLib; - var diagnosticMessage = referencePathMatchResult.diagnosticMessage; - if (fileReference) { - referencedFiles.push(fileReference); - } - if (diagnosticMessage) { - parseDiagnostics.push(ts.createFileDiagnostic(sourceFile, range.pos, range.end - range.pos, diagnosticMessage)); - } - } - else { - var amdModuleNameRegEx = /^\/\/\/\s*".length; - return parseErrorAtPosition(start, end - start, ts.Diagnostics.Type_argument_list_cannot_be_empty); - } - } - function parseQualifiedName(left) { - var result = createNode(135 /* QualifiedName */, left.pos); - result.left = left; - result.right = parseIdentifierName(); - return finishNode(result); - } - function parseJSDocRecordType() { - var result = createNode(257 /* JSDocRecordType */); - nextToken(); - result.members = parseDelimitedList(24 /* JSDocRecordMembers */, parseJSDocRecordMember); - checkForTrailingComma(result.members); - parseExpected(16 /* CloseBraceToken */); - return finishNode(result); - } - function parseJSDocRecordMember() { - var result = createNode(258 /* JSDocRecordMember */); - result.name = parseSimplePropertyName(); - if (token === 54 /* ColonToken */) { - nextToken(); - result.type = parseJSDocType(); - } - return finishNode(result); - } - function parseJSDocNonNullableType() { - var result = createNode(256 /* JSDocNonNullableType */); - nextToken(); - result.type = parseJSDocType(); - return finishNode(result); - } - function parseJSDocTupleType() { - var result = createNode(254 /* JSDocTupleType */); - nextToken(); - result.types = parseDelimitedList(25 /* JSDocTupleTypes */, parseJSDocType); - checkForTrailingComma(result.types); - parseExpected(20 /* CloseBracketToken */); - return finishNode(result); - } - function checkForTrailingComma(list) { - if (parseDiagnostics.length === 0 && list.hasTrailingComma) { - var start = list.end - ",".length; - parseErrorAtPosition(start, ",".length, ts.Diagnostics.Trailing_comma_not_allowed); - } - } - function parseJSDocUnionType() { - var result = createNode(253 /* JSDocUnionType */); - nextToken(); - result.types = parseJSDocTypeList(parseJSDocType()); - parseExpected(18 /* CloseParenToken */); - return finishNode(result); - } - function parseJSDocTypeList(firstType) { - ts.Debug.assert(!!firstType); - var types = []; - types.pos = firstType.pos; - types.push(firstType); - while (parseOptional(47 /* BarToken */)) { - types.push(parseJSDocType()); - } - types.end = scanner.getStartPos(); - return types; - } - function parseJSDocAllType() { - var result = createNode(250 /* JSDocAllType */); - nextToken(); - return finishNode(result); - } - function parseJSDocUnknownOrNullableType() { - var pos = scanner.getStartPos(); - // skip the ? - nextToken(); - // Need to lookahead to decide if this is a nullable or unknown type. - // Here are cases where we'll pick the unknown type: - // - // Foo(?, - // { a: ? } - // Foo(?) - // Foo - // Foo(?= - // (?| - if (token === 24 /* CommaToken */ || - token === 16 /* CloseBraceToken */ || - token === 18 /* CloseParenToken */ || - token === 27 /* GreaterThanToken */ || - token === 56 /* EqualsToken */ || - token === 47 /* BarToken */) { - var result = createNode(251 /* JSDocUnknownType */, pos); - return finishNode(result); - } - else { - var result = createNode(255 /* JSDocNullableType */, pos); - result.type = parseJSDocType(); - return finishNode(result); - } - } - function parseIsolatedJSDocComment(content, start, length) { - initializeState("file.js", content, 2 /* Latest */, /*_syntaxCursor:*/ undefined); - var jsDocComment = parseJSDocComment(/*parent:*/ undefined, start, length); - var diagnostics = parseDiagnostics; - clearState(); - return jsDocComment ? { jsDocComment: jsDocComment, diagnostics: diagnostics } : undefined; - } - JSDocParser.parseIsolatedJSDocComment = parseIsolatedJSDocComment; - function parseJSDocComment(parent, start, length) { - var comment = parseJSDocCommentWorker(start, length); - if (comment) { - fixupParentReferences(comment); - comment.parent = parent; - } - return comment; - } - JSDocParser.parseJSDocComment = parseJSDocComment; - function parseJSDocCommentWorker(start, length) { - var content = sourceText; - start = start || 0; - var end = length === undefined ? content.length : start + length; - length = end - start; - ts.Debug.assert(start >= 0); - ts.Debug.assert(start <= end); - ts.Debug.assert(end <= content.length); - var tags; - var pos; - // NOTE(cyrusn): This is essentially a handwritten scanner for JSDocComments. I - // considered using an actual Scanner, but this would complicate things. The - // scanner would need to know it was in a Doc Comment. Otherwise, it would then - // produce comments *inside* the doc comment. In the end it was just easier to - // write a simple scanner rather than go that route. - if (length >= "/** */".length) { - if (content.charCodeAt(start) === 47 /* slash */ && - content.charCodeAt(start + 1) === 42 /* asterisk */ && - content.charCodeAt(start + 2) === 42 /* asterisk */ && - content.charCodeAt(start + 3) !== 42 /* asterisk */) { - // Initially we can parse out a tag. We also have seen a starting asterisk. - // This is so that /** * @type */ doesn't parse. - var canParseTag = true; - var seenAsterisk = true; - for (pos = start + "/**".length; pos < end;) { - var ch = content.charCodeAt(pos); - pos++; - if (ch === 64 /* at */ && canParseTag) { - parseTag(); - // Once we parse out a tag, we cannot keep parsing out tags on this line. - canParseTag = false; - continue; - } - if (ts.isLineBreak(ch)) { - // After a line break, we can parse a tag, and we haven't seen as asterisk - // on the next line yet. - canParseTag = true; - seenAsterisk = false; - continue; - } - if (ts.isWhiteSpace(ch)) { - // Whitespace doesn't affect any of our parsing. - continue; - } - // Ignore the first asterisk on a line. - if (ch === 42 /* asterisk */) { - if (seenAsterisk) { - // If we've already seen an asterisk, then we can no longer parse a tag - // on this line. - canParseTag = false; - } - seenAsterisk = true; - continue; - } - // Anything else is doc comment text. We can't do anything with it. Because it - // wasn't a tag, we can no longer parse a tag on this line until we hit the next - // line break. - canParseTag = false; - } - } - } - return createJSDocComment(); - function createJSDocComment() { - if (!tags) { - return undefined; - } - var result = createNode(265 /* JSDocComment */, start); - result.tags = tags; - return finishNode(result, end); - } - function skipWhitespace() { - while (pos < end && ts.isWhiteSpace(content.charCodeAt(pos))) { - pos++; - } - } - function parseTag() { - ts.Debug.assert(content.charCodeAt(pos - 1) === 64 /* at */); - var atToken = createNode(55 /* AtToken */, pos - 1); - atToken.end = pos; - var tagName = scanIdentifier(); - if (!tagName) { - return; - } - var tag = handleTag(atToken, tagName) || handleUnknownTag(atToken, tagName); - addTag(tag); - } - function handleTag(atToken, tagName) { - if (tagName) { - switch (tagName.text) { - case "param": - return handleParamTag(atToken, tagName); - case "return": - case "returns": - return handleReturnTag(atToken, tagName); - case "template": - return handleTemplateTag(atToken, tagName); - case "type": - return handleTypeTag(atToken, tagName); - } - } - return undefined; - } - function handleUnknownTag(atToken, tagName) { - var result = createNode(266 /* JSDocTag */, atToken.pos); - result.atToken = atToken; - result.tagName = tagName; - return finishNode(result, pos); - } - function addTag(tag) { - if (tag) { - if (!tags) { - tags = []; - tags.pos = tag.pos; - } - tags.push(tag); - tags.end = tag.end; - } - } - function tryParseTypeExpression() { - skipWhitespace(); - if (content.charCodeAt(pos) !== 123 /* openBrace */) { - return undefined; - } - var typeExpression = parseJSDocTypeExpression(pos, end - pos); - pos = typeExpression.end; - return typeExpression; - } - function handleParamTag(atToken, tagName) { - var typeExpression = tryParseTypeExpression(); - skipWhitespace(); - var name; - var isBracketed; - if (content.charCodeAt(pos) === 91 /* openBracket */) { - pos++; - skipWhitespace(); - name = scanIdentifier(); - isBracketed = true; - } - else { - name = scanIdentifier(); - } - if (!name) { - parseErrorAtPosition(pos, 0, ts.Diagnostics.Identifier_expected); - } - var preName, postName; - if (typeExpression) { - postName = name; - } - else { - preName = name; - } - if (!typeExpression) { - typeExpression = tryParseTypeExpression(); - } - var result = createNode(267 /* JSDocParameterTag */, atToken.pos); - result.atToken = atToken; - result.tagName = tagName; - result.preParameterName = preName; - result.typeExpression = typeExpression; - result.postParameterName = postName; - result.isBracketed = isBracketed; - return finishNode(result, pos); - } - function handleReturnTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 268 /* JSDocReturnTag */; })) { - parseErrorAtPosition(tagName.pos, pos - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); - } - var result = createNode(268 /* JSDocReturnTag */, atToken.pos); - result.atToken = atToken; - result.tagName = tagName; - result.typeExpression = tryParseTypeExpression(); - return finishNode(result, pos); - } - function handleTypeTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 269 /* JSDocTypeTag */; })) { - parseErrorAtPosition(tagName.pos, pos - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); - } - var result = createNode(269 /* JSDocTypeTag */, atToken.pos); - result.atToken = atToken; - result.tagName = tagName; - result.typeExpression = tryParseTypeExpression(); - return finishNode(result, pos); - } - function handleTemplateTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 270 /* JSDocTemplateTag */; })) { - parseErrorAtPosition(tagName.pos, pos - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); - } - var typeParameters = []; - typeParameters.pos = pos; - while (true) { - skipWhitespace(); - var startPos = pos; - var name_8 = scanIdentifier(); - if (!name_8) { - parseErrorAtPosition(startPos, 0, ts.Diagnostics.Identifier_expected); - return undefined; - } - var typeParameter = createNode(137 /* TypeParameter */, name_8.pos); - typeParameter.name = name_8; - finishNode(typeParameter, pos); - typeParameters.push(typeParameter); - skipWhitespace(); - if (content.charCodeAt(pos) !== 44 /* comma */) { - break; - } - pos++; - } - typeParameters.end = pos; - var result = createNode(270 /* JSDocTemplateTag */, atToken.pos); - result.atToken = atToken; - result.tagName = tagName; - result.typeParameters = typeParameters; - return finishNode(result, pos); - } - function scanIdentifier() { - var startPos = pos; - for (; pos < end; pos++) { - var ch = content.charCodeAt(pos); - if (pos === startPos && ts.isIdentifierStart(ch, 2 /* Latest */)) { - continue; - } - else if (pos > startPos && ts.isIdentifierPart(ch, 2 /* Latest */)) { - continue; - } - break; - } - if (startPos === pos) { - return undefined; - } - var result = createNode(69 /* Identifier */, startPos); - result.text = content.substring(startPos, pos); - return finishNode(result, pos); - } - } - JSDocParser.parseJSDocCommentWorker = parseJSDocCommentWorker; - })(JSDocParser = Parser.JSDocParser || (Parser.JSDocParser = {})); - })(Parser || (Parser = {})); - var IncrementalParser; - (function (IncrementalParser) { - function updateSourceFile(sourceFile, newText, textChangeRange, aggressiveChecks) { - aggressiveChecks = aggressiveChecks || ts.Debug.shouldAssert(2 /* Aggressive */); - checkChangeRange(sourceFile, newText, textChangeRange, aggressiveChecks); - if (ts.textChangeRangeIsUnchanged(textChangeRange)) { - // if the text didn't change, then we can just return our current source file as-is. - return sourceFile; - } - if (sourceFile.statements.length === 0) { - // If we don't have any statements in the current source file, then there's no real - // way to incrementally parse. So just do a full parse instead. - return Parser.parseSourceFile(sourceFile.fileName, newText, sourceFile.languageVersion, /*syntaxCursor*/ undefined, /*setNodeParents*/ true); - } - // Make sure we're not trying to incrementally update a source file more than once. Once - // we do an update the original source file is considered unusbale from that point onwards. - // - // This is because we do incremental parsing in-place. i.e. we take nodes from the old - // tree and give them new positions and parents. From that point on, trusting the old - // tree at all is not possible as far too much of it may violate invariants. - var incrementalSourceFile = sourceFile; - ts.Debug.assert(!incrementalSourceFile.hasBeenIncrementallyParsed); - incrementalSourceFile.hasBeenIncrementallyParsed = true; - var oldText = sourceFile.text; - var syntaxCursor = createSyntaxCursor(sourceFile); - // Make the actual change larger so that we know to reparse anything whose lookahead - // might have intersected the change. - var changeRange = extendToAffectedRange(sourceFile, textChangeRange); - checkChangeRange(sourceFile, newText, changeRange, aggressiveChecks); - // Ensure that extending the affected range only moved the start of the change range - // earlier in the file. - ts.Debug.assert(changeRange.span.start <= textChangeRange.span.start); - ts.Debug.assert(ts.textSpanEnd(changeRange.span) === ts.textSpanEnd(textChangeRange.span)); - ts.Debug.assert(ts.textSpanEnd(ts.textChangeRangeNewSpan(changeRange)) === ts.textSpanEnd(ts.textChangeRangeNewSpan(textChangeRange))); - // The is the amount the nodes after the edit range need to be adjusted. It can be - // positive (if the edit added characters), negative (if the edit deleted characters) - // or zero (if this was a pure overwrite with nothing added/removed). - var delta = ts.textChangeRangeNewSpan(changeRange).length - changeRange.span.length; - // If we added or removed characters during the edit, then we need to go and adjust all - // the nodes after the edit. Those nodes may move forward (if we inserted chars) or they - // may move backward (if we deleted chars). - // - // Doing this helps us out in two ways. First, it means that any nodes/tokens we want - // to reuse are already at the appropriate position in the new text. That way when we - // reuse them, we don't have to figure out if they need to be adjusted. Second, it makes - // it very easy to determine if we can reuse a node. If the node's position is at where - // we are in the text, then we can reuse it. Otherwise we can't. If the node's position - // is ahead of us, then we'll need to rescan tokens. If the node's position is behind - // us, then we'll need to skip it or crumble it as appropriate - // - // We will also adjust the positions of nodes that intersect the change range as well. - // By doing this, we ensure that all the positions in the old tree are consistent, not - // just the positions of nodes entirely before/after the change range. By being - // consistent, we can then easily map from positions to nodes in the old tree easily. - // - // Also, mark any syntax elements that intersect the changed span. We know, up front, - // that we cannot reuse these elements. - updateTokenPositionsAndMarkElements(incrementalSourceFile, changeRange.span.start, ts.textSpanEnd(changeRange.span), ts.textSpanEnd(ts.textChangeRangeNewSpan(changeRange)), delta, oldText, newText, aggressiveChecks); - // Now that we've set up our internal incremental state just proceed and parse the - // source file in the normal fashion. When possible the parser will retrieve and - // reuse nodes from the old tree. - // - // Note: passing in 'true' for setNodeParents is very important. When incrementally - // parsing, we will be reusing nodes from the old tree, and placing it into new - // parents. If we don't set the parents now, we'll end up with an observably - // inconsistent tree. Setting the parents on the new tree should be very fast. We - // will immediately bail out of walking any subtrees when we can see that their parents - // are already correct. - var result = Parser.parseSourceFile(sourceFile.fileName, newText, sourceFile.languageVersion, syntaxCursor, /* setParentNode */ true); - return result; - } - IncrementalParser.updateSourceFile = updateSourceFile; - function moveElementEntirelyPastChangeRange(element, isArray, delta, oldText, newText, aggressiveChecks) { - if (isArray) { - visitArray(element); - } - else { - visitNode(element); - } - return; - function visitNode(node) { - var text = ""; - if (aggressiveChecks && shouldCheckNode(node)) { - text = oldText.substring(node.pos, node.end); - } - // Ditch any existing LS children we may have created. This way we can avoid - // moving them forward. - if (node._children) { - node._children = undefined; - } - if (node.jsDocComment) { - node.jsDocComment = undefined; - } - node.pos += delta; - node.end += delta; - if (aggressiveChecks && shouldCheckNode(node)) { - ts.Debug.assert(text === newText.substring(node.pos, node.end)); - } - forEachChild(node, visitNode, visitArray); - checkNodePositions(node, aggressiveChecks); - } - function visitArray(array) { - array._children = undefined; - array.pos += delta; - array.end += delta; - for (var _i = 0; _i < array.length; _i++) { - var node = array[_i]; - visitNode(node); - } - } - } - function shouldCheckNode(node) { - switch (node.kind) { - case 9 /* StringLiteral */: - case 8 /* NumericLiteral */: - case 69 /* Identifier */: - return true; - } - return false; - } - function adjustIntersectingElement(element, changeStart, changeRangeOldEnd, changeRangeNewEnd, delta) { - ts.Debug.assert(element.end >= changeStart, "Adjusting an element that was entirely before the change range"); - ts.Debug.assert(element.pos <= changeRangeOldEnd, "Adjusting an element that was entirely after the change range"); - ts.Debug.assert(element.pos <= element.end); - // We have an element that intersects the change range in some way. It may have its - // start, or its end (or both) in the changed range. We want to adjust any part - // that intersects such that the final tree is in a consistent state. i.e. all - // chlidren have spans within the span of their parent, and all siblings are ordered - // properly. - // We may need to update both the 'pos' and the 'end' of the element. - // If the 'pos' is before the start of the change, then we don't need to touch it. - // If it isn't, then the 'pos' must be inside the change. How we update it will - // depend if delta is positive or negative. If delta is positive then we have - // something like: - // - // -------------------AAA----------------- - // -------------------BBBCCCCCCC----------------- - // - // In this case, we consider any node that started in the change range to still be - // starting at the same position. - // - // however, if the delta is negative, then we instead have something like this: - // - // -------------------XXXYYYYYYY----------------- - // -------------------ZZZ----------------- - // - // In this case, any element that started in the 'X' range will keep its position. - // However any element htat started after that will have their pos adjusted to be - // at the end of the new range. i.e. any node that started in the 'Y' range will - // be adjusted to have their start at the end of the 'Z' range. - // - // The element will keep its position if possible. Or Move backward to the new-end - // if it's in the 'Y' range. - element.pos = Math.min(element.pos, changeRangeNewEnd); - // If the 'end' is after the change range, then we always adjust it by the delta - // amount. However, if the end is in the change range, then how we adjust it - // will depend on if delta is positive or negative. If delta is positive then we - // have something like: - // - // -------------------AAA----------------- - // -------------------BBBCCCCCCC----------------- - // - // In this case, we consider any node that ended inside the change range to keep its - // end position. - // - // however, if the delta is negative, then we instead have something like this: - // - // -------------------XXXYYYYYYY----------------- - // -------------------ZZZ----------------- - // - // In this case, any element that ended in the 'X' range will keep its position. - // However any element htat ended after that will have their pos adjusted to be - // at the end of the new range. i.e. any node that ended in the 'Y' range will - // be adjusted to have their end at the end of the 'Z' range. - if (element.end >= changeRangeOldEnd) { - // Element ends after the change range. Always adjust the end pos. - element.end += delta; - } - else { - // Element ends in the change range. The element will keep its position if - // possible. Or Move backward to the new-end if it's in the 'Y' range. - element.end = Math.min(element.end, changeRangeNewEnd); - } - ts.Debug.assert(element.pos <= element.end); - if (element.parent) { - ts.Debug.assert(element.pos >= element.parent.pos); - ts.Debug.assert(element.end <= element.parent.end); - } - } - function checkNodePositions(node, aggressiveChecks) { - if (aggressiveChecks) { - var pos = node.pos; - forEachChild(node, function (child) { - ts.Debug.assert(child.pos >= pos); - pos = child.end; - }); - ts.Debug.assert(pos <= node.end); - } - } - function updateTokenPositionsAndMarkElements(sourceFile, changeStart, changeRangeOldEnd, changeRangeNewEnd, delta, oldText, newText, aggressiveChecks) { - visitNode(sourceFile); - return; - function visitNode(child) { - ts.Debug.assert(child.pos <= child.end); - if (child.pos > changeRangeOldEnd) { - // Node is entirely past the change range. We need to move both its pos and - // end, forward or backward appropriately. - moveElementEntirelyPastChangeRange(child, /*isArray*/ false, delta, oldText, newText, aggressiveChecks); - return; - } - // Check if the element intersects the change range. If it does, then it is not - // reusable. Also, we'll need to recurse to see what constituent portions we may - // be able to use. - var fullEnd = child.end; - if (fullEnd >= changeStart) { - child.intersectsChange = true; - child._children = undefined; - // Adjust the pos or end (or both) of the intersecting element accordingly. - adjustIntersectingElement(child, changeStart, changeRangeOldEnd, changeRangeNewEnd, delta); - forEachChild(child, visitNode, visitArray); - checkNodePositions(child, aggressiveChecks); - return; - } - // Otherwise, the node is entirely before the change range. No need to do anything with it. - ts.Debug.assert(fullEnd < changeStart); - } - function visitArray(array) { - ts.Debug.assert(array.pos <= array.end); - if (array.pos > changeRangeOldEnd) { - // Array is entirely after the change range. We need to move it, and move any of - // its children. - moveElementEntirelyPastChangeRange(array, /*isArray*/ true, delta, oldText, newText, aggressiveChecks); - return; - } - // Check if the element intersects the change range. If it does, then it is not - // reusable. Also, we'll need to recurse to see what constituent portions we may - // be able to use. - var fullEnd = array.end; - if (fullEnd >= changeStart) { - array.intersectsChange = true; - 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; _i < array.length; _i++) { - var node = array[_i]; - visitNode(node); - } - return; - } - // Otherwise, the array is entirely before the change range. No need to do anything with it. - ts.Debug.assert(fullEnd < changeStart); - } - } - function extendToAffectedRange(sourceFile, changeRange) { - // Consider the following code: - // void foo() { /; } - // - // If the text changes with an insertion of / just before the semicolon then we end up with: - // void foo() { //; } - // - // If we were to just use the changeRange a is, then we would not rescan the { token - // (as it does not intersect the actual original change range). Because an edit may - // change the token touching it, we actually need to look back *at least* one token so - // that the prior token sees that change. - var maxLookahead = 1; - var start = changeRange.span.start; - // the first iteration aligns us with the change start. subsequent iteration move us to - // the left by maxLookahead tokens. We only need to do this as long as we're not at the - // start of the tree. - for (var i = 0; start > 0 && i <= maxLookahead; i++) { - var nearestNode = findNearestNodeStartingBeforeOrAtPosition(sourceFile, start); - ts.Debug.assert(nearestNode.pos <= start); - var position = nearestNode.pos; - start = Math.max(0, position - 1); - } - var finalSpan = ts.createTextSpanFromBounds(start, ts.textSpanEnd(changeRange.span)); - var finalLength = changeRange.newLength + (changeRange.span.start - start); - return ts.createTextChangeRange(finalSpan, finalLength); - } - function findNearestNodeStartingBeforeOrAtPosition(sourceFile, position) { - var bestResult = sourceFile; - var lastNodeEntirelyBeforePosition; - forEachChild(sourceFile, visit); - if (lastNodeEntirelyBeforePosition) { - var lastChildOfLastEntireNodeBeforePosition = getLastChild(lastNodeEntirelyBeforePosition); - if (lastChildOfLastEntireNodeBeforePosition.pos > bestResult.pos) { - bestResult = lastChildOfLastEntireNodeBeforePosition; - } - } - return bestResult; - function getLastChild(node) { - while (true) { - var lastChild = getLastChildWorker(node); - if (lastChild) { - node = lastChild; - } - else { - return node; - } - } - } - function getLastChildWorker(node) { - var last = undefined; - forEachChild(node, function (child) { - if (ts.nodeIsPresent(child)) { - last = child; - } - }); - return last; - } - function visit(child) { - if (ts.nodeIsMissing(child)) { - // Missing nodes are effectively invisible to us. We never even consider them - // When trying to find the nearest node before us. - return; - } - // If the child intersects this position, then this node is currently the nearest - // node that starts before the position. - if (child.pos <= position) { - if (child.pos >= bestResult.pos) { - // This node starts before the position, and is closer to the position than - // the previous best node we found. It is now the new best node. - bestResult = child; - } - // Now, the node may overlap the position, or it may end entirely before the - // position. If it overlaps with the position, then either it, or one of its - // children must be the nearest node before the position. So we can just - // recurse into this child to see if we can find something better. - if (position < child.end) { - // The nearest node is either this child, or one of the children inside - // of it. We've already marked this child as the best so far. Recurse - // in case one of the children is better. - forEachChild(child, visit); - // Once we look at the children of this node, then there's no need to - // continue any further. - return true; - } - else { - ts.Debug.assert(child.end <= position); - // The child ends entirely before this position. Say you have the following - // (where $ is the position) - // - // ? $ : <...> <...> - // - // We would want to find the nearest preceding node in "complex expr 2". - // To support that, we keep track of this node, and once we're done searching - // for a best node, we recurse down this node to see if we can find a good - // result in it. - // - // This approach allows us to quickly skip over nodes that are entirely - // before the position, while still allowing us to find any nodes in the - // last one that might be what we want. - lastNodeEntirelyBeforePosition = child; - } - } - else { - ts.Debug.assert(child.pos > position); - // We're now at a node that is entirely past the position we're searching for. - // This node (and all following nodes) could never contribute to the result, - // so just skip them by returning 'true' here. - return true; - } - } - } - function checkChangeRange(sourceFile, newText, textChangeRange, aggressiveChecks) { - var oldText = sourceFile.text; - if (textChangeRange) { - ts.Debug.assert((oldText.length - textChangeRange.span.length + textChangeRange.newLength) === newText.length); - if (aggressiveChecks || ts.Debug.shouldAssert(3 /* VeryAggressive */)) { - var oldTextPrefix = oldText.substr(0, textChangeRange.span.start); - var newTextPrefix = newText.substr(0, textChangeRange.span.start); - ts.Debug.assert(oldTextPrefix === newTextPrefix); - var oldTextSuffix = oldText.substring(ts.textSpanEnd(textChangeRange.span), oldText.length); - var newTextSuffix = newText.substring(ts.textSpanEnd(ts.textChangeRangeNewSpan(textChangeRange)), newText.length); - ts.Debug.assert(oldTextSuffix === newTextSuffix); - } - } - } - function createSyntaxCursor(sourceFile) { - var currentArray = sourceFile.statements; - var currentArrayIndex = 0; - ts.Debug.assert(currentArrayIndex < currentArray.length); - var current = currentArray[currentArrayIndex]; - var lastQueriedPosition = -1 /* Value */; - return { - currentNode: function (position) { - // Only compute the current node if the position is different than the last time - // we were asked. The parser commonly asks for the node at the same position - // twice. Once to know if can read an appropriate list element at a certain point, - // and then to actually read and consume the node. - if (position !== lastQueriedPosition) { - // Much of the time the parser will need the very next node in the array that - // we just returned a node from.So just simply check for that case and move - // forward in the array instead of searching for the node again. - if (current && current.end === position && currentArrayIndex < (currentArray.length - 1)) { - currentArrayIndex++; - current = currentArray[currentArrayIndex]; - } - // If we don't have a node, or the node we have isn't in the right position, - // then try to find a viable node at the position requested. - if (!current || current.pos !== position) { - findHighestListElementThatStartsAtPosition(position); - } - } - // Cache this query so that we don't do any extra work if the parser calls back - // into us. Note: this is very common as the parser will make pairs of calls like - // 'isListElement -> parseListElement'. If we were unable to find a node when - // called with 'isListElement', we don't want to redo the work when parseListElement - // is called immediately after. - lastQueriedPosition = position; - // Either we don'd have a node, or we have a node at the position being asked for. - ts.Debug.assert(!current || current.pos === position); - return current; - } - }; - // Finds the highest element in the tree we can find that starts at the provided position. - // The element must be a direct child of some node list in the tree. This way after we - // return it, we can easily return its next sibling in the list. - function findHighestListElementThatStartsAtPosition(position) { - // Clear out any cached state about the last node we found. - currentArray = undefined; - currentArrayIndex = -1 /* Value */; - current = undefined; - // Recurse into the source file to find the highest node at this position. - forEachChild(sourceFile, visitNode, visitArray); - return; - function visitNode(node) { - if (position >= node.pos && position < node.end) { - // Position was within this node. Keep searching deeper to find the node. - forEachChild(node, visitNode, visitArray); - // don't procede any futher in the search. - return true; - } - // position wasn't in this node, have to keep searching. - return false; - } - function visitArray(array) { - if (position >= array.pos && position < array.end) { - // position was in this array. Search through this array to see if we find a - // viable element. - for (var i = 0, n = array.length; i < n; i++) { - var child = array[i]; - if (child) { - if (child.pos === position) { - // Found the right node. We're done. - currentArray = array; - currentArrayIndex = i; - current = child; - return true; - } - else { - if (child.pos < position && position < child.end) { - // Position in somewhere within this child. Search in it and - // stop searching in this array. - forEachChild(child, visitNode, visitArray); - return true; - } - } - } - } - } - // position wasn't in this array, have to keep searching. - return false; - } - } - } - var InvalidPosition; - (function (InvalidPosition) { - InvalidPosition[InvalidPosition["Value"] = -1] = "Value"; - })(InvalidPosition || (InvalidPosition = {})); - })(IncrementalParser || (IncrementalParser = {})); -})(ts || (ts = {})); -/// -/* @internal */ -var ts; -(function (ts) { - var nextSymbolId = 1; - var nextNodeId = 1; - var nextMergeId = 1; - function getNodeId(node) { - if (!node.id) - node.id = nextNodeId++; - return node.id; - } - ts.getNodeId = getNodeId; - ts.checkTime = 0; - function getSymbolId(symbol) { - if (!symbol.id) { - symbol.id = nextSymbolId++; - } - return symbol.id; - } - ts.getSymbolId = getSymbolId; - function createTypeChecker(host, produceDiagnostics) { - // Cancellation that controls whether or not we can cancel in the middle of type checking. - // In general cancelling is *not* safe for the type checker. We might be in the middle of - // computing something, and we will leave our internals in an inconsistent state. Callers - // who set the cancellation token should catch if a cancellation exception occurs, and - // should throw away and create a new TypeChecker. - // - // Currently we only support setting the cancellation token when getting diagnostics. This - // is because diagnostics can be quite expensive, and we want to allow hosts to bail out if - // they no longer need the information (for example, if the user started editing again). - var cancellationToken; - var Symbol = ts.objectAllocator.getSymbolConstructor(); - var Type = ts.objectAllocator.getTypeConstructor(); - var Signature = ts.objectAllocator.getSignatureConstructor(); - var typeCount = 0; - var symbolCount = 0; - var emptyArray = []; - var emptySymbols = {}; - var compilerOptions = host.getCompilerOptions(); - var languageVersion = compilerOptions.target || 0 /* ES3 */; - var modulekind = compilerOptions.module ? compilerOptions.module : languageVersion === 2 /* ES6 */ ? 5 /* ES6 */ : 0 /* None */; - var emitResolver = createResolver(); - var undefinedSymbol = createSymbol(4 /* Property */ | 67108864 /* Transient */, "undefined"); - var argumentsSymbol = createSymbol(4 /* Property */ | 67108864 /* Transient */, "arguments"); - var checker = { - getNodeCount: function () { return ts.sum(host.getSourceFiles(), "nodeCount"); }, - getIdentifierCount: function () { return ts.sum(host.getSourceFiles(), "identifierCount"); }, - getSymbolCount: function () { return ts.sum(host.getSourceFiles(), "symbolCount") + symbolCount; }, - getTypeCount: function () { return typeCount; }, - isUndefinedSymbol: function (symbol) { return symbol === undefinedSymbol; }, - isArgumentsSymbol: function (symbol) { return symbol === argumentsSymbol; }, - getDiagnostics: getDiagnostics, - getGlobalDiagnostics: getGlobalDiagnostics, - // The language service will always care about the narrowed type of a symbol, because that is - // the type the language says the symbol should have. - getTypeOfSymbolAtLocation: getNarrowedTypeOfSymbol, - getDeclaredTypeOfSymbol: getDeclaredTypeOfSymbol, - getPropertiesOfType: getPropertiesOfType, - getPropertyOfType: getPropertyOfType, - getSignaturesOfType: getSignaturesOfType, - getIndexTypeOfType: getIndexTypeOfType, - getBaseTypes: getBaseTypes, - getReturnTypeOfSignature: getReturnTypeOfSignature, - getSymbolsInScope: getSymbolsInScope, - getSymbolAtLocation: getSymbolAtLocation, - getShorthandAssignmentValueSymbol: getShorthandAssignmentValueSymbol, - getTypeAtLocation: getTypeOfNode, - typeToString: typeToString, - getSymbolDisplayBuilder: getSymbolDisplayBuilder, - symbolToString: symbolToString, - getAugmentedPropertiesOfType: getAugmentedPropertiesOfType, - getRootSymbols: getRootSymbols, - getContextualType: getContextualType, - getFullyQualifiedName: getFullyQualifiedName, - getResolvedSignature: getResolvedSignature, - getConstantValue: getConstantValue, - isValidPropertyAccess: isValidPropertyAccess, - getSignatureFromDeclaration: getSignatureFromDeclaration, - isImplementationOfOverload: isImplementationOfOverload, - getAliasedSymbol: resolveAlias, - getEmitResolver: getEmitResolver, - getExportsOfModule: getExportsOfModuleAsArray, - getJsxElementAttributesType: getJsxElementAttributesType, - getJsxIntrinsicTagNames: getJsxIntrinsicTagNames, - isOptionalParameter: isOptionalParameter - }; - var unknownSymbol = createSymbol(4 /* Property */ | 67108864 /* Transient */, "unknown"); - var resolvingSymbol = createSymbol(67108864 /* Transient */, "__resolving__"); - var anyType = createIntrinsicType(1 /* Any */, "any"); - var stringType = createIntrinsicType(2 /* String */, "string"); - var numberType = createIntrinsicType(4 /* Number */, "number"); - var booleanType = createIntrinsicType(8 /* Boolean */, "boolean"); - var esSymbolType = createIntrinsicType(16777216 /* ESSymbol */, "symbol"); - var voidType = createIntrinsicType(16 /* Void */, "void"); - var undefinedType = createIntrinsicType(32 /* Undefined */ | 2097152 /* ContainsUndefinedOrNull */, "undefined"); - var nullType = createIntrinsicType(64 /* Null */ | 2097152 /* ContainsUndefinedOrNull */, "null"); - var unknownType = createIntrinsicType(1 /* Any */, "unknown"); - var circularType = createIntrinsicType(1 /* Any */, "__circular__"); - var emptyObjectType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); - var emptyGenericType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); - emptyGenericType.instantiations = {}; - var anyFunctionType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); - // The anyFunctionType contains the anyFunctionType by definition. The flag is further propagated - // in getPropagatingFlagsOfTypes, and it is checked in inferFromTypes. - anyFunctionType.flags |= 8388608 /* ContainsAnyFunctionType */; - var noConstraintType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); - var anySignature = createSignature(undefined, undefined, emptyArray, anyType, undefined, 0, false, false); - var unknownSignature = createSignature(undefined, undefined, emptyArray, unknownType, undefined, 0, false, false); - var globals = {}; - var globalESSymbolConstructorSymbol; - var getGlobalPromiseConstructorSymbol; - var globalObjectType; - var globalFunctionType; - var globalArrayType; - var globalStringType; - var globalNumberType; - var globalBooleanType; - var globalRegExpType; - var globalTemplateStringsArrayType; - var globalESSymbolType; - var jsxElementType; - /** Lazily loaded, use getJsxIntrinsicElementType() */ - var jsxIntrinsicElementsType; - var globalIterableType; - var globalIteratorType; - var globalIterableIteratorType; - var anyArrayType; - var getGlobalClassDecoratorType; - var getGlobalParameterDecoratorType; - var getGlobalPropertyDecoratorType; - var getGlobalMethodDecoratorType; - var getGlobalTypedPropertyDescriptorType; - var getGlobalPromiseType; - var tryGetGlobalPromiseType; - var getGlobalPromiseLikeType; - var getInstantiatedGlobalPromiseLikeType; - var getGlobalPromiseConstructorLikeType; - var getGlobalThenableType; - var tupleTypes = {}; - var unionTypes = {}; - var intersectionTypes = {}; - var stringLiteralTypes = {}; - var emitExtends = false; - var emitDecorate = false; - var emitParam = false; - var emitAwaiter = false; - var emitGenerator = false; - var resolutionTargets = []; - var resolutionResults = []; - var resolutionPropertyNames = []; - var mergedSymbols = []; - var symbolLinks = []; - var nodeLinks = []; - var potentialThisCollisions = []; - var awaitedTypeStack = []; - var diagnostics = ts.createDiagnosticCollection(); - var primitiveTypeInfo = { - "string": { - type: stringType, - flags: 258 /* StringLike */ - }, - "number": { - type: numberType, - flags: 132 /* NumberLike */ - }, - "boolean": { - type: booleanType, - flags: 8 /* Boolean */ - }, - "symbol": { - type: esSymbolType, - flags: 16777216 /* ESSymbol */ - } - }; - var JsxNames = { - JSX: "JSX", - IntrinsicElements: "IntrinsicElements", - ElementClass: "ElementClass", - ElementAttributesPropertyNameContainer: "ElementAttributesProperty", - Element: "Element" - }; - var subtypeRelation = {}; - var assignableRelation = {}; - var identityRelation = {}; - // This is for caching the result of getSymbolDisplayBuilder. Do not access directly. - 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 = {})); - initializeTypeChecker(); - return checker; - function getEmitResolver(sourceFile, cancellationToken) { - // Ensure we have all the type information in place for this file so that all the - // emitter questions of this resolver will return the right information. - getDiagnostics(sourceFile, cancellationToken); - return emitResolver; - } - function error(location, message, arg0, arg1, arg2) { - var diagnostic = location - ? ts.createDiagnosticForNode(location, message, arg0, arg1, arg2) - : ts.createCompilerDiagnostic(message, arg0, arg1, arg2); - diagnostics.add(diagnostic); - } - function createSymbol(flags, name) { - symbolCount++; - return new Symbol(flags, name); - } - function getExcludedSymbolFlags(flags) { - var result = 0; - if (flags & 2 /* BlockScopedVariable */) - result |= 107455 /* BlockScopedVariableExcludes */; - if (flags & 1 /* FunctionScopedVariable */) - result |= 107454 /* FunctionScopedVariableExcludes */; - if (flags & 4 /* Property */) - result |= 107455 /* PropertyExcludes */; - if (flags & 8 /* EnumMember */) - result |= 107455 /* EnumMemberExcludes */; - if (flags & 16 /* Function */) - result |= 106927 /* FunctionExcludes */; - if (flags & 32 /* Class */) - result |= 899519 /* ClassExcludes */; - if (flags & 64 /* Interface */) - result |= 792960 /* InterfaceExcludes */; - if (flags & 256 /* RegularEnum */) - result |= 899327 /* RegularEnumExcludes */; - if (flags & 128 /* ConstEnum */) - result |= 899967 /* ConstEnumExcludes */; - if (flags & 512 /* ValueModule */) - result |= 106639 /* ValueModuleExcludes */; - if (flags & 8192 /* Method */) - result |= 99263 /* MethodExcludes */; - if (flags & 32768 /* GetAccessor */) - result |= 41919 /* GetAccessorExcludes */; - if (flags & 65536 /* SetAccessor */) - result |= 74687 /* SetAccessorExcludes */; - if (flags & 262144 /* TypeParameter */) - result |= 530912 /* TypeParameterExcludes */; - if (flags & 524288 /* TypeAlias */) - result |= 793056 /* TypeAliasExcludes */; - if (flags & 8388608 /* Alias */) - result |= 8388608 /* AliasExcludes */; - return result; - } - function recordMergedSymbol(target, source) { - if (!source.mergeId) - source.mergeId = nextMergeId++; - mergedSymbols[source.mergeId] = target; - } - function cloneSymbol(symbol) { - var result = createSymbol(symbol.flags | 33554432 /* Merged */, symbol.name); - result.declarations = symbol.declarations.slice(0); - result.parent = symbol.parent; - if (symbol.valueDeclaration) - result.valueDeclaration = symbol.valueDeclaration; - if (symbol.constEnumOnlyModule) - result.constEnumOnlyModule = true; - if (symbol.members) - result.members = cloneSymbolTable(symbol.members); - if (symbol.exports) - result.exports = cloneSymbolTable(symbol.exports); - recordMergedSymbol(result, symbol); - return result; - } - function mergeSymbol(target, source) { - if (!(target.flags & getExcludedSymbolFlags(source.flags))) { - if (source.flags & 512 /* ValueModule */ && target.flags & 512 /* ValueModule */ && target.constEnumOnlyModule && !source.constEnumOnlyModule) { - // reset flag when merging instantiated module into value module that has only const enums - target.constEnumOnlyModule = false; - } - target.flags |= source.flags; - if (!target.valueDeclaration && source.valueDeclaration) - target.valueDeclaration = source.valueDeclaration; - ts.forEach(source.declarations, function (node) { - target.declarations.push(node); - }); - if (source.members) { - if (!target.members) - target.members = {}; - mergeSymbolTable(target.members, source.members); - } - if (source.exports) { - if (!target.exports) - target.exports = {}; - mergeSymbolTable(target.exports, source.exports); - } - recordMergedSymbol(target, source); - } - else { - var message = target.flags & 2 /* BlockScopedVariable */ || source.flags & 2 /* BlockScopedVariable */ - ? ts.Diagnostics.Cannot_redeclare_block_scoped_variable_0 : ts.Diagnostics.Duplicate_identifier_0; - ts.forEach(source.declarations, function (node) { - error(node.name ? node.name : node, message, symbolToString(source)); - }); - ts.forEach(target.declarations, function (node) { - error(node.name ? node.name : node, message, symbolToString(source)); - }); - } - } - function cloneSymbolTable(symbolTable) { - var result = {}; - for (var id in symbolTable) { - if (ts.hasProperty(symbolTable, id)) { - result[id] = symbolTable[id]; - } - } - return result; - } - function mergeSymbolTable(target, source) { - for (var id in source) { - if (ts.hasProperty(source, id)) { - if (!ts.hasProperty(target, id)) { - target[id] = source[id]; - } - else { - var symbol = target[id]; - if (!(symbol.flags & 33554432 /* Merged */)) { - target[id] = symbol = cloneSymbol(symbol); - } - mergeSymbol(symbol, source[id]); - } - } - } - } - function getSymbolLinks(symbol) { - if (symbol.flags & 67108864 /* Transient */) - return symbol; - var id = getSymbolId(symbol); - return symbolLinks[id] || (symbolLinks[id] = {}); - } - function getNodeLinks(node) { - var nodeId = getNodeId(node); - return nodeLinks[nodeId] || (nodeLinks[nodeId] = {}); - } - function getSourceFile(node) { - return ts.getAncestor(node, 248 /* SourceFile */); - } - function isGlobalSourceFile(node) { - return node.kind === 248 /* SourceFile */ && !ts.isExternalModule(node); - } - function getSymbol(symbols, name, meaning) { - if (meaning && ts.hasProperty(symbols, name)) { - var symbol = symbols[name]; - ts.Debug.assert((symbol.flags & 16777216 /* Instantiated */) === 0, "Should never get an instantiated symbol here."); - if (symbol.flags & meaning) { - return symbol; - } - if (symbol.flags & 8388608 /* Alias */) { - var target = resolveAlias(symbol); - // Unknown symbol means an error occurred in alias resolution, treat it as positive answer to avoid cascading errors - if (target === unknownSymbol || target.flags & meaning) { - return symbol; - } - } - } - // return undefined if we can't find a symbol. - } - function isBlockScopedNameDeclaredBeforeUse(declaration, usage) { - var declarationFile = ts.getSourceFileOfNode(declaration); - var useFile = ts.getSourceFileOfNode(usage); - if (declarationFile !== useFile) { - if (modulekind || (!compilerOptions.outFile && !compilerOptions.out)) { - // nodes are in different files and order cannot be determines - return true; - } - var sourceFiles = host.getSourceFiles(); - return ts.indexOf(sourceFiles, declarationFile) <= ts.indexOf(sourceFiles, useFile); - } - if (declaration.pos <= usage.pos) { - // declaration is before usage - // still might be illegal if usage is in the initializer of the variable declaration - return declaration.kind !== 211 /* VariableDeclaration */ || - !isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage); - } - // declaration is after usage - // can be legal if usage is deferred (i.e. inside function or in initializer of instance property) - return isUsedInFunctionOrNonStaticProperty(declaration, usage); - function isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage) { - var container = ts.getEnclosingBlockScopeContainer(declaration); - if (declaration.parent.parent.kind === 193 /* VariableStatement */ || - declaration.parent.parent.kind === 199 /* ForStatement */) { - // variable statement/for statement case, - // use site should not be inside variable declaration (initializer of declaration or binding element) - return isSameScopeDescendentOf(usage, declaration, container); - } - else if (declaration.parent.parent.kind === 201 /* ForOfStatement */ || - declaration.parent.parent.kind === 200 /* ForInStatement */) { - // ForIn/ForOf case - use site should not be used in expression part - var expression = declaration.parent.parent.expression; - return isSameScopeDescendentOf(usage, expression, container); - } - } - function isUsedInFunctionOrNonStaticProperty(declaration, usage) { - var container = ts.getEnclosingBlockScopeContainer(declaration); - var current = usage; - while (current) { - if (current === container) { - return false; - } - if (ts.isFunctionLike(current)) { - return true; - } - var initializerOfNonStaticProperty = current.parent && - current.parent.kind === 141 /* PropertyDeclaration */ && - (current.parent.flags & 128 /* Static */) === 0 && - current.parent.initializer === current; - if (initializerOfNonStaticProperty) { - return true; - } - current = current.parent; - } - return false; - } - } - // Resolve a given name for a given meaning at a given location. An error is reported if the name was not found and - // the nameNotFoundMessage argument is not undefined. Returns the resolved symbol, or undefined if no symbol with - // the given name can be found. - function resolveName(location, name, meaning, nameNotFoundMessage, nameArg) { - var result; - var lastLocation; - var propertyWithInvalidInitializer; - var errorLocation = location; - var grandparent; - loop: while (location) { - // Locals of a source file are not in scope (because they get merged into the global symbol table) - if (location.locals && !isGlobalSourceFile(location)) { - if (result = getSymbol(location.locals, name, meaning)) { - // Type parameters of a function are in scope in the entire function declaration, including the parameter - // list and return type. However, local types are only in scope in the function body. - if (!(meaning & 793056 /* Type */) || - !(result.flags & (793056 /* Type */ & ~262144 /* TypeParameter */)) || - !ts.isFunctionLike(location) || - lastLocation === location.body) { - break loop; - } - result = undefined; - } - } - switch (location.kind) { - case 248 /* SourceFile */: - if (!ts.isExternalModule(location)) - break; - case 218 /* ModuleDeclaration */: - var moduleExports = getSymbolOfNode(location).exports; - if (location.kind === 248 /* SourceFile */ || - (location.kind === 218 /* ModuleDeclaration */ && location.name.kind === 9 /* StringLiteral */)) { - // It's an external module. Because of module/namespace merging, a module's exports are in scope, - // yet we never want to treat an export specifier as putting a member in scope. Therefore, - // if the name we find is purely an export specifier, it is not actually considered in scope. - // Two things to note about this: - // 1. We have to check this without calling getSymbol. The problem with calling getSymbol - // on an export specifier is that it might find the export specifier itself, and try to - // resolve it as an alias. This will cause the checker to consider the export specifier - // a circular alias reference when it might not be. - // 2. We check === SymbolFlags.Alias in order to check that the symbol is *purely* - // an alias. If we used &, we'd be throwing out symbols that have non alias aspects, - // which is not the desired behavior. - if (ts.hasProperty(moduleExports, name) && - moduleExports[name].flags === 8388608 /* Alias */ && - ts.getDeclarationOfKind(moduleExports[name], 230 /* ExportSpecifier */)) { - break; - } - result = moduleExports["default"]; - var localSymbol = ts.getLocalSymbolForExportDefault(result); - if (result && localSymbol && (result.flags & meaning) && localSymbol.name === name) { - break loop; - } - result = undefined; - } - if (result = getSymbol(moduleExports, name, meaning & 8914931 /* ModuleMember */)) { - break loop; - } - break; - case 217 /* EnumDeclaration */: - if (result = getSymbol(getSymbolOfNode(location).exports, name, meaning & 8 /* EnumMember */)) { - break loop; - } - break; - case 141 /* PropertyDeclaration */: - case 140 /* PropertySignature */: - // TypeScript 1.0 spec (April 2014): 8.4.1 - // Initializer expressions for instance member variables are evaluated in the scope - // of the class constructor body but are not permitted to reference parameters or - // local variables of the constructor. This effectively means that entities from outer scopes - // by the same name as a constructor parameter or local variable are inaccessible - // in initializer expressions for instance member variables. - if (ts.isClassLike(location.parent) && !(location.flags & 128 /* Static */)) { - var ctor = findConstructorDeclaration(location.parent); - if (ctor && ctor.locals) { - if (getSymbol(ctor.locals, name, meaning & 107455 /* Value */)) { - // Remember the property node, it will be used later to report appropriate error - propertyWithInvalidInitializer = location; - } - } - } - break; - case 214 /* ClassDeclaration */: - case 186 /* ClassExpression */: - case 215 /* InterfaceDeclaration */: - if (result = getSymbol(getSymbolOfNode(location).members, name, meaning & 793056 /* Type */)) { - if (lastLocation && lastLocation.flags & 128 /* Static */) { - // TypeScript 1.0 spec (April 2014): 3.4.1 - // The scope of a type parameter extends over the entire declaration with which the type - // parameter list is associated, with the exception of static member declarations in classes. - error(errorLocation, ts.Diagnostics.Static_members_cannot_reference_class_type_parameters); - return undefined; - } - break loop; - } - if (location.kind === 186 /* ClassExpression */ && meaning & 32 /* Class */) { - var className = location.name; - if (className && name === className.text) { - result = location.symbol; - break loop; - } - } - break; - // It is not legal to reference a class's own type parameters from a computed property name that - // belongs to the class. For example: - // - // function foo() { return '' } - // class C { // <-- Class's own type parameter T - // [foo()]() { } // <-- Reference to T from class's own computed property - // } - // - case 136 /* ComputedPropertyName */: - grandparent = location.parent.parent; - if (ts.isClassLike(grandparent) || grandparent.kind === 215 /* InterfaceDeclaration */) { - // A reference to this grandparent's type parameters would be an error - if (result = getSymbol(getSymbolOfNode(grandparent).members, name, meaning & 793056 /* Type */)) { - error(errorLocation, ts.Diagnostics.A_computed_property_name_cannot_reference_a_type_parameter_from_its_containing_type); - return undefined; - } - } - break; - case 143 /* MethodDeclaration */: - case 142 /* MethodSignature */: - case 144 /* Constructor */: - case 145 /* GetAccessor */: - case 146 /* SetAccessor */: - case 213 /* FunctionDeclaration */: - case 174 /* ArrowFunction */: - if (meaning & 3 /* Variable */ && name === "arguments") { - result = argumentsSymbol; - break loop; - } - break; - case 173 /* FunctionExpression */: - if (meaning & 3 /* Variable */ && name === "arguments") { - result = argumentsSymbol; - break loop; - } - if (meaning & 16 /* Function */) { - var functionName = location.name; - if (functionName && name === functionName.text) { - result = location.symbol; - break loop; - } - } - break; - case 139 /* Decorator */: - // Decorators are resolved at the class declaration. Resolving at the parameter - // or member would result in looking up locals in the method. - // - // function y() {} - // class C { - // method(@y x, y) {} // <-- decorator y should be resolved at the class declaration, not the parameter. - // } - // - if (location.parent && location.parent.kind === 138 /* Parameter */) { - location = location.parent; - } - // - // function y() {} - // class C { - // @y method(x, y) {} // <-- decorator y should be resolved at the class declaration, not the method. - // } - // - if (location.parent && ts.isClassElement(location.parent)) { - location = location.parent; - } - break; - } - lastLocation = location; - location = location.parent; - } - if (!result) { - result = getSymbol(globals, name, meaning); - } - if (!result) { - if (nameNotFoundMessage) { - error(errorLocation, nameNotFoundMessage, typeof nameArg === "string" ? nameArg : ts.declarationNameToString(nameArg)); - } - return undefined; - } - // Perform extra checks only if error reporting was requested - if (nameNotFoundMessage) { - if (propertyWithInvalidInitializer) { - // We have a match, but the reference occurred within a property initializer and the identifier also binds - // to a local variable in the constructor where the code will be emitted. - var propertyName = propertyWithInvalidInitializer.name; - error(errorLocation, ts.Diagnostics.Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor, ts.declarationNameToString(propertyName), typeof nameArg === "string" ? nameArg : ts.declarationNameToString(nameArg)); - return undefined; - } - // Only check for block-scoped variable if we are looking for the - // name with variable meaning - // For example, - // declare module foo { - // interface bar {} - // } - // let foo/*1*/: foo/*2*/.bar; - // The foo at /*1*/ and /*2*/ will share same symbol with two meaning - // block - scope variable and namespace module. However, only when we - // try to resolve name in /*1*/ which is used in variable position, - // we want to check for block- scoped - if (meaning & 2 /* BlockScopedVariable */) { - var exportOrLocalSymbol = getExportSymbolOfValueSymbolIfExported(result); - if (exportOrLocalSymbol.flags & 2 /* BlockScopedVariable */) { - checkResolvedBlockScopedVariable(exportOrLocalSymbol, errorLocation); - } - } - } - return result; - } - function checkResolvedBlockScopedVariable(result, errorLocation) { - ts.Debug.assert((result.flags & 2 /* BlockScopedVariable */) !== 0); - // 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 (!isBlockScopedNameDeclaredBeforeUse(ts.getAncestor(declaration, 211 /* VariableDeclaration */), errorLocation)) { - error(errorLocation, ts.Diagnostics.Block_scoped_variable_0_used_before_its_declaration, ts.declarationNameToString(declaration.name)); - } - } - /* Starting from 'initial' node walk up the parent chain until 'stopAt' node is reached. - * If at any point current node is equal to 'parent' node - return true. - * Return false if 'stopAt' node is reached or isFunctionLike(current) === true. - */ - function isSameScopeDescendentOf(initial, parent, stopAt) { - if (!parent) { - return false; - } - for (var current = initial; current && current !== stopAt && !ts.isFunctionLike(current); current = current.parent) { - if (current === parent) { - return true; - } - } - return false; - } - function getAnyImportSyntax(node) { - if (ts.isAliasSymbolDeclaration(node)) { - if (node.kind === 221 /* ImportEqualsDeclaration */) { - return node; - } - while (node && node.kind !== 222 /* ImportDeclaration */) { - node = node.parent; - } - return node; - } - } - function getDeclarationOfAliasSymbol(symbol) { - return ts.forEach(symbol.declarations, function (d) { return ts.isAliasSymbolDeclaration(d) ? d : undefined; }); - } - function getTargetOfImportEqualsDeclaration(node) { - if (node.moduleReference.kind === 232 /* ExternalModuleReference */) { - return resolveExternalModuleSymbol(resolveExternalModuleName(node, ts.getExternalModuleImportEqualsDeclarationExpression(node))); - } - return getSymbolOfPartOfRightHandSideOfImportEquals(node.moduleReference, node); - } - function getTargetOfImportClause(node) { - var moduleSymbol = resolveExternalModuleName(node, node.parent.moduleSpecifier); - if (moduleSymbol) { - var exportDefaultSymbol = resolveSymbol(moduleSymbol.exports["default"]); - if (!exportDefaultSymbol) { - error(node.name, ts.Diagnostics.Module_0_has_no_default_export, symbolToString(moduleSymbol)); - } - return exportDefaultSymbol; - } - } - function getTargetOfNamespaceImport(node) { - var moduleSpecifier = node.parent.parent.moduleSpecifier; - return resolveESModuleSymbol(resolveExternalModuleName(node, moduleSpecifier), moduleSpecifier); - } - function getMemberOfModuleVariable(moduleSymbol, name) { - if (moduleSymbol.flags & 3 /* Variable */) { - var typeAnnotation = moduleSymbol.valueDeclaration.type; - if (typeAnnotation) { - return getPropertyOfType(getTypeFromTypeNode(typeAnnotation), name); - } - } - } - // This function creates a synthetic symbol that combines the value side of one symbol with the - // type/namespace side of another symbol. Consider this example: - // - // declare module graphics { - // interface Point { - // x: number; - // y: number; - // } - // } - // declare var graphics: { - // Point: new (x: number, y: number) => graphics.Point; - // } - // declare module "graphics" { - // export = graphics; - // } - // - // An 'import { Point } from "graphics"' needs to create a symbol that combines the value side 'Point' - // property with the type/namespace side interface 'Point'. - function combineValueAndTypeSymbols(valueSymbol, typeSymbol) { - if (valueSymbol.flags & (793056 /* Type */ | 1536 /* Namespace */)) { - return valueSymbol; - } - var result = createSymbol(valueSymbol.flags | typeSymbol.flags, valueSymbol.name); - result.declarations = ts.concatenate(valueSymbol.declarations, typeSymbol.declarations); - result.parent = valueSymbol.parent || typeSymbol.parent; - if (valueSymbol.valueDeclaration) - result.valueDeclaration = valueSymbol.valueDeclaration; - if (typeSymbol.members) - result.members = typeSymbol.members; - if (valueSymbol.exports) - result.exports = valueSymbol.exports; - return result; - } - function getExportOfModule(symbol, name) { - if (symbol.flags & 1536 /* Module */) { - var exports = getExportsOfSymbol(symbol); - if (ts.hasProperty(exports, name)) { - return resolveSymbol(exports[name]); - } - } - } - function getPropertyOfVariable(symbol, name) { - if (symbol.flags & 3 /* Variable */) { - var typeAnnotation = symbol.valueDeclaration.type; - if (typeAnnotation) { - return resolveSymbol(getPropertyOfType(getTypeFromTypeNode(typeAnnotation), name)); - } - } - } - function getExternalModuleMember(node, specifier) { - var moduleSymbol = resolveExternalModuleName(node, node.moduleSpecifier); - var targetSymbol = resolveESModuleSymbol(moduleSymbol, node.moduleSpecifier); - if (targetSymbol) { - var name_9 = specifier.propertyName || specifier.name; - if (name_9.text) { - var symbolFromModule = getExportOfModule(targetSymbol, name_9.text); - var symbolFromVariable = getPropertyOfVariable(targetSymbol, name_9.text); - var symbol = symbolFromModule && symbolFromVariable ? - combineValueAndTypeSymbols(symbolFromVariable, symbolFromModule) : - symbolFromModule || symbolFromVariable; - if (!symbol) { - error(name_9, ts.Diagnostics.Module_0_has_no_exported_member_1, getFullyQualifiedName(moduleSymbol), ts.declarationNameToString(name_9)); - } - return symbol; - } - } - } - function getTargetOfImportSpecifier(node) { - return getExternalModuleMember(node.parent.parent.parent, node); - } - function getTargetOfExportSpecifier(node) { - return node.parent.parent.moduleSpecifier ? - getExternalModuleMember(node.parent.parent, node) : - resolveEntityName(node.propertyName || node.name, 107455 /* Value */ | 793056 /* Type */ | 1536 /* Namespace */); - } - function getTargetOfExportAssignment(node) { - return resolveEntityName(node.expression, 107455 /* Value */ | 793056 /* Type */ | 1536 /* Namespace */); - } - function getTargetOfAliasDeclaration(node) { - switch (node.kind) { - case 221 /* ImportEqualsDeclaration */: - return getTargetOfImportEqualsDeclaration(node); - case 223 /* ImportClause */: - return getTargetOfImportClause(node); - case 224 /* NamespaceImport */: - return getTargetOfNamespaceImport(node); - case 226 /* ImportSpecifier */: - return getTargetOfImportSpecifier(node); - case 230 /* ExportSpecifier */: - return getTargetOfExportSpecifier(node); - case 227 /* ExportAssignment */: - return getTargetOfExportAssignment(node); - } - } - function resolveSymbol(symbol) { - return symbol && symbol.flags & 8388608 /* Alias */ && !(symbol.flags & (107455 /* Value */ | 793056 /* Type */ | 1536 /* Namespace */)) ? resolveAlias(symbol) : symbol; - } - function resolveAlias(symbol) { - ts.Debug.assert((symbol.flags & 8388608 /* Alias */) !== 0, "Should only get Alias here."); - var links = getSymbolLinks(symbol); - if (!links.target) { - links.target = resolvingSymbol; - var node = getDeclarationOfAliasSymbol(symbol); - var target = getTargetOfAliasDeclaration(node); - if (links.target === resolvingSymbol) { - links.target = target || unknownSymbol; - } - else { - error(node, ts.Diagnostics.Circular_definition_of_import_alias_0, symbolToString(symbol)); - } - } - else if (links.target === resolvingSymbol) { - links.target = unknownSymbol; - } - return links.target; - } - function markExportAsReferenced(node) { - var symbol = getSymbolOfNode(node); - var target = resolveAlias(symbol); - if (target) { - var markAlias = (target === unknownSymbol && compilerOptions.isolatedModules) || - (target !== unknownSymbol && (target.flags & 107455 /* Value */) && !isConstEnumOrConstEnumOnlyModule(target)); - if (markAlias) { - markAliasSymbolAsReferenced(symbol); - } - } - } - // When an alias symbol is referenced, we need to mark the entity it references as referenced and in turn repeat that until - // we reach a non-alias or an exported entity (which is always considered referenced). We do this by checking the target of - // the alias as an expression (which recursively takes us back here if the target references another alias). - function markAliasSymbolAsReferenced(symbol) { - var links = getSymbolLinks(symbol); - if (!links.referenced) { - links.referenced = true; - var node = getDeclarationOfAliasSymbol(symbol); - if (node.kind === 227 /* ExportAssignment */) { - // export default - checkExpressionCached(node.expression); - } - else if (node.kind === 230 /* ExportSpecifier */) { - // export { } or export { as foo } - checkExpressionCached(node.propertyName || node.name); - } - else if (ts.isInternalModuleImportEqualsDeclaration(node)) { - // import foo = - checkExpressionCached(node.moduleReference); - } - } - } - // This function is only for imports with entity names - function getSymbolOfPartOfRightHandSideOfImportEquals(entityName, importDeclaration) { - if (!importDeclaration) { - importDeclaration = ts.getAncestor(entityName, 221 /* ImportEqualsDeclaration */); - ts.Debug.assert(importDeclaration !== undefined); - } - // There are three things we might try to look for. In the following examples, - // 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)) { - entityName = entityName.parent; - } - // Check for case 1 and 3 in the above example - if (entityName.kind === 69 /* Identifier */ || entityName.parent.kind === 135 /* QualifiedName */) { - return resolveEntityName(entityName, 1536 /* Namespace */); - } - else { - // Case 2 in above example - // entityName.kind could be a QualifiedName or a Missing identifier - ts.Debug.assert(entityName.parent.kind === 221 /* ImportEqualsDeclaration */); - return resolveEntityName(entityName, 107455 /* Value */ | 793056 /* Type */ | 1536 /* Namespace */); - } - } - function getFullyQualifiedName(symbol) { - return symbol.parent ? getFullyQualifiedName(symbol.parent) + "." + symbolToString(symbol) : symbolToString(symbol); - } - // Resolves a qualified name and any involved aliases - function resolveEntityName(name, meaning, ignoreErrors) { - if (ts.nodeIsMissing(name)) { - return undefined; - } - var symbol; - if (name.kind === 69 /* Identifier */) { - var message = meaning === 1536 /* Namespace */ ? ts.Diagnostics.Cannot_find_namespace_0 : ts.Diagnostics.Cannot_find_name_0; - symbol = resolveName(name, name.text, meaning, ignoreErrors ? undefined : message, name); - if (!symbol) { - return undefined; - } - } - else if (name.kind === 135 /* QualifiedName */ || name.kind === 166 /* PropertyAccessExpression */) { - var left = name.kind === 135 /* QualifiedName */ ? name.left : name.expression; - var right = name.kind === 135 /* QualifiedName */ ? name.right : name.name; - var namespace = resolveEntityName(left, 1536 /* Namespace */, ignoreErrors); - if (!namespace || namespace === unknownSymbol || ts.nodeIsMissing(right)) { - return undefined; - } - symbol = getSymbol(getExportsOfSymbol(namespace), right.text, meaning); - if (!symbol) { - if (!ignoreErrors) { - error(right, ts.Diagnostics.Module_0_has_no_exported_member_1, getFullyQualifiedName(namespace), ts.declarationNameToString(right)); - } - return undefined; - } - } - else { - ts.Debug.fail("Unknown entity name kind."); - } - ts.Debug.assert((symbol.flags & 16777216 /* Instantiated */) === 0, "Should never get an instantiated symbol here."); - return symbol.flags & meaning ? symbol : resolveAlias(symbol); - } - function resolveExternalModuleName(location, moduleReferenceExpression) { - if (moduleReferenceExpression.kind !== 9 /* StringLiteral */) { - return; - } - var moduleReferenceLiteral = moduleReferenceExpression; - var searchPath = ts.getDirectoryPath(getSourceFile(location).fileName); - // Module names are escaped in our symbol table. However, string literal values aren't. - // Escape the name in the "require(...)" clause to ensure we find the right symbol. - var moduleName = ts.escapeIdentifier(moduleReferenceLiteral.text); - if (moduleName === undefined) { - return; - } - var isRelative = ts.isExternalModuleNameRelative(moduleName); - if (!isRelative) { - var symbol = getSymbol(globals, "\"" + moduleName + "\"", 512 /* ValueModule */); - if (symbol) { - return symbol; - } - } - var resolvedModule = ts.getResolvedModule(getSourceFile(location), moduleReferenceLiteral.text); - var sourceFile = resolvedModule && host.getSourceFile(resolvedModule.resolvedFileName); - if (sourceFile) { - if (sourceFile.symbol) { - return sourceFile.symbol; - } - error(moduleReferenceLiteral, ts.Diagnostics.File_0_is_not_a_module, sourceFile.fileName); - return; - } - error(moduleReferenceLiteral, ts.Diagnostics.Cannot_find_module_0, moduleName); - } - // An external module with an 'export =' declaration resolves to the target of the 'export =' declaration, - // and an external module with no 'export =' declaration resolves to the module itself. - function resolveExternalModuleSymbol(moduleSymbol) { - return moduleSymbol && resolveSymbol(moduleSymbol.exports["export="]) || moduleSymbol; - } - // An external module with an 'export =' declaration may be referenced as an ES6 module provided the 'export =' - // references a symbol that is at least declared as a module or a variable. The target of the 'export =' may - // combine other declarations with the module or variable (e.g. a class/module, function/module, interface/variable). - function resolveESModuleSymbol(moduleSymbol, moduleReferenceExpression) { - var symbol = resolveExternalModuleSymbol(moduleSymbol); - if (symbol && !(symbol.flags & (1536 /* Module */ | 3 /* Variable */))) { - error(moduleReferenceExpression, ts.Diagnostics.Module_0_resolves_to_a_non_module_entity_and_cannot_be_imported_using_this_construct, symbolToString(moduleSymbol)); - symbol = undefined; - } - return symbol; - } - function getExportAssignmentSymbol(moduleSymbol) { - return moduleSymbol.exports["export="]; - } - function getExportsOfModuleAsArray(moduleSymbol) { - return symbolsToArray(getExportsOfModule(moduleSymbol)); - } - function getExportsOfSymbol(symbol) { - return symbol.flags & 1536 /* Module */ ? getExportsOfModule(symbol) : symbol.exports || emptySymbols; - } - function getExportsOfModule(moduleSymbol) { - var links = getSymbolLinks(moduleSymbol); - return links.resolvedExports || (links.resolvedExports = getExportsForModule(moduleSymbol)); - } - function extendExportSymbols(target, source) { - for (var id in source) { - if (id !== "default" && !ts.hasProperty(target, id)) { - target[id] = source[id]; - } - } - } - function getExportsForModule(moduleSymbol) { - var result; - var visitedSymbols = []; - visit(moduleSymbol); - return result || 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. - function visit(symbol) { - if (symbol && symbol.flags & 1952 /* HasExports */ && !ts.contains(visitedSymbols, symbol)) { - visitedSymbols.push(symbol); - if (symbol !== moduleSymbol) { - if (!result) { - result = cloneSymbolTable(moduleSymbol.exports); - } - extendExportSymbols(result, symbol.exports); - } - // All export * declarations are collected in an __export symbol by the binder - var exportStars = symbol.exports["__export"]; - if (exportStars) { - for (var _i = 0, _a = exportStars.declarations; _i < _a.length; _i++) { - var node = _a[_i]; - visit(resolveExternalModuleName(node, node.moduleSpecifier)); - } - } - } - } - } - function getMergedSymbol(symbol) { - var merged; - return symbol && symbol.mergeId && (merged = mergedSymbols[symbol.mergeId]) ? merged : symbol; - } - function getSymbolOfNode(node) { - return getMergedSymbol(node.symbol); - } - function getParentOfSymbol(symbol) { - return getMergedSymbol(symbol.parent); - } - function getExportSymbolOfValueSymbolIfExported(symbol) { - return symbol && (symbol.flags & 1048576 /* ExportValue */) !== 0 - ? getMergedSymbol(symbol.exportSymbol) - : symbol; - } - function symbolIsValue(symbol) { - // If it is an instantiated symbol, then it is a value if the symbol it is an - // instantiation of is a value. - if (symbol.flags & 16777216 /* Instantiated */) { - return symbolIsValue(getSymbolLinks(symbol).target); - } - // If the symbol has the value flag, it is trivially a value. - if (symbol.flags & 107455 /* Value */) { - return true; - } - // If it is an alias, then it is a value if the symbol it resolves to is a value. - if (symbol.flags & 8388608 /* Alias */) { - return (resolveAlias(symbol).flags & 107455 /* Value */) !== 0; - } - return false; - } - function findConstructorDeclaration(node) { - var members = node.members; - for (var _i = 0; _i < members.length; _i++) { - var member = members[_i]; - if (member.kind === 144 /* Constructor */ && ts.nodeIsPresent(member.body)) { - return member; - } - } - } - function createType(flags) { - var result = new Type(checker, flags); - result.id = typeCount++; - return result; - } - function createIntrinsicType(kind, intrinsicName) { - var type = createType(kind); - type.intrinsicName = intrinsicName; - return type; - } - function createObjectType(kind, symbol) { - var type = createType(kind); - type.symbol = symbol; - return type; - } - // A reserved member name starts with two underscores, but the third character cannot be an underscore - // or the @ symbol. A third underscore indicates an escaped form of an identifer that started - // with at least two underscores. The @ character indicates that the name is denoted by a well known ES - // Symbol instance. - function isReservedMemberName(name) { - return name.charCodeAt(0) === 95 /* _ */ && - name.charCodeAt(1) === 95 /* _ */ && - name.charCodeAt(2) !== 95 /* _ */ && - name.charCodeAt(2) !== 64 /* at */; - } - function getNamedMembers(members) { - var result; - for (var id in members) { - if (ts.hasProperty(members, id)) { - if (!isReservedMemberName(id)) { - if (!result) - result = []; - var symbol = members[id]; - if (symbolIsValue(symbol)) { - result.push(symbol); - } - } - } - } - return result || emptyArray; - } - function setObjectTypeMembers(type, members, callSignatures, constructSignatures, stringIndexType, numberIndexType) { - type.members = members; - type.properties = getNamedMembers(members); - type.callSignatures = callSignatures; - type.constructSignatures = constructSignatures; - if (stringIndexType) - type.stringIndexType = stringIndexType; - if (numberIndexType) - type.numberIndexType = numberIndexType; - return type; - } - function createAnonymousType(symbol, members, callSignatures, constructSignatures, stringIndexType, numberIndexType) { - return setObjectTypeMembers(createObjectType(65536 /* Anonymous */, symbol), members, callSignatures, constructSignatures, stringIndexType, numberIndexType); - } - function forEachSymbolTableInScope(enclosingDeclaration, callback) { - var result; - for (var location_1 = enclosingDeclaration; location_1; location_1 = location_1.parent) { - // Locals of a source file are not in scope (because they get merged into the global symbol table) - if (location_1.locals && !isGlobalSourceFile(location_1)) { - if (result = callback(location_1.locals)) { - return result; - } - } - switch (location_1.kind) { - case 248 /* SourceFile */: - if (!ts.isExternalModule(location_1)) { - break; - } - case 218 /* ModuleDeclaration */: - if (result = callback(getSymbolOfNode(location_1).exports)) { - return result; - } - break; - case 214 /* ClassDeclaration */: - case 215 /* InterfaceDeclaration */: - if (result = callback(getSymbolOfNode(location_1).members)) { - return result; - } - break; - } - } - return callback(globals); - } - function getQualifiedLeftMeaning(rightMeaning) { - // If we are looking in value space, the parent meaning is value, other wise it is namespace - return rightMeaning === 107455 /* Value */ ? 107455 /* Value */ : 1536 /* Namespace */; - } - function getAccessibleSymbolChain(symbol, enclosingDeclaration, meaning, useOnlyExternalAliasing) { - function getAccessibleSymbolChainFromSymbolTable(symbols) { - function canQualifySymbol(symbolFromSymbolTable, meaning) { - // If the symbol is equivalent and doesn't need further qualification, this symbol is accessible - if (!needsQualification(symbolFromSymbolTable, enclosingDeclaration, meaning)) { - return true; - } - // If symbol needs qualification, make sure that parent is accessible, if it is then this symbol is accessible too - var accessibleParent = getAccessibleSymbolChain(symbolFromSymbolTable.parent, enclosingDeclaration, getQualifiedLeftMeaning(meaning), useOnlyExternalAliasing); - return !!accessibleParent; - } - function isAccessible(symbolFromSymbolTable, resolvedAliasSymbol) { - if (symbol === (resolvedAliasSymbol || symbolFromSymbolTable)) { - // if the symbolFromSymbolTable is not external module (it could be if it was determined as ambient external module and would be in globals table) - // and if symbolfrom symbolTable or alias resolution matches the symbol, - // check the symbol can be qualified, it is only then this symbol is accessible - return !ts.forEach(symbolFromSymbolTable.declarations, hasExternalModuleSymbol) && - canQualifySymbol(symbolFromSymbolTable, meaning); - } - } - // If symbol is directly available by its name in the symbol table - if (isAccessible(ts.lookUp(symbols, symbol.name))) { - return [symbol]; - } - // Check if symbol is any of the alias - return ts.forEachValue(symbols, function (symbolFromSymbolTable) { - if (symbolFromSymbolTable.flags & 8388608 /* Alias */ - && symbolFromSymbolTable.name !== "export=" - && !ts.getDeclarationOfKind(symbolFromSymbolTable, 230 /* ExportSpecifier */)) { - if (!useOnlyExternalAliasing || - // Is this external alias, then use it to name - ts.forEach(symbolFromSymbolTable.declarations, ts.isExternalModuleImportEqualsDeclaration)) { - var resolvedImportedSymbol = resolveAlias(symbolFromSymbolTable); - if (isAccessible(symbolFromSymbolTable, resolveAlias(symbolFromSymbolTable))) { - return [symbolFromSymbolTable]; - } - // Look in the exported members, if we can find accessibleSymbolChain, symbol is accessible using this chain - // but only if the symbolFromSymbolTable can be qualified - var accessibleSymbolsFromExports = resolvedImportedSymbol.exports ? getAccessibleSymbolChainFromSymbolTable(resolvedImportedSymbol.exports) : undefined; - if (accessibleSymbolsFromExports && canQualifySymbol(symbolFromSymbolTable, getQualifiedLeftMeaning(meaning))) { - return [symbolFromSymbolTable].concat(accessibleSymbolsFromExports); - } - } - } - }); - } - if (symbol) { - return forEachSymbolTableInScope(enclosingDeclaration, getAccessibleSymbolChainFromSymbolTable); - } - } - function needsQualification(symbol, enclosingDeclaration, meaning) { - var qualify = false; - forEachSymbolTableInScope(enclosingDeclaration, function (symbolTable) { - // If symbol of this name is not available in the symbol table we are ok - if (!ts.hasProperty(symbolTable, symbol.name)) { - // Continue to the next symbol table - return false; - } - // If the symbol with this name is present it should refer to the symbol - var symbolFromSymbolTable = symbolTable[symbol.name]; - if (symbolFromSymbolTable === symbol) { - // No need to qualify - return true; - } - // Qualify if the symbol from symbol table has same meaning as expected - symbolFromSymbolTable = (symbolFromSymbolTable.flags & 8388608 /* Alias */ && !ts.getDeclarationOfKind(symbolFromSymbolTable, 230 /* ExportSpecifier */)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; - if (symbolFromSymbolTable.flags & meaning) { - qualify = true; - return true; - } - // Continue to the next symbol table - return false; - }); - return qualify; - } - function isSymbolAccessible(symbol, enclosingDeclaration, meaning) { - if (symbol && enclosingDeclaration && !(symbol.flags & 262144 /* TypeParameter */)) { - var initialSymbol = symbol; - var meaningToLook = meaning; - while (symbol) { - // Symbol is accessible if it by itself is accessible - var accessibleSymbolChain = getAccessibleSymbolChain(symbol, enclosingDeclaration, meaningToLook, /*useOnlyExternalAliasing*/ false); - if (accessibleSymbolChain) { - var hasAccessibleDeclarations = hasVisibleDeclarations(accessibleSymbolChain[0]); - if (!hasAccessibleDeclarations) { - return { - accessibility: 1 /* NotAccessible */, - errorSymbolName: symbolToString(initialSymbol, enclosingDeclaration, meaning), - errorModuleName: symbol !== initialSymbol ? symbolToString(symbol, enclosingDeclaration, 1536 /* Namespace */) : undefined - }; - } - return hasAccessibleDeclarations; - } - // If we haven't got the accessible symbol, it doesn't mean the symbol is actually inaccessible. - // It could be a qualified symbol and hence verify the path - // e.g.: - // module m { - // export class c { - // } - // } - // let x: typeof m.c - // In the above example when we start with checking if typeof m.c symbol is accessible, - // we are going to see if c can be accessed in scope directly. - // But it can't, hence the accessible is going to be undefined, but that doesn't mean m.c is inaccessible - // It is accessible if the parent m is accessible because then m.c can be accessed through qualification - meaningToLook = getQualifiedLeftMeaning(meaning); - symbol = getParentOfSymbol(symbol); - } - // This could be a symbol that is not exported in the external module - // or it could be a symbol from different external module that is not aliased and hence cannot be named - var symbolExternalModule = ts.forEach(initialSymbol.declarations, getExternalModuleContainer); - if (symbolExternalModule) { - var enclosingExternalModule = getExternalModuleContainer(enclosingDeclaration); - if (symbolExternalModule !== enclosingExternalModule) { - // name from different external module that is not visible - return { - accessibility: 2 /* CannotBeNamed */, - errorSymbolName: symbolToString(initialSymbol, enclosingDeclaration, meaning), - errorModuleName: symbolToString(symbolExternalModule) - }; - } - } - // Just a local name that is not accessible - return { - accessibility: 1 /* NotAccessible */, - errorSymbolName: symbolToString(initialSymbol, enclosingDeclaration, meaning) - }; - } - return { accessibility: 0 /* Accessible */ }; - function getExternalModuleContainer(declaration) { - for (; declaration; declaration = declaration.parent) { - if (hasExternalModuleSymbol(declaration)) { - return getSymbolOfNode(declaration); - } - } - } - } - function hasExternalModuleSymbol(declaration) { - return (declaration.kind === 218 /* ModuleDeclaration */ && declaration.name.kind === 9 /* StringLiteral */) || - (declaration.kind === 248 /* SourceFile */ && ts.isExternalModule(declaration)); - } - function hasVisibleDeclarations(symbol) { - var aliasesToMakeVisible; - if (ts.forEach(symbol.declarations, function (declaration) { return !getIsDeclarationVisible(declaration); })) { - return undefined; - } - return { accessibility: 0 /* Accessible */, aliasesToMakeVisible: aliasesToMakeVisible }; - function getIsDeclarationVisible(declaration) { - if (!isDeclarationVisible(declaration)) { - // Mark the unexported alias as visible if its parent is visible - // because these kind of aliases can be used to name types in declaration file - var anyImportSyntax = getAnyImportSyntax(declaration); - if (anyImportSyntax && - !(anyImportSyntax.flags & 1 /* Export */) && - isDeclarationVisible(anyImportSyntax.parent)) { - getNodeLinks(declaration).isVisible = true; - if (aliasesToMakeVisible) { - if (!ts.contains(aliasesToMakeVisible, anyImportSyntax)) { - aliasesToMakeVisible.push(anyImportSyntax); - } - } - else { - aliasesToMakeVisible = [anyImportSyntax]; - } - return true; - } - // Declaration is not visible - return false; - } - return true; - } - } - function isEntityNameVisible(entityName, enclosingDeclaration) { - // get symbol of the first identifier of the entityName - var meaning; - if (entityName.parent.kind === 154 /* TypeQuery */) { - // Typeof value - meaning = 107455 /* Value */ | 1048576 /* ExportValue */; - } - else if (entityName.kind === 135 /* QualifiedName */ || entityName.kind === 166 /* PropertyAccessExpression */ || - entityName.parent.kind === 221 /* ImportEqualsDeclaration */) { - // Left identifier from type reference or TypeAlias - // Entity name of the import declaration - meaning = 1536 /* Namespace */; - } - else { - // Type Reference or TypeAlias entity = Identifier - meaning = 793056 /* Type */; - } - var firstIdentifier = getFirstIdentifier(entityName); - var symbol = resolveName(enclosingDeclaration, firstIdentifier.text, meaning, /*nodeNotFoundErrorMessage*/ undefined, /*nameArg*/ undefined); - // Verify if the symbol is accessible - return (symbol && hasVisibleDeclarations(symbol)) || { - accessibility: 1 /* NotAccessible */, - errorSymbolName: ts.getTextOfNode(firstIdentifier), - errorNode: firstIdentifier - }; - } - function writeKeyword(writer, kind) { - writer.writeKeyword(ts.tokenToString(kind)); - } - function writePunctuation(writer, kind) { - writer.writePunctuation(ts.tokenToString(kind)); - } - function writeSpace(writer) { - writer.writeSpace(" "); - } - function symbolToString(symbol, enclosingDeclaration, meaning) { - var writer = ts.getSingleLineStringWriter(); - getSymbolDisplayBuilder().buildSymbolDisplay(symbol, writer, enclosingDeclaration, meaning); - var result = writer.string(); - ts.releaseStringWriter(writer); - return result; - } - function signatureToString(signature, enclosingDeclaration, flags) { - var writer = ts.getSingleLineStringWriter(); - getSymbolDisplayBuilder().buildSignatureDisplay(signature, writer, enclosingDeclaration, flags); - var result = writer.string(); - ts.releaseStringWriter(writer); - return result; - } - function typeToString(type, enclosingDeclaration, flags) { - var writer = ts.getSingleLineStringWriter(); - getSymbolDisplayBuilder().buildTypeDisplay(type, writer, enclosingDeclaration, flags); - var result = writer.string(); - ts.releaseStringWriter(writer); - var maxLength = compilerOptions.noErrorTruncation || flags & 4 /* NoTruncation */ ? undefined : 100; - if (maxLength && result.length >= maxLength) { - result = result.substr(0, maxLength - "...".length) + "..."; - } - return result; - } - function getTypeAliasForTypeLiteral(type) { - if (type.symbol && type.symbol.flags & 2048 /* TypeLiteral */) { - var node = type.symbol.declarations[0].parent; - while (node.kind === 160 /* ParenthesizedType */) { - node = node.parent; - } - if (node.kind === 216 /* TypeAliasDeclaration */) { - return getSymbolOfNode(node); - } - } - return undefined; - } - function getSymbolDisplayBuilder() { - function getNameOfSymbol(symbol) { - if (symbol.declarations && symbol.declarations.length) { - var declaration = symbol.declarations[0]; - if (declaration.name) { - return ts.declarationNameToString(declaration.name); - } - switch (declaration.kind) { - case 186 /* ClassExpression */: - return "(Anonymous class)"; - case 173 /* FunctionExpression */: - case 174 /* ArrowFunction */: - return "(Anonymous function)"; - } - } - return symbol.name; - } - /** - * Writes only the name of the symbol out to the writer. Uses the original source text - * for the name of the symbol if it is available to match how the user inputted the name. - */ - function appendSymbolNameOnly(symbol, writer) { - writer.writeSymbol(getNameOfSymbol(symbol), symbol); - } - /** - * Enclosing declaration is optional when we don't want to get qualified name in the enclosing declaration scope - * Meaning needs to be specified if the enclosing declaration is given - */ - function buildSymbolDisplay(symbol, writer, enclosingDeclaration, meaning, flags, typeFlags) { - var parentSymbol; - function appendParentTypeArgumentsAndSymbolName(symbol) { - if (parentSymbol) { - // Write type arguments of instantiated class/interface here - if (flags & 1 /* WriteTypeParametersOrArguments */) { - if (symbol.flags & 16777216 /* Instantiated */) { - buildDisplayForTypeArgumentsAndDelimiters(getTypeParametersOfClassOrInterface(parentSymbol), symbol.mapper, writer, enclosingDeclaration); - } - else { - buildTypeParameterDisplayFromSymbol(parentSymbol, writer, enclosingDeclaration); - } - } - writePunctuation(writer, 21 /* DotToken */); - } - parentSymbol = symbol; - appendSymbolNameOnly(symbol, writer); - } - // Let the writer know we just wrote out a symbol. The declaration emitter writer uses - // this to determine if an import it has previously seen (and not written out) needs - // to be written to the file once the walk of the tree is complete. - // - // NOTE(cyrusn): This approach feels somewhat unfortunate. A simple pass over the tree - // up front (for example, during checking) could determine if we need to emit the imports - // and we could then access that data during declaration emit. - writer.trackSymbol(symbol, enclosingDeclaration, meaning); - function walkSymbol(symbol, meaning) { - if (symbol) { - var accessibleSymbolChain = getAccessibleSymbolChain(symbol, enclosingDeclaration, meaning, !!(flags & 2 /* UseOnlyExternalAliasing */)); - if (!accessibleSymbolChain || - needsQualification(accessibleSymbolChain[0], enclosingDeclaration, accessibleSymbolChain.length === 1 ? meaning : getQualifiedLeftMeaning(meaning))) { - // Go up and add our parent. - walkSymbol(getParentOfSymbol(accessibleSymbolChain ? accessibleSymbolChain[0] : symbol), getQualifiedLeftMeaning(meaning)); - } - if (accessibleSymbolChain) { - for (var _i = 0; _i < accessibleSymbolChain.length; _i++) { - var accessibleSymbol = accessibleSymbolChain[_i]; - appendParentTypeArgumentsAndSymbolName(accessibleSymbol); - } - } - else { - // If we didn't find accessible symbol chain for this symbol, break if this is external module - if (!parentSymbol && ts.forEach(symbol.declarations, hasExternalModuleSymbol)) { - return; - } - // if this is anonymous type break - if (symbol.flags & 2048 /* TypeLiteral */ || symbol.flags & 4096 /* ObjectLiteral */) { - return; - } - appendParentTypeArgumentsAndSymbolName(symbol); - } - } - } - // Get qualified name if the symbol is not a type parameter - // and there is an enclosing declaration or we specifically - // asked for it - var isTypeParameter = symbol.flags & 262144 /* TypeParameter */; - var typeFormatFlag = 128 /* UseFullyQualifiedType */ & typeFlags; - if (!isTypeParameter && (enclosingDeclaration || typeFormatFlag)) { - walkSymbol(symbol, meaning); - return; - } - return appendParentTypeArgumentsAndSymbolName(symbol); - } - function buildTypeDisplay(type, writer, enclosingDeclaration, globalFlags, symbolStack) { - var globalFlagsToPass = globalFlags & 16 /* WriteOwnNameForAnyLike */; - var inObjectTypeLiteral = false; - return writeType(type, globalFlags); - function writeType(type, flags) { - // Write undefined/null type as any - if (type.flags & 16777343 /* Intrinsic */) { - // Special handling for unknown / resolving types, they should show up as any and not unknown or __resolving - writer.writeKeyword(!(globalFlags & 16 /* WriteOwnNameForAnyLike */) && isTypeAny(type) - ? "any" - : type.intrinsicName); - } - else if (type.flags & 33554432 /* ThisType */) { - if (inObjectTypeLiteral) { - writer.reportInaccessibleThisError(); - } - writer.writeKeyword("this"); - } - else if (type.flags & 4096 /* Reference */) { - writeTypeReference(type, flags); - } - else if (type.flags & (1024 /* Class */ | 2048 /* Interface */ | 128 /* Enum */ | 512 /* TypeParameter */)) { - // The specified symbol flags need to be reinterpreted as type flags - buildSymbolDisplay(type.symbol, writer, enclosingDeclaration, 793056 /* Type */, 0 /* None */, flags); - } - else if (type.flags & 8192 /* Tuple */) { - writeTupleType(type); - } - else if (type.flags & 49152 /* UnionOrIntersection */) { - writeUnionOrIntersectionType(type, flags); - } - else if (type.flags & 65536 /* Anonymous */) { - writeAnonymousType(type, flags); - } - else if (type.flags & 256 /* StringLiteral */) { - writer.writeStringLiteral(type.text); - } - else { - // Should never get here - // { ... } - writePunctuation(writer, 15 /* OpenBraceToken */); - writeSpace(writer); - writePunctuation(writer, 22 /* DotDotDotToken */); - writeSpace(writer); - writePunctuation(writer, 16 /* CloseBraceToken */); - } - } - function writeTypeList(types, delimiter) { - for (var i = 0; i < types.length; i++) { - if (i > 0) { - if (delimiter !== 24 /* CommaToken */) { - writeSpace(writer); - } - writePunctuation(writer, delimiter); - writeSpace(writer); - } - writeType(types[i], delimiter === 24 /* CommaToken */ ? 0 /* None */ : 64 /* InElementType */); - } - } - function writeSymbolTypeReference(symbol, typeArguments, pos, end, flags) { - // Unnamed function expressions and arrow functions have reserved names that we don't want to display - if (symbol.flags & 32 /* Class */ || !isReservedMemberName(symbol.name)) { - buildSymbolDisplay(symbol, writer, enclosingDeclaration, 793056 /* Type */, 0 /* None */, flags); - } - if (pos < end) { - writePunctuation(writer, 25 /* LessThanToken */); - writeType(typeArguments[pos++], 0 /* None */); - while (pos < end) { - writePunctuation(writer, 24 /* CommaToken */); - writeSpace(writer); - writeType(typeArguments[pos++], 0 /* None */); - } - writePunctuation(writer, 27 /* 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 */); - } - else { - // Write the type reference in the format f.g.C where A and B are type arguments - // for outer type parameters, and f and g are the respective declaring containers of those - // type parameters. - var outerTypeParameters = type.target.outerTypeParameters; - var i = 0; - if (outerTypeParameters) { - var length_1 = outerTypeParameters.length; - while (i < length_1) { - // Find group of type arguments for type parameters with the same declaring container. - var start = i; - var parent_3 = getParentSymbolOfTypeParameter(outerTypeParameters[i]); - do { - i++; - } while (i < length_1 && getParentSymbolOfTypeParameter(outerTypeParameters[i]) === parent_3); - // When type parameters are their own type arguments for the whole group (i.e. we have - // the default outer type arguments), we don't show the group. - if (!ts.rangeEquals(outerTypeParameters, typeArguments, start, i)) { - writeSymbolTypeReference(parent_3, typeArguments, start, i, flags); - writePunctuation(writer, 21 /* DotToken */); - } - } - } - var typeParameterCount = (type.target.typeParameters || emptyArray).length; - writeSymbolTypeReference(type.symbol, typeArguments, i, typeParameterCount, flags); - } - } - function writeTupleType(type) { - writePunctuation(writer, 19 /* OpenBracketToken */); - writeTypeList(type.elementTypes, 24 /* CommaToken */); - writePunctuation(writer, 20 /* CloseBracketToken */); - } - function writeUnionOrIntersectionType(type, flags) { - if (flags & 64 /* InElementType */) { - writePunctuation(writer, 17 /* OpenParenToken */); - } - writeTypeList(type.types, type.flags & 16384 /* Union */ ? 47 /* BarToken */ : 46 /* AmpersandToken */); - if (flags & 64 /* InElementType */) { - writePunctuation(writer, 18 /* CloseParenToken */); - } - } - function writeAnonymousType(type, flags) { - var symbol = type.symbol; - if (symbol) { - // Always use 'typeof T' for type of class, enum, and module objects - if (symbol.flags & (32 /* Class */ | 384 /* Enum */ | 512 /* ValueModule */)) { - writeTypeofSymbol(type, flags); - } - else if (shouldWriteTypeOfFunctionSymbol()) { - writeTypeofSymbol(type, flags); - } - else if (ts.contains(symbolStack, symbol)) { - // If type is an anonymous type literal in a type alias declaration, use type alias name - var typeAlias = getTypeAliasForTypeLiteral(type); - if (typeAlias) { - // The specified symbol flags need to be reinterpreted as type flags - buildSymbolDisplay(typeAlias, writer, enclosingDeclaration, 793056 /* Type */, 0 /* None */, flags); - } - else { - // Recursive usage, use any - writeKeyword(writer, 117 /* AnyKeyword */); - } - } - else { - // Since instantiations of the same anonymous type have the same symbol, tracking symbols instead - // of types allows us to catch circular references to instantiations of the same anonymous type - if (!symbolStack) { - symbolStack = []; - } - symbolStack.push(symbol); - writeLiteralType(type, flags); - symbolStack.pop(); - } - } - else { - // Anonymous types with no symbol are never circular - writeLiteralType(type, flags); - } - function shouldWriteTypeOfFunctionSymbol() { - var isStaticMethodSymbol = !!(symbol.flags & 8192 /* Method */ && - ts.forEach(symbol.declarations, function (declaration) { return declaration.flags & 128 /* Static */; })); - var isNonLocalFunctionSymbol = !!(symbol.flags & 16 /* Function */) && - (symbol.parent || - ts.forEach(symbol.declarations, function (declaration) { - return declaration.parent.kind === 248 /* SourceFile */ || declaration.parent.kind === 219 /* ModuleBlock */; - })); - if (isStaticMethodSymbol || isNonLocalFunctionSymbol) { - // typeof is allowed only for static/non local functions - return !!(flags & 2 /* UseTypeOfFunction */) || - (ts.contains(symbolStack, symbol)); // it is type of the symbol uses itself recursively - } - } - } - function writeTypeofSymbol(type, typeFormatFlags) { - writeKeyword(writer, 101 /* TypeOfKeyword */); - writeSpace(writer); - buildSymbolDisplay(type.symbol, writer, enclosingDeclaration, 107455 /* Value */, 0 /* None */, typeFormatFlags); - } - function getIndexerParameterName(type, indexKind, fallbackName) { - var declaration = getIndexDeclarationOfSymbol(type.symbol, indexKind); - if (!declaration) { - // declaration might not be found if indexer was added from the contextual type. - // in this case use fallback name - return fallbackName; - } - ts.Debug.assert(declaration.parameters.length !== 0); - return ts.declarationNameToString(declaration.parameters[0].name); - } - function writeLiteralType(type, flags) { - var resolved = resolveStructuredTypeMembers(type); - if (!resolved.properties.length && !resolved.stringIndexType && !resolved.numberIndexType) { - if (!resolved.callSignatures.length && !resolved.constructSignatures.length) { - writePunctuation(writer, 15 /* OpenBraceToken */); - writePunctuation(writer, 16 /* CloseBraceToken */); - return; - } - if (resolved.callSignatures.length === 1 && !resolved.constructSignatures.length) { - if (flags & 64 /* InElementType */) { - writePunctuation(writer, 17 /* OpenParenToken */); - } - buildSignatureDisplay(resolved.callSignatures[0], writer, enclosingDeclaration, globalFlagsToPass | 8 /* WriteArrowStyleSignature */, symbolStack); - if (flags & 64 /* InElementType */) { - writePunctuation(writer, 18 /* CloseParenToken */); - } - return; - } - if (resolved.constructSignatures.length === 1 && !resolved.callSignatures.length) { - if (flags & 64 /* InElementType */) { - writePunctuation(writer, 17 /* OpenParenToken */); - } - writeKeyword(writer, 92 /* NewKeyword */); - writeSpace(writer); - buildSignatureDisplay(resolved.constructSignatures[0], writer, enclosingDeclaration, globalFlagsToPass | 8 /* WriteArrowStyleSignature */, symbolStack); - if (flags & 64 /* InElementType */) { - writePunctuation(writer, 18 /* CloseParenToken */); - } - return; - } - } - var saveInObjectTypeLiteral = inObjectTypeLiteral; - inObjectTypeLiteral = true; - writePunctuation(writer, 15 /* 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, symbolStack); - writePunctuation(writer, 23 /* SemicolonToken */); - writer.writeLine(); - } - for (var _b = 0, _c = resolved.constructSignatures; _b < _c.length; _b++) { - var signature = _c[_b]; - writeKeyword(writer, 92 /* NewKeyword */); - writeSpace(writer); - buildSignatureDisplay(signature, writer, enclosingDeclaration, globalFlagsToPass, symbolStack); - writePunctuation(writer, 23 /* SemicolonToken */); - writer.writeLine(); - } - if (resolved.stringIndexType) { - // [x: string]: - writePunctuation(writer, 19 /* OpenBracketToken */); - writer.writeParameter(getIndexerParameterName(resolved, 0 /* String */, /*fallbackName*/ "x")); - writePunctuation(writer, 54 /* ColonToken */); - writeSpace(writer); - writeKeyword(writer, 130 /* StringKeyword */); - writePunctuation(writer, 20 /* CloseBracketToken */); - writePunctuation(writer, 54 /* ColonToken */); - writeSpace(writer); - writeType(resolved.stringIndexType, 0 /* None */); - writePunctuation(writer, 23 /* SemicolonToken */); - writer.writeLine(); - } - if (resolved.numberIndexType) { - // [x: number]: - writePunctuation(writer, 19 /* OpenBracketToken */); - writer.writeParameter(getIndexerParameterName(resolved, 1 /* Number */, /*fallbackName*/ "x")); - writePunctuation(writer, 54 /* ColonToken */); - writeSpace(writer); - writeKeyword(writer, 128 /* NumberKeyword */); - writePunctuation(writer, 20 /* CloseBracketToken */); - writePunctuation(writer, 54 /* ColonToken */); - writeSpace(writer); - writeType(resolved.numberIndexType, 0 /* None */); - writePunctuation(writer, 23 /* SemicolonToken */); - writer.writeLine(); - } - for (var _d = 0, _e = resolved.properties; _d < _e.length; _d++) { - var p = _e[_d]; - var t = getTypeOfSymbol(p); - if (p.flags & (16 /* Function */ | 8192 /* Method */) && !getPropertiesOfObjectType(t).length) { - var signatures = getSignaturesOfType(t, 0 /* Call */); - for (var _f = 0; _f < signatures.length; _f++) { - var signature = signatures[_f]; - buildSymbolDisplay(p, writer); - if (p.flags & 536870912 /* Optional */) { - writePunctuation(writer, 53 /* QuestionToken */); - } - buildSignatureDisplay(signature, writer, enclosingDeclaration, globalFlagsToPass, symbolStack); - writePunctuation(writer, 23 /* SemicolonToken */); - writer.writeLine(); - } - } - else { - buildSymbolDisplay(p, writer); - if (p.flags & 536870912 /* Optional */) { - writePunctuation(writer, 53 /* QuestionToken */); - } - writePunctuation(writer, 54 /* ColonToken */); - writeSpace(writer); - writeType(t, 0 /* None */); - writePunctuation(writer, 23 /* SemicolonToken */); - writer.writeLine(); - } - } - writer.decreaseIndent(); - writePunctuation(writer, 16 /* CloseBraceToken */); - inObjectTypeLiteral = saveInObjectTypeLiteral; - } - } - function buildTypeParameterDisplayFromSymbol(symbol, writer, enclosingDeclaraiton, flags) { - var targetSymbol = getTargetSymbol(symbol); - if (targetSymbol.flags & 32 /* Class */ || targetSymbol.flags & 64 /* Interface */ || targetSymbol.flags & 524288 /* TypeAlias */) { - buildDisplayForTypeParametersAndDelimiters(getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol), writer, enclosingDeclaraiton, flags); - } - } - function buildTypeParameterDisplay(tp, writer, enclosingDeclaration, flags, symbolStack) { - appendSymbolNameOnly(tp.symbol, writer); - var constraint = getConstraintOfTypeParameter(tp); - if (constraint) { - writeSpace(writer); - writeKeyword(writer, 83 /* ExtendsKeyword */); - writeSpace(writer); - buildTypeDisplay(constraint, writer, enclosingDeclaration, flags, symbolStack); - } - } - function buildParameterDisplay(p, writer, enclosingDeclaration, flags, symbolStack) { - var parameterNode = p.valueDeclaration; - if (ts.isRestParameter(parameterNode)) { - writePunctuation(writer, 22 /* DotDotDotToken */); - } - appendSymbolNameOnly(p, writer); - if (isOptionalParameter(parameterNode)) { - writePunctuation(writer, 53 /* QuestionToken */); - } - writePunctuation(writer, 54 /* ColonToken */); - writeSpace(writer); - buildTypeDisplay(getTypeOfSymbol(p), writer, enclosingDeclaration, flags, symbolStack); - } - function buildDisplayForTypeParametersAndDelimiters(typeParameters, writer, enclosingDeclaration, flags, symbolStack) { - if (typeParameters && typeParameters.length) { - writePunctuation(writer, 25 /* LessThanToken */); - for (var i = 0; i < typeParameters.length; i++) { - if (i > 0) { - writePunctuation(writer, 24 /* CommaToken */); - writeSpace(writer); - } - buildTypeParameterDisplay(typeParameters[i], writer, enclosingDeclaration, flags, symbolStack); - } - writePunctuation(writer, 27 /* GreaterThanToken */); - } - } - function buildDisplayForTypeArgumentsAndDelimiters(typeParameters, mapper, writer, enclosingDeclaration, flags, symbolStack) { - if (typeParameters && typeParameters.length) { - writePunctuation(writer, 25 /* LessThanToken */); - for (var i = 0; i < typeParameters.length; i++) { - if (i > 0) { - writePunctuation(writer, 24 /* CommaToken */); - writeSpace(writer); - } - buildTypeDisplay(mapper(typeParameters[i]), writer, enclosingDeclaration, 0 /* None */); - } - writePunctuation(writer, 27 /* GreaterThanToken */); - } - } - function buildDisplayForParametersAndDelimiters(parameters, writer, enclosingDeclaration, flags, symbolStack) { - writePunctuation(writer, 17 /* OpenParenToken */); - for (var i = 0; i < parameters.length; i++) { - if (i > 0) { - writePunctuation(writer, 24 /* CommaToken */); - writeSpace(writer); - } - buildParameterDisplay(parameters[i], writer, enclosingDeclaration, flags, symbolStack); - } - writePunctuation(writer, 18 /* CloseParenToken */); - } - function buildReturnTypeDisplay(signature, writer, enclosingDeclaration, flags, symbolStack) { - if (flags & 8 /* WriteArrowStyleSignature */) { - writeSpace(writer); - writePunctuation(writer, 34 /* EqualsGreaterThanToken */); - } - else { - writePunctuation(writer, 54 /* ColonToken */); - } - writeSpace(writer); - var returnType; - if (signature.typePredicate) { - writer.writeParameter(signature.typePredicate.parameterName); - writeSpace(writer); - writeKeyword(writer, 124 /* IsKeyword */); - writeSpace(writer); - returnType = signature.typePredicate.type; - } - else { - returnType = getReturnTypeOfSignature(signature); - } - buildTypeDisplay(returnType, writer, enclosingDeclaration, flags, symbolStack); - } - function buildSignatureDisplay(signature, writer, enclosingDeclaration, flags, symbolStack) { - if (signature.target && (flags & 32 /* WriteTypeArgumentsOfSignature */)) { - // Instantiated signature, write type arguments instead - // This is achieved by passing in the mapper separately - buildDisplayForTypeArgumentsAndDelimiters(signature.target.typeParameters, signature.mapper, writer, enclosingDeclaration); - } - else { - buildDisplayForTypeParametersAndDelimiters(signature.typeParameters, writer, enclosingDeclaration, flags, symbolStack); - } - buildDisplayForParametersAndDelimiters(signature.parameters, writer, enclosingDeclaration, flags, symbolStack); - buildReturnTypeDisplay(signature, writer, enclosingDeclaration, flags, symbolStack); - } - return _displayBuilder || (_displayBuilder = { - buildSymbolDisplay: buildSymbolDisplay, - buildTypeDisplay: buildTypeDisplay, - buildTypeParameterDisplay: buildTypeParameterDisplay, - buildParameterDisplay: buildParameterDisplay, - buildDisplayForParametersAndDelimiters: buildDisplayForParametersAndDelimiters, - buildDisplayForTypeParametersAndDelimiters: buildDisplayForTypeParametersAndDelimiters, - buildTypeParameterDisplayFromSymbol: buildTypeParameterDisplayFromSymbol, - buildSignatureDisplay: buildSignatureDisplay, - buildReturnTypeDisplay: buildReturnTypeDisplay - }); - } - function isDeclarationVisible(node) { - function getContainingExternalModule(node) { - for (; node; node = node.parent) { - if (node.kind === 218 /* ModuleDeclaration */) { - if (node.name.kind === 9 /* StringLiteral */) { - return node; - } - } - else if (node.kind === 248 /* SourceFile */) { - return ts.isExternalModule(node) ? node : undefined; - } - } - ts.Debug.fail("getContainingModule cant reach here"); - } - function isUsedInExportAssignment(node) { - // Get source File and see if it is external module and has export assigned symbol - var externalModule = getContainingExternalModule(node); - var exportAssignmentSymbol; - var resolvedExportSymbol; - if (externalModule) { - // This is export assigned symbol node - var externalModuleSymbol = getSymbolOfNode(externalModule); - exportAssignmentSymbol = getExportAssignmentSymbol(externalModuleSymbol); - var symbolOfNode = getSymbolOfNode(node); - if (isSymbolUsedInExportAssignment(symbolOfNode)) { - return true; - } - // if symbolOfNode is alias declaration, resolve the symbol declaration and check - if (symbolOfNode.flags & 8388608 /* Alias */) { - return isSymbolUsedInExportAssignment(resolveAlias(symbolOfNode)); - } - } - // Check if the symbol is used in export assignment - function isSymbolUsedInExportAssignment(symbol) { - if (exportAssignmentSymbol === symbol) { - return true; - } - if (exportAssignmentSymbol && !!(exportAssignmentSymbol.flags & 8388608 /* Alias */)) { - // if export assigned symbol is alias declaration, resolve the alias - resolvedExportSymbol = resolvedExportSymbol || resolveAlias(exportAssignmentSymbol); - if (resolvedExportSymbol === symbol) { - return true; - } - // Container of resolvedExportSymbol is visible - return ts.forEach(resolvedExportSymbol.declarations, function (current) { - while (current) { - if (current === node) { - return true; - } - current = current.parent; - } - }); - } - } - } - function determineIfDeclarationIsVisible() { - switch (node.kind) { - case 163 /* BindingElement */: - return isDeclarationVisible(node.parent.parent); - case 211 /* VariableDeclaration */: - if (ts.isBindingPattern(node.name) && - !node.name.elements.length) { - // If the binding pattern is empty, this variable declaration is not visible - return false; - } - // Otherwise fall through - case 218 /* ModuleDeclaration */: - case 214 /* ClassDeclaration */: - case 215 /* InterfaceDeclaration */: - case 216 /* TypeAliasDeclaration */: - case 213 /* FunctionDeclaration */: - case 217 /* EnumDeclaration */: - case 221 /* ImportEqualsDeclaration */: - var parent_4 = getDeclarationContainer(node); - // If the node is not exported or it is not ambient module element (except import declaration) - if (!(ts.getCombinedNodeFlags(node) & 1 /* Export */) && - !(node.kind !== 221 /* ImportEqualsDeclaration */ && parent_4.kind !== 248 /* SourceFile */ && ts.isInAmbientContext(parent_4))) { - return isGlobalSourceFile(parent_4); - } - // Exported members/ambient module elements (exception import declaration) are visible if parent is visible - return isDeclarationVisible(parent_4); - case 141 /* PropertyDeclaration */: - case 140 /* PropertySignature */: - case 145 /* GetAccessor */: - case 146 /* SetAccessor */: - case 143 /* MethodDeclaration */: - case 142 /* MethodSignature */: - if (node.flags & (32 /* Private */ | 64 /* Protected */)) { - // Private/protected properties/methods are not visible - return false; - } - // Public properties/methods are visible if its parents are visible, so let it fall into next case statement - case 144 /* Constructor */: - case 148 /* ConstructSignature */: - case 147 /* CallSignature */: - case 149 /* IndexSignature */: - case 138 /* Parameter */: - case 219 /* ModuleBlock */: - case 152 /* FunctionType */: - case 153 /* ConstructorType */: - case 155 /* TypeLiteral */: - case 151 /* TypeReference */: - case 156 /* ArrayType */: - case 157 /* TupleType */: - case 158 /* UnionType */: - case 159 /* IntersectionType */: - case 160 /* ParenthesizedType */: - return isDeclarationVisible(node.parent); - // Default binding, import specifier and namespace import is visible - // only on demand so by default it is not visible - case 223 /* ImportClause */: - case 224 /* NamespaceImport */: - case 226 /* ImportSpecifier */: - return false; - // Type parameters are always visible - case 137 /* TypeParameter */: - // Source file is always visible - case 248 /* SourceFile */: - return true; - // Export assignements do not create name bindings outside the module - case 227 /* ExportAssignment */: - return false; - default: - ts.Debug.fail("isDeclarationVisible unknown: SyntaxKind: " + node.kind); - } - } - if (node) { - var links = getNodeLinks(node); - if (links.isVisible === undefined) { - links.isVisible = !!determineIfDeclarationIsVisible(); - } - return links.isVisible; - } - } - function collectLinkedAliases(node) { - var exportSymbol; - if (node.parent && node.parent.kind === 227 /* ExportAssignment */) { - exportSymbol = resolveName(node.parent, node.text, 107455 /* Value */ | 793056 /* Type */ | 1536 /* Namespace */ | 8388608 /* Alias */, ts.Diagnostics.Cannot_find_name_0, node); - } - else if (node.parent.kind === 230 /* ExportSpecifier */) { - var exportSpecifier = node.parent; - exportSymbol = exportSpecifier.parent.parent.moduleSpecifier ? - getExternalModuleMember(exportSpecifier.parent.parent, exportSpecifier) : - resolveEntityName(exportSpecifier.propertyName || exportSpecifier.name, 107455 /* Value */ | 793056 /* Type */ | 1536 /* Namespace */ | 8388608 /* Alias */); - } - var result = []; - if (exportSymbol) { - buildVisibleNodeList(exportSymbol.declarations); - } - return result; - function buildVisibleNodeList(declarations) { - ts.forEach(declarations, function (declaration) { - getNodeLinks(declaration).isVisible = true; - var resultNode = getAnyImportSyntax(declaration) || declaration; - if (!ts.contains(result, resultNode)) { - result.push(resultNode); - } - if (ts.isInternalModuleImportEqualsDeclaration(declaration)) { - // Add the referenced top container visible - var internalModuleReference = declaration.moduleReference; - var firstIdentifier = getFirstIdentifier(internalModuleReference); - var importSymbol = resolveName(declaration, firstIdentifier.text, 107455 /* Value */ | 793056 /* Type */ | 1536 /* Namespace */, ts.Diagnostics.Cannot_find_name_0, firstIdentifier); - buildVisibleNodeList(importSymbol.declarations); - } - }); - } - } - /** - * Push an entry on the type resolution stack. If an entry with the given target and the given property name - * is already on the stack, and no entries in between already have a type, then a circularity has occurred. - * In this case, the result values of the existing entry and all entries pushed after it are changed to false, - * and the value false is returned. Otherwise, the new entry is just pushed onto the stack, and true is returned. - * In order to see if the same query has already been done before, the target object and the propertyName both - * must match the one passed in. - * - * @param target The symbol, type, or signature whose type is being queried - * @param propertyName The property name that should be used to query the target for its type - */ - function pushTypeResolution(target, propertyName) { - var resolutionCycleStartIndex = findResolutionCycleStartIndex(target, propertyName); - if (resolutionCycleStartIndex >= 0) { - // A cycle was found - var length_2 = resolutionTargets.length; - for (var i = resolutionCycleStartIndex; i < length_2; i++) { - resolutionResults[i] = false; - } - return false; - } - resolutionTargets.push(target); - resolutionResults.push(true); - resolutionPropertyNames.push(propertyName); - return true; - } - function findResolutionCycleStartIndex(target, propertyName) { - for (var i = resolutionTargets.length - 1; i >= 0; i--) { - if (hasType(resolutionTargets[i], resolutionPropertyNames[i])) { - return -1; - } - if (resolutionTargets[i] === target && resolutionPropertyNames[i] === propertyName) { - return i; - } - } - return -1; - } - function hasType(target, propertyName) { - if (propertyName === 0 /* Type */) { - return getSymbolLinks(target).type; - } - if (propertyName === 2 /* DeclaredType */) { - return getSymbolLinks(target).declaredType; - } - if (propertyName === 1 /* ResolvedBaseConstructorType */) { - ts.Debug.assert(!!(target.flags & 1024 /* Class */)); - return target.resolvedBaseConstructorType; - } - if (propertyName === 3 /* ResolvedReturnType */) { - return target.resolvedReturnType; - } - ts.Debug.fail("Unhandled TypeSystemPropertyName " + propertyName); - } - // Pop an entry from the type resolution stack and return its associated result value. The result value will - // be true if no circularities were detected, or false if a circularity was found. - function popTypeResolution() { - resolutionTargets.pop(); - resolutionPropertyNames.pop(); - return resolutionResults.pop(); - } - function getDeclarationContainer(node) { - node = ts.getRootDeclaration(node); - // Parent chain: - // VaribleDeclaration -> VariableDeclarationList -> VariableStatement -> 'Declaration Container' - return node.kind === 211 /* VariableDeclaration */ ? node.parent.parent.parent : node.parent; - } - function getTypeOfPrototypeProperty(prototype) { - // 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'. - var classType = getDeclaredTypeOfSymbol(prototype.parent); - return classType.typeParameters ? createTypeReference(classType, ts.map(classType.typeParameters, function (_) { return anyType; })) : classType; - } - // Return the type of the given property in the given type, or undefined if no such property exists - function getTypeOfPropertyOfType(type, name) { - var prop = getPropertyOfType(type, name); - return prop ? getTypeOfSymbol(prop) : undefined; - } - function isTypeAny(type) { - return type && (type.flags & 1 /* Any */) !== 0; - } - // Return the type of a binding element parent. We check SymbolLinks first to see if a type has been - // assigned by contextual typing. - function getTypeForBindingElementParent(node) { - var symbol = getSymbolOfNode(node); - return symbol && getSymbolLinks(symbol).type || getTypeForVariableLikeDeclaration(node); - } - // Return the inferred type for a binding element - function getTypeForBindingElement(declaration) { - var pattern = declaration.parent; - var parentType = getTypeForBindingElementParent(pattern.parent); - // If parent has the unknown (error) type, then so does this binding element - if (parentType === unknownType) { - return unknownType; - } - // If no type was specified or inferred for parent, or if the specified or inferred type is any, - // infer from the initializer of the binding element if one is present. Otherwise, go with the - // undefined or any type of the parent. - if (!parentType || isTypeAny(parentType)) { - if (declaration.initializer) { - return checkExpressionCached(declaration.initializer); - } - return parentType; - } - var type; - if (pattern.kind === 161 /* ObjectBindingPattern */) { - // Use explicitly specified property name ({ p: xxx } form), or otherwise the implied name ({ p } form) - var name_10 = declaration.propertyName || declaration.name; - // Use type of the specified property, or otherwise, for a numeric name, the type of the numeric index signature, - // or otherwise the type of the string index signature. - type = getTypeOfPropertyOfType(parentType, name_10.text) || - isNumericLiteralName(name_10.text) && getIndexTypeOfType(parentType, 1 /* Number */) || - getIndexTypeOfType(parentType, 0 /* String */); - if (!type) { - error(name_10, ts.Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(parentType), ts.declarationNameToString(name_10)); - return unknownType; - } - } - else { - // This elementType will be used if the specific property corresponding to this index is not - // present (aka the tuple element property). This call also checks that the parentType is in - // fact an iterable or array (depending on target language). - var elementType = checkIteratedTypeOrElementType(parentType, pattern, /*allowStringInput*/ false); - if (!declaration.dotDotDotToken) { - // Use specific property type when parent is a tuple or numeric index type when parent is an array - var propName = "" + ts.indexOf(pattern.elements, declaration); - type = isTupleLikeType(parentType) - ? getTypeOfPropertyOfType(parentType, propName) - : elementType; - if (!type) { - if (isTupleType(parentType)) { - error(declaration, ts.Diagnostics.Tuple_type_0_with_length_1_cannot_be_assigned_to_tuple_with_length_2, typeToString(parentType), parentType.elementTypes.length, pattern.elements.length); - } - else { - error(declaration, ts.Diagnostics.Type_0_has_no_property_1, typeToString(parentType), propName); - } - return unknownType; - } - } - else { - // Rest element has an array type with the same element type as the parent type - type = createArrayType(elementType); - } - } - return type; - } - // Return the inferred type for a variable, parameter, or property declaration - function getTypeForVariableLikeDeclaration(declaration) { - // A variable declared in a for..in statement is always of type any - if (declaration.parent.parent.kind === 200 /* ForInStatement */) { - return anyType; - } - if (declaration.parent.parent.kind === 201 /* ForOfStatement */) { - // checkRightHandSideOfForOf will return undefined if the for-of expression type was - // missing properties/signatures required to get its iteratedType (like - // [Symbol.iterator] or next). This may be because we accessed properties from anyType, - // or it may have led to an error inside getElementTypeOfIterable. - return checkRightHandSideOfForOf(declaration.parent.parent.expression) || anyType; - } - if (ts.isBindingPattern(declaration.parent)) { - return getTypeForBindingElement(declaration); - } - // Use type from type annotation if one is present - if (declaration.type) { - return getTypeFromTypeNode(declaration.type); - } - if (declaration.kind === 138 /* Parameter */) { - var func = declaration.parent; - // For a parameter of a set accessor, use the type of the get accessor if one is present - if (func.kind === 146 /* SetAccessor */ && !ts.hasDynamicName(func)) { - var getter = ts.getDeclarationOfKind(declaration.parent.symbol, 145 /* GetAccessor */); - if (getter) { - return getReturnTypeOfSignature(getSignatureFromDeclaration(getter)); - } - } - // Use contextual parameter type if one is available - var type = getContextuallyTypedParameterType(declaration); - if (type) { - return type; - } - } - // Use the type of the initializer expression if one is present - if (declaration.initializer) { - return checkExpressionCached(declaration.initializer); - } - // If it is a short-hand property assignment, use the type of the identifier - if (declaration.kind === 246 /* ShorthandPropertyAssignment */) { - return checkIdentifier(declaration.name); - } - // If the declaration specifies a binding pattern, use the type implied by the binding pattern - if (ts.isBindingPattern(declaration.name)) { - return getTypeFromBindingPattern(declaration.name, /*includePatternInType*/ false); - } - // No type specified and nothing can be inferred - return undefined; - } - // Return the type implied by a binding pattern element. This is the type of the initializer of the element if - // one is present. Otherwise, if the element is itself a binding pattern, it is the type implied by the binding - // pattern. Otherwise, it is the type any. - function getTypeFromBindingElement(element, includePatternInType) { - if (element.initializer) { - return getWidenedType(checkExpressionCached(element.initializer)); - } - if (ts.isBindingPattern(element.name)) { - return getTypeFromBindingPattern(element.name, includePatternInType); - } - return anyType; - } - // Return the type implied by an object binding pattern - function getTypeFromObjectBindingPattern(pattern, includePatternInType) { - var members = {}; - ts.forEach(pattern.elements, function (e) { - var flags = 4 /* Property */ | 67108864 /* Transient */ | (e.initializer ? 536870912 /* Optional */ : 0); - var name = e.propertyName || e.name; - var symbol = createSymbol(flags, name.text); - symbol.type = getTypeFromBindingElement(e, includePatternInType); - symbol.bindingElement = e; - members[symbol.name] = symbol; - }); - var result = createAnonymousType(undefined, members, emptyArray, emptyArray, undefined, undefined); - if (includePatternInType) { - result.pattern = pattern; - } - return result; - } - // Return the type implied by an array binding pattern - function getTypeFromArrayBindingPattern(pattern, includePatternInType) { - var elements = pattern.elements; - if (elements.length === 0 || elements[elements.length - 1].dotDotDotToken) { - return languageVersion >= 2 /* ES6 */ ? createIterableType(anyType) : anyArrayType; - } - // If the pattern has at least one element, and no rest element, then it should imply a tuple type. - var elementTypes = ts.map(elements, function (e) { return e.kind === 187 /* OmittedExpression */ ? anyType : getTypeFromBindingElement(e, includePatternInType); }); - if (includePatternInType) { - var result = createNewTupleType(elementTypes); - result.pattern = pattern; - return result; - } - return createTupleType(elementTypes); - } - // Return the type implied by a binding pattern. This is the type implied purely by the binding pattern itself - // and without regard to its context (i.e. without regard any type annotation or initializer associated with the - // declaration in which the binding pattern is contained). For example, the implied type of [x, y] is [any, any] - // and the implied type of { x, y: z = 1 } is { x: any; y: number; }. The type implied by a binding pattern is - // used as the contextual type of an initializer associated with the binding pattern. Also, for a destructuring - // parameter with no type annotation or initializer, the type implied by the binding pattern becomes the type of - // the parameter. - function getTypeFromBindingPattern(pattern, includePatternInType) { - return pattern.kind === 161 /* ObjectBindingPattern */ - ? getTypeFromObjectBindingPattern(pattern, includePatternInType) - : getTypeFromArrayBindingPattern(pattern, includePatternInType); - } - // Return the type associated with a variable, parameter, or property declaration. In the simple case this is the type - // specified in a type annotation or inferred from an initializer. However, in the case of a destructuring declaration it - // is a bit more involved. For example: - // - // var [x, s = ""] = [1, "one"]; - // - // Here, the array literal [1, "one"] is contextually typed by the type [any, string], which is the implied type of the - // binding pattern [x, s = ""]. Because the contextual type is a tuple type, the resulting type of [1, "one"] is the - // tuple type [number, string]. Thus, the type inferred for 'x' is number and the type inferred for 's' is string. - function getWidenedTypeForVariableLikeDeclaration(declaration, reportErrors) { - var type = getTypeForVariableLikeDeclaration(declaration); - if (type) { - if (reportErrors) { - reportErrorsFromWidening(declaration, type); - } - // During a normal type check we'll never get to here with a property assignment (the check of the containing - // object literal uses a different path). We exclude widening only so that language services and type verification - // tools see the actual type. - return declaration.kind !== 245 /* PropertyAssignment */ ? getWidenedType(type) : type; - } - // Rest parameters default to type any[], other parameters default to type any - type = declaration.dotDotDotToken ? anyArrayType : anyType; - // Report implicit any errors unless this is a private property within an ambient declaration - if (reportErrors && compilerOptions.noImplicitAny) { - var root = ts.getRootDeclaration(declaration); - if (!isPrivateWithinAmbient(root) && !(root.kind === 138 /* Parameter */ && isPrivateWithinAmbient(root.parent))) { - reportImplicitAnyError(declaration, type); - } - } - return type; - } - function getTypeOfVariableOrParameterOrProperty(symbol) { - var links = getSymbolLinks(symbol); - if (!links.type) { - // Handle prototype property - if (symbol.flags & 134217728 /* Prototype */) { - return links.type = getTypeOfPrototypeProperty(symbol); - } - // Handle catch clause variables - var declaration = symbol.valueDeclaration; - if (declaration.parent.kind === 244 /* CatchClause */) { - return links.type = anyType; - } - // Handle export default expressions - if (declaration.kind === 227 /* ExportAssignment */) { - return links.type = checkExpression(declaration.expression); - } - // Handle variable, parameter or property - if (!pushTypeResolution(symbol, 0 /* Type */)) { - return unknownType; - } - var type = getWidenedTypeForVariableLikeDeclaration(declaration, /*reportErrors*/ true); - if (!popTypeResolution()) { - if (symbol.valueDeclaration.type) { - // Variable has type annotation that circularly references the variable itself - type = unknownType; - error(symbol.valueDeclaration, ts.Diagnostics._0_is_referenced_directly_or_indirectly_in_its_own_type_annotation, symbolToString(symbol)); - } - else { - // Variable has initializer that circularly references the variable itself - type = anyType; - if (compilerOptions.noImplicitAny) { - error(symbol.valueDeclaration, ts.Diagnostics._0_implicitly_has_type_any_because_it_does_not_have_a_type_annotation_and_is_referenced_directly_or_indirectly_in_its_own_initializer, symbolToString(symbol)); - } - } - } - links.type = type; - } - return links.type; - } - function getAnnotatedAccessorType(accessor) { - if (accessor) { - if (accessor.kind === 145 /* GetAccessor */) { - return accessor.type && getTypeFromTypeNode(accessor.type); - } - else { - var setterTypeAnnotation = ts.getSetAccessorTypeAnnotationNode(accessor); - return setterTypeAnnotation && getTypeFromTypeNode(setterTypeAnnotation); - } - } - return undefined; - } - function getTypeOfAccessors(symbol) { - var links = getSymbolLinks(symbol); - if (!links.type) { - if (!pushTypeResolution(symbol, 0 /* Type */)) { - return unknownType; - } - var getter = ts.getDeclarationOfKind(symbol, 145 /* GetAccessor */); - var setter = ts.getDeclarationOfKind(symbol, 146 /* SetAccessor */); - var type; - // First try to see if the user specified a return type on the get-accessor. - var getterReturnType = getAnnotatedAccessorType(getter); - if (getterReturnType) { - type = getterReturnType; - } - else { - // If the user didn't specify a return type, try to use the set-accessor's parameter type. - var setterParameterType = getAnnotatedAccessorType(setter); - if (setterParameterType) { - type = setterParameterType; - } - else { - // If there are no specified types, try to infer it from the body of the get accessor if it exists. - if (getter && getter.body) { - type = getReturnTypeFromBody(getter); - } - else { - if (compilerOptions.noImplicitAny) { - error(setter, ts.Diagnostics.Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_type_annotation, symbolToString(symbol)); - } - type = anyType; - } - } - } - if (!popTypeResolution()) { - type = anyType; - if (compilerOptions.noImplicitAny) { - var getter_1 = ts.getDeclarationOfKind(symbol, 145 /* GetAccessor */); - error(getter_1, ts.Diagnostics._0_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions, symbolToString(symbol)); - } - } - links.type = type; - } - return links.type; - } - function getTypeOfFuncClassEnumModule(symbol) { - var links = getSymbolLinks(symbol); - if (!links.type) { - links.type = createObjectType(65536 /* Anonymous */, symbol); - } - return links.type; - } - function getTypeOfEnumMember(symbol) { - var links = getSymbolLinks(symbol); - if (!links.type) { - links.type = getDeclaredTypeOfEnum(getParentOfSymbol(symbol)); - } - return links.type; - } - function getTypeOfAlias(symbol) { - var links = getSymbolLinks(symbol); - if (!links.type) { - var targetSymbol = resolveAlias(symbol); - // It only makes sense to get the type of a value symbol. If the result of resolving - // the alias is not a value, then it has no type. To get the type associated with a - // type symbol, call getDeclaredTypeOfSymbol. - // This check is important because without it, a call to getTypeOfSymbol could end - // up recursively calling getTypeOfAlias, causing a stack overflow. - links.type = targetSymbol.flags & 107455 /* Value */ - ? getTypeOfSymbol(targetSymbol) - : unknownType; - } - return links.type; - } - function getTypeOfInstantiatedSymbol(symbol) { - var links = getSymbolLinks(symbol); - if (!links.type) { - links.type = instantiateType(getTypeOfSymbol(links.target), links.mapper); - } - return links.type; - } - function getTypeOfSymbol(symbol) { - if (symbol.flags & 16777216 /* Instantiated */) { - return getTypeOfInstantiatedSymbol(symbol); - } - if (symbol.flags & (3 /* Variable */ | 4 /* Property */)) { - return getTypeOfVariableOrParameterOrProperty(symbol); - } - if (symbol.flags & (16 /* Function */ | 8192 /* Method */ | 32 /* Class */ | 384 /* Enum */ | 512 /* ValueModule */)) { - return getTypeOfFuncClassEnumModule(symbol); - } - if (symbol.flags & 8 /* EnumMember */) { - return getTypeOfEnumMember(symbol); - } - if (symbol.flags & 98304 /* Accessor */) { - return getTypeOfAccessors(symbol); - } - if (symbol.flags & 8388608 /* Alias */) { - return getTypeOfAlias(symbol); - } - return unknownType; - } - function getTargetType(type) { - return type.flags & 4096 /* Reference */ ? type.target : type; - } - function hasBaseType(type, checkBase) { - return check(type); - function check(type) { - var target = getTargetType(type); - return target === checkBase || ts.forEach(getBaseTypes(target), check); - } - } - // Appends the type parameters given by a list of declarations to a set of type parameters and returns the resulting set. - // The function allocates a new array if the input type parameter set is undefined, but otherwise it modifies the set - // in-place and returns the same array. - function appendTypeParameters(typeParameters, declarations) { - for (var _i = 0; _i < declarations.length; _i++) { - var declaration = declarations[_i]; - var tp = getDeclaredTypeOfTypeParameter(getSymbolOfNode(declaration)); - if (!typeParameters) { - typeParameters = [tp]; - } - else if (!ts.contains(typeParameters, tp)) { - typeParameters.push(tp); - } - } - return typeParameters; - } - // Appends the outer type parameters of a node to a set of type parameters and returns the resulting set. The function - // allocates a new array if the input type parameter set is undefined, but otherwise it modifies the set in-place and - // returns the same array. - function appendOuterTypeParameters(typeParameters, node) { - while (true) { - node = node.parent; - if (!node) { - return typeParameters; - } - if (node.kind === 214 /* ClassDeclaration */ || node.kind === 186 /* ClassExpression */ || - node.kind === 213 /* FunctionDeclaration */ || node.kind === 173 /* FunctionExpression */ || - node.kind === 143 /* MethodDeclaration */ || node.kind === 174 /* ArrowFunction */) { - var declarations = node.typeParameters; - if (declarations) { - return appendTypeParameters(appendOuterTypeParameters(typeParameters, node), declarations); - } - } - } - } - // 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, 215 /* InterfaceDeclaration */); - return appendOuterTypeParameters(undefined, declaration); - } - // The local type parameters are the combined set of type parameters from all declarations of the class, - // interface, or type alias. - function getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol) { - var result; - for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { - var node = _a[_i]; - if (node.kind === 215 /* InterfaceDeclaration */ || node.kind === 214 /* ClassDeclaration */ || - node.kind === 186 /* ClassExpression */ || node.kind === 216 /* TypeAliasDeclaration */) { - var declaration = node; - if (declaration.typeParameters) { - result = appendTypeParameters(result, declaration.typeParameters); - } - } - } - return result; - } - // The full set of type parameters for a generic class or interface type consists of its outer type parameters plus - // its locally declared type parameters. - function getTypeParametersOfClassOrInterface(symbol) { - return ts.concatenate(getOuterTypeParametersOfClassOrInterface(symbol), getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol)); - } - function isConstructorType(type) { - return type.flags & 80896 /* ObjectType */ && getSignaturesOfType(type, 1 /* Construct */).length > 0; - } - function getBaseTypeNodeOfClass(type) { - return ts.getClassExtendsHeritageClauseElement(type.symbol.valueDeclaration); - } - function getConstructorsForTypeArguments(type, typeArgumentNodes) { - var typeArgCount = typeArgumentNodes ? typeArgumentNodes.length : 0; - return ts.filter(getSignaturesOfType(type, 1 /* Construct */), function (sig) { return (sig.typeParameters ? sig.typeParameters.length : 0) === typeArgCount; }); - } - function getInstantiatedConstructorsForTypeArguments(type, typeArgumentNodes) { - var signatures = getConstructorsForTypeArguments(type, typeArgumentNodes); - if (typeArgumentNodes) { - var typeArguments = ts.map(typeArgumentNodes, getTypeFromTypeNode); - signatures = ts.map(signatures, function (sig) { return getSignatureInstantiation(sig, typeArguments); }); - } - return signatures; - } - // The base constructor of a class can resolve to - // undefinedType if the class has no extends clause, - // 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) { - if (!type.resolvedBaseConstructorType) { - var baseTypeNode = getBaseTypeNodeOfClass(type); - if (!baseTypeNode) { - return type.resolvedBaseConstructorType = undefinedType; - } - if (!pushTypeResolution(type, 1 /* ResolvedBaseConstructorType */)) { - return unknownType; - } - var baseConstructorType = checkExpression(baseTypeNode.expression); - if (baseConstructorType.flags & 80896 /* 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); - } - if (!popTypeResolution()) { - error(type.symbol.valueDeclaration, ts.Diagnostics._0_is_referenced_directly_or_indirectly_in_its_own_base_expression, symbolToString(type.symbol)); - return type.resolvedBaseConstructorType = unknownType; - } - if (baseConstructorType !== unknownType && baseConstructorType !== nullType && !isConstructorType(baseConstructorType)) { - error(baseTypeNode.expression, ts.Diagnostics.Type_0_is_not_a_constructor_function_type, typeToString(baseConstructorType)); - return type.resolvedBaseConstructorType = unknownType; - } - type.resolvedBaseConstructorType = baseConstructorType; - } - return type.resolvedBaseConstructorType; - } - function hasClassBaseType(type) { - return !!ts.forEach(getBaseTypes(type), function (t) { return !!(t.symbol.flags & 32 /* Class */); }); - } - function getBaseTypes(type) { - var isClass = type.symbol.flags & 32 /* Class */; - var isInterface = type.symbol.flags & 64 /* Interface */; - if (!type.resolvedBaseTypes) { - if (!isClass && !isInterface) { - ts.Debug.fail("type must be class or interface"); - } - if (isClass) { - resolveBaseTypesOfClass(type); - } - if (isInterface) { - resolveBaseTypesOfInterface(type); - } - } - return type.resolvedBaseTypes; - } - function resolveBaseTypesOfClass(type) { - type.resolvedBaseTypes = type.resolvedBaseTypes || emptyArray; - var baseContructorType = getBaseConstructorTypeOfClass(type); - if (!(baseContructorType.flags & 80896 /* ObjectType */)) { - return; - } - var baseTypeNode = getBaseTypeNodeOfClass(type); - var baseType; - if (baseContructorType.symbol && baseContructorType.symbol.flags & 32 /* Class */) { - // When base constructor type is a class we know that the constructors all have the same type parameters as the - // class and all return the instance type of the class. There is no need for further checks and we can apply the - // type arguments in the same manner as a type reference to get the same error reporting experience. - baseType = getTypeFromClassOrInterfaceReference(baseTypeNode, baseContructorType.symbol); - } - else { - // The class derives from a "class-like" constructor function, check that we have at least one construct signature - // with a matching number of type parameters and use the return type of the first instantiated signature. Elsewhere - // we check that all instantiated signatures return the same type. - var constructors = getInstantiatedConstructorsForTypeArguments(baseContructorType, baseTypeNode.typeArguments); - if (!constructors.length) { - error(baseTypeNode.expression, ts.Diagnostics.No_base_constructor_has_the_specified_number_of_type_arguments); - return; - } - baseType = getReturnTypeOfSignature(constructors[0]); - } - if (baseType === unknownType) { - return; - } - if (!(getTargetType(baseType).flags & (1024 /* Class */ | 2048 /* Interface */))) { - error(baseTypeNode.expression, ts.Diagnostics.Base_constructor_return_type_0_is_not_a_class_or_interface_type, typeToString(baseType)); - return; - } - if (type === baseType || hasBaseType(baseType, type)) { - error(type.symbol.valueDeclaration, ts.Diagnostics.Type_0_recursively_references_itself_as_a_base_type, typeToString(type, /*enclosingDeclaration*/ undefined, 1 /* WriteArrayAsGenericType */)); - return; - } - if (type.resolvedBaseTypes === emptyArray) { - type.resolvedBaseTypes = [baseType]; - } - else { - type.resolvedBaseTypes.push(baseType); - } - } - function resolveBaseTypesOfInterface(type) { - type.resolvedBaseTypes = type.resolvedBaseTypes || emptyArray; - for (var _i = 0, _a = type.symbol.declarations; _i < _a.length; _i++) { - var declaration = _a[_i]; - if (declaration.kind === 215 /* InterfaceDeclaration */ && ts.getInterfaceBaseTypeNodes(declaration)) { - for (var _b = 0, _c = ts.getInterfaceBaseTypeNodes(declaration); _b < _c.length; _b++) { - var node = _c[_b]; - var baseType = getTypeFromTypeNode(node); - if (baseType !== unknownType) { - if (getTargetType(baseType).flags & (1024 /* Class */ | 2048 /* Interface */)) { - if (type !== baseType && !hasBaseType(baseType, type)) { - if (type.resolvedBaseTypes === emptyArray) { - type.resolvedBaseTypes = [baseType]; - } - else { - type.resolvedBaseTypes.push(baseType); - } - } - else { - error(declaration, ts.Diagnostics.Type_0_recursively_references_itself_as_a_base_type, typeToString(type, /*enclosingDeclaration*/ undefined, 1 /* WriteArrayAsGenericType */)); - } - } - else { - error(node, ts.Diagnostics.An_interface_may_only_extend_a_class_or_another_interface); - } - } - } - } - } - } - // Returns true if the interface given by the symbol is free of "this" references. Specifically, the result is - // true if the interface itself contains no references to "this" in its body, if all base types are interfaces, - // and if none of the base interfaces have a "this" type. - function isIndependentInterface(symbol) { - for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { - var declaration = _a[_i]; - if (declaration.kind === 215 /* InterfaceDeclaration */) { - if (declaration.flags & 524288 /* ContainsThis */) { - return false; - } - var baseTypeNodes = ts.getInterfaceBaseTypeNodes(declaration); - if (baseTypeNodes) { - for (var _b = 0; _b < baseTypeNodes.length; _b++) { - var node = baseTypeNodes[_b]; - if (ts.isSupportedExpressionWithTypeArguments(node)) { - var baseSymbol = resolveEntityName(node.expression, 793056 /* Type */, /*ignoreErrors*/ true); - if (!baseSymbol || !(baseSymbol.flags & 64 /* Interface */) || getDeclaredTypeOfClassOrInterface(baseSymbol).thisType) { - return false; - } - } - } - } - } - } - return true; - } - function getDeclaredTypeOfClassOrInterface(symbol) { - var links = getSymbolLinks(symbol); - if (!links.declaredType) { - var kind = symbol.flags & 32 /* Class */ ? 1024 /* Class */ : 2048 /* Interface */; - var type = links.declaredType = createObjectType(kind, symbol); - var outerTypeParameters = getOuterTypeParametersOfClassOrInterface(symbol); - var localTypeParameters = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol); - // A class or interface is generic if it has type parameters or a "this" type. We always give classes a "this" type - // because it is not feasible to analyze all members to determine if the "this" type escapes the class (in particular, - // property types inferred from initializers and method return types inferred from return statements are very hard - // to exhaustively analyze). We give interfaces a "this" type if we can't definitely determine that they are free of - // "this" references. - if (outerTypeParameters || localTypeParameters || kind === 1024 /* Class */ || !isIndependentInterface(symbol)) { - type.flags |= 4096 /* Reference */; - type.typeParameters = ts.concatenate(outerTypeParameters, localTypeParameters); - type.outerTypeParameters = outerTypeParameters; - type.localTypeParameters = localTypeParameters; - type.instantiations = {}; - type.instantiations[getTypeListId(type.typeParameters)] = type; - type.target = type; - type.typeArguments = type.typeParameters; - type.thisType = createType(512 /* TypeParameter */ | 33554432 /* ThisType */); - type.thisType.symbol = symbol; - type.thisType.constraint = getTypeWithThisArgument(type); - } - } - return links.declaredType; - } - function getDeclaredTypeOfTypeAlias(symbol) { - var links = getSymbolLinks(symbol); - if (!links.declaredType) { - // Note that we use the links object as the target here because the symbol object is used as the unique - // identity for resolution of the 'type' property in SymbolLinks. - if (!pushTypeResolution(symbol, 2 /* DeclaredType */)) { - return unknownType; - } - var declaration = ts.getDeclarationOfKind(symbol, 216 /* TypeAliasDeclaration */); - var type = getTypeFromTypeNode(declaration.type); - if (popTypeResolution()) { - links.typeParameters = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol); - if (links.typeParameters) { - // Initialize the instantiation cache for generic type aliases. The declared type corresponds to - // an instantiation of the type alias with the type parameters supplied as type arguments. - links.instantiations = {}; - links.instantiations[getTypeListId(links.typeParameters)] = type; - } - } - else { - type = unknownType; - error(declaration.name, ts.Diagnostics.Type_alias_0_circularly_references_itself, symbolToString(symbol)); - } - links.declaredType = type; - } - return links.declaredType; - } - function getDeclaredTypeOfEnum(symbol) { - var links = getSymbolLinks(symbol); - if (!links.declaredType) { - var type = createType(128 /* Enum */); - type.symbol = symbol; - links.declaredType = type; - } - return links.declaredType; - } - function getDeclaredTypeOfTypeParameter(symbol) { - var links = getSymbolLinks(symbol); - if (!links.declaredType) { - var type = createType(512 /* TypeParameter */); - type.symbol = symbol; - if (!ts.getDeclarationOfKind(symbol, 137 /* TypeParameter */).constraint) { - type.constraint = noConstraintType; - } - links.declaredType = type; - } - return links.declaredType; - } - function getDeclaredTypeOfAlias(symbol) { - var links = getSymbolLinks(symbol); - if (!links.declaredType) { - links.declaredType = getDeclaredTypeOfSymbol(resolveAlias(symbol)); - } - return links.declaredType; - } - function getDeclaredTypeOfSymbol(symbol) { - ts.Debug.assert((symbol.flags & 16777216 /* Instantiated */) === 0); - if (symbol.flags & (32 /* Class */ | 64 /* Interface */)) { - return getDeclaredTypeOfClassOrInterface(symbol); - } - if (symbol.flags & 524288 /* TypeAlias */) { - return getDeclaredTypeOfTypeAlias(symbol); - } - if (symbol.flags & 384 /* Enum */) { - return getDeclaredTypeOfEnum(symbol); - } - if (symbol.flags & 262144 /* TypeParameter */) { - return getDeclaredTypeOfTypeParameter(symbol); - } - if (symbol.flags & 8388608 /* Alias */) { - return getDeclaredTypeOfAlias(symbol); - } - return unknownType; - } - // A type reference is considered independent if each type argument is considered independent. - function isIndependentTypeReference(node) { - if (node.typeArguments) { - for (var _i = 0, _a = node.typeArguments; _i < _a.length; _i++) { - var typeNode = _a[_i]; - if (!isIndependentType(typeNode)) { - return false; - } - } - } - return true; - } - // A type is considered independent if it the any, string, number, boolean, symbol, or void keyword, a string - // literal type, an array with an element type that is considered independent, or a type reference that is - // considered independent. - function isIndependentType(node) { - switch (node.kind) { - case 117 /* AnyKeyword */: - case 130 /* StringKeyword */: - case 128 /* NumberKeyword */: - case 120 /* BooleanKeyword */: - case 131 /* SymbolKeyword */: - case 103 /* VoidKeyword */: - case 9 /* StringLiteral */: - return true; - case 156 /* ArrayType */: - return isIndependentType(node.elementType); - case 151 /* TypeReference */: - return isIndependentTypeReference(node); - } - return false; - } - // A variable-like declaration is considered independent (free of this references) if it has a type annotation - // that specifies an independent type, or if it has no type annotation and no initializer (and thus of type any). - function isIndependentVariableLikeDeclaration(node) { - return node.type && isIndependentType(node.type) || !node.type && !node.initializer; - } - // A function-like declaration is considered independent (free of this references) if it has a return type - // annotation that is considered independent and if each parameter is considered independent. - function isIndependentFunctionLikeDeclaration(node) { - if (node.kind !== 144 /* Constructor */ && (!node.type || !isIndependentType(node.type))) { - return false; - } - for (var _i = 0, _a = node.parameters; _i < _a.length; _i++) { - var parameter = _a[_i]; - if (!isIndependentVariableLikeDeclaration(parameter)) { - return false; - } - } - return true; - } - // Returns true if the class or interface member given by the symbol is free of "this" references. The - // function may return false for symbols that are actually free of "this" references because it is not - // feasible to perform a complete analysis in all cases. In particular, property members with types - // inferred from their initializers and function members with inferred return types are convervatively - // assumed not to be free of "this" references. - function isIndependentMember(symbol) { - if (symbol.declarations && symbol.declarations.length === 1) { - var declaration = symbol.declarations[0]; - if (declaration) { - switch (declaration.kind) { - case 141 /* PropertyDeclaration */: - case 140 /* PropertySignature */: - return isIndependentVariableLikeDeclaration(declaration); - case 143 /* MethodDeclaration */: - case 142 /* MethodSignature */: - case 144 /* Constructor */: - return isIndependentFunctionLikeDeclaration(declaration); - } - } - } - return false; - } - function createSymbolTable(symbols) { - var result = {}; - for (var _i = 0; _i < symbols.length; _i++) { - var symbol = symbols[_i]; - result[symbol.name] = symbol; - } - return result; - } - // The mappingThisOnly flag indicates that the only type parameter being mapped is "this". When the flag is true, - // we check symbols to see if we can quickly conclude they are free of "this" references, thus needing no instantiation. - function createInstantiatedSymbolTable(symbols, mapper, mappingThisOnly) { - var result = {}; - for (var _i = 0; _i < symbols.length; _i++) { - var symbol = symbols[_i]; - result[symbol.name] = mappingThisOnly && isIndependentMember(symbol) ? symbol : instantiateSymbol(symbol, mapper); - } - return result; - } - function addInheritedMembers(symbols, baseSymbols) { - for (var _i = 0; _i < baseSymbols.length; _i++) { - var s = baseSymbols[_i]; - if (!ts.hasProperty(symbols, s.name)) { - symbols[s.name] = s; - } - } - } - function addInheritedSignatures(signatures, baseSignatures) { - if (baseSignatures) { - for (var _i = 0; _i < baseSignatures.length; _i++) { - var signature = baseSignatures[_i]; - signatures.push(signature); - } - } - } - function resolveDeclaredMembers(type) { - if (!type.declaredProperties) { - var symbol = type.symbol; - type.declaredProperties = getNamedMembers(symbol.members); - type.declaredCallSignatures = getSignaturesOfSymbol(symbol.members["__call"]); - type.declaredConstructSignatures = getSignaturesOfSymbol(symbol.members["__new"]); - type.declaredStringIndexType = getIndexTypeOfSymbol(symbol, 0 /* String */); - type.declaredNumberIndexType = getIndexTypeOfSymbol(symbol, 1 /* Number */); - } - return type; - } - function getTypeWithThisArgument(type, thisArgument) { - if (type.flags & 4096 /* Reference */) { - return createTypeReference(type.target, ts.concatenate(type.typeArguments, [thisArgument || type.target.thisType])); - } - return type; - } - function resolveObjectTypeMembers(type, source, typeParameters, typeArguments) { - var mapper = identityMapper; - var members = source.symbol.members; - var callSignatures = source.declaredCallSignatures; - var constructSignatures = source.declaredConstructSignatures; - var stringIndexType = source.declaredStringIndexType; - var numberIndexType = source.declaredNumberIndexType; - if (!ts.rangeEquals(typeParameters, typeArguments, 0, typeParameters.length)) { - mapper = createTypeMapper(typeParameters, typeArguments); - members = createInstantiatedSymbolTable(source.declaredProperties, mapper, /*mappingThisOnly*/ typeParameters.length === 1); - callSignatures = instantiateList(source.declaredCallSignatures, mapper, instantiateSignature); - constructSignatures = instantiateList(source.declaredConstructSignatures, mapper, instantiateSignature); - stringIndexType = instantiateType(source.declaredStringIndexType, mapper); - numberIndexType = instantiateType(source.declaredNumberIndexType, mapper); - } - var baseTypes = getBaseTypes(source); - if (baseTypes.length) { - if (members === source.symbol.members) { - members = createSymbolTable(source.declaredProperties); - } - var thisArgument = ts.lastOrUndefined(typeArguments); - for (var _i = 0; _i < baseTypes.length; _i++) { - var baseType = baseTypes[_i]; - var instantiatedBaseType = thisArgument ? getTypeWithThisArgument(instantiateType(baseType, mapper), thisArgument) : baseType; - addInheritedMembers(members, getPropertiesOfObjectType(instantiatedBaseType)); - callSignatures = ts.concatenate(callSignatures, getSignaturesOfType(instantiatedBaseType, 0 /* Call */)); - constructSignatures = ts.concatenate(constructSignatures, getSignaturesOfType(instantiatedBaseType, 1 /* Construct */)); - stringIndexType = stringIndexType || getIndexTypeOfType(instantiatedBaseType, 0 /* String */); - numberIndexType = numberIndexType || getIndexTypeOfType(instantiatedBaseType, 1 /* Number */); - } - } - setObjectTypeMembers(type, members, callSignatures, constructSignatures, stringIndexType, numberIndexType); - } - function resolveClassOrInterfaceMembers(type) { - resolveObjectTypeMembers(type, resolveDeclaredMembers(type), emptyArray, emptyArray); - } - function resolveTypeReferenceMembers(type) { - var source = resolveDeclaredMembers(type.target); - var typeParameters = ts.concatenate(source.typeParameters, [source.thisType]); - var typeArguments = type.typeArguments && type.typeArguments.length === typeParameters.length ? - type.typeArguments : ts.concatenate(type.typeArguments, [type]); - resolveObjectTypeMembers(type, source, typeParameters, typeArguments); - } - function createSignature(declaration, typeParameters, parameters, resolvedReturnType, typePredicate, minArgumentCount, hasRestParameter, hasStringLiterals) { - var sig = new Signature(checker); - sig.declaration = declaration; - sig.typeParameters = typeParameters; - sig.parameters = parameters; - sig.resolvedReturnType = resolvedReturnType; - sig.typePredicate = typePredicate; - sig.minArgumentCount = minArgumentCount; - sig.hasRestParameter = hasRestParameter; - sig.hasStringLiterals = hasStringLiterals; - return sig; - } - function cloneSignature(sig) { - return createSignature(sig.declaration, sig.typeParameters, sig.parameters, sig.resolvedReturnType, sig.typePredicate, sig.minArgumentCount, sig.hasRestParameter, sig.hasStringLiterals); - } - function getDefaultConstructSignatures(classType) { - if (!hasClassBaseType(classType)) { - return [createSignature(undefined, classType.localTypeParameters, emptyArray, classType, undefined, 0, false, false)]; - } - var baseConstructorType = getBaseConstructorTypeOfClass(classType); - var baseSignatures = getSignaturesOfType(baseConstructorType, 1 /* Construct */); - var baseTypeNode = getBaseTypeNodeOfClass(classType); - var typeArguments = ts.map(baseTypeNode.typeArguments, getTypeFromTypeNode); - var typeArgCount = typeArguments ? typeArguments.length : 0; - var result = []; - for (var _i = 0; _i < baseSignatures.length; _i++) { - var baseSig = baseSignatures[_i]; - var typeParamCount = baseSig.typeParameters ? baseSig.typeParameters.length : 0; - if (typeParamCount === typeArgCount) { - var sig = typeParamCount ? getSignatureInstantiation(baseSig, typeArguments) : cloneSignature(baseSig); - sig.typeParameters = classType.localTypeParameters; - sig.resolvedReturnType = classType; - result.push(sig); - } - } - return result; - } - function createTupleTypeMemberSymbols(memberTypes) { - var members = {}; - for (var i = 0; i < memberTypes.length; i++) { - var symbol = createSymbol(4 /* Property */ | 67108864 /* Transient */, "" + i); - symbol.type = memberTypes[i]; - members[i] = symbol; - } - return members; - } - function resolveTupleTypeMembers(type) { - var arrayElementType = getUnionType(type.elementTypes, /*noSubtypeReduction*/ true); - // Make the tuple type itself the 'this' type by including an extra type argument - var arrayType = resolveStructuredTypeMembers(createTypeFromGenericGlobalType(globalArrayType, [arrayElementType, type])); - var members = createTupleTypeMemberSymbols(type.elementTypes); - addInheritedMembers(members, arrayType.properties); - setObjectTypeMembers(type, members, arrayType.callSignatures, arrayType.constructSignatures, arrayType.stringIndexType, arrayType.numberIndexType); - } - function findMatchingSignature(signatureList, signature, partialMatch, ignoreReturnTypes) { - for (var _i = 0; _i < signatureList.length; _i++) { - var s = signatureList[_i]; - if (compareSignatures(s, signature, partialMatch, ignoreReturnTypes, compareTypes)) { - return s; - } - } - } - function findMatchingSignatures(signatureLists, signature, listIndex) { - if (signature.typeParameters) { - // We require an exact match for generic signatures, so we only return signatures from the first - // signature list and only if they have exact matches in the other signature lists. - if (listIndex > 0) { - return undefined; - } - for (var i = 1; i < signatureLists.length; i++) { - if (!findMatchingSignature(signatureLists[i], signature, /*partialMatch*/ false, /*ignoreReturnTypes*/ false)) { - return undefined; - } - } - return [signature]; - } - var result = undefined; - for (var i = 0; i < signatureLists.length; i++) { - // Allow matching non-generic signatures to have excess parameters and different return types - var match = i === listIndex ? signature : findMatchingSignature(signatureLists[i], signature, /*partialMatch*/ true, /*ignoreReturnTypes*/ true); - if (!match) { - return undefined; - } - if (!ts.contains(result, match)) { - (result || (result = [])).push(match); - } - } - return result; - } - // The signatures of a union type are those signatures that are present in each of the constituent types. - // Generic signatures must match exactly, but non-generic signatures are allowed to have extra optional - // parameters and may differ in return types. When signatures differ in return types, the resulting return - // type is the union of the constituent return types. - function getUnionSignatures(types, kind) { - var signatureLists = ts.map(types, function (t) { return getSignaturesOfType(t, kind); }); - var result = undefined; - for (var i = 0; i < signatureLists.length; i++) { - for (var _i = 0, _a = signatureLists[i]; _i < _a.length; _i++) { - var signature = _a[_i]; - // Only process signatures with parameter lists that aren't already in the result list - if (!result || !findMatchingSignature(result, signature, /*partialMatch*/ false, /*ignoreReturnTypes*/ true)) { - var unionSignatures = findMatchingSignatures(signatureLists, signature, i); - if (unionSignatures) { - var s = signature; - // Union the result types when more than one signature matches - if (unionSignatures.length > 1) { - s = cloneSignature(signature); - // Clear resolved return type we possibly got from cloneSignature - s.resolvedReturnType = undefined; - s.unionSignatures = unionSignatures; - } - (result || (result = [])).push(s); - } - } - } - } - return result || emptyArray; - } - function getUnionIndexType(types, kind) { - var indexTypes = []; - for (var _i = 0; _i < types.length; _i++) { - var type = types[_i]; - var indexType = getIndexTypeOfType(type, kind); - if (!indexType) { - return undefined; - } - indexTypes.push(indexType); - } - return getUnionType(indexTypes); - } - function resolveUnionTypeMembers(type) { - // The members and properties collections are empty for union types. To get all properties of a union - // type use getPropertiesOfType (only the language service uses this). - var callSignatures = getUnionSignatures(type.types, 0 /* Call */); - var constructSignatures = getUnionSignatures(type.types, 1 /* Construct */); - var stringIndexType = getUnionIndexType(type.types, 0 /* String */); - var numberIndexType = getUnionIndexType(type.types, 1 /* Number */); - setObjectTypeMembers(type, emptySymbols, callSignatures, constructSignatures, stringIndexType, numberIndexType); - } - function intersectTypes(type1, type2) { - return !type1 ? type2 : !type2 ? type1 : getIntersectionType([type1, type2]); - } - function resolveIntersectionTypeMembers(type) { - // The members and properties collections are empty for intersection types. To get all properties of an - // intersection type use getPropertiesOfType (only the language service uses this). - var callSignatures = emptyArray; - var constructSignatures = emptyArray; - var stringIndexType = undefined; - var numberIndexType = undefined; - for (var _i = 0, _a = type.types; _i < _a.length; _i++) { - var t = _a[_i]; - callSignatures = ts.concatenate(callSignatures, getSignaturesOfType(t, 0 /* Call */)); - constructSignatures = ts.concatenate(constructSignatures, getSignaturesOfType(t, 1 /* Construct */)); - stringIndexType = intersectTypes(stringIndexType, getIndexTypeOfType(t, 0 /* String */)); - numberIndexType = intersectTypes(numberIndexType, getIndexTypeOfType(t, 1 /* Number */)); - } - setObjectTypeMembers(type, emptySymbols, callSignatures, constructSignatures, stringIndexType, numberIndexType); - } - function resolveAnonymousTypeMembers(type) { - var symbol = type.symbol; - var members; - var callSignatures; - var constructSignatures; - var stringIndexType; - var numberIndexType; - if (type.target) { - members = createInstantiatedSymbolTable(getPropertiesOfObjectType(type.target), type.mapper, /*mappingThisOnly*/ false); - callSignatures = instantiateList(getSignaturesOfType(type.target, 0 /* Call */), type.mapper, instantiateSignature); - constructSignatures = instantiateList(getSignaturesOfType(type.target, 1 /* Construct */), type.mapper, instantiateSignature); - stringIndexType = instantiateType(getIndexTypeOfType(type.target, 0 /* String */), type.mapper); - numberIndexType = instantiateType(getIndexTypeOfType(type.target, 1 /* Number */), type.mapper); - } - else if (symbol.flags & 2048 /* TypeLiteral */) { - members = symbol.members; - callSignatures = getSignaturesOfSymbol(members["__call"]); - constructSignatures = getSignaturesOfSymbol(members["__new"]); - stringIndexType = getIndexTypeOfSymbol(symbol, 0 /* String */); - numberIndexType = getIndexTypeOfSymbol(symbol, 1 /* Number */); - } - else { - // Combinations of function, class, enum and module - members = emptySymbols; - callSignatures = emptyArray; - constructSignatures = emptyArray; - if (symbol.flags & 1952 /* HasExports */) { - members = getExportsOfSymbol(symbol); - } - if (symbol.flags & (16 /* Function */ | 8192 /* Method */)) { - callSignatures = getSignaturesOfSymbol(symbol); - } - if (symbol.flags & 32 /* Class */) { - var classType = getDeclaredTypeOfClassOrInterface(symbol); - constructSignatures = getSignaturesOfSymbol(symbol.members["__constructor"]); - if (!constructSignatures.length) { - constructSignatures = getDefaultConstructSignatures(classType); - } - var baseConstructorType = getBaseConstructorTypeOfClass(classType); - if (baseConstructorType.flags & 80896 /* ObjectType */) { - members = createSymbolTable(getNamedMembers(members)); - addInheritedMembers(members, getPropertiesOfObjectType(baseConstructorType)); - } - } - stringIndexType = undefined; - numberIndexType = (symbol.flags & 384 /* Enum */) ? stringType : undefined; - } - setObjectTypeMembers(type, members, callSignatures, constructSignatures, stringIndexType, numberIndexType); - } - function resolveStructuredTypeMembers(type) { - if (!type.members) { - if (type.flags & 4096 /* Reference */) { - resolveTypeReferenceMembers(type); - } - else if (type.flags & (1024 /* Class */ | 2048 /* Interface */)) { - resolveClassOrInterfaceMembers(type); - } - else if (type.flags & 65536 /* Anonymous */) { - resolveAnonymousTypeMembers(type); - } - else if (type.flags & 8192 /* Tuple */) { - resolveTupleTypeMembers(type); - } - else if (type.flags & 16384 /* Union */) { - resolveUnionTypeMembers(type); - } - else if (type.flags & 32768 /* Intersection */) { - resolveIntersectionTypeMembers(type); - } - } - return type; - } - // Return properties of an object type or an empty array for other types - function getPropertiesOfObjectType(type) { - if (type.flags & 80896 /* ObjectType */) { - return resolveStructuredTypeMembers(type).properties; - } - return emptyArray; - } - // 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, name) { - if (type.flags & 80896 /* ObjectType */) { - var resolved = resolveStructuredTypeMembers(type); - if (ts.hasProperty(resolved.members, name)) { - var symbol = resolved.members[name]; - if (symbolIsValue(symbol)) { - return symbol; - } - } - } - } - function getPropertiesOfUnionOrIntersectionType(type) { - for (var _i = 0, _a = type.types; _i < _a.length; _i++) { - var current = _a[_i]; - for (var _b = 0, _c = getPropertiesOfType(current); _b < _c.length; _b++) { - var prop = _c[_b]; - getPropertyOfUnionOrIntersectionType(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 - if (type.flags & 16384 /* Union */) { - break; - } - } - return type.resolvedProperties ? symbolsToArray(type.resolvedProperties) : emptyArray; - } - function getPropertiesOfType(type) { - type = getApparentType(type); - return type.flags & 49152 /* UnionOrIntersection */ ? getPropertiesOfUnionOrIntersectionType(type) : getPropertiesOfObjectType(type); - } - /** - * For a type parameter, return the base constraint of the type parameter. For the string, number, - * boolean, and symbol primitive types, return the corresponding object types. Otherwise return the - * type itself. Note that the apparent type of a union type is the union type itself. - */ - function getApparentType(type) { - if (type.flags & 512 /* TypeParameter */) { - do { - type = getConstraintOfTypeParameter(type); - } while (type && type.flags & 512 /* TypeParameter */); - if (!type) { - type = emptyObjectType; - } - } - if (type.flags & 258 /* StringLike */) { - type = globalStringType; - } - else if (type.flags & 132 /* NumberLike */) { - type = globalNumberType; - } - else if (type.flags & 8 /* Boolean */) { - type = globalBooleanType; - } - else if (type.flags & 16777216 /* ESSymbol */) { - type = globalESSymbolType; - } - return type; - } - function createUnionOrIntersectionProperty(containingType, name) { - var types = containingType.types; - var props; - for (var _i = 0; _i < types.length; _i++) { - var current = types[_i]; - var type = getApparentType(current); - if (type !== unknownType) { - var prop = getPropertyOfType(type, name); - if (prop && !(getDeclarationFlagsFromSymbol(prop) & (32 /* Private */ | 64 /* Protected */))) { - if (!props) { - props = [prop]; - } - else if (!ts.contains(props, prop)) { - props.push(prop); - } - } - else if (containingType.flags & 16384 /* Union */) { - // A union type requires the property to be present in all constituent types - return undefined; - } - } - } - if (!props) { - return undefined; - } - if (props.length === 1) { - return props[0]; - } - var propTypes = []; - var declarations = []; - for (var _a = 0; _a < props.length; _a++) { - var prop = props[_a]; - if (prop.declarations) { - ts.addRange(declarations, prop.declarations); - } - propTypes.push(getTypeOfSymbol(prop)); - } - var result = createSymbol(4 /* Property */ | 67108864 /* Transient */ | 268435456 /* SyntheticProperty */, name); - result.containingType = containingType; - result.declarations = declarations; - result.type = containingType.flags & 16384 /* Union */ ? getUnionType(propTypes) : getIntersectionType(propTypes); - return result; - } - function getPropertyOfUnionOrIntersectionType(type, name) { - var properties = type.resolvedProperties || (type.resolvedProperties = {}); - if (ts.hasProperty(properties, name)) { - return properties[name]; - } - var property = createUnionOrIntersectionProperty(type, name); - if (property) { - properties[name] = property; - } - return property; - } - // 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 - // Object and Function as appropriate. - function getPropertyOfType(type, name) { - type = getApparentType(type); - if (type.flags & 80896 /* ObjectType */) { - var resolved = resolveStructuredTypeMembers(type); - if (ts.hasProperty(resolved.members, name)) { - var symbol = resolved.members[name]; - if (symbolIsValue(symbol)) { - return symbol; - } - } - if (resolved === anyFunctionType || resolved.callSignatures.length || resolved.constructSignatures.length) { - var symbol = getPropertyOfObjectType(globalFunctionType, name); - if (symbol) { - return symbol; - } - } - return getPropertyOfObjectType(globalObjectType, name); - } - if (type.flags & 49152 /* UnionOrIntersection */) { - return getPropertyOfUnionOrIntersectionType(type, name); - } - return undefined; - } - function getSignaturesOfStructuredType(type, kind) { - if (type.flags & 130048 /* StructuredType */) { - var resolved = resolveStructuredTypeMembers(type); - return kind === 0 /* Call */ ? resolved.callSignatures : resolved.constructSignatures; - } - return emptyArray; - } - /** - * Return the signatures of the given kind in the given type. Creates synthetic union signatures when necessary and - * maps primitive types and type parameters are to their apparent types. - */ - function getSignaturesOfType(type, kind) { - return getSignaturesOfStructuredType(getApparentType(type), kind); - } - function typeHasConstructSignatures(type) { - var apparentType = getApparentType(type); - if (apparentType.flags & (80896 /* ObjectType */ | 16384 /* Union */)) { - var resolved = resolveStructuredTypeMembers(type); - return resolved.constructSignatures.length > 0; - } - return false; - } - function typeHasCallOrConstructSignatures(type) { - var apparentType = getApparentType(type); - if (apparentType.flags & 130048 /* StructuredType */) { - var resolved = resolveStructuredTypeMembers(type); - return resolved.callSignatures.length > 0 || resolved.constructSignatures.length > 0; - } - return false; - } - function getIndexTypeOfStructuredType(type, kind) { - if (type.flags & 130048 /* StructuredType */) { - var resolved = resolveStructuredTypeMembers(type); - return kind === 0 /* String */ ? resolved.stringIndexType : resolved.numberIndexType; - } - } - // Return the index type of the given kind in the given type. Creates synthetic union index types when necessary and - // maps primitive types and type parameters are to their apparent types. - function getIndexTypeOfType(type, kind) { - return getIndexTypeOfStructuredType(getApparentType(type), kind); - } - // Return list of type parameters with duplicates removed (duplicate identifier errors are generated in the actual - // type checking functions). - function getTypeParametersFromDeclaration(typeParameterDeclarations) { - var result = []; - ts.forEach(typeParameterDeclarations, function (node) { - var tp = getDeclaredTypeOfTypeParameter(node.symbol); - if (!ts.contains(result, tp)) { - result.push(tp); - } - }); - return result; - } - function symbolsToArray(symbols) { - var result = []; - for (var id in symbols) { - if (!isReservedMemberName(id)) { - result.push(symbols[id]); - } - } - return result; - } - function isOptionalParameter(node) { - if (ts.hasQuestionToken(node)) { - return true; - } - if (node.initializer) { - var signatureDeclaration = node.parent; - var signature = getSignatureFromDeclaration(signatureDeclaration); - var parameterIndex = signatureDeclaration.parameters.indexOf(node); - ts.Debug.assert(parameterIndex >= 0); - return parameterIndex >= signature.minArgumentCount; - } - return false; - } - function getSignatureFromDeclaration(declaration) { - var links = getNodeLinks(declaration); - if (!links.resolvedSignature) { - var classType = declaration.kind === 144 /* Constructor */ ? - getDeclaredTypeOfClassOrInterface(getMergedSymbol(declaration.parent.symbol)) - : undefined; - var typeParameters = classType ? classType.localTypeParameters : - declaration.typeParameters ? getTypeParametersFromDeclaration(declaration.typeParameters) : undefined; - var parameters = []; - var hasStringLiterals = false; - var minArgumentCount = -1; - for (var i = 0, n = declaration.parameters.length; i < n; i++) { - var param = declaration.parameters[i]; - parameters.push(param.symbol); - if (param.type && param.type.kind === 9 /* StringLiteral */) { - hasStringLiterals = true; - } - if (param.initializer || param.questionToken || param.dotDotDotToken) { - if (minArgumentCount < 0) { - minArgumentCount = i; - } - } - else { - // If we see any required parameters, it means the prior ones were not in fact optional. - minArgumentCount = -1; - } - } - if (minArgumentCount < 0) { - minArgumentCount = declaration.parameters.length; - } - var returnType; - var typePredicate; - if (classType) { - returnType = classType; - } - else if (declaration.type) { - returnType = getTypeFromTypeNode(declaration.type); - if (declaration.type.kind === 150 /* TypePredicate */) { - var typePredicateNode = declaration.type; - typePredicate = { - parameterName: typePredicateNode.parameterName ? typePredicateNode.parameterName.text : undefined, - parameterIndex: typePredicateNode.parameterName ? getTypePredicateParameterIndex(declaration.parameters, typePredicateNode.parameterName) : undefined, - type: getTypeFromTypeNode(typePredicateNode.type) - }; - } - } - else { - // TypeScript 1.0 spec (April 2014): - // If only one accessor includes a type annotation, the other behaves as if it had the same type annotation. - if (declaration.kind === 145 /* GetAccessor */ && !ts.hasDynamicName(declaration)) { - var setter = ts.getDeclarationOfKind(declaration.symbol, 146 /* SetAccessor */); - returnType = getAnnotatedAccessorType(setter); - } - if (!returnType && ts.nodeIsMissing(declaration.body)) { - returnType = anyType; - } - } - links.resolvedSignature = createSignature(declaration, typeParameters, parameters, returnType, typePredicate, minArgumentCount, ts.hasRestParameter(declaration), hasStringLiterals); - } - return links.resolvedSignature; - } - function getSignaturesOfSymbol(symbol) { - if (!symbol) - return emptyArray; - var result = []; - for (var i = 0, len = symbol.declarations.length; i < len; i++) { - var node = symbol.declarations[i]; - switch (node.kind) { - case 152 /* FunctionType */: - case 153 /* ConstructorType */: - case 213 /* FunctionDeclaration */: - case 143 /* MethodDeclaration */: - case 142 /* MethodSignature */: - case 144 /* Constructor */: - case 147 /* CallSignature */: - case 148 /* ConstructSignature */: - case 149 /* IndexSignature */: - case 145 /* GetAccessor */: - case 146 /* SetAccessor */: - case 173 /* FunctionExpression */: - case 174 /* ArrowFunction */: - // Don't include signature if node is the implementation of an overloaded function. A node is considered - // an implementation node if it has a body and the previous node is of the same kind and immediately - // precedes the implementation node (i.e. has the same parent and ends where the implementation starts). - if (i > 0 && node.body) { - var previous = symbol.declarations[i - 1]; - if (node.parent === previous.parent && node.kind === previous.kind && node.pos === previous.end) { - break; - } - } - result.push(getSignatureFromDeclaration(node)); - } - } - return result; - } - function getReturnTypeOfSignature(signature) { - if (!signature.resolvedReturnType) { - if (!pushTypeResolution(signature, 3 /* ResolvedReturnType */)) { - return unknownType; - } - var type; - if (signature.target) { - type = instantiateType(getReturnTypeOfSignature(signature.target), signature.mapper); - } - else if (signature.unionSignatures) { - type = getUnionType(ts.map(signature.unionSignatures, getReturnTypeOfSignature)); - } - else { - type = getReturnTypeFromBody(signature.declaration); - } - if (!popTypeResolution()) { - type = anyType; - if (compilerOptions.noImplicitAny) { - var declaration = signature.declaration; - if (declaration.name) { - error(declaration.name, 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, ts.declarationNameToString(declaration.name)); - } - else { - error(declaration, ts.Diagnostics.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); - } - } - } - signature.resolvedReturnType = type; - } - return signature.resolvedReturnType; - } - function getRestTypeOfSignature(signature) { - if (signature.hasRestParameter) { - var type = getTypeOfSymbol(ts.lastOrUndefined(signature.parameters)); - if (type.flags & 4096 /* Reference */ && type.target === globalArrayType) { - return type.typeArguments[0]; - } - } - return anyType; - } - function getSignatureInstantiation(signature, typeArguments) { - return instantiateSignature(signature, createTypeMapper(signature.typeParameters, typeArguments), true); - } - function getErasedSignature(signature) { - if (!signature.typeParameters) - return signature; - if (!signature.erasedSignatureCache) { - if (signature.target) { - signature.erasedSignatureCache = instantiateSignature(getErasedSignature(signature.target), signature.mapper); - } - else { - signature.erasedSignatureCache = instantiateSignature(signature, createTypeEraser(signature.typeParameters), true); - } - } - return signature.erasedSignatureCache; - } - function getOrCreateTypeFromSignature(signature) { - // There are two ways to declare a construct signature, one is by declaring a class constructor - // using the constructor keyword, and the other is declaring a bare construct signature in an - // 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 === 144 /* Constructor */ || signature.declaration.kind === 148 /* ConstructSignature */; - var type = createObjectType(65536 /* Anonymous */ | 262144 /* FromSignature */); - type.members = emptySymbols; - type.properties = emptyArray; - type.callSignatures = !isConstructor ? [signature] : emptyArray; - type.constructSignatures = isConstructor ? [signature] : emptyArray; - signature.isolatedSignatureType = type; - } - return signature.isolatedSignatureType; - } - function getIndexSymbol(symbol) { - return symbol.members["__index"]; - } - function getIndexDeclarationOfSymbol(symbol, kind) { - var syntaxKind = kind === 1 /* Number */ ? 128 /* NumberKeyword */ : 130 /* StringKeyword */; - var indexSymbol = getIndexSymbol(symbol); - if (indexSymbol) { - for (var _i = 0, _a = indexSymbol.declarations; _i < _a.length; _i++) { - var decl = _a[_i]; - var node = decl; - if (node.parameters.length === 1) { - var parameter = node.parameters[0]; - if (parameter && parameter.type && parameter.type.kind === syntaxKind) { - return node; - } - } - } - } - return undefined; - } - function getIndexTypeOfSymbol(symbol, kind) { - var declaration = getIndexDeclarationOfSymbol(symbol, kind); - return declaration - ? declaration.type ? getTypeFromTypeNode(declaration.type) : anyType - : undefined; - } - function getConstraintOfTypeParameter(type) { - if (!type.constraint) { - if (type.target) { - var targetConstraint = getConstraintOfTypeParameter(type.target); - type.constraint = targetConstraint ? instantiateType(targetConstraint, type.mapper) : noConstraintType; - } - else { - type.constraint = getTypeFromTypeNode(ts.getDeclarationOfKind(type.symbol, 137 /* TypeParameter */).constraint); - } - } - return type.constraint === noConstraintType ? undefined : type.constraint; - } - function getParentSymbolOfTypeParameter(typeParameter) { - return getSymbolOfNode(ts.getDeclarationOfKind(typeParameter.symbol, 137 /* TypeParameter */).parent); - } - function getTypeListId(types) { - if (types) { - switch (types.length) { - case 1: - return "" + types[0].id; - case 2: - return types[0].id + "," + types[1].id; - default: - var result = ""; - for (var i = 0; i < types.length; i++) { - if (i > 0) { - result += ","; - } - result += types[i].id; - } - return result; - } - } - return ""; - } - // This function is used to propagate certain flags when creating new object type references and union types. - // It is only necessary to do so if a constituent type might be the undefined type, the null type, the type - // of an object literal or the anyFunctionType. This is because there are operations in the type checker - // that care about the presence of such types at arbitrary depth in a containing type. - function getPropagatingFlagsOfTypes(types) { - var result = 0; - for (var _i = 0; _i < types.length; _i++) { - var type = types[_i]; - result |= type.flags; - } - return result & 14680064 /* PropagatingFlags */; - } - function createTypeReference(target, typeArguments) { - var id = getTypeListId(typeArguments); - var type = target.instantiations[id]; - if (!type) { - var flags = 4096 /* Reference */ | (typeArguments ? getPropagatingFlagsOfTypes(typeArguments) : 0); - type = target.instantiations[id] = createObjectType(flags, target.symbol); - type.target = target; - type.typeArguments = typeArguments; - } - return type; - } - function isTypeParameterReferenceIllegalInConstraint(typeReferenceNode, typeParameterSymbol) { - var links = getNodeLinks(typeReferenceNode); - if (links.isIllegalTypeReferenceInConstraint !== undefined) { - return links.isIllegalTypeReferenceInConstraint; - } - // bubble up to the declaration - var currentNode = typeReferenceNode; - // forEach === exists - while (!ts.forEach(typeParameterSymbol.declarations, function (d) { return d.parent === currentNode.parent; })) { - currentNode = currentNode.parent; - } - // if last step was made from the type parameter this means that path has started somewhere in constraint which is illegal - links.isIllegalTypeReferenceInConstraint = currentNode.kind === 137 /* TypeParameter */; - return links.isIllegalTypeReferenceInConstraint; - } - function checkTypeParameterHasIllegalReferencesInConstraint(typeParameter) { - var typeParameterSymbol; - function check(n) { - if (n.kind === 151 /* TypeReference */ && n.typeName.kind === 69 /* Identifier */) { - var links = getNodeLinks(n); - if (links.isIllegalTypeReferenceInConstraint === undefined) { - var symbol = resolveName(typeParameter, n.typeName.text, 793056 /* Type */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined); - if (symbol && (symbol.flags & 262144 /* TypeParameter */)) { - // TypeScript 1.0 spec (April 2014): 3.4.1 - // Type parameters declared in a particular type parameter list - // may not be referenced in constraints in that type parameter list - // symbol.declaration.parent === typeParameter.parent - // -> typeParameter and symbol.declaration originate from the same type parameter list - // -> illegal for all declarations in symbol - // forEach === exists - links.isIllegalTypeReferenceInConstraint = ts.forEach(symbol.declarations, function (d) { return d.parent === typeParameter.parent; }); - } - } - if (links.isIllegalTypeReferenceInConstraint) { - error(typeParameter, ts.Diagnostics.Constraint_of_a_type_parameter_cannot_reference_any_type_parameter_from_the_same_type_parameter_list); - } - } - ts.forEachChild(n, check); - } - if (typeParameter.constraint) { - typeParameterSymbol = getSymbolOfNode(typeParameter); - check(typeParameter.constraint); - } - } - // Get type from reference to class or interface - function getTypeFromClassOrInterfaceReference(node, symbol) { - var type = getDeclaredTypeOfSymbol(symbol); - var typeParameters = type.localTypeParameters; - if (typeParameters) { - if (!node.typeArguments || node.typeArguments.length !== typeParameters.length) { - error(node, ts.Diagnostics.Generic_type_0_requires_1_type_argument_s, typeToString(type, /*enclosingDeclaration*/ undefined, 1 /* WriteArrayAsGenericType */), typeParameters.length); - return unknownType; - } - // In a type reference, the outer type parameters of the referenced class or interface are automatically - // supplied as type arguments and the type reference only specifies arguments for the local type parameters - // of the class or interface. - return createTypeReference(type, ts.concatenate(type.outerTypeParameters, ts.map(node.typeArguments, getTypeFromTypeNode))); - } - if (node.typeArguments) { - error(node, ts.Diagnostics.Type_0_is_not_generic, typeToString(type)); - return unknownType; - } - return type; - } - // Get type from reference to type alias. When a type alias is generic, the declared type of the type alias may include - // references to the type parameters of the alias. We replace those with the actual type arguments by instantiating the - // declared type. Instantiations are cached using the type identities of the type arguments as the key. - function getTypeFromTypeAliasReference(node, symbol) { - var type = getDeclaredTypeOfSymbol(symbol); - var links = getSymbolLinks(symbol); - var typeParameters = links.typeParameters; - if (typeParameters) { - if (!node.typeArguments || node.typeArguments.length !== typeParameters.length) { - error(node, ts.Diagnostics.Generic_type_0_requires_1_type_argument_s, symbolToString(symbol), typeParameters.length); - return unknownType; - } - var typeArguments = ts.map(node.typeArguments, getTypeFromTypeNode); - var id = getTypeListId(typeArguments); - return links.instantiations[id] || (links.instantiations[id] = instantiateType(type, createTypeMapper(typeParameters, typeArguments))); - } - if (node.typeArguments) { - error(node, ts.Diagnostics.Type_0_is_not_generic, symbolToString(symbol)); - return unknownType; - } - return type; - } - // Get type from reference to named type that cannot be generic (enum or type parameter) - function getTypeFromNonGenericTypeReference(node, symbol) { - if (symbol.flags & 262144 /* TypeParameter */ && isTypeParameterReferenceIllegalInConstraint(node, symbol)) { - // TypeScript 1.0 spec (April 2014): 3.4.1 - // Type parameters declared in a particular type parameter list - // may not be referenced in constraints in that type parameter list - // Implementation: such type references are resolved to 'unknown' type that usually denotes error - return unknownType; - } - if (node.typeArguments) { - error(node, ts.Diagnostics.Type_0_is_not_generic, symbolToString(symbol)); - return unknownType; - } - return getDeclaredTypeOfSymbol(symbol); - } - function getTypeFromTypeReference(node) { - var links = getNodeLinks(node); - if (!links.resolvedType) { - // We only support expressions that are simple qualified names. For other expressions this produces undefined. - var typeNameOrExpression = node.kind === 151 /* TypeReference */ ? node.typeName : - ts.isSupportedExpressionWithTypeArguments(node) ? node.expression : - undefined; - var symbol = typeNameOrExpression && resolveEntityName(typeNameOrExpression, 793056 /* Type */) || unknownSymbol; - var type = symbol === unknownSymbol ? unknownType : - symbol.flags & (32 /* Class */ | 64 /* Interface */) ? getTypeFromClassOrInterfaceReference(node, symbol) : - symbol.flags & 524288 /* TypeAlias */ ? getTypeFromTypeAliasReference(node, symbol) : - getTypeFromNonGenericTypeReference(node, symbol); - // Cache both the resolved symbol and the resolved type. The resolved symbol is needed in when we check the - // type reference in checkTypeReferenceOrExpressionWithTypeArguments. - links.resolvedSymbol = symbol; - links.resolvedType = type; - } - return links.resolvedType; - } - function getTypeFromTypeQueryNode(node) { - var links = getNodeLinks(node); - if (!links.resolvedType) { - // TypeScript 1.0 spec (April 2014): 3.6.3 - // The expression is processed as an identifier expression (section 4.3) - // or property access expression(section 4.10), - // the widened type(section 3.9) of which becomes the result. - links.resolvedType = getWidenedType(checkExpression(node.exprName)); - } - return links.resolvedType; - } - function getTypeOfGlobalSymbol(symbol, arity) { - function getTypeDeclaration(symbol) { - var declarations = symbol.declarations; - for (var _i = 0; _i < declarations.length; _i++) { - var declaration = declarations[_i]; - switch (declaration.kind) { - case 214 /* ClassDeclaration */: - case 215 /* InterfaceDeclaration */: - case 217 /* EnumDeclaration */: - return declaration; - } - } - } - if (!symbol) { - return arity ? emptyGenericType : emptyObjectType; - } - var type = getDeclaredTypeOfSymbol(symbol); - if (!(type.flags & 80896 /* ObjectType */)) { - error(getTypeDeclaration(symbol), ts.Diagnostics.Global_type_0_must_be_a_class_or_interface_type, symbol.name); - return arity ? emptyGenericType : emptyObjectType; - } - if ((type.typeParameters ? type.typeParameters.length : 0) !== arity) { - error(getTypeDeclaration(symbol), ts.Diagnostics.Global_type_0_must_have_1_type_parameter_s, symbol.name, arity); - return arity ? emptyGenericType : emptyObjectType; - } - return type; - } - function getGlobalValueSymbol(name) { - return getGlobalSymbol(name, 107455 /* Value */, ts.Diagnostics.Cannot_find_global_value_0); - } - function getGlobalTypeSymbol(name) { - return getGlobalSymbol(name, 793056 /* Type */, ts.Diagnostics.Cannot_find_global_type_0); - } - function getGlobalSymbol(name, meaning, diagnostic) { - return resolveName(undefined, name, meaning, diagnostic, name); - } - function getGlobalType(name, arity) { - if (arity === void 0) { arity = 0; } - return getTypeOfGlobalSymbol(getGlobalTypeSymbol(name), arity); - } - function tryGetGlobalType(name, arity) { - if (arity === void 0) { arity = 0; } - return getTypeOfGlobalSymbol(getGlobalSymbol(name, 793056 /* Type */, /*diagnostic*/ undefined), arity); - } - /** - * Returns a type that is inside a namespace at the global scope, e.g. - * getExportedTypeFromNamespace('JSX', 'Element') returns the JSX.Element type - */ - function getExportedTypeFromNamespace(namespace, name) { - var namespaceSymbol = getGlobalSymbol(namespace, 1536 /* Namespace */, /*diagnosticMessage*/ undefined); - var typeSymbol = namespaceSymbol && getSymbol(namespaceSymbol.exports, name, 793056 /* Type */); - return typeSymbol && getDeclaredTypeOfSymbol(typeSymbol); - } - function getGlobalESSymbolConstructorSymbol() { - return globalESSymbolConstructorSymbol || (globalESSymbolConstructorSymbol = getGlobalValueSymbol("Symbol")); - } - /** - * Creates a TypeReference for a generic `TypedPropertyDescriptor`. - */ - function createTypedPropertyDescriptorType(propertyType) { - var globalTypedPropertyDescriptorType = getGlobalTypedPropertyDescriptorType(); - return globalTypedPropertyDescriptorType !== emptyGenericType - ? createTypeReference(globalTypedPropertyDescriptorType, [propertyType]) - : emptyObjectType; - } - /** - * Instantiates a global type that is generic with some element type, and returns that instantiation. - */ - function createTypeFromGenericGlobalType(genericGlobalType, typeArguments) { - return genericGlobalType !== emptyGenericType ? createTypeReference(genericGlobalType, typeArguments) : emptyObjectType; - } - function createIterableType(elementType) { - return createTypeFromGenericGlobalType(globalIterableType, [elementType]); - } - function createIterableIteratorType(elementType) { - return createTypeFromGenericGlobalType(globalIterableIteratorType, [elementType]); - } - function createArrayType(elementType) { - return createTypeFromGenericGlobalType(globalArrayType, [elementType]); - } - function getTypeFromArrayTypeNode(node) { - var links = getNodeLinks(node); - if (!links.resolvedType) { - links.resolvedType = createArrayType(getTypeFromTypeNode(node.elementType)); - } - return links.resolvedType; - } - function createTupleType(elementTypes) { - var id = getTypeListId(elementTypes); - return tupleTypes[id] || (tupleTypes[id] = createNewTupleType(elementTypes)); - } - function createNewTupleType(elementTypes) { - var type = createObjectType(8192 /* Tuple */ | getPropagatingFlagsOfTypes(elementTypes)); - type.elementTypes = elementTypes; - return type; - } - function getTypeFromTupleTypeNode(node) { - var links = getNodeLinks(node); - if (!links.resolvedType) { - links.resolvedType = createTupleType(ts.map(node.elementTypes, getTypeFromTypeNode)); - } - return links.resolvedType; - } - function addTypeToSet(typeSet, type, typeSetKind) { - if (type.flags & typeSetKind) { - addTypesToSet(typeSet, type.types, typeSetKind); - } - else if (!ts.contains(typeSet, type)) { - typeSet.push(type); - } - } - // Add the given types to the given type set. Order is preserved, duplicates are removed, - // and nested types of the given kind are flattened into the set. - function addTypesToSet(typeSet, types, typeSetKind) { - for (var _i = 0; _i < types.length; _i++) { - var type = types[_i]; - addTypeToSet(typeSet, type, typeSetKind); - } - } - function isSubtypeOfAny(candidate, types) { - for (var i = 0, len = types.length; i < len; i++) { - if (candidate !== types[i] && isTypeSubtypeOf(candidate, types[i])) { - return true; - } - } - return false; - } - function removeSubtypes(types) { - var i = types.length; - while (i > 0) { - i--; - if (isSubtypeOfAny(types[i], types)) { - types.splice(i, 1); - } - } - } - function containsTypeAny(types) { - for (var _i = 0; _i < types.length; _i++) { - var type = types[_i]; - if (isTypeAny(type)) { - return true; - } - } - return false; - } - function removeAllButLast(types, typeToRemove) { - var i = types.length; - while (i > 0 && types.length > 1) { - i--; - if (types[i] === typeToRemove) { - types.splice(i, 1); - } - } - } - // We reduce the constituent type set to only include types that aren't subtypes of other types, unless - // the noSubtypeReduction flag is specified, in which case we perform a simple deduplication based on - // object identity. Subtype reduction is possible only when union types are known not to circularly - // reference themselves (as is the case with union types created by expression constructs such as array - // literals and the || and ?: operators). Named types can circularly reference themselves and therefore - // cannot be deduplicated during their declaration. For example, "type Item = string | (() => Item" is - // a named type that circularly references itself. - function getUnionType(types, noSubtypeReduction) { - if (types.length === 0) { - return emptyObjectType; - } - var typeSet = []; - addTypesToSet(typeSet, types, 16384 /* Union */); - if (containsTypeAny(typeSet)) { - return anyType; - } - if (noSubtypeReduction) { - removeAllButLast(typeSet, undefinedType); - removeAllButLast(typeSet, nullType); - } - else { - removeSubtypes(typeSet); - } - if (typeSet.length === 1) { - return typeSet[0]; - } - var id = getTypeListId(typeSet); - var type = unionTypes[id]; - if (!type) { - type = unionTypes[id] = createObjectType(16384 /* Union */ | getPropagatingFlagsOfTypes(typeSet)); - type.types = typeSet; - } - return type; - } - function getTypeFromUnionTypeNode(node) { - var links = getNodeLinks(node); - if (!links.resolvedType) { - links.resolvedType = getUnionType(ts.map(node.types, getTypeFromTypeNode), /*noSubtypeReduction*/ true); - } - return links.resolvedType; - } - // 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. - // Also, unlike union types, the order of the constituent types is preserved in order that overload resolution - // for intersections of types with signatures can be deterministic. - function getIntersectionType(types) { - if (types.length === 0) { - return emptyObjectType; - } - var typeSet = []; - addTypesToSet(typeSet, types, 32768 /* Intersection */); - if (containsTypeAny(typeSet)) { - return anyType; - } - if (typeSet.length === 1) { - return typeSet[0]; - } - var id = getTypeListId(typeSet); - var type = intersectionTypes[id]; - if (!type) { - type = intersectionTypes[id] = createObjectType(32768 /* Intersection */ | getPropagatingFlagsOfTypes(typeSet)); - type.types = typeSet; - } - return type; - } - function getTypeFromIntersectionTypeNode(node) { - var links = getNodeLinks(node); - if (!links.resolvedType) { - links.resolvedType = getIntersectionType(ts.map(node.types, getTypeFromTypeNode)); - } - return links.resolvedType; - } - function getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node) { - var links = getNodeLinks(node); - if (!links.resolvedType) { - // Deferred resolution of members is handled by resolveObjectTypeMembers - links.resolvedType = createObjectType(65536 /* Anonymous */, node.symbol); - } - return links.resolvedType; - } - function getStringLiteralType(node) { - if (ts.hasProperty(stringLiteralTypes, node.text)) { - return stringLiteralTypes[node.text]; - } - var type = stringLiteralTypes[node.text] = createType(256 /* StringLiteral */); - type.text = ts.getTextOfNode(node); - return type; - } - function getTypeFromStringLiteral(node) { - var links = getNodeLinks(node); - if (!links.resolvedType) { - links.resolvedType = getStringLiteralType(node); - } - return links.resolvedType; - } - function getThisType(node) { - var container = ts.getThisContainer(node, /*includeArrowFunctions*/ false); - var parent = container && container.parent; - if (parent && (ts.isClassLike(parent) || parent.kind === 215 /* InterfaceDeclaration */)) { - if (!(container.flags & 128 /* Static */)) { - return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(parent)).thisType; - } - } - error(node, ts.Diagnostics.A_this_type_is_available_only_in_a_non_static_member_of_a_class_or_interface); - return unknownType; - } - function getTypeFromThisTypeNode(node) { - var links = getNodeLinks(node); - if (!links.resolvedType) { - links.resolvedType = getThisType(node); - } - return links.resolvedType; - } - function getTypeFromTypeNode(node) { - switch (node.kind) { - case 117 /* AnyKeyword */: - return anyType; - case 130 /* StringKeyword */: - return stringType; - case 128 /* NumberKeyword */: - return numberType; - case 120 /* BooleanKeyword */: - return booleanType; - case 131 /* SymbolKeyword */: - return esSymbolType; - case 103 /* VoidKeyword */: - return voidType; - case 97 /* ThisKeyword */: - return getTypeFromThisTypeNode(node); - case 9 /* StringLiteral */: - return getTypeFromStringLiteral(node); - case 151 /* TypeReference */: - return getTypeFromTypeReference(node); - case 150 /* TypePredicate */: - return booleanType; - case 188 /* ExpressionWithTypeArguments */: - return getTypeFromTypeReference(node); - case 154 /* TypeQuery */: - return getTypeFromTypeQueryNode(node); - case 156 /* ArrayType */: - return getTypeFromArrayTypeNode(node); - case 157 /* TupleType */: - return getTypeFromTupleTypeNode(node); - case 158 /* UnionType */: - return getTypeFromUnionTypeNode(node); - case 159 /* IntersectionType */: - return getTypeFromIntersectionTypeNode(node); - case 160 /* ParenthesizedType */: - return getTypeFromTypeNode(node.type); - case 152 /* FunctionType */: - case 153 /* ConstructorType */: - case 155 /* TypeLiteral */: - return getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node); - // This function assumes that an identifier or qualified name is a type expression - // Callers should first ensure this by calling isTypeNode - case 69 /* Identifier */: - case 135 /* QualifiedName */: - var symbol = getSymbolAtLocation(node); - return symbol && getDeclaredTypeOfSymbol(symbol); - default: - return unknownType; - } - } - function instantiateList(items, mapper, instantiator) { - if (items && items.length) { - var result = []; - for (var _i = 0; _i < items.length; _i++) { - var v = items[_i]; - result.push(instantiator(v, mapper)); - } - return result; - } - return items; - } - function createUnaryTypeMapper(source, target) { - return function (t) { return t === source ? target : t; }; - } - function createBinaryTypeMapper(source1, target1, source2, target2) { - return function (t) { return t === source1 ? target1 : t === source2 ? target2 : t; }; - } - function createTypeMapper(sources, targets) { - switch (sources.length) { - case 1: return createUnaryTypeMapper(sources[0], targets[0]); - case 2: return createBinaryTypeMapper(sources[0], targets[0], sources[1], targets[1]); - } - return function (t) { - for (var i = 0; i < sources.length; i++) { - if (t === sources[i]) { - return targets[i]; - } - } - return t; - }; - } - function createUnaryTypeEraser(source) { - return function (t) { return t === source ? anyType : t; }; - } - function createBinaryTypeEraser(source1, source2) { - return function (t) { return t === source1 || t === source2 ? anyType : t; }; - } - function createTypeEraser(sources) { - switch (sources.length) { - case 1: return createUnaryTypeEraser(sources[0]); - case 2: return createBinaryTypeEraser(sources[0], sources[1]); - } - return function (t) { - for (var _i = 0; _i < sources.length; _i++) { - var source = sources[_i]; - if (t === source) { - return anyType; - } - } - return t; - }; - } - function createInferenceMapper(context) { - var mapper = function (t) { - for (var i = 0; i < context.typeParameters.length; i++) { - if (t === context.typeParameters[i]) { - context.inferences[i].isFixed = true; - return getInferredType(context, i); - } - } - return t; - }; - mapper.context = context; - return mapper; - } - function identityMapper(type) { - return type; - } - function combineTypeMappers(mapper1, mapper2) { - return function (t) { return instantiateType(mapper1(t), mapper2); }; - } - function instantiateTypeParameter(typeParameter, mapper) { - var result = createType(512 /* TypeParameter */); - result.symbol = typeParameter.symbol; - if (typeParameter.constraint) { - result.constraint = instantiateType(typeParameter.constraint, mapper); - } - else { - result.target = typeParameter; - result.mapper = mapper; - } - return result; - } - function instantiateSignature(signature, mapper, eraseTypeParameters) { - var freshTypeParameters; - var freshTypePredicate; - if (signature.typeParameters && !eraseTypeParameters) { - freshTypeParameters = instantiateList(signature.typeParameters, mapper, instantiateTypeParameter); - mapper = combineTypeMappers(createTypeMapper(signature.typeParameters, freshTypeParameters), mapper); - } - if (signature.typePredicate) { - freshTypePredicate = { - parameterName: signature.typePredicate.parameterName, - parameterIndex: signature.typePredicate.parameterIndex, - type: instantiateType(signature.typePredicate.type, mapper) - }; - } - var result = createSignature(signature.declaration, freshTypeParameters, instantiateList(signature.parameters, mapper, instantiateSymbol), instantiateType(signature.resolvedReturnType, mapper), freshTypePredicate, signature.minArgumentCount, signature.hasRestParameter, signature.hasStringLiterals); - result.target = signature; - result.mapper = mapper; - return result; - } - function instantiateSymbol(symbol, mapper) { - if (symbol.flags & 16777216 /* Instantiated */) { - var links = getSymbolLinks(symbol); - // If symbol being instantiated is itself a instantiation, fetch the original target and combine the - // type mappers. This ensures that original type identities are properly preserved and that aliases - // always reference a non-aliases. - symbol = links.target; - mapper = combineTypeMappers(links.mapper, mapper); - } - // Keep the flags from the symbol we're instantiating. Mark that is instantiated, and - // also transient so that we can just store data on it directly. - var result = createSymbol(16777216 /* Instantiated */ | 67108864 /* Transient */ | symbol.flags, symbol.name); - result.declarations = symbol.declarations; - result.parent = symbol.parent; - result.target = symbol; - result.mapper = mapper; - if (symbol.valueDeclaration) { - result.valueDeclaration = symbol.valueDeclaration; - } - return result; - } - function instantiateAnonymousType(type, mapper) { - if (mapper.instantiations) { - var cachedType = mapper.instantiations[type.id]; - if (cachedType) { - return cachedType; - } - } - else { - mapper.instantiations = []; - } - // Mark the anonymous type as instantiated such that our infinite instantiation detection logic can recognize it - var result = createObjectType(65536 /* Anonymous */ | 131072 /* Instantiated */, type.symbol); - result.target = type; - result.mapper = mapper; - mapper.instantiations[type.id] = result; - return result; - } - function instantiateType(type, mapper) { - if (type && mapper !== identityMapper) { - if (type.flags & 512 /* TypeParameter */) { - return mapper(type); - } - if (type.flags & 65536 /* Anonymous */) { - return type.symbol && type.symbol.flags & (16 /* Function */ | 8192 /* Method */ | 32 /* Class */ | 2048 /* TypeLiteral */ | 4096 /* ObjectLiteral */) ? - instantiateAnonymousType(type, mapper) : type; - } - if (type.flags & 4096 /* Reference */) { - return createTypeReference(type.target, instantiateList(type.typeArguments, mapper, instantiateType)); - } - if (type.flags & 8192 /* Tuple */) { - return createTupleType(instantiateList(type.elementTypes, mapper, instantiateType)); - } - if (type.flags & 16384 /* Union */) { - return getUnionType(instantiateList(type.types, mapper, instantiateType), /*noSubtypeReduction*/ true); - } - if (type.flags & 32768 /* Intersection */) { - return getIntersectionType(instantiateList(type.types, mapper, instantiateType)); - } - } - return type; - } - // 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 !== 143 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); - switch (node.kind) { - case 173 /* FunctionExpression */: - case 174 /* ArrowFunction */: - return isContextSensitiveFunctionLikeDeclaration(node); - case 165 /* ObjectLiteralExpression */: - return ts.forEach(node.properties, isContextSensitive); - case 164 /* ArrayLiteralExpression */: - return ts.forEach(node.elements, isContextSensitive); - case 182 /* ConditionalExpression */: - return isContextSensitive(node.whenTrue) || - isContextSensitive(node.whenFalse); - case 181 /* BinaryExpression */: - return node.operatorToken.kind === 52 /* BarBarToken */ && - (isContextSensitive(node.left) || isContextSensitive(node.right)); - case 245 /* PropertyAssignment */: - return isContextSensitive(node.initializer); - case 143 /* MethodDeclaration */: - case 142 /* MethodSignature */: - return isContextSensitiveFunctionLikeDeclaration(node); - case 172 /* ParenthesizedExpression */: - return isContextSensitive(node.expression); - } - return false; - } - function isContextSensitiveFunctionLikeDeclaration(node) { - return !node.typeParameters && node.parameters.length && !ts.forEach(node.parameters, function (p) { return p.type; }); - } - function getTypeWithoutSignatures(type) { - if (type.flags & 80896 /* ObjectType */) { - var resolved = resolveStructuredTypeMembers(type); - if (resolved.constructSignatures.length) { - var result = createObjectType(65536 /* Anonymous */, type.symbol); - result.members = resolved.members; - result.properties = resolved.properties; - result.callSignatures = emptyArray; - result.constructSignatures = emptyArray; - type = result; - } - } - return type; - } - // TYPE CHECKING - function isTypeIdenticalTo(source, target) { - return checkTypeRelatedTo(source, target, identityRelation, /*errorNode*/ undefined); - } - function compareTypes(source, target) { - return checkTypeRelatedTo(source, target, identityRelation, /*errorNode*/ undefined) ? -1 /* True */ : 0 /* False */; - } - function isTypeSubtypeOf(source, target) { - return checkTypeSubtypeOf(source, target, /*errorNode*/ undefined); - } - function isTypeAssignableTo(source, target) { - return checkTypeAssignableTo(source, target, /*errorNode*/ undefined); - } - function checkTypeSubtypeOf(source, target, errorNode, headMessage, containingMessageChain) { - return checkTypeRelatedTo(source, target, subtypeRelation, errorNode, headMessage, containingMessageChain); - } - function checkTypeAssignableTo(source, target, errorNode, headMessage, containingMessageChain) { - return checkTypeRelatedTo(source, target, assignableRelation, errorNode, headMessage, containingMessageChain); - } - function isSignatureAssignableTo(source, target) { - var sourceType = getOrCreateTypeFromSignature(source); - var targetType = getOrCreateTypeFromSignature(target); - return checkTypeRelatedTo(sourceType, targetType, assignableRelation, /*errorNode*/ undefined); - } - /** - * Checks if 'source' is related to 'target' (e.g.: is a assignable to). - * @param source The left-hand-side of the relation. - * @param target The right-hand-side of the relation. - * @param relation The relation considered. One of 'identityRelation', 'assignableRelation', or 'subTypeRelation'. - * Used as both to determine which checks are performed and as a cache of previously computed results. - * @param errorNode The suggested node upon which all errors will be reported, if defined. This may or may not be the actual node used. - * @param headMessage If the error chain should be prepended by a head message, then headMessage will be used. - * @param containingMessageChain A chain of errors to prepend any new errors found. - */ - function checkTypeRelatedTo(source, target, relation, errorNode, headMessage, containingMessageChain) { - var errorInfo; - var sourceStack; - var targetStack; - var maybeStack; - var expandingFlags; - var depth = 0; - var overflow = false; - var elaborateErrors = false; - ts.Debug.assert(relation !== identityRelation || !errorNode, "no error reporting in identity checking"); - var result = isRelatedTo(source, target, errorNode !== undefined, headMessage); - if (overflow) { - error(errorNode, ts.Diagnostics.Excessive_stack_depth_comparing_types_0_and_1, typeToString(source), typeToString(target)); - } - else if (errorInfo) { - // If we already computed this relation, but in a context where we didn't want to report errors (e.g. overload resolution), - // then we'll only have a top-level error (e.g. 'Class X does not implement interface Y') without any details. If this happened, - // request a recompuation to get a complete error message. This will be skipped if we've already done this computation in a context - // where errors were being reported. - if (errorInfo.next === undefined) { - errorInfo = undefined; - elaborateErrors = true; - isRelatedTo(source, target, errorNode !== undefined, headMessage); - } - if (containingMessageChain) { - errorInfo = ts.concatenateDiagnosticMessageChains(containingMessageChain, errorInfo); - } - diagnostics.add(ts.createDiagnosticForNodeFromMessageChain(errorNode, errorInfo)); - } - return result !== 0 /* False */; - function reportError(message, arg0, arg1, arg2) { - errorInfo = ts.chainDiagnosticMessages(errorInfo, message, arg0, arg1, arg2); - } - function reportRelationError(message, source, target) { - var sourceType = typeToString(source); - var targetType = typeToString(target); - if (sourceType === targetType) { - sourceType = typeToString(source, /*enclosingDeclaration*/ undefined, 128 /* UseFullyQualifiedType */); - targetType = typeToString(target, /*enclosingDeclaration*/ undefined, 128 /* UseFullyQualifiedType */); - } - reportError(message || ts.Diagnostics.Type_0_is_not_assignable_to_type_1, sourceType, targetType); - } - // Compare two types and return - // Ternary.True if they are related with no assumptions, - // Ternary.Maybe if they are related with assumptions of other relationships, or - // Ternary.False if they are not related. - function isRelatedTo(source, target, reportErrors, headMessage) { - var result; - // both types are the same - covers 'they are the same primitive type or both are Any' or the same type parameter cases - if (source === target) - return -1 /* True */; - if (relation === identityRelation) { - return isIdenticalTo(source, target); - } - if (isTypeAny(target)) - return -1 /* True */; - if (source === undefinedType) - return -1 /* True */; - if (source === nullType && target !== undefinedType) - return -1 /* True */; - if (source.flags & 128 /* Enum */ && target === numberType) - return -1 /* True */; - if (source.flags & 256 /* StringLiteral */ && target === stringType) - return -1 /* True */; - if (relation === assignableRelation) { - if (isTypeAny(source)) - return -1 /* True */; - if (source === numberType && target.flags & 128 /* Enum */) - return -1 /* True */; - } - if (source.flags & 1048576 /* FreshObjectLiteral */) { - if (hasExcessProperties(source, target, reportErrors)) { - if (reportErrors) { - reportRelationError(headMessage, source, target); - } - return 0 /* False */; - } - // Above we check for excess properties with respect to the entire target type. When union - // and intersection types are further deconstructed on the target side, we don't want to - // make the check again (as it might fail for a partial target type). Therefore we obtain - // the regular source type and proceed with that. - if (target.flags & 49152 /* UnionOrIntersection */) { - source = getRegularTypeOfObjectLiteral(source); - } - } - var saveErrorInfo = errorInfo; - // Note that the "each" checks must precede the "some" checks to produce the correct results - if (source.flags & 16384 /* Union */) { - if (result = eachTypeRelatedToType(source, target, reportErrors)) { - return result; - } - } - else if (target.flags & 32768 /* Intersection */) { - if (result = typeRelatedToEachType(source, target, reportErrors)) { - return result; - } - } - else { - // It is necessary to try "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 & 32768 /* Intersection */) { - // If target is a union type the following check will report errors so we suppress them here - if (result = someTypeRelatedToType(source, target, reportErrors && !(target.flags & 16384 /* Union */))) { - return result; - } - } - if (target.flags & 16384 /* Union */) { - if (result = typeRelatedToSomeType(source, target, reportErrors)) { - return result; - } - } - } - if (source.flags & 512 /* TypeParameter */) { - var constraint = getConstraintOfTypeParameter(source); - if (!constraint || constraint.flags & 1 /* Any */) { - constraint = emptyObjectType; - } - // Report constraint errors only if the constraint is not the empty object type - var reportConstraintErrors = reportErrors && constraint !== emptyObjectType; - if (result = isRelatedTo(constraint, target, reportConstraintErrors)) { - errorInfo = saveErrorInfo; - return result; - } - } - else { - if (source.flags & 4096 /* Reference */ && target.flags & 4096 /* Reference */ && source.target === target.target) { - // We have type references to same target type, see if relationship holds for all type arguments - if (result = typeArgumentsRelatedTo(source, target, reportErrors)) { - return result; - } - } - // Even if relationship doesn't hold for unions, intersections, or generic type references, - // it may hold in a structural comparison. - var apparentType = getApparentType(source); - // 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 (apparentType.flags & (80896 /* ObjectType */ | 32768 /* Intersection */) && target.flags & 80896 /* ObjectType */) { - // Report structural errors only if we haven't reported any errors yet - var reportStructuralErrors = reportErrors && errorInfo === saveErrorInfo; - if (result = objectTypeRelatedTo(apparentType, source, target, reportStructuralErrors)) { - errorInfo = saveErrorInfo; - return result; - } - } - } - if (reportErrors) { - reportRelationError(headMessage, source, target); - } - return 0 /* False */; - } - function isIdenticalTo(source, target) { - var result; - if (source.flags & 80896 /* ObjectType */ && target.flags & 80896 /* ObjectType */) { - if (source.flags & 4096 /* Reference */ && target.flags & 4096 /* Reference */ && source.target === target.target) { - // We have type references to same target type, see if all type arguments are identical - if (result = typeArgumentsRelatedTo(source, target, /*reportErrors*/ false)) { - return result; - } - } - return objectTypeRelatedTo(source, source, target, /*reportErrors*/ false); - } - if (source.flags & 512 /* TypeParameter */ && target.flags & 512 /* TypeParameter */) { - return typeParameterIdenticalTo(source, target); - } - if (source.flags & 16384 /* Union */ && target.flags & 16384 /* Union */ || - source.flags & 32768 /* Intersection */ && target.flags & 32768 /* Intersection */) { - if (result = eachTypeRelatedToSomeType(source, target)) { - if (result &= eachTypeRelatedToSomeType(target, source)) { - return result; - } - } - } - return 0 /* False */; - } - // Check if a property with the given name is known anywhere in the given type. In an object type, a property - // is considered known if the object type is empty and the check is for assignability, if the object type has - // 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, name) { - if (type.flags & 80896 /* ObjectType */) { - var resolved = resolveStructuredTypeMembers(type); - if (relation === assignableRelation && (type === globalObjectType || resolved.properties.length === 0) || - resolved.stringIndexType || resolved.numberIndexType || getPropertyOfType(type, name)) { - return true; - } - } - else if (type.flags & 49152 /* UnionOrIntersection */) { - for (var _i = 0, _a = type.types; _i < _a.length; _i++) { - var t = _a[_i]; - if (isKnownProperty(t, name)) { - return true; - } - } - } - return false; - } - function hasExcessProperties(source, target, reportErrors) { - if (someConstituentTypeHasKind(target, 80896 /* ObjectType */)) { - for (var _i = 0, _a = getPropertiesOfObjectType(source); _i < _a.length; _i++) { - var prop = _a[_i]; - if (!isKnownProperty(target, prop.name)) { - if (reportErrors) { - // We know *exactly* where things went wrong when comparing the types. - // Use this property as the error node as this will be more helpful in - // reasoning about what went wrong. - errorNode = prop.valueDeclaration; - reportError(ts.Diagnostics.Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1, symbolToString(prop), typeToString(target)); - } - return true; - } - } - } - return false; - } - function eachTypeRelatedToSomeType(source, target) { - var result = -1 /* True */; - var sourceTypes = source.types; - for (var _i = 0; _i < sourceTypes.length; _i++) { - var sourceType = sourceTypes[_i]; - var related = typeRelatedToSomeType(sourceType, target, false); - if (!related) { - return 0 /* False */; - } - result &= related; - } - return result; - } - function typeRelatedToSomeType(source, target, reportErrors) { - var targetTypes = target.types; - for (var i = 0, len = targetTypes.length; i < len; i++) { - var related = isRelatedTo(source, targetTypes[i], reportErrors && i === len - 1); - if (related) { - return related; - } - } - return 0 /* False */; - } - function typeRelatedToEachType(source, target, reportErrors) { - var result = -1 /* True */; - var targetTypes = target.types; - for (var _i = 0; _i < targetTypes.length; _i++) { - var targetType = targetTypes[_i]; - var related = isRelatedTo(source, targetType, reportErrors); - if (!related) { - return 0 /* False */; - } - result &= related; - } - return result; - } - function someTypeRelatedToType(source, target, reportErrors) { - var sourceTypes = source.types; - for (var i = 0, len = sourceTypes.length; i < len; i++) { - var related = isRelatedTo(sourceTypes[i], target, reportErrors && i === len - 1); - if (related) { - return related; - } - } - return 0 /* False */; - } - function eachTypeRelatedToType(source, target, reportErrors) { - var result = -1 /* True */; - var sourceTypes = source.types; - for (var _i = 0; _i < sourceTypes.length; _i++) { - var sourceType = sourceTypes[_i]; - var related = isRelatedTo(sourceType, target, reportErrors); - if (!related) { - return 0 /* False */; - } - result &= related; - } - return result; - } - function typeArgumentsRelatedTo(source, target, reportErrors) { - var sources = source.typeArguments || emptyArray; - var targets = target.typeArguments || emptyArray; - if (sources.length !== targets.length && relation === identityRelation) { - return 0 /* False */; - } - var result = -1 /* True */; - for (var i = 0; i < targets.length; i++) { - var related = isRelatedTo(sources[i], targets[i], reportErrors); - if (!related) { - return 0 /* False */; - } - result &= related; - } - return result; - } - function typeParameterIdenticalTo(source, target) { - if (source.symbol.name !== target.symbol.name) { - return 0 /* False */; - } - // covers case when both type parameters does not have constraint (both equal to noConstraintType) - if (source.constraint === target.constraint) { - return -1 /* True */; - } - if (source.constraint === noConstraintType || target.constraint === noConstraintType) { - return 0 /* False */; - } - return isIdenticalTo(source.constraint, target.constraint); - } - // Determine if two object types are related by structure. First, check if the result is already available in the global cache. - // Second, check if we have already started a comparison of the given two types in which case we assume the result to be true. - // Third, check if both types are part of deeply nested chains of generic type instantiations and if so assume the types are - // equal and infinitely expanding. Fourth, if we have reached a depth of 100 nested comparisons, assume we have runaway recursion - // and issue an error. Otherwise, actually compare the structure of the two types. - function objectTypeRelatedTo(apparentSource, originalSource, target, reportErrors) { - if (overflow) { - return 0 /* False */; - } - var id = relation !== identityRelation || apparentSource.id < target.id ? apparentSource.id + "," + target.id : target.id + "," + apparentSource.id; - var related = relation[id]; - if (related !== undefined) { - // If we computed this relation already and it was failed and reported, or if we're not being asked to elaborate - // errors, we can use the cached value. Otherwise, recompute the relation - if (!elaborateErrors || (related === 3 /* FailedAndReported */)) { - return related === 1 /* Succeeded */ ? -1 /* True */ : 0 /* False */; - } - } - if (depth > 0) { - for (var i = 0; i < depth; i++) { - // If source and target are already being compared, consider them related with assumptions - if (maybeStack[i][id]) { - return 1 /* Maybe */; - } - } - if (depth === 100) { - overflow = true; - return 0 /* False */; - } - } - else { - sourceStack = []; - targetStack = []; - maybeStack = []; - expandingFlags = 0; - } - sourceStack[depth] = apparentSource; - targetStack[depth] = target; - maybeStack[depth] = {}; - maybeStack[depth][id] = 1 /* Succeeded */; - depth++; - var saveExpandingFlags = expandingFlags; - if (!(expandingFlags & 1) && isDeeplyNestedGeneric(apparentSource, sourceStack, depth)) - expandingFlags |= 1; - if (!(expandingFlags & 2) && isDeeplyNestedGeneric(target, targetStack, depth)) - expandingFlags |= 2; - var result; - if (expandingFlags === 3) { - result = 1 /* Maybe */; - } - else { - result = propertiesRelatedTo(apparentSource, target, reportErrors); - if (result) { - result &= signaturesRelatedTo(apparentSource, target, 0 /* Call */, reportErrors); - if (result) { - result &= signaturesRelatedTo(apparentSource, target, 1 /* Construct */, reportErrors); - if (result) { - result &= stringIndexTypesRelatedTo(apparentSource, originalSource, target, reportErrors); - if (result) { - result &= numberIndexTypesRelatedTo(apparentSource, originalSource, target, reportErrors); - } - } - } - } - } - expandingFlags = saveExpandingFlags; - depth--; - if (result) { - var maybeCache = maybeStack[depth]; - // If result is definitely true, copy assumptions to global cache, else copy to next level up - var destinationCache = (result === -1 /* True */ || depth === 0) ? relation : maybeStack[depth - 1]; - ts.copyMap(maybeCache, destinationCache); - } - else { - // A false result goes straight into global cache (when something is false under assumptions it - // will also be false without assumptions) - relation[id] = reportErrors ? 3 /* FailedAndReported */ : 2 /* Failed */; - } - return result; - } - function propertiesRelatedTo(source, target, reportErrors) { - if (relation === identityRelation) { - return propertiesIdenticalTo(source, target); - } - var result = -1 /* True */; - var properties = getPropertiesOfObjectType(target); - var requireOptionalProperties = relation === subtypeRelation && !(source.flags & 524288 /* ObjectLiteral */); - for (var _i = 0; _i < properties.length; _i++) { - var targetProp = properties[_i]; - var sourceProp = getPropertyOfType(source, targetProp.name); - if (sourceProp !== targetProp) { - if (!sourceProp) { - if (!(targetProp.flags & 536870912 /* Optional */) || requireOptionalProperties) { - if (reportErrors) { - reportError(ts.Diagnostics.Property_0_is_missing_in_type_1, symbolToString(targetProp), typeToString(source)); - } - return 0 /* False */; - } - } - else if (!(targetProp.flags & 134217728 /* Prototype */)) { - var sourcePropFlags = getDeclarationFlagsFromSymbol(sourceProp); - var targetPropFlags = getDeclarationFlagsFromSymbol(targetProp); - if (sourcePropFlags & 32 /* Private */ || targetPropFlags & 32 /* Private */) { - if (sourceProp.valueDeclaration !== targetProp.valueDeclaration) { - if (reportErrors) { - if (sourcePropFlags & 32 /* Private */ && targetPropFlags & 32 /* Private */) { - reportError(ts.Diagnostics.Types_have_separate_declarations_of_a_private_property_0, symbolToString(targetProp)); - } - else { - reportError(ts.Diagnostics.Property_0_is_private_in_type_1_but_not_in_type_2, symbolToString(targetProp), typeToString(sourcePropFlags & 32 /* Private */ ? source : target), typeToString(sourcePropFlags & 32 /* Private */ ? target : source)); - } - } - return 0 /* False */; - } - } - else if (targetPropFlags & 64 /* Protected */) { - var sourceDeclaredInClass = sourceProp.parent && sourceProp.parent.flags & 32 /* Class */; - var sourceClass = sourceDeclaredInClass ? getDeclaredTypeOfSymbol(sourceProp.parent) : undefined; - var targetClass = getDeclaredTypeOfSymbol(targetProp.parent); - if (!sourceClass || !hasBaseType(sourceClass, targetClass)) { - if (reportErrors) { - reportError(ts.Diagnostics.Property_0_is_protected_but_type_1_is_not_a_class_derived_from_2, symbolToString(targetProp), typeToString(sourceClass || source), typeToString(targetClass)); - } - return 0 /* False */; - } - } - else if (sourcePropFlags & 64 /* Protected */) { - if (reportErrors) { - reportError(ts.Diagnostics.Property_0_is_protected_in_type_1_but_public_in_type_2, symbolToString(targetProp), typeToString(source), typeToString(target)); - } - return 0 /* False */; - } - var related = isRelatedTo(getTypeOfSymbol(sourceProp), getTypeOfSymbol(targetProp), reportErrors); - if (!related) { - if (reportErrors) { - reportError(ts.Diagnostics.Types_of_property_0_are_incompatible, symbolToString(targetProp)); - } - return 0 /* False */; - } - result &= related; - if (sourceProp.flags & 536870912 /* Optional */ && !(targetProp.flags & 536870912 /* Optional */)) { - // TypeScript 1.0 spec (April 2014): 3.8.3 - // S is a subtype of a type T, and T is a supertype of S if ... - // S' and T are object types and, for each member M in T.. - // M is a property and S' contains a property N where - // if M is a required property, N is also a required property - // (M - property in T) - // (N - property in S) - if (reportErrors) { - reportError(ts.Diagnostics.Property_0_is_optional_in_type_1_but_required_in_type_2, symbolToString(targetProp), typeToString(source), typeToString(target)); - } - return 0 /* False */; - } - } - } - } - return result; - } - function propertiesIdenticalTo(source, target) { - if (!(source.flags & 80896 /* ObjectType */ && target.flags & 80896 /* ObjectType */)) { - return 0 /* False */; - } - var sourceProperties = getPropertiesOfObjectType(source); - var targetProperties = getPropertiesOfObjectType(target); - if (sourceProperties.length !== targetProperties.length) { - return 0 /* False */; - } - var result = -1 /* True */; - for (var _i = 0; _i < sourceProperties.length; _i++) { - var sourceProp = sourceProperties[_i]; - var targetProp = getPropertyOfObjectType(target, sourceProp.name); - if (!targetProp) { - return 0 /* False */; - } - var related = compareProperties(sourceProp, targetProp, isRelatedTo); - if (!related) { - return 0 /* False */; - } - result &= related; - } - return result; - } - function signaturesRelatedTo(source, target, kind, reportErrors) { - if (relation === identityRelation) { - return signaturesIdenticalTo(source, target, kind); - } - if (target === anyFunctionType || source === anyFunctionType) { - return -1 /* True */; - } - var sourceSignatures = getSignaturesOfType(source, kind); - var targetSignatures = getSignaturesOfType(target, kind); - var result = -1 /* True */; - var saveErrorInfo = errorInfo; - if (kind === 1 /* Construct */) { - // Only want to compare the construct signatures for abstractness guarantees. - // Because the "abstractness" of a class is the same across all construct signatures - // (internally we are checking the corresponding declaration), it is enough to perform - // the check and report an error once over all pairs of source and target construct signatures. - // - // sourceSig and targetSig are (possibly) undefined. - // - // Note that in an extends-clause, targetSignatures is stripped, so the check never proceeds. - var sourceSig = sourceSignatures[0]; - var targetSig = targetSignatures[0]; - result &= abstractSignatureRelatedTo(source, sourceSig, target, targetSig); - if (result !== -1 /* True */) { - return result; - } - } - outer: for (var _i = 0; _i < targetSignatures.length; _i++) { - var t = targetSignatures[_i]; - if (!t.hasStringLiterals || target.flags & 262144 /* FromSignature */) { - var localErrors = reportErrors; - var checkedAbstractAssignability = false; - for (var _a = 0; _a < sourceSignatures.length; _a++) { - var s = sourceSignatures[_a]; - if (!s.hasStringLiterals || source.flags & 262144 /* FromSignature */) { - var related = signatureRelatedTo(s, t, localErrors); - if (related) { - result &= related; - errorInfo = saveErrorInfo; - continue outer; - } - // Only report errors from the first failure - localErrors = false; - } - } - return 0 /* False */; - } - } - return result; - function abstractSignatureRelatedTo(source, sourceSig, target, targetSig) { - if (sourceSig && targetSig) { - var sourceDecl = source.symbol && getClassLikeDeclarationOfSymbol(source.symbol); - var targetDecl = target.symbol && getClassLikeDeclarationOfSymbol(target.symbol); - if (!sourceDecl) { - // If the source object isn't itself a class declaration, it can be freely assigned, regardless - // of whether the constructed object is abstract or not. - return -1 /* True */; - } - var sourceErasedSignature = getErasedSignature(sourceSig); - var targetErasedSignature = getErasedSignature(targetSig); - var sourceReturnType = sourceErasedSignature && getReturnTypeOfSignature(sourceErasedSignature); - var targetReturnType = targetErasedSignature && getReturnTypeOfSignature(targetErasedSignature); - var sourceReturnDecl = sourceReturnType && sourceReturnType.symbol && getClassLikeDeclarationOfSymbol(sourceReturnType.symbol); - var targetReturnDecl = targetReturnType && targetReturnType.symbol && getClassLikeDeclarationOfSymbol(targetReturnType.symbol); - var sourceIsAbstract = sourceReturnDecl && sourceReturnDecl.flags & 256 /* Abstract */; - var targetIsAbstract = targetReturnDecl && targetReturnDecl.flags & 256 /* Abstract */; - if (sourceIsAbstract && !(targetIsAbstract && targetDecl)) { - // if target isn't a class-declaration type, then it can be new'd, so we forbid the assignment. - if (reportErrors) { - reportError(ts.Diagnostics.Cannot_assign_an_abstract_constructor_type_to_a_non_abstract_constructor_type); - } - return 0 /* False */; - } - } - return -1 /* True */; - } - } - function signatureRelatedTo(source, target, reportErrors) { - if (source === target) { - return -1 /* True */; - } - if (!target.hasRestParameter && source.minArgumentCount > target.parameters.length) { - return 0 /* False */; - } - var sourceMax = source.parameters.length; - var targetMax = target.parameters.length; - var checkCount; - if (source.hasRestParameter && target.hasRestParameter) { - checkCount = sourceMax > targetMax ? sourceMax : targetMax; - sourceMax--; - targetMax--; - } - else if (source.hasRestParameter) { - sourceMax--; - checkCount = targetMax; - } - else if (target.hasRestParameter) { - targetMax--; - checkCount = sourceMax; - } - else { - checkCount = sourceMax < targetMax ? sourceMax : targetMax; - } - // Spec 1.0 Section 3.8.3 & 3.8.4: - // M and N (the signatures) are instantiated using type Any as the type argument for all type parameters declared by M and N - source = getErasedSignature(source); - target = getErasedSignature(target); - var result = -1 /* True */; - for (var i = 0; i < checkCount; i++) { - var s = i < sourceMax ? getTypeOfSymbol(source.parameters[i]) : getRestTypeOfSignature(source); - var t = i < targetMax ? getTypeOfSymbol(target.parameters[i]) : getRestTypeOfSignature(target); - var saveErrorInfo = errorInfo; - var related = isRelatedTo(s, t, reportErrors); - if (!related) { - related = isRelatedTo(t, s, false); - if (!related) { - if (reportErrors) { - reportError(ts.Diagnostics.Types_of_parameters_0_and_1_are_incompatible, source.parameters[i < sourceMax ? i : sourceMax].name, target.parameters[i < targetMax ? i : targetMax].name); - } - return 0 /* False */; - } - errorInfo = saveErrorInfo; - } - result &= related; - } - if (source.typePredicate && target.typePredicate) { - var hasDifferentParameterIndex = source.typePredicate.parameterIndex !== target.typePredicate.parameterIndex; - var hasDifferentTypes; - if (hasDifferentParameterIndex || - (hasDifferentTypes = !isTypeIdenticalTo(source.typePredicate.type, target.typePredicate.type))) { - if (reportErrors) { - var sourceParamText = source.typePredicate.parameterName; - var targetParamText = target.typePredicate.parameterName; - var sourceTypeText = typeToString(source.typePredicate.type); - var targetTypeText = typeToString(target.typePredicate.type); - if (hasDifferentParameterIndex) { - reportError(ts.Diagnostics.Parameter_0_is_not_in_the_same_position_as_parameter_1, sourceParamText, targetParamText); - } - else if (hasDifferentTypes) { - reportError(ts.Diagnostics.Type_0_is_not_assignable_to_type_1, sourceTypeText, targetTypeText); - } - reportError(ts.Diagnostics.Type_predicate_0_is_not_assignable_to_1, sourceParamText + " is " + sourceTypeText, targetParamText + " is " + targetTypeText); - } - return 0 /* False */; - } - } - else if (!source.typePredicate && target.typePredicate) { - if (reportErrors) { - reportError(ts.Diagnostics.Signature_0_must_have_a_type_predicate, signatureToString(source)); - } - return 0 /* False */; - } - var targetReturnType = getReturnTypeOfSignature(target); - if (targetReturnType === voidType) - return result; - var sourceReturnType = getReturnTypeOfSignature(source); - return result & isRelatedTo(sourceReturnType, targetReturnType, reportErrors); - } - function signaturesIdenticalTo(source, target, kind) { - var sourceSignatures = getSignaturesOfType(source, kind); - var targetSignatures = getSignaturesOfType(target, kind); - if (sourceSignatures.length !== targetSignatures.length) { - return 0 /* False */; - } - var result = -1 /* True */; - for (var i = 0, len = sourceSignatures.length; i < len; ++i) { - var related = compareSignatures(sourceSignatures[i], targetSignatures[i], /*partialMatch*/ false, /*ignoreReturnTypes*/ false, isRelatedTo); - if (!related) { - return 0 /* False */; - } - result &= related; - } - return result; - } - function stringIndexTypesRelatedTo(source, originalSource, target, reportErrors) { - if (relation === identityRelation) { - return indexTypesIdenticalTo(0 /* String */, source, target); - } - var targetType = getIndexTypeOfType(target, 0 /* String */); - if (targetType) { - if ((targetType.flags & 1 /* Any */) && !(originalSource.flags & 16777726 /* Primitive */)) { - // non-primitive assignment to any is always allowed, eg - // `var x: { [index: string]: any } = { property: 12 };` - return -1 /* True */; - } - var sourceType = getIndexTypeOfType(source, 0 /* String */); - if (!sourceType) { - if (reportErrors) { - reportError(ts.Diagnostics.Index_signature_is_missing_in_type_0, typeToString(source)); - } - return 0 /* False */; - } - var related = isRelatedTo(sourceType, targetType, reportErrors); - if (!related) { - if (reportErrors) { - reportError(ts.Diagnostics.Index_signatures_are_incompatible); - } - return 0 /* False */; - } - return related; - } - return -1 /* True */; - } - function numberIndexTypesRelatedTo(source, originalSource, target, reportErrors) { - if (relation === identityRelation) { - return indexTypesIdenticalTo(1 /* Number */, source, target); - } - var targetType = getIndexTypeOfType(target, 1 /* Number */); - if (targetType) { - if ((targetType.flags & 1 /* Any */) && !(originalSource.flags & 16777726 /* Primitive */)) { - // non-primitive assignment to any is always allowed, eg - // `var x: { [index: number]: any } = { property: 12 };` - return -1 /* True */; - } - var sourceStringType = getIndexTypeOfType(source, 0 /* String */); - var sourceNumberType = getIndexTypeOfType(source, 1 /* Number */); - if (!(sourceStringType || sourceNumberType)) { - if (reportErrors) { - reportError(ts.Diagnostics.Index_signature_is_missing_in_type_0, typeToString(source)); - } - return 0 /* False */; - } - var related; - if (sourceStringType && sourceNumberType) { - // If we know for sure we're testing both string and numeric index types then only report errors from the second one - related = isRelatedTo(sourceStringType, targetType, false) || isRelatedTo(sourceNumberType, targetType, reportErrors); - } - else { - related = isRelatedTo(sourceStringType || sourceNumberType, targetType, reportErrors); - } - if (!related) { - if (reportErrors) { - reportError(ts.Diagnostics.Index_signatures_are_incompatible); - } - return 0 /* False */; - } - return related; - } - return -1 /* True */; - } - function indexTypesIdenticalTo(indexKind, source, target) { - var targetType = getIndexTypeOfType(target, indexKind); - var sourceType = getIndexTypeOfType(source, indexKind); - if (!sourceType && !targetType) { - return -1 /* True */; - } - if (sourceType && targetType) { - return isRelatedTo(sourceType, targetType); - } - return 0 /* False */; - } - } - // Return true if the given type is part of a deeply nested chain of generic instantiations. We consider this to be the case - // when structural type comparisons have been started for 10 or more instantiations of the same generic type. It is possible, - // though highly unlikely, for this test to be true in a situation where a chain of instantiations is not infinitely expanding. - // Effectively, we will generate a false positive when two types are structurally equal to at least 10 levels, but unequal at - // some level beyond that. - function isDeeplyNestedGeneric(type, stack, depth) { - // We track type references (created by createTypeReference) and instantiated types (created by instantiateType) - if (type.flags & (4096 /* Reference */ | 131072 /* Instantiated */) && depth >= 5) { - var symbol = type.symbol; - var count = 0; - for (var i = 0; i < depth; i++) { - var t = stack[i]; - if (t.flags & (4096 /* Reference */ | 131072 /* Instantiated */) && t.symbol === symbol) { - count++; - if (count >= 5) - return true; - } - } - } - return false; - } - function isPropertyIdenticalTo(sourceProp, targetProp) { - return compareProperties(sourceProp, targetProp, compareTypes) !== 0 /* False */; - } - function compareProperties(sourceProp, targetProp, compareTypes) { - // Two members are considered identical when - // - they are public properties with identical names, optionality, and types, - // - they are private or protected properties originating in the same declaration and having identical types - if (sourceProp === targetProp) { - return -1 /* True */; - } - var sourcePropAccessibility = getDeclarationFlagsFromSymbol(sourceProp) & (32 /* Private */ | 64 /* Protected */); - var targetPropAccessibility = getDeclarationFlagsFromSymbol(targetProp) & (32 /* Private */ | 64 /* Protected */); - if (sourcePropAccessibility !== targetPropAccessibility) { - return 0 /* False */; - } - if (sourcePropAccessibility) { - if (getTargetSymbol(sourceProp) !== getTargetSymbol(targetProp)) { - return 0 /* False */; - } - } - else { - if ((sourceProp.flags & 536870912 /* Optional */) !== (targetProp.flags & 536870912 /* Optional */)) { - return 0 /* False */; - } - } - return compareTypes(getTypeOfSymbol(sourceProp), getTypeOfSymbol(targetProp)); - } - function compareSignatures(source, target, partialMatch, ignoreReturnTypes, compareTypes) { - if (source === target) { - return -1 /* True */; - } - if (source.parameters.length !== target.parameters.length || - source.minArgumentCount !== target.minArgumentCount || - source.hasRestParameter !== target.hasRestParameter) { - if (!partialMatch || - source.parameters.length < target.parameters.length && !source.hasRestParameter || - source.minArgumentCount > target.minArgumentCount) { - return 0 /* False */; - } - } - var result = -1 /* True */; - if (source.typeParameters && target.typeParameters) { - if (source.typeParameters.length !== target.typeParameters.length) { - return 0 /* False */; - } - for (var i = 0, len = source.typeParameters.length; i < len; ++i) { - var related = compareTypes(source.typeParameters[i], target.typeParameters[i]); - if (!related) { - return 0 /* False */; - } - result &= related; - } - } - else if (source.typeParameters || target.typeParameters) { - return 0 /* False */; - } - // Spec 1.0 Section 3.8.3 & 3.8.4: - // M and N (the signatures) are instantiated using type Any as the type argument for all type parameters declared by M and N - source = getErasedSignature(source); - target = getErasedSignature(target); - var targetLen = target.parameters.length; - for (var i = 0; i < targetLen; i++) { - var s = isRestParameterIndex(source, i) ? getRestTypeOfSignature(source) : getTypeOfSymbol(source.parameters[i]); - var t = isRestParameterIndex(target, i) ? getRestTypeOfSignature(target) : getTypeOfSymbol(target.parameters[i]); - var related = compareTypes(s, t); - if (!related) { - return 0 /* False */; - } - result &= related; - } - if (!ignoreReturnTypes) { - result &= compareTypes(getReturnTypeOfSignature(source), getReturnTypeOfSignature(target)); - } - return result; - } - function isRestParameterIndex(signature, parameterIndex) { - return signature.hasRestParameter && parameterIndex >= signature.parameters.length - 1; - } - function isSupertypeOfEach(candidate, types) { - for (var _i = 0; _i < types.length; _i++) { - var type = types[_i]; - if (candidate !== type && !isTypeSubtypeOf(type, candidate)) - return false; - } - return true; - } - function getCommonSupertype(types) { - return ts.forEach(types, function (t) { return isSupertypeOfEach(t, types) ? t : undefined; }); - } - function reportNoCommonSupertypeError(types, errorLocation, errorMessageChainHead) { - // The downfallType/bestSupertypeDownfallType is the first type that caused a particular candidate - // to not be the common supertype. So if it weren't for this one downfallType (and possibly others), - // the type in question could have been the common supertype. - var bestSupertype; - var bestSupertypeDownfallType; - var bestSupertypeScore = 0; - for (var i = 0; i < types.length; i++) { - var score = 0; - var downfallType = undefined; - for (var j = 0; j < types.length; j++) { - if (isTypeSubtypeOf(types[j], types[i])) { - score++; - } - else if (!downfallType) { - downfallType = types[j]; - } - } - ts.Debug.assert(!!downfallType, "If there is no common supertype, each type should have a downfallType"); - if (score > bestSupertypeScore) { - bestSupertype = types[i]; - bestSupertypeDownfallType = downfallType; - bestSupertypeScore = score; - } - // types.length - 1 is the maximum score, given that getCommonSupertype returned false - if (bestSupertypeScore === types.length - 1) { - break; - } - } - // In the following errors, the {1} slot is before the {0} slot because checkTypeSubtypeOf supplies the - // subtype as the first argument to the error - checkTypeSubtypeOf(bestSupertypeDownfallType, bestSupertype, errorLocation, ts.Diagnostics.Type_argument_candidate_1_is_not_a_valid_type_argument_because_it_is_not_a_supertype_of_candidate_0, errorMessageChainHead); - } - function isArrayType(type) { - return type.flags & 4096 /* Reference */ && type.target === globalArrayType; - } - function isArrayLikeType(type) { - // A type is array-like if it is not the undefined or null type and if it is assignable to any[] - return !(type.flags & (32 /* Undefined */ | 64 /* Null */)) && isTypeAssignableTo(type, anyArrayType); - } - function isTupleLikeType(type) { - return !!getPropertyOfType(type, "0"); - } - /** - * Check if a Type was written as a tuple type literal. - * Prefer using isTupleLikeType() unless the use of `elementTypes` is required. - */ - function isTupleType(type) { - return !!(type.flags & 8192 /* Tuple */); - } - function getRegularTypeOfObjectLiteral(type) { - if (type.flags & 1048576 /* FreshObjectLiteral */) { - var regularType = type.regularType; - if (!regularType) { - regularType = createType(type.flags & ~1048576 /* FreshObjectLiteral */); - regularType.symbol = type.symbol; - regularType.members = type.members; - regularType.properties = type.properties; - regularType.callSignatures = type.callSignatures; - regularType.constructSignatures = type.constructSignatures; - regularType.stringIndexType = type.stringIndexType; - regularType.numberIndexType = type.numberIndexType; - type.regularType = regularType; - } - return regularType; - } - return type; - } - function getWidenedTypeOfObjectLiteral(type) { - var properties = getPropertiesOfObjectType(type); - var members = {}; - ts.forEach(properties, function (p) { - var propType = getTypeOfSymbol(p); - var widenedType = getWidenedType(propType); - if (propType !== widenedType) { - var symbol = createSymbol(p.flags | 67108864 /* Transient */, p.name); - symbol.declarations = p.declarations; - symbol.parent = p.parent; - symbol.type = widenedType; - symbol.target = p; - if (p.valueDeclaration) - symbol.valueDeclaration = p.valueDeclaration; - p = symbol; - } - members[p.name] = p; - }); - var stringIndexType = getIndexTypeOfType(type, 0 /* String */); - var numberIndexType = getIndexTypeOfType(type, 1 /* Number */); - if (stringIndexType) - stringIndexType = getWidenedType(stringIndexType); - if (numberIndexType) - numberIndexType = getWidenedType(numberIndexType); - return createAnonymousType(type.symbol, members, emptyArray, emptyArray, stringIndexType, numberIndexType); - } - function getWidenedType(type) { - if (type.flags & 6291456 /* RequiresWidening */) { - if (type.flags & (32 /* Undefined */ | 64 /* Null */)) { - return anyType; - } - if (type.flags & 524288 /* ObjectLiteral */) { - return getWidenedTypeOfObjectLiteral(type); - } - if (type.flags & 16384 /* Union */) { - return getUnionType(ts.map(type.types, getWidenedType), /*noSubtypeReduction*/ true); - } - if (isArrayType(type)) { - return createArrayType(getWidenedType(type.typeArguments[0])); - } - if (isTupleType(type)) { - return createTupleType(ts.map(type.elementTypes, getWidenedType)); - } - } - return type; - } - /** - * Reports implicit any errors that occur as a result of widening 'null' and 'undefined' - * to 'any'. A call to reportWideningErrorsInType is normally accompanied by a call to - * getWidenedType. But in some cases getWidenedType is called without reporting errors - * (type argument inference is an example). - * - * The return value indicates whether an error was in fact reported. The particular circumstances - * are on a best effort basis. Currently, if the null or undefined that causes widening is inside - * an object literal property (arbitrarily deeply), this function reports an error. If no error is - * reported, reportImplicitAnyError is a suitable fallback to report a general error. - */ - function reportWideningErrorsInType(type) { - var errorReported = false; - if (type.flags & 16384 /* Union */) { - for (var _i = 0, _a = type.types; _i < _a.length; _i++) { - var t = _a[_i]; - if (reportWideningErrorsInType(t)) { - errorReported = true; - } - } - } - if (isArrayType(type)) { - return reportWideningErrorsInType(type.typeArguments[0]); - } - if (isTupleType(type)) { - for (var _b = 0, _c = type.elementTypes; _b < _c.length; _b++) { - var t = _c[_b]; - if (reportWideningErrorsInType(t)) { - errorReported = true; - } - } - } - if (type.flags & 524288 /* ObjectLiteral */) { - for (var _d = 0, _e = getPropertiesOfObjectType(type); _d < _e.length; _d++) { - var p = _e[_d]; - var t = getTypeOfSymbol(p); - if (t.flags & 2097152 /* ContainsUndefinedOrNull */) { - if (!reportWideningErrorsInType(t)) { - error(p.valueDeclaration, ts.Diagnostics.Object_literal_s_property_0_implicitly_has_an_1_type, p.name, typeToString(getWidenedType(t))); - } - errorReported = true; - } - } - } - return errorReported; - } - function reportImplicitAnyError(declaration, type) { - var typeAsString = typeToString(getWidenedType(type)); - var diagnostic; - switch (declaration.kind) { - case 141 /* PropertyDeclaration */: - case 140 /* PropertySignature */: - diagnostic = ts.Diagnostics.Member_0_implicitly_has_an_1_type; - break; - case 138 /* Parameter */: - diagnostic = declaration.dotDotDotToken ? - ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type : - ts.Diagnostics.Parameter_0_implicitly_has_an_1_type; - break; - case 213 /* FunctionDeclaration */: - case 143 /* MethodDeclaration */: - case 142 /* MethodSignature */: - case 145 /* GetAccessor */: - case 146 /* SetAccessor */: - case 173 /* FunctionExpression */: - case 174 /* ArrowFunction */: - if (!declaration.name) { - error(declaration, ts.Diagnostics.Function_expression_which_lacks_return_type_annotation_implicitly_has_an_0_return_type, typeAsString); - return; - } - diagnostic = ts.Diagnostics._0_which_lacks_return_type_annotation_implicitly_has_an_1_return_type; - break; - default: - diagnostic = ts.Diagnostics.Variable_0_implicitly_has_an_1_type; - } - error(declaration, diagnostic, ts.declarationNameToString(declaration.name), typeAsString); - } - function reportErrorsFromWidening(declaration, type) { - if (produceDiagnostics && compilerOptions.noImplicitAny && type.flags & 2097152 /* ContainsUndefinedOrNull */) { - // Report implicit any error within type if possible, otherwise report error on declaration - if (!reportWideningErrorsInType(type)) { - reportImplicitAnyError(declaration, type); - } - } - } - function forEachMatchingParameterType(source, target, callback) { - var sourceMax = source.parameters.length; - var targetMax = target.parameters.length; - var count; - if (source.hasRestParameter && target.hasRestParameter) { - count = sourceMax > targetMax ? sourceMax : targetMax; - sourceMax--; - targetMax--; - } - else if (source.hasRestParameter) { - sourceMax--; - count = targetMax; - } - else if (target.hasRestParameter) { - targetMax--; - count = sourceMax; - } - else { - count = sourceMax < targetMax ? sourceMax : targetMax; - } - for (var i = 0; i < count; i++) { - var s = i < sourceMax ? getTypeOfSymbol(source.parameters[i]) : getRestTypeOfSignature(source); - var t = i < targetMax ? getTypeOfSymbol(target.parameters[i]) : getRestTypeOfSignature(target); - callback(s, t); - } - } - function createInferenceContext(typeParameters, inferUnionTypes) { - var inferences = []; - for (var _i = 0; _i < typeParameters.length; _i++) { - var unused = typeParameters[_i]; - inferences.push({ - primary: undefined, secondary: undefined, isFixed: false - }); - } - return { - typeParameters: typeParameters, - inferUnionTypes: inferUnionTypes, - inferences: inferences, - inferredTypes: new Array(typeParameters.length) - }; - } - function inferTypes(context, source, target) { - var sourceStack; - var targetStack; - var depth = 0; - var inferiority = 0; - inferFromTypes(source, target); - function isInProcess(source, target) { - for (var i = 0; i < depth; i++) { - if (source === sourceStack[i] && target === targetStack[i]) { - return true; - } - } - return false; - } - function inferFromTypes(source, target) { - if (target.flags & 512 /* TypeParameter */) { - // If target is a type parameter, make an inference, unless the source type contains - // the anyFunctionType (the wildcard type that's used to avoid contextually typing functions). - // Because the anyFunctionType is internal, it should not be exposed to the user by adding - // it as an inference candidate. Hopefully, a better candidate will come along that does - // not contain anyFunctionType when we come back to this argument for its second round - // of inference. - if (source.flags & 8388608 /* ContainsAnyFunctionType */) { - return; - } - var typeParameters = context.typeParameters; - for (var i = 0; i < typeParameters.length; i++) { - if (target === typeParameters[i]) { - var inferences = context.inferences[i]; - if (!inferences.isFixed) { - // Any inferences that are made to a type parameter in a union type are inferior - // to inferences made to a flat (non-union) type. This is because if we infer to - // T | string[], we really don't know if we should be inferring to T or not (because - // the correct constituent on the target side could be string[]). Therefore, we put - // such inferior inferences into a secondary bucket, and only use them if the primary - // bucket is empty. - var candidates = inferiority ? - inferences.secondary || (inferences.secondary = []) : - inferences.primary || (inferences.primary = []); - if (!ts.contains(candidates, source)) { - candidates.push(source); - } - } - return; - } - } - } - else if (source.flags & 4096 /* Reference */ && target.flags & 4096 /* Reference */ && source.target === target.target) { - // If source and target are references to the same generic type, infer from type arguments - var sourceTypes = source.typeArguments || emptyArray; - var targetTypes = target.typeArguments || emptyArray; - var count = sourceTypes.length < targetTypes.length ? sourceTypes.length : targetTypes.length; - for (var i = 0; i < count; i++) { - inferFromTypes(sourceTypes[i], targetTypes[i]); - } - } - else if (source.flags & 8192 /* Tuple */ && target.flags & 8192 /* Tuple */ && source.elementTypes.length === target.elementTypes.length) { - // If source and target are tuples of the same size, infer from element types - var sourceTypes = source.elementTypes; - var targetTypes = target.elementTypes; - for (var i = 0; i < sourceTypes.length; i++) { - inferFromTypes(sourceTypes[i], targetTypes[i]); - } - } - else if (target.flags & 49152 /* UnionOrIntersection */) { - var targetTypes = target.types; - var typeParameterCount = 0; - var typeParameter; - // First infer to each type in union or intersection that isn't a type parameter - for (var _i = 0; _i < targetTypes.length; _i++) { - var t = targetTypes[_i]; - if (t.flags & 512 /* TypeParameter */ && ts.contains(context.typeParameters, t)) { - typeParameter = t; - typeParameterCount++; - } - else { - inferFromTypes(source, t); - } - } - // Next, if target is a union type containing a single naked type parameter, make a - // secondary inference to that type parameter. We don't do this for intersection types - // because in a target type like Foo & T we don't know how which parts of the source type - // should be matched by Foo and which should be inferred to T. - if (target.flags & 16384 /* Union */ && typeParameterCount === 1) { - inferiority++; - inferFromTypes(source, typeParameter); - inferiority--; - } - } - else if (source.flags & 49152 /* UnionOrIntersection */) { - // Source is a union or intersection type, infer from each consituent type - var sourceTypes = source.types; - for (var _a = 0; _a < sourceTypes.length; _a++) { - var sourceType = sourceTypes[_a]; - inferFromTypes(sourceType, target); - } - } - else { - source = getApparentType(source); - if (source.flags & 80896 /* ObjectType */ && (target.flags & (4096 /* Reference */ | 8192 /* Tuple */) || - (target.flags & 65536 /* Anonymous */) && target.symbol && target.symbol.flags & (8192 /* Method */ | 2048 /* TypeLiteral */ | 32 /* Class */))) { - // If source is an object type, and target is a type reference, a tuple type, the type of a method, or a type literal, infer from members - if (isInProcess(source, target)) { - return; - } - if (isDeeplyNestedGeneric(source, sourceStack, depth) && isDeeplyNestedGeneric(target, targetStack, depth)) { - return; - } - if (depth === 0) { - sourceStack = []; - targetStack = []; - } - sourceStack[depth] = source; - targetStack[depth] = target; - depth++; - inferFromProperties(source, target); - inferFromSignatures(source, target, 0 /* Call */); - inferFromSignatures(source, target, 1 /* Construct */); - inferFromIndexTypes(source, target, 0 /* String */, 0 /* String */); - inferFromIndexTypes(source, target, 1 /* Number */, 1 /* Number */); - inferFromIndexTypes(source, target, 0 /* String */, 1 /* Number */); - depth--; - } - } - } - function inferFromProperties(source, target) { - var properties = getPropertiesOfObjectType(target); - for (var _i = 0; _i < properties.length; _i++) { - var targetProp = properties[_i]; - var sourceProp = getPropertyOfObjectType(source, targetProp.name); - if (sourceProp) { - inferFromTypes(getTypeOfSymbol(sourceProp), getTypeOfSymbol(targetProp)); - } - } - } - function inferFromSignatures(source, target, kind) { - var sourceSignatures = getSignaturesOfType(source, kind); - var targetSignatures = getSignaturesOfType(target, kind); - var sourceLen = sourceSignatures.length; - var targetLen = targetSignatures.length; - var len = sourceLen < targetLen ? sourceLen : targetLen; - for (var i = 0; i < len; i++) { - inferFromSignature(getErasedSignature(sourceSignatures[sourceLen - len + i]), getErasedSignature(targetSignatures[targetLen - len + i])); - } - } - function inferFromSignature(source, target) { - forEachMatchingParameterType(source, target, inferFromTypes); - if (source.typePredicate && target.typePredicate) { - if (target.typePredicate.parameterIndex === source.typePredicate.parameterIndex) { - // Return types from type predicates are treated as booleans. In order to infer types - // from type predicates we would need to infer using the type within the type predicate - // (i.e. 'Foo' from 'x is Foo'). - inferFromTypes(source.typePredicate.type, target.typePredicate.type); - } - } - else { - inferFromTypes(getReturnTypeOfSignature(source), getReturnTypeOfSignature(target)); - } - } - function inferFromIndexTypes(source, target, sourceKind, targetKind) { - var targetIndexType = getIndexTypeOfType(target, targetKind); - if (targetIndexType) { - var sourceIndexType = getIndexTypeOfType(source, sourceKind); - if (sourceIndexType) { - inferFromTypes(sourceIndexType, targetIndexType); - } - } - } - } - function getInferenceCandidates(context, index) { - var inferences = context.inferences[index]; - return inferences.primary || inferences.secondary || emptyArray; - } - function getInferredType(context, index) { - var inferredType = context.inferredTypes[index]; - var inferenceSucceeded; - if (!inferredType) { - var inferences = getInferenceCandidates(context, index); - if (inferences.length) { - // Infer widened union or supertype, or the unknown type for no common supertype - var unionOrSuperType = context.inferUnionTypes ? getUnionType(inferences) : getCommonSupertype(inferences); - inferredType = unionOrSuperType ? getWidenedType(unionOrSuperType) : unknownType; - inferenceSucceeded = !!unionOrSuperType; - } - else { - // Infer the empty object type when no inferences were made. It is important to remember that - // in this case, inference still succeeds, meaning there is no error for not having inference - // candidates. An inference error only occurs when there are *conflicting* candidates, i.e. - // candidates with no common supertype. - inferredType = emptyObjectType; - inferenceSucceeded = true; - } - // Only do the constraint check if inference succeeded (to prevent cascading errors) - if (inferenceSucceeded) { - var constraint = getConstraintOfTypeParameter(context.typeParameters[index]); - inferredType = constraint && !isTypeAssignableTo(inferredType, constraint) ? constraint : inferredType; - } - else if (context.failedTypeParameterIndex === undefined || context.failedTypeParameterIndex > index) { - // If inference failed, it is necessary to record the index of the failed type parameter (the one we are on). - // It might be that inference has already failed on a later type parameter on a previous call to inferTypeArguments. - // So if this failure is on preceding type parameter, this type parameter is the new failure index. - context.failedTypeParameterIndex = index; - } - context.inferredTypes[index] = inferredType; - } - return inferredType; - } - function getInferredTypes(context) { - for (var i = 0; i < context.inferredTypes.length; i++) { - getInferredType(context, i); - } - return context.inferredTypes; - } - function hasAncestor(node, kind) { - return ts.getAncestor(node, kind) !== undefined; - } - // EXPRESSION TYPE CHECKING - function getResolvedSymbol(node) { - var links = getNodeLinks(node); - if (!links.resolvedSymbol) { - links.resolvedSymbol = (!ts.nodeIsMissing(node) && resolveName(node, node.text, 107455 /* Value */ | 1048576 /* ExportValue */, ts.Diagnostics.Cannot_find_name_0, node)) || unknownSymbol; - } - return links.resolvedSymbol; - } - function isInTypeQuery(node) { - // TypeScript 1.0 spec (April 2014): 3.6.3 - // A type query consists of the keyword typeof followed by an expression. - // The expression is restricted to a single identifier or a sequence of identifiers separated by periods - while (node) { - switch (node.kind) { - case 154 /* TypeQuery */: - return true; - case 69 /* Identifier */: - case 135 /* QualifiedName */: - node = node.parent; - continue; - default: - return false; - } - } - ts.Debug.fail("should not get here"); - } - // For a union type, remove all constituent types that are of the given type kind (when isOfTypeKind is true) - // or not of the given type kind (when isOfTypeKind is false) - function removeTypesFromUnionType(type, typeKind, isOfTypeKind, allowEmptyUnionResult) { - if (type.flags & 16384 /* Union */) { - var types = type.types; - if (ts.forEach(types, function (t) { return !!(t.flags & typeKind) === isOfTypeKind; })) { - // Above we checked if we have anything to remove, now use the opposite test to do the removal - var narrowedType = getUnionType(ts.filter(types, function (t) { return !(t.flags & typeKind) === isOfTypeKind; })); - if (allowEmptyUnionResult || narrowedType !== emptyObjectType) { - return narrowedType; - } - } - } - else if (allowEmptyUnionResult && !!(type.flags & typeKind) === isOfTypeKind) { - // Use getUnionType(emptyArray) instead of emptyObjectType in case the way empty union types - // are represented ever changes. - return getUnionType(emptyArray); - } - return type; - } - function hasInitializer(node) { - return !!(node.initializer || ts.isBindingPattern(node.parent) && hasInitializer(node.parent.parent)); - } - // Check if a given variable is assigned within a given syntax node - function isVariableAssignedWithin(symbol, node) { - var links = getNodeLinks(node); - if (links.assignmentChecks) { - var cachedResult = links.assignmentChecks[symbol.id]; - if (cachedResult !== undefined) { - return cachedResult; - } - } - else { - links.assignmentChecks = {}; - } - return links.assignmentChecks[symbol.id] = isAssignedIn(node); - function isAssignedInBinaryExpression(node) { - if (node.operatorToken.kind >= 56 /* FirstAssignment */ && node.operatorToken.kind <= 68 /* LastAssignment */) { - var n = node.left; - while (n.kind === 172 /* ParenthesizedExpression */) { - n = n.expression; - } - if (n.kind === 69 /* Identifier */ && getResolvedSymbol(n) === symbol) { - return true; - } - } - return ts.forEachChild(node, isAssignedIn); - } - function isAssignedInVariableDeclaration(node) { - if (!ts.isBindingPattern(node.name) && getSymbolOfNode(node) === symbol && hasInitializer(node)) { - return true; - } - return ts.forEachChild(node, isAssignedIn); - } - function isAssignedIn(node) { - switch (node.kind) { - case 181 /* BinaryExpression */: - return isAssignedInBinaryExpression(node); - case 211 /* VariableDeclaration */: - case 163 /* BindingElement */: - return isAssignedInVariableDeclaration(node); - case 161 /* ObjectBindingPattern */: - case 162 /* ArrayBindingPattern */: - case 164 /* ArrayLiteralExpression */: - case 165 /* ObjectLiteralExpression */: - case 166 /* PropertyAccessExpression */: - case 167 /* ElementAccessExpression */: - case 168 /* CallExpression */: - case 169 /* NewExpression */: - case 171 /* TypeAssertionExpression */: - case 189 /* AsExpression */: - case 172 /* ParenthesizedExpression */: - case 179 /* PrefixUnaryExpression */: - case 175 /* DeleteExpression */: - case 178 /* AwaitExpression */: - case 176 /* TypeOfExpression */: - case 177 /* VoidExpression */: - case 180 /* PostfixUnaryExpression */: - case 184 /* YieldExpression */: - case 182 /* ConditionalExpression */: - case 185 /* SpreadElementExpression */: - case 192 /* Block */: - case 193 /* VariableStatement */: - case 195 /* ExpressionStatement */: - case 196 /* IfStatement */: - case 197 /* DoStatement */: - case 198 /* WhileStatement */: - case 199 /* ForStatement */: - case 200 /* ForInStatement */: - case 201 /* ForOfStatement */: - case 204 /* ReturnStatement */: - case 205 /* WithStatement */: - case 206 /* SwitchStatement */: - case 241 /* CaseClause */: - case 242 /* DefaultClause */: - case 207 /* LabeledStatement */: - case 208 /* ThrowStatement */: - case 209 /* TryStatement */: - case 244 /* CatchClause */: - case 233 /* JsxElement */: - case 234 /* JsxSelfClosingElement */: - case 238 /* JsxAttribute */: - case 239 /* JsxSpreadAttribute */: - case 235 /* JsxOpeningElement */: - case 240 /* JsxExpression */: - return ts.forEachChild(node, isAssignedIn); - } - return false; - } - } - // Get the narrowed type of a given symbol at a given location - function getNarrowedTypeOfSymbol(symbol, node) { - var type = getTypeOfSymbol(symbol); - // Only narrow when symbol is variable of type any or an object, union, or type parameter type - if (node && symbol.flags & 3 /* Variable */) { - if (isTypeAny(type) || type.flags & (80896 /* ObjectType */ | 16384 /* Union */ | 512 /* TypeParameter */)) { - loop: while (node.parent) { - var child = node; - node = node.parent; - var narrowedType = type; - switch (node.kind) { - case 196 /* IfStatement */: - // In a branch of an if statement, narrow based on controlling expression - if (child !== node.expression) { - narrowedType = narrowType(type, node.expression, /*assumeTrue*/ child === node.thenStatement); - } - break; - case 182 /* ConditionalExpression */: - // In a branch of a conditional expression, narrow based on controlling condition - if (child !== node.condition) { - narrowedType = narrowType(type, node.condition, /*assumeTrue*/ child === node.whenTrue); - } - break; - case 181 /* BinaryExpression */: - // In the right operand of an && or ||, narrow based on left operand - if (child === node.right) { - if (node.operatorToken.kind === 51 /* AmpersandAmpersandToken */) { - narrowedType = narrowType(type, node.left, /*assumeTrue*/ true); - } - else if (node.operatorToken.kind === 52 /* BarBarToken */) { - narrowedType = narrowType(type, node.left, /*assumeTrue*/ false); - } - } - break; - case 248 /* SourceFile */: - case 218 /* ModuleDeclaration */: - case 213 /* FunctionDeclaration */: - case 143 /* MethodDeclaration */: - case 142 /* MethodSignature */: - case 145 /* GetAccessor */: - case 146 /* SetAccessor */: - case 144 /* Constructor */: - // Stop at the first containing function or module declaration - break loop; - } - // Use narrowed type if construct contains no assignments to variable - if (narrowedType !== type) { - if (isVariableAssignedWithin(symbol, node)) { - break; - } - type = narrowedType; - } - } - } - } - return type; - function narrowTypeByEquality(type, expr, assumeTrue) { - // Check that we have 'typeof ' on the left and string literal on the right - if (expr.left.kind !== 176 /* TypeOfExpression */ || expr.right.kind !== 9 /* StringLiteral */) { - return type; - } - var left = expr.left; - var right = expr.right; - if (left.expression.kind !== 69 /* Identifier */ || getResolvedSymbol(left.expression) !== symbol) { - return type; - } - var typeInfo = primitiveTypeInfo[right.text]; - if (expr.operatorToken.kind === 33 /* ExclamationEqualsEqualsToken */) { - assumeTrue = !assumeTrue; - } - if (assumeTrue) { - // Assumed result is true. If check was not for a primitive type, remove all primitive types - if (!typeInfo) { - return removeTypesFromUnionType(type, /*typeKind*/ 258 /* StringLike */ | 132 /* NumberLike */ | 8 /* Boolean */ | 16777216 /* ESSymbol */, - /*isOfTypeKind*/ true, /*allowEmptyUnionResult*/ false); - } - // Check was for a primitive type, return that primitive type if it is a subtype - if (isTypeSubtypeOf(typeInfo.type, type)) { - return typeInfo.type; - } - // Otherwise, remove all types that aren't of the primitive type kind. This can happen when the type is - // union of enum types and other types. - return removeTypesFromUnionType(type, /*typeKind*/ typeInfo.flags, /*isOfTypeKind*/ false, /*allowEmptyUnionResult*/ false); - } - else { - // Assumed result is false. If check was for a primitive type, remove that primitive type - if (typeInfo) { - return removeTypesFromUnionType(type, /*typeKind*/ typeInfo.flags, /*isOfTypeKind*/ true, /*allowEmptyUnionResult*/ false); - } - // Otherwise we don't have enough information to do anything. - return type; - } - } - function narrowTypeByAnd(type, expr, assumeTrue) { - if (assumeTrue) { - // The assumed result is true, therefore we narrow assuming each operand to be true. - return narrowType(narrowType(type, expr.left, /*assumeTrue*/ true), expr.right, /*assumeTrue*/ true); - } - else { - // The assumed result is false. This means either the first operand was false, or the first operand was true - // and the second operand was false. We narrow with those assumptions and union the two resulting types. - return getUnionType([ - narrowType(type, expr.left, /*assumeTrue*/ false), - narrowType(narrowType(type, expr.left, /*assumeTrue*/ true), expr.right, /*assumeTrue*/ false) - ]); - } - } - function narrowTypeByOr(type, expr, assumeTrue) { - if (assumeTrue) { - // The assumed result is true. This means either the first operand was true, or the first operand was false - // and the second operand was true. We narrow with those assumptions and union the two resulting types. - return getUnionType([ - narrowType(type, expr.left, /*assumeTrue*/ true), - narrowType(narrowType(type, expr.left, /*assumeTrue*/ false), expr.right, /*assumeTrue*/ true) - ]); - } - else { - // The assumed result is false, therefore we narrow assuming each operand to be false. - return narrowType(narrowType(type, expr.left, /*assumeTrue*/ false), expr.right, /*assumeTrue*/ false); - } - } - function narrowTypeByInstanceof(type, expr, assumeTrue) { - // Check that type is not any, assumed result is true, and we have variable symbol on the left - if (isTypeAny(type) || !assumeTrue || expr.left.kind !== 69 /* Identifier */ || getResolvedSymbol(expr.left) !== symbol) { - return type; - } - // Check that right operand is a function type with a prototype property - var rightType = checkExpression(expr.right); - if (!isTypeSubtypeOf(rightType, globalFunctionType)) { - return type; - } - var targetType; - var prototypeProperty = getPropertyOfType(rightType, "prototype"); - if (prototypeProperty) { - // Target type is type of the prototype property - var prototypePropertyType = getTypeOfSymbol(prototypeProperty); - if (!isTypeAny(prototypePropertyType)) { - targetType = prototypePropertyType; - } - } - if (!targetType) { - // Target type is type of construct signature - var constructSignatures; - if (rightType.flags & 2048 /* Interface */) { - constructSignatures = resolveDeclaredMembers(rightType).declaredConstructSignatures; - } - else if (rightType.flags & 65536 /* Anonymous */) { - constructSignatures = getSignaturesOfType(rightType, 1 /* Construct */); - } - if (constructSignatures && constructSignatures.length) { - targetType = getUnionType(ts.map(constructSignatures, function (signature) { return getReturnTypeOfSignature(getErasedSignature(signature)); })); - } - } - if (targetType) { - return getNarrowedType(type, targetType); - } - return type; - } - function getNarrowedType(originalType, narrowedTypeCandidate) { - // If the current type is a union type, remove all constituents that aren't assignable to target. If that produces - // 0 candidates, fall back to the assignability check - if (originalType.flags & 16384 /* Union */) { - var assignableConstituents = ts.filter(originalType.types, function (t) { return isTypeAssignableTo(t, narrowedTypeCandidate); }); - if (assignableConstituents.length) { - return getUnionType(assignableConstituents); - } - } - if (isTypeAssignableTo(narrowedTypeCandidate, originalType)) { - // Narrow to the target type if it's assignable to the current type - return narrowedTypeCandidate; - } - return originalType; - } - function narrowTypeByTypePredicate(type, expr, assumeTrue) { - if (type.flags & 1 /* Any */) { - return type; - } - var signature = getResolvedSignature(expr); - if (signature.typePredicate && - expr.arguments[signature.typePredicate.parameterIndex] && - getSymbolAtLocation(expr.arguments[signature.typePredicate.parameterIndex]) === symbol) { - if (!assumeTrue) { - if (type.flags & 16384 /* Union */) { - return getUnionType(ts.filter(type.types, function (t) { return !isTypeSubtypeOf(t, signature.typePredicate.type); })); - } - return type; - } - return getNarrowedType(type, signature.typePredicate.type); - } - return type; - } - // Narrow the given type based on the given expression having the assumed boolean value. The returned type - // will be a subtype or the same type as the argument. - function narrowType(type, expr, assumeTrue) { - switch (expr.kind) { - case 168 /* CallExpression */: - return narrowTypeByTypePredicate(type, expr, assumeTrue); - case 172 /* ParenthesizedExpression */: - return narrowType(type, expr.expression, assumeTrue); - case 181 /* BinaryExpression */: - var operator = expr.operatorToken.kind; - if (operator === 32 /* EqualsEqualsEqualsToken */ || operator === 33 /* ExclamationEqualsEqualsToken */) { - return narrowTypeByEquality(type, expr, assumeTrue); - } - else if (operator === 51 /* AmpersandAmpersandToken */) { - return narrowTypeByAnd(type, expr, assumeTrue); - } - else if (operator === 52 /* BarBarToken */) { - return narrowTypeByOr(type, expr, assumeTrue); - } - else if (operator === 91 /* InstanceOfKeyword */) { - return narrowTypeByInstanceof(type, expr, assumeTrue); - } - break; - case 179 /* PrefixUnaryExpression */: - if (expr.operator === 49 /* ExclamationToken */) { - return narrowType(type, expr.operand, !assumeTrue); - } - break; - } - return type; - } - } - function checkIdentifier(node) { - var symbol = getResolvedSymbol(node); - // As noted in ECMAScript 6 language spec, arrow functions never have an arguments objects. - // Although in down-level emit of arrow function, we emit it using function expression which means that - // arguments objects will be bound to the inner object; emitting arrow function natively in ES6, arguments objects - // will be bound to non-arrow function that contain this arrow function. This results in inconsistent behavior. - // To avoid that we will give an error to users if they use arguments objects in arrow function so that they - // can explicitly bound arguments objects - if (symbol === argumentsSymbol) { - var container = ts.getContainingFunction(node); - if (container.kind === 174 /* ArrowFunction */) { - if (languageVersion < 2 /* ES6 */) { - error(node, ts.Diagnostics.The_arguments_object_cannot_be_referenced_in_an_arrow_function_in_ES3_and_ES5_Consider_using_a_standard_function_expression); - } - } - if (node.parserContextFlags & 8 /* Await */) { - getNodeLinks(container).flags |= 4096 /* CaptureArguments */; - getNodeLinks(node).flags |= 2048 /* LexicalArguments */; - } - } - if (symbol.flags & 8388608 /* Alias */ && !isInTypeQuery(node) && !isConstEnumOrConstEnumOnlyModule(resolveAlias(symbol))) { - markAliasSymbolAsReferenced(symbol); - } - checkCollisionWithCapturedSuperVariable(node, node); - checkCollisionWithCapturedThisVariable(node, node); - checkBlockScopedBindingCapturedInLoop(node, symbol); - return getNarrowedTypeOfSymbol(getExportSymbolOfValueSymbolIfExported(symbol), node); - } - function isInsideFunction(node, threshold) { - var current = node; - while (current && current !== threshold) { - if (ts.isFunctionLike(current)) { - return true; - } - current = current.parent; - } - return false; - } - function checkBlockScopedBindingCapturedInLoop(node, symbol) { - if (languageVersion >= 2 /* ES6 */ || - (symbol.flags & 2 /* BlockScopedVariable */) === 0 || - symbol.valueDeclaration.parent.kind === 244 /* CatchClause */) { - return; - } - // - check if binding is used in some function - // (stop the walk when reaching container of binding declaration) - // - if first check succeeded - check if variable is declared inside the loop - // nesting structure: - // (variable declaration or binding element) -> variable declaration list -> container - var container = symbol.valueDeclaration; - while (container.kind !== 212 /* VariableDeclarationList */) { - container = container.parent; - } - // get the parent of variable declaration list - container = container.parent; - if (container.kind === 193 /* VariableStatement */) { - // if parent is variable statement - get its parent - container = container.parent; - } - var inFunction = isInsideFunction(node.parent, container); - var current = container; - while (current && !ts.nodeStartsNewLexicalEnvironment(current)) { - if (isIterationStatement(current, /*lookInLabeledStatements*/ false)) { - if (inFunction) { - grammarErrorOnFirstToken(current, ts.Diagnostics.Loop_contains_block_scoped_variable_0_referenced_by_a_function_in_the_loop_This_is_only_supported_in_ECMAScript_6_or_higher, ts.declarationNameToString(node)); - } - // mark value declaration so during emit they can have a special handling - getNodeLinks(symbol.valueDeclaration).flags |= 16384 /* BlockScopedBindingInLoop */; - break; - } - current = current.parent; - } - } - function captureLexicalThis(node, container) { - getNodeLinks(node).flags |= 2 /* LexicalThis */; - if (container.kind === 141 /* PropertyDeclaration */ || container.kind === 144 /* Constructor */) { - var classNode = container.parent; - getNodeLinks(classNode).flags |= 4 /* CaptureThis */; - } - else { - getNodeLinks(container).flags |= 4 /* CaptureThis */; - } - } - function checkThisExpression(node) { - // Stop at the first arrow function so that we can - // tell whether 'this' needs to be captured. - var container = ts.getThisContainer(node, /* includeArrowFunctions */ true); - var needToCaptureLexicalThis = false; - // Now skip arrow functions to get the "real" owner of 'this'. - if (container.kind === 174 /* ArrowFunction */) { - container = ts.getThisContainer(container, /* includeArrowFunctions */ false); - // When targeting es6, arrow function lexically bind "this" so we do not need to do the work of binding "this" in emitted code - needToCaptureLexicalThis = (languageVersion < 2 /* ES6 */); - } - switch (container.kind) { - case 218 /* ModuleDeclaration */: - error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_module_or_namespace_body); - // do not return here so in case if lexical this is captured - it will be reflected in flags on NodeLinks - break; - case 217 /* EnumDeclaration */: - error(node, ts.Diagnostics.this_cannot_be_referenced_in_current_location); - // do not return here so in case if lexical this is captured - it will be reflected in flags on NodeLinks - break; - case 144 /* Constructor */: - if (isInConstructorArgumentInitializer(node, container)) { - error(node, ts.Diagnostics.this_cannot_be_referenced_in_constructor_arguments); - } - break; - case 141 /* PropertyDeclaration */: - case 140 /* PropertySignature */: - if (container.flags & 128 /* Static */) { - error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_static_property_initializer); - } - break; - case 136 /* ComputedPropertyName */: - error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_computed_property_name); - break; - } - if (needToCaptureLexicalThis) { - captureLexicalThis(node, container); - } - if (ts.isClassLike(container.parent)) { - var symbol = getSymbolOfNode(container.parent); - return container.flags & 128 /* Static */ ? getTypeOfSymbol(symbol) : getDeclaredTypeOfSymbol(symbol).thisType; - } - return anyType; - } - function isInConstructorArgumentInitializer(node, constructorDecl) { - for (var n = node; n && n !== constructorDecl; n = n.parent) { - if (n.kind === 138 /* Parameter */) { - return true; - } - } - return false; - } - function checkSuperExpression(node) { - var isCallExpression = node.parent.kind === 168 /* CallExpression */ && node.parent.expression === node; - var classDeclaration = ts.getContainingClass(node); - var classType = classDeclaration && getDeclaredTypeOfSymbol(getSymbolOfNode(classDeclaration)); - var baseClassType = classType && getBaseTypes(classType)[0]; - var container = ts.getSuperContainer(node, /*includeFunctions*/ true); - var needToCaptureLexicalThis = false; - if (!isCallExpression) { - // adjust the container reference in case if super is used inside arrow functions with arbitrary deep nesting - while (container && container.kind === 174 /* ArrowFunction */) { - container = ts.getSuperContainer(container, /*includeFunctions*/ true); - needToCaptureLexicalThis = languageVersion < 2 /* ES6 */; - } - } - var canUseSuperExpression = isLegalUsageOfSuperExpression(container); - var nodeCheckFlag = 0; - // always set NodeCheckFlags for 'super' expression node - if (canUseSuperExpression) { - if ((container.flags & 128 /* Static */) || isCallExpression) { - nodeCheckFlag = 512 /* SuperStatic */; - } - else { - nodeCheckFlag = 256 /* SuperInstance */; - } - getNodeLinks(node).flags |= nodeCheckFlag; - if (needToCaptureLexicalThis) { - // call expressions are allowed only in constructors so they should always capture correct 'this' - // super property access expressions can also appear in arrow functions - - // in this case they should also use correct lexical this - captureLexicalThis(node.parent, container); - } - } - if (!baseClassType) { - if (!classDeclaration || !ts.getClassExtendsHeritageClauseElement(classDeclaration)) { - error(node, ts.Diagnostics.super_can_only_be_referenced_in_a_derived_class); - } - return unknownType; - } - if (!canUseSuperExpression) { - if (container && container.kind === 136 /* 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 { - error(node, ts.Diagnostics.super_property_access_is_permitted_only_in_a_constructor_member_function_or_member_accessor_of_a_derived_class); - } - return unknownType; - } - if (container.kind === 144 /* Constructor */ && isInConstructorArgumentInitializer(node, container)) { - // issue custom error message for super property access in constructor arguments (to be aligned with old compiler) - error(node, ts.Diagnostics.super_cannot_be_referenced_in_constructor_arguments); - return unknownType; - } - return nodeCheckFlag === 512 /* SuperStatic */ - ? getBaseConstructorTypeOfClass(classType) - : baseClassType; - function isLegalUsageOfSuperExpression(container) { - if (!container) { - return false; - } - if (isCallExpression) { - // TS 1.0 SPEC (April 2014): 4.8.1 - // Super calls are only permitted in constructors of derived classes - return container.kind === 144 /* Constructor */; - } - else { - // TS 1.0 SPEC (April 2014) - // 'super' property access is allowed - // - 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 - if (container && ts.isClassLike(container.parent)) { - if (container.flags & 128 /* Static */) { - return container.kind === 143 /* MethodDeclaration */ || - container.kind === 142 /* MethodSignature */ || - container.kind === 145 /* GetAccessor */ || - container.kind === 146 /* SetAccessor */; - } - else { - return container.kind === 143 /* MethodDeclaration */ || - container.kind === 142 /* MethodSignature */ || - container.kind === 145 /* GetAccessor */ || - container.kind === 146 /* SetAccessor */ || - container.kind === 141 /* PropertyDeclaration */ || - container.kind === 140 /* PropertySignature */ || - container.kind === 144 /* Constructor */; - } - } - } - return false; - } - } - // Return contextual type of parameter or undefined if no contextual type is available - function getContextuallyTypedParameterType(parameter) { - var func = parameter.parent; - if (isFunctionExpressionOrArrowFunction(func) || ts.isObjectLiteralMethod(func)) { - if (isContextSensitive(func)) { - var contextualSignature = getContextualSignature(func); - if (contextualSignature) { - var funcHasRestParameters = ts.hasRestParameter(func); - var len = func.parameters.length - (funcHasRestParameters ? 1 : 0); - var indexOfParameter = ts.indexOf(func.parameters, parameter); - if (indexOfParameter < len) { - return getTypeAtPosition(contextualSignature, indexOfParameter); - } - // If last parameter is contextually rest parameter get its type - if (funcHasRestParameters && - indexOfParameter === (func.parameters.length - 1) && - isRestParameterIndex(contextualSignature, func.parameters.length - 1)) { - return getTypeOfSymbol(ts.lastOrUndefined(contextualSignature.parameters)); - } - } - } - } - return undefined; - } - // In a variable, parameter or property declaration with a type annotation, the contextual type of an initializer - // expression is the type of the variable, parameter or property. Otherwise, in a parameter declaration of a - // contextually typed function expression, the contextual type of an initializer expression is the contextual type - // of the parameter. Otherwise, in a variable or parameter declaration with a binding pattern name, the contextual - // type of an initializer expression is the type implied by the binding pattern. - function getContextualTypeForInitializerExpression(node) { - var declaration = node.parent; - if (node === declaration.initializer) { - if (declaration.type) { - return getTypeFromTypeNode(declaration.type); - } - if (declaration.kind === 138 /* Parameter */) { - var type = getContextuallyTypedParameterType(declaration); - if (type) { - return type; - } - } - if (ts.isBindingPattern(declaration.name)) { - return getTypeFromBindingPattern(declaration.name, /*includePatternInType*/ true); - } - } - return undefined; - } - function getContextualTypeForReturnExpression(node) { - var func = ts.getContainingFunction(node); - if (func && !func.asteriskToken) { - return getContextualReturnType(func); - } - return undefined; - } - function getContextualTypeForYieldOperand(node) { - var func = ts.getContainingFunction(node); - if (func) { - var contextualReturnType = getContextualReturnType(func); - if (contextualReturnType) { - return node.asteriskToken - ? contextualReturnType - : getElementTypeOfIterableIterator(contextualReturnType); - } - } - return undefined; - } - function isInParameterInitializerBeforeContainingFunction(node) { - while (node.parent && !ts.isFunctionLike(node.parent)) { - if (node.parent.kind === 138 /* Parameter */ && node.parent.initializer === node) { - return true; - } - node = node.parent; - } - return false; - } - function getContextualReturnType(functionDecl) { - // 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 === 144 /* Constructor */ || - functionDecl.kind === 145 /* GetAccessor */ && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(functionDecl.symbol, 146 /* SetAccessor */))) { - return getReturnTypeOfSignature(getSignatureFromDeclaration(functionDecl)); - } - // Otherwise, if the containing function is contextually typed by a function type with exactly one call signature - // and that call signature is non-generic, return statements are contextually typed by the return type of the signature - var signature = getContextualSignatureForFunctionLikeDeclaration(functionDecl); - if (signature) { - return getReturnTypeOfSignature(signature); - } - return undefined; - } - // In a typed function call, an argument or substitution expression is contextually typed by the type of the corresponding parameter. - function getContextualTypeForArgument(callTarget, arg) { - var args = getEffectiveCallArguments(callTarget); - var argIndex = ts.indexOf(args, arg); - if (argIndex >= 0) { - var signature = getResolvedSignature(callTarget); - return getTypeAtPosition(signature, argIndex); - } - return undefined; - } - function getContextualTypeForSubstitutionExpression(template, substitutionExpression) { - if (template.parent.kind === 170 /* TaggedTemplateExpression */) { - return getContextualTypeForArgument(template.parent, substitutionExpression); - } - return undefined; - } - function getContextualTypeForBinaryOperand(node) { - var binaryExpression = node.parent; - var operator = binaryExpression.operatorToken.kind; - if (operator >= 56 /* FirstAssignment */ && operator <= 68 /* LastAssignment */) { - // In an assignment expression, the right operand is contextually typed by the type of the left operand. - if (node === binaryExpression.right) { - return checkExpression(binaryExpression.left); - } - } - else if (operator === 52 /* BarBarToken */) { - // When an || expression has a contextual type, the operands are contextually typed by that type. When an || - // expression has no contextual type, the right operand is contextually typed by the type of the left operand. - var type = getContextualType(binaryExpression); - if (!type && node === binaryExpression.right) { - type = checkExpression(binaryExpression.left); - } - return type; - } - return undefined; - } - // Apply a mapping function to a contextual type and return the resulting type. If the contextual type - // is a union type, the mapping function is applied to each constituent type and a union of the resulting - // types is returned. - function applyToContextualType(type, mapper) { - if (!(type.flags & 16384 /* Union */)) { - return mapper(type); - } - var types = type.types; - var mappedType; - var mappedTypes; - for (var _i = 0; _i < types.length; _i++) { - var current = types[_i]; - var t = mapper(current); - if (t) { - if (!mappedType) { - mappedType = t; - } - else if (!mappedTypes) { - mappedTypes = [mappedType, t]; - } - else { - mappedTypes.push(t); - } - } - } - return mappedTypes ? getUnionType(mappedTypes) : mappedType; - } - function getTypeOfPropertyOfContextualType(type, name) { - return applyToContextualType(type, function (t) { - var prop = t.flags & 130048 /* StructuredType */ ? getPropertyOfType(t, name) : undefined; - return prop ? getTypeOfSymbol(prop) : undefined; - }); - } - function getIndexTypeOfContextualType(type, kind) { - return applyToContextualType(type, function (t) { return getIndexTypeOfStructuredType(t, kind); }); - } - // Return true if the given contextual type is a tuple-like type - function contextualTypeIsTupleLikeType(type) { - return !!(type.flags & 16384 /* Union */ ? ts.forEach(type.types, isTupleLikeType) : isTupleLikeType(type)); - } - // Return true if the given contextual type provides an index signature of the given kind - function contextualTypeHasIndexSignature(type, kind) { - return !!(type.flags & 16384 /* Union */ ? ts.forEach(type.types, function (t) { return getIndexTypeOfStructuredType(t, kind); }) : getIndexTypeOfStructuredType(type, kind)); - } - // In an object literal contextually typed by a type T, the contextual type of a property assignment is the type of - // the matching property in T, if one exists. Otherwise, it is the type of the numeric index signature in T, if one - // exists. Otherwise, it is the type of the string index signature in T, if one exists. - function getContextualTypeForObjectLiteralMethod(node) { - ts.Debug.assert(ts.isObjectLiteralMethod(node)); - if (isInsideWithStatementBody(node)) { - // We cannot answer semantic questions within a with block, do not proceed any further - return undefined; - } - return getContextualTypeForObjectLiteralElement(node); - } - function getContextualTypeForObjectLiteralElement(element) { - var objectLiteral = element.parent; - var type = getContextualType(objectLiteral); - if (type) { - if (!ts.hasDynamicName(element)) { - // For a (non-symbol) computed property, there is no reason to look up the name - // in the type. It will just be "__computed", which does not appear in any - // SymbolTable. - var symbolName = getSymbolOfNode(element).name; - var propertyType = getTypeOfPropertyOfContextualType(type, symbolName); - if (propertyType) { - return propertyType; - } - } - return isNumericName(element.name) && getIndexTypeOfContextualType(type, 1 /* Number */) || - getIndexTypeOfContextualType(type, 0 /* String */); - } - return undefined; - } - // In an array literal contextually typed by a type T, the contextual type of an element expression at index N is - // the type of the property with the numeric name N in T, if one exists. Otherwise, if T has a numeric index signature, - // it is the type of the numeric index signature in T. Otherwise, in ES6 and higher, the contextual type is the iterated - // type of T. - function getContextualTypeForElementExpression(node) { - var arrayLiteral = node.parent; - var type = getContextualType(arrayLiteral); - if (type) { - var index = ts.indexOf(arrayLiteral.elements, node); - return getTypeOfPropertyOfContextualType(type, "" + index) - || getIndexTypeOfContextualType(type, 1 /* Number */) - || (languageVersion >= 2 /* ES6 */ ? getElementTypeOfIterable(type, /*errorNode*/ undefined) : undefined); - } - return undefined; - } - // In a contextually typed conditional expression, the true/false expressions are contextually typed by the same type. - function getContextualTypeForConditionalOperand(node) { - var conditional = node.parent; - return node === conditional.whenTrue || node === conditional.whenFalse ? getContextualType(conditional) : undefined; - } - function getContextualTypeForJsxExpression(expr) { - // Contextual type only applies to JSX expressions that are in attribute assignments (not in 'Children' positions) - if (expr.parent.kind === 238 /* JsxAttribute */) { - var attrib = expr.parent; - var attrsType = getJsxElementAttributesType(attrib.parent); - if (!attrsType || isTypeAny(attrsType)) { - return undefined; - } - else { - return getTypeOfPropertyOfType(attrsType, attrib.name.text); - } - } - if (expr.kind === 239 /* JsxSpreadAttribute */) { - return getJsxElementAttributesType(expr.parent); - } - return undefined; - } - // Return the contextual type for a given expression node. During overload resolution, a contextual type may temporarily - // be "pushed" onto a node using the contextualType property. - function getContextualType(node) { - var type = getContextualTypeWorker(node); - return type && getApparentType(type); - } - function getContextualTypeWorker(node) { - if (isInsideWithStatementBody(node)) { - // We cannot answer semantic questions within a with block, do not proceed any further - return undefined; - } - if (node.contextualType) { - return node.contextualType; - } - var parent = node.parent; - switch (parent.kind) { - case 211 /* VariableDeclaration */: - case 138 /* Parameter */: - case 141 /* PropertyDeclaration */: - case 140 /* PropertySignature */: - case 163 /* BindingElement */: - return getContextualTypeForInitializerExpression(node); - case 174 /* ArrowFunction */: - case 204 /* ReturnStatement */: - return getContextualTypeForReturnExpression(node); - case 184 /* YieldExpression */: - return getContextualTypeForYieldOperand(parent); - case 168 /* CallExpression */: - case 169 /* NewExpression */: - return getContextualTypeForArgument(parent, node); - case 171 /* TypeAssertionExpression */: - case 189 /* AsExpression */: - return getTypeFromTypeNode(parent.type); - case 181 /* BinaryExpression */: - return getContextualTypeForBinaryOperand(node); - case 245 /* PropertyAssignment */: - return getContextualTypeForObjectLiteralElement(parent); - case 164 /* ArrayLiteralExpression */: - return getContextualTypeForElementExpression(node); - case 182 /* ConditionalExpression */: - return getContextualTypeForConditionalOperand(node); - case 190 /* TemplateSpan */: - ts.Debug.assert(parent.parent.kind === 183 /* TemplateExpression */); - return getContextualTypeForSubstitutionExpression(parent.parent, node); - case 172 /* ParenthesizedExpression */: - return getContextualType(parent); - case 240 /* JsxExpression */: - case 239 /* JsxSpreadAttribute */: - return getContextualTypeForJsxExpression(parent); - } - return undefined; - } - // If the given type is an object or union type, if that type has a single signature, and if - // that signature is non-generic, return the signature. Otherwise return undefined. - function getNonGenericSignature(type) { - var signatures = getSignaturesOfStructuredType(type, 0 /* Call */); - if (signatures.length === 1) { - var signature = signatures[0]; - if (!signature.typeParameters) { - return signature; - } - } - } - function isFunctionExpressionOrArrowFunction(node) { - return node.kind === 173 /* FunctionExpression */ || node.kind === 174 /* ArrowFunction */; - } - function getContextualSignatureForFunctionLikeDeclaration(node) { - // Only function expressions, arrow functions, and object literal methods are contextually typed. - return isFunctionExpressionOrArrowFunction(node) || ts.isObjectLiteralMethod(node) - ? getContextualSignature(node) - : undefined; - } - // Return the contextual signature for a given expression node. A contextual type provides a - // contextual signature if it has a single call signature and if that call signature is non-generic. - // If the contextual type is a union type, get the signature from each type possible and if they are - // 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 !== 143 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); - var type = ts.isObjectLiteralMethod(node) - ? getContextualTypeForObjectLiteralMethod(node) - : getContextualType(node); - if (!type) { - return undefined; - } - if (!(type.flags & 16384 /* Union */)) { - return getNonGenericSignature(type); - } - var signatureList; - var types = type.types; - for (var _i = 0; _i < types.length; _i++) { - var current = types[_i]; - var signature = getNonGenericSignature(current); - if (signature) { - if (!signatureList) { - // This signature will contribute to contextual union signature - signatureList = [signature]; - } - else if (!compareSignatures(signatureList[0], signature, /*partialMatch*/ false, /*ignoreReturnTypes*/ true, compareTypes)) { - // Signatures aren't identical, do not use - return undefined; - } - else { - // Use this signature for contextual union signature - signatureList.push(signature); - } - } - } - // Result is union of signatures collected (return type is union of return types of this signature set) - var result; - if (signatureList) { - result = cloneSignature(signatureList[0]); - // Clear resolved return type we possibly got from cloneSignature - result.resolvedReturnType = undefined; - result.unionSignatures = signatureList; - } - return result; - } - /** - * Detect if the mapper implies an inference context. Specifically, there are 4 possible values - * for a mapper. Let's go through each one of them: - * - * 1. undefined - this means we are not doing inferential typing, but we may do contextual typing, - * which could cause us to assign a parameter a type - * 2. identityMapper - means we want to avoid assigning a parameter a type, whether or not we are in - * inferential typing (context is undefined for the identityMapper) - * 3. a mapper created by createInferenceMapper - we are doing inferential typing, we want to assign - * types to parameters and fix type parameters (context is defined) - * 4. an instantiation mapper created by createTypeMapper or createTypeEraser - this should never be - * passed as the contextual mapper when checking an expression (context is undefined for these) - * - * isInferentialContext is detecting if we are in case 3 - */ - function isInferentialContext(mapper) { - return mapper && mapper.context; - } - // A node is an assignment target if it is on the left hand side of an '=' token, if it is parented by a property - // 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) { - var parent = node.parent; - if (parent.kind === 181 /* BinaryExpression */ && parent.operatorToken.kind === 56 /* EqualsToken */ && parent.left === node) { - return true; - } - if (parent.kind === 245 /* PropertyAssignment */) { - return isAssignmentTarget(parent.parent); - } - if (parent.kind === 164 /* ArrayLiteralExpression */) { - return isAssignmentTarget(parent); - } - return false; - } - function checkSpreadElementExpression(node, contextualMapper) { - // It is usually not safe to call checkExpressionCached if we can be contextually typing. - // You can tell that we are contextually typing because of the contextualMapper parameter. - // While it is true that a spread element can have a contextual type, it does not do anything - // with this type. It is neither affected by it, nor does it propagate it to its operand. - // So the fact that contextualMapper is passed is not important, because the operand of a spread - // element is not contextually typed. - var arrayOrIterableType = checkExpressionCached(node.expression, contextualMapper); - return checkIteratedTypeOrElementType(arrayOrIterableType, node.expression, /*allowStringInput*/ false); - } - function hasDefaultValue(node) { - return (node.kind === 163 /* BindingElement */ && !!node.initializer) || - (node.kind === 181 /* BinaryExpression */ && node.operatorToken.kind === 56 /* EqualsToken */); - } - function checkArrayLiteral(node, contextualMapper) { - var elements = node.elements; - var hasSpreadElement = false; - var elementTypes = []; - var inDestructuringPattern = isAssignmentTarget(node); - for (var _i = 0; _i < elements.length; _i++) { - var e = elements[_i]; - if (inDestructuringPattern && e.kind === 185 /* SpreadElementExpression */) { - // Given the following situation: - // var c: {}; - // [...c] = ["", 0]; - // - // c is represented in the tree as a spread element in an array literal. - // But c really functions as a rest element, and its purpose is to provide - // a contextual type for the right hand side of the assignment. Therefore, - // instead of calling checkExpression on "...c", which will give an error - // if c is not iterable/array-like, we need to act as if we are trying to - // get the contextual element type from it. So we do something similar to - // getContextualTypeForElementExpression, which will crucially not error - // 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); - if (restElementType) { - elementTypes.push(restElementType); - } - } - else { - var type = checkExpression(e, contextualMapper); - elementTypes.push(type); - } - hasSpreadElement = hasSpreadElement || e.kind === 185 /* SpreadElementExpression */; - } - if (!hasSpreadElement) { - // If array literal is actually a destructuring pattern, mark it as an implied type. We do this such - // that we get the same behavior for "var [x, y] = []" and "[x, y] = []". - if (inDestructuringPattern && elementTypes.length) { - var type = createNewTupleType(elementTypes); - type.pattern = node; - return type; - } - var contextualType = getContextualType(node); - if (contextualType && contextualTypeIsTupleLikeType(contextualType)) { - 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 === 162 /* ArrayBindingPattern */ || pattern.kind === 164 /* ArrayLiteralExpression */)) { - var patternElements = pattern.elements; - for (var i = elementTypes.length; i < patternElements.length; i++) { - var patternElement = patternElements[i]; - if (hasDefaultValue(patternElement)) { - elementTypes.push(contextualType.elementTypes[i]); - } - else { - if (patternElement.kind !== 187 /* OmittedExpression */) { - error(patternElement, ts.Diagnostics.Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value); - } - elementTypes.push(unknownType); - } - } - } - if (elementTypes.length) { - return createTupleType(elementTypes); - } - } - } - return createArrayType(elementTypes.length ? getUnionType(elementTypes) : undefinedType); - } - function isNumericName(name) { - return name.kind === 136 /* ComputedPropertyName */ ? isNumericComputedName(name) : isNumericLiteralName(name.text); - } - function isNumericComputedName(name) { - // It seems odd to consider an expression of type Any to result in a numeric name, - // but this behavior is consistent with checkIndexedAccess - return isTypeAnyOrAllConstituentTypesHaveKind(checkComputedPropertyName(name), 132 /* NumberLike */); - } - function isTypeAnyOrAllConstituentTypesHaveKind(type, kind) { - return isTypeAny(type) || allConstituentTypesHaveKind(type, kind); - } - function isNumericLiteralName(name) { - // The intent of numeric names is that - // - they are names with text in a numeric form, and that - // - setting properties/indexing with them is always equivalent to doing so with the numeric literal 'numLit', - // acquired by applying the abstract 'ToNumber' operation on the name's text. - // - // The subtlety is in the latter portion, as we cannot reliably say that anything that looks like a numeric literal is a numeric name. - // In fact, it is the case that the text of the name must be equal to 'ToString(numLit)' for this to hold. - // - // Consider the property name '"0xF00D"'. When one indexes with '0xF00D', they are actually indexing with the value of 'ToString(0xF00D)' - // according to the ECMAScript specification, so it is actually as if the user indexed with the string '"61453"'. - // Thus, the text of all numeric literals equivalent to '61543' such as '0xF00D', '0xf00D', '0170015', etc. are not valid numeric names - // because their 'ToString' representation is not equal to their original text. - // This is motivated by ECMA-262 sections 9.3.1, 9.8.1, 11.1.5, and 11.2.1. - // - // Here, we test whether 'ToString(ToNumber(name))' is exactly equal to 'name'. - // The '+' prefix operator is equivalent here to applying the abstract ToNumber operation. - // Applying the 'toString()' method on a number gives us the abstract ToString operation on a number. - // - // Note that this accepts the values 'Infinity', '-Infinity', and 'NaN', and that this is intentional. - // This is desired behavior, because when indexing with them as numeric entities, you are indexing - // with the strings '"Infinity"', '"-Infinity"', and '"NaN"' respectively. - return (+name).toString() === name; - } - function checkComputedPropertyName(node) { - var links = getNodeLinks(node.expression); - if (!links.resolvedType) { - links.resolvedType = checkExpression(node.expression); - // This will allow types number, string, symbol or any. It will also allow enums, the unknown - // type, and any union of these types (like string | number). - if (!isTypeAnyOrAllConstituentTypesHaveKind(links.resolvedType, 132 /* NumberLike */ | 258 /* StringLike */ | 16777216 /* ESSymbol */)) { - error(node, ts.Diagnostics.A_computed_property_name_must_be_of_type_string_number_symbol_or_any); - } - else { - checkThatExpressionIsProperSymbolReference(node.expression, links.resolvedType, /*reportError*/ true); - } - } - return links.resolvedType; - } - function checkObjectLiteral(node, contextualMapper) { - var inDestructuringPattern = isAssignmentTarget(node); - // Grammar checking - checkGrammarObjectLiteralExpression(node, inDestructuringPattern); - var propertiesTable = {}; - var propertiesArray = []; - var contextualType = getContextualType(node); - var contextualTypeHasPattern = contextualType && contextualType.pattern && - (contextualType.pattern.kind === 161 /* ObjectBindingPattern */ || contextualType.pattern.kind === 165 /* ObjectLiteralExpression */); - var typeFlags = 0; - for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { - var memberDecl = _a[_i]; - var member = memberDecl.symbol; - if (memberDecl.kind === 245 /* PropertyAssignment */ || - memberDecl.kind === 246 /* ShorthandPropertyAssignment */ || - ts.isObjectLiteralMethod(memberDecl)) { - var type = void 0; - if (memberDecl.kind === 245 /* PropertyAssignment */) { - type = checkPropertyAssignment(memberDecl, contextualMapper); - } - else if (memberDecl.kind === 143 /* MethodDeclaration */) { - type = checkObjectLiteralMethod(memberDecl, contextualMapper); - } - else { - ts.Debug.assert(memberDecl.kind === 246 /* ShorthandPropertyAssignment */); - type = checkExpression(memberDecl.name, contextualMapper); - } - typeFlags |= type.flags; - var prop = createSymbol(4 /* Property */ | 67108864 /* Transient */ | member.flags, member.name); - if (inDestructuringPattern) { - // If object literal is an assignment pattern and if the assignment pattern specifies a default value - // for the property, make the property optional. - var isOptional = (memberDecl.kind === 245 /* PropertyAssignment */ && hasDefaultValue(memberDecl.initializer)) || - (memberDecl.kind === 246 /* ShorthandPropertyAssignment */ && memberDecl.objectAssignmentInitializer); - if (isOptional) { - prop.flags |= 536870912 /* Optional */; - } - } - else if (contextualTypeHasPattern) { - // 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); - if (impliedProp) { - prop.flags |= impliedProp.flags & 536870912 /* Optional */; - } - else if (!compilerOptions.suppressExcessPropertyErrors) { - error(memberDecl.name, ts.Diagnostics.Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1, symbolToString(member), typeToString(contextualType)); - } - } - prop.declarations = member.declarations; - prop.parent = member.parent; - if (member.valueDeclaration) { - prop.valueDeclaration = member.valueDeclaration; - } - prop.type = type; - prop.target = member; - member = prop; - } - else { - // TypeScript 1.0 spec (April 2014) - // A get accessor declaration is processed in the same manner as - // 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 === 145 /* GetAccessor */ || memberDecl.kind === 146 /* SetAccessor */); - checkAccessorDeclaration(memberDecl); - } - if (!ts.hasDynamicName(memberDecl)) { - propertiesTable[member.name] = member; - } - propertiesArray.push(member); - } - // If object literal is contextually typed by the implied type of a binding pattern, augment the result - // type with those properties for which the binding pattern specifies a default value. - if (contextualTypeHasPattern) { - for (var _b = 0, _c = getPropertiesOfType(contextualType); _b < _c.length; _b++) { - var prop = _c[_b]; - if (!ts.hasProperty(propertiesTable, prop.name)) { - if (!(prop.flags & 536870912 /* Optional */)) { - error(prop.valueDeclaration || prop.bindingElement, ts.Diagnostics.Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value); - } - propertiesTable[prop.name] = prop; - propertiesArray.push(prop); - } - } - } - var stringIndexType = getIndexType(0 /* String */); - var numberIndexType = getIndexType(1 /* Number */); - var result = createAnonymousType(node.symbol, propertiesTable, emptyArray, emptyArray, stringIndexType, numberIndexType); - var freshObjectLiteralFlag = compilerOptions.suppressExcessPropertyErrors ? 0 : 1048576 /* FreshObjectLiteral */; - result.flags |= 524288 /* ObjectLiteral */ | 4194304 /* ContainsObjectLiteral */ | freshObjectLiteralFlag | (typeFlags & 14680064 /* PropagatingFlags */); - if (inDestructuringPattern) { - result.pattern = node; - } - return result; - function getIndexType(kind) { - if (contextualType && contextualTypeHasIndexSignature(contextualType, kind)) { - var propTypes = []; - for (var i = 0; i < propertiesArray.length; i++) { - var propertyDecl = node.properties[i]; - if (kind === 0 /* String */ || isNumericName(propertyDecl.name)) { - // Do not call getSymbolOfNode(propertyDecl), as that will get the - // original symbol for the node. We actually want to get the symbol - // created by checkObjectLiteral, since that will be appropriately - // contextually typed and resolved. - var type = getTypeOfSymbol(propertiesArray[i]); - if (!ts.contains(propTypes, type)) { - propTypes.push(type); - } - } - } - var result_1 = propTypes.length ? getUnionType(propTypes) : undefinedType; - typeFlags |= result_1.flags; - return result_1; - } - return undefined; - } - } - function checkJsxSelfClosingElement(node) { - checkJsxOpeningLikeElement(node); - return jsxElementType || anyType; - } - function tagNamesAreEquivalent(lhs, rhs) { - if (lhs.kind !== rhs.kind) { - return false; - } - if (lhs.kind === 69 /* Identifier */) { - return lhs.text === rhs.text; - } - return lhs.right.text === rhs.right.text && - tagNamesAreEquivalent(lhs.left, rhs.left); - } - function checkJsxElement(node) { - // Check attributes - checkJsxOpeningLikeElement(node.openingElement); - // Check that the closing tag matches - if (!tagNamesAreEquivalent(node.openingElement.tagName, node.closingElement.tagName)) { - error(node.closingElement, ts.Diagnostics.Expected_corresponding_JSX_closing_tag_for_0, ts.getTextOfNode(node.openingElement.tagName)); - } - else { - // Perform resolution on the closing tag so that rename/go to definition/etc work - getJsxElementTagSymbol(node.closingElement); - } - // Check children - for (var _i = 0, _a = node.children; _i < _a.length; _i++) { - var child = _a[_i]; - switch (child.kind) { - case 240 /* JsxExpression */: - checkJsxExpression(child); - break; - case 233 /* JsxElement */: - checkJsxElement(child); - break; - case 234 /* JsxSelfClosingElement */: - checkJsxSelfClosingElement(child); - break; - } - } - return jsxElementType || anyType; - } - /** - * Returns true iff the JSX element name would be a valid JS identifier, ignoring restrictions about keywords not being identifiers - */ - function isUnhyphenatedJsxName(name) { - // - is the only character supported in JSX attribute names that isn't valid in JavaScript identifiers - return name.indexOf("-") < 0; - } - /** - * Returns true iff React would emit this tag name as a string rather than an identifier or qualified name - */ - function isJsxIntrinsicIdentifier(tagName) { - if (tagName.kind === 135 /* QualifiedName */) { - return false; - } - else { - return ts.isIntrinsicJsxName(tagName.text); - } - } - function checkJsxAttribute(node, elementAttributesType, nameTable) { - var correspondingPropType = undefined; - // Look up the corresponding property for this attribute - if (elementAttributesType === emptyObjectType && isUnhyphenatedJsxName(node.name.text)) { - // If there is no 'props' property, you may not have non-"data-" attributes - error(node.parent, ts.Diagnostics.JSX_element_class_does_not_support_attributes_because_it_does_not_have_a_0_property, getJsxElementPropertiesName()); - } - else if (elementAttributesType && !isTypeAny(elementAttributesType)) { - var correspondingPropSymbol = getPropertyOfType(elementAttributesType, node.name.text); - correspondingPropType = correspondingPropSymbol && getTypeOfSymbol(correspondingPropSymbol); - if (isUnhyphenatedJsxName(node.name.text)) { - // Maybe there's a string indexer? - var indexerType = getIndexTypeOfType(elementAttributesType, 0 /* String */); - if (indexerType) { - correspondingPropType = indexerType; - } - else { - // If there's no corresponding property with this name, error - if (!correspondingPropType) { - error(node.name, ts.Diagnostics.Property_0_does_not_exist_on_type_1, node.name.text, typeToString(elementAttributesType)); - return unknownType; - } - } - } - } - var exprType; - if (node.initializer) { - exprType = checkExpression(node.initializer); - } - else { - // is sugar for - exprType = booleanType; - } - if (correspondingPropType) { - checkTypeAssignableTo(exprType, correspondingPropType, node); - } - nameTable[node.name.text] = true; - return exprType; - } - function checkJsxSpreadAttribute(node, elementAttributesType, nameTable) { - var type = checkExpression(node.expression); - var props = getPropertiesOfType(type); - for (var _i = 0; _i < props.length; _i++) { - var prop = props[_i]; - // Is there a corresponding property in the element attributes type? Skip checking of properties - // that have already been assigned to, as these are not actually pushed into the resulting type - if (!nameTable[prop.name]) { - var targetPropSym = getPropertyOfType(elementAttributesType, prop.name); - if (targetPropSym) { - var msg = ts.chainDiagnosticMessages(undefined, ts.Diagnostics.Property_0_of_JSX_spread_attribute_is_not_assignable_to_target_property, prop.name); - checkTypeAssignableTo(getTypeOfSymbol(prop), getTypeOfSymbol(targetPropSym), node, undefined, msg); - } - nameTable[prop.name] = true; - } - } - return type; - } - /// Returns the type JSX.IntrinsicElements. May return `unknownType` if that type is not present. - function getJsxIntrinsicElementsType() { - if (!jsxIntrinsicElementsType) { - jsxIntrinsicElementsType = getExportedTypeFromNamespace(JsxNames.JSX, JsxNames.IntrinsicElements) || unknownType; - } - return jsxIntrinsicElementsType; - } - /// Given a JSX opening element or self-closing element, return the symbol of the property that the tag name points to if - /// this is an intrinsic tag. This might be a named - /// property of the IntrinsicElements interface, or its string indexer. - /// If this is a class-based tag (otherwise returns undefined), returns the symbol of the class - /// type or factory function. - /// Otherwise, returns unknownSymbol. - function getJsxElementTagSymbol(node) { - var flags = 8 /* UnknownElement */; - var links = getNodeLinks(node); - if (!links.resolvedSymbol) { - if (isJsxIntrinsicIdentifier(node.tagName)) { - links.resolvedSymbol = lookupIntrinsicTag(node); - } - else { - links.resolvedSymbol = lookupClassTag(node); - } - } - return links.resolvedSymbol; - function lookupIntrinsicTag(node) { - var intrinsicElementsType = getJsxIntrinsicElementsType(); - if (intrinsicElementsType !== unknownType) { - // Property case - var intrinsicProp = getPropertyOfType(intrinsicElementsType, node.tagName.text); - if (intrinsicProp) { - links.jsxFlags |= 1 /* IntrinsicNamedElement */; - return intrinsicProp; - } - // Intrinsic string indexer case - var indexSignatureType = getIndexTypeOfType(intrinsicElementsType, 0 /* String */); - if (indexSignatureType) { - links.jsxFlags |= 2 /* IntrinsicIndexedElement */; - return intrinsicElementsType.symbol; - } - // Wasn't found - error(node, ts.Diagnostics.Property_0_does_not_exist_on_type_1, node.tagName.text, "JSX." + JsxNames.IntrinsicElements); - return unknownSymbol; - } - else { - if (compilerOptions.noImplicitAny) { - error(node, ts.Diagnostics.JSX_element_implicitly_has_type_any_because_no_interface_JSX_0_exists, JsxNames.IntrinsicElements); - } - } - } - function lookupClassTag(node) { - var valueSymbol = resolveJsxTagName(node); - // Look up the value in the current scope - if (valueSymbol && valueSymbol !== unknownSymbol) { - links.jsxFlags |= 4 /* ClassElement */; - if (valueSymbol.flags & 8388608 /* Alias */) { - markAliasSymbolAsReferenced(valueSymbol); - } - } - return valueSymbol || unknownSymbol; - } - function resolveJsxTagName(node) { - if (node.tagName.kind === 69 /* Identifier */) { - var tag = node.tagName; - var sym = getResolvedSymbol(tag); - return sym.exportSymbol || sym; - } - else { - return checkQualifiedName(node.tagName).symbol; - } - } - } - /** - * Given a JSX element that is a class element, finds the Element Instance Type. If the - * element is not a class element, or the class element type cannot be determined, returns 'undefined'. - * For example, in the element , the element instance type is `MyClass` (not `typeof MyClass`). - */ - function getJsxElementInstanceType(node) { - // There is no such thing as an instance type for a non-class element. This - // line shouldn't be hit. - ts.Debug.assert(!!(getNodeLinks(node).jsxFlags & 4 /* ClassElement */), "Should not call getJsxElementInstanceType on non-class Element"); - var classSymbol = getJsxElementTagSymbol(node); - if (classSymbol === unknownSymbol) { - // Couldn't find the class instance type. Error has already been issued - return anyType; - } - var valueType = getTypeOfSymbol(classSymbol); - if (isTypeAny(valueType)) { - // Short-circuit if the class tag is using an element type 'any' - return anyType; - } - // Resolve the signatures, preferring constructors - var signatures = getSignaturesOfType(valueType, 1 /* Construct */); - if (signatures.length === 0) { - // No construct signatures, try call signatures - signatures = getSignaturesOfType(valueType, 0 /* Call */); - if (signatures.length === 0) { - // We found no signatures at all, which is an error - error(node.tagName, ts.Diagnostics.JSX_element_type_0_does_not_have_any_construct_or_call_signatures, ts.getTextOfNode(node.tagName)); - return unknownType; - } - } - var returnType = getUnionType(signatures.map(getReturnTypeOfSignature)); - // Issue an error if this return type isn't assignable to JSX.ElementClass - var elemClassType = getJsxGlobalElementClassType(); - if (elemClassType) { - checkTypeRelatedTo(returnType, elemClassType, assignableRelation, node, ts.Diagnostics.JSX_element_type_0_is_not_a_constructor_function_for_JSX_elements); - } - return returnType; - } - /// e.g. "props" for React.d.ts, - /// or 'undefined' if ElementAttributesPropery doesn't exist (which means all - /// non-intrinsic elements' attributes type is 'any'), - /// or '' if it has 0 properties (which means every - /// non-instrinsic elements' attributes type is the element instance type) - function getJsxElementPropertiesName() { - // JSX - var jsxNamespace = getGlobalSymbol(JsxNames.JSX, 1536 /* Namespace */, /*diagnosticMessage*/ undefined); - // JSX.ElementAttributesProperty [symbol] - var attribsPropTypeSym = jsxNamespace && getSymbol(jsxNamespace.exports, JsxNames.ElementAttributesPropertyNameContainer, 793056 /* Type */); - // JSX.ElementAttributesProperty [type] - var attribPropType = attribsPropTypeSym && getDeclaredTypeOfSymbol(attribsPropTypeSym); - // The properites of JSX.ElementAttributesProperty - var attribProperties = attribPropType && getPropertiesOfType(attribPropType); - if (attribProperties) { - // Element Attributes has zero properties, so the element attributes type will be the class instance type - if (attribProperties.length === 0) { - return ""; - } - else if (attribProperties.length === 1) { - return attribProperties[0].name; - } - else { - error(attribsPropTypeSym.declarations[0], ts.Diagnostics.The_global_type_JSX_0_may_not_have_more_than_one_property, JsxNames.ElementAttributesPropertyNameContainer); - return undefined; - } - } - else { - // No interface exists, so the element attributes type will be an implicit any - return undefined; - } - } - /** - * Given an opening/self-closing element, get the 'element attributes type', i.e. the type that tells - * us which attributes are valid on a given element. - */ - function getJsxElementAttributesType(node) { - var links = getNodeLinks(node); - if (!links.resolvedJsxType) { - var sym = getJsxElementTagSymbol(node); - if (links.jsxFlags & 4 /* ClassElement */) { - var elemInstanceType = getJsxElementInstanceType(node); - if (isTypeAny(elemInstanceType)) { - return links.resolvedJsxType = elemInstanceType; - } - var propsName = getJsxElementPropertiesName(); - if (propsName === undefined) { - // There is no type ElementAttributesProperty, return 'any' - return links.resolvedJsxType = anyType; - } - else if (propsName === "") { - // If there is no e.g. 'props' member in ElementAttributesProperty, use the element class type instead - return links.resolvedJsxType = elemInstanceType; - } - else { - var attributesType = getTypeOfPropertyOfType(elemInstanceType, propsName); - if (!attributesType) { - // There is no property named 'props' on this instance type - return links.resolvedJsxType = emptyObjectType; - } - else if (isTypeAny(attributesType) || (attributesType === unknownType)) { - return links.resolvedJsxType = attributesType; - } - else if (!(attributesType.flags & 80896 /* ObjectType */)) { - error(node.tagName, ts.Diagnostics.JSX_element_attributes_type_0_must_be_an_object_type, typeToString(attributesType)); - return links.resolvedJsxType = anyType; - } - else { - return links.resolvedJsxType = attributesType; - } - } - } - else if (links.jsxFlags & 1 /* IntrinsicNamedElement */) { - return links.resolvedJsxType = getTypeOfSymbol(sym); - } - else if (links.jsxFlags & 2 /* IntrinsicIndexedElement */) { - return links.resolvedJsxType = getIndexTypeOfSymbol(sym, 0 /* String */); - } - else { - // Resolution failed, so we don't know - return links.resolvedJsxType = anyType; - } - } - return links.resolvedJsxType; - } - /** - * Given a JSX attribute, returns the symbol for the corresponds property - * of the element attributes type. Will return unknownSymbol for attributes - * that have no matching element attributes type property. - */ - function getJsxAttributePropertySymbol(attrib) { - var attributesType = getJsxElementAttributesType(attrib.parent); - var prop = getPropertyOfType(attributesType, attrib.name.text); - return prop || unknownSymbol; - } - var jsxElementClassType = undefined; - function getJsxGlobalElementClassType() { - if (!jsxElementClassType) { - jsxElementClassType = getExportedTypeFromNamespace(JsxNames.JSX, JsxNames.ElementClass); - } - return jsxElementClassType; - } - /// Returns all the properties of the Jsx.IntrinsicElements interface - function getJsxIntrinsicTagNames() { - var intrinsics = getJsxIntrinsicElementsType(); - return intrinsics ? getPropertiesOfType(intrinsics) : emptyArray; - } - function checkJsxPreconditions(errorNode) { - // Preconditions for using JSX - if ((compilerOptions.jsx || 0 /* None */) === 0 /* None */) { - error(errorNode, ts.Diagnostics.Cannot_use_JSX_unless_the_jsx_flag_is_provided); - } - if (jsxElementType === undefined) { - if (compilerOptions.noImplicitAny) { - error(errorNode, ts.Diagnostics.JSX_element_implicitly_has_type_any_because_the_global_type_JSX_Element_does_not_exist); - } - } - } - function checkJsxOpeningLikeElement(node) { - checkGrammarJsxElement(node); - checkJsxPreconditions(node); - // If we're compiling under --jsx react, the symbol 'React' should - // be marked as 'used' so we don't incorrectly elide its import. And if there - // is no 'React' symbol in scope, we should issue an error. - if (compilerOptions.jsx === 2 /* React */) { - var reactSym = resolveName(node.tagName, "React", 107455 /* Value */, ts.Diagnostics.Cannot_find_name_0, "React"); - if (reactSym) { - getSymbolLinks(reactSym).referenced = true; - } - } - var targetAttributesType = getJsxElementAttributesType(node); - var nameTable = {}; - // Process this array in right-to-left order so we know which - // attributes (mostly from spreads) are being overwritten and - // thus should have their types ignored - var sawSpreadedAny = false; - for (var i = node.attributes.length - 1; i >= 0; i--) { - if (node.attributes[i].kind === 238 /* JsxAttribute */) { - checkJsxAttribute((node.attributes[i]), targetAttributesType, nameTable); - } - else { - ts.Debug.assert(node.attributes[i].kind === 239 /* JsxSpreadAttribute */); - var spreadType = checkJsxSpreadAttribute((node.attributes[i]), targetAttributesType, nameTable); - if (isTypeAny(spreadType)) { - sawSpreadedAny = true; - } - } - } - // Check that all required properties have been provided. If an 'any' - // was spreaded in, though, assume that it provided all required properties - if (targetAttributesType && !sawSpreadedAny) { - var targetProperties = getPropertiesOfType(targetAttributesType); - for (var i = 0; i < targetProperties.length; i++) { - if (!(targetProperties[i].flags & 536870912 /* Optional */) && - nameTable[targetProperties[i].name] === undefined) { - error(node, ts.Diagnostics.Property_0_is_missing_in_type_1, targetProperties[i].name, typeToString(targetAttributesType)); - } - } - } - } - function checkJsxExpression(node) { - if (node.expression) { - return checkExpression(node.expression); - } - else { - return unknownType; - } - } - // 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 : 141 /* PropertyDeclaration */; - } - function getDeclarationFlagsFromSymbol(s) { - return s.valueDeclaration ? ts.getCombinedNodeFlags(s.valueDeclaration) : s.flags & 134217728 /* Prototype */ ? 16 /* Public */ | 128 /* Static */ : 0; - } - /** - * Check whether the requested property access is valid. - * Returns true if node is a valid property access, and false otherwise. - * @param node The node to be checked. - * @param left The left hand side of the property access (e.g.: the super in `super.foo`). - * @param type The type of left. - * @param prop The symbol for the right hand side of the property access. - */ - function checkClassPropertyAccess(node, left, type, prop) { - var flags = getDeclarationFlagsFromSymbol(prop); - var declaringClass = getDeclaredTypeOfSymbol(prop.parent); - if (left.kind === 95 /* SuperKeyword */) { - var errorNode = node.kind === 166 /* PropertyAccessExpression */ ? - node.name : - node.right; - // 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, - // a super property access is permitted and must specify a public instance member function of the base class. - // - In a static member function or static member accessor - // where this references the constructor function object of a derived class, - // a super property access is permitted and must specify a public static member function of the base class. - if (getDeclarationKindFromSymbol(prop) !== 143 /* MethodDeclaration */) { - // `prop` refers to a *property* declared in the super class - // rather than a *method*, so it does not satisfy the above criteria. - error(errorNode, ts.Diagnostics.Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword); - return false; - } - if (flags & 256 /* Abstract */) { - // A method cannot be accessed in a super property access if the method is abstract. - // This error could mask a private property access error. But, a member - // cannot simultaneously be private and abstract, so this will trigger an - // additional error elsewhere. - error(errorNode, ts.Diagnostics.Abstract_method_0_in_class_1_cannot_be_accessed_via_super_expression, symbolToString(prop), typeToString(declaringClass)); - return false; - } - } - // Public properties are otherwise accessible. - if (!(flags & (32 /* Private */ | 64 /* Protected */))) { - return true; - } - // Property is known to be private or protected at this point - // Get the declaring and enclosing class instance types - var enclosingClassDeclaration = ts.getContainingClass(node); - var enclosingClass = enclosingClassDeclaration ? getDeclaredTypeOfSymbol(getSymbolOfNode(enclosingClassDeclaration)) : undefined; - // Private property is accessible if declaring and enclosing class are the same - if (flags & 32 /* Private */) { - if (declaringClass !== enclosingClass) { - error(node, ts.Diagnostics.Property_0_is_private_and_only_accessible_within_class_1, symbolToString(prop), typeToString(declaringClass)); - return false; - } - return true; - } - // 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 */) { - return true; - } - // A protected property is accessible in the declaring class and classes derived from it - if (!enclosingClass || !hasBaseType(enclosingClass, declaringClass)) { - error(node, ts.Diagnostics.Property_0_is_protected_and_only_accessible_within_class_1_and_its_subclasses, symbolToString(prop), typeToString(declaringClass)); - return false; - } - // No further restrictions for static properties - if (flags & 128 /* Static */) { - return true; - } - // An instance property must be accessed through an instance of the enclosing class - if (type.flags & 33554432 /* ThisType */) { - // get the original type -- represented as the type constraint of the 'this' type - type = getConstraintOfTypeParameter(type); - } - // TODO: why is the first part of this check here? - if (!(getTargetType(type).flags & (1024 /* Class */ | 2048 /* Interface */) && hasBaseType(type, enclosingClass))) { - error(node, ts.Diagnostics.Property_0_is_protected_and_only_accessible_through_an_instance_of_class_1, symbolToString(prop), typeToString(enclosingClass)); - return false; - } - return true; - } - function checkPropertyAccessExpression(node) { - return checkPropertyAccessExpressionOrQualifiedName(node, node.expression, node.name); - } - function checkQualifiedName(node) { - return checkPropertyAccessExpressionOrQualifiedName(node, node.left, node.right); - } - function checkPropertyAccessExpressionOrQualifiedName(node, left, right) { - var type = checkExpression(left); - if (isTypeAny(type)) { - return type; - } - var apparentType = getApparentType(getWidenedType(type)); - if (apparentType === unknownType) { - // handle cases when type is Type parameter with invalid constraint - return unknownType; - } - var prop = getPropertyOfType(apparentType, right.text); - if (!prop) { - if (right.text) { - error(right, ts.Diagnostics.Property_0_does_not_exist_on_type_1, ts.declarationNameToString(right), typeToString(type.flags & 33554432 /* ThisType */ ? apparentType : type)); - } - return unknownType; - } - getNodeLinks(node).resolvedSymbol = prop; - if (prop.parent && prop.parent.flags & 32 /* Class */) { - checkClassPropertyAccess(node, left, apparentType, prop); - } - return getTypeOfSymbol(prop); - } - function isValidPropertyAccess(node, propertyName) { - var left = node.kind === 166 /* PropertyAccessExpression */ - ? node.expression - : node.left; - var type = checkExpression(left); - if (type !== unknownType && !isTypeAny(type)) { - var prop = getPropertyOfType(getWidenedType(type), propertyName); - if (prop && prop.parent && prop.parent.flags & 32 /* Class */) { - return checkClassPropertyAccess(node, left, type, prop); - } - } - return true; - } - function checkIndexedAccess(node) { - // Grammar checking - if (!node.argumentExpression) { - var sourceFile = getSourceFile(node); - if (node.parent.kind === 169 /* NewExpression */ && node.parent.expression === node) { - var start = ts.skipTrivia(sourceFile.text, node.expression.end); - var end = node.end; - grammarErrorAtPos(sourceFile, start, end - start, ts.Diagnostics.new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead); - } - else { - var start = node.end - "]".length; - var end = node.end; - grammarErrorAtPos(sourceFile, start, end - start, ts.Diagnostics.Expression_expected); - } - } - // Obtain base constraint such that we can bail out if the constraint is an unknown type - var objectType = getApparentType(checkExpression(node.expression)); - var indexType = node.argumentExpression ? checkExpression(node.argumentExpression) : unknownType; - if (objectType === unknownType) { - return unknownType; - } - var isConstEnum = isConstEnumObjectType(objectType); - if (isConstEnum && - (!node.argumentExpression || node.argumentExpression.kind !== 9 /* StringLiteral */)) { - error(node.argumentExpression, ts.Diagnostics.A_const_enum_member_can_only_be_accessed_using_a_string_literal); - return unknownType; - } - // TypeScript 1.0 spec (April 2014): 4.10 Property Access - // - If IndexExpr is a string literal or a numeric literal and ObjExpr's apparent type has a property with the name - // given by that literal(converted to its string representation in the case of a numeric literal), the property access is of the type of that property. - // - Otherwise, if ObjExpr's apparent type has a numeric index signature and IndexExpr is of type Any, the Number primitive type, or an enum type, - // the property access is of the type of that index signature. - // - Otherwise, if ObjExpr's apparent type has a string index signature and IndexExpr is of type Any, the String or Number primitive type, or an enum type, - // the property access is of the type of that index signature. - // - Otherwise, if IndexExpr is of type Any, the String or Number primitive type, or an enum type, the property access is of type Any. - // See if we can index as a property. - if (node.argumentExpression) { - var name_11 = getPropertyNameForIndexedAccess(node.argumentExpression, indexType); - if (name_11 !== undefined) { - var prop = getPropertyOfType(objectType, name_11); - 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_11, symbolToString(objectType.symbol)); - return unknownType; - } - } - } - // Check for compatible indexer types. - if (isTypeAnyOrAllConstituentTypesHaveKind(indexType, 258 /* StringLike */ | 132 /* NumberLike */ | 16777216 /* ESSymbol */)) { - // Try to use a number indexer. - if (isTypeAnyOrAllConstituentTypesHaveKind(indexType, 132 /* NumberLike */)) { - var numberIndexType = getIndexTypeOfType(objectType, 1 /* Number */); - if (numberIndexType) { - return numberIndexType; - } - } - // Try to use string indexing. - var stringIndexType = getIndexTypeOfType(objectType, 0 /* String */); - if (stringIndexType) { - return stringIndexType; - } - // Fall back to any. - if (compilerOptions.noImplicitAny && !compilerOptions.suppressImplicitAnyIndexErrors && !isTypeAny(objectType)) { - error(node, ts.Diagnostics.Index_signature_of_object_type_implicitly_has_an_any_type); - } - return anyType; - } - // REVIEW: Users should know the type that was actually used. - error(node, ts.Diagnostics.An_index_expression_argument_must_be_of_type_string_number_symbol_or_any); - return unknownType; - } - /** - * If indexArgumentExpression is a string literal or number literal, returns its text. - * If indexArgumentExpression is a constant value, returns its string value. - * If indexArgumentExpression is a well known symbol, returns the property name corresponding - * to this symbol, as long as it is a proper symbol reference. - * Otherwise, returns undefined. - */ - function getPropertyNameForIndexedAccess(indexArgumentExpression, indexArgumentType) { - if (indexArgumentExpression.kind === 9 /* StringLiteral */ || indexArgumentExpression.kind === 8 /* NumericLiteral */) { - return indexArgumentExpression.text; - } - if (indexArgumentExpression.kind === 167 /* ElementAccessExpression */ || indexArgumentExpression.kind === 166 /* PropertyAccessExpression */) { - var value = getConstantValue(indexArgumentExpression); - if (value !== undefined) { - return value.toString(); - } - } - if (checkThatExpressionIsProperSymbolReference(indexArgumentExpression, indexArgumentType, /*reportError*/ false)) { - var rightHandSideName = indexArgumentExpression.name.text; - return ts.getPropertyNameForKnownSymbolName(rightHandSideName); - } - return undefined; - } - /** - * A proper symbol reference requires the following: - * 1. The property access denotes a property that exists - * 2. The expression is of the form Symbol. - * 3. The property access is of the primitive type symbol. - * 4. Symbol in this context resolves to the global Symbol object - */ - function checkThatExpressionIsProperSymbolReference(expression, expressionType, reportError) { - if (expressionType === unknownType) { - // There is already an error, so no need to report one. - return false; - } - if (!ts.isWellKnownSymbolSyntactically(expression)) { - return false; - } - // Make sure the property type is the primitive symbol type - if ((expressionType.flags & 16777216 /* ESSymbol */) === 0) { - if (reportError) { - error(expression, ts.Diagnostics.A_computed_property_name_of_the_form_0_must_be_of_type_symbol, ts.getTextOfNode(expression)); - } - return false; - } - // The name is Symbol., so make sure Symbol actually resolves to the - // global Symbol object - var leftHandSide = expression.expression; - var leftHandSideSymbol = getResolvedSymbol(leftHandSide); - if (!leftHandSideSymbol) { - return false; - } - var globalESSymbol = getGlobalESSymbolConstructorSymbol(); - if (!globalESSymbol) { - // Already errored when we tried to look up the symbol - return false; - } - if (leftHandSideSymbol !== globalESSymbol) { - if (reportError) { - error(leftHandSide, ts.Diagnostics.Symbol_reference_does_not_refer_to_the_global_Symbol_constructor_object); - } - return false; - } - return true; - } - function resolveUntypedCall(node) { - if (node.kind === 170 /* TaggedTemplateExpression */) { - checkExpression(node.template); - } - else if (node.kind !== 139 /* Decorator */) { - ts.forEach(node.arguments, function (argument) { - checkExpression(argument); - }); - } - return anySignature; - } - function resolveErrorCall(node) { - resolveUntypedCall(node); - return unknownSignature; - } - // Re-order candidate signatures into the result array. Assumes the result array to be empty. - // The candidate list orders groups in reverse, but within a group signatures are kept in declaration order - // A nit here is that we reorder only signatures that belong to the same symbol, - // so order how inherited signatures are processed is still preserved. - // interface A { (x: string): void } - // interface B extends A { (x: 'foo'): string } - // let b: B; - // b('foo') // <- here overloads should be processed as [(x:'foo'): string, (x: string): void] - function reorderCandidates(signatures, result) { - var lastParent; - var lastSymbol; - var cutoffIndex = 0; - var index; - var specializedIndex = -1; - var spliceIndex; - ts.Debug.assert(!result.length); - for (var _i = 0; _i < signatures.length; _i++) { - var signature = signatures[_i]; - var symbol = signature.declaration && getSymbolOfNode(signature.declaration); - var parent_5 = signature.declaration && signature.declaration.parent; - if (!lastSymbol || symbol === lastSymbol) { - if (lastParent && parent_5 === lastParent) { - index++; - } - else { - lastParent = parent_5; - index = cutoffIndex; - } - } - else { - // 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_5; - } - lastSymbol = symbol; - // specialized signatures always need to be placed before non-specialized signatures regardless - // of the cutoff position; see GH#1133 - if (signature.hasStringLiterals) { - specializedIndex++; - spliceIndex = specializedIndex; - // The cutoff index always needs to be greater than or equal to the specialized signature index - // in order to prevent non-specialized signatures from being added before a specialized - // signature. - cutoffIndex++; - } - else { - spliceIndex = index; - } - result.splice(spliceIndex, 0, signature); - } - } - function getSpreadArgumentIndex(args) { - for (var i = 0; i < args.length; i++) { - var arg = args[i]; - if (arg && arg.kind === 185 /* SpreadElementExpression */) { - return i; - } - } - return -1; - } - function hasCorrectArity(node, args, signature) { - var adjustedArgCount; // Apparent number of arguments we will have in this call - var typeArguments; // Type arguments (undefined if none) - var callIsIncomplete; // In incomplete call we want to be lenient when we have too few arguments - var isDecorator; - var spreadArgIndex = -1; - if (node.kind === 170 /* TaggedTemplateExpression */) { - var tagExpression = node; - // Even if the call is incomplete, we'll have a missing expression as our last argument, - // so we can say the count is just the arg list length - adjustedArgCount = args.length; - typeArguments = undefined; - if (tagExpression.template.kind === 183 /* TemplateExpression */) { - // If a tagged template expression lacks a tail literal, the call is incomplete. - // Specifically, a template only can end in a TemplateTail or a Missing literal. - var templateExpression = tagExpression.template; - var lastSpan = ts.lastOrUndefined(templateExpression.templateSpans); - ts.Debug.assert(lastSpan !== undefined); // we should always have at least one span. - callIsIncomplete = ts.nodeIsMissing(lastSpan.literal) || !!lastSpan.literal.isUnterminated; - } - else { - // If the template didn't end in a backtick, or its beginning occurred right prior to EOF, - // 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 */); - callIsIncomplete = !!templateLiteral.isUnterminated; - } - } - else if (node.kind === 139 /* Decorator */) { - isDecorator = true; - typeArguments = undefined; - adjustedArgCount = getEffectiveArgumentCount(node, /*args*/ undefined, signature); - } - else { - var callExpression = node; - if (!callExpression.arguments) { - // This only happens when we have something of the form: 'new C' - ts.Debug.assert(callExpression.kind === 169 /* NewExpression */); - return signature.minArgumentCount === 0; - } - // For IDE scenarios we may have an incomplete call, so a trailing comma is tantamount to adding another argument. - adjustedArgCount = callExpression.arguments.hasTrailingComma ? args.length + 1 : args.length; - // If we are missing the close paren, the call is incomplete. - callIsIncomplete = callExpression.arguments.end === callExpression.end; - typeArguments = callExpression.typeArguments; - spreadArgIndex = getSpreadArgumentIndex(args); - } - // If the user supplied type arguments, but the number of type arguments does not match - // the declared number of type parameters, the call has an incorrect arity. - var hasRightNumberOfTypeArgs = !typeArguments || - (signature.typeParameters && typeArguments.length === signature.typeParameters.length); - if (!hasRightNumberOfTypeArgs) { - return false; - } - // If spread arguments are present, check that they correspond to a rest parameter. If so, no - // further checking is necessary. - if (spreadArgIndex >= 0) { - return isRestParameterIndex(signature, spreadArgIndex); - } - // Too many arguments implies incorrect arity. - if (!signature.hasRestParameter && adjustedArgCount > signature.parameters.length) { - return false; - } - // If the call is incomplete, we should skip the lower bound check. - var hasEnoughArguments = adjustedArgCount >= signature.minArgumentCount; - return callIsIncomplete || hasEnoughArguments; - } - // If type has a single call signature and no other members, return that signature. Otherwise, return undefined. - function getSingleCallSignature(type) { - if (type.flags & 80896 /* ObjectType */) { - var resolved = resolveStructuredTypeMembers(type); - if (resolved.callSignatures.length === 1 && resolved.constructSignatures.length === 0 && - resolved.properties.length === 0 && !resolved.stringIndexType && !resolved.numberIndexType) { - return resolved.callSignatures[0]; - } - } - return undefined; - } - // Instantiate a generic signature in the context of a non-generic signature (section 3.8.5 in TypeScript spec) - function instantiateSignatureInContextOf(signature, contextualSignature, contextualMapper) { - var context = createInferenceContext(signature.typeParameters, /*inferUnionTypes*/ true); - forEachMatchingParameterType(contextualSignature, signature, function (source, target) { - // Type parameters from outer context referenced by source type are fixed by instantiation of the source type - inferTypes(context, instantiateType(source, contextualMapper), target); - }); - return getSignatureInstantiation(signature, getInferredTypes(context)); - } - function inferTypeArguments(node, signature, args, excludeArgument, context) { - var typeParameters = signature.typeParameters; - var inferenceMapper = createInferenceMapper(context); - // Clear out all the inference results from the last time inferTypeArguments was called on this context - for (var i = 0; i < typeParameters.length; i++) { - // As an optimization, we don't have to clear (and later recompute) inferred types - // for type parameters that have already been fixed on the previous call to inferTypeArguments. - // It would be just as correct to reset all of them. But then we'd be repeating the same work - // for the type parameters that were fixed, namely the work done by getInferredType. - if (!context.inferences[i].isFixed) { - context.inferredTypes[i] = undefined; - } - } - // On this call to inferTypeArguments, we may get more inferences for certain type parameters that were not - // fixed last time. This means that a type parameter that failed inference last time may succeed this time, - // or vice versa. Therefore, the failedTypeParameterIndex is useless if it points to an unfixed type parameter, - // because it may change. So here we reset it. However, getInferredType will not revisit any type parameters - // that were previously fixed. So if a fixed type parameter failed previously, it will fail again because - // it will contain the exact same set of inferences. So if we reset the index from a fixed type parameter, - // we will lose information that we won't recover this time around. - if (context.failedTypeParameterIndex !== undefined && !context.inferences[context.failedTypeParameterIndex].isFixed) { - context.failedTypeParameterIndex = undefined; - } - // We perform two passes over the arguments. In the first pass we infer from all arguments, but use - // wildcards for all context sensitive function expressions. - var argCount = getEffectiveArgumentCount(node, args, signature); - 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 !== 187 /* OmittedExpression */) { - var paramType = getTypeAtPosition(signature, i); - var argType = getEffectiveArgumentType(node, i, arg); - // If the effective argument type is 'undefined', there is no synthetic type - // for the argument. In that case, we should check the argument. - if (argType === undefined) { - // For context sensitive arguments we pass the identityMapper, which is a signal to treat all - // context sensitive function expressions as wildcards - var mapper = excludeArgument && excludeArgument[i] !== undefined ? identityMapper : inferenceMapper; - argType = checkExpressionWithContextualType(arg, paramType, mapper); - } - inferTypes(context, argType, paramType); - } - } - // In the second pass we visit only context sensitive arguments, and only those that aren't excluded, this - // time treating function expressions normally (which may cause previously inferred type arguments to be fixed - // as we construct types for contextually typed parameters) - // Decorators will not have `excludeArgument`, as their arguments cannot be contextually typed. - // Tagged template expressions will always have `undefined` for `excludeArgument[0]`. - if (excludeArgument) { - for (var i = 0; i < argCount; i++) { - // No need to check for omitted args and template expressions, their exlusion value is always undefined - if (excludeArgument[i] === false) { - var arg = args[i]; - var paramType = getTypeAtPosition(signature, i); - inferTypes(context, checkExpressionWithContextualType(arg, paramType, inferenceMapper), paramType); - } - } - } - getInferredTypes(context); - } - function checkTypeArguments(signature, typeArguments, typeArgumentResultTypes, reportErrors, headMessage) { - var typeParameters = signature.typeParameters; - var typeArgumentsAreAssignable = true; - for (var i = 0; i < typeParameters.length; i++) { - var typeArgNode = typeArguments[i]; - var typeArgument = getTypeFromTypeNode(typeArgNode); - // Do not push on this array! It has a preallocated length - typeArgumentResultTypes[i] = typeArgument; - if (typeArgumentsAreAssignable /* so far */) { - var constraint = getConstraintOfTypeParameter(typeParameters[i]); - if (constraint) { - var errorInfo = void 0; - var typeArgumentHeadMessage = ts.Diagnostics.Type_0_does_not_satisfy_the_constraint_1; - if (reportErrors && headMessage) { - errorInfo = ts.chainDiagnosticMessages(errorInfo, typeArgumentHeadMessage); - typeArgumentHeadMessage = headMessage; - } - typeArgumentsAreAssignable = checkTypeAssignableTo(typeArgument, constraint, reportErrors ? typeArgNode : undefined, typeArgumentHeadMessage, errorInfo); - } - } - } - return typeArgumentsAreAssignable; - } - function checkApplicableSignature(node, args, signature, relation, excludeArgument, reportErrors) { - var argCount = getEffectiveArgumentCount(node, args, signature); - 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 !== 187 /* OmittedExpression */) { - // Check spread elements against rest type (from arity check we know spread argument corresponds to a rest parameter) - var paramType = getTypeAtPosition(signature, i); - var argType = getEffectiveArgumentType(node, i, arg); - // 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) { - argType = arg.kind === 9 /* StringLiteral */ && !reportErrors - ? getStringLiteralType(arg) - : checkExpressionWithContextualType(arg, paramType, excludeArgument && excludeArgument[i] ? identityMapper : undefined); - } - // Use argument expression as error location when reporting errors - var errorNode = reportErrors ? getEffectiveArgumentErrorNode(node, i, arg) : undefined; - var headMessage = ts.Diagnostics.Argument_of_type_0_is_not_assignable_to_parameter_of_type_1; - if (!checkTypeRelatedTo(argType, paramType, relation, errorNode, headMessage)) { - return false; - } - } - } - return true; - } - /** - * Returns the effective arguments for an expression that works like a function invocation. - * - * If 'node' is a CallExpression or a NewExpression, then its argument list is returned. - * If 'node' is a TaggedTemplateExpression, a new argument list is constructed from the substitution - * expressions, where the first element of the list is `undefined`. - * If 'node' is a Decorator, the argument list will be `undefined`, and its arguments and types - * will be supplied from calls to `getEffectiveArgumentCount` and `getEffectiveArgumentType`. - */ - function getEffectiveCallArguments(node) { - var args; - if (node.kind === 170 /* TaggedTemplateExpression */) { - var template = node.template; - args = [undefined]; - if (template.kind === 183 /* TemplateExpression */) { - ts.forEach(template.templateSpans, function (span) { - args.push(span.expression); - }); - } - } - else if (node.kind === 139 /* Decorator */) { - // For a decorator, we return undefined as we will determine - // the number and types of arguments for a decorator using - // `getEffectiveArgumentCount` and `getEffectiveArgumentType` below. - return undefined; - } - else { - args = node.arguments || emptyArray; - } - return args; - } - /** - * Returns the effective argument count for a node that works like a function invocation. - * If 'node' is a Decorator, the number of arguments is derived from the decoration - * target and the signature: - * If 'node.target' is a class declaration or class expression, the effective argument - * count is 1. - * If 'node.target' is a parameter declaration, the effective argument count is 3. - * If 'node.target' is a property declaration, the effective argument count is 2. - * If 'node.target' is a method or accessor declaration, the effective argument count - * is 3, although it can be 2 if the signature only accepts two arguments, allowing - * us to match a property decorator. - * Otherwise, the argument count is the length of the 'args' array. - */ - function getEffectiveArgumentCount(node, args, signature) { - if (node.kind === 139 /* Decorator */) { - switch (node.parent.kind) { - case 214 /* ClassDeclaration */: - case 186 /* ClassExpression */: - // A class decorator will have one argument (see `ClassDecorator` in core.d.ts) - return 1; - case 141 /* PropertyDeclaration */: - // A property declaration decorator will have two arguments (see - // `PropertyDecorator` in core.d.ts) - return 2; - case 143 /* MethodDeclaration */: - case 145 /* GetAccessor */: - case 146 /* SetAccessor */: - // A method or accessor declaration decorator will have two or three arguments (see - // `PropertyDecorator` and `MethodDecorator` in core.d.ts) - // If we are emitting decorators for ES3, we will only pass two arguments. - if (languageVersion === 0 /* ES3 */) { - return 2; - } - // If the method decorator signature only accepts a target and a key, we will only - // type check those arguments. - return signature.parameters.length >= 3 ? 3 : 2; - case 138 /* Parameter */: - // A parameter declaration decorator will have three arguments (see - // `ParameterDecorator` in core.d.ts) - return 3; - } - } - else { - return args.length; - } - } - /** - * Returns the effective type of the first argument to a decorator. - * If 'node' is a class declaration or class expression, the effective argument type - * is the type of the static side of the class. - * If 'node' is a parameter declaration, the effective argument type is either the type - * of the static or instance side of the class for the parameter's parent method, - * depending on whether the method is declared static. - * For a constructor, the type is always the type of the static side of the class. - * If 'node' is a property, method, or accessor declaration, the effective argument - * type is the type of the static or instance side of the parent class for class - * element, depending on whether the element is declared static. - */ - function getEffectiveDecoratorFirstArgumentType(node) { - // The first argument to a decorator is its `target`. - if (node.kind === 214 /* 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 === 138 /* Parameter */) { - // For a parameter decorator, the `target` is the parent type of the - // parameter's containing method. - node = node.parent; - if (node.kind === 144 /* Constructor */) { - var classSymbol = getSymbolOfNode(node); - return getTypeOfSymbol(classSymbol); - } - } - if (node.kind === 141 /* PropertyDeclaration */ || - node.kind === 143 /* MethodDeclaration */ || - node.kind === 145 /* GetAccessor */ || - node.kind === 146 /* SetAccessor */) { - // For a property or method decorator, the `target` is the - // "static"-side type of the parent of the member if the member is - // declared "static"; otherwise, it is the "instance"-side type of the - // parent of the member. - return getParentTypeOfClassElement(node); - } - ts.Debug.fail("Unsupported decorator target."); - return unknownType; - } - /** - * Returns the effective type for the second argument to a decorator. - * If 'node' is a parameter, its effective argument type is one of the following: - * If 'node.parent' is a constructor, the effective argument type is 'any', as we - * will emit `undefined`. - * If 'node.parent' is a member with an identifier, numeric, or string literal name, - * the effective argument type will be a string literal type for the member name. - * If 'node.parent' is a computed property name, the effective argument type will - * either be a symbol type or the string type. - * If 'node' is a member with an identifier, numeric, or string literal name, the - * effective argument type will be a string literal type for the member name. - * If 'node' is a computed property name, the effective argument type will either - * be a symbol type or the string type. - * A class decorator does not have a second argument type. - */ - function getEffectiveDecoratorSecondArgumentType(node) { - // The second argument to a decorator is its `propertyKey` - if (node.kind === 214 /* ClassDeclaration */) { - ts.Debug.fail("Class decorators should not have a second synthetic argument."); - return unknownType; - } - if (node.kind === 138 /* Parameter */) { - node = node.parent; - if (node.kind === 144 /* Constructor */) { - // For a constructor parameter decorator, the `propertyKey` will be `undefined`. - return anyType; - } - } - if (node.kind === 141 /* PropertyDeclaration */ || - node.kind === 143 /* MethodDeclaration */ || - node.kind === 145 /* GetAccessor */ || - node.kind === 146 /* SetAccessor */) { - // The `propertyKey` for a property or method decorator will be a - // string literal type if the member name is an identifier, number, or string; - // otherwise, if the member name is a computed property name it will - // be either string or symbol. - var element = node; - switch (element.name.kind) { - case 69 /* Identifier */: - case 8 /* NumericLiteral */: - case 9 /* StringLiteral */: - return getStringLiteralType(element.name); - case 136 /* ComputedPropertyName */: - var nameType = checkComputedPropertyName(element.name); - if (allConstituentTypesHaveKind(nameType, 16777216 /* ESSymbol */)) { - return nameType; - } - else { - return stringType; - } - default: - ts.Debug.fail("Unsupported property name."); - return unknownType; - } - } - ts.Debug.fail("Unsupported decorator target."); - return unknownType; - } - /** - * Returns the effective argument type for the third argument to a decorator. - * If 'node' is a parameter, the effective argument type is the number type. - * If 'node' is a method or accessor, the effective argument type is a - * `TypedPropertyDescriptor` instantiated with the type of the member. - * Class and property decorators do not have a third effective argument. - */ - function getEffectiveDecoratorThirdArgumentType(node) { - // The third argument to a decorator is either its `descriptor` for a method decorator - // or its `parameterIndex` for a paramter decorator - if (node.kind === 214 /* ClassDeclaration */) { - ts.Debug.fail("Class decorators should not have a third synthetic argument."); - return unknownType; - } - if (node.kind === 138 /* Parameter */) { - // The `parameterIndex` for a parameter decorator is always a number - return numberType; - } - if (node.kind === 141 /* PropertyDeclaration */) { - ts.Debug.fail("Property decorators should not have a third synthetic argument."); - return unknownType; - } - if (node.kind === 143 /* MethodDeclaration */ || - node.kind === 145 /* GetAccessor */ || - node.kind === 146 /* SetAccessor */) { - // The `descriptor` for a method decorator will be a `TypedPropertyDescriptor` - // for the type of the member. - var propertyType = getTypeOfNode(node); - return createTypedPropertyDescriptorType(propertyType); - } - ts.Debug.fail("Unsupported decorator target."); - return unknownType; - } - /** - * Returns the effective argument type for the provided argument to a decorator. - */ - function getEffectiveDecoratorArgumentType(node, argIndex) { - if (argIndex === 0) { - return getEffectiveDecoratorFirstArgumentType(node.parent); - } - else if (argIndex === 1) { - return getEffectiveDecoratorSecondArgumentType(node.parent); - } - else if (argIndex === 2) { - return getEffectiveDecoratorThirdArgumentType(node.parent); - } - ts.Debug.fail("Decorators should not have a fourth synthetic argument."); - return unknownType; - } - /** - * Gets the effective argument type for an argument in a call expression. - */ - function getEffectiveArgumentType(node, argIndex, arg) { - // 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 === 139 /* Decorator */) { - return getEffectiveDecoratorArgumentType(node, argIndex); - } - else if (argIndex === 0 && node.kind === 170 /* TaggedTemplateExpression */) { - return globalTemplateStringsArrayType; - } - // This is not a synthetic argument, so we return 'undefined' - // to signal that the caller needs to check the argument. - return undefined; - } - /** - * Gets the effective argument expression for an argument in a call expression. - */ - function getEffectiveArgument(node, args, argIndex) { - // For a decorator or the first argument of a tagged template expression we return undefined. - if (node.kind === 139 /* Decorator */ || - (argIndex === 0 && node.kind === 170 /* TaggedTemplateExpression */)) { - return undefined; - } - return args[argIndex]; - } - /** - * Gets the error node to use when reporting errors for an effective argument. - */ - function getEffectiveArgumentErrorNode(node, argIndex, arg) { - if (node.kind === 139 /* Decorator */) { - // For a decorator, we use the expression of the decorator for error reporting. - return node.expression; - } - else if (argIndex === 0 && node.kind === 170 /* TaggedTemplateExpression */) { - // For a the first argument of a tagged template expression, we use the template of the tag for error reporting. - return node.template; - } - else { - return arg; - } - } - function resolveCall(node, signatures, candidatesOutArray, headMessage) { - var isTaggedTemplate = node.kind === 170 /* TaggedTemplateExpression */; - var isDecorator = node.kind === 139 /* Decorator */; - var typeArguments; - if (!isTaggedTemplate && !isDecorator) { - typeArguments = node.typeArguments; - // We already perform checking on the type arguments on the class declaration itself. - if (node.expression.kind !== 95 /* SuperKeyword */) { - ts.forEach(typeArguments, checkSourceElement); - } - } - var candidates = candidatesOutArray || []; - // reorderCandidates fills up the candidates array directly - reorderCandidates(signatures, candidates); - if (!candidates.length) { - reportError(ts.Diagnostics.Supplied_parameters_do_not_match_any_signature_of_call_target); - return resolveErrorCall(node); - } - var args = getEffectiveCallArguments(node); - // The following applies to any value of 'excludeArgument[i]': - // - true: the argument at 'i' is susceptible to a one-time permanent contextual typing. - // - undefined: the argument at 'i' is *not* susceptible to permanent contextual typing. - // - false: the argument at 'i' *was* and *has been* permanently contextually typed. - // - // The idea is that we will perform type argument inference & assignability checking once - // without using the susceptible parameters that are functions, and once more for each of those - // parameters, contextually typing each as we go along. - // - // For a tagged template, then the first argument be 'undefined' if necessary - // because it represents a TemplateStringsArray. - // - // For a decorator, no arguments are susceptible to contextual typing due to the fact - // decorators are applied to a declaration by the emitter, and not to an expression. - var excludeArgument; - if (!isDecorator) { - // We do not need to call `getEffectiveArgumentCount` here as it only - // applies when calculating the number of arguments for a decorator. - for (var i = isTaggedTemplate ? 1 : 0; i < args.length; i++) { - if (isContextSensitive(args[i])) { - if (!excludeArgument) { - excludeArgument = new Array(args.length); - } - excludeArgument[i] = true; - } - } - } - // The following variables are captured and modified by calls to chooseOverload. - // If overload resolution or type argument inference fails, we want to report the - // best error possible. The best error is one which says that an argument was not - // assignable to a parameter. This implies that everything else about the overload - // was fine. So if there is any overload that is only incorrect because of an - // argument, we will report an error on that one. - // - // function foo(s: string) {} - // function foo(n: number) {} // Report argument error on this overload - // function foo() {} - // foo(true); - // - // If none of the overloads even made it that far, there are two possibilities. - // There was a problem with type arguments for some overload, in which case - // report an error on that. Or none of the overloads even had correct arity, - // in which case give an arity error. - // - // function foo(x: T, y: T) {} // Report type argument inference error - // function foo() {} - // foo(0, true); - // - var candidateForArgumentError; - var candidateForTypeArgumentError; - var resultOfFailedInference; - var result; - // 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 - // of those signatures becomes the return type of the function call. - // Otherwise, the return type of the first signature in the candidate list becomes the return - // type of the function call. - // - // Whether the call is an error is determined by assignability of the arguments. The subtype pass - // is just important for choosing the best signature. So in the case where there is only one - // signature, the subtype pass is useless. So skipping it is an optimization. - if (candidates.length > 1) { - result = chooseOverload(candidates, subtypeRelation); - } - if (!result) { - // Reinitialize these pointers for round two - candidateForArgumentError = undefined; - candidateForTypeArgumentError = undefined; - resultOfFailedInference = undefined; - result = chooseOverload(candidates, assignableRelation); - } - if (result) { - return result; - } - // No signatures were applicable. Now report errors based on the last applicable signature with - // no arguments excluded from assignability checks. - // If candidate is undefined, it means that no candidates had a suitable arity. In that case, - // skip the checkApplicableSignature check. - if (candidateForArgumentError) { - // excludeArgument is undefined, in this case also equivalent to [undefined, undefined, ...] - // The importance of excludeArgument is to prevent us from typing function expression parameters - // in arguments too early. If possible, we'd like to only type them once we know the correct - // overload. However, this matters for the case where the call is correct. When the call is - // an error, we don't need to exclude any arguments, although it would cause no harm to do so. - checkApplicableSignature(node, args, candidateForArgumentError, assignableRelation, /*excludeArgument*/ undefined, /*reportErrors*/ true); - } - else if (candidateForTypeArgumentError) { - if (!isTaggedTemplate && !isDecorator && typeArguments) { - checkTypeArguments(candidateForTypeArgumentError, node.typeArguments, [], /*reportErrors*/ true, headMessage); - } - else { - ts.Debug.assert(resultOfFailedInference.failedTypeParameterIndex >= 0); - var failedTypeParameter = candidateForTypeArgumentError.typeParameters[resultOfFailedInference.failedTypeParameterIndex]; - var inferenceCandidates = getInferenceCandidates(resultOfFailedInference, resultOfFailedInference.failedTypeParameterIndex); - var diagnosticChainHead = ts.chainDiagnosticMessages(/*details*/ undefined, // details will be provided by call to reportNoCommonSupertypeError - ts.Diagnostics.The_type_argument_for_type_parameter_0_cannot_be_inferred_from_the_usage_Consider_specifying_the_type_arguments_explicitly, typeToString(failedTypeParameter)); - if (headMessage) { - diagnosticChainHead = ts.chainDiagnosticMessages(diagnosticChainHead, headMessage); - } - reportNoCommonSupertypeError(inferenceCandidates, node.expression || node.tag, diagnosticChainHead); - } - } - else { - reportError(ts.Diagnostics.Supplied_parameters_do_not_match_any_signature_of_call_target); - } - // No signature was applicable. We have already reported the errors for the invalid signature. - // If this is a type resolution session, e.g. Language Service, try to get better information that anySignature. - // Pick the first candidate that matches the arity. This way we can get a contextual type for cases like: - // declare function f(a: { xa: number; xb: number; }); - // f({ | - if (!produceDiagnostics) { - for (var _i = 0; _i < candidates.length; _i++) { - var candidate = candidates[_i]; - if (hasCorrectArity(node, args, candidate)) { - if (candidate.typeParameters && typeArguments) { - candidate = getSignatureInstantiation(candidate, ts.map(typeArguments, getTypeFromTypeNode)); - } - return candidate; - } - } - } - return resolveErrorCall(node); - function reportError(message, arg0, arg1, arg2) { - var errorInfo; - errorInfo = ts.chainDiagnosticMessages(errorInfo, message, arg0, arg1, arg2); - if (headMessage) { - errorInfo = ts.chainDiagnosticMessages(errorInfo, headMessage); - } - diagnostics.add(ts.createDiagnosticForNodeFromMessageChain(node, errorInfo)); - } - function chooseOverload(candidates, relation) { - for (var _i = 0; _i < candidates.length; _i++) { - var originalCandidate = candidates[_i]; - if (!hasCorrectArity(node, args, originalCandidate)) { - continue; - } - var candidate = void 0; - var typeArgumentsAreValid = void 0; - var inferenceContext = originalCandidate.typeParameters - ? createInferenceContext(originalCandidate.typeParameters, /*inferUnionTypes*/ false) - : undefined; - while (true) { - candidate = originalCandidate; - if (candidate.typeParameters) { - var typeArgumentTypes = void 0; - if (typeArguments) { - typeArgumentTypes = new Array(candidate.typeParameters.length); - typeArgumentsAreValid = checkTypeArguments(candidate, typeArguments, typeArgumentTypes, /*reportErrors*/ false); - } - else { - inferTypeArguments(node, candidate, args, excludeArgument, inferenceContext); - typeArgumentsAreValid = inferenceContext.failedTypeParameterIndex === undefined; - typeArgumentTypes = inferenceContext.inferredTypes; - } - if (!typeArgumentsAreValid) { - break; - } - candidate = getSignatureInstantiation(candidate, typeArgumentTypes); - } - if (!checkApplicableSignature(node, args, candidate, relation, excludeArgument, /*reportErrors*/ false)) { - break; - } - var index = excludeArgument ? ts.indexOf(excludeArgument, true) : -1; - if (index < 0) { - return candidate; - } - excludeArgument[index] = false; - } - // A post-mortem of this iteration of the loop. The signature was not applicable, - // so we want to track it as a candidate for reporting an error. If the candidate - // had no type parameters, or had no issues related to type arguments, we can - // report an error based on the arguments. If there was an issue with type - // arguments, then we can only report an error based on the type arguments. - if (originalCandidate.typeParameters) { - var instantiatedCandidate = candidate; - if (typeArgumentsAreValid) { - candidateForArgumentError = instantiatedCandidate; - } - else { - candidateForTypeArgumentError = originalCandidate; - if (!typeArguments) { - resultOfFailedInference = inferenceContext; - } - } - } - else { - ts.Debug.assert(originalCandidate === candidate); - candidateForArgumentError = originalCandidate; - } - } - return undefined; - } - } - function resolveCallExpression(node, candidatesOutArray) { - if (node.expression.kind === 95 /* SuperKeyword */) { - var superType = checkSuperExpression(node.expression); - if (superType !== unknownType) { - // In super call, the candidate signatures are the matching arity signatures of the base constructor function instantiated - // with the type arguments specified in the extends clause. - var baseTypeNode = ts.getClassExtendsHeritageClauseElement(ts.getContainingClass(node)); - var baseConstructors = getInstantiatedConstructorsForTypeArguments(superType, baseTypeNode.typeArguments); - return resolveCall(node, baseConstructors, candidatesOutArray); - } - return resolveUntypedCall(node); - } - var funcType = checkExpression(node.expression); - var apparentType = getApparentType(funcType); - if (apparentType === unknownType) { - // Another error has already been reported - return resolveErrorCall(node); - } - // Technically, this signatures list may be incomplete. We are taking the apparent type, - // but we are not including call signatures that may have been added to the Object or - // Function interface, since they have none by default. This is a bit of a leap of faith - // that the user will not add any. - var callSignatures = getSignaturesOfType(apparentType, 0 /* Call */); - var constructSignatures = getSignaturesOfType(apparentType, 1 /* Construct */); - // TS 1.0 spec: 4.12 - // If FuncExpr is of type Any, or of an object type that has no call or construct signatures - // but is a subtype of the Function interface, the call is an untyped function call. In an - // untyped function call no TypeArgs are permitted, Args can be any argument list, no contextual - // types are provided for the argument expressions, and the result is always of type Any. - // We exclude union types because we may have a union of function types that happen to have - // no common signatures. - if (isTypeAny(funcType) || (!callSignatures.length && !constructSignatures.length && !(funcType.flags & 16384 /* Union */) && isTypeAssignableTo(funcType, globalFunctionType))) { - // The unknownType indicates that an error already occured (and was reported). No - // need to report another error in this case. - if (funcType !== unknownType && node.typeArguments) { - error(node, ts.Diagnostics.Untyped_function_calls_may_not_accept_type_arguments); - } - return resolveUntypedCall(node); - } - // If FuncExpr's apparent type(section 3.8.1) is a function type, the call is a typed function call. - // TypeScript employs overload resolution in typed function calls in order to support functions - // with multiple call signatures. - if (!callSignatures.length) { - if (constructSignatures.length) { - error(node, ts.Diagnostics.Value_of_type_0_is_not_callable_Did_you_mean_to_include_new, typeToString(funcType)); - } - else { - error(node, ts.Diagnostics.Cannot_invoke_an_expression_whose_type_lacks_a_call_signature); - } - return resolveErrorCall(node); - } - return resolveCall(node, callSignatures, candidatesOutArray); - } - function resolveNewExpression(node, candidatesOutArray) { - if (node.arguments && languageVersion < 1 /* ES5 */) { - var spreadIndex = getSpreadArgumentIndex(node.arguments); - if (spreadIndex >= 0) { - error(node.arguments[spreadIndex], ts.Diagnostics.Spread_operator_in_new_expressions_is_only_available_when_targeting_ECMAScript_5_and_higher); - } - } - var expressionType = checkExpression(node.expression); - // If expressionType's apparent type(section 3.8.1) is an object type with one or - // more construct signatures, the expression is processed in the same manner as a - // function call, but using the construct signatures as the initial set of candidate - // signatures for overload resolution. The result type of the function call becomes - // the result type of the operation. - expressionType = getApparentType(expressionType); - if (expressionType === unknownType) { - // Another error has already been reported - return resolveErrorCall(node); - } - // If the expression is a class of abstract type, then it cannot be instantiated. - // Note, only class declarations can be declared abstract. - // In the case of a merged class-module or class-interface declaration, - // only the class declaration node will have the Abstract flag set. - var valueDecl = expressionType.symbol && getClassLikeDeclarationOfSymbol(expressionType.symbol); - if (valueDecl && valueDecl.flags & 256 /* Abstract */) { - error(node, ts.Diagnostics.Cannot_create_an_instance_of_the_abstract_class_0, ts.declarationNameToString(valueDecl.name)); - return resolveErrorCall(node); - } - // TS 1.0 spec: 4.11 - // If expressionType is of type Any, Args can be any argument - // list and the result of the operation is of type Any. - if (isTypeAny(expressionType)) { - if (node.typeArguments) { - error(node, ts.Diagnostics.Untyped_function_calls_may_not_accept_type_arguments); - } - return resolveUntypedCall(node); - } - // Technically, this signatures list may be incomplete. We are taking the apparent type, - // but we are not including construct signatures that may have been added to the Object or - // Function interface, since they have none by default. This is a bit of a leap of faith - // that the user will not add any. - var constructSignatures = getSignaturesOfType(expressionType, 1 /* Construct */); - if (constructSignatures.length) { - return resolveCall(node, constructSignatures, candidatesOutArray); - } - // If expressionType's apparent type is an object type with no construct signatures but - // one or more call signatures, the expression is processed as a function call. A compile-time - // error occurs if the result of the function call is not Void. The type of the result of the - // operation is Any. - var callSignatures = getSignaturesOfType(expressionType, 0 /* Call */); - if (callSignatures.length) { - var signature = resolveCall(node, callSignatures, candidatesOutArray); - if (getReturnTypeOfSignature(signature) !== voidType) { - error(node, ts.Diagnostics.Only_a_void_function_can_be_called_with_the_new_keyword); - } - return signature; - } - error(node, ts.Diagnostics.Cannot_use_new_with_an_expression_whose_type_lacks_a_call_or_construct_signature); - return resolveErrorCall(node); - } - function resolveTaggedTemplateExpression(node, candidatesOutArray) { - var tagType = checkExpression(node.tag); - var apparentType = getApparentType(tagType); - if (apparentType === unknownType) { - // Another error has already been reported - return resolveErrorCall(node); - } - var callSignatures = getSignaturesOfType(apparentType, 0 /* Call */); - if (isTypeAny(tagType) || (!callSignatures.length && !(tagType.flags & 16384 /* Union */) && isTypeAssignableTo(tagType, globalFunctionType))) { - return resolveUntypedCall(node); - } - if (!callSignatures.length) { - error(node, ts.Diagnostics.Cannot_invoke_an_expression_whose_type_lacks_a_call_signature); - return resolveErrorCall(node); - } - return resolveCall(node, callSignatures, candidatesOutArray); - } - /** - * Gets the localized diagnostic head message to use for errors when resolving a decorator as a call expression. - */ - function getDiagnosticHeadMessageForDecoratorResolution(node) { - switch (node.parent.kind) { - case 214 /* ClassDeclaration */: - case 186 /* ClassExpression */: - return ts.Diagnostics.Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression; - case 138 /* Parameter */: - return ts.Diagnostics.Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression; - case 141 /* PropertyDeclaration */: - return ts.Diagnostics.Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression; - case 143 /* MethodDeclaration */: - case 145 /* GetAccessor */: - case 146 /* SetAccessor */: - return ts.Diagnostics.Unable_to_resolve_signature_of_method_decorator_when_called_as_an_expression; - } - } - /** - * Resolves a decorator as if it were a call expression. - */ - function resolveDecorator(node, candidatesOutArray) { - var funcType = checkExpression(node.expression); - var apparentType = getApparentType(funcType); - if (apparentType === unknownType) { - return resolveErrorCall(node); - } - var callSignatures = getSignaturesOfType(apparentType, 0 /* Call */); - if (funcType === anyType || (!callSignatures.length && !(funcType.flags & 16384 /* Union */) && isTypeAssignableTo(funcType, globalFunctionType))) { - return resolveUntypedCall(node); - } - var headMessage = getDiagnosticHeadMessageForDecoratorResolution(node); - if (!callSignatures.length) { - var errorInfo; - errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.Cannot_invoke_an_expression_whose_type_lacks_a_call_signature); - errorInfo = ts.chainDiagnosticMessages(errorInfo, headMessage); - diagnostics.add(ts.createDiagnosticForNodeFromMessageChain(node, errorInfo)); - return resolveErrorCall(node); - } - return resolveCall(node, callSignatures, candidatesOutArray, headMessage); - } - // candidatesOutArray is passed by signature help in the language service, and collectCandidates - // must fill it up with the appropriate candidate signatures - function getResolvedSignature(node, candidatesOutArray) { - var links = getNodeLinks(node); - // If getResolvedSignature has already been called, we will have cached the resolvedSignature. - // However, it is possible that either candidatesOutArray was not passed in the first time, - // or that a different candidatesOutArray was passed in. Therefore, we need to redo the work - // to correctly fill the candidatesOutArray. - if (!links.resolvedSignature || candidatesOutArray) { - links.resolvedSignature = anySignature; - if (node.kind === 168 /* CallExpression */) { - links.resolvedSignature = resolveCallExpression(node, candidatesOutArray); - } - else if (node.kind === 169 /* NewExpression */) { - links.resolvedSignature = resolveNewExpression(node, candidatesOutArray); - } - else if (node.kind === 170 /* TaggedTemplateExpression */) { - links.resolvedSignature = resolveTaggedTemplateExpression(node, candidatesOutArray); - } - else if (node.kind === 139 /* Decorator */) { - links.resolvedSignature = resolveDecorator(node, candidatesOutArray); - } - else { - ts.Debug.fail("Branch in 'getResolvedSignature' should be unreachable."); - } - } - return links.resolvedSignature; - } - /** - * Syntactically and semantically checks a call or new expression. - * @param node The call/new expression to be checked. - * @returns On success, the expression's signature's return type. On failure, anyType. - */ - function checkCallExpression(node) { - // 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 */) { - return voidType; - } - if (node.kind === 169 /* NewExpression */) { - var declaration = signature.declaration; - if (declaration && - declaration.kind !== 144 /* Constructor */ && - declaration.kind !== 148 /* ConstructSignature */ && - declaration.kind !== 153 /* ConstructorType */) { - // When resolved signature is a call signature (and not a construct signature) the result type is any - if (compilerOptions.noImplicitAny) { - error(node, ts.Diagnostics.new_expression_whose_target_lacks_a_construct_signature_implicitly_has_an_any_type); - } - return anyType; - } - } - return getReturnTypeOfSignature(signature); - } - function checkTaggedTemplateExpression(node) { - return getReturnTypeOfSignature(getResolvedSignature(node)); - } - function checkAssertion(node) { - var exprType = getRegularTypeOfObjectLiteral(checkExpression(node.expression)); - var targetType = getTypeFromTypeNode(node.type); - if (produceDiagnostics && targetType !== unknownType) { - var widenedType = getWidenedType(exprType); - if (!(isTypeAssignableTo(targetType, widenedType))) { - checkTypeAssignableTo(exprType, targetType, node, ts.Diagnostics.Neither_type_0_nor_type_1_is_assignable_to_the_other); - } - } - return targetType; - } - function getTypeAtPosition(signature, pos) { - return signature.hasRestParameter ? - pos < signature.parameters.length - 1 ? getTypeOfSymbol(signature.parameters[pos]) : getRestTypeOfSignature(signature) : - pos < signature.parameters.length ? getTypeOfSymbol(signature.parameters[pos]) : anyType; - } - function assignContextualParameterTypes(signature, context, mapper) { - var len = signature.parameters.length - (signature.hasRestParameter ? 1 : 0); - for (var i = 0; i < len; i++) { - var parameter = signature.parameters[i]; - 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); - } - } - // When contextual typing assigns a type to a parameter that contains a binding pattern, we also need to push - // the destructured type into the contained binding elements. - function assignBindingElementTypes(node) { - if (ts.isBindingPattern(node.name)) { - for (var _i = 0, _a = node.name.elements; _i < _a.length; _i++) { - var element = _a[_i]; - if (element.kind !== 187 /* OmittedExpression */) { - getSymbolLinks(getSymbolOfNode(element)).type = getTypeForBindingElement(element); - assignBindingElementTypes(element); - } - } - } - } - function assignTypeToParameterAndFixTypeParameters(parameter, contextualType, mapper) { - var links = getSymbolLinks(parameter); - if (!links.type) { - links.type = instantiateType(contextualType, mapper); - assignBindingElementTypes(parameter.valueDeclaration); - } - else if (isInferentialContext(mapper)) { - // Even if the parameter already has a type, it might be because it was given a type while - // processing the function as an argument to a prior signature during overload resolution. - // If this was the case, it may have caused some type parameters to be fixed. So here, - // we need to ensure that type parameters at the same positions get fixed again. This is - // done by calling instantiateType to attach the mapper to the contextualType, and then - // calling inferTypes to force a walk of contextualType so that all the correct fixing - // happens. The choice to pass in links.type may seem kind of arbitrary, but it serves - // to make sure that all the correct positions in contextualType are reached by the walk. - // Here is an example: - // - // interface Base { - // baseProp; - // } - // interface Derived extends Base { - // toBase(): Base; - // } - // - // var derived: Derived; - // - // declare function foo(x: T, func: (p: T) => T): T; - // declare function foo(x: T, func: (p: T) => T): T; - // - // var result = foo(derived, d => d.toBase()); - // - // We are typing d while checking the second overload. But we've already given d - // a type (Derived) from the first overload. However, we still want to fix the - // T in the second overload so that we do not infer Base as a candidate for T - // (inferring Base would make type argument inference inconsistent between the two - // overloads). - inferTypes(mapper.context, links.type, instantiateType(contextualType, mapper)); - } - } - function createPromiseType(promisedType) { - // creates a `Promise` type where `T` is the promisedType argument - var globalPromiseType = getGlobalPromiseType(); - if (globalPromiseType !== emptyGenericType) { - // if the promised type is itself a promise, get the underlying type; otherwise, fallback to the promised type - promisedType = getAwaitedType(promisedType); - return createTypeReference(globalPromiseType, [promisedType]); - } - return emptyObjectType; - } - function getReturnTypeFromBody(func, contextualMapper) { - var contextualSignature = getContextualSignatureForFunctionLikeDeclaration(func); - if (!func.body) { - return unknownType; - } - var isAsync = ts.isAsyncFunctionLike(func); - var type; - if (func.body.kind !== 192 /* Block */) { - type = checkExpressionCached(func.body, contextualMapper); - if (isAsync) { - // From within an async function you can return either a non-promise value or a promise. Any - // Promise/A+ compatible implementation will always assimilate any foreign promise, so the - // return type of the body should be unwrapped to its awaited type, which we will wrap in - // the native Promise type later in this function. - type = checkAwaitedType(type, func, ts.Diagnostics.Return_expression_in_async_function_does_not_have_a_valid_callable_then_member); - } - } - else { - var types; - var funcIsGenerator = !!func.asteriskToken; - if (funcIsGenerator) { - types = checkAndAggregateYieldOperandTypes(func.body, contextualMapper); - if (types.length === 0) { - var iterableIteratorAny = createIterableIteratorType(anyType); - if (compilerOptions.noImplicitAny) { - error(func.asteriskToken, ts.Diagnostics.Generator_implicitly_has_type_0_because_it_does_not_yield_any_values_Consider_supplying_a_return_type, typeToString(iterableIteratorAny)); - } - return iterableIteratorAny; - } - } - else { - types = checkAndAggregateReturnExpressionTypes(func.body, contextualMapper, isAsync); - if (types.length === 0) { - if (isAsync) { - // For an async function, the return type will not be void, but rather a Promise for void. - var promiseType = createPromiseType(voidType); - if (promiseType === emptyObjectType) { - error(func, ts.Diagnostics.An_async_function_or_method_must_have_a_valid_awaitable_return_type); - return unknownType; - } - return promiseType; - } - else { - return voidType; - } - } - } - // When yield/return statements are contextually typed we allow the return type to be a union type. - // Otherwise we require the yield/return expressions to have a best common supertype. - type = contextualSignature ? getUnionType(types) : getCommonSupertype(types); - if (!type) { - if (funcIsGenerator) { - error(func, ts.Diagnostics.No_best_common_type_exists_among_yield_expressions); - return createIterableIteratorType(unknownType); - } - else { - error(func, ts.Diagnostics.No_best_common_type_exists_among_return_expressions); - return unknownType; - } - } - if (funcIsGenerator) { - type = createIterableIteratorType(type); - } - } - if (!contextualSignature) { - reportErrorsFromWidening(func, type); - } - var widenedType = getWidenedType(type); - if (isAsync) { - // From within an async function you can return either a non-promise value or a promise. Any - // Promise/A+ compatible implementation will always assimilate any foreign promise, so the - // return type of the body is awaited type of the body, wrapped in a native Promise type. - var promiseType = createPromiseType(widenedType); - if (promiseType === emptyObjectType) { - error(func, ts.Diagnostics.An_async_function_or_method_must_have_a_valid_awaitable_return_type); - return unknownType; - } - return promiseType; - } - else { - return widenedType; - } - } - function checkAndAggregateYieldOperandTypes(body, contextualMapper) { - var aggregatedTypes = []; - ts.forEachYieldExpression(body, function (yieldExpression) { - var expr = yieldExpression.expression; - if (expr) { - var type = checkExpressionCached(expr, contextualMapper); - if (yieldExpression.asteriskToken) { - // A yield* expression effectively yields everything that its operand yields - type = checkElementTypeOfIterable(type, yieldExpression.expression); - } - if (!ts.contains(aggregatedTypes, type)) { - aggregatedTypes.push(type); - } - } - }); - return aggregatedTypes; - } - function checkAndAggregateReturnExpressionTypes(body, contextualMapper, isAsync) { - var aggregatedTypes = []; - ts.forEachReturnStatement(body, function (returnStatement) { - var expr = returnStatement.expression; - if (expr) { - var type = checkExpressionCached(expr, contextualMapper); - if (isAsync) { - // From within an async function you can return either a non-promise value or a promise. Any - // Promise/A+ compatible implementation will always assimilate any foreign promise, so the - // return type of the body should be unwrapped to its awaited type, which should be wrapped in - // the native Promise type by the caller. - type = checkAwaitedType(type, body.parent, ts.Diagnostics.Return_expression_in_async_function_does_not_have_a_valid_callable_then_member); - } - if (!ts.contains(aggregatedTypes, type)) { - aggregatedTypes.push(type); - } - } - }); - return aggregatedTypes; - } - function bodyContainsAReturnStatement(funcBody) { - return ts.forEachReturnStatement(funcBody, function (returnStatement) { - return true; - }); - } - function bodyContainsSingleThrowStatement(body) { - return (body.statements.length === 1) && (body.statements[0].kind === 208 /* ThrowStatement */); - } - // TypeScript Specification 1.0 (6.3) - July 2014 - // An explicitly typed function whose return type isn't the Void or the Any type - // must have at least one return statement somewhere in its body. - // An exception to this rule is if the function implementation consists of a single 'throw' statement. - function checkIfNonVoidFunctionHasReturnExpressionsOrSingleThrowStatment(func, returnType) { - if (!produceDiagnostics) { - return; - } - // Functions that return 'void' or 'any' don't need any return expressions. - if (returnType === voidType || isTypeAny(returnType)) { - return; - } - // If all we have is a function signature, or an arrow function with an expression body, then there is nothing to check. - if (ts.nodeIsMissing(func.body) || func.body.kind !== 192 /* Block */) { - return; - } - var bodyBlock = func.body; - // Ensure the body has at least one return expression. - if (bodyContainsAReturnStatement(bodyBlock)) { - return; - } - // If there are no return expressions, then we need to check if - // the function body consists solely of a throw statement; - // this is to make an exception for unimplemented functions. - if (bodyContainsSingleThrowStatement(bodyBlock)) { - return; - } - // This function does not conform to the specification. - error(func.type, ts.Diagnostics.A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value_or_consist_of_a_single_throw_statement); - } - function checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper) { - ts.Debug.assert(node.kind !== 143 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); - // Grammar checking - var hasGrammarError = checkGrammarFunctionLikeDeclaration(node); - if (!hasGrammarError && node.kind === 173 /* FunctionExpression */) { - checkGrammarForGenerator(node); - } - // The identityMapper object is used to indicate that function expressions are wildcards - if (contextualMapper === identityMapper && isContextSensitive(node)) { - return anyFunctionType; - } - var isAsync = ts.isAsyncFunctionLike(node); - if (isAsync) { - emitAwaiter = true; - } - var links = getNodeLinks(node); - var type = getTypeOfSymbol(node.symbol); - var contextSensitive = isContextSensitive(node); - var mightFixTypeParameters = contextSensitive && isInferentialContext(contextualMapper); - // Check if function expression is contextually typed and assign parameter types if so. - // See the comment in assignTypeToParameterAndFixTypeParameters to understand why we need to - // check mightFixTypeParameters. - if (mightFixTypeParameters || !(links.flags & 1024 /* ContextChecked */)) { - var contextualSignature = getContextualSignature(node); - // If a type check is started at a function expression that is an argument of a function call, obtaining the - // contextual type may recursively get back to here during overload resolution of the call. If so, we will have - // already assigned contextual types. - var contextChecked = !!(links.flags & 1024 /* ContextChecked */); - if (mightFixTypeParameters || !contextChecked) { - links.flags |= 1024 /* ContextChecked */; - if (contextualSignature) { - var signature = getSignaturesOfType(type, 0 /* Call */)[0]; - if (contextSensitive) { - assignContextualParameterTypes(signature, contextualSignature, contextualMapper || identityMapper); - } - if (mightFixTypeParameters || !node.type && !signature.resolvedReturnType) { - var returnType = getReturnTypeFromBody(node, contextualMapper); - if (!signature.resolvedReturnType) { - signature.resolvedReturnType = returnType; - } - } - } - if (!contextChecked) { - checkSignatureDeclaration(node); - } - } - } - if (produceDiagnostics && node.kind !== 143 /* MethodDeclaration */ && node.kind !== 142 /* MethodSignature */) { - checkCollisionWithCapturedSuperVariable(node, node.name); - checkCollisionWithCapturedThisVariable(node, node.name); - } - return type; - } - function checkFunctionExpressionOrObjectLiteralMethodBody(node) { - ts.Debug.assert(node.kind !== 143 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); - var isAsync = ts.isAsyncFunctionLike(node); - if (isAsync) { - emitAwaiter = true; - } - var returnType = node.type && getTypeFromTypeNode(node.type); - var promisedType; - if (returnType && isAsync) { - promisedType = checkAsyncFunctionReturnType(node); - } - if (returnType && !node.asteriskToken) { - checkIfNonVoidFunctionHasReturnExpressionsOrSingleThrowStatment(node, isAsync ? promisedType : returnType); - } - if (node.body) { - if (!node.type) { - // There are some checks that are only performed in getReturnTypeFromBody, that may produce errors - // we need. An example is the noImplicitAny errors resulting from widening the return expression - // of a function. Because checking of function expression bodies is deferred, there was never an - // appropriate time to do this during the main walk of the file (see the comment at the top of - // checkFunctionExpressionBodies). So it must be done now. - getReturnTypeOfSignature(getSignatureFromDeclaration(node)); - } - if (node.body.kind === 192 /* Block */) { - checkSourceElement(node.body); - } - else { - // From within an async function you can return either a non-promise value or a promise. Any - // Promise/A+ compatible implementation will always assimilate any foreign promise, so we - // should not be checking assignability of a promise to the return type. Instead, we need to - // check assignability of the awaited type of the expression body against the promised type of - // its return type annotation. - var exprType = checkExpression(node.body); - if (returnType) { - if (isAsync) { - var awaitedType = checkAwaitedType(exprType, node.body, ts.Diagnostics.Expression_body_for_async_arrow_function_does_not_have_a_valid_callable_then_member); - checkTypeAssignableTo(awaitedType, promisedType, node.body); - } - else { - checkTypeAssignableTo(exprType, returnType, node.body); - } - } - checkFunctionAndClassExpressionBodies(node.body); - } - } - } - function checkArithmeticOperandType(operand, type, diagnostic) { - if (!isTypeAnyOrAllConstituentTypesHaveKind(type, 132 /* NumberLike */)) { - error(operand, diagnostic); - return false; - } - return true; - } - function checkReferenceExpression(n, invalidReferenceMessage, constantVariableMessage) { - function findSymbol(n) { - var symbol = getNodeLinks(n).resolvedSymbol; - // Because we got the symbol from the resolvedSymbol property, it might be of kind - // SymbolFlags.ExportValue. In this case it is necessary to get the actual export - // symbol, which will have the correct flags set on it. - return symbol && getExportSymbolOfValueSymbolIfExported(symbol); - } - function isReferenceOrErrorExpression(n) { - // TypeScript 1.0 spec (April 2014): - // Expressions are classified as values or references. - // References are the subset of expressions that are permitted as the target of an assignment. - // Specifically, references are combinations of identifiers(section 4.3), parentheses(section 4.7), - // and property accesses(section 4.10). - // All other expression constructs described in this chapter are classified as values. - switch (n.kind) { - case 69 /* Identifier */: { - var symbol = findSymbol(n); - // TypeScript 1.0 spec (April 2014): 4.3 - // An identifier expression that references a variable or parameter is classified as a reference. - // An identifier expression that references any other kind of entity is classified as a value(and therefore cannot be the target of an assignment). - return !symbol || symbol === unknownSymbol || symbol === argumentsSymbol || (symbol.flags & 3 /* Variable */) !== 0; - } - case 166 /* PropertyAccessExpression */: { - var symbol = findSymbol(n); - // TypeScript 1.0 spec (April 2014): 4.10 - // A property access expression is always classified as a reference. - // NOTE (not in spec): assignment to enum members should not be allowed - return !symbol || symbol === unknownSymbol || (symbol.flags & ~8 /* EnumMember */) !== 0; - } - case 167 /* ElementAccessExpression */: - // old compiler doesn't check indexed access - return true; - case 172 /* ParenthesizedExpression */: - return isReferenceOrErrorExpression(n.expression); - default: - return false; - } - } - function isConstVariableReference(n) { - switch (n.kind) { - case 69 /* Identifier */: - case 166 /* PropertyAccessExpression */: { - var symbol = findSymbol(n); - return symbol && (symbol.flags & 3 /* Variable */) !== 0 && (getDeclarationFlagsFromSymbol(symbol) & 32768 /* Const */) !== 0; - } - case 167 /* ElementAccessExpression */: { - var index = n.argumentExpression; - var symbol = findSymbol(n.expression); - if (symbol && index && index.kind === 9 /* StringLiteral */) { - var name_12 = index.text; - var prop = getPropertyOfType(getTypeOfSymbol(symbol), name_12); - return prop && (prop.flags & 3 /* Variable */) !== 0 && (getDeclarationFlagsFromSymbol(prop) & 32768 /* Const */) !== 0; - } - return false; - } - case 172 /* ParenthesizedExpression */: - return isConstVariableReference(n.expression); - default: - return false; - } - } - if (!isReferenceOrErrorExpression(n)) { - error(n, invalidReferenceMessage); - return false; - } - if (isConstVariableReference(n)) { - error(n, constantVariableMessage); - return false; - } - return true; - } - function checkDeleteExpression(node) { - checkExpression(node.expression); - return booleanType; - } - function checkTypeOfExpression(node) { - checkExpression(node.expression); - return stringType; - } - function checkVoidExpression(node) { - checkExpression(node.expression); - return undefinedType; - } - function checkAwaitExpression(node) { - // Grammar checking - if (produceDiagnostics) { - if (!(node.parserContextFlags & 8 /* Await */)) { - grammarErrorOnFirstToken(node, ts.Diagnostics.await_expression_is_only_allowed_within_an_async_function); - } - if (isInParameterInitializerBeforeContainingFunction(node)) { - error(node, ts.Diagnostics.await_expressions_cannot_be_used_in_a_parameter_initializer); - } - } - var operandType = checkExpression(node.expression); - return checkAwaitedType(operandType, node); - } - function checkPrefixUnaryExpression(node) { - var operandType = checkExpression(node.operand); - switch (node.operator) { - case 35 /* PlusToken */: - case 36 /* MinusToken */: - case 50 /* TildeToken */: - if (someConstituentTypeHasKind(operandType, 16777216 /* ESSymbol */)) { - error(node.operand, ts.Diagnostics.The_0_operator_cannot_be_applied_to_type_symbol, ts.tokenToString(node.operator)); - } - return numberType; - case 49 /* ExclamationToken */: - return booleanType; - case 41 /* PlusPlusToken */: - case 42 /* MinusMinusToken */: - var ok = checkArithmeticOperandType(node.operand, operandType, ts.Diagnostics.An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type); - if (ok) { - // run check only if former checks succeeded to avoid reporting cascading errors - 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); - } - return numberType; - } - return unknownType; - } - function checkPostfixUnaryExpression(node) { - var operandType = checkExpression(node.operand); - var ok = checkArithmeticOperandType(node.operand, operandType, ts.Diagnostics.An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type); - if (ok) { - // run check only if former checks succeeded to avoid reporting cascading errors - 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); - } - return numberType; - } - // Just like isTypeOfKind below, except that it returns true if *any* constituent - // has this kind. - function someConstituentTypeHasKind(type, kind) { - if (type.flags & kind) { - return true; - } - if (type.flags & 49152 /* UnionOrIntersection */) { - var types = type.types; - for (var _i = 0; _i < types.length; _i++) { - var current = types[_i]; - if (current.flags & kind) { - return true; - } - } - return false; - } - return false; - } - // Return true if type has the given flags, or is a union or intersection type composed of types that all have those flags. - function allConstituentTypesHaveKind(type, kind) { - if (type.flags & kind) { - return true; - } - if (type.flags & 49152 /* UnionOrIntersection */) { - var types = type.types; - for (var _i = 0; _i < types.length; _i++) { - var current = types[_i]; - if (!(current.flags & kind)) { - return false; - } - } - return true; - } - return false; - } - function isConstEnumObjectType(type) { - return type.flags & (80896 /* ObjectType */ | 65536 /* Anonymous */) && type.symbol && isConstEnumSymbol(type.symbol); - } - function isConstEnumSymbol(symbol) { - return (symbol.flags & 128 /* ConstEnum */) !== 0; - } - function checkInstanceOfExpression(left, right, leftType, rightType) { - // TypeScript 1.0 spec (April 2014): 4.15.4 - // The instanceof operator requires the left operand to be of type Any, an object type, or a type parameter type, - // and the right operand to be of type Any or a subtype of the 'Function' interface type. - // The result is always of the Boolean primitive type. - // NOTE: do not raise error if leftType is unknown as related error was already reported - if (allConstituentTypesHaveKind(leftType, 16777726 /* Primitive */)) { - error(left, ts.Diagnostics.The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_parameter); - } - // NOTE: do not raise error if right is unknown as related error was already reported - if (!(isTypeAny(rightType) || isTypeSubtypeOf(rightType, globalFunctionType))) { - error(right, ts.Diagnostics.The_right_hand_side_of_an_instanceof_expression_must_be_of_type_any_or_of_a_type_assignable_to_the_Function_interface_type); - } - return booleanType; - } - function checkInExpression(left, right, leftType, rightType) { - // TypeScript 1.0 spec (April 2014): 4.15.5 - // The in operator requires the left operand to be of type Any, the String primitive type, or the Number primitive type, - // and the right operand to be of type Any, an object type, or a type parameter type. - // The result is always of the Boolean primitive type. - if (!isTypeAnyOrAllConstituentTypesHaveKind(leftType, 258 /* StringLike */ | 132 /* NumberLike */ | 16777216 /* ESSymbol */)) { - error(left, ts.Diagnostics.The_left_hand_side_of_an_in_expression_must_be_of_type_any_string_number_or_symbol); - } - if (!isTypeAnyOrAllConstituentTypesHaveKind(rightType, 80896 /* ObjectType */ | 512 /* TypeParameter */)) { - error(right, ts.Diagnostics.The_right_hand_side_of_an_in_expression_must_be_of_type_any_an_object_type_or_a_type_parameter); - } - return booleanType; - } - function checkObjectLiteralAssignment(node, sourceType, contextualMapper) { - var properties = node.properties; - for (var _i = 0; _i < properties.length; _i++) { - var p = properties[_i]; - if (p.kind === 245 /* PropertyAssignment */ || p.kind === 246 /* ShorthandPropertyAssignment */) { - // TODO(andersh): Computed property support - var name_13 = p.name; - var type = isTypeAny(sourceType) - ? sourceType - : getTypeOfPropertyOfType(sourceType, name_13.text) || - isNumericLiteralName(name_13.text) && getIndexTypeOfType(sourceType, 1 /* Number */) || - getIndexTypeOfType(sourceType, 0 /* String */); - if (type) { - if (p.kind === 246 /* ShorthandPropertyAssignment */) { - checkDestructuringAssignment(p, type); - } - else { - checkDestructuringAssignment(p.initializer || name_13, type); - } - } - else { - error(name_13, ts.Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(sourceType), ts.declarationNameToString(name_13)); - } - } - else { - error(p, ts.Diagnostics.Property_assignment_expected); - } - } - return sourceType; - } - function checkArrayLiteralAssignment(node, sourceType, contextualMapper) { - // This elementType will be used if the specific property corresponding to this index is not - // present (aka the tuple element property). This call also checks that the parentType is in - // fact an iterable or array (depending on target language). - var elementType = checkIteratedTypeOrElementType(sourceType, node, /*allowStringInput*/ false) || unknownType; - var elements = node.elements; - for (var i = 0; i < elements.length; i++) { - var e = elements[i]; - if (e.kind !== 187 /* OmittedExpression */) { - if (e.kind !== 185 /* SpreadElementExpression */) { - var propName = "" + i; - var type = isTypeAny(sourceType) - ? sourceType - : isTupleLikeType(sourceType) - ? getTypeOfPropertyOfType(sourceType, propName) - : elementType; - if (type) { - checkDestructuringAssignment(e, type, contextualMapper); - } - else { - if (isTupleType(sourceType)) { - error(e, ts.Diagnostics.Tuple_type_0_with_length_1_cannot_be_assigned_to_tuple_with_length_2, typeToString(sourceType), sourceType.elementTypes.length, elements.length); - } - else { - error(e, ts.Diagnostics.Type_0_has_no_property_1, typeToString(sourceType), propName); - } - } - } - else { - if (i < elements.length - 1) { - error(e, ts.Diagnostics.A_rest_element_must_be_last_in_an_array_destructuring_pattern); - } - else { - var restExpression = e.expression; - if (restExpression.kind === 181 /* BinaryExpression */ && restExpression.operatorToken.kind === 56 /* EqualsToken */) { - error(restExpression.operatorToken, ts.Diagnostics.A_rest_element_cannot_have_an_initializer); - } - else { - checkDestructuringAssignment(restExpression, createArrayType(elementType), contextualMapper); - } - } - } - } - } - return sourceType; - } - function checkDestructuringAssignment(exprOrAssignment, sourceType, contextualMapper) { - var target; - if (exprOrAssignment.kind === 246 /* ShorthandPropertyAssignment */) { - var prop = exprOrAssignment; - if (prop.objectAssignmentInitializer) { - checkBinaryLikeExpression(prop.name, prop.equalsToken, prop.objectAssignmentInitializer, contextualMapper); - } - target = exprOrAssignment.name; - } - else { - target = exprOrAssignment; - } - if (target.kind === 181 /* BinaryExpression */ && target.operatorToken.kind === 56 /* EqualsToken */) { - checkBinaryExpression(target, contextualMapper); - target = target.left; - } - if (target.kind === 165 /* ObjectLiteralExpression */) { - return checkObjectLiteralAssignment(target, sourceType, contextualMapper); - } - if (target.kind === 164 /* ArrayLiteralExpression */) { - return checkArrayLiteralAssignment(target, sourceType, contextualMapper); - } - return checkReferenceAssignment(target, sourceType, contextualMapper); - } - function checkReferenceAssignment(target, sourceType, contextualMapper) { - var targetType = checkExpression(target, contextualMapper); - if (checkReferenceExpression(target, ts.Diagnostics.Invalid_left_hand_side_of_assignment_expression, ts.Diagnostics.Left_hand_side_of_assignment_expression_cannot_be_a_constant)) { - checkTypeAssignableTo(sourceType, targetType, target, /*headMessage*/ undefined); - } - return sourceType; - } - function checkBinaryExpression(node, contextualMapper) { - return checkBinaryLikeExpression(node.left, node.operatorToken, node.right, contextualMapper, node); - } - function checkBinaryLikeExpression(left, operatorToken, right, contextualMapper, errorNode) { - var operator = operatorToken.kind; - if (operator === 56 /* EqualsToken */ && (left.kind === 165 /* ObjectLiteralExpression */ || left.kind === 164 /* ArrayLiteralExpression */)) { - return checkDestructuringAssignment(left, checkExpression(right, contextualMapper), contextualMapper); - } - var leftType = checkExpression(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 */: - // TypeScript 1.0 spec (April 2014): 4.19.1 - // These operators require their operands to be of type Any, the Number primitive type, - // or an enum type. Operands of an enum type are treated - // as having the primitive type Number. If one operand is the null or undefined value, - // it is treated as having the type of the other operand. - // The result is always of the Number primitive type. - if (leftType.flags & (32 /* Undefined */ | 64 /* Null */)) - leftType = rightType; - if (rightType.flags & (32 /* Undefined */ | 64 /* Null */)) - rightType = leftType; - var suggestedOperator; - // if a user tries to apply a bitwise operator to 2 boolean operands - // try and return them a helpful suggestion - if ((leftType.flags & 8 /* Boolean */) && - (rightType.flags & 8 /* Boolean */) && - (suggestedOperator = getSuggestedBooleanOperator(operatorToken.kind)) !== undefined) { - error(errorNode || operatorToken, ts.Diagnostics.The_0_operator_is_not_allowed_for_boolean_types_Consider_using_1_instead, ts.tokenToString(operatorToken.kind), ts.tokenToString(suggestedOperator)); - } - else { - // otherwise just check each operand separately and report errors as normal - var leftOk = checkArithmeticOperandType(left, leftType, ts.Diagnostics.The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type); - var rightOk = checkArithmeticOperandType(right, rightType, ts.Diagnostics.The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type); - if (leftOk && rightOk) { - checkAssignmentOperator(numberType); - } - } - return numberType; - case 35 /* PlusToken */: - case 57 /* PlusEqualsToken */: - // TypeScript 1.0 spec (April 2014): 4.19.2 - // The binary + operator requires both operands to be of the Number primitive type or an enum type, - // or at least one of the operands to be of type Any or the String primitive type. - // If one operand is the null or undefined value, it is treated as having the type of the other operand. - if (leftType.flags & (32 /* Undefined */ | 64 /* Null */)) - leftType = rightType; - if (rightType.flags & (32 /* Undefined */ | 64 /* Null */)) - rightType = leftType; - var resultType; - if (allConstituentTypesHaveKind(leftType, 132 /* NumberLike */) && allConstituentTypesHaveKind(rightType, 132 /* NumberLike */)) { - // Operands of an enum type are treated as having the primitive type Number. - // If both operands are of the Number primitive type, the result is of the Number primitive type. - resultType = numberType; - } - else { - if (allConstituentTypesHaveKind(leftType, 258 /* StringLike */) || allConstituentTypesHaveKind(rightType, 258 /* StringLike */)) { - // If one or both operands are of the String primitive type, the result is of the String primitive type. - resultType = stringType; - } - else if (isTypeAny(leftType) || isTypeAny(rightType)) { - // Otherwise, the result is of type Any. - // NOTE: unknown type here denotes error type. Old compiler treated this case as any type so do we. - resultType = leftType === unknownType || rightType === unknownType ? unknownType : anyType; - } - // Symbols are not allowed at all in arithmetic expressions - if (resultType && !checkForDisallowedESSymbolOperand(operator)) { - return resultType; - } - } - if (!resultType) { - reportOperatorError(); - return anyType; - } - if (operator === 57 /* PlusEqualsToken */) { - checkAssignmentOperator(resultType); - } - return resultType; - case 25 /* LessThanToken */: - case 27 /* GreaterThanToken */: - case 28 /* LessThanEqualsToken */: - case 29 /* GreaterThanEqualsToken */: - if (!checkForDisallowedESSymbolOperand(operator)) { - return booleanType; - } - // Fall through - case 30 /* EqualsEqualsToken */: - case 31 /* ExclamationEqualsToken */: - case 32 /* EqualsEqualsEqualsToken */: - case 33 /* ExclamationEqualsEqualsToken */: - if (!isTypeAssignableTo(leftType, rightType) && !isTypeAssignableTo(rightType, leftType)) { - reportOperatorError(); - } - return booleanType; - case 91 /* InstanceOfKeyword */: - return checkInstanceOfExpression(left, right, leftType, rightType); - case 90 /* InKeyword */: - return checkInExpression(left, right, leftType, rightType); - case 51 /* AmpersandAmpersandToken */: - return rightType; - case 52 /* BarBarToken */: - return getUnionType([leftType, rightType]); - case 56 /* EqualsToken */: - checkAssignmentOperator(rightType); - return getRegularTypeOfObjectLiteral(rightType); - case 24 /* CommaToken */: - return rightType; - } - // Return true if there was no error, false if there was an error. - function checkForDisallowedESSymbolOperand(operator) { - var offendingSymbolOperand = someConstituentTypeHasKind(leftType, 16777216 /* ESSymbol */) ? left : - someConstituentTypeHasKind(rightType, 16777216 /* ESSymbol */) ? right : - undefined; - if (offendingSymbolOperand) { - error(offendingSymbolOperand, ts.Diagnostics.The_0_operator_cannot_be_applied_to_type_symbol, ts.tokenToString(operator)); - return false; - } - return true; - } - 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 */; - default: - return undefined; - } - } - function checkAssignmentOperator(valueType) { - if (produceDiagnostics && operator >= 56 /* FirstAssignment */ && operator <= 68 /* LastAssignment */) { - // TypeScript 1.0 spec (April 2014): 4.17 - // An assignment of the form - // VarExpr = ValueExpr - // requires VarExpr to be classified as a reference - // A compound assignment furthermore requires VarExpr to be classified as a reference (section 4.1) - // and the type of the non - compound operation to be assignable to the type of VarExpr. - var ok = checkReferenceExpression(left, ts.Diagnostics.Invalid_left_hand_side_of_assignment_expression, ts.Diagnostics.Left_hand_side_of_assignment_expression_cannot_be_a_constant); - // Use default messages - if (ok) { - // to avoid cascading errors check assignability only if 'isReference' check succeeded and no errors were reported - checkTypeAssignableTo(valueType, leftType, left, /*headMessage*/ undefined); - } - } - } - function reportOperatorError() { - error(errorNode || operatorToken, ts.Diagnostics.Operator_0_cannot_be_applied_to_types_1_and_2, ts.tokenToString(operatorToken.kind), typeToString(leftType), typeToString(rightType)); - } - } - function isYieldExpressionInClass(node) { - var current = node; - var parent = node.parent; - while (parent) { - if (ts.isFunctionLike(parent) && current === parent.body) { - return false; - } - else if (ts.isClassLike(current)) { - return true; - } - current = parent; - parent = parent.parent; - } - return false; - } - function checkYieldExpression(node) { - // Grammar checking - if (produceDiagnostics) { - if (!(node.parserContextFlags & 2 /* Yield */) || isYieldExpressionInClass(node)) { - grammarErrorOnFirstToken(node, ts.Diagnostics.A_yield_expression_is_only_allowed_in_a_generator_body); - } - if (isInParameterInitializerBeforeContainingFunction(node)) { - error(node, ts.Diagnostics.yield_expressions_cannot_be_used_in_a_parameter_initializer); - } - } - if (node.expression) { - var func = ts.getContainingFunction(node); - // If the user's code is syntactically correct, the func should always have a star. After all, - // we are in a yield context. - if (func && func.asteriskToken) { - var expressionType = checkExpressionCached(node.expression, /*contextualMapper*/ undefined); - var expressionElementType; - var nodeIsYieldStar = !!node.asteriskToken; - if (nodeIsYieldStar) { - expressionElementType = checkElementTypeOfIterable(expressionType, node.expression); - } - // There is no point in doing an assignability check if the function - // has no explicit return type because the return type is directly computed - // from the yield expressions. - if (func.type) { - var signatureElementType = getElementTypeOfIterableIterator(getTypeFromTypeNode(func.type)) || anyType; - if (nodeIsYieldStar) { - checkTypeAssignableTo(expressionElementType, signatureElementType, node.expression, /*headMessage*/ undefined); - } - else { - checkTypeAssignableTo(expressionType, signatureElementType, node.expression, /*headMessage*/ undefined); - } - } - } - } - // Both yield and yield* expressions have type 'any' - return anyType; - } - function checkConditionalExpression(node, contextualMapper) { - checkExpression(node.condition); - var type1 = checkExpression(node.whenTrue, contextualMapper); - var type2 = checkExpression(node.whenFalse, contextualMapper); - return getUnionType([type1, type2]); - } - function checkTemplateExpression(node) { - // We just want to check each expressions, but we are unconcerned with - // the type of each expression, as any value may be coerced into a string. - // It is worth asking whether this is what we really want though. - // A place where we actually *are* concerned with the expressions' types are - // in tagged templates. - ts.forEach(node.templateSpans, function (templateSpan) { - checkExpression(templateSpan.expression); - }); - return stringType; - } - function checkExpressionWithContextualType(node, contextualType, contextualMapper) { - var saveContextualType = node.contextualType; - node.contextualType = contextualType; - var result = checkExpression(node, contextualMapper); - node.contextualType = saveContextualType; - return result; - } - function checkExpressionCached(node, contextualMapper) { - var links = getNodeLinks(node); - if (!links.resolvedType) { - links.resolvedType = checkExpression(node, contextualMapper); - } - return links.resolvedType; - } - function checkPropertyAssignment(node, contextualMapper) { - // 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 === 136 /* ComputedPropertyName */) { - checkComputedPropertyName(node.name); - } - return checkExpression(node.initializer, contextualMapper); - } - function checkObjectLiteralMethod(node, contextualMapper) { - // Grammar checking - checkGrammarMethod(node); - // 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 === 136 /* ComputedPropertyName */) { - checkComputedPropertyName(node.name); - } - var uninstantiatedType = checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); - return instantiateTypeWithSingleGenericCallSignature(node, uninstantiatedType, contextualMapper); - } - function instantiateTypeWithSingleGenericCallSignature(node, type, contextualMapper) { - if (isInferentialContext(contextualMapper)) { - var signature = getSingleCallSignature(type); - if (signature && signature.typeParameters) { - var contextualType = getContextualType(node); - if (contextualType) { - var contextualSignature = getSingleCallSignature(contextualType); - if (contextualSignature && !contextualSignature.typeParameters) { - return getOrCreateTypeFromSignature(instantiateSignatureInContextOf(signature, contextualSignature, contextualMapper)); - } - } - } - } - return type; - } - // Checks an expression and returns its type. The contextualMapper parameter serves two purposes: When - // contextualMapper is not undefined and not equal to the identityMapper function object it indicates that the - // expression is being inferentially typed (section 4.12.2 in spec) and provides the type mapper to use in - // conjunction with the generic contextual type. When contextualMapper is equal to the identityMapper function - // object, it serves as an indicator that all contained function and arrow expressions should be considered to - // have the wildcard function type; this form of type check is used during overload resolution to exclude - // contextually typed function and arrow expressions in the initial phase. - function checkExpression(node, contextualMapper) { - var type; - if (node.kind === 135 /* QualifiedName */) { - type = checkQualifiedName(node); - } - else { - var uninstantiatedType = checkExpressionWorker(node, contextualMapper); - type = instantiateTypeWithSingleGenericCallSignature(node, uninstantiatedType, contextualMapper); - } - if (isConstEnumObjectType(type)) { - // enum object type for const enums are only permitted in: - // - 'left' in property access - // - 'object' in indexed access - // - target in rhs of import statement - var ok = (node.parent.kind === 166 /* PropertyAccessExpression */ && node.parent.expression === node) || - (node.parent.kind === 167 /* ElementAccessExpression */ && node.parent.expression === node) || - ((node.kind === 69 /* Identifier */ || node.kind === 135 /* QualifiedName */) && isInRightSideOfImportOrExportAssignment(node)); - if (!ok) { - error(node, ts.Diagnostics.const_enums_can_only_be_used_in_property_or_index_access_expressions_or_the_right_hand_side_of_an_import_declaration_or_export_assignment); - } - } - return type; - } - function checkNumericLiteral(node) { - // Grammar checking - checkGrammarNumericLiteral(node); - return numberType; - } - function checkExpressionWorker(node, contextualMapper) { - switch (node.kind) { - case 69 /* Identifier */: - return checkIdentifier(node); - case 97 /* ThisKeyword */: - return checkThisExpression(node); - case 95 /* SuperKeyword */: - return checkSuperExpression(node); - case 93 /* NullKeyword */: - return nullType; - case 99 /* TrueKeyword */: - case 84 /* FalseKeyword */: - return booleanType; - case 8 /* NumericLiteral */: - return checkNumericLiteral(node); - case 183 /* TemplateExpression */: - return checkTemplateExpression(node); - case 9 /* StringLiteral */: - case 11 /* NoSubstitutionTemplateLiteral */: - return stringType; - case 10 /* RegularExpressionLiteral */: - return globalRegExpType; - case 164 /* ArrayLiteralExpression */: - return checkArrayLiteral(node, contextualMapper); - case 165 /* ObjectLiteralExpression */: - return checkObjectLiteral(node, contextualMapper); - case 166 /* PropertyAccessExpression */: - return checkPropertyAccessExpression(node); - case 167 /* ElementAccessExpression */: - return checkIndexedAccess(node); - case 168 /* CallExpression */: - case 169 /* NewExpression */: - return checkCallExpression(node); - case 170 /* TaggedTemplateExpression */: - return checkTaggedTemplateExpression(node); - case 172 /* ParenthesizedExpression */: - return checkExpression(node.expression, contextualMapper); - case 186 /* ClassExpression */: - return checkClassExpression(node); - case 173 /* FunctionExpression */: - case 174 /* ArrowFunction */: - return checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); - case 176 /* TypeOfExpression */: - return checkTypeOfExpression(node); - case 171 /* TypeAssertionExpression */: - case 189 /* AsExpression */: - return checkAssertion(node); - case 175 /* DeleteExpression */: - return checkDeleteExpression(node); - case 177 /* VoidExpression */: - return checkVoidExpression(node); - case 178 /* AwaitExpression */: - return checkAwaitExpression(node); - case 179 /* PrefixUnaryExpression */: - return checkPrefixUnaryExpression(node); - case 180 /* PostfixUnaryExpression */: - return checkPostfixUnaryExpression(node); - case 181 /* BinaryExpression */: - return checkBinaryExpression(node, contextualMapper); - case 182 /* ConditionalExpression */: - return checkConditionalExpression(node, contextualMapper); - case 185 /* SpreadElementExpression */: - return checkSpreadElementExpression(node, contextualMapper); - case 187 /* OmittedExpression */: - return undefinedType; - case 184 /* YieldExpression */: - return checkYieldExpression(node); - case 240 /* JsxExpression */: - return checkJsxExpression(node); - case 233 /* JsxElement */: - return checkJsxElement(node); - case 234 /* JsxSelfClosingElement */: - return checkJsxSelfClosingElement(node); - case 235 /* JsxOpeningElement */: - ts.Debug.fail("Shouldn't ever directly check a JsxOpeningElement"); - } - return unknownType; - } - // DECLARATION AND STATEMENT TYPE CHECKING - function checkTypeParameter(node) { - // Grammar Checking - if (node.expression) { - grammarErrorOnFirstToken(node.expression, ts.Diagnostics.Type_expected); - } - checkSourceElement(node.constraint); - if (produceDiagnostics) { - checkTypeParameterHasIllegalReferencesInConstraint(node); - checkTypeNameIsReserved(node.name, ts.Diagnostics.Type_parameter_name_cannot_be_0); - } - // TODO: Check multiple declarations are identical - } - function checkParameter(node) { - // Grammar checking - // It is a SyntaxError if the Identifier "eval" or the Identifier "arguments" occurs as the - // Identifier in a PropertySetParameterList of a PropertyAssignment that is contained in strict code - // or if its FunctionBody is strict code(11.1.5). - // Grammar checking - checkGrammarDecorators(node) || checkGrammarModifiers(node); - checkVariableLikeDeclaration(node); - var func = ts.getContainingFunction(node); - if (node.flags & 112 /* AccessibilityModifier */) { - func = ts.getContainingFunction(node); - if (!(func.kind === 144 /* Constructor */ && ts.nodeIsPresent(func.body))) { - error(node, ts.Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation); - } - } - if (node.questionToken && ts.isBindingPattern(node.name) && func.body) { - error(node, ts.Diagnostics.A_binding_pattern_parameter_cannot_be_optional_in_an_implementation_signature); - } - // Only check rest parameter type if it's not a binding pattern. Since binding patterns are - // not allowed in a rest parameter, we already have an error from checkGrammarParameterList. - if (node.dotDotDotToken && !ts.isBindingPattern(node.name) && !isArrayType(getTypeOfSymbol(node.symbol))) { - error(node, ts.Diagnostics.A_rest_parameter_must_be_of_an_array_type); - } - } - function isSyntacticallyValidGenerator(node) { - if (!node.asteriskToken || !node.body) { - return false; - } - return node.kind === 143 /* MethodDeclaration */ || - node.kind === 213 /* FunctionDeclaration */ || - node.kind === 173 /* FunctionExpression */; - } - function getTypePredicateParameterIndex(parameterList, parameter) { - if (parameterList) { - for (var i = 0; i < parameterList.length; i++) { - var param = parameterList[i]; - if (param.name.kind === 69 /* Identifier */ && - param.name.text === parameter.text) { - return i; - } - } - } - return -1; - } - function isInLegalTypePredicatePosition(node) { - switch (node.parent.kind) { - case 174 /* ArrowFunction */: - case 147 /* CallSignature */: - case 213 /* FunctionDeclaration */: - case 173 /* FunctionExpression */: - case 152 /* FunctionType */: - case 143 /* MethodDeclaration */: - case 142 /* MethodSignature */: - return node === node.parent.type; - } - return false; - } - function checkSignatureDeclaration(node) { - // Grammar checking - if (node.kind === 149 /* IndexSignature */) { - checkGrammarIndexSignature(node); - } - else if (node.kind === 152 /* FunctionType */ || node.kind === 213 /* FunctionDeclaration */ || node.kind === 153 /* ConstructorType */ || - node.kind === 147 /* CallSignature */ || node.kind === 144 /* Constructor */ || - node.kind === 148 /* ConstructSignature */) { - checkGrammarFunctionLikeDeclaration(node); - } - checkTypeParameters(node.typeParameters); - ts.forEach(node.parameters, checkParameter); - if (node.type) { - if (node.type.kind === 150 /* TypePredicate */) { - var typePredicate = getSignatureFromDeclaration(node).typePredicate; - var typePredicateNode = node.type; - if (isInLegalTypePredicatePosition(typePredicateNode)) { - if (typePredicate.parameterIndex >= 0) { - if (node.parameters[typePredicate.parameterIndex].dotDotDotToken) { - error(typePredicateNode.parameterName, ts.Diagnostics.A_type_predicate_cannot_reference_a_rest_parameter); - } - else { - checkTypeAssignableTo(typePredicate.type, getTypeOfNode(node.parameters[typePredicate.parameterIndex]), typePredicateNode.type); - } - } - else if (typePredicateNode.parameterName) { - var hasReportedError = false; - for (var _i = 0, _a = node.parameters; _i < _a.length; _i++) { - var param = _a[_i]; - if (hasReportedError) { - break; - } - if (param.name.kind === 161 /* ObjectBindingPattern */ || - param.name.kind === 162 /* ArrayBindingPattern */) { - (function checkBindingPattern(pattern) { - for (var _i = 0, _a = pattern.elements; _i < _a.length; _i++) { - var element = _a[_i]; - if (element.name.kind === 69 /* Identifier */ && - element.name.text === typePredicate.parameterName) { - error(typePredicateNode.parameterName, ts.Diagnostics.A_type_predicate_cannot_reference_element_0_in_a_binding_pattern, typePredicate.parameterName); - hasReportedError = true; - break; - } - else if (element.name.kind === 162 /* ArrayBindingPattern */ || - element.name.kind === 161 /* ObjectBindingPattern */) { - checkBindingPattern(element.name); - } - } - })(param.name); - } - } - if (!hasReportedError) { - error(typePredicateNode.parameterName, ts.Diagnostics.Cannot_find_parameter_0, typePredicate.parameterName); - } - } - } - else { - error(typePredicateNode, ts.Diagnostics.A_type_predicate_is_only_allowed_in_return_type_position_for_functions_and_methods); - } - } - else { - checkSourceElement(node.type); - } - } - if (produceDiagnostics) { - checkCollisionWithArgumentsInGeneratedCode(node); - if (compilerOptions.noImplicitAny && !node.type) { - switch (node.kind) { - case 148 /* ConstructSignature */: - error(node, ts.Diagnostics.Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); - break; - case 147 /* 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)) { - var returnType = getTypeFromTypeNode(node.type); - if (returnType === voidType) { - error(node.type, ts.Diagnostics.A_generator_cannot_have_a_void_type_annotation); - } - else { - var generatorElementType = getElementTypeOfIterableIterator(returnType) || anyType; - var iterableIteratorInstantiation = createIterableIteratorType(generatorElementType); - // Naively, one could check that IterableIterator is assignable to the return type annotation. - // However, that would not catch the error in the following case. - // - // interface BadGenerator extends Iterable, Iterator { } - // function* g(): BadGenerator { } // Iterable and Iterator have different types! - // - checkTypeAssignableTo(iterableIteratorInstantiation, returnType, node.type); - } - } - } - } - checkSpecializedSignatureDeclaration(node); - } - function checkTypeForDuplicateIndexSignatures(node) { - if (node.kind === 215 /* InterfaceDeclaration */) { - var nodeSymbol = getSymbolOfNode(node); - // in case of merging interface declaration it is possible that we'll enter this check procedure several times for every declaration - // to prevent this run check only for the first declaration of a given kind - if (nodeSymbol.declarations.length > 0 && nodeSymbol.declarations[0] !== node) { - return; - } - } - // TypeScript 1.0 spec (April 2014) - // 3.7.4: An object type can contain at most one string index signature and one numeric index signature. - // 8.5: A class declaration can have at most one string index member declaration and one numeric index member declaration - var indexSymbol = getIndexSymbol(getSymbolOfNode(node)); - if (indexSymbol) { - var seenNumericIndexer = false; - var seenStringIndexer = false; - for (var _i = 0, _a = indexSymbol.declarations; _i < _a.length; _i++) { - var decl = _a[_i]; - var declaration = decl; - if (declaration.parameters.length === 1 && declaration.parameters[0].type) { - switch (declaration.parameters[0].type.kind) { - case 130 /* StringKeyword */: - if (!seenStringIndexer) { - seenStringIndexer = true; - } - else { - error(declaration, ts.Diagnostics.Duplicate_string_index_signature); - } - break; - case 128 /* NumberKeyword */: - if (!seenNumericIndexer) { - seenNumericIndexer = true; - } - else { - error(declaration, ts.Diagnostics.Duplicate_number_index_signature); - } - break; - } - } - } - } - } - function checkPropertyDeclaration(node) { - // Grammar checking - checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarProperty(node) || checkGrammarComputedPropertyName(node.name); - checkVariableLikeDeclaration(node); - } - function checkMethodDeclaration(node) { - // Grammar checking - checkGrammarMethod(node) || checkGrammarComputedPropertyName(node.name); - // Grammar checking for modifiers is done inside the function checkGrammarFunctionLikeDeclaration - checkFunctionLikeDeclaration(node); - // Abstract methods cannot have an implementation. - // Extra checks are to avoid reporting multiple errors relating to the "abstractness" of the node. - if (node.flags & 256 /* Abstract */ && node.body) { - error(node, ts.Diagnostics.Method_0_cannot_have_an_implementation_because_it_is_marked_abstract, ts.declarationNameToString(node.name)); - } - } - function checkConstructorDeclaration(node) { - // Grammar check on signature of constructor and modifier of the constructor is done in checkSignatureDeclaration function. - checkSignatureDeclaration(node); - // Grammar check for checking only related to constructoDeclaration - checkGrammarConstructorTypeParameters(node) || checkGrammarConstructorTypeAnnotation(node); - checkSourceElement(node.body); - var symbol = getSymbolOfNode(node); - var firstDeclaration = ts.getDeclarationOfKind(symbol, node.kind); - // Only type check the symbol once - if (node === firstDeclaration) { - checkFunctionOrConstructorSymbol(symbol); - } - // exit early in the case of signature - super checks are not relevant to them - if (ts.nodeIsMissing(node.body)) { - return; - } - if (!produceDiagnostics) { - return; - } - function isSuperCallExpression(n) { - return n.kind === 168 /* CallExpression */ && n.expression.kind === 95 /* SuperKeyword */; - } - function containsSuperCallAsComputedPropertyName(n) { - return n.name && containsSuperCall(n.name); - } - function containsSuperCall(n) { - if (isSuperCallExpression(n)) { - return true; - } - else if (ts.isFunctionLike(n)) { - return false; - } - else if (ts.isClassLike(n)) { - return ts.forEach(n.members, containsSuperCallAsComputedPropertyName); - } - return ts.forEachChild(n, containsSuperCall); - } - function markThisReferencesAsErrors(n) { - if (n.kind === 97 /* ThisKeyword */) { - error(n, ts.Diagnostics.this_cannot_be_referenced_in_current_location); - } - else if (n.kind !== 173 /* FunctionExpression */ && n.kind !== 213 /* FunctionDeclaration */) { - ts.forEachChild(n, markThisReferencesAsErrors); - } - } - function isInstancePropertyWithInitializer(n) { - return n.kind === 141 /* PropertyDeclaration */ && - !(n.flags & 128 /* Static */) && - !!n.initializer; - } - // TS 1.0 spec (April 2014): 8.3.2 - // Constructors of classes with no extends clause may not contain super calls, whereas - // constructors of derived classes must contain at least one super call somewhere in their function body. - var containingClassDecl = node.parent; - if (ts.getClassExtendsHeritageClauseElement(containingClassDecl)) { - var containingClassSymbol = getSymbolOfNode(containingClassDecl); - var containingClassInstanceType = getDeclaredTypeOfSymbol(containingClassSymbol); - var baseConstructorType = getBaseConstructorTypeOfClass(containingClassInstanceType); - if (containsSuperCall(node.body)) { - if (baseConstructorType === nullType) { - error(node, ts.Diagnostics.A_constructor_cannot_contain_a_super_call_when_its_class_extends_null); - } - // The first statement in the body of a constructor (excluding prologue directives) must be a super call - // if both of the following are true: - // - The containing class is a derived class. - // - The constructor declares parameter properties - // or the containing class declares instance member variables with initializers. - var superCallShouldBeFirst = ts.forEach(node.parent.members, isInstancePropertyWithInitializer) || - ts.forEach(node.parameters, function (p) { return p.flags & (16 /* Public */ | 32 /* Private */ | 64 /* Protected */); }); - // Skip past any prologue directives to find the first statement - // to ensure that it was a super call. - if (superCallShouldBeFirst) { - var statements = node.body.statements; - var superCallStatement; - for (var _i = 0; _i < statements.length; _i++) { - var statement = statements[_i]; - if (statement.kind === 195 /* ExpressionStatement */ && isSuperCallExpression(statement.expression)) { - superCallStatement = statement; - break; - } - if (!ts.isPrologueDirective(statement)) { - break; - } - } - if (!superCallStatement) { - error(node, ts.Diagnostics.A_super_call_must_be_the_first_statement_in_the_constructor_when_a_class_contains_initialized_properties_or_has_parameter_properties); - } - else { - // In such a required super call, it is a compile-time error for argument expressions to reference this. - markThisReferencesAsErrors(superCallStatement.expression); - } - } - } - else if (baseConstructorType !== nullType) { - error(node, ts.Diagnostics.Constructors_for_derived_classes_must_contain_a_super_call); - } - } - } - function checkAccessorDeclaration(node) { - if (produceDiagnostics) { - // Grammar checking accessors - checkGrammarFunctionLikeDeclaration(node) || checkGrammarAccessor(node) || checkGrammarComputedPropertyName(node.name); - if (node.kind === 145 /* GetAccessor */) { - if (!ts.isInAmbientContext(node) && ts.nodeIsPresent(node.body) && !(bodyContainsAReturnStatement(node.body) || bodyContainsSingleThrowStatement(node.body))) { - error(node.name, ts.Diagnostics.A_get_accessor_must_return_a_value_or_consist_of_a_single_throw_statement); - } - } - 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 === 145 /* GetAccessor */ ? 146 /* SetAccessor */ : 145 /* GetAccessor */; - var otherAccessor = ts.getDeclarationOfKind(node.symbol, otherKind); - if (otherAccessor) { - if (((node.flags & 112 /* AccessibilityModifier */) !== (otherAccessor.flags & 112 /* AccessibilityModifier */))) { - error(node.name, ts.Diagnostics.Getter_and_setter_accessors_do_not_agree_in_visibility); - } - var currentAccessorType = getAnnotatedAccessorType(node); - var otherAccessorType = getAnnotatedAccessorType(otherAccessor); - // TypeScript 1.0 spec (April 2014): 4.5 - // If both accessors include type annotations, the specified types must be identical. - if (currentAccessorType && otherAccessorType) { - if (!isTypeIdenticalTo(currentAccessorType, otherAccessorType)) { - error(node, ts.Diagnostics.get_and_set_accessor_must_have_the_same_type); - } - } - } - } - getTypeOfAccessors(getSymbolOfNode(node)); - } - checkFunctionLikeDeclaration(node); - } - function checkMissingDeclaration(node) { - checkDecorators(node); - } - function checkTypeArgumentConstraints(typeParameters, typeArguments) { - var result = true; - for (var i = 0; i < typeParameters.length; i++) { - var constraint = getConstraintOfTypeParameter(typeParameters[i]); - if (constraint) { - var typeArgument = typeArguments[i]; - result = result && checkTypeAssignableTo(getTypeFromTypeNode(typeArgument), constraint, typeArgument, ts.Diagnostics.Type_0_does_not_satisfy_the_constraint_1); - } - } - return result; - } - function checkTypeReferenceNode(node) { - checkGrammarTypeArguments(node, node.typeArguments); - var type = getTypeFromTypeReference(node); - if (type !== unknownType && node.typeArguments) { - // Do type argument local checks only if referenced type is successfully resolved - ts.forEach(node.typeArguments, checkSourceElement); - if (produceDiagnostics) { - var symbol = getNodeLinks(node).resolvedSymbol; - var typeParameters = symbol.flags & 524288 /* TypeAlias */ ? getSymbolLinks(symbol).typeParameters : type.target.localTypeParameters; - checkTypeArgumentConstraints(typeParameters, node.typeArguments); - } - } - } - function checkTypeQuery(node) { - getTypeFromTypeQueryNode(node); - } - function checkTypeLiteral(node) { - ts.forEach(node.members, checkSourceElement); - if (produceDiagnostics) { - var type = getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node); - checkIndexConstraints(type); - checkTypeForDuplicateIndexSignatures(node); - } - } - function checkArrayType(node) { - checkSourceElement(node.elementType); - } - function checkTupleType(node) { - // Grammar checking - var hasErrorFromDisallowedTrailingComma = checkGrammarForDisallowedTrailingComma(node.elementTypes); - if (!hasErrorFromDisallowedTrailingComma && node.elementTypes.length === 0) { - grammarErrorOnNode(node, ts.Diagnostics.A_tuple_type_element_list_cannot_be_empty); - } - ts.forEach(node.elementTypes, checkSourceElement); - } - function checkUnionOrIntersectionType(node) { - ts.forEach(node.types, checkSourceElement); - } - function isPrivateWithinAmbient(node) { - return (node.flags & 32 /* Private */) && ts.isInAmbientContext(node); - } - function checkSpecializedSignatureDeclaration(signatureDeclarationNode) { - if (!produceDiagnostics) { - return; - } - var signature = getSignatureFromDeclaration(signatureDeclarationNode); - if (!signature.hasStringLiterals) { - return; - } - // TypeScript 1.0 spec (April 2014): 3.7.2.2 - // Specialized signatures are not permitted in conjunction with a function body - if (ts.nodeIsPresent(signatureDeclarationNode.body)) { - error(signatureDeclarationNode, ts.Diagnostics.A_signature_with_an_implementation_cannot_use_a_string_literal_type); - return; - } - // TypeScript 1.0 spec (April 2014): 3.7.2.4 - // Every specialized call or construct signature in an object type must be assignable - // to at least one non-specialized call or construct signature in the same object type - var signaturesToCheck; - // Unnamed (call\construct) signatures in interfaces are inherited and not shadowed so examining just node symbol won't give complete answer. - // Use declaring type to obtain full list of signatures. - if (!signatureDeclarationNode.name && signatureDeclarationNode.parent && signatureDeclarationNode.parent.kind === 215 /* InterfaceDeclaration */) { - ts.Debug.assert(signatureDeclarationNode.kind === 147 /* CallSignature */ || signatureDeclarationNode.kind === 148 /* ConstructSignature */); - var signatureKind = signatureDeclarationNode.kind === 147 /* CallSignature */ ? 0 /* Call */ : 1 /* Construct */; - var containingSymbol = getSymbolOfNode(signatureDeclarationNode.parent); - var containingType = getDeclaredTypeOfSymbol(containingSymbol); - signaturesToCheck = getSignaturesOfType(containingType, signatureKind); - } - else { - signaturesToCheck = getSignaturesOfSymbol(getSymbolOfNode(signatureDeclarationNode)); - } - for (var _i = 0; _i < signaturesToCheck.length; _i++) { - var otherSignature = signaturesToCheck[_i]; - if (!otherSignature.hasStringLiterals && isSignatureAssignableTo(signature, otherSignature)) { - return; - } - } - error(signatureDeclarationNode, ts.Diagnostics.Specialized_overload_signature_is_not_assignable_to_any_non_specialized_signature); - } - function getEffectiveDeclarationFlags(n, flagsToCheck) { - var flags = ts.getCombinedNodeFlags(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 !== 215 /* InterfaceDeclaration */ && - n.parent.kind !== 214 /* ClassDeclaration */ && - n.parent.kind !== 186 /* ClassExpression */ && - ts.isInAmbientContext(n)) { - if (!(flags & 2 /* Ambient */)) { - // It is nested in an ambient context, which means it is automatically exported - flags |= 1 /* Export */; - } - flags |= 2 /* Ambient */; - } - return flags & flagsToCheck; - } - function checkFunctionOrConstructorSymbol(symbol) { - if (!produceDiagnostics) { - return; - } - function getCanonicalOverload(overloads, implementation) { - // Consider the canonical set of flags to be the flags of the bodyDeclaration or the first declaration - // Error on all deviations from this canonical set of flags - // The caveat is that if some overloads are defined in lib.d.ts, we don't want to - // report the errors on those. To achieve this, we will say that the implementation is - // the canonical signature only if it is in the same container as the first overload - var implementationSharesContainerWithFirstOverload = implementation !== undefined && implementation.parent === overloads[0].parent; - return implementationSharesContainerWithFirstOverload ? implementation : overloads[0]; - } - function checkFlagAgreementBetweenOverloads(overloads, implementation, flagsToCheck, someOverloadFlags, allOverloadFlags) { - // Error if some overloads have a flag that is not shared by all overloads. To find the - // deviations, we XOR someOverloadFlags with allOverloadFlags - var someButNotAllOverloadFlags = someOverloadFlags ^ allOverloadFlags; - if (someButNotAllOverloadFlags !== 0) { - var canonicalFlags = getEffectiveDeclarationFlags(getCanonicalOverload(overloads, implementation), flagsToCheck); - ts.forEach(overloads, function (o) { - var deviation = getEffectiveDeclarationFlags(o, flagsToCheck) ^ canonicalFlags; - if (deviation & 1 /* Export */) { - error(o.name, ts.Diagnostics.Overload_signatures_must_all_be_exported_or_not_exported); - } - else if (deviation & 2 /* Ambient */) { - error(o.name, ts.Diagnostics.Overload_signatures_must_all_be_ambient_or_non_ambient); - } - else if (deviation & (32 /* Private */ | 64 /* Protected */)) { - error(o.name, ts.Diagnostics.Overload_signatures_must_all_be_public_private_or_protected); - } - else if (deviation & 256 /* Abstract */) { - error(o.name, ts.Diagnostics.Overload_signatures_must_all_be_abstract_or_not_abstract); - } - }); - } - } - function checkQuestionTokenAgreementBetweenOverloads(overloads, implementation, someHaveQuestionToken, allHaveQuestionToken) { - if (someHaveQuestionToken !== allHaveQuestionToken) { - var canonicalHasQuestionToken = ts.hasQuestionToken(getCanonicalOverload(overloads, implementation)); - ts.forEach(overloads, function (o) { - var deviation = ts.hasQuestionToken(o) !== canonicalHasQuestionToken; - if (deviation) { - error(o.name, ts.Diagnostics.Overload_signatures_must_all_be_optional_or_required); - } - }); - } - } - var flagsToCheck = 1 /* Export */ | 2 /* Ambient */ | 32 /* Private */ | 64 /* Protected */ | 256 /* Abstract */; - var someNodeFlags = 0; - var allNodeFlags = flagsToCheck; - var someHaveQuestionToken = false; - var allHaveQuestionToken = true; - var hasOverloads = false; - var bodyDeclaration; - var lastSeenNonAmbientDeclaration; - var previousDeclaration; - var declarations = symbol.declarations; - var isConstructor = (symbol.flags & 16384 /* Constructor */) !== 0; - function reportImplementationExpectedError(node) { - if (node.name && ts.nodeIsMissing(node.name)) { - return; - } - var seen = false; - var subsequentNode = ts.forEachChild(node.parent, function (c) { - if (seen) { - return c; - } - else { - seen = c === node; - } - }); - if (subsequentNode) { - if (subsequentNode.kind === node.kind) { - 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) { - // the only situation when this is possible (same kind\same name but different symbol) - mixed static and instance class members - ts.Debug.assert(node.kind === 143 /* MethodDeclaration */ || node.kind === 142 /* MethodSignature */); - ts.Debug.assert((node.flags & 128 /* Static */) !== (subsequentNode.flags & 128 /* Static */)); - var diagnostic = node.flags & 128 /* Static */ ? ts.Diagnostics.Function_overload_must_be_static : ts.Diagnostics.Function_overload_must_not_be_static; - error(errorNode_1, diagnostic); - return; - } - else if (ts.nodeIsPresent(subsequentNode.body)) { - error(errorNode_1, ts.Diagnostics.Function_implementation_name_must_be_0, ts.declarationNameToString(node.name)); - return; - } - } - } - var errorNode = node.name || node; - if (isConstructor) { - error(errorNode, ts.Diagnostics.Constructor_implementation_is_missing); - } - else { - // Report different errors regarding non-consecutive blocks of declarations depending on whether - // the node in question is abstract. - if (node.flags & 256 /* Abstract */) { - error(errorNode, ts.Diagnostics.All_declarations_of_an_abstract_method_must_be_consecutive); - } - else { - error(errorNode, ts.Diagnostics.Function_implementation_is_missing_or_not_immediately_following_the_declaration); - } - } - } - // when checking exported function declarations across modules check only duplicate implementations - // names and consistency of modifiers are verified when we check local symbol - var isExportSymbolInsideModule = symbol.parent && symbol.parent.flags & 1536 /* Module */; - var duplicateFunctionDeclaration = false; - var multipleConstructorImplementation = false; - for (var _i = 0; _i < declarations.length; _i++) { - var current = declarations[_i]; - var node = current; - var inAmbientContext = ts.isInAmbientContext(node); - var inAmbientContextOrInterface = node.parent.kind === 215 /* InterfaceDeclaration */ || node.parent.kind === 155 /* TypeLiteral */ || inAmbientContext; - if (inAmbientContextOrInterface) { - // check if declarations are consecutive only if they are non-ambient - // 1. ambient declarations can be interleaved - // i.e. this is legal - // declare function foo(); - // declare function bar(); - // declare function foo(); - // 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 === 213 /* FunctionDeclaration */ || node.kind === 143 /* MethodDeclaration */ || node.kind === 142 /* MethodSignature */ || node.kind === 144 /* Constructor */) { - var currentNodeFlags = getEffectiveDeclarationFlags(node, flagsToCheck); - someNodeFlags |= currentNodeFlags; - allNodeFlags &= currentNodeFlags; - someHaveQuestionToken = someHaveQuestionToken || ts.hasQuestionToken(node); - allHaveQuestionToken = allHaveQuestionToken && ts.hasQuestionToken(node); - if (ts.nodeIsPresent(node.body) && bodyDeclaration) { - if (isConstructor) { - multipleConstructorImplementation = true; - } - else { - duplicateFunctionDeclaration = true; - } - } - else if (!isExportSymbolInsideModule && previousDeclaration && previousDeclaration.parent === node.parent && previousDeclaration.end !== node.pos) { - reportImplementationExpectedError(previousDeclaration); - } - if (ts.nodeIsPresent(node.body)) { - if (!bodyDeclaration) { - bodyDeclaration = node; - } - } - else { - hasOverloads = true; - } - previousDeclaration = node; - if (!inAmbientContextOrInterface) { - lastSeenNonAmbientDeclaration = node; - } - } - } - if (multipleConstructorImplementation) { - ts.forEach(declarations, function (declaration) { - error(declaration, ts.Diagnostics.Multiple_constructor_implementations_are_not_allowed); - }); - } - if (duplicateFunctionDeclaration) { - ts.forEach(declarations, function (declaration) { - error(declaration.name, ts.Diagnostics.Duplicate_function_implementation); - }); - } - // Abstract methods can't have an implementation -- in particular, they don't need one. - if (!isExportSymbolInsideModule && lastSeenNonAmbientDeclaration && !lastSeenNonAmbientDeclaration.body && - !(lastSeenNonAmbientDeclaration.flags & 256 /* Abstract */)) { - reportImplementationExpectedError(lastSeenNonAmbientDeclaration); - } - if (hasOverloads) { - checkFlagAgreementBetweenOverloads(declarations, bodyDeclaration, flagsToCheck, someNodeFlags, allNodeFlags); - checkQuestionTokenAgreementBetweenOverloads(declarations, bodyDeclaration, someHaveQuestionToken, allHaveQuestionToken); - if (bodyDeclaration) { - var signatures = getSignaturesOfSymbol(symbol); - var bodySignature = getSignatureFromDeclaration(bodyDeclaration); - // If the implementation signature has string literals, we will have reported an error in - // checkSpecializedSignatureDeclaration - if (!bodySignature.hasStringLiterals) { - // TypeScript 1.0 spec (April 2014): 6.1 - // If a function declaration includes overloads, the overloads determine the call - // signatures of the type given to the function object - // and the function implementation signature must be assignable to that type - // - // TypeScript 1.0 spec (April 2014): 3.8.4 - // Note that specialized call and construct signatures (section 3.7.2.4) are not significant when determining assignment compatibility - // Consider checking against specialized signatures too. Not doing so creates a type hole: - // - // function g(x: "hi", y: boolean); - // function g(x: string, y: {}); - // function g(x: string, y: string) { } - // - // The implementation is completely unrelated to the specialized signature, yet we do not check this. - for (var _a = 0; _a < signatures.length; _a++) { - var signature = signatures[_a]; - if (!signature.hasStringLiterals && !isSignatureAssignableTo(bodySignature, signature)) { - error(signature.declaration, ts.Diagnostics.Overload_signature_is_not_compatible_with_function_implementation); - break; - } - } - } - } - } - } - function checkExportsOnMergedDeclarations(node) { - if (!produceDiagnostics) { - return; - } - // if localSymbol is defined on node then node itself is exported - check is required - var symbol = node.localSymbol; - if (!symbol) { - // local symbol is undefined => this declaration is non-exported. - // however symbol might contain other declarations that are exported - symbol = getSymbolOfNode(node); - if (!(symbol.flags & 7340032 /* Export */)) { - // this is a pure local symbol (all declarations are non-exported) - no need to check anything - return; - } - } - // run the check only for the first declaration in the list - if (ts.getDeclarationOfKind(symbol, node.kind) !== node) { - return; - } - // we use SymbolFlags.ExportValue, SymbolFlags.ExportType and SymbolFlags.ExportNamespace - // to denote disjoint declarationSpaces (without making new enum type). - var exportedDeclarationSpaces = 0 /* None */; - var nonExportedDeclarationSpaces = 0 /* None */; - var defaultExportedDeclarationSpaces = 0 /* None */; - for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { - var d = _a[_i]; - var declarationSpaces = getDeclarationSpaces(d); - var effectiveDeclarationFlags = getEffectiveDeclarationFlags(d, 1 /* Export */ | 1024 /* Default */); - if (effectiveDeclarationFlags & 1 /* Export */) { - if (effectiveDeclarationFlags & 1024 /* Default */) { - defaultExportedDeclarationSpaces |= declarationSpaces; - } - else { - exportedDeclarationSpaces |= declarationSpaces; - } - } - else { - nonExportedDeclarationSpaces |= declarationSpaces; - } - } - // Spaces for anyting not declared a 'default export'. - var nonDefaultExportedDeclarationSpaces = exportedDeclarationSpaces | nonExportedDeclarationSpaces; - var commonDeclarationSpacesForExportsAndLocals = exportedDeclarationSpaces & nonExportedDeclarationSpaces; - var commonDeclarationSpacesForDefaultAndNonDefault = defaultExportedDeclarationSpaces & nonDefaultExportedDeclarationSpaces; - if (commonDeclarationSpacesForExportsAndLocals || commonDeclarationSpacesForDefaultAndNonDefault) { - // declaration spaces for exported and non-exported declarations intersect - for (var _b = 0, _c = symbol.declarations; _b < _c.length; _b++) { - var d = _c[_b]; - var declarationSpaces = getDeclarationSpaces(d); - // Only error on the declarations that conributed to the intersecting spaces. - if (declarationSpaces & commonDeclarationSpacesForDefaultAndNonDefault) { - error(d.name, ts.Diagnostics.Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_default_0_declaration_instead, ts.declarationNameToString(d.name)); - } - else if (declarationSpaces & commonDeclarationSpacesForExportsAndLocals) { - error(d.name, ts.Diagnostics.Individual_declarations_in_merged_declaration_0_must_be_all_exported_or_all_local, ts.declarationNameToString(d.name)); - } - } - } - function getDeclarationSpaces(d) { - switch (d.kind) { - case 215 /* InterfaceDeclaration */: - return 2097152 /* ExportType */; - case 218 /* ModuleDeclaration */: - return d.name.kind === 9 /* StringLiteral */ || ts.getModuleInstanceState(d) !== 0 /* NonInstantiated */ - ? 4194304 /* ExportNamespace */ | 1048576 /* ExportValue */ - : 4194304 /* ExportNamespace */; - case 214 /* ClassDeclaration */: - case 217 /* EnumDeclaration */: - return 2097152 /* ExportType */ | 1048576 /* ExportValue */; - case 221 /* ImportEqualsDeclaration */: - var result = 0; - var target = resolveAlias(getSymbolOfNode(d)); - ts.forEach(target.declarations, function (d) { result |= getDeclarationSpaces(d); }); - return result; - default: - return 1048576 /* ExportValue */; - } - } - } - function checkNonThenableType(type, location, message) { - type = getWidenedType(type); - if (!isTypeAny(type) && isTypeAssignableTo(type, getGlobalThenableType())) { - if (location) { - if (!message) { - message = ts.Diagnostics.Operand_for_await_does_not_have_a_valid_callable_then_member; - } - error(location, message); - } - return unknownType; - } - return type; - } - /** - * Gets the "promised type" of a promise. - * @param type The type of the promise. - * @remarks The "promised type" of a type is the type of the "value" parameter of the "onfulfilled" callback. - */ - function getPromisedType(promise) { - // - // { // promise - // then( // thenFunction - // onfulfilled: ( // onfulfilledParameterType - // value: T // valueParameterType - // ) => any - // ): any; - // } - // - if (promise.flags & 1 /* Any */) { - return undefined; - } - if ((promise.flags & 4096 /* Reference */) && promise.target === tryGetGlobalPromiseType()) { - return promise.typeArguments[0]; - } - var globalPromiseLikeType = getInstantiatedGlobalPromiseLikeType(); - if (globalPromiseLikeType === emptyObjectType || !isTypeAssignableTo(promise, globalPromiseLikeType)) { - return undefined; - } - var thenFunction = getTypeOfPropertyOfType(promise, "then"); - if (thenFunction && (thenFunction.flags & 1 /* Any */)) { - return undefined; - } - var thenSignatures = thenFunction ? getSignaturesOfType(thenFunction, 0 /* Call */) : emptyArray; - if (thenSignatures.length === 0) { - return undefined; - } - var onfulfilledParameterType = getUnionType(ts.map(thenSignatures, getTypeOfFirstParameterOfSignature)); - if (onfulfilledParameterType.flags & 1 /* Any */) { - return undefined; - } - var onfulfilledParameterSignatures = getSignaturesOfType(onfulfilledParameterType, 0 /* Call */); - if (onfulfilledParameterSignatures.length === 0) { - return undefined; - } - var valueParameterType = getUnionType(ts.map(onfulfilledParameterSignatures, getTypeOfFirstParameterOfSignature)); - return valueParameterType; - } - function getTypeOfFirstParameterOfSignature(signature) { - return getTypeAtPosition(signature, 0); - } - /** - * Gets the "awaited type" of a type. - * @param type The type to await. - * @remarks The "awaited type" of an expression is its "promised type" if the expression is a - * Promise-like type; otherwise, it is the type of the expression. This is used to reflect - * The runtime behavior of the `await` keyword. - */ - function getAwaitedType(type) { - return checkAwaitedType(type, /*location*/ undefined, /*message*/ undefined); - } - function checkAwaitedType(type, location, message) { - return checkAwaitedTypeWorker(type); - function checkAwaitedTypeWorker(type) { - if (type.flags & 16384 /* Union */) { - var types = []; - for (var _i = 0, _a = type.types; _i < _a.length; _i++) { - var constituentType = _a[_i]; - types.push(checkAwaitedTypeWorker(constituentType)); - } - return getUnionType(types); - } - else { - var promisedType = getPromisedType(type); - if (promisedType === undefined) { - // The type was not a PromiseLike, so it could not be unwrapped any further. - // As long as the type does not have a callable "then" property, it is - // safe to return the type; otherwise, an error will have been reported in - // the call to checkNonThenableType and we will return unknownType. - // - // An example of a non-promise "thenable" might be: - // - // await { then(): void {} } - // - // The "thenable" does not match the minimal definition for a PromiseLike. When - // a Promise/A+-compatible or ES6 promise tries to adopt this value, the promise - // will never settle. We treat this as an error to help flag an early indicator - // of a runtime problem. If the user wants to return this value from an async - // function, they would need to wrap it in some other value. If they want it to - // be treated as a promise, they can cast to . - return checkNonThenableType(type, location, message); - } - else { - if (type.id === promisedType.id || awaitedTypeStack.indexOf(promisedType.id) >= 0) { - // We have a bad actor in the form of a promise whose promised type is - // the same promise type, or a mutually recursive promise. Return the - // unknown type as we cannot guess the shape. If this were the actual - // case in the JavaScript, this Promise would never resolve. - // - // An example of a bad actor with a singly-recursive promise type might - // be: - // - // interface BadPromise { - // then( - // onfulfilled: (value: BadPromise) => any, - // onrejected: (error: any) => any): BadPromise; - // } - // - // The above interface will pass the PromiseLike check, and return a - // promised type of `BadPromise`. Since this is a self reference, we - // don't want to keep recursing ad infinitum. - // - // An example of a bad actor in the form of a mutually-recursive - // promise type might be: - // - // interface BadPromiseA { - // then( - // onfulfilled: (value: BadPromiseB) => any, - // onrejected: (error: any) => any): BadPromiseB; - // } - // - // interface BadPromiseB { - // then( - // onfulfilled: (value: BadPromiseA) => any, - // onrejected: (error: any) => any): BadPromiseA; - // } - // - if (location) { - error(location, ts.Diagnostics._0_is_referenced_directly_or_indirectly_in_the_fulfillment_callback_of_its_own_then_method, symbolToString(type.symbol)); - } - return unknownType; - } - // Keep track of the type we're about to unwrap to avoid bad recursive promise types. - // See the comments above for more information. - awaitedTypeStack.push(type.id); - var awaitedType = checkAwaitedTypeWorker(promisedType); - awaitedTypeStack.pop(); - return awaitedType; - } - } - } - } - /** - * Checks the return type of an async function to ensure it is a compatible - * Promise implementation. - * @param node The signature to check - * @param returnType The return type for the function - * @remarks - * This checks that an async function has a valid Promise-compatible return type, - * and returns the *awaited type* of the promise. An async function has a valid - * Promise-compatible return type if the resolved value of the return type has a - * construct signature that takes in an `initializer` function that in turn supplies - * a `resolve` function as one of its arguments and results in an object with a - * callable `then` signature. - */ - function checkAsyncFunctionReturnType(node) { - var globalPromiseConstructorLikeType = getGlobalPromiseConstructorLikeType(); - if (globalPromiseConstructorLikeType === emptyObjectType) { - // If we couldn't resolve the global PromiseConstructorLike type we cannot verify - // compatibility with __awaiter. - return unknownType; - } - // As part of our emit for an async function, we will need to emit the entity name of - // the return type annotation as an expression. To meet the necessary runtime semantics - // for __awaiter, we must also check that the type of the declaration (e.g. the static - // side or "constructor" of the promise type) is compatible `PromiseConstructorLike`. - // - // An example might be (from lib.es6.d.ts): - // - // interface Promise { ... } - // interface PromiseConstructor { - // new (...): Promise; - // } - // declare var Promise: PromiseConstructor; - // - // When an async function declares a return type annotation of `Promise`, we - // need to get the type of the `Promise` variable declaration above, which would - // be `PromiseConstructor`. - // - // The same case applies to a class: - // - // declare class Promise { - // constructor(...); - // then(...): Promise; - // } - // - // When we get the type of the `Promise` symbol here, we get the type of the static - // side of the `Promise` class, which would be `{ new (...): Promise }`. - var promiseType = getTypeFromTypeNode(node.type); - if (promiseType === unknownType && compilerOptions.isolatedModules) { - // If we are compiling with isolatedModules, we may not be able to resolve the - // type as a value. As such, we will just return unknownType; - return unknownType; - } - var promiseConstructor = getMergedSymbol(promiseType.symbol); - if (!promiseConstructor || !symbolIsValue(promiseConstructor)) { - error(node, ts.Diagnostics.Type_0_is_not_a_valid_async_function_return_type, typeToString(promiseType)); - return unknownType; - } - // Validate the promise constructor type. - var promiseConstructorType = getTypeOfSymbol(promiseConstructor); - if (!checkTypeAssignableTo(promiseConstructorType, globalPromiseConstructorLikeType, node, ts.Diagnostics.Type_0_is_not_a_valid_async_function_return_type)) { - return unknownType; - } - // Verify there is no local declaration that could collide with the promise constructor. - var promiseName = ts.getEntityNameFromTypeNode(node.type); - var root = getFirstIdentifier(promiseName); - var rootSymbol = getSymbol(node.locals, root.text, 107455 /* Value */); - if (rootSymbol) { - error(rootSymbol.valueDeclaration, ts.Diagnostics.Duplicate_identifier_0_Compiler_uses_declaration_1_to_support_async_functions, root.text, getFullyQualifiedName(promiseConstructor)); - return unknownType; - } - // Get and return the awaited type of the return type. - return checkAwaitedType(promiseType, node, ts.Diagnostics.An_async_function_or_method_must_have_a_valid_awaitable_return_type); - } - /** Check a decorator */ - function checkDecorator(node) { - var signature = getResolvedSignature(node); - var returnType = getReturnTypeOfSignature(signature); - if (returnType.flags & 1 /* Any */) { - return; - } - var expectedReturnType; - var headMessage = getDiagnosticHeadMessageForDecoratorResolution(node); - var errorInfo; - switch (node.parent.kind) { - case 214 /* ClassDeclaration */: - var classSymbol = getSymbolOfNode(node.parent); - var classConstructorType = getTypeOfSymbol(classSymbol); - expectedReturnType = getUnionType([classConstructorType, voidType]); - break; - case 138 /* Parameter */: - expectedReturnType = voidType; - errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.The_return_type_of_a_parameter_decorator_function_must_be_either_void_or_any); - break; - case 141 /* PropertyDeclaration */: - expectedReturnType = voidType; - errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.The_return_type_of_a_property_decorator_function_must_be_either_void_or_any); - break; - case 143 /* MethodDeclaration */: - case 145 /* GetAccessor */: - case 146 /* SetAccessor */: - var methodType = getTypeOfNode(node.parent); - var descriptorType = createTypedPropertyDescriptorType(methodType); - expectedReturnType = getUnionType([descriptorType, voidType]); - break; - } - checkTypeAssignableTo(returnType, expectedReturnType, node, headMessage, errorInfo); - } - /** Checks a type reference node as an expression. */ - function checkTypeNodeAsExpression(node) { - // 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 === 151 /* TypeReference */) { - var root = getFirstIdentifier(node.typeName); - var meaning = root.parent.kind === 151 /* TypeReference */ ? 793056 /* Type */ : 1536 /* Namespace */; - // Resolve type so we know which symbol is referenced - var rootSymbol = resolveName(root, root.text, meaning | 8388608 /* Alias */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined); - // Resolved symbol is alias - if (rootSymbol && rootSymbol.flags & 8388608 /* Alias */) { - var aliasTarget = resolveAlias(rootSymbol); - // If alias has value symbol - mark alias as referenced - if (aliasTarget.flags & 107455 /* Value */ && !isConstEnumOrConstEnumOnlyModule(resolveAlias(rootSymbol))) { - markAliasSymbolAsReferenced(rootSymbol); - } - } - } - } - /** - * Checks the type annotation of an accessor declaration or property declaration as - * an expression if it is a type reference to a type with a value declaration. - */ - function checkTypeAnnotationAsExpression(node) { - switch (node.kind) { - case 141 /* PropertyDeclaration */: - checkTypeNodeAsExpression(node.type); - break; - case 138 /* Parameter */: - checkTypeNodeAsExpression(node.type); - break; - case 143 /* MethodDeclaration */: - checkTypeNodeAsExpression(node.type); - break; - case 145 /* GetAccessor */: - checkTypeNodeAsExpression(node.type); - break; - case 146 /* SetAccessor */: - checkTypeNodeAsExpression(ts.getSetAccessorTypeAnnotationNode(node)); - break; - } - } - /** Checks the type annotation of the parameters of a function/method or the constructor of a class as expressions */ - function checkParameterTypeAnnotationsAsExpressions(node) { - // ensure all type annotations with a value declaration are checked as an expression - for (var _i = 0, _a = node.parameters; _i < _a.length; _i++) { - var parameter = _a[_i]; - checkTypeAnnotationAsExpression(parameter); - } - } - /** Check the decorators of a node */ - function checkDecorators(node) { - if (!node.decorators) { - return; - } - // skip this check for nodes that cannot have decorators. These should have already had an error reported by - // checkGrammarDecorators. - if (!ts.nodeCanBeDecorated(node)) { - return; - } - if (!compilerOptions.experimentalDecorators) { - error(node, ts.Diagnostics.Experimental_support_for_decorators_is_a_feature_that_is_subject_to_change_in_a_future_release_Specify_experimentalDecorators_to_remove_this_warning); - } - 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 214 /* ClassDeclaration */: - var constructor = ts.getFirstConstructorWithBody(node); - if (constructor) { - checkParameterTypeAnnotationsAsExpressions(constructor); - } - break; - case 143 /* MethodDeclaration */: - checkParameterTypeAnnotationsAsExpressions(node); - // fall-through - case 146 /* SetAccessor */: - case 145 /* GetAccessor */: - case 141 /* PropertyDeclaration */: - case 138 /* Parameter */: - checkTypeAnnotationAsExpression(node); - break; - } - } - emitDecorate = true; - if (node.kind === 138 /* Parameter */) { - emitParam = true; - } - ts.forEach(node.decorators, checkDecorator); - } - function checkFunctionDeclaration(node) { - if (produceDiagnostics) { - checkFunctionLikeDeclaration(node) || checkGrammarForGenerator(node); - checkCollisionWithCapturedSuperVariable(node, node.name); - checkCollisionWithCapturedThisVariable(node, node.name); - checkCollisionWithRequireExportsInGeneratedCode(node, node.name); - } - } - function checkFunctionLikeDeclaration(node) { - checkDecorators(node); - checkSignatureDeclaration(node); - var isAsync = ts.isAsyncFunctionLike(node); - if (isAsync) { - emitAwaiter = true; - } - // Do not use hasDynamicName here, because that returns false for well known symbols. - // We want to perform checkComputedPropertyName for all computed properties, including - // well known symbols. - if (node.name && node.name.kind === 136 /* ComputedPropertyName */) { - // This check will account for methods in class/interface declarations, - // as well as accessors in classes/object literals - checkComputedPropertyName(node.name); - } - if (!ts.hasDynamicName(node)) { - // first we want to check the local symbol that contain this declaration - // - if node.localSymbol !== undefined - this is current declaration is exported and localSymbol points to the local symbol - // - if node.localSymbol === undefined - this node is non-exported so we can just pick the result of getSymbolOfNode - var symbol = getSymbolOfNode(node); - var localSymbol = node.localSymbol || symbol; - var firstDeclaration = ts.getDeclarationOfKind(localSymbol, node.kind); - // Only type check the symbol once - if (node === firstDeclaration) { - checkFunctionOrConstructorSymbol(localSymbol); - } - if (symbol.parent) { - // run check once for the first declaration - if (ts.getDeclarationOfKind(symbol, node.kind) === node) { - // run check on export symbol to check that modifiers agree across all exported declarations - checkFunctionOrConstructorSymbol(symbol); - } - } - } - checkSourceElement(node.body); - if (node.type && !isAccessor(node.kind) && !node.asteriskToken) { - var returnType = getTypeFromTypeNode(node.type); - var promisedType; - if (isAsync) { - promisedType = checkAsyncFunctionReturnType(node); - } - checkIfNonVoidFunctionHasReturnExpressionsOrSingleThrowStatment(node, isAsync ? promisedType : returnType); - } - if (produceDiagnostics && !node.type) { - // Report an implicit any error if there is no body, no explicit return type, and node is not a private method - // in an ambient context - if (compilerOptions.noImplicitAny && ts.nodeIsMissing(node.body) && !isPrivateWithinAmbient(node)) { - reportImplicitAnyError(node, anyType); - } - if (node.asteriskToken && ts.nodeIsPresent(node.body)) { - // A generator with a body and no type annotation can still cause errors. It can error if the - // yielded values have no common supertype, or it can give an implicit any error if it has no - // yielded values. The only way to trigger these errors is to try checking its return type. - getReturnTypeOfSignature(getSignatureFromDeclaration(node)); - } - } - } - function checkBlock(node) { - // Grammar checking for SyntaxKind.Block - if (node.kind === 192 /* Block */) { - checkGrammarStatementInAmbientContext(node); - } - ts.forEach(node.statements, checkSourceElement); - if (ts.isFunctionBlock(node) || node.kind === 219 /* ModuleBlock */) { - checkFunctionAndClassExpressionBodies(node); - } - } - function checkCollisionWithArgumentsInGeneratedCode(node) { - // no rest parameters \ declaration context \ overload - no codegen impact - if (!ts.hasRestParameter(node) || ts.isInAmbientContext(node) || ts.nodeIsMissing(node.body)) { - return; - } - ts.forEach(node.parameters, function (p) { - if (p.name && !ts.isBindingPattern(p.name) && p.name.text === argumentsSymbol.name) { - error(p, ts.Diagnostics.Duplicate_identifier_arguments_Compiler_uses_arguments_to_initialize_rest_parameters); - } - }); - } - function needCollisionCheckForIdentifier(node, identifier, name) { - if (!(identifier && identifier.text === name)) { - return false; - } - if (node.kind === 141 /* PropertyDeclaration */ || - node.kind === 140 /* PropertySignature */ || - node.kind === 143 /* MethodDeclaration */ || - node.kind === 142 /* MethodSignature */ || - node.kind === 145 /* GetAccessor */ || - node.kind === 146 /* SetAccessor */) { - // it is ok to have member named '_super' or '_this' - member access is always qualified - return false; - } - if (ts.isInAmbientContext(node)) { - // ambient context - no codegen impact - return false; - } - var root = ts.getRootDeclaration(node); - if (root.kind === 138 /* Parameter */ && ts.nodeIsMissing(root.parent.body)) { - // just an overload - no codegen impact - return false; - } - return true; - } - function checkCollisionWithCapturedThisVariable(node, name) { - if (needCollisionCheckForIdentifier(node, name, "_this")) { - potentialThisCollisions.push(node); - } - } - // this function will run after checking the source file so 'CaptureThis' is correct for all nodes - function checkIfThisIsCapturedInEnclosingScope(node) { - var current = node; - while (current) { - if (getNodeCheckFlags(current) & 4 /* CaptureThis */) { - var isDeclaration_1 = node.kind !== 69 /* Identifier */; - if (isDeclaration_1) { - error(node.name, ts.Diagnostics.Duplicate_identifier_this_Compiler_uses_variable_declaration_this_to_capture_this_reference); - } - else { - error(node, ts.Diagnostics.Expression_resolves_to_variable_declaration_this_that_compiler_uses_to_capture_this_reference); - } - return; - } - current = current.parent; - } - } - function checkCollisionWithCapturedSuperVariable(node, name) { - if (!needCollisionCheckForIdentifier(node, name, "_super")) { - return; - } - // bubble up and find containing type - var enclosingClass = ts.getContainingClass(node); - // if containing type was not found or it is ambient - exit (no codegen) - if (!enclosingClass || ts.isInAmbientContext(enclosingClass)) { - return; - } - if (ts.getClassExtendsHeritageClauseElement(enclosingClass)) { - var isDeclaration_2 = node.kind !== 69 /* Identifier */; - if (isDeclaration_2) { - error(node, ts.Diagnostics.Duplicate_identifier_super_Compiler_uses_super_to_capture_base_class_reference); - } - else { - error(node, ts.Diagnostics.Expression_resolves_to_super_that_compiler_uses_to_capture_base_class_reference); - } - } - } - function checkCollisionWithRequireExportsInGeneratedCode(node, name) { - if (!needCollisionCheckForIdentifier(node, name, "require") && !needCollisionCheckForIdentifier(node, name, "exports")) { - return; - } - // Uninstantiated modules shouldnt do this check - if (node.kind === 218 /* ModuleDeclaration */ && ts.getModuleInstanceState(node) !== 1 /* Instantiated */) { - return; - } - // In case of variable declaration, node.parent is variable statement so look at the variable statement's parent - var parent = getDeclarationContainer(node); - if (parent.kind === 248 /* SourceFile */ && ts.isExternalModule(parent)) { - // If the declaration happens to be in external module, report error that require and exports are reserved keywords - error(name, ts.Diagnostics.Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module, ts.declarationNameToString(name), ts.declarationNameToString(name)); - } - } - function checkVarDeclaredNamesNotShadowed(node) { - // - ScriptBody : StatementList - // It is a Syntax Error if any element of the LexicallyDeclaredNames of StatementList - // also occurs in the VarDeclaredNames of StatementList. - // - Block : { StatementList } - // It is a Syntax Error if any element of the LexicallyDeclaredNames of StatementList - // also occurs in the VarDeclaredNames of StatementList. - // Variable declarations are hoisted to the top of their function scope. They can shadow - // block scoped declarations, which bind tighter. this will not be flagged as duplicate definition - // by the binder as the declaration scope is different. - // A non-initialized declaration is a no-op as the block declaration will resolve before the var - // declaration. the problem is if the declaration has an initializer. this will act as a write to the - // block declared value. this is fine for let, but not const. - // Only consider declarations with initializers, uninitialized let declarations will not - // step on a let/const variable. - // Do not consider let and const declarations, as duplicate block-scoped declarations - // are handled by the binder. - // We are only looking for let declarations that step on let\const declarations from a - // different scope. e.g.: - // { - // const x = 0; // localDeclarationSymbol obtained after name resolution will correspond to this declaration - // let x = 0; // symbol for this declaration will be 'symbol' - // } - // skip block-scoped variables and parameters - if ((ts.getCombinedNodeFlags(node) & 49152 /* BlockScoped */) !== 0 || ts.isParameterDeclaration(node)) { - return; - } - // 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 === 211 /* VariableDeclaration */ && !node.initializer) { - return; - } - var symbol = getSymbolOfNode(node); - if (symbol.flags & 1 /* FunctionScopedVariable */) { - var localDeclarationSymbol = resolveName(node, node.name.text, 3 /* Variable */, /*nodeNotFoundErrorMessage*/ undefined, /*nameArg*/ undefined); - if (localDeclarationSymbol && - localDeclarationSymbol !== symbol && - localDeclarationSymbol.flags & 2 /* BlockScopedVariable */) { - if (getDeclarationFlagsFromSymbol(localDeclarationSymbol) & 49152 /* BlockScoped */) { - var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 212 /* VariableDeclarationList */); - var container = varDeclList.parent.kind === 193 /* VariableStatement */ && varDeclList.parent.parent - ? varDeclList.parent.parent - : undefined; - // names of block-scoped and function scoped variables can collide only - // if block scoped variable is defined in the function\module\source file scope (because of variable hoisting) - var namesShareScope = container && - (container.kind === 192 /* Block */ && ts.isFunctionLike(container.parent) || - container.kind === 219 /* ModuleBlock */ || - container.kind === 218 /* ModuleDeclaration */ || - container.kind === 248 /* SourceFile */); - // here we know that function scoped variable is shadowed by block scoped one - // if they are defined in the same scope - binder has already reported redeclaration error - // otherwise if variable has an initializer - show error that initialization will fail - // since LHS will be block scoped name instead of function scoped - if (!namesShareScope) { - var name_14 = symbolToString(localDeclarationSymbol); - error(node, ts.Diagnostics.Cannot_initialize_outer_scoped_variable_0_in_the_same_scope_as_block_scoped_declaration_1, name_14, name_14); - } - } - } - } - } - // Check that a parameter initializer contains no references to parameters declared to the right of itself - function checkParameterInitializer(node) { - if (ts.getRootDeclaration(node).kind !== 138 /* Parameter */) { - return; - } - var func = ts.getContainingFunction(node); - visit(node.initializer); - function visit(n) { - if (n.kind === 69 /* Identifier */) { - var referencedSymbol = getNodeLinks(n).resolvedSymbol; - // check FunctionLikeDeclaration.locals (stores parameters\function local variable) - // if it contains entry with a specified name and if this entry matches the resolved symbol - if (referencedSymbol && referencedSymbol !== unknownSymbol && getSymbol(func.locals, referencedSymbol.name, 107455 /* Value */) === referencedSymbol) { - if (referencedSymbol.valueDeclaration.kind === 138 /* Parameter */) { - if (referencedSymbol.valueDeclaration === node) { - error(n, ts.Diagnostics.Parameter_0_cannot_be_referenced_in_its_initializer, ts.declarationNameToString(node.name)); - return; - } - if (referencedSymbol.valueDeclaration.pos < node.pos) { - // legal case - parameter initializer references some parameter strictly on left of current parameter declaration - return; - } - } - error(n, ts.Diagnostics.Initializer_of_parameter_0_cannot_reference_identifier_1_declared_after_it, ts.declarationNameToString(node.name), ts.declarationNameToString(n)); - } - } - else { - ts.forEachChild(n, visit); - } - } - } - // Check variable, parameter, or property declaration - function checkVariableLikeDeclaration(node) { - checkDecorators(node); - checkSourceElement(node.type); - // For a computed property, just check the initializer and exit - // 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 === 136 /* ComputedPropertyName */) { - checkComputedPropertyName(node.name); - if (node.initializer) { - checkExpressionCached(node.initializer); - } - } - // For a binding pattern, check contained binding elements - if (ts.isBindingPattern(node.name)) { - 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 === 138 /* Parameter */ && ts.nodeIsMissing(ts.getContainingFunction(node).body)) { - error(node, ts.Diagnostics.A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation); - return; - } - // For a binding pattern, validate the initializer and exit - if (ts.isBindingPattern(node.name)) { - if (node.initializer) { - checkTypeAssignableTo(checkExpressionCached(node.initializer), getWidenedTypeForVariableLikeDeclaration(node), node, /*headMessage*/ undefined); - checkParameterInitializer(node); - } - return; - } - var symbol = getSymbolOfNode(node); - var type = getTypeOfVariableOrParameterOrProperty(symbol); - if (node === symbol.valueDeclaration) { - // Node is the primary declaration of the symbol, just validate the initializer - if (node.initializer) { - checkTypeAssignableTo(checkExpressionCached(node.initializer), type, node, /*headMessage*/ undefined); - checkParameterInitializer(node); - } - } - 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); - 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)); - } - if (node.initializer) { - checkTypeAssignableTo(checkExpressionCached(node.initializer), declarationType, node, /*headMessage*/ undefined); - } - } - if (node.kind !== 141 /* PropertyDeclaration */ && node.kind !== 140 /* PropertySignature */) { - // We know we don't have a binding pattern or computed name here - checkExportsOnMergedDeclarations(node); - if (node.kind === 211 /* VariableDeclaration */ || node.kind === 163 /* BindingElement */) { - checkVarDeclaredNamesNotShadowed(node); - } - checkCollisionWithCapturedSuperVariable(node, node.name); - checkCollisionWithCapturedThisVariable(node, node.name); - checkCollisionWithRequireExportsInGeneratedCode(node, node.name); - } - } - function checkVariableDeclaration(node) { - checkGrammarVariableDeclaration(node); - return checkVariableLikeDeclaration(node); - } - function checkBindingElement(node) { - checkGrammarBindingElement(node); - return checkVariableLikeDeclaration(node); - } - function checkVariableStatement(node) { - // Grammar checking - checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarVariableDeclarationList(node.declarationList) || checkGrammarForDisallowedLetOrConstStatement(node); - ts.forEach(node.declarationList.declarations, checkSourceElement); - } - 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 === 165 /* ObjectLiteralExpression */) { - if (ts.isAsyncFunctionLike(node)) { - if (node.modifiers.length > 1) { - return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); - } - } - else { - return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); - } - } - } - function checkExpressionStatement(node) { - // Grammar checking - checkGrammarStatementInAmbientContext(node); - checkExpression(node.expression); - } - function checkIfStatement(node) { - // Grammar checking - checkGrammarStatementInAmbientContext(node); - checkExpression(node.expression); - checkSourceElement(node.thenStatement); - checkSourceElement(node.elseStatement); - } - function checkDoStatement(node) { - // Grammar checking - checkGrammarStatementInAmbientContext(node); - checkSourceElement(node.statement); - checkExpression(node.expression); - } - function checkWhileStatement(node) { - // Grammar checking - checkGrammarStatementInAmbientContext(node); - checkExpression(node.expression); - checkSourceElement(node.statement); - } - function checkForStatement(node) { - // Grammar checking - if (!checkGrammarStatementInAmbientContext(node)) { - if (node.initializer && node.initializer.kind === 212 /* VariableDeclarationList */) { - checkGrammarVariableDeclarationList(node.initializer); - } - } - if (node.initializer) { - if (node.initializer.kind === 212 /* VariableDeclarationList */) { - ts.forEach(node.initializer.declarations, checkVariableDeclaration); - } - else { - checkExpression(node.initializer); - } - } - if (node.condition) - checkExpression(node.condition); - if (node.incrementor) - checkExpression(node.incrementor); - checkSourceElement(node.statement); - } - function checkForOfStatement(node) { - checkGrammarForInOrForOfStatement(node); - // Check the LHS and RHS - // If the LHS is a declaration, just check it as a variable declaration, which will in turn check the RHS - // 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 === 212 /* VariableDeclarationList */) { - checkForInOrForOfVariableDeclaration(node); - } - else { - var varExpr = node.initializer; - var iteratedType = checkRightHandSideOfForOf(node.expression); - // There may be a destructuring assignment on the left side - if (varExpr.kind === 164 /* ArrayLiteralExpression */ || varExpr.kind === 165 /* ObjectLiteralExpression */) { - // iteratedType may be undefined. In this case, we still want to check the structure of - // varExpr, in particular making sure it's a valid LeftHandSideExpression. But we'd like - // to short circuit the type relation checking as much as possible, so we pass the unknownType. - checkDestructuringAssignment(varExpr, iteratedType || unknownType); - } - else { - var leftType = checkExpression(varExpr); - checkReferenceExpression(varExpr, /*invalidReferenceMessage*/ ts.Diagnostics.Invalid_left_hand_side_in_for_of_statement, - /*constantVariableMessage*/ ts.Diagnostics.The_left_hand_side_of_a_for_of_statement_cannot_be_a_previously_defined_constant); - // iteratedType will be undefined if the rightType was missing properties/signatures - // required to get its iteratedType (like [Symbol.iterator] or next). This may be - // because we accessed properties from anyType, or it may have led to an error inside - // getElementTypeOfIterable. - if (iteratedType) { - checkTypeAssignableTo(iteratedType, leftType, varExpr, /*headMessage*/ undefined); - } - } - } - checkSourceElement(node.statement); - } - function checkForInStatement(node) { - // Grammar checking - checkGrammarForInOrForOfStatement(node); - // TypeScript 1.0 spec (April 2014): 5.4 - // In a 'for-in' statement of the form - // 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 === 212 /* VariableDeclarationList */) { - var variable = node.initializer.declarations[0]; - if (variable && ts.isBindingPattern(variable.name)) { - error(variable.name, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern); - } - checkForInOrForOfVariableDeclaration(node); - } - else { - // In a 'for-in' statement of the form - // for (Var in Expr) Statement - // Var must be an expression classified as a reference of type Any or the String primitive type, - // 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 === 164 /* ArrayLiteralExpression */ || varExpr.kind === 165 /* ObjectLiteralExpression */) { - error(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern); - } - else if (!isTypeAnyOrAllConstituentTypesHaveKind(leftType, 258 /* StringLike */)) { - error(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_must_be_of_type_string_or_any); - } - else { - // run check only former check succeeded to avoid cascading errors - checkReferenceExpression(varExpr, ts.Diagnostics.Invalid_left_hand_side_in_for_in_statement, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_previously_defined_constant); - } - } - var rightType = checkExpression(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, 80896 /* ObjectType */ | 512 /* TypeParameter */)) { - error(node.expression, ts.Diagnostics.The_right_hand_side_of_a_for_in_statement_must_be_of_type_any_an_object_type_or_a_type_parameter); - } - checkSourceElement(node.statement); - } - function checkForInOrForOfVariableDeclaration(iterationStatement) { - var variableDeclarationList = iterationStatement.initializer; - // checkGrammarForInOrForOfStatement will check that there is exactly one declaration. - if (variableDeclarationList.declarations.length >= 1) { - var decl = variableDeclarationList.declarations[0]; - checkVariableDeclaration(decl); - } - } - function checkRightHandSideOfForOf(rhsExpression) { - var expressionType = getTypeOfExpression(rhsExpression); - return checkIteratedTypeOrElementType(expressionType, rhsExpression, /*allowStringInput*/ true); - } - function checkIteratedTypeOrElementType(inputType, errorNode, allowStringInput) { - if (isTypeAny(inputType)) { - return inputType; - } - if (languageVersion >= 2 /* ES6 */) { - return checkElementTypeOfIterable(inputType, errorNode); - } - if (allowStringInput) { - return checkElementTypeOfArrayOrString(inputType, errorNode); - } - if (isArrayLikeType(inputType)) { - var indexType = getIndexTypeOfType(inputType, 1 /* Number */); - if (indexType) { - return indexType; - } - } - error(errorNode, ts.Diagnostics.Type_0_is_not_an_array_type, typeToString(inputType)); - return unknownType; - } - /** - * When errorNode is undefined, it means we should not report any errors. - */ - function checkElementTypeOfIterable(iterable, errorNode) { - var elementType = getElementTypeOfIterable(iterable, errorNode); - // Now even though we have extracted the iteratedType, we will have to validate that the type - // passed in is actually an Iterable. - if (errorNode && elementType) { - checkTypeAssignableTo(iterable, createIterableType(elementType), errorNode); - } - return elementType || anyType; - } - /** - * We want to treat type as an iterable, and get the type it is an iterable of. The iterable - * must have the following structure (annotated with the names of the variables below): - * - * { // iterable - * [Symbol.iterator]: { // iteratorFunction - * (): Iterator - * } - * } - * - * T is the type we are after. At every level that involves analyzing return types - * of signatures, we union the return types of all the signatures. - * - * Another thing to note is that at any step of this process, we could run into a dead end, - * meaning either the property is missing, or we run into the anyType. If either of these things - * happens, we return undefined to signal that we could not find the iterated type. If a property - * is missing, and the previous step did not result in 'any', then we also give an error if the - * caller requested it. Then the caller can decide what to do in the case where there is no iterated - * type. This is different from returning anyType, because that would signify that we have matched the - * whole pattern and that T (above) is 'any'. - */ - function getElementTypeOfIterable(type, errorNode) { - if (isTypeAny(type)) { - return undefined; - } - var typeAsIterable = type; - 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 & 4096 /* Reference */) && type.target === globalIterableType) { - typeAsIterable.iterableElementType = type.typeArguments[0]; - } - else { - var iteratorFunction = getTypeOfPropertyOfType(type, ts.getPropertyNameForKnownSymbolName("iterator")); - if (isTypeAny(iteratorFunction)) { - return undefined; - } - var iteratorFunctionSignatures = iteratorFunction ? getSignaturesOfType(iteratorFunction, 0 /* Call */) : emptyArray; - if (iteratorFunctionSignatures.length === 0) { - if (errorNode) { - error(errorNode, ts.Diagnostics.Type_must_have_a_Symbol_iterator_method_that_returns_an_iterator); - } - return undefined; - } - typeAsIterable.iterableElementType = getElementTypeOfIterator(getUnionType(ts.map(iteratorFunctionSignatures, getReturnTypeOfSignature)), errorNode); - } - } - return typeAsIterable.iterableElementType; - } - /** - * This function has very similar logic as getElementTypeOfIterable, except that it operates on - * Iterators instead of Iterables. Here is the structure: - * - * { // iterator - * next: { // iteratorNextFunction - * (): { // iteratorNextResult - * value: T // iteratorNextValue - * } - * } - * } - * - */ - function getElementTypeOfIterator(type, errorNode) { - if (isTypeAny(type)) { - return undefined; - } - var typeAsIterator = type; - 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 & 4096 /* Reference */) && type.target === globalIteratorType) { - typeAsIterator.iteratorElementType = type.typeArguments[0]; - } - else { - var iteratorNextFunction = getTypeOfPropertyOfType(type, "next"); - if (isTypeAny(iteratorNextFunction)) { - return undefined; - } - var iteratorNextFunctionSignatures = iteratorNextFunction ? getSignaturesOfType(iteratorNextFunction, 0 /* Call */) : emptyArray; - if (iteratorNextFunctionSignatures.length === 0) { - if (errorNode) { - error(errorNode, ts.Diagnostics.An_iterator_must_have_a_next_method); - } - return undefined; - } - var iteratorNextResult = getUnionType(ts.map(iteratorNextFunctionSignatures, getReturnTypeOfSignature)); - if (isTypeAny(iteratorNextResult)) { - return undefined; - } - var iteratorNextValue = getTypeOfPropertyOfType(iteratorNextResult, "value"); - if (!iteratorNextValue) { - if (errorNode) { - error(errorNode, ts.Diagnostics.The_type_returned_by_the_next_method_of_an_iterator_must_have_a_value_property); - } - return undefined; - } - typeAsIterator.iteratorElementType = iteratorNextValue; - } - } - return typeAsIterator.iteratorElementType; - } - function getElementTypeOfIterableIterator(type) { - if (isTypeAny(type)) { - return undefined; - } - // As an optimization, if the type is instantiated directly using the globalIterableIteratorType (IterableIterator), - // then just grab its type argument. - if ((type.flags & 4096 /* Reference */) && type.target === globalIterableIteratorType) { - return type.typeArguments[0]; - } - return getElementTypeOfIterable(type, /*errorNode*/ undefined) || - getElementTypeOfIterator(type, /*errorNode*/ undefined); - } - /** - * This function does the following steps: - * 1. Break up arrayOrStringType (possibly a union) into its string constituents and array constituents. - * 2. Take the element types of the array constituents. - * 3. Return the union of the element types, and string if there was a string constitutent. - * - * For example: - * string -> string - * number[] -> number - * string[] | number[] -> string | number - * string | number[] -> string | number - * string | string[] | number[] -> string | number - * - * It also errors if: - * 1. Some constituent is neither a string nor an array. - * 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 */); - // 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 = removeTypesFromUnionType(arrayOrStringType, 258 /* StringLike */, /*isTypeOfKind*/ true, /*allowEmptyUnionResult*/ true); - var hasStringConstituent = arrayOrStringType !== arrayType; - var reportedError = false; - if (hasStringConstituent) { - if (languageVersion < 1 /* ES5 */) { - error(errorNode, ts.Diagnostics.Using_a_string_in_a_for_of_statement_is_only_supported_in_ECMAScript_5_and_higher); - reportedError = true; - } - // Now that we've removed all the StringLike types, if no constituents remain, then the entire - // arrayOrStringType was a string. - if (arrayType === emptyObjectType) { - return stringType; - } - } - if (!isArrayLikeType(arrayType)) { - if (!reportedError) { - // Which error we report depends on whether there was a string constituent. For example, - // if the input type is number | string, we want to say that number is not an array type. - // But if the input was just number, we want to say that number is not an array type - // or a string type. - var diagnostic = hasStringConstituent - ? ts.Diagnostics.Type_0_is_not_an_array_type - : ts.Diagnostics.Type_0_is_not_an_array_type_or_a_string_type; - error(errorNode, diagnostic, typeToString(arrayType)); - } - return hasStringConstituent ? stringType : unknownType; - } - var arrayElementType = getIndexTypeOfType(arrayType, 1 /* Number */) || unknownType; - if (hasStringConstituent) { - // This is just an optimization for the case where arrayOrStringType is string | string[] - if (arrayElementType.flags & 258 /* StringLike */) { - return stringType; - } - return getUnionType([arrayElementType, stringType]); - } - return arrayElementType; - } - function checkBreakOrContinueStatement(node) { - // Grammar checking - checkGrammarStatementInAmbientContext(node) || checkGrammarBreakOrContinueStatement(node); - // TODO: Check that target label is valid - } - function isGetAccessorWithAnnotatatedSetAccessor(node) { - return !!(node.kind === 145 /* GetAccessor */ && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(node.symbol, 146 /* SetAccessor */))); - } - function checkReturnStatement(node) { - // Grammar checking - if (!checkGrammarStatementInAmbientContext(node)) { - var functionBlock = ts.getContainingFunction(node); - if (!functionBlock) { - grammarErrorOnFirstToken(node, ts.Diagnostics.A_return_statement_can_only_be_used_within_a_function_body); - } - } - if (node.expression) { - var func = ts.getContainingFunction(node); - if (func) { - var signature = getSignatureFromDeclaration(func); - var returnType = getReturnTypeOfSignature(signature); - var exprType = checkExpressionCached(node.expression); - if (func.asteriskToken) { - // A generator does not need its return expressions checked against its return type. - // Instead, the yield expressions are checked against the element type. - // TODO: Check return expressions of generators when return type tracking is added - // for generators. - return; - } - if (func.kind === 146 /* SetAccessor */) { - error(node.expression, ts.Diagnostics.Setters_cannot_return_a_value); - } - else if (func.kind === 144 /* Constructor */) { - if (!isTypeAssignableTo(exprType, returnType)) { - error(node.expression, ts.Diagnostics.Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class); - } - } - else if (func.type || isGetAccessorWithAnnotatatedSetAccessor(func) || signature.typePredicate) { - if (ts.isAsyncFunctionLike(func)) { - var promisedType = getPromisedType(returnType); - var awaitedType = checkAwaitedType(exprType, node.expression, ts.Diagnostics.Return_expression_in_async_function_does_not_have_a_valid_callable_then_member); - if (promisedType) { - // If the function has a return type, but promisedType is - // undefined, an error will be reported in checkAsyncFunctionReturnType - // so we don't need to report one here. - checkTypeAssignableTo(awaitedType, promisedType, node.expression); - } - } - else { - checkTypeAssignableTo(exprType, returnType, node.expression); - } - } - } - } - } - function checkWithStatement(node) { - // Grammar checking for withStatement - if (!checkGrammarStatementInAmbientContext(node)) { - if (node.parserContextFlags & 8 /* Await */) { - grammarErrorOnFirstToken(node, ts.Diagnostics.with_statements_are_not_allowed_in_an_async_function_block); - } - } - checkExpression(node.expression); - error(node.expression, ts.Diagnostics.All_symbols_within_a_with_block_will_be_resolved_to_any); - } - function checkSwitchStatement(node) { - // Grammar checking - checkGrammarStatementInAmbientContext(node); - var firstDefaultClause; - var hasDuplicateDefaultClause = false; - var expressionType = checkExpression(node.expression); - ts.forEach(node.caseBlock.clauses, function (clause) { - // Grammar check for duplicate default clauses, skip if we already report duplicate default clause - if (clause.kind === 242 /* DefaultClause */ && !hasDuplicateDefaultClause) { - if (firstDefaultClause === undefined) { - firstDefaultClause = clause; - } - else { - var sourceFile = ts.getSourceFileOfNode(node); - var start = ts.skipTrivia(sourceFile.text, clause.pos); - var end = clause.statements.length > 0 ? clause.statements[0].pos : clause.end; - grammarErrorAtPos(sourceFile, start, end - start, ts.Diagnostics.A_default_clause_cannot_appear_more_than_once_in_a_switch_statement); - hasDuplicateDefaultClause = true; - } - } - if (produceDiagnostics && clause.kind === 241 /* CaseClause */) { - var caseClause = clause; - // TypeScript 1.0 spec (April 2014):5.9 - // In a 'switch' statement, each 'case' expression must be of a type that is assignable to or from the type of the 'switch' expression. - var caseType = checkExpression(caseClause.expression); - if (!isTypeAssignableTo(expressionType, caseType)) { - // check 'expressionType isAssignableTo caseType' failed, try the reversed check and report errors if it fails - checkTypeAssignableTo(caseType, expressionType, caseClause.expression, /*headMessage*/ undefined); - } - } - ts.forEach(clause.statements, checkSourceElement); - }); - } - function checkLabeledStatement(node) { - // Grammar checking - if (!checkGrammarStatementInAmbientContext(node)) { - var current = node.parent; - while (current) { - if (ts.isFunctionLike(current)) { - break; - } - if (current.kind === 207 /* LabeledStatement */ && current.label.text === node.label.text) { - var sourceFile = ts.getSourceFileOfNode(node); - grammarErrorOnNode(node.label, ts.Diagnostics.Duplicate_label_0, ts.getTextOfNodeFromSourceText(sourceFile.text, node.label)); - break; - } - current = current.parent; - } - } - // ensure that label is unique - checkSourceElement(node.statement); - } - function checkThrowStatement(node) { - // Grammar checking - if (!checkGrammarStatementInAmbientContext(node)) { - if (node.expression === undefined) { - grammarErrorAfterFirstToken(node, ts.Diagnostics.Line_break_not_permitted_here); - } - } - if (node.expression) { - checkExpression(node.expression); - } - } - function checkTryStatement(node) { - // Grammar checking - checkGrammarStatementInAmbientContext(node); - checkBlock(node.tryBlock); - var catchClause = node.catchClause; - if (catchClause) { - // Grammar checking - if (catchClause.variableDeclaration) { - if (catchClause.variableDeclaration.name.kind !== 69 /* Identifier */) { - grammarErrorOnFirstToken(catchClause.variableDeclaration.name, ts.Diagnostics.Catch_clause_variable_name_must_be_an_identifier); - } - else if (catchClause.variableDeclaration.type) { - grammarErrorOnFirstToken(catchClause.variableDeclaration.type, ts.Diagnostics.Catch_clause_variable_cannot_have_a_type_annotation); - } - else if (catchClause.variableDeclaration.initializer) { - grammarErrorOnFirstToken(catchClause.variableDeclaration.initializer, ts.Diagnostics.Catch_clause_variable_cannot_have_an_initializer); - } - else { - var identifierName = catchClause.variableDeclaration.name.text; - var locals = catchClause.block.locals; - if (locals && ts.hasProperty(locals, identifierName)) { - var localSymbol = locals[identifierName]; - if (localSymbol && (localSymbol.flags & 2 /* BlockScopedVariable */) !== 0) { - grammarErrorOnNode(localSymbol.valueDeclaration, ts.Diagnostics.Cannot_redeclare_identifier_0_in_catch_clause, identifierName); - } - } - } - } - checkBlock(catchClause.block); - } - if (node.finallyBlock) { - checkBlock(node.finallyBlock); - } - } - function checkIndexConstraints(type) { - var declaredNumberIndexer = getIndexDeclarationOfSymbol(type.symbol, 1 /* Number */); - var declaredStringIndexer = getIndexDeclarationOfSymbol(type.symbol, 0 /* String */); - var stringIndexType = getIndexTypeOfType(type, 0 /* String */); - var numberIndexType = getIndexTypeOfType(type, 1 /* Number */); - if (stringIndexType || numberIndexType) { - ts.forEach(getPropertiesOfObjectType(type), function (prop) { - var propType = getTypeOfSymbol(prop); - checkIndexConstraintForProperty(prop, propType, type, declaredStringIndexer, stringIndexType, 0 /* String */); - checkIndexConstraintForProperty(prop, propType, type, declaredNumberIndexer, numberIndexType, 1 /* Number */); - }); - if (type.flags & 1024 /* Class */ && ts.isClassLike(type.symbol.valueDeclaration)) { - var classDeclaration = type.symbol.valueDeclaration; - for (var _i = 0, _a = classDeclaration.members; _i < _a.length; _i++) { - var member = _a[_i]; - // Only process instance properties with computed names here. - // Static properties cannot be in conflict with indexers, - // and properties with literal names were already checked. - if (!(member.flags & 128 /* Static */) && ts.hasDynamicName(member)) { - var propType = getTypeOfSymbol(member.symbol); - checkIndexConstraintForProperty(member.symbol, propType, type, declaredStringIndexer, stringIndexType, 0 /* String */); - checkIndexConstraintForProperty(member.symbol, propType, type, declaredNumberIndexer, numberIndexType, 1 /* Number */); - } - } - } - } - var errorNode; - 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 & 2048 /* Interface */)) { - var someBaseTypeHasBothIndexers = ts.forEach(getBaseTypes(type), function (base) { return getIndexTypeOfType(base, 0 /* String */) && getIndexTypeOfType(base, 1 /* Number */); }); - errorNode = someBaseTypeHasBothIndexers ? undefined : type.symbol.declarations[0]; - } - } - if (errorNode && !isTypeAssignableTo(numberIndexType, stringIndexType)) { - error(errorNode, ts.Diagnostics.Numeric_index_type_0_is_not_assignable_to_string_index_type_1, typeToString(numberIndexType), typeToString(stringIndexType)); - } - function checkIndexConstraintForProperty(prop, propertyType, containingType, indexDeclaration, indexType, indexKind) { - if (!indexType) { - return; - } - // index is numeric and property name is not valid numeric literal - if (indexKind === 1 /* Number */ && !isNumericName(prop.valueDeclaration.name)) { - return; - } - // 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 === 136 /* ComputedPropertyName */ || prop.parent === containingType.symbol) { - errorNode = prop.valueDeclaration; - } - else if (indexDeclaration) { - errorNode = indexDeclaration; - } - else if (containingType.flags & 2048 /* 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 - var someBaseClassHasBothPropertyAndIndexer = ts.forEach(getBaseTypes(containingType), function (base) { return getPropertyOfObjectType(base, prop.name) && getIndexTypeOfType(base, indexKind); }); - errorNode = someBaseClassHasBothPropertyAndIndexer ? undefined : containingType.symbol.declarations[0]; - } - if (errorNode && !isTypeAssignableTo(propertyType, indexType)) { - var errorMessage = indexKind === 0 /* String */ - ? ts.Diagnostics.Property_0_of_type_1_is_not_assignable_to_string_index_type_2 - : ts.Diagnostics.Property_0_of_type_1_is_not_assignable_to_numeric_index_type_2; - error(errorNode, errorMessage, symbolToString(prop), typeToString(propertyType), typeToString(indexType)); - } - } - } - function checkTypeNameIsReserved(name, message) { - // TS 1.0 spec (April 2014): 3.6.1 - // The predefined type keywords are reserved and cannot be used as names of user defined types. - switch (name.text) { - case "any": - case "number": - case "boolean": - case "string": - case "symbol": - case "void": - error(name, message, name.text); - } - } - // Check each type parameter and check that list has no duplicate type parameter declarations - function checkTypeParameters(typeParameterDeclarations) { - if (typeParameterDeclarations) { - for (var i = 0, n = typeParameterDeclarations.length; i < n; i++) { - var node = typeParameterDeclarations[i]; - checkTypeParameter(node); - if (produceDiagnostics) { - for (var j = 0; j < i; j++) { - if (typeParameterDeclarations[j].symbol === node.symbol) { - error(node.name, ts.Diagnostics.Duplicate_identifier_0, ts.declarationNameToString(node.name)); - } - } - } - } - } - } - function checkClassExpression(node) { - checkClassLikeDeclaration(node); - return getTypeOfSymbol(getSymbolOfNode(node)); - } - function checkClassDeclaration(node) { - if (!node.name && !(node.flags & 1024 /* Default */)) { - grammarErrorOnFirstToken(node, ts.Diagnostics.A_class_declaration_without_the_default_modifier_must_have_a_name); - } - checkClassLikeDeclaration(node); - ts.forEach(node.members, checkSourceElement); - } - function checkClassLikeDeclaration(node) { - checkGrammarClassDeclarationHeritageClauses(node); - checkDecorators(node); - if (node.name) { - checkTypeNameIsReserved(node.name, ts.Diagnostics.Class_name_cannot_be_0); - checkCollisionWithCapturedThisVariable(node, node.name); - checkCollisionWithRequireExportsInGeneratedCode(node, node.name); - } - checkTypeParameters(node.typeParameters); - checkExportsOnMergedDeclarations(node); - var symbol = getSymbolOfNode(node); - var type = getDeclaredTypeOfSymbol(symbol); - var typeWithThis = getTypeWithThisArgument(type); - var staticType = getTypeOfSymbol(symbol); - var baseTypeNode = ts.getClassExtendsHeritageClauseElement(node); - if (baseTypeNode) { - emitExtends = emitExtends || !ts.isInAmbientContext(node); - var baseTypes = getBaseTypes(type); - if (baseTypes.length && produceDiagnostics) { - var baseType = baseTypes[0]; - var staticBaseType = getBaseConstructorTypeOfClass(type); - checkSourceElement(baseTypeNode.expression); - if (baseTypeNode.typeArguments) { - ts.forEach(baseTypeNode.typeArguments, checkSourceElement); - for (var _i = 0, _a = getConstructorsForTypeArguments(staticBaseType, baseTypeNode.typeArguments); _i < _a.length; _i++) { - var constructor = _a[_i]; - if (!checkTypeArgumentConstraints(constructor.typeParameters, baseTypeNode.typeArguments)) { - break; - } - } - } - checkTypeAssignableTo(typeWithThis, getTypeWithThisArgument(baseType, type.thisType), node.name || node, ts.Diagnostics.Class_0_incorrectly_extends_base_class_1); - checkTypeAssignableTo(staticType, getTypeWithoutSignatures(staticBaseType), node.name || node, ts.Diagnostics.Class_static_side_0_incorrectly_extends_base_class_static_side_1); - if (!(staticBaseType.symbol && staticBaseType.symbol.flags & 32 /* Class */)) { - // When the static base type is a "class-like" constructor function (but not actually a class), we verify - // that all instantiated base constructor signatures return the same type. We can simply compare the type - // references (as opposed to checking the structure of the types) because elsewhere we have already checked - // that the base type is a class or interface type (and not, for example, an anonymous object type). - var constructors = getInstantiatedConstructorsForTypeArguments(staticBaseType, baseTypeNode.typeArguments); - if (ts.forEach(constructors, function (sig) { return getReturnTypeOfSignature(sig) !== baseType; })) { - error(baseTypeNode.expression, ts.Diagnostics.Base_constructors_must_all_have_the_same_return_type); - } - } - checkKindsOfPropertyMemberOverrides(type, baseType); - } - } - var implementedTypeNodes = ts.getClassImplementsHeritageClauseElements(node); - if (implementedTypeNodes) { - for (var _b = 0; _b < implementedTypeNodes.length; _b++) { - var typeRefNode = implementedTypeNodes[_b]; - if (!ts.isSupportedExpressionWithTypeArguments(typeRefNode)) { - error(typeRefNode.expression, ts.Diagnostics.A_class_can_only_implement_an_identifier_Slashqualified_name_with_optional_type_arguments); - } - checkTypeReferenceNode(typeRefNode); - if (produceDiagnostics) { - var t = getTypeFromTypeNode(typeRefNode); - if (t !== unknownType) { - var declaredType = (t.flags & 4096 /* Reference */) ? t.target : t; - if (declaredType.flags & (1024 /* Class */ | 2048 /* Interface */)) { - checkTypeAssignableTo(typeWithThis, getTypeWithThisArgument(t, type.thisType), node.name || node, ts.Diagnostics.Class_0_incorrectly_implements_interface_1); - } - else { - error(typeRefNode, ts.Diagnostics.A_class_may_only_implement_another_class_or_interface); - } - } - } - } - } - if (produceDiagnostics) { - checkIndexConstraints(type); - checkTypeForDuplicateIndexSignatures(node); - } - } - function getTargetSymbol(s) { - // if symbol is instantiated its flags are not copied from the 'target' - // so we'll need to get back original 'target' symbol to work with correct set of flags - return s.flags & 16777216 /* Instantiated */ ? getSymbolLinks(s).target : s; - } - function getClassLikeDeclarationOfSymbol(symbol) { - return ts.forEach(symbol.declarations, function (d) { return ts.isClassLike(d) ? d : undefined; }); - } - function checkKindsOfPropertyMemberOverrides(type, baseType) { - // TypeScript 1.0 spec (April 2014): 8.2.3 - // A derived class inherits all members from its base class it doesn't override. - // Inheritance means that a derived class implicitly contains all non - overridden members of the base class. - // Both public and private property members are inherited, but only public property members can be overridden. - // A property member in a derived class is said to override a property member in a base class - // when the derived class property member has the same name and kind(instance or static) - // as the base class property member. - // The type of an overriding property member must be assignable(section 3.8.4) - // to the type of the overridden property member, or otherwise a compile - time error occurs. - // Base class instance member functions can be overridden by derived class instance member functions, - // but not by other kinds of members. - // Base class instance member variables and accessors can be overridden by - // derived class instance member variables and accessors, but not by other kinds of members. - // NOTE: assignability is checked in checkClassDeclaration - var baseProperties = getPropertiesOfObjectType(baseType); - for (var _i = 0; _i < baseProperties.length; _i++) { - var baseProperty = baseProperties[_i]; - var base = getTargetSymbol(baseProperty); - if (base.flags & 134217728 /* Prototype */) { - continue; - } - var derived = getTargetSymbol(getPropertyOfObjectType(type, base.name)); - var baseDeclarationFlags = getDeclarationFlagsFromSymbol(base); - ts.Debug.assert(!!derived, "derived should point to something, even if it is the base class' declaration."); - if (derived) { - // In order to resolve whether the inherited method was overriden in the base class or not, - // we compare the Symbols obtained. Since getTargetSymbol returns the symbol on the *uninstantiated* - // type declaration, derived and base resolve to the same symbol even in the case of generic classes. - if (derived === base) { - // derived class inherits base without override/redeclaration - var derivedClassDecl = getClassLikeDeclarationOfSymbol(type.symbol); - // It is an error to inherit an abstract member without implementing it or being declared abstract. - // If there is no declaration for the derived class (as in the case of class expressions), - // then the class cannot be declared abstract. - if (baseDeclarationFlags & 256 /* Abstract */ && (!derivedClassDecl || !(derivedClassDecl.flags & 256 /* Abstract */))) { - if (derivedClassDecl.kind === 186 /* ClassExpression */) { - error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1, symbolToString(baseProperty), typeToString(baseType)); - } - else { - error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_0_does_not_implement_inherited_abstract_member_1_from_class_2, typeToString(type), symbolToString(baseProperty), typeToString(baseType)); - } - } - } - else { - // derived overrides base. - var derivedDeclarationFlags = getDeclarationFlagsFromSymbol(derived); - if ((baseDeclarationFlags & 32 /* Private */) || (derivedDeclarationFlags & 32 /* Private */)) { - // either base or derived property is private - not override, skip it - continue; - } - if ((baseDeclarationFlags & 128 /* Static */) !== (derivedDeclarationFlags & 128 /* Static */)) { - // value of 'static' is not the same for properties - not override, skip it - continue; - } - if ((base.flags & derived.flags & 8192 /* Method */) || ((base.flags & 98308 /* PropertyOrAccessor */) && (derived.flags & 98308 /* PropertyOrAccessor */))) { - // method is overridden with method or property/accessor is overridden with property/accessor - correct case - continue; - } - var errorMessage = void 0; - if (base.flags & 8192 /* Method */) { - if (derived.flags & 98304 /* Accessor */) { - errorMessage = ts.Diagnostics.Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_accessor; - } - else { - ts.Debug.assert((derived.flags & 4 /* Property */) !== 0); - errorMessage = ts.Diagnostics.Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_property; - } - } - else if (base.flags & 4 /* Property */) { - ts.Debug.assert((derived.flags & 8192 /* Method */) !== 0); - errorMessage = ts.Diagnostics.Class_0_defines_instance_member_property_1_but_extended_class_2_defines_it_as_instance_member_function; - } - else { - ts.Debug.assert((base.flags & 98304 /* Accessor */) !== 0); - ts.Debug.assert((derived.flags & 8192 /* Method */) !== 0); - errorMessage = ts.Diagnostics.Class_0_defines_instance_member_accessor_1_but_extended_class_2_defines_it_as_instance_member_function; - } - error(derived.valueDeclaration.name, errorMessage, typeToString(baseType), symbolToString(base), typeToString(type)); - } - } - } - } - function isAccessor(kind) { - return kind === 145 /* GetAccessor */ || kind === 146 /* SetAccessor */; - } - function areTypeParametersIdentical(list1, list2) { - if (!list1 && !list2) { - return true; - } - if (!list1 || !list2 || list1.length !== list2.length) { - return false; - } - // TypeScript 1.0 spec (April 2014): - // When a generic interface has multiple declarations, all declarations must have identical type parameter - // lists, i.e. identical type parameter names with identical constraints in identical order. - for (var i = 0, len = list1.length; i < len; i++) { - var tp1 = list1[i]; - var tp2 = list2[i]; - if (tp1.name.text !== tp2.name.text) { - return false; - } - if (!tp1.constraint && !tp2.constraint) { - continue; - } - if (!tp1.constraint || !tp2.constraint) { - return false; - } - if (!isTypeIdenticalTo(getTypeFromTypeNode(tp1.constraint), getTypeFromTypeNode(tp2.constraint))) { - return false; - } - } - return true; - } - function checkInheritedPropertiesAreIdentical(type, typeNode) { - var baseTypes = getBaseTypes(type); - if (baseTypes.length < 2) { - return true; - } - var seen = {}; - ts.forEach(resolveDeclaredMembers(type).declaredProperties, function (p) { seen[p.name] = { prop: p, containingType: type }; }); - var ok = true; - for (var _i = 0; _i < baseTypes.length; _i++) { - var base = baseTypes[_i]; - var properties = getPropertiesOfObjectType(getTypeWithThisArgument(base, type.thisType)); - for (var _a = 0; _a < properties.length; _a++) { - var prop = properties[_a]; - if (!ts.hasProperty(seen, prop.name)) { - seen[prop.name] = { prop: prop, containingType: base }; - } - else { - var existing = seen[prop.name]; - var isInheritedProperty = existing.containingType !== type; - if (isInheritedProperty && !isPropertyIdenticalTo(existing.prop, prop)) { - ok = false; - var typeName1 = typeToString(existing.containingType); - var typeName2 = typeToString(base); - var errorInfo = ts.chainDiagnosticMessages(undefined, ts.Diagnostics.Named_property_0_of_types_1_and_2_are_not_identical, symbolToString(prop), typeName1, typeName2); - errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.Interface_0_cannot_simultaneously_extend_types_1_and_2, typeToString(type), typeName1, typeName2); - diagnostics.add(ts.createDiagnosticForNodeFromMessageChain(typeNode, errorInfo)); - } - } - } - } - return ok; - } - function checkInterfaceDeclaration(node) { - // Grammar checking - checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarInterfaceDeclaration(node); - checkTypeParameters(node.typeParameters); - if (produceDiagnostics) { - checkTypeNameIsReserved(node.name, ts.Diagnostics.Interface_name_cannot_be_0); - checkExportsOnMergedDeclarations(node); - var symbol = getSymbolOfNode(node); - var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 215 /* InterfaceDeclaration */); - if (symbol.declarations.length > 1) { - if (node !== firstInterfaceDecl && !areTypeParametersIdentical(firstInterfaceDecl.typeParameters, node.typeParameters)) { - error(node.name, ts.Diagnostics.All_declarations_of_an_interface_must_have_identical_type_parameters); - } - } - // Only check this symbol once - if (node === firstInterfaceDecl) { - var type = getDeclaredTypeOfSymbol(symbol); - var typeWithThis = getTypeWithThisArgument(type); - // run subsequent checks only if first set succeeded - if (checkInheritedPropertiesAreIdentical(type, node.name)) { - for (var _i = 0, _a = getBaseTypes(type); _i < _a.length; _i++) { - var baseType = _a[_i]; - checkTypeAssignableTo(typeWithThis, getTypeWithThisArgument(baseType, type.thisType), node.name, ts.Diagnostics.Interface_0_incorrectly_extends_interface_1); - } - checkIndexConstraints(type); - } - } - } - ts.forEach(ts.getInterfaceBaseTypeNodes(node), function (heritageElement) { - if (!ts.isSupportedExpressionWithTypeArguments(heritageElement)) { - error(heritageElement.expression, ts.Diagnostics.An_interface_can_only_extend_an_identifier_Slashqualified_name_with_optional_type_arguments); - } - checkTypeReferenceNode(heritageElement); - }); - ts.forEach(node.members, checkSourceElement); - if (produceDiagnostics) { - checkTypeForDuplicateIndexSignatures(node); - } - } - function checkTypeAliasDeclaration(node) { - // Grammar checking - checkGrammarDecorators(node) || checkGrammarModifiers(node); - checkTypeNameIsReserved(node.name, ts.Diagnostics.Type_alias_name_cannot_be_0); - checkSourceElement(node.type); - } - function computeEnumMemberValues(node) { - var nodeLinks = getNodeLinks(node); - if (!(nodeLinks.flags & 8192 /* EnumValuesComputed */)) { - var enumSymbol = getSymbolOfNode(node); - var enumType = getDeclaredTypeOfSymbol(enumSymbol); - var autoValue = 0; // set to undefined when enum member is non-constant - var ambient = ts.isInAmbientContext(node); - var enumIsConst = ts.isConst(node); - for (var _i = 0, _a = node.members; _i < _a.length; _i++) { - var member = _a[_i]; - if (member.name.kind === 136 /* ComputedPropertyName */) { - error(member.name, ts.Diagnostics.Computed_property_names_are_not_allowed_in_enums); - } - else if (isNumericLiteralName(member.name.text)) { - error(member.name, ts.Diagnostics.An_enum_member_cannot_have_a_numeric_name); - } - var previousEnumMemberIsNonConstant = autoValue === undefined; - var initializer = member.initializer; - if (initializer) { - autoValue = computeConstantValueForEnumMemberInitializer(initializer, enumType, enumIsConst, ambient); - } - else if (ambient && !enumIsConst) { - // In ambient enum declarations that specify no const modifier, enum member declarations - // that omit a value are considered computed members (as opposed to having auto-incremented values assigned). - autoValue = undefined; - } - else if (previousEnumMemberIsNonConstant) { - // If the member declaration specifies no value, the member is considered a constant enum member. - // If the member is the first member in the enum declaration, it is assigned the value zero. - // Otherwise, it is assigned the value of the immediately preceding member plus one, - // and an error occurs if the immediately preceding member is not a constant enum member - error(member.name, ts.Diagnostics.Enum_member_must_have_initializer); - } - if (autoValue !== undefined) { - getNodeLinks(member).enumMemberValue = autoValue++; - } - } - nodeLinks.flags |= 8192 /* EnumValuesComputed */; - } - function computeConstantValueForEnumMemberInitializer(initializer, enumType, enumIsConst, ambient) { - // Controls if error should be reported after evaluation of constant value is completed - // Can be false if another more precise error was already reported during evaluation. - var reportError = true; - var value = evalConstant(initializer); - if (reportError) { - if (value === undefined) { - if (enumIsConst) { - error(initializer, ts.Diagnostics.In_const_enum_declarations_member_initializer_must_be_constant_expression); - } - else if (ambient) { - error(initializer, ts.Diagnostics.In_ambient_enum_declarations_member_initializer_must_be_constant_expression); - } - else { - // Only here do we need to check that the initializer is assignable to the enum type. - checkTypeAssignableTo(checkExpression(initializer), enumType, initializer, /*headMessage*/ undefined); - } - } - else if (enumIsConst) { - if (isNaN(value)) { - error(initializer, ts.Diagnostics.const_enum_member_initializer_was_evaluated_to_disallowed_value_NaN); - } - else if (!isFinite(value)) { - error(initializer, ts.Diagnostics.const_enum_member_initializer_was_evaluated_to_a_non_finite_value); - } - } - } - return value; - function evalConstant(e) { - switch (e.kind) { - case 179 /* 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; - } - return undefined; - case 181 /* BinaryExpression */: - var left = evalConstant(e.left); - if (left === undefined) { - return undefined; - } - var right = evalConstant(e.right); - if (right === undefined) { - 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; - } - return undefined; - case 8 /* NumericLiteral */: - return +e.text; - case 172 /* ParenthesizedExpression */: - return evalConstant(e.expression); - case 69 /* Identifier */: - case 167 /* ElementAccessExpression */: - case 166 /* PropertyAccessExpression */: - var member = initializer.parent; - var currentType = getTypeOfSymbol(getSymbolOfNode(member.parent)); - var enumType_1; - var propertyName; - if (e.kind === 69 /* Identifier */) { - // unqualified names can refer to member that reside in different declaration of the enum so just doing name resolution won't work. - // instead pick current enum type and later try to fetch member from the type - enumType_1 = currentType; - propertyName = e.text; - } - else { - var expression; - if (e.kind === 167 /* ElementAccessExpression */) { - if (e.argumentExpression === undefined || - e.argumentExpression.kind !== 9 /* StringLiteral */) { - return undefined; - } - expression = e.expression; - propertyName = e.argumentExpression.text; - } - else { - expression = e.expression; - propertyName = e.name.text; - } - // expression part in ElementAccess\PropertyAccess should be either identifier or dottedName - var current = expression; - while (current) { - if (current.kind === 69 /* Identifier */) { - break; - } - else if (current.kind === 166 /* PropertyAccessExpression */) { - current = current.expression; - } - else { - return undefined; - } - } - enumType_1 = checkExpression(expression); - // allow references to constant members of other enums - if (!(enumType_1.symbol && (enumType_1.symbol.flags & 384 /* Enum */))) { - return undefined; - } - } - if (propertyName === undefined) { - return undefined; - } - var property = getPropertyOfObjectType(enumType_1, propertyName); - if (!property || !(property.flags & 8 /* EnumMember */)) { - return undefined; - } - var propertyDecl = property.valueDeclaration; - // self references are illegal - if (member === propertyDecl) { - return undefined; - } - // illegal case: forward reference - if (!isBlockScopedNameDeclaredBeforeUse(propertyDecl, member)) { - reportError = false; - error(e, ts.Diagnostics.A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_enums); - return undefined; - } - return getNodeLinks(propertyDecl).enumMemberValue; - } - } - } - } - function checkEnumDeclaration(node) { - if (!produceDiagnostics) { - return; - } - // Grammar checking - checkGrammarDecorators(node) || checkGrammarModifiers(node); - checkTypeNameIsReserved(node.name, ts.Diagnostics.Enum_name_cannot_be_0); - checkCollisionWithCapturedThisVariable(node, node.name); - checkCollisionWithRequireExportsInGeneratedCode(node, node.name); - checkExportsOnMergedDeclarations(node); - computeEnumMemberValues(node); - var enumIsConst = ts.isConst(node); - if (compilerOptions.isolatedModules && enumIsConst && ts.isInAmbientContext(node)) { - error(node.name, ts.Diagnostics.Ambient_const_enums_are_not_allowed_when_the_isolatedModules_flag_is_provided); - } - // Spec 2014 - Section 9.3: - // It isn't possible for one enum declaration to continue the automatic numbering sequence of another, - // and when an enum type has multiple declarations, only one declaration is permitted to omit a value - // for the first member. - // - // Only perform this check once per symbol - var enumSymbol = getSymbolOfNode(node); - var firstDeclaration = ts.getDeclarationOfKind(enumSymbol, node.kind); - if (node === firstDeclaration) { - if (enumSymbol.declarations.length > 1) { - // check that const is placed\omitted on all enum declarations - ts.forEach(enumSymbol.declarations, function (decl) { - if (ts.isConstEnumDeclaration(decl) !== enumIsConst) { - error(decl.name, ts.Diagnostics.Enum_declarations_must_all_be_const_or_non_const); - } - }); - } - var seenEnumMissingInitialInitializer = false; - ts.forEach(enumSymbol.declarations, function (declaration) { - // return true if we hit a violation of the rule, false otherwise - if (declaration.kind !== 217 /* EnumDeclaration */) { - return false; - } - var enumDeclaration = declaration; - if (!enumDeclaration.members.length) { - return false; - } - var firstEnumMember = enumDeclaration.members[0]; - if (!firstEnumMember.initializer) { - if (seenEnumMissingInitialInitializer) { - error(firstEnumMember.name, ts.Diagnostics.In_an_enum_with_multiple_declarations_only_one_declaration_can_omit_an_initializer_for_its_first_enum_element); - } - else { - seenEnumMissingInitialInitializer = true; - } - } - }); - } - } - function getFirstNonAmbientClassOrFunctionDeclaration(symbol) { - var declarations = symbol.declarations; - for (var _i = 0; _i < declarations.length; _i++) { - var declaration = declarations[_i]; - if ((declaration.kind === 214 /* ClassDeclaration */ || - (declaration.kind === 213 /* FunctionDeclaration */ && ts.nodeIsPresent(declaration.body))) && - !ts.isInAmbientContext(declaration)) { - return declaration; - } - } - return undefined; - } - function inSameLexicalScope(node1, node2) { - var container1 = ts.getEnclosingBlockScopeContainer(node1); - var container2 = ts.getEnclosingBlockScopeContainer(node2); - if (isGlobalSourceFile(container1)) { - return isGlobalSourceFile(container2); - } - else if (isGlobalSourceFile(container2)) { - return false; - } - else { - return container1 === container2; - } - } - function checkModuleDeclaration(node) { - if (produceDiagnostics) { - // Grammar checking - var isAmbientExternalModule = node.name.kind === 9 /* StringLiteral */; - var contextErrorMessage = isAmbientExternalModule - ? ts.Diagnostics.An_ambient_module_declaration_is_only_allowed_at_the_top_level_in_a_file - : ts.Diagnostics.A_namespace_declaration_is_only_allowed_in_a_namespace_or_module; - if (checkGrammarModuleElementContext(node, contextErrorMessage)) { - // If we hit a module declaration in an illegal context, just bail out to avoid cascading errors. - return; - } - if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node)) { - if (!ts.isInAmbientContext(node) && node.name.kind === 9 /* StringLiteral */) { - grammarErrorOnNode(node.name, ts.Diagnostics.Only_ambient_modules_can_use_quoted_names); - } - } - checkCollisionWithCapturedThisVariable(node, node.name); - checkCollisionWithRequireExportsInGeneratedCode(node, node.name); - checkExportsOnMergedDeclarations(node); - var symbol = getSymbolOfNode(node); - // The following checks only apply on a non-ambient instantiated module declaration. - if (symbol.flags & 512 /* ValueModule */ - && symbol.declarations.length > 1 - && !ts.isInAmbientContext(node) - && ts.isInstantiatedModule(node, compilerOptions.preserveConstEnums || compilerOptions.isolatedModules)) { - var firstNonAmbientClassOrFunc = getFirstNonAmbientClassOrFunctionDeclaration(symbol); - if (firstNonAmbientClassOrFunc) { - if (ts.getSourceFileOfNode(node) !== ts.getSourceFileOfNode(firstNonAmbientClassOrFunc)) { - error(node.name, ts.Diagnostics.A_namespace_declaration_cannot_be_in_a_different_file_from_a_class_or_function_with_which_it_is_merged); - } - else if (node.pos < firstNonAmbientClassOrFunc.pos) { - error(node.name, ts.Diagnostics.A_namespace_declaration_cannot_be_located_prior_to_a_class_or_function_with_which_it_is_merged); - } - } - // 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, 214 /* ClassDeclaration */); - if (mergedClass && - inSameLexicalScope(node, mergedClass)) { - getNodeLinks(node).flags |= 32768 /* LexicalModuleMergesWithClass */; - } - } - // Checks for ambient external modules. - if (isAmbientExternalModule) { - if (!isGlobalSourceFile(node.parent)) { - error(node.name, ts.Diagnostics.Ambient_modules_cannot_be_nested_in_other_modules_or_namespaces); - } - if (ts.isExternalModuleNameRelative(node.name.text)) { - error(node.name, ts.Diagnostics.Ambient_module_declaration_cannot_specify_relative_module_name); - } - } - } - checkSourceElement(node.body); - } - function getFirstIdentifier(node) { - while (true) { - if (node.kind === 135 /* QualifiedName */) { - node = node.left; - } - else if (node.kind === 166 /* PropertyAccessExpression */) { - node = node.expression; - } - else { - break; - } - } - ts.Debug.assert(node.kind === 69 /* Identifier */); - return node; - } - function checkExternalImportOrExportDeclaration(node) { - var moduleName = ts.getExternalModuleName(node); - if (!ts.nodeIsMissing(moduleName) && moduleName.kind !== 9 /* StringLiteral */) { - error(moduleName, ts.Diagnostics.String_literal_expected); - return false; - } - var inAmbientExternalModule = node.parent.kind === 219 /* ModuleBlock */ && node.parent.parent.name.kind === 9 /* StringLiteral */; - if (node.parent.kind !== 248 /* SourceFile */ && !inAmbientExternalModule) { - error(moduleName, node.kind === 228 /* ExportDeclaration */ ? - ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace : - ts.Diagnostics.Import_declarations_in_a_namespace_cannot_reference_a_module); - return false; - } - if (inAmbientExternalModule && ts.isExternalModuleNameRelative(moduleName.text)) { - // TypeScript 1.0 spec (April 2013): 12.1.6 - // An ExternalImportDeclaration in an AmbientExternalModuleDeclaration may reference - // other external modules only through top - level external module names. - // Relative external module names are not permitted. - error(node, ts.Diagnostics.Import_or_export_declaration_in_an_ambient_module_declaration_cannot_reference_module_through_relative_module_name); - return false; - } - return true; - } - function checkAliasSymbol(node) { - var symbol = getSymbolOfNode(node); - var target = resolveAlias(symbol); - if (target !== unknownSymbol) { - var excludedMeanings = (symbol.flags & 107455 /* Value */ ? 107455 /* Value */ : 0) | - (symbol.flags & 793056 /* Type */ ? 793056 /* Type */ : 0) | - (symbol.flags & 1536 /* Namespace */ ? 1536 /* Namespace */ : 0); - if (target.flags & excludedMeanings) { - var message = node.kind === 230 /* ExportSpecifier */ ? - ts.Diagnostics.Export_declaration_conflicts_with_exported_declaration_of_0 : - ts.Diagnostics.Import_declaration_conflicts_with_local_declaration_of_0; - error(node, message, symbolToString(symbol)); - } - } - } - function checkImportBinding(node) { - checkCollisionWithCapturedThisVariable(node, node.name); - checkCollisionWithRequireExportsInGeneratedCode(node, node.name); - checkAliasSymbol(node); - } - function checkImportDeclaration(node) { - if (checkGrammarModuleElementContext(node, ts.Diagnostics.An_import_declaration_can_only_be_used_in_a_namespace_or_module)) { - // If we hit an import declaration in an illegal context, just bail out to avoid cascading errors. - return; - } - if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && (node.flags & 2035 /* Modifier */)) { - grammarErrorOnFirstToken(node, ts.Diagnostics.An_import_declaration_cannot_have_modifiers); - } - if (checkExternalImportOrExportDeclaration(node)) { - var importClause = node.importClause; - if (importClause) { - if (importClause.name) { - checkImportBinding(importClause); - } - if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 224 /* NamespaceImport */) { - checkImportBinding(importClause.namedBindings); - } - else { - ts.forEach(importClause.namedBindings.elements, checkImportBinding); - } - } - } - } - } - function checkImportEqualsDeclaration(node) { - if (checkGrammarModuleElementContext(node, ts.Diagnostics.An_import_declaration_can_only_be_used_in_a_namespace_or_module)) { - // If we hit an import declaration in an illegal context, just bail out to avoid cascading errors. - return; - } - checkGrammarDecorators(node) || checkGrammarModifiers(node); - if (ts.isInternalModuleImportEqualsDeclaration(node) || checkExternalImportOrExportDeclaration(node)) { - checkImportBinding(node); - if (node.flags & 1 /* Export */) { - markExportAsReferenced(node); - } - if (ts.isInternalModuleImportEqualsDeclaration(node)) { - var target = resolveAlias(getSymbolOfNode(node)); - if (target !== unknownSymbol) { - if (target.flags & 107455 /* Value */) { - // Target is a value symbol, check that it is not hidden by a local declaration with the same name - var moduleName = getFirstIdentifier(node.moduleReference); - if (!(resolveEntityName(moduleName, 107455 /* Value */ | 1536 /* Namespace */).flags & 1536 /* Namespace */)) { - error(moduleName, ts.Diagnostics.Module_0_is_hidden_by_a_local_declaration_with_the_same_name, ts.declarationNameToString(moduleName)); - } - } - if (target.flags & 793056 /* Type */) { - checkTypeNameIsReserved(node.name, ts.Diagnostics.Import_name_cannot_be_0); - } - } - } - else { - if (modulekind === 5 /* ES6 */ && !ts.isInAmbientContext(node)) { - // Import equals declaration is deprecated in es6 or above - grammarErrorOnNode(node, ts.Diagnostics.Import_assignment_cannot_be_used_when_targeting_ECMAScript_6_modules_Consider_using_import_Asterisk_as_ns_from_mod_import_a_from_mod_import_d_from_mod_or_another_module_format_instead); - } - } - } - } - function checkExportDeclaration(node) { - if (checkGrammarModuleElementContext(node, ts.Diagnostics.An_export_declaration_can_only_be_used_in_a_module)) { - // If we hit an export in an illegal context, just bail out to avoid cascading errors. - return; - } - if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && (node.flags & 2035 /* Modifier */)) { - grammarErrorOnFirstToken(node, ts.Diagnostics.An_export_declaration_cannot_have_modifiers); - } - if (!node.moduleSpecifier || checkExternalImportOrExportDeclaration(node)) { - if (node.exportClause) { - // export { x, y } - // export { x, y } from "foo" - ts.forEach(node.exportClause.elements, checkExportSpecifier); - var inAmbientExternalModule = node.parent.kind === 219 /* ModuleBlock */ && node.parent.parent.name.kind === 9 /* StringLiteral */; - if (node.parent.kind !== 248 /* SourceFile */ && !inAmbientExternalModule) { - error(node, ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace); - } - } - else { - // export * from "foo" - var moduleSymbol = resolveExternalModuleName(node, node.moduleSpecifier); - if (moduleSymbol && moduleSymbol.exports["export="]) { - error(node.moduleSpecifier, ts.Diagnostics.Module_0_uses_export_and_cannot_be_used_with_export_Asterisk, symbolToString(moduleSymbol)); - } - } - } - } - function checkGrammarModuleElementContext(node, errorMessage) { - if (node.parent.kind !== 248 /* SourceFile */ && node.parent.kind !== 219 /* ModuleBlock */ && node.parent.kind !== 218 /* ModuleDeclaration */) { - return grammarErrorOnFirstToken(node, errorMessage); - } - } - function checkExportSpecifier(node) { - checkAliasSymbol(node); - if (!node.parent.parent.moduleSpecifier) { - markExportAsReferenced(node); - } - } - function checkExportAssignment(node) { - if (checkGrammarModuleElementContext(node, ts.Diagnostics.An_export_assignment_can_only_be_used_in_a_module)) { - // If we hit an export assignment in an illegal context, just bail out to avoid cascading errors. - return; - } - var container = node.parent.kind === 248 /* SourceFile */ ? node.parent : node.parent.parent; - if (container.kind === 218 /* ModuleDeclaration */ && container.name.kind === 69 /* Identifier */) { - error(node, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_namespace); - return; - } - // Grammar checking - if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && (node.flags & 2035 /* Modifier */)) { - grammarErrorOnFirstToken(node, ts.Diagnostics.An_export_assignment_cannot_have_modifiers); - } - if (node.expression.kind === 69 /* Identifier */) { - markExportAsReferenced(node); - } - else { - checkExpressionCached(node.expression); - } - checkExternalModuleExports(container); - if (node.isExportEquals && !ts.isInAmbientContext(node)) { - if (modulekind === 5 /* ES6 */) { - // export assignment is not supported in es6 modules - grammarErrorOnNode(node, ts.Diagnostics.Export_assignment_cannot_be_used_when_targeting_ECMAScript_6_modules_Consider_using_export_default_or_another_module_format_instead); - } - else if (modulekind === 4 /* System */) { - // system modules does not support export assignment - grammarErrorOnNode(node, ts.Diagnostics.Export_assignment_is_not_supported_when_module_flag_is_system); - } - } - } - function getModuleStatements(node) { - if (node.kind === 248 /* SourceFile */) { - return node.statements; - } - if (node.kind === 218 /* ModuleDeclaration */ && node.body.kind === 219 /* ModuleBlock */) { - return node.body.statements; - } - return emptyArray; - } - function hasExportedMembers(moduleSymbol) { - for (var id in moduleSymbol.exports) { - if (id !== "export=") { - return true; - } - } - return false; - } - function checkExternalModuleExports(node) { - var moduleSymbol = getSymbolOfNode(node); - var links = getSymbolLinks(moduleSymbol); - if (!links.exportsChecked) { - var exportEqualsSymbol = moduleSymbol.exports["export="]; - if (exportEqualsSymbol && hasExportedMembers(moduleSymbol)) { - var declaration = getDeclarationOfAliasSymbol(exportEqualsSymbol) || exportEqualsSymbol.valueDeclaration; - error(declaration, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_module_with_other_exported_elements); - } - links.exportsChecked = true; - } - } - function checkTypePredicate(node) { - if (!isInLegalTypePredicatePosition(node)) { - error(node, ts.Diagnostics.A_type_predicate_is_only_allowed_in_return_type_position_for_functions_and_methods); - } - } - function checkSourceElement(node) { - if (!node) { - return; - } - var kind = node.kind; - if (cancellationToken) { - // Only bother checking on a few construct kinds. We don't want to be excessivly - // hitting the cancellation token on every node we check. - switch (kind) { - case 218 /* ModuleDeclaration */: - case 214 /* ClassDeclaration */: - case 215 /* InterfaceDeclaration */: - case 213 /* FunctionDeclaration */: - cancellationToken.throwIfCancellationRequested(); - } - } - switch (kind) { - case 137 /* TypeParameter */: - return checkTypeParameter(node); - case 138 /* Parameter */: - return checkParameter(node); - case 141 /* PropertyDeclaration */: - case 140 /* PropertySignature */: - return checkPropertyDeclaration(node); - case 152 /* FunctionType */: - case 153 /* ConstructorType */: - case 147 /* CallSignature */: - case 148 /* ConstructSignature */: - return checkSignatureDeclaration(node); - case 149 /* IndexSignature */: - return checkSignatureDeclaration(node); - case 143 /* MethodDeclaration */: - case 142 /* MethodSignature */: - return checkMethodDeclaration(node); - case 144 /* Constructor */: - return checkConstructorDeclaration(node); - case 145 /* GetAccessor */: - case 146 /* SetAccessor */: - return checkAccessorDeclaration(node); - case 151 /* TypeReference */: - return checkTypeReferenceNode(node); - case 150 /* TypePredicate */: - return checkTypePredicate(node); - case 154 /* TypeQuery */: - return checkTypeQuery(node); - case 155 /* TypeLiteral */: - return checkTypeLiteral(node); - case 156 /* ArrayType */: - return checkArrayType(node); - case 157 /* TupleType */: - return checkTupleType(node); - case 158 /* UnionType */: - case 159 /* IntersectionType */: - return checkUnionOrIntersectionType(node); - case 160 /* ParenthesizedType */: - return checkSourceElement(node.type); - case 213 /* FunctionDeclaration */: - return checkFunctionDeclaration(node); - case 192 /* Block */: - case 219 /* ModuleBlock */: - return checkBlock(node); - case 193 /* VariableStatement */: - return checkVariableStatement(node); - case 195 /* ExpressionStatement */: - return checkExpressionStatement(node); - case 196 /* IfStatement */: - return checkIfStatement(node); - case 197 /* DoStatement */: - return checkDoStatement(node); - case 198 /* WhileStatement */: - return checkWhileStatement(node); - case 199 /* ForStatement */: - return checkForStatement(node); - case 200 /* ForInStatement */: - return checkForInStatement(node); - case 201 /* ForOfStatement */: - return checkForOfStatement(node); - case 202 /* ContinueStatement */: - case 203 /* BreakStatement */: - return checkBreakOrContinueStatement(node); - case 204 /* ReturnStatement */: - return checkReturnStatement(node); - case 205 /* WithStatement */: - return checkWithStatement(node); - case 206 /* SwitchStatement */: - return checkSwitchStatement(node); - case 207 /* LabeledStatement */: - return checkLabeledStatement(node); - case 208 /* ThrowStatement */: - return checkThrowStatement(node); - case 209 /* TryStatement */: - return checkTryStatement(node); - case 211 /* VariableDeclaration */: - return checkVariableDeclaration(node); - case 163 /* BindingElement */: - return checkBindingElement(node); - case 214 /* ClassDeclaration */: - return checkClassDeclaration(node); - case 215 /* InterfaceDeclaration */: - return checkInterfaceDeclaration(node); - case 216 /* TypeAliasDeclaration */: - return checkTypeAliasDeclaration(node); - case 217 /* EnumDeclaration */: - return checkEnumDeclaration(node); - case 218 /* ModuleDeclaration */: - return checkModuleDeclaration(node); - case 222 /* ImportDeclaration */: - return checkImportDeclaration(node); - case 221 /* ImportEqualsDeclaration */: - return checkImportEqualsDeclaration(node); - case 228 /* ExportDeclaration */: - return checkExportDeclaration(node); - case 227 /* ExportAssignment */: - return checkExportAssignment(node); - case 194 /* EmptyStatement */: - checkGrammarStatementInAmbientContext(node); - return; - case 210 /* DebuggerStatement */: - checkGrammarStatementInAmbientContext(node); - return; - case 231 /* MissingDeclaration */: - return checkMissingDeclaration(node); - } - } - // Function and class expression bodies are checked after all statements in the enclosing body. This is - // to ensure constructs like the following are permitted: - // let foo = function () { - // let s = foo(); - // return "hello"; - // } - // Here, performing a full type check of the body of the function expression whilst in the process of - // determining the type of foo would cause foo to be given type any because of the recursive reference. - // Delaying the type check of the body ensures foo has been assigned a type. - function checkFunctionAndClassExpressionBodies(node) { - switch (node.kind) { - case 173 /* FunctionExpression */: - case 174 /* ArrowFunction */: - ts.forEach(node.parameters, checkFunctionAndClassExpressionBodies); - checkFunctionExpressionOrObjectLiteralMethodBody(node); - break; - case 186 /* ClassExpression */: - ts.forEach(node.members, checkSourceElement); - ts.forEachChild(node, checkFunctionAndClassExpressionBodies); - break; - case 143 /* MethodDeclaration */: - case 142 /* MethodSignature */: - ts.forEach(node.decorators, checkFunctionAndClassExpressionBodies); - ts.forEach(node.parameters, checkFunctionAndClassExpressionBodies); - if (ts.isObjectLiteralMethod(node)) { - checkFunctionExpressionOrObjectLiteralMethodBody(node); - } - break; - case 144 /* Constructor */: - case 145 /* GetAccessor */: - case 146 /* SetAccessor */: - case 213 /* FunctionDeclaration */: - ts.forEach(node.parameters, checkFunctionAndClassExpressionBodies); - break; - case 205 /* WithStatement */: - checkFunctionAndClassExpressionBodies(node.expression); - break; - case 139 /* Decorator */: - case 138 /* Parameter */: - case 141 /* PropertyDeclaration */: - case 140 /* PropertySignature */: - case 161 /* ObjectBindingPattern */: - case 162 /* ArrayBindingPattern */: - case 163 /* BindingElement */: - case 164 /* ArrayLiteralExpression */: - case 165 /* ObjectLiteralExpression */: - case 245 /* PropertyAssignment */: - case 166 /* PropertyAccessExpression */: - case 167 /* ElementAccessExpression */: - case 168 /* CallExpression */: - case 169 /* NewExpression */: - case 170 /* TaggedTemplateExpression */: - case 183 /* TemplateExpression */: - case 190 /* TemplateSpan */: - case 171 /* TypeAssertionExpression */: - case 189 /* AsExpression */: - case 172 /* ParenthesizedExpression */: - case 176 /* TypeOfExpression */: - case 177 /* VoidExpression */: - case 178 /* AwaitExpression */: - case 175 /* DeleteExpression */: - case 179 /* PrefixUnaryExpression */: - case 180 /* PostfixUnaryExpression */: - case 181 /* BinaryExpression */: - case 182 /* ConditionalExpression */: - case 185 /* SpreadElementExpression */: - case 184 /* YieldExpression */: - case 192 /* Block */: - case 219 /* ModuleBlock */: - case 193 /* VariableStatement */: - case 195 /* ExpressionStatement */: - case 196 /* IfStatement */: - case 197 /* DoStatement */: - case 198 /* WhileStatement */: - case 199 /* ForStatement */: - case 200 /* ForInStatement */: - case 201 /* ForOfStatement */: - case 202 /* ContinueStatement */: - case 203 /* BreakStatement */: - case 204 /* ReturnStatement */: - case 206 /* SwitchStatement */: - case 220 /* CaseBlock */: - case 241 /* CaseClause */: - case 242 /* DefaultClause */: - case 207 /* LabeledStatement */: - case 208 /* ThrowStatement */: - case 209 /* TryStatement */: - case 244 /* CatchClause */: - case 211 /* VariableDeclaration */: - case 212 /* VariableDeclarationList */: - case 214 /* ClassDeclaration */: - case 243 /* HeritageClause */: - case 188 /* ExpressionWithTypeArguments */: - case 217 /* EnumDeclaration */: - case 247 /* EnumMember */: - case 227 /* ExportAssignment */: - case 248 /* SourceFile */: - case 240 /* JsxExpression */: - case 233 /* JsxElement */: - case 234 /* JsxSelfClosingElement */: - case 238 /* JsxAttribute */: - case 239 /* JsxSpreadAttribute */: - case 235 /* JsxOpeningElement */: - ts.forEachChild(node, checkFunctionAndClassExpressionBodies); - break; - } - } - function checkSourceFile(node) { - var start = new Date().getTime(); - checkSourceFileWorker(node); - ts.checkTime += new Date().getTime() - start; - } - // Fully type check a source file and collect the relevant diagnostics. - function checkSourceFileWorker(node) { - var links = getNodeLinks(node); - if (!(links.flags & 1 /* TypeChecked */)) { - // Check whether the file has declared it is the default lib, - // and whether the user has specifically chosen to avoid checking it. - if (node.isDefaultLib && compilerOptions.skipDefaultLibCheck) { - return; - } - // Grammar checking - checkGrammarSourceFile(node); - emitExtends = false; - emitDecorate = false; - emitParam = false; - potentialThisCollisions.length = 0; - ts.forEach(node.statements, checkSourceElement); - checkFunctionAndClassExpressionBodies(node); - if (ts.isExternalModule(node)) { - checkExternalModuleExports(node); - } - if (potentialThisCollisions.length) { - ts.forEach(potentialThisCollisions, checkIfThisIsCapturedInEnclosingScope); - potentialThisCollisions.length = 0; - } - if (emitExtends) { - links.flags |= 8 /* EmitExtends */; - } - if (emitDecorate) { - links.flags |= 16 /* EmitDecorate */; - } - if (emitParam) { - links.flags |= 32 /* EmitParam */; - } - if (emitAwaiter) { - links.flags |= 64 /* EmitAwaiter */; - } - if (emitGenerator || (emitAwaiter && languageVersion < 2 /* ES6 */)) { - links.flags |= 128 /* EmitGenerator */; - } - links.flags |= 1 /* TypeChecked */; - } - } - function getDiagnostics(sourceFile, ct) { - try { - // Record the cancellation token so it can be checked later on during checkSourceElement. - // Do this in a finally block so we can ensure that it gets reset back to nothing after - // this call is done. - cancellationToken = ct; - return getDiagnosticsWorker(sourceFile); - } - finally { - cancellationToken = undefined; - } - } - function getDiagnosticsWorker(sourceFile) { - throwIfNonDiagnosticsProducing(); - if (sourceFile) { - checkSourceFile(sourceFile); - return diagnostics.getDiagnostics(sourceFile.fileName); - } - ts.forEach(host.getSourceFiles(), checkSourceFile); - return diagnostics.getDiagnostics(); - } - function getGlobalDiagnostics() { - throwIfNonDiagnosticsProducing(); - return diagnostics.getGlobalDiagnostics(); - } - function throwIfNonDiagnosticsProducing() { - if (!produceDiagnostics) { - throw new Error("Trying to get diagnostics from a type checker that does not produce them."); - } - } - // Language service support - function isInsideWithStatementBody(node) { - if (node) { - while (node.parent) { - if (node.parent.kind === 205 /* WithStatement */ && node.parent.statement === node) { - return true; - } - node = node.parent; - } - } - return false; - } - function getSymbolsInScope(location, meaning) { - var symbols = {}; - var memberFlags = 0; - if (isInsideWithStatementBody(location)) { - // We cannot answer semantic questions within a with block, do not proceed any further - return []; - } - populateSymbols(); - return symbolsToArray(symbols); - function populateSymbols() { - while (location) { - if (location.locals && !isGlobalSourceFile(location)) { - copySymbols(location.locals, meaning); - } - switch (location.kind) { - case 248 /* SourceFile */: - if (!ts.isExternalModule(location)) { - break; - } - case 218 /* ModuleDeclaration */: - copySymbols(getSymbolOfNode(location).exports, meaning & 8914931 /* ModuleMember */); - break; - case 217 /* EnumDeclaration */: - copySymbols(getSymbolOfNode(location).exports, meaning & 8 /* EnumMember */); - break; - case 186 /* ClassExpression */: - var className = location.name; - if (className) { - copySymbol(location.symbol, meaning); - } - // fall through; this fall-through is necessary because we would like to handle - // type parameter inside class expression similar to how we handle it in classDeclaration and interface Declaration - case 214 /* ClassDeclaration */: - case 215 /* InterfaceDeclaration */: - // If we didn't come from static member of class or interface, - // add the type parameters into the symbol table - // (type parameters of classDeclaration/classExpression and interface are in member property of the symbol. - // Note: that the memberFlags come from previous iteration. - if (!(memberFlags & 128 /* Static */)) { - copySymbols(getSymbolOfNode(location).members, meaning & 793056 /* Type */); - } - break; - case 173 /* FunctionExpression */: - var funcName = location.name; - if (funcName) { - copySymbol(location.symbol, meaning); - } - break; - } - if (ts.introducesArgumentsExoticObject(location)) { - copySymbol(argumentsSymbol, meaning); - } - memberFlags = location.flags; - location = location.parent; - } - copySymbols(globals, meaning); - } - /** - * Copy the given symbol into symbol tables if the symbol has the given meaning - * and it doesn't already existed in the symbol table - * @param key a key for storing in symbol table; if undefined, use symbol.name - * @param symbol the symbol to be added into symbol table - * @param meaning meaning of symbol to filter by before adding to symbol table - */ - function copySymbol(symbol, meaning) { - if (symbol.flags & meaning) { - var id = symbol.name; - // We will copy all symbol regardless of its reserved name because - // symbolsToArray will check whether the key is a reserved name and - // it will not copy symbol with reserved name to the array - if (!ts.hasProperty(symbols, id)) { - symbols[id] = symbol; - } - } - } - function copySymbols(source, meaning) { - if (meaning) { - for (var id in source) { - var symbol = source[id]; - copySymbol(symbol, meaning); - } - } - } - } - function isTypeDeclarationName(name) { - return name.kind === 69 /* Identifier */ && - isTypeDeclaration(name.parent) && - name.parent.name === name; - } - function isTypeDeclaration(node) { - switch (node.kind) { - case 137 /* TypeParameter */: - case 214 /* ClassDeclaration */: - case 215 /* InterfaceDeclaration */: - case 216 /* TypeAliasDeclaration */: - case 217 /* EnumDeclaration */: - return true; - } - } - // True if the given identifier is part of a type reference - function isTypeReferenceIdentifier(entityName) { - var node = entityName; - while (node.parent && node.parent.kind === 135 /* QualifiedName */) { - node = node.parent; - } - return node.parent && node.parent.kind === 151 /* TypeReference */; - } - function isHeritageClauseElementIdentifier(entityName) { - var node = entityName; - while (node.parent && node.parent.kind === 166 /* PropertyAccessExpression */) { - node = node.parent; - } - return node.parent && node.parent.kind === 188 /* ExpressionWithTypeArguments */; - } - function getLeftSideOfImportEqualsOrExportAssignment(nodeOnRightSide) { - while (nodeOnRightSide.parent.kind === 135 /* QualifiedName */) { - nodeOnRightSide = nodeOnRightSide.parent; - } - if (nodeOnRightSide.parent.kind === 221 /* ImportEqualsDeclaration */) { - return nodeOnRightSide.parent.moduleReference === nodeOnRightSide && nodeOnRightSide.parent; - } - if (nodeOnRightSide.parent.kind === 227 /* ExportAssignment */) { - return nodeOnRightSide.parent.expression === nodeOnRightSide && nodeOnRightSide.parent; - } - return undefined; - } - function isInRightSideOfImportOrExportAssignment(node) { - return getLeftSideOfImportEqualsOrExportAssignment(node) !== undefined; - } - function getSymbolOfEntityNameOrPropertyAccessExpression(entityName) { - if (ts.isDeclarationName(entityName)) { - return getSymbolOfNode(entityName.parent); - } - if (entityName.parent.kind === 227 /* ExportAssignment */) { - return resolveEntityName(entityName, - /*all meanings*/ 107455 /* Value */ | 793056 /* Type */ | 1536 /* Namespace */ | 8388608 /* Alias */); - } - if (entityName.kind !== 166 /* PropertyAccessExpression */) { - if (isInRightSideOfImportOrExportAssignment(entityName)) { - // Since we already checked for ExportAssignment, this really could only be an Import - return getSymbolOfPartOfRightHandSideOfImportEquals(entityName); - } - } - if (ts.isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { - entityName = entityName.parent; - } - if (isHeritageClauseElementIdentifier(entityName)) { - var meaning = 0 /* None */; - // In an interface or class, we're definitely interested in a type. - if (entityName.parent.kind === 188 /* ExpressionWithTypeArguments */) { - meaning = 793056 /* Type */; - // In a class 'extends' clause we are also looking for a value. - if (ts.isExpressionWithTypeArgumentsInClassExtendsClause(entityName.parent)) { - meaning |= 107455 /* Value */; - } - } - else { - meaning = 1536 /* Namespace */; - } - meaning |= 8388608 /* Alias */; - return resolveEntityName(entityName, meaning); - } - else if ((entityName.parent.kind === 235 /* JsxOpeningElement */) || - (entityName.parent.kind === 234 /* JsxSelfClosingElement */) || - (entityName.parent.kind === 237 /* JsxClosingElement */)) { - return getJsxElementTagSymbol(entityName.parent); - } - else if (ts.isExpression(entityName)) { - if (ts.nodeIsMissing(entityName)) { - // Missing entity name. - return undefined; - } - if (entityName.kind === 69 /* Identifier */) { - // Include aliases in the meaning, this ensures that we do not follow aliases to where they point and instead - // return the alias symbol. - var meaning = 107455 /* Value */ | 8388608 /* Alias */; - return resolveEntityName(entityName, meaning); - } - else if (entityName.kind === 166 /* PropertyAccessExpression */) { - var symbol = getNodeLinks(entityName).resolvedSymbol; - if (!symbol) { - checkPropertyAccessExpression(entityName); - } - return getNodeLinks(entityName).resolvedSymbol; - } - else if (entityName.kind === 135 /* QualifiedName */) { - var symbol = getNodeLinks(entityName).resolvedSymbol; - if (!symbol) { - checkQualifiedName(entityName); - } - return getNodeLinks(entityName).resolvedSymbol; - } - } - else if (isTypeReferenceIdentifier(entityName)) { - var meaning = entityName.parent.kind === 151 /* TypeReference */ ? 793056 /* Type */ : 1536 /* Namespace */; - // Include aliases in the meaning, this ensures that we do not follow aliases to where they point and instead - // return the alias symbol. - meaning |= 8388608 /* Alias */; - return resolveEntityName(entityName, meaning); - } - else if (entityName.parent.kind === 238 /* JsxAttribute */) { - return getJsxAttributePropertySymbol(entityName.parent); - } - if (entityName.parent.kind === 150 /* TypePredicate */) { - return resolveEntityName(entityName, /*meaning*/ 1 /* FunctionScopedVariable */); - } - // Do we want to return undefined here? - return undefined; - } - function getSymbolAtLocation(node) { - if (isInsideWithStatementBody(node)) { - // We cannot answer semantic questions within a with block, do not proceed any further - return undefined; - } - if (ts.isDeclarationName(node)) { - // This is a declaration, call getSymbolOfNode - return getSymbolOfNode(node.parent); - } - if (node.kind === 69 /* Identifier */) { - if (isInRightSideOfImportOrExportAssignment(node)) { - return node.parent.kind === 227 /* ExportAssignment */ - ? getSymbolOfEntityNameOrPropertyAccessExpression(node) - : getSymbolOfPartOfRightHandSideOfImportEquals(node); - } - else if (node.parent.kind === 163 /* BindingElement */ && - node.parent.parent.kind === 161 /* ObjectBindingPattern */ && - node === node.parent.propertyName) { - var typeOfPattern = getTypeOfNode(node.parent.parent); - var propertyDeclaration = typeOfPattern && getPropertyOfType(typeOfPattern, node.text); - if (propertyDeclaration) { - return propertyDeclaration; - } - } - } - switch (node.kind) { - case 69 /* Identifier */: - case 166 /* PropertyAccessExpression */: - case 135 /* QualifiedName */: - return getSymbolOfEntityNameOrPropertyAccessExpression(node); - case 97 /* ThisKeyword */: - case 95 /* SuperKeyword */: - var type = ts.isExpression(node) ? checkExpression(node) : getTypeFromTypeNode(node); - return type.symbol; - case 121 /* ConstructorKeyword */: - // constructor keyword for an overload, should take us to the definition if it exist - var constructorDeclaration = node.parent; - if (constructorDeclaration && constructorDeclaration.kind === 144 /* Constructor */) { - return constructorDeclaration.parent.symbol; - } - return undefined; - case 9 /* StringLiteral */: - // External module name in an import declaration - if ((ts.isExternalModuleImportEqualsDeclaration(node.parent.parent) && - ts.getExternalModuleImportEqualsDeclarationExpression(node.parent.parent) === node) || - ((node.parent.kind === 222 /* ImportDeclaration */ || node.parent.kind === 228 /* ExportDeclaration */) && - node.parent.moduleSpecifier === node)) { - return resolveExternalModuleName(node, node); - } - // Fall through - case 8 /* NumericLiteral */: - // index access - if (node.parent.kind === 167 /* ElementAccessExpression */ && node.parent.argumentExpression === node) { - var objectType = checkExpression(node.parent.expression); - if (objectType === unknownType) - return undefined; - var apparentType = getApparentType(objectType); - if (apparentType === unknownType) - return undefined; - return getPropertyOfType(apparentType, node.text); - } - break; - } - return undefined; - } - function getShorthandAssignmentValueSymbol(location) { - // The function returns a value symbol of an identifier in the short-hand property assignment. - // This is necessary as an identifier in short-hand property assignment can contains two meaning: - // property name and property value. - if (location && location.kind === 246 /* ShorthandPropertyAssignment */) { - return resolveEntityName(location.name, 107455 /* Value */); - } - return undefined; - } - function getTypeOfNode(node) { - if (isInsideWithStatementBody(node)) { - // We cannot answer semantic questions within a with block, do not proceed any further - return unknownType; - } - if (ts.isTypeNode(node)) { - return getTypeFromTypeNode(node); - } - if (ts.isExpression(node)) { - return getTypeOfExpression(node); - } - if (ts.isExpressionWithTypeArgumentsInClassExtendsClause(node)) { - // A SyntaxKind.ExpressionWithTypeArguments is considered a type node, except when it occurs in the - // extends clause of a class. We handle that case here. - return getBaseTypes(getDeclaredTypeOfSymbol(getSymbolOfNode(node.parent.parent)))[0]; - } - if (isTypeDeclaration(node)) { - // In this case, we call getSymbolOfNode instead of getSymbolAtLocation because it is a declaration - var symbol = getSymbolOfNode(node); - return getDeclaredTypeOfSymbol(symbol); - } - if (isTypeDeclarationName(node)) { - var symbol = getSymbolAtLocation(node); - return symbol && getDeclaredTypeOfSymbol(symbol); - } - if (ts.isDeclaration(node)) { - // In this case, we call getSymbolOfNode instead of getSymbolAtLocation because it is a declaration - var symbol = getSymbolOfNode(node); - return getTypeOfSymbol(symbol); - } - if (ts.isDeclarationName(node)) { - var symbol = getSymbolAtLocation(node); - return symbol && getTypeOfSymbol(symbol); - } - if (ts.isBindingPattern(node)) { - return getTypeForVariableLikeDeclaration(node.parent); - } - if (isInRightSideOfImportOrExportAssignment(node)) { - var symbol = getSymbolAtLocation(node); - var declaredType = symbol && getDeclaredTypeOfSymbol(symbol); - return declaredType !== unknownType ? declaredType : getTypeOfSymbol(symbol); - } - return unknownType; - } - function getTypeOfExpression(expr) { - if (ts.isRightSideOfQualifiedNameOrPropertyAccess(expr)) { - expr = expr.parent; - } - return checkExpression(expr); - } - /** - * Gets either the static or instance type of a class element, based on - * whether the element is declared as "static". - */ - function getParentTypeOfClassElement(node) { - var classSymbol = getSymbolOfNode(node.parent); - return node.flags & 128 /* Static */ - ? getTypeOfSymbol(classSymbol) - : getDeclaredTypeOfSymbol(classSymbol); - } - // Return the list of properties of the given type, augmented with properties from Function - // if the type has call or construct signatures - function getAugmentedPropertiesOfType(type) { - type = getApparentType(type); - var propsByName = createSymbolTable(getPropertiesOfType(type)); - if (getSignaturesOfType(type, 0 /* Call */).length || getSignaturesOfType(type, 1 /* Construct */).length) { - ts.forEach(getPropertiesOfType(globalFunctionType), function (p) { - if (!ts.hasProperty(propsByName, p.name)) { - propsByName[p.name] = p; - } - }); - } - return getNamedMembers(propsByName); - } - function getRootSymbols(symbol) { - if (symbol.flags & 268435456 /* SyntheticProperty */) { - var symbols = []; - var name_15 = symbol.name; - ts.forEach(getSymbolLinks(symbol).containingType.types, function (t) { - var symbol = getPropertyOfType(t, name_15); - if (symbol) { - symbols.push(symbol); - } - }); - return symbols; - } - else if (symbol.flags & 67108864 /* Transient */) { - var target = getSymbolLinks(symbol).target; - if (target) { - return [target]; - } - } - return [symbol]; - } - // Emitter support - // When resolved as an expression identifier, if the given node references an exported entity, return the declaration - // node of the exported entity's container. Otherwise, return undefined. - function getReferencedExportContainer(node) { - var symbol = getReferencedValueSymbol(node); - if (symbol) { - if (symbol.flags & 1048576 /* ExportValue */) { - // If we reference an exported entity within the same module declaration, then whether - // we prefix depends on the kind of entity. SymbolFlags.ExportHasLocal encompasses all the - // kinds that we do NOT prefix. - var exportSymbol = getMergedSymbol(symbol.exportSymbol); - if (exportSymbol.flags & 944 /* ExportHasLocal */) { - return undefined; - } - symbol = exportSymbol; - } - var parentSymbol = getParentOfSymbol(symbol); - if (parentSymbol) { - if (parentSymbol.flags & 512 /* ValueModule */ && parentSymbol.valueDeclaration.kind === 248 /* SourceFile */) { - return parentSymbol.valueDeclaration; - } - for (var n = node.parent; n; n = n.parent) { - if ((n.kind === 218 /* ModuleDeclaration */ || n.kind === 217 /* EnumDeclaration */) && getSymbolOfNode(n) === parentSymbol) { - return n; - } - } - } - } - } - // When resolved as an expression identifier, if the given node references an import, return the declaration of - // that import. Otherwise, return undefined. - function getReferencedImportDeclaration(node) { - var symbol = getReferencedValueSymbol(node); - return symbol && symbol.flags & 8388608 /* Alias */ ? getDeclarationOfAliasSymbol(symbol) : undefined; - } - function isStatementWithLocals(node) { - switch (node.kind) { - case 192 /* Block */: - case 220 /* CaseBlock */: - case 199 /* ForStatement */: - case 200 /* ForInStatement */: - case 201 /* ForOfStatement */: - return true; - } - return false; - } - function isNestedRedeclarationSymbol(symbol) { - if (symbol.flags & 418 /* BlockScoped */) { - var links = getSymbolLinks(symbol); - if (links.isNestedRedeclaration === undefined) { - var container = ts.getEnclosingBlockScopeContainer(symbol.valueDeclaration); - links.isNestedRedeclaration = isStatementWithLocals(container) && - !!resolveName(container.parent, symbol.name, 107455 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined); - } - return links.isNestedRedeclaration; - } - return false; - } - // When resolved as an expression identifier, if the given node references a nested block scoped entity with - // a name that hides an existing name, return the declaration of that entity. Otherwise, return undefined. - function getReferencedNestedRedeclaration(node) { - var symbol = getReferencedValueSymbol(node); - return symbol && isNestedRedeclarationSymbol(symbol) ? symbol.valueDeclaration : undefined; - } - // Return true if the given node is a declaration of a nested block scoped entity with a name that hides an - // existing name. - function isNestedRedeclaration(node) { - return isNestedRedeclarationSymbol(getSymbolOfNode(node)); - } - function isValueAliasDeclaration(node) { - switch (node.kind) { - case 221 /* ImportEqualsDeclaration */: - case 223 /* ImportClause */: - case 224 /* NamespaceImport */: - case 226 /* ImportSpecifier */: - case 230 /* ExportSpecifier */: - return isAliasResolvedToValue(getSymbolOfNode(node)); - case 228 /* ExportDeclaration */: - var exportClause = node.exportClause; - return exportClause && ts.forEach(exportClause.elements, isValueAliasDeclaration); - case 227 /* ExportAssignment */: - return node.expression && node.expression.kind === 69 /* Identifier */ ? isAliasResolvedToValue(getSymbolOfNode(node)) : true; - } - return false; - } - function isTopLevelValueImportEqualsWithEntityName(node) { - if (node.parent.kind !== 248 /* SourceFile */ || !ts.isInternalModuleImportEqualsDeclaration(node)) { - // parent is not source file or it is not reference to internal module - return false; - } - var isValue = isAliasResolvedToValue(getSymbolOfNode(node)); - return isValue && node.moduleReference && !ts.nodeIsMissing(node.moduleReference); - } - function isAliasResolvedToValue(symbol) { - var target = resolveAlias(symbol); - if (target === unknownSymbol && compilerOptions.isolatedModules) { - return true; - } - // const enums and modules that contain only const enums are not considered values from the emit perespective - // unless 'preserveConstEnums' option is set to true - return target !== unknownSymbol && - target && - target.flags & 107455 /* Value */ && - (compilerOptions.preserveConstEnums || !isConstEnumOrConstEnumOnlyModule(target)); - } - function isConstEnumOrConstEnumOnlyModule(s) { - return isConstEnumSymbol(s) || s.constEnumOnlyModule; - } - function isReferencedAliasDeclaration(node, checkChildren) { - if (ts.isAliasSymbolDeclaration(node)) { - var symbol = getSymbolOfNode(node); - if (getSymbolLinks(symbol).referenced) { - return true; - } - } - if (checkChildren) { - return ts.forEachChild(node, function (node) { return isReferencedAliasDeclaration(node, checkChildren); }); - } - return false; - } - function isImplementationOfOverload(node) { - if (ts.nodeIsPresent(node.body)) { - var symbol = getSymbolOfNode(node); - var signaturesOfSymbol = getSignaturesOfSymbol(symbol); - // If this function body corresponds to function with multiple signature, it is implementation of overload - // e.g.: function foo(a: string): string; - // function foo(a: number): number; - // function foo(a: any) { // This is implementation of the overloads - // return a; - // } - return signaturesOfSymbol.length > 1 || - // If there is single signature for the symbol, it is overload if that signature isn't coming from the node - // e.g.: function foo(a: string): string; - // function foo(a: any) { // This is implementation of the overloads - // return a; - // } - (signaturesOfSymbol.length === 1 && signaturesOfSymbol[0].declaration !== node); - } - return false; - } - function getNodeCheckFlags(node) { - return getNodeLinks(node).flags; - } - function getEnumMemberValue(node) { - computeEnumMemberValues(node.parent); - return getNodeLinks(node).enumMemberValue; - } - function getConstantValue(node) { - if (node.kind === 247 /* EnumMember */) { - return getEnumMemberValue(node); - } - var symbol = getNodeLinks(node).resolvedSymbol; - if (symbol && (symbol.flags & 8 /* EnumMember */)) { - // inline property\index accesses only for const enums - if (ts.isConstEnumDeclaration(symbol.valueDeclaration.parent)) { - return getEnumMemberValue(symbol.valueDeclaration); - } - } - return undefined; - } - function isFunctionType(type) { - return type.flags & 80896 /* ObjectType */ && getSignaturesOfType(type, 0 /* Call */).length > 0; - } - function getTypeReferenceSerializationKind(typeName) { - // Resolve the symbol as a value to ensure the type can be reached at runtime during emit. - var valueSymbol = resolveEntityName(typeName, 107455 /* Value */, /*ignoreErrors*/ true); - var constructorType = valueSymbol ? getTypeOfSymbol(valueSymbol) : undefined; - if (constructorType && isConstructorType(constructorType)) { - return ts.TypeReferenceSerializationKind.TypeWithConstructSignatureAndValue; - } - // Resolve the symbol as a type so that we can provide a more useful hint for the type serializer. - var typeSymbol = resolveEntityName(typeName, 793056 /* Type */, /*ignoreErrors*/ true); - // We might not be able to resolve type symbol so use unknown type in that case (eg error case) - if (!typeSymbol) { - return ts.TypeReferenceSerializationKind.ObjectType; - } - var type = getDeclaredTypeOfSymbol(typeSymbol); - if (type === unknownType) { - return ts.TypeReferenceSerializationKind.Unknown; - } - else if (type.flags & 1 /* Any */) { - return ts.TypeReferenceSerializationKind.ObjectType; - } - else if (allConstituentTypesHaveKind(type, 16 /* Void */)) { - return ts.TypeReferenceSerializationKind.VoidType; - } - else if (allConstituentTypesHaveKind(type, 8 /* Boolean */)) { - return ts.TypeReferenceSerializationKind.BooleanType; - } - else if (allConstituentTypesHaveKind(type, 132 /* NumberLike */)) { - return ts.TypeReferenceSerializationKind.NumberLikeType; - } - else if (allConstituentTypesHaveKind(type, 258 /* StringLike */)) { - return ts.TypeReferenceSerializationKind.StringLikeType; - } - else if (allConstituentTypesHaveKind(type, 8192 /* Tuple */)) { - return ts.TypeReferenceSerializationKind.ArrayLikeType; - } - else if (allConstituentTypesHaveKind(type, 16777216 /* ESSymbol */)) { - return ts.TypeReferenceSerializationKind.ESSymbolType; - } - else if (isFunctionType(type)) { - return ts.TypeReferenceSerializationKind.TypeWithCallSignature; - } - else if (isArrayType(type)) { - return ts.TypeReferenceSerializationKind.ArrayLikeType; - } - else { - return ts.TypeReferenceSerializationKind.ObjectType; - } - } - function writeTypeOfDeclaration(declaration, enclosingDeclaration, flags, writer) { - // Get type of the symbol if this is the valid symbol otherwise get type at location - var symbol = getSymbolOfNode(declaration); - var type = symbol && !(symbol.flags & (2048 /* TypeLiteral */ | 131072 /* Signature */)) - ? getTypeOfSymbol(symbol) - : unknownType; - getSymbolDisplayBuilder().buildTypeDisplay(type, writer, enclosingDeclaration, flags); - } - function writeReturnTypeOfSignatureDeclaration(signatureDeclaration, enclosingDeclaration, flags, writer) { - var signature = getSignatureFromDeclaration(signatureDeclaration); - getSymbolDisplayBuilder().buildTypeDisplay(getReturnTypeOfSignature(signature), writer, enclosingDeclaration, flags); - } - function writeTypeOfExpression(expr, enclosingDeclaration, flags, writer) { - var type = getTypeOfExpression(expr); - getSymbolDisplayBuilder().buildTypeDisplay(type, writer, enclosingDeclaration, flags); - } - function hasGlobalName(name) { - return ts.hasProperty(globals, name); - } - function getReferencedValueSymbol(reference) { - return getNodeLinks(reference).resolvedSymbol || - resolveName(reference, reference.text, 107455 /* Value */ | 1048576 /* ExportValue */ | 8388608 /* Alias */, - /*nodeNotFoundMessage*/ undefined, /*nameArg*/ undefined); - } - function getReferencedValueDeclaration(reference) { - ts.Debug.assert(!ts.nodeIsSynthesized(reference)); - var symbol = getReferencedValueSymbol(reference); - return symbol && getExportSymbolOfValueSymbolIfExported(symbol).valueDeclaration; - } - function instantiateSingleCallFunctionType(functionType, typeArguments) { - if (functionType === unknownType) { - return unknownType; - } - var signature = getSingleCallSignature(functionType); - if (!signature) { - return unknownType; - } - var instantiatedSignature = getSignatureInstantiation(signature, typeArguments); - return getOrCreateTypeFromSignature(instantiatedSignature); - } - function createResolver() { - return { - getReferencedExportContainer: getReferencedExportContainer, - getReferencedImportDeclaration: getReferencedImportDeclaration, - getReferencedNestedRedeclaration: getReferencedNestedRedeclaration, - isNestedRedeclaration: isNestedRedeclaration, - isValueAliasDeclaration: isValueAliasDeclaration, - hasGlobalName: hasGlobalName, - isReferencedAliasDeclaration: isReferencedAliasDeclaration, - getNodeCheckFlags: getNodeCheckFlags, - isTopLevelValueImportEqualsWithEntityName: isTopLevelValueImportEqualsWithEntityName, - isDeclarationVisible: isDeclarationVisible, - isImplementationOfOverload: isImplementationOfOverload, - writeTypeOfDeclaration: writeTypeOfDeclaration, - writeReturnTypeOfSignatureDeclaration: writeReturnTypeOfSignatureDeclaration, - writeTypeOfExpression: writeTypeOfExpression, - isSymbolAccessible: isSymbolAccessible, - isEntityNameVisible: isEntityNameVisible, - getConstantValue: getConstantValue, - collectLinkedAliases: collectLinkedAliases, - getReferencedValueDeclaration: getReferencedValueDeclaration, - getTypeReferenceSerializationKind: getTypeReferenceSerializationKind, - isOptionalParameter: isOptionalParameter - }; - } - function initializeTypeChecker() { - // Bind all source files and propagate errors - ts.forEach(host.getSourceFiles(), function (file) { - ts.bindSourceFile(file); - }); - // Initialize global symbol table - ts.forEach(host.getSourceFiles(), function (file) { - if (!ts.isExternalModule(file)) { - mergeSymbolTable(globals, file.locals); - } - }); - // Initialize special symbols - getSymbolLinks(undefinedSymbol).type = undefinedType; - getSymbolLinks(argumentsSymbol).type = getGlobalType("IArguments"); - getSymbolLinks(unknownSymbol).type = unknownType; - globals[undefinedSymbol.name] = undefinedSymbol; - // Initialize special types - globalArrayType = getGlobalType("Array", /*arity*/ 1); - globalObjectType = getGlobalType("Object"); - globalFunctionType = getGlobalType("Function"); - globalStringType = getGlobalType("String"); - globalNumberType = getGlobalType("Number"); - globalBooleanType = getGlobalType("Boolean"); - globalRegExpType = getGlobalType("RegExp"); - jsxElementType = getExportedTypeFromNamespace("JSX", JsxNames.Element); - getGlobalClassDecoratorType = ts.memoize(function () { return getGlobalType("ClassDecorator"); }); - getGlobalPropertyDecoratorType = ts.memoize(function () { return getGlobalType("PropertyDecorator"); }); - getGlobalMethodDecoratorType = ts.memoize(function () { return getGlobalType("MethodDecorator"); }); - getGlobalParameterDecoratorType = ts.memoize(function () { return getGlobalType("ParameterDecorator"); }); - getGlobalTypedPropertyDescriptorType = ts.memoize(function () { return getGlobalType("TypedPropertyDescriptor", /*arity*/ 1); }); - getGlobalPromiseType = ts.memoize(function () { return getGlobalType("Promise", /*arity*/ 1); }); - tryGetGlobalPromiseType = ts.memoize(function () { return getGlobalSymbol("Promise", 793056 /* Type */, /*diagnostic*/ undefined) && getGlobalPromiseType(); }); - getGlobalPromiseLikeType = ts.memoize(function () { return getGlobalType("PromiseLike", /*arity*/ 1); }); - getInstantiatedGlobalPromiseLikeType = ts.memoize(createInstantiatedPromiseLikeType); - getGlobalPromiseConstructorSymbol = ts.memoize(function () { return getGlobalValueSymbol("Promise"); }); - getGlobalPromiseConstructorLikeType = ts.memoize(function () { return getGlobalType("PromiseConstructorLike"); }); - getGlobalThenableType = ts.memoize(createThenableType); - // If we're in ES6 mode, load the TemplateStringsArray. - // Otherwise, default to 'unknown' for the purposes of type checking in LS scenarios. - if (languageVersion >= 2 /* ES6 */) { - globalTemplateStringsArrayType = getGlobalType("TemplateStringsArray"); - globalESSymbolType = getGlobalType("Symbol"); - globalESSymbolConstructorSymbol = getGlobalValueSymbol("Symbol"); - globalIterableType = getGlobalType("Iterable", /*arity*/ 1); - globalIteratorType = getGlobalType("Iterator", /*arity*/ 1); - globalIterableIteratorType = getGlobalType("IterableIterator", /*arity*/ 1); - } - else { - globalTemplateStringsArrayType = unknownType; - // Consider putting Symbol interface in lib.d.ts. On the plus side, putting it in lib.d.ts would make it - // extensible for Polyfilling Symbols. But putting it into lib.d.ts could also break users that have - // a global Symbol already, particularly if it is a class. - globalESSymbolType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); - globalESSymbolConstructorSymbol = undefined; - globalIterableType = emptyGenericType; - globalIteratorType = emptyGenericType; - globalIterableIteratorType = emptyGenericType; - } - anyArrayType = createArrayType(anyType); - } - function createInstantiatedPromiseLikeType() { - var promiseLikeType = getGlobalPromiseLikeType(); - if (promiseLikeType !== emptyGenericType) { - return createTypeReference(promiseLikeType, [anyType]); - } - return emptyObjectType; - } - function createThenableType() { - // build the thenable type that is used to verify against a non-promise "thenable" operand to `await`. - var thenPropertySymbol = createSymbol(67108864 /* Transient */ | 4 /* Property */, "then"); - getSymbolLinks(thenPropertySymbol).type = globalFunctionType; - var thenableType = createObjectType(65536 /* Anonymous */); - thenableType.properties = [thenPropertySymbol]; - thenableType.members = createSymbolTable(thenableType.properties); - thenableType.callSignatures = []; - thenableType.constructSignatures = []; - return thenableType; - } - // GRAMMAR CHECKING - function checkGrammarDecorators(node) { - if (!node.decorators) { - return false; - } - if (!ts.nodeCanBeDecorated(node)) { - return grammarErrorOnFirstToken(node, ts.Diagnostics.Decorators_are_not_valid_here); - } - else if (node.kind === 145 /* GetAccessor */ || node.kind === 146 /* SetAccessor */) { - var accessors = ts.getAllAccessorDeclarations(node.parent.members, node); - if (accessors.firstAccessor.decorators && node === accessors.secondAccessor) { - return grammarErrorOnFirstToken(node, ts.Diagnostics.Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name); - } - } - return false; - } - function checkGrammarModifiers(node) { - switch (node.kind) { - case 145 /* GetAccessor */: - case 146 /* SetAccessor */: - case 144 /* Constructor */: - case 141 /* PropertyDeclaration */: - case 140 /* PropertySignature */: - case 143 /* MethodDeclaration */: - case 142 /* MethodSignature */: - case 149 /* IndexSignature */: - case 218 /* ModuleDeclaration */: - case 222 /* ImportDeclaration */: - case 221 /* ImportEqualsDeclaration */: - case 228 /* ExportDeclaration */: - case 227 /* ExportAssignment */: - case 138 /* Parameter */: - break; - case 213 /* FunctionDeclaration */: - if (node.modifiers && (node.modifiers.length > 1 || node.modifiers[0].kind !== 118 /* AsyncKeyword */) && - node.parent.kind !== 219 /* ModuleBlock */ && node.parent.kind !== 248 /* SourceFile */) { - return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); - } - break; - case 214 /* ClassDeclaration */: - case 215 /* InterfaceDeclaration */: - case 193 /* VariableStatement */: - case 216 /* TypeAliasDeclaration */: - if (node.modifiers && node.parent.kind !== 219 /* ModuleBlock */ && node.parent.kind !== 248 /* SourceFile */) { - return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); - } - break; - case 217 /* EnumDeclaration */: - if (node.modifiers && (node.modifiers.length > 1 || node.modifiers[0].kind !== 74 /* ConstKeyword */) && - node.parent.kind !== 219 /* ModuleBlock */ && node.parent.kind !== 248 /* SourceFile */) { - return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); - } - break; - default: - return false; - } - if (!node.modifiers) { - return; - } - var lastStatic, lastPrivate, lastProtected, lastDeclare, lastAsync; - var flags = 0; - for (var _i = 0, _a = node.modifiers; _i < _a.length; _i++) { - var modifier = _a[_i]; - switch (modifier.kind) { - case 112 /* PublicKeyword */: - case 111 /* ProtectedKeyword */: - case 110 /* PrivateKeyword */: - var text = void 0; - if (modifier.kind === 112 /* PublicKeyword */) { - text = "public"; - } - else if (modifier.kind === 111 /* ProtectedKeyword */) { - text = "protected"; - lastProtected = modifier; - } - else { - text = "private"; - lastPrivate = modifier; - } - if (flags & 112 /* AccessibilityModifier */) { - return grammarErrorOnNode(modifier, ts.Diagnostics.Accessibility_modifier_already_seen); - } - else if (flags & 128 /* Static */) { - return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "static"); - } - else if (flags & 512 /* Async */) { - return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "async"); - } - else if (node.parent.kind === 219 /* ModuleBlock */ || node.parent.kind === 248 /* SourceFile */) { - return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_element, text); - } - else if (flags & 256 /* Abstract */) { - if (modifier.kind === 110 /* PrivateKeyword */) { - return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, text, "abstract"); - } - else { - return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "abstract"); - } - } - flags |= ts.modifierToFlag(modifier.kind); - break; - case 113 /* StaticKeyword */: - if (flags & 128 /* Static */) { - return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "static"); - } - else if (flags & 512 /* Async */) { - return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "static", "async"); - } - else if (node.parent.kind === 219 /* ModuleBlock */ || node.parent.kind === 248 /* SourceFile */) { - return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_element, "static"); - } - else if (node.kind === 138 /* Parameter */) { - return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "static"); - } - else if (flags & 256 /* Abstract */) { - return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "static", "abstract"); - } - flags |= 128 /* Static */; - lastStatic = modifier; - break; - case 82 /* ExportKeyword */: - if (flags & 1 /* Export */) { - return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "export"); - } - else if (flags & 2 /* Ambient */) { - return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "declare"); - } - else if (flags & 256 /* Abstract */) { - return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "abstract"); - } - else if (flags & 512 /* Async */) { - return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "async"); - } - else if (node.parent.kind === 214 /* ClassDeclaration */) { - return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "export"); - } - else if (node.kind === 138 /* Parameter */) { - return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "export"); - } - flags |= 1 /* Export */; - break; - case 122 /* DeclareKeyword */: - if (flags & 2 /* Ambient */) { - return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "declare"); - } - else if (flags & 512 /* Async */) { - return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); - } - else if (node.parent.kind === 214 /* ClassDeclaration */) { - return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "declare"); - } - else if (node.kind === 138 /* Parameter */) { - return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "declare"); - } - else if (ts.isInAmbientContext(node.parent) && node.parent.kind === 219 /* ModuleBlock */) { - return grammarErrorOnNode(modifier, ts.Diagnostics.A_declare_modifier_cannot_be_used_in_an_already_ambient_context); - } - flags |= 2 /* Ambient */; - lastDeclare = modifier; - break; - case 115 /* AbstractKeyword */: - if (flags & 256 /* Abstract */) { - return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "abstract"); - } - if (node.kind !== 214 /* ClassDeclaration */) { - if (node.kind !== 143 /* MethodDeclaration */) { - return grammarErrorOnNode(modifier, ts.Diagnostics.abstract_modifier_can_only_appear_on_a_class_or_method_declaration); - } - if (!(node.parent.kind === 214 /* ClassDeclaration */ && node.parent.flags & 256 /* Abstract */)) { - return grammarErrorOnNode(modifier, ts.Diagnostics.Abstract_methods_can_only_appear_within_an_abstract_class); - } - if (flags & 128 /* Static */) { - return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "static", "abstract"); - } - if (flags & 32 /* Private */) { - return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "private", "abstract"); - } - } - flags |= 256 /* Abstract */; - break; - case 118 /* AsyncKeyword */: - if (flags & 512 /* Async */) { - return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "async"); - } - else if (flags & 2 /* Ambient */ || ts.isInAmbientContext(node.parent)) { - return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); - } - else if (node.kind === 138 /* Parameter */) { - return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "async"); - } - flags |= 512 /* Async */; - lastAsync = modifier; - break; - } - } - if (node.kind === 144 /* Constructor */) { - if (flags & 128 /* Static */) { - return grammarErrorOnNode(lastStatic, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "static"); - } - if (flags & 256 /* Abstract */) { - return grammarErrorOnNode(lastStatic, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "abstract"); - } - else if (flags & 64 /* Protected */) { - return grammarErrorOnNode(lastProtected, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "protected"); - } - else if (flags & 32 /* Private */) { - return grammarErrorOnNode(lastPrivate, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "private"); - } - else if (flags & 512 /* Async */) { - return grammarErrorOnNode(lastAsync, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "async"); - } - return; - } - else if ((node.kind === 222 /* ImportDeclaration */ || node.kind === 221 /* ImportEqualsDeclaration */) && flags & 2 /* Ambient */) { - return grammarErrorOnNode(lastDeclare, ts.Diagnostics.A_0_modifier_cannot_be_used_with_an_import_declaration, "declare"); - } - else if (node.kind === 138 /* Parameter */ && (flags & 112 /* AccessibilityModifier */) && ts.isBindingPattern(node.name)) { - return grammarErrorOnNode(node, ts.Diagnostics.A_parameter_property_may_not_be_a_binding_pattern); - } - if (flags & 512 /* Async */) { - return checkGrammarAsyncModifier(node, lastAsync); - } - } - function checkGrammarAsyncModifier(node, asyncModifier) { - if (languageVersion < 2 /* ES6 */) { - return grammarErrorOnNode(asyncModifier, ts.Diagnostics.Async_functions_are_only_available_when_targeting_ECMAScript_6_and_higher); - } - switch (node.kind) { - case 143 /* MethodDeclaration */: - case 213 /* FunctionDeclaration */: - case 173 /* FunctionExpression */: - case 174 /* ArrowFunction */: - if (!node.asteriskToken) { - return false; - } - break; - } - return grammarErrorOnNode(asyncModifier, ts.Diagnostics._0_modifier_cannot_be_used_here, "async"); - } - function checkGrammarForDisallowedTrailingComma(list) { - if (list && list.hasTrailingComma) { - var start = list.end - ",".length; - var end = list.end; - var sourceFile = ts.getSourceFileOfNode(list[0]); - return grammarErrorAtPos(sourceFile, start, end - start, ts.Diagnostics.Trailing_comma_not_allowed); - } - } - function checkGrammarTypeParameterList(node, typeParameters, file) { - if (checkGrammarForDisallowedTrailingComma(typeParameters)) { - return true; - } - if (typeParameters && typeParameters.length === 0) { - var start = typeParameters.pos - "<".length; - var end = ts.skipTrivia(file.text, typeParameters.end) + ">".length; - return grammarErrorAtPos(file, start, end - start, ts.Diagnostics.Type_parameter_list_cannot_be_empty); - } - } - function checkGrammarParameterList(parameters) { - if (checkGrammarForDisallowedTrailingComma(parameters)) { - return true; - } - var seenOptionalParameter = false; - var parameterCount = parameters.length; - for (var i = 0; i < parameterCount; i++) { - var parameter = parameters[i]; - if (parameter.dotDotDotToken) { - if (i !== (parameterCount - 1)) { - return grammarErrorOnNode(parameter.dotDotDotToken, ts.Diagnostics.A_rest_parameter_must_be_last_in_a_parameter_list); - } - if (ts.isBindingPattern(parameter.name)) { - return grammarErrorOnNode(parameter.name, ts.Diagnostics.A_rest_element_cannot_contain_a_binding_pattern); - } - if (parameter.questionToken) { - return grammarErrorOnNode(parameter.questionToken, ts.Diagnostics.A_rest_parameter_cannot_be_optional); - } - if (parameter.initializer) { - return grammarErrorOnNode(parameter.name, ts.Diagnostics.A_rest_parameter_cannot_have_an_initializer); - } - } - else if (parameter.questionToken) { - seenOptionalParameter = true; - if (parameter.initializer) { - return grammarErrorOnNode(parameter.name, ts.Diagnostics.Parameter_cannot_have_question_mark_and_initializer); - } - } - else if (seenOptionalParameter && !parameter.initializer) { - return grammarErrorOnNode(parameter.name, ts.Diagnostics.A_required_parameter_cannot_follow_an_optional_parameter); - } - } - } - function checkGrammarFunctionLikeDeclaration(node) { - // Prevent cascading error by short-circuit - var file = ts.getSourceFileOfNode(node); - return checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarTypeParameterList(node, node.typeParameters, file) || - checkGrammarParameterList(node.parameters) || checkGrammarArrowFunction(node, file); - } - function checkGrammarArrowFunction(node, file) { - if (node.kind === 174 /* ArrowFunction */) { - var arrowFunction = node; - var startLine = ts.getLineAndCharacterOfPosition(file, arrowFunction.equalsGreaterThanToken.pos).line; - var endLine = ts.getLineAndCharacterOfPosition(file, arrowFunction.equalsGreaterThanToken.end).line; - if (startLine !== endLine) { - return grammarErrorOnNode(arrowFunction.equalsGreaterThanToken, ts.Diagnostics.Line_terminator_not_permitted_before_arrow); - } - } - return false; - } - function checkGrammarIndexSignatureParameters(node) { - var parameter = node.parameters[0]; - if (node.parameters.length !== 1) { - if (parameter) { - return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_must_have_exactly_one_parameter); - } - else { - return grammarErrorOnNode(node, ts.Diagnostics.An_index_signature_must_have_exactly_one_parameter); - } - } - if (parameter.dotDotDotToken) { - return grammarErrorOnNode(parameter.dotDotDotToken, ts.Diagnostics.An_index_signature_cannot_have_a_rest_parameter); - } - if (parameter.flags & 2035 /* Modifier */) { - return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_cannot_have_an_accessibility_modifier); - } - if (parameter.questionToken) { - return grammarErrorOnNode(parameter.questionToken, ts.Diagnostics.An_index_signature_parameter_cannot_have_a_question_mark); - } - if (parameter.initializer) { - return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_cannot_have_an_initializer); - } - if (!parameter.type) { - return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_must_have_a_type_annotation); - } - if (parameter.type.kind !== 130 /* StringKeyword */ && parameter.type.kind !== 128 /* NumberKeyword */) { - return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_type_must_be_string_or_number); - } - if (!node.type) { - return grammarErrorOnNode(node, ts.Diagnostics.An_index_signature_must_have_a_type_annotation); - } - } - function checkGrammarForIndexSignatureModifier(node) { - if (node.flags & 2035 /* Modifier */) { - grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_not_permitted_on_index_signature_members); - } - } - function checkGrammarIndexSignature(node) { - // Prevent cascading error by short-circuit - return checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarIndexSignatureParameters(node) || checkGrammarForIndexSignatureModifier(node); - } - function checkGrammarForAtLeastOneTypeArgument(node, typeArguments) { - if (typeArguments && typeArguments.length === 0) { - var sourceFile = ts.getSourceFileOfNode(node); - var start = typeArguments.pos - "<".length; - var end = ts.skipTrivia(sourceFile.text, typeArguments.end) + ">".length; - return grammarErrorAtPos(sourceFile, start, end - start, ts.Diagnostics.Type_argument_list_cannot_be_empty); - } - } - function checkGrammarTypeArguments(node, typeArguments) { - return checkGrammarForDisallowedTrailingComma(typeArguments) || - checkGrammarForAtLeastOneTypeArgument(node, typeArguments); - } - function checkGrammarForOmittedArgument(node, args) { - if (args) { - var sourceFile = ts.getSourceFileOfNode(node); - for (var _i = 0; _i < args.length; _i++) { - var arg = args[_i]; - if (arg.kind === 187 /* OmittedExpression */) { - return grammarErrorAtPos(sourceFile, arg.pos, 0, ts.Diagnostics.Argument_expression_expected); - } - } - } - } - function checkGrammarArguments(node, args) { - return checkGrammarForDisallowedTrailingComma(args) || - checkGrammarForOmittedArgument(node, args); - } - function checkGrammarHeritageClause(node) { - var types = node.types; - if (checkGrammarForDisallowedTrailingComma(types)) { - return true; - } - if (types && types.length === 0) { - var listType = ts.tokenToString(node.token); - var sourceFile = ts.getSourceFileOfNode(node); - return grammarErrorAtPos(sourceFile, types.pos, 0, ts.Diagnostics._0_list_cannot_be_empty, listType); - } - } - function checkGrammarClassDeclarationHeritageClauses(node) { - var seenExtendsClause = false; - var seenImplementsClause = false; - 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 (seenExtendsClause) { - return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_already_seen); - } - if (seenImplementsClause) { - return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_must_precede_implements_clause); - } - if (heritageClause.types.length > 1) { - return grammarErrorOnFirstToken(heritageClause.types[1], ts.Diagnostics.Classes_can_only_extend_a_single_class); - } - seenExtendsClause = true; - } - else { - ts.Debug.assert(heritageClause.token === 106 /* ImplementsKeyword */); - if (seenImplementsClause) { - return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.implements_clause_already_seen); - } - seenImplementsClause = true; - } - // Grammar checking heritageClause inside class declaration - checkGrammarHeritageClause(heritageClause); - } - } - } - function checkGrammarInterfaceDeclaration(node) { - var seenExtendsClause = false; - if (node.heritageClauses) { - for (var _i = 0, _a = node.heritageClauses; _i < _a.length; _i++) { - var heritageClause = _a[_i]; - if (heritageClause.token === 83 /* ExtendsKeyword */) { - if (seenExtendsClause) { - return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_already_seen); - } - seenExtendsClause = true; - } - else { - ts.Debug.assert(heritageClause.token === 106 /* ImplementsKeyword */); - return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.Interface_declaration_cannot_have_implements_clause); - } - // Grammar checking heritageClause inside class declaration - checkGrammarHeritageClause(heritageClause); - } - } - return false; - } - function checkGrammarComputedPropertyName(node) { - // If node is not a computedPropertyName, just skip the grammar checking - if (node.kind !== 136 /* ComputedPropertyName */) { - return false; - } - var computedPropertyName = node; - if (computedPropertyName.expression.kind === 181 /* BinaryExpression */ && computedPropertyName.expression.operatorToken.kind === 24 /* CommaToken */) { - return grammarErrorOnNode(computedPropertyName.expression, ts.Diagnostics.A_comma_expression_is_not_allowed_in_a_computed_property_name); - } - } - function checkGrammarForGenerator(node) { - if (node.asteriskToken) { - ts.Debug.assert(node.kind === 213 /* FunctionDeclaration */ || - node.kind === 173 /* FunctionExpression */ || - node.kind === 143 /* MethodDeclaration */); - if (ts.isInAmbientContext(node)) { - return grammarErrorOnNode(node.asteriskToken, ts.Diagnostics.Generators_are_not_allowed_in_an_ambient_context); - } - if (!node.body) { - return grammarErrorOnNode(node.asteriskToken, ts.Diagnostics.An_overload_signature_cannot_be_declared_as_a_generator); - } - if (languageVersion < 2 /* ES6 */) { - return grammarErrorOnNode(node.asteriskToken, ts.Diagnostics.Generators_are_only_available_when_targeting_ECMAScript_6_or_higher); - } - } - } - function checkGrammarForInvalidQuestionMark(node, questionToken, message) { - if (questionToken) { - return grammarErrorOnNode(questionToken, message); - } - } - function checkGrammarObjectLiteralExpression(node, inDestructuring) { - var seen = {}; - var Property = 1; - var GetAccessor = 2; - var SetAccesor = 4; - var GetOrSetAccessor = GetAccessor | SetAccesor; - for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { - var prop = _a[_i]; - var name_16 = prop.name; - if (prop.kind === 187 /* OmittedExpression */ || - name_16.kind === 136 /* ComputedPropertyName */) { - // If the name is not a ComputedPropertyName, the grammar checking will skip it - checkGrammarComputedPropertyName(name_16); - continue; - } - if (prop.kind === 246 /* ShorthandPropertyAssignment */ && !inDestructuring && prop.objectAssignmentInitializer) { - // having objectAssignmentInitializer is only valid in ObjectAssignmentPattern - // outside of destructuring it is a syntax error - return grammarErrorOnNode(prop.equalsToken, ts.Diagnostics.can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment); - } - // ECMA-262 11.1.5 Object Initialiser - // If previous is not undefined then throw a SyntaxError exception if any of the following conditions are true - // a.This production is contained in strict code and IsDataDescriptor(previous) is true and - // 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 - var currentKind = void 0; - if (prop.kind === 245 /* PropertyAssignment */ || prop.kind === 246 /* ShorthandPropertyAssignment */) { - // Grammar checking for computedPropertName and shorthandPropertyAssignment - checkGrammarForInvalidQuestionMark(prop, prop.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional); - if (name_16.kind === 8 /* NumericLiteral */) { - checkGrammarNumericLiteral(name_16); - } - currentKind = Property; - } - else if (prop.kind === 143 /* MethodDeclaration */) { - currentKind = Property; - } - else if (prop.kind === 145 /* GetAccessor */) { - currentKind = GetAccessor; - } - else if (prop.kind === 146 /* SetAccessor */) { - currentKind = SetAccesor; - } - else { - ts.Debug.fail("Unexpected syntax kind:" + prop.kind); - } - if (!ts.hasProperty(seen, name_16.text)) { - seen[name_16.text] = currentKind; - } - else { - var existingKind = seen[name_16.text]; - if (currentKind === Property && existingKind === Property) { - continue; - } - else if ((currentKind & GetOrSetAccessor) && (existingKind & GetOrSetAccessor)) { - if (existingKind !== GetOrSetAccessor && currentKind !== existingKind) { - seen[name_16.text] = currentKind | existingKind; - } - else { - return grammarErrorOnNode(name_16, ts.Diagnostics.An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name); - } - } - else { - return grammarErrorOnNode(name_16, ts.Diagnostics.An_object_literal_cannot_have_property_and_accessor_with_the_same_name); - } - } - } - } - function checkGrammarJsxElement(node) { - var seen = {}; - for (var _i = 0, _a = node.attributes; _i < _a.length; _i++) { - var attr = _a[_i]; - if (attr.kind === 239 /* JsxSpreadAttribute */) { - continue; - } - var jsxAttr = attr; - var name_17 = jsxAttr.name; - if (!ts.hasProperty(seen, name_17.text)) { - seen[name_17.text] = true; - } - else { - return grammarErrorOnNode(name_17, ts.Diagnostics.JSX_elements_cannot_have_multiple_attributes_with_the_same_name); - } - var initializer = jsxAttr.initializer; - if (initializer && initializer.kind === 240 /* JsxExpression */ && !initializer.expression) { - return grammarErrorOnNode(jsxAttr.initializer, ts.Diagnostics.JSX_attributes_must_only_be_assigned_a_non_empty_expression); - } - } - } - function checkGrammarForInOrForOfStatement(forInOrOfStatement) { - if (checkGrammarStatementInAmbientContext(forInOrOfStatement)) { - return true; - } - if (forInOrOfStatement.initializer.kind === 212 /* VariableDeclarationList */) { - var variableList = forInOrOfStatement.initializer; - if (!checkGrammarVariableDeclarationList(variableList)) { - if (variableList.declarations.length > 1) { - var diagnostic = forInOrOfStatement.kind === 200 /* ForInStatement */ - ? ts.Diagnostics.Only_a_single_variable_declaration_is_allowed_in_a_for_in_statement - : ts.Diagnostics.Only_a_single_variable_declaration_is_allowed_in_a_for_of_statement; - return grammarErrorOnFirstToken(variableList.declarations[1], diagnostic); - } - var firstDeclaration = variableList.declarations[0]; - if (firstDeclaration.initializer) { - var diagnostic = forInOrOfStatement.kind === 200 /* ForInStatement */ - ? ts.Diagnostics.The_variable_declaration_of_a_for_in_statement_cannot_have_an_initializer - : ts.Diagnostics.The_variable_declaration_of_a_for_of_statement_cannot_have_an_initializer; - return grammarErrorOnNode(firstDeclaration.name, diagnostic); - } - if (firstDeclaration.type) { - var diagnostic = forInOrOfStatement.kind === 200 /* ForInStatement */ - ? ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_use_a_type_annotation - : ts.Diagnostics.The_left_hand_side_of_a_for_of_statement_cannot_use_a_type_annotation; - return grammarErrorOnNode(firstDeclaration, diagnostic); - } - } - } - return false; - } - function checkGrammarAccessor(accessor) { - var kind = accessor.kind; - if (languageVersion < 1 /* ES5 */) { - return grammarErrorOnNode(accessor.name, ts.Diagnostics.Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher); - } - else if (ts.isInAmbientContext(accessor)) { - return grammarErrorOnNode(accessor.name, ts.Diagnostics.An_accessor_cannot_be_declared_in_an_ambient_context); - } - else if (accessor.body === undefined) { - return grammarErrorAtPos(ts.getSourceFileOfNode(accessor), accessor.end - 1, ";".length, ts.Diagnostics._0_expected, "{"); - } - else if (accessor.typeParameters) { - return grammarErrorOnNode(accessor.name, ts.Diagnostics.An_accessor_cannot_have_type_parameters); - } - else if (kind === 145 /* GetAccessor */ && accessor.parameters.length) { - return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_get_accessor_cannot_have_parameters); - } - else if (kind === 146 /* SetAccessor */) { - if (accessor.type) { - return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_set_accessor_cannot_have_a_return_type_annotation); - } - else if (accessor.parameters.length !== 1) { - return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_set_accessor_must_have_exactly_one_parameter); - } - else { - var parameter = accessor.parameters[0]; - if (parameter.dotDotDotToken) { - return grammarErrorOnNode(parameter.dotDotDotToken, ts.Diagnostics.A_set_accessor_cannot_have_rest_parameter); - } - else if (parameter.flags & 2035 /* Modifier */) { - return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation); - } - else if (parameter.questionToken) { - return grammarErrorOnNode(parameter.questionToken, ts.Diagnostics.A_set_accessor_cannot_have_an_optional_parameter); - } - else if (parameter.initializer) { - return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_set_accessor_parameter_cannot_have_an_initializer); - } - } - } - } - function checkGrammarForNonSymbolComputedProperty(node, message) { - if (node.kind === 136 /* ComputedPropertyName */ && !ts.isWellKnownSymbolSyntactically(node.expression)) { - return grammarErrorOnNode(node, message); - } - } - function checkGrammarMethod(node) { - if (checkGrammarDisallowedModifiersOnObjectLiteralExpressionMethod(node) || - checkGrammarFunctionLikeDeclaration(node) || - checkGrammarForGenerator(node)) { - return true; - } - if (node.parent.kind === 165 /* ObjectLiteralExpression */) { - if (checkGrammarForInvalidQuestionMark(node, node.questionToken, ts.Diagnostics.A_class_member_cannot_be_declared_optional)) { - return true; - } - else if (node.body === undefined) { - return grammarErrorAtPos(getSourceFile(node), node.end - 1, ";".length, ts.Diagnostics._0_expected, "{"); - } - } - if (ts.isClassLike(node.parent)) { - if (checkGrammarForInvalidQuestionMark(node, node.questionToken, ts.Diagnostics.A_class_member_cannot_be_declared_optional)) { - return true; - } - // Technically, computed properties in ambient contexts is disallowed - // for property declarations and accessors too, not just methods. - // However, property declarations disallow computed names in general, - // and accessors are not allowed in ambient contexts in general, - // so this error only really matters for methods. - if (ts.isInAmbientContext(node)) { - return checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_an_ambient_context_must_directly_refer_to_a_built_in_symbol); - } - else if (!node.body) { - 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 === 215 /* InterfaceDeclaration */) { - return checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_an_interface_must_directly_refer_to_a_built_in_symbol); - } - else if (node.parent.kind === 155 /* TypeLiteral */) { - return checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_type_literal_must_directly_refer_to_a_built_in_symbol); - } - } - function isIterationStatement(node, lookInLabeledStatements) { - switch (node.kind) { - case 199 /* ForStatement */: - case 200 /* ForInStatement */: - case 201 /* ForOfStatement */: - case 197 /* DoStatement */: - case 198 /* WhileStatement */: - return true; - case 207 /* LabeledStatement */: - return lookInLabeledStatements && isIterationStatement(node.statement, lookInLabeledStatements); - } - return false; - } - function checkGrammarBreakOrContinueStatement(node) { - var current = node; - while (current) { - if (ts.isFunctionLike(current)) { - return grammarErrorOnNode(node, ts.Diagnostics.Jump_target_cannot_cross_function_boundary); - } - switch (current.kind) { - case 207 /* LabeledStatement */: - if (node.label && current.label.text === node.label.text) { - // found matching label - verify that label usage is correct - // continue can only target labels that are on iteration statements - var isMisplacedContinueLabel = node.kind === 202 /* ContinueStatement */ - && !isIterationStatement(current.statement, /*lookInLabeledStatement*/ true); - if (isMisplacedContinueLabel) { - return grammarErrorOnNode(node, ts.Diagnostics.A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement); - } - return false; - } - break; - case 206 /* SwitchStatement */: - if (node.kind === 203 /* BreakStatement */ && !node.label) { - // unlabeled break within switch statement - ok - return false; - } - break; - default: - if (isIterationStatement(current, /*lookInLabeledStatement*/ false) && !node.label) { - // unlabeled break or continue within iteration statement - ok - return false; - } - break; - } - current = current.parent; - } - if (node.label) { - var message = node.kind === 203 /* BreakStatement */ - ? ts.Diagnostics.A_break_statement_can_only_jump_to_a_label_of_an_enclosing_statement - : ts.Diagnostics.A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement; - return grammarErrorOnNode(node, message); - } - else { - var message = node.kind === 203 /* BreakStatement */ - ? ts.Diagnostics.A_break_statement_can_only_be_used_within_an_enclosing_iteration_or_switch_statement - : ts.Diagnostics.A_continue_statement_can_only_be_used_within_an_enclosing_iteration_statement; - return grammarErrorOnNode(node, message); - } - } - function checkGrammarBindingElement(node) { - if (node.dotDotDotToken) { - var elements = node.parent.elements; - 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 === 162 /* ArrayBindingPattern */ || node.name.kind === 161 /* ObjectBindingPattern */) { - return grammarErrorOnNode(node.name, ts.Diagnostics.A_rest_element_cannot_contain_a_binding_pattern); - } - if (node.initializer) { - // Error on equals token which immediate precedes the initializer - return grammarErrorAtPos(ts.getSourceFileOfNode(node), node.initializer.pos - 1, 1, ts.Diagnostics.A_rest_element_cannot_have_an_initializer); - } - } - } - function checkGrammarVariableDeclaration(node) { - if (node.parent.parent.kind !== 200 /* ForInStatement */ && node.parent.parent.kind !== 201 /* ForOfStatement */) { - if (ts.isInAmbientContext(node)) { - if (node.initializer) { - // Error on equals token which immediate precedes the initializer - var equalsTokenLength = "=".length; - return grammarErrorAtPos(ts.getSourceFileOfNode(node), node.initializer.pos - equalsTokenLength, equalsTokenLength, ts.Diagnostics.Initializers_are_not_allowed_in_ambient_contexts); - } - } - else if (!node.initializer) { - if (ts.isBindingPattern(node.name) && !ts.isBindingPattern(node.parent)) { - return grammarErrorOnNode(node, ts.Diagnostics.A_destructuring_declaration_must_have_an_initializer); - } - if (ts.isConst(node)) { - return grammarErrorOnNode(node, ts.Diagnostics.const_declarations_must_be_initialized); - } - } - } - var checkLetConstNames = languageVersion >= 2 /* ES6 */ && (ts.isLet(node) || ts.isConst(node)); - // 1. LexicalDeclaration : LetOrConst BindingList ; - // It is a Syntax Error if the BoundNames of BindingList contains "let". - // 2. ForDeclaration: ForDeclaration : LetOrConst ForBinding - // It is a Syntax Error if the BoundNames of ForDeclaration contains "let". - // It is a SyntaxError if a VariableDeclaration or VariableDeclarationNoIn occurs within strict code - // and its Identifier is eval or arguments - return checkLetConstNames && checkGrammarNameInLetOrConstDeclarations(node.name); - } - function checkGrammarNameInLetOrConstDeclarations(name) { - if (name.kind === 69 /* Identifier */) { - if (name.text === "let") { - return grammarErrorOnNode(name, ts.Diagnostics.let_is_not_allowed_to_be_used_as_a_name_in_let_or_const_declarations); - } - } - else { - var elements = name.elements; - for (var _i = 0; _i < elements.length; _i++) { - var element = elements[_i]; - if (element.kind !== 187 /* OmittedExpression */) { - checkGrammarNameInLetOrConstDeclarations(element.name); - } - } - } - } - function checkGrammarVariableDeclarationList(declarationList) { - var declarations = declarationList.declarations; - if (checkGrammarForDisallowedTrailingComma(declarationList.declarations)) { - return true; - } - if (!declarationList.declarations.length) { - return grammarErrorAtPos(ts.getSourceFileOfNode(declarationList), declarations.pos, declarations.end - declarations.pos, ts.Diagnostics.Variable_declaration_list_cannot_be_empty); - } - } - function allowLetAndConstDeclarations(parent) { - switch (parent.kind) { - case 196 /* IfStatement */: - case 197 /* DoStatement */: - case 198 /* WhileStatement */: - case 205 /* WithStatement */: - case 199 /* ForStatement */: - case 200 /* ForInStatement */: - case 201 /* ForOfStatement */: - return false; - case 207 /* LabeledStatement */: - return allowLetAndConstDeclarations(parent.parent); - } - return true; - } - function checkGrammarForDisallowedLetOrConstStatement(node) { - if (!allowLetAndConstDeclarations(node.parent)) { - if (ts.isLet(node.declarationList)) { - return grammarErrorOnNode(node, ts.Diagnostics.let_declarations_can_only_be_declared_inside_a_block); - } - else if (ts.isConst(node.declarationList)) { - return grammarErrorOnNode(node, ts.Diagnostics.const_declarations_can_only_be_declared_inside_a_block); - } - } - } - function isIntegerLiteral(expression) { - if (expression.kind === 179 /* PrefixUnaryExpression */) { - var unaryExpression = expression; - if (unaryExpression.operator === 35 /* PlusToken */ || unaryExpression.operator === 36 /* MinusToken */) { - expression = unaryExpression.operand; - } - } - if (expression.kind === 8 /* NumericLiteral */) { - // Allows for scientific notation since literalExpression.text was formed by - // coercing a number to a string. Sometimes this coercion can yield a string - // in scientific notation. - // We also don't need special logic for hex because a hex integer is converted - // to decimal when it is coerced. - return /^[0-9]+([eE]\+?[0-9]+)?$/.test(expression.text); - } - return false; - } - function hasParseDiagnostics(sourceFile) { - return sourceFile.parseDiagnostics.length > 0; - } - function grammarErrorOnFirstToken(node, message, arg0, arg1, arg2) { - var sourceFile = ts.getSourceFileOfNode(node); - if (!hasParseDiagnostics(sourceFile)) { - var span = ts.getSpanOfTokenAtPosition(sourceFile, node.pos); - diagnostics.add(ts.createFileDiagnostic(sourceFile, span.start, span.length, message, arg0, arg1, arg2)); - return true; - } - } - function grammarErrorAtPos(sourceFile, start, length, message, arg0, arg1, arg2) { - if (!hasParseDiagnostics(sourceFile)) { - diagnostics.add(ts.createFileDiagnostic(sourceFile, start, length, message, arg0, arg1, arg2)); - return true; - } - } - function grammarErrorOnNode(node, message, arg0, arg1, arg2) { - var sourceFile = ts.getSourceFileOfNode(node); - if (!hasParseDiagnostics(sourceFile)) { - diagnostics.add(ts.createDiagnosticForNode(node, message, arg0, arg1, arg2)); - return true; - } - } - function isEvalOrArgumentsIdentifier(node) { - return node.kind === 69 /* Identifier */ && - (node.text === "eval" || node.text === "arguments"); - } - function checkGrammarConstructorTypeParameters(node) { - if (node.typeParameters) { - return grammarErrorAtPos(ts.getSourceFileOfNode(node), node.typeParameters.pos, node.typeParameters.end - node.typeParameters.pos, ts.Diagnostics.Type_parameters_cannot_appear_on_a_constructor_declaration); - } - } - function checkGrammarConstructorTypeAnnotation(node) { - if (node.type) { - return grammarErrorOnNode(node.type, ts.Diagnostics.Type_annotation_cannot_appear_on_a_constructor_declaration); - } - } - function checkGrammarProperty(node) { - if (ts.isClassLike(node.parent)) { - if (checkGrammarForInvalidQuestionMark(node, node.questionToken, ts.Diagnostics.A_class_member_cannot_be_declared_optional) || - checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_class_property_declaration_must_directly_refer_to_a_built_in_symbol)) { - return true; - } - } - else if (node.parent.kind === 215 /* InterfaceDeclaration */) { - if (checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_an_interface_must_directly_refer_to_a_built_in_symbol)) { - return true; - } - } - else if (node.parent.kind === 155 /* TypeLiteral */) { - if (checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_type_literal_must_directly_refer_to_a_built_in_symbol)) { - return true; - } - } - if (ts.isInAmbientContext(node) && node.initializer) { - return grammarErrorOnFirstToken(node.initializer, ts.Diagnostics.Initializers_are_not_allowed_in_ambient_contexts); - } - } - function checkGrammarTopLevelElementForRequiredDeclareModifier(node) { - // A declare modifier is required for any top level .d.ts declaration except export=, export default, - // interfaces and imports categories: - // - // DeclarationElement: - // ExportAssignment - // export_opt InterfaceDeclaration - // export_opt ImportDeclaration - // export_opt ExternalImportDeclaration - // export_opt AmbientDeclaration - // - if (node.kind === 215 /* InterfaceDeclaration */ || - node.kind === 222 /* ImportDeclaration */ || - node.kind === 221 /* ImportEqualsDeclaration */ || - node.kind === 228 /* ExportDeclaration */ || - node.kind === 227 /* ExportAssignment */ || - (node.flags & 2 /* Ambient */) || - (node.flags & (1 /* Export */ | 1024 /* Default */))) { - return false; - } - return grammarErrorOnFirstToken(node, ts.Diagnostics.A_declare_modifier_is_required_for_a_top_level_declaration_in_a_d_ts_file); - } - function checkGrammarTopLevelElementsForRequiredDeclareModifier(file) { - for (var _i = 0, _a = file.statements; _i < _a.length; _i++) { - var decl = _a[_i]; - if (ts.isDeclaration(decl) || decl.kind === 193 /* VariableStatement */) { - if (checkGrammarTopLevelElementForRequiredDeclareModifier(decl)) { - return true; - } - } - } - } - function checkGrammarSourceFile(node) { - return ts.isInAmbientContext(node) && checkGrammarTopLevelElementsForRequiredDeclareModifier(node); - } - function checkGrammarStatementInAmbientContext(node) { - if (ts.isInAmbientContext(node)) { - // An accessors is already reported about the ambient context - if (isAccessor(node.parent.kind)) { - return getNodeLinks(node).hasReportedStatementInAmbientContext = true; - } - // Find containing block which is either Block, ModuleBlock, SourceFile - var links = getNodeLinks(node); - if (!links.hasReportedStatementInAmbientContext && ts.isFunctionLike(node.parent)) { - return getNodeLinks(node).hasReportedStatementInAmbientContext = grammarErrorOnFirstToken(node, ts.Diagnostics.An_implementation_cannot_be_declared_in_ambient_contexts); - } - // We are either parented by another statement, or some sort of block. - // If we're in a block, we only want to really report an error once - // to prevent noisyness. So use a bit on the block to indicate if - // this has already been reported, and don't report if it has. - // - if (node.parent.kind === 192 /* Block */ || node.parent.kind === 219 /* ModuleBlock */ || node.parent.kind === 248 /* SourceFile */) { - var links_1 = getNodeLinks(node.parent); - // Check if the containing block ever report this error - if (!links_1.hasReportedStatementInAmbientContext) { - return links_1.hasReportedStatementInAmbientContext = grammarErrorOnFirstToken(node, ts.Diagnostics.Statements_are_not_allowed_in_ambient_contexts); - } - } - else { - } - } - } - function checkGrammarNumericLiteral(node) { - // Grammar checking - if (node.flags & 65536 /* OctalLiteral */ && languageVersion >= 1 /* ES5 */) { - return grammarErrorOnNode(node, ts.Diagnostics.Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher); - } - } - function grammarErrorAfterFirstToken(node, message, arg0, arg1, arg2) { - var sourceFile = ts.getSourceFileOfNode(node); - if (!hasParseDiagnostics(sourceFile)) { - var span = ts.getSpanOfTokenAtPosition(sourceFile, node.pos); - diagnostics.add(ts.createFileDiagnostic(sourceFile, ts.textSpanEnd(span), /*length*/ 0, message, arg0, arg1, arg2)); - return true; - } - } - } - ts.createTypeChecker = createTypeChecker; -})(ts || (ts = {})); -/// -/* @internal */ -var ts; -(function (ts) { - function getDeclarationDiagnostics(host, resolver, targetSourceFile) { - var diagnostics = []; - var jsFilePath = ts.getOwnEmitOutputFilePath(targetSourceFile, host, ".js"); - emitDeclarations(host, resolver, diagnostics, jsFilePath, targetSourceFile); - return diagnostics; - } - ts.getDeclarationDiagnostics = getDeclarationDiagnostics; - function emitDeclarations(host, resolver, diagnostics, jsFilePath, root) { - var newLine = host.getNewLine(); - var compilerOptions = host.getCompilerOptions(); - var write; - var writeLine; - var increaseIndent; - var decreaseIndent; - var writeTextOfNode; - var writer = createAndSetNewTextWriterWithSymbolWriter(); - var enclosingDeclaration; - var currentSourceFile; - var reportedDeclarationError = false; - var errorNameNode; - var emitJsDocComments = compilerOptions.removeComments ? function (declaration) { } : writeJsDocComments; - var emit = compilerOptions.stripInternal ? stripInternal : emitNode; - var moduleElementDeclarationEmitInfo = []; - var asynchronousSubModuleDeclarationEmitInfo; - // Contains the reference paths that needs to go in the declaration file. - // Collecting this separately because reference paths need to be first thing in the declaration file - // and we could be collecting these paths from multiple files into single one with --out option - var referencePathsOutput = ""; - if (root) { - // Emitting just a single file, so emit references in this file only - if (!compilerOptions.noResolve) { - var addedGlobalFileReference = false; - ts.forEach(root.referencedFiles, function (fileReference) { - var referencedFile = ts.tryResolveScriptReference(host, root, fileReference); - // All the references that are not going to be part of same file - if (referencedFile && ((referencedFile.flags & 8192 /* DeclarationFile */) || - ts.shouldEmitToOwnFile(referencedFile, compilerOptions) || - !addedGlobalFileReference)) { - writeReferencePath(referencedFile); - if (!ts.isExternalModuleOrDeclarationFile(referencedFile)) { - addedGlobalFileReference = true; - } - } - }); - } - emitSourceFile(root); - // create asynchronous output for the importDeclarations - if (moduleElementDeclarationEmitInfo.length) { - var oldWriter = writer; - ts.forEach(moduleElementDeclarationEmitInfo, function (aliasEmitInfo) { - if (aliasEmitInfo.isVisible) { - ts.Debug.assert(aliasEmitInfo.node.kind === 222 /* ImportDeclaration */); - createAndSetNewTextWriterWithSymbolWriter(); - ts.Debug.assert(aliasEmitInfo.indent === 0); - writeImportDeclaration(aliasEmitInfo.node); - aliasEmitInfo.asynchronousOutput = writer.getText(); - } - }); - setWriter(oldWriter); - } - } - else { - // Emit references corresponding to this file - var emittedReferencedFiles = []; - ts.forEach(host.getSourceFiles(), function (sourceFile) { - if (!ts.isExternalModuleOrDeclarationFile(sourceFile)) { - // Check what references need to be added - if (!compilerOptions.noResolve) { - ts.forEach(sourceFile.referencedFiles, function (fileReference) { - var referencedFile = ts.tryResolveScriptReference(host, sourceFile, fileReference); - // If the reference file is a declaration file or an external module, emit that reference - if (referencedFile && (ts.isExternalModuleOrDeclarationFile(referencedFile) && - !ts.contains(emittedReferencedFiles, referencedFile))) { - writeReferencePath(referencedFile); - emittedReferencedFiles.push(referencedFile); - } - }); - } - emitSourceFile(sourceFile); - } - }); - } - return { - reportedDeclarationError: reportedDeclarationError, - moduleElementDeclarationEmitInfo: moduleElementDeclarationEmitInfo, - synchronousDeclarationOutput: writer.getText(), - referencePathsOutput: referencePathsOutput - }; - function hasInternalAnnotation(range) { - var text = currentSourceFile.text; - var comment = text.substring(range.pos, range.end); - return comment.indexOf("@internal") >= 0; - } - function stripInternal(node) { - if (node) { - var leadingCommentRanges = ts.getLeadingCommentRanges(currentSourceFile.text, node.pos); - if (ts.forEach(leadingCommentRanges, hasInternalAnnotation)) { - return; - } - emitNode(node); - } - } - function createAndSetNewTextWriterWithSymbolWriter() { - var writer = ts.createTextWriter(newLine); - writer.trackSymbol = trackSymbol; - writer.reportInaccessibleThisError = reportInaccessibleThisError; - writer.writeKeyword = writer.write; - writer.writeOperator = writer.write; - writer.writePunctuation = writer.write; - writer.writeSpace = writer.write; - writer.writeStringLiteral = writer.writeLiteral; - writer.writeParameter = writer.write; - writer.writeSymbol = writer.write; - setWriter(writer); - return writer; - } - function setWriter(newWriter) { - writer = newWriter; - write = newWriter.write; - writeTextOfNode = newWriter.writeTextOfNode; - writeLine = newWriter.writeLine; - increaseIndent = newWriter.increaseIndent; - decreaseIndent = newWriter.decreaseIndent; - } - function writeAsynchronousModuleElements(nodes) { - var oldWriter = writer; - ts.forEach(nodes, function (declaration) { - var nodeToCheck; - if (declaration.kind === 211 /* VariableDeclaration */) { - nodeToCheck = declaration.parent.parent; - } - else if (declaration.kind === 225 /* NamedImports */ || declaration.kind === 226 /* ImportSpecifier */ || declaration.kind === 223 /* ImportClause */) { - ts.Debug.fail("We should be getting ImportDeclaration instead to write"); - } - else { - nodeToCheck = declaration; - } - var moduleElementEmitInfo = ts.forEach(moduleElementDeclarationEmitInfo, function (declEmitInfo) { return declEmitInfo.node === nodeToCheck ? declEmitInfo : undefined; }); - if (!moduleElementEmitInfo && asynchronousSubModuleDeclarationEmitInfo) { - moduleElementEmitInfo = ts.forEach(asynchronousSubModuleDeclarationEmitInfo, function (declEmitInfo) { return declEmitInfo.node === nodeToCheck ? declEmitInfo : undefined; }); - } - // If the alias was marked as not visible when we saw its declaration, we would have saved the aliasEmitInfo, but if we haven't yet visited the alias declaration - // then we don't need to write it at this point. We will write it when we actually see its declaration - // Eg. - // export function bar(a: foo.Foo) { } - // import foo = require("foo"); - // 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 === 222 /* ImportDeclaration */) { - // we have to create asynchronous output only after we have collected complete information - // because it is possible to enable multiple bindings as asynchronously visible - moduleElementEmitInfo.isVisible = true; - } - else { - createAndSetNewTextWriterWithSymbolWriter(); - for (var declarationIndent = moduleElementEmitInfo.indent; declarationIndent; declarationIndent--) { - increaseIndent(); - } - if (nodeToCheck.kind === 218 /* ModuleDeclaration */) { - ts.Debug.assert(asynchronousSubModuleDeclarationEmitInfo === undefined); - asynchronousSubModuleDeclarationEmitInfo = []; - } - writeModuleElement(nodeToCheck); - if (nodeToCheck.kind === 218 /* ModuleDeclaration */) { - moduleElementEmitInfo.subModuleElementDeclarationEmitInfo = asynchronousSubModuleDeclarationEmitInfo; - asynchronousSubModuleDeclarationEmitInfo = undefined; - } - moduleElementEmitInfo.asynchronousOutput = writer.getText(); - } - } - }); - setWriter(oldWriter); - } - function handleSymbolAccessibilityError(symbolAccesibilityResult) { - if (symbolAccesibilityResult.accessibility === 0 /* Accessible */) { - // write the aliases - if (symbolAccesibilityResult && symbolAccesibilityResult.aliasesToMakeVisible) { - writeAsynchronousModuleElements(symbolAccesibilityResult.aliasesToMakeVisible); - } - } - else { - // Report error - reportedDeclarationError = true; - var errorInfo = writer.getSymbolAccessibilityDiagnostic(symbolAccesibilityResult); - if (errorInfo) { - if (errorInfo.typeName) { - diagnostics.push(ts.createDiagnosticForNode(symbolAccesibilityResult.errorNode || errorInfo.errorNode, errorInfo.diagnosticMessage, ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, errorInfo.typeName), symbolAccesibilityResult.errorSymbolName, symbolAccesibilityResult.errorModuleName)); - } - else { - diagnostics.push(ts.createDiagnosticForNode(symbolAccesibilityResult.errorNode || errorInfo.errorNode, errorInfo.diagnosticMessage, symbolAccesibilityResult.errorSymbolName, symbolAccesibilityResult.errorModuleName)); - } - } - } - } - function trackSymbol(symbol, enclosingDeclaration, meaning) { - handleSymbolAccessibilityError(resolver.isSymbolAccessible(symbol, enclosingDeclaration, meaning)); - } - function reportInaccessibleThisError() { - if (errorNameNode) { - diagnostics.push(ts.createDiagnosticForNode(errorNameNode, ts.Diagnostics.The_inferred_type_of_0_references_an_inaccessible_this_type_A_type_annotation_is_necessary, ts.declarationNameToString(errorNameNode))); - } - } - function writeTypeOfDeclaration(declaration, type, getSymbolAccessibilityDiagnostic) { - writer.getSymbolAccessibilityDiagnostic = getSymbolAccessibilityDiagnostic; - write(": "); - if (type) { - // Write the type - emitType(type); - } - else { - errorNameNode = declaration.name; - resolver.writeTypeOfDeclaration(declaration, enclosingDeclaration, 2 /* UseTypeOfFunction */, writer); - errorNameNode = undefined; - } - } - function writeReturnTypeAtSignature(signature, getSymbolAccessibilityDiagnostic) { - writer.getSymbolAccessibilityDiagnostic = getSymbolAccessibilityDiagnostic; - write(": "); - if (signature.type) { - // Write the type - emitType(signature.type); - } - else { - errorNameNode = signature.name; - resolver.writeReturnTypeOfSignatureDeclaration(signature, enclosingDeclaration, 2 /* UseTypeOfFunction */, writer); - errorNameNode = undefined; - } - } - function emitLines(nodes) { - for (var _i = 0; _i < nodes.length; _i++) { - var node = nodes[_i]; - emit(node); - } - } - function emitSeparatedList(nodes, separator, eachNodeEmitFn, canEmitFn) { - var currentWriterPos = writer.getTextPos(); - for (var _i = 0; _i < nodes.length; _i++) { - var node = nodes[_i]; - if (!canEmitFn || canEmitFn(node)) { - if (currentWriterPos !== writer.getTextPos()) { - write(separator); - } - currentWriterPos = writer.getTextPos(); - eachNodeEmitFn(node); - } - } - } - function emitCommaList(nodes, eachNodeEmitFn, canEmitFn) { - emitSeparatedList(nodes, ", ", eachNodeEmitFn, canEmitFn); - } - function writeJsDocComments(declaration) { - if (declaration) { - var jsDocComments = ts.getJsDocComments(declaration, currentSourceFile); - ts.emitNewLineBeforeLeadingComments(currentSourceFile, writer, declaration, jsDocComments); - // jsDoc comments are emitted at /*leading comment1 */space/*leading comment*/space - ts.emitComments(currentSourceFile, writer, jsDocComments, /*trailingSeparator*/ true, newLine, ts.writeCommentRange); - } - } - function emitTypeWithNewGetSymbolAccessibilityDiagnostic(type, getSymbolAccessibilityDiagnostic) { - writer.getSymbolAccessibilityDiagnostic = getSymbolAccessibilityDiagnostic; - emitType(type); - } - function emitType(type) { - switch (type.kind) { - case 117 /* AnyKeyword */: - case 130 /* StringKeyword */: - case 128 /* NumberKeyword */: - case 120 /* BooleanKeyword */: - case 131 /* SymbolKeyword */: - case 103 /* VoidKeyword */: - case 97 /* ThisKeyword */: - case 9 /* StringLiteral */: - return writeTextOfNode(currentSourceFile, type); - case 188 /* ExpressionWithTypeArguments */: - return emitExpressionWithTypeArguments(type); - case 151 /* TypeReference */: - return emitTypeReference(type); - case 154 /* TypeQuery */: - return emitTypeQuery(type); - case 156 /* ArrayType */: - return emitArrayType(type); - case 157 /* TupleType */: - return emitTupleType(type); - case 158 /* UnionType */: - return emitUnionType(type); - case 159 /* IntersectionType */: - return emitIntersectionType(type); - case 160 /* ParenthesizedType */: - return emitParenType(type); - case 152 /* FunctionType */: - case 153 /* ConstructorType */: - return emitSignatureDeclarationWithJsDocComments(type); - case 155 /* TypeLiteral */: - return emitTypeLiteral(type); - case 69 /* Identifier */: - return emitEntityName(type); - case 135 /* QualifiedName */: - return emitEntityName(type); - case 150 /* TypePredicate */: - return emitTypePredicate(type); - } - function writeEntityName(entityName) { - if (entityName.kind === 69 /* Identifier */) { - writeTextOfNode(currentSourceFile, entityName); - } - else { - var left = entityName.kind === 135 /* QualifiedName */ ? entityName.left : entityName.expression; - var right = entityName.kind === 135 /* QualifiedName */ ? entityName.right : entityName.name; - writeEntityName(left); - write("."); - writeTextOfNode(currentSourceFile, right); - } - } - function emitEntityName(entityName) { - var visibilityResult = resolver.isEntityNameVisible(entityName, - // Aliases can be written asynchronously so use correct enclosing declaration - entityName.parent.kind === 221 /* ImportEqualsDeclaration */ ? entityName.parent : enclosingDeclaration); - handleSymbolAccessibilityError(visibilityResult); - writeEntityName(entityName); - } - function emitExpressionWithTypeArguments(node) { - if (ts.isSupportedExpressionWithTypeArguments(node)) { - ts.Debug.assert(node.expression.kind === 69 /* Identifier */ || node.expression.kind === 166 /* PropertyAccessExpression */); - emitEntityName(node.expression); - if (node.typeArguments) { - write("<"); - emitCommaList(node.typeArguments, emitType); - write(">"); - } - } - } - function emitTypeReference(type) { - emitEntityName(type.typeName); - if (type.typeArguments) { - write("<"); - emitCommaList(type.typeArguments, emitType); - write(">"); - } - } - function emitTypePredicate(type) { - writeTextOfNode(currentSourceFile, type.parameterName); - write(" is "); - emitType(type.type); - } - function emitTypeQuery(type) { - write("typeof "); - emitEntityName(type.exprName); - } - function emitArrayType(type) { - emitType(type.elementType); - write("[]"); - } - function emitTupleType(type) { - write("["); - emitCommaList(type.elementTypes, emitType); - write("]"); - } - function emitUnionType(type) { - emitSeparatedList(type.types, " | ", emitType); - } - function emitIntersectionType(type) { - emitSeparatedList(type.types, " & ", emitType); - } - function emitParenType(type) { - write("("); - emitType(type.type); - write(")"); - } - function emitTypeLiteral(type) { - write("{"); - if (type.members.length) { - writeLine(); - increaseIndent(); - // write members - emitLines(type.members); - decreaseIndent(); - } - write("}"); - } - } - function emitSourceFile(node) { - currentSourceFile = node; - enclosingDeclaration = node; - emitLines(node.statements); - } - // Return a temp variable name to be used in `export default` statements. - // The temp name will be of the form _default_counter. - // Note that export default is only allowed at most once in a module, so we - // do not need to keep track of created temp names. - function getExportDefaultTempVariableName() { - var baseName = "_default"; - if (!ts.hasProperty(currentSourceFile.identifiers, baseName)) { - return baseName; - } - var count = 0; - while (true) { - var name_18 = baseName + "_" + (++count); - if (!ts.hasProperty(currentSourceFile.identifiers, name_18)) { - return name_18; - } - } - } - function emitExportAssignment(node) { - if (node.expression.kind === 69 /* Identifier */) { - write(node.isExportEquals ? "export = " : "export default "); - writeTextOfNode(currentSourceFile, node.expression); - } - else { - // Expression - var tempVarName = getExportDefaultTempVariableName(); - write("declare var "); - write(tempVarName); - write(": "); - writer.getSymbolAccessibilityDiagnostic = getDefaultExportAccessibilityDiagnostic; - resolver.writeTypeOfExpression(node.expression, enclosingDeclaration, 2 /* UseTypeOfFunction */, writer); - write(";"); - writeLine(); - write(node.isExportEquals ? "export = " : "export default "); - write(tempVarName); - } - write(";"); - writeLine(); - // Make all the declarations visible for the export name - if (node.expression.kind === 69 /* Identifier */) { - var nodes = resolver.collectLinkedAliases(node.expression); - // write each of these declarations asynchronously - writeAsynchronousModuleElements(nodes); - } - function getDefaultExportAccessibilityDiagnostic(diagnostic) { - return { - diagnosticMessage: ts.Diagnostics.Default_export_of_the_module_has_or_is_using_private_name_0, - errorNode: node - }; - } - } - function isModuleElementVisible(node) { - return resolver.isDeclarationVisible(node); - } - function emitModuleElement(node, isModuleElementVisible) { - if (isModuleElementVisible) { - writeModuleElement(node); - } - else if (node.kind === 221 /* ImportEqualsDeclaration */ || - (node.parent.kind === 248 /* SourceFile */ && ts.isExternalModule(currentSourceFile))) { - var isVisible; - if (asynchronousSubModuleDeclarationEmitInfo && node.parent.kind !== 248 /* SourceFile */) { - // Import declaration of another module that is visited async so lets put it in right spot - asynchronousSubModuleDeclarationEmitInfo.push({ - node: node, - outputPos: writer.getTextPos(), - indent: writer.getIndent(), - isVisible: isVisible - }); - } - else { - if (node.kind === 222 /* ImportDeclaration */) { - var importDeclaration = node; - if (importDeclaration.importClause) { - isVisible = (importDeclaration.importClause.name && resolver.isDeclarationVisible(importDeclaration.importClause)) || - isVisibleNamedBinding(importDeclaration.importClause.namedBindings); - } - } - moduleElementDeclarationEmitInfo.push({ - node: node, - outputPos: writer.getTextPos(), - indent: writer.getIndent(), - isVisible: isVisible - }); - } - } - } - function writeModuleElement(node) { - switch (node.kind) { - case 213 /* FunctionDeclaration */: - return writeFunctionDeclaration(node); - case 193 /* VariableStatement */: - return writeVariableStatement(node); - case 215 /* InterfaceDeclaration */: - return writeInterfaceDeclaration(node); - case 214 /* ClassDeclaration */: - return writeClassDeclaration(node); - case 216 /* TypeAliasDeclaration */: - return writeTypeAliasDeclaration(node); - case 217 /* EnumDeclaration */: - return writeEnumDeclaration(node); - case 218 /* ModuleDeclaration */: - return writeModuleDeclaration(node); - case 221 /* ImportEqualsDeclaration */: - return writeImportEqualsDeclaration(node); - case 222 /* ImportDeclaration */: - return writeImportDeclaration(node); - default: - ts.Debug.fail("Unknown symbol kind"); - } - } - function emitModuleElementDeclarationFlags(node) { - // If the node is parented in the current source file we need to emit export declare or just export - if (node.parent === currentSourceFile) { - // If the node is exported - if (node.flags & 1 /* Export */) { - write("export "); - } - if (node.flags & 1024 /* Default */) { - write("default "); - } - else if (node.kind !== 215 /* InterfaceDeclaration */) { - write("declare "); - } - } - } - function emitClassMemberDeclarationFlags(node) { - if (node.flags & 32 /* Private */) { - write("private "); - } - else if (node.flags & 64 /* Protected */) { - write("protected "); - } - if (node.flags & 128 /* Static */) { - write("static "); - } - if (node.flags & 256 /* Abstract */) { - write("abstract "); - } - } - function writeImportEqualsDeclaration(node) { - // note usage of writer. methods instead of aliases created, just to make sure we are using - // correct writer especially to handle asynchronous alias writing - emitJsDocComments(node); - if (node.flags & 1 /* Export */) { - write("export "); - } - write("import "); - writeTextOfNode(currentSourceFile, node.name); - write(" = "); - if (ts.isInternalModuleImportEqualsDeclaration(node)) { - emitTypeWithNewGetSymbolAccessibilityDiagnostic(node.moduleReference, getImportEntityNameVisibilityError); - write(";"); - } - else { - write("require("); - writeTextOfNode(currentSourceFile, ts.getExternalModuleImportEqualsDeclarationExpression(node)); - write(");"); - } - writer.writeLine(); - function getImportEntityNameVisibilityError(symbolAccesibilityResult) { - return { - diagnosticMessage: ts.Diagnostics.Import_declaration_0_is_using_private_name_1, - errorNode: node, - typeName: node.name - }; - } - } - function isVisibleNamedBinding(namedBindings) { - if (namedBindings) { - if (namedBindings.kind === 224 /* NamespaceImport */) { - return resolver.isDeclarationVisible(namedBindings); - } - else { - return ts.forEach(namedBindings.elements, function (namedImport) { return resolver.isDeclarationVisible(namedImport); }); - } - } - } - function writeImportDeclaration(node) { - if (!node.importClause && !(node.flags & 1 /* Export */)) { - // do not write non-exported import declarations that don't have import clauses - return; - } - emitJsDocComments(node); - if (node.flags & 1 /* Export */) { - write("export "); - } - write("import "); - if (node.importClause) { - var currentWriterPos = writer.getTextPos(); - if (node.importClause.name && resolver.isDeclarationVisible(node.importClause)) { - writeTextOfNode(currentSourceFile, node.importClause.name); - } - if (node.importClause.namedBindings && isVisibleNamedBinding(node.importClause.namedBindings)) { - if (currentWriterPos !== writer.getTextPos()) { - // If the default binding was emitted, write the separated - write(", "); - } - if (node.importClause.namedBindings.kind === 224 /* NamespaceImport */) { - write("* as "); - writeTextOfNode(currentSourceFile, node.importClause.namedBindings.name); - } - else { - write("{ "); - emitCommaList(node.importClause.namedBindings.elements, emitImportOrExportSpecifier, resolver.isDeclarationVisible); - write(" }"); - } - } - write(" from "); - } - writeTextOfNode(currentSourceFile, node.moduleSpecifier); - write(";"); - writer.writeLine(); - } - function emitImportOrExportSpecifier(node) { - if (node.propertyName) { - writeTextOfNode(currentSourceFile, node.propertyName); - write(" as "); - } - writeTextOfNode(currentSourceFile, node.name); - } - function emitExportSpecifier(node) { - emitImportOrExportSpecifier(node); - // Make all the declarations visible for the export name - var nodes = resolver.collectLinkedAliases(node.propertyName || node.name); - // write each of these declarations asynchronously - writeAsynchronousModuleElements(nodes); - } - function emitExportDeclaration(node) { - emitJsDocComments(node); - write("export "); - if (node.exportClause) { - write("{ "); - emitCommaList(node.exportClause.elements, emitExportSpecifier); - write(" }"); - } - else { - write("*"); - } - if (node.moduleSpecifier) { - write(" from "); - writeTextOfNode(currentSourceFile, node.moduleSpecifier); - } - write(";"); - writer.writeLine(); - } - function writeModuleDeclaration(node) { - emitJsDocComments(node); - emitModuleElementDeclarationFlags(node); - if (node.flags & 131072 /* Namespace */) { - write("namespace "); - } - else { - write("module "); - } - writeTextOfNode(currentSourceFile, node.name); - while (node.body.kind !== 219 /* ModuleBlock */) { - node = node.body; - write("."); - writeTextOfNode(currentSourceFile, node.name); - } - var prevEnclosingDeclaration = enclosingDeclaration; - enclosingDeclaration = node; - write(" {"); - writeLine(); - increaseIndent(); - emitLines(node.body.statements); - decreaseIndent(); - write("}"); - writeLine(); - enclosingDeclaration = prevEnclosingDeclaration; - } - function writeTypeAliasDeclaration(node) { - var prevEnclosingDeclaration = enclosingDeclaration; - enclosingDeclaration = node; - emitJsDocComments(node); - emitModuleElementDeclarationFlags(node); - write("type "); - writeTextOfNode(currentSourceFile, node.name); - emitTypeParameters(node.typeParameters); - write(" = "); - emitTypeWithNewGetSymbolAccessibilityDiagnostic(node.type, getTypeAliasDeclarationVisibilityError); - write(";"); - writeLine(); - enclosingDeclaration = prevEnclosingDeclaration; - function getTypeAliasDeclarationVisibilityError(symbolAccesibilityResult) { - return { - diagnosticMessage: ts.Diagnostics.Exported_type_alias_0_has_or_is_using_private_name_1, - errorNode: node.type, - typeName: node.name - }; - } - } - function writeEnumDeclaration(node) { - emitJsDocComments(node); - emitModuleElementDeclarationFlags(node); - if (ts.isConst(node)) { - write("const "); - } - write("enum "); - writeTextOfNode(currentSourceFile, node.name); - write(" {"); - writeLine(); - increaseIndent(); - emitLines(node.members); - decreaseIndent(); - write("}"); - writeLine(); - } - function emitEnumMemberDeclaration(node) { - emitJsDocComments(node); - writeTextOfNode(currentSourceFile, node.name); - var enumMemberValue = resolver.getConstantValue(node); - if (enumMemberValue !== undefined) { - write(" = "); - write(enumMemberValue.toString()); - } - write(","); - writeLine(); - } - function isPrivateMethodTypeParameter(node) { - return node.parent.kind === 143 /* MethodDeclaration */ && (node.parent.flags & 32 /* Private */); - } - function emitTypeParameters(typeParameters) { - function emitTypeParameter(node) { - increaseIndent(); - emitJsDocComments(node); - decreaseIndent(); - writeTextOfNode(currentSourceFile, node.name); - // 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 === 152 /* FunctionType */ || - node.parent.kind === 153 /* ConstructorType */ || - (node.parent.parent && node.parent.parent.kind === 155 /* TypeLiteral */)) { - ts.Debug.assert(node.parent.kind === 143 /* MethodDeclaration */ || - node.parent.kind === 142 /* MethodSignature */ || - node.parent.kind === 152 /* FunctionType */ || - node.parent.kind === 153 /* ConstructorType */ || - node.parent.kind === 147 /* CallSignature */ || - node.parent.kind === 148 /* ConstructSignature */); - emitType(node.constraint); - } - else { - emitTypeWithNewGetSymbolAccessibilityDiagnostic(node.constraint, getTypeParameterConstraintVisibilityError); - } - } - function getTypeParameterConstraintVisibilityError(symbolAccesibilityResult) { - // Type parameter constraints are named by user so we should always be able to name it - var diagnosticMessage; - switch (node.parent.kind) { - case 214 /* ClassDeclaration */: - diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_class_has_or_is_using_private_name_1; - break; - case 215 /* InterfaceDeclaration */: - diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1; - break; - case 148 /* ConstructSignature */: - diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; - break; - case 147 /* CallSignature */: - diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; - break; - case 143 /* MethodDeclaration */: - case 142 /* MethodSignature */: - if (node.parent.flags & 128 /* Static */) { - diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1; - } - else if (node.parent.parent.kind === 214 /* ClassDeclaration */) { - diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_public_method_from_exported_class_has_or_is_using_private_name_1; - } - else { - diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1; - } - break; - case 213 /* FunctionDeclaration */: - diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_function_has_or_is_using_private_name_1; - break; - default: - ts.Debug.fail("This is unknown parent for type parameter: " + node.parent.kind); - } - return { - diagnosticMessage: diagnosticMessage, - errorNode: node, - typeName: node.name - }; - } - } - if (typeParameters) { - write("<"); - emitCommaList(typeParameters, emitTypeParameter); - write(">"); - } - } - function emitHeritageClause(typeReferences, isImplementsList) { - if (typeReferences) { - write(isImplementsList ? " implements " : " extends "); - emitCommaList(typeReferences, emitTypeOfTypeReference); - } - function emitTypeOfTypeReference(node) { - if (ts.isSupportedExpressionWithTypeArguments(node)) { - emitTypeWithNewGetSymbolAccessibilityDiagnostic(node, getHeritageClauseVisibilityError); - } - else if (!isImplementsList && node.expression.kind === 93 /* NullKeyword */) { - write("null"); - } - function getHeritageClauseVisibilityError(symbolAccesibilityResult) { - var diagnosticMessage; - // Heritage clause is written by user so it can always be named - if (node.parent.parent.kind === 214 /* ClassDeclaration */) { - // Class or Interface implemented/extended is inaccessible - diagnosticMessage = isImplementsList ? - ts.Diagnostics.Implements_clause_of_exported_class_0_has_or_is_using_private_name_1 : - ts.Diagnostics.Extends_clause_of_exported_class_0_has_or_is_using_private_name_1; - } - else { - // interface is inaccessible - diagnosticMessage = ts.Diagnostics.Extends_clause_of_exported_interface_0_has_or_is_using_private_name_1; - } - return { - diagnosticMessage: diagnosticMessage, - errorNode: node, - typeName: node.parent.parent.name - }; - } - } - } - function writeClassDeclaration(node) { - function emitParameterProperties(constructorDeclaration) { - if (constructorDeclaration) { - ts.forEach(constructorDeclaration.parameters, function (param) { - if (param.flags & 112 /* AccessibilityModifier */) { - emitPropertyDeclaration(param); - } - }); - } - } - emitJsDocComments(node); - emitModuleElementDeclarationFlags(node); - if (node.flags & 256 /* Abstract */) { - write("abstract "); - } - write("class "); - writeTextOfNode(currentSourceFile, node.name); - var prevEnclosingDeclaration = enclosingDeclaration; - enclosingDeclaration = node; - emitTypeParameters(node.typeParameters); - var baseTypeNode = ts.getClassExtendsHeritageClauseElement(node); - if (baseTypeNode) { - emitHeritageClause([baseTypeNode], /*isImplementsList*/ false); - } - emitHeritageClause(ts.getClassImplementsHeritageClauseElements(node), /*isImplementsList*/ true); - write(" {"); - writeLine(); - increaseIndent(); - emitParameterProperties(ts.getFirstConstructorWithBody(node)); - emitLines(node.members); - decreaseIndent(); - write("}"); - writeLine(); - enclosingDeclaration = prevEnclosingDeclaration; - } - function writeInterfaceDeclaration(node) { - emitJsDocComments(node); - emitModuleElementDeclarationFlags(node); - write("interface "); - writeTextOfNode(currentSourceFile, node.name); - var prevEnclosingDeclaration = enclosingDeclaration; - enclosingDeclaration = node; - emitTypeParameters(node.typeParameters); - emitHeritageClause(ts.getInterfaceBaseTypeNodes(node), /*isImplementsList*/ false); - write(" {"); - writeLine(); - increaseIndent(); - emitLines(node.members); - decreaseIndent(); - write("}"); - writeLine(); - enclosingDeclaration = prevEnclosingDeclaration; - } - function emitPropertyDeclaration(node) { - if (ts.hasDynamicName(node)) { - return; - } - emitJsDocComments(node); - emitClassMemberDeclarationFlags(node); - emitVariableDeclaration(node); - write(";"); - writeLine(); - } - 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 !== 211 /* VariableDeclaration */ || resolver.isDeclarationVisible(node)) { - if (ts.isBindingPattern(node.name)) { - emitBindingPattern(node.name); - } - else { - // If this node is a computed name, it can only be a symbol, because we've already skipped - // it if it's not a well known symbol. In that case, the text of the name will be exactly - // what we want, namely the name expression enclosed in brackets. - writeTextOfNode(currentSourceFile, node.name); - // If optional property emit ? - if ((node.kind === 141 /* PropertyDeclaration */ || node.kind === 140 /* PropertySignature */) && ts.hasQuestionToken(node)) { - write("?"); - } - if ((node.kind === 141 /* PropertyDeclaration */ || node.kind === 140 /* PropertySignature */) && node.parent.kind === 155 /* TypeLiteral */) { - emitTypeOfVariableDeclarationFromTypeLiteral(node); - } - else if (!(node.flags & 32 /* Private */)) { - writeTypeOfDeclaration(node, node.type, getVariableDeclarationTypeVisibilityError); - } - } - } - function getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccesibilityResult) { - if (node.kind === 211 /* VariableDeclaration */) { - return symbolAccesibilityResult.errorModuleName ? - symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? - ts.Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : - ts.Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_private_module_2 : - ts.Diagnostics.Exported_variable_0_has_or_is_using_private_name_1; - } - else if (node.kind === 141 /* PropertyDeclaration */ || node.kind === 140 /* PropertySignature */) { - // TODO(jfreeman): Deal with computed properties in error reporting. - if (node.flags & 128 /* Static */) { - return symbolAccesibilityResult.errorModuleName ? - symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? - ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : - ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : - ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_private_name_1; - } - else if (node.parent.kind === 214 /* ClassDeclaration */) { - return symbolAccesibilityResult.errorModuleName ? - symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? - ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : - ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : - ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_private_name_1; - } - else { - // Interfaces cannot have types that cannot be named - return symbolAccesibilityResult.errorModuleName ? - ts.Diagnostics.Property_0_of_exported_interface_has_or_is_using_name_1_from_private_module_2 : - ts.Diagnostics.Property_0_of_exported_interface_has_or_is_using_private_name_1; - } - } - } - function getVariableDeclarationTypeVisibilityError(symbolAccesibilityResult) { - var diagnosticMessage = getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccesibilityResult); - return diagnosticMessage !== undefined ? { - diagnosticMessage: diagnosticMessage, - errorNode: node, - typeName: node.name - } : undefined; - } - function emitBindingPattern(bindingPattern) { - // Only select non-omitted expression from the bindingPattern's elements. - // We have to do this to avoid emitting trailing commas. - // For example: - // original: var [, c,,] = [ 2,3,4] - // emitted: declare var c: number; // instead of declare var c:number, ; - var elements = []; - for (var _i = 0, _a = bindingPattern.elements; _i < _a.length; _i++) { - var element = _a[_i]; - if (element.kind !== 187 /* OmittedExpression */) { - elements.push(element); - } - } - emitCommaList(elements, emitBindingElement); - } - function emitBindingElement(bindingElement) { - function getBindingElementTypeVisibilityError(symbolAccesibilityResult) { - var diagnosticMessage = getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccesibilityResult); - return diagnosticMessage !== undefined ? { - diagnosticMessage: diagnosticMessage, - errorNode: bindingElement, - typeName: bindingElement.name - } : undefined; - } - if (bindingElement.name) { - if (ts.isBindingPattern(bindingElement.name)) { - emitBindingPattern(bindingElement.name); - } - else { - writeTextOfNode(currentSourceFile, bindingElement.name); - writeTypeOfDeclaration(bindingElement, /*type*/ undefined, getBindingElementTypeVisibilityError); - } - } - } - } - function emitTypeOfVariableDeclarationFromTypeLiteral(node) { - // if this is property of type literal, - // or is parameter of method/call/construct/index signature of type literal - // emit only if type is specified - if (node.type) { - write(": "); - emitType(node.type); - } - } - function isVariableStatementVisible(node) { - return ts.forEach(node.declarationList.declarations, function (varDeclaration) { return resolver.isDeclarationVisible(varDeclaration); }); - } - function writeVariableStatement(node) { - emitJsDocComments(node); - emitModuleElementDeclarationFlags(node); - if (ts.isLet(node.declarationList)) { - write("let "); - } - else if (ts.isConst(node.declarationList)) { - write("const "); - } - else { - write("var "); - } - emitCommaList(node.declarationList.declarations, emitVariableDeclaration, resolver.isDeclarationVisible); - write(";"); - writeLine(); - } - function emitAccessorDeclaration(node) { - if (ts.hasDynamicName(node)) { - return; - } - var accessors = ts.getAllAccessorDeclarations(node.parent.members, node); - var accessorWithTypeAnnotation; - if (node === accessors.firstAccessor) { - emitJsDocComments(accessors.getAccessor); - emitJsDocComments(accessors.setAccessor); - emitClassMemberDeclarationFlags(node); - writeTextOfNode(currentSourceFile, node.name); - if (!(node.flags & 32 /* Private */)) { - accessorWithTypeAnnotation = node; - var type = getTypeAnnotationFromAccessor(node); - if (!type) { - // couldn't get type for the first accessor, try the another one - var anotherAccessor = node.kind === 145 /* GetAccessor */ ? accessors.setAccessor : accessors.getAccessor; - type = getTypeAnnotationFromAccessor(anotherAccessor); - if (type) { - accessorWithTypeAnnotation = anotherAccessor; - } - } - writeTypeOfDeclaration(node, type, getAccessorDeclarationTypeVisibilityError); - } - write(";"); - writeLine(); - } - function getTypeAnnotationFromAccessor(accessor) { - if (accessor) { - return accessor.kind === 145 /* GetAccessor */ - ? accessor.type // Getter - return type - : accessor.parameters.length > 0 - ? accessor.parameters[0].type // Setter parameter type - : undefined; - } - } - function getAccessorDeclarationTypeVisibilityError(symbolAccesibilityResult) { - var diagnosticMessage; - if (accessorWithTypeAnnotation.kind === 146 /* SetAccessor */) { - // Setters have to have type named and cannot infer it so, the type should always be named - if (accessorWithTypeAnnotation.parent.flags & 128 /* Static */) { - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? - ts.Diagnostics.Parameter_0_of_public_static_property_setter_from_exported_class_has_or_is_using_name_1_from_private_module_2 : - ts.Diagnostics.Parameter_0_of_public_static_property_setter_from_exported_class_has_or_is_using_private_name_1; - } - else { - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? - ts.Diagnostics.Parameter_0_of_public_property_setter_from_exported_class_has_or_is_using_name_1_from_private_module_2 : - ts.Diagnostics.Parameter_0_of_public_property_setter_from_exported_class_has_or_is_using_private_name_1; - } - return { - diagnosticMessage: diagnosticMessage, - errorNode: accessorWithTypeAnnotation.parameters[0], - // TODO(jfreeman): Investigate why we are passing node.name instead of node.parameters[0].name - typeName: accessorWithTypeAnnotation.name - }; - } - else { - if (accessorWithTypeAnnotation.flags & 128 /* Static */) { - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? - symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? - ts.Diagnostics.Return_type_of_public_static_property_getter_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : - ts.Diagnostics.Return_type_of_public_static_property_getter_from_exported_class_has_or_is_using_name_0_from_private_module_1 : - ts.Diagnostics.Return_type_of_public_static_property_getter_from_exported_class_has_or_is_using_private_name_0; - } - else { - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? - symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? - ts.Diagnostics.Return_type_of_public_property_getter_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : - ts.Diagnostics.Return_type_of_public_property_getter_from_exported_class_has_or_is_using_name_0_from_private_module_1 : - ts.Diagnostics.Return_type_of_public_property_getter_from_exported_class_has_or_is_using_private_name_0; - } - return { - diagnosticMessage: diagnosticMessage, - errorNode: accessorWithTypeAnnotation.name, - typeName: undefined - }; - } - } - } - function writeFunctionDeclaration(node) { - if (ts.hasDynamicName(node)) { - return; - } - // If we are emitting Method/Constructor it isn't moduleElement and hence already determined to be emitting - // so no need to verify if the declaration is visible - if (!resolver.isImplementationOfOverload(node)) { - emitJsDocComments(node); - if (node.kind === 213 /* FunctionDeclaration */) { - emitModuleElementDeclarationFlags(node); - } - else if (node.kind === 143 /* MethodDeclaration */) { - emitClassMemberDeclarationFlags(node); - } - if (node.kind === 213 /* FunctionDeclaration */) { - write("function "); - writeTextOfNode(currentSourceFile, node.name); - } - else if (node.kind === 144 /* Constructor */) { - write("constructor"); - } - else { - writeTextOfNode(currentSourceFile, node.name); - if (ts.hasQuestionToken(node)) { - write("?"); - } - } - emitSignatureDeclaration(node); - } - } - function emitSignatureDeclarationWithJsDocComments(node) { - emitJsDocComments(node); - emitSignatureDeclaration(node); - } - function emitSignatureDeclaration(node) { - // Construct signature or constructor type write new Signature - if (node.kind === 148 /* ConstructSignature */ || node.kind === 153 /* ConstructorType */) { - write("new "); - } - emitTypeParameters(node.typeParameters); - if (node.kind === 149 /* IndexSignature */) { - write("["); - } - else { - write("("); - } - var prevEnclosingDeclaration = enclosingDeclaration; - enclosingDeclaration = node; - // Parameters - emitCommaList(node.parameters, emitParameterDeclaration); - if (node.kind === 149 /* IndexSignature */) { - write("]"); - } - else { - write(")"); - } - // If this is not a constructor and is not private, emit the return type - var isFunctionTypeOrConstructorType = node.kind === 152 /* FunctionType */ || node.kind === 153 /* ConstructorType */; - if (isFunctionTypeOrConstructorType || node.parent.kind === 155 /* TypeLiteral */) { - // Emit type literal signature return type only if specified - if (node.type) { - write(isFunctionTypeOrConstructorType ? " => " : ": "); - emitType(node.type); - } - } - else if (node.kind !== 144 /* Constructor */ && !(node.flags & 32 /* Private */)) { - writeReturnTypeAtSignature(node, getReturnTypeVisibilityError); - } - enclosingDeclaration = prevEnclosingDeclaration; - if (!isFunctionTypeOrConstructorType) { - write(";"); - writeLine(); - } - function getReturnTypeVisibilityError(symbolAccesibilityResult) { - var diagnosticMessage; - switch (node.kind) { - case 148 /* ConstructSignature */: - // Interfaces cannot have return types that cannot be named - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? - ts.Diagnostics.Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : - ts.Diagnostics.Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_0; - break; - case 147 /* CallSignature */: - // Interfaces cannot have return types that cannot be named - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? - ts.Diagnostics.Return_type_of_call_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : - ts.Diagnostics.Return_type_of_call_signature_from_exported_interface_has_or_is_using_private_name_0; - break; - case 149 /* IndexSignature */: - // Interfaces cannot have return types that cannot be named - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? - ts.Diagnostics.Return_type_of_index_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : - ts.Diagnostics.Return_type_of_index_signature_from_exported_interface_has_or_is_using_private_name_0; - break; - case 143 /* MethodDeclaration */: - case 142 /* MethodSignature */: - if (node.flags & 128 /* Static */) { - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? - symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? - ts.Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : - 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 === 214 /* ClassDeclaration */) { - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? - symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? - ts.Diagnostics.Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : - ts.Diagnostics.Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_private_module_1 : - ts.Diagnostics.Return_type_of_public_method_from_exported_class_has_or_is_using_private_name_0; - } - else { - // Interfaces cannot have return types that cannot be named - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? - ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : - ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0; - } - break; - case 213 /* FunctionDeclaration */: - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? - symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? - ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : - ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_name_0_from_private_module_1 : - ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_private_name_0; - break; - default: - ts.Debug.fail("This is unknown kind for signature: " + node.kind); - } - return { - diagnosticMessage: diagnosticMessage, - errorNode: node.name || node - }; - } - } - function emitParameterDeclaration(node) { - increaseIndent(); - emitJsDocComments(node); - if (node.dotDotDotToken) { - write("..."); - } - if (ts.isBindingPattern(node.name)) { - // For bindingPattern, we can't simply writeTextOfNode from the source file - // because we want to omit the initializer and using writeTextOfNode will result in initializer get emitted. - // Therefore, we will have to recursively emit each element in the bindingPattern. - emitBindingPattern(node.name); - } - else { - writeTextOfNode(currentSourceFile, node.name); - } - if (resolver.isOptionalParameter(node)) { - write("?"); - } - decreaseIndent(); - if (node.parent.kind === 152 /* FunctionType */ || - node.parent.kind === 153 /* ConstructorType */ || - node.parent.parent.kind === 155 /* TypeLiteral */) { - emitTypeOfVariableDeclarationFromTypeLiteral(node); - } - else if (!(node.parent.flags & 32 /* Private */)) { - writeTypeOfDeclaration(node, node.type, getParameterDeclarationTypeVisibilityError); - } - function getParameterDeclarationTypeVisibilityError(symbolAccesibilityResult) { - var diagnosticMessage = getParameterDeclarationTypeVisibilityDiagnosticMessage(symbolAccesibilityResult); - return diagnosticMessage !== undefined ? { - diagnosticMessage: diagnosticMessage, - errorNode: node, - typeName: node.name - } : undefined; - } - function getParameterDeclarationTypeVisibilityDiagnosticMessage(symbolAccesibilityResult) { - switch (node.parent.kind) { - case 144 /* Constructor */: - return symbolAccesibilityResult.errorModuleName ? - symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? - ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : - ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_private_module_2 : - ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_private_name_1; - case 148 /* ConstructSignature */: - // Interfaces cannot have parameter types that cannot be named - return symbolAccesibilityResult.errorModuleName ? - ts.Diagnostics.Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : - ts.Diagnostics.Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; - case 147 /* CallSignature */: - // Interfaces cannot have parameter types that cannot be named - return symbolAccesibilityResult.errorModuleName ? - ts.Diagnostics.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : - ts.Diagnostics.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; - case 143 /* MethodDeclaration */: - case 142 /* MethodSignature */: - if (node.parent.flags & 128 /* Static */) { - return symbolAccesibilityResult.errorModuleName ? - symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? - ts.Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : - 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 === 214 /* ClassDeclaration */) { - return symbolAccesibilityResult.errorModuleName ? - symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? - ts.Diagnostics.Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : - ts.Diagnostics.Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_private_module_2 : - ts.Diagnostics.Parameter_0_of_public_method_from_exported_class_has_or_is_using_private_name_1; - } - else { - // Interfaces cannot have parameter types that cannot be named - return symbolAccesibilityResult.errorModuleName ? - 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 213 /* FunctionDeclaration */: - return symbolAccesibilityResult.errorModuleName ? - symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? - ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : - ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_name_1_from_private_module_2 : - ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_private_name_1; - default: - ts.Debug.fail("This is unknown parent for parameter: " + node.parent.kind); - } - } - function emitBindingPattern(bindingPattern) { - // We have to explicitly emit square bracket and bracket because these tokens are not store inside the node. - if (bindingPattern.kind === 161 /* ObjectBindingPattern */) { - write("{"); - emitCommaList(bindingPattern.elements, emitBindingElement); - write("}"); - } - else if (bindingPattern.kind === 162 /* ArrayBindingPattern */) { - write("["); - var elements = bindingPattern.elements; - emitCommaList(elements, emitBindingElement); - if (elements && elements.hasTrailingComma) { - write(", "); - } - write("]"); - } - } - function emitBindingElement(bindingElement) { - function getBindingElementTypeVisibilityError(symbolAccesibilityResult) { - var diagnosticMessage = getParameterDeclarationTypeVisibilityDiagnosticMessage(symbolAccesibilityResult); - return diagnosticMessage !== undefined ? { - diagnosticMessage: diagnosticMessage, - errorNode: bindingElement, - typeName: bindingElement.name - } : undefined; - } - if (bindingElement.kind === 187 /* OmittedExpression */) { - // If bindingElement is an omittedExpression (i.e. containing elision), - // we will emit blank space (although this may differ from users' original code, - // it allows emitSeparatedList to write separator appropriately) - // Example: - // original: function foo([, x, ,]) {} - // emit : function foo([ , x, , ]) {} - write(" "); - } - else if (bindingElement.kind === 163 /* BindingElement */) { - if (bindingElement.propertyName) { - // bindingElement has propertyName property in the following case: - // { y: [a,b,c] ...} -> bindingPattern will have a property called propertyName for "y" - // We have to explicitly emit the propertyName before descending into its binding elements. - // Example: - // original: function foo({y: [a,b,c]}) {} - // emit : declare function foo({y: [a, b, c]}: { y: [any, any, any] }) void; - writeTextOfNode(currentSourceFile, bindingElement.propertyName); - write(": "); - } - if (bindingElement.name) { - if (ts.isBindingPattern(bindingElement.name)) { - // If it is a nested binding pattern, we will recursively descend into each element and emit each one separately. - // In the case of rest element, we will omit rest element. - // Example: - // original: function foo([a, [[b]], c] = [1,[["string"]], 3]) {} - // emit : declare function foo([a, [[b]], c]: [number, [[string]], number]): void; - // original with rest: function foo([a, ...c]) {} - // emit : declare function foo([a, ...c]): void; - emitBindingPattern(bindingElement.name); - } - else { - ts.Debug.assert(bindingElement.name.kind === 69 /* Identifier */); - // If the node is just an identifier, we will simply emit the text associated with the node's name - // Example: - // original: function foo({y = 10, x}) {} - // emit : declare function foo({y, x}: {number, any}): void; - if (bindingElement.dotDotDotToken) { - write("..."); - } - writeTextOfNode(currentSourceFile, bindingElement.name); - } - } - } - } - } - function emitNode(node) { - switch (node.kind) { - case 213 /* FunctionDeclaration */: - case 218 /* ModuleDeclaration */: - case 221 /* ImportEqualsDeclaration */: - case 215 /* InterfaceDeclaration */: - case 214 /* ClassDeclaration */: - case 216 /* TypeAliasDeclaration */: - case 217 /* EnumDeclaration */: - return emitModuleElement(node, isModuleElementVisible(node)); - case 193 /* VariableStatement */: - return emitModuleElement(node, isVariableStatementVisible(node)); - case 222 /* ImportDeclaration */: - // Import declaration without import clause is visible, otherwise it is not visible - return emitModuleElement(node, /*isModuleElementVisible*/ !node.importClause); - case 228 /* ExportDeclaration */: - return emitExportDeclaration(node); - case 144 /* Constructor */: - case 143 /* MethodDeclaration */: - case 142 /* MethodSignature */: - return writeFunctionDeclaration(node); - case 148 /* ConstructSignature */: - case 147 /* CallSignature */: - case 149 /* IndexSignature */: - return emitSignatureDeclarationWithJsDocComments(node); - case 145 /* GetAccessor */: - case 146 /* SetAccessor */: - return emitAccessorDeclaration(node); - case 141 /* PropertyDeclaration */: - case 140 /* PropertySignature */: - return emitPropertyDeclaration(node); - case 247 /* EnumMember */: - return emitEnumMemberDeclaration(node); - case 227 /* ExportAssignment */: - return emitExportAssignment(node); - case 248 /* SourceFile */: - return emitSourceFile(node); - } - } - function writeReferencePath(referencedFile) { - var declFileName = referencedFile.flags & 8192 /* DeclarationFile */ - ? referencedFile.fileName // Declaration file, use declaration file name - : ts.shouldEmitToOwnFile(referencedFile, compilerOptions) - ? ts.getOwnEmitOutputFilePath(referencedFile, host, ".d.ts") // Own output file so get the .d.ts file - : ts.removeFileExtension(compilerOptions.outFile || compilerOptions.out) + ".d.ts"; // Global out file - declFileName = ts.getRelativePathToDirectoryOrUrl(ts.getDirectoryPath(ts.normalizeSlashes(jsFilePath)), declFileName, host.getCurrentDirectory(), host.getCanonicalFileName, - /*isAbsolutePathAnUrl*/ false); - referencePathsOutput += "/// " + newLine; - } - } - /* @internal */ - function writeDeclarationFile(jsFilePath, sourceFile, host, resolver, diagnostics) { - var emitDeclarationResult = emitDeclarations(host, resolver, diagnostics, jsFilePath, sourceFile); - // TODO(shkamat): Should we not write any declaration file if any of them can produce error, - // or should we just not write this file like we are doing now - if (!emitDeclarationResult.reportedDeclarationError) { - var declarationOutput = emitDeclarationResult.referencePathsOutput - + getDeclarationOutput(emitDeclarationResult.synchronousDeclarationOutput, emitDeclarationResult.moduleElementDeclarationEmitInfo); - ts.writeFile(host, diagnostics, ts.removeFileExtension(jsFilePath) + ".d.ts", declarationOutput, host.getCompilerOptions().emitBOM); - } - function getDeclarationOutput(synchronousDeclarationOutput, moduleElementDeclarationEmitInfo) { - var appliedSyncOutputPos = 0; - var declarationOutput = ""; - // apply asynchronous additions to the synchronous output - ts.forEach(moduleElementDeclarationEmitInfo, function (aliasEmitInfo) { - if (aliasEmitInfo.asynchronousOutput) { - declarationOutput += synchronousDeclarationOutput.substring(appliedSyncOutputPos, aliasEmitInfo.outputPos); - declarationOutput += getDeclarationOutput(aliasEmitInfo.asynchronousOutput, aliasEmitInfo.subModuleElementDeclarationEmitInfo); - appliedSyncOutputPos = aliasEmitInfo.outputPos; - } - }); - declarationOutput += synchronousDeclarationOutput.substring(appliedSyncOutputPos); - return declarationOutput; - } - } - ts.writeDeclarationFile = writeDeclarationFile; -})(ts || (ts = {})); -/// -/// -/* @internal */ -var ts; -(function (ts) { - function isExternalModuleOrDeclarationFile(sourceFile) { - return ts.isExternalModule(sourceFile) || ts.isDeclarationFile(sourceFile); - } - ts.isExternalModuleOrDeclarationFile = isExternalModuleOrDeclarationFile; - var entities = { - "quot": 0x0022, - "amp": 0x0026, - "apos": 0x0027, - "lt": 0x003C, - "gt": 0x003E, - "nbsp": 0x00A0, - "iexcl": 0x00A1, - "cent": 0x00A2, - "pound": 0x00A3, - "curren": 0x00A4, - "yen": 0x00A5, - "brvbar": 0x00A6, - "sect": 0x00A7, - "uml": 0x00A8, - "copy": 0x00A9, - "ordf": 0x00AA, - "laquo": 0x00AB, - "not": 0x00AC, - "shy": 0x00AD, - "reg": 0x00AE, - "macr": 0x00AF, - "deg": 0x00B0, - "plusmn": 0x00B1, - "sup2": 0x00B2, - "sup3": 0x00B3, - "acute": 0x00B4, - "micro": 0x00B5, - "para": 0x00B6, - "middot": 0x00B7, - "cedil": 0x00B8, - "sup1": 0x00B9, - "ordm": 0x00BA, - "raquo": 0x00BB, - "frac14": 0x00BC, - "frac12": 0x00BD, - "frac34": 0x00BE, - "iquest": 0x00BF, - "Agrave": 0x00C0, - "Aacute": 0x00C1, - "Acirc": 0x00C2, - "Atilde": 0x00C3, - "Auml": 0x00C4, - "Aring": 0x00C5, - "AElig": 0x00C6, - "Ccedil": 0x00C7, - "Egrave": 0x00C8, - "Eacute": 0x00C9, - "Ecirc": 0x00CA, - "Euml": 0x00CB, - "Igrave": 0x00CC, - "Iacute": 0x00CD, - "Icirc": 0x00CE, - "Iuml": 0x00CF, - "ETH": 0x00D0, - "Ntilde": 0x00D1, - "Ograve": 0x00D2, - "Oacute": 0x00D3, - "Ocirc": 0x00D4, - "Otilde": 0x00D5, - "Ouml": 0x00D6, - "times": 0x00D7, - "Oslash": 0x00D8, - "Ugrave": 0x00D9, - "Uacute": 0x00DA, - "Ucirc": 0x00DB, - "Uuml": 0x00DC, - "Yacute": 0x00DD, - "THORN": 0x00DE, - "szlig": 0x00DF, - "agrave": 0x00E0, - "aacute": 0x00E1, - "acirc": 0x00E2, - "atilde": 0x00E3, - "auml": 0x00E4, - "aring": 0x00E5, - "aelig": 0x00E6, - "ccedil": 0x00E7, - "egrave": 0x00E8, - "eacute": 0x00E9, - "ecirc": 0x00EA, - "euml": 0x00EB, - "igrave": 0x00EC, - "iacute": 0x00ED, - "icirc": 0x00EE, - "iuml": 0x00EF, - "eth": 0x00F0, - "ntilde": 0x00F1, - "ograve": 0x00F2, - "oacute": 0x00F3, - "ocirc": 0x00F4, - "otilde": 0x00F5, - "ouml": 0x00F6, - "divide": 0x00F7, - "oslash": 0x00F8, - "ugrave": 0x00F9, - "uacute": 0x00FA, - "ucirc": 0x00FB, - "uuml": 0x00FC, - "yacute": 0x00FD, - "thorn": 0x00FE, - "yuml": 0x00FF, - "OElig": 0x0152, - "oelig": 0x0153, - "Scaron": 0x0160, - "scaron": 0x0161, - "Yuml": 0x0178, - "fnof": 0x0192, - "circ": 0x02C6, - "tilde": 0x02DC, - "Alpha": 0x0391, - "Beta": 0x0392, - "Gamma": 0x0393, - "Delta": 0x0394, - "Epsilon": 0x0395, - "Zeta": 0x0396, - "Eta": 0x0397, - "Theta": 0x0398, - "Iota": 0x0399, - "Kappa": 0x039A, - "Lambda": 0x039B, - "Mu": 0x039C, - "Nu": 0x039D, - "Xi": 0x039E, - "Omicron": 0x039F, - "Pi": 0x03A0, - "Rho": 0x03A1, - "Sigma": 0x03A3, - "Tau": 0x03A4, - "Upsilon": 0x03A5, - "Phi": 0x03A6, - "Chi": 0x03A7, - "Psi": 0x03A8, - "Omega": 0x03A9, - "alpha": 0x03B1, - "beta": 0x03B2, - "gamma": 0x03B3, - "delta": 0x03B4, - "epsilon": 0x03B5, - "zeta": 0x03B6, - "eta": 0x03B7, - "theta": 0x03B8, - "iota": 0x03B9, - "kappa": 0x03BA, - "lambda": 0x03BB, - "mu": 0x03BC, - "nu": 0x03BD, - "xi": 0x03BE, - "omicron": 0x03BF, - "pi": 0x03C0, - "rho": 0x03C1, - "sigmaf": 0x03C2, - "sigma": 0x03C3, - "tau": 0x03C4, - "upsilon": 0x03C5, - "phi": 0x03C6, - "chi": 0x03C7, - "psi": 0x03C8, - "omega": 0x03C9, - "thetasym": 0x03D1, - "upsih": 0x03D2, - "piv": 0x03D6, - "ensp": 0x2002, - "emsp": 0x2003, - "thinsp": 0x2009, - "zwnj": 0x200C, - "zwj": 0x200D, - "lrm": 0x200E, - "rlm": 0x200F, - "ndash": 0x2013, - "mdash": 0x2014, - "lsquo": 0x2018, - "rsquo": 0x2019, - "sbquo": 0x201A, - "ldquo": 0x201C, - "rdquo": 0x201D, - "bdquo": 0x201E, - "dagger": 0x2020, - "Dagger": 0x2021, - "bull": 0x2022, - "hellip": 0x2026, - "permil": 0x2030, - "prime": 0x2032, - "Prime": 0x2033, - "lsaquo": 0x2039, - "rsaquo": 0x203A, - "oline": 0x203E, - "frasl": 0x2044, - "euro": 0x20AC, - "image": 0x2111, - "weierp": 0x2118, - "real": 0x211C, - "trade": 0x2122, - "alefsym": 0x2135, - "larr": 0x2190, - "uarr": 0x2191, - "rarr": 0x2192, - "darr": 0x2193, - "harr": 0x2194, - "crarr": 0x21B5, - "lArr": 0x21D0, - "uArr": 0x21D1, - "rArr": 0x21D2, - "dArr": 0x21D3, - "hArr": 0x21D4, - "forall": 0x2200, - "part": 0x2202, - "exist": 0x2203, - "empty": 0x2205, - "nabla": 0x2207, - "isin": 0x2208, - "notin": 0x2209, - "ni": 0x220B, - "prod": 0x220F, - "sum": 0x2211, - "minus": 0x2212, - "lowast": 0x2217, - "radic": 0x221A, - "prop": 0x221D, - "infin": 0x221E, - "ang": 0x2220, - "and": 0x2227, - "or": 0x2228, - "cap": 0x2229, - "cup": 0x222A, - "int": 0x222B, - "there4": 0x2234, - "sim": 0x223C, - "cong": 0x2245, - "asymp": 0x2248, - "ne": 0x2260, - "equiv": 0x2261, - "le": 0x2264, - "ge": 0x2265, - "sub": 0x2282, - "sup": 0x2283, - "nsub": 0x2284, - "sube": 0x2286, - "supe": 0x2287, - "oplus": 0x2295, - "otimes": 0x2297, - "perp": 0x22A5, - "sdot": 0x22C5, - "lceil": 0x2308, - "rceil": 0x2309, - "lfloor": 0x230A, - "rfloor": 0x230B, - "lang": 0x2329, - "rang": 0x232A, - "loz": 0x25CA, - "spades": 0x2660, - "clubs": 0x2663, - "hearts": 0x2665, - "diams": 0x2666 - }; - // Flags enum to track count of temp variables and a few dedicated names - var TempFlags; - (function (TempFlags) { - TempFlags[TempFlags["Auto"] = 0] = "Auto"; - TempFlags[TempFlags["CountMask"] = 268435455] = "CountMask"; - TempFlags[TempFlags["_i"] = 268435456] = "_i"; - })(TempFlags || (TempFlags = {})); - // 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) { - // emit output for the __extends helper function - var extendsHelper = "\nvar __extends = (this && this.__extends) || function (d, b) {\n for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];\n function __() { this.constructor = d; }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n};"; - // emit output for the __decorate helper function - var decorateHelper = "\nvar __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\n return c > 3 && r && Object.defineProperty(target, key, r), r;\n};"; - // emit output for the __metadata helper function - var metadataHelper = "\nvar __metadata = (this && this.__metadata) || function (k, v) {\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(k, v);\n};"; - // emit output for the __param helper function - var paramHelper = "\nvar __param = (this && this.__param) || function (paramIndex, decorator) {\n return function (target, key) { decorator(target, key, paramIndex); }\n};"; - var awaiterHelper = "\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promise, generator) {\n return new Promise(function (resolve, reject) {\n generator = generator.call(thisArg, _arguments);\n function cast(value) { return value instanceof Promise && value.constructor === Promise ? value : new Promise(function (resolve) { resolve(value); }); }\n function onfulfill(value) { try { step(\"next\", value); } catch (e) { reject(e); } }\n function onreject(value) { try { step(\"throw\", value); } catch (e) { reject(e); } }\n function step(verb, value) {\n var result = generator[verb](value);\n result.done ? resolve(result.value) : cast(result.value).then(onfulfill, onreject);\n }\n step(\"next\", void 0);\n });\n};"; - var compilerOptions = host.getCompilerOptions(); - var languageVersion = compilerOptions.target || 0 /* ES3 */; - var modulekind = compilerOptions.module ? compilerOptions.module : languageVersion === 2 /* ES6 */ ? 5 /* ES6 */ : 0 /* None */; - var sourceMapDataList = compilerOptions.sourceMap || compilerOptions.inlineSourceMap ? [] : undefined; - var diagnostics = []; - var newLine = host.getNewLine(); - var jsxDesugaring = host.getCompilerOptions().jsx !== 1 /* Preserve */; - var shouldEmitJsx = function (s) { return (s.languageVariant === 1 /* JSX */ && !jsxDesugaring); }; - if (targetSourceFile === undefined) { - ts.forEach(host.getSourceFiles(), function (sourceFile) { - if (ts.shouldEmitToOwnFile(sourceFile, compilerOptions)) { - var jsFilePath = ts.getOwnEmitOutputFilePath(sourceFile, host, shouldEmitJsx(sourceFile) ? ".jsx" : ".js"); - emitFile(jsFilePath, sourceFile); - } - }); - if (compilerOptions.outFile || compilerOptions.out) { - emitFile(compilerOptions.outFile || compilerOptions.out); - } - } - else { - // targetSourceFile is specified (e.g calling emitter from language service or calling getSemanticDiagnostic from language service) - if (ts.shouldEmitToOwnFile(targetSourceFile, compilerOptions)) { - var jsFilePath = ts.getOwnEmitOutputFilePath(targetSourceFile, host, shouldEmitJsx(targetSourceFile) ? ".jsx" : ".js"); - emitFile(jsFilePath, targetSourceFile); - } - else if (!ts.isDeclarationFile(targetSourceFile) && (compilerOptions.outFile || compilerOptions.out)) { - emitFile(compilerOptions.outFile || compilerOptions.out); - } - } - // Sort and make the unique list of diagnostics - diagnostics = ts.sortAndDeduplicateDiagnostics(diagnostics); - return { - emitSkipped: false, - diagnostics: diagnostics, - sourceMaps: sourceMapDataList - }; - function isNodeDescendentOf(node, ancestor) { - while (node) { - if (node === ancestor) - return true; - node = node.parent; - } - return false; - } - function isUniqueLocalName(name, container) { - for (var node = container; isNodeDescendentOf(node, container); node = node.nextContainer) { - if (node.locals && ts.hasProperty(node.locals, name)) { - // We conservatively include alias symbols to cover cases where they're emitted as locals - if (node.locals[name].flags & (107455 /* Value */ | 1048576 /* ExportValue */ | 8388608 /* Alias */)) { - return false; - } - } - } - return true; - } - function emitJavaScript(jsFilePath, root) { - var writer = ts.createTextWriter(newLine); - var write = writer.write, writeTextOfNode = writer.writeTextOfNode, writeLine = writer.writeLine, increaseIndent = writer.increaseIndent, decreaseIndent = writer.decreaseIndent; - var currentSourceFile; - // name of an exporter function if file is a System external module - // System.register([...], function () {...}) - // exporting in System modules looks like: - // export var x; ... x = 1 - // => - // var x;... exporter("x", x = 1) - var exportFunctionForFile; - var generatedNameSet = {}; - var nodeToGeneratedName = []; - var computedPropertyNamesToGeneratedNames; - var extendsEmitted = false; - var decorateEmitted = false; - var paramEmitted = false; - var awaiterEmitted = false; - var tempFlags = 0; - var tempVariables; - var tempParameters; - var externalImports; - var exportSpecifiers; - var exportEquals; - var hasExportStars; - /** Write emitted output to disk */ - var writeEmittedFiles = writeJavaScriptFile; - var detachedCommentsInfo; - var writeComment = ts.writeCommentRange; - /** Emit a node */ - var emit = emitNodeWithCommentsAndWithoutSourcemap; - /** Called just before starting emit of a node */ - var emitStart = function (node) { }; - /** Called once the emit of the node is done */ - var emitEnd = function (node) { }; - /** Emit the text for the given token that comes after startPos - * This by default writes the text provided with the given tokenKind - * but if optional emitFn callback is provided the text is emitted using the callback instead of default text - * @param tokenKind the kind of the token to search and emit - * @param startPos the position in the source to start searching for the token - * @param emitFn if given will be invoked to emit the text instead of actual token emit */ - var emitToken = emitTokenText; - /** Called to before starting the lexical scopes as in function/class in the emitted code because of node - * @param scopeDeclaration node that starts the lexical scope - * @param scopeName Optional name of this scope instead of deducing one from the declaration node */ - var scopeEmitStart = function (scopeDeclaration, scopeName) { }; - /** Called after coming out of the scope */ - var scopeEmitEnd = function () { }; - /** Sourcemap data that will get encoded */ - var sourceMapData; - /** If removeComments is true, no leading-comments needed to be emitted **/ - var emitLeadingCommentsOfPosition = compilerOptions.removeComments ? function (pos) { } : emitLeadingCommentsOfPositionWorker; - var moduleEmitDelegates = (_a = {}, - _a[5 /* ES6 */] = emitES6Module, - _a[2 /* AMD */] = emitAMDModule, - _a[4 /* System */] = emitSystemModule, - _a[3 /* UMD */] = emitUMDModule, - _a[1 /* CommonJS */] = emitCommonJSModule, - _a - ); - if (compilerOptions.sourceMap || compilerOptions.inlineSourceMap) { - initializeEmitterWithSourceMaps(); - } - if (root) { - // Do not call emit directly. It does not set the currentSourceFile. - emitSourceFile(root); - } - else { - ts.forEach(host.getSourceFiles(), function (sourceFile) { - if (!isExternalModuleOrDeclarationFile(sourceFile)) { - emitSourceFile(sourceFile); - } - }); - } - writeLine(); - writeEmittedFiles(writer.getText(), /*writeByteOrderMark*/ compilerOptions.emitBOM); - return; - function emitSourceFile(sourceFile) { - currentSourceFile = sourceFile; - exportFunctionForFile = undefined; - emit(sourceFile); - } - function isUniqueName(name) { - return !resolver.hasGlobalName(name) && - !ts.hasProperty(currentSourceFile.identifiers, name) && - !ts.hasProperty(generatedNameSet, name); - } - // Return the next available name in the pattern _a ... _z, _0, _1, ... - // TempFlags._i or TempFlags._n may be used to express a preference for that dedicated name. - // Note that names generated by makeTempVariableName and makeUniqueName will never conflict. - function makeTempVariableName(flags) { - if (flags && !(tempFlags & flags)) { - var name_19 = flags === 268435456 /* _i */ ? "_i" : "_n"; - if (isUniqueName(name_19)) { - tempFlags |= flags; - return name_19; - } - } - while (true) { - var count = tempFlags & 268435455 /* CountMask */; - tempFlags++; - // Skip over 'i' and 'n' - if (count !== 8 && count !== 13) { - var name_20 = count < 26 ? "_" + String.fromCharCode(97 /* a */ + count) : "_" + (count - 26); - if (isUniqueName(name_20)) { - return name_20; - } - } - } - } - // Generate a name that is unique within the current file and doesn't conflict with any names - // in global scope. The name is formed by adding an '_n' suffix to the specified base name, - // where n is a positive integer. Note that names generated by makeTempVariableName and - // makeUniqueName are guaranteed to never conflict. - function makeUniqueName(baseName) { - // Find the first unique 'name_n', where n is a positive number - if (baseName.charCodeAt(baseName.length - 1) !== 95 /* _ */) { - baseName += "_"; - } - var i = 1; - while (true) { - var generatedName = baseName + i; - if (isUniqueName(generatedName)) { - return generatedNameSet[generatedName] = generatedName; - } - i++; - } - } - function generateNameForModuleOrEnum(node) { - var name = node.name.text; - // Use module/enum name itself if it is unique, otherwise make a unique variation - return isUniqueLocalName(name, node) ? name : makeUniqueName(name); - } - function generateNameForImportOrExportDeclaration(node) { - var expr = ts.getExternalModuleName(node); - var baseName = expr.kind === 9 /* StringLiteral */ ? - ts.escapeIdentifier(ts.makeIdentifierFromModuleName(expr.text)) : "module"; - return makeUniqueName(baseName); - } - function generateNameForExportDefault() { - return makeUniqueName("default"); - } - function generateNameForClassExpression() { - return makeUniqueName("class"); - } - function generateNameForNode(node) { - switch (node.kind) { - case 69 /* Identifier */: - return makeUniqueName(node.text); - case 218 /* ModuleDeclaration */: - case 217 /* EnumDeclaration */: - return generateNameForModuleOrEnum(node); - case 222 /* ImportDeclaration */: - case 228 /* ExportDeclaration */: - return generateNameForImportOrExportDeclaration(node); - case 213 /* FunctionDeclaration */: - case 214 /* ClassDeclaration */: - case 227 /* ExportAssignment */: - return generateNameForExportDefault(); - case 186 /* ClassExpression */: - return generateNameForClassExpression(); - } - } - function getGeneratedNameForNode(node) { - var id = ts.getNodeId(node); - return nodeToGeneratedName[id] || (nodeToGeneratedName[id] = ts.unescapeIdentifier(generateNameForNode(node))); - } - function initializeEmitterWithSourceMaps() { - var sourceMapDir; // The directory in which sourcemap will be - // Current source map file and its index in the sources list - var sourceMapSourceIndex = -1; - // Names and its index map - var sourceMapNameIndexMap = {}; - var sourceMapNameIndices = []; - function getSourceMapNameIndex() { - return sourceMapNameIndices.length ? ts.lastOrUndefined(sourceMapNameIndices) : -1; - } - // Last recorded and encoded spans - var lastRecordedSourceMapSpan; - var lastEncodedSourceMapSpan = { - emittedLine: 1, - emittedColumn: 1, - sourceLine: 1, - sourceColumn: 1, - sourceIndex: 0 - }; - var lastEncodedNameIndex = 0; - // Encoding for sourcemap span - function encodeLastRecordedSourceMapSpan() { - if (!lastRecordedSourceMapSpan || lastRecordedSourceMapSpan === lastEncodedSourceMapSpan) { - return; - } - var prevEncodedEmittedColumn = lastEncodedSourceMapSpan.emittedColumn; - // Line/Comma delimiters - if (lastEncodedSourceMapSpan.emittedLine === lastRecordedSourceMapSpan.emittedLine) { - // Emit comma to separate the entry - if (sourceMapData.sourceMapMappings) { - sourceMapData.sourceMapMappings += ","; - } - } - else { - // Emit line delimiters - for (var encodedLine = lastEncodedSourceMapSpan.emittedLine; encodedLine < lastRecordedSourceMapSpan.emittedLine; encodedLine++) { - sourceMapData.sourceMapMappings += ";"; - } - prevEncodedEmittedColumn = 1; - } - // 1. Relative Column 0 based - sourceMapData.sourceMapMappings += base64VLQFormatEncode(lastRecordedSourceMapSpan.emittedColumn - prevEncodedEmittedColumn); - // 2. Relative sourceIndex - sourceMapData.sourceMapMappings += base64VLQFormatEncode(lastRecordedSourceMapSpan.sourceIndex - lastEncodedSourceMapSpan.sourceIndex); - // 3. Relative sourceLine 0 based - sourceMapData.sourceMapMappings += base64VLQFormatEncode(lastRecordedSourceMapSpan.sourceLine - lastEncodedSourceMapSpan.sourceLine); - // 4. Relative sourceColumn 0 based - sourceMapData.sourceMapMappings += base64VLQFormatEncode(lastRecordedSourceMapSpan.sourceColumn - lastEncodedSourceMapSpan.sourceColumn); - // 5. Relative namePosition 0 based - if (lastRecordedSourceMapSpan.nameIndex >= 0) { - sourceMapData.sourceMapMappings += base64VLQFormatEncode(lastRecordedSourceMapSpan.nameIndex - lastEncodedNameIndex); - lastEncodedNameIndex = lastRecordedSourceMapSpan.nameIndex; - } - lastEncodedSourceMapSpan = lastRecordedSourceMapSpan; - sourceMapData.sourceMapDecodedMappings.push(lastEncodedSourceMapSpan); - function base64VLQFormatEncode(inValue) { - function base64FormatEncode(inValue) { - if (inValue < 64) { - return "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(inValue); - } - throw TypeError(inValue + ": not a 64 based value"); - } - // Add a new least significant bit that has the sign of the value. - // if negative number the least significant bit that gets added to the number has value 1 - // else least significant bit value that gets added is 0 - // eg. -1 changes to binary : 01 [1] => 3 - // +1 changes to binary : 01 [0] => 2 - if (inValue < 0) { - inValue = ((-inValue) << 1) + 1; - } - else { - inValue = inValue << 1; - } - // Encode 5 bits at a time starting from least significant bits - var encodedStr = ""; - do { - var currentDigit = inValue & 31; // 11111 - inValue = inValue >> 5; - if (inValue > 0) { - // There are still more digits to decode, set the msb (6th bit) - currentDigit = currentDigit | 32; - } - encodedStr = encodedStr + base64FormatEncode(currentDigit); - } while (inValue > 0); - return encodedStr; - } - } - function recordSourceMapSpan(pos) { - var sourceLinePos = ts.getLineAndCharacterOfPosition(currentSourceFile, pos); - // Convert the location to be one-based. - sourceLinePos.line++; - sourceLinePos.character++; - var emittedLine = writer.getLine(); - var emittedColumn = writer.getColumn(); - // If this location wasn't recorded or the location in source is going backwards, record the span - if (!lastRecordedSourceMapSpan || - lastRecordedSourceMapSpan.emittedLine !== emittedLine || - lastRecordedSourceMapSpan.emittedColumn !== emittedColumn || - (lastRecordedSourceMapSpan.sourceIndex === sourceMapSourceIndex && - (lastRecordedSourceMapSpan.sourceLine > sourceLinePos.line || - (lastRecordedSourceMapSpan.sourceLine === sourceLinePos.line && lastRecordedSourceMapSpan.sourceColumn > sourceLinePos.character)))) { - // Encode the last recordedSpan before assigning new - encodeLastRecordedSourceMapSpan(); - // New span - lastRecordedSourceMapSpan = { - emittedLine: emittedLine, - emittedColumn: emittedColumn, - sourceLine: sourceLinePos.line, - sourceColumn: sourceLinePos.character, - nameIndex: getSourceMapNameIndex(), - sourceIndex: sourceMapSourceIndex - }; - } - 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; - } - } - function recordEmitNodeStartSpan(node) { - // Get the token pos after skipping to the token (ignoring the leading trivia) - recordSourceMapSpan(ts.skipTrivia(currentSourceFile.text, node.pos)); - } - function recordEmitNodeEndSpan(node) { - recordSourceMapSpan(node.end); - } - function writeTextWithSpanRecord(tokenKind, startPos, emitFn) { - var tokenStartPos = ts.skipTrivia(currentSourceFile.text, startPos); - recordSourceMapSpan(tokenStartPos); - var tokenEndPos = emitTokenText(tokenKind, tokenStartPos, emitFn); - recordSourceMapSpan(tokenEndPos); - return tokenEndPos; - } - function recordNewSourceFileStart(node) { - // Add the file to tsFilePaths - // If sourceroot option: Use the relative path corresponding to the common directory path - // otherwise source locations relative to map file location - var sourcesDirectoryPath = compilerOptions.sourceRoot ? host.getCommonSourceDirectory() : sourceMapDir; - sourceMapData.sourceMapSources.push(ts.getRelativePathToDirectoryOrUrl(sourcesDirectoryPath, node.fileName, host.getCurrentDirectory(), host.getCanonicalFileName, - /*isAbsolutePathAnUrl*/ true)); - sourceMapSourceIndex = sourceMapData.sourceMapSources.length - 1; - // The one that can be used from program to get the actual source file - sourceMapData.inputSourceFileNames.push(node.fileName); - if (compilerOptions.inlineSources) { - if (!sourceMapData.sourceMapSourcesContent) { - sourceMapData.sourceMapSourcesContent = []; - } - sourceMapData.sourceMapSourcesContent.push(node.text); - } - } - function recordScopeNameOfNode(node, scopeName) { - function recordScopeNameIndex(scopeNameIndex) { - sourceMapNameIndices.push(scopeNameIndex); - } - function recordScopeNameStart(scopeName) { - var scopeNameIndex = -1; - if (scopeName) { - var parentIndex = getSourceMapNameIndex(); - if (parentIndex !== -1) { - // Child scopes are always shown with a dot (even if they have no name), - // unless it is a computed property. Then it is shown with brackets, - // but the brackets are included in the name. - var name_21 = node.name; - if (!name_21 || name_21.kind !== 136 /* ComputedPropertyName */) { - scopeName = "." + scopeName; - } - scopeName = sourceMapData.sourceMapNames[parentIndex] + scopeName; - } - scopeNameIndex = ts.getProperty(sourceMapNameIndexMap, scopeName); - if (scopeNameIndex === undefined) { - scopeNameIndex = sourceMapData.sourceMapNames.length; - sourceMapData.sourceMapNames.push(scopeName); - sourceMapNameIndexMap[scopeName] = scopeNameIndex; - } - } - recordScopeNameIndex(scopeNameIndex); - } - if (scopeName) { - // The scope was already given a name use it - recordScopeNameStart(scopeName); - } - else if (node.kind === 213 /* FunctionDeclaration */ || - node.kind === 173 /* FunctionExpression */ || - node.kind === 143 /* MethodDeclaration */ || - node.kind === 142 /* MethodSignature */ || - node.kind === 145 /* GetAccessor */ || - node.kind === 146 /* SetAccessor */ || - node.kind === 218 /* ModuleDeclaration */ || - node.kind === 214 /* ClassDeclaration */ || - node.kind === 217 /* EnumDeclaration */) { - // Declaration and has associated name use it - if (node.name) { - var name_22 = node.name; - // For computed property names, the text will include the brackets - scopeName = name_22.kind === 136 /* ComputedPropertyName */ - ? ts.getTextOfNode(name_22) - : node.name.text; - } - recordScopeNameStart(scopeName); - } - else { - // Block just use the name from upper level scope - recordScopeNameIndex(getSourceMapNameIndex()); - } - } - function recordScopeNameEnd() { - sourceMapNameIndices.pop(); - } - ; - function writeCommentRangeWithMap(curentSourceFile, writer, comment, newLine) { - recordSourceMapSpan(comment.pos); - ts.writeCommentRange(currentSourceFile, writer, comment, newLine); - recordSourceMapSpan(comment.end); - } - function serializeSourceMapContents(version, file, sourceRoot, sources, names, mappings, sourcesContent) { - if (typeof JSON !== "undefined") { - var map_1 = { - version: version, - file: file, - sourceRoot: sourceRoot, - sources: sources, - names: names, - mappings: mappings - }; - if (sourcesContent !== undefined) { - map_1.sourcesContent = sourcesContent; - } - return JSON.stringify(map_1); - } - return "{\"version\":" + version + ",\"file\":\"" + ts.escapeString(file) + "\",\"sourceRoot\":\"" + ts.escapeString(sourceRoot) + "\",\"sources\":[" + serializeStringArray(sources) + "],\"names\":[" + serializeStringArray(names) + "],\"mappings\":\"" + ts.escapeString(mappings) + "\" " + (sourcesContent !== undefined ? ",\"sourcesContent\":[" + serializeStringArray(sourcesContent) + "]" : "") + "}"; - function serializeStringArray(list) { - var output = ""; - for (var i = 0, n = list.length; i < n; i++) { - if (i) { - output += ","; - } - output += "\"" + ts.escapeString(list[i]) + "\""; - } - return output; - } - } - function writeJavaScriptAndSourceMapFile(emitOutput, writeByteOrderMark) { - encodeLastRecordedSourceMapSpan(); - var sourceMapText = serializeSourceMapContents(3, sourceMapData.sourceMapFile, sourceMapData.sourceMapSourceRoot, sourceMapData.sourceMapSources, sourceMapData.sourceMapNames, sourceMapData.sourceMapMappings, sourceMapData.sourceMapSourcesContent); - sourceMapDataList.push(sourceMapData); - var sourceMapUrl; - if (compilerOptions.inlineSourceMap) { - // Encode the sourceMap into the sourceMap url - var base64SourceMapText = ts.convertToBase64(sourceMapText); - sourceMapUrl = "//# sourceMappingURL=data:application/json;base64," + base64SourceMapText; - } - else { - // Write source map file - ts.writeFile(host, diagnostics, sourceMapData.sourceMapFilePath, sourceMapText, /*writeByteOrderMark*/ false); - sourceMapUrl = "//# sourceMappingURL=" + sourceMapData.jsSourceMappingURL; - } - // Write sourcemap url to the js file and write the js file - writeJavaScriptFile(emitOutput + sourceMapUrl, writeByteOrderMark); - } - // Initialize source map data - var sourceMapJsFile = ts.getBaseFileName(ts.normalizeSlashes(jsFilePath)); - sourceMapData = { - sourceMapFilePath: jsFilePath + ".map", - jsSourceMappingURL: sourceMapJsFile + ".map", - sourceMapFile: sourceMapJsFile, - sourceMapSourceRoot: compilerOptions.sourceRoot || "", - sourceMapSources: [], - inputSourceFileNames: [], - sourceMapNames: [], - sourceMapMappings: "", - sourceMapSourcesContent: undefined, - sourceMapDecodedMappings: [] - }; - // Normalize source root and make sure it has trailing "/" so that it can be used to combine paths with the - // relative paths of the sources list in the sourcemap - sourceMapData.sourceMapSourceRoot = ts.normalizeSlashes(sourceMapData.sourceMapSourceRoot); - if (sourceMapData.sourceMapSourceRoot.length && sourceMapData.sourceMapSourceRoot.charCodeAt(sourceMapData.sourceMapSourceRoot.length - 1) !== 47 /* slash */) { - sourceMapData.sourceMapSourceRoot += ts.directorySeparator; - } - if (compilerOptions.mapRoot) { - sourceMapDir = ts.normalizeSlashes(compilerOptions.mapRoot); - if (root) { - // For modules or multiple emit files the mapRoot will have directory structure like the sources - // So if src\a.ts and src\lib\b.ts are compiled together user would be moving the maps into mapRoot\a.js.map and mapRoot\lib\b.js.map - sourceMapDir = ts.getDirectoryPath(ts.getSourceFilePathInNewDir(root, host, sourceMapDir)); - } - if (!ts.isRootedDiskPath(sourceMapDir) && !ts.isUrl(sourceMapDir)) { - // The relative paths are relative to the common directory - sourceMapDir = ts.combinePaths(host.getCommonSourceDirectory(), sourceMapDir); - sourceMapData.jsSourceMappingURL = ts.getRelativePathToDirectoryOrUrl(ts.getDirectoryPath(ts.normalizePath(jsFilePath)), // get the relative sourceMapDir path based on jsFilePath - ts.combinePaths(sourceMapDir, sourceMapData.jsSourceMappingURL), // this is where user expects to see sourceMap - host.getCurrentDirectory(), host.getCanonicalFileName, - /*isAbsolutePathAnUrl*/ true); - } - else { - sourceMapData.jsSourceMappingURL = ts.combinePaths(sourceMapDir, sourceMapData.jsSourceMappingURL); - } - } - else { - sourceMapDir = ts.getDirectoryPath(ts.normalizePath(jsFilePath)); - } - function emitNodeWithSourceMap(node) { - if (node) { - if (ts.nodeIsSynthesized(node)) { - return emitNodeWithoutSourceMap(node); - } - if (node.kind !== 248 /* SourceFile */) { - recordEmitNodeStartSpan(node); - emitNodeWithoutSourceMap(node); - recordEmitNodeEndSpan(node); - } - else { - recordNewSourceFileStart(node); - emitNodeWithoutSourceMap(node); - } - } - } - function emitNodeWithCommentsAndWithSourcemap(node) { - emitNodeConsideringCommentsOption(node, emitNodeWithSourceMap); - } - writeEmittedFiles = writeJavaScriptAndSourceMapFile; - emit = emitNodeWithCommentsAndWithSourcemap; - emitStart = recordEmitNodeStartSpan; - emitEnd = recordEmitNodeEndSpan; - emitToken = writeTextWithSpanRecord; - scopeEmitStart = recordScopeNameOfNode; - scopeEmitEnd = recordScopeNameEnd; - writeComment = writeCommentRangeWithMap; - } - function writeJavaScriptFile(emitOutput, writeByteOrderMark) { - ts.writeFile(host, diagnostics, jsFilePath, emitOutput, writeByteOrderMark); - } - // Create a temporary variable with a unique unused name. - function createTempVariable(flags) { - var result = ts.createSynthesizedNode(69 /* Identifier */); - result.text = makeTempVariableName(flags); - return result; - } - function recordTempDeclaration(name) { - if (!tempVariables) { - tempVariables = []; - } - tempVariables.push(name); - } - function createAndRecordTempVariable(flags) { - var temp = createTempVariable(flags); - recordTempDeclaration(temp); - return temp; - } - function emitTempDeclarations(newLine) { - if (tempVariables) { - if (newLine) { - writeLine(); - } - else { - write(" "); - } - write("var "); - emitCommaList(tempVariables); - write(";"); - } - } - function emitTokenText(tokenKind, startPos, emitFn) { - var tokenString = ts.tokenToString(tokenKind); - if (emitFn) { - emitFn(); - } - else { - write(tokenString); - } - return startPos + tokenString.length; - } - function emitOptional(prefix, node) { - if (node) { - write(prefix); - emit(node); - } - } - function emitParenthesizedIf(node, parenthesized) { - if (parenthesized) { - write("("); - } - emit(node); - if (parenthesized) { - write(")"); - } - } - function emitTrailingCommaIfPresent(nodeList) { - if (nodeList.hasTrailingComma) { - write(","); - } - } - function emitLinePreservingList(parent, nodes, allowTrailingComma, spacesBetweenBraces) { - ts.Debug.assert(nodes.length > 0); - increaseIndent(); - if (nodeStartPositionsAreOnSameLine(parent, nodes[0])) { - if (spacesBetweenBraces) { - write(" "); - } - } - else { - writeLine(); - } - for (var i = 0, n = nodes.length; i < n; i++) { - if (i) { - if (nodeEndIsOnSameLineAsNodeStart(nodes[i - 1], nodes[i])) { - write(", "); - } - else { - write(","); - writeLine(); - } - } - emit(nodes[i]); - } - if (nodes.hasTrailingComma && allowTrailingComma) { - write(","); - } - decreaseIndent(); - if (nodeEndPositionsAreOnSameLine(parent, ts.lastOrUndefined(nodes))) { - if (spacesBetweenBraces) { - write(" "); - } - } - else { - writeLine(); - } - } - function emitList(nodes, start, count, multiLine, trailingComma, leadingComma, noTrailingNewLine, emitNode) { - if (!emitNode) { - emitNode = emit; - } - for (var i = 0; i < count; i++) { - if (multiLine) { - if (i || leadingComma) { - write(","); - } - writeLine(); - } - else { - if (i || leadingComma) { - write(", "); - } - } - var node = nodes[start + i]; - // This emitting is to make sure we emit following comment properly - // ...(x, /*comment1*/ y)... - // ^ => node.pos - // "comment1" is not considered leading comment for "y" but rather - // considered as trailing comment of the previous node. - emitTrailingCommentsOfPosition(node.pos); - emitNode(node); - leadingComma = true; - } - if (trailingComma) { - write(","); - } - if (multiLine && !noTrailingNewLine) { - writeLine(); - } - return count; - } - function emitCommaList(nodes) { - if (nodes) { - emitList(nodes, 0, nodes.length, /*multiline*/ false, /*trailingComma*/ false); - } - } - function emitLines(nodes) { - emitLinesStartingAt(nodes, /*startIndex*/ 0); - } - function emitLinesStartingAt(nodes, startIndex) { - for (var i = startIndex; i < nodes.length; i++) { - writeLine(); - emit(nodes[i]); - } - } - function isBinaryOrOctalIntegerLiteral(node, text) { - if (node.kind === 8 /* NumericLiteral */ && text.length > 1) { - switch (text.charCodeAt(1)) { - case 98 /* b */: - case 66 /* B */: - case 111 /* o */: - case 79 /* O */: - return true; - } - } - return false; - } - function emitLiteral(node) { - var text = getLiteralText(node); - if ((compilerOptions.sourceMap || compilerOptions.inlineSourceMap) && (node.kind === 9 /* StringLiteral */ || ts.isTemplateLiteralKind(node.kind))) { - writer.writeLiteral(text); - } - else if (languageVersion < 2 /* ES6 */ && isBinaryOrOctalIntegerLiteral(node, text)) { - write(node.text); - } - else { - write(text); - } - } - function getLiteralText(node) { - // 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 */ && (ts.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 (node.parent) { - return ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, node); - } - // If we can't reach the original source text, use the canonical form if it's a number, - // or an escaped quoted form of the original text if it's string-like. - switch (node.kind) { - case 9 /* StringLiteral */: - return getQuotedEscapedLiteralText("\"", node.text, "\""); - case 11 /* NoSubstitutionTemplateLiteral */: - return getQuotedEscapedLiteralText("`", node.text, "`"); - case 12 /* TemplateHead */: - return getQuotedEscapedLiteralText("`", node.text, "${"); - case 13 /* TemplateMiddle */: - return getQuotedEscapedLiteralText("}", node.text, "${"); - case 14 /* TemplateTail */: - return getQuotedEscapedLiteralText("}", node.text, "`"); - case 8 /* NumericLiteral */: - return node.text; - } - ts.Debug.fail("Literal kind '" + node.kind + "' not accounted for."); - } - function getQuotedEscapedLiteralText(leftQuote, text, rightQuote) { - return leftQuote + ts.escapeNonAsciiCharacters(ts.escapeString(text)) + rightQuote; - } - function emitDownlevelRawTemplateLiteral(node) { - // 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"); - text = ts.escapeString(text); - write("\"" + text + "\""); - } - function emitDownlevelTaggedTemplateArray(node, literalEmitter) { - write("["); - if (node.template.kind === 11 /* NoSubstitutionTemplateLiteral */) { - literalEmitter(node.template); - } - else { - literalEmitter(node.template.head); - ts.forEach(node.template.templateSpans, function (child) { - write(", "); - literalEmitter(child.literal); - }); - } - write("]"); - } - function emitDownlevelTaggedTemplate(node) { - var tempVariable = createAndRecordTempVariable(0 /* Auto */); - write("("); - emit(tempVariable); - write(" = "); - emitDownlevelTaggedTemplateArray(node, emit); - write(", "); - emit(tempVariable); - write(".raw = "); - emitDownlevelTaggedTemplateArray(node, emitDownlevelRawTemplateLiteral); - write(", "); - emitParenthesizedIf(node.tag, needsParenthesisForPropertyAccessOrInvocation(node.tag)); - write("("); - emit(tempVariable); - // Now we emit the expressions - if (node.template.kind === 183 /* TemplateExpression */) { - ts.forEach(node.template.templateSpans, function (templateSpan) { - write(", "); - var needsParens = templateSpan.expression.kind === 181 /* BinaryExpression */ - && templateSpan.expression.operatorToken.kind === 24 /* CommaToken */; - emitParenthesizedIf(templateSpan.expression, needsParens); - }); - } - write("))"); - } - function emitTemplateExpression(node) { - // In ES6 mode and above, we can simply emit each portion of a template in order, but in - // ES3 & ES5 we must convert the template expression into a series of string concatenations. - if (languageVersion >= 2 /* ES6 */) { - ts.forEachChild(node, emit); - return; - } - var emitOuterParens = ts.isExpression(node.parent) - && templateNeedsParens(node, node.parent); - if (emitOuterParens) { - write("("); - } - var headEmitted = false; - if (shouldEmitTemplateHead()) { - emitLiteral(node.head); - headEmitted = true; - } - for (var i = 0, n = node.templateSpans.length; i < n; i++) { - var templateSpan = node.templateSpans[i]; - // Check if the expression has operands and binds its operands less closely than binary '+'. - // If it does, we need to wrap 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 needsParens = templateSpan.expression.kind !== 172 /* ParenthesizedExpression */ - && comparePrecedenceToBinaryPlus(templateSpan.expression) !== 1 /* GreaterThan */; - if (i > 0 || headEmitted) { - // If this is the first span and the head was not emitted, then this templateSpan's - // expression will be the first to be emitted. Don't emit the preceding ' + ' in that - // case. - write(" + "); - } - emitParenthesizedIf(templateSpan.expression, needsParens); - // 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 (templateSpan.literal.text.length !== 0) { - write(" + "); - emitLiteral(templateSpan.literal); - } - } - if (emitOuterParens) { - write(")"); - } - function shouldEmitTemplateHead() { - // If this expression has an empty head literal and the first template span has a non-empty - // literal, then emitting the empty head literal is not necessary. - // `${ foo } and ${ bar }` - // can be emitted as - // foo + " and " + bar - // This is because it is only required that one of the first two operands in the emit - // output must be a string literal, so that the other operand and all following operands - // are forced into strings. - // - // If the first template span has an empty literal, then the head must still be emitted. - // `${ foo }${ bar }` - // must still be emitted as - // "" + foo + bar - // 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; - } - function templateNeedsParens(template, parent) { - switch (parent.kind) { - case 168 /* CallExpression */: - case 169 /* NewExpression */: - return parent.expression === template; - case 170 /* TaggedTemplateExpression */: - case 172 /* ParenthesizedExpression */: - return false; - default: - return comparePrecedenceToBinaryPlus(parent) !== -1 /* LessThan */; - } - } - /** - * Returns whether the expression has lesser, greater, - * or equal precedence to the binary '+' operator - */ - function comparePrecedenceToBinaryPlus(expression) { - // All binary expressions have lower precedence than '+' apart from '*', '/', and '%' - // which have greater precedence and '-' which has equal precedence. - // All unary operators have a higher precedence apart from yield. - // Arrow functions and conditionals have a lower precedence, - // although we convert the former into regular function expressions in ES5 mode, - // and in ES6 mode this function won't get called anyway. - // - // TODO (drosen): Note that we need to account for the upcoming 'yield' and - // spread ('...') unary operators that are anticipated for ES6. - switch (expression.kind) { - case 181 /* BinaryExpression */: - switch (expression.operatorToken.kind) { - case 37 /* AsteriskToken */: - case 39 /* SlashToken */: - case 40 /* PercentToken */: - return 1 /* GreaterThan */; - case 35 /* PlusToken */: - case 36 /* MinusToken */: - return 0 /* EqualTo */; - default: - return -1 /* LessThan */; - } - case 184 /* YieldExpression */: - case 182 /* ConditionalExpression */: - return -1 /* LessThan */; - default: - return 1 /* GreaterThan */; - } - } - } - function emitTemplateSpan(span) { - emit(span.expression); - emit(span.literal); - } - function jsxEmitReact(node) { - /// Emit a tag name, which is either '"div"' for lower-cased names, or - /// 'Div' for upper-cased or dotted names - function emitTagName(name) { - if (name.kind === 69 /* Identifier */ && ts.isIntrinsicJsxName(name.text)) { - write("\""); - emit(name); - write("\""); - } - else { - emit(name); - } - } - /// Emit an attribute name, which is quoted if it needs to be quoted. Because - /// these emit into an object literal property name, we don't need to be worried - /// about keywords, just non-identifier characters - function emitAttributeName(name) { - if (/[A-Za-z_]+[\w*]/.test(name.text)) { - write("\""); - emit(name); - write("\""); - } - else { - emit(name); - } - } - /// Emit an name/value pair for an attribute (e.g. "x: 3") - function emitJsxAttribute(node) { - emitAttributeName(node.name); - write(": "); - if (node.initializer) { - emit(node.initializer); - } - else { - write("true"); - } - } - function emitJsxElement(openingNode, children) { - var syntheticReactRef = ts.createSynthesizedNode(69 /* Identifier */); - syntheticReactRef.text = "React"; - syntheticReactRef.parent = openingNode; - // Call React.createElement(tag, ... - emitLeadingComments(openingNode); - emitExpressionIdentifier(syntheticReactRef); - write(".createElement("); - emitTagName(openingNode.tagName); - write(", "); - // Attribute list - if (openingNode.attributes.length === 0) { - // When there are no attributes, React wants "null" - write("null"); - } - else { - // Either emit one big object literal (no spread attribs), or - // a call to React.__spread - var attrs = openingNode.attributes; - if (ts.forEach(attrs, function (attr) { return attr.kind === 239 /* JsxSpreadAttribute */; })) { - emitExpressionIdentifier(syntheticReactRef); - write(".__spread("); - var haveOpenedObjectLiteral = false; - for (var i_1 = 0; i_1 < attrs.length; i_1++) { - if (attrs[i_1].kind === 239 /* JsxSpreadAttribute */) { - // If this is the first argument, we need to emit a {} as the first argument - if (i_1 === 0) { - write("{}, "); - } - if (haveOpenedObjectLiteral) { - write("}"); - haveOpenedObjectLiteral = false; - } - if (i_1 > 0) { - write(", "); - } - emit(attrs[i_1].expression); - } - else { - ts.Debug.assert(attrs[i_1].kind === 238 /* JsxAttribute */); - if (haveOpenedObjectLiteral) { - write(", "); - } - else { - haveOpenedObjectLiteral = true; - if (i_1 > 0) { - write(", "); - } - write("{"); - } - emitJsxAttribute(attrs[i_1]); - } - } - if (haveOpenedObjectLiteral) - write("}"); - write(")"); // closing paren to React.__spread( - } - else { - // One object literal with all the attributes in them - write("{"); - for (var i = 0; i < attrs.length; i++) { - if (i > 0) { - write(", "); - } - emitJsxAttribute(attrs[i]); - } - write("}"); - } - } - // Children - if (children) { - for (var i = 0; i < children.length; i++) { - // Don't emit empty expressions - if (children[i].kind === 240 /* JsxExpression */ && !(children[i].expression)) { - continue; - } - // Don't emit empty strings - if (children[i].kind === 236 /* JsxText */) { - var text = getTextToEmit(children[i]); - if (text !== undefined) { - write(", \""); - write(text); - write("\""); - } - } - else { - write(", "); - emit(children[i]); - } - } - } - // Closing paren - write(")"); // closes "React.createElement(" - emitTrailingComments(openingNode); - } - if (node.kind === 233 /* JsxElement */) { - emitJsxElement(node.openingElement, node.children); - } - else { - ts.Debug.assert(node.kind === 234 /* JsxSelfClosingElement */); - emitJsxElement(node); - } - } - function jsxEmitPreserve(node) { - function emitJsxAttribute(node) { - emit(node.name); - if (node.initializer) { - write("="); - emit(node.initializer); - } - } - function emitJsxSpreadAttribute(node) { - write("{..."); - emit(node.expression); - write("}"); - } - function emitAttributes(attribs) { - for (var i = 0, n = attribs.length; i < n; i++) { - if (i > 0) { - write(" "); - } - if (attribs[i].kind === 239 /* JsxSpreadAttribute */) { - emitJsxSpreadAttribute(attribs[i]); - } - else { - ts.Debug.assert(attribs[i].kind === 238 /* JsxAttribute */); - emitJsxAttribute(attribs[i]); - } - } - } - function emitJsxOpeningOrSelfClosingElement(node) { - write("<"); - emit(node.tagName); - if (node.attributes.length > 0 || (node.kind === 234 /* JsxSelfClosingElement */)) { - write(" "); - } - emitAttributes(node.attributes); - if (node.kind === 234 /* JsxSelfClosingElement */) { - write("/>"); - } - else { - write(">"); - } - } - function emitJsxClosingElement(node) { - write(""); - } - function emitJsxElement(node) { - emitJsxOpeningOrSelfClosingElement(node.openingElement); - for (var i = 0, n = node.children.length; i < n; i++) { - emit(node.children[i]); - } - emitJsxClosingElement(node.closingElement); - } - if (node.kind === 233 /* JsxElement */) { - emitJsxElement(node); - } - else { - ts.Debug.assert(node.kind === 234 /* JsxSelfClosingElement */); - emitJsxOpeningOrSelfClosingElement(node); - } - } - // This function specifically handles numeric/string literals for enum and accessor 'identifiers'. - // In a sense, it does not actually emit identifiers as much as it declares a name for a specific property. - // For example, this is utilized when feeding in a result to Object.defineProperty. - function emitExpressionForPropertyName(node) { - ts.Debug.assert(node.kind !== 163 /* BindingElement */); - if (node.kind === 9 /* StringLiteral */) { - emitLiteral(node); - } - else if (node.kind === 136 /* ComputedPropertyName */) { - // if this is a decorated computed property, we will need to capture the result - // of the property expression so that we can apply decorators later. This is to ensure - // we don't introduce unintended side effects: - // - // class C { - // [_a = x]() { } - // } - // - // The emit for the decorated computed property decorator is: - // - // __decorate([dec], C.prototype, _a, Object.getOwnPropertyDescriptor(C.prototype, _a)); - // - if (ts.nodeIsDecorated(node.parent)) { - if (!computedPropertyNamesToGeneratedNames) { - computedPropertyNamesToGeneratedNames = []; - } - var generatedName = computedPropertyNamesToGeneratedNames[ts.getNodeId(node)]; - if (generatedName) { - // we have already generated a variable for this node, write that value instead. - write(generatedName); - return; - } - generatedName = createAndRecordTempVariable(0 /* Auto */).text; - computedPropertyNamesToGeneratedNames[ts.getNodeId(node)] = generatedName; - write(generatedName); - write(" = "); - } - emit(node.expression); - } - else { - write("\""); - if (node.kind === 8 /* NumericLiteral */) { - write(node.text); - } - else { - writeTextOfNode(currentSourceFile, node); - } - write("\""); - } - } - function isExpressionIdentifier(node) { - var parent = node.parent; - switch (parent.kind) { - case 164 /* ArrayLiteralExpression */: - case 189 /* AsExpression */: - case 181 /* BinaryExpression */: - case 168 /* CallExpression */: - case 241 /* CaseClause */: - case 136 /* ComputedPropertyName */: - case 182 /* ConditionalExpression */: - case 139 /* Decorator */: - case 175 /* DeleteExpression */: - case 197 /* DoStatement */: - case 167 /* ElementAccessExpression */: - case 227 /* ExportAssignment */: - case 195 /* ExpressionStatement */: - case 188 /* ExpressionWithTypeArguments */: - case 199 /* ForStatement */: - case 200 /* ForInStatement */: - case 201 /* ForOfStatement */: - case 196 /* IfStatement */: - case 234 /* JsxSelfClosingElement */: - case 235 /* JsxOpeningElement */: - case 239 /* JsxSpreadAttribute */: - case 240 /* JsxExpression */: - case 169 /* NewExpression */: - case 172 /* ParenthesizedExpression */: - case 180 /* PostfixUnaryExpression */: - case 179 /* PrefixUnaryExpression */: - case 204 /* ReturnStatement */: - case 246 /* ShorthandPropertyAssignment */: - case 185 /* SpreadElementExpression */: - case 206 /* SwitchStatement */: - case 170 /* TaggedTemplateExpression */: - case 190 /* TemplateSpan */: - case 208 /* ThrowStatement */: - case 171 /* TypeAssertionExpression */: - case 176 /* TypeOfExpression */: - case 177 /* VoidExpression */: - case 198 /* WhileStatement */: - case 205 /* WithStatement */: - case 184 /* YieldExpression */: - return true; - case 163 /* BindingElement */: - case 247 /* EnumMember */: - case 138 /* Parameter */: - case 245 /* PropertyAssignment */: - case 141 /* PropertyDeclaration */: - case 211 /* VariableDeclaration */: - return parent.initializer === node; - case 166 /* PropertyAccessExpression */: - return parent.expression === node; - case 174 /* ArrowFunction */: - case 173 /* FunctionExpression */: - return parent.body === node; - case 221 /* ImportEqualsDeclaration */: - return parent.moduleReference === node; - case 135 /* QualifiedName */: - return parent.left === node; - } - return false; - } - function emitExpressionIdentifier(node) { - if (resolver.getNodeCheckFlags(node) & 2048 /* LexicalArguments */) { - write("_arguments"); - return; - } - var container = resolver.getReferencedExportContainer(node); - if (container) { - if (container.kind === 248 /* SourceFile */) { - // Identifier references module export - if (modulekind !== 5 /* ES6 */ && modulekind !== 4 /* System */) { - write("exports."); - } - } - else { - // Identifier references namespace export - write(getGeneratedNameForNode(container)); - write("."); - } - } - else { - if (modulekind !== 5 /* ES6 */) { - var declaration = resolver.getReferencedImportDeclaration(node); - if (declaration) { - if (declaration.kind === 223 /* ImportClause */) { - // Identifier references default import - write(getGeneratedNameForNode(declaration.parent)); - write(languageVersion === 0 /* ES3 */ ? "[\"default\"]" : ".default"); - return; - } - else if (declaration.kind === 226 /* ImportSpecifier */) { - // Identifier references named import - write(getGeneratedNameForNode(declaration.parent.parent.parent)); - var name_23 = declaration.propertyName || declaration.name; - var identifier = ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, name_23); - if (languageVersion === 0 /* ES3 */ && identifier === "default") { - write("[\"default\"]"); - } - else { - write("."); - write(identifier); - } - return; - } - } - } - if (languageVersion !== 2 /* ES6 */) { - var declaration = resolver.getReferencedNestedRedeclaration(node); - if (declaration) { - write(getGeneratedNameForNode(declaration.name)); - return; - } - } - } - if (ts.nodeIsSynthesized(node)) { - write(node.text); - } - else { - writeTextOfNode(currentSourceFile, node); - } - } - function isNameOfNestedRedeclaration(node) { - if (languageVersion < 2 /* ES6 */) { - var parent_6 = node.parent; - switch (parent_6.kind) { - case 163 /* BindingElement */: - case 214 /* ClassDeclaration */: - case 217 /* EnumDeclaration */: - case 211 /* VariableDeclaration */: - return parent_6.name === node && resolver.isNestedRedeclaration(parent_6); - } - } - return false; - } - function emitIdentifier(node) { - if (!node.parent) { - write(node.text); - } - else if (isExpressionIdentifier(node)) { - emitExpressionIdentifier(node); - } - else if (isNameOfNestedRedeclaration(node)) { - write(getGeneratedNameForNode(node)); - } - else if (ts.nodeIsSynthesized(node)) { - write(node.text); - } - else { - writeTextOfNode(currentSourceFile, node); - } - } - function emitThis(node) { - if (resolver.getNodeCheckFlags(node) & 2 /* LexicalThis */) { - write("_this"); - } - else { - write("this"); - } - } - function emitSuper(node) { - if (languageVersion >= 2 /* ES6 */) { - write("super"); - } - else { - var flags = resolver.getNodeCheckFlags(node); - if (flags & 256 /* SuperInstance */) { - write("_super.prototype"); - } - else { - write("_super"); - } - } - } - function emitObjectBindingPattern(node) { - write("{ "); - var elements = node.elements; - emitList(elements, 0, elements.length, /*multiLine*/ false, /*trailingComma*/ elements.hasTrailingComma); - write(" }"); - } - function emitArrayBindingPattern(node) { - write("["); - var elements = node.elements; - emitList(elements, 0, elements.length, /*multiLine*/ false, /*trailingComma*/ elements.hasTrailingComma); - write("]"); - } - function emitBindingElement(node) { - if (node.propertyName) { - emit(node.propertyName); - write(": "); - } - if (node.dotDotDotToken) { - write("..."); - } - if (ts.isBindingPattern(node.name)) { - emit(node.name); - } - else { - emitModuleMemberName(node); - } - emitOptional(" = ", node.initializer); - } - function emitSpreadElementExpression(node) { - write("..."); - emit(node.expression); - } - function emitYieldExpression(node) { - write(ts.tokenToString(114 /* YieldKeyword */)); - if (node.asteriskToken) { - write("*"); - } - if (node.expression) { - write(" "); - emit(node.expression); - } - } - function emitAwaitExpression(node) { - var needsParenthesis = needsParenthesisForAwaitExpressionAsYield(node); - if (needsParenthesis) { - write("("); - } - write(ts.tokenToString(114 /* YieldKeyword */)); - write(" "); - emit(node.expression); - if (needsParenthesis) { - write(")"); - } - } - function needsParenthesisForAwaitExpressionAsYield(node) { - if (node.parent.kind === 181 /* BinaryExpression */ && !ts.isAssignmentOperator(node.parent.operatorToken.kind)) { - return true; - } - else if (node.parent.kind === 182 /* ConditionalExpression */ && node.parent.condition === node) { - return true; - } - return false; - } - function needsParenthesisForPropertyAccessOrInvocation(node) { - switch (node.kind) { - case 69 /* Identifier */: - case 164 /* ArrayLiteralExpression */: - case 166 /* PropertyAccessExpression */: - case 167 /* ElementAccessExpression */: - case 168 /* CallExpression */: - case 172 /* ParenthesizedExpression */: - // This list is not exhaustive and only includes those cases that are relevant - // to the check in emitArrayLiteral. More cases can be added as needed. - return false; - } - return true; - } - function emitListWithSpread(elements, needsUniqueCopy, multiLine, trailingComma, useConcat) { - var pos = 0; - var group = 0; - var length = elements.length; - while (pos < length) { - // Emit using the pattern .concat(, , ...) - if (group === 1 && useConcat) { - write(".concat("); - } - else if (group > 0) { - write(", "); - } - var e = elements[pos]; - if (e.kind === 185 /* SpreadElementExpression */) { - e = e.expression; - emitParenthesizedIf(e, /*parenthesized*/ group === 0 && needsParenthesisForPropertyAccessOrInvocation(e)); - pos++; - if (pos === length && group === 0 && needsUniqueCopy && e.kind !== 164 /* ArrayLiteralExpression */) { - write(".slice()"); - } - } - else { - var i = pos; - while (i < length && elements[i].kind !== 185 /* SpreadElementExpression */) { - i++; - } - write("["); - if (multiLine) { - increaseIndent(); - } - emitList(elements, pos, i - pos, multiLine, trailingComma && i === length); - if (multiLine) { - decreaseIndent(); - } - write("]"); - pos = i; - } - group++; - } - if (group > 1) { - if (useConcat) { - write(")"); - } - } - } - function isSpreadElementExpression(node) { - return node.kind === 185 /* SpreadElementExpression */; - } - function emitArrayLiteral(node) { - var elements = node.elements; - if (elements.length === 0) { - write("[]"); - } - else if (languageVersion >= 2 /* ES6 */ || !ts.forEach(elements, isSpreadElementExpression)) { - write("["); - emitLinePreservingList(node, node.elements, elements.hasTrailingComma, /*spacesBetweenBraces:*/ false); - write("]"); - } - else { - emitListWithSpread(elements, /*needsUniqueCopy*/ true, /*multiLine*/ (node.flags & 2048 /* MultiLine */) !== 0, - /*trailingComma*/ elements.hasTrailingComma, /*useConcat*/ true); - } - } - function emitObjectLiteralBody(node, numElements) { - if (numElements === 0) { - write("{}"); - return; - } - write("{"); - if (numElements > 0) { - var properties = node.properties; - // If we are not doing a downlevel transformation for object literals, - // then try to preserve the original shape of the object literal. - // Otherwise just try to preserve the formatting. - if (numElements === properties.length) { - emitLinePreservingList(node, properties, /* allowTrailingComma */ languageVersion >= 1 /* ES5 */, /* spacesBetweenBraces */ true); - } - else { - var multiLine = (node.flags & 2048 /* MultiLine */) !== 0; - if (!multiLine) { - write(" "); - } - else { - increaseIndent(); - } - emitList(properties, 0, numElements, /*multiLine*/ multiLine, /*trailingComma*/ false); - if (!multiLine) { - write(" "); - } - else { - decreaseIndent(); - } - } - } - write("}"); - } - function emitDownlevelObjectLiteralWithComputedProperties(node, firstComputedPropertyIndex) { - var multiLine = (node.flags & 2048 /* MultiLine */) !== 0; - var properties = node.properties; - write("("); - if (multiLine) { - increaseIndent(); - } - // 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 tempVar = createAndRecordTempVariable(0 /* Auto */); - // Write out the first non-computed properties - // (or all properties if none of them are computed), - // then emit the rest through indexing on the temp variable. - emit(tempVar); - write(" = "); - emitObjectLiteralBody(node, firstComputedPropertyIndex); - for (var i = firstComputedPropertyIndex, n = properties.length; i < n; i++) { - writeComma(); - var property = properties[i]; - emitStart(property); - if (property.kind === 145 /* GetAccessor */ || property.kind === 146 /* SetAccessor */) { - // TODO (drosen): Reconcile with 'emitMemberFunctions'. - var accessors = ts.getAllAccessorDeclarations(node.properties, property); - if (property !== accessors.firstAccessor) { - continue; - } - write("Object.defineProperty("); - emit(tempVar); - write(", "); - emitStart(node.name); - emitExpressionForPropertyName(property.name); - emitEnd(property.name); - write(", {"); - increaseIndent(); - if (accessors.getAccessor) { - writeLine(); - emitLeadingComments(accessors.getAccessor); - write("get: "); - emitStart(accessors.getAccessor); - write("function "); - emitSignatureAndBody(accessors.getAccessor); - emitEnd(accessors.getAccessor); - emitTrailingComments(accessors.getAccessor); - write(","); - } - if (accessors.setAccessor) { - writeLine(); - emitLeadingComments(accessors.setAccessor); - write("set: "); - emitStart(accessors.setAccessor); - write("function "); - emitSignatureAndBody(accessors.setAccessor); - emitEnd(accessors.setAccessor); - emitTrailingComments(accessors.setAccessor); - write(","); - } - writeLine(); - write("enumerable: true,"); - writeLine(); - write("configurable: true"); - decreaseIndent(); - writeLine(); - write("})"); - emitEnd(property); - } - else { - emitLeadingComments(property); - emitStart(property.name); - emit(tempVar); - emitMemberAccessForPropertyName(property.name); - emitEnd(property.name); - write(" = "); - if (property.kind === 245 /* PropertyAssignment */) { - emit(property.initializer); - } - else if (property.kind === 246 /* ShorthandPropertyAssignment */) { - emitExpressionIdentifier(property.name); - } - else if (property.kind === 143 /* MethodDeclaration */) { - emitFunctionDeclaration(property); - } - else { - ts.Debug.fail("ObjectLiteralElement type not accounted for: " + property.kind); - } - } - emitEnd(property); - } - writeComma(); - emit(tempVar); - if (multiLine) { - decreaseIndent(); - writeLine(); - } - write(")"); - function writeComma() { - if (multiLine) { - write(","); - writeLine(); - } - else { - write(", "); - } - } - } - function emitObjectLiteral(node) { - var properties = node.properties; - if (languageVersion < 2 /* ES6 */) { - var numProperties = properties.length; - // Find the first computed property. - // Everything until that point can be emitted as part of the initial object literal. - var numInitialNonComputedProperties = numProperties; - for (var i = 0, n = properties.length; i < n; i++) { - if (properties[i].name.kind === 136 /* ComputedPropertyName */) { - numInitialNonComputedProperties = i; - break; - } - } - var hasComputedProperty = numInitialNonComputedProperties !== properties.length; - if (hasComputedProperty) { - emitDownlevelObjectLiteralWithComputedProperties(node, numInitialNonComputedProperties); - return; - } - } - // Ordinary case: either the object has no computed properties - // or we're compiling with an ES6+ target. - emitObjectLiteralBody(node, properties.length); - } - function createBinaryExpression(left, operator, right, startsOnNewLine) { - var result = ts.createSynthesizedNode(181 /* BinaryExpression */, startsOnNewLine); - result.operatorToken = ts.createSynthesizedNode(operator); - result.left = left; - result.right = right; - return result; - } - function createPropertyAccessExpression(expression, name) { - var result = ts.createSynthesizedNode(166 /* PropertyAccessExpression */); - result.expression = parenthesizeForAccess(expression); - result.dotToken = ts.createSynthesizedNode(21 /* DotToken */); - result.name = name; - return result; - } - function createElementAccessExpression(expression, argumentExpression) { - var result = ts.createSynthesizedNode(167 /* ElementAccessExpression */); - result.expression = parenthesizeForAccess(expression); - result.argumentExpression = argumentExpression; - return result; - } - function parenthesizeForAccess(expr) { - // When diagnosing whether the expression needs parentheses, the decision should be based - // on the innermost expression in a chain of nested type assertions. - while (expr.kind === 171 /* TypeAssertionExpression */ || expr.kind === 189 /* AsExpression */) { - expr = expr.expression; - } - // isLeftHandSideExpression is almost the correct criterion for when it is not necessary - // to parenthesize the expression before a dot. The known exceptions are: - // - // NewExpression: - // new C.x -> not the same as (new C).x - // NumberLiteral - // 1.x -> not the same as (1).x - // - if (ts.isLeftHandSideExpression(expr) && - expr.kind !== 169 /* NewExpression */ && - expr.kind !== 8 /* NumericLiteral */) { - return expr; - } - var node = ts.createSynthesizedNode(172 /* ParenthesizedExpression */); - node.expression = expr; - return node; - } - function emitComputedPropertyName(node) { - write("["); - emitExpressionForPropertyName(node); - write("]"); - } - function emitMethod(node) { - if (languageVersion >= 2 /* ES6 */ && node.asteriskToken) { - write("*"); - } - emit(node.name); - if (languageVersion < 2 /* ES6 */) { - write(": function "); - } - emitSignatureAndBody(node); - } - function emitPropertyAssignment(node) { - emit(node.name); - write(": "); - // This is to ensure that we emit comment in the following case: - // For example: - // obj = { - // id: /*comment1*/ ()=>void - // } - // "comment1" is not considered to be leading comment for node.initializer - // but rather a trailing comment on the previous node. - emitTrailingCommentsOfPosition(node.initializer.pos); - emit(node.initializer); - } - // Return true if identifier resolves to an exported member of a namespace - function isNamespaceExportReference(node) { - var container = resolver.getReferencedExportContainer(node); - return container && container.kind !== 248 /* SourceFile */; - } - function emitShorthandPropertyAssignment(node) { - // The name property of a short-hand property assignment is considered an expression position, so here - // we manually emit the identifier to avoid rewriting. - writeTextOfNode(currentSourceFile, node.name); - // If emitting pre-ES6 code, or if the name requires rewriting when resolved as an expression identifier, - // we emit a normal property assignment. For example: - // module m { - // export let y; - // } - // module m { - // let obj = { y }; - // } - // Here we need to emit obj = { y : m.y } regardless of the output target. - if (languageVersion < 2 /* ES6 */ || isNamespaceExportReference(node.name)) { - // Emit identifier as an identifier - write(": "); - emit(node.name); - } - if (languageVersion >= 2 /* ES6 */ && node.objectAssignmentInitializer) { - write(" = "); - emit(node.objectAssignmentInitializer); - } - } - function tryEmitConstantValue(node) { - var constantValue = tryGetConstEnumValue(node); - if (constantValue !== undefined) { - write(constantValue.toString()); - if (!compilerOptions.removeComments) { - var propertyName = node.kind === 166 /* PropertyAccessExpression */ ? ts.declarationNameToString(node.name) : ts.getTextOfNode(node.argumentExpression); - write(" /* " + propertyName + " */"); - } - return true; - } - return false; - } - function tryGetConstEnumValue(node) { - if (compilerOptions.isolatedModules) { - return undefined; - } - return node.kind === 166 /* PropertyAccessExpression */ || node.kind === 167 /* ElementAccessExpression */ - ? resolver.getConstantValue(node) - : undefined; - } - // Returns 'true' if the code was actually indented, false otherwise. - // If the code is not indented, an optional valueToWriteWhenNotIndenting will be - // emitted instead. - function indentIfOnDifferentLines(parent, node1, node2, valueToWriteWhenNotIndenting) { - var realNodesAreOnDifferentLines = !ts.nodeIsSynthesized(parent) && !nodeEndIsOnSameLineAsNodeStart(node1, node2); - // Always use a newline for synthesized code if the synthesizer desires it. - var synthesizedNodeIsOnDifferentLine = synthesizedNodeStartsOnNewLine(node2); - if (realNodesAreOnDifferentLines || synthesizedNodeIsOnDifferentLine) { - increaseIndent(); - writeLine(); - return true; - } - else { - if (valueToWriteWhenNotIndenting) { - write(valueToWriteWhenNotIndenting); - } - return false; - } - } - function emitPropertyAccess(node) { - if (tryEmitConstantValue(node)) { - return; - } - emit(node.expression); - var indentedBeforeDot = indentIfOnDifferentLines(node, node.expression, node.dotToken); - // 1 .toString is a valid property access, emit a space after the literal - // Also emit a space if expression is a integer const enum value - it will appear in generated code as numeric literal - var shouldEmitSpace; - if (!indentedBeforeDot) { - if (node.expression.kind === 8 /* NumericLiteral */) { - // check if numeric literal was originally written with a dot - var text = ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, node.expression); - shouldEmitSpace = text.indexOf(ts.tokenToString(21 /* DotToken */)) < 0; - } - else { - // check if constant enum value is integer - var constantValue = tryGetConstEnumValue(node.expression); - // isFinite handles cases when constantValue is undefined - shouldEmitSpace = isFinite(constantValue) && Math.floor(constantValue) === constantValue; - } - } - if (shouldEmitSpace) { - write(" ."); - } - else { - write("."); - } - var indentedAfterDot = indentIfOnDifferentLines(node, node.dotToken, node.name); - emit(node.name); - decreaseIndentIf(indentedBeforeDot, indentedAfterDot); - } - function emitQualifiedName(node) { - emit(node.left); - write("."); - emit(node.right); - } - function emitQualifiedNameAsExpression(node, useFallback) { - if (node.left.kind === 69 /* Identifier */) { - emitEntityNameAsExpression(node.left, useFallback); - } - else if (useFallback) { - var temp = createAndRecordTempVariable(0 /* Auto */); - write("("); - emitNodeWithoutSourceMap(temp); - write(" = "); - emitEntityNameAsExpression(node.left, /*useFallback*/ true); - write(") && "); - emitNodeWithoutSourceMap(temp); - } - else { - emitEntityNameAsExpression(node.left, /*useFallback*/ false); - } - write("."); - emit(node.right); - } - function emitEntityNameAsExpression(node, useFallback) { - switch (node.kind) { - case 69 /* Identifier */: - if (useFallback) { - write("typeof "); - emitExpressionIdentifier(node); - write(" !== 'undefined' && "); - } - emitExpressionIdentifier(node); - break; - case 135 /* QualifiedName */: - emitQualifiedNameAsExpression(node, useFallback); - break; - } - } - function emitIndexedAccess(node) { - if (tryEmitConstantValue(node)) { - return; - } - emit(node.expression); - write("["); - emit(node.argumentExpression); - write("]"); - } - function hasSpreadElement(elements) { - return ts.forEach(elements, function (e) { return e.kind === 185 /* SpreadElementExpression */; }); - } - function skipParentheses(node) { - while (node.kind === 172 /* ParenthesizedExpression */ || node.kind === 171 /* TypeAssertionExpression */ || node.kind === 189 /* AsExpression */) { - node = node.expression; - } - return node; - } - function emitCallTarget(node) { - if (node.kind === 69 /* Identifier */ || node.kind === 97 /* ThisKeyword */ || node.kind === 95 /* SuperKeyword */) { - emit(node); - return node; - } - var temp = createAndRecordTempVariable(0 /* Auto */); - write("("); - emit(temp); - write(" = "); - emit(node); - write(")"); - return temp; - } - function emitCallWithSpread(node) { - var target; - var expr = skipParentheses(node.expression); - if (expr.kind === 166 /* PropertyAccessExpression */) { - // Target will be emitted as "this" argument - target = emitCallTarget(expr.expression); - write("."); - emit(expr.name); - } - else if (expr.kind === 167 /* ElementAccessExpression */) { - // Target will be emitted as "this" argument - target = emitCallTarget(expr.expression); - write("["); - emit(expr.argumentExpression); - write("]"); - } - else if (expr.kind === 95 /* SuperKeyword */) { - target = expr; - write("_super"); - } - else { - emit(node.expression); - } - write(".apply("); - if (target) { - if (target.kind === 95 /* SuperKeyword */) { - // Calls of form super(...) and super.foo(...) - emitThis(target); - } - else { - // Calls of form obj.foo(...) - emit(target); - } - } - else { - // Calls of form foo(...) - write("void 0"); - } - write(", "); - emitListWithSpread(node.arguments, /*needsUniqueCopy*/ false, /*multiLine*/ false, /*trailingComma*/ false, /*useConcat*/ true); - write(")"); - } - function emitCallExpression(node) { - if (languageVersion < 2 /* ES6 */ && hasSpreadElement(node.arguments)) { - emitCallWithSpread(node); - return; - } - var superCall = false; - if (node.expression.kind === 95 /* SuperKeyword */) { - emitSuper(node.expression); - superCall = true; - } - else { - emit(node.expression); - superCall = node.expression.kind === 166 /* PropertyAccessExpression */ && node.expression.expression.kind === 95 /* SuperKeyword */; - } - if (superCall && languageVersion < 2 /* ES6 */) { - write(".call("); - emitThis(node.expression); - if (node.arguments.length) { - write(", "); - emitCommaList(node.arguments); - } - write(")"); - } - else { - write("("); - emitCommaList(node.arguments); - write(")"); - } - } - function emitNewExpression(node) { - write("new "); - // Spread operator logic is supported in new expressions in ES5 using a combination - // of Function.prototype.bind() and Function.prototype.apply(). - // - // Example: - // - // var args = [1, 2, 3, 4, 5]; - // new Array(...args); - // - // is compiled into the following ES5: - // - // var args = [1, 2, 3, 4, 5]; - // new (Array.bind.apply(Array, [void 0].concat(args))); - // - // The 'thisArg' to 'bind' is ignored when invoking the result of 'bind' with 'new', - // Thus, we set it to undefined ('void 0'). - if (languageVersion === 1 /* ES5 */ && - node.arguments && - hasSpreadElement(node.arguments)) { - write("("); - var target = emitCallTarget(node.expression); - write(".bind.apply("); - emit(target); - write(", [void 0].concat("); - emitListWithSpread(node.arguments, /*needsUniqueCopy*/ false, /*multiline*/ false, /*trailingComma*/ false, /*useConcat*/ false); - write(")))"); - write("()"); - } - else { - emit(node.expression); - if (node.arguments) { - write("("); - emitCommaList(node.arguments); - write(")"); - } - } - } - function emitTaggedTemplateExpression(node) { - if (languageVersion >= 2 /* ES6 */) { - emit(node.tag); - write(" "); - emit(node.template); - } - else { - emitDownlevelTaggedTemplate(node); - } - } - function emitParenExpression(node) { - // If the node is synthesized, it means the emitter put the parentheses there, - // not the user. If we didn't want them, the emitter would not have put them - // there. - if (!ts.nodeIsSynthesized(node) && node.parent.kind !== 174 /* ArrowFunction */) { - if (node.expression.kind === 171 /* TypeAssertionExpression */ || node.expression.kind === 189 /* AsExpression */) { - var operand = node.expression.expression; - // Make sure we consider all nested cast expressions, e.g.: - // (-A).x; - while (operand.kind === 171 /* TypeAssertionExpression */ || operand.kind === 189 /* AsExpression */) { - operand = operand.expression; - } - // We have an expression of the form: (SubExpr) - // Emitting this as (SubExpr) is really not desirable. We would like to emit the subexpr as is. - // Omitting the parentheses, however, could cause change in the semantics of the generated - // code if the casted expression has a lower precedence than the rest of the expression, e.g.: - // (new A).foo should be emitted as (new A).foo and not new A.foo - // (typeof A).toString() should be emitted as (typeof A).toString() and not typeof A.toString() - // new (A()) should be emitted as new (A()) and not new A() - // (function foo() { })() should be emitted as an IIF (function foo(){})() and not declaration function foo(){} () - if (operand.kind !== 179 /* PrefixUnaryExpression */ && - operand.kind !== 177 /* VoidExpression */ && - operand.kind !== 176 /* TypeOfExpression */ && - operand.kind !== 175 /* DeleteExpression */ && - operand.kind !== 180 /* PostfixUnaryExpression */ && - operand.kind !== 169 /* NewExpression */ && - !(operand.kind === 168 /* CallExpression */ && node.parent.kind === 169 /* NewExpression */) && - !(operand.kind === 173 /* FunctionExpression */ && node.parent.kind === 168 /* CallExpression */) && - !(operand.kind === 8 /* NumericLiteral */ && node.parent.kind === 166 /* PropertyAccessExpression */)) { - emit(operand); - return; - } - } - } - write("("); - emit(node.expression); - write(")"); - } - function emitDeleteExpression(node) { - write(ts.tokenToString(78 /* DeleteKeyword */)); - write(" "); - emit(node.expression); - } - function emitVoidExpression(node) { - write(ts.tokenToString(103 /* VoidKeyword */)); - write(" "); - emit(node.expression); - } - function emitTypeOfExpression(node) { - write(ts.tokenToString(101 /* TypeOfKeyword */)); - write(" "); - emit(node.expression); - } - function isNameOfExportedSourceLevelDeclarationInSystemExternalModule(node) { - if (!isCurrentFileSystemExternalModule() || node.kind !== 69 /* Identifier */ || ts.nodeIsSynthesized(node)) { - return false; - } - var isVariableDeclarationOrBindingElement = node.parent && (node.parent.kind === 211 /* VariableDeclaration */ || node.parent.kind === 163 /* BindingElement */); - var targetDeclaration = isVariableDeclarationOrBindingElement - ? node.parent - : resolver.getReferencedValueDeclaration(node); - return isSourceFileLevelDeclarationInSystemJsModule(targetDeclaration, /*isExported*/ true); - } - function emitPrefixUnaryExpression(node) { - var exportChanged = isNameOfExportedSourceLevelDeclarationInSystemExternalModule(node.operand); - if (exportChanged) { - // emit - // ++x - // as - // exports('x', ++x) - write(exportFunctionForFile + "(\""); - emitNodeWithoutSourceMap(node.operand); - write("\", "); - } - write(ts.tokenToString(node.operator)); - // In some cases, we need to emit a space between the operator and the operand. One obvious case - // is when the operator is an identifier, like delete or typeof. We also need to do this for plus - // and minus expressions in certain cases. Specifically, consider the following two cases (parens - // are just for clarity of exposition, and not part of the source code): - // - // (+(+1)) - // (+(++1)) - // - // We need to emit a space in both cases. In the first case, the absence of a space will make - // the resulting expression a prefix increment operation. And in the second, it will make the resulting - // expression a prefix increment whose operand is a plus expression - (++(+x)) - // The same is true of minus of course. - if (node.operand.kind === 179 /* PrefixUnaryExpression */) { - var operand = node.operand; - if (node.operator === 35 /* PlusToken */ && (operand.operator === 35 /* PlusToken */ || operand.operator === 41 /* PlusPlusToken */)) { - write(" "); - } - else if (node.operator === 36 /* MinusToken */ && (operand.operator === 36 /* MinusToken */ || operand.operator === 42 /* MinusMinusToken */)) { - write(" "); - } - } - emit(node.operand); - if (exportChanged) { - write(")"); - } - } - function emitPostfixUnaryExpression(node) { - var exportChanged = isNameOfExportedSourceLevelDeclarationInSystemExternalModule(node.operand); - if (exportChanged) { - // 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)' - write("(" + exportFunctionForFile + "(\""); - emitNodeWithoutSourceMap(node.operand); - write("\", "); - write(ts.tokenToString(node.operator)); - emit(node.operand); - if (node.operator === 41 /* PlusPlusToken */) { - write(") - 1)"); - } - else { - write(") + 1)"); - } - } - else { - emit(node.operand); - write(ts.tokenToString(node.operator)); - } - } - function shouldHoistDeclarationInSystemJsModule(node) { - return isSourceFileLevelDeclarationInSystemJsModule(node, /*isExported*/ false); - } - /* - * Checks if given node is a source file level declaration (not nested in module/function). - * If 'isExported' is true - then declaration must also be exported. - * This function is used in two cases: - * - check if node is a exported source file level value to determine - * if we should also export the value after its it changed - * - check if node is a source level declaration to emit it differently, - * i.e non-exported variable statement 'var x = 1' is hoisted so - * we we emit variable statement 'var' should be dropped. - */ - function isSourceFileLevelDeclarationInSystemJsModule(node, isExported) { - if (!node || !isCurrentFileSystemExternalModule()) { - return false; - } - var current = node; - while (current) { - if (current.kind === 248 /* SourceFile */) { - return !isExported || ((ts.getCombinedNodeFlags(node) & 1 /* Export */) !== 0); - } - else if (ts.isFunctionLike(current) || current.kind === 219 /* ModuleBlock */) { - return false; - } - else { - current = current.parent; - } - } - } - /** - * Emit ES7 exponentiation operator downlevel using Math.pow - * @param node a binary expression node containing exponentiationOperator (**, **=) - */ - function emitExponentiationOperator(node) { - var leftHandSideExpression = node.left; - if (node.operatorToken.kind === 60 /* AsteriskAsteriskEqualsToken */) { - var synthesizedLHS; - var shouldEmitParentheses = false; - if (ts.isElementAccessExpression(leftHandSideExpression)) { - shouldEmitParentheses = true; - write("("); - synthesizedLHS = ts.createSynthesizedNode(167 /* ElementAccessExpression */, /*startsOnNewLine*/ false); - var identifier = emitTempVariableAssignment(leftHandSideExpression.expression, /*canDefinedTempVariablesInPlaces*/ false, /*shouldEmitCommaBeforeAssignment*/ false); - synthesizedLHS.expression = identifier; - if (leftHandSideExpression.argumentExpression.kind !== 8 /* NumericLiteral */ && - leftHandSideExpression.argumentExpression.kind !== 9 /* StringLiteral */) { - var tempArgumentExpression = createAndRecordTempVariable(268435456 /* _i */); - synthesizedLHS.argumentExpression = tempArgumentExpression; - emitAssignment(tempArgumentExpression, leftHandSideExpression.argumentExpression, /*shouldEmitCommaBeforeAssignment*/ true); - } - else { - synthesizedLHS.argumentExpression = leftHandSideExpression.argumentExpression; - } - write(", "); - } - else if (ts.isPropertyAccessExpression(leftHandSideExpression)) { - shouldEmitParentheses = true; - write("("); - synthesizedLHS = ts.createSynthesizedNode(166 /* PropertyAccessExpression */, /*startsOnNewLine*/ false); - var identifier = emitTempVariableAssignment(leftHandSideExpression.expression, /*canDefinedTempVariablesInPlaces*/ false, /*shouldemitCommaBeforeAssignment*/ false); - synthesizedLHS.expression = identifier; - synthesizedLHS.dotToken = leftHandSideExpression.dotToken; - synthesizedLHS.name = leftHandSideExpression.name; - write(", "); - } - emit(synthesizedLHS || leftHandSideExpression); - write(" = "); - write("Math.pow("); - emit(synthesizedLHS || leftHandSideExpression); - write(", "); - emit(node.right); - write(")"); - if (shouldEmitParentheses) { - write(")"); - } - } - else { - write("Math.pow("); - emit(leftHandSideExpression); - write(", "); - emit(node.right); - write(")"); - } - } - function emitBinaryExpression(node) { - if (languageVersion < 2 /* ES6 */ && node.operatorToken.kind === 56 /* EqualsToken */ && - (node.left.kind === 165 /* ObjectLiteralExpression */ || node.left.kind === 164 /* ArrayLiteralExpression */)) { - emitDestructuring(node, node.parent.kind === 195 /* ExpressionStatement */); - } - else { - var exportChanged = node.operatorToken.kind >= 56 /* FirstAssignment */ && - node.operatorToken.kind <= 68 /* LastAssignment */ && - isNameOfExportedSourceLevelDeclarationInSystemExternalModule(node.left); - if (exportChanged) { - // emit assignment 'x y' as 'exports("x", x y)' - write(exportFunctionForFile + "(\""); - emitNodeWithoutSourceMap(node.left); - write("\", "); - } - if (node.operatorToken.kind === 38 /* AsteriskAsteriskToken */ || node.operatorToken.kind === 60 /* AsteriskAsteriskEqualsToken */) { - // Downleveled emit exponentiation operator using Math.pow - emitExponentiationOperator(node); - } - else { - emit(node.left); - // Add indentation before emit the operator if the operator is on different line - // For example: - // 3 - // + 2; - // emitted as - // 3 - // + 2; - var indentedBeforeOperator = indentIfOnDifferentLines(node, node.left, node.operatorToken, node.operatorToken.kind !== 24 /* CommaToken */ ? " " : undefined); - write(ts.tokenToString(node.operatorToken.kind)); - var indentedAfterOperator = indentIfOnDifferentLines(node, node.operatorToken, node.right, " "); - emit(node.right); - decreaseIndentIf(indentedBeforeOperator, indentedAfterOperator); - } - if (exportChanged) { - write(")"); - } - } - } - function synthesizedNodeStartsOnNewLine(node) { - return ts.nodeIsSynthesized(node) && node.startsOnNewLine; - } - function emitConditionalExpression(node) { - emit(node.condition); - var indentedBeforeQuestion = indentIfOnDifferentLines(node, node.condition, node.questionToken, " "); - write("?"); - var indentedAfterQuestion = indentIfOnDifferentLines(node, node.questionToken, node.whenTrue, " "); - emit(node.whenTrue); - decreaseIndentIf(indentedBeforeQuestion, indentedAfterQuestion); - var indentedBeforeColon = indentIfOnDifferentLines(node, node.whenTrue, node.colonToken, " "); - write(":"); - var indentedAfterColon = indentIfOnDifferentLines(node, node.colonToken, node.whenFalse, " "); - emit(node.whenFalse); - decreaseIndentIf(indentedBeforeColon, indentedAfterColon); - } - // Helper function to decrease the indent if we previously indented. Allows multiple - // previous indent values to be considered at a time. This also allows caller to just - // call this once, passing in all their appropriate indent values, instead of needing - // to call this helper function multiple times. - function decreaseIndentIf(value1, value2) { - if (value1) { - decreaseIndent(); - } - if (value2) { - decreaseIndent(); - } - } - function isSingleLineEmptyBlock(node) { - if (node && node.kind === 192 /* Block */) { - var block = node; - return block.statements.length === 0 && nodeEndIsOnSameLineAsNodeStart(block, block); - } - } - function emitBlock(node) { - if (isSingleLineEmptyBlock(node)) { - emitToken(15 /* OpenBraceToken */, node.pos); - write(" "); - emitToken(16 /* CloseBraceToken */, node.statements.end); - return; - } - emitToken(15 /* OpenBraceToken */, node.pos); - increaseIndent(); - scopeEmitStart(node.parent); - if (node.kind === 219 /* ModuleBlock */) { - ts.Debug.assert(node.parent.kind === 218 /* ModuleDeclaration */); - emitCaptureThisForNodeIfNecessary(node.parent); - } - emitLines(node.statements); - if (node.kind === 219 /* ModuleBlock */) { - emitTempDeclarations(/*newLine*/ true); - } - decreaseIndent(); - writeLine(); - emitToken(16 /* CloseBraceToken */, node.statements.end); - scopeEmitEnd(); - } - function emitEmbeddedStatement(node) { - if (node.kind === 192 /* Block */) { - write(" "); - emit(node); - } - else { - increaseIndent(); - writeLine(); - emit(node); - decreaseIndent(); - } - } - function emitExpressionStatement(node) { - emitParenthesizedIf(node.expression, /*parenthesized*/ node.expression.kind === 174 /* ArrowFunction */); - write(";"); - } - function emitIfStatement(node) { - var endPos = emitToken(88 /* IfKeyword */, node.pos); - write(" "); - endPos = emitToken(17 /* OpenParenToken */, endPos); - emit(node.expression); - emitToken(18 /* CloseParenToken */, node.expression.end); - emitEmbeddedStatement(node.thenStatement); - if (node.elseStatement) { - writeLine(); - emitToken(80 /* ElseKeyword */, node.thenStatement.end); - if (node.elseStatement.kind === 196 /* IfStatement */) { - write(" "); - emit(node.elseStatement); - } - else { - emitEmbeddedStatement(node.elseStatement); - } - } - } - function emitDoStatement(node) { - write("do"); - emitEmbeddedStatement(node.statement); - if (node.statement.kind === 192 /* Block */) { - write(" "); - } - else { - writeLine(); - } - write("while ("); - emit(node.expression); - write(");"); - } - function emitWhileStatement(node) { - write("while ("); - emit(node.expression); - write(")"); - emitEmbeddedStatement(node.statement); - } - /** - * Returns true if start of variable declaration list was emitted. - * Returns false if nothing was written - this can happen for source file level variable declarations - * in system modules where such variable declarations are hoisted. - */ - function tryEmitStartOfVariableDeclarationList(decl, startPos) { - if (shouldHoistVariable(decl, /*checkIfSourceFileLevelDecl*/ true)) { - // variables in variable declaration list were already hoisted - return false; - } - var tokenKind = 102 /* VarKeyword */; - if (decl && languageVersion >= 2 /* ES6 */) { - if (ts.isLet(decl)) { - tokenKind = 108 /* LetKeyword */; - } - else if (ts.isConst(decl)) { - tokenKind = 74 /* ConstKeyword */; - } - } - if (startPos !== undefined) { - emitToken(tokenKind, startPos); - write(" "); - } - else { - switch (tokenKind) { - case 102 /* VarKeyword */: - write("var "); - break; - case 108 /* LetKeyword */: - write("let "); - break; - case 74 /* ConstKeyword */: - write("const "); - break; - } - } - return true; - } - function emitVariableDeclarationListSkippingUninitializedEntries(list) { - var started = false; - for (var _a = 0, _b = list.declarations; _a < _b.length; _a++) { - var decl = _b[_a]; - if (!decl.initializer) { - continue; - } - if (!started) { - started = true; - } - else { - write(", "); - } - emit(decl); - } - return started; - } - function emitForStatement(node) { - var endPos = emitToken(86 /* ForKeyword */, node.pos); - write(" "); - endPos = emitToken(17 /* OpenParenToken */, endPos); - if (node.initializer && node.initializer.kind === 212 /* VariableDeclarationList */) { - var variableDeclarationList = node.initializer; - var startIsEmitted = tryEmitStartOfVariableDeclarationList(variableDeclarationList, endPos); - if (startIsEmitted) { - emitCommaList(variableDeclarationList.declarations); - } - else { - emitVariableDeclarationListSkippingUninitializedEntries(variableDeclarationList); - } - } - else if (node.initializer) { - emit(node.initializer); - } - write(";"); - emitOptional(" ", node.condition); - write(";"); - emitOptional(" ", node.incrementor); - write(")"); - emitEmbeddedStatement(node.statement); - } - function emitForInOrForOfStatement(node) { - if (languageVersion < 2 /* ES6 */ && node.kind === 201 /* ForOfStatement */) { - return emitDownLevelForOfStatement(node); - } - var endPos = emitToken(86 /* ForKeyword */, node.pos); - write(" "); - endPos = emitToken(17 /* OpenParenToken */, endPos); - if (node.initializer.kind === 212 /* VariableDeclarationList */) { - var variableDeclarationList = node.initializer; - if (variableDeclarationList.declarations.length >= 1) { - tryEmitStartOfVariableDeclarationList(variableDeclarationList, endPos); - emit(variableDeclarationList.declarations[0]); - } - } - else { - emit(node.initializer); - } - if (node.kind === 200 /* ForInStatement */) { - write(" in "); - } - else { - write(" of "); - } - emit(node.expression); - emitToken(18 /* CloseParenToken */, node.expression.end); - emitEmbeddedStatement(node.statement); - } - function emitDownLevelForOfStatement(node) { - // The following ES6 code: - // - // for (let v of expr) { } - // - // should be emitted as - // - // for (let _i = 0, _a = expr; _i < _a.length; _i++) { - // let v = _a[_i]; - // } - // - // where _a and _i are temps emitted to capture the RHS and the counter, - // respectively. - // When the left hand side is an expression instead of a let declaration, - // the "let v" is not emitted. - // When the left hand side is a let/const, the v is renamed if there is - // another v in scope. - // Note that all assignments to the LHS are emitted in the body, including - // all destructuring. - // Note also that because an extra statement is needed to assign to the LHS, - // for-of bodies are always emitted as blocks. - var endPos = emitToken(86 /* ForKeyword */, node.pos); - write(" "); - endPos = emitToken(17 /* OpenParenToken */, endPos); - // Do not emit the LHS let declaration yet, because it might contain destructuring. - // Do not call recordTempDeclaration because we are declaring the temps - // right here. Recording means they will be declared later. - // 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 rhsIsIdentifier = node.expression.kind === 69 /* Identifier */; - var counter = createTempVariable(268435456 /* _i */); - var rhsReference = rhsIsIdentifier ? node.expression : createTempVariable(0 /* Auto */); - // This is the let keyword for the counter and rhsReference. The let keyword for - // the LHS will be emitted inside the body. - emitStart(node.expression); - write("var "); - // _i = 0 - emitNodeWithoutSourceMap(counter); - write(" = 0"); - emitEnd(node.expression); - if (!rhsIsIdentifier) { - // , _a = expr - write(", "); - emitStart(node.expression); - emitNodeWithoutSourceMap(rhsReference); - write(" = "); - emitNodeWithoutSourceMap(node.expression); - emitEnd(node.expression); - } - write("; "); - // _i < _a.length; - emitStart(node.initializer); - emitNodeWithoutSourceMap(counter); - write(" < "); - emitNodeWithCommentsAndWithoutSourcemap(rhsReference); - write(".length"); - emitEnd(node.initializer); - write("; "); - // _i++) - emitStart(node.initializer); - emitNodeWithoutSourceMap(counter); - write("++"); - emitEnd(node.initializer); - emitToken(18 /* CloseParenToken */, node.expression.end); - // Body - write(" {"); - writeLine(); - increaseIndent(); - // Initialize LHS - // let v = _a[_i]; - var rhsIterationValue = createElementAccessExpression(rhsReference, counter); - emitStart(node.initializer); - if (node.initializer.kind === 212 /* VariableDeclarationList */) { - write("var "); - var variableDeclarationList = node.initializer; - if (variableDeclarationList.declarations.length > 0) { - var declaration = variableDeclarationList.declarations[0]; - if (ts.isBindingPattern(declaration.name)) { - // This works whether the declaration is a var, let, or const. - // It will use rhsIterationValue _a[_i] as the initializer. - emitDestructuring(declaration, /*isAssignmentExpressionStatement*/ false, rhsIterationValue); - } - else { - // The following call does not include the initializer, so we have - // to emit it separately. - emitNodeWithCommentsAndWithoutSourcemap(declaration); - write(" = "); - emitNodeWithoutSourceMap(rhsIterationValue); - } - } - else { - // It's an empty declaration list. This can only happen in an error case, if the user wrote - // for (let of []) {} - emitNodeWithoutSourceMap(createTempVariable(0 /* Auto */)); - write(" = "); - emitNodeWithoutSourceMap(rhsIterationValue); - } - } - else { - // Initializer is an expression. Emit the expression in the body, so that it's - // evaluated on every iteration. - var assignmentExpression = createBinaryExpression(node.initializer, 56 /* EqualsToken */, rhsIterationValue, /*startsOnNewLine*/ false); - if (node.initializer.kind === 164 /* ArrayLiteralExpression */ || node.initializer.kind === 165 /* ObjectLiteralExpression */) { - // This is a destructuring pattern, so call emitDestructuring instead of emit. Calling emit will not work, because it will cause - // the BinaryExpression to be passed in instead of the expression statement, which will cause emitDestructuring to crash. - emitDestructuring(assignmentExpression, /*isAssignmentExpressionStatement*/ true, /*value*/ undefined); - } - else { - emitNodeWithCommentsAndWithoutSourcemap(assignmentExpression); - } - } - emitEnd(node.initializer); - write(";"); - if (node.statement.kind === 192 /* Block */) { - emitLines(node.statement.statements); - } - else { - writeLine(); - emit(node.statement); - } - writeLine(); - decreaseIndent(); - write("}"); - } - function emitBreakOrContinueStatement(node) { - emitToken(node.kind === 203 /* BreakStatement */ ? 70 /* BreakKeyword */ : 75 /* ContinueKeyword */, node.pos); - emitOptional(" ", node.label); - write(";"); - } - function emitReturnStatement(node) { - emitToken(94 /* ReturnKeyword */, node.pos); - emitOptional(" ", node.expression); - write(";"); - } - function emitWithStatement(node) { - write("with ("); - emit(node.expression); - write(")"); - emitEmbeddedStatement(node.statement); - } - function emitSwitchStatement(node) { - var endPos = emitToken(96 /* SwitchKeyword */, node.pos); - write(" "); - emitToken(17 /* OpenParenToken */, endPos); - emit(node.expression); - endPos = emitToken(18 /* CloseParenToken */, node.expression.end); - write(" "); - emitCaseBlock(node.caseBlock, endPos); - } - function emitCaseBlock(node, startPos) { - emitToken(15 /* OpenBraceToken */, startPos); - increaseIndent(); - emitLines(node.clauses); - decreaseIndent(); - writeLine(); - emitToken(16 /* CloseBraceToken */, node.clauses.end); - } - function nodeStartPositionsAreOnSameLine(node1, node2) { - return ts.getLineOfLocalPosition(currentSourceFile, ts.skipTrivia(currentSourceFile.text, node1.pos)) === - ts.getLineOfLocalPosition(currentSourceFile, ts.skipTrivia(currentSourceFile.text, node2.pos)); - } - function nodeEndPositionsAreOnSameLine(node1, node2) { - return ts.getLineOfLocalPosition(currentSourceFile, node1.end) === - ts.getLineOfLocalPosition(currentSourceFile, node2.end); - } - function nodeEndIsOnSameLineAsNodeStart(node1, node2) { - return ts.getLineOfLocalPosition(currentSourceFile, node1.end) === - ts.getLineOfLocalPosition(currentSourceFile, ts.skipTrivia(currentSourceFile.text, node2.pos)); - } - function emitCaseOrDefaultClause(node) { - if (node.kind === 241 /* CaseClause */) { - write("case "); - emit(node.expression); - write(":"); - } - else { - write("default:"); - } - if (node.statements.length === 1 && nodeStartPositionsAreOnSameLine(node, node.statements[0])) { - write(" "); - emit(node.statements[0]); - } - else { - increaseIndent(); - emitLines(node.statements); - decreaseIndent(); - } - } - function emitThrowStatement(node) { - write("throw "); - emit(node.expression); - write(";"); - } - function emitTryStatement(node) { - write("try "); - emit(node.tryBlock); - emit(node.catchClause); - if (node.finallyBlock) { - writeLine(); - write("finally "); - emit(node.finallyBlock); - } - } - function emitCatchClause(node) { - writeLine(); - var endPos = emitToken(72 /* CatchKeyword */, node.pos); - write(" "); - emitToken(17 /* OpenParenToken */, endPos); - emit(node.variableDeclaration); - emitToken(18 /* CloseParenToken */, node.variableDeclaration ? node.variableDeclaration.end : endPos); - write(" "); - emitBlock(node.block); - } - function emitDebuggerStatement(node) { - emitToken(76 /* DebuggerKeyword */, node.pos); - write(";"); - } - function emitLabelledStatement(node) { - emit(node.label); - write(": "); - emit(node.statement); - } - function getContainingModule(node) { - do { - node = node.parent; - } while (node && node.kind !== 218 /* ModuleDeclaration */); - return node; - } - function emitContainingModuleName(node) { - var container = getContainingModule(node); - write(container ? getGeneratedNameForNode(container) : "exports"); - } - function emitModuleMemberName(node) { - emitStart(node.name); - if (ts.getCombinedNodeFlags(node) & 1 /* Export */) { - var container = getContainingModule(node); - if (container) { - write(getGeneratedNameForNode(container)); - write("."); - } - else if (modulekind !== 5 /* ES6 */ && modulekind !== 4 /* System */) { - write("exports."); - } - } - emitNodeWithCommentsAndWithoutSourcemap(node.name); - emitEnd(node.name); - } - function createVoidZero() { - var zero = ts.createSynthesizedNode(8 /* NumericLiteral */); - zero.text = "0"; - var result = ts.createSynthesizedNode(177 /* VoidExpression */); - result.expression = zero; - return result; - } - function emitEs6ExportDefaultCompat(node) { - if (node.parent.kind === 248 /* SourceFile */) { - ts.Debug.assert(!!(node.flags & 1024 /* Default */) || node.kind === 227 /* ExportAssignment */); - // only allow export default at a source file level - if (modulekind === 1 /* CommonJS */ || modulekind === 2 /* AMD */ || modulekind === 3 /* UMD */) { - if (!currentSourceFile.symbol.exports["___esModule"]) { - if (languageVersion === 1 /* ES5 */) { - // default value of configurable, enumerable, writable are `false`. - write("Object.defineProperty(exports, \"__esModule\", { value: true });"); - writeLine(); - } - else if (languageVersion === 0 /* ES3 */) { - write("exports.__esModule = true;"); - writeLine(); - } - } - } - } - } - function emitExportMemberAssignment(node) { - if (node.flags & 1 /* Export */) { - writeLine(); - emitStart(node); - // emit call to exporter only for top level nodes - if (modulekind === 4 /* System */ && node.parent === currentSourceFile) { - // emit export default as - // export("default", ) - write(exportFunctionForFile + "(\""); - if (node.flags & 1024 /* Default */) { - write("default"); - } - else { - emitNodeWithCommentsAndWithoutSourcemap(node.name); - } - write("\", "); - emitDeclarationName(node); - write(")"); - } - else { - if (node.flags & 1024 /* Default */) { - emitEs6ExportDefaultCompat(node); - if (languageVersion === 0 /* ES3 */) { - write("exports[\"default\"]"); - } - else { - write("exports.default"); - } - } - else { - emitModuleMemberName(node); - } - write(" = "); - emitDeclarationName(node); - } - emitEnd(node); - write(";"); - } - } - function emitExportMemberAssignments(name) { - if (modulekind === 4 /* System */) { - return; - } - if (!exportEquals && exportSpecifiers && ts.hasProperty(exportSpecifiers, name.text)) { - for (var _a = 0, _b = exportSpecifiers[name.text]; _a < _b.length; _a++) { - var specifier = _b[_a]; - writeLine(); - emitStart(specifier.name); - emitContainingModuleName(specifier); - write("."); - emitNodeWithCommentsAndWithoutSourcemap(specifier.name); - emitEnd(specifier.name); - write(" = "); - emitExpressionIdentifier(name); - write(";"); - } - } - } - function emitExportSpecifierInSystemModule(specifier) { - ts.Debug.assert(modulekind === 4 /* System */); - if (!resolver.getReferencedValueDeclaration(specifier.propertyName || specifier.name) && !resolver.isValueAliasDeclaration(specifier)) { - return; - } - writeLine(); - emitStart(specifier.name); - write(exportFunctionForFile + "(\""); - emitNodeWithCommentsAndWithoutSourcemap(specifier.name); - write("\", "); - emitExpressionIdentifier(specifier.propertyName || specifier.name); - write(")"); - emitEnd(specifier.name); - write(";"); - } - /** - * Emit an assignment to a given identifier, 'name', with a given expression, 'value'. - * @param name an identifier as a left-hand-side operand of the assignment - * @param value an expression as a right-hand-side operand of the assignment - * @param shouldEmitCommaBeforeAssignment a boolean indicating whether to prefix an assignment with comma - */ - function emitAssignment(name, value, shouldEmitCommaBeforeAssignment) { - if (shouldEmitCommaBeforeAssignment) { - write(", "); - } - var exportChanged = isNameOfExportedSourceLevelDeclarationInSystemExternalModule(name); - if (exportChanged) { - write(exportFunctionForFile + "(\""); - emitNodeWithCommentsAndWithoutSourcemap(name); - write("\", "); - } - var isVariableDeclarationOrBindingElement = name.parent && (name.parent.kind === 211 /* VariableDeclaration */ || name.parent.kind === 163 /* BindingElement */); - if (isVariableDeclarationOrBindingElement) { - emitModuleMemberName(name.parent); - } - else { - emit(name); - } - write(" = "); - emit(value); - if (exportChanged) { - write(")"); - } - } - /** - * Create temporary variable, emit an assignment of the variable the given expression - * @param expression an expression to assign to the newly created temporary variable - * @param canDefineTempVariablesInPlace a boolean indicating whether you can define the temporary variable at an assignment location - * @param shouldEmitCommaBeforeAssignment a boolean indicating whether an assignment should prefix with comma - */ - function emitTempVariableAssignment(expression, canDefineTempVariablesInPlace, shouldEmitCommaBeforeAssignment) { - var identifier = createTempVariable(0 /* Auto */); - if (!canDefineTempVariablesInPlace) { - recordTempDeclaration(identifier); - } - emitAssignment(identifier, expression, shouldEmitCommaBeforeAssignment); - return identifier; - } - function emitDestructuring(root, isAssignmentExpressionStatement, value) { - var emitCount = 0; - // An exported declaration is actually emitted as an assignment (to a property on the module object), so - // temporary variables in an exported declaration need to have real declarations elsewhere - // Also temporary variables should be explicitly allocated for source level declarations when module target is system - // because actual variable declarations are hoisted - var canDefineTempVariablesInPlace = false; - if (root.kind === 211 /* VariableDeclaration */) { - var isExported = ts.getCombinedNodeFlags(root) & 1 /* Export */; - var isSourceLevelForSystemModuleKind = shouldHoistDeclarationInSystemJsModule(root); - canDefineTempVariablesInPlace = !isExported && !isSourceLevelForSystemModuleKind; - } - else if (root.kind === 138 /* Parameter */) { - canDefineTempVariablesInPlace = true; - } - if (root.kind === 181 /* BinaryExpression */) { - emitAssignmentExpression(root); - } - else { - ts.Debug.assert(!isAssignmentExpressionStatement); - emitBindingElement(root, value); - } - /** - * Ensures that there exists a declared identifier whose value holds the given expression. - * This function is useful to ensure that the expression's value can be read from in subsequent expressions. - * Unless 'reuseIdentifierExpressions' is false, 'expr' will be returned if it is just an identifier. - * - * @param expr the expression whose value needs to be bound. - * @param reuseIdentifierExpressions true if identifier expressions can simply be returned; - * false if it is necessary to always emit an identifier. - */ - function ensureIdentifier(expr, reuseIdentifierExpressions) { - if (expr.kind === 69 /* Identifier */ && reuseIdentifierExpressions) { - return expr; - } - var identifier = emitTempVariableAssignment(expr, canDefineTempVariablesInPlace, emitCount > 0); - emitCount++; - return identifier; - } - function createDefaultValueCheck(value, defaultValue) { - // The value expression will be evaluated twice, so for anything but a simple identifier - // we need to generate a temporary variable - value = ensureIdentifier(value, /*reuseIdentifierExpressions*/ true); - // Return the expression 'value === void 0 ? defaultValue : value' - var equals = ts.createSynthesizedNode(181 /* BinaryExpression */); - equals.left = value; - equals.operatorToken = ts.createSynthesizedNode(32 /* EqualsEqualsEqualsToken */); - equals.right = createVoidZero(); - return createConditionalExpression(equals, defaultValue, value); - } - function createConditionalExpression(condition, whenTrue, whenFalse) { - var cond = ts.createSynthesizedNode(182 /* ConditionalExpression */); - cond.condition = condition; - cond.questionToken = ts.createSynthesizedNode(53 /* QuestionToken */); - cond.whenTrue = whenTrue; - cond.colonToken = ts.createSynthesizedNode(54 /* ColonToken */); - cond.whenFalse = whenFalse; - return cond; - } - function createNumericLiteral(value) { - var node = ts.createSynthesizedNode(8 /* NumericLiteral */); - node.text = "" + value; - return node; - } - function createPropertyAccessForDestructuringProperty(object, propName) { - // We create a synthetic copy of the identifier in order to avoid the rewriting that might - // otherwise occur when the identifier is emitted. - var syntheticName = ts.createSynthesizedNode(propName.kind); - syntheticName.text = propName.text; - if (syntheticName.kind !== 69 /* Identifier */) { - return createElementAccessExpression(object, syntheticName); - } - return createPropertyAccessExpression(object, syntheticName); - } - function createSliceCall(value, sliceIndex) { - var call = ts.createSynthesizedNode(168 /* CallExpression */); - var sliceIdentifier = ts.createSynthesizedNode(69 /* Identifier */); - sliceIdentifier.text = "slice"; - call.expression = createPropertyAccessExpression(value, sliceIdentifier); - call.arguments = ts.createSynthesizedNodeArray(); - call.arguments[0] = createNumericLiteral(sliceIndex); - return call; - } - function emitObjectLiteralAssignment(target, value) { - var properties = target.properties; - if (properties.length !== 1) { - // For anything but a single element destructuring we need to generate a temporary - // to ensure value is evaluated exactly once. - value = ensureIdentifier(value, /*reuseIdentifierExpressions*/ true); - } - for (var _a = 0; _a < properties.length; _a++) { - var p = properties[_a]; - if (p.kind === 245 /* PropertyAssignment */ || p.kind === 246 /* ShorthandPropertyAssignment */) { - var propName = p.name; - var target_1 = p.kind === 246 /* ShorthandPropertyAssignment */ ? p : p.initializer || propName; - emitDestructuringAssignment(target_1, createPropertyAccessForDestructuringProperty(value, propName)); - } - } - } - function emitArrayLiteralAssignment(target, value) { - var elements = target.elements; - if (elements.length !== 1) { - // For anything but a single element destructuring we need to generate a temporary - // to ensure value is evaluated exactly once. - value = ensureIdentifier(value, /*reuseIdentifierExpressions*/ true); - } - for (var i = 0; i < elements.length; i++) { - var e = elements[i]; - if (e.kind !== 187 /* OmittedExpression */) { - if (e.kind !== 185 /* SpreadElementExpression */) { - emitDestructuringAssignment(e, createElementAccessExpression(value, createNumericLiteral(i))); - } - else if (i === elements.length - 1) { - emitDestructuringAssignment(e.expression, createSliceCall(value, i)); - } - } - } - } - function emitDestructuringAssignment(target, value) { - if (target.kind === 246 /* ShorthandPropertyAssignment */) { - if (target.objectAssignmentInitializer) { - value = createDefaultValueCheck(value, target.objectAssignmentInitializer); - } - target = target.name; - } - else if (target.kind === 181 /* BinaryExpression */ && target.operatorToken.kind === 56 /* EqualsToken */) { - value = createDefaultValueCheck(value, target.right); - target = target.left; - } - if (target.kind === 165 /* ObjectLiteralExpression */) { - emitObjectLiteralAssignment(target, value); - } - else if (target.kind === 164 /* ArrayLiteralExpression */) { - emitArrayLiteralAssignment(target, value); - } - else { - emitAssignment(target, value, /*shouldEmitCommaBeforeAssignment*/ emitCount > 0); - emitCount++; - } - } - function emitAssignmentExpression(root) { - var target = root.left; - var value = root.right; - if (ts.isEmptyObjectLiteralOrArrayLiteral(target)) { - emit(value); - } - else if (isAssignmentExpressionStatement) { - emitDestructuringAssignment(target, value); - } - else { - if (root.parent.kind !== 172 /* ParenthesizedExpression */) { - write("("); - } - value = ensureIdentifier(value, /*reuseIdentifierExpressions*/ true); - emitDestructuringAssignment(target, value); - write(", "); - emit(value); - if (root.parent.kind !== 172 /* ParenthesizedExpression */) { - write(")"); - } - } - } - function emitBindingElement(target, value) { - if (target.initializer) { - // Combine value and initializer - value = value ? createDefaultValueCheck(value, target.initializer) : target.initializer; - } - else if (!value) { - // Use 'void 0' in absence of value and initializer - value = createVoidZero(); - } - if (ts.isBindingPattern(target.name)) { - var pattern = target.name; - var elements = pattern.elements; - var numElements = elements.length; - if (numElements !== 1) { - // For anything other than a single-element destructuring we need to generate a temporary - // to ensure value is evaluated exactly once. Additionally, if we have zero elements - // we need to emit *something* to ensure that in case a 'var' keyword was already emitted, - // so in that case, we'll intentionally create that temporary. - value = ensureIdentifier(value, /*reuseIdentifierExpressions*/ numElements !== 0); - } - for (var i = 0; i < numElements; i++) { - var element = elements[i]; - if (pattern.kind === 161 /* ObjectBindingPattern */) { - // Rewrite element to a declaration with an initializer that fetches property - var propName = element.propertyName || element.name; - emitBindingElement(element, createPropertyAccessForDestructuringProperty(value, propName)); - } - else if (element.kind !== 187 /* OmittedExpression */) { - if (!element.dotDotDotToken) { - // Rewrite element to a declaration that accesses array element at index i - emitBindingElement(element, createElementAccessExpression(value, createNumericLiteral(i))); - } - else if (i === numElements - 1) { - emitBindingElement(element, createSliceCall(value, i)); - } - } - } - } - else { - emitAssignment(target.name, value, /*shouldEmitCommaBeforeAssignment*/ emitCount > 0); - emitCount++; - } - } - } - function emitVariableDeclaration(node) { - if (ts.isBindingPattern(node.name)) { - if (languageVersion < 2 /* ES6 */) { - emitDestructuring(node, /*isAssignmentExpressionStatement*/ false); - } - else { - emit(node.name); - emitOptional(" = ", node.initializer); - } - } - else { - var initializer = node.initializer; - if (!initializer && languageVersion < 2 /* ES6 */) { - // downlevel emit for non-initialized let bindings defined in loops - // for (...) { let x; } - // should be - // for (...) { var = void 0; } - // this is necessary to preserve ES6 semantic in scenarios like - // for (...) { let x; console.log(x); x = 1 } // assignment on one iteration should not affect other iterations - var isUninitializedLet = (resolver.getNodeCheckFlags(node) & 16384 /* BlockScopedBindingInLoop */) && - (getCombinedFlagsForIdentifier(node.name) & 16384 /* Let */); - // NOTE: default initialization should not be added to let bindings in for-in\for-of statements - if (isUninitializedLet && - node.parent.parent.kind !== 200 /* ForInStatement */ && - node.parent.parent.kind !== 201 /* ForOfStatement */) { - initializer = createVoidZero(); - } - } - var exportChanged = isNameOfExportedSourceLevelDeclarationInSystemExternalModule(node.name); - if (exportChanged) { - write(exportFunctionForFile + "(\""); - emitNodeWithCommentsAndWithoutSourcemap(node.name); - write("\", "); - } - emitModuleMemberName(node); - emitOptional(" = ", initializer); - if (exportChanged) { - write(")"); - } - } - } - function emitExportVariableAssignments(node) { - if (node.kind === 187 /* OmittedExpression */) { - return; - } - var name = node.name; - if (name.kind === 69 /* Identifier */) { - emitExportMemberAssignments(name); - } - else if (ts.isBindingPattern(name)) { - ts.forEach(name.elements, emitExportVariableAssignments); - } - } - function getCombinedFlagsForIdentifier(node) { - if (!node.parent || (node.parent.kind !== 211 /* VariableDeclaration */ && node.parent.kind !== 163 /* BindingElement */)) { - return 0; - } - return ts.getCombinedNodeFlags(node.parent); - } - function isES6ExportedDeclaration(node) { - return !!(node.flags & 1 /* Export */) && - modulekind === 5 /* ES6 */ && - node.parent.kind === 248 /* SourceFile */; - } - function emitVariableStatement(node) { - var startIsEmitted = false; - if (node.flags & 1 /* Export */) { - if (isES6ExportedDeclaration(node)) { - // Exported ES6 module member - write("export "); - startIsEmitted = tryEmitStartOfVariableDeclarationList(node.declarationList); - } - } - else { - startIsEmitted = tryEmitStartOfVariableDeclarationList(node.declarationList); - } - if (startIsEmitted) { - emitCommaList(node.declarationList.declarations); - write(";"); - } - else { - var atLeastOneItem = emitVariableDeclarationListSkippingUninitializedEntries(node.declarationList); - if (atLeastOneItem) { - write(";"); - } - } - if (modulekind !== 5 /* ES6 */ && node.parent === currentSourceFile) { - ts.forEach(node.declarationList.declarations, emitExportVariableAssignments); - } - } - function shouldEmitLeadingAndTrailingCommentsForVariableStatement(node) { - // If we're not exporting the variables, there's nothing special here. - // Always emit comments for these nodes. - if (!(node.flags & 1 /* Export */)) { - return true; - } - // If we are exporting, but it's a top-level ES6 module exports, - // we'll emit the declaration list verbatim, so emit comments too. - if (isES6ExportedDeclaration(node)) { - return true; - } - // Otherwise, only emit if we have at least one initializer present. - for (var _a = 0, _b = node.declarationList.declarations; _a < _b.length; _a++) { - var declaration = _b[_a]; - if (declaration.initializer) { - return true; - } - } - return false; - } - function emitParameter(node) { - if (languageVersion < 2 /* ES6 */) { - if (ts.isBindingPattern(node.name)) { - var name_24 = createTempVariable(0 /* Auto */); - if (!tempParameters) { - tempParameters = []; - } - tempParameters.push(name_24); - emit(name_24); - } - else { - emit(node.name); - } - } - else { - if (node.dotDotDotToken) { - write("..."); - } - emit(node.name); - emitOptional(" = ", node.initializer); - } - } - function emitDefaultValueAssignments(node) { - if (languageVersion < 2 /* ES6 */) { - var tempIndex = 0; - ts.forEach(node.parameters, function (parameter) { - // A rest parameter cannot have a binding pattern or an initializer, - // so let's just ignore it. - if (parameter.dotDotDotToken) { - return; - } - var paramName = parameter.name, initializer = parameter.initializer; - if (ts.isBindingPattern(paramName)) { - // 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. - var hasBindingElements = paramName.elements.length > 0; - if (hasBindingElements || initializer) { - writeLine(); - write("var "); - if (hasBindingElements) { - emitDestructuring(parameter, /*isAssignmentExpressionStatement*/ false, tempParameters[tempIndex]); - } - else { - emit(tempParameters[tempIndex]); - write(" = "); - emit(initializer); - } - write(";"); - tempIndex++; - } - } - else if (initializer) { - writeLine(); - emitStart(parameter); - write("if ("); - emitNodeWithoutSourceMap(paramName); - write(" === void 0)"); - emitEnd(parameter); - write(" { "); - emitStart(parameter); - emitNodeWithCommentsAndWithoutSourcemap(paramName); - write(" = "); - emitNodeWithCommentsAndWithoutSourcemap(initializer); - emitEnd(parameter); - write("; }"); - } - }); - } - } - function emitRestParameter(node) { - if (languageVersion < 2 /* ES6 */ && ts.hasRestParameter(node)) { - var restIndex = node.parameters.length - 1; - var restParam = node.parameters[restIndex]; - // A rest parameter cannot have a binding pattern, so let's just ignore it if it does. - if (ts.isBindingPattern(restParam.name)) { - return; - } - var tempName = createTempVariable(268435456 /* _i */).text; - writeLine(); - emitLeadingComments(restParam); - emitStart(restParam); - write("var "); - emitNodeWithCommentsAndWithoutSourcemap(restParam.name); - write(" = [];"); - emitEnd(restParam); - emitTrailingComments(restParam); - writeLine(); - write("for ("); - emitStart(restParam); - write("var " + tempName + " = " + restIndex + ";"); - emitEnd(restParam); - write(" "); - emitStart(restParam); - write(tempName + " < arguments.length;"); - emitEnd(restParam); - write(" "); - emitStart(restParam); - write(tempName + "++"); - emitEnd(restParam); - write(") {"); - increaseIndent(); - writeLine(); - emitStart(restParam); - emitNodeWithCommentsAndWithoutSourcemap(restParam.name); - write("[" + tempName + " - " + restIndex + "] = arguments[" + tempName + "];"); - emitEnd(restParam); - decreaseIndent(); - writeLine(); - write("}"); - } - } - function emitAccessor(node) { - write(node.kind === 145 /* GetAccessor */ ? "get " : "set "); - emit(node.name); - emitSignatureAndBody(node); - } - function shouldEmitAsArrowFunction(node) { - return node.kind === 174 /* ArrowFunction */ && languageVersion >= 2 /* ES6 */; - } - function emitDeclarationName(node) { - if (node.name) { - emitNodeWithCommentsAndWithoutSourcemap(node.name); - } - else { - write(getGeneratedNameForNode(node)); - } - } - function shouldEmitFunctionName(node) { - if (node.kind === 173 /* FunctionExpression */) { - // Emit name if one is present - return !!node.name; - } - if (node.kind === 213 /* FunctionDeclaration */) { - // Emit name if one is present, or emit generated name in down-level case (for export default case) - return !!node.name || languageVersion < 2 /* ES6 */; - } - } - function emitFunctionDeclaration(node) { - if (ts.nodeIsMissing(node.body)) { - return emitCommentsOnNotEmittedNode(node); - } - // TODO (yuisu) : we should not have special cases to condition emitting comments - // but have one place to fix check for these conditions. - if (node.kind !== 143 /* MethodDeclaration */ && node.kind !== 142 /* MethodSignature */ && - node.parent && node.parent.kind !== 245 /* PropertyAssignment */ && - node.parent.kind !== 168 /* CallExpression */) { - // 1. Methods will emit the comments as part of emitting method declaration - // 2. If the function is a property of object literal, emitting leading-comments - // is done by emitNodeWithoutSourceMap which then call this function. - // In particular, we would like to avoid emit comments twice in following case: - // For example: - // var obj = { - // id: - // /*comment*/ () => void - // } - // 3. If the function is an argument in call expression, emitting of comments will be - // taken care of in emit list of arguments inside of emitCallexpression - emitLeadingComments(node); - } - emitStart(node); - // For targeting below es6, emit functions-like declaration including arrow function using function keyword. - // When targeting ES6, emit arrow function natively in ES6 by omitting function keyword and using fat arrow instead - if (!shouldEmitAsArrowFunction(node)) { - if (isES6ExportedDeclaration(node)) { - write("export "); - if (node.flags & 1024 /* Default */) { - write("default "); - } - } - write("function"); - if (languageVersion >= 2 /* ES6 */ && node.asteriskToken) { - write("*"); - } - write(" "); - } - if (shouldEmitFunctionName(node)) { - emitDeclarationName(node); - } - emitSignatureAndBody(node); - if (modulekind !== 5 /* ES6 */ && node.kind === 213 /* FunctionDeclaration */ && node.parent === currentSourceFile && node.name) { - emitExportMemberAssignments(node.name); - } - emitEnd(node); - if (node.kind !== 143 /* MethodDeclaration */ && node.kind !== 142 /* MethodSignature */) { - emitTrailingComments(node); - } - } - function emitCaptureThisForNodeIfNecessary(node) { - if (resolver.getNodeCheckFlags(node) & 4 /* CaptureThis */) { - writeLine(); - emitStart(node); - write("var _this = this;"); - emitEnd(node); - } - } - function emitSignatureParameters(node) { - increaseIndent(); - write("("); - if (node) { - var parameters = node.parameters; - var omitCount = languageVersion < 2 /* ES6 */ && ts.hasRestParameter(node) ? 1 : 0; - emitList(parameters, 0, parameters.length - omitCount, /*multiLine*/ false, /*trailingComma*/ false); - } - write(")"); - decreaseIndent(); - } - function emitSignatureParametersForArrow(node) { - // Check whether the parameter list needs parentheses and preserve no-parenthesis - if (node.parameters.length === 1 && node.pos === node.parameters[0].pos) { - emit(node.parameters[0]); - return; - } - emitSignatureParameters(node); - } - function emitAsyncFunctionBodyForES6(node) { - var promiseConstructor = ts.getEntityNameFromTypeNode(node.type); - var isArrowFunction = node.kind === 174 /* ArrowFunction */; - var hasLexicalArguments = (resolver.getNodeCheckFlags(node) & 4096 /* CaptureArguments */) !== 0; - var args; - // 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. - // - // The emit for an async arrow without a lexical `arguments` binding might be: - // - // // input - // let a = async (b) => { await b; } - // - // // output - // let a = (b) => __awaiter(this, void 0, void 0, function* () { - // yield b; - // }); - // - // The emit for an async arrow with a lexical `arguments` binding might be: - // - // // input - // let a = async (b) => { await arguments[0]; } - // - // // output - // let a = (b) => __awaiter(this, arguments, void 0, function* (arguments) { - // yield arguments[0]; - // }); - // - // The emit for an async function expression without a lexical `arguments` binding - // might be: - // - // // input - // let a = async function (b) { - // await b; - // } - // - // // output - // let a = function (b) { - // return __awaiter(this, void 0, void 0, function* () { - // yield b; - // }); - // } - // - // The emit for an async function expression with a lexical `arguments` binding - // might be: - // - // // input - // let a = async function (b) { - // await arguments[0]; - // } - // - // // output - // let a = function (b) { - // return __awaiter(this, arguments, void 0, function* (_arguments) { - // yield _arguments[0]; - // }); - // } - // - // The emit for an async function expression with a lexical `arguments` binding - // and a return type annotation might be: - // - // // input - // let a = async function (b): MyPromise { - // await arguments[0]; - // } - // - // // output - // let a = function (b) { - // return __awaiter(this, arguments, MyPromise, function* (_arguments) { - // yield _arguments[0]; - // }); - // } - // - // If this is not an async arrow, emit the opening brace of the function body - // and the start of the return statement. - if (!isArrowFunction) { - write(" {"); - increaseIndent(); - writeLine(); - write("return"); - } - write(" __awaiter(this"); - if (hasLexicalArguments) { - write(", arguments"); - } - else { - write(", void 0"); - } - if (promiseConstructor) { - write(", "); - emitNodeWithoutSourceMap(promiseConstructor); - } - else { - write(", Promise"); - } - // Emit the call to __awaiter. - if (hasLexicalArguments) { - write(", function* (_arguments)"); - } - else { - write(", function* ()"); - } - // Emit the signature and body for the inner generator function. - emitFunctionBody(node); - write(")"); - // If this is not an async arrow, emit the closing brace of the outer function body. - if (!isArrowFunction) { - write(";"); - decreaseIndent(); - writeLine(); - write("}"); - } - } - function emitFunctionBody(node) { - if (!node.body) { - // There can be no body when there are parse errors. Just emit an empty block - // in that case. - write(" { }"); - } - else { - if (node.body.kind === 192 /* Block */) { - emitBlockFunctionBody(node, node.body); - } - else { - emitExpressionFunctionBody(node, node.body); - } - } - } - function emitSignatureAndBody(node) { - var saveTempFlags = tempFlags; - var saveTempVariables = tempVariables; - var saveTempParameters = tempParameters; - tempFlags = 0; - tempVariables = undefined; - tempParameters = undefined; - // When targeting ES6, emit arrow function natively in ES6 - if (shouldEmitAsArrowFunction(node)) { - emitSignatureParametersForArrow(node); - write(" =>"); - } - else { - emitSignatureParameters(node); - } - var isAsync = ts.isAsyncFunctionLike(node); - if (isAsync && languageVersion === 2 /* ES6 */) { - emitAsyncFunctionBodyForES6(node); - } - else { - emitFunctionBody(node); - } - if (!isES6ExportedDeclaration(node)) { - emitExportMemberAssignment(node); - } - tempFlags = saveTempFlags; - tempVariables = saveTempVariables; - tempParameters = saveTempParameters; - } - // Returns true if any preamble code was emitted. - function emitFunctionBodyPreamble(node) { - emitCaptureThisForNodeIfNecessary(node); - emitDefaultValueAssignments(node); - emitRestParameter(node); - } - function emitExpressionFunctionBody(node, body) { - if (languageVersion < 2 /* ES6 */ || node.flags & 512 /* Async */) { - emitDownLevelExpressionFunctionBody(node, body); - return; - } - // For es6 and higher we can emit the expression as is. However, in the case - // where the expression might end up looking like a block when emitted, we'll - // also wrap it in parentheses first. For example if you have: a => {} - // then we need to generate: a => ({}) - write(" "); - // Unwrap all type assertions. - var current = body; - while (current.kind === 171 /* TypeAssertionExpression */) { - current = current.expression; - } - emitParenthesizedIf(body, current.kind === 165 /* ObjectLiteralExpression */); - } - function emitDownLevelExpressionFunctionBody(node, body) { - write(" {"); - scopeEmitStart(node); - increaseIndent(); - var outPos = writer.getTextPos(); - emitDetachedComments(node.body); - emitFunctionBodyPreamble(node); - var preambleEmitted = writer.getTextPos() !== outPos; - decreaseIndent(); - // If we didn't have to emit any preamble code, then attempt to keep the arrow - // function on one line. - if (!preambleEmitted && nodeStartPositionsAreOnSameLine(node, body)) { - write(" "); - emitStart(body); - write("return "); - emit(body); - emitEnd(body); - write(";"); - emitTempDeclarations(/*newLine*/ false); - write(" "); - } - else { - increaseIndent(); - writeLine(); - emitLeadingComments(node.body); - write("return "); - emit(body); - write(";"); - emitTrailingComments(node.body); - emitTempDeclarations(/*newLine*/ true); - decreaseIndent(); - writeLine(); - } - emitStart(node.body); - write("}"); - emitEnd(node.body); - scopeEmitEnd(); - } - function emitBlockFunctionBody(node, body) { - write(" {"); - scopeEmitStart(node); - var initialTextPos = writer.getTextPos(); - increaseIndent(); - emitDetachedComments(body.statements); - // Emit all the directive prologues (like "use strict"). These have to come before - // any other preamble code we write (like parameter initializers). - var startIndex = emitDirectivePrologues(body.statements, /*startWithNewLine*/ true); - emitFunctionBodyPreamble(node); - decreaseIndent(); - var preambleEmitted = writer.getTextPos() !== initialTextPos; - if (!preambleEmitted && nodeEndIsOnSameLineAsNodeStart(body, body)) { - for (var _a = 0, _b = body.statements; _a < _b.length; _a++) { - var statement = _b[_a]; - write(" "); - emit(statement); - } - emitTempDeclarations(/*newLine*/ false); - write(" "); - emitLeadingCommentsOfPosition(body.statements.end); - } - else { - increaseIndent(); - emitLinesStartingAt(body.statements, startIndex); - emitTempDeclarations(/*newLine*/ true); - writeLine(); - emitLeadingCommentsOfPosition(body.statements.end); - decreaseIndent(); - } - emitToken(16 /* CloseBraceToken */, body.statements.end); - scopeEmitEnd(); - } - function findInitialSuperCall(ctor) { - if (ctor.body) { - var statement = ctor.body.statements[0]; - if (statement && statement.kind === 195 /* ExpressionStatement */) { - var expr = statement.expression; - if (expr && expr.kind === 168 /* CallExpression */) { - var func = expr.expression; - if (func && func.kind === 95 /* SuperKeyword */) { - return statement; - } - } - } - } - } - function emitParameterPropertyAssignments(node) { - ts.forEach(node.parameters, function (param) { - if (param.flags & 112 /* AccessibilityModifier */) { - writeLine(); - emitStart(param); - emitStart(param.name); - write("this."); - emitNodeWithoutSourceMap(param.name); - emitEnd(param.name); - write(" = "); - emit(param.name); - write(";"); - emitEnd(param); - } - }); - } - function emitMemberAccessForPropertyName(memberName) { - // This does not emit source map because it is emitted by caller as caller - // is aware how the property name changes to the property access - // eg. public x = 10; becomes this.x and static x = 10 becomes className.x - if (memberName.kind === 9 /* StringLiteral */ || memberName.kind === 8 /* NumericLiteral */) { - write("["); - emitNodeWithCommentsAndWithoutSourcemap(memberName); - write("]"); - } - else if (memberName.kind === 136 /* ComputedPropertyName */) { - emitComputedPropertyName(memberName); - } - else { - write("."); - emitNodeWithCommentsAndWithoutSourcemap(memberName); - } - } - function getInitializedProperties(node, isStatic) { - var properties = []; - for (var _a = 0, _b = node.members; _a < _b.length; _a++) { - var member = _b[_a]; - if (member.kind === 141 /* PropertyDeclaration */ && isStatic === ((member.flags & 128 /* Static */) !== 0) && member.initializer) { - properties.push(member); - } - } - return properties; - } - function emitPropertyDeclarations(node, properties) { - for (var _a = 0; _a < properties.length; _a++) { - var property = properties[_a]; - emitPropertyDeclaration(node, property); - } - } - function emitPropertyDeclaration(node, property, receiver, isExpression) { - writeLine(); - emitLeadingComments(property); - emitStart(property); - emitStart(property.name); - if (receiver) { - emit(receiver); - } - else { - if (property.flags & 128 /* Static */) { - emitDeclarationName(node); - } - else { - write("this"); - } - } - emitMemberAccessForPropertyName(property.name); - emitEnd(property.name); - write(" = "); - emit(property.initializer); - if (!isExpression) { - write(";"); - } - emitEnd(property); - emitTrailingComments(property); - } - function emitMemberFunctionsForES5AndLower(node) { - ts.forEach(node.members, function (member) { - if (member.kind === 191 /* SemicolonClassElement */) { - writeLine(); - write(";"); - } - else if (member.kind === 143 /* MethodDeclaration */ || node.kind === 142 /* MethodSignature */) { - if (!member.body) { - return emitCommentsOnNotEmittedNode(member); - } - writeLine(); - emitLeadingComments(member); - emitStart(member); - emitStart(member.name); - emitClassMemberPrefix(node, member); - emitMemberAccessForPropertyName(member.name); - emitEnd(member.name); - write(" = "); - emitFunctionDeclaration(member); - emitEnd(member); - write(";"); - emitTrailingComments(member); - } - else if (member.kind === 145 /* GetAccessor */ || member.kind === 146 /* SetAccessor */) { - var accessors = ts.getAllAccessorDeclarations(node.members, member); - if (member === accessors.firstAccessor) { - writeLine(); - emitStart(member); - write("Object.defineProperty("); - emitStart(member.name); - emitClassMemberPrefix(node, member); - write(", "); - emitExpressionForPropertyName(member.name); - emitEnd(member.name); - write(", {"); - increaseIndent(); - if (accessors.getAccessor) { - writeLine(); - emitLeadingComments(accessors.getAccessor); - write("get: "); - emitStart(accessors.getAccessor); - write("function "); - emitSignatureAndBody(accessors.getAccessor); - emitEnd(accessors.getAccessor); - emitTrailingComments(accessors.getAccessor); - write(","); - } - if (accessors.setAccessor) { - writeLine(); - emitLeadingComments(accessors.setAccessor); - write("set: "); - emitStart(accessors.setAccessor); - write("function "); - emitSignatureAndBody(accessors.setAccessor); - emitEnd(accessors.setAccessor); - emitTrailingComments(accessors.setAccessor); - write(","); - } - writeLine(); - write("enumerable: true,"); - writeLine(); - write("configurable: true"); - decreaseIndent(); - writeLine(); - write("});"); - emitEnd(member); - } - } - }); - } - function emitMemberFunctionsForES6AndHigher(node) { - for (var _a = 0, _b = node.members; _a < _b.length; _a++) { - var member = _b[_a]; - if ((member.kind === 143 /* MethodDeclaration */ || node.kind === 142 /* MethodSignature */) && !member.body) { - emitCommentsOnNotEmittedNode(member); - } - else if (member.kind === 143 /* MethodDeclaration */ || - member.kind === 145 /* GetAccessor */ || - member.kind === 146 /* SetAccessor */) { - writeLine(); - emitLeadingComments(member); - emitStart(member); - if (member.flags & 128 /* Static */) { - write("static "); - } - if (member.kind === 145 /* GetAccessor */) { - write("get "); - } - else if (member.kind === 146 /* SetAccessor */) { - write("set "); - } - if (member.asteriskToken) { - write("*"); - } - emit(member.name); - emitSignatureAndBody(member); - emitEnd(member); - emitTrailingComments(member); - } - else if (member.kind === 191 /* SemicolonClassElement */) { - writeLine(); - write(";"); - } - } - } - function emitConstructor(node, baseTypeElement) { - var saveTempFlags = tempFlags; - var saveTempVariables = tempVariables; - var saveTempParameters = tempParameters; - tempFlags = 0; - tempVariables = undefined; - tempParameters = undefined; - emitConstructorWorker(node, baseTypeElement); - tempFlags = saveTempFlags; - tempVariables = saveTempVariables; - tempParameters = saveTempParameters; - } - function emitConstructorWorker(node, baseTypeElement) { - // Check if we have property assignment inside class declaration. - // If there is property assignment, we need to emit constructor whether users define it or not - // If there is no property assignment, we can omit constructor if users do not define it - var hasInstancePropertyWithInitializer = false; - // Emit the constructor overload pinned comments - ts.forEach(node.members, function (member) { - if (member.kind === 144 /* Constructor */ && !member.body) { - emitCommentsOnNotEmittedNode(member); - } - // Check if there is any non-static property assignment - if (member.kind === 141 /* PropertyDeclaration */ && member.initializer && (member.flags & 128 /* Static */) === 0) { - hasInstancePropertyWithInitializer = true; - } - }); - var ctor = ts.getFirstConstructorWithBody(node); - // For target ES6 and above, if there is no user-defined constructor and there is no property assignment - // do not emit constructor in class declaration. - if (languageVersion >= 2 /* ES6 */ && !ctor && !hasInstancePropertyWithInitializer) { - return; - } - if (ctor) { - emitLeadingComments(ctor); - } - emitStart(ctor || node); - if (languageVersion < 2 /* ES6 */) { - write("function "); - emitDeclarationName(node); - emitSignatureParameters(ctor); - } - else { - write("constructor"); - if (ctor) { - emitSignatureParameters(ctor); - } - else { - // Based on EcmaScript6 section 14.5.14: Runtime Semantics: ClassDefinitionEvaluation. - // If constructor is empty, then, - // If ClassHeritageopt is present, then - // Let constructor be the result of parsing the String "constructor(... args){ super (...args);}" using the syntactic grammar with the goal symbol MethodDefinition. - // Else, - // Let constructor be the result of parsing the String "constructor( ){ }" using the syntactic grammar with the goal symbol MethodDefinition - if (baseTypeElement) { - write("(...args)"); - } - else { - write("()"); - } - } - } - var startIndex = 0; - write(" {"); - scopeEmitStart(node, "constructor"); - increaseIndent(); - if (ctor) { - // Emit all the directive prologues (like "use strict"). These have to come before - // any other preamble code we write (like parameter initializers). - startIndex = emitDirectivePrologues(ctor.body.statements, /*startWithNewLine*/ true); - emitDetachedComments(ctor.body.statements); - } - emitCaptureThisForNodeIfNecessary(node); - var superCall; - if (ctor) { - emitDefaultValueAssignments(ctor); - emitRestParameter(ctor); - if (baseTypeElement) { - superCall = findInitialSuperCall(ctor); - if (superCall) { - writeLine(); - emit(superCall); - } - } - emitParameterPropertyAssignments(ctor); - } - else { - if (baseTypeElement) { - writeLine(); - emitStart(baseTypeElement); - if (languageVersion < 2 /* ES6 */) { - write("_super.apply(this, arguments);"); - } - else { - write("super(...args);"); - } - emitEnd(baseTypeElement); - } - } - emitPropertyDeclarations(node, getInitializedProperties(node, /*static:*/ false)); - if (ctor) { - var statements = ctor.body.statements; - if (superCall) { - statements = statements.slice(1); - } - emitLinesStartingAt(statements, startIndex); - } - emitTempDeclarations(/*newLine*/ true); - writeLine(); - if (ctor) { - emitLeadingCommentsOfPosition(ctor.body.statements.end); - } - decreaseIndent(); - emitToken(16 /* CloseBraceToken */, ctor ? ctor.body.statements.end : node.members.end); - scopeEmitEnd(); - emitEnd(ctor || node); - if (ctor) { - emitTrailingComments(ctor); - } - } - function emitClassExpression(node) { - return emitClassLikeDeclaration(node); - } - function emitClassDeclaration(node) { - return emitClassLikeDeclaration(node); - } - function emitClassLikeDeclaration(node) { - if (languageVersion < 2 /* ES6 */) { - emitClassLikeDeclarationBelowES6(node); - } - else { - emitClassLikeDeclarationForES6AndHigher(node); - } - if (modulekind !== 5 /* ES6 */ && node.parent === currentSourceFile && node.name) { - emitExportMemberAssignments(node.name); - } - } - function emitClassLikeDeclarationForES6AndHigher(node) { - var thisNodeIsDecorated = ts.nodeIsDecorated(node); - if (node.kind === 214 /* ClassDeclaration */) { - if (thisNodeIsDecorated) { - // To preserve the correct runtime semantics when decorators are applied to the class, - // the emit needs to follow one of the following rules: - // - // * For a local class declaration: - // - // @dec class C { - // } - // - // The emit should be: - // - // let C = class { - // }; - // C = __decorate([dec], C); - // - // * For an exported class declaration: - // - // @dec export class C { - // } - // - // The emit should be: - // - // export let C = class { - // }; - // C = __decorate([dec], C); - // - // * For a default export of a class declaration with a name: - // - // @dec default export class C { - // } - // - // The emit should be: - // - // let C = class { - // } - // C = __decorate([dec], C); - // export default C; - // - // * For a default export of a class declaration without a name: - // - // @dec default export class { - // } - // - // The emit should be: - // - // let _default = class { - // } - // _default = __decorate([dec], _default); - // export default _default; - // - if (isES6ExportedDeclaration(node) && !(node.flags & 1024 /* Default */)) { - write("export "); - } - write("let "); - emitDeclarationName(node); - write(" = "); - } - else if (isES6ExportedDeclaration(node)) { - write("export "); - if (node.flags & 1024 /* Default */) { - write("default "); - } - } - } - // If the class has static properties, and it's a class expression, then we'll need - // to specialize the emit a bit. for a class expression of the form: - // - // class C { static a = 1; static b = 2; ... } - // - // We'll emit: - // - // (_temp = class C { ... }, _temp.a = 1, _temp.b = 2, _temp) - // - // This keeps the expression as an expression, while ensuring that the static parts - // of it have been initialized by the time it is used. - var staticProperties = getInitializedProperties(node, /*static:*/ true); - var isClassExpressionWithStaticProperties = staticProperties.length > 0 && node.kind === 186 /* ClassExpression */; - var tempVariable; - if (isClassExpressionWithStaticProperties) { - tempVariable = createAndRecordTempVariable(0 /* Auto */); - write("("); - increaseIndent(); - emit(tempVariable); - write(" = "); - } - write("class"); - // emit name if - // - node has a name - // - this is default export with static initializers - if ((node.name || (node.flags & 1024 /* Default */ && staticProperties.length > 0)) && !thisNodeIsDecorated) { - write(" "); - emitDeclarationName(node); - } - var baseTypeNode = ts.getClassExtendsHeritageClauseElement(node); - if (baseTypeNode) { - write(" extends "); - emit(baseTypeNode.expression); - } - write(" {"); - increaseIndent(); - scopeEmitStart(node); - writeLine(); - emitConstructor(node, baseTypeNode); - emitMemberFunctionsForES6AndHigher(node); - decreaseIndent(); - writeLine(); - emitToken(16 /* CloseBraceToken */, node.members.end); - scopeEmitEnd(); - // TODO(rbuckton): Need to go back to `let _a = class C {}` approach, removing the defineProperty call for now. - // For a decorated class, we need to assign its name (if it has one). This is because we emit - // the class as a class expression to avoid the double-binding of the identifier: - // - // let C = class { - // } - // Object.defineProperty(C, "name", { value: "C", configurable: true }); - // - if (thisNodeIsDecorated) { - write(";"); - } - // Emit static property assignment. Because classDeclaration is lexically evaluated, - // it is safe to emit static property assignment after classDeclaration - // From ES6 specification: - // 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 (isClassExpressionWithStaticProperties) { - for (var _a = 0; _a < staticProperties.length; _a++) { - var property = staticProperties[_a]; - write(","); - writeLine(); - emitPropertyDeclaration(node, property, /*receiver:*/ tempVariable, /*isExpression:*/ true); - } - write(","); - writeLine(); - emit(tempVariable); - decreaseIndent(); - write(")"); - } - else { - writeLine(); - emitPropertyDeclarations(node, staticProperties); - emitDecoratorsOfClass(node); - } - // If this is an exported class, but not on the top level (i.e. on an internal - // module), export it - if (!isES6ExportedDeclaration(node) && (node.flags & 1 /* Export */)) { - writeLine(); - emitStart(node); - emitModuleMemberName(node); - write(" = "); - emitDeclarationName(node); - emitEnd(node); - write(";"); - } - else if (isES6ExportedDeclaration(node) && (node.flags & 1024 /* Default */) && thisNodeIsDecorated) { - // if this is a top level default export of decorated class, write the export after the declaration. - writeLine(); - write("export default "); - emitDeclarationName(node); - write(";"); - } - } - function emitClassLikeDeclarationBelowES6(node) { - if (node.kind === 214 /* ClassDeclaration */) { - // source file level classes in system modules are hoisted so 'var's for them are already defined - if (!shouldHoistDeclarationInSystemJsModule(node)) { - write("var "); - } - emitDeclarationName(node); - write(" = "); - } - write("(function ("); - var baseTypeNode = ts.getClassExtendsHeritageClauseElement(node); - if (baseTypeNode) { - write("_super"); - } - write(") {"); - var saveTempFlags = tempFlags; - var saveTempVariables = tempVariables; - var saveTempParameters = tempParameters; - var saveComputedPropertyNamesToGeneratedNames = computedPropertyNamesToGeneratedNames; - tempFlags = 0; - tempVariables = undefined; - tempParameters = undefined; - computedPropertyNamesToGeneratedNames = undefined; - increaseIndent(); - scopeEmitStart(node); - if (baseTypeNode) { - writeLine(); - emitStart(baseTypeNode); - write("__extends("); - emitDeclarationName(node); - write(", _super);"); - emitEnd(baseTypeNode); - } - writeLine(); - emitConstructor(node, baseTypeNode); - emitMemberFunctionsForES5AndLower(node); - emitPropertyDeclarations(node, getInitializedProperties(node, /*static:*/ true)); - writeLine(); - emitDecoratorsOfClass(node); - writeLine(); - emitToken(16 /* CloseBraceToken */, node.members.end, function () { - write("return "); - emitDeclarationName(node); - }); - write(";"); - emitTempDeclarations(/*newLine*/ true); - tempFlags = saveTempFlags; - tempVariables = saveTempVariables; - tempParameters = saveTempParameters; - computedPropertyNamesToGeneratedNames = saveComputedPropertyNamesToGeneratedNames; - decreaseIndent(); - writeLine(); - emitToken(16 /* CloseBraceToken */, node.members.end); - scopeEmitEnd(); - emitStart(node); - write(")("); - if (baseTypeNode) { - emit(baseTypeNode.expression); - } - write(")"); - if (node.kind === 214 /* ClassDeclaration */) { - write(";"); - } - emitEnd(node); - if (node.kind === 214 /* ClassDeclaration */) { - emitExportMemberAssignment(node); - } - } - function emitClassMemberPrefix(node, member) { - emitDeclarationName(node); - if (!(member.flags & 128 /* Static */)) { - write(".prototype"); - } - } - function emitDecoratorsOfClass(node) { - emitDecoratorsOfMembers(node, /*staticFlag*/ 0); - emitDecoratorsOfMembers(node, 128 /* Static */); - emitDecoratorsOfConstructor(node); - } - function emitDecoratorsOfConstructor(node) { - var decorators = node.decorators; - var constructor = ts.getFirstConstructorWithBody(node); - var hasDecoratedParameters = constructor && ts.forEach(constructor.parameters, ts.nodeIsDecorated); - // skip decoration of the constructor if neither it nor its parameters are decorated - if (!decorators && !hasDecoratedParameters) { - return; - } - // Emit the call to __decorate. Given the class: - // - // @dec - // class C { - // } - // - // The emit for the class is: - // - // C = __decorate([dec], C); - // - writeLine(); - emitStart(node); - emitDeclarationName(node); - write(" = __decorate(["); - increaseIndent(); - writeLine(); - var decoratorCount = decorators ? decorators.length : 0; - var argumentsWritten = emitList(decorators, 0, decoratorCount, /*multiLine*/ true, /*trailingComma*/ false, /*leadingComma*/ false, /*noTrailingNewLine*/ true, function (decorator) { - emitStart(decorator); - emit(decorator.expression); - emitEnd(decorator); - }); - argumentsWritten += emitDecoratorsOfParameters(constructor, /*leadingComma*/ argumentsWritten > 0); - emitSerializedTypeMetadata(node, /*leadingComma*/ argumentsWritten >= 0); - decreaseIndent(); - writeLine(); - write("], "); - emitDeclarationName(node); - write(");"); - emitEnd(node); - writeLine(); - } - function emitDecoratorsOfMembers(node, staticFlag) { - for (var _a = 0, _b = node.members; _a < _b.length; _a++) { - var member = _b[_a]; - // only emit members in the correct group - if ((member.flags & 128 /* Static */) !== staticFlag) { - continue; - } - // skip members that cannot be decorated (such as the constructor) - if (!ts.nodeCanBeDecorated(member)) { - continue; - } - // skip a member if it or any of its parameters are not decorated - if (!ts.nodeOrChildIsDecorated(member)) { - continue; - } - // skip an accessor declaration if it is not the first accessor - var decorators = void 0; - var functionLikeMember = void 0; - if (ts.isAccessor(member)) { - var accessors = ts.getAllAccessorDeclarations(node.members, member); - if (member !== accessors.firstAccessor) { - continue; - } - // get the decorators from the first accessor with decorators - decorators = accessors.firstAccessor.decorators; - if (!decorators && accessors.secondAccessor) { - decorators = accessors.secondAccessor.decorators; - } - // we only decorate parameters of the set accessor - functionLikeMember = accessors.setAccessor; - } - else { - decorators = member.decorators; - // we only decorate the parameters here if this is a method - if (member.kind === 143 /* MethodDeclaration */) { - functionLikeMember = member; - } - } - // Emit the call to __decorate. Given the following: - // - // class C { - // @dec method(@dec2 x) {} - // @dec get accessor() {} - // @dec prop; - // } - // - // The emit for a method is: - // - // __decorate([ - // dec, - // __param(0, dec2), - // __metadata("design:type", Function), - // __metadata("design:paramtypes", [Object]), - // __metadata("design:returntype", void 0) - // ], C.prototype, "method", undefined); - // - // The emit for an accessor is: - // - // __decorate([ - // dec - // ], C.prototype, "accessor", undefined); - // - // The emit for a property is: - // - // __decorate([ - // dec - // ], C.prototype, "prop"); - // - writeLine(); - emitStart(member); - write("__decorate(["); - increaseIndent(); - writeLine(); - var decoratorCount = decorators ? decorators.length : 0; - var argumentsWritten = emitList(decorators, 0, decoratorCount, /*multiLine*/ true, /*trailingComma*/ false, /*leadingComma*/ false, /*noTrailingNewLine*/ true, function (decorator) { - emitStart(decorator); - emit(decorator.expression); - emitEnd(decorator); - }); - argumentsWritten += emitDecoratorsOfParameters(functionLikeMember, argumentsWritten > 0); - emitSerializedTypeMetadata(member, argumentsWritten > 0); - decreaseIndent(); - writeLine(); - write("], "); - emitStart(member.name); - emitClassMemberPrefix(node, member); - write(", "); - emitExpressionForPropertyName(member.name); - emitEnd(member.name); - if (languageVersion > 0 /* ES3 */) { - if (member.kind !== 141 /* PropertyDeclaration */) { - // We emit `null` here to indicate to `__decorate` that it can invoke `Object.getOwnPropertyDescriptor` directly. - // We have this extra argument here so that we can inject an explicit property descriptor at a later date. - write(", null"); - } - else { - // We emit `void 0` here to indicate to `__decorate` that it can invoke `Object.defineProperty` directly, but that it - // should not invoke `Object.getOwnPropertyDescriptor`. - write(", void 0"); - } - } - write(");"); - emitEnd(member); - writeLine(); - } - } - function emitDecoratorsOfParameters(node, leadingComma) { - var argumentsWritten = 0; - if (node) { - var parameterIndex = 0; - for (var _a = 0, _b = node.parameters; _a < _b.length; _a++) { - var parameter = _b[_a]; - if (ts.nodeIsDecorated(parameter)) { - var decorators = parameter.decorators; - argumentsWritten += emitList(decorators, 0, decorators.length, /*multiLine*/ true, /*trailingComma*/ false, /*leadingComma*/ leadingComma, /*noTrailingNewLine*/ true, function (decorator) { - emitStart(decorator); - write("__param(" + parameterIndex + ", "); - emit(decorator.expression); - write(")"); - emitEnd(decorator); - }); - leadingComma = true; - } - ++parameterIndex; - } - } - return argumentsWritten; - } - function shouldEmitTypeMetadata(node) { - // This method determines whether to emit the "design:type" metadata based on the node's kind. - // The caller should have already tested whether the node has decorators and whether the emitDecoratorMetadata - // compiler option is set. - switch (node.kind) { - case 143 /* MethodDeclaration */: - case 145 /* GetAccessor */: - case 146 /* SetAccessor */: - case 141 /* PropertyDeclaration */: - return true; - } - return false; - } - function shouldEmitReturnTypeMetadata(node) { - // This method determines whether to emit the "design:returntype" metadata based on the node's kind. - // The caller should have already tested whether the node has decorators and whether the emitDecoratorMetadata - // compiler option is set. - switch (node.kind) { - case 143 /* MethodDeclaration */: - return true; - } - return false; - } - function shouldEmitParamTypesMetadata(node) { - // This method determines whether to emit the "design:paramtypes" metadata based on the node's kind. - // The caller should have already tested whether the node has decorators and whether the emitDecoratorMetadata - // compiler option is set. - switch (node.kind) { - case 214 /* ClassDeclaration */: - case 143 /* MethodDeclaration */: - case 146 /* SetAccessor */: - return true; - } - return false; - } - /** Serializes the type of a declaration to an appropriate JS constructor value. Used by the __metadata decorator for a class member. */ - function emitSerializedTypeOfNode(node) { - // serialization of the type of a declaration uses the following rules: - // - // * The serialized type of a ClassDeclaration is "Function" - // * The serialized type of a ParameterDeclaration is the serialized type of its type annotation. - // * The serialized type of a PropertyDeclaration is the serialized type of its type annotation. - // * The serialized type of an AccessorDeclaration is the serialized type of the return type annotation of its getter or parameter type annotation of its setter. - // * The serialized type of any other FunctionLikeDeclaration is "Function". - // * The serialized type of any other node is "void 0". - // - // For rules on serializing type annotations, see `serializeTypeNode`. - switch (node.kind) { - case 214 /* ClassDeclaration */: - write("Function"); - return; - case 141 /* PropertyDeclaration */: - emitSerializedTypeNode(node.type); - return; - case 138 /* Parameter */: - emitSerializedTypeNode(node.type); - return; - case 145 /* GetAccessor */: - emitSerializedTypeNode(node.type); - return; - case 146 /* SetAccessor */: - emitSerializedTypeNode(ts.getSetAccessorTypeAnnotationNode(node)); - return; - } - if (ts.isFunctionLike(node)) { - write("Function"); - return; - } - write("void 0"); - } - function emitSerializedTypeNode(node) { - if (node) { - switch (node.kind) { - case 103 /* VoidKeyword */: - write("void 0"); - return; - case 160 /* ParenthesizedType */: - emitSerializedTypeNode(node.type); - return; - case 152 /* FunctionType */: - case 153 /* ConstructorType */: - write("Function"); - return; - case 156 /* ArrayType */: - case 157 /* TupleType */: - write("Array"); - return; - case 150 /* TypePredicate */: - case 120 /* BooleanKeyword */: - write("Boolean"); - return; - case 130 /* StringKeyword */: - case 9 /* StringLiteral */: - write("String"); - return; - case 128 /* NumberKeyword */: - write("Number"); - return; - case 131 /* SymbolKeyword */: - write("Symbol"); - return; - case 151 /* TypeReference */: - emitSerializedTypeReferenceNode(node); - return; - case 154 /* TypeQuery */: - case 155 /* TypeLiteral */: - case 158 /* UnionType */: - case 159 /* IntersectionType */: - case 117 /* AnyKeyword */: - break; - default: - ts.Debug.fail("Cannot serialize unexpected type node."); - break; - } - } - write("Object"); - } - /** Serializes a TypeReferenceNode to an appropriate JS constructor value. Used by the __metadata decorator. */ - function emitSerializedTypeReferenceNode(node) { - var location = node.parent; - while (ts.isDeclaration(location) || ts.isTypeNode(location)) { - location = location.parent; - } - // Clone the type name and parent it to a location outside of the current declaration. - var typeName = ts.cloneEntityName(node.typeName); - typeName.parent = location; - var result = resolver.getTypeReferenceSerializationKind(typeName); - switch (result) { - case ts.TypeReferenceSerializationKind.Unknown: - var temp = createAndRecordTempVariable(0 /* Auto */); - write("(typeof ("); - emitNodeWithoutSourceMap(temp); - write(" = "); - emitEntityNameAsExpression(typeName, /*useFallback*/ true); - write(") === 'function' && "); - emitNodeWithoutSourceMap(temp); - write(") || Object"); - break; - case ts.TypeReferenceSerializationKind.TypeWithConstructSignatureAndValue: - emitEntityNameAsExpression(typeName, /*useFallback*/ false); - break; - case ts.TypeReferenceSerializationKind.VoidType: - write("void 0"); - break; - case ts.TypeReferenceSerializationKind.BooleanType: - write("Boolean"); - break; - case ts.TypeReferenceSerializationKind.NumberLikeType: - write("Number"); - break; - case ts.TypeReferenceSerializationKind.StringLikeType: - write("String"); - break; - case ts.TypeReferenceSerializationKind.ArrayLikeType: - write("Array"); - break; - case ts.TypeReferenceSerializationKind.ESSymbolType: - if (languageVersion < 2 /* ES6 */) { - write("typeof Symbol === 'function' ? Symbol : Object"); - } - else { - write("Symbol"); - } - break; - case ts.TypeReferenceSerializationKind.TypeWithCallSignature: - write("Function"); - break; - case ts.TypeReferenceSerializationKind.ObjectType: - write("Object"); - break; - } - } - /** Serializes the parameter types of a function or the constructor of a class. Used by the __metadata decorator for a method or set accessor. */ - function emitSerializedParameterTypesOfNode(node) { - // serialization of parameter types uses the following rules: - // - // * If the declaration is a class, the parameters of the first constructor with a body are used. - // * If the declaration is function-like and has a body, the parameters of the function are used. - // - // For the rules on serializing the type of each parameter declaration, see `serializeTypeOfDeclaration`. - if (node) { - var valueDeclaration; - if (node.kind === 214 /* ClassDeclaration */) { - valueDeclaration = ts.getFirstConstructorWithBody(node); - } - else if (ts.isFunctionLike(node) && ts.nodeIsPresent(node.body)) { - valueDeclaration = node; - } - if (valueDeclaration) { - var parameters = valueDeclaration.parameters; - var parameterCount = parameters.length; - if (parameterCount > 0) { - for (var i = 0; i < parameterCount; i++) { - if (i > 0) { - write(", "); - } - if (parameters[i].dotDotDotToken) { - var parameterType = parameters[i].type; - if (parameterType.kind === 156 /* ArrayType */) { - parameterType = parameterType.elementType; - } - else if (parameterType.kind === 151 /* TypeReference */ && parameterType.typeArguments && parameterType.typeArguments.length === 1) { - parameterType = parameterType.typeArguments[0]; - } - else { - parameterType = undefined; - } - emitSerializedTypeNode(parameterType); - } - else { - emitSerializedTypeOfNode(parameters[i]); - } - } - } - } - } - } - /** Serializes the return type of function. Used by the __metadata decorator for a method. */ - function emitSerializedReturnTypeOfNode(node) { - if (node && ts.isFunctionLike(node) && node.type) { - emitSerializedTypeNode(node.type); - return; - } - write("void 0"); - } - function emitSerializedTypeMetadata(node, writeComma) { - // This method emits the serialized type metadata for a decorator target. - // The caller should have already tested whether the node has decorators. - var argumentsWritten = 0; - if (compilerOptions.emitDecoratorMetadata) { - if (shouldEmitTypeMetadata(node)) { - if (writeComma) { - write(", "); - } - writeLine(); - write("__metadata('design:type', "); - emitSerializedTypeOfNode(node); - write(")"); - argumentsWritten++; - } - if (shouldEmitParamTypesMetadata(node)) { - if (writeComma || argumentsWritten) { - write(", "); - } - writeLine(); - write("__metadata('design:paramtypes', ["); - emitSerializedParameterTypesOfNode(node); - write("])"); - argumentsWritten++; - } - if (shouldEmitReturnTypeMetadata(node)) { - if (writeComma || argumentsWritten) { - write(", "); - } - writeLine(); - write("__metadata('design:returntype', "); - emitSerializedReturnTypeOfNode(node); - write(")"); - argumentsWritten++; - } - } - return argumentsWritten; - } - function emitInterfaceDeclaration(node) { - emitCommentsOnNotEmittedNode(node); - } - function shouldEmitEnumDeclaration(node) { - var isConstEnum = ts.isConst(node); - return !isConstEnum || compilerOptions.preserveConstEnums || compilerOptions.isolatedModules; - } - function emitEnumDeclaration(node) { - // const enums are completely erased during compilation. - if (!shouldEmitEnumDeclaration(node)) { - return; - } - if (!shouldHoistDeclarationInSystemJsModule(node)) { - // do not emit var if variable was already hoisted - if (!(node.flags & 1 /* Export */) || isES6ExportedDeclaration(node)) { - emitStart(node); - if (isES6ExportedDeclaration(node)) { - write("export "); - } - write("var "); - emit(node.name); - emitEnd(node); - write(";"); - } - } - writeLine(); - emitStart(node); - write("(function ("); - emitStart(node.name); - write(getGeneratedNameForNode(node)); - emitEnd(node.name); - write(") {"); - increaseIndent(); - scopeEmitStart(node); - emitLines(node.members); - decreaseIndent(); - writeLine(); - emitToken(16 /* CloseBraceToken */, node.members.end); - scopeEmitEnd(); - write(")("); - emitModuleMemberName(node); - write(" || ("); - emitModuleMemberName(node); - write(" = {}));"); - emitEnd(node); - if (!isES6ExportedDeclaration(node) && node.flags & 1 /* Export */ && !shouldHoistDeclarationInSystemJsModule(node)) { - // do not emit var if variable was already hoisted - writeLine(); - emitStart(node); - write("var "); - emit(node.name); - write(" = "); - emitModuleMemberName(node); - emitEnd(node); - write(";"); - } - if (modulekind !== 5 /* ES6 */ && node.parent === currentSourceFile) { - if (modulekind === 4 /* System */ && (node.flags & 1 /* Export */)) { - // write the call to exporter for enum - writeLine(); - write(exportFunctionForFile + "(\""); - emitDeclarationName(node); - write("\", "); - emitDeclarationName(node); - write(");"); - } - emitExportMemberAssignments(node.name); - } - } - function emitEnumMember(node) { - var enumParent = node.parent; - emitStart(node); - write(getGeneratedNameForNode(enumParent)); - write("["); - write(getGeneratedNameForNode(enumParent)); - write("["); - emitExpressionForPropertyName(node.name); - write("] = "); - writeEnumMemberDeclarationValue(node); - write("] = "); - emitExpressionForPropertyName(node.name); - emitEnd(node); - write(";"); - } - function writeEnumMemberDeclarationValue(member) { - var value = resolver.getConstantValue(member); - if (value !== undefined) { - write(value.toString()); - return; - } - else if (member.initializer) { - emit(member.initializer); - } - else { - write("undefined"); - } - } - function getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration) { - if (moduleDeclaration.body.kind === 218 /* ModuleDeclaration */) { - var recursiveInnerModule = getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration.body); - return recursiveInnerModule || moduleDeclaration.body; - } - } - function shouldEmitModuleDeclaration(node) { - return ts.isInstantiatedModule(node, compilerOptions.preserveConstEnums || compilerOptions.isolatedModules); - } - function isModuleMergedWithES6Class(node) { - return languageVersion === 2 /* ES6 */ && !!(resolver.getNodeCheckFlags(node) & 32768 /* LexicalModuleMergesWithClass */); - } - function emitModuleDeclaration(node) { - // Emit only if this module is non-ambient. - var shouldEmit = shouldEmitModuleDeclaration(node); - if (!shouldEmit) { - return emitCommentsOnNotEmittedNode(node); - } - var hoistedInDeclarationScope = shouldHoistDeclarationInSystemJsModule(node); - var emitVarForModule = !hoistedInDeclarationScope && !isModuleMergedWithES6Class(node); - if (emitVarForModule) { - emitStart(node); - if (isES6ExportedDeclaration(node)) { - write("export "); - } - write("var "); - emit(node.name); - write(";"); - emitEnd(node); - writeLine(); - } - emitStart(node); - write("(function ("); - emitStart(node.name); - write(getGeneratedNameForNode(node)); - emitEnd(node.name); - write(") "); - if (node.body.kind === 219 /* ModuleBlock */) { - var saveTempFlags = tempFlags; - var saveTempVariables = tempVariables; - tempFlags = 0; - tempVariables = undefined; - emit(node.body); - tempFlags = saveTempFlags; - tempVariables = saveTempVariables; - } - else { - write("{"); - increaseIndent(); - scopeEmitStart(node); - emitCaptureThisForNodeIfNecessary(node); - writeLine(); - emit(node.body); - decreaseIndent(); - writeLine(); - var moduleBlock = getInnerMostModuleDeclarationFromDottedModule(node).body; - emitToken(16 /* CloseBraceToken */, moduleBlock.statements.end); - scopeEmitEnd(); - } - write(")("); - // write moduleDecl = containingModule.m only if it is not exported es6 module member - if ((node.flags & 1 /* Export */) && !isES6ExportedDeclaration(node)) { - emit(node.name); - write(" = "); - } - emitModuleMemberName(node); - write(" || ("); - emitModuleMemberName(node); - write(" = {}));"); - emitEnd(node); - if (!isES6ExportedDeclaration(node) && node.name.kind === 69 /* Identifier */ && node.parent === currentSourceFile) { - if (modulekind === 4 /* System */ && (node.flags & 1 /* Export */)) { - writeLine(); - write(exportFunctionForFile + "(\""); - emitDeclarationName(node); - write("\", "); - emitDeclarationName(node); - write(");"); - } - emitExportMemberAssignments(node.name); - } - } - /* - * Some bundlers (SystemJS builder) sometimes want to rename dependencies. - * Here we check if alternative name was provided for a given moduleName and return it if possible. - */ - function tryRenameExternalModule(moduleName) { - if (currentSourceFile.renamedDependencies && ts.hasProperty(currentSourceFile.renamedDependencies, moduleName.text)) { - return "\"" + currentSourceFile.renamedDependencies[moduleName.text] + "\""; - } - return undefined; - } - function emitRequire(moduleName) { - if (moduleName.kind === 9 /* StringLiteral */) { - write("require("); - var text = tryRenameExternalModule(moduleName); - if (text) { - write(text); - } - else { - emitStart(moduleName); - emitLiteral(moduleName); - emitEnd(moduleName); - } - emitToken(18 /* CloseParenToken */, moduleName.end); - } - else { - write("require()"); - } - } - function getNamespaceDeclarationNode(node) { - if (node.kind === 221 /* ImportEqualsDeclaration */) { - return node; - } - var importClause = node.importClause; - if (importClause && importClause.namedBindings && importClause.namedBindings.kind === 224 /* NamespaceImport */) { - return importClause.namedBindings; - } - } - function isDefaultImport(node) { - return node.kind === 222 /* ImportDeclaration */ && node.importClause && !!node.importClause.name; - } - function emitExportImportAssignments(node) { - if (ts.isAliasSymbolDeclaration(node) && resolver.isValueAliasDeclaration(node)) { - emitExportMemberAssignments(node.name); - } - ts.forEachChild(node, emitExportImportAssignments); - } - function emitImportDeclaration(node) { - if (modulekind !== 5 /* ES6 */) { - return emitExternalImportDeclaration(node); - } - // ES6 import - if (node.importClause) { - var shouldEmitDefaultBindings = resolver.isReferencedAliasDeclaration(node.importClause); - var shouldEmitNamedBindings = node.importClause.namedBindings && resolver.isReferencedAliasDeclaration(node.importClause.namedBindings, /* checkChildren */ true); - if (shouldEmitDefaultBindings || shouldEmitNamedBindings) { - write("import "); - emitStart(node.importClause); - if (shouldEmitDefaultBindings) { - emit(node.importClause.name); - if (shouldEmitNamedBindings) { - write(", "); - } - } - if (shouldEmitNamedBindings) { - emitLeadingComments(node.importClause.namedBindings); - emitStart(node.importClause.namedBindings); - if (node.importClause.namedBindings.kind === 224 /* NamespaceImport */) { - write("* as "); - emit(node.importClause.namedBindings.name); - } - else { - write("{ "); - emitExportOrImportSpecifierList(node.importClause.namedBindings.elements, resolver.isReferencedAliasDeclaration); - write(" }"); - } - emitEnd(node.importClause.namedBindings); - emitTrailingComments(node.importClause.namedBindings); - } - emitEnd(node.importClause); - write(" from "); - emit(node.moduleSpecifier); - write(";"); - } - } - else { - write("import "); - emit(node.moduleSpecifier); - write(";"); - } - } - function emitExternalImportDeclaration(node) { - if (ts.contains(externalImports, node)) { - var isExportedImport = node.kind === 221 /* ImportEqualsDeclaration */ && (node.flags & 1 /* Export */) !== 0; - var namespaceDeclaration = getNamespaceDeclarationNode(node); - if (modulekind !== 2 /* AMD */) { - emitLeadingComments(node); - emitStart(node); - if (namespaceDeclaration && !isDefaultImport(node)) { - // import x = require("foo") - // import * as x from "foo" - if (!isExportedImport) - write("var "); - emitModuleMemberName(namespaceDeclaration); - write(" = "); - } - else { - // import "foo" - // import x from "foo" - // import { x, y } from "foo" - // import d, * as x from "foo" - // import d, { x, y } from "foo" - var isNakedImport = 222 /* ImportDeclaration */ && !node.importClause; - if (!isNakedImport) { - write("var "); - write(getGeneratedNameForNode(node)); - write(" = "); - } - } - emitRequire(ts.getExternalModuleName(node)); - if (namespaceDeclaration && isDefaultImport(node)) { - // import d, * as x from "foo" - write(", "); - emitModuleMemberName(namespaceDeclaration); - write(" = "); - write(getGeneratedNameForNode(node)); - } - write(";"); - emitEnd(node); - emitExportImportAssignments(node); - emitTrailingComments(node); - } - else { - if (isExportedImport) { - emitModuleMemberName(namespaceDeclaration); - write(" = "); - emit(namespaceDeclaration.name); - write(";"); - } - else if (namespaceDeclaration && isDefaultImport(node)) { - // import d, * as x from "foo" - write("var "); - emitModuleMemberName(namespaceDeclaration); - write(" = "); - write(getGeneratedNameForNode(node)); - write(";"); - } - emitExportImportAssignments(node); - } - } - } - function emitImportEqualsDeclaration(node) { - if (ts.isExternalModuleImportEqualsDeclaration(node)) { - emitExternalImportDeclaration(node); - return; - } - // preserve old compiler's behavior: emit 'var' for import declaration (even if we do not consider them referenced) when - // - current file is not external module - // - import declaration is top level and target is value imported by entity name - if (resolver.isReferencedAliasDeclaration(node) || - (!ts.isExternalModule(currentSourceFile) && resolver.isTopLevelValueImportEqualsWithEntityName(node))) { - emitLeadingComments(node); - emitStart(node); - // variable declaration for import-equals declaration can be hoisted in system modules - // in this case 'var' should be omitted and emit should contain only initialization - var variableDeclarationIsHoisted = shouldHoistVariable(node, /*checkIfSourceFileLevelDecl*/ true); - // is it top level export import v = a.b.c in system module? - // if yes - it needs to be rewritten as exporter('v', v = a.b.c) - var isExported = isSourceFileLevelDeclarationInSystemJsModule(node, /*isExported*/ true); - if (!variableDeclarationIsHoisted) { - ts.Debug.assert(!isExported); - if (isES6ExportedDeclaration(node)) { - write("export "); - write("var "); - } - else if (!(node.flags & 1 /* Export */)) { - write("var "); - } - } - if (isExported) { - write(exportFunctionForFile + "(\""); - emitNodeWithoutSourceMap(node.name); - write("\", "); - } - emitModuleMemberName(node); - write(" = "); - emit(node.moduleReference); - if (isExported) { - write(")"); - } - write(";"); - emitEnd(node); - emitExportImportAssignments(node); - emitTrailingComments(node); - } - } - function emitExportDeclaration(node) { - ts.Debug.assert(modulekind !== 4 /* System */); - if (modulekind !== 5 /* ES6 */) { - if (node.moduleSpecifier && (!node.exportClause || resolver.isValueAliasDeclaration(node))) { - emitStart(node); - var generatedName = getGeneratedNameForNode(node); - if (node.exportClause) { - // export { x, y, ... } from "foo" - if (modulekind !== 2 /* AMD */) { - write("var "); - write(generatedName); - write(" = "); - emitRequire(ts.getExternalModuleName(node)); - write(";"); - } - for (var _a = 0, _b = node.exportClause.elements; _a < _b.length; _a++) { - var specifier = _b[_a]; - if (resolver.isValueAliasDeclaration(specifier)) { - writeLine(); - emitStart(specifier); - emitContainingModuleName(specifier); - write("."); - emitNodeWithCommentsAndWithoutSourcemap(specifier.name); - write(" = "); - write(generatedName); - write("."); - emitNodeWithCommentsAndWithoutSourcemap(specifier.propertyName || specifier.name); - write(";"); - emitEnd(specifier); - } - } - } - else { - // export * from "foo" - writeLine(); - write("__export("); - if (modulekind !== 2 /* AMD */) { - emitRequire(ts.getExternalModuleName(node)); - } - else { - write(generatedName); - } - write(");"); - } - emitEnd(node); - } - } - else { - if (!node.exportClause || resolver.isValueAliasDeclaration(node)) { - write("export "); - if (node.exportClause) { - // export { x, y, ... } - write("{ "); - emitExportOrImportSpecifierList(node.exportClause.elements, resolver.isValueAliasDeclaration); - write(" }"); - } - else { - write("*"); - } - if (node.moduleSpecifier) { - write(" from "); - emit(node.moduleSpecifier); - } - write(";"); - } - } - } - function emitExportOrImportSpecifierList(specifiers, shouldEmit) { - ts.Debug.assert(modulekind === 5 /* ES6 */); - var needsComma = false; - for (var _a = 0; _a < specifiers.length; _a++) { - var specifier = specifiers[_a]; - if (shouldEmit(specifier)) { - if (needsComma) { - write(", "); - } - if (specifier.propertyName) { - emit(specifier.propertyName); - write(" as "); - } - emit(specifier.name); - needsComma = true; - } - } - } - function emitExportAssignment(node) { - if (!node.isExportEquals && resolver.isValueAliasDeclaration(node)) { - if (modulekind === 5 /* ES6 */) { - writeLine(); - emitStart(node); - write("export default "); - var expression = node.expression; - emit(expression); - if (expression.kind !== 213 /* FunctionDeclaration */ && - expression.kind !== 214 /* ClassDeclaration */) { - write(";"); - } - emitEnd(node); - } - else { - writeLine(); - emitStart(node); - if (modulekind === 4 /* System */) { - write(exportFunctionForFile + "(\"default\","); - emit(node.expression); - write(")"); - } - else { - emitEs6ExportDefaultCompat(node); - emitContainingModuleName(node); - if (languageVersion === 0 /* ES3 */) { - write("[\"default\"] = "); - } - else { - write(".default = "); - } - emit(node.expression); - } - write(";"); - emitEnd(node); - } - } - } - function collectExternalModuleInfo(sourceFile) { - externalImports = []; - exportSpecifiers = {}; - exportEquals = undefined; - hasExportStars = false; - for (var _a = 0, _b = sourceFile.statements; _a < _b.length; _a++) { - var node = _b[_a]; - switch (node.kind) { - case 222 /* 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); - } - break; - case 221 /* ImportEqualsDeclaration */: - if (node.moduleReference.kind === 232 /* ExternalModuleReference */ && resolver.isReferencedAliasDeclaration(node)) { - // import x = require("mod") where x is referenced - externalImports.push(node); - } - break; - case 228 /* ExportDeclaration */: - if (node.moduleSpecifier) { - if (!node.exportClause) { - // export * from "mod" - externalImports.push(node); - hasExportStars = true; - } - else if (resolver.isValueAliasDeclaration(node)) { - // export { x, y } from "mod" where at least one export is a value symbol - externalImports.push(node); - } - } - else { - // export { x, y } - for (var _c = 0, _d = node.exportClause.elements; _c < _d.length; _c++) { - var specifier = _d[_c]; - var name_25 = (specifier.propertyName || specifier.name).text; - (exportSpecifiers[name_25] || (exportSpecifiers[name_25] = [])).push(specifier); - } - } - break; - case 227 /* ExportAssignment */: - if (node.isExportEquals && !exportEquals) { - // export = x - exportEquals = node; - } - break; - } - } - } - function emitExportStarHelper() { - if (hasExportStars) { - writeLine(); - write("function __export(m) {"); - increaseIndent(); - writeLine(); - write("for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];"); - decreaseIndent(); - writeLine(); - write("}"); - } - } - function getLocalNameForExternalImport(node) { - var namespaceDeclaration = getNamespaceDeclarationNode(node); - if (namespaceDeclaration && !isDefaultImport(node)) { - return ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, namespaceDeclaration.name); - } - if (node.kind === 222 /* ImportDeclaration */ && node.importClause) { - return getGeneratedNameForNode(node); - } - if (node.kind === 228 /* ExportDeclaration */ && node.moduleSpecifier) { - return getGeneratedNameForNode(node); - } - } - function getExternalModuleNameText(importNode) { - var moduleName = ts.getExternalModuleName(importNode); - if (moduleName.kind === 9 /* StringLiteral */) { - return tryRenameExternalModule(moduleName) || getLiteralText(moduleName); - } - return undefined; - } - function emitVariableDeclarationsForImports() { - if (externalImports.length === 0) { - return; - } - writeLine(); - var started = false; - for (var _a = 0; _a < externalImports.length; _a++) { - var importNode = externalImports[_a]; - // do not create variable declaration for exports and imports that lack import clause - var skipNode = importNode.kind === 228 /* ExportDeclaration */ || - (importNode.kind === 222 /* ImportDeclaration */ && !importNode.importClause); - if (skipNode) { - continue; - } - if (!started) { - write("var "); - started = true; - } - else { - write(", "); - } - write(getLocalNameForExternalImport(importNode)); - } - if (started) { - write(";"); - } - } - function emitLocalStorageForExportedNamesIfNecessary(exportedDeclarations) { - // 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. - if (!hasExportStars) { - // local names set is needed only in presence of star exports - return undefined; - } - // local names set should only be added if we have anything exported - if (!exportedDeclarations && 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 _a = 0; _a < externalImports.length; _a++) { - var externalImport = externalImports[_a]; - if (externalImport.kind === 228 /* ExportDeclaration */ && externalImport.exportClause) { - hasExportDeclarationWithExportClause = true; - break; - } - } - if (!hasExportDeclarationWithExportClause) { - // we still need to emit exportStar helper - return emitExportStarFunction(/*localNames*/ undefined); - } - } - var exportedNamesStorageRef = makeUniqueName("exportedNames"); - writeLine(); - write("var " + exportedNamesStorageRef + " = {"); - increaseIndent(); - var started = false; - if (exportedDeclarations) { - for (var i = 0; i < exportedDeclarations.length; ++i) { - // write name of exported declaration, i.e 'export var x...' - writeExportedName(exportedDeclarations[i]); - } - } - if (exportSpecifiers) { - for (var n in exportSpecifiers) { - for (var _b = 0, _c = exportSpecifiers[n]; _b < _c.length; _b++) { - var specifier = _c[_b]; - // write name of export specified, i.e. 'export {x}' - writeExportedName(specifier.name); - } - } - } - for (var _d = 0; _d < externalImports.length; _d++) { - var externalImport = externalImports[_d]; - if (externalImport.kind !== 228 /* ExportDeclaration */) { - continue; - } - var exportDecl = externalImport; - if (!exportDecl.exportClause) { - // export * from ... - continue; - } - for (var _e = 0, _f = exportDecl.exportClause.elements; _e < _f.length; _e++) { - var element = _f[_e]; - // write name of indirectly exported entry, i.e. 'export {x} from ...' - writeExportedName(element.name || element.propertyName); - } - } - decreaseIndent(); - writeLine(); - write("};"); - return emitExportStarFunction(exportedNamesStorageRef); - function emitExportStarFunction(localNames) { - var exportStarFunction = makeUniqueName("exportStar"); - writeLine(); - // define an export star helper function - write("function " + exportStarFunction + "(m) {"); - increaseIndent(); - writeLine(); - write("var exports = {};"); - writeLine(); - write("for(var n in m) {"); - increaseIndent(); - writeLine(); - write("if (n !== \"default\""); - if (localNames) { - write("&& !" + localNames + ".hasOwnProperty(n)"); - } - write(") exports[n] = m[n];"); - decreaseIndent(); - writeLine(); - write("}"); - writeLine(); - write(exportFunctionForFile + "(exports);"); - decreaseIndent(); - writeLine(); - write("}"); - return exportStarFunction; - } - function writeExportedName(node) { - // do not record default exports - // they are local to module and never overwritten (explicitly skipped) by star export - if (node.kind !== 69 /* Identifier */ && node.flags & 1024 /* Default */) { - return; - } - if (started) { - write(","); - } - else { - started = true; - } - writeLine(); - write("'"); - if (node.kind === 69 /* Identifier */) { - emitNodeWithCommentsAndWithoutSourcemap(node); - } - else { - emitDeclarationName(node); - } - write("': true"); - } - } - function processTopLevelVariableAndFunctionDeclarations(node) { - // per ES6 spec: - // 15.2.1.16.4 ModuleDeclarationInstantiation() Concrete Method - // - var declarations are initialized to undefined - 14.a.ii - // - function/generator declarations are instantiated - 16.a.iv - // this means that after module is instantiated but before its evaluation - // exported functions are already accessible at import sites - // in theory we should hoist only exported functions and its dependencies - // in practice to simplify things we'll hoist all source level functions and variable declaration - // including variables declarations for module and class declarations - var hoistedVars; - var hoistedFunctionDeclarations; - var exportedDeclarations; - visit(node); - if (hoistedVars) { - writeLine(); - write("var "); - var seen = {}; - for (var i = 0; i < hoistedVars.length; ++i) { - var local = hoistedVars[i]; - var name_26 = local.kind === 69 /* Identifier */ - ? local - : local.name; - if (name_26) { - // do not emit duplicate entries (in case of declaration merging) in the list of hoisted variables - var text = ts.unescapeIdentifier(name_26.text); - if (ts.hasProperty(seen, text)) { - continue; - } - else { - seen[text] = text; - } - } - if (i !== 0) { - write(", "); - } - if (local.kind === 214 /* ClassDeclaration */ || local.kind === 218 /* ModuleDeclaration */ || local.kind === 217 /* EnumDeclaration */) { - emitDeclarationName(local); - } - else { - emit(local); - } - var flags = ts.getCombinedNodeFlags(local.kind === 69 /* Identifier */ ? local.parent : local); - if (flags & 1 /* Export */) { - if (!exportedDeclarations) { - exportedDeclarations = []; - } - exportedDeclarations.push(local); - } - } - write(";"); - } - if (hoistedFunctionDeclarations) { - for (var _a = 0; _a < hoistedFunctionDeclarations.length; _a++) { - var f = hoistedFunctionDeclarations[_a]; - writeLine(); - emit(f); - if (f.flags & 1 /* Export */) { - if (!exportedDeclarations) { - exportedDeclarations = []; - } - exportedDeclarations.push(f); - } - } - } - return exportedDeclarations; - function visit(node) { - if (node.flags & 2 /* Ambient */) { - return; - } - if (node.kind === 213 /* FunctionDeclaration */) { - if (!hoistedFunctionDeclarations) { - hoistedFunctionDeclarations = []; - } - hoistedFunctionDeclarations.push(node); - return; - } - if (node.kind === 214 /* ClassDeclaration */) { - if (!hoistedVars) { - hoistedVars = []; - } - hoistedVars.push(node); - return; - } - if (node.kind === 217 /* EnumDeclaration */) { - if (shouldEmitEnumDeclaration(node)) { - if (!hoistedVars) { - hoistedVars = []; - } - hoistedVars.push(node); - } - return; - } - if (node.kind === 218 /* ModuleDeclaration */) { - if (shouldEmitModuleDeclaration(node)) { - if (!hoistedVars) { - hoistedVars = []; - } - hoistedVars.push(node); - } - return; - } - if (node.kind === 211 /* VariableDeclaration */ || node.kind === 163 /* BindingElement */) { - if (shouldHoistVariable(node, /*checkIfSourceFileLevelDecl*/ false)) { - var name_27 = node.name; - if (name_27.kind === 69 /* Identifier */) { - if (!hoistedVars) { - hoistedVars = []; - } - hoistedVars.push(name_27); - } - else { - ts.forEachChild(name_27, visit); - } - } - return; - } - if (ts.isInternalModuleImportEqualsDeclaration(node) && resolver.isValueAliasDeclaration(node)) { - if (!hoistedVars) { - hoistedVars = []; - } - hoistedVars.push(node.name); - return; - } - if (ts.isBindingPattern(node)) { - ts.forEach(node.elements, visit); - return; - } - if (!ts.isDeclaration(node)) { - ts.forEachChild(node, visit); - } - } - } - function shouldHoistVariable(node, checkIfSourceFileLevelDecl) { - if (checkIfSourceFileLevelDecl && !shouldHoistDeclarationInSystemJsModule(node)) { - return false; - } - // hoist variable if - // - it is not block scoped - // - it is top level block scoped - // if block scoped variables are nested in some another block then - // no other functions can use them except ones that are defined at least in the same block - return (ts.getCombinedNodeFlags(node) & 49152 /* BlockScoped */) === 0 || - ts.getEnclosingBlockScopeContainer(node).kind === 248 /* SourceFile */; - } - function isCurrentFileSystemExternalModule() { - return modulekind === 4 /* System */ && ts.isExternalModule(currentSourceFile); - } - function emitSystemModuleBody(node, dependencyGroups, startIndex) { - // 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 file1; // local alias - // var y; - // function foo() { return y + file1.x(); } - // exports("foo", foo); - // return { - // setters: [ - // function(v) { file1 = v } - // ], - // execute(): function() { - // y = 1; - // console.log(y); - // } - // }; - // } - emitVariableDeclarationsForImports(); - writeLine(); - var exportedDeclarations = processTopLevelVariableAndFunctionDeclarations(node); - var exportStarFunction = emitLocalStorageForExportedNamesIfNecessary(exportedDeclarations); - writeLine(); - write("return {"); - increaseIndent(); - writeLine(); - emitSetters(exportStarFunction, dependencyGroups); - writeLine(); - emitExecute(node, startIndex); - decreaseIndent(); - writeLine(); - write("}"); // return - emitTempDeclarations(/*newLine*/ true); - } - function emitSetters(exportStarFunction, dependencyGroups) { - write("setters:["); - for (var i = 0; i < dependencyGroups.length; ++i) { - if (i !== 0) { - write(","); - } - writeLine(); - increaseIndent(); - var group = dependencyGroups[i]; - // derive a unique name for parameter from the first named entry in the group - var parameterName = makeUniqueName(ts.forEach(group, getLocalNameForExternalImport) || ""); - write("function (" + parameterName + ") {"); - increaseIndent(); - for (var _a = 0; _a < group.length; _a++) { - var entry = group[_a]; - var importVariableName = getLocalNameForExternalImport(entry) || ""; - switch (entry.kind) { - case 222 /* ImportDeclaration */: - if (!entry.importClause) { - // 'import "..."' case - // module is imported only for side-effects, no emit required - break; - } - // fall-through - case 221 /* ImportEqualsDeclaration */: - ts.Debug.assert(importVariableName !== ""); - writeLine(); - // save import into the local - write(importVariableName + " = " + parameterName + ";"); - writeLine(); - break; - case 228 /* ExportDeclaration */: - ts.Debug.assert(importVariableName !== ""); - if (entry.exportClause) { - // export {a, b as c} from 'foo' - // emit as: - // exports_({ - // "a": _["a"], - // "c": _["b"] - // }); - writeLine(); - write(exportFunctionForFile + "({"); - writeLine(); - increaseIndent(); - for (var i_2 = 0, len = entry.exportClause.elements.length; i_2 < len; ++i_2) { - if (i_2 !== 0) { - write(","); - writeLine(); - } - var e = entry.exportClause.elements[i_2]; - write("\""); - emitNodeWithCommentsAndWithoutSourcemap(e.name); - write("\": " + parameterName + "[\""); - emitNodeWithCommentsAndWithoutSourcemap(e.propertyName || e.name); - write("\"]"); - } - decreaseIndent(); - writeLine(); - write("});"); - } - else { - writeLine(); - // export * from 'foo' - // emit as: - // exportStar(_foo); - write(exportStarFunction + "(" + parameterName + ");"); - } - writeLine(); - break; - } - } - decreaseIndent(); - write("}"); - decreaseIndent(); - } - write("],"); - } - function emitExecute(node, startIndex) { - write("execute: function() {"); - increaseIndent(); - writeLine(); - for (var i = startIndex; i < node.statements.length; ++i) { - var statement = node.statements[i]; - switch (statement.kind) { - // - function declarations are not emitted because they were already hoisted - // - import declarations are not emitted since they are already handled in setters - // - export declarations with module specifiers are not emitted since they were already written in setters - // - export declarations without module specifiers are emitted preserving the order - case 213 /* FunctionDeclaration */: - case 222 /* ImportDeclaration */: - continue; - case 228 /* ExportDeclaration */: - if (!statement.moduleSpecifier) { - for (var _a = 0, _b = statement.exportClause.elements; _a < _b.length; _a++) { - var element = _b[_a]; - // write call to exporter function for every export specifier in exports list - emitExportSpecifierInSystemModule(element); - } - } - continue; - case 221 /* ImportEqualsDeclaration */: - if (!ts.isInternalModuleImportEqualsDeclaration(statement)) { - // - import equals declarations that import external modules are not emitted - continue; - } - // fall-though for import declarations that import internal modules - default: - writeLine(); - emit(statement); - } - } - decreaseIndent(); - writeLine(); - write("}"); // execute - } - function emitSystemModule(node) { - collectExternalModuleInfo(node); - // System modules has the following shape - // System.register(['dep-1', ... 'dep-n'], function(exports) {/* module body function */}) - // 'exports' here is a function 'exports(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 'emitPostfixUnaryExpression' for more details - ts.Debug.assert(!exportFunctionForFile); - // make sure that name of 'exports' function does not conflict with existing identifiers - exportFunctionForFile = makeUniqueName("exports"); - writeLine(); - write("System.register("); - if (node.moduleName) { - write("\"" + node.moduleName + "\", "); - } - write("["); - var groupIndices = {}; - var dependencyGroups = []; - for (var i = 0; i < externalImports.length; ++i) { - var text = getExternalModuleNameText(externalImports[i]); - if (ts.hasProperty(groupIndices, text)) { - // deduplicate/group entries in dependency list by the dependency name - var groupIndex = groupIndices[text]; - dependencyGroups[groupIndex].push(externalImports[i]); - continue; - } - else { - groupIndices[text] = dependencyGroups.length; - dependencyGroups.push([externalImports[i]]); - } - if (i !== 0) { - write(", "); - } - write(text); - } - write("], function(" + exportFunctionForFile + ") {"); - writeLine(); - increaseIndent(); - var startIndex = emitDirectivePrologues(node.statements, /*startWithNewLine*/ true); - emitEmitHelpers(node); - emitCaptureThisForNodeIfNecessary(node); - emitSystemModuleBody(node, dependencyGroups, startIndex); - decreaseIndent(); - writeLine(); - write("});"); - } - function getAMDDependencyNames(node, includeNonAmdDependencies) { - // names of modules with corresponding parameter in the factory function - var aliasedModuleNames = []; - // names of modules with no corresponding parameters in factory function - var unaliasedModuleNames = []; - var importAliasNames = []; // names of the parameters in the factory function; these - // parameters need to match the indexes of the corresponding - // module names in aliasedModuleNames. - // Fill in amd-dependency tags - for (var _a = 0, _b = node.amdDependencies; _a < _b.length; _a++) { - var amdDependency = _b[_a]; - if (amdDependency.name) { - aliasedModuleNames.push("\"" + amdDependency.path + "\""); - importAliasNames.push(amdDependency.name); - } - else { - unaliasedModuleNames.push("\"" + amdDependency.path + "\""); - } - } - for (var _c = 0; _c < externalImports.length; _c++) { - var importNode = externalImports[_c]; - // Find the name of the external module - var externalModuleName = getExternalModuleNameText(importNode); - // Find the name of the module alias, if there is one - var importAliasName = getLocalNameForExternalImport(importNode); - if (includeNonAmdDependencies && importAliasName) { - aliasedModuleNames.push(externalModuleName); - importAliasNames.push(importAliasName); - } - else { - unaliasedModuleNames.push(externalModuleName); - } - } - return { aliasedModuleNames: aliasedModuleNames, unaliasedModuleNames: unaliasedModuleNames, importAliasNames: importAliasNames }; - } - function emitAMDDependencies(node, includeNonAmdDependencies) { - // An AMD define function has the following shape: - // define(id?, dependencies?, factory); - // - // This has the shape of - // define(name, ["module1", "module2"], function (module1Alias) { - // The location of the alias in the parameter list in the factory function needs to - // match the position of the module name in the dependency list. - // - // To ensure this is true in cases of modules with no aliases, e.g.: - // `import "module"` or `` - // we need to add modules without alias names to the end of the dependencies list - var dependencyNames = getAMDDependencyNames(node, includeNonAmdDependencies); - emitAMDDependencyList(dependencyNames); - write(", "); - emitAMDFactoryHeader(dependencyNames); - } - function emitAMDDependencyList(_a) { - var aliasedModuleNames = _a.aliasedModuleNames, unaliasedModuleNames = _a.unaliasedModuleNames; - write("[\"require\", \"exports\""); - if (aliasedModuleNames.length) { - write(", "); - write(aliasedModuleNames.join(", ")); - } - if (unaliasedModuleNames.length) { - write(", "); - write(unaliasedModuleNames.join(", ")); - } - write("]"); - } - function emitAMDFactoryHeader(_a) { - var importAliasNames = _a.importAliasNames; - write("function (require, exports"); - if (importAliasNames.length) { - write(", "); - write(importAliasNames.join(", ")); - } - write(") {"); - } - function emitAMDModule(node) { - emitEmitHelpers(node); - collectExternalModuleInfo(node); - writeLine(); - write("define("); - if (node.moduleName) { - write("\"" + node.moduleName + "\", "); - } - emitAMDDependencies(node, /*includeNonAmdDependencies*/ true); - increaseIndent(); - var startIndex = emitDirectivePrologues(node.statements, /*startWithNewLine*/ true); - emitExportStarHelper(); - emitCaptureThisForNodeIfNecessary(node); - emitLinesStartingAt(node.statements, startIndex); - emitTempDeclarations(/*newLine*/ true); - emitExportEquals(/*emitAsReturn*/ true); - decreaseIndent(); - writeLine(); - write("});"); - } - function emitCommonJSModule(node) { - var startIndex = emitDirectivePrologues(node.statements, /*startWithNewLine*/ false); - emitEmitHelpers(node); - collectExternalModuleInfo(node); - emitExportStarHelper(); - emitCaptureThisForNodeIfNecessary(node); - emitLinesStartingAt(node.statements, startIndex); - emitTempDeclarations(/*newLine*/ true); - emitExportEquals(/*emitAsReturn*/ false); - } - function emitUMDModule(node) { - emitEmitHelpers(node); - collectExternalModuleInfo(node); - var dependencyNames = getAMDDependencyNames(node, /*includeNonAmdDependencies*/ false); - // Module is detected first to support Browserify users that load into a browser with an AMD loader - writeLines("(function (factory) {\n if (typeof module === 'object' && typeof module.exports === 'object') {\n var v = factory(require, exports); if (v !== undefined) module.exports = v;\n }\n else if (typeof define === 'function' && define.amd) {\n define("); - emitAMDDependencyList(dependencyNames); - write(", factory);"); - writeLines(" }\n})("); - emitAMDFactoryHeader(dependencyNames); - increaseIndent(); - var startIndex = emitDirectivePrologues(node.statements, /*startWithNewLine*/ true); - emitExportStarHelper(); - emitCaptureThisForNodeIfNecessary(node); - emitLinesStartingAt(node.statements, startIndex); - emitTempDeclarations(/*newLine*/ true); - emitExportEquals(/*emitAsReturn*/ true); - decreaseIndent(); - writeLine(); - write("});"); - } - function emitES6Module(node) { - externalImports = undefined; - exportSpecifiers = undefined; - exportEquals = undefined; - hasExportStars = false; - var startIndex = emitDirectivePrologues(node.statements, /*startWithNewLine*/ false); - emitEmitHelpers(node); - emitCaptureThisForNodeIfNecessary(node); - emitLinesStartingAt(node.statements, startIndex); - emitTempDeclarations(/*newLine*/ true); - // Emit exportDefault if it exists will happen as part - // or normal statement emit. - } - function emitExportEquals(emitAsReturn) { - if (exportEquals && resolver.isValueAliasDeclaration(exportEquals)) { - writeLine(); - emitStart(exportEquals); - write(emitAsReturn ? "return " : "module.exports = "); - emit(exportEquals.expression); - write(";"); - emitEnd(exportEquals); - } - } - function emitJsxElement(node) { - switch (compilerOptions.jsx) { - case 2 /* React */: - jsxEmitReact(node); - break; - case 1 /* Preserve */: - // Fall back to preserve if None was specified (we'll error earlier) - default: - jsxEmitPreserve(node); - break; - } - } - function trimReactWhitespaceAndApplyEntities(node) { - var result = undefined; - var text = ts.getTextOfNode(node, /*includeTrivia*/ true); - var firstNonWhitespace = 0; - var lastNonWhitespace = -1; - // JSX trims whitespace at the end and beginning of lines, except that the - // start/end of a tag is considered a start/end of a line only if that line is - // on the same line as the closing tag. See examples in tests/cases/conformance/jsx/tsxReactEmitWhitespace.tsx - for (var i = 0; i < text.length; i++) { - var c = text.charCodeAt(i); - if (ts.isLineBreak(c)) { - if (firstNonWhitespace !== -1 && (lastNonWhitespace - firstNonWhitespace + 1 > 0)) { - var part = text.substr(firstNonWhitespace, lastNonWhitespace - firstNonWhitespace + 1); - result = (result ? result + "\" + ' ' + \"" : "") + ts.escapeString(part); - } - firstNonWhitespace = -1; - } - else if (!ts.isWhiteSpace(c)) { - lastNonWhitespace = i; - if (firstNonWhitespace === -1) { - firstNonWhitespace = i; - } - } - } - if (firstNonWhitespace !== -1) { - var part = text.substr(firstNonWhitespace); - result = (result ? result + "\" + ' ' + \"" : "") + ts.escapeString(part); - } - if (result) { - // Replace entities like   - result = result.replace(/&(\w+);/g, function (s, m) { - if (entities[m] !== undefined) { - return String.fromCharCode(entities[m]); - } - else { - return s; - } - }); - } - return result; - } - function getTextToEmit(node) { - switch (compilerOptions.jsx) { - case 2 /* React */: - var text = trimReactWhitespaceAndApplyEntities(node); - if (text === undefined || text.length === 0) { - return undefined; - } - else { - return text; - } - case 1 /* Preserve */: - default: - return ts.getTextOfNode(node, /*includeTrivia*/ true); - } - } - function emitJsxText(node) { - switch (compilerOptions.jsx) { - case 2 /* React */: - write("\""); - write(trimReactWhitespaceAndApplyEntities(node)); - write("\""); - break; - case 1 /* Preserve */: - default: - writer.writeLiteral(ts.getTextOfNode(node, /*includeTrivia*/ true)); - break; - } - } - function emitJsxExpression(node) { - if (node.expression) { - switch (compilerOptions.jsx) { - case 1 /* Preserve */: - default: - write("{"); - emit(node.expression); - write("}"); - break; - case 2 /* React */: - emit(node.expression); - break; - } - } - } - function emitDirectivePrologues(statements, startWithNewLine) { - for (var i = 0; i < statements.length; ++i) { - if (ts.isPrologueDirective(statements[i])) { - if (startWithNewLine || i > 0) { - writeLine(); - } - emit(statements[i]); - } - else { - // return index of the first non prologue directive - return i; - } - } - return statements.length; - } - function writeLines(text) { - var lines = text.split(/\r\n|\r|\n/g); - for (var i = 0; i < lines.length; ++i) { - var line = lines[i]; - if (line.length) { - writeLine(); - write(line); - } - } - } - function emitEmitHelpers(node) { - // Only emit helpers if the user did not say otherwise. - if (!compilerOptions.noEmitHelpers) { - // Only Emit __extends function when target ES5. - // For target ES6 and above, we can emit classDeclaration as is. - if ((languageVersion < 2 /* ES6 */) && (!extendsEmitted && resolver.getNodeCheckFlags(node) & 8 /* EmitExtends */)) { - writeLines(extendsHelper); - extendsEmitted = true; - } - if (!decorateEmitted && resolver.getNodeCheckFlags(node) & 16 /* EmitDecorate */) { - writeLines(decorateHelper); - if (compilerOptions.emitDecoratorMetadata) { - writeLines(metadataHelper); - } - decorateEmitted = true; - } - if (!paramEmitted && resolver.getNodeCheckFlags(node) & 32 /* EmitParam */) { - writeLines(paramHelper); - paramEmitted = true; - } - if (!awaiterEmitted && resolver.getNodeCheckFlags(node) & 64 /* EmitAwaiter */) { - writeLines(awaiterHelper); - awaiterEmitted = true; - } - } - } - function emitSourceFileNode(node) { - // Start new file on new line - writeLine(); - emitShebang(); - emitDetachedComments(node); - if (ts.isExternalModule(node) || compilerOptions.isolatedModules) { - var emitModule = moduleEmitDelegates[modulekind] || moduleEmitDelegates[1 /* CommonJS */]; - emitModule(node); - } - else { - // emit prologue directives prior to __extends - var startIndex = emitDirectivePrologues(node.statements, /*startWithNewLine*/ false); - externalImports = undefined; - exportSpecifiers = undefined; - exportEquals = undefined; - hasExportStars = false; - emitEmitHelpers(node); - emitCaptureThisForNodeIfNecessary(node); - emitLinesStartingAt(node.statements, startIndex); - emitTempDeclarations(/*newLine*/ true); - } - emitLeadingComments(node.endOfFileToken); - } - function emitNodeWithCommentsAndWithoutSourcemap(node) { - emitNodeConsideringCommentsOption(node, emitNodeWithoutSourceMap); - } - function emitNodeConsideringCommentsOption(node, emitNodeConsideringSourcemap) { - if (node) { - if (node.flags & 2 /* Ambient */) { - return emitCommentsOnNotEmittedNode(node); - } - if (isSpecializedCommentHandling(node)) { - // This is the node that will handle its own comments and sourcemap - return emitNodeWithoutSourceMap(node); - } - var emitComments_1 = shouldEmitLeadingAndTrailingComments(node); - if (emitComments_1) { - emitLeadingComments(node); - } - emitNodeConsideringSourcemap(node); - if (emitComments_1) { - emitTrailingComments(node); - } - } - } - function emitNodeWithoutSourceMap(node) { - if (node) { - emitJavaScriptWorker(node); - } - } - function isSpecializedCommentHandling(node) { - switch (node.kind) { - // All of these entities are emitted in a specialized fashion. As such, we allow - // the specialized methods for each to handle the comments on the nodes. - case 215 /* InterfaceDeclaration */: - case 213 /* FunctionDeclaration */: - case 222 /* ImportDeclaration */: - case 221 /* ImportEqualsDeclaration */: - case 216 /* TypeAliasDeclaration */: - case 227 /* ExportAssignment */: - return true; - } - } - function shouldEmitLeadingAndTrailingComments(node) { - switch (node.kind) { - case 193 /* VariableStatement */: - return shouldEmitLeadingAndTrailingCommentsForVariableStatement(node); - case 218 /* ModuleDeclaration */: - // Only emit the leading/trailing comments for a module if we're actually - // emitting the module as well. - return shouldEmitModuleDeclaration(node); - case 217 /* EnumDeclaration */: - // Only emit the leading/trailing comments for an enum if we're actually - // emitting the module as well. - return shouldEmitEnumDeclaration(node); - } - // If the node is emitted in specialized fashion, dont emit comments as this node will handle - // emitting comments when emitting itself - ts.Debug.assert(!isSpecializedCommentHandling(node)); - // If this is the expression body of an arrow function that we're down-leveling, - // then we don't want to emit comments when we emit the body. It will have already - // been taken care of when we emitted the 'return' statement for the function - // expression body. - if (node.kind !== 192 /* Block */ && - node.parent && - node.parent.kind === 174 /* ArrowFunction */ && - node.parent.body === node && - compilerOptions.target <= 1 /* ES5 */) { - return false; - } - // Emit comments for everything else. - return true; - } - function emitJavaScriptWorker(node) { - // Check if the node can be emitted regardless of the ScriptTarget - switch (node.kind) { - case 69 /* Identifier */: - return emitIdentifier(node); - case 138 /* Parameter */: - return emitParameter(node); - case 143 /* MethodDeclaration */: - case 142 /* MethodSignature */: - return emitMethod(node); - case 145 /* GetAccessor */: - case 146 /* SetAccessor */: - return emitAccessor(node); - case 97 /* ThisKeyword */: - return emitThis(node); - case 95 /* SuperKeyword */: - return emitSuper(node); - case 93 /* NullKeyword */: - return write("null"); - case 99 /* TrueKeyword */: - return write("true"); - case 84 /* FalseKeyword */: - return write("false"); - case 8 /* NumericLiteral */: - case 9 /* StringLiteral */: - case 10 /* RegularExpressionLiteral */: - case 11 /* NoSubstitutionTemplateLiteral */: - case 12 /* TemplateHead */: - case 13 /* TemplateMiddle */: - case 14 /* TemplateTail */: - return emitLiteral(node); - case 183 /* TemplateExpression */: - return emitTemplateExpression(node); - case 190 /* TemplateSpan */: - return emitTemplateSpan(node); - case 233 /* JsxElement */: - case 234 /* JsxSelfClosingElement */: - return emitJsxElement(node); - case 236 /* JsxText */: - return emitJsxText(node); - case 240 /* JsxExpression */: - return emitJsxExpression(node); - case 135 /* QualifiedName */: - return emitQualifiedName(node); - case 161 /* ObjectBindingPattern */: - return emitObjectBindingPattern(node); - case 162 /* ArrayBindingPattern */: - return emitArrayBindingPattern(node); - case 163 /* BindingElement */: - return emitBindingElement(node); - case 164 /* ArrayLiteralExpression */: - return emitArrayLiteral(node); - case 165 /* ObjectLiteralExpression */: - return emitObjectLiteral(node); - case 245 /* PropertyAssignment */: - return emitPropertyAssignment(node); - case 246 /* ShorthandPropertyAssignment */: - return emitShorthandPropertyAssignment(node); - case 136 /* ComputedPropertyName */: - return emitComputedPropertyName(node); - case 166 /* PropertyAccessExpression */: - return emitPropertyAccess(node); - case 167 /* ElementAccessExpression */: - return emitIndexedAccess(node); - case 168 /* CallExpression */: - return emitCallExpression(node); - case 169 /* NewExpression */: - return emitNewExpression(node); - case 170 /* TaggedTemplateExpression */: - return emitTaggedTemplateExpression(node); - case 171 /* TypeAssertionExpression */: - return emit(node.expression); - case 189 /* AsExpression */: - return emit(node.expression); - case 172 /* ParenthesizedExpression */: - return emitParenExpression(node); - case 213 /* FunctionDeclaration */: - case 173 /* FunctionExpression */: - case 174 /* ArrowFunction */: - return emitFunctionDeclaration(node); - case 175 /* DeleteExpression */: - return emitDeleteExpression(node); - case 176 /* TypeOfExpression */: - return emitTypeOfExpression(node); - case 177 /* VoidExpression */: - return emitVoidExpression(node); - case 178 /* AwaitExpression */: - return emitAwaitExpression(node); - case 179 /* PrefixUnaryExpression */: - return emitPrefixUnaryExpression(node); - case 180 /* PostfixUnaryExpression */: - return emitPostfixUnaryExpression(node); - case 181 /* BinaryExpression */: - return emitBinaryExpression(node); - case 182 /* ConditionalExpression */: - return emitConditionalExpression(node); - case 185 /* SpreadElementExpression */: - return emitSpreadElementExpression(node); - case 184 /* YieldExpression */: - return emitYieldExpression(node); - case 187 /* OmittedExpression */: - return; - case 192 /* Block */: - case 219 /* ModuleBlock */: - return emitBlock(node); - case 193 /* VariableStatement */: - return emitVariableStatement(node); - case 194 /* EmptyStatement */: - return write(";"); - case 195 /* ExpressionStatement */: - return emitExpressionStatement(node); - case 196 /* IfStatement */: - return emitIfStatement(node); - case 197 /* DoStatement */: - return emitDoStatement(node); - case 198 /* WhileStatement */: - return emitWhileStatement(node); - case 199 /* ForStatement */: - return emitForStatement(node); - case 201 /* ForOfStatement */: - case 200 /* ForInStatement */: - return emitForInOrForOfStatement(node); - case 202 /* ContinueStatement */: - case 203 /* BreakStatement */: - return emitBreakOrContinueStatement(node); - case 204 /* ReturnStatement */: - return emitReturnStatement(node); - case 205 /* WithStatement */: - return emitWithStatement(node); - case 206 /* SwitchStatement */: - return emitSwitchStatement(node); - case 241 /* CaseClause */: - case 242 /* DefaultClause */: - return emitCaseOrDefaultClause(node); - case 207 /* LabeledStatement */: - return emitLabelledStatement(node); - case 208 /* ThrowStatement */: - return emitThrowStatement(node); - case 209 /* TryStatement */: - return emitTryStatement(node); - case 244 /* CatchClause */: - return emitCatchClause(node); - case 210 /* DebuggerStatement */: - return emitDebuggerStatement(node); - case 211 /* VariableDeclaration */: - return emitVariableDeclaration(node); - case 186 /* ClassExpression */: - return emitClassExpression(node); - case 214 /* ClassDeclaration */: - return emitClassDeclaration(node); - case 215 /* InterfaceDeclaration */: - return emitInterfaceDeclaration(node); - case 217 /* EnumDeclaration */: - return emitEnumDeclaration(node); - case 247 /* EnumMember */: - return emitEnumMember(node); - case 218 /* ModuleDeclaration */: - return emitModuleDeclaration(node); - case 222 /* ImportDeclaration */: - return emitImportDeclaration(node); - case 221 /* ImportEqualsDeclaration */: - return emitImportEqualsDeclaration(node); - case 228 /* ExportDeclaration */: - return emitExportDeclaration(node); - case 227 /* ExportAssignment */: - return emitExportAssignment(node); - case 248 /* SourceFile */: - return emitSourceFileNode(node); - } - } - function hasDetachedComments(pos) { - return detachedCommentsInfo !== undefined && ts.lastOrUndefined(detachedCommentsInfo).nodePos === pos; - } - function getLeadingCommentsWithoutDetachedComments() { - // get the leading comments from detachedPos - var leadingComments = ts.getLeadingCommentRanges(currentSourceFile.text, ts.lastOrUndefined(detachedCommentsInfo).detachedCommentEndPos); - if (detachedCommentsInfo.length - 1) { - detachedCommentsInfo.pop(); - } - else { - detachedCommentsInfo = undefined; - } - return leadingComments; - } - function isPinnedComments(comment) { - return currentSourceFile.text.charCodeAt(comment.pos + 1) === 42 /* asterisk */ && - currentSourceFile.text.charCodeAt(comment.pos + 2) === 33 /* exclamation */; - } - /** - * Determine if the given comment is a triple-slash - * - * @return true if the comment is a triple-slash comment else false - **/ - function isTripleSlashComment(comment) { - // Verify this is /// comment, but do the regexp match only when we first can find /// in the comment text - // so that we don't end up computing comment string and doing match for all // comments - if (currentSourceFile.text.charCodeAt(comment.pos + 1) === 47 /* slash */ && - comment.pos + 2 < comment.end && - currentSourceFile.text.charCodeAt(comment.pos + 2) === 47 /* slash */) { - var textSubStr = currentSourceFile.text.substring(comment.pos, comment.end); - return textSubStr.match(ts.fullTripleSlashReferencePathRegEx) || - textSubStr.match(ts.fullTripleSlashAMDReferencePathRegEx) ? - true : false; - } - return false; - } - function getLeadingCommentsToEmit(node) { - // Emit the leading comments only if the parent's pos doesn't match because parent should take care of emitting these comments - if (node.parent) { - if (node.parent.kind === 248 /* SourceFile */ || node.pos !== node.parent.pos) { - if (hasDetachedComments(node.pos)) { - // get comments without detached comments - return getLeadingCommentsWithoutDetachedComments(); - } - else { - // get the leading comments from the node - return ts.getLeadingCommentRangesOfNode(node, currentSourceFile); - } - } - } - } - function getTrailingCommentsToEmit(node) { - // Emit the trailing comments only if the parent's pos doesn't match because parent should take care of emitting these comments - if (node.parent) { - if (node.parent.kind === 248 /* SourceFile */ || node.end !== node.parent.end) { - return ts.getTrailingCommentRanges(currentSourceFile.text, node.end); - } - } - } - /** - * Emit comments associated with node that will not be emitted into JS file - */ - function emitCommentsOnNotEmittedNode(node) { - emitLeadingCommentsWorker(node, /*isEmittedNode:*/ false); - } - function emitLeadingComments(node) { - return emitLeadingCommentsWorker(node, /*isEmittedNode:*/ true); - } - function emitLeadingCommentsWorker(node, isEmittedNode) { - if (compilerOptions.removeComments) { - return; - } - var leadingComments; - if (isEmittedNode) { - leadingComments = getLeadingCommentsToEmit(node); - } - else { - // If the node will not be emitted in JS, remove all the comments(normal, pinned and ///) associated with the node, - // unless it is a triple slash comment at the top of the file. - // For Example: - // /// - // declare var x; - // /// - // interface F {} - // The first /// will NOT be removed while the second one will be removed eventhough both node will not be emitted - if (node.pos === 0) { - leadingComments = ts.filter(getLeadingCommentsToEmit(node), isTripleSlashComment); - } - } - ts.emitNewLineBeforeLeadingComments(currentSourceFile, writer, node, leadingComments); - // Leading comments are emitted at /*leading comment1 */space/*leading comment*/space - ts.emitComments(currentSourceFile, writer, leadingComments, /*trailingSeparator:*/ true, newLine, writeComment); - } - function emitTrailingComments(node) { - if (compilerOptions.removeComments) { - return; - } - // Emit the trailing comments only if the parent's end doesn't match - var trailingComments = getTrailingCommentsToEmit(node); - // trailing comments are emitted at space/*trailing comment1 */space/*trailing comment*/ - ts.emitComments(currentSourceFile, writer, trailingComments, /*trailingSeparator*/ false, newLine, writeComment); - } - /** - * Emit trailing comments at the position. The term trailing comment is used here to describe following comment: - * x, /comment1/ y - * ^ => pos; the function will emit "comment1" in the emitJS - */ - function emitTrailingCommentsOfPosition(pos) { - if (compilerOptions.removeComments) { - return; - } - var trailingComments = ts.getTrailingCommentRanges(currentSourceFile.text, pos); - // trailing comments are emitted at space/*trailing comment1 */space/*trailing comment*/ - ts.emitComments(currentSourceFile, writer, trailingComments, /*trailingSeparator*/ true, newLine, writeComment); - } - function emitLeadingCommentsOfPositionWorker(pos) { - if (compilerOptions.removeComments) { - return; - } - var leadingComments; - if (hasDetachedComments(pos)) { - // get comments without detached comments - leadingComments = getLeadingCommentsWithoutDetachedComments(); - } - else { - // get the leading comments from the node - leadingComments = ts.getLeadingCommentRanges(currentSourceFile.text, pos); - } - ts.emitNewLineBeforeLeadingComments(currentSourceFile, writer, { pos: pos, end: pos }, leadingComments); - // Leading comments are emitted at /*leading comment1 */space/*leading comment*/space - ts.emitComments(currentSourceFile, writer, leadingComments, /*trailingSeparator*/ true, newLine, writeComment); - } - function emitDetachedComments(node) { - var leadingComments; - if (compilerOptions.removeComments) { - // removeComments is true, only reserve pinned comment at the top of file - // For example: - // /*! Pinned Comment */ - // - // var x = 10; - if (node.pos === 0) { - leadingComments = ts.filter(ts.getLeadingCommentRanges(currentSourceFile.text, node.pos), isPinnedComments); - } - } - else { - // removeComments is false, just get detached as normal and bypass the process to filter comment - leadingComments = ts.getLeadingCommentRanges(currentSourceFile.text, node.pos); - } - if (leadingComments) { - var detachedComments = []; - var lastComment; - ts.forEach(leadingComments, function (comment) { - if (lastComment) { - var lastCommentLine = ts.getLineOfLocalPosition(currentSourceFile, lastComment.end); - var commentLine = ts.getLineOfLocalPosition(currentSourceFile, comment.pos); - if (commentLine >= lastCommentLine + 2) { - // There was a blank line between the last comment and this comment. This - // comment is not part of the copyright comments. Return what we have so - // far. - return detachedComments; - } - } - detachedComments.push(comment); - lastComment = comment; - }); - if (detachedComments.length) { - // All comments look like they could have been part of the copyright header. Make - // sure there is at least one blank line between it and the node. If not, it's not - // a copyright header. - var lastCommentLine = ts.getLineOfLocalPosition(currentSourceFile, ts.lastOrUndefined(detachedComments).end); - var nodeLine = ts.getLineOfLocalPosition(currentSourceFile, ts.skipTrivia(currentSourceFile.text, node.pos)); - if (nodeLine >= lastCommentLine + 2) { - // Valid detachedComments - ts.emitNewLineBeforeLeadingComments(currentSourceFile, writer, node, leadingComments); - ts.emitComments(currentSourceFile, writer, detachedComments, /*trailingSeparator*/ true, newLine, writeComment); - var currentDetachedCommentInfo = { nodePos: node.pos, detachedCommentEndPos: ts.lastOrUndefined(detachedComments).end }; - if (detachedCommentsInfo) { - detachedCommentsInfo.push(currentDetachedCommentInfo); - } - else { - detachedCommentsInfo = [currentDetachedCommentInfo]; - } - } - } - } - } - function emitShebang() { - var shebang = ts.getShebang(currentSourceFile.text); - if (shebang) { - write(shebang); - } - } - var _a; - } - function emitFile(jsFilePath, sourceFile) { - emitJavaScript(jsFilePath, sourceFile); - if (compilerOptions.declaration) { - ts.writeDeclarationFile(jsFilePath, sourceFile, host, resolver, diagnostics); - } - } - } - ts.emitFiles = emitFiles; -})(ts || (ts = {})); -/// -/// -/// -var ts; -(function (ts) { - /* @internal */ ts.programTime = 0; - /* @internal */ ts.emitTime = 0; - /* @internal */ ts.ioReadTime = 0; - /* @internal */ ts.ioWriteTime = 0; - /** The version of the TypeScript compiler release */ - var emptyArray = []; - ts.version = "1.8.0"; - function findConfigFile(searchPath) { - var fileName = "tsconfig.json"; - while (true) { - if (ts.sys.fileExists(fileName)) { - return fileName; - } - var parentPath = ts.getDirectoryPath(searchPath); - if (parentPath === searchPath) { - break; - } - searchPath = parentPath; - fileName = "../" + fileName; - } - return undefined; - } - ts.findConfigFile = findConfigFile; - function resolveTripleslashReference(moduleName, containingFile) { - var basePath = ts.getDirectoryPath(containingFile); - var referencedFileName = ts.isRootedDiskPath(moduleName) ? moduleName : ts.combinePaths(basePath, moduleName); - return ts.normalizePath(referencedFileName); - } - ts.resolveTripleslashReference = resolveTripleslashReference; - function resolveModuleName(moduleName, containingFile, compilerOptions, host) { - var moduleResolution = compilerOptions.moduleResolution !== undefined - ? compilerOptions.moduleResolution - : compilerOptions.module === 1 /* CommonJS */ ? 2 /* NodeJs */ : 1 /* Classic */; - switch (moduleResolution) { - case 2 /* NodeJs */: return nodeModuleNameResolver(moduleName, containingFile, host); - case 1 /* Classic */: return classicNameResolver(moduleName, containingFile, compilerOptions, host); - } - } - ts.resolveModuleName = resolveModuleName; - function nodeModuleNameResolver(moduleName, containingFile, host) { - var containingDirectory = ts.getDirectoryPath(containingFile); - if (ts.getRootLength(moduleName) !== 0 || nameStartsWithDotSlashOrDotDotSlash(moduleName)) { - var failedLookupLocations = []; - var candidate = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName)); - var resolvedFileName = loadNodeModuleFromFile(candidate, failedLookupLocations, host); - if (resolvedFileName) { - return { resolvedModule: { resolvedFileName: resolvedFileName }, failedLookupLocations: failedLookupLocations }; - } - resolvedFileName = loadNodeModuleFromDirectory(candidate, failedLookupLocations, host); - return resolvedFileName - ? { resolvedModule: { resolvedFileName: resolvedFileName }, failedLookupLocations: failedLookupLocations } - : { resolvedModule: undefined, failedLookupLocations: failedLookupLocations }; - } - else { - return loadModuleFromNodeModules(moduleName, containingDirectory, host); - } - } - ts.nodeModuleNameResolver = nodeModuleNameResolver; - function loadNodeModuleFromFile(candidate, failedLookupLocation, host) { - return ts.forEach(ts.moduleFileExtensions, tryLoad); - function tryLoad(ext) { - var fileName = ts.fileExtensionIs(candidate, ext) ? candidate : candidate + ext; - if (host.fileExists(fileName)) { - return fileName; - } - else { - failedLookupLocation.push(fileName); - return undefined; - } - } - } - function loadNodeModuleFromDirectory(candidate, failedLookupLocation, host) { - var packageJsonPath = ts.combinePaths(candidate, "package.json"); - if (host.fileExists(packageJsonPath)) { - var jsonContent; - try { - var jsonText = host.readFile(packageJsonPath); - jsonContent = jsonText ? JSON.parse(jsonText) : { typings: undefined }; - } - catch (e) { - // gracefully handle if readFile fails or returns not JSON - jsonContent = { typings: undefined }; - } - if (jsonContent.typings) { - var result = loadNodeModuleFromFile(ts.normalizePath(ts.combinePaths(candidate, jsonContent.typings)), failedLookupLocation, host); - if (result) { - return result; - } - } - } - else { - // record package json as one of failed lookup locations - in the future if this file will appear it will invalidate resolution results - failedLookupLocation.push(packageJsonPath); - } - return loadNodeModuleFromFile(ts.combinePaths(candidate, "index"), failedLookupLocation, host); - } - function loadModuleFromNodeModules(moduleName, directory, host) { - var failedLookupLocations = []; - directory = ts.normalizeSlashes(directory); - while (true) { - var baseName = ts.getBaseFileName(directory); - if (baseName !== "node_modules") { - var nodeModulesFolder = ts.combinePaths(directory, "node_modules"); - var candidate = ts.normalizePath(ts.combinePaths(nodeModulesFolder, moduleName)); - var result = loadNodeModuleFromFile(candidate, failedLookupLocations, host); - if (result) { - return { resolvedModule: { resolvedFileName: result, isExternalLibraryImport: true }, failedLookupLocations: failedLookupLocations }; - } - result = loadNodeModuleFromDirectory(candidate, failedLookupLocations, host); - if (result) { - return { resolvedModule: { resolvedFileName: result, isExternalLibraryImport: true }, failedLookupLocations: failedLookupLocations }; - } - } - var parentPath = ts.getDirectoryPath(directory); - if (parentPath === directory) { - break; - } - directory = parentPath; - } - return { resolvedModule: undefined, failedLookupLocations: failedLookupLocations }; - } - function nameStartsWithDotSlashOrDotDotSlash(name) { - var i = name.lastIndexOf("./", 1); - return i === 0 || (i === 1 && name.charCodeAt(0) === 46 /* dot */); - } - function classicNameResolver(moduleName, containingFile, compilerOptions, host) { - // module names that contain '!' are used to reference resources and are not resolved to actual files on disk - if (moduleName.indexOf("!") != -1) { - return { resolvedModule: undefined, failedLookupLocations: [] }; - } - var searchPath = ts.getDirectoryPath(containingFile); - var searchName; - var failedLookupLocations = []; - var referencedSourceFile; - while (true) { - searchName = ts.normalizePath(ts.combinePaths(searchPath, moduleName)); - referencedSourceFile = ts.forEach(ts.supportedExtensions, function (extension) { - if (extension === ".tsx" && !compilerOptions.jsx) { - // resolve .tsx files only if jsx support is enabled - // 'logical not' handles both undefined and None cases - return undefined; - } - var candidate = searchName + extension; - if (host.fileExists(candidate)) { - return candidate; - } - else { - failedLookupLocations.push(candidate); - } - }); - if (referencedSourceFile) { - break; - } - var parentPath = ts.getDirectoryPath(searchPath); - if (parentPath === searchPath) { - break; - } - searchPath = parentPath; - } - return referencedSourceFile - ? { resolvedModule: { resolvedFileName: referencedSourceFile }, failedLookupLocations: failedLookupLocations } - : { resolvedModule: undefined, failedLookupLocations: failedLookupLocations }; - } - ts.classicNameResolver = classicNameResolver; - /* @internal */ - ts.defaultInitCompilerOptions = { - module: 1 /* CommonJS */, - target: 0 /* ES3 */, - noImplicitAny: false, - outDir: "built", - rootDir: ".", - sourceMap: false - }; - function createCompilerHost(options, setParentNodes) { - var currentDirectory; - var existingDirectories = {}; - function getCanonicalFileName(fileName) { - // if underlying system can distinguish between two files whose names differs only in cases then file name already in canonical form. - // otherwise use toLowerCase as a canonical form. - return ts.sys.useCaseSensitiveFileNames ? fileName : fileName.toLowerCase(); - } - // returned by CScript sys environment - var unsupportedFileEncodingErrorCode = -2147024809; - function getSourceFile(fileName, languageVersion, onError) { - var text; - try { - var start = new Date().getTime(); - text = ts.sys.readFile(fileName, options.charset); - ts.ioReadTime += new Date().getTime() - start; - } - catch (e) { - if (onError) { - onError(e.number === unsupportedFileEncodingErrorCode - ? ts.createCompilerDiagnostic(ts.Diagnostics.Unsupported_file_encoding).messageText - : e.message); - } - text = ""; - } - return text !== undefined ? ts.createSourceFile(fileName, text, languageVersion, setParentNodes) : undefined; - } - function directoryExists(directoryPath) { - if (ts.hasProperty(existingDirectories, directoryPath)) { - return true; - } - if (ts.sys.directoryExists(directoryPath)) { - existingDirectories[directoryPath] = true; - return true; - } - return false; - } - function ensureDirectoriesExist(directoryPath) { - if (directoryPath.length > ts.getRootLength(directoryPath) && !directoryExists(directoryPath)) { - var parentDirectory = ts.getDirectoryPath(directoryPath); - ensureDirectoriesExist(parentDirectory); - ts.sys.createDirectory(directoryPath); - } - } - function writeFile(fileName, data, writeByteOrderMark, onError) { - try { - var start = new Date().getTime(); - ensureDirectoriesExist(ts.getDirectoryPath(ts.normalizePath(fileName))); - ts.sys.writeFile(fileName, data, writeByteOrderMark); - ts.ioWriteTime += new Date().getTime() - start; - } - catch (e) { - if (onError) { - onError(e.message); - } - } - } - var newLine = ts.getNewLineCharacter(options); - return { - getSourceFile: getSourceFile, - getDefaultLibFileName: function (options) { return ts.combinePaths(ts.getDirectoryPath(ts.normalizePath(ts.sys.getExecutingFilePath())), ts.getDefaultLibFileName(options)); }, - writeFile: writeFile, - getCurrentDirectory: function () { return currentDirectory || (currentDirectory = ts.sys.getCurrentDirectory()); }, - useCaseSensitiveFileNames: function () { return ts.sys.useCaseSensitiveFileNames; }, - getCanonicalFileName: getCanonicalFileName, - getNewLine: function () { return newLine; }, - fileExists: function (fileName) { return ts.sys.fileExists(fileName); }, - readFile: function (fileName) { return ts.sys.readFile(fileName); } - }; - } - ts.createCompilerHost = createCompilerHost; - function getPreEmitDiagnostics(program, sourceFile, cancellationToken) { - var diagnostics = program.getOptionsDiagnostics(cancellationToken).concat(program.getSyntacticDiagnostics(sourceFile, cancellationToken), program.getGlobalDiagnostics(cancellationToken), program.getSemanticDiagnostics(sourceFile, cancellationToken)); - if (program.getCompilerOptions().declaration) { - diagnostics.concat(program.getDeclarationDiagnostics(sourceFile, cancellationToken)); - } - return ts.sortAndDeduplicateDiagnostics(diagnostics); - } - ts.getPreEmitDiagnostics = getPreEmitDiagnostics; - function flattenDiagnosticMessageText(messageText, newLine) { - if (typeof messageText === "string") { - return messageText; - } - else { - var diagnosticChain = messageText; - var result = ""; - var indent = 0; - while (diagnosticChain) { - if (indent) { - result += newLine; - for (var i = 0; i < indent; i++) { - result += " "; - } - } - result += diagnosticChain.messageText; - indent++; - diagnosticChain = diagnosticChain.next; - } - return result; - } - } - ts.flattenDiagnosticMessageText = flattenDiagnosticMessageText; - function createProgram(rootNames, options, host, oldProgram) { - var program; - var files = []; - var fileProcessingDiagnostics = ts.createDiagnosticCollection(); - var programDiagnostics = ts.createDiagnosticCollection(); - var commonSourceDirectory; - var diagnosticsProducingTypeChecker; - var noDiagnosticsTypeChecker; - var classifiableNames; - var skipDefaultLib = options.noLib; - var start = new Date().getTime(); - host = host || createCompilerHost(options); - var resolveModuleNamesWorker = host.resolveModuleNames - ? (function (moduleNames, containingFile) { return host.resolveModuleNames(moduleNames, containingFile); }) - : (function (moduleNames, containingFile) { return ts.map(moduleNames, function (moduleName) { return resolveModuleName(moduleName, containingFile, options, host).resolvedModule; }); }); - var filesByName = ts.createFileMap(function (fileName) { return host.getCanonicalFileName(fileName); }); - if (oldProgram) { - // check properties that can affect structure of the program or module resolution strategy - // if any of these properties has changed - structure cannot be reused - var oldOptions = oldProgram.getCompilerOptions(); - if ((oldOptions.module !== options.module) || - (oldOptions.noResolve !== options.noResolve) || - (oldOptions.target !== options.target) || - (oldOptions.noLib !== options.noLib) || - (oldOptions.jsx !== options.jsx)) { - oldProgram = undefined; - } - } - if (!tryReuseStructureFromOldProgram()) { - ts.forEach(rootNames, function (name) { return processRootFile(name, false); }); - // Do not process the default library if: - // - The '--noLib' flag is used. - // - A 'no-default-lib' reference comment is encountered in - // processing the root files. - if (!skipDefaultLib) { - processRootFile(host.getDefaultLibFileName(options), true); - } - } - verifyCompilerOptions(); - // unconditionally set oldProgram to undefined to prevent it from being captured in closure - oldProgram = undefined; - ts.programTime += new Date().getTime() - start; - program = { - getRootFileNames: function () { return rootNames; }, - getSourceFile: getSourceFile, - getSourceFiles: function () { return files; }, - getCompilerOptions: function () { return options; }, - getSyntacticDiagnostics: getSyntacticDiagnostics, - getOptionsDiagnostics: getOptionsDiagnostics, - getGlobalDiagnostics: getGlobalDiagnostics, - getSemanticDiagnostics: getSemanticDiagnostics, - getDeclarationDiagnostics: getDeclarationDiagnostics, - getTypeChecker: getTypeChecker, - getClassifiableNames: getClassifiableNames, - getDiagnosticsProducingTypeChecker: getDiagnosticsProducingTypeChecker, - getCommonSourceDirectory: function () { return commonSourceDirectory; }, - emit: emit, - getCurrentDirectory: function () { return host.getCurrentDirectory(); }, - getNodeCount: function () { return getDiagnosticsProducingTypeChecker().getNodeCount(); }, - getIdentifierCount: function () { return getDiagnosticsProducingTypeChecker().getIdentifierCount(); }, - getSymbolCount: function () { return getDiagnosticsProducingTypeChecker().getSymbolCount(); }, - getTypeCount: function () { return getDiagnosticsProducingTypeChecker().getTypeCount(); }, - getFileProcessingDiagnostics: function () { return fileProcessingDiagnostics; } - }; - return program; - function getClassifiableNames() { - if (!classifiableNames) { - // Initialize a checker so that all our files are bound. - getTypeChecker(); - classifiableNames = {}; - for (var _i = 0; _i < files.length; _i++) { - var sourceFile = files[_i]; - ts.copyMap(sourceFile.classifiableNames, classifiableNames); - } - } - return classifiableNames; - } - function tryReuseStructureFromOldProgram() { - if (!oldProgram) { - return false; - } - ts.Debug.assert(!oldProgram.structureIsReused); - // there is an old program, check if we can reuse its structure - var oldRootNames = oldProgram.getRootFileNames(); - if (!ts.arrayIsEqualTo(oldRootNames, rootNames)) { - return false; - } - // check if program source files has changed in the way that can affect structure of the program - var newSourceFiles = []; - var modifiedSourceFiles = []; - for (var _i = 0, _a = oldProgram.getSourceFiles(); _i < _a.length; _i++) { - var oldSourceFile = _a[_i]; - var newSourceFile = host.getSourceFile(oldSourceFile.fileName, options.target); - if (!newSourceFile) { - return false; - } - if (oldSourceFile !== newSourceFile) { - if (oldSourceFile.hasNoDefaultLib !== newSourceFile.hasNoDefaultLib) { - // value of no-default-lib has changed - // this will affect if default library is injected into the list of files - return false; - } - // check tripleslash references - if (!ts.arrayIsEqualTo(oldSourceFile.referencedFiles, newSourceFile.referencedFiles, fileReferenceIsEqualTo)) { - // tripleslash references has changed - return false; - } - // check imports - collectExternalModuleReferences(newSourceFile); - if (!ts.arrayIsEqualTo(oldSourceFile.imports, newSourceFile.imports, moduleNameIsEqualTo)) { - // imports has changed - return false; - } - if (resolveModuleNamesWorker) { - var moduleNames = ts.map(newSourceFile.imports, function (name) { return name.text; }); - var resolutions = resolveModuleNamesWorker(moduleNames, newSourceFile.fileName); - // ensure that module resolution results are still correct - for (var i = 0; i < moduleNames.length; ++i) { - var newResolution = resolutions[i]; - var oldResolution = ts.getResolvedModule(oldSourceFile, moduleNames[i]); - var resolutionChanged = oldResolution - ? !newResolution || - oldResolution.resolvedFileName !== newResolution.resolvedFileName || - !!oldResolution.isExternalLibraryImport !== !!newResolution.isExternalLibraryImport - : newResolution; - if (resolutionChanged) { - return false; - } - } - } - // pass the cache of module resolutions from the old source file - newSourceFile.resolvedModules = oldSourceFile.resolvedModules; - modifiedSourceFiles.push(newSourceFile); - } - else { - // file has no changes - use it as is - newSourceFile = oldSourceFile; - } - // if file has passed all checks it should be safe to reuse it - newSourceFiles.push(newSourceFile); - } - // update fileName -> file mapping - for (var _b = 0; _b < newSourceFiles.length; _b++) { - var file = newSourceFiles[_b]; - filesByName.set(file.fileName, file); - } - files = newSourceFiles; - fileProcessingDiagnostics = oldProgram.getFileProcessingDiagnostics(); - for (var _c = 0; _c < modifiedSourceFiles.length; _c++) { - var modifiedFile = modifiedSourceFiles[_c]; - fileProcessingDiagnostics.reattachFileDiagnostics(modifiedFile); - } - oldProgram.structureIsReused = true; - return true; - } - function getEmitHost(writeFileCallback) { - return { - getCanonicalFileName: function (fileName) { return host.getCanonicalFileName(fileName); }, - getCommonSourceDirectory: program.getCommonSourceDirectory, - getCompilerOptions: program.getCompilerOptions, - getCurrentDirectory: function () { return host.getCurrentDirectory(); }, - getNewLine: function () { return host.getNewLine(); }, - getSourceFile: program.getSourceFile, - getSourceFiles: program.getSourceFiles, - writeFile: writeFileCallback || (function (fileName, data, writeByteOrderMark, onError) { return host.writeFile(fileName, data, writeByteOrderMark, onError); }) - }; - } - function getDiagnosticsProducingTypeChecker() { - return diagnosticsProducingTypeChecker || (diagnosticsProducingTypeChecker = ts.createTypeChecker(program, /*produceDiagnostics:*/ true)); - } - function getTypeChecker() { - return noDiagnosticsTypeChecker || (noDiagnosticsTypeChecker = ts.createTypeChecker(program, /*produceDiagnostics:*/ false)); - } - function emit(sourceFile, writeFileCallback, cancellationToken) { - var _this = this; - return runWithCancellationToken(function () { return emitWorker(_this, sourceFile, writeFileCallback, cancellationToken); }); - } - function emitWorker(program, sourceFile, writeFileCallback, cancellationToken) { - // If the noEmitOnError flag is set, then check if we have any errors so far. If so, - // immediately bail out. Note that we pass 'undefined' for 'sourceFile' so that we - // get any preEmit diagnostics, not just the ones - if (options.noEmitOnError && getPreEmitDiagnostics(program, /*sourceFile:*/ undefined, cancellationToken).length > 0) { - return { diagnostics: [], sourceMaps: undefined, emitSkipped: true }; - } - // Create the emit resolver outside of the "emitTime" tracking code below. That way - // any cost associated with it (like type checking) are appropriate associated with - // the type-checking counter. - // - // If the -out option is specified, we should not pass the source file to getEmitResolver. - // This is because in the -out scenario all files need to be emitted, and therefore all - // files need to be type checked. And the way to specify that all files need to be type - // checked is to not pass the file to getEmitResolver. - var emitResolver = getDiagnosticsProducingTypeChecker().getEmitResolver((options.outFile || options.out) ? undefined : sourceFile); - var start = new Date().getTime(); - var emitResult = ts.emitFiles(emitResolver, getEmitHost(writeFileCallback), sourceFile); - ts.emitTime += new Date().getTime() - start; - return emitResult; - } - function getSourceFile(fileName) { - // first try to use file name as is to find file - // then try to convert relative file name to absolute and use it to retrieve source file - return filesByName.get(fileName) || filesByName.get(ts.getNormalizedAbsolutePath(fileName, host.getCurrentDirectory())); - } - function getDiagnosticsHelper(sourceFile, getDiagnostics, cancellationToken) { - if (sourceFile) { - return getDiagnostics(sourceFile, cancellationToken); - } - var allDiagnostics = []; - ts.forEach(program.getSourceFiles(), function (sourceFile) { - if (cancellationToken) { - cancellationToken.throwIfCancellationRequested(); - } - ts.addRange(allDiagnostics, getDiagnostics(sourceFile, cancellationToken)); - }); - return ts.sortAndDeduplicateDiagnostics(allDiagnostics); - } - function getSyntacticDiagnostics(sourceFile, cancellationToken) { - return getDiagnosticsHelper(sourceFile, getSyntacticDiagnosticsForFile, cancellationToken); - } - function getSemanticDiagnostics(sourceFile, cancellationToken) { - return getDiagnosticsHelper(sourceFile, getSemanticDiagnosticsForFile, cancellationToken); - } - function getDeclarationDiagnostics(sourceFile, cancellationToken) { - return getDiagnosticsHelper(sourceFile, getDeclarationDiagnosticsForFile, cancellationToken); - } - function getSyntacticDiagnosticsForFile(sourceFile, cancellationToken) { - return sourceFile.parseDiagnostics; - } - function runWithCancellationToken(func) { - try { - return func(); - } - catch (e) { - if (e instanceof ts.OperationCanceledException) { - // We were canceled while performing the operation. Because our type checker - // might be a bad state, we need to throw it away. - // - // Note: we are overly agressive here. We do not actually *have* to throw away - // the "noDiagnosticsTypeChecker". However, for simplicity, i'd like to keep - // the lifetimes of these two TypeCheckers the same. Also, we generally only - // cancel when the user has made a change anyways. And, in that case, we (the - // program instance) will get thrown away anyways. So trying to keep one of - // these type checkers alive doesn't serve much purpose. - noDiagnosticsTypeChecker = undefined; - diagnosticsProducingTypeChecker = undefined; - } - throw e; - } - } - function getSemanticDiagnosticsForFile(sourceFile, cancellationToken) { - return runWithCancellationToken(function () { - var typeChecker = getDiagnosticsProducingTypeChecker(); - ts.Debug.assert(!!sourceFile.bindDiagnostics); - var bindDiagnostics = sourceFile.bindDiagnostics; - var checkDiagnostics = typeChecker.getDiagnostics(sourceFile, cancellationToken); - var fileProcessingDiagnosticsInFile = fileProcessingDiagnostics.getDiagnostics(sourceFile.fileName); - var programDiagnosticsInFile = programDiagnostics.getDiagnostics(sourceFile.fileName); - return bindDiagnostics.concat(checkDiagnostics).concat(fileProcessingDiagnosticsInFile).concat(programDiagnosticsInFile); - }); - } - function getDeclarationDiagnosticsForFile(sourceFile, cancellationToken) { - return runWithCancellationToken(function () { - if (!ts.isDeclarationFile(sourceFile)) { - var resolver = getDiagnosticsProducingTypeChecker().getEmitResolver(sourceFile, cancellationToken); - // Don't actually write any files since we're just getting diagnostics. - var writeFile_1 = function () { }; - return ts.getDeclarationDiagnostics(getEmitHost(writeFile_1), resolver, sourceFile); - } - }); - } - function getOptionsDiagnostics() { - var allDiagnostics = []; - ts.addRange(allDiagnostics, fileProcessingDiagnostics.getGlobalDiagnostics()); - ts.addRange(allDiagnostics, programDiagnostics.getGlobalDiagnostics()); - return ts.sortAndDeduplicateDiagnostics(allDiagnostics); - } - function getGlobalDiagnostics() { - var allDiagnostics = []; - ts.addRange(allDiagnostics, getDiagnosticsProducingTypeChecker().getGlobalDiagnostics()); - return ts.sortAndDeduplicateDiagnostics(allDiagnostics); - } - function hasExtension(fileName) { - return ts.getBaseFileName(fileName).indexOf(".") >= 0; - } - function processRootFile(fileName, isDefaultLib) { - processSourceFile(ts.normalizePath(fileName), isDefaultLib); - } - function fileReferenceIsEqualTo(a, b) { - return a.fileName === b.fileName; - } - function moduleNameIsEqualTo(a, b) { - return a.text === b.text; - } - function collectExternalModuleReferences(file) { - if (file.imports) { - return; - } - var imports; - for (var _i = 0, _a = file.statements; _i < _a.length; _i++) { - var node = _a[_i]; - collect(node, /* allowRelativeModuleNames */ true); - } - file.imports = imports || emptyArray; - function collect(node, allowRelativeModuleNames) { - switch (node.kind) { - case 222 /* ImportDeclaration */: - case 221 /* ImportEqualsDeclaration */: - case 228 /* ExportDeclaration */: - var moduleNameExpr = ts.getExternalModuleName(node); - if (!moduleNameExpr || moduleNameExpr.kind !== 9 /* StringLiteral */) { - break; - } - if (!moduleNameExpr.text) { - break; - } - if (allowRelativeModuleNames || !ts.isExternalModuleNameRelative(moduleNameExpr.text)) { - (imports || (imports = [])).push(moduleNameExpr); - } - break; - case 218 /* ModuleDeclaration */: - if (node.name.kind === 9 /* StringLiteral */ && (node.flags & 2 /* Ambient */ || ts.isDeclarationFile(file))) { - // TypeScript 1.0 spec (April 2014): 12.1.6 - // An AmbientExternalModuleDeclaration declares an external module. - // This type of declaration is permitted only in the global module. - // The StringLiteral must specify a top - level external module name. - // Relative external module names are not permitted - ts.forEachChild(node.body, function (node) { - // TypeScript 1.0 spec (April 2014): 12.1.6 - // An ExternalImportDeclaration in anAmbientExternalModuleDeclaration may reference other external modules - // only through top - level external module names. Relative external module names are not permitted. - collect(node, /* allowRelativeModuleNames */ false); - }); - } - break; - } - } - } - function processSourceFile(fileName, isDefaultLib, refFile, refPos, refEnd) { - var diagnosticArgument; - var diagnostic; - if (hasExtension(fileName)) { - if (!options.allowNonTsExtensions && !ts.forEach(ts.supportedExtensions, function (extension) { return ts.fileExtensionIs(host.getCanonicalFileName(fileName), extension); })) { - diagnostic = ts.Diagnostics.File_0_has_unsupported_extension_The_only_supported_extensions_are_1; - diagnosticArgument = [fileName, "'" + ts.supportedExtensions.join("', '") + "'"]; - } - else if (!findSourceFile(fileName, isDefaultLib, refFile, refPos, refEnd)) { - diagnostic = ts.Diagnostics.File_0_not_found; - diagnosticArgument = [fileName]; - } - else if (refFile && host.getCanonicalFileName(fileName) === host.getCanonicalFileName(refFile.fileName)) { - diagnostic = ts.Diagnostics.A_file_cannot_have_a_reference_to_itself; - diagnosticArgument = [fileName]; - } - } - else { - var nonTsFile = options.allowNonTsExtensions && findSourceFile(fileName, isDefaultLib, refFile, refPos, refEnd); - if (!nonTsFile) { - if (options.allowNonTsExtensions) { - diagnostic = ts.Diagnostics.File_0_not_found; - diagnosticArgument = [fileName]; - } - else if (!ts.forEach(ts.supportedExtensions, function (extension) { return findSourceFile(fileName + extension, isDefaultLib, refFile, refPos, refEnd); })) { - diagnostic = ts.Diagnostics.File_0_not_found; - fileName += ".ts"; - diagnosticArgument = [fileName]; - } - } - } - if (diagnostic) { - if (refFile !== undefined && refEnd !== undefined && refPos !== undefined) { - fileProcessingDiagnostics.add(ts.createFileDiagnostic.apply(void 0, [refFile, refPos, refEnd - refPos, diagnostic].concat(diagnosticArgument))); - } - else { - fileProcessingDiagnostics.add(ts.createCompilerDiagnostic.apply(void 0, [diagnostic].concat(diagnosticArgument))); - } - } - } - // Get source file from normalized fileName - function findSourceFile(fileName, isDefaultLib, refFile, refPos, refEnd) { - if (filesByName.contains(fileName)) { - // We've already looked for this file, use cached result - return getSourceFileFromCache(fileName, /*useAbsolutePath*/ false); - } - var normalizedAbsolutePath = ts.getNormalizedAbsolutePath(fileName, host.getCurrentDirectory()); - if (filesByName.contains(normalizedAbsolutePath)) { - var file_1 = getSourceFileFromCache(normalizedAbsolutePath, /*useAbsolutePath*/ true); - // we don't have resolution for this relative file name but the match was found by absolute file name - // store resolution for relative name as well - filesByName.set(fileName, file_1); - return file_1; - } - // We haven't looked for this file, do so now and cache result - var file = host.getSourceFile(fileName, options.target, function (hostErrorMessage) { - if (refFile !== undefined && refPos !== undefined && refEnd !== undefined) { - fileProcessingDiagnostics.add(ts.createFileDiagnostic(refFile, refPos, refEnd - refPos, ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage)); - } - else { - fileProcessingDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage)); - } - }); - filesByName.set(fileName, file); - if (file) { - skipDefaultLib = skipDefaultLib || file.hasNoDefaultLib; - // Set the source file for normalized absolute path - filesByName.set(normalizedAbsolutePath, file); - var basePath = ts.getDirectoryPath(fileName); - if (!options.noResolve) { - processReferencedFiles(file, basePath); - } - // always process imported modules to record module name resolutions - processImportedModules(file, basePath); - if (isDefaultLib) { - file.isDefaultLib = true; - files.unshift(file); - } - else { - files.push(file); - } - } - return file; - function getSourceFileFromCache(fileName, useAbsolutePath) { - var file = filesByName.get(fileName); - if (file && host.useCaseSensitiveFileNames()) { - var sourceFileName = useAbsolutePath ? ts.getNormalizedAbsolutePath(file.fileName, host.getCurrentDirectory()) : file.fileName; - if (ts.normalizeSlashes(fileName) !== ts.normalizeSlashes(sourceFileName)) { - if (refFile !== undefined && refPos !== undefined && refEnd !== undefined) { - fileProcessingDiagnostics.add(ts.createFileDiagnostic(refFile, refPos, refEnd - refPos, ts.Diagnostics.File_name_0_differs_from_already_included_file_name_1_only_in_casing, fileName, sourceFileName)); - } - else { - fileProcessingDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.File_name_0_differs_from_already_included_file_name_1_only_in_casing, fileName, sourceFileName)); - } - } - } - return file; - } - } - function processReferencedFiles(file, basePath) { - ts.forEach(file.referencedFiles, function (ref) { - var referencedFileName = resolveTripleslashReference(ref.fileName, file.fileName); - processSourceFile(referencedFileName, /* isDefaultLib */ false, file, ref.pos, ref.end); - }); - } - function processImportedModules(file, basePath) { - collectExternalModuleReferences(file); - if (file.imports.length) { - file.resolvedModules = {}; - var moduleNames = ts.map(file.imports, function (name) { return name.text; }); - var resolutions = resolveModuleNamesWorker(moduleNames, file.fileName); - for (var i = 0; i < file.imports.length; ++i) { - var resolution = resolutions[i]; - ts.setResolvedModule(file, moduleNames[i], resolution); - if (resolution && !options.noResolve) { - var importedFile = findModuleSourceFile(resolution.resolvedFileName, file.imports[i]); - if (importedFile && resolution.isExternalLibraryImport) { - if (!ts.isExternalModule(importedFile)) { - var start_2 = ts.getTokenPosOfNode(file.imports[i], file); - fileProcessingDiagnostics.add(ts.createFileDiagnostic(file, start_2, file.imports[i].end - start_2, ts.Diagnostics.Exported_external_package_typings_file_0_is_not_a_module_Please_contact_the_package_author_to_update_the_package_definition, importedFile.fileName)); - } - else if (!ts.fileExtensionIs(importedFile.fileName, ".d.ts")) { - var start_3 = ts.getTokenPosOfNode(file.imports[i], file); - fileProcessingDiagnostics.add(ts.createFileDiagnostic(file, start_3, file.imports[i].end - start_3, ts.Diagnostics.Exported_external_package_typings_can_only_be_in_d_ts_files_Please_contact_the_package_author_to_update_the_package_definition)); - } - else if (importedFile.referencedFiles.length) { - var firstRef = importedFile.referencedFiles[0]; - fileProcessingDiagnostics.add(ts.createFileDiagnostic(importedFile, firstRef.pos, firstRef.end - firstRef.pos, ts.Diagnostics.Exported_external_package_typings_file_cannot_contain_tripleslash_references_Please_contact_the_package_author_to_update_the_package_definition)); - } - } - } - } - } - else { - // no imports - drop cached module resolutions - file.resolvedModules = undefined; - } - return; - function findModuleSourceFile(fileName, nameLiteral) { - return findSourceFile(fileName, /* isDefaultLib */ false, file, ts.skipTrivia(file.text, nameLiteral.pos), nameLiteral.end); - } - } - function computeCommonSourceDirectory(sourceFiles) { - var commonPathComponents; - var currentDirectory = host.getCurrentDirectory(); - ts.forEach(files, function (sourceFile) { - // Each file contributes into common source file path - if (ts.isDeclarationFile(sourceFile)) { - return; - } - var sourcePathComponents = ts.getNormalizedPathComponents(sourceFile.fileName, currentDirectory); - sourcePathComponents.pop(); // The base file name is not part of the common directory path - if (!commonPathComponents) { - // first file - commonPathComponents = sourcePathComponents; - return; - } - for (var i = 0, n = Math.min(commonPathComponents.length, sourcePathComponents.length); i < n; i++) { - if (commonPathComponents[i] !== sourcePathComponents[i]) { - if (i === 0) { - programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_find_the_common_subdirectory_path_for_the_input_files)); - return; - } - // New common path found that is 0 -> i-1 - commonPathComponents.length = i; - break; - } - } - // If the sourcePathComponents was shorter than the commonPathComponents, truncate to the sourcePathComponents - if (sourcePathComponents.length < commonPathComponents.length) { - commonPathComponents.length = sourcePathComponents.length; - } - }); - return ts.getNormalizedPathFromPathComponents(commonPathComponents); - } - function checkSourceFilesBelongToPath(sourceFiles, rootDirectory) { - var allFilesBelongToPath = true; - if (sourceFiles) { - var currentDirectory = host.getCurrentDirectory(); - var absoluteRootDirectoryPath = host.getCanonicalFileName(ts.getNormalizedAbsolutePath(rootDirectory, currentDirectory)); - for (var _i = 0; _i < sourceFiles.length; _i++) { - var sourceFile = sourceFiles[_i]; - if (!ts.isDeclarationFile(sourceFile)) { - var absoluteSourceFilePath = host.getCanonicalFileName(ts.getNormalizedAbsolutePath(sourceFile.fileName, currentDirectory)); - if (absoluteSourceFilePath.indexOf(absoluteRootDirectoryPath) !== 0) { - programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.File_0_is_not_under_rootDir_1_rootDir_is_expected_to_contain_all_source_files, sourceFile.fileName, options.rootDir)); - allFilesBelongToPath = false; - } - } - } - } - return allFilesBelongToPath; - } - function verifyCompilerOptions() { - if (options.isolatedModules) { - if (options.declaration) { - programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "declaration", "isolatedModules")); - } - if (options.noEmitOnError) { - programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "noEmitOnError", "isolatedModules")); - } - if (options.out) { - programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "out", "isolatedModules")); - } - if (options.outFile) { - programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "outFile", "isolatedModules")); - } - } - if (options.inlineSourceMap) { - if (options.sourceMap) { - programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "sourceMap", "inlineSourceMap")); - } - if (options.mapRoot) { - programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "mapRoot", "inlineSourceMap")); - } - if (options.sourceRoot) { - programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "sourceRoot", "inlineSourceMap")); - } - } - if (options.inlineSources) { - if (!options.sourceMap && !options.inlineSourceMap) { - programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_inlineSources_can_only_be_used_when_either_option_inlineSourceMap_or_option_sourceMap_is_provided)); - } - } - if (options.out && options.outFile) { - programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "out", "outFile")); - } - if (!options.sourceMap && (options.mapRoot || options.sourceRoot)) { - // Error to specify --mapRoot or --sourceRoot without mapSourceFiles - if (options.mapRoot) { - programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "mapRoot", "sourceMap")); - } - if (options.sourceRoot) { - programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "sourceRoot", "sourceMap")); - } - return; - } - var languageVersion = options.target || 0 /* ES3 */; - var outFile = options.outFile || options.out; - var firstExternalModuleSourceFile = ts.forEach(files, function (f) { return ts.isExternalModule(f) ? f : undefined; }); - if (options.isolatedModules) { - if (!options.module && languageVersion < 2 /* ES6 */) { - 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; }); - if (firstNonExternalModuleSourceFile) { - var span = ts.getErrorSpanForNode(firstNonExternalModuleSourceFile, firstNonExternalModuleSourceFile); - programDiagnostics.add(ts.createFileDiagnostic(firstNonExternalModuleSourceFile, span.start, span.length, ts.Diagnostics.Cannot_compile_namespaces_when_the_isolatedModules_flag_is_provided)); - } - } - else if (firstExternalModuleSourceFile && languageVersion < 2 /* ES6 */ && !options.module) { - // We cannot use createDiagnosticFromNode because nodes do not have parents yet - var span = ts.getErrorSpanForNode(firstExternalModuleSourceFile, firstExternalModuleSourceFile.externalModuleIndicator); - programDiagnostics.add(ts.createFileDiagnostic(firstExternalModuleSourceFile, span.start, span.length, ts.Diagnostics.Cannot_compile_modules_unless_the_module_flag_is_provided)); - } - // Cannot specify module gen target of es6 when below es6 - if (options.module === 5 /* ES6 */ && languageVersion < 2 /* ES6 */) { - programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_compile_modules_into_es2015_when_targeting_ES5_or_lower)); - } - // there has to be common source directory if user specified --outdir || --sourceRoot - // if user specified --mapRoot, there needs to be common source directory if there would be multiple files being emitted - if (options.outDir || - options.sourceRoot || - (options.mapRoot && - (!outFile || firstExternalModuleSourceFile !== undefined))) { - if (options.rootDir && checkSourceFilesBelongToPath(files, options.rootDir)) { - // If a rootDir is specified and is valid use it as the commonSourceDirectory - commonSourceDirectory = ts.getNormalizedAbsolutePath(options.rootDir, host.getCurrentDirectory()); - } - else { - // Compute the commonSourceDirectory from the input files - commonSourceDirectory = computeCommonSourceDirectory(files); - } - if (commonSourceDirectory && commonSourceDirectory[commonSourceDirectory.length - 1] !== ts.directorySeparator) { - // Make sure directory path ends with directory separator so this string can directly - // used to replace with "" to get the relative path of the source file and the relative path doesn't - // start with / making it rooted path - commonSourceDirectory += ts.directorySeparator; - } - } - if (options.noEmit) { - if (options.out) { - programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "noEmit", "out")); - } - if (options.outFile) { - programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "noEmit", "outFile")); - } - if (options.outDir) { - programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "noEmit", "outDir")); - } - if (options.declaration) { - programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "noEmit", "declaration")); - } - } - if (options.emitDecoratorMetadata && - !options.experimentalDecorators) { - programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "emitDecoratorMetadata", "experimentalDecorators")); - } - } - } - ts.createProgram = createProgram; -})(ts || (ts = {})); -/// -/// -/// -/// -var ts; -(function (ts) { - /* @internal */ - ts.optionDeclarations = [ - { - name: "charset", - type: "string" - }, - { - name: "declaration", - shortName: "d", - type: "boolean", - description: ts.Diagnostics.Generates_corresponding_d_ts_file - }, - { - name: "diagnostics", - type: "boolean" - }, - { - name: "emitBOM", - type: "boolean" - }, - { - name: "help", - shortName: "h", - type: "boolean", - description: ts.Diagnostics.Print_this_message - }, - { - 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: { - "preserve": 1 /* Preserve */, - "react": 2 /* React */ - }, - paramType: ts.Diagnostics.KIND, - description: ts.Diagnostics.Specify_JSX_code_generation_Colon_preserve_or_react, - error: ts.Diagnostics.Argument_for_jsx_must_be_preserve_or_react - }, - { - name: "listFiles", - type: "boolean" - }, - { - name: "locale", - type: "string" - }, - { - name: "mapRoot", - type: "string", - isFilePath: true, - description: ts.Diagnostics.Specifies_the_location_where_debugger_should_locate_map_files_instead_of_generated_locations, - paramType: ts.Diagnostics.LOCATION - }, - { - name: "module", - shortName: "m", - type: { - "commonjs": 1 /* CommonJS */, - "amd": 2 /* AMD */, - "system": 4 /* System */, - "umd": 3 /* UMD */, - "es6": 5 /* ES6 */, - "es2015": 5 /* ES2015 */ - }, - description: ts.Diagnostics.Specify_module_code_generation_Colon_commonjs_amd_system_umd_or_es2015, - paramType: ts.Diagnostics.KIND, - error: ts.Diagnostics.Argument_for_module_option_must_be_commonjs_amd_system_umd_or_es2015 - }, - { - name: "newLine", - type: { - "crlf": 0 /* CarriageReturnLineFeed */, - "lf": 1 /* LineFeed */ - }, - description: ts.Diagnostics.Specifies_the_end_of_line_sequence_to_be_used_when_emitting_files_Colon_CRLF_dos_or_LF_unix, - paramType: ts.Diagnostics.NEWLINE, - error: ts.Diagnostics.Argument_for_newLine_option_must_be_CRLF_or_LF - }, - { - 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: "noImplicitAny", - type: "boolean", - description: ts.Diagnostics.Raise_error_on_expressions_and_declarations_with_an_implied_any_type - }, - { - name: "noLib", - type: "boolean" - }, - { - name: "noResolve", - type: "boolean" - }, - { - name: "skipDefaultLibCheck", - type: "boolean" - }, - { - name: "out", - type: "string", - isFilePath: false, - // for correct behaviour, please use outFile - 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: "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, - description: ts.Diagnostics.Specifies_the_root_directory_of_input_files_Use_to_control_the_output_directory_structure_with_outDir, - paramType: ts.Diagnostics.LOCATION - }, - { - name: "isolatedModules", - type: "boolean" - }, - { - name: "sourceMap", - type: "boolean", - description: ts.Diagnostics.Generates_corresponding_map_file - }, - { - name: "sourceRoot", - type: "string", - isFilePath: true, - description: ts.Diagnostics.Specifies_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: { - "es3": 0 /* ES3 */, - "es5": 1 /* ES5 */, - "es6": 2 /* ES6 */, - "es2015": 2 /* ES2015 */ - }, - description: ts.Diagnostics.Specify_ECMAScript_target_version_Colon_ES3_default_ES5_or_ES2015_experimental, - paramType: ts.Diagnostics.VERSION, - error: ts.Diagnostics.Argument_for_target_option_must_be_ES3_ES5_or_ES2015 - }, - { - 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: { - "node": 2 /* NodeJs */, - "classic": 1 /* Classic */ - }, - description: ts.Diagnostics.Specifies_module_resolution_strategy_Colon_node_Node_js_or_classic_TypeScript_pre_1_6, - error: ts.Diagnostics.Argument_for_moduleResolution_option_must_be_node_or_classic - } - ]; - var optionNameMapCache; - /* @internal */ - function getOptionNameMap() { - if (optionNameMapCache) { - return optionNameMapCache; - } - var optionNameMap = {}; - var shortOptionNames = {}; - 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 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++]; - if (s.charCodeAt(0) === 64 /* at */) { - parseResponseFile(s.slice(1)); - } - else if (s.charCodeAt(0) === 45 /* minus */) { - s = s.slice(s.charCodeAt(1) === 45 /* minus */ ? 2 : 1).toLowerCase(); - // Try to translate short option names to their full equivalents. - if (ts.hasProperty(shortOptionNames, s)) { - s = shortOptionNames[s]; - } - if (ts.hasProperty(optionNameMap, s)) { - var opt = optionNameMap[s]; - // Check to see if no argument was provided (e.g. "--locale" is the last command-line argument). - 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++]); - break; - case "boolean": - options[opt.name] = true; - break; - case "string": - options[opt.name] = args[i++] || ""; - break; - // If not a primitive, the possible types are specified in what is effectively a map of options. - default: - var map_2 = opt.type; - var key = (args[i++] || "").toLowerCase(); - if (ts.hasProperty(map_2, key)) { - options[opt.name] = map_2[key]; - } - else { - errors.push(ts.createCompilerDiagnostic(opt.error)); - } - } - } - 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 /* space */) - pos++; - if (pos >= text.length) - break; - var start = pos; - if (text.charCodeAt(start) === 34 /* doubleQuote */) { - pos++; - while (pos < text.length && text.charCodeAt(pos) !== 34 /* doubleQuote */) - 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 /* space */) - pos++; - args.push(text.substring(start, pos)); - } - } - parseStrings(args); - } - } - ts.parseCommandLine = parseCommandLine; - /** - * Read tsconfig.json file - * @param fileName The path to the config file - */ - 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; - /** - * Parse the text of the tsconfig.json file - * @param fileName The path to the config file - * @param jsonText The text of the config file - */ - function parseConfigFileTextToJson(fileName, jsonText) { - try { - return { config: /\S/.test(jsonText) ? JSON.parse(jsonText) : {} }; - } - catch (e) { - return { error: ts.createCompilerDiagnostic(ts.Diagnostics.Failed_to_parse_file_0_Colon_1, fileName, e.message) }; - } - } - ts.parseConfigFileTextToJson = parseConfigFileTextToJson; - /** - * Parse the contents of a config file (tsconfig.json). - * @param json The contents of the config file to parse - * @param host Instance of ParseConfigHost used to enumerate files in folder. - * @param basePath A root directory to resolve relative path entries in the config - * file to. e.g. outDir - */ - function parseJsonConfigFileContent(json, host, basePath) { - var _a = convertCompilerOptionsFromJson(json["compilerOptions"], basePath), options = _a.options, errors = _a.errors; - return { - options: options, - fileNames: getFileNames(), - errors: errors - }; - function getFileNames() { - var fileNames = []; - if (ts.hasProperty(json, "files")) { - if (json["files"] instanceof Array) { - fileNames = ts.map(json["files"], function (s) { return ts.combinePaths(basePath, s); }); - } - else { - errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Compiler_option_0_requires_a_value_of_type_1, "files", "Array")); - } - } - else { - var exclude = json["exclude"] instanceof Array ? ts.map(json["exclude"], ts.normalizeSlashes) : undefined; - var sysFiles = host.readDirectory(basePath, ".ts", exclude).concat(host.readDirectory(basePath, ".tsx", exclude)); - for (var i = 0; i < sysFiles.length; i++) { - var name_28 = sysFiles[i]; - if (ts.fileExtensionIs(name_28, ".d.ts")) { - var baseName = name_28.substr(0, name_28.length - ".d.ts".length); - if (!ts.contains(sysFiles, baseName + ".tsx") && !ts.contains(sysFiles, baseName + ".ts")) { - fileNames.push(name_28); - } - } - else if (ts.fileExtensionIs(name_28, ".ts")) { - if (!ts.contains(sysFiles, name_28 + "x")) { - fileNames.push(name_28); - } - } - else { - fileNames.push(name_28); - } - } - } - return fileNames; - } - } - ts.parseJsonConfigFileContent = parseJsonConfigFileContent; - function convertCompilerOptionsFromJson(jsonOptions, basePath) { - var options = {}; - var errors = []; - if (!jsonOptions) { - return { options: options, errors: errors }; - } - var optionNameMap = ts.arrayToMap(ts.optionDeclarations, function (opt) { return opt.name; }); - for (var id in jsonOptions) { - if (ts.hasProperty(optionNameMap, id)) { - var opt = optionNameMap[id]; - var optType = opt.type; - var value = jsonOptions[id]; - var expectedType = typeof optType === "string" ? optType : "string"; - if (typeof value === expectedType) { - if (typeof optType !== "string") { - var key = value.toLowerCase(); - if (ts.hasProperty(optType, key)) { - value = optType[key]; - } - else { - errors.push(ts.createCompilerDiagnostic(opt.error)); - value = 0; - } - } - if (opt.isFilePath) { - value = ts.normalizePath(ts.combinePaths(basePath, value)); - if (value === "") { - value = "."; - } - } - options[opt.name] = value; - } - else { - errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Compiler_option_0_requires_a_value_of_type_1, id, expectedType)); - } - } - else { - errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Unknown_compiler_option_0, id)); - } - } - return { options: options, errors: errors }; - } - ts.convertCompilerOptionsFromJson = convertCompilerOptionsFromJson; -})(ts || (ts = {})); -/* @internal */ -var ts; -(function (ts) { - var OutliningElementsCollector; - (function (OutliningElementsCollector) { - function collectElements(sourceFile) { - var elements = []; - var collapseText = "..."; - function addOutliningSpan(hintSpanNode, startElement, endElement, autoCollapse) { - if (hintSpanNode && startElement && endElement) { - var span = { - textSpan: ts.createTextSpanFromBounds(startElement.pos, endElement.end), - hintSpan: ts.createTextSpanFromBounds(hintSpanNode.getStart(), hintSpanNode.end), - bannerText: collapseText, - autoCollapse: autoCollapse - }; - elements.push(span); - } - } - function addOutliningSpanComments(commentSpan, autoCollapse) { - if (commentSpan) { - var span = { - textSpan: ts.createTextSpanFromBounds(commentSpan.pos, commentSpan.end), - hintSpan: ts.createTextSpanFromBounds(commentSpan.pos, commentSpan.end), - bannerText: collapseText, - autoCollapse: autoCollapse - }; - elements.push(span); - } - } - function addOutliningForLeadingCommentsForNode(n) { - var comments = ts.getLeadingCommentRangesOfNode(n, sourceFile); - if (comments) { - var firstSingleLineCommentStart = -1; - var lastSingleLineCommentEnd = -1; - var isFirstSingleLineComment = true; - var singleLineCommentCount = 0; - for (var _i = 0; _i < comments.length; _i++) { - var currentComment = comments[_i]; - // For single line comments, combine consecutive ones (2 or more) into - // a single span from the start of the first till the end of the last - if (currentComment.kind === 2 /* SingleLineCommentTrivia */) { - if (isFirstSingleLineComment) { - firstSingleLineCommentStart = currentComment.pos; - } - isFirstSingleLineComment = false; - lastSingleLineCommentEnd = currentComment.end; - singleLineCommentCount++; - } - else if (currentComment.kind === 3 /* MultiLineCommentTrivia */) { - combineAndAddMultipleSingleLineComments(singleLineCommentCount, firstSingleLineCommentStart, lastSingleLineCommentEnd); - addOutliningSpanComments(currentComment, /*autoCollapse*/ false); - singleLineCommentCount = 0; - lastSingleLineCommentEnd = -1; - isFirstSingleLineComment = true; - } - } - combineAndAddMultipleSingleLineComments(singleLineCommentCount, firstSingleLineCommentStart, lastSingleLineCommentEnd); - } - } - function combineAndAddMultipleSingleLineComments(count, start, end) { - // Only outline spans of two or more consecutive single line comments - if (count > 1) { - var multipleSingleLineComments = { - pos: start, - end: end, - kind: 2 /* SingleLineCommentTrivia */ - }; - addOutliningSpanComments(multipleSingleLineComments, /*autoCollapse*/ false); - } - } - function autoCollapse(node) { - return ts.isFunctionBlock(node) && node.parent.kind !== 174 /* ArrowFunction */; - } - var depth = 0; - var maxDepth = 20; - function walk(n) { - if (depth > maxDepth) { - return; - } - if (ts.isDeclaration(n)) { - addOutliningForLeadingCommentsForNode(n); - } - switch (n.kind) { - case 192 /* Block */: - if (!ts.isFunctionBlock(n)) { - var parent_7 = n.parent; - var openBrace = ts.findChildOfKind(n, 15 /* OpenBraceToken */, sourceFile); - var closeBrace = ts.findChildOfKind(n, 16 /* CloseBraceToken */, sourceFile); - // Check if the block is standalone, or 'attached' to some parent statement. - // If the latter, we want to collaps the block, but consider its hint span - // to be the entire span of the parent. - if (parent_7.kind === 197 /* DoStatement */ || - parent_7.kind === 200 /* ForInStatement */ || - parent_7.kind === 201 /* ForOfStatement */ || - parent_7.kind === 199 /* ForStatement */ || - parent_7.kind === 196 /* IfStatement */ || - parent_7.kind === 198 /* WhileStatement */ || - parent_7.kind === 205 /* WithStatement */ || - parent_7.kind === 244 /* CatchClause */) { - addOutliningSpan(parent_7, openBrace, closeBrace, autoCollapse(n)); - break; - } - if (parent_7.kind === 209 /* TryStatement */) { - // Could be the try-block, or the finally-block. - var tryStatement = parent_7; - if (tryStatement.tryBlock === n) { - addOutliningSpan(parent_7, openBrace, closeBrace, autoCollapse(n)); - break; - } - else if (tryStatement.finallyBlock === n) { - var finallyKeyword = ts.findChildOfKind(tryStatement, 85 /* FinallyKeyword */, sourceFile); - if (finallyKeyword) { - addOutliningSpan(finallyKeyword, openBrace, closeBrace, autoCollapse(n)); - break; - } - } - } - // Block was a standalone block. In this case we want to only collapse - // the span of the block, independent of any parent span. - var span = ts.createTextSpanFromBounds(n.getStart(), n.end); - elements.push({ - textSpan: span, - hintSpan: span, - bannerText: collapseText, - autoCollapse: autoCollapse(n) - }); - break; - } - // Fallthrough. - case 219 /* ModuleBlock */: { - var openBrace = ts.findChildOfKind(n, 15 /* OpenBraceToken */, sourceFile); - var closeBrace = ts.findChildOfKind(n, 16 /* CloseBraceToken */, sourceFile); - addOutliningSpan(n.parent, openBrace, closeBrace, autoCollapse(n)); - break; - } - case 214 /* ClassDeclaration */: - case 215 /* InterfaceDeclaration */: - case 217 /* EnumDeclaration */: - case 165 /* ObjectLiteralExpression */: - case 220 /* CaseBlock */: { - var openBrace = ts.findChildOfKind(n, 15 /* OpenBraceToken */, sourceFile); - var closeBrace = ts.findChildOfKind(n, 16 /* CloseBraceToken */, sourceFile); - addOutliningSpan(n, openBrace, closeBrace, autoCollapse(n)); - break; - } - case 164 /* ArrayLiteralExpression */: - var openBracket = ts.findChildOfKind(n, 19 /* OpenBracketToken */, sourceFile); - var closeBracket = ts.findChildOfKind(n, 20 /* CloseBracketToken */, sourceFile); - addOutliningSpan(n, openBracket, closeBracket, autoCollapse(n)); - break; - } - depth++; - ts.forEachChild(n, walk); - depth--; - } - walk(sourceFile); - return elements; - } - OutliningElementsCollector.collectElements = collectElements; - })(OutliningElementsCollector = ts.OutliningElementsCollector || (ts.OutliningElementsCollector = {})); -})(ts || (ts = {})); -/* @internal */ -var ts; -(function (ts) { - var NavigateTo; - (function (NavigateTo) { - function getNavigateToItems(program, cancellationToken, searchValue, maxResultCount) { - var patternMatcher = ts.createPatternMatcher(searchValue); - var rawItems = []; - // Search the declarations in all files and output matched NavigateToItem into array of NavigateToItem[] - ts.forEach(program.getSourceFiles(), function (sourceFile) { - cancellationToken.throwIfCancellationRequested(); - var nameToDeclarations = sourceFile.getNamedDeclarations(); - for (var name_29 in nameToDeclarations) { - var declarations = ts.getProperty(nameToDeclarations, name_29); - if (declarations) { - // First do a quick check to see if the name of the declaration matches the - // last portion of the (possibly) dotted name they're searching for. - var matches = patternMatcher.getMatchesForLastSegmentOfPattern(name_29); - if (!matches) { - continue; - } - for (var _i = 0; _i < declarations.length; _i++) { - var declaration = declarations[_i]; - // It was a match! If the pattern has dots in it, then also see if the - // declaration container matches as well. - if (patternMatcher.patternContainsDots) { - var containers = getContainers(declaration); - if (!containers) { - return undefined; - } - matches = patternMatcher.getMatches(containers, name_29); - if (!matches) { - continue; - } - } - var fileName = sourceFile.fileName; - var matchKind = bestMatchKind(matches); - rawItems.push({ name: name_29, fileName: fileName, matchKind: matchKind, isCaseSensitive: allMatchesAreCaseSensitive(matches), declaration: declaration }); - } - } - } - }); - rawItems.sort(compareNavigateToItems); - if (maxResultCount !== undefined) { - rawItems = rawItems.slice(0, maxResultCount); - } - var items = ts.map(rawItems, createNavigateToItem); - return items; - function allMatchesAreCaseSensitive(matches) { - ts.Debug.assert(matches.length > 0); - // This is a case sensitive match, only if all the submatches were case sensitive. - for (var _i = 0; _i < matches.length; _i++) { - var match = matches[_i]; - if (!match.isCaseSensitive) { - return false; - } - } - return true; - } - function getTextOfIdentifierOrLiteral(node) { - if (node) { - if (node.kind === 69 /* Identifier */ || - node.kind === 9 /* StringLiteral */ || - node.kind === 8 /* NumericLiteral */) { - return node.text; - } - } - return undefined; - } - function tryAddSingleDeclarationName(declaration, containers) { - if (declaration && declaration.name) { - var text = getTextOfIdentifierOrLiteral(declaration.name); - if (text !== undefined) { - containers.unshift(text); - } - else if (declaration.name.kind === 136 /* ComputedPropertyName */) { - return tryAddComputedPropertyName(declaration.name.expression, containers, /*includeLastPortion:*/ true); - } - else { - // Don't know how to add this. - return false; - } - } - return true; - } - // Only added the names of computed properties if they're simple dotted expressions, like: - // - // [X.Y.Z]() { } - function tryAddComputedPropertyName(expression, containers, includeLastPortion) { - var text = getTextOfIdentifierOrLiteral(expression); - if (text !== undefined) { - if (includeLastPortion) { - containers.unshift(text); - } - return true; - } - if (expression.kind === 166 /* PropertyAccessExpression */) { - var propertyAccess = expression; - if (includeLastPortion) { - containers.unshift(propertyAccess.name.text); - } - return tryAddComputedPropertyName(propertyAccess.expression, containers, /*includeLastPortion:*/ true); - } - return false; - } - function getContainers(declaration) { - 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 === 136 /* ComputedPropertyName */) { - if (!tryAddComputedPropertyName(declaration.name.expression, containers, /*includeLastPortion:*/ false)) { - return undefined; - } - } - // Now, walk up our containers, adding all their names to the container array. - declaration = ts.getContainerNode(declaration); - while (declaration) { - if (!tryAddSingleDeclarationName(declaration, containers)) { - return undefined; - } - declaration = ts.getContainerNode(declaration); - } - return containers; - } - function bestMatchKind(matches) { - ts.Debug.assert(matches.length > 0); - var bestMatchKind = ts.PatternMatchKind.camelCase; - for (var _i = 0; _i < matches.length; _i++) { - var match = matches[_i]; - var kind = match.kind; - if (kind < bestMatchKind) { - bestMatchKind = kind; - } - } - return bestMatchKind; - } - // This means "compare in a case insensitive manner." - var baseSensitivity = { sensitivity: "base" }; - function compareNavigateToItems(i1, i2) { - // TODO(cyrusn): get the gamut of comparisons that VS already uses here. - // Right now we just sort by kind first, and then by name of the item. - // 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); - } - function createNavigateToItem(rawItem) { - var declaration = rawItem.declaration; - var container = ts.getContainerNode(declaration); - return { - name: rawItem.name, - kind: ts.getNodeKind(declaration), - kindModifiers: ts.getNodeModifiers(declaration), - matchKind: ts.PatternMatchKind[rawItem.matchKind], - isCaseSensitive: rawItem.isCaseSensitive, - fileName: rawItem.fileName, - textSpan: ts.createTextSpanFromBounds(declaration.getStart(), declaration.getEnd()), - // TODO(jfreeman): What should be the containerName when the container has a computed name? - containerName: container && container.name ? container.name.text : "", - containerKind: container && container.name ? ts.getNodeKind(container) : "" - }; - } - } - NavigateTo.getNavigateToItems = getNavigateToItems; - })(NavigateTo = ts.NavigateTo || (ts.NavigateTo = {})); -})(ts || (ts = {})); -/// -/* @internal */ -var ts; -(function (ts) { - var NavigationBar; - (function (NavigationBar) { - function getNavigationBarItems(sourceFile) { - // If the source file has any child items, then it included in the tree - // and takes lexical ownership of all other top-level items. - var hasGlobalNode = false; - return getItemsWorker(getTopLevelNodes(sourceFile), createTopLevelItem); - function getIndent(node) { - // If we have a global node in the tree, - // then it adds an extra layer of depth to all subnodes. - var indent = hasGlobalNode ? 1 : 0; - var current = node.parent; - while (current) { - switch (current.kind) { - case 218 /* ModuleDeclaration */: - // If we have a module declared as A.B.C, it is more "intuitive" - // to say it only has a single layer of depth - do { - current = current.parent; - } while (current.kind === 218 /* ModuleDeclaration */); - // fall through - case 214 /* ClassDeclaration */: - case 217 /* EnumDeclaration */: - case 215 /* InterfaceDeclaration */: - case 213 /* FunctionDeclaration */: - indent++; - } - current = current.parent; - } - return indent; - } - function getChildNodes(nodes) { - var childNodes = []; - function visit(node) { - switch (node.kind) { - case 193 /* VariableStatement */: - ts.forEach(node.declarationList.declarations, visit); - break; - case 161 /* ObjectBindingPattern */: - case 162 /* ArrayBindingPattern */: - ts.forEach(node.elements, visit); - break; - case 228 /* ExportDeclaration */: - // Handle named exports case e.g.: - // export {a, b as B} from "mod"; - if (node.exportClause) { - ts.forEach(node.exportClause.elements, visit); - } - break; - case 222 /* ImportDeclaration */: - var importClause = node.importClause; - if (importClause) { - // Handle default import case e.g.: - // import d from "mod"; - if (importClause.name) { - childNodes.push(importClause); - } - // Handle named bindings in imports e.g.: - // import * as NS from "mod"; - // import {a, b as B} from "mod"; - if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 224 /* NamespaceImport */) { - childNodes.push(importClause.namedBindings); - } - else { - ts.forEach(importClause.namedBindings.elements, visit); - } - } - } - break; - case 163 /* BindingElement */: - case 211 /* VariableDeclaration */: - if (ts.isBindingPattern(node.name)) { - visit(node.name); - break; - } - // Fall through - case 214 /* ClassDeclaration */: - case 217 /* EnumDeclaration */: - case 215 /* InterfaceDeclaration */: - case 218 /* ModuleDeclaration */: - case 213 /* FunctionDeclaration */: - case 221 /* ImportEqualsDeclaration */: - case 226 /* ImportSpecifier */: - case 230 /* ExportSpecifier */: - childNodes.push(node); - break; - } - } - //for (let i = 0, n = nodes.length; i < n; i++) { - // let node = nodes[i]; - // if (node.kind === SyntaxKind.ClassDeclaration || - // node.kind === SyntaxKind.EnumDeclaration || - // node.kind === SyntaxKind.InterfaceDeclaration || - // node.kind === SyntaxKind.ModuleDeclaration || - // node.kind === SyntaxKind.FunctionDeclaration) { - // childNodes.push(node); - // } - // else if (node.kind === SyntaxKind.VariableStatement) { - // childNodes.push.apply(childNodes, (node).declarations); - // } - //} - ts.forEach(nodes, visit); - return sortNodes(childNodes); - } - function getTopLevelNodes(node) { - var topLevelNodes = []; - topLevelNodes.push(node); - addTopLevelNodes(node.statements, topLevelNodes); - return topLevelNodes; - } - function sortNodes(nodes) { - return nodes.slice(0).sort(function (n1, n2) { - if (n1.name && n2.name) { - return ts.getPropertyNameForPropertyNameNode(n1.name).localeCompare(ts.getPropertyNameForPropertyNameNode(n2.name)); - } - else if (n1.name) { - return 1; - } - else if (n2.name) { - return -1; - } - else { - return n1.kind - n2.kind; - } - }); - } - function addTopLevelNodes(nodes, topLevelNodes) { - nodes = sortNodes(nodes); - for (var _i = 0; _i < nodes.length; _i++) { - var node = nodes[_i]; - switch (node.kind) { - case 214 /* ClassDeclaration */: - case 217 /* EnumDeclaration */: - case 215 /* InterfaceDeclaration */: - topLevelNodes.push(node); - break; - case 218 /* ModuleDeclaration */: - var moduleDeclaration = node; - topLevelNodes.push(node); - addTopLevelNodes(getInnermostModule(moduleDeclaration).body.statements, topLevelNodes); - break; - case 213 /* FunctionDeclaration */: - var functionDeclaration = node; - if (isTopLevelFunctionDeclaration(functionDeclaration)) { - topLevelNodes.push(node); - addTopLevelNodes(functionDeclaration.body.statements, topLevelNodes); - } - break; - } - } - } - function isTopLevelFunctionDeclaration(functionDeclaration) { - if (functionDeclaration.kind === 213 /* FunctionDeclaration */) { - // A function declaration is 'top level' if it contains any function declarations - // within it. - if (functionDeclaration.body && functionDeclaration.body.kind === 192 /* Block */) { - // Proper function declarations can only have identifier names - if (ts.forEach(functionDeclaration.body.statements, function (s) { return s.kind === 213 /* FunctionDeclaration */ && !isEmpty(s.name.text); })) { - return true; - } - // Or if it is not parented by another function. i.e all functions - // at module scope are 'top level'. - if (!ts.isFunctionBlock(functionDeclaration.parent)) { - return true; - } - } - } - return false; - } - function getItemsWorker(nodes, createItem) { - var items = []; - var keyToItem = {}; - for (var _i = 0; _i < nodes.length; _i++) { - var child = nodes[_i]; - var item = createItem(child); - if (item !== undefined) { - if (item.text.length > 0) { - var key = item.text + "-" + item.kind + "-" + item.indent; - var itemWithSameName = keyToItem[key]; - if (itemWithSameName) { - // We had an item with the same name. Merge these items together. - merge(itemWithSameName, item); - } - else { - keyToItem[key] = item; - items.push(item); - } - } - } - } - return items; - } - function merge(target, source) { - // First, add any spans in the source to the target. - ts.addRange(target.spans, source.spans); - if (source.childItems) { - if (!target.childItems) { - target.childItems = []; - } - // Next, recursively merge or add any children in the source as appropriate. - outer: for (var _i = 0, _a = source.childItems; _i < _a.length; _i++) { - var sourceChild = _a[_i]; - for (var _b = 0, _c = target.childItems; _b < _c.length; _b++) { - var targetChild = _c[_b]; - if (targetChild.text === sourceChild.text && targetChild.kind === sourceChild.kind) { - // Found a match. merge them. - merge(targetChild, sourceChild); - continue outer; - } - } - // Didn't find a match, just add this child to the list. - target.childItems.push(sourceChild); - } - } - } - function createChildItem(node) { - switch (node.kind) { - case 138 /* Parameter */: - if (ts.isBindingPattern(node.name)) { - break; - } - if ((node.flags & 2035 /* Modifier */) === 0) { - return undefined; - } - return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberVariableElement); - case 143 /* MethodDeclaration */: - case 142 /* MethodSignature */: - return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberFunctionElement); - case 145 /* GetAccessor */: - return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberGetAccessorElement); - case 146 /* SetAccessor */: - return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberSetAccessorElement); - case 149 /* IndexSignature */: - return createItem(node, "[]", ts.ScriptElementKind.indexSignatureElement); - case 247 /* EnumMember */: - return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberVariableElement); - case 147 /* CallSignature */: - return createItem(node, "()", ts.ScriptElementKind.callSignatureElement); - case 148 /* ConstructSignature */: - return createItem(node, "new()", ts.ScriptElementKind.constructSignatureElement); - case 141 /* PropertyDeclaration */: - case 140 /* PropertySignature */: - return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberVariableElement); - case 213 /* FunctionDeclaration */: - return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.functionElement); - case 211 /* VariableDeclaration */: - case 163 /* BindingElement */: - var variableDeclarationNode; - var name_30; - if (node.kind === 163 /* BindingElement */) { - name_30 = node.name; - variableDeclarationNode = node; - // binding elements are added only for variable declarations - // bubble up to the containing variable declaration - while (variableDeclarationNode && variableDeclarationNode.kind !== 211 /* VariableDeclaration */) { - variableDeclarationNode = variableDeclarationNode.parent; - } - ts.Debug.assert(variableDeclarationNode !== undefined); - } - else { - ts.Debug.assert(!ts.isBindingPattern(node.name)); - variableDeclarationNode = node; - name_30 = node.name; - } - if (ts.isConst(variableDeclarationNode)) { - return createItem(node, getTextOfNode(name_30), ts.ScriptElementKind.constElement); - } - else if (ts.isLet(variableDeclarationNode)) { - return createItem(node, getTextOfNode(name_30), ts.ScriptElementKind.letElement); - } - else { - return createItem(node, getTextOfNode(name_30), ts.ScriptElementKind.variableElement); - } - case 144 /* Constructor */: - return createItem(node, "constructor", ts.ScriptElementKind.constructorImplementationElement); - case 230 /* ExportSpecifier */: - case 226 /* ImportSpecifier */: - case 221 /* ImportEqualsDeclaration */: - case 223 /* ImportClause */: - case 224 /* NamespaceImport */: - return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.alias); - } - return undefined; - function createItem(node, name, scriptElementKind) { - return getNavigationBarItem(name, scriptElementKind, ts.getNodeModifiers(node), [getNodeSpan(node)]); - } - } - function isEmpty(text) { - return !text || text.trim() === ""; - } - function getNavigationBarItem(text, kind, kindModifiers, spans, childItems, indent) { - if (childItems === void 0) { childItems = []; } - if (indent === void 0) { indent = 0; } - if (isEmpty(text)) { - return undefined; - } - return { - text: text, - kind: kind, - kindModifiers: kindModifiers, - spans: spans, - childItems: childItems, - indent: indent, - bolded: false, - grayed: false - }; - } - function createTopLevelItem(node) { - switch (node.kind) { - case 248 /* SourceFile */: - return createSourceFileItem(node); - case 214 /* ClassDeclaration */: - return createClassItem(node); - case 217 /* EnumDeclaration */: - return createEnumItem(node); - case 215 /* InterfaceDeclaration */: - return createIterfaceItem(node); - case 218 /* ModuleDeclaration */: - return createModuleItem(node); - case 213 /* FunctionDeclaration */: - return createFunctionItem(node); - } - return undefined; - function getModuleName(moduleDeclaration) { - // We want to maintain quotation marks. - if (moduleDeclaration.name.kind === 9 /* StringLiteral */) { - return getTextOfNode(moduleDeclaration.name); - } - // 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 === 218 /* ModuleDeclaration */) { - moduleDeclaration = moduleDeclaration.body; - result.push(moduleDeclaration.name.text); - } - return result.join("."); - } - function createModuleItem(node) { - var moduleName = getModuleName(node); - var childItems = getItemsWorker(getChildNodes(getInnermostModule(node).body.statements), createChildItem); - return getNavigationBarItem(moduleName, ts.ScriptElementKind.moduleElement, ts.getNodeModifiers(node), [getNodeSpan(node)], childItems, getIndent(node)); - } - function createFunctionItem(node) { - if (node.body && node.body.kind === 192 /* Block */) { - var childItems = getItemsWorker(sortNodes(node.body.statements), createChildItem); - return getNavigationBarItem(!node.name ? "default" : node.name.text, ts.ScriptElementKind.functionElement, ts.getNodeModifiers(node), [getNodeSpan(node)], childItems, getIndent(node)); - } - return undefined; - } - function createSourceFileItem(node) { - var childItems = getItemsWorker(getChildNodes(node.statements), createChildItem); - if (childItems === undefined || childItems.length === 0) { - return undefined; - } - hasGlobalNode = true; - var rootName = ts.isExternalModule(node) - ? "\"" + ts.escapeString(ts.getBaseFileName(ts.removeFileExtension(ts.normalizePath(node.fileName)))) + "\"" - : ""; - return getNavigationBarItem(rootName, ts.ScriptElementKind.moduleElement, ts.ScriptElementKindModifier.none, [getNodeSpan(node)], childItems); - } - function createClassItem(node) { - var childItems; - if (node.members) { - var constructor = ts.forEach(node.members, function (member) { - return member.kind === 144 /* Constructor */ && member; - }); - // Add the constructor parameters in as children of the class (for property parameters). - // Note that *all non-binding pattern named* parameters will be added to the nodes array, but parameters that - // are not properties will be filtered out later by createChildItem. - var nodes = removeDynamicallyNamedProperties(node); - if (constructor) { - ts.addRange(nodes, ts.filter(constructor.parameters, function (p) { return !ts.isBindingPattern(p.name); })); - } - childItems = getItemsWorker(sortNodes(nodes), createChildItem); - } - var nodeName = !node.name ? "default" : node.name.text; - return getNavigationBarItem(nodeName, ts.ScriptElementKind.classElement, ts.getNodeModifiers(node), [getNodeSpan(node)], childItems, getIndent(node)); - } - function createEnumItem(node) { - var childItems = getItemsWorker(sortNodes(removeComputedProperties(node)), createChildItem); - return getNavigationBarItem(node.name.text, ts.ScriptElementKind.enumElement, ts.getNodeModifiers(node), [getNodeSpan(node)], childItems, getIndent(node)); - } - function createIterfaceItem(node) { - var childItems = getItemsWorker(sortNodes(removeDynamicallyNamedProperties(node)), createChildItem); - return getNavigationBarItem(node.name.text, ts.ScriptElementKind.interfaceElement, ts.getNodeModifiers(node), [getNodeSpan(node)], childItems, getIndent(node)); - } - } - function removeComputedProperties(node) { - return ts.filter(node.members, function (member) { return member.name === undefined || member.name.kind !== 136 /* ComputedPropertyName */; }); - } - /** - * Like removeComputedProperties, but retains the properties with well known symbol names - */ - function removeDynamicallyNamedProperties(node) { - return ts.filter(node.members, function (member) { return !ts.hasDynamicName(member); }); - } - function getInnermostModule(node) { - while (node.body.kind === 218 /* ModuleDeclaration */) { - node = node.body; - } - return node; - } - function getNodeSpan(node) { - return node.kind === 248 /* SourceFile */ - ? ts.createTextSpanFromBounds(node.getFullStart(), node.getEnd()) - : ts.createTextSpanFromBounds(node.getStart(), node.getEnd()); - } - function getTextOfNode(node) { - return ts.getTextOfNodeFromSourceText(sourceFile.text, node); - } - } - NavigationBar.getNavigationBarItems = getNavigationBarItems; - })(NavigationBar = ts.NavigationBar || (ts.NavigationBar = {})); -})(ts || (ts = {})); -/* @internal */ -var ts; -(function (ts) { - // Note(cyrusn): this enum is ordered from strongest match type to weakest match type. - (function (PatternMatchKind) { - PatternMatchKind[PatternMatchKind["exact"] = 0] = "exact"; - PatternMatchKind[PatternMatchKind["prefix"] = 1] = "prefix"; - PatternMatchKind[PatternMatchKind["substring"] = 2] = "substring"; - PatternMatchKind[PatternMatchKind["camelCase"] = 3] = "camelCase"; - })(ts.PatternMatchKind || (ts.PatternMatchKind = {})); - var PatternMatchKind = ts.PatternMatchKind; - function createPatternMatch(kind, punctuationStripped, isCaseSensitive, camelCaseWeight) { - return { - kind: kind, - punctuationStripped: punctuationStripped, - isCaseSensitive: isCaseSensitive, - camelCaseWeight: camelCaseWeight - }; - } - function createPatternMatcher(pattern) { - // We'll often see the same candidate string many times when searching (For example, when - // we see the name of a module that is used everywhere, or the name of an overload). As - // such, we cache the information we compute about the candidate for the life of this - // pattern matcher so we don't have to compute it multiple times. - var stringToWordSpans = {}; - pattern = pattern.trim(); - var fullPatternSegment = createSegment(pattern); - var dotSeparatedSegments = pattern.split(".").map(function (p) { return createSegment(p.trim()); }); - var invalidPattern = dotSeparatedSegments.length === 0 || ts.forEach(dotSeparatedSegments, segmentIsInvalid); - return { - getMatches: getMatches, - getMatchesForLastSegmentOfPattern: getMatchesForLastSegmentOfPattern, - patternContainsDots: dotSeparatedSegments.length > 1 - }; - // Quick checks so we can bail out when asked to match a candidate. - function skipMatch(candidate) { - return invalidPattern || !candidate; - } - function getMatchesForLastSegmentOfPattern(candidate) { - if (skipMatch(candidate)) { - return undefined; - } - return matchSegment(candidate, ts.lastOrUndefined(dotSeparatedSegments)); - } - function getMatches(candidateContainers, candidate) { - if (skipMatch(candidate)) { - return undefined; - } - // First, check that the last part of the dot separated pattern matches the name of the - // candidate. If not, then there's no point in proceeding and doing the more - // expensive work. - var candidateMatch = matchSegment(candidate, ts.lastOrUndefined(dotSeparatedSegments)); - if (!candidateMatch) { - return undefined; - } - candidateContainers = candidateContainers || []; - // -1 because the last part was checked against the name, and only the rest - // of the parts are checked against the container. - if (dotSeparatedSegments.length - 1 > candidateContainers.length) { - // There weren't enough container parts to match against the pattern parts. - // So this definitely doesn't match. - return undefined; - } - // So far so good. Now break up the container for the candidate and check if all - // the dotted parts match up correctly. - var totalMatch = candidateMatch; - for (var i = dotSeparatedSegments.length - 2, j = candidateContainers.length - 1; i >= 0; i--, j--) { - var segment = dotSeparatedSegments[i]; - var containerName = candidateContainers[j]; - var containerMatch = matchSegment(containerName, segment); - if (!containerMatch) { - // This container didn't match the pattern piece. So there's no match at all. - return undefined; - } - ts.addRange(totalMatch, containerMatch); - } - // Success, this symbol's full name matched against the dotted name the user was asking - // about. - return totalMatch; - } - function getWordSpans(word) { - if (!ts.hasProperty(stringToWordSpans, word)) { - stringToWordSpans[word] = breakIntoWordSpans(word); - } - return stringToWordSpans[word]; - } - function matchTextChunk(candidate, chunk, punctuationStripped) { - var index = indexOfIgnoringCase(candidate, chunk.textLowerCase); - if (index === 0) { - if (chunk.text.length === candidate.length) { - // a) Check if the part matches the candidate entirely, in an case insensitive or - // sensitive manner. If it does, return that there was an exact match. - return createPatternMatch(PatternMatchKind.exact, punctuationStripped, /*isCaseSensitive:*/ candidate === chunk.text); - } - else { - // b) Check if the part is a prefix of the candidate, in a case insensitive or sensitive - // manner. If it does, return that there was a prefix match. - return createPatternMatch(PatternMatchKind.prefix, punctuationStripped, /*isCaseSensitive:*/ startsWith(candidate, chunk.text)); - } - } - var isLowercase = chunk.isLowerCase; - if (isLowercase) { - if (index > 0) { - // c) If the part is entirely lowercase, then check if it is contained anywhere in the - // candidate in a case insensitive manner. If so, return that there was a substring - // match. - // - // Note: We only have a substring match if the lowercase part is prefix match of some - // word part. That way we don't match something like 'Class' when the user types 'a'. - // But we would match 'FooAttribute' (since 'Attribute' starts with 'a'). - var wordSpans = getWordSpans(candidate); - for (var _i = 0; _i < wordSpans.length; _i++) { - var span = wordSpans[_i]; - if (partStartsWith(candidate, span, chunk.text, /*ignoreCase:*/ true)) { - return createPatternMatch(PatternMatchKind.substring, punctuationStripped, - /*isCaseSensitive:*/ partStartsWith(candidate, span, chunk.text, /*ignoreCase:*/ false)); - } - } - } - } - else { - // d) If the part was not entirely lowercase, then check if it is contained in the - // candidate in a case *sensitive* manner. If so, return that there was a substring - // match. - if (candidate.indexOf(chunk.text) > 0) { - return createPatternMatch(PatternMatchKind.substring, punctuationStripped, /*isCaseSensitive:*/ true); - } - } - if (!isLowercase) { - // e) If the part was not entirely lowercase, then attempt a camel cased match as well. - if (chunk.characterSpans.length > 0) { - var candidateParts = getWordSpans(candidate); - var camelCaseWeight = tryCamelCaseMatch(candidate, candidateParts, chunk, /*ignoreCase:*/ false); - if (camelCaseWeight !== undefined) { - return createPatternMatch(PatternMatchKind.camelCase, punctuationStripped, /*isCaseSensitive:*/ true, /*camelCaseWeight:*/ camelCaseWeight); - } - camelCaseWeight = tryCamelCaseMatch(candidate, candidateParts, chunk, /*ignoreCase:*/ true); - if (camelCaseWeight !== undefined) { - return createPatternMatch(PatternMatchKind.camelCase, punctuationStripped, /*isCaseSensitive:*/ false, /*camelCaseWeight:*/ camelCaseWeight); - } - } - } - if (isLowercase) { - // f) Is the pattern a substring of the candidate starting on one of the candidate's word boundaries? - // We could check every character boundary start of the candidate for the pattern. However, that's - // an m * n operation in the wost case. Instead, find the first instance of the pattern - // substring, and see if it starts on a capital letter. It seems unlikely that the user will try to - // filter the list based on a substring that starts on a capital letter and also with a lowercase one. - // (Pattern: fogbar, Candidate: quuxfogbarFogBar). - if (chunk.text.length < candidate.length) { - if (index > 0 && isUpperCaseLetter(candidate.charCodeAt(index))) { - return createPatternMatch(PatternMatchKind.substring, punctuationStripped, /*isCaseSensitive:*/ false); - } - } - } - return undefined; - } - function containsSpaceOrAsterisk(text) { - for (var i = 0; i < text.length; i++) { - var ch = text.charCodeAt(i); - if (ch === 32 /* space */ || ch === 42 /* asterisk */) { - return true; - } - } - return false; - } - function matchSegment(candidate, segment) { - // First check if the segment matches as is. This is also useful if the segment contains - // characters we would normally strip when splitting into parts that we also may want to - // match in the candidate. For example if the segment is "@int" and the candidate is - // "@int", then that will show up as an exact match here. - // - // Note: if the segment contains a space or an asterisk then we must assume that it's a - // multi-word segment. - if (!containsSpaceOrAsterisk(segment.totalTextChunk.text)) { - var match = matchTextChunk(candidate, segment.totalTextChunk, /*punctuationStripped:*/ false); - if (match) { - return [match]; - } - } - // The logic for pattern matching is now as follows: - // - // 1) Break the segment passed in into words. Breaking is rather simple and a - // good way to think about it that if gives you all the individual alphanumeric words - // of the pattern. - // - // 2) For each word try to match the word against the candidate value. - // - // 3) Matching is as follows: - // - // a) Check if the word matches the candidate entirely, in an case insensitive or - // sensitive manner. If it does, return that there was an exact match. - // - // b) Check if the word is a prefix of the candidate, in a case insensitive or - // sensitive manner. If it does, return that there was a prefix match. - // - // c) If the word is entirely lowercase, then check if it is contained anywhere in the - // candidate in a case insensitive manner. If so, return that there was a substring - // match. - // - // Note: We only have a substring match if the lowercase part is prefix match of - // some word part. That way we don't match something like 'Class' when the user - // types 'a'. But we would match 'FooAttribute' (since 'Attribute' starts with - // 'a'). - // - // d) If the word was not entirely lowercase, then check if it is contained in the - // candidate in a case *sensitive* manner. If so, return that there was a substring - // match. - // - // e) If the word was not entirely lowercase, then attempt a camel cased match as - // well. - // - // f) The word is all lower case. Is it a case insensitive substring of the candidate starting - // on a part boundary of the candidate? - // - // Only if all words have some sort of match is the pattern considered matched. - var subWordTextChunks = segment.subWordTextChunks; - var matches = undefined; - for (var _i = 0; _i < subWordTextChunks.length; _i++) { - var subWordTextChunk = subWordTextChunks[_i]; - // Try to match the candidate with this word - var result = matchTextChunk(candidate, subWordTextChunk, /*punctuationStripped:*/ true); - if (!result) { - return undefined; - } - matches = matches || []; - matches.push(result); - } - return matches; - } - function partStartsWith(candidate, candidateSpan, pattern, ignoreCase, patternSpan) { - var patternPartStart = patternSpan ? patternSpan.start : 0; - var patternPartLength = patternSpan ? patternSpan.length : pattern.length; - if (patternPartLength > candidateSpan.length) { - // Pattern part is longer than the candidate part. There can never be a match. - return false; - } - if (ignoreCase) { - for (var i = 0; i < patternPartLength; i++) { - var ch1 = pattern.charCodeAt(patternPartStart + i); - var ch2 = candidate.charCodeAt(candidateSpan.start + i); - if (toLowerCase(ch1) !== toLowerCase(ch2)) { - return false; - } - } - } - else { - for (var i = 0; i < patternPartLength; i++) { - var ch1 = pattern.charCodeAt(patternPartStart + i); - var ch2 = candidate.charCodeAt(candidateSpan.start + i); - if (ch1 !== ch2) { - return false; - } - } - } - return true; - } - function tryCamelCaseMatch(candidate, candidateParts, chunk, ignoreCase) { - var chunkCharacterSpans = chunk.characterSpans; - // Note: we may have more pattern parts than candidate parts. This is because multiple - // pattern parts may match a candidate part. For example "SiUI" against "SimpleUI". - // We'll have 3 pattern parts Si/U/I against two candidate parts Simple/UI. However, U - // and I will both match in UI. - var currentCandidate = 0; - var currentChunkSpan = 0; - var firstMatch = undefined; - var contiguous = undefined; - while (true) { - // Let's consider our termination cases - if (currentChunkSpan === chunkCharacterSpans.length) { - // We did match! We shall assign a weight to this - var weight = 0; - // Was this contiguous? - if (contiguous) { - weight += 1; - } - // Did we start at the beginning of the candidate? - if (firstMatch === 0) { - weight += 2; - } - return weight; - } - else if (currentCandidate === candidateParts.length) { - // No match, since we still have more of the pattern to hit - return undefined; - } - var candidatePart = candidateParts[currentCandidate]; - var gotOneMatchThisCandidate = false; - // Consider the case of matching SiUI against SimpleUIElement. The candidate parts - // will be Simple/UI/Element, and the pattern parts will be Si/U/I. We'll match 'Si' - // against 'Simple' first. Then we'll match 'U' against 'UI'. However, we want to - // still keep matching pattern parts against that candidate part. - for (; currentChunkSpan < chunkCharacterSpans.length; currentChunkSpan++) { - var chunkCharacterSpan = chunkCharacterSpans[currentChunkSpan]; - if (gotOneMatchThisCandidate) { - // We've already gotten one pattern part match in this candidate. We will - // only continue trying to consumer pattern parts if the last part and this - // part are both upper case. - if (!isUpperCaseLetter(chunk.text.charCodeAt(chunkCharacterSpans[currentChunkSpan - 1].start)) || - !isUpperCaseLetter(chunk.text.charCodeAt(chunkCharacterSpans[currentChunkSpan].start))) { - break; - } - } - if (!partStartsWith(candidate, candidatePart, chunk.text, ignoreCase, chunkCharacterSpan)) { - break; - } - gotOneMatchThisCandidate = true; - firstMatch = firstMatch === undefined ? currentCandidate : firstMatch; - // If we were contiguous, then keep that value. If we weren't, then keep that - // value. If we don't know, then set the value to 'true' as an initial match is - // obviously contiguous. - contiguous = contiguous === undefined ? true : contiguous; - candidatePart = ts.createTextSpan(candidatePart.start + chunkCharacterSpan.length, candidatePart.length - chunkCharacterSpan.length); - } - // Check if we matched anything at all. If we didn't, then we need to unset the - // contiguous bit if we currently had it set. - // If we haven't set the bit yet, then that means we haven't matched anything so - // far, and we don't want to change that. - if (!gotOneMatchThisCandidate && contiguous !== undefined) { - contiguous = false; - } - // Move onto the next candidate. - currentCandidate++; - } - } - } - ts.createPatternMatcher = createPatternMatcher; - // Helper function to compare two matches to determine which is better. Matches are first - // ordered by kind (so all prefix matches always beat all substring matches). Then, if the - // match is a camel case match, the relative weights of the match are used to determine - // which is better (with a greater weight being better). Then if the match is of the same - // type, then a case sensitive match is considered better than an insensitive one. - function patternMatchCompareTo(match1, match2) { - return compareType(match1, match2) || - compareCamelCase(match1, match2) || - compareCase(match1, match2) || - comparePunctuation(match1, match2); - } - function comparePunctuation(result1, result2) { - // Consider a match to be better if it was successful without stripping punctuation - // versus a match that had to strip punctuation to succeed. - if (result1.punctuationStripped !== result2.punctuationStripped) { - return result1.punctuationStripped ? 1 : -1; - } - return 0; - } - function compareCase(result1, result2) { - if (result1.isCaseSensitive !== result2.isCaseSensitive) { - return result1.isCaseSensitive ? -1 : 1; - } - return 0; - } - function compareType(result1, result2) { - return result1.kind - result2.kind; - } - function compareCamelCase(result1, result2) { - if (result1.kind === PatternMatchKind.camelCase && result2.kind === PatternMatchKind.camelCase) { - // Swap the values here. If result1 has a higher weight, then we want it to come - // first. - return result2.camelCaseWeight - result1.camelCaseWeight; - } - return 0; - } - function createSegment(text) { - return { - totalTextChunk: createTextChunk(text), - subWordTextChunks: breakPatternIntoTextChunks(text) - }; - } - // A segment is considered invalid if we couldn't find any words in it. - function segmentIsInvalid(segment) { - return segment.subWordTextChunks.length === 0; - } - function isUpperCaseLetter(ch) { - // Fast check for the ascii range. - if (ch >= 65 /* A */ && ch <= 90 /* Z */) { - return true; - } - if (ch < 127 /* maxAsciiCharacter */ || !ts.isUnicodeIdentifierStart(ch, 2 /* Latest */)) { - return false; - } - // TODO: find a way to determine this for any unicode characters in a - // non-allocating manner. - var str = String.fromCharCode(ch); - return str === str.toUpperCase(); - } - function isLowerCaseLetter(ch) { - // Fast check for the ascii range. - if (ch >= 97 /* a */ && ch <= 122 /* z */) { - return true; - } - if (ch < 127 /* maxAsciiCharacter */ || !ts.isUnicodeIdentifierStart(ch, 2 /* Latest */)) { - return false; - } - // TODO: find a way to determine this for any unicode characters in a - // non-allocating manner. - var str = String.fromCharCode(ch); - return str === str.toLowerCase(); - } - function containsUpperCaseLetter(string) { - for (var i = 0, n = string.length; i < n; i++) { - if (isUpperCaseLetter(string.charCodeAt(i))) { - return true; - } - } - return false; - } - function startsWith(string, search) { - for (var i = 0, n = search.length; i < n; i++) { - if (string.charCodeAt(i) !== search.charCodeAt(i)) { - return false; - } - } - return true; - } - // Assumes 'value' is already lowercase. - function indexOfIgnoringCase(string, value) { - for (var i = 0, n = string.length - value.length; i <= n; i++) { - if (startsWithIgnoringCase(string, value, i)) { - return i; - } - } - return -1; - } - // Assumes 'value' is already lowercase. - function startsWithIgnoringCase(string, value, start) { - for (var i = 0, n = value.length; i < n; i++) { - var ch1 = toLowerCase(string.charCodeAt(i + start)); - var ch2 = value.charCodeAt(i); - if (ch1 !== ch2) { - return false; - } - } - return true; - } - function toLowerCase(ch) { - // Fast convert for the ascii range. - if (ch >= 65 /* A */ && ch <= 90 /* Z */) { - return 97 /* a */ + (ch - 65 /* A */); - } - if (ch < 127 /* maxAsciiCharacter */) { - return ch; - } - // TODO: find a way to compute this for any unicode characters in a - // non-allocating manner. - return String.fromCharCode(ch).toLowerCase().charCodeAt(0); - } - function isDigit(ch) { - // TODO(cyrusn): Find a way to support this for unicode digits. - return ch >= 48 /* _0 */ && ch <= 57 /* _9 */; - } - function isWordChar(ch) { - return isUpperCaseLetter(ch) || isLowerCaseLetter(ch) || isDigit(ch) || ch === 95 /* _ */ || ch === 36 /* $ */; - } - function breakPatternIntoTextChunks(pattern) { - var result = []; - var wordStart = 0; - var wordLength = 0; - for (var i = 0; i < pattern.length; i++) { - var ch = pattern.charCodeAt(i); - if (isWordChar(ch)) { - if (wordLength++ === 0) { - wordStart = i; - } - } - else { - if (wordLength > 0) { - result.push(createTextChunk(pattern.substr(wordStart, wordLength))); - wordLength = 0; - } - } - } - if (wordLength > 0) { - result.push(createTextChunk(pattern.substr(wordStart, wordLength))); - } - return result; - } - function createTextChunk(text) { - var textLowerCase = text.toLowerCase(); - return { - text: text, - textLowerCase: textLowerCase, - isLowerCase: text === textLowerCase, - characterSpans: breakIntoCharacterSpans(text) - }; - } - /* @internal */ function breakIntoCharacterSpans(identifier) { - return breakIntoSpans(identifier, /*word:*/ false); - } - ts.breakIntoCharacterSpans = breakIntoCharacterSpans; - /* @internal */ function breakIntoWordSpans(identifier) { - return breakIntoSpans(identifier, /*word:*/ true); - } - ts.breakIntoWordSpans = breakIntoWordSpans; - function breakIntoSpans(identifier, word) { - var result = []; - var wordStart = 0; - for (var i = 1, n = identifier.length; i < n; i++) { - var lastIsDigit = isDigit(identifier.charCodeAt(i - 1)); - var currentIsDigit = isDigit(identifier.charCodeAt(i)); - var hasTransitionFromLowerToUpper = transitionFromLowerToUpper(identifier, word, i); - var hasTransitionFromUpperToLower = transitionFromUpperToLower(identifier, word, i, wordStart); - if (charIsPunctuation(identifier.charCodeAt(i - 1)) || - charIsPunctuation(identifier.charCodeAt(i)) || - lastIsDigit !== currentIsDigit || - hasTransitionFromLowerToUpper || - hasTransitionFromUpperToLower) { - if (!isAllPunctuation(identifier, wordStart, i)) { - result.push(ts.createTextSpan(wordStart, i - wordStart)); - } - wordStart = i; - } - } - if (!isAllPunctuation(identifier, wordStart, identifier.length)) { - result.push(ts.createTextSpan(wordStart, identifier.length - wordStart)); - } - return result; - } - function charIsPunctuation(ch) { - switch (ch) { - case 33 /* exclamation */: - case 34 /* doubleQuote */: - case 35 /* hash */: - case 37 /* percent */: - case 38 /* ampersand */: - case 39 /* singleQuote */: - case 40 /* openParen */: - case 41 /* closeParen */: - case 42 /* asterisk */: - case 44 /* comma */: - case 45 /* minus */: - case 46 /* dot */: - case 47 /* slash */: - case 58 /* colon */: - case 59 /* semicolon */: - case 63 /* question */: - case 64 /* at */: - case 91 /* openBracket */: - case 92 /* backslash */: - case 93 /* closeBracket */: - case 95 /* _ */: - case 123 /* openBrace */: - case 125 /* closeBrace */: - return true; - } - return false; - } - function isAllPunctuation(identifier, start, end) { - for (var i = start; i < end; i++) { - var ch = identifier.charCodeAt(i); - // We don't consider _ or $ as punctuation as there may be things with that name. - if (!charIsPunctuation(ch) || ch === 95 /* _ */ || ch === 36 /* $ */) { - return false; - } - } - return true; - } - function transitionFromUpperToLower(identifier, word, index, wordStart) { - if (word) { - // Cases this supports: - // 1) IDisposable -> I, Disposable - // 2) UIElement -> UI, Element - // 3) HTMLDocument -> HTML, Document - // - // etc. - if (index !== wordStart && - index + 1 < identifier.length) { - var currentIsUpper = isUpperCaseLetter(identifier.charCodeAt(index)); - var nextIsLower = isLowerCaseLetter(identifier.charCodeAt(index + 1)); - if (currentIsUpper && nextIsLower) { - // We have a transition from an upper to a lower letter here. But we only - // want to break if all the letters that preceded are uppercase. i.e. if we - // have "Foo" we don't want to break that into "F, oo". But if we have - // "IFoo" or "UIFoo", then we want to break that into "I, Foo" and "UI, - // Foo". i.e. the last uppercase letter belongs to the lowercase letters - // that follows. Note: this will make the following not split properly: - // "HELLOthere". However, these sorts of names do not show up in .Net - // programs. - for (var i = wordStart; i < index; i++) { - if (!isUpperCaseLetter(identifier.charCodeAt(i))) { - return false; - } - } - return true; - } - } - } - return false; - } - function transitionFromLowerToUpper(identifier, word, index) { - var lastIsUpper = isUpperCaseLetter(identifier.charCodeAt(index - 1)); - var currentIsUpper = isUpperCaseLetter(identifier.charCodeAt(index)); - // See if the casing indicates we're starting a new word. Note: if we're breaking on - // words, then just seeing an upper case character isn't enough. Instead, it has to - // be uppercase and the previous character can't be uppercase. - // - // For example, breaking "AddMetadata" on words would make: Add Metadata - // - // on characters would be: A dd M etadata - // - // Break "AM" on words would be: AM - // - // on characters would be: A M - // - // We break the search string on characters. But we break the symbol name on words. - var transition = word - ? (currentIsUpper && !lastIsUpper) - : currentIsUpper; - return transition; - } -})(ts || (ts = {})); -/// -/* @internal */ -var ts; -(function (ts) { - var SignatureHelp; - (function (SignatureHelp) { - // A partially written generic type expression is not guaranteed to have the correct syntax tree. the expression could be parsed as less than/greater than expression or a comma expression - // or some other combination depending on what the user has typed so far. For the purposes of signature help we need to consider any location after "<" as a possible generic type reference. - // To do this, the method will back parse the expression starting at the position required. it will try to parse the current expression as a generic type expression, if it did succeed it - // will return the generic identifier that started the expression (e.g. "foo" in "foo(#a, b) -> The token introduces a list, and should begin a sig help session - // Case 2: - // fo#o#(a, b)# -> The token is either not associated with a list, or ends a list, so the session should end - // 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 */) { - // 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); - var isTypeArgList = callExpression.typeArguments && callExpression.typeArguments.pos === list.pos; - ts.Debug.assert(list !== undefined); - return { - kind: isTypeArgList ? 0 /* TypeArguments */ : 1 /* CallArguments */, - invocation: callExpression, - argumentsSpan: getApplicableSpanForArguments(list), - argumentIndex: 0, - argumentCount: getArgumentCount(list) - }; - } - // findListItemInfo can return undefined if we are not in parent's argument list - // or type argument list. This includes cases where the cursor is: - // - To the right of the closing paren, non-substitution template, or template tail. - // - Between the type arguments and the arguments (greater than token) - // - On the target of the call (parent.func) - // - On the 'new' keyword in a 'new' expression - var listItemInfo = ts.findListItemInfo(node); - if (listItemInfo) { - var list = listItemInfo.list; - var isTypeArgList = callExpression.typeArguments && callExpression.typeArguments.pos === list.pos; - var argumentIndex = getArgumentIndex(list, node); - var argumentCount = getArgumentCount(list); - ts.Debug.assert(argumentIndex === 0 || argumentIndex < argumentCount, "argumentCount < argumentIndex, " + argumentCount + " < " + argumentIndex); - return { - kind: isTypeArgList ? 0 /* TypeArguments */ : 1 /* CallArguments */, - invocation: callExpression, - argumentsSpan: getApplicableSpanForArguments(list), - argumentIndex: argumentIndex, - argumentCount: argumentCount - }; - } - } - else if (node.kind === 11 /* NoSubstitutionTemplateLiteral */ && node.parent.kind === 170 /* TaggedTemplateExpression */) { - // Check if we're actually inside the template; - // otherwise we'll fall out and return undefined. - if (ts.isInsideTemplateLiteral(node, position)) { - return getArgumentListInfoForTemplate(node.parent, /*argumentIndex*/ 0); - } - } - else if (node.kind === 12 /* TemplateHead */ && node.parent.parent.kind === 170 /* TaggedTemplateExpression */) { - var templateExpression = node.parent; - var tagExpression = templateExpression.parent; - ts.Debug.assert(templateExpression.kind === 183 /* TemplateExpression */); - var argumentIndex = ts.isInsideTemplateLiteral(node, position) ? 0 : 1; - return getArgumentListInfoForTemplate(tagExpression, argumentIndex); - } - else if (node.parent.kind === 190 /* TemplateSpan */ && node.parent.parent.parent.kind === 170 /* TaggedTemplateExpression */) { - var templateSpan = node.parent; - var templateExpression = templateSpan.parent; - var tagExpression = templateExpression.parent; - ts.Debug.assert(templateExpression.kind === 183 /* TemplateExpression */); - // If we're just after a template tail, don't show signature help. - if (node.kind === 14 /* TemplateTail */ && !ts.isInsideTemplateLiteral(node, position)) { - return undefined; - } - var spanIndex = templateExpression.templateSpans.indexOf(templateSpan); - var argumentIndex = getArgumentIndexForTemplatePiece(spanIndex, node); - return getArgumentListInfoForTemplate(tagExpression, argumentIndex); - } - return undefined; - } - function getArgumentIndex(argumentsList, node) { - // The list we got back can include commas. In the presence of errors it may - // also just have nodes without commas. For example "Foo(a b c)" will have 3 - // args without commas. We want to find what index we're at. So we count - // forward until we hit ourselves, only incrementing the index if it isn't a - // comma. - // - // Note: the subtlety around trailing commas (in getArgumentCount) does not apply - // here. That's because we're only walking forward until we hit the node we're - // on. In that case, even if we're after the trailing comma, we'll still see - // that trailing comma in the list, and we'll have generated the appropriate - // arg index. - var argumentIndex = 0; - var listChildren = argumentsList.getChildren(); - for (var _i = 0; _i < listChildren.length; _i++) { - var child = listChildren[_i]; - if (child === node) { - break; - } - if (child.kind !== 24 /* CommaToken */) { - argumentIndex++; - } - } - return argumentIndex; - } - function getArgumentCount(argumentsList) { - // The argument count for a list is normally the number of non-comma children it has. - // For example, if you have "Foo(a,b)" then there will be three children of the arg - // list 'a' '' 'b'. So, in this case the arg count will be 2. However, there - // is a small subtlety. If you have "Foo(a,)", then the child list will just have - // 'a' ''. So, in the case where the last child is a comma, we increase the - // arg count by one to compensate. - // - // Note: this subtlety only applies to the last comma. If you had "Foo(a,," then - // we'll have: 'a' '' '' - // 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 */) { - argumentCount++; - } - return argumentCount; - } - // spanIndex is either the index for a given template span. - // This does not give appropriate results for a NoSubstitutionTemplateLiteral - function getArgumentIndexForTemplatePiece(spanIndex, node) { - // Because the TemplateStringsArray is the first argument, we have to offset each substitution expression by 1. - // There are three cases we can encounter: - // 1. We are precisely in the template literal (argIndex = 0). - // 2. We are in or to the right of the substitution expression (argIndex = spanIndex + 1). - // 3. We are directly to the right of the template literal, but because we look for the token on the left, - // not enough to put us in the substitution expression; we should consider ourselves part of - // the *next* span's expression by offsetting the index (argIndex = (spanIndex + 1) + 1). - // - // Example: f `# abcd $#{# 1 + 1# }# efghi ${ #"#hello"# } # ` - // ^ ^ ^ ^ ^ ^ ^ ^ ^ - // Case: 1 1 3 2 1 3 2 2 1 - ts.Debug.assert(position >= node.getStart(), "Assumed 'position' could not occur before node."); - if (ts.isTemplateLiteralKind(node.kind)) { - if (ts.isInsideTemplateLiteral(node, position)) { - return 0; - } - return spanIndex + 2; - } - return spanIndex + 1; - } - function getArgumentListInfoForTemplate(tagExpression, argumentIndex) { - // argumentCount is either 1 or (numSpans + 1) to account for the template strings array argument. - var argumentCount = tagExpression.template.kind === 11 /* NoSubstitutionTemplateLiteral */ - ? 1 - : tagExpression.template.templateSpans.length + 1; - ts.Debug.assert(argumentIndex === 0 || argumentIndex < argumentCount, "argumentCount < argumentIndex, " + argumentCount + " < " + argumentIndex); - return { - kind: 2 /* TaggedTemplateArguments */, - invocation: tagExpression, - argumentsSpan: getApplicableSpanForTaggedTemplate(tagExpression), - argumentIndex: argumentIndex, - argumentCount: argumentCount - }; - } - function getApplicableSpanForArguments(argumentsList) { - // We use full start and skip trivia on the end because we want to include trivia on - // both sides. For example, - // - // foo( /*comment */ a, b, c /*comment*/ ) - // | | - // - // The applicable span is from the first bar to the second bar (inclusive, - // but not including parentheses) - var applicableSpanStart = argumentsList.getFullStart(); - var applicableSpanEnd = ts.skipTrivia(sourceFile.text, argumentsList.getEnd(), /*stopAfterLineBreak*/ false); - return ts.createTextSpan(applicableSpanStart, applicableSpanEnd - applicableSpanStart); - } - function getApplicableSpanForTaggedTemplate(taggedTemplate) { - var template = taggedTemplate.template; - var applicableSpanStart = template.getStart(); - var applicableSpanEnd = template.getEnd(); - // We need to adjust the end position for the case where the template does not have a tail. - // Otherwise, we will not show signature help past the expression. - // For example, - // - // ` ${ 1 + 1 foo(10) - // | | - // - // 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 === 183 /* TemplateExpression */) { - var lastSpan = ts.lastOrUndefined(template.templateSpans); - if (lastSpan.literal.getFullWidth() === 0) { - applicableSpanEnd = ts.skipTrivia(sourceFile.text, applicableSpanEnd, /*stopAfterLineBreak*/ false); - } - } - return ts.createTextSpan(applicableSpanStart, applicableSpanEnd - applicableSpanStart); - } - function getContainingArgumentInfo(node) { - for (var n = node; n.kind !== 248 /* SourceFile */; n = n.parent) { - if (ts.isFunctionBlock(n)) { - return undefined; - } - // If the node is not a subspan of its parent, this is a big problem. - // There have been crashes that might be caused by this violation. - if (n.pos < n.parent.pos || n.end > n.parent.end) { - ts.Debug.fail("Node of kind " + n.kind + " is not a subspan of its parent of kind " + n.parent.kind); - } - var argumentInfo_1 = getImmediatelyContainingArgumentInfo(n); - if (argumentInfo_1) { - return argumentInfo_1; - } - } - return undefined; - } - function getChildListThatStartsWithOpenerToken(parent, openerToken, sourceFile) { - var children = parent.getChildren(sourceFile); - var indexOfOpenerToken = children.indexOf(openerToken); - ts.Debug.assert(indexOfOpenerToken >= 0 && children.length > indexOfOpenerToken + 1); - return children[indexOfOpenerToken + 1]; - } - /** - * The selectedItemIndex could be negative for several reasons. - * 1. There are too many arguments for all of the overloads - * 2. None of the overloads were type compatible - * The solution here is to try to pick the best overload by picking - * either the first one that has an appropriate number of parameters, - * or the one with the most parameters. - */ - function selectBestInvalidOverloadIndex(candidates, argumentCount) { - var maxParamsSignatureIndex = -1; - var maxParams = -1; - for (var i = 0; i < candidates.length; i++) { - var candidate = candidates[i]; - if (candidate.hasRestParameter || candidate.parameters.length >= argumentCount) { - return i; - } - if (candidate.parameters.length > maxParams) { - maxParams = candidate.parameters.length; - maxParamsSignatureIndex = i; - } - } - return maxParamsSignatureIndex; - } - function createSignatureHelpItems(candidates, bestSignature, argumentListInfo) { - var applicableSpan = argumentListInfo.argumentsSpan; - var isTypeParameterList = argumentListInfo.kind === 0 /* TypeArguments */; - var invocation = argumentListInfo.invocation; - var callTarget = ts.getInvokedExpression(invocation); - var callTargetSymbol = typeChecker.getSymbolAtLocation(callTarget); - var callTargetDisplayParts = callTargetSymbol && ts.symbolToDisplayParts(typeChecker, callTargetSymbol, /*enclosingDeclaration*/ undefined, /*meaning*/ undefined); - var items = ts.map(candidates, function (candidateSignature) { - var signatureHelpParameters; - var prefixDisplayParts = []; - var suffixDisplayParts = []; - if (callTargetDisplayParts) { - ts.addRange(prefixDisplayParts, callTargetDisplayParts); - } - if (isTypeParameterList) { - prefixDisplayParts.push(ts.punctuationPart(25 /* LessThanToken */)); - var typeParameters = candidateSignature.typeParameters; - signatureHelpParameters = typeParameters && typeParameters.length > 0 ? ts.map(typeParameters, createSignatureHelpParameterForTypeParameter) : emptyArray; - suffixDisplayParts.push(ts.punctuationPart(27 /* GreaterThanToken */)); - var parameterParts = ts.mapToDisplayParts(function (writer) { - return typeChecker.getSymbolDisplayBuilder().buildDisplayForParametersAndDelimiters(candidateSignature.parameters, writer, invocation); - }); - ts.addRange(suffixDisplayParts, parameterParts); - } - else { - var typeParameterParts = ts.mapToDisplayParts(function (writer) { - return typeChecker.getSymbolDisplayBuilder().buildDisplayForTypeParametersAndDelimiters(candidateSignature.typeParameters, writer, invocation); - }); - ts.addRange(prefixDisplayParts, typeParameterParts); - prefixDisplayParts.push(ts.punctuationPart(17 /* OpenParenToken */)); - var parameters = candidateSignature.parameters; - signatureHelpParameters = parameters.length > 0 ? ts.map(parameters, createSignatureHelpParameterForParameter) : emptyArray; - suffixDisplayParts.push(ts.punctuationPart(18 /* CloseParenToken */)); - } - var returnTypeParts = ts.mapToDisplayParts(function (writer) { - return typeChecker.getSymbolDisplayBuilder().buildReturnTypeDisplay(candidateSignature, writer, invocation); - }); - ts.addRange(suffixDisplayParts, returnTypeParts); - return { - isVariadic: candidateSignature.hasRestParameter, - prefixDisplayParts: prefixDisplayParts, - suffixDisplayParts: suffixDisplayParts, - separatorDisplayParts: [ts.punctuationPart(24 /* CommaToken */), ts.spacePart()], - parameters: signatureHelpParameters, - documentation: candidateSignature.getDocumentationComment() - }; - }); - var argumentIndex = argumentListInfo.argumentIndex; - // argumentCount is the *apparent* number of arguments. - var argumentCount = argumentListInfo.argumentCount; - var selectedItemIndex = candidates.indexOf(bestSignature); - if (selectedItemIndex < 0) { - selectedItemIndex = selectBestInvalidOverloadIndex(candidates, argumentCount); - } - ts.Debug.assert(argumentIndex === 0 || argumentIndex < argumentCount, "argumentCount < argumentIndex, " + argumentCount + " < " + argumentIndex); - return { - items: items, - applicableSpan: applicableSpan, - selectedItemIndex: selectedItemIndex, - argumentIndex: argumentIndex, - argumentCount: argumentCount - }; - function createSignatureHelpParameterForParameter(parameter) { - var displayParts = ts.mapToDisplayParts(function (writer) { - return typeChecker.getSymbolDisplayBuilder().buildParameterDisplay(parameter, writer, invocation); - }); - return { - name: parameter.name, - documentation: parameter.getDocumentationComment(), - displayParts: displayParts, - isOptional: typeChecker.isOptionalParameter(parameter.valueDeclaration) - }; - } - function createSignatureHelpParameterForTypeParameter(typeParameter) { - var displayParts = ts.mapToDisplayParts(function (writer) { - return typeChecker.getSymbolDisplayBuilder().buildTypeParameterDisplay(typeParameter, writer, invocation); - }); - return { - name: typeParameter.symbol.name, - documentation: emptyArray, - displayParts: displayParts, - isOptional: false - }; - } - } - } - SignatureHelp.getSignatureHelpItems = getSignatureHelpItems; - })(SignatureHelp = ts.SignatureHelp || (ts.SignatureHelp = {})); -})(ts || (ts = {})); -// These utilities are common to multiple language service features. -/* @internal */ -var ts; -(function (ts) { - function getEndLinePosition(line, sourceFile) { - ts.Debug.assert(line >= 0); - var lineStarts = sourceFile.getLineStarts(); - var lineIndex = line; - if (lineIndex + 1 === lineStarts.length) { - // last line - return EOF - return sourceFile.text.length - 1; - } - else { - // current line start - var start = lineStarts[lineIndex]; - // take the start position of the next line -1 = it should be some line break - var pos = lineStarts[lineIndex + 1] - 1; - ts.Debug.assert(ts.isLineBreak(sourceFile.text.charCodeAt(pos))); - // walk backwards skipping line breaks, stop the the beginning of current line. - // i.e: - // - // $ <- end of line for this position should match the start position - while (start <= pos && ts.isLineBreak(sourceFile.text.charCodeAt(pos))) { - pos--; - } - return pos; - } - } - ts.getEndLinePosition = getEndLinePosition; - function getLineStartPositionForPosition(position, sourceFile) { - var lineStarts = sourceFile.getLineStarts(); - var line = sourceFile.getLineAndCharacterOfPosition(position).line; - return lineStarts[line]; - } - ts.getLineStartPositionForPosition = getLineStartPositionForPosition; - function rangeContainsRange(r1, r2) { - return startEndContainsRange(r1.pos, r1.end, r2); - } - ts.rangeContainsRange = rangeContainsRange; - function startEndContainsRange(start, end, range) { - return start <= range.pos && end >= range.end; - } - ts.startEndContainsRange = startEndContainsRange; - function rangeContainsStartEnd(range, start, end) { - return range.pos <= start && range.end >= end; - } - ts.rangeContainsStartEnd = rangeContainsStartEnd; - function rangeOverlapsWithStartEnd(r1, start, end) { - return startEndOverlapsWithStartEnd(r1.pos, r1.end, start, end); - } - ts.rangeOverlapsWithStartEnd = rangeOverlapsWithStartEnd; - function startEndOverlapsWithStartEnd(start1, end1, start2, end2) { - var start = Math.max(start1, start2); - var end = Math.min(end1, end2); - return start < end; - } - ts.startEndOverlapsWithStartEnd = startEndOverlapsWithStartEnd; - function positionBelongsToNode(candidate, position, sourceFile) { - return candidate.end > position || !isCompletedNode(candidate, sourceFile); - } - ts.positionBelongsToNode = positionBelongsToNode; - function isCompletedNode(n, sourceFile) { - if (ts.nodeIsMissing(n)) { - return false; - } - switch (n.kind) { - case 214 /* ClassDeclaration */: - case 215 /* InterfaceDeclaration */: - case 217 /* EnumDeclaration */: - case 165 /* ObjectLiteralExpression */: - case 161 /* ObjectBindingPattern */: - case 155 /* TypeLiteral */: - case 192 /* Block */: - case 219 /* ModuleBlock */: - case 220 /* CaseBlock */: - return nodeEndsWith(n, 16 /* CloseBraceToken */, sourceFile); - case 244 /* CatchClause */: - return isCompletedNode(n.block, sourceFile); - case 169 /* NewExpression */: - if (!n.arguments) { - return true; - } - // fall through - case 168 /* CallExpression */: - case 172 /* ParenthesizedExpression */: - case 160 /* ParenthesizedType */: - return nodeEndsWith(n, 18 /* CloseParenToken */, sourceFile); - case 152 /* FunctionType */: - case 153 /* ConstructorType */: - return isCompletedNode(n.type, sourceFile); - case 144 /* Constructor */: - case 145 /* GetAccessor */: - case 146 /* SetAccessor */: - case 213 /* FunctionDeclaration */: - case 173 /* FunctionExpression */: - case 143 /* MethodDeclaration */: - case 142 /* MethodSignature */: - case 148 /* ConstructSignature */: - case 147 /* CallSignature */: - case 174 /* ArrowFunction */: - if (n.body) { - return isCompletedNode(n.body, sourceFile); - } - if (n.type) { - return isCompletedNode(n.type, sourceFile); - } - // 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 218 /* ModuleDeclaration */: - return n.body && isCompletedNode(n.body, sourceFile); - case 196 /* IfStatement */: - if (n.elseStatement) { - return isCompletedNode(n.elseStatement, sourceFile); - } - return isCompletedNode(n.thenStatement, sourceFile); - case 195 /* ExpressionStatement */: - return isCompletedNode(n.expression, sourceFile) || - hasChildOfKind(n, 23 /* SemicolonToken */); - case 164 /* ArrayLiteralExpression */: - case 162 /* ArrayBindingPattern */: - case 167 /* ElementAccessExpression */: - case 136 /* ComputedPropertyName */: - case 157 /* TupleType */: - return nodeEndsWith(n, 20 /* CloseBracketToken */, sourceFile); - case 149 /* IndexSignature */: - if (n.type) { - return isCompletedNode(n.type, sourceFile); - } - return hasChildOfKind(n, 20 /* CloseBracketToken */, sourceFile); - case 241 /* CaseClause */: - case 242 /* DefaultClause */: - // there is no such thing as terminator token for CaseClause/DefaultClause so for simplicitly always consider them non-completed - return false; - case 199 /* ForStatement */: - case 200 /* ForInStatement */: - case 201 /* ForOfStatement */: - case 198 /* WhileStatement */: - return isCompletedNode(n.statement, sourceFile); - case 197 /* 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); - if (hasWhileKeyword) { - return nodeEndsWith(n, 18 /* CloseParenToken */, sourceFile); - } - return isCompletedNode(n.statement, sourceFile); - case 154 /* TypeQuery */: - return isCompletedNode(n.exprName, sourceFile); - case 176 /* TypeOfExpression */: - case 175 /* DeleteExpression */: - case 177 /* VoidExpression */: - case 184 /* YieldExpression */: - case 185 /* SpreadElementExpression */: - var unaryWordExpression = n; - return isCompletedNode(unaryWordExpression.expression, sourceFile); - case 170 /* TaggedTemplateExpression */: - return isCompletedNode(n.template, sourceFile); - case 183 /* TemplateExpression */: - var lastSpan = ts.lastOrUndefined(n.templateSpans); - return isCompletedNode(lastSpan, sourceFile); - case 190 /* TemplateSpan */: - return ts.nodeIsPresent(n.literal); - case 179 /* PrefixUnaryExpression */: - return isCompletedNode(n.operand, sourceFile); - case 181 /* BinaryExpression */: - return isCompletedNode(n.right, sourceFile); - case 182 /* ConditionalExpression */: - return isCompletedNode(n.whenFalse, sourceFile); - default: - return true; - } - } - ts.isCompletedNode = isCompletedNode; - /* - * Checks if node ends with 'expectedLastToken'. - * If child at position 'length - 1' is 'SemicolonToken' it is skipped and 'expectedLastToken' is compared with child at position 'length - 2'. - */ - function nodeEndsWith(n, expectedLastToken, sourceFile) { - var children = n.getChildren(sourceFile); - if (children.length) { - var last = ts.lastOrUndefined(children); - if (last.kind === expectedLastToken) { - return true; - } - else if (last.kind === 23 /* SemicolonToken */ && children.length !== 1) { - return children[children.length - 2].kind === expectedLastToken; - } - } - return false; - } - function findListItemInfo(node) { - var list = findContainingList(node); - // It is possible at this point for syntaxList to be undefined, either if - // node.parent had no list child, or if none of its list children contained - // the span of node. If this happens, return undefined. The caller should - // handle this case. - if (!list) { - return undefined; - } - var children = list.getChildren(); - var listItemIndex = ts.indexOf(children, node); - return { - listItemIndex: listItemIndex, - list: list - }; - } - ts.findListItemInfo = findListItemInfo; - function hasChildOfKind(n, kind, sourceFile) { - return !!findChildOfKind(n, kind, sourceFile); - } - ts.hasChildOfKind = hasChildOfKind; - function findChildOfKind(n, kind, sourceFile) { - return ts.forEach(n.getChildren(sourceFile), function (c) { return c.kind === kind && c; }); - } - ts.findChildOfKind = findChildOfKind; - function findContainingList(node) { - // The node might be a list element (nonsynthetic) or a comma (synthetic). Either way, it will - // be parented by the container of the SyntaxList, not the SyntaxList itself. - // In order to find the list item index, we first need to locate SyntaxList itself and then search - // for the position of the relevant node (or comma). - var syntaxList = ts.forEach(node.parent.getChildren(), function (c) { - // find syntax list that covers the span of the node - if (c.kind === 271 /* SyntaxList */ && c.pos <= node.pos && c.end >= node.end) { - return c; - } - }); - // Either we didn't find an appropriate list, or the list must contain us. - ts.Debug.assert(!syntaxList || ts.contains(syntaxList.getChildren(), node)); - return syntaxList; - } - ts.findContainingList = findContainingList; - /* Gets the token whose text has range [start, end) and - * position >= start and (position < end or (position === end && token is keyword or identifier)) - */ - function getTouchingWord(sourceFile, position) { - return getTouchingToken(sourceFile, position, function (n) { return isWord(n.kind); }); - } - ts.getTouchingWord = getTouchingWord; - /* Gets the token whose text has range [start, end) and position >= start - * and (position < end or (position === end && token is keyword or identifier or numeric\string litera)) - */ - function getTouchingPropertyName(sourceFile, position) { - return getTouchingToken(sourceFile, position, function (n) { return isPropertyName(n.kind); }); - } - ts.getTouchingPropertyName = getTouchingPropertyName; - /** Returns the token if position is in [start, end) or if position === end and includeItemAtEndPosition(token) === true */ - function getTouchingToken(sourceFile, position, includeItemAtEndPosition) { - return getTokenAtPositionWorker(sourceFile, position, /*allowPositionInLeadingTrivia*/ false, includeItemAtEndPosition); - } - ts.getTouchingToken = getTouchingToken; - /** Returns a token if position is in [start-of-leading-trivia, end) */ - function getTokenAtPosition(sourceFile, position) { - return getTokenAtPositionWorker(sourceFile, position, /*allowPositionInLeadingTrivia*/ true, /*includeItemAtEndPosition*/ undefined); - } - ts.getTokenAtPosition = getTokenAtPosition; - /** Get the token whose text contains the position */ - function getTokenAtPositionWorker(sourceFile, position, allowPositionInLeadingTrivia, includeItemAtEndPosition) { - var current = sourceFile; - outer: while (true) { - if (isToken(current)) { - // exit early - return current; - } - // find the child that contains 'position' - for (var i = 0, n = current.getChildCount(sourceFile); i < n; i++) { - var child = current.getChildAt(i); - var start = allowPositionInLeadingTrivia ? child.getFullStart() : child.getStart(sourceFile); - if (start <= position) { - var end = child.getEnd(); - if (position < end || (position === end && child.kind === 1 /* EndOfFileToken */)) { - current = child; - continue outer; - } - else if (includeItemAtEndPosition && end === position) { - var previousToken = findPrecedingToken(position, sourceFile, child); - if (previousToken && includeItemAtEndPosition(previousToken)) { - return previousToken; - } - } - } - } - return current; - } - } - /** - * The token on the left of the position is the token that strictly includes the position - * or sits to the left of the cursor if it is on a boundary. For example - * - * fo|o -> will return foo - * foo |bar -> will return foo - * - */ - function findTokenOnLeftOfPosition(file, position) { - // Ideally, getTokenAtPosition should return a token. However, it is currently - // broken, so we do a check to make sure the result was indeed a token. - var tokenAtPosition = getTokenAtPosition(file, position); - if (isToken(tokenAtPosition) && position > tokenAtPosition.getStart(file) && position < tokenAtPosition.getEnd()) { - return tokenAtPosition; - } - return findPrecedingToken(position, file); - } - ts.findTokenOnLeftOfPosition = findTokenOnLeftOfPosition; - function findNextToken(previousToken, parent) { - return find(parent); - function find(n) { - if (isToken(n) && n.pos === previousToken.end) { - // this is token that starts at the end of previous token - return it - return n; - } - var children = n.getChildren(); - for (var _i = 0; _i < children.length; _i++) { - var child = children[_i]; - var shouldDiveInChildNode = - // previous token is enclosed somewhere in the child - (child.pos <= previousToken.pos && child.end > previousToken.end) || - // previous token ends exactly at the beginning of child - (child.pos === previousToken.end); - if (shouldDiveInChildNode && nodeHasTokens(child)) { - return find(child); - } - } - return undefined; - } - } - ts.findNextToken = findNextToken; - function findPrecedingToken(position, sourceFile, startNode) { - return find(startNode || sourceFile); - function findRightmostToken(n) { - if (isToken(n) || n.kind === 236 /* JsxText */) { - return n; - } - var children = n.getChildren(); - var candidate = findRightmostChildNodeWithTokens(children, /*exclusiveStartPosition*/ children.length); - return candidate && findRightmostToken(candidate); - } - function find(n) { - if (isToken(n) || n.kind === 236 /* JsxText */) { - return n; - } - var children = n.getChildren(); - for (var i = 0, len = children.length; i < len; i++) { - var child = children[i]; - // condition 'position < child.end' checks if child node end after the position - // in the example below this condition will be false for 'aaaa' and 'bbbb' and true for 'ccc' - // aaaa___bbbb___$__ccc - // after we found child node with end after the position we check if start of the node is after the position. - // if yes - then position is in the trivia and we need to look into the previous child to find the token in question. - // 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 === 236 /* JsxText */)) { - var start = child.getStart(sourceFile); - var lookInPreviousChild = (start >= position) || - (child.kind === 236 /* JsxText */ && start === child.end); // whitespace only JsxText - if (lookInPreviousChild) { - // actual start of the node is past the position - previous token should be at the end of previous child - var candidate = findRightmostChildNodeWithTokens(children, /*exclusiveStartPosition*/ i); - return candidate && findRightmostToken(candidate); - } - else { - // candidate should be in this node - return find(child); - } - } - } - ts.Debug.assert(startNode !== undefined || n.kind === 248 /* SourceFile */); - // Here we know that none of child token nodes embrace the position, - // the only known case is when position is at the end of the file. - // Try to find the rightmost token in the file without filtering. - // Namely we are skipping the check: 'position < node.end' - if (children.length) { - var candidate = findRightmostChildNodeWithTokens(children, /*exclusiveStartPosition*/ children.length); - return candidate && findRightmostToken(candidate); - } - } - /// finds last node that is considered as candidate for search (isCandidate(node) === true) starting from 'exclusiveStartPosition' - function findRightmostChildNodeWithTokens(children, exclusiveStartPosition) { - for (var i = exclusiveStartPosition - 1; i >= 0; --i) { - if (nodeHasTokens(children[i])) { - return children[i]; - } - } - } - } - ts.findPrecedingToken = findPrecedingToken; - function isInString(sourceFile, position) { - var token = getTokenAtPosition(sourceFile, position); - return token && token.kind === 9 /* StringLiteral */ && position > token.getStart(); - } - ts.isInString = isInString; - function isInComment(sourceFile, position) { - return isInCommentHelper(sourceFile, position, /*predicate*/ undefined); - } - ts.isInComment = isInComment; - /** - * Returns true if the cursor at position in sourceFile is within a comment that additionally - * satisfies predicate, and false otherwise. - */ - function isInCommentHelper(sourceFile, position, predicate) { - var token = getTokenAtPosition(sourceFile, position); - if (token && position <= token.getStart()) { - var commentRanges = ts.getLeadingCommentRanges(sourceFile.text, token.pos); - // The end marker of a single-line comment does not include the newline character. - // In the following case, we are inside a comment (^ denotes the cursor position): - // - // // asdf ^\n - // - // But for multi-line comments, we don't want to be inside the comment in the following case: - // - // /* asdf */^ - // - // Internally, we represent the end of the comment at the newline and closing '/', respectively. - return predicate ? - ts.forEach(commentRanges, function (c) { return c.pos < position && - (c.kind == 2 /* SingleLineCommentTrivia */ ? position <= c.end : position < c.end) && - predicate(c); }) : - ts.forEach(commentRanges, function (c) { return c.pos < position && - (c.kind == 2 /* SingleLineCommentTrivia */ ? position <= c.end : position < c.end); }); - } - return false; - } - ts.isInCommentHelper = isInCommentHelper; - function hasDocComment(sourceFile, position) { - var token = getTokenAtPosition(sourceFile, position); - // First, we have to see if this position actually landed in a comment. - var commentRanges = ts.getLeadingCommentRanges(sourceFile.text, token.pos); - return ts.forEach(commentRanges, jsDocPrefix); - function jsDocPrefix(c) { - var text = sourceFile.text; - return text.length >= c.pos + 3 && text[c.pos] === '/' && text[c.pos + 1] === '*' && text[c.pos + 2] === '*'; - } - } - ts.hasDocComment = hasDocComment; - /** - * Get the corresponding JSDocTag node if the position is in a jsDoc comment - */ - function getJsDocTagAtPosition(sourceFile, position) { - var node = ts.getTokenAtPosition(sourceFile, position); - if (isToken(node)) { - switch (node.kind) { - case 102 /* VarKeyword */: - case 108 /* LetKeyword */: - case 74 /* ConstKeyword */: - // if the current token is var, let or const, skip the VariableDeclarationList - node = node.parent === undefined ? undefined : node.parent.parent; - break; - default: - node = node.parent; - break; - } - } - if (node) { - var jsDocComment = node.jsDocComment; - if (jsDocComment) { - for (var _i = 0, _a = jsDocComment.tags; _i < _a.length; _i++) { - var tag = _a[_i]; - if (tag.pos <= position && position <= tag.end) { - return tag; - } - } - } - } - return undefined; - } - ts.getJsDocTagAtPosition = getJsDocTagAtPosition; - function nodeHasTokens(n) { - // If we have a token or node that has a non-zero width, it must have tokens. - // Note, that getWidth() does not take trivia into account. - return n.getWidth() !== 0; - } - function getNodeModifiers(node) { - var flags = ts.getCombinedNodeFlags(node); - var result = []; - if (flags & 32 /* Private */) - result.push(ts.ScriptElementKindModifier.privateMemberModifier); - if (flags & 64 /* Protected */) - result.push(ts.ScriptElementKindModifier.protectedMemberModifier); - if (flags & 16 /* Public */) - result.push(ts.ScriptElementKindModifier.publicMemberModifier); - if (flags & 128 /* Static */) - result.push(ts.ScriptElementKindModifier.staticModifier); - if (flags & 256 /* Abstract */) - result.push(ts.ScriptElementKindModifier.abstractModifier); - if (flags & 1 /* Export */) - result.push(ts.ScriptElementKindModifier.exportedModifier); - if (ts.isInAmbientContext(node)) - result.push(ts.ScriptElementKindModifier.ambientModifier); - return result.length > 0 ? result.join(',') : ts.ScriptElementKindModifier.none; - } - ts.getNodeModifiers = getNodeModifiers; - function getTypeArgumentOrTypeParameterList(node) { - if (node.kind === 151 /* TypeReference */ || node.kind === 168 /* CallExpression */) { - return node.typeArguments; - } - if (ts.isFunctionLike(node) || node.kind === 214 /* ClassDeclaration */ || node.kind === 215 /* InterfaceDeclaration */) { - return node.typeParameters; - } - return undefined; - } - ts.getTypeArgumentOrTypeParameterList = getTypeArgumentOrTypeParameterList; - function isToken(n) { - return n.kind >= 0 /* FirstToken */ && n.kind <= 134 /* LastToken */; - } - ts.isToken = isToken; - function isWord(kind) { - return kind === 69 /* Identifier */ || ts.isKeyword(kind); - } - ts.isWord = isWord; - function isPropertyName(kind) { - return kind === 9 /* StringLiteral */ || kind === 8 /* NumericLiteral */ || isWord(kind); - } - function isComment(kind) { - return kind === 2 /* SingleLineCommentTrivia */ || kind === 3 /* MultiLineCommentTrivia */; - } - ts.isComment = isComment; - function isStringOrRegularExpressionOrTemplateLiteral(kind) { - if (kind === 9 /* StringLiteral */ - || kind === 10 /* RegularExpressionLiteral */ - || ts.isTemplateLiteralKind(kind)) { - return true; - } - return false; - } - ts.isStringOrRegularExpressionOrTemplateLiteral = isStringOrRegularExpressionOrTemplateLiteral; - function isPunctuation(kind) { - return 15 /* FirstPunctuation */ <= kind && kind <= 68 /* LastPunctuation */; - } - ts.isPunctuation = isPunctuation; - function isInsideTemplateLiteral(node, position) { - return ts.isTemplateLiteralKind(node.kind) - && (node.getStart() < position && position < node.getEnd()) || (!!node.isUnterminated && position === node.getEnd()); - } - ts.isInsideTemplateLiteral = isInsideTemplateLiteral; - function isAccessibilityModifier(kind) { - switch (kind) { - case 112 /* PublicKeyword */: - case 110 /* PrivateKeyword */: - case 111 /* ProtectedKeyword */: - return true; - } - return false; - } - ts.isAccessibilityModifier = isAccessibilityModifier; - function compareDataObjects(dst, src) { - for (var e in dst) { - if (typeof dst[e] === "object") { - if (!compareDataObjects(dst[e], src[e])) { - return false; - } - } - else if (typeof dst[e] !== "function") { - if (dst[e] !== src[e]) { - return false; - } - } - } - return true; - } - ts.compareDataObjects = compareDataObjects; -})(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 === 138 /* Parameter */; - } - ts.isFirstDeclarationOfSymbolParameter = isFirstDeclarationOfSymbolParameter; - var displayPartWriter = getDisplayPartWriter(); - function getDisplayPartWriter() { - var displayParts; - var lineStart; - var indent; - resetWriter(); - return { - displayParts: function () { return displayParts; }, - writeKeyword: function (text) { return writeKind(text, ts.SymbolDisplayPartKind.keyword); }, - writeOperator: function (text) { return writeKind(text, ts.SymbolDisplayPartKind.operator); }, - writePunctuation: function (text) { return writeKind(text, ts.SymbolDisplayPartKind.punctuation); }, - writeSpace: function (text) { return writeKind(text, ts.SymbolDisplayPartKind.space); }, - writeStringLiteral: function (text) { return writeKind(text, ts.SymbolDisplayPartKind.stringLiteral); }, - writeParameter: function (text) { return writeKind(text, ts.SymbolDisplayPartKind.parameterName); }, - writeSymbol: writeSymbol, - writeLine: writeLine, - increaseIndent: function () { indent++; }, - decreaseIndent: function () { indent--; }, - clear: resetWriter, - trackSymbol: function () { }, - reportInaccessibleThisError: function () { } - }; - function writeIndent() { - if (lineStart) { - var indentString = ts.getIndentString(indent); - if (indentString) { - displayParts.push(displayPart(indentString, ts.SymbolDisplayPartKind.space)); - } - lineStart = false; - } - } - function writeKind(text, kind) { - writeIndent(); - displayParts.push(displayPart(text, kind)); - } - function writeSymbol(text, symbol) { - writeIndent(); - displayParts.push(symbolPart(text, symbol)); - } - function writeLine() { - displayParts.push(lineBreakPart()); - lineStart = true; - } - function resetWriter() { - displayParts = []; - lineStart = true; - indent = 0; - } - } - function symbolPart(text, symbol) { - return displayPart(text, displayPartKind(symbol), symbol); - function displayPartKind(symbol) { - var flags = symbol.flags; - if (flags & 3 /* Variable */) { - return isFirstDeclarationOfSymbolParameter(symbol) ? ts.SymbolDisplayPartKind.parameterName : ts.SymbolDisplayPartKind.localName; - } - else if (flags & 4 /* Property */) { - return ts.SymbolDisplayPartKind.propertyName; - } - else if (flags & 32768 /* GetAccessor */) { - return ts.SymbolDisplayPartKind.propertyName; - } - else if (flags & 65536 /* SetAccessor */) { - return ts.SymbolDisplayPartKind.propertyName; - } - else if (flags & 8 /* EnumMember */) { - return ts.SymbolDisplayPartKind.enumMemberName; - } - else if (flags & 16 /* Function */) { - return ts.SymbolDisplayPartKind.functionName; - } - else if (flags & 32 /* Class */) { - return ts.SymbolDisplayPartKind.className; - } - else if (flags & 64 /* Interface */) { - return ts.SymbolDisplayPartKind.interfaceName; - } - else if (flags & 384 /* Enum */) { - return ts.SymbolDisplayPartKind.enumName; - } - else if (flags & 1536 /* Module */) { - return ts.SymbolDisplayPartKind.moduleName; - } - else if (flags & 8192 /* Method */) { - return ts.SymbolDisplayPartKind.methodName; - } - else if (flags & 262144 /* TypeParameter */) { - return ts.SymbolDisplayPartKind.typeParameterName; - } - else if (flags & 524288 /* TypeAlias */) { - return ts.SymbolDisplayPartKind.aliasName; - } - else if (flags & 8388608 /* Alias */) { - return ts.SymbolDisplayPartKind.aliasName; - } - return ts.SymbolDisplayPartKind.text; - } - } - ts.symbolPart = symbolPart; - function displayPart(text, kind, symbol) { - return { - text: text, - kind: ts.SymbolDisplayPartKind[kind] - }; - } - ts.displayPart = displayPart; - function spacePart() { - return displayPart(" ", ts.SymbolDisplayPartKind.space); - } - ts.spacePart = spacePart; - function keywordPart(kind) { - return displayPart(ts.tokenToString(kind), ts.SymbolDisplayPartKind.keyword); - } - ts.keywordPart = keywordPart; - function punctuationPart(kind) { - return displayPart(ts.tokenToString(kind), ts.SymbolDisplayPartKind.punctuation); - } - ts.punctuationPart = punctuationPart; - function operatorPart(kind) { - return displayPart(ts.tokenToString(kind), ts.SymbolDisplayPartKind.operator); - } - ts.operatorPart = operatorPart; - function textOrKeywordPart(text) { - var kind = ts.stringToToken(text); - return kind === undefined - ? textPart(text) - : keywordPart(kind); - } - ts.textOrKeywordPart = textOrKeywordPart; - function textPart(text) { - return displayPart(text, ts.SymbolDisplayPartKind.text); - } - ts.textPart = textPart; - var carriageReturnLineFeed = "\r\n"; - /** - * The default is CRLF. - */ - function getNewLineOrDefaultFromHost(host) { - return host.getNewLine ? host.getNewLine() : carriageReturnLineFeed; - } - ts.getNewLineOrDefaultFromHost = getNewLineOrDefaultFromHost; - function lineBreakPart() { - return displayPart("\n", ts.SymbolDisplayPartKind.lineBreak); - } - ts.lineBreakPart = lineBreakPart; - function mapToDisplayParts(writeDisplayParts) { - writeDisplayParts(displayPartWriter); - var result = displayPartWriter.displayParts(); - displayPartWriter.clear(); - return result; - } - ts.mapToDisplayParts = mapToDisplayParts; - function typeToDisplayParts(typechecker, type, enclosingDeclaration, flags) { - return mapToDisplayParts(function (writer) { - typechecker.getSymbolDisplayBuilder().buildTypeDisplay(type, writer, enclosingDeclaration, flags); - }); - } - ts.typeToDisplayParts = typeToDisplayParts; - function symbolToDisplayParts(typeChecker, symbol, enclosingDeclaration, meaning, flags) { - return mapToDisplayParts(function (writer) { - typeChecker.getSymbolDisplayBuilder().buildSymbolDisplay(symbol, writer, enclosingDeclaration, meaning, flags); - }); - } - ts.symbolToDisplayParts = symbolToDisplayParts; - function signatureToDisplayParts(typechecker, signature, enclosingDeclaration, flags) { - return mapToDisplayParts(function (writer) { - typechecker.getSymbolDisplayBuilder().buildSignatureDisplay(signature, writer, enclosingDeclaration, flags); - }); - } - ts.signatureToDisplayParts = signatureToDisplayParts; - function getDeclaredName(typeChecker, 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 is under the cursor. - if (isImportOrExportSpecifierName(location)) { - return location.getText(); - } - // Try to get the local symbol if we're dealing with an 'export default' - // since that symbol has the "true" name. - var localExportDefaultSymbol = ts.getLocalSymbolForExportDefault(symbol); - var name = typeChecker.symbolToString(localExportDefaultSymbol || symbol); - return name; - } - ts.getDeclaredName = getDeclaredName; - function isImportOrExportSpecifierName(location) { - return location.parent && - (location.parent.kind === 226 /* ImportSpecifier */ || location.parent.kind === 230 /* ExportSpecifier */) && - location.parent.propertyName === location; - } - ts.isImportOrExportSpecifierName = isImportOrExportSpecifierName; - /** - * Strip off existed single quotes or double quotes from a given string - * - * @return non-quoted string - */ - function stripQuotes(name) { - var length = name.length; - if (length >= 2 && - name.charCodeAt(0) === name.charCodeAt(length - 1) && - (name.charCodeAt(0) === 34 /* doubleQuote */ || name.charCodeAt(0) === 39 /* singleQuote */)) { - return name.substring(1, length - 1); - } - ; - return name; - } - ts.stripQuotes = stripQuotes; -})(ts || (ts = {})); -/// -/// -/* @internal */ -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 */); - /** - * Scanner that is currently used for formatting - */ - 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 = {})); - function getFormattingScanner(sourceFile, startPos, endPos) { - ts.Debug.assert(scanner === undefined); - scanner = sourceFile.languageVariant === 1 /* JSX */ ? jsxScanner : standardScanner; - scanner.setText(sourceFile.text); - scanner.setTextPos(startPos); - var wasNewLine = true; - var leadingTrivia; - var trailingTrivia; - var savedPos; - var lastScanAction; - var lastTokenInfo; - return { - advance: advance, - readTokenInfo: readTokenInfo, - isOnToken: isOnToken, - lastTrailingTriviaWasNewLine: function () { return wasNewLine; }, - close: function () { - ts.Debug.assert(scanner !== undefined); - lastTokenInfo = undefined; - scanner.setText(undefined); - scanner = undefined; - } - }; - function advance() { - ts.Debug.assert(scanner !== undefined); - lastTokenInfo = undefined; - var isStarted = scanner.getStartPos() !== startPos; - if (isStarted) { - if (trailingTrivia) { - ts.Debug.assert(trailingTrivia.length !== 0); - wasNewLine = ts.lastOrUndefined(trailingTrivia).kind === 4 /* NewLineTrivia */; - } - else { - wasNewLine = false; - } - } - leadingTrivia = undefined; - trailingTrivia = undefined; - if (!isStarted) { - scanner.scan(); - } - var t; - var pos = scanner.getStartPos(); - // Read leading trivia and token - while (pos < endPos) { - var t_1 = scanner.getToken(); - if (!ts.isTrivia(t_1)) { - break; - } - // consume leading trivia - scanner.scan(); - var item = { - pos: pos, - end: scanner.getStartPos(), - kind: t_1 - }; - pos = scanner.getStartPos(); - if (!leadingTrivia) { - leadingTrivia = []; - } - leadingTrivia.push(item); - } - savedPos = scanner.getStartPos(); - } - function shouldRescanGreaterThanToken(node) { - if (node) { - switch (node.kind) { - case 29 /* GreaterThanEqualsToken */: - case 64 /* GreaterThanGreaterThanEqualsToken */: - case 65 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 45 /* GreaterThanGreaterThanGreaterThanToken */: - case 44 /* GreaterThanGreaterThanToken */: - return true; - } - } - return false; - } - function shouldRescanJsxIdentifier(node) { - if (node.parent) { - switch (node.parent.kind) { - case 238 /* JsxAttribute */: - case 235 /* JsxOpeningElement */: - case 237 /* JsxClosingElement */: - case 234 /* JsxSelfClosingElement */: - return node.kind === 69 /* Identifier */; - } - } - return false; - } - function shouldRescanSlashToken(container) { - return container.kind === 10 /* RegularExpressionLiteral */; - } - function shouldRescanTemplateToken(container) { - return container.kind === 13 /* TemplateMiddle */ || - container.kind === 14 /* TemplateTail */; - } - function startsWithSlashToken(t) { - return t === 39 /* SlashToken */ || t === 61 /* SlashEqualsToken */; - } - function readTokenInfo(n) { - ts.Debug.assert(scanner !== undefined); - if (!isOnToken()) { - // scanner is not on the token (either advance was not called yet or scanner is already past the end position) - return { - leadingTrivia: leadingTrivia, - trailingTrivia: undefined, - token: undefined - }; - } - // normally scanner returns the smallest available token - // check the kind of context node to determine if scanner should have more greedy behavior and consume more text. - var expectedScanAction = shouldRescanGreaterThanToken(n) - ? 1 /* RescanGreaterThanToken */ - : shouldRescanSlashToken(n) - ? 2 /* RescanSlashToken */ - : shouldRescanTemplateToken(n) - ? 3 /* RescanTemplateToken */ - : shouldRescanJsxIdentifier(n) - ? 4 /* RescanJsxIdentifier */ - : 0 /* Scan */; - if (lastTokenInfo && expectedScanAction === lastScanAction) { - // readTokenInfo was called before with the same expected scan action. - // No need to re-scan text, return existing 'lastTokenInfo' - // it is ok to call fixTokenKind here since it does not affect - // what portion of text is consumed. In opposize rescanning can change it, - // i.e. for '>=' when originally scanner eats just one character - // and rescanning forces it to consume more. - return fixTokenKind(lastTokenInfo, n); - } - if (scanner.getStartPos() !== savedPos) { - ts.Debug.assert(lastTokenInfo !== undefined); - // readTokenInfo was called before but scan action differs - rescan text - scanner.setTextPos(savedPos); - scanner.scan(); - } - var currentToken = scanner.getToken(); - if (expectedScanAction === 1 /* RescanGreaterThanToken */ && currentToken === 27 /* GreaterThanToken */) { - currentToken = scanner.reScanGreaterToken(); - ts.Debug.assert(n.kind === currentToken); - lastScanAction = 1 /* RescanGreaterThanToken */; - } - else if (expectedScanAction === 2 /* RescanSlashToken */ && startsWithSlashToken(currentToken)) { - currentToken = scanner.reScanSlashToken(); - ts.Debug.assert(n.kind === currentToken); - lastScanAction = 2 /* RescanSlashToken */; - } - else if (expectedScanAction === 3 /* RescanTemplateToken */ && currentToken === 16 /* CloseBraceToken */) { - currentToken = scanner.reScanTemplateToken(); - lastScanAction = 3 /* RescanTemplateToken */; - } - else if (expectedScanAction === 4 /* RescanJsxIdentifier */ && currentToken === 69 /* Identifier */) { - currentToken = scanner.scanJsxIdentifier(); - lastScanAction = 4 /* RescanJsxIdentifier */; - } - else { - lastScanAction = 0 /* Scan */; - } - var token = { - pos: scanner.getStartPos(), - end: scanner.getTextPos(), - kind: currentToken - }; - // consume trailing trivia - if (trailingTrivia) { - trailingTrivia = undefined; - } - while (scanner.getStartPos() < endPos) { - currentToken = scanner.scan(); - if (!ts.isTrivia(currentToken)) { - break; - } - var trivia = { - pos: scanner.getStartPos(), - end: scanner.getTextPos(), - kind: currentToken - }; - if (!trailingTrivia) { - trailingTrivia = []; - } - trailingTrivia.push(trivia); - if (currentToken === 4 /* NewLineTrivia */) { - // move past new line - scanner.scan(); - break; - } - } - lastTokenInfo = { - leadingTrivia: leadingTrivia, - trailingTrivia: trailingTrivia, - token: token - }; - return fixTokenKind(lastTokenInfo, n); - } - function isOnToken() { - ts.Debug.assert(scanner !== undefined); - var current = (lastTokenInfo && lastTokenInfo.token.kind) || scanner.getToken(); - var startPos = (lastTokenInfo && lastTokenInfo.token.pos) || scanner.getStartPos(); - return startPos < endPos && current !== 1 /* EndOfFileToken */ && !ts.isTrivia(current); - } - // when containing node in the tree is token - // but its kind differs from the kind that was returned by the scanner, - // then kind needs to be fixed. This might happen in cases - // when parser interprets token differently, i.e keyword treated as identifier - function fixTokenKind(tokenInfo, container) { - if (ts.isToken(container) && tokenInfo.token.kind !== container.kind) { - tokenInfo.token.kind = container.kind; - } - return tokenInfo; - } - } - formatting.getFormattingScanner = getFormattingScanner; - })(formatting = ts.formatting || (ts.formatting = {})); -})(ts || (ts = {})); -/// -/* @internal */ -var ts; -(function (ts) { - var formatting; - (function (formatting) { - var FormattingContext = (function () { - function FormattingContext(sourceFile, formattingRequestKind) { - this.sourceFile = sourceFile; - this.formattingRequestKind = formattingRequestKind; - } - FormattingContext.prototype.updateContext = function (currentRange, currentTokenParent, nextRange, nextTokenParent, commonParent) { - ts.Debug.assert(currentRange !== undefined, "currentTokenSpan is null"); - ts.Debug.assert(currentTokenParent !== undefined, "currentTokenParent is null"); - ts.Debug.assert(nextRange !== undefined, "nextTokenSpan is null"); - ts.Debug.assert(nextTokenParent !== undefined, "nextTokenParent is null"); - ts.Debug.assert(commonParent !== undefined, "commonParent is null"); - this.currentTokenSpan = currentRange; - this.currentTokenParent = currentTokenParent; - this.nextTokenSpan = nextRange; - this.nextTokenParent = nextTokenParent; - this.contextNode = commonParent; - // drop cached results - this.contextNodeAllOnSameLine = undefined; - this.nextNodeAllOnSameLine = undefined; - this.tokensAreOnSameLine = undefined; - this.contextNodeBlockIsOnOneLine = undefined; - this.nextNodeBlockIsOnOneLine = undefined; - }; - FormattingContext.prototype.ContextNodeAllOnSameLine = function () { - if (this.contextNodeAllOnSameLine === undefined) { - this.contextNodeAllOnSameLine = this.NodeIsOnOneLine(this.contextNode); - } - return this.contextNodeAllOnSameLine; - }; - FormattingContext.prototype.NextNodeAllOnSameLine = function () { - if (this.nextNodeAllOnSameLine === undefined) { - this.nextNodeAllOnSameLine = this.NodeIsOnOneLine(this.nextTokenParent); - } - return this.nextNodeAllOnSameLine; - }; - FormattingContext.prototype.TokensAreOnSameLine = function () { - if (this.tokensAreOnSameLine === undefined) { - var startLine = this.sourceFile.getLineAndCharacterOfPosition(this.currentTokenSpan.pos).line; - var endLine = this.sourceFile.getLineAndCharacterOfPosition(this.nextTokenSpan.pos).line; - this.tokensAreOnSameLine = (startLine === endLine); - } - return this.tokensAreOnSameLine; - }; - FormattingContext.prototype.ContextNodeBlockIsOnOneLine = function () { - if (this.contextNodeBlockIsOnOneLine === undefined) { - this.contextNodeBlockIsOnOneLine = this.BlockIsOnOneLine(this.contextNode); - } - return this.contextNodeBlockIsOnOneLine; - }; - FormattingContext.prototype.NextNodeBlockIsOnOneLine = function () { - if (this.nextNodeBlockIsOnOneLine === undefined) { - this.nextNodeBlockIsOnOneLine = this.BlockIsOnOneLine(this.nextTokenParent); - } - return this.nextNodeBlockIsOnOneLine; - }; - FormattingContext.prototype.NodeIsOnOneLine = function (node) { - var startLine = this.sourceFile.getLineAndCharacterOfPosition(node.getStart(this.sourceFile)).line; - var endLine = this.sourceFile.getLineAndCharacterOfPosition(node.getEnd()).line; - 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); - if (openBrace && closeBrace) { - var startLine = this.sourceFile.getLineAndCharacterOfPosition(openBrace.getEnd()).line; - var endLine = this.sourceFile.getLineAndCharacterOfPosition(closeBrace.getStart(this.sourceFile)).line; - return startLine === endLine; - } - return false; - }; - return FormattingContext; - })(); - formatting.FormattingContext = FormattingContext; - })(formatting = ts.formatting || (ts.formatting = {})); -})(ts || (ts = {})); -/// -/* @internal */ -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 = {})); -/// -/* @internal */ -var ts; -(function (ts) { - var formatting; - (function (formatting) { - var Rule = (function () { - function Rule(Descriptor, Operation, Flag) { - if (Flag === void 0) { Flag = 0 /* None */; } - this.Descriptor = Descriptor; - this.Operation = Operation; - this.Flag = Flag; - } - Rule.prototype.toString = function () { - return "[desc=" + this.Descriptor + "," + - "operation=" + this.Operation + "," + - "flag=" + this.Flag + "]"; - }; - return Rule; - })(); - formatting.Rule = Rule; - })(formatting = ts.formatting || (ts.formatting = {})); -})(ts || (ts = {})); -/// -/* @internal */ -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 = {})); -/// -/* @internal */ -var ts; -(function (ts) { - var formatting; - (function (formatting) { - var RuleDescriptor = (function () { - function RuleDescriptor(LeftTokenRange, RightTokenRange) { - this.LeftTokenRange = LeftTokenRange; - this.RightTokenRange = RightTokenRange; - } - RuleDescriptor.prototype.toString = function () { - return "[leftRange=" + this.LeftTokenRange + "," + - "rightRange=" + this.RightTokenRange + "]"; - }; - RuleDescriptor.create1 = function (left, right) { - return RuleDescriptor.create4(formatting.Shared.TokenRange.FromToken(left), formatting.Shared.TokenRange.FromToken(right)); - }; - RuleDescriptor.create2 = function (left, right) { - return RuleDescriptor.create4(left, formatting.Shared.TokenRange.FromToken(right)); - }; - RuleDescriptor.create3 = function (left, right) { - return RuleDescriptor.create4(formatting.Shared.TokenRange.FromToken(left), right); - }; - RuleDescriptor.create4 = function (left, right) { - return new RuleDescriptor(left, right); - }; - return RuleDescriptor; - })(); - formatting.RuleDescriptor = RuleDescriptor; - })(formatting = ts.formatting || (ts.formatting = {})); -})(ts || (ts = {})); -/// -/* @internal */ -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 = {})); -/// -/* @internal */ -var ts; -(function (ts) { - var formatting; - (function (formatting) { - var RuleOperation = (function () { - function RuleOperation() { - this.Context = null; - this.Action = null; - } - RuleOperation.prototype.toString = function () { - return "[context=" + this.Context + "," + - "action=" + this.Action + "]"; - }; - RuleOperation.create1 = function (action) { - return RuleOperation.create2(formatting.RuleOperationContext.Any, action); - }; - RuleOperation.create2 = function (context, action) { - var result = new RuleOperation(); - result.Context = context; - result.Action = action; - return result; - }; - return RuleOperation; - })(); - formatting.RuleOperation = RuleOperation; - })(formatting = ts.formatting || (ts.formatting = {})); -})(ts || (ts = {})); -/// -/* @internal */ -var ts; -(function (ts) { - var formatting; - (function (formatting) { - var RuleOperationContext = (function () { - function RuleOperationContext() { - var funcs = []; - for (var _i = 0; _i < arguments.length; _i++) { - funcs[_i - 0] = arguments[_i]; - } - this.customContextChecks = funcs; - } - RuleOperationContext.prototype.IsAny = function () { - return this === RuleOperationContext.Any; - }; - RuleOperationContext.prototype.InContext = function (context) { - if (this.IsAny()) { - return true; - } - for (var _i = 0, _a = this.customContextChecks; _i < _a.length; _i++) { - var check = _a[_i]; - if (!check(context)) { - return false; - } - } - return true; - }; - RuleOperationContext.Any = new RuleOperationContext(); - return RuleOperationContext; - })(); - formatting.RuleOperationContext = RuleOperationContext; - })(formatting = ts.formatting || (ts.formatting = {})); -})(ts || (ts = {})); -/// -/* @internal */ -var ts; -(function (ts) { - var formatting; - (function (formatting) { - var Rules = (function () { - function Rules() { - /// - /// Common Rules - /// - // Leave comments alone - 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.IsSameLineTokenContext), 8 /* Delete */)); - this.NoSpaceBeforeColon = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 54 /* ColonToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 8 /* Delete */)); - this.NoSpaceBeforeQuestionMark = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 53 /* QuestionToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 8 /* Delete */)); - this.SpaceAfterColon = new formatting.Rule(formatting.RuleDescriptor.create3(54 /* ColonToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 2 /* Space */)); - this.SpaceAfterQuestionMarkInConditionalOperator = new formatting.Rule(formatting.RuleDescriptor.create3(53 /* QuestionToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsConditionalOperatorContext), 2 /* Space */)); - this.NoSpaceAfterQuestionMark = new formatting.Rule(formatting.RuleDescriptor.create3(53 /* QuestionToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); - this.SpaceAfterSemicolon = new formatting.Rule(formatting.RuleDescriptor.create3(23 /* SemicolonToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); - // Space after }. - this.SpaceAfterCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create3(16 /* CloseBraceToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsAfterCodeBlockContext), 2 /* Space */)); - // Special case for (}, else) and (}, while) since else & while tokens are not part of the tree which makes SpaceAfterCloseBrace rule not applied - this.SpaceBetweenCloseBraceAndElse = new formatting.Rule(formatting.RuleDescriptor.create1(16 /* CloseBraceToken */, 80 /* ElseKeyword */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); - this.SpaceBetweenCloseBraceAndWhile = new formatting.Rule(formatting.RuleDescriptor.create1(16 /* CloseBraceToken */, 104 /* WhileKeyword */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); - this.NoSpaceAfterCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create3(16 /* CloseBraceToken */, formatting.Shared.TokenRange.FromTokens([18 /* CloseParenToken */, 20 /* CloseBracketToken */, 24 /* CommaToken */, 23 /* SemicolonToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); - // No space for dot - this.NoSpaceBeforeDot = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 21 /* DotToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); - this.NoSpaceAfterDot = new formatting.Rule(formatting.RuleDescriptor.create3(21 /* DotToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 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.IsSameLineTokenContext), 8 /* Delete */)); - this.NoSpaceAfterCloseBracket = new formatting.Rule(formatting.RuleDescriptor.create3(20 /* CloseBracketToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, 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 */); - // 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 */]); - this.SpaceBeforeOpenBraceInTypeScriptDeclWithBlock = new formatting.Rule(formatting.RuleDescriptor.create2(this.TypeScriptOpenBraceLeftTokenRange, 15 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsTypeScriptDeclWithBlockContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), 2 /* Space */), 1 /* CanDeleteNewLines */); - // Place a space before open brace in a control flow construct - this.ControlOpenBraceLeftTokenRange = formatting.Shared.TokenRange.FromTokens([18 /* CloseParenToken */, 3 /* MultiLineCommentTrivia */, 79 /* DoKeyword */, 100 /* TryKeyword */, 85 /* FinallyKeyword */, 80 /* ElseKeyword */]); - this.SpaceBeforeOpenBraceInControl = new formatting.Rule(formatting.RuleDescriptor.create2(this.ControlOpenBraceLeftTokenRange, 15 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsControlDeclContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), 2 /* Space */), 1 /* CanDeleteNewLines */); - // Insert a space after { and before } in single-line contexts, but remove space from empty object literals {}. - this.SpaceAfterOpenBrace = new formatting.Rule(formatting.RuleDescriptor.create3(15 /* OpenBraceToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSingleLineBlockContext), 2 /* Space */)); - 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.NoSpaceBetweenEmptyBraceBrackets = new formatting.Rule(formatting.RuleDescriptor.create1(15 /* OpenBraceToken */, 16 /* CloseBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, 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 */)); - // 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 */)); - // 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.IsSameLineTokenContext, 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.IsSameLineTokenContext), 8 /* Delete */)); - this.NoSpaceAfterUnaryPredecrementOperator = new formatting.Rule(formatting.RuleDescriptor.create3(42 /* MinusMinusToken */, formatting.Shared.TokenRange.UnaryPredecrementExpressions), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); - this.NoSpaceBeforeUnaryPostincrementOperator = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.UnaryPostincrementExpressions, 41 /* PlusPlusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); - this.NoSpaceBeforeUnaryPostdecrementOperator = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.UnaryPostdecrementExpressions, 42 /* MinusMinusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); - // More unary operator special-casing. - // DevDiv 181814: Be careful when removing leading whitespace - // around unary operators. Examples: - // 1 - -2 --X--> 1--2 - // a + ++b --X--> a+++b - this.SpaceAfterPostincrementWhenFollowedByAdd = new formatting.Rule(formatting.RuleDescriptor.create1(41 /* PlusPlusToken */, 35 /* PlusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); - this.SpaceAfterAddWhenFollowedByUnaryPlus = new formatting.Rule(formatting.RuleDescriptor.create1(35 /* PlusToken */, 35 /* PlusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); - this.SpaceAfterAddWhenFollowedByPreincrement = new formatting.Rule(formatting.RuleDescriptor.create1(35 /* PlusToken */, 41 /* PlusPlusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); - this.SpaceAfterPostdecrementWhenFollowedBySubtract = new formatting.Rule(formatting.RuleDescriptor.create1(42 /* MinusMinusToken */, 36 /* MinusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); - this.SpaceAfterSubtractWhenFollowedByUnaryMinus = new formatting.Rule(formatting.RuleDescriptor.create1(36 /* MinusToken */, 36 /* MinusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); - this.SpaceAfterSubtractWhenFollowedByPredecrement = new formatting.Rule(formatting.RuleDescriptor.create1(36 /* MinusToken */, 42 /* MinusMinusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); - this.NoSpaceBeforeComma = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 24 /* CommaToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); - this.SpaceAfterCertainKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([102 /* VarKeyword */, 98 /* ThrowKeyword */, 92 /* NewKeyword */, 78 /* DeleteKeyword */, 94 /* ReturnKeyword */, 101 /* TypeOfKeyword */, 119 /* AwaitKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); - this.SpaceAfterLetConstInVariableDeclaration = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([108 /* LetKeyword */, 74 /* ConstKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsStartOfVariableDeclarationList), 2 /* Space */)); - this.NoSpaceBeforeOpenParenInFuncCall = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 17 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsFunctionCallOrNewContext, Rules.IsPreviousTokenNotComma), 8 /* Delete */)); - this.SpaceAfterFunctionInFuncDecl = new formatting.Rule(formatting.RuleDescriptor.create3(87 /* FunctionKeyword */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2 /* Space */)); - this.NoSpaceBeforeOpenParenInFuncDecl = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 17 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsFunctionDeclContext), 8 /* Delete */)); - this.SpaceAfterVoidOperator = new formatting.Rule(formatting.RuleDescriptor.create3(103 /* VoidKeyword */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsVoidOpContext), 2 /* Space */)); - this.NoSpaceBetweenReturnAndSemicolon = new formatting.Rule(formatting.RuleDescriptor.create1(94 /* ReturnKeyword */, 23 /* SemicolonToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); - // Add a space between statements. All keywords except (do,else,case) has open/close parens after them. - // So, we have a rule to add a space for [),Any], [do,Any], [else,Any], and [case,Any] - this.SpaceBetweenStatements = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([18 /* CloseParenToken */, 79 /* DoKeyword */, 80 /* ElseKeyword */, 71 /* CaseKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotForContext), 2 /* Space */)); - // This low-pri rule takes care of "try {" and "finally {" in case the rule SpaceBeforeOpenBraceInControl didn't execute on FormatOnEnter. - this.SpaceAfterTryFinally = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([100 /* TryKeyword */, 85 /* FinallyKeyword */]), 15 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); - // get x() {} - // set x(val) {} - this.SpaceAfterGetSetInMember = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([123 /* GetKeyword */, 129 /* SetKeyword */]), 69 /* Identifier */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2 /* Space */)); - // Special case for binary operators (that are keywords). For these we have to add a space and shouldn't follow any user options. - this.SpaceBeforeBinaryKeywordOperator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.BinaryKeywordOperators), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); - this.SpaceAfterBinaryKeywordOperator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.BinaryKeywordOperators, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); - // TypeScript-specific higher priority rules - // Treat constructor as an identifier in a function declaration, and remove spaces between constructor and following left parentheses - this.NoSpaceAfterConstructor = new formatting.Rule(formatting.RuleDescriptor.create1(121 /* ConstructorKeyword */, 17 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); - // Use of module as a function call. e.g.: import m2 = module("m2"); - this.NoSpaceAfterModuleImport = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([125 /* ModuleKeyword */, 127 /* RequireKeyword */]), 17 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); - // Add a space around certain TypeScript keywords - this.SpaceAfterCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([115 /* AbstractKeyword */, 73 /* ClassKeyword */, 122 /* DeclareKeyword */, 77 /* DefaultKeyword */, 81 /* EnumKeyword */, 82 /* ExportKeyword */, 83 /* ExtendsKeyword */, 123 /* GetKeyword */, 106 /* ImplementsKeyword */, 89 /* ImportKeyword */, 107 /* InterfaceKeyword */, 125 /* ModuleKeyword */, 126 /* NamespaceKeyword */, 110 /* PrivateKeyword */, 112 /* PublicKeyword */, 111 /* ProtectedKeyword */, 129 /* SetKeyword */, 113 /* StaticKeyword */, 132 /* TypeKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); - this.SpaceBeforeCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([83 /* ExtendsKeyword */, 106 /* ImplementsKeyword */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); - // Treat string literals in module names as identifiers, and add a space between the literal and the opening Brace braces, e.g.: module "m2" { - this.SpaceAfterModuleName = new formatting.Rule(formatting.RuleDescriptor.create1(9 /* StringLiteral */, 15 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsModuleDeclContext), 2 /* Space */)); - // Lambda expressions - this.SpaceAfterArrow = new formatting.Rule(formatting.RuleDescriptor.create3(34 /* EqualsGreaterThanToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); - // Optional parameters and let args - this.NoSpaceAfterEllipsis = new formatting.Rule(formatting.RuleDescriptor.create1(22 /* DotDotDotToken */, 69 /* Identifier */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); - this.NoSpaceAfterOptionalParameters = new formatting.Rule(formatting.RuleDescriptor.create3(53 /* QuestionToken */, formatting.Shared.TokenRange.FromTokens([18 /* CloseParenToken */, 24 /* CommaToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 8 /* Delete */)); - // generics and type assertions - this.NoSpaceBeforeOpenAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.TypeNames, 25 /* LessThanToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), 8 /* Delete */)); - this.NoSpaceBetweenCloseParenAndAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create1(18 /* CloseParenToken */, 25 /* LessThanToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), 8 /* Delete */)); - this.NoSpaceAfterOpenAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create3(25 /* LessThanToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, 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.IsSameLineTokenContext, 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.IsSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), 8 /* Delete */)); - this.NoSpaceAfterTypeAssertion = new formatting.Rule(formatting.RuleDescriptor.create3(27 /* GreaterThanToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsTypeAssertionContext), 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.IsSameLineTokenContext, 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.IsSameLineTokenContext), 2 /* Space */)); - this.NoSpaceAfterAt = new formatting.Rule(formatting.RuleDescriptor.create3(55 /* AtToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); - this.SpaceAfterDecorator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([115 /* AbstractKeyword */, 69 /* Identifier */, 82 /* ExportKeyword */, 77 /* DefaultKeyword */, 73 /* ClassKeyword */, 113 /* StaticKeyword */, 112 /* PublicKeyword */, 110 /* PrivateKeyword */, 111 /* ProtectedKeyword */, 123 /* GetKeyword */, 129 /* SetKeyword */, 19 /* OpenBracketToken */, 37 /* AsteriskToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsEndOfDecoratorContextOnSameLine), 2 /* Space */)); - this.NoSpaceBetweenFunctionKeywordAndStar = new formatting.Rule(formatting.RuleDescriptor.create1(87 /* FunctionKeyword */, 37 /* AsteriskToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclarationOrFunctionExpressionContext), 8 /* Delete */)); - this.SpaceAfterStarInGeneratorDeclaration = new formatting.Rule(formatting.RuleDescriptor.create3(37 /* AsteriskToken */, formatting.Shared.TokenRange.FromTokens([69 /* Identifier */, 17 /* OpenParenToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclarationOrFunctionExpressionContext), 2 /* Space */)); - this.NoSpaceBetweenYieldKeywordAndStar = new formatting.Rule(formatting.RuleDescriptor.create1(114 /* YieldKeyword */, 37 /* AsteriskToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsYieldOrYieldStarWithOperand), 8 /* Delete */)); - this.SpaceBetweenYieldOrYieldStarAndOperand = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([114 /* YieldKeyword */, 37 /* AsteriskToken */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsYieldOrYieldStarWithOperand), 2 /* Space */)); - // Async-await - this.SpaceBetweenAsyncAndOpenParen = new formatting.Rule(formatting.RuleDescriptor.create1(118 /* AsyncKeyword */, 17 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsArrowFunctionContext, Rules.IsSameLineTokenContext), 2 /* Space */)); - this.SpaceBetweenAsyncAndFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(118 /* AsyncKeyword */, 87 /* FunctionKeyword */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); - // template string - this.SpaceBetweenTagAndTemplateString = new formatting.Rule(formatting.RuleDescriptor.create3(69 /* Identifier */, formatting.Shared.TokenRange.FromTokens([11 /* NoSubstitutionTemplateLiteral */, 12 /* TemplateHead */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); - this.NoSpaceAfterTemplateHeadAndMiddle = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([12 /* TemplateHead */, 13 /* TemplateMiddle */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); - this.NoSpaceBeforeTemplateMiddleAndTail = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([13 /* TemplateMiddle */, 14 /* TemplateTail */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); - // These rules are higher in priority than user-configurable rules. - this.HighPriorityCommonRules = - [ - this.IgnoreBeforeComment, this.IgnoreAfterLineComment, - this.NoSpaceBeforeColon, this.SpaceAfterColon, this.NoSpaceBeforeQuestionMark, this.SpaceAfterQuestionMarkInConditionalOperator, - this.NoSpaceAfterQuestionMark, - this.NoSpaceBeforeDot, this.NoSpaceAfterDot, - this.NoSpaceAfterUnaryPrefixOperator, - this.NoSpaceAfterUnaryPreincrementOperator, this.NoSpaceAfterUnaryPredecrementOperator, - this.NoSpaceBeforeUnaryPostincrementOperator, this.NoSpaceBeforeUnaryPostdecrementOperator, - this.SpaceAfterPostincrementWhenFollowedByAdd, - this.SpaceAfterAddWhenFollowedByUnaryPlus, this.SpaceAfterAddWhenFollowedByPreincrement, - this.SpaceAfterPostdecrementWhenFollowedBySubtract, - this.SpaceAfterSubtractWhenFollowedByUnaryMinus, this.SpaceAfterSubtractWhenFollowedByPredecrement, - this.NoSpaceAfterCloseBrace, - this.SpaceAfterOpenBrace, this.SpaceBeforeCloseBrace, this.NewLineBeforeCloseBraceInBlockContext, - this.SpaceAfterCloseBrace, this.SpaceBetweenCloseBraceAndElse, this.SpaceBetweenCloseBraceAndWhile, this.NoSpaceBetweenEmptyBraceBrackets, - this.NoSpaceBetweenFunctionKeywordAndStar, this.SpaceAfterStarInGeneratorDeclaration, - this.SpaceAfterFunctionInFuncDecl, this.NewLineAfterOpenBraceInBlockContext, this.SpaceAfterGetSetInMember, - this.NoSpaceBetweenYieldKeywordAndStar, this.SpaceBetweenYieldOrYieldStarAndOperand, - this.NoSpaceBetweenReturnAndSemicolon, - this.SpaceAfterCertainKeywords, - this.SpaceAfterLetConstInVariableDeclaration, - this.NoSpaceBeforeOpenParenInFuncCall, - this.SpaceBeforeBinaryKeywordOperator, this.SpaceAfterBinaryKeywordOperator, - this.SpaceAfterVoidOperator, - this.SpaceBetweenAsyncAndOpenParen, this.SpaceBetweenAsyncAndFunctionKeyword, - this.SpaceBetweenTagAndTemplateString, this.NoSpaceAfterTemplateHeadAndMiddle, this.NoSpaceBeforeTemplateMiddleAndTail, - // TypeScript-specific rules - this.NoSpaceAfterConstructor, this.NoSpaceAfterModuleImport, - this.SpaceAfterCertainTypeScriptKeywords, this.SpaceBeforeCertainTypeScriptKeywords, - this.SpaceAfterModuleName, - this.SpaceAfterArrow, - this.NoSpaceAfterEllipsis, - this.NoSpaceAfterOptionalParameters, - this.NoSpaceBetweenEmptyInterfaceBraceBrackets, - this.NoSpaceBeforeOpenAngularBracket, - this.NoSpaceBetweenCloseParenAndAngularBracket, - this.NoSpaceAfterOpenAngularBracket, - this.NoSpaceBeforeCloseAngularBracket, - this.NoSpaceAfterCloseAngularBracket, - this.NoSpaceAfterTypeAssertion, - this.SpaceBeforeAt, - this.NoSpaceAfterAt, - this.SpaceAfterDecorator, - ]; - // These rules are lower in priority than user-configurable rules. - this.LowPriorityCommonRules = - [ - this.NoSpaceBeforeSemicolon, - this.SpaceBeforeOpenBraceInControl, this.SpaceBeforeOpenBraceInFunction, this.SpaceBeforeOpenBraceInTypeScriptDeclWithBlock, - this.NoSpaceBeforeComma, - this.NoSpaceBeforeOpenBracket, - this.NoSpaceAfterCloseBracket, - this.SpaceAfterSemicolon, - this.NoSpaceBeforeOpenParenInFuncDecl, - this.SpaceBetweenStatements, this.SpaceAfterTryFinally - ]; - /// - /// 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.IsSameLineTokenContext), 2 /* Space */)); - this.NoSpaceAfterComma = new formatting.Rule(formatting.RuleDescriptor.create3(24 /* CommaToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 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.IsSameLineTokenContext, 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.IsSameLineTokenContext, 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.IsSameLineTokenContext, 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.IsSameLineTokenContext, 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 */)); - // 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 */); - // 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 */); - // 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 */); - // 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.IsSameLineTokenContext, 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.IsSameLineTokenContext, 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.IsSameLineTokenContext), 2 /* Space */)); - this.SpaceBeforeCloseParen = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 18 /* CloseParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); - this.NoSpaceBetweenParens = new formatting.Rule(formatting.RuleDescriptor.create1(17 /* OpenParenToken */, 18 /* CloseParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); - this.NoSpaceAfterOpenParen = new formatting.Rule(formatting.RuleDescriptor.create3(17 /* OpenParenToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); - this.NoSpaceBeforeCloseParen = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 18 /* CloseParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 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.IsSameLineTokenContext), 2 /* Space */)); - this.SpaceBeforeCloseBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 20 /* CloseBracketToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); - this.NoSpaceBetweenBrackets = new formatting.Rule(formatting.RuleDescriptor.create1(19 /* OpenBracketToken */, 20 /* CloseBracketToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); - this.NoSpaceAfterOpenBracket = new formatting.Rule(formatting.RuleDescriptor.create3(19 /* OpenBracketToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); - this.NoSpaceBeforeCloseBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 20 /* CloseBracketToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); - // Insert space after function keyword for anonymous functions - this.SpaceAfterAnonymousFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(87 /* FunctionKeyword */, 17 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2 /* Space */)); - this.NoSpaceAfterAnonymousFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(87 /* FunctionKeyword */, 17 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 8 /* Delete */)); - } - Rules.prototype.getRuleName = function (rule) { - var o = this; - for (var name_31 in o) { - if (o[name_31] === rule) { - return name_31; - } - } - throw new Error("Unknown rule"); - }; - /// - /// Contexts - /// - Rules.IsForContext = function (context) { - return context.contextNode.kind === 199 /* ForStatement */; - }; - Rules.IsNotForContext = function (context) { - return !Rules.IsForContext(context); - }; - Rules.IsBinaryOpContext = function (context) { - switch (context.contextNode.kind) { - case 181 /* BinaryExpression */: - case 182 /* ConditionalExpression */: - case 189 /* AsExpression */: - case 150 /* TypePredicate */: - case 158 /* UnionType */: - case 159 /* IntersectionType */: - return true; - // equals in binding elements: function foo([[x, y] = [1, 2]]) - case 163 /* BindingElement */: - // equals in type X = ... - case 216 /* TypeAliasDeclaration */: - // equal in import a = module('a'); - case 221 /* ImportEqualsDeclaration */: - // equal in let a = 0; - case 211 /* VariableDeclaration */: - // equal in p = 0; - case 138 /* Parameter */: - case 247 /* EnumMember */: - case 141 /* PropertyDeclaration */: - case 140 /* PropertySignature */: - return context.currentTokenSpan.kind === 56 /* EqualsToken */ || context.nextTokenSpan.kind === 56 /* EqualsToken */; - // "in" keyword in for (let x in []) { } - case 200 /* ForInStatement */: - return context.currentTokenSpan.kind === 90 /* InKeyword */ || context.nextTokenSpan.kind === 90 /* InKeyword */; - // Technically, "of" is not a binary operator, but format it the same way as "in" - case 201 /* ForOfStatement */: - return context.currentTokenSpan.kind === 134 /* OfKeyword */ || context.nextTokenSpan.kind === 134 /* OfKeyword */; - } - return false; - }; - Rules.IsNotBinaryOpContext = function (context) { - return !Rules.IsBinaryOpContext(context); - }; - Rules.IsConditionalOperatorContext = function (context) { - return context.contextNode.kind === 182 /* ConditionalExpression */; - }; - Rules.IsSameLineTokenOrBeforeMultilineBlockContext = function (context) { - //// This check is mainly used inside SpaceBeforeOpenBraceInControl and SpaceBeforeOpenBraceInFunction. - //// - //// Ex: - //// if (1) { .... - //// * ) and { are on the same line so apply the rule. Here we don't care whether it's same or multi block context - //// - //// Ex: - //// if (1) - //// { ... } - //// * ) and { are on differnet lines. We only need to format if the block is multiline context. So in this case we don't format. - //// - //// Ex: - //// if (1) - //// { ... - //// } - //// * ) and { are on differnet lines. We only need to format if the block is multiline context. So in this case we format. - return context.TokensAreOnSameLine() || Rules.IsBeforeMultilineBlockContext(context); - }; - // This check is done before an open brace in a control construct, a function, or a typescript block declaration - Rules.IsBeforeMultilineBlockContext = function (context) { - return Rules.IsBeforeBlockContext(context) && !(context.NextNodeAllOnSameLine() || context.NextNodeBlockIsOnOneLine()); - }; - Rules.IsMultilineBlockContext = function (context) { - return Rules.IsBlockContext(context) && !(context.ContextNodeAllOnSameLine() || context.ContextNodeBlockIsOnOneLine()); - }; - Rules.IsSingleLineBlockContext = function (context) { - return Rules.IsBlockContext(context) && (context.ContextNodeAllOnSameLine() || context.ContextNodeBlockIsOnOneLine()); - }; - Rules.IsBlockContext = function (context) { - return Rules.NodeIsBlockContext(context.contextNode); - }; - Rules.IsBeforeBlockContext = function (context) { - return Rules.NodeIsBlockContext(context.nextTokenParent); - }; - // IMPORTANT!!! This method must return true ONLY for nodes with open and close braces as immediate children - Rules.NodeIsBlockContext = function (node) { - if (Rules.NodeIsTypeScriptDeclWithBlockContext(node)) { - // This means we are in a context that looks like a block to the user, but in the grammar is actually not a node (it's a class, module, enum, object type literal, etc). - return true; - } - switch (node.kind) { - case 192 /* Block */: - case 220 /* CaseBlock */: - case 165 /* ObjectLiteralExpression */: - case 219 /* ModuleBlock */: - return true; - } - return false; - }; - Rules.IsFunctionDeclContext = function (context) { - switch (context.contextNode.kind) { - case 213 /* FunctionDeclaration */: - case 143 /* MethodDeclaration */: - case 142 /* MethodSignature */: - //case SyntaxKind.MemberFunctionDeclaration: - case 145 /* GetAccessor */: - case 146 /* SetAccessor */: - ///case SyntaxKind.MethodSignature: - case 147 /* CallSignature */: - case 173 /* FunctionExpression */: - case 144 /* Constructor */: - case 174 /* ArrowFunction */: - //case SyntaxKind.ConstructorDeclaration: - //case SyntaxKind.SimpleArrowFunctionExpression: - //case SyntaxKind.ParenthesizedArrowFunctionExpression: - case 215 /* InterfaceDeclaration */: - return true; - } - return false; - }; - Rules.IsFunctionDeclarationOrFunctionExpressionContext = function (context) { - return context.contextNode.kind === 213 /* FunctionDeclaration */ || context.contextNode.kind === 173 /* FunctionExpression */; - }; - Rules.IsTypeScriptDeclWithBlockContext = function (context) { - return Rules.NodeIsTypeScriptDeclWithBlockContext(context.contextNode); - }; - Rules.NodeIsTypeScriptDeclWithBlockContext = function (node) { - switch (node.kind) { - case 214 /* ClassDeclaration */: - case 186 /* ClassExpression */: - case 215 /* InterfaceDeclaration */: - case 217 /* EnumDeclaration */: - case 155 /* TypeLiteral */: - case 218 /* ModuleDeclaration */: - return true; - } - return false; - }; - Rules.IsAfterCodeBlockContext = function (context) { - switch (context.currentTokenParent.kind) { - case 214 /* ClassDeclaration */: - case 218 /* ModuleDeclaration */: - case 217 /* EnumDeclaration */: - case 192 /* Block */: - case 244 /* CatchClause */: - case 219 /* ModuleBlock */: - case 206 /* SwitchStatement */: - return true; - } - return false; - }; - Rules.IsControlDeclContext = function (context) { - switch (context.contextNode.kind) { - case 196 /* IfStatement */: - case 206 /* SwitchStatement */: - case 199 /* ForStatement */: - case 200 /* ForInStatement */: - case 201 /* ForOfStatement */: - case 198 /* WhileStatement */: - case 209 /* TryStatement */: - case 197 /* DoStatement */: - case 205 /* WithStatement */: - // TODO - // case SyntaxKind.ElseClause: - case 244 /* CatchClause */: - return true; - default: - return false; - } - }; - Rules.IsObjectContext = function (context) { - return context.contextNode.kind === 165 /* ObjectLiteralExpression */; - }; - Rules.IsFunctionCallContext = function (context) { - return context.contextNode.kind === 168 /* CallExpression */; - }; - Rules.IsNewContext = function (context) { - return context.contextNode.kind === 169 /* NewExpression */; - }; - Rules.IsFunctionCallOrNewContext = function (context) { - return Rules.IsFunctionCallContext(context) || Rules.IsNewContext(context); - }; - Rules.IsPreviousTokenNotComma = function (context) { - return context.currentTokenSpan.kind !== 24 /* CommaToken */; - }; - Rules.IsArrowFunctionContext = function (context) { - return context.contextNode.kind === 174 /* ArrowFunction */; - }; - Rules.IsSameLineTokenContext = function (context) { - return context.TokensAreOnSameLine(); - }; - Rules.IsNotBeforeBlockInFunctionDeclarationContext = function (context) { - return !Rules.IsFunctionDeclContext(context) && !Rules.IsBeforeBlockContext(context); - }; - Rules.IsEndOfDecoratorContextOnSameLine = function (context) { - return context.TokensAreOnSameLine() && - context.contextNode.decorators && - Rules.NodeIsInDecoratorContext(context.currentTokenParent) && - !Rules.NodeIsInDecoratorContext(context.nextTokenParent); - }; - Rules.NodeIsInDecoratorContext = function (node) { - while (ts.isExpression(node)) { - node = node.parent; - } - return node.kind === 139 /* Decorator */; - }; - Rules.IsStartOfVariableDeclarationList = function (context) { - return context.currentTokenParent.kind === 212 /* VariableDeclarationList */ && - context.currentTokenParent.getStart(context.sourceFile) === context.currentTokenSpan.pos; - }; - Rules.IsNotFormatOnEnter = function (context) { - return context.formattingRequestKind !== 2 /* FormatOnEnter */; - }; - Rules.IsModuleDeclContext = function (context) { - return context.contextNode.kind === 218 /* ModuleDeclaration */; - }; - Rules.IsObjectTypeContext = function (context) { - return context.contextNode.kind === 155 /* TypeLiteral */; // && context.contextNode.parent.kind !== SyntaxKind.InterfaceDeclaration; - }; - Rules.IsTypeArgumentOrParameterOrAssertion = function (token, parent) { - if (token.kind !== 25 /* LessThanToken */ && token.kind !== 27 /* GreaterThanToken */) { - return false; - } - switch (parent.kind) { - case 151 /* TypeReference */: - case 171 /* TypeAssertionExpression */: - case 214 /* ClassDeclaration */: - case 186 /* ClassExpression */: - case 215 /* InterfaceDeclaration */: - case 213 /* FunctionDeclaration */: - case 173 /* FunctionExpression */: - case 174 /* ArrowFunction */: - case 143 /* MethodDeclaration */: - case 142 /* MethodSignature */: - case 147 /* CallSignature */: - case 148 /* ConstructSignature */: - case 168 /* CallExpression */: - case 169 /* NewExpression */: - case 188 /* ExpressionWithTypeArguments */: - return true; - default: - return false; - } - }; - Rules.IsTypeArgumentOrParameterOrAssertionContext = function (context) { - return Rules.IsTypeArgumentOrParameterOrAssertion(context.currentTokenSpan, context.currentTokenParent) || - Rules.IsTypeArgumentOrParameterOrAssertion(context.nextTokenSpan, context.nextTokenParent); - }; - Rules.IsTypeAssertionContext = function (context) { - return context.contextNode.kind === 171 /* TypeAssertionExpression */; - }; - Rules.IsVoidOpContext = function (context) { - return context.currentTokenSpan.kind === 103 /* VoidKeyword */ && context.currentTokenParent.kind === 177 /* VoidExpression */; - }; - Rules.IsYieldOrYieldStarWithOperand = function (context) { - return context.contextNode.kind === 184 /* YieldExpression */ && context.contextNode.expression !== undefined; - }; - return Rules; - })(); - formatting.Rules = Rules; - })(formatting = ts.formatting || (ts.formatting = {})); -})(ts || (ts = {})); -/// -/* @internal */ -var ts; -(function (ts) { - var formatting; - (function (formatting) { - var RulesMap = (function () { - function RulesMap() { - this.map = []; - this.mapRowLength = 0; - } - RulesMap.create = function (rules) { - var result = new RulesMap(); - result.Initialize(rules); - return result; - }; - RulesMap.prototype.Initialize = function (rules) { - this.mapRowLength = 134 /* LastToken */ + 1; - this.map = new Array(this.mapRowLength * this.mapRowLength); //new Array(this.mapRowLength * this.mapRowLength); - // This array is used only during construction of the rulesbucket in the map - var rulesBucketConstructionStateList = new Array(this.map.length); //new Array(this.map.length); - this.FillRules(rules, rulesBucketConstructionStateList); - return this.map; - }; - RulesMap.prototype.FillRules = function (rules, rulesBucketConstructionStateList) { - var _this = this; - rules.forEach(function (rule) { - _this.FillRule(rule, rulesBucketConstructionStateList); - }); - }; - RulesMap.prototype.GetRuleBucketIndex = function (row, column) { - 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) { - var _this = this; - var specificRule = rule.Descriptor.LeftTokenRange !== formatting.Shared.TokenRange.Any && - rule.Descriptor.RightTokenRange !== formatting.Shared.TokenRange.Any; - rule.Descriptor.LeftTokenRange.GetTokens().forEach(function (left) { - rule.Descriptor.RightTokenRange.GetTokens().forEach(function (right) { - var rulesBucketIndex = _this.GetRuleBucketIndex(left, right); - var rulesBucket = _this.map[rulesBucketIndex]; - if (rulesBucket === undefined) { - rulesBucket = _this.map[rulesBucketIndex] = new RulesBucket(); - } - rulesBucket.AddRule(rule, specificRule, rulesBucketConstructionStateList, rulesBucketIndex); - }); - }); - }; - RulesMap.prototype.GetRule = function (context) { - var bucketIndex = this.GetRuleBucketIndex(context.currentTokenSpan.kind, context.nextTokenSpan.kind); - var bucket = this.map[bucketIndex]; - if (bucket != null) { - for (var _i = 0, _a = bucket.Rules(); _i < _a.length; _i++) { - var rule = _a[_i]; - if (rule.Operation.Context.InContext(context)) { - return rule; - } - } - } - return null; - }; - return RulesMap; - })(); - formatting.RulesMap = RulesMap; - var MaskBitSize = 5; - var Mask = 0x1f; - (function (RulesPosition) { - RulesPosition[RulesPosition["IgnoreRulesSpecific"] = 0] = "IgnoreRulesSpecific"; - RulesPosition[RulesPosition["IgnoreRulesAny"] = MaskBitSize * 1] = "IgnoreRulesAny"; - RulesPosition[RulesPosition["ContextRulesSpecific"] = MaskBitSize * 2] = "ContextRulesSpecific"; - RulesPosition[RulesPosition["ContextRulesAny"] = MaskBitSize * 3] = "ContextRulesAny"; - RulesPosition[RulesPosition["NoContextRulesSpecific"] = MaskBitSize * 4] = "NoContextRulesSpecific"; - RulesPosition[RulesPosition["NoContextRulesAny"] = MaskBitSize * 5] = "NoContextRulesAny"; - })(formatting.RulesPosition || (formatting.RulesPosition = {})); - var RulesPosition = formatting.RulesPosition; - var RulesBucketConstructionState = (function () { - function RulesBucketConstructionState() { - //// The Rules list contains all the inserted rules into a rulebucket in the following order: - //// 1- Ignore rules with specific token combination - //// 2- Ignore rules with any token combination - //// 3- Context rules with specific token combination - //// 4- Context rules with any token combination - //// 5- Non-context rules with specific token combination - //// 6- Non-context rules with any token combination - //// - //// The member rulesInsertionIndexBitmap is used to describe the number of rules - //// in each sub-bucket (above) hence can be used to know the index of where to insert - //// the next rule. It's a bitmap which contains 6 different sections each is given 5 bits. - //// - //// Example: - //// In order to insert a rule to the end of sub-bucket (3), we get the index by adding - //// the values in the bitmap segments 3rd, 2nd, and 1st. - this.rulesInsertionIndexBitmap = 0; - } - RulesBucketConstructionState.prototype.GetInsertionIndex = function (maskPosition) { - var index = 0; - var pos = 0; - var indexBitmap = this.rulesInsertionIndexBitmap; - while (pos <= maskPosition) { - index += (indexBitmap & Mask); - indexBitmap >>= MaskBitSize; - pos += MaskBitSize; - } - return index; - }; - RulesBucketConstructionState.prototype.IncreaseInsertionIndex = function (maskPosition) { - var value = (this.rulesInsertionIndexBitmap >> maskPosition) & Mask; - value++; - ts.Debug.assert((value & Mask) === value, "Adding more rules into the sub-bucket than allowed. Maximum allowed is 32 rules."); - var temp = this.rulesInsertionIndexBitmap & ~(Mask << maskPosition); - temp |= value << maskPosition; - this.rulesInsertionIndexBitmap = temp; - }; - return RulesBucketConstructionState; - })(); - formatting.RulesBucketConstructionState = RulesBucketConstructionState; - var RulesBucket = (function () { - function RulesBucket() { - this.rules = []; - } - RulesBucket.prototype.Rules = function () { - return this.rules; - }; - RulesBucket.prototype.AddRule = function (rule, specificTokens, constructionState, rulesBucketIndex) { - var position; - if (rule.Operation.Action === 1 /* Ignore */) { - position = specificTokens ? - RulesPosition.IgnoreRulesSpecific : - RulesPosition.IgnoreRulesAny; - } - else if (!rule.Operation.Context.IsAny()) { - position = specificTokens ? - RulesPosition.ContextRulesSpecific : - RulesPosition.ContextRulesAny; - } - else { - position = specificTokens ? - RulesPosition.NoContextRulesSpecific : - RulesPosition.NoContextRulesAny; - } - var state = constructionState[rulesBucketIndex]; - if (state === undefined) { - state = constructionState[rulesBucketIndex] = new RulesBucketConstructionState(); - } - var index = state.GetInsertionIndex(position); - this.rules.splice(index, 0, rule); - state.IncreaseInsertionIndex(position); - }; - return RulesBucket; - })(); - formatting.RulesBucket = RulesBucket; - })(formatting = ts.formatting || (ts.formatting = {})); -})(ts || (ts = {})); -/// -/* @internal */ -var ts; -(function (ts) { - var formatting; - (function (formatting) { - var Shared; - (function (Shared) { - var TokenRangeAccess = (function () { - function TokenRangeAccess(from, to, except) { - this.tokens = []; - for (var token = from; token <= to; token++) { - if (except.indexOf(token) < 0) { - this.tokens.push(token); - } - } - } - TokenRangeAccess.prototype.GetTokens = function () { - return this.tokens; - }; - TokenRangeAccess.prototype.Contains = function (token) { - return this.tokens.indexOf(token) >= 0; - }; - return TokenRangeAccess; - })(); - Shared.TokenRangeAccess = TokenRangeAccess; - var TokenValuesAccess = (function () { - function TokenValuesAccess(tks) { - this.tokens = tks && tks.length ? tks : []; - } - TokenValuesAccess.prototype.GetTokens = function () { - return this.tokens; - }; - TokenValuesAccess.prototype.Contains = function (token) { - return this.tokens.indexOf(token) >= 0; - }; - return TokenValuesAccess; - })(); - Shared.TokenValuesAccess = TokenValuesAccess; - var TokenSingleValueAccess = (function () { - function TokenSingleValueAccess(token) { - this.token = token; - } - TokenSingleValueAccess.prototype.GetTokens = function () { - return [this.token]; - }; - TokenSingleValueAccess.prototype.Contains = function (tokenValue) { - return tokenValue === this.token; - }; - return TokenSingleValueAccess; - })(); - Shared.TokenSingleValueAccess = TokenSingleValueAccess; - var TokenAllAccess = (function () { - function TokenAllAccess() { - } - TokenAllAccess.prototype.GetTokens = function () { - var result = []; - for (var token = 0 /* FirstToken */; token <= 134 /* LastToken */; token++) { - result.push(token); - } - return result; - }; - TokenAllAccess.prototype.Contains = function (tokenValue) { - return true; - }; - TokenAllAccess.prototype.toString = function () { - return "[allTokens]"; - }; - return TokenAllAccess; - })(); - Shared.TokenAllAccess = TokenAllAccess; - var TokenRange = (function () { - function TokenRange(tokenAccess) { - this.tokenAccess = tokenAccess; - } - TokenRange.FromToken = function (token) { - return new TokenRange(new TokenSingleValueAccess(token)); - }; - TokenRange.FromTokens = function (tokens) { - return new TokenRange(new TokenValuesAccess(tokens)); - }; - TokenRange.FromRange = function (f, to, except) { - if (except === void 0) { except = []; } - return new TokenRange(new TokenRangeAccess(f, to, except)); - }; - TokenRange.AllTokens = function () { - return new TokenRange(new TokenAllAccess()); - }; - TokenRange.prototype.GetTokens = function () { - return this.tokenAccess.GetTokens(); - }; - TokenRange.prototype.Contains = function (token) { - return this.tokenAccess.Contains(token); - }; - TokenRange.prototype.toString = function () { - return this.tokenAccess.toString(); - }; - TokenRange.Any = TokenRange.AllTokens(); - TokenRange.AnyIncludingMultilineComments = TokenRange.FromTokens(TokenRange.Any.GetTokens().concat([3 /* MultiLineCommentTrivia */])); - TokenRange.Keywords = TokenRange.FromRange(70 /* FirstKeyword */, 134 /* LastKeyword */); - TokenRange.BinaryOperators = TokenRange.FromRange(25 /* FirstBinaryOperator */, 68 /* LastBinaryOperator */); - TokenRange.BinaryKeywordOperators = TokenRange.FromTokens([90 /* InKeyword */, 91 /* InstanceOfKeyword */, 134 /* OfKeyword */, 116 /* AsKeyword */, 124 /* IsKeyword */]); - TokenRange.UnaryPrefixOperators = TokenRange.FromTokens([41 /* PlusPlusToken */, 42 /* MinusMinusToken */, 50 /* TildeToken */, 49 /* ExclamationToken */]); - TokenRange.UnaryPrefixExpressions = TokenRange.FromTokens([8 /* NumericLiteral */, 69 /* Identifier */, 17 /* OpenParenToken */, 19 /* OpenBracketToken */, 15 /* OpenBraceToken */, 97 /* ThisKeyword */, 92 /* NewKeyword */]); - TokenRange.UnaryPreincrementExpressions = TokenRange.FromTokens([69 /* Identifier */, 17 /* OpenParenToken */, 97 /* ThisKeyword */, 92 /* NewKeyword */]); - TokenRange.UnaryPostincrementExpressions = TokenRange.FromTokens([69 /* Identifier */, 18 /* CloseParenToken */, 20 /* CloseBracketToken */, 92 /* NewKeyword */]); - TokenRange.UnaryPredecrementExpressions = TokenRange.FromTokens([69 /* Identifier */, 17 /* OpenParenToken */, 97 /* ThisKeyword */, 92 /* NewKeyword */]); - TokenRange.UnaryPostdecrementExpressions = TokenRange.FromTokens([69 /* Identifier */, 18 /* CloseParenToken */, 20 /* CloseBracketToken */, 92 /* NewKeyword */]); - TokenRange.Comments = TokenRange.FromTokens([2 /* SingleLineCommentTrivia */, 3 /* MultiLineCommentTrivia */]); - TokenRange.TypeNames = TokenRange.FromTokens([69 /* Identifier */, 128 /* NumberKeyword */, 130 /* StringKeyword */, 120 /* BooleanKeyword */, 131 /* SymbolKeyword */, 103 /* VoidKeyword */, 117 /* AnyKeyword */]); - return TokenRange; - })(); - Shared.TokenRange = TokenRange; - })(Shared = formatting.Shared || (formatting.Shared = {})); - })(formatting = ts.formatting || (ts.formatting = {})); -})(ts || (ts = {})); -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/* @internal */ -var ts; -(function (ts) { - var formatting; - (function (formatting) { - var RulesProvider = (function () { - function RulesProvider() { - this.globalRules = new formatting.Rules(); - } - RulesProvider.prototype.getRuleName = function (rule) { - return this.globalRules.getRuleName(rule); - }; - RulesProvider.prototype.getRuleByName = function (name) { - return this.globalRules[name]; - }; - RulesProvider.prototype.getRulesMap = function () { - return this.rulesMap; - }; - RulesProvider.prototype.ensureUpToDate = function (options) { - // TODO: Should this be '==='? - if (this.options == null || !ts.compareDataObjects(this.options, options)) { - var activeRules = this.createActiveRules(options); - var rulesMap = formatting.RulesMap.create(activeRules); - this.activeRules = activeRules; - this.rulesMap = rulesMap; - this.options = ts.clone(options); - } - }; - RulesProvider.prototype.createActiveRules = function (options) { - var rules = this.globalRules.HighPriorityCommonRules.slice(0); - if (options.InsertSpaceAfterCommaDelimiter) { - rules.push(this.globalRules.SpaceAfterComma); - } - else { - rules.push(this.globalRules.NoSpaceAfterComma); - } - if (options.InsertSpaceAfterFunctionKeywordForAnonymousFunctions) { - rules.push(this.globalRules.SpaceAfterAnonymousFunctionKeyword); - } - else { - rules.push(this.globalRules.NoSpaceAfterAnonymousFunctionKeyword); - } - if (options.InsertSpaceAfterKeywordsInControlFlowStatements) { - rules.push(this.globalRules.SpaceAfterKeywordInControl); - } - else { - rules.push(this.globalRules.NoSpaceAfterKeywordInControl); - } - if (options.InsertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis) { - rules.push(this.globalRules.SpaceAfterOpenParen); - rules.push(this.globalRules.SpaceBeforeCloseParen); - rules.push(this.globalRules.NoSpaceBetweenParens); - } - else { - rules.push(this.globalRules.NoSpaceAfterOpenParen); - rules.push(this.globalRules.NoSpaceBeforeCloseParen); - rules.push(this.globalRules.NoSpaceBetweenParens); - } - if (options.InsertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets) { - rules.push(this.globalRules.SpaceAfterOpenBracket); - rules.push(this.globalRules.SpaceBeforeCloseBracket); - rules.push(this.globalRules.NoSpaceBetweenBrackets); - } - else { - rules.push(this.globalRules.NoSpaceAfterOpenBracket); - rules.push(this.globalRules.NoSpaceBeforeCloseBracket); - rules.push(this.globalRules.NoSpaceBetweenBrackets); - } - if (options.InsertSpaceAfterSemicolonInForStatements) { - rules.push(this.globalRules.SpaceAfterSemicolonInFor); - } - else { - rules.push(this.globalRules.NoSpaceAfterSemicolonInFor); - } - if (options.InsertSpaceBeforeAndAfterBinaryOperators) { - rules.push(this.globalRules.SpaceBeforeBinaryOperator); - rules.push(this.globalRules.SpaceAfterBinaryOperator); - } - else { - rules.push(this.globalRules.NoSpaceBeforeBinaryOperator); - rules.push(this.globalRules.NoSpaceAfterBinaryOperator); - } - if (options.PlaceOpenBraceOnNewLineForControlBlocks) { - rules.push(this.globalRules.NewLineBeforeOpenBraceInControl); - } - if (options.PlaceOpenBraceOnNewLineForFunctions) { - rules.push(this.globalRules.NewLineBeforeOpenBraceInFunction); - rules.push(this.globalRules.NewLineBeforeOpenBraceInTypeScriptDeclWithBlock); - } - rules = rules.concat(this.globalRules.LowPriorityCommonRules); - return rules; - }; - return RulesProvider; - })(); - formatting.RulesProvider = RulesProvider; - })(formatting = ts.formatting || (ts.formatting = {})); -})(ts || (ts = {})); -/// -/// -/// -/// -/* @internal */ -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) { - return []; - } - // get the span for the previous\current line - var span = { - // get start position for the previous line - pos: ts.getStartPositionOfLine(line - 1, sourceFile), - // get end position for the current line (end value is exclusive so add 1 to the result) - end: ts.getEndLinePosition(line, sourceFile) + 1 - }; - return formatSpan(span, sourceFile, options, rulesProvider, 2 /* FormatOnEnter */); - } - formatting.formatOnEnter = formatOnEnter; - function formatOnSemicolon(position, sourceFile, rulesProvider, options) { - return formatOutermostParent(position, 23 /* 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 */); - } - formatting.formatOnClosingCurly = formatOnClosingCurly; - function formatDocument(sourceFile, rulesProvider, options) { - var span = { - pos: 0, - end: sourceFile.text.length - }; - return formatSpan(span, sourceFile, options, rulesProvider, 0 /* FormatDocument */); - } - formatting.formatDocument = formatDocument; - function formatSelection(start, end, sourceFile, rulesProvider, options) { - // format from the beginning of the line - var span = { - pos: ts.getLineStartPositionForPosition(start, sourceFile), - end: end - }; - return formatSpan(span, sourceFile, options, rulesProvider, 1 /* FormatSelection */); - } - formatting.formatSelection = formatSelection; - function formatOutermostParent(position, expectedLastToken, sourceFile, options, rulesProvider, requestKind) { - var parent = findOutermostParent(position, expectedLastToken, sourceFile); - if (!parent) { - return []; - } - var span = { - pos: ts.getLineStartPositionForPosition(parent.getStart(sourceFile), sourceFile), - end: parent.end - }; - return formatSpan(span, sourceFile, options, rulesProvider, requestKind); - } - function findOutermostParent(position, expectedTokenKind, sourceFile) { - var precedingToken = ts.findPrecedingToken(position, sourceFile); - // when it is claimed that trigger character was typed at given position - // we verify that there is a token with a matching kind whose end is equal to position (because the character was just typed). - // If this condition is not hold - then trigger character was typed in some other context, - // i.e.in comment and thus should not trigger autoformatting - if (!precedingToken || - precedingToken.kind !== expectedTokenKind || - position !== precedingToken.getEnd()) { - return undefined; - } - // walk up and search for the parent node that ends at the same position with precedingToken. - // for cases like this - // - // let x = 1; - // while (true) { - // } - // after typing close curly in while statement we want to reformat just the while statement. - // However if we just walk upwards searching for the parent that has the same end value - - // we'll end up with the whole source file. isListElement allows to stop on the list element level - var current = precedingToken; - while (current && - current.parent && - current.parent.end === precedingToken.end && - !isListElement(current.parent, current)) { - current = current.parent; - } - return current; - } - // Returns true if node is a element in some list in parent - // 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 214 /* ClassDeclaration */: - case 215 /* InterfaceDeclaration */: - return ts.rangeContainsRange(parent.members, node); - case 218 /* ModuleDeclaration */: - var body = parent.body; - return body && body.kind === 192 /* Block */ && ts.rangeContainsRange(body.statements, node); - case 248 /* SourceFile */: - case 192 /* Block */: - case 219 /* ModuleBlock */: - return ts.rangeContainsRange(parent.statements, node); - case 244 /* CatchClause */: - return ts.rangeContainsRange(parent.block.statements, node); - } - return false; - } - /** find node that fully contains given text range */ - function findEnclosingNode(range, sourceFile) { - return find(sourceFile); - function find(n) { - var candidate = ts.forEachChild(n, function (c) { return ts.startEndContainsRange(c.getStart(sourceFile), c.end, range) && c; }); - if (candidate) { - var result = find(candidate); - if (result) { - return result; - } - } - return n; - } - } - /** formatting is not applied to ranges that contain parse errors. - * This function will return a predicate that for a given text range will tell - * if there are any parse errors that overlap with the range. - */ - function prepareRangeContainsErrorFunction(errors, originalRange) { - if (!errors.length) { - return rangeHasNoErrors; - } - // pick only errors that fall in range - var sorted = errors - .filter(function (d) { return ts.rangeOverlapsWithStartEnd(originalRange, d.start, d.start + d.length); }) - .sort(function (e1, e2) { return e1.start - e2.start; }); - if (!sorted.length) { - return rangeHasNoErrors; - } - var index = 0; - return function (r) { - // in current implementation sequence of arguments [r1, r2...] is monotonically increasing. - // 'index' tracks the index of the most recent error that was checked. - while (true) { - if (index >= sorted.length) { - // all errors in the range were already checked -> no error in specified range - return false; - } - var error = sorted[index]; - if (r.end <= error.start) { - // specified range ends before the error refered by 'index' - no error in range - return false; - } - if (ts.startEndOverlapsWithStartEnd(r.pos, r.end, error.start, error.start + error.length)) { - // specified range overlaps with error range - return true; - } - index++; - } - }; - function rangeHasNoErrors(r) { - return false; - } - } - /** - * Start of the original range might fall inside the comment - scanner will not yield appropriate results - * This function will look for token that is located before the start of target range - * and return its end as start position for the scanner. - */ - function getScanStartPosition(enclosingNode, originalRange, sourceFile) { - var start = enclosingNode.getStart(sourceFile); - if (start === originalRange.pos && enclosingNode.end === originalRange.end) { - return start; - } - var precedingToken = ts.findPrecedingToken(originalRange.pos, sourceFile); - if (!precedingToken) { - // no preceding token found - start from the beginning of enclosing node - return enclosingNode.pos; - } - // preceding token ends after the start of original range (i.e when originaRange.pos falls in the middle of literal) - // start from the beginning of enclosingNode to handle the entire 'originalRange' - if (precedingToken.end >= originalRange.pos) { - return enclosingNode.pos; - } - return precedingToken.end; - } - /* - * For cases like - * if (a || - * b ||$ - * c) {...} - * If we hit Enter at $ we want line ' b ||' to be indented. - * Formatting will be applied to the last two lines. - * Node that fully encloses these lines is binary expression 'a ||...'. - * Initial indentation for this node will be 0. - * Binary expressions don't introduce new indentation scopes, however it is possible - * that some parent node on the same line does - like if statement in this case. - * Note that we are considering parents only from the same line with initial node - - * if parent is on the different line - its delta was already contributed - * to the initial indentation. - */ - function getOwnOrInheritedDelta(n, options, sourceFile) { - var previousLine = -1 /* Unknown */; - var childKind = 0 /* Unknown */; - while (n) { - var line = sourceFile.getLineAndCharacterOfPosition(n.getStart(sourceFile)).line; - if (previousLine !== -1 /* Unknown */ && line !== previousLine) { - break; - } - if (formatting.SmartIndenter.shouldIndentChildNode(n.kind, childKind)) { - return options.IndentSize; - } - previousLine = line; - childKind = n.kind; - n = n.parent; - } - return 0; - } - function formatSpan(originalRange, sourceFile, options, rulesProvider, requestKind) { - var rangeContainsError = prepareRangeContainsErrorFunction(sourceFile.parseDiagnostics, originalRange); - // formatting context is used by rules provider - var formattingContext = new formatting.FormattingContext(sourceFile, requestKind); - // find the smallest node that fully wraps the range and compute the initial indentation for the node - var enclosingNode = findEnclosingNode(originalRange, sourceFile); - var formattingScanner = formatting.getFormattingScanner(sourceFile, getScanStartPosition(enclosingNode, originalRange, sourceFile), originalRange.end); - var initialIndentation = formatting.SmartIndenter.getIndentationForNode(enclosingNode, originalRange, sourceFile, options); - var previousRangeHasError; - var previousRange; - var previousParent; - var previousRangeStartLine; - var lastIndentedLine; - var indentationOnLastIndentedLine; - var edits = []; - formattingScanner.advance(); - if (formattingScanner.isOnToken()) { - var startLine = sourceFile.getLineAndCharacterOfPosition(enclosingNode.getStart(sourceFile)).line; - var undecoratedStartLine = startLine; - if (enclosingNode.decorators) { - undecoratedStartLine = sourceFile.getLineAndCharacterOfPosition(ts.getNonDecoratorTokenPosOfNode(enclosingNode, sourceFile)).line; - } - var delta = getOwnOrInheritedDelta(enclosingNode, options, sourceFile); - processNode(enclosingNode, enclosingNode, startLine, undecoratedStartLine, initialIndentation, delta); - } - formattingScanner.close(); - return edits; - // local functions - /** Tries to compute the indentation for a list element. - * If list element is not in range then - * function will pick its actual indentation - * so it can be pushed downstream as inherited indentation. - * If list element is in the range - its indentation will be equal - * to inherited indentation from its predecessors. - */ - function tryComputeIndentationForListItem(startPos, endPos, parentStartLine, range, inheritedIndentation) { - if (ts.rangeOverlapsWithStartEnd(range, startPos, endPos)) { - if (inheritedIndentation !== -1 /* Unknown */) { - return inheritedIndentation; - } - } - else { - var startLine = sourceFile.getLineAndCharacterOfPosition(startPos).line; - var startLinePosition = ts.getLineStartPositionForPosition(startPos, sourceFile); - var column = formatting.SmartIndenter.findFirstNonWhitespaceColumn(startLinePosition, startPos, sourceFile, options); - if (startLine !== parentStartLine || startPos === column) { - return column; - } - } - return -1 /* Unknown */; - } - function computeIndentation(node, startLine, inheritedIndentation, parent, parentDynamicIndentation, effectiveParentStartLine) { - var indentation = inheritedIndentation; - if (indentation === -1 /* Unknown */) { - if (isSomeBlock(node.kind)) { - // blocks should be indented in - // - other blocks - // - source file - // - switch\default clauses - if (isSomeBlock(parent.kind) || - parent.kind === 248 /* SourceFile */ || - parent.kind === 241 /* CaseClause */ || - parent.kind === 242 /* DefaultClause */) { - indentation = parentDynamicIndentation.getIndentation() + parentDynamicIndentation.getDelta(); - } - else { - indentation = parentDynamicIndentation.getIndentation(); - } - } - else { - if (formatting.SmartIndenter.childStartsOnTheSameLineWithElseInIfStatement(parent, node, startLine, sourceFile)) { - indentation = parentDynamicIndentation.getIndentation(); - } - else { - indentation = parentDynamicIndentation.getIndentation() + parentDynamicIndentation.getDelta(); - } - } - } - var delta = formatting.SmartIndenter.shouldIndentChildNode(node.kind, 0 /* Unknown */) ? options.IndentSize : 0; - if (effectiveParentStartLine === startLine) { - // if node is located on the same line with the parent - // - inherit indentation from the parent - // - push children if either parent of node itself has non-zero delta - indentation = startLine === lastIndentedLine - ? indentationOnLastIndentedLine - : parentDynamicIndentation.getIndentation(); - delta = Math.min(options.IndentSize, parentDynamicIndentation.getDelta() + delta); - } - return { - indentation: indentation, - delta: delta - }; - } - function getFirstNonDecoratorTokenOfNode(node) { - if (node.modifiers && node.modifiers.length) { - return node.modifiers[0].kind; - } - switch (node.kind) { - case 214 /* ClassDeclaration */: return 73 /* ClassKeyword */; - case 215 /* InterfaceDeclaration */: return 107 /* InterfaceKeyword */; - case 213 /* FunctionDeclaration */: return 87 /* FunctionKeyword */; - case 217 /* EnumDeclaration */: return 217 /* EnumDeclaration */; - case 145 /* GetAccessor */: return 123 /* GetKeyword */; - case 146 /* SetAccessor */: return 129 /* SetKeyword */; - case 143 /* MethodDeclaration */: - if (node.asteriskToken) { - return 37 /* AsteriskToken */; - } - // fall-through - case 141 /* PropertyDeclaration */: - case 138 /* Parameter */: - return node.name.kind; - } - } - function getDynamicIndentation(node, nodeStartLine, indentation, delta) { - return { - getIndentationForComment: function (kind, tokenIndentation) { - switch (kind) { - // preceding comment to the token that closes the indentation scope inherits the indentation from the scope - // .. { - // // comment - // } - case 16 /* CloseBraceToken */: - case 20 /* CloseBracketToken */: - case 18 /* CloseParenToken */: - return indentation + delta; - } - return tokenIndentation !== -1 /* Unknown */ ? tokenIndentation : indentation; - }, - getIndentationForToken: function (line, kind) { - if (nodeStartLine !== line && node.decorators) { - if (kind === getFirstNonDecoratorTokenOfNode(node)) { - // if this token is the first token following the list of decorators, we do not need to indent - return indentation; - } - } - 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 */: - return indentation; - default: - // if token line equals to the line of containing node (this is a first token in the node) - use node indentation - return nodeStartLine !== line ? indentation + delta : indentation; - } - }, - getIndentation: function () { return indentation; }, - getDelta: function () { return delta; }, - recomputeIndentation: function (lineAdded) { - if (node.parent && formatting.SmartIndenter.shouldIndentChildNode(node.parent.kind, node.kind)) { - if (lineAdded) { - indentation += options.IndentSize; - } - else { - indentation -= options.IndentSize; - } - if (formatting.SmartIndenter.shouldIndentChildNode(node.kind, 0 /* Unknown */)) { - delta = options.IndentSize; - } - else { - delta = 0; - } - } - } - }; - } - function processNode(node, contextNode, nodeStartLine, undecoratedNodeStartLine, indentation, delta) { - if (!ts.rangeOverlapsWithStartEnd(originalRange, node.getStart(sourceFile), node.getEnd())) { - return; - } - var nodeDynamicIndentation = getDynamicIndentation(node, nodeStartLine, indentation, delta); - // a useful observations when tracking context node - // / - // [a] - // / | \ - // [b] [c] [d] - // node 'a' is a context node for nodes 'b', 'c', 'd' - // except for the leftmost leaf token in [b] - in this case context node ('e') is located somewhere above 'a' - // this rule can be applied recursively to child nodes of 'a'. - // - // context node is set to parent node value after processing every child node - // context node is set to parent of the token after processing every token - var childContextNode = contextNode; - // if there are any tokens that logically belong to node and interleave child nodes - // such tokens will be consumed in processChildNode for for the child that follows them - ts.forEachChild(node, function (child) { - processChildNode(child, /*inheritedIndentation*/ -1 /* Unknown */, node, nodeDynamicIndentation, nodeStartLine, undecoratedNodeStartLine, /*isListElement*/ false); - }, function (nodes) { - processChildNodes(nodes, node, nodeStartLine, nodeDynamicIndentation); - }); - // proceed any tokens in the node that are located after child nodes - while (formattingScanner.isOnToken()) { - var tokenInfo = formattingScanner.readTokenInfo(node); - if (tokenInfo.token.end > node.end) { - break; - } - consumeTokenAndAdvanceScanner(tokenInfo, node, nodeDynamicIndentation); - } - function processChildNode(child, inheritedIndentation, parent, parentDynamicIndentation, parentStartLine, undecoratedParentStartLine, isListItem) { - var childStartPos = child.getStart(sourceFile); - var childStartLine = sourceFile.getLineAndCharacterOfPosition(childStartPos).line; - var undecoratedChildStartLine = childStartLine; - if (child.decorators) { - undecoratedChildStartLine = sourceFile.getLineAndCharacterOfPosition(ts.getNonDecoratorTokenPosOfNode(child, sourceFile)).line; - } - // if child is a list item - try to get its indentation - var childIndentationAmount = -1 /* Unknown */; - if (isListItem) { - childIndentationAmount = tryComputeIndentationForListItem(childStartPos, child.end, parentStartLine, originalRange, inheritedIndentation); - if (childIndentationAmount !== -1 /* Unknown */) { - inheritedIndentation = childIndentationAmount; - } - } - // child node is outside the target range - do not dive inside - if (!ts.rangeOverlapsWithStartEnd(originalRange, child.pos, child.end)) { - return inheritedIndentation; - } - if (child.getFullWidth() === 0) { - return inheritedIndentation; - } - while (formattingScanner.isOnToken()) { - // proceed any parent tokens that are located prior to child.getStart() - var tokenInfo = formattingScanner.readTokenInfo(node); - if (tokenInfo.token.end > childStartPos) { - // stop when formatting scanner advances past the beginning of the child - break; - } - consumeTokenAndAdvanceScanner(tokenInfo, node, parentDynamicIndentation); - } - if (!formattingScanner.isOnToken()) { - return inheritedIndentation; - } - if (ts.isToken(child)) { - // 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); - consumeTokenAndAdvanceScanner(tokenInfo, node, parentDynamicIndentation); - return inheritedIndentation; - } - var effectiveParentStartLine = child.kind === 139 /* Decorator */ ? childStartLine : undecoratedParentStartLine; - var childIndentation = computeIndentation(child, childStartLine, childIndentationAmount, node, parentDynamicIndentation, effectiveParentStartLine); - processNode(child, childContextNode, childStartLine, undecoratedChildStartLine, childIndentation.indentation, childIndentation.delta); - childContextNode = node; - return inheritedIndentation; - } - function processChildNodes(nodes, parent, parentStartLine, parentDynamicIndentation) { - var listStartToken = getOpenTokenForList(parent, nodes); - var listEndToken = getCloseTokenForOpenToken(listStartToken); - var listDynamicIndentation = parentDynamicIndentation; - var startLine = parentStartLine; - if (listStartToken !== 0 /* Unknown */) { - // introduce a new indentation scope for lists (including list start and end tokens) - while (formattingScanner.isOnToken()) { - var tokenInfo = formattingScanner.readTokenInfo(parent); - if (tokenInfo.token.end > nodes.pos) { - // stop when formatting scanner moves past the beginning of node list - break; - } - else if (tokenInfo.token.kind === listStartToken) { - // consume list start token - startLine = sourceFile.getLineAndCharacterOfPosition(tokenInfo.token.pos).line; - var indentation_1 = computeIndentation(tokenInfo.token, startLine, -1 /* Unknown */, parent, parentDynamicIndentation, parentStartLine); - listDynamicIndentation = getDynamicIndentation(parent, parentStartLine, indentation_1.indentation, indentation_1.delta); - consumeTokenAndAdvanceScanner(tokenInfo, parent, listDynamicIndentation); - } - else { - // consume any tokens that precede the list as child elements of 'node' using its indentation scope - consumeTokenAndAdvanceScanner(tokenInfo, parent, parentDynamicIndentation); - } - } - } - var inheritedIndentation = -1 /* Unknown */; - for (var _i = 0; _i < nodes.length; _i++) { - var child = nodes[_i]; - inheritedIndentation = processChildNode(child, inheritedIndentation, node, listDynamicIndentation, startLine, startLine, /*isListElement*/ true); - } - if (listEndToken !== 0 /* Unknown */) { - if (formattingScanner.isOnToken()) { - var tokenInfo = formattingScanner.readTokenInfo(parent); - // consume the list end token only if it is still belong to the parent - // there might be the case when current token matches end token but does not considered as one - // function (x: function) <-- - // without this check close paren will be interpreted as list end token for function expression which is wrong - if (tokenInfo.token.kind === listEndToken && ts.rangeContainsRange(parent, tokenInfo.token)) { - // consume list end token - consumeTokenAndAdvanceScanner(tokenInfo, parent, listDynamicIndentation); - } - } - } - } - function consumeTokenAndAdvanceScanner(currentTokenInfo, parent, dynamicIndentation) { - ts.Debug.assert(ts.rangeContainsRange(parent, currentTokenInfo.token)); - var lastTriviaWasNewLine = formattingScanner.lastTrailingTriviaWasNewLine(); - var indentToken = false; - if (currentTokenInfo.leadingTrivia) { - processTrivia(currentTokenInfo.leadingTrivia, parent, childContextNode, dynamicIndentation); - } - var lineAdded; - var isTokenInRange = ts.rangeContainsRange(originalRange, currentTokenInfo.token); - var tokenStart = sourceFile.getLineAndCharacterOfPosition(currentTokenInfo.token.pos); - if (isTokenInRange) { - var rangeHasError = rangeContainsError(currentTokenInfo.token); - // save previousRange since processRange will overwrite this value with current one - var savePreviousRange = previousRange; - lineAdded = processRange(currentTokenInfo.token, tokenStart, parent, childContextNode, dynamicIndentation); - if (rangeHasError) { - // do not indent comments\token if token range overlaps with some error - indentToken = false; - } - else { - if (lineAdded !== undefined) { - indentToken = lineAdded; - } - else { - // indent token only if end line of previous range does not match start line of the token - var prevEndLine = savePreviousRange && sourceFile.getLineAndCharacterOfPosition(savePreviousRange.end).line; - indentToken = lastTriviaWasNewLine && tokenStart.line !== prevEndLine; - } - } - } - if (currentTokenInfo.trailingTrivia) { - processTrivia(currentTokenInfo.trailingTrivia, parent, childContextNode, dynamicIndentation); - } - if (indentToken) { - var tokenIndentation = (isTokenInRange && !rangeContainsError(currentTokenInfo.token)) ? - dynamicIndentation.getIndentationForToken(tokenStart.line, currentTokenInfo.token.kind) : - -1 /* Unknown */; - if (currentTokenInfo.leadingTrivia) { - var commentIndentation = dynamicIndentation.getIndentationForComment(currentTokenInfo.token.kind, tokenIndentation); - var indentNextTokenOrTrivia = true; - for (var _i = 0, _a = currentTokenInfo.leadingTrivia; _i < _a.length; _i++) { - var triviaItem = _a[_i]; - if (!ts.rangeContainsRange(originalRange, triviaItem)) { - continue; - } - switch (triviaItem.kind) { - case 3 /* MultiLineCommentTrivia */: - indentMultilineComment(triviaItem, commentIndentation, /*firstLineIsIndented*/ !indentNextTokenOrTrivia); - indentNextTokenOrTrivia = false; - break; - case 2 /* SingleLineCommentTrivia */: - if (indentNextTokenOrTrivia) { - insertIndentation(triviaItem.pos, commentIndentation, /*lineAdded*/ false); - indentNextTokenOrTrivia = false; - } - break; - case 4 /* NewLineTrivia */: - indentNextTokenOrTrivia = true; - break; - } - } - } - // indent token only if is it is in target range and does not overlap with any error ranges - if (tokenIndentation !== -1 /* Unknown */) { - insertIndentation(currentTokenInfo.token.pos, tokenIndentation, lineAdded); - lastIndentedLine = tokenStart.line; - indentationOnLastIndentedLine = tokenIndentation; - } - } - formattingScanner.advance(); - childContextNode = parent; - } - } - function processTrivia(trivia, parent, contextNode, dynamicIndentation) { - for (var _i = 0; _i < trivia.length; _i++) { - var triviaItem = trivia[_i]; - if (ts.isComment(triviaItem.kind) && ts.rangeContainsRange(originalRange, triviaItem)) { - var triviaItemStart = sourceFile.getLineAndCharacterOfPosition(triviaItem.pos); - processRange(triviaItem, triviaItemStart, parent, contextNode, dynamicIndentation); - } - } - } - function processRange(range, rangeStart, parent, contextNode, dynamicIndentation) { - var rangeHasError = rangeContainsError(range); - var lineAdded; - if (!rangeHasError && !previousRangeHasError) { - if (!previousRange) { - // trim whitespaces starting from the beginning of the span up to the current line - var originalStart = sourceFile.getLineAndCharacterOfPosition(originalRange.pos); - trimTrailingWhitespacesForLines(originalStart.line, rangeStart.line); - } - else { - lineAdded = - processPair(range, rangeStart.line, parent, previousRange, previousRangeStartLine, previousParent, contextNode, dynamicIndentation); - } - } - previousRange = range; - previousParent = parent; - previousRangeStartLine = rangeStart.line; - previousRangeHasError = rangeHasError; - return lineAdded; - } - function processPair(currentItem, currentStartLine, currentParent, previousItem, previousStartLine, previousParent, contextNode, dynamicIndentation) { - formattingContext.updateContext(previousItem, previousParent, currentItem, currentParent, contextNode); - var rule = rulesProvider.getRulesMap().GetRule(formattingContext); - var trimTrailingWhitespaces; - var lineAdded; - if (rule) { - applyRuleEdits(rule, previousItem, previousStartLine, currentItem, currentStartLine); - if (rule.Operation.Action & (2 /* Space */ | 8 /* Delete */) && currentStartLine !== previousStartLine) { - lineAdded = false; - // Handle the case where the next line is moved to be the end of this line. - // In this case we don't indent the next line in the next pass. - if (currentParent.getStart(sourceFile) === currentItem.pos) { - dynamicIndentation.recomputeIndentation(/*lineAdded*/ false); - } - } - else if (rule.Operation.Action & 4 /* NewLine */ && currentStartLine === previousStartLine) { - lineAdded = true; - // Handle the case where token2 is moved to the new line. - // In this case we indent token2 in the next pass but we set - // sameLineIndent flag to notify the indenter that the indentation is within the line. - if (currentParent.getStart(sourceFile) === currentItem.pos) { - dynamicIndentation.recomputeIndentation(/*lineAdded*/ true); - } - } - // We need to trim trailing whitespace between the tokens if they were on different lines, and no rule was applied to put them on the same line - trimTrailingWhitespaces = - (rule.Operation.Action & (4 /* NewLine */ | 2 /* Space */)) && - rule.Flag !== 1 /* CanDeleteNewLines */; - } - else { - trimTrailingWhitespaces = true; - } - if (currentStartLine !== previousStartLine && trimTrailingWhitespaces) { - // We need to trim trailing whitespace between the tokens if they were on different lines, and no rule was applied to put them on the same line - trimTrailingWhitespacesForLines(previousStartLine, currentStartLine, previousItem); - } - return lineAdded; - } - function insertIndentation(pos, indentation, lineAdded) { - var indentationString = getIndentationString(indentation, options); - if (lineAdded) { - // new line is added before the token by the formatting rules - // insert indentation string at the very beginning of the token - recordReplace(pos, 0, indentationString); - } - else { - var tokenStart = sourceFile.getLineAndCharacterOfPosition(pos); - if (indentation !== tokenStart.character) { - var startLinePosition = ts.getStartPositionOfLine(tokenStart.line, sourceFile); - recordReplace(startLinePosition, tokenStart.character, indentationString); - } - } - } - function indentMultilineComment(commentRange, indentation, firstLineIsIndented) { - // split comment in lines - var startLine = sourceFile.getLineAndCharacterOfPosition(commentRange.pos).line; - var endLine = sourceFile.getLineAndCharacterOfPosition(commentRange.end).line; - var parts; - if (startLine === endLine) { - if (!firstLineIsIndented) { - // treat as single line comment - insertIndentation(commentRange.pos, indentation, /*lineAdded*/ false); - } - return; - } - else { - parts = []; - var startPos = commentRange.pos; - for (var line = startLine; line < endLine; ++line) { - var endOfLine = ts.getEndLinePosition(line, sourceFile); - parts.push({ pos: startPos, end: endOfLine }); - startPos = ts.getStartPositionOfLine(line + 1, sourceFile); - } - parts.push({ pos: startPos, end: commentRange.end }); - } - var startLinePos = ts.getStartPositionOfLine(startLine, sourceFile); - var nonWhitespaceColumnInFirstPart = formatting.SmartIndenter.findFirstNonWhitespaceCharacterAndColumn(startLinePos, parts[0].pos, sourceFile, options); - if (indentation === nonWhitespaceColumnInFirstPart.column) { - return; - } - var startIndex = 0; - if (firstLineIsIndented) { - startIndex = 1; - startLine++; - } - // shift all parts on the delta size - var delta = indentation - nonWhitespaceColumnInFirstPart.column; - for (var i = startIndex, len = parts.length; i < len; ++i, ++startLine) { - var startLinePos_1 = ts.getStartPositionOfLine(startLine, sourceFile); - var nonWhitespaceCharacterAndColumn = i === 0 - ? nonWhitespaceColumnInFirstPart - : formatting.SmartIndenter.findFirstNonWhitespaceCharacterAndColumn(parts[i].pos, parts[i].end, sourceFile, options); - var newIndentation = nonWhitespaceCharacterAndColumn.column + delta; - if (newIndentation > 0) { - var indentationString = getIndentationString(newIndentation, options); - recordReplace(startLinePos_1, nonWhitespaceCharacterAndColumn.character, indentationString); - } - else { - recordDelete(startLinePos_1, nonWhitespaceCharacterAndColumn.character); - } - } - } - function trimTrailingWhitespacesForLines(line1, line2, range) { - for (var line = line1; line < line2; ++line) { - var lineStartPosition = ts.getStartPositionOfLine(line, sourceFile); - var lineEndPosition = ts.getEndLinePosition(line, sourceFile); - // do not trim whitespaces in comments or template expression - if (range && (ts.isComment(range.kind) || ts.isStringOrRegularExpressionOrTemplateLiteral(range.kind)) && range.pos <= lineEndPosition && range.end > lineEndPosition) { - continue; - } - var pos = lineEndPosition; - while (pos >= lineStartPosition && ts.isWhiteSpace(sourceFile.text.charCodeAt(pos))) { - pos--; - } - if (pos !== lineEndPosition) { - ts.Debug.assert(pos === lineStartPosition || !ts.isWhiteSpace(sourceFile.text.charCodeAt(pos))); - recordDelete(pos + 1, lineEndPosition - pos); - } - } - } - function newTextChange(start, len, newText) { - return { span: ts.createTextSpan(start, len), newText: newText }; - } - function recordDelete(start, len) { - if (len) { - edits.push(newTextChange(start, len, "")); - } - } - function recordReplace(start, len, newText) { - if (len || newText) { - edits.push(newTextChange(start, len, newText)); - } - } - function applyRuleEdits(rule, previousRange, previousStartLine, currentRange, currentStartLine) { - var between; - switch (rule.Operation.Action) { - case 1 /* Ignore */: - // no action required - return; - case 8 /* Delete */: - if (previousRange.end !== currentRange.pos) { - // delete characters starting from t1.end up to t2.pos exclusive - recordDelete(previousRange.end, currentRange.pos - previousRange.end); - } - break; - case 4 /* NewLine */: - // exit early if we on different lines and rule cannot change number of newlines - // if line1 and line2 are on subsequent lines then no edits are required - ok to exit - // if line1 and line2 are separated with more than one newline - ok to exit since we cannot delete extra new lines - if (rule.Flag !== 1 /* CanDeleteNewLines */ && previousStartLine !== currentStartLine) { - return; - } - // 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); - } - break; - case 2 /* Space */: - // exit early if we on different lines and rule cannot change number of newlines - if (rule.Flag !== 1 /* CanDeleteNewLines */ && previousStartLine !== currentStartLine) { - return; - } - var posDelta = currentRange.pos - previousRange.end; - if (posDelta !== 1 || sourceFile.text.charCodeAt(previousRange.end) !== 32 /* space */) { - recordReplace(previousRange.end, currentRange.pos - previousRange.end, " "); - } - break; - } - } - } - function isSomeBlock(kind) { - switch (kind) { - case 192 /* Block */: - case 219 /* ModuleBlock */: - return true; - } - return false; - } - function getOpenTokenForList(node, list) { - switch (node.kind) { - case 144 /* Constructor */: - case 213 /* FunctionDeclaration */: - case 173 /* FunctionExpression */: - case 143 /* MethodDeclaration */: - case 142 /* MethodSignature */: - case 174 /* ArrowFunction */: - if (node.typeParameters === list) { - return 25 /* LessThanToken */; - } - else if (node.parameters === list) { - return 17 /* OpenParenToken */; - } - break; - case 168 /* CallExpression */: - case 169 /* NewExpression */: - if (node.typeArguments === list) { - return 25 /* LessThanToken */; - } - else if (node.arguments === list) { - return 17 /* OpenParenToken */; - } - break; - case 151 /* TypeReference */: - if (node.typeArguments === list) { - return 25 /* LessThanToken */; - } - } - return 0 /* Unknown */; - } - function getCloseTokenForOpenToken(kind) { - switch (kind) { - case 17 /* OpenParenToken */: - return 18 /* CloseParenToken */; - case 25 /* LessThanToken */: - return 27 /* GreaterThanToken */; - } - return 0 /* Unknown */; - } - var internedSizes; - var internedTabsIndentation; - var internedSpacesIndentation; - function getIndentationString(indentation, options) { - // reset interned strings if FormatCodeOptions were changed - var resetInternedStrings = !internedSizes || (internedSizes.tabSize !== options.TabSize || internedSizes.indentSize !== options.IndentSize); - if (resetInternedStrings) { - internedSizes = { tabSize: options.TabSize, indentSize: options.IndentSize }; - internedTabsIndentation = internedSpacesIndentation = undefined; - } - if (!options.ConvertTabsToSpaces) { - var tabs = Math.floor(indentation / options.TabSize); - var spaces = indentation - tabs * options.TabSize; - var tabString; - if (!internedTabsIndentation) { - internedTabsIndentation = []; - } - if (internedTabsIndentation[tabs] === undefined) { - internedTabsIndentation[tabs] = tabString = repeat('\t', tabs); - } - else { - tabString = internedTabsIndentation[tabs]; - } - return spaces ? tabString + repeat(" ", spaces) : tabString; - } - else { - var spacesString; - var quotient = Math.floor(indentation / options.IndentSize); - var remainder = indentation % options.IndentSize; - if (!internedSpacesIndentation) { - internedSpacesIndentation = []; - } - if (internedSpacesIndentation[quotient] === undefined) { - spacesString = repeat(" ", options.IndentSize * quotient); - internedSpacesIndentation[quotient] = spacesString; - } - else { - spacesString = internedSpacesIndentation[quotient]; - } - return remainder ? spacesString + repeat(" ", remainder) : spacesString; - } - function repeat(value, count) { - var s = ""; - for (var i = 0; i < count; ++i) { - s += value; - } - return s; - } - } - formatting.getIndentationString = getIndentationString; - })(formatting = ts.formatting || (ts.formatting = {})); -})(ts || (ts = {})); -/// -/* @internal */ -var ts; -(function (ts) { - var formatting; - (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 0; // past EOF - } - // no indentation when the indent style is set to none, - // so we can return fast - if (options.IndentStyle === ts.IndentStyle.None) { - return 0; - } - var precedingToken = ts.findPrecedingToken(position, sourceFile); - if (!precedingToken) { - return 0; - } - // no indentation in string \regex\template literals - var precedingTokenIsLiteral = ts.isStringOrRegularExpressionOrTemplateLiteral(precedingToken.kind); - if (precedingTokenIsLiteral && precedingToken.getStart(sourceFile) <= position && precedingToken.end > position) { - return 0; - } - var lineAtPosition = sourceFile.getLineAndCharacterOfPosition(position).line; - // indentation is first non-whitespace character in a previous line - // for block indentation, we should look for a line which contains something that's not - // whitespace. - if (options.IndentStyle === ts.IndentStyle.Block) { - // move backwards until we find a line with a non-whitespace character, - // then find the first non-whitespace character for that line. - var current_1 = position; - while (current_1 > 0) { - var char = sourceFile.text.charCodeAt(current_1); - if (!ts.isWhiteSpace(char) && !ts.isLineBreak(char)) { - break; - } - current_1--; - } - var lineStart = ts.getLineStartPositionForPosition(current_1, sourceFile); - return SmartIndenter.findFirstNonWhitespaceColumn(lineStart, current_1, sourceFile, options); - } - if (precedingToken.kind === 24 /* CommaToken */ && precedingToken.parent.kind !== 181 /* BinaryExpression */) { - // previous token is comma that separates items in list - find the previous item and try to derive indentation from it - var actualIndentation = getActualIndentationForListItemBeforeComma(precedingToken, sourceFile, options); - if (actualIndentation !== -1 /* Unknown */) { - return actualIndentation; - } - } - // try to find node that can contribute to indentation and includes 'position' starting from 'precedingToken' - // if such node is found - compute initial indentation for 'position' inside this node - var previous; - var current = precedingToken; - var currentStart; - var indentationDelta; - while (current) { - if (ts.positionBelongsToNode(current, position, sourceFile) && shouldIndentChildNode(current.kind, previous ? previous.kind : 0 /* Unknown */)) { - currentStart = getStartLineAndCharacterForNode(current, sourceFile); - if (nextTokenIsCurlyBraceOnSameLineAsCursor(precedingToken, current, lineAtPosition, sourceFile)) { - indentationDelta = 0; - } - else { - indentationDelta = lineAtPosition !== currentStart.line ? options.IndentSize : 0; - } - break; - } - // check if current node is a list item - if yes, take indentation from it - var actualIndentation = getActualIndentationForListItem(current, sourceFile, options); - if (actualIndentation !== -1 /* Unknown */) { - return actualIndentation; - } - actualIndentation = getLineIndentationWhenExpressionIsInMultiLine(current, sourceFile, options); - if (actualIndentation !== -1 /* Unknown */) { - return actualIndentation + options.IndentSize; - } - previous = current; - current = current.parent; - } - if (!current) { - // no parent was found - return 0 to be indented on the level of SourceFile - return 0; - } - return getIndentationForNodeWorker(current, currentStart, /*ignoreActualIndentationRange*/ undefined, indentationDelta, sourceFile, options); - } - SmartIndenter.getIndentation = getIndentation; - 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 getIndentationForNodeWorker(current, currentStart, ignoreActualIndentationRange, indentationDelta, sourceFile, options) { - var parent = current.parent; - var parentStart; - // walk upwards and collect indentations for pairs of parent-child nodes - // indentation is not added if parent and child nodes start on the same line or if parent is IfStatement and child starts on the same line with 'else clause' - while (parent) { - var useActualIndentation = true; - if (ignoreActualIndentationRange) { - var start = current.getStart(sourceFile); - useActualIndentation = start < ignoreActualIndentationRange.pos || start > ignoreActualIndentationRange.end; - } - if (useActualIndentation) { - // check if current node is a list item - if yes, take indentation from it - var actualIndentation = getActualIndentationForListItem(current, sourceFile, options); - if (actualIndentation !== -1 /* Unknown */) { - return actualIndentation + indentationDelta; - } - } - parentStart = getParentStart(parent, current, sourceFile); - var parentAndChildShareLine = parentStart.line === currentStart.line || - childStartsOnTheSameLineWithElseInIfStatement(parent, current, currentStart.line, sourceFile); - if (useActualIndentation) { - // try to fetch actual indentation for current node from source text - var actualIndentation = getActualIndentationForNode(current, parent, currentStart, parentAndChildShareLine, sourceFile, options); - if (actualIndentation !== -1 /* Unknown */) { - return actualIndentation + indentationDelta; - } - actualIndentation = getLineIndentationWhenExpressionIsInMultiLine(current, sourceFile, options); - if (actualIndentation !== -1 /* Unknown */) { - return actualIndentation + indentationDelta; - } - } - // 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.kind, current.kind) && !parentAndChildShareLine) { - indentationDelta += options.IndentSize; - } - current = parent; - currentStart = parentStart; - parent = current.parent; - } - return indentationDelta; - } - function getParentStart(parent, child, sourceFile) { - var containingList = getContainingList(child, sourceFile); - if (containingList) { - return sourceFile.getLineAndCharacterOfPosition(containingList.pos); - } - return sourceFile.getLineAndCharacterOfPosition(parent.getStart(sourceFile)); - } - /* - * Function returns Value.Unknown if indentation cannot be determined - */ - function getActualIndentationForListItemBeforeComma(commaToken, sourceFile, options) { - // previous token is comma that separates items in list - find the previous item and try to derive indentation from it - var commaItemInfo = ts.findListItemInfo(commaToken); - if (commaItemInfo && commaItemInfo.listItemIndex > 0) { - return deriveActualIndentationFromList(commaItemInfo.list.getChildren(), commaItemInfo.listItemIndex - 1, sourceFile, options); - } - else { - // handle broken code gracefully - return -1 /* Unknown */; - } - } - /* - * Function returns Value.Unknown if actual indentation for node should not be used (i.e because node is nested expression) - */ - function getActualIndentationForNode(current, parent, currentLineAndChar, parentAndChildShareLine, sourceFile, options) { - // actual indentation is used for statements\declarations if one of cases below is true: - // - parent is SourceFile - by default immediate children of SourceFile are not indented except when user indents them manually - // - parent and child are not on the same line - var useActualIndentation = (ts.isDeclaration(current) || ts.isStatement(current)) && - (parent.kind === 248 /* SourceFile */ || !parentAndChildShareLine); - if (!useActualIndentation) { - return -1 /* Unknown */; - } - return findColumnForFirstNonWhitespaceCharacterInLine(currentLineAndChar, sourceFile, options); - } - function nextTokenIsCurlyBraceOnSameLineAsCursor(precedingToken, current, lineAtPosition, sourceFile) { - var nextToken = ts.findNextToken(precedingToken, current); - if (!nextToken) { - return false; - } - if (nextToken.kind === 15 /* OpenBraceToken */) { - // open braces are always indented at the parent level - return true; - } - else if (nextToken.kind === 16 /* 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 { - // $ - // } - /// and this one - not - // class A { - // $} - var nextTokenStartLine = getStartLineAndCharacterForNode(nextToken, sourceFile).line; - return lineAtPosition === nextTokenStartLine; - } - return false; - } - function getStartLineAndCharacterForNode(n, sourceFile) { - return sourceFile.getLineAndCharacterOfPosition(n.getStart(sourceFile)); - } - function childStartsOnTheSameLineWithElseInIfStatement(parent, child, childStartLine, sourceFile) { - if (parent.kind === 196 /* IfStatement */ && parent.elseStatement === child) { - var elseKeyword = ts.findChildOfKind(parent, 80 /* ElseKeyword */, sourceFile); - ts.Debug.assert(elseKeyword !== undefined); - var elseKeywordStartLine = getStartLineAndCharacterForNode(elseKeyword, sourceFile).line; - return elseKeywordStartLine === childStartLine; - } - return false; - } - SmartIndenter.childStartsOnTheSameLineWithElseInIfStatement = childStartsOnTheSameLineWithElseInIfStatement; - function getContainingList(node, sourceFile) { - if (node.parent) { - switch (node.parent.kind) { - case 151 /* TypeReference */: - if (node.parent.typeArguments && - ts.rangeContainsStartEnd(node.parent.typeArguments, node.getStart(sourceFile), node.getEnd())) { - return node.parent.typeArguments; - } - break; - case 165 /* ObjectLiteralExpression */: - return node.parent.properties; - case 164 /* ArrayLiteralExpression */: - return node.parent.elements; - case 213 /* FunctionDeclaration */: - case 173 /* FunctionExpression */: - case 174 /* ArrowFunction */: - case 143 /* MethodDeclaration */: - case 142 /* MethodSignature */: - case 147 /* CallSignature */: - case 148 /* ConstructSignature */: { - var start = node.getStart(sourceFile); - if (node.parent.typeParameters && - ts.rangeContainsStartEnd(node.parent.typeParameters, start, node.getEnd())) { - return node.parent.typeParameters; - } - if (ts.rangeContainsStartEnd(node.parent.parameters, start, node.getEnd())) { - return node.parent.parameters; - } - break; - } - case 169 /* NewExpression */: - case 168 /* CallExpression */: { - var start = node.getStart(sourceFile); - if (node.parent.typeArguments && - ts.rangeContainsStartEnd(node.parent.typeArguments, start, node.getEnd())) { - return node.parent.typeArguments; - } - if (node.parent.arguments && - ts.rangeContainsStartEnd(node.parent.arguments, start, node.getEnd())) { - return node.parent.arguments; - } - break; - } - } - } - return undefined; - } - function getActualIndentationForListItem(node, sourceFile, options) { - var containingList = getContainingList(node, sourceFile); - return containingList ? getActualIndentationFromList(containingList) : -1 /* Unknown */; - function getActualIndentationFromList(list) { - var index = ts.indexOf(list, node); - return index !== -1 ? deriveActualIndentationFromList(list, index, sourceFile, options) : -1 /* Unknown */; - } - } - 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 */) { - return -1 /* Unknown */; - } - if (node.parent && (node.parent.kind === 168 /* CallExpression */ || - node.parent.kind === 169 /* NewExpression */) && - node.parent.expression !== node) { - var fullCallOrNewExpression = node.parent.expression; - var startingExpression = getStartingExpression(fullCallOrNewExpression); - if (fullCallOrNewExpression === startingExpression) { - return -1 /* Unknown */; - } - var fullCallOrNewExpressionEnd = sourceFile.getLineAndCharacterOfPosition(fullCallOrNewExpression.end); - var startingExpressionEnd = sourceFile.getLineAndCharacterOfPosition(startingExpression.end); - if (fullCallOrNewExpressionEnd.line === startingExpressionEnd.line) { - return -1 /* Unknown */; - } - return findColumnForFirstNonWhitespaceCharacterInLine(fullCallOrNewExpressionEnd, sourceFile, options); - } - return -1 /* Unknown */; - function getStartingExpression(node) { - while (true) { - switch (node.kind) { - case 168 /* CallExpression */: - case 169 /* NewExpression */: - case 166 /* PropertyAccessExpression */: - case 167 /* ElementAccessExpression */: - node = node.expression; - break; - default: - return node; - } - } - return node; - } - } - function deriveActualIndentationFromList(list, index, sourceFile, options) { - ts.Debug.assert(index >= 0 && index < list.length); - var node = list[index]; - // walk toward the start of the list starting from current node and check if the line is the same for all items. - // 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 */) { - continue; - } - // skip list items that ends on the same line with the current list element - var prevEndLine = sourceFile.getLineAndCharacterOfPosition(list[i].end).line; - if (prevEndLine !== lineAndCharacter.line) { - return findColumnForFirstNonWhitespaceCharacterInLine(lineAndCharacter, sourceFile, options); - } - lineAndCharacter = getStartLineAndCharacterForNode(list[i], sourceFile); - } - return -1 /* Unknown */; - } - function findColumnForFirstNonWhitespaceCharacterInLine(lineAndCharacter, sourceFile, options) { - var lineStart = sourceFile.getPositionOfLineAndCharacter(lineAndCharacter.line, 0); - return findFirstNonWhitespaceColumn(lineStart, lineStart + lineAndCharacter.character, sourceFile, options); - } - /* - Character is the actual index of the character since the beginning of the line. - Column - position of the character after expanding tabs to spaces - "0\t2$" - value of 'character' for '$' is 3 - value of 'column' for '$' is 6 (assuming that tab size is 4) - */ - function findFirstNonWhitespaceCharacterAndColumn(startPos, endPos, sourceFile, options) { - var character = 0; - var column = 0; - for (var pos = startPos; pos < endPos; ++pos) { - var ch = sourceFile.text.charCodeAt(pos); - if (!ts.isWhiteSpace(ch)) { - break; - } - if (ch === 9 /* tab */) { - column += options.TabSize + (column % options.TabSize); - } - else { - column++; - } - character++; - } - return { column: column, character: character }; - } - SmartIndenter.findFirstNonWhitespaceCharacterAndColumn = findFirstNonWhitespaceCharacterAndColumn; - function findFirstNonWhitespaceColumn(startPos, endPos, sourceFile, options) { - return findFirstNonWhitespaceCharacterAndColumn(startPos, endPos, sourceFile, options).column; - } - SmartIndenter.findFirstNonWhitespaceColumn = findFirstNonWhitespaceColumn; - function nodeContentIsAlwaysIndented(kind) { - switch (kind) { - case 195 /* ExpressionStatement */: - case 214 /* ClassDeclaration */: - case 186 /* ClassExpression */: - case 215 /* InterfaceDeclaration */: - case 217 /* EnumDeclaration */: - case 216 /* TypeAliasDeclaration */: - case 164 /* ArrayLiteralExpression */: - case 192 /* Block */: - case 219 /* ModuleBlock */: - case 165 /* ObjectLiteralExpression */: - case 155 /* TypeLiteral */: - case 157 /* TupleType */: - case 220 /* CaseBlock */: - case 242 /* DefaultClause */: - case 241 /* CaseClause */: - case 172 /* ParenthesizedExpression */: - case 166 /* PropertyAccessExpression */: - case 168 /* CallExpression */: - case 169 /* NewExpression */: - case 193 /* VariableStatement */: - case 211 /* VariableDeclaration */: - case 227 /* ExportAssignment */: - case 204 /* ReturnStatement */: - case 182 /* ConditionalExpression */: - case 162 /* ArrayBindingPattern */: - case 161 /* ObjectBindingPattern */: - case 233 /* JsxElement */: - case 234 /* JsxSelfClosingElement */: - case 142 /* MethodSignature */: - case 147 /* CallSignature */: - case 148 /* ConstructSignature */: - case 138 /* Parameter */: - case 152 /* FunctionType */: - case 153 /* ConstructorType */: - case 160 /* ParenthesizedType */: - case 170 /* TaggedTemplateExpression */: - case 178 /* AwaitExpression */: - return true; - } - return false; - } - function shouldIndentChildNode(parent, child) { - if (nodeContentIsAlwaysIndented(parent)) { - return true; - } - switch (parent) { - case 197 /* DoStatement */: - case 198 /* WhileStatement */: - case 200 /* ForInStatement */: - case 201 /* ForOfStatement */: - case 199 /* ForStatement */: - case 196 /* IfStatement */: - case 213 /* FunctionDeclaration */: - case 173 /* FunctionExpression */: - case 143 /* MethodDeclaration */: - case 174 /* ArrowFunction */: - case 144 /* Constructor */: - case 145 /* GetAccessor */: - case 146 /* SetAccessor */: - return child !== 192 /* Block */; - default: - return false; - } - } - SmartIndenter.shouldIndentChildNode = shouldIndentChildNode; - })(SmartIndenter = formatting.SmartIndenter || (formatting.SmartIndenter = {})); - })(formatting = ts.formatting || (ts.formatting = {})); -})(ts || (ts = {})); -/// -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 ts; -(function (ts) { - /** The version of the language service API */ - ts.servicesVersion = "0.4"; - var ScriptSnapshot; - (function (ScriptSnapshot) { - var StringScriptSnapshot = (function () { - function StringScriptSnapshot(text) { - this.text = text; - } - StringScriptSnapshot.prototype.getText = function (start, end) { - return this.text.substring(start, end); - }; - StringScriptSnapshot.prototype.getLength = function () { - return this.text.length; - }; - StringScriptSnapshot.prototype.getChangeRange = function (oldSnapshot) { - // Text-based snapshots do not support incremental parsing. Return undefined - // to signal that to the caller. - return undefined; - }; - return StringScriptSnapshot; - })(); - function fromString(text) { - return new StringScriptSnapshot(text); - } - ScriptSnapshot.fromString = fromString; - })(ScriptSnapshot = ts.ScriptSnapshot || (ts.ScriptSnapshot = {})); - var scanner = ts.createScanner(2 /* Latest */, /*skipTrivia*/ true); - var emptyArray = []; - var jsDocTagNames = [ - "augments", - "author", - "argument", - "borrows", - "class", - "constant", - "constructor", - "constructs", - "default", - "deprecated", - "description", - "event", - "example", - "extends", - "field", - "fileOverview", - "function", - "ignore", - "inner", - "lends", - "link", - "memberOf", - "name", - "namespace", - "param", - "private", - "property", - "public", - "requires", - "returns", - "see", - "since", - "static", - "throws", - "type", - "version" - ]; - var jsDocCompletionEntries; - function createNode(kind, pos, end, flags, parent) { - var node = new (ts.getNodeConstructor(kind))(pos, end); - node.flags = flags; - node.parent = parent; - return node; - } - var NodeObject = (function () { - function NodeObject() { - } - NodeObject.prototype.getSourceFile = function () { - return ts.getSourceFileOfNode(this); - }; - NodeObject.prototype.getStart = function (sourceFile) { - return ts.getTokenPosOfNode(this, sourceFile); - }; - NodeObject.prototype.getFullStart = function () { - return this.pos; - }; - NodeObject.prototype.getEnd = function () { - return this.end; - }; - NodeObject.prototype.getWidth = function (sourceFile) { - return this.getEnd() - this.getStart(sourceFile); - }; - NodeObject.prototype.getFullWidth = function () { - return this.end - this.pos; - }; - NodeObject.prototype.getLeadingTriviaWidth = function (sourceFile) { - return this.getStart(sourceFile) - this.pos; - }; - NodeObject.prototype.getFullText = function (sourceFile) { - return (sourceFile || this.getSourceFile()).text.substring(this.pos, this.end); - }; - NodeObject.prototype.getText = function (sourceFile) { - return (sourceFile || this.getSourceFile()).text.substring(this.getStart(), this.getEnd()); - }; - NodeObject.prototype.addSyntheticNodes = function (nodes, pos, end) { - scanner.setTextPos(pos); - while (pos < end) { - var token = scanner.scan(); - var textPos = scanner.getTextPos(); - nodes.push(createNode(token, pos, textPos, 4096 /* Synthetic */, this)); - pos = textPos; - } - return pos; - }; - NodeObject.prototype.createSyntaxList = function (nodes) { - var list = createNode(271 /* SyntaxList */, nodes.pos, nodes.end, 4096 /* Synthetic */, this); - list._children = []; - var pos = nodes.pos; - for (var _i = 0; _i < nodes.length; _i++) { - var node = nodes[_i]; - if (pos < node.pos) { - pos = this.addSyntheticNodes(list._children, pos, node.pos); - } - list._children.push(node); - pos = node.end; - } - if (pos < nodes.end) { - this.addSyntheticNodes(list._children, pos, nodes.end); - } - return list; - }; - NodeObject.prototype.createChildren = function (sourceFile) { - var _this = this; - var children; - if (this.kind >= 135 /* FirstNode */) { - scanner.setText((sourceFile || this.getSourceFile()).text); - children = []; - var pos = this.pos; - var processNode = function (node) { - if (pos < node.pos) { - pos = _this.addSyntheticNodes(children, pos, node.pos); - } - children.push(node); - pos = node.end; - }; - var processNodes = function (nodes) { - if (pos < nodes.pos) { - pos = _this.addSyntheticNodes(children, pos, nodes.pos); - } - children.push(_this.createSyntaxList(nodes)); - pos = nodes.end; - }; - ts.forEachChild(this, processNode, processNodes); - if (pos < this.end) { - this.addSyntheticNodes(children, pos, this.end); - } - scanner.setText(undefined); - } - this._children = children || emptyArray; - }; - NodeObject.prototype.getChildCount = function (sourceFile) { - if (!this._children) - this.createChildren(sourceFile); - return this._children.length; - }; - NodeObject.prototype.getChildAt = function (index, sourceFile) { - if (!this._children) - this.createChildren(sourceFile); - return this._children[index]; - }; - NodeObject.prototype.getChildren = function (sourceFile) { - if (!this._children) - this.createChildren(sourceFile); - return this._children; - }; - NodeObject.prototype.getFirstToken = function (sourceFile) { - var children = this.getChildren(sourceFile); - if (!children.length) { - return undefined; - } - var child = children[0]; - return child.kind < 135 /* FirstNode */ ? child : child.getFirstToken(sourceFile); - }; - NodeObject.prototype.getLastToken = function (sourceFile) { - var children = this.getChildren(sourceFile); - var child = ts.lastOrUndefined(children); - if (!child) { - return undefined; - } - return child.kind < 135 /* FirstNode */ ? child : child.getLastToken(sourceFile); - }; - return NodeObject; - })(); - var SymbolObject = (function () { - function SymbolObject(flags, name) { - this.flags = flags; - this.name = name; - } - SymbolObject.prototype.getFlags = function () { - return this.flags; - }; - SymbolObject.prototype.getName = function () { - return this.name; - }; - SymbolObject.prototype.getDeclarations = function () { - return this.declarations; - }; - SymbolObject.prototype.getDocumentationComment = function () { - if (this.documentationComment === undefined) { - this.documentationComment = getJsDocCommentsFromDeclarations(this.declarations, this.name, !(this.flags & 4 /* Property */)); - } - return this.documentationComment; - }; - return SymbolObject; - })(); - function getJsDocCommentsFromDeclarations(declarations, name, canUseParsedParamTagComments) { - var documentationComment = []; - var docComments = getJsDocCommentsSeparatedByNewLines(); - ts.forEach(docComments, function (docComment) { - if (documentationComment.length) { - documentationComment.push(ts.lineBreakPart()); - } - documentationComment.push(docComment); - }); - return documentationComment; - function getJsDocCommentsSeparatedByNewLines() { - var paramTag = "@param"; - var jsDocCommentParts = []; - ts.forEach(declarations, function (declaration, indexOfDeclaration) { - // Make sure we are collecting doc comment from declaration once, - // In case of union property there might be same declaration multiple times - // which only varies in type parameter - // Eg. let a: Array | Array; a.length - // The property length will have two declarations of property length coming - // from Array - Array and Array - if (ts.indexOf(declarations, declaration) === indexOfDeclaration) { - var sourceFileOfDeclaration = ts.getSourceFileOfNode(declaration); - // If it is parameter - try and get the jsDoc comment with @param tag from function declaration's jsDoc comments - if (canUseParsedParamTagComments && declaration.kind === 138 /* Parameter */) { - ts.forEach(getJsDocCommentTextRange(declaration.parent, sourceFileOfDeclaration), function (jsDocCommentTextRange) { - var cleanedParamJsDocComment = getCleanedParamJsDocComment(jsDocCommentTextRange.pos, jsDocCommentTextRange.end, sourceFileOfDeclaration); - if (cleanedParamJsDocComment) { - ts.addRange(jsDocCommentParts, cleanedParamJsDocComment); - } - }); - } - // If this is left side of dotted module declaration, there is no doc comments associated with this node - if (declaration.kind === 218 /* ModuleDeclaration */ && declaration.body.kind === 218 /* ModuleDeclaration */) { - return; - } - // If this is dotted module name, get the doc comments from the parent - while (declaration.kind === 218 /* ModuleDeclaration */ && declaration.parent.kind === 218 /* ModuleDeclaration */) { - declaration = declaration.parent; - } - // Get the cleaned js doc comment text from the declaration - ts.forEach(getJsDocCommentTextRange(declaration.kind === 211 /* VariableDeclaration */ ? declaration.parent.parent : declaration, sourceFileOfDeclaration), function (jsDocCommentTextRange) { - var cleanedJsDocComment = getCleanedJsDocComment(jsDocCommentTextRange.pos, jsDocCommentTextRange.end, sourceFileOfDeclaration); - if (cleanedJsDocComment) { - ts.addRange(jsDocCommentParts, cleanedJsDocComment); - } - }); - } - }); - return jsDocCommentParts; - function getJsDocCommentTextRange(node, sourceFile) { - return ts.map(ts.getJsDocComments(node, sourceFile), function (jsDocComment) { - return { - pos: jsDocComment.pos + "/*".length, - end: jsDocComment.end - "*/".length // Trim off comment end indicator - }; - }); - } - function consumeWhiteSpacesOnTheLine(pos, end, sourceFile, maxSpacesToRemove) { - if (maxSpacesToRemove !== undefined) { - end = Math.min(end, pos + maxSpacesToRemove); - } - for (; pos < end; pos++) { - var ch = sourceFile.text.charCodeAt(pos); - if (!ts.isWhiteSpace(ch) || ts.isLineBreak(ch)) { - // Either found lineBreak or non whiteSpace - return pos; - } - } - return end; - } - function consumeLineBreaks(pos, end, sourceFile) { - while (pos < end && ts.isLineBreak(sourceFile.text.charCodeAt(pos))) { - pos++; - } - return pos; - } - function isName(pos, end, sourceFile, name) { - return pos + name.length < end && - sourceFile.text.substr(pos, name.length) === name && - (ts.isWhiteSpace(sourceFile.text.charCodeAt(pos + name.length)) || - ts.isLineBreak(sourceFile.text.charCodeAt(pos + name.length))); - } - function isParamTag(pos, end, sourceFile) { - // If it is @param tag - return isName(pos, end, sourceFile, paramTag); - } - function pushDocCommentLineText(docComments, text, blankLineCount) { - // Add the empty lines in between texts - while (blankLineCount--) { - docComments.push(ts.textPart("")); - } - docComments.push(ts.textPart(text)); - } - function getCleanedJsDocComment(pos, end, sourceFile) { - var spacesToRemoveAfterAsterisk; - var docComments = []; - var blankLineCount = 0; - var isInParamTag = false; - while (pos < end) { - var docCommentTextOfLine = ""; - // First consume leading white space - pos = consumeWhiteSpacesOnTheLine(pos, end, sourceFile); - // If the comment starts with '*' consume the spaces on this line - if (pos < end && sourceFile.text.charCodeAt(pos) === 42 /* asterisk */) { - var lineStartPos = pos + 1; - pos = consumeWhiteSpacesOnTheLine(pos + 1, end, sourceFile, spacesToRemoveAfterAsterisk); - // Set the spaces to remove after asterisk as margin if not already set - if (spacesToRemoveAfterAsterisk === undefined && pos < end && !ts.isLineBreak(sourceFile.text.charCodeAt(pos))) { - spacesToRemoveAfterAsterisk = pos - lineStartPos; - } - } - else if (spacesToRemoveAfterAsterisk === undefined) { - spacesToRemoveAfterAsterisk = 0; - } - // Analyse text on this line - while (pos < end && !ts.isLineBreak(sourceFile.text.charCodeAt(pos))) { - var ch = sourceFile.text.charAt(pos); - if (ch === "@") { - // If it is @param tag - if (isParamTag(pos, end, sourceFile)) { - isInParamTag = true; - pos += paramTag.length; - continue; - } - else { - isInParamTag = false; - } - } - // Add the ch to doc text if we arent in param tag - if (!isInParamTag) { - docCommentTextOfLine += ch; - } - // Scan next character - pos++; - } - // Continue with next line - pos = consumeLineBreaks(pos, end, sourceFile); - if (docCommentTextOfLine) { - pushDocCommentLineText(docComments, docCommentTextOfLine, blankLineCount); - blankLineCount = 0; - } - else if (!isInParamTag && docComments.length) { - // This is blank line when there is text already parsed - blankLineCount++; - } - } - return docComments; - } - function getCleanedParamJsDocComment(pos, end, sourceFile) { - var paramHelpStringMargin; - var paramDocComments = []; - while (pos < end) { - if (isParamTag(pos, end, sourceFile)) { - var blankLineCount = 0; - var recordedParamTag = false; - // Consume leading spaces - pos = consumeWhiteSpaces(pos + paramTag.length); - if (pos >= end) { - break; - } - // Ignore type expression - if (sourceFile.text.charCodeAt(pos) === 123 /* openBrace */) { - pos++; - for (var curlies = 1; pos < end; pos++) { - var charCode = sourceFile.text.charCodeAt(pos); - // { character means we need to find another } to match the found one - if (charCode === 123 /* openBrace */) { - curlies++; - continue; - } - // } char - if (charCode === 125 /* closeBrace */) { - curlies--; - if (curlies === 0) { - // We do not have any more } to match the type expression is ignored completely - pos++; - break; - } - else { - // there are more { to be matched with } - continue; - } - } - // Found start of another tag - if (charCode === 64 /* at */) { - break; - } - } - // Consume white spaces - pos = consumeWhiteSpaces(pos); - if (pos >= end) { - break; - } - } - // Parameter name - if (isName(pos, end, sourceFile, name)) { - // Found the parameter we are looking for consume white spaces - pos = consumeWhiteSpaces(pos + name.length); - if (pos >= end) { - break; - } - var paramHelpString = ""; - var firstLineParamHelpStringPos = pos; - while (pos < end) { - var ch = sourceFile.text.charCodeAt(pos); - // at line break, set this comment line text and go to next line - if (ts.isLineBreak(ch)) { - if (paramHelpString) { - pushDocCommentLineText(paramDocComments, paramHelpString, blankLineCount); - paramHelpString = ""; - blankLineCount = 0; - recordedParamTag = true; - } - else if (recordedParamTag) { - blankLineCount++; - } - // Get the pos after cleaning start of the line - setPosForParamHelpStringOnNextLine(firstLineParamHelpStringPos); - continue; - } - // Done scanning param help string - next tag found - if (ch === 64 /* at */) { - break; - } - paramHelpString += sourceFile.text.charAt(pos); - // Go to next character - pos++; - } - // If there is param help text, add it top the doc comments - if (paramHelpString) { - pushDocCommentLineText(paramDocComments, paramHelpString, blankLineCount); - } - paramHelpStringMargin = undefined; - } - // If this is the start of another tag, continue with the loop in seach of param tag with symbol name - if (sourceFile.text.charCodeAt(pos) === 64 /* at */) { - continue; - } - } - // Next character - pos++; - } - return paramDocComments; - function consumeWhiteSpaces(pos) { - while (pos < end && ts.isWhiteSpace(sourceFile.text.charCodeAt(pos))) { - pos++; - } - return pos; - } - function setPosForParamHelpStringOnNextLine(firstLineParamHelpStringPos) { - // Get the pos after consuming line breaks - pos = consumeLineBreaks(pos, end, sourceFile); - if (pos >= end) { - return; - } - if (paramHelpStringMargin === undefined) { - paramHelpStringMargin = sourceFile.getLineAndCharacterOfPosition(firstLineParamHelpStringPos).character; - } - // Now consume white spaces max - var startOfLinePos = pos; - pos = consumeWhiteSpacesOnTheLine(pos, end, sourceFile, paramHelpStringMargin); - if (pos >= end) { - return; - } - var consumedSpaces = pos - startOfLinePos; - if (consumedSpaces < paramHelpStringMargin) { - var ch = sourceFile.text.charCodeAt(pos); - if (ch === 42 /* asterisk */) { - // Consume more spaces after asterisk - pos = consumeWhiteSpacesOnTheLine(pos + 1, end, sourceFile, paramHelpStringMargin - consumedSpaces - 1); - } - } - } - } - } - } - var TypeObject = (function () { - function TypeObject(checker, flags) { - this.checker = checker; - this.flags = flags; - } - TypeObject.prototype.getFlags = function () { - return this.flags; - }; - TypeObject.prototype.getSymbol = function () { - return this.symbol; - }; - TypeObject.prototype.getProperties = function () { - return this.checker.getPropertiesOfType(this); - }; - TypeObject.prototype.getProperty = function (propertyName) { - return this.checker.getPropertyOfType(this, propertyName); - }; - TypeObject.prototype.getApparentProperties = function () { - return this.checker.getAugmentedPropertiesOfType(this); - }; - TypeObject.prototype.getCallSignatures = function () { - return this.checker.getSignaturesOfType(this, 0 /* Call */); - }; - TypeObject.prototype.getConstructSignatures = function () { - return this.checker.getSignaturesOfType(this, 1 /* Construct */); - }; - TypeObject.prototype.getStringIndexType = function () { - return this.checker.getIndexTypeOfType(this, 0 /* String */); - }; - TypeObject.prototype.getNumberIndexType = function () { - return this.checker.getIndexTypeOfType(this, 1 /* Number */); - }; - TypeObject.prototype.getBaseTypes = function () { - return this.flags & (1024 /* Class */ | 2048 /* Interface */) - ? this.checker.getBaseTypes(this) - : undefined; - }; - return TypeObject; - })(); - var SignatureObject = (function () { - function SignatureObject(checker) { - this.checker = checker; - } - SignatureObject.prototype.getDeclaration = function () { - return this.declaration; - }; - SignatureObject.prototype.getTypeParameters = function () { - return this.typeParameters; - }; - SignatureObject.prototype.getParameters = function () { - return this.parameters; - }; - SignatureObject.prototype.getReturnType = function () { - return this.checker.getReturnTypeOfSignature(this); - }; - SignatureObject.prototype.getDocumentationComment = function () { - if (this.documentationComment === undefined) { - this.documentationComment = this.declaration ? getJsDocCommentsFromDeclarations([this.declaration], - /*name*/ undefined, - /*canUseParsedParamTagComments*/ false) : []; - } - return this.documentationComment; - }; - return SignatureObject; - })(); - var SourceFileObject = (function (_super) { - __extends(SourceFileObject, _super); - function SourceFileObject() { - _super.apply(this, arguments); - } - SourceFileObject.prototype.update = function (newText, textChangeRange) { - return ts.updateSourceFile(this, newText, textChangeRange); - }; - SourceFileObject.prototype.getLineAndCharacterOfPosition = function (position) { - return ts.getLineAndCharacterOfPosition(this, position); - }; - SourceFileObject.prototype.getLineStarts = function () { - return ts.getLineStarts(this); - }; - SourceFileObject.prototype.getPositionOfLineAndCharacter = function (line, character) { - return ts.getPositionOfLineAndCharacter(this, line, character); - }; - SourceFileObject.prototype.getNamedDeclarations = function () { - if (!this.namedDeclarations) { - this.namedDeclarations = this.computeNamedDeclarations(); - } - return this.namedDeclarations; - }; - SourceFileObject.prototype.computeNamedDeclarations = function () { - var result = {}; - ts.forEachChild(this, visit); - return result; - function addDeclaration(declaration) { - var name = getDeclarationName(declaration); - if (name) { - var declarations = getDeclarations(name); - declarations.push(declaration); - } - } - function getDeclarations(name) { - return ts.getProperty(result, name) || (result[name] = []); - } - function getDeclarationName(declaration) { - if (declaration.name) { - var result_2 = getTextOfIdentifierOrLiteral(declaration.name); - if (result_2 !== undefined) { - return result_2; - } - if (declaration.name.kind === 136 /* ComputedPropertyName */) { - var expr = declaration.name.expression; - if (expr.kind === 166 /* PropertyAccessExpression */) { - return expr.name.text; - } - return getTextOfIdentifierOrLiteral(expr); - } - } - return undefined; - } - function getTextOfIdentifierOrLiteral(node) { - if (node) { - if (node.kind === 69 /* Identifier */ || - node.kind === 9 /* StringLiteral */ || - node.kind === 8 /* NumericLiteral */) { - return node.text; - } - } - return undefined; - } - function visit(node) { - switch (node.kind) { - case 213 /* FunctionDeclaration */: - case 143 /* MethodDeclaration */: - case 142 /* MethodSignature */: - var functionDeclaration = node; - var declarationName = getDeclarationName(functionDeclaration); - if (declarationName) { - var declarations = getDeclarations(declarationName); - var lastDeclaration = ts.lastOrUndefined(declarations); - // Check whether this declaration belongs to an "overload group". - if (lastDeclaration && functionDeclaration.parent === lastDeclaration.parent && functionDeclaration.symbol === lastDeclaration.symbol) { - // Overwrite the last declaration if it was an overload - // and this one is an implementation. - if (functionDeclaration.body && !lastDeclaration.body) { - declarations[declarations.length - 1] = functionDeclaration; - } - } - else { - declarations.push(functionDeclaration); - } - ts.forEachChild(node, visit); - } - break; - case 214 /* ClassDeclaration */: - case 215 /* InterfaceDeclaration */: - case 216 /* TypeAliasDeclaration */: - case 217 /* EnumDeclaration */: - case 218 /* ModuleDeclaration */: - case 221 /* ImportEqualsDeclaration */: - case 230 /* ExportSpecifier */: - case 226 /* ImportSpecifier */: - case 221 /* ImportEqualsDeclaration */: - case 223 /* ImportClause */: - case 224 /* NamespaceImport */: - case 145 /* GetAccessor */: - case 146 /* SetAccessor */: - case 155 /* TypeLiteral */: - addDeclaration(node); - // fall through - case 144 /* Constructor */: - case 193 /* VariableStatement */: - case 212 /* VariableDeclarationList */: - case 161 /* ObjectBindingPattern */: - case 162 /* ArrayBindingPattern */: - case 219 /* ModuleBlock */: - ts.forEachChild(node, visit); - break; - case 192 /* Block */: - if (ts.isFunctionBlock(node)) { - ts.forEachChild(node, visit); - } - break; - case 138 /* Parameter */: - // Only consider properties defined as constructor parameters - if (!(node.flags & 112 /* AccessibilityModifier */)) { - break; - } - // fall through - case 211 /* VariableDeclaration */: - case 163 /* BindingElement */: - if (ts.isBindingPattern(node.name)) { - ts.forEachChild(node.name, visit); - break; - } - case 247 /* EnumMember */: - case 141 /* PropertyDeclaration */: - case 140 /* PropertySignature */: - addDeclaration(node); - break; - case 228 /* ExportDeclaration */: - // Handle named exports case e.g.: - // export {a, b as B} from "mod"; - if (node.exportClause) { - ts.forEach(node.exportClause.elements, visit); - } - break; - case 222 /* ImportDeclaration */: - var importClause = node.importClause; - if (importClause) { - // Handle default import case e.g.: - // import d from "mod"; - if (importClause.name) { - addDeclaration(importClause); - } - // Handle named bindings in imports e.g.: - // import * as NS from "mod"; - // import {a, b as B} from "mod"; - if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 224 /* NamespaceImport */) { - addDeclaration(importClause.namedBindings); - } - else { - ts.forEach(importClause.namedBindings.elements, visit); - } - } - } - break; - } - } - }; - return SourceFileObject; - })(NodeObject); - var TextChange = (function () { - function TextChange() { - } - return TextChange; - })(); - ts.TextChange = TextChange; - var HighlightSpanKind; - (function (HighlightSpanKind) { - HighlightSpanKind.none = "none"; - HighlightSpanKind.definition = "definition"; - HighlightSpanKind.reference = "reference"; - HighlightSpanKind.writtenReference = "writtenReference"; - })(HighlightSpanKind = ts.HighlightSpanKind || (ts.HighlightSpanKind = {})); - (function (IndentStyle) { - IndentStyle[IndentStyle["None"] = 0] = "None"; - IndentStyle[IndentStyle["Block"] = 1] = "Block"; - IndentStyle[IndentStyle["Smart"] = 2] = "Smart"; - })(ts.IndentStyle || (ts.IndentStyle = {})); - var IndentStyle = ts.IndentStyle; - (function (SymbolDisplayPartKind) { - SymbolDisplayPartKind[SymbolDisplayPartKind["aliasName"] = 0] = "aliasName"; - SymbolDisplayPartKind[SymbolDisplayPartKind["className"] = 1] = "className"; - SymbolDisplayPartKind[SymbolDisplayPartKind["enumName"] = 2] = "enumName"; - SymbolDisplayPartKind[SymbolDisplayPartKind["fieldName"] = 3] = "fieldName"; - SymbolDisplayPartKind[SymbolDisplayPartKind["interfaceName"] = 4] = "interfaceName"; - SymbolDisplayPartKind[SymbolDisplayPartKind["keyword"] = 5] = "keyword"; - SymbolDisplayPartKind[SymbolDisplayPartKind["lineBreak"] = 6] = "lineBreak"; - SymbolDisplayPartKind[SymbolDisplayPartKind["numericLiteral"] = 7] = "numericLiteral"; - SymbolDisplayPartKind[SymbolDisplayPartKind["stringLiteral"] = 8] = "stringLiteral"; - SymbolDisplayPartKind[SymbolDisplayPartKind["localName"] = 9] = "localName"; - SymbolDisplayPartKind[SymbolDisplayPartKind["methodName"] = 10] = "methodName"; - SymbolDisplayPartKind[SymbolDisplayPartKind["moduleName"] = 11] = "moduleName"; - SymbolDisplayPartKind[SymbolDisplayPartKind["operator"] = 12] = "operator"; - SymbolDisplayPartKind[SymbolDisplayPartKind["parameterName"] = 13] = "parameterName"; - SymbolDisplayPartKind[SymbolDisplayPartKind["propertyName"] = 14] = "propertyName"; - SymbolDisplayPartKind[SymbolDisplayPartKind["punctuation"] = 15] = "punctuation"; - SymbolDisplayPartKind[SymbolDisplayPartKind["space"] = 16] = "space"; - SymbolDisplayPartKind[SymbolDisplayPartKind["text"] = 17] = "text"; - SymbolDisplayPartKind[SymbolDisplayPartKind["typeParameterName"] = 18] = "typeParameterName"; - SymbolDisplayPartKind[SymbolDisplayPartKind["enumMemberName"] = 19] = "enumMemberName"; - SymbolDisplayPartKind[SymbolDisplayPartKind["functionName"] = 20] = "functionName"; - 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"; - TokenClass[TokenClass["Operator"] = 2] = "Operator"; - TokenClass[TokenClass["Comment"] = 3] = "Comment"; - TokenClass[TokenClass["Whitespace"] = 4] = "Whitespace"; - TokenClass[TokenClass["Identifier"] = 5] = "Identifier"; - TokenClass[TokenClass["NumberLiteral"] = 6] = "NumberLiteral"; - TokenClass[TokenClass["StringLiteral"] = 7] = "StringLiteral"; - TokenClass[TokenClass["RegExpLiteral"] = 8] = "RegExpLiteral"; - })(ts.TokenClass || (ts.TokenClass = {})); - var TokenClass = ts.TokenClass; - // TODO: move these to enums - var ScriptElementKind; - (function (ScriptElementKind) { - ScriptElementKind.unknown = ""; - ScriptElementKind.warning = "warning"; - // predefined type (void) or keyword (class) - ScriptElementKind.keyword = "keyword"; - // top level script node - ScriptElementKind.scriptElement = "script"; - // module foo {} - ScriptElementKind.moduleElement = "module"; - // class X {} - ScriptElementKind.classElement = "class"; - // var x = class X {} - ScriptElementKind.localClassElement = "local class"; - // interface Y {} - ScriptElementKind.interfaceElement = "interface"; - // type T = ... - ScriptElementKind.typeElement = "type"; - // enum E - ScriptElementKind.enumElement = "enum"; - // Inside module and script only - // let v = .. - ScriptElementKind.variableElement = "var"; - // Inside function - ScriptElementKind.localVariableElement = "local var"; - // Inside module and script only - // function f() { } - ScriptElementKind.functionElement = "function"; - // Inside function - ScriptElementKind.localFunctionElement = "local function"; - // class X { [public|private]* foo() {} } - ScriptElementKind.memberFunctionElement = "method"; - // class X { [public|private]* [get|set] foo:number; } - ScriptElementKind.memberGetAccessorElement = "getter"; - ScriptElementKind.memberSetAccessorElement = "setter"; - // class X { [public|private]* foo:number; } - // interface Y { foo:number; } - ScriptElementKind.memberVariableElement = "property"; - // class X { constructor() { } } - ScriptElementKind.constructorImplementationElement = "constructor"; - // interface Y { ():number; } - ScriptElementKind.callSignatureElement = "call"; - // interface Y { []:number; } - ScriptElementKind.indexSignatureElement = "index"; - // interface Y { new():Y; } - ScriptElementKind.constructSignatureElement = "construct"; - // function foo(*Y*: string) - ScriptElementKind.parameterElement = "parameter"; - ScriptElementKind.typeParameterElement = "type parameter"; - ScriptElementKind.primitiveType = "primitive type"; - ScriptElementKind.label = "label"; - ScriptElementKind.alias = "alias"; - ScriptElementKind.constElement = "const"; - ScriptElementKind.letElement = "let"; - })(ScriptElementKind = ts.ScriptElementKind || (ts.ScriptElementKind = {})); - var ScriptElementKindModifier; - (function (ScriptElementKindModifier) { - ScriptElementKindModifier.none = ""; - ScriptElementKindModifier.publicMemberModifier = "public"; - ScriptElementKindModifier.privateMemberModifier = "private"; - ScriptElementKindModifier.protectedMemberModifier = "protected"; - ScriptElementKindModifier.exportedModifier = "export"; - ScriptElementKindModifier.ambientModifier = "declare"; - ScriptElementKindModifier.staticModifier = "static"; - ScriptElementKindModifier.abstractModifier = "abstract"; - })(ScriptElementKindModifier = ts.ScriptElementKindModifier || (ts.ScriptElementKindModifier = {})); - var ClassificationTypeNames = (function () { - function ClassificationTypeNames() { - } - ClassificationTypeNames.comment = "comment"; - ClassificationTypeNames.identifier = "identifier"; - ClassificationTypeNames.keyword = "keyword"; - ClassificationTypeNames.numericLiteral = "number"; - ClassificationTypeNames.operator = "operator"; - ClassificationTypeNames.stringLiteral = "string"; - ClassificationTypeNames.whiteSpace = "whitespace"; - ClassificationTypeNames.text = "text"; - ClassificationTypeNames.punctuation = "punctuation"; - ClassificationTypeNames.className = "class name"; - ClassificationTypeNames.enumName = "enum name"; - ClassificationTypeNames.interfaceName = "interface name"; - ClassificationTypeNames.moduleName = "module name"; - ClassificationTypeNames.typeParameterName = "type parameter name"; - ClassificationTypeNames.typeAliasName = "type alias name"; - ClassificationTypeNames.parameterName = "parameter name"; - ClassificationTypeNames.docCommentTagName = "doc comment tag name"; - return ClassificationTypeNames; - })(); - 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"; - })(ts.ClassificationType || (ts.ClassificationType = {})); - var ClassificationType = ts.ClassificationType; - function displayPartsToString(displayParts) { - if (displayParts) { - return ts.map(displayParts, function (displayPart) { return displayPart.text; }).join(""); - } - return ""; - } - ts.displayPartsToString = displayPartsToString; - function isLocalVariableOrFunction(symbol) { - if (symbol.parent) { - return false; // This is exported symbol - } - return ts.forEach(symbol.declarations, function (declaration) { - // Function expressions are local - if (declaration.kind === 173 /* FunctionExpression */) { - return true; - } - if (declaration.kind !== 211 /* VariableDeclaration */ && declaration.kind !== 213 /* FunctionDeclaration */) { - return false; - } - // If the parent is not sourceFile or module block it is local variable - for (var parent_8 = declaration.parent; !ts.isFunctionBlock(parent_8); parent_8 = parent_8.parent) { - // Reached source file or module block - if (parent_8.kind === 248 /* SourceFile */ || parent_8.kind === 219 /* ModuleBlock */) { - return false; - } - } - // parent is in function block - return true; - }); - } - function getDefaultCompilerOptions() { - // Always default to "ScriptTarget.ES5" for the language service - return { - target: 1 /* ES5 */, - module: 0 /* None */, - jsx: 1 /* Preserve */ - }; - } - ts.getDefaultCompilerOptions = getDefaultCompilerOptions; - // Cache host information about scrip Should be refreshed - // at each language service public entry point, since we don't know when - // set of scripts handled by the host changes. - var HostCache = (function () { - function HostCache(host, getCanonicalFileName) { - this.host = host; - // script id => script index - this.fileNameToEntry = ts.createFileMap(getCanonicalFileName); - // Initialize the list with the root file names - var rootFileNames = host.getScriptFileNames(); - for (var _i = 0; _i < rootFileNames.length; _i++) { - var fileName = rootFileNames[_i]; - this.createEntry(fileName); - } - // store the compilation settings - this._compilationSettings = host.getCompilationSettings() || getDefaultCompilerOptions(); - } - HostCache.prototype.compilationSettings = function () { - return this._compilationSettings; - }; - HostCache.prototype.createEntry = function (fileName) { - var entry; - var scriptSnapshot = this.host.getScriptSnapshot(fileName); - if (scriptSnapshot) { - entry = { - hostFileName: fileName, - version: this.host.getScriptVersion(fileName), - scriptSnapshot: scriptSnapshot - }; - } - this.fileNameToEntry.set(fileName, entry); - return entry; - }; - HostCache.prototype.getEntry = function (fileName) { - return this.fileNameToEntry.get(fileName); - }; - HostCache.prototype.contains = function (fileName) { - return this.fileNameToEntry.contains(fileName); - }; - HostCache.prototype.getOrCreateEntry = function (fileName) { - if (this.contains(fileName)) { - return this.getEntry(fileName); - } - return this.createEntry(fileName); - }; - HostCache.prototype.getRootFileNames = function () { - var fileNames = []; - this.fileNameToEntry.forEachValue(function (value) { - if (value) { - fileNames.push(value.hostFileName); - } - }); - return fileNames; - }; - HostCache.prototype.getVersion = function (fileName) { - var file = this.getEntry(fileName); - return file && file.version; - }; - HostCache.prototype.getScriptSnapshot = function (fileName) { - var file = this.getEntry(fileName); - return file && file.scriptSnapshot; - }; - return HostCache; - })(); - var SyntaxTreeCache = (function () { - function SyntaxTreeCache(host) { - this.host = host; - } - SyntaxTreeCache.prototype.getCurrentSourceFile = function (fileName) { - var scriptSnapshot = this.host.getScriptSnapshot(fileName); - if (!scriptSnapshot) { - // The host does not know about this file. - throw new Error("Could not find file: '" + fileName + "'."); - } - var version = this.host.getScriptVersion(fileName); - var sourceFile; - if (this.currentFileName !== fileName) { - // This is a new file, just parse it - sourceFile = createLanguageServiceSourceFile(fileName, scriptSnapshot, 2 /* Latest */, version, /*setNodeParents:*/ true); - } - else if (this.currentFileVersion !== version) { - // This is the same file, just a newer version. Incrementally parse the file. - var editRange = scriptSnapshot.getChangeRange(this.currentFileScriptSnapshot); - sourceFile = updateLanguageServiceSourceFile(this.currentSourceFile, scriptSnapshot, version, editRange); - } - if (sourceFile) { - // All done, ensure state is up to date - this.currentFileVersion = version; - this.currentFileName = fileName; - this.currentFileScriptSnapshot = scriptSnapshot; - this.currentSourceFile = sourceFile; - } - return this.currentSourceFile; - }; - return SyntaxTreeCache; - })(); - function setSourceFileFields(sourceFile, scriptSnapshot, version) { - sourceFile.version = version; - sourceFile.scriptSnapshot = scriptSnapshot; - } - /* - * This function will compile source text from 'input' argument using specified compiler options. - * If not options are provided - it will use a set of default compiler options. - * Extra compiler options that will unconditionally be used by this function are: - * - isolatedModules = true - * - allowNonTsExtensions = true - * - noLib = true - * - noResolve = true - */ - function transpileModule(input, transpileOptions) { - var options = transpileOptions.compilerOptions ? ts.clone(transpileOptions.compilerOptions) : getDefaultCompilerOptions(); - options.isolatedModules = true; - // Filename can be non-ts file. - options.allowNonTsExtensions = true; - // We are not returning a sourceFile for lib file when asked by the program, - // so pass --noLib to avoid reporting a file not found error. - options.noLib = true; - // We are not doing a full typecheck, we are not resolving the whole context, - // so pass --noResolve to avoid reporting missing file errors. - options.noResolve = true; - // if jsx is specified then treat file as .tsx - var inputFileName = transpileOptions.fileName || (options.jsx ? "module.tsx" : "module.ts"); - var sourceFile = ts.createSourceFile(inputFileName, input, options.target); - if (transpileOptions.moduleName) { - sourceFile.moduleName = transpileOptions.moduleName; - } - sourceFile.renamedDependencies = transpileOptions.renamedDependencies; - var newLine = ts.getNewLineCharacter(options); - // Output - var outputText; - var sourceMapText; - // Create a compilerHost object to allow the compiler to read and write files - var compilerHost = { - getSourceFile: function (fileName, target) { return fileName === ts.normalizeSlashes(inputFileName) ? sourceFile : undefined; }, - writeFile: function (name, text, writeByteOrderMark) { - if (ts.fileExtensionIs(name, ".map")) { - ts.Debug.assert(sourceMapText === undefined, "Unexpected multiple source map outputs for the file '" + name + "'"); - sourceMapText = text; - } - else { - ts.Debug.assert(outputText === undefined, "Unexpected multiple outputs for the file: " + name); - outputText = text; - } - }, - getDefaultLibFileName: function () { return "lib.d.ts"; }, - useCaseSensitiveFileNames: function () { return false; }, - getCanonicalFileName: function (fileName) { return fileName; }, - getCurrentDirectory: function () { return ""; }, - getNewLine: function () { return newLine; }, - fileExists: function (fileName) { return fileName === inputFileName; }, - readFile: function (fileName) { return ""; } - }; - var program = ts.createProgram([inputFileName], options, compilerHost); - var diagnostics; - if (transpileOptions.reportDiagnostics) { - diagnostics = []; - ts.addRange(/*to*/ diagnostics, /*from*/ program.getSyntacticDiagnostics(sourceFile)); - ts.addRange(/*to*/ diagnostics, /*from*/ program.getOptionsDiagnostics()); - } - // Emit - program.emit(); - ts.Debug.assert(outputText !== undefined, "Output generation failed"); - return { outputText: outputText, diagnostics: diagnostics, sourceMapText: sourceMapText }; - } - ts.transpileModule = transpileModule; - /* - * This is a shortcut function for transpileModule - it accepts transpileOptions as parameters and returns only outputText part of the result. - */ - function transpile(input, compilerOptions, fileName, diagnostics, moduleName) { - var output = transpileModule(input, { compilerOptions: compilerOptions, fileName: fileName, reportDiagnostics: !!diagnostics, moduleName: moduleName }); - // addRange correctly handles cases when wither 'from' or 'to' argument is missing - ts.addRange(diagnostics, output.diagnostics); - return output.outputText; - } - ts.transpile = transpile; - function createLanguageServiceSourceFile(fileName, scriptSnapshot, scriptTarget, version, setNodeParents) { - var text = scriptSnapshot.getText(0, scriptSnapshot.getLength()); - var sourceFile = ts.createSourceFile(fileName, text, scriptTarget, setNodeParents); - setSourceFileFields(sourceFile, scriptSnapshot, version); - // after full parsing we can use table with interned strings as name table - sourceFile.nameTable = sourceFile.identifiers; - return sourceFile; - } - ts.createLanguageServiceSourceFile = createLanguageServiceSourceFile; - ts.disableIncrementalParsing = false; - function updateLanguageServiceSourceFile(sourceFile, scriptSnapshot, version, textChangeRange, aggressiveChecks) { - // If we were given a text change range, and our version or open-ness changed, then - // incrementally parse this file. - if (textChangeRange) { - if (version !== sourceFile.version) { - // Once incremental parsing is ready, then just call into this function. - if (!ts.disableIncrementalParsing) { - var newText; - // grab the fragment from the beginning of the original text to the beginning of the span - var prefix = textChangeRange.span.start !== 0 - ? sourceFile.text.substr(0, textChangeRange.span.start) - : ""; - // grab the fragment from the end of the span till the end of the original text - var suffix = ts.textSpanEnd(textChangeRange.span) !== sourceFile.text.length - ? sourceFile.text.substr(ts.textSpanEnd(textChangeRange.span)) - : ""; - if (textChangeRange.newLength === 0) { - // edit was a deletion - just combine prefix and suffix - newText = prefix && suffix ? prefix + suffix : prefix || suffix; - } - else { - // it was actual edit, fetch the fragment of new text that correspond to new span - var changedText = scriptSnapshot.getText(textChangeRange.span.start, textChangeRange.span.start + textChangeRange.newLength); - // combine prefix, changed text and suffix - newText = prefix && suffix - ? prefix + changedText + suffix - : prefix - ? (prefix + changedText) - : (changedText + suffix); - } - var newSourceFile = ts.updateSourceFile(sourceFile, newText, textChangeRange, aggressiveChecks); - setSourceFileFields(newSourceFile, scriptSnapshot, version); - // after incremental parsing nameTable might not be up-to-date - // drop it so it can be lazily recreated later - newSourceFile.nameTable = undefined; - // dispose all resources held by old script snapshot - if (sourceFile !== newSourceFile && sourceFile.scriptSnapshot) { - if (sourceFile.scriptSnapshot.dispose) { - sourceFile.scriptSnapshot.dispose(); - } - sourceFile.scriptSnapshot = undefined; - } - return newSourceFile; - } - } - } - // Otherwise, just create a new source file. - return createLanguageServiceSourceFile(sourceFile.fileName, scriptSnapshot, sourceFile.languageVersion, version, /*setNodeParents:*/ true); - } - ts.updateLanguageServiceSourceFile = updateLanguageServiceSourceFile; - function createGetCanonicalFileName(useCaseSensitivefileNames) { - return useCaseSensitivefileNames - ? (function (fileName) { return fileName; }) - : (function (fileName) { return fileName.toLowerCase(); }); - } - ts.createGetCanonicalFileName = createGetCanonicalFileName; - function createDocumentRegistry(useCaseSensitiveFileNames) { - // Maps from compiler setting target (ES3, ES5, etc.) to all the cached documents we have - // for those settings. - var buckets = {}; - var getCanonicalFileName = createGetCanonicalFileName(!!useCaseSensitiveFileNames); - function getKeyFromCompilationSettings(settings) { - return "_" + settings.target + "|" + settings.module + "|" + settings.noResolve + "|" + settings.jsx; - } - function getBucketForCompilationSettings(settings, createIfMissing) { - var key = getKeyFromCompilationSettings(settings); - var bucket = ts.lookUp(buckets, key); - if (!bucket && createIfMissing) { - buckets[key] = bucket = ts.createFileMap(getCanonicalFileName); - } - return bucket; - } - function reportStats() { - var bucketInfoArray = Object.keys(buckets).filter(function (name) { return name && name.charAt(0) === '_'; }).map(function (name) { - var entries = ts.lookUp(buckets, name); - var sourceFiles = []; - for (var i in entries) { - var entry = entries.get(i); - sourceFiles.push({ - name: i, - refCount: entry.languageServiceRefCount, - references: entry.owners.slice(0) - }); - } - sourceFiles.sort(function (x, y) { return y.refCount - x.refCount; }); - return { - bucket: name, - sourceFiles: sourceFiles - }; - }); - return JSON.stringify(bucketInfoArray, null, 2); - } - function acquireDocument(fileName, compilationSettings, scriptSnapshot, version) { - return acquireOrUpdateDocument(fileName, compilationSettings, scriptSnapshot, version, /*acquiring:*/ true); - } - function updateDocument(fileName, compilationSettings, scriptSnapshot, version) { - return acquireOrUpdateDocument(fileName, compilationSettings, scriptSnapshot, version, /*acquiring:*/ false); - } - function acquireOrUpdateDocument(fileName, compilationSettings, scriptSnapshot, version, acquiring) { - var bucket = getBucketForCompilationSettings(compilationSettings, /*createIfMissing*/ true); - var entry = bucket.get(fileName); - if (!entry) { - ts.Debug.assert(acquiring, "How could we be trying to update a document that the registry doesn't have?"); - // Have never seen this file with these settings. Create a new source file for it. - var sourceFile = createLanguageServiceSourceFile(fileName, scriptSnapshot, compilationSettings.target, version, /*setNodeParents:*/ false); - entry = { - sourceFile: sourceFile, - languageServiceRefCount: 0, - owners: [] - }; - bucket.set(fileName, entry); - } - else { - // We have an entry for this file. However, it may be for a different version of - // the script snapshot. If so, update it appropriately. Otherwise, we can just - // return it as is. - if (entry.sourceFile.version !== version) { - entry.sourceFile = updateLanguageServiceSourceFile(entry.sourceFile, scriptSnapshot, version, scriptSnapshot.getChangeRange(entry.sourceFile.scriptSnapshot)); - } - } - // If we're acquiring, then this is the first time this LS is asking for this document. - // Increase our ref count so we know there's another LS using the document. If we're - // not acquiring, then that means the LS is 'updating' the file instead, and that means - // it has already acquired the document previously. As such, we do not need to increase - // the ref count. - if (acquiring) { - entry.languageServiceRefCount++; - } - return entry.sourceFile; - } - function releaseDocument(fileName, compilationSettings) { - var bucket = getBucketForCompilationSettings(compilationSettings, false); - ts.Debug.assert(bucket !== undefined); - var entry = bucket.get(fileName); - entry.languageServiceRefCount--; - ts.Debug.assert(entry.languageServiceRefCount >= 0); - if (entry.languageServiceRefCount === 0) { - bucket.remove(fileName); - } - } - return { - acquireDocument: acquireDocument, - updateDocument: updateDocument, - releaseDocument: releaseDocument, - reportStats: reportStats - }; - } - ts.createDocumentRegistry = createDocumentRegistry; - function preProcessFile(sourceText, readImportFiles) { - if (readImportFiles === void 0) { readImportFiles = true; } - var referencedFiles = []; - var importedFiles = []; - var ambientExternalModules; - var isNoDefaultLib = false; - function processTripleSlashDirectives() { - var commentRanges = ts.getLeadingCommentRanges(sourceText, 0); - ts.forEach(commentRanges, function (commentRange) { - var comment = sourceText.substring(commentRange.pos, commentRange.end); - var referencePathMatchResult = ts.getFileReferenceFromReferencePath(comment, commentRange); - if (referencePathMatchResult) { - isNoDefaultLib = referencePathMatchResult.isNoDefaultLib; - var fileReference = referencePathMatchResult.fileReference; - if (fileReference) { - referencedFiles.push(fileReference); - } - } - }); - } - function recordAmbientExternalModule() { - if (!ambientExternalModules) { - ambientExternalModules = []; - } - ambientExternalModules.push(scanner.getTokenValue()); - } - function recordModuleName() { - var importPath = scanner.getTokenValue(); - var pos = scanner.getTokenPos(); - importedFiles.push({ - fileName: importPath, - pos: pos, - end: pos + importPath.length - }); - } - function processImport() { - scanner.setText(sourceText); - var token = scanner.scan(); - // Look for: - // import "mod"; - // import d from "mod" - // import {a as A } from "mod"; - // import * as NS from "mod" - // import d, {a, b as B} from "mod" - // import i = require("mod"); - // - // export * from "mod" - // export {a as b} from "mod" - // export import i = require("mod") - while (token !== 1 /* EndOfFileToken */) { - if (token === 122 /* DeclareKeyword */) { - // declare module "mod" - token = scanner.scan(); - if (token === 125 /* ModuleKeyword */) { - token = scanner.scan(); - if (token === 9 /* StringLiteral */) { - recordAmbientExternalModule(); - continue; - } - } - } - else if (token === 89 /* ImportKeyword */) { - token = scanner.scan(); - if (token === 9 /* StringLiteral */) { - // import "mod"; - recordModuleName(); - continue; - } - else { - if (token === 69 /* Identifier */ || ts.isKeyword(token)) { - token = scanner.scan(); - if (token === 133 /* FromKeyword */) { - token = scanner.scan(); - if (token === 9 /* StringLiteral */) { - // import d from "mod"; - recordModuleName(); - continue; - } - } - else if (token === 56 /* EqualsToken */) { - token = scanner.scan(); - if (token === 127 /* RequireKeyword */) { - token = scanner.scan(); - if (token === 17 /* OpenParenToken */) { - token = scanner.scan(); - if (token === 9 /* StringLiteral */) { - // import i = require("mod"); - recordModuleName(); - continue; - } - } - } - } - else if (token === 24 /* CommaToken */) { - // consume comma and keep going - token = scanner.scan(); - } - else { - // unknown syntax - continue; - } - } - if (token === 15 /* OpenBraceToken */) { - token = scanner.scan(); - // consume "{ a as B, c, d as D}" clauses - while (token !== 16 /* CloseBraceToken */) { - token = scanner.scan(); - } - if (token === 16 /* CloseBraceToken */) { - token = scanner.scan(); - if (token === 133 /* FromKeyword */) { - token = scanner.scan(); - if (token === 9 /* StringLiteral */) { - // import {a as A} from "mod"; - // import d, {a, b as B} from "mod" - recordModuleName(); - } - } - } - } - else if (token === 37 /* AsteriskToken */) { - token = scanner.scan(); - if (token === 116 /* AsKeyword */) { - token = scanner.scan(); - if (token === 69 /* Identifier */ || ts.isKeyword(token)) { - token = scanner.scan(); - if (token === 133 /* FromKeyword */) { - token = scanner.scan(); - if (token === 9 /* StringLiteral */) { - // import * as NS from "mod" - // import d, * as NS from "mod" - recordModuleName(); - } - } - } - } - } - } - } - else if (token === 82 /* ExportKeyword */) { - token = scanner.scan(); - if (token === 15 /* OpenBraceToken */) { - token = scanner.scan(); - // consume "{ a as B, c, d as D}" clauses - while (token !== 16 /* CloseBraceToken */) { - token = scanner.scan(); - } - if (token === 16 /* CloseBraceToken */) { - token = scanner.scan(); - if (token === 133 /* FromKeyword */) { - token = scanner.scan(); - if (token === 9 /* StringLiteral */) { - // export {a as A} from "mod"; - // export {a, b as B} from "mod" - recordModuleName(); - } - } - } - } - else if (token === 37 /* AsteriskToken */) { - token = scanner.scan(); - if (token === 133 /* FromKeyword */) { - token = scanner.scan(); - if (token === 9 /* StringLiteral */) { - // export * from "mod" - recordModuleName(); - } - } - } - else if (token === 89 /* ImportKeyword */) { - token = scanner.scan(); - if (token === 69 /* Identifier */ || ts.isKeyword(token)) { - token = scanner.scan(); - if (token === 56 /* EqualsToken */) { - token = scanner.scan(); - if (token === 127 /* RequireKeyword */) { - token = scanner.scan(); - if (token === 17 /* OpenParenToken */) { - token = scanner.scan(); - if (token === 9 /* StringLiteral */) { - // export import i = require("mod"); - recordModuleName(); - } - } - } - } - } - } - } - token = scanner.scan(); - } - scanner.setText(undefined); - } - if (readImportFiles) { - processImport(); - } - processTripleSlashDirectives(); - return { referencedFiles: referencedFiles, importedFiles: importedFiles, isLibFile: isNoDefaultLib, ambientExternalModules: ambientExternalModules }; - } - ts.preProcessFile = preProcessFile; - /// Helpers - function getTargetLabel(referenceNode, labelName) { - while (referenceNode) { - if (referenceNode.kind === 207 /* LabeledStatement */ && referenceNode.label.text === labelName) { - return referenceNode.label; - } - referenceNode = referenceNode.parent; - } - return undefined; - } - function isJumpStatementTarget(node) { - return node.kind === 69 /* Identifier */ && - (node.parent.kind === 203 /* BreakStatement */ || node.parent.kind === 202 /* ContinueStatement */) && - node.parent.label === node; - } - function isLabelOfLabeledStatement(node) { - return node.kind === 69 /* Identifier */ && - node.parent.kind === 207 /* LabeledStatement */ && - node.parent.label === node; - } - /** - * Whether or not a 'node' is preceded by a label of the given string. - * Note: 'node' cannot be a SourceFile. - */ - function isLabeledBy(node, labelName) { - for (var owner = node.parent; owner.kind === 207 /* LabeledStatement */; owner = owner.parent) { - if (owner.label.text === labelName) { - return true; - } - } - return false; - } - function isLabelName(node) { - return isLabelOfLabeledStatement(node) || isJumpStatementTarget(node); - } - function isRightSideOfQualifiedName(node) { - return node.parent.kind === 135 /* QualifiedName */ && node.parent.right === node; - } - function isRightSideOfPropertyAccess(node) { - return node && node.parent && node.parent.kind === 166 /* PropertyAccessExpression */ && node.parent.name === node; - } - function isCallExpressionTarget(node) { - if (isRightSideOfPropertyAccess(node)) { - node = node.parent; - } - return node && node.parent && node.parent.kind === 168 /* CallExpression */ && node.parent.expression === node; - } - function isNewExpressionTarget(node) { - if (isRightSideOfPropertyAccess(node)) { - node = node.parent; - } - return node && node.parent && node.parent.kind === 169 /* NewExpression */ && node.parent.expression === node; - } - function isNameOfModuleDeclaration(node) { - return node.parent.kind === 218 /* ModuleDeclaration */ && node.parent.name === node; - } - function isNameOfFunctionDeclaration(node) { - return node.kind === 69 /* Identifier */ && - ts.isFunctionLike(node.parent) && node.parent.name === node; - } - /** Returns true if node is a name of an object literal property, e.g. "a" in x = { "a": 1 } */ - function isNameOfPropertyAssignment(node) { - return (node.kind === 69 /* Identifier */ || node.kind === 9 /* StringLiteral */ || node.kind === 8 /* NumericLiteral */) && - (node.parent.kind === 245 /* PropertyAssignment */ || node.parent.kind === 246 /* ShorthandPropertyAssignment */) && node.parent.name === node; - } - function isLiteralNameOfPropertyDeclarationOrIndexAccess(node) { - if (node.kind === 9 /* StringLiteral */ || node.kind === 8 /* NumericLiteral */) { - switch (node.parent.kind) { - case 141 /* PropertyDeclaration */: - case 140 /* PropertySignature */: - case 245 /* PropertyAssignment */: - case 247 /* EnumMember */: - case 143 /* MethodDeclaration */: - case 142 /* MethodSignature */: - case 145 /* GetAccessor */: - case 146 /* SetAccessor */: - case 218 /* ModuleDeclaration */: - return node.parent.name === node; - case 167 /* ElementAccessExpression */: - return node.parent.argumentExpression === node; - } - } - return false; - } - function isNameOfExternalModuleImportOrDeclaration(node) { - if (node.kind === 9 /* StringLiteral */) { - return isNameOfModuleDeclaration(node) || - (ts.isExternalModuleImportEqualsDeclaration(node.parent.parent) && ts.getExternalModuleImportEqualsDeclarationExpression(node.parent.parent) === node); - } - return false; - } - /** Returns true if the position is within a comment */ - function isInsideComment(sourceFile, token, position) { - // The position has to be: 1. in the leading trivia (before token.getStart()), and 2. within a comment - return position <= token.getStart(sourceFile) && - (isInsideCommentRange(ts.getTrailingCommentRanges(sourceFile.text, token.getFullStart())) || - isInsideCommentRange(ts.getLeadingCommentRanges(sourceFile.text, token.getFullStart()))); - function isInsideCommentRange(comments) { - return ts.forEach(comments, function (comment) { - // either we are 1. completely inside the comment, or 2. at the end of the comment - if (comment.pos < position && position < comment.end) { - return true; - } - else if (position === comment.end) { - var text = sourceFile.text; - var width = comment.end - comment.pos; - // is single line comment or just /* - if (width <= 2 || text.charCodeAt(comment.pos + 1) === 47 /* slash */) { - return true; - } - else { - // is unterminated multi-line comment - return !(text.charCodeAt(comment.end - 1) === 47 /* slash */ && - text.charCodeAt(comment.end - 2) === 42 /* asterisk */); - } - } - return false; - }); - } - } - var SemanticMeaning; - (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"; - })(SemanticMeaning || (SemanticMeaning = {})); - var BreakContinueSearchType; - (function (BreakContinueSearchType) { - BreakContinueSearchType[BreakContinueSearchType["None"] = 0] = "None"; - BreakContinueSearchType[BreakContinueSearchType["Unlabeled"] = 1] = "Unlabeled"; - BreakContinueSearchType[BreakContinueSearchType["Labeled"] = 2] = "Labeled"; - BreakContinueSearchType[BreakContinueSearchType["All"] = 3] = "All"; - })(BreakContinueSearchType || (BreakContinueSearchType = {})); - // A cache of completion entries for keywords, these do not change between sessions - var keywordCompletions = []; - for (var i = 70 /* FirstKeyword */; i <= 134 /* LastKeyword */; i++) { - keywordCompletions.push({ - name: ts.tokenToString(i), - kind: ScriptElementKind.keyword, - kindModifiers: ScriptElementKindModifier.none, - sortText: "0" - }); - } - /* @internal */ function getContainerNode(node) { - while (true) { - node = node.parent; - if (!node) { - return undefined; - } - switch (node.kind) { - case 248 /* SourceFile */: - case 143 /* MethodDeclaration */: - case 142 /* MethodSignature */: - case 213 /* FunctionDeclaration */: - case 173 /* FunctionExpression */: - case 145 /* GetAccessor */: - case 146 /* SetAccessor */: - case 214 /* ClassDeclaration */: - case 215 /* InterfaceDeclaration */: - case 217 /* EnumDeclaration */: - case 218 /* ModuleDeclaration */: - return node; - } - } - } - ts.getContainerNode = getContainerNode; - /* @internal */ function getNodeKind(node) { - switch (node.kind) { - case 218 /* ModuleDeclaration */: return ScriptElementKind.moduleElement; - case 214 /* ClassDeclaration */: return ScriptElementKind.classElement; - case 215 /* InterfaceDeclaration */: return ScriptElementKind.interfaceElement; - case 216 /* TypeAliasDeclaration */: return ScriptElementKind.typeElement; - case 217 /* EnumDeclaration */: return ScriptElementKind.enumElement; - case 211 /* VariableDeclaration */: - return ts.isConst(node) - ? ScriptElementKind.constElement - : ts.isLet(node) - ? ScriptElementKind.letElement - : ScriptElementKind.variableElement; - case 213 /* FunctionDeclaration */: return ScriptElementKind.functionElement; - case 145 /* GetAccessor */: return ScriptElementKind.memberGetAccessorElement; - case 146 /* SetAccessor */: return ScriptElementKind.memberSetAccessorElement; - case 143 /* MethodDeclaration */: - case 142 /* MethodSignature */: - return ScriptElementKind.memberFunctionElement; - case 141 /* PropertyDeclaration */: - case 140 /* PropertySignature */: - return ScriptElementKind.memberVariableElement; - case 149 /* IndexSignature */: return ScriptElementKind.indexSignatureElement; - case 148 /* ConstructSignature */: return ScriptElementKind.constructSignatureElement; - case 147 /* CallSignature */: return ScriptElementKind.callSignatureElement; - case 144 /* Constructor */: return ScriptElementKind.constructorImplementationElement; - case 137 /* TypeParameter */: return ScriptElementKind.typeParameterElement; - case 247 /* EnumMember */: return ScriptElementKind.variableElement; - case 138 /* Parameter */: return (node.flags & 112 /* AccessibilityModifier */) ? ScriptElementKind.memberVariableElement : ScriptElementKind.parameterElement; - case 221 /* ImportEqualsDeclaration */: - case 226 /* ImportSpecifier */: - case 223 /* ImportClause */: - case 230 /* ExportSpecifier */: - case 224 /* NamespaceImport */: - return ScriptElementKind.alias; - } - return ScriptElementKind.unknown; - } - ts.getNodeKind = getNodeKind; - var CancellationTokenObject = (function () { - function CancellationTokenObject(cancellationToken) { - this.cancellationToken = cancellationToken; - } - CancellationTokenObject.prototype.isCancellationRequested = function () { - return this.cancellationToken && this.cancellationToken.isCancellationRequested(); - }; - CancellationTokenObject.prototype.throwIfCancellationRequested = function () { - if (this.isCancellationRequested()) { - throw new ts.OperationCanceledException(); - } - }; - return CancellationTokenObject; - })(); - function createLanguageService(host, documentRegistry) { - if (documentRegistry === void 0) { documentRegistry = createDocumentRegistry(); } - var syntaxTreeCache = new SyntaxTreeCache(host); - var ruleProvider; - var program; - var lastProjectVersion; - var useCaseSensitivefileNames = false; - var cancellationToken = new CancellationTokenObject(host.getCancellationToken && host.getCancellationToken()); - // Check if the localized messages json is set, otherwise query the host for it - if (!ts.localizedDiagnosticMessages && host.getLocalizedDiagnosticMessages) { - ts.localizedDiagnosticMessages = host.getLocalizedDiagnosticMessages(); - } - function log(message) { - if (host.log) { - host.log(message); - } - } - var getCanonicalFileName = createGetCanonicalFileName(useCaseSensitivefileNames); - function getValidSourceFile(fileName) { - fileName = ts.normalizeSlashes(fileName); - var sourceFile = program.getSourceFile(getCanonicalFileName(fileName)); - if (!sourceFile) { - throw new Error("Could not find file: '" + fileName + "'."); - } - return sourceFile; - } - function getRuleProvider(options) { - // Ensure rules are initialized and up to date wrt to formatting options - if (!ruleProvider) { - ruleProvider = new ts.formatting.RulesProvider(); - } - ruleProvider.ensureUpToDate(options); - return ruleProvider; - } - function synchronizeHostData() { - // perform fast check if host supports it - if (host.getProjectVersion) { - var hostProjectVersion = host.getProjectVersion(); - if (hostProjectVersion) { - if (lastProjectVersion === hostProjectVersion) { - return; - } - lastProjectVersion = hostProjectVersion; - } - } - // 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 - if (programUpToDate()) { - return; - } - // IMPORTANT - It is critical from this moment onward that we do not check - // cancellation tokens. We are about to mutate source files from a previous program - // instance. If we cancel midway through, we may end up in an inconsistent state where - // the program points to old source files that have been invalidated because of - // incremental parsing. - var oldSettings = program && program.getCompilerOptions(); - var newSettings = hostCache.compilationSettings(); - var changesInCompilationSettingsAffectSyntax = oldSettings && - (oldSettings.target !== newSettings.target || - oldSettings.module !== newSettings.module || - oldSettings.noResolve !== newSettings.noResolve || - oldSettings.jsx !== newSettings.jsx); - // Now create a new compiler - var compilerHost = { - getSourceFile: getOrCreateSourceFile, - getCancellationToken: function () { return cancellationToken; }, - getCanonicalFileName: getCanonicalFileName, - useCaseSensitiveFileNames: function () { return useCaseSensitivefileNames; }, - getNewLine: function () { return ts.getNewLineOrDefaultFromHost(host); }, - getDefaultLibFileName: function (options) { return host.getDefaultLibFileName(options); }, - writeFile: function (fileName, data, writeByteOrderMark) { }, - getCurrentDirectory: function () { return host.getCurrentDirectory(); }, - fileExists: function (fileName) { - // stub missing host functionality - ts.Debug.assert(!host.resolveModuleNames); - return hostCache.getOrCreateEntry(fileName) !== undefined; - }, - readFile: function (fileName) { - // stub missing host functionality - var entry = hostCache.getOrCreateEntry(fileName); - return entry && entry.scriptSnapshot.getText(0, entry.scriptSnapshot.getLength()); - } - }; - if (host.resolveModuleNames) { - compilerHost.resolveModuleNames = function (moduleNames, containingFile) { return host.resolveModuleNames(moduleNames, containingFile); }; - } - var newProgram = ts.createProgram(hostCache.getRootFileNames(), newSettings, compilerHost, program); - // Release any files we have acquired in the old program but are - // not part of the new program. - if (program) { - var oldSourceFiles = program.getSourceFiles(); - for (var _i = 0; _i < oldSourceFiles.length; _i++) { - var oldSourceFile = oldSourceFiles[_i]; - var fileName = oldSourceFile.fileName; - if (!newProgram.getSourceFile(fileName) || changesInCompilationSettingsAffectSyntax) { - documentRegistry.releaseDocument(fileName, oldSettings); - } - } - } - // hostCache is captured in the closure for 'getOrCreateSourceFile' but it should not be used past this point. - // It needs to be cleared to allow all collected snapshots to be released - hostCache = undefined; - program = newProgram; - // Make sure all the nodes in the program are both bound, and have their parent - // pointers set property. - program.getTypeChecker(); - return; - function getOrCreateSourceFile(fileName) { - ts.Debug.assert(hostCache !== undefined); - // The program is asking for this file, check first if the host can locate it. - // If the host can not locate the file, then it does not exist. return undefined - // to the program to allow reporting of errors for missing files. - var hostFileInformation = hostCache.getOrCreateEntry(fileName); - if (!hostFileInformation) { - return undefined; - } - // Check if the language version has changed since we last created a program; if they are the same, - // it is safe to reuse the souceFiles; if not, then the shape of the AST can change, and the oldSourceFile - // can not be reused. we have to dump all syntax trees and create new ones. - if (!changesInCompilationSettingsAffectSyntax) { - // Check if the old program had this file already - var oldSourceFile = program && program.getSourceFile(fileName); - if (oldSourceFile) { - // We already had a source file for this file name. Go to the registry to - // ensure that we get the right up to date version of it. We need this to - // address the following 'race'. Specifically, say we have the following: - // - // LS1 - // \ - // DocumentRegistry - // / - // LS2 - // - // Each LS has a reference to file 'foo.ts' at version 1. LS2 then updates - // it's version of 'foo.ts' to version 2. This will cause LS2 and the - // DocumentRegistry to have version 2 of the document. HOwever, LS1 will - // have version 1. And *importantly* this source file will be *corrupt*. - // The act of creating version 2 of the file irrevocably damages the version - // 1 file. - // - // So, later when we call into LS1, we need to make sure that it doesn't use - // it's source file any more, and instead defers to DocumentRegistry to get - // either version 1, version 2 (or some other version) depending on what the - // host says should be used. - return documentRegistry.updateDocument(fileName, newSettings, hostFileInformation.scriptSnapshot, hostFileInformation.version); - } - } - // Could not find this file in the old program, create a new SourceFile for it. - return documentRegistry.acquireDocument(fileName, newSettings, hostFileInformation.scriptSnapshot, hostFileInformation.version); - } - function sourceFileUpToDate(sourceFile) { - return sourceFile && sourceFile.version === hostCache.getVersion(sourceFile.fileName); - } - function programUpToDate() { - // If we haven't create a program yet, then it is not up-to-date - if (!program) { - return false; - } - // If number of files in the program do not match, it is not up-to-date - var rootFileNames = hostCache.getRootFileNames(); - if (program.getSourceFiles().length !== rootFileNames.length) { - return false; - } - // If any file is not up-to-date, then the whole program is not up-to-date - for (var _i = 0; _i < rootFileNames.length; _i++) { - var fileName = rootFileNames[_i]; - if (!sourceFileUpToDate(program.getSourceFile(fileName))) { - return false; - } - } - // If the compilation settings do no match, then the program is not up-to-date - return ts.compareDataObjects(program.getCompilerOptions(), hostCache.compilationSettings()); - } - } - function getProgram() { - synchronizeHostData(); - return program; - } - function cleanupSemanticCache() { - // TODO: Should we jettison the program (or it's type checker) here? - } - function dispose() { - if (program) { - ts.forEach(program.getSourceFiles(), function (f) { - return documentRegistry.releaseDocument(f.fileName, program.getCompilerOptions()); - }); - } - } - /// Diagnostics - function getSyntacticDiagnostics(fileName) { - synchronizeHostData(); - return program.getSyntacticDiagnostics(getValidSourceFile(fileName), cancellationToken); - } - /** - * getSemanticDiagnostiscs return array of Diagnostics. If '-d' is not enabled, only report semantic errors - * If '-d' enabled, report both semantic and emitter errors - */ - function getSemanticDiagnostics(fileName) { - synchronizeHostData(); - var targetSourceFile = getValidSourceFile(fileName); - // For JavaScript files, we don't want to report the normal typescript semantic errors. - // Instead, we just report errors for using TypeScript-only constructs from within a - // JavaScript file. - if (ts.isJavaScript(fileName)) { - return getJavaScriptSemanticDiagnostics(targetSourceFile); - } - // Only perform the action per file regardless of '-out' flag as LanguageServiceHost is expected to call this function per file. - // Therefore only get diagnostics for given file. - var semanticDiagnostics = program.getSemanticDiagnostics(targetSourceFile, cancellationToken); - if (!program.getCompilerOptions().declaration) { - return semanticDiagnostics; - } - // If '-d' is enabled, check for emitter error. One example of emitter error is export class implements non-export interface - var declarationDiagnostics = program.getDeclarationDiagnostics(targetSourceFile, cancellationToken); - return ts.concatenate(semanticDiagnostics, declarationDiagnostics); - } - function getJavaScriptSemanticDiagnostics(sourceFile) { - var diagnostics = []; - walk(sourceFile); - return diagnostics; - function walk(node) { - if (!node) { - return false; - } - switch (node.kind) { - case 221 /* ImportEqualsDeclaration */: - diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.import_can_only_be_used_in_a_ts_file)); - return true; - case 227 /* ExportAssignment */: - diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.export_can_only_be_used_in_a_ts_file)); - return true; - case 214 /* ClassDeclaration */: - var classDeclaration = node; - if (checkModifiers(classDeclaration.modifiers) || - checkTypeParameters(classDeclaration.typeParameters)) { - return true; - } - break; - case 243 /* HeritageClause */: - var heritageClause = node; - if (heritageClause.token === 106 /* ImplementsKeyword */) { - diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.implements_clauses_can_only_be_used_in_a_ts_file)); - return true; - } - break; - case 215 /* InterfaceDeclaration */: - diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.interface_declarations_can_only_be_used_in_a_ts_file)); - return true; - case 218 /* ModuleDeclaration */: - diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.module_declarations_can_only_be_used_in_a_ts_file)); - return true; - case 216 /* TypeAliasDeclaration */: - diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.type_aliases_can_only_be_used_in_a_ts_file)); - return true; - case 143 /* MethodDeclaration */: - case 142 /* MethodSignature */: - case 144 /* Constructor */: - case 145 /* GetAccessor */: - case 146 /* SetAccessor */: - case 173 /* FunctionExpression */: - case 213 /* FunctionDeclaration */: - case 174 /* ArrowFunction */: - case 213 /* FunctionDeclaration */: - var functionDeclaration = node; - if (checkModifiers(functionDeclaration.modifiers) || - checkTypeParameters(functionDeclaration.typeParameters) || - checkTypeAnnotation(functionDeclaration.type)) { - return true; - } - break; - case 193 /* VariableStatement */: - var variableStatement = node; - if (checkModifiers(variableStatement.modifiers)) { - return true; - } - break; - case 211 /* VariableDeclaration */: - var variableDeclaration = node; - if (checkTypeAnnotation(variableDeclaration.type)) { - return true; - } - break; - case 168 /* CallExpression */: - case 169 /* NewExpression */: - var expression = node; - if (expression.typeArguments && expression.typeArguments.length > 0) { - var start = expression.typeArguments.pos; - diagnostics.push(ts.createFileDiagnostic(sourceFile, start, expression.typeArguments.end - start, ts.Diagnostics.type_arguments_can_only_be_used_in_a_ts_file)); - return true; - } - break; - case 138 /* Parameter */: - var parameter = node; - if (parameter.modifiers) { - var start = parameter.modifiers.pos; - diagnostics.push(ts.createFileDiagnostic(sourceFile, start, parameter.modifiers.end - start, ts.Diagnostics.parameter_modifiers_can_only_be_used_in_a_ts_file)); - return true; - } - if (parameter.questionToken) { - diagnostics.push(ts.createDiagnosticForNode(parameter.questionToken, ts.Diagnostics._0_can_only_be_used_in_a_ts_file, '?')); - return true; - } - if (parameter.type) { - diagnostics.push(ts.createDiagnosticForNode(parameter.type, ts.Diagnostics.types_can_only_be_used_in_a_ts_file)); - return true; - } - break; - case 141 /* PropertyDeclaration */: - diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.property_declarations_can_only_be_used_in_a_ts_file)); - return true; - case 217 /* EnumDeclaration */: - diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.enum_declarations_can_only_be_used_in_a_ts_file)); - return true; - case 171 /* TypeAssertionExpression */: - var typeAssertionExpression = node; - diagnostics.push(ts.createDiagnosticForNode(typeAssertionExpression.type, ts.Diagnostics.type_assertion_expressions_can_only_be_used_in_a_ts_file)); - return true; - case 139 /* Decorator */: - diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.decorators_can_only_be_used_in_a_ts_file)); - return true; - } - return ts.forEachChild(node, walk); - } - function checkTypeParameters(typeParameters) { - if (typeParameters) { - var start = typeParameters.pos; - diagnostics.push(ts.createFileDiagnostic(sourceFile, start, typeParameters.end - start, ts.Diagnostics.type_parameter_declarations_can_only_be_used_in_a_ts_file)); - return true; - } - return false; - } - function checkTypeAnnotation(type) { - if (type) { - diagnostics.push(ts.createDiagnosticForNode(type, ts.Diagnostics.types_can_only_be_used_in_a_ts_file)); - return true; - } - return false; - } - function checkModifiers(modifiers) { - if (modifiers) { - for (var _i = 0; _i < modifiers.length; _i++) { - var modifier = modifiers[_i]; - switch (modifier.kind) { - case 112 /* PublicKeyword */: - case 110 /* PrivateKeyword */: - case 111 /* ProtectedKeyword */: - case 122 /* DeclareKeyword */: - diagnostics.push(ts.createDiagnosticForNode(modifier, ts.Diagnostics._0_can_only_be_used_in_a_ts_file, ts.tokenToString(modifier.kind))); - return true; - // These are all legal modifiers. - case 113 /* StaticKeyword */: - case 82 /* ExportKeyword */: - case 74 /* ConstKeyword */: - case 77 /* DefaultKeyword */: - case 115 /* AbstractKeyword */: - } - } - } - return false; - } - } - function getCompilerOptionsDiagnostics() { - synchronizeHostData(); - return program.getOptionsDiagnostics(cancellationToken).concat(program.getGlobalDiagnostics(cancellationToken)); - } - /** - * Get the name to be display in completion from a given symbol. - * - * @return undefined if the name is of external module otherwise a name with striped of any quote - */ - function getCompletionEntryDisplayNameForSymbol(symbol, target, performCharacterChecks, location) { - var displayName = ts.getDeclaredName(program.getTypeChecker(), symbol, location); - if (displayName) { - var firstCharCode = displayName.charCodeAt(0); - // First check of the displayName is not external module; if it is an external module, it is not valid entry - if ((symbol.flags & 1536 /* Namespace */) && (firstCharCode === 39 /* singleQuote */ || firstCharCode === 34 /* doubleQuote */)) { - // If the symbol is external module, don't show it in the completion list - // (i.e declare module "http" { let x; } | // <= request completion here, "http" should not be there) - return undefined; - } - } - return getCompletionEntryDisplayName(displayName, target, performCharacterChecks); - } - /** - * Get a displayName from a given for completion list, performing any necessary quotes stripping - * and checking whether the name is valid identifier name. - */ - function getCompletionEntryDisplayName(name, target, performCharacterChecks) { - if (!name) { - return undefined; - } - name = ts.stripQuotes(name); - if (!name) { - return undefined; - } - // If the user entered name for the symbol was quoted, removing the quotes is not enough, as the name could be an - // invalid identifier name. We need to check if whatever was inside the quotes is actually a valid identifier name. - // e.g "b a" is valid quoted name but when we strip off the quotes, it is invalid. - // We, thus, need to check if whatever was inside the quotes is actually a valid identifier name. - if (performCharacterChecks) { - if (!ts.isIdentifierStart(name.charCodeAt(0), target)) { - return undefined; - } - for (var i = 1, n = name.length; i < n; i++) { - if (!ts.isIdentifierPart(name.charCodeAt(i), target)) { - return undefined; - } - } - } - return name; - } - function getCompletionData(fileName, position) { - var typeChecker = program.getTypeChecker(); - var syntacticStart = new Date().getTime(); - var sourceFile = getValidSourceFile(fileName); - var isJavaScriptFile = ts.isJavaScript(fileName); - var isJsDocTagName = false; - var start = new Date().getTime(); - var currentToken = ts.getTokenAtPosition(sourceFile, position); - log("getCompletionData: Get current token: " + (new Date().getTime() - start)); - start = new Date().getTime(); - // Completion not allowed inside comments, bail out if this is the case - var insideComment = isInsideComment(sourceFile, currentToken, position); - log("getCompletionData: Is inside comment: " + (new Date().getTime() - start)); - if (insideComment) { - // The current position is next to the '@' sign, when no tag name being provided yet. - // Provide a full list of tag names - if (ts.hasDocComment(sourceFile, position) && sourceFile.text.charCodeAt(position - 1) === 64 /* at */) { - isJsDocTagName = true; - } - // Completion should work inside certain JsDoc tags. For example: - // /** @type {number | string} */ - // Completion should work in the brackets - var insideJsDocTagExpression = false; - var tag = ts.getJsDocTagAtPosition(sourceFile, position); - if (tag) { - if (tag.tagName.pos <= position && position <= tag.tagName.end) { - isJsDocTagName = true; - } - switch (tag.kind) { - case 269 /* JSDocTypeTag */: - case 267 /* JSDocParameterTag */: - case 268 /* JSDocReturnTag */: - var tagWithExpression = tag; - if (tagWithExpression.typeExpression) { - insideJsDocTagExpression = tagWithExpression.typeExpression.pos < position && position < tagWithExpression.typeExpression.end; - } - break; - } - } - if (isJsDocTagName) { - return { symbols: undefined, 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 - // comment or the plain text part of a jsDoc comment, so no completion should be available - log("Returning an empty list because completion was inside a regular comment or plain text part of a JsDoc comment."); - return undefined; - } - } - start = new Date().getTime(); - var previousToken = ts.findPrecedingToken(position, sourceFile); - log("getCompletionData: Get previous token 1: " + (new Date().getTime() - start)); - // The decision to provide completion depends on the contextToken, which is determined through the previousToken. - // Note: 'previousToken' (and thus 'contextToken') can be undefined if we are the beginning of the file - var contextToken = previousToken; - // Check if the caret is at the end of an identifier; this is a partial identifier that we want to complete: e.g. a.toS| - // Skip this partial identifier and adjust the contextToken to the token that precedes it. - if (contextToken && position <= contextToken.end && ts.isWord(contextToken.kind)) { - var start_4 = new Date().getTime(); - contextToken = ts.findPrecedingToken(contextToken.getFullStart(), sourceFile); - log("getCompletionData: Get previous token 2: " + (new Date().getTime() - start_4)); - } - // Find the node where completion is requested on. - // Also determine whether we are trying to complete with members of that node - // or attributes of a JSX tag. - var node = currentToken; - var isRightOfDot = false; - var isRightOfOpenTag = false; - var isStartingCloseTag = false; - var location = ts.getTouchingPropertyName(sourceFile, position); - if (contextToken) { - // Bail out if this is a known invalid completion location - if (isCompletionListBlocker(contextToken)) { - log("Returning an empty list because completion was requested in an invalid position."); - return undefined; - } - var parent_9 = contextToken.parent, kind = contextToken.kind; - if (kind === 21 /* DotToken */) { - if (parent_9.kind === 166 /* PropertyAccessExpression */) { - node = contextToken.parent.expression; - isRightOfDot = true; - } - else if (parent_9.kind === 135 /* QualifiedName */) { - node = contextToken.parent.left; - isRightOfDot = true; - } - else { - // There is nothing that precedes the dot, so this likely just a stray character - // or leading into a '...' token. Just bail out instead. - return undefined; - } - } - else if (sourceFile.languageVariant === 1 /* JSX */) { - if (kind === 25 /* LessThanToken */) { - isRightOfOpenTag = true; - location = contextToken; - } - else if (kind === 39 /* SlashToken */ && contextToken.parent.kind === 237 /* JsxClosingElement */) { - isStartingCloseTag = true; - } - } - } - var semanticStart = new Date().getTime(); - var isMemberCompletion; - var isNewIdentifierLocation; - var symbols = []; - if (isRightOfDot) { - getTypeScriptMemberSymbols(); - } - else if (isRightOfOpenTag) { - var tagSymbols = typeChecker.getJsxIntrinsicTagNames(); - if (tryGetGlobalSymbols()) { - symbols = tagSymbols.concat(symbols.filter(function (s) { return !!(s.flags & 107455 /* Value */); })); - } - else { - symbols = tagSymbols; - } - isMemberCompletion = true; - isNewIdentifierLocation = false; - } - else if (isStartingCloseTag) { - var tagName = contextToken.parent.parent.openingElement.tagName; - symbols = [typeChecker.getSymbolAtLocation(tagName)]; - isMemberCompletion = true; - isNewIdentifierLocation = false; - } - else { - // For JavaScript or TypeScript, if we're not after a dot, then just try to get the - // global symbols in scope. These results should be valid for either language as - // the set of symbols that can be referenced from this location. - if (!tryGetGlobalSymbols()) { - return undefined; - } - } - log("getCompletionData: Semantic work: " + (new Date().getTime() - semanticStart)); - return { symbols: symbols, isMemberCompletion: isMemberCompletion, isNewIdentifierLocation: isNewIdentifierLocation, location: location, isRightOfDot: (isRightOfDot || isRightOfOpenTag), isJsDocTagName: isJsDocTagName }; - function getTypeScriptMemberSymbols() { - // Right of dot member completion list - isMemberCompletion = true; - isNewIdentifierLocation = false; - if (node.kind === 69 /* Identifier */ || node.kind === 135 /* QualifiedName */ || node.kind === 166 /* PropertyAccessExpression */) { - var symbol = typeChecker.getSymbolAtLocation(node); - // This is an alias, follow what it aliases - if (symbol && symbol.flags & 8388608 /* Alias */) { - symbol = typeChecker.getAliasedSymbol(symbol); - } - if (symbol && symbol.flags & 1952 /* HasExports */) { - // Extract module or enum members - var exportedSymbols = typeChecker.getExportsOfModule(symbol); - ts.forEach(exportedSymbols, function (symbol) { - if (typeChecker.isValidPropertyAccess((node.parent), symbol.name)) { - symbols.push(symbol); - } - }); - } - } - var type = typeChecker.getTypeAtLocation(node); - addTypeProperties(type); - } - function addTypeProperties(type) { - if (type) { - // Filter private properties - for (var _i = 0, _a = type.getApparentProperties(); _i < _a.length; _i++) { - var symbol = _a[_i]; - if (typeChecker.isValidPropertyAccess((node.parent), symbol.name)) { - symbols.push(symbol); - } - } - if (isJavaScriptFile && type.flags & 16384 /* Union */) { - // In javascript files, for union types, we don't just get the members that - // the individual types have in common, we also include all the members that - // each individual type has. This is because we're going to add all identifiers - // anyways. So we might as well elevate the members that were at least part - // of the individual types to a higher status since we know what they are. - var unionType = type; - for (var _b = 0, _c = unionType.types; _b < _c.length; _b++) { - var elementType = _c[_b]; - addTypeProperties(elementType); - } - } - } - } - function tryGetGlobalSymbols() { - var objectLikeContainer; - var namedImportsOrExports; - var jsxContainer; - if (objectLikeContainer = tryGetObjectLikeCompletionContainer(contextToken)) { - return tryGetObjectLikeCompletionSymbols(objectLikeContainer); - } - if (namedImportsOrExports = tryGetNamedImportsOrExportsForCompletion(contextToken)) { - // cursor is in an import clause - // try to show exported member for imported module - return tryGetImportOrExportClauseCompletionSymbols(namedImportsOrExports); - } - if (jsxContainer = tryGetContainingJsxElement(contextToken)) { - var attrsType; - if ((jsxContainer.kind === 234 /* JsxSelfClosingElement */) || (jsxContainer.kind === 235 /* JsxOpeningElement */)) { - // Cursor is inside a JSX self-closing element or opening element - attrsType = typeChecker.getJsxElementAttributesType(jsxContainer); - if (attrsType) { - symbols = filterJsxAttributes(typeChecker.getPropertiesOfType(attrsType), jsxContainer.attributes); - isMemberCompletion = true; - isNewIdentifierLocation = false; - return true; - } - } - } - // Get all entities in the current scope. - isMemberCompletion = false; - isNewIdentifierLocation = isNewIdentifierDefinitionLocation(contextToken); - if (previousToken !== contextToken) { - ts.Debug.assert(!!previousToken, "Expected 'contextToken' to be defined when different from 'previousToken'."); - } - // We need to find the node that will give us an appropriate scope to begin - // aggregating completion candidates. This is achieved in 'getScopeNode' - // by finding the first node that encompasses a position, accounting for whether a node - // is "complete" to decide whether a position belongs to the node. - // - // However, at the end of an identifier, we are interested in the scope of the identifier - // itself, but fall outside of the identifier. For instance: - // - // xyz => x$ - // - // the cursor is outside of both the 'x' and the arrow function 'xyz => x', - // so 'xyz' is not returned in our results. - // - // We define 'adjustedPosition' so that we may appropriately account for - // being at the end of an identifier. The intention is that if requesting completion - // at the end of an identifier, it should be effectively equivalent to requesting completion - // anywhere inside/at the beginning of the identifier. So in the previous case, the - // 'adjustedPosition' will work as if requesting completion in the following: - // - // xyz => $x - // - // If previousToken !== contextToken, then - // - 'contextToken' was adjusted to the token prior to 'previousToken' - // because we were at the end of an identifier. - // - 'previousToken' is defined. - var adjustedPosition = previousToken !== contextToken ? - previousToken.getStart() : - position; - var scopeNode = getScopeNode(contextToken, adjustedPosition, sourceFile) || sourceFile; - /// TODO filter meaning based on the current context - var symbolMeanings = 793056 /* Type */ | 107455 /* Value */ | 1536 /* Namespace */ | 8388608 /* Alias */; - symbols = typeChecker.getSymbolsInScope(scopeNode, symbolMeanings); - return true; - } - /** - * Finds the first node that "embraces" the position, so that one may - * accurately aggregate locals from the closest containing scope. - */ - function getScopeNode(initialToken, position, sourceFile) { - var scope = initialToken; - while (scope && !ts.positionBelongsToNode(scope, position, sourceFile)) { - scope = scope.parent; - } - return scope; - } - function isCompletionListBlocker(contextToken) { - var start = new Date().getTime(); - var result = isInStringOrRegularExpressionOrTemplateLiteral(contextToken) || - isSolelyIdentifierDefinitionLocation(contextToken) || - isDotOfNumericLiteral(contextToken) || - isInJsxText(contextToken); - log("getCompletionsAtPosition: isCompletionListBlocker: " + (new Date().getTime() - start)); - return result; - } - function isInJsxText(contextToken) { - if (contextToken.kind === 236 /* JsxText */) { - return true; - } - if (contextToken.kind === 27 /* GreaterThanToken */ && contextToken.parent) { - if (contextToken.parent.kind === 235 /* JsxOpeningElement */) { - return true; - } - if (contextToken.parent.kind === 237 /* JsxClosingElement */ || contextToken.parent.kind === 234 /* JsxSelfClosingElement */) { - return contextToken.parent.parent && contextToken.parent.parent.kind === 233 /* JsxElement */; - } - } - return false; - } - function isNewIdentifierDefinitionLocation(previousToken) { - if (previousToken) { - var containingNodeKind = previousToken.parent.kind; - switch (previousToken.kind) { - case 24 /* CommaToken */: - return containingNodeKind === 168 /* CallExpression */ // func( a, | - || containingNodeKind === 144 /* Constructor */ // constructor( a, | /* public, protected, private keywords are allowed here, so show completion */ - || containingNodeKind === 169 /* NewExpression */ // new C(a, | - || containingNodeKind === 164 /* ArrayLiteralExpression */ // [a, | - || containingNodeKind === 181 /* BinaryExpression */ // let x = (a, | - || containingNodeKind === 152 /* FunctionType */; // var x: (s: string, list| - case 17 /* OpenParenToken */: - return containingNodeKind === 168 /* CallExpression */ // func( | - || containingNodeKind === 144 /* Constructor */ // constructor( | - || containingNodeKind === 169 /* NewExpression */ // new C(a| - || containingNodeKind === 172 /* ParenthesizedExpression */ // let x = (a| - || containingNodeKind === 160 /* ParenthesizedType */; // function F(pred: (a| /* this can become an arrow function, where 'a' is the argument */ - case 19 /* OpenBracketToken */: - return containingNodeKind === 164 /* ArrayLiteralExpression */ // [ | - || containingNodeKind === 149 /* IndexSignature */ // [ | : string ] - || containingNodeKind === 136 /* ComputedPropertyName */; // [ | /* this can become an index signature */ - case 125 /* ModuleKeyword */: // module | - case 126 /* NamespaceKeyword */: - return true; - case 21 /* DotToken */: - return containingNodeKind === 218 /* ModuleDeclaration */; // module A.| - case 15 /* OpenBraceToken */: - return containingNodeKind === 214 /* ClassDeclaration */; // class A{ | - case 56 /* EqualsToken */: - return containingNodeKind === 211 /* VariableDeclaration */ // let x = a| - || containingNodeKind === 181 /* BinaryExpression */; // x = a| - case 12 /* TemplateHead */: - return containingNodeKind === 183 /* TemplateExpression */; // `aa ${| - case 13 /* TemplateMiddle */: - return containingNodeKind === 190 /* TemplateSpan */; // `aa ${10} dd ${| - case 112 /* PublicKeyword */: - case 110 /* PrivateKeyword */: - case 111 /* ProtectedKeyword */: - return containingNodeKind === 141 /* PropertyDeclaration */; // class A{ public | - } - // Previous token may have been a keyword that was converted to an identifier. - switch (previousToken.getText()) { - case "public": - case "protected": - case "private": - return true; - } - } - return false; - } - function isInStringOrRegularExpressionOrTemplateLiteral(contextToken) { - if (contextToken.kind === 9 /* StringLiteral */ - || contextToken.kind === 10 /* RegularExpressionLiteral */ - || ts.isTemplateLiteralKind(contextToken.kind)) { - var start_5 = contextToken.getStart(); - var end = contextToken.getEnd(); - // To be "in" one of these literals, the position has to be: - // 1. entirely within the token text. - // 2. at the end position of an unterminated token. - // 3. at the end of a regular expression (due to trailing flags like '/foo/g'). - if (start_5 < position && position < end) { - return true; - } - if (position === end) { - return !!contextToken.isUnterminated - || contextToken.kind === 10 /* RegularExpressionLiteral */; - } - } - return false; - } - /** - * Aggregates relevant symbols for completion in object literals and object binding patterns. - * Relevant symbols are stored in the captured 'symbols' variable. - * - * @returns true if 'symbols' was successfully populated; false otherwise. - */ - function tryGetObjectLikeCompletionSymbols(objectLikeContainer) { - // We're looking up possible property names from contextual/inferred/declared type. - isMemberCompletion = true; - var typeForObject; - var existingMembers; - if (objectLikeContainer.kind === 165 /* ObjectLiteralExpression */) { - // We are completing on contextual types, but may also include properties - // other than those within the declared type. - isNewIdentifierLocation = true; - typeForObject = typeChecker.getContextualType(objectLikeContainer); - existingMembers = objectLikeContainer.properties; - } - else if (objectLikeContainer.kind === 161 /* ObjectBindingPattern */) { - // We are *only* completing on properties from the type being destructured. - isNewIdentifierLocation = false; - var rootDeclaration = ts.getRootDeclaration(objectLikeContainer.parent); - if (ts.isVariableLike(rootDeclaration)) { - // We don't want to complete using the type acquired by the shape - // of the binding pattern; we are only interested in types acquired - // through type declaration or inference. - if (rootDeclaration.initializer || rootDeclaration.type) { - typeForObject = typeChecker.getTypeAtLocation(objectLikeContainer); - existingMembers = objectLikeContainer.elements; - } - } - else { - ts.Debug.fail("Root declaration is not variable-like."); - } - } - else { - ts.Debug.fail("Expected object literal or binding pattern, got " + objectLikeContainer.kind); - } - if (!typeForObject) { - return false; - } - var typeMembers = typeChecker.getPropertiesOfType(typeForObject); - if (typeMembers && typeMembers.length > 0) { - // Add filtered items to the completion list - symbols = filterObjectMembersList(typeMembers, existingMembers); - } - return true; - } - /** - * Aggregates relevant symbols for completion in import clauses and export clauses - * whose declarations have a module specifier; for instance, symbols will be aggregated for - * - * import { | } from "moduleName"; - * export { a as foo, | } from "moduleName"; - * - * but not for - * - * export { | }; - * - * Relevant symbols are stored in the captured 'symbols' variable. - * - * @returns true if 'symbols' was successfully populated; false otherwise. - */ - function tryGetImportOrExportClauseCompletionSymbols(namedImportsOrExports) { - var declarationKind = namedImportsOrExports.kind === 225 /* NamedImports */ ? - 222 /* ImportDeclaration */ : - 228 /* ExportDeclaration */; - var importOrExportDeclaration = ts.getAncestor(namedImportsOrExports, declarationKind); - var moduleSpecifier = importOrExportDeclaration.moduleSpecifier; - if (!moduleSpecifier) { - return false; - } - isMemberCompletion = true; - isNewIdentifierLocation = false; - var exports; - var moduleSpecifierSymbol = typeChecker.getSymbolAtLocation(importOrExportDeclaration.moduleSpecifier); - if (moduleSpecifierSymbol) { - exports = typeChecker.getExportsOfModule(moduleSpecifierSymbol); - } - symbols = exports ? filterNamedImportOrExportCompletionItems(exports, namedImportsOrExports.elements) : emptyArray; - return true; - } - /** - * Returns the immediate owning object literal or binding pattern of a context token, - * on the condition that one exists and that the context implies completion should be given. - */ - function tryGetObjectLikeCompletionContainer(contextToken) { - if (contextToken) { - switch (contextToken.kind) { - case 15 /* OpenBraceToken */: // let x = { | - case 24 /* CommaToken */: - var parent_10 = contextToken.parent; - if (parent_10 && (parent_10.kind === 165 /* ObjectLiteralExpression */ || parent_10.kind === 161 /* ObjectBindingPattern */)) { - return parent_10; - } - break; - } - } - return undefined; - } - /** - * Returns the containing list of named imports or exports of a context token, - * on the condition that one exists and that the context implies completion should be given. - */ - function tryGetNamedImportsOrExportsForCompletion(contextToken) { - if (contextToken) { - switch (contextToken.kind) { - case 15 /* OpenBraceToken */: // import { | - case 24 /* CommaToken */: - switch (contextToken.parent.kind) { - case 225 /* NamedImports */: - case 229 /* NamedExports */: - return contextToken.parent; - } - } - } - return undefined; - } - function tryGetContainingJsxElement(contextToken) { - if (contextToken) { - var parent_11 = contextToken.parent; - switch (contextToken.kind) { - case 26 /* LessThanSlashToken */: - case 39 /* SlashToken */: - case 69 /* Identifier */: - case 238 /* JsxAttribute */: - case 239 /* JsxSpreadAttribute */: - if (parent_11 && (parent_11.kind === 234 /* JsxSelfClosingElement */ || parent_11.kind === 235 /* JsxOpeningElement */)) { - return parent_11; - } - else if (parent_11.kind === 238 /* JsxAttribute */) { - return parent_11.parent; - } - break; - // The context token is the closing } or " of an attribute, which means - // its parent is a JsxExpression, whose parent is a JsxAttribute, - // whose parent is a JsxOpeningLikeElement - case 9 /* StringLiteral */: - if (parent_11 && ((parent_11.kind === 238 /* JsxAttribute */) || (parent_11.kind === 239 /* JsxSpreadAttribute */))) { - return parent_11.parent; - } - break; - case 16 /* CloseBraceToken */: - if (parent_11 && - parent_11.kind === 240 /* JsxExpression */ && - parent_11.parent && - (parent_11.parent.kind === 238 /* JsxAttribute */)) { - return parent_11.parent.parent; - } - if (parent_11 && parent_11.kind === 239 /* JsxSpreadAttribute */) { - return parent_11.parent; - } - break; - } - } - return undefined; - } - function isFunction(kind) { - switch (kind) { - case 173 /* FunctionExpression */: - case 174 /* ArrowFunction */: - case 213 /* FunctionDeclaration */: - case 143 /* MethodDeclaration */: - case 142 /* MethodSignature */: - case 145 /* GetAccessor */: - case 146 /* SetAccessor */: - case 147 /* CallSignature */: - case 148 /* ConstructSignature */: - case 149 /* IndexSignature */: - return true; - } - return false; - } - /** - * @returns true if we are certain that the currently edited location must define a new location; false otherwise. - */ - function isSolelyIdentifierDefinitionLocation(contextToken) { - var containingNodeKind = contextToken.parent.kind; - switch (contextToken.kind) { - case 24 /* CommaToken */: - return containingNodeKind === 211 /* VariableDeclaration */ || - containingNodeKind === 212 /* VariableDeclarationList */ || - containingNodeKind === 193 /* VariableStatement */ || - containingNodeKind === 217 /* EnumDeclaration */ || - isFunction(containingNodeKind) || - containingNodeKind === 214 /* ClassDeclaration */ || - containingNodeKind === 186 /* ClassExpression */ || - containingNodeKind === 215 /* InterfaceDeclaration */ || - containingNodeKind === 162 /* ArrayBindingPattern */ || - containingNodeKind === 216 /* TypeAliasDeclaration */; // type Map, K, | - case 21 /* DotToken */: - return containingNodeKind === 162 /* ArrayBindingPattern */; // var [.| - case 54 /* ColonToken */: - return containingNodeKind === 163 /* BindingElement */; // var {x :html| - case 19 /* OpenBracketToken */: - return containingNodeKind === 162 /* ArrayBindingPattern */; // var [x| - case 17 /* OpenParenToken */: - return containingNodeKind === 244 /* CatchClause */ || - isFunction(containingNodeKind); - case 15 /* OpenBraceToken */: - return containingNodeKind === 217 /* EnumDeclaration */ || - containingNodeKind === 215 /* InterfaceDeclaration */ || - containingNodeKind === 155 /* TypeLiteral */; // let x : { | - case 23 /* SemicolonToken */: - return containingNodeKind === 140 /* PropertySignature */ && - contextToken.parent && contextToken.parent.parent && - (contextToken.parent.parent.kind === 215 /* InterfaceDeclaration */ || - contextToken.parent.parent.kind === 155 /* TypeLiteral */); // let x : { a; | - case 25 /* LessThanToken */: - return containingNodeKind === 214 /* ClassDeclaration */ || - containingNodeKind === 186 /* ClassExpression */ || - containingNodeKind === 215 /* InterfaceDeclaration */ || - containingNodeKind === 216 /* TypeAliasDeclaration */ || - isFunction(containingNodeKind); - case 113 /* StaticKeyword */: - return containingNodeKind === 141 /* PropertyDeclaration */; - case 22 /* DotDotDotToken */: - return containingNodeKind === 138 /* Parameter */ || - (contextToken.parent && contextToken.parent.parent && - contextToken.parent.parent.kind === 162 /* ArrayBindingPattern */); // var [...z| - case 112 /* PublicKeyword */: - case 110 /* PrivateKeyword */: - case 111 /* ProtectedKeyword */: - return containingNodeKind === 138 /* Parameter */; - case 116 /* AsKeyword */: - return containingNodeKind === 226 /* ImportSpecifier */ || - containingNodeKind === 230 /* ExportSpecifier */ || - containingNodeKind === 224 /* NamespaceImport */; - case 73 /* ClassKeyword */: - case 81 /* EnumKeyword */: - case 107 /* InterfaceKeyword */: - case 87 /* FunctionKeyword */: - case 102 /* VarKeyword */: - case 123 /* GetKeyword */: - case 129 /* SetKeyword */: - case 89 /* ImportKeyword */: - case 108 /* LetKeyword */: - case 74 /* ConstKeyword */: - case 114 /* YieldKeyword */: - case 132 /* TypeKeyword */: - return true; - } - // Previous token may have been a keyword that was converted to an identifier. - switch (contextToken.getText()) { - case "abstract": - case "async": - case "class": - case "const": - case "declare": - case "enum": - case "function": - case "interface": - case "let": - case "private": - case "protected": - case "public": - case "static": - case "var": - case "yield": - return true; - } - return false; - } - function isDotOfNumericLiteral(contextToken) { - if (contextToken.kind === 8 /* NumericLiteral */) { - var text = contextToken.getFullText(); - return text.charAt(text.length - 1) === "."; - } - return false; - } - /** - * Filters out completion suggestions for named imports or exports. - * - * @param exportsOfModule The list of symbols which a module exposes. - * @param namedImportsOrExports The list of existing import/export specifiers in the import/export clause. - * - * @returns Symbols to be suggested at an import/export clause, barring those whose named imports/exports - * do not occur at the current position and have not otherwise been typed. - */ - function filterNamedImportOrExportCompletionItems(exportsOfModule, namedImportsOrExports) { - var exisingImportsOrExports = {}; - for (var _i = 0; _i < namedImportsOrExports.length; _i++) { - var element = namedImportsOrExports[_i]; - // If this is the current item we are editing right now, do not filter it out - if (element.getStart() <= position && position <= element.getEnd()) { - continue; - } - var name_32 = element.propertyName || element.name; - exisingImportsOrExports[name_32.text] = true; - } - if (ts.isEmpty(exisingImportsOrExports)) { - return exportsOfModule; - } - return ts.filter(exportsOfModule, function (e) { return !ts.lookUp(exisingImportsOrExports, e.name); }); - } - /** - * Filters out completion suggestions for named imports or exports. - * - * @returns Symbols to be suggested in an object binding pattern or object literal expression, barring those whose declarations - * do not occur at the current position and have not otherwise been typed. - */ - function filterObjectMembersList(contextualMemberSymbols, existingMembers) { - if (!existingMembers || existingMembers.length === 0) { - return contextualMemberSymbols; - } - var existingMemberNames = {}; - for (var _i = 0; _i < existingMembers.length; _i++) { - var m = existingMembers[_i]; - // Ignore omitted expressions for missing members - if (m.kind !== 245 /* PropertyAssignment */ && - m.kind !== 246 /* ShorthandPropertyAssignment */ && - m.kind !== 163 /* BindingElement */) { - continue; - } - // If this is the current item we are editing right now, do not filter it out - if (m.getStart() <= position && position <= m.getEnd()) { - continue; - } - var existingName = void 0; - if (m.kind === 163 /* BindingElement */ && m.propertyName) { - existingName = m.propertyName.text; - } - else { - // TODO(jfreeman): Account for computed property name - // NOTE: if one only performs this step when m.name is an identifier, - // things like '__proto__' are not filtered out. - existingName = m.name.text; - } - existingMemberNames[existingName] = true; - } - return ts.filter(contextualMemberSymbols, function (m) { return !ts.lookUp(existingMemberNames, m.name); }); - } - /** - * Filters out completion suggestions from 'symbols' according to existing JSX attributes. - * - * @returns Symbols to be suggested in a JSX element, barring those whose attributes - * do not occur at the current position and have not otherwise been typed. - */ - function filterJsxAttributes(symbols, attributes) { - var seenNames = {}; - for (var _i = 0; _i < attributes.length; _i++) { - var attr = attributes[_i]; - // If this is the current item we are editing right now, do not filter it out - if (attr.getStart() <= position && position <= attr.getEnd()) { - continue; - } - if (attr.kind === 238 /* JsxAttribute */) { - seenNames[attr.name.text] = true; - } - } - return ts.filter(symbols, function (a) { return !ts.lookUp(seenNames, a.name); }); - } - } - function getCompletionsAtPosition(fileName, position) { - synchronizeHostData(); - var completionData = getCompletionData(fileName, position); - if (!completionData) { - return undefined; - } - var symbols = completionData.symbols, isMemberCompletion = completionData.isMemberCompletion, isNewIdentifierLocation = completionData.isNewIdentifierLocation, location = completionData.location, isRightOfDot = completionData.isRightOfDot, isJsDocTagName = completionData.isJsDocTagName; - var entries; - if (isJsDocTagName) { - // If the current position is a jsDoc tag name, only tag names should be provided for completion - return { isMemberCompletion: false, isNewIdentifierLocation: false, entries: getAllJsDocCompletionEntries() }; - } - if (isRightOfDot && ts.isJavaScript(fileName)) { - entries = getCompletionEntriesFromSymbols(symbols); - ts.addRange(entries, getJavaScriptCompletionEntries()); - } - else { - if (!symbols || symbols.length === 0) { - return undefined; - } - entries = getCompletionEntriesFromSymbols(symbols); - } - // Add keywords if this is not a member completion list - if (!isMemberCompletion && !isJsDocTagName) { - ts.addRange(entries, keywordCompletions); - } - return { isMemberCompletion: isMemberCompletion, isNewIdentifierLocation: isNewIdentifierLocation, entries: entries }; - function getJavaScriptCompletionEntries() { - var entries = []; - var allNames = {}; - var target = program.getCompilerOptions().target; - for (var _i = 0, _a = program.getSourceFiles(); _i < _a.length; _i++) { - var sourceFile = _a[_i]; - var nameTable = getNameTable(sourceFile); - for (var name_33 in nameTable) { - if (!allNames[name_33]) { - allNames[name_33] = name_33; - var displayName = getCompletionEntryDisplayName(name_33, target, /*performCharacterChecks:*/ true); - if (displayName) { - var entry = { - name: displayName, - kind: ScriptElementKind.warning, - kindModifiers: "", - sortText: "1" - }; - entries.push(entry); - } - } - } - } - return entries; - } - function getAllJsDocCompletionEntries() { - return jsDocCompletionEntries || (jsDocCompletionEntries = ts.map(jsDocTagNames, function (tagName) { - return { - name: tagName, - kind: ScriptElementKind.keyword, - kindModifiers: "", - sortText: "0" - }; - })); - } - function createCompletionEntry(symbol, location) { - // Try to get a valid display name for this symbol, if we could not find one, then ignore it. - // We would like to only show things that can be added after a dot, so for instance numeric properties can - // not be accessed with a dot (a.1 <- invalid) - var displayName = getCompletionEntryDisplayNameForSymbol(symbol, program.getCompilerOptions().target, /*performCharacterChecks:*/ true, location); - if (!displayName) { - return undefined; - } - // TODO(drosen): Right now we just permit *all* semantic meanings when calling - // 'getSymbolKind' which is permissible given that it is backwards compatible; but - // really we should consider passing the meaning for the node so that we don't report - // that a suggestion for a value is an interface. We COULD also just do what - // 'getSymbolModifiers' does, which is to use the first declaration. - // Use a 'sortText' of 0' so that all symbol completion entries come before any other - // entries (like JavaScript identifier entries). - return { - name: displayName, - kind: getSymbolKind(symbol, location), - kindModifiers: getSymbolModifiers(symbol), - sortText: "0" - }; - } - function getCompletionEntriesFromSymbols(symbols) { - var start = new Date().getTime(); - var entries = []; - if (symbols) { - var nameToSymbol = {}; - for (var _i = 0; _i < symbols.length; _i++) { - var symbol = symbols[_i]; - var entry = createCompletionEntry(symbol, location); - if (entry) { - var id = ts.escapeIdentifier(entry.name); - if (!ts.lookUp(nameToSymbol, id)) { - entries.push(entry); - nameToSymbol[id] = symbol; - } - } - } - } - log("getCompletionsAtPosition: getCompletionEntriesFromSymbols: " + (new Date().getTime() - start)); - return entries; - } - } - function getCompletionEntryDetails(fileName, position, entryName) { - synchronizeHostData(); - // Compute all the completion symbols again. - var completionData = getCompletionData(fileName, position); - if (completionData) { - var symbols = completionData.symbols, location_2 = completionData.location; - // Find the symbol with the matching entry name. - var target = program.getCompilerOptions().target; - // We don't need to perform character checks here because we're only comparing the - // name against 'entryName' (which is known to be good), not building a new - // completion entry. - var symbol = ts.forEach(symbols, function (s) { return getCompletionEntryDisplayNameForSymbol(s, target, /*performCharacterChecks:*/ false, location_2) === entryName ? s : undefined; }); - if (symbol) { - var _a = getSymbolDisplayPartsDocumentationAndSymbolKind(symbol, getValidSourceFile(fileName), location_2, location_2, 7 /* All */), displayParts = _a.displayParts, documentation = _a.documentation, symbolKind = _a.symbolKind; - return { - name: entryName, - kindModifiers: getSymbolModifiers(symbol), - kind: symbolKind, - displayParts: displayParts, - documentation: documentation - }; - } - } - // Didn't find a symbol with this name. See if we can find a keyword instead. - var keywordCompletion = ts.forEach(keywordCompletions, function (c) { return c.name === entryName; }); - if (keywordCompletion) { - return { - name: entryName, - kind: ScriptElementKind.keyword, - kindModifiers: ScriptElementKindModifier.none, - displayParts: [ts.displayPart(entryName, SymbolDisplayPartKind.keyword)], - documentation: undefined - }; - } - return undefined; - } - // TODO(drosen): use contextual SemanticMeaning. - function getSymbolKind(symbol, location) { - var flags = symbol.getFlags(); - if (flags & 32 /* Class */) - return ts.getDeclarationOfKind(symbol, 186 /* ClassExpression */) ? - ScriptElementKind.localClassElement : ScriptElementKind.classElement; - if (flags & 384 /* Enum */) - return ScriptElementKind.enumElement; - if (flags & 524288 /* TypeAlias */) - return ScriptElementKind.typeElement; - if (flags & 64 /* Interface */) - return ScriptElementKind.interfaceElement; - if (flags & 262144 /* TypeParameter */) - return ScriptElementKind.typeParameterElement; - var result = getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar(symbol, flags, location); - if (result === ScriptElementKind.unknown) { - if (flags & 262144 /* TypeParameter */) - return ScriptElementKind.typeParameterElement; - if (flags & 8 /* EnumMember */) - return ScriptElementKind.variableElement; - if (flags & 8388608 /* Alias */) - return ScriptElementKind.alias; - if (flags & 1536 /* Module */) - return ScriptElementKind.moduleElement; - } - return result; - } - function getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar(symbol, flags, location) { - var typeChecker = program.getTypeChecker(); - if (typeChecker.isUndefinedSymbol(symbol)) { - return ScriptElementKind.variableElement; - } - if (typeChecker.isArgumentsSymbol(symbol)) { - return ScriptElementKind.localVariableElement; - } - if (flags & 3 /* Variable */) { - if (ts.isFirstDeclarationOfSymbolParameter(symbol)) { - return ScriptElementKind.parameterElement; - } - else if (symbol.valueDeclaration && ts.isConst(symbol.valueDeclaration)) { - return ScriptElementKind.constElement; - } - else if (ts.forEach(symbol.declarations, ts.isLet)) { - return ScriptElementKind.letElement; - } - return isLocalVariableOrFunction(symbol) ? ScriptElementKind.localVariableElement : ScriptElementKind.variableElement; - } - if (flags & 16 /* Function */) - return isLocalVariableOrFunction(symbol) ? ScriptElementKind.localFunctionElement : ScriptElementKind.functionElement; - if (flags & 32768 /* GetAccessor */) - return ScriptElementKind.memberGetAccessorElement; - if (flags & 65536 /* SetAccessor */) - return ScriptElementKind.memberSetAccessorElement; - if (flags & 8192 /* Method */) - return ScriptElementKind.memberFunctionElement; - if (flags & 16384 /* Constructor */) - return ScriptElementKind.constructorImplementationElement; - if (flags & 4 /* Property */) { - if (flags & 268435456 /* SyntheticProperty */) { - // If union property is result of union of non method (property/accessors/variables), it is labeled as property - var unionPropertyKind = ts.forEach(typeChecker.getRootSymbols(symbol), function (rootSymbol) { - var rootSymbolFlags = rootSymbol.getFlags(); - if (rootSymbolFlags & (98308 /* PropertyOrAccessor */ | 3 /* Variable */)) { - return ScriptElementKind.memberVariableElement; - } - ts.Debug.assert(!!(rootSymbolFlags & 8192 /* Method */)); - }); - if (!unionPropertyKind) { - // If this was union of all methods, - //make sure it has call signatures before we can label it as method - var typeOfUnionProperty = typeChecker.getTypeOfSymbolAtLocation(symbol, location); - if (typeOfUnionProperty.getCallSignatures().length) { - return ScriptElementKind.memberFunctionElement; - } - return ScriptElementKind.memberVariableElement; - } - return unionPropertyKind; - } - return ScriptElementKind.memberVariableElement; - } - return ScriptElementKind.unknown; - } - function getSymbolModifiers(symbol) { - return symbol && symbol.declarations && symbol.declarations.length > 0 - ? ts.getNodeModifiers(symbol.declarations[0]) - : ScriptElementKindModifier.none; - } - // TODO(drosen): Currently completion entry details passes the SemanticMeaning.All instead of using semanticMeaning of location - function getSymbolDisplayPartsDocumentationAndSymbolKind(symbol, sourceFile, enclosingDeclaration, location, semanticMeaning) { - if (semanticMeaning === void 0) { semanticMeaning = getMeaningFromLocation(location); } - var typeChecker = program.getTypeChecker(); - var displayParts = []; - var documentation; - var symbolFlags = symbol.flags; - var symbolKind = getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar(symbol, symbolFlags, location); - var hasAddedSymbolInfo; - var type; - // Class at constructor site need to be shown as constructor apart from property,method, vars - if (symbolKind !== ScriptElementKind.unknown || symbolFlags & 32 /* Class */ || symbolFlags & 8388608 /* Alias */) { - // If it is accessor they are allowed only if location is at name of the accessor - if (symbolKind === ScriptElementKind.memberGetAccessorElement || symbolKind === ScriptElementKind.memberSetAccessorElement) { - symbolKind = ScriptElementKind.memberVariableElement; - } - var signature; - type = typeChecker.getTypeOfSymbolAtLocation(symbol, location); - if (type) { - if (location.parent && location.parent.kind === 166 /* PropertyAccessExpression */) { - var right = location.parent.name; - // Either the location is on the right of a property access, or on the left and the right is missing - if (right === location || (right && right.getFullWidth() === 0)) { - location = location.parent; - } - } - // try get the call/construct signature from the type if it matches - var callExpression; - if (location.kind === 168 /* CallExpression */ || location.kind === 169 /* NewExpression */) { - callExpression = location; - } - else if (isCallExpressionTarget(location) || isNewExpressionTarget(location)) { - callExpression = location.parent; - } - if (callExpression) { - var candidateSignatures = []; - signature = typeChecker.getResolvedSignature(callExpression, candidateSignatures); - if (!signature && candidateSignatures.length) { - // Use the first candidate: - signature = candidateSignatures[0]; - } - var useConstructSignatures = callExpression.kind === 169 /* NewExpression */ || callExpression.expression.kind === 95 /* 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 - // either the original signature or its target, so check for either - signature = allSignatures.length ? allSignatures[0] : undefined; - } - if (signature) { - if (useConstructSignatures && (symbolFlags & 32 /* Class */)) { - // Constructor - symbolKind = ScriptElementKind.constructorImplementationElement; - addPrefixForAnyFunctionOrVar(type.symbol, symbolKind); - } - else if (symbolFlags & 8388608 /* Alias */) { - symbolKind = ScriptElementKind.alias; - pushTypePart(symbolKind); - displayParts.push(ts.spacePart()); - if (useConstructSignatures) { - displayParts.push(ts.keywordPart(92 /* NewKeyword */)); - displayParts.push(ts.spacePart()); - } - addFullSymbolName(symbol); - } - else { - addPrefixForAnyFunctionOrVar(symbol, symbolKind); - } - switch (symbolKind) { - case ScriptElementKind.memberVariableElement: - case ScriptElementKind.variableElement: - case ScriptElementKind.constElement: - case ScriptElementKind.letElement: - case ScriptElementKind.parameterElement: - case ScriptElementKind.localVariableElement: - // If it is call or construct signature of lambda's write type name - displayParts.push(ts.punctuationPart(54 /* ColonToken */)); - displayParts.push(ts.spacePart()); - if (useConstructSignatures) { - displayParts.push(ts.keywordPart(92 /* NewKeyword */)); - displayParts.push(ts.spacePart()); - } - if (!(type.flags & 65536 /* Anonymous */)) { - ts.addRange(displayParts, ts.symbolToDisplayParts(typeChecker, type.symbol, enclosingDeclaration, /*meaning*/ undefined, 1 /* WriteTypeParametersOrArguments */)); - } - addSignatureDisplayParts(signature, allSignatures, 8 /* WriteArrowStyleSignature */); - break; - default: - // Just signature - addSignatureDisplayParts(signature, allSignatures); - } - hasAddedSymbolInfo = true; - } - } - else if ((isNameOfFunctionDeclaration(location) && !(symbol.flags & 98304 /* Accessor */)) || - (location.kind === 121 /* ConstructorKeyword */ && location.parent.kind === 144 /* Constructor */)) { - // get the signature from the declaration and write it - var functionDeclaration = location.parent; - var allSignatures = functionDeclaration.kind === 144 /* Constructor */ ? type.getConstructSignatures() : type.getCallSignatures(); - if (!typeChecker.isImplementationOfOverload(functionDeclaration)) { - signature = typeChecker.getSignatureFromDeclaration(functionDeclaration); - } - else { - signature = allSignatures[0]; - } - if (functionDeclaration.kind === 144 /* Constructor */) { - // show (constructor) Type(...) signature - symbolKind = ScriptElementKind.constructorImplementationElement; - addPrefixForAnyFunctionOrVar(type.symbol, symbolKind); - } - else { - // (function/method) symbol(..signature) - addPrefixForAnyFunctionOrVar(functionDeclaration.kind === 147 /* CallSignature */ && - !(type.symbol.flags & 2048 /* TypeLiteral */ || type.symbol.flags & 4096 /* ObjectLiteral */) ? type.symbol : symbol, symbolKind); - } - addSignatureDisplayParts(signature, allSignatures); - hasAddedSymbolInfo = true; - } - } - } - if (symbolFlags & 32 /* Class */ && !hasAddedSymbolInfo) { - if (ts.getDeclarationOfKind(symbol, 186 /* ClassExpression */)) { - // Special case for class expressions because we would like to indicate that - // the class name is local to the class body (similar to function expression) - // (local class) class - pushTypePart(ScriptElementKind.localClassElement); - } - else { - // Class declaration has name which is not local. - displayParts.push(ts.keywordPart(73 /* ClassKeyword */)); - } - displayParts.push(ts.spacePart()); - addFullSymbolName(symbol); - writeTypeParametersOfSymbol(symbol, sourceFile); - } - if ((symbolFlags & 64 /* Interface */) && (semanticMeaning & 2 /* Type */)) { - addNewLineIfDisplayPartsExist(); - displayParts.push(ts.keywordPart(107 /* InterfaceKeyword */)); - displayParts.push(ts.spacePart()); - addFullSymbolName(symbol); - writeTypeParametersOfSymbol(symbol, sourceFile); - } - if (symbolFlags & 524288 /* TypeAlias */) { - addNewLineIfDisplayPartsExist(); - displayParts.push(ts.keywordPart(132 /* TypeKeyword */)); - displayParts.push(ts.spacePart()); - addFullSymbolName(symbol); - writeTypeParametersOfSymbol(symbol, sourceFile); - displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(56 /* EqualsToken */)); - displayParts.push(ts.spacePart()); - ts.addRange(displayParts, ts.typeToDisplayParts(typeChecker, typeChecker.getDeclaredTypeOfSymbol(symbol), enclosingDeclaration)); - } - if (symbolFlags & 384 /* Enum */) { - addNewLineIfDisplayPartsExist(); - if (ts.forEach(symbol.declarations, ts.isConstEnumDeclaration)) { - displayParts.push(ts.keywordPart(74 /* ConstKeyword */)); - displayParts.push(ts.spacePart()); - } - displayParts.push(ts.keywordPart(81 /* EnumKeyword */)); - displayParts.push(ts.spacePart()); - addFullSymbolName(symbol); - } - if (symbolFlags & 1536 /* Module */) { - addNewLineIfDisplayPartsExist(); - var declaration = ts.getDeclarationOfKind(symbol, 218 /* ModuleDeclaration */); - var isNamespace = declaration && declaration.name && declaration.name.kind === 69 /* Identifier */; - displayParts.push(ts.keywordPart(isNamespace ? 126 /* NamespaceKeyword */ : 125 /* ModuleKeyword */)); - displayParts.push(ts.spacePart()); - addFullSymbolName(symbol); - } - if ((symbolFlags & 262144 /* TypeParameter */) && (semanticMeaning & 2 /* Type */)) { - addNewLineIfDisplayPartsExist(); - displayParts.push(ts.punctuationPart(17 /* OpenParenToken */)); - displayParts.push(ts.textPart("type parameter")); - displayParts.push(ts.punctuationPart(18 /* CloseParenToken */)); - displayParts.push(ts.spacePart()); - addFullSymbolName(symbol); - displayParts.push(ts.spacePart()); - displayParts.push(ts.keywordPart(90 /* InKeyword */)); - displayParts.push(ts.spacePart()); - if (symbol.parent) { - // Class/Interface type parameter - addFullSymbolName(symbol.parent, enclosingDeclaration); - writeTypeParametersOfSymbol(symbol.parent, enclosingDeclaration); - } - else { - // Method/function type parameter - var container = ts.getContainingFunction(location); - if (container) { - var signatureDeclaration = ts.getDeclarationOfKind(symbol, 137 /* TypeParameter */).parent; - var signature = typeChecker.getSignatureFromDeclaration(signatureDeclaration); - if (signatureDeclaration.kind === 148 /* ConstructSignature */) { - displayParts.push(ts.keywordPart(92 /* NewKeyword */)); - displayParts.push(ts.spacePart()); - } - else if (signatureDeclaration.kind !== 147 /* CallSignature */ && signatureDeclaration.name) { - addFullSymbolName(signatureDeclaration.symbol); - } - ts.addRange(displayParts, ts.signatureToDisplayParts(typeChecker, signature, sourceFile, 32 /* WriteTypeArgumentsOfSignature */)); - } - else { - // Type aliash type parameter - // For example - // type list = T[]; // Both T will go through same code path - var declaration = ts.getDeclarationOfKind(symbol, 137 /* TypeParameter */).parent; - displayParts.push(ts.keywordPart(132 /* TypeKeyword */)); - displayParts.push(ts.spacePart()); - addFullSymbolName(declaration.symbol); - writeTypeParametersOfSymbol(declaration.symbol, sourceFile); - } - } - } - if (symbolFlags & 8 /* EnumMember */) { - addPrefixForAnyFunctionOrVar(symbol, "enum member"); - var declaration = symbol.declarations[0]; - if (declaration.kind === 247 /* EnumMember */) { - var constantValue = typeChecker.getConstantValue(declaration); - if (constantValue !== undefined) { - displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(56 /* EqualsToken */)); - displayParts.push(ts.spacePart()); - displayParts.push(ts.displayPart(constantValue.toString(), SymbolDisplayPartKind.numericLiteral)); - } - } - } - if (symbolFlags & 8388608 /* Alias */) { - addNewLineIfDisplayPartsExist(); - displayParts.push(ts.keywordPart(89 /* ImportKeyword */)); - displayParts.push(ts.spacePart()); - addFullSymbolName(symbol); - ts.forEach(symbol.declarations, function (declaration) { - if (declaration.kind === 221 /* ImportEqualsDeclaration */) { - var importEqualsDeclaration = declaration; - if (ts.isExternalModuleImportEqualsDeclaration(importEqualsDeclaration)) { - displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(56 /* EqualsToken */)); - displayParts.push(ts.spacePart()); - displayParts.push(ts.keywordPart(127 /* RequireKeyword */)); - displayParts.push(ts.punctuationPart(17 /* OpenParenToken */)); - displayParts.push(ts.displayPart(ts.getTextOfNode(ts.getExternalModuleImportEqualsDeclarationExpression(importEqualsDeclaration)), SymbolDisplayPartKind.stringLiteral)); - displayParts.push(ts.punctuationPart(18 /* CloseParenToken */)); - } - else { - var internalAliasSymbol = typeChecker.getSymbolAtLocation(importEqualsDeclaration.moduleReference); - if (internalAliasSymbol) { - displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(56 /* EqualsToken */)); - displayParts.push(ts.spacePart()); - addFullSymbolName(internalAliasSymbol, enclosingDeclaration); - } - } - return true; - } - }); - } - if (!hasAddedSymbolInfo) { - if (symbolKind !== ScriptElementKind.unknown) { - if (type) { - addPrefixForAnyFunctionOrVar(symbol, symbolKind); - // For properties, variables and local vars: show the type - if (symbolKind === ScriptElementKind.memberVariableElement || - symbolFlags & 3 /* Variable */ || - symbolKind === ScriptElementKind.localVariableElement) { - displayParts.push(ts.punctuationPart(54 /* ColonToken */)); - displayParts.push(ts.spacePart()); - // If the type is type parameter, format it specially - if (type.symbol && type.symbol.flags & 262144 /* TypeParameter */) { - var typeParameterParts = ts.mapToDisplayParts(function (writer) { - typeChecker.getSymbolDisplayBuilder().buildTypeParameterDisplay(type, writer, enclosingDeclaration); - }); - ts.addRange(displayParts, typeParameterParts); - } - else { - ts.addRange(displayParts, ts.typeToDisplayParts(typeChecker, type, enclosingDeclaration)); - } - } - else if (symbolFlags & 16 /* Function */ || - symbolFlags & 8192 /* Method */ || - symbolFlags & 16384 /* Constructor */ || - symbolFlags & 131072 /* Signature */ || - symbolFlags & 98304 /* Accessor */ || - symbolKind === ScriptElementKind.memberFunctionElement) { - var allSignatures = type.getCallSignatures(); - addSignatureDisplayParts(allSignatures[0], allSignatures); - } - } - } - else { - symbolKind = getSymbolKind(symbol, location); - } - } - if (!documentation) { - documentation = symbol.getDocumentationComment(); - } - return { displayParts: displayParts, documentation: documentation, symbolKind: symbolKind }; - function addNewLineIfDisplayPartsExist() { - if (displayParts.length) { - displayParts.push(ts.lineBreakPart()); - } - } - function addFullSymbolName(symbol, enclosingDeclaration) { - var fullSymbolDisplayParts = ts.symbolToDisplayParts(typeChecker, symbol, enclosingDeclaration || sourceFile, /*meaning*/ undefined, 1 /* WriteTypeParametersOrArguments */ | 2 /* UseOnlyExternalAliasing */); - ts.addRange(displayParts, fullSymbolDisplayParts); - } - function addPrefixForAnyFunctionOrVar(symbol, symbolKind) { - addNewLineIfDisplayPartsExist(); - if (symbolKind) { - pushTypePart(symbolKind); - displayParts.push(ts.spacePart()); - addFullSymbolName(symbol); - } - } - function pushTypePart(symbolKind) { - switch (symbolKind) { - case ScriptElementKind.variableElement: - case ScriptElementKind.functionElement: - case ScriptElementKind.letElement: - case ScriptElementKind.constElement: - case ScriptElementKind.constructorImplementationElement: - displayParts.push(ts.textOrKeywordPart(symbolKind)); - return; - default: - displayParts.push(ts.punctuationPart(17 /* OpenParenToken */)); - displayParts.push(ts.textOrKeywordPart(symbolKind)); - displayParts.push(ts.punctuationPart(18 /* CloseParenToken */)); - return; - } - } - function addSignatureDisplayParts(signature, allSignatures, flags) { - 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.displayPart((allSignatures.length - 1).toString(), SymbolDisplayPartKind.numericLiteral)); - displayParts.push(ts.spacePart()); - displayParts.push(ts.textPart(allSignatures.length === 2 ? "overload" : "overloads")); - displayParts.push(ts.punctuationPart(18 /* CloseParenToken */)); - } - documentation = signature.getDocumentationComment(); - } - function writeTypeParametersOfSymbol(symbol, enclosingDeclaration) { - var typeParameterParts = ts.mapToDisplayParts(function (writer) { - typeChecker.getSymbolDisplayBuilder().buildTypeParameterDisplayFromSymbol(symbol, writer, enclosingDeclaration); - }); - ts.addRange(displayParts, typeParameterParts); - } - } - function getQuickInfoAtPosition(fileName, position) { - synchronizeHostData(); - var sourceFile = getValidSourceFile(fileName); - var node = ts.getTouchingPropertyName(sourceFile, position); - if (!node) { - return undefined; - } - if (isLabelName(node)) { - return undefined; - } - var typeChecker = program.getTypeChecker(); - var symbol = typeChecker.getSymbolAtLocation(node); - if (!symbol) { - // Try getting just type at this position and show - switch (node.kind) { - case 69 /* Identifier */: - case 166 /* PropertyAccessExpression */: - case 135 /* QualifiedName */: - case 97 /* ThisKeyword */: - case 95 /* SuperKeyword */: - // For the identifiers/this/super etc get the type at position - var type = typeChecker.getTypeAtLocation(node); - if (type) { - return { - kind: ScriptElementKind.unknown, - kindModifiers: ScriptElementKindModifier.none, - textSpan: ts.createTextSpan(node.getStart(), node.getWidth()), - displayParts: ts.typeToDisplayParts(typeChecker, type, getContainerNode(node)), - documentation: type.symbol ? type.symbol.getDocumentationComment() : undefined - }; - } - } - return undefined; - } - var displayPartsDocumentationsAndKind = getSymbolDisplayPartsDocumentationAndSymbolKind(symbol, sourceFile, getContainerNode(node), node); - return { - kind: displayPartsDocumentationsAndKind.symbolKind, - kindModifiers: getSymbolModifiers(symbol), - textSpan: ts.createTextSpan(node.getStart(), node.getWidth()), - displayParts: displayPartsDocumentationsAndKind.displayParts, - documentation: displayPartsDocumentationsAndKind.documentation - }; - } - function createDefinitionInfo(node, symbolKind, symbolName, containerName) { - return { - fileName: node.getSourceFile().fileName, - textSpan: ts.createTextSpanFromBounds(node.getStart(), node.getEnd()), - kind: symbolKind, - name: symbolName, - containerKind: undefined, - containerName: containerName - }; - } - function getDefinitionFromSymbol(symbol, node) { - var typeChecker = program.getTypeChecker(); - var result = []; - var declarations = symbol.getDeclarations(); - var symbolName = typeChecker.symbolToString(symbol); // Do not get scoped name, just the name of the symbol - var symbolKind = getSymbolKind(symbol, node); - var containerSymbol = symbol.parent; - var containerName = containerSymbol ? typeChecker.symbolToString(containerSymbol, node) : ""; - if (!tryAddConstructSignature(symbol, node, symbolKind, symbolName, containerName, result) && - !tryAddCallSignature(symbol, node, symbolKind, symbolName, containerName, result)) { - // Just add all the declarations. - ts.forEach(declarations, function (declaration) { - result.push(createDefinitionInfo(declaration, symbolKind, symbolName, containerName)); - }); - } - return result; - function tryAddConstructSignature(symbol, location, symbolKind, symbolName, containerName, result) { - // Applicable only if we are in a new expression, or we are on a constructor declaration - // and in either case the symbol has a construct signature definition, i.e. class - if (isNewExpressionTarget(location) || location.kind === 121 /* ConstructorKeyword */) { - if (symbol.flags & 32 /* Class */) { - // Find the first class-like declaration and try to get the construct signature. - for (var _i = 0, _a = symbol.getDeclarations(); _i < _a.length; _i++) { - var declaration = _a[_i]; - if (ts.isClassLike(declaration)) { - return tryAddSignature(declaration.members, - /*selectConstructors*/ true, symbolKind, symbolName, containerName, result); - } - } - ts.Debug.fail("Expected declaration to have at least one class-like declaration"); - } - } - return false; - } - function tryAddCallSignature(symbol, location, symbolKind, symbolName, containerName, result) { - if (isCallExpressionTarget(location) || isNewExpressionTarget(location) || isNameOfFunctionDeclaration(location)) { - return tryAddSignature(symbol.declarations, /*selectConstructors*/ false, symbolKind, symbolName, containerName, result); - } - return false; - } - function tryAddSignature(signatureDeclarations, selectConstructors, symbolKind, symbolName, containerName, result) { - var declarations = []; - var definition; - ts.forEach(signatureDeclarations, function (d) { - if ((selectConstructors && d.kind === 144 /* Constructor */) || - (!selectConstructors && (d.kind === 213 /* FunctionDeclaration */ || d.kind === 143 /* MethodDeclaration */ || d.kind === 142 /* MethodSignature */))) { - declarations.push(d); - if (d.body) - definition = d; - } - }); - if (definition) { - result.push(createDefinitionInfo(definition, symbolKind, symbolName, containerName)); - return true; - } - else if (declarations.length) { - result.push(createDefinitionInfo(ts.lastOrUndefined(declarations), symbolKind, symbolName, containerName)); - return true; - } - return false; - } - } - /// Goto definition - function getDefinitionAtPosition(fileName, position) { - synchronizeHostData(); - var sourceFile = getValidSourceFile(fileName); - var node = ts.getTouchingPropertyName(sourceFile, position); - if (!node) { - return undefined; - } - // Labels - if (isJumpStatementTarget(node)) { - var labelName = node.text; - var label = getTargetLabel(node.parent, node.text); - return label ? [createDefinitionInfo(label, ScriptElementKind.label, labelName, /*containerName*/ undefined)] : undefined; - } - /// Triple slash reference comments - var comment = ts.forEach(sourceFile.referencedFiles, function (r) { return (r.pos <= position && position < r.end) ? r : undefined; }); - if (comment) { - var referenceFile = ts.tryResolveScriptReference(program, sourceFile, comment); - if (referenceFile) { - return [{ - fileName: referenceFile.fileName, - textSpan: ts.createTextSpanFromBounds(0, 0), - kind: ScriptElementKind.scriptElement, - name: comment.fileName, - containerName: undefined, - containerKind: undefined - }]; - } - return undefined; - } - var typeChecker = program.getTypeChecker(); - var symbol = typeChecker.getSymbolAtLocation(node); - // Could not find a symbol e.g. node is string or number keyword, - // or the symbol was an internal symbol and does not have a declaration e.g. undefined symbol - if (!symbol) { - return undefined; - } - // If this is an alias, and the request came at the declaration location - // get the aliased symbol instead. This allows for goto def on an import e.g. - // import {A, B} from "mod"; - // to jump to the implementation directly. - if (symbol.flags & 8388608 /* Alias */) { - var declaration = symbol.declarations[0]; - if (node.kind === 69 /* Identifier */ && node.parent === declaration) { - symbol = typeChecker.getAliasedSymbol(symbol); - } - } - // Because name in short-hand property assignment has two different meanings: property name and property value, - // using go-to-definition at such position should go to the variable declaration of the property value rather than - // go to the declaration of the property name (in this case stay at the same position). However, if go-to-definition - // is performed at the location of property access, we would like to go to definition of the property in the short-hand - // assignment. This case and others are handled by the following code. - if (node.parent.kind === 246 /* ShorthandPropertyAssignment */) { - var shorthandSymbol = typeChecker.getShorthandAssignmentValueSymbol(symbol.valueDeclaration); - if (!shorthandSymbol) { - return []; - } - var shorthandDeclarations = shorthandSymbol.getDeclarations(); - var shorthandSymbolKind = getSymbolKind(shorthandSymbol, node); - var shorthandSymbolName = typeChecker.symbolToString(shorthandSymbol); - var shorthandContainerName = typeChecker.symbolToString(symbol.parent, node); - return ts.map(shorthandDeclarations, function (declaration) { return createDefinitionInfo(declaration, shorthandSymbolKind, shorthandSymbolName, shorthandContainerName); }); - } - return getDefinitionFromSymbol(symbol, node); - } - /// Goto type - function getTypeDefinitionAtPosition(fileName, position) { - synchronizeHostData(); - var sourceFile = getValidSourceFile(fileName); - var node = ts.getTouchingPropertyName(sourceFile, position); - if (!node) { - return undefined; - } - var typeChecker = program.getTypeChecker(); - var symbol = typeChecker.getSymbolAtLocation(node); - if (!symbol) { - return undefined; - } - var type = typeChecker.getTypeOfSymbolAtLocation(symbol, node); - if (!type) { - return undefined; - } - if (type.flags & 16384 /* Union */) { - var result = []; - ts.forEach(type.types, function (t) { - if (t.symbol) { - ts.addRange(/*to*/ result, /*from*/ getDefinitionFromSymbol(t.symbol, node)); - } - }); - return result; - } - if (!type.symbol) { - return undefined; - } - return getDefinitionFromSymbol(type.symbol, node); - } - function getOccurrencesAtPosition(fileName, position) { - var results = getOccurrencesAtPositionCore(fileName, position); - if (results) { - var sourceFile = getCanonicalFileName(ts.normalizeSlashes(fileName)); - // Get occurrences only supports reporting occurrences for the file queried. So - // filter down to that list. - results = ts.filter(results, function (r) { return getCanonicalFileName(ts.normalizeSlashes(r.fileName)) === sourceFile; }); - } - return results; - } - function getDocumentHighlights(fileName, position, filesToSearch) { - synchronizeHostData(); - filesToSearch = ts.map(filesToSearch, ts.normalizeSlashes); - var sourceFilesToSearch = ts.filter(program.getSourceFiles(), function (f) { return ts.contains(filesToSearch, f.fileName); }); - var sourceFile = getValidSourceFile(fileName); - var node = ts.getTouchingWord(sourceFile, position); - if (!node) { - return undefined; - } - return getSemanticDocumentHighlights(node) || getSyntacticDocumentHighlights(node); - function getHighlightSpanForNode(node) { - var start = node.getStart(); - var end = node.getEnd(); - return { - fileName: sourceFile.fileName, - textSpan: ts.createTextSpanFromBounds(start, end), - kind: HighlightSpanKind.none - }; - } - function getSemanticDocumentHighlights(node) { - if (node.kind === 69 /* Identifier */ || - node.kind === 97 /* ThisKeyword */ || - node.kind === 95 /* SuperKeyword */ || - isLiteralNameOfPropertyDeclarationOrIndexAccess(node) || - isNameOfExternalModuleImportOrDeclaration(node)) { - var referencedSymbols = getReferencedSymbolsForNode(node, sourceFilesToSearch, /*findInStrings:*/ false, /*findInComments:*/ false); - return convertReferencedSymbols(referencedSymbols); - } - return undefined; - function convertReferencedSymbols(referencedSymbols) { - if (!referencedSymbols) { - return undefined; - } - var fileNameToDocumentHighlights = {}; - var result = []; - for (var _i = 0; _i < referencedSymbols.length; _i++) { - var referencedSymbol = referencedSymbols[_i]; - for (var _a = 0, _b = referencedSymbol.references; _a < _b.length; _a++) { - var referenceEntry = _b[_a]; - var fileName_1 = referenceEntry.fileName; - var documentHighlights = ts.getProperty(fileNameToDocumentHighlights, fileName_1); - if (!documentHighlights) { - documentHighlights = { fileName: fileName_1, highlightSpans: [] }; - fileNameToDocumentHighlights[fileName_1] = documentHighlights; - result.push(documentHighlights); - } - documentHighlights.highlightSpans.push({ - textSpan: referenceEntry.textSpan, - kind: referenceEntry.isWriteAccess ? HighlightSpanKind.writtenReference : HighlightSpanKind.reference - }); - } - } - return result; - } - } - function getSyntacticDocumentHighlights(node) { - var fileName = sourceFile.fileName; - var highlightSpans = getHighlightSpans(node); - if (!highlightSpans || highlightSpans.length === 0) { - return undefined; - } - return [{ fileName: fileName, highlightSpans: highlightSpans }]; - // returns true if 'node' is defined and has a matching 'kind'. - function hasKind(node, kind) { - return node !== undefined && node.kind === kind; - } - // Null-propagating 'parent' function. - function parent(node) { - return node && node.parent; - } - function getHighlightSpans(node) { - if (node) { - switch (node.kind) { - case 88 /* IfKeyword */: - case 80 /* ElseKeyword */: - if (hasKind(node.parent, 196 /* IfStatement */)) { - return getIfElseOccurrences(node.parent); - } - break; - case 94 /* ReturnKeyword */: - if (hasKind(node.parent, 204 /* ReturnStatement */)) { - return getReturnOccurrences(node.parent); - } - break; - case 98 /* ThrowKeyword */: - if (hasKind(node.parent, 208 /* ThrowStatement */)) { - return getThrowOccurrences(node.parent); - } - break; - case 72 /* CatchKeyword */: - if (hasKind(parent(parent(node)), 209 /* TryStatement */)) { - return getTryCatchFinallyOccurrences(node.parent.parent); - } - break; - case 100 /* TryKeyword */: - case 85 /* FinallyKeyword */: - if (hasKind(parent(node), 209 /* TryStatement */)) { - return getTryCatchFinallyOccurrences(node.parent); - } - break; - case 96 /* SwitchKeyword */: - if (hasKind(node.parent, 206 /* SwitchStatement */)) { - return getSwitchCaseDefaultOccurrences(node.parent); - } - break; - case 71 /* CaseKeyword */: - case 77 /* DefaultKeyword */: - if (hasKind(parent(parent(parent(node))), 206 /* SwitchStatement */)) { - return getSwitchCaseDefaultOccurrences(node.parent.parent.parent); - } - break; - case 70 /* BreakKeyword */: - case 75 /* ContinueKeyword */: - if (hasKind(node.parent, 203 /* BreakStatement */) || hasKind(node.parent, 202 /* ContinueStatement */)) { - return getBreakOrContinueStatementOccurrences(node.parent); - } - break; - case 86 /* ForKeyword */: - if (hasKind(node.parent, 199 /* ForStatement */) || - hasKind(node.parent, 200 /* ForInStatement */) || - hasKind(node.parent, 201 /* ForOfStatement */)) { - return getLoopBreakContinueOccurrences(node.parent); - } - break; - case 104 /* WhileKeyword */: - case 79 /* DoKeyword */: - if (hasKind(node.parent, 198 /* WhileStatement */) || hasKind(node.parent, 197 /* DoStatement */)) { - return getLoopBreakContinueOccurrences(node.parent); - } - break; - case 121 /* ConstructorKeyword */: - if (hasKind(node.parent, 144 /* Constructor */)) { - return getConstructorOccurrences(node.parent); - } - break; - case 123 /* GetKeyword */: - case 129 /* SetKeyword */: - if (hasKind(node.parent, 145 /* GetAccessor */) || hasKind(node.parent, 146 /* SetAccessor */)) { - return getGetAndSetOccurrences(node.parent); - } - break; - default: - if (ts.isModifier(node.kind) && node.parent && - (ts.isDeclaration(node.parent) || node.parent.kind === 193 /* VariableStatement */)) { - return getModifierOccurrences(node.kind, node.parent); - } - } - } - return undefined; - } - /** - * Aggregates all throw-statements within this node *without* crossing - * into function boundaries and try-blocks with catch-clauses. - */ - function aggregateOwnedThrowStatements(node) { - var statementAccumulator = []; - aggregate(node); - return statementAccumulator; - function aggregate(node) { - if (node.kind === 208 /* ThrowStatement */) { - statementAccumulator.push(node); - } - else if (node.kind === 209 /* TryStatement */) { - var tryStatement = node; - if (tryStatement.catchClause) { - aggregate(tryStatement.catchClause); - } - else { - // Exceptions thrown within a try block lacking a catch clause - // are "owned" in the current context. - aggregate(tryStatement.tryBlock); - } - if (tryStatement.finallyBlock) { - aggregate(tryStatement.finallyBlock); - } - } - else if (!ts.isFunctionLike(node)) { - ts.forEachChild(node, aggregate); - } - } - ; - } - /** - * For lack of a better name, this function takes a throw statement and returns the - * nearest ancestor that is a try-block (whose try statement has a catch clause), - * function-block, or source file. - */ - function getThrowStatementOwner(throwStatement) { - var child = throwStatement; - while (child.parent) { - var parent_12 = child.parent; - if (ts.isFunctionBlock(parent_12) || parent_12.kind === 248 /* SourceFile */) { - return parent_12; - } - // A throw-statement is only owned by a try-statement if the try-statement has - // a catch clause, and if the throw-statement occurs within the try block. - if (parent_12.kind === 209 /* TryStatement */) { - var tryStatement = parent_12; - if (tryStatement.tryBlock === child && tryStatement.catchClause) { - return child; - } - } - child = parent_12; - } - return undefined; - } - function aggregateAllBreakAndContinueStatements(node) { - var statementAccumulator = []; - aggregate(node); - return statementAccumulator; - function aggregate(node) { - if (node.kind === 203 /* BreakStatement */ || node.kind === 202 /* ContinueStatement */) { - statementAccumulator.push(node); - } - else if (!ts.isFunctionLike(node)) { - ts.forEachChild(node, aggregate); - } - } - ; - } - function ownsBreakOrContinueStatement(owner, statement) { - var actualOwner = getBreakOrContinueOwner(statement); - return actualOwner && actualOwner === owner; - } - function getBreakOrContinueOwner(statement) { - for (var node_2 = statement.parent; node_2; node_2 = node_2.parent) { - switch (node_2.kind) { - case 206 /* SwitchStatement */: - if (statement.kind === 202 /* ContinueStatement */) { - continue; - } - // Fall through. - case 199 /* ForStatement */: - case 200 /* ForInStatement */: - case 201 /* ForOfStatement */: - case 198 /* WhileStatement */: - case 197 /* DoStatement */: - if (!statement.label || isLabeledBy(node_2, statement.label.text)) { - return node_2; - } - break; - default: - // Don't cross function boundaries. - if (ts.isFunctionLike(node_2)) { - return undefined; - } - break; - } - } - return undefined; - } - function getModifierOccurrences(modifier, declaration) { - 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 === 214 /* ClassDeclaration */ || - container.kind === 186 /* ClassExpression */ || - (declaration.kind === 138 /* Parameter */ && hasKind(container, 144 /* Constructor */)))) { - return undefined; - } - } - else if (modifier === 113 /* StaticKeyword */) { - if (!(container.kind === 214 /* ClassDeclaration */ || container.kind === 186 /* ClassExpression */)) { - return undefined; - } - } - else if (modifier === 82 /* ExportKeyword */ || modifier === 122 /* DeclareKeyword */) { - if (!(container.kind === 219 /* ModuleBlock */ || container.kind === 248 /* SourceFile */)) { - return undefined; - } - } - else if (modifier === 115 /* AbstractKeyword */) { - if (!(container.kind === 214 /* ClassDeclaration */ || declaration.kind === 214 /* ClassDeclaration */)) { - return undefined; - } - } - else { - // unsupported modifier - return undefined; - } - var keywords = []; - var modifierFlag = getFlagFromModifier(modifier); - var nodes; - switch (container.kind) { - case 219 /* ModuleBlock */: - case 248 /* SourceFile */: - // Container is either a class declaration or the declaration is a classDeclaration - if (modifierFlag & 256 /* Abstract */) { - nodes = declaration.members.concat(declaration); - } - else { - nodes = container.statements; - } - break; - case 144 /* Constructor */: - nodes = container.parameters.concat(container.parent.members); - break; - case 214 /* ClassDeclaration */: - case 186 /* ClassExpression */: - nodes = container.members; - // If we're an accessibility modifier, we're in an instance member and should search - // the constructor's parameter list for instance members as well. - if (modifierFlag & 112 /* AccessibilityModifier */) { - var constructor = ts.forEach(container.members, function (member) { - return member.kind === 144 /* Constructor */ && member; - }); - if (constructor) { - nodes = nodes.concat(constructor.parameters); - } - } - else if (modifierFlag & 256 /* Abstract */) { - nodes = nodes.concat(container); - } - break; - default: - ts.Debug.fail("Invalid container kind."); - } - ts.forEach(nodes, function (node) { - if (node.modifiers && node.flags & modifierFlag) { - ts.forEach(node.modifiers, function (child) { return pushKeywordIf(keywords, child, modifier); }); - } - }); - return ts.map(keywords, getHighlightSpanForNode); - function getFlagFromModifier(modifier) { - switch (modifier) { - case 112 /* PublicKeyword */: - return 16 /* Public */; - case 110 /* PrivateKeyword */: - return 32 /* Private */; - case 111 /* ProtectedKeyword */: - return 64 /* Protected */; - case 113 /* StaticKeyword */: - return 128 /* Static */; - case 82 /* ExportKeyword */: - return 1 /* Export */; - case 122 /* DeclareKeyword */: - return 2 /* Ambient */; - case 115 /* AbstractKeyword */: - return 256 /* Abstract */; - default: - ts.Debug.fail(); - } - } - } - function pushKeywordIf(keywordList, token) { - var expected = []; - for (var _i = 2; _i < arguments.length; _i++) { - expected[_i - 2] = arguments[_i]; - } - if (token && ts.contains(expected, token.kind)) { - keywordList.push(token); - return true; - } - return false; - } - function getGetAndSetOccurrences(accessorDeclaration) { - var keywords = []; - tryPushAccessorKeyword(accessorDeclaration.symbol, 145 /* GetAccessor */); - tryPushAccessorKeyword(accessorDeclaration.symbol, 146 /* SetAccessor */); - return ts.map(keywords, getHighlightSpanForNode); - function tryPushAccessorKeyword(accessorSymbol, accessorKind) { - var accessor = ts.getDeclarationOfKind(accessorSymbol, accessorKind); - if (accessor) { - ts.forEach(accessor.getChildren(), function (child) { return pushKeywordIf(keywords, child, 123 /* GetKeyword */, 129 /* SetKeyword */); }); - } - } - } - function getConstructorOccurrences(constructorDeclaration) { - var declarations = constructorDeclaration.symbol.getDeclarations(); - var keywords = []; - ts.forEach(declarations, function (declaration) { - ts.forEach(declaration.getChildren(), function (token) { - return pushKeywordIf(keywords, token, 121 /* ConstructorKeyword */); - }); - }); - return ts.map(keywords, getHighlightSpanForNode); - } - function getLoopBreakContinueOccurrences(loopNode) { - var keywords = []; - if (pushKeywordIf(keywords, loopNode.getFirstToken(), 86 /* ForKeyword */, 104 /* WhileKeyword */, 79 /* DoKeyword */)) { - // If we succeeded and got a do-while loop, then start looking for a 'while' keyword. - if (loopNode.kind === 197 /* DoStatement */) { - var loopTokens = loopNode.getChildren(); - for (var i = loopTokens.length - 1; i >= 0; i--) { - if (pushKeywordIf(keywords, loopTokens[i], 104 /* WhileKeyword */)) { - break; - } - } - } - } - var breaksAndContinues = aggregateAllBreakAndContinueStatements(loopNode.statement); - ts.forEach(breaksAndContinues, function (statement) { - if (ownsBreakOrContinueStatement(loopNode, statement)) { - pushKeywordIf(keywords, statement.getFirstToken(), 70 /* BreakKeyword */, 75 /* ContinueKeyword */); - } - }); - return ts.map(keywords, getHighlightSpanForNode); - } - function getBreakOrContinueStatementOccurrences(breakOrContinueStatement) { - var owner = getBreakOrContinueOwner(breakOrContinueStatement); - if (owner) { - switch (owner.kind) { - case 199 /* ForStatement */: - case 200 /* ForInStatement */: - case 201 /* ForOfStatement */: - case 197 /* DoStatement */: - case 198 /* WhileStatement */: - return getLoopBreakContinueOccurrences(owner); - case 206 /* SwitchStatement */: - return getSwitchCaseDefaultOccurrences(owner); - } - } - return undefined; - } - function getSwitchCaseDefaultOccurrences(switchStatement) { - var keywords = []; - pushKeywordIf(keywords, switchStatement.getFirstToken(), 96 /* SwitchKeyword */); - // Go through each clause in the switch statement, collecting the 'case'/'default' keywords. - ts.forEach(switchStatement.caseBlock.clauses, function (clause) { - pushKeywordIf(keywords, clause.getFirstToken(), 71 /* CaseKeyword */, 77 /* DefaultKeyword */); - var breaksAndContinues = aggregateAllBreakAndContinueStatements(clause); - ts.forEach(breaksAndContinues, function (statement) { - if (ownsBreakOrContinueStatement(switchStatement, statement)) { - pushKeywordIf(keywords, statement.getFirstToken(), 70 /* BreakKeyword */); - } - }); - }); - return ts.map(keywords, getHighlightSpanForNode); - } - function getTryCatchFinallyOccurrences(tryStatement) { - var keywords = []; - pushKeywordIf(keywords, tryStatement.getFirstToken(), 100 /* TryKeyword */); - if (tryStatement.catchClause) { - pushKeywordIf(keywords, tryStatement.catchClause.getFirstToken(), 72 /* CatchKeyword */); - } - if (tryStatement.finallyBlock) { - var finallyKeyword = ts.findChildOfKind(tryStatement, 85 /* FinallyKeyword */, sourceFile); - pushKeywordIf(keywords, finallyKeyword, 85 /* FinallyKeyword */); - } - return ts.map(keywords, getHighlightSpanForNode); - } - function getThrowOccurrences(throwStatement) { - var owner = getThrowStatementOwner(throwStatement); - if (!owner) { - return undefined; - } - var keywords = []; - ts.forEach(aggregateOwnedThrowStatements(owner), function (throwStatement) { - pushKeywordIf(keywords, throwStatement.getFirstToken(), 98 /* ThrowKeyword */); - }); - // If the "owner" is a function, then we equate 'return' and 'throw' statements in their - // ability to "jump out" of the function, and include occurrences for both. - if (ts.isFunctionBlock(owner)) { - ts.forEachReturnStatement(owner, function (returnStatement) { - pushKeywordIf(keywords, returnStatement.getFirstToken(), 94 /* ReturnKeyword */); - }); - } - return ts.map(keywords, getHighlightSpanForNode); - } - 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, 192 /* Block */))) { - return undefined; - } - var keywords = []; - ts.forEachReturnStatement(func.body, function (returnStatement) { - pushKeywordIf(keywords, returnStatement.getFirstToken(), 94 /* ReturnKeyword */); - }); - // Include 'throw' statements that do not occur within a try block. - ts.forEach(aggregateOwnedThrowStatements(func.body), function (throwStatement) { - pushKeywordIf(keywords, throwStatement.getFirstToken(), 98 /* ThrowKeyword */); - }); - return ts.map(keywords, getHighlightSpanForNode); - } - function getIfElseOccurrences(ifStatement) { - var keywords = []; - // Traverse upwards through all parent if-statements linked by their else-branches. - while (hasKind(ifStatement.parent, 196 /* IfStatement */) && ifStatement.parent.elseStatement === ifStatement) { - ifStatement = ifStatement.parent; - } - // Now traverse back down through the else branches, aggregating if/else keywords of if-statements. - while (ifStatement) { - var children = ifStatement.getChildren(); - pushKeywordIf(keywords, children[0], 88 /* IfKeyword */); - // Generally the 'else' keyword is second-to-last, so we traverse backwards. - for (var i = children.length - 1; i >= 0; i--) { - if (pushKeywordIf(keywords, children[i], 80 /* ElseKeyword */)) { - break; - } - } - if (!hasKind(ifStatement.elseStatement, 196 /* IfStatement */)) { - break; - } - ifStatement = ifStatement.elseStatement; - } - var result = []; - // 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) { - var elseKeyword = keywords[i]; - var ifKeyword = keywords[i + 1]; // this *should* always be an 'if' keyword. - var shouldCombindElseAndIf = true; - // Avoid recalculating getStart() by iterating backwards. - for (var j = ifKeyword.getStart() - 1; j >= elseKeyword.end; j--) { - if (!ts.isWhiteSpace(sourceFile.text.charCodeAt(j))) { - shouldCombindElseAndIf = false; - break; - } - } - if (shouldCombindElseAndIf) { - result.push({ - fileName: fileName, - textSpan: ts.createTextSpanFromBounds(elseKeyword.getStart(), ifKeyword.end), - kind: HighlightSpanKind.reference - }); - i++; // skip the next keyword - continue; - } - } - // Ordinary case: just highlight the keyword. - result.push(getHighlightSpanForNode(keywords[i])); - } - return result; - } - } - } - /// References and Occurrences - function getOccurrencesAtPositionCore(fileName, position) { - synchronizeHostData(); - return convertDocumentHighlights(getDocumentHighlights(fileName, position, [fileName])); - function convertDocumentHighlights(documentHighlights) { - if (!documentHighlights) { - return undefined; - } - var result = []; - for (var _i = 0; _i < documentHighlights.length; _i++) { - var entry = documentHighlights[_i]; - for (var _a = 0, _b = entry.highlightSpans; _a < _b.length; _a++) { - var highlightSpan = _b[_a]; - result.push({ - fileName: entry.fileName, - textSpan: highlightSpan.textSpan, - isWriteAccess: highlightSpan.kind === HighlightSpanKind.writtenReference - }); - } - } - return result; - } - } - function convertReferences(referenceSymbols) { - if (!referenceSymbols) { - return undefined; - } - var referenceEntries = []; - for (var _i = 0; _i < referenceSymbols.length; _i++) { - var referenceSymbol = referenceSymbols[_i]; - ts.addRange(referenceEntries, referenceSymbol.references); - } - return referenceEntries; - } - function findRenameLocations(fileName, position, findInStrings, findInComments) { - var referencedSymbols = findReferencedSymbols(fileName, position, findInStrings, findInComments); - return convertReferences(referencedSymbols); - } - function getReferencesAtPosition(fileName, position) { - var referencedSymbols = findReferencedSymbols(fileName, position, /*findInStrings:*/ false, /*findInComments:*/ false); - return convertReferences(referencedSymbols); - } - function findReferences(fileName, position) { - var referencedSymbols = findReferencedSymbols(fileName, position, /*findInStrings:*/ false, /*findInComments:*/ false); - // Only include referenced symbols that have a valid definition. - return ts.filter(referencedSymbols, function (rs) { return !!rs.definition; }); - } - function findReferencedSymbols(fileName, position, findInStrings, findInComments) { - synchronizeHostData(); - var sourceFile = getValidSourceFile(fileName); - var node = ts.getTouchingPropertyName(sourceFile, position); - if (!node) { - return undefined; - } - if (node.kind !== 69 /* Identifier */ && - // TODO (drosen): This should be enabled in a later release - currently breaks rename. - //node.kind !== SyntaxKind.ThisKeyword && - //node.kind !== SyntaxKind.SuperKeyword && - !isLiteralNameOfPropertyDeclarationOrIndexAccess(node) && - !isNameOfExternalModuleImportOrDeclaration(node)) { - return undefined; - } - ts.Debug.assert(node.kind === 69 /* Identifier */ || node.kind === 8 /* NumericLiteral */ || node.kind === 9 /* StringLiteral */); - return getReferencedSymbolsForNode(node, program.getSourceFiles(), findInStrings, findInComments); - } - function getReferencedSymbolsForNode(node, sourceFiles, findInStrings, findInComments) { - var typeChecker = program.getTypeChecker(); - // Labels - if (isLabelName(node)) { - if (isJumpStatementTarget(node)) { - var labelDefinition = getTargetLabel(node.parent, node.text); - // if we have a label definition, look within its statement for references, if not, then - // the label is undefined and we have no results.. - return labelDefinition ? getLabelReferencesInNode(labelDefinition.parent, labelDefinition) : undefined; - } - else { - // it is a label definition and not a target, search within the parent labeledStatement - return getLabelReferencesInNode(node.parent, node); - } - } - if (node.kind === 97 /* ThisKeyword */) { - return getReferencesForThisKeyword(node, sourceFiles); - } - if (node.kind === 95 /* SuperKeyword */) { - return getReferencesForSuperKeyword(node); - } - var symbol = typeChecker.getSymbolAtLocation(node); - // Could not find a symbol e.g. unknown identifier - if (!symbol) { - // Can't have references to something that we have no symbol for. - return undefined; - } - var declarations = symbol.declarations; - // The symbol was an internal symbol and does not have a declaration e.g. undefined symbol - if (!declarations || !declarations.length) { - return undefined; - } - var result; - // Compute the meaning from the location and the symbol it references - var searchMeaning = getIntersectingMeaningFromDeclarations(getMeaningFromLocation(node), declarations); - // Get the text to search for. - // Note: if this is an external module symbol, the name doesn't include quotes. - var declaredName = ts.stripQuotes(ts.getDeclaredName(typeChecker, symbol, node)); - // Try to get the smallest valid scope that we can limit our search to; - // otherwise we'll need to search globally (i.e. include each file). - var scope = getSymbolScope(symbol); - // Maps from a symbol ID to the ReferencedSymbol entry in 'result'. - var symbolToIndex = []; - if (scope) { - result = []; - getReferencesInNode(scope, symbol, declaredName, node, searchMeaning, findInStrings, findInComments, result, symbolToIndex); - } - else { - var internedName = getInternedName(symbol, node, declarations); - for (var _i = 0; _i < sourceFiles.length; _i++) { - var sourceFile = sourceFiles[_i]; - cancellationToken.throwIfCancellationRequested(); - var nameTable = getNameTable(sourceFile); - if (ts.lookUp(nameTable, internedName)) { - result = result || []; - getReferencesInNode(sourceFile, symbol, declaredName, node, searchMeaning, findInStrings, findInComments, result, symbolToIndex); - } - } - } - return result; - function getDefinition(symbol) { - var info = getSymbolDisplayPartsDocumentationAndSymbolKind(symbol, node.getSourceFile(), getContainerNode(node), node); - var name = ts.map(info.displayParts, function (p) { return p.text; }).join(""); - var declarations = symbol.declarations; - if (!declarations || declarations.length === 0) { - return undefined; - } - return { - containerKind: "", - containerName: "", - name: name, - kind: info.symbolKind, - fileName: declarations[0].getSourceFile().fileName, - textSpan: ts.createTextSpan(declarations[0].getStart(), 0) - }; - } - function isImportOrExportSpecifierImportSymbol(symbol) { - return (symbol.flags & 8388608 /* Alias */) && ts.forEach(symbol.declarations, function (declaration) { - return declaration.kind === 226 /* ImportSpecifier */ || declaration.kind === 230 /* ExportSpecifier */; - }); - } - function getInternedName(symbol, location, declarations) { - // 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)) { - return location.getText(); - } - // Try to get the local symbol if we're dealing with an 'export default' - // since that symbol has the "true" name. - var localExportDefaultSymbol = ts.getLocalSymbolForExportDefault(symbol); - symbol = localExportDefaultSymbol || symbol; - return ts.stripQuotes(symbol.name); - } - /** - * Determines the smallest scope in which a symbol may have named references. - * Note that not every construct has been accounted for. This function can - * probably be improved. - * - * @returns undefined if the scope cannot be determined, implying that - * a reference to a symbol can occur anywhere. - */ - function getSymbolScope(symbol) { - // 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 === 173 /* FunctionExpression */ || valueDeclaration.kind === 186 /* ClassExpression */)) { - return valueDeclaration; - } - // If this is private property or method, the scope is the containing class - if (symbol.flags & (4 /* Property */ | 8192 /* Method */)) { - var privateDeclaration = ts.forEach(symbol.getDeclarations(), function (d) { return (d.flags & 32 /* Private */) ? d : undefined; }); - if (privateDeclaration) { - return ts.getAncestor(privateDeclaration, 214 /* ClassDeclaration */); - } - } - // If the symbol is an import we would like to find it if we are looking for what it imports. - // So consider it visibile outside its declaration scope. - if (symbol.flags & 8388608 /* Alias */) { - return undefined; - } - // if this symbol is visible from its parent container, e.g. exported, then bail out - // if symbol correspond to the union property - bail out - if (symbol.parent || (symbol.flags & 268435456 /* SyntheticProperty */)) { - return undefined; - } - var scope = undefined; - var declarations = symbol.getDeclarations(); - if (declarations) { - for (var _i = 0; _i < declarations.length; _i++) { - var declaration = declarations[_i]; - var container = getContainerNode(declaration); - if (!container) { - return undefined; - } - if (scope && scope !== container) { - // Different declarations have different containers, bail out - return undefined; - } - if (container.kind === 248 /* SourceFile */ && !ts.isExternalModule(container)) { - // This is a global variable and not an external module, any declaration defined - // within this scope is visible outside the file - return undefined; - } - // The search scope is the container node - scope = container; - } - } - return scope; - } - function getPossibleSymbolReferencePositions(sourceFile, symbolName, start, end) { - var positions = []; - /// TODO: Cache symbol existence for files to save text search - // Also, need to make this work for unicode escapes. - // Be resilient in the face of a symbol with no name or zero length name - if (!symbolName || !symbolName.length) { - return positions; - } - var text = sourceFile.text; - var sourceLength = text.length; - var symbolNameLength = symbolName.length; - var position = text.indexOf(symbolName, start); - while (position >= 0) { - cancellationToken.throwIfCancellationRequested(); - // If we are past the end, stop looking - if (position > end) - break; - // 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 */))) { - // Found a real match. Keep searching. - positions.push(position); - } - position = text.indexOf(symbolName, position + symbolNameLength + 1); - } - return positions; - } - function getLabelReferencesInNode(container, targetLabel) { - var references = []; - var sourceFile = container.getSourceFile(); - var labelName = targetLabel.text; - var possiblePositions = getPossibleSymbolReferencePositions(sourceFile, labelName, container.getStart(), container.getEnd()); - ts.forEach(possiblePositions, function (position) { - cancellationToken.throwIfCancellationRequested(); - var node = ts.getTouchingWord(sourceFile, position); - if (!node || node.getWidth() !== labelName.length) { - return; - } - // Only pick labels that are either the target label, or have a target that is the target label - if (node === targetLabel || - (isJumpStatementTarget(node) && getTargetLabel(node, labelName) === targetLabel)) { - references.push(getReferenceEntryFromNode(node)); - } - }); - var definition = { - containerKind: "", - containerName: "", - fileName: targetLabel.getSourceFile().fileName, - kind: ScriptElementKind.label, - name: labelName, - textSpan: ts.createTextSpanFromBounds(targetLabel.getStart(), targetLabel.getEnd()) - }; - return [{ definition: definition, references: references }]; - } - function isValidReferencePosition(node, searchSymbolName) { - if (node) { - // Compare the length so we filter out strict superstrings of the symbol we are looking for - switch (node.kind) { - case 69 /* Identifier */: - return node.getWidth() === searchSymbolName.length; - case 9 /* StringLiteral */: - if (isLiteralNameOfPropertyDeclarationOrIndexAccess(node) || - isNameOfExternalModuleImportOrDeclaration(node)) { - // For string literals we have two additional chars for the quotes - return node.getWidth() === searchSymbolName.length + 2; - } - break; - case 8 /* NumericLiteral */: - if (isLiteralNameOfPropertyDeclarationOrIndexAccess(node)) { - return node.getWidth() === searchSymbolName.length; - } - break; - } - } - return false; - } - /** Search within node "container" for references for a search value, where the search value is defined as a - * tuple of(searchSymbol, searchText, searchLocation, and searchMeaning). - * searchLocation: a node where the search value - */ - function getReferencesInNode(container, searchSymbol, searchText, searchLocation, searchMeaning, findInStrings, findInComments, result, symbolToIndex) { - var sourceFile = container.getSourceFile(); - var tripleSlashDirectivePrefixRegex = /^\/\/\/\s*= 0) { - var referencedSymbol = getReferencedSymbol(shorthandValueSymbol); - referencedSymbol.references.push(getReferenceEntryFromNode(referenceSymbolDeclaration.name)); - } - } - }); - } - return; - function getReferencedSymbol(symbol) { - var symbolId = ts.getSymbolId(symbol); - var index = symbolToIndex[symbolId]; - if (index === undefined) { - index = result.length; - symbolToIndex[symbolId] = index; - result.push({ - definition: getDefinition(symbol), - references: [] - }); - } - return result[index]; - } - function isInNonReferenceComment(sourceFile, position) { - return ts.isInCommentHelper(sourceFile, position, isNonReferenceComment); - function isNonReferenceComment(c) { - var commentText = sourceFile.text.substring(c.pos, c.end); - return !tripleSlashDirectivePrefixRegex.test(commentText); - } - } - } - function getReferencesForSuperKeyword(superKeyword) { - var searchSpaceNode = ts.getSuperContainer(superKeyword, /*includeFunctions*/ false); - if (!searchSpaceNode) { - return undefined; - } - // Whether 'super' occurs in a static context within a class. - var staticFlag = 128 /* Static */; - switch (searchSpaceNode.kind) { - case 141 /* PropertyDeclaration */: - case 140 /* PropertySignature */: - case 143 /* MethodDeclaration */: - case 142 /* MethodSignature */: - case 144 /* Constructor */: - case 145 /* GetAccessor */: - case 146 /* SetAccessor */: - staticFlag &= searchSpaceNode.flags; - searchSpaceNode = searchSpaceNode.parent; // re-assign to be the owning class - break; - default: - return undefined; - } - var references = []; - var sourceFile = searchSpaceNode.getSourceFile(); - var possiblePositions = getPossibleSymbolReferencePositions(sourceFile, "super", searchSpaceNode.getStart(), searchSpaceNode.getEnd()); - ts.forEach(possiblePositions, function (position) { - cancellationToken.throwIfCancellationRequested(); - var node = ts.getTouchingWord(sourceFile, position); - if (!node || node.kind !== 95 /* SuperKeyword */) { - return; - } - var container = ts.getSuperContainer(node, /*includeFunctions*/ false); - // If we have a 'super' container, we must have an enclosing class. - // Now make sure the owning class is the same as the search-space - // and has the same static qualifier as the original 'super's owner. - if (container && (128 /* Static */ & container.flags) === staticFlag && container.parent.symbol === searchSpaceNode.symbol) { - references.push(getReferenceEntryFromNode(node)); - } - }); - var definition = getDefinition(searchSpaceNode.symbol); - return [{ definition: definition, references: references }]; - } - function getReferencesForThisKeyword(thisOrSuperKeyword, sourceFiles) { - var searchSpaceNode = ts.getThisContainer(thisOrSuperKeyword, /* includeArrowFunctions */ false); - // Whether 'this' occurs in a static context within a class. - var staticFlag = 128 /* Static */; - switch (searchSpaceNode.kind) { - case 143 /* MethodDeclaration */: - case 142 /* MethodSignature */: - if (ts.isObjectLiteralMethod(searchSpaceNode)) { - break; - } - // fall through - case 141 /* PropertyDeclaration */: - case 140 /* PropertySignature */: - case 144 /* Constructor */: - case 145 /* GetAccessor */: - case 146 /* SetAccessor */: - staticFlag &= searchSpaceNode.flags; - searchSpaceNode = searchSpaceNode.parent; // re-assign to be the owning class - break; - case 248 /* SourceFile */: - if (ts.isExternalModule(searchSpaceNode)) { - return undefined; - } - // Fall through - case 213 /* FunctionDeclaration */: - case 173 /* FunctionExpression */: - break; - // Computed properties in classes are not handled here because references to this are illegal, - // so there is no point finding references to them. - default: - return undefined; - } - var references = []; - var possiblePositions; - if (searchSpaceNode.kind === 248 /* SourceFile */) { - ts.forEach(sourceFiles, function (sourceFile) { - possiblePositions = getPossibleSymbolReferencePositions(sourceFile, "this", sourceFile.getStart(), sourceFile.getEnd()); - getThisReferencesInFile(sourceFile, sourceFile, possiblePositions, references); - }); - } - else { - var sourceFile = searchSpaceNode.getSourceFile(); - possiblePositions = getPossibleSymbolReferencePositions(sourceFile, "this", searchSpaceNode.getStart(), searchSpaceNode.getEnd()); - getThisReferencesInFile(sourceFile, searchSpaceNode, possiblePositions, references); - } - return [{ - definition: { - containerKind: "", - containerName: "", - fileName: node.getSourceFile().fileName, - kind: ScriptElementKind.variableElement, - name: "this", - textSpan: ts.createTextSpanFromBounds(node.getStart(), node.getEnd()) - }, - references: references - }]; - function getThisReferencesInFile(sourceFile, searchSpaceNode, possiblePositions, result) { - ts.forEach(possiblePositions, function (position) { - cancellationToken.throwIfCancellationRequested(); - var node = ts.getTouchingWord(sourceFile, position); - if (!node || node.kind !== 97 /* ThisKeyword */) { - return; - } - var container = ts.getThisContainer(node, /* includeArrowFunctions */ false); - switch (searchSpaceNode.kind) { - case 173 /* FunctionExpression */: - case 213 /* FunctionDeclaration */: - if (searchSpaceNode.symbol === container.symbol) { - result.push(getReferenceEntryFromNode(node)); - } - break; - case 143 /* MethodDeclaration */: - case 142 /* MethodSignature */: - if (ts.isObjectLiteralMethod(searchSpaceNode) && searchSpaceNode.symbol === container.symbol) { - result.push(getReferenceEntryFromNode(node)); - } - break; - case 186 /* ClassExpression */: - case 214 /* ClassDeclaration */: - // Make sure the container belongs to the same class - // and has the appropriate static modifier from the original container. - if (container.parent && searchSpaceNode.symbol === container.parent.symbol && (container.flags & 128 /* Static */) === staticFlag) { - result.push(getReferenceEntryFromNode(node)); - } - break; - case 248 /* SourceFile */: - if (container.kind === 248 /* SourceFile */ && !ts.isExternalModule(container)) { - result.push(getReferenceEntryFromNode(node)); - } - break; - } - }); - } - } - function populateSearchSymbolSet(symbol, location) { - // The search set contains at least the current symbol - var result = [symbol]; - // If the symbol is an alias, add what it alaises to the list - if (isImportOrExportSpecifierImportSymbol(symbol)) { - result.push(typeChecker.getAliasedSymbol(symbol)); - } - // If the location is in a context sensitive location (i.e. in an object literal) try - // to get a contextual type for it, and add the property symbol from the contextual - // type to the search set - if (isNameOfPropertyAssignment(location)) { - ts.forEach(getPropertySymbolsFromContextualType(location), function (contextualSymbol) { - ts.addRange(result, typeChecker.getRootSymbols(contextualSymbol)); - }); - /* Because in short-hand property assignment, location has two meaning : property name and as value of the property - * When we do findAllReference at the position of the short-hand property assignment, we would want to have references to position of - * property name and variable declaration of the identifier. - * Like in below example, when querying for all references for an identifier 'name', of the property assignment, the language service - * should show both 'name' in 'obj' and 'name' in variable declaration - * let name = "Foo"; - * let obj = { name }; - * In order to do that, we will populate the search set with the value symbol of the identifier as a value of the property assignment - * so that when matching with potential reference symbol, both symbols from property declaration and variable declaration - * will be included correctly. - */ - var shorthandValueSymbol = typeChecker.getShorthandAssignmentValueSymbol(location.parent); - if (shorthandValueSymbol) { - result.push(shorthandValueSymbol); - } - } - // If this is a union property, add all the symbols from all its source symbols in all unioned types. - // If the symbol is an instantiation from a another symbol (e.g. widened symbol) , add the root the list - ts.forEach(typeChecker.getRootSymbols(symbol), function (rootSymbol) { - if (rootSymbol !== symbol) { - result.push(rootSymbol); - } - // Add symbol of properties/methods of the same name in base classes and implemented interfaces definitions - if (rootSymbol.parent && rootSymbol.parent.flags & (32 /* Class */ | 64 /* Interface */)) { - getPropertySymbolsFromBaseTypes(rootSymbol.parent, rootSymbol.getName(), result); - } - }); - return result; - } - function getPropertySymbolsFromBaseTypes(symbol, propertyName, result) { - if (symbol && symbol.flags & (32 /* Class */ | 64 /* Interface */)) { - ts.forEach(symbol.getDeclarations(), function (declaration) { - if (declaration.kind === 214 /* ClassDeclaration */) { - getPropertySymbolFromTypeReference(ts.getClassExtendsHeritageClauseElement(declaration)); - ts.forEach(ts.getClassImplementsHeritageClauseElements(declaration), getPropertySymbolFromTypeReference); - } - else if (declaration.kind === 215 /* InterfaceDeclaration */) { - ts.forEach(ts.getInterfaceBaseTypeNodes(declaration), getPropertySymbolFromTypeReference); - } - }); - } - return; - function getPropertySymbolFromTypeReference(typeReference) { - if (typeReference) { - var type = typeChecker.getTypeAtLocation(typeReference); - if (type) { - var propertySymbol = typeChecker.getPropertyOfType(type, propertyName); - if (propertySymbol) { - result.push(propertySymbol); - } - // Visit the typeReference as well to see if it directly or indirectly use that property - getPropertySymbolsFromBaseTypes(type.symbol, propertyName, result); - } - } - } - } - function getRelatedSymbol(searchSymbols, referenceSymbol, referenceLocation) { - if (searchSymbols.indexOf(referenceSymbol) >= 0) { - return referenceSymbol; - } - // If the reference symbol is an alias, check if what it is aliasing is one of the search - // symbols. - if (isImportOrExportSpecifierImportSymbol(referenceSymbol)) { - var aliasedSymbol = typeChecker.getAliasedSymbol(referenceSymbol); - if (searchSymbols.indexOf(aliasedSymbol) >= 0) { - return aliasedSymbol; - } - } - // If the reference location is in an object literal, try to get the contextual type for the - // object literal, lookup the property symbol in the contextual type, and use this symbol to - // compare to our searchSymbol - if (isNameOfPropertyAssignment(referenceLocation)) { - return ts.forEach(getPropertySymbolsFromContextualType(referenceLocation), function (contextualSymbol) { - return ts.forEach(typeChecker.getRootSymbols(contextualSymbol), function (s) { return searchSymbols.indexOf(s) >= 0 ? s : undefined; }); - }); - } - // Unwrap symbols to get to the root (e.g. transient symbols as a result of widening) - // Or a union property, use its underlying unioned symbols - return ts.forEach(typeChecker.getRootSymbols(referenceSymbol), function (rootSymbol) { - // if it is in the list, then we are done - if (searchSymbols.indexOf(rootSymbol) >= 0) { - return rootSymbol; - } - // Finally, try all properties with the same name in any type the containing type extended or implemented, and - // see if any is in the list - if (rootSymbol.parent && rootSymbol.parent.flags & (32 /* Class */ | 64 /* Interface */)) { - var result_3 = []; - getPropertySymbolsFromBaseTypes(rootSymbol.parent, rootSymbol.getName(), result_3); - return ts.forEach(result_3, function (s) { return searchSymbols.indexOf(s) >= 0 ? s : undefined; }); - } - return undefined; - }); - } - function getPropertySymbolsFromContextualType(node) { - if (isNameOfPropertyAssignment(node)) { - var objectLiteral = node.parent.parent; - var contextualType = typeChecker.getContextualType(objectLiteral); - var name_34 = node.text; - if (contextualType) { - if (contextualType.flags & 16384 /* Union */) { - // This is a union type, first see if the property we are looking for is a union property (i.e. exists in all types) - // if not, search the constituent types for the property - var unionProperty = contextualType.getProperty(name_34); - if (unionProperty) { - return [unionProperty]; - } - else { - var result_4 = []; - ts.forEach(contextualType.types, function (t) { - var symbol = t.getProperty(name_34); - if (symbol) { - result_4.push(symbol); - } - }); - return result_4; - } - } - else { - var symbol_1 = contextualType.getProperty(name_34); - if (symbol_1) { - return [symbol_1]; - } - } - } - } - return undefined; - } - /** Given an initial searchMeaning, extracted from a location, widen the search scope based on the declarations - * of the corresponding symbol. e.g. if we are searching for "Foo" in value position, but "Foo" references a class - * then we need to widen the search to include type positions as well. - * On the contrary, if we are searching for "Bar" in type position and we trace bar to an interface, and an uninstantiated - * module, we want to keep the search limited to only types, as the two declarations (interface and uninstantiated module) - * do not intersect in any of the three spaces. - */ - function getIntersectingMeaningFromDeclarations(meaning, declarations) { - if (declarations) { - var lastIterationMeaning; - do { - // The result is order-sensitive, for instance if initialMeaning === Namespace, and declarations = [class, instantiated module] - // we need to consider both as they initialMeaning intersects with the module in the namespace space, and the module - // intersects with the class in the value space. - // To achieve that we will keep iterating until the result stabilizes. - // Remember the last meaning - lastIterationMeaning = meaning; - for (var _i = 0; _i < declarations.length; _i++) { - var declaration = declarations[_i]; - var declarationMeaning = getMeaningFromDeclaration(declaration); - if (declarationMeaning & meaning) { - meaning |= declarationMeaning; - } - } - } while (meaning !== lastIterationMeaning); - } - return meaning; - } - } - function getReferenceEntryFromNode(node) { - var start = node.getStart(); - var end = node.getEnd(); - if (node.kind === 9 /* StringLiteral */) { - start += 1; - end -= 1; - } - return { - fileName: node.getSourceFile().fileName, - textSpan: ts.createTextSpanFromBounds(start, end), - isWriteAccess: isWriteAccess(node) - }; - } - /** 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)) { - return true; - } - var parent = node.parent; - if (parent) { - if (parent.kind === 180 /* PostfixUnaryExpression */ || parent.kind === 179 /* PrefixUnaryExpression */) { - return true; - } - else if (parent.kind === 181 /* BinaryExpression */ && parent.left === node) { - var operator = parent.operatorToken.kind; - return 56 /* FirstAssignment */ <= operator && operator <= 68 /* LastAssignment */; - } - } - return false; - } - /// NavigateTo - function getNavigateToItems(searchValue, maxResultCount) { - synchronizeHostData(); - return ts.NavigateTo.getNavigateToItems(program, cancellationToken, searchValue, maxResultCount); - } - function containErrors(diagnostics) { - return ts.forEach(diagnostics, function (diagnostic) { return diagnostic.category === ts.DiagnosticCategory.Error; }); - } - function getEmitOutput(fileName) { - synchronizeHostData(); - var sourceFile = getValidSourceFile(fileName); - var outputFiles = []; - function writeFile(fileName, data, writeByteOrderMark) { - outputFiles.push({ - name: fileName, - writeByteOrderMark: writeByteOrderMark, - text: data - }); - } - var emitOutput = program.emit(sourceFile, writeFile, cancellationToken); - return { - outputFiles: outputFiles, - emitSkipped: emitOutput.emitSkipped - }; - } - function getMeaningFromDeclaration(node) { - switch (node.kind) { - case 138 /* Parameter */: - case 211 /* VariableDeclaration */: - case 163 /* BindingElement */: - case 141 /* PropertyDeclaration */: - case 140 /* PropertySignature */: - case 245 /* PropertyAssignment */: - case 246 /* ShorthandPropertyAssignment */: - case 247 /* EnumMember */: - case 143 /* MethodDeclaration */: - case 142 /* MethodSignature */: - case 144 /* Constructor */: - case 145 /* GetAccessor */: - case 146 /* SetAccessor */: - case 213 /* FunctionDeclaration */: - case 173 /* FunctionExpression */: - case 174 /* ArrowFunction */: - case 244 /* CatchClause */: - return 1 /* Value */; - case 137 /* TypeParameter */: - case 215 /* InterfaceDeclaration */: - case 216 /* TypeAliasDeclaration */: - case 155 /* TypeLiteral */: - return 2 /* Type */; - case 214 /* ClassDeclaration */: - case 217 /* EnumDeclaration */: - return 1 /* Value */ | 2 /* Type */; - case 218 /* ModuleDeclaration */: - if (node.name.kind === 9 /* StringLiteral */) { - return 4 /* Namespace */ | 1 /* Value */; - } - else if (ts.getModuleInstanceState(node) === 1 /* Instantiated */) { - return 4 /* Namespace */ | 1 /* Value */; - } - else { - return 4 /* Namespace */; - } - case 225 /* NamedImports */: - case 226 /* ImportSpecifier */: - case 221 /* ImportEqualsDeclaration */: - case 222 /* ImportDeclaration */: - case 227 /* ExportAssignment */: - case 228 /* ExportDeclaration */: - return 1 /* Value */ | 2 /* Type */ | 4 /* Namespace */; - // An external module can be a Value - case 248 /* SourceFile */: - return 4 /* Namespace */ | 1 /* Value */; - } - return 1 /* Value */ | 2 /* Type */ | 4 /* Namespace */; - ts.Debug.fail("Unknown declaration type"); - } - function isTypeReference(node) { - if (ts.isRightSideOfQualifiedNameOrPropertyAccess(node)) { - node = node.parent; - } - return node.parent.kind === 151 /* TypeReference */ || - (node.parent.kind === 188 /* ExpressionWithTypeArguments */ && !ts.isExpressionWithTypeArgumentsInClassExtendsClause(node.parent)) || - node.kind === 97 /* ThisKeyword */ && !ts.isExpression(node); - } - function isNamespaceReference(node) { - return isQualifiedNameNamespaceReference(node) || isPropertyAccessNamespaceReference(node); - } - function isPropertyAccessNamespaceReference(node) { - var root = node; - var isLastClause = true; - if (root.parent.kind === 166 /* PropertyAccessExpression */) { - while (root.parent && root.parent.kind === 166 /* PropertyAccessExpression */) { - root = root.parent; - } - isLastClause = root.name === node; - } - if (!isLastClause && root.parent.kind === 188 /* ExpressionWithTypeArguments */ && root.parent.parent.kind === 243 /* HeritageClause */) { - var decl = root.parent.parent.parent; - return (decl.kind === 214 /* ClassDeclaration */ && root.parent.parent.token === 106 /* ImplementsKeyword */) || - (decl.kind === 215 /* InterfaceDeclaration */ && root.parent.parent.token === 83 /* ExtendsKeyword */); - } - return false; - } - function isQualifiedNameNamespaceReference(node) { - var root = node; - var isLastClause = true; - if (root.parent.kind === 135 /* QualifiedName */) { - while (root.parent && root.parent.kind === 135 /* QualifiedName */) { - root = root.parent; - } - isLastClause = root.right === node; - } - return root.parent.kind === 151 /* TypeReference */ && !isLastClause; - } - function isInRightSideOfImport(node) { - while (node.parent.kind === 135 /* QualifiedName */) { - node = node.parent; - } - return ts.isInternalModuleImportEqualsDeclaration(node.parent) && node.parent.moduleReference === node; - } - function getMeaningFromRightHandSideOfImportEquals(node) { - ts.Debug.assert(node.kind === 69 /* Identifier */); - // import a = |b|; // Namespace - // import a = |b.c|; // Value, type, namespace - // import a = |b.c|.d; // Namespace - if (node.parent.kind === 135 /* QualifiedName */ && - node.parent.right === node && - node.parent.parent.kind === 221 /* ImportEqualsDeclaration */) { - return 1 /* Value */ | 2 /* Type */ | 4 /* Namespace */; - } - return 4 /* Namespace */; - } - function getMeaningFromLocation(node) { - if (node.parent.kind === 227 /* ExportAssignment */) { - return 1 /* Value */ | 2 /* Type */ | 4 /* Namespace */; - } - else if (isInRightSideOfImport(node)) { - return getMeaningFromRightHandSideOfImportEquals(node); - } - else if (ts.isDeclarationName(node)) { - return getMeaningFromDeclaration(node.parent); - } - else if (isTypeReference(node)) { - return 2 /* Type */; - } - else if (isNamespaceReference(node)) { - return 4 /* Namespace */; - } - else { - return 1 /* Value */; - } - } - // Signature help - /** - * This is a semantic operation. - */ - function getSignatureHelpItems(fileName, position) { - synchronizeHostData(); - var sourceFile = getValidSourceFile(fileName); - return ts.SignatureHelp.getSignatureHelpItems(program, sourceFile, position, cancellationToken); - } - /// Syntactic features - function getSourceFile(fileName) { - return syntaxTreeCache.getCurrentSourceFile(fileName); - } - function getNameOrDottedNameSpan(fileName, startPos, endPos) { - var sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName); - // Get node at the location - var node = ts.getTouchingPropertyName(sourceFile, startPos); - if (!node) { - return; - } - switch (node.kind) { - case 166 /* PropertyAccessExpression */: - case 135 /* QualifiedName */: - case 9 /* StringLiteral */: - case 84 /* FalseKeyword */: - case 99 /* TrueKeyword */: - case 93 /* NullKeyword */: - case 95 /* SuperKeyword */: - case 97 /* ThisKeyword */: - case 69 /* Identifier */: - break; - // Cant create the text span - default: - return; - } - var nodeForStartPos = node; - while (true) { - if (isRightSideOfPropertyAccess(nodeForStartPos) || isRightSideOfQualifiedName(nodeForStartPos)) { - // If on the span is in right side of the the property or qualified name, return the span from the qualified name pos to end of this node - nodeForStartPos = nodeForStartPos.parent; - } - else if (isNameOfModuleDeclaration(nodeForStartPos)) { - // 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 === 218 /* ModuleDeclaration */ && - nodeForStartPos.parent.parent.body === nodeForStartPos.parent) { - // Use parent module declarations name for start pos - nodeForStartPos = nodeForStartPos.parent.parent.name; - } - else { - // We have to use this name for start pos - break; - } - } - else { - // Is not a member expression so we have found the node for start pos - break; - } - } - return ts.createTextSpanFromBounds(nodeForStartPos.getStart(), node.getEnd()); - } - function getBreakpointStatementAtPosition(fileName, position) { - // doesn't use compiler - no need to synchronize with host - var sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName); - return ts.BreakpointResolver.spanInSourceFileAtLocation(sourceFile, position); - } - function getNavigationBarItems(fileName) { - var sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName); - return ts.NavigationBar.getNavigationBarItems(sourceFile); - } - function getSemanticClassifications(fileName, span) { - return convertClassifications(getEncodedSemanticClassifications(fileName, span)); - } - function checkForClassificationCancellation(kind) { - // We don't want to actually call back into our host on every node to find out if we've - // been canceled. That would be an enormous amount of chattyness, along with the all - // the overhead of marshalling the data to/from the host. So instead we pick a few - // reasonable node kinds to bother checking on. These node kinds represent high level - // constructs that we would expect to see commonly, but just at a far less frequent - // interval. - // - // For example, in checker.ts (around 750k) we only have around 600 of these constructs. - // 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 218 /* ModuleDeclaration */: - case 214 /* ClassDeclaration */: - case 215 /* InterfaceDeclaration */: - case 213 /* FunctionDeclaration */: - cancellationToken.throwIfCancellationRequested(); - } - } - function getEncodedSemanticClassifications(fileName, span) { - synchronizeHostData(); - var sourceFile = getValidSourceFile(fileName); - var typeChecker = program.getTypeChecker(); - var result = []; - var classifiableNames = program.getClassifiableNames(); - processNode(sourceFile); - return { spans: result, endOfLineState: 0 /* None */ }; - function pushClassification(start, length, type) { - result.push(start); - result.push(length); - result.push(type); - } - function classifySymbol(symbol, meaningAtPosition) { - var flags = symbol.getFlags(); - if ((flags & 788448 /* Classifiable */) === 0 /* None */) { - return; - } - if (flags & 32 /* Class */) { - return 11 /* className */; - } - else if (flags & 384 /* Enum */) { - return 12 /* enumName */; - } - else if (flags & 524288 /* TypeAlias */) { - return 16 /* typeAliasName */; - } - else if (meaningAtPosition & 2 /* Type */) { - if (flags & 64 /* Interface */) { - return 13 /* interfaceName */; - } - else if (flags & 262144 /* TypeParameter */) { - return 15 /* typeParameterName */; - } - } - else if (flags & 1536 /* Module */) { - // Only classify a module as such if - // - It appears in a namespace context. - // - There exists a module declaration which actually impacts the value side. - if (meaningAtPosition & 4 /* Namespace */ || - (meaningAtPosition & 1 /* Value */ && hasValueSideModule(symbol))) { - return 14 /* moduleName */; - } - } - return undefined; - /** - * Returns true if there exists a module that introduces entities on the value side. - */ - function hasValueSideModule(symbol) { - return ts.forEach(symbol.declarations, function (declaration) { - return declaration.kind === 218 /* ModuleDeclaration */ && - ts.getModuleInstanceState(declaration) === 1 /* Instantiated */; - }); - } - } - function processNode(node) { - // Only walk into nodes that intersect the requested span. - if (node && ts.textSpanIntersectsWith(span, node.getFullStart(), node.getFullWidth())) { - var kind = node.kind; - checkForClassificationCancellation(kind); - if (kind === 69 /* Identifier */ && !ts.nodeIsMissing(node)) { - var identifier = node; - // Only bother calling into the typechecker if this is an identifier that - // could possibly resolve to a type name. This makes classification run - // in a third of the time it would normally take. - if (classifiableNames[identifier.text]) { - var symbol = typeChecker.getSymbolAtLocation(node); - if (symbol) { - var type = classifySymbol(symbol, getMeaningFromLocation(node)); - if (type) { - pushClassification(node.getStart(), node.getWidth(), type); - } - } - } - } - ts.forEachChild(node, processNode); - } - } - } - function getClassificationTypeName(type) { - switch (type) { - case 1 /* comment */: return ClassificationTypeNames.comment; - case 2 /* identifier */: return ClassificationTypeNames.identifier; - case 3 /* keyword */: return ClassificationTypeNames.keyword; - case 4 /* numericLiteral */: return ClassificationTypeNames.numericLiteral; - case 5 /* operator */: return ClassificationTypeNames.operator; - case 6 /* stringLiteral */: return ClassificationTypeNames.stringLiteral; - case 8 /* whiteSpace */: return ClassificationTypeNames.whiteSpace; - case 9 /* text */: return ClassificationTypeNames.text; - case 10 /* punctuation */: return ClassificationTypeNames.punctuation; - case 11 /* className */: return ClassificationTypeNames.className; - case 12 /* enumName */: return ClassificationTypeNames.enumName; - case 13 /* interfaceName */: return ClassificationTypeNames.interfaceName; - case 14 /* moduleName */: return ClassificationTypeNames.moduleName; - case 15 /* typeParameterName */: return ClassificationTypeNames.typeParameterName; - case 16 /* typeAliasName */: return ClassificationTypeNames.typeAliasName; - case 17 /* parameterName */: return ClassificationTypeNames.parameterName; - case 18 /* docCommentTagName */: return ClassificationTypeNames.docCommentTagName; - } - } - function convertClassifications(classifications) { - ts.Debug.assert(classifications.spans.length % 3 === 0); - var dense = classifications.spans; - var result = []; - for (var i = 0, n = dense.length; i < n; i += 3) { - result.push({ - textSpan: ts.createTextSpan(dense[i], dense[i + 1]), - classificationType: getClassificationTypeName(dense[i + 2]) - }); - } - return result; - } - function getSyntacticClassifications(fileName, span) { - return convertClassifications(getEncodedSyntacticClassifications(fileName, span)); - } - function getEncodedSyntacticClassifications(fileName, span) { - // doesn't use compiler - no need to synchronize with host - var sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName); - 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 result = []; - processElement(sourceFile); - return { spans: result, endOfLineState: 0 /* None */ }; - function pushClassification(start, length, type) { - result.push(start); - result.push(length); - result.push(type); - } - function classifyLeadingTriviaAndGetTokenStart(token) { - triviaScanner.setTextPos(token.pos); - while (true) { - var start = triviaScanner.getTextPos(); - // only bother scanning if we have something that could be trivia. - if (!ts.couldStartTrivia(sourceFile.text, start)) { - return start; - } - var kind = triviaScanner.scan(); - var end = triviaScanner.getTextPos(); - var width = end - start; - // The moment we get something that isn't trivia, then stop processing. - if (!ts.isTrivia(kind)) { - return start; - } - // Don't bother with newlines/whitespace. - if (kind === 4 /* NewLineTrivia */ || kind === 5 /* WhitespaceTrivia */) { - continue; - } - // Only bother with the trivia if it at least intersects the span of interest. - if (ts.isComment(kind)) { - classifyComment(token, kind, start, width); - // Classifying a comment might cause us to reuse the trivia scanner - // (because of jsdoc comments). So after we classify the comment make - // sure we set the scanner position back to where it needs to be. - triviaScanner.setTextPos(end); - continue; - } - if (kind === 7 /* ConflictMarkerTrivia */) { - var text = sourceFile.text; - var ch = text.charCodeAt(start); - // for the <<<<<<< and >>>>>>> markers, we just add them in as comments - // in the classification stream. - if (ch === 60 /* lessThan */ || ch === 62 /* greaterThan */) { - pushClassification(start, width, 1 /* comment */); - continue; - } - // for the ======== add a comment for the first line, and then lex all - // subsequent lines up until the end of the conflict marker. - ts.Debug.assert(ch === 61 /* equals */); - classifyDisabledMergeCode(text, start, end); - } - } - } - function classifyComment(token, kind, start, width) { - if (kind === 3 /* MultiLineCommentTrivia */) { - // See if this is a doc comment. If so, we'll classify certain portions of it - // specially. - var docCommentAndDiagnostics = ts.parseIsolatedJSDocComment(sourceFile.text, start, width); - if (docCommentAndDiagnostics && docCommentAndDiagnostics.jsDocComment) { - docCommentAndDiagnostics.jsDocComment.parent = token; - classifyJSDocComment(docCommentAndDiagnostics.jsDocComment); - return; - } - } - // Simple comment. Just add as is. - pushCommentRange(start, width); - } - function pushCommentRange(start, width) { - pushClassification(start, width, 1 /* comment */); - } - function classifyJSDocComment(docComment) { - var pos = docComment.pos; - for (var _i = 0, _a = docComment.tags; _i < _a.length; _i++) { - var tag = _a[_i]; - // As we walk through each tag, classify the portion of text from the end of - // the last tag (or the start of the entire doc comment) as 'comment'. - if (tag.pos !== pos) { - pushCommentRange(pos, tag.pos - pos); - } - pushClassification(tag.atToken.pos, tag.atToken.end - tag.atToken.pos, 10 /* punctuation */); - pushClassification(tag.tagName.pos, tag.tagName.end - tag.tagName.pos, 18 /* docCommentTagName */); - pos = tag.tagName.end; - switch (tag.kind) { - case 267 /* JSDocParameterTag */: - processJSDocParameterTag(tag); - break; - case 270 /* JSDocTemplateTag */: - processJSDocTemplateTag(tag); - break; - case 269 /* JSDocTypeTag */: - processElement(tag.typeExpression); - break; - case 268 /* JSDocReturnTag */: - processElement(tag.typeExpression); - break; - } - pos = tag.end; - } - if (pos !== docComment.end) { - pushCommentRange(pos, docComment.end - pos); - } - return; - function processJSDocParameterTag(tag) { - if (tag.preParameterName) { - pushCommentRange(pos, tag.preParameterName.pos - pos); - pushClassification(tag.preParameterName.pos, tag.preParameterName.end - tag.preParameterName.pos, 17 /* parameterName */); - pos = tag.preParameterName.end; - } - if (tag.typeExpression) { - pushCommentRange(pos, tag.typeExpression.pos - pos); - processElement(tag.typeExpression); - pos = tag.typeExpression.end; - } - if (tag.postParameterName) { - pushCommentRange(pos, tag.postParameterName.pos - pos); - pushClassification(tag.postParameterName.pos, tag.postParameterName.end - tag.postParameterName.pos, 17 /* parameterName */); - pos = tag.postParameterName.end; - } - } - } - function processJSDocTemplateTag(tag) { - for (var _i = 0, _a = tag.getChildren(); _i < _a.length; _i++) { - var child = _a[_i]; - processElement(child); - } - } - function classifyDisabledMergeCode(text, start, end) { - // Classify the line that the ======= marker is on as a comment. Then just lex - // all further tokens and add them to the result. - for (var i = start; i < end; i++) { - if (ts.isLineBreak(text.charCodeAt(i))) { - break; - } - } - pushClassification(start, i - start, 1 /* comment */); - mergeConflictScanner.setTextPos(i); - while (mergeConflictScanner.getTextPos() < end) { - classifyDisabledCodeToken(); - } - } - function classifyDisabledCodeToken() { - var start = mergeConflictScanner.getTextPos(); - var tokenKind = mergeConflictScanner.scan(); - var end = mergeConflictScanner.getTextPos(); - var type = classifyTokenType(tokenKind); - if (type) { - pushClassification(start, end - start, type); - } - } - function classifyToken(token) { - if (ts.nodeIsMissing(token)) { - return; - } - var tokenStart = classifyLeadingTriviaAndGetTokenStart(token); - var tokenWidth = token.end - tokenStart; - ts.Debug.assert(tokenWidth >= 0); - if (tokenWidth > 0) { - var type = classifyTokenType(token.kind, token); - if (type) { - pushClassification(tokenStart, tokenWidth, type); - } - } - } - // for accurate classification, the actual token should be passed in. however, for - // cases like 'disabled merge code' classification, we just get the token kind and - // classify based on that instead. - function classifyTokenType(tokenKind, token) { - if (ts.isKeyword(tokenKind)) { - return 3 /* keyword */; - } - // Special case < and > If they appear in a generic context they are punctuation, - // not operators. - if (tokenKind === 25 /* LessThanToken */ || tokenKind === 27 /* 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)) { - return 10 /* punctuation */; - } - } - if (ts.isPunctuation(tokenKind)) { - if (token) { - if (tokenKind === 56 /* EqualsToken */) { - // the '=' in a variable declaration is special cased here. - if (token.parent.kind === 211 /* VariableDeclaration */ || - token.parent.kind === 141 /* PropertyDeclaration */ || - token.parent.kind === 138 /* Parameter */) { - return 5 /* operator */; - } - } - if (token.parent.kind === 181 /* BinaryExpression */ || - token.parent.kind === 179 /* PrefixUnaryExpression */ || - token.parent.kind === 180 /* PostfixUnaryExpression */ || - token.parent.kind === 182 /* ConditionalExpression */) { - return 5 /* operator */; - } - } - return 10 /* punctuation */; - } - else if (tokenKind === 8 /* NumericLiteral */) { - return 4 /* numericLiteral */; - } - else if (tokenKind === 9 /* StringLiteral */) { - return 6 /* stringLiteral */; - } - else if (tokenKind === 10 /* RegularExpressionLiteral */) { - // TODO: we should get another classification type for these literals. - return 6 /* stringLiteral */; - } - else if (ts.isTemplateLiteralKind(tokenKind)) { - // TODO (drosen): we should *also* get another classification type for these literals. - return 6 /* stringLiteral */; - } - else if (tokenKind === 69 /* Identifier */) { - if (token) { - switch (token.parent.kind) { - case 214 /* ClassDeclaration */: - if (token.parent.name === token) { - return 11 /* className */; - } - return; - case 137 /* TypeParameter */: - if (token.parent.name === token) { - return 15 /* typeParameterName */; - } - return; - case 215 /* InterfaceDeclaration */: - if (token.parent.name === token) { - return 13 /* interfaceName */; - } - return; - case 217 /* EnumDeclaration */: - if (token.parent.name === token) { - return 12 /* enumName */; - } - return; - case 218 /* ModuleDeclaration */: - if (token.parent.name === token) { - return 14 /* moduleName */; - } - return; - case 138 /* Parameter */: - if (token.parent.name === token) { - return 17 /* parameterName */; - } - return; - } - } - return 2 /* identifier */; - } - } - function processElement(element) { - if (!element) { - return; - } - // Ignore nodes that don't intersect the original span to classify. - if (ts.decodedTextSpanIntersectsWith(spanStart, spanLength, element.pos, element.getFullWidth())) { - checkForClassificationCancellation(element.kind); - var children = element.getChildren(sourceFile); - for (var i = 0, n = children.length; i < n; i++) { - var child = children[i]; - if (ts.isToken(child)) { - classifyToken(child); - } - else { - // Recurse into our child nodes. - processElement(child); - } - } - } - } - } - function getOutliningSpans(fileName) { - // doesn't use compiler - no need to synchronize with host - var sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName); - return ts.OutliningElementsCollector.collectElements(sourceFile); - } - function getBraceMatchingAtPosition(fileName, position) { - var sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName); - var result = []; - var token = ts.getTouchingToken(sourceFile, position); - if (token.getStart(sourceFile) === position) { - var matchKind = getMatchingTokenKind(token); - // Ensure that there is a corresponding token to match ours. - if (matchKind) { - var parentElement = token.parent; - var childNodes = parentElement.getChildren(sourceFile); - for (var _i = 0; _i < childNodes.length; _i++) { - var current = childNodes[_i]; - if (current.kind === matchKind) { - var range1 = ts.createTextSpan(token.getStart(sourceFile), token.getWidth(sourceFile)); - var range2 = ts.createTextSpan(current.getStart(sourceFile), current.getWidth(sourceFile)); - // We want to order the braces when we return the result. - if (range1.start < range2.start) { - result.push(range1, range2); - } - else { - result.push(range2, range1); - } - break; - } - } - } - } - 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 */; - } - return undefined; - } - } - function getIndentationAtPosition(fileName, position, editorOptions) { - var start = new Date().getTime(); - var sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName); - log("getIndentationAtPosition: getCurrentSourceFile: " + (new Date().getTime() - start)); - start = new Date().getTime(); - var result = ts.formatting.SmartIndenter.getIndentation(position, sourceFile, editorOptions); - log("getIndentationAtPosition: computeIndentation : " + (new Date().getTime() - start)); - return result; - } - function getFormattingEditsForRange(fileName, start, end, options) { - var sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName); - return ts.formatting.formatSelection(start, end, sourceFile, getRuleProvider(options), options); - } - function getFormattingEditsForDocument(fileName, options) { - var sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName); - return ts.formatting.formatDocument(sourceFile, getRuleProvider(options), options); - } - function getFormattingEditsAfterKeystroke(fileName, position, key, options) { - var sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName); - if (key === "}") { - return ts.formatting.formatOnClosingCurly(position, sourceFile, getRuleProvider(options), options); - } - else if (key === ";") { - return ts.formatting.formatOnSemicolon(position, sourceFile, getRuleProvider(options), options); - } - else if (key === "\n") { - return ts.formatting.formatOnEnter(position, sourceFile, getRuleProvider(options), options); - } - return []; - } - /** - * Checks if position points to a valid position to add JSDoc comments, and if so, - * returns the appropriate template. Otherwise returns an empty string. - * Valid positions are - * - outside of comments, statements, and expressions, and - * - preceding a: - * - function/constructor/method declaration - * - class declarations - * - variable statements - * - namespace declarations - * - * Hosts should ideally check that: - * - The line is all whitespace up to 'position' before performing the insertion. - * - If the keystroke sequence "/\*\*" induced the call, we also check that the next - * non-whitespace character is '*', which (approximately) indicates whether we added - * the second '*' to complete an existing (JSDoc) comment. - * @param fileName The file in which to perform the check. - * @param position The (character-indexed) position in the file where the check should - * be performed. - */ - function getDocCommentTemplateAtPosition(fileName, position) { - var start = new Date().getTime(); - var sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName); - // Check if in a context where we don't want to perform any insertion - if (ts.isInString(sourceFile, position) || ts.isInComment(sourceFile, position) || ts.hasDocComment(sourceFile, position)) { - return undefined; - } - var tokenAtPos = ts.getTokenAtPosition(sourceFile, position); - var tokenStart = tokenAtPos.getStart(); - if (!tokenAtPos || tokenStart < position) { - return undefined; - } - // TODO: add support for: - // - enums/enum members - // - interfaces - // - property declarations - // - potentially property assignments - var commentOwner; - findOwner: for (commentOwner = tokenAtPos; commentOwner; commentOwner = commentOwner.parent) { - switch (commentOwner.kind) { - case 213 /* FunctionDeclaration */: - case 143 /* MethodDeclaration */: - case 144 /* Constructor */: - case 214 /* ClassDeclaration */: - case 193 /* VariableStatement */: - break findOwner; - case 248 /* SourceFile */: - return undefined; - case 218 /* ModuleDeclaration */: - // If in walking up the tree, we hit a a nested namespace declaration, - // then we must be somewhere within a dotted namespace name; however we don't - // want to give back a JSDoc template for the 'b' or 'c' in 'namespace a.b.c { }'. - if (commentOwner.parent.kind === 218 /* ModuleDeclaration */) { - return undefined; - } - break findOwner; - } - } - if (!commentOwner || commentOwner.getStart() < position) { - return undefined; - } - var parameters = getParametersForJsDocOwningNode(commentOwner); - var posLineAndChar = sourceFile.getLineAndCharacterOfPosition(position); - var lineStart = sourceFile.getLineStarts()[posLineAndChar.line]; - var indentationStr = sourceFile.text.substr(lineStart, posLineAndChar.character); - // TODO: call a helper method instead once PR #4133 gets merged in. - var newLine = host.getNewLine ? host.getNewLine() : "\r\n"; - var docParams = ""; - for (var i = 0, numParams = parameters.length; i < numParams; i++) { - var currentName = parameters[i].name; - var paramName = currentName.kind === 69 /* Identifier */ ? - currentName.text : - "param" + i; - docParams += indentationStr + " * @param " + paramName + newLine; - } - // A doc comment consists of the following - // * The opening comment line - // * the first line (without a param) for the object's untagged info (this is also where the caret ends up) - // * the '@param'-tagged lines - // * TODO: other tags. - // * the closing comment line - // * if the caret was directly in front of the object, then we add an extra line and indentation. - var preamble = "/**" + newLine + - indentationStr + " * "; - var result = preamble + newLine + - docParams + - indentationStr + " */" + - (tokenStart === position ? newLine + indentationStr : ""); - return { newText: result, caretOffset: preamble.length }; - } - function getParametersForJsDocOwningNode(commentOwner) { - if (ts.isFunctionLike(commentOwner)) { - return commentOwner.parameters; - } - if (commentOwner.kind === 193 /* VariableStatement */) { - var varStatement = commentOwner; - var varDeclarations = varStatement.declarationList.declarations; - if (varDeclarations.length === 1 && varDeclarations[0].initializer) { - return getParametersFromRightHandSideOfAssignment(varDeclarations[0].initializer); - } - } - return emptyArray; - } - /** - * Digs into an an initializer or RHS operand of an assignment operation - * to get the parameters of an apt signature corresponding to a - * function expression or a class expression. - * - * @param rightHandSide the expression which may contain an appropriate set of parameters - * @returns the parameters of a signature found on the RHS if one exists; otherwise 'emptyArray'. - */ - function getParametersFromRightHandSideOfAssignment(rightHandSide) { - while (rightHandSide.kind === 172 /* ParenthesizedExpression */) { - rightHandSide = rightHandSide.expression; - } - switch (rightHandSide.kind) { - case 173 /* FunctionExpression */: - case 174 /* ArrowFunction */: - return rightHandSide.parameters; - case 186 /* ClassExpression */: - for (var _i = 0, _a = rightHandSide.members; _i < _a.length; _i++) { - var member = _a[_i]; - if (member.kind === 144 /* Constructor */) { - return member.parameters; - } - } - break; - } - return emptyArray; - } - function getTodoComments(fileName, descriptors) { - // Note: while getting todo comments seems like a syntactic operation, we actually - // treat it as a semantic operation here. This is because we expect our host to call - // this on every single file. If we treat this syntactically, then that will cause - // us to populate and throw away the tree in our syntax tree cache for each file. By - // treating this as a semantic operation, we can access any tree without throwing - // anything away. - synchronizeHostData(); - var sourceFile = getValidSourceFile(fileName); - cancellationToken.throwIfCancellationRequested(); - var fileContents = sourceFile.text; - var result = []; - if (descriptors.length > 0) { - var regExp = getTodoCommentsRegExp(); - var matchArray; - while (matchArray = regExp.exec(fileContents)) { - cancellationToken.throwIfCancellationRequested(); - // If we got a match, here is what the match array will look like. Say the source text is: - // - // " // hack 1" - // - // The result array with the regexp: will be: - // - // ["// hack 1", "// ", "hack 1", undefined, "hack"] - // - // Here are the relevant capture groups: - // 0) The full match for the entire regexp. - // 1) The preamble to the message portion. - // 2) The message portion. - // 3...N) The descriptor that was matched - by index. 'undefined' for each - // descriptor that didn't match. an actual value if it did match. - // - // i.e. 'undefined' in position 3 above means TODO(jason) didn't match. - // "hack" in position 4 means HACK did match. - var firstDescriptorCaptureIndex = 3; - ts.Debug.assert(matchArray.length === descriptors.length + firstDescriptorCaptureIndex); - var preamble = matchArray[1]; - var matchPosition = matchArray.index + preamble.length; - // OK, we have found a match in the file. This is only an acceptable match if - // it is contained within a comment. - var token = ts.getTokenAtPosition(sourceFile, matchPosition); - if (!isInsideComment(sourceFile, token, matchPosition)) { - continue; - } - var descriptor = undefined; - for (var i = 0, n = descriptors.length; i < n; i++) { - if (matchArray[i + firstDescriptorCaptureIndex]) { - descriptor = descriptors[i]; - } - } - ts.Debug.assert(descriptor !== undefined); - // We don't want to match something like 'TODOBY', so we make sure a non - // letter/digit follows the match. - if (isLetterOrDigit(fileContents.charCodeAt(matchPosition + descriptor.text.length))) { - continue; - } - var message = matchArray[2]; - result.push({ - descriptor: descriptor, - message: message, - position: matchPosition - }); - } - } - return result; - function escapeRegExp(str) { - return str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&"); - } - function getTodoCommentsRegExp() { - // NOTE: ?: means 'non-capture group'. It allows us to have groups without having to - // filter them out later in the final result array. - // TODO comments can appear in one of the following forms: - // - // 1) // TODO or /////////// TODO - // - // 2) /* TODO or /********** TODO - // - // 3) /* - // * TODO - // */ - // - // The following three regexps are used to match the start of the text up to the TODO - // comment portion. - var singleLineCommentStart = /(?:\/\/+\s*)/.source; - var multiLineCommentStart = /(?:\/\*+\s*)/.source; - var anyNumberOfSpacesAndAsterixesAtStartOfLine = /(?:^(?:\s|\*)*)/.source; - // Match any of the above three TODO comment start regexps. - // Note that the outermost group *is* a capture group. We want to capture the preamble - // so that we can determine the starting position of the TODO comment match. - var preamble = "(" + anyNumberOfSpacesAndAsterixesAtStartOfLine + "|" + singleLineCommentStart + "|" + multiLineCommentStart + ")"; - // Takes the descriptors and forms a regexp that matches them as if they were literals. - // For example, if the descriptors are "TODO(jason)" and "HACK", then this will be: - // - // (?:(TODO\(jason\))|(HACK)) - // - // Note that the outermost group is *not* a capture group, but the innermost groups - // *are* capture groups. By capturing the inner literals we can determine after - // matching which descriptor we are dealing with. - var literals = "(?:" + ts.map(descriptors, function (d) { return "(" + escapeRegExp(d.text) + ")"; }).join("|") + ")"; - // After matching a descriptor literal, the following regexp matches the rest of the - // text up to the end of the line (or */). - var endOfLineOrEndOfComment = /(?:$|\*\/)/.source; - var messageRemainder = /(?:.*?)/.source; - // This is the portion of the match we'll return as part of the TODO comment result. We - // match the literal portion up to the end of the line or end of comment. - var messagePortion = "(" + literals + messageRemainder + ")"; - var regExpString = preamble + messagePortion + endOfLineOrEndOfComment; - // The final regexp will look like this: - // /((?:\/\/+\s*)|(?:\/\*+\s*)|(?:^(?:\s|\*)*))((?:(TODO\(jason\))|(HACK))(?:.*?))(?:$|\*\/)/gim - // The flags of the regexp are important here. - // 'g' is so that we are doing a global search and can find matches several times - // in the input. - // - // 'i' is for case insensitivity (We do this to match C# TODO comment code). - // - // 'm' is so we can find matches in a multi-line input. - return new RegExp(regExpString, "gim"); - } - function isLetterOrDigit(char) { - return (char >= 97 /* a */ && char <= 122 /* z */) || - (char >= 65 /* A */ && char <= 90 /* Z */) || - (char >= 48 /* _0 */ && char <= 57 /* _9 */); - } - } - function getRenameInfo(fileName, position) { - synchronizeHostData(); - var sourceFile = getValidSourceFile(fileName); - var typeChecker = program.getTypeChecker(); - var node = ts.getTouchingWord(sourceFile, position); - // Can only rename an identifier. - if (node && node.kind === 69 /* Identifier */) { - var symbol = typeChecker.getSymbolAtLocation(node); - // Only allow a symbol to be renamed if it actually has at least one declaration. - if (symbol) { - var declarations = symbol.getDeclarations(); - if (declarations && declarations.length > 0) { - // Disallow rename for elements that are defined in the standard TypeScript library. - var defaultLibFileName = host.getDefaultLibFileName(host.getCompilationSettings()); - if (defaultLibFileName) { - for (var _i = 0; _i < declarations.length; _i++) { - var current = declarations[_i]; - var sourceFile_2 = current.getSourceFile(); - var canonicalName = getCanonicalFileName(ts.normalizePath(sourceFile_2.fileName)); - if (sourceFile_2 && getCanonicalFileName(ts.normalizePath(sourceFile_2.fileName)) === getCanonicalFileName(ts.normalizePath(defaultLibFileName))) { - return getRenameInfoError(ts.getLocaleSpecificMessage(ts.Diagnostics.You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library.key)); - } - } - } - var displayName = ts.stripQuotes(ts.getDeclaredName(typeChecker, symbol, node)); - var kind = getSymbolKind(symbol, node); - if (kind) { - return { - canRename: true, - localizedErrorMessage: undefined, - displayName: displayName, - fullDisplayName: typeChecker.getFullyQualifiedName(symbol), - kind: kind, - kindModifiers: getSymbolModifiers(symbol), - triggerSpan: ts.createTextSpan(node.getStart(), node.getWidth()) - }; - } - } - } - } - return getRenameInfoError(ts.getLocaleSpecificMessage(ts.Diagnostics.You_cannot_rename_this_element.key)); - function getRenameInfoError(localizedErrorMessage) { - return { - canRename: false, - localizedErrorMessage: localizedErrorMessage, - displayName: undefined, - fullDisplayName: undefined, - kind: undefined, - kindModifiers: undefined, - triggerSpan: undefined - }; - } - } - return { - dispose: dispose, - cleanupSemanticCache: cleanupSemanticCache, - getSyntacticDiagnostics: getSyntacticDiagnostics, - getSemanticDiagnostics: getSemanticDiagnostics, - getCompilerOptionsDiagnostics: getCompilerOptionsDiagnostics, - getSyntacticClassifications: getSyntacticClassifications, - getSemanticClassifications: getSemanticClassifications, - getEncodedSyntacticClassifications: getEncodedSyntacticClassifications, - getEncodedSemanticClassifications: getEncodedSemanticClassifications, - getCompletionsAtPosition: getCompletionsAtPosition, - getCompletionEntryDetails: getCompletionEntryDetails, - getSignatureHelpItems: getSignatureHelpItems, - getQuickInfoAtPosition: getQuickInfoAtPosition, - getDefinitionAtPosition: getDefinitionAtPosition, - getTypeDefinitionAtPosition: getTypeDefinitionAtPosition, - getReferencesAtPosition: getReferencesAtPosition, - findReferences: findReferences, - getOccurrencesAtPosition: getOccurrencesAtPosition, - getDocumentHighlights: getDocumentHighlights, - getNameOrDottedNameSpan: getNameOrDottedNameSpan, - getBreakpointStatementAtPosition: getBreakpointStatementAtPosition, - getNavigateToItems: getNavigateToItems, - getRenameInfo: getRenameInfo, - findRenameLocations: findRenameLocations, - getNavigationBarItems: getNavigationBarItems, - getOutliningSpans: getOutliningSpans, - getTodoComments: getTodoComments, - getBraceMatchingAtPosition: getBraceMatchingAtPosition, - getIndentationAtPosition: getIndentationAtPosition, - getFormattingEditsForRange: getFormattingEditsForRange, - getFormattingEditsForDocument: getFormattingEditsForDocument, - getFormattingEditsAfterKeystroke: getFormattingEditsAfterKeystroke, - getDocCommentTemplateAtPosition: getDocCommentTemplateAtPosition, - getEmitOutput: getEmitOutput, - getSourceFile: getSourceFile, - getProgram: getProgram - }; - } - ts.createLanguageService = createLanguageService; - /* @internal */ - function getNameTable(sourceFile) { - if (!sourceFile.nameTable) { - initializeNameTable(sourceFile); - } - return sourceFile.nameTable; - } - ts.getNameTable = getNameTable; - function initializeNameTable(sourceFile) { - var nameTable = {}; - walk(sourceFile); - sourceFile.nameTable = nameTable; - function walk(node) { - switch (node.kind) { - case 69 /* Identifier */: - nameTable[node.text] = node.text; - break; - case 9 /* StringLiteral */: - case 8 /* NumericLiteral */: - // We want to store any numbers/strings if they were a name that could be - // related to a declaration. So, if we have 'import x = require("something")' - // 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 === 232 /* ExternalModuleReference */ || - isArgumentOfElementAccessExpression(node)) { - nameTable[node.text] = node.text; - } - break; - default: - ts.forEachChild(node, walk); - } - } - } - function isArgumentOfElementAccessExpression(node) { - return node && - node.parent && - node.parent.kind === 167 /* ElementAccessExpression */ && - node.parent.argumentExpression === node; - } - /// Classifier - function createClassifier() { - var scanner = ts.createScanner(2 /* 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[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; - // 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 - // lines, just as we do with the end-of-line state. However, this is a burden for implementers, - // and the behavior is entirely subsumed by the syntactic classifier anyway, so we instead - // flatten any nesting when the template stack is non-empty and encode it in the end-of-line state. - // Situations in which this fails are - // 1) When template strings are nested across different lines: - // `hello ${ `world - // ` }` - // - // Where on the second line, you will get the closing of a template, - // a closing curly, and a new template. - // - // 2) When substitution expressions have curly braces and the curly brace falls on the next line: - // `hello ${ () => { - // return "world" } } ` - // - // Where on the second line, you will get the 'return' keyword, - // a string literal, and a template end consisting of '} } `'. - var templateStack = []; - /** 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 === 129 /* SetKeyword */ || - keyword2 === 121 /* ConstructorKeyword */ || - keyword2 === 113 /* StaticKeyword */) { - // Allow things like "public get", "public constructor" and "public static". - // These are all legal. - return true; - } - // Any other keyword following "public" is actually an identifier an not a real - // keyword. - return false; - } - // Assume any other keyword combination is legal. This can be refined in the future - // if there are more cases we want the classifier to be better at. - return true; - } - function convertClassifications(classifications, text) { - var entries = []; - var dense = classifications.spans; - var lastEnd = 0; - for (var i = 0, n = dense.length; i < n; i += 3) { - var start = dense[i]; - var length_3 = dense[i + 1]; - var type = dense[i + 2]; - // Make a whitespace entry between the last item and this one. - if (lastEnd >= 0) { - var whitespaceLength_1 = start - lastEnd; - if (whitespaceLength_1 > 0) { - entries.push({ length: whitespaceLength_1, classification: TokenClass.Whitespace }); - } - } - entries.push({ length: length_3, classification: convertClassification(type) }); - lastEnd = start + length_3; - } - var whitespaceLength = text.length - lastEnd; - if (whitespaceLength > 0) { - entries.push({ length: whitespaceLength, classification: TokenClass.Whitespace }); - } - return { entries: entries, finalLexState: classifications.endOfLineState }; - } - function convertClassification(type) { - switch (type) { - case 1 /* comment */: return TokenClass.Comment; - case 3 /* keyword */: return TokenClass.Keyword; - case 4 /* numericLiteral */: return TokenClass.NumberLiteral; - case 5 /* operator */: return TokenClass.Operator; - case 6 /* stringLiteral */: return TokenClass.StringLiteral; - case 8 /* whiteSpace */: return TokenClass.Whitespace; - case 10 /* punctuation */: return TokenClass.Punctuation; - case 2 /* identifier */: - case 11 /* className */: - case 12 /* enumName */: - case 13 /* interfaceName */: - case 14 /* moduleName */: - case 15 /* typeParameterName */: - case 16 /* typeAliasName */: - case 9 /* text */: - case 17 /* parameterName */: - default: - return TokenClass.Identifier; - } - } - function getClassificationsForLine(text, lexState, syntacticClassifierAbsent) { - return convertClassifications(getEncodedLexicalClassifications(text, lexState, syntacticClassifierAbsent), text); - } - // If there is a syntactic classifier ('syntacticClassifierAbsent' is false), - // we will be more conservative in order to avoid conflicting with the syntactic classifier. - function getEncodedLexicalClassifications(text, lexState, syntacticClassifierAbsent) { - var offset = 0; - var token = 0 /* Unknown */; - var lastNonTriviaToken = 0 /* Unknown */; - // Empty out the template stack for reuse. - while (templateStack.length > 0) { - templateStack.pop(); - } - // If we're in a string literal, then prepend: "\ - // (and a newline). That way when we lex we'll think we're still in a string literal. - // - // If we're in a multiline comment, then prepend: /* - // (and a newline). That way when we lex we'll think we're still in a multiline comment. - switch (lexState) { - case 3 /* InDoubleQuoteStringLiteral */: - text = '"\\\n' + text; - offset = 3; - break; - case 2 /* InSingleQuoteStringLiteral */: - text = "'\\\n" + text; - offset = 3; - break; - case 1 /* InMultiLineCommentTrivia */: - text = "/*\n" + text; - offset = 3; - break; - case 4 /* InTemplateHeadOrNoSubstitutionTemplate */: - text = "`\n" + text; - offset = 2; - break; - case 5 /* InTemplateMiddleOrTail */: - text = "}\n" + text; - offset = 2; - // fallthrough - case 6 /* InTemplateSubstitutionPosition */: - templateStack.push(12 /* TemplateHead */); - break; - } - scanner.setText(text); - var result = { - endOfLineState: 0 /* None */, - spans: [] - }; - // We can run into an unfortunate interaction between the lexical and syntactic classifier - // when the user is typing something generic. Consider the case where the user types: - // - // Foo tokens. It's a weak heuristic, but should - // work well enough in practice. - var angleBracketStack = 0; - 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 */; - } - } - else if (lastNonTriviaToken === 21 /* DotToken */ && isKeyword(token)) { - token = 69 /* Identifier */; - } - else if (isKeyword(lastNonTriviaToken) && isKeyword(token) && !canFollow(lastNonTriviaToken, token)) { - // We have two keywords in a row. Only treat the second as a keyword if - // it's a sequence that could legally occur in the language. Otherwise - // treat it as an identifier. This way, if someone writes "private var" - // we recognize that 'var' is actually an identifier here. - token = 69 /* Identifier */; - } - else if (lastNonTriviaToken === 69 /* Identifier */ && - token === 25 /* LessThanToken */) { - // Could be the start of something generic. Keep track of that by bumping - // up the current count of generic contexts we may be in. - angleBracketStack++; - } - else if (token === 27 /* 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 === 130 /* StringKeyword */ || - token === 128 /* NumberKeyword */ || - token === 120 /* BooleanKeyword */ || - token === 131 /* SymbolKeyword */) { - if (angleBracketStack > 0 && !syntacticClassifierAbsent) { - // If it looks like we're could be in something generic, don't classify this - // as a keyword. We may just get overwritten by the syntactic classifier, - // causing a noisy experience for the user. - token = 69 /* Identifier */; - } - } - else if (token === 12 /* TemplateHead */) { - templateStack.push(token); - } - else if (token === 15 /* 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 */) { - // 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 */) { - token = scanner.reScanTemplateToken(); - // Only pop on a TemplateTail; a TemplateMiddle indicates there is more for us. - if (token === 14 /* TemplateTail */) { - templateStack.pop(); - } - else { - ts.Debug.assert(token === 13 /* TemplateMiddle */, "Should have been a template middle. Was " + token); - } - } - else { - ts.Debug.assert(lastTemplateStackToken === 15 /* OpenBraceToken */, "Should have been an open brace. Was: " + token); - templateStack.pop(); - } - } - } - lastNonTriviaToken = token; - } - processToken(); - } while (token !== 1 /* EndOfFileToken */); - return result; - function processToken() { - var start = scanner.getTokenPos(); - var end = scanner.getTextPos(); - addResult(start, end, classFromKind(token)); - if (end >= text.length) { - if (token === 9 /* StringLiteral */) { - // Check to see if we finished up on a multiline string literal. - var tokenText = scanner.getTokenText(); - if (scanner.isUnterminated()) { - var lastCharIndex = tokenText.length - 1; - var numBackslashes = 0; - while (tokenText.charCodeAt(lastCharIndex - numBackslashes) === 92 /* backslash */) { - numBackslashes++; - } - // If we have an odd number of backslashes, then the multiline string is unclosed - if (numBackslashes & 1) { - var quoteChar = tokenText.charCodeAt(0); - result.endOfLineState = quoteChar === 34 /* doubleQuote */ - ? 3 /* InDoubleQuoteStringLiteral */ - : 2 /* InSingleQuoteStringLiteral */; - } - } - } - else if (token === 3 /* MultiLineCommentTrivia */) { - // Check to see if the multiline comment was unclosed. - if (scanner.isUnterminated()) { - result.endOfLineState = 1 /* InMultiLineCommentTrivia */; - } - } - else if (ts.isTemplateLiteralKind(token)) { - if (scanner.isUnterminated()) { - if (token === 14 /* TemplateTail */) { - result.endOfLineState = 5 /* InTemplateMiddleOrTail */; - } - else if (token === 11 /* NoSubstitutionTemplateLiteral */) { - result.endOfLineState = 4 /* InTemplateHeadOrNoSubstitutionTemplate */; - } - else { - ts.Debug.fail("Only 'NoSubstitutionTemplateLiteral's and 'TemplateTail's can be unterminated; got SyntaxKind #" + token); - } - } - } - else if (templateStack.length > 0 && ts.lastOrUndefined(templateStack) === 12 /* TemplateHead */) { - result.endOfLineState = 6 /* InTemplateSubstitutionPosition */; - } - } - } - function addResult(start, end, classification) { - if (classification === 8 /* whiteSpace */) { - // Don't bother with whitespace classifications. They're not needed. - return; - } - if (start === 0 && offset > 0) { - // We're classifying the first token, and this was a case where we prepended - // text. We should consider the start of this token to be at the start of - // the original text. - start += offset; - } - // All our tokens are in relation to the augmented text. Move them back to be - // relative to the original text. - start -= offset; - end -= offset; - var length = end - start; - if (length > 0) { - result.spans.push(start); - result.spans.push(length); - result.spans.push(classification); - } - } - } - 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 */: - return true; - default: - return false; - } - } - function isPrefixUnaryExpressionOperatorToken(token) { - switch (token) { - case 35 /* PlusToken */: - case 36 /* MinusToken */: - case 50 /* TildeToken */: - case 49 /* ExclamationToken */: - case 41 /* PlusPlusToken */: - case 42 /* MinusMinusToken */: - return true; - default: - return false; - } - } - function isKeyword(token) { - return token >= 70 /* FirstKeyword */ && token <= 134 /* LastKeyword */; - } - function classFromKind(token) { - if (isKeyword(token)) { - return 3 /* keyword */; - } - else if (isBinaryExpressionOperatorToken(token) || isPrefixUnaryExpressionOperatorToken(token)) { - return 5 /* operator */; - } - else if (token >= 15 /* FirstPunctuation */ && token <= 68 /* LastPunctuation */) { - return 10 /* punctuation */; - } - switch (token) { - case 8 /* NumericLiteral */: - return 4 /* numericLiteral */; - case 9 /* StringLiteral */: - return 6 /* stringLiteral */; - case 10 /* RegularExpressionLiteral */: - return 7 /* regularExpressionLiteral */; - case 7 /* ConflictMarkerTrivia */: - case 3 /* MultiLineCommentTrivia */: - case 2 /* SingleLineCommentTrivia */: - return 1 /* comment */; - case 5 /* WhitespaceTrivia */: - case 4 /* NewLineTrivia */: - return 8 /* whiteSpace */; - case 69 /* Identifier */: - default: - if (ts.isTemplateLiteralKind(token)) { - return 6 /* stringLiteral */; - } - return 2 /* identifier */; - } - } - return { - getClassificationsForLine: getClassificationsForLine, - getEncodedLexicalClassifications: getEncodedLexicalClassifications - }; - } - ts.createClassifier = createClassifier; - /** - * Get the path of the default library files (lib.d.ts) as distributed with the typescript - * node package. - * The functionality is not supported if the ts module is consumed outside of a node module. - */ - function getDefaultLibFilePath(options) { - // Check __dirname is defined and that we are on a node.js system. - if (typeof __dirname !== "undefined") { - return __dirname + ts.directorySeparator + ts.getDefaultLibFileName(options); - } - throw new Error("getDefaultLibFilePath is only supported when consumed as a node module. "); - } - ts.getDefaultLibFilePath = getDefaultLibFilePath; - function initializeServices() { - ts.objectAllocator = { - getNodeConstructor: function (kind) { - function Node(pos, end) { - this.pos = pos; - this.end = end; - this.flags = 0 /* None */; - this.parent = undefined; - } - var proto = kind === 248 /* SourceFile */ ? new SourceFileObject() : new NodeObject(); - proto.kind = kind; - Node.prototype = proto; - return Node; - }, - getSymbolConstructor: function () { return SymbolObject; }, - getTypeConstructor: function () { return TypeObject; }, - getSignatureConstructor: function () { return SignatureObject; } - }; - } - initializeServices(); -})(ts || (ts = {})); -// Copyright (c) Microsoft. All rights reserved. Licensed under the Apache License, Version 2.0. -// See LICENSE.txt in the project root for complete license information. -/// -/* @internal */ -var ts; -(function (ts) { - var BreakpointResolver; - (function (BreakpointResolver) { - /** - * Get the breakpoint span in given sourceFile - */ - function spanInSourceFileAtLocation(sourceFile, position) { - // Cannot set breakpoint in dts file - if (sourceFile.flags & 8192 /* DeclarationFile */) { - return undefined; - } - var tokenAtLocation = ts.getTokenAtPosition(sourceFile, position); - var lineOfPosition = sourceFile.getLineAndCharacterOfPosition(position).line; - if (sourceFile.getLineAndCharacterOfPosition(tokenAtLocation.getStart()).line > lineOfPosition) { - // Get previous token if the token is returned starts on new line - // eg: let x =10; |--- cursor is here - // let y = 10; - // token at position will return let keyword on second line as the token but we would like to use - // token on same line if trailing trivia (comments or white spaces on same line) part of the last token on that line - tokenAtLocation = ts.findPrecedingToken(tokenAtLocation.pos, sourceFile); - // Its a blank line - if (!tokenAtLocation || sourceFile.getLineAndCharacterOfPosition(tokenAtLocation.getEnd()).line !== lineOfPosition) { - return undefined; - } - } - // Cannot set breakpoint in ambient declarations - if (ts.isInAmbientContext(tokenAtLocation)) { - return undefined; - } - // Get the span in the node based on its syntax - return spanInNode(tokenAtLocation); - function textSpan(startNode, endNode) { - return ts.createTextSpanFromBounds(startNode.getStart(), (endNode || startNode).getEnd()); - } - function spanInNodeIfStartsOnSameLine(node, otherwiseOnNode) { - if (node && lineOfPosition === sourceFile.getLineAndCharacterOfPosition(node.getStart()).line) { - return spanInNode(node); - } - return spanInNode(otherwiseOnNode); - } - function spanInPreviousNode(node) { - return spanInNode(ts.findPrecedingToken(node.pos, sourceFile)); - } - function spanInNextNode(node) { - return spanInNode(ts.findNextToken(node, node.parent)); - } - function spanInNode(node) { - if (node) { - if (ts.isExpression(node)) { - if (node.parent.kind === 197 /* DoStatement */) { - // Set span as if on while keyword - return spanInPreviousNode(node); - } - if (node.parent.kind === 199 /* ForStatement */) { - // For now lets set the span on this expression, fix it later - return textSpan(node); - } - if (node.parent.kind === 181 /* BinaryExpression */ && node.parent.operatorToken.kind === 24 /* CommaToken */) { - // if this is comma expression, the breakpoint is possible in this expression - return textSpan(node); - } - if (node.parent.kind === 174 /* ArrowFunction */ && node.parent.body === node) { - // If this is body of arrow function, it is allowed to have the breakpoint - return textSpan(node); - } - } - switch (node.kind) { - case 193 /* VariableStatement */: - // Span on first variable declaration - return spanInVariableDeclaration(node.declarationList.declarations[0]); - case 211 /* VariableDeclaration */: - case 141 /* PropertyDeclaration */: - case 140 /* PropertySignature */: - return spanInVariableDeclaration(node); - case 138 /* Parameter */: - return spanInParameterDeclaration(node); - case 213 /* FunctionDeclaration */: - case 143 /* MethodDeclaration */: - case 142 /* MethodSignature */: - case 145 /* GetAccessor */: - case 146 /* SetAccessor */: - case 144 /* Constructor */: - case 173 /* FunctionExpression */: - case 174 /* ArrowFunction */: - return spanInFunctionDeclaration(node); - case 192 /* Block */: - if (ts.isFunctionBlock(node)) { - return spanInFunctionBlock(node); - } - // Fall through - case 219 /* ModuleBlock */: - return spanInBlock(node); - case 244 /* CatchClause */: - return spanInBlock(node.block); - case 195 /* ExpressionStatement */: - // span on the expression - return textSpan(node.expression); - case 204 /* ReturnStatement */: - // span on return keyword and expression if present - return textSpan(node.getChildAt(0), node.expression); - case 198 /* WhileStatement */: - // Span on while(...) - return textSpan(node, ts.findNextToken(node.expression, node)); - case 197 /* DoStatement */: - // span in statement of the do statement - return spanInNode(node.statement); - case 210 /* DebuggerStatement */: - // span on debugger keyword - return textSpan(node.getChildAt(0)); - case 196 /* IfStatement */: - // set on if(..) span - return textSpan(node, ts.findNextToken(node.expression, node)); - case 207 /* LabeledStatement */: - // span in statement - return spanInNode(node.statement); - case 203 /* BreakStatement */: - case 202 /* ContinueStatement */: - // On break or continue keyword and label if present - return textSpan(node.getChildAt(0), node.label); - case 199 /* ForStatement */: - return spanInForStatement(node); - case 200 /* ForInStatement */: - case 201 /* ForOfStatement */: - // span on for (a in ...) - return textSpan(node, ts.findNextToken(node.expression, node)); - case 206 /* SwitchStatement */: - // span on switch(...) - return textSpan(node, ts.findNextToken(node.expression, node)); - case 241 /* CaseClause */: - case 242 /* DefaultClause */: - // span in first statement of the clause - return spanInNode(node.statements[0]); - case 209 /* TryStatement */: - // span in try block - return spanInBlock(node.tryBlock); - case 208 /* ThrowStatement */: - // span in throw ... - return textSpan(node, node.expression); - case 227 /* ExportAssignment */: - // span on export = id - return textSpan(node, node.expression); - case 221 /* ImportEqualsDeclaration */: - // import statement without including semicolon - return textSpan(node, node.moduleReference); - case 222 /* ImportDeclaration */: - // import statement without including semicolon - return textSpan(node, node.moduleSpecifier); - case 228 /* ExportDeclaration */: - // import statement without including semicolon - return textSpan(node, node.moduleSpecifier); - case 218 /* ModuleDeclaration */: - // span on complete module if it is instantiated - if (ts.getModuleInstanceState(node) !== 1 /* Instantiated */) { - return undefined; - } - case 214 /* ClassDeclaration */: - case 217 /* EnumDeclaration */: - case 247 /* EnumMember */: - case 168 /* CallExpression */: - case 169 /* NewExpression */: - // span on complete node - return textSpan(node); - case 205 /* WithStatement */: - // span in statement - return spanInNode(node.statement); - // No breakpoint in interface, type alias - case 215 /* InterfaceDeclaration */: - case 216 /* TypeAliasDeclaration */: - return undefined; - // Tokens: - case 23 /* SemicolonToken */: - case 1 /* EndOfFileToken */: - return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile)); - case 24 /* CommaToken */: - return spanInPreviousNode(node); - case 15 /* OpenBraceToken */: - return spanInOpenBraceToken(node); - case 16 /* CloseBraceToken */: - return spanInCloseBraceToken(node); - case 17 /* OpenParenToken */: - return spanInOpenParenToken(node); - case 18 /* CloseParenToken */: - return spanInCloseParenToken(node); - case 54 /* ColonToken */: - return spanInColonToken(node); - case 27 /* GreaterThanToken */: - case 25 /* LessThanToken */: - return spanInGreaterThanOrLessThanToken(node); - // Keywords: - case 104 /* WhileKeyword */: - return spanInWhileKeyword(node); - case 80 /* ElseKeyword */: - case 72 /* CatchKeyword */: - case 85 /* FinallyKeyword */: - return spanInNextNode(node); - default: - // If this is name of property assignment, set breakpoint in the initializer - if (node.parent.kind === 245 /* PropertyAssignment */ && node.parent.name === node) { - return spanInNode(node.parent.initializer); - } - // Breakpoint in type assertion goes to its operand - if (node.parent.kind === 171 /* TypeAssertionExpression */ && node.parent.type === node) { - return spanInNode(node.parent.expression); - } - // return type of function go to previous token - if (ts.isFunctionLike(node.parent) && node.parent.type === node) { - return spanInPreviousNode(node); - } - // Default go to parent to set the breakpoint - return spanInNode(node.parent); - } - } - function spanInVariableDeclaration(variableDeclaration) { - // If declaration of for in statement, just set the span in parent - if (variableDeclaration.parent.parent.kind === 200 /* ForInStatement */ || - variableDeclaration.parent.parent.kind === 201 /* ForOfStatement */) { - return spanInNode(variableDeclaration.parent.parent); - } - var isParentVariableStatement = variableDeclaration.parent.parent.kind === 193 /* VariableStatement */; - var isDeclarationOfForStatement = variableDeclaration.parent.parent.kind === 199 /* ForStatement */ && ts.contains(variableDeclaration.parent.parent.initializer.declarations, variableDeclaration); - var declarations = isParentVariableStatement - ? variableDeclaration.parent.parent.declarationList.declarations - : isDeclarationOfForStatement - ? variableDeclaration.parent.parent.initializer.declarations - : undefined; - // Breakpoint is possible in variableDeclaration only if there is initialization - if (variableDeclaration.initializer || (variableDeclaration.flags & 1 /* Export */)) { - if (declarations && declarations[0] === variableDeclaration) { - if (isParentVariableStatement) { - // First declaration - include let keyword - return textSpan(variableDeclaration.parent, variableDeclaration); - } - else { - ts.Debug.assert(isDeclarationOfForStatement); - // Include let keyword from for statement declarations in the span - return textSpan(ts.findPrecedingToken(variableDeclaration.pos, sourceFile, variableDeclaration.parent), variableDeclaration); - } - } - else { - // Span only on this declaration - return textSpan(variableDeclaration); - } - } - else if (declarations && declarations[0] !== variableDeclaration) { - // If we cant set breakpoint on this declaration, set it on previous one - var indexOfCurrentDeclaration = ts.indexOf(declarations, variableDeclaration); - return spanInVariableDeclaration(declarations[indexOfCurrentDeclaration - 1]); - } - } - function canHaveSpanInParameterDeclaration(parameter) { - // Breakpoint is possible on parameter only if it has initializer, is a rest parameter, or has public or private modifier - return !!parameter.initializer || parameter.dotDotDotToken !== undefined || - !!(parameter.flags & 16 /* Public */) || !!(parameter.flags & 32 /* Private */); - } - function spanInParameterDeclaration(parameter) { - if (canHaveSpanInParameterDeclaration(parameter)) { - return textSpan(parameter); - } - else { - var functionDeclaration = parameter.parent; - var indexOfParameter = ts.indexOf(functionDeclaration.parameters, parameter); - if (indexOfParameter) { - // Not a first parameter, go to previous parameter - return spanInParameterDeclaration(functionDeclaration.parameters[indexOfParameter - 1]); - } - else { - // Set breakpoint in the function declaration body - return spanInNode(functionDeclaration.body); - } - } - } - function canFunctionHaveSpanInWholeDeclaration(functionDeclaration) { - return !!(functionDeclaration.flags & 1 /* Export */) || - (functionDeclaration.parent.kind === 214 /* ClassDeclaration */ && functionDeclaration.kind !== 144 /* Constructor */); - } - function spanInFunctionDeclaration(functionDeclaration) { - // No breakpoints in the function signature - if (!functionDeclaration.body) { - return undefined; - } - if (canFunctionHaveSpanInWholeDeclaration(functionDeclaration)) { - // Set the span on whole function declaration - return textSpan(functionDeclaration); - } - // Set span in function body - return spanInNode(functionDeclaration.body); - } - function spanInFunctionBlock(block) { - var nodeForSpanInBlock = block.statements.length ? block.statements[0] : block.getLastToken(); - if (canFunctionHaveSpanInWholeDeclaration(block.parent)) { - return spanInNodeIfStartsOnSameLine(block.parent, nodeForSpanInBlock); - } - return spanInNode(nodeForSpanInBlock); - } - function spanInBlock(block) { - switch (block.parent.kind) { - case 218 /* ModuleDeclaration */: - if (ts.getModuleInstanceState(block.parent) !== 1 /* Instantiated */) { - return undefined; - } - // Set on parent if on same line otherwise on first statement - case 198 /* WhileStatement */: - case 196 /* IfStatement */: - case 200 /* ForInStatement */: - case 201 /* ForOfStatement */: - return spanInNodeIfStartsOnSameLine(block.parent, block.statements[0]); - // Set span on previous token if it starts on same line otherwise on the first statement of the block - case 199 /* ForStatement */: - 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 spanInForStatement(forStatement) { - if (forStatement.initializer) { - if (forStatement.initializer.kind === 212 /* VariableDeclarationList */) { - var variableDeclarationList = forStatement.initializer; - if (variableDeclarationList.declarations.length > 0) { - return spanInNode(variableDeclarationList.declarations[0]); - } - } - else { - return spanInNode(forStatement.initializer); - } - } - if (forStatement.condition) { - return textSpan(forStatement.condition); - } - if (forStatement.incrementor) { - return textSpan(forStatement.incrementor); - } - } - // Tokens: - function spanInOpenBraceToken(node) { - switch (node.parent.kind) { - case 217 /* EnumDeclaration */: - var enumDeclaration = node.parent; - return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), enumDeclaration.members.length ? enumDeclaration.members[0] : enumDeclaration.getLastToken(sourceFile)); - case 214 /* ClassDeclaration */: - var classDeclaration = node.parent; - return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), classDeclaration.members.length ? classDeclaration.members[0] : classDeclaration.getLastToken(sourceFile)); - case 220 /* CaseBlock */: - return spanInNodeIfStartsOnSameLine(node.parent.parent, node.parent.clauses[0]); - } - // Default to parent node - return spanInNode(node.parent); - } - function spanInCloseBraceToken(node) { - switch (node.parent.kind) { - case 219 /* ModuleBlock */: - // If this is not instantiated module block no bp span - if (ts.getModuleInstanceState(node.parent.parent) !== 1 /* Instantiated */) { - return undefined; - } - case 217 /* EnumDeclaration */: - case 214 /* ClassDeclaration */: - // Span on close brace token - return textSpan(node); - case 192 /* Block */: - if (ts.isFunctionBlock(node.parent)) { - // Span on close brace token - return textSpan(node); - } - // fall through. - case 244 /* CatchClause */: - return spanInNode(ts.lastOrUndefined(node.parent.statements)); - ; - case 220 /* CaseBlock */: - // breakpoint in last statement of the last clause - var caseBlock = node.parent; - var lastClause = ts.lastOrUndefined(caseBlock.clauses); - if (lastClause) { - return spanInNode(ts.lastOrUndefined(lastClause.statements)); - } - return undefined; - // Default to parent node - default: - return spanInNode(node.parent); - } - } - function spanInOpenParenToken(node) { - if (node.parent.kind === 197 /* DoStatement */) { - // Go to while keyword and do action instead - return spanInPreviousNode(node); - } - // Default to parent node - return spanInNode(node.parent); - } - function spanInCloseParenToken(node) { - // Is this close paren token of parameter list, set span in previous token - switch (node.parent.kind) { - case 173 /* FunctionExpression */: - case 213 /* FunctionDeclaration */: - case 174 /* ArrowFunction */: - case 143 /* MethodDeclaration */: - case 142 /* MethodSignature */: - case 145 /* GetAccessor */: - case 146 /* SetAccessor */: - case 144 /* Constructor */: - case 198 /* WhileStatement */: - case 197 /* DoStatement */: - case 199 /* ForStatement */: - return spanInPreviousNode(node); - // Default to parent node - default: - return spanInNode(node.parent); - } - // Default to parent node - return spanInNode(node.parent); - } - function spanInColonToken(node) { - // Is this : specifying return annotation of the function declaration - if (ts.isFunctionLike(node.parent) || node.parent.kind === 245 /* PropertyAssignment */) { - return spanInPreviousNode(node); - } - return spanInNode(node.parent); - } - function spanInGreaterThanOrLessThanToken(node) { - if (node.parent.kind === 171 /* TypeAssertionExpression */) { - return spanInNode(node.parent.expression); - } - return spanInNode(node.parent); - } - function spanInWhileKeyword(node) { - if (node.parent.kind === 197 /* DoStatement */) { - // Set span on while expression - return textSpan(node, ts.findNextToken(node.parent.expression, node.parent)); - } - // Default to parent node - return spanInNode(node.parent); - } - } - } - BreakpointResolver.spanInSourceFileAtLocation = spanInSourceFileAtLocation; - })(BreakpointResolver = ts.BreakpointResolver || (ts.BreakpointResolver = {})); -})(ts || (ts = {})); -// -// Copyright (c) Microsoft Corporation. All rights reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -/// -/* @internal */ -var debugObjectHost = this; -/* @internal */ -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; - this.lineStartPositions = null; - } - 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); - // TODO: should this be '==='? - 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 scriptSnapshotShim is a COM object then property check becomes method call with no arguments - // 'in' does not have this effect - 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 shimHost is a COM object then property check will become method call with no arguments. - // 'in' does not have this effect. - 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.lookUp(resolutionsInFile, name); - return result ? { resolvedFileName: result } : undefined; - }); - }; - } - } - 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) { - // shimmed host does not support getProjectVersion - return undefined; - } - return this.shimHost.getProjectVersion(); - }; - LanguageServiceShimHostAdapter.prototype.useCaseSensitiveFileNames = function () { - return this.shimHost.useCaseSensitiveFileNames ? this.shimHost.useCaseSensitiveFileNames() : false; - }; - LanguageServiceShimHostAdapter.prototype.getCompilationSettings = function () { - var settingsJson = this.shimHost.getCompilationSettings(); - // TODO: should this be '==='? - if (settingsJson == null || settingsJson == "") { - throw Error("LanguageServiceShimHostAdapter.getCompilationSettings: empty compilationSettings"); - return null; - } - return JSON.parse(settingsJson); - }; - LanguageServiceShimHostAdapter.prototype.getScriptFileNames = function () { - var encoded = this.shimHost.getScriptFileNames(); - return this.files = JSON.parse(encoded); - }; - LanguageServiceShimHostAdapter.prototype.getScriptSnapshot = function (fileName) { - // Shim the API changes for 1.5 release. This should be removed once - // TypeScript 1.5 has shipped. - if (this.files && this.files.indexOf(fileName) < 0) { - return undefined; - } - var scriptSnapshot = this.shimHost.getScriptSnapshot(fileName); - return scriptSnapshot && new ScriptSnapshotShimAdapter(scriptSnapshot); - }; - 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.getDefaultLibFileName = function (options) { - // Wrap the API changes for 1.5 release. This try/catch - // should be removed once TypeScript 1.5 has shipped. - try { - return this.shimHost.getDefaultLibFileName(JSON.stringify(options)); - } - catch (e) { - return ""; - } - }; - return LanguageServiceShimHostAdapter; - })(); - ts.LanguageServiceShimHostAdapter = LanguageServiceShimHostAdapter; - /** A cancellation that throttles calls to the host */ - var ThrottledCancellationToken = (function () { - function ThrottledCancellationToken(hostCancellationToken) { - this.hostCancellationToken = hostCancellationToken; - // Store when we last tried to cancel. Checking cancellation can be expensive (as we have - // to marshall over to the host layer). So we only bother actually checking once enough - // time has passed. - this.lastCancellationCheckTime = 0; - } - ThrottledCancellationToken.prototype.isCancellationRequested = function () { - var time = Date.now(); - var duration = Math.abs(time - this.lastCancellationCheckTime); - if (duration > 10) { - // Check no more than once every 10 ms. - this.lastCancellationCheckTime = time; - return this.hostCancellationToken.isCancellationRequested(); - } - return false; - }; - return ThrottledCancellationToken; - })(); - var CoreServicesShimHostAdapter = (function () { - function CoreServicesShimHostAdapter(shimHost) { - this.shimHost = shimHost; - } - CoreServicesShimHostAdapter.prototype.readDirectory = function (rootDir, extension, exclude) { - // Wrap the API changes for 1.5 release. This try/catch - // should be removed once TypeScript 1.5 has shipped. - // Also consider removing the optional designation for - // the exclude param at this time. - var encoded; - try { - encoded = this.shimHost.readDirectory(rootDir, extension, JSON.stringify(exclude)); - } - catch (e) { - encoded = this.shimHost.readDirectory(rootDir, extension); - } - return JSON.parse(encoded); - }; - CoreServicesShimHostAdapter.prototype.fileExists = function (fileName) { - return this.shimHost.fileExists(fileName); - }; - CoreServicesShimHostAdapter.prototype.readFile = function (fileName) { - return this.shimHost.readFile(fileName); - }; - return CoreServicesShimHostAdapter; - })(); - ts.CoreServicesShimHostAdapter = CoreServicesShimHostAdapter; - function simpleForwardCall(logger, actionDescription, action, logPerformance) { - if (logPerformance) { - logger.log(actionDescription); - var start = Date.now(); - } - var result = action(); - if (logPerformance) { - var end = Date.now(); - 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) { - try { - var result = simpleForwardCall(logger, actionDescription, action, logPerformance); - return JSON.stringify({ 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, - /// TODO: no need for the tolowerCase call - category: ts.DiagnosticCategory[diagnostic.category].toLowerCase(), - code: diagnostic.code - }; - } - 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; - } - LanguageServiceShimObject.prototype.forwardJSONCall = function (actionDescription, action) { - return forwardJSONCall(this.logger, actionDescription, action, this.logPerformance); - }; - /// DISPOSE - /** - * Ensure (almost) deterministic release of internal Javascript resources when - * some external native objects holds onto us (e.g. Com/Interop). - */ - LanguageServiceShimObject.prototype.dispose = function (dummy) { - this.logger.log("dispose()"); - this.languageService.dispose(); - this.languageService = null; - // force a GC - if (debugObjectHost && debugObjectHost.CollectGarbage) { - debugObjectHost.CollectGarbage(); - this.logger.log("CollectGarbage()"); - } - this.logger = null; - _super.prototype.dispose.call(this, dummy); - }; - /// REFRESH - /** - * Update the list of scripts known to the compiler - */ - 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 () { - var classifications = _this.languageService.getSyntacticClassifications(fileName, ts.createTextSpan(start, length)); - return classifications; - }); - }; - LanguageServiceShimObject.prototype.getSemanticClassifications = function (fileName, start, length) { - var _this = this; - return this.forwardJSONCall("getSemanticClassifications('" + fileName + "', " + start + ", " + length + ")", function () { - var classifications = _this.languageService.getSemanticClassifications(fileName, ts.createTextSpan(start, length)); - return classifications; - }); - }; - LanguageServiceShimObject.prototype.getEncodedSyntacticClassifications = function (fileName, start, length) { - var _this = this; - return this.forwardJSONCall("getEncodedSyntacticClassifications('" + fileName + "', " + start + ", " + length + ")", function () { - // directly serialize the spans out to a string. This is much faster to decode - // on the managed side versus a full JSON array. - 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 () { - // directly serialize the spans out to a string. This is much faster to decode - // on the managed side versus a full JSON array. - 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); - }); - }; - /// QUICKINFO - /** - * Computes a string representation of the type at the requested position - * in the active file. - */ - LanguageServiceShimObject.prototype.getQuickInfoAtPosition = function (fileName, position) { - var _this = this; - return this.forwardJSONCall("getQuickInfoAtPosition('" + fileName + "', " + position + ")", function () { - var quickInfo = _this.languageService.getQuickInfoAtPosition(fileName, position); - return quickInfo; - }); - }; - /// NAMEORDOTTEDNAMESPAN - /** - * Computes span information of the name or dotted name at the requested position - * in the active file. - */ - LanguageServiceShimObject.prototype.getNameOrDottedNameSpan = function (fileName, startPos, endPos) { - var _this = this; - return this.forwardJSONCall("getNameOrDottedNameSpan('" + fileName + "', " + startPos + ", " + endPos + ")", function () { - var spanInfo = _this.languageService.getNameOrDottedNameSpan(fileName, startPos, endPos); - return spanInfo; - }); - }; - /** - * STATEMENTSPAN - * Computes span information of statement at the requested position in the active file. - */ - LanguageServiceShimObject.prototype.getBreakpointStatementAtPosition = function (fileName, position) { - var _this = this; - return this.forwardJSONCall("getBreakpointStatementAtPosition('" + fileName + "', " + position + ")", function () { - var spanInfo = _this.languageService.getBreakpointStatementAtPosition(fileName, position); - return spanInfo; - }); - }; - /// SIGNATUREHELP - LanguageServiceShimObject.prototype.getSignatureHelpItems = function (fileName, position) { - var _this = this; - return this.forwardJSONCall("getSignatureHelpItems('" + fileName + "', " + position + ")", function () { - var signatureInfo = _this.languageService.getSignatureHelpItems(fileName, position); - return signatureInfo; - }); - }; - /// GOTO DEFINITION - /** - * Computes the definition location and file for the symbol - * at the requested position. - */ - LanguageServiceShimObject.prototype.getDefinitionAtPosition = function (fileName, position) { - var _this = this; - return this.forwardJSONCall("getDefinitionAtPosition('" + fileName + "', " + position + ")", function () { - return _this.languageService.getDefinitionAtPosition(fileName, position); - }); - }; - /// GOTO Type - /** - * Computes the definition location of the type of the symbol - * at the requested 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.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); - }); - }; - /// GET BRACE MATCHING - LanguageServiceShimObject.prototype.getBraceMatchingAtPosition = function (fileName, position) { - var _this = this; - return this.forwardJSONCall("getBraceMatchingAtPosition('" + fileName + "', " + position + ")", function () { - var textRanges = _this.languageService.getBraceMatchingAtPosition(fileName, position); - return textRanges; - }); - }; - /// GET SMART INDENT - LanguageServiceShimObject.prototype.getIndentationAtPosition = function (fileName, position, options /*Services.EditorOptions*/) { - var _this = this; - return this.forwardJSONCall("getIndentationAtPosition('" + fileName + "', " + position + ")", function () { - var localOptions = JSON.parse(options); - return _this.languageService.getIndentationAtPosition(fileName, position, localOptions); - }); - }; - /// GET REFERENCES - 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)); - // workaround for VS document higlighting issue - keep only items from the initial file - var normalizedName = ts.normalizeSlashes(fileName).toLowerCase(); - return ts.filter(results, function (r) { return ts.normalizeSlashes(r.fileName).toLowerCase() === normalizedName; }); - }); - }; - /// COMPLETION LISTS - /** - * Get a string based representation of the completions - * to provide at the given source position and providing a member completion - * list if requested. - */ - LanguageServiceShimObject.prototype.getCompletionsAtPosition = function (fileName, position) { - var _this = this; - return this.forwardJSONCall("getCompletionsAtPosition('" + fileName + "', " + position + ")", function () { - var completion = _this.languageService.getCompletionsAtPosition(fileName, position); - return completion; - }); - }; - /** Get a string based representation of a completion list entry details */ - LanguageServiceShimObject.prototype.getCompletionEntryDetails = function (fileName, position, entryName) { - var _this = this; - return this.forwardJSONCall("getCompletionEntryDetails('" + fileName + "', " + position + ", " + entryName + ")", function () { - var details = _this.languageService.getCompletionEntryDetails(fileName, position, entryName); - return details; - }); - }; - LanguageServiceShimObject.prototype.getFormattingEditsForRange = function (fileName, start, end, options /*Services.FormatCodeOptions*/) { - var _this = this; - return this.forwardJSONCall("getFormattingEditsForRange('" + fileName + "', " + start + ", " + end + ")", function () { - var localOptions = JSON.parse(options); - var edits = _this.languageService.getFormattingEditsForRange(fileName, start, end, localOptions); - return edits; - }); - }; - LanguageServiceShimObject.prototype.getFormattingEditsForDocument = function (fileName, options /*Services.FormatCodeOptions*/) { - var _this = this; - return this.forwardJSONCall("getFormattingEditsForDocument('" + fileName + "')", function () { - var localOptions = JSON.parse(options); - var edits = _this.languageService.getFormattingEditsForDocument(fileName, localOptions); - return edits; - }); - }; - LanguageServiceShimObject.prototype.getFormattingEditsAfterKeystroke = function (fileName, position, key, options /*Services.FormatCodeOptions*/) { - var _this = this; - return this.forwardJSONCall("getFormattingEditsAfterKeystroke('" + fileName + "', " + position + ", '" + key + "')", function () { - var localOptions = JSON.parse(options); - var edits = _this.languageService.getFormattingEditsAfterKeystroke(fileName, position, key, localOptions); - return edits; - }); - }; - LanguageServiceShimObject.prototype.getDocCommentTemplateAtPosition = function (fileName, position) { - var _this = this; - return this.forwardJSONCall("getDocCommentTemplateAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getDocCommentTemplateAtPosition(fileName, position); }); - }; - /// NAVIGATE TO - /** Return a list of symbols that are interesting to navigate to */ - LanguageServiceShimObject.prototype.getNavigateToItems = function (searchValue, maxResultCount) { - var _this = this; - return this.forwardJSONCall("getNavigateToItems('" + searchValue + "', " + maxResultCount + ")", function () { - var items = _this.languageService.getNavigateToItems(searchValue, maxResultCount); - return items; - }); - }; - LanguageServiceShimObject.prototype.getNavigationBarItems = function (fileName) { - var _this = this; - return this.forwardJSONCall("getNavigationBarItems('" + fileName + "')", function () { - var items = _this.languageService.getNavigationBarItems(fileName); - return items; - }); - }; - LanguageServiceShimObject.prototype.getOutliningSpans = function (fileName) { - var _this = this; - return this.forwardJSONCall("getOutliningSpans('" + fileName + "')", function () { - var items = _this.languageService.getOutliningSpans(fileName); - return items; - }); - }; - LanguageServiceShimObject.prototype.getTodoComments = function (fileName, descriptors) { - var _this = this; - return this.forwardJSONCall("getTodoComments('" + fileName + "')", function () { - var items = _this.languageService.getTodoComments(fileName, JSON.parse(descriptors)); - return items; - }); - }; - /// Emit - LanguageServiceShimObject.prototype.getEmitOutput = function (fileName) { - var _this = this; - return this.forwardJSONCall("getEmitOutput('" + fileName + "')", function () { - var output = _this.languageService.getEmitOutput(fileName); - // Shim the API changes for 1.5 release. This should be removed once - // TypeScript 1.5 has shipped. - output.emitOutputStatus = output.emitSkipped ? 1 : 0; - return output; - }); - }; - 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) { - _super.call(this, factory); - this.logger = logger; - this.logPerformance = false; - this.classifier = ts.createClassifier(); - } - 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); - }; - /// COLORIZATION - ClassifierShimObject.prototype.getClassificationsForLine = function (text, lexState, classifyKeywordsInGenerics) { - var classification = this.classifier.getClassificationsForLine(text, lexState, classifyKeywordsInGenerics); - var items = classification.entries; - var result = ""; - for (var i = 0; i < items.length; i++) { - result += items[i].length + "\n"; - result += items[i].classification + "\n"; - } - result += classification.finalLexState; - return result; - }; - return ClassifierShimObject; - })(ShimBase); - 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; - } - 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.getPreProcessedFileInfo = function (fileName, sourceTextSnapshot) { - return this.forwardJSONCall("getPreProcessedFileInfo('" + fileName + "')", function () { - var result = ts.preProcessFile(sourceTextSnapshot.getText(0, sourceTextSnapshot.getLength())); - var convertResult = { - referencedFiles: [], - importedFiles: [], - ambientExternalModules: result.ambientExternalModules, - isLibFile: result.isLibFile - }; - ts.forEach(result.referencedFiles, function (refFile) { - convertResult.referencedFiles.push({ - path: ts.normalizePath(refFile.fileName), - position: refFile.pos, - length: refFile.end - refFile.pos - }); - }); - ts.forEach(result.importedFiles, function (importedFile) { - convertResult.importedFiles.push({ - path: ts.normalizeSlashes(importedFile.fileName), - position: importedFile.pos, - length: importedFile.end - importedFile.pos - }); - }); - return convertResult; - }); - }; - 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: {}, - files: [], - errors: [realizeDiagnostic(result.error, '\r\n')] - }; - } - var configFile = ts.parseJsonConfigFileContent(result.config, _this.host, ts.getDirectoryPath(ts.normalizeSlashes(fileName))); - return { - options: configFile.options, - files: configFile.fileNames, - errors: realizeDiagnostics(configFile.errors, '\r\n') - }; - }); - }; - CoreServicesShimObject.prototype.getDefaultCompilationSettings = function () { - return this.forwardJSONCall("getDefaultCompilationSettings()", function () { - return ts.getDefaultCompilerOptions(); - }); - }; - return CoreServicesShimObject; - })(ShimBase); - var TypeScriptServicesFactory = (function () { - function TypeScriptServicesFactory() { - this._shims = []; - } - /* - * Returns script API version. - */ - 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()); - } - 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 () { - // Forget all the registered shims - this._shims = []; - this.documentRegistry = ts.createDocumentRegistry(); - }; - 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 = {})); -/// TODO: this is used by VS, clean this up on both sides of the interface -/* @internal */ -var TypeScript; -(function (TypeScript) { - var Services; - (function (Services) { - Services.TypeScriptServicesFactory = ts.TypeScriptServicesFactory; - })(Services = TypeScript.Services || (TypeScript.Services = {})); -})(TypeScript || (TypeScript = {})); -/* @internal */ -var toolsVersion = "1.6"; +var ts; +(function (ts) { + // token > SyntaxKind.Identifer => token is a keyword + // Also, If you add a new SyntaxKind be sure to keep the `Markers` section at the bottom in sync + (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"; + // We detect and preserve #! on the first line + SyntaxKind[SyntaxKind["ShebangTrivia"] = 6] = "ShebangTrivia"; + // We detect and provide better error recovery when we encounter a git merge marker. This + // allows us to edit files with git-conflict markers in them in a much more pleasant manner. + SyntaxKind[SyntaxKind["ConflictMarkerTrivia"] = 7] = "ConflictMarkerTrivia"; + // Literals + SyntaxKind[SyntaxKind["NumericLiteral"] = 8] = "NumericLiteral"; + SyntaxKind[SyntaxKind["StringLiteral"] = 9] = "StringLiteral"; + SyntaxKind[SyntaxKind["RegularExpressionLiteral"] = 10] = "RegularExpressionLiteral"; + SyntaxKind[SyntaxKind["NoSubstitutionTemplateLiteral"] = 11] = "NoSubstitutionTemplateLiteral"; + // Pseudo-literals + SyntaxKind[SyntaxKind["TemplateHead"] = 12] = "TemplateHead"; + SyntaxKind[SyntaxKind["TemplateMiddle"] = 13] = "TemplateMiddle"; + SyntaxKind[SyntaxKind["TemplateTail"] = 14] = "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"; + // 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"; + // Identifiers + SyntaxKind[SyntaxKind["Identifier"] = 69] = "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"; + // 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"; + // 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["RequireKeyword"] = 127] = "RequireKeyword"; + SyntaxKind[SyntaxKind["NumberKeyword"] = 128] = "NumberKeyword"; + SyntaxKind[SyntaxKind["SetKeyword"] = 129] = "SetKeyword"; + SyntaxKind[SyntaxKind["StringKeyword"] = 130] = "StringKeyword"; + SyntaxKind[SyntaxKind["SymbolKeyword"] = 131] = "SymbolKeyword"; + SyntaxKind[SyntaxKind["TypeKeyword"] = 132] = "TypeKeyword"; + SyntaxKind[SyntaxKind["FromKeyword"] = 133] = "FromKeyword"; + SyntaxKind[SyntaxKind["OfKeyword"] = 134] = "OfKeyword"; + // Parse tree nodes + // Names + SyntaxKind[SyntaxKind["QualifiedName"] = 135] = "QualifiedName"; + SyntaxKind[SyntaxKind["ComputedPropertyName"] = 136] = "ComputedPropertyName"; + // Signature elements + SyntaxKind[SyntaxKind["TypeParameter"] = 137] = "TypeParameter"; + SyntaxKind[SyntaxKind["Parameter"] = 138] = "Parameter"; + SyntaxKind[SyntaxKind["Decorator"] = 139] = "Decorator"; + // TypeMember + SyntaxKind[SyntaxKind["PropertySignature"] = 140] = "PropertySignature"; + SyntaxKind[SyntaxKind["PropertyDeclaration"] = 141] = "PropertyDeclaration"; + SyntaxKind[SyntaxKind["MethodSignature"] = 142] = "MethodSignature"; + SyntaxKind[SyntaxKind["MethodDeclaration"] = 143] = "MethodDeclaration"; + SyntaxKind[SyntaxKind["Constructor"] = 144] = "Constructor"; + SyntaxKind[SyntaxKind["GetAccessor"] = 145] = "GetAccessor"; + SyntaxKind[SyntaxKind["SetAccessor"] = 146] = "SetAccessor"; + SyntaxKind[SyntaxKind["CallSignature"] = 147] = "CallSignature"; + SyntaxKind[SyntaxKind["ConstructSignature"] = 148] = "ConstructSignature"; + SyntaxKind[SyntaxKind["IndexSignature"] = 149] = "IndexSignature"; + // Type + SyntaxKind[SyntaxKind["TypePredicate"] = 150] = "TypePredicate"; + SyntaxKind[SyntaxKind["TypeReference"] = 151] = "TypeReference"; + SyntaxKind[SyntaxKind["FunctionType"] = 152] = "FunctionType"; + SyntaxKind[SyntaxKind["ConstructorType"] = 153] = "ConstructorType"; + SyntaxKind[SyntaxKind["TypeQuery"] = 154] = "TypeQuery"; + SyntaxKind[SyntaxKind["TypeLiteral"] = 155] = "TypeLiteral"; + SyntaxKind[SyntaxKind["ArrayType"] = 156] = "ArrayType"; + SyntaxKind[SyntaxKind["TupleType"] = 157] = "TupleType"; + SyntaxKind[SyntaxKind["UnionType"] = 158] = "UnionType"; + SyntaxKind[SyntaxKind["IntersectionType"] = 159] = "IntersectionType"; + SyntaxKind[SyntaxKind["ParenthesizedType"] = 160] = "ParenthesizedType"; + // Binding patterns + SyntaxKind[SyntaxKind["ObjectBindingPattern"] = 161] = "ObjectBindingPattern"; + SyntaxKind[SyntaxKind["ArrayBindingPattern"] = 162] = "ArrayBindingPattern"; + SyntaxKind[SyntaxKind["BindingElement"] = 163] = "BindingElement"; + // Expression + SyntaxKind[SyntaxKind["ArrayLiteralExpression"] = 164] = "ArrayLiteralExpression"; + SyntaxKind[SyntaxKind["ObjectLiteralExpression"] = 165] = "ObjectLiteralExpression"; + SyntaxKind[SyntaxKind["PropertyAccessExpression"] = 166] = "PropertyAccessExpression"; + SyntaxKind[SyntaxKind["ElementAccessExpression"] = 167] = "ElementAccessExpression"; + SyntaxKind[SyntaxKind["CallExpression"] = 168] = "CallExpression"; + SyntaxKind[SyntaxKind["NewExpression"] = 169] = "NewExpression"; + SyntaxKind[SyntaxKind["TaggedTemplateExpression"] = 170] = "TaggedTemplateExpression"; + SyntaxKind[SyntaxKind["TypeAssertionExpression"] = 171] = "TypeAssertionExpression"; + SyntaxKind[SyntaxKind["ParenthesizedExpression"] = 172] = "ParenthesizedExpression"; + SyntaxKind[SyntaxKind["FunctionExpression"] = 173] = "FunctionExpression"; + SyntaxKind[SyntaxKind["ArrowFunction"] = 174] = "ArrowFunction"; + SyntaxKind[SyntaxKind["DeleteExpression"] = 175] = "DeleteExpression"; + SyntaxKind[SyntaxKind["TypeOfExpression"] = 176] = "TypeOfExpression"; + SyntaxKind[SyntaxKind["VoidExpression"] = 177] = "VoidExpression"; + SyntaxKind[SyntaxKind["AwaitExpression"] = 178] = "AwaitExpression"; + SyntaxKind[SyntaxKind["PrefixUnaryExpression"] = 179] = "PrefixUnaryExpression"; + SyntaxKind[SyntaxKind["PostfixUnaryExpression"] = 180] = "PostfixUnaryExpression"; + SyntaxKind[SyntaxKind["BinaryExpression"] = 181] = "BinaryExpression"; + SyntaxKind[SyntaxKind["ConditionalExpression"] = 182] = "ConditionalExpression"; + SyntaxKind[SyntaxKind["TemplateExpression"] = 183] = "TemplateExpression"; + SyntaxKind[SyntaxKind["YieldExpression"] = 184] = "YieldExpression"; + SyntaxKind[SyntaxKind["SpreadElementExpression"] = 185] = "SpreadElementExpression"; + SyntaxKind[SyntaxKind["ClassExpression"] = 186] = "ClassExpression"; + SyntaxKind[SyntaxKind["OmittedExpression"] = 187] = "OmittedExpression"; + SyntaxKind[SyntaxKind["ExpressionWithTypeArguments"] = 188] = "ExpressionWithTypeArguments"; + SyntaxKind[SyntaxKind["AsExpression"] = 189] = "AsExpression"; + // Misc + SyntaxKind[SyntaxKind["TemplateSpan"] = 190] = "TemplateSpan"; + SyntaxKind[SyntaxKind["SemicolonClassElement"] = 191] = "SemicolonClassElement"; + // Element + SyntaxKind[SyntaxKind["Block"] = 192] = "Block"; + SyntaxKind[SyntaxKind["VariableStatement"] = 193] = "VariableStatement"; + SyntaxKind[SyntaxKind["EmptyStatement"] = 194] = "EmptyStatement"; + SyntaxKind[SyntaxKind["ExpressionStatement"] = 195] = "ExpressionStatement"; + SyntaxKind[SyntaxKind["IfStatement"] = 196] = "IfStatement"; + SyntaxKind[SyntaxKind["DoStatement"] = 197] = "DoStatement"; + SyntaxKind[SyntaxKind["WhileStatement"] = 198] = "WhileStatement"; + SyntaxKind[SyntaxKind["ForStatement"] = 199] = "ForStatement"; + SyntaxKind[SyntaxKind["ForInStatement"] = 200] = "ForInStatement"; + SyntaxKind[SyntaxKind["ForOfStatement"] = 201] = "ForOfStatement"; + SyntaxKind[SyntaxKind["ContinueStatement"] = 202] = "ContinueStatement"; + SyntaxKind[SyntaxKind["BreakStatement"] = 203] = "BreakStatement"; + SyntaxKind[SyntaxKind["ReturnStatement"] = 204] = "ReturnStatement"; + SyntaxKind[SyntaxKind["WithStatement"] = 205] = "WithStatement"; + SyntaxKind[SyntaxKind["SwitchStatement"] = 206] = "SwitchStatement"; + SyntaxKind[SyntaxKind["LabeledStatement"] = 207] = "LabeledStatement"; + SyntaxKind[SyntaxKind["ThrowStatement"] = 208] = "ThrowStatement"; + SyntaxKind[SyntaxKind["TryStatement"] = 209] = "TryStatement"; + SyntaxKind[SyntaxKind["DebuggerStatement"] = 210] = "DebuggerStatement"; + SyntaxKind[SyntaxKind["VariableDeclaration"] = 211] = "VariableDeclaration"; + SyntaxKind[SyntaxKind["VariableDeclarationList"] = 212] = "VariableDeclarationList"; + SyntaxKind[SyntaxKind["FunctionDeclaration"] = 213] = "FunctionDeclaration"; + SyntaxKind[SyntaxKind["ClassDeclaration"] = 214] = "ClassDeclaration"; + SyntaxKind[SyntaxKind["InterfaceDeclaration"] = 215] = "InterfaceDeclaration"; + SyntaxKind[SyntaxKind["TypeAliasDeclaration"] = 216] = "TypeAliasDeclaration"; + SyntaxKind[SyntaxKind["EnumDeclaration"] = 217] = "EnumDeclaration"; + SyntaxKind[SyntaxKind["ModuleDeclaration"] = 218] = "ModuleDeclaration"; + SyntaxKind[SyntaxKind["ModuleBlock"] = 219] = "ModuleBlock"; + SyntaxKind[SyntaxKind["CaseBlock"] = 220] = "CaseBlock"; + SyntaxKind[SyntaxKind["ImportEqualsDeclaration"] = 221] = "ImportEqualsDeclaration"; + SyntaxKind[SyntaxKind["ImportDeclaration"] = 222] = "ImportDeclaration"; + SyntaxKind[SyntaxKind["ImportClause"] = 223] = "ImportClause"; + SyntaxKind[SyntaxKind["NamespaceImport"] = 224] = "NamespaceImport"; + SyntaxKind[SyntaxKind["NamedImports"] = 225] = "NamedImports"; + SyntaxKind[SyntaxKind["ImportSpecifier"] = 226] = "ImportSpecifier"; + SyntaxKind[SyntaxKind["ExportAssignment"] = 227] = "ExportAssignment"; + SyntaxKind[SyntaxKind["ExportDeclaration"] = 228] = "ExportDeclaration"; + SyntaxKind[SyntaxKind["NamedExports"] = 229] = "NamedExports"; + SyntaxKind[SyntaxKind["ExportSpecifier"] = 230] = "ExportSpecifier"; + SyntaxKind[SyntaxKind["MissingDeclaration"] = 231] = "MissingDeclaration"; + // Module references + SyntaxKind[SyntaxKind["ExternalModuleReference"] = 232] = "ExternalModuleReference"; + // JSX + SyntaxKind[SyntaxKind["JsxElement"] = 233] = "JsxElement"; + SyntaxKind[SyntaxKind["JsxSelfClosingElement"] = 234] = "JsxSelfClosingElement"; + SyntaxKind[SyntaxKind["JsxOpeningElement"] = 235] = "JsxOpeningElement"; + SyntaxKind[SyntaxKind["JsxText"] = 236] = "JsxText"; + SyntaxKind[SyntaxKind["JsxClosingElement"] = 237] = "JsxClosingElement"; + SyntaxKind[SyntaxKind["JsxAttribute"] = 238] = "JsxAttribute"; + SyntaxKind[SyntaxKind["JsxSpreadAttribute"] = 239] = "JsxSpreadAttribute"; + SyntaxKind[SyntaxKind["JsxExpression"] = 240] = "JsxExpression"; + // Clauses + SyntaxKind[SyntaxKind["CaseClause"] = 241] = "CaseClause"; + SyntaxKind[SyntaxKind["DefaultClause"] = 242] = "DefaultClause"; + SyntaxKind[SyntaxKind["HeritageClause"] = 243] = "HeritageClause"; + SyntaxKind[SyntaxKind["CatchClause"] = 244] = "CatchClause"; + // Property assignments + SyntaxKind[SyntaxKind["PropertyAssignment"] = 245] = "PropertyAssignment"; + SyntaxKind[SyntaxKind["ShorthandPropertyAssignment"] = 246] = "ShorthandPropertyAssignment"; + // Enum + SyntaxKind[SyntaxKind["EnumMember"] = 247] = "EnumMember"; + // Top-level nodes + SyntaxKind[SyntaxKind["SourceFile"] = 248] = "SourceFile"; + // JSDoc nodes. + SyntaxKind[SyntaxKind["JSDocTypeExpression"] = 249] = "JSDocTypeExpression"; + // The * type. + SyntaxKind[SyntaxKind["JSDocAllType"] = 250] = "JSDocAllType"; + // The ? type. + SyntaxKind[SyntaxKind["JSDocUnknownType"] = 251] = "JSDocUnknownType"; + SyntaxKind[SyntaxKind["JSDocArrayType"] = 252] = "JSDocArrayType"; + SyntaxKind[SyntaxKind["JSDocUnionType"] = 253] = "JSDocUnionType"; + SyntaxKind[SyntaxKind["JSDocTupleType"] = 254] = "JSDocTupleType"; + SyntaxKind[SyntaxKind["JSDocNullableType"] = 255] = "JSDocNullableType"; + SyntaxKind[SyntaxKind["JSDocNonNullableType"] = 256] = "JSDocNonNullableType"; + SyntaxKind[SyntaxKind["JSDocRecordType"] = 257] = "JSDocRecordType"; + SyntaxKind[SyntaxKind["JSDocRecordMember"] = 258] = "JSDocRecordMember"; + SyntaxKind[SyntaxKind["JSDocTypeReference"] = 259] = "JSDocTypeReference"; + SyntaxKind[SyntaxKind["JSDocOptionalType"] = 260] = "JSDocOptionalType"; + SyntaxKind[SyntaxKind["JSDocFunctionType"] = 261] = "JSDocFunctionType"; + SyntaxKind[SyntaxKind["JSDocVariadicType"] = 262] = "JSDocVariadicType"; + SyntaxKind[SyntaxKind["JSDocConstructorType"] = 263] = "JSDocConstructorType"; + SyntaxKind[SyntaxKind["JSDocThisType"] = 264] = "JSDocThisType"; + SyntaxKind[SyntaxKind["JSDocComment"] = 265] = "JSDocComment"; + SyntaxKind[SyntaxKind["JSDocTag"] = 266] = "JSDocTag"; + SyntaxKind[SyntaxKind["JSDocParameterTag"] = 267] = "JSDocParameterTag"; + SyntaxKind[SyntaxKind["JSDocReturnTag"] = 268] = "JSDocReturnTag"; + SyntaxKind[SyntaxKind["JSDocTypeTag"] = 269] = "JSDocTypeTag"; + SyntaxKind[SyntaxKind["JSDocTemplateTag"] = 270] = "JSDocTemplateTag"; + // Synthesized list + SyntaxKind[SyntaxKind["SyntaxList"] = 271] = "SyntaxList"; + // Enum value count + SyntaxKind[SyntaxKind["Count"] = 272] = "Count"; + // Markers + SyntaxKind[SyntaxKind["FirstAssignment"] = 56] = "FirstAssignment"; + SyntaxKind[SyntaxKind["LastAssignment"] = 68] = "LastAssignment"; + SyntaxKind[SyntaxKind["FirstReservedWord"] = 70] = "FirstReservedWord"; + SyntaxKind[SyntaxKind["LastReservedWord"] = 105] = "LastReservedWord"; + SyntaxKind[SyntaxKind["FirstKeyword"] = 70] = "FirstKeyword"; + SyntaxKind[SyntaxKind["LastKeyword"] = 134] = "LastKeyword"; + SyntaxKind[SyntaxKind["FirstFutureReservedWord"] = 106] = "FirstFutureReservedWord"; + SyntaxKind[SyntaxKind["LastFutureReservedWord"] = 114] = "LastFutureReservedWord"; + SyntaxKind[SyntaxKind["FirstTypeNode"] = 151] = "FirstTypeNode"; + SyntaxKind[SyntaxKind["LastTypeNode"] = 160] = "LastTypeNode"; + SyntaxKind[SyntaxKind["FirstPunctuation"] = 15] = "FirstPunctuation"; + SyntaxKind[SyntaxKind["LastPunctuation"] = 68] = "LastPunctuation"; + SyntaxKind[SyntaxKind["FirstToken"] = 0] = "FirstToken"; + SyntaxKind[SyntaxKind["LastToken"] = 134] = "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"] = 135] = "FirstNode"; + })(ts.SyntaxKind || (ts.SyntaxKind = {})); + var SyntaxKind = ts.SyntaxKind; + (function (NodeFlags) { + NodeFlags[NodeFlags["None"] = 0] = "None"; + NodeFlags[NodeFlags["Export"] = 1] = "Export"; + NodeFlags[NodeFlags["Ambient"] = 2] = "Ambient"; + NodeFlags[NodeFlags["Public"] = 16] = "Public"; + NodeFlags[NodeFlags["Private"] = 32] = "Private"; + NodeFlags[NodeFlags["Protected"] = 64] = "Protected"; + NodeFlags[NodeFlags["Static"] = 128] = "Static"; + NodeFlags[NodeFlags["Abstract"] = 256] = "Abstract"; + NodeFlags[NodeFlags["Async"] = 512] = "Async"; + NodeFlags[NodeFlags["Default"] = 1024] = "Default"; + NodeFlags[NodeFlags["MultiLine"] = 2048] = "MultiLine"; + NodeFlags[NodeFlags["Synthetic"] = 4096] = "Synthetic"; + NodeFlags[NodeFlags["DeclarationFile"] = 8192] = "DeclarationFile"; + NodeFlags[NodeFlags["Let"] = 16384] = "Let"; + NodeFlags[NodeFlags["Const"] = 32768] = "Const"; + NodeFlags[NodeFlags["OctalLiteral"] = 65536] = "OctalLiteral"; + NodeFlags[NodeFlags["Namespace"] = 131072] = "Namespace"; + NodeFlags[NodeFlags["ExportContext"] = 262144] = "ExportContext"; + NodeFlags[NodeFlags["ContainsThis"] = 524288] = "ContainsThis"; + NodeFlags[NodeFlags["Modifier"] = 2035] = "Modifier"; + NodeFlags[NodeFlags["AccessibilityModifier"] = 112] = "AccessibilityModifier"; + NodeFlags[NodeFlags["BlockScoped"] = 49152] = "BlockScoped"; + })(ts.NodeFlags || (ts.NodeFlags = {})); + var NodeFlags = ts.NodeFlags; + /* @internal */ + (function (ParserContextFlags) { + ParserContextFlags[ParserContextFlags["None"] = 0] = "None"; + // If this node was parsed in a context where 'in-expressions' are not allowed. + ParserContextFlags[ParserContextFlags["DisallowIn"] = 1] = "DisallowIn"; + // If this node was parsed in the 'yield' context created when parsing a generator. + ParserContextFlags[ParserContextFlags["Yield"] = 2] = "Yield"; + // If this node was parsed as part of a decorator + ParserContextFlags[ParserContextFlags["Decorator"] = 4] = "Decorator"; + // If this node was parsed in the 'await' context created when parsing an async function. + ParserContextFlags[ParserContextFlags["Await"] = 8] = "Await"; + // If the parser encountered an error when parsing the code that created this node. Note + // the parser only sets this directly on the node it creates right after encountering the + // error. + ParserContextFlags[ParserContextFlags["ThisNodeHasError"] = 16] = "ThisNodeHasError"; + // This node was parsed in a JavaScript file and can be processed differently. For example + // its type can be specified usign a JSDoc comment. + ParserContextFlags[ParserContextFlags["JavaScriptFile"] = 32] = "JavaScriptFile"; + // Context flags set directly by the parser. + ParserContextFlags[ParserContextFlags["ParserGeneratedFlags"] = 31] = "ParserGeneratedFlags"; + // Exclude these flags when parsing a Type + ParserContextFlags[ParserContextFlags["TypeExcludesFlags"] = 10] = "TypeExcludesFlags"; + // Context flags computed by aggregating child flags upwards. + // Used during incremental parsing to determine if this node or any of its children had an + // error. Computed only once and then cached. + ParserContextFlags[ParserContextFlags["ThisNodeOrAnySubNodesHasError"] = 64] = "ThisNodeOrAnySubNodesHasError"; + // Used to know if we've computed data from children and cached it in this node. + ParserContextFlags[ParserContextFlags["HasAggregatedChildData"] = 128] = "HasAggregatedChildData"; + })(ts.ParserContextFlags || (ts.ParserContextFlags = {})); + var ParserContextFlags = ts.ParserContextFlags; + (function (JsxFlags) { + JsxFlags[JsxFlags["None"] = 0] = "None"; + JsxFlags[JsxFlags["IntrinsicNamedElement"] = 1] = "IntrinsicNamedElement"; + JsxFlags[JsxFlags["IntrinsicIndexedElement"] = 2] = "IntrinsicIndexedElement"; + JsxFlags[JsxFlags["ClassElement"] = 4] = "ClassElement"; + JsxFlags[JsxFlags["UnknownElement"] = 8] = "UnknownElement"; + JsxFlags[JsxFlags["IntrinsicElement"] = 3] = "IntrinsicElement"; + })(ts.JsxFlags || (ts.JsxFlags = {})); + var JsxFlags = ts.JsxFlags; + /* @internal */ + (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; + var OperationCanceledException = (function () { + function OperationCanceledException() { + } + return OperationCanceledException; + })(); + ts.OperationCanceledException = OperationCanceledException; + /** Return code used by getEmitOutput function to indicate status of the function */ + (function (ExitStatus) { + // Compiler ran successfully. Either this was a simple do-nothing compilation (for example, + // when -version or -help was provided, or this was a normal compilation, no diagnostics + // were produced, and all outputs were generated successfully. + ExitStatus[ExitStatus["Success"] = 0] = "Success"; + // Diagnostics were produced and because of them no code was generated. + ExitStatus[ExitStatus["DiagnosticsPresent_OutputsSkipped"] = 1] = "DiagnosticsPresent_OutputsSkipped"; + // Diagnostics were produced and outputs were generated in spite of them. + 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"; + })(ts.TypeFormatFlags || (ts.TypeFormatFlags = {})); + var TypeFormatFlags = ts.TypeFormatFlags; + (function (SymbolFormatFlags) { + SymbolFormatFlags[SymbolFormatFlags["None"] = 0] = "None"; + // Write symbols's type argument if it is instantiated symbol + // eg. class C { p: T } <-- Show p as C.p here + // var a: C; + // var p = a.p; <--- Here p is property of C so show it as C.p instead of just C.p + SymbolFormatFlags[SymbolFormatFlags["WriteTypeParametersOrArguments"] = 1] = "WriteTypeParametersOrArguments"; + // Use only external alias information to get the symbol name in the given context + // eg. module m { export class c { } } import x = m.c; + // When this flag is specified m.c will be used to refer to the class instead of alias symbol x + SymbolFormatFlags[SymbolFormatFlags["UseOnlyExternalAliasing"] = 2] = "UseOnlyExternalAliasing"; + })(ts.SymbolFormatFlags || (ts.SymbolFormatFlags = {})); + var SymbolFormatFlags = ts.SymbolFormatFlags; + /* @internal */ + (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; + /** Indicates how to serialize the name for a TypeReferenceNode when emitting decorator + * metadata */ + /* @internal */ + (function (TypeReferenceSerializationKind) { + TypeReferenceSerializationKind[TypeReferenceSerializationKind["Unknown"] = 0] = "Unknown"; + // should be emitted using a safe fallback. + TypeReferenceSerializationKind[TypeReferenceSerializationKind["TypeWithConstructSignatureAndValue"] = 1] = "TypeWithConstructSignatureAndValue"; + // function that can be reached at runtime (e.g. a `class` + // declaration or a `var` declaration for the static side + // of a type, such as the global `Promise` type in lib.d.ts). + TypeReferenceSerializationKind[TypeReferenceSerializationKind["VoidType"] = 2] = "VoidType"; + TypeReferenceSerializationKind[TypeReferenceSerializationKind["NumberLikeType"] = 3] = "NumberLikeType"; + TypeReferenceSerializationKind[TypeReferenceSerializationKind["StringLikeType"] = 4] = "StringLikeType"; + TypeReferenceSerializationKind[TypeReferenceSerializationKind["BooleanType"] = 5] = "BooleanType"; + TypeReferenceSerializationKind[TypeReferenceSerializationKind["ArrayLikeType"] = 6] = "ArrayLikeType"; + TypeReferenceSerializationKind[TypeReferenceSerializationKind["ESSymbolType"] = 7] = "ESSymbolType"; + TypeReferenceSerializationKind[TypeReferenceSerializationKind["TypeWithCallSignature"] = 8] = "TypeWithCallSignature"; + // with call signatures. + TypeReferenceSerializationKind[TypeReferenceSerializationKind["ObjectType"] = 9] = "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"] = 793056] = "Type"; + SymbolFlags[SymbolFlags["Namespace"] = 1536] = "Namespace"; + SymbolFlags[SymbolFlags["Module"] = 1536] = "Module"; + SymbolFlags[SymbolFlags["Accessor"] = 98304] = "Accessor"; + // Variables can be redeclared, but can not redeclare a block-scoped declaration with the + // same name, or any other value that is not a variable, e.g. ValueModule or Class + SymbolFlags[SymbolFlags["FunctionScopedVariableExcludes"] = 107454] = "FunctionScopedVariableExcludes"; + // Block-scoped declarations are not allowed to be re-declared + // they can not merge with anything in the value space + SymbolFlags[SymbolFlags["BlockScopedVariableExcludes"] = 107455] = "BlockScopedVariableExcludes"; + SymbolFlags[SymbolFlags["ParameterExcludes"] = 107455] = "ParameterExcludes"; + SymbolFlags[SymbolFlags["PropertyExcludes"] = 107455] = "PropertyExcludes"; + SymbolFlags[SymbolFlags["EnumMemberExcludes"] = 107455] = "EnumMemberExcludes"; + SymbolFlags[SymbolFlags["FunctionExcludes"] = 106927] = "FunctionExcludes"; + SymbolFlags[SymbolFlags["ClassExcludes"] = 899519] = "ClassExcludes"; + SymbolFlags[SymbolFlags["InterfaceExcludes"] = 792960] = "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"] = 530912] = "TypeParameterExcludes"; + SymbolFlags[SymbolFlags["TypeAliasExcludes"] = 793056] = "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"; + /* @internal */ + // The set of things we consider semantically classifiable. Used to speed up the LS during + // classification. + SymbolFlags[SymbolFlags["Classifiable"] = 788448] = "Classifiable"; + })(ts.SymbolFlags || (ts.SymbolFlags = {})); + var SymbolFlags = ts.SymbolFlags; + /* @internal */ + (function (NodeCheckFlags) { + NodeCheckFlags[NodeCheckFlags["TypeChecked"] = 1] = "TypeChecked"; + NodeCheckFlags[NodeCheckFlags["LexicalThis"] = 2] = "LexicalThis"; + NodeCheckFlags[NodeCheckFlags["CaptureThis"] = 4] = "CaptureThis"; + NodeCheckFlags[NodeCheckFlags["EmitExtends"] = 8] = "EmitExtends"; + NodeCheckFlags[NodeCheckFlags["EmitDecorate"] = 16] = "EmitDecorate"; + NodeCheckFlags[NodeCheckFlags["EmitParam"] = 32] = "EmitParam"; + NodeCheckFlags[NodeCheckFlags["EmitAwaiter"] = 64] = "EmitAwaiter"; + NodeCheckFlags[NodeCheckFlags["EmitGenerator"] = 128] = "EmitGenerator"; + NodeCheckFlags[NodeCheckFlags["SuperInstance"] = 256] = "SuperInstance"; + NodeCheckFlags[NodeCheckFlags["SuperStatic"] = 512] = "SuperStatic"; + NodeCheckFlags[NodeCheckFlags["ContextChecked"] = 1024] = "ContextChecked"; + NodeCheckFlags[NodeCheckFlags["LexicalArguments"] = 2048] = "LexicalArguments"; + NodeCheckFlags[NodeCheckFlags["CaptureArguments"] = 4096] = "CaptureArguments"; + // Values for enum members have been computed, and any errors have been reported for them. + NodeCheckFlags[NodeCheckFlags["EnumValuesComputed"] = 8192] = "EnumValuesComputed"; + NodeCheckFlags[NodeCheckFlags["BlockScopedBindingInLoop"] = 16384] = "BlockScopedBindingInLoop"; + NodeCheckFlags[NodeCheckFlags["LexicalModuleMergesWithClass"] = 32768] = "LexicalModuleMergesWithClass"; + NodeCheckFlags[NodeCheckFlags["LoopWithBlockScopedBindingCapturedInFunction"] = 65536] = "LoopWithBlockScopedBindingCapturedInFunction"; + })(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["Void"] = 16] = "Void"; + TypeFlags[TypeFlags["Undefined"] = 32] = "Undefined"; + TypeFlags[TypeFlags["Null"] = 64] = "Null"; + TypeFlags[TypeFlags["Enum"] = 128] = "Enum"; + TypeFlags[TypeFlags["StringLiteral"] = 256] = "StringLiteral"; + TypeFlags[TypeFlags["TypeParameter"] = 512] = "TypeParameter"; + TypeFlags[TypeFlags["Class"] = 1024] = "Class"; + TypeFlags[TypeFlags["Interface"] = 2048] = "Interface"; + TypeFlags[TypeFlags["Reference"] = 4096] = "Reference"; + TypeFlags[TypeFlags["Tuple"] = 8192] = "Tuple"; + TypeFlags[TypeFlags["Union"] = 16384] = "Union"; + TypeFlags[TypeFlags["Intersection"] = 32768] = "Intersection"; + TypeFlags[TypeFlags["Anonymous"] = 65536] = "Anonymous"; + TypeFlags[TypeFlags["Instantiated"] = 131072] = "Instantiated"; + /* @internal */ + TypeFlags[TypeFlags["FromSignature"] = 262144] = "FromSignature"; + TypeFlags[TypeFlags["ObjectLiteral"] = 524288] = "ObjectLiteral"; + /* @internal */ + TypeFlags[TypeFlags["FreshObjectLiteral"] = 1048576] = "FreshObjectLiteral"; + /* @internal */ + TypeFlags[TypeFlags["ContainsUndefinedOrNull"] = 2097152] = "ContainsUndefinedOrNull"; + /* @internal */ + TypeFlags[TypeFlags["ContainsObjectLiteral"] = 4194304] = "ContainsObjectLiteral"; + /* @internal */ + TypeFlags[TypeFlags["ContainsAnyFunctionType"] = 8388608] = "ContainsAnyFunctionType"; + TypeFlags[TypeFlags["ESSymbol"] = 16777216] = "ESSymbol"; + TypeFlags[TypeFlags["ThisType"] = 33554432] = "ThisType"; + /* @internal */ + TypeFlags[TypeFlags["Intrinsic"] = 16777343] = "Intrinsic"; + /* @internal */ + TypeFlags[TypeFlags["Primitive"] = 16777726] = "Primitive"; + TypeFlags[TypeFlags["StringLike"] = 258] = "StringLike"; + TypeFlags[TypeFlags["NumberLike"] = 132] = "NumberLike"; + TypeFlags[TypeFlags["ObjectType"] = 80896] = "ObjectType"; + TypeFlags[TypeFlags["UnionOrIntersection"] = 49152] = "UnionOrIntersection"; + TypeFlags[TypeFlags["StructuredType"] = 130048] = "StructuredType"; + /* @internal */ + TypeFlags[TypeFlags["RequiresWidening"] = 6291456] = "RequiresWidening"; + /* @internal */ + TypeFlags[TypeFlags["PropagatingFlags"] = 14680064] = "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 (DiagnosticCategory) { + DiagnosticCategory[DiagnosticCategory["Warning"] = 0] = "Warning"; + DiagnosticCategory[DiagnosticCategory["Error"] = 1] = "Error"; + DiagnosticCategory[DiagnosticCategory["Message"] = 2] = "Message"; + })(ts.DiagnosticCategory || (ts.DiagnosticCategory = {})); + var DiagnosticCategory = ts.DiagnosticCategory; + (function (ModuleResolutionKind) { + ModuleResolutionKind[ModuleResolutionKind["Classic"] = 1] = "Classic"; + ModuleResolutionKind[ModuleResolutionKind["NodeJs"] = 2] = "NodeJs"; + })(ts.ModuleResolutionKind || (ts.ModuleResolutionKind = {})); + var ModuleResolutionKind = ts.ModuleResolutionKind; + (function (ModuleKind) { + ModuleKind[ModuleKind["None"] = 0] = "None"; + ModuleKind[ModuleKind["CommonJS"] = 1] = "CommonJS"; + 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 (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"; + })(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; + /* @internal */ + (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"; + // Unicode 3.0 space characters + 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; +})(ts || (ts = {})); +/// +/* @internal */ +var ts; +(function (ts) { + /** + * Ternary values are defined such that + * x & y is False if either x or y is False. + * x & y is Maybe if either x or y is Maybe, but neither x or y is False. + * x & y is True if both x and y are True. + * x | y is False if both x and y are False. + * x | y is Maybe if either x or y is Maybe, but neither x or y is True. + * x | y is True if either x or y is True. + */ + (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; + function createFileMap(getCanonicalFileName) { + var files = {}; + return { + get: get, + set: set, + contains: contains, + remove: remove, + clear: clear, + forEachValue: forEachValueInMap + }; + function set(fileName, value) { + files[normalizeKey(fileName)] = value; + } + function get(fileName) { + return files[normalizeKey(fileName)]; + } + function contains(fileName) { + return hasProperty(files, normalizeKey(fileName)); + } + function remove(fileName) { + var key = normalizeKey(fileName); + delete files[key]; + } + function forEachValueInMap(f) { + forEachValue(files, f); + } + function normalizeKey(key) { + return getCanonicalFileName(normalizeSlashes(key)); + } + function clear() { + files = {}; + } + } + ts.createFileMap = createFileMap; + (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; + /** + * Iterates through 'array' by index and performs the callback on each element of array until the callback + * returns a truthy value, then returns that value. + * If no such value is found, the callback is applied to each element of array and undefined is returned. + */ + function forEach(array, callback) { + if (array) { + for (var i = 0, len = array.length; i < len; i++) { + var result = callback(array[i], i); + if (result) { + return result; + } + } + } + return undefined; + } + ts.forEach = forEach; + function contains(array, value) { + if (array) { + for (var _i = 0; _i < array.length; _i++) { + var v = array[_i]; + if (v === value) { + return true; + } + } + } + return false; + } + ts.contains = contains; + function indexOf(array, value) { + if (array) { + for (var i = 0, len = array.length; i < len; i++) { + if (array[i] === value) { + return i; + } + } + } + return -1; + } + ts.indexOf = indexOf; + function countWhere(array, predicate) { + var count = 0; + if (array) { + for (var _i = 0; _i < array.length; _i++) { + var v = array[_i]; + if (predicate(v)) { + count++; + } + } + } + return count; + } + ts.countWhere = countWhere; + function filter(array, f) { + var result; + if (array) { + result = []; + for (var _i = 0; _i < array.length; _i++) { + var item = array[_i]; + if (f(item)) { + result.push(item); + } + } + } + return result; + } + ts.filter = filter; + function map(array, f) { + var result; + if (array) { + result = []; + for (var _i = 0; _i < array.length; _i++) { + var v = array[_i]; + result.push(f(v)); + } + } + return result; + } + ts.map = map; + function concatenate(array1, array2) { + if (!array2 || !array2.length) + return array1; + if (!array1 || !array1.length) + return array2; + return array1.concat(array2); + } + ts.concatenate = concatenate; + function deduplicate(array) { + var result; + if (array) { + result = []; + for (var _i = 0; _i < array.length; _i++) { + var item = array[_i]; + if (!contains(result, item)) { + result.push(item); + } + } + } + return result; + } + ts.deduplicate = deduplicate; + function sum(array, prop) { + var result = 0; + for (var _i = 0; _i < array.length; _i++) { + var v = array[_i]; + result += v[prop]; + } + return result; + } + ts.sum = sum; + function addRange(to, from) { + if (to && from) { + for (var _i = 0; _i < from.length; _i++) { + var v = from[_i]; + to.push(v); + } + } + } + ts.addRange = addRange; + function rangeEquals(array1, array2, pos, end) { + while (pos < end) { + if (array1[pos] !== array2[pos]) { + return false; + } + pos++; + } + return true; + } + ts.rangeEquals = rangeEquals; + /** + * Returns the last element of an array if non-empty, undefined otherwise. + */ + function lastOrUndefined(array) { + if (array.length === 0) { + return undefined; + } + return array[array.length - 1]; + } + ts.lastOrUndefined = lastOrUndefined; + /** + * 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 + * number[index] exceeds number. + * @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) { + var low = 0; + var high = array.length - 1; + while (low <= high) { + var middle = low + ((high - low) >> 1); + var midValue = array[middle]; + if (midValue === value) { + return middle; + } + else if (midValue > value) { + high = middle - 1; + } + else { + low = middle + 1; + } + } + return ~low; + } + ts.binarySearch = binarySearch; + function reduceLeft(array, f, initial) { + if (array) { + var count = array.length; + if (count > 0) { + var pos = 0; + var result = arguments.length <= 2 ? array[pos++] : initial; + while (pos < count) { + result = f(result, array[pos++]); + } + return result; + } + } + return initial; + } + ts.reduceLeft = reduceLeft; + function reduceRight(array, f, initial) { + if (array) { + var pos = array.length - 1; + if (pos >= 0) { + var result = arguments.length <= 2 ? array[pos--] : initial; + while (pos >= 0) { + result = f(result, array[pos--]); + } + return result; + } + } + return initial; + } + ts.reduceRight = reduceRight; + var hasOwnProperty = Object.prototype.hasOwnProperty; + function hasProperty(map, key) { + return hasOwnProperty.call(map, key); + } + ts.hasProperty = hasProperty; + function getProperty(map, key) { + return hasOwnProperty.call(map, key) ? map[key] : undefined; + } + ts.getProperty = getProperty; + function isEmpty(map) { + for (var id in map) { + if (hasProperty(map, id)) { + return false; + } + } + return true; + } + ts.isEmpty = isEmpty; + function clone(object) { + var result = {}; + for (var id in object) { + result[id] = object[id]; + } + return result; + } + ts.clone = clone; + function extend(first, second) { + var result = {}; + for (var id in first) { + result[id] = first[id]; + } + for (var id in second) { + if (!hasProperty(result, id)) { + result[id] = second[id]; + } + } + return result; + } + ts.extend = extend; + function forEachValue(map, callback) { + var result; + for (var id in map) { + if (result = callback(map[id])) + break; + } + return result; + } + ts.forEachValue = forEachValue; + function forEachKey(map, callback) { + var result; + for (var id in map) { + if (result = callback(id)) + break; + } + return result; + } + ts.forEachKey = forEachKey; + function lookUp(map, key) { + return hasProperty(map, key) ? map[key] : undefined; + } + ts.lookUp = lookUp; + function copyMap(source, target) { + for (var p in source) { + target[p] = source[p]; + } + } + ts.copyMap = copyMap; + /** + * Creates a map from the elements of an array. + * + * @param array the array of input elements. + * @param makeKey a function that produces a key for a given element. + * + * This function makes no effort to avoid collisions; if any two elements produce + * the same key with the given 'makeKey' function, then the element with the higher + * index in the array will be the one associated with the produced key. + */ + function arrayToMap(array, makeKey) { + var result = {}; + forEach(array, function (value) { + result[makeKey(value)] = value; + }); + return result; + } + ts.arrayToMap = arrayToMap; + function memoize(callback) { + var value; + return function () { + if (callback) { + value = callback(); + callback = undefined; + } + return value; + }; + } + ts.memoize = memoize; + function formatStringFromArgs(text, args, baseIndex) { + baseIndex = baseIndex || 0; + return text.replace(/{(\d+)}/g, function (match, index) { return args[+index + baseIndex]; }); + } + ts.localizedDiagnosticMessages = undefined; + function getLocaleSpecificMessage(message) { + return ts.localizedDiagnosticMessages && ts.localizedDiagnosticMessages[message.key] + ? ts.localizedDiagnosticMessages[message.key] + : message.message; + } + ts.getLocaleSpecificMessage = getLocaleSpecificMessage; + function createFileDiagnostic(file, start, length, message) { + var end = start + length; + Debug.assert(start >= 0, "start must be non-negative, is " + start); + Debug.assert(length >= 0, "length must be non-negative, is " + length); + if (file) { + Debug.assert(start <= file.text.length, "start must be within the bounds of the file. " + start + " > " + file.text.length); + Debug.assert(end <= file.text.length, "end must be the bounds of the file. " + end + " > " + file.text.length); + } + var text = getLocaleSpecificMessage(message); + if (arguments.length > 4) { + text = formatStringFromArgs(text, arguments, 4); + } + return { + file: file, + start: start, + length: length, + messageText: text, + category: message.category, + code: message.code + }; + } + ts.createFileDiagnostic = createFileDiagnostic; + function createCompilerDiagnostic(message) { + var text = getLocaleSpecificMessage(message); + if (arguments.length > 1) { + text = formatStringFromArgs(text, arguments, 1); + } + return { + file: undefined, + start: undefined, + length: undefined, + messageText: text, + category: message.category, + code: message.code + }; + } + ts.createCompilerDiagnostic = createCompilerDiagnostic; + function chainDiagnosticMessages(details, message) { + var text = getLocaleSpecificMessage(message); + if (arguments.length > 2) { + text = formatStringFromArgs(text, arguments, 2); + } + return { + messageText: text, + category: message.category, + code: message.code, + next: details + }; + } + ts.chainDiagnosticMessages = chainDiagnosticMessages; + function concatenateDiagnosticMessageChains(headChain, tailChain) { + var lastChain = headChain; + while (lastChain.next) { + lastChain = lastChain.next; + } + lastChain.next = tailChain; + return headChain; + } + ts.concatenateDiagnosticMessageChains = concatenateDiagnosticMessageChains; + function compareValues(a, b) { + if (a === b) + return 0 /* EqualTo */; + if (a === undefined) + return -1 /* LessThan */; + if (b === undefined) + return 1 /* GreaterThan */; + return a < b ? -1 /* LessThan */ : 1 /* GreaterThan */; + } + ts.compareValues = compareValues; + function getDiagnosticFileName(diagnostic) { + return diagnostic.file ? diagnostic.file.fileName : undefined; + } + function compareDiagnostics(d1, d2) { + return compareValues(getDiagnosticFileName(d1), getDiagnosticFileName(d2)) || + compareValues(d1.start, d2.start) || + compareValues(d1.length, d2.length) || + compareValues(d1.code, d2.code) || + compareMessageText(d1.messageText, d2.messageText) || + 0 /* EqualTo */; + } + ts.compareDiagnostics = compareDiagnostics; + function compareMessageText(text1, text2) { + while (text1 && text2) { + // We still have both chains. + var string1 = typeof text1 === "string" ? text1 : text1.messageText; + var string2 = typeof text2 === "string" ? text2 : text2.messageText; + var res = compareValues(string1, string2); + if (res) { + return res; + } + text1 = typeof text1 === "string" ? undefined : text1.next; + text2 = typeof text2 === "string" ? undefined : text2.next; + } + if (!text1 && !text2) { + // if the chains are done, then these messages are the same. + return 0 /* EqualTo */; + } + // We still have one chain remaining. The shorter chain should come first. + return text1 ? 1 /* GreaterThan */ : -1 /* LessThan */; + } + function sortAndDeduplicateDiagnostics(diagnostics) { + return deduplicateSortedDiagnostics(diagnostics.sort(compareDiagnostics)); + } + ts.sortAndDeduplicateDiagnostics = sortAndDeduplicateDiagnostics; + function deduplicateSortedDiagnostics(diagnostics) { + if (diagnostics.length < 2) { + return diagnostics; + } + var newDiagnostics = [diagnostics[0]]; + var previousDiagnostic = diagnostics[0]; + for (var i = 1; i < diagnostics.length; i++) { + var currentDiagnostic = diagnostics[i]; + var isDupe = compareDiagnostics(currentDiagnostic, previousDiagnostic) === 0 /* EqualTo */; + if (!isDupe) { + newDiagnostics.push(currentDiagnostic); + previousDiagnostic = currentDiagnostic; + } + } + return newDiagnostics; + } + ts.deduplicateSortedDiagnostics = deduplicateSortedDiagnostics; + function normalizeSlashes(path) { + return path.replace(/\\/g, "/"); + } + ts.normalizeSlashes = normalizeSlashes; + // 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 */) + return 1; + var p1 = path.indexOf("/", 2); + if (p1 < 0) + return 2; + var p2 = path.indexOf("/", p1 + 1); + if (p2 < 0) + return p1 + 1; + return p2 + 1; + } + if (path.charCodeAt(1) === 58 /* colon */) { + if (path.charCodeAt(2) === 47 /* slash */) + return 3; + return 2; + } + // Per RFC 1738 'file' URI schema has the shape file:/// + // if is omitted then it is assumed that host value is 'localhost', + // however slash after the omitted is not removed. + // file:///folder1/file1 - this is a correct URI + // file://folder2/file2 - this is an incorrect URI + if (path.lastIndexOf("file:///", 0) === 0) { + return "file:///".length; + } + var idx = path.indexOf("://"); + if (idx !== -1) { + return idx + "://".length; + } + return 0; + } + ts.getRootLength = getRootLength; + ts.directorySeparator = "/"; + function getNormalizedParts(normalizedSlashedPath, rootLength) { + var parts = normalizedSlashedPath.substr(rootLength).split(ts.directorySeparator); + var normalized = []; + for (var _i = 0; _i < parts.length; _i++) { + var part = parts[_i]; + if (part !== ".") { + if (part === ".." && normalized.length > 0 && lastOrUndefined(normalized) !== "..") { + normalized.pop(); + } + else { + // A part may be an empty string (which is 'falsy') if the path had consecutive slashes, + // e.g. "path//file.ts". Drop these before re-joining the parts. + if (part) { + normalized.push(part); + } + } + } + } + return normalized; + } + function normalizePath(path) { + path = normalizeSlashes(path); + var rootLength = getRootLength(path); + var normalized = getNormalizedParts(path, rootLength); + return path.substr(0, rootLength) + normalized.join(ts.directorySeparator); + } + ts.normalizePath = normalizePath; + function getDirectoryPath(path) { + return path.substr(0, Math.max(getRootLength(path), path.lastIndexOf(ts.directorySeparator))); + } + ts.getDirectoryPath = getDirectoryPath; + function isUrl(path) { + return path && !isRootedDiskPath(path) && path.indexOf("://") !== -1; + } + ts.isUrl = isUrl; + function isRootedDiskPath(path) { + return getRootLength(path) !== 0; + } + ts.isRootedDiskPath = isRootedDiskPath; + function normalizedPathComponents(path, rootLength) { + var normalizedParts = getNormalizedParts(path, rootLength); + return [path.substr(0, rootLength)].concat(normalizedParts); + } + function getNormalizedPathComponents(path, currentDirectory) { + path = normalizeSlashes(path); + var rootLength = getRootLength(path); + if (rootLength === 0) { + // If the path is not rooted it is relative to current directory + path = combinePaths(normalizeSlashes(currentDirectory), path); + rootLength = getRootLength(path); + } + return normalizedPathComponents(path, rootLength); + } + ts.getNormalizedPathComponents = getNormalizedPathComponents; + function getNormalizedAbsolutePath(fileName, currentDirectory) { + return getNormalizedPathFromPathComponents(getNormalizedPathComponents(fileName, currentDirectory)); + } + ts.getNormalizedAbsolutePath = getNormalizedAbsolutePath; + function getNormalizedPathFromPathComponents(pathComponents) { + if (pathComponents && pathComponents.length) { + return pathComponents[0] + pathComponents.slice(1).join(ts.directorySeparator); + } + } + ts.getNormalizedPathFromPathComponents = getNormalizedPathFromPathComponents; + function getNormalizedPathComponentsOfUrl(url) { + // Get root length of http://www.website.com/folder1/foler2/ + // In this example the root is: http://www.website.com/ + // normalized path components should be ["http://www.website.com/", "folder1", "folder2"] + var urlLength = url.length; + // Initial root length is http:// part + var rootLength = url.indexOf("://") + "://".length; + while (rootLength < urlLength) { + // Consume all immediate slashes in the protocol + // eg.initial rootlength is just file:// but it needs to consume another "/" in file:/// + if (url.charCodeAt(rootLength) === 47 /* slash */) { + rootLength++; + } + else { + // non slash character means we continue proceeding to next component of root search + break; + } + } + // there are no parts after http:// just return current string as the pathComponent + if (rootLength === urlLength) { + return [url]; + } + // Find the index of "/" after website.com so the root can be http://www.website.com/ (from existing http://) + var indexOfNextSlash = url.indexOf(ts.directorySeparator, rootLength); + if (indexOfNextSlash !== -1) { + // Found the "/" after the website.com so the root is length of http://www.website.com/ + // and get components afetr the root normally like any other folder components + rootLength = indexOfNextSlash + 1; + return normalizedPathComponents(url, rootLength); + } + else { + // Can't find the host assume the rest of the string as component + // but make sure we append "/" to it as root is not joined using "/" + // eg. if url passed in was http://website.com we want to use root as [http://website.com/] + // so that other path manipulations will be correct and it can be merged with relative paths correctly + return [url + ts.directorySeparator]; + } + } + function getNormalizedPathOrUrlComponents(pathOrUrl, currentDirectory) { + if (isUrl(pathOrUrl)) { + return getNormalizedPathComponentsOfUrl(pathOrUrl); + } + else { + return getNormalizedPathComponents(pathOrUrl, currentDirectory); + } + } + function getRelativePathToDirectoryOrUrl(directoryPathOrUrl, relativeOrAbsolutePath, currentDirectory, getCanonicalFileName, isAbsolutePathAnUrl) { + var pathComponents = getNormalizedPathOrUrlComponents(relativeOrAbsolutePath, currentDirectory); + var directoryComponents = getNormalizedPathOrUrlComponents(directoryPathOrUrl, currentDirectory); + if (directoryComponents.length > 1 && lastOrUndefined(directoryComponents) === "") { + // If the directory path given was of type test/cases/ then we really need components of directory to be only till its name + // that is ["test", "cases", ""] needs to be actually ["test", "cases"] + directoryComponents.length--; + } + // Find the component that differs + for (var joinStartIndex = 0; joinStartIndex < pathComponents.length && joinStartIndex < directoryComponents.length; joinStartIndex++) { + if (getCanonicalFileName(directoryComponents[joinStartIndex]) !== getCanonicalFileName(pathComponents[joinStartIndex])) { + break; + } + } + // Get the relative path + if (joinStartIndex) { + var relativePath = ""; + var relativePathComponents = pathComponents.slice(joinStartIndex, pathComponents.length); + for (; joinStartIndex < directoryComponents.length; joinStartIndex++) { + if (directoryComponents[joinStartIndex] !== "") { + relativePath = relativePath + ".." + ts.directorySeparator; + } + } + return relativePath + relativePathComponents.join(ts.directorySeparator); + } + // Cant find the relative path, get the absolute path + var absolutePath = getNormalizedPathFromPathComponents(pathComponents); + if (isAbsolutePathAnUrl && isRootedDiskPath(absolutePath)) { + absolutePath = "file:///" + absolutePath; + } + return absolutePath; + } + ts.getRelativePathToDirectoryOrUrl = getRelativePathToDirectoryOrUrl; + function getBaseFileName(path) { + if (!path) { + return undefined; + } + var i = path.lastIndexOf(ts.directorySeparator); + return i < 0 ? path : path.substring(i + 1); + } + ts.getBaseFileName = getBaseFileName; + function combinePaths(path1, path2) { + if (!(path1 && path1.length)) + return path2; + if (!(path2 && path2.length)) + return path1; + if (getRootLength(path2) !== 0) + return path2; + if (path1.charAt(path1.length - 1) === ts.directorySeparator) + return path1 + path2; + return path1 + ts.directorySeparator + path2; + } + ts.combinePaths = combinePaths; + function fileExtensionIs(path, extension) { + var pathLen = path.length; + var extLen = extension.length; + return pathLen > extLen && path.substr(pathLen - extLen, extLen) === extension; + } + ts.fileExtensionIs = fileExtensionIs; + /** + * List of supported extensions in order of file resolution precedence. + */ + ts.supportedExtensions = [".ts", ".tsx", ".d.ts"]; + /** + * List of extensions that will be used to look for external modules. + * This list is kept separate from supportedExtensions to for cases when we'll allow to include .js files in compilation, + * but still would like to load only TypeScript files as modules + */ + ts.moduleFileExtensions = ts.supportedExtensions; + function isSupportedSourceFileName(fileName) { + if (!fileName) { + return false; + } + for (var _i = 0; _i < ts.supportedExtensions.length; _i++) { + var extension = ts.supportedExtensions[_i]; + if (fileExtensionIs(fileName, extension)) { + return true; + } + } + return false; + } + ts.isSupportedSourceFileName = isSupportedSourceFileName; + var extensionsToRemove = [".d.ts", ".ts", ".js", ".tsx", ".jsx"]; + function removeFileExtension(path) { + for (var _i = 0; _i < extensionsToRemove.length; _i++) { + var ext = extensionsToRemove[_i]; + if (fileExtensionIs(path, ext)) { + return path.substr(0, path.length - ext.length); + } + } + return path; + } + ts.removeFileExtension = removeFileExtension; + var backslashOrDoubleQuote = /[\"\\]/g; + var escapedCharsRegExp = /[\u0000-\u001f\t\v\f\b\r\n\u2028\u2029\u0085]/g; + var escapedCharsMap = { + "\0": "\\0", + "\t": "\\t", + "\v": "\\v", + "\f": "\\f", + "\b": "\\b", + "\r": "\\r", + "\n": "\\n", + "\\": "\\\\", + "\"": "\\\"", + "\u2028": "\\u2028", + "\u2029": "\\u2029", + "\u0085": "\\u0085" // nextLine + }; + function Symbol(flags, name) { + this.flags = flags; + this.name = name; + this.declarations = undefined; + } + function Type(checker, flags) { + this.flags = flags; + } + function Signature(checker) { + } + ts.objectAllocator = { + getNodeConstructor: function (kind) { + function Node(pos, end) { + this.pos = pos; + this.end = end; + this.flags = 0 /* None */; + this.parent = undefined; + } + Node.prototype = { kind: kind }; + return Node; + }, + getSymbolConstructor: function () { return Symbol; }, + 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) { + var currentAssertionLevel = 0 /* None */; + function shouldAssert(level) { + return currentAssertionLevel >= level; + } + Debug.shouldAssert = shouldAssert; + function assert(expression, message, verboseDebugInfo) { + if (!expression) { + var verboseDebugString = ""; + if (verboseDebugInfo) { + verboseDebugString = "\r\nVerbose Debug Information: " + verboseDebugInfo(); + } + debugger; + throw new Error("Debug Failure. False expression: " + (message || "") + verboseDebugString); + } + } + Debug.assert = assert; + function fail(message) { + Debug.assert(false, message); + } + Debug.fail = fail; + })(Debug = ts.Debug || (ts.Debug = {})); + function copyListRemovingItem(item, list) { + var copiedList = []; + for (var _i = 0; _i < list.length; _i++) { + var e = list[_i]; + if (e !== item) { + copiedList.push(e); + } + } + return copiedList; + } + ts.copyListRemovingItem = copyListRemovingItem; +})(ts || (ts = {})); +/// +var ts; +(function (ts) { + ts.sys = (function () { + function getWScriptSystem() { + var fso = new ActiveXObject("Scripting.FileSystemObject"); + var fileStream = new ActiveXObject("ADODB.Stream"); + fileStream.Type = 2 /*text*/; + var binaryStream = new ActiveXObject("ADODB.Stream"); + binaryStream.Type = 1 /*binary*/; + var args = []; + for (var i = 0; i < WScript.Arguments.length; i++) { + args[i] = WScript.Arguments.Item(i); + } + function readFile(fileName, encoding) { + if (!fso.FileExists(fileName)) { + return undefined; + } + fileStream.Open(); + try { + if (encoding) { + fileStream.Charset = encoding; + fileStream.LoadFromFile(fileName); + } + else { + // Load file and read the first two bytes into a string with no interpretation + fileStream.Charset = "x-ansi"; + fileStream.LoadFromFile(fileName); + var bom = fileStream.ReadText(2) || ""; + // Position must be at 0 before encoding can be changed + fileStream.Position = 0; + // [0xFF,0xFE] and [0xFE,0xFF] mean utf-16 (little or big endian), otherwise default to utf-8 + fileStream.Charset = bom.length >= 2 && (bom.charCodeAt(0) === 0xFF && bom.charCodeAt(1) === 0xFE || bom.charCodeAt(0) === 0xFE && bom.charCodeAt(1) === 0xFF) ? "unicode" : "utf-8"; + } + // ReadText method always strips byte order mark from resulting string + return fileStream.ReadText(); + } + catch (e) { + throw e; + } + finally { + fileStream.Close(); + } + } + function writeFile(fileName, data, writeByteOrderMark) { + fileStream.Open(); + binaryStream.Open(); + try { + // Write characters in UTF-8 encoding + fileStream.Charset = "utf-8"; + fileStream.WriteText(data); + // If we don't want the BOM, then skip it by setting the starting location to 3 (size of BOM). + // If not, start from position 0, as the BOM will be added automatically when charset==utf8. + if (writeByteOrderMark) { + fileStream.Position = 0; + } + else { + fileStream.Position = 3; + } + fileStream.CopyTo(binaryStream); + binaryStream.SaveToFile(fileName, 2 /*overwrite*/); + } + finally { + binaryStream.Close(); + fileStream.Close(); + } + } + function getCanonicalPath(path) { + return path.toLowerCase(); + } + function getNames(collection) { + var result = []; + for (var e = new Enumerator(collection); !e.atEnd(); e.moveNext()) { + result.push(e.item().Name); + } + return result.sort(); + } + function readDirectory(path, extension, exclude) { + var result = []; + exclude = ts.map(exclude, function (s) { return getCanonicalPath(ts.combinePaths(path, s)); }); + visitDirectory(path); + return result; + function visitDirectory(path) { + var folder = fso.GetFolder(path || "."); + var files = getNames(folder.files); + for (var _i = 0; _i < files.length; _i++) { + var current = files[_i]; + var name_1 = ts.combinePaths(path, current); + if ((!extension || ts.fileExtensionIs(name_1, extension)) && !ts.contains(exclude, getCanonicalPath(name_1))) { + result.push(name_1); + } + } + var subfolders = getNames(folder.subfolders); + for (var _a = 0; _a < subfolders.length; _a++) { + var current = subfolders[_a]; + var name_2 = ts.combinePaths(path, current); + if (!ts.contains(exclude, getCanonicalPath(name_2))) { + visitDirectory(name_2); + } + } + } + } + return { + args: args, + newLine: "\r\n", + useCaseSensitiveFileNames: false, + write: function (s) { + WScript.StdOut.Write(s); + }, + readFile: readFile, + writeFile: writeFile, + resolvePath: function (path) { + return fso.GetAbsolutePathName(path); + }, + fileExists: function (path) { + return fso.FileExists(path); + }, + directoryExists: function (path) { + return fso.FolderExists(path); + }, + createDirectory: function (directoryName) { + if (!this.directoryExists(directoryName)) { + fso.CreateFolder(directoryName); + } + }, + getExecutingFilePath: function () { + return WScript.ScriptFullName; + }, + getCurrentDirectory: function () { + return new ActiveXObject("WScript.Shell").CurrentDirectory; + }, + readDirectory: readDirectory, + exit: function (exitCode) { + try { + WScript.Quit(exitCode); + } + catch (e) { + } + } + }; + } + function getNodeSystem() { + var _fs = require("fs"); + var _path = require("path"); + var _os = require("os"); + // average async stat takes about 30 microseconds + // set chunk size to do 30 files in < 1 millisecond + function createWatchedFileSet(interval, chunkSize) { + if (interval === void 0) { interval = 2500; } + if (chunkSize === void 0) { chunkSize = 30; } + var watchedFiles = []; + var nextFileToCheck = 0; + var watchTimer; + function getModifiedTime(fileName) { + return _fs.statSync(fileName).mtime; + } + function poll(checkedIndex) { + var watchedFile = watchedFiles[checkedIndex]; + if (!watchedFile) { + return; + } + _fs.stat(watchedFile.fileName, function (err, stats) { + if (err) { + watchedFile.callback(watchedFile.fileName); + } + else if (watchedFile.mtime.getTime() !== stats.mtime.getTime()) { + watchedFile.mtime = getModifiedTime(watchedFile.fileName); + watchedFile.callback(watchedFile.fileName, watchedFile.mtime.getTime() === 0); + } + }); + } + // this implementation uses polling and + // stat due to inconsistencies of fs.watch + // and efficiency of stat on modern filesystems + function startWatchTimer() { + watchTimer = setInterval(function () { + var count = 0; + var nextToCheck = nextFileToCheck; + var firstCheck = -1; + while ((count < chunkSize) && (nextToCheck !== firstCheck)) { + poll(nextToCheck); + if (firstCheck < 0) { + firstCheck = nextToCheck; + } + nextToCheck++; + if (nextToCheck === watchedFiles.length) { + nextToCheck = 0; + } + count++; + } + nextFileToCheck = nextToCheck; + }, interval); + } + function addFile(fileName, callback) { + var file = { + fileName: fileName, + callback: callback, + mtime: getModifiedTime(fileName) + }; + watchedFiles.push(file); + if (watchedFiles.length === 1) { + startWatchTimer(); + } + return file; + } + function removeFile(file) { + watchedFiles = ts.copyListRemovingItem(file, watchedFiles); + } + return { + getModifiedTime: getModifiedTime, + poll: poll, + startWatchTimer: startWatchTimer, + addFile: addFile, + removeFile: removeFile + }; + } + // REVIEW: for now this implementation uses polling. + // The advantage of polling is that it works reliably + // on all os and with network mounted files. + // For 90 referenced files, the average time to detect + // changes is 2*msInterval (by default 5 seconds). + // The overhead of this is .04 percent (1/2500) with + // average pause of < 1 millisecond (and max + // pause less than 1.5 milliseconds); question is + // do we anticipate reference sets in the 100s and + // do we care about waiting 10-20 seconds to detect + // changes for large reference sets? If so, do we want + // to increase the chunk size or decrease the interval + // time dynamically to match the large reference set? + var watchedFileSet = createWatchedFileSet(); + function isNode4OrLater() { + return parseInt(process.version.charAt(1)) >= 4; + } + 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"; + function readFile(fileName, encoding) { + if (!_fs.existsSync(fileName)) { + return undefined; + } + var buffer = _fs.readFileSync(fileName); + var len = buffer.length; + if (len >= 2 && buffer[0] === 0xFE && buffer[1] === 0xFF) { + // Big endian UTF-16 byte order mark detected. Since big endian is not supported by node.js, + // flip all byte pairs and treat as little endian. + len &= ~1; + for (var i = 0; i < len; i += 2) { + var temp = buffer[i]; + buffer[i] = buffer[i + 1]; + buffer[i + 1] = temp; + } + return buffer.toString("utf16le", 2); + } + if (len >= 2 && buffer[0] === 0xFF && buffer[1] === 0xFE) { + // Little endian UTF-16 byte order mark detected + return buffer.toString("utf16le", 2); + } + if (len >= 3 && buffer[0] === 0xEF && buffer[1] === 0xBB && buffer[2] === 0xBF) { + // UTF-8 byte order mark detected + return buffer.toString("utf8", 3); + } + // Default is UTF-8 with no byte order mark + return buffer.toString("utf8"); + } + function writeFile(fileName, data, writeByteOrderMark) { + // If a BOM is required, emit one + if (writeByteOrderMark) { + data = "\uFEFF" + data; + } + _fs.writeFileSync(fileName, data, "utf8"); + } + function getCanonicalPath(path) { + return useCaseSensitiveFileNames ? path.toLowerCase() : path; + } + function readDirectory(path, extension, exclude) { + var result = []; + exclude = ts.map(exclude, function (s) { return getCanonicalPath(ts.combinePaths(path, s)); }); + visitDirectory(path); + return result; + function visitDirectory(path) { + var files = _fs.readdirSync(path || ".").sort(); + var directories = []; + for (var _i = 0; _i < files.length; _i++) { + var current = files[_i]; + var name_3 = ts.combinePaths(path, current); + if (!ts.contains(exclude, getCanonicalPath(name_3))) { + var stat = _fs.statSync(name_3); + if (stat.isFile()) { + if (!extension || ts.fileExtensionIs(name_3, extension)) { + result.push(name_3); + } + } + else if (stat.isDirectory()) { + directories.push(name_3); + } + } + } + for (var _a = 0; _a < directories.length; _a++) { + var current = directories[_a]; + visitDirectory(current); + } + } + } + return { + args: process.argv.slice(2), + newLine: _os.EOL, + useCaseSensitiveFileNames: useCaseSensitiveFileNames, + write: function (s) { + var buffer = new Buffer(s, "utf8"); + var offset = 0; + var toWrite = buffer.length; + var written = 0; + // 1 is a standard descriptor for stdout + while ((written = _fs.writeSync(1, buffer, offset, toWrite)) < toWrite) { + offset += written; + toWrite -= written; + } + }, + readFile: readFile, + writeFile: writeFile, + watchFile: function (fileName, callback) { + // Node 4.0 stablized the `fs.watch` function on Windows which avoids polling + // and is more efficient than `fs.watchFile` (ref: https://github.com/nodejs/node/pull/2649 + // and https://github.com/Microsoft/TypeScript/issues/4643), therefore + // if the current node.js version is newer than 4, use `fs.watch` instead. + if (isNode4OrLater()) { + // Note: in node the callback of fs.watch is given only the relative file name as a parameter + return _fs.watch(fileName, function (eventName, relativeFileName) { return callback(fileName); }); + } + var watchedFile = watchedFileSet.addFile(fileName, callback); + return { + close: function () { return watchedFileSet.removeFile(watchedFile); } + }; + }, + watchDirectory: function (path, callback, recursive) { + // 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) + return _fs.watch(path, { persistent: true, recursive: !!recursive }, function (eventName, relativeFileName) { + // In watchDirectory we only care about adding and removing files (when event name is + // "rename"); changes made within files are handled by corresponding fileWatchers (when + // event name is "change") + if (eventName === "rename") { + // When deleting a file, the passed baseFileName is null + callback(!relativeFileName ? relativeFileName : ts.normalizePath(ts.combinePaths(path, relativeFileName))); + } + ; + }); + }, + resolvePath: function (path) { + return _path.resolve(path); + }, + fileExists: function (path) { + return _fs.existsSync(path); + }, + directoryExists: function (path) { + return _fs.existsSync(path) && _fs.statSync(path).isDirectory(); + }, + createDirectory: function (directoryName) { + if (!this.directoryExists(directoryName)) { + _fs.mkdirSync(directoryName); + } + }, + getExecutingFilePath: function () { + return __filename; + }, + getCurrentDirectory: function () { + return process.cwd(); + }, + readDirectory: readDirectory, + getMemoryUsage: function () { + if (global.gc) { + global.gc(); + } + return process.memoryUsage().heapUsed; + }, + exit: function (exitCode) { + process.exit(exitCode); + } + }; + } + if (typeof WScript !== "undefined" && typeof ActiveXObject === "function") { + return 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(); + } + else { + return undefined; // Unsupported host + } + })(); +})(ts || (ts = {})); +// +/// +/* @internal */ +var ts; +(function (ts) { + ts.Diagnostics = { + Unterminated_string_literal: { code: 1002, category: ts.DiagnosticCategory.Error, key: "Unterminated_string_literal_1002", message: "Unterminated string literal." }, + Identifier_expected: { code: 1003, category: ts.DiagnosticCategory.Error, key: "Identifier_expected_1003", message: "Identifier expected." }, + _0_expected: { code: 1005, category: ts.DiagnosticCategory.Error, key: "_0_expected_1005", message: "'{0}' expected." }, + A_file_cannot_have_a_reference_to_itself: { code: 1006, category: ts.DiagnosticCategory.Error, key: "A_file_cannot_have_a_reference_to_itself_1006", message: "A file cannot have a reference to itself." }, + Trailing_comma_not_allowed: { code: 1009, category: ts.DiagnosticCategory.Error, key: "Trailing_comma_not_allowed_1009", message: "Trailing comma not allowed." }, + Asterisk_Slash_expected: { code: 1010, category: ts.DiagnosticCategory.Error, key: "Asterisk_Slash_expected_1010", message: "'*/' expected." }, + Unexpected_token: { code: 1012, category: ts.DiagnosticCategory.Error, key: "Unexpected_token_1012", message: "Unexpected token." }, + A_rest_parameter_must_be_last_in_a_parameter_list: { code: 1014, category: ts.DiagnosticCategory.Error, key: "A_rest_parameter_must_be_last_in_a_parameter_list_1014", message: "A rest parameter must be last in a parameter list." }, + Parameter_cannot_have_question_mark_and_initializer: { code: 1015, category: ts.DiagnosticCategory.Error, key: "Parameter_cannot_have_question_mark_and_initializer_1015", message: "Parameter cannot have question mark and initializer." }, + A_required_parameter_cannot_follow_an_optional_parameter: { code: 1016, category: ts.DiagnosticCategory.Error, key: "A_required_parameter_cannot_follow_an_optional_parameter_1016", message: "A required parameter cannot follow an optional parameter." }, + An_index_signature_cannot_have_a_rest_parameter: { code: 1017, category: ts.DiagnosticCategory.Error, key: "An_index_signature_cannot_have_a_rest_parameter_1017", message: "An index signature cannot have a rest parameter." }, + An_index_signature_parameter_cannot_have_an_accessibility_modifier: { code: 1018, category: ts.DiagnosticCategory.Error, key: "An_index_signature_parameter_cannot_have_an_accessibility_modifier_1018", message: "An index signature parameter cannot have an accessibility modifier." }, + An_index_signature_parameter_cannot_have_a_question_mark: { code: 1019, category: ts.DiagnosticCategory.Error, key: "An_index_signature_parameter_cannot_have_a_question_mark_1019", message: "An index signature parameter cannot have a question mark." }, + An_index_signature_parameter_cannot_have_an_initializer: { code: 1020, category: ts.DiagnosticCategory.Error, key: "An_index_signature_parameter_cannot_have_an_initializer_1020", message: "An index signature parameter cannot have an initializer." }, + An_index_signature_must_have_a_type_annotation: { code: 1021, category: ts.DiagnosticCategory.Error, key: "An_index_signature_must_have_a_type_annotation_1021", message: "An index signature must have a type annotation." }, + An_index_signature_parameter_must_have_a_type_annotation: { code: 1022, category: ts.DiagnosticCategory.Error, key: "An_index_signature_parameter_must_have_a_type_annotation_1022", message: "An index signature parameter must have a type annotation." }, + An_index_signature_parameter_type_must_be_string_or_number: { code: 1023, category: ts.DiagnosticCategory.Error, key: "An_index_signature_parameter_type_must_be_string_or_number_1023", message: "An index signature parameter type must be 'string' or 'number'." }, + Accessibility_modifier_already_seen: { code: 1028, category: ts.DiagnosticCategory.Error, key: "Accessibility_modifier_already_seen_1028", message: "Accessibility modifier already seen." }, + _0_modifier_must_precede_1_modifier: { code: 1029, category: ts.DiagnosticCategory.Error, key: "_0_modifier_must_precede_1_modifier_1029", message: "'{0}' modifier must precede '{1}' modifier." }, + _0_modifier_already_seen: { code: 1030, category: ts.DiagnosticCategory.Error, key: "_0_modifier_already_seen_1030", message: "'{0}' modifier already seen." }, + _0_modifier_cannot_appear_on_a_class_element: { code: 1031, category: ts.DiagnosticCategory.Error, key: "_0_modifier_cannot_appear_on_a_class_element_1031", message: "'{0}' modifier cannot appear on a class element." }, + super_must_be_followed_by_an_argument_list_or_member_access: { code: 1034, category: ts.DiagnosticCategory.Error, key: "super_must_be_followed_by_an_argument_list_or_member_access_1034", message: "'super' must be followed by an argument list or member access." }, + Only_ambient_modules_can_use_quoted_names: { code: 1035, category: ts.DiagnosticCategory.Error, key: "Only_ambient_modules_can_use_quoted_names_1035", message: "Only ambient modules can use quoted names." }, + Statements_are_not_allowed_in_ambient_contexts: { code: 1036, category: ts.DiagnosticCategory.Error, key: "Statements_are_not_allowed_in_ambient_contexts_1036", message: "Statements are not allowed in ambient contexts." }, + A_declare_modifier_cannot_be_used_in_an_already_ambient_context: { code: 1038, category: ts.DiagnosticCategory.Error, key: "A_declare_modifier_cannot_be_used_in_an_already_ambient_context_1038", message: "A 'declare' modifier cannot be used in an already ambient context." }, + Initializers_are_not_allowed_in_ambient_contexts: { code: 1039, category: ts.DiagnosticCategory.Error, key: "Initializers_are_not_allowed_in_ambient_contexts_1039", message: "Initializers are not allowed in ambient contexts." }, + _0_modifier_cannot_be_used_in_an_ambient_context: { code: 1040, category: ts.DiagnosticCategory.Error, key: "_0_modifier_cannot_be_used_in_an_ambient_context_1040", message: "'{0}' modifier cannot be used in an ambient context." }, + _0_modifier_cannot_be_used_with_a_class_declaration: { code: 1041, category: ts.DiagnosticCategory.Error, key: "_0_modifier_cannot_be_used_with_a_class_declaration_1041", message: "'{0}' modifier cannot be used with a class declaration." }, + _0_modifier_cannot_be_used_here: { code: 1042, category: ts.DiagnosticCategory.Error, key: "_0_modifier_cannot_be_used_here_1042", message: "'{0}' modifier cannot be used here." }, + _0_modifier_cannot_appear_on_a_data_property: { code: 1043, category: ts.DiagnosticCategory.Error, key: "_0_modifier_cannot_appear_on_a_data_property_1043", message: "'{0}' modifier cannot appear on a data property." }, + _0_modifier_cannot_appear_on_a_module_element: { code: 1044, category: ts.DiagnosticCategory.Error, key: "_0_modifier_cannot_appear_on_a_module_element_1044", message: "'{0}' modifier cannot appear on a module element." }, + A_0_modifier_cannot_be_used_with_an_interface_declaration: { code: 1045, category: ts.DiagnosticCategory.Error, key: "A_0_modifier_cannot_be_used_with_an_interface_declaration_1045", message: "A '{0}' modifier cannot be used with an interface declaration." }, + A_declare_modifier_is_required_for_a_top_level_declaration_in_a_d_ts_file: { code: 1046, category: ts.DiagnosticCategory.Error, key: "A_declare_modifier_is_required_for_a_top_level_declaration_in_a_d_ts_file_1046", message: "A 'declare' modifier is required for a top level declaration in a .d.ts file." }, + A_rest_parameter_cannot_be_optional: { code: 1047, category: ts.DiagnosticCategory.Error, key: "A_rest_parameter_cannot_be_optional_1047", message: "A rest parameter cannot be optional." }, + A_rest_parameter_cannot_have_an_initializer: { code: 1048, category: ts.DiagnosticCategory.Error, key: "A_rest_parameter_cannot_have_an_initializer_1048", message: "A rest parameter cannot have an initializer." }, + A_set_accessor_must_have_exactly_one_parameter: { code: 1049, category: ts.DiagnosticCategory.Error, key: "A_set_accessor_must_have_exactly_one_parameter_1049", message: "A 'set' accessor must have exactly one parameter." }, + A_set_accessor_cannot_have_an_optional_parameter: { code: 1051, category: ts.DiagnosticCategory.Error, key: "A_set_accessor_cannot_have_an_optional_parameter_1051", message: "A 'set' accessor cannot have an optional parameter." }, + A_set_accessor_parameter_cannot_have_an_initializer: { code: 1052, category: ts.DiagnosticCategory.Error, key: "A_set_accessor_parameter_cannot_have_an_initializer_1052", message: "A 'set' accessor parameter cannot have an initializer." }, + A_set_accessor_cannot_have_rest_parameter: { code: 1053, category: ts.DiagnosticCategory.Error, key: "A_set_accessor_cannot_have_rest_parameter_1053", message: "A 'set' accessor cannot have rest parameter." }, + A_get_accessor_cannot_have_parameters: { code: 1054, category: ts.DiagnosticCategory.Error, key: "A_get_accessor_cannot_have_parameters_1054", message: "A 'get' accessor cannot have parameters." }, + Type_0_is_not_a_valid_async_function_return_type: { code: 1055, category: ts.DiagnosticCategory.Error, key: "Type_0_is_not_a_valid_async_function_return_type_1055", message: "Type '{0}' is not a valid async function return type." }, + Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher: { code: 1056, category: ts.DiagnosticCategory.Error, key: "Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher_1056", message: "Accessors are only available when targeting ECMAScript 5 and higher." }, + An_async_function_or_method_must_have_a_valid_awaitable_return_type: { code: 1057, category: ts.DiagnosticCategory.Error, key: "An_async_function_or_method_must_have_a_valid_awaitable_return_type_1057", message: "An async function or method must have a valid awaitable return type." }, + Operand_for_await_does_not_have_a_valid_callable_then_member: { code: 1058, category: ts.DiagnosticCategory.Error, key: "Operand_for_await_does_not_have_a_valid_callable_then_member_1058", message: "Operand for 'await' does not have a valid callable 'then' member." }, + Return_expression_in_async_function_does_not_have_a_valid_callable_then_member: { code: 1059, category: ts.DiagnosticCategory.Error, key: "Return_expression_in_async_function_does_not_have_a_valid_callable_then_member_1059", message: "Return expression in async function does not have a valid callable 'then' member." }, + Expression_body_for_async_arrow_function_does_not_have_a_valid_callable_then_member: { code: 1060, category: ts.DiagnosticCategory.Error, key: "Expression_body_for_async_arrow_function_does_not_have_a_valid_callable_then_member_1060", message: "Expression body for async arrow function does not have a valid callable 'then' member." }, + Enum_member_must_have_initializer: { code: 1061, category: ts.DiagnosticCategory.Error, key: "Enum_member_must_have_initializer_1061", message: "Enum member must have initializer." }, + _0_is_referenced_directly_or_indirectly_in_the_fulfillment_callback_of_its_own_then_method: { code: 1062, category: ts.DiagnosticCategory.Error, key: "_0_is_referenced_directly_or_indirectly_in_the_fulfillment_callback_of_its_own_then_method_1062", message: "{0} is referenced directly or indirectly in the fulfillment callback of its own 'then' method." }, + An_export_assignment_cannot_be_used_in_a_namespace: { code: 1063, category: ts.DiagnosticCategory.Error, key: "An_export_assignment_cannot_be_used_in_a_namespace_1063", message: "An export assignment cannot be used in a namespace." }, + In_ambient_enum_declarations_member_initializer_must_be_constant_expression: { code: 1066, category: ts.DiagnosticCategory.Error, key: "In_ambient_enum_declarations_member_initializer_must_be_constant_expression_1066", message: "In ambient enum declarations member initializer must be constant expression." }, + Unexpected_token_A_constructor_method_accessor_or_property_was_expected: { code: 1068, category: ts.DiagnosticCategory.Error, key: "Unexpected_token_A_constructor_method_accessor_or_property_was_expected_1068", message: "Unexpected token. A constructor, method, accessor, or property was expected." }, + A_0_modifier_cannot_be_used_with_an_import_declaration: { code: 1079, category: ts.DiagnosticCategory.Error, key: "A_0_modifier_cannot_be_used_with_an_import_declaration_1079", message: "A '{0}' modifier cannot be used with an import declaration." }, + Invalid_reference_directive_syntax: { code: 1084, category: ts.DiagnosticCategory.Error, key: "Invalid_reference_directive_syntax_1084", message: "Invalid 'reference' directive syntax." }, + Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher: { code: 1085, category: ts.DiagnosticCategory.Error, key: "Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher_1085", message: "Octal literals are not available when targeting ECMAScript 5 and higher." }, + An_accessor_cannot_be_declared_in_an_ambient_context: { code: 1086, category: ts.DiagnosticCategory.Error, key: "An_accessor_cannot_be_declared_in_an_ambient_context_1086", message: "An accessor cannot be declared in an ambient context." }, + _0_modifier_cannot_appear_on_a_constructor_declaration: { code: 1089, category: ts.DiagnosticCategory.Error, key: "_0_modifier_cannot_appear_on_a_constructor_declaration_1089", message: "'{0}' modifier cannot appear on a constructor declaration." }, + _0_modifier_cannot_appear_on_a_parameter: { code: 1090, category: ts.DiagnosticCategory.Error, key: "_0_modifier_cannot_appear_on_a_parameter_1090", message: "'{0}' modifier cannot appear on a parameter." }, + Only_a_single_variable_declaration_is_allowed_in_a_for_in_statement: { code: 1091, category: ts.DiagnosticCategory.Error, key: "Only_a_single_variable_declaration_is_allowed_in_a_for_in_statement_1091", message: "Only a single variable declaration is allowed in a 'for...in' statement." }, + Type_parameters_cannot_appear_on_a_constructor_declaration: { code: 1092, category: ts.DiagnosticCategory.Error, key: "Type_parameters_cannot_appear_on_a_constructor_declaration_1092", message: "Type parameters cannot appear on a constructor declaration." }, + Type_annotation_cannot_appear_on_a_constructor_declaration: { code: 1093, category: ts.DiagnosticCategory.Error, key: "Type_annotation_cannot_appear_on_a_constructor_declaration_1093", message: "Type annotation cannot appear on a constructor declaration." }, + An_accessor_cannot_have_type_parameters: { code: 1094, category: ts.DiagnosticCategory.Error, key: "An_accessor_cannot_have_type_parameters_1094", message: "An accessor cannot have type parameters." }, + A_set_accessor_cannot_have_a_return_type_annotation: { code: 1095, category: ts.DiagnosticCategory.Error, key: "A_set_accessor_cannot_have_a_return_type_annotation_1095", message: "A 'set' accessor cannot have a return type annotation." }, + An_index_signature_must_have_exactly_one_parameter: { code: 1096, category: ts.DiagnosticCategory.Error, key: "An_index_signature_must_have_exactly_one_parameter_1096", message: "An index signature must have exactly one parameter." }, + _0_list_cannot_be_empty: { code: 1097, category: ts.DiagnosticCategory.Error, key: "_0_list_cannot_be_empty_1097", message: "'{0}' list cannot be empty." }, + Type_parameter_list_cannot_be_empty: { code: 1098, category: ts.DiagnosticCategory.Error, key: "Type_parameter_list_cannot_be_empty_1098", message: "Type parameter list cannot be empty." }, + Type_argument_list_cannot_be_empty: { code: 1099, category: ts.DiagnosticCategory.Error, key: "Type_argument_list_cannot_be_empty_1099", message: "Type argument list cannot be empty." }, + Invalid_use_of_0_in_strict_mode: { code: 1100, category: ts.DiagnosticCategory.Error, key: "Invalid_use_of_0_in_strict_mode_1100", message: "Invalid use of '{0}' in strict mode." }, + with_statements_are_not_allowed_in_strict_mode: { code: 1101, category: ts.DiagnosticCategory.Error, key: "with_statements_are_not_allowed_in_strict_mode_1101", message: "'with' statements are not allowed in strict mode." }, + delete_cannot_be_called_on_an_identifier_in_strict_mode: { code: 1102, category: ts.DiagnosticCategory.Error, key: "delete_cannot_be_called_on_an_identifier_in_strict_mode_1102", message: "'delete' cannot be called on an identifier in strict mode." }, + A_continue_statement_can_only_be_used_within_an_enclosing_iteration_statement: { code: 1104, category: ts.DiagnosticCategory.Error, key: "A_continue_statement_can_only_be_used_within_an_enclosing_iteration_statement_1104", message: "A 'continue' statement can only be used within an enclosing iteration statement." }, + A_break_statement_can_only_be_used_within_an_enclosing_iteration_or_switch_statement: { code: 1105, category: ts.DiagnosticCategory.Error, key: "A_break_statement_can_only_be_used_within_an_enclosing_iteration_or_switch_statement_1105", message: "A 'break' statement can only be used within an enclosing iteration or switch statement." }, + Jump_target_cannot_cross_function_boundary: { code: 1107, category: ts.DiagnosticCategory.Error, key: "Jump_target_cannot_cross_function_boundary_1107", message: "Jump target cannot cross function boundary." }, + A_return_statement_can_only_be_used_within_a_function_body: { code: 1108, category: ts.DiagnosticCategory.Error, key: "A_return_statement_can_only_be_used_within_a_function_body_1108", message: "A 'return' statement can only be used within a function body." }, + Expression_expected: { code: 1109, category: ts.DiagnosticCategory.Error, key: "Expression_expected_1109", message: "Expression expected." }, + Type_expected: { code: 1110, category: ts.DiagnosticCategory.Error, key: "Type_expected_1110", message: "Type expected." }, + A_class_member_cannot_be_declared_optional: { code: 1112, category: ts.DiagnosticCategory.Error, key: "A_class_member_cannot_be_declared_optional_1112", message: "A class member cannot be declared optional." }, + A_default_clause_cannot_appear_more_than_once_in_a_switch_statement: { code: 1113, category: ts.DiagnosticCategory.Error, key: "A_default_clause_cannot_appear_more_than_once_in_a_switch_statement_1113", message: "A 'default' clause cannot appear more than once in a 'switch' statement." }, + Duplicate_label_0: { code: 1114, category: ts.DiagnosticCategory.Error, key: "Duplicate_label_0_1114", message: "Duplicate label '{0}'" }, + A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement: { code: 1115, category: ts.DiagnosticCategory.Error, key: "A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement_1115", message: "A 'continue' statement can only jump to a label of an enclosing iteration statement." }, + A_break_statement_can_only_jump_to_a_label_of_an_enclosing_statement: { code: 1116, category: ts.DiagnosticCategory.Error, key: "A_break_statement_can_only_jump_to_a_label_of_an_enclosing_statement_1116", message: "A 'break' statement can only jump to a label of an enclosing statement." }, + An_object_literal_cannot_have_multiple_properties_with_the_same_name_in_strict_mode: { code: 1117, category: ts.DiagnosticCategory.Error, key: "An_object_literal_cannot_have_multiple_properties_with_the_same_name_in_strict_mode_1117", message: "An object literal cannot have multiple properties with the same name in strict mode." }, + An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name: { code: 1118, category: ts.DiagnosticCategory.Error, key: "An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name_1118", message: "An object literal cannot have multiple get/set accessors with the same name." }, + An_object_literal_cannot_have_property_and_accessor_with_the_same_name: { code: 1119, category: ts.DiagnosticCategory.Error, key: "An_object_literal_cannot_have_property_and_accessor_with_the_same_name_1119", message: "An object literal cannot have property and accessor with the same name." }, + An_export_assignment_cannot_have_modifiers: { code: 1120, category: ts.DiagnosticCategory.Error, key: "An_export_assignment_cannot_have_modifiers_1120", message: "An export assignment cannot have modifiers." }, + Octal_literals_are_not_allowed_in_strict_mode: { code: 1121, category: ts.DiagnosticCategory.Error, key: "Octal_literals_are_not_allowed_in_strict_mode_1121", message: "Octal literals are not allowed in strict mode." }, + A_tuple_type_element_list_cannot_be_empty: { code: 1122, category: ts.DiagnosticCategory.Error, key: "A_tuple_type_element_list_cannot_be_empty_1122", message: "A tuple type element list cannot be empty." }, + Variable_declaration_list_cannot_be_empty: { code: 1123, category: ts.DiagnosticCategory.Error, key: "Variable_declaration_list_cannot_be_empty_1123", message: "Variable declaration list cannot be empty." }, + Digit_expected: { code: 1124, category: ts.DiagnosticCategory.Error, key: "Digit_expected_1124", message: "Digit expected." }, + Hexadecimal_digit_expected: { code: 1125, category: ts.DiagnosticCategory.Error, key: "Hexadecimal_digit_expected_1125", message: "Hexadecimal digit expected." }, + Unexpected_end_of_text: { code: 1126, category: ts.DiagnosticCategory.Error, key: "Unexpected_end_of_text_1126", message: "Unexpected end of text." }, + Invalid_character: { code: 1127, category: ts.DiagnosticCategory.Error, key: "Invalid_character_1127", message: "Invalid character." }, + Declaration_or_statement_expected: { code: 1128, category: ts.DiagnosticCategory.Error, key: "Declaration_or_statement_expected_1128", message: "Declaration or statement expected." }, + Statement_expected: { code: 1129, category: ts.DiagnosticCategory.Error, key: "Statement_expected_1129", message: "Statement expected." }, + case_or_default_expected: { code: 1130, category: ts.DiagnosticCategory.Error, key: "case_or_default_expected_1130", message: "'case' or 'default' expected." }, + Property_or_signature_expected: { code: 1131, category: ts.DiagnosticCategory.Error, key: "Property_or_signature_expected_1131", message: "Property or signature expected." }, + Enum_member_expected: { code: 1132, category: ts.DiagnosticCategory.Error, key: "Enum_member_expected_1132", message: "Enum member expected." }, + Variable_declaration_expected: { code: 1134, category: ts.DiagnosticCategory.Error, key: "Variable_declaration_expected_1134", message: "Variable declaration expected." }, + Argument_expression_expected: { code: 1135, category: ts.DiagnosticCategory.Error, key: "Argument_expression_expected_1135", message: "Argument expression expected." }, + Property_assignment_expected: { code: 1136, category: ts.DiagnosticCategory.Error, key: "Property_assignment_expected_1136", message: "Property assignment expected." }, + Expression_or_comma_expected: { code: 1137, category: ts.DiagnosticCategory.Error, key: "Expression_or_comma_expected_1137", message: "Expression or comma expected." }, + Parameter_declaration_expected: { code: 1138, category: ts.DiagnosticCategory.Error, key: "Parameter_declaration_expected_1138", message: "Parameter declaration expected." }, + Type_parameter_declaration_expected: { code: 1139, category: ts.DiagnosticCategory.Error, key: "Type_parameter_declaration_expected_1139", message: "Type parameter declaration expected." }, + Type_argument_expected: { code: 1140, category: ts.DiagnosticCategory.Error, key: "Type_argument_expected_1140", message: "Type argument expected." }, + String_literal_expected: { code: 1141, category: ts.DiagnosticCategory.Error, key: "String_literal_expected_1141", message: "String literal expected." }, + Line_break_not_permitted_here: { code: 1142, category: ts.DiagnosticCategory.Error, key: "Line_break_not_permitted_here_1142", message: "Line break not permitted here." }, + or_expected: { code: 1144, category: ts.DiagnosticCategory.Error, key: "or_expected_1144", message: "'{' or ';' expected." }, + Modifiers_not_permitted_on_index_signature_members: { code: 1145, category: ts.DiagnosticCategory.Error, key: "Modifiers_not_permitted_on_index_signature_members_1145", message: "Modifiers not permitted on index signature members." }, + Declaration_expected: { code: 1146, category: ts.DiagnosticCategory.Error, key: "Declaration_expected_1146", message: "Declaration expected." }, + Import_declarations_in_a_namespace_cannot_reference_a_module: { code: 1147, category: ts.DiagnosticCategory.Error, key: "Import_declarations_in_a_namespace_cannot_reference_a_module_1147", message: "Import declarations in a namespace cannot reference a module." }, + Cannot_compile_modules_unless_the_module_flag_is_provided: { code: 1148, category: ts.DiagnosticCategory.Error, key: "Cannot_compile_modules_unless_the_module_flag_is_provided_1148", message: "Cannot compile modules unless the '--module' flag is provided." }, + File_name_0_differs_from_already_included_file_name_1_only_in_casing: { code: 1149, category: ts.DiagnosticCategory.Error, key: "File_name_0_differs_from_already_included_file_name_1_only_in_casing_1149", message: "File name '{0}' differs from already included file name '{1}' only in casing" }, + new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead: { code: 1150, category: ts.DiagnosticCategory.Error, key: "new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead_1150", message: "'new T[]' cannot be used to create an array. Use 'new Array()' instead." }, + const_declarations_must_be_initialized: { code: 1155, category: ts.DiagnosticCategory.Error, key: "const_declarations_must_be_initialized_1155", message: "'const' declarations must be initialized" }, + const_declarations_can_only_be_declared_inside_a_block: { code: 1156, category: ts.DiagnosticCategory.Error, key: "const_declarations_can_only_be_declared_inside_a_block_1156", message: "'const' declarations can only be declared inside a block." }, + let_declarations_can_only_be_declared_inside_a_block: { code: 1157, category: ts.DiagnosticCategory.Error, key: "let_declarations_can_only_be_declared_inside_a_block_1157", message: "'let' declarations can only be declared inside a block." }, + Unterminated_template_literal: { code: 1160, category: ts.DiagnosticCategory.Error, key: "Unterminated_template_literal_1160", message: "Unterminated template literal." }, + Unterminated_regular_expression_literal: { code: 1161, category: ts.DiagnosticCategory.Error, key: "Unterminated_regular_expression_literal_1161", message: "Unterminated regular expression literal." }, + An_object_member_cannot_be_declared_optional: { code: 1162, category: ts.DiagnosticCategory.Error, key: "An_object_member_cannot_be_declared_optional_1162", message: "An object member cannot be declared optional." }, + A_yield_expression_is_only_allowed_in_a_generator_body: { code: 1163, category: ts.DiagnosticCategory.Error, key: "A_yield_expression_is_only_allowed_in_a_generator_body_1163", message: "A 'yield' expression is only allowed in a generator body." }, + Computed_property_names_are_not_allowed_in_enums: { code: 1164, category: ts.DiagnosticCategory.Error, key: "Computed_property_names_are_not_allowed_in_enums_1164", message: "Computed property names are not allowed in enums." }, + A_computed_property_name_in_an_ambient_context_must_directly_refer_to_a_built_in_symbol: { code: 1165, category: ts.DiagnosticCategory.Error, key: "A_computed_property_name_in_an_ambient_context_must_directly_refer_to_a_built_in_symbol_1165", message: "A computed property name in an ambient context must directly refer to a built-in symbol." }, + A_computed_property_name_in_a_class_property_declaration_must_directly_refer_to_a_built_in_symbol: { code: 1166, category: ts.DiagnosticCategory.Error, key: "A_computed_property_name_in_a_class_property_declaration_must_directly_refer_to_a_built_in_symbol_1166", message: "A computed property name in a class property declaration must directly refer to a built-in symbol." }, + A_computed_property_name_in_a_method_overload_must_directly_refer_to_a_built_in_symbol: { code: 1168, category: ts.DiagnosticCategory.Error, key: "A_computed_property_name_in_a_method_overload_must_directly_refer_to_a_built_in_symbol_1168", message: "A computed property name in a method overload must directly refer to a built-in symbol." }, + A_computed_property_name_in_an_interface_must_directly_refer_to_a_built_in_symbol: { code: 1169, category: ts.DiagnosticCategory.Error, key: "A_computed_property_name_in_an_interface_must_directly_refer_to_a_built_in_symbol_1169", message: "A computed property name in an interface must directly refer to a built-in symbol." }, + A_computed_property_name_in_a_type_literal_must_directly_refer_to_a_built_in_symbol: { code: 1170, category: ts.DiagnosticCategory.Error, key: "A_computed_property_name_in_a_type_literal_must_directly_refer_to_a_built_in_symbol_1170", message: "A computed property name in a type literal must directly refer to a built-in symbol." }, + A_comma_expression_is_not_allowed_in_a_computed_property_name: { code: 1171, category: ts.DiagnosticCategory.Error, key: "A_comma_expression_is_not_allowed_in_a_computed_property_name_1171", message: "A comma expression is not allowed in a computed property name." }, + extends_clause_already_seen: { code: 1172, category: ts.DiagnosticCategory.Error, key: "extends_clause_already_seen_1172", message: "'extends' clause already seen." }, + extends_clause_must_precede_implements_clause: { code: 1173, category: ts.DiagnosticCategory.Error, key: "extends_clause_must_precede_implements_clause_1173", message: "'extends' clause must precede 'implements' clause." }, + Classes_can_only_extend_a_single_class: { code: 1174, category: ts.DiagnosticCategory.Error, key: "Classes_can_only_extend_a_single_class_1174", message: "Classes can only extend a single class." }, + implements_clause_already_seen: { code: 1175, category: ts.DiagnosticCategory.Error, key: "implements_clause_already_seen_1175", message: "'implements' clause already seen." }, + Interface_declaration_cannot_have_implements_clause: { code: 1176, category: ts.DiagnosticCategory.Error, key: "Interface_declaration_cannot_have_implements_clause_1176", message: "Interface declaration cannot have 'implements' clause." }, + Binary_digit_expected: { code: 1177, category: ts.DiagnosticCategory.Error, key: "Binary_digit_expected_1177", message: "Binary digit expected." }, + Octal_digit_expected: { code: 1178, category: ts.DiagnosticCategory.Error, key: "Octal_digit_expected_1178", message: "Octal digit expected." }, + Unexpected_token_expected: { code: 1179, category: ts.DiagnosticCategory.Error, key: "Unexpected_token_expected_1179", message: "Unexpected token. '{' expected." }, + Property_destructuring_pattern_expected: { code: 1180, category: ts.DiagnosticCategory.Error, key: "Property_destructuring_pattern_expected_1180", message: "Property destructuring pattern expected." }, + Array_element_destructuring_pattern_expected: { code: 1181, category: ts.DiagnosticCategory.Error, key: "Array_element_destructuring_pattern_expected_1181", message: "Array element destructuring pattern expected." }, + A_destructuring_declaration_must_have_an_initializer: { code: 1182, category: ts.DiagnosticCategory.Error, key: "A_destructuring_declaration_must_have_an_initializer_1182", message: "A destructuring declaration must have an initializer." }, + An_implementation_cannot_be_declared_in_ambient_contexts: { code: 1183, category: ts.DiagnosticCategory.Error, key: "An_implementation_cannot_be_declared_in_ambient_contexts_1183", message: "An implementation cannot be declared in ambient contexts." }, + Modifiers_cannot_appear_here: { code: 1184, category: ts.DiagnosticCategory.Error, key: "Modifiers_cannot_appear_here_1184", message: "Modifiers cannot appear here." }, + Merge_conflict_marker_encountered: { code: 1185, category: ts.DiagnosticCategory.Error, key: "Merge_conflict_marker_encountered_1185", message: "Merge conflict marker encountered." }, + A_rest_element_cannot_have_an_initializer: { code: 1186, category: ts.DiagnosticCategory.Error, key: "A_rest_element_cannot_have_an_initializer_1186", message: "A rest element cannot have an initializer." }, + A_parameter_property_may_not_be_a_binding_pattern: { code: 1187, category: ts.DiagnosticCategory.Error, key: "A_parameter_property_may_not_be_a_binding_pattern_1187", message: "A parameter property may not be a binding pattern." }, + Only_a_single_variable_declaration_is_allowed_in_a_for_of_statement: { code: 1188, category: ts.DiagnosticCategory.Error, key: "Only_a_single_variable_declaration_is_allowed_in_a_for_of_statement_1188", message: "Only a single variable declaration is allowed in a 'for...of' statement." }, + The_variable_declaration_of_a_for_in_statement_cannot_have_an_initializer: { code: 1189, category: ts.DiagnosticCategory.Error, key: "The_variable_declaration_of_a_for_in_statement_cannot_have_an_initializer_1189", message: "The variable declaration of a 'for...in' statement cannot have an initializer." }, + The_variable_declaration_of_a_for_of_statement_cannot_have_an_initializer: { code: 1190, category: ts.DiagnosticCategory.Error, key: "The_variable_declaration_of_a_for_of_statement_cannot_have_an_initializer_1190", message: "The variable declaration of a 'for...of' statement cannot have an initializer." }, + An_import_declaration_cannot_have_modifiers: { code: 1191, category: ts.DiagnosticCategory.Error, key: "An_import_declaration_cannot_have_modifiers_1191", message: "An import declaration cannot have modifiers." }, + Module_0_has_no_default_export: { code: 1192, category: ts.DiagnosticCategory.Error, key: "Module_0_has_no_default_export_1192", message: "Module '{0}' has no default export." }, + An_export_declaration_cannot_have_modifiers: { code: 1193, category: ts.DiagnosticCategory.Error, key: "An_export_declaration_cannot_have_modifiers_1193", message: "An export declaration cannot have modifiers." }, + Export_declarations_are_not_permitted_in_a_namespace: { code: 1194, category: ts.DiagnosticCategory.Error, key: "Export_declarations_are_not_permitted_in_a_namespace_1194", message: "Export declarations are not permitted in a namespace." }, + Catch_clause_variable_name_must_be_an_identifier: { code: 1195, category: ts.DiagnosticCategory.Error, key: "Catch_clause_variable_name_must_be_an_identifier_1195", message: "Catch clause variable name must be an identifier." }, + Catch_clause_variable_cannot_have_a_type_annotation: { code: 1196, category: ts.DiagnosticCategory.Error, key: "Catch_clause_variable_cannot_have_a_type_annotation_1196", message: "Catch clause variable cannot have a type annotation." }, + Catch_clause_variable_cannot_have_an_initializer: { code: 1197, category: ts.DiagnosticCategory.Error, key: "Catch_clause_variable_cannot_have_an_initializer_1197", message: "Catch clause variable cannot have an initializer." }, + An_extended_Unicode_escape_value_must_be_between_0x0_and_0x10FFFF_inclusive: { code: 1198, category: ts.DiagnosticCategory.Error, key: "An_extended_Unicode_escape_value_must_be_between_0x0_and_0x10FFFF_inclusive_1198", message: "An extended Unicode escape value must be between 0x0 and 0x10FFFF inclusive." }, + Unterminated_Unicode_escape_sequence: { code: 1199, category: ts.DiagnosticCategory.Error, key: "Unterminated_Unicode_escape_sequence_1199", message: "Unterminated Unicode escape sequence." }, + Line_terminator_not_permitted_before_arrow: { code: 1200, category: ts.DiagnosticCategory.Error, key: "Line_terminator_not_permitted_before_arrow_1200", message: "Line terminator not permitted before arrow." }, + Import_assignment_cannot_be_used_when_targeting_ECMAScript_6_modules_Consider_using_import_Asterisk_as_ns_from_mod_import_a_from_mod_import_d_from_mod_or_another_module_format_instead: { code: 1202, category: ts.DiagnosticCategory.Error, key: "Import_assignment_cannot_be_used_when_targeting_ECMAScript_6_modules_Consider_using_import_Asterisk__1202", message: "Import assignment cannot be used when targeting ECMAScript 6 modules. Consider using 'import * as ns from \"mod\"', 'import {a} from \"mod\"', 'import d from \"mod\"', or another module format instead." }, + Export_assignment_cannot_be_used_when_targeting_ECMAScript_6_modules_Consider_using_export_default_or_another_module_format_instead: { code: 1203, category: ts.DiagnosticCategory.Error, key: "Export_assignment_cannot_be_used_when_targeting_ECMAScript_6_modules_Consider_using_export_default_o_1203", message: "Export assignment cannot be used when targeting ECMAScript 6 modules. Consider using 'export default' or another module format instead." }, + Cannot_compile_modules_into_es2015_when_targeting_ES5_or_lower: { code: 1204, category: ts.DiagnosticCategory.Error, key: "Cannot_compile_modules_into_es2015_when_targeting_ES5_or_lower_1204", message: "Cannot compile modules into 'es2015' when targeting 'ES5' or lower." }, + Decorators_are_not_valid_here: { code: 1206, category: ts.DiagnosticCategory.Error, key: "Decorators_are_not_valid_here_1206", message: "Decorators are not valid here." }, + Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name: { code: 1207, category: ts.DiagnosticCategory.Error, key: "Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name_1207", message: "Decorators cannot be applied to multiple get/set accessors of the same name." }, + Cannot_compile_namespaces_when_the_isolatedModules_flag_is_provided: { code: 1208, category: ts.DiagnosticCategory.Error, key: "Cannot_compile_namespaces_when_the_isolatedModules_flag_is_provided_1208", message: "Cannot compile namespaces when the '--isolatedModules' flag is provided." }, + Ambient_const_enums_are_not_allowed_when_the_isolatedModules_flag_is_provided: { code: 1209, category: ts.DiagnosticCategory.Error, key: "Ambient_const_enums_are_not_allowed_when_the_isolatedModules_flag_is_provided_1209", message: "Ambient const enums are not allowed when the '--isolatedModules' flag is provided." }, + Invalid_use_of_0_Class_definitions_are_automatically_in_strict_mode: { code: 1210, category: ts.DiagnosticCategory.Error, key: "Invalid_use_of_0_Class_definitions_are_automatically_in_strict_mode_1210", message: "Invalid use of '{0}'. Class definitions are automatically in strict mode." }, + A_class_declaration_without_the_default_modifier_must_have_a_name: { code: 1211, category: ts.DiagnosticCategory.Error, key: "A_class_declaration_without_the_default_modifier_must_have_a_name_1211", message: "A class declaration without the 'default' modifier must have a name" }, + Identifier_expected_0_is_a_reserved_word_in_strict_mode: { code: 1212, category: ts.DiagnosticCategory.Error, key: "Identifier_expected_0_is_a_reserved_word_in_strict_mode_1212", message: "Identifier expected. '{0}' is a reserved word in strict mode" }, + Identifier_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_strict_mode: { code: 1213, category: ts.DiagnosticCategory.Error, key: "Identifier_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_stric_1213", message: "Identifier expected. '{0}' is a reserved word in strict mode. Class definitions are automatically in strict mode." }, + Identifier_expected_0_is_a_reserved_word_in_strict_mode_Modules_are_automatically_in_strict_mode: { code: 1214, category: ts.DiagnosticCategory.Error, key: "Identifier_expected_0_is_a_reserved_word_in_strict_mode_Modules_are_automatically_in_strict_mode_1214", message: "Identifier expected. '{0}' is a reserved word in strict mode. Modules are automatically in strict mode." }, + Invalid_use_of_0_Modules_are_automatically_in_strict_mode: { code: 1215, category: ts.DiagnosticCategory.Error, key: "Invalid_use_of_0_Modules_are_automatically_in_strict_mode_1215", message: "Invalid use of '{0}'. Modules are automatically in strict mode." }, + Export_assignment_is_not_supported_when_module_flag_is_system: { code: 1218, category: ts.DiagnosticCategory.Error, key: "Export_assignment_is_not_supported_when_module_flag_is_system_1218", message: "Export assignment is not supported when '--module' flag is 'system'." }, + Experimental_support_for_decorators_is_a_feature_that_is_subject_to_change_in_a_future_release_Specify_experimentalDecorators_to_remove_this_warning: { code: 1219, category: ts.DiagnosticCategory.Error, key: "Experimental_support_for_decorators_is_a_feature_that_is_subject_to_change_in_a_future_release_Speci_1219", message: "Experimental support for decorators is a feature that is subject to change in a future release. Specify '--experimentalDecorators' to remove this warning." }, + Generators_are_only_available_when_targeting_ECMAScript_6_or_higher: { code: 1220, category: ts.DiagnosticCategory.Error, key: "Generators_are_only_available_when_targeting_ECMAScript_6_or_higher_1220", message: "Generators are only available when targeting ECMAScript 6 or higher." }, + Generators_are_not_allowed_in_an_ambient_context: { code: 1221, category: ts.DiagnosticCategory.Error, key: "Generators_are_not_allowed_in_an_ambient_context_1221", message: "Generators are not allowed in an ambient context." }, + An_overload_signature_cannot_be_declared_as_a_generator: { code: 1222, category: ts.DiagnosticCategory.Error, key: "An_overload_signature_cannot_be_declared_as_a_generator_1222", message: "An overload signature cannot be declared as a generator." }, + _0_tag_already_specified: { code: 1223, category: ts.DiagnosticCategory.Error, key: "_0_tag_already_specified_1223", message: "'{0}' tag already specified." }, + Signature_0_must_have_a_type_predicate: { code: 1224, category: ts.DiagnosticCategory.Error, key: "Signature_0_must_have_a_type_predicate_1224", message: "Signature '{0}' must have a type predicate." }, + Cannot_find_parameter_0: { code: 1225, category: ts.DiagnosticCategory.Error, key: "Cannot_find_parameter_0_1225", message: "Cannot find parameter '{0}'." }, + Type_predicate_0_is_not_assignable_to_1: { code: 1226, category: ts.DiagnosticCategory.Error, key: "Type_predicate_0_is_not_assignable_to_1_1226", message: "Type predicate '{0}' is not assignable to '{1}'." }, + Parameter_0_is_not_in_the_same_position_as_parameter_1: { code: 1227, category: ts.DiagnosticCategory.Error, key: "Parameter_0_is_not_in_the_same_position_as_parameter_1_1227", message: "Parameter '{0}' is not in the same position as parameter '{1}'." }, + A_type_predicate_is_only_allowed_in_return_type_position_for_functions_and_methods: { code: 1228, category: ts.DiagnosticCategory.Error, key: "A_type_predicate_is_only_allowed_in_return_type_position_for_functions_and_methods_1228", message: "A type predicate is only allowed in return type position for functions and methods." }, + A_type_predicate_cannot_reference_a_rest_parameter: { code: 1229, category: ts.DiagnosticCategory.Error, key: "A_type_predicate_cannot_reference_a_rest_parameter_1229", message: "A type predicate cannot reference a rest parameter." }, + A_type_predicate_cannot_reference_element_0_in_a_binding_pattern: { code: 1230, category: ts.DiagnosticCategory.Error, key: "A_type_predicate_cannot_reference_element_0_in_a_binding_pattern_1230", message: "A type predicate cannot reference element '{0}' in a binding pattern." }, + An_export_assignment_can_only_be_used_in_a_module: { code: 1231, category: ts.DiagnosticCategory.Error, key: "An_export_assignment_can_only_be_used_in_a_module_1231", message: "An export assignment can only be used in a module." }, + An_import_declaration_can_only_be_used_in_a_namespace_or_module: { code: 1232, category: ts.DiagnosticCategory.Error, key: "An_import_declaration_can_only_be_used_in_a_namespace_or_module_1232", message: "An import declaration can only be used in a namespace or module." }, + An_export_declaration_can_only_be_used_in_a_module: { code: 1233, category: ts.DiagnosticCategory.Error, key: "An_export_declaration_can_only_be_used_in_a_module_1233", message: "An export declaration can only be used in a module." }, + An_ambient_module_declaration_is_only_allowed_at_the_top_level_in_a_file: { code: 1234, category: ts.DiagnosticCategory.Error, key: "An_ambient_module_declaration_is_only_allowed_at_the_top_level_in_a_file_1234", message: "An ambient module declaration is only allowed at the top level in a file." }, + A_namespace_declaration_is_only_allowed_in_a_namespace_or_module: { code: 1235, category: ts.DiagnosticCategory.Error, key: "A_namespace_declaration_is_only_allowed_in_a_namespace_or_module_1235", message: "A namespace declaration is only allowed in a namespace or module." }, + The_return_type_of_a_property_decorator_function_must_be_either_void_or_any: { code: 1236, category: ts.DiagnosticCategory.Error, key: "The_return_type_of_a_property_decorator_function_must_be_either_void_or_any_1236", message: "The return type of a property decorator function must be either 'void' or 'any'." }, + The_return_type_of_a_parameter_decorator_function_must_be_either_void_or_any: { code: 1237, category: ts.DiagnosticCategory.Error, key: "The_return_type_of_a_parameter_decorator_function_must_be_either_void_or_any_1237", message: "The return type of a parameter decorator function must be either 'void' or 'any'." }, + Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression: { code: 1238, category: ts.DiagnosticCategory.Error, key: "Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression_1238", message: "Unable to resolve signature of class decorator when called as an expression." }, + Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression: { code: 1239, category: ts.DiagnosticCategory.Error, key: "Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression_1239", message: "Unable to resolve signature of parameter decorator when called as an expression." }, + Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression: { code: 1240, category: ts.DiagnosticCategory.Error, key: "Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression_1240", message: "Unable to resolve signature of property decorator when called as an expression." }, + Unable_to_resolve_signature_of_method_decorator_when_called_as_an_expression: { code: 1241, category: ts.DiagnosticCategory.Error, key: "Unable_to_resolve_signature_of_method_decorator_when_called_as_an_expression_1241", message: "Unable to resolve signature of method decorator when called as an expression." }, + abstract_modifier_can_only_appear_on_a_class_or_method_declaration: { code: 1242, category: ts.DiagnosticCategory.Error, key: "abstract_modifier_can_only_appear_on_a_class_or_method_declaration_1242", message: "'abstract' modifier can only appear on a class or method declaration." }, + _0_modifier_cannot_be_used_with_1_modifier: { code: 1243, category: ts.DiagnosticCategory.Error, key: "_0_modifier_cannot_be_used_with_1_modifier_1243", message: "'{0}' modifier cannot be used with '{1}' modifier." }, + Abstract_methods_can_only_appear_within_an_abstract_class: { code: 1244, category: ts.DiagnosticCategory.Error, key: "Abstract_methods_can_only_appear_within_an_abstract_class_1244", message: "Abstract methods can only appear within an abstract class." }, + Method_0_cannot_have_an_implementation_because_it_is_marked_abstract: { code: 1245, category: ts.DiagnosticCategory.Error, key: "Method_0_cannot_have_an_implementation_because_it_is_marked_abstract_1245", message: "Method '{0}' cannot have an implementation because it is marked abstract." }, + with_statements_are_not_allowed_in_an_async_function_block: { code: 1300, category: ts.DiagnosticCategory.Error, key: "with_statements_are_not_allowed_in_an_async_function_block_1300", message: "'with' statements are not allowed in an async function block." }, + await_expression_is_only_allowed_within_an_async_function: { code: 1308, category: ts.DiagnosticCategory.Error, key: "await_expression_is_only_allowed_within_an_async_function_1308", message: "'await' expression is only allowed within an async function." }, + Async_functions_are_only_available_when_targeting_ECMAScript_6_and_higher: { code: 1311, category: ts.DiagnosticCategory.Error, key: "Async_functions_are_only_available_when_targeting_ECMAScript_6_and_higher_1311", message: "Async functions are only available when targeting ECMAScript 6 and higher." }, + can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment: { code: 1312, category: ts.DiagnosticCategory.Error, key: "can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment_1312", message: "'=' can only be used in an object literal property inside a destructuring assignment." }, + Duplicate_identifier_0: { code: 2300, category: ts.DiagnosticCategory.Error, key: "Duplicate_identifier_0_2300", message: "Duplicate identifier '{0}'." }, + Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor: { code: 2301, category: ts.DiagnosticCategory.Error, key: "Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor_2301", message: "Initializer of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor." }, + Static_members_cannot_reference_class_type_parameters: { code: 2302, category: ts.DiagnosticCategory.Error, key: "Static_members_cannot_reference_class_type_parameters_2302", message: "Static members cannot reference class type parameters." }, + Circular_definition_of_import_alias_0: { code: 2303, category: ts.DiagnosticCategory.Error, key: "Circular_definition_of_import_alias_0_2303", message: "Circular definition of import alias '{0}'." }, + Cannot_find_name_0: { code: 2304, category: ts.DiagnosticCategory.Error, key: "Cannot_find_name_0_2304", message: "Cannot find name '{0}'." }, + Module_0_has_no_exported_member_1: { code: 2305, category: ts.DiagnosticCategory.Error, key: "Module_0_has_no_exported_member_1_2305", message: "Module '{0}' has no exported member '{1}'." }, + File_0_is_not_a_module: { code: 2306, category: ts.DiagnosticCategory.Error, key: "File_0_is_not_a_module_2306", message: "File '{0}' is not a module." }, + Cannot_find_module_0: { code: 2307, category: ts.DiagnosticCategory.Error, key: "Cannot_find_module_0_2307", message: "Cannot find module '{0}'." }, + An_export_assignment_cannot_be_used_in_a_module_with_other_exported_elements: { code: 2309, category: ts.DiagnosticCategory.Error, key: "An_export_assignment_cannot_be_used_in_a_module_with_other_exported_elements_2309", message: "An export assignment cannot be used in a module with other exported elements." }, + Type_0_recursively_references_itself_as_a_base_type: { code: 2310, category: ts.DiagnosticCategory.Error, key: "Type_0_recursively_references_itself_as_a_base_type_2310", message: "Type '{0}' recursively references itself as a base type." }, + A_class_may_only_extend_another_class: { code: 2311, category: ts.DiagnosticCategory.Error, key: "A_class_may_only_extend_another_class_2311", message: "A class may only extend another class." }, + An_interface_may_only_extend_a_class_or_another_interface: { code: 2312, category: ts.DiagnosticCategory.Error, key: "An_interface_may_only_extend_a_class_or_another_interface_2312", message: "An interface may only extend a class or another interface." }, + Constraint_of_a_type_parameter_cannot_reference_any_type_parameter_from_the_same_type_parameter_list: { code: 2313, category: ts.DiagnosticCategory.Error, key: "Constraint_of_a_type_parameter_cannot_reference_any_type_parameter_from_the_same_type_parameter_list_2313", message: "Constraint of a type parameter cannot reference any type parameter from the same type parameter list." }, + Generic_type_0_requires_1_type_argument_s: { code: 2314, category: ts.DiagnosticCategory.Error, key: "Generic_type_0_requires_1_type_argument_s_2314", message: "Generic type '{0}' requires {1} type argument(s)." }, + Type_0_is_not_generic: { code: 2315, category: ts.DiagnosticCategory.Error, key: "Type_0_is_not_generic_2315", message: "Type '{0}' is not generic." }, + Global_type_0_must_be_a_class_or_interface_type: { code: 2316, category: ts.DiagnosticCategory.Error, key: "Global_type_0_must_be_a_class_or_interface_type_2316", message: "Global type '{0}' must be a class or interface type." }, + Global_type_0_must_have_1_type_parameter_s: { code: 2317, category: ts.DiagnosticCategory.Error, key: "Global_type_0_must_have_1_type_parameter_s_2317", message: "Global type '{0}' must have {1} type parameter(s)." }, + Cannot_find_global_type_0: { code: 2318, category: ts.DiagnosticCategory.Error, key: "Cannot_find_global_type_0_2318", message: "Cannot find global type '{0}'." }, + Named_property_0_of_types_1_and_2_are_not_identical: { code: 2319, category: ts.DiagnosticCategory.Error, key: "Named_property_0_of_types_1_and_2_are_not_identical_2319", message: "Named property '{0}' of types '{1}' and '{2}' are not identical." }, + Interface_0_cannot_simultaneously_extend_types_1_and_2: { code: 2320, category: ts.DiagnosticCategory.Error, key: "Interface_0_cannot_simultaneously_extend_types_1_and_2_2320", message: "Interface '{0}' cannot simultaneously extend types '{1}' and '{2}'." }, + Excessive_stack_depth_comparing_types_0_and_1: { code: 2321, category: ts.DiagnosticCategory.Error, key: "Excessive_stack_depth_comparing_types_0_and_1_2321", message: "Excessive stack depth comparing types '{0}' and '{1}'." }, + Type_0_is_not_assignable_to_type_1: { code: 2322, category: ts.DiagnosticCategory.Error, key: "Type_0_is_not_assignable_to_type_1_2322", message: "Type '{0}' is not assignable to type '{1}'." }, + Property_0_is_missing_in_type_1: { code: 2324, category: ts.DiagnosticCategory.Error, key: "Property_0_is_missing_in_type_1_2324", message: "Property '{0}' is missing in type '{1}'." }, + Property_0_is_private_in_type_1_but_not_in_type_2: { code: 2325, category: ts.DiagnosticCategory.Error, key: "Property_0_is_private_in_type_1_but_not_in_type_2_2325", message: "Property '{0}' is private in type '{1}' but not in type '{2}'." }, + Types_of_property_0_are_incompatible: { code: 2326, category: ts.DiagnosticCategory.Error, key: "Types_of_property_0_are_incompatible_2326", message: "Types of property '{0}' are incompatible." }, + Property_0_is_optional_in_type_1_but_required_in_type_2: { code: 2327, category: ts.DiagnosticCategory.Error, key: "Property_0_is_optional_in_type_1_but_required_in_type_2_2327", message: "Property '{0}' is optional in type '{1}' but required in type '{2}'." }, + Types_of_parameters_0_and_1_are_incompatible: { code: 2328, category: ts.DiagnosticCategory.Error, key: "Types_of_parameters_0_and_1_are_incompatible_2328", message: "Types of parameters '{0}' and '{1}' are incompatible." }, + Index_signature_is_missing_in_type_0: { code: 2329, category: ts.DiagnosticCategory.Error, key: "Index_signature_is_missing_in_type_0_2329", message: "Index signature is missing in type '{0}'." }, + Index_signatures_are_incompatible: { code: 2330, category: ts.DiagnosticCategory.Error, key: "Index_signatures_are_incompatible_2330", message: "Index signatures are incompatible." }, + this_cannot_be_referenced_in_a_module_or_namespace_body: { code: 2331, category: ts.DiagnosticCategory.Error, key: "this_cannot_be_referenced_in_a_module_or_namespace_body_2331", message: "'this' cannot be referenced in a module or namespace body." }, + this_cannot_be_referenced_in_current_location: { code: 2332, category: ts.DiagnosticCategory.Error, key: "this_cannot_be_referenced_in_current_location_2332", message: "'this' cannot be referenced in current location." }, + this_cannot_be_referenced_in_constructor_arguments: { code: 2333, category: ts.DiagnosticCategory.Error, key: "this_cannot_be_referenced_in_constructor_arguments_2333", message: "'this' cannot be referenced in constructor arguments." }, + this_cannot_be_referenced_in_a_static_property_initializer: { code: 2334, category: ts.DiagnosticCategory.Error, key: "this_cannot_be_referenced_in_a_static_property_initializer_2334", message: "'this' cannot be referenced in a static property initializer." }, + super_can_only_be_referenced_in_a_derived_class: { code: 2335, category: ts.DiagnosticCategory.Error, key: "super_can_only_be_referenced_in_a_derived_class_2335", message: "'super' can only be referenced in a derived class." }, + super_cannot_be_referenced_in_constructor_arguments: { code: 2336, category: ts.DiagnosticCategory.Error, key: "super_cannot_be_referenced_in_constructor_arguments_2336", message: "'super' cannot be referenced in constructor arguments." }, + Super_calls_are_not_permitted_outside_constructors_or_in_nested_functions_inside_constructors: { code: 2337, category: ts.DiagnosticCategory.Error, key: "Super_calls_are_not_permitted_outside_constructors_or_in_nested_functions_inside_constructors_2337", message: "Super calls are not permitted outside constructors or in nested functions inside constructors." }, + super_property_access_is_permitted_only_in_a_constructor_member_function_or_member_accessor_of_a_derived_class: { code: 2338, category: ts.DiagnosticCategory.Error, key: "super_property_access_is_permitted_only_in_a_constructor_member_function_or_member_accessor_of_a_der_2338", message: "'super' property access is permitted only in a constructor, member function, or member accessor of a derived class." }, + Property_0_does_not_exist_on_type_1: { code: 2339, category: ts.DiagnosticCategory.Error, key: "Property_0_does_not_exist_on_type_1_2339", message: "Property '{0}' does not exist on type '{1}'." }, + Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword: { code: 2340, category: ts.DiagnosticCategory.Error, key: "Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword_2340", message: "Only public and protected methods of the base class are accessible via the 'super' keyword." }, + Property_0_is_private_and_only_accessible_within_class_1: { code: 2341, category: ts.DiagnosticCategory.Error, key: "Property_0_is_private_and_only_accessible_within_class_1_2341", message: "Property '{0}' is private and only accessible within class '{1}'." }, + An_index_expression_argument_must_be_of_type_string_number_symbol_or_any: { code: 2342, category: ts.DiagnosticCategory.Error, key: "An_index_expression_argument_must_be_of_type_string_number_symbol_or_any_2342", message: "An index expression argument must be of type 'string', 'number', 'symbol', or 'any'." }, + Type_0_does_not_satisfy_the_constraint_1: { code: 2344, category: ts.DiagnosticCategory.Error, key: "Type_0_does_not_satisfy_the_constraint_1_2344", message: "Type '{0}' does not satisfy the constraint '{1}'." }, + Argument_of_type_0_is_not_assignable_to_parameter_of_type_1: { code: 2345, category: ts.DiagnosticCategory.Error, key: "Argument_of_type_0_is_not_assignable_to_parameter_of_type_1_2345", message: "Argument of type '{0}' is not assignable to parameter of type '{1}'." }, + Supplied_parameters_do_not_match_any_signature_of_call_target: { code: 2346, category: ts.DiagnosticCategory.Error, key: "Supplied_parameters_do_not_match_any_signature_of_call_target_2346", message: "Supplied parameters do not match any signature of call target." }, + Untyped_function_calls_may_not_accept_type_arguments: { code: 2347, category: ts.DiagnosticCategory.Error, key: "Untyped_function_calls_may_not_accept_type_arguments_2347", message: "Untyped function calls may not accept type arguments." }, + Value_of_type_0_is_not_callable_Did_you_mean_to_include_new: { code: 2348, category: ts.DiagnosticCategory.Error, key: "Value_of_type_0_is_not_callable_Did_you_mean_to_include_new_2348", message: "Value of type '{0}' is not callable. Did you mean to include 'new'?" }, + Cannot_invoke_an_expression_whose_type_lacks_a_call_signature: { code: 2349, category: ts.DiagnosticCategory.Error, key: "Cannot_invoke_an_expression_whose_type_lacks_a_call_signature_2349", message: "Cannot invoke an expression whose type lacks a call signature." }, + Only_a_void_function_can_be_called_with_the_new_keyword: { code: 2350, category: ts.DiagnosticCategory.Error, key: "Only_a_void_function_can_be_called_with_the_new_keyword_2350", message: "Only a void function can be called with the 'new' keyword." }, + Cannot_use_new_with_an_expression_whose_type_lacks_a_call_or_construct_signature: { code: 2351, category: ts.DiagnosticCategory.Error, key: "Cannot_use_new_with_an_expression_whose_type_lacks_a_call_or_construct_signature_2351", message: "Cannot use 'new' with an expression whose type lacks a call or construct signature." }, + Neither_type_0_nor_type_1_is_assignable_to_the_other: { code: 2352, category: ts.DiagnosticCategory.Error, key: "Neither_type_0_nor_type_1_is_assignable_to_the_other_2352", message: "Neither type '{0}' nor type '{1}' is assignable to the other." }, + Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1: { code: 2353, category: ts.DiagnosticCategory.Error, key: "Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1_2353", message: "Object literal may only specify known properties, and '{0}' does not exist in type '{1}'." }, + No_best_common_type_exists_among_return_expressions: { code: 2354, category: ts.DiagnosticCategory.Error, key: "No_best_common_type_exists_among_return_expressions_2354", message: "No best common type exists among return expressions." }, + A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value_or_consist_of_a_single_throw_statement: { code: 2355, category: ts.DiagnosticCategory.Error, key: "A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value_or_consist_of_a_single_th_2355", message: "A function whose declared type is neither 'void' nor 'any' must return a value or consist of a single 'throw' statement." }, + An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type: { code: 2356, category: ts.DiagnosticCategory.Error, key: "An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type_2356", message: "An arithmetic operand must be of type 'any', 'number' or an enum type." }, + The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_property_or_indexer: { code: 2357, category: ts.DiagnosticCategory.Error, key: "The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_property_or_indexer_2357", message: "The operand of an increment or decrement operator must be a variable, property or indexer." }, + The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_parameter: { code: 2358, category: ts.DiagnosticCategory.Error, key: "The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_paramete_2358", message: "The left-hand side of an 'instanceof' expression must be of type 'any', an object type or a type parameter." }, + The_right_hand_side_of_an_instanceof_expression_must_be_of_type_any_or_of_a_type_assignable_to_the_Function_interface_type: { code: 2359, category: ts.DiagnosticCategory.Error, key: "The_right_hand_side_of_an_instanceof_expression_must_be_of_type_any_or_of_a_type_assignable_to_the_F_2359", message: "The right-hand side of an 'instanceof' expression must be of type 'any' or of a type assignable to the 'Function' interface type." }, + The_left_hand_side_of_an_in_expression_must_be_of_type_any_string_number_or_symbol: { code: 2360, category: ts.DiagnosticCategory.Error, key: "The_left_hand_side_of_an_in_expression_must_be_of_type_any_string_number_or_symbol_2360", message: "The left-hand side of an 'in' expression must be of type 'any', 'string', 'number', or 'symbol'." }, + The_right_hand_side_of_an_in_expression_must_be_of_type_any_an_object_type_or_a_type_parameter: { code: 2361, category: ts.DiagnosticCategory.Error, key: "The_right_hand_side_of_an_in_expression_must_be_of_type_any_an_object_type_or_a_type_parameter_2361", message: "The right-hand side of an 'in' expression must be of type 'any', an object type or a type parameter" }, + The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type: { code: 2362, category: ts.DiagnosticCategory.Error, key: "The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type_2362", message: "The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type." }, + The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type: { code: 2363, category: ts.DiagnosticCategory.Error, key: "The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type_2363", message: "The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type." }, + Invalid_left_hand_side_of_assignment_expression: { code: 2364, category: ts.DiagnosticCategory.Error, key: "Invalid_left_hand_side_of_assignment_expression_2364", message: "Invalid left-hand side of assignment expression." }, + Operator_0_cannot_be_applied_to_types_1_and_2: { code: 2365, category: ts.DiagnosticCategory.Error, key: "Operator_0_cannot_be_applied_to_types_1_and_2_2365", message: "Operator '{0}' cannot be applied to types '{1}' and '{2}'." }, + Type_parameter_name_cannot_be_0: { code: 2368, category: ts.DiagnosticCategory.Error, key: "Type_parameter_name_cannot_be_0_2368", message: "Type parameter name cannot be '{0}'" }, + A_parameter_property_is_only_allowed_in_a_constructor_implementation: { code: 2369, category: ts.DiagnosticCategory.Error, key: "A_parameter_property_is_only_allowed_in_a_constructor_implementation_2369", message: "A parameter property is only allowed in a constructor implementation." }, + A_rest_parameter_must_be_of_an_array_type: { code: 2370, category: ts.DiagnosticCategory.Error, key: "A_rest_parameter_must_be_of_an_array_type_2370", message: "A rest parameter must be of an array type." }, + A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation: { code: 2371, category: ts.DiagnosticCategory.Error, key: "A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation_2371", message: "A parameter initializer is only allowed in a function or constructor implementation." }, + Parameter_0_cannot_be_referenced_in_its_initializer: { code: 2372, category: ts.DiagnosticCategory.Error, key: "Parameter_0_cannot_be_referenced_in_its_initializer_2372", message: "Parameter '{0}' cannot be referenced in its initializer." }, + Initializer_of_parameter_0_cannot_reference_identifier_1_declared_after_it: { code: 2373, category: ts.DiagnosticCategory.Error, key: "Initializer_of_parameter_0_cannot_reference_identifier_1_declared_after_it_2373", message: "Initializer of parameter '{0}' cannot reference identifier '{1}' declared after it." }, + Duplicate_string_index_signature: { code: 2374, category: ts.DiagnosticCategory.Error, key: "Duplicate_string_index_signature_2374", message: "Duplicate string index signature." }, + Duplicate_number_index_signature: { code: 2375, category: ts.DiagnosticCategory.Error, key: "Duplicate_number_index_signature_2375", message: "Duplicate number index signature." }, + A_super_call_must_be_the_first_statement_in_the_constructor_when_a_class_contains_initialized_properties_or_has_parameter_properties: { code: 2376, category: ts.DiagnosticCategory.Error, key: "A_super_call_must_be_the_first_statement_in_the_constructor_when_a_class_contains_initialized_proper_2376", message: "A 'super' call must be the first statement in the constructor when a class contains initialized properties or has parameter properties." }, + Constructors_for_derived_classes_must_contain_a_super_call: { code: 2377, category: ts.DiagnosticCategory.Error, key: "Constructors_for_derived_classes_must_contain_a_super_call_2377", message: "Constructors for derived classes must contain a 'super' call." }, + A_get_accessor_must_return_a_value_or_consist_of_a_single_throw_statement: { code: 2378, category: ts.DiagnosticCategory.Error, key: "A_get_accessor_must_return_a_value_or_consist_of_a_single_throw_statement_2378", message: "A 'get' accessor must return a value or consist of a single 'throw' statement." }, + Getter_and_setter_accessors_do_not_agree_in_visibility: { code: 2379, category: ts.DiagnosticCategory.Error, key: "Getter_and_setter_accessors_do_not_agree_in_visibility_2379", message: "Getter and setter accessors do not agree in visibility." }, + get_and_set_accessor_must_have_the_same_type: { code: 2380, category: ts.DiagnosticCategory.Error, key: "get_and_set_accessor_must_have_the_same_type_2380", message: "'get' and 'set' accessor must have the same type." }, + A_signature_with_an_implementation_cannot_use_a_string_literal_type: { code: 2381, category: ts.DiagnosticCategory.Error, key: "A_signature_with_an_implementation_cannot_use_a_string_literal_type_2381", message: "A signature with an implementation cannot use a string literal type." }, + Specialized_overload_signature_is_not_assignable_to_any_non_specialized_signature: { code: 2382, category: ts.DiagnosticCategory.Error, key: "Specialized_overload_signature_is_not_assignable_to_any_non_specialized_signature_2382", message: "Specialized overload signature is not assignable to any non-specialized signature." }, + Overload_signatures_must_all_be_exported_or_not_exported: { code: 2383, category: ts.DiagnosticCategory.Error, key: "Overload_signatures_must_all_be_exported_or_not_exported_2383", message: "Overload signatures must all be exported or not exported." }, + Overload_signatures_must_all_be_ambient_or_non_ambient: { code: 2384, category: ts.DiagnosticCategory.Error, key: "Overload_signatures_must_all_be_ambient_or_non_ambient_2384", message: "Overload signatures must all be ambient or non-ambient." }, + Overload_signatures_must_all_be_public_private_or_protected: { code: 2385, category: ts.DiagnosticCategory.Error, key: "Overload_signatures_must_all_be_public_private_or_protected_2385", message: "Overload signatures must all be public, private or protected." }, + Overload_signatures_must_all_be_optional_or_required: { code: 2386, category: ts.DiagnosticCategory.Error, key: "Overload_signatures_must_all_be_optional_or_required_2386", message: "Overload signatures must all be optional or required." }, + Function_overload_must_be_static: { code: 2387, category: ts.DiagnosticCategory.Error, key: "Function_overload_must_be_static_2387", message: "Function overload must be static." }, + Function_overload_must_not_be_static: { code: 2388, category: ts.DiagnosticCategory.Error, key: "Function_overload_must_not_be_static_2388", message: "Function overload must not be static." }, + Function_implementation_name_must_be_0: { code: 2389, category: ts.DiagnosticCategory.Error, key: "Function_implementation_name_must_be_0_2389", message: "Function implementation name must be '{0}'." }, + Constructor_implementation_is_missing: { code: 2390, category: ts.DiagnosticCategory.Error, key: "Constructor_implementation_is_missing_2390", message: "Constructor implementation is missing." }, + Function_implementation_is_missing_or_not_immediately_following_the_declaration: { code: 2391, category: ts.DiagnosticCategory.Error, key: "Function_implementation_is_missing_or_not_immediately_following_the_declaration_2391", message: "Function implementation is missing or not immediately following the declaration." }, + Multiple_constructor_implementations_are_not_allowed: { code: 2392, category: ts.DiagnosticCategory.Error, key: "Multiple_constructor_implementations_are_not_allowed_2392", message: "Multiple constructor implementations are not allowed." }, + Duplicate_function_implementation: { code: 2393, category: ts.DiagnosticCategory.Error, key: "Duplicate_function_implementation_2393", message: "Duplicate function implementation." }, + Overload_signature_is_not_compatible_with_function_implementation: { code: 2394, category: ts.DiagnosticCategory.Error, key: "Overload_signature_is_not_compatible_with_function_implementation_2394", message: "Overload signature is not compatible with function implementation." }, + Individual_declarations_in_merged_declaration_0_must_be_all_exported_or_all_local: { code: 2395, category: ts.DiagnosticCategory.Error, key: "Individual_declarations_in_merged_declaration_0_must_be_all_exported_or_all_local_2395", message: "Individual declarations in merged declaration '{0}' must be all exported or all local." }, + Duplicate_identifier_arguments_Compiler_uses_arguments_to_initialize_rest_parameters: { code: 2396, category: ts.DiagnosticCategory.Error, key: "Duplicate_identifier_arguments_Compiler_uses_arguments_to_initialize_rest_parameters_2396", message: "Duplicate identifier 'arguments'. Compiler uses 'arguments' to initialize rest parameters." }, + Duplicate_identifier_this_Compiler_uses_variable_declaration_this_to_capture_this_reference: { code: 2399, category: ts.DiagnosticCategory.Error, key: "Duplicate_identifier_this_Compiler_uses_variable_declaration_this_to_capture_this_reference_2399", message: "Duplicate identifier '_this'. Compiler uses variable declaration '_this' to capture 'this' reference." }, + Expression_resolves_to_variable_declaration_this_that_compiler_uses_to_capture_this_reference: { code: 2400, category: ts.DiagnosticCategory.Error, key: "Expression_resolves_to_variable_declaration_this_that_compiler_uses_to_capture_this_reference_2400", message: "Expression resolves to variable declaration '_this' that compiler uses to capture 'this' reference." }, + Duplicate_identifier_super_Compiler_uses_super_to_capture_base_class_reference: { code: 2401, category: ts.DiagnosticCategory.Error, key: "Duplicate_identifier_super_Compiler_uses_super_to_capture_base_class_reference_2401", message: "Duplicate identifier '_super'. Compiler uses '_super' to capture base class reference." }, + Expression_resolves_to_super_that_compiler_uses_to_capture_base_class_reference: { code: 2402, category: ts.DiagnosticCategory.Error, key: "Expression_resolves_to_super_that_compiler_uses_to_capture_base_class_reference_2402", message: "Expression resolves to '_super' that compiler uses to capture base class reference." }, + Subsequent_variable_declarations_must_have_the_same_type_Variable_0_must_be_of_type_1_but_here_has_type_2: { code: 2403, category: ts.DiagnosticCategory.Error, key: "Subsequent_variable_declarations_must_have_the_same_type_Variable_0_must_be_of_type_1_but_here_has_t_2403", message: "Subsequent variable declarations must have the same type. Variable '{0}' must be of type '{1}', but here has type '{2}'." }, + The_left_hand_side_of_a_for_in_statement_cannot_use_a_type_annotation: { code: 2404, category: ts.DiagnosticCategory.Error, key: "The_left_hand_side_of_a_for_in_statement_cannot_use_a_type_annotation_2404", message: "The left-hand side of a 'for...in' statement cannot use a type annotation." }, + The_left_hand_side_of_a_for_in_statement_must_be_of_type_string_or_any: { code: 2405, category: ts.DiagnosticCategory.Error, key: "The_left_hand_side_of_a_for_in_statement_must_be_of_type_string_or_any_2405", message: "The left-hand side of a 'for...in' statement must be of type 'string' or 'any'." }, + Invalid_left_hand_side_in_for_in_statement: { code: 2406, category: ts.DiagnosticCategory.Error, key: "Invalid_left_hand_side_in_for_in_statement_2406", message: "Invalid left-hand side in 'for...in' statement." }, + The_right_hand_side_of_a_for_in_statement_must_be_of_type_any_an_object_type_or_a_type_parameter: { code: 2407, category: ts.DiagnosticCategory.Error, key: "The_right_hand_side_of_a_for_in_statement_must_be_of_type_any_an_object_type_or_a_type_parameter_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'." }, + 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}'." }, + Class_name_cannot_be_0: { code: 2414, category: ts.DiagnosticCategory.Error, key: "Class_name_cannot_be_0_2414", message: "Class name cannot be '{0}'" }, + Class_0_incorrectly_extends_base_class_1: { code: 2415, category: ts.DiagnosticCategory.Error, key: "Class_0_incorrectly_extends_base_class_1_2415", message: "Class '{0}' incorrectly extends base class '{1}'." }, + Class_static_side_0_incorrectly_extends_base_class_static_side_1: { code: 2417, category: ts.DiagnosticCategory.Error, key: "Class_static_side_0_incorrectly_extends_base_class_static_side_1_2417", message: "Class static side '{0}' incorrectly extends base class static side '{1}'." }, + Type_name_0_in_extends_clause_does_not_reference_constructor_function_for_0: { code: 2419, category: ts.DiagnosticCategory.Error, key: "Type_name_0_in_extends_clause_does_not_reference_constructor_function_for_0_2419", message: "Type name '{0}' in extends clause does not reference constructor function for '{0}'." }, + Class_0_incorrectly_implements_interface_1: { code: 2420, category: ts.DiagnosticCategory.Error, key: "Class_0_incorrectly_implements_interface_1_2420", message: "Class '{0}' incorrectly implements interface '{1}'." }, + A_class_may_only_implement_another_class_or_interface: { code: 2422, category: ts.DiagnosticCategory.Error, key: "A_class_may_only_implement_another_class_or_interface_2422", message: "A class may only implement another class or interface." }, + Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_accessor: { code: 2423, category: ts.DiagnosticCategory.Error, key: "Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_access_2423", message: "Class '{0}' defines instance member function '{1}', but extended class '{2}' defines it as instance member accessor." }, + Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_property: { code: 2424, category: ts.DiagnosticCategory.Error, key: "Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_proper_2424", message: "Class '{0}' defines instance member function '{1}', but extended class '{2}' defines it as instance member property." }, + Class_0_defines_instance_member_property_1_but_extended_class_2_defines_it_as_instance_member_function: { code: 2425, category: ts.DiagnosticCategory.Error, key: "Class_0_defines_instance_member_property_1_but_extended_class_2_defines_it_as_instance_member_functi_2425", message: "Class '{0}' defines instance member property '{1}', but extended class '{2}' defines it as instance member function." }, + Class_0_defines_instance_member_accessor_1_but_extended_class_2_defines_it_as_instance_member_function: { code: 2426, category: ts.DiagnosticCategory.Error, key: "Class_0_defines_instance_member_accessor_1_but_extended_class_2_defines_it_as_instance_member_functi_2426", message: "Class '{0}' defines instance member accessor '{1}', but extended class '{2}' defines it as instance member function." }, + Interface_name_cannot_be_0: { code: 2427, category: ts.DiagnosticCategory.Error, key: "Interface_name_cannot_be_0_2427", message: "Interface name cannot be '{0}'" }, + All_declarations_of_an_interface_must_have_identical_type_parameters: { code: 2428, category: ts.DiagnosticCategory.Error, key: "All_declarations_of_an_interface_must_have_identical_type_parameters_2428", message: "All declarations of an interface must have identical type parameters." }, + Interface_0_incorrectly_extends_interface_1: { code: 2430, category: ts.DiagnosticCategory.Error, key: "Interface_0_incorrectly_extends_interface_1_2430", message: "Interface '{0}' incorrectly extends interface '{1}'." }, + Enum_name_cannot_be_0: { code: 2431, category: ts.DiagnosticCategory.Error, key: "Enum_name_cannot_be_0_2431", message: "Enum name cannot be '{0}'" }, + In_an_enum_with_multiple_declarations_only_one_declaration_can_omit_an_initializer_for_its_first_enum_element: { code: 2432, category: ts.DiagnosticCategory.Error, key: "In_an_enum_with_multiple_declarations_only_one_declaration_can_omit_an_initializer_for_its_first_enu_2432", message: "In an enum with multiple declarations, only one declaration can omit an initializer for its first enum element." }, + A_namespace_declaration_cannot_be_in_a_different_file_from_a_class_or_function_with_which_it_is_merged: { code: 2433, category: ts.DiagnosticCategory.Error, key: "A_namespace_declaration_cannot_be_in_a_different_file_from_a_class_or_function_with_which_it_is_merg_2433", message: "A namespace declaration cannot be in a different file from a class or function with which it is merged" }, + A_namespace_declaration_cannot_be_located_prior_to_a_class_or_function_with_which_it_is_merged: { code: 2434, category: ts.DiagnosticCategory.Error, key: "A_namespace_declaration_cannot_be_located_prior_to_a_class_or_function_with_which_it_is_merged_2434", message: "A namespace declaration cannot be located prior to a class or function with which it is merged" }, + Ambient_modules_cannot_be_nested_in_other_modules_or_namespaces: { code: 2435, category: ts.DiagnosticCategory.Error, key: "Ambient_modules_cannot_be_nested_in_other_modules_or_namespaces_2435", message: "Ambient modules cannot be nested in other modules or namespaces." }, + Ambient_module_declaration_cannot_specify_relative_module_name: { code: 2436, category: ts.DiagnosticCategory.Error, key: "Ambient_module_declaration_cannot_specify_relative_module_name_2436", message: "Ambient module declaration cannot specify relative module name." }, + Module_0_is_hidden_by_a_local_declaration_with_the_same_name: { code: 2437, category: ts.DiagnosticCategory.Error, key: "Module_0_is_hidden_by_a_local_declaration_with_the_same_name_2437", message: "Module '{0}' is hidden by a local declaration with the same name" }, + Import_name_cannot_be_0: { code: 2438, category: ts.DiagnosticCategory.Error, key: "Import_name_cannot_be_0_2438", message: "Import name cannot be '{0}'" }, + Import_or_export_declaration_in_an_ambient_module_declaration_cannot_reference_module_through_relative_module_name: { code: 2439, category: ts.DiagnosticCategory.Error, key: "Import_or_export_declaration_in_an_ambient_module_declaration_cannot_reference_module_through_relati_2439", message: "Import or export declaration in an ambient module declaration cannot reference module through relative module name." }, + Import_declaration_conflicts_with_local_declaration_of_0: { code: 2440, category: ts.DiagnosticCategory.Error, key: "Import_declaration_conflicts_with_local_declaration_of_0_2440", message: "Import declaration conflicts with local declaration of '{0}'" }, + Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module: { code: 2441, category: ts.DiagnosticCategory.Error, key: "Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module_2441", message: "Duplicate identifier '{0}'. Compiler reserves name '{1}' in top level scope of a module." }, + Types_have_separate_declarations_of_a_private_property_0: { code: 2442, category: ts.DiagnosticCategory.Error, key: "Types_have_separate_declarations_of_a_private_property_0_2442", message: "Types have separate declarations of a private property '{0}'." }, + Property_0_is_protected_but_type_1_is_not_a_class_derived_from_2: { code: 2443, category: ts.DiagnosticCategory.Error, key: "Property_0_is_protected_but_type_1_is_not_a_class_derived_from_2_2443", message: "Property '{0}' is protected but type '{1}' is not a class derived from '{2}'." }, + Property_0_is_protected_in_type_1_but_public_in_type_2: { code: 2444, category: ts.DiagnosticCategory.Error, key: "Property_0_is_protected_in_type_1_but_public_in_type_2_2444", message: "Property '{0}' is protected in type '{1}' but public in type '{2}'." }, + Property_0_is_protected_and_only_accessible_within_class_1_and_its_subclasses: { code: 2445, category: ts.DiagnosticCategory.Error, key: "Property_0_is_protected_and_only_accessible_within_class_1_and_its_subclasses_2445", message: "Property '{0}' is protected and only accessible within class '{1}' and its subclasses." }, + Property_0_is_protected_and_only_accessible_through_an_instance_of_class_1: { code: 2446, category: ts.DiagnosticCategory.Error, key: "Property_0_is_protected_and_only_accessible_through_an_instance_of_class_1_2446", message: "Property '{0}' is protected and only accessible through an instance of class '{1}'." }, + The_0_operator_is_not_allowed_for_boolean_types_Consider_using_1_instead: { code: 2447, category: ts.DiagnosticCategory.Error, key: "The_0_operator_is_not_allowed_for_boolean_types_Consider_using_1_instead_2447", message: "The '{0}' operator is not allowed for boolean types. Consider using '{1}' instead." }, + Block_scoped_variable_0_used_before_its_declaration: { code: 2448, category: ts.DiagnosticCategory.Error, key: "Block_scoped_variable_0_used_before_its_declaration_2448", message: "Block-scoped variable '{0}' used before its declaration." }, + The_operand_of_an_increment_or_decrement_operator_cannot_be_a_constant: { code: 2449, category: ts.DiagnosticCategory.Error, key: "The_operand_of_an_increment_or_decrement_operator_cannot_be_a_constant_2449", message: "The operand of an increment or decrement operator cannot be a constant." }, + Left_hand_side_of_assignment_expression_cannot_be_a_constant: { code: 2450, category: ts.DiagnosticCategory.Error, key: "Left_hand_side_of_assignment_expression_cannot_be_a_constant_2450", message: "Left-hand side of assignment expression cannot be a constant." }, + Cannot_redeclare_block_scoped_variable_0: { code: 2451, category: ts.DiagnosticCategory.Error, key: "Cannot_redeclare_block_scoped_variable_0_2451", message: "Cannot redeclare block-scoped variable '{0}'." }, + An_enum_member_cannot_have_a_numeric_name: { code: 2452, category: ts.DiagnosticCategory.Error, key: "An_enum_member_cannot_have_a_numeric_name_2452", message: "An enum member cannot have a numeric name." }, + The_type_argument_for_type_parameter_0_cannot_be_inferred_from_the_usage_Consider_specifying_the_type_arguments_explicitly: { code: 2453, category: ts.DiagnosticCategory.Error, key: "The_type_argument_for_type_parameter_0_cannot_be_inferred_from_the_usage_Consider_specifying_the_typ_2453", message: "The type argument for type parameter '{0}' cannot be inferred from the usage. Consider specifying the type arguments explicitly." }, + Type_argument_candidate_1_is_not_a_valid_type_argument_because_it_is_not_a_supertype_of_candidate_0: { code: 2455, category: ts.DiagnosticCategory.Error, key: "Type_argument_candidate_1_is_not_a_valid_type_argument_because_it_is_not_a_supertype_of_candidate_0_2455", message: "Type argument candidate '{1}' is not a valid type argument because it is not a supertype of candidate '{0}'." }, + Type_alias_0_circularly_references_itself: { code: 2456, category: ts.DiagnosticCategory.Error, key: "Type_alias_0_circularly_references_itself_2456", message: "Type alias '{0}' circularly references itself." }, + Type_alias_name_cannot_be_0: { code: 2457, category: ts.DiagnosticCategory.Error, key: "Type_alias_name_cannot_be_0_2457", message: "Type alias name cannot be '{0}'" }, + An_AMD_module_cannot_have_multiple_name_assignments: { code: 2458, category: ts.DiagnosticCategory.Error, key: "An_AMD_module_cannot_have_multiple_name_assignments_2458", message: "An AMD module cannot have multiple name assignments." }, + Type_0_has_no_property_1_and_no_string_index_signature: { code: 2459, category: ts.DiagnosticCategory.Error, key: "Type_0_has_no_property_1_and_no_string_index_signature_2459", message: "Type '{0}' has no property '{1}' and no string index signature." }, + Type_0_has_no_property_1: { code: 2460, category: ts.DiagnosticCategory.Error, key: "Type_0_has_no_property_1_2460", message: "Type '{0}' has no property '{1}'." }, + Type_0_is_not_an_array_type: { code: 2461, category: ts.DiagnosticCategory.Error, key: "Type_0_is_not_an_array_type_2461", message: "Type '{0}' is not an array type." }, + A_rest_element_must_be_last_in_an_array_destructuring_pattern: { code: 2462, category: ts.DiagnosticCategory.Error, key: "A_rest_element_must_be_last_in_an_array_destructuring_pattern_2462", message: "A rest element must be last in an array destructuring pattern" }, + A_binding_pattern_parameter_cannot_be_optional_in_an_implementation_signature: { code: 2463, category: ts.DiagnosticCategory.Error, key: "A_binding_pattern_parameter_cannot_be_optional_in_an_implementation_signature_2463", message: "A binding pattern parameter cannot be optional in an implementation signature." }, + A_computed_property_name_must_be_of_type_string_number_symbol_or_any: { code: 2464, category: ts.DiagnosticCategory.Error, key: "A_computed_property_name_must_be_of_type_string_number_symbol_or_any_2464", message: "A computed property name must be of type 'string', 'number', 'symbol', or 'any'." }, + this_cannot_be_referenced_in_a_computed_property_name: { code: 2465, category: ts.DiagnosticCategory.Error, key: "this_cannot_be_referenced_in_a_computed_property_name_2465", message: "'this' cannot be referenced in a computed property name." }, + super_cannot_be_referenced_in_a_computed_property_name: { code: 2466, category: ts.DiagnosticCategory.Error, key: "super_cannot_be_referenced_in_a_computed_property_name_2466", message: "'super' cannot be referenced in a computed property name." }, + A_computed_property_name_cannot_reference_a_type_parameter_from_its_containing_type: { code: 2467, category: ts.DiagnosticCategory.Error, key: "A_computed_property_name_cannot_reference_a_type_parameter_from_its_containing_type_2467", message: "A computed property name cannot reference a type parameter from its containing type." }, + Cannot_find_global_value_0: { code: 2468, category: ts.DiagnosticCategory.Error, key: "Cannot_find_global_value_0_2468", message: "Cannot find global value '{0}'." }, + The_0_operator_cannot_be_applied_to_type_symbol: { code: 2469, category: ts.DiagnosticCategory.Error, key: "The_0_operator_cannot_be_applied_to_type_symbol_2469", message: "The '{0}' operator cannot be applied to type 'symbol'." }, + Symbol_reference_does_not_refer_to_the_global_Symbol_constructor_object: { code: 2470, category: ts.DiagnosticCategory.Error, key: "Symbol_reference_does_not_refer_to_the_global_Symbol_constructor_object_2470", message: "'Symbol' reference does not refer to the global Symbol constructor object." }, + A_computed_property_name_of_the_form_0_must_be_of_type_symbol: { code: 2471, category: ts.DiagnosticCategory.Error, key: "A_computed_property_name_of_the_form_0_must_be_of_type_symbol_2471", message: "A computed property name of the form '{0}' must be of type 'symbol'." }, + Spread_operator_in_new_expressions_is_only_available_when_targeting_ECMAScript_5_and_higher: { code: 2472, category: ts.DiagnosticCategory.Error, key: "Spread_operator_in_new_expressions_is_only_available_when_targeting_ECMAScript_5_and_higher_2472", message: "Spread operator in 'new' expressions is only available when targeting ECMAScript 5 and higher." }, + Enum_declarations_must_all_be_const_or_non_const: { code: 2473, category: ts.DiagnosticCategory.Error, key: "Enum_declarations_must_all_be_const_or_non_const_2473", message: "Enum declarations must all be const or non-const." }, + In_const_enum_declarations_member_initializer_must_be_constant_expression: { code: 2474, category: ts.DiagnosticCategory.Error, key: "In_const_enum_declarations_member_initializer_must_be_constant_expression_2474", message: "In 'const' enum declarations member initializer must be constant expression." }, + const_enums_can_only_be_used_in_property_or_index_access_expressions_or_the_right_hand_side_of_an_import_declaration_or_export_assignment: { code: 2475, category: ts.DiagnosticCategory.Error, key: "const_enums_can_only_be_used_in_property_or_index_access_expressions_or_the_right_hand_side_of_an_im_2475", message: "'const' enums can only be used in property or index access expressions or the right hand side of an import declaration or export assignment." }, + A_const_enum_member_can_only_be_accessed_using_a_string_literal: { code: 2476, category: ts.DiagnosticCategory.Error, key: "A_const_enum_member_can_only_be_accessed_using_a_string_literal_2476", message: "A const enum member can only be accessed using a string literal." }, + const_enum_member_initializer_was_evaluated_to_a_non_finite_value: { code: 2477, category: ts.DiagnosticCategory.Error, key: "const_enum_member_initializer_was_evaluated_to_a_non_finite_value_2477", message: "'const' enum member initializer was evaluated to a non-finite value." }, + const_enum_member_initializer_was_evaluated_to_disallowed_value_NaN: { code: 2478, category: ts.DiagnosticCategory.Error, key: "const_enum_member_initializer_was_evaluated_to_disallowed_value_NaN_2478", message: "'const' enum member initializer was evaluated to disallowed value 'NaN'." }, + Property_0_does_not_exist_on_const_enum_1: { code: 2479, category: ts.DiagnosticCategory.Error, key: "Property_0_does_not_exist_on_const_enum_1_2479", message: "Property '{0}' does not exist on 'const' enum '{1}'." }, + let_is_not_allowed_to_be_used_as_a_name_in_let_or_const_declarations: { code: 2480, category: ts.DiagnosticCategory.Error, key: "let_is_not_allowed_to_be_used_as_a_name_in_let_or_const_declarations_2480", message: "'let' is not allowed to be used as a name in 'let' or 'const' declarations." }, + Cannot_initialize_outer_scoped_variable_0_in_the_same_scope_as_block_scoped_declaration_1: { code: 2481, category: ts.DiagnosticCategory.Error, key: "Cannot_initialize_outer_scoped_variable_0_in_the_same_scope_as_block_scoped_declaration_1_2481", message: "Cannot initialize outer scoped variable '{0}' in the same scope as block scoped declaration '{1}'." }, + The_left_hand_side_of_a_for_of_statement_cannot_use_a_type_annotation: { code: 2483, category: ts.DiagnosticCategory.Error, key: "The_left_hand_side_of_a_for_of_statement_cannot_use_a_type_annotation_2483", message: "The left-hand side of a 'for...of' statement cannot use a type annotation." }, + Export_declaration_conflicts_with_exported_declaration_of_0: { code: 2484, category: ts.DiagnosticCategory.Error, key: "Export_declaration_conflicts_with_exported_declaration_of_0_2484", message: "Export declaration conflicts with exported declaration of '{0}'" }, + The_left_hand_side_of_a_for_of_statement_cannot_be_a_previously_defined_constant: { code: 2485, category: ts.DiagnosticCategory.Error, key: "The_left_hand_side_of_a_for_of_statement_cannot_be_a_previously_defined_constant_2485", message: "The left-hand side of a 'for...of' statement cannot be a previously defined constant." }, + The_left_hand_side_of_a_for_in_statement_cannot_be_a_previously_defined_constant: { code: 2486, category: ts.DiagnosticCategory.Error, key: "The_left_hand_side_of_a_for_in_statement_cannot_be_a_previously_defined_constant_2486", message: "The left-hand side of a 'for...in' statement cannot be a previously defined constant." }, + Invalid_left_hand_side_in_for_of_statement: { code: 2487, category: ts.DiagnosticCategory.Error, key: "Invalid_left_hand_side_in_for_of_statement_2487", message: "Invalid left-hand side in 'for...of' statement." }, + Type_must_have_a_Symbol_iterator_method_that_returns_an_iterator: { code: 2488, category: ts.DiagnosticCategory.Error, key: "Type_must_have_a_Symbol_iterator_method_that_returns_an_iterator_2488", message: "Type must have a '[Symbol.iterator]()' method that returns an iterator." }, + An_iterator_must_have_a_next_method: { code: 2489, category: ts.DiagnosticCategory.Error, key: "An_iterator_must_have_a_next_method_2489", message: "An iterator must have a 'next()' method." }, + The_type_returned_by_the_next_method_of_an_iterator_must_have_a_value_property: { code: 2490, category: ts.DiagnosticCategory.Error, key: "The_type_returned_by_the_next_method_of_an_iterator_must_have_a_value_property_2490", message: "The type returned by the 'next()' method of an iterator must have a 'value' property." }, + The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern: { code: 2491, category: ts.DiagnosticCategory.Error, key: "The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern_2491", message: "The left-hand side of a 'for...in' statement cannot be a destructuring pattern." }, + Cannot_redeclare_identifier_0_in_catch_clause: { code: 2492, category: ts.DiagnosticCategory.Error, key: "Cannot_redeclare_identifier_0_in_catch_clause_2492", message: "Cannot redeclare identifier '{0}' in catch clause" }, + Tuple_type_0_with_length_1_cannot_be_assigned_to_tuple_with_length_2: { code: 2493, category: ts.DiagnosticCategory.Error, key: "Tuple_type_0_with_length_1_cannot_be_assigned_to_tuple_with_length_2_2493", message: "Tuple type '{0}' with length '{1}' cannot be assigned to tuple with length '{2}'." }, + Using_a_string_in_a_for_of_statement_is_only_supported_in_ECMAScript_5_and_higher: { code: 2494, category: ts.DiagnosticCategory.Error, key: "Using_a_string_in_a_for_of_statement_is_only_supported_in_ECMAScript_5_and_higher_2494", message: "Using a string in a 'for...of' statement is only supported in ECMAScript 5 and higher." }, + Type_0_is_not_an_array_type_or_a_string_type: { code: 2495, category: ts.DiagnosticCategory.Error, key: "Type_0_is_not_an_array_type_or_a_string_type_2495", message: "Type '{0}' is not an array type or a string type." }, + The_arguments_object_cannot_be_referenced_in_an_arrow_function_in_ES3_and_ES5_Consider_using_a_standard_function_expression: { code: 2496, category: ts.DiagnosticCategory.Error, key: "The_arguments_object_cannot_be_referenced_in_an_arrow_function_in_ES3_and_ES5_Consider_using_a_stand_2496", message: "The 'arguments' object cannot be referenced in an arrow function in ES3 and ES5. Consider using a standard function expression." }, + Module_0_resolves_to_a_non_module_entity_and_cannot_be_imported_using_this_construct: { code: 2497, category: ts.DiagnosticCategory.Error, key: "Module_0_resolves_to_a_non_module_entity_and_cannot_be_imported_using_this_construct_2497", message: "Module '{0}' resolves to a non-module entity and cannot be imported using this construct." }, + Module_0_uses_export_and_cannot_be_used_with_export_Asterisk: { code: 2498, category: ts.DiagnosticCategory.Error, key: "Module_0_uses_export_and_cannot_be_used_with_export_Asterisk_2498", message: "Module '{0}' uses 'export =' and cannot be used with 'export *'." }, + An_interface_can_only_extend_an_identifier_Slashqualified_name_with_optional_type_arguments: { code: 2499, category: ts.DiagnosticCategory.Error, key: "An_interface_can_only_extend_an_identifier_Slashqualified_name_with_optional_type_arguments_2499", message: "An interface can only extend an identifier/qualified-name with optional type arguments." }, + A_class_can_only_implement_an_identifier_Slashqualified_name_with_optional_type_arguments: { code: 2500, category: ts.DiagnosticCategory.Error, key: "A_class_can_only_implement_an_identifier_Slashqualified_name_with_optional_type_arguments_2500", message: "A class can only implement an identifier/qualified-name with optional type arguments." }, + A_rest_element_cannot_contain_a_binding_pattern: { code: 2501, category: ts.DiagnosticCategory.Error, key: "A_rest_element_cannot_contain_a_binding_pattern_2501", message: "A rest element cannot contain a binding pattern." }, + _0_is_referenced_directly_or_indirectly_in_its_own_type_annotation: { code: 2502, category: ts.DiagnosticCategory.Error, key: "_0_is_referenced_directly_or_indirectly_in_its_own_type_annotation_2502", message: "'{0}' is referenced directly or indirectly in its own type annotation." }, + Cannot_find_namespace_0: { code: 2503, category: ts.DiagnosticCategory.Error, key: "Cannot_find_namespace_0_2503", message: "Cannot find namespace '{0}'." }, + No_best_common_type_exists_among_yield_expressions: { code: 2504, category: ts.DiagnosticCategory.Error, key: "No_best_common_type_exists_among_yield_expressions_2504", message: "No best common type exists among yield expressions." }, + A_generator_cannot_have_a_void_type_annotation: { code: 2505, category: ts.DiagnosticCategory.Error, key: "A_generator_cannot_have_a_void_type_annotation_2505", message: "A generator cannot have a 'void' type annotation." }, + _0_is_referenced_directly_or_indirectly_in_its_own_base_expression: { code: 2506, category: ts.DiagnosticCategory.Error, key: "_0_is_referenced_directly_or_indirectly_in_its_own_base_expression_2506", message: "'{0}' is referenced directly or indirectly in its own base expression." }, + Type_0_is_not_a_constructor_function_type: { code: 2507, category: ts.DiagnosticCategory.Error, key: "Type_0_is_not_a_constructor_function_type_2507", message: "Type '{0}' is not a constructor function type." }, + No_base_constructor_has_the_specified_number_of_type_arguments: { code: 2508, category: ts.DiagnosticCategory.Error, key: "No_base_constructor_has_the_specified_number_of_type_arguments_2508", message: "No base constructor has the specified number of type arguments." }, + Base_constructor_return_type_0_is_not_a_class_or_interface_type: { code: 2509, category: ts.DiagnosticCategory.Error, key: "Base_constructor_return_type_0_is_not_a_class_or_interface_type_2509", message: "Base constructor return type '{0}' is not a class or interface type." }, + Base_constructors_must_all_have_the_same_return_type: { code: 2510, category: ts.DiagnosticCategory.Error, key: "Base_constructors_must_all_have_the_same_return_type_2510", message: "Base constructors must all have the same return type." }, + Cannot_create_an_instance_of_the_abstract_class_0: { code: 2511, category: ts.DiagnosticCategory.Error, key: "Cannot_create_an_instance_of_the_abstract_class_0_2511", message: "Cannot create an instance of the abstract class '{0}'." }, + Overload_signatures_must_all_be_abstract_or_not_abstract: { code: 2512, category: ts.DiagnosticCategory.Error, key: "Overload_signatures_must_all_be_abstract_or_not_abstract_2512", message: "Overload signatures must all be abstract or not abstract." }, + Abstract_method_0_in_class_1_cannot_be_accessed_via_super_expression: { code: 2513, category: ts.DiagnosticCategory.Error, key: "Abstract_method_0_in_class_1_cannot_be_accessed_via_super_expression_2513", message: "Abstract method '{0}' in class '{1}' cannot be accessed via super expression." }, + Classes_containing_abstract_methods_must_be_marked_abstract: { code: 2514, category: ts.DiagnosticCategory.Error, key: "Classes_containing_abstract_methods_must_be_marked_abstract_2514", message: "Classes containing abstract methods must be marked abstract." }, + Non_abstract_class_0_does_not_implement_inherited_abstract_member_1_from_class_2: { code: 2515, category: ts.DiagnosticCategory.Error, key: "Non_abstract_class_0_does_not_implement_inherited_abstract_member_1_from_class_2_2515", message: "Non-abstract class '{0}' does not implement inherited abstract member '{1}' from class '{2}'." }, + All_declarations_of_an_abstract_method_must_be_consecutive: { code: 2516, category: ts.DiagnosticCategory.Error, key: "All_declarations_of_an_abstract_method_must_be_consecutive_2516", message: "All declarations of an abstract method must be consecutive." }, + Cannot_assign_an_abstract_constructor_type_to_a_non_abstract_constructor_type: { code: 2517, category: ts.DiagnosticCategory.Error, key: "Cannot_assign_an_abstract_constructor_type_to_a_non_abstract_constructor_type_2517", message: "Cannot assign an abstract constructor type to a non-abstract constructor type." }, + Duplicate_identifier_0_Compiler_uses_declaration_1_to_support_async_functions: { code: 2520, category: ts.DiagnosticCategory.Error, key: "Duplicate_identifier_0_Compiler_uses_declaration_1_to_support_async_functions_2520", message: "Duplicate identifier '{0}'. Compiler uses declaration '{1}' to support async functions." }, + Expression_resolves_to_variable_declaration_0_that_compiler_uses_to_support_async_functions: { code: 2521, category: ts.DiagnosticCategory.Error, key: "Expression_resolves_to_variable_declaration_0_that_compiler_uses_to_support_async_functions_2521", message: "Expression resolves to variable declaration '{0}' that compiler uses to support async functions." }, + The_arguments_object_cannot_be_referenced_in_an_async_arrow_function_Consider_using_a_standard_async_function_expression: { code: 2522, category: ts.DiagnosticCategory.Error, key: "The_arguments_object_cannot_be_referenced_in_an_async_arrow_function_Consider_using_a_standard_async_2522", message: "The 'arguments' object cannot be referenced in an async arrow function. Consider using a standard async function expression." }, + yield_expressions_cannot_be_used_in_a_parameter_initializer: { code: 2523, category: ts.DiagnosticCategory.Error, key: "yield_expressions_cannot_be_used_in_a_parameter_initializer_2523", message: "'yield' expressions cannot be used in a parameter initializer." }, + await_expressions_cannot_be_used_in_a_parameter_initializer: { code: 2524, category: ts.DiagnosticCategory.Error, key: "await_expressions_cannot_be_used_in_a_parameter_initializer_2524", message: "'await' expressions cannot be used in a parameter initializer." }, + Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value: { code: 2525, category: ts.DiagnosticCategory.Error, key: "Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value_2525", message: "Initializer provides no value for this binding element and the binding element has no default value." }, + A_this_type_is_available_only_in_a_non_static_member_of_a_class_or_interface: { code: 2526, category: ts.DiagnosticCategory.Error, key: "A_this_type_is_available_only_in_a_non_static_member_of_a_class_or_interface_2526", message: "A 'this' type is available only in a non-static member of a class or interface." }, + The_inferred_type_of_0_references_an_inaccessible_this_type_A_type_annotation_is_necessary: { code: 2527, category: ts.DiagnosticCategory.Error, key: "The_inferred_type_of_0_references_an_inaccessible_this_type_A_type_annotation_is_necessary_2527", message: "The inferred type of '{0}' references an inaccessible 'this' type. A type annotation is necessary." }, + A_module_cannot_have_multiple_default_exports: { code: 2528, category: ts.DiagnosticCategory.Error, key: "A_module_cannot_have_multiple_default_exports_2528", message: "A module cannot have multiple default exports." }, + JSX_element_attributes_type_0_must_be_an_object_type: { code: 2600, category: ts.DiagnosticCategory.Error, key: "JSX_element_attributes_type_0_must_be_an_object_type_2600", message: "JSX element attributes type '{0}' must be an object type." }, + The_return_type_of_a_JSX_element_constructor_must_return_an_object_type: { code: 2601, category: ts.DiagnosticCategory.Error, key: "The_return_type_of_a_JSX_element_constructor_must_return_an_object_type_2601", message: "The return type of a JSX element constructor must return an object type." }, + JSX_element_implicitly_has_type_any_because_the_global_type_JSX_Element_does_not_exist: { code: 2602, category: ts.DiagnosticCategory.Error, key: "JSX_element_implicitly_has_type_any_because_the_global_type_JSX_Element_does_not_exist_2602", message: "JSX element implicitly has type 'any' because the global type 'JSX.Element' does not exist." }, + Property_0_in_type_1_is_not_assignable_to_type_2: { code: 2603, category: ts.DiagnosticCategory.Error, key: "Property_0_in_type_1_is_not_assignable_to_type_2_2603", message: "Property '{0}' in type '{1}' is not assignable to type '{2}'" }, + JSX_element_type_0_does_not_have_any_construct_or_call_signatures: { code: 2604, category: ts.DiagnosticCategory.Error, key: "JSX_element_type_0_does_not_have_any_construct_or_call_signatures_2604", message: "JSX element type '{0}' does not have any construct or call signatures." }, + JSX_element_type_0_is_not_a_constructor_function_for_JSX_elements: { code: 2605, category: ts.DiagnosticCategory.Error, key: "JSX_element_type_0_is_not_a_constructor_function_for_JSX_elements_2605", message: "JSX element type '{0}' is not a constructor function for JSX elements." }, + Property_0_of_JSX_spread_attribute_is_not_assignable_to_target_property: { code: 2606, category: ts.DiagnosticCategory.Error, key: "Property_0_of_JSX_spread_attribute_is_not_assignable_to_target_property_2606", message: "Property '{0}' of JSX spread attribute is not assignable to target property." }, + JSX_element_class_does_not_support_attributes_because_it_does_not_have_a_0_property: { code: 2607, category: ts.DiagnosticCategory.Error, key: "JSX_element_class_does_not_support_attributes_because_it_does_not_have_a_0_property_2607", message: "JSX element class does not support attributes because it does not have a '{0}' property" }, + The_global_type_JSX_0_may_not_have_more_than_one_property: { code: 2608, category: ts.DiagnosticCategory.Error, key: "The_global_type_JSX_0_may_not_have_more_than_one_property_2608", message: "The global type 'JSX.{0}' may not have more than one property" }, + Cannot_emit_namespaced_JSX_elements_in_React: { code: 2650, category: ts.DiagnosticCategory.Error, key: "Cannot_emit_namespaced_JSX_elements_in_React_2650", message: "Cannot emit namespaced JSX elements in React" }, + A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_enums: { code: 2651, category: ts.DiagnosticCategory.Error, key: "A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_memb_2651", message: "A member initializer in a enum declaration cannot reference members declared after it, including members defined in other enums." }, + Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_default_0_declaration_instead: { code: 2652, category: ts.DiagnosticCategory.Error, key: "Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_d_2652", message: "Merged declaration '{0}' cannot include a default export declaration. Consider adding a separate 'export default {0}' declaration instead." }, + Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1: { code: 2653, category: ts.DiagnosticCategory.Error, key: "Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1_2653", message: "Non-abstract class expression does not implement inherited abstract member '{0}' from class '{1}'." }, + Exported_external_package_typings_file_cannot_contain_tripleslash_references_Please_contact_the_package_author_to_update_the_package_definition: { code: 2654, category: ts.DiagnosticCategory.Error, key: "Exported_external_package_typings_file_cannot_contain_tripleslash_references_Please_contact_the_pack_2654", message: "Exported external package typings file cannot contain tripleslash references. Please contact the package author to update the package definition." }, + Exported_external_package_typings_file_0_is_not_a_module_Please_contact_the_package_author_to_update_the_package_definition: { code: 2656, category: ts.DiagnosticCategory.Error, key: "Exported_external_package_typings_file_0_is_not_a_module_Please_contact_the_package_author_to_update_2656", message: "Exported external package typings file '{0}' is not a module. Please contact the package author to update the package definition." }, + JSX_expressions_must_have_one_parent_element: { code: 2657, category: ts.DiagnosticCategory.Error, key: "JSX_expressions_must_have_one_parent_element_2657", message: "JSX expressions must have one parent element" }, + Import_declaration_0_is_using_private_name_1: { code: 4000, category: ts.DiagnosticCategory.Error, key: "Import_declaration_0_is_using_private_name_1_4000", message: "Import declaration '{0}' is using private name '{1}'." }, + Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: { code: 4002, category: ts.DiagnosticCategory.Error, key: "Type_parameter_0_of_exported_class_has_or_is_using_private_name_1_4002", message: "Type parameter '{0}' of exported class has or is using private name '{1}'." }, + Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1: { code: 4004, category: ts.DiagnosticCategory.Error, key: "Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1_4004", message: "Type parameter '{0}' of exported interface has or is using private name '{1}'." }, + Type_parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1: { code: 4006, category: ts.DiagnosticCategory.Error, key: "Type_parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1_4006", message: "Type parameter '{0}' of constructor signature from exported interface has or is using private name '{1}'." }, + Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1: { code: 4008, category: ts.DiagnosticCategory.Error, key: "Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1_4008", message: "Type parameter '{0}' of call signature from exported interface has or is using private name '{1}'." }, + Type_parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1: { code: 4010, category: ts.DiagnosticCategory.Error, key: "Type_parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1_4010", message: "Type parameter '{0}' of public static method from exported class has or is using private name '{1}'." }, + Type_parameter_0_of_public_method_from_exported_class_has_or_is_using_private_name_1: { code: 4012, category: ts.DiagnosticCategory.Error, key: "Type_parameter_0_of_public_method_from_exported_class_has_or_is_using_private_name_1_4012", message: "Type parameter '{0}' of public method from exported class has or is using private name '{1}'." }, + Type_parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1: { code: 4014, category: ts.DiagnosticCategory.Error, key: "Type_parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1_4014", message: "Type parameter '{0}' of method from exported interface has or is using private name '{1}'." }, + Type_parameter_0_of_exported_function_has_or_is_using_private_name_1: { code: 4016, category: ts.DiagnosticCategory.Error, key: "Type_parameter_0_of_exported_function_has_or_is_using_private_name_1_4016", message: "Type parameter '{0}' of exported function has or is using private name '{1}'." }, + Implements_clause_of_exported_class_0_has_or_is_using_private_name_1: { code: 4019, category: ts.DiagnosticCategory.Error, key: "Implements_clause_of_exported_class_0_has_or_is_using_private_name_1_4019", message: "Implements clause of exported class '{0}' has or is using private name '{1}'." }, + Extends_clause_of_exported_class_0_has_or_is_using_private_name_1: { code: 4020, category: ts.DiagnosticCategory.Error, key: "Extends_clause_of_exported_class_0_has_or_is_using_private_name_1_4020", message: "Extends clause of exported class '{0}' has or is using private name '{1}'." }, + Extends_clause_of_exported_interface_0_has_or_is_using_private_name_1: { code: 4022, category: ts.DiagnosticCategory.Error, key: "Extends_clause_of_exported_interface_0_has_or_is_using_private_name_1_4022", message: "Extends clause of exported interface '{0}' has or is using private name '{1}'." }, + Exported_variable_0_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: { code: 4023, category: ts.DiagnosticCategory.Error, key: "Exported_variable_0_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named_4023", message: "Exported variable '{0}' has or is using name '{1}' from external module {2} but cannot be named." }, + Exported_variable_0_has_or_is_using_name_1_from_private_module_2: { code: 4024, category: ts.DiagnosticCategory.Error, key: "Exported_variable_0_has_or_is_using_name_1_from_private_module_2_4024", message: "Exported variable '{0}' has or is using name '{1}' from private module '{2}'." }, + Exported_variable_0_has_or_is_using_private_name_1: { code: 4025, category: ts.DiagnosticCategory.Error, key: "Exported_variable_0_has_or_is_using_private_name_1_4025", message: "Exported variable '{0}' has or is using private name '{1}'." }, + Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: { code: 4026, category: ts.DiagnosticCategory.Error, key: "Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot__4026", message: "Public static property '{0}' of exported class has or is using name '{1}' from external module {2} but cannot be named." }, + Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2: { code: 4027, category: ts.DiagnosticCategory.Error, key: "Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2_4027", message: "Public static property '{0}' of exported class has or is using name '{1}' from private module '{2}'." }, + Public_static_property_0_of_exported_class_has_or_is_using_private_name_1: { code: 4028, category: ts.DiagnosticCategory.Error, key: "Public_static_property_0_of_exported_class_has_or_is_using_private_name_1_4028", message: "Public static property '{0}' of exported class has or is using private name '{1}'." }, + Public_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: { code: 4029, category: ts.DiagnosticCategory.Error, key: "Public_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_name_4029", message: "Public property '{0}' of exported class has or is using name '{1}' from external module {2} but cannot be named." }, + Public_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2: { code: 4030, category: ts.DiagnosticCategory.Error, key: "Public_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2_4030", message: "Public property '{0}' of exported class has or is using name '{1}' from private module '{2}'." }, + Public_property_0_of_exported_class_has_or_is_using_private_name_1: { code: 4031, category: ts.DiagnosticCategory.Error, key: "Public_property_0_of_exported_class_has_or_is_using_private_name_1_4031", message: "Public property '{0}' of exported class has or is using private name '{1}'." }, + Property_0_of_exported_interface_has_or_is_using_name_1_from_private_module_2: { code: 4032, category: ts.DiagnosticCategory.Error, key: "Property_0_of_exported_interface_has_or_is_using_name_1_from_private_module_2_4032", message: "Property '{0}' of exported interface has or is using name '{1}' from private module '{2}'." }, + Property_0_of_exported_interface_has_or_is_using_private_name_1: { code: 4033, category: ts.DiagnosticCategory.Error, key: "Property_0_of_exported_interface_has_or_is_using_private_name_1_4033", message: "Property '{0}' of exported interface has or is using private name '{1}'." }, + Parameter_0_of_public_static_property_setter_from_exported_class_has_or_is_using_name_1_from_private_module_2: { code: 4034, category: ts.DiagnosticCategory.Error, key: "Parameter_0_of_public_static_property_setter_from_exported_class_has_or_is_using_name_1_from_private_4034", message: "Parameter '{0}' of public static property setter from exported class has or is using name '{1}' from private module '{2}'." }, + Parameter_0_of_public_static_property_setter_from_exported_class_has_or_is_using_private_name_1: { code: 4035, category: ts.DiagnosticCategory.Error, key: "Parameter_0_of_public_static_property_setter_from_exported_class_has_or_is_using_private_name_1_4035", message: "Parameter '{0}' of public static property setter from exported class has or is using private name '{1}'." }, + Parameter_0_of_public_property_setter_from_exported_class_has_or_is_using_name_1_from_private_module_2: { code: 4036, category: ts.DiagnosticCategory.Error, key: "Parameter_0_of_public_property_setter_from_exported_class_has_or_is_using_name_1_from_private_module_4036", message: "Parameter '{0}' of public property setter from exported class has or is using name '{1}' from private module '{2}'." }, + Parameter_0_of_public_property_setter_from_exported_class_has_or_is_using_private_name_1: { code: 4037, category: ts.DiagnosticCategory.Error, key: "Parameter_0_of_public_property_setter_from_exported_class_has_or_is_using_private_name_1_4037", message: "Parameter '{0}' of public property setter from exported class has or is using private name '{1}'." }, + Return_type_of_public_static_property_getter_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named: { code: 4038, category: ts.DiagnosticCategory.Error, key: "Return_type_of_public_static_property_getter_from_exported_class_has_or_is_using_name_0_from_externa_4038", message: "Return type of public static property getter from exported class has or is using name '{0}' from external module {1} but cannot be named." }, + Return_type_of_public_static_property_getter_from_exported_class_has_or_is_using_name_0_from_private_module_1: { code: 4039, category: ts.DiagnosticCategory.Error, key: "Return_type_of_public_static_property_getter_from_exported_class_has_or_is_using_name_0_from_private_4039", message: "Return type of public static property getter from exported class has or is using name '{0}' from private module '{1}'." }, + Return_type_of_public_static_property_getter_from_exported_class_has_or_is_using_private_name_0: { code: 4040, category: ts.DiagnosticCategory.Error, key: "Return_type_of_public_static_property_getter_from_exported_class_has_or_is_using_private_name_0_4040", message: "Return type of public static property getter from exported class has or is using private name '{0}'." }, + Return_type_of_public_property_getter_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named: { code: 4041, category: ts.DiagnosticCategory.Error, key: "Return_type_of_public_property_getter_from_exported_class_has_or_is_using_name_0_from_external_modul_4041", message: "Return type of public property getter from exported class has or is using name '{0}' from external module {1} but cannot be named." }, + Return_type_of_public_property_getter_from_exported_class_has_or_is_using_name_0_from_private_module_1: { code: 4042, category: ts.DiagnosticCategory.Error, key: "Return_type_of_public_property_getter_from_exported_class_has_or_is_using_name_0_from_private_module_4042", message: "Return type of public property getter from exported class has or is using name '{0}' from private module '{1}'." }, + Return_type_of_public_property_getter_from_exported_class_has_or_is_using_private_name_0: { code: 4043, category: ts.DiagnosticCategory.Error, key: "Return_type_of_public_property_getter_from_exported_class_has_or_is_using_private_name_0_4043", message: "Return type of public property getter from exported class has or is using private name '{0}'." }, + Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1: { code: 4044, category: ts.DiagnosticCategory.Error, key: "Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_name_0_from_private_mod_4044", message: "Return type of constructor signature from exported interface has or is using name '{0}' from private module '{1}'." }, + Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_0: { code: 4045, category: ts.DiagnosticCategory.Error, key: "Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_0_4045", message: "Return type of constructor signature from exported interface has or is using private name '{0}'." }, + Return_type_of_call_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1: { code: 4046, category: ts.DiagnosticCategory.Error, key: "Return_type_of_call_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1_4046", message: "Return type of call signature from exported interface has or is using name '{0}' from private module '{1}'." }, + Return_type_of_call_signature_from_exported_interface_has_or_is_using_private_name_0: { code: 4047, category: ts.DiagnosticCategory.Error, key: "Return_type_of_call_signature_from_exported_interface_has_or_is_using_private_name_0_4047", message: "Return type of call signature from exported interface has or is using private name '{0}'." }, + Return_type_of_index_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1: { code: 4048, category: ts.DiagnosticCategory.Error, key: "Return_type_of_index_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1_4048", message: "Return type of index signature from exported interface has or is using name '{0}' from private module '{1}'." }, + Return_type_of_index_signature_from_exported_interface_has_or_is_using_private_name_0: { code: 4049, category: ts.DiagnosticCategory.Error, key: "Return_type_of_index_signature_from_exported_interface_has_or_is_using_private_name_0_4049", message: "Return type of index signature from exported interface has or is using private name '{0}'." }, + Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named: { code: 4050, category: ts.DiagnosticCategory.Error, key: "Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_external_module__4050", message: "Return type of public static method from exported class has or is using name '{0}' from external module {1} but cannot be named." }, + Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_private_module_1: { code: 4051, category: ts.DiagnosticCategory.Error, key: "Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_private_module_1_4051", message: "Return type of public static method from exported class has or is using name '{0}' from private module '{1}'." }, + Return_type_of_public_static_method_from_exported_class_has_or_is_using_private_name_0: { code: 4052, category: ts.DiagnosticCategory.Error, key: "Return_type_of_public_static_method_from_exported_class_has_or_is_using_private_name_0_4052", message: "Return type of public static method from exported class has or is using private name '{0}'." }, + Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named: { code: 4053, category: ts.DiagnosticCategory.Error, key: "Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_c_4053", message: "Return type of public method from exported class has or is using name '{0}' from external module {1} but cannot be named." }, + Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_private_module_1: { code: 4054, category: ts.DiagnosticCategory.Error, key: "Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_private_module_1_4054", message: "Return type of public method from exported class has or is using name '{0}' from private module '{1}'." }, + Return_type_of_public_method_from_exported_class_has_or_is_using_private_name_0: { code: 4055, category: ts.DiagnosticCategory.Error, key: "Return_type_of_public_method_from_exported_class_has_or_is_using_private_name_0_4055", message: "Return type of public method from exported class has or is using private name '{0}'." }, + Return_type_of_method_from_exported_interface_has_or_is_using_name_0_from_private_module_1: { code: 4056, category: ts.DiagnosticCategory.Error, key: "Return_type_of_method_from_exported_interface_has_or_is_using_name_0_from_private_module_1_4056", message: "Return type of method from exported interface has or is using name '{0}' from private module '{1}'." }, + Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0: { code: 4057, category: ts.DiagnosticCategory.Error, key: "Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0_4057", message: "Return type of method from exported interface has or is using private name '{0}'." }, + Return_type_of_exported_function_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named: { code: 4058, category: ts.DiagnosticCategory.Error, key: "Return_type_of_exported_function_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named_4058", message: "Return type of exported function has or is using name '{0}' from external module {1} but cannot be named." }, + Return_type_of_exported_function_has_or_is_using_name_0_from_private_module_1: { code: 4059, category: ts.DiagnosticCategory.Error, key: "Return_type_of_exported_function_has_or_is_using_name_0_from_private_module_1_4059", message: "Return type of exported function has or is using name '{0}' from private module '{1}'." }, + Return_type_of_exported_function_has_or_is_using_private_name_0: { code: 4060, category: ts.DiagnosticCategory.Error, key: "Return_type_of_exported_function_has_or_is_using_private_name_0_4060", message: "Return type of exported function has or is using private name '{0}'." }, + Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: { code: 4061, category: ts.DiagnosticCategory.Error, key: "Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_can_4061", message: "Parameter '{0}' of constructor from exported class has or is using name '{1}' from external module {2} but cannot be named." }, + Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_private_module_2: { code: 4062, category: ts.DiagnosticCategory.Error, key: "Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_private_module_2_4062", message: "Parameter '{0}' of constructor from exported class has or is using name '{1}' from private module '{2}'." }, + Parameter_0_of_constructor_from_exported_class_has_or_is_using_private_name_1: { code: 4063, category: ts.DiagnosticCategory.Error, key: "Parameter_0_of_constructor_from_exported_class_has_or_is_using_private_name_1_4063", message: "Parameter '{0}' of constructor from exported class has or is using private name '{1}'." }, + Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2: { code: 4064, category: ts.DiagnosticCategory.Error, key: "Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_name_1_from_private_mod_4064", message: "Parameter '{0}' of constructor signature from exported interface has or is using name '{1}' from private module '{2}'." }, + Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1: { code: 4065, category: ts.DiagnosticCategory.Error, key: "Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1_4065", message: "Parameter '{0}' of constructor signature from exported interface has or is using private name '{1}'." }, + Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2: { code: 4066, category: ts.DiagnosticCategory.Error, key: "Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2_4066", message: "Parameter '{0}' of call signature from exported interface has or is using name '{1}' from private module '{2}'." }, + Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1: { code: 4067, category: ts.DiagnosticCategory.Error, key: "Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1_4067", message: "Parameter '{0}' of call signature from exported interface has or is using private name '{1}'." }, + Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: { code: 4068, category: ts.DiagnosticCategory.Error, key: "Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_external_module__4068", message: "Parameter '{0}' of public static method from exported class has or is using name '{1}' from external module {2} but cannot be named." }, + Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_private_module_2: { code: 4069, category: ts.DiagnosticCategory.Error, key: "Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_private_module_2_4069", message: "Parameter '{0}' of public static method from exported class has or is using name '{1}' from private module '{2}'." }, + Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1: { code: 4070, category: ts.DiagnosticCategory.Error, key: "Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1_4070", message: "Parameter '{0}' of public static method from exported class has or is using private name '{1}'." }, + Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: { code: 4071, category: ts.DiagnosticCategory.Error, key: "Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_c_4071", message: "Parameter '{0}' of public method from exported class has or is using name '{1}' from external module {2} but cannot be named." }, + Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_private_module_2: { code: 4072, category: ts.DiagnosticCategory.Error, key: "Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_private_module_2_4072", message: "Parameter '{0}' of public method from exported class has or is using name '{1}' from private module '{2}'." }, + Parameter_0_of_public_method_from_exported_class_has_or_is_using_private_name_1: { code: 4073, category: ts.DiagnosticCategory.Error, key: "Parameter_0_of_public_method_from_exported_class_has_or_is_using_private_name_1_4073", message: "Parameter '{0}' of public method from exported class has or is using private name '{1}'." }, + Parameter_0_of_method_from_exported_interface_has_or_is_using_name_1_from_private_module_2: { code: 4074, category: ts.DiagnosticCategory.Error, key: "Parameter_0_of_method_from_exported_interface_has_or_is_using_name_1_from_private_module_2_4074", message: "Parameter '{0}' of method from exported interface has or is using name '{1}' from private module '{2}'." }, + Parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1: { code: 4075, category: ts.DiagnosticCategory.Error, key: "Parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1_4075", message: "Parameter '{0}' of method from exported interface has or is using private name '{1}'." }, + Parameter_0_of_exported_function_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: { code: 4076, category: ts.DiagnosticCategory.Error, key: "Parameter_0_of_exported_function_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named_4076", message: "Parameter '{0}' of exported function has or is using name '{1}' from external module {2} but cannot be named." }, + Parameter_0_of_exported_function_has_or_is_using_name_1_from_private_module_2: { code: 4077, category: ts.DiagnosticCategory.Error, key: "Parameter_0_of_exported_function_has_or_is_using_name_1_from_private_module_2_4077", message: "Parameter '{0}' of exported function has or is using name '{1}' from private module '{2}'." }, + Parameter_0_of_exported_function_has_or_is_using_private_name_1: { code: 4078, category: ts.DiagnosticCategory.Error, key: "Parameter_0_of_exported_function_has_or_is_using_private_name_1_4078", message: "Parameter '{0}' of exported function has or is using private name '{1}'." }, + Exported_type_alias_0_has_or_is_using_private_name_1: { code: 4081, category: ts.DiagnosticCategory.Error, key: "Exported_type_alias_0_has_or_is_using_private_name_1_4081", message: "Exported type alias '{0}' has or is using private name '{1}'." }, + Default_export_of_the_module_has_or_is_using_private_name_0: { code: 4082, category: ts.DiagnosticCategory.Error, key: "Default_export_of_the_module_has_or_is_using_private_name_0_4082", message: "Default export of the module has or is using private name '{0}'." }, + The_current_host_does_not_support_the_0_option: { code: 5001, category: ts.DiagnosticCategory.Error, key: "The_current_host_does_not_support_the_0_option_5001", message: "The current host does not support the '{0}' option." }, + Cannot_find_the_common_subdirectory_path_for_the_input_files: { code: 5009, category: ts.DiagnosticCategory.Error, key: "Cannot_find_the_common_subdirectory_path_for_the_input_files_5009", message: "Cannot find the common subdirectory path for the input files." }, + Cannot_read_file_0_Colon_1: { code: 5012, category: ts.DiagnosticCategory.Error, key: "Cannot_read_file_0_Colon_1_5012", message: "Cannot read file '{0}': {1}" }, + Unsupported_file_encoding: { code: 5013, category: ts.DiagnosticCategory.Error, key: "Unsupported_file_encoding_5013", message: "Unsupported file encoding." }, + Failed_to_parse_file_0_Colon_1: { code: 5014, category: ts.DiagnosticCategory.Error, key: "Failed_to_parse_file_0_Colon_1_5014", message: "Failed to parse file '{0}': {1}." }, + Unknown_compiler_option_0: { code: 5023, category: ts.DiagnosticCategory.Error, key: "Unknown_compiler_option_0_5023", message: "Unknown compiler option '{0}'." }, + Compiler_option_0_requires_a_value_of_type_1: { code: 5024, category: ts.DiagnosticCategory.Error, key: "Compiler_option_0_requires_a_value_of_type_1_5024", message: "Compiler option '{0}' requires a value of type {1}." }, + Could_not_write_file_0_Colon_1: { code: 5033, category: ts.DiagnosticCategory.Error, key: "Could_not_write_file_0_Colon_1_5033", message: "Could not write file '{0}': {1}" }, + Option_project_cannot_be_mixed_with_source_files_on_a_command_line: { code: 5042, category: ts.DiagnosticCategory.Error, key: "Option_project_cannot_be_mixed_with_source_files_on_a_command_line_5042", message: "Option 'project' cannot be mixed with source files on a command line." }, + Option_isolatedModules_can_only_be_used_when_either_option_module_is_provided_or_option_target_is_ES2015_or_higher: { code: 5047, category: ts.DiagnosticCategory.Error, key: "Option_isolatedModules_can_only_be_used_when_either_option_module_is_provided_or_option_target_is_ES_5047", message: "Option 'isolatedModules' can only be used when either option '--module' is provided or option 'target' is 'ES2015' or higher." }, + Option_inlineSources_can_only_be_used_when_either_option_inlineSourceMap_or_option_sourceMap_is_provided: { code: 5051, category: ts.DiagnosticCategory.Error, key: "Option_inlineSources_can_only_be_used_when_either_option_inlineSourceMap_or_option_sourceMap_is_prov_5051", message: "Option 'inlineSources' can only be used when either option '--inlineSourceMap' or option '--sourceMap' is provided." }, + Option_0_cannot_be_specified_without_specifying_option_1: { code: 5052, category: ts.DiagnosticCategory.Error, key: "Option_0_cannot_be_specified_without_specifying_option_1_5052", message: "Option '{0}' cannot be specified without specifying option '{1}'." }, + Option_0_cannot_be_specified_with_option_1: { code: 5053, category: ts.DiagnosticCategory.Error, key: "Option_0_cannot_be_specified_with_option_1_5053", message: "Option '{0}' cannot be specified with option '{1}'." }, + A_tsconfig_json_file_is_already_defined_at_Colon_0: { code: 5054, category: ts.DiagnosticCategory.Error, key: "A_tsconfig_json_file_is_already_defined_at_Colon_0_5054", message: "A 'tsconfig.json' file is already defined at: '{0}'." }, + Concatenate_and_emit_output_to_single_file: { code: 6001, category: ts.DiagnosticCategory.Message, key: "Concatenate_and_emit_output_to_single_file_6001", message: "Concatenate and emit output to single file." }, + Generates_corresponding_d_ts_file: { code: 6002, category: ts.DiagnosticCategory.Message, key: "Generates_corresponding_d_ts_file_6002", message: "Generates corresponding '.d.ts' file." }, + Specifies_the_location_where_debugger_should_locate_map_files_instead_of_generated_locations: { code: 6003, category: ts.DiagnosticCategory.Message, key: "Specifies_the_location_where_debugger_should_locate_map_files_instead_of_generated_locations_6003", message: "Specifies the location where debugger should locate map files instead of generated locations." }, + Specifies_the_location_where_debugger_should_locate_TypeScript_files_instead_of_source_locations: { code: 6004, category: ts.DiagnosticCategory.Message, key: "Specifies_the_location_where_debugger_should_locate_TypeScript_files_instead_of_source_locations_6004", message: "Specifies the location where debugger should locate TypeScript files instead of source locations." }, + Watch_input_files: { code: 6005, category: ts.DiagnosticCategory.Message, key: "Watch_input_files_6005", message: "Watch input files." }, + Redirect_output_structure_to_the_directory: { code: 6006, category: ts.DiagnosticCategory.Message, key: "Redirect_output_structure_to_the_directory_6006", message: "Redirect output structure to the directory." }, + Do_not_erase_const_enum_declarations_in_generated_code: { code: 6007, category: ts.DiagnosticCategory.Message, key: "Do_not_erase_const_enum_declarations_in_generated_code_6007", message: "Do not erase const enum declarations in generated code." }, + Do_not_emit_outputs_if_any_errors_were_reported: { code: 6008, category: ts.DiagnosticCategory.Message, key: "Do_not_emit_outputs_if_any_errors_were_reported_6008", message: "Do not emit outputs if any errors were reported." }, + Do_not_emit_comments_to_output: { code: 6009, category: ts.DiagnosticCategory.Message, key: "Do_not_emit_comments_to_output_6009", message: "Do not emit comments to output." }, + Do_not_emit_outputs: { code: 6010, category: ts.DiagnosticCategory.Message, key: "Do_not_emit_outputs_6010", message: "Do not emit outputs." }, + Specify_ECMAScript_target_version_Colon_ES3_default_ES5_or_ES2015_experimental: { code: 6015, category: ts.DiagnosticCategory.Message, key: "Specify_ECMAScript_target_version_Colon_ES3_default_ES5_or_ES2015_experimental_6015", message: "Specify ECMAScript target version: 'ES3' (default), 'ES5', or 'ES2015' (experimental)" }, + Specify_module_code_generation_Colon_commonjs_amd_system_umd_or_es2015: { code: 6016, category: ts.DiagnosticCategory.Message, key: "Specify_module_code_generation_Colon_commonjs_amd_system_umd_or_es2015_6016", message: "Specify module code generation: 'commonjs', 'amd', 'system', 'umd' or 'es2015'" }, + Print_this_message: { code: 6017, category: ts.DiagnosticCategory.Message, key: "Print_this_message_6017", message: "Print this message." }, + Print_the_compiler_s_version: { code: 6019, category: ts.DiagnosticCategory.Message, key: "Print_the_compiler_s_version_6019", message: "Print the compiler's version." }, + Compile_the_project_in_the_given_directory: { code: 6020, category: ts.DiagnosticCategory.Message, key: "Compile_the_project_in_the_given_directory_6020", message: "Compile the project in the given directory." }, + Syntax_Colon_0: { code: 6023, category: ts.DiagnosticCategory.Message, key: "Syntax_Colon_0_6023", message: "Syntax: {0}" }, + options: { code: 6024, category: ts.DiagnosticCategory.Message, key: "options_6024", message: "options" }, + file: { code: 6025, category: ts.DiagnosticCategory.Message, key: "file_6025", message: "file" }, + Examples_Colon_0: { code: 6026, category: ts.DiagnosticCategory.Message, key: "Examples_Colon_0_6026", message: "Examples: {0}" }, + Options_Colon: { code: 6027, category: ts.DiagnosticCategory.Message, key: "Options_Colon_6027", message: "Options:" }, + Version_0: { code: 6029, category: ts.DiagnosticCategory.Message, key: "Version_0_6029", message: "Version {0}" }, + Insert_command_line_options_and_files_from_a_file: { code: 6030, category: ts.DiagnosticCategory.Message, key: "Insert_command_line_options_and_files_from_a_file_6030", message: "Insert command line options and files from a file." }, + File_change_detected_Starting_incremental_compilation: { code: 6032, category: ts.DiagnosticCategory.Message, key: "File_change_detected_Starting_incremental_compilation_6032", message: "File change detected. Starting incremental compilation..." }, + KIND: { code: 6034, category: ts.DiagnosticCategory.Message, key: "KIND_6034", message: "KIND" }, + FILE: { code: 6035, category: ts.DiagnosticCategory.Message, key: "FILE_6035", message: "FILE" }, + VERSION: { code: 6036, category: ts.DiagnosticCategory.Message, key: "VERSION_6036", message: "VERSION" }, + LOCATION: { code: 6037, category: ts.DiagnosticCategory.Message, key: "LOCATION_6037", message: "LOCATION" }, + DIRECTORY: { code: 6038, category: ts.DiagnosticCategory.Message, key: "DIRECTORY_6038", message: "DIRECTORY" }, + Compilation_complete_Watching_for_file_changes: { code: 6042, category: ts.DiagnosticCategory.Message, key: "Compilation_complete_Watching_for_file_changes_6042", message: "Compilation complete. Watching for file changes." }, + Generates_corresponding_map_file: { code: 6043, category: ts.DiagnosticCategory.Message, key: "Generates_corresponding_map_file_6043", message: "Generates corresponding '.map' file." }, + Compiler_option_0_expects_an_argument: { code: 6044, category: ts.DiagnosticCategory.Error, key: "Compiler_option_0_expects_an_argument_6044", message: "Compiler option '{0}' expects an argument." }, + Unterminated_quoted_string_in_response_file_0: { code: 6045, category: ts.DiagnosticCategory.Error, key: "Unterminated_quoted_string_in_response_file_0_6045", message: "Unterminated quoted string in response file '{0}'." }, + Argument_for_module_option_must_be_commonjs_amd_system_umd_or_es2015: { code: 6046, category: ts.DiagnosticCategory.Error, key: "Argument_for_module_option_must_be_commonjs_amd_system_umd_or_es2015_6046", message: "Argument for '--module' option must be 'commonjs', 'amd', 'system', 'umd', or 'es2015'." }, + Argument_for_target_option_must_be_ES3_ES5_or_ES2015: { code: 6047, category: ts.DiagnosticCategory.Error, key: "Argument_for_target_option_must_be_ES3_ES5_or_ES2015_6047", message: "Argument for '--target' option must be 'ES3', 'ES5', or 'ES2015'." }, + Locale_must_be_of_the_form_language_or_language_territory_For_example_0_or_1: { code: 6048, category: ts.DiagnosticCategory.Error, key: "Locale_must_be_of_the_form_language_or_language_territory_For_example_0_or_1_6048", message: "Locale must be of the form or -. For example '{0}' or '{1}'." }, + Unsupported_locale_0: { code: 6049, category: ts.DiagnosticCategory.Error, key: "Unsupported_locale_0_6049", message: "Unsupported locale '{0}'." }, + Unable_to_open_file_0: { code: 6050, category: ts.DiagnosticCategory.Error, key: "Unable_to_open_file_0_6050", message: "Unable to open file '{0}'." }, + Corrupted_locale_file_0: { code: 6051, category: ts.DiagnosticCategory.Error, key: "Corrupted_locale_file_0_6051", message: "Corrupted locale file {0}." }, + Raise_error_on_expressions_and_declarations_with_an_implied_any_type: { code: 6052, category: ts.DiagnosticCategory.Message, key: "Raise_error_on_expressions_and_declarations_with_an_implied_any_type_6052", message: "Raise error on expressions and declarations with an implied 'any' type." }, + File_0_not_found: { code: 6053, category: ts.DiagnosticCategory.Error, key: "File_0_not_found_6053", message: "File '{0}' not found." }, + File_0_has_unsupported_extension_The_only_supported_extensions_are_1: { code: 6054, category: ts.DiagnosticCategory.Error, key: "File_0_has_unsupported_extension_The_only_supported_extensions_are_1_6054", message: "File '{0}' has unsupported extension. The only supported extensions are {1}." }, + Suppress_noImplicitAny_errors_for_indexing_objects_lacking_index_signatures: { code: 6055, category: ts.DiagnosticCategory.Message, key: "Suppress_noImplicitAny_errors_for_indexing_objects_lacking_index_signatures_6055", message: "Suppress noImplicitAny errors for indexing objects lacking index signatures." }, + Do_not_emit_declarations_for_code_that_has_an_internal_annotation: { code: 6056, category: ts.DiagnosticCategory.Message, key: "Do_not_emit_declarations_for_code_that_has_an_internal_annotation_6056", message: "Do not emit declarations for code that has an '@internal' annotation." }, + Specifies_the_root_directory_of_input_files_Use_to_control_the_output_directory_structure_with_outDir: { code: 6058, category: ts.DiagnosticCategory.Message, key: "Specifies_the_root_directory_of_input_files_Use_to_control_the_output_directory_structure_with_outDi_6058", message: "Specifies the root directory of input files. Use to control the output directory structure with --outDir." }, + File_0_is_not_under_rootDir_1_rootDir_is_expected_to_contain_all_source_files: { code: 6059, category: ts.DiagnosticCategory.Error, key: "File_0_is_not_under_rootDir_1_rootDir_is_expected_to_contain_all_source_files_6059", message: "File '{0}' is not under 'rootDir' '{1}'. 'rootDir' is expected to contain all source files." }, + Specifies_the_end_of_line_sequence_to_be_used_when_emitting_files_Colon_CRLF_dos_or_LF_unix: { code: 6060, category: ts.DiagnosticCategory.Message, key: "Specifies_the_end_of_line_sequence_to_be_used_when_emitting_files_Colon_CRLF_dos_or_LF_unix_6060", message: "Specifies the end of line sequence to be used when emitting files: 'CRLF' (dos) or 'LF' (unix)." }, + NEWLINE: { code: 6061, category: ts.DiagnosticCategory.Message, key: "NEWLINE_6061", message: "NEWLINE" }, + Argument_for_newLine_option_must_be_CRLF_or_LF: { code: 6062, category: ts.DiagnosticCategory.Error, key: "Argument_for_newLine_option_must_be_CRLF_or_LF_6062", message: "Argument for '--newLine' option must be 'CRLF' or 'LF'." }, + Argument_for_moduleResolution_option_must_be_node_or_classic: { code: 6063, category: ts.DiagnosticCategory.Error, key: "Argument_for_moduleResolution_option_must_be_node_or_classic_6063", message: "Argument for '--moduleResolution' option must be 'node' or 'classic'." }, + Specify_JSX_code_generation_Colon_preserve_or_react: { code: 6080, category: ts.DiagnosticCategory.Message, key: "Specify_JSX_code_generation_Colon_preserve_or_react_6080", message: "Specify JSX code generation: 'preserve' or 'react'" }, + Argument_for_jsx_must_be_preserve_or_react: { code: 6081, category: ts.DiagnosticCategory.Message, key: "Argument_for_jsx_must_be_preserve_or_react_6081", message: "Argument for '--jsx' must be 'preserve' or 'react'." }, + Enables_experimental_support_for_ES7_decorators: { code: 6065, category: ts.DiagnosticCategory.Message, key: "Enables_experimental_support_for_ES7_decorators_6065", message: "Enables experimental support for ES7 decorators." }, + Enables_experimental_support_for_emitting_type_metadata_for_decorators: { code: 6066, category: ts.DiagnosticCategory.Message, key: "Enables_experimental_support_for_emitting_type_metadata_for_decorators_6066", message: "Enables experimental support for emitting type metadata for decorators." }, + Enables_experimental_support_for_ES7_async_functions: { code: 6068, category: ts.DiagnosticCategory.Message, key: "Enables_experimental_support_for_ES7_async_functions_6068", message: "Enables experimental support for ES7 async functions." }, + Specifies_module_resolution_strategy_Colon_node_Node_js_or_classic_TypeScript_pre_1_6: { code: 6069, category: ts.DiagnosticCategory.Message, key: "Specifies_module_resolution_strategy_Colon_node_Node_js_or_classic_TypeScript_pre_1_6_6069", message: "Specifies module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6)." }, + Initializes_a_TypeScript_project_and_creates_a_tsconfig_json_file: { code: 6070, category: ts.DiagnosticCategory.Message, key: "Initializes_a_TypeScript_project_and_creates_a_tsconfig_json_file_6070", message: "Initializes a TypeScript project and creates a tsconfig.json file." }, + Successfully_created_a_tsconfig_json_file: { code: 6071, category: ts.DiagnosticCategory.Message, key: "Successfully_created_a_tsconfig_json_file_6071", message: "Successfully created a tsconfig.json file." }, + Suppress_excess_property_checks_for_object_literals: { code: 6072, category: ts.DiagnosticCategory.Message, key: "Suppress_excess_property_checks_for_object_literals_6072", message: "Suppress excess property checks for object literals." }, + Disallow_inconsistently_cased_references_to_the_same_file: { code: 6073, category: ts.DiagnosticCategory.Message, key: "Disallow_inconsistently_cased_references_to_the_same_file_6073", message: "Disallow inconsistently-cased references to the same 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." }, + new_expression_whose_target_lacks_a_construct_signature_implicitly_has_an_any_type: { code: 7009, category: ts.DiagnosticCategory.Error, key: "new_expression_whose_target_lacks_a_construct_signature_implicitly_has_an_any_type_7009", message: "'new' expression, whose target lacks a construct signature, implicitly has an 'any' type." }, + _0_which_lacks_return_type_annotation_implicitly_has_an_1_return_type: { code: 7010, category: ts.DiagnosticCategory.Error, key: "_0_which_lacks_return_type_annotation_implicitly_has_an_1_return_type_7010", message: "'{0}', which lacks return-type annotation, implicitly has an '{1}' return type." }, + Function_expression_which_lacks_return_type_annotation_implicitly_has_an_0_return_type: { code: 7011, category: ts.DiagnosticCategory.Error, key: "Function_expression_which_lacks_return_type_annotation_implicitly_has_an_0_return_type_7011", message: "Function expression, which lacks return-type annotation, implicitly has an '{0}' return type." }, + Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type: { code: 7013, category: ts.DiagnosticCategory.Error, key: "Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type_7013", message: "Construct signature, which lacks return-type annotation, implicitly has an 'any' return type." }, + Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_type_annotation: { code: 7016, category: ts.DiagnosticCategory.Error, key: "Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_type_annotation_7016", message: "Property '{0}' implicitly has type 'any', because its 'set' accessor lacks a type annotation." }, + Index_signature_of_object_type_implicitly_has_an_any_type: { code: 7017, category: ts.DiagnosticCategory.Error, key: "Index_signature_of_object_type_implicitly_has_an_any_type_7017", message: "Index signature of object type implicitly has an 'any' type." }, + Object_literal_s_property_0_implicitly_has_an_1_type: { code: 7018, category: ts.DiagnosticCategory.Error, key: "Object_literal_s_property_0_implicitly_has_an_1_type_7018", message: "Object literal's property '{0}' implicitly has an '{1}' type." }, + Rest_parameter_0_implicitly_has_an_any_type: { code: 7019, category: ts.DiagnosticCategory.Error, key: "Rest_parameter_0_implicitly_has_an_any_type_7019", message: "Rest parameter '{0}' implicitly has an 'any[]' type." }, + Call_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type: { code: 7020, category: ts.DiagnosticCategory.Error, key: "Call_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type_7020", message: "Call signature, which lacks return-type annotation, implicitly has an 'any' return type." }, + _0_implicitly_has_type_any_because_it_does_not_have_a_type_annotation_and_is_referenced_directly_or_indirectly_in_its_own_initializer: { code: 7022, category: ts.DiagnosticCategory.Error, key: "_0_implicitly_has_type_any_because_it_does_not_have_a_type_annotation_and_is_referenced_directly_or__7022", message: "'{0}' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer." }, + _0_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions: { code: 7023, category: ts.DiagnosticCategory.Error, key: "_0_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_reference_7023", message: "'{0}' implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions." }, + Function_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions: { code: 7024, category: ts.DiagnosticCategory.Error, key: "Function_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_ref_7024", message: "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." }, + Generator_implicitly_has_type_0_because_it_does_not_yield_any_values_Consider_supplying_a_return_type: { code: 7025, category: ts.DiagnosticCategory.Error, key: "Generator_implicitly_has_type_0_because_it_does_not_yield_any_values_Consider_supplying_a_return_typ_7025", message: "Generator implicitly has type '{0}' because it does not yield any values. Consider supplying a return type." }, + JSX_element_implicitly_has_type_any_because_no_interface_JSX_0_exists: { code: 7026, category: ts.DiagnosticCategory.Error, key: "JSX_element_implicitly_has_type_any_because_no_interface_JSX_0_exists_7026", message: "JSX element implicitly has type 'any' because no interface 'JSX.{0}' exists" }, + 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." }, + export_can_only_be_used_in_a_ts_file: { code: 8003, category: ts.DiagnosticCategory.Error, key: "export_can_only_be_used_in_a_ts_file_8003", message: "'export=' can only be used in a .ts file." }, + type_parameter_declarations_can_only_be_used_in_a_ts_file: { code: 8004, category: ts.DiagnosticCategory.Error, key: "type_parameter_declarations_can_only_be_used_in_a_ts_file_8004", message: "'type parameter declarations' can only be used in a .ts file." }, + implements_clauses_can_only_be_used_in_a_ts_file: { code: 8005, category: ts.DiagnosticCategory.Error, key: "implements_clauses_can_only_be_used_in_a_ts_file_8005", message: "'implements clauses' can only be used in a .ts file." }, + interface_declarations_can_only_be_used_in_a_ts_file: { code: 8006, category: ts.DiagnosticCategory.Error, key: "interface_declarations_can_only_be_used_in_a_ts_file_8006", message: "'interface declarations' can only be used in a .ts file." }, + module_declarations_can_only_be_used_in_a_ts_file: { code: 8007, category: ts.DiagnosticCategory.Error, key: "module_declarations_can_only_be_used_in_a_ts_file_8007", message: "'module declarations' can only be used in a .ts file." }, + type_aliases_can_only_be_used_in_a_ts_file: { code: 8008, category: ts.DiagnosticCategory.Error, key: "type_aliases_can_only_be_used_in_a_ts_file_8008", message: "'type aliases' can only be used in a .ts file." }, + _0_can_only_be_used_in_a_ts_file: { code: 8009, category: ts.DiagnosticCategory.Error, key: "_0_can_only_be_used_in_a_ts_file_8009", message: "'{0}' can only be used in a .ts file." }, + types_can_only_be_used_in_a_ts_file: { code: 8010, category: ts.DiagnosticCategory.Error, key: "types_can_only_be_used_in_a_ts_file_8010", message: "'types' can only be used in a .ts file." }, + type_arguments_can_only_be_used_in_a_ts_file: { code: 8011, category: ts.DiagnosticCategory.Error, key: "type_arguments_can_only_be_used_in_a_ts_file_8011", message: "'type arguments' can only be used in a .ts file." }, + parameter_modifiers_can_only_be_used_in_a_ts_file: { code: 8012, category: ts.DiagnosticCategory.Error, key: "parameter_modifiers_can_only_be_used_in_a_ts_file_8012", message: "'parameter modifiers' can only be used in a .ts file." }, + property_declarations_can_only_be_used_in_a_ts_file: { code: 8014, category: ts.DiagnosticCategory.Error, key: "property_declarations_can_only_be_used_in_a_ts_file_8014", message: "'property declarations' can only be used in a .ts file." }, + enum_declarations_can_only_be_used_in_a_ts_file: { code: 8015, category: ts.DiagnosticCategory.Error, key: "enum_declarations_can_only_be_used_in_a_ts_file_8015", message: "'enum declarations' can only be used in a .ts file." }, + type_assertion_expressions_can_only_be_used_in_a_ts_file: { code: 8016, category: ts.DiagnosticCategory.Error, key: "type_assertion_expressions_can_only_be_used_in_a_ts_file_8016", message: "'type assertion expressions' can only be used in a .ts file." }, + decorators_can_only_be_used_in_a_ts_file: { code: 8017, category: ts.DiagnosticCategory.Error, key: "decorators_can_only_be_used_in_a_ts_file_8017", message: "'decorators' can only be used in a .ts file." }, + Only_identifiers_Slashqualified_names_with_optional_type_arguments_are_currently_supported_in_a_class_extends_clauses: { code: 9002, category: ts.DiagnosticCategory.Error, key: "Only_identifiers_Slashqualified_names_with_optional_type_arguments_are_currently_supported_in_a_clas_9002", message: "Only identifiers/qualified-names with optional type arguments are currently supported in a class 'extends' clauses." }, + class_expressions_are_not_currently_supported: { code: 9003, category: ts.DiagnosticCategory.Error, key: "class_expressions_are_not_currently_supported_9003", message: "'class' expressions are not currently supported." }, + JSX_attributes_must_only_be_assigned_a_non_empty_expression: { code: 17000, category: ts.DiagnosticCategory.Error, key: "JSX_attributes_must_only_be_assigned_a_non_empty_expression_17000", message: "JSX attributes must only be assigned a non-empty 'expression'." }, + JSX_elements_cannot_have_multiple_attributes_with_the_same_name: { code: 17001, category: ts.DiagnosticCategory.Error, key: "JSX_elements_cannot_have_multiple_attributes_with_the_same_name_17001", message: "JSX elements cannot have multiple attributes with the same name." }, + Expected_corresponding_JSX_closing_tag_for_0: { code: 17002, category: ts.DiagnosticCategory.Error, key: "Expected_corresponding_JSX_closing_tag_for_0_17002", message: "Expected corresponding JSX closing tag for '{0}'." }, + JSX_attribute_expected: { code: 17003, category: ts.DiagnosticCategory.Error, key: "JSX_attribute_expected_17003", message: "JSX attribute expected." }, + Cannot_use_JSX_unless_the_jsx_flag_is_provided: { code: 17004, category: ts.DiagnosticCategory.Error, key: "Cannot_use_JSX_unless_the_jsx_flag_is_provided_17004", message: "Cannot use JSX unless the '--jsx' flag is provided." }, + A_constructor_cannot_contain_a_super_call_when_its_class_extends_null: { code: 17005, category: ts.DiagnosticCategory.Error, key: "A_constructor_cannot_contain_a_super_call_when_its_class_extends_null_17005", message: "A constructor cannot contain a 'super' call when its class extends 'null'" }, + An_unary_expression_with_the_0_operator_is_not_allowed_in_the_left_hand_side_of_an_exponentiation_expression_Consider_enclosing_the_expression_in_parentheses: { code: 17006, category: ts.DiagnosticCategory.Error, key: "An_unary_expression_with_the_0_operator_is_not_allowed_in_the_left_hand_side_of_an_exponentiation_ex_17006", message: "An unary expression with the '{0}' operator is not allowed in the left-hand side of an exponentiation expression. Consider enclosing the expression in parentheses." }, + A_type_assertion_expression_is_not_allowed_in_the_left_hand_side_of_an_exponentiation_expression_Consider_enclosing_the_expression_in_parentheses: { code: 17007, category: ts.DiagnosticCategory.Error, key: "A_type_assertion_expression_is_not_allowed_in_the_left_hand_side_of_an_exponentiation_expression_Con_17007", message: "A type assertion expression is not allowed in the left-hand side of an exponentiation expression. Consider enclosing the expression in parentheses." } + }; +})(ts || (ts = {})); +/// +/// +var ts; +(function (ts) { + /* @internal */ + function tokenIsIdentifierOrKeyword(token) { + return token >= 69 /* Identifier */; + } + ts.tokenIsIdentifierOrKeyword = tokenIsIdentifierOrKeyword; + var textToToken = { + "abstract": 115 /* AbstractKeyword */, + "any": 117 /* AnyKeyword */, + "as": 116 /* AsKeyword */, + "boolean": 120 /* BooleanKeyword */, + "break": 70 /* BreakKeyword */, + "case": 71 /* CaseKeyword */, + "catch": 72 /* CatchKeyword */, + "class": 73 /* ClassKeyword */, + "continue": 75 /* ContinueKeyword */, + "const": 74 /* ConstKeyword */, + "constructor": 121 /* ConstructorKeyword */, + "debugger": 76 /* DebuggerKeyword */, + "declare": 122 /* DeclareKeyword */, + "default": 77 /* DefaultKeyword */, + "delete": 78 /* DeleteKeyword */, + "do": 79 /* DoKeyword */, + "else": 80 /* ElseKeyword */, + "enum": 81 /* EnumKeyword */, + "export": 82 /* ExportKeyword */, + "extends": 83 /* ExtendsKeyword */, + "false": 84 /* FalseKeyword */, + "finally": 85 /* FinallyKeyword */, + "for": 86 /* ForKeyword */, + "from": 133 /* FromKeyword */, + "function": 87 /* FunctionKeyword */, + "get": 123 /* GetKeyword */, + "if": 88 /* IfKeyword */, + "implements": 106 /* ImplementsKeyword */, + "import": 89 /* ImportKeyword */, + "in": 90 /* InKeyword */, + "instanceof": 91 /* InstanceOfKeyword */, + "interface": 107 /* InterfaceKeyword */, + "is": 124 /* IsKeyword */, + "let": 108 /* LetKeyword */, + "module": 125 /* ModuleKeyword */, + "namespace": 126 /* NamespaceKeyword */, + "new": 92 /* NewKeyword */, + "null": 93 /* NullKeyword */, + "number": 128 /* NumberKeyword */, + "package": 109 /* PackageKeyword */, + "private": 110 /* PrivateKeyword */, + "protected": 111 /* ProtectedKeyword */, + "public": 112 /* PublicKeyword */, + "require": 127 /* RequireKeyword */, + "return": 94 /* ReturnKeyword */, + "set": 129 /* SetKeyword */, + "static": 113 /* StaticKeyword */, + "string": 130 /* StringKeyword */, + "super": 95 /* SuperKeyword */, + "switch": 96 /* SwitchKeyword */, + "symbol": 131 /* SymbolKeyword */, + "this": 97 /* ThisKeyword */, + "throw": 98 /* ThrowKeyword */, + "true": 99 /* TrueKeyword */, + "try": 100 /* TryKeyword */, + "type": 132 /* TypeKeyword */, + "typeof": 101 /* TypeOfKeyword */, + "var": 102 /* VarKeyword */, + "void": 103 /* VoidKeyword */, + "while": 104 /* WhileKeyword */, + "with": 105 /* WithKeyword */, + "yield": 114 /* YieldKeyword */, + "async": 118 /* AsyncKeyword */, + "await": 119 /* AwaitKeyword */, + "of": 134 /* OfKeyword */, + "{": 15 /* OpenBraceToken */, + "}": 16 /* CloseBraceToken */, + "(": 17 /* OpenParenToken */, + ")": 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 */ + }; + /* + As per ECMAScript Language Specification 3th Edition, Section 7.6: Identifiers + IdentifierStart :: + Can contain Unicode 3.0.0 categories: + Uppercase letter (Lu), + Lowercase letter (Ll), + Titlecase letter (Lt), + Modifier letter (Lm), + Other letter (Lo), or + Letter number (Nl). + IdentifierPart :: = + Can contain IdentifierStart + Unicode 3.0.0 categories: + Non-spacing mark (Mn), + Combining spacing mark (Mc), + Decimal number (Nd), or + Connector punctuation (Pc). + + Codepoint ranges for ES3 Identifiers are extracted from the Unicode 3.0.0 specification at: + http://www.unicode.org/Public/3.0-Update/UnicodeData-3.0.0.txt + */ + 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,]; + /* + As per ECMAScript Language Specification 5th Edition, Section 7.6: ISyntaxToken Names and Identifiers + IdentifierStart :: + Can contain Unicode 6.2 categories: + Uppercase letter (Lu), + Lowercase letter (Ll), + Titlecase letter (Lt), + Modifier letter (Lm), + Other letter (Lo), or + Letter number (Nl). + IdentifierPart :: + Can contain IdentifierStart + Unicode 6.2 categories: + Non-spacing mark (Mn), + Combining spacing mark (Mc), + Decimal number (Nd), + Connector punctuation (Pc), + , or + . + + Codepoint ranges for ES5 Identifiers are extracted from the Unicode 6.2 specification at: + http://www.unicode.org/Public/6.2.0/ucd/UnicodeData.txt + */ + 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) { + // Bail out quickly if it couldn't possibly be in the map. + if (code < map[0]) { + return false; + } + // Perform binary search in one of the Unicode range maps + var lo = 0; + var hi = map.length; + var mid; + while (lo + 1 < hi) { + mid = lo + (hi - lo) / 2; + // mid has to be even to catch a range's beginning + 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; + } + /* @internal */ function isUnicodeIdentifierStart(code, languageVersion) { + return languageVersion >= 1 /* ES5 */ ? + lookupInUnicodeMap(code, unicodeES5IdentifierStart) : + lookupInUnicodeMap(code, unicodeES3IdentifierStart); + } + ts.isUnicodeIdentifierStart = isUnicodeIdentifierStart; + function isUnicodeIdentifierPart(code, languageVersion) { + return languageVersion >= 1 /* ES5 */ ? + lookupInUnicodeMap(code, unicodeES5IdentifierPart) : + lookupInUnicodeMap(code, unicodeES3IdentifierPart); + } + function makeReverseMap(source) { + var result = []; + for (var name_4 in source) { + if (source.hasOwnProperty(name_4)) { + result[source[name_4]] = name_4; + } + } + return result; + } + var tokenStrings = makeReverseMap(textToToken); + function tokenToString(t) { + return tokenStrings[t]; + } + ts.tokenToString = tokenToString; + /* @internal */ + function stringToToken(s) { + return textToToken[s]; + } + ts.stringToToken = stringToToken; + /* @internal */ + function computeLineStarts(text) { + var result = new Array(); + var pos = 0; + var lineStart = 0; + while (pos < text.length) { + var ch = text.charCodeAt(pos++); + switch (ch) { + case 13 /* carriageReturn */: + if (text.charCodeAt(pos) === 10 /* lineFeed */) { + pos++; + } + case 10 /* lineFeed */: + result.push(lineStart); + lineStart = pos; + break; + default: + if (ch > 127 /* maxAsciiCharacter */ && 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; + /* @internal */ + function computePositionOfLineAndCharacter(lineStarts, line, character) { + ts.Debug.assert(line >= 0 && line < lineStarts.length); + return lineStarts[line] + character; + } + ts.computePositionOfLineAndCharacter = computePositionOfLineAndCharacter; + /* @internal */ + function getLineStarts(sourceFile) { + return sourceFile.lineMap || (sourceFile.lineMap = computeLineStarts(sourceFile.text)); + } + ts.getLineStarts = getLineStarts; + /* @internal */ + /** + * We assume the first line starts at position 0 and 'position' is non-negative. + */ + function computeLineAndCharacterOfPosition(lineStarts, position) { + var lineNumber = ts.binarySearch(lineStarts, position); + if (lineNumber < 0) { + // If the actual position was not found, + // the binary search returns the 2's-complement of the next line start + // e.g. if the line starts at [5, 10, 23, 80] and the position requested was 20 + // then the search will return -2. + // + // We want the index of the previous line start, so we subtract 1. + // Review 2's-complement if this is confusing. + 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) { + // Note: nextLine is in the Zs space, and should be considered to be a whitespace. + // It is explicitly not a line-break as it isn't in the exact set specified by EcmaScript. + return ch === 32 /* space */ || + ch === 9 /* tab */ || + ch === 11 /* verticalTab */ || + ch === 12 /* formFeed */ || + ch === 160 /* nonBreakingSpace */ || + ch === 133 /* nextLine */ || + ch === 5760 /* ogham */ || + ch >= 8192 /* enQuad */ && ch <= 8203 /* zeroWidthSpace */ || + ch === 8239 /* narrowNoBreakSpace */ || + ch === 8287 /* mathematicalSpace */ || + ch === 12288 /* ideographicSpace */ || + ch === 65279 /* byteOrderMark */; + } + ts.isWhiteSpace = isWhiteSpace; + function isLineBreak(ch) { + // ES5 7.3: + // The ECMAScript line terminator characters are listed in Table 3. + // Table 3: Line Terminator Characters + // Code Unit Value Name Formal Name + // \u000A Line Feed + // \u000D Carriage Return + // \u2028 Line separator + // \u2029 Paragraph separator + // Only the characters in Table 3 are treated as line terminators. Other new line or line + // breaking characters are treated as white space but not as line terminators. + return ch === 10 /* lineFeed */ || + ch === 13 /* carriageReturn */ || + ch === 8232 /* lineSeparator */ || + ch === 8233 /* paragraphSeparator */; + } + ts.isLineBreak = isLineBreak; + function isDigit(ch) { + return ch >= 48 /* _0 */ && ch <= 57 /* _9 */; + } + /* @internal */ + function isOctalDigit(ch) { + return ch >= 48 /* _0 */ && ch <= 55 /* _7 */; + } + ts.isOctalDigit = isOctalDigit; + function couldStartTrivia(text, pos) { + // Keep in sync with skipTrivia + var ch = text.charCodeAt(pos); + switch (ch) { + case 13 /* carriageReturn */: + case 10 /* lineFeed */: + case 9 /* tab */: + case 11 /* verticalTab */: + case 12 /* formFeed */: + case 32 /* space */: + case 47 /* slash */: + // starts of normal trivia + case 60 /* lessThan */: + case 61 /* equals */: + case 62 /* greaterThan */: + // Starts of conflict marker trivia + return true; + case 35 /* hash */: + // Only if its the beginning can we have #! trivia + return pos === 0; + default: + return ch > 127 /* maxAsciiCharacter */; + } + } + ts.couldStartTrivia = couldStartTrivia; + /* @internal */ + function skipTrivia(text, pos, stopAfterLineBreak) { + // Keep in sync with couldStartTrivia + while (true) { + var ch = text.charCodeAt(pos); + switch (ch) { + case 13 /* carriageReturn */: + if (text.charCodeAt(pos + 1) === 10 /* lineFeed */) { + pos++; + } + case 10 /* lineFeed */: + pos++; + if (stopAfterLineBreak) { + return pos; + } + continue; + case 9 /* tab */: + case 11 /* verticalTab */: + case 12 /* formFeed */: + case 32 /* space */: + pos++; + continue; + case 47 /* slash */: + if (text.charCodeAt(pos + 1) === 47 /* slash */) { + pos += 2; + while (pos < text.length) { + if (isLineBreak(text.charCodeAt(pos))) { + break; + } + pos++; + } + continue; + } + if (text.charCodeAt(pos + 1) === 42 /* asterisk */) { + pos += 2; + while (pos < text.length) { + if (text.charCodeAt(pos) === 42 /* asterisk */ && text.charCodeAt(pos + 1) === 47 /* slash */) { + pos += 2; + break; + } + pos++; + } + continue; + } + break; + case 60 /* lessThan */: + case 61 /* equals */: + case 62 /* greaterThan */: + if (isConflictMarkerTrivia(text, pos)) { + pos = scanConflictMarkerTrivia(text, pos); + continue; + } + break; + case 35 /* hash */: + if (pos === 0 && isShebangTrivia(text, pos)) { + pos = scanShebangTrivia(text, pos); + continue; + } + break; + default: + if (ch > 127 /* maxAsciiCharacter */ && (isWhiteSpace(ch) || isLineBreak(ch))) { + pos++; + continue; + } + break; + } + return pos; + } + } + ts.skipTrivia = skipTrivia; + // All conflict markers consist of the same character repeated seven times. If it is + // a <<<<<<< or >>>>>>> marker then it is also followd by a space. + var mergeConflictMarkerLength = "<<<<<<<".length; + function isConflictMarkerTrivia(text, pos) { + ts.Debug.assert(pos >= 0); + // Conflict markers must be at the start of a line. + 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 /* equals */ || + text.charCodeAt(pos + mergeConflictMarkerLength) === 32 /* space */; + } + } + 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 /* lessThan */ || ch === 62 /* greaterThan */) { + while (pos < len && !isLineBreak(text.charCodeAt(pos))) { + pos++; + } + } + else { + ts.Debug.assert(ch === 61 /* equals */); + // Consume everything from the start of the mid-conlict marker to the start of the next + // end-conflict marker. + while (pos < len) { + var ch_1 = text.charCodeAt(pos); + if (ch_1 === 62 /* greaterThan */ && isConflictMarkerTrivia(text, pos)) { + break; + } + pos++; + } + } + return pos; + } + var shebangTriviaRegex = /^#!.*/; + function isShebangTrivia(text, pos) { + // Shebangs check must only be done at the start of the file + 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; + } + /** + * Extract comments from text prefixing the token closest following `pos`. + * The return value is an array containing a TextRange for each comment. + * Single-line comment ranges include the beginning '//' characters but not the ending line break. + * Multi - line comment ranges include the beginning '/* and ending '/' characters. + * The return value is undefined if no comments were found. + * @param trailing + * If false, whitespace is skipped until the first line break and comments between that location + * and the next token are returned. + * If true, comments occurring between the given position and the next line break are returned. + */ + function getCommentRanges(text, pos, trailing) { + var result; + var collecting = trailing || pos === 0; + while (true) { + var ch = text.charCodeAt(pos); + switch (ch) { + case 13 /* carriageReturn */: + if (text.charCodeAt(pos + 1) === 10 /* lineFeed */) { + pos++; + } + case 10 /* lineFeed */: + pos++; + if (trailing) { + return result; + } + collecting = true; + if (result && result.length) { + ts.lastOrUndefined(result).hasTrailingNewLine = true; + } + continue; + case 9 /* tab */: + case 11 /* verticalTab */: + case 12 /* formFeed */: + case 32 /* space */: + pos++; + continue; + case 47 /* slash */: + var nextChar = text.charCodeAt(pos + 1); + var hasTrailingNewLine = false; + if (nextChar === 47 /* slash */ || nextChar === 42 /* asterisk */) { + var kind = nextChar === 47 /* slash */ ? 2 /* SingleLineCommentTrivia */ : 3 /* MultiLineCommentTrivia */; + var startPos = pos; + pos += 2; + if (nextChar === 47 /* slash */) { + while (pos < text.length) { + if (isLineBreak(text.charCodeAt(pos))) { + hasTrailingNewLine = true; + break; + } + pos++; + } + } + else { + while (pos < text.length) { + if (text.charCodeAt(pos) === 42 /* asterisk */ && text.charCodeAt(pos + 1) === 47 /* slash */) { + pos += 2; + break; + } + pos++; + } + } + if (collecting) { + if (!result) { + result = []; + } + result.push({ pos: startPos, end: pos, hasTrailingNewLine: hasTrailingNewLine, kind: kind }); + } + continue; + } + break; + default: + if (ch > 127 /* maxAsciiCharacter */ && (isWhiteSpace(ch) || isLineBreak(ch))) { + if (result && result.length && isLineBreak(ch)) { + ts.lastOrUndefined(result).hasTrailingNewLine = true; + } + pos++; + continue; + } + break; + } + return result; + } + } + function getLeadingCommentRanges(text, pos) { + return getCommentRanges(text, pos, /*trailing*/ false); + } + ts.getLeadingCommentRanges = getLeadingCommentRanges; + function getTrailingCommentRanges(text, pos) { + return getCommentRanges(text, pos, /*trailing*/ true); + } + ts.getTrailingCommentRanges = getTrailingCommentRanges; + /** Optionally, get the shebang */ + function getShebang(text) { + return shebangTriviaRegex.test(text) + ? shebangTriviaRegex.exec(text)[0] + : undefined; + } + ts.getShebang = getShebang; + function isIdentifierStart(ch, languageVersion) { + return ch >= 65 /* A */ && ch <= 90 /* Z */ || ch >= 97 /* a */ && ch <= 122 /* z */ || + ch === 36 /* $ */ || ch === 95 /* _ */ || + ch > 127 /* maxAsciiCharacter */ && isUnicodeIdentifierStart(ch, languageVersion); + } + ts.isIdentifierStart = isIdentifierStart; + function isIdentifierPart(ch, languageVersion) { + return ch >= 65 /* A */ && ch <= 90 /* Z */ || ch >= 97 /* a */ && ch <= 122 /* z */ || + ch >= 48 /* _0 */ && ch <= 57 /* _9 */ || ch === 36 /* $ */ || ch === 95 /* _ */ || + ch > 127 /* maxAsciiCharacter */ && isUnicodeIdentifierPart(ch, languageVersion); + } + ts.isIdentifierPart = isIdentifierPart; + // Creates a scanner over a (possibly unspecified) range of a piece of text. + function createScanner(languageVersion, skipTrivia, languageVariant, text, onError, start, length) { + if (languageVariant === void 0) { languageVariant = 0 /* Standard */; } + // Current position (end position of text of current token) + var pos; + // end of text + var end; + // Start position of whitespace before current token + var startPos; + // Start position of text of current token + 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 /* Identifier */ || token > 105 /* LastReservedWord */; }, + isReservedWord: function () { return token >= 70 /* FirstReservedWord */ && token <= 105 /* LastReservedWord */; }, + isUnterminated: function () { return tokenIsUnterminated; }, + reScanGreaterToken: reScanGreaterToken, + reScanSlashToken: reScanSlashToken, + reScanTemplateToken: reScanTemplateToken, + scanJsxIdentifier: scanJsxIdentifier, + reScanJsxToken: reScanJsxToken, + scanJsxToken: scanJsxToken, + scan: scan, + setText: setText, + setScriptTarget: setScriptTarget, + setLanguageVariant: setLanguageVariant, + setOnError: setOnError, + setTextPos: setTextPos, + tryScan: tryScan, + lookAhead: lookAhead + }; + 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 /* dot */) { + pos++; + while (isDigit(text.charCodeAt(pos))) + pos++; + } + var end = pos; + if (text.charCodeAt(pos) === 69 /* E */ || text.charCodeAt(pos) === 101 /* e */) { + pos++; + if (text.charCodeAt(pos) === 43 /* plus */ || text.charCodeAt(pos) === 45 /* minus */) + 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)); + } + /** + * Scans the given number of hexadecimal digits in the text, + * returning -1 if the given number is unavailable. + */ + function scanExactNumberOfHexDigits(count) { + return scanHexDigits(/*minCount*/ count, /*scanAsManyAsPossible*/ false); + } + /** + * Scans as many hexadecimal digits as are available in the text, + * returning -1 if the given number of digits was unavailable. + */ + function scanMinimumNumberOfHexDigits(count) { + return scanHexDigits(/*minCount*/ count, /*scanAsManyAsPossible*/ true); + } + function scanHexDigits(minCount, scanAsManyAsPossible) { + var digits = 0; + var value = 0; + while (digits < minCount || scanAsManyAsPossible) { + var ch = text.charCodeAt(pos); + if (ch >= 48 /* _0 */ && ch <= 57 /* _9 */) { + value = value * 16 + ch - 48 /* _0 */; + } + else if (ch >= 65 /* A */ && ch <= 70 /* F */) { + value = value * 16 + ch - 65 /* A */ + 10; + } + else if (ch >= 97 /* a */ && ch <= 102 /* f */) { + value = value * 16 + ch - 97 /* a */ + 10; + } + else { + break; + } + pos++; + digits++; + } + if (digits < minCount) { + value = -1; + } + return value; + } + function scanString() { + var quote = text.charCodeAt(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 /* backslash */) { + 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; + } + /** + * Sets the current 'tokenValue' and returns a NoSubstitutionTemplateLiteral or + * a literal component of a TemplateExpression. + */ + function scanTemplateAndSetTokenValue() { + var startedWithBacktick = text.charCodeAt(pos) === 96 /* backtick */; + 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 /* NoSubstitutionTemplateLiteral */ : 14 /* TemplateTail */; + break; + } + var currChar = text.charCodeAt(pos); + // '`' + if (currChar === 96 /* backtick */) { + contents += text.substring(start, pos); + pos++; + resultingToken = startedWithBacktick ? 11 /* NoSubstitutionTemplateLiteral */ : 14 /* 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 */; + break; + } + // Escape character + if (currChar === 92 /* backslash */) { + contents += text.substring(start, pos); + contents += scanEscapeSequence(); + start = pos; + continue; + } + // Speculated ECMAScript 6 Spec 11.8.6.1: + // and LineTerminatorSequences are normalized to for Template Values + if (currChar === 13 /* carriageReturn */) { + contents += text.substring(start, pos); + pos++; + if (pos < end && text.charCodeAt(pos) === 10 /* lineFeed */) { + 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++); + switch (ch) { + case 48 /* _0 */: + return "\0"; + case 98 /* b */: + return "\b"; + case 116 /* t */: + return "\t"; + case 110 /* n */: + return "\n"; + case 118 /* v */: + return "\v"; + case 102 /* f */: + return "\f"; + case 114 /* r */: + return "\r"; + case 39 /* singleQuote */: + return "\'"; + case 34 /* doubleQuote */: + return "\""; + case 117 /* u */: + // '\u{DDDDDDDD}' + if (pos < end && text.charCodeAt(pos) === 123 /* openBrace */) { + hasExtendedUnicodeEscape = true; + pos++; + return scanExtendedUnicodeEscape(); + } + // '\uDDDD' + return scanHexadecimalEscape(/*numDigits*/ 4); + case 120 /* x */: + // '\xDD' + return scanHexadecimalEscape(/*numDigits*/ 2); + // when encountering a LineContinuation (i.e. a backslash and a line terminator sequence), + // the line terminator is interpreted to be "the empty code unit sequence". + case 13 /* carriageReturn */: + if (pos < end && text.charCodeAt(pos) === 10 /* lineFeed */) { + pos++; + } + // fall through + case 10 /* lineFeed */: + case 8232 /* lineSeparator */: + case 8233 /* paragraphSeparator */: + 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; + // Validate the value of the digit + 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 /* closeBrace */) { + // Only swallow the following character up if it's a '}'. + pos++; + } + else { + error(ts.Diagnostics.Unterminated_Unicode_escape_sequence); + isInvalidExtendedEscape = true; + } + if (isInvalidExtendedEscape) { + return ""; + } + return utf16EncodeAsString(escapedValue); + } + // Derived from the 10.1.1 UTF16Encoding of the ES6 Spec. + 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); + } + // Current character is known to be a backslash. Check for Unicode escape of the form '\uXXXX' + // and return code point value if valid Unicode escape is found. Otherwise return -1. + function peekUnicodeEscape() { + if (pos + 5 < end && text.charCodeAt(pos + 1) === 117 /* u */) { + 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 /* backslash */) { + ch = peekUnicodeEscape(); + if (!(ch >= 0 && isIdentifierPart(ch, languageVersion))) { + break; + } + result += text.substring(start, pos); + result += String.fromCharCode(ch); + // Valid Unicode escape is always six characters + pos += 6; + start = pos; + } + else { + break; + } + } + result += text.substring(start, pos); + return result; + } + function getIdentifierToken() { + // Reserved words are between 2 and 11 characters long and start with a lowercase letter + var len = tokenValue.length; + if (len >= 2 && len <= 11) { + var ch = tokenValue.charCodeAt(0); + if (ch >= 97 /* a */ && ch <= 122 /* z */ && hasOwnProperty.call(textToToken, tokenValue)) { + return token = textToToken[tokenValue]; + } + } + return token = 69 /* Identifier */; + } + function scanBinaryOrOctalDigits(base) { + 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. + var numberOfDigits = 0; + while (true) { + var ch = text.charCodeAt(pos); + var valueOfCh = ch - 48 /* _0 */; + if (!isDigit(ch) || valueOfCh >= base) { + break; + } + value = value * base + valueOfCh; + pos++; + numberOfDigits++; + } + // Invalid binaryIntegerLiteral or octalIntegerLiteral + 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 /* EndOfFileToken */; + } + var ch = text.charCodeAt(pos); + // Special handling for shebang + if (ch === 35 /* hash */ && pos === 0 && isShebangTrivia(text, pos)) { + pos = scanShebangTrivia(text, pos); + if (skipTrivia) { + continue; + } + else { + return token = 6 /* ShebangTrivia */; + } + } + switch (ch) { + case 10 /* lineFeed */: + case 13 /* carriageReturn */: + precedingLineBreak = true; + if (skipTrivia) { + pos++; + continue; + } + else { + if (ch === 13 /* carriageReturn */ && pos + 1 < end && text.charCodeAt(pos + 1) === 10 /* lineFeed */) { + // consume both CR and LF + pos += 2; + } + else { + pos++; + } + return token = 4 /* NewLineTrivia */; + } + case 9 /* tab */: + case 11 /* verticalTab */: + case 12 /* formFeed */: + case 32 /* space */: + if (skipTrivia) { + pos++; + continue; + } + else { + while (pos < end && isWhiteSpace(text.charCodeAt(pos))) { + pos++; + } + return token = 5 /* WhitespaceTrivia */; + } + 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 += 2, token = 31 /* ExclamationEqualsToken */; + } + return pos++, token = 49 /* ExclamationToken */; + case 34 /* doubleQuote */: + case 39 /* singleQuote */: + tokenValue = scanString(); + return token = 9 /* StringLiteral */; + case 96 /* backtick */: + return token = scanTemplateAndSetTokenValue(); + case 37 /* percent */: + if (text.charCodeAt(pos + 1) === 61 /* equals */) { + return pos += 2, token = 62 /* PercentEqualsToken */; + } + return pos++, token = 40 /* PercentToken */; + case 38 /* ampersand */: + if (text.charCodeAt(pos + 1) === 38 /* ampersand */) { + return pos += 2, token = 51 /* AmpersandAmpersandToken */; + } + if (text.charCodeAt(pos + 1) === 61 /* equals */) { + return pos += 2, token = 66 /* AmpersandEqualsToken */; + } + return pos++, token = 46 /* AmpersandToken */; + case 40 /* openParen */: + return pos++, token = 17 /* OpenParenToken */; + case 41 /* closeParen */: + return pos++, token = 18 /* CloseParenToken */; + case 42 /* asterisk */: + if (text.charCodeAt(pos + 1) === 61 /* equals */) { + return pos += 2, token = 59 /* AsteriskEqualsToken */; + } + if (text.charCodeAt(pos + 1) === 42 /* asterisk */) { + if (text.charCodeAt(pos + 2) === 61 /* equals */) { + return pos += 3, token = 60 /* AsteriskAsteriskEqualsToken */; + } + return pos += 2, token = 38 /* AsteriskAsteriskToken */; + } + return pos++, token = 37 /* AsteriskToken */; + case 43 /* plus */: + if (text.charCodeAt(pos + 1) === 43 /* plus */) { + return pos += 2, token = 41 /* PlusPlusToken */; + } + if (text.charCodeAt(pos + 1) === 61 /* equals */) { + return pos += 2, token = 57 /* PlusEqualsToken */; + } + return pos++, token = 35 /* PlusToken */; + case 44 /* comma */: + return pos++, token = 24 /* CommaToken */; + case 45 /* minus */: + if (text.charCodeAt(pos + 1) === 45 /* minus */) { + return pos += 2, token = 42 /* MinusMinusToken */; + } + if (text.charCodeAt(pos + 1) === 61 /* equals */) { + return pos += 2, token = 58 /* MinusEqualsToken */; + } + return pos++, token = 36 /* 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++, token = 21 /* DotToken */; + case 47 /* slash */: + // Single-line comment + if (text.charCodeAt(pos + 1) === 47 /* slash */) { + pos += 2; + while (pos < end) { + if (isLineBreak(text.charCodeAt(pos))) { + break; + } + pos++; + } + if (skipTrivia) { + continue; + } + else { + return token = 2 /* SingleLineCommentTrivia */; + } + } + // Multi-line comment + if (text.charCodeAt(pos + 1) === 42 /* asterisk */) { + pos += 2; + var commentClosed = false; + while (pos < end) { + var ch_2 = text.charCodeAt(pos); + if (ch_2 === 42 /* asterisk */ && text.charCodeAt(pos + 1) === 47 /* slash */) { + 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 /* MultiLineCommentTrivia */; + } + } + if (text.charCodeAt(pos + 1) === 61 /* equals */) { + return pos += 2, token = 61 /* SlashEqualsToken */; + } + return pos++, token = 39 /* SlashToken */; + case 48 /* _0 */: + if (pos + 2 < end && (text.charCodeAt(pos + 1) === 88 /* X */ || text.charCodeAt(pos + 1) === 120 /* x */)) { + pos += 2; + var value = scanMinimumNumberOfHexDigits(1); + if (value < 0) { + error(ts.Diagnostics.Hexadecimal_digit_expected); + value = 0; + } + tokenValue = "" + value; + return token = 8 /* NumericLiteral */; + } + else if (pos + 2 < end && (text.charCodeAt(pos + 1) === 66 /* B */ || text.charCodeAt(pos + 1) === 98 /* b */)) { + pos += 2; + var value = scanBinaryOrOctalDigits(/* base */ 2); + if (value < 0) { + error(ts.Diagnostics.Binary_digit_expected); + value = 0; + } + tokenValue = "" + value; + return token = 8 /* NumericLiteral */; + } + else if (pos + 2 < end && (text.charCodeAt(pos + 1) === 79 /* O */ || text.charCodeAt(pos + 1) === 111 /* o */)) { + pos += 2; + var value = scanBinaryOrOctalDigits(/* base */ 8); + if (value < 0) { + error(ts.Diagnostics.Octal_digit_expected); + value = 0; + } + tokenValue = "" + value; + return token = 8 /* NumericLiteral */; + } + // Try to parse as an octal + if (pos + 1 < end && isOctalDigit(text.charCodeAt(pos + 1))) { + tokenValue = "" + scanOctalDigits(); + return token = 8 /* NumericLiteral */; + } + // This fall-through is a deviation from the EcmaScript grammar. The grammar says that a leading zero + // can only be followed by an octal digit, a dot, or the end of the number literal. However, we are being + // permissive and allowing decimal digits of the form 08* and 09* (which many browsers also do). + case 49 /* _1 */: + case 50 /* _2 */: + case 51 /* _3 */: + case 52 /* _4 */: + case 53 /* _5 */: + case 54 /* _6 */: + case 55 /* _7 */: + case 56 /* _8 */: + case 57 /* _9 */: + tokenValue = "" + scanNumber(); + return token = 8 /* NumericLiteral */; + case 58 /* colon */: + return pos++, token = 54 /* ColonToken */; + case 59 /* semicolon */: + return pos++, token = 23 /* SemicolonToken */; + case 60 /* lessThan */: + if (isConflictMarkerTrivia(text, pos)) { + pos = scanConflictMarkerTrivia(text, pos, error); + if (skipTrivia) { + continue; + } + else { + return token = 7 /* ConflictMarkerTrivia */; + } + } + if (text.charCodeAt(pos + 1) === 60 /* lessThan */) { + if (text.charCodeAt(pos + 2) === 61 /* equals */) { + return pos += 3, token = 63 /* LessThanLessThanEqualsToken */; + } + return pos += 2, token = 43 /* LessThanLessThanToken */; + } + if (text.charCodeAt(pos + 1) === 61 /* equals */) { + return pos += 2, token = 28 /* 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++, token = 25 /* LessThanToken */; + case 61 /* equals */: + if (isConflictMarkerTrivia(text, pos)) { + pos = scanConflictMarkerTrivia(text, pos, error); + if (skipTrivia) { + continue; + } + else { + return token = 7 /* ConflictMarkerTrivia */; + } + } + if (text.charCodeAt(pos + 1) === 61 /* equals */) { + if (text.charCodeAt(pos + 2) === 61 /* equals */) { + return pos += 3, token = 32 /* EqualsEqualsEqualsToken */; + } + return pos += 2, token = 30 /* EqualsEqualsToken */; + } + if (text.charCodeAt(pos + 1) === 62 /* greaterThan */) { + return pos += 2, token = 34 /* EqualsGreaterThanToken */; + } + return pos++, token = 56 /* EqualsToken */; + case 62 /* greaterThan */: + if (isConflictMarkerTrivia(text, pos)) { + pos = scanConflictMarkerTrivia(text, pos, error); + if (skipTrivia) { + continue; + } + else { + return token = 7 /* ConflictMarkerTrivia */; + } + } + return pos++, token = 27 /* GreaterThanToken */; + case 63 /* question */: + return pos++, token = 53 /* QuestionToken */; + case 91 /* openBracket */: + return pos++, token = 19 /* OpenBracketToken */; + case 93 /* closeBracket */: + return pos++, token = 20 /* CloseBracketToken */; + case 94 /* caret */: + if (text.charCodeAt(pos + 1) === 61 /* equals */) { + return pos += 2, token = 68 /* CaretEqualsToken */; + } + return pos++, token = 48 /* CaretToken */; + case 123 /* openBrace */: + return pos++, token = 15 /* OpenBraceToken */; + case 124 /* bar */: + if (text.charCodeAt(pos + 1) === 124 /* bar */) { + return pos += 2, token = 52 /* BarBarToken */; + } + if (text.charCodeAt(pos + 1) === 61 /* equals */) { + return pos += 2, token = 67 /* BarEqualsToken */; + } + return pos++, token = 47 /* BarToken */; + case 125 /* closeBrace */: + return pos++, token = 16 /* CloseBraceToken */; + case 126 /* tilde */: + return pos++, token = 50 /* TildeToken */; + case 64 /* at */: + return pos++, token = 55 /* AtToken */; + case 92 /* backslash */: + var cookedChar = peekUnicodeEscape(); + if (cookedChar >= 0 && isIdentifierStart(cookedChar, languageVersion)) { + pos += 6; + tokenValue = String.fromCharCode(cookedChar) + scanIdentifierParts(); + return token = getIdentifierToken(); + } + error(ts.Diagnostics.Invalid_character); + return pos++, token = 0 /* Unknown */; + default: + if (isIdentifierStart(ch, languageVersion)) { + pos++; + while (pos < end && isIdentifierPart(ch = text.charCodeAt(pos), languageVersion)) + pos++; + tokenValue = text.substring(tokenPos, pos); + if (ch === 92 /* backslash */) { + tokenValue += scanIdentifierParts(); + } + return token = getIdentifierToken(); + } + else if (isWhiteSpace(ch)) { + pos++; + continue; + } + else if (isLineBreak(ch)) { + precedingLineBreak = true; + pos++; + continue; + } + error(ts.Diagnostics.Invalid_character); + return pos++, token = 0 /* Unknown */; + } + } + } + function reScanGreaterToken() { + if (token === 27 /* 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 += 2, token = 45 /* GreaterThanGreaterThanGreaterThanToken */; + } + if (text.charCodeAt(pos + 1) === 61 /* equals */) { + return pos += 2, token = 64 /* GreaterThanGreaterThanEqualsToken */; + } + return pos++, token = 44 /* GreaterThanGreaterThanToken */; + } + if (text.charCodeAt(pos) === 61 /* equals */) { + return pos++, token = 29 /* GreaterThanEqualsToken */; + } + } + return token; + } + function reScanSlashToken() { + if (token === 39 /* SlashToken */ || token === 61 /* SlashEqualsToken */) { + var p = tokenPos + 1; + var inEscape = false; + var inCharacterClass = false; + while (true) { + // If we reach the end of a file, or hit a newline, then this is an unterminated + // regex. Report error and return what we have so far. + 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) { + // Parsing an escape character; + // reset the flag and just advance to the next char. + inEscape = false; + } + else if (ch === 47 /* slash */ && !inCharacterClass) { + // A slash within a character class is permissible, + // but in general it signals the end of the regexp literal. + p++; + break; + } + else if (ch === 91 /* openBracket */) { + inCharacterClass = true; + } + else if (ch === 92 /* backslash */) { + inEscape = true; + } + else if (ch === 93 /* closeBracket */) { + inCharacterClass = false; + } + p++; + } + while (p < end && isIdentifierPart(text.charCodeAt(p), languageVersion)) { + p++; + } + pos = p; + tokenValue = text.substring(tokenPos, pos); + token = 10 /* RegularExpressionLiteral */; + } + return token; + } + /** + * Unconditionally back up and scan a template expression portion. + */ + function reScanTemplateToken() { + ts.Debug.assert(token === 16 /* CloseBraceToken */, "'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 /* EndOfFileToken */; + } + var char = text.charCodeAt(pos); + if (char === 60 /* lessThan */) { + if (text.charCodeAt(pos + 1) === 47 /* slash */) { + pos += 2; + return token = 26 /* LessThanSlashToken */; + } + pos++; + return token = 25 /* LessThanToken */; + } + if (char === 123 /* openBrace */) { + pos++; + return token = 15 /* OpenBraceToken */; + } + while (pos < end) { + pos++; + char = text.charCodeAt(pos); + if ((char === 123 /* openBrace */) || (char === 60 /* lessThan */)) { + break; + } + } + return token = 236 /* JsxText */; + } + // Scans a JSX identifier; these differ from normal identifiers in that + // they allow dashes + function scanJsxIdentifier() { + if (tokenIsIdentifierOrKeyword(token)) { + var firstCharPosition = pos; + while (pos < end) { + var ch = text.charCodeAt(pos); + if (ch === 45 /* minus */ || ((firstCharPosition === pos) ? isIdentifierStart(ch, languageVersion) : isIdentifierPart(ch, languageVersion))) { + pos++; + } + else { + break; + } + } + tokenValue += text.substr(firstCharPosition, pos - firstCharPosition); + } + return token; + } + 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 our callback returned something 'falsy' or we're just looking ahead, + // then unconditionally restore us to where we were. + if (!result || isLookahead) { + pos = savePos; + startPos = saveStartPos; + tokenPos = saveTokenPos; + token = saveToken; + tokenValue = saveTokenValue; + precedingLineBreak = savePrecedingLineBreak; + } + return result; + } + function lookAhead(callback) { + return speculationHelper(callback, /*isLookahead:*/ true); + } + function tryScan(callback) { + return speculationHelper(callback, /*isLookahead:*/ false); + } + 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 /* Unknown */; + precedingLineBreak = false; + tokenValue = undefined; + hasExtendedUnicodeEscape = false; + tokenIsUnterminated = false; + } + } + ts.createScanner = createScanner; +})(ts || (ts = {})); +/// +/* @internal */ +var ts; +(function (ts) { + ts.bindTime = 0; + (function (ModuleInstanceState) { + ModuleInstanceState[ModuleInstanceState["NonInstantiated"] = 0] = "NonInstantiated"; + ModuleInstanceState[ModuleInstanceState["Instantiated"] = 1] = "Instantiated"; + ModuleInstanceState[ModuleInstanceState["ConstEnumOnly"] = 2] = "ConstEnumOnly"; + })(ts.ModuleInstanceState || (ts.ModuleInstanceState = {})); + var ModuleInstanceState = ts.ModuleInstanceState; + function getModuleInstanceState(node) { + // A module is uninstantiated if it contains only + // 1. interface declarations, type alias declarations + if (node.kind === 215 /* InterfaceDeclaration */ || node.kind === 216 /* TypeAliasDeclaration */) { + return 0 /* NonInstantiated */; + } + else if (ts.isConstEnumDeclaration(node)) { + return 2 /* ConstEnumOnly */; + } + else if ((node.kind === 222 /* ImportDeclaration */ || node.kind === 221 /* ImportEqualsDeclaration */) && !(node.flags & 1 /* Export */)) { + return 0 /* NonInstantiated */; + } + else if (node.kind === 219 /* ModuleBlock */) { + var state = 0 /* NonInstantiated */; + ts.forEachChild(node, function (n) { + switch (getModuleInstanceState(n)) { + case 0 /* NonInstantiated */: + // child is non-instantiated - continue searching + return false; + case 2 /* ConstEnumOnly */: + // child is const enum only - record state and continue searching + state = 2 /* ConstEnumOnly */; + return false; + case 1 /* Instantiated */: + // child is instantiated - record state and stop + state = 1 /* Instantiated */; + return true; + } + }); + return state; + } + else if (node.kind === 218 /* ModuleDeclaration */) { + return getModuleInstanceState(node.body); + } + else { + return 1 /* Instantiated */; + } + } + ts.getModuleInstanceState = getModuleInstanceState; + var ContainerFlags; + (function (ContainerFlags) { + // The current node is not a container, and no container manipulation should happen before + // recursing into it. + ContainerFlags[ContainerFlags["None"] = 0] = "None"; + // 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... + ContainerFlags[ContainerFlags["IsContainer"] = 1] = "IsContainer"; + // 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... + ContainerFlags[ContainerFlags["IsBlockScopedContainer"] = 2] = "IsBlockScopedContainer"; + ContainerFlags[ContainerFlags["HasLocals"] = 4] = "HasLocals"; + // If the current node is a container that also container that also contains locals. Examples: + // + // Functions, Methods, Modules, Source-files. + ContainerFlags[ContainerFlags["IsContainerWithLocals"] = 5] = "IsContainerWithLocals"; + })(ContainerFlags || (ContainerFlags = {})); + function bindSourceFile(file) { + var start = new Date().getTime(); + bindSourceFileWorker(file); + ts.bindTime += new Date().getTime() - start; + } + ts.bindSourceFile = bindSourceFile; + function bindSourceFileWorker(file) { + var parent; + var container; + var blockScopeContainer; + var lastContainer; + var seenThisKeyword; + // 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). + var inStrictMode = !!file.externalModuleIndicator; + var symbolCount = 0; + var Symbol = ts.objectAllocator.getSymbolConstructor(); + var classifiableNames = {}; + if (!file.locals) { + bind(file); + file.symbolCount = symbolCount; + file.classifiableNames = classifiableNames; + } + return; + function createSymbol(flags, name) { + symbolCount++; + return new Symbol(flags, name); + } + function addDeclarationToSymbol(symbol, node, symbolFlags) { + symbol.flags |= symbolFlags; + node.symbol = symbol; + if (!symbol.declarations) { + symbol.declarations = []; + } + symbol.declarations.push(node); + if (symbolFlags & 1952 /* HasExports */ && !symbol.exports) { + symbol.exports = {}; + } + if (symbolFlags & 6240 /* HasMembers */ && !symbol.members) { + symbol.members = {}; + } + if (symbolFlags & 107455 /* Value */ && !symbol.valueDeclaration) { + 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) { + if (node.name) { + if (node.kind === 218 /* ModuleDeclaration */ && node.name.kind === 9 /* StringLiteral */) { + return "\"" + node.name.text + "\""; + } + if (node.name.kind === 136 /* ComputedPropertyName */) { + var nameExpression = node.name.expression; + ts.Debug.assert(ts.isWellKnownSymbolSyntactically(nameExpression)); + return ts.getPropertyNameForKnownSymbolName(nameExpression.name.text); + } + return node.name.text; + } + switch (node.kind) { + case 144 /* Constructor */: + return "__constructor"; + case 152 /* FunctionType */: + case 147 /* CallSignature */: + return "__call"; + case 153 /* ConstructorType */: + case 148 /* ConstructSignature */: + return "__new"; + case 149 /* IndexSignature */: + return "__index"; + case 228 /* ExportDeclaration */: + return "__export"; + case 227 /* ExportAssignment */: + return node.isExportEquals ? "export=" : "default"; + case 213 /* FunctionDeclaration */: + case 214 /* ClassDeclaration */: + return node.flags & 1024 /* Default */ ? "default" : undefined; + } + } + function getDisplayName(node) { + return node.name ? ts.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, parent, node, includes, excludes) { + ts.Debug.assert(!ts.hasDynamicName(node)); + var isDefaultExport = node.flags & 1024 /* Default */; + // The exported symbol for an export default function/class node is always named "default" + var name = isDefaultExport && parent ? "default" : getDeclarationName(node); + var symbol; + if (name !== undefined) { + // Check and see if the symbol table already has a symbol with this name. If not, + // 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. + // + // 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 = ts.hasProperty(symbolTable, name) + ? symbolTable[name] + : (symbolTable[name] = createSymbol(0 /* None */, name)); + if (name && (includes & 788448 /* Classifiable */)) { + classifiableNames[name] = name; + } + if (symbol.flags & excludes) { + if (node.name) { + node.name.parent = node; + } + // Report errors every position with duplicate declaration + // Report errors on previous encountered declarations + var message = symbol.flags & 2 /* BlockScopedVariable */ + ? ts.Diagnostics.Cannot_redeclare_block_scoped_variable_0 + : ts.Diagnostics.Duplicate_identifier_0; + ts.forEach(symbol.declarations, function (declaration) { + if (declaration.flags & 1024 /* Default */) { + message = ts.Diagnostics.A_module_cannot_have_multiple_default_exports; + } + }); + ts.forEach(symbol.declarations, function (declaration) { + file.bindDiagnostics.push(ts.createDiagnosticForNode(declaration.name || declaration, message, getDisplayName(declaration))); + }); + file.bindDiagnostics.push(ts.createDiagnosticForNode(node.name || node, message, getDisplayName(node))); + symbol = createSymbol(0 /* None */, name); + } + } + else { + symbol = createSymbol(0 /* None */, "__missing"); + } + addDeclarationToSymbol(symbol, node, includes); + symbol.parent = parent; + return symbol; + } + function declareModuleMember(node, symbolFlags, symbolExcludes) { + var hasExportModifier = ts.getCombinedNodeFlags(node) & 1 /* Export */; + if (symbolFlags & 8388608 /* Alias */) { + if (node.kind === 230 /* ExportSpecifier */ || (node.kind === 221 /* 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. + if (hasExportModifier || container.flags & 262144 /* ExportContext */) { + var exportKind = (symbolFlags & 107455 /* Value */ ? 1048576 /* ExportValue */ : 0) | + (symbolFlags & 793056 /* Type */ ? 2097152 /* ExportType */ : 0) | + (symbolFlags & 1536 /* Namespace */ ? 4194304 /* ExportNamespace */ : 0); + var 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 bindChildren(node) { + // Before we recurse into a node's chilren, we first save the existing parent, container + // and block-container. Then after we pop out of processing the children, we restore + // these saved values. + var saveParent = parent; + var saveContainer = container; + var savedBlockScopeContainer = blockScopeContainer; + // This node will now be set as the parent of all of its children as we recurse into them. + parent = node; + // 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 accidently move any stale data forward from + // a previous compilation. + var containerFlags = getContainerFlags(node); + if (containerFlags & 1 /* IsContainer */) { + container = blockScopeContainer = node; + if (containerFlags & 4 /* HasLocals */) { + container.locals = {}; + } + addToContainerChain(container); + } + else if (containerFlags & 2 /* IsBlockScopedContainer */) { + blockScopeContainer = node; + blockScopeContainer.locals = undefined; + } + if (node.kind === 215 /* InterfaceDeclaration */) { + seenThisKeyword = false; + ts.forEachChild(node, bind); + node.flags = seenThisKeyword ? node.flags | 524288 /* ContainsThis */ : node.flags & ~524288 /* ContainsThis */; + } + else { + ts.forEachChild(node, bind); + } + container = saveContainer; + parent = saveParent; + blockScopeContainer = savedBlockScopeContainer; + } + function getContainerFlags(node) { + switch (node.kind) { + case 186 /* ClassExpression */: + case 214 /* ClassDeclaration */: + case 215 /* InterfaceDeclaration */: + case 217 /* EnumDeclaration */: + case 155 /* TypeLiteral */: + case 165 /* ObjectLiteralExpression */: + return 1 /* IsContainer */; + case 147 /* CallSignature */: + case 148 /* ConstructSignature */: + case 149 /* IndexSignature */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: + case 213 /* FunctionDeclaration */: + case 144 /* Constructor */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: + case 152 /* FunctionType */: + case 153 /* ConstructorType */: + case 173 /* FunctionExpression */: + case 174 /* ArrowFunction */: + case 218 /* ModuleDeclaration */: + case 248 /* SourceFile */: + case 216 /* TypeAliasDeclaration */: + return 5 /* IsContainerWithLocals */; + case 244 /* CatchClause */: + case 199 /* ForStatement */: + case 200 /* ForInStatement */: + case 201 /* ForOfStatement */: + case 220 /* CaseBlock */: + return 2 /* IsBlockScopedContainer */; + case 192 /* Block */: + // do not treat blocks directly inside a function as a block-scoped-container. + // Locals that reside in this block should go to the function locals. Othewise 'x' + // would not appear to be a redeclaration of a block scoped local in the following + // 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 ts.isFunctionLike(node.parent) ? 0 /* None */ : 2 /* IsBlockScopedContainer */; + } + return 0 /* None */; + } + function addToContainerChain(next) { + if (lastContainer) { + lastContainer.nextContainer = next; + } + lastContainer = next; + } + function declareSymbolAndAddToSymbolTable(node, symbolFlags, symbolExcludes) { + // Just call this directly so that the return type of this function stays "void". + declareSymbolAndAddToSymbolTableWorker(node, symbolFlags, symbolExcludes); + } + function declareSymbolAndAddToSymbolTableWorker(node, symbolFlags, symbolExcludes) { + 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 218 /* ModuleDeclaration */: + return declareModuleMember(node, symbolFlags, symbolExcludes); + case 248 /* SourceFile */: + return declareSourceFileMember(node, symbolFlags, symbolExcludes); + case 186 /* ClassExpression */: + case 214 /* ClassDeclaration */: + return declareClassMember(node, symbolFlags, symbolExcludes); + case 217 /* EnumDeclaration */: + return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); + case 155 /* TypeLiteral */: + case 165 /* ObjectLiteralExpression */: + case 215 /* InterfaceDeclaration */: + // Interface/Object-types always have their children added to the 'members' of + // their container. They are only accessible through an instance of their + // container, and are never in scope otherwise (even inside the body of the + // object / type / interface declaring them). An exception is type parameters, + // which are in scope without qualification (similar to 'locals'). + return declareSymbol(container.symbol.members, container.symbol, node, symbolFlags, symbolExcludes); + case 152 /* FunctionType */: + case 153 /* ConstructorType */: + case 147 /* CallSignature */: + case 148 /* ConstructSignature */: + case 149 /* IndexSignature */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: + case 144 /* Constructor */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: + case 213 /* FunctionDeclaration */: + case 173 /* FunctionExpression */: + case 174 /* ArrowFunction */: + case 216 /* TypeAliasDeclaration */: + // All the children of these container types are never visible through another + // symbol (i.e. through another symbol's 'exports' or 'members'). Instead, + // they're only accessed 'lexically' (i.e. from code that exists underneath + // 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, undefined, node, symbolFlags, symbolExcludes); + } + } + function declareClassMember(node, symbolFlags, symbolExcludes) { + return node.flags & 128 /* Static */ + ? declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes) + : declareSymbol(container.symbol.members, container.symbol, node, symbolFlags, symbolExcludes); + } + function declareSourceFileMember(node, symbolFlags, symbolExcludes) { + return ts.isExternalModule(file) + ? declareModuleMember(node, symbolFlags, symbolExcludes) + : declareSymbol(file.locals, undefined, node, symbolFlags, symbolExcludes); + } + function isAmbientContext(node) { + while (node) { + if (node.flags & 2 /* Ambient */) { + return true; + } + node = node.parent; + } + return false; + } + function hasExportDeclarations(node) { + var body = node.kind === 248 /* SourceFile */ ? node : node.body; + if (body.kind === 248 /* SourceFile */ || body.kind === 219 /* ModuleBlock */) { + for (var _i = 0, _a = body.statements; _i < _a.length; _i++) { + var stat = _a[_i]; + if (stat.kind === 228 /* ExportDeclaration */ || stat.kind === 227 /* ExportAssignment */) { + return true; + } + } + } + return false; + } + function setExportContextFlag(node) { + // 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 (isAmbientContext(node) && !hasExportDeclarations(node)) { + node.flags |= 262144 /* ExportContext */; + } + else { + node.flags &= ~262144 /* ExportContext */; + } + } + function bindModuleDeclaration(node) { + setExportContextFlag(node); + if (node.name.kind === 9 /* StringLiteral */) { + declareSymbolAndAddToSymbolTable(node, 512 /* ValueModule */, 106639 /* ValueModuleExcludes */); + } + else { + var state = getModuleInstanceState(node); + if (state === 0 /* NonInstantiated */) { + declareSymbolAndAddToSymbolTable(node, 1024 /* NamespaceModule */, 0 /* NamespaceModuleExcludes */); + } + else { + declareSymbolAndAddToSymbolTable(node, 512 /* ValueModule */, 106639 /* ValueModuleExcludes */); + if (node.symbol.flags & (16 /* Function */ | 32 /* Class */ | 256 /* 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 { + var currentModuleIsConstEnumOnly = state === 2 /* 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) { + // For a given function symbol "<...>(...) => T" we want to generate a symbol identical + // to the one we would get for: { <...>(...): T } + // + // We do that by making an anonymous type literal symbol, and then setting the function + // symbol as its sole member. To the rest of the system, this symbol will be indistinguishable + // from an actual type literal symbol you would have gotten had you used the long form. + var symbol = createSymbol(131072 /* Signature */, getDeclarationName(node)); + addDeclarationToSymbol(symbol, node, 131072 /* Signature */); + var typeLiteralSymbol = createSymbol(2048 /* TypeLiteral */, "__type"); + addDeclarationToSymbol(typeLiteralSymbol, node, 2048 /* TypeLiteral */); + typeLiteralSymbol.members = (_a = {}, _a[symbol.name] = symbol, _a); + var _a; + } + function bindObjectLiteralExpression(node) { + var ElementKind; + (function (ElementKind) { + ElementKind[ElementKind["Property"] = 1] = "Property"; + ElementKind[ElementKind["Accessor"] = 2] = "Accessor"; + })(ElementKind || (ElementKind = {})); + if (inStrictMode) { + var seen = {}; + for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { + var prop = _a[_i]; + if (prop.name.kind !== 69 /* Identifier */) { + continue; + } + var identifier = prop.name; + // ECMA-262 11.1.5 Object Initialiser + // If previous is not undefined then throw a SyntaxError exception if any of the following conditions are true + // a.This production is contained in strict code and IsDataDescriptor(previous) is true and + // 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 + var currentKind = prop.kind === 245 /* PropertyAssignment */ || prop.kind === 246 /* ShorthandPropertyAssignment */ || prop.kind === 143 /* MethodDeclaration */ + ? 1 /* Property */ + : 2 /* Accessor */; + var existingKind = seen[identifier.text]; + if (!existingKind) { + seen[identifier.text] = currentKind; + continue; + } + if (currentKind === 1 /* Property */ && existingKind === 1 /* Property */) { + var span = ts.getErrorSpanForNode(file, identifier); + file.bindDiagnostics.push(ts.createFileDiagnostic(file, span.start, span.length, ts.Diagnostics.An_object_literal_cannot_have_multiple_properties_with_the_same_name_in_strict_mode)); + } + } + } + return bindAnonymousDeclaration(node, 4096 /* ObjectLiteral */, "__object"); + } + function bindAnonymousDeclaration(node, symbolFlags, name) { + var symbol = createSymbol(symbolFlags, name); + addDeclarationToSymbol(symbol, node, symbolFlags); + } + function bindBlockScopedDeclaration(node, symbolFlags, symbolExcludes) { + switch (blockScopeContainer.kind) { + case 218 /* ModuleDeclaration */: + declareModuleMember(node, symbolFlags, symbolExcludes); + break; + case 248 /* SourceFile */: + if (ts.isExternalModule(container)) { + declareModuleMember(node, symbolFlags, symbolExcludes); + break; + } + // fall through. + default: + if (!blockScopeContainer.locals) { + blockScopeContainer.locals = {}; + addToContainerChain(blockScopeContainer); + } + declareSymbol(blockScopeContainer.locals, undefined, node, symbolFlags, symbolExcludes); + } + } + function bindBlockScopedVariableDeclaration(node) { + bindBlockScopedDeclaration(node, 2 /* BlockScopedVariable */, 107455 /* 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) { + if (inStrictMode && + node.originalKeywordKind >= 106 /* FirstFutureReservedWord */ && + node.originalKeywordKind <= 114 /* LastFutureReservedWord */ && + !ts.isIdentifierName(node)) { + // Report error only if there are no parse errors in file + if (!file.parseDiagnostics.length) { + file.bindDiagnostics.push(ts.createDiagnosticForNode(node, getStrictModeIdentifierMessage(node), ts.declarationNameToString(node))); + } + } + } + function getStrictModeIdentifierMessage(node) { + // Provide specialized messages to help the user understand why we think they're in + // strict mode. + if (ts.getContainingClass(node)) { + return ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_strict_mode; + } + if (file.externalModuleIndicator) { + return ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode_Modules_are_automatically_in_strict_mode; + } + return ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode; + } + function checkStrictModeBinaryExpression(node) { + if (inStrictMode && ts.isLeftHandSideExpression(node.left) && ts.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) { + // 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) { + // Grammar checking + if (inStrictMode && node.expression.kind === 69 /* Identifier */) { + // When a delete operator occurs within strict mode code, a SyntaxError is thrown if its + // UnaryExpression is a direct reference to a variable, function argument, or function name + var span = ts.getErrorSpanForNode(file, node.expression); + file.bindDiagnostics.push(ts.createFileDiagnostic(file, span.start, span.length, ts.Diagnostics.delete_cannot_be_called_on_an_identifier_in_strict_mode)); + } + } + function isEvalOrArgumentsIdentifier(node) { + return node.kind === 69 /* Identifier */ && + (node.text === "eval" || node.text === "arguments"); + } + function checkStrictModeEvalOrArguments(contextNode, name) { + if (name && name.kind === 69 /* Identifier */) { + var identifier = name; + if (isEvalOrArgumentsIdentifier(identifier)) { + // We check first if the name is inside class declaration or class expression; if so give explicit message + // otherwise report generic error message. + var span = ts.getErrorSpanForNode(file, name); + file.bindDiagnostics.push(ts.createFileDiagnostic(file, span.start, span.length, getStrictModeEvalOrArgumentsMessage(contextNode), identifier.text)); + } + } + } + function getStrictModeEvalOrArgumentsMessage(node) { + // Provide specialized messages to help the user understand why we think they're in + // strict mode. + if (ts.getContainingClass(node)) { + return ts.Diagnostics.Invalid_use_of_0_Class_definitions_are_automatically_in_strict_mode; + } + if (file.externalModuleIndicator) { + return ts.Diagnostics.Invalid_use_of_0_Modules_are_automatically_in_strict_mode; + } + return ts.Diagnostics.Invalid_use_of_0_in_strict_mode; + } + function checkStrictModeFunctionName(node) { + 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 checkStrictModeNumericLiteral(node) { + if (inStrictMode && node.flags & 65536 /* OctalLiteral */) { + file.bindDiagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.Octal_literals_are_not_allowed_in_strict_mode)); + } + } + function checkStrictModePostfixUnaryExpression(node) { + // 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) { + // Grammar checking + if (inStrictMode) { + if (node.operator === 41 /* PlusPlusToken */ || node.operator === 42 /* MinusMinusToken */) { + checkStrictModeEvalOrArguments(node, node.operand); + } + } + } + function checkStrictModeWithStatement(node) { + // Grammar checking for withStatement + if (inStrictMode) { + grammarErrorOnFirstToken(node, ts.Diagnostics.with_statements_are_not_allowed_in_strict_mode); + } + } + function grammarErrorOnFirstToken(node, message, arg0, arg1, arg2) { + var span = ts.getSpanOfTokenAtPosition(file, node.pos); + file.bindDiagnostics.push(ts.createFileDiagnostic(file, span.start, span.length, message, arg0, arg1, arg2)); + } + function getDestructuringParameterName(node) { + return "__" + ts.indexOf(node.parent.parameters, node); + } + function bind(node) { + node.parent = parent; + var savedInStrictMode = inStrictMode; + if (!savedInStrictMode) { + updateStrictMode(node); + } + // 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. + bindChildren(node); + inStrictMode = savedInStrictMode; + } + function updateStrictMode(node) { + switch (node.kind) { + case 248 /* SourceFile */: + case 219 /* ModuleBlock */: + updateStrictModeStatementList(node.statements); + return; + case 192 /* Block */: + if (ts.isFunctionLike(node.parent)) { + updateStrictModeStatementList(node.statements); + } + return; + case 214 /* ClassDeclaration */: + case 186 /* ClassExpression */: + // All classes are automatically in strict mode in ES6. + inStrictMode = true; + return; + } + } + function updateStrictModeStatementList(statements) { + for (var _i = 0; _i < statements.length; _i++) { + var statement = statements[_i]; + if (!ts.isPrologueDirective(statement)) { + return; + } + if (isUseStrictPrologueDirective(statement)) { + inStrictMode = true; + return; + } + } + } + /// Should be called only on prologue directives (isPrologueDirective(node) should be true) + function isUseStrictPrologueDirective(node) { + var nodeText = ts.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) { + switch (node.kind) { + case 69 /* Identifier */: + return checkStrictModeIdentifier(node); + case 181 /* BinaryExpression */: + return checkStrictModeBinaryExpression(node); + case 244 /* CatchClause */: + return checkStrictModeCatchClause(node); + case 175 /* DeleteExpression */: + return checkStrictModeDeleteExpression(node); + case 8 /* NumericLiteral */: + return checkStrictModeNumericLiteral(node); + case 180 /* PostfixUnaryExpression */: + return checkStrictModePostfixUnaryExpression(node); + case 179 /* PrefixUnaryExpression */: + return checkStrictModePrefixUnaryExpression(node); + case 205 /* WithStatement */: + return checkStrictModeWithStatement(node); + case 97 /* ThisKeyword */: + seenThisKeyword = true; + return; + case 137 /* TypeParameter */: + return declareSymbolAndAddToSymbolTable(node, 262144 /* TypeParameter */, 530912 /* TypeParameterExcludes */); + case 138 /* Parameter */: + return bindParameter(node); + case 211 /* VariableDeclaration */: + case 163 /* BindingElement */: + return bindVariableDeclarationOrBindingElement(node); + case 141 /* PropertyDeclaration */: + case 140 /* PropertySignature */: + return bindPropertyOrMethodOrAccessor(node, 4 /* Property */ | (node.questionToken ? 536870912 /* Optional */ : 0 /* None */), 107455 /* PropertyExcludes */); + case 245 /* PropertyAssignment */: + case 246 /* ShorthandPropertyAssignment */: + return bindPropertyOrMethodOrAccessor(node, 4 /* Property */, 107455 /* PropertyExcludes */); + case 247 /* EnumMember */: + return bindPropertyOrMethodOrAccessor(node, 8 /* EnumMember */, 107455 /* EnumMemberExcludes */); + case 147 /* CallSignature */: + case 148 /* ConstructSignature */: + case 149 /* IndexSignature */: + return declareSymbolAndAddToSymbolTable(node, 131072 /* Signature */, 0 /* None */); + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: + // If this is an ObjectLiteralExpression method, then it sits in the same space + // as other properties in the object literal. So we use SymbolFlags.PropertyExcludes + // so that it will conflict with any other object literal members with the same + // name. + return bindPropertyOrMethodOrAccessor(node, 8192 /* Method */ | (node.questionToken ? 536870912 /* Optional */ : 0 /* None */), ts.isObjectLiteralMethod(node) ? 107455 /* PropertyExcludes */ : 99263 /* MethodExcludes */); + case 213 /* FunctionDeclaration */: + checkStrictModeFunctionName(node); + return declareSymbolAndAddToSymbolTable(node, 16 /* Function */, 106927 /* FunctionExcludes */); + case 144 /* Constructor */: + return declareSymbolAndAddToSymbolTable(node, 16384 /* Constructor */, /*symbolExcludes:*/ 0 /* None */); + case 145 /* GetAccessor */: + return bindPropertyOrMethodOrAccessor(node, 32768 /* GetAccessor */, 41919 /* GetAccessorExcludes */); + case 146 /* SetAccessor */: + return bindPropertyOrMethodOrAccessor(node, 65536 /* SetAccessor */, 74687 /* SetAccessorExcludes */); + case 152 /* FunctionType */: + case 153 /* ConstructorType */: + return bindFunctionOrConstructorType(node); + case 155 /* TypeLiteral */: + return bindAnonymousDeclaration(node, 2048 /* TypeLiteral */, "__type"); + case 165 /* ObjectLiteralExpression */: + return bindObjectLiteralExpression(node); + case 173 /* FunctionExpression */: + case 174 /* ArrowFunction */: + checkStrictModeFunctionName(node); + var bindingName = node.name ? node.name.text : "__function"; + return bindAnonymousDeclaration(node, 16 /* Function */, bindingName); + case 186 /* ClassExpression */: + case 214 /* ClassDeclaration */: + return bindClassLikeDeclaration(node); + case 215 /* InterfaceDeclaration */: + return bindBlockScopedDeclaration(node, 64 /* Interface */, 792960 /* InterfaceExcludes */); + case 216 /* TypeAliasDeclaration */: + return bindBlockScopedDeclaration(node, 524288 /* TypeAlias */, 793056 /* TypeAliasExcludes */); + case 217 /* EnumDeclaration */: + return bindEnumDeclaration(node); + case 218 /* ModuleDeclaration */: + return bindModuleDeclaration(node); + case 221 /* ImportEqualsDeclaration */: + case 224 /* NamespaceImport */: + case 226 /* ImportSpecifier */: + case 230 /* ExportSpecifier */: + return declareSymbolAndAddToSymbolTable(node, 8388608 /* Alias */, 8388608 /* AliasExcludes */); + case 223 /* ImportClause */: + return bindImportClause(node); + case 228 /* ExportDeclaration */: + return bindExportDeclaration(node); + case 227 /* ExportAssignment */: + return bindExportAssignment(node); + case 248 /* SourceFile */: + return bindSourceFileIfExternalModule(); + } + } + function bindSourceFileIfExternalModule() { + setExportContextFlag(file); + if (ts.isExternalModule(file)) { + bindAnonymousDeclaration(file, 512 /* ValueModule */, "\"" + ts.removeFileExtension(file.fileName) + "\""); + } + } + function bindExportAssignment(node) { + if (!container.symbol || !container.symbol.exports) { + // Export assignment in some sort of block construct + bindAnonymousDeclaration(node, 8388608 /* Alias */, getDeclarationName(node)); + } + else if (node.expression.kind === 69 /* Identifier */) { + // An export default clause with an identifier exports all meanings of that identifier + declareSymbol(container.symbol.exports, container.symbol, node, 8388608 /* Alias */, 107455 /* PropertyExcludes */ | 8388608 /* AliasExcludes */); + } + else { + // An export default clause with an expression exports a value + declareSymbol(container.symbol.exports, container.symbol, node, 4 /* Property */, 107455 /* PropertyExcludes */ | 8388608 /* AliasExcludes */); + } + } + function bindExportDeclaration(node) { + if (!container.symbol || !container.symbol.exports) { + // Export * in some sort of block construct + bindAnonymousDeclaration(node, 1073741824 /* ExportStar */, getDeclarationName(node)); + } + else if (!node.exportClause) { + // All export * declarations are collected in an __export symbol + declareSymbol(container.symbol.exports, container.symbol, node, 1073741824 /* ExportStar */, 0 /* None */); + } + } + function bindImportClause(node) { + if (node.name) { + declareSymbolAndAddToSymbolTable(node, 8388608 /* Alias */, 8388608 /* AliasExcludes */); + } + } + function bindClassLikeDeclaration(node) { + if (node.kind === 214 /* ClassDeclaration */) { + bindBlockScopedDeclaration(node, 32 /* Class */, 899519 /* ClassExcludes */); + } + else { + var bindingName = node.name ? node.name.text : "__class"; + bindAnonymousDeclaration(node, 32 /* Class */, bindingName); + // Add name of class expression into the map for semantic classifier + if (node.name) { + classifiableNames[node.name.text] = node.name.text; + } + } + var 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. + var prototypeSymbol = createSymbol(4 /* Property */ | 134217728 /* Prototype */, "prototype"); + if (ts.hasProperty(symbol.exports, prototypeSymbol.name)) { + if (node.name) { + node.name.parent = node; + } + file.bindDiagnostics.push(ts.createDiagnosticForNode(symbol.exports[prototypeSymbol.name].declarations[0], ts.Diagnostics.Duplicate_identifier_0, prototypeSymbol.name)); + } + symbol.exports[prototypeSymbol.name] = prototypeSymbol; + prototypeSymbol.parent = symbol; + } + function bindEnumDeclaration(node) { + return ts.isConst(node) + ? bindBlockScopedDeclaration(node, 128 /* ConstEnum */, 899967 /* ConstEnumExcludes */) + : bindBlockScopedDeclaration(node, 256 /* RegularEnum */, 899327 /* RegularEnumExcludes */); + } + function bindVariableDeclarationOrBindingElement(node) { + if (inStrictMode) { + checkStrictModeEvalOrArguments(node, node.name); + } + if (!ts.isBindingPattern(node.name)) { + if (ts.isBlockOrCatchScoped(node)) { + bindBlockScopedVariableDeclaration(node); + } + else if (ts.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, 1 /* FunctionScopedVariable */, 107455 /* ParameterExcludes */); + } + else { + declareSymbolAndAddToSymbolTable(node, 1 /* FunctionScopedVariable */, 107454 /* FunctionScopedVariableExcludes */); + } + } + } + function bindParameter(node) { + 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 (ts.isBindingPattern(node.name)) { + bindAnonymousDeclaration(node, 1 /* FunctionScopedVariable */, getDestructuringParameterName(node)); + } + else { + declareSymbolAndAddToSymbolTable(node, 1 /* FunctionScopedVariable */, 107455 /* ParameterExcludes */); + } + // If this is a property-parameter, then also declare the property symbol into the + // containing class. + if (node.flags & 112 /* AccessibilityModifier */ && + node.parent.kind === 144 /* Constructor */ && + ts.isClassLike(node.parent.parent)) { + var classDeclaration = node.parent.parent; + declareSymbol(classDeclaration.symbol.members, classDeclaration.symbol, node, 4 /* Property */, 107455 /* PropertyExcludes */); + } + } + function bindPropertyOrMethodOrAccessor(node, symbolFlags, symbolExcludes) { + return ts.hasDynamicName(node) + ? bindAnonymousDeclaration(node, symbolFlags, "__computed") + : declareSymbolAndAddToSymbolTable(node, symbolFlags, symbolExcludes); + } + } +})(ts || (ts = {})); +/// +/// +/* @internal */ +var ts; +(function (ts) { + function getDeclarationOfKind(symbol, kind) { + var declarations = symbol.declarations; + if (declarations) { + for (var _i = 0; _i < declarations.length; _i++) { + var declaration = declarations[_i]; + if (declaration.kind === kind) { + return declaration; + } + } + } + return undefined; + } + ts.getDeclarationOfKind = getDeclarationOfKind; + // Pool writers to avoid needing to allocate them for every symbol we write. + var stringWriters = []; + function getSingleLineStringWriter() { + if (stringWriters.length === 0) { + var str = ""; + var writeText = function (text) { return str += text; }; + return { + string: function () { return str; }, + writeKeyword: writeText, + writeOperator: writeText, + writePunctuation: writeText, + writeSpace: writeText, + writeStringLiteral: writeText, + writeParameter: writeText, + writeSymbol: writeText, + // Completely ignore indentation for string writers. And map newlines to + // a single space. + writeLine: function () { return str += " "; }, + increaseIndent: function () { }, + decreaseIndent: function () { }, + clear: function () { return str = ""; }, + trackSymbol: function () { }, + reportInaccessibleThisError: function () { } + }; + } + return stringWriters.pop(); + } + ts.getSingleLineStringWriter = getSingleLineStringWriter; + function releaseStringWriter(writer) { + writer.clear(); + stringWriters.push(writer); + } + ts.releaseStringWriter = releaseStringWriter; + function getFullWidth(node) { + return node.end - node.pos; + } + ts.getFullWidth = getFullWidth; + function arrayIsEqualTo(array1, array2, equaler) { + if (!array1 || !array2) { + return array1 === array2; + } + if (array1.length !== array2.length) { + return false; + } + for (var i = 0; i < array1.length; ++i) { + var equals = equaler ? equaler(array1[i], array2[i]) : array1[i] === array2[i]; + if (!equals) { + return false; + } + } + return true; + } + ts.arrayIsEqualTo = arrayIsEqualTo; + function hasResolvedModule(sourceFile, moduleNameText) { + return sourceFile.resolvedModules && ts.hasProperty(sourceFile.resolvedModules, moduleNameText); + } + ts.hasResolvedModule = hasResolvedModule; + function getResolvedModule(sourceFile, moduleNameText) { + return hasResolvedModule(sourceFile, moduleNameText) ? sourceFile.resolvedModules[moduleNameText] : undefined; + } + ts.getResolvedModule = getResolvedModule; + function setResolvedModule(sourceFile, moduleNameText, resolvedModule) { + if (!sourceFile.resolvedModules) { + sourceFile.resolvedModules = {}; + } + sourceFile.resolvedModules[moduleNameText] = resolvedModule; + } + ts.setResolvedModule = setResolvedModule; + // Returns true if this node contains a parse error anywhere underneath it. + function containsParseError(node) { + aggregateChildData(node); + return (node.parserContextFlags & 64 /* ThisNodeOrAnySubNodesHasError */) !== 0; + } + ts.containsParseError = containsParseError; + function aggregateChildData(node) { + if (!(node.parserContextFlags & 128 /* HasAggregatedChildData */)) { + // A node is considered to contain a parse error if: + // a) the parser explicitly marked that it had an error + // b) any of it's children reported that it had an error. + var thisNodeOrAnySubNodesHasError = ((node.parserContextFlags & 16 /* ThisNodeHasError */) !== 0) || + ts.forEachChild(node, containsParseError); + // If so, mark ourselves accordingly. + if (thisNodeOrAnySubNodesHasError) { + node.parserContextFlags |= 64 /* ThisNodeOrAnySubNodesHasError */; + } + // Also mark that we've propogated the child information to this node. This way we can + // always consult the bit directly on this node without needing to check its children + // again. + node.parserContextFlags |= 128 /* HasAggregatedChildData */; + } + } + function getSourceFileOfNode(node) { + while (node && node.kind !== 248 /* SourceFile */) { + node = node.parent; + } + return node; + } + ts.getSourceFileOfNode = getSourceFileOfNode; + function getStartPositionOfLine(line, sourceFile) { + ts.Debug.assert(line >= 0); + return ts.getLineStarts(sourceFile)[line]; + } + ts.getStartPositionOfLine = getStartPositionOfLine; + // This is a useful function for debugging purposes. + function nodePosToString(node) { + var file = getSourceFileOfNode(node); + var loc = ts.getLineAndCharacterOfPosition(file, node.pos); + return file.fileName + "(" + (loc.line + 1) + "," + (loc.character + 1) + ")"; + } + ts.nodePosToString = nodePosToString; + function getStartPosOfNode(node) { + return node.pos; + } + ts.getStartPosOfNode = getStartPosOfNode; + // Returns true if this node is missing from the actual source code. A 'missing' node is different + // from 'undefined/defined'. When a node is undefined (which can happen for optional nodes + // in the tree), it is definitely missing. However, a node may be defined, but still be + // missing. This happens whenever the parser knows it needs to parse something, but can't + // get anything in the source code that it expects at that location. For example: + // + // let a: ; + // + // Here, the Type in the Type-Annotation is not-optional (as there is a colon in the source + // code). So the parser will attempt to parse out a type, and will create an actual node. + // However, this node will be 'missing' in the sense that no actual source-code/tokens are + // contained within it. + function nodeIsMissing(node) { + if (!node) { + return true; + } + return node.pos === node.end && node.pos >= 0 && node.kind !== 1 /* EndOfFileToken */; + } + ts.nodeIsMissing = nodeIsMissing; + function nodeIsPresent(node) { + return !nodeIsMissing(node); + } + ts.nodeIsPresent = nodeIsPresent; + function getTokenPosOfNode(node, sourceFile) { + // With nodes that have no width (i.e. 'Missing' nodes), we actually *don't* + // want to skip trivia because this will launch us forward to the next token. + if (nodeIsMissing(node)) { + return node.pos; + } + return ts.skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.pos); + } + ts.getTokenPosOfNode = getTokenPosOfNode; + function getNonDecoratorTokenPosOfNode(node, sourceFile) { + if (nodeIsMissing(node) || !node.decorators) { + return getTokenPosOfNode(node, sourceFile); + } + return ts.skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.decorators.end); + } + ts.getNonDecoratorTokenPosOfNode = getNonDecoratorTokenPosOfNode; + function getSourceTextOfNodeFromSourceFile(sourceFile, node, includeTrivia) { + if (includeTrivia === void 0) { includeTrivia = false; } + if (nodeIsMissing(node)) { + return ""; + } + var text = sourceFile.text; + return text.substring(includeTrivia ? node.pos : ts.skipTrivia(text, node.pos), node.end); + } + ts.getSourceTextOfNodeFromSourceFile = getSourceTextOfNodeFromSourceFile; + function getTextOfNodeFromSourceText(sourceText, node) { + if (nodeIsMissing(node)) { + return ""; + } + return sourceText.substring(ts.skipTrivia(sourceText, node.pos), node.end); + } + ts.getTextOfNodeFromSourceText = getTextOfNodeFromSourceText; + function getTextOfNode(node, includeTrivia) { + if (includeTrivia === void 0) { includeTrivia = false; } + return getSourceTextOfNodeFromSourceFile(getSourceFileOfNode(node), node, includeTrivia); + } + ts.getTextOfNode = getTextOfNode; + // Add an extra underscore to identifiers that start with two underscores to avoid issues with magic names like '__proto__' + function escapeIdentifier(identifier) { + return identifier.length >= 2 && identifier.charCodeAt(0) === 95 /* _ */ && identifier.charCodeAt(1) === 95 /* _ */ ? "_" + identifier : identifier; + } + ts.escapeIdentifier = escapeIdentifier; + // Remove extra underscore from escaped identifier + function unescapeIdentifier(identifier) { + return identifier.length >= 3 && identifier.charCodeAt(0) === 95 /* _ */ && identifier.charCodeAt(1) === 95 /* _ */ && identifier.charCodeAt(2) === 95 /* _ */ ? identifier.substr(1) : identifier; + } + ts.unescapeIdentifier = unescapeIdentifier; + // Make an identifier from an external module name by extracting the string after the last "/" and replacing + // all non-alphanumeric characters with underscores + function makeIdentifierFromModuleName(moduleName) { + return ts.getBaseFileName(moduleName).replace(/^(\d)/, "_$1").replace(/\W/g, "_"); + } + ts.makeIdentifierFromModuleName = makeIdentifierFromModuleName; + function isBlockOrCatchScoped(declaration) { + return (getCombinedNodeFlags(declaration) & 49152 /* BlockScoped */) !== 0 || + isCatchClauseVariableDeclaration(declaration); + } + ts.isBlockOrCatchScoped = isBlockOrCatchScoped; + // Gets the nearest enclosing block scope container that has the provided node + // as a descendant, that is not the provided node. + function getEnclosingBlockScopeContainer(node) { + var current = node.parent; + while (current) { + if (isFunctionLike(current)) { + return current; + } + switch (current.kind) { + case 248 /* SourceFile */: + case 220 /* CaseBlock */: + case 244 /* CatchClause */: + case 218 /* ModuleDeclaration */: + case 199 /* ForStatement */: + case 200 /* ForInStatement */: + case 201 /* ForOfStatement */: + return current; + case 192 /* Block */: + // function block is not considered block-scope container + // see comment in binder.ts: bind(...), case for SyntaxKind.Block + if (!isFunctionLike(current.parent)) { + return current; + } + } + current = current.parent; + } + } + ts.getEnclosingBlockScopeContainer = getEnclosingBlockScopeContainer; + function isCatchClauseVariableDeclaration(declaration) { + return declaration && + declaration.kind === 211 /* VariableDeclaration */ && + declaration.parent && + declaration.parent.kind === 244 /* CatchClause */; + } + ts.isCatchClauseVariableDeclaration = isCatchClauseVariableDeclaration; + // 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. + function declarationNameToString(name) { + return getFullWidth(name) === 0 ? "(Missing)" : getTextOfNode(name); + } + ts.declarationNameToString = declarationNameToString; + function createDiagnosticForNode(node, message, arg0, arg1, arg2) { + var sourceFile = getSourceFileOfNode(node); + var span = getErrorSpanForNode(sourceFile, node); + return ts.createFileDiagnostic(sourceFile, span.start, span.length, message, arg0, arg1, arg2); + } + ts.createDiagnosticForNode = createDiagnosticForNode; + function createDiagnosticForNodeFromMessageChain(node, messageChain) { + var sourceFile = getSourceFileOfNode(node); + var span = getErrorSpanForNode(sourceFile, node); + return { + file: sourceFile, + start: span.start, + length: span.length, + code: messageChain.code, + category: messageChain.category, + messageText: messageChain.next ? messageChain : messageChain.messageText + }; + } + ts.createDiagnosticForNodeFromMessageChain = createDiagnosticForNodeFromMessageChain; + function getSpanOfTokenAtPosition(sourceFile, pos) { + var scanner = ts.createScanner(sourceFile.languageVersion, /*skipTrivia*/ true, sourceFile.languageVariant, sourceFile.text, /*onError:*/ undefined, pos); + scanner.scan(); + var start = scanner.getTokenPos(); + return ts.createTextSpanFromBounds(start, scanner.getTextPos()); + } + ts.getSpanOfTokenAtPosition = getSpanOfTokenAtPosition; + function getErrorSpanForNode(sourceFile, node) { + var errorNode = node; + switch (node.kind) { + case 248 /* SourceFile */: + var pos_1 = ts.skipTrivia(sourceFile.text, 0, /*stopAfterLineBreak*/ false); + if (pos_1 === sourceFile.text.length) { + // file is empty - return span for the beginning of the file + return ts.createTextSpan(0, 0); + } + return getSpanOfTokenAtPosition(sourceFile, pos_1); + // This list is a work in progress. Add missing node kinds to improve their error + // spans. + case 211 /* VariableDeclaration */: + case 163 /* BindingElement */: + case 214 /* ClassDeclaration */: + case 186 /* ClassExpression */: + case 215 /* InterfaceDeclaration */: + case 218 /* ModuleDeclaration */: + case 217 /* EnumDeclaration */: + case 247 /* EnumMember */: + case 213 /* FunctionDeclaration */: + case 173 /* FunctionExpression */: + errorNode = node.name; + break; + } + if (errorNode === undefined) { + // If we don't have a better node, then just set the error on the first token of + // construct. + return getSpanOfTokenAtPosition(sourceFile, node.pos); + } + var pos = nodeIsMissing(errorNode) + ? errorNode.pos + : ts.skipTrivia(sourceFile.text, errorNode.pos); + return ts.createTextSpanFromBounds(pos, errorNode.end); + } + ts.getErrorSpanForNode = getErrorSpanForNode; + function isExternalModule(file) { + return file.externalModuleIndicator !== undefined; + } + ts.isExternalModule = isExternalModule; + function isDeclarationFile(file) { + return (file.flags & 8192 /* DeclarationFile */) !== 0; + } + ts.isDeclarationFile = isDeclarationFile; + function isConstEnumDeclaration(node) { + return node.kind === 217 /* EnumDeclaration */ && isConst(node); + } + ts.isConstEnumDeclaration = isConstEnumDeclaration; + function walkUpBindingElementsAndPatterns(node) { + while (node && (node.kind === 163 /* BindingElement */ || isBindingPattern(node))) { + node = node.parent; + } + return node; + } + // Returns the node flags for this node and all relevant parent nodes. This is done so that + // nodes like variable declarations and binding elements can returned a view of their flags + // that includes the modifiers from their container. i.e. flags like export/declare aren't + // stored on the variable declaration directly, but on the containing variable statement + // (if it has one). Similarly, flags for let/const are store on the variable declaration + // list. By calling this function, all those flags are combined so that the client can treat + // the node as if it actually had those flags. + function getCombinedNodeFlags(node) { + node = walkUpBindingElementsAndPatterns(node); + var flags = node.flags; + if (node.kind === 211 /* VariableDeclaration */) { + node = node.parent; + } + if (node && node.kind === 212 /* VariableDeclarationList */) { + flags |= node.flags; + node = node.parent; + } + if (node && node.kind === 193 /* VariableStatement */) { + flags |= node.flags; + } + return flags; + } + ts.getCombinedNodeFlags = getCombinedNodeFlags; + function isConst(node) { + return !!(getCombinedNodeFlags(node) & 32768 /* Const */); + } + ts.isConst = isConst; + function isLet(node) { + return !!(getCombinedNodeFlags(node) & 16384 /* Let */); + } + ts.isLet = isLet; + function isPrologueDirective(node) { + return node.kind === 195 /* ExpressionStatement */ && node.expression.kind === 9 /* StringLiteral */; + } + ts.isPrologueDirective = isPrologueDirective; + function getLeadingCommentRangesOfNode(node, sourceFileOfNode) { + return ts.getLeadingCommentRanges(sourceFileOfNode.text, node.pos); + } + ts.getLeadingCommentRangesOfNode = getLeadingCommentRangesOfNode; + function getJsDocComments(node, sourceFileOfNode) { + var commentRanges = (node.kind === 138 /* Parameter */ || node.kind === 137 /* TypeParameter */) ? + ts.concatenate(ts.getTrailingCommentRanges(sourceFileOfNode.text, node.pos), ts.getLeadingCommentRanges(sourceFileOfNode.text, node.pos)) : + getLeadingCommentRangesOfNode(node, sourceFileOfNode); + return ts.filter(commentRanges, isJsDocComment); + function isJsDocComment(comment) { + // True if the comment starts with '/**' but not if it is '/**/' + return sourceFileOfNode.text.charCodeAt(comment.pos + 1) === 42 /* asterisk */ && + sourceFileOfNode.text.charCodeAt(comment.pos + 2) === 42 /* asterisk */ && + sourceFileOfNode.text.charCodeAt(comment.pos + 3) !== 47 /* slash */; + } + } + ts.getJsDocComments = getJsDocComments; + ts.fullTripleSlashReferencePathRegEx = /^(\/\/\/\s*/; + ts.fullTripleSlashAMDReferencePathRegEx = /^(\/\/\/\s*/; + function isTypeNode(node) { + if (151 /* FirstTypeNode */ <= node.kind && node.kind <= 160 /* LastTypeNode */) { + return true; + } + switch (node.kind) { + case 117 /* AnyKeyword */: + case 128 /* NumberKeyword */: + case 130 /* StringKeyword */: + case 120 /* BooleanKeyword */: + case 131 /* SymbolKeyword */: + return true; + case 103 /* VoidKeyword */: + return node.parent.kind !== 177 /* VoidExpression */; + case 9 /* StringLiteral */: + // Specialized signatures can have string literals as their parameters' type names + return node.parent.kind === 138 /* Parameter */; + case 188 /* ExpressionWithTypeArguments */: + return !isExpressionWithTypeArgumentsInClassExtendsClause(node); + // Identifiers and qualified names may be type nodes, depending on their context. Climb + // above them to find the lowest container + case 69 /* Identifier */: + // If the identifier is the RHS of a qualified name, then it's a type iff its parent is. + if (node.parent.kind === 135 /* QualifiedName */ && node.parent.right === node) { + node = node.parent; + } + else if (node.parent.kind === 166 /* 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 === 135 /* QualifiedName */ || node.kind === 166 /* PropertyAccessExpression */, "'node' was expected to be a qualified name, identifier or property access in 'isTypeNode'."); + case 135 /* QualifiedName */: + case 166 /* PropertyAccessExpression */: + case 97 /* ThisKeyword */: + var parent_1 = node.parent; + if (parent_1.kind === 154 /* TypeQuery */) { + return false; + } + // Do not recursively call isTypeNode on the parent. In the example: + // + // let a: A.B.C; + // + // Calling isTypeNode would consider the qualified name A.B a type node. Only C or + // A.B.C is a type node. + if (151 /* FirstTypeNode */ <= parent_1.kind && parent_1.kind <= 160 /* LastTypeNode */) { + return true; + } + switch (parent_1.kind) { + case 188 /* ExpressionWithTypeArguments */: + return !isExpressionWithTypeArgumentsInClassExtendsClause(parent_1); + case 137 /* TypeParameter */: + return node === parent_1.constraint; + case 141 /* PropertyDeclaration */: + case 140 /* PropertySignature */: + case 138 /* Parameter */: + case 211 /* VariableDeclaration */: + return node === parent_1.type; + case 213 /* FunctionDeclaration */: + case 173 /* FunctionExpression */: + case 174 /* ArrowFunction */: + case 144 /* Constructor */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: + return node === parent_1.type; + case 147 /* CallSignature */: + case 148 /* ConstructSignature */: + case 149 /* IndexSignature */: + return node === parent_1.type; + case 171 /* TypeAssertionExpression */: + return node === parent_1.type; + case 168 /* CallExpression */: + case 169 /* NewExpression */: + return parent_1.typeArguments && ts.indexOf(parent_1.typeArguments, node) >= 0; + case 170 /* TaggedTemplateExpression */: + // TODO (drosen): TaggedTemplateExpressions may eventually support type arguments. + return false; + } + } + return false; + } + ts.isTypeNode = isTypeNode; + // Warning: This has the same semantics as the forEach family of functions, + // in that traversal terminates in the event that 'visitor' supplies a truthy value. + function forEachReturnStatement(body, visitor) { + return traverse(body); + function traverse(node) { + switch (node.kind) { + case 204 /* ReturnStatement */: + return visitor(node); + case 220 /* CaseBlock */: + case 192 /* Block */: + case 196 /* IfStatement */: + case 197 /* DoStatement */: + case 198 /* WhileStatement */: + case 199 /* ForStatement */: + case 200 /* ForInStatement */: + case 201 /* ForOfStatement */: + case 205 /* WithStatement */: + case 206 /* SwitchStatement */: + case 241 /* CaseClause */: + case 242 /* DefaultClause */: + case 207 /* LabeledStatement */: + case 209 /* TryStatement */: + case 244 /* CatchClause */: + return ts.forEachChild(node, traverse); + } + } + } + ts.forEachReturnStatement = forEachReturnStatement; + function forEachYieldExpression(body, visitor) { + return traverse(body); + function traverse(node) { + switch (node.kind) { + case 184 /* YieldExpression */: + visitor(node); + var operand = node.expression; + if (operand) { + traverse(operand); + } + case 217 /* EnumDeclaration */: + case 215 /* InterfaceDeclaration */: + case 218 /* ModuleDeclaration */: + case 216 /* TypeAliasDeclaration */: + case 214 /* ClassDeclaration */: + case 186 /* ClassExpression */: + // These are not allowed inside a generator now, but eventually they may be allowed + // as local types. Regardless, any yield statements contained within them should be + // skipped in this traversal. + return; + default: + if (isFunctionLike(node)) { + var name_5 = node.name; + if (name_5 && name_5.kind === 136 /* ComputedPropertyName */) { + // Note that we will not include methods/accessors of a class because they would require + // first descending into the class. This is by design. + traverse(name_5.expression); + return; + } + } + else if (!isTypeNode(node)) { + // This is the general case, which should include mostly expressions and statements. + // Also includes NodeArrays. + ts.forEachChild(node, traverse); + } + } + } + } + ts.forEachYieldExpression = forEachYieldExpression; + function isVariableLike(node) { + if (node) { + switch (node.kind) { + case 163 /* BindingElement */: + case 247 /* EnumMember */: + case 138 /* Parameter */: + case 245 /* PropertyAssignment */: + case 141 /* PropertyDeclaration */: + case 140 /* PropertySignature */: + case 246 /* ShorthandPropertyAssignment */: + case 211 /* VariableDeclaration */: + return true; + } + } + return false; + } + ts.isVariableLike = isVariableLike; + function isAccessor(node) { + return node && (node.kind === 145 /* GetAccessor */ || node.kind === 146 /* SetAccessor */); + } + ts.isAccessor = isAccessor; + function isClassLike(node) { + return node && (node.kind === 214 /* ClassDeclaration */ || node.kind === 186 /* ClassExpression */); + } + ts.isClassLike = isClassLike; + function isFunctionLike(node) { + if (node) { + switch (node.kind) { + case 144 /* Constructor */: + case 173 /* FunctionExpression */: + case 213 /* FunctionDeclaration */: + case 174 /* ArrowFunction */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: + case 147 /* CallSignature */: + case 148 /* ConstructSignature */: + case 149 /* IndexSignature */: + case 152 /* FunctionType */: + case 153 /* ConstructorType */: + return true; + } + } + return false; + } + ts.isFunctionLike = isFunctionLike; + function introducesArgumentsExoticObject(node) { + switch (node.kind) { + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: + case 144 /* Constructor */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: + case 213 /* FunctionDeclaration */: + case 173 /* FunctionExpression */: + return true; + } + return false; + } + ts.introducesArgumentsExoticObject = introducesArgumentsExoticObject; + function isIterationStatement(node, lookInLabeledStatements) { + switch (node.kind) { + case 199 /* ForStatement */: + case 200 /* ForInStatement */: + case 201 /* ForOfStatement */: + case 197 /* DoStatement */: + case 198 /* WhileStatement */: + return true; + case 207 /* LabeledStatement */: + return lookInLabeledStatements && isIterationStatement(node.statement, lookInLabeledStatements); + } + return false; + } + ts.isIterationStatement = isIterationStatement; + function isFunctionBlock(node) { + return node && node.kind === 192 /* Block */ && isFunctionLike(node.parent); + } + ts.isFunctionBlock = isFunctionBlock; + function isObjectLiteralMethod(node) { + return node && node.kind === 143 /* MethodDeclaration */ && node.parent.kind === 165 /* ObjectLiteralExpression */; + } + ts.isObjectLiteralMethod = isObjectLiteralMethod; + function getContainingFunction(node) { + while (true) { + node = node.parent; + if (!node || isFunctionLike(node)) { + return node; + } + } + } + ts.getContainingFunction = getContainingFunction; + function getContainingClass(node) { + while (true) { + node = node.parent; + if (!node || isClassLike(node)) { + return node; + } + } + } + ts.getContainingClass = getContainingClass; + function getThisContainer(node, includeArrowFunctions) { + while (true) { + node = node.parent; + if (!node) { + return undefined; + } + switch (node.kind) { + case 136 /* ComputedPropertyName */: + // If the grandparent node is an object literal (as opposed to a class), + // then the computed property is not a 'this' container. + // A computed property name in a class needs to be a this container + // so that we can error on it. + if (isClassLike(node.parent.parent)) { + return node; + } + // If this is a computed property, then the parent should not + // make it a this container. The parent might be a property + // in an object literal, like a method or accessor. But in order for + // such a parent to be a this container, the reference must be in + // the *body* of the container. + node = node.parent; + break; + case 139 /* Decorator */: + // Decorators are always applied outside of the body of a class or method. + if (node.parent.kind === 138 /* Parameter */ && isClassElement(node.parent.parent)) { + // If the decorator's parent is a Parameter, we resolve the this container from + // the grandparent class declaration. + node = node.parent.parent; + } + else if (isClassElement(node.parent)) { + // If the decorator's parent is a class element, we resolve the 'this' container + // from the parent class declaration. + node = node.parent; + } + break; + case 174 /* ArrowFunction */: + if (!includeArrowFunctions) { + continue; + } + // Fall through + case 213 /* FunctionDeclaration */: + case 173 /* FunctionExpression */: + case 218 /* ModuleDeclaration */: + case 141 /* PropertyDeclaration */: + case 140 /* PropertySignature */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: + case 144 /* Constructor */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: + case 147 /* CallSignature */: + case 148 /* ConstructSignature */: + case 149 /* IndexSignature */: + case 217 /* EnumDeclaration */: + case 248 /* SourceFile */: + return node; + } + } + } + ts.getThisContainer = getThisContainer; + function getSuperContainer(node, includeFunctions) { + while (true) { + node = node.parent; + if (!node) + return node; + switch (node.kind) { + case 136 /* ComputedPropertyName */: + // If the grandparent node is an object literal (as opposed to a class), + // then the computed property is not a 'super' container. + // A computed property name in a class needs to be a super container + // so that we can error on it. + if (isClassLike(node.parent.parent)) { + return node; + } + // If this is a computed property, then the parent should not + // make it a super container. The parent might be a property + // in an object literal, like a method or accessor. But in order for + // such a parent to be a super container, the reference must be in + // the *body* of the container. + node = node.parent; + break; + case 139 /* Decorator */: + // Decorators are always applied outside of the body of a class or method. + if (node.parent.kind === 138 /* Parameter */ && isClassElement(node.parent.parent)) { + // If the decorator's parent is a Parameter, we resolve the this container from + // the grandparent class declaration. + node = node.parent.parent; + } + else if (isClassElement(node.parent)) { + // If the decorator's parent is a class element, we resolve the 'this' container + // from the parent class declaration. + node = node.parent; + } + break; + case 213 /* FunctionDeclaration */: + case 173 /* FunctionExpression */: + case 174 /* ArrowFunction */: + if (!includeFunctions) { + continue; + } + case 141 /* PropertyDeclaration */: + case 140 /* PropertySignature */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: + case 144 /* Constructor */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: + return node; + } + } + } + ts.getSuperContainer = getSuperContainer; + function getEntityNameFromTypeNode(node) { + if (node) { + switch (node.kind) { + case 151 /* TypeReference */: + return node.typeName; + case 188 /* ExpressionWithTypeArguments */: + return node.expression; + case 69 /* Identifier */: + case 135 /* QualifiedName */: + return node; + } + } + return undefined; + } + ts.getEntityNameFromTypeNode = getEntityNameFromTypeNode; + function getInvokedExpression(node) { + if (node.kind === 170 /* TaggedTemplateExpression */) { + return node.tag; + } + // Will either be a CallExpression, NewExpression, or Decorator. + return node.expression; + } + ts.getInvokedExpression = getInvokedExpression; + function nodeCanBeDecorated(node) { + switch (node.kind) { + case 214 /* ClassDeclaration */: + // classes are valid targets + return true; + case 141 /* PropertyDeclaration */: + // property declarations are valid if their parent is a class declaration. + return node.parent.kind === 214 /* ClassDeclaration */; + case 138 /* Parameter */: + // if the parameter's parent has a body and its grandparent is a class declaration, this is a valid target; + return node.parent.body && node.parent.parent.kind === 214 /* ClassDeclaration */; + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: + case 143 /* MethodDeclaration */: + // if this method has a body and its parent is a class declaration, this is a valid target. + return node.body && node.parent.kind === 214 /* ClassDeclaration */; + } + return false; + } + ts.nodeCanBeDecorated = nodeCanBeDecorated; + function nodeIsDecorated(node) { + switch (node.kind) { + case 214 /* ClassDeclaration */: + if (node.decorators) { + return true; + } + return false; + case 141 /* PropertyDeclaration */: + case 138 /* Parameter */: + if (node.decorators) { + return true; + } + return false; + case 145 /* GetAccessor */: + if (node.body && node.decorators) { + return true; + } + return false; + case 143 /* MethodDeclaration */: + case 146 /* SetAccessor */: + if (node.body && node.decorators) { + return true; + } + return false; + } + return false; + } + ts.nodeIsDecorated = nodeIsDecorated; + function childIsDecorated(node) { + switch (node.kind) { + case 214 /* ClassDeclaration */: + return ts.forEach(node.members, nodeOrChildIsDecorated); + case 143 /* MethodDeclaration */: + case 146 /* SetAccessor */: + return ts.forEach(node.parameters, nodeIsDecorated); + } + return false; + } + ts.childIsDecorated = childIsDecorated; + function nodeOrChildIsDecorated(node) { + return nodeIsDecorated(node) || childIsDecorated(node); + } + ts.nodeOrChildIsDecorated = nodeOrChildIsDecorated; + function isPropertyAccessExpression(node) { + return node.kind === 166 /* PropertyAccessExpression */; + } + ts.isPropertyAccessExpression = isPropertyAccessExpression; + function isElementAccessExpression(node) { + return node.kind === 167 /* ElementAccessExpression */; + } + ts.isElementAccessExpression = isElementAccessExpression; + function isExpression(node) { + switch (node.kind) { + case 95 /* SuperKeyword */: + case 93 /* NullKeyword */: + case 99 /* TrueKeyword */: + case 84 /* FalseKeyword */: + case 10 /* RegularExpressionLiteral */: + case 164 /* ArrayLiteralExpression */: + case 165 /* ObjectLiteralExpression */: + case 166 /* PropertyAccessExpression */: + case 167 /* ElementAccessExpression */: + case 168 /* CallExpression */: + case 169 /* NewExpression */: + case 170 /* TaggedTemplateExpression */: + case 189 /* AsExpression */: + case 171 /* TypeAssertionExpression */: + case 172 /* ParenthesizedExpression */: + case 173 /* FunctionExpression */: + case 186 /* ClassExpression */: + case 174 /* ArrowFunction */: + case 177 /* VoidExpression */: + case 175 /* DeleteExpression */: + case 176 /* TypeOfExpression */: + case 179 /* PrefixUnaryExpression */: + case 180 /* PostfixUnaryExpression */: + case 181 /* BinaryExpression */: + case 182 /* ConditionalExpression */: + case 185 /* SpreadElementExpression */: + case 183 /* TemplateExpression */: + case 11 /* NoSubstitutionTemplateLiteral */: + case 187 /* OmittedExpression */: + case 233 /* JsxElement */: + case 234 /* JsxSelfClosingElement */: + case 184 /* YieldExpression */: + case 178 /* AwaitExpression */: + return true; + case 135 /* QualifiedName */: + while (node.parent.kind === 135 /* QualifiedName */) { + node = node.parent; + } + return node.parent.kind === 154 /* TypeQuery */; + case 69 /* Identifier */: + if (node.parent.kind === 154 /* TypeQuery */) { + return true; + } + // fall through + case 8 /* NumericLiteral */: + case 9 /* StringLiteral */: + case 97 /* ThisKeyword */: + var parent_2 = node.parent; + switch (parent_2.kind) { + case 211 /* VariableDeclaration */: + case 138 /* Parameter */: + case 141 /* PropertyDeclaration */: + case 140 /* PropertySignature */: + case 247 /* EnumMember */: + case 245 /* PropertyAssignment */: + case 163 /* BindingElement */: + return parent_2.initializer === node; + case 195 /* ExpressionStatement */: + case 196 /* IfStatement */: + case 197 /* DoStatement */: + case 198 /* WhileStatement */: + case 204 /* ReturnStatement */: + case 205 /* WithStatement */: + case 206 /* SwitchStatement */: + case 241 /* CaseClause */: + case 208 /* ThrowStatement */: + case 206 /* SwitchStatement */: + return parent_2.expression === node; + case 199 /* ForStatement */: + var forStatement = parent_2; + return (forStatement.initializer === node && forStatement.initializer.kind !== 212 /* VariableDeclarationList */) || + forStatement.condition === node || + forStatement.incrementor === node; + case 200 /* ForInStatement */: + case 201 /* ForOfStatement */: + var forInStatement = parent_2; + return (forInStatement.initializer === node && forInStatement.initializer.kind !== 212 /* VariableDeclarationList */) || + forInStatement.expression === node; + case 171 /* TypeAssertionExpression */: + case 189 /* AsExpression */: + return node === parent_2.expression; + case 190 /* TemplateSpan */: + return node === parent_2.expression; + case 136 /* ComputedPropertyName */: + return node === parent_2.expression; + case 139 /* Decorator */: + case 240 /* JsxExpression */: + case 239 /* JsxSpreadAttribute */: + return true; + case 188 /* ExpressionWithTypeArguments */: + return parent_2.expression === node && isExpressionWithTypeArgumentsInClassExtendsClause(parent_2); + default: + if (isExpression(parent_2)) { + return true; + } + } + } + return false; + } + ts.isExpression = isExpression; + function isExternalModuleNameRelative(moduleName) { + // TypeScript 1.0 spec (April 2014): 11.2.1 + // An external module name is "relative" if the first term is "." or "..". + return moduleName.substr(0, 2) === "./" || moduleName.substr(0, 3) === "../" || moduleName.substr(0, 2) === ".\\" || moduleName.substr(0, 3) === "..\\"; + } + ts.isExternalModuleNameRelative = isExternalModuleNameRelative; + function isInstantiatedModule(node, preserveConstEnums) { + var moduleState = ts.getModuleInstanceState(node); + return moduleState === 1 /* Instantiated */ || + (preserveConstEnums && moduleState === 2 /* ConstEnumOnly */); + } + ts.isInstantiatedModule = isInstantiatedModule; + function isExternalModuleImportEqualsDeclaration(node) { + return node.kind === 221 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 232 /* ExternalModuleReference */; + } + ts.isExternalModuleImportEqualsDeclaration = isExternalModuleImportEqualsDeclaration; + function getExternalModuleImportEqualsDeclarationExpression(node) { + ts.Debug.assert(isExternalModuleImportEqualsDeclaration(node)); + return node.moduleReference.expression; + } + ts.getExternalModuleImportEqualsDeclarationExpression = getExternalModuleImportEqualsDeclarationExpression; + function isInternalModuleImportEqualsDeclaration(node) { + return node.kind === 221 /* ImportEqualsDeclaration */ && node.moduleReference.kind !== 232 /* ExternalModuleReference */; + } + ts.isInternalModuleImportEqualsDeclaration = isInternalModuleImportEqualsDeclaration; + function getExternalModuleName(node) { + if (node.kind === 222 /* ImportDeclaration */) { + return node.moduleSpecifier; + } + if (node.kind === 221 /* ImportEqualsDeclaration */) { + var reference = node.moduleReference; + if (reference.kind === 232 /* ExternalModuleReference */) { + return reference.expression; + } + } + if (node.kind === 228 /* ExportDeclaration */) { + return node.moduleSpecifier; + } + } + ts.getExternalModuleName = getExternalModuleName; + function hasQuestionToken(node) { + if (node) { + switch (node.kind) { + case 138 /* Parameter */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: + case 246 /* ShorthandPropertyAssignment */: + case 245 /* PropertyAssignment */: + case 141 /* PropertyDeclaration */: + case 140 /* PropertySignature */: + return node.questionToken !== undefined; + } + } + return false; + } + ts.hasQuestionToken = hasQuestionToken; + function isJSDocConstructSignature(node) { + return node.kind === 261 /* JSDocFunctionType */ && + node.parameters.length > 0 && + node.parameters[0].type.kind === 263 /* JSDocConstructorType */; + } + ts.isJSDocConstructSignature = isJSDocConstructSignature; + function getJSDocTag(node, kind) { + if (node && node.jsDocComment) { + for (var _i = 0, _a = node.jsDocComment.tags; _i < _a.length; _i++) { + var tag = _a[_i]; + if (tag.kind === kind) { + return tag; + } + } + } + } + function getJSDocTypeTag(node) { + return getJSDocTag(node, 269 /* JSDocTypeTag */); + } + ts.getJSDocTypeTag = getJSDocTypeTag; + function getJSDocReturnTag(node) { + return getJSDocTag(node, 268 /* JSDocReturnTag */); + } + ts.getJSDocReturnTag = getJSDocReturnTag; + function getJSDocTemplateTag(node) { + return getJSDocTag(node, 270 /* JSDocTemplateTag */); + } + ts.getJSDocTemplateTag = getJSDocTemplateTag; + function getCorrespondingJSDocParameterTag(parameter) { + if (parameter.name && parameter.name.kind === 69 /* Identifier */) { + // If it's a parameter, see if the parent has a jsdoc comment with an @param + // annotation. + var parameterName = parameter.name.text; + var docComment = parameter.parent.jsDocComment; + if (docComment) { + return ts.forEach(docComment.tags, function (t) { + if (t.kind === 267 /* JSDocParameterTag */) { + var parameterTag = t; + var name_6 = parameterTag.preParameterName || parameterTag.postParameterName; + if (name_6.text === parameterName) { + return t; + } + } + }); + } + } + } + ts.getCorrespondingJSDocParameterTag = getCorrespondingJSDocParameterTag; + function hasRestParameter(s) { + return isRestParameter(ts.lastOrUndefined(s.parameters)); + } + ts.hasRestParameter = hasRestParameter; + function isRestParameter(node) { + if (node) { + if (node.parserContextFlags & 32 /* JavaScriptFile */) { + if (node.type && node.type.kind === 262 /* JSDocVariadicType */) { + return true; + } + var paramTag = getCorrespondingJSDocParameterTag(node); + if (paramTag && paramTag.typeExpression) { + return paramTag.typeExpression.type.kind === 262 /* JSDocVariadicType */; + } + } + return node.dotDotDotToken !== undefined; + } + return false; + } + ts.isRestParameter = isRestParameter; + function isLiteralKind(kind) { + return 8 /* FirstLiteralToken */ <= kind && kind <= 11 /* LastLiteralToken */; + } + ts.isLiteralKind = isLiteralKind; + function isTextualLiteralKind(kind) { + return kind === 9 /* StringLiteral */ || kind === 11 /* NoSubstitutionTemplateLiteral */; + } + ts.isTextualLiteralKind = isTextualLiteralKind; + function isTemplateLiteralKind(kind) { + return 11 /* FirstTemplateToken */ <= kind && kind <= 14 /* LastTemplateToken */; + } + ts.isTemplateLiteralKind = isTemplateLiteralKind; + function isBindingPattern(node) { + return !!node && (node.kind === 162 /* ArrayBindingPattern */ || node.kind === 161 /* ObjectBindingPattern */); + } + ts.isBindingPattern = isBindingPattern; + function isInAmbientContext(node) { + while (node) { + if (node.flags & (2 /* Ambient */ | 8192 /* DeclarationFile */)) { + return true; + } + node = node.parent; + } + return false; + } + ts.isInAmbientContext = isInAmbientContext; + function isDeclaration(node) { + switch (node.kind) { + case 174 /* ArrowFunction */: + case 163 /* BindingElement */: + case 214 /* ClassDeclaration */: + case 186 /* ClassExpression */: + case 144 /* Constructor */: + case 217 /* EnumDeclaration */: + case 247 /* EnumMember */: + case 230 /* ExportSpecifier */: + case 213 /* FunctionDeclaration */: + case 173 /* FunctionExpression */: + case 145 /* GetAccessor */: + case 223 /* ImportClause */: + case 221 /* ImportEqualsDeclaration */: + case 226 /* ImportSpecifier */: + case 215 /* InterfaceDeclaration */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: + case 218 /* ModuleDeclaration */: + case 224 /* NamespaceImport */: + case 138 /* Parameter */: + case 245 /* PropertyAssignment */: + case 141 /* PropertyDeclaration */: + case 140 /* PropertySignature */: + case 146 /* SetAccessor */: + case 246 /* ShorthandPropertyAssignment */: + case 216 /* TypeAliasDeclaration */: + case 137 /* TypeParameter */: + case 211 /* VariableDeclaration */: + return true; + } + return false; + } + ts.isDeclaration = isDeclaration; + function isStatement(n) { + switch (n.kind) { + case 203 /* BreakStatement */: + case 202 /* ContinueStatement */: + case 210 /* DebuggerStatement */: + case 197 /* DoStatement */: + case 195 /* ExpressionStatement */: + case 194 /* EmptyStatement */: + case 200 /* ForInStatement */: + case 201 /* ForOfStatement */: + case 199 /* ForStatement */: + case 196 /* IfStatement */: + case 207 /* LabeledStatement */: + case 204 /* ReturnStatement */: + case 206 /* SwitchStatement */: + case 98 /* ThrowKeyword */: + case 209 /* TryStatement */: + case 193 /* VariableStatement */: + case 198 /* WhileStatement */: + case 205 /* WithStatement */: + case 227 /* ExportAssignment */: + return true; + default: + return false; + } + } + ts.isStatement = isStatement; + function isClassElement(n) { + switch (n.kind) { + case 144 /* Constructor */: + case 141 /* PropertyDeclaration */: + case 143 /* MethodDeclaration */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: + case 142 /* MethodSignature */: + case 149 /* IndexSignature */: + return true; + default: + return false; + } + } + ts.isClassElement = isClassElement; + // True if the given identifier, string literal, or number literal is the name of a declaration node + function isDeclarationName(name) { + if (name.kind !== 69 /* Identifier */ && name.kind !== 9 /* StringLiteral */ && name.kind !== 8 /* NumericLiteral */) { + return false; + } + var parent = name.parent; + if (parent.kind === 226 /* ImportSpecifier */ || parent.kind === 230 /* ExportSpecifier */) { + if (parent.propertyName) { + return true; + } + } + if (isDeclaration(parent)) { + return parent.name === name; + } + return false; + } + ts.isDeclarationName = isDeclarationName; + // Return true if the given identifier is classified as an IdentifierName + function isIdentifierName(node) { + var parent = node.parent; + switch (parent.kind) { + case 141 /* PropertyDeclaration */: + case 140 /* PropertySignature */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: + case 247 /* EnumMember */: + case 245 /* PropertyAssignment */: + case 166 /* PropertyAccessExpression */: + // Name in member declaration or property name in property access + return parent.name === node; + case 135 /* QualifiedName */: + // Name on right hand side of dot in a type query + if (parent.right === node) { + while (parent.kind === 135 /* QualifiedName */) { + parent = parent.parent; + } + return parent.kind === 154 /* TypeQuery */; + } + return false; + case 163 /* BindingElement */: + case 226 /* ImportSpecifier */: + // Property name in binding element or import specifier + return parent.propertyName === node; + case 230 /* ExportSpecifier */: + // Any name in an export specifier + return true; + } + return false; + } + ts.isIdentifierName = isIdentifierName; + // An alias symbol is created by one of the following declarations: + // import = ... + // import from ... + // import * as from ... + // import { x as } from ... + // export { x as } from ... + // export = ... + // export default ... + function isAliasSymbolDeclaration(node) { + return node.kind === 221 /* ImportEqualsDeclaration */ || + node.kind === 223 /* ImportClause */ && !!node.name || + node.kind === 224 /* NamespaceImport */ || + node.kind === 226 /* ImportSpecifier */ || + node.kind === 230 /* ExportSpecifier */ || + node.kind === 227 /* ExportAssignment */ && node.expression.kind === 69 /* Identifier */; + } + ts.isAliasSymbolDeclaration = isAliasSymbolDeclaration; + function getClassExtendsHeritageClauseElement(node) { + var heritageClause = getHeritageClause(node.heritageClauses, 83 /* ExtendsKeyword */); + return heritageClause && heritageClause.types.length > 0 ? heritageClause.types[0] : undefined; + } + ts.getClassExtendsHeritageClauseElement = getClassExtendsHeritageClauseElement; + function getClassImplementsHeritageClauseElements(node) { + var heritageClause = getHeritageClause(node.heritageClauses, 106 /* ImplementsKeyword */); + return heritageClause ? heritageClause.types : undefined; + } + ts.getClassImplementsHeritageClauseElements = getClassImplementsHeritageClauseElements; + function getInterfaceBaseTypeNodes(node) { + var heritageClause = getHeritageClause(node.heritageClauses, 83 /* ExtendsKeyword */); + return heritageClause ? heritageClause.types : undefined; + } + ts.getInterfaceBaseTypeNodes = getInterfaceBaseTypeNodes; + function getHeritageClause(clauses, kind) { + if (clauses) { + for (var _i = 0; _i < clauses.length; _i++) { + var clause = clauses[_i]; + if (clause.token === kind) { + return clause; + } + } + } + return undefined; + } + ts.getHeritageClause = getHeritageClause; + function tryResolveScriptReference(host, sourceFile, reference) { + if (!host.getCompilerOptions().noResolve) { + var referenceFileName = ts.isRootedDiskPath(reference.fileName) ? reference.fileName : ts.combinePaths(ts.getDirectoryPath(sourceFile.fileName), reference.fileName); + referenceFileName = ts.getNormalizedAbsolutePath(referenceFileName, host.getCurrentDirectory()); + return host.getSourceFile(referenceFileName); + } + } + ts.tryResolveScriptReference = tryResolveScriptReference; + function getAncestor(node, kind) { + while (node) { + if (node.kind === kind) { + return node; + } + node = node.parent; + } + return undefined; + } + ts.getAncestor = getAncestor; + function getFileReferenceFromReferencePath(comment, commentRange) { + var simpleReferenceRegEx = /^\/\/\/\s*/gim; + if (simpleReferenceRegEx.exec(comment)) { + if (isNoDefaultLibRegEx.exec(comment)) { + return { + isNoDefaultLib: true + }; + } + else { + var matchResult = ts.fullTripleSlashReferencePathRegEx.exec(comment); + if (matchResult) { + var start = commentRange.pos; + var end = commentRange.end; + return { + fileReference: { + pos: start, + end: end, + fileName: matchResult[3] + }, + isNoDefaultLib: false + }; + } + else { + return { + diagnosticMessage: ts.Diagnostics.Invalid_reference_directive_syntax, + isNoDefaultLib: false + }; + } + } + } + return undefined; + } + ts.getFileReferenceFromReferencePath = getFileReferenceFromReferencePath; + function isKeyword(token) { + return 70 /* FirstKeyword */ <= token && token <= 134 /* LastKeyword */; + } + ts.isKeyword = isKeyword; + function isTrivia(token) { + return 2 /* FirstTriviaToken */ <= token && token <= 7 /* LastTriviaToken */; + } + ts.isTrivia = isTrivia; + function isAsyncFunctionLike(node) { + return isFunctionLike(node) && (node.flags & 512 /* Async */) !== 0 && !isAccessor(node); + } + ts.isAsyncFunctionLike = isAsyncFunctionLike; + /** + * A declaration has a dynamic name if both of the following are true: + * 1. The declaration has a computed property name + * 2. The computed name is *not* expressed as Symbol., where name + * is a property of the Symbol constructor that denotes a built in + * Symbol. + */ + function hasDynamicName(declaration) { + return declaration.name && + declaration.name.kind === 136 /* ComputedPropertyName */ && + !isWellKnownSymbolSyntactically(declaration.name.expression); + } + ts.hasDynamicName = hasDynamicName; + /** + * Checks if the expression is of the form: + * Symbol.name + * where Symbol is literally the word "Symbol", and name is any identifierName + */ + function isWellKnownSymbolSyntactically(node) { + return isPropertyAccessExpression(node) && isESSymbolIdentifier(node.expression); + } + ts.isWellKnownSymbolSyntactically = isWellKnownSymbolSyntactically; + function getPropertyNameForPropertyNameNode(name) { + if (name.kind === 69 /* Identifier */ || name.kind === 9 /* StringLiteral */ || name.kind === 8 /* NumericLiteral */) { + return name.text; + } + if (name.kind === 136 /* ComputedPropertyName */) { + var nameExpression = name.expression; + if (isWellKnownSymbolSyntactically(nameExpression)) { + var rightHandSideName = nameExpression.name.text; + return getPropertyNameForKnownSymbolName(rightHandSideName); + } + } + return undefined; + } + ts.getPropertyNameForPropertyNameNode = getPropertyNameForPropertyNameNode; + function getPropertyNameForKnownSymbolName(symbolName) { + return "__@" + symbolName; + } + ts.getPropertyNameForKnownSymbolName = getPropertyNameForKnownSymbolName; + /** + * Includes the word "Symbol" with unicode escapes + */ + function isESSymbolIdentifier(node) { + return node.kind === 69 /* Identifier */ && node.text === "Symbol"; + } + ts.isESSymbolIdentifier = isESSymbolIdentifier; + function isModifier(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 113 /* StaticKeyword */: + return true; + } + return false; + } + ts.isModifier = isModifier; + function isParameterDeclaration(node) { + var root = getRootDeclaration(node); + return root.kind === 138 /* Parameter */; + } + ts.isParameterDeclaration = isParameterDeclaration; + function getRootDeclaration(node) { + while (node.kind === 163 /* BindingElement */) { + node = node.parent.parent; + } + return node; + } + ts.getRootDeclaration = getRootDeclaration; + function nodeStartsNewLexicalEnvironment(n) { + return isFunctionLike(n) || n.kind === 218 /* ModuleDeclaration */ || n.kind === 248 /* SourceFile */; + } + ts.nodeStartsNewLexicalEnvironment = nodeStartsNewLexicalEnvironment; + function cloneEntityName(node) { + if (node.kind === 69 /* Identifier */) { + var clone_1 = createSynthesizedNode(69 /* Identifier */); + clone_1.text = node.text; + return clone_1; + } + else { + var clone_2 = createSynthesizedNode(135 /* QualifiedName */); + clone_2.left = cloneEntityName(node.left); + clone_2.left.parent = clone_2; + clone_2.right = cloneEntityName(node.right); + clone_2.right.parent = clone_2; + return clone_2; + } + } + ts.cloneEntityName = cloneEntityName; + function nodeIsSynthesized(node) { + return node.pos === -1; + } + ts.nodeIsSynthesized = nodeIsSynthesized; + function createSynthesizedNode(kind, startsOnNewLine) { + var node = ts.createNode(kind, /* pos */ -1, /* end */ -1); + node.startsOnNewLine = startsOnNewLine; + return node; + } + ts.createSynthesizedNode = createSynthesizedNode; + function createSynthesizedNodeArray() { + var array = []; + array.pos = -1; + array.end = -1; + return array; + } + ts.createSynthesizedNodeArray = createSynthesizedNodeArray; + function createDiagnosticCollection() { + var nonFileDiagnostics = []; + var fileDiagnostics = {}; + var diagnosticsModified = false; + var modificationCount = 0; + return { + add: add, + getGlobalDiagnostics: getGlobalDiagnostics, + getDiagnostics: getDiagnostics, + getModificationCount: getModificationCount, + reattachFileDiagnostics: reattachFileDiagnostics + }; + function getModificationCount() { + return modificationCount; + } + function reattachFileDiagnostics(newFile) { + if (!ts.hasProperty(fileDiagnostics, newFile.fileName)) { + return; + } + for (var _i = 0, _a = fileDiagnostics[newFile.fileName]; _i < _a.length; _i++) { + var diagnostic = _a[_i]; + diagnostic.file = newFile; + } + } + function add(diagnostic) { + var diagnostics; + if (diagnostic.file) { + diagnostics = fileDiagnostics[diagnostic.file.fileName]; + if (!diagnostics) { + diagnostics = []; + fileDiagnostics[diagnostic.file.fileName] = diagnostics; + } + } + else { + diagnostics = nonFileDiagnostics; + } + diagnostics.push(diagnostic); + diagnosticsModified = true; + modificationCount++; + } + function getGlobalDiagnostics() { + sortAndDeduplicate(); + return nonFileDiagnostics; + } + function getDiagnostics(fileName) { + sortAndDeduplicate(); + if (fileName) { + return fileDiagnostics[fileName] || []; + } + var allDiagnostics = []; + function pushDiagnostic(d) { + allDiagnostics.push(d); + } + ts.forEach(nonFileDiagnostics, pushDiagnostic); + for (var key in fileDiagnostics) { + if (ts.hasProperty(fileDiagnostics, key)) { + ts.forEach(fileDiagnostics[key], pushDiagnostic); + } + } + return ts.sortAndDeduplicateDiagnostics(allDiagnostics); + } + function sortAndDeduplicate() { + if (!diagnosticsModified) { + return; + } + diagnosticsModified = false; + nonFileDiagnostics = ts.sortAndDeduplicateDiagnostics(nonFileDiagnostics); + for (var key in fileDiagnostics) { + if (ts.hasProperty(fileDiagnostics, key)) { + fileDiagnostics[key] = ts.sortAndDeduplicateDiagnostics(fileDiagnostics[key]); + } + } + } + } + ts.createDiagnosticCollection = createDiagnosticCollection; + // This consists of the first 19 unprintable ASCII characters, canonical escapes, lineSeparator, + // paragraphSeparator, and nextLine. The latter three are just desirable to suppress new lines in + // the language service. These characters should be escaped when printing, and if any characters are added, + // the map below must be updated. Note that this regexp *does not* include the 'delete' character. + // There is no reason for this other than that JSON.stringify does not handle it either. + var escapedCharsRegExp = /[\\\"\u0000-\u001f\t\v\f\b\r\n\u2028\u2029\u0085]/g; + var escapedCharsMap = { + "\0": "\\0", + "\t": "\\t", + "\v": "\\v", + "\f": "\\f", + "\b": "\\b", + "\r": "\\r", + "\n": "\\n", + "\\": "\\\\", + "\"": "\\\"", + "\u2028": "\\u2028", + "\u2029": "\\u2029", + "\u0085": "\\u0085" // nextLine + }; + /** + * Based heavily on the abstract 'Quote'/'QuoteJSONString' operation from ECMA-262 (24.3.2.2), + * but augmented for a few select characters (e.g. lineSeparator, paragraphSeparator, nextLine) + * Note that this doesn't actually wrap the input in double quotes. + */ + function escapeString(s) { + s = escapedCharsRegExp.test(s) ? s.replace(escapedCharsRegExp, getReplacement) : s; + return s; + function getReplacement(c) { + return escapedCharsMap[c] || get16BitUnicodeEscapeSequence(c.charCodeAt(0)); + } + } + ts.escapeString = escapeString; + function isIntrinsicJsxName(name) { + var ch = name.substr(0, 1); + return ch.toLowerCase() === ch; + } + ts.isIntrinsicJsxName = isIntrinsicJsxName; + function get16BitUnicodeEscapeSequence(charCode) { + var hexCharCode = charCode.toString(16).toUpperCase(); + var paddedHexCode = ("0000" + hexCharCode).slice(-4); + return "\\u" + paddedHexCode; + } + var nonAsciiCharacters = /[^\u0000-\u007F]/g; + function escapeNonAsciiCharacters(s) { + // Replace non-ASCII characters with '\uNNNN' escapes if any exist. + // Otherwise just return the original string. + return nonAsciiCharacters.test(s) ? + s.replace(nonAsciiCharacters, function (c) { return get16BitUnicodeEscapeSequence(c.charCodeAt(0)); }) : + s; + } + ts.escapeNonAsciiCharacters = escapeNonAsciiCharacters; + var indentStrings = ["", " "]; + function getIndentString(level) { + if (indentStrings[level] === undefined) { + indentStrings[level] = getIndentString(level - 1) + indentStrings[1]; + } + return indentStrings[level]; + } + ts.getIndentString = getIndentString; + function getIndentSize() { + return indentStrings[1].length; + } + ts.getIndentSize = getIndentSize; + function createTextWriter(newLine) { + var output = ""; + var indent = 0; + var lineStart = true; + var lineCount = 0; + var linePos = 0; + function write(s) { + if (s && s.length) { + if (lineStart) { + output += getIndentString(indent); + lineStart = false; + } + output += s; + } + } + function rawWrite(s) { + if (s !== undefined) { + if (lineStart) { + lineStart = false; + } + output += s; + } + } + function writeLiteral(s) { + if (s && s.length) { + write(s); + var lineStartsOfS = ts.computeLineStarts(s); + if (lineStartsOfS.length > 1) { + lineCount = lineCount + lineStartsOfS.length - 1; + linePos = output.length - s.length + ts.lastOrUndefined(lineStartsOfS); + } + } + } + function writeLine() { + if (!lineStart) { + output += newLine; + lineCount++; + linePos = output.length; + lineStart = true; + } + } + function writeTextOfNode(sourceFile, node) { + write(getSourceTextOfNodeFromSourceFile(sourceFile, node)); + } + return { + write: write, + rawWrite: rawWrite, + writeTextOfNode: writeTextOfNode, + writeLiteral: writeLiteral, + writeLine: writeLine, + increaseIndent: function () { return indent++; }, + decreaseIndent: function () { return indent--; }, + getIndent: function () { return indent; }, + getTextPos: function () { return output.length; }, + getLine: function () { return lineCount + 1; }, + getColumn: function () { return lineStart ? indent * getIndentSize() + 1 : output.length - linePos + 1; }, + getText: function () { return output; } + }; + } + ts.createTextWriter = createTextWriter; + function getOwnEmitOutputFilePath(sourceFile, host, extension) { + var compilerOptions = host.getCompilerOptions(); + var emitOutputFilePathWithoutExtension; + if (compilerOptions.outDir) { + emitOutputFilePathWithoutExtension = ts.removeFileExtension(getSourceFilePathInNewDir(sourceFile, host, compilerOptions.outDir)); + } + else { + emitOutputFilePathWithoutExtension = ts.removeFileExtension(sourceFile.fileName); + } + return emitOutputFilePathWithoutExtension + extension; + } + ts.getOwnEmitOutputFilePath = getOwnEmitOutputFilePath; + function getSourceFilePathInNewDir(sourceFile, host, newDirPath) { + var sourceFilePath = ts.getNormalizedAbsolutePath(sourceFile.fileName, host.getCurrentDirectory()); + sourceFilePath = sourceFilePath.replace(host.getCommonSourceDirectory(), ""); + return ts.combinePaths(newDirPath, sourceFilePath); + } + ts.getSourceFilePathInNewDir = getSourceFilePathInNewDir; + function writeFile(host, diagnostics, fileName, data, writeByteOrderMark) { + host.writeFile(fileName, data, writeByteOrderMark, function (hostErrorMessage) { + diagnostics.push(ts.createCompilerDiagnostic(ts.Diagnostics.Could_not_write_file_0_Colon_1, fileName, hostErrorMessage)); + }); + } + ts.writeFile = writeFile; + function getLineOfLocalPosition(currentSourceFile, pos) { + return ts.getLineAndCharacterOfPosition(currentSourceFile, pos).line; + } + ts.getLineOfLocalPosition = getLineOfLocalPosition; + function getFirstConstructorWithBody(node) { + return ts.forEach(node.members, function (member) { + if (member.kind === 144 /* Constructor */ && nodeIsPresent(member.body)) { + return member; + } + }); + } + ts.getFirstConstructorWithBody = getFirstConstructorWithBody; + function getSetAccessorTypeAnnotationNode(accessor) { + return accessor && accessor.parameters.length > 0 && accessor.parameters[0].type; + } + ts.getSetAccessorTypeAnnotationNode = getSetAccessorTypeAnnotationNode; + function shouldEmitToOwnFile(sourceFile, compilerOptions) { + if (!isDeclarationFile(sourceFile)) { + if ((isExternalModule(sourceFile) || !(compilerOptions.outFile || compilerOptions.out))) { + // 1. in-browser single file compilation scenario + // 2. non .js file + return compilerOptions.isolatedModules || !ts.fileExtensionIs(sourceFile.fileName, ".js"); + } + return false; + } + return false; + } + ts.shouldEmitToOwnFile = shouldEmitToOwnFile; + function getAllAccessorDeclarations(declarations, accessor) { + var firstAccessor; + var secondAccessor; + var getAccessor; + var setAccessor; + if (hasDynamicName(accessor)) { + firstAccessor = accessor; + if (accessor.kind === 145 /* GetAccessor */) { + getAccessor = accessor; + } + else if (accessor.kind === 146 /* SetAccessor */) { + setAccessor = accessor; + } + else { + ts.Debug.fail("Accessor has wrong kind"); + } + } + else { + ts.forEach(declarations, function (member) { + if ((member.kind === 145 /* GetAccessor */ || member.kind === 146 /* SetAccessor */) + && (member.flags & 128 /* Static */) === (accessor.flags & 128 /* Static */)) { + var memberName = getPropertyNameForPropertyNameNode(member.name); + var accessorName = getPropertyNameForPropertyNameNode(accessor.name); + if (memberName === accessorName) { + if (!firstAccessor) { + firstAccessor = member; + } + else if (!secondAccessor) { + secondAccessor = member; + } + if (member.kind === 145 /* GetAccessor */ && !getAccessor) { + getAccessor = member; + } + if (member.kind === 146 /* SetAccessor */ && !setAccessor) { + setAccessor = member; + } + } + } + }); + } + return { + firstAccessor: firstAccessor, + secondAccessor: secondAccessor, + getAccessor: getAccessor, + setAccessor: setAccessor + }; + } + ts.getAllAccessorDeclarations = getAllAccessorDeclarations; + function emitNewLineBeforeLeadingComments(currentSourceFile, writer, node, leadingComments) { + // If the leading comments start on different line than the start of node, write new line + if (leadingComments && leadingComments.length && node.pos !== leadingComments[0].pos && + getLineOfLocalPosition(currentSourceFile, node.pos) !== getLineOfLocalPosition(currentSourceFile, leadingComments[0].pos)) { + writer.writeLine(); + } + } + ts.emitNewLineBeforeLeadingComments = emitNewLineBeforeLeadingComments; + function emitComments(currentSourceFile, writer, comments, trailingSeparator, newLine, writeComment) { + var emitLeadingSpace = !trailingSeparator; + ts.forEach(comments, function (comment) { + if (emitLeadingSpace) { + writer.write(" "); + emitLeadingSpace = false; + } + writeComment(currentSourceFile, writer, comment, newLine); + if (comment.hasTrailingNewLine) { + writer.writeLine(); + } + else if (trailingSeparator) { + writer.write(" "); + } + else { + // Emit leading space to separate comment during next comment emit + emitLeadingSpace = true; + } + }); + } + ts.emitComments = emitComments; + function writeCommentRange(currentSourceFile, writer, comment, newLine) { + if (currentSourceFile.text.charCodeAt(comment.pos + 1) === 42 /* asterisk */) { + var firstCommentLineAndCharacter = ts.getLineAndCharacterOfPosition(currentSourceFile, comment.pos); + var lineCount = ts.getLineStarts(currentSourceFile).length; + var firstCommentLineIndent; + for (var pos = comment.pos, currentLine = firstCommentLineAndCharacter.line; pos < comment.end; currentLine++) { + var nextLineStart = (currentLine + 1) === lineCount + ? currentSourceFile.text.length + 1 + : getStartPositionOfLine(currentLine + 1, currentSourceFile); + if (pos !== comment.pos) { + // If we are not emitting first line, we need to write the spaces to adjust the alignment + if (firstCommentLineIndent === undefined) { + firstCommentLineIndent = calculateIndent(getStartPositionOfLine(firstCommentLineAndCharacter.line, currentSourceFile), comment.pos); + } + // These are number of spaces writer is going to write at current indent + var currentWriterIndentSpacing = writer.getIndent() * getIndentSize(); + // Number of spaces we want to be writing + // eg: Assume writer indent + // module m { + // /* starts at character 9 this is line 1 + // * starts at character pos 4 line --1 = 8 - 8 + 3 + // More left indented comment */ --2 = 8 - 8 + 2 + // class c { } + // } + // module m { + // /* this is line 1 -- Assume current writer indent 8 + // * line --3 = 8 - 4 + 5 + // More right indented comment */ --4 = 8 - 4 + 11 + // class c { } + // } + var spacesToEmit = currentWriterIndentSpacing - firstCommentLineIndent + calculateIndent(pos, nextLineStart); + if (spacesToEmit > 0) { + var numberOfSingleSpacesToEmit = spacesToEmit % getIndentSize(); + var indentSizeSpaceString = getIndentString((spacesToEmit - numberOfSingleSpacesToEmit) / getIndentSize()); + // Write indent size string ( in eg 1: = "", 2: "" , 3: string with 8 spaces 4: string with 12 spaces + writer.rawWrite(indentSizeSpaceString); + // Emit the single spaces (in eg: 1: 3 spaces, 2: 2 spaces, 3: 1 space, 4: 3 spaces) + while (numberOfSingleSpacesToEmit) { + writer.rawWrite(" "); + numberOfSingleSpacesToEmit--; + } + } + else { + // No spaces to emit write empty string + writer.rawWrite(""); + } + } + // Write the comment line text + writeTrimmedCurrentLine(pos, nextLineStart); + pos = nextLineStart; + } + } + else { + // Single line comment of style //.... + writer.write(currentSourceFile.text.substring(comment.pos, comment.end)); + } + function writeTrimmedCurrentLine(pos, nextLineStart) { + var end = Math.min(comment.end, nextLineStart - 1); + var currentLineText = currentSourceFile.text.substring(pos, end).replace(/^\s+|\s+$/g, ""); + if (currentLineText) { + // trimmed forward and ending spaces text + writer.write(currentLineText); + if (end !== comment.end) { + writer.writeLine(); + } + } + else { + // Empty string - make sure we write empty line + writer.writeLiteral(newLine); + } + } + function calculateIndent(pos, end) { + var currentLineIndent = 0; + for (; pos < end && ts.isWhiteSpace(currentSourceFile.text.charCodeAt(pos)); pos++) { + if (currentSourceFile.text.charCodeAt(pos) === 9 /* tab */) { + // Tabs = TabSize = indent size and go to next tabStop + currentLineIndent += getIndentSize() - (currentLineIndent % getIndentSize()); + } + else { + // Single space + currentLineIndent++; + } + } + return currentLineIndent; + } + } + ts.writeCommentRange = writeCommentRange; + function modifierToFlag(token) { + switch (token) { + case 113 /* StaticKeyword */: return 128 /* Static */; + case 112 /* PublicKeyword */: return 16 /* Public */; + case 111 /* ProtectedKeyword */: return 64 /* Protected */; + case 110 /* PrivateKeyword */: return 32 /* Private */; + case 115 /* AbstractKeyword */: return 256 /* Abstract */; + case 82 /* ExportKeyword */: return 1 /* Export */; + case 122 /* DeclareKeyword */: return 2 /* Ambient */; + case 74 /* ConstKeyword */: return 32768 /* Const */; + case 77 /* DefaultKeyword */: return 1024 /* Default */; + case 118 /* AsyncKeyword */: return 512 /* Async */; + } + return 0; + } + ts.modifierToFlag = modifierToFlag; + function isLeftHandSideExpression(expr) { + if (expr) { + switch (expr.kind) { + case 166 /* PropertyAccessExpression */: + case 167 /* ElementAccessExpression */: + case 169 /* NewExpression */: + case 168 /* CallExpression */: + case 233 /* JsxElement */: + case 234 /* JsxSelfClosingElement */: + case 170 /* TaggedTemplateExpression */: + case 164 /* ArrayLiteralExpression */: + case 172 /* ParenthesizedExpression */: + case 165 /* ObjectLiteralExpression */: + case 186 /* ClassExpression */: + case 173 /* FunctionExpression */: + case 69 /* Identifier */: + case 10 /* RegularExpressionLiteral */: + case 8 /* NumericLiteral */: + case 9 /* StringLiteral */: + case 11 /* NoSubstitutionTemplateLiteral */: + case 183 /* TemplateExpression */: + case 84 /* FalseKeyword */: + case 93 /* NullKeyword */: + case 97 /* ThisKeyword */: + case 99 /* TrueKeyword */: + case 95 /* SuperKeyword */: + return true; + } + } + return false; + } + ts.isLeftHandSideExpression = isLeftHandSideExpression; + function isAssignmentOperator(token) { + return token >= 56 /* FirstAssignment */ && token <= 68 /* LastAssignment */; + } + ts.isAssignmentOperator = isAssignmentOperator; + function isExpressionWithTypeArgumentsInClassExtendsClause(node) { + return node.kind === 188 /* ExpressionWithTypeArguments */ && + node.parent.token === 83 /* ExtendsKeyword */ && + isClassLike(node.parent.parent); + } + ts.isExpressionWithTypeArgumentsInClassExtendsClause = isExpressionWithTypeArgumentsInClassExtendsClause; + // Returns false if this heritage clause element's expression contains something unsupported + // (i.e. not a name or dotted name). + function isSupportedExpressionWithTypeArguments(node) { + return isSupportedExpressionWithTypeArgumentsRest(node.expression); + } + ts.isSupportedExpressionWithTypeArguments = isSupportedExpressionWithTypeArguments; + function isSupportedExpressionWithTypeArgumentsRest(node) { + if (node.kind === 69 /* Identifier */) { + return true; + } + else if (isPropertyAccessExpression(node)) { + return isSupportedExpressionWithTypeArgumentsRest(node.expression); + } + else { + return false; + } + } + function isRightSideOfQualifiedNameOrPropertyAccess(node) { + return (node.parent.kind === 135 /* QualifiedName */ && node.parent.right === node) || + (node.parent.kind === 166 /* PropertyAccessExpression */ && node.parent.name === node); + } + ts.isRightSideOfQualifiedNameOrPropertyAccess = isRightSideOfQualifiedNameOrPropertyAccess; + function isEmptyObjectLiteralOrArrayLiteral(expression) { + var kind = expression.kind; + if (kind === 165 /* ObjectLiteralExpression */) { + return expression.properties.length === 0; + } + if (kind === 164 /* ArrayLiteralExpression */) { + return expression.elements.length === 0; + } + return false; + } + ts.isEmptyObjectLiteralOrArrayLiteral = isEmptyObjectLiteralOrArrayLiteral; + function getLocalSymbolForExportDefault(symbol) { + return symbol && symbol.valueDeclaration && (symbol.valueDeclaration.flags & 1024 /* Default */) ? symbol.valueDeclaration.localSymbol : undefined; + } + ts.getLocalSymbolForExportDefault = getLocalSymbolForExportDefault; + function isJavaScript(fileName) { + return ts.fileExtensionIs(fileName, ".js"); + } + ts.isJavaScript = isJavaScript; + function isTsx(fileName) { + return ts.fileExtensionIs(fileName, ".tsx"); + } + ts.isTsx = isTsx; + /** + * Replace each instance of non-ascii characters by one, two, three, or four escape sequences + * representing the UTF-8 encoding of the character, and return the expanded char code list. + */ + function getExpandedCharCodes(input) { + var output = []; + var length = input.length; + for (var i = 0; i < length; i++) { + var charCode = input.charCodeAt(i); + // handel utf8 + if (charCode < 0x80) { + output.push(charCode); + } + else if (charCode < 0x800) { + output.push((charCode >> 6) | 192); + output.push((charCode & 63) | 128); + } + else if (charCode < 0x10000) { + output.push((charCode >> 12) | 224); + output.push(((charCode >> 6) & 63) | 128); + output.push((charCode & 63) | 128); + } + else if (charCode < 0x20000) { + output.push((charCode >> 18) | 240); + output.push(((charCode >> 12) & 63) | 128); + output.push(((charCode >> 6) & 63) | 128); + output.push((charCode & 63) | 128); + } + else { + ts.Debug.assert(false, "Unexpected code point"); + } + } + return output; + } + var base64Digits = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="; + /** + * Converts a string to a base-64 encoded ASCII string. + */ + function convertToBase64(input) { + var result = ""; + var charCodes = getExpandedCharCodes(input); + var i = 0; + var length = charCodes.length; + var byte1, byte2, byte3, byte4; + while (i < length) { + // Convert every 6-bits in the input 3 character points + // into a base64 digit + byte1 = charCodes[i] >> 2; + byte2 = (charCodes[i] & 3) << 4 | charCodes[i + 1] >> 4; + byte3 = (charCodes[i + 1] & 15) << 2 | charCodes[i + 2] >> 6; + byte4 = charCodes[i + 2] & 63; + // We are out of characters in the input, set the extra + // digits to 64 (padding character). + if (i + 1 >= length) { + byte3 = byte4 = 64; + } + else if (i + 2 >= length) { + byte4 = 64; + } + // Write to the ouput + result += base64Digits.charAt(byte1) + base64Digits.charAt(byte2) + base64Digits.charAt(byte3) + base64Digits.charAt(byte4); + i += 3; + } + return result; + } + ts.convertToBase64 = convertToBase64; + var carriageReturnLineFeed = "\r\n"; + var lineFeed = "\n"; + function getNewLineCharacter(options) { + if (options.newLine === 0 /* CarriageReturnLineFeed */) { + return carriageReturnLineFeed; + } + else if (options.newLine === 1 /* LineFeed */) { + return lineFeed; + } + else if (ts.sys) { + return ts.sys.newLine; + } + return carriageReturnLineFeed; + } + ts.getNewLineCharacter = getNewLineCharacter; +})(ts || (ts = {})); +var ts; +(function (ts) { + function getDefaultLibFileName(options) { + return options.target === 2 /* ES6 */ ? "lib.es6.d.ts" : "lib.d.ts"; + } + ts.getDefaultLibFileName = getDefaultLibFileName; + function textSpanEnd(span) { + return span.start + span.length; + } + ts.textSpanEnd = textSpanEnd; + function textSpanIsEmpty(span) { + return span.length === 0; + } + ts.textSpanIsEmpty = textSpanIsEmpty; + function textSpanContainsPosition(span, position) { + return position >= span.start && position < textSpanEnd(span); + } + ts.textSpanContainsPosition = textSpanContainsPosition; + // Returns true if 'span' contains 'other'. + function textSpanContainsTextSpan(span, other) { + return other.start >= span.start && textSpanEnd(other) <= textSpanEnd(span); + } + ts.textSpanContainsTextSpan = textSpanContainsTextSpan; + function textSpanOverlapsWith(span, other) { + var overlapStart = Math.max(span.start, other.start); + var overlapEnd = Math.min(textSpanEnd(span), textSpanEnd(other)); + return overlapStart < overlapEnd; + } + ts.textSpanOverlapsWith = textSpanOverlapsWith; + function textSpanOverlap(span1, span2) { + var overlapStart = Math.max(span1.start, span2.start); + var overlapEnd = Math.min(textSpanEnd(span1), textSpanEnd(span2)); + if (overlapStart < overlapEnd) { + return createTextSpanFromBounds(overlapStart, overlapEnd); + } + return undefined; + } + ts.textSpanOverlap = textSpanOverlap; + function textSpanIntersectsWithTextSpan(span, other) { + return other.start <= textSpanEnd(span) && textSpanEnd(other) >= span.start; + } + ts.textSpanIntersectsWithTextSpan = textSpanIntersectsWithTextSpan; + function textSpanIntersectsWith(span, start, length) { + var end = start + length; + return start <= textSpanEnd(span) && end >= span.start; + } + ts.textSpanIntersectsWith = textSpanIntersectsWith; + function decodedTextSpanIntersectsWith(start1, length1, start2, length2) { + var end1 = start1 + length1; + var end2 = start2 + length2; + return start2 <= end1 && end2 >= start1; + } + ts.decodedTextSpanIntersectsWith = decodedTextSpanIntersectsWith; + function textSpanIntersectsWithPosition(span, position) { + return position <= textSpanEnd(span) && position >= span.start; + } + ts.textSpanIntersectsWithPosition = textSpanIntersectsWithPosition; + function textSpanIntersection(span1, span2) { + var intersectStart = Math.max(span1.start, span2.start); + var intersectEnd = Math.min(textSpanEnd(span1), textSpanEnd(span2)); + if (intersectStart <= intersectEnd) { + return createTextSpanFromBounds(intersectStart, intersectEnd); + } + return undefined; + } + ts.textSpanIntersection = textSpanIntersection; + function createTextSpan(start, length) { + if (start < 0) { + throw new Error("start < 0"); + } + if (length < 0) { + throw new Error("length < 0"); + } + return { start: start, length: length }; + } + ts.createTextSpan = createTextSpan; + function createTextSpanFromBounds(start, end) { + return createTextSpan(start, end - start); + } + ts.createTextSpanFromBounds = createTextSpanFromBounds; + function textChangeRangeNewSpan(range) { + return createTextSpan(range.span.start, range.newLength); + } + ts.textChangeRangeNewSpan = textChangeRangeNewSpan; + function textChangeRangeIsUnchanged(range) { + return textSpanIsEmpty(range.span) && range.newLength === 0; + } + ts.textChangeRangeIsUnchanged = textChangeRangeIsUnchanged; + function createTextChangeRange(span, newLength) { + if (newLength < 0) { + throw new Error("newLength < 0"); + } + return { span: span, newLength: newLength }; + } + ts.createTextChangeRange = createTextChangeRange; + ts.unchangedTextChangeRange = createTextChangeRange(createTextSpan(0, 0), 0); + /** + * Called to merge all the changes that occurred across several versions of a script snapshot + * into a single change. i.e. if a user keeps making successive edits to a script we will + * have a text change from V1 to V2, V2 to V3, ..., Vn. + * + * This function will then merge those changes into a single change range valid between V1 and + * Vn. + */ + function collapseTextChangeRangesAcrossMultipleVersions(changes) { + if (changes.length === 0) { + return ts.unchangedTextChangeRange; + } + if (changes.length === 1) { + return changes[0]; + } + // We change from talking about { { oldStart, oldLength }, newLength } to { oldStart, oldEnd, newEnd } + // as it makes things much easier to reason about. + var change0 = changes[0]; + var oldStartN = change0.span.start; + var oldEndN = textSpanEnd(change0.span); + var newEndN = oldStartN + change0.newLength; + for (var i = 1; i < changes.length; i++) { + var nextChange = changes[i]; + // Consider the following case: + // i.e. two edits. The first represents the text change range { { 10, 50 }, 30 }. i.e. The span starting + // at 10, with length 50 is reduced to length 30. The second represents the text change range { { 30, 30 }, 40 }. + // i.e. the span starting at 30 with length 30 is increased to length 40. + // + // 0 10 20 30 40 50 60 70 80 90 100 + // ------------------------------------------------------------------------------------------------------- + // | / + // | /---- + // T1 | /---- + // | /---- + // | /---- + // ------------------------------------------------------------------------------------------------------- + // | \ + // | \ + // T2 | \ + // | \ + // | \ + // ------------------------------------------------------------------------------------------------------- + // + // Merging these turns out to not be too difficult. First, determining the new start of the change is trivial + // it's just the min of the old and new starts. i.e.: + // + // 0 10 20 30 40 50 60 70 80 90 100 + // ------------------------------------------------------------*------------------------------------------ + // | / + // | /---- + // T1 | /---- + // | /---- + // | /---- + // ----------------------------------------$-------------------$------------------------------------------ + // . | \ + // . | \ + // T2 . | \ + // . | \ + // . | \ + // ----------------------------------------------------------------------*-------------------------------- + // + // (Note the dots represent the newly inferrred start. + // Determining the new and old end is also pretty simple. Basically it boils down to paying attention to the + // absolute positions at the asterixes, and the relative change between the dollar signs. Basically, we see + // which if the two $'s precedes the other, and we move that one forward until they line up. in this case that + // means: + // + // 0 10 20 30 40 50 60 70 80 90 100 + // --------------------------------------------------------------------------------*---------------------- + // | / + // | /---- + // T1 | /---- + // | /---- + // | /---- + // ------------------------------------------------------------$------------------------------------------ + // . | \ + // . | \ + // T2 . | \ + // . | \ + // . | \ + // ----------------------------------------------------------------------*-------------------------------- + // + // In other words (in this case), we're recognizing that the second edit happened after where the first edit + // ended with a delta of 20 characters (60 - 40). Thus, if we go back in time to where the first edit started + // that's the same as if we started at char 80 instead of 60. + // + // As it so happens, the same logic applies if the second edit precedes the first edit. In that case rahter + // than pusing the first edit forward to match the second, we'll push the second edit forward to match the + // first. + // + // In this case that means we have { oldStart: 10, oldEnd: 80, newEnd: 70 } or, in TextChangeRange + // semantics: { { start: 10, length: 70 }, newLength: 60 } + // + // The math then works out as follows. + // If we have { oldStart1, oldEnd1, newEnd1 } and { oldStart2, oldEnd2, newEnd2 } then we can compute the + // final result like so: + // + // { + // oldStart3: Min(oldStart1, oldStart2), + // oldEnd3 : Max(oldEnd1, oldEnd1 + (oldEnd2 - newEnd1)), + // newEnd3 : Max(newEnd2, newEnd2 + (newEnd1 - oldEnd2)) + // } + var oldStart1 = oldStartN; + var oldEnd1 = oldEndN; + var newEnd1 = newEndN; + var oldStart2 = nextChange.span.start; + var oldEnd2 = textSpanEnd(nextChange.span); + var newEnd2 = oldStart2 + nextChange.newLength; + oldStartN = Math.min(oldStart1, oldStart2); + oldEndN = Math.max(oldEnd1, oldEnd1 + (oldEnd2 - newEnd1)); + newEndN = Math.max(newEnd2, newEnd2 + (newEnd1 - oldEnd2)); + } + return createTextChangeRange(createTextSpanFromBounds(oldStartN, oldEndN), /*newLength:*/ newEndN - oldStartN); + } + ts.collapseTextChangeRangesAcrossMultipleVersions = collapseTextChangeRangesAcrossMultipleVersions; + function getTypeParameterOwner(d) { + if (d && d.kind === 137 /* TypeParameter */) { + for (var current = d; current; current = current.parent) { + if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 215 /* InterfaceDeclaration */) { + return current; + } + } + } + } + ts.getTypeParameterOwner = getTypeParameterOwner; +})(ts || (ts = {})); +/// +/// +var ts; +(function (ts) { + var nodeConstructors = new Array(272 /* Count */); + /* @internal */ ts.parseTime = 0; + function getNodeConstructor(kind) { + return nodeConstructors[kind] || (nodeConstructors[kind] = ts.objectAllocator.getNodeConstructor(kind)); + } + ts.getNodeConstructor = getNodeConstructor; + function createNode(kind, pos, end) { + return new (getNodeConstructor(kind))(pos, end); + } + ts.createNode = createNode; + function visitNode(cbNode, node) { + if (node) { + return cbNode(node); + } + } + function visitNodeArray(cbNodes, nodes) { + if (nodes) { + return cbNodes(nodes); + } + } + function visitEachNode(cbNode, nodes) { + if (nodes) { + for (var _i = 0; _i < nodes.length; _i++) { + var node = nodes[_i]; + var result = cbNode(node); + if (result) { + return result; + } + } + } + } + // Invokes a callback for each child of the given node. The 'cbNode' callback is invoked for all child nodes + // stored in properties. If a 'cbNodes' callback is specified, it is invoked for embedded arrays; otherwise, + // embedded arrays are flattened and the 'cbNode' callback is invoked for each element. If a callback returns + // a truthy value, iteration stops and that value is returned. Otherwise, undefined is returned. + function forEachChild(node, cbNode, cbNodeArray) { + if (!node) { + return; + } + // The visitXXX functions could be written as local functions that close over the cbNode and cbNodeArray + // callback parameters, but that causes a closure allocation for each invocation with noticeable effects + // on performance. + var visitNodes = cbNodeArray ? visitNodeArray : visitEachNode; + var cbNodes = cbNodeArray || cbNode; + switch (node.kind) { + case 135 /* QualifiedName */: + return visitNode(cbNode, node.left) || + visitNode(cbNode, node.right); + case 137 /* TypeParameter */: + return visitNode(cbNode, node.name) || + visitNode(cbNode, node.constraint) || + visitNode(cbNode, node.expression); + case 246 /* ShorthandPropertyAssignment */: + return visitNodes(cbNodes, node.decorators) || + visitNodes(cbNodes, node.modifiers) || + visitNode(cbNode, node.name) || + visitNode(cbNode, node.questionToken) || + visitNode(cbNode, node.equalsToken) || + visitNode(cbNode, node.objectAssignmentInitializer); + case 138 /* Parameter */: + case 141 /* PropertyDeclaration */: + case 140 /* PropertySignature */: + case 245 /* PropertyAssignment */: + case 211 /* VariableDeclaration */: + case 163 /* BindingElement */: + return visitNodes(cbNodes, node.decorators) || + visitNodes(cbNodes, node.modifiers) || + visitNode(cbNode, node.propertyName) || + visitNode(cbNode, node.dotDotDotToken) || + visitNode(cbNode, node.name) || + visitNode(cbNode, node.questionToken) || + visitNode(cbNode, node.type) || + visitNode(cbNode, node.initializer); + case 152 /* FunctionType */: + case 153 /* ConstructorType */: + case 147 /* CallSignature */: + case 148 /* ConstructSignature */: + case 149 /* IndexSignature */: + return visitNodes(cbNodes, node.decorators) || + visitNodes(cbNodes, node.modifiers) || + visitNodes(cbNodes, node.typeParameters) || + visitNodes(cbNodes, node.parameters) || + visitNode(cbNode, node.type); + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: + case 144 /* Constructor */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: + case 173 /* FunctionExpression */: + case 213 /* FunctionDeclaration */: + case 174 /* ArrowFunction */: + return visitNodes(cbNodes, node.decorators) || + visitNodes(cbNodes, node.modifiers) || + visitNode(cbNode, node.asteriskToken) || + visitNode(cbNode, node.name) || + visitNode(cbNode, node.questionToken) || + visitNodes(cbNodes, node.typeParameters) || + visitNodes(cbNodes, node.parameters) || + visitNode(cbNode, node.type) || + visitNode(cbNode, node.equalsGreaterThanToken) || + visitNode(cbNode, node.body); + case 151 /* TypeReference */: + return visitNode(cbNode, node.typeName) || + visitNodes(cbNodes, node.typeArguments); + case 150 /* TypePredicate */: + return visitNode(cbNode, node.parameterName) || + visitNode(cbNode, node.type); + case 154 /* TypeQuery */: + return visitNode(cbNode, node.exprName); + case 155 /* TypeLiteral */: + return visitNodes(cbNodes, node.members); + case 156 /* ArrayType */: + return visitNode(cbNode, node.elementType); + case 157 /* TupleType */: + return visitNodes(cbNodes, node.elementTypes); + case 158 /* UnionType */: + case 159 /* IntersectionType */: + return visitNodes(cbNodes, node.types); + case 160 /* ParenthesizedType */: + return visitNode(cbNode, node.type); + case 161 /* ObjectBindingPattern */: + case 162 /* ArrayBindingPattern */: + return visitNodes(cbNodes, node.elements); + case 164 /* ArrayLiteralExpression */: + return visitNodes(cbNodes, node.elements); + case 165 /* ObjectLiteralExpression */: + return visitNodes(cbNodes, node.properties); + case 166 /* PropertyAccessExpression */: + return visitNode(cbNode, node.expression) || + visitNode(cbNode, node.dotToken) || + visitNode(cbNode, node.name); + case 167 /* ElementAccessExpression */: + return visitNode(cbNode, node.expression) || + visitNode(cbNode, node.argumentExpression); + case 168 /* CallExpression */: + case 169 /* NewExpression */: + return visitNode(cbNode, node.expression) || + visitNodes(cbNodes, node.typeArguments) || + visitNodes(cbNodes, node.arguments); + case 170 /* TaggedTemplateExpression */: + return visitNode(cbNode, node.tag) || + visitNode(cbNode, node.template); + case 171 /* TypeAssertionExpression */: + return visitNode(cbNode, node.type) || + visitNode(cbNode, node.expression); + case 172 /* ParenthesizedExpression */: + return visitNode(cbNode, node.expression); + case 175 /* DeleteExpression */: + return visitNode(cbNode, node.expression); + case 176 /* TypeOfExpression */: + return visitNode(cbNode, node.expression); + case 177 /* VoidExpression */: + return visitNode(cbNode, node.expression); + case 179 /* PrefixUnaryExpression */: + return visitNode(cbNode, node.operand); + case 184 /* YieldExpression */: + return visitNode(cbNode, node.asteriskToken) || + visitNode(cbNode, node.expression); + case 178 /* AwaitExpression */: + return visitNode(cbNode, node.expression); + case 180 /* PostfixUnaryExpression */: + return visitNode(cbNode, node.operand); + case 181 /* BinaryExpression */: + return visitNode(cbNode, node.left) || + visitNode(cbNode, node.operatorToken) || + visitNode(cbNode, node.right); + case 189 /* AsExpression */: + return visitNode(cbNode, node.expression) || + visitNode(cbNode, node.type); + case 182 /* ConditionalExpression */: + return visitNode(cbNode, node.condition) || + visitNode(cbNode, node.questionToken) || + visitNode(cbNode, node.whenTrue) || + visitNode(cbNode, node.colonToken) || + visitNode(cbNode, node.whenFalse); + case 185 /* SpreadElementExpression */: + return visitNode(cbNode, node.expression); + case 192 /* Block */: + case 219 /* ModuleBlock */: + return visitNodes(cbNodes, node.statements); + case 248 /* SourceFile */: + return visitNodes(cbNodes, node.statements) || + visitNode(cbNode, node.endOfFileToken); + case 193 /* VariableStatement */: + return visitNodes(cbNodes, node.decorators) || + visitNodes(cbNodes, node.modifiers) || + visitNode(cbNode, node.declarationList); + case 212 /* VariableDeclarationList */: + return visitNodes(cbNodes, node.declarations); + case 195 /* ExpressionStatement */: + return visitNode(cbNode, node.expression); + case 196 /* IfStatement */: + return visitNode(cbNode, node.expression) || + visitNode(cbNode, node.thenStatement) || + visitNode(cbNode, node.elseStatement); + case 197 /* DoStatement */: + return visitNode(cbNode, node.statement) || + visitNode(cbNode, node.expression); + case 198 /* WhileStatement */: + return visitNode(cbNode, node.expression) || + visitNode(cbNode, node.statement); + case 199 /* ForStatement */: + return visitNode(cbNode, node.initializer) || + visitNode(cbNode, node.condition) || + visitNode(cbNode, node.incrementor) || + visitNode(cbNode, node.statement); + case 200 /* ForInStatement */: + return visitNode(cbNode, node.initializer) || + visitNode(cbNode, node.expression) || + visitNode(cbNode, node.statement); + case 201 /* ForOfStatement */: + return visitNode(cbNode, node.initializer) || + visitNode(cbNode, node.expression) || + visitNode(cbNode, node.statement); + case 202 /* ContinueStatement */: + case 203 /* BreakStatement */: + return visitNode(cbNode, node.label); + case 204 /* ReturnStatement */: + return visitNode(cbNode, node.expression); + case 205 /* WithStatement */: + return visitNode(cbNode, node.expression) || + visitNode(cbNode, node.statement); + case 206 /* SwitchStatement */: + return visitNode(cbNode, node.expression) || + visitNode(cbNode, node.caseBlock); + case 220 /* CaseBlock */: + return visitNodes(cbNodes, node.clauses); + case 241 /* CaseClause */: + return visitNode(cbNode, node.expression) || + visitNodes(cbNodes, node.statements); + case 242 /* DefaultClause */: + return visitNodes(cbNodes, node.statements); + case 207 /* LabeledStatement */: + return visitNode(cbNode, node.label) || + visitNode(cbNode, node.statement); + case 208 /* ThrowStatement */: + return visitNode(cbNode, node.expression); + case 209 /* TryStatement */: + return visitNode(cbNode, node.tryBlock) || + visitNode(cbNode, node.catchClause) || + visitNode(cbNode, node.finallyBlock); + case 244 /* CatchClause */: + return visitNode(cbNode, node.variableDeclaration) || + visitNode(cbNode, node.block); + case 139 /* Decorator */: + return visitNode(cbNode, node.expression); + case 214 /* ClassDeclaration */: + case 186 /* ClassExpression */: + return visitNodes(cbNodes, node.decorators) || + visitNodes(cbNodes, node.modifiers) || + visitNode(cbNode, node.name) || + visitNodes(cbNodes, node.typeParameters) || + visitNodes(cbNodes, node.heritageClauses) || + visitNodes(cbNodes, node.members); + case 215 /* InterfaceDeclaration */: + return visitNodes(cbNodes, node.decorators) || + visitNodes(cbNodes, node.modifiers) || + visitNode(cbNode, node.name) || + visitNodes(cbNodes, node.typeParameters) || + visitNodes(cbNodes, node.heritageClauses) || + visitNodes(cbNodes, node.members); + case 216 /* TypeAliasDeclaration */: + return visitNodes(cbNodes, node.decorators) || + visitNodes(cbNodes, node.modifiers) || + visitNode(cbNode, node.name) || + visitNodes(cbNodes, node.typeParameters) || + visitNode(cbNode, node.type); + case 217 /* EnumDeclaration */: + return visitNodes(cbNodes, node.decorators) || + visitNodes(cbNodes, node.modifiers) || + visitNode(cbNode, node.name) || + visitNodes(cbNodes, node.members); + case 247 /* EnumMember */: + return visitNode(cbNode, node.name) || + visitNode(cbNode, node.initializer); + case 218 /* ModuleDeclaration */: + return visitNodes(cbNodes, node.decorators) || + visitNodes(cbNodes, node.modifiers) || + visitNode(cbNode, node.name) || + visitNode(cbNode, node.body); + case 221 /* ImportEqualsDeclaration */: + return visitNodes(cbNodes, node.decorators) || + visitNodes(cbNodes, node.modifiers) || + visitNode(cbNode, node.name) || + visitNode(cbNode, node.moduleReference); + case 222 /* ImportDeclaration */: + return visitNodes(cbNodes, node.decorators) || + visitNodes(cbNodes, node.modifiers) || + visitNode(cbNode, node.importClause) || + visitNode(cbNode, node.moduleSpecifier); + case 223 /* ImportClause */: + return visitNode(cbNode, node.name) || + visitNode(cbNode, node.namedBindings); + case 224 /* NamespaceImport */: + return visitNode(cbNode, node.name); + case 225 /* NamedImports */: + case 229 /* NamedExports */: + return visitNodes(cbNodes, node.elements); + case 228 /* ExportDeclaration */: + return visitNodes(cbNodes, node.decorators) || + visitNodes(cbNodes, node.modifiers) || + visitNode(cbNode, node.exportClause) || + visitNode(cbNode, node.moduleSpecifier); + case 226 /* ImportSpecifier */: + case 230 /* ExportSpecifier */: + return visitNode(cbNode, node.propertyName) || + visitNode(cbNode, node.name); + case 227 /* ExportAssignment */: + return visitNodes(cbNodes, node.decorators) || + visitNodes(cbNodes, node.modifiers) || + visitNode(cbNode, node.expression); + case 183 /* TemplateExpression */: + return visitNode(cbNode, node.head) || visitNodes(cbNodes, node.templateSpans); + case 190 /* TemplateSpan */: + return visitNode(cbNode, node.expression) || visitNode(cbNode, node.literal); + case 136 /* ComputedPropertyName */: + return visitNode(cbNode, node.expression); + case 243 /* HeritageClause */: + return visitNodes(cbNodes, node.types); + case 188 /* ExpressionWithTypeArguments */: + return visitNode(cbNode, node.expression) || + visitNodes(cbNodes, node.typeArguments); + case 232 /* ExternalModuleReference */: + return visitNode(cbNode, node.expression); + case 231 /* MissingDeclaration */: + return visitNodes(cbNodes, node.decorators); + case 233 /* JsxElement */: + return visitNode(cbNode, node.openingElement) || + visitNodes(cbNodes, node.children) || + visitNode(cbNode, node.closingElement); + case 234 /* JsxSelfClosingElement */: + case 235 /* JsxOpeningElement */: + return visitNode(cbNode, node.tagName) || + visitNodes(cbNodes, node.attributes); + case 238 /* JsxAttribute */: + return visitNode(cbNode, node.name) || + visitNode(cbNode, node.initializer); + case 239 /* JsxSpreadAttribute */: + return visitNode(cbNode, node.expression); + case 240 /* JsxExpression */: + return visitNode(cbNode, node.expression); + case 237 /* JsxClosingElement */: + return visitNode(cbNode, node.tagName); + case 249 /* JSDocTypeExpression */: + return visitNode(cbNode, node.type); + case 253 /* JSDocUnionType */: + return visitNodes(cbNodes, node.types); + case 254 /* JSDocTupleType */: + return visitNodes(cbNodes, node.types); + case 252 /* JSDocArrayType */: + return visitNode(cbNode, node.elementType); + case 256 /* JSDocNonNullableType */: + return visitNode(cbNode, node.type); + case 255 /* JSDocNullableType */: + return visitNode(cbNode, node.type); + case 257 /* JSDocRecordType */: + return visitNodes(cbNodes, node.members); + case 259 /* JSDocTypeReference */: + return visitNode(cbNode, node.name) || + visitNodes(cbNodes, node.typeArguments); + case 260 /* JSDocOptionalType */: + return visitNode(cbNode, node.type); + case 261 /* JSDocFunctionType */: + return visitNodes(cbNodes, node.parameters) || + visitNode(cbNode, node.type); + case 262 /* JSDocVariadicType */: + return visitNode(cbNode, node.type); + case 263 /* JSDocConstructorType */: + return visitNode(cbNode, node.type); + case 264 /* JSDocThisType */: + return visitNode(cbNode, node.type); + case 258 /* JSDocRecordMember */: + return visitNode(cbNode, node.name) || + visitNode(cbNode, node.type); + case 265 /* JSDocComment */: + return visitNodes(cbNodes, node.tags); + case 267 /* JSDocParameterTag */: + return visitNode(cbNode, node.preParameterName) || + visitNode(cbNode, node.typeExpression) || + visitNode(cbNode, node.postParameterName); + case 268 /* JSDocReturnTag */: + return visitNode(cbNode, node.typeExpression); + case 269 /* JSDocTypeTag */: + return visitNode(cbNode, node.typeExpression); + case 270 /* JSDocTemplateTag */: + return visitNodes(cbNodes, node.typeParameters); + } + } + ts.forEachChild = forEachChild; + function createSourceFile(fileName, sourceText, languageVersion, setParentNodes) { + if (setParentNodes === void 0) { setParentNodes = false; } + var start = new Date().getTime(); + var result = Parser.parseSourceFile(fileName, sourceText, languageVersion, /*syntaxCursor*/ undefined, setParentNodes); + ts.parseTime += new Date().getTime() - start; + return result; + } + ts.createSourceFile = createSourceFile; + // Produces a new SourceFile for the 'newText' provided. The 'textChangeRange' parameter + // indicates what changed between the 'text' that this SourceFile has and the 'newText'. + // The SourceFile will be created with the compiler attempting to reuse as many nodes from + // this file as possible. + // + // Note: this function mutates nodes from this SourceFile. That means any existing nodes + // from this SourceFile that are being held onto may change as a result (including + // becoming detached from any SourceFile). It is recommended that this SourceFile not + // be used once 'update' is called on it. + function updateSourceFile(sourceFile, newText, textChangeRange, aggressiveChecks) { + return IncrementalParser.updateSourceFile(sourceFile, newText, textChangeRange, aggressiveChecks); + } + ts.updateSourceFile = updateSourceFile; + /* @internal */ + function parseIsolatedJSDocComment(content, start, length) { + return Parser.JSDocParser.parseIsolatedJSDocComment(content, start, length); + } + ts.parseIsolatedJSDocComment = parseIsolatedJSDocComment; + /* @internal */ + // Exposed only for testing. + function parseJSDocTypeExpressionForTests(content, start, length) { + return Parser.JSDocParser.parseJSDocTypeExpressionForTests(content, start, length); + } + ts.parseJSDocTypeExpressionForTests = parseJSDocTypeExpressionForTests; + // Implement the parser as a singleton module. We do this for perf reasons because creating + // parser instances can actually be expensive enough to impact us on projects with many source + // files. + var Parser; + (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 disallowInAndDecoratorContext = 1 /* DisallowIn */ | 4 /* Decorator */; + var sourceFile; + var parseDiagnostics; + var syntaxCursor; + var token; + var sourceText; + var nodeCount; + var identifiers; + var identifierCount; + var parsingContext; + // Flags that dictate what parsing context we're in. For example: + // Whether or not we are in strict parsing mode. All that changes in strict parsing mode is + // that some tokens that would be considered identifiers may be considered keywords. + // + // When adding more parser context flags, consider which is the more common case that the + // flag will be in. This should be the 'false' state for that flag. The reason for this is + // that we don't store data in our nodes unless the value is in the *non-default* state. So, + // for example, more often than code 'allows-in' (or doesn't 'disallow-in'). We opt for + // 'disallow-in' set to 'false'. Otherwise, if we had 'allowsIn' set to 'true', then almost + // all nodes would need extra state on them to store this info. + // + // Note: 'allowIn' and 'allowYield' track 1:1 with the [in] and [yield] concepts in the ES6 + // grammar specification. + // + // An important thing about these context concepts. By default they are effectively inherited + // while parsing through every grammar production. i.e. if you don't change them, then when + // you parse a sub-production, it will have the same context values as the parent production. + // This is great most of the time. After all, consider all the 'expression' grammar productions + // and how nearly all of them pass along the 'in' and 'yield' context values: + // + // EqualityExpression[In, Yield] : + // RelationalExpression[?In, ?Yield] + // EqualityExpression[?In, ?Yield] == RelationalExpression[?In, ?Yield] + // EqualityExpression[?In, ?Yield] != RelationalExpression[?In, ?Yield] + // EqualityExpression[?In, ?Yield] === RelationalExpression[?In, ?Yield] + // EqualityExpression[?In, ?Yield] !== RelationalExpression[?In, ?Yield] + // + // Where you have to be careful is then understanding what the points are in the grammar + // where the values are *not* passed along. For example: + // + // SingleNameBinding[Yield,GeneratorParameter] + // [+GeneratorParameter]BindingIdentifier[Yield] Initializer[In]opt + // [~GeneratorParameter]BindingIdentifier[?Yield]Initializer[In, ?Yield]opt + // + // Here this is saying that if the GeneratorParameter context flag is set, that we should + // explicitly set the 'yield' context flag to false before calling into the BindingIdentifier + // and we should explicitly unset the 'yield' context flag before calling into the Initializer. + // production. Conversely, if the GeneratorParameter context flag is not set, then we + // should leave the 'yield' context flag alone. + // + // Getting this all correct is tricky and requires careful reading of the grammar to + // understand when these values should be changed versus when they should be inherited. + // + // Note: it should not be necessary to save/restore these flags during speculative/lookahead + // parsing. These context flags are naturally stored and restored through normal recursive + // descent parsing and unwinding. + var contextFlags; + // Whether or not we've had a parse error since creating the last AST node. If we have + // encountered an error, it will be stored on the next AST node we create. Parse errors + // can be broken down into three categories: + // + // 1) An error that occurred during scanning. For example, an unterminated literal, or a + // character that was completely not understood. + // + // 2) A token was expected, but was not present. This type of error is commonly produced + // by the 'parseExpected' function. + // + // 3) A token was present that no parsing function was able to consume. This type of error + // only occurs in the 'abortParsingListOrMoveToNextToken' function when the parser + // decides to skip the token. + // + // In all of these cases, we want to mark the next node as having had an error before it. + // With this mark, we can know in incremental settings if this node can be reused, or if + // we have to reparse it. If we don't keep this information around, we may just reuse the + // node. in that event we would then not produce the same errors as we did before, causing + // significant confusion problems. + // + // Note: it is necessary that this value be saved/restored during speculative/lookahead + // parsing. During lookahead parsing, we will often create a node. That node will have + // this value attached, and then this value will be set back to 'false'. If we decide to + // rewind, we must get back to the same value we had prior to the lookahead. + // + // 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) { + initializeState(fileName, _sourceText, languageVersion, _syntaxCursor); + var result = parseSourceFileWorker(fileName, languageVersion, setParentNodes); + clearState(); + return result; + } + Parser.parseSourceFile = parseSourceFile; + function initializeState(fileName, _sourceText, languageVersion, _syntaxCursor) { + sourceText = _sourceText; + syntaxCursor = _syntaxCursor; + parseDiagnostics = []; + parsingContext = 0; + identifiers = {}; + identifierCount = 0; + nodeCount = 0; + contextFlags = ts.isJavaScript(fileName) ? 32 /* JavaScriptFile */ : 0 /* None */; + parseErrorBeforeNextFinishedNode = false; + // Initialize and prime the scanner before parsing the source elements. + scanner.setText(sourceText); + scanner.setOnError(scanError); + scanner.setScriptTarget(languageVersion); + scanner.setLanguageVariant(ts.isTsx(fileName) ? 1 /* JSX */ : 0 /* Standard */); + } + function clearState() { + // Clear out the text the scanner is pointing at, so it doesn't keep anything alive unnecessarily. + scanner.setText(""); + scanner.setOnError(undefined); + // Clear any data. We don't want to accidently hold onto it for too long. + parseDiagnostics = undefined; + sourceFile = undefined; + identifiers = undefined; + syntaxCursor = undefined; + sourceText = undefined; + } + function parseSourceFileWorker(fileName, languageVersion, setParentNodes) { + sourceFile = createSourceFile(fileName, languageVersion); + // Prime the scanner. + token = nextToken(); + processReferenceComments(sourceFile); + sourceFile.statements = parseList(0 /* SourceElements */, parseStatement); + ts.Debug.assert(token === 1 /* EndOfFileToken */); + sourceFile.endOfFileToken = parseTokenNode(); + setExternalModuleIndicator(sourceFile); + sourceFile.nodeCount = nodeCount; + sourceFile.identifierCount = identifierCount; + sourceFile.identifiers = identifiers; + sourceFile.parseDiagnostics = parseDiagnostics; + if (setParentNodes) { + fixupParentReferences(sourceFile); + } + // If this is a javascript file, proactively see if we can get JSDoc comments for + // relevant nodes in the file. We'll use these to provide typing informaion if they're + // available. + if (ts.isJavaScript(fileName)) { + addJSDocComments(); + } + return sourceFile; + } + function addJSDocComments() { + forEachChild(sourceFile, visit); + return; + function visit(node) { + // Add additional cases as necessary depending on how we see JSDoc comments used + // in the wild. + switch (node.kind) { + case 193 /* VariableStatement */: + case 213 /* FunctionDeclaration */: + case 138 /* Parameter */: + addJSDocComment(node); + } + forEachChild(node, visit); + } + } + function addJSDocComment(node) { + var comments = ts.getLeadingCommentRangesOfNode(node, sourceFile); + if (comments) { + for (var _i = 0; _i < comments.length; _i++) { + var comment = comments[_i]; + var jsDocComment = JSDocParser.parseJSDocComment(node, comment.pos, comment.end - comment.pos); + if (jsDocComment) { + node.jsDocComment = jsDocComment; + } + } + } + } + function fixupParentReferences(sourceFile) { + // normally parent references are set during binding. However, for clients that only need + // a syntax tree, and no semantic features, then the binding process is an unnecessary + // overhead. This functions allows us to set all the parents, without all the expense of + // binding. + var parent = sourceFile; + forEachChild(sourceFile, visitNode); + return; + function visitNode(n) { + // walk down setting parents that differ from the parent we think it should be. This + // allows us to quickly bail out of setting parents for subtrees during incremental + // parsing + if (n.parent !== parent) { + n.parent = parent; + var saveParent = parent; + parent = n; + forEachChild(n, visitNode); + parent = saveParent; + } + } + } + Parser.fixupParentReferences = fixupParentReferences; + function createSourceFile(fileName, languageVersion) { + var sourceFile = createNode(248 /* SourceFile */, /*pos*/ 0); + sourceFile.pos = 0; + sourceFile.end = sourceText.length; + sourceFile.text = sourceText; + sourceFile.bindDiagnostics = []; + sourceFile.languageVersion = languageVersion; + sourceFile.fileName = ts.normalizePath(fileName); + sourceFile.flags = ts.fileExtensionIs(sourceFile.fileName, ".d.ts") ? 8192 /* DeclarationFile */ : 0; + sourceFile.languageVariant = ts.isTsx(sourceFile.fileName) ? 1 /* JSX */ : 0 /* Standard */; + return sourceFile; + } + function setContextFlag(val, flag) { + if (val) { + contextFlags |= flag; + } + else { + contextFlags &= ~flag; + } + } + function setDisallowInContext(val) { + setContextFlag(val, 1 /* DisallowIn */); + } + function setYieldContext(val) { + setContextFlag(val, 2 /* Yield */); + } + function setDecoratorContext(val) { + setContextFlag(val, 4 /* Decorator */); + } + function setAwaitContext(val) { + setContextFlag(val, 8 /* Await */); + } + function doOutsideOfContext(context, func) { + // contextFlagsToClear will contain only the context flags that are + // currently set that we need to temporarily clear + // We don't just blindly reset to the previous flags to ensure + // that we do not mutate cached flags for the incremental + // parser (ThisNodeHasError, ThisNodeOrAnySubNodesHasError, and + // HasAggregatedChildData). + var contextFlagsToClear = context & contextFlags; + if (contextFlagsToClear) { + // clear the requested context flags + setContextFlag(false, contextFlagsToClear); + var result = func(); + // restore the context flags we just cleared + setContextFlag(true, contextFlagsToClear); + return result; + } + // no need to do anything special as we are not in any of the requested contexts + return func(); + } + function doInsideOfContext(context, func) { + // contextFlagsToSet will contain only the context flags that + // are not currently set that we need to temporarily enable. + // We don't just blindly reset to the previous flags to ensure + // that we do not mutate cached flags for the incremental + // parser (ThisNodeHasError, ThisNodeOrAnySubNodesHasError, and + // HasAggregatedChildData). + var contextFlagsToSet = context & ~contextFlags; + if (contextFlagsToSet) { + // set the requested context flags + setContextFlag(true, contextFlagsToSet); + var result = func(); + // reset the context flags we just set + setContextFlag(false, contextFlagsToSet); + return result; + } + // no need to do anything special as we are already in all of the requested contexts + return func(); + } + function allowInAnd(func) { + return doOutsideOfContext(1 /* DisallowIn */, func); + } + function disallowInAnd(func) { + return doInsideOfContext(1 /* DisallowIn */, func); + } + function doInYieldContext(func) { + return doInsideOfContext(2 /* Yield */, func); + } + function doOutsideOfYieldContext(func) { + return doOutsideOfContext(2 /* Yield */, func); + } + function doInDecoratorContext(func) { + return doInsideOfContext(4 /* Decorator */, func); + } + function doInAwaitContext(func) { + return doInsideOfContext(8 /* Await */, func); + } + function doOutsideOfAwaitContext(func) { + return doOutsideOfContext(8 /* Await */, func); + } + function doInYieldAndAwaitContext(func) { + return doInsideOfContext(2 /* Yield */ | 8 /* Await */, func); + } + function doOutsideOfYieldAndAwaitContext(func) { + return doOutsideOfContext(2 /* Yield */ | 8 /* Await */, func); + } + function inContext(flags) { + return (contextFlags & flags) !== 0; + } + function inYieldContext() { + return inContext(2 /* Yield */); + } + function inDisallowInContext() { + return inContext(1 /* DisallowIn */); + } + function inDecoratorContext() { + return inContext(4 /* Decorator */); + } + function inAwaitContext() { + return inContext(8 /* Await */); + } + function parseErrorAtCurrentToken(message, arg0) { + var start = scanner.getTokenPos(); + var length = scanner.getTextPos() - start; + parseErrorAtPosition(start, length, message, arg0); + } + function parseErrorAtPosition(start, length, message, arg0) { + // Don't report another error if it would just be at the same position as the last error. + var lastError = ts.lastOrUndefined(parseDiagnostics); + if (!lastError || start !== lastError.start) { + parseDiagnostics.push(ts.createFileDiagnostic(sourceFile, start, length, message, arg0)); + } + // Mark that we've encountered an error. We'll set an appropriate bit on the next + // node we finish so that it can't be reused incrementally. + parseErrorBeforeNextFinishedNode = true; + } + function scanError(message, length) { + var pos = scanner.getTextPos(); + parseErrorAtPosition(pos, length || 0, message); + } + function getNodePos() { + return scanner.getStartPos(); + } + function getNodeEnd() { + return scanner.getStartPos(); + } + function nextToken() { + return token = scanner.scan(); + } + function getTokenPos(pos) { + return ts.skipTrivia(sourceText, pos); + } + function reScanGreaterToken() { + return token = scanner.reScanGreaterToken(); + } + function reScanSlashToken() { + return token = scanner.reScanSlashToken(); + } + function reScanTemplateToken() { + return token = scanner.reScanTemplateToken(); + } + function scanJsxIdentifier() { + return token = scanner.scanJsxIdentifier(); + } + function scanJsxText() { + return token = scanner.scanJsxToken(); + } + function speculationHelper(callback, isLookAhead) { + // Keep track of the state we'll need to rollback to if lookahead fails (or if the + // caller asked us to always reset our state). + var saveToken = token; + var saveParseDiagnosticsLength = parseDiagnostics.length; + var saveParseErrorBeforeNextFinishedNode = parseErrorBeforeNextFinishedNode; + // Note: it is not actually necessary to save/restore the context flags here. That's + // because the saving/restoring of these flags happens naturally through the recursive + // descent nature of our parser. However, we still store this here just so we can + // assert that that invariant holds. + var saveContextFlags = contextFlags; + // If we're only looking ahead, then tell the scanner to only lookahead as well. + // Otherwise, if we're actually speculatively parsing, then tell the scanner to do the + // same. + var result = isLookAhead + ? scanner.lookAhead(callback) + : scanner.tryScan(callback); + ts.Debug.assert(saveContextFlags === contextFlags); + // If our callback returned something 'falsy' or we're just looking ahead, + // then unconditionally restore us to where we were. + if (!result || isLookAhead) { + token = saveToken; + parseDiagnostics.length = saveParseDiagnosticsLength; + parseErrorBeforeNextFinishedNode = saveParseErrorBeforeNextFinishedNode; + } + return result; + } + // Invokes the provided callback then unconditionally restores the parser to the state it + // was in immediately prior to invoking the callback. The result of invoking the callback + // is returned from this function. + function lookAhead(callback) { + return speculationHelper(callback, /*isLookAhead*/ true); + } + // Invokes the provided callback. If the callback returns something falsy, then it restores + // the parser to the state it was in immediately prior to invoking the callback. If the + // callback returns something truthy, then the parser state is not rolled back. The result + // of invoking the callback is returned from this function. + function tryParse(callback) { + return speculationHelper(callback, /*isLookAhead*/ false); + } + // Ignore strict mode flag because we will report an error in type checker instead. + function isIdentifier() { + if (token === 69 /* Identifier */) { + return true; + } + // If we have a 'yield' keyword, and we're in the [yield] context, then 'yield' is + // considered a keyword and is not an identifier. + if (token === 114 /* YieldKeyword */ && inYieldContext()) { + return false; + } + // If we have a 'await' keyword, and we're in the [Await] context, then 'await' is + // considered a keyword and is not an identifier. + if (token === 119 /* AwaitKeyword */ && inAwaitContext()) { + return false; + } + return token > 105 /* LastReservedWord */; + } + function parseExpected(kind, diagnosticMessage, shouldAdvance) { + if (shouldAdvance === void 0) { shouldAdvance = true; } + if (token === kind) { + if (shouldAdvance) { + nextToken(); + } + return true; + } + // Report specific message if provided with one. Otherwise, report generic fallback message. + if (diagnosticMessage) { + parseErrorAtCurrentToken(diagnosticMessage); + } + else { + parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(kind)); + } + return false; + } + function parseOptional(t) { + if (token === t) { + nextToken(); + return true; + } + return false; + } + function parseOptionalToken(t) { + if (token === t) { + return parseTokenNode(); + } + return undefined; + } + function parseExpectedToken(t, reportAtCurrentPosition, diagnosticMessage, arg0) { + return parseOptionalToken(t) || + createMissingNode(t, reportAtCurrentPosition, diagnosticMessage, arg0); + } + function parseTokenNode() { + var node = createNode(token); + nextToken(); + return finishNode(node); + } + function canParseSemicolon() { + // If there's a real semicolon, then we can always parse it out. + if (token === 23 /* 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(); + } + function parseSemicolon() { + if (canParseSemicolon()) { + if (token === 23 /* SemicolonToken */) { + // consume the semicolon if it was explicitly provided. + nextToken(); + } + return true; + } + else { + return parseExpected(23 /* SemicolonToken */); + } + } + function createNode(kind, pos) { + nodeCount++; + if (!(pos >= 0)) { + pos = scanner.getStartPos(); + } + return new (nodeConstructors[kind] || (nodeConstructors[kind] = ts.objectAllocator.getNodeConstructor(kind)))(pos, pos); + } + function finishNode(node, end) { + node.end = end === undefined ? scanner.getStartPos() : end; + if (contextFlags) { + node.parserContextFlags = contextFlags; + } + // Keep track on the node if we encountered an error while parsing it. If we did, then + // we cannot reuse the node incrementally. Once we've marked this node, clear out the + // flag so that we don't mark any subsequent nodes. + if (parseErrorBeforeNextFinishedNode) { + parseErrorBeforeNextFinishedNode = false; + node.parserContextFlags |= 16 /* ThisNodeHasError */; + } + return node; + } + function createMissingNode(kind, reportAtCurrentPosition, diagnosticMessage, arg0) { + if (reportAtCurrentPosition) { + parseErrorAtPosition(scanner.getStartPos(), 0, diagnosticMessage, arg0); + } + else { + parseErrorAtCurrentToken(diagnosticMessage, arg0); + } + var result = createNode(kind, scanner.getStartPos()); + result.text = ""; + return finishNode(result); + } + function internIdentifier(text) { + text = ts.escapeIdentifier(text); + return ts.hasProperty(identifiers, text) ? identifiers[text] : (identifiers[text] = text); + } + // An identifier that starts with two underscores has an extra underscore character prepended to it to avoid issues + // with magic property names like '__proto__'. The 'identifiers' object is used to share a single string instance for + // each identifier in order to reduce memory consumption. + function createIdentifier(isIdentifier, diagnosticMessage) { + identifierCount++; + if (isIdentifier) { + var node = createNode(69 /* Identifier */); + // Store original token kind if it is not just an Identifier so we can report appropriate error later in type checker + if (token !== 69 /* Identifier */) { + node.originalKeywordKind = token; + } + node.text = internIdentifier(scanner.getTokenValue()); + nextToken(); + return finishNode(node); + } + return createMissingNode(69 /* Identifier */, /*reportAtCurrentPosition*/ false, diagnosticMessage || ts.Diagnostics.Identifier_expected); + } + function parseIdentifier(diagnosticMessage) { + return createIdentifier(isIdentifier(), diagnosticMessage); + } + function parseIdentifierName() { + return createIdentifier(ts.tokenIsIdentifierOrKeyword(token)); + } + function isLiteralPropertyName() { + return ts.tokenIsIdentifierOrKeyword(token) || + token === 9 /* StringLiteral */ || + token === 8 /* NumericLiteral */; + } + function parsePropertyNameWorker(allowComputedPropertyNames) { + if (token === 9 /* StringLiteral */ || token === 8 /* NumericLiteral */) { + return parseLiteralNode(/*internName*/ true); + } + if (allowComputedPropertyNames && token === 19 /* OpenBracketToken */) { + return parseComputedPropertyName(); + } + return parseIdentifierName(); + } + function parsePropertyName() { + return parsePropertyNameWorker(/*allowComputedPropertyNames:*/ true); + } + function parseSimplePropertyName() { + return parsePropertyNameWorker(/*allowComputedPropertyNames:*/ false); + } + function isSimplePropertyName() { + return token === 9 /* StringLiteral */ || token === 8 /* NumericLiteral */ || ts.tokenIsIdentifierOrKeyword(token); + } + function parseComputedPropertyName() { + // PropertyName [Yield]: + // LiteralPropertyName + // ComputedPropertyName[?Yield] + var node = createNode(136 /* ComputedPropertyName */); + parseExpected(19 /* OpenBracketToken */); + // We parse any expression (including a comma expression). But the grammar + // says that only an assignment expression is allowed, so the grammar checker + // will error if it sees a comma expression. + node.expression = allowInAnd(parseExpression); + parseExpected(20 /* CloseBracketToken */); + return finishNode(node); + } + function parseContextualModifier(t) { + return token === t && tryParse(nextTokenCanFollowModifier); + } + function nextTokenCanFollowModifier() { + if (token === 74 /* ConstKeyword */) { + // 'const' is only a modifier if followed by 'enum'. + return nextToken() === 81 /* EnumKeyword */; + } + if (token === 82 /* ExportKeyword */) { + nextToken(); + if (token === 77 /* DefaultKeyword */) { + return lookAhead(nextTokenIsClassOrFunction); + } + return token !== 37 /* AsteriskToken */ && token !== 15 /* OpenBraceToken */ && canFollowModifier(); + } + if (token === 77 /* DefaultKeyword */) { + return nextTokenIsClassOrFunction(); + } + if (token === 113 /* StaticKeyword */) { + nextToken(); + return canFollowModifier(); + } + nextToken(); + if (scanner.hasPrecedingLineBreak()) { + return false; + } + return canFollowModifier(); + } + function parseAnyContextualModifier() { + return ts.isModifier(token) && tryParse(nextTokenCanFollowModifier); + } + function canFollowModifier() { + return token === 19 /* OpenBracketToken */ + || token === 15 /* OpenBraceToken */ + || token === 37 /* AsteriskToken */ + || isLiteralPropertyName(); + } + function nextTokenIsClassOrFunction() { + nextToken(); + return token === 73 /* ClassKeyword */ || token === 87 /* FunctionKeyword */; + } + // True if positioned at the start of a list element + function isListElement(parsingContext, inErrorRecovery) { + var node = currentNode(parsingContext); + if (node) { + return true; + } + switch (parsingContext) { + case 0 /* SourceElements */: + case 1 /* BlockStatements */: + case 3 /* SwitchClauseStatements */: + // If we're in error recovery, then we don't want to treat ';' as an empty statement. + // The problem is that ';' can show up in far too many contexts, and if we see one + // and assume it's a statement, then we may bail out inappropriately from whatever + // 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(); + case 2 /* SwitchClauses */: + return token === 71 /* CaseKeyword */ || token === 77 /* DefaultKeyword */; + case 4 /* TypeMembers */: + return isStartOfTypeMember(); + case 5 /* ClassMembers */: + // We allow semicolons as class elements (as specified by ES6) as long as we're + // 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); + 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(); + case 12 /* ObjectLiteralMembers */: + return token === 19 /* OpenBracketToken */ || token === 37 /* AsteriskToken */ || isLiteralPropertyName(); + case 9 /* ObjectBindingElements */: + return 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 */) { + return lookAhead(isValidHeritageClauseObjectLiteral); + } + if (!inErrorRecovery) { + return isStartOfLeftHandSideExpression() && !isHeritageClauseExtendsOrImplementsKeyword(); + } + else { + // If we're in error recovery we tighten up what we're willing to match. + // That way we don't treat something like "this" as a valid heritage clause + // element during recovery. + return isIdentifier() && !isHeritageClauseExtendsOrImplementsKeyword(); + } + case 8 /* VariableDeclarations */: + return isIdentifierOrPattern(); + case 10 /* ArrayBindingElements */: + return token === 24 /* CommaToken */ || token === 22 /* DotDotDotToken */ || isIdentifierOrPattern(); + case 17 /* TypeParameters */: + return isIdentifier(); + case 11 /* ArgumentExpressions */: + case 15 /* ArrayLiteralMembers */: + return token === 24 /* CommaToken */ || token === 22 /* DotDotDotToken */ || isStartOfExpression(); + case 16 /* Parameters */: + return isStartOfParameter(); + case 18 /* TypeArguments */: + case 19 /* TupleElementTypes */: + return token === 24 /* CommaToken */ || isStartOfType(); + case 20 /* HeritageClauses */: + return isHeritageClause(); + case 21 /* ImportOrExportSpecifiers */: + return ts.tokenIsIdentifierOrKeyword(token); + case 13 /* JsxAttributes */: + return ts.tokenIsIdentifierOrKeyword(token) || token === 15 /* OpenBraceToken */; + case 14 /* JsxChildren */: + return true; + case 22 /* JSDocFunctionParameters */: + case 23 /* JSDocTypeArguments */: + case 25 /* JSDocTupleTypes */: + return JSDocParser.isJSDocType(); + case 24 /* JSDocRecordMembers */: + return isSimplePropertyName(); + } + ts.Debug.fail("Non-exhaustive case in 'isListElement'."); + } + function isValidHeritageClauseObjectLiteral() { + ts.Debug.assert(token === 15 /* OpenBraceToken */); + if (nextToken() === 16 /* CloseBraceToken */) { + // if we see "extends {}" then only treat the {} as what we're extending (and not + // the class body) if we have: + // + // extends {} { + // extends {}, + // extends {} extends + // extends {} implements + var next = nextToken(); + return next === 24 /* CommaToken */ || next === 15 /* OpenBraceToken */ || next === 83 /* ExtendsKeyword */ || next === 106 /* ImplementsKeyword */; + } + return true; + } + function nextTokenIsIdentifier() { + nextToken(); + return isIdentifier(); + } + function nextTokenIsIdentifierOrKeyword() { + nextToken(); + return ts.tokenIsIdentifierOrKeyword(token); + } + function isHeritageClauseExtendsOrImplementsKeyword() { + if (token === 106 /* ImplementsKeyword */ || + token === 83 /* ExtendsKeyword */) { + return lookAhead(nextTokenIsStartOfExpression); + } + return false; + } + function nextTokenIsStartOfExpression() { + nextToken(); + return isStartOfExpression(); + } + // True if positioned at a list terminator + function isListTerminator(kind) { + if (token === 1 /* EndOfFileToken */) { + // Being at the end of the file ends all lists. + return true; + } + switch (kind) { + case 1 /* BlockStatements */: + case 2 /* SwitchClauses */: + case 4 /* TypeMembers */: + case 5 /* ClassMembers */: + case 6 /* EnumMembers */: + case 12 /* ObjectLiteralMembers */: + case 9 /* ObjectBindingElements */: + case 21 /* ImportOrExportSpecifiers */: + return token === 16 /* CloseBraceToken */; + case 3 /* SwitchClauseStatements */: + return token === 16 /* CloseBraceToken */ || token === 71 /* CaseKeyword */ || token === 77 /* DefaultKeyword */; + case 7 /* HeritageClauseElement */: + return token === 15 /* OpenBraceToken */ || token === 83 /* ExtendsKeyword */ || token === 106 /* ImplementsKeyword */; + case 8 /* VariableDeclarations */: + return isVariableDeclaratorListTerminator(); + case 17 /* TypeParameters */: + // Tokens other than '>' are here for better error recovery + return token === 27 /* GreaterThanToken */ || token === 17 /* OpenParenToken */ || token === 15 /* OpenBraceToken */ || token === 83 /* ExtendsKeyword */ || token === 106 /* ImplementsKeyword */; + case 11 /* ArgumentExpressions */: + // Tokens other than ')' are here for better error recovery + return token === 18 /* CloseParenToken */ || token === 23 /* SemicolonToken */; + case 15 /* ArrayLiteralMembers */: + case 19 /* TupleElementTypes */: + case 10 /* ArrayBindingElements */: + return token === 20 /* 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*/; + case 18 /* TypeArguments */: + // Tokens other than '>' are here for better error recovery + return token === 27 /* GreaterThanToken */ || token === 17 /* OpenParenToken */; + case 20 /* HeritageClauses */: + return token === 15 /* OpenBraceToken */ || token === 16 /* CloseBraceToken */; + case 13 /* JsxAttributes */: + return token === 27 /* GreaterThanToken */ || token === 39 /* SlashToken */; + case 14 /* JsxChildren */: + return token === 25 /* LessThanToken */ && lookAhead(nextTokenIsSlash); + case 22 /* JSDocFunctionParameters */: + return token === 18 /* CloseParenToken */ || token === 54 /* ColonToken */ || token === 16 /* CloseBraceToken */; + case 23 /* JSDocTypeArguments */: + return token === 27 /* GreaterThanToken */ || token === 16 /* CloseBraceToken */; + case 25 /* JSDocTupleTypes */: + return token === 20 /* CloseBracketToken */ || token === 16 /* CloseBraceToken */; + case 24 /* JSDocRecordMembers */: + return token === 16 /* CloseBraceToken */; + } + } + function isVariableDeclaratorListTerminator() { + // If we can consume a semicolon (either explicitly, or with ASI), then consider us done + // with parsing the list of variable declarators. + if (canParseSemicolon()) { + return true; + } + // in the case where we're parsing the variable declarator of a 'for-in' statement, we + // are done if we see an 'in' keyword in front of us. Same with for-of + if (isInOrOfKeyword(token)) { + return true; + } + // ERROR RECOVERY TWEAK: + // 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 */) { + return true; + } + // Keep trying to parse out variable declarators. + return false; + } + // True if positioned at element or terminator of the current list or any enclosing list + function isInSomeParsingContext() { + for (var kind = 0; kind < 26 /* Count */; kind++) { + if (parsingContext & (1 << kind)) { + if (isListElement(kind, /* inErrorRecovery */ true) || isListTerminator(kind)) { + return true; + } + } + } + return false; + } + // Parses a list of elements + function parseList(kind, parseElement) { + var saveParsingContext = parsingContext; + parsingContext |= 1 << kind; + var result = []; + result.pos = getNodePos(); + while (!isListTerminator(kind)) { + if (isListElement(kind, /* inErrorRecovery */ false)) { + var element = parseListElement(kind, parseElement); + result.push(element); + continue; + } + if (abortParsingListOrMoveToNextToken(kind)) { + break; + } + } + result.end = getNodeEnd(); + parsingContext = saveParsingContext; + return result; + } + function parseListElement(parsingContext, parseElement) { + var node = currentNode(parsingContext); + if (node) { + return consumeNode(node); + } + return parseElement(); + } + function currentNode(parsingContext) { + // If there is an outstanding parse error that we've encountered, but not attached to + // some node, then we cannot get a node from the old source tree. This is because we + // want to mark the next node we encounter as being unusable. + // + // Note: This may be too conservative. Perhaps we could reuse the node and set the bit + // on it (or its leftmost child) as having the error. For now though, being conservative + // is nice and likely won't ever affect perf. + if (parseErrorBeforeNextFinishedNode) { + return undefined; + } + if (!syntaxCursor) { + // if we don't have a cursor, we could never return a node from the old tree. + return undefined; + } + var node = syntaxCursor.currentNode(scanner.getStartPos()); + // Can't reuse a missing node. + if (ts.nodeIsMissing(node)) { + return undefined; + } + // Can't reuse a node that intersected the change range. + if (node.intersectsChange) { + return undefined; + } + // Can't reuse a node that contains a parse error. This is necessary so that we + // produce the same set of errors again. + if (ts.containsParseError(node)) { + return undefined; + } + // We can only reuse a node if it was parsed under the same strict mode that we're + // currently in. i.e. if we originally parsed a node in non-strict mode, but then + // the user added 'using strict' at the top of the file, then we can't use that node + // again as the presense of strict mode may cause us to parse the tokens in the file + // differetly. + // + // Note: we *can* reuse tokens when the strict mode changes. That's because tokens + // are unaffected by strict mode. It's just the parser will decide what to do with it + // differently depending on what mode it is in. + // + // This also applies to all our other context flags as well. + var nodeContextFlags = node.parserContextFlags & 31 /* ParserGeneratedFlags */; + if (nodeContextFlags !== contextFlags) { + return undefined; + } + // Ok, we have a node that looks like it could be reused. Now verify that it is valid + // in the currest list parsing context that we're currently at. + if (!canReuseNode(node, parsingContext)) { + return undefined; + } + return node; + } + function consumeNode(node) { + // Move the scanner so it is after the node we just consumed. + scanner.setTextPos(node.end); + nextToken(); + return node; + } + function canReuseNode(node, parsingContext) { + switch (parsingContext) { + case 5 /* ClassMembers */: + return isReusableClassMember(node); + case 2 /* SwitchClauses */: + return isReusableSwitchClause(node); + case 0 /* SourceElements */: + case 1 /* BlockStatements */: + case 3 /* SwitchClauseStatements */: + return isReusableStatement(node); + case 6 /* EnumMembers */: + return isReusableEnumMember(node); + case 4 /* TypeMembers */: + return isReusableTypeMember(node); + case 8 /* VariableDeclarations */: + return isReusableVariableDeclaration(node); + case 16 /* Parameters */: + return isReusableParameter(node); + // Any other lists we do not care about reusing nodes in. But feel free to add if + // you can do so safely. Danger areas involve nodes that may involve speculative + // parsing. If speculative parsing is involved with the node, then the range the + // parser reached while looking ahead might be in the edited range (see the example + // in canReuseVariableDeclaratorNode for a good case of this). + case 20 /* HeritageClauses */: + // This would probably be safe to reuse. There is no speculative parsing with + // heritage clauses. + case 17 /* TypeParameters */: + // This would probably be safe to reuse. There is no speculative parsing with + // type parameters. Note that that's because type *parameters* only occur in + // unambiguous *type* contexts. While type *arguments* occur in very ambiguous + // *expression* contexts. + case 19 /* TupleElementTypes */: + // This would probably be safe to reuse. There is no speculative parsing with + // tuple types. + // Technically, type argument list types are probably safe to reuse. While + // speculative parsing is involved with them (since type argument lists are only + // produced from speculative parsing a < as a type argument list), we only have + // the types because speculative parsing succeeded. Thus, the lookahead never + // went past the end of the list and rewound. + case 18 /* TypeArguments */: + // Note: these are almost certainly not safe to ever reuse. Expressions commonly + // need a large amount of lookahead, and we should not reuse them as they may + // have actually intersected the edit. + case 11 /* ArgumentExpressions */: + // This is not safe to reuse for the same reason as the 'AssignmentExpression' + // cases. i.e. a property assignment may end with an expression, and thus might + // have lookahead far beyond it's old node. + case 12 /* ObjectLiteralMembers */: + // This is probably not safe to reuse. There can be speculative parsing with + // type names in a heritage clause. There can be generic names in the type + // name list, and there can be left hand side expressions (which can have type + // arguments.) + case 7 /* HeritageClauseElement */: + // Perhaps safe to reuse, but it's unlikely we'd see more than a dozen attributes + // on any given element. Same for children. + case 13 /* JsxAttributes */: + case 14 /* JsxChildren */: + } + return false; + } + function isReusableClassMember(node) { + if (node) { + switch (node.kind) { + case 144 /* Constructor */: + case 149 /* IndexSignature */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: + case 141 /* PropertyDeclaration */: + case 191 /* SemicolonClassElement */: + return true; + case 143 /* MethodDeclaration */: + // Method declarations are not necessarily reusable. An object-literal + // may have a method calls "constructor(...)" and we must reparse that + // into an actual .ConstructorDeclaration. + var methodDeclaration = node; + var nameIsConstructor = methodDeclaration.name.kind === 69 /* Identifier */ && + methodDeclaration.name.originalKeywordKind === 121 /* ConstructorKeyword */; + return !nameIsConstructor; + } + } + return false; + } + function isReusableSwitchClause(node) { + if (node) { + switch (node.kind) { + case 241 /* CaseClause */: + case 242 /* DefaultClause */: + return true; + } + } + return false; + } + function isReusableStatement(node) { + if (node) { + switch (node.kind) { + case 213 /* FunctionDeclaration */: + case 193 /* VariableStatement */: + case 192 /* Block */: + case 196 /* IfStatement */: + case 195 /* ExpressionStatement */: + case 208 /* ThrowStatement */: + case 204 /* ReturnStatement */: + case 206 /* SwitchStatement */: + case 203 /* BreakStatement */: + case 202 /* ContinueStatement */: + case 200 /* ForInStatement */: + case 201 /* ForOfStatement */: + case 199 /* ForStatement */: + case 198 /* WhileStatement */: + case 205 /* WithStatement */: + case 194 /* EmptyStatement */: + case 209 /* TryStatement */: + case 207 /* LabeledStatement */: + case 197 /* DoStatement */: + case 210 /* DebuggerStatement */: + case 222 /* ImportDeclaration */: + case 221 /* ImportEqualsDeclaration */: + case 228 /* ExportDeclaration */: + case 227 /* ExportAssignment */: + case 218 /* ModuleDeclaration */: + case 214 /* ClassDeclaration */: + case 215 /* InterfaceDeclaration */: + case 217 /* EnumDeclaration */: + case 216 /* TypeAliasDeclaration */: + return true; + } + } + return false; + } + function isReusableEnumMember(node) { + return node.kind === 247 /* EnumMember */; + } + function isReusableTypeMember(node) { + if (node) { + switch (node.kind) { + case 148 /* ConstructSignature */: + case 142 /* MethodSignature */: + case 149 /* IndexSignature */: + case 140 /* PropertySignature */: + case 147 /* CallSignature */: + return true; + } + } + return false; + } + function isReusableVariableDeclaration(node) { + if (node.kind !== 211 /* VariableDeclaration */) { + return false; + } + // Very subtle incremental parsing bug. Consider the following code: + // + // let v = new List < A, B + // + // This is actually legal code. It's a list of variable declarators "v = new List() + // + // then we have a problem. "v = new List= 0) { + // Always preserve a trailing comma by marking it on the NodeArray + result.hasTrailingComma = true; + } + result.end = getNodeEnd(); + parsingContext = saveParsingContext; + return result; + } + function createMissingList() { + var pos = getNodePos(); + var result = []; + result.pos = pos; + result.end = pos; + return result; + } + function parseBracketedList(kind, parseElement, open, close) { + if (parseExpected(open)) { + var result = parseDelimitedList(kind, parseElement); + parseExpected(close); + return result; + } + return createMissingList(); + } + // 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(135 /* QualifiedName */, entity.pos); + node.left = entity; + node.right = parseRightSideOfDot(allowReservedWords); + entity = finishNode(node); + } + return entity; + } + function parseRightSideOfDot(allowIdentifierNames) { + // Technically a keyword is valid here as all identifiers and keywords are identifier names. + // However, often we'll encounter this in error situations when the identifier or keyword + // is actually starting another valid construct. + // + // So, we check for the following specific case: + // + // name. + // identifierOrKeyword identifierNameOrKeyword + // + // Note: the newlines are important here. For example, if that above code + // were rewritten into: + // + // name.identifierOrKeyword + // identifierNameOrKeyword + // + // Then we would consider it valid. That's because ASI would take effect and + // the code would be implicitly: "name.identifierOrKeyword; identifierNameOrKeyword". + // In the first case though, ASI will not take effect because there is not a + // line terminator after the identifier or keyword. + if (scanner.hasPrecedingLineBreak() && ts.tokenIsIdentifierOrKeyword(token)) { + var matchesPattern = lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine); + if (matchesPattern) { + // 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 */, /*reportAtCurrentToken*/ true, ts.Diagnostics.Identifier_expected); + } + } + return allowIdentifierNames ? parseIdentifierName() : parseIdentifier(); + } + function parseTemplateExpression() { + var template = createNode(183 /* TemplateExpression */); + template.head = parseLiteralNode(); + ts.Debug.assert(template.head.kind === 12 /* TemplateHead */, "Template head has wrong token kind"); + var templateSpans = []; + templateSpans.pos = getNodePos(); + do { + templateSpans.push(parseTemplateSpan()); + } while (ts.lastOrUndefined(templateSpans).literal.kind === 13 /* TemplateMiddle */); + templateSpans.end = getNodeEnd(); + template.templateSpans = templateSpans; + return finishNode(template); + } + function parseTemplateSpan() { + var span = createNode(190 /* TemplateSpan */); + span.expression = allowInAnd(parseExpression); + var literal; + if (token === 16 /* CloseBraceToken */) { + reScanTemplateToken(); + literal = parseLiteralNode(); + } + else { + literal = parseExpectedToken(14 /* TemplateTail */, /*reportAtCurrentPosition*/ false, ts.Diagnostics._0_expected, ts.tokenToString(16 /* CloseBraceToken */)); + } + span.literal = literal; + return finishNode(span); + } + function parseLiteralNode(internName) { + var node = createNode(token); + var text = scanner.getTokenValue(); + node.text = internName ? internIdentifier(text) : text; + if (scanner.hasExtendedUnicodeEscape()) { + node.hasExtendedUnicodeEscape = true; + } + if (scanner.isUnterminated()) { + node.isUnterminated = true; + } + var tokenPos = scanner.getTokenPos(); + nextToken(); + finishNode(node); + // Octal literals are not allowed in strict mode or ES5 + // Note that theoretically the following condition would hold true literals like 009, + // which is not octal.But because of how the scanner separates the tokens, we would + // never get a token like this. Instead, we would get 00 and 9 as two separate tokens. + // We also do not need to check for negatives because any prefix operator would be part of a + // parent unary expression. + if (node.kind === 8 /* NumericLiteral */ + && sourceText.charCodeAt(tokenPos) === 48 /* _0 */ + && ts.isOctalDigit(sourceText.charCodeAt(tokenPos + 1))) { + node.flags |= 65536 /* OctalLiteral */; + } + return node; + } + // TYPES + function parseTypeReferenceOrTypePredicate() { + var typeName = parseEntityName(/*allowReservedWords*/ false, ts.Diagnostics.Type_expected); + if (typeName.kind === 69 /* Identifier */ && token === 124 /* IsKeyword */ && !scanner.hasPrecedingLineBreak()) { + nextToken(); + var node_1 = createNode(150 /* TypePredicate */, typeName.pos); + node_1.parameterName = typeName; + node_1.type = parseType(); + return finishNode(node_1); + } + var node = createNode(151 /* TypeReference */, typeName.pos); + node.typeName = typeName; + if (!scanner.hasPrecedingLineBreak() && token === 25 /* LessThanToken */) { + node.typeArguments = parseBracketedList(18 /* TypeArguments */, parseType, 25 /* LessThanToken */, 27 /* GreaterThanToken */); + } + return finishNode(node); + } + function parseTypeQuery() { + var node = createNode(154 /* TypeQuery */); + parseExpected(101 /* TypeOfKeyword */); + node.exprName = parseEntityName(/*allowReservedWords*/ true); + return finishNode(node); + } + function parseTypeParameter() { + var node = createNode(137 /* TypeParameter */); + node.name = parseIdentifier(); + if (parseOptional(83 /* ExtendsKeyword */)) { + // It's not uncommon for people to write improper constraints to a generic. If the + // user writes a constraint that is an expression and not an actual type, then parse + // it out as an expression (so we can recover well), but report that a type is needed + // instead. + if (isStartOfType() || !isStartOfExpression()) { + node.constraint = parseType(); + } + else { + // It was not a type, and it looked like an expression. Parse out an expression + // here so we recover well. Note: it is important that we call parseUnaryExpression + // and not parseExpression here. If the user has: + // + // + // + // We do *not* want to consume the > as we're consuming the expression for "". + node.expression = parseUnaryExpressionOrHigher(); + } + } + return finishNode(node); + } + function parseTypeParameters() { + if (token === 25 /* LessThanToken */) { + return parseBracketedList(17 /* TypeParameters */, parseTypeParameter, 25 /* LessThanToken */, 27 /* GreaterThanToken */); + } + } + function parseParameterType() { + if (parseOptional(54 /* ColonToken */)) { + return token === 9 /* StringLiteral */ + ? parseLiteralNode(/*internName*/ true) + : parseType(); + } + return undefined; + } + function isStartOfParameter() { + return token === 22 /* DotDotDotToken */ || isIdentifierOrPattern() || ts.isModifier(token) || token === 55 /* AtToken */; + } + function setModifiers(node, modifiers) { + if (modifiers) { + node.flags |= modifiers.flags; + node.modifiers = modifiers; + } + } + function parseParameter() { + var node = createNode(138 /* Parameter */); + node.decorators = parseDecorators(); + setModifiers(node, parseModifiers()); + node.dotDotDotToken = parseOptionalToken(22 /* DotDotDotToken */); + // FormalParameter [Yield,Await]: + // BindingElement[?Yield,?Await] + node.name = parseIdentifierOrPattern(); + if (ts.getFullWidth(node.name) === 0 && node.flags === 0 && ts.isModifier(token)) { + // in cases like + // 'use strict' + // function foo(static) + // isParameter('static') === true, because of isModifier('static') + // however 'static' is not a legal identifier in a strict mode. + // so result of this function will be ParameterDeclaration (flags = 0, name = missing, type = undefined, initializer = undefined) + // and current token will not change => parsing of the enclosing parameter list will last till the end of time (or OOM) + // to avoid this we'll advance cursor to the next token. + nextToken(); + } + node.questionToken = parseOptionalToken(53 /* QuestionToken */); + node.type = parseParameterType(); + node.initializer = parseBindingElementInitializer(/*inParameter*/ true); + // Do not check for initializers in an ambient context for parameters. This is not + // a grammar error because the grammar allows arbitrary call signatures in + // an ambient context. + // It is actually not necessary for this to be an error at all. The reason is that + // function/constructor implementations are syntactically disallowed in ambient + // contexts. In addition, parameter initializers are semantically disallowed in + // overload signatures. So parameter initializers are transitively disallowed in + // ambient contexts. + return finishNode(node); + } + function parseBindingElementInitializer(inParameter) { + return inParameter ? parseParameterInitializer() : parseNonParameterInitializer(); + } + function parseParameterInitializer() { + return parseInitializer(/*inParameter*/ true); + } + function fillSignature(returnToken, yieldContext, awaitContext, requireCompleteParameterList, signature) { + var returnTokenRequired = returnToken === 34 /* EqualsGreaterThanToken */; + signature.typeParameters = parseTypeParameters(); + signature.parameters = parseParameterList(yieldContext, awaitContext, requireCompleteParameterList); + if (returnTokenRequired) { + parseExpected(returnToken); + signature.type = parseType(); + } + else if (parseOptional(returnToken)) { + signature.type = parseType(); + } + } + function parseParameterList(yieldContext, awaitContext, requireCompleteParameterList) { + // FormalParameters [Yield,Await]: (modified) + // [empty] + // FormalParameterList[?Yield,Await] + // + // FormalParameter[Yield,Await]: (modified) + // BindingElement[?Yield,Await] + // + // BindingElement [Yield,Await]: (modified) + // SingleNameBinding[?Yield,?Await] + // BindingPattern[?Yield,?Await]Initializer [In, ?Yield,?Await] opt + // + // SingleNameBinding [Yield,Await]: + // BindingIdentifier[?Yield,?Await]Initializer [In, ?Yield,?Await] opt + if (parseExpected(17 /* OpenParenToken */)) { + var savedYieldContext = inYieldContext(); + var savedAwaitContext = inAwaitContext(); + setYieldContext(yieldContext); + setAwaitContext(awaitContext); + var result = parseDelimitedList(16 /* Parameters */, parseParameter); + setYieldContext(savedYieldContext); + setAwaitContext(savedAwaitContext); + if (!parseExpected(18 /* CloseParenToken */) && requireCompleteParameterList) { + // Caller insisted that we had to end with a ) We didn't. So just return + // undefined here. + return undefined; + } + return result; + } + // We didn't even have an open paren. If the caller requires a complete parameter list, + // we definitely can't provide that. However, if they're ok with an incomplete one, + // then just return an empty set of parameters. + return requireCompleteParameterList ? undefined : createMissingList(); + } + 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 */)) { + return; + } + // Didn't have a comma. We must have a (possible ASI) semicolon. + parseSemicolon(); + } + function parseSignatureMember(kind) { + var node = createNode(kind); + if (kind === 148 /* ConstructSignature */) { + parseExpected(92 /* NewKeyword */); + } + fillSignature(54 /* ColonToken */, /*yieldContext*/ false, /*awaitContext*/ false, /*requireCompleteParameterList*/ false, node); + parseTypeMemberSemicolon(); + return finishNode(node); + } + function isIndexSignature() { + if (token !== 19 /* OpenBracketToken */) { + return false; + } + return lookAhead(isUnambiguouslyIndexSignature); + } + function isUnambiguouslyIndexSignature() { + // The only allowed sequence is: + // + // [id: + // + // However, for error recovery, we also check the following cases: + // + // [... + // [id, + // [id?, + // [id?: + // [id?] + // [public id + // [private id + // [protected id + // [] + // + nextToken(); + if (token === 22 /* DotDotDotToken */ || token === 20 /* CloseBracketToken */) { + return true; + } + if (ts.isModifier(token)) { + nextToken(); + if (isIdentifier()) { + return true; + } + } + else if (!isIdentifier()) { + return false; + } + else { + // Skip the identifier + nextToken(); + } + // 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 */) { + 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 */) { + 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 */; + } + function parseIndexSignatureDeclaration(fullStart, decorators, modifiers) { + var node = createNode(149 /* IndexSignature */, fullStart); + node.decorators = decorators; + setModifiers(node, modifiers); + node.parameters = parseBracketedList(16 /* Parameters */, parseParameter, 19 /* OpenBracketToken */, 20 /* CloseBracketToken */); + node.type = parseTypeAnnotation(); + parseTypeMemberSemicolon(); + return finishNode(node); + } + function parsePropertyOrMethodSignature() { + var fullStart = scanner.getStartPos(); + var name = parsePropertyName(); + var questionToken = parseOptionalToken(53 /* QuestionToken */); + if (token === 17 /* OpenParenToken */ || token === 25 /* LessThanToken */) { + var method = createNode(142 /* MethodSignature */, fullStart); + method.name = name; + method.questionToken = questionToken; + // Method signatues don't exist in expression contexts. So they have neither + // [Yield] nor [Await] + fillSignature(54 /* ColonToken */, /*yieldContext*/ false, /*awaitContext*/ false, /*requireCompleteParameterList*/ false, method); + parseTypeMemberSemicolon(); + return finishNode(method); + } + else { + var property = createNode(140 /* PropertySignature */, fullStart); + property.name = name; + property.questionToken = questionToken; + property.type = parseTypeAnnotation(); + parseTypeMemberSemicolon(); + return finishNode(property); + } + } + function isStartOfTypeMember() { + switch (token) { + case 17 /* OpenParenToken */: + case 25 /* LessThanToken */: + case 19 /* OpenBracketToken */: + return true; + default: + if (ts.isModifier(token)) { + var result = lookAhead(isStartOfIndexSignatureDeclaration); + if (result) { + return result; + } + } + return isLiteralPropertyName() && lookAhead(isTypeMemberWithLiteralPropertyName); + } + } + function isStartOfIndexSignatureDeclaration() { + while (ts.isModifier(token)) { + nextToken(); + } + return isIndexSignature(); + } + function isTypeMemberWithLiteralPropertyName() { + nextToken(); + return token === 17 /* OpenParenToken */ || + token === 25 /* LessThanToken */ || + token === 53 /* QuestionToken */ || + token === 54 /* ColonToken */ || + canParseSemicolon(); + } + function parseTypeMember() { + switch (token) { + case 17 /* OpenParenToken */: + case 25 /* LessThanToken */: + return parseSignatureMember(147 /* CallSignature */); + case 19 /* OpenBracketToken */: + // Indexer or computed property + return isIndexSignature() + ? parseIndexSignatureDeclaration(scanner.getStartPos(), /*decorators*/ undefined, /*modifiers*/ undefined) + : parsePropertyOrMethodSignature(); + case 92 /* NewKeyword */: + if (lookAhead(isStartOfConstructSignature)) { + return parseSignatureMember(148 /* ConstructSignature */); + } + // fall through. + case 9 /* StringLiteral */: + case 8 /* NumericLiteral */: + return parsePropertyOrMethodSignature(); + default: + // Index declaration as allowed as a type member. But as per the grammar, + // they also allow modifiers. So we have to check for an index declaration + // that might be following modifiers. This ensures that things work properly + // when incrementally parsing as the parser will produce the Index declaration + // if it has the same text regardless of whether it is inside a class or an + // object type. + if (ts.isModifier(token)) { + var result = tryParse(parseIndexSignatureWithModifiers); + if (result) { + return result; + } + } + if (ts.tokenIsIdentifierOrKeyword(token)) { + return parsePropertyOrMethodSignature(); + } + } + } + function parseIndexSignatureWithModifiers() { + var fullStart = scanner.getStartPos(); + var decorators = parseDecorators(); + var modifiers = parseModifiers(); + return isIndexSignature() + ? parseIndexSignatureDeclaration(fullStart, decorators, modifiers) + : undefined; + } + function isStartOfConstructSignature() { + nextToken(); + return token === 17 /* OpenParenToken */ || token === 25 /* LessThanToken */; + } + function parseTypeLiteral() { + var node = createNode(155 /* TypeLiteral */); + node.members = parseObjectTypeMembers(); + return finishNode(node); + } + function parseObjectTypeMembers() { + var members; + if (parseExpected(15 /* OpenBraceToken */)) { + members = parseList(4 /* TypeMembers */, parseTypeMember); + parseExpected(16 /* CloseBraceToken */); + } + else { + members = createMissingList(); + } + return members; + } + function parseTupleType() { + var node = createNode(157 /* TupleType */); + node.elementTypes = parseBracketedList(19 /* TupleElementTypes */, parseType, 19 /* OpenBracketToken */, 20 /* CloseBracketToken */); + return finishNode(node); + } + function parseParenthesizedType() { + var node = createNode(160 /* ParenthesizedType */); + parseExpected(17 /* OpenParenToken */); + node.type = parseType(); + parseExpected(18 /* CloseParenToken */); + return finishNode(node); + } + function parseFunctionOrConstructorType(kind) { + var node = createNode(kind); + if (kind === 153 /* ConstructorType */) { + parseExpected(92 /* NewKeyword */); + } + fillSignature(34 /* EqualsGreaterThanToken */, /*yieldContext*/ false, /*awaitContext*/ false, /*requireCompleteParameterList*/ false, node); + return finishNode(node); + } + function parseKeywordAndNoDot() { + var node = parseTokenNode(); + return token === 21 /* DotToken */ ? undefined : node; + } + function parseNonArrayType() { + switch (token) { + case 117 /* AnyKeyword */: + case 130 /* StringKeyword */: + case 128 /* NumberKeyword */: + case 120 /* BooleanKeyword */: + case 131 /* SymbolKeyword */: + // If these are followed by a dot, then parse these out as a dotted type reference instead. + var node = tryParse(parseKeywordAndNoDot); + return node || parseTypeReferenceOrTypePredicate(); + case 103 /* VoidKeyword */: + case 97 /* ThisKeyword */: + return parseTokenNode(); + case 101 /* TypeOfKeyword */: + return parseTypeQuery(); + case 15 /* OpenBraceToken */: + return parseTypeLiteral(); + case 19 /* OpenBracketToken */: + return parseTupleType(); + case 17 /* OpenParenToken */: + return parseParenthesizedType(); + default: + return parseTypeReferenceOrTypePredicate(); + } + } + function isStartOfType() { + switch (token) { + case 117 /* AnyKeyword */: + case 130 /* StringKeyword */: + case 128 /* NumberKeyword */: + case 120 /* BooleanKeyword */: + case 131 /* SymbolKeyword */: + case 103 /* VoidKeyword */: + case 97 /* ThisKeyword */: + case 101 /* TypeOfKeyword */: + case 15 /* OpenBraceToken */: + case 19 /* OpenBracketToken */: + case 25 /* LessThanToken */: + case 92 /* NewKeyword */: + return true; + case 17 /* 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); + default: + return isIdentifier(); + } + } + function isStartOfParenthesizedOrFunctionType() { + nextToken(); + return token === 18 /* CloseParenToken */ || isStartOfParameter() || isStartOfType(); + } + function parseArrayTypeOrHigher() { + var type = parseNonArrayType(); + while (!scanner.hasPrecedingLineBreak() && parseOptional(19 /* OpenBracketToken */)) { + parseExpected(20 /* CloseBracketToken */); + var node = createNode(156 /* ArrayType */, type.pos); + node.elementType = type; + type = finishNode(node); + } + return type; + } + function parseUnionOrIntersectionType(kind, parseConstituentType, operator) { + var type = parseConstituentType(); + if (token === operator) { + var types = [type]; + types.pos = type.pos; + while (parseOptional(operator)) { + types.push(parseConstituentType()); + } + types.end = getNodeEnd(); + var node = createNode(kind, type.pos); + node.types = types; + type = finishNode(node); + } + return type; + } + function parseIntersectionTypeOrHigher() { + return parseUnionOrIntersectionType(159 /* IntersectionType */, parseArrayTypeOrHigher, 46 /* AmpersandToken */); + } + function parseUnionTypeOrHigher() { + return parseUnionOrIntersectionType(158 /* UnionType */, parseIntersectionTypeOrHigher, 47 /* BarToken */); + } + function isStartOfFunctionType() { + if (token === 25 /* LessThanToken */) { + return true; + } + return token === 17 /* OpenParenToken */ && lookAhead(isUnambiguouslyStartOfFunctionType); + } + function isUnambiguouslyStartOfFunctionType() { + nextToken(); + if (token === 18 /* CloseParenToken */ || token === 22 /* DotDotDotToken */) { + // ( ) + // ( ... + return true; + } + if (isIdentifier() || ts.isModifier(token)) { + nextToken(); + if (token === 54 /* ColonToken */ || token === 24 /* CommaToken */ || + token === 53 /* QuestionToken */ || token === 56 /* EqualsToken */ || + isIdentifier() || ts.isModifier(token)) { + // ( id : + // ( id , + // ( id ? + // ( id = + // ( modifier id + return true; + } + if (token === 18 /* CloseParenToken */) { + nextToken(); + if (token === 34 /* EqualsGreaterThanToken */) { + // ( id ) => + return true; + } + } + } + return false; + } + function parseType() { + // The rules about 'yield' only apply to actual code/expression contexts. They don't + // apply to 'type' contexts. So we disable these parameters here before moving on. + return doOutsideOfContext(10 /* TypeExcludesFlags */, parseTypeWorker); + } + function parseTypeWorker() { + if (isStartOfFunctionType()) { + return parseFunctionOrConstructorType(152 /* FunctionType */); + } + if (token === 92 /* NewKeyword */) { + return parseFunctionOrConstructorType(153 /* ConstructorType */); + } + return parseUnionTypeOrHigher(); + } + function parseTypeAnnotation() { + return parseOptional(54 /* ColonToken */) ? parseType() : undefined; + } + // EXPRESSIONS + function isStartOfLeftHandSideExpression() { + switch (token) { + case 97 /* ThisKeyword */: + case 95 /* SuperKeyword */: + case 93 /* NullKeyword */: + case 99 /* TrueKeyword */: + case 84 /* 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 */: + return true; + default: + return isIdentifier(); + } + } + function isStartOfExpression() { + if (isStartOfLeftHandSideExpression()) { + 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 */: + // 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. + return true; + default: + // Error tolerance. If we see the start of some binary operator, we consider + // that the start of an expression. That way we'll parse out a missing identifier, + // give a good message about an identifier being missing, and then consume the + // rest of the binary expression. + if (isBinaryOperator()) { + return true; + } + return isIdentifier(); + } + } + 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 */ && + isStartOfExpression(); + } + function allowInAndParseExpression() { + return allowInAnd(parseExpression); + } + function parseExpression() { + // Expression[in]: + // AssignmentExpression[in] + // Expression[in] , AssignmentExpression[in] + // clear the decorator context when parsing Expression, as it should be unambiguous when parsing a decorator + var saveDecoratorContext = inDecoratorContext(); + if (saveDecoratorContext) { + setDecoratorContext(false); + } + var expr = parseAssignmentExpressionOrHigher(); + var operatorToken; + while ((operatorToken = parseOptionalToken(24 /* CommaToken */))) { + expr = makeBinaryExpression(expr, operatorToken, parseAssignmentExpressionOrHigher()); + } + if (saveDecoratorContext) { + setDecoratorContext(true); + } + return expr; + } + function parseInitializer(inParameter) { + if (token !== 56 /* EqualsToken */) { + // It's not uncommon during typing for the user to miss writing the '=' token. Check if + // there is no newline after the last token and if we're on an expression. If so, parse + // this as an equals-value clause with a missing equals. + // NOTE: There are two places where we allow equals-value clauses. The first is in a + // variable declarator. The second is with a parameter. For variable declarators + // 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()) { + // 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; + } + } + // Initializer[In, Yield] : + // = AssignmentExpression[?In, ?Yield] + parseExpected(56 /* EqualsToken */); + return parseAssignmentExpressionOrHigher(); + } + function parseAssignmentExpressionOrHigher() { + // AssignmentExpression[in,yield]: + // 1) ConditionalExpression[?in,?yield] + // 2) LeftHandSideExpression = AssignmentExpression[?in,?yield] + // 3) LeftHandSideExpression AssignmentOperator AssignmentExpression[?in,?yield] + // 4) ArrowFunctionExpression[?in,?yield] + // 5) [+Yield] YieldExpression[?In] + // + // Note: for ease of implementation we treat productions '2' and '3' as the same thing. + // (i.e. they're both BinaryExpressions with an assignment operator in it). + // First, do the simple check if we have a YieldExpression (production '5'). + if (isYieldExpression()) { + return parseYieldExpression(); + } + // Then, check if we have an arrow function (production '4') that starts with a parenthesized + // parameter list. If we do, we must *not* recurse for productions 1, 2 or 3. An ArrowFunction is + // not a LeftHandSideExpression, nor does it start a ConditionalExpression. So we are done + // with AssignmentExpression if we see one. + var arrowExpression = tryParseParenthesizedArrowFunctionExpression(); + if (arrowExpression) { + return arrowExpression; + } + // Now try to see if we're in production '1', '2' or '3'. A conditional expression can + // start with a LogicalOrExpression, while the assignment productions can only start with + // LeftHandSideExpressions. + // + // So, first, we try to just parse out a BinaryExpression. If we get something that is a + // LeftHandSide or higher, then we can try to parse out the assignment expression part. + // Otherwise, we try to parse out the conditional expression bit. We want to allow any + // binary expression here, so we pass in the 'lowest' precedence here so that it matches + // and consumes anything. + var expr = parseBinaryExpressionOrHigher(/*precedence*/ 0); + // 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 */) { + return parseSimpleArrowFunctionExpression(expr); + } + // Now see if we might be in cases '2' or '3'. + // If the expression was a LHS expression, and we have an assignment operator, then + // we're in '2' or '3'. Consume the assignment and return. + // + // Note: we call reScanGreaterToken so that we get an appropriately merged token + // for cases like > > = becoming >>= + if (ts.isLeftHandSideExpression(expr) && ts.isAssignmentOperator(reScanGreaterToken())) { + return makeBinaryExpression(expr, parseTokenNode(), parseAssignmentExpressionOrHigher()); + } + // It wasn't an assignment or a lambda. This is a conditional expression: + return parseConditionalExpressionRest(expr); + } + function isYieldExpression() { + if (token === 114 /* YieldKeyword */) { + // If we have a 'yield' keyword, and htis is a context where yield expressions are + // allowed, then definitely parse out a yield expression. + if (inYieldContext()) { + return true; + } + // We're in a context where 'yield expr' is not allowed. However, if we can + // definitely tell that the user was trying to parse a 'yield expr' and not + // just a normal expr that start with a 'yield' identifier, then parse out + // a 'yield expr'. We can then report an error later that they are only + // allowed in generator expressions. + // + // for example, if we see 'yield(foo)', then we'll have to treat that as an + // invocation expression of something called 'yield'. However, if we have + // 'yield foo' then that is not legal as a normal expression, so we can + // definitely recognize this as a yield expression. + // + // for now we just check if the next token is an identifier. More heuristics + // can be added here later as necessary. We just need to make sure that we + // don't accidently consume something legal. + return lookAhead(nextTokenIsIdentifierOrKeywordOrNumberOnSameLine); + } + return false; + } + function nextTokenIsIdentifierOnSameLine() { + nextToken(); + return !scanner.hasPrecedingLineBreak() && isIdentifier(); + } + function parseYieldExpression() { + var node = createNode(184 /* 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 */); + node.expression = parseAssignmentExpressionOrHigher(); + return finishNode(node); + } + else { + // if the next token is not on the same line as yield. or we don't have an '*' or + // the start of an expressin, then this is just a simple "yield" expression. + return finishNode(node); + } + } + function parseSimpleArrowFunctionExpression(identifier) { + ts.Debug.assert(token === 34 /* EqualsGreaterThanToken */, "parseSimpleArrowFunctionExpression should only have been called if we had a =>"); + var node = createNode(174 /* ArrowFunction */, identifier.pos); + var parameter = createNode(138 /* Parameter */, identifier.pos); + parameter.name = identifier; + finishNode(parameter); + node.parameters = [parameter]; + node.parameters.pos = parameter.pos; + node.parameters.end = parameter.end; + node.equalsGreaterThanToken = parseExpectedToken(34 /* EqualsGreaterThanToken */, false, ts.Diagnostics._0_expected, "=>"); + node.body = parseArrowFunctionExpressionBody(/*isAsync*/ false); + return finishNode(node); + } + function tryParseParenthesizedArrowFunctionExpression() { + var triState = isParenthesizedArrowFunctionExpression(); + if (triState === 0 /* False */) { + // It's definitely not a parenthesized arrow function expression. + return undefined; + } + // If we definitely have an arrow function, then we can just parse one, not requiring a + // following => or { token. Otherwise, we *might* have an arrow function. Try to parse + // it out, but don't allow any ambiguity, and return 'undefined' if this could be an + // expression instead. + var arrowFunction = triState === 1 /* True */ + ? parseParenthesizedArrowFunctionExpressionHead(/*allowAmbiguity*/ true) + : tryParse(parsePossibleParenthesizedArrowFunctionExpressionHead); + if (!arrowFunction) { + // Didn't appear to actually be a parenthesized arrow function. Just bail out. + return undefined; + } + var isAsync = !!(arrowFunction.flags & 512 /* Async */); + // 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 */) + ? parseArrowFunctionExpressionBody(isAsync) + : parseIdentifier(); + return finishNode(arrowFunction); + } + // True -> We definitely expect a parenthesized arrow function here. + // False -> There *cannot* be a parenthesized arrow function here. + // 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 */) { + return lookAhead(isParenthesizedArrowFunctionExpressionWorker); + } + if (token === 34 /* 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. + return 1 /* True */; + } + // Definitely not a parenthesized arrow function. + return 0 /* False */; + } + function isParenthesizedArrowFunctionExpressionWorker() { + if (token === 118 /* AsyncKeyword */) { + nextToken(); + if (scanner.hasPrecedingLineBreak()) { + return 0 /* False */; + } + if (token !== 17 /* OpenParenToken */ && token !== 25 /* LessThanToken */) { + return 0 /* False */; + } + } + var first = token; + var second = nextToken(); + if (first === 17 /* OpenParenToken */) { + if (second === 18 /* 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 */: + return 1 /* True */; + default: + return 0 /* False */; + } + } + // If encounter "([" or "({", this could be the start of a binding pattern. + // Examples: + // ([ x ]) => { } + // ({ x }) => { } + // ([ x ]) + // ({ x }) + if (second === 19 /* OpenBracketToken */ || second === 15 /* OpenBraceToken */) { + return 2 /* Unknown */; + } + // Simple case: "(..." + // This is an arrow function with a rest parameter. + if (second === 22 /* DotDotDotToken */) { + return 1 /* True */; + } + // If we had "(" followed by something that's not an identifier, + // then this definitely doesn't look like a lambda. + // Note: we could be a little more lenient and allow + // "(public" or "(private". These would not ever actually be allowed, + // but we could provide a good error message instead of bailing out. + if (!isIdentifier()) { + return 0 /* False */; + } + // If we have something like "(a:", then we must have a + // type-annotated parameter in an arrow function expression. + if (nextToken() === 54 /* ColonToken */) { + return 1 /* True */; + } + // This *could* be a parenthesized arrow function. + // Return Unknown to let the caller know. + return 2 /* Unknown */; + } + else { + ts.Debug.assert(first === 25 /* LessThanToken */); + // If we have "<" not followed by an identifier, + // then this definitely is not an arrow function. + if (!isIdentifier()) { + return 0 /* False */; + } + // JSX overrides + if (sourceFile.languageVariant === 1 /* JSX */) { + var isArrowFunctionInJsx = lookAhead(function () { + var third = nextToken(); + if (third === 83 /* ExtendsKeyword */) { + var fourth = nextToken(); + switch (fourth) { + case 56 /* EqualsToken */: + case 27 /* GreaterThanToken */: + return false; + default: + return true; + } + } + else if (third === 24 /* CommaToken */) { + return true; + } + return false; + }); + if (isArrowFunctionInJsx) { + return 1 /* True */; + } + return 0 /* False */; + } + // This *could* be a parenthesized arrow function. + return 2 /* Unknown */; + } + } + function parsePossibleParenthesizedArrowFunctionExpressionHead() { + return parseParenthesizedArrowFunctionExpressionHead(/*allowAmbiguity*/ false); + } + function parseParenthesizedArrowFunctionExpressionHead(allowAmbiguity) { + var node = createNode(174 /* ArrowFunction */); + setModifiers(node, parseModifiersForArrowFunction()); + var isAsync = !!(node.flags & 512 /* Async */); + // Arrow functions are never generators. + // + // If we're speculatively parsing a signature for a parenthesized arrow function, then + // we have to have a complete parameter list. Otherwise we might see something like + // 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); + // If we couldn't get parameters, we definitely could not parse out an arrow function. + if (!node.parameters) { + return undefined; + } + // Parsing a signature isn't enough. + // Parenthesized arrow signatures often look like other valid expressions. + // For instance: + // - "(x = 10)" is an assignment expression parsed as a signature with a default parameter value. + // - "(x,y)" is a comma expression parsed as a signature with two parameters. + // - "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 */) { + // 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 */) { + return parseFunctionBlock(/*allowYield*/ false, /*allowAwait*/ isAsync, /*ignoreMissingOpenBrace*/ false); + } + if (token !== 23 /* SemicolonToken */ && + token !== 87 /* FunctionKeyword */ && + token !== 73 /* ClassKeyword */ && + isStartOfStatement() && + !isStartOfExpressionStatement()) { + // Check if we got a plain statement (i.e. no expression-statements, no function/class expressions/declarations) + // + // Here we try to recover from a potential error situation in the case where the + // user meant to supply a block. For example, if the user wrote: + // + // a => + // let v = 0; + // } + // + // they may be missing an open brace. Check to see if that's the case so we can + // try to recover better. If we don't do this, then the next close curly we see may end + // up preemptively closing the containing construct. + // + // Note: even when 'ignoreMissingOpenBrace' is passed as true, parseBody will still error. + return parseFunctionBlock(/*allowYield*/ false, /*allowAwait*/ isAsync, /*ignoreMissingOpenBrace*/ true); + } + return isAsync + ? doInAwaitContext(parseAssignmentExpressionOrHigher) + : doOutsideOfAwaitContext(parseAssignmentExpressionOrHigher); + } + function parseConditionalExpressionRest(leftOperand) { + // Note: we are passed in an expression which was produced from parseBinaryExpressionOrHigher. + var questionToken = parseOptionalToken(53 /* QuestionToken */); + if (!questionToken) { + return leftOperand; + } + // Note: we explicitly 'allowIn' in the whenTrue part of the condition expression, and + // we do not that for the 'whenFalse' part. + var node = createNode(182 /* 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.whenFalse = parseAssignmentExpressionOrHigher(); + return finishNode(node); + } + function parseBinaryExpressionOrHigher(precedence) { + var leftOperand = parseUnaryExpressionOrHigher(); + return parseBinaryExpressionRest(precedence, leftOperand); + } + function isInOrOfKeyword(t) { + return t === 90 /* InKeyword */ || t === 134 /* OfKeyword */; + } + function parseBinaryExpressionRest(precedence, leftOperand) { + while (true) { + // We either have a binary operator here, or we're finished. We call + // reScanGreaterToken so that we merge token sequences like > and = into >= + reScanGreaterToken(); + var newPrecedence = getBinaryOperatorPrecedence(); + // Check the precedence to see if we should "take" this operator + // - For left associative operator (all operator but **), consume the operator, + // recursively call the function below, and parse binaryExpression as a rightOperand + // of the caller if the new precendence of the operator is greater then or equal to the current precendence. + // For example: + // a - b - c; + // ^token; leftOperand = b. Return b to the caller as a rightOperand + // a * b - c + // ^token; leftOperand = b. Return b to the caller as a rightOperand + // a - b * c; + // ^token; leftOperand = b. Return b * c to the caller as a rightOperand + // - For right associative operator (**), consume the operator, recursively call the function + // and parse binaryExpression as a rightOperand of the caller if the new precendence of + // the operator is strictly grater than the current precendence + // For example: + // a ** b ** c; + // ^^token; leftOperand = b. Return b ** c to the caller as a rightOperand + // a - b ** c; + // ^^token; leftOperand = b. Return b ** c to the caller as a rightOperand + // a ** b - c + // ^token; leftOperand = b. Return b to the caller as a rightOperand + var consumeCurrentOperator = token === 38 /* AsteriskAsteriskToken */ ? + newPrecedence >= precedence : + newPrecedence > precedence; + if (!consumeCurrentOperator) { + break; + } + if (token === 90 /* InKeyword */ && inDisallowInContext()) { + break; + } + if (token === 116 /* AsKeyword */) { + // Make sure we *do* perform ASI for constructs like this: + // var x = foo + // as (Bar) + // This should be parsed as an initialized variable, followed + // by a function call to 'as' with the argument 'Bar' + if (scanner.hasPrecedingLineBreak()) { + break; + } + else { + nextToken(); + leftOperand = makeAsExpression(leftOperand, parseType()); + } + } + else { + leftOperand = makeBinaryExpression(leftOperand, parseTokenNode(), parseBinaryExpressionOrHigher(newPrecedence)); + } + } + return leftOperand; + } + function isBinaryOperator() { + if (inDisallowInContext() && token === 90 /* InKeyword */) { + return false; + } + return getBinaryOperatorPrecedence() > 0; + } + function getBinaryOperatorPrecedence() { + switch (token) { + case 52 /* BarBarToken */: + return 1; + case 51 /* AmpersandAmpersandToken */: + return 2; + case 47 /* BarToken */: + return 3; + case 48 /* CaretToken */: + return 4; + case 46 /* AmpersandToken */: + return 5; + case 30 /* EqualsEqualsToken */: + case 31 /* ExclamationEqualsToken */: + case 32 /* EqualsEqualsEqualsToken */: + case 33 /* ExclamationEqualsEqualsToken */: + return 6; + case 25 /* LessThanToken */: + case 27 /* GreaterThanToken */: + case 28 /* LessThanEqualsToken */: + case 29 /* GreaterThanEqualsToken */: + case 91 /* InstanceOfKeyword */: + case 90 /* InKeyword */: + case 116 /* AsKeyword */: + return 7; + case 43 /* LessThanLessThanToken */: + case 44 /* GreaterThanGreaterThanToken */: + case 45 /* GreaterThanGreaterThanGreaterThanToken */: + return 8; + case 35 /* PlusToken */: + case 36 /* MinusToken */: + return 9; + case 37 /* AsteriskToken */: + case 39 /* SlashToken */: + case 40 /* PercentToken */: + return 10; + case 38 /* AsteriskAsteriskToken */: + return 11; + } + // -1 is lower than all other precedences. Returning it will cause binary expression + // parsing to stop. + return -1; + } + function makeBinaryExpression(left, operatorToken, right) { + var node = createNode(181 /* BinaryExpression */, left.pos); + node.left = left; + node.operatorToken = operatorToken; + node.right = right; + return finishNode(node); + } + function makeAsExpression(left, right) { + var node = createNode(189 /* AsExpression */, left.pos); + node.expression = left; + node.type = right; + return finishNode(node); + } + function parsePrefixUnaryExpression() { + var node = createNode(179 /* PrefixUnaryExpression */); + node.operator = token; + nextToken(); + node.operand = parseSimpleUnaryExpression(); + return finishNode(node); + } + function parseDeleteExpression() { + var node = createNode(175 /* DeleteExpression */); + nextToken(); + node.expression = parseSimpleUnaryExpression(); + return finishNode(node); + } + function parseTypeOfExpression() { + var node = createNode(176 /* TypeOfExpression */); + nextToken(); + node.expression = parseSimpleUnaryExpression(); + return finishNode(node); + } + function parseVoidExpression() { + var node = createNode(177 /* VoidExpression */); + nextToken(); + node.expression = parseSimpleUnaryExpression(); + return finishNode(node); + } + function isAwaitExpression() { + if (token === 119 /* AwaitKeyword */) { + if (inAwaitContext()) { + return true; + } + // here we are using similar heuristics as 'isYieldExpression' + return lookAhead(nextTokenIsIdentifierOnSameLine); + } + return false; + } + function parseAwaitExpression() { + var node = createNode(178 /* AwaitExpression */); + nextToken(); + node.expression = parseSimpleUnaryExpression(); + return finishNode(node); + } + /** + * Parse ES7 unary expression and await expression + * + * ES7 UnaryExpression: + * 1) SimpleUnaryExpression[?yield] + * 2) IncrementExpression[?yield] ** UnaryExpression[?yield] + */ + function parseUnaryExpressionOrHigher() { + if (isAwaitExpression()) { + return parseAwaitExpression(); + } + if (isIncrementExpression()) { + var incrementExpression = parseIncrementExpression(); + return token === 38 /* AsteriskAsteriskToken */ ? + parseBinaryExpressionRest(getBinaryOperatorPrecedence(), incrementExpression) : + incrementExpression; + } + var unaryOperator = token; + var simpleUnaryExpression = parseSimpleUnaryExpression(); + if (token === 38 /* AsteriskAsteriskToken */) { + var diagnostic; + var start = ts.skipTrivia(sourceText, simpleUnaryExpression.pos); + if (simpleUnaryExpression.kind === 171 /* TypeAssertionExpression */) { + parseErrorAtPosition(start, simpleUnaryExpression.end - start, ts.Diagnostics.A_type_assertion_expression_is_not_allowed_in_the_left_hand_side_of_an_exponentiation_expression_Consider_enclosing_the_expression_in_parentheses); + } + else { + parseErrorAtPosition(start, simpleUnaryExpression.end - start, ts.Diagnostics.An_unary_expression_with_the_0_operator_is_not_allowed_in_the_left_hand_side_of_an_exponentiation_expression_Consider_enclosing_the_expression_in_parentheses, ts.tokenToString(unaryOperator)); + } + } + return simpleUnaryExpression; + } + /** + * Parse ES7 simple-unary expression or higher: + * + * ES7 SimpleUnaryExpression: + * 1) IncrementExpression[?yield] + * 2) delete UnaryExpression[?yield] + * 3) void UnaryExpression[?yield] + * 4) typeof UnaryExpression[?yield] + * 5) + UnaryExpression[?yield] + * 6) - UnaryExpression[?yield] + * 7) ~ UnaryExpression[?yield] + * 8) ! UnaryExpression[?yield] + */ + function parseSimpleUnaryExpression() { + switch (token) { + case 35 /* PlusToken */: + case 36 /* MinusToken */: + case 50 /* TildeToken */: + case 49 /* ExclamationToken */: + return parsePrefixUnaryExpression(); + case 78 /* DeleteKeyword */: + return parseDeleteExpression(); + case 101 /* TypeOfKeyword */: + return parseTypeOfExpression(); + case 103 /* VoidKeyword */: + return parseVoidExpression(); + case 25 /* LessThanToken */: + // This is modified UnaryExpression grammar in TypeScript + // UnaryExpression (modified): + // < type > UnaryExpression + return parseTypeAssertion(); + default: + return parseIncrementExpression(); + } + } + /** + * Check if the current token can possibly be an ES7 increment expression. + * + * ES7 IncrementExpression: + * LeftHandSideExpression[?Yield] + * LeftHandSideExpression[?Yield][no LineTerminator here]++ + * LeftHandSideExpression[?Yield][no LineTerminator here]-- + * ++LeftHandSideExpression[?Yield] + * --LeftHandSideExpression[?Yield] + */ + function isIncrementExpression() { + // This function is called inside parseUnaryExpression to decide + // whether to call parseSimpleUnaryExpression or call parseIncrmentExpression directly + switch (token) { + case 35 /* PlusToken */: + case 36 /* MinusToken */: + case 50 /* TildeToken */: + case 49 /* ExclamationToken */: + case 78 /* DeleteKeyword */: + case 101 /* TypeOfKeyword */: + case 103 /* VoidKeyword */: + return false; + case 25 /* LessThanToken */: + // If we are not in JSX context, we are parsing TypeAssertion which is an UnaryExpression + if (sourceFile.languageVariant !== 1 /* JSX */) { + return false; + } + // We are in JSX context and the token is part of JSXElement. + // Fall through + default: + return true; + } + } + /** + * Parse ES7 IncrementExpression. IncrementExpression is used instead of ES6's PostFixExpression. + * + * ES7 IncrementExpression[yield]: + * 1) LeftHandSideExpression[?yield] + * 2) LeftHandSideExpression[?yield] [[no LineTerminator here]]++ + * 3) LeftHandSideExpression[?yield] [[no LineTerminator here]]-- + * 4) ++LeftHandSideExpression[?yield] + * 5) --LeftHandSideExpression[?yield] + * In TypeScript (2), (3) are parsed as PostfixUnaryExpression. (4), (5) are parsed as PrefixUnaryExpression + */ + function parseIncrementExpression() { + if (token === 41 /* PlusPlusToken */ || token === 42 /* MinusMinusToken */) { + var node = createNode(179 /* PrefixUnaryExpression */); + node.operator = token; + nextToken(); + node.operand = parseLeftHandSideExpressionOrHigher(); + return finishNode(node); + } + else if (sourceFile.languageVariant === 1 /* JSX */ && token === 25 /* LessThanToken */ && lookAhead(nextTokenIsIdentifierOrKeyword)) { + // JSXElement is part of primaryExpression + return parseJsxElementOrSelfClosingElement(/*inExpressionContext*/ true); + } + var expression = parseLeftHandSideExpressionOrHigher(); + ts.Debug.assert(ts.isLeftHandSideExpression(expression)); + if ((token === 41 /* PlusPlusToken */ || token === 42 /* MinusMinusToken */) && !scanner.hasPrecedingLineBreak()) { + var node = createNode(180 /* PostfixUnaryExpression */, expression.pos); + node.operand = expression; + node.operator = token; + nextToken(); + return finishNode(node); + } + return expression; + } + function parseLeftHandSideExpressionOrHigher() { + // Original Ecma: + // LeftHandSideExpression: See 11.2 + // NewExpression + // CallExpression + // + // Our simplification: + // + // LeftHandSideExpression: See 11.2 + // MemberExpression + // CallExpression + // + // See comment in parseMemberExpressionOrHigher on how we replaced NewExpression with + // MemberExpression to make our lives easier. + // + // to best understand the below code, it's important to see how CallExpression expands + // out into its own productions: + // + // CallExpression: + // MemberExpression Arguments + // CallExpression Arguments + // CallExpression[Expression] + // CallExpression.IdentifierName + // super ( ArgumentListopt ) + // super.IdentifierName + // + // Because of the recursion in these calls, we need to bottom out first. There are two + // bottom out states we can run into. Either we see 'super' which must start either of + // 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 */ + ? parseSuperExpression() + : parseMemberExpressionOrHigher(); + // Now, we *may* be complete. However, we might have consumed the start of a + // CallExpression. As such, we need to consume the rest of it here to be complete. + return parseCallExpressionRest(expression); + } + function parseMemberExpressionOrHigher() { + // Note: to make our lives simpler, we decompose the the NewExpression productions and + // place ObjectCreationExpression and FunctionExpression into PrimaryExpression. + // like so: + // + // PrimaryExpression : See 11.1 + // this + // Identifier + // Literal + // ArrayLiteral + // ObjectLiteral + // (Expression) + // FunctionExpression + // new MemberExpression Arguments? + // + // MemberExpression : See 11.2 + // PrimaryExpression + // MemberExpression[Expression] + // MemberExpression.IdentifierName + // + // CallExpression : See 11.2 + // MemberExpression + // CallExpression Arguments + // CallExpression[Expression] + // CallExpression.IdentifierName + // + // Technically this is ambiguous. i.e. CallExpression defines: + // + // CallExpression: + // CallExpression Arguments + // + // If you see: "new Foo()" + // + // Then that could be treated as a single ObjectCreationExpression, or it could be + // treated as the invocation of "new Foo". We disambiguate that in code (to match + // the original grammar) by making sure that if we see an ObjectCreationExpression + // we always consume arguments if they are there. So we treat "new Foo()" as an + // object creation only, and not at all as an invocation) Another way to think + // about this is that for every "new" that we see, we will consume an argument list if + // it is there as part of the *associated* object creation node. Any additional + // argument lists we see, will become invocation expressions. + // + // Because there are no other places in the grammar now that refer to FunctionExpression + // or ObjectCreationExpression, it is safe to push down into the PrimaryExpression + // production. + // + // Because CallExpression and MemberExpression are left recursive, we need to bottom out + // of the recursion immediately. So we parse out a primary expression to start with. + var expression = parsePrimaryExpression(); + return parseMemberExpressionRest(expression); + } + function parseSuperExpression() { + var expression = parseTokenNode(); + if (token === 17 /* OpenParenToken */ || token === 21 /* DotToken */ || token === 19 /* 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(166 /* PropertyAccessExpression */, expression.pos); + node.expression = expression; + node.dotToken = parseExpectedToken(21 /* DotToken */, /*reportAtCurrentPosition*/ false, ts.Diagnostics.super_must_be_followed_by_an_argument_list_or_member_access); + node.name = parseRightSideOfDot(/*allowIdentifierNames*/ true); + return finishNode(node); + } + function parseJsxElementOrSelfClosingElement(inExpressionContext) { + var opening = parseJsxOpeningOrSelfClosingElement(inExpressionContext); + var result; + if (opening.kind === 235 /* JsxOpeningElement */) { + var node = createNode(233 /* JsxElement */, opening.pos); + node.openingElement = opening; + node.children = parseJsxChildren(node.openingElement.tagName); + node.closingElement = parseJsxClosingElement(inExpressionContext); + result = finishNode(node); + } + else { + ts.Debug.assert(opening.kind === 234 /* JsxSelfClosingElement */); + // Nothing else to do for self-closing elements + result = opening; + } + // If the user writes the invalid code '
' in an expression context (i.e. not wrapped in + // an enclosing tag), we'll naively try to parse ^ this as a 'less than' operator and the remainder of the tag + // as garbage, which will cause the formatter to badly mangle the JSX. Perform a speculative parse of a JSX + // element if we see a < token so that we can wrap it in a synthetic binary expression so the formatter + // 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 */) { + var invalidElement = tryParse(function () { return parseJsxElementOrSelfClosingElement(/*inExpressionContext*/ true); }); + if (invalidElement) { + parseErrorAtCurrentToken(ts.Diagnostics.JSX_expressions_must_have_one_parent_element); + var badNode = createNode(181 /* BinaryExpression */, result.pos); + badNode.end = invalidElement.end; + badNode.left = result; + badNode.right = invalidElement; + badNode.operatorToken = createMissingNode(24 /* CommaToken */, /*reportAtCurrentPosition*/ false, /*diagnosticMessage*/ undefined); + badNode.operatorToken.pos = badNode.operatorToken.end = badNode.right.pos; + return badNode; + } + } + return result; + } + function parseJsxText() { + var node = createNode(236 /* JsxText */, scanner.getStartPos()); + token = scanner.scanJsxToken(); + return finishNode(node); + } + function parseJsxChild() { + switch (token) { + case 236 /* JsxText */: + return parseJsxText(); + case 15 /* OpenBraceToken */: + return parseJsxExpression(/*inExpressionContext*/ false); + case 25 /* LessThanToken */: + return parseJsxElementOrSelfClosingElement(/*inExpressionContext*/ false); + } + ts.Debug.fail("Unknown JSX child kind " + token); + } + function parseJsxChildren(openingTagName) { + var result = []; + result.pos = scanner.getStartPos(); + var saveParsingContext = parsingContext; + parsingContext |= 1 << 14 /* JsxChildren */; + while (true) { + token = scanner.reScanJsxToken(); + if (token === 26 /* LessThanSlashToken */) { + break; + } + else if (token === 1 /* EndOfFileToken */) { + parseErrorAtCurrentToken(ts.Diagnostics.Expected_corresponding_JSX_closing_tag_for_0, ts.getTextOfNodeFromSourceText(sourceText, openingTagName)); + break; + } + result.push(parseJsxChild()); + } + result.end = scanner.getTokenPos(); + parsingContext = saveParsingContext; + return result; + } + function parseJsxOpeningOrSelfClosingElement(inExpressionContext) { + var fullStart = scanner.getStartPos(); + parseExpected(25 /* LessThanToken */); + var tagName = parseJsxElementName(); + var attributes = parseList(13 /* JsxAttributes */, parseJsxAttribute); + var node; + if (token === 27 /* 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(235 /* JsxOpeningElement */, fullStart); + scanJsxText(); + } + else { + parseExpected(39 /* SlashToken */); + if (inExpressionContext) { + parseExpected(27 /* GreaterThanToken */); + } + else { + parseExpected(27 /* GreaterThanToken */, /*diagnostic*/ undefined, /*advance*/ false); + scanJsxText(); + } + node = createNode(234 /* JsxSelfClosingElement */, fullStart); + } + node.tagName = tagName; + node.attributes = attributes; + return finishNode(node); + } + function parseJsxElementName() { + scanJsxIdentifier(); + var elementName = parseIdentifierName(); + while (parseOptional(21 /* DotToken */)) { + scanJsxIdentifier(); + var node = createNode(135 /* QualifiedName */, elementName.pos); + node.left = elementName; + node.right = parseIdentifierName(); + elementName = finishNode(node); + } + return elementName; + } + function parseJsxExpression(inExpressionContext) { + var node = createNode(240 /* JsxExpression */); + parseExpected(15 /* OpenBraceToken */); + if (token !== 16 /* CloseBraceToken */) { + node.expression = parseExpression(); + } + if (inExpressionContext) { + parseExpected(16 /* CloseBraceToken */); + } + else { + parseExpected(16 /* CloseBraceToken */, /*message*/ undefined, /*advance*/ false); + scanJsxText(); + } + return finishNode(node); + } + function parseJsxAttribute() { + if (token === 15 /* OpenBraceToken */) { + return parseJsxSpreadAttribute(); + } + scanJsxIdentifier(); + var node = createNode(238 /* JsxAttribute */); + node.name = parseIdentifierName(); + if (parseOptional(56 /* EqualsToken */)) { + switch (token) { + case 9 /* StringLiteral */: + node.initializer = parseLiteralNode(); + break; + default: + node.initializer = parseJsxExpression(/*inExpressionContext*/ true); + break; + } + } + return finishNode(node); + } + function parseJsxSpreadAttribute() { + var node = createNode(239 /* JsxSpreadAttribute */); + parseExpected(15 /* OpenBraceToken */); + parseExpected(22 /* DotDotDotToken */); + node.expression = parseExpression(); + parseExpected(16 /* CloseBraceToken */); + return finishNode(node); + } + function parseJsxClosingElement(inExpressionContext) { + var node = createNode(237 /* JsxClosingElement */); + parseExpected(26 /* LessThanSlashToken */); + node.tagName = parseJsxElementName(); + if (inExpressionContext) { + parseExpected(27 /* GreaterThanToken */); + } + else { + parseExpected(27 /* GreaterThanToken */, /*diagnostic*/ undefined, /*advance*/ false); + scanJsxText(); + } + return finishNode(node); + } + function parseTypeAssertion() { + var node = createNode(171 /* TypeAssertionExpression */); + parseExpected(25 /* LessThanToken */); + node.type = parseType(); + parseExpected(27 /* GreaterThanToken */); + node.expression = parseSimpleUnaryExpression(); + return finishNode(node); + } + function parseMemberExpressionRest(expression) { + while (true) { + var dotToken = parseOptionalToken(21 /* DotToken */); + if (dotToken) { + var propertyAccess = createNode(166 /* PropertyAccessExpression */, expression.pos); + propertyAccess.expression = expression; + propertyAccess.dotToken = dotToken; + propertyAccess.name = parseRightSideOfDot(/*allowIdentifierNames*/ true); + expression = finishNode(propertyAccess); + 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(167 /* ElementAccessExpression */, expression.pos); + indexedAccess.expression = expression; + // It's not uncommon for a user to write: "new Type[]". + // Check for that common pattern and report a better error message. + if (token !== 20 /* 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 */); + expression = finishNode(indexedAccess); + continue; + } + if (token === 11 /* NoSubstitutionTemplateLiteral */ || token === 12 /* TemplateHead */) { + var tagExpression = createNode(170 /* TaggedTemplateExpression */, expression.pos); + tagExpression.tag = expression; + tagExpression.template = token === 11 /* NoSubstitutionTemplateLiteral */ + ? parseLiteralNode() + : parseTemplateExpression(); + expression = finishNode(tagExpression); + continue; + } + return expression; + } + } + function parseCallExpressionRest(expression) { + while (true) { + expression = parseMemberExpressionRest(expression); + if (token === 25 /* 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 + // stack. + var typeArguments = tryParse(parseTypeArgumentsInExpression); + if (!typeArguments) { + return expression; + } + var callExpr = createNode(168 /* CallExpression */, expression.pos); + callExpr.expression = expression; + callExpr.typeArguments = typeArguments; + callExpr.arguments = parseArgumentList(); + expression = finishNode(callExpr); + continue; + } + else if (token === 17 /* OpenParenToken */) { + var callExpr = createNode(168 /* CallExpression */, expression.pos); + callExpr.expression = expression; + callExpr.arguments = parseArgumentList(); + expression = finishNode(callExpr); + continue; + } + return expression; + } + } + function parseArgumentList() { + parseExpected(17 /* OpenParenToken */); + var result = parseDelimitedList(11 /* ArgumentExpressions */, parseArgumentExpression); + parseExpected(18 /* CloseParenToken */); + return result; + } + function parseTypeArgumentsInExpression() { + if (!parseOptional(25 /* LessThanToken */)) { + return undefined; + } + var typeArguments = parseDelimitedList(18 /* TypeArguments */, parseType); + if (!parseExpected(27 /* GreaterThanToken */)) { + // If it doesn't have the closing > then it's definitely not an type argument list. + return undefined; + } + // If we have a '<', then only parse this as a arugment list if the type arguments + // are complete and we have an open paren. if we don't, rewind and return nothing. + return typeArguments && canFollowTypeArgumentsInExpression() + ? typeArguments + : undefined; + } + function canFollowTypeArgumentsInExpression() { + switch (token) { + case 17 /* 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 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 { + // 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. + default: + // Anything else treat as an expression. + return false; + } + } + function parsePrimaryExpression() { + switch (token) { + case 8 /* NumericLiteral */: + case 9 /* StringLiteral */: + case 11 /* NoSubstitutionTemplateLiteral */: + return parseLiteralNode(); + case 97 /* ThisKeyword */: + case 95 /* SuperKeyword */: + case 93 /* NullKeyword */: + case 99 /* TrueKeyword */: + case 84 /* FalseKeyword */: + return parseTokenNode(); + case 17 /* OpenParenToken */: + return parseParenthesizedExpression(); + case 19 /* OpenBracketToken */: + return parseArrayLiteralExpression(); + case 15 /* OpenBraceToken */: + return parseObjectLiteralExpression(); + case 118 /* AsyncKeyword */: + // Async arrow functions are parsed earlier in parseAssignmentExpressionOrHigher. + // If we encounter `async [no LineTerminator here] function` then this is an async + // function; otherwise, its an identifier. + if (!lookAhead(nextTokenIsFunctionKeywordOnSameLine)) { + break; + } + return parseFunctionExpression(); + case 73 /* ClassKeyword */: + return parseClassExpression(); + case 87 /* FunctionKeyword */: + return parseFunctionExpression(); + case 92 /* NewKeyword */: + return parseNewExpression(); + case 39 /* SlashToken */: + case 61 /* SlashEqualsToken */: + if (reScanSlashToken() === 10 /* RegularExpressionLiteral */) { + return parseLiteralNode(); + } + break; + case 12 /* TemplateHead */: + return parseTemplateExpression(); + } + return parseIdentifier(ts.Diagnostics.Expression_expected); + } + function parseParenthesizedExpression() { + var node = createNode(172 /* ParenthesizedExpression */); + parseExpected(17 /* OpenParenToken */); + node.expression = allowInAnd(parseExpression); + parseExpected(18 /* CloseParenToken */); + return finishNode(node); + } + function parseSpreadElement() { + var node = createNode(185 /* SpreadElementExpression */); + parseExpected(22 /* DotDotDotToken */); + node.expression = parseAssignmentExpressionOrHigher(); + return finishNode(node); + } + function parseArgumentOrArrayLiteralElement() { + return token === 22 /* DotDotDotToken */ ? parseSpreadElement() : + token === 24 /* CommaToken */ ? createNode(187 /* OmittedExpression */) : + parseAssignmentExpressionOrHigher(); + } + function parseArgumentExpression() { + return doOutsideOfContext(disallowInAndDecoratorContext, parseArgumentOrArrayLiteralElement); + } + function parseArrayLiteralExpression() { + var node = createNode(164 /* ArrayLiteralExpression */); + parseExpected(19 /* OpenBracketToken */); + if (scanner.hasPrecedingLineBreak()) + node.flags |= 2048 /* MultiLine */; + node.elements = parseDelimitedList(15 /* ArrayLiteralMembers */, parseArgumentOrArrayLiteralElement); + parseExpected(20 /* CloseBracketToken */); + return finishNode(node); + } + function tryParseAccessorDeclaration(fullStart, decorators, modifiers) { + if (parseContextualModifier(123 /* GetKeyword */)) { + return parseAccessorDeclaration(145 /* GetAccessor */, fullStart, decorators, modifiers); + } + else if (parseContextualModifier(129 /* SetKeyword */)) { + return parseAccessorDeclaration(146 /* SetAccessor */, fullStart, decorators, modifiers); + } + return undefined; + } + function parseObjectLiteralElement() { + var fullStart = scanner.getStartPos(); + var decorators = parseDecorators(); + var modifiers = parseModifiers(); + var accessor = tryParseAccessorDeclaration(fullStart, decorators, modifiers); + if (accessor) { + return accessor; + } + var asteriskToken = parseOptionalToken(37 /* AsteriskToken */); + var tokenIsIdentifier = isIdentifier(); + var nameToken = token; + 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 */) { + return parseMethodDeclaration(fullStart, decorators, modifiers, asteriskToken, propertyName, questionToken); + } + // check if it is short-hand property assignment or normal property assignment + // NOTE: if token is EqualsToken it is interpreted as CoverInitializedName production + // CoverInitializedName[Yield] : + // IdentifierReference[?Yield] Initializer[In, ?Yield] + // this is necessary because ObjectLiteral productions are also used to cover grammar for ObjectAssignmentPattern + var isShorthandPropertyAssignment = tokenIsIdentifier && (token === 24 /* CommaToken */ || token === 16 /* CloseBraceToken */ || token === 56 /* EqualsToken */); + if (isShorthandPropertyAssignment) { + var shorthandDeclaration = createNode(246 /* ShorthandPropertyAssignment */, fullStart); + shorthandDeclaration.name = propertyName; + shorthandDeclaration.questionToken = questionToken; + var equalsToken = parseOptionalToken(56 /* EqualsToken */); + if (equalsToken) { + shorthandDeclaration.equalsToken = equalsToken; + shorthandDeclaration.objectAssignmentInitializer = allowInAnd(parseAssignmentExpressionOrHigher); + } + return finishNode(shorthandDeclaration); + } + else { + var propertyAssignment = createNode(245 /* PropertyAssignment */, fullStart); + propertyAssignment.name = propertyName; + propertyAssignment.questionToken = questionToken; + parseExpected(54 /* ColonToken */); + propertyAssignment.initializer = allowInAnd(parseAssignmentExpressionOrHigher); + return finishNode(propertyAssignment); + } + } + function parseObjectLiteralExpression() { + var node = createNode(165 /* ObjectLiteralExpression */); + parseExpected(15 /* OpenBraceToken */); + if (scanner.hasPrecedingLineBreak()) { + node.flags |= 2048 /* MultiLine */; + } + node.properties = parseDelimitedList(12 /* ObjectLiteralMembers */, parseObjectLiteralElement, /*considerSemicolonAsDelimeter*/ true); + parseExpected(16 /* CloseBraceToken */); + return finishNode(node); + } + function parseFunctionExpression() { + // GeneratorExpression: + // function* BindingIdentifier [Yield][opt](FormalParameters[Yield]){ GeneratorBody } + // + // FunctionExpression: + // function BindingIdentifier[opt](FormalParameters){ FunctionBody } + var saveDecoratorContext = inDecoratorContext(); + if (saveDecoratorContext) { + setDecoratorContext(false); + } + var node = createNode(173 /* FunctionExpression */); + setModifiers(node, parseModifiers()); + parseExpected(87 /* FunctionKeyword */); + node.asteriskToken = parseOptionalToken(37 /* AsteriskToken */); + var isGenerator = !!node.asteriskToken; + var isAsync = !!(node.flags & 512 /* Async */); + node.name = + isGenerator && isAsync ? doInYieldAndAwaitContext(parseOptionalIdentifier) : + isGenerator ? doInYieldContext(parseOptionalIdentifier) : + isAsync ? doInAwaitContext(parseOptionalIdentifier) : + parseOptionalIdentifier(); + fillSignature(54 /* ColonToken */, /*yieldContext*/ isGenerator, /*awaitContext*/ isAsync, /*requireCompleteParameterList*/ false, node); + node.body = parseFunctionBlock(/*allowYield*/ isGenerator, /*allowAwait*/ isAsync, /*ignoreMissingOpenBrace*/ false); + if (saveDecoratorContext) { + setDecoratorContext(true); + } + return finishNode(node); + } + function parseOptionalIdentifier() { + return isIdentifier() ? parseIdentifier() : undefined; + } + function parseNewExpression() { + var node = createNode(169 /* NewExpression */); + parseExpected(92 /* NewKeyword */); + node.expression = parseMemberExpressionOrHigher(); + node.typeArguments = tryParse(parseTypeArgumentsInExpression); + if (node.typeArguments || token === 17 /* OpenParenToken */) { + node.arguments = parseArgumentList(); + } + return finishNode(node); + } + // STATEMENTS + function parseBlock(ignoreMissingOpenBrace, diagnosticMessage) { + var node = createNode(192 /* Block */); + if (parseExpected(15 /* OpenBraceToken */, diagnosticMessage) || ignoreMissingOpenBrace) { + node.statements = parseList(1 /* BlockStatements */, parseStatement); + parseExpected(16 /* CloseBraceToken */); + } + else { + node.statements = createMissingList(); + } + return finishNode(node); + } + function parseFunctionBlock(allowYield, allowAwait, ignoreMissingOpenBrace, diagnosticMessage) { + var savedYieldContext = inYieldContext(); + setYieldContext(allowYield); + var savedAwaitContext = inAwaitContext(); + setAwaitContext(allowAwait); + // We may be in a [Decorator] context when parsing a function expression or + // arrow function. The body of the function is not in [Decorator] context. + var saveDecoratorContext = inDecoratorContext(); + if (saveDecoratorContext) { + setDecoratorContext(false); + } + var block = parseBlock(ignoreMissingOpenBrace, diagnosticMessage); + if (saveDecoratorContext) { + setDecoratorContext(true); + } + setYieldContext(savedYieldContext); + setAwaitContext(savedAwaitContext); + return block; + } + function parseEmptyStatement() { + var node = createNode(194 /* EmptyStatement */); + parseExpected(23 /* SemicolonToken */); + return finishNode(node); + } + function parseIfStatement() { + var node = createNode(196 /* IfStatement */); + parseExpected(88 /* IfKeyword */); + parseExpected(17 /* OpenParenToken */); + node.expression = allowInAnd(parseExpression); + parseExpected(18 /* CloseParenToken */); + node.thenStatement = parseStatement(); + node.elseStatement = parseOptional(80 /* ElseKeyword */) ? parseStatement() : undefined; + return finishNode(node); + } + function parseDoStatement() { + var node = createNode(197 /* DoStatement */); + parseExpected(79 /* DoKeyword */); + node.statement = parseStatement(); + parseExpected(104 /* WhileKeyword */); + parseExpected(17 /* OpenParenToken */); + node.expression = allowInAnd(parseExpression); + parseExpected(18 /* 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 */); + return finishNode(node); + } + function parseWhileStatement() { + var node = createNode(198 /* WhileStatement */); + parseExpected(104 /* WhileKeyword */); + parseExpected(17 /* OpenParenToken */); + node.expression = allowInAnd(parseExpression); + parseExpected(18 /* CloseParenToken */); + node.statement = parseStatement(); + return finishNode(node); + } + function parseForOrForInOrForOfStatement() { + var pos = getNodePos(); + parseExpected(86 /* ForKeyword */); + parseExpected(17 /* OpenParenToken */); + var initializer = undefined; + if (token !== 23 /* SemicolonToken */) { + if (token === 102 /* VarKeyword */ || token === 108 /* LetKeyword */ || token === 74 /* ConstKeyword */) { + initializer = parseVariableDeclarationList(/*inForStatementInitializer*/ true); + } + else { + initializer = disallowInAnd(parseExpression); + } + } + var forOrForInOrForOfStatement; + if (parseOptional(90 /* InKeyword */)) { + var forInStatement = createNode(200 /* ForInStatement */, pos); + forInStatement.initializer = initializer; + forInStatement.expression = allowInAnd(parseExpression); + parseExpected(18 /* CloseParenToken */); + forOrForInOrForOfStatement = forInStatement; + } + else if (parseOptional(134 /* OfKeyword */)) { + var forOfStatement = createNode(201 /* ForOfStatement */, pos); + forOfStatement.initializer = initializer; + forOfStatement.expression = allowInAnd(parseAssignmentExpressionOrHigher); + parseExpected(18 /* CloseParenToken */); + forOrForInOrForOfStatement = forOfStatement; + } + else { + var forStatement = createNode(199 /* ForStatement */, pos); + forStatement.initializer = initializer; + parseExpected(23 /* SemicolonToken */); + if (token !== 23 /* SemicolonToken */ && token !== 18 /* CloseParenToken */) { + forStatement.condition = allowInAnd(parseExpression); + } + parseExpected(23 /* SemicolonToken */); + if (token !== 18 /* CloseParenToken */) { + forStatement.incrementor = allowInAnd(parseExpression); + } + parseExpected(18 /* CloseParenToken */); + forOrForInOrForOfStatement = forStatement; + } + forOrForInOrForOfStatement.statement = parseStatement(); + return finishNode(forOrForInOrForOfStatement); + } + function parseBreakOrContinueStatement(kind) { + var node = createNode(kind); + parseExpected(kind === 203 /* BreakStatement */ ? 70 /* BreakKeyword */ : 75 /* ContinueKeyword */); + if (!canParseSemicolon()) { + node.label = parseIdentifier(); + } + parseSemicolon(); + return finishNode(node); + } + function parseReturnStatement() { + var node = createNode(204 /* ReturnStatement */); + parseExpected(94 /* ReturnKeyword */); + if (!canParseSemicolon()) { + node.expression = allowInAnd(parseExpression); + } + parseSemicolon(); + return finishNode(node); + } + function parseWithStatement() { + var node = createNode(205 /* WithStatement */); + parseExpected(105 /* WithKeyword */); + parseExpected(17 /* OpenParenToken */); + node.expression = allowInAnd(parseExpression); + parseExpected(18 /* CloseParenToken */); + node.statement = parseStatement(); + return finishNode(node); + } + function parseCaseClause() { + var node = createNode(241 /* CaseClause */); + parseExpected(71 /* CaseKeyword */); + node.expression = allowInAnd(parseExpression); + parseExpected(54 /* ColonToken */); + node.statements = parseList(3 /* SwitchClauseStatements */, parseStatement); + return finishNode(node); + } + function parseDefaultClause() { + var node = createNode(242 /* DefaultClause */); + parseExpected(77 /* DefaultKeyword */); + parseExpected(54 /* ColonToken */); + node.statements = parseList(3 /* SwitchClauseStatements */, parseStatement); + return finishNode(node); + } + function parseCaseOrDefaultClause() { + return token === 71 /* CaseKeyword */ ? parseCaseClause() : parseDefaultClause(); + } + function parseSwitchStatement() { + var node = createNode(206 /* SwitchStatement */); + parseExpected(96 /* SwitchKeyword */); + parseExpected(17 /* OpenParenToken */); + node.expression = allowInAnd(parseExpression); + parseExpected(18 /* CloseParenToken */); + var caseBlock = createNode(220 /* CaseBlock */, scanner.getStartPos()); + parseExpected(15 /* OpenBraceToken */); + caseBlock.clauses = parseList(2 /* SwitchClauses */, parseCaseOrDefaultClause); + parseExpected(16 /* CloseBraceToken */); + node.caseBlock = finishNode(caseBlock); + return finishNode(node); + } + function parseThrowStatement() { + // ThrowStatement[Yield] : + // throw [no LineTerminator here]Expression[In, ?Yield]; + // Because of automatic semicolon insertion, we need to report error if this + // throw could be terminated with a semicolon. Note: we can't call 'parseExpression' + // 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(208 /* ThrowStatement */); + parseExpected(98 /* ThrowKeyword */); + node.expression = scanner.hasPrecedingLineBreak() ? undefined : allowInAnd(parseExpression); + parseSemicolon(); + return finishNode(node); + } + // TODO: Review for error recovery + function parseTryStatement() { + var node = createNode(209 /* TryStatement */); + parseExpected(100 /* TryKeyword */); + node.tryBlock = parseBlock(/*ignoreMissingOpenBrace*/ false); + node.catchClause = token === 72 /* CatchKeyword */ ? parseCatchClause() : undefined; + // If we don't have a catch clause, then we must have a finally clause. Try to parse + // one out no matter what. + if (!node.catchClause || token === 85 /* FinallyKeyword */) { + parseExpected(85 /* FinallyKeyword */); + node.finallyBlock = parseBlock(/*ignoreMissingOpenBrace*/ false); + } + return finishNode(node); + } + function parseCatchClause() { + var result = createNode(244 /* CatchClause */); + parseExpected(72 /* CatchKeyword */); + if (parseExpected(17 /* OpenParenToken */)) { + result.variableDeclaration = parseVariableDeclaration(); + } + parseExpected(18 /* CloseParenToken */); + result.block = parseBlock(/*ignoreMissingOpenBrace*/ false); + return finishNode(result); + } + function parseDebuggerStatement() { + var node = createNode(210 /* DebuggerStatement */); + parseExpected(76 /* DebuggerKeyword */); + parseSemicolon(); + return finishNode(node); + } + function parseExpressionOrLabeledStatement() { + // Avoiding having to do the lookahead for a labeled statement by just trying to parse + // out an expression, seeing if it is identifier and then seeing if it is followed by + // a colon. + var fullStart = scanner.getStartPos(); + var expression = allowInAnd(parseExpression); + if (expression.kind === 69 /* Identifier */ && parseOptional(54 /* ColonToken */)) { + var labeledStatement = createNode(207 /* LabeledStatement */, fullStart); + labeledStatement.label = expression; + labeledStatement.statement = parseStatement(); + return finishNode(labeledStatement); + } + else { + var expressionStatement = createNode(195 /* ExpressionStatement */, fullStart); + expressionStatement.expression = expression; + parseSemicolon(); + return finishNode(expressionStatement); + } + } + function nextTokenIsIdentifierOrKeywordOnSameLine() { + nextToken(); + return ts.tokenIsIdentifierOrKeyword(token) && !scanner.hasPrecedingLineBreak(); + } + function nextTokenIsFunctionKeywordOnSameLine() { + nextToken(); + return token === 87 /* FunctionKeyword */ && !scanner.hasPrecedingLineBreak(); + } + function nextTokenIsIdentifierOrKeywordOrNumberOnSameLine() { + nextToken(); + return (ts.tokenIsIdentifierOrKeyword(token) || token === 8 /* NumericLiteral */) && !scanner.hasPrecedingLineBreak(); + } + function isDeclaration() { + while (true) { + switch (token) { + case 102 /* VarKeyword */: + case 108 /* LetKeyword */: + case 74 /* ConstKeyword */: + case 87 /* FunctionKeyword */: + case 73 /* ClassKeyword */: + case 81 /* EnumKeyword */: + return true; + // 'declare', 'module', 'namespace', 'interface'* and 'type' are all legal JavaScript identifiers; + // however, an identifier cannot be followed by another identifier on the same line. This is what we + // count on to parse out the respective declarations. For instance, we exploit this to say that + // + // namespace n + // + // can be none other than the beginning of a namespace declaration, but need to respect that JavaScript sees + // + // namespace + // n + // + // as the identifier 'namespace' on one line followed by the identifier 'n' on another. + // We need to look one token ahead to see if it permissible to try parsing a declaration. + // + // *Note*: 'interface' is actually a strict mode reserved word. So while + // + // "use strict" + // interface + // I {} + // + // could be legal, it would add complexity for very little gain. + case 107 /* InterfaceKeyword */: + case 132 /* TypeKeyword */: + return nextTokenIsIdentifierOnSameLine(); + case 125 /* ModuleKeyword */: + case 126 /* NamespaceKeyword */: + return nextTokenIsIdentifierOrStringLiteralOnSameLine(); + case 115 /* AbstractKeyword */: + case 118 /* AsyncKeyword */: + case 122 /* DeclareKeyword */: + case 110 /* PrivateKeyword */: + case 111 /* ProtectedKeyword */: + case 112 /* PublicKeyword */: + nextToken(); + // ASI takes effect for this modifier. + if (scanner.hasPrecedingLineBreak()) { + return false; + } + continue; + case 89 /* ImportKeyword */: + nextToken(); + return token === 9 /* StringLiteral */ || token === 37 /* AsteriskToken */ || + token === 15 /* OpenBraceToken */ || ts.tokenIsIdentifierOrKeyword(token); + case 82 /* ExportKeyword */: + nextToken(); + if (token === 56 /* EqualsToken */ || token === 37 /* AsteriskToken */ || + token === 15 /* OpenBraceToken */ || token === 77 /* DefaultKeyword */) { + return true; + } + continue; + case 113 /* StaticKeyword */: + nextToken(); + continue; + default: + return false; + } + } + } + function isStartOfDeclaration() { + return lookAhead(isDeclaration); + } + 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 */: + // '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 */: + return true; + case 74 /* ConstKeyword */: + case 82 /* ExportKeyword */: + case 89 /* ImportKeyword */: + return isStartOfDeclaration(); + case 118 /* AsyncKeyword */: + case 122 /* DeclareKeyword */: + case 107 /* InterfaceKeyword */: + case 125 /* ModuleKeyword */: + case 126 /* NamespaceKeyword */: + case 132 /* TypeKeyword */: + // When these don't start a declaration, they're an identifier in an expression statement + return true; + case 112 /* PublicKeyword */: + case 110 /* PrivateKeyword */: + case 111 /* ProtectedKeyword */: + case 113 /* StaticKeyword */: + // When these don't start a declaration, they may be the start of a class member if an identifier + // immediately follows. Otherwise they're an identifier in an expression statement. + return isStartOfDeclaration() || !lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine); + default: + return isStartOfExpression(); + } + } + function nextTokenIsIdentifierOrStartOfDestructuring() { + nextToken(); + return isIdentifier() || token === 15 /* OpenBraceToken */ || token === 19 /* OpenBracketToken */; + } + function isLetDeclaration() { + // In ES6 'let' always starts a lexical declaration if followed by an identifier or { + // or [. + return lookAhead(nextTokenIsIdentifierOrStartOfDestructuring); + } + function parseStatement() { + switch (token) { + case 23 /* SemicolonToken */: + return parseEmptyStatement(); + case 15 /* OpenBraceToken */: + return parseBlock(/*ignoreMissingOpenBrace*/ false); + case 102 /* VarKeyword */: + return parseVariableStatement(scanner.getStartPos(), /*decorators*/ undefined, /*modifiers*/ undefined); + case 108 /* LetKeyword */: + if (isLetDeclaration()) { + return parseVariableStatement(scanner.getStartPos(), /*decorators*/ undefined, /*modifiers*/ undefined); + } + break; + case 87 /* FunctionKeyword */: + return parseFunctionDeclaration(scanner.getStartPos(), /*decorators*/ undefined, /*modifiers*/ undefined); + case 73 /* ClassKeyword */: + return parseClassDeclaration(scanner.getStartPos(), /*decorators*/ undefined, /*modifiers*/ undefined); + case 88 /* IfKeyword */: + return parseIfStatement(); + case 79 /* DoKeyword */: + return parseDoStatement(); + case 104 /* WhileKeyword */: + return parseWhileStatement(); + case 86 /* ForKeyword */: + return parseForOrForInOrForOfStatement(); + case 75 /* ContinueKeyword */: + return parseBreakOrContinueStatement(202 /* ContinueStatement */); + case 70 /* BreakKeyword */: + return parseBreakOrContinueStatement(203 /* BreakStatement */); + case 94 /* ReturnKeyword */: + return parseReturnStatement(); + case 105 /* WithKeyword */: + return parseWithStatement(); + case 96 /* SwitchKeyword */: + return parseSwitchStatement(); + case 98 /* ThrowKeyword */: + return parseThrowStatement(); + case 100 /* TryKeyword */: + // Include 'catch' and 'finally' for error recovery. + case 72 /* CatchKeyword */: + case 85 /* FinallyKeyword */: + return parseTryStatement(); + case 76 /* DebuggerKeyword */: + return parseDebuggerStatement(); + case 55 /* AtToken */: + return parseDeclaration(); + case 118 /* AsyncKeyword */: + case 107 /* InterfaceKeyword */: + case 132 /* TypeKeyword */: + case 125 /* ModuleKeyword */: + case 126 /* NamespaceKeyword */: + case 122 /* DeclareKeyword */: + case 74 /* ConstKeyword */: + case 81 /* EnumKeyword */: + case 82 /* ExportKeyword */: + case 89 /* ImportKeyword */: + case 110 /* PrivateKeyword */: + case 111 /* ProtectedKeyword */: + case 112 /* PublicKeyword */: + case 115 /* AbstractKeyword */: + case 113 /* StaticKeyword */: + if (isStartOfDeclaration()) { + return parseDeclaration(); + } + break; + } + return parseExpressionOrLabeledStatement(); + } + function parseDeclaration() { + var fullStart = getNodePos(); + var decorators = parseDecorators(); + var modifiers = parseModifiers(); + switch (token) { + case 102 /* VarKeyword */: + case 108 /* LetKeyword */: + case 74 /* ConstKeyword */: + return parseVariableStatement(fullStart, decorators, modifiers); + case 87 /* FunctionKeyword */: + return parseFunctionDeclaration(fullStart, decorators, modifiers); + case 73 /* ClassKeyword */: + return parseClassDeclaration(fullStart, decorators, modifiers); + case 107 /* InterfaceKeyword */: + return parseInterfaceDeclaration(fullStart, decorators, modifiers); + case 132 /* TypeKeyword */: + return parseTypeAliasDeclaration(fullStart, decorators, modifiers); + case 81 /* EnumKeyword */: + return parseEnumDeclaration(fullStart, decorators, modifiers); + case 125 /* ModuleKeyword */: + case 126 /* NamespaceKeyword */: + return parseModuleDeclaration(fullStart, decorators, modifiers); + case 89 /* ImportKeyword */: + return parseImportDeclarationOrImportEqualsDeclaration(fullStart, decorators, modifiers); + case 82 /* ExportKeyword */: + nextToken(); + return token === 77 /* DefaultKeyword */ || token === 56 /* EqualsToken */ ? + parseExportAssignment(fullStart, decorators, modifiers) : + parseExportDeclaration(fullStart, decorators, modifiers); + default: + if (decorators || modifiers) { + // We reached this point because we encountered decorators and/or modifiers and assumed a declaration + // would follow. For recovery and error reporting purposes, return an incomplete declaration. + var node = createMissingNode(231 /* MissingDeclaration */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); + node.pos = fullStart; + node.decorators = decorators; + setModifiers(node, modifiers); + return finishNode(node); + } + } + } + function nextTokenIsIdentifierOrStringLiteralOnSameLine() { + nextToken(); + return !scanner.hasPrecedingLineBreak() && (isIdentifier() || token === 9 /* StringLiteral */); + } + function parseFunctionBlockOrSemicolon(isGenerator, isAsync, diagnosticMessage) { + if (token !== 15 /* OpenBraceToken */ && canParseSemicolon()) { + parseSemicolon(); + return; + } + return parseFunctionBlock(isGenerator, isAsync, /*ignoreMissingOpenBrace*/ false, diagnosticMessage); + } + // DECLARATIONS + function parseArrayBindingElement() { + if (token === 24 /* CommaToken */) { + return createNode(187 /* OmittedExpression */); + } + var node = createNode(163 /* BindingElement */); + node.dotDotDotToken = parseOptionalToken(22 /* DotDotDotToken */); + node.name = parseIdentifierOrPattern(); + node.initializer = parseBindingElementInitializer(/*inParameter*/ false); + return finishNode(node); + } + function parseObjectBindingElement() { + var node = createNode(163 /* BindingElement */); + // TODO(andersh): Handle computed properties + var tokenIsIdentifier = isIdentifier(); + var propertyName = parsePropertyName(); + if (tokenIsIdentifier && token !== 54 /* ColonToken */) { + node.name = propertyName; + } + else { + parseExpected(54 /* ColonToken */); + node.propertyName = propertyName; + node.name = parseIdentifierOrPattern(); + } + node.initializer = parseBindingElementInitializer(/*inParameter*/ false); + return finishNode(node); + } + function parseObjectBindingPattern() { + var node = createNode(161 /* ObjectBindingPattern */); + parseExpected(15 /* OpenBraceToken */); + node.elements = parseDelimitedList(9 /* ObjectBindingElements */, parseObjectBindingElement); + parseExpected(16 /* CloseBraceToken */); + return finishNode(node); + } + function parseArrayBindingPattern() { + var node = createNode(162 /* ArrayBindingPattern */); + parseExpected(19 /* OpenBracketToken */); + node.elements = parseDelimitedList(10 /* ArrayBindingElements */, parseArrayBindingElement); + parseExpected(20 /* CloseBracketToken */); + return finishNode(node); + } + function isIdentifierOrPattern() { + return token === 15 /* OpenBraceToken */ || token === 19 /* OpenBracketToken */ || isIdentifier(); + } + function parseIdentifierOrPattern() { + if (token === 19 /* OpenBracketToken */) { + return parseArrayBindingPattern(); + } + if (token === 15 /* OpenBraceToken */) { + return parseObjectBindingPattern(); + } + return parseIdentifier(); + } + function parseVariableDeclaration() { + var node = createNode(211 /* VariableDeclaration */); + node.name = parseIdentifierOrPattern(); + node.type = parseTypeAnnotation(); + if (!isInOrOfKeyword(token)) { + node.initializer = parseInitializer(/*inParameter*/ false); + } + return finishNode(node); + } + function parseVariableDeclarationList(inForStatementInitializer) { + var node = createNode(212 /* VariableDeclarationList */); + switch (token) { + case 102 /* VarKeyword */: + break; + case 108 /* LetKeyword */: + node.flags |= 16384 /* Let */; + break; + case 74 /* ConstKeyword */: + node.flags |= 32768 /* Const */; + break; + default: + ts.Debug.fail(); + } + nextToken(); + // The user may have written the following: + // + // for (let of X) { } + // + // In this case, we want to parse an empty declaration list, and then parse 'of' + // as a keyword. The reason this is not automatic is that 'of' is a valid identifier. + // 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 === 134 /* OfKeyword */ && lookAhead(canFollowContextualOfKeyword)) { + node.declarations = createMissingList(); + } + else { + var savedDisallowIn = inDisallowInContext(); + setDisallowInContext(inForStatementInitializer); + node.declarations = parseDelimitedList(8 /* VariableDeclarations */, parseVariableDeclaration); + setDisallowInContext(savedDisallowIn); + } + return finishNode(node); + } + function canFollowContextualOfKeyword() { + return nextTokenIsIdentifier() && nextToken() === 18 /* CloseParenToken */; + } + function parseVariableStatement(fullStart, decorators, modifiers) { + var node = createNode(193 /* VariableStatement */, fullStart); + node.decorators = decorators; + setModifiers(node, modifiers); + node.declarationList = parseVariableDeclarationList(/*inForStatementInitializer*/ false); + parseSemicolon(); + return finishNode(node); + } + function parseFunctionDeclaration(fullStart, decorators, modifiers) { + var node = createNode(213 /* FunctionDeclaration */, fullStart); + node.decorators = decorators; + setModifiers(node, modifiers); + parseExpected(87 /* FunctionKeyword */); + node.asteriskToken = parseOptionalToken(37 /* AsteriskToken */); + node.name = node.flags & 1024 /* Default */ ? parseOptionalIdentifier() : parseIdentifier(); + var isGenerator = !!node.asteriskToken; + var isAsync = !!(node.flags & 512 /* Async */); + fillSignature(54 /* ColonToken */, /*yieldContext*/ isGenerator, /*awaitContext*/ isAsync, /*requireCompleteParameterList*/ false, node); + node.body = parseFunctionBlockOrSemicolon(isGenerator, isAsync, ts.Diagnostics.or_expected); + return finishNode(node); + } + function parseConstructorDeclaration(pos, decorators, modifiers) { + var node = createNode(144 /* Constructor */, pos); + node.decorators = decorators; + setModifiers(node, modifiers); + parseExpected(121 /* ConstructorKeyword */); + fillSignature(54 /* ColonToken */, /*yieldContext*/ false, /*awaitContext*/ false, /*requireCompleteParameterList*/ false, node); + node.body = parseFunctionBlockOrSemicolon(/*isGenerator*/ false, /*isAsync*/ false, ts.Diagnostics.or_expected); + return finishNode(node); + } + function parseMethodDeclaration(fullStart, decorators, modifiers, asteriskToken, name, questionToken, diagnosticMessage) { + var method = createNode(143 /* MethodDeclaration */, fullStart); + method.decorators = decorators; + setModifiers(method, modifiers); + method.asteriskToken = asteriskToken; + method.name = name; + method.questionToken = questionToken; + var isGenerator = !!asteriskToken; + var isAsync = !!(method.flags & 512 /* Async */); + fillSignature(54 /* ColonToken */, /*yieldContext*/ isGenerator, /*awaitContext*/ isAsync, /*requireCompleteParameterList*/ false, method); + method.body = parseFunctionBlockOrSemicolon(isGenerator, isAsync, diagnosticMessage); + return finishNode(method); + } + function parsePropertyDeclaration(fullStart, decorators, modifiers, name, questionToken) { + var property = createNode(141 /* PropertyDeclaration */, fullStart); + property.decorators = decorators; + setModifiers(property, modifiers); + property.name = name; + property.questionToken = questionToken; + property.type = parseTypeAnnotation(); + // For instance properties specifically, since they are evaluated inside the constructor, + // we do *not * want to parse yield expressions, so we specifically turn the yield context + // off. The grammar would look something like this: + // + // MemberVariableDeclaration[Yield]: + // AccessibilityModifier_opt PropertyName TypeAnnotation_opt Initialiser_opt[In]; + // AccessibilityModifier_opt static_opt PropertyName TypeAnnotation_opt Initialiser_opt[In, ?Yield]; + // + // The checker may still error in the static case to explicitly disallow the yield expression. + property.initializer = modifiers && modifiers.flags & 128 /* Static */ + ? allowInAnd(parseNonParameterInitializer) + : doOutsideOfContext(2 /* Yield */ | 1 /* DisallowIn */, parseNonParameterInitializer); + parseSemicolon(); + return finishNode(property); + } + function parsePropertyOrMethodDeclaration(fullStart, decorators, modifiers) { + var asteriskToken = parseOptionalToken(37 /* 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 */) { + return parseMethodDeclaration(fullStart, decorators, modifiers, asteriskToken, name, questionToken, ts.Diagnostics.or_expected); + } + else { + return parsePropertyDeclaration(fullStart, decorators, modifiers, name, questionToken); + } + } + function parseNonParameterInitializer() { + return parseInitializer(/*inParameter*/ false); + } + function parseAccessorDeclaration(kind, fullStart, decorators, modifiers) { + var node = createNode(kind, fullStart); + node.decorators = decorators; + setModifiers(node, modifiers); + node.name = parsePropertyName(); + fillSignature(54 /* ColonToken */, /*yieldContext*/ false, /*awaitContext*/ false, /*requireCompleteParameterList*/ false, node); + node.body = parseFunctionBlockOrSemicolon(/*isGenerator*/ false, /*isAsync*/ false); + return finishNode(node); + } + function isClassMemberModifier(idToken) { + switch (idToken) { + case 112 /* PublicKeyword */: + case 110 /* PrivateKeyword */: + case 111 /* ProtectedKeyword */: + case 113 /* StaticKeyword */: + return true; + default: + return false; + } + } + function isClassMemberStart() { + var idToken; + if (token === 55 /* AtToken */) { + return true; + } + // Eat up all modifiers, but hold on to the last one in case it is actually an identifier. + while (ts.isModifier(token)) { + idToken = token; + // If the idToken is a class modifier (protected, private, public, and static), it is + // certain that we are starting to parse class member. This allows better error recovery + // Example: + // public foo() ... // true + // public @dec blah ... // true; we will then report an error later + // export public ... // true; we will then report an error later + if (isClassMemberModifier(idToken)) { + return true; + } + nextToken(); + } + if (token === 37 /* AsteriskToken */) { + return true; + } + // Try to get the first property-like token following all modifiers. + // This can either be an identifier or the 'get' or 'set' keywords. + if (isLiteralPropertyName()) { + idToken = token; + nextToken(); + } + // Index signatures and computed properties are class members; we can parse. + if (token === 19 /* 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 === 129 /* SetKeyword */ || idToken === 123 /* 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 */: + return true; + default: + // Covers + // - Semicolons (declaration termination) + // - Closing braces (end-of-class, must be declaration) + // - End-of-files (not valid, but permitted so that it gets caught later on) + // - Line-breaks (enabling *automatic semicolon insertion*) + return canParseSemicolon(); + } + } + return false; + } + function parseDecorators() { + var decorators; + while (true) { + var decoratorStart = getNodePos(); + if (!parseOptional(55 /* AtToken */)) { + break; + } + if (!decorators) { + decorators = []; + decorators.pos = scanner.getStartPos(); + } + var decorator = createNode(139 /* Decorator */, decoratorStart); + decorator.expression = doInDecoratorContext(parseLeftHandSideExpressionOrHigher); + decorators.push(finishNode(decorator)); + } + if (decorators) { + decorators.end = getNodeEnd(); + } + return decorators; + } + function parseModifiers() { + var flags = 0; + var modifiers; + while (true) { + var modifierStart = scanner.getStartPos(); + var modifierKind = token; + if (!parseAnyContextualModifier()) { + break; + } + if (!modifiers) { + modifiers = []; + modifiers.pos = modifierStart; + } + flags |= ts.modifierToFlag(modifierKind); + modifiers.push(finishNode(createNode(modifierKind, modifierStart))); + } + if (modifiers) { + modifiers.flags = flags; + modifiers.end = scanner.getStartPos(); + } + return modifiers; + } + function parseModifiersForArrowFunction() { + var flags = 0; + var modifiers; + if (token === 118 /* AsyncKeyword */) { + var modifierStart = scanner.getStartPos(); + var modifierKind = token; + nextToken(); + modifiers = []; + modifiers.pos = modifierStart; + flags |= ts.modifierToFlag(modifierKind); + modifiers.push(finishNode(createNode(modifierKind, modifierStart))); + modifiers.flags = flags; + modifiers.end = scanner.getStartPos(); + } + return modifiers; + } + function parseClassElement() { + if (token === 23 /* SemicolonToken */) { + var result = createNode(191 /* SemicolonClassElement */); + nextToken(); + return finishNode(result); + } + var fullStart = getNodePos(); + var decorators = parseDecorators(); + var modifiers = parseModifiers(); + var accessor = tryParseAccessorDeclaration(fullStart, decorators, modifiers); + if (accessor) { + return accessor; + } + if (token === 121 /* ConstructorKeyword */) { + return parseConstructorDeclaration(fullStart, decorators, modifiers); + } + if (isIndexSignature()) { + return parseIndexSignatureDeclaration(fullStart, decorators, modifiers); + } + // It is very important that we check this *after* checking indexers because + // the [ token can start an index signature or a computed property name + if (ts.tokenIsIdentifierOrKeyword(token) || + token === 9 /* StringLiteral */ || + token === 8 /* NumericLiteral */ || + token === 37 /* AsteriskToken */ || + token === 19 /* OpenBracketToken */) { + return parsePropertyOrMethodDeclaration(fullStart, decorators, modifiers); + } + if (decorators || modifiers) { + // treat this as a property declaration with a missing name. + var name_7 = createMissingNode(69 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); + return parsePropertyDeclaration(fullStart, decorators, modifiers, name_7, /*questionToken*/ undefined); + } + // 'isClassMemberStart' should have hinted not to attempt parsing. + ts.Debug.fail("Should not have attempted to parse class member declaration."); + } + function parseClassExpression() { + return parseClassDeclarationOrExpression( + /*fullStart*/ scanner.getStartPos(), + /*decorators*/ undefined, + /*modifiers*/ undefined, 186 /* ClassExpression */); + } + function parseClassDeclaration(fullStart, decorators, modifiers) { + return parseClassDeclarationOrExpression(fullStart, decorators, modifiers, 214 /* ClassDeclaration */); + } + function parseClassDeclarationOrExpression(fullStart, decorators, modifiers, kind) { + var node = createNode(kind, fullStart); + node.decorators = decorators; + setModifiers(node, modifiers); + parseExpected(73 /* ClassKeyword */); + node.name = parseNameOfClassDeclarationOrExpression(); + node.typeParameters = parseTypeParameters(); + node.heritageClauses = parseHeritageClauses(/*isClassHeritageClause*/ true); + if (parseExpected(15 /* OpenBraceToken */)) { + // ClassTail[Yield,Await] : (Modified) See 14.5 + // ClassHeritage[?Yield,?Await]opt { ClassBody[?Yield,?Await]opt } + node.members = parseClassMembers(); + parseExpected(16 /* CloseBraceToken */); + } + else { + node.members = createMissingList(); + } + return finishNode(node); + } + function parseNameOfClassDeclarationOrExpression() { + // implements is a future reserved word so + // 'class implements' might mean either + // - class expression with omitted name, 'implements' starts heritage clause + // - class with name 'implements' + // 'isImplementsClause' helps to disambiguate between these two cases + return isIdentifier() && !isImplementsClause() + ? parseIdentifier() + : undefined; + } + function isImplementsClause() { + return token === 106 /* ImplementsKeyword */ && lookAhead(nextTokenIsIdentifierOrKeyword); + } + function parseHeritageClauses(isClassHeritageClause) { + // ClassTail[Yield,Await] : (Modified) See 14.5 + // ClassHeritage[?Yield,?Await]opt { ClassBody[?Yield,?Await]opt } + if (isHeritageClause()) { + return parseList(20 /* HeritageClauses */, parseHeritageClause); + } + return undefined; + } + function parseHeritageClausesWorker() { + return parseList(20 /* HeritageClauses */, parseHeritageClause); + } + function parseHeritageClause() { + if (token === 83 /* ExtendsKeyword */ || token === 106 /* ImplementsKeyword */) { + var node = createNode(243 /* HeritageClause */); + node.token = token; + nextToken(); + node.types = parseDelimitedList(7 /* HeritageClauseElement */, parseExpressionWithTypeArguments); + return finishNode(node); + } + return undefined; + } + function parseExpressionWithTypeArguments() { + var node = createNode(188 /* ExpressionWithTypeArguments */); + node.expression = parseLeftHandSideExpressionOrHigher(); + if (token === 25 /* LessThanToken */) { + node.typeArguments = parseBracketedList(18 /* TypeArguments */, parseType, 25 /* LessThanToken */, 27 /* GreaterThanToken */); + } + return finishNode(node); + } + function isHeritageClause() { + return token === 83 /* ExtendsKeyword */ || token === 106 /* ImplementsKeyword */; + } + function parseClassMembers() { + return parseList(5 /* ClassMembers */, parseClassElement); + } + function parseInterfaceDeclaration(fullStart, decorators, modifiers) { + var node = createNode(215 /* InterfaceDeclaration */, fullStart); + node.decorators = decorators; + setModifiers(node, modifiers); + parseExpected(107 /* InterfaceKeyword */); + node.name = parseIdentifier(); + node.typeParameters = parseTypeParameters(); + node.heritageClauses = parseHeritageClauses(/*isClassHeritageClause*/ false); + node.members = parseObjectTypeMembers(); + return finishNode(node); + } + function parseTypeAliasDeclaration(fullStart, decorators, modifiers) { + var node = createNode(216 /* TypeAliasDeclaration */, fullStart); + node.decorators = decorators; + setModifiers(node, modifiers); + parseExpected(132 /* TypeKeyword */); + node.name = parseIdentifier(); + node.typeParameters = parseTypeParameters(); + parseExpected(56 /* EqualsToken */); + node.type = parseType(); + parseSemicolon(); + return 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 + // ConstantEnumMemberSection, which starts at the beginning of an enum declaration + // or any time an integer literal initializer is encountered. + function parseEnumMember() { + var node = createNode(247 /* EnumMember */, scanner.getStartPos()); + node.name = parsePropertyName(); + node.initializer = allowInAnd(parseNonParameterInitializer); + return finishNode(node); + } + function parseEnumDeclaration(fullStart, decorators, modifiers) { + var node = createNode(217 /* EnumDeclaration */, fullStart); + node.decorators = decorators; + setModifiers(node, modifiers); + parseExpected(81 /* EnumKeyword */); + node.name = parseIdentifier(); + if (parseExpected(15 /* OpenBraceToken */)) { + node.members = parseDelimitedList(6 /* EnumMembers */, parseEnumMember); + parseExpected(16 /* CloseBraceToken */); + } + else { + node.members = createMissingList(); + } + return finishNode(node); + } + function parseModuleBlock() { + var node = createNode(219 /* ModuleBlock */, scanner.getStartPos()); + if (parseExpected(15 /* OpenBraceToken */)) { + node.statements = parseList(1 /* BlockStatements */, parseStatement); + parseExpected(16 /* CloseBraceToken */); + } + else { + node.statements = createMissingList(); + } + return finishNode(node); + } + function parseModuleOrNamespaceDeclaration(fullStart, decorators, modifiers, flags) { + var node = createNode(218 /* ModuleDeclaration */, fullStart); + // If we are parsing a dotted namespace name, we want to + // propagate the 'Namespace' flag across the names if set. + var namespaceFlag = flags & 131072 /* Namespace */; + node.decorators = decorators; + setModifiers(node, modifiers); + node.flags |= flags; + node.name = parseIdentifier(); + node.body = parseOptional(21 /* DotToken */) + ? parseModuleOrNamespaceDeclaration(getNodePos(), /*decorators*/ undefined, /*modifiers*/ undefined, 1 /* Export */ | namespaceFlag) + : parseModuleBlock(); + return finishNode(node); + } + function parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers) { + var node = createNode(218 /* ModuleDeclaration */, fullStart); + node.decorators = decorators; + setModifiers(node, modifiers); + node.name = parseLiteralNode(/*internName*/ true); + node.body = parseModuleBlock(); + return finishNode(node); + } + function parseModuleDeclaration(fullStart, decorators, modifiers) { + var flags = modifiers ? modifiers.flags : 0; + if (parseOptional(126 /* NamespaceKeyword */)) { + flags |= 131072 /* Namespace */; + } + else { + parseExpected(125 /* ModuleKeyword */); + if (token === 9 /* StringLiteral */) { + return parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers); + } + } + return parseModuleOrNamespaceDeclaration(fullStart, decorators, modifiers, flags); + } + function isExternalModuleReference() { + return token === 127 /* RequireKeyword */ && + lookAhead(nextTokenIsOpenParen); + } + function nextTokenIsOpenParen() { + return nextToken() === 17 /* OpenParenToken */; + } + function nextTokenIsSlash() { + return nextToken() === 39 /* SlashToken */; + } + function nextTokenIsCommaOrFromKeyword() { + nextToken(); + return token === 24 /* CommaToken */ || + token === 133 /* FromKeyword */; + } + function parseImportDeclarationOrImportEqualsDeclaration(fullStart, decorators, modifiers) { + parseExpected(89 /* ImportKeyword */); + var afterImportPos = scanner.getStartPos(); + var identifier; + if (isIdentifier()) { + identifier = parseIdentifier(); + if (token !== 24 /* CommaToken */ && token !== 133 /* FromKeyword */) { + // ImportEquals declaration of type: + // import x = require("mod"); or + // import x = M.x; + var importEqualsDeclaration = createNode(221 /* ImportEqualsDeclaration */, fullStart); + importEqualsDeclaration.decorators = decorators; + setModifiers(importEqualsDeclaration, modifiers); + importEqualsDeclaration.name = identifier; + parseExpected(56 /* EqualsToken */); + importEqualsDeclaration.moduleReference = parseModuleReference(); + parseSemicolon(); + return finishNode(importEqualsDeclaration); + } + } + // Import statement + var importDeclaration = createNode(222 /* ImportDeclaration */, fullStart); + importDeclaration.decorators = decorators; + setModifiers(importDeclaration, modifiers); + // ImportDeclaration: + // import ImportClause from ModuleSpecifier ; + // import ModuleSpecifier; + if (identifier || + token === 37 /* AsteriskToken */ || + token === 15 /* OpenBraceToken */) { + importDeclaration.importClause = parseImportClause(identifier, afterImportPos); + parseExpected(133 /* FromKeyword */); + } + importDeclaration.moduleSpecifier = parseModuleSpecifier(); + parseSemicolon(); + return finishNode(importDeclaration); + } + function parseImportClause(identifier, fullStart) { + // ImportClause: + // ImportedDefaultBinding + // NameSpaceImport + // NamedImports + // ImportedDefaultBinding, NameSpaceImport + // ImportedDefaultBinding, NamedImports + var importClause = createNode(223 /* ImportClause */, fullStart); + if (identifier) { + // ImportedDefaultBinding: + // ImportedBinding + importClause.name = identifier; + } + // 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(225 /* NamedImports */); + } + return finishNode(importClause); + } + function parseModuleReference() { + return isExternalModuleReference() + ? parseExternalModuleReference() + : parseEntityName(/*allowReservedWords*/ false); + } + function parseExternalModuleReference() { + var node = createNode(232 /* ExternalModuleReference */); + parseExpected(127 /* RequireKeyword */); + parseExpected(17 /* OpenParenToken */); + node.expression = parseModuleSpecifier(); + parseExpected(18 /* CloseParenToken */); + return finishNode(node); + } + function parseModuleSpecifier() { + // We allow arbitrary expressions here, even though the grammar only allows string + // literals. We check to ensure that it is only a string literal later in the grammar + // walker. + var result = parseExpression(); + // Ensure the string being required is in our 'identifier' table. This will ensure + // that features like 'find refs' will look inside this file when search for its name. + if (result.kind === 9 /* StringLiteral */) { + internIdentifier(result.text); + } + return result; + } + function parseNamespaceImport() { + // NameSpaceImport: + // * as ImportedBinding + var namespaceImport = createNode(224 /* NamespaceImport */); + parseExpected(37 /* AsteriskToken */); + parseExpected(116 /* AsKeyword */); + namespaceImport.name = parseIdentifier(); + return finishNode(namespaceImport); + } + function parseNamedImportsOrExports(kind) { + var node = createNode(kind); + // NamedImports: + // { } + // { ImportsList } + // { ImportsList, } + // ImportsList: + // ImportSpecifier + // ImportsList, ImportSpecifier + node.elements = parseBracketedList(21 /* ImportOrExportSpecifiers */, kind === 225 /* NamedImports */ ? parseImportSpecifier : parseExportSpecifier, 15 /* OpenBraceToken */, 16 /* CloseBraceToken */); + return finishNode(node); + } + function parseExportSpecifier() { + return parseImportOrExportSpecifier(230 /* ExportSpecifier */); + } + function parseImportSpecifier() { + return parseImportOrExportSpecifier(226 /* ImportSpecifier */); + } + function parseImportOrExportSpecifier(kind) { + var node = createNode(kind); + // ImportSpecifier: + // BindingIdentifier + // IdentifierName as BindingIdentifier + // ExportSpecififer: + // IdentifierName + // IdentifierName as IdentifierName + var checkIdentifierIsKeyword = ts.isKeyword(token) && !isIdentifier(); + var checkIdentifierStart = scanner.getTokenPos(); + var checkIdentifierEnd = scanner.getTextPos(); + var identifierName = parseIdentifierName(); + if (token === 116 /* AsKeyword */) { + node.propertyName = identifierName; + parseExpected(116 /* AsKeyword */); + checkIdentifierIsKeyword = ts.isKeyword(token) && !isIdentifier(); + checkIdentifierStart = scanner.getTokenPos(); + checkIdentifierEnd = scanner.getTextPos(); + node.name = parseIdentifierName(); + } + else { + node.name = identifierName; + } + if (kind === 226 /* ImportSpecifier */ && checkIdentifierIsKeyword) { + // Report error identifier expected + parseErrorAtPosition(checkIdentifierStart, checkIdentifierEnd - checkIdentifierStart, ts.Diagnostics.Identifier_expected); + } + return finishNode(node); + } + function parseExportDeclaration(fullStart, decorators, modifiers) { + var node = createNode(228 /* ExportDeclaration */, fullStart); + node.decorators = decorators; + setModifiers(node, modifiers); + if (parseOptional(37 /* AsteriskToken */)) { + parseExpected(133 /* FromKeyword */); + node.moduleSpecifier = parseModuleSpecifier(); + } + else { + node.exportClause = parseNamedImportsOrExports(229 /* NamedExports */); + // It is not uncommon to accidentally omit the 'from' keyword. Additionally, in editing scenarios, + // the 'from' keyword can be parsed as a named export when the export clause is unterminated (i.e. `export { from "moduleName";`) + // If we don't have a 'from' keyword, see if we have a string literal such that ASI won't take effect. + if (token === 133 /* FromKeyword */ || (token === 9 /* StringLiteral */ && !scanner.hasPrecedingLineBreak())) { + parseExpected(133 /* FromKeyword */); + node.moduleSpecifier = parseModuleSpecifier(); + } + } + parseSemicolon(); + return finishNode(node); + } + function parseExportAssignment(fullStart, decorators, modifiers) { + var node = createNode(227 /* ExportAssignment */, fullStart); + node.decorators = decorators; + setModifiers(node, modifiers); + if (parseOptional(56 /* EqualsToken */)) { + node.isExportEquals = true; + } + else { + parseExpected(77 /* DefaultKeyword */); + } + node.expression = parseAssignmentExpressionOrHigher(); + parseSemicolon(); + return finishNode(node); + } + function processReferenceComments(sourceFile) { + var triviaScanner = ts.createScanner(sourceFile.languageVersion, /*skipTrivia*/ false, 0 /* Standard */, sourceText); + var referencedFiles = []; + var amdDependencies = []; + var amdModuleName; + // Keep scanning all the leading trivia in the file until we get to something that + // isn't trivia. Any single line comment will be analyzed to see if it is a + // reference comment. + while (true) { + var kind = triviaScanner.scan(); + if (kind === 5 /* WhitespaceTrivia */ || kind === 4 /* NewLineTrivia */ || kind === 3 /* MultiLineCommentTrivia */) { + continue; + } + if (kind !== 2 /* SingleLineCommentTrivia */) { + break; + } + var range = { pos: triviaScanner.getTokenPos(), end: triviaScanner.getTextPos(), kind: triviaScanner.getToken() }; + var comment = sourceText.substring(range.pos, range.end); + var referencePathMatchResult = ts.getFileReferenceFromReferencePath(comment, range); + if (referencePathMatchResult) { + var fileReference = referencePathMatchResult.fileReference; + sourceFile.hasNoDefaultLib = referencePathMatchResult.isNoDefaultLib; + var diagnosticMessage = referencePathMatchResult.diagnosticMessage; + if (fileReference) { + referencedFiles.push(fileReference); + } + if (diagnosticMessage) { + parseDiagnostics.push(ts.createFileDiagnostic(sourceFile, range.pos, range.end - range.pos, diagnosticMessage)); + } + } + else { + var amdModuleNameRegEx = /^\/\/\/\s*".length; + return parseErrorAtPosition(start, end - start, ts.Diagnostics.Type_argument_list_cannot_be_empty); + } + } + function parseQualifiedName(left) { + var result = createNode(135 /* QualifiedName */, left.pos); + result.left = left; + result.right = parseIdentifierName(); + return finishNode(result); + } + function parseJSDocRecordType() { + var result = createNode(257 /* JSDocRecordType */); + nextToken(); + result.members = parseDelimitedList(24 /* JSDocRecordMembers */, parseJSDocRecordMember); + checkForTrailingComma(result.members); + parseExpected(16 /* CloseBraceToken */); + return finishNode(result); + } + function parseJSDocRecordMember() { + var result = createNode(258 /* JSDocRecordMember */); + result.name = parseSimplePropertyName(); + if (token === 54 /* ColonToken */) { + nextToken(); + result.type = parseJSDocType(); + } + return finishNode(result); + } + function parseJSDocNonNullableType() { + var result = createNode(256 /* JSDocNonNullableType */); + nextToken(); + result.type = parseJSDocType(); + return finishNode(result); + } + function parseJSDocTupleType() { + var result = createNode(254 /* JSDocTupleType */); + nextToken(); + result.types = parseDelimitedList(25 /* JSDocTupleTypes */, parseJSDocType); + checkForTrailingComma(result.types); + parseExpected(20 /* CloseBracketToken */); + return finishNode(result); + } + function checkForTrailingComma(list) { + if (parseDiagnostics.length === 0 && list.hasTrailingComma) { + var start = list.end - ",".length; + parseErrorAtPosition(start, ",".length, ts.Diagnostics.Trailing_comma_not_allowed); + } + } + function parseJSDocUnionType() { + var result = createNode(253 /* JSDocUnionType */); + nextToken(); + result.types = parseJSDocTypeList(parseJSDocType()); + parseExpected(18 /* CloseParenToken */); + return finishNode(result); + } + function parseJSDocTypeList(firstType) { + ts.Debug.assert(!!firstType); + var types = []; + types.pos = firstType.pos; + types.push(firstType); + while (parseOptional(47 /* BarToken */)) { + types.push(parseJSDocType()); + } + types.end = scanner.getStartPos(); + return types; + } + function parseJSDocAllType() { + var result = createNode(250 /* JSDocAllType */); + nextToken(); + return finishNode(result); + } + function parseJSDocUnknownOrNullableType() { + var pos = scanner.getStartPos(); + // skip the ? + nextToken(); + // Need to lookahead to decide if this is a nullable or unknown type. + // Here are cases where we'll pick the unknown type: + // + // Foo(?, + // { a: ? } + // Foo(?) + // Foo + // Foo(?= + // (?| + if (token === 24 /* CommaToken */ || + token === 16 /* CloseBraceToken */ || + token === 18 /* CloseParenToken */ || + token === 27 /* GreaterThanToken */ || + token === 56 /* EqualsToken */ || + token === 47 /* BarToken */) { + var result = createNode(251 /* JSDocUnknownType */, pos); + return finishNode(result); + } + else { + var result = createNode(255 /* JSDocNullableType */, pos); + result.type = parseJSDocType(); + return finishNode(result); + } + } + function parseIsolatedJSDocComment(content, start, length) { + initializeState("file.js", content, 2 /* Latest */, /*_syntaxCursor:*/ undefined); + var jsDocComment = parseJSDocComment(/*parent:*/ undefined, start, length); + var diagnostics = parseDiagnostics; + clearState(); + return jsDocComment ? { jsDocComment: jsDocComment, diagnostics: diagnostics } : undefined; + } + JSDocParser.parseIsolatedJSDocComment = parseIsolatedJSDocComment; + function parseJSDocComment(parent, start, length) { + var comment = parseJSDocCommentWorker(start, length); + if (comment) { + fixupParentReferences(comment); + comment.parent = parent; + } + return comment; + } + JSDocParser.parseJSDocComment = parseJSDocComment; + function parseJSDocCommentWorker(start, length) { + var content = sourceText; + start = start || 0; + var end = length === undefined ? content.length : start + length; + length = end - start; + ts.Debug.assert(start >= 0); + ts.Debug.assert(start <= end); + ts.Debug.assert(end <= content.length); + var tags; + var pos; + // NOTE(cyrusn): This is essentially a handwritten scanner for JSDocComments. I + // considered using an actual Scanner, but this would complicate things. The + // scanner would need to know it was in a Doc Comment. Otherwise, it would then + // produce comments *inside* the doc comment. In the end it was just easier to + // write a simple scanner rather than go that route. + if (length >= "/** */".length) { + if (content.charCodeAt(start) === 47 /* slash */ && + content.charCodeAt(start + 1) === 42 /* asterisk */ && + content.charCodeAt(start + 2) === 42 /* asterisk */ && + content.charCodeAt(start + 3) !== 42 /* asterisk */) { + // Initially we can parse out a tag. We also have seen a starting asterisk. + // This is so that /** * @type */ doesn't parse. + var canParseTag = true; + var seenAsterisk = true; + for (pos = start + "/**".length; pos < end;) { + var ch = content.charCodeAt(pos); + pos++; + if (ch === 64 /* at */ && canParseTag) { + parseTag(); + // Once we parse out a tag, we cannot keep parsing out tags on this line. + canParseTag = false; + continue; + } + if (ts.isLineBreak(ch)) { + // After a line break, we can parse a tag, and we haven't seen as asterisk + // on the next line yet. + canParseTag = true; + seenAsterisk = false; + continue; + } + if (ts.isWhiteSpace(ch)) { + // Whitespace doesn't affect any of our parsing. + continue; + } + // Ignore the first asterisk on a line. + if (ch === 42 /* asterisk */) { + if (seenAsterisk) { + // If we've already seen an asterisk, then we can no longer parse a tag + // on this line. + canParseTag = false; + } + seenAsterisk = true; + continue; + } + // Anything else is doc comment text. We can't do anything with it. Because it + // wasn't a tag, we can no longer parse a tag on this line until we hit the next + // line break. + canParseTag = false; + } + } + } + return createJSDocComment(); + function createJSDocComment() { + if (!tags) { + return undefined; + } + var result = createNode(265 /* JSDocComment */, start); + result.tags = tags; + return finishNode(result, end); + } + function skipWhitespace() { + while (pos < end && ts.isWhiteSpace(content.charCodeAt(pos))) { + pos++; + } + } + function parseTag() { + ts.Debug.assert(content.charCodeAt(pos - 1) === 64 /* at */); + var atToken = createNode(55 /* AtToken */, pos - 1); + atToken.end = pos; + var tagName = scanIdentifier(); + if (!tagName) { + return; + } + var tag = handleTag(atToken, tagName) || handleUnknownTag(atToken, tagName); + addTag(tag); + } + function handleTag(atToken, tagName) { + if (tagName) { + switch (tagName.text) { + case "param": + return handleParamTag(atToken, tagName); + case "return": + case "returns": + return handleReturnTag(atToken, tagName); + case "template": + return handleTemplateTag(atToken, tagName); + case "type": + return handleTypeTag(atToken, tagName); + } + } + return undefined; + } + function handleUnknownTag(atToken, tagName) { + var result = createNode(266 /* JSDocTag */, atToken.pos); + result.atToken = atToken; + result.tagName = tagName; + return finishNode(result, pos); + } + function addTag(tag) { + if (tag) { + if (!tags) { + tags = []; + tags.pos = tag.pos; + } + tags.push(tag); + tags.end = tag.end; + } + } + function tryParseTypeExpression() { + skipWhitespace(); + if (content.charCodeAt(pos) !== 123 /* openBrace */) { + return undefined; + } + var typeExpression = parseJSDocTypeExpression(pos, end - pos); + pos = typeExpression.end; + return typeExpression; + } + function handleParamTag(atToken, tagName) { + var typeExpression = tryParseTypeExpression(); + skipWhitespace(); + var name; + var isBracketed; + if (content.charCodeAt(pos) === 91 /* openBracket */) { + pos++; + skipWhitespace(); + name = scanIdentifier(); + isBracketed = true; + } + else { + name = scanIdentifier(); + } + if (!name) { + parseErrorAtPosition(pos, 0, ts.Diagnostics.Identifier_expected); + } + var preName, postName; + if (typeExpression) { + postName = name; + } + else { + preName = name; + } + if (!typeExpression) { + typeExpression = tryParseTypeExpression(); + } + var result = createNode(267 /* JSDocParameterTag */, atToken.pos); + result.atToken = atToken; + result.tagName = tagName; + result.preParameterName = preName; + result.typeExpression = typeExpression; + result.postParameterName = postName; + result.isBracketed = isBracketed; + return finishNode(result, pos); + } + function handleReturnTag(atToken, tagName) { + if (ts.forEach(tags, function (t) { return t.kind === 268 /* JSDocReturnTag */; })) { + parseErrorAtPosition(tagName.pos, pos - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); + } + var result = createNode(268 /* JSDocReturnTag */, atToken.pos); + result.atToken = atToken; + result.tagName = tagName; + result.typeExpression = tryParseTypeExpression(); + return finishNode(result, pos); + } + function handleTypeTag(atToken, tagName) { + if (ts.forEach(tags, function (t) { return t.kind === 269 /* JSDocTypeTag */; })) { + parseErrorAtPosition(tagName.pos, pos - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); + } + var result = createNode(269 /* JSDocTypeTag */, atToken.pos); + result.atToken = atToken; + result.tagName = tagName; + result.typeExpression = tryParseTypeExpression(); + return finishNode(result, pos); + } + function handleTemplateTag(atToken, tagName) { + if (ts.forEach(tags, function (t) { return t.kind === 270 /* JSDocTemplateTag */; })) { + parseErrorAtPosition(tagName.pos, pos - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); + } + var typeParameters = []; + typeParameters.pos = pos; + while (true) { + skipWhitespace(); + var startPos = pos; + var name_8 = scanIdentifier(); + if (!name_8) { + parseErrorAtPosition(startPos, 0, ts.Diagnostics.Identifier_expected); + return undefined; + } + var typeParameter = createNode(137 /* TypeParameter */, name_8.pos); + typeParameter.name = name_8; + finishNode(typeParameter, pos); + typeParameters.push(typeParameter); + skipWhitespace(); + if (content.charCodeAt(pos) !== 44 /* comma */) { + break; + } + pos++; + } + typeParameters.end = pos; + var result = createNode(270 /* JSDocTemplateTag */, atToken.pos); + result.atToken = atToken; + result.tagName = tagName; + result.typeParameters = typeParameters; + return finishNode(result, pos); + } + function scanIdentifier() { + var startPos = pos; + for (; pos < end; pos++) { + var ch = content.charCodeAt(pos); + if (pos === startPos && ts.isIdentifierStart(ch, 2 /* Latest */)) { + continue; + } + else if (pos > startPos && ts.isIdentifierPart(ch, 2 /* Latest */)) { + continue; + } + break; + } + if (startPos === pos) { + return undefined; + } + var result = createNode(69 /* Identifier */, startPos); + result.text = content.substring(startPos, pos); + return finishNode(result, pos); + } + } + JSDocParser.parseJSDocCommentWorker = parseJSDocCommentWorker; + })(JSDocParser = Parser.JSDocParser || (Parser.JSDocParser = {})); + })(Parser || (Parser = {})); + var IncrementalParser; + (function (IncrementalParser) { + function updateSourceFile(sourceFile, newText, textChangeRange, aggressiveChecks) { + aggressiveChecks = aggressiveChecks || ts.Debug.shouldAssert(2 /* Aggressive */); + checkChangeRange(sourceFile, newText, textChangeRange, aggressiveChecks); + if (ts.textChangeRangeIsUnchanged(textChangeRange)) { + // if the text didn't change, then we can just return our current source file as-is. + return sourceFile; + } + if (sourceFile.statements.length === 0) { + // If we don't have any statements in the current source file, then there's no real + // way to incrementally parse. So just do a full parse instead. + return Parser.parseSourceFile(sourceFile.fileName, newText, sourceFile.languageVersion, /*syntaxCursor*/ undefined, /*setNodeParents*/ true); + } + // Make sure we're not trying to incrementally update a source file more than once. Once + // we do an update the original source file is considered unusbale from that point onwards. + // + // This is because we do incremental parsing in-place. i.e. we take nodes from the old + // tree and give them new positions and parents. From that point on, trusting the old + // tree at all is not possible as far too much of it may violate invariants. + var incrementalSourceFile = sourceFile; + ts.Debug.assert(!incrementalSourceFile.hasBeenIncrementallyParsed); + incrementalSourceFile.hasBeenIncrementallyParsed = true; + var oldText = sourceFile.text; + var syntaxCursor = createSyntaxCursor(sourceFile); + // Make the actual change larger so that we know to reparse anything whose lookahead + // might have intersected the change. + var changeRange = extendToAffectedRange(sourceFile, textChangeRange); + checkChangeRange(sourceFile, newText, changeRange, aggressiveChecks); + // Ensure that extending the affected range only moved the start of the change range + // earlier in the file. + ts.Debug.assert(changeRange.span.start <= textChangeRange.span.start); + ts.Debug.assert(ts.textSpanEnd(changeRange.span) === ts.textSpanEnd(textChangeRange.span)); + ts.Debug.assert(ts.textSpanEnd(ts.textChangeRangeNewSpan(changeRange)) === ts.textSpanEnd(ts.textChangeRangeNewSpan(textChangeRange))); + // The is the amount the nodes after the edit range need to be adjusted. It can be + // positive (if the edit added characters), negative (if the edit deleted characters) + // or zero (if this was a pure overwrite with nothing added/removed). + var delta = ts.textChangeRangeNewSpan(changeRange).length - changeRange.span.length; + // If we added or removed characters during the edit, then we need to go and adjust all + // the nodes after the edit. Those nodes may move forward (if we inserted chars) or they + // may move backward (if we deleted chars). + // + // Doing this helps us out in two ways. First, it means that any nodes/tokens we want + // to reuse are already at the appropriate position in the new text. That way when we + // reuse them, we don't have to figure out if they need to be adjusted. Second, it makes + // it very easy to determine if we can reuse a node. If the node's position is at where + // we are in the text, then we can reuse it. Otherwise we can't. If the node's position + // is ahead of us, then we'll need to rescan tokens. If the node's position is behind + // us, then we'll need to skip it or crumble it as appropriate + // + // We will also adjust the positions of nodes that intersect the change range as well. + // By doing this, we ensure that all the positions in the old tree are consistent, not + // just the positions of nodes entirely before/after the change range. By being + // consistent, we can then easily map from positions to nodes in the old tree easily. + // + // Also, mark any syntax elements that intersect the changed span. We know, up front, + // that we cannot reuse these elements. + updateTokenPositionsAndMarkElements(incrementalSourceFile, changeRange.span.start, ts.textSpanEnd(changeRange.span), ts.textSpanEnd(ts.textChangeRangeNewSpan(changeRange)), delta, oldText, newText, aggressiveChecks); + // Now that we've set up our internal incremental state just proceed and parse the + // source file in the normal fashion. When possible the parser will retrieve and + // reuse nodes from the old tree. + // + // Note: passing in 'true' for setNodeParents is very important. When incrementally + // parsing, we will be reusing nodes from the old tree, and placing it into new + // parents. If we don't set the parents now, we'll end up with an observably + // inconsistent tree. Setting the parents on the new tree should be very fast. We + // will immediately bail out of walking any subtrees when we can see that their parents + // are already correct. + var result = Parser.parseSourceFile(sourceFile.fileName, newText, sourceFile.languageVersion, syntaxCursor, /* setParentNode */ true); + return result; + } + IncrementalParser.updateSourceFile = updateSourceFile; + function moveElementEntirelyPastChangeRange(element, isArray, delta, oldText, newText, aggressiveChecks) { + if (isArray) { + visitArray(element); + } + else { + visitNode(element); + } + return; + function visitNode(node) { + var text = ""; + if (aggressiveChecks && shouldCheckNode(node)) { + text = oldText.substring(node.pos, node.end); + } + // Ditch any existing LS children we may have created. This way we can avoid + // moving them forward. + if (node._children) { + node._children = undefined; + } + if (node.jsDocComment) { + node.jsDocComment = undefined; + } + node.pos += delta; + node.end += delta; + if (aggressiveChecks && shouldCheckNode(node)) { + ts.Debug.assert(text === newText.substring(node.pos, node.end)); + } + forEachChild(node, visitNode, visitArray); + checkNodePositions(node, aggressiveChecks); + } + function visitArray(array) { + array._children = undefined; + array.pos += delta; + array.end += delta; + for (var _i = 0; _i < array.length; _i++) { + var node = array[_i]; + visitNode(node); + } + } + } + function shouldCheckNode(node) { + switch (node.kind) { + case 9 /* StringLiteral */: + case 8 /* NumericLiteral */: + case 69 /* Identifier */: + return true; + } + return false; + } + function adjustIntersectingElement(element, changeStart, changeRangeOldEnd, changeRangeNewEnd, delta) { + ts.Debug.assert(element.end >= changeStart, "Adjusting an element that was entirely before the change range"); + ts.Debug.assert(element.pos <= changeRangeOldEnd, "Adjusting an element that was entirely after the change range"); + ts.Debug.assert(element.pos <= element.end); + // We have an element that intersects the change range in some way. It may have its + // start, or its end (or both) in the changed range. We want to adjust any part + // that intersects such that the final tree is in a consistent state. i.e. all + // chlidren have spans within the span of their parent, and all siblings are ordered + // properly. + // We may need to update both the 'pos' and the 'end' of the element. + // If the 'pos' is before the start of the change, then we don't need to touch it. + // If it isn't, then the 'pos' must be inside the change. How we update it will + // depend if delta is positive or negative. If delta is positive then we have + // something like: + // + // -------------------AAA----------------- + // -------------------BBBCCCCCCC----------------- + // + // In this case, we consider any node that started in the change range to still be + // starting at the same position. + // + // however, if the delta is negative, then we instead have something like this: + // + // -------------------XXXYYYYYYY----------------- + // -------------------ZZZ----------------- + // + // In this case, any element that started in the 'X' range will keep its position. + // However any element htat started after that will have their pos adjusted to be + // at the end of the new range. i.e. any node that started in the 'Y' range will + // be adjusted to have their start at the end of the 'Z' range. + // + // The element will keep its position if possible. Or Move backward to the new-end + // if it's in the 'Y' range. + element.pos = Math.min(element.pos, changeRangeNewEnd); + // If the 'end' is after the change range, then we always adjust it by the delta + // amount. However, if the end is in the change range, then how we adjust it + // will depend on if delta is positive or negative. If delta is positive then we + // have something like: + // + // -------------------AAA----------------- + // -------------------BBBCCCCCCC----------------- + // + // In this case, we consider any node that ended inside the change range to keep its + // end position. + // + // however, if the delta is negative, then we instead have something like this: + // + // -------------------XXXYYYYYYY----------------- + // -------------------ZZZ----------------- + // + // In this case, any element that ended in the 'X' range will keep its position. + // However any element htat ended after that will have their pos adjusted to be + // at the end of the new range. i.e. any node that ended in the 'Y' range will + // be adjusted to have their end at the end of the 'Z' range. + if (element.end >= changeRangeOldEnd) { + // Element ends after the change range. Always adjust the end pos. + element.end += delta; + } + else { + // Element ends in the change range. The element will keep its position if + // possible. Or Move backward to the new-end if it's in the 'Y' range. + element.end = Math.min(element.end, changeRangeNewEnd); + } + ts.Debug.assert(element.pos <= element.end); + if (element.parent) { + ts.Debug.assert(element.pos >= element.parent.pos); + ts.Debug.assert(element.end <= element.parent.end); + } + } + function checkNodePositions(node, aggressiveChecks) { + if (aggressiveChecks) { + var pos = node.pos; + forEachChild(node, function (child) { + ts.Debug.assert(child.pos >= pos); + pos = child.end; + }); + ts.Debug.assert(pos <= node.end); + } + } + function updateTokenPositionsAndMarkElements(sourceFile, changeStart, changeRangeOldEnd, changeRangeNewEnd, delta, oldText, newText, aggressiveChecks) { + visitNode(sourceFile); + return; + function visitNode(child) { + ts.Debug.assert(child.pos <= child.end); + if (child.pos > changeRangeOldEnd) { + // Node is entirely past the change range. We need to move both its pos and + // end, forward or backward appropriately. + moveElementEntirelyPastChangeRange(child, /*isArray*/ false, delta, oldText, newText, aggressiveChecks); + return; + } + // Check if the element intersects the change range. If it does, then it is not + // reusable. Also, we'll need to recurse to see what constituent portions we may + // be able to use. + var fullEnd = child.end; + if (fullEnd >= changeStart) { + child.intersectsChange = true; + child._children = undefined; + // Adjust the pos or end (or both) of the intersecting element accordingly. + adjustIntersectingElement(child, changeStart, changeRangeOldEnd, changeRangeNewEnd, delta); + forEachChild(child, visitNode, visitArray); + checkNodePositions(child, aggressiveChecks); + return; + } + // Otherwise, the node is entirely before the change range. No need to do anything with it. + ts.Debug.assert(fullEnd < changeStart); + } + function visitArray(array) { + ts.Debug.assert(array.pos <= array.end); + if (array.pos > changeRangeOldEnd) { + // Array is entirely after the change range. We need to move it, and move any of + // its children. + moveElementEntirelyPastChangeRange(array, /*isArray*/ true, delta, oldText, newText, aggressiveChecks); + return; + } + // Check if the element intersects the change range. If it does, then it is not + // reusable. Also, we'll need to recurse to see what constituent portions we may + // be able to use. + var fullEnd = array.end; + if (fullEnd >= changeStart) { + array.intersectsChange = true; + 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; _i < array.length; _i++) { + var node = array[_i]; + visitNode(node); + } + return; + } + // Otherwise, the array is entirely before the change range. No need to do anything with it. + ts.Debug.assert(fullEnd < changeStart); + } + } + function extendToAffectedRange(sourceFile, changeRange) { + // Consider the following code: + // void foo() { /; } + // + // If the text changes with an insertion of / just before the semicolon then we end up with: + // void foo() { //; } + // + // If we were to just use the changeRange a is, then we would not rescan the { token + // (as it does not intersect the actual original change range). Because an edit may + // change the token touching it, we actually need to look back *at least* one token so + // that the prior token sees that change. + var maxLookahead = 1; + var start = changeRange.span.start; + // the first iteration aligns us with the change start. subsequent iteration move us to + // the left by maxLookahead tokens. We only need to do this as long as we're not at the + // start of the tree. + for (var i = 0; start > 0 && i <= maxLookahead; i++) { + var nearestNode = findNearestNodeStartingBeforeOrAtPosition(sourceFile, start); + ts.Debug.assert(nearestNode.pos <= start); + var position = nearestNode.pos; + start = Math.max(0, position - 1); + } + var finalSpan = ts.createTextSpanFromBounds(start, ts.textSpanEnd(changeRange.span)); + var finalLength = changeRange.newLength + (changeRange.span.start - start); + return ts.createTextChangeRange(finalSpan, finalLength); + } + function findNearestNodeStartingBeforeOrAtPosition(sourceFile, position) { + var bestResult = sourceFile; + var lastNodeEntirelyBeforePosition; + forEachChild(sourceFile, visit); + if (lastNodeEntirelyBeforePosition) { + var lastChildOfLastEntireNodeBeforePosition = getLastChild(lastNodeEntirelyBeforePosition); + if (lastChildOfLastEntireNodeBeforePosition.pos > bestResult.pos) { + bestResult = lastChildOfLastEntireNodeBeforePosition; + } + } + return bestResult; + function getLastChild(node) { + while (true) { + var lastChild = getLastChildWorker(node); + if (lastChild) { + node = lastChild; + } + else { + return node; + } + } + } + function getLastChildWorker(node) { + var last = undefined; + forEachChild(node, function (child) { + if (ts.nodeIsPresent(child)) { + last = child; + } + }); + return last; + } + function visit(child) { + if (ts.nodeIsMissing(child)) { + // Missing nodes are effectively invisible to us. We never even consider them + // When trying to find the nearest node before us. + return; + } + // If the child intersects this position, then this node is currently the nearest + // node that starts before the position. + if (child.pos <= position) { + if (child.pos >= bestResult.pos) { + // This node starts before the position, and is closer to the position than + // the previous best node we found. It is now the new best node. + bestResult = child; + } + // Now, the node may overlap the position, or it may end entirely before the + // position. If it overlaps with the position, then either it, or one of its + // children must be the nearest node before the position. So we can just + // recurse into this child to see if we can find something better. + if (position < child.end) { + // The nearest node is either this child, or one of the children inside + // of it. We've already marked this child as the best so far. Recurse + // in case one of the children is better. + forEachChild(child, visit); + // Once we look at the children of this node, then there's no need to + // continue any further. + return true; + } + else { + ts.Debug.assert(child.end <= position); + // The child ends entirely before this position. Say you have the following + // (where $ is the position) + // + // ? $ : <...> <...> + // + // We would want to find the nearest preceding node in "complex expr 2". + // To support that, we keep track of this node, and once we're done searching + // for a best node, we recurse down this node to see if we can find a good + // result in it. + // + // This approach allows us to quickly skip over nodes that are entirely + // before the position, while still allowing us to find any nodes in the + // last one that might be what we want. + lastNodeEntirelyBeforePosition = child; + } + } + else { + ts.Debug.assert(child.pos > position); + // We're now at a node that is entirely past the position we're searching for. + // This node (and all following nodes) could never contribute to the result, + // so just skip them by returning 'true' here. + return true; + } + } + } + function checkChangeRange(sourceFile, newText, textChangeRange, aggressiveChecks) { + var oldText = sourceFile.text; + if (textChangeRange) { + ts.Debug.assert((oldText.length - textChangeRange.span.length + textChangeRange.newLength) === newText.length); + if (aggressiveChecks || ts.Debug.shouldAssert(3 /* VeryAggressive */)) { + var oldTextPrefix = oldText.substr(0, textChangeRange.span.start); + var newTextPrefix = newText.substr(0, textChangeRange.span.start); + ts.Debug.assert(oldTextPrefix === newTextPrefix); + var oldTextSuffix = oldText.substring(ts.textSpanEnd(textChangeRange.span), oldText.length); + var newTextSuffix = newText.substring(ts.textSpanEnd(ts.textChangeRangeNewSpan(textChangeRange)), newText.length); + ts.Debug.assert(oldTextSuffix === newTextSuffix); + } + } + } + function createSyntaxCursor(sourceFile) { + var currentArray = sourceFile.statements; + var currentArrayIndex = 0; + ts.Debug.assert(currentArrayIndex < currentArray.length); + var current = currentArray[currentArrayIndex]; + var lastQueriedPosition = -1 /* Value */; + return { + currentNode: function (position) { + // Only compute the current node if the position is different than the last time + // we were asked. The parser commonly asks for the node at the same position + // twice. Once to know if can read an appropriate list element at a certain point, + // and then to actually read and consume the node. + if (position !== lastQueriedPosition) { + // Much of the time the parser will need the very next node in the array that + // we just returned a node from.So just simply check for that case and move + // forward in the array instead of searching for the node again. + if (current && current.end === position && currentArrayIndex < (currentArray.length - 1)) { + currentArrayIndex++; + current = currentArray[currentArrayIndex]; + } + // If we don't have a node, or the node we have isn't in the right position, + // then try to find a viable node at the position requested. + if (!current || current.pos !== position) { + findHighestListElementThatStartsAtPosition(position); + } + } + // Cache this query so that we don't do any extra work if the parser calls back + // into us. Note: this is very common as the parser will make pairs of calls like + // 'isListElement -> parseListElement'. If we were unable to find a node when + // called with 'isListElement', we don't want to redo the work when parseListElement + // is called immediately after. + lastQueriedPosition = position; + // Either we don'd have a node, or we have a node at the position being asked for. + ts.Debug.assert(!current || current.pos === position); + return current; + } + }; + // Finds the highest element in the tree we can find that starts at the provided position. + // The element must be a direct child of some node list in the tree. This way after we + // return it, we can easily return its next sibling in the list. + function findHighestListElementThatStartsAtPosition(position) { + // Clear out any cached state about the last node we found. + currentArray = undefined; + currentArrayIndex = -1 /* Value */; + current = undefined; + // Recurse into the source file to find the highest node at this position. + forEachChild(sourceFile, visitNode, visitArray); + return; + function visitNode(node) { + if (position >= node.pos && position < node.end) { + // Position was within this node. Keep searching deeper to find the node. + forEachChild(node, visitNode, visitArray); + // don't procede any futher in the search. + return true; + } + // position wasn't in this node, have to keep searching. + return false; + } + function visitArray(array) { + if (position >= array.pos && position < array.end) { + // position was in this array. Search through this array to see if we find a + // viable element. + for (var i = 0, n = array.length; i < n; i++) { + var child = array[i]; + if (child) { + if (child.pos === position) { + // Found the right node. We're done. + currentArray = array; + currentArrayIndex = i; + current = child; + return true; + } + else { + if (child.pos < position && position < child.end) { + // Position in somewhere within this child. Search in it and + // stop searching in this array. + forEachChild(child, visitNode, visitArray); + return true; + } + } + } + } + } + // position wasn't in this array, have to keep searching. + return false; + } + } + } + var InvalidPosition; + (function (InvalidPosition) { + InvalidPosition[InvalidPosition["Value"] = -1] = "Value"; + })(InvalidPosition || (InvalidPosition = {})); + })(IncrementalParser || (IncrementalParser = {})); +})(ts || (ts = {})); +/// +/* @internal */ +var ts; +(function (ts) { + var nextSymbolId = 1; + var nextNodeId = 1; + var nextMergeId = 1; + function getNodeId(node) { + if (!node.id) + node.id = nextNodeId++; + return node.id; + } + ts.getNodeId = getNodeId; + ts.checkTime = 0; + function getSymbolId(symbol) { + if (!symbol.id) { + symbol.id = nextSymbolId++; + } + return symbol.id; + } + ts.getSymbolId = getSymbolId; + function createTypeChecker(host, produceDiagnostics) { + // Cancellation that controls whether or not we can cancel in the middle of type checking. + // In general cancelling is *not* safe for the type checker. We might be in the middle of + // computing something, and we will leave our internals in an inconsistent state. Callers + // who set the cancellation token should catch if a cancellation exception occurs, and + // should throw away and create a new TypeChecker. + // + // Currently we only support setting the cancellation token when getting diagnostics. This + // is because diagnostics can be quite expensive, and we want to allow hosts to bail out if + // they no longer need the information (for example, if the user started editing again). + var cancellationToken; + var Symbol = ts.objectAllocator.getSymbolConstructor(); + var Type = ts.objectAllocator.getTypeConstructor(); + var Signature = ts.objectAllocator.getSignatureConstructor(); + var typeCount = 0; + var symbolCount = 0; + var emptyArray = []; + var emptySymbols = {}; + var compilerOptions = host.getCompilerOptions(); + var languageVersion = compilerOptions.target || 0 /* ES3 */; + var modulekind = compilerOptions.module ? compilerOptions.module : languageVersion === 2 /* ES6 */ ? 5 /* ES6 */ : 0 /* None */; + var emitResolver = createResolver(); + var undefinedSymbol = createSymbol(4 /* Property */ | 67108864 /* Transient */, "undefined"); + var argumentsSymbol = createSymbol(4 /* Property */ | 67108864 /* Transient */, "arguments"); + var checker = { + getNodeCount: function () { return ts.sum(host.getSourceFiles(), "nodeCount"); }, + getIdentifierCount: function () { return ts.sum(host.getSourceFiles(), "identifierCount"); }, + getSymbolCount: function () { return ts.sum(host.getSourceFiles(), "symbolCount") + symbolCount; }, + getTypeCount: function () { return typeCount; }, + isUndefinedSymbol: function (symbol) { return symbol === undefinedSymbol; }, + isArgumentsSymbol: function (symbol) { return symbol === argumentsSymbol; }, + getDiagnostics: getDiagnostics, + getGlobalDiagnostics: getGlobalDiagnostics, + // The language service will always care about the narrowed type of a symbol, because that is + // the type the language says the symbol should have. + getTypeOfSymbolAtLocation: getNarrowedTypeOfSymbol, + getDeclaredTypeOfSymbol: getDeclaredTypeOfSymbol, + getPropertiesOfType: getPropertiesOfType, + getPropertyOfType: getPropertyOfType, + getSignaturesOfType: getSignaturesOfType, + getIndexTypeOfType: getIndexTypeOfType, + getBaseTypes: getBaseTypes, + getReturnTypeOfSignature: getReturnTypeOfSignature, + getSymbolsInScope: getSymbolsInScope, + getSymbolAtLocation: getSymbolAtLocation, + getShorthandAssignmentValueSymbol: getShorthandAssignmentValueSymbol, + getTypeAtLocation: getTypeOfNode, + typeToString: typeToString, + getSymbolDisplayBuilder: getSymbolDisplayBuilder, + symbolToString: symbolToString, + getAugmentedPropertiesOfType: getAugmentedPropertiesOfType, + getRootSymbols: getRootSymbols, + getContextualType: getContextualType, + getFullyQualifiedName: getFullyQualifiedName, + getResolvedSignature: getResolvedSignature, + getConstantValue: getConstantValue, + isValidPropertyAccess: isValidPropertyAccess, + getSignatureFromDeclaration: getSignatureFromDeclaration, + isImplementationOfOverload: isImplementationOfOverload, + getAliasedSymbol: resolveAlias, + getEmitResolver: getEmitResolver, + getExportsOfModule: getExportsOfModuleAsArray, + getJsxElementAttributesType: getJsxElementAttributesType, + getJsxIntrinsicTagNames: getJsxIntrinsicTagNames, + isOptionalParameter: isOptionalParameter + }; + var unknownSymbol = createSymbol(4 /* Property */ | 67108864 /* Transient */, "unknown"); + var resolvingSymbol = createSymbol(67108864 /* Transient */, "__resolving__"); + var anyType = createIntrinsicType(1 /* Any */, "any"); + var stringType = createIntrinsicType(2 /* String */, "string"); + var numberType = createIntrinsicType(4 /* Number */, "number"); + var booleanType = createIntrinsicType(8 /* Boolean */, "boolean"); + var esSymbolType = createIntrinsicType(16777216 /* ESSymbol */, "symbol"); + var voidType = createIntrinsicType(16 /* Void */, "void"); + var undefinedType = createIntrinsicType(32 /* Undefined */ | 2097152 /* ContainsUndefinedOrNull */, "undefined"); + var nullType = createIntrinsicType(64 /* Null */ | 2097152 /* ContainsUndefinedOrNull */, "null"); + var unknownType = createIntrinsicType(1 /* Any */, "unknown"); + var circularType = createIntrinsicType(1 /* Any */, "__circular__"); + var emptyObjectType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); + var emptyGenericType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); + emptyGenericType.instantiations = {}; + var anyFunctionType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); + // The anyFunctionType contains the anyFunctionType by definition. The flag is further propagated + // in getPropagatingFlagsOfTypes, and it is checked in inferFromTypes. + anyFunctionType.flags |= 8388608 /* ContainsAnyFunctionType */; + var noConstraintType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); + var anySignature = createSignature(undefined, undefined, emptyArray, anyType, undefined, 0, false, false); + var unknownSignature = createSignature(undefined, undefined, emptyArray, unknownType, undefined, 0, false, false); + var globals = {}; + var globalESSymbolConstructorSymbol; + var getGlobalPromiseConstructorSymbol; + var globalObjectType; + var globalFunctionType; + var globalArrayType; + var globalStringType; + var globalNumberType; + var globalBooleanType; + var globalRegExpType; + var globalTemplateStringsArrayType; + var globalESSymbolType; + var jsxElementType; + /** Lazily loaded, use getJsxIntrinsicElementType() */ + var jsxIntrinsicElementsType; + var globalIterableType; + var globalIteratorType; + var globalIterableIteratorType; + var anyArrayType; + var getGlobalClassDecoratorType; + var getGlobalParameterDecoratorType; + var getGlobalPropertyDecoratorType; + var getGlobalMethodDecoratorType; + var getGlobalTypedPropertyDescriptorType; + var getGlobalPromiseType; + var tryGetGlobalPromiseType; + var getGlobalPromiseLikeType; + var getInstantiatedGlobalPromiseLikeType; + var getGlobalPromiseConstructorLikeType; + var getGlobalThenableType; + var tupleTypes = {}; + var unionTypes = {}; + var intersectionTypes = {}; + var stringLiteralTypes = {}; + var emitExtends = false; + var emitDecorate = false; + var emitParam = false; + var emitAwaiter = false; + var emitGenerator = false; + var resolutionTargets = []; + var resolutionResults = []; + var resolutionPropertyNames = []; + var mergedSymbols = []; + var symbolLinks = []; + var nodeLinks = []; + var potentialThisCollisions = []; + var awaitedTypeStack = []; + var diagnostics = ts.createDiagnosticCollection(); + var primitiveTypeInfo = { + "string": { + type: stringType, + flags: 258 /* StringLike */ + }, + "number": { + type: numberType, + flags: 132 /* NumberLike */ + }, + "boolean": { + type: booleanType, + flags: 8 /* Boolean */ + }, + "symbol": { + type: esSymbolType, + flags: 16777216 /* ESSymbol */ + } + }; + var JsxNames = { + JSX: "JSX", + IntrinsicElements: "IntrinsicElements", + ElementClass: "ElementClass", + ElementAttributesPropertyNameContainer: "ElementAttributesProperty", + Element: "Element" + }; + var subtypeRelation = {}; + var assignableRelation = {}; + var identityRelation = {}; + // This is for caching the result of getSymbolDisplayBuilder. Do not access directly. + 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 = {})); + initializeTypeChecker(); + return checker; + function getEmitResolver(sourceFile, cancellationToken) { + // Ensure we have all the type information in place for this file so that all the + // emitter questions of this resolver will return the right information. + getDiagnostics(sourceFile, cancellationToken); + return emitResolver; + } + function error(location, message, arg0, arg1, arg2) { + var diagnostic = location + ? ts.createDiagnosticForNode(location, message, arg0, arg1, arg2) + : ts.createCompilerDiagnostic(message, arg0, arg1, arg2); + diagnostics.add(diagnostic); + } + function createSymbol(flags, name) { + symbolCount++; + return new Symbol(flags, name); + } + function getExcludedSymbolFlags(flags) { + var result = 0; + if (flags & 2 /* BlockScopedVariable */) + result |= 107455 /* BlockScopedVariableExcludes */; + if (flags & 1 /* FunctionScopedVariable */) + result |= 107454 /* FunctionScopedVariableExcludes */; + if (flags & 4 /* Property */) + result |= 107455 /* PropertyExcludes */; + if (flags & 8 /* EnumMember */) + result |= 107455 /* EnumMemberExcludes */; + if (flags & 16 /* Function */) + result |= 106927 /* FunctionExcludes */; + if (flags & 32 /* Class */) + result |= 899519 /* ClassExcludes */; + if (flags & 64 /* Interface */) + result |= 792960 /* InterfaceExcludes */; + if (flags & 256 /* RegularEnum */) + result |= 899327 /* RegularEnumExcludes */; + if (flags & 128 /* ConstEnum */) + result |= 899967 /* ConstEnumExcludes */; + if (flags & 512 /* ValueModule */) + result |= 106639 /* ValueModuleExcludes */; + if (flags & 8192 /* Method */) + result |= 99263 /* MethodExcludes */; + if (flags & 32768 /* GetAccessor */) + result |= 41919 /* GetAccessorExcludes */; + if (flags & 65536 /* SetAccessor */) + result |= 74687 /* SetAccessorExcludes */; + if (flags & 262144 /* TypeParameter */) + result |= 530912 /* TypeParameterExcludes */; + if (flags & 524288 /* TypeAlias */) + result |= 793056 /* TypeAliasExcludes */; + if (flags & 8388608 /* Alias */) + result |= 8388608 /* AliasExcludes */; + return result; + } + function recordMergedSymbol(target, source) { + if (!source.mergeId) + source.mergeId = nextMergeId++; + mergedSymbols[source.mergeId] = target; + } + function cloneSymbol(symbol) { + var result = createSymbol(symbol.flags | 33554432 /* Merged */, symbol.name); + result.declarations = symbol.declarations.slice(0); + result.parent = symbol.parent; + if (symbol.valueDeclaration) + result.valueDeclaration = symbol.valueDeclaration; + if (symbol.constEnumOnlyModule) + result.constEnumOnlyModule = true; + if (symbol.members) + result.members = cloneSymbolTable(symbol.members); + if (symbol.exports) + result.exports = cloneSymbolTable(symbol.exports); + recordMergedSymbol(result, symbol); + return result; + } + function mergeSymbol(target, source) { + if (!(target.flags & getExcludedSymbolFlags(source.flags))) { + if (source.flags & 512 /* ValueModule */ && target.flags & 512 /* ValueModule */ && target.constEnumOnlyModule && !source.constEnumOnlyModule) { + // reset flag when merging instantiated module into value module that has only const enums + target.constEnumOnlyModule = false; + } + target.flags |= source.flags; + if (!target.valueDeclaration && source.valueDeclaration) + target.valueDeclaration = source.valueDeclaration; + ts.forEach(source.declarations, function (node) { + target.declarations.push(node); + }); + if (source.members) { + if (!target.members) + target.members = {}; + mergeSymbolTable(target.members, source.members); + } + if (source.exports) { + if (!target.exports) + target.exports = {}; + mergeSymbolTable(target.exports, source.exports); + } + recordMergedSymbol(target, source); + } + else { + var message = target.flags & 2 /* BlockScopedVariable */ || source.flags & 2 /* BlockScopedVariable */ + ? ts.Diagnostics.Cannot_redeclare_block_scoped_variable_0 : ts.Diagnostics.Duplicate_identifier_0; + ts.forEach(source.declarations, function (node) { + error(node.name ? node.name : node, message, symbolToString(source)); + }); + ts.forEach(target.declarations, function (node) { + error(node.name ? node.name : node, message, symbolToString(source)); + }); + } + } + function cloneSymbolTable(symbolTable) { + var result = {}; + for (var id in symbolTable) { + if (ts.hasProperty(symbolTable, id)) { + result[id] = symbolTable[id]; + } + } + return result; + } + function mergeSymbolTable(target, source) { + for (var id in source) { + if (ts.hasProperty(source, id)) { + if (!ts.hasProperty(target, id)) { + target[id] = source[id]; + } + else { + var symbol = target[id]; + if (!(symbol.flags & 33554432 /* Merged */)) { + target[id] = symbol = cloneSymbol(symbol); + } + mergeSymbol(symbol, source[id]); + } + } + } + } + function getSymbolLinks(symbol) { + if (symbol.flags & 67108864 /* Transient */) + return symbol; + var id = getSymbolId(symbol); + return symbolLinks[id] || (symbolLinks[id] = {}); + } + function getNodeLinks(node) { + var nodeId = getNodeId(node); + return nodeLinks[nodeId] || (nodeLinks[nodeId] = {}); + } + function getSourceFile(node) { + return ts.getAncestor(node, 248 /* SourceFile */); + } + function isGlobalSourceFile(node) { + return node.kind === 248 /* SourceFile */ && !ts.isExternalModule(node); + } + function getSymbol(symbols, name, meaning) { + if (meaning && ts.hasProperty(symbols, name)) { + var symbol = symbols[name]; + ts.Debug.assert((symbol.flags & 16777216 /* Instantiated */) === 0, "Should never get an instantiated symbol here."); + if (symbol.flags & meaning) { + return symbol; + } + if (symbol.flags & 8388608 /* Alias */) { + var target = resolveAlias(symbol); + // Unknown symbol means an error occurred in alias resolution, treat it as positive answer to avoid cascading errors + if (target === unknownSymbol || target.flags & meaning) { + return symbol; + } + } + } + // return undefined if we can't find a symbol. + } + function isBlockScopedNameDeclaredBeforeUse(declaration, usage) { + var declarationFile = ts.getSourceFileOfNode(declaration); + var useFile = ts.getSourceFileOfNode(usage); + if (declarationFile !== useFile) { + if (modulekind || (!compilerOptions.outFile && !compilerOptions.out)) { + // nodes are in different files and order cannot be determines + return true; + } + var sourceFiles = host.getSourceFiles(); + return ts.indexOf(sourceFiles, declarationFile) <= ts.indexOf(sourceFiles, useFile); + } + if (declaration.pos <= usage.pos) { + // declaration is before usage + // still might be illegal if usage is in the initializer of the variable declaration + return declaration.kind !== 211 /* VariableDeclaration */ || + !isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage); + } + // declaration is after usage + // can be legal if usage is deferred (i.e. inside function or in initializer of instance property) + return isUsedInFunctionOrNonStaticProperty(declaration, usage); + function isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage) { + var container = ts.getEnclosingBlockScopeContainer(declaration); + if (declaration.parent.parent.kind === 193 /* VariableStatement */ || + declaration.parent.parent.kind === 199 /* ForStatement */) { + // variable statement/for statement case, + // use site should not be inside variable declaration (initializer of declaration or binding element) + return isSameScopeDescendentOf(usage, declaration, container); + } + else if (declaration.parent.parent.kind === 201 /* ForOfStatement */ || + declaration.parent.parent.kind === 200 /* ForInStatement */) { + // ForIn/ForOf case - use site should not be used in expression part + var expression = declaration.parent.parent.expression; + return isSameScopeDescendentOf(usage, expression, container); + } + } + function isUsedInFunctionOrNonStaticProperty(declaration, usage) { + var container = ts.getEnclosingBlockScopeContainer(declaration); + var current = usage; + while (current) { + if (current === container) { + return false; + } + if (ts.isFunctionLike(current)) { + return true; + } + var initializerOfNonStaticProperty = current.parent && + current.parent.kind === 141 /* PropertyDeclaration */ && + (current.parent.flags & 128 /* Static */) === 0 && + current.parent.initializer === current; + if (initializerOfNonStaticProperty) { + return true; + } + current = current.parent; + } + return false; + } + } + // Resolve a given name for a given meaning at a given location. An error is reported if the name was not found and + // the nameNotFoundMessage argument is not undefined. Returns the resolved symbol, or undefined if no symbol with + // the given name can be found. + function resolveName(location, name, meaning, nameNotFoundMessage, nameArg) { + var result; + var lastLocation; + var propertyWithInvalidInitializer; + var errorLocation = location; + var grandparent; + loop: while (location) { + // Locals of a source file are not in scope (because they get merged into the global symbol table) + if (location.locals && !isGlobalSourceFile(location)) { + if (result = getSymbol(location.locals, name, meaning)) { + // Type parameters of a function are in scope in the entire function declaration, including the parameter + // list and return type. However, local types are only in scope in the function body. + if (!(meaning & 793056 /* Type */) || + !(result.flags & (793056 /* Type */ & ~262144 /* TypeParameter */)) || + !ts.isFunctionLike(location) || + lastLocation === location.body) { + break loop; + } + result = undefined; + } + } + switch (location.kind) { + case 248 /* SourceFile */: + if (!ts.isExternalModule(location)) + break; + case 218 /* ModuleDeclaration */: + var moduleExports = getSymbolOfNode(location).exports; + if (location.kind === 248 /* SourceFile */ || + (location.kind === 218 /* ModuleDeclaration */ && location.name.kind === 9 /* StringLiteral */)) { + // It's an external module. Because of module/namespace merging, a module's exports are in scope, + // yet we never want to treat an export specifier as putting a member in scope. Therefore, + // if the name we find is purely an export specifier, it is not actually considered in scope. + // Two things to note about this: + // 1. We have to check this without calling getSymbol. The problem with calling getSymbol + // on an export specifier is that it might find the export specifier itself, and try to + // resolve it as an alias. This will cause the checker to consider the export specifier + // a circular alias reference when it might not be. + // 2. We check === SymbolFlags.Alias in order to check that the symbol is *purely* + // an alias. If we used &, we'd be throwing out symbols that have non alias aspects, + // which is not the desired behavior. + if (ts.hasProperty(moduleExports, name) && + moduleExports[name].flags === 8388608 /* Alias */ && + ts.getDeclarationOfKind(moduleExports[name], 230 /* ExportSpecifier */)) { + break; + } + result = moduleExports["default"]; + var localSymbol = ts.getLocalSymbolForExportDefault(result); + if (result && localSymbol && (result.flags & meaning) && localSymbol.name === name) { + break loop; + } + result = undefined; + } + if (result = getSymbol(moduleExports, name, meaning & 8914931 /* ModuleMember */)) { + break loop; + } + break; + case 217 /* EnumDeclaration */: + if (result = getSymbol(getSymbolOfNode(location).exports, name, meaning & 8 /* EnumMember */)) { + break loop; + } + break; + case 141 /* PropertyDeclaration */: + case 140 /* PropertySignature */: + // TypeScript 1.0 spec (April 2014): 8.4.1 + // Initializer expressions for instance member variables are evaluated in the scope + // of the class constructor body but are not permitted to reference parameters or + // local variables of the constructor. This effectively means that entities from outer scopes + // by the same name as a constructor parameter or local variable are inaccessible + // in initializer expressions for instance member variables. + if (ts.isClassLike(location.parent) && !(location.flags & 128 /* Static */)) { + var ctor = findConstructorDeclaration(location.parent); + if (ctor && ctor.locals) { + if (getSymbol(ctor.locals, name, meaning & 107455 /* Value */)) { + // Remember the property node, it will be used later to report appropriate error + propertyWithInvalidInitializer = location; + } + } + } + break; + case 214 /* ClassDeclaration */: + case 186 /* ClassExpression */: + case 215 /* InterfaceDeclaration */: + if (result = getSymbol(getSymbolOfNode(location).members, name, meaning & 793056 /* Type */)) { + if (lastLocation && lastLocation.flags & 128 /* Static */) { + // TypeScript 1.0 spec (April 2014): 3.4.1 + // The scope of a type parameter extends over the entire declaration with which the type + // parameter list is associated, with the exception of static member declarations in classes. + error(errorLocation, ts.Diagnostics.Static_members_cannot_reference_class_type_parameters); + return undefined; + } + break loop; + } + if (location.kind === 186 /* ClassExpression */ && meaning & 32 /* Class */) { + var className = location.name; + if (className && name === className.text) { + result = location.symbol; + break loop; + } + } + break; + // It is not legal to reference a class's own type parameters from a computed property name that + // belongs to the class. For example: + // + // function foo() { return '' } + // class C { // <-- Class's own type parameter T + // [foo()]() { } // <-- Reference to T from class's own computed property + // } + // + case 136 /* ComputedPropertyName */: + grandparent = location.parent.parent; + if (ts.isClassLike(grandparent) || grandparent.kind === 215 /* InterfaceDeclaration */) { + // A reference to this grandparent's type parameters would be an error + if (result = getSymbol(getSymbolOfNode(grandparent).members, name, meaning & 793056 /* Type */)) { + error(errorLocation, ts.Diagnostics.A_computed_property_name_cannot_reference_a_type_parameter_from_its_containing_type); + return undefined; + } + } + break; + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: + case 144 /* Constructor */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: + case 213 /* FunctionDeclaration */: + case 174 /* ArrowFunction */: + if (meaning & 3 /* Variable */ && name === "arguments") { + result = argumentsSymbol; + break loop; + } + break; + case 173 /* FunctionExpression */: + if (meaning & 3 /* Variable */ && name === "arguments") { + result = argumentsSymbol; + break loop; + } + if (meaning & 16 /* Function */) { + var functionName = location.name; + if (functionName && name === functionName.text) { + result = location.symbol; + break loop; + } + } + break; + case 139 /* Decorator */: + // Decorators are resolved at the class declaration. Resolving at the parameter + // or member would result in looking up locals in the method. + // + // function y() {} + // class C { + // method(@y x, y) {} // <-- decorator y should be resolved at the class declaration, not the parameter. + // } + // + if (location.parent && location.parent.kind === 138 /* Parameter */) { + location = location.parent; + } + // + // function y() {} + // class C { + // @y method(x, y) {} // <-- decorator y should be resolved at the class declaration, not the method. + // } + // + if (location.parent && ts.isClassElement(location.parent)) { + location = location.parent; + } + break; + } + lastLocation = location; + location = location.parent; + } + if (!result) { + result = getSymbol(globals, name, meaning); + } + if (!result) { + if (nameNotFoundMessage) { + error(errorLocation, nameNotFoundMessage, typeof nameArg === "string" ? nameArg : ts.declarationNameToString(nameArg)); + } + return undefined; + } + // Perform extra checks only if error reporting was requested + if (nameNotFoundMessage) { + if (propertyWithInvalidInitializer) { + // We have a match, but the reference occurred within a property initializer and the identifier also binds + // to a local variable in the constructor where the code will be emitted. + var propertyName = propertyWithInvalidInitializer.name; + error(errorLocation, ts.Diagnostics.Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor, ts.declarationNameToString(propertyName), typeof nameArg === "string" ? nameArg : ts.declarationNameToString(nameArg)); + return undefined; + } + // Only check for block-scoped variable if we are looking for the + // name with variable meaning + // For example, + // declare module foo { + // interface bar {} + // } + // let foo/*1*/: foo/*2*/.bar; + // The foo at /*1*/ and /*2*/ will share same symbol with two meaning + // block - scope variable and namespace module. However, only when we + // try to resolve name in /*1*/ which is used in variable position, + // we want to check for block- scoped + if (meaning & 2 /* BlockScopedVariable */) { + var exportOrLocalSymbol = getExportSymbolOfValueSymbolIfExported(result); + if (exportOrLocalSymbol.flags & 2 /* BlockScopedVariable */) { + checkResolvedBlockScopedVariable(exportOrLocalSymbol, errorLocation); + } + } + } + return result; + } + function checkResolvedBlockScopedVariable(result, errorLocation) { + ts.Debug.assert((result.flags & 2 /* BlockScopedVariable */) !== 0); + // 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 (!isBlockScopedNameDeclaredBeforeUse(ts.getAncestor(declaration, 211 /* VariableDeclaration */), errorLocation)) { + error(errorLocation, ts.Diagnostics.Block_scoped_variable_0_used_before_its_declaration, ts.declarationNameToString(declaration.name)); + } + } + /* Starting from 'initial' node walk up the parent chain until 'stopAt' node is reached. + * If at any point current node is equal to 'parent' node - return true. + * Return false if 'stopAt' node is reached or isFunctionLike(current) === true. + */ + function isSameScopeDescendentOf(initial, parent, stopAt) { + if (!parent) { + return false; + } + for (var current = initial; current && current !== stopAt && !ts.isFunctionLike(current); current = current.parent) { + if (current === parent) { + return true; + } + } + return false; + } + function getAnyImportSyntax(node) { + if (ts.isAliasSymbolDeclaration(node)) { + if (node.kind === 221 /* ImportEqualsDeclaration */) { + return node; + } + while (node && node.kind !== 222 /* ImportDeclaration */) { + node = node.parent; + } + return node; + } + } + function getDeclarationOfAliasSymbol(symbol) { + return ts.forEach(symbol.declarations, function (d) { return ts.isAliasSymbolDeclaration(d) ? d : undefined; }); + } + function getTargetOfImportEqualsDeclaration(node) { + if (node.moduleReference.kind === 232 /* ExternalModuleReference */) { + return resolveExternalModuleSymbol(resolveExternalModuleName(node, ts.getExternalModuleImportEqualsDeclarationExpression(node))); + } + return getSymbolOfPartOfRightHandSideOfImportEquals(node.moduleReference, node); + } + function getTargetOfImportClause(node) { + var moduleSymbol = resolveExternalModuleName(node, node.parent.moduleSpecifier); + if (moduleSymbol) { + var exportDefaultSymbol = resolveSymbol(moduleSymbol.exports["default"]); + if (!exportDefaultSymbol) { + error(node.name, ts.Diagnostics.Module_0_has_no_default_export, symbolToString(moduleSymbol)); + } + return exportDefaultSymbol; + } + } + function getTargetOfNamespaceImport(node) { + var moduleSpecifier = node.parent.parent.moduleSpecifier; + return resolveESModuleSymbol(resolveExternalModuleName(node, moduleSpecifier), moduleSpecifier); + } + function getMemberOfModuleVariable(moduleSymbol, name) { + if (moduleSymbol.flags & 3 /* Variable */) { + var typeAnnotation = moduleSymbol.valueDeclaration.type; + if (typeAnnotation) { + return getPropertyOfType(getTypeFromTypeNode(typeAnnotation), name); + } + } + } + // This function creates a synthetic symbol that combines the value side of one symbol with the + // type/namespace side of another symbol. Consider this example: + // + // declare module graphics { + // interface Point { + // x: number; + // y: number; + // } + // } + // declare var graphics: { + // Point: new (x: number, y: number) => graphics.Point; + // } + // declare module "graphics" { + // export = graphics; + // } + // + // An 'import { Point } from "graphics"' needs to create a symbol that combines the value side 'Point' + // property with the type/namespace side interface 'Point'. + function combineValueAndTypeSymbols(valueSymbol, typeSymbol) { + if (valueSymbol.flags & (793056 /* Type */ | 1536 /* Namespace */)) { + return valueSymbol; + } + var result = createSymbol(valueSymbol.flags | typeSymbol.flags, valueSymbol.name); + result.declarations = ts.concatenate(valueSymbol.declarations, typeSymbol.declarations); + result.parent = valueSymbol.parent || typeSymbol.parent; + if (valueSymbol.valueDeclaration) + result.valueDeclaration = valueSymbol.valueDeclaration; + if (typeSymbol.members) + result.members = typeSymbol.members; + if (valueSymbol.exports) + result.exports = valueSymbol.exports; + return result; + } + function getExportOfModule(symbol, name) { + if (symbol.flags & 1536 /* Module */) { + var exports = getExportsOfSymbol(symbol); + if (ts.hasProperty(exports, name)) { + return resolveSymbol(exports[name]); + } + } + } + function getPropertyOfVariable(symbol, name) { + if (symbol.flags & 3 /* Variable */) { + var typeAnnotation = symbol.valueDeclaration.type; + if (typeAnnotation) { + return resolveSymbol(getPropertyOfType(getTypeFromTypeNode(typeAnnotation), name)); + } + } + } + function getExternalModuleMember(node, specifier) { + var moduleSymbol = resolveExternalModuleName(node, node.moduleSpecifier); + var targetSymbol = resolveESModuleSymbol(moduleSymbol, node.moduleSpecifier); + if (targetSymbol) { + var name_9 = specifier.propertyName || specifier.name; + if (name_9.text) { + var symbolFromModule = getExportOfModule(targetSymbol, name_9.text); + var symbolFromVariable = getPropertyOfVariable(targetSymbol, name_9.text); + var symbol = symbolFromModule && symbolFromVariable ? + combineValueAndTypeSymbols(symbolFromVariable, symbolFromModule) : + symbolFromModule || symbolFromVariable; + if (!symbol) { + error(name_9, ts.Diagnostics.Module_0_has_no_exported_member_1, getFullyQualifiedName(moduleSymbol), ts.declarationNameToString(name_9)); + } + return symbol; + } + } + } + function getTargetOfImportSpecifier(node) { + return getExternalModuleMember(node.parent.parent.parent, node); + } + function getTargetOfExportSpecifier(node) { + return node.parent.parent.moduleSpecifier ? + getExternalModuleMember(node.parent.parent, node) : + resolveEntityName(node.propertyName || node.name, 107455 /* Value */ | 793056 /* Type */ | 1536 /* Namespace */); + } + function getTargetOfExportAssignment(node) { + return resolveEntityName(node.expression, 107455 /* Value */ | 793056 /* Type */ | 1536 /* Namespace */); + } + function getTargetOfAliasDeclaration(node) { + switch (node.kind) { + case 221 /* ImportEqualsDeclaration */: + return getTargetOfImportEqualsDeclaration(node); + case 223 /* ImportClause */: + return getTargetOfImportClause(node); + case 224 /* NamespaceImport */: + return getTargetOfNamespaceImport(node); + case 226 /* ImportSpecifier */: + return getTargetOfImportSpecifier(node); + case 230 /* ExportSpecifier */: + return getTargetOfExportSpecifier(node); + case 227 /* ExportAssignment */: + return getTargetOfExportAssignment(node); + } + } + function resolveSymbol(symbol) { + return symbol && symbol.flags & 8388608 /* Alias */ && !(symbol.flags & (107455 /* Value */ | 793056 /* Type */ | 1536 /* Namespace */)) ? resolveAlias(symbol) : symbol; + } + function resolveAlias(symbol) { + ts.Debug.assert((symbol.flags & 8388608 /* Alias */) !== 0, "Should only get Alias here."); + var links = getSymbolLinks(symbol); + if (!links.target) { + links.target = resolvingSymbol; + var node = getDeclarationOfAliasSymbol(symbol); + var target = getTargetOfAliasDeclaration(node); + if (links.target === resolvingSymbol) { + links.target = target || unknownSymbol; + } + else { + error(node, ts.Diagnostics.Circular_definition_of_import_alias_0, symbolToString(symbol)); + } + } + else if (links.target === resolvingSymbol) { + links.target = unknownSymbol; + } + return links.target; + } + function markExportAsReferenced(node) { + var symbol = getSymbolOfNode(node); + var target = resolveAlias(symbol); + if (target) { + var markAlias = (target === unknownSymbol && compilerOptions.isolatedModules) || + (target !== unknownSymbol && (target.flags & 107455 /* Value */) && !isConstEnumOrConstEnumOnlyModule(target)); + if (markAlias) { + markAliasSymbolAsReferenced(symbol); + } + } + } + // When an alias symbol is referenced, we need to mark the entity it references as referenced and in turn repeat that until + // we reach a non-alias or an exported entity (which is always considered referenced). We do this by checking the target of + // the alias as an expression (which recursively takes us back here if the target references another alias). + function markAliasSymbolAsReferenced(symbol) { + var links = getSymbolLinks(symbol); + if (!links.referenced) { + links.referenced = true; + var node = getDeclarationOfAliasSymbol(symbol); + if (node.kind === 227 /* ExportAssignment */) { + // export default + checkExpressionCached(node.expression); + } + else if (node.kind === 230 /* ExportSpecifier */) { + // export { } or export { as foo } + checkExpressionCached(node.propertyName || node.name); + } + else if (ts.isInternalModuleImportEqualsDeclaration(node)) { + // import foo = + checkExpressionCached(node.moduleReference); + } + } + } + // This function is only for imports with entity names + function getSymbolOfPartOfRightHandSideOfImportEquals(entityName, importDeclaration) { + if (!importDeclaration) { + importDeclaration = ts.getAncestor(entityName, 221 /* ImportEqualsDeclaration */); + ts.Debug.assert(importDeclaration !== undefined); + } + // There are three things we might try to look for. In the following examples, + // 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)) { + entityName = entityName.parent; + } + // Check for case 1 and 3 in the above example + if (entityName.kind === 69 /* Identifier */ || entityName.parent.kind === 135 /* QualifiedName */) { + return resolveEntityName(entityName, 1536 /* Namespace */); + } + else { + // Case 2 in above example + // entityName.kind could be a QualifiedName or a Missing identifier + ts.Debug.assert(entityName.parent.kind === 221 /* ImportEqualsDeclaration */); + return resolveEntityName(entityName, 107455 /* Value */ | 793056 /* Type */ | 1536 /* Namespace */); + } + } + function getFullyQualifiedName(symbol) { + return symbol.parent ? getFullyQualifiedName(symbol.parent) + "." + symbolToString(symbol) : symbolToString(symbol); + } + // Resolves a qualified name and any involved aliases + function resolveEntityName(name, meaning, ignoreErrors) { + if (ts.nodeIsMissing(name)) { + return undefined; + } + var symbol; + if (name.kind === 69 /* Identifier */) { + var message = meaning === 1536 /* Namespace */ ? ts.Diagnostics.Cannot_find_namespace_0 : ts.Diagnostics.Cannot_find_name_0; + symbol = resolveName(name, name.text, meaning, ignoreErrors ? undefined : message, name); + if (!symbol) { + return undefined; + } + } + else if (name.kind === 135 /* QualifiedName */ || name.kind === 166 /* PropertyAccessExpression */) { + var left = name.kind === 135 /* QualifiedName */ ? name.left : name.expression; + var right = name.kind === 135 /* QualifiedName */ ? name.right : name.name; + var namespace = resolveEntityName(left, 1536 /* Namespace */, ignoreErrors); + if (!namespace || namespace === unknownSymbol || ts.nodeIsMissing(right)) { + return undefined; + } + symbol = getSymbol(getExportsOfSymbol(namespace), right.text, meaning); + if (!symbol) { + if (!ignoreErrors) { + error(right, ts.Diagnostics.Module_0_has_no_exported_member_1, getFullyQualifiedName(namespace), ts.declarationNameToString(right)); + } + return undefined; + } + } + else { + ts.Debug.fail("Unknown entity name kind."); + } + ts.Debug.assert((symbol.flags & 16777216 /* Instantiated */) === 0, "Should never get an instantiated symbol here."); + return symbol.flags & meaning ? symbol : resolveAlias(symbol); + } + function resolveExternalModuleName(location, moduleReferenceExpression) { + if (moduleReferenceExpression.kind !== 9 /* StringLiteral */) { + return; + } + var moduleReferenceLiteral = moduleReferenceExpression; + var searchPath = ts.getDirectoryPath(getSourceFile(location).fileName); + // Module names are escaped in our symbol table. However, string literal values aren't. + // Escape the name in the "require(...)" clause to ensure we find the right symbol. + var moduleName = ts.escapeIdentifier(moduleReferenceLiteral.text); + if (moduleName === undefined) { + return; + } + var isRelative = ts.isExternalModuleNameRelative(moduleName); + if (!isRelative) { + var symbol = getSymbol(globals, "\"" + moduleName + "\"", 512 /* ValueModule */); + if (symbol) { + return symbol; + } + } + var resolvedModule = ts.getResolvedModule(getSourceFile(location), moduleReferenceLiteral.text); + var sourceFile = resolvedModule && host.getSourceFile(resolvedModule.resolvedFileName); + if (sourceFile) { + if (sourceFile.symbol) { + return sourceFile.symbol; + } + error(moduleReferenceLiteral, ts.Diagnostics.File_0_is_not_a_module, sourceFile.fileName); + return; + } + error(moduleReferenceLiteral, ts.Diagnostics.Cannot_find_module_0, moduleName); + } + // An external module with an 'export =' declaration resolves to the target of the 'export =' declaration, + // and an external module with no 'export =' declaration resolves to the module itself. + function resolveExternalModuleSymbol(moduleSymbol) { + return moduleSymbol && resolveSymbol(moduleSymbol.exports["export="]) || moduleSymbol; + } + // An external module with an 'export =' declaration may be referenced as an ES6 module provided the 'export =' + // references a symbol that is at least declared as a module or a variable. The target of the 'export =' may + // combine other declarations with the module or variable (e.g. a class/module, function/module, interface/variable). + function resolveESModuleSymbol(moduleSymbol, moduleReferenceExpression) { + var symbol = resolveExternalModuleSymbol(moduleSymbol); + if (symbol && !(symbol.flags & (1536 /* Module */ | 3 /* Variable */))) { + error(moduleReferenceExpression, ts.Diagnostics.Module_0_resolves_to_a_non_module_entity_and_cannot_be_imported_using_this_construct, symbolToString(moduleSymbol)); + symbol = undefined; + } + return symbol; + } + function getExportAssignmentSymbol(moduleSymbol) { + return moduleSymbol.exports["export="]; + } + function getExportsOfModuleAsArray(moduleSymbol) { + return symbolsToArray(getExportsOfModule(moduleSymbol)); + } + function getExportsOfSymbol(symbol) { + return symbol.flags & 1536 /* Module */ ? getExportsOfModule(symbol) : symbol.exports || emptySymbols; + } + function getExportsOfModule(moduleSymbol) { + var links = getSymbolLinks(moduleSymbol); + return links.resolvedExports || (links.resolvedExports = getExportsForModule(moduleSymbol)); + } + function extendExportSymbols(target, source) { + for (var id in source) { + if (id !== "default" && !ts.hasProperty(target, id)) { + target[id] = source[id]; + } + } + } + function getExportsForModule(moduleSymbol) { + var result; + var visitedSymbols = []; + visit(moduleSymbol); + return result || 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. + function visit(symbol) { + if (symbol && symbol.flags & 1952 /* HasExports */ && !ts.contains(visitedSymbols, symbol)) { + visitedSymbols.push(symbol); + if (symbol !== moduleSymbol) { + if (!result) { + result = cloneSymbolTable(moduleSymbol.exports); + } + extendExportSymbols(result, symbol.exports); + } + // All export * declarations are collected in an __export symbol by the binder + var exportStars = symbol.exports["__export"]; + if (exportStars) { + for (var _i = 0, _a = exportStars.declarations; _i < _a.length; _i++) { + var node = _a[_i]; + visit(resolveExternalModuleName(node, node.moduleSpecifier)); + } + } + } + } + } + function getMergedSymbol(symbol) { + var merged; + return symbol && symbol.mergeId && (merged = mergedSymbols[symbol.mergeId]) ? merged : symbol; + } + function getSymbolOfNode(node) { + return getMergedSymbol(node.symbol); + } + function getParentOfSymbol(symbol) { + return getMergedSymbol(symbol.parent); + } + function getExportSymbolOfValueSymbolIfExported(symbol) { + return symbol && (symbol.flags & 1048576 /* ExportValue */) !== 0 + ? getMergedSymbol(symbol.exportSymbol) + : symbol; + } + function symbolIsValue(symbol) { + // If it is an instantiated symbol, then it is a value if the symbol it is an + // instantiation of is a value. + if (symbol.flags & 16777216 /* Instantiated */) { + return symbolIsValue(getSymbolLinks(symbol).target); + } + // If the symbol has the value flag, it is trivially a value. + if (symbol.flags & 107455 /* Value */) { + return true; + } + // If it is an alias, then it is a value if the symbol it resolves to is a value. + if (symbol.flags & 8388608 /* Alias */) { + return (resolveAlias(symbol).flags & 107455 /* Value */) !== 0; + } + return false; + } + function findConstructorDeclaration(node) { + var members = node.members; + for (var _i = 0; _i < members.length; _i++) { + var member = members[_i]; + if (member.kind === 144 /* Constructor */ && ts.nodeIsPresent(member.body)) { + return member; + } + } + } + function createType(flags) { + var result = new Type(checker, flags); + result.id = typeCount++; + return result; + } + function createIntrinsicType(kind, intrinsicName) { + var type = createType(kind); + type.intrinsicName = intrinsicName; + return type; + } + function createObjectType(kind, symbol) { + var type = createType(kind); + type.symbol = symbol; + return type; + } + // A reserved member name starts with two underscores, but the third character cannot be an underscore + // or the @ symbol. A third underscore indicates an escaped form of an identifer that started + // with at least two underscores. The @ character indicates that the name is denoted by a well known ES + // Symbol instance. + function isReservedMemberName(name) { + return name.charCodeAt(0) === 95 /* _ */ && + name.charCodeAt(1) === 95 /* _ */ && + name.charCodeAt(2) !== 95 /* _ */ && + name.charCodeAt(2) !== 64 /* at */; + } + function getNamedMembers(members) { + var result; + for (var id in members) { + if (ts.hasProperty(members, id)) { + if (!isReservedMemberName(id)) { + if (!result) + result = []; + var symbol = members[id]; + if (symbolIsValue(symbol)) { + result.push(symbol); + } + } + } + } + return result || emptyArray; + } + function setObjectTypeMembers(type, members, callSignatures, constructSignatures, stringIndexType, numberIndexType) { + type.members = members; + type.properties = getNamedMembers(members); + type.callSignatures = callSignatures; + type.constructSignatures = constructSignatures; + if (stringIndexType) + type.stringIndexType = stringIndexType; + if (numberIndexType) + type.numberIndexType = numberIndexType; + return type; + } + function createAnonymousType(symbol, members, callSignatures, constructSignatures, stringIndexType, numberIndexType) { + return setObjectTypeMembers(createObjectType(65536 /* Anonymous */, symbol), members, callSignatures, constructSignatures, stringIndexType, numberIndexType); + } + function forEachSymbolTableInScope(enclosingDeclaration, callback) { + var result; + for (var location_1 = enclosingDeclaration; location_1; location_1 = location_1.parent) { + // Locals of a source file are not in scope (because they get merged into the global symbol table) + if (location_1.locals && !isGlobalSourceFile(location_1)) { + if (result = callback(location_1.locals)) { + return result; + } + } + switch (location_1.kind) { + case 248 /* SourceFile */: + if (!ts.isExternalModule(location_1)) { + break; + } + case 218 /* ModuleDeclaration */: + if (result = callback(getSymbolOfNode(location_1).exports)) { + return result; + } + break; + case 214 /* ClassDeclaration */: + case 215 /* InterfaceDeclaration */: + if (result = callback(getSymbolOfNode(location_1).members)) { + return result; + } + break; + } + } + return callback(globals); + } + function getQualifiedLeftMeaning(rightMeaning) { + // If we are looking in value space, the parent meaning is value, other wise it is namespace + return rightMeaning === 107455 /* Value */ ? 107455 /* Value */ : 1536 /* Namespace */; + } + function getAccessibleSymbolChain(symbol, enclosingDeclaration, meaning, useOnlyExternalAliasing) { + function getAccessibleSymbolChainFromSymbolTable(symbols) { + function canQualifySymbol(symbolFromSymbolTable, meaning) { + // If the symbol is equivalent and doesn't need further qualification, this symbol is accessible + if (!needsQualification(symbolFromSymbolTable, enclosingDeclaration, meaning)) { + return true; + } + // If symbol needs qualification, make sure that parent is accessible, if it is then this symbol is accessible too + var accessibleParent = getAccessibleSymbolChain(symbolFromSymbolTable.parent, enclosingDeclaration, getQualifiedLeftMeaning(meaning), useOnlyExternalAliasing); + return !!accessibleParent; + } + function isAccessible(symbolFromSymbolTable, resolvedAliasSymbol) { + if (symbol === (resolvedAliasSymbol || symbolFromSymbolTable)) { + // if the symbolFromSymbolTable is not external module (it could be if it was determined as ambient external module and would be in globals table) + // and if symbolfrom symbolTable or alias resolution matches the symbol, + // check the symbol can be qualified, it is only then this symbol is accessible + return !ts.forEach(symbolFromSymbolTable.declarations, hasExternalModuleSymbol) && + canQualifySymbol(symbolFromSymbolTable, meaning); + } + } + // If symbol is directly available by its name in the symbol table + if (isAccessible(ts.lookUp(symbols, symbol.name))) { + return [symbol]; + } + // Check if symbol is any of the alias + return ts.forEachValue(symbols, function (symbolFromSymbolTable) { + if (symbolFromSymbolTable.flags & 8388608 /* Alias */ + && symbolFromSymbolTable.name !== "export=" + && !ts.getDeclarationOfKind(symbolFromSymbolTable, 230 /* ExportSpecifier */)) { + if (!useOnlyExternalAliasing || + // Is this external alias, then use it to name + ts.forEach(symbolFromSymbolTable.declarations, ts.isExternalModuleImportEqualsDeclaration)) { + var resolvedImportedSymbol = resolveAlias(symbolFromSymbolTable); + if (isAccessible(symbolFromSymbolTable, resolveAlias(symbolFromSymbolTable))) { + return [symbolFromSymbolTable]; + } + // Look in the exported members, if we can find accessibleSymbolChain, symbol is accessible using this chain + // but only if the symbolFromSymbolTable can be qualified + var accessibleSymbolsFromExports = resolvedImportedSymbol.exports ? getAccessibleSymbolChainFromSymbolTable(resolvedImportedSymbol.exports) : undefined; + if (accessibleSymbolsFromExports && canQualifySymbol(symbolFromSymbolTable, getQualifiedLeftMeaning(meaning))) { + return [symbolFromSymbolTable].concat(accessibleSymbolsFromExports); + } + } + } + }); + } + if (symbol) { + return forEachSymbolTableInScope(enclosingDeclaration, getAccessibleSymbolChainFromSymbolTable); + } + } + function needsQualification(symbol, enclosingDeclaration, meaning) { + var qualify = false; + forEachSymbolTableInScope(enclosingDeclaration, function (symbolTable) { + // If symbol of this name is not available in the symbol table we are ok + if (!ts.hasProperty(symbolTable, symbol.name)) { + // Continue to the next symbol table + return false; + } + // If the symbol with this name is present it should refer to the symbol + var symbolFromSymbolTable = symbolTable[symbol.name]; + if (symbolFromSymbolTable === symbol) { + // No need to qualify + return true; + } + // Qualify if the symbol from symbol table has same meaning as expected + symbolFromSymbolTable = (symbolFromSymbolTable.flags & 8388608 /* Alias */ && !ts.getDeclarationOfKind(symbolFromSymbolTable, 230 /* ExportSpecifier */)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; + if (symbolFromSymbolTable.flags & meaning) { + qualify = true; + return true; + } + // Continue to the next symbol table + return false; + }); + return qualify; + } + function isSymbolAccessible(symbol, enclosingDeclaration, meaning) { + if (symbol && enclosingDeclaration && !(symbol.flags & 262144 /* TypeParameter */)) { + var initialSymbol = symbol; + var meaningToLook = meaning; + while (symbol) { + // Symbol is accessible if it by itself is accessible + var accessibleSymbolChain = getAccessibleSymbolChain(symbol, enclosingDeclaration, meaningToLook, /*useOnlyExternalAliasing*/ false); + if (accessibleSymbolChain) { + var hasAccessibleDeclarations = hasVisibleDeclarations(accessibleSymbolChain[0]); + if (!hasAccessibleDeclarations) { + return { + accessibility: 1 /* NotAccessible */, + errorSymbolName: symbolToString(initialSymbol, enclosingDeclaration, meaning), + errorModuleName: symbol !== initialSymbol ? symbolToString(symbol, enclosingDeclaration, 1536 /* Namespace */) : undefined + }; + } + return hasAccessibleDeclarations; + } + // If we haven't got the accessible symbol, it doesn't mean the symbol is actually inaccessible. + // It could be a qualified symbol and hence verify the path + // e.g.: + // module m { + // export class c { + // } + // } + // let x: typeof m.c + // In the above example when we start with checking if typeof m.c symbol is accessible, + // we are going to see if c can be accessed in scope directly. + // But it can't, hence the accessible is going to be undefined, but that doesn't mean m.c is inaccessible + // It is accessible if the parent m is accessible because then m.c can be accessed through qualification + meaningToLook = getQualifiedLeftMeaning(meaning); + symbol = getParentOfSymbol(symbol); + } + // This could be a symbol that is not exported in the external module + // or it could be a symbol from different external module that is not aliased and hence cannot be named + var symbolExternalModule = ts.forEach(initialSymbol.declarations, getExternalModuleContainer); + if (symbolExternalModule) { + var enclosingExternalModule = getExternalModuleContainer(enclosingDeclaration); + if (symbolExternalModule !== enclosingExternalModule) { + // name from different external module that is not visible + return { + accessibility: 2 /* CannotBeNamed */, + errorSymbolName: symbolToString(initialSymbol, enclosingDeclaration, meaning), + errorModuleName: symbolToString(symbolExternalModule) + }; + } + } + // Just a local name that is not accessible + return { + accessibility: 1 /* NotAccessible */, + errorSymbolName: symbolToString(initialSymbol, enclosingDeclaration, meaning) + }; + } + return { accessibility: 0 /* Accessible */ }; + function getExternalModuleContainer(declaration) { + for (; declaration; declaration = declaration.parent) { + if (hasExternalModuleSymbol(declaration)) { + return getSymbolOfNode(declaration); + } + } + } + } + function hasExternalModuleSymbol(declaration) { + return (declaration.kind === 218 /* ModuleDeclaration */ && declaration.name.kind === 9 /* StringLiteral */) || + (declaration.kind === 248 /* SourceFile */ && ts.isExternalModule(declaration)); + } + function hasVisibleDeclarations(symbol) { + var aliasesToMakeVisible; + if (ts.forEach(symbol.declarations, function (declaration) { return !getIsDeclarationVisible(declaration); })) { + return undefined; + } + return { accessibility: 0 /* Accessible */, aliasesToMakeVisible: aliasesToMakeVisible }; + function getIsDeclarationVisible(declaration) { + if (!isDeclarationVisible(declaration)) { + // Mark the unexported alias as visible if its parent is visible + // because these kind of aliases can be used to name types in declaration file + var anyImportSyntax = getAnyImportSyntax(declaration); + if (anyImportSyntax && + !(anyImportSyntax.flags & 1 /* Export */) && + isDeclarationVisible(anyImportSyntax.parent)) { + getNodeLinks(declaration).isVisible = true; + if (aliasesToMakeVisible) { + if (!ts.contains(aliasesToMakeVisible, anyImportSyntax)) { + aliasesToMakeVisible.push(anyImportSyntax); + } + } + else { + aliasesToMakeVisible = [anyImportSyntax]; + } + return true; + } + // Declaration is not visible + return false; + } + return true; + } + } + function isEntityNameVisible(entityName, enclosingDeclaration) { + // get symbol of the first identifier of the entityName + var meaning; + if (entityName.parent.kind === 154 /* TypeQuery */) { + // Typeof value + meaning = 107455 /* Value */ | 1048576 /* ExportValue */; + } + else if (entityName.kind === 135 /* QualifiedName */ || entityName.kind === 166 /* PropertyAccessExpression */ || + entityName.parent.kind === 221 /* ImportEqualsDeclaration */) { + // Left identifier from type reference or TypeAlias + // Entity name of the import declaration + meaning = 1536 /* Namespace */; + } + else { + // Type Reference or TypeAlias entity = Identifier + meaning = 793056 /* Type */; + } + var firstIdentifier = getFirstIdentifier(entityName); + var symbol = resolveName(enclosingDeclaration, firstIdentifier.text, meaning, /*nodeNotFoundErrorMessage*/ undefined, /*nameArg*/ undefined); + // Verify if the symbol is accessible + return (symbol && hasVisibleDeclarations(symbol)) || { + accessibility: 1 /* NotAccessible */, + errorSymbolName: ts.getTextOfNode(firstIdentifier), + errorNode: firstIdentifier + }; + } + function writeKeyword(writer, kind) { + writer.writeKeyword(ts.tokenToString(kind)); + } + function writePunctuation(writer, kind) { + writer.writePunctuation(ts.tokenToString(kind)); + } + function writeSpace(writer) { + writer.writeSpace(" "); + } + function symbolToString(symbol, enclosingDeclaration, meaning) { + var writer = ts.getSingleLineStringWriter(); + getSymbolDisplayBuilder().buildSymbolDisplay(symbol, writer, enclosingDeclaration, meaning); + var result = writer.string(); + ts.releaseStringWriter(writer); + return result; + } + function signatureToString(signature, enclosingDeclaration, flags) { + var writer = ts.getSingleLineStringWriter(); + getSymbolDisplayBuilder().buildSignatureDisplay(signature, writer, enclosingDeclaration, flags); + var result = writer.string(); + ts.releaseStringWriter(writer); + return result; + } + function typeToString(type, enclosingDeclaration, flags) { + var writer = ts.getSingleLineStringWriter(); + getSymbolDisplayBuilder().buildTypeDisplay(type, writer, enclosingDeclaration, flags); + var result = writer.string(); + ts.releaseStringWriter(writer); + var maxLength = compilerOptions.noErrorTruncation || flags & 4 /* NoTruncation */ ? undefined : 100; + if (maxLength && result.length >= maxLength) { + result = result.substr(0, maxLength - "...".length) + "..."; + } + return result; + } + function getTypeAliasForTypeLiteral(type) { + if (type.symbol && type.symbol.flags & 2048 /* TypeLiteral */) { + var node = type.symbol.declarations[0].parent; + while (node.kind === 160 /* ParenthesizedType */) { + node = node.parent; + } + if (node.kind === 216 /* TypeAliasDeclaration */) { + return getSymbolOfNode(node); + } + } + return undefined; + } + function getSymbolDisplayBuilder() { + function getNameOfSymbol(symbol) { + if (symbol.declarations && symbol.declarations.length) { + var declaration = symbol.declarations[0]; + if (declaration.name) { + return ts.declarationNameToString(declaration.name); + } + switch (declaration.kind) { + case 186 /* ClassExpression */: + return "(Anonymous class)"; + case 173 /* FunctionExpression */: + case 174 /* ArrowFunction */: + return "(Anonymous function)"; + } + } + return symbol.name; + } + /** + * Writes only the name of the symbol out to the writer. Uses the original source text + * for the name of the symbol if it is available to match how the user inputted the name. + */ + function appendSymbolNameOnly(symbol, writer) { + writer.writeSymbol(getNameOfSymbol(symbol), symbol); + } + /** + * Enclosing declaration is optional when we don't want to get qualified name in the enclosing declaration scope + * Meaning needs to be specified if the enclosing declaration is given + */ + function buildSymbolDisplay(symbol, writer, enclosingDeclaration, meaning, flags, typeFlags) { + var parentSymbol; + function appendParentTypeArgumentsAndSymbolName(symbol) { + if (parentSymbol) { + // Write type arguments of instantiated class/interface here + if (flags & 1 /* WriteTypeParametersOrArguments */) { + if (symbol.flags & 16777216 /* Instantiated */) { + buildDisplayForTypeArgumentsAndDelimiters(getTypeParametersOfClassOrInterface(parentSymbol), symbol.mapper, writer, enclosingDeclaration); + } + else { + buildTypeParameterDisplayFromSymbol(parentSymbol, writer, enclosingDeclaration); + } + } + writePunctuation(writer, 21 /* DotToken */); + } + parentSymbol = symbol; + appendSymbolNameOnly(symbol, writer); + } + // Let the writer know we just wrote out a symbol. The declaration emitter writer uses + // this to determine if an import it has previously seen (and not written out) needs + // to be written to the file once the walk of the tree is complete. + // + // NOTE(cyrusn): This approach feels somewhat unfortunate. A simple pass over the tree + // up front (for example, during checking) could determine if we need to emit the imports + // and we could then access that data during declaration emit. + writer.trackSymbol(symbol, enclosingDeclaration, meaning); + function walkSymbol(symbol, meaning) { + if (symbol) { + var accessibleSymbolChain = getAccessibleSymbolChain(symbol, enclosingDeclaration, meaning, !!(flags & 2 /* UseOnlyExternalAliasing */)); + if (!accessibleSymbolChain || + needsQualification(accessibleSymbolChain[0], enclosingDeclaration, accessibleSymbolChain.length === 1 ? meaning : getQualifiedLeftMeaning(meaning))) { + // Go up and add our parent. + walkSymbol(getParentOfSymbol(accessibleSymbolChain ? accessibleSymbolChain[0] : symbol), getQualifiedLeftMeaning(meaning)); + } + if (accessibleSymbolChain) { + for (var _i = 0; _i < accessibleSymbolChain.length; _i++) { + var accessibleSymbol = accessibleSymbolChain[_i]; + appendParentTypeArgumentsAndSymbolName(accessibleSymbol); + } + } + else { + // If we didn't find accessible symbol chain for this symbol, break if this is external module + if (!parentSymbol && ts.forEach(symbol.declarations, hasExternalModuleSymbol)) { + return; + } + // if this is anonymous type break + if (symbol.flags & 2048 /* TypeLiteral */ || symbol.flags & 4096 /* ObjectLiteral */) { + return; + } + appendParentTypeArgumentsAndSymbolName(symbol); + } + } + } + // Get qualified name if the symbol is not a type parameter + // and there is an enclosing declaration or we specifically + // asked for it + var isTypeParameter = symbol.flags & 262144 /* TypeParameter */; + var typeFormatFlag = 128 /* UseFullyQualifiedType */ & typeFlags; + if (!isTypeParameter && (enclosingDeclaration || typeFormatFlag)) { + walkSymbol(symbol, meaning); + return; + } + return appendParentTypeArgumentsAndSymbolName(symbol); + } + function buildTypeDisplay(type, writer, enclosingDeclaration, globalFlags, symbolStack) { + var globalFlagsToPass = globalFlags & 16 /* WriteOwnNameForAnyLike */; + var inObjectTypeLiteral = false; + return writeType(type, globalFlags); + function writeType(type, flags) { + // Write undefined/null type as any + if (type.flags & 16777343 /* Intrinsic */) { + // Special handling for unknown / resolving types, they should show up as any and not unknown or __resolving + writer.writeKeyword(!(globalFlags & 16 /* WriteOwnNameForAnyLike */) && isTypeAny(type) + ? "any" + : type.intrinsicName); + } + else if (type.flags & 33554432 /* ThisType */) { + if (inObjectTypeLiteral) { + writer.reportInaccessibleThisError(); + } + writer.writeKeyword("this"); + } + else if (type.flags & 4096 /* Reference */) { + writeTypeReference(type, flags); + } + else if (type.flags & (1024 /* Class */ | 2048 /* Interface */ | 128 /* Enum */ | 512 /* TypeParameter */)) { + // The specified symbol flags need to be reinterpreted as type flags + buildSymbolDisplay(type.symbol, writer, enclosingDeclaration, 793056 /* Type */, 0 /* None */, flags); + } + else if (type.flags & 8192 /* Tuple */) { + writeTupleType(type); + } + else if (type.flags & 49152 /* UnionOrIntersection */) { + writeUnionOrIntersectionType(type, flags); + } + else if (type.flags & 65536 /* Anonymous */) { + writeAnonymousType(type, flags); + } + else if (type.flags & 256 /* StringLiteral */) { + writer.writeStringLiteral(type.text); + } + else { + // Should never get here + // { ... } + writePunctuation(writer, 15 /* OpenBraceToken */); + writeSpace(writer); + writePunctuation(writer, 22 /* DotDotDotToken */); + writeSpace(writer); + writePunctuation(writer, 16 /* CloseBraceToken */); + } + } + function writeTypeList(types, delimiter) { + for (var i = 0; i < types.length; i++) { + if (i > 0) { + if (delimiter !== 24 /* CommaToken */) { + writeSpace(writer); + } + writePunctuation(writer, delimiter); + writeSpace(writer); + } + writeType(types[i], delimiter === 24 /* CommaToken */ ? 0 /* None */ : 64 /* InElementType */); + } + } + function writeSymbolTypeReference(symbol, typeArguments, pos, end, flags) { + // Unnamed function expressions and arrow functions have reserved names that we don't want to display + if (symbol.flags & 32 /* Class */ || !isReservedMemberName(symbol.name)) { + buildSymbolDisplay(symbol, writer, enclosingDeclaration, 793056 /* Type */, 0 /* None */, flags); + } + if (pos < end) { + writePunctuation(writer, 25 /* LessThanToken */); + writeType(typeArguments[pos++], 0 /* None */); + while (pos < end) { + writePunctuation(writer, 24 /* CommaToken */); + writeSpace(writer); + writeType(typeArguments[pos++], 0 /* None */); + } + writePunctuation(writer, 27 /* 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 */); + } + else { + // Write the type reference in the format f
.g.C where A and B are type arguments + // for outer type parameters, and f and g are the respective declaring containers of those + // type parameters. + var outerTypeParameters = type.target.outerTypeParameters; + var i = 0; + if (outerTypeParameters) { + var length_1 = outerTypeParameters.length; + while (i < length_1) { + // Find group of type arguments for type parameters with the same declaring container. + var start = i; + var parent_3 = getParentSymbolOfTypeParameter(outerTypeParameters[i]); + do { + i++; + } while (i < length_1 && getParentSymbolOfTypeParameter(outerTypeParameters[i]) === parent_3); + // When type parameters are their own type arguments for the whole group (i.e. we have + // the default outer type arguments), we don't show the group. + if (!ts.rangeEquals(outerTypeParameters, typeArguments, start, i)) { + writeSymbolTypeReference(parent_3, typeArguments, start, i, flags); + writePunctuation(writer, 21 /* DotToken */); + } + } + } + var typeParameterCount = (type.target.typeParameters || emptyArray).length; + writeSymbolTypeReference(type.symbol, typeArguments, i, typeParameterCount, flags); + } + } + function writeTupleType(type) { + writePunctuation(writer, 19 /* OpenBracketToken */); + writeTypeList(type.elementTypes, 24 /* CommaToken */); + writePunctuation(writer, 20 /* CloseBracketToken */); + } + function writeUnionOrIntersectionType(type, flags) { + if (flags & 64 /* InElementType */) { + writePunctuation(writer, 17 /* OpenParenToken */); + } + writeTypeList(type.types, type.flags & 16384 /* Union */ ? 47 /* BarToken */ : 46 /* AmpersandToken */); + if (flags & 64 /* InElementType */) { + writePunctuation(writer, 18 /* CloseParenToken */); + } + } + function writeAnonymousType(type, flags) { + var symbol = type.symbol; + if (symbol) { + // Always use 'typeof T' for type of class, enum, and module objects + if (symbol.flags & (32 /* Class */ | 384 /* Enum */ | 512 /* ValueModule */)) { + writeTypeofSymbol(type, flags); + } + else if (shouldWriteTypeOfFunctionSymbol()) { + writeTypeofSymbol(type, flags); + } + else if (ts.contains(symbolStack, symbol)) { + // If type is an anonymous type literal in a type alias declaration, use type alias name + var typeAlias = getTypeAliasForTypeLiteral(type); + if (typeAlias) { + // The specified symbol flags need to be reinterpreted as type flags + buildSymbolDisplay(typeAlias, writer, enclosingDeclaration, 793056 /* Type */, 0 /* None */, flags); + } + else { + // Recursive usage, use any + writeKeyword(writer, 117 /* AnyKeyword */); + } + } + else { + // Since instantiations of the same anonymous type have the same symbol, tracking symbols instead + // of types allows us to catch circular references to instantiations of the same anonymous type + if (!symbolStack) { + symbolStack = []; + } + symbolStack.push(symbol); + writeLiteralType(type, flags); + symbolStack.pop(); + } + } + else { + // Anonymous types with no symbol are never circular + writeLiteralType(type, flags); + } + function shouldWriteTypeOfFunctionSymbol() { + var isStaticMethodSymbol = !!(symbol.flags & 8192 /* Method */ && + ts.forEach(symbol.declarations, function (declaration) { return declaration.flags & 128 /* Static */; })); + var isNonLocalFunctionSymbol = !!(symbol.flags & 16 /* Function */) && + (symbol.parent || + ts.forEach(symbol.declarations, function (declaration) { + return declaration.parent.kind === 248 /* SourceFile */ || declaration.parent.kind === 219 /* ModuleBlock */; + })); + if (isStaticMethodSymbol || isNonLocalFunctionSymbol) { + // typeof is allowed only for static/non local functions + return !!(flags & 2 /* UseTypeOfFunction */) || + (ts.contains(symbolStack, symbol)); // it is type of the symbol uses itself recursively + } + } + } + function writeTypeofSymbol(type, typeFormatFlags) { + writeKeyword(writer, 101 /* TypeOfKeyword */); + writeSpace(writer); + buildSymbolDisplay(type.symbol, writer, enclosingDeclaration, 107455 /* Value */, 0 /* None */, typeFormatFlags); + } + function getIndexerParameterName(type, indexKind, fallbackName) { + var declaration = getIndexDeclarationOfSymbol(type.symbol, indexKind); + if (!declaration) { + // declaration might not be found if indexer was added from the contextual type. + // in this case use fallback name + return fallbackName; + } + ts.Debug.assert(declaration.parameters.length !== 0); + return ts.declarationNameToString(declaration.parameters[0].name); + } + function writeLiteralType(type, flags) { + var resolved = resolveStructuredTypeMembers(type); + if (!resolved.properties.length && !resolved.stringIndexType && !resolved.numberIndexType) { + if (!resolved.callSignatures.length && !resolved.constructSignatures.length) { + writePunctuation(writer, 15 /* OpenBraceToken */); + writePunctuation(writer, 16 /* CloseBraceToken */); + return; + } + if (resolved.callSignatures.length === 1 && !resolved.constructSignatures.length) { + if (flags & 64 /* InElementType */) { + writePunctuation(writer, 17 /* OpenParenToken */); + } + buildSignatureDisplay(resolved.callSignatures[0], writer, enclosingDeclaration, globalFlagsToPass | 8 /* WriteArrowStyleSignature */, symbolStack); + if (flags & 64 /* InElementType */) { + writePunctuation(writer, 18 /* CloseParenToken */); + } + return; + } + if (resolved.constructSignatures.length === 1 && !resolved.callSignatures.length) { + if (flags & 64 /* InElementType */) { + writePunctuation(writer, 17 /* OpenParenToken */); + } + writeKeyword(writer, 92 /* NewKeyword */); + writeSpace(writer); + buildSignatureDisplay(resolved.constructSignatures[0], writer, enclosingDeclaration, globalFlagsToPass | 8 /* WriteArrowStyleSignature */, symbolStack); + if (flags & 64 /* InElementType */) { + writePunctuation(writer, 18 /* CloseParenToken */); + } + return; + } + } + var saveInObjectTypeLiteral = inObjectTypeLiteral; + inObjectTypeLiteral = true; + writePunctuation(writer, 15 /* 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, symbolStack); + writePunctuation(writer, 23 /* SemicolonToken */); + writer.writeLine(); + } + for (var _b = 0, _c = resolved.constructSignatures; _b < _c.length; _b++) { + var signature = _c[_b]; + writeKeyword(writer, 92 /* NewKeyword */); + writeSpace(writer); + buildSignatureDisplay(signature, writer, enclosingDeclaration, globalFlagsToPass, symbolStack); + writePunctuation(writer, 23 /* SemicolonToken */); + writer.writeLine(); + } + if (resolved.stringIndexType) { + // [x: string]: + writePunctuation(writer, 19 /* OpenBracketToken */); + writer.writeParameter(getIndexerParameterName(resolved, 0 /* String */, /*fallbackName*/ "x")); + writePunctuation(writer, 54 /* ColonToken */); + writeSpace(writer); + writeKeyword(writer, 130 /* StringKeyword */); + writePunctuation(writer, 20 /* CloseBracketToken */); + writePunctuation(writer, 54 /* ColonToken */); + writeSpace(writer); + writeType(resolved.stringIndexType, 0 /* None */); + writePunctuation(writer, 23 /* SemicolonToken */); + writer.writeLine(); + } + if (resolved.numberIndexType) { + // [x: number]: + writePunctuation(writer, 19 /* OpenBracketToken */); + writer.writeParameter(getIndexerParameterName(resolved, 1 /* Number */, /*fallbackName*/ "x")); + writePunctuation(writer, 54 /* ColonToken */); + writeSpace(writer); + writeKeyword(writer, 128 /* NumberKeyword */); + writePunctuation(writer, 20 /* CloseBracketToken */); + writePunctuation(writer, 54 /* ColonToken */); + writeSpace(writer); + writeType(resolved.numberIndexType, 0 /* None */); + writePunctuation(writer, 23 /* SemicolonToken */); + writer.writeLine(); + } + for (var _d = 0, _e = resolved.properties; _d < _e.length; _d++) { + var p = _e[_d]; + var t = getTypeOfSymbol(p); + if (p.flags & (16 /* Function */ | 8192 /* Method */) && !getPropertiesOfObjectType(t).length) { + var signatures = getSignaturesOfType(t, 0 /* Call */); + for (var _f = 0; _f < signatures.length; _f++) { + var signature = signatures[_f]; + buildSymbolDisplay(p, writer); + if (p.flags & 536870912 /* Optional */) { + writePunctuation(writer, 53 /* QuestionToken */); + } + buildSignatureDisplay(signature, writer, enclosingDeclaration, globalFlagsToPass, symbolStack); + writePunctuation(writer, 23 /* SemicolonToken */); + writer.writeLine(); + } + } + else { + buildSymbolDisplay(p, writer); + if (p.flags & 536870912 /* Optional */) { + writePunctuation(writer, 53 /* QuestionToken */); + } + writePunctuation(writer, 54 /* ColonToken */); + writeSpace(writer); + writeType(t, 0 /* None */); + writePunctuation(writer, 23 /* SemicolonToken */); + writer.writeLine(); + } + } + writer.decreaseIndent(); + writePunctuation(writer, 16 /* CloseBraceToken */); + inObjectTypeLiteral = saveInObjectTypeLiteral; + } + } + function buildTypeParameterDisplayFromSymbol(symbol, writer, enclosingDeclaraiton, flags) { + var targetSymbol = getTargetSymbol(symbol); + if (targetSymbol.flags & 32 /* Class */ || targetSymbol.flags & 64 /* Interface */ || targetSymbol.flags & 524288 /* TypeAlias */) { + buildDisplayForTypeParametersAndDelimiters(getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol), writer, enclosingDeclaraiton, flags); + } + } + function buildTypeParameterDisplay(tp, writer, enclosingDeclaration, flags, symbolStack) { + appendSymbolNameOnly(tp.symbol, writer); + var constraint = getConstraintOfTypeParameter(tp); + if (constraint) { + writeSpace(writer); + writeKeyword(writer, 83 /* ExtendsKeyword */); + writeSpace(writer); + buildTypeDisplay(constraint, writer, enclosingDeclaration, flags, symbolStack); + } + } + function buildParameterDisplay(p, writer, enclosingDeclaration, flags, symbolStack) { + var parameterNode = p.valueDeclaration; + if (ts.isRestParameter(parameterNode)) { + writePunctuation(writer, 22 /* DotDotDotToken */); + } + appendSymbolNameOnly(p, writer); + if (isOptionalParameter(parameterNode)) { + writePunctuation(writer, 53 /* QuestionToken */); + } + writePunctuation(writer, 54 /* ColonToken */); + writeSpace(writer); + buildTypeDisplay(getTypeOfSymbol(p), writer, enclosingDeclaration, flags, symbolStack); + } + function buildDisplayForTypeParametersAndDelimiters(typeParameters, writer, enclosingDeclaration, flags, symbolStack) { + if (typeParameters && typeParameters.length) { + writePunctuation(writer, 25 /* LessThanToken */); + for (var i = 0; i < typeParameters.length; i++) { + if (i > 0) { + writePunctuation(writer, 24 /* CommaToken */); + writeSpace(writer); + } + buildTypeParameterDisplay(typeParameters[i], writer, enclosingDeclaration, flags, symbolStack); + } + writePunctuation(writer, 27 /* GreaterThanToken */); + } + } + function buildDisplayForTypeArgumentsAndDelimiters(typeParameters, mapper, writer, enclosingDeclaration, flags, symbolStack) { + if (typeParameters && typeParameters.length) { + writePunctuation(writer, 25 /* LessThanToken */); + for (var i = 0; i < typeParameters.length; i++) { + if (i > 0) { + writePunctuation(writer, 24 /* CommaToken */); + writeSpace(writer); + } + buildTypeDisplay(mapper(typeParameters[i]), writer, enclosingDeclaration, 0 /* None */); + } + writePunctuation(writer, 27 /* GreaterThanToken */); + } + } + function buildDisplayForParametersAndDelimiters(parameters, writer, enclosingDeclaration, flags, symbolStack) { + writePunctuation(writer, 17 /* OpenParenToken */); + for (var i = 0; i < parameters.length; i++) { + if (i > 0) { + writePunctuation(writer, 24 /* CommaToken */); + writeSpace(writer); + } + buildParameterDisplay(parameters[i], writer, enclosingDeclaration, flags, symbolStack); + } + writePunctuation(writer, 18 /* CloseParenToken */); + } + function buildReturnTypeDisplay(signature, writer, enclosingDeclaration, flags, symbolStack) { + if (flags & 8 /* WriteArrowStyleSignature */) { + writeSpace(writer); + writePunctuation(writer, 34 /* EqualsGreaterThanToken */); + } + else { + writePunctuation(writer, 54 /* ColonToken */); + } + writeSpace(writer); + var returnType; + if (signature.typePredicate) { + writer.writeParameter(signature.typePredicate.parameterName); + writeSpace(writer); + writeKeyword(writer, 124 /* IsKeyword */); + writeSpace(writer); + returnType = signature.typePredicate.type; + } + else { + returnType = getReturnTypeOfSignature(signature); + } + buildTypeDisplay(returnType, writer, enclosingDeclaration, flags, symbolStack); + } + function buildSignatureDisplay(signature, writer, enclosingDeclaration, flags, symbolStack) { + if (signature.target && (flags & 32 /* WriteTypeArgumentsOfSignature */)) { + // Instantiated signature, write type arguments instead + // This is achieved by passing in the mapper separately + buildDisplayForTypeArgumentsAndDelimiters(signature.target.typeParameters, signature.mapper, writer, enclosingDeclaration); + } + else { + buildDisplayForTypeParametersAndDelimiters(signature.typeParameters, writer, enclosingDeclaration, flags, symbolStack); + } + buildDisplayForParametersAndDelimiters(signature.parameters, writer, enclosingDeclaration, flags, symbolStack); + buildReturnTypeDisplay(signature, writer, enclosingDeclaration, flags, symbolStack); + } + return _displayBuilder || (_displayBuilder = { + buildSymbolDisplay: buildSymbolDisplay, + buildTypeDisplay: buildTypeDisplay, + buildTypeParameterDisplay: buildTypeParameterDisplay, + buildParameterDisplay: buildParameterDisplay, + buildDisplayForParametersAndDelimiters: buildDisplayForParametersAndDelimiters, + buildDisplayForTypeParametersAndDelimiters: buildDisplayForTypeParametersAndDelimiters, + buildTypeParameterDisplayFromSymbol: buildTypeParameterDisplayFromSymbol, + buildSignatureDisplay: buildSignatureDisplay, + buildReturnTypeDisplay: buildReturnTypeDisplay + }); + } + function isDeclarationVisible(node) { + function getContainingExternalModule(node) { + for (; node; node = node.parent) { + if (node.kind === 218 /* ModuleDeclaration */) { + if (node.name.kind === 9 /* StringLiteral */) { + return node; + } + } + else if (node.kind === 248 /* SourceFile */) { + return ts.isExternalModule(node) ? node : undefined; + } + } + ts.Debug.fail("getContainingModule cant reach here"); + } + function isUsedInExportAssignment(node) { + // Get source File and see if it is external module and has export assigned symbol + var externalModule = getContainingExternalModule(node); + var exportAssignmentSymbol; + var resolvedExportSymbol; + if (externalModule) { + // This is export assigned symbol node + var externalModuleSymbol = getSymbolOfNode(externalModule); + exportAssignmentSymbol = getExportAssignmentSymbol(externalModuleSymbol); + var symbolOfNode = getSymbolOfNode(node); + if (isSymbolUsedInExportAssignment(symbolOfNode)) { + return true; + } + // if symbolOfNode is alias declaration, resolve the symbol declaration and check + if (symbolOfNode.flags & 8388608 /* Alias */) { + return isSymbolUsedInExportAssignment(resolveAlias(symbolOfNode)); + } + } + // Check if the symbol is used in export assignment + function isSymbolUsedInExportAssignment(symbol) { + if (exportAssignmentSymbol === symbol) { + return true; + } + if (exportAssignmentSymbol && !!(exportAssignmentSymbol.flags & 8388608 /* Alias */)) { + // if export assigned symbol is alias declaration, resolve the alias + resolvedExportSymbol = resolvedExportSymbol || resolveAlias(exportAssignmentSymbol); + if (resolvedExportSymbol === symbol) { + return true; + } + // Container of resolvedExportSymbol is visible + return ts.forEach(resolvedExportSymbol.declarations, function (current) { + while (current) { + if (current === node) { + return true; + } + current = current.parent; + } + }); + } + } + } + function determineIfDeclarationIsVisible() { + switch (node.kind) { + case 163 /* BindingElement */: + return isDeclarationVisible(node.parent.parent); + case 211 /* VariableDeclaration */: + if (ts.isBindingPattern(node.name) && + !node.name.elements.length) { + // If the binding pattern is empty, this variable declaration is not visible + return false; + } + // Otherwise fall through + case 218 /* ModuleDeclaration */: + case 214 /* ClassDeclaration */: + case 215 /* InterfaceDeclaration */: + case 216 /* TypeAliasDeclaration */: + case 213 /* FunctionDeclaration */: + case 217 /* EnumDeclaration */: + case 221 /* ImportEqualsDeclaration */: + var parent_4 = getDeclarationContainer(node); + // If the node is not exported or it is not ambient module element (except import declaration) + if (!(ts.getCombinedNodeFlags(node) & 1 /* Export */) && + !(node.kind !== 221 /* ImportEqualsDeclaration */ && parent_4.kind !== 248 /* SourceFile */ && ts.isInAmbientContext(parent_4))) { + return isGlobalSourceFile(parent_4); + } + // Exported members/ambient module elements (exception import declaration) are visible if parent is visible + return isDeclarationVisible(parent_4); + case 141 /* PropertyDeclaration */: + case 140 /* PropertySignature */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: + if (node.flags & (32 /* Private */ | 64 /* Protected */)) { + // Private/protected properties/methods are not visible + return false; + } + // Public properties/methods are visible if its parents are visible, so let it fall into next case statement + case 144 /* Constructor */: + case 148 /* ConstructSignature */: + case 147 /* CallSignature */: + case 149 /* IndexSignature */: + case 138 /* Parameter */: + case 219 /* ModuleBlock */: + case 152 /* FunctionType */: + case 153 /* ConstructorType */: + case 155 /* TypeLiteral */: + case 151 /* TypeReference */: + case 156 /* ArrayType */: + case 157 /* TupleType */: + case 158 /* UnionType */: + case 159 /* IntersectionType */: + case 160 /* ParenthesizedType */: + return isDeclarationVisible(node.parent); + // Default binding, import specifier and namespace import is visible + // only on demand so by default it is not visible + case 223 /* ImportClause */: + case 224 /* NamespaceImport */: + case 226 /* ImportSpecifier */: + return false; + // Type parameters are always visible + case 137 /* TypeParameter */: + // Source file is always visible + case 248 /* SourceFile */: + return true; + // Export assignements do not create name bindings outside the module + case 227 /* ExportAssignment */: + return false; + default: + ts.Debug.fail("isDeclarationVisible unknown: SyntaxKind: " + node.kind); + } + } + if (node) { + var links = getNodeLinks(node); + if (links.isVisible === undefined) { + links.isVisible = !!determineIfDeclarationIsVisible(); + } + return links.isVisible; + } + } + function collectLinkedAliases(node) { + var exportSymbol; + if (node.parent && node.parent.kind === 227 /* ExportAssignment */) { + exportSymbol = resolveName(node.parent, node.text, 107455 /* Value */ | 793056 /* Type */ | 1536 /* Namespace */ | 8388608 /* Alias */, ts.Diagnostics.Cannot_find_name_0, node); + } + else if (node.parent.kind === 230 /* ExportSpecifier */) { + var exportSpecifier = node.parent; + exportSymbol = exportSpecifier.parent.parent.moduleSpecifier ? + getExternalModuleMember(exportSpecifier.parent.parent, exportSpecifier) : + resolveEntityName(exportSpecifier.propertyName || exportSpecifier.name, 107455 /* Value */ | 793056 /* Type */ | 1536 /* Namespace */ | 8388608 /* Alias */); + } + var result = []; + if (exportSymbol) { + buildVisibleNodeList(exportSymbol.declarations); + } + return result; + function buildVisibleNodeList(declarations) { + ts.forEach(declarations, function (declaration) { + getNodeLinks(declaration).isVisible = true; + var resultNode = getAnyImportSyntax(declaration) || declaration; + if (!ts.contains(result, resultNode)) { + result.push(resultNode); + } + if (ts.isInternalModuleImportEqualsDeclaration(declaration)) { + // Add the referenced top container visible + var internalModuleReference = declaration.moduleReference; + var firstIdentifier = getFirstIdentifier(internalModuleReference); + var importSymbol = resolveName(declaration, firstIdentifier.text, 107455 /* Value */ | 793056 /* Type */ | 1536 /* Namespace */, ts.Diagnostics.Cannot_find_name_0, firstIdentifier); + buildVisibleNodeList(importSymbol.declarations); + } + }); + } + } + /** + * Push an entry on the type resolution stack. If an entry with the given target and the given property name + * is already on the stack, and no entries in between already have a type, then a circularity has occurred. + * In this case, the result values of the existing entry and all entries pushed after it are changed to false, + * and the value false is returned. Otherwise, the new entry is just pushed onto the stack, and true is returned. + * In order to see if the same query has already been done before, the target object and the propertyName both + * must match the one passed in. + * + * @param target The symbol, type, or signature whose type is being queried + * @param propertyName The property name that should be used to query the target for its type + */ + function pushTypeResolution(target, propertyName) { + var resolutionCycleStartIndex = findResolutionCycleStartIndex(target, propertyName); + if (resolutionCycleStartIndex >= 0) { + // A cycle was found + var length_2 = resolutionTargets.length; + for (var i = resolutionCycleStartIndex; i < length_2; i++) { + resolutionResults[i] = false; + } + return false; + } + resolutionTargets.push(target); + resolutionResults.push(true); + resolutionPropertyNames.push(propertyName); + return true; + } + function findResolutionCycleStartIndex(target, propertyName) { + for (var i = resolutionTargets.length - 1; i >= 0; i--) { + if (hasType(resolutionTargets[i], resolutionPropertyNames[i])) { + return -1; + } + if (resolutionTargets[i] === target && resolutionPropertyNames[i] === propertyName) { + return i; + } + } + return -1; + } + function hasType(target, propertyName) { + if (propertyName === 0 /* Type */) { + return getSymbolLinks(target).type; + } + if (propertyName === 2 /* DeclaredType */) { + return getSymbolLinks(target).declaredType; + } + if (propertyName === 1 /* ResolvedBaseConstructorType */) { + ts.Debug.assert(!!(target.flags & 1024 /* Class */)); + return target.resolvedBaseConstructorType; + } + if (propertyName === 3 /* ResolvedReturnType */) { + return target.resolvedReturnType; + } + ts.Debug.fail("Unhandled TypeSystemPropertyName " + propertyName); + } + // Pop an entry from the type resolution stack and return its associated result value. The result value will + // be true if no circularities were detected, or false if a circularity was found. + function popTypeResolution() { + resolutionTargets.pop(); + resolutionPropertyNames.pop(); + return resolutionResults.pop(); + } + function getDeclarationContainer(node) { + node = ts.getRootDeclaration(node); + // Parent chain: + // VaribleDeclaration -> VariableDeclarationList -> VariableStatement -> 'Declaration Container' + return node.kind === 211 /* VariableDeclaration */ ? node.parent.parent.parent : node.parent; + } + function getTypeOfPrototypeProperty(prototype) { + // 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'. + var classType = getDeclaredTypeOfSymbol(prototype.parent); + return classType.typeParameters ? createTypeReference(classType, ts.map(classType.typeParameters, function (_) { return anyType; })) : classType; + } + // Return the type of the given property in the given type, or undefined if no such property exists + function getTypeOfPropertyOfType(type, name) { + var prop = getPropertyOfType(type, name); + return prop ? getTypeOfSymbol(prop) : undefined; + } + function isTypeAny(type) { + return type && (type.flags & 1 /* Any */) !== 0; + } + // Return the type of a binding element parent. We check SymbolLinks first to see if a type has been + // assigned by contextual typing. + function getTypeForBindingElementParent(node) { + var symbol = getSymbolOfNode(node); + return symbol && getSymbolLinks(symbol).type || getTypeForVariableLikeDeclaration(node); + } + // Return the inferred type for a binding element + function getTypeForBindingElement(declaration) { + var pattern = declaration.parent; + var parentType = getTypeForBindingElementParent(pattern.parent); + // If parent has the unknown (error) type, then so does this binding element + if (parentType === unknownType) { + return unknownType; + } + // If no type was specified or inferred for parent, or if the specified or inferred type is any, + // infer from the initializer of the binding element if one is present. Otherwise, go with the + // undefined or any type of the parent. + if (!parentType || isTypeAny(parentType)) { + if (declaration.initializer) { + return checkExpressionCached(declaration.initializer); + } + return parentType; + } + var type; + if (pattern.kind === 161 /* ObjectBindingPattern */) { + // Use explicitly specified property name ({ p: xxx } form), or otherwise the implied name ({ p } form) + var name_10 = declaration.propertyName || declaration.name; + // Use type of the specified property, or otherwise, for a numeric name, the type of the numeric index signature, + // or otherwise the type of the string index signature. + type = getTypeOfPropertyOfType(parentType, name_10.text) || + isNumericLiteralName(name_10.text) && getIndexTypeOfType(parentType, 1 /* Number */) || + getIndexTypeOfType(parentType, 0 /* String */); + if (!type) { + error(name_10, ts.Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(parentType), ts.declarationNameToString(name_10)); + return unknownType; + } + } + else { + // This elementType will be used if the specific property corresponding to this index is not + // present (aka the tuple element property). This call also checks that the parentType is in + // fact an iterable or array (depending on target language). + var elementType = checkIteratedTypeOrElementType(parentType, pattern, /*allowStringInput*/ false); + if (!declaration.dotDotDotToken) { + // Use specific property type when parent is a tuple or numeric index type when parent is an array + var propName = "" + ts.indexOf(pattern.elements, declaration); + type = isTupleLikeType(parentType) + ? getTypeOfPropertyOfType(parentType, propName) + : elementType; + if (!type) { + if (isTupleType(parentType)) { + error(declaration, ts.Diagnostics.Tuple_type_0_with_length_1_cannot_be_assigned_to_tuple_with_length_2, typeToString(parentType), parentType.elementTypes.length, pattern.elements.length); + } + else { + error(declaration, ts.Diagnostics.Type_0_has_no_property_1, typeToString(parentType), propName); + } + return unknownType; + } + } + else { + // Rest element has an array type with the same element type as the parent type + type = createArrayType(elementType); + } + } + return type; + } + // Return the inferred type for a variable, parameter, or property declaration + function getTypeForVariableLikeDeclaration(declaration) { + // A variable declared in a for..in statement is always of type any + if (declaration.parent.parent.kind === 200 /* ForInStatement */) { + return anyType; + } + if (declaration.parent.parent.kind === 201 /* ForOfStatement */) { + // checkRightHandSideOfForOf will return undefined if the for-of expression type was + // missing properties/signatures required to get its iteratedType (like + // [Symbol.iterator] or next). This may be because we accessed properties from anyType, + // or it may have led to an error inside getElementTypeOfIterable. + return checkRightHandSideOfForOf(declaration.parent.parent.expression) || anyType; + } + if (ts.isBindingPattern(declaration.parent)) { + return getTypeForBindingElement(declaration); + } + // Use type from type annotation if one is present + if (declaration.type) { + return getTypeFromTypeNode(declaration.type); + } + if (declaration.kind === 138 /* Parameter */) { + var func = declaration.parent; + // For a parameter of a set accessor, use the type of the get accessor if one is present + if (func.kind === 146 /* SetAccessor */ && !ts.hasDynamicName(func)) { + var getter = ts.getDeclarationOfKind(declaration.parent.symbol, 145 /* GetAccessor */); + if (getter) { + return getReturnTypeOfSignature(getSignatureFromDeclaration(getter)); + } + } + // Use contextual parameter type if one is available + var type = getContextuallyTypedParameterType(declaration); + if (type) { + return type; + } + } + // Use the type of the initializer expression if one is present + if (declaration.initializer) { + return checkExpressionCached(declaration.initializer); + } + // If it is a short-hand property assignment, use the type of the identifier + if (declaration.kind === 246 /* ShorthandPropertyAssignment */) { + return checkIdentifier(declaration.name); + } + // If the declaration specifies a binding pattern, use the type implied by the binding pattern + if (ts.isBindingPattern(declaration.name)) { + return getTypeFromBindingPattern(declaration.name, /*includePatternInType*/ false); + } + // No type specified and nothing can be inferred + return undefined; + } + // Return the type implied by a binding pattern element. This is the type of the initializer of the element if + // one is present. Otherwise, if the element is itself a binding pattern, it is the type implied by the binding + // pattern. Otherwise, it is the type any. + function getTypeFromBindingElement(element, includePatternInType) { + if (element.initializer) { + return getWidenedType(checkExpressionCached(element.initializer)); + } + if (ts.isBindingPattern(element.name)) { + return getTypeFromBindingPattern(element.name, includePatternInType); + } + return anyType; + } + // Return the type implied by an object binding pattern + function getTypeFromObjectBindingPattern(pattern, includePatternInType) { + var members = {}; + ts.forEach(pattern.elements, function (e) { + var flags = 4 /* Property */ | 67108864 /* Transient */ | (e.initializer ? 536870912 /* Optional */ : 0); + var name = e.propertyName || e.name; + var symbol = createSymbol(flags, name.text); + symbol.type = getTypeFromBindingElement(e, includePatternInType); + symbol.bindingElement = e; + members[symbol.name] = symbol; + }); + var result = createAnonymousType(undefined, members, emptyArray, emptyArray, undefined, undefined); + if (includePatternInType) { + result.pattern = pattern; + } + return result; + } + // Return the type implied by an array binding pattern + function getTypeFromArrayBindingPattern(pattern, includePatternInType) { + var elements = pattern.elements; + if (elements.length === 0 || elements[elements.length - 1].dotDotDotToken) { + return languageVersion >= 2 /* ES6 */ ? createIterableType(anyType) : anyArrayType; + } + // If the pattern has at least one element, and no rest element, then it should imply a tuple type. + var elementTypes = ts.map(elements, function (e) { return e.kind === 187 /* OmittedExpression */ ? anyType : getTypeFromBindingElement(e, includePatternInType); }); + if (includePatternInType) { + var result = createNewTupleType(elementTypes); + result.pattern = pattern; + return result; + } + return createTupleType(elementTypes); + } + // Return the type implied by a binding pattern. This is the type implied purely by the binding pattern itself + // and without regard to its context (i.e. without regard any type annotation or initializer associated with the + // declaration in which the binding pattern is contained). For example, the implied type of [x, y] is [any, any] + // and the implied type of { x, y: z = 1 } is { x: any; y: number; }. The type implied by a binding pattern is + // used as the contextual type of an initializer associated with the binding pattern. Also, for a destructuring + // parameter with no type annotation or initializer, the type implied by the binding pattern becomes the type of + // the parameter. + function getTypeFromBindingPattern(pattern, includePatternInType) { + return pattern.kind === 161 /* ObjectBindingPattern */ + ? getTypeFromObjectBindingPattern(pattern, includePatternInType) + : getTypeFromArrayBindingPattern(pattern, includePatternInType); + } + // Return the type associated with a variable, parameter, or property declaration. In the simple case this is the type + // specified in a type annotation or inferred from an initializer. However, in the case of a destructuring declaration it + // is a bit more involved. For example: + // + // var [x, s = ""] = [1, "one"]; + // + // Here, the array literal [1, "one"] is contextually typed by the type [any, string], which is the implied type of the + // binding pattern [x, s = ""]. Because the contextual type is a tuple type, the resulting type of [1, "one"] is the + // tuple type [number, string]. Thus, the type inferred for 'x' is number and the type inferred for 's' is string. + function getWidenedTypeForVariableLikeDeclaration(declaration, reportErrors) { + var type = getTypeForVariableLikeDeclaration(declaration); + if (type) { + if (reportErrors) { + reportErrorsFromWidening(declaration, type); + } + // During a normal type check we'll never get to here with a property assignment (the check of the containing + // object literal uses a different path). We exclude widening only so that language services and type verification + // tools see the actual type. + return declaration.kind !== 245 /* PropertyAssignment */ ? getWidenedType(type) : type; + } + // Rest parameters default to type any[], other parameters default to type any + type = declaration.dotDotDotToken ? anyArrayType : anyType; + // Report implicit any errors unless this is a private property within an ambient declaration + if (reportErrors && compilerOptions.noImplicitAny) { + var root = ts.getRootDeclaration(declaration); + if (!isPrivateWithinAmbient(root) && !(root.kind === 138 /* Parameter */ && isPrivateWithinAmbient(root.parent))) { + reportImplicitAnyError(declaration, type); + } + } + return type; + } + function getTypeOfVariableOrParameterOrProperty(symbol) { + var links = getSymbolLinks(symbol); + if (!links.type) { + // Handle prototype property + if (symbol.flags & 134217728 /* Prototype */) { + return links.type = getTypeOfPrototypeProperty(symbol); + } + // Handle catch clause variables + var declaration = symbol.valueDeclaration; + if (declaration.parent.kind === 244 /* CatchClause */) { + return links.type = anyType; + } + // Handle export default expressions + if (declaration.kind === 227 /* ExportAssignment */) { + return links.type = checkExpression(declaration.expression); + } + // Handle variable, parameter or property + if (!pushTypeResolution(symbol, 0 /* Type */)) { + return unknownType; + } + var type = getWidenedTypeForVariableLikeDeclaration(declaration, /*reportErrors*/ true); + if (!popTypeResolution()) { + if (symbol.valueDeclaration.type) { + // Variable has type annotation that circularly references the variable itself + type = unknownType; + error(symbol.valueDeclaration, ts.Diagnostics._0_is_referenced_directly_or_indirectly_in_its_own_type_annotation, symbolToString(symbol)); + } + else { + // Variable has initializer that circularly references the variable itself + type = anyType; + if (compilerOptions.noImplicitAny) { + error(symbol.valueDeclaration, ts.Diagnostics._0_implicitly_has_type_any_because_it_does_not_have_a_type_annotation_and_is_referenced_directly_or_indirectly_in_its_own_initializer, symbolToString(symbol)); + } + } + } + links.type = type; + } + return links.type; + } + function getAnnotatedAccessorType(accessor) { + if (accessor) { + if (accessor.kind === 145 /* GetAccessor */) { + return accessor.type && getTypeFromTypeNode(accessor.type); + } + else { + var setterTypeAnnotation = ts.getSetAccessorTypeAnnotationNode(accessor); + return setterTypeAnnotation && getTypeFromTypeNode(setterTypeAnnotation); + } + } + return undefined; + } + function getTypeOfAccessors(symbol) { + var links = getSymbolLinks(symbol); + if (!links.type) { + if (!pushTypeResolution(symbol, 0 /* Type */)) { + return unknownType; + } + var getter = ts.getDeclarationOfKind(symbol, 145 /* GetAccessor */); + var setter = ts.getDeclarationOfKind(symbol, 146 /* SetAccessor */); + var type; + // First try to see if the user specified a return type on the get-accessor. + var getterReturnType = getAnnotatedAccessorType(getter); + if (getterReturnType) { + type = getterReturnType; + } + else { + // If the user didn't specify a return type, try to use the set-accessor's parameter type. + var setterParameterType = getAnnotatedAccessorType(setter); + if (setterParameterType) { + type = setterParameterType; + } + else { + // If there are no specified types, try to infer it from the body of the get accessor if it exists. + if (getter && getter.body) { + type = getReturnTypeFromBody(getter); + } + else { + if (compilerOptions.noImplicitAny) { + error(setter, ts.Diagnostics.Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_type_annotation, symbolToString(symbol)); + } + type = anyType; + } + } + } + if (!popTypeResolution()) { + type = anyType; + if (compilerOptions.noImplicitAny) { + var getter_1 = ts.getDeclarationOfKind(symbol, 145 /* GetAccessor */); + error(getter_1, ts.Diagnostics._0_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions, symbolToString(symbol)); + } + } + links.type = type; + } + return links.type; + } + function getTypeOfFuncClassEnumModule(symbol) { + var links = getSymbolLinks(symbol); + if (!links.type) { + links.type = createObjectType(65536 /* Anonymous */, symbol); + } + return links.type; + } + function getTypeOfEnumMember(symbol) { + var links = getSymbolLinks(symbol); + if (!links.type) { + links.type = getDeclaredTypeOfEnum(getParentOfSymbol(symbol)); + } + return links.type; + } + function getTypeOfAlias(symbol) { + var links = getSymbolLinks(symbol); + if (!links.type) { + var targetSymbol = resolveAlias(symbol); + // It only makes sense to get the type of a value symbol. If the result of resolving + // the alias is not a value, then it has no type. To get the type associated with a + // type symbol, call getDeclaredTypeOfSymbol. + // This check is important because without it, a call to getTypeOfSymbol could end + // up recursively calling getTypeOfAlias, causing a stack overflow. + links.type = targetSymbol.flags & 107455 /* Value */ + ? getTypeOfSymbol(targetSymbol) + : unknownType; + } + return links.type; + } + function getTypeOfInstantiatedSymbol(symbol) { + var links = getSymbolLinks(symbol); + if (!links.type) { + links.type = instantiateType(getTypeOfSymbol(links.target), links.mapper); + } + return links.type; + } + function getTypeOfSymbol(symbol) { + if (symbol.flags & 16777216 /* Instantiated */) { + return getTypeOfInstantiatedSymbol(symbol); + } + if (symbol.flags & (3 /* Variable */ | 4 /* Property */)) { + return getTypeOfVariableOrParameterOrProperty(symbol); + } + if (symbol.flags & (16 /* Function */ | 8192 /* Method */ | 32 /* Class */ | 384 /* Enum */ | 512 /* ValueModule */)) { + return getTypeOfFuncClassEnumModule(symbol); + } + if (symbol.flags & 8 /* EnumMember */) { + return getTypeOfEnumMember(symbol); + } + if (symbol.flags & 98304 /* Accessor */) { + return getTypeOfAccessors(symbol); + } + if (symbol.flags & 8388608 /* Alias */) { + return getTypeOfAlias(symbol); + } + return unknownType; + } + function getTargetType(type) { + return type.flags & 4096 /* Reference */ ? type.target : type; + } + function hasBaseType(type, checkBase) { + return check(type); + function check(type) { + var target = getTargetType(type); + return target === checkBase || ts.forEach(getBaseTypes(target), check); + } + } + // Appends the type parameters given by a list of declarations to a set of type parameters and returns the resulting set. + // The function allocates a new array if the input type parameter set is undefined, but otherwise it modifies the set + // in-place and returns the same array. + function appendTypeParameters(typeParameters, declarations) { + for (var _i = 0; _i < declarations.length; _i++) { + var declaration = declarations[_i]; + var tp = getDeclaredTypeOfTypeParameter(getSymbolOfNode(declaration)); + if (!typeParameters) { + typeParameters = [tp]; + } + else if (!ts.contains(typeParameters, tp)) { + typeParameters.push(tp); + } + } + return typeParameters; + } + // Appends the outer type parameters of a node to a set of type parameters and returns the resulting set. The function + // allocates a new array if the input type parameter set is undefined, but otherwise it modifies the set in-place and + // returns the same array. + function appendOuterTypeParameters(typeParameters, node) { + while (true) { + node = node.parent; + if (!node) { + return typeParameters; + } + if (node.kind === 214 /* ClassDeclaration */ || node.kind === 186 /* ClassExpression */ || + node.kind === 213 /* FunctionDeclaration */ || node.kind === 173 /* FunctionExpression */ || + node.kind === 143 /* MethodDeclaration */ || node.kind === 174 /* ArrowFunction */) { + var declarations = node.typeParameters; + if (declarations) { + return appendTypeParameters(appendOuterTypeParameters(typeParameters, node), declarations); + } + } + } + } + // 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, 215 /* InterfaceDeclaration */); + return appendOuterTypeParameters(undefined, declaration); + } + // The local type parameters are the combined set of type parameters from all declarations of the class, + // interface, or type alias. + function getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol) { + var result; + for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { + var node = _a[_i]; + if (node.kind === 215 /* InterfaceDeclaration */ || node.kind === 214 /* ClassDeclaration */ || + node.kind === 186 /* ClassExpression */ || node.kind === 216 /* TypeAliasDeclaration */) { + var declaration = node; + if (declaration.typeParameters) { + result = appendTypeParameters(result, declaration.typeParameters); + } + } + } + return result; + } + // The full set of type parameters for a generic class or interface type consists of its outer type parameters plus + // its locally declared type parameters. + function getTypeParametersOfClassOrInterface(symbol) { + return ts.concatenate(getOuterTypeParametersOfClassOrInterface(symbol), getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol)); + } + function isConstructorType(type) { + return type.flags & 80896 /* ObjectType */ && getSignaturesOfType(type, 1 /* Construct */).length > 0; + } + function getBaseTypeNodeOfClass(type) { + return ts.getClassExtendsHeritageClauseElement(type.symbol.valueDeclaration); + } + function getConstructorsForTypeArguments(type, typeArgumentNodes) { + var typeArgCount = typeArgumentNodes ? typeArgumentNodes.length : 0; + return ts.filter(getSignaturesOfType(type, 1 /* Construct */), function (sig) { return (sig.typeParameters ? sig.typeParameters.length : 0) === typeArgCount; }); + } + function getInstantiatedConstructorsForTypeArguments(type, typeArgumentNodes) { + var signatures = getConstructorsForTypeArguments(type, typeArgumentNodes); + if (typeArgumentNodes) { + var typeArguments = ts.map(typeArgumentNodes, getTypeFromTypeNode); + signatures = ts.map(signatures, function (sig) { return getSignatureInstantiation(sig, typeArguments); }); + } + return signatures; + } + // The base constructor of a class can resolve to + // undefinedType if the class has no extends clause, + // 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) { + if (!type.resolvedBaseConstructorType) { + var baseTypeNode = getBaseTypeNodeOfClass(type); + if (!baseTypeNode) { + return type.resolvedBaseConstructorType = undefinedType; + } + if (!pushTypeResolution(type, 1 /* ResolvedBaseConstructorType */)) { + return unknownType; + } + var baseConstructorType = checkExpression(baseTypeNode.expression); + if (baseConstructorType.flags & 80896 /* 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); + } + if (!popTypeResolution()) { + error(type.symbol.valueDeclaration, ts.Diagnostics._0_is_referenced_directly_or_indirectly_in_its_own_base_expression, symbolToString(type.symbol)); + return type.resolvedBaseConstructorType = unknownType; + } + if (baseConstructorType !== unknownType && baseConstructorType !== nullType && !isConstructorType(baseConstructorType)) { + error(baseTypeNode.expression, ts.Diagnostics.Type_0_is_not_a_constructor_function_type, typeToString(baseConstructorType)); + return type.resolvedBaseConstructorType = unknownType; + } + type.resolvedBaseConstructorType = baseConstructorType; + } + return type.resolvedBaseConstructorType; + } + function hasClassBaseType(type) { + return !!ts.forEach(getBaseTypes(type), function (t) { return !!(t.symbol.flags & 32 /* Class */); }); + } + function getBaseTypes(type) { + var isClass = type.symbol.flags & 32 /* Class */; + var isInterface = type.symbol.flags & 64 /* Interface */; + if (!type.resolvedBaseTypes) { + if (!isClass && !isInterface) { + ts.Debug.fail("type must be class or interface"); + } + if (isClass) { + resolveBaseTypesOfClass(type); + } + if (isInterface) { + resolveBaseTypesOfInterface(type); + } + } + return type.resolvedBaseTypes; + } + function resolveBaseTypesOfClass(type) { + type.resolvedBaseTypes = type.resolvedBaseTypes || emptyArray; + var baseContructorType = getBaseConstructorTypeOfClass(type); + if (!(baseContructorType.flags & 80896 /* ObjectType */)) { + return; + } + var baseTypeNode = getBaseTypeNodeOfClass(type); + var baseType; + if (baseContructorType.symbol && baseContructorType.symbol.flags & 32 /* Class */) { + // When base constructor type is a class we know that the constructors all have the same type parameters as the + // class and all return the instance type of the class. There is no need for further checks and we can apply the + // type arguments in the same manner as a type reference to get the same error reporting experience. + baseType = getTypeFromClassOrInterfaceReference(baseTypeNode, baseContructorType.symbol); + } + else { + // The class derives from a "class-like" constructor function, check that we have at least one construct signature + // with a matching number of type parameters and use the return type of the first instantiated signature. Elsewhere + // we check that all instantiated signatures return the same type. + var constructors = getInstantiatedConstructorsForTypeArguments(baseContructorType, baseTypeNode.typeArguments); + if (!constructors.length) { + error(baseTypeNode.expression, ts.Diagnostics.No_base_constructor_has_the_specified_number_of_type_arguments); + return; + } + baseType = getReturnTypeOfSignature(constructors[0]); + } + if (baseType === unknownType) { + return; + } + if (!(getTargetType(baseType).flags & (1024 /* Class */ | 2048 /* Interface */))) { + error(baseTypeNode.expression, ts.Diagnostics.Base_constructor_return_type_0_is_not_a_class_or_interface_type, typeToString(baseType)); + return; + } + if (type === baseType || hasBaseType(baseType, type)) { + error(type.symbol.valueDeclaration, ts.Diagnostics.Type_0_recursively_references_itself_as_a_base_type, typeToString(type, /*enclosingDeclaration*/ undefined, 1 /* WriteArrayAsGenericType */)); + return; + } + if (type.resolvedBaseTypes === emptyArray) { + type.resolvedBaseTypes = [baseType]; + } + else { + type.resolvedBaseTypes.push(baseType); + } + } + function resolveBaseTypesOfInterface(type) { + type.resolvedBaseTypes = type.resolvedBaseTypes || emptyArray; + for (var _i = 0, _a = type.symbol.declarations; _i < _a.length; _i++) { + var declaration = _a[_i]; + if (declaration.kind === 215 /* InterfaceDeclaration */ && ts.getInterfaceBaseTypeNodes(declaration)) { + for (var _b = 0, _c = ts.getInterfaceBaseTypeNodes(declaration); _b < _c.length; _b++) { + var node = _c[_b]; + var baseType = getTypeFromTypeNode(node); + if (baseType !== unknownType) { + if (getTargetType(baseType).flags & (1024 /* Class */ | 2048 /* Interface */)) { + if (type !== baseType && !hasBaseType(baseType, type)) { + if (type.resolvedBaseTypes === emptyArray) { + type.resolvedBaseTypes = [baseType]; + } + else { + type.resolvedBaseTypes.push(baseType); + } + } + else { + error(declaration, ts.Diagnostics.Type_0_recursively_references_itself_as_a_base_type, typeToString(type, /*enclosingDeclaration*/ undefined, 1 /* WriteArrayAsGenericType */)); + } + } + else { + error(node, ts.Diagnostics.An_interface_may_only_extend_a_class_or_another_interface); + } + } + } + } + } + } + // Returns true if the interface given by the symbol is free of "this" references. Specifically, the result is + // true if the interface itself contains no references to "this" in its body, if all base types are interfaces, + // and if none of the base interfaces have a "this" type. + function isIndependentInterface(symbol) { + for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { + var declaration = _a[_i]; + if (declaration.kind === 215 /* InterfaceDeclaration */) { + if (declaration.flags & 524288 /* ContainsThis */) { + return false; + } + var baseTypeNodes = ts.getInterfaceBaseTypeNodes(declaration); + if (baseTypeNodes) { + for (var _b = 0; _b < baseTypeNodes.length; _b++) { + var node = baseTypeNodes[_b]; + if (ts.isSupportedExpressionWithTypeArguments(node)) { + var baseSymbol = resolveEntityName(node.expression, 793056 /* Type */, /*ignoreErrors*/ true); + if (!baseSymbol || !(baseSymbol.flags & 64 /* Interface */) || getDeclaredTypeOfClassOrInterface(baseSymbol).thisType) { + return false; + } + } + } + } + } + } + return true; + } + function getDeclaredTypeOfClassOrInterface(symbol) { + var links = getSymbolLinks(symbol); + if (!links.declaredType) { + var kind = symbol.flags & 32 /* Class */ ? 1024 /* Class */ : 2048 /* Interface */; + var type = links.declaredType = createObjectType(kind, symbol); + var outerTypeParameters = getOuterTypeParametersOfClassOrInterface(symbol); + var localTypeParameters = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol); + // A class or interface is generic if it has type parameters or a "this" type. We always give classes a "this" type + // because it is not feasible to analyze all members to determine if the "this" type escapes the class (in particular, + // property types inferred from initializers and method return types inferred from return statements are very hard + // to exhaustively analyze). We give interfaces a "this" type if we can't definitely determine that they are free of + // "this" references. + if (outerTypeParameters || localTypeParameters || kind === 1024 /* Class */ || !isIndependentInterface(symbol)) { + type.flags |= 4096 /* Reference */; + type.typeParameters = ts.concatenate(outerTypeParameters, localTypeParameters); + type.outerTypeParameters = outerTypeParameters; + type.localTypeParameters = localTypeParameters; + type.instantiations = {}; + type.instantiations[getTypeListId(type.typeParameters)] = type; + type.target = type; + type.typeArguments = type.typeParameters; + type.thisType = createType(512 /* TypeParameter */ | 33554432 /* ThisType */); + type.thisType.symbol = symbol; + type.thisType.constraint = getTypeWithThisArgument(type); + } + } + return links.declaredType; + } + function getDeclaredTypeOfTypeAlias(symbol) { + var links = getSymbolLinks(symbol); + if (!links.declaredType) { + // Note that we use the links object as the target here because the symbol object is used as the unique + // identity for resolution of the 'type' property in SymbolLinks. + if (!pushTypeResolution(symbol, 2 /* DeclaredType */)) { + return unknownType; + } + var declaration = ts.getDeclarationOfKind(symbol, 216 /* TypeAliasDeclaration */); + var type = getTypeFromTypeNode(declaration.type); + if (popTypeResolution()) { + links.typeParameters = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol); + if (links.typeParameters) { + // Initialize the instantiation cache for generic type aliases. The declared type corresponds to + // an instantiation of the type alias with the type parameters supplied as type arguments. + links.instantiations = {}; + links.instantiations[getTypeListId(links.typeParameters)] = type; + } + } + else { + type = unknownType; + error(declaration.name, ts.Diagnostics.Type_alias_0_circularly_references_itself, symbolToString(symbol)); + } + links.declaredType = type; + } + return links.declaredType; + } + function getDeclaredTypeOfEnum(symbol) { + var links = getSymbolLinks(symbol); + if (!links.declaredType) { + var type = createType(128 /* Enum */); + type.symbol = symbol; + links.declaredType = type; + } + return links.declaredType; + } + function getDeclaredTypeOfTypeParameter(symbol) { + var links = getSymbolLinks(symbol); + if (!links.declaredType) { + var type = createType(512 /* TypeParameter */); + type.symbol = symbol; + if (!ts.getDeclarationOfKind(symbol, 137 /* TypeParameter */).constraint) { + type.constraint = noConstraintType; + } + links.declaredType = type; + } + return links.declaredType; + } + function getDeclaredTypeOfAlias(symbol) { + var links = getSymbolLinks(symbol); + if (!links.declaredType) { + links.declaredType = getDeclaredTypeOfSymbol(resolveAlias(symbol)); + } + return links.declaredType; + } + function getDeclaredTypeOfSymbol(symbol) { + ts.Debug.assert((symbol.flags & 16777216 /* Instantiated */) === 0); + if (symbol.flags & (32 /* Class */ | 64 /* Interface */)) { + return getDeclaredTypeOfClassOrInterface(symbol); + } + if (symbol.flags & 524288 /* TypeAlias */) { + return getDeclaredTypeOfTypeAlias(symbol); + } + if (symbol.flags & 384 /* Enum */) { + return getDeclaredTypeOfEnum(symbol); + } + if (symbol.flags & 262144 /* TypeParameter */) { + return getDeclaredTypeOfTypeParameter(symbol); + } + if (symbol.flags & 8388608 /* Alias */) { + return getDeclaredTypeOfAlias(symbol); + } + return unknownType; + } + // A type reference is considered independent if each type argument is considered independent. + function isIndependentTypeReference(node) { + if (node.typeArguments) { + for (var _i = 0, _a = node.typeArguments; _i < _a.length; _i++) { + var typeNode = _a[_i]; + if (!isIndependentType(typeNode)) { + return false; + } + } + } + return true; + } + // A type is considered independent if it the any, string, number, boolean, symbol, or void keyword, a string + // literal type, an array with an element type that is considered independent, or a type reference that is + // considered independent. + function isIndependentType(node) { + switch (node.kind) { + case 117 /* AnyKeyword */: + case 130 /* StringKeyword */: + case 128 /* NumberKeyword */: + case 120 /* BooleanKeyword */: + case 131 /* SymbolKeyword */: + case 103 /* VoidKeyword */: + case 9 /* StringLiteral */: + return true; + case 156 /* ArrayType */: + return isIndependentType(node.elementType); + case 151 /* TypeReference */: + return isIndependentTypeReference(node); + } + return false; + } + // A variable-like declaration is considered independent (free of this references) if it has a type annotation + // that specifies an independent type, or if it has no type annotation and no initializer (and thus of type any). + function isIndependentVariableLikeDeclaration(node) { + return node.type && isIndependentType(node.type) || !node.type && !node.initializer; + } + // A function-like declaration is considered independent (free of this references) if it has a return type + // annotation that is considered independent and if each parameter is considered independent. + function isIndependentFunctionLikeDeclaration(node) { + if (node.kind !== 144 /* Constructor */ && (!node.type || !isIndependentType(node.type))) { + return false; + } + for (var _i = 0, _a = node.parameters; _i < _a.length; _i++) { + var parameter = _a[_i]; + if (!isIndependentVariableLikeDeclaration(parameter)) { + return false; + } + } + return true; + } + // Returns true if the class or interface member given by the symbol is free of "this" references. The + // function may return false for symbols that are actually free of "this" references because it is not + // feasible to perform a complete analysis in all cases. In particular, property members with types + // inferred from their initializers and function members with inferred return types are convervatively + // assumed not to be free of "this" references. + function isIndependentMember(symbol) { + if (symbol.declarations && symbol.declarations.length === 1) { + var declaration = symbol.declarations[0]; + if (declaration) { + switch (declaration.kind) { + case 141 /* PropertyDeclaration */: + case 140 /* PropertySignature */: + return isIndependentVariableLikeDeclaration(declaration); + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: + case 144 /* Constructor */: + return isIndependentFunctionLikeDeclaration(declaration); + } + } + } + return false; + } + function createSymbolTable(symbols) { + var result = {}; + for (var _i = 0; _i < symbols.length; _i++) { + var symbol = symbols[_i]; + result[symbol.name] = symbol; + } + return result; + } + // The mappingThisOnly flag indicates that the only type parameter being mapped is "this". When the flag is true, + // we check symbols to see if we can quickly conclude they are free of "this" references, thus needing no instantiation. + function createInstantiatedSymbolTable(symbols, mapper, mappingThisOnly) { + var result = {}; + for (var _i = 0; _i < symbols.length; _i++) { + var symbol = symbols[_i]; + result[symbol.name] = mappingThisOnly && isIndependentMember(symbol) ? symbol : instantiateSymbol(symbol, mapper); + } + return result; + } + function addInheritedMembers(symbols, baseSymbols) { + for (var _i = 0; _i < baseSymbols.length; _i++) { + var s = baseSymbols[_i]; + if (!ts.hasProperty(symbols, s.name)) { + symbols[s.name] = s; + } + } + } + function addInheritedSignatures(signatures, baseSignatures) { + if (baseSignatures) { + for (var _i = 0; _i < baseSignatures.length; _i++) { + var signature = baseSignatures[_i]; + signatures.push(signature); + } + } + } + function resolveDeclaredMembers(type) { + if (!type.declaredProperties) { + var symbol = type.symbol; + type.declaredProperties = getNamedMembers(symbol.members); + type.declaredCallSignatures = getSignaturesOfSymbol(symbol.members["__call"]); + type.declaredConstructSignatures = getSignaturesOfSymbol(symbol.members["__new"]); + type.declaredStringIndexType = getIndexTypeOfSymbol(symbol, 0 /* String */); + type.declaredNumberIndexType = getIndexTypeOfSymbol(symbol, 1 /* Number */); + } + return type; + } + function getTypeWithThisArgument(type, thisArgument) { + if (type.flags & 4096 /* Reference */) { + return createTypeReference(type.target, ts.concatenate(type.typeArguments, [thisArgument || type.target.thisType])); + } + return type; + } + function resolveObjectTypeMembers(type, source, typeParameters, typeArguments) { + var mapper = identityMapper; + var members = source.symbol.members; + var callSignatures = source.declaredCallSignatures; + var constructSignatures = source.declaredConstructSignatures; + var stringIndexType = source.declaredStringIndexType; + var numberIndexType = source.declaredNumberIndexType; + if (!ts.rangeEquals(typeParameters, typeArguments, 0, typeParameters.length)) { + mapper = createTypeMapper(typeParameters, typeArguments); + members = createInstantiatedSymbolTable(source.declaredProperties, mapper, /*mappingThisOnly*/ typeParameters.length === 1); + callSignatures = instantiateList(source.declaredCallSignatures, mapper, instantiateSignature); + constructSignatures = instantiateList(source.declaredConstructSignatures, mapper, instantiateSignature); + stringIndexType = instantiateType(source.declaredStringIndexType, mapper); + numberIndexType = instantiateType(source.declaredNumberIndexType, mapper); + } + var baseTypes = getBaseTypes(source); + if (baseTypes.length) { + if (members === source.symbol.members) { + members = createSymbolTable(source.declaredProperties); + } + var thisArgument = ts.lastOrUndefined(typeArguments); + for (var _i = 0; _i < baseTypes.length; _i++) { + var baseType = baseTypes[_i]; + var instantiatedBaseType = thisArgument ? getTypeWithThisArgument(instantiateType(baseType, mapper), thisArgument) : baseType; + addInheritedMembers(members, getPropertiesOfObjectType(instantiatedBaseType)); + callSignatures = ts.concatenate(callSignatures, getSignaturesOfType(instantiatedBaseType, 0 /* Call */)); + constructSignatures = ts.concatenate(constructSignatures, getSignaturesOfType(instantiatedBaseType, 1 /* Construct */)); + stringIndexType = stringIndexType || getIndexTypeOfType(instantiatedBaseType, 0 /* String */); + numberIndexType = numberIndexType || getIndexTypeOfType(instantiatedBaseType, 1 /* Number */); + } + } + setObjectTypeMembers(type, members, callSignatures, constructSignatures, stringIndexType, numberIndexType); + } + function resolveClassOrInterfaceMembers(type) { + resolveObjectTypeMembers(type, resolveDeclaredMembers(type), emptyArray, emptyArray); + } + function resolveTypeReferenceMembers(type) { + var source = resolveDeclaredMembers(type.target); + var typeParameters = ts.concatenate(source.typeParameters, [source.thisType]); + var typeArguments = type.typeArguments && type.typeArguments.length === typeParameters.length ? + type.typeArguments : ts.concatenate(type.typeArguments, [type]); + resolveObjectTypeMembers(type, source, typeParameters, typeArguments); + } + function createSignature(declaration, typeParameters, parameters, resolvedReturnType, typePredicate, minArgumentCount, hasRestParameter, hasStringLiterals) { + var sig = new Signature(checker); + sig.declaration = declaration; + sig.typeParameters = typeParameters; + sig.parameters = parameters; + sig.resolvedReturnType = resolvedReturnType; + sig.typePredicate = typePredicate; + sig.minArgumentCount = minArgumentCount; + sig.hasRestParameter = hasRestParameter; + sig.hasStringLiterals = hasStringLiterals; + return sig; + } + function cloneSignature(sig) { + return createSignature(sig.declaration, sig.typeParameters, sig.parameters, sig.resolvedReturnType, sig.typePredicate, sig.minArgumentCount, sig.hasRestParameter, sig.hasStringLiterals); + } + function getDefaultConstructSignatures(classType) { + if (!hasClassBaseType(classType)) { + return [createSignature(undefined, classType.localTypeParameters, emptyArray, classType, undefined, 0, false, false)]; + } + var baseConstructorType = getBaseConstructorTypeOfClass(classType); + var baseSignatures = getSignaturesOfType(baseConstructorType, 1 /* Construct */); + var baseTypeNode = getBaseTypeNodeOfClass(classType); + var typeArguments = ts.map(baseTypeNode.typeArguments, getTypeFromTypeNode); + var typeArgCount = typeArguments ? typeArguments.length : 0; + var result = []; + for (var _i = 0; _i < baseSignatures.length; _i++) { + var baseSig = baseSignatures[_i]; + var typeParamCount = baseSig.typeParameters ? baseSig.typeParameters.length : 0; + if (typeParamCount === typeArgCount) { + var sig = typeParamCount ? getSignatureInstantiation(baseSig, typeArguments) : cloneSignature(baseSig); + sig.typeParameters = classType.localTypeParameters; + sig.resolvedReturnType = classType; + result.push(sig); + } + } + return result; + } + function createTupleTypeMemberSymbols(memberTypes) { + var members = {}; + for (var i = 0; i < memberTypes.length; i++) { + var symbol = createSymbol(4 /* Property */ | 67108864 /* Transient */, "" + i); + symbol.type = memberTypes[i]; + members[i] = symbol; + } + return members; + } + function resolveTupleTypeMembers(type) { + var arrayElementType = getUnionType(type.elementTypes, /*noSubtypeReduction*/ true); + // Make the tuple type itself the 'this' type by including an extra type argument + var arrayType = resolveStructuredTypeMembers(createTypeFromGenericGlobalType(globalArrayType, [arrayElementType, type])); + var members = createTupleTypeMemberSymbols(type.elementTypes); + addInheritedMembers(members, arrayType.properties); + setObjectTypeMembers(type, members, arrayType.callSignatures, arrayType.constructSignatures, arrayType.stringIndexType, arrayType.numberIndexType); + } + function findMatchingSignature(signatureList, signature, partialMatch, ignoreReturnTypes) { + for (var _i = 0; _i < signatureList.length; _i++) { + var s = signatureList[_i]; + if (compareSignatures(s, signature, partialMatch, ignoreReturnTypes, compareTypes)) { + return s; + } + } + } + function findMatchingSignatures(signatureLists, signature, listIndex) { + if (signature.typeParameters) { + // We require an exact match for generic signatures, so we only return signatures from the first + // signature list and only if they have exact matches in the other signature lists. + if (listIndex > 0) { + return undefined; + } + for (var i = 1; i < signatureLists.length; i++) { + if (!findMatchingSignature(signatureLists[i], signature, /*partialMatch*/ false, /*ignoreReturnTypes*/ false)) { + return undefined; + } + } + return [signature]; + } + var result = undefined; + for (var i = 0; i < signatureLists.length; i++) { + // Allow matching non-generic signatures to have excess parameters and different return types + var match = i === listIndex ? signature : findMatchingSignature(signatureLists[i], signature, /*partialMatch*/ true, /*ignoreReturnTypes*/ true); + if (!match) { + return undefined; + } + if (!ts.contains(result, match)) { + (result || (result = [])).push(match); + } + } + return result; + } + // The signatures of a union type are those signatures that are present in each of the constituent types. + // Generic signatures must match exactly, but non-generic signatures are allowed to have extra optional + // parameters and may differ in return types. When signatures differ in return types, the resulting return + // type is the union of the constituent return types. + function getUnionSignatures(types, kind) { + var signatureLists = ts.map(types, function (t) { return getSignaturesOfType(t, kind); }); + var result = undefined; + for (var i = 0; i < signatureLists.length; i++) { + for (var _i = 0, _a = signatureLists[i]; _i < _a.length; _i++) { + var signature = _a[_i]; + // Only process signatures with parameter lists that aren't already in the result list + if (!result || !findMatchingSignature(result, signature, /*partialMatch*/ false, /*ignoreReturnTypes*/ true)) { + var unionSignatures = findMatchingSignatures(signatureLists, signature, i); + if (unionSignatures) { + var s = signature; + // Union the result types when more than one signature matches + if (unionSignatures.length > 1) { + s = cloneSignature(signature); + // Clear resolved return type we possibly got from cloneSignature + s.resolvedReturnType = undefined; + s.unionSignatures = unionSignatures; + } + (result || (result = [])).push(s); + } + } + } + } + return result || emptyArray; + } + function getUnionIndexType(types, kind) { + var indexTypes = []; + for (var _i = 0; _i < types.length; _i++) { + var type = types[_i]; + var indexType = getIndexTypeOfType(type, kind); + if (!indexType) { + return undefined; + } + indexTypes.push(indexType); + } + return getUnionType(indexTypes); + } + function resolveUnionTypeMembers(type) { + // The members and properties collections are empty for union types. To get all properties of a union + // type use getPropertiesOfType (only the language service uses this). + var callSignatures = getUnionSignatures(type.types, 0 /* Call */); + var constructSignatures = getUnionSignatures(type.types, 1 /* Construct */); + var stringIndexType = getUnionIndexType(type.types, 0 /* String */); + var numberIndexType = getUnionIndexType(type.types, 1 /* Number */); + setObjectTypeMembers(type, emptySymbols, callSignatures, constructSignatures, stringIndexType, numberIndexType); + } + function intersectTypes(type1, type2) { + return !type1 ? type2 : !type2 ? type1 : getIntersectionType([type1, type2]); + } + function resolveIntersectionTypeMembers(type) { + // The members and properties collections are empty for intersection types. To get all properties of an + // intersection type use getPropertiesOfType (only the language service uses this). + var callSignatures = emptyArray; + var constructSignatures = emptyArray; + var stringIndexType = undefined; + var numberIndexType = undefined; + for (var _i = 0, _a = type.types; _i < _a.length; _i++) { + var t = _a[_i]; + callSignatures = ts.concatenate(callSignatures, getSignaturesOfType(t, 0 /* Call */)); + constructSignatures = ts.concatenate(constructSignatures, getSignaturesOfType(t, 1 /* Construct */)); + stringIndexType = intersectTypes(stringIndexType, getIndexTypeOfType(t, 0 /* String */)); + numberIndexType = intersectTypes(numberIndexType, getIndexTypeOfType(t, 1 /* Number */)); + } + setObjectTypeMembers(type, emptySymbols, callSignatures, constructSignatures, stringIndexType, numberIndexType); + } + function resolveAnonymousTypeMembers(type) { + var symbol = type.symbol; + var members; + var callSignatures; + var constructSignatures; + var stringIndexType; + var numberIndexType; + if (type.target) { + members = createInstantiatedSymbolTable(getPropertiesOfObjectType(type.target), type.mapper, /*mappingThisOnly*/ false); + callSignatures = instantiateList(getSignaturesOfType(type.target, 0 /* Call */), type.mapper, instantiateSignature); + constructSignatures = instantiateList(getSignaturesOfType(type.target, 1 /* Construct */), type.mapper, instantiateSignature); + stringIndexType = instantiateType(getIndexTypeOfType(type.target, 0 /* String */), type.mapper); + numberIndexType = instantiateType(getIndexTypeOfType(type.target, 1 /* Number */), type.mapper); + } + else if (symbol.flags & 2048 /* TypeLiteral */) { + members = symbol.members; + callSignatures = getSignaturesOfSymbol(members["__call"]); + constructSignatures = getSignaturesOfSymbol(members["__new"]); + stringIndexType = getIndexTypeOfSymbol(symbol, 0 /* String */); + numberIndexType = getIndexTypeOfSymbol(symbol, 1 /* Number */); + } + else { + // Combinations of function, class, enum and module + members = emptySymbols; + callSignatures = emptyArray; + constructSignatures = emptyArray; + if (symbol.flags & 1952 /* HasExports */) { + members = getExportsOfSymbol(symbol); + } + if (symbol.flags & (16 /* Function */ | 8192 /* Method */)) { + callSignatures = getSignaturesOfSymbol(symbol); + } + if (symbol.flags & 32 /* Class */) { + var classType = getDeclaredTypeOfClassOrInterface(symbol); + constructSignatures = getSignaturesOfSymbol(symbol.members["__constructor"]); + if (!constructSignatures.length) { + constructSignatures = getDefaultConstructSignatures(classType); + } + var baseConstructorType = getBaseConstructorTypeOfClass(classType); + if (baseConstructorType.flags & 80896 /* ObjectType */) { + members = createSymbolTable(getNamedMembers(members)); + addInheritedMembers(members, getPropertiesOfObjectType(baseConstructorType)); + } + } + stringIndexType = undefined; + numberIndexType = (symbol.flags & 384 /* Enum */) ? stringType : undefined; + } + setObjectTypeMembers(type, members, callSignatures, constructSignatures, stringIndexType, numberIndexType); + } + function resolveStructuredTypeMembers(type) { + if (!type.members) { + if (type.flags & 4096 /* Reference */) { + resolveTypeReferenceMembers(type); + } + else if (type.flags & (1024 /* Class */ | 2048 /* Interface */)) { + resolveClassOrInterfaceMembers(type); + } + else if (type.flags & 65536 /* Anonymous */) { + resolveAnonymousTypeMembers(type); + } + else if (type.flags & 8192 /* Tuple */) { + resolveTupleTypeMembers(type); + } + else if (type.flags & 16384 /* Union */) { + resolveUnionTypeMembers(type); + } + else if (type.flags & 32768 /* Intersection */) { + resolveIntersectionTypeMembers(type); + } + } + return type; + } + // Return properties of an object type or an empty array for other types + function getPropertiesOfObjectType(type) { + if (type.flags & 80896 /* ObjectType */) { + return resolveStructuredTypeMembers(type).properties; + } + return emptyArray; + } + // 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, name) { + if (type.flags & 80896 /* ObjectType */) { + var resolved = resolveStructuredTypeMembers(type); + if (ts.hasProperty(resolved.members, name)) { + var symbol = resolved.members[name]; + if (symbolIsValue(symbol)) { + return symbol; + } + } + } + } + function getPropertiesOfUnionOrIntersectionType(type) { + for (var _i = 0, _a = type.types; _i < _a.length; _i++) { + var current = _a[_i]; + for (var _b = 0, _c = getPropertiesOfType(current); _b < _c.length; _b++) { + var prop = _c[_b]; + getPropertyOfUnionOrIntersectionType(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 + if (type.flags & 16384 /* Union */) { + break; + } + } + return type.resolvedProperties ? symbolsToArray(type.resolvedProperties) : emptyArray; + } + function getPropertiesOfType(type) { + type = getApparentType(type); + return type.flags & 49152 /* UnionOrIntersection */ ? getPropertiesOfUnionOrIntersectionType(type) : getPropertiesOfObjectType(type); + } + /** + * For a type parameter, return the base constraint of the type parameter. For the string, number, + * boolean, and symbol primitive types, return the corresponding object types. Otherwise return the + * type itself. Note that the apparent type of a union type is the union type itself. + */ + function getApparentType(type) { + if (type.flags & 512 /* TypeParameter */) { + do { + type = getConstraintOfTypeParameter(type); + } while (type && type.flags & 512 /* TypeParameter */); + if (!type) { + type = emptyObjectType; + } + } + if (type.flags & 258 /* StringLike */) { + type = globalStringType; + } + else if (type.flags & 132 /* NumberLike */) { + type = globalNumberType; + } + else if (type.flags & 8 /* Boolean */) { + type = globalBooleanType; + } + else if (type.flags & 16777216 /* ESSymbol */) { + type = globalESSymbolType; + } + return type; + } + function createUnionOrIntersectionProperty(containingType, name) { + var types = containingType.types; + var props; + for (var _i = 0; _i < types.length; _i++) { + var current = types[_i]; + var type = getApparentType(current); + if (type !== unknownType) { + var prop = getPropertyOfType(type, name); + if (prop && !(getDeclarationFlagsFromSymbol(prop) & (32 /* Private */ | 64 /* Protected */))) { + if (!props) { + props = [prop]; + } + else if (!ts.contains(props, prop)) { + props.push(prop); + } + } + else if (containingType.flags & 16384 /* Union */) { + // A union type requires the property to be present in all constituent types + return undefined; + } + } + } + if (!props) { + return undefined; + } + if (props.length === 1) { + return props[0]; + } + var propTypes = []; + var declarations = []; + for (var _a = 0; _a < props.length; _a++) { + var prop = props[_a]; + if (prop.declarations) { + ts.addRange(declarations, prop.declarations); + } + propTypes.push(getTypeOfSymbol(prop)); + } + var result = createSymbol(4 /* Property */ | 67108864 /* Transient */ | 268435456 /* SyntheticProperty */, name); + result.containingType = containingType; + result.declarations = declarations; + result.type = containingType.flags & 16384 /* Union */ ? getUnionType(propTypes) : getIntersectionType(propTypes); + return result; + } + function getPropertyOfUnionOrIntersectionType(type, name) { + var properties = type.resolvedProperties || (type.resolvedProperties = {}); + if (ts.hasProperty(properties, name)) { + return properties[name]; + } + var property = createUnionOrIntersectionProperty(type, name); + if (property) { + properties[name] = property; + } + return property; + } + // 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 + // Object and Function as appropriate. + function getPropertyOfType(type, name) { + type = getApparentType(type); + if (type.flags & 80896 /* ObjectType */) { + var resolved = resolveStructuredTypeMembers(type); + if (ts.hasProperty(resolved.members, name)) { + var symbol = resolved.members[name]; + if (symbolIsValue(symbol)) { + return symbol; + } + } + if (resolved === anyFunctionType || resolved.callSignatures.length || resolved.constructSignatures.length) { + var symbol = getPropertyOfObjectType(globalFunctionType, name); + if (symbol) { + return symbol; + } + } + return getPropertyOfObjectType(globalObjectType, name); + } + if (type.flags & 49152 /* UnionOrIntersection */) { + return getPropertyOfUnionOrIntersectionType(type, name); + } + return undefined; + } + function getSignaturesOfStructuredType(type, kind) { + if (type.flags & 130048 /* StructuredType */) { + var resolved = resolveStructuredTypeMembers(type); + return kind === 0 /* Call */ ? resolved.callSignatures : resolved.constructSignatures; + } + return emptyArray; + } + /** + * Return the signatures of the given kind in the given type. Creates synthetic union signatures when necessary and + * maps primitive types and type parameters are to their apparent types. + */ + function getSignaturesOfType(type, kind) { + return getSignaturesOfStructuredType(getApparentType(type), kind); + } + function typeHasConstructSignatures(type) { + var apparentType = getApparentType(type); + if (apparentType.flags & (80896 /* ObjectType */ | 16384 /* Union */)) { + var resolved = resolveStructuredTypeMembers(type); + return resolved.constructSignatures.length > 0; + } + return false; + } + function typeHasCallOrConstructSignatures(type) { + var apparentType = getApparentType(type); + if (apparentType.flags & 130048 /* StructuredType */) { + var resolved = resolveStructuredTypeMembers(type); + return resolved.callSignatures.length > 0 || resolved.constructSignatures.length > 0; + } + return false; + } + function getIndexTypeOfStructuredType(type, kind) { + if (type.flags & 130048 /* StructuredType */) { + var resolved = resolveStructuredTypeMembers(type); + return kind === 0 /* String */ ? resolved.stringIndexType : resolved.numberIndexType; + } + } + // Return the index type of the given kind in the given type. Creates synthetic union index types when necessary and + // maps primitive types and type parameters are to their apparent types. + function getIndexTypeOfType(type, kind) { + return getIndexTypeOfStructuredType(getApparentType(type), kind); + } + // Return list of type parameters with duplicates removed (duplicate identifier errors are generated in the actual + // type checking functions). + function getTypeParametersFromDeclaration(typeParameterDeclarations) { + var result = []; + ts.forEach(typeParameterDeclarations, function (node) { + var tp = getDeclaredTypeOfTypeParameter(node.symbol); + if (!ts.contains(result, tp)) { + result.push(tp); + } + }); + return result; + } + function symbolsToArray(symbols) { + var result = []; + for (var id in symbols) { + if (!isReservedMemberName(id)) { + result.push(symbols[id]); + } + } + return result; + } + function isOptionalParameter(node) { + if (ts.hasQuestionToken(node)) { + return true; + } + if (node.initializer) { + var signatureDeclaration = node.parent; + var signature = getSignatureFromDeclaration(signatureDeclaration); + var parameterIndex = signatureDeclaration.parameters.indexOf(node); + ts.Debug.assert(parameterIndex >= 0); + return parameterIndex >= signature.minArgumentCount; + } + return false; + } + function getSignatureFromDeclaration(declaration) { + var links = getNodeLinks(declaration); + if (!links.resolvedSignature) { + var classType = declaration.kind === 144 /* Constructor */ ? + getDeclaredTypeOfClassOrInterface(getMergedSymbol(declaration.parent.symbol)) + : undefined; + var typeParameters = classType ? classType.localTypeParameters : + declaration.typeParameters ? getTypeParametersFromDeclaration(declaration.typeParameters) : undefined; + var parameters = []; + var hasStringLiterals = false; + var minArgumentCount = -1; + for (var i = 0, n = declaration.parameters.length; i < n; i++) { + var param = declaration.parameters[i]; + parameters.push(param.symbol); + if (param.type && param.type.kind === 9 /* StringLiteral */) { + hasStringLiterals = true; + } + if (param.initializer || param.questionToken || param.dotDotDotToken) { + if (minArgumentCount < 0) { + minArgumentCount = i; + } + } + else { + // If we see any required parameters, it means the prior ones were not in fact optional. + minArgumentCount = -1; + } + } + if (minArgumentCount < 0) { + minArgumentCount = declaration.parameters.length; + } + var returnType; + var typePredicate; + if (classType) { + returnType = classType; + } + else if (declaration.type) { + returnType = getTypeFromTypeNode(declaration.type); + if (declaration.type.kind === 150 /* TypePredicate */) { + var typePredicateNode = declaration.type; + typePredicate = { + parameterName: typePredicateNode.parameterName ? typePredicateNode.parameterName.text : undefined, + parameterIndex: typePredicateNode.parameterName ? getTypePredicateParameterIndex(declaration.parameters, typePredicateNode.parameterName) : undefined, + type: getTypeFromTypeNode(typePredicateNode.type) + }; + } + } + else { + // TypeScript 1.0 spec (April 2014): + // If only one accessor includes a type annotation, the other behaves as if it had the same type annotation. + if (declaration.kind === 145 /* GetAccessor */ && !ts.hasDynamicName(declaration)) { + var setter = ts.getDeclarationOfKind(declaration.symbol, 146 /* SetAccessor */); + returnType = getAnnotatedAccessorType(setter); + } + if (!returnType && ts.nodeIsMissing(declaration.body)) { + returnType = anyType; + } + } + links.resolvedSignature = createSignature(declaration, typeParameters, parameters, returnType, typePredicate, minArgumentCount, ts.hasRestParameter(declaration), hasStringLiterals); + } + return links.resolvedSignature; + } + function getSignaturesOfSymbol(symbol) { + if (!symbol) + return emptyArray; + var result = []; + for (var i = 0, len = symbol.declarations.length; i < len; i++) { + var node = symbol.declarations[i]; + switch (node.kind) { + case 152 /* FunctionType */: + case 153 /* ConstructorType */: + case 213 /* FunctionDeclaration */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: + case 144 /* Constructor */: + case 147 /* CallSignature */: + case 148 /* ConstructSignature */: + case 149 /* IndexSignature */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: + case 173 /* FunctionExpression */: + case 174 /* ArrowFunction */: + // Don't include signature if node is the implementation of an overloaded function. A node is considered + // an implementation node if it has a body and the previous node is of the same kind and immediately + // precedes the implementation node (i.e. has the same parent and ends where the implementation starts). + if (i > 0 && node.body) { + var previous = symbol.declarations[i - 1]; + if (node.parent === previous.parent && node.kind === previous.kind && node.pos === previous.end) { + break; + } + } + result.push(getSignatureFromDeclaration(node)); + } + } + return result; + } + function getReturnTypeOfSignature(signature) { + if (!signature.resolvedReturnType) { + if (!pushTypeResolution(signature, 3 /* ResolvedReturnType */)) { + return unknownType; + } + var type; + if (signature.target) { + type = instantiateType(getReturnTypeOfSignature(signature.target), signature.mapper); + } + else if (signature.unionSignatures) { + type = getUnionType(ts.map(signature.unionSignatures, getReturnTypeOfSignature)); + } + else { + type = getReturnTypeFromBody(signature.declaration); + } + if (!popTypeResolution()) { + type = anyType; + if (compilerOptions.noImplicitAny) { + var declaration = signature.declaration; + if (declaration.name) { + error(declaration.name, 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, ts.declarationNameToString(declaration.name)); + } + else { + error(declaration, ts.Diagnostics.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); + } + } + } + signature.resolvedReturnType = type; + } + return signature.resolvedReturnType; + } + function getRestTypeOfSignature(signature) { + if (signature.hasRestParameter) { + var type = getTypeOfSymbol(ts.lastOrUndefined(signature.parameters)); + if (type.flags & 4096 /* Reference */ && type.target === globalArrayType) { + return type.typeArguments[0]; + } + } + return anyType; + } + function getSignatureInstantiation(signature, typeArguments) { + return instantiateSignature(signature, createTypeMapper(signature.typeParameters, typeArguments), true); + } + function getErasedSignature(signature) { + if (!signature.typeParameters) + return signature; + if (!signature.erasedSignatureCache) { + if (signature.target) { + signature.erasedSignatureCache = instantiateSignature(getErasedSignature(signature.target), signature.mapper); + } + else { + signature.erasedSignatureCache = instantiateSignature(signature, createTypeEraser(signature.typeParameters), true); + } + } + return signature.erasedSignatureCache; + } + function getOrCreateTypeFromSignature(signature) { + // There are two ways to declare a construct signature, one is by declaring a class constructor + // using the constructor keyword, and the other is declaring a bare construct signature in an + // 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 === 144 /* Constructor */ || signature.declaration.kind === 148 /* ConstructSignature */; + var type = createObjectType(65536 /* Anonymous */ | 262144 /* FromSignature */); + type.members = emptySymbols; + type.properties = emptyArray; + type.callSignatures = !isConstructor ? [signature] : emptyArray; + type.constructSignatures = isConstructor ? [signature] : emptyArray; + signature.isolatedSignatureType = type; + } + return signature.isolatedSignatureType; + } + function getIndexSymbol(symbol) { + return symbol.members["__index"]; + } + function getIndexDeclarationOfSymbol(symbol, kind) { + var syntaxKind = kind === 1 /* Number */ ? 128 /* NumberKeyword */ : 130 /* StringKeyword */; + var indexSymbol = getIndexSymbol(symbol); + if (indexSymbol) { + for (var _i = 0, _a = indexSymbol.declarations; _i < _a.length; _i++) { + var decl = _a[_i]; + var node = decl; + if (node.parameters.length === 1) { + var parameter = node.parameters[0]; + if (parameter && parameter.type && parameter.type.kind === syntaxKind) { + return node; + } + } + } + } + return undefined; + } + function getIndexTypeOfSymbol(symbol, kind) { + var declaration = getIndexDeclarationOfSymbol(symbol, kind); + return declaration + ? declaration.type ? getTypeFromTypeNode(declaration.type) : anyType + : undefined; + } + function getConstraintOfTypeParameter(type) { + if (!type.constraint) { + if (type.target) { + var targetConstraint = getConstraintOfTypeParameter(type.target); + type.constraint = targetConstraint ? instantiateType(targetConstraint, type.mapper) : noConstraintType; + } + else { + type.constraint = getTypeFromTypeNode(ts.getDeclarationOfKind(type.symbol, 137 /* TypeParameter */).constraint); + } + } + return type.constraint === noConstraintType ? undefined : type.constraint; + } + function getParentSymbolOfTypeParameter(typeParameter) { + return getSymbolOfNode(ts.getDeclarationOfKind(typeParameter.symbol, 137 /* TypeParameter */).parent); + } + function getTypeListId(types) { + if (types) { + switch (types.length) { + case 1: + return "" + types[0].id; + case 2: + return types[0].id + "," + types[1].id; + default: + var result = ""; + for (var i = 0; i < types.length; i++) { + if (i > 0) { + result += ","; + } + result += types[i].id; + } + return result; + } + } + return ""; + } + // This function is used to propagate certain flags when creating new object type references and union types. + // It is only necessary to do so if a constituent type might be the undefined type, the null type, the type + // of an object literal or the anyFunctionType. This is because there are operations in the type checker + // that care about the presence of such types at arbitrary depth in a containing type. + function getPropagatingFlagsOfTypes(types) { + var result = 0; + for (var _i = 0; _i < types.length; _i++) { + var type = types[_i]; + result |= type.flags; + } + return result & 14680064 /* PropagatingFlags */; + } + function createTypeReference(target, typeArguments) { + var id = getTypeListId(typeArguments); + var type = target.instantiations[id]; + if (!type) { + var flags = 4096 /* Reference */ | (typeArguments ? getPropagatingFlagsOfTypes(typeArguments) : 0); + type = target.instantiations[id] = createObjectType(flags, target.symbol); + type.target = target; + type.typeArguments = typeArguments; + } + return type; + } + function isTypeParameterReferenceIllegalInConstraint(typeReferenceNode, typeParameterSymbol) { + var links = getNodeLinks(typeReferenceNode); + if (links.isIllegalTypeReferenceInConstraint !== undefined) { + return links.isIllegalTypeReferenceInConstraint; + } + // bubble up to the declaration + var currentNode = typeReferenceNode; + // forEach === exists + while (!ts.forEach(typeParameterSymbol.declarations, function (d) { return d.parent === currentNode.parent; })) { + currentNode = currentNode.parent; + } + // if last step was made from the type parameter this means that path has started somewhere in constraint which is illegal + links.isIllegalTypeReferenceInConstraint = currentNode.kind === 137 /* TypeParameter */; + return links.isIllegalTypeReferenceInConstraint; + } + function checkTypeParameterHasIllegalReferencesInConstraint(typeParameter) { + var typeParameterSymbol; + function check(n) { + if (n.kind === 151 /* TypeReference */ && n.typeName.kind === 69 /* Identifier */) { + var links = getNodeLinks(n); + if (links.isIllegalTypeReferenceInConstraint === undefined) { + var symbol = resolveName(typeParameter, n.typeName.text, 793056 /* Type */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined); + if (symbol && (symbol.flags & 262144 /* TypeParameter */)) { + // TypeScript 1.0 spec (April 2014): 3.4.1 + // Type parameters declared in a particular type parameter list + // may not be referenced in constraints in that type parameter list + // symbol.declaration.parent === typeParameter.parent + // -> typeParameter and symbol.declaration originate from the same type parameter list + // -> illegal for all declarations in symbol + // forEach === exists + links.isIllegalTypeReferenceInConstraint = ts.forEach(symbol.declarations, function (d) { return d.parent === typeParameter.parent; }); + } + } + if (links.isIllegalTypeReferenceInConstraint) { + error(typeParameter, ts.Diagnostics.Constraint_of_a_type_parameter_cannot_reference_any_type_parameter_from_the_same_type_parameter_list); + } + } + ts.forEachChild(n, check); + } + if (typeParameter.constraint) { + typeParameterSymbol = getSymbolOfNode(typeParameter); + check(typeParameter.constraint); + } + } + // Get type from reference to class or interface + function getTypeFromClassOrInterfaceReference(node, symbol) { + var type = getDeclaredTypeOfSymbol(symbol); + var typeParameters = type.localTypeParameters; + if (typeParameters) { + if (!node.typeArguments || node.typeArguments.length !== typeParameters.length) { + error(node, ts.Diagnostics.Generic_type_0_requires_1_type_argument_s, typeToString(type, /*enclosingDeclaration*/ undefined, 1 /* WriteArrayAsGenericType */), typeParameters.length); + return unknownType; + } + // In a type reference, the outer type parameters of the referenced class or interface are automatically + // supplied as type arguments and the type reference only specifies arguments for the local type parameters + // of the class or interface. + return createTypeReference(type, ts.concatenate(type.outerTypeParameters, ts.map(node.typeArguments, getTypeFromTypeNode))); + } + if (node.typeArguments) { + error(node, ts.Diagnostics.Type_0_is_not_generic, typeToString(type)); + return unknownType; + } + return type; + } + // Get type from reference to type alias. When a type alias is generic, the declared type of the type alias may include + // references to the type parameters of the alias. We replace those with the actual type arguments by instantiating the + // declared type. Instantiations are cached using the type identities of the type arguments as the key. + function getTypeFromTypeAliasReference(node, symbol) { + var type = getDeclaredTypeOfSymbol(symbol); + var links = getSymbolLinks(symbol); + var typeParameters = links.typeParameters; + if (typeParameters) { + if (!node.typeArguments || node.typeArguments.length !== typeParameters.length) { + error(node, ts.Diagnostics.Generic_type_0_requires_1_type_argument_s, symbolToString(symbol), typeParameters.length); + return unknownType; + } + var typeArguments = ts.map(node.typeArguments, getTypeFromTypeNode); + var id = getTypeListId(typeArguments); + return links.instantiations[id] || (links.instantiations[id] = instantiateType(type, createTypeMapper(typeParameters, typeArguments))); + } + if (node.typeArguments) { + error(node, ts.Diagnostics.Type_0_is_not_generic, symbolToString(symbol)); + return unknownType; + } + return type; + } + // Get type from reference to named type that cannot be generic (enum or type parameter) + function getTypeFromNonGenericTypeReference(node, symbol) { + if (symbol.flags & 262144 /* TypeParameter */ && isTypeParameterReferenceIllegalInConstraint(node, symbol)) { + // TypeScript 1.0 spec (April 2014): 3.4.1 + // Type parameters declared in a particular type parameter list + // may not be referenced in constraints in that type parameter list + // Implementation: such type references are resolved to 'unknown' type that usually denotes error + return unknownType; + } + if (node.typeArguments) { + error(node, ts.Diagnostics.Type_0_is_not_generic, symbolToString(symbol)); + return unknownType; + } + return getDeclaredTypeOfSymbol(symbol); + } + function getTypeFromTypeReference(node) { + var links = getNodeLinks(node); + if (!links.resolvedType) { + // We only support expressions that are simple qualified names. For other expressions this produces undefined. + var typeNameOrExpression = node.kind === 151 /* TypeReference */ ? node.typeName : + ts.isSupportedExpressionWithTypeArguments(node) ? node.expression : + undefined; + var symbol = typeNameOrExpression && resolveEntityName(typeNameOrExpression, 793056 /* Type */) || unknownSymbol; + var type = symbol === unknownSymbol ? unknownType : + symbol.flags & (32 /* Class */ | 64 /* Interface */) ? getTypeFromClassOrInterfaceReference(node, symbol) : + symbol.flags & 524288 /* TypeAlias */ ? getTypeFromTypeAliasReference(node, symbol) : + getTypeFromNonGenericTypeReference(node, symbol); + // Cache both the resolved symbol and the resolved type. The resolved symbol is needed in when we check the + // type reference in checkTypeReferenceOrExpressionWithTypeArguments. + links.resolvedSymbol = symbol; + links.resolvedType = type; + } + return links.resolvedType; + } + function getTypeFromTypeQueryNode(node) { + var links = getNodeLinks(node); + if (!links.resolvedType) { + // TypeScript 1.0 spec (April 2014): 3.6.3 + // The expression is processed as an identifier expression (section 4.3) + // or property access expression(section 4.10), + // the widened type(section 3.9) of which becomes the result. + links.resolvedType = getWidenedType(checkExpression(node.exprName)); + } + return links.resolvedType; + } + function getTypeOfGlobalSymbol(symbol, arity) { + function getTypeDeclaration(symbol) { + var declarations = symbol.declarations; + for (var _i = 0; _i < declarations.length; _i++) { + var declaration = declarations[_i]; + switch (declaration.kind) { + case 214 /* ClassDeclaration */: + case 215 /* InterfaceDeclaration */: + case 217 /* EnumDeclaration */: + return declaration; + } + } + } + if (!symbol) { + return arity ? emptyGenericType : emptyObjectType; + } + var type = getDeclaredTypeOfSymbol(symbol); + if (!(type.flags & 80896 /* ObjectType */)) { + error(getTypeDeclaration(symbol), ts.Diagnostics.Global_type_0_must_be_a_class_or_interface_type, symbol.name); + return arity ? emptyGenericType : emptyObjectType; + } + if ((type.typeParameters ? type.typeParameters.length : 0) !== arity) { + error(getTypeDeclaration(symbol), ts.Diagnostics.Global_type_0_must_have_1_type_parameter_s, symbol.name, arity); + return arity ? emptyGenericType : emptyObjectType; + } + return type; + } + function getGlobalValueSymbol(name) { + return getGlobalSymbol(name, 107455 /* Value */, ts.Diagnostics.Cannot_find_global_value_0); + } + function getGlobalTypeSymbol(name) { + return getGlobalSymbol(name, 793056 /* Type */, ts.Diagnostics.Cannot_find_global_type_0); + } + function getGlobalSymbol(name, meaning, diagnostic) { + return resolveName(undefined, name, meaning, diagnostic, name); + } + function getGlobalType(name, arity) { + if (arity === void 0) { arity = 0; } + return getTypeOfGlobalSymbol(getGlobalTypeSymbol(name), arity); + } + function tryGetGlobalType(name, arity) { + if (arity === void 0) { arity = 0; } + return getTypeOfGlobalSymbol(getGlobalSymbol(name, 793056 /* Type */, /*diagnostic*/ undefined), arity); + } + /** + * Returns a type that is inside a namespace at the global scope, e.g. + * getExportedTypeFromNamespace('JSX', 'Element') returns the JSX.Element type + */ + function getExportedTypeFromNamespace(namespace, name) { + var namespaceSymbol = getGlobalSymbol(namespace, 1536 /* Namespace */, /*diagnosticMessage*/ undefined); + var typeSymbol = namespaceSymbol && getSymbol(namespaceSymbol.exports, name, 793056 /* Type */); + return typeSymbol && getDeclaredTypeOfSymbol(typeSymbol); + } + function getGlobalESSymbolConstructorSymbol() { + return globalESSymbolConstructorSymbol || (globalESSymbolConstructorSymbol = getGlobalValueSymbol("Symbol")); + } + /** + * Creates a TypeReference for a generic `TypedPropertyDescriptor`. + */ + function createTypedPropertyDescriptorType(propertyType) { + var globalTypedPropertyDescriptorType = getGlobalTypedPropertyDescriptorType(); + return globalTypedPropertyDescriptorType !== emptyGenericType + ? createTypeReference(globalTypedPropertyDescriptorType, [propertyType]) + : emptyObjectType; + } + /** + * Instantiates a global type that is generic with some element type, and returns that instantiation. + */ + function createTypeFromGenericGlobalType(genericGlobalType, typeArguments) { + return genericGlobalType !== emptyGenericType ? createTypeReference(genericGlobalType, typeArguments) : emptyObjectType; + } + function createIterableType(elementType) { + return createTypeFromGenericGlobalType(globalIterableType, [elementType]); + } + function createIterableIteratorType(elementType) { + return createTypeFromGenericGlobalType(globalIterableIteratorType, [elementType]); + } + function createArrayType(elementType) { + return createTypeFromGenericGlobalType(globalArrayType, [elementType]); + } + function getTypeFromArrayTypeNode(node) { + var links = getNodeLinks(node); + if (!links.resolvedType) { + links.resolvedType = createArrayType(getTypeFromTypeNode(node.elementType)); + } + return links.resolvedType; + } + function createTupleType(elementTypes) { + var id = getTypeListId(elementTypes); + return tupleTypes[id] || (tupleTypes[id] = createNewTupleType(elementTypes)); + } + function createNewTupleType(elementTypes) { + var type = createObjectType(8192 /* Tuple */ | getPropagatingFlagsOfTypes(elementTypes)); + type.elementTypes = elementTypes; + return type; + } + function getTypeFromTupleTypeNode(node) { + var links = getNodeLinks(node); + if (!links.resolvedType) { + links.resolvedType = createTupleType(ts.map(node.elementTypes, getTypeFromTypeNode)); + } + return links.resolvedType; + } + function addTypeToSet(typeSet, type, typeSetKind) { + if (type.flags & typeSetKind) { + addTypesToSet(typeSet, type.types, typeSetKind); + } + else if (!ts.contains(typeSet, type)) { + typeSet.push(type); + } + } + // Add the given types to the given type set. Order is preserved, duplicates are removed, + // and nested types of the given kind are flattened into the set. + function addTypesToSet(typeSet, types, typeSetKind) { + for (var _i = 0; _i < types.length; _i++) { + var type = types[_i]; + addTypeToSet(typeSet, type, typeSetKind); + } + } + function isSubtypeOfAny(candidate, types) { + for (var i = 0, len = types.length; i < len; i++) { + if (candidate !== types[i] && isTypeSubtypeOf(candidate, types[i])) { + return true; + } + } + return false; + } + function removeSubtypes(types) { + var i = types.length; + while (i > 0) { + i--; + if (isSubtypeOfAny(types[i], types)) { + types.splice(i, 1); + } + } + } + function containsTypeAny(types) { + for (var _i = 0; _i < types.length; _i++) { + var type = types[_i]; + if (isTypeAny(type)) { + return true; + } + } + return false; + } + function removeAllButLast(types, typeToRemove) { + var i = types.length; + while (i > 0 && types.length > 1) { + i--; + if (types[i] === typeToRemove) { + types.splice(i, 1); + } + } + } + // We reduce the constituent type set to only include types that aren't subtypes of other types, unless + // the noSubtypeReduction flag is specified, in which case we perform a simple deduplication based on + // object identity. Subtype reduction is possible only when union types are known not to circularly + // reference themselves (as is the case with union types created by expression constructs such as array + // literals and the || and ?: operators). Named types can circularly reference themselves and therefore + // cannot be deduplicated during their declaration. For example, "type Item = string | (() => Item" is + // a named type that circularly references itself. + function getUnionType(types, noSubtypeReduction) { + if (types.length === 0) { + return emptyObjectType; + } + var typeSet = []; + addTypesToSet(typeSet, types, 16384 /* Union */); + if (containsTypeAny(typeSet)) { + return anyType; + } + if (noSubtypeReduction) { + removeAllButLast(typeSet, undefinedType); + removeAllButLast(typeSet, nullType); + } + else { + removeSubtypes(typeSet); + } + if (typeSet.length === 1) { + return typeSet[0]; + } + var id = getTypeListId(typeSet); + var type = unionTypes[id]; + if (!type) { + type = unionTypes[id] = createObjectType(16384 /* Union */ | getPropagatingFlagsOfTypes(typeSet)); + type.types = typeSet; + } + return type; + } + function getTypeFromUnionTypeNode(node) { + var links = getNodeLinks(node); + if (!links.resolvedType) { + links.resolvedType = getUnionType(ts.map(node.types, getTypeFromTypeNode), /*noSubtypeReduction*/ true); + } + return links.resolvedType; + } + // 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. + // Also, unlike union types, the order of the constituent types is preserved in order that overload resolution + // for intersections of types with signatures can be deterministic. + function getIntersectionType(types) { + if (types.length === 0) { + return emptyObjectType; + } + var typeSet = []; + addTypesToSet(typeSet, types, 32768 /* Intersection */); + if (containsTypeAny(typeSet)) { + return anyType; + } + if (typeSet.length === 1) { + return typeSet[0]; + } + var id = getTypeListId(typeSet); + var type = intersectionTypes[id]; + if (!type) { + type = intersectionTypes[id] = createObjectType(32768 /* Intersection */ | getPropagatingFlagsOfTypes(typeSet)); + type.types = typeSet; + } + return type; + } + function getTypeFromIntersectionTypeNode(node) { + var links = getNodeLinks(node); + if (!links.resolvedType) { + links.resolvedType = getIntersectionType(ts.map(node.types, getTypeFromTypeNode)); + } + return links.resolvedType; + } + function getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node) { + var links = getNodeLinks(node); + if (!links.resolvedType) { + // Deferred resolution of members is handled by resolveObjectTypeMembers + links.resolvedType = createObjectType(65536 /* Anonymous */, node.symbol); + } + return links.resolvedType; + } + function getStringLiteralType(node) { + if (ts.hasProperty(stringLiteralTypes, node.text)) { + return stringLiteralTypes[node.text]; + } + var type = stringLiteralTypes[node.text] = createType(256 /* StringLiteral */); + type.text = ts.getTextOfNode(node); + return type; + } + function getTypeFromStringLiteral(node) { + var links = getNodeLinks(node); + if (!links.resolvedType) { + links.resolvedType = getStringLiteralType(node); + } + return links.resolvedType; + } + function getThisType(node) { + var container = ts.getThisContainer(node, /*includeArrowFunctions*/ false); + var parent = container && container.parent; + if (parent && (ts.isClassLike(parent) || parent.kind === 215 /* InterfaceDeclaration */)) { + if (!(container.flags & 128 /* Static */)) { + return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(parent)).thisType; + } + } + error(node, ts.Diagnostics.A_this_type_is_available_only_in_a_non_static_member_of_a_class_or_interface); + return unknownType; + } + function getTypeFromThisTypeNode(node) { + var links = getNodeLinks(node); + if (!links.resolvedType) { + links.resolvedType = getThisType(node); + } + return links.resolvedType; + } + function getTypeFromTypeNode(node) { + switch (node.kind) { + case 117 /* AnyKeyword */: + return anyType; + case 130 /* StringKeyword */: + return stringType; + case 128 /* NumberKeyword */: + return numberType; + case 120 /* BooleanKeyword */: + return booleanType; + case 131 /* SymbolKeyword */: + return esSymbolType; + case 103 /* VoidKeyword */: + return voidType; + case 97 /* ThisKeyword */: + return getTypeFromThisTypeNode(node); + case 9 /* StringLiteral */: + return getTypeFromStringLiteral(node); + case 151 /* TypeReference */: + return getTypeFromTypeReference(node); + case 150 /* TypePredicate */: + return booleanType; + case 188 /* ExpressionWithTypeArguments */: + return getTypeFromTypeReference(node); + case 154 /* TypeQuery */: + return getTypeFromTypeQueryNode(node); + case 156 /* ArrayType */: + return getTypeFromArrayTypeNode(node); + case 157 /* TupleType */: + return getTypeFromTupleTypeNode(node); + case 158 /* UnionType */: + return getTypeFromUnionTypeNode(node); + case 159 /* IntersectionType */: + return getTypeFromIntersectionTypeNode(node); + case 160 /* ParenthesizedType */: + return getTypeFromTypeNode(node.type); + case 152 /* FunctionType */: + case 153 /* ConstructorType */: + case 155 /* TypeLiteral */: + return getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node); + // This function assumes that an identifier or qualified name is a type expression + // Callers should first ensure this by calling isTypeNode + case 69 /* Identifier */: + case 135 /* QualifiedName */: + var symbol = getSymbolAtLocation(node); + return symbol && getDeclaredTypeOfSymbol(symbol); + default: + return unknownType; + } + } + function instantiateList(items, mapper, instantiator) { + if (items && items.length) { + var result = []; + for (var _i = 0; _i < items.length; _i++) { + var v = items[_i]; + result.push(instantiator(v, mapper)); + } + return result; + } + return items; + } + function createUnaryTypeMapper(source, target) { + return function (t) { return t === source ? target : t; }; + } + function createBinaryTypeMapper(source1, target1, source2, target2) { + return function (t) { return t === source1 ? target1 : t === source2 ? target2 : t; }; + } + function createTypeMapper(sources, targets) { + switch (sources.length) { + case 1: return createUnaryTypeMapper(sources[0], targets[0]); + case 2: return createBinaryTypeMapper(sources[0], targets[0], sources[1], targets[1]); + } + return function (t) { + for (var i = 0; i < sources.length; i++) { + if (t === sources[i]) { + return targets[i]; + } + } + return t; + }; + } + function createUnaryTypeEraser(source) { + return function (t) { return t === source ? anyType : t; }; + } + function createBinaryTypeEraser(source1, source2) { + return function (t) { return t === source1 || t === source2 ? anyType : t; }; + } + function createTypeEraser(sources) { + switch (sources.length) { + case 1: return createUnaryTypeEraser(sources[0]); + case 2: return createBinaryTypeEraser(sources[0], sources[1]); + } + return function (t) { + for (var _i = 0; _i < sources.length; _i++) { + var source = sources[_i]; + if (t === source) { + return anyType; + } + } + return t; + }; + } + function createInferenceMapper(context) { + var mapper = function (t) { + for (var i = 0; i < context.typeParameters.length; i++) { + if (t === context.typeParameters[i]) { + context.inferences[i].isFixed = true; + return getInferredType(context, i); + } + } + return t; + }; + mapper.context = context; + return mapper; + } + function identityMapper(type) { + return type; + } + function combineTypeMappers(mapper1, mapper2) { + return function (t) { return instantiateType(mapper1(t), mapper2); }; + } + function instantiateTypeParameter(typeParameter, mapper) { + var result = createType(512 /* TypeParameter */); + result.symbol = typeParameter.symbol; + if (typeParameter.constraint) { + result.constraint = instantiateType(typeParameter.constraint, mapper); + } + else { + result.target = typeParameter; + result.mapper = mapper; + } + return result; + } + function instantiateSignature(signature, mapper, eraseTypeParameters) { + var freshTypeParameters; + var freshTypePredicate; + if (signature.typeParameters && !eraseTypeParameters) { + freshTypeParameters = instantiateList(signature.typeParameters, mapper, instantiateTypeParameter); + mapper = combineTypeMappers(createTypeMapper(signature.typeParameters, freshTypeParameters), mapper); + } + if (signature.typePredicate) { + freshTypePredicate = { + parameterName: signature.typePredicate.parameterName, + parameterIndex: signature.typePredicate.parameterIndex, + type: instantiateType(signature.typePredicate.type, mapper) + }; + } + var result = createSignature(signature.declaration, freshTypeParameters, instantiateList(signature.parameters, mapper, instantiateSymbol), instantiateType(signature.resolvedReturnType, mapper), freshTypePredicate, signature.minArgumentCount, signature.hasRestParameter, signature.hasStringLiterals); + result.target = signature; + result.mapper = mapper; + return result; + } + function instantiateSymbol(symbol, mapper) { + if (symbol.flags & 16777216 /* Instantiated */) { + var links = getSymbolLinks(symbol); + // If symbol being instantiated is itself a instantiation, fetch the original target and combine the + // type mappers. This ensures that original type identities are properly preserved and that aliases + // always reference a non-aliases. + symbol = links.target; + mapper = combineTypeMappers(links.mapper, mapper); + } + // Keep the flags from the symbol we're instantiating. Mark that is instantiated, and + // also transient so that we can just store data on it directly. + var result = createSymbol(16777216 /* Instantiated */ | 67108864 /* Transient */ | symbol.flags, symbol.name); + result.declarations = symbol.declarations; + result.parent = symbol.parent; + result.target = symbol; + result.mapper = mapper; + if (symbol.valueDeclaration) { + result.valueDeclaration = symbol.valueDeclaration; + } + return result; + } + function instantiateAnonymousType(type, mapper) { + if (mapper.instantiations) { + var cachedType = mapper.instantiations[type.id]; + if (cachedType) { + return cachedType; + } + } + else { + mapper.instantiations = []; + } + // Mark the anonymous type as instantiated such that our infinite instantiation detection logic can recognize it + var result = createObjectType(65536 /* Anonymous */ | 131072 /* Instantiated */, type.symbol); + result.target = type; + result.mapper = mapper; + mapper.instantiations[type.id] = result; + return result; + } + function instantiateType(type, mapper) { + if (type && mapper !== identityMapper) { + if (type.flags & 512 /* TypeParameter */) { + return mapper(type); + } + if (type.flags & 65536 /* Anonymous */) { + return type.symbol && type.symbol.flags & (16 /* Function */ | 8192 /* Method */ | 32 /* Class */ | 2048 /* TypeLiteral */ | 4096 /* ObjectLiteral */) ? + instantiateAnonymousType(type, mapper) : type; + } + if (type.flags & 4096 /* Reference */) { + return createTypeReference(type.target, instantiateList(type.typeArguments, mapper, instantiateType)); + } + if (type.flags & 8192 /* Tuple */) { + return createTupleType(instantiateList(type.elementTypes, mapper, instantiateType)); + } + if (type.flags & 16384 /* Union */) { + return getUnionType(instantiateList(type.types, mapper, instantiateType), /*noSubtypeReduction*/ true); + } + if (type.flags & 32768 /* Intersection */) { + return getIntersectionType(instantiateList(type.types, mapper, instantiateType)); + } + } + return type; + } + // 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 !== 143 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + switch (node.kind) { + case 173 /* FunctionExpression */: + case 174 /* ArrowFunction */: + return isContextSensitiveFunctionLikeDeclaration(node); + case 165 /* ObjectLiteralExpression */: + return ts.forEach(node.properties, isContextSensitive); + case 164 /* ArrayLiteralExpression */: + return ts.forEach(node.elements, isContextSensitive); + case 182 /* ConditionalExpression */: + return isContextSensitive(node.whenTrue) || + isContextSensitive(node.whenFalse); + case 181 /* BinaryExpression */: + return node.operatorToken.kind === 52 /* BarBarToken */ && + (isContextSensitive(node.left) || isContextSensitive(node.right)); + case 245 /* PropertyAssignment */: + return isContextSensitive(node.initializer); + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: + return isContextSensitiveFunctionLikeDeclaration(node); + case 172 /* ParenthesizedExpression */: + return isContextSensitive(node.expression); + } + return false; + } + function isContextSensitiveFunctionLikeDeclaration(node) { + return !node.typeParameters && node.parameters.length && !ts.forEach(node.parameters, function (p) { return p.type; }); + } + function getTypeWithoutSignatures(type) { + if (type.flags & 80896 /* ObjectType */) { + var resolved = resolveStructuredTypeMembers(type); + if (resolved.constructSignatures.length) { + var result = createObjectType(65536 /* Anonymous */, type.symbol); + result.members = resolved.members; + result.properties = resolved.properties; + result.callSignatures = emptyArray; + result.constructSignatures = emptyArray; + type = result; + } + } + return type; + } + // TYPE CHECKING + function isTypeIdenticalTo(source, target) { + return checkTypeRelatedTo(source, target, identityRelation, /*errorNode*/ undefined); + } + function compareTypes(source, target) { + return checkTypeRelatedTo(source, target, identityRelation, /*errorNode*/ undefined) ? -1 /* True */ : 0 /* False */; + } + function isTypeSubtypeOf(source, target) { + return checkTypeSubtypeOf(source, target, /*errorNode*/ undefined); + } + function isTypeAssignableTo(source, target) { + return checkTypeAssignableTo(source, target, /*errorNode*/ undefined); + } + function checkTypeSubtypeOf(source, target, errorNode, headMessage, containingMessageChain) { + return checkTypeRelatedTo(source, target, subtypeRelation, errorNode, headMessage, containingMessageChain); + } + function checkTypeAssignableTo(source, target, errorNode, headMessage, containingMessageChain) { + return checkTypeRelatedTo(source, target, assignableRelation, errorNode, headMessage, containingMessageChain); + } + function isSignatureAssignableTo(source, target) { + var sourceType = getOrCreateTypeFromSignature(source); + var targetType = getOrCreateTypeFromSignature(target); + return checkTypeRelatedTo(sourceType, targetType, assignableRelation, /*errorNode*/ undefined); + } + /** + * Checks if 'source' is related to 'target' (e.g.: is a assignable to). + * @param source The left-hand-side of the relation. + * @param target The right-hand-side of the relation. + * @param relation The relation considered. One of 'identityRelation', 'assignableRelation', or 'subTypeRelation'. + * Used as both to determine which checks are performed and as a cache of previously computed results. + * @param errorNode The suggested node upon which all errors will be reported, if defined. This may or may not be the actual node used. + * @param headMessage If the error chain should be prepended by a head message, then headMessage will be used. + * @param containingMessageChain A chain of errors to prepend any new errors found. + */ + function checkTypeRelatedTo(source, target, relation, errorNode, headMessage, containingMessageChain) { + var errorInfo; + var sourceStack; + var targetStack; + var maybeStack; + var expandingFlags; + var depth = 0; + var overflow = false; + var elaborateErrors = false; + ts.Debug.assert(relation !== identityRelation || !errorNode, "no error reporting in identity checking"); + var result = isRelatedTo(source, target, errorNode !== undefined, headMessage); + if (overflow) { + error(errorNode, ts.Diagnostics.Excessive_stack_depth_comparing_types_0_and_1, typeToString(source), typeToString(target)); + } + else if (errorInfo) { + // If we already computed this relation, but in a context where we didn't want to report errors (e.g. overload resolution), + // then we'll only have a top-level error (e.g. 'Class X does not implement interface Y') without any details. If this happened, + // request a recompuation to get a complete error message. This will be skipped if we've already done this computation in a context + // where errors were being reported. + if (errorInfo.next === undefined) { + errorInfo = undefined; + elaborateErrors = true; + isRelatedTo(source, target, errorNode !== undefined, headMessage); + } + if (containingMessageChain) { + errorInfo = ts.concatenateDiagnosticMessageChains(containingMessageChain, errorInfo); + } + diagnostics.add(ts.createDiagnosticForNodeFromMessageChain(errorNode, errorInfo)); + } + return result !== 0 /* False */; + function reportError(message, arg0, arg1, arg2) { + errorInfo = ts.chainDiagnosticMessages(errorInfo, message, arg0, arg1, arg2); + } + function reportRelationError(message, source, target) { + var sourceType = typeToString(source); + var targetType = typeToString(target); + if (sourceType === targetType) { + sourceType = typeToString(source, /*enclosingDeclaration*/ undefined, 128 /* UseFullyQualifiedType */); + targetType = typeToString(target, /*enclosingDeclaration*/ undefined, 128 /* UseFullyQualifiedType */); + } + reportError(message || ts.Diagnostics.Type_0_is_not_assignable_to_type_1, sourceType, targetType); + } + // Compare two types and return + // Ternary.True if they are related with no assumptions, + // Ternary.Maybe if they are related with assumptions of other relationships, or + // Ternary.False if they are not related. + function isRelatedTo(source, target, reportErrors, headMessage) { + var result; + // both types are the same - covers 'they are the same primitive type or both are Any' or the same type parameter cases + if (source === target) + return -1 /* True */; + if (relation === identityRelation) { + return isIdenticalTo(source, target); + } + if (isTypeAny(target)) + return -1 /* True */; + if (source === undefinedType) + return -1 /* True */; + if (source === nullType && target !== undefinedType) + return -1 /* True */; + if (source.flags & 128 /* Enum */ && target === numberType) + return -1 /* True */; + if (source.flags & 256 /* StringLiteral */ && target === stringType) + return -1 /* True */; + if (relation === assignableRelation) { + if (isTypeAny(source)) + return -1 /* True */; + if (source === numberType && target.flags & 128 /* Enum */) + return -1 /* True */; + } + if (source.flags & 1048576 /* FreshObjectLiteral */) { + if (hasExcessProperties(source, target, reportErrors)) { + if (reportErrors) { + reportRelationError(headMessage, source, target); + } + return 0 /* False */; + } + // Above we check for excess properties with respect to the entire target type. When union + // and intersection types are further deconstructed on the target side, we don't want to + // make the check again (as it might fail for a partial target type). Therefore we obtain + // the regular source type and proceed with that. + if (target.flags & 49152 /* UnionOrIntersection */) { + source = getRegularTypeOfObjectLiteral(source); + } + } + var saveErrorInfo = errorInfo; + // Note that the "each" checks must precede the "some" checks to produce the correct results + if (source.flags & 16384 /* Union */) { + if (result = eachTypeRelatedToType(source, target, reportErrors)) { + return result; + } + } + else if (target.flags & 32768 /* Intersection */) { + if (result = typeRelatedToEachType(source, target, reportErrors)) { + return result; + } + } + else { + // It is necessary to try "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 & 32768 /* Intersection */) { + // If target is a union type the following check will report errors so we suppress them here + if (result = someTypeRelatedToType(source, target, reportErrors && !(target.flags & 16384 /* Union */))) { + return result; + } + } + if (target.flags & 16384 /* Union */) { + if (result = typeRelatedToSomeType(source, target, reportErrors)) { + return result; + } + } + } + if (source.flags & 512 /* TypeParameter */) { + var constraint = getConstraintOfTypeParameter(source); + if (!constraint || constraint.flags & 1 /* Any */) { + constraint = emptyObjectType; + } + // Report constraint errors only if the constraint is not the empty object type + var reportConstraintErrors = reportErrors && constraint !== emptyObjectType; + if (result = isRelatedTo(constraint, target, reportConstraintErrors)) { + errorInfo = saveErrorInfo; + return result; + } + } + else { + if (source.flags & 4096 /* Reference */ && target.flags & 4096 /* Reference */ && source.target === target.target) { + // We have type references to same target type, see if relationship holds for all type arguments + if (result = typeArgumentsRelatedTo(source, target, reportErrors)) { + return result; + } + } + // Even if relationship doesn't hold for unions, intersections, or generic type references, + // it may hold in a structural comparison. + var apparentType = getApparentType(source); + // 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 (apparentType.flags & (80896 /* ObjectType */ | 32768 /* Intersection */) && target.flags & 80896 /* ObjectType */) { + // Report structural errors only if we haven't reported any errors yet + var reportStructuralErrors = reportErrors && errorInfo === saveErrorInfo; + if (result = objectTypeRelatedTo(apparentType, source, target, reportStructuralErrors)) { + errorInfo = saveErrorInfo; + return result; + } + } + } + if (reportErrors) { + reportRelationError(headMessage, source, target); + } + return 0 /* False */; + } + function isIdenticalTo(source, target) { + var result; + if (source.flags & 80896 /* ObjectType */ && target.flags & 80896 /* ObjectType */) { + if (source.flags & 4096 /* Reference */ && target.flags & 4096 /* Reference */ && source.target === target.target) { + // We have type references to same target type, see if all type arguments are identical + if (result = typeArgumentsRelatedTo(source, target, /*reportErrors*/ false)) { + return result; + } + } + return objectTypeRelatedTo(source, source, target, /*reportErrors*/ false); + } + if (source.flags & 512 /* TypeParameter */ && target.flags & 512 /* TypeParameter */) { + return typeParameterIdenticalTo(source, target); + } + if (source.flags & 16384 /* Union */ && target.flags & 16384 /* Union */ || + source.flags & 32768 /* Intersection */ && target.flags & 32768 /* Intersection */) { + if (result = eachTypeRelatedToSomeType(source, target)) { + if (result &= eachTypeRelatedToSomeType(target, source)) { + return result; + } + } + } + return 0 /* False */; + } + // Check if a property with the given name is known anywhere in the given type. In an object type, a property + // is considered known if the object type is empty and the check is for assignability, if the object type has + // 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, name) { + if (type.flags & 80896 /* ObjectType */) { + var resolved = resolveStructuredTypeMembers(type); + if (relation === assignableRelation && (type === globalObjectType || resolved.properties.length === 0) || + resolved.stringIndexType || resolved.numberIndexType || getPropertyOfType(type, name)) { + return true; + } + } + else if (type.flags & 49152 /* UnionOrIntersection */) { + for (var _i = 0, _a = type.types; _i < _a.length; _i++) { + var t = _a[_i]; + if (isKnownProperty(t, name)) { + return true; + } + } + } + return false; + } + function hasExcessProperties(source, target, reportErrors) { + if (someConstituentTypeHasKind(target, 80896 /* ObjectType */)) { + for (var _i = 0, _a = getPropertiesOfObjectType(source); _i < _a.length; _i++) { + var prop = _a[_i]; + if (!isKnownProperty(target, prop.name)) { + if (reportErrors) { + // We know *exactly* where things went wrong when comparing the types. + // Use this property as the error node as this will be more helpful in + // reasoning about what went wrong. + errorNode = prop.valueDeclaration; + reportError(ts.Diagnostics.Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1, symbolToString(prop), typeToString(target)); + } + return true; + } + } + } + return false; + } + function eachTypeRelatedToSomeType(source, target) { + var result = -1 /* True */; + var sourceTypes = source.types; + for (var _i = 0; _i < sourceTypes.length; _i++) { + var sourceType = sourceTypes[_i]; + var related = typeRelatedToSomeType(sourceType, target, false); + if (!related) { + return 0 /* False */; + } + result &= related; + } + return result; + } + function typeRelatedToSomeType(source, target, reportErrors) { + var targetTypes = target.types; + for (var i = 0, len = targetTypes.length; i < len; i++) { + var related = isRelatedTo(source, targetTypes[i], reportErrors && i === len - 1); + if (related) { + return related; + } + } + return 0 /* False */; + } + function typeRelatedToEachType(source, target, reportErrors) { + var result = -1 /* True */; + var targetTypes = target.types; + for (var _i = 0; _i < targetTypes.length; _i++) { + var targetType = targetTypes[_i]; + var related = isRelatedTo(source, targetType, reportErrors); + if (!related) { + return 0 /* False */; + } + result &= related; + } + return result; + } + function someTypeRelatedToType(source, target, reportErrors) { + var sourceTypes = source.types; + for (var i = 0, len = sourceTypes.length; i < len; i++) { + var related = isRelatedTo(sourceTypes[i], target, reportErrors && i === len - 1); + if (related) { + return related; + } + } + return 0 /* False */; + } + function eachTypeRelatedToType(source, target, reportErrors) { + var result = -1 /* True */; + var sourceTypes = source.types; + for (var _i = 0; _i < sourceTypes.length; _i++) { + var sourceType = sourceTypes[_i]; + var related = isRelatedTo(sourceType, target, reportErrors); + if (!related) { + return 0 /* False */; + } + result &= related; + } + return result; + } + function typeArgumentsRelatedTo(source, target, reportErrors) { + var sources = source.typeArguments || emptyArray; + var targets = target.typeArguments || emptyArray; + if (sources.length !== targets.length && relation === identityRelation) { + return 0 /* False */; + } + var result = -1 /* True */; + for (var i = 0; i < targets.length; i++) { + var related = isRelatedTo(sources[i], targets[i], reportErrors); + if (!related) { + return 0 /* False */; + } + result &= related; + } + return result; + } + function typeParameterIdenticalTo(source, target) { + if (source.symbol.name !== target.symbol.name) { + return 0 /* False */; + } + // covers case when both type parameters does not have constraint (both equal to noConstraintType) + if (source.constraint === target.constraint) { + return -1 /* True */; + } + if (source.constraint === noConstraintType || target.constraint === noConstraintType) { + return 0 /* False */; + } + return isIdenticalTo(source.constraint, target.constraint); + } + // Determine if two object types are related by structure. First, check if the result is already available in the global cache. + // Second, check if we have already started a comparison of the given two types in which case we assume the result to be true. + // Third, check if both types are part of deeply nested chains of generic type instantiations and if so assume the types are + // equal and infinitely expanding. Fourth, if we have reached a depth of 100 nested comparisons, assume we have runaway recursion + // and issue an error. Otherwise, actually compare the structure of the two types. + function objectTypeRelatedTo(apparentSource, originalSource, target, reportErrors) { + if (overflow) { + return 0 /* False */; + } + var id = relation !== identityRelation || apparentSource.id < target.id ? apparentSource.id + "," + target.id : target.id + "," + apparentSource.id; + var related = relation[id]; + if (related !== undefined) { + // If we computed this relation already and it was failed and reported, or if we're not being asked to elaborate + // errors, we can use the cached value. Otherwise, recompute the relation + if (!elaborateErrors || (related === 3 /* FailedAndReported */)) { + return related === 1 /* Succeeded */ ? -1 /* True */ : 0 /* False */; + } + } + if (depth > 0) { + for (var i = 0; i < depth; i++) { + // If source and target are already being compared, consider them related with assumptions + if (maybeStack[i][id]) { + return 1 /* Maybe */; + } + } + if (depth === 100) { + overflow = true; + return 0 /* False */; + } + } + else { + sourceStack = []; + targetStack = []; + maybeStack = []; + expandingFlags = 0; + } + sourceStack[depth] = apparentSource; + targetStack[depth] = target; + maybeStack[depth] = {}; + maybeStack[depth][id] = 1 /* Succeeded */; + depth++; + var saveExpandingFlags = expandingFlags; + if (!(expandingFlags & 1) && isDeeplyNestedGeneric(apparentSource, sourceStack, depth)) + expandingFlags |= 1; + if (!(expandingFlags & 2) && isDeeplyNestedGeneric(target, targetStack, depth)) + expandingFlags |= 2; + var result; + if (expandingFlags === 3) { + result = 1 /* Maybe */; + } + else { + result = propertiesRelatedTo(apparentSource, target, reportErrors); + if (result) { + result &= signaturesRelatedTo(apparentSource, target, 0 /* Call */, reportErrors); + if (result) { + result &= signaturesRelatedTo(apparentSource, target, 1 /* Construct */, reportErrors); + if (result) { + result &= stringIndexTypesRelatedTo(apparentSource, originalSource, target, reportErrors); + if (result) { + result &= numberIndexTypesRelatedTo(apparentSource, originalSource, target, reportErrors); + } + } + } + } + } + expandingFlags = saveExpandingFlags; + depth--; + if (result) { + var maybeCache = maybeStack[depth]; + // If result is definitely true, copy assumptions to global cache, else copy to next level up + var destinationCache = (result === -1 /* True */ || depth === 0) ? relation : maybeStack[depth - 1]; + ts.copyMap(maybeCache, destinationCache); + } + else { + // A false result goes straight into global cache (when something is false under assumptions it + // will also be false without assumptions) + relation[id] = reportErrors ? 3 /* FailedAndReported */ : 2 /* Failed */; + } + return result; + } + function propertiesRelatedTo(source, target, reportErrors) { + if (relation === identityRelation) { + return propertiesIdenticalTo(source, target); + } + var result = -1 /* True */; + var properties = getPropertiesOfObjectType(target); + var requireOptionalProperties = relation === subtypeRelation && !(source.flags & 524288 /* ObjectLiteral */); + for (var _i = 0; _i < properties.length; _i++) { + var targetProp = properties[_i]; + var sourceProp = getPropertyOfType(source, targetProp.name); + if (sourceProp !== targetProp) { + if (!sourceProp) { + if (!(targetProp.flags & 536870912 /* Optional */) || requireOptionalProperties) { + if (reportErrors) { + reportError(ts.Diagnostics.Property_0_is_missing_in_type_1, symbolToString(targetProp), typeToString(source)); + } + return 0 /* False */; + } + } + else if (!(targetProp.flags & 134217728 /* Prototype */)) { + var sourcePropFlags = getDeclarationFlagsFromSymbol(sourceProp); + var targetPropFlags = getDeclarationFlagsFromSymbol(targetProp); + if (sourcePropFlags & 32 /* Private */ || targetPropFlags & 32 /* Private */) { + if (sourceProp.valueDeclaration !== targetProp.valueDeclaration) { + if (reportErrors) { + if (sourcePropFlags & 32 /* Private */ && targetPropFlags & 32 /* Private */) { + reportError(ts.Diagnostics.Types_have_separate_declarations_of_a_private_property_0, symbolToString(targetProp)); + } + else { + reportError(ts.Diagnostics.Property_0_is_private_in_type_1_but_not_in_type_2, symbolToString(targetProp), typeToString(sourcePropFlags & 32 /* Private */ ? source : target), typeToString(sourcePropFlags & 32 /* Private */ ? target : source)); + } + } + return 0 /* False */; + } + } + else if (targetPropFlags & 64 /* Protected */) { + var sourceDeclaredInClass = sourceProp.parent && sourceProp.parent.flags & 32 /* Class */; + var sourceClass = sourceDeclaredInClass ? getDeclaredTypeOfSymbol(sourceProp.parent) : undefined; + var targetClass = getDeclaredTypeOfSymbol(targetProp.parent); + if (!sourceClass || !hasBaseType(sourceClass, targetClass)) { + if (reportErrors) { + reportError(ts.Diagnostics.Property_0_is_protected_but_type_1_is_not_a_class_derived_from_2, symbolToString(targetProp), typeToString(sourceClass || source), typeToString(targetClass)); + } + return 0 /* False */; + } + } + else if (sourcePropFlags & 64 /* Protected */) { + if (reportErrors) { + reportError(ts.Diagnostics.Property_0_is_protected_in_type_1_but_public_in_type_2, symbolToString(targetProp), typeToString(source), typeToString(target)); + } + return 0 /* False */; + } + var related = isRelatedTo(getTypeOfSymbol(sourceProp), getTypeOfSymbol(targetProp), reportErrors); + if (!related) { + if (reportErrors) { + reportError(ts.Diagnostics.Types_of_property_0_are_incompatible, symbolToString(targetProp)); + } + return 0 /* False */; + } + result &= related; + if (sourceProp.flags & 536870912 /* Optional */ && !(targetProp.flags & 536870912 /* Optional */)) { + // TypeScript 1.0 spec (April 2014): 3.8.3 + // S is a subtype of a type T, and T is a supertype of S if ... + // S' and T are object types and, for each member M in T.. + // M is a property and S' contains a property N where + // if M is a required property, N is also a required property + // (M - property in T) + // (N - property in S) + if (reportErrors) { + reportError(ts.Diagnostics.Property_0_is_optional_in_type_1_but_required_in_type_2, symbolToString(targetProp), typeToString(source), typeToString(target)); + } + return 0 /* False */; + } + } + } + } + return result; + } + function propertiesIdenticalTo(source, target) { + if (!(source.flags & 80896 /* ObjectType */ && target.flags & 80896 /* ObjectType */)) { + return 0 /* False */; + } + var sourceProperties = getPropertiesOfObjectType(source); + var targetProperties = getPropertiesOfObjectType(target); + if (sourceProperties.length !== targetProperties.length) { + return 0 /* False */; + } + var result = -1 /* True */; + for (var _i = 0; _i < sourceProperties.length; _i++) { + var sourceProp = sourceProperties[_i]; + var targetProp = getPropertyOfObjectType(target, sourceProp.name); + if (!targetProp) { + return 0 /* False */; + } + var related = compareProperties(sourceProp, targetProp, isRelatedTo); + if (!related) { + return 0 /* False */; + } + result &= related; + } + return result; + } + function signaturesRelatedTo(source, target, kind, reportErrors) { + if (relation === identityRelation) { + return signaturesIdenticalTo(source, target, kind); + } + if (target === anyFunctionType || source === anyFunctionType) { + return -1 /* True */; + } + var sourceSignatures = getSignaturesOfType(source, kind); + var targetSignatures = getSignaturesOfType(target, kind); + var result = -1 /* True */; + var saveErrorInfo = errorInfo; + if (kind === 1 /* Construct */) { + // Only want to compare the construct signatures for abstractness guarantees. + // Because the "abstractness" of a class is the same across all construct signatures + // (internally we are checking the corresponding declaration), it is enough to perform + // the check and report an error once over all pairs of source and target construct signatures. + // + // sourceSig and targetSig are (possibly) undefined. + // + // Note that in an extends-clause, targetSignatures is stripped, so the check never proceeds. + var sourceSig = sourceSignatures[0]; + var targetSig = targetSignatures[0]; + result &= abstractSignatureRelatedTo(source, sourceSig, target, targetSig); + if (result !== -1 /* True */) { + return result; + } + } + outer: for (var _i = 0; _i < targetSignatures.length; _i++) { + var t = targetSignatures[_i]; + if (!t.hasStringLiterals || target.flags & 262144 /* FromSignature */) { + var localErrors = reportErrors; + var checkedAbstractAssignability = false; + for (var _a = 0; _a < sourceSignatures.length; _a++) { + var s = sourceSignatures[_a]; + if (!s.hasStringLiterals || source.flags & 262144 /* FromSignature */) { + var related = signatureRelatedTo(s, t, localErrors); + if (related) { + result &= related; + errorInfo = saveErrorInfo; + continue outer; + } + // Only report errors from the first failure + localErrors = false; + } + } + return 0 /* False */; + } + } + return result; + function abstractSignatureRelatedTo(source, sourceSig, target, targetSig) { + if (sourceSig && targetSig) { + var sourceDecl = source.symbol && getClassLikeDeclarationOfSymbol(source.symbol); + var targetDecl = target.symbol && getClassLikeDeclarationOfSymbol(target.symbol); + if (!sourceDecl) { + // If the source object isn't itself a class declaration, it can be freely assigned, regardless + // of whether the constructed object is abstract or not. + return -1 /* True */; + } + var sourceErasedSignature = getErasedSignature(sourceSig); + var targetErasedSignature = getErasedSignature(targetSig); + var sourceReturnType = sourceErasedSignature && getReturnTypeOfSignature(sourceErasedSignature); + var targetReturnType = targetErasedSignature && getReturnTypeOfSignature(targetErasedSignature); + var sourceReturnDecl = sourceReturnType && sourceReturnType.symbol && getClassLikeDeclarationOfSymbol(sourceReturnType.symbol); + var targetReturnDecl = targetReturnType && targetReturnType.symbol && getClassLikeDeclarationOfSymbol(targetReturnType.symbol); + var sourceIsAbstract = sourceReturnDecl && sourceReturnDecl.flags & 256 /* Abstract */; + var targetIsAbstract = targetReturnDecl && targetReturnDecl.flags & 256 /* Abstract */; + if (sourceIsAbstract && !(targetIsAbstract && targetDecl)) { + // if target isn't a class-declaration type, then it can be new'd, so we forbid the assignment. + if (reportErrors) { + reportError(ts.Diagnostics.Cannot_assign_an_abstract_constructor_type_to_a_non_abstract_constructor_type); + } + return 0 /* False */; + } + } + return -1 /* True */; + } + } + function signatureRelatedTo(source, target, reportErrors) { + if (source === target) { + return -1 /* True */; + } + if (!target.hasRestParameter && source.minArgumentCount > target.parameters.length) { + return 0 /* False */; + } + var sourceMax = source.parameters.length; + var targetMax = target.parameters.length; + var checkCount; + if (source.hasRestParameter && target.hasRestParameter) { + checkCount = sourceMax > targetMax ? sourceMax : targetMax; + sourceMax--; + targetMax--; + } + else if (source.hasRestParameter) { + sourceMax--; + checkCount = targetMax; + } + else if (target.hasRestParameter) { + targetMax--; + checkCount = sourceMax; + } + else { + checkCount = sourceMax < targetMax ? sourceMax : targetMax; + } + // Spec 1.0 Section 3.8.3 & 3.8.4: + // M and N (the signatures) are instantiated using type Any as the type argument for all type parameters declared by M and N + source = getErasedSignature(source); + target = getErasedSignature(target); + var result = -1 /* True */; + for (var i = 0; i < checkCount; i++) { + var s = i < sourceMax ? getTypeOfSymbol(source.parameters[i]) : getRestTypeOfSignature(source); + var t = i < targetMax ? getTypeOfSymbol(target.parameters[i]) : getRestTypeOfSignature(target); + var saveErrorInfo = errorInfo; + var related = isRelatedTo(s, t, reportErrors); + if (!related) { + related = isRelatedTo(t, s, false); + if (!related) { + if (reportErrors) { + reportError(ts.Diagnostics.Types_of_parameters_0_and_1_are_incompatible, source.parameters[i < sourceMax ? i : sourceMax].name, target.parameters[i < targetMax ? i : targetMax].name); + } + return 0 /* False */; + } + errorInfo = saveErrorInfo; + } + result &= related; + } + if (source.typePredicate && target.typePredicate) { + var hasDifferentParameterIndex = source.typePredicate.parameterIndex !== target.typePredicate.parameterIndex; + var hasDifferentTypes; + if (hasDifferentParameterIndex || + (hasDifferentTypes = !isTypeIdenticalTo(source.typePredicate.type, target.typePredicate.type))) { + if (reportErrors) { + var sourceParamText = source.typePredicate.parameterName; + var targetParamText = target.typePredicate.parameterName; + var sourceTypeText = typeToString(source.typePredicate.type); + var targetTypeText = typeToString(target.typePredicate.type); + if (hasDifferentParameterIndex) { + reportError(ts.Diagnostics.Parameter_0_is_not_in_the_same_position_as_parameter_1, sourceParamText, targetParamText); + } + else if (hasDifferentTypes) { + reportError(ts.Diagnostics.Type_0_is_not_assignable_to_type_1, sourceTypeText, targetTypeText); + } + reportError(ts.Diagnostics.Type_predicate_0_is_not_assignable_to_1, sourceParamText + " is " + sourceTypeText, targetParamText + " is " + targetTypeText); + } + return 0 /* False */; + } + } + else if (!source.typePredicate && target.typePredicate) { + if (reportErrors) { + reportError(ts.Diagnostics.Signature_0_must_have_a_type_predicate, signatureToString(source)); + } + return 0 /* False */; + } + var targetReturnType = getReturnTypeOfSignature(target); + if (targetReturnType === voidType) + return result; + var sourceReturnType = getReturnTypeOfSignature(source); + return result & isRelatedTo(sourceReturnType, targetReturnType, reportErrors); + } + function signaturesIdenticalTo(source, target, kind) { + var sourceSignatures = getSignaturesOfType(source, kind); + var targetSignatures = getSignaturesOfType(target, kind); + if (sourceSignatures.length !== targetSignatures.length) { + return 0 /* False */; + } + var result = -1 /* True */; + for (var i = 0, len = sourceSignatures.length; i < len; ++i) { + var related = compareSignatures(sourceSignatures[i], targetSignatures[i], /*partialMatch*/ false, /*ignoreReturnTypes*/ false, isRelatedTo); + if (!related) { + return 0 /* False */; + } + result &= related; + } + return result; + } + function stringIndexTypesRelatedTo(source, originalSource, target, reportErrors) { + if (relation === identityRelation) { + return indexTypesIdenticalTo(0 /* String */, source, target); + } + var targetType = getIndexTypeOfType(target, 0 /* String */); + if (targetType) { + if ((targetType.flags & 1 /* Any */) && !(originalSource.flags & 16777726 /* Primitive */)) { + // non-primitive assignment to any is always allowed, eg + // `var x: { [index: string]: any } = { property: 12 };` + return -1 /* True */; + } + var sourceType = getIndexTypeOfType(source, 0 /* String */); + if (!sourceType) { + if (reportErrors) { + reportError(ts.Diagnostics.Index_signature_is_missing_in_type_0, typeToString(source)); + } + return 0 /* False */; + } + var related = isRelatedTo(sourceType, targetType, reportErrors); + if (!related) { + if (reportErrors) { + reportError(ts.Diagnostics.Index_signatures_are_incompatible); + } + return 0 /* False */; + } + return related; + } + return -1 /* True */; + } + function numberIndexTypesRelatedTo(source, originalSource, target, reportErrors) { + if (relation === identityRelation) { + return indexTypesIdenticalTo(1 /* Number */, source, target); + } + var targetType = getIndexTypeOfType(target, 1 /* Number */); + if (targetType) { + if ((targetType.flags & 1 /* Any */) && !(originalSource.flags & 16777726 /* Primitive */)) { + // non-primitive assignment to any is always allowed, eg + // `var x: { [index: number]: any } = { property: 12 };` + return -1 /* True */; + } + var sourceStringType = getIndexTypeOfType(source, 0 /* String */); + var sourceNumberType = getIndexTypeOfType(source, 1 /* Number */); + if (!(sourceStringType || sourceNumberType)) { + if (reportErrors) { + reportError(ts.Diagnostics.Index_signature_is_missing_in_type_0, typeToString(source)); + } + return 0 /* False */; + } + var related; + if (sourceStringType && sourceNumberType) { + // If we know for sure we're testing both string and numeric index types then only report errors from the second one + related = isRelatedTo(sourceStringType, targetType, false) || isRelatedTo(sourceNumberType, targetType, reportErrors); + } + else { + related = isRelatedTo(sourceStringType || sourceNumberType, targetType, reportErrors); + } + if (!related) { + if (reportErrors) { + reportError(ts.Diagnostics.Index_signatures_are_incompatible); + } + return 0 /* False */; + } + return related; + } + return -1 /* True */; + } + function indexTypesIdenticalTo(indexKind, source, target) { + var targetType = getIndexTypeOfType(target, indexKind); + var sourceType = getIndexTypeOfType(source, indexKind); + if (!sourceType && !targetType) { + return -1 /* True */; + } + if (sourceType && targetType) { + return isRelatedTo(sourceType, targetType); + } + return 0 /* False */; + } + } + // Return true if the given type is part of a deeply nested chain of generic instantiations. We consider this to be the case + // when structural type comparisons have been started for 10 or more instantiations of the same generic type. It is possible, + // though highly unlikely, for this test to be true in a situation where a chain of instantiations is not infinitely expanding. + // Effectively, we will generate a false positive when two types are structurally equal to at least 10 levels, but unequal at + // some level beyond that. + function isDeeplyNestedGeneric(type, stack, depth) { + // We track type references (created by createTypeReference) and instantiated types (created by instantiateType) + if (type.flags & (4096 /* Reference */ | 131072 /* Instantiated */) && depth >= 5) { + var symbol = type.symbol; + var count = 0; + for (var i = 0; i < depth; i++) { + var t = stack[i]; + if (t.flags & (4096 /* Reference */ | 131072 /* Instantiated */) && t.symbol === symbol) { + count++; + if (count >= 5) + return true; + } + } + } + return false; + } + function isPropertyIdenticalTo(sourceProp, targetProp) { + return compareProperties(sourceProp, targetProp, compareTypes) !== 0 /* False */; + } + function compareProperties(sourceProp, targetProp, compareTypes) { + // Two members are considered identical when + // - they are public properties with identical names, optionality, and types, + // - they are private or protected properties originating in the same declaration and having identical types + if (sourceProp === targetProp) { + return -1 /* True */; + } + var sourcePropAccessibility = getDeclarationFlagsFromSymbol(sourceProp) & (32 /* Private */ | 64 /* Protected */); + var targetPropAccessibility = getDeclarationFlagsFromSymbol(targetProp) & (32 /* Private */ | 64 /* Protected */); + if (sourcePropAccessibility !== targetPropAccessibility) { + return 0 /* False */; + } + if (sourcePropAccessibility) { + if (getTargetSymbol(sourceProp) !== getTargetSymbol(targetProp)) { + return 0 /* False */; + } + } + else { + if ((sourceProp.flags & 536870912 /* Optional */) !== (targetProp.flags & 536870912 /* Optional */)) { + return 0 /* False */; + } + } + return compareTypes(getTypeOfSymbol(sourceProp), getTypeOfSymbol(targetProp)); + } + function compareSignatures(source, target, partialMatch, ignoreReturnTypes, compareTypes) { + if (source === target) { + return -1 /* True */; + } + if (source.parameters.length !== target.parameters.length || + source.minArgumentCount !== target.minArgumentCount || + source.hasRestParameter !== target.hasRestParameter) { + if (!partialMatch || + source.parameters.length < target.parameters.length && !source.hasRestParameter || + source.minArgumentCount > target.minArgumentCount) { + return 0 /* False */; + } + } + var result = -1 /* True */; + if (source.typeParameters && target.typeParameters) { + if (source.typeParameters.length !== target.typeParameters.length) { + return 0 /* False */; + } + for (var i = 0, len = source.typeParameters.length; i < len; ++i) { + var related = compareTypes(source.typeParameters[i], target.typeParameters[i]); + if (!related) { + return 0 /* False */; + } + result &= related; + } + } + else if (source.typeParameters || target.typeParameters) { + return 0 /* False */; + } + // Spec 1.0 Section 3.8.3 & 3.8.4: + // M and N (the signatures) are instantiated using type Any as the type argument for all type parameters declared by M and N + source = getErasedSignature(source); + target = getErasedSignature(target); + var targetLen = target.parameters.length; + for (var i = 0; i < targetLen; i++) { + var s = isRestParameterIndex(source, i) ? getRestTypeOfSignature(source) : getTypeOfSymbol(source.parameters[i]); + var t = isRestParameterIndex(target, i) ? getRestTypeOfSignature(target) : getTypeOfSymbol(target.parameters[i]); + var related = compareTypes(s, t); + if (!related) { + return 0 /* False */; + } + result &= related; + } + if (!ignoreReturnTypes) { + result &= compareTypes(getReturnTypeOfSignature(source), getReturnTypeOfSignature(target)); + } + return result; + } + function isRestParameterIndex(signature, parameterIndex) { + return signature.hasRestParameter && parameterIndex >= signature.parameters.length - 1; + } + function isSupertypeOfEach(candidate, types) { + for (var _i = 0; _i < types.length; _i++) { + var type = types[_i]; + if (candidate !== type && !isTypeSubtypeOf(type, candidate)) + return false; + } + return true; + } + function getCommonSupertype(types) { + return ts.forEach(types, function (t) { return isSupertypeOfEach(t, types) ? t : undefined; }); + } + function reportNoCommonSupertypeError(types, errorLocation, errorMessageChainHead) { + // The downfallType/bestSupertypeDownfallType is the first type that caused a particular candidate + // to not be the common supertype. So if it weren't for this one downfallType (and possibly others), + // the type in question could have been the common supertype. + var bestSupertype; + var bestSupertypeDownfallType; + var bestSupertypeScore = 0; + for (var i = 0; i < types.length; i++) { + var score = 0; + var downfallType = undefined; + for (var j = 0; j < types.length; j++) { + if (isTypeSubtypeOf(types[j], types[i])) { + score++; + } + else if (!downfallType) { + downfallType = types[j]; + } + } + ts.Debug.assert(!!downfallType, "If there is no common supertype, each type should have a downfallType"); + if (score > bestSupertypeScore) { + bestSupertype = types[i]; + bestSupertypeDownfallType = downfallType; + bestSupertypeScore = score; + } + // types.length - 1 is the maximum score, given that getCommonSupertype returned false + if (bestSupertypeScore === types.length - 1) { + break; + } + } + // In the following errors, the {1} slot is before the {0} slot because checkTypeSubtypeOf supplies the + // subtype as the first argument to the error + checkTypeSubtypeOf(bestSupertypeDownfallType, bestSupertype, errorLocation, ts.Diagnostics.Type_argument_candidate_1_is_not_a_valid_type_argument_because_it_is_not_a_supertype_of_candidate_0, errorMessageChainHead); + } + function isArrayType(type) { + return type.flags & 4096 /* Reference */ && type.target === globalArrayType; + } + function isArrayLikeType(type) { + // A type is array-like if it is not the undefined or null type and if it is assignable to any[] + return !(type.flags & (32 /* Undefined */ | 64 /* Null */)) && isTypeAssignableTo(type, anyArrayType); + } + function isTupleLikeType(type) { + return !!getPropertyOfType(type, "0"); + } + /** + * Check if a Type was written as a tuple type literal. + * Prefer using isTupleLikeType() unless the use of `elementTypes` is required. + */ + function isTupleType(type) { + return !!(type.flags & 8192 /* Tuple */); + } + function getRegularTypeOfObjectLiteral(type) { + if (type.flags & 1048576 /* FreshObjectLiteral */) { + var regularType = type.regularType; + if (!regularType) { + regularType = createType(type.flags & ~1048576 /* FreshObjectLiteral */); + regularType.symbol = type.symbol; + regularType.members = type.members; + regularType.properties = type.properties; + regularType.callSignatures = type.callSignatures; + regularType.constructSignatures = type.constructSignatures; + regularType.stringIndexType = type.stringIndexType; + regularType.numberIndexType = type.numberIndexType; + type.regularType = regularType; + } + return regularType; + } + return type; + } + function getWidenedTypeOfObjectLiteral(type) { + var properties = getPropertiesOfObjectType(type); + var members = {}; + ts.forEach(properties, function (p) { + var propType = getTypeOfSymbol(p); + var widenedType = getWidenedType(propType); + if (propType !== widenedType) { + var symbol = createSymbol(p.flags | 67108864 /* Transient */, p.name); + symbol.declarations = p.declarations; + symbol.parent = p.parent; + symbol.type = widenedType; + symbol.target = p; + if (p.valueDeclaration) + symbol.valueDeclaration = p.valueDeclaration; + p = symbol; + } + members[p.name] = p; + }); + var stringIndexType = getIndexTypeOfType(type, 0 /* String */); + var numberIndexType = getIndexTypeOfType(type, 1 /* Number */); + if (stringIndexType) + stringIndexType = getWidenedType(stringIndexType); + if (numberIndexType) + numberIndexType = getWidenedType(numberIndexType); + return createAnonymousType(type.symbol, members, emptyArray, emptyArray, stringIndexType, numberIndexType); + } + function getWidenedType(type) { + if (type.flags & 6291456 /* RequiresWidening */) { + if (type.flags & (32 /* Undefined */ | 64 /* Null */)) { + return anyType; + } + if (type.flags & 524288 /* ObjectLiteral */) { + return getWidenedTypeOfObjectLiteral(type); + } + if (type.flags & 16384 /* Union */) { + return getUnionType(ts.map(type.types, getWidenedType), /*noSubtypeReduction*/ true); + } + if (isArrayType(type)) { + return createArrayType(getWidenedType(type.typeArguments[0])); + } + if (isTupleType(type)) { + return createTupleType(ts.map(type.elementTypes, getWidenedType)); + } + } + return type; + } + /** + * Reports implicit any errors that occur as a result of widening 'null' and 'undefined' + * to 'any'. A call to reportWideningErrorsInType is normally accompanied by a call to + * getWidenedType. But in some cases getWidenedType is called without reporting errors + * (type argument inference is an example). + * + * The return value indicates whether an error was in fact reported. The particular circumstances + * are on a best effort basis. Currently, if the null or undefined that causes widening is inside + * an object literal property (arbitrarily deeply), this function reports an error. If no error is + * reported, reportImplicitAnyError is a suitable fallback to report a general error. + */ + function reportWideningErrorsInType(type) { + var errorReported = false; + if (type.flags & 16384 /* Union */) { + for (var _i = 0, _a = type.types; _i < _a.length; _i++) { + var t = _a[_i]; + if (reportWideningErrorsInType(t)) { + errorReported = true; + } + } + } + if (isArrayType(type)) { + return reportWideningErrorsInType(type.typeArguments[0]); + } + if (isTupleType(type)) { + for (var _b = 0, _c = type.elementTypes; _b < _c.length; _b++) { + var t = _c[_b]; + if (reportWideningErrorsInType(t)) { + errorReported = true; + } + } + } + if (type.flags & 524288 /* ObjectLiteral */) { + for (var _d = 0, _e = getPropertiesOfObjectType(type); _d < _e.length; _d++) { + var p = _e[_d]; + var t = getTypeOfSymbol(p); + if (t.flags & 2097152 /* ContainsUndefinedOrNull */) { + if (!reportWideningErrorsInType(t)) { + error(p.valueDeclaration, ts.Diagnostics.Object_literal_s_property_0_implicitly_has_an_1_type, p.name, typeToString(getWidenedType(t))); + } + errorReported = true; + } + } + } + return errorReported; + } + function reportImplicitAnyError(declaration, type) { + var typeAsString = typeToString(getWidenedType(type)); + var diagnostic; + switch (declaration.kind) { + case 141 /* PropertyDeclaration */: + case 140 /* PropertySignature */: + diagnostic = ts.Diagnostics.Member_0_implicitly_has_an_1_type; + break; + case 138 /* Parameter */: + diagnostic = declaration.dotDotDotToken ? + ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type : + ts.Diagnostics.Parameter_0_implicitly_has_an_1_type; + break; + case 213 /* FunctionDeclaration */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: + case 173 /* FunctionExpression */: + case 174 /* ArrowFunction */: + if (!declaration.name) { + error(declaration, ts.Diagnostics.Function_expression_which_lacks_return_type_annotation_implicitly_has_an_0_return_type, typeAsString); + return; + } + diagnostic = ts.Diagnostics._0_which_lacks_return_type_annotation_implicitly_has_an_1_return_type; + break; + default: + diagnostic = ts.Diagnostics.Variable_0_implicitly_has_an_1_type; + } + error(declaration, diagnostic, ts.declarationNameToString(declaration.name), typeAsString); + } + function reportErrorsFromWidening(declaration, type) { + if (produceDiagnostics && compilerOptions.noImplicitAny && type.flags & 2097152 /* ContainsUndefinedOrNull */) { + // Report implicit any error within type if possible, otherwise report error on declaration + if (!reportWideningErrorsInType(type)) { + reportImplicitAnyError(declaration, type); + } + } + } + function forEachMatchingParameterType(source, target, callback) { + var sourceMax = source.parameters.length; + var targetMax = target.parameters.length; + var count; + if (source.hasRestParameter && target.hasRestParameter) { + count = sourceMax > targetMax ? sourceMax : targetMax; + sourceMax--; + targetMax--; + } + else if (source.hasRestParameter) { + sourceMax--; + count = targetMax; + } + else if (target.hasRestParameter) { + targetMax--; + count = sourceMax; + } + else { + count = sourceMax < targetMax ? sourceMax : targetMax; + } + for (var i = 0; i < count; i++) { + var s = i < sourceMax ? getTypeOfSymbol(source.parameters[i]) : getRestTypeOfSignature(source); + var t = i < targetMax ? getTypeOfSymbol(target.parameters[i]) : getRestTypeOfSignature(target); + callback(s, t); + } + } + function createInferenceContext(typeParameters, inferUnionTypes) { + var inferences = []; + for (var _i = 0; _i < typeParameters.length; _i++) { + var unused = typeParameters[_i]; + inferences.push({ + primary: undefined, secondary: undefined, isFixed: false + }); + } + return { + typeParameters: typeParameters, + inferUnionTypes: inferUnionTypes, + inferences: inferences, + inferredTypes: new Array(typeParameters.length) + }; + } + function inferTypes(context, source, target) { + var sourceStack; + var targetStack; + var depth = 0; + var inferiority = 0; + inferFromTypes(source, target); + function isInProcess(source, target) { + for (var i = 0; i < depth; i++) { + if (source === sourceStack[i] && target === targetStack[i]) { + return true; + } + } + return false; + } + function inferFromTypes(source, target) { + if (target.flags & 512 /* TypeParameter */) { + // If target is a type parameter, make an inference, unless the source type contains + // the anyFunctionType (the wildcard type that's used to avoid contextually typing functions). + // Because the anyFunctionType is internal, it should not be exposed to the user by adding + // it as an inference candidate. Hopefully, a better candidate will come along that does + // not contain anyFunctionType when we come back to this argument for its second round + // of inference. + if (source.flags & 8388608 /* ContainsAnyFunctionType */) { + return; + } + var typeParameters = context.typeParameters; + for (var i = 0; i < typeParameters.length; i++) { + if (target === typeParameters[i]) { + var inferences = context.inferences[i]; + if (!inferences.isFixed) { + // Any inferences that are made to a type parameter in a union type are inferior + // to inferences made to a flat (non-union) type. This is because if we infer to + // T | string[], we really don't know if we should be inferring to T or not (because + // the correct constituent on the target side could be string[]). Therefore, we put + // such inferior inferences into a secondary bucket, and only use them if the primary + // bucket is empty. + var candidates = inferiority ? + inferences.secondary || (inferences.secondary = []) : + inferences.primary || (inferences.primary = []); + if (!ts.contains(candidates, source)) { + candidates.push(source); + } + } + return; + } + } + } + else if (source.flags & 4096 /* Reference */ && target.flags & 4096 /* Reference */ && source.target === target.target) { + // If source and target are references to the same generic type, infer from type arguments + var sourceTypes = source.typeArguments || emptyArray; + var targetTypes = target.typeArguments || emptyArray; + var count = sourceTypes.length < targetTypes.length ? sourceTypes.length : targetTypes.length; + for (var i = 0; i < count; i++) { + inferFromTypes(sourceTypes[i], targetTypes[i]); + } + } + else if (source.flags & 8192 /* Tuple */ && target.flags & 8192 /* Tuple */ && source.elementTypes.length === target.elementTypes.length) { + // If source and target are tuples of the same size, infer from element types + var sourceTypes = source.elementTypes; + var targetTypes = target.elementTypes; + for (var i = 0; i < sourceTypes.length; i++) { + inferFromTypes(sourceTypes[i], targetTypes[i]); + } + } + else if (target.flags & 49152 /* UnionOrIntersection */) { + var targetTypes = target.types; + var typeParameterCount = 0; + var typeParameter; + // First infer to each type in union or intersection that isn't a type parameter + for (var _i = 0; _i < targetTypes.length; _i++) { + var t = targetTypes[_i]; + if (t.flags & 512 /* TypeParameter */ && ts.contains(context.typeParameters, t)) { + typeParameter = t; + typeParameterCount++; + } + else { + inferFromTypes(source, t); + } + } + // Next, if target is a union type containing a single naked type parameter, make a + // secondary inference to that type parameter. We don't do this for intersection types + // because in a target type like Foo & T we don't know how which parts of the source type + // should be matched by Foo and which should be inferred to T. + if (target.flags & 16384 /* Union */ && typeParameterCount === 1) { + inferiority++; + inferFromTypes(source, typeParameter); + inferiority--; + } + } + else if (source.flags & 49152 /* UnionOrIntersection */) { + // Source is a union or intersection type, infer from each consituent type + var sourceTypes = source.types; + for (var _a = 0; _a < sourceTypes.length; _a++) { + var sourceType = sourceTypes[_a]; + inferFromTypes(sourceType, target); + } + } + else { + source = getApparentType(source); + if (source.flags & 80896 /* ObjectType */ && (target.flags & (4096 /* Reference */ | 8192 /* Tuple */) || + (target.flags & 65536 /* Anonymous */) && target.symbol && target.symbol.flags & (8192 /* Method */ | 2048 /* TypeLiteral */ | 32 /* Class */))) { + // If source is an object type, and target is a type reference, a tuple type, the type of a method, or a type literal, infer from members + if (isInProcess(source, target)) { + return; + } + if (isDeeplyNestedGeneric(source, sourceStack, depth) && isDeeplyNestedGeneric(target, targetStack, depth)) { + return; + } + if (depth === 0) { + sourceStack = []; + targetStack = []; + } + sourceStack[depth] = source; + targetStack[depth] = target; + depth++; + inferFromProperties(source, target); + inferFromSignatures(source, target, 0 /* Call */); + inferFromSignatures(source, target, 1 /* Construct */); + inferFromIndexTypes(source, target, 0 /* String */, 0 /* String */); + inferFromIndexTypes(source, target, 1 /* Number */, 1 /* Number */); + inferFromIndexTypes(source, target, 0 /* String */, 1 /* Number */); + depth--; + } + } + } + function inferFromProperties(source, target) { + var properties = getPropertiesOfObjectType(target); + for (var _i = 0; _i < properties.length; _i++) { + var targetProp = properties[_i]; + var sourceProp = getPropertyOfObjectType(source, targetProp.name); + if (sourceProp) { + inferFromTypes(getTypeOfSymbol(sourceProp), getTypeOfSymbol(targetProp)); + } + } + } + function inferFromSignatures(source, target, kind) { + var sourceSignatures = getSignaturesOfType(source, kind); + var targetSignatures = getSignaturesOfType(target, kind); + var sourceLen = sourceSignatures.length; + var targetLen = targetSignatures.length; + var len = sourceLen < targetLen ? sourceLen : targetLen; + for (var i = 0; i < len; i++) { + inferFromSignature(getErasedSignature(sourceSignatures[sourceLen - len + i]), getErasedSignature(targetSignatures[targetLen - len + i])); + } + } + function inferFromSignature(source, target) { + forEachMatchingParameterType(source, target, inferFromTypes); + if (source.typePredicate && target.typePredicate) { + if (target.typePredicate.parameterIndex === source.typePredicate.parameterIndex) { + // Return types from type predicates are treated as booleans. In order to infer types + // from type predicates we would need to infer using the type within the type predicate + // (i.e. 'Foo' from 'x is Foo'). + inferFromTypes(source.typePredicate.type, target.typePredicate.type); + } + } + else { + inferFromTypes(getReturnTypeOfSignature(source), getReturnTypeOfSignature(target)); + } + } + function inferFromIndexTypes(source, target, sourceKind, targetKind) { + var targetIndexType = getIndexTypeOfType(target, targetKind); + if (targetIndexType) { + var sourceIndexType = getIndexTypeOfType(source, sourceKind); + if (sourceIndexType) { + inferFromTypes(sourceIndexType, targetIndexType); + } + } + } + } + function getInferenceCandidates(context, index) { + var inferences = context.inferences[index]; + return inferences.primary || inferences.secondary || emptyArray; + } + function getInferredType(context, index) { + var inferredType = context.inferredTypes[index]; + var inferenceSucceeded; + if (!inferredType) { + var inferences = getInferenceCandidates(context, index); + if (inferences.length) { + // Infer widened union or supertype, or the unknown type for no common supertype + var unionOrSuperType = context.inferUnionTypes ? getUnionType(inferences) : getCommonSupertype(inferences); + inferredType = unionOrSuperType ? getWidenedType(unionOrSuperType) : unknownType; + inferenceSucceeded = !!unionOrSuperType; + } + else { + // Infer the empty object type when no inferences were made. It is important to remember that + // in this case, inference still succeeds, meaning there is no error for not having inference + // candidates. An inference error only occurs when there are *conflicting* candidates, i.e. + // candidates with no common supertype. + inferredType = emptyObjectType; + inferenceSucceeded = true; + } + // Only do the constraint check if inference succeeded (to prevent cascading errors) + if (inferenceSucceeded) { + var constraint = getConstraintOfTypeParameter(context.typeParameters[index]); + inferredType = constraint && !isTypeAssignableTo(inferredType, constraint) ? constraint : inferredType; + } + else if (context.failedTypeParameterIndex === undefined || context.failedTypeParameterIndex > index) { + // If inference failed, it is necessary to record the index of the failed type parameter (the one we are on). + // It might be that inference has already failed on a later type parameter on a previous call to inferTypeArguments. + // So if this failure is on preceding type parameter, this type parameter is the new failure index. + context.failedTypeParameterIndex = index; + } + context.inferredTypes[index] = inferredType; + } + return inferredType; + } + function getInferredTypes(context) { + for (var i = 0; i < context.inferredTypes.length; i++) { + getInferredType(context, i); + } + return context.inferredTypes; + } + function hasAncestor(node, kind) { + return ts.getAncestor(node, kind) !== undefined; + } + // EXPRESSION TYPE CHECKING + function getResolvedSymbol(node) { + var links = getNodeLinks(node); + if (!links.resolvedSymbol) { + links.resolvedSymbol = (!ts.nodeIsMissing(node) && resolveName(node, node.text, 107455 /* Value */ | 1048576 /* ExportValue */, ts.Diagnostics.Cannot_find_name_0, node)) || unknownSymbol; + } + return links.resolvedSymbol; + } + function isInTypeQuery(node) { + // TypeScript 1.0 spec (April 2014): 3.6.3 + // A type query consists of the keyword typeof followed by an expression. + // The expression is restricted to a single identifier or a sequence of identifiers separated by periods + while (node) { + switch (node.kind) { + case 154 /* TypeQuery */: + return true; + case 69 /* Identifier */: + case 135 /* QualifiedName */: + node = node.parent; + continue; + default: + return false; + } + } + ts.Debug.fail("should not get here"); + } + // For a union type, remove all constituent types that are of the given type kind (when isOfTypeKind is true) + // or not of the given type kind (when isOfTypeKind is false) + function removeTypesFromUnionType(type, typeKind, isOfTypeKind, allowEmptyUnionResult) { + if (type.flags & 16384 /* Union */) { + var types = type.types; + if (ts.forEach(types, function (t) { return !!(t.flags & typeKind) === isOfTypeKind; })) { + // Above we checked if we have anything to remove, now use the opposite test to do the removal + var narrowedType = getUnionType(ts.filter(types, function (t) { return !(t.flags & typeKind) === isOfTypeKind; })); + if (allowEmptyUnionResult || narrowedType !== emptyObjectType) { + return narrowedType; + } + } + } + else if (allowEmptyUnionResult && !!(type.flags & typeKind) === isOfTypeKind) { + // Use getUnionType(emptyArray) instead of emptyObjectType in case the way empty union types + // are represented ever changes. + return getUnionType(emptyArray); + } + return type; + } + function hasInitializer(node) { + return !!(node.initializer || ts.isBindingPattern(node.parent) && hasInitializer(node.parent.parent)); + } + // Check if a given variable is assigned within a given syntax node + function isVariableAssignedWithin(symbol, node) { + var links = getNodeLinks(node); + if (links.assignmentChecks) { + var cachedResult = links.assignmentChecks[symbol.id]; + if (cachedResult !== undefined) { + return cachedResult; + } + } + else { + links.assignmentChecks = {}; + } + return links.assignmentChecks[symbol.id] = isAssignedIn(node); + function isAssignedInBinaryExpression(node) { + if (node.operatorToken.kind >= 56 /* FirstAssignment */ && node.operatorToken.kind <= 68 /* LastAssignment */) { + var n = node.left; + while (n.kind === 172 /* ParenthesizedExpression */) { + n = n.expression; + } + if (n.kind === 69 /* Identifier */ && getResolvedSymbol(n) === symbol) { + return true; + } + } + return ts.forEachChild(node, isAssignedIn); + } + function isAssignedInVariableDeclaration(node) { + if (!ts.isBindingPattern(node.name) && getSymbolOfNode(node) === symbol && hasInitializer(node)) { + return true; + } + return ts.forEachChild(node, isAssignedIn); + } + function isAssignedIn(node) { + switch (node.kind) { + case 181 /* BinaryExpression */: + return isAssignedInBinaryExpression(node); + case 211 /* VariableDeclaration */: + case 163 /* BindingElement */: + return isAssignedInVariableDeclaration(node); + case 161 /* ObjectBindingPattern */: + case 162 /* ArrayBindingPattern */: + case 164 /* ArrayLiteralExpression */: + case 165 /* ObjectLiteralExpression */: + case 166 /* PropertyAccessExpression */: + case 167 /* ElementAccessExpression */: + case 168 /* CallExpression */: + case 169 /* NewExpression */: + case 171 /* TypeAssertionExpression */: + case 189 /* AsExpression */: + case 172 /* ParenthesizedExpression */: + case 179 /* PrefixUnaryExpression */: + case 175 /* DeleteExpression */: + case 178 /* AwaitExpression */: + case 176 /* TypeOfExpression */: + case 177 /* VoidExpression */: + case 180 /* PostfixUnaryExpression */: + case 184 /* YieldExpression */: + case 182 /* ConditionalExpression */: + case 185 /* SpreadElementExpression */: + case 192 /* Block */: + case 193 /* VariableStatement */: + case 195 /* ExpressionStatement */: + case 196 /* IfStatement */: + case 197 /* DoStatement */: + case 198 /* WhileStatement */: + case 199 /* ForStatement */: + case 200 /* ForInStatement */: + case 201 /* ForOfStatement */: + case 204 /* ReturnStatement */: + case 205 /* WithStatement */: + case 206 /* SwitchStatement */: + case 241 /* CaseClause */: + case 242 /* DefaultClause */: + case 207 /* LabeledStatement */: + case 208 /* ThrowStatement */: + case 209 /* TryStatement */: + case 244 /* CatchClause */: + case 233 /* JsxElement */: + case 234 /* JsxSelfClosingElement */: + case 238 /* JsxAttribute */: + case 239 /* JsxSpreadAttribute */: + case 235 /* JsxOpeningElement */: + case 240 /* JsxExpression */: + return ts.forEachChild(node, isAssignedIn); + } + return false; + } + } + // Get the narrowed type of a given symbol at a given location + function getNarrowedTypeOfSymbol(symbol, node) { + var type = getTypeOfSymbol(symbol); + // Only narrow when symbol is variable of type any or an object, union, or type parameter type + if (node && symbol.flags & 3 /* Variable */) { + if (isTypeAny(type) || type.flags & (80896 /* ObjectType */ | 16384 /* Union */ | 512 /* TypeParameter */)) { + loop: while (node.parent) { + var child = node; + node = node.parent; + var narrowedType = type; + switch (node.kind) { + case 196 /* IfStatement */: + // In a branch of an if statement, narrow based on controlling expression + if (child !== node.expression) { + narrowedType = narrowType(type, node.expression, /*assumeTrue*/ child === node.thenStatement); + } + break; + case 182 /* ConditionalExpression */: + // In a branch of a conditional expression, narrow based on controlling condition + if (child !== node.condition) { + narrowedType = narrowType(type, node.condition, /*assumeTrue*/ child === node.whenTrue); + } + break; + case 181 /* BinaryExpression */: + // In the right operand of an && or ||, narrow based on left operand + if (child === node.right) { + if (node.operatorToken.kind === 51 /* AmpersandAmpersandToken */) { + narrowedType = narrowType(type, node.left, /*assumeTrue*/ true); + } + else if (node.operatorToken.kind === 52 /* BarBarToken */) { + narrowedType = narrowType(type, node.left, /*assumeTrue*/ false); + } + } + break; + case 248 /* SourceFile */: + case 218 /* ModuleDeclaration */: + case 213 /* FunctionDeclaration */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: + case 144 /* Constructor */: + // Stop at the first containing function or module declaration + break loop; + } + // Use narrowed type if construct contains no assignments to variable + if (narrowedType !== type) { + if (isVariableAssignedWithin(symbol, node)) { + break; + } + type = narrowedType; + } + } + } + } + return type; + function narrowTypeByEquality(type, expr, assumeTrue) { + // Check that we have 'typeof ' on the left and string literal on the right + if (expr.left.kind !== 176 /* TypeOfExpression */ || expr.right.kind !== 9 /* StringLiteral */) { + return type; + } + var left = expr.left; + var right = expr.right; + if (left.expression.kind !== 69 /* Identifier */ || getResolvedSymbol(left.expression) !== symbol) { + return type; + } + var typeInfo = primitiveTypeInfo[right.text]; + if (expr.operatorToken.kind === 33 /* ExclamationEqualsEqualsToken */) { + assumeTrue = !assumeTrue; + } + if (assumeTrue) { + // Assumed result is true. If check was not for a primitive type, remove all primitive types + if (!typeInfo) { + return removeTypesFromUnionType(type, /*typeKind*/ 258 /* StringLike */ | 132 /* NumberLike */ | 8 /* Boolean */ | 16777216 /* ESSymbol */, + /*isOfTypeKind*/ true, /*allowEmptyUnionResult*/ false); + } + // Check was for a primitive type, return that primitive type if it is a subtype + if (isTypeSubtypeOf(typeInfo.type, type)) { + return typeInfo.type; + } + // Otherwise, remove all types that aren't of the primitive type kind. This can happen when the type is + // union of enum types and other types. + return removeTypesFromUnionType(type, /*typeKind*/ typeInfo.flags, /*isOfTypeKind*/ false, /*allowEmptyUnionResult*/ false); + } + else { + // Assumed result is false. If check was for a primitive type, remove that primitive type + if (typeInfo) { + return removeTypesFromUnionType(type, /*typeKind*/ typeInfo.flags, /*isOfTypeKind*/ true, /*allowEmptyUnionResult*/ false); + } + // Otherwise we don't have enough information to do anything. + return type; + } + } + function narrowTypeByAnd(type, expr, assumeTrue) { + if (assumeTrue) { + // The assumed result is true, therefore we narrow assuming each operand to be true. + return narrowType(narrowType(type, expr.left, /*assumeTrue*/ true), expr.right, /*assumeTrue*/ true); + } + else { + // The assumed result is false. This means either the first operand was false, or the first operand was true + // and the second operand was false. We narrow with those assumptions and union the two resulting types. + return getUnionType([ + narrowType(type, expr.left, /*assumeTrue*/ false), + narrowType(narrowType(type, expr.left, /*assumeTrue*/ true), expr.right, /*assumeTrue*/ false) + ]); + } + } + function narrowTypeByOr(type, expr, assumeTrue) { + if (assumeTrue) { + // The assumed result is true. This means either the first operand was true, or the first operand was false + // and the second operand was true. We narrow with those assumptions and union the two resulting types. + return getUnionType([ + narrowType(type, expr.left, /*assumeTrue*/ true), + narrowType(narrowType(type, expr.left, /*assumeTrue*/ false), expr.right, /*assumeTrue*/ true) + ]); + } + else { + // The assumed result is false, therefore we narrow assuming each operand to be false. + return narrowType(narrowType(type, expr.left, /*assumeTrue*/ false), expr.right, /*assumeTrue*/ false); + } + } + function narrowTypeByInstanceof(type, expr, assumeTrue) { + // Check that type is not any, assumed result is true, and we have variable symbol on the left + if (isTypeAny(type) || !assumeTrue || expr.left.kind !== 69 /* Identifier */ || getResolvedSymbol(expr.left) !== symbol) { + return type; + } + // Check that right operand is a function type with a prototype property + var rightType = checkExpression(expr.right); + if (!isTypeSubtypeOf(rightType, globalFunctionType)) { + return type; + } + var targetType; + var prototypeProperty = getPropertyOfType(rightType, "prototype"); + if (prototypeProperty) { + // Target type is type of the prototype property + var prototypePropertyType = getTypeOfSymbol(prototypeProperty); + if (!isTypeAny(prototypePropertyType)) { + targetType = prototypePropertyType; + } + } + if (!targetType) { + // Target type is type of construct signature + var constructSignatures; + if (rightType.flags & 2048 /* Interface */) { + constructSignatures = resolveDeclaredMembers(rightType).declaredConstructSignatures; + } + else if (rightType.flags & 65536 /* Anonymous */) { + constructSignatures = getSignaturesOfType(rightType, 1 /* Construct */); + } + if (constructSignatures && constructSignatures.length) { + targetType = getUnionType(ts.map(constructSignatures, function (signature) { return getReturnTypeOfSignature(getErasedSignature(signature)); })); + } + } + if (targetType) { + return getNarrowedType(type, targetType); + } + return type; + } + function getNarrowedType(originalType, narrowedTypeCandidate) { + // If the current type is a union type, remove all constituents that aren't assignable to target. If that produces + // 0 candidates, fall back to the assignability check + if (originalType.flags & 16384 /* Union */) { + var assignableConstituents = ts.filter(originalType.types, function (t) { return isTypeAssignableTo(t, narrowedTypeCandidate); }); + if (assignableConstituents.length) { + return getUnionType(assignableConstituents); + } + } + if (isTypeAssignableTo(narrowedTypeCandidate, originalType)) { + // Narrow to the target type if it's assignable to the current type + return narrowedTypeCandidate; + } + return originalType; + } + function narrowTypeByTypePredicate(type, expr, assumeTrue) { + if (type.flags & 1 /* Any */) { + return type; + } + var signature = getResolvedSignature(expr); + if (signature.typePredicate && + expr.arguments[signature.typePredicate.parameterIndex] && + getSymbolAtLocation(expr.arguments[signature.typePredicate.parameterIndex]) === symbol) { + if (!assumeTrue) { + if (type.flags & 16384 /* Union */) { + return getUnionType(ts.filter(type.types, function (t) { return !isTypeSubtypeOf(t, signature.typePredicate.type); })); + } + return type; + } + return getNarrowedType(type, signature.typePredicate.type); + } + return type; + } + // Narrow the given type based on the given expression having the assumed boolean value. The returned type + // will be a subtype or the same type as the argument. + function narrowType(type, expr, assumeTrue) { + switch (expr.kind) { + case 168 /* CallExpression */: + return narrowTypeByTypePredicate(type, expr, assumeTrue); + case 172 /* ParenthesizedExpression */: + return narrowType(type, expr.expression, assumeTrue); + case 181 /* BinaryExpression */: + var operator = expr.operatorToken.kind; + if (operator === 32 /* EqualsEqualsEqualsToken */ || operator === 33 /* ExclamationEqualsEqualsToken */) { + return narrowTypeByEquality(type, expr, assumeTrue); + } + else if (operator === 51 /* AmpersandAmpersandToken */) { + return narrowTypeByAnd(type, expr, assumeTrue); + } + else if (operator === 52 /* BarBarToken */) { + return narrowTypeByOr(type, expr, assumeTrue); + } + else if (operator === 91 /* InstanceOfKeyword */) { + return narrowTypeByInstanceof(type, expr, assumeTrue); + } + break; + case 179 /* PrefixUnaryExpression */: + if (expr.operator === 49 /* ExclamationToken */) { + return narrowType(type, expr.operand, !assumeTrue); + } + break; + } + return type; + } + } + function checkIdentifier(node) { + var symbol = getResolvedSymbol(node); + // As noted in ECMAScript 6 language spec, arrow functions never have an arguments objects. + // Although in down-level emit of arrow function, we emit it using function expression which means that + // arguments objects will be bound to the inner object; emitting arrow function natively in ES6, arguments objects + // will be bound to non-arrow function that contain this arrow function. This results in inconsistent behavior. + // To avoid that we will give an error to users if they use arguments objects in arrow function so that they + // can explicitly bound arguments objects + if (symbol === argumentsSymbol) { + var container = ts.getContainingFunction(node); + if (container.kind === 174 /* ArrowFunction */) { + if (languageVersion < 2 /* ES6 */) { + error(node, ts.Diagnostics.The_arguments_object_cannot_be_referenced_in_an_arrow_function_in_ES3_and_ES5_Consider_using_a_standard_function_expression); + } + } + if (node.parserContextFlags & 8 /* Await */) { + getNodeLinks(container).flags |= 4096 /* CaptureArguments */; + getNodeLinks(node).flags |= 2048 /* LexicalArguments */; + } + } + if (symbol.flags & 8388608 /* Alias */ && !isInTypeQuery(node) && !isConstEnumOrConstEnumOnlyModule(resolveAlias(symbol))) { + markAliasSymbolAsReferenced(symbol); + } + checkCollisionWithCapturedSuperVariable(node, node); + checkCollisionWithCapturedThisVariable(node, node); + checkBlockScopedBindingCapturedInLoop(node, symbol); + return getNarrowedTypeOfSymbol(getExportSymbolOfValueSymbolIfExported(symbol), node); + } + function isInsideFunction(node, threshold) { + var current = node; + while (current && current !== threshold) { + if (ts.isFunctionLike(current)) { + return true; + } + current = current.parent; + } + return false; + } + function checkBlockScopedBindingCapturedInLoop(node, symbol) { + if (languageVersion >= 2 /* ES6 */ || + (symbol.flags & (2 /* BlockScopedVariable */ | 32 /* Class */)) === 0 || + symbol.valueDeclaration.parent.kind === 244 /* CatchClause */) { + return; + } + // 1. walk from the use site up to the declaration and check + // if there is anything function like between declaration and use-site (is binding/class is captured in function). + // 2. walk from the declaration up to the boundary of lexical environment and check + // if there is an iteration statement in between declaration and boundary (is binding/class declared inside iteration statement) + var container; + if (symbol.flags & 32 /* Class */) { + // get parent of class declaration + container = getClassLikeDeclarationOfSymbol(symbol).parent; + } + else { + // nesting structure: + // (variable declaration or binding element) -> variable declaration list -> container + container = symbol.valueDeclaration; + while (container.kind !== 212 /* VariableDeclarationList */) { + container = container.parent; + } + // get the parent of variable declaration list + container = container.parent; + if (container.kind === 193 /* VariableStatement */) { + // if parent is variable statement - get its parent + container = container.parent; + } + } + var inFunction = isInsideFunction(node.parent, container); + var current = container; + while (current && !ts.nodeStartsNewLexicalEnvironment(current)) { + if (ts.isIterationStatement(current, /*lookInLabeledStatements*/ false)) { + if (inFunction) { + getNodeLinks(current).flags |= 65536 /* LoopWithBlockScopedBindingCapturedInFunction */; + } + // mark value declaration so during emit they can have a special handling + getNodeLinks(symbol.valueDeclaration).flags |= 16384 /* BlockScopedBindingInLoop */; + break; + } + current = current.parent; + } + } + function captureLexicalThis(node, container) { + getNodeLinks(node).flags |= 2 /* LexicalThis */; + if (container.kind === 141 /* PropertyDeclaration */ || container.kind === 144 /* Constructor */) { + var classNode = container.parent; + getNodeLinks(classNode).flags |= 4 /* CaptureThis */; + } + else { + getNodeLinks(container).flags |= 4 /* CaptureThis */; + } + } + function checkThisExpression(node) { + // Stop at the first arrow function so that we can + // tell whether 'this' needs to be captured. + var container = ts.getThisContainer(node, /* includeArrowFunctions */ true); + var needToCaptureLexicalThis = false; + // Now skip arrow functions to get the "real" owner of 'this'. + if (container.kind === 174 /* ArrowFunction */) { + container = ts.getThisContainer(container, /* includeArrowFunctions */ false); + // When targeting es6, arrow function lexically bind "this" so we do not need to do the work of binding "this" in emitted code + needToCaptureLexicalThis = (languageVersion < 2 /* ES6 */); + } + switch (container.kind) { + case 218 /* ModuleDeclaration */: + error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_module_or_namespace_body); + // do not return here so in case if lexical this is captured - it will be reflected in flags on NodeLinks + break; + case 217 /* EnumDeclaration */: + error(node, ts.Diagnostics.this_cannot_be_referenced_in_current_location); + // do not return here so in case if lexical this is captured - it will be reflected in flags on NodeLinks + break; + case 144 /* Constructor */: + if (isInConstructorArgumentInitializer(node, container)) { + error(node, ts.Diagnostics.this_cannot_be_referenced_in_constructor_arguments); + } + break; + case 141 /* PropertyDeclaration */: + case 140 /* PropertySignature */: + if (container.flags & 128 /* Static */) { + error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_static_property_initializer); + } + break; + case 136 /* ComputedPropertyName */: + error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_computed_property_name); + break; + } + if (needToCaptureLexicalThis) { + captureLexicalThis(node, container); + } + if (ts.isClassLike(container.parent)) { + var symbol = getSymbolOfNode(container.parent); + return container.flags & 128 /* Static */ ? getTypeOfSymbol(symbol) : getDeclaredTypeOfSymbol(symbol).thisType; + } + return anyType; + } + function isInConstructorArgumentInitializer(node, constructorDecl) { + for (var n = node; n && n !== constructorDecl; n = n.parent) { + if (n.kind === 138 /* Parameter */) { + return true; + } + } + return false; + } + function checkSuperExpression(node) { + var isCallExpression = node.parent.kind === 168 /* CallExpression */ && node.parent.expression === node; + var classDeclaration = ts.getContainingClass(node); + var classType = classDeclaration && getDeclaredTypeOfSymbol(getSymbolOfNode(classDeclaration)); + var baseClassType = classType && getBaseTypes(classType)[0]; + var container = ts.getSuperContainer(node, /*includeFunctions*/ true); + var needToCaptureLexicalThis = false; + if (!isCallExpression) { + // adjust the container reference in case if super is used inside arrow functions with arbitrary deep nesting + while (container && container.kind === 174 /* ArrowFunction */) { + container = ts.getSuperContainer(container, /*includeFunctions*/ true); + needToCaptureLexicalThis = languageVersion < 2 /* ES6 */; + } + } + var canUseSuperExpression = isLegalUsageOfSuperExpression(container); + var nodeCheckFlag = 0; + // always set NodeCheckFlags for 'super' expression node + if (canUseSuperExpression) { + if ((container.flags & 128 /* Static */) || isCallExpression) { + nodeCheckFlag = 512 /* SuperStatic */; + } + else { + nodeCheckFlag = 256 /* SuperInstance */; + } + getNodeLinks(node).flags |= nodeCheckFlag; + if (needToCaptureLexicalThis) { + // call expressions are allowed only in constructors so they should always capture correct 'this' + // super property access expressions can also appear in arrow functions - + // in this case they should also use correct lexical this + captureLexicalThis(node.parent, container); + } + } + if (!baseClassType) { + if (!classDeclaration || !ts.getClassExtendsHeritageClauseElement(classDeclaration)) { + error(node, ts.Diagnostics.super_can_only_be_referenced_in_a_derived_class); + } + return unknownType; + } + if (!canUseSuperExpression) { + if (container && container.kind === 136 /* 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 { + error(node, ts.Diagnostics.super_property_access_is_permitted_only_in_a_constructor_member_function_or_member_accessor_of_a_derived_class); + } + return unknownType; + } + if (container.kind === 144 /* Constructor */ && isInConstructorArgumentInitializer(node, container)) { + // issue custom error message for super property access in constructor arguments (to be aligned with old compiler) + error(node, ts.Diagnostics.super_cannot_be_referenced_in_constructor_arguments); + return unknownType; + } + return nodeCheckFlag === 512 /* SuperStatic */ + ? getBaseConstructorTypeOfClass(classType) + : baseClassType; + function isLegalUsageOfSuperExpression(container) { + if (!container) { + return false; + } + if (isCallExpression) { + // TS 1.0 SPEC (April 2014): 4.8.1 + // Super calls are only permitted in constructors of derived classes + return container.kind === 144 /* Constructor */; + } + else { + // TS 1.0 SPEC (April 2014) + // 'super' property access is allowed + // - 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 + if (container && ts.isClassLike(container.parent)) { + if (container.flags & 128 /* Static */) { + return container.kind === 143 /* MethodDeclaration */ || + container.kind === 142 /* MethodSignature */ || + container.kind === 145 /* GetAccessor */ || + container.kind === 146 /* SetAccessor */; + } + else { + return container.kind === 143 /* MethodDeclaration */ || + container.kind === 142 /* MethodSignature */ || + container.kind === 145 /* GetAccessor */ || + container.kind === 146 /* SetAccessor */ || + container.kind === 141 /* PropertyDeclaration */ || + container.kind === 140 /* PropertySignature */ || + container.kind === 144 /* Constructor */; + } + } + } + return false; + } + } + // Return contextual type of parameter or undefined if no contextual type is available + function getContextuallyTypedParameterType(parameter) { + var func = parameter.parent; + if (isFunctionExpressionOrArrowFunction(func) || ts.isObjectLiteralMethod(func)) { + if (isContextSensitive(func)) { + var contextualSignature = getContextualSignature(func); + if (contextualSignature) { + var funcHasRestParameters = ts.hasRestParameter(func); + var len = func.parameters.length - (funcHasRestParameters ? 1 : 0); + var indexOfParameter = ts.indexOf(func.parameters, parameter); + if (indexOfParameter < len) { + return getTypeAtPosition(contextualSignature, indexOfParameter); + } + // If last parameter is contextually rest parameter get its type + if (funcHasRestParameters && + indexOfParameter === (func.parameters.length - 1) && + isRestParameterIndex(contextualSignature, func.parameters.length - 1)) { + return getTypeOfSymbol(ts.lastOrUndefined(contextualSignature.parameters)); + } + } + } + } + return undefined; + } + // In a variable, parameter or property declaration with a type annotation, the contextual type of an initializer + // expression is the type of the variable, parameter or property. Otherwise, in a parameter declaration of a + // contextually typed function expression, the contextual type of an initializer expression is the contextual type + // of the parameter. Otherwise, in a variable or parameter declaration with a binding pattern name, the contextual + // type of an initializer expression is the type implied by the binding pattern. + function getContextualTypeForInitializerExpression(node) { + var declaration = node.parent; + if (node === declaration.initializer) { + if (declaration.type) { + return getTypeFromTypeNode(declaration.type); + } + if (declaration.kind === 138 /* Parameter */) { + var type = getContextuallyTypedParameterType(declaration); + if (type) { + return type; + } + } + if (ts.isBindingPattern(declaration.name)) { + return getTypeFromBindingPattern(declaration.name, /*includePatternInType*/ true); + } + } + return undefined; + } + function getContextualTypeForReturnExpression(node) { + var func = ts.getContainingFunction(node); + if (func && !func.asteriskToken) { + return getContextualReturnType(func); + } + return undefined; + } + function getContextualTypeForYieldOperand(node) { + var func = ts.getContainingFunction(node); + if (func) { + var contextualReturnType = getContextualReturnType(func); + if (contextualReturnType) { + return node.asteriskToken + ? contextualReturnType + : getElementTypeOfIterableIterator(contextualReturnType); + } + } + return undefined; + } + function isInParameterInitializerBeforeContainingFunction(node) { + while (node.parent && !ts.isFunctionLike(node.parent)) { + if (node.parent.kind === 138 /* Parameter */ && node.parent.initializer === node) { + return true; + } + node = node.parent; + } + return false; + } + function getContextualReturnType(functionDecl) { + // 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 === 144 /* Constructor */ || + functionDecl.kind === 145 /* GetAccessor */ && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(functionDecl.symbol, 146 /* SetAccessor */))) { + return getReturnTypeOfSignature(getSignatureFromDeclaration(functionDecl)); + } + // Otherwise, if the containing function is contextually typed by a function type with exactly one call signature + // and that call signature is non-generic, return statements are contextually typed by the return type of the signature + var signature = getContextualSignatureForFunctionLikeDeclaration(functionDecl); + if (signature) { + return getReturnTypeOfSignature(signature); + } + return undefined; + } + // In a typed function call, an argument or substitution expression is contextually typed by the type of the corresponding parameter. + function getContextualTypeForArgument(callTarget, arg) { + var args = getEffectiveCallArguments(callTarget); + var argIndex = ts.indexOf(args, arg); + if (argIndex >= 0) { + var signature = getResolvedSignature(callTarget); + return getTypeAtPosition(signature, argIndex); + } + return undefined; + } + function getContextualTypeForSubstitutionExpression(template, substitutionExpression) { + if (template.parent.kind === 170 /* TaggedTemplateExpression */) { + return getContextualTypeForArgument(template.parent, substitutionExpression); + } + return undefined; + } + function getContextualTypeForBinaryOperand(node) { + var binaryExpression = node.parent; + var operator = binaryExpression.operatorToken.kind; + if (operator >= 56 /* FirstAssignment */ && operator <= 68 /* LastAssignment */) { + // In an assignment expression, the right operand is contextually typed by the type of the left operand. + if (node === binaryExpression.right) { + return checkExpression(binaryExpression.left); + } + } + else if (operator === 52 /* BarBarToken */) { + // When an || expression has a contextual type, the operands are contextually typed by that type. When an || + // expression has no contextual type, the right operand is contextually typed by the type of the left operand. + var type = getContextualType(binaryExpression); + if (!type && node === binaryExpression.right) { + type = checkExpression(binaryExpression.left); + } + return type; + } + return undefined; + } + // Apply a mapping function to a contextual type and return the resulting type. If the contextual type + // is a union type, the mapping function is applied to each constituent type and a union of the resulting + // types is returned. + function applyToContextualType(type, mapper) { + if (!(type.flags & 16384 /* Union */)) { + return mapper(type); + } + var types = type.types; + var mappedType; + var mappedTypes; + for (var _i = 0; _i < types.length; _i++) { + var current = types[_i]; + var t = mapper(current); + if (t) { + if (!mappedType) { + mappedType = t; + } + else if (!mappedTypes) { + mappedTypes = [mappedType, t]; + } + else { + mappedTypes.push(t); + } + } + } + return mappedTypes ? getUnionType(mappedTypes) : mappedType; + } + function getTypeOfPropertyOfContextualType(type, name) { + return applyToContextualType(type, function (t) { + var prop = t.flags & 130048 /* StructuredType */ ? getPropertyOfType(t, name) : undefined; + return prop ? getTypeOfSymbol(prop) : undefined; + }); + } + function getIndexTypeOfContextualType(type, kind) { + return applyToContextualType(type, function (t) { return getIndexTypeOfStructuredType(t, kind); }); + } + // Return true if the given contextual type is a tuple-like type + function contextualTypeIsTupleLikeType(type) { + return !!(type.flags & 16384 /* Union */ ? ts.forEach(type.types, isTupleLikeType) : isTupleLikeType(type)); + } + // Return true if the given contextual type provides an index signature of the given kind + function contextualTypeHasIndexSignature(type, kind) { + return !!(type.flags & 16384 /* Union */ ? ts.forEach(type.types, function (t) { return getIndexTypeOfStructuredType(t, kind); }) : getIndexTypeOfStructuredType(type, kind)); + } + // In an object literal contextually typed by a type T, the contextual type of a property assignment is the type of + // the matching property in T, if one exists. Otherwise, it is the type of the numeric index signature in T, if one + // exists. Otherwise, it is the type of the string index signature in T, if one exists. + function getContextualTypeForObjectLiteralMethod(node) { + ts.Debug.assert(ts.isObjectLiteralMethod(node)); + if (isInsideWithStatementBody(node)) { + // We cannot answer semantic questions within a with block, do not proceed any further + return undefined; + } + return getContextualTypeForObjectLiteralElement(node); + } + function getContextualTypeForObjectLiteralElement(element) { + var objectLiteral = element.parent; + var type = getContextualType(objectLiteral); + if (type) { + if (!ts.hasDynamicName(element)) { + // For a (non-symbol) computed property, there is no reason to look up the name + // in the type. It will just be "__computed", which does not appear in any + // SymbolTable. + var symbolName = getSymbolOfNode(element).name; + var propertyType = getTypeOfPropertyOfContextualType(type, symbolName); + if (propertyType) { + return propertyType; + } + } + return isNumericName(element.name) && getIndexTypeOfContextualType(type, 1 /* Number */) || + getIndexTypeOfContextualType(type, 0 /* String */); + } + return undefined; + } + // In an array literal contextually typed by a type T, the contextual type of an element expression at index N is + // the type of the property with the numeric name N in T, if one exists. Otherwise, if T has a numeric index signature, + // it is the type of the numeric index signature in T. Otherwise, in ES6 and higher, the contextual type is the iterated + // type of T. + function getContextualTypeForElementExpression(node) { + var arrayLiteral = node.parent; + var type = getContextualType(arrayLiteral); + if (type) { + var index = ts.indexOf(arrayLiteral.elements, node); + return getTypeOfPropertyOfContextualType(type, "" + index) + || getIndexTypeOfContextualType(type, 1 /* Number */) + || (languageVersion >= 2 /* ES6 */ ? getElementTypeOfIterable(type, /*errorNode*/ undefined) : undefined); + } + return undefined; + } + // In a contextually typed conditional expression, the true/false expressions are contextually typed by the same type. + function getContextualTypeForConditionalOperand(node) { + var conditional = node.parent; + return node === conditional.whenTrue || node === conditional.whenFalse ? getContextualType(conditional) : undefined; + } + function getContextualTypeForJsxExpression(expr) { + // Contextual type only applies to JSX expressions that are in attribute assignments (not in 'Children' positions) + if (expr.parent.kind === 238 /* JsxAttribute */) { + var attrib = expr.parent; + var attrsType = getJsxElementAttributesType(attrib.parent); + if (!attrsType || isTypeAny(attrsType)) { + return undefined; + } + else { + return getTypeOfPropertyOfType(attrsType, attrib.name.text); + } + } + if (expr.kind === 239 /* JsxSpreadAttribute */) { + return getJsxElementAttributesType(expr.parent); + } + return undefined; + } + // Return the contextual type for a given expression node. During overload resolution, a contextual type may temporarily + // be "pushed" onto a node using the contextualType property. + function getContextualType(node) { + var type = getContextualTypeWorker(node); + return type && getApparentType(type); + } + function getContextualTypeWorker(node) { + if (isInsideWithStatementBody(node)) { + // We cannot answer semantic questions within a with block, do not proceed any further + return undefined; + } + if (node.contextualType) { + return node.contextualType; + } + var parent = node.parent; + switch (parent.kind) { + case 211 /* VariableDeclaration */: + case 138 /* Parameter */: + case 141 /* PropertyDeclaration */: + case 140 /* PropertySignature */: + case 163 /* BindingElement */: + return getContextualTypeForInitializerExpression(node); + case 174 /* ArrowFunction */: + case 204 /* ReturnStatement */: + return getContextualTypeForReturnExpression(node); + case 184 /* YieldExpression */: + return getContextualTypeForYieldOperand(parent); + case 168 /* CallExpression */: + case 169 /* NewExpression */: + return getContextualTypeForArgument(parent, node); + case 171 /* TypeAssertionExpression */: + case 189 /* AsExpression */: + return getTypeFromTypeNode(parent.type); + case 181 /* BinaryExpression */: + return getContextualTypeForBinaryOperand(node); + case 245 /* PropertyAssignment */: + return getContextualTypeForObjectLiteralElement(parent); + case 164 /* ArrayLiteralExpression */: + return getContextualTypeForElementExpression(node); + case 182 /* ConditionalExpression */: + return getContextualTypeForConditionalOperand(node); + case 190 /* TemplateSpan */: + ts.Debug.assert(parent.parent.kind === 183 /* TemplateExpression */); + return getContextualTypeForSubstitutionExpression(parent.parent, node); + case 172 /* ParenthesizedExpression */: + return getContextualType(parent); + case 240 /* JsxExpression */: + case 239 /* JsxSpreadAttribute */: + return getContextualTypeForJsxExpression(parent); + } + return undefined; + } + // If the given type is an object or union type, if that type has a single signature, and if + // that signature is non-generic, return the signature. Otherwise return undefined. + function getNonGenericSignature(type) { + var signatures = getSignaturesOfStructuredType(type, 0 /* Call */); + if (signatures.length === 1) { + var signature = signatures[0]; + if (!signature.typeParameters) { + return signature; + } + } + } + function isFunctionExpressionOrArrowFunction(node) { + return node.kind === 173 /* FunctionExpression */ || node.kind === 174 /* ArrowFunction */; + } + function getContextualSignatureForFunctionLikeDeclaration(node) { + // Only function expressions, arrow functions, and object literal methods are contextually typed. + return isFunctionExpressionOrArrowFunction(node) || ts.isObjectLiteralMethod(node) + ? getContextualSignature(node) + : undefined; + } + // Return the contextual signature for a given expression node. A contextual type provides a + // contextual signature if it has a single call signature and if that call signature is non-generic. + // If the contextual type is a union type, get the signature from each type possible and if they are + // 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 !== 143 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + var type = ts.isObjectLiteralMethod(node) + ? getContextualTypeForObjectLiteralMethod(node) + : getContextualType(node); + if (!type) { + return undefined; + } + if (!(type.flags & 16384 /* Union */)) { + return getNonGenericSignature(type); + } + var signatureList; + var types = type.types; + for (var _i = 0; _i < types.length; _i++) { + var current = types[_i]; + var signature = getNonGenericSignature(current); + if (signature) { + if (!signatureList) { + // This signature will contribute to contextual union signature + signatureList = [signature]; + } + else if (!compareSignatures(signatureList[0], signature, /*partialMatch*/ false, /*ignoreReturnTypes*/ true, compareTypes)) { + // Signatures aren't identical, do not use + return undefined; + } + else { + // Use this signature for contextual union signature + signatureList.push(signature); + } + } + } + // Result is union of signatures collected (return type is union of return types of this signature set) + var result; + if (signatureList) { + result = cloneSignature(signatureList[0]); + // Clear resolved return type we possibly got from cloneSignature + result.resolvedReturnType = undefined; + result.unionSignatures = signatureList; + } + return result; + } + /** + * Detect if the mapper implies an inference context. Specifically, there are 4 possible values + * for a mapper. Let's go through each one of them: + * + * 1. undefined - this means we are not doing inferential typing, but we may do contextual typing, + * which could cause us to assign a parameter a type + * 2. identityMapper - means we want to avoid assigning a parameter a type, whether or not we are in + * inferential typing (context is undefined for the identityMapper) + * 3. a mapper created by createInferenceMapper - we are doing inferential typing, we want to assign + * types to parameters and fix type parameters (context is defined) + * 4. an instantiation mapper created by createTypeMapper or createTypeEraser - this should never be + * passed as the contextual mapper when checking an expression (context is undefined for these) + * + * isInferentialContext is detecting if we are in case 3 + */ + function isInferentialContext(mapper) { + return mapper && mapper.context; + } + // A node is an assignment target if it is on the left hand side of an '=' token, if it is parented by a property + // 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) { + var parent = node.parent; + if (parent.kind === 181 /* BinaryExpression */ && parent.operatorToken.kind === 56 /* EqualsToken */ && parent.left === node) { + return true; + } + if (parent.kind === 245 /* PropertyAssignment */) { + return isAssignmentTarget(parent.parent); + } + if (parent.kind === 164 /* ArrayLiteralExpression */) { + return isAssignmentTarget(parent); + } + return false; + } + function checkSpreadElementExpression(node, contextualMapper) { + // It is usually not safe to call checkExpressionCached if we can be contextually typing. + // You can tell that we are contextually typing because of the contextualMapper parameter. + // While it is true that a spread element can have a contextual type, it does not do anything + // with this type. It is neither affected by it, nor does it propagate it to its operand. + // So the fact that contextualMapper is passed is not important, because the operand of a spread + // element is not contextually typed. + var arrayOrIterableType = checkExpressionCached(node.expression, contextualMapper); + return checkIteratedTypeOrElementType(arrayOrIterableType, node.expression, /*allowStringInput*/ false); + } + function hasDefaultValue(node) { + return (node.kind === 163 /* BindingElement */ && !!node.initializer) || + (node.kind === 181 /* BinaryExpression */ && node.operatorToken.kind === 56 /* EqualsToken */); + } + function checkArrayLiteral(node, contextualMapper) { + var elements = node.elements; + var hasSpreadElement = false; + var elementTypes = []; + var inDestructuringPattern = isAssignmentTarget(node); + for (var _i = 0; _i < elements.length; _i++) { + var e = elements[_i]; + if (inDestructuringPattern && e.kind === 185 /* SpreadElementExpression */) { + // Given the following situation: + // var c: {}; + // [...c] = ["", 0]; + // + // c is represented in the tree as a spread element in an array literal. + // But c really functions as a rest element, and its purpose is to provide + // a contextual type for the right hand side of the assignment. Therefore, + // instead of calling checkExpression on "...c", which will give an error + // if c is not iterable/array-like, we need to act as if we are trying to + // get the contextual element type from it. So we do something similar to + // getContextualTypeForElementExpression, which will crucially not error + // 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); + if (restElementType) { + elementTypes.push(restElementType); + } + } + else { + var type = checkExpression(e, contextualMapper); + elementTypes.push(type); + } + hasSpreadElement = hasSpreadElement || e.kind === 185 /* SpreadElementExpression */; + } + if (!hasSpreadElement) { + // If array literal is actually a destructuring pattern, mark it as an implied type. We do this such + // that we get the same behavior for "var [x, y] = []" and "[x, y] = []". + if (inDestructuringPattern && elementTypes.length) { + var type = createNewTupleType(elementTypes); + type.pattern = node; + return type; + } + var contextualType = getContextualType(node); + if (contextualType && contextualTypeIsTupleLikeType(contextualType)) { + 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 === 162 /* ArrayBindingPattern */ || pattern.kind === 164 /* ArrayLiteralExpression */)) { + var patternElements = pattern.elements; + for (var i = elementTypes.length; i < patternElements.length; i++) { + var patternElement = patternElements[i]; + if (hasDefaultValue(patternElement)) { + elementTypes.push(contextualType.elementTypes[i]); + } + else { + if (patternElement.kind !== 187 /* OmittedExpression */) { + error(patternElement, ts.Diagnostics.Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value); + } + elementTypes.push(unknownType); + } + } + } + if (elementTypes.length) { + return createTupleType(elementTypes); + } + } + } + return createArrayType(elementTypes.length ? getUnionType(elementTypes) : undefinedType); + } + function isNumericName(name) { + return name.kind === 136 /* ComputedPropertyName */ ? isNumericComputedName(name) : isNumericLiteralName(name.text); + } + function isNumericComputedName(name) { + // It seems odd to consider an expression of type Any to result in a numeric name, + // but this behavior is consistent with checkIndexedAccess + return isTypeAnyOrAllConstituentTypesHaveKind(checkComputedPropertyName(name), 132 /* NumberLike */); + } + function isTypeAnyOrAllConstituentTypesHaveKind(type, kind) { + return isTypeAny(type) || allConstituentTypesHaveKind(type, kind); + } + function isNumericLiteralName(name) { + // The intent of numeric names is that + // - they are names with text in a numeric form, and that + // - setting properties/indexing with them is always equivalent to doing so with the numeric literal 'numLit', + // acquired by applying the abstract 'ToNumber' operation on the name's text. + // + // The subtlety is in the latter portion, as we cannot reliably say that anything that looks like a numeric literal is a numeric name. + // In fact, it is the case that the text of the name must be equal to 'ToString(numLit)' for this to hold. + // + // Consider the property name '"0xF00D"'. When one indexes with '0xF00D', they are actually indexing with the value of 'ToString(0xF00D)' + // according to the ECMAScript specification, so it is actually as if the user indexed with the string '"61453"'. + // Thus, the text of all numeric literals equivalent to '61543' such as '0xF00D', '0xf00D', '0170015', etc. are not valid numeric names + // because their 'ToString' representation is not equal to their original text. + // This is motivated by ECMA-262 sections 9.3.1, 9.8.1, 11.1.5, and 11.2.1. + // + // Here, we test whether 'ToString(ToNumber(name))' is exactly equal to 'name'. + // The '+' prefix operator is equivalent here to applying the abstract ToNumber operation. + // Applying the 'toString()' method on a number gives us the abstract ToString operation on a number. + // + // Note that this accepts the values 'Infinity', '-Infinity', and 'NaN', and that this is intentional. + // This is desired behavior, because when indexing with them as numeric entities, you are indexing + // with the strings '"Infinity"', '"-Infinity"', and '"NaN"' respectively. + return (+name).toString() === name; + } + function checkComputedPropertyName(node) { + var links = getNodeLinks(node.expression); + if (!links.resolvedType) { + links.resolvedType = checkExpression(node.expression); + // This will allow types number, string, symbol or any. It will also allow enums, the unknown + // type, and any union of these types (like string | number). + if (!isTypeAnyOrAllConstituentTypesHaveKind(links.resolvedType, 132 /* NumberLike */ | 258 /* StringLike */ | 16777216 /* ESSymbol */)) { + error(node, ts.Diagnostics.A_computed_property_name_must_be_of_type_string_number_symbol_or_any); + } + else { + checkThatExpressionIsProperSymbolReference(node.expression, links.resolvedType, /*reportError*/ true); + } + } + return links.resolvedType; + } + function checkObjectLiteral(node, contextualMapper) { + var inDestructuringPattern = isAssignmentTarget(node); + // Grammar checking + checkGrammarObjectLiteralExpression(node, inDestructuringPattern); + var propertiesTable = {}; + var propertiesArray = []; + var contextualType = getContextualType(node); + var contextualTypeHasPattern = contextualType && contextualType.pattern && + (contextualType.pattern.kind === 161 /* ObjectBindingPattern */ || contextualType.pattern.kind === 165 /* ObjectLiteralExpression */); + var typeFlags = 0; + for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { + var memberDecl = _a[_i]; + var member = memberDecl.symbol; + if (memberDecl.kind === 245 /* PropertyAssignment */ || + memberDecl.kind === 246 /* ShorthandPropertyAssignment */ || + ts.isObjectLiteralMethod(memberDecl)) { + var type = void 0; + if (memberDecl.kind === 245 /* PropertyAssignment */) { + type = checkPropertyAssignment(memberDecl, contextualMapper); + } + else if (memberDecl.kind === 143 /* MethodDeclaration */) { + type = checkObjectLiteralMethod(memberDecl, contextualMapper); + } + else { + ts.Debug.assert(memberDecl.kind === 246 /* ShorthandPropertyAssignment */); + type = checkExpression(memberDecl.name, contextualMapper); + } + typeFlags |= type.flags; + var prop = createSymbol(4 /* Property */ | 67108864 /* Transient */ | member.flags, member.name); + if (inDestructuringPattern) { + // If object literal is an assignment pattern and if the assignment pattern specifies a default value + // for the property, make the property optional. + var isOptional = (memberDecl.kind === 245 /* PropertyAssignment */ && hasDefaultValue(memberDecl.initializer)) || + (memberDecl.kind === 246 /* ShorthandPropertyAssignment */ && memberDecl.objectAssignmentInitializer); + if (isOptional) { + prop.flags |= 536870912 /* Optional */; + } + } + else if (contextualTypeHasPattern) { + // 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); + if (impliedProp) { + prop.flags |= impliedProp.flags & 536870912 /* Optional */; + } + else if (!compilerOptions.suppressExcessPropertyErrors) { + error(memberDecl.name, ts.Diagnostics.Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1, symbolToString(member), typeToString(contextualType)); + } + } + prop.declarations = member.declarations; + prop.parent = member.parent; + if (member.valueDeclaration) { + prop.valueDeclaration = member.valueDeclaration; + } + prop.type = type; + prop.target = member; + member = prop; + } + else { + // TypeScript 1.0 spec (April 2014) + // A get accessor declaration is processed in the same manner as + // 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 === 145 /* GetAccessor */ || memberDecl.kind === 146 /* SetAccessor */); + checkAccessorDeclaration(memberDecl); + } + if (!ts.hasDynamicName(memberDecl)) { + propertiesTable[member.name] = member; + } + propertiesArray.push(member); + } + // If object literal is contextually typed by the implied type of a binding pattern, augment the result + // type with those properties for which the binding pattern specifies a default value. + if (contextualTypeHasPattern) { + for (var _b = 0, _c = getPropertiesOfType(contextualType); _b < _c.length; _b++) { + var prop = _c[_b]; + if (!ts.hasProperty(propertiesTable, prop.name)) { + if (!(prop.flags & 536870912 /* Optional */)) { + error(prop.valueDeclaration || prop.bindingElement, ts.Diagnostics.Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value); + } + propertiesTable[prop.name] = prop; + propertiesArray.push(prop); + } + } + } + var stringIndexType = getIndexType(0 /* String */); + var numberIndexType = getIndexType(1 /* Number */); + var result = createAnonymousType(node.symbol, propertiesTable, emptyArray, emptyArray, stringIndexType, numberIndexType); + var freshObjectLiteralFlag = compilerOptions.suppressExcessPropertyErrors ? 0 : 1048576 /* FreshObjectLiteral */; + result.flags |= 524288 /* ObjectLiteral */ | 4194304 /* ContainsObjectLiteral */ | freshObjectLiteralFlag | (typeFlags & 14680064 /* PropagatingFlags */); + if (inDestructuringPattern) { + result.pattern = node; + } + return result; + function getIndexType(kind) { + if (contextualType && contextualTypeHasIndexSignature(contextualType, kind)) { + var propTypes = []; + for (var i = 0; i < propertiesArray.length; i++) { + var propertyDecl = node.properties[i]; + if (kind === 0 /* String */ || isNumericName(propertyDecl.name)) { + // Do not call getSymbolOfNode(propertyDecl), as that will get the + // original symbol for the node. We actually want to get the symbol + // created by checkObjectLiteral, since that will be appropriately + // contextually typed and resolved. + var type = getTypeOfSymbol(propertiesArray[i]); + if (!ts.contains(propTypes, type)) { + propTypes.push(type); + } + } + } + var result_1 = propTypes.length ? getUnionType(propTypes) : undefinedType; + typeFlags |= result_1.flags; + return result_1; + } + return undefined; + } + } + function checkJsxSelfClosingElement(node) { + checkJsxOpeningLikeElement(node); + return jsxElementType || anyType; + } + function tagNamesAreEquivalent(lhs, rhs) { + if (lhs.kind !== rhs.kind) { + return false; + } + if (lhs.kind === 69 /* Identifier */) { + return lhs.text === rhs.text; + } + return lhs.right.text === rhs.right.text && + tagNamesAreEquivalent(lhs.left, rhs.left); + } + function checkJsxElement(node) { + // Check attributes + checkJsxOpeningLikeElement(node.openingElement); + // Check that the closing tag matches + if (!tagNamesAreEquivalent(node.openingElement.tagName, node.closingElement.tagName)) { + error(node.closingElement, ts.Diagnostics.Expected_corresponding_JSX_closing_tag_for_0, ts.getTextOfNode(node.openingElement.tagName)); + } + else { + // Perform resolution on the closing tag so that rename/go to definition/etc work + getJsxElementTagSymbol(node.closingElement); + } + // Check children + for (var _i = 0, _a = node.children; _i < _a.length; _i++) { + var child = _a[_i]; + switch (child.kind) { + case 240 /* JsxExpression */: + checkJsxExpression(child); + break; + case 233 /* JsxElement */: + checkJsxElement(child); + break; + case 234 /* JsxSelfClosingElement */: + checkJsxSelfClosingElement(child); + break; + } + } + return jsxElementType || anyType; + } + /** + * Returns true iff the JSX element name would be a valid JS identifier, ignoring restrictions about keywords not being identifiers + */ + function isUnhyphenatedJsxName(name) { + // - is the only character supported in JSX attribute names that isn't valid in JavaScript identifiers + return name.indexOf("-") < 0; + } + /** + * Returns true iff React would emit this tag name as a string rather than an identifier or qualified name + */ + function isJsxIntrinsicIdentifier(tagName) { + if (tagName.kind === 135 /* QualifiedName */) { + return false; + } + else { + return ts.isIntrinsicJsxName(tagName.text); + } + } + function checkJsxAttribute(node, elementAttributesType, nameTable) { + var correspondingPropType = undefined; + // Look up the corresponding property for this attribute + if (elementAttributesType === emptyObjectType && isUnhyphenatedJsxName(node.name.text)) { + // If there is no 'props' property, you may not have non-"data-" attributes + error(node.parent, ts.Diagnostics.JSX_element_class_does_not_support_attributes_because_it_does_not_have_a_0_property, getJsxElementPropertiesName()); + } + else if (elementAttributesType && !isTypeAny(elementAttributesType)) { + var correspondingPropSymbol = getPropertyOfType(elementAttributesType, node.name.text); + correspondingPropType = correspondingPropSymbol && getTypeOfSymbol(correspondingPropSymbol); + if (isUnhyphenatedJsxName(node.name.text)) { + // Maybe there's a string indexer? + var indexerType = getIndexTypeOfType(elementAttributesType, 0 /* String */); + if (indexerType) { + correspondingPropType = indexerType; + } + else { + // If there's no corresponding property with this name, error + if (!correspondingPropType) { + error(node.name, ts.Diagnostics.Property_0_does_not_exist_on_type_1, node.name.text, typeToString(elementAttributesType)); + return unknownType; + } + } + } + } + var exprType; + if (node.initializer) { + exprType = checkExpression(node.initializer); + } + else { + // is sugar for + exprType = booleanType; + } + if (correspondingPropType) { + checkTypeAssignableTo(exprType, correspondingPropType, node); + } + nameTable[node.name.text] = true; + return exprType; + } + function checkJsxSpreadAttribute(node, elementAttributesType, nameTable) { + var type = checkExpression(node.expression); + var props = getPropertiesOfType(type); + for (var _i = 0; _i < props.length; _i++) { + var prop = props[_i]; + // Is there a corresponding property in the element attributes type? Skip checking of properties + // that have already been assigned to, as these are not actually pushed into the resulting type + if (!nameTable[prop.name]) { + var targetPropSym = getPropertyOfType(elementAttributesType, prop.name); + if (targetPropSym) { + var msg = ts.chainDiagnosticMessages(undefined, ts.Diagnostics.Property_0_of_JSX_spread_attribute_is_not_assignable_to_target_property, prop.name); + checkTypeAssignableTo(getTypeOfSymbol(prop), getTypeOfSymbol(targetPropSym), node, undefined, msg); + } + nameTable[prop.name] = true; + } + } + return type; + } + /// Returns the type JSX.IntrinsicElements. May return `unknownType` if that type is not present. + function getJsxIntrinsicElementsType() { + if (!jsxIntrinsicElementsType) { + jsxIntrinsicElementsType = getExportedTypeFromNamespace(JsxNames.JSX, JsxNames.IntrinsicElements) || unknownType; + } + return jsxIntrinsicElementsType; + } + /// Given a JSX opening element or self-closing element, return the symbol of the property that the tag name points to if + /// this is an intrinsic tag. This might be a named + /// property of the IntrinsicElements interface, or its string indexer. + /// If this is a class-based tag (otherwise returns undefined), returns the symbol of the class + /// type or factory function. + /// Otherwise, returns unknownSymbol. + function getJsxElementTagSymbol(node) { + var flags = 8 /* UnknownElement */; + var links = getNodeLinks(node); + if (!links.resolvedSymbol) { + if (isJsxIntrinsicIdentifier(node.tagName)) { + links.resolvedSymbol = lookupIntrinsicTag(node); + } + else { + links.resolvedSymbol = lookupClassTag(node); + } + } + return links.resolvedSymbol; + function lookupIntrinsicTag(node) { + var intrinsicElementsType = getJsxIntrinsicElementsType(); + if (intrinsicElementsType !== unknownType) { + // Property case + var intrinsicProp = getPropertyOfType(intrinsicElementsType, node.tagName.text); + if (intrinsicProp) { + links.jsxFlags |= 1 /* IntrinsicNamedElement */; + return intrinsicProp; + } + // Intrinsic string indexer case + var indexSignatureType = getIndexTypeOfType(intrinsicElementsType, 0 /* String */); + if (indexSignatureType) { + links.jsxFlags |= 2 /* IntrinsicIndexedElement */; + return intrinsicElementsType.symbol; + } + // Wasn't found + error(node, ts.Diagnostics.Property_0_does_not_exist_on_type_1, node.tagName.text, "JSX." + JsxNames.IntrinsicElements); + return unknownSymbol; + } + else { + if (compilerOptions.noImplicitAny) { + error(node, ts.Diagnostics.JSX_element_implicitly_has_type_any_because_no_interface_JSX_0_exists, JsxNames.IntrinsicElements); + } + } + } + function lookupClassTag(node) { + var valueSymbol = resolveJsxTagName(node); + // Look up the value in the current scope + if (valueSymbol && valueSymbol !== unknownSymbol) { + links.jsxFlags |= 4 /* ClassElement */; + if (valueSymbol.flags & 8388608 /* Alias */) { + markAliasSymbolAsReferenced(valueSymbol); + } + } + return valueSymbol || unknownSymbol; + } + function resolveJsxTagName(node) { + if (node.tagName.kind === 69 /* Identifier */) { + var tag = node.tagName; + var sym = getResolvedSymbol(tag); + return sym.exportSymbol || sym; + } + else { + return checkQualifiedName(node.tagName).symbol; + } + } + } + /** + * Given a JSX element that is a class element, finds the Element Instance Type. If the + * element is not a class element, or the class element type cannot be determined, returns 'undefined'. + * For example, in the element , the element instance type is `MyClass` (not `typeof MyClass`). + */ + function getJsxElementInstanceType(node) { + // There is no such thing as an instance type for a non-class element. This + // line shouldn't be hit. + ts.Debug.assert(!!(getNodeLinks(node).jsxFlags & 4 /* ClassElement */), "Should not call getJsxElementInstanceType on non-class Element"); + var classSymbol = getJsxElementTagSymbol(node); + if (classSymbol === unknownSymbol) { + // Couldn't find the class instance type. Error has already been issued + return anyType; + } + var valueType = getTypeOfSymbol(classSymbol); + if (isTypeAny(valueType)) { + // Short-circuit if the class tag is using an element type 'any' + return anyType; + } + // Resolve the signatures, preferring constructors + var signatures = getSignaturesOfType(valueType, 1 /* Construct */); + if (signatures.length === 0) { + // No construct signatures, try call signatures + signatures = getSignaturesOfType(valueType, 0 /* Call */); + if (signatures.length === 0) { + // We found no signatures at all, which is an error + error(node.tagName, ts.Diagnostics.JSX_element_type_0_does_not_have_any_construct_or_call_signatures, ts.getTextOfNode(node.tagName)); + return unknownType; + } + } + var returnType = getUnionType(signatures.map(getReturnTypeOfSignature)); + // Issue an error if this return type isn't assignable to JSX.ElementClass + var elemClassType = getJsxGlobalElementClassType(); + if (elemClassType) { + checkTypeRelatedTo(returnType, elemClassType, assignableRelation, node, ts.Diagnostics.JSX_element_type_0_is_not_a_constructor_function_for_JSX_elements); + } + return returnType; + } + /// e.g. "props" for React.d.ts, + /// or 'undefined' if ElementAttributesPropery doesn't exist (which means all + /// non-intrinsic elements' attributes type is 'any'), + /// or '' if it has 0 properties (which means every + /// non-instrinsic elements' attributes type is the element instance type) + function getJsxElementPropertiesName() { + // JSX + var jsxNamespace = getGlobalSymbol(JsxNames.JSX, 1536 /* Namespace */, /*diagnosticMessage*/ undefined); + // JSX.ElementAttributesProperty [symbol] + var attribsPropTypeSym = jsxNamespace && getSymbol(jsxNamespace.exports, JsxNames.ElementAttributesPropertyNameContainer, 793056 /* Type */); + // JSX.ElementAttributesProperty [type] + var attribPropType = attribsPropTypeSym && getDeclaredTypeOfSymbol(attribsPropTypeSym); + // The properites of JSX.ElementAttributesProperty + var attribProperties = attribPropType && getPropertiesOfType(attribPropType); + if (attribProperties) { + // Element Attributes has zero properties, so the element attributes type will be the class instance type + if (attribProperties.length === 0) { + return ""; + } + else if (attribProperties.length === 1) { + return attribProperties[0].name; + } + else { + error(attribsPropTypeSym.declarations[0], ts.Diagnostics.The_global_type_JSX_0_may_not_have_more_than_one_property, JsxNames.ElementAttributesPropertyNameContainer); + return undefined; + } + } + else { + // No interface exists, so the element attributes type will be an implicit any + return undefined; + } + } + /** + * Given an opening/self-closing element, get the 'element attributes type', i.e. the type that tells + * us which attributes are valid on a given element. + */ + function getJsxElementAttributesType(node) { + var links = getNodeLinks(node); + if (!links.resolvedJsxType) { + var sym = getJsxElementTagSymbol(node); + if (links.jsxFlags & 4 /* ClassElement */) { + var elemInstanceType = getJsxElementInstanceType(node); + if (isTypeAny(elemInstanceType)) { + return links.resolvedJsxType = elemInstanceType; + } + var propsName = getJsxElementPropertiesName(); + if (propsName === undefined) { + // There is no type ElementAttributesProperty, return 'any' + return links.resolvedJsxType = anyType; + } + else if (propsName === "") { + // If there is no e.g. 'props' member in ElementAttributesProperty, use the element class type instead + return links.resolvedJsxType = elemInstanceType; + } + else { + var attributesType = getTypeOfPropertyOfType(elemInstanceType, propsName); + if (!attributesType) { + // There is no property named 'props' on this instance type + return links.resolvedJsxType = emptyObjectType; + } + else if (isTypeAny(attributesType) || (attributesType === unknownType)) { + return links.resolvedJsxType = attributesType; + } + else if (!(attributesType.flags & 80896 /* ObjectType */)) { + error(node.tagName, ts.Diagnostics.JSX_element_attributes_type_0_must_be_an_object_type, typeToString(attributesType)); + return links.resolvedJsxType = anyType; + } + else { + return links.resolvedJsxType = attributesType; + } + } + } + else if (links.jsxFlags & 1 /* IntrinsicNamedElement */) { + return links.resolvedJsxType = getTypeOfSymbol(sym); + } + else if (links.jsxFlags & 2 /* IntrinsicIndexedElement */) { + return links.resolvedJsxType = getIndexTypeOfSymbol(sym, 0 /* String */); + } + else { + // Resolution failed, so we don't know + return links.resolvedJsxType = anyType; + } + } + return links.resolvedJsxType; + } + /** + * Given a JSX attribute, returns the symbol for the corresponds property + * of the element attributes type. Will return unknownSymbol for attributes + * that have no matching element attributes type property. + */ + function getJsxAttributePropertySymbol(attrib) { + var attributesType = getJsxElementAttributesType(attrib.parent); + var prop = getPropertyOfType(attributesType, attrib.name.text); + return prop || unknownSymbol; + } + var jsxElementClassType = undefined; + function getJsxGlobalElementClassType() { + if (!jsxElementClassType) { + jsxElementClassType = getExportedTypeFromNamespace(JsxNames.JSX, JsxNames.ElementClass); + } + return jsxElementClassType; + } + /// Returns all the properties of the Jsx.IntrinsicElements interface + function getJsxIntrinsicTagNames() { + var intrinsics = getJsxIntrinsicElementsType(); + return intrinsics ? getPropertiesOfType(intrinsics) : emptyArray; + } + function checkJsxPreconditions(errorNode) { + // Preconditions for using JSX + if ((compilerOptions.jsx || 0 /* None */) === 0 /* None */) { + error(errorNode, ts.Diagnostics.Cannot_use_JSX_unless_the_jsx_flag_is_provided); + } + if (jsxElementType === undefined) { + if (compilerOptions.noImplicitAny) { + error(errorNode, ts.Diagnostics.JSX_element_implicitly_has_type_any_because_the_global_type_JSX_Element_does_not_exist); + } + } + } + function checkJsxOpeningLikeElement(node) { + checkGrammarJsxElement(node); + checkJsxPreconditions(node); + // If we're compiling under --jsx react, the symbol 'React' should + // be marked as 'used' so we don't incorrectly elide its import. And if there + // is no 'React' symbol in scope, we should issue an error. + if (compilerOptions.jsx === 2 /* React */) { + var reactSym = resolveName(node.tagName, "React", 107455 /* Value */, ts.Diagnostics.Cannot_find_name_0, "React"); + if (reactSym) { + getSymbolLinks(reactSym).referenced = true; + } + } + var targetAttributesType = getJsxElementAttributesType(node); + var nameTable = {}; + // Process this array in right-to-left order so we know which + // attributes (mostly from spreads) are being overwritten and + // thus should have their types ignored + var sawSpreadedAny = false; + for (var i = node.attributes.length - 1; i >= 0; i--) { + if (node.attributes[i].kind === 238 /* JsxAttribute */) { + checkJsxAttribute((node.attributes[i]), targetAttributesType, nameTable); + } + else { + ts.Debug.assert(node.attributes[i].kind === 239 /* JsxSpreadAttribute */); + var spreadType = checkJsxSpreadAttribute((node.attributes[i]), targetAttributesType, nameTable); + if (isTypeAny(spreadType)) { + sawSpreadedAny = true; + } + } + } + // Check that all required properties have been provided. If an 'any' + // was spreaded in, though, assume that it provided all required properties + if (targetAttributesType && !sawSpreadedAny) { + var targetProperties = getPropertiesOfType(targetAttributesType); + for (var i = 0; i < targetProperties.length; i++) { + if (!(targetProperties[i].flags & 536870912 /* Optional */) && + nameTable[targetProperties[i].name] === undefined) { + error(node, ts.Diagnostics.Property_0_is_missing_in_type_1, targetProperties[i].name, typeToString(targetAttributesType)); + } + } + } + } + function checkJsxExpression(node) { + if (node.expression) { + return checkExpression(node.expression); + } + else { + return unknownType; + } + } + // 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 : 141 /* PropertyDeclaration */; + } + function getDeclarationFlagsFromSymbol(s) { + return s.valueDeclaration ? ts.getCombinedNodeFlags(s.valueDeclaration) : s.flags & 134217728 /* Prototype */ ? 16 /* Public */ | 128 /* Static */ : 0; + } + /** + * Check whether the requested property access is valid. + * Returns true if node is a valid property access, and false otherwise. + * @param node The node to be checked. + * @param left The left hand side of the property access (e.g.: the super in `super.foo`). + * @param type The type of left. + * @param prop The symbol for the right hand side of the property access. + */ + function checkClassPropertyAccess(node, left, type, prop) { + var flags = getDeclarationFlagsFromSymbol(prop); + var declaringClass = getDeclaredTypeOfSymbol(prop.parent); + if (left.kind === 95 /* SuperKeyword */) { + var errorNode = node.kind === 166 /* PropertyAccessExpression */ ? + node.name : + node.right; + // 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, + // a super property access is permitted and must specify a public instance member function of the base class. + // - In a static member function or static member accessor + // where this references the constructor function object of a derived class, + // a super property access is permitted and must specify a public static member function of the base class. + if (getDeclarationKindFromSymbol(prop) !== 143 /* MethodDeclaration */) { + // `prop` refers to a *property* declared in the super class + // rather than a *method*, so it does not satisfy the above criteria. + error(errorNode, ts.Diagnostics.Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword); + return false; + } + if (flags & 256 /* Abstract */) { + // A method cannot be accessed in a super property access if the method is abstract. + // This error could mask a private property access error. But, a member + // cannot simultaneously be private and abstract, so this will trigger an + // additional error elsewhere. + error(errorNode, ts.Diagnostics.Abstract_method_0_in_class_1_cannot_be_accessed_via_super_expression, symbolToString(prop), typeToString(declaringClass)); + return false; + } + } + // Public properties are otherwise accessible. + if (!(flags & (32 /* Private */ | 64 /* Protected */))) { + return true; + } + // Property is known to be private or protected at this point + // Get the declaring and enclosing class instance types + var enclosingClassDeclaration = ts.getContainingClass(node); + var enclosingClass = enclosingClassDeclaration ? getDeclaredTypeOfSymbol(getSymbolOfNode(enclosingClassDeclaration)) : undefined; + // Private property is accessible if declaring and enclosing class are the same + if (flags & 32 /* Private */) { + if (declaringClass !== enclosingClass) { + error(node, ts.Diagnostics.Property_0_is_private_and_only_accessible_within_class_1, symbolToString(prop), typeToString(declaringClass)); + return false; + } + return true; + } + // 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 */) { + return true; + } + // A protected property is accessible in the declaring class and classes derived from it + if (!enclosingClass || !hasBaseType(enclosingClass, declaringClass)) { + error(node, ts.Diagnostics.Property_0_is_protected_and_only_accessible_within_class_1_and_its_subclasses, symbolToString(prop), typeToString(declaringClass)); + return false; + } + // No further restrictions for static properties + if (flags & 128 /* Static */) { + return true; + } + // An instance property must be accessed through an instance of the enclosing class + if (type.flags & 33554432 /* ThisType */) { + // get the original type -- represented as the type constraint of the 'this' type + type = getConstraintOfTypeParameter(type); + } + // TODO: why is the first part of this check here? + if (!(getTargetType(type).flags & (1024 /* Class */ | 2048 /* Interface */) && hasBaseType(type, enclosingClass))) { + error(node, ts.Diagnostics.Property_0_is_protected_and_only_accessible_through_an_instance_of_class_1, symbolToString(prop), typeToString(enclosingClass)); + return false; + } + return true; + } + function checkPropertyAccessExpression(node) { + return checkPropertyAccessExpressionOrQualifiedName(node, node.expression, node.name); + } + function checkQualifiedName(node) { + return checkPropertyAccessExpressionOrQualifiedName(node, node.left, node.right); + } + function checkPropertyAccessExpressionOrQualifiedName(node, left, right) { + var type = checkExpression(left); + if (isTypeAny(type)) { + return type; + } + var apparentType = getApparentType(getWidenedType(type)); + if (apparentType === unknownType) { + // handle cases when type is Type parameter with invalid constraint + return unknownType; + } + var prop = getPropertyOfType(apparentType, right.text); + if (!prop) { + if (right.text) { + error(right, ts.Diagnostics.Property_0_does_not_exist_on_type_1, ts.declarationNameToString(right), typeToString(type.flags & 33554432 /* ThisType */ ? apparentType : type)); + } + return unknownType; + } + getNodeLinks(node).resolvedSymbol = prop; + if (prop.parent && prop.parent.flags & 32 /* Class */) { + checkClassPropertyAccess(node, left, apparentType, prop); + } + return getTypeOfSymbol(prop); + } + function isValidPropertyAccess(node, propertyName) { + var left = node.kind === 166 /* PropertyAccessExpression */ + ? node.expression + : node.left; + var type = checkExpression(left); + if (type !== unknownType && !isTypeAny(type)) { + var prop = getPropertyOfType(getWidenedType(type), propertyName); + if (prop && prop.parent && prop.parent.flags & 32 /* Class */) { + return checkClassPropertyAccess(node, left, type, prop); + } + } + return true; + } + function checkIndexedAccess(node) { + // Grammar checking + if (!node.argumentExpression) { + var sourceFile = getSourceFile(node); + if (node.parent.kind === 169 /* NewExpression */ && node.parent.expression === node) { + var start = ts.skipTrivia(sourceFile.text, node.expression.end); + var end = node.end; + grammarErrorAtPos(sourceFile, start, end - start, ts.Diagnostics.new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead); + } + else { + var start = node.end - "]".length; + var end = node.end; + grammarErrorAtPos(sourceFile, start, end - start, ts.Diagnostics.Expression_expected); + } + } + // Obtain base constraint such that we can bail out if the constraint is an unknown type + var objectType = getApparentType(checkExpression(node.expression)); + var indexType = node.argumentExpression ? checkExpression(node.argumentExpression) : unknownType; + if (objectType === unknownType) { + return unknownType; + } + var isConstEnum = isConstEnumObjectType(objectType); + if (isConstEnum && + (!node.argumentExpression || node.argumentExpression.kind !== 9 /* StringLiteral */)) { + error(node.argumentExpression, ts.Diagnostics.A_const_enum_member_can_only_be_accessed_using_a_string_literal); + return unknownType; + } + // TypeScript 1.0 spec (April 2014): 4.10 Property Access + // - If IndexExpr is a string literal or a numeric literal and ObjExpr's apparent type has a property with the name + // given by that literal(converted to its string representation in the case of a numeric literal), the property access is of the type of that property. + // - Otherwise, if ObjExpr's apparent type has a numeric index signature and IndexExpr is of type Any, the Number primitive type, or an enum type, + // the property access is of the type of that index signature. + // - Otherwise, if ObjExpr's apparent type has a string index signature and IndexExpr is of type Any, the String or Number primitive type, or an enum type, + // the property access is of the type of that index signature. + // - Otherwise, if IndexExpr is of type Any, the String or Number primitive type, or an enum type, the property access is of type Any. + // See if we can index as a property. + if (node.argumentExpression) { + var name_11 = getPropertyNameForIndexedAccess(node.argumentExpression, indexType); + if (name_11 !== undefined) { + var prop = getPropertyOfType(objectType, name_11); + 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_11, symbolToString(objectType.symbol)); + return unknownType; + } + } + } + // Check for compatible indexer types. + if (isTypeAnyOrAllConstituentTypesHaveKind(indexType, 258 /* StringLike */ | 132 /* NumberLike */ | 16777216 /* ESSymbol */)) { + // Try to use a number indexer. + if (isTypeAnyOrAllConstituentTypesHaveKind(indexType, 132 /* NumberLike */)) { + var numberIndexType = getIndexTypeOfType(objectType, 1 /* Number */); + if (numberIndexType) { + return numberIndexType; + } + } + // Try to use string indexing. + var stringIndexType = getIndexTypeOfType(objectType, 0 /* String */); + if (stringIndexType) { + return stringIndexType; + } + // Fall back to any. + if (compilerOptions.noImplicitAny && !compilerOptions.suppressImplicitAnyIndexErrors && !isTypeAny(objectType)) { + error(node, ts.Diagnostics.Index_signature_of_object_type_implicitly_has_an_any_type); + } + return anyType; + } + // REVIEW: Users should know the type that was actually used. + error(node, ts.Diagnostics.An_index_expression_argument_must_be_of_type_string_number_symbol_or_any); + return unknownType; + } + /** + * If indexArgumentExpression is a string literal or number literal, returns its text. + * If indexArgumentExpression is a constant value, returns its string value. + * If indexArgumentExpression is a well known symbol, returns the property name corresponding + * to this symbol, as long as it is a proper symbol reference. + * Otherwise, returns undefined. + */ + function getPropertyNameForIndexedAccess(indexArgumentExpression, indexArgumentType) { + if (indexArgumentExpression.kind === 9 /* StringLiteral */ || indexArgumentExpression.kind === 8 /* NumericLiteral */) { + return indexArgumentExpression.text; + } + if (indexArgumentExpression.kind === 167 /* ElementAccessExpression */ || indexArgumentExpression.kind === 166 /* PropertyAccessExpression */) { + var value = getConstantValue(indexArgumentExpression); + if (value !== undefined) { + return value.toString(); + } + } + if (checkThatExpressionIsProperSymbolReference(indexArgumentExpression, indexArgumentType, /*reportError*/ false)) { + var rightHandSideName = indexArgumentExpression.name.text; + return ts.getPropertyNameForKnownSymbolName(rightHandSideName); + } + return undefined; + } + /** + * A proper symbol reference requires the following: + * 1. The property access denotes a property that exists + * 2. The expression is of the form Symbol. + * 3. The property access is of the primitive type symbol. + * 4. Symbol in this context resolves to the global Symbol object + */ + function checkThatExpressionIsProperSymbolReference(expression, expressionType, reportError) { + if (expressionType === unknownType) { + // There is already an error, so no need to report one. + return false; + } + if (!ts.isWellKnownSymbolSyntactically(expression)) { + return false; + } + // Make sure the property type is the primitive symbol type + if ((expressionType.flags & 16777216 /* ESSymbol */) === 0) { + if (reportError) { + error(expression, ts.Diagnostics.A_computed_property_name_of_the_form_0_must_be_of_type_symbol, ts.getTextOfNode(expression)); + } + return false; + } + // The name is Symbol., so make sure Symbol actually resolves to the + // global Symbol object + var leftHandSide = expression.expression; + var leftHandSideSymbol = getResolvedSymbol(leftHandSide); + if (!leftHandSideSymbol) { + return false; + } + var globalESSymbol = getGlobalESSymbolConstructorSymbol(); + if (!globalESSymbol) { + // Already errored when we tried to look up the symbol + return false; + } + if (leftHandSideSymbol !== globalESSymbol) { + if (reportError) { + error(leftHandSide, ts.Diagnostics.Symbol_reference_does_not_refer_to_the_global_Symbol_constructor_object); + } + return false; + } + return true; + } + function resolveUntypedCall(node) { + if (node.kind === 170 /* TaggedTemplateExpression */) { + checkExpression(node.template); + } + else if (node.kind !== 139 /* Decorator */) { + ts.forEach(node.arguments, function (argument) { + checkExpression(argument); + }); + } + return anySignature; + } + function resolveErrorCall(node) { + resolveUntypedCall(node); + return unknownSignature; + } + // Re-order candidate signatures into the result array. Assumes the result array to be empty. + // The candidate list orders groups in reverse, but within a group signatures are kept in declaration order + // A nit here is that we reorder only signatures that belong to the same symbol, + // so order how inherited signatures are processed is still preserved. + // interface A { (x: string): void } + // interface B extends A { (x: 'foo'): string } + // let b: B; + // b('foo') // <- here overloads should be processed as [(x:'foo'): string, (x: string): void] + function reorderCandidates(signatures, result) { + var lastParent; + var lastSymbol; + var cutoffIndex = 0; + var index; + var specializedIndex = -1; + var spliceIndex; + ts.Debug.assert(!result.length); + for (var _i = 0; _i < signatures.length; _i++) { + var signature = signatures[_i]; + var symbol = signature.declaration && getSymbolOfNode(signature.declaration); + var parent_5 = signature.declaration && signature.declaration.parent; + if (!lastSymbol || symbol === lastSymbol) { + if (lastParent && parent_5 === lastParent) { + index++; + } + else { + lastParent = parent_5; + index = cutoffIndex; + } + } + else { + // 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_5; + } + lastSymbol = symbol; + // specialized signatures always need to be placed before non-specialized signatures regardless + // of the cutoff position; see GH#1133 + if (signature.hasStringLiterals) { + specializedIndex++; + spliceIndex = specializedIndex; + // The cutoff index always needs to be greater than or equal to the specialized signature index + // in order to prevent non-specialized signatures from being added before a specialized + // signature. + cutoffIndex++; + } + else { + spliceIndex = index; + } + result.splice(spliceIndex, 0, signature); + } + } + function getSpreadArgumentIndex(args) { + for (var i = 0; i < args.length; i++) { + var arg = args[i]; + if (arg && arg.kind === 185 /* SpreadElementExpression */) { + return i; + } + } + return -1; + } + function hasCorrectArity(node, args, signature) { + var adjustedArgCount; // Apparent number of arguments we will have in this call + var typeArguments; // Type arguments (undefined if none) + var callIsIncomplete; // In incomplete call we want to be lenient when we have too few arguments + var isDecorator; + var spreadArgIndex = -1; + if (node.kind === 170 /* TaggedTemplateExpression */) { + var tagExpression = node; + // Even if the call is incomplete, we'll have a missing expression as our last argument, + // so we can say the count is just the arg list length + adjustedArgCount = args.length; + typeArguments = undefined; + if (tagExpression.template.kind === 183 /* TemplateExpression */) { + // If a tagged template expression lacks a tail literal, the call is incomplete. + // Specifically, a template only can end in a TemplateTail or a Missing literal. + var templateExpression = tagExpression.template; + var lastSpan = ts.lastOrUndefined(templateExpression.templateSpans); + ts.Debug.assert(lastSpan !== undefined); // we should always have at least one span. + callIsIncomplete = ts.nodeIsMissing(lastSpan.literal) || !!lastSpan.literal.isUnterminated; + } + else { + // If the template didn't end in a backtick, or its beginning occurred right prior to EOF, + // 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 */); + callIsIncomplete = !!templateLiteral.isUnterminated; + } + } + else if (node.kind === 139 /* Decorator */) { + isDecorator = true; + typeArguments = undefined; + adjustedArgCount = getEffectiveArgumentCount(node, /*args*/ undefined, signature); + } + else { + var callExpression = node; + if (!callExpression.arguments) { + // This only happens when we have something of the form: 'new C' + ts.Debug.assert(callExpression.kind === 169 /* NewExpression */); + return signature.minArgumentCount === 0; + } + // For IDE scenarios we may have an incomplete call, so a trailing comma is tantamount to adding another argument. + adjustedArgCount = callExpression.arguments.hasTrailingComma ? args.length + 1 : args.length; + // If we are missing the close paren, the call is incomplete. + callIsIncomplete = callExpression.arguments.end === callExpression.end; + typeArguments = callExpression.typeArguments; + spreadArgIndex = getSpreadArgumentIndex(args); + } + // If the user supplied type arguments, but the number of type arguments does not match + // the declared number of type parameters, the call has an incorrect arity. + var hasRightNumberOfTypeArgs = !typeArguments || + (signature.typeParameters && typeArguments.length === signature.typeParameters.length); + if (!hasRightNumberOfTypeArgs) { + return false; + } + // If spread arguments are present, check that they correspond to a rest parameter. If so, no + // further checking is necessary. + if (spreadArgIndex >= 0) { + return isRestParameterIndex(signature, spreadArgIndex); + } + // Too many arguments implies incorrect arity. + if (!signature.hasRestParameter && adjustedArgCount > signature.parameters.length) { + return false; + } + // If the call is incomplete, we should skip the lower bound check. + var hasEnoughArguments = adjustedArgCount >= signature.minArgumentCount; + return callIsIncomplete || hasEnoughArguments; + } + // If type has a single call signature and no other members, return that signature. Otherwise, return undefined. + function getSingleCallSignature(type) { + if (type.flags & 80896 /* ObjectType */) { + var resolved = resolveStructuredTypeMembers(type); + if (resolved.callSignatures.length === 1 && resolved.constructSignatures.length === 0 && + resolved.properties.length === 0 && !resolved.stringIndexType && !resolved.numberIndexType) { + return resolved.callSignatures[0]; + } + } + return undefined; + } + // Instantiate a generic signature in the context of a non-generic signature (section 3.8.5 in TypeScript spec) + function instantiateSignatureInContextOf(signature, contextualSignature, contextualMapper) { + var context = createInferenceContext(signature.typeParameters, /*inferUnionTypes*/ true); + forEachMatchingParameterType(contextualSignature, signature, function (source, target) { + // Type parameters from outer context referenced by source type are fixed by instantiation of the source type + inferTypes(context, instantiateType(source, contextualMapper), target); + }); + return getSignatureInstantiation(signature, getInferredTypes(context)); + } + function inferTypeArguments(node, signature, args, excludeArgument, context) { + var typeParameters = signature.typeParameters; + var inferenceMapper = createInferenceMapper(context); + // Clear out all the inference results from the last time inferTypeArguments was called on this context + for (var i = 0; i < typeParameters.length; i++) { + // As an optimization, we don't have to clear (and later recompute) inferred types + // for type parameters that have already been fixed on the previous call to inferTypeArguments. + // It would be just as correct to reset all of them. But then we'd be repeating the same work + // for the type parameters that were fixed, namely the work done by getInferredType. + if (!context.inferences[i].isFixed) { + context.inferredTypes[i] = undefined; + } + } + // On this call to inferTypeArguments, we may get more inferences for certain type parameters that were not + // fixed last time. This means that a type parameter that failed inference last time may succeed this time, + // or vice versa. Therefore, the failedTypeParameterIndex is useless if it points to an unfixed type parameter, + // because it may change. So here we reset it. However, getInferredType will not revisit any type parameters + // that were previously fixed. So if a fixed type parameter failed previously, it will fail again because + // it will contain the exact same set of inferences. So if we reset the index from a fixed type parameter, + // we will lose information that we won't recover this time around. + if (context.failedTypeParameterIndex !== undefined && !context.inferences[context.failedTypeParameterIndex].isFixed) { + context.failedTypeParameterIndex = undefined; + } + // We perform two passes over the arguments. In the first pass we infer from all arguments, but use + // wildcards for all context sensitive function expressions. + var argCount = getEffectiveArgumentCount(node, args, signature); + 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 !== 187 /* OmittedExpression */) { + var paramType = getTypeAtPosition(signature, i); + var argType = getEffectiveArgumentType(node, i, arg); + // If the effective argument type is 'undefined', there is no synthetic type + // for the argument. In that case, we should check the argument. + if (argType === undefined) { + // For context sensitive arguments we pass the identityMapper, which is a signal to treat all + // context sensitive function expressions as wildcards + var mapper = excludeArgument && excludeArgument[i] !== undefined ? identityMapper : inferenceMapper; + argType = checkExpressionWithContextualType(arg, paramType, mapper); + } + inferTypes(context, argType, paramType); + } + } + // In the second pass we visit only context sensitive arguments, and only those that aren't excluded, this + // time treating function expressions normally (which may cause previously inferred type arguments to be fixed + // as we construct types for contextually typed parameters) + // Decorators will not have `excludeArgument`, as their arguments cannot be contextually typed. + // Tagged template expressions will always have `undefined` for `excludeArgument[0]`. + if (excludeArgument) { + for (var i = 0; i < argCount; i++) { + // No need to check for omitted args and template expressions, their exlusion value is always undefined + if (excludeArgument[i] === false) { + var arg = args[i]; + var paramType = getTypeAtPosition(signature, i); + inferTypes(context, checkExpressionWithContextualType(arg, paramType, inferenceMapper), paramType); + } + } + } + getInferredTypes(context); + } + function checkTypeArguments(signature, typeArguments, typeArgumentResultTypes, reportErrors, headMessage) { + var typeParameters = signature.typeParameters; + var typeArgumentsAreAssignable = true; + for (var i = 0; i < typeParameters.length; i++) { + var typeArgNode = typeArguments[i]; + var typeArgument = getTypeFromTypeNode(typeArgNode); + // Do not push on this array! It has a preallocated length + typeArgumentResultTypes[i] = typeArgument; + if (typeArgumentsAreAssignable /* so far */) { + var constraint = getConstraintOfTypeParameter(typeParameters[i]); + if (constraint) { + var errorInfo = void 0; + var typeArgumentHeadMessage = ts.Diagnostics.Type_0_does_not_satisfy_the_constraint_1; + if (reportErrors && headMessage) { + errorInfo = ts.chainDiagnosticMessages(errorInfo, typeArgumentHeadMessage); + typeArgumentHeadMessage = headMessage; + } + typeArgumentsAreAssignable = checkTypeAssignableTo(typeArgument, constraint, reportErrors ? typeArgNode : undefined, typeArgumentHeadMessage, errorInfo); + } + } + } + return typeArgumentsAreAssignable; + } + function checkApplicableSignature(node, args, signature, relation, excludeArgument, reportErrors) { + var argCount = getEffectiveArgumentCount(node, args, signature); + 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 !== 187 /* OmittedExpression */) { + // Check spread elements against rest type (from arity check we know spread argument corresponds to a rest parameter) + var paramType = getTypeAtPosition(signature, i); + var argType = getEffectiveArgumentType(node, i, arg); + // 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) { + argType = arg.kind === 9 /* StringLiteral */ && !reportErrors + ? getStringLiteralType(arg) + : checkExpressionWithContextualType(arg, paramType, excludeArgument && excludeArgument[i] ? identityMapper : undefined); + } + // Use argument expression as error location when reporting errors + var errorNode = reportErrors ? getEffectiveArgumentErrorNode(node, i, arg) : undefined; + var headMessage = ts.Diagnostics.Argument_of_type_0_is_not_assignable_to_parameter_of_type_1; + if (!checkTypeRelatedTo(argType, paramType, relation, errorNode, headMessage)) { + return false; + } + } + } + return true; + } + /** + * Returns the effective arguments for an expression that works like a function invocation. + * + * If 'node' is a CallExpression or a NewExpression, then its argument list is returned. + * If 'node' is a TaggedTemplateExpression, a new argument list is constructed from the substitution + * expressions, where the first element of the list is `undefined`. + * If 'node' is a Decorator, the argument list will be `undefined`, and its arguments and types + * will be supplied from calls to `getEffectiveArgumentCount` and `getEffectiveArgumentType`. + */ + function getEffectiveCallArguments(node) { + var args; + if (node.kind === 170 /* TaggedTemplateExpression */) { + var template = node.template; + args = [undefined]; + if (template.kind === 183 /* TemplateExpression */) { + ts.forEach(template.templateSpans, function (span) { + args.push(span.expression); + }); + } + } + else if (node.kind === 139 /* Decorator */) { + // For a decorator, we return undefined as we will determine + // the number and types of arguments for a decorator using + // `getEffectiveArgumentCount` and `getEffectiveArgumentType` below. + return undefined; + } + else { + args = node.arguments || emptyArray; + } + return args; + } + /** + * Returns the effective argument count for a node that works like a function invocation. + * If 'node' is a Decorator, the number of arguments is derived from the decoration + * target and the signature: + * If 'node.target' is a class declaration or class expression, the effective argument + * count is 1. + * If 'node.target' is a parameter declaration, the effective argument count is 3. + * If 'node.target' is a property declaration, the effective argument count is 2. + * If 'node.target' is a method or accessor declaration, the effective argument count + * is 3, although it can be 2 if the signature only accepts two arguments, allowing + * us to match a property decorator. + * Otherwise, the argument count is the length of the 'args' array. + */ + function getEffectiveArgumentCount(node, args, signature) { + if (node.kind === 139 /* Decorator */) { + switch (node.parent.kind) { + case 214 /* ClassDeclaration */: + case 186 /* ClassExpression */: + // A class decorator will have one argument (see `ClassDecorator` in core.d.ts) + return 1; + case 141 /* PropertyDeclaration */: + // A property declaration decorator will have two arguments (see + // `PropertyDecorator` in core.d.ts) + return 2; + case 143 /* MethodDeclaration */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: + // A method or accessor declaration decorator will have two or three arguments (see + // `PropertyDecorator` and `MethodDecorator` in core.d.ts) + // If we are emitting decorators for ES3, we will only pass two arguments. + if (languageVersion === 0 /* ES3 */) { + return 2; + } + // If the method decorator signature only accepts a target and a key, we will only + // type check those arguments. + return signature.parameters.length >= 3 ? 3 : 2; + case 138 /* Parameter */: + // A parameter declaration decorator will have three arguments (see + // `ParameterDecorator` in core.d.ts) + return 3; + } + } + else { + return args.length; + } + } + /** + * Returns the effective type of the first argument to a decorator. + * If 'node' is a class declaration or class expression, the effective argument type + * is the type of the static side of the class. + * If 'node' is a parameter declaration, the effective argument type is either the type + * of the static or instance side of the class for the parameter's parent method, + * depending on whether the method is declared static. + * For a constructor, the type is always the type of the static side of the class. + * If 'node' is a property, method, or accessor declaration, the effective argument + * type is the type of the static or instance side of the parent class for class + * element, depending on whether the element is declared static. + */ + function getEffectiveDecoratorFirstArgumentType(node) { + // The first argument to a decorator is its `target`. + if (node.kind === 214 /* 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 === 138 /* Parameter */) { + // For a parameter decorator, the `target` is the parent type of the + // parameter's containing method. + node = node.parent; + if (node.kind === 144 /* Constructor */) { + var classSymbol = getSymbolOfNode(node); + return getTypeOfSymbol(classSymbol); + } + } + if (node.kind === 141 /* PropertyDeclaration */ || + node.kind === 143 /* MethodDeclaration */ || + node.kind === 145 /* GetAccessor */ || + node.kind === 146 /* SetAccessor */) { + // For a property or method decorator, the `target` is the + // "static"-side type of the parent of the member if the member is + // declared "static"; otherwise, it is the "instance"-side type of the + // parent of the member. + return getParentTypeOfClassElement(node); + } + ts.Debug.fail("Unsupported decorator target."); + return unknownType; + } + /** + * Returns the effective type for the second argument to a decorator. + * If 'node' is a parameter, its effective argument type is one of the following: + * If 'node.parent' is a constructor, the effective argument type is 'any', as we + * will emit `undefined`. + * If 'node.parent' is a member with an identifier, numeric, or string literal name, + * the effective argument type will be a string literal type for the member name. + * If 'node.parent' is a computed property name, the effective argument type will + * either be a symbol type or the string type. + * If 'node' is a member with an identifier, numeric, or string literal name, the + * effective argument type will be a string literal type for the member name. + * If 'node' is a computed property name, the effective argument type will either + * be a symbol type or the string type. + * A class decorator does not have a second argument type. + */ + function getEffectiveDecoratorSecondArgumentType(node) { + // The second argument to a decorator is its `propertyKey` + if (node.kind === 214 /* ClassDeclaration */) { + ts.Debug.fail("Class decorators should not have a second synthetic argument."); + return unknownType; + } + if (node.kind === 138 /* Parameter */) { + node = node.parent; + if (node.kind === 144 /* Constructor */) { + // For a constructor parameter decorator, the `propertyKey` will be `undefined`. + return anyType; + } + } + if (node.kind === 141 /* PropertyDeclaration */ || + node.kind === 143 /* MethodDeclaration */ || + node.kind === 145 /* GetAccessor */ || + node.kind === 146 /* SetAccessor */) { + // The `propertyKey` for a property or method decorator will be a + // string literal type if the member name is an identifier, number, or string; + // otherwise, if the member name is a computed property name it will + // be either string or symbol. + var element = node; + switch (element.name.kind) { + case 69 /* Identifier */: + case 8 /* NumericLiteral */: + case 9 /* StringLiteral */: + return getStringLiteralType(element.name); + case 136 /* ComputedPropertyName */: + var nameType = checkComputedPropertyName(element.name); + if (allConstituentTypesHaveKind(nameType, 16777216 /* ESSymbol */)) { + return nameType; + } + else { + return stringType; + } + default: + ts.Debug.fail("Unsupported property name."); + return unknownType; + } + } + ts.Debug.fail("Unsupported decorator target."); + return unknownType; + } + /** + * Returns the effective argument type for the third argument to a decorator. + * If 'node' is a parameter, the effective argument type is the number type. + * If 'node' is a method or accessor, the effective argument type is a + * `TypedPropertyDescriptor` instantiated with the type of the member. + * Class and property decorators do not have a third effective argument. + */ + function getEffectiveDecoratorThirdArgumentType(node) { + // The third argument to a decorator is either its `descriptor` for a method decorator + // or its `parameterIndex` for a paramter decorator + if (node.kind === 214 /* ClassDeclaration */) { + ts.Debug.fail("Class decorators should not have a third synthetic argument."); + return unknownType; + } + if (node.kind === 138 /* Parameter */) { + // The `parameterIndex` for a parameter decorator is always a number + return numberType; + } + if (node.kind === 141 /* PropertyDeclaration */) { + ts.Debug.fail("Property decorators should not have a third synthetic argument."); + return unknownType; + } + if (node.kind === 143 /* MethodDeclaration */ || + node.kind === 145 /* GetAccessor */ || + node.kind === 146 /* SetAccessor */) { + // The `descriptor` for a method decorator will be a `TypedPropertyDescriptor` + // for the type of the member. + var propertyType = getTypeOfNode(node); + return createTypedPropertyDescriptorType(propertyType); + } + ts.Debug.fail("Unsupported decorator target."); + return unknownType; + } + /** + * Returns the effective argument type for the provided argument to a decorator. + */ + function getEffectiveDecoratorArgumentType(node, argIndex) { + if (argIndex === 0) { + return getEffectiveDecoratorFirstArgumentType(node.parent); + } + else if (argIndex === 1) { + return getEffectiveDecoratorSecondArgumentType(node.parent); + } + else if (argIndex === 2) { + return getEffectiveDecoratorThirdArgumentType(node.parent); + } + ts.Debug.fail("Decorators should not have a fourth synthetic argument."); + return unknownType; + } + /** + * Gets the effective argument type for an argument in a call expression. + */ + function getEffectiveArgumentType(node, argIndex, arg) { + // 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 === 139 /* Decorator */) { + return getEffectiveDecoratorArgumentType(node, argIndex); + } + else if (argIndex === 0 && node.kind === 170 /* TaggedTemplateExpression */) { + return globalTemplateStringsArrayType; + } + // This is not a synthetic argument, so we return 'undefined' + // to signal that the caller needs to check the argument. + return undefined; + } + /** + * Gets the effective argument expression for an argument in a call expression. + */ + function getEffectiveArgument(node, args, argIndex) { + // For a decorator or the first argument of a tagged template expression we return undefined. + if (node.kind === 139 /* Decorator */ || + (argIndex === 0 && node.kind === 170 /* TaggedTemplateExpression */)) { + return undefined; + } + return args[argIndex]; + } + /** + * Gets the error node to use when reporting errors for an effective argument. + */ + function getEffectiveArgumentErrorNode(node, argIndex, arg) { + if (node.kind === 139 /* Decorator */) { + // For a decorator, we use the expression of the decorator for error reporting. + return node.expression; + } + else if (argIndex === 0 && node.kind === 170 /* TaggedTemplateExpression */) { + // For a the first argument of a tagged template expression, we use the template of the tag for error reporting. + return node.template; + } + else { + return arg; + } + } + function resolveCall(node, signatures, candidatesOutArray, headMessage) { + var isTaggedTemplate = node.kind === 170 /* TaggedTemplateExpression */; + var isDecorator = node.kind === 139 /* Decorator */; + var typeArguments; + if (!isTaggedTemplate && !isDecorator) { + typeArguments = node.typeArguments; + // We already perform checking on the type arguments on the class declaration itself. + if (node.expression.kind !== 95 /* SuperKeyword */) { + ts.forEach(typeArguments, checkSourceElement); + } + } + var candidates = candidatesOutArray || []; + // reorderCandidates fills up the candidates array directly + reorderCandidates(signatures, candidates); + if (!candidates.length) { + reportError(ts.Diagnostics.Supplied_parameters_do_not_match_any_signature_of_call_target); + return resolveErrorCall(node); + } + var args = getEffectiveCallArguments(node); + // The following applies to any value of 'excludeArgument[i]': + // - true: the argument at 'i' is susceptible to a one-time permanent contextual typing. + // - undefined: the argument at 'i' is *not* susceptible to permanent contextual typing. + // - false: the argument at 'i' *was* and *has been* permanently contextually typed. + // + // The idea is that we will perform type argument inference & assignability checking once + // without using the susceptible parameters that are functions, and once more for each of those + // parameters, contextually typing each as we go along. + // + // For a tagged template, then the first argument be 'undefined' if necessary + // because it represents a TemplateStringsArray. + // + // For a decorator, no arguments are susceptible to contextual typing due to the fact + // decorators are applied to a declaration by the emitter, and not to an expression. + var excludeArgument; + if (!isDecorator) { + // We do not need to call `getEffectiveArgumentCount` here as it only + // applies when calculating the number of arguments for a decorator. + for (var i = isTaggedTemplate ? 1 : 0; i < args.length; i++) { + if (isContextSensitive(args[i])) { + if (!excludeArgument) { + excludeArgument = new Array(args.length); + } + excludeArgument[i] = true; + } + } + } + // The following variables are captured and modified by calls to chooseOverload. + // If overload resolution or type argument inference fails, we want to report the + // best error possible. The best error is one which says that an argument was not + // assignable to a parameter. This implies that everything else about the overload + // was fine. So if there is any overload that is only incorrect because of an + // argument, we will report an error on that one. + // + // function foo(s: string) {} + // function foo(n: number) {} // Report argument error on this overload + // function foo() {} + // foo(true); + // + // If none of the overloads even made it that far, there are two possibilities. + // There was a problem with type arguments for some overload, in which case + // report an error on that. Or none of the overloads even had correct arity, + // in which case give an arity error. + // + // function foo(x: T, y: T) {} // Report type argument inference error + // function foo() {} + // foo(0, true); + // + var candidateForArgumentError; + var candidateForTypeArgumentError; + var resultOfFailedInference; + var result; + // 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 + // of those signatures becomes the return type of the function call. + // Otherwise, the return type of the first signature in the candidate list becomes the return + // type of the function call. + // + // Whether the call is an error is determined by assignability of the arguments. The subtype pass + // is just important for choosing the best signature. So in the case where there is only one + // signature, the subtype pass is useless. So skipping it is an optimization. + if (candidates.length > 1) { + result = chooseOverload(candidates, subtypeRelation); + } + if (!result) { + // Reinitialize these pointers for round two + candidateForArgumentError = undefined; + candidateForTypeArgumentError = undefined; + resultOfFailedInference = undefined; + result = chooseOverload(candidates, assignableRelation); + } + if (result) { + return result; + } + // No signatures were applicable. Now report errors based on the last applicable signature with + // no arguments excluded from assignability checks. + // If candidate is undefined, it means that no candidates had a suitable arity. In that case, + // skip the checkApplicableSignature check. + if (candidateForArgumentError) { + // excludeArgument is undefined, in this case also equivalent to [undefined, undefined, ...] + // The importance of excludeArgument is to prevent us from typing function expression parameters + // in arguments too early. If possible, we'd like to only type them once we know the correct + // overload. However, this matters for the case where the call is correct. When the call is + // an error, we don't need to exclude any arguments, although it would cause no harm to do so. + checkApplicableSignature(node, args, candidateForArgumentError, assignableRelation, /*excludeArgument*/ undefined, /*reportErrors*/ true); + } + else if (candidateForTypeArgumentError) { + if (!isTaggedTemplate && !isDecorator && typeArguments) { + checkTypeArguments(candidateForTypeArgumentError, node.typeArguments, [], /*reportErrors*/ true, headMessage); + } + else { + ts.Debug.assert(resultOfFailedInference.failedTypeParameterIndex >= 0); + var failedTypeParameter = candidateForTypeArgumentError.typeParameters[resultOfFailedInference.failedTypeParameterIndex]; + var inferenceCandidates = getInferenceCandidates(resultOfFailedInference, resultOfFailedInference.failedTypeParameterIndex); + var diagnosticChainHead = ts.chainDiagnosticMessages(/*details*/ undefined, // details will be provided by call to reportNoCommonSupertypeError + ts.Diagnostics.The_type_argument_for_type_parameter_0_cannot_be_inferred_from_the_usage_Consider_specifying_the_type_arguments_explicitly, typeToString(failedTypeParameter)); + if (headMessage) { + diagnosticChainHead = ts.chainDiagnosticMessages(diagnosticChainHead, headMessage); + } + reportNoCommonSupertypeError(inferenceCandidates, node.expression || node.tag, diagnosticChainHead); + } + } + else { + reportError(ts.Diagnostics.Supplied_parameters_do_not_match_any_signature_of_call_target); + } + // No signature was applicable. We have already reported the errors for the invalid signature. + // If this is a type resolution session, e.g. Language Service, try to get better information that anySignature. + // Pick the first candidate that matches the arity. This way we can get a contextual type for cases like: + // declare function f(a: { xa: number; xb: number; }); + // f({ | + if (!produceDiagnostics) { + for (var _i = 0; _i < candidates.length; _i++) { + var candidate = candidates[_i]; + if (hasCorrectArity(node, args, candidate)) { + if (candidate.typeParameters && typeArguments) { + candidate = getSignatureInstantiation(candidate, ts.map(typeArguments, getTypeFromTypeNode)); + } + return candidate; + } + } + } + return resolveErrorCall(node); + function reportError(message, arg0, arg1, arg2) { + var errorInfo; + errorInfo = ts.chainDiagnosticMessages(errorInfo, message, arg0, arg1, arg2); + if (headMessage) { + errorInfo = ts.chainDiagnosticMessages(errorInfo, headMessage); + } + diagnostics.add(ts.createDiagnosticForNodeFromMessageChain(node, errorInfo)); + } + function chooseOverload(candidates, relation) { + for (var _i = 0; _i < candidates.length; _i++) { + var originalCandidate = candidates[_i]; + if (!hasCorrectArity(node, args, originalCandidate)) { + continue; + } + var candidate = void 0; + var typeArgumentsAreValid = void 0; + var inferenceContext = originalCandidate.typeParameters + ? createInferenceContext(originalCandidate.typeParameters, /*inferUnionTypes*/ false) + : undefined; + while (true) { + candidate = originalCandidate; + if (candidate.typeParameters) { + var typeArgumentTypes = void 0; + if (typeArguments) { + typeArgumentTypes = new Array(candidate.typeParameters.length); + typeArgumentsAreValid = checkTypeArguments(candidate, typeArguments, typeArgumentTypes, /*reportErrors*/ false); + } + else { + inferTypeArguments(node, candidate, args, excludeArgument, inferenceContext); + typeArgumentsAreValid = inferenceContext.failedTypeParameterIndex === undefined; + typeArgumentTypes = inferenceContext.inferredTypes; + } + if (!typeArgumentsAreValid) { + break; + } + candidate = getSignatureInstantiation(candidate, typeArgumentTypes); + } + if (!checkApplicableSignature(node, args, candidate, relation, excludeArgument, /*reportErrors*/ false)) { + break; + } + var index = excludeArgument ? ts.indexOf(excludeArgument, true) : -1; + if (index < 0) { + return candidate; + } + excludeArgument[index] = false; + } + // A post-mortem of this iteration of the loop. The signature was not applicable, + // so we want to track it as a candidate for reporting an error. If the candidate + // had no type parameters, or had no issues related to type arguments, we can + // report an error based on the arguments. If there was an issue with type + // arguments, then we can only report an error based on the type arguments. + if (originalCandidate.typeParameters) { + var instantiatedCandidate = candidate; + if (typeArgumentsAreValid) { + candidateForArgumentError = instantiatedCandidate; + } + else { + candidateForTypeArgumentError = originalCandidate; + if (!typeArguments) { + resultOfFailedInference = inferenceContext; + } + } + } + else { + ts.Debug.assert(originalCandidate === candidate); + candidateForArgumentError = originalCandidate; + } + } + return undefined; + } + } + function resolveCallExpression(node, candidatesOutArray) { + if (node.expression.kind === 95 /* SuperKeyword */) { + var superType = checkSuperExpression(node.expression); + if (superType !== unknownType) { + // In super call, the candidate signatures are the matching arity signatures of the base constructor function instantiated + // with the type arguments specified in the extends clause. + var baseTypeNode = ts.getClassExtendsHeritageClauseElement(ts.getContainingClass(node)); + var baseConstructors = getInstantiatedConstructorsForTypeArguments(superType, baseTypeNode.typeArguments); + return resolveCall(node, baseConstructors, candidatesOutArray); + } + return resolveUntypedCall(node); + } + var funcType = checkExpression(node.expression); + var apparentType = getApparentType(funcType); + if (apparentType === unknownType) { + // Another error has already been reported + return resolveErrorCall(node); + } + // Technically, this signatures list may be incomplete. We are taking the apparent type, + // but we are not including call signatures that may have been added to the Object or + // Function interface, since they have none by default. This is a bit of a leap of faith + // that the user will not add any. + var callSignatures = getSignaturesOfType(apparentType, 0 /* Call */); + var constructSignatures = getSignaturesOfType(apparentType, 1 /* Construct */); + // TS 1.0 spec: 4.12 + // If FuncExpr is of type Any, or of an object type that has no call or construct signatures + // but is a subtype of the Function interface, the call is an untyped function call. In an + // untyped function call no TypeArgs are permitted, Args can be any argument list, no contextual + // types are provided for the argument expressions, and the result is always of type Any. + // We exclude union types because we may have a union of function types that happen to have + // no common signatures. + if (isTypeAny(funcType) || (!callSignatures.length && !constructSignatures.length && !(funcType.flags & 16384 /* Union */) && isTypeAssignableTo(funcType, globalFunctionType))) { + // The unknownType indicates that an error already occured (and was reported). No + // need to report another error in this case. + if (funcType !== unknownType && node.typeArguments) { + error(node, ts.Diagnostics.Untyped_function_calls_may_not_accept_type_arguments); + } + return resolveUntypedCall(node); + } + // If FuncExpr's apparent type(section 3.8.1) is a function type, the call is a typed function call. + // TypeScript employs overload resolution in typed function calls in order to support functions + // with multiple call signatures. + if (!callSignatures.length) { + if (constructSignatures.length) { + error(node, ts.Diagnostics.Value_of_type_0_is_not_callable_Did_you_mean_to_include_new, typeToString(funcType)); + } + else { + error(node, ts.Diagnostics.Cannot_invoke_an_expression_whose_type_lacks_a_call_signature); + } + return resolveErrorCall(node); + } + return resolveCall(node, callSignatures, candidatesOutArray); + } + function resolveNewExpression(node, candidatesOutArray) { + if (node.arguments && languageVersion < 1 /* ES5 */) { + var spreadIndex = getSpreadArgumentIndex(node.arguments); + if (spreadIndex >= 0) { + error(node.arguments[spreadIndex], ts.Diagnostics.Spread_operator_in_new_expressions_is_only_available_when_targeting_ECMAScript_5_and_higher); + } + } + var expressionType = checkExpression(node.expression); + // If expressionType's apparent type(section 3.8.1) is an object type with one or + // more construct signatures, the expression is processed in the same manner as a + // function call, but using the construct signatures as the initial set of candidate + // signatures for overload resolution. The result type of the function call becomes + // the result type of the operation. + expressionType = getApparentType(expressionType); + if (expressionType === unknownType) { + // Another error has already been reported + return resolveErrorCall(node); + } + // If the expression is a class of abstract type, then it cannot be instantiated. + // Note, only class declarations can be declared abstract. + // In the case of a merged class-module or class-interface declaration, + // only the class declaration node will have the Abstract flag set. + var valueDecl = expressionType.symbol && getClassLikeDeclarationOfSymbol(expressionType.symbol); + if (valueDecl && valueDecl.flags & 256 /* Abstract */) { + error(node, ts.Diagnostics.Cannot_create_an_instance_of_the_abstract_class_0, ts.declarationNameToString(valueDecl.name)); + return resolveErrorCall(node); + } + // TS 1.0 spec: 4.11 + // If expressionType is of type Any, Args can be any argument + // list and the result of the operation is of type Any. + if (isTypeAny(expressionType)) { + if (node.typeArguments) { + error(node, ts.Diagnostics.Untyped_function_calls_may_not_accept_type_arguments); + } + return resolveUntypedCall(node); + } + // Technically, this signatures list may be incomplete. We are taking the apparent type, + // but we are not including construct signatures that may have been added to the Object or + // Function interface, since they have none by default. This is a bit of a leap of faith + // that the user will not add any. + var constructSignatures = getSignaturesOfType(expressionType, 1 /* Construct */); + if (constructSignatures.length) { + return resolveCall(node, constructSignatures, candidatesOutArray); + } + // If expressionType's apparent type is an object type with no construct signatures but + // one or more call signatures, the expression is processed as a function call. A compile-time + // error occurs if the result of the function call is not Void. The type of the result of the + // operation is Any. + var callSignatures = getSignaturesOfType(expressionType, 0 /* Call */); + if (callSignatures.length) { + var signature = resolveCall(node, callSignatures, candidatesOutArray); + if (getReturnTypeOfSignature(signature) !== voidType) { + error(node, ts.Diagnostics.Only_a_void_function_can_be_called_with_the_new_keyword); + } + return signature; + } + error(node, ts.Diagnostics.Cannot_use_new_with_an_expression_whose_type_lacks_a_call_or_construct_signature); + return resolveErrorCall(node); + } + function resolveTaggedTemplateExpression(node, candidatesOutArray) { + var tagType = checkExpression(node.tag); + var apparentType = getApparentType(tagType); + if (apparentType === unknownType) { + // Another error has already been reported + return resolveErrorCall(node); + } + var callSignatures = getSignaturesOfType(apparentType, 0 /* Call */); + if (isTypeAny(tagType) || (!callSignatures.length && !(tagType.flags & 16384 /* Union */) && isTypeAssignableTo(tagType, globalFunctionType))) { + return resolveUntypedCall(node); + } + if (!callSignatures.length) { + error(node, ts.Diagnostics.Cannot_invoke_an_expression_whose_type_lacks_a_call_signature); + return resolveErrorCall(node); + } + return resolveCall(node, callSignatures, candidatesOutArray); + } + /** + * Gets the localized diagnostic head message to use for errors when resolving a decorator as a call expression. + */ + function getDiagnosticHeadMessageForDecoratorResolution(node) { + switch (node.parent.kind) { + case 214 /* ClassDeclaration */: + case 186 /* ClassExpression */: + return ts.Diagnostics.Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression; + case 138 /* Parameter */: + return ts.Diagnostics.Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression; + case 141 /* PropertyDeclaration */: + return ts.Diagnostics.Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression; + case 143 /* MethodDeclaration */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: + return ts.Diagnostics.Unable_to_resolve_signature_of_method_decorator_when_called_as_an_expression; + } + } + /** + * Resolves a decorator as if it were a call expression. + */ + function resolveDecorator(node, candidatesOutArray) { + var funcType = checkExpression(node.expression); + var apparentType = getApparentType(funcType); + if (apparentType === unknownType) { + return resolveErrorCall(node); + } + var callSignatures = getSignaturesOfType(apparentType, 0 /* Call */); + if (funcType === anyType || (!callSignatures.length && !(funcType.flags & 16384 /* Union */) && isTypeAssignableTo(funcType, globalFunctionType))) { + return resolveUntypedCall(node); + } + var headMessage = getDiagnosticHeadMessageForDecoratorResolution(node); + if (!callSignatures.length) { + var errorInfo; + errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.Cannot_invoke_an_expression_whose_type_lacks_a_call_signature); + errorInfo = ts.chainDiagnosticMessages(errorInfo, headMessage); + diagnostics.add(ts.createDiagnosticForNodeFromMessageChain(node, errorInfo)); + return resolveErrorCall(node); + } + return resolveCall(node, callSignatures, candidatesOutArray, headMessage); + } + // candidatesOutArray is passed by signature help in the language service, and collectCandidates + // must fill it up with the appropriate candidate signatures + function getResolvedSignature(node, candidatesOutArray) { + var links = getNodeLinks(node); + // If getResolvedSignature has already been called, we will have cached the resolvedSignature. + // However, it is possible that either candidatesOutArray was not passed in the first time, + // or that a different candidatesOutArray was passed in. Therefore, we need to redo the work + // to correctly fill the candidatesOutArray. + if (!links.resolvedSignature || candidatesOutArray) { + links.resolvedSignature = anySignature; + if (node.kind === 168 /* CallExpression */) { + links.resolvedSignature = resolveCallExpression(node, candidatesOutArray); + } + else if (node.kind === 169 /* NewExpression */) { + links.resolvedSignature = resolveNewExpression(node, candidatesOutArray); + } + else if (node.kind === 170 /* TaggedTemplateExpression */) { + links.resolvedSignature = resolveTaggedTemplateExpression(node, candidatesOutArray); + } + else if (node.kind === 139 /* Decorator */) { + links.resolvedSignature = resolveDecorator(node, candidatesOutArray); + } + else { + ts.Debug.fail("Branch in 'getResolvedSignature' should be unreachable."); + } + } + return links.resolvedSignature; + } + /** + * Syntactically and semantically checks a call or new expression. + * @param node The call/new expression to be checked. + * @returns On success, the expression's signature's return type. On failure, anyType. + */ + function checkCallExpression(node) { + // 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 */) { + return voidType; + } + if (node.kind === 169 /* NewExpression */) { + var declaration = signature.declaration; + if (declaration && + declaration.kind !== 144 /* Constructor */ && + declaration.kind !== 148 /* ConstructSignature */ && + declaration.kind !== 153 /* ConstructorType */) { + // When resolved signature is a call signature (and not a construct signature) the result type is any + if (compilerOptions.noImplicitAny) { + error(node, ts.Diagnostics.new_expression_whose_target_lacks_a_construct_signature_implicitly_has_an_any_type); + } + return anyType; + } + } + return getReturnTypeOfSignature(signature); + } + function checkTaggedTemplateExpression(node) { + return getReturnTypeOfSignature(getResolvedSignature(node)); + } + function checkAssertion(node) { + var exprType = getRegularTypeOfObjectLiteral(checkExpression(node.expression)); + var targetType = getTypeFromTypeNode(node.type); + if (produceDiagnostics && targetType !== unknownType) { + var widenedType = getWidenedType(exprType); + if (!(isTypeAssignableTo(targetType, widenedType))) { + checkTypeAssignableTo(exprType, targetType, node, ts.Diagnostics.Neither_type_0_nor_type_1_is_assignable_to_the_other); + } + } + return targetType; + } + function getTypeAtPosition(signature, pos) { + return signature.hasRestParameter ? + pos < signature.parameters.length - 1 ? getTypeOfSymbol(signature.parameters[pos]) : getRestTypeOfSignature(signature) : + pos < signature.parameters.length ? getTypeOfSymbol(signature.parameters[pos]) : anyType; + } + function assignContextualParameterTypes(signature, context, mapper) { + var len = signature.parameters.length - (signature.hasRestParameter ? 1 : 0); + for (var i = 0; i < len; i++) { + var parameter = signature.parameters[i]; + 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); + } + } + // When contextual typing assigns a type to a parameter that contains a binding pattern, we also need to push + // the destructured type into the contained binding elements. + function assignBindingElementTypes(node) { + if (ts.isBindingPattern(node.name)) { + for (var _i = 0, _a = node.name.elements; _i < _a.length; _i++) { + var element = _a[_i]; + if (element.kind !== 187 /* OmittedExpression */) { + if (element.name.kind === 69 /* Identifier */) { + getSymbolLinks(getSymbolOfNode(element)).type = getTypeForBindingElement(element); + } + assignBindingElementTypes(element); + } + } + } + } + function assignTypeToParameterAndFixTypeParameters(parameter, contextualType, mapper) { + var links = getSymbolLinks(parameter); + if (!links.type) { + links.type = instantiateType(contextualType, mapper); + assignBindingElementTypes(parameter.valueDeclaration); + } + else if (isInferentialContext(mapper)) { + // Even if the parameter already has a type, it might be because it was given a type while + // processing the function as an argument to a prior signature during overload resolution. + // If this was the case, it may have caused some type parameters to be fixed. So here, + // we need to ensure that type parameters at the same positions get fixed again. This is + // done by calling instantiateType to attach the mapper to the contextualType, and then + // calling inferTypes to force a walk of contextualType so that all the correct fixing + // happens. The choice to pass in links.type may seem kind of arbitrary, but it serves + // to make sure that all the correct positions in contextualType are reached by the walk. + // Here is an example: + // + // interface Base { + // baseProp; + // } + // interface Derived extends Base { + // toBase(): Base; + // } + // + // var derived: Derived; + // + // declare function foo(x: T, func: (p: T) => T): T; + // declare function foo(x: T, func: (p: T) => T): T; + // + // var result = foo(derived, d => d.toBase()); + // + // We are typing d while checking the second overload. But we've already given d + // a type (Derived) from the first overload. However, we still want to fix the + // T in the second overload so that we do not infer Base as a candidate for T + // (inferring Base would make type argument inference inconsistent between the two + // overloads). + inferTypes(mapper.context, links.type, instantiateType(contextualType, mapper)); + } + } + function createPromiseType(promisedType) { + // creates a `Promise` type where `T` is the promisedType argument + var globalPromiseType = getGlobalPromiseType(); + if (globalPromiseType !== emptyGenericType) { + // if the promised type is itself a promise, get the underlying type; otherwise, fallback to the promised type + promisedType = getAwaitedType(promisedType); + return createTypeReference(globalPromiseType, [promisedType]); + } + return emptyObjectType; + } + function getReturnTypeFromBody(func, contextualMapper) { + var contextualSignature = getContextualSignatureForFunctionLikeDeclaration(func); + if (!func.body) { + return unknownType; + } + var isAsync = ts.isAsyncFunctionLike(func); + var type; + if (func.body.kind !== 192 /* Block */) { + type = checkExpressionCached(func.body, contextualMapper); + if (isAsync) { + // From within an async function you can return either a non-promise value or a promise. Any + // Promise/A+ compatible implementation will always assimilate any foreign promise, so the + // return type of the body should be unwrapped to its awaited type, which we will wrap in + // the native Promise type later in this function. + type = checkAwaitedType(type, func, ts.Diagnostics.Return_expression_in_async_function_does_not_have_a_valid_callable_then_member); + } + } + else { + var types; + var funcIsGenerator = !!func.asteriskToken; + if (funcIsGenerator) { + types = checkAndAggregateYieldOperandTypes(func.body, contextualMapper); + if (types.length === 0) { + var iterableIteratorAny = createIterableIteratorType(anyType); + if (compilerOptions.noImplicitAny) { + error(func.asteriskToken, ts.Diagnostics.Generator_implicitly_has_type_0_because_it_does_not_yield_any_values_Consider_supplying_a_return_type, typeToString(iterableIteratorAny)); + } + return iterableIteratorAny; + } + } + else { + types = checkAndAggregateReturnExpressionTypes(func.body, contextualMapper, isAsync); + if (types.length === 0) { + if (isAsync) { + // For an async function, the return type will not be void, but rather a Promise for void. + var promiseType = createPromiseType(voidType); + if (promiseType === emptyObjectType) { + error(func, ts.Diagnostics.An_async_function_or_method_must_have_a_valid_awaitable_return_type); + return unknownType; + } + return promiseType; + } + else { + return voidType; + } + } + } + // When yield/return statements are contextually typed we allow the return type to be a union type. + // Otherwise we require the yield/return expressions to have a best common supertype. + type = contextualSignature ? getUnionType(types) : getCommonSupertype(types); + if (!type) { + if (funcIsGenerator) { + error(func, ts.Diagnostics.No_best_common_type_exists_among_yield_expressions); + return createIterableIteratorType(unknownType); + } + else { + error(func, ts.Diagnostics.No_best_common_type_exists_among_return_expressions); + return unknownType; + } + } + if (funcIsGenerator) { + type = createIterableIteratorType(type); + } + } + if (!contextualSignature) { + reportErrorsFromWidening(func, type); + } + var widenedType = getWidenedType(type); + if (isAsync) { + // From within an async function you can return either a non-promise value or a promise. Any + // Promise/A+ compatible implementation will always assimilate any foreign promise, so the + // return type of the body is awaited type of the body, wrapped in a native Promise type. + var promiseType = createPromiseType(widenedType); + if (promiseType === emptyObjectType) { + error(func, ts.Diagnostics.An_async_function_or_method_must_have_a_valid_awaitable_return_type); + return unknownType; + } + return promiseType; + } + else { + return widenedType; + } + } + function checkAndAggregateYieldOperandTypes(body, contextualMapper) { + var aggregatedTypes = []; + ts.forEachYieldExpression(body, function (yieldExpression) { + var expr = yieldExpression.expression; + if (expr) { + var type = checkExpressionCached(expr, contextualMapper); + if (yieldExpression.asteriskToken) { + // A yield* expression effectively yields everything that its operand yields + type = checkElementTypeOfIterable(type, yieldExpression.expression); + } + if (!ts.contains(aggregatedTypes, type)) { + aggregatedTypes.push(type); + } + } + }); + return aggregatedTypes; + } + function checkAndAggregateReturnExpressionTypes(body, contextualMapper, isAsync) { + var aggregatedTypes = []; + ts.forEachReturnStatement(body, function (returnStatement) { + var expr = returnStatement.expression; + if (expr) { + var type = checkExpressionCached(expr, contextualMapper); + if (isAsync) { + // From within an async function you can return either a non-promise value or a promise. Any + // Promise/A+ compatible implementation will always assimilate any foreign promise, so the + // return type of the body should be unwrapped to its awaited type, which should be wrapped in + // the native Promise type by the caller. + type = checkAwaitedType(type, body.parent, ts.Diagnostics.Return_expression_in_async_function_does_not_have_a_valid_callable_then_member); + } + if (!ts.contains(aggregatedTypes, type)) { + aggregatedTypes.push(type); + } + } + }); + return aggregatedTypes; + } + function bodyContainsAReturnStatement(funcBody) { + return ts.forEachReturnStatement(funcBody, function (returnStatement) { + return true; + }); + } + function bodyContainsSingleThrowStatement(body) { + return (body.statements.length === 1) && (body.statements[0].kind === 208 /* ThrowStatement */); + } + // TypeScript Specification 1.0 (6.3) - July 2014 + // An explicitly typed function whose return type isn't the Void or the Any type + // must have at least one return statement somewhere in its body. + // An exception to this rule is if the function implementation consists of a single 'throw' statement. + function checkIfNonVoidFunctionHasReturnExpressionsOrSingleThrowStatment(func, returnType) { + if (!produceDiagnostics) { + return; + } + // Functions that return 'void' or 'any' don't need any return expressions. + if (returnType === voidType || isTypeAny(returnType)) { + return; + } + // If all we have is a function signature, or an arrow function with an expression body, then there is nothing to check. + if (ts.nodeIsMissing(func.body) || func.body.kind !== 192 /* Block */) { + return; + } + var bodyBlock = func.body; + // Ensure the body has at least one return expression. + if (bodyContainsAReturnStatement(bodyBlock)) { + return; + } + // If there are no return expressions, then we need to check if + // the function body consists solely of a throw statement; + // this is to make an exception for unimplemented functions. + if (bodyContainsSingleThrowStatement(bodyBlock)) { + return; + } + // This function does not conform to the specification. + error(func.type, ts.Diagnostics.A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value_or_consist_of_a_single_throw_statement); + } + function checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper) { + ts.Debug.assert(node.kind !== 143 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + // Grammar checking + var hasGrammarError = checkGrammarFunctionLikeDeclaration(node); + if (!hasGrammarError && node.kind === 173 /* FunctionExpression */) { + checkGrammarForGenerator(node); + } + // The identityMapper object is used to indicate that function expressions are wildcards + if (contextualMapper === identityMapper && isContextSensitive(node)) { + return anyFunctionType; + } + var isAsync = ts.isAsyncFunctionLike(node); + if (isAsync) { + emitAwaiter = true; + } + var links = getNodeLinks(node); + var type = getTypeOfSymbol(node.symbol); + var contextSensitive = isContextSensitive(node); + var mightFixTypeParameters = contextSensitive && isInferentialContext(contextualMapper); + // Check if function expression is contextually typed and assign parameter types if so. + // See the comment in assignTypeToParameterAndFixTypeParameters to understand why we need to + // check mightFixTypeParameters. + if (mightFixTypeParameters || !(links.flags & 1024 /* ContextChecked */)) { + var contextualSignature = getContextualSignature(node); + // If a type check is started at a function expression that is an argument of a function call, obtaining the + // contextual type may recursively get back to here during overload resolution of the call. If so, we will have + // already assigned contextual types. + var contextChecked = !!(links.flags & 1024 /* ContextChecked */); + if (mightFixTypeParameters || !contextChecked) { + links.flags |= 1024 /* ContextChecked */; + if (contextualSignature) { + var signature = getSignaturesOfType(type, 0 /* Call */)[0]; + if (contextSensitive) { + assignContextualParameterTypes(signature, contextualSignature, contextualMapper || identityMapper); + } + if (mightFixTypeParameters || !node.type && !signature.resolvedReturnType) { + var returnType = getReturnTypeFromBody(node, contextualMapper); + if (!signature.resolvedReturnType) { + signature.resolvedReturnType = returnType; + } + } + } + if (!contextChecked) { + checkSignatureDeclaration(node); + } + } + } + if (produceDiagnostics && node.kind !== 143 /* MethodDeclaration */ && node.kind !== 142 /* MethodSignature */) { + checkCollisionWithCapturedSuperVariable(node, node.name); + checkCollisionWithCapturedThisVariable(node, node.name); + } + return type; + } + function checkFunctionExpressionOrObjectLiteralMethodBody(node) { + ts.Debug.assert(node.kind !== 143 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + var isAsync = ts.isAsyncFunctionLike(node); + if (isAsync) { + emitAwaiter = true; + } + var returnType = node.type && getTypeFromTypeNode(node.type); + var promisedType; + if (returnType && isAsync) { + promisedType = checkAsyncFunctionReturnType(node); + } + if (returnType && !node.asteriskToken) { + checkIfNonVoidFunctionHasReturnExpressionsOrSingleThrowStatment(node, isAsync ? promisedType : returnType); + } + if (node.body) { + if (!node.type) { + // There are some checks that are only performed in getReturnTypeFromBody, that may produce errors + // we need. An example is the noImplicitAny errors resulting from widening the return expression + // of a function. Because checking of function expression bodies is deferred, there was never an + // appropriate time to do this during the main walk of the file (see the comment at the top of + // checkFunctionExpressionBodies). So it must be done now. + getReturnTypeOfSignature(getSignatureFromDeclaration(node)); + } + if (node.body.kind === 192 /* Block */) { + checkSourceElement(node.body); + } + else { + // From within an async function you can return either a non-promise value or a promise. Any + // Promise/A+ compatible implementation will always assimilate any foreign promise, so we + // should not be checking assignability of a promise to the return type. Instead, we need to + // check assignability of the awaited type of the expression body against the promised type of + // its return type annotation. + var exprType = checkExpression(node.body); + if (returnType) { + if (isAsync) { + var awaitedType = checkAwaitedType(exprType, node.body, ts.Diagnostics.Expression_body_for_async_arrow_function_does_not_have_a_valid_callable_then_member); + checkTypeAssignableTo(awaitedType, promisedType, node.body); + } + else { + checkTypeAssignableTo(exprType, returnType, node.body); + } + } + checkFunctionAndClassExpressionBodies(node.body); + } + } + } + function checkArithmeticOperandType(operand, type, diagnostic) { + if (!isTypeAnyOrAllConstituentTypesHaveKind(type, 132 /* NumberLike */)) { + error(operand, diagnostic); + return false; + } + return true; + } + function checkReferenceExpression(n, invalidReferenceMessage, constantVariableMessage) { + function findSymbol(n) { + var symbol = getNodeLinks(n).resolvedSymbol; + // Because we got the symbol from the resolvedSymbol property, it might be of kind + // SymbolFlags.ExportValue. In this case it is necessary to get the actual export + // symbol, which will have the correct flags set on it. + return symbol && getExportSymbolOfValueSymbolIfExported(symbol); + } + function isReferenceOrErrorExpression(n) { + // TypeScript 1.0 spec (April 2014): + // Expressions are classified as values or references. + // References are the subset of expressions that are permitted as the target of an assignment. + // Specifically, references are combinations of identifiers(section 4.3), parentheses(section 4.7), + // and property accesses(section 4.10). + // All other expression constructs described in this chapter are classified as values. + switch (n.kind) { + case 69 /* Identifier */: { + var symbol = findSymbol(n); + // TypeScript 1.0 spec (April 2014): 4.3 + // An identifier expression that references a variable or parameter is classified as a reference. + // An identifier expression that references any other kind of entity is classified as a value(and therefore cannot be the target of an assignment). + return !symbol || symbol === unknownSymbol || symbol === argumentsSymbol || (symbol.flags & 3 /* Variable */) !== 0; + } + case 166 /* PropertyAccessExpression */: { + var symbol = findSymbol(n); + // TypeScript 1.0 spec (April 2014): 4.10 + // A property access expression is always classified as a reference. + // NOTE (not in spec): assignment to enum members should not be allowed + return !symbol || symbol === unknownSymbol || (symbol.flags & ~8 /* EnumMember */) !== 0; + } + case 167 /* ElementAccessExpression */: + // old compiler doesn't check indexed access + return true; + case 172 /* ParenthesizedExpression */: + return isReferenceOrErrorExpression(n.expression); + default: + return false; + } + } + function isConstVariableReference(n) { + switch (n.kind) { + case 69 /* Identifier */: + case 166 /* PropertyAccessExpression */: { + var symbol = findSymbol(n); + return symbol && (symbol.flags & 3 /* Variable */) !== 0 && (getDeclarationFlagsFromSymbol(symbol) & 32768 /* Const */) !== 0; + } + case 167 /* ElementAccessExpression */: { + var index = n.argumentExpression; + var symbol = findSymbol(n.expression); + if (symbol && index && index.kind === 9 /* StringLiteral */) { + var name_12 = index.text; + var prop = getPropertyOfType(getTypeOfSymbol(symbol), name_12); + return prop && (prop.flags & 3 /* Variable */) !== 0 && (getDeclarationFlagsFromSymbol(prop) & 32768 /* Const */) !== 0; + } + return false; + } + case 172 /* ParenthesizedExpression */: + return isConstVariableReference(n.expression); + default: + return false; + } + } + if (!isReferenceOrErrorExpression(n)) { + error(n, invalidReferenceMessage); + return false; + } + if (isConstVariableReference(n)) { + error(n, constantVariableMessage); + return false; + } + return true; + } + function checkDeleteExpression(node) { + checkExpression(node.expression); + return booleanType; + } + function checkTypeOfExpression(node) { + checkExpression(node.expression); + return stringType; + } + function checkVoidExpression(node) { + checkExpression(node.expression); + return undefinedType; + } + function checkAwaitExpression(node) { + // Grammar checking + if (produceDiagnostics) { + if (!(node.parserContextFlags & 8 /* Await */)) { + grammarErrorOnFirstToken(node, ts.Diagnostics.await_expression_is_only_allowed_within_an_async_function); + } + if (isInParameterInitializerBeforeContainingFunction(node)) { + error(node, ts.Diagnostics.await_expressions_cannot_be_used_in_a_parameter_initializer); + } + } + var operandType = checkExpression(node.expression); + return checkAwaitedType(operandType, node); + } + function checkPrefixUnaryExpression(node) { + var operandType = checkExpression(node.operand); + switch (node.operator) { + case 35 /* PlusToken */: + case 36 /* MinusToken */: + case 50 /* TildeToken */: + if (someConstituentTypeHasKind(operandType, 16777216 /* ESSymbol */)) { + error(node.operand, ts.Diagnostics.The_0_operator_cannot_be_applied_to_type_symbol, ts.tokenToString(node.operator)); + } + return numberType; + case 49 /* ExclamationToken */: + return booleanType; + case 41 /* PlusPlusToken */: + case 42 /* MinusMinusToken */: + var ok = checkArithmeticOperandType(node.operand, operandType, ts.Diagnostics.An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type); + if (ok) { + // run check only if former checks succeeded to avoid reporting cascading errors + 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); + } + return numberType; + } + return unknownType; + } + function checkPostfixUnaryExpression(node) { + var operandType = checkExpression(node.operand); + var ok = checkArithmeticOperandType(node.operand, operandType, ts.Diagnostics.An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type); + if (ok) { + // run check only if former checks succeeded to avoid reporting cascading errors + 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); + } + return numberType; + } + // Just like isTypeOfKind below, except that it returns true if *any* constituent + // has this kind. + function someConstituentTypeHasKind(type, kind) { + if (type.flags & kind) { + return true; + } + if (type.flags & 49152 /* UnionOrIntersection */) { + var types = type.types; + for (var _i = 0; _i < types.length; _i++) { + var current = types[_i]; + if (current.flags & kind) { + return true; + } + } + return false; + } + return false; + } + // Return true if type has the given flags, or is a union or intersection type composed of types that all have those flags. + function allConstituentTypesHaveKind(type, kind) { + if (type.flags & kind) { + return true; + } + if (type.flags & 49152 /* UnionOrIntersection */) { + var types = type.types; + for (var _i = 0; _i < types.length; _i++) { + var current = types[_i]; + if (!(current.flags & kind)) { + return false; + } + } + return true; + } + return false; + } + function isConstEnumObjectType(type) { + return type.flags & (80896 /* ObjectType */ | 65536 /* Anonymous */) && type.symbol && isConstEnumSymbol(type.symbol); + } + function isConstEnumSymbol(symbol) { + return (symbol.flags & 128 /* ConstEnum */) !== 0; + } + function checkInstanceOfExpression(left, right, leftType, rightType) { + // TypeScript 1.0 spec (April 2014): 4.15.4 + // The instanceof operator requires the left operand to be of type Any, an object type, or a type parameter type, + // and the right operand to be of type Any or a subtype of the 'Function' interface type. + // The result is always of the Boolean primitive type. + // NOTE: do not raise error if leftType is unknown as related error was already reported + if (allConstituentTypesHaveKind(leftType, 16777726 /* Primitive */)) { + error(left, ts.Diagnostics.The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_parameter); + } + // NOTE: do not raise error if right is unknown as related error was already reported + if (!(isTypeAny(rightType) || isTypeSubtypeOf(rightType, globalFunctionType))) { + error(right, ts.Diagnostics.The_right_hand_side_of_an_instanceof_expression_must_be_of_type_any_or_of_a_type_assignable_to_the_Function_interface_type); + } + return booleanType; + } + function checkInExpression(left, right, leftType, rightType) { + // TypeScript 1.0 spec (April 2014): 4.15.5 + // The in operator requires the left operand to be of type Any, the String primitive type, or the Number primitive type, + // and the right operand to be of type Any, an object type, or a type parameter type. + // The result is always of the Boolean primitive type. + if (!isTypeAnyOrAllConstituentTypesHaveKind(leftType, 258 /* StringLike */ | 132 /* NumberLike */ | 16777216 /* ESSymbol */)) { + error(left, ts.Diagnostics.The_left_hand_side_of_an_in_expression_must_be_of_type_any_string_number_or_symbol); + } + if (!isTypeAnyOrAllConstituentTypesHaveKind(rightType, 80896 /* ObjectType */ | 512 /* TypeParameter */)) { + error(right, ts.Diagnostics.The_right_hand_side_of_an_in_expression_must_be_of_type_any_an_object_type_or_a_type_parameter); + } + return booleanType; + } + function checkObjectLiteralAssignment(node, sourceType, contextualMapper) { + var properties = node.properties; + for (var _i = 0; _i < properties.length; _i++) { + var p = properties[_i]; + if (p.kind === 245 /* PropertyAssignment */ || p.kind === 246 /* ShorthandPropertyAssignment */) { + // TODO(andersh): Computed property support + var name_13 = p.name; + var type = isTypeAny(sourceType) + ? sourceType + : getTypeOfPropertyOfType(sourceType, name_13.text) || + isNumericLiteralName(name_13.text) && getIndexTypeOfType(sourceType, 1 /* Number */) || + getIndexTypeOfType(sourceType, 0 /* String */); + if (type) { + if (p.kind === 246 /* ShorthandPropertyAssignment */) { + checkDestructuringAssignment(p, type); + } + else { + checkDestructuringAssignment(p.initializer || name_13, type); + } + } + else { + error(name_13, ts.Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(sourceType), ts.declarationNameToString(name_13)); + } + } + else { + error(p, ts.Diagnostics.Property_assignment_expected); + } + } + return sourceType; + } + function checkArrayLiteralAssignment(node, sourceType, contextualMapper) { + // This elementType will be used if the specific property corresponding to this index is not + // present (aka the tuple element property). This call also checks that the parentType is in + // fact an iterable or array (depending on target language). + var elementType = checkIteratedTypeOrElementType(sourceType, node, /*allowStringInput*/ false) || unknownType; + var elements = node.elements; + for (var i = 0; i < elements.length; i++) { + var e = elements[i]; + if (e.kind !== 187 /* OmittedExpression */) { + if (e.kind !== 185 /* SpreadElementExpression */) { + var propName = "" + i; + var type = isTypeAny(sourceType) + ? sourceType + : isTupleLikeType(sourceType) + ? getTypeOfPropertyOfType(sourceType, propName) + : elementType; + if (type) { + checkDestructuringAssignment(e, type, contextualMapper); + } + else { + if (isTupleType(sourceType)) { + error(e, ts.Diagnostics.Tuple_type_0_with_length_1_cannot_be_assigned_to_tuple_with_length_2, typeToString(sourceType), sourceType.elementTypes.length, elements.length); + } + else { + error(e, ts.Diagnostics.Type_0_has_no_property_1, typeToString(sourceType), propName); + } + } + } + else { + if (i < elements.length - 1) { + error(e, ts.Diagnostics.A_rest_element_must_be_last_in_an_array_destructuring_pattern); + } + else { + var restExpression = e.expression; + if (restExpression.kind === 181 /* BinaryExpression */ && restExpression.operatorToken.kind === 56 /* EqualsToken */) { + error(restExpression.operatorToken, ts.Diagnostics.A_rest_element_cannot_have_an_initializer); + } + else { + checkDestructuringAssignment(restExpression, createArrayType(elementType), contextualMapper); + } + } + } + } + } + return sourceType; + } + function checkDestructuringAssignment(exprOrAssignment, sourceType, contextualMapper) { + var target; + if (exprOrAssignment.kind === 246 /* ShorthandPropertyAssignment */) { + var prop = exprOrAssignment; + if (prop.objectAssignmentInitializer) { + checkBinaryLikeExpression(prop.name, prop.equalsToken, prop.objectAssignmentInitializer, contextualMapper); + } + target = exprOrAssignment.name; + } + else { + target = exprOrAssignment; + } + if (target.kind === 181 /* BinaryExpression */ && target.operatorToken.kind === 56 /* EqualsToken */) { + checkBinaryExpression(target, contextualMapper); + target = target.left; + } + if (target.kind === 165 /* ObjectLiteralExpression */) { + return checkObjectLiteralAssignment(target, sourceType, contextualMapper); + } + if (target.kind === 164 /* ArrayLiteralExpression */) { + return checkArrayLiteralAssignment(target, sourceType, contextualMapper); + } + return checkReferenceAssignment(target, sourceType, contextualMapper); + } + function checkReferenceAssignment(target, sourceType, contextualMapper) { + var targetType = checkExpression(target, contextualMapper); + if (checkReferenceExpression(target, ts.Diagnostics.Invalid_left_hand_side_of_assignment_expression, ts.Diagnostics.Left_hand_side_of_assignment_expression_cannot_be_a_constant)) { + checkTypeAssignableTo(sourceType, targetType, target, /*headMessage*/ undefined); + } + return sourceType; + } + function checkBinaryExpression(node, contextualMapper) { + return checkBinaryLikeExpression(node.left, node.operatorToken, node.right, contextualMapper, node); + } + function checkBinaryLikeExpression(left, operatorToken, right, contextualMapper, errorNode) { + var operator = operatorToken.kind; + if (operator === 56 /* EqualsToken */ && (left.kind === 165 /* ObjectLiteralExpression */ || left.kind === 164 /* ArrayLiteralExpression */)) { + return checkDestructuringAssignment(left, checkExpression(right, contextualMapper), contextualMapper); + } + var leftType = checkExpression(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 */: + // TypeScript 1.0 spec (April 2014): 4.19.1 + // These operators require their operands to be of type Any, the Number primitive type, + // or an enum type. Operands of an enum type are treated + // as having the primitive type Number. If one operand is the null or undefined value, + // it is treated as having the type of the other operand. + // The result is always of the Number primitive type. + if (leftType.flags & (32 /* Undefined */ | 64 /* Null */)) + leftType = rightType; + if (rightType.flags & (32 /* Undefined */ | 64 /* Null */)) + rightType = leftType; + var suggestedOperator; + // if a user tries to apply a bitwise operator to 2 boolean operands + // try and return them a helpful suggestion + if ((leftType.flags & 8 /* Boolean */) && + (rightType.flags & 8 /* Boolean */) && + (suggestedOperator = getSuggestedBooleanOperator(operatorToken.kind)) !== undefined) { + error(errorNode || operatorToken, ts.Diagnostics.The_0_operator_is_not_allowed_for_boolean_types_Consider_using_1_instead, ts.tokenToString(operatorToken.kind), ts.tokenToString(suggestedOperator)); + } + else { + // otherwise just check each operand separately and report errors as normal + var leftOk = checkArithmeticOperandType(left, leftType, ts.Diagnostics.The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type); + var rightOk = checkArithmeticOperandType(right, rightType, ts.Diagnostics.The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type); + if (leftOk && rightOk) { + checkAssignmentOperator(numberType); + } + } + return numberType; + case 35 /* PlusToken */: + case 57 /* PlusEqualsToken */: + // TypeScript 1.0 spec (April 2014): 4.19.2 + // The binary + operator requires both operands to be of the Number primitive type or an enum type, + // or at least one of the operands to be of type Any or the String primitive type. + // If one operand is the null or undefined value, it is treated as having the type of the other operand. + if (leftType.flags & (32 /* Undefined */ | 64 /* Null */)) + leftType = rightType; + if (rightType.flags & (32 /* Undefined */ | 64 /* Null */)) + rightType = leftType; + var resultType; + if (allConstituentTypesHaveKind(leftType, 132 /* NumberLike */) && allConstituentTypesHaveKind(rightType, 132 /* NumberLike */)) { + // Operands of an enum type are treated as having the primitive type Number. + // If both operands are of the Number primitive type, the result is of the Number primitive type. + resultType = numberType; + } + else { + if (allConstituentTypesHaveKind(leftType, 258 /* StringLike */) || allConstituentTypesHaveKind(rightType, 258 /* StringLike */)) { + // If one or both operands are of the String primitive type, the result is of the String primitive type. + resultType = stringType; + } + else if (isTypeAny(leftType) || isTypeAny(rightType)) { + // Otherwise, the result is of type Any. + // NOTE: unknown type here denotes error type. Old compiler treated this case as any type so do we. + resultType = leftType === unknownType || rightType === unknownType ? unknownType : anyType; + } + // Symbols are not allowed at all in arithmetic expressions + if (resultType && !checkForDisallowedESSymbolOperand(operator)) { + return resultType; + } + } + if (!resultType) { + reportOperatorError(); + return anyType; + } + if (operator === 57 /* PlusEqualsToken */) { + checkAssignmentOperator(resultType); + } + return resultType; + case 25 /* LessThanToken */: + case 27 /* GreaterThanToken */: + case 28 /* LessThanEqualsToken */: + case 29 /* GreaterThanEqualsToken */: + if (!checkForDisallowedESSymbolOperand(operator)) { + return booleanType; + } + // Fall through + case 30 /* EqualsEqualsToken */: + case 31 /* ExclamationEqualsToken */: + case 32 /* EqualsEqualsEqualsToken */: + case 33 /* ExclamationEqualsEqualsToken */: + if (!isTypeAssignableTo(leftType, rightType) && !isTypeAssignableTo(rightType, leftType)) { + reportOperatorError(); + } + return booleanType; + case 91 /* InstanceOfKeyword */: + return checkInstanceOfExpression(left, right, leftType, rightType); + case 90 /* InKeyword */: + return checkInExpression(left, right, leftType, rightType); + case 51 /* AmpersandAmpersandToken */: + return rightType; + case 52 /* BarBarToken */: + return getUnionType([leftType, rightType]); + case 56 /* EqualsToken */: + checkAssignmentOperator(rightType); + return getRegularTypeOfObjectLiteral(rightType); + case 24 /* CommaToken */: + return rightType; + } + // Return true if there was no error, false if there was an error. + function checkForDisallowedESSymbolOperand(operator) { + var offendingSymbolOperand = someConstituentTypeHasKind(leftType, 16777216 /* ESSymbol */) ? left : + someConstituentTypeHasKind(rightType, 16777216 /* ESSymbol */) ? right : + undefined; + if (offendingSymbolOperand) { + error(offendingSymbolOperand, ts.Diagnostics.The_0_operator_cannot_be_applied_to_type_symbol, ts.tokenToString(operator)); + return false; + } + return true; + } + 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 */; + default: + return undefined; + } + } + function checkAssignmentOperator(valueType) { + if (produceDiagnostics && operator >= 56 /* FirstAssignment */ && operator <= 68 /* LastAssignment */) { + // TypeScript 1.0 spec (April 2014): 4.17 + // An assignment of the form + // VarExpr = ValueExpr + // requires VarExpr to be classified as a reference + // A compound assignment furthermore requires VarExpr to be classified as a reference (section 4.1) + // and the type of the non - compound operation to be assignable to the type of VarExpr. + var ok = checkReferenceExpression(left, ts.Diagnostics.Invalid_left_hand_side_of_assignment_expression, ts.Diagnostics.Left_hand_side_of_assignment_expression_cannot_be_a_constant); + // Use default messages + if (ok) { + // to avoid cascading errors check assignability only if 'isReference' check succeeded and no errors were reported + checkTypeAssignableTo(valueType, leftType, left, /*headMessage*/ undefined); + } + } + } + function reportOperatorError() { + error(errorNode || operatorToken, ts.Diagnostics.Operator_0_cannot_be_applied_to_types_1_and_2, ts.tokenToString(operatorToken.kind), typeToString(leftType), typeToString(rightType)); + } + } + function isYieldExpressionInClass(node) { + var current = node; + var parent = node.parent; + while (parent) { + if (ts.isFunctionLike(parent) && current === parent.body) { + return false; + } + else if (ts.isClassLike(current)) { + return true; + } + current = parent; + parent = parent.parent; + } + return false; + } + function checkYieldExpression(node) { + // Grammar checking + if (produceDiagnostics) { + if (!(node.parserContextFlags & 2 /* Yield */) || isYieldExpressionInClass(node)) { + grammarErrorOnFirstToken(node, ts.Diagnostics.A_yield_expression_is_only_allowed_in_a_generator_body); + } + if (isInParameterInitializerBeforeContainingFunction(node)) { + error(node, ts.Diagnostics.yield_expressions_cannot_be_used_in_a_parameter_initializer); + } + } + if (node.expression) { + var func = ts.getContainingFunction(node); + // If the user's code is syntactically correct, the func should always have a star. After all, + // we are in a yield context. + if (func && func.asteriskToken) { + var expressionType = checkExpressionCached(node.expression, /*contextualMapper*/ undefined); + var expressionElementType; + var nodeIsYieldStar = !!node.asteriskToken; + if (nodeIsYieldStar) { + expressionElementType = checkElementTypeOfIterable(expressionType, node.expression); + } + // There is no point in doing an assignability check if the function + // has no explicit return type because the return type is directly computed + // from the yield expressions. + if (func.type) { + var signatureElementType = getElementTypeOfIterableIterator(getTypeFromTypeNode(func.type)) || anyType; + if (nodeIsYieldStar) { + checkTypeAssignableTo(expressionElementType, signatureElementType, node.expression, /*headMessage*/ undefined); + } + else { + checkTypeAssignableTo(expressionType, signatureElementType, node.expression, /*headMessage*/ undefined); + } + } + } + } + // Both yield and yield* expressions have type 'any' + return anyType; + } + function checkConditionalExpression(node, contextualMapper) { + checkExpression(node.condition); + var type1 = checkExpression(node.whenTrue, contextualMapper); + var type2 = checkExpression(node.whenFalse, contextualMapper); + return getUnionType([type1, type2]); + } + function checkTemplateExpression(node) { + // We just want to check each expressions, but we are unconcerned with + // the type of each expression, as any value may be coerced into a string. + // It is worth asking whether this is what we really want though. + // A place where we actually *are* concerned with the expressions' types are + // in tagged templates. + ts.forEach(node.templateSpans, function (templateSpan) { + checkExpression(templateSpan.expression); + }); + return stringType; + } + function checkExpressionWithContextualType(node, contextualType, contextualMapper) { + var saveContextualType = node.contextualType; + node.contextualType = contextualType; + var result = checkExpression(node, contextualMapper); + node.contextualType = saveContextualType; + return result; + } + function checkExpressionCached(node, contextualMapper) { + var links = getNodeLinks(node); + if (!links.resolvedType) { + links.resolvedType = checkExpression(node, contextualMapper); + } + return links.resolvedType; + } + function checkPropertyAssignment(node, contextualMapper) { + // 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 === 136 /* ComputedPropertyName */) { + checkComputedPropertyName(node.name); + } + return checkExpression(node.initializer, contextualMapper); + } + function checkObjectLiteralMethod(node, contextualMapper) { + // Grammar checking + checkGrammarMethod(node); + // 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 === 136 /* ComputedPropertyName */) { + checkComputedPropertyName(node.name); + } + var uninstantiatedType = checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); + return instantiateTypeWithSingleGenericCallSignature(node, uninstantiatedType, contextualMapper); + } + function instantiateTypeWithSingleGenericCallSignature(node, type, contextualMapper) { + if (isInferentialContext(contextualMapper)) { + var signature = getSingleCallSignature(type); + if (signature && signature.typeParameters) { + var contextualType = getContextualType(node); + if (contextualType) { + var contextualSignature = getSingleCallSignature(contextualType); + if (contextualSignature && !contextualSignature.typeParameters) { + return getOrCreateTypeFromSignature(instantiateSignatureInContextOf(signature, contextualSignature, contextualMapper)); + } + } + } + } + return type; + } + // Checks an expression and returns its type. The contextualMapper parameter serves two purposes: When + // contextualMapper is not undefined and not equal to the identityMapper function object it indicates that the + // expression is being inferentially typed (section 4.12.2 in spec) and provides the type mapper to use in + // conjunction with the generic contextual type. When contextualMapper is equal to the identityMapper function + // object, it serves as an indicator that all contained function and arrow expressions should be considered to + // have the wildcard function type; this form of type check is used during overload resolution to exclude + // contextually typed function and arrow expressions in the initial phase. + function checkExpression(node, contextualMapper) { + var type; + if (node.kind === 135 /* QualifiedName */) { + type = checkQualifiedName(node); + } + else { + var uninstantiatedType = checkExpressionWorker(node, contextualMapper); + type = instantiateTypeWithSingleGenericCallSignature(node, uninstantiatedType, contextualMapper); + } + if (isConstEnumObjectType(type)) { + // enum object type for const enums are only permitted in: + // - 'left' in property access + // - 'object' in indexed access + // - target in rhs of import statement + var ok = (node.parent.kind === 166 /* PropertyAccessExpression */ && node.parent.expression === node) || + (node.parent.kind === 167 /* ElementAccessExpression */ && node.parent.expression === node) || + ((node.kind === 69 /* Identifier */ || node.kind === 135 /* QualifiedName */) && isInRightSideOfImportOrExportAssignment(node)); + if (!ok) { + error(node, ts.Diagnostics.const_enums_can_only_be_used_in_property_or_index_access_expressions_or_the_right_hand_side_of_an_import_declaration_or_export_assignment); + } + } + return type; + } + function checkNumericLiteral(node) { + // Grammar checking + checkGrammarNumericLiteral(node); + return numberType; + } + function checkExpressionWorker(node, contextualMapper) { + switch (node.kind) { + case 69 /* Identifier */: + return checkIdentifier(node); + case 97 /* ThisKeyword */: + return checkThisExpression(node); + case 95 /* SuperKeyword */: + return checkSuperExpression(node); + case 93 /* NullKeyword */: + return nullType; + case 99 /* TrueKeyword */: + case 84 /* FalseKeyword */: + return booleanType; + case 8 /* NumericLiteral */: + return checkNumericLiteral(node); + case 183 /* TemplateExpression */: + return checkTemplateExpression(node); + case 9 /* StringLiteral */: + case 11 /* NoSubstitutionTemplateLiteral */: + return stringType; + case 10 /* RegularExpressionLiteral */: + return globalRegExpType; + case 164 /* ArrayLiteralExpression */: + return checkArrayLiteral(node, contextualMapper); + case 165 /* ObjectLiteralExpression */: + return checkObjectLiteral(node, contextualMapper); + case 166 /* PropertyAccessExpression */: + return checkPropertyAccessExpression(node); + case 167 /* ElementAccessExpression */: + return checkIndexedAccess(node); + case 168 /* CallExpression */: + case 169 /* NewExpression */: + return checkCallExpression(node); + case 170 /* TaggedTemplateExpression */: + return checkTaggedTemplateExpression(node); + case 172 /* ParenthesizedExpression */: + return checkExpression(node.expression, contextualMapper); + case 186 /* ClassExpression */: + return checkClassExpression(node); + case 173 /* FunctionExpression */: + case 174 /* ArrowFunction */: + return checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); + case 176 /* TypeOfExpression */: + return checkTypeOfExpression(node); + case 171 /* TypeAssertionExpression */: + case 189 /* AsExpression */: + return checkAssertion(node); + case 175 /* DeleteExpression */: + return checkDeleteExpression(node); + case 177 /* VoidExpression */: + return checkVoidExpression(node); + case 178 /* AwaitExpression */: + return checkAwaitExpression(node); + case 179 /* PrefixUnaryExpression */: + return checkPrefixUnaryExpression(node); + case 180 /* PostfixUnaryExpression */: + return checkPostfixUnaryExpression(node); + case 181 /* BinaryExpression */: + return checkBinaryExpression(node, contextualMapper); + case 182 /* ConditionalExpression */: + return checkConditionalExpression(node, contextualMapper); + case 185 /* SpreadElementExpression */: + return checkSpreadElementExpression(node, contextualMapper); + case 187 /* OmittedExpression */: + return undefinedType; + case 184 /* YieldExpression */: + return checkYieldExpression(node); + case 240 /* JsxExpression */: + return checkJsxExpression(node); + case 233 /* JsxElement */: + return checkJsxElement(node); + case 234 /* JsxSelfClosingElement */: + return checkJsxSelfClosingElement(node); + case 235 /* JsxOpeningElement */: + ts.Debug.fail("Shouldn't ever directly check a JsxOpeningElement"); + } + return unknownType; + } + // DECLARATION AND STATEMENT TYPE CHECKING + function checkTypeParameter(node) { + // Grammar Checking + if (node.expression) { + grammarErrorOnFirstToken(node.expression, ts.Diagnostics.Type_expected); + } + checkSourceElement(node.constraint); + if (produceDiagnostics) { + checkTypeParameterHasIllegalReferencesInConstraint(node); + checkTypeNameIsReserved(node.name, ts.Diagnostics.Type_parameter_name_cannot_be_0); + } + // TODO: Check multiple declarations are identical + } + function checkParameter(node) { + // Grammar checking + // It is a SyntaxError if the Identifier "eval" or the Identifier "arguments" occurs as the + // Identifier in a PropertySetParameterList of a PropertyAssignment that is contained in strict code + // or if its FunctionBody is strict code(11.1.5). + // Grammar checking + checkGrammarDecorators(node) || checkGrammarModifiers(node); + checkVariableLikeDeclaration(node); + var func = ts.getContainingFunction(node); + if (node.flags & 112 /* AccessibilityModifier */) { + func = ts.getContainingFunction(node); + if (!(func.kind === 144 /* Constructor */ && ts.nodeIsPresent(func.body))) { + error(node, ts.Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation); + } + } + if (node.questionToken && ts.isBindingPattern(node.name) && func.body) { + error(node, ts.Diagnostics.A_binding_pattern_parameter_cannot_be_optional_in_an_implementation_signature); + } + // Only check rest parameter type if it's not a binding pattern. Since binding patterns are + // not allowed in a rest parameter, we already have an error from checkGrammarParameterList. + if (node.dotDotDotToken && !ts.isBindingPattern(node.name) && !isArrayType(getTypeOfSymbol(node.symbol))) { + error(node, ts.Diagnostics.A_rest_parameter_must_be_of_an_array_type); + } + } + function isSyntacticallyValidGenerator(node) { + if (!node.asteriskToken || !node.body) { + return false; + } + return node.kind === 143 /* MethodDeclaration */ || + node.kind === 213 /* FunctionDeclaration */ || + node.kind === 173 /* FunctionExpression */; + } + function getTypePredicateParameterIndex(parameterList, parameter) { + if (parameterList) { + for (var i = 0; i < parameterList.length; i++) { + var param = parameterList[i]; + if (param.name.kind === 69 /* Identifier */ && + param.name.text === parameter.text) { + return i; + } + } + } + return -1; + } + function isInLegalTypePredicatePosition(node) { + switch (node.parent.kind) { + case 174 /* ArrowFunction */: + case 147 /* CallSignature */: + case 213 /* FunctionDeclaration */: + case 173 /* FunctionExpression */: + case 152 /* FunctionType */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: + return node === node.parent.type; + } + return false; + } + function checkSignatureDeclaration(node) { + // Grammar checking + if (node.kind === 149 /* IndexSignature */) { + checkGrammarIndexSignature(node); + } + else if (node.kind === 152 /* FunctionType */ || node.kind === 213 /* FunctionDeclaration */ || node.kind === 153 /* ConstructorType */ || + node.kind === 147 /* CallSignature */ || node.kind === 144 /* Constructor */ || + node.kind === 148 /* ConstructSignature */) { + checkGrammarFunctionLikeDeclaration(node); + } + checkTypeParameters(node.typeParameters); + ts.forEach(node.parameters, checkParameter); + if (node.type) { + if (node.type.kind === 150 /* TypePredicate */) { + var typePredicate = getSignatureFromDeclaration(node).typePredicate; + var typePredicateNode = node.type; + if (isInLegalTypePredicatePosition(typePredicateNode)) { + if (typePredicate.parameterIndex >= 0) { + if (node.parameters[typePredicate.parameterIndex].dotDotDotToken) { + error(typePredicateNode.parameterName, ts.Diagnostics.A_type_predicate_cannot_reference_a_rest_parameter); + } + else { + checkTypeAssignableTo(typePredicate.type, getTypeOfNode(node.parameters[typePredicate.parameterIndex]), typePredicateNode.type); + } + } + else if (typePredicateNode.parameterName) { + var hasReportedError = false; + for (var _i = 0, _a = node.parameters; _i < _a.length; _i++) { + var param = _a[_i]; + if (hasReportedError) { + break; + } + if (param.name.kind === 161 /* ObjectBindingPattern */ || + param.name.kind === 162 /* ArrayBindingPattern */) { + (function checkBindingPattern(pattern) { + for (var _i = 0, _a = pattern.elements; _i < _a.length; _i++) { + var element = _a[_i]; + if (element.name.kind === 69 /* Identifier */ && + element.name.text === typePredicate.parameterName) { + error(typePredicateNode.parameterName, ts.Diagnostics.A_type_predicate_cannot_reference_element_0_in_a_binding_pattern, typePredicate.parameterName); + hasReportedError = true; + break; + } + else if (element.name.kind === 162 /* ArrayBindingPattern */ || + element.name.kind === 161 /* ObjectBindingPattern */) { + checkBindingPattern(element.name); + } + } + })(param.name); + } + } + if (!hasReportedError) { + error(typePredicateNode.parameterName, ts.Diagnostics.Cannot_find_parameter_0, typePredicate.parameterName); + } + } + } + else { + error(typePredicateNode, ts.Diagnostics.A_type_predicate_is_only_allowed_in_return_type_position_for_functions_and_methods); + } + } + else { + checkSourceElement(node.type); + } + } + if (produceDiagnostics) { + checkCollisionWithArgumentsInGeneratedCode(node); + if (compilerOptions.noImplicitAny && !node.type) { + switch (node.kind) { + case 148 /* ConstructSignature */: + error(node, ts.Diagnostics.Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); + break; + case 147 /* 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)) { + var returnType = getTypeFromTypeNode(node.type); + if (returnType === voidType) { + error(node.type, ts.Diagnostics.A_generator_cannot_have_a_void_type_annotation); + } + else { + var generatorElementType = getElementTypeOfIterableIterator(returnType) || anyType; + var iterableIteratorInstantiation = createIterableIteratorType(generatorElementType); + // Naively, one could check that IterableIterator is assignable to the return type annotation. + // However, that would not catch the error in the following case. + // + // interface BadGenerator extends Iterable, Iterator { } + // function* g(): BadGenerator { } // Iterable and Iterator have different types! + // + checkTypeAssignableTo(iterableIteratorInstantiation, returnType, node.type); + } + } + } + } + checkSpecializedSignatureDeclaration(node); + } + function checkTypeForDuplicateIndexSignatures(node) { + if (node.kind === 215 /* InterfaceDeclaration */) { + var nodeSymbol = getSymbolOfNode(node); + // in case of merging interface declaration it is possible that we'll enter this check procedure several times for every declaration + // to prevent this run check only for the first declaration of a given kind + if (nodeSymbol.declarations.length > 0 && nodeSymbol.declarations[0] !== node) { + return; + } + } + // TypeScript 1.0 spec (April 2014) + // 3.7.4: An object type can contain at most one string index signature and one numeric index signature. + // 8.5: A class declaration can have at most one string index member declaration and one numeric index member declaration + var indexSymbol = getIndexSymbol(getSymbolOfNode(node)); + if (indexSymbol) { + var seenNumericIndexer = false; + var seenStringIndexer = false; + for (var _i = 0, _a = indexSymbol.declarations; _i < _a.length; _i++) { + var decl = _a[_i]; + var declaration = decl; + if (declaration.parameters.length === 1 && declaration.parameters[0].type) { + switch (declaration.parameters[0].type.kind) { + case 130 /* StringKeyword */: + if (!seenStringIndexer) { + seenStringIndexer = true; + } + else { + error(declaration, ts.Diagnostics.Duplicate_string_index_signature); + } + break; + case 128 /* NumberKeyword */: + if (!seenNumericIndexer) { + seenNumericIndexer = true; + } + else { + error(declaration, ts.Diagnostics.Duplicate_number_index_signature); + } + break; + } + } + } + } + } + function checkPropertyDeclaration(node) { + // Grammar checking + checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarProperty(node) || checkGrammarComputedPropertyName(node.name); + checkVariableLikeDeclaration(node); + } + function checkMethodDeclaration(node) { + // Grammar checking + checkGrammarMethod(node) || checkGrammarComputedPropertyName(node.name); + // Grammar checking for modifiers is done inside the function checkGrammarFunctionLikeDeclaration + checkFunctionLikeDeclaration(node); + // Abstract methods cannot have an implementation. + // Extra checks are to avoid reporting multiple errors relating to the "abstractness" of the node. + if (node.flags & 256 /* Abstract */ && node.body) { + error(node, ts.Diagnostics.Method_0_cannot_have_an_implementation_because_it_is_marked_abstract, ts.declarationNameToString(node.name)); + } + } + function checkConstructorDeclaration(node) { + // Grammar check on signature of constructor and modifier of the constructor is done in checkSignatureDeclaration function. + checkSignatureDeclaration(node); + // Grammar check for checking only related to constructoDeclaration + checkGrammarConstructorTypeParameters(node) || checkGrammarConstructorTypeAnnotation(node); + checkSourceElement(node.body); + var symbol = getSymbolOfNode(node); + var firstDeclaration = ts.getDeclarationOfKind(symbol, node.kind); + // Only type check the symbol once + if (node === firstDeclaration) { + checkFunctionOrConstructorSymbol(symbol); + } + // exit early in the case of signature - super checks are not relevant to them + if (ts.nodeIsMissing(node.body)) { + return; + } + if (!produceDiagnostics) { + return; + } + function isSuperCallExpression(n) { + return n.kind === 168 /* CallExpression */ && n.expression.kind === 95 /* SuperKeyword */; + } + function containsSuperCallAsComputedPropertyName(n) { + return n.name && containsSuperCall(n.name); + } + function containsSuperCall(n) { + if (isSuperCallExpression(n)) { + return true; + } + else if (ts.isFunctionLike(n)) { + return false; + } + else if (ts.isClassLike(n)) { + return ts.forEach(n.members, containsSuperCallAsComputedPropertyName); + } + return ts.forEachChild(n, containsSuperCall); + } + function markThisReferencesAsErrors(n) { + if (n.kind === 97 /* ThisKeyword */) { + error(n, ts.Diagnostics.this_cannot_be_referenced_in_current_location); + } + else if (n.kind !== 173 /* FunctionExpression */ && n.kind !== 213 /* FunctionDeclaration */) { + ts.forEachChild(n, markThisReferencesAsErrors); + } + } + function isInstancePropertyWithInitializer(n) { + return n.kind === 141 /* PropertyDeclaration */ && + !(n.flags & 128 /* Static */) && + !!n.initializer; + } + // TS 1.0 spec (April 2014): 8.3.2 + // Constructors of classes with no extends clause may not contain super calls, whereas + // constructors of derived classes must contain at least one super call somewhere in their function body. + var containingClassDecl = node.parent; + if (ts.getClassExtendsHeritageClauseElement(containingClassDecl)) { + var containingClassSymbol = getSymbolOfNode(containingClassDecl); + var containingClassInstanceType = getDeclaredTypeOfSymbol(containingClassSymbol); + var baseConstructorType = getBaseConstructorTypeOfClass(containingClassInstanceType); + if (containsSuperCall(node.body)) { + if (baseConstructorType === nullType) { + error(node, ts.Diagnostics.A_constructor_cannot_contain_a_super_call_when_its_class_extends_null); + } + // The first statement in the body of a constructor (excluding prologue directives) must be a super call + // if both of the following are true: + // - The containing class is a derived class. + // - The constructor declares parameter properties + // or the containing class declares instance member variables with initializers. + var superCallShouldBeFirst = ts.forEach(node.parent.members, isInstancePropertyWithInitializer) || + ts.forEach(node.parameters, function (p) { return p.flags & (16 /* Public */ | 32 /* Private */ | 64 /* Protected */); }); + // Skip past any prologue directives to find the first statement + // to ensure that it was a super call. + if (superCallShouldBeFirst) { + var statements = node.body.statements; + var superCallStatement; + for (var _i = 0; _i < statements.length; _i++) { + var statement = statements[_i]; + if (statement.kind === 195 /* ExpressionStatement */ && isSuperCallExpression(statement.expression)) { + superCallStatement = statement; + break; + } + if (!ts.isPrologueDirective(statement)) { + break; + } + } + if (!superCallStatement) { + error(node, ts.Diagnostics.A_super_call_must_be_the_first_statement_in_the_constructor_when_a_class_contains_initialized_properties_or_has_parameter_properties); + } + else { + // In such a required super call, it is a compile-time error for argument expressions to reference this. + markThisReferencesAsErrors(superCallStatement.expression); + } + } + } + else if (baseConstructorType !== nullType) { + error(node, ts.Diagnostics.Constructors_for_derived_classes_must_contain_a_super_call); + } + } + } + function checkAccessorDeclaration(node) { + if (produceDiagnostics) { + // Grammar checking accessors + checkGrammarFunctionLikeDeclaration(node) || checkGrammarAccessor(node) || checkGrammarComputedPropertyName(node.name); + if (node.kind === 145 /* GetAccessor */) { + if (!ts.isInAmbientContext(node) && ts.nodeIsPresent(node.body) && !(bodyContainsAReturnStatement(node.body) || bodyContainsSingleThrowStatement(node.body))) { + error(node.name, ts.Diagnostics.A_get_accessor_must_return_a_value_or_consist_of_a_single_throw_statement); + } + } + 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 === 145 /* GetAccessor */ ? 146 /* SetAccessor */ : 145 /* GetAccessor */; + var otherAccessor = ts.getDeclarationOfKind(node.symbol, otherKind); + if (otherAccessor) { + if (((node.flags & 112 /* AccessibilityModifier */) !== (otherAccessor.flags & 112 /* AccessibilityModifier */))) { + error(node.name, ts.Diagnostics.Getter_and_setter_accessors_do_not_agree_in_visibility); + } + var currentAccessorType = getAnnotatedAccessorType(node); + var otherAccessorType = getAnnotatedAccessorType(otherAccessor); + // TypeScript 1.0 spec (April 2014): 4.5 + // If both accessors include type annotations, the specified types must be identical. + if (currentAccessorType && otherAccessorType) { + if (!isTypeIdenticalTo(currentAccessorType, otherAccessorType)) { + error(node, ts.Diagnostics.get_and_set_accessor_must_have_the_same_type); + } + } + } + } + getTypeOfAccessors(getSymbolOfNode(node)); + } + checkFunctionLikeDeclaration(node); + } + function checkMissingDeclaration(node) { + checkDecorators(node); + } + function checkTypeArgumentConstraints(typeParameters, typeArguments) { + var result = true; + for (var i = 0; i < typeParameters.length; i++) { + var constraint = getConstraintOfTypeParameter(typeParameters[i]); + if (constraint) { + var typeArgument = typeArguments[i]; + result = result && checkTypeAssignableTo(getTypeFromTypeNode(typeArgument), constraint, typeArgument, ts.Diagnostics.Type_0_does_not_satisfy_the_constraint_1); + } + } + return result; + } + function checkTypeReferenceNode(node) { + checkGrammarTypeArguments(node, node.typeArguments); + var type = getTypeFromTypeReference(node); + if (type !== unknownType && node.typeArguments) { + // Do type argument local checks only if referenced type is successfully resolved + ts.forEach(node.typeArguments, checkSourceElement); + if (produceDiagnostics) { + var symbol = getNodeLinks(node).resolvedSymbol; + var typeParameters = symbol.flags & 524288 /* TypeAlias */ ? getSymbolLinks(symbol).typeParameters : type.target.localTypeParameters; + checkTypeArgumentConstraints(typeParameters, node.typeArguments); + } + } + } + function checkTypeQuery(node) { + getTypeFromTypeQueryNode(node); + } + function checkTypeLiteral(node) { + ts.forEach(node.members, checkSourceElement); + if (produceDiagnostics) { + var type = getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node); + checkIndexConstraints(type); + checkTypeForDuplicateIndexSignatures(node); + } + } + function checkArrayType(node) { + checkSourceElement(node.elementType); + } + function checkTupleType(node) { + // Grammar checking + var hasErrorFromDisallowedTrailingComma = checkGrammarForDisallowedTrailingComma(node.elementTypes); + if (!hasErrorFromDisallowedTrailingComma && node.elementTypes.length === 0) { + grammarErrorOnNode(node, ts.Diagnostics.A_tuple_type_element_list_cannot_be_empty); + } + ts.forEach(node.elementTypes, checkSourceElement); + } + function checkUnionOrIntersectionType(node) { + ts.forEach(node.types, checkSourceElement); + } + function isPrivateWithinAmbient(node) { + return (node.flags & 32 /* Private */) && ts.isInAmbientContext(node); + } + function checkSpecializedSignatureDeclaration(signatureDeclarationNode) { + if (!produceDiagnostics) { + return; + } + var signature = getSignatureFromDeclaration(signatureDeclarationNode); + if (!signature.hasStringLiterals) { + return; + } + // TypeScript 1.0 spec (April 2014): 3.7.2.2 + // Specialized signatures are not permitted in conjunction with a function body + if (ts.nodeIsPresent(signatureDeclarationNode.body)) { + error(signatureDeclarationNode, ts.Diagnostics.A_signature_with_an_implementation_cannot_use_a_string_literal_type); + return; + } + // TypeScript 1.0 spec (April 2014): 3.7.2.4 + // Every specialized call or construct signature in an object type must be assignable + // to at least one non-specialized call or construct signature in the same object type + var signaturesToCheck; + // Unnamed (call\construct) signatures in interfaces are inherited and not shadowed so examining just node symbol won't give complete answer. + // Use declaring type to obtain full list of signatures. + if (!signatureDeclarationNode.name && signatureDeclarationNode.parent && signatureDeclarationNode.parent.kind === 215 /* InterfaceDeclaration */) { + ts.Debug.assert(signatureDeclarationNode.kind === 147 /* CallSignature */ || signatureDeclarationNode.kind === 148 /* ConstructSignature */); + var signatureKind = signatureDeclarationNode.kind === 147 /* CallSignature */ ? 0 /* Call */ : 1 /* Construct */; + var containingSymbol = getSymbolOfNode(signatureDeclarationNode.parent); + var containingType = getDeclaredTypeOfSymbol(containingSymbol); + signaturesToCheck = getSignaturesOfType(containingType, signatureKind); + } + else { + signaturesToCheck = getSignaturesOfSymbol(getSymbolOfNode(signatureDeclarationNode)); + } + for (var _i = 0; _i < signaturesToCheck.length; _i++) { + var otherSignature = signaturesToCheck[_i]; + if (!otherSignature.hasStringLiterals && isSignatureAssignableTo(signature, otherSignature)) { + return; + } + } + error(signatureDeclarationNode, ts.Diagnostics.Specialized_overload_signature_is_not_assignable_to_any_non_specialized_signature); + } + function getEffectiveDeclarationFlags(n, flagsToCheck) { + var flags = ts.getCombinedNodeFlags(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 !== 215 /* InterfaceDeclaration */ && + n.parent.kind !== 214 /* ClassDeclaration */ && + n.parent.kind !== 186 /* ClassExpression */ && + ts.isInAmbientContext(n)) { + if (!(flags & 2 /* Ambient */)) { + // It is nested in an ambient context, which means it is automatically exported + flags |= 1 /* Export */; + } + flags |= 2 /* Ambient */; + } + return flags & flagsToCheck; + } + function checkFunctionOrConstructorSymbol(symbol) { + if (!produceDiagnostics) { + return; + } + function getCanonicalOverload(overloads, implementation) { + // Consider the canonical set of flags to be the flags of the bodyDeclaration or the first declaration + // Error on all deviations from this canonical set of flags + // The caveat is that if some overloads are defined in lib.d.ts, we don't want to + // report the errors on those. To achieve this, we will say that the implementation is + // the canonical signature only if it is in the same container as the first overload + var implementationSharesContainerWithFirstOverload = implementation !== undefined && implementation.parent === overloads[0].parent; + return implementationSharesContainerWithFirstOverload ? implementation : overloads[0]; + } + function checkFlagAgreementBetweenOverloads(overloads, implementation, flagsToCheck, someOverloadFlags, allOverloadFlags) { + // Error if some overloads have a flag that is not shared by all overloads. To find the + // deviations, we XOR someOverloadFlags with allOverloadFlags + var someButNotAllOverloadFlags = someOverloadFlags ^ allOverloadFlags; + if (someButNotAllOverloadFlags !== 0) { + var canonicalFlags = getEffectiveDeclarationFlags(getCanonicalOverload(overloads, implementation), flagsToCheck); + ts.forEach(overloads, function (o) { + var deviation = getEffectiveDeclarationFlags(o, flagsToCheck) ^ canonicalFlags; + if (deviation & 1 /* Export */) { + error(o.name, ts.Diagnostics.Overload_signatures_must_all_be_exported_or_not_exported); + } + else if (deviation & 2 /* Ambient */) { + error(o.name, ts.Diagnostics.Overload_signatures_must_all_be_ambient_or_non_ambient); + } + else if (deviation & (32 /* Private */ | 64 /* Protected */)) { + error(o.name, ts.Diagnostics.Overload_signatures_must_all_be_public_private_or_protected); + } + else if (deviation & 256 /* Abstract */) { + error(o.name, ts.Diagnostics.Overload_signatures_must_all_be_abstract_or_not_abstract); + } + }); + } + } + function checkQuestionTokenAgreementBetweenOverloads(overloads, implementation, someHaveQuestionToken, allHaveQuestionToken) { + if (someHaveQuestionToken !== allHaveQuestionToken) { + var canonicalHasQuestionToken = ts.hasQuestionToken(getCanonicalOverload(overloads, implementation)); + ts.forEach(overloads, function (o) { + var deviation = ts.hasQuestionToken(o) !== canonicalHasQuestionToken; + if (deviation) { + error(o.name, ts.Diagnostics.Overload_signatures_must_all_be_optional_or_required); + } + }); + } + } + var flagsToCheck = 1 /* Export */ | 2 /* Ambient */ | 32 /* Private */ | 64 /* Protected */ | 256 /* Abstract */; + var someNodeFlags = 0; + var allNodeFlags = flagsToCheck; + var someHaveQuestionToken = false; + var allHaveQuestionToken = true; + var hasOverloads = false; + var bodyDeclaration; + var lastSeenNonAmbientDeclaration; + var previousDeclaration; + var declarations = symbol.declarations; + var isConstructor = (symbol.flags & 16384 /* Constructor */) !== 0; + function reportImplementationExpectedError(node) { + if (node.name && ts.nodeIsMissing(node.name)) { + return; + } + var seen = false; + var subsequentNode = ts.forEachChild(node.parent, function (c) { + if (seen) { + return c; + } + else { + seen = c === node; + } + }); + if (subsequentNode) { + if (subsequentNode.kind === node.kind) { + 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) { + // the only situation when this is possible (same kind\same name but different symbol) - mixed static and instance class members + ts.Debug.assert(node.kind === 143 /* MethodDeclaration */ || node.kind === 142 /* MethodSignature */); + ts.Debug.assert((node.flags & 128 /* Static */) !== (subsequentNode.flags & 128 /* Static */)); + var diagnostic = node.flags & 128 /* Static */ ? ts.Diagnostics.Function_overload_must_be_static : ts.Diagnostics.Function_overload_must_not_be_static; + error(errorNode_1, diagnostic); + return; + } + else if (ts.nodeIsPresent(subsequentNode.body)) { + error(errorNode_1, ts.Diagnostics.Function_implementation_name_must_be_0, ts.declarationNameToString(node.name)); + return; + } + } + } + var errorNode = node.name || node; + if (isConstructor) { + error(errorNode, ts.Diagnostics.Constructor_implementation_is_missing); + } + else { + // Report different errors regarding non-consecutive blocks of declarations depending on whether + // the node in question is abstract. + if (node.flags & 256 /* Abstract */) { + error(errorNode, ts.Diagnostics.All_declarations_of_an_abstract_method_must_be_consecutive); + } + else { + error(errorNode, ts.Diagnostics.Function_implementation_is_missing_or_not_immediately_following_the_declaration); + } + } + } + // when checking exported function declarations across modules check only duplicate implementations + // names and consistency of modifiers are verified when we check local symbol + var isExportSymbolInsideModule = symbol.parent && symbol.parent.flags & 1536 /* Module */; + var duplicateFunctionDeclaration = false; + var multipleConstructorImplementation = false; + for (var _i = 0; _i < declarations.length; _i++) { + var current = declarations[_i]; + var node = current; + var inAmbientContext = ts.isInAmbientContext(node); + var inAmbientContextOrInterface = node.parent.kind === 215 /* InterfaceDeclaration */ || node.parent.kind === 155 /* TypeLiteral */ || inAmbientContext; + if (inAmbientContextOrInterface) { + // check if declarations are consecutive only if they are non-ambient + // 1. ambient declarations can be interleaved + // i.e. this is legal + // declare function foo(); + // declare function bar(); + // declare function foo(); + // 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 === 213 /* FunctionDeclaration */ || node.kind === 143 /* MethodDeclaration */ || node.kind === 142 /* MethodSignature */ || node.kind === 144 /* Constructor */) { + var currentNodeFlags = getEffectiveDeclarationFlags(node, flagsToCheck); + someNodeFlags |= currentNodeFlags; + allNodeFlags &= currentNodeFlags; + someHaveQuestionToken = someHaveQuestionToken || ts.hasQuestionToken(node); + allHaveQuestionToken = allHaveQuestionToken && ts.hasQuestionToken(node); + if (ts.nodeIsPresent(node.body) && bodyDeclaration) { + if (isConstructor) { + multipleConstructorImplementation = true; + } + else { + duplicateFunctionDeclaration = true; + } + } + else if (!isExportSymbolInsideModule && previousDeclaration && previousDeclaration.parent === node.parent && previousDeclaration.end !== node.pos) { + reportImplementationExpectedError(previousDeclaration); + } + if (ts.nodeIsPresent(node.body)) { + if (!bodyDeclaration) { + bodyDeclaration = node; + } + } + else { + hasOverloads = true; + } + previousDeclaration = node; + if (!inAmbientContextOrInterface) { + lastSeenNonAmbientDeclaration = node; + } + } + } + if (multipleConstructorImplementation) { + ts.forEach(declarations, function (declaration) { + error(declaration, ts.Diagnostics.Multiple_constructor_implementations_are_not_allowed); + }); + } + if (duplicateFunctionDeclaration) { + ts.forEach(declarations, function (declaration) { + error(declaration.name, ts.Diagnostics.Duplicate_function_implementation); + }); + } + // Abstract methods can't have an implementation -- in particular, they don't need one. + if (!isExportSymbolInsideModule && lastSeenNonAmbientDeclaration && !lastSeenNonAmbientDeclaration.body && + !(lastSeenNonAmbientDeclaration.flags & 256 /* Abstract */)) { + reportImplementationExpectedError(lastSeenNonAmbientDeclaration); + } + if (hasOverloads) { + checkFlagAgreementBetweenOverloads(declarations, bodyDeclaration, flagsToCheck, someNodeFlags, allNodeFlags); + checkQuestionTokenAgreementBetweenOverloads(declarations, bodyDeclaration, someHaveQuestionToken, allHaveQuestionToken); + if (bodyDeclaration) { + var signatures = getSignaturesOfSymbol(symbol); + var bodySignature = getSignatureFromDeclaration(bodyDeclaration); + // If the implementation signature has string literals, we will have reported an error in + // checkSpecializedSignatureDeclaration + if (!bodySignature.hasStringLiterals) { + // TypeScript 1.0 spec (April 2014): 6.1 + // If a function declaration includes overloads, the overloads determine the call + // signatures of the type given to the function object + // and the function implementation signature must be assignable to that type + // + // TypeScript 1.0 spec (April 2014): 3.8.4 + // Note that specialized call and construct signatures (section 3.7.2.4) are not significant when determining assignment compatibility + // Consider checking against specialized signatures too. Not doing so creates a type hole: + // + // function g(x: "hi", y: boolean); + // function g(x: string, y: {}); + // function g(x: string, y: string) { } + // + // The implementation is completely unrelated to the specialized signature, yet we do not check this. + for (var _a = 0; _a < signatures.length; _a++) { + var signature = signatures[_a]; + if (!signature.hasStringLiterals && !isSignatureAssignableTo(bodySignature, signature)) { + error(signature.declaration, ts.Diagnostics.Overload_signature_is_not_compatible_with_function_implementation); + break; + } + } + } + } + } + } + function checkExportsOnMergedDeclarations(node) { + if (!produceDiagnostics) { + return; + } + // if localSymbol is defined on node then node itself is exported - check is required + var symbol = node.localSymbol; + if (!symbol) { + // local symbol is undefined => this declaration is non-exported. + // however symbol might contain other declarations that are exported + symbol = getSymbolOfNode(node); + if (!(symbol.flags & 7340032 /* Export */)) { + // this is a pure local symbol (all declarations are non-exported) - no need to check anything + return; + } + } + // run the check only for the first declaration in the list + if (ts.getDeclarationOfKind(symbol, node.kind) !== node) { + return; + } + // we use SymbolFlags.ExportValue, SymbolFlags.ExportType and SymbolFlags.ExportNamespace + // to denote disjoint declarationSpaces (without making new enum type). + var exportedDeclarationSpaces = 0 /* None */; + var nonExportedDeclarationSpaces = 0 /* None */; + var defaultExportedDeclarationSpaces = 0 /* None */; + for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { + var d = _a[_i]; + var declarationSpaces = getDeclarationSpaces(d); + var effectiveDeclarationFlags = getEffectiveDeclarationFlags(d, 1 /* Export */ | 1024 /* Default */); + if (effectiveDeclarationFlags & 1 /* Export */) { + if (effectiveDeclarationFlags & 1024 /* Default */) { + defaultExportedDeclarationSpaces |= declarationSpaces; + } + else { + exportedDeclarationSpaces |= declarationSpaces; + } + } + else { + nonExportedDeclarationSpaces |= declarationSpaces; + } + } + // Spaces for anyting not declared a 'default export'. + var nonDefaultExportedDeclarationSpaces = exportedDeclarationSpaces | nonExportedDeclarationSpaces; + var commonDeclarationSpacesForExportsAndLocals = exportedDeclarationSpaces & nonExportedDeclarationSpaces; + var commonDeclarationSpacesForDefaultAndNonDefault = defaultExportedDeclarationSpaces & nonDefaultExportedDeclarationSpaces; + if (commonDeclarationSpacesForExportsAndLocals || commonDeclarationSpacesForDefaultAndNonDefault) { + // declaration spaces for exported and non-exported declarations intersect + for (var _b = 0, _c = symbol.declarations; _b < _c.length; _b++) { + var d = _c[_b]; + var declarationSpaces = getDeclarationSpaces(d); + // Only error on the declarations that conributed to the intersecting spaces. + if (declarationSpaces & commonDeclarationSpacesForDefaultAndNonDefault) { + error(d.name, ts.Diagnostics.Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_default_0_declaration_instead, ts.declarationNameToString(d.name)); + } + else if (declarationSpaces & commonDeclarationSpacesForExportsAndLocals) { + error(d.name, ts.Diagnostics.Individual_declarations_in_merged_declaration_0_must_be_all_exported_or_all_local, ts.declarationNameToString(d.name)); + } + } + } + function getDeclarationSpaces(d) { + switch (d.kind) { + case 215 /* InterfaceDeclaration */: + return 2097152 /* ExportType */; + case 218 /* ModuleDeclaration */: + return d.name.kind === 9 /* StringLiteral */ || ts.getModuleInstanceState(d) !== 0 /* NonInstantiated */ + ? 4194304 /* ExportNamespace */ | 1048576 /* ExportValue */ + : 4194304 /* ExportNamespace */; + case 214 /* ClassDeclaration */: + case 217 /* EnumDeclaration */: + return 2097152 /* ExportType */ | 1048576 /* ExportValue */; + case 221 /* ImportEqualsDeclaration */: + var result = 0; + var target = resolveAlias(getSymbolOfNode(d)); + ts.forEach(target.declarations, function (d) { result |= getDeclarationSpaces(d); }); + return result; + default: + return 1048576 /* ExportValue */; + } + } + } + function checkNonThenableType(type, location, message) { + type = getWidenedType(type); + if (!isTypeAny(type) && isTypeAssignableTo(type, getGlobalThenableType())) { + if (location) { + if (!message) { + message = ts.Diagnostics.Operand_for_await_does_not_have_a_valid_callable_then_member; + } + error(location, message); + } + return unknownType; + } + return type; + } + /** + * Gets the "promised type" of a promise. + * @param type The type of the promise. + * @remarks The "promised type" of a type is the type of the "value" parameter of the "onfulfilled" callback. + */ + function getPromisedType(promise) { + // + // { // promise + // then( // thenFunction + // onfulfilled: ( // onfulfilledParameterType + // value: T // valueParameterType + // ) => any + // ): any; + // } + // + if (promise.flags & 1 /* Any */) { + return undefined; + } + if ((promise.flags & 4096 /* Reference */) && promise.target === tryGetGlobalPromiseType()) { + return promise.typeArguments[0]; + } + var globalPromiseLikeType = getInstantiatedGlobalPromiseLikeType(); + if (globalPromiseLikeType === emptyObjectType || !isTypeAssignableTo(promise, globalPromiseLikeType)) { + return undefined; + } + var thenFunction = getTypeOfPropertyOfType(promise, "then"); + if (thenFunction && (thenFunction.flags & 1 /* Any */)) { + return undefined; + } + var thenSignatures = thenFunction ? getSignaturesOfType(thenFunction, 0 /* Call */) : emptyArray; + if (thenSignatures.length === 0) { + return undefined; + } + var onfulfilledParameterType = getUnionType(ts.map(thenSignatures, getTypeOfFirstParameterOfSignature)); + if (onfulfilledParameterType.flags & 1 /* Any */) { + return undefined; + } + var onfulfilledParameterSignatures = getSignaturesOfType(onfulfilledParameterType, 0 /* Call */); + if (onfulfilledParameterSignatures.length === 0) { + return undefined; + } + var valueParameterType = getUnionType(ts.map(onfulfilledParameterSignatures, getTypeOfFirstParameterOfSignature)); + return valueParameterType; + } + function getTypeOfFirstParameterOfSignature(signature) { + return getTypeAtPosition(signature, 0); + } + /** + * Gets the "awaited type" of a type. + * @param type The type to await. + * @remarks The "awaited type" of an expression is its "promised type" if the expression is a + * Promise-like type; otherwise, it is the type of the expression. This is used to reflect + * The runtime behavior of the `await` keyword. + */ + function getAwaitedType(type) { + return checkAwaitedType(type, /*location*/ undefined, /*message*/ undefined); + } + function checkAwaitedType(type, location, message) { + return checkAwaitedTypeWorker(type); + function checkAwaitedTypeWorker(type) { + if (type.flags & 16384 /* Union */) { + var types = []; + for (var _i = 0, _a = type.types; _i < _a.length; _i++) { + var constituentType = _a[_i]; + types.push(checkAwaitedTypeWorker(constituentType)); + } + return getUnionType(types); + } + else { + var promisedType = getPromisedType(type); + if (promisedType === undefined) { + // The type was not a PromiseLike, so it could not be unwrapped any further. + // As long as the type does not have a callable "then" property, it is + // safe to return the type; otherwise, an error will have been reported in + // the call to checkNonThenableType and we will return unknownType. + // + // An example of a non-promise "thenable" might be: + // + // await { then(): void {} } + // + // The "thenable" does not match the minimal definition for a PromiseLike. When + // a Promise/A+-compatible or ES6 promise tries to adopt this value, the promise + // will never settle. We treat this as an error to help flag an early indicator + // of a runtime problem. If the user wants to return this value from an async + // function, they would need to wrap it in some other value. If they want it to + // be treated as a promise, they can cast to . + return checkNonThenableType(type, location, message); + } + else { + if (type.id === promisedType.id || awaitedTypeStack.indexOf(promisedType.id) >= 0) { + // We have a bad actor in the form of a promise whose promised type is + // the same promise type, or a mutually recursive promise. Return the + // unknown type as we cannot guess the shape. If this were the actual + // case in the JavaScript, this Promise would never resolve. + // + // An example of a bad actor with a singly-recursive promise type might + // be: + // + // interface BadPromise { + // then( + // onfulfilled: (value: BadPromise) => any, + // onrejected: (error: any) => any): BadPromise; + // } + // + // The above interface will pass the PromiseLike check, and return a + // promised type of `BadPromise`. Since this is a self reference, we + // don't want to keep recursing ad infinitum. + // + // An example of a bad actor in the form of a mutually-recursive + // promise type might be: + // + // interface BadPromiseA { + // then( + // onfulfilled: (value: BadPromiseB) => any, + // onrejected: (error: any) => any): BadPromiseB; + // } + // + // interface BadPromiseB { + // then( + // onfulfilled: (value: BadPromiseA) => any, + // onrejected: (error: any) => any): BadPromiseA; + // } + // + if (location) { + error(location, ts.Diagnostics._0_is_referenced_directly_or_indirectly_in_the_fulfillment_callback_of_its_own_then_method, symbolToString(type.symbol)); + } + return unknownType; + } + // Keep track of the type we're about to unwrap to avoid bad recursive promise types. + // See the comments above for more information. + awaitedTypeStack.push(type.id); + var awaitedType = checkAwaitedTypeWorker(promisedType); + awaitedTypeStack.pop(); + return awaitedType; + } + } + } + } + /** + * Checks the return type of an async function to ensure it is a compatible + * Promise implementation. + * @param node The signature to check + * @param returnType The return type for the function + * @remarks + * This checks that an async function has a valid Promise-compatible return type, + * and returns the *awaited type* of the promise. An async function has a valid + * Promise-compatible return type if the resolved value of the return type has a + * construct signature that takes in an `initializer` function that in turn supplies + * a `resolve` function as one of its arguments and results in an object with a + * callable `then` signature. + */ + function checkAsyncFunctionReturnType(node) { + var globalPromiseConstructorLikeType = getGlobalPromiseConstructorLikeType(); + if (globalPromiseConstructorLikeType === emptyObjectType) { + // If we couldn't resolve the global PromiseConstructorLike type we cannot verify + // compatibility with __awaiter. + return unknownType; + } + // As part of our emit for an async function, we will need to emit the entity name of + // the return type annotation as an expression. To meet the necessary runtime semantics + // for __awaiter, we must also check that the type of the declaration (e.g. the static + // side or "constructor" of the promise type) is compatible `PromiseConstructorLike`. + // + // An example might be (from lib.es6.d.ts): + // + // interface Promise { ... } + // interface PromiseConstructor { + // new (...): Promise; + // } + // declare var Promise: PromiseConstructor; + // + // When an async function declares a return type annotation of `Promise`, we + // need to get the type of the `Promise` variable declaration above, which would + // be `PromiseConstructor`. + // + // The same case applies to a class: + // + // declare class Promise { + // constructor(...); + // then(...): Promise; + // } + // + // When we get the type of the `Promise` symbol here, we get the type of the static + // side of the `Promise` class, which would be `{ new (...): Promise }`. + var promiseType = getTypeFromTypeNode(node.type); + if (promiseType === unknownType && compilerOptions.isolatedModules) { + // If we are compiling with isolatedModules, we may not be able to resolve the + // type as a value. As such, we will just return unknownType; + return unknownType; + } + var promiseConstructor = getMergedSymbol(promiseType.symbol); + if (!promiseConstructor || !symbolIsValue(promiseConstructor)) { + error(node, ts.Diagnostics.Type_0_is_not_a_valid_async_function_return_type, typeToString(promiseType)); + return unknownType; + } + // Validate the promise constructor type. + var promiseConstructorType = getTypeOfSymbol(promiseConstructor); + if (!checkTypeAssignableTo(promiseConstructorType, globalPromiseConstructorLikeType, node, ts.Diagnostics.Type_0_is_not_a_valid_async_function_return_type)) { + return unknownType; + } + // Verify there is no local declaration that could collide with the promise constructor. + var promiseName = ts.getEntityNameFromTypeNode(node.type); + var root = getFirstIdentifier(promiseName); + var rootSymbol = getSymbol(node.locals, root.text, 107455 /* Value */); + if (rootSymbol) { + error(rootSymbol.valueDeclaration, ts.Diagnostics.Duplicate_identifier_0_Compiler_uses_declaration_1_to_support_async_functions, root.text, getFullyQualifiedName(promiseConstructor)); + return unknownType; + } + // Get and return the awaited type of the return type. + return checkAwaitedType(promiseType, node, ts.Diagnostics.An_async_function_or_method_must_have_a_valid_awaitable_return_type); + } + /** Check a decorator */ + function checkDecorator(node) { + var signature = getResolvedSignature(node); + var returnType = getReturnTypeOfSignature(signature); + if (returnType.flags & 1 /* Any */) { + return; + } + var expectedReturnType; + var headMessage = getDiagnosticHeadMessageForDecoratorResolution(node); + var errorInfo; + switch (node.parent.kind) { + case 214 /* ClassDeclaration */: + var classSymbol = getSymbolOfNode(node.parent); + var classConstructorType = getTypeOfSymbol(classSymbol); + expectedReturnType = getUnionType([classConstructorType, voidType]); + break; + case 138 /* Parameter */: + expectedReturnType = voidType; + errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.The_return_type_of_a_parameter_decorator_function_must_be_either_void_or_any); + break; + case 141 /* PropertyDeclaration */: + expectedReturnType = voidType; + errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.The_return_type_of_a_property_decorator_function_must_be_either_void_or_any); + break; + case 143 /* MethodDeclaration */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: + var methodType = getTypeOfNode(node.parent); + var descriptorType = createTypedPropertyDescriptorType(methodType); + expectedReturnType = getUnionType([descriptorType, voidType]); + break; + } + checkTypeAssignableTo(returnType, expectedReturnType, node, headMessage, errorInfo); + } + /** Checks a type reference node as an expression. */ + function checkTypeNodeAsExpression(node) { + // 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 === 151 /* TypeReference */) { + var root = getFirstIdentifier(node.typeName); + var meaning = root.parent.kind === 151 /* TypeReference */ ? 793056 /* Type */ : 1536 /* Namespace */; + // Resolve type so we know which symbol is referenced + var rootSymbol = resolveName(root, root.text, meaning | 8388608 /* Alias */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined); + // Resolved symbol is alias + if (rootSymbol && rootSymbol.flags & 8388608 /* Alias */) { + var aliasTarget = resolveAlias(rootSymbol); + // If alias has value symbol - mark alias as referenced + if (aliasTarget.flags & 107455 /* Value */ && !isConstEnumOrConstEnumOnlyModule(resolveAlias(rootSymbol))) { + markAliasSymbolAsReferenced(rootSymbol); + } + } + } + } + /** + * Checks the type annotation of an accessor declaration or property declaration as + * an expression if it is a type reference to a type with a value declaration. + */ + function checkTypeAnnotationAsExpression(node) { + switch (node.kind) { + case 141 /* PropertyDeclaration */: + checkTypeNodeAsExpression(node.type); + break; + case 138 /* Parameter */: + checkTypeNodeAsExpression(node.type); + break; + case 143 /* MethodDeclaration */: + checkTypeNodeAsExpression(node.type); + break; + case 145 /* GetAccessor */: + checkTypeNodeAsExpression(node.type); + break; + case 146 /* SetAccessor */: + checkTypeNodeAsExpression(ts.getSetAccessorTypeAnnotationNode(node)); + break; + } + } + /** Checks the type annotation of the parameters of a function/method or the constructor of a class as expressions */ + function checkParameterTypeAnnotationsAsExpressions(node) { + // ensure all type annotations with a value declaration are checked as an expression + for (var _i = 0, _a = node.parameters; _i < _a.length; _i++) { + var parameter = _a[_i]; + checkTypeAnnotationAsExpression(parameter); + } + } + /** Check the decorators of a node */ + function checkDecorators(node) { + if (!node.decorators) { + return; + } + // skip this check for nodes that cannot have decorators. These should have already had an error reported by + // checkGrammarDecorators. + if (!ts.nodeCanBeDecorated(node)) { + return; + } + if (!compilerOptions.experimentalDecorators) { + error(node, ts.Diagnostics.Experimental_support_for_decorators_is_a_feature_that_is_subject_to_change_in_a_future_release_Specify_experimentalDecorators_to_remove_this_warning); + } + 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 214 /* ClassDeclaration */: + var constructor = ts.getFirstConstructorWithBody(node); + if (constructor) { + checkParameterTypeAnnotationsAsExpressions(constructor); + } + break; + case 143 /* MethodDeclaration */: + checkParameterTypeAnnotationsAsExpressions(node); + // fall-through + case 146 /* SetAccessor */: + case 145 /* GetAccessor */: + case 141 /* PropertyDeclaration */: + case 138 /* Parameter */: + checkTypeAnnotationAsExpression(node); + break; + } + } + emitDecorate = true; + if (node.kind === 138 /* Parameter */) { + emitParam = true; + } + ts.forEach(node.decorators, checkDecorator); + } + function checkFunctionDeclaration(node) { + if (produceDiagnostics) { + checkFunctionLikeDeclaration(node) || checkGrammarForGenerator(node); + checkCollisionWithCapturedSuperVariable(node, node.name); + checkCollisionWithCapturedThisVariable(node, node.name); + checkCollisionWithRequireExportsInGeneratedCode(node, node.name); + } + } + function checkFunctionLikeDeclaration(node) { + checkDecorators(node); + checkSignatureDeclaration(node); + var isAsync = ts.isAsyncFunctionLike(node); + if (isAsync) { + emitAwaiter = true; + } + // Do not use hasDynamicName here, because that returns false for well known symbols. + // We want to perform checkComputedPropertyName for all computed properties, including + // well known symbols. + if (node.name && node.name.kind === 136 /* ComputedPropertyName */) { + // This check will account for methods in class/interface declarations, + // as well as accessors in classes/object literals + checkComputedPropertyName(node.name); + } + if (!ts.hasDynamicName(node)) { + // first we want to check the local symbol that contain this declaration + // - if node.localSymbol !== undefined - this is current declaration is exported and localSymbol points to the local symbol + // - if node.localSymbol === undefined - this node is non-exported so we can just pick the result of getSymbolOfNode + var symbol = getSymbolOfNode(node); + var localSymbol = node.localSymbol || symbol; + var firstDeclaration = ts.getDeclarationOfKind(localSymbol, node.kind); + // Only type check the symbol once + if (node === firstDeclaration) { + checkFunctionOrConstructorSymbol(localSymbol); + } + if (symbol.parent) { + // run check once for the first declaration + if (ts.getDeclarationOfKind(symbol, node.kind) === node) { + // run check on export symbol to check that modifiers agree across all exported declarations + checkFunctionOrConstructorSymbol(symbol); + } + } + } + checkSourceElement(node.body); + if (node.type && !isAccessor(node.kind) && !node.asteriskToken) { + var returnType = getTypeFromTypeNode(node.type); + var promisedType; + if (isAsync) { + promisedType = checkAsyncFunctionReturnType(node); + } + checkIfNonVoidFunctionHasReturnExpressionsOrSingleThrowStatment(node, isAsync ? promisedType : returnType); + } + if (produceDiagnostics && !node.type) { + // Report an implicit any error if there is no body, no explicit return type, and node is not a private method + // in an ambient context + if (compilerOptions.noImplicitAny && ts.nodeIsMissing(node.body) && !isPrivateWithinAmbient(node)) { + reportImplicitAnyError(node, anyType); + } + if (node.asteriskToken && ts.nodeIsPresent(node.body)) { + // A generator with a body and no type annotation can still cause errors. It can error if the + // yielded values have no common supertype, or it can give an implicit any error if it has no + // yielded values. The only way to trigger these errors is to try checking its return type. + getReturnTypeOfSignature(getSignatureFromDeclaration(node)); + } + } + } + function checkBlock(node) { + // Grammar checking for SyntaxKind.Block + if (node.kind === 192 /* Block */) { + checkGrammarStatementInAmbientContext(node); + } + ts.forEach(node.statements, checkSourceElement); + if (ts.isFunctionBlock(node) || node.kind === 219 /* ModuleBlock */) { + checkFunctionAndClassExpressionBodies(node); + } + } + function checkCollisionWithArgumentsInGeneratedCode(node) { + // no rest parameters \ declaration context \ overload - no codegen impact + if (!ts.hasRestParameter(node) || ts.isInAmbientContext(node) || ts.nodeIsMissing(node.body)) { + return; + } + ts.forEach(node.parameters, function (p) { + if (p.name && !ts.isBindingPattern(p.name) && p.name.text === argumentsSymbol.name) { + error(p, ts.Diagnostics.Duplicate_identifier_arguments_Compiler_uses_arguments_to_initialize_rest_parameters); + } + }); + } + function needCollisionCheckForIdentifier(node, identifier, name) { + if (!(identifier && identifier.text === name)) { + return false; + } + if (node.kind === 141 /* PropertyDeclaration */ || + node.kind === 140 /* PropertySignature */ || + node.kind === 143 /* MethodDeclaration */ || + node.kind === 142 /* MethodSignature */ || + node.kind === 145 /* GetAccessor */ || + node.kind === 146 /* SetAccessor */) { + // it is ok to have member named '_super' or '_this' - member access is always qualified + return false; + } + if (ts.isInAmbientContext(node)) { + // ambient context - no codegen impact + return false; + } + var root = ts.getRootDeclaration(node); + if (root.kind === 138 /* Parameter */ && ts.nodeIsMissing(root.parent.body)) { + // just an overload - no codegen impact + return false; + } + return true; + } + function checkCollisionWithCapturedThisVariable(node, name) { + if (needCollisionCheckForIdentifier(node, name, "_this")) { + potentialThisCollisions.push(node); + } + } + // this function will run after checking the source file so 'CaptureThis' is correct for all nodes + function checkIfThisIsCapturedInEnclosingScope(node) { + var current = node; + while (current) { + if (getNodeCheckFlags(current) & 4 /* CaptureThis */) { + var isDeclaration_1 = node.kind !== 69 /* Identifier */; + if (isDeclaration_1) { + error(node.name, ts.Diagnostics.Duplicate_identifier_this_Compiler_uses_variable_declaration_this_to_capture_this_reference); + } + else { + error(node, ts.Diagnostics.Expression_resolves_to_variable_declaration_this_that_compiler_uses_to_capture_this_reference); + } + return; + } + current = current.parent; + } + } + function checkCollisionWithCapturedSuperVariable(node, name) { + if (!needCollisionCheckForIdentifier(node, name, "_super")) { + return; + } + // bubble up and find containing type + var enclosingClass = ts.getContainingClass(node); + // if containing type was not found or it is ambient - exit (no codegen) + if (!enclosingClass || ts.isInAmbientContext(enclosingClass)) { + return; + } + if (ts.getClassExtendsHeritageClauseElement(enclosingClass)) { + var isDeclaration_2 = node.kind !== 69 /* Identifier */; + if (isDeclaration_2) { + error(node, ts.Diagnostics.Duplicate_identifier_super_Compiler_uses_super_to_capture_base_class_reference); + } + else { + error(node, ts.Diagnostics.Expression_resolves_to_super_that_compiler_uses_to_capture_base_class_reference); + } + } + } + function checkCollisionWithRequireExportsInGeneratedCode(node, name) { + if (!needCollisionCheckForIdentifier(node, name, "require") && !needCollisionCheckForIdentifier(node, name, "exports")) { + return; + } + // Uninstantiated modules shouldnt do this check + if (node.kind === 218 /* ModuleDeclaration */ && ts.getModuleInstanceState(node) !== 1 /* Instantiated */) { + return; + } + // In case of variable declaration, node.parent is variable statement so look at the variable statement's parent + var parent = getDeclarationContainer(node); + if (parent.kind === 248 /* SourceFile */ && ts.isExternalModule(parent)) { + // If the declaration happens to be in external module, report error that require and exports are reserved keywords + error(name, ts.Diagnostics.Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module, ts.declarationNameToString(name), ts.declarationNameToString(name)); + } + } + function checkVarDeclaredNamesNotShadowed(node) { + // - ScriptBody : StatementList + // It is a Syntax Error if any element of the LexicallyDeclaredNames of StatementList + // also occurs in the VarDeclaredNames of StatementList. + // - Block : { StatementList } + // It is a Syntax Error if any element of the LexicallyDeclaredNames of StatementList + // also occurs in the VarDeclaredNames of StatementList. + // Variable declarations are hoisted to the top of their function scope. They can shadow + // block scoped declarations, which bind tighter. this will not be flagged as duplicate definition + // by the binder as the declaration scope is different. + // A non-initialized declaration is a no-op as the block declaration will resolve before the var + // declaration. the problem is if the declaration has an initializer. this will act as a write to the + // block declared value. this is fine for let, but not const. + // Only consider declarations with initializers, uninitialized let declarations will not + // step on a let/const variable. + // Do not consider let and const declarations, as duplicate block-scoped declarations + // are handled by the binder. + // We are only looking for let declarations that step on let\const declarations from a + // different scope. e.g.: + // { + // const x = 0; // localDeclarationSymbol obtained after name resolution will correspond to this declaration + // let x = 0; // symbol for this declaration will be 'symbol' + // } + // skip block-scoped variables and parameters + if ((ts.getCombinedNodeFlags(node) & 49152 /* BlockScoped */) !== 0 || ts.isParameterDeclaration(node)) { + return; + } + // 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 === 211 /* VariableDeclaration */ && !node.initializer) { + return; + } + var symbol = getSymbolOfNode(node); + if (symbol.flags & 1 /* FunctionScopedVariable */) { + var localDeclarationSymbol = resolveName(node, node.name.text, 3 /* Variable */, /*nodeNotFoundErrorMessage*/ undefined, /*nameArg*/ undefined); + if (localDeclarationSymbol && + localDeclarationSymbol !== symbol && + localDeclarationSymbol.flags & 2 /* BlockScopedVariable */) { + if (getDeclarationFlagsFromSymbol(localDeclarationSymbol) & 49152 /* BlockScoped */) { + var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 212 /* VariableDeclarationList */); + var container = varDeclList.parent.kind === 193 /* VariableStatement */ && varDeclList.parent.parent + ? varDeclList.parent.parent + : undefined; + // names of block-scoped and function scoped variables can collide only + // if block scoped variable is defined in the function\module\source file scope (because of variable hoisting) + var namesShareScope = container && + (container.kind === 192 /* Block */ && ts.isFunctionLike(container.parent) || + container.kind === 219 /* ModuleBlock */ || + container.kind === 218 /* ModuleDeclaration */ || + container.kind === 248 /* SourceFile */); + // here we know that function scoped variable is shadowed by block scoped one + // if they are defined in the same scope - binder has already reported redeclaration error + // otherwise if variable has an initializer - show error that initialization will fail + // since LHS will be block scoped name instead of function scoped + if (!namesShareScope) { + var name_14 = symbolToString(localDeclarationSymbol); + error(node, ts.Diagnostics.Cannot_initialize_outer_scoped_variable_0_in_the_same_scope_as_block_scoped_declaration_1, name_14, name_14); + } + } + } + } + } + // Check that a parameter initializer contains no references to parameters declared to the right of itself + function checkParameterInitializer(node) { + if (ts.getRootDeclaration(node).kind !== 138 /* Parameter */) { + return; + } + var func = ts.getContainingFunction(node); + visit(node.initializer); + function visit(n) { + if (n.kind === 69 /* Identifier */) { + var referencedSymbol = getNodeLinks(n).resolvedSymbol; + // check FunctionLikeDeclaration.locals (stores parameters\function local variable) + // if it contains entry with a specified name and if this entry matches the resolved symbol + if (referencedSymbol && referencedSymbol !== unknownSymbol && getSymbol(func.locals, referencedSymbol.name, 107455 /* Value */) === referencedSymbol) { + if (referencedSymbol.valueDeclaration.kind === 138 /* Parameter */) { + if (referencedSymbol.valueDeclaration === node) { + error(n, ts.Diagnostics.Parameter_0_cannot_be_referenced_in_its_initializer, ts.declarationNameToString(node.name)); + return; + } + if (referencedSymbol.valueDeclaration.pos < node.pos) { + // legal case - parameter initializer references some parameter strictly on left of current parameter declaration + return; + } + } + error(n, ts.Diagnostics.Initializer_of_parameter_0_cannot_reference_identifier_1_declared_after_it, ts.declarationNameToString(node.name), ts.declarationNameToString(n)); + } + } + else { + ts.forEachChild(n, visit); + } + } + } + // Check variable, parameter, or property declaration + function checkVariableLikeDeclaration(node) { + checkDecorators(node); + checkSourceElement(node.type); + // For a computed property, just check the initializer and exit + // 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 === 136 /* ComputedPropertyName */) { + checkComputedPropertyName(node.name); + if (node.initializer) { + checkExpressionCached(node.initializer); + } + } + // For a binding pattern, check contained binding elements + if (ts.isBindingPattern(node.name)) { + 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 === 138 /* Parameter */ && ts.nodeIsMissing(ts.getContainingFunction(node).body)) { + error(node, ts.Diagnostics.A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation); + return; + } + // For a binding pattern, validate the initializer and exit + if (ts.isBindingPattern(node.name)) { + if (node.initializer) { + checkTypeAssignableTo(checkExpressionCached(node.initializer), getWidenedTypeForVariableLikeDeclaration(node), node, /*headMessage*/ undefined); + checkParameterInitializer(node); + } + return; + } + var symbol = getSymbolOfNode(node); + var type = getTypeOfVariableOrParameterOrProperty(symbol); + if (node === symbol.valueDeclaration) { + // Node is the primary declaration of the symbol, just validate the initializer + if (node.initializer) { + checkTypeAssignableTo(checkExpressionCached(node.initializer), type, node, /*headMessage*/ undefined); + checkParameterInitializer(node); + } + } + 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); + 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)); + } + if (node.initializer) { + checkTypeAssignableTo(checkExpressionCached(node.initializer), declarationType, node, /*headMessage*/ undefined); + } + } + if (node.kind !== 141 /* PropertyDeclaration */ && node.kind !== 140 /* PropertySignature */) { + // We know we don't have a binding pattern or computed name here + checkExportsOnMergedDeclarations(node); + if (node.kind === 211 /* VariableDeclaration */ || node.kind === 163 /* BindingElement */) { + checkVarDeclaredNamesNotShadowed(node); + } + checkCollisionWithCapturedSuperVariable(node, node.name); + checkCollisionWithCapturedThisVariable(node, node.name); + checkCollisionWithRequireExportsInGeneratedCode(node, node.name); + } + } + function checkVariableDeclaration(node) { + checkGrammarVariableDeclaration(node); + return checkVariableLikeDeclaration(node); + } + function checkBindingElement(node) { + checkGrammarBindingElement(node); + return checkVariableLikeDeclaration(node); + } + function checkVariableStatement(node) { + // Grammar checking + checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarVariableDeclarationList(node.declarationList) || checkGrammarForDisallowedLetOrConstStatement(node); + ts.forEach(node.declarationList.declarations, checkSourceElement); + } + 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 === 165 /* ObjectLiteralExpression */) { + if (ts.isAsyncFunctionLike(node)) { + if (node.modifiers.length > 1) { + return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); + } + } + else { + return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); + } + } + } + function checkExpressionStatement(node) { + // Grammar checking + checkGrammarStatementInAmbientContext(node); + checkExpression(node.expression); + } + function checkIfStatement(node) { + // Grammar checking + checkGrammarStatementInAmbientContext(node); + checkExpression(node.expression); + checkSourceElement(node.thenStatement); + checkSourceElement(node.elseStatement); + } + function checkDoStatement(node) { + // Grammar checking + checkGrammarStatementInAmbientContext(node); + checkSourceElement(node.statement); + checkExpression(node.expression); + } + function checkWhileStatement(node) { + // Grammar checking + checkGrammarStatementInAmbientContext(node); + checkExpression(node.expression); + checkSourceElement(node.statement); + } + function checkForStatement(node) { + // Grammar checking + if (!checkGrammarStatementInAmbientContext(node)) { + if (node.initializer && node.initializer.kind === 212 /* VariableDeclarationList */) { + checkGrammarVariableDeclarationList(node.initializer); + } + } + if (node.initializer) { + if (node.initializer.kind === 212 /* VariableDeclarationList */) { + ts.forEach(node.initializer.declarations, checkVariableDeclaration); + } + else { + checkExpression(node.initializer); + } + } + if (node.condition) + checkExpression(node.condition); + if (node.incrementor) + checkExpression(node.incrementor); + checkSourceElement(node.statement); + } + function checkForOfStatement(node) { + checkGrammarForInOrForOfStatement(node); + // Check the LHS and RHS + // If the LHS is a declaration, just check it as a variable declaration, which will in turn check the RHS + // 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 === 212 /* VariableDeclarationList */) { + checkForInOrForOfVariableDeclaration(node); + } + else { + var varExpr = node.initializer; + var iteratedType = checkRightHandSideOfForOf(node.expression); + // There may be a destructuring assignment on the left side + if (varExpr.kind === 164 /* ArrayLiteralExpression */ || varExpr.kind === 165 /* ObjectLiteralExpression */) { + // iteratedType may be undefined. In this case, we still want to check the structure of + // varExpr, in particular making sure it's a valid LeftHandSideExpression. But we'd like + // to short circuit the type relation checking as much as possible, so we pass the unknownType. + checkDestructuringAssignment(varExpr, iteratedType || unknownType); + } + else { + var leftType = checkExpression(varExpr); + checkReferenceExpression(varExpr, /*invalidReferenceMessage*/ ts.Diagnostics.Invalid_left_hand_side_in_for_of_statement, + /*constantVariableMessage*/ ts.Diagnostics.The_left_hand_side_of_a_for_of_statement_cannot_be_a_previously_defined_constant); + // iteratedType will be undefined if the rightType was missing properties/signatures + // required to get its iteratedType (like [Symbol.iterator] or next). This may be + // because we accessed properties from anyType, or it may have led to an error inside + // getElementTypeOfIterable. + if (iteratedType) { + checkTypeAssignableTo(iteratedType, leftType, varExpr, /*headMessage*/ undefined); + } + } + } + checkSourceElement(node.statement); + } + function checkForInStatement(node) { + // Grammar checking + checkGrammarForInOrForOfStatement(node); + // TypeScript 1.0 spec (April 2014): 5.4 + // In a 'for-in' statement of the form + // 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 === 212 /* VariableDeclarationList */) { + var variable = node.initializer.declarations[0]; + if (variable && ts.isBindingPattern(variable.name)) { + error(variable.name, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern); + } + checkForInOrForOfVariableDeclaration(node); + } + else { + // In a 'for-in' statement of the form + // for (Var in Expr) Statement + // Var must be an expression classified as a reference of type Any or the String primitive type, + // 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 === 164 /* ArrayLiteralExpression */ || varExpr.kind === 165 /* ObjectLiteralExpression */) { + error(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern); + } + else if (!isTypeAnyOrAllConstituentTypesHaveKind(leftType, 258 /* StringLike */)) { + error(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_must_be_of_type_string_or_any); + } + else { + // run check only former check succeeded to avoid cascading errors + checkReferenceExpression(varExpr, ts.Diagnostics.Invalid_left_hand_side_in_for_in_statement, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_previously_defined_constant); + } + } + var rightType = checkExpression(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, 80896 /* ObjectType */ | 512 /* TypeParameter */)) { + error(node.expression, ts.Diagnostics.The_right_hand_side_of_a_for_in_statement_must_be_of_type_any_an_object_type_or_a_type_parameter); + } + checkSourceElement(node.statement); + } + function checkForInOrForOfVariableDeclaration(iterationStatement) { + var variableDeclarationList = iterationStatement.initializer; + // checkGrammarForInOrForOfStatement will check that there is exactly one declaration. + if (variableDeclarationList.declarations.length >= 1) { + var decl = variableDeclarationList.declarations[0]; + checkVariableDeclaration(decl); + } + } + function checkRightHandSideOfForOf(rhsExpression) { + var expressionType = getTypeOfExpression(rhsExpression); + return checkIteratedTypeOrElementType(expressionType, rhsExpression, /*allowStringInput*/ true); + } + function checkIteratedTypeOrElementType(inputType, errorNode, allowStringInput) { + if (isTypeAny(inputType)) { + return inputType; + } + if (languageVersion >= 2 /* ES6 */) { + return checkElementTypeOfIterable(inputType, errorNode); + } + if (allowStringInput) { + return checkElementTypeOfArrayOrString(inputType, errorNode); + } + if (isArrayLikeType(inputType)) { + var indexType = getIndexTypeOfType(inputType, 1 /* Number */); + if (indexType) { + return indexType; + } + } + error(errorNode, ts.Diagnostics.Type_0_is_not_an_array_type, typeToString(inputType)); + return unknownType; + } + /** + * When errorNode is undefined, it means we should not report any errors. + */ + function checkElementTypeOfIterable(iterable, errorNode) { + var elementType = getElementTypeOfIterable(iterable, errorNode); + // Now even though we have extracted the iteratedType, we will have to validate that the type + // passed in is actually an Iterable. + if (errorNode && elementType) { + checkTypeAssignableTo(iterable, createIterableType(elementType), errorNode); + } + return elementType || anyType; + } + /** + * We want to treat type as an iterable, and get the type it is an iterable of. The iterable + * must have the following structure (annotated with the names of the variables below): + * + * { // iterable + * [Symbol.iterator]: { // iteratorFunction + * (): Iterator + * } + * } + * + * T is the type we are after. At every level that involves analyzing return types + * of signatures, we union the return types of all the signatures. + * + * Another thing to note is that at any step of this process, we could run into a dead end, + * meaning either the property is missing, or we run into the anyType. If either of these things + * happens, we return undefined to signal that we could not find the iterated type. If a property + * is missing, and the previous step did not result in 'any', then we also give an error if the + * caller requested it. Then the caller can decide what to do in the case where there is no iterated + * type. This is different from returning anyType, because that would signify that we have matched the + * whole pattern and that T (above) is 'any'. + */ + function getElementTypeOfIterable(type, errorNode) { + if (isTypeAny(type)) { + return undefined; + } + var typeAsIterable = type; + 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 & 4096 /* Reference */) && type.target === globalIterableType) { + typeAsIterable.iterableElementType = type.typeArguments[0]; + } + else { + var iteratorFunction = getTypeOfPropertyOfType(type, ts.getPropertyNameForKnownSymbolName("iterator")); + if (isTypeAny(iteratorFunction)) { + return undefined; + } + var iteratorFunctionSignatures = iteratorFunction ? getSignaturesOfType(iteratorFunction, 0 /* Call */) : emptyArray; + if (iteratorFunctionSignatures.length === 0) { + if (errorNode) { + error(errorNode, ts.Diagnostics.Type_must_have_a_Symbol_iterator_method_that_returns_an_iterator); + } + return undefined; + } + typeAsIterable.iterableElementType = getElementTypeOfIterator(getUnionType(ts.map(iteratorFunctionSignatures, getReturnTypeOfSignature)), errorNode); + } + } + return typeAsIterable.iterableElementType; + } + /** + * This function has very similar logic as getElementTypeOfIterable, except that it operates on + * Iterators instead of Iterables. Here is the structure: + * + * { // iterator + * next: { // iteratorNextFunction + * (): { // iteratorNextResult + * value: T // iteratorNextValue + * } + * } + * } + * + */ + function getElementTypeOfIterator(type, errorNode) { + if (isTypeAny(type)) { + return undefined; + } + var typeAsIterator = type; + 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 & 4096 /* Reference */) && type.target === globalIteratorType) { + typeAsIterator.iteratorElementType = type.typeArguments[0]; + } + else { + var iteratorNextFunction = getTypeOfPropertyOfType(type, "next"); + if (isTypeAny(iteratorNextFunction)) { + return undefined; + } + var iteratorNextFunctionSignatures = iteratorNextFunction ? getSignaturesOfType(iteratorNextFunction, 0 /* Call */) : emptyArray; + if (iteratorNextFunctionSignatures.length === 0) { + if (errorNode) { + error(errorNode, ts.Diagnostics.An_iterator_must_have_a_next_method); + } + return undefined; + } + var iteratorNextResult = getUnionType(ts.map(iteratorNextFunctionSignatures, getReturnTypeOfSignature)); + if (isTypeAny(iteratorNextResult)) { + return undefined; + } + var iteratorNextValue = getTypeOfPropertyOfType(iteratorNextResult, "value"); + if (!iteratorNextValue) { + if (errorNode) { + error(errorNode, ts.Diagnostics.The_type_returned_by_the_next_method_of_an_iterator_must_have_a_value_property); + } + return undefined; + } + typeAsIterator.iteratorElementType = iteratorNextValue; + } + } + return typeAsIterator.iteratorElementType; + } + function getElementTypeOfIterableIterator(type) { + if (isTypeAny(type)) { + return undefined; + } + // As an optimization, if the type is instantiated directly using the globalIterableIteratorType (IterableIterator), + // then just grab its type argument. + if ((type.flags & 4096 /* Reference */) && type.target === globalIterableIteratorType) { + return type.typeArguments[0]; + } + return getElementTypeOfIterable(type, /*errorNode*/ undefined) || + getElementTypeOfIterator(type, /*errorNode*/ undefined); + } + /** + * This function does the following steps: + * 1. Break up arrayOrStringType (possibly a union) into its string constituents and array constituents. + * 2. Take the element types of the array constituents. + * 3. Return the union of the element types, and string if there was a string constitutent. + * + * For example: + * string -> string + * number[] -> number + * string[] | number[] -> string | number + * string | number[] -> string | number + * string | string[] | number[] -> string | number + * + * It also errors if: + * 1. Some constituent is neither a string nor an array. + * 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 */); + // 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 = removeTypesFromUnionType(arrayOrStringType, 258 /* StringLike */, /*isTypeOfKind*/ true, /*allowEmptyUnionResult*/ true); + var hasStringConstituent = arrayOrStringType !== arrayType; + var reportedError = false; + if (hasStringConstituent) { + if (languageVersion < 1 /* ES5 */) { + error(errorNode, ts.Diagnostics.Using_a_string_in_a_for_of_statement_is_only_supported_in_ECMAScript_5_and_higher); + reportedError = true; + } + // Now that we've removed all the StringLike types, if no constituents remain, then the entire + // arrayOrStringType was a string. + if (arrayType === emptyObjectType) { + return stringType; + } + } + if (!isArrayLikeType(arrayType)) { + if (!reportedError) { + // Which error we report depends on whether there was a string constituent. For example, + // if the input type is number | string, we want to say that number is not an array type. + // But if the input was just number, we want to say that number is not an array type + // or a string type. + var diagnostic = hasStringConstituent + ? ts.Diagnostics.Type_0_is_not_an_array_type + : ts.Diagnostics.Type_0_is_not_an_array_type_or_a_string_type; + error(errorNode, diagnostic, typeToString(arrayType)); + } + return hasStringConstituent ? stringType : unknownType; + } + var arrayElementType = getIndexTypeOfType(arrayType, 1 /* Number */) || unknownType; + if (hasStringConstituent) { + // This is just an optimization for the case where arrayOrStringType is string | string[] + if (arrayElementType.flags & 258 /* StringLike */) { + return stringType; + } + return getUnionType([arrayElementType, stringType]); + } + return arrayElementType; + } + function checkBreakOrContinueStatement(node) { + // Grammar checking + checkGrammarStatementInAmbientContext(node) || checkGrammarBreakOrContinueStatement(node); + // TODO: Check that target label is valid + } + function isGetAccessorWithAnnotatatedSetAccessor(node) { + return !!(node.kind === 145 /* GetAccessor */ && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(node.symbol, 146 /* SetAccessor */))); + } + function checkReturnStatement(node) { + // Grammar checking + if (!checkGrammarStatementInAmbientContext(node)) { + var functionBlock = ts.getContainingFunction(node); + if (!functionBlock) { + grammarErrorOnFirstToken(node, ts.Diagnostics.A_return_statement_can_only_be_used_within_a_function_body); + } + } + if (node.expression) { + var func = ts.getContainingFunction(node); + if (func) { + var signature = getSignatureFromDeclaration(func); + var returnType = getReturnTypeOfSignature(signature); + var exprType = checkExpressionCached(node.expression); + if (func.asteriskToken) { + // A generator does not need its return expressions checked against its return type. + // Instead, the yield expressions are checked against the element type. + // TODO: Check return expressions of generators when return type tracking is added + // for generators. + return; + } + if (func.kind === 146 /* SetAccessor */) { + error(node.expression, ts.Diagnostics.Setters_cannot_return_a_value); + } + else if (func.kind === 144 /* Constructor */) { + if (!isTypeAssignableTo(exprType, returnType)) { + error(node.expression, ts.Diagnostics.Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class); + } + } + else if (func.type || isGetAccessorWithAnnotatatedSetAccessor(func) || signature.typePredicate) { + if (ts.isAsyncFunctionLike(func)) { + var promisedType = getPromisedType(returnType); + var awaitedType = checkAwaitedType(exprType, node.expression, ts.Diagnostics.Return_expression_in_async_function_does_not_have_a_valid_callable_then_member); + if (promisedType) { + // If the function has a return type, but promisedType is + // undefined, an error will be reported in checkAsyncFunctionReturnType + // so we don't need to report one here. + checkTypeAssignableTo(awaitedType, promisedType, node.expression); + } + } + else { + checkTypeAssignableTo(exprType, returnType, node.expression); + } + } + } + } + } + function checkWithStatement(node) { + // Grammar checking for withStatement + if (!checkGrammarStatementInAmbientContext(node)) { + if (node.parserContextFlags & 8 /* Await */) { + grammarErrorOnFirstToken(node, ts.Diagnostics.with_statements_are_not_allowed_in_an_async_function_block); + } + } + checkExpression(node.expression); + error(node.expression, ts.Diagnostics.All_symbols_within_a_with_block_will_be_resolved_to_any); + } + function checkSwitchStatement(node) { + // Grammar checking + checkGrammarStatementInAmbientContext(node); + var firstDefaultClause; + var hasDuplicateDefaultClause = false; + var expressionType = checkExpression(node.expression); + ts.forEach(node.caseBlock.clauses, function (clause) { + // Grammar check for duplicate default clauses, skip if we already report duplicate default clause + if (clause.kind === 242 /* DefaultClause */ && !hasDuplicateDefaultClause) { + if (firstDefaultClause === undefined) { + firstDefaultClause = clause; + } + else { + var sourceFile = ts.getSourceFileOfNode(node); + var start = ts.skipTrivia(sourceFile.text, clause.pos); + var end = clause.statements.length > 0 ? clause.statements[0].pos : clause.end; + grammarErrorAtPos(sourceFile, start, end - start, ts.Diagnostics.A_default_clause_cannot_appear_more_than_once_in_a_switch_statement); + hasDuplicateDefaultClause = true; + } + } + if (produceDiagnostics && clause.kind === 241 /* CaseClause */) { + var caseClause = clause; + // TypeScript 1.0 spec (April 2014):5.9 + // In a 'switch' statement, each 'case' expression must be of a type that is assignable to or from the type of the 'switch' expression. + var caseType = checkExpression(caseClause.expression); + if (!isTypeAssignableTo(expressionType, caseType)) { + // check 'expressionType isAssignableTo caseType' failed, try the reversed check and report errors if it fails + checkTypeAssignableTo(caseType, expressionType, caseClause.expression, /*headMessage*/ undefined); + } + } + ts.forEach(clause.statements, checkSourceElement); + }); + } + function checkLabeledStatement(node) { + // Grammar checking + if (!checkGrammarStatementInAmbientContext(node)) { + var current = node.parent; + while (current) { + if (ts.isFunctionLike(current)) { + break; + } + if (current.kind === 207 /* LabeledStatement */ && current.label.text === node.label.text) { + var sourceFile = ts.getSourceFileOfNode(node); + grammarErrorOnNode(node.label, ts.Diagnostics.Duplicate_label_0, ts.getTextOfNodeFromSourceText(sourceFile.text, node.label)); + break; + } + current = current.parent; + } + } + // ensure that label is unique + checkSourceElement(node.statement); + } + function checkThrowStatement(node) { + // Grammar checking + if (!checkGrammarStatementInAmbientContext(node)) { + if (node.expression === undefined) { + grammarErrorAfterFirstToken(node, ts.Diagnostics.Line_break_not_permitted_here); + } + } + if (node.expression) { + checkExpression(node.expression); + } + } + function checkTryStatement(node) { + // Grammar checking + checkGrammarStatementInAmbientContext(node); + checkBlock(node.tryBlock); + var catchClause = node.catchClause; + if (catchClause) { + // Grammar checking + if (catchClause.variableDeclaration) { + if (catchClause.variableDeclaration.name.kind !== 69 /* Identifier */) { + grammarErrorOnFirstToken(catchClause.variableDeclaration.name, ts.Diagnostics.Catch_clause_variable_name_must_be_an_identifier); + } + else if (catchClause.variableDeclaration.type) { + grammarErrorOnFirstToken(catchClause.variableDeclaration.type, ts.Diagnostics.Catch_clause_variable_cannot_have_a_type_annotation); + } + else if (catchClause.variableDeclaration.initializer) { + grammarErrorOnFirstToken(catchClause.variableDeclaration.initializer, ts.Diagnostics.Catch_clause_variable_cannot_have_an_initializer); + } + else { + var identifierName = catchClause.variableDeclaration.name.text; + var locals = catchClause.block.locals; + if (locals && ts.hasProperty(locals, identifierName)) { + var localSymbol = locals[identifierName]; + if (localSymbol && (localSymbol.flags & 2 /* BlockScopedVariable */) !== 0) { + grammarErrorOnNode(localSymbol.valueDeclaration, ts.Diagnostics.Cannot_redeclare_identifier_0_in_catch_clause, identifierName); + } + } + } + } + checkBlock(catchClause.block); + } + if (node.finallyBlock) { + checkBlock(node.finallyBlock); + } + } + function checkIndexConstraints(type) { + var declaredNumberIndexer = getIndexDeclarationOfSymbol(type.symbol, 1 /* Number */); + var declaredStringIndexer = getIndexDeclarationOfSymbol(type.symbol, 0 /* String */); + var stringIndexType = getIndexTypeOfType(type, 0 /* String */); + var numberIndexType = getIndexTypeOfType(type, 1 /* Number */); + if (stringIndexType || numberIndexType) { + ts.forEach(getPropertiesOfObjectType(type), function (prop) { + var propType = getTypeOfSymbol(prop); + checkIndexConstraintForProperty(prop, propType, type, declaredStringIndexer, stringIndexType, 0 /* String */); + checkIndexConstraintForProperty(prop, propType, type, declaredNumberIndexer, numberIndexType, 1 /* Number */); + }); + if (type.flags & 1024 /* Class */ && ts.isClassLike(type.symbol.valueDeclaration)) { + var classDeclaration = type.symbol.valueDeclaration; + for (var _i = 0, _a = classDeclaration.members; _i < _a.length; _i++) { + var member = _a[_i]; + // Only process instance properties with computed names here. + // Static properties cannot be in conflict with indexers, + // and properties with literal names were already checked. + if (!(member.flags & 128 /* Static */) && ts.hasDynamicName(member)) { + var propType = getTypeOfSymbol(member.symbol); + checkIndexConstraintForProperty(member.symbol, propType, type, declaredStringIndexer, stringIndexType, 0 /* String */); + checkIndexConstraintForProperty(member.symbol, propType, type, declaredNumberIndexer, numberIndexType, 1 /* Number */); + } + } + } + } + var errorNode; + 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 & 2048 /* Interface */)) { + var someBaseTypeHasBothIndexers = ts.forEach(getBaseTypes(type), function (base) { return getIndexTypeOfType(base, 0 /* String */) && getIndexTypeOfType(base, 1 /* Number */); }); + errorNode = someBaseTypeHasBothIndexers ? undefined : type.symbol.declarations[0]; + } + } + if (errorNode && !isTypeAssignableTo(numberIndexType, stringIndexType)) { + error(errorNode, ts.Diagnostics.Numeric_index_type_0_is_not_assignable_to_string_index_type_1, typeToString(numberIndexType), typeToString(stringIndexType)); + } + function checkIndexConstraintForProperty(prop, propertyType, containingType, indexDeclaration, indexType, indexKind) { + if (!indexType) { + return; + } + // index is numeric and property name is not valid numeric literal + if (indexKind === 1 /* Number */ && !isNumericName(prop.valueDeclaration.name)) { + return; + } + // 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 === 136 /* ComputedPropertyName */ || prop.parent === containingType.symbol) { + errorNode = prop.valueDeclaration; + } + else if (indexDeclaration) { + errorNode = indexDeclaration; + } + else if (containingType.flags & 2048 /* 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 + var someBaseClassHasBothPropertyAndIndexer = ts.forEach(getBaseTypes(containingType), function (base) { return getPropertyOfObjectType(base, prop.name) && getIndexTypeOfType(base, indexKind); }); + errorNode = someBaseClassHasBothPropertyAndIndexer ? undefined : containingType.symbol.declarations[0]; + } + if (errorNode && !isTypeAssignableTo(propertyType, indexType)) { + var errorMessage = indexKind === 0 /* String */ + ? ts.Diagnostics.Property_0_of_type_1_is_not_assignable_to_string_index_type_2 + : ts.Diagnostics.Property_0_of_type_1_is_not_assignable_to_numeric_index_type_2; + error(errorNode, errorMessage, symbolToString(prop), typeToString(propertyType), typeToString(indexType)); + } + } + } + function checkTypeNameIsReserved(name, message) { + // TS 1.0 spec (April 2014): 3.6.1 + // The predefined type keywords are reserved and cannot be used as names of user defined types. + switch (name.text) { + case "any": + case "number": + case "boolean": + case "string": + case "symbol": + case "void": + error(name, message, name.text); + } + } + // Check each type parameter and check that list has no duplicate type parameter declarations + function checkTypeParameters(typeParameterDeclarations) { + if (typeParameterDeclarations) { + for (var i = 0, n = typeParameterDeclarations.length; i < n; i++) { + var node = typeParameterDeclarations[i]; + checkTypeParameter(node); + if (produceDiagnostics) { + for (var j = 0; j < i; j++) { + if (typeParameterDeclarations[j].symbol === node.symbol) { + error(node.name, ts.Diagnostics.Duplicate_identifier_0, ts.declarationNameToString(node.name)); + } + } + } + } + } + } + function checkClassExpression(node) { + checkClassLikeDeclaration(node); + return getTypeOfSymbol(getSymbolOfNode(node)); + } + function checkClassDeclaration(node) { + if (!node.name && !(node.flags & 1024 /* Default */)) { + grammarErrorOnFirstToken(node, ts.Diagnostics.A_class_declaration_without_the_default_modifier_must_have_a_name); + } + checkClassLikeDeclaration(node); + ts.forEach(node.members, checkSourceElement); + } + function checkClassLikeDeclaration(node) { + checkGrammarClassDeclarationHeritageClauses(node); + checkDecorators(node); + if (node.name) { + checkTypeNameIsReserved(node.name, ts.Diagnostics.Class_name_cannot_be_0); + checkCollisionWithCapturedThisVariable(node, node.name); + checkCollisionWithRequireExportsInGeneratedCode(node, node.name); + } + checkTypeParameters(node.typeParameters); + checkExportsOnMergedDeclarations(node); + var symbol = getSymbolOfNode(node); + var type = getDeclaredTypeOfSymbol(symbol); + var typeWithThis = getTypeWithThisArgument(type); + var staticType = getTypeOfSymbol(symbol); + var baseTypeNode = ts.getClassExtendsHeritageClauseElement(node); + if (baseTypeNode) { + emitExtends = emitExtends || !ts.isInAmbientContext(node); + var baseTypes = getBaseTypes(type); + if (baseTypes.length && produceDiagnostics) { + var baseType = baseTypes[0]; + var staticBaseType = getBaseConstructorTypeOfClass(type); + checkSourceElement(baseTypeNode.expression); + if (baseTypeNode.typeArguments) { + ts.forEach(baseTypeNode.typeArguments, checkSourceElement); + for (var _i = 0, _a = getConstructorsForTypeArguments(staticBaseType, baseTypeNode.typeArguments); _i < _a.length; _i++) { + var constructor = _a[_i]; + if (!checkTypeArgumentConstraints(constructor.typeParameters, baseTypeNode.typeArguments)) { + break; + } + } + } + checkTypeAssignableTo(typeWithThis, getTypeWithThisArgument(baseType, type.thisType), node.name || node, ts.Diagnostics.Class_0_incorrectly_extends_base_class_1); + checkTypeAssignableTo(staticType, getTypeWithoutSignatures(staticBaseType), node.name || node, ts.Diagnostics.Class_static_side_0_incorrectly_extends_base_class_static_side_1); + if (!(staticBaseType.symbol && staticBaseType.symbol.flags & 32 /* Class */)) { + // When the static base type is a "class-like" constructor function (but not actually a class), we verify + // that all instantiated base constructor signatures return the same type. We can simply compare the type + // references (as opposed to checking the structure of the types) because elsewhere we have already checked + // that the base type is a class or interface type (and not, for example, an anonymous object type). + var constructors = getInstantiatedConstructorsForTypeArguments(staticBaseType, baseTypeNode.typeArguments); + if (ts.forEach(constructors, function (sig) { return getReturnTypeOfSignature(sig) !== baseType; })) { + error(baseTypeNode.expression, ts.Diagnostics.Base_constructors_must_all_have_the_same_return_type); + } + } + checkKindsOfPropertyMemberOverrides(type, baseType); + } + } + var implementedTypeNodes = ts.getClassImplementsHeritageClauseElements(node); + if (implementedTypeNodes) { + for (var _b = 0; _b < implementedTypeNodes.length; _b++) { + var typeRefNode = implementedTypeNodes[_b]; + if (!ts.isSupportedExpressionWithTypeArguments(typeRefNode)) { + error(typeRefNode.expression, ts.Diagnostics.A_class_can_only_implement_an_identifier_Slashqualified_name_with_optional_type_arguments); + } + checkTypeReferenceNode(typeRefNode); + if (produceDiagnostics) { + var t = getTypeFromTypeNode(typeRefNode); + if (t !== unknownType) { + var declaredType = (t.flags & 4096 /* Reference */) ? t.target : t; + if (declaredType.flags & (1024 /* Class */ | 2048 /* Interface */)) { + checkTypeAssignableTo(typeWithThis, getTypeWithThisArgument(t, type.thisType), node.name || node, ts.Diagnostics.Class_0_incorrectly_implements_interface_1); + } + else { + error(typeRefNode, ts.Diagnostics.A_class_may_only_implement_another_class_or_interface); + } + } + } + } + } + if (produceDiagnostics) { + checkIndexConstraints(type); + checkTypeForDuplicateIndexSignatures(node); + } + } + function getTargetSymbol(s) { + // if symbol is instantiated its flags are not copied from the 'target' + // so we'll need to get back original 'target' symbol to work with correct set of flags + return s.flags & 16777216 /* Instantiated */ ? getSymbolLinks(s).target : s; + } + function getClassLikeDeclarationOfSymbol(symbol) { + return ts.forEach(symbol.declarations, function (d) { return ts.isClassLike(d) ? d : undefined; }); + } + function checkKindsOfPropertyMemberOverrides(type, baseType) { + // TypeScript 1.0 spec (April 2014): 8.2.3 + // A derived class inherits all members from its base class it doesn't override. + // Inheritance means that a derived class implicitly contains all non - overridden members of the base class. + // Both public and private property members are inherited, but only public property members can be overridden. + // A property member in a derived class is said to override a property member in a base class + // when the derived class property member has the same name and kind(instance or static) + // as the base class property member. + // The type of an overriding property member must be assignable(section 3.8.4) + // to the type of the overridden property member, or otherwise a compile - time error occurs. + // Base class instance member functions can be overridden by derived class instance member functions, + // but not by other kinds of members. + // Base class instance member variables and accessors can be overridden by + // derived class instance member variables and accessors, but not by other kinds of members. + // NOTE: assignability is checked in checkClassDeclaration + var baseProperties = getPropertiesOfObjectType(baseType); + for (var _i = 0; _i < baseProperties.length; _i++) { + var baseProperty = baseProperties[_i]; + var base = getTargetSymbol(baseProperty); + if (base.flags & 134217728 /* Prototype */) { + continue; + } + var derived = getTargetSymbol(getPropertyOfObjectType(type, base.name)); + var baseDeclarationFlags = getDeclarationFlagsFromSymbol(base); + ts.Debug.assert(!!derived, "derived should point to something, even if it is the base class' declaration."); + if (derived) { + // In order to resolve whether the inherited method was overriden in the base class or not, + // we compare the Symbols obtained. Since getTargetSymbol returns the symbol on the *uninstantiated* + // type declaration, derived and base resolve to the same symbol even in the case of generic classes. + if (derived === base) { + // derived class inherits base without override/redeclaration + var derivedClassDecl = getClassLikeDeclarationOfSymbol(type.symbol); + // It is an error to inherit an abstract member without implementing it or being declared abstract. + // If there is no declaration for the derived class (as in the case of class expressions), + // then the class cannot be declared abstract. + if (baseDeclarationFlags & 256 /* Abstract */ && (!derivedClassDecl || !(derivedClassDecl.flags & 256 /* Abstract */))) { + if (derivedClassDecl.kind === 186 /* ClassExpression */) { + error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1, symbolToString(baseProperty), typeToString(baseType)); + } + else { + error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_0_does_not_implement_inherited_abstract_member_1_from_class_2, typeToString(type), symbolToString(baseProperty), typeToString(baseType)); + } + } + } + else { + // derived overrides base. + var derivedDeclarationFlags = getDeclarationFlagsFromSymbol(derived); + if ((baseDeclarationFlags & 32 /* Private */) || (derivedDeclarationFlags & 32 /* Private */)) { + // either base or derived property is private - not override, skip it + continue; + } + if ((baseDeclarationFlags & 128 /* Static */) !== (derivedDeclarationFlags & 128 /* Static */)) { + // value of 'static' is not the same for properties - not override, skip it + continue; + } + if ((base.flags & derived.flags & 8192 /* Method */) || ((base.flags & 98308 /* PropertyOrAccessor */) && (derived.flags & 98308 /* PropertyOrAccessor */))) { + // method is overridden with method or property/accessor is overridden with property/accessor - correct case + continue; + } + var errorMessage = void 0; + if (base.flags & 8192 /* Method */) { + if (derived.flags & 98304 /* Accessor */) { + errorMessage = ts.Diagnostics.Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_accessor; + } + else { + ts.Debug.assert((derived.flags & 4 /* Property */) !== 0); + errorMessage = ts.Diagnostics.Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_property; + } + } + else if (base.flags & 4 /* Property */) { + ts.Debug.assert((derived.flags & 8192 /* Method */) !== 0); + errorMessage = ts.Diagnostics.Class_0_defines_instance_member_property_1_but_extended_class_2_defines_it_as_instance_member_function; + } + else { + ts.Debug.assert((base.flags & 98304 /* Accessor */) !== 0); + ts.Debug.assert((derived.flags & 8192 /* Method */) !== 0); + errorMessage = ts.Diagnostics.Class_0_defines_instance_member_accessor_1_but_extended_class_2_defines_it_as_instance_member_function; + } + error(derived.valueDeclaration.name, errorMessage, typeToString(baseType), symbolToString(base), typeToString(type)); + } + } + } + } + function isAccessor(kind) { + return kind === 145 /* GetAccessor */ || kind === 146 /* SetAccessor */; + } + function areTypeParametersIdentical(list1, list2) { + if (!list1 && !list2) { + return true; + } + if (!list1 || !list2 || list1.length !== list2.length) { + return false; + } + // TypeScript 1.0 spec (April 2014): + // When a generic interface has multiple declarations, all declarations must have identical type parameter + // lists, i.e. identical type parameter names with identical constraints in identical order. + for (var i = 0, len = list1.length; i < len; i++) { + var tp1 = list1[i]; + var tp2 = list2[i]; + if (tp1.name.text !== tp2.name.text) { + return false; + } + if (!tp1.constraint && !tp2.constraint) { + continue; + } + if (!tp1.constraint || !tp2.constraint) { + return false; + } + if (!isTypeIdenticalTo(getTypeFromTypeNode(tp1.constraint), getTypeFromTypeNode(tp2.constraint))) { + return false; + } + } + return true; + } + function checkInheritedPropertiesAreIdentical(type, typeNode) { + var baseTypes = getBaseTypes(type); + if (baseTypes.length < 2) { + return true; + } + var seen = {}; + ts.forEach(resolveDeclaredMembers(type).declaredProperties, function (p) { seen[p.name] = { prop: p, containingType: type }; }); + var ok = true; + for (var _i = 0; _i < baseTypes.length; _i++) { + var base = baseTypes[_i]; + var properties = getPropertiesOfObjectType(getTypeWithThisArgument(base, type.thisType)); + for (var _a = 0; _a < properties.length; _a++) { + var prop = properties[_a]; + if (!ts.hasProperty(seen, prop.name)) { + seen[prop.name] = { prop: prop, containingType: base }; + } + else { + var existing = seen[prop.name]; + var isInheritedProperty = existing.containingType !== type; + if (isInheritedProperty && !isPropertyIdenticalTo(existing.prop, prop)) { + ok = false; + var typeName1 = typeToString(existing.containingType); + var typeName2 = typeToString(base); + var errorInfo = ts.chainDiagnosticMessages(undefined, ts.Diagnostics.Named_property_0_of_types_1_and_2_are_not_identical, symbolToString(prop), typeName1, typeName2); + errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.Interface_0_cannot_simultaneously_extend_types_1_and_2, typeToString(type), typeName1, typeName2); + diagnostics.add(ts.createDiagnosticForNodeFromMessageChain(typeNode, errorInfo)); + } + } + } + } + return ok; + } + function checkInterfaceDeclaration(node) { + // Grammar checking + checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarInterfaceDeclaration(node); + checkTypeParameters(node.typeParameters); + if (produceDiagnostics) { + checkTypeNameIsReserved(node.name, ts.Diagnostics.Interface_name_cannot_be_0); + checkExportsOnMergedDeclarations(node); + var symbol = getSymbolOfNode(node); + var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 215 /* InterfaceDeclaration */); + if (symbol.declarations.length > 1) { + if (node !== firstInterfaceDecl && !areTypeParametersIdentical(firstInterfaceDecl.typeParameters, node.typeParameters)) { + error(node.name, ts.Diagnostics.All_declarations_of_an_interface_must_have_identical_type_parameters); + } + } + // Only check this symbol once + if (node === firstInterfaceDecl) { + var type = getDeclaredTypeOfSymbol(symbol); + var typeWithThis = getTypeWithThisArgument(type); + // run subsequent checks only if first set succeeded + if (checkInheritedPropertiesAreIdentical(type, node.name)) { + for (var _i = 0, _a = getBaseTypes(type); _i < _a.length; _i++) { + var baseType = _a[_i]; + checkTypeAssignableTo(typeWithThis, getTypeWithThisArgument(baseType, type.thisType), node.name, ts.Diagnostics.Interface_0_incorrectly_extends_interface_1); + } + checkIndexConstraints(type); + } + } + } + ts.forEach(ts.getInterfaceBaseTypeNodes(node), function (heritageElement) { + if (!ts.isSupportedExpressionWithTypeArguments(heritageElement)) { + error(heritageElement.expression, ts.Diagnostics.An_interface_can_only_extend_an_identifier_Slashqualified_name_with_optional_type_arguments); + } + checkTypeReferenceNode(heritageElement); + }); + ts.forEach(node.members, checkSourceElement); + if (produceDiagnostics) { + checkTypeForDuplicateIndexSignatures(node); + } + } + function checkTypeAliasDeclaration(node) { + // Grammar checking + checkGrammarDecorators(node) || checkGrammarModifiers(node); + checkTypeNameIsReserved(node.name, ts.Diagnostics.Type_alias_name_cannot_be_0); + checkSourceElement(node.type); + } + function computeEnumMemberValues(node) { + var nodeLinks = getNodeLinks(node); + if (!(nodeLinks.flags & 8192 /* EnumValuesComputed */)) { + var enumSymbol = getSymbolOfNode(node); + var enumType = getDeclaredTypeOfSymbol(enumSymbol); + var autoValue = 0; // set to undefined when enum member is non-constant + var ambient = ts.isInAmbientContext(node); + var enumIsConst = ts.isConst(node); + for (var _i = 0, _a = node.members; _i < _a.length; _i++) { + var member = _a[_i]; + if (member.name.kind === 136 /* ComputedPropertyName */) { + error(member.name, ts.Diagnostics.Computed_property_names_are_not_allowed_in_enums); + } + else if (isNumericLiteralName(member.name.text)) { + error(member.name, ts.Diagnostics.An_enum_member_cannot_have_a_numeric_name); + } + var previousEnumMemberIsNonConstant = autoValue === undefined; + var initializer = member.initializer; + if (initializer) { + autoValue = computeConstantValueForEnumMemberInitializer(initializer, enumType, enumIsConst, ambient); + } + else if (ambient && !enumIsConst) { + // In ambient enum declarations that specify no const modifier, enum member declarations + // that omit a value are considered computed members (as opposed to having auto-incremented values assigned). + autoValue = undefined; + } + else if (previousEnumMemberIsNonConstant) { + // If the member declaration specifies no value, the member is considered a constant enum member. + // If the member is the first member in the enum declaration, it is assigned the value zero. + // Otherwise, it is assigned the value of the immediately preceding member plus one, + // and an error occurs if the immediately preceding member is not a constant enum member + error(member.name, ts.Diagnostics.Enum_member_must_have_initializer); + } + if (autoValue !== undefined) { + getNodeLinks(member).enumMemberValue = autoValue++; + } + } + nodeLinks.flags |= 8192 /* EnumValuesComputed */; + } + function computeConstantValueForEnumMemberInitializer(initializer, enumType, enumIsConst, ambient) { + // Controls if error should be reported after evaluation of constant value is completed + // Can be false if another more precise error was already reported during evaluation. + var reportError = true; + var value = evalConstant(initializer); + if (reportError) { + if (value === undefined) { + if (enumIsConst) { + error(initializer, ts.Diagnostics.In_const_enum_declarations_member_initializer_must_be_constant_expression); + } + else if (ambient) { + error(initializer, ts.Diagnostics.In_ambient_enum_declarations_member_initializer_must_be_constant_expression); + } + else { + // Only here do we need to check that the initializer is assignable to the enum type. + checkTypeAssignableTo(checkExpression(initializer), enumType, initializer, /*headMessage*/ undefined); + } + } + else if (enumIsConst) { + if (isNaN(value)) { + error(initializer, ts.Diagnostics.const_enum_member_initializer_was_evaluated_to_disallowed_value_NaN); + } + else if (!isFinite(value)) { + error(initializer, ts.Diagnostics.const_enum_member_initializer_was_evaluated_to_a_non_finite_value); + } + } + } + return value; + function evalConstant(e) { + switch (e.kind) { + case 179 /* 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; + } + return undefined; + case 181 /* BinaryExpression */: + var left = evalConstant(e.left); + if (left === undefined) { + return undefined; + } + var right = evalConstant(e.right); + if (right === undefined) { + 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; + } + return undefined; + case 8 /* NumericLiteral */: + return +e.text; + case 172 /* ParenthesizedExpression */: + return evalConstant(e.expression); + case 69 /* Identifier */: + case 167 /* ElementAccessExpression */: + case 166 /* PropertyAccessExpression */: + var member = initializer.parent; + var currentType = getTypeOfSymbol(getSymbolOfNode(member.parent)); + var enumType_1; + var propertyName; + if (e.kind === 69 /* Identifier */) { + // unqualified names can refer to member that reside in different declaration of the enum so just doing name resolution won't work. + // instead pick current enum type and later try to fetch member from the type + enumType_1 = currentType; + propertyName = e.text; + } + else { + var expression; + if (e.kind === 167 /* ElementAccessExpression */) { + if (e.argumentExpression === undefined || + e.argumentExpression.kind !== 9 /* StringLiteral */) { + return undefined; + } + expression = e.expression; + propertyName = e.argumentExpression.text; + } + else { + expression = e.expression; + propertyName = e.name.text; + } + // expression part in ElementAccess\PropertyAccess should be either identifier or dottedName + var current = expression; + while (current) { + if (current.kind === 69 /* Identifier */) { + break; + } + else if (current.kind === 166 /* PropertyAccessExpression */) { + current = current.expression; + } + else { + return undefined; + } + } + enumType_1 = checkExpression(expression); + // allow references to constant members of other enums + if (!(enumType_1.symbol && (enumType_1.symbol.flags & 384 /* Enum */))) { + return undefined; + } + } + if (propertyName === undefined) { + return undefined; + } + var property = getPropertyOfObjectType(enumType_1, propertyName); + if (!property || !(property.flags & 8 /* EnumMember */)) { + return undefined; + } + var propertyDecl = property.valueDeclaration; + // self references are illegal + if (member === propertyDecl) { + return undefined; + } + // illegal case: forward reference + if (!isBlockScopedNameDeclaredBeforeUse(propertyDecl, member)) { + reportError = false; + error(e, ts.Diagnostics.A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_enums); + return undefined; + } + return getNodeLinks(propertyDecl).enumMemberValue; + } + } + } + } + function checkEnumDeclaration(node) { + if (!produceDiagnostics) { + return; + } + // Grammar checking + checkGrammarDecorators(node) || checkGrammarModifiers(node); + checkTypeNameIsReserved(node.name, ts.Diagnostics.Enum_name_cannot_be_0); + checkCollisionWithCapturedThisVariable(node, node.name); + checkCollisionWithRequireExportsInGeneratedCode(node, node.name); + checkExportsOnMergedDeclarations(node); + computeEnumMemberValues(node); + var enumIsConst = ts.isConst(node); + if (compilerOptions.isolatedModules && enumIsConst && ts.isInAmbientContext(node)) { + error(node.name, ts.Diagnostics.Ambient_const_enums_are_not_allowed_when_the_isolatedModules_flag_is_provided); + } + // Spec 2014 - Section 9.3: + // It isn't possible for one enum declaration to continue the automatic numbering sequence of another, + // and when an enum type has multiple declarations, only one declaration is permitted to omit a value + // for the first member. + // + // Only perform this check once per symbol + var enumSymbol = getSymbolOfNode(node); + var firstDeclaration = ts.getDeclarationOfKind(enumSymbol, node.kind); + if (node === firstDeclaration) { + if (enumSymbol.declarations.length > 1) { + // check that const is placed\omitted on all enum declarations + ts.forEach(enumSymbol.declarations, function (decl) { + if (ts.isConstEnumDeclaration(decl) !== enumIsConst) { + error(decl.name, ts.Diagnostics.Enum_declarations_must_all_be_const_or_non_const); + } + }); + } + var seenEnumMissingInitialInitializer = false; + ts.forEach(enumSymbol.declarations, function (declaration) { + // return true if we hit a violation of the rule, false otherwise + if (declaration.kind !== 217 /* EnumDeclaration */) { + return false; + } + var enumDeclaration = declaration; + if (!enumDeclaration.members.length) { + return false; + } + var firstEnumMember = enumDeclaration.members[0]; + if (!firstEnumMember.initializer) { + if (seenEnumMissingInitialInitializer) { + error(firstEnumMember.name, ts.Diagnostics.In_an_enum_with_multiple_declarations_only_one_declaration_can_omit_an_initializer_for_its_first_enum_element); + } + else { + seenEnumMissingInitialInitializer = true; + } + } + }); + } + } + function getFirstNonAmbientClassOrFunctionDeclaration(symbol) { + var declarations = symbol.declarations; + for (var _i = 0; _i < declarations.length; _i++) { + var declaration = declarations[_i]; + if ((declaration.kind === 214 /* ClassDeclaration */ || + (declaration.kind === 213 /* FunctionDeclaration */ && ts.nodeIsPresent(declaration.body))) && + !ts.isInAmbientContext(declaration)) { + return declaration; + } + } + return undefined; + } + function inSameLexicalScope(node1, node2) { + var container1 = ts.getEnclosingBlockScopeContainer(node1); + var container2 = ts.getEnclosingBlockScopeContainer(node2); + if (isGlobalSourceFile(container1)) { + return isGlobalSourceFile(container2); + } + else if (isGlobalSourceFile(container2)) { + return false; + } + else { + return container1 === container2; + } + } + function checkModuleDeclaration(node) { + if (produceDiagnostics) { + // Grammar checking + var isAmbientExternalModule = node.name.kind === 9 /* StringLiteral */; + var contextErrorMessage = isAmbientExternalModule + ? ts.Diagnostics.An_ambient_module_declaration_is_only_allowed_at_the_top_level_in_a_file + : ts.Diagnostics.A_namespace_declaration_is_only_allowed_in_a_namespace_or_module; + if (checkGrammarModuleElementContext(node, contextErrorMessage)) { + // If we hit a module declaration in an illegal context, just bail out to avoid cascading errors. + return; + } + if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node)) { + if (!ts.isInAmbientContext(node) && node.name.kind === 9 /* StringLiteral */) { + grammarErrorOnNode(node.name, ts.Diagnostics.Only_ambient_modules_can_use_quoted_names); + } + } + checkCollisionWithCapturedThisVariable(node, node.name); + checkCollisionWithRequireExportsInGeneratedCode(node, node.name); + checkExportsOnMergedDeclarations(node); + var symbol = getSymbolOfNode(node); + // The following checks only apply on a non-ambient instantiated module declaration. + if (symbol.flags & 512 /* ValueModule */ + && symbol.declarations.length > 1 + && !ts.isInAmbientContext(node) + && ts.isInstantiatedModule(node, compilerOptions.preserveConstEnums || compilerOptions.isolatedModules)) { + var firstNonAmbientClassOrFunc = getFirstNonAmbientClassOrFunctionDeclaration(symbol); + if (firstNonAmbientClassOrFunc) { + if (ts.getSourceFileOfNode(node) !== ts.getSourceFileOfNode(firstNonAmbientClassOrFunc)) { + error(node.name, ts.Diagnostics.A_namespace_declaration_cannot_be_in_a_different_file_from_a_class_or_function_with_which_it_is_merged); + } + else if (node.pos < firstNonAmbientClassOrFunc.pos) { + error(node.name, ts.Diagnostics.A_namespace_declaration_cannot_be_located_prior_to_a_class_or_function_with_which_it_is_merged); + } + } + // 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, 214 /* ClassDeclaration */); + if (mergedClass && + inSameLexicalScope(node, mergedClass)) { + getNodeLinks(node).flags |= 32768 /* LexicalModuleMergesWithClass */; + } + } + // Checks for ambient external modules. + if (isAmbientExternalModule) { + if (!isGlobalSourceFile(node.parent)) { + error(node.name, ts.Diagnostics.Ambient_modules_cannot_be_nested_in_other_modules_or_namespaces); + } + if (ts.isExternalModuleNameRelative(node.name.text)) { + error(node.name, ts.Diagnostics.Ambient_module_declaration_cannot_specify_relative_module_name); + } + } + } + checkSourceElement(node.body); + } + function getFirstIdentifier(node) { + while (true) { + if (node.kind === 135 /* QualifiedName */) { + node = node.left; + } + else if (node.kind === 166 /* PropertyAccessExpression */) { + node = node.expression; + } + else { + break; + } + } + ts.Debug.assert(node.kind === 69 /* Identifier */); + return node; + } + function checkExternalImportOrExportDeclaration(node) { + var moduleName = ts.getExternalModuleName(node); + if (!ts.nodeIsMissing(moduleName) && moduleName.kind !== 9 /* StringLiteral */) { + error(moduleName, ts.Diagnostics.String_literal_expected); + return false; + } + var inAmbientExternalModule = node.parent.kind === 219 /* ModuleBlock */ && node.parent.parent.name.kind === 9 /* StringLiteral */; + if (node.parent.kind !== 248 /* SourceFile */ && !inAmbientExternalModule) { + error(moduleName, node.kind === 228 /* ExportDeclaration */ ? + ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace : + ts.Diagnostics.Import_declarations_in_a_namespace_cannot_reference_a_module); + return false; + } + if (inAmbientExternalModule && ts.isExternalModuleNameRelative(moduleName.text)) { + // TypeScript 1.0 spec (April 2013): 12.1.6 + // An ExternalImportDeclaration in an AmbientExternalModuleDeclaration may reference + // other external modules only through top - level external module names. + // Relative external module names are not permitted. + error(node, ts.Diagnostics.Import_or_export_declaration_in_an_ambient_module_declaration_cannot_reference_module_through_relative_module_name); + return false; + } + return true; + } + function checkAliasSymbol(node) { + var symbol = getSymbolOfNode(node); + var target = resolveAlias(symbol); + if (target !== unknownSymbol) { + var excludedMeanings = (symbol.flags & 107455 /* Value */ ? 107455 /* Value */ : 0) | + (symbol.flags & 793056 /* Type */ ? 793056 /* Type */ : 0) | + (symbol.flags & 1536 /* Namespace */ ? 1536 /* Namespace */ : 0); + if (target.flags & excludedMeanings) { + var message = node.kind === 230 /* ExportSpecifier */ ? + ts.Diagnostics.Export_declaration_conflicts_with_exported_declaration_of_0 : + ts.Diagnostics.Import_declaration_conflicts_with_local_declaration_of_0; + error(node, message, symbolToString(symbol)); + } + } + } + function checkImportBinding(node) { + checkCollisionWithCapturedThisVariable(node, node.name); + checkCollisionWithRequireExportsInGeneratedCode(node, node.name); + checkAliasSymbol(node); + } + function checkImportDeclaration(node) { + if (checkGrammarModuleElementContext(node, ts.Diagnostics.An_import_declaration_can_only_be_used_in_a_namespace_or_module)) { + // If we hit an import declaration in an illegal context, just bail out to avoid cascading errors. + return; + } + if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && (node.flags & 2035 /* Modifier */)) { + grammarErrorOnFirstToken(node, ts.Diagnostics.An_import_declaration_cannot_have_modifiers); + } + if (checkExternalImportOrExportDeclaration(node)) { + var importClause = node.importClause; + if (importClause) { + if (importClause.name) { + checkImportBinding(importClause); + } + if (importClause.namedBindings) { + if (importClause.namedBindings.kind === 224 /* NamespaceImport */) { + checkImportBinding(importClause.namedBindings); + } + else { + ts.forEach(importClause.namedBindings.elements, checkImportBinding); + } + } + } + } + } + function checkImportEqualsDeclaration(node) { + if (checkGrammarModuleElementContext(node, ts.Diagnostics.An_import_declaration_can_only_be_used_in_a_namespace_or_module)) { + // If we hit an import declaration in an illegal context, just bail out to avoid cascading errors. + return; + } + checkGrammarDecorators(node) || checkGrammarModifiers(node); + if (ts.isInternalModuleImportEqualsDeclaration(node) || checkExternalImportOrExportDeclaration(node)) { + checkImportBinding(node); + if (node.flags & 1 /* Export */) { + markExportAsReferenced(node); + } + if (ts.isInternalModuleImportEqualsDeclaration(node)) { + var target = resolveAlias(getSymbolOfNode(node)); + if (target !== unknownSymbol) { + if (target.flags & 107455 /* Value */) { + // Target is a value symbol, check that it is not hidden by a local declaration with the same name + var moduleName = getFirstIdentifier(node.moduleReference); + if (!(resolveEntityName(moduleName, 107455 /* Value */ | 1536 /* Namespace */).flags & 1536 /* Namespace */)) { + error(moduleName, ts.Diagnostics.Module_0_is_hidden_by_a_local_declaration_with_the_same_name, ts.declarationNameToString(moduleName)); + } + } + if (target.flags & 793056 /* Type */) { + checkTypeNameIsReserved(node.name, ts.Diagnostics.Import_name_cannot_be_0); + } + } + } + else { + if (modulekind === 5 /* ES6 */ && !ts.isInAmbientContext(node)) { + // Import equals declaration is deprecated in es6 or above + grammarErrorOnNode(node, ts.Diagnostics.Import_assignment_cannot_be_used_when_targeting_ECMAScript_6_modules_Consider_using_import_Asterisk_as_ns_from_mod_import_a_from_mod_import_d_from_mod_or_another_module_format_instead); + } + } + } + } + function checkExportDeclaration(node) { + if (checkGrammarModuleElementContext(node, ts.Diagnostics.An_export_declaration_can_only_be_used_in_a_module)) { + // If we hit an export in an illegal context, just bail out to avoid cascading errors. + return; + } + if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && (node.flags & 2035 /* Modifier */)) { + grammarErrorOnFirstToken(node, ts.Diagnostics.An_export_declaration_cannot_have_modifiers); + } + if (!node.moduleSpecifier || checkExternalImportOrExportDeclaration(node)) { + if (node.exportClause) { + // export { x, y } + // export { x, y } from "foo" + ts.forEach(node.exportClause.elements, checkExportSpecifier); + var inAmbientExternalModule = node.parent.kind === 219 /* ModuleBlock */ && node.parent.parent.name.kind === 9 /* StringLiteral */; + if (node.parent.kind !== 248 /* SourceFile */ && !inAmbientExternalModule) { + error(node, ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace); + } + } + else { + // export * from "foo" + var moduleSymbol = resolveExternalModuleName(node, node.moduleSpecifier); + if (moduleSymbol && moduleSymbol.exports["export="]) { + error(node.moduleSpecifier, ts.Diagnostics.Module_0_uses_export_and_cannot_be_used_with_export_Asterisk, symbolToString(moduleSymbol)); + } + } + } + } + function checkGrammarModuleElementContext(node, errorMessage) { + if (node.parent.kind !== 248 /* SourceFile */ && node.parent.kind !== 219 /* ModuleBlock */ && node.parent.kind !== 218 /* ModuleDeclaration */) { + return grammarErrorOnFirstToken(node, errorMessage); + } + } + function checkExportSpecifier(node) { + checkAliasSymbol(node); + if (!node.parent.parent.moduleSpecifier) { + markExportAsReferenced(node); + } + } + function checkExportAssignment(node) { + if (checkGrammarModuleElementContext(node, ts.Diagnostics.An_export_assignment_can_only_be_used_in_a_module)) { + // If we hit an export assignment in an illegal context, just bail out to avoid cascading errors. + return; + } + var container = node.parent.kind === 248 /* SourceFile */ ? node.parent : node.parent.parent; + if (container.kind === 218 /* ModuleDeclaration */ && container.name.kind === 69 /* Identifier */) { + error(node, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_namespace); + return; + } + // Grammar checking + if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && (node.flags & 2035 /* Modifier */)) { + grammarErrorOnFirstToken(node, ts.Diagnostics.An_export_assignment_cannot_have_modifiers); + } + if (node.expression.kind === 69 /* Identifier */) { + markExportAsReferenced(node); + } + else { + checkExpressionCached(node.expression); + } + checkExternalModuleExports(container); + if (node.isExportEquals && !ts.isInAmbientContext(node)) { + if (modulekind === 5 /* ES6 */) { + // export assignment is not supported in es6 modules + grammarErrorOnNode(node, ts.Diagnostics.Export_assignment_cannot_be_used_when_targeting_ECMAScript_6_modules_Consider_using_export_default_or_another_module_format_instead); + } + else if (modulekind === 4 /* System */) { + // system modules does not support export assignment + grammarErrorOnNode(node, ts.Diagnostics.Export_assignment_is_not_supported_when_module_flag_is_system); + } + } + } + function getModuleStatements(node) { + if (node.kind === 248 /* SourceFile */) { + return node.statements; + } + if (node.kind === 218 /* ModuleDeclaration */ && node.body.kind === 219 /* ModuleBlock */) { + return node.body.statements; + } + return emptyArray; + } + function hasExportedMembers(moduleSymbol) { + for (var id in moduleSymbol.exports) { + if (id !== "export=") { + return true; + } + } + return false; + } + function checkExternalModuleExports(node) { + var moduleSymbol = getSymbolOfNode(node); + var links = getSymbolLinks(moduleSymbol); + if (!links.exportsChecked) { + var exportEqualsSymbol = moduleSymbol.exports["export="]; + if (exportEqualsSymbol && hasExportedMembers(moduleSymbol)) { + var declaration = getDeclarationOfAliasSymbol(exportEqualsSymbol) || exportEqualsSymbol.valueDeclaration; + error(declaration, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_module_with_other_exported_elements); + } + links.exportsChecked = true; + } + } + function checkTypePredicate(node) { + if (!isInLegalTypePredicatePosition(node)) { + error(node, ts.Diagnostics.A_type_predicate_is_only_allowed_in_return_type_position_for_functions_and_methods); + } + } + function checkSourceElement(node) { + if (!node) { + return; + } + var kind = node.kind; + if (cancellationToken) { + // Only bother checking on a few construct kinds. We don't want to be excessivly + // hitting the cancellation token on every node we check. + switch (kind) { + case 218 /* ModuleDeclaration */: + case 214 /* ClassDeclaration */: + case 215 /* InterfaceDeclaration */: + case 213 /* FunctionDeclaration */: + cancellationToken.throwIfCancellationRequested(); + } + } + switch (kind) { + case 137 /* TypeParameter */: + return checkTypeParameter(node); + case 138 /* Parameter */: + return checkParameter(node); + case 141 /* PropertyDeclaration */: + case 140 /* PropertySignature */: + return checkPropertyDeclaration(node); + case 152 /* FunctionType */: + case 153 /* ConstructorType */: + case 147 /* CallSignature */: + case 148 /* ConstructSignature */: + return checkSignatureDeclaration(node); + case 149 /* IndexSignature */: + return checkSignatureDeclaration(node); + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: + return checkMethodDeclaration(node); + case 144 /* Constructor */: + return checkConstructorDeclaration(node); + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: + return checkAccessorDeclaration(node); + case 151 /* TypeReference */: + return checkTypeReferenceNode(node); + case 150 /* TypePredicate */: + return checkTypePredicate(node); + case 154 /* TypeQuery */: + return checkTypeQuery(node); + case 155 /* TypeLiteral */: + return checkTypeLiteral(node); + case 156 /* ArrayType */: + return checkArrayType(node); + case 157 /* TupleType */: + return checkTupleType(node); + case 158 /* UnionType */: + case 159 /* IntersectionType */: + return checkUnionOrIntersectionType(node); + case 160 /* ParenthesizedType */: + return checkSourceElement(node.type); + case 213 /* FunctionDeclaration */: + return checkFunctionDeclaration(node); + case 192 /* Block */: + case 219 /* ModuleBlock */: + return checkBlock(node); + case 193 /* VariableStatement */: + return checkVariableStatement(node); + case 195 /* ExpressionStatement */: + return checkExpressionStatement(node); + case 196 /* IfStatement */: + return checkIfStatement(node); + case 197 /* DoStatement */: + return checkDoStatement(node); + case 198 /* WhileStatement */: + return checkWhileStatement(node); + case 199 /* ForStatement */: + return checkForStatement(node); + case 200 /* ForInStatement */: + return checkForInStatement(node); + case 201 /* ForOfStatement */: + return checkForOfStatement(node); + case 202 /* ContinueStatement */: + case 203 /* BreakStatement */: + return checkBreakOrContinueStatement(node); + case 204 /* ReturnStatement */: + return checkReturnStatement(node); + case 205 /* WithStatement */: + return checkWithStatement(node); + case 206 /* SwitchStatement */: + return checkSwitchStatement(node); + case 207 /* LabeledStatement */: + return checkLabeledStatement(node); + case 208 /* ThrowStatement */: + return checkThrowStatement(node); + case 209 /* TryStatement */: + return checkTryStatement(node); + case 211 /* VariableDeclaration */: + return checkVariableDeclaration(node); + case 163 /* BindingElement */: + return checkBindingElement(node); + case 214 /* ClassDeclaration */: + return checkClassDeclaration(node); + case 215 /* InterfaceDeclaration */: + return checkInterfaceDeclaration(node); + case 216 /* TypeAliasDeclaration */: + return checkTypeAliasDeclaration(node); + case 217 /* EnumDeclaration */: + return checkEnumDeclaration(node); + case 218 /* ModuleDeclaration */: + return checkModuleDeclaration(node); + case 222 /* ImportDeclaration */: + return checkImportDeclaration(node); + case 221 /* ImportEqualsDeclaration */: + return checkImportEqualsDeclaration(node); + case 228 /* ExportDeclaration */: + return checkExportDeclaration(node); + case 227 /* ExportAssignment */: + return checkExportAssignment(node); + case 194 /* EmptyStatement */: + checkGrammarStatementInAmbientContext(node); + return; + case 210 /* DebuggerStatement */: + checkGrammarStatementInAmbientContext(node); + return; + case 231 /* MissingDeclaration */: + return checkMissingDeclaration(node); + } + } + // Function and class expression bodies are checked after all statements in the enclosing body. This is + // to ensure constructs like the following are permitted: + // let foo = function () { + // let s = foo(); + // return "hello"; + // } + // Here, performing a full type check of the body of the function expression whilst in the process of + // determining the type of foo would cause foo to be given type any because of the recursive reference. + // Delaying the type check of the body ensures foo has been assigned a type. + function checkFunctionAndClassExpressionBodies(node) { + switch (node.kind) { + case 173 /* FunctionExpression */: + case 174 /* ArrowFunction */: + ts.forEach(node.parameters, checkFunctionAndClassExpressionBodies); + checkFunctionExpressionOrObjectLiteralMethodBody(node); + break; + case 186 /* ClassExpression */: + ts.forEach(node.members, checkSourceElement); + ts.forEachChild(node, checkFunctionAndClassExpressionBodies); + break; + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: + ts.forEach(node.decorators, checkFunctionAndClassExpressionBodies); + ts.forEach(node.parameters, checkFunctionAndClassExpressionBodies); + if (ts.isObjectLiteralMethod(node)) { + checkFunctionExpressionOrObjectLiteralMethodBody(node); + } + break; + case 144 /* Constructor */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: + case 213 /* FunctionDeclaration */: + ts.forEach(node.parameters, checkFunctionAndClassExpressionBodies); + break; + case 205 /* WithStatement */: + checkFunctionAndClassExpressionBodies(node.expression); + break; + case 139 /* Decorator */: + case 138 /* Parameter */: + case 141 /* PropertyDeclaration */: + case 140 /* PropertySignature */: + case 161 /* ObjectBindingPattern */: + case 162 /* ArrayBindingPattern */: + case 163 /* BindingElement */: + case 164 /* ArrayLiteralExpression */: + case 165 /* ObjectLiteralExpression */: + case 245 /* PropertyAssignment */: + case 166 /* PropertyAccessExpression */: + case 167 /* ElementAccessExpression */: + case 168 /* CallExpression */: + case 169 /* NewExpression */: + case 170 /* TaggedTemplateExpression */: + case 183 /* TemplateExpression */: + case 190 /* TemplateSpan */: + case 171 /* TypeAssertionExpression */: + case 189 /* AsExpression */: + case 172 /* ParenthesizedExpression */: + case 176 /* TypeOfExpression */: + case 177 /* VoidExpression */: + case 178 /* AwaitExpression */: + case 175 /* DeleteExpression */: + case 179 /* PrefixUnaryExpression */: + case 180 /* PostfixUnaryExpression */: + case 181 /* BinaryExpression */: + case 182 /* ConditionalExpression */: + case 185 /* SpreadElementExpression */: + case 184 /* YieldExpression */: + case 192 /* Block */: + case 219 /* ModuleBlock */: + case 193 /* VariableStatement */: + case 195 /* ExpressionStatement */: + case 196 /* IfStatement */: + case 197 /* DoStatement */: + case 198 /* WhileStatement */: + case 199 /* ForStatement */: + case 200 /* ForInStatement */: + case 201 /* ForOfStatement */: + case 202 /* ContinueStatement */: + case 203 /* BreakStatement */: + case 204 /* ReturnStatement */: + case 206 /* SwitchStatement */: + case 220 /* CaseBlock */: + case 241 /* CaseClause */: + case 242 /* DefaultClause */: + case 207 /* LabeledStatement */: + case 208 /* ThrowStatement */: + case 209 /* TryStatement */: + case 244 /* CatchClause */: + case 211 /* VariableDeclaration */: + case 212 /* VariableDeclarationList */: + case 214 /* ClassDeclaration */: + case 243 /* HeritageClause */: + case 188 /* ExpressionWithTypeArguments */: + case 217 /* EnumDeclaration */: + case 247 /* EnumMember */: + case 227 /* ExportAssignment */: + case 248 /* SourceFile */: + case 240 /* JsxExpression */: + case 233 /* JsxElement */: + case 234 /* JsxSelfClosingElement */: + case 238 /* JsxAttribute */: + case 239 /* JsxSpreadAttribute */: + case 235 /* JsxOpeningElement */: + ts.forEachChild(node, checkFunctionAndClassExpressionBodies); + break; + } + } + function checkSourceFile(node) { + var start = new Date().getTime(); + checkSourceFileWorker(node); + ts.checkTime += new Date().getTime() - start; + } + // Fully type check a source file and collect the relevant diagnostics. + function checkSourceFileWorker(node) { + var links = getNodeLinks(node); + if (!(links.flags & 1 /* TypeChecked */)) { + // Check whether the file has declared it is the default lib, + // and whether the user has specifically chosen to avoid checking it. + if (node.isDefaultLib && compilerOptions.skipDefaultLibCheck) { + return; + } + // Grammar checking + checkGrammarSourceFile(node); + emitExtends = false; + emitDecorate = false; + emitParam = false; + potentialThisCollisions.length = 0; + ts.forEach(node.statements, checkSourceElement); + checkFunctionAndClassExpressionBodies(node); + if (ts.isExternalModule(node)) { + checkExternalModuleExports(node); + } + if (potentialThisCollisions.length) { + ts.forEach(potentialThisCollisions, checkIfThisIsCapturedInEnclosingScope); + potentialThisCollisions.length = 0; + } + if (emitExtends) { + links.flags |= 8 /* EmitExtends */; + } + if (emitDecorate) { + links.flags |= 16 /* EmitDecorate */; + } + if (emitParam) { + links.flags |= 32 /* EmitParam */; + } + if (emitAwaiter) { + links.flags |= 64 /* EmitAwaiter */; + } + if (emitGenerator || (emitAwaiter && languageVersion < 2 /* ES6 */)) { + links.flags |= 128 /* EmitGenerator */; + } + links.flags |= 1 /* TypeChecked */; + } + } + function getDiagnostics(sourceFile, ct) { + try { + // Record the cancellation token so it can be checked later on during checkSourceElement. + // Do this in a finally block so we can ensure that it gets reset back to nothing after + // this call is done. + cancellationToken = ct; + return getDiagnosticsWorker(sourceFile); + } + finally { + cancellationToken = undefined; + } + } + function getDiagnosticsWorker(sourceFile) { + throwIfNonDiagnosticsProducing(); + if (sourceFile) { + checkSourceFile(sourceFile); + return diagnostics.getDiagnostics(sourceFile.fileName); + } + ts.forEach(host.getSourceFiles(), checkSourceFile); + return diagnostics.getDiagnostics(); + } + function getGlobalDiagnostics() { + throwIfNonDiagnosticsProducing(); + return diagnostics.getGlobalDiagnostics(); + } + function throwIfNonDiagnosticsProducing() { + if (!produceDiagnostics) { + throw new Error("Trying to get diagnostics from a type checker that does not produce them."); + } + } + // Language service support + function isInsideWithStatementBody(node) { + if (node) { + while (node.parent) { + if (node.parent.kind === 205 /* WithStatement */ && node.parent.statement === node) { + return true; + } + node = node.parent; + } + } + return false; + } + function getSymbolsInScope(location, meaning) { + var symbols = {}; + var memberFlags = 0; + if (isInsideWithStatementBody(location)) { + // We cannot answer semantic questions within a with block, do not proceed any further + return []; + } + populateSymbols(); + return symbolsToArray(symbols); + function populateSymbols() { + while (location) { + if (location.locals && !isGlobalSourceFile(location)) { + copySymbols(location.locals, meaning); + } + switch (location.kind) { + case 248 /* SourceFile */: + if (!ts.isExternalModule(location)) { + break; + } + case 218 /* ModuleDeclaration */: + copySymbols(getSymbolOfNode(location).exports, meaning & 8914931 /* ModuleMember */); + break; + case 217 /* EnumDeclaration */: + copySymbols(getSymbolOfNode(location).exports, meaning & 8 /* EnumMember */); + break; + case 186 /* ClassExpression */: + var className = location.name; + if (className) { + copySymbol(location.symbol, meaning); + } + // fall through; this fall-through is necessary because we would like to handle + // type parameter inside class expression similar to how we handle it in classDeclaration and interface Declaration + case 214 /* ClassDeclaration */: + case 215 /* InterfaceDeclaration */: + // If we didn't come from static member of class or interface, + // add the type parameters into the symbol table + // (type parameters of classDeclaration/classExpression and interface are in member property of the symbol. + // Note: that the memberFlags come from previous iteration. + if (!(memberFlags & 128 /* Static */)) { + copySymbols(getSymbolOfNode(location).members, meaning & 793056 /* Type */); + } + break; + case 173 /* FunctionExpression */: + var funcName = location.name; + if (funcName) { + copySymbol(location.symbol, meaning); + } + break; + } + if (ts.introducesArgumentsExoticObject(location)) { + copySymbol(argumentsSymbol, meaning); + } + memberFlags = location.flags; + location = location.parent; + } + copySymbols(globals, meaning); + } + /** + * Copy the given symbol into symbol tables if the symbol has the given meaning + * and it doesn't already existed in the symbol table + * @param key a key for storing in symbol table; if undefined, use symbol.name + * @param symbol the symbol to be added into symbol table + * @param meaning meaning of symbol to filter by before adding to symbol table + */ + function copySymbol(symbol, meaning) { + if (symbol.flags & meaning) { + var id = symbol.name; + // We will copy all symbol regardless of its reserved name because + // symbolsToArray will check whether the key is a reserved name and + // it will not copy symbol with reserved name to the array + if (!ts.hasProperty(symbols, id)) { + symbols[id] = symbol; + } + } + } + function copySymbols(source, meaning) { + if (meaning) { + for (var id in source) { + var symbol = source[id]; + copySymbol(symbol, meaning); + } + } + } + } + function isTypeDeclarationName(name) { + return name.kind === 69 /* Identifier */ && + isTypeDeclaration(name.parent) && + name.parent.name === name; + } + function isTypeDeclaration(node) { + switch (node.kind) { + case 137 /* TypeParameter */: + case 214 /* ClassDeclaration */: + case 215 /* InterfaceDeclaration */: + case 216 /* TypeAliasDeclaration */: + case 217 /* EnumDeclaration */: + return true; + } + } + // True if the given identifier is part of a type reference + function isTypeReferenceIdentifier(entityName) { + var node = entityName; + while (node.parent && node.parent.kind === 135 /* QualifiedName */) { + node = node.parent; + } + return node.parent && node.parent.kind === 151 /* TypeReference */; + } + function isHeritageClauseElementIdentifier(entityName) { + var node = entityName; + while (node.parent && node.parent.kind === 166 /* PropertyAccessExpression */) { + node = node.parent; + } + return node.parent && node.parent.kind === 188 /* ExpressionWithTypeArguments */; + } + function getLeftSideOfImportEqualsOrExportAssignment(nodeOnRightSide) { + while (nodeOnRightSide.parent.kind === 135 /* QualifiedName */) { + nodeOnRightSide = nodeOnRightSide.parent; + } + if (nodeOnRightSide.parent.kind === 221 /* ImportEqualsDeclaration */) { + return nodeOnRightSide.parent.moduleReference === nodeOnRightSide && nodeOnRightSide.parent; + } + if (nodeOnRightSide.parent.kind === 227 /* ExportAssignment */) { + return nodeOnRightSide.parent.expression === nodeOnRightSide && nodeOnRightSide.parent; + } + return undefined; + } + function isInRightSideOfImportOrExportAssignment(node) { + return getLeftSideOfImportEqualsOrExportAssignment(node) !== undefined; + } + function getSymbolOfEntityNameOrPropertyAccessExpression(entityName) { + if (ts.isDeclarationName(entityName)) { + return getSymbolOfNode(entityName.parent); + } + if (entityName.parent.kind === 227 /* ExportAssignment */) { + return resolveEntityName(entityName, + /*all meanings*/ 107455 /* Value */ | 793056 /* Type */ | 1536 /* Namespace */ | 8388608 /* Alias */); + } + if (entityName.kind !== 166 /* PropertyAccessExpression */) { + if (isInRightSideOfImportOrExportAssignment(entityName)) { + // Since we already checked for ExportAssignment, this really could only be an Import + return getSymbolOfPartOfRightHandSideOfImportEquals(entityName); + } + } + if (ts.isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { + entityName = entityName.parent; + } + if (isHeritageClauseElementIdentifier(entityName)) { + var meaning = 0 /* None */; + // In an interface or class, we're definitely interested in a type. + if (entityName.parent.kind === 188 /* ExpressionWithTypeArguments */) { + meaning = 793056 /* Type */; + // In a class 'extends' clause we are also looking for a value. + if (ts.isExpressionWithTypeArgumentsInClassExtendsClause(entityName.parent)) { + meaning |= 107455 /* Value */; + } + } + else { + meaning = 1536 /* Namespace */; + } + meaning |= 8388608 /* Alias */; + return resolveEntityName(entityName, meaning); + } + else if ((entityName.parent.kind === 235 /* JsxOpeningElement */) || + (entityName.parent.kind === 234 /* JsxSelfClosingElement */) || + (entityName.parent.kind === 237 /* JsxClosingElement */)) { + return getJsxElementTagSymbol(entityName.parent); + } + else if (ts.isExpression(entityName)) { + if (ts.nodeIsMissing(entityName)) { + // Missing entity name. + return undefined; + } + if (entityName.kind === 69 /* Identifier */) { + // Include aliases in the meaning, this ensures that we do not follow aliases to where they point and instead + // return the alias symbol. + var meaning = 107455 /* Value */ | 8388608 /* Alias */; + return resolveEntityName(entityName, meaning); + } + else if (entityName.kind === 166 /* PropertyAccessExpression */) { + var symbol = getNodeLinks(entityName).resolvedSymbol; + if (!symbol) { + checkPropertyAccessExpression(entityName); + } + return getNodeLinks(entityName).resolvedSymbol; + } + else if (entityName.kind === 135 /* QualifiedName */) { + var symbol = getNodeLinks(entityName).resolvedSymbol; + if (!symbol) { + checkQualifiedName(entityName); + } + return getNodeLinks(entityName).resolvedSymbol; + } + } + else if (isTypeReferenceIdentifier(entityName)) { + var meaning = entityName.parent.kind === 151 /* TypeReference */ ? 793056 /* Type */ : 1536 /* Namespace */; + // Include aliases in the meaning, this ensures that we do not follow aliases to where they point and instead + // return the alias symbol. + meaning |= 8388608 /* Alias */; + return resolveEntityName(entityName, meaning); + } + else if (entityName.parent.kind === 238 /* JsxAttribute */) { + return getJsxAttributePropertySymbol(entityName.parent); + } + if (entityName.parent.kind === 150 /* TypePredicate */) { + return resolveEntityName(entityName, /*meaning*/ 1 /* FunctionScopedVariable */); + } + // Do we want to return undefined here? + return undefined; + } + function getSymbolAtLocation(node) { + if (isInsideWithStatementBody(node)) { + // We cannot answer semantic questions within a with block, do not proceed any further + return undefined; + } + if (ts.isDeclarationName(node)) { + // This is a declaration, call getSymbolOfNode + return getSymbolOfNode(node.parent); + } + if (node.kind === 69 /* Identifier */) { + if (isInRightSideOfImportOrExportAssignment(node)) { + return node.parent.kind === 227 /* ExportAssignment */ + ? getSymbolOfEntityNameOrPropertyAccessExpression(node) + : getSymbolOfPartOfRightHandSideOfImportEquals(node); + } + else if (node.parent.kind === 163 /* BindingElement */ && + node.parent.parent.kind === 161 /* ObjectBindingPattern */ && + node === node.parent.propertyName) { + var typeOfPattern = getTypeOfNode(node.parent.parent); + var propertyDeclaration = typeOfPattern && getPropertyOfType(typeOfPattern, node.text); + if (propertyDeclaration) { + return propertyDeclaration; + } + } + } + switch (node.kind) { + case 69 /* Identifier */: + case 166 /* PropertyAccessExpression */: + case 135 /* QualifiedName */: + return getSymbolOfEntityNameOrPropertyAccessExpression(node); + case 97 /* ThisKeyword */: + case 95 /* SuperKeyword */: + var type = ts.isExpression(node) ? checkExpression(node) : getTypeFromTypeNode(node); + return type.symbol; + case 121 /* ConstructorKeyword */: + // constructor keyword for an overload, should take us to the definition if it exist + var constructorDeclaration = node.parent; + if (constructorDeclaration && constructorDeclaration.kind === 144 /* Constructor */) { + return constructorDeclaration.parent.symbol; + } + return undefined; + case 9 /* StringLiteral */: + // External module name in an import declaration + if ((ts.isExternalModuleImportEqualsDeclaration(node.parent.parent) && + ts.getExternalModuleImportEqualsDeclarationExpression(node.parent.parent) === node) || + ((node.parent.kind === 222 /* ImportDeclaration */ || node.parent.kind === 228 /* ExportDeclaration */) && + node.parent.moduleSpecifier === node)) { + return resolveExternalModuleName(node, node); + } + // Fall through + case 8 /* NumericLiteral */: + // index access + if (node.parent.kind === 167 /* ElementAccessExpression */ && node.parent.argumentExpression === node) { + var objectType = checkExpression(node.parent.expression); + if (objectType === unknownType) + return undefined; + var apparentType = getApparentType(objectType); + if (apparentType === unknownType) + return undefined; + return getPropertyOfType(apparentType, node.text); + } + break; + } + return undefined; + } + function getShorthandAssignmentValueSymbol(location) { + // The function returns a value symbol of an identifier in the short-hand property assignment. + // This is necessary as an identifier in short-hand property assignment can contains two meaning: + // property name and property value. + if (location && location.kind === 246 /* ShorthandPropertyAssignment */) { + return resolveEntityName(location.name, 107455 /* Value */); + } + return undefined; + } + function getTypeOfNode(node) { + if (isInsideWithStatementBody(node)) { + // We cannot answer semantic questions within a with block, do not proceed any further + return unknownType; + } + if (ts.isTypeNode(node)) { + return getTypeFromTypeNode(node); + } + if (ts.isExpression(node)) { + return getTypeOfExpression(node); + } + if (ts.isExpressionWithTypeArgumentsInClassExtendsClause(node)) { + // A SyntaxKind.ExpressionWithTypeArguments is considered a type node, except when it occurs in the + // extends clause of a class. We handle that case here. + return getBaseTypes(getDeclaredTypeOfSymbol(getSymbolOfNode(node.parent.parent)))[0]; + } + if (isTypeDeclaration(node)) { + // In this case, we call getSymbolOfNode instead of getSymbolAtLocation because it is a declaration + var symbol = getSymbolOfNode(node); + return getDeclaredTypeOfSymbol(symbol); + } + if (isTypeDeclarationName(node)) { + var symbol = getSymbolAtLocation(node); + return symbol && getDeclaredTypeOfSymbol(symbol); + } + if (ts.isDeclaration(node)) { + // In this case, we call getSymbolOfNode instead of getSymbolAtLocation because it is a declaration + var symbol = getSymbolOfNode(node); + return getTypeOfSymbol(symbol); + } + if (ts.isDeclarationName(node)) { + var symbol = getSymbolAtLocation(node); + return symbol && getTypeOfSymbol(symbol); + } + if (ts.isBindingPattern(node)) { + return getTypeForVariableLikeDeclaration(node.parent); + } + if (isInRightSideOfImportOrExportAssignment(node)) { + var symbol = getSymbolAtLocation(node); + var declaredType = symbol && getDeclaredTypeOfSymbol(symbol); + return declaredType !== unknownType ? declaredType : getTypeOfSymbol(symbol); + } + return unknownType; + } + function getTypeOfExpression(expr) { + if (ts.isRightSideOfQualifiedNameOrPropertyAccess(expr)) { + expr = expr.parent; + } + return checkExpression(expr); + } + /** + * Gets either the static or instance type of a class element, based on + * whether the element is declared as "static". + */ + function getParentTypeOfClassElement(node) { + var classSymbol = getSymbolOfNode(node.parent); + return node.flags & 128 /* Static */ + ? getTypeOfSymbol(classSymbol) + : getDeclaredTypeOfSymbol(classSymbol); + } + // Return the list of properties of the given type, augmented with properties from Function + // if the type has call or construct signatures + function getAugmentedPropertiesOfType(type) { + type = getApparentType(type); + var propsByName = createSymbolTable(getPropertiesOfType(type)); + if (getSignaturesOfType(type, 0 /* Call */).length || getSignaturesOfType(type, 1 /* Construct */).length) { + ts.forEach(getPropertiesOfType(globalFunctionType), function (p) { + if (!ts.hasProperty(propsByName, p.name)) { + propsByName[p.name] = p; + } + }); + } + return getNamedMembers(propsByName); + } + function getRootSymbols(symbol) { + if (symbol.flags & 268435456 /* SyntheticProperty */) { + var symbols = []; + var name_15 = symbol.name; + ts.forEach(getSymbolLinks(symbol).containingType.types, function (t) { + var symbol = getPropertyOfType(t, name_15); + if (symbol) { + symbols.push(symbol); + } + }); + return symbols; + } + else if (symbol.flags & 67108864 /* Transient */) { + var target = getSymbolLinks(symbol).target; + if (target) { + return [target]; + } + } + return [symbol]; + } + // Emitter support + function isArgumentsLocalBinding(node) { + return getReferencedValueSymbol(node) === argumentsSymbol; + } + // When resolved as an expression identifier, if the given node references an exported entity, return the declaration + // node of the exported entity's container. Otherwise, return undefined. + function getReferencedExportContainer(node) { + var symbol = getReferencedValueSymbol(node); + if (symbol) { + if (symbol.flags & 1048576 /* ExportValue */) { + // If we reference an exported entity within the same module declaration, then whether + // we prefix depends on the kind of entity. SymbolFlags.ExportHasLocal encompasses all the + // kinds that we do NOT prefix. + var exportSymbol = getMergedSymbol(symbol.exportSymbol); + if (exportSymbol.flags & 944 /* ExportHasLocal */) { + return undefined; + } + symbol = exportSymbol; + } + var parentSymbol = getParentOfSymbol(symbol); + if (parentSymbol) { + if (parentSymbol.flags & 512 /* ValueModule */ && parentSymbol.valueDeclaration.kind === 248 /* SourceFile */) { + return parentSymbol.valueDeclaration; + } + for (var n = node.parent; n; n = n.parent) { + if ((n.kind === 218 /* ModuleDeclaration */ || n.kind === 217 /* EnumDeclaration */) && getSymbolOfNode(n) === parentSymbol) { + return n; + } + } + } + } + } + // When resolved as an expression identifier, if the given node references an import, return the declaration of + // that import. Otherwise, return undefined. + function getReferencedImportDeclaration(node) { + var symbol = getReferencedValueSymbol(node); + return symbol && symbol.flags & 8388608 /* Alias */ ? getDeclarationOfAliasSymbol(symbol) : undefined; + } + function isStatementWithLocals(node) { + switch (node.kind) { + case 192 /* Block */: + case 220 /* CaseBlock */: + case 199 /* ForStatement */: + case 200 /* ForInStatement */: + case 201 /* ForOfStatement */: + return true; + } + return false; + } + function isNestedRedeclarationSymbol(symbol) { + if (symbol.flags & 418 /* BlockScoped */) { + var links = getSymbolLinks(symbol); + if (links.isNestedRedeclaration === undefined) { + var container = ts.getEnclosingBlockScopeContainer(symbol.valueDeclaration); + links.isNestedRedeclaration = isStatementWithLocals(container) && + !!resolveName(container.parent, symbol.name, 107455 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined); + } + return links.isNestedRedeclaration; + } + return false; + } + // When resolved as an expression identifier, if the given node references a nested block scoped entity with + // a name that hides an existing name, return the declaration of that entity. Otherwise, return undefined. + function getReferencedNestedRedeclaration(node) { + var symbol = getReferencedValueSymbol(node); + return symbol && isNestedRedeclarationSymbol(symbol) ? symbol.valueDeclaration : undefined; + } + // Return true if the given node is a declaration of a nested block scoped entity with a name that hides an + // existing name. + function isNestedRedeclaration(node) { + return isNestedRedeclarationSymbol(getSymbolOfNode(node)); + } + function isValueAliasDeclaration(node) { + switch (node.kind) { + case 221 /* ImportEqualsDeclaration */: + case 223 /* ImportClause */: + case 224 /* NamespaceImport */: + case 226 /* ImportSpecifier */: + case 230 /* ExportSpecifier */: + return isAliasResolvedToValue(getSymbolOfNode(node)); + case 228 /* ExportDeclaration */: + var exportClause = node.exportClause; + return exportClause && ts.forEach(exportClause.elements, isValueAliasDeclaration); + case 227 /* ExportAssignment */: + return node.expression && node.expression.kind === 69 /* Identifier */ ? isAliasResolvedToValue(getSymbolOfNode(node)) : true; + } + return false; + } + function isTopLevelValueImportEqualsWithEntityName(node) { + if (node.parent.kind !== 248 /* SourceFile */ || !ts.isInternalModuleImportEqualsDeclaration(node)) { + // parent is not source file or it is not reference to internal module + return false; + } + var isValue = isAliasResolvedToValue(getSymbolOfNode(node)); + return isValue && node.moduleReference && !ts.nodeIsMissing(node.moduleReference); + } + function isAliasResolvedToValue(symbol) { + var target = resolveAlias(symbol); + if (target === unknownSymbol && compilerOptions.isolatedModules) { + return true; + } + // const enums and modules that contain only const enums are not considered values from the emit perespective + // unless 'preserveConstEnums' option is set to true + return target !== unknownSymbol && + target && + target.flags & 107455 /* Value */ && + (compilerOptions.preserveConstEnums || !isConstEnumOrConstEnumOnlyModule(target)); + } + function isConstEnumOrConstEnumOnlyModule(s) { + return isConstEnumSymbol(s) || s.constEnumOnlyModule; + } + function isReferencedAliasDeclaration(node, checkChildren) { + if (ts.isAliasSymbolDeclaration(node)) { + var symbol = getSymbolOfNode(node); + if (getSymbolLinks(symbol).referenced) { + return true; + } + } + if (checkChildren) { + return ts.forEachChild(node, function (node) { return isReferencedAliasDeclaration(node, checkChildren); }); + } + return false; + } + function isImplementationOfOverload(node) { + if (ts.nodeIsPresent(node.body)) { + var symbol = getSymbolOfNode(node); + var signaturesOfSymbol = getSignaturesOfSymbol(symbol); + // If this function body corresponds to function with multiple signature, it is implementation of overload + // e.g.: function foo(a: string): string; + // function foo(a: number): number; + // function foo(a: any) { // This is implementation of the overloads + // return a; + // } + return signaturesOfSymbol.length > 1 || + // If there is single signature for the symbol, it is overload if that signature isn't coming from the node + // e.g.: function foo(a: string): string; + // function foo(a: any) { // This is implementation of the overloads + // return a; + // } + (signaturesOfSymbol.length === 1 && signaturesOfSymbol[0].declaration !== node); + } + return false; + } + function getNodeCheckFlags(node) { + return getNodeLinks(node).flags; + } + function getEnumMemberValue(node) { + computeEnumMemberValues(node.parent); + return getNodeLinks(node).enumMemberValue; + } + function getConstantValue(node) { + if (node.kind === 247 /* EnumMember */) { + return getEnumMemberValue(node); + } + var symbol = getNodeLinks(node).resolvedSymbol; + if (symbol && (symbol.flags & 8 /* EnumMember */)) { + // inline property\index accesses only for const enums + if (ts.isConstEnumDeclaration(symbol.valueDeclaration.parent)) { + return getEnumMemberValue(symbol.valueDeclaration); + } + } + return undefined; + } + function isFunctionType(type) { + return type.flags & 80896 /* ObjectType */ && getSignaturesOfType(type, 0 /* Call */).length > 0; + } + function getTypeReferenceSerializationKind(typeName) { + // Resolve the symbol as a value to ensure the type can be reached at runtime during emit. + var valueSymbol = resolveEntityName(typeName, 107455 /* Value */, /*ignoreErrors*/ true); + var constructorType = valueSymbol ? getTypeOfSymbol(valueSymbol) : undefined; + if (constructorType && isConstructorType(constructorType)) { + return ts.TypeReferenceSerializationKind.TypeWithConstructSignatureAndValue; + } + // Resolve the symbol as a type so that we can provide a more useful hint for the type serializer. + var typeSymbol = resolveEntityName(typeName, 793056 /* Type */, /*ignoreErrors*/ true); + // We might not be able to resolve type symbol so use unknown type in that case (eg error case) + if (!typeSymbol) { + return ts.TypeReferenceSerializationKind.ObjectType; + } + var type = getDeclaredTypeOfSymbol(typeSymbol); + if (type === unknownType) { + return ts.TypeReferenceSerializationKind.Unknown; + } + else if (type.flags & 1 /* Any */) { + return ts.TypeReferenceSerializationKind.ObjectType; + } + else if (allConstituentTypesHaveKind(type, 16 /* Void */)) { + return ts.TypeReferenceSerializationKind.VoidType; + } + else if (allConstituentTypesHaveKind(type, 8 /* Boolean */)) { + return ts.TypeReferenceSerializationKind.BooleanType; + } + else if (allConstituentTypesHaveKind(type, 132 /* NumberLike */)) { + return ts.TypeReferenceSerializationKind.NumberLikeType; + } + else if (allConstituentTypesHaveKind(type, 258 /* StringLike */)) { + return ts.TypeReferenceSerializationKind.StringLikeType; + } + else if (allConstituentTypesHaveKind(type, 8192 /* Tuple */)) { + return ts.TypeReferenceSerializationKind.ArrayLikeType; + } + else if (allConstituentTypesHaveKind(type, 16777216 /* ESSymbol */)) { + return ts.TypeReferenceSerializationKind.ESSymbolType; + } + else if (isFunctionType(type)) { + return ts.TypeReferenceSerializationKind.TypeWithCallSignature; + } + else if (isArrayType(type)) { + return ts.TypeReferenceSerializationKind.ArrayLikeType; + } + else { + return ts.TypeReferenceSerializationKind.ObjectType; + } + } + function writeTypeOfDeclaration(declaration, enclosingDeclaration, flags, writer) { + // Get type of the symbol if this is the valid symbol otherwise get type at location + var symbol = getSymbolOfNode(declaration); + var type = symbol && !(symbol.flags & (2048 /* TypeLiteral */ | 131072 /* Signature */)) + ? getTypeOfSymbol(symbol) + : unknownType; + getSymbolDisplayBuilder().buildTypeDisplay(type, writer, enclosingDeclaration, flags); + } + function writeReturnTypeOfSignatureDeclaration(signatureDeclaration, enclosingDeclaration, flags, writer) { + var signature = getSignatureFromDeclaration(signatureDeclaration); + getSymbolDisplayBuilder().buildTypeDisplay(getReturnTypeOfSignature(signature), writer, enclosingDeclaration, flags); + } + function writeTypeOfExpression(expr, enclosingDeclaration, flags, writer) { + var type = getTypeOfExpression(expr); + getSymbolDisplayBuilder().buildTypeDisplay(type, writer, enclosingDeclaration, flags); + } + function hasGlobalName(name) { + return ts.hasProperty(globals, name); + } + function getReferencedValueSymbol(reference) { + return getNodeLinks(reference).resolvedSymbol || + resolveName(reference, reference.text, 107455 /* Value */ | 1048576 /* ExportValue */ | 8388608 /* Alias */, + /*nodeNotFoundMessage*/ undefined, /*nameArg*/ undefined); + } + function getReferencedValueDeclaration(reference) { + ts.Debug.assert(!ts.nodeIsSynthesized(reference)); + var symbol = getReferencedValueSymbol(reference); + return symbol && getExportSymbolOfValueSymbolIfExported(symbol).valueDeclaration; + } + function instantiateSingleCallFunctionType(functionType, typeArguments) { + if (functionType === unknownType) { + return unknownType; + } + var signature = getSingleCallSignature(functionType); + if (!signature) { + return unknownType; + } + var instantiatedSignature = getSignatureInstantiation(signature, typeArguments); + return getOrCreateTypeFromSignature(instantiatedSignature); + } + function createResolver() { + return { + getReferencedExportContainer: getReferencedExportContainer, + getReferencedImportDeclaration: getReferencedImportDeclaration, + getReferencedNestedRedeclaration: getReferencedNestedRedeclaration, + isNestedRedeclaration: isNestedRedeclaration, + isValueAliasDeclaration: isValueAliasDeclaration, + hasGlobalName: hasGlobalName, + isReferencedAliasDeclaration: isReferencedAliasDeclaration, + getNodeCheckFlags: getNodeCheckFlags, + isTopLevelValueImportEqualsWithEntityName: isTopLevelValueImportEqualsWithEntityName, + isDeclarationVisible: isDeclarationVisible, + isImplementationOfOverload: isImplementationOfOverload, + writeTypeOfDeclaration: writeTypeOfDeclaration, + writeReturnTypeOfSignatureDeclaration: writeReturnTypeOfSignatureDeclaration, + writeTypeOfExpression: writeTypeOfExpression, + isSymbolAccessible: isSymbolAccessible, + isEntityNameVisible: isEntityNameVisible, + getConstantValue: getConstantValue, + collectLinkedAliases: collectLinkedAliases, + getReferencedValueDeclaration: getReferencedValueDeclaration, + getTypeReferenceSerializationKind: getTypeReferenceSerializationKind, + isOptionalParameter: isOptionalParameter, + isArgumentsLocalBinding: isArgumentsLocalBinding + }; + } + function initializeTypeChecker() { + // Bind all source files and propagate errors + ts.forEach(host.getSourceFiles(), function (file) { + ts.bindSourceFile(file); + }); + // Initialize global symbol table + ts.forEach(host.getSourceFiles(), function (file) { + if (!ts.isExternalModule(file)) { + mergeSymbolTable(globals, file.locals); + } + }); + // Initialize special symbols + getSymbolLinks(undefinedSymbol).type = undefinedType; + getSymbolLinks(argumentsSymbol).type = getGlobalType("IArguments"); + getSymbolLinks(unknownSymbol).type = unknownType; + globals[undefinedSymbol.name] = undefinedSymbol; + // Initialize special types + globalArrayType = getGlobalType("Array", /*arity*/ 1); + globalObjectType = getGlobalType("Object"); + globalFunctionType = getGlobalType("Function"); + globalStringType = getGlobalType("String"); + globalNumberType = getGlobalType("Number"); + globalBooleanType = getGlobalType("Boolean"); + globalRegExpType = getGlobalType("RegExp"); + jsxElementType = getExportedTypeFromNamespace("JSX", JsxNames.Element); + getGlobalClassDecoratorType = ts.memoize(function () { return getGlobalType("ClassDecorator"); }); + getGlobalPropertyDecoratorType = ts.memoize(function () { return getGlobalType("PropertyDecorator"); }); + getGlobalMethodDecoratorType = ts.memoize(function () { return getGlobalType("MethodDecorator"); }); + getGlobalParameterDecoratorType = ts.memoize(function () { return getGlobalType("ParameterDecorator"); }); + getGlobalTypedPropertyDescriptorType = ts.memoize(function () { return getGlobalType("TypedPropertyDescriptor", /*arity*/ 1); }); + getGlobalPromiseType = ts.memoize(function () { return getGlobalType("Promise", /*arity*/ 1); }); + tryGetGlobalPromiseType = ts.memoize(function () { return getGlobalSymbol("Promise", 793056 /* Type */, /*diagnostic*/ undefined) && getGlobalPromiseType(); }); + getGlobalPromiseLikeType = ts.memoize(function () { return getGlobalType("PromiseLike", /*arity*/ 1); }); + getInstantiatedGlobalPromiseLikeType = ts.memoize(createInstantiatedPromiseLikeType); + getGlobalPromiseConstructorSymbol = ts.memoize(function () { return getGlobalValueSymbol("Promise"); }); + getGlobalPromiseConstructorLikeType = ts.memoize(function () { return getGlobalType("PromiseConstructorLike"); }); + getGlobalThenableType = ts.memoize(createThenableType); + // If we're in ES6 mode, load the TemplateStringsArray. + // Otherwise, default to 'unknown' for the purposes of type checking in LS scenarios. + if (languageVersion >= 2 /* ES6 */) { + globalTemplateStringsArrayType = getGlobalType("TemplateStringsArray"); + globalESSymbolType = getGlobalType("Symbol"); + globalESSymbolConstructorSymbol = getGlobalValueSymbol("Symbol"); + globalIterableType = getGlobalType("Iterable", /*arity*/ 1); + globalIteratorType = getGlobalType("Iterator", /*arity*/ 1); + globalIterableIteratorType = getGlobalType("IterableIterator", /*arity*/ 1); + } + else { + globalTemplateStringsArrayType = unknownType; + // Consider putting Symbol interface in lib.d.ts. On the plus side, putting it in lib.d.ts would make it + // extensible for Polyfilling Symbols. But putting it into lib.d.ts could also break users that have + // a global Symbol already, particularly if it is a class. + globalESSymbolType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); + globalESSymbolConstructorSymbol = undefined; + globalIterableType = emptyGenericType; + globalIteratorType = emptyGenericType; + globalIterableIteratorType = emptyGenericType; + } + anyArrayType = createArrayType(anyType); + } + function createInstantiatedPromiseLikeType() { + var promiseLikeType = getGlobalPromiseLikeType(); + if (promiseLikeType !== emptyGenericType) { + return createTypeReference(promiseLikeType, [anyType]); + } + return emptyObjectType; + } + function createThenableType() { + // build the thenable type that is used to verify against a non-promise "thenable" operand to `await`. + var thenPropertySymbol = createSymbol(67108864 /* Transient */ | 4 /* Property */, "then"); + getSymbolLinks(thenPropertySymbol).type = globalFunctionType; + var thenableType = createObjectType(65536 /* Anonymous */); + thenableType.properties = [thenPropertySymbol]; + thenableType.members = createSymbolTable(thenableType.properties); + thenableType.callSignatures = []; + thenableType.constructSignatures = []; + return thenableType; + } + // GRAMMAR CHECKING + function checkGrammarDecorators(node) { + if (!node.decorators) { + return false; + } + if (!ts.nodeCanBeDecorated(node)) { + return grammarErrorOnFirstToken(node, ts.Diagnostics.Decorators_are_not_valid_here); + } + else if (node.kind === 145 /* GetAccessor */ || node.kind === 146 /* SetAccessor */) { + var accessors = ts.getAllAccessorDeclarations(node.parent.members, node); + if (accessors.firstAccessor.decorators && node === accessors.secondAccessor) { + return grammarErrorOnFirstToken(node, ts.Diagnostics.Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name); + } + } + return false; + } + function checkGrammarModifiers(node) { + switch (node.kind) { + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: + case 144 /* Constructor */: + case 141 /* PropertyDeclaration */: + case 140 /* PropertySignature */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: + case 149 /* IndexSignature */: + case 218 /* ModuleDeclaration */: + case 222 /* ImportDeclaration */: + case 221 /* ImportEqualsDeclaration */: + case 228 /* ExportDeclaration */: + case 227 /* ExportAssignment */: + case 138 /* Parameter */: + break; + case 213 /* FunctionDeclaration */: + if (node.modifiers && (node.modifiers.length > 1 || node.modifiers[0].kind !== 118 /* AsyncKeyword */) && + node.parent.kind !== 219 /* ModuleBlock */ && node.parent.kind !== 248 /* SourceFile */) { + return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); + } + break; + case 214 /* ClassDeclaration */: + case 215 /* InterfaceDeclaration */: + case 193 /* VariableStatement */: + case 216 /* TypeAliasDeclaration */: + if (node.modifiers && node.parent.kind !== 219 /* ModuleBlock */ && node.parent.kind !== 248 /* SourceFile */) { + return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); + } + break; + case 217 /* EnumDeclaration */: + if (node.modifiers && (node.modifiers.length > 1 || node.modifiers[0].kind !== 74 /* ConstKeyword */) && + node.parent.kind !== 219 /* ModuleBlock */ && node.parent.kind !== 248 /* SourceFile */) { + return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); + } + break; + default: + return false; + } + if (!node.modifiers) { + return; + } + var lastStatic, lastPrivate, lastProtected, lastDeclare, lastAsync; + var flags = 0; + for (var _i = 0, _a = node.modifiers; _i < _a.length; _i++) { + var modifier = _a[_i]; + switch (modifier.kind) { + case 112 /* PublicKeyword */: + case 111 /* ProtectedKeyword */: + case 110 /* PrivateKeyword */: + var text = void 0; + if (modifier.kind === 112 /* PublicKeyword */) { + text = "public"; + } + else if (modifier.kind === 111 /* ProtectedKeyword */) { + text = "protected"; + lastProtected = modifier; + } + else { + text = "private"; + lastPrivate = modifier; + } + if (flags & 112 /* AccessibilityModifier */) { + return grammarErrorOnNode(modifier, ts.Diagnostics.Accessibility_modifier_already_seen); + } + else if (flags & 128 /* Static */) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "static"); + } + else if (flags & 512 /* Async */) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "async"); + } + else if (node.parent.kind === 219 /* ModuleBlock */ || node.parent.kind === 248 /* SourceFile */) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_element, text); + } + else if (flags & 256 /* Abstract */) { + if (modifier.kind === 110 /* PrivateKeyword */) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, text, "abstract"); + } + else { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "abstract"); + } + } + flags |= ts.modifierToFlag(modifier.kind); + break; + case 113 /* StaticKeyword */: + if (flags & 128 /* Static */) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "static"); + } + else if (flags & 512 /* Async */) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "static", "async"); + } + else if (node.parent.kind === 219 /* ModuleBlock */ || node.parent.kind === 248 /* SourceFile */) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_element, "static"); + } + else if (node.kind === 138 /* Parameter */) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "static"); + } + else if (flags & 256 /* Abstract */) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "static", "abstract"); + } + flags |= 128 /* Static */; + lastStatic = modifier; + break; + case 82 /* ExportKeyword */: + if (flags & 1 /* Export */) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "export"); + } + else if (flags & 2 /* Ambient */) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "declare"); + } + else if (flags & 256 /* Abstract */) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "abstract"); + } + else if (flags & 512 /* Async */) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "async"); + } + else if (node.parent.kind === 214 /* ClassDeclaration */) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "export"); + } + else if (node.kind === 138 /* Parameter */) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "export"); + } + flags |= 1 /* Export */; + break; + case 122 /* DeclareKeyword */: + if (flags & 2 /* Ambient */) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "declare"); + } + else if (flags & 512 /* Async */) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); + } + else if (node.parent.kind === 214 /* ClassDeclaration */) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "declare"); + } + else if (node.kind === 138 /* Parameter */) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "declare"); + } + else if (ts.isInAmbientContext(node.parent) && node.parent.kind === 219 /* ModuleBlock */) { + return grammarErrorOnNode(modifier, ts.Diagnostics.A_declare_modifier_cannot_be_used_in_an_already_ambient_context); + } + flags |= 2 /* Ambient */; + lastDeclare = modifier; + break; + case 115 /* AbstractKeyword */: + if (flags & 256 /* Abstract */) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "abstract"); + } + if (node.kind !== 214 /* ClassDeclaration */) { + if (node.kind !== 143 /* MethodDeclaration */) { + return grammarErrorOnNode(modifier, ts.Diagnostics.abstract_modifier_can_only_appear_on_a_class_or_method_declaration); + } + if (!(node.parent.kind === 214 /* ClassDeclaration */ && node.parent.flags & 256 /* Abstract */)) { + return grammarErrorOnNode(modifier, ts.Diagnostics.Abstract_methods_can_only_appear_within_an_abstract_class); + } + if (flags & 128 /* Static */) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "static", "abstract"); + } + if (flags & 32 /* Private */) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "private", "abstract"); + } + } + flags |= 256 /* Abstract */; + break; + case 118 /* AsyncKeyword */: + if (flags & 512 /* Async */) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "async"); + } + else if (flags & 2 /* Ambient */ || ts.isInAmbientContext(node.parent)) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); + } + else if (node.kind === 138 /* Parameter */) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "async"); + } + flags |= 512 /* Async */; + lastAsync = modifier; + break; + } + } + if (node.kind === 144 /* Constructor */) { + if (flags & 128 /* Static */) { + return grammarErrorOnNode(lastStatic, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "static"); + } + if (flags & 256 /* Abstract */) { + return grammarErrorOnNode(lastStatic, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "abstract"); + } + else if (flags & 64 /* Protected */) { + return grammarErrorOnNode(lastProtected, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "protected"); + } + else if (flags & 32 /* Private */) { + return grammarErrorOnNode(lastPrivate, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "private"); + } + else if (flags & 512 /* Async */) { + return grammarErrorOnNode(lastAsync, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "async"); + } + return; + } + else if ((node.kind === 222 /* ImportDeclaration */ || node.kind === 221 /* ImportEqualsDeclaration */) && flags & 2 /* Ambient */) { + return grammarErrorOnNode(lastDeclare, ts.Diagnostics.A_0_modifier_cannot_be_used_with_an_import_declaration, "declare"); + } + else if (node.kind === 138 /* Parameter */ && (flags & 112 /* AccessibilityModifier */) && ts.isBindingPattern(node.name)) { + return grammarErrorOnNode(node, ts.Diagnostics.A_parameter_property_may_not_be_a_binding_pattern); + } + if (flags & 512 /* Async */) { + return checkGrammarAsyncModifier(node, lastAsync); + } + } + function checkGrammarAsyncModifier(node, asyncModifier) { + if (languageVersion < 2 /* ES6 */) { + return grammarErrorOnNode(asyncModifier, ts.Diagnostics.Async_functions_are_only_available_when_targeting_ECMAScript_6_and_higher); + } + switch (node.kind) { + case 143 /* MethodDeclaration */: + case 213 /* FunctionDeclaration */: + case 173 /* FunctionExpression */: + case 174 /* ArrowFunction */: + if (!node.asteriskToken) { + return false; + } + break; + } + return grammarErrorOnNode(asyncModifier, ts.Diagnostics._0_modifier_cannot_be_used_here, "async"); + } + function checkGrammarForDisallowedTrailingComma(list) { + if (list && list.hasTrailingComma) { + var start = list.end - ",".length; + var end = list.end; + var sourceFile = ts.getSourceFileOfNode(list[0]); + return grammarErrorAtPos(sourceFile, start, end - start, ts.Diagnostics.Trailing_comma_not_allowed); + } + } + function checkGrammarTypeParameterList(node, typeParameters, file) { + if (checkGrammarForDisallowedTrailingComma(typeParameters)) { + return true; + } + if (typeParameters && typeParameters.length === 0) { + var start = typeParameters.pos - "<".length; + var end = ts.skipTrivia(file.text, typeParameters.end) + ">".length; + return grammarErrorAtPos(file, start, end - start, ts.Diagnostics.Type_parameter_list_cannot_be_empty); + } + } + function checkGrammarParameterList(parameters) { + if (checkGrammarForDisallowedTrailingComma(parameters)) { + return true; + } + var seenOptionalParameter = false; + var parameterCount = parameters.length; + for (var i = 0; i < parameterCount; i++) { + var parameter = parameters[i]; + if (parameter.dotDotDotToken) { + if (i !== (parameterCount - 1)) { + return grammarErrorOnNode(parameter.dotDotDotToken, ts.Diagnostics.A_rest_parameter_must_be_last_in_a_parameter_list); + } + if (ts.isBindingPattern(parameter.name)) { + return grammarErrorOnNode(parameter.name, ts.Diagnostics.A_rest_element_cannot_contain_a_binding_pattern); + } + if (parameter.questionToken) { + return grammarErrorOnNode(parameter.questionToken, ts.Diagnostics.A_rest_parameter_cannot_be_optional); + } + if (parameter.initializer) { + return grammarErrorOnNode(parameter.name, ts.Diagnostics.A_rest_parameter_cannot_have_an_initializer); + } + } + else if (parameter.questionToken) { + seenOptionalParameter = true; + if (parameter.initializer) { + return grammarErrorOnNode(parameter.name, ts.Diagnostics.Parameter_cannot_have_question_mark_and_initializer); + } + } + else if (seenOptionalParameter && !parameter.initializer) { + return grammarErrorOnNode(parameter.name, ts.Diagnostics.A_required_parameter_cannot_follow_an_optional_parameter); + } + } + } + function checkGrammarFunctionLikeDeclaration(node) { + // Prevent cascading error by short-circuit + var file = ts.getSourceFileOfNode(node); + return checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarTypeParameterList(node, node.typeParameters, file) || + checkGrammarParameterList(node.parameters) || checkGrammarArrowFunction(node, file); + } + function checkGrammarArrowFunction(node, file) { + if (node.kind === 174 /* ArrowFunction */) { + var arrowFunction = node; + var startLine = ts.getLineAndCharacterOfPosition(file, arrowFunction.equalsGreaterThanToken.pos).line; + var endLine = ts.getLineAndCharacterOfPosition(file, arrowFunction.equalsGreaterThanToken.end).line; + if (startLine !== endLine) { + return grammarErrorOnNode(arrowFunction.equalsGreaterThanToken, ts.Diagnostics.Line_terminator_not_permitted_before_arrow); + } + } + return false; + } + function checkGrammarIndexSignatureParameters(node) { + var parameter = node.parameters[0]; + if (node.parameters.length !== 1) { + if (parameter) { + return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_must_have_exactly_one_parameter); + } + else { + return grammarErrorOnNode(node, ts.Diagnostics.An_index_signature_must_have_exactly_one_parameter); + } + } + if (parameter.dotDotDotToken) { + return grammarErrorOnNode(parameter.dotDotDotToken, ts.Diagnostics.An_index_signature_cannot_have_a_rest_parameter); + } + if (parameter.flags & 2035 /* Modifier */) { + return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_cannot_have_an_accessibility_modifier); + } + if (parameter.questionToken) { + return grammarErrorOnNode(parameter.questionToken, ts.Diagnostics.An_index_signature_parameter_cannot_have_a_question_mark); + } + if (parameter.initializer) { + return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_cannot_have_an_initializer); + } + if (!parameter.type) { + return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_must_have_a_type_annotation); + } + if (parameter.type.kind !== 130 /* StringKeyword */ && parameter.type.kind !== 128 /* NumberKeyword */) { + return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_type_must_be_string_or_number); + } + if (!node.type) { + return grammarErrorOnNode(node, ts.Diagnostics.An_index_signature_must_have_a_type_annotation); + } + } + function checkGrammarForIndexSignatureModifier(node) { + if (node.flags & 2035 /* Modifier */) { + grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_not_permitted_on_index_signature_members); + } + } + function checkGrammarIndexSignature(node) { + // Prevent cascading error by short-circuit + return checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarIndexSignatureParameters(node) || checkGrammarForIndexSignatureModifier(node); + } + function checkGrammarForAtLeastOneTypeArgument(node, typeArguments) { + if (typeArguments && typeArguments.length === 0) { + var sourceFile = ts.getSourceFileOfNode(node); + var start = typeArguments.pos - "<".length; + var end = ts.skipTrivia(sourceFile.text, typeArguments.end) + ">".length; + return grammarErrorAtPos(sourceFile, start, end - start, ts.Diagnostics.Type_argument_list_cannot_be_empty); + } + } + function checkGrammarTypeArguments(node, typeArguments) { + return checkGrammarForDisallowedTrailingComma(typeArguments) || + checkGrammarForAtLeastOneTypeArgument(node, typeArguments); + } + function checkGrammarForOmittedArgument(node, args) { + if (args) { + var sourceFile = ts.getSourceFileOfNode(node); + for (var _i = 0; _i < args.length; _i++) { + var arg = args[_i]; + if (arg.kind === 187 /* OmittedExpression */) { + return grammarErrorAtPos(sourceFile, arg.pos, 0, ts.Diagnostics.Argument_expression_expected); + } + } + } + } + function checkGrammarArguments(node, args) { + return checkGrammarForDisallowedTrailingComma(args) || + checkGrammarForOmittedArgument(node, args); + } + function checkGrammarHeritageClause(node) { + var types = node.types; + if (checkGrammarForDisallowedTrailingComma(types)) { + return true; + } + if (types && types.length === 0) { + var listType = ts.tokenToString(node.token); + var sourceFile = ts.getSourceFileOfNode(node); + return grammarErrorAtPos(sourceFile, types.pos, 0, ts.Diagnostics._0_list_cannot_be_empty, listType); + } + } + function checkGrammarClassDeclarationHeritageClauses(node) { + var seenExtendsClause = false; + var seenImplementsClause = false; + 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 (seenExtendsClause) { + return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_already_seen); + } + if (seenImplementsClause) { + return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_must_precede_implements_clause); + } + if (heritageClause.types.length > 1) { + return grammarErrorOnFirstToken(heritageClause.types[1], ts.Diagnostics.Classes_can_only_extend_a_single_class); + } + seenExtendsClause = true; + } + else { + ts.Debug.assert(heritageClause.token === 106 /* ImplementsKeyword */); + if (seenImplementsClause) { + return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.implements_clause_already_seen); + } + seenImplementsClause = true; + } + // Grammar checking heritageClause inside class declaration + checkGrammarHeritageClause(heritageClause); + } + } + } + function checkGrammarInterfaceDeclaration(node) { + var seenExtendsClause = false; + if (node.heritageClauses) { + for (var _i = 0, _a = node.heritageClauses; _i < _a.length; _i++) { + var heritageClause = _a[_i]; + if (heritageClause.token === 83 /* ExtendsKeyword */) { + if (seenExtendsClause) { + return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_already_seen); + } + seenExtendsClause = true; + } + else { + ts.Debug.assert(heritageClause.token === 106 /* ImplementsKeyword */); + return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.Interface_declaration_cannot_have_implements_clause); + } + // Grammar checking heritageClause inside class declaration + checkGrammarHeritageClause(heritageClause); + } + } + return false; + } + function checkGrammarComputedPropertyName(node) { + // If node is not a computedPropertyName, just skip the grammar checking + if (node.kind !== 136 /* ComputedPropertyName */) { + return false; + } + var computedPropertyName = node; + if (computedPropertyName.expression.kind === 181 /* BinaryExpression */ && computedPropertyName.expression.operatorToken.kind === 24 /* CommaToken */) { + return grammarErrorOnNode(computedPropertyName.expression, ts.Diagnostics.A_comma_expression_is_not_allowed_in_a_computed_property_name); + } + } + function checkGrammarForGenerator(node) { + if (node.asteriskToken) { + ts.Debug.assert(node.kind === 213 /* FunctionDeclaration */ || + node.kind === 173 /* FunctionExpression */ || + node.kind === 143 /* MethodDeclaration */); + if (ts.isInAmbientContext(node)) { + return grammarErrorOnNode(node.asteriskToken, ts.Diagnostics.Generators_are_not_allowed_in_an_ambient_context); + } + if (!node.body) { + return grammarErrorOnNode(node.asteriskToken, ts.Diagnostics.An_overload_signature_cannot_be_declared_as_a_generator); + } + if (languageVersion < 2 /* ES6 */) { + return grammarErrorOnNode(node.asteriskToken, ts.Diagnostics.Generators_are_only_available_when_targeting_ECMAScript_6_or_higher); + } + } + } + function checkGrammarForInvalidQuestionMark(node, questionToken, message) { + if (questionToken) { + return grammarErrorOnNode(questionToken, message); + } + } + function checkGrammarObjectLiteralExpression(node, inDestructuring) { + var seen = {}; + var Property = 1; + var GetAccessor = 2; + var SetAccesor = 4; + var GetOrSetAccessor = GetAccessor | SetAccesor; + for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { + var prop = _a[_i]; + var name_16 = prop.name; + if (prop.kind === 187 /* OmittedExpression */ || + name_16.kind === 136 /* ComputedPropertyName */) { + // If the name is not a ComputedPropertyName, the grammar checking will skip it + checkGrammarComputedPropertyName(name_16); + continue; + } + if (prop.kind === 246 /* ShorthandPropertyAssignment */ && !inDestructuring && prop.objectAssignmentInitializer) { + // having objectAssignmentInitializer is only valid in ObjectAssignmentPattern + // outside of destructuring it is a syntax error + return grammarErrorOnNode(prop.equalsToken, ts.Diagnostics.can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment); + } + // ECMA-262 11.1.5 Object Initialiser + // If previous is not undefined then throw a SyntaxError exception if any of the following conditions are true + // a.This production is contained in strict code and IsDataDescriptor(previous) is true and + // 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 + var currentKind = void 0; + if (prop.kind === 245 /* PropertyAssignment */ || prop.kind === 246 /* ShorthandPropertyAssignment */) { + // Grammar checking for computedPropertName and shorthandPropertyAssignment + checkGrammarForInvalidQuestionMark(prop, prop.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional); + if (name_16.kind === 8 /* NumericLiteral */) { + checkGrammarNumericLiteral(name_16); + } + currentKind = Property; + } + else if (prop.kind === 143 /* MethodDeclaration */) { + currentKind = Property; + } + else if (prop.kind === 145 /* GetAccessor */) { + currentKind = GetAccessor; + } + else if (prop.kind === 146 /* SetAccessor */) { + currentKind = SetAccesor; + } + else { + ts.Debug.fail("Unexpected syntax kind:" + prop.kind); + } + if (!ts.hasProperty(seen, name_16.text)) { + seen[name_16.text] = currentKind; + } + else { + var existingKind = seen[name_16.text]; + if (currentKind === Property && existingKind === Property) { + continue; + } + else if ((currentKind & GetOrSetAccessor) && (existingKind & GetOrSetAccessor)) { + if (existingKind !== GetOrSetAccessor && currentKind !== existingKind) { + seen[name_16.text] = currentKind | existingKind; + } + else { + return grammarErrorOnNode(name_16, ts.Diagnostics.An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name); + } + } + else { + return grammarErrorOnNode(name_16, ts.Diagnostics.An_object_literal_cannot_have_property_and_accessor_with_the_same_name); + } + } + } + } + function checkGrammarJsxElement(node) { + var seen = {}; + for (var _i = 0, _a = node.attributes; _i < _a.length; _i++) { + var attr = _a[_i]; + if (attr.kind === 239 /* JsxSpreadAttribute */) { + continue; + } + var jsxAttr = attr; + var name_17 = jsxAttr.name; + if (!ts.hasProperty(seen, name_17.text)) { + seen[name_17.text] = true; + } + else { + return grammarErrorOnNode(name_17, ts.Diagnostics.JSX_elements_cannot_have_multiple_attributes_with_the_same_name); + } + var initializer = jsxAttr.initializer; + if (initializer && initializer.kind === 240 /* JsxExpression */ && !initializer.expression) { + return grammarErrorOnNode(jsxAttr.initializer, ts.Diagnostics.JSX_attributes_must_only_be_assigned_a_non_empty_expression); + } + } + } + function checkGrammarForInOrForOfStatement(forInOrOfStatement) { + if (checkGrammarStatementInAmbientContext(forInOrOfStatement)) { + return true; + } + if (forInOrOfStatement.initializer.kind === 212 /* VariableDeclarationList */) { + var variableList = forInOrOfStatement.initializer; + if (!checkGrammarVariableDeclarationList(variableList)) { + if (variableList.declarations.length > 1) { + var diagnostic = forInOrOfStatement.kind === 200 /* ForInStatement */ + ? ts.Diagnostics.Only_a_single_variable_declaration_is_allowed_in_a_for_in_statement + : ts.Diagnostics.Only_a_single_variable_declaration_is_allowed_in_a_for_of_statement; + return grammarErrorOnFirstToken(variableList.declarations[1], diagnostic); + } + var firstDeclaration = variableList.declarations[0]; + if (firstDeclaration.initializer) { + var diagnostic = forInOrOfStatement.kind === 200 /* ForInStatement */ + ? ts.Diagnostics.The_variable_declaration_of_a_for_in_statement_cannot_have_an_initializer + : ts.Diagnostics.The_variable_declaration_of_a_for_of_statement_cannot_have_an_initializer; + return grammarErrorOnNode(firstDeclaration.name, diagnostic); + } + if (firstDeclaration.type) { + var diagnostic = forInOrOfStatement.kind === 200 /* ForInStatement */ + ? ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_use_a_type_annotation + : ts.Diagnostics.The_left_hand_side_of_a_for_of_statement_cannot_use_a_type_annotation; + return grammarErrorOnNode(firstDeclaration, diagnostic); + } + } + } + return false; + } + function checkGrammarAccessor(accessor) { + var kind = accessor.kind; + if (languageVersion < 1 /* ES5 */) { + return grammarErrorOnNode(accessor.name, ts.Diagnostics.Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher); + } + else if (ts.isInAmbientContext(accessor)) { + return grammarErrorOnNode(accessor.name, ts.Diagnostics.An_accessor_cannot_be_declared_in_an_ambient_context); + } + else if (accessor.body === undefined) { + return grammarErrorAtPos(ts.getSourceFileOfNode(accessor), accessor.end - 1, ";".length, ts.Diagnostics._0_expected, "{"); + } + else if (accessor.typeParameters) { + return grammarErrorOnNode(accessor.name, ts.Diagnostics.An_accessor_cannot_have_type_parameters); + } + else if (kind === 145 /* GetAccessor */ && accessor.parameters.length) { + return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_get_accessor_cannot_have_parameters); + } + else if (kind === 146 /* SetAccessor */) { + if (accessor.type) { + return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_set_accessor_cannot_have_a_return_type_annotation); + } + else if (accessor.parameters.length !== 1) { + return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_set_accessor_must_have_exactly_one_parameter); + } + else { + var parameter = accessor.parameters[0]; + if (parameter.dotDotDotToken) { + return grammarErrorOnNode(parameter.dotDotDotToken, ts.Diagnostics.A_set_accessor_cannot_have_rest_parameter); + } + else if (parameter.flags & 2035 /* Modifier */) { + return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation); + } + else if (parameter.questionToken) { + return grammarErrorOnNode(parameter.questionToken, ts.Diagnostics.A_set_accessor_cannot_have_an_optional_parameter); + } + else if (parameter.initializer) { + return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_set_accessor_parameter_cannot_have_an_initializer); + } + } + } + } + function checkGrammarForNonSymbolComputedProperty(node, message) { + if (node.kind === 136 /* ComputedPropertyName */ && !ts.isWellKnownSymbolSyntactically(node.expression)) { + return grammarErrorOnNode(node, message); + } + } + function checkGrammarMethod(node) { + if (checkGrammarDisallowedModifiersOnObjectLiteralExpressionMethod(node) || + checkGrammarFunctionLikeDeclaration(node) || + checkGrammarForGenerator(node)) { + return true; + } + if (node.parent.kind === 165 /* ObjectLiteralExpression */) { + if (checkGrammarForInvalidQuestionMark(node, node.questionToken, ts.Diagnostics.A_class_member_cannot_be_declared_optional)) { + return true; + } + else if (node.body === undefined) { + return grammarErrorAtPos(getSourceFile(node), node.end - 1, ";".length, ts.Diagnostics._0_expected, "{"); + } + } + if (ts.isClassLike(node.parent)) { + if (checkGrammarForInvalidQuestionMark(node, node.questionToken, ts.Diagnostics.A_class_member_cannot_be_declared_optional)) { + return true; + } + // Technically, computed properties in ambient contexts is disallowed + // for property declarations and accessors too, not just methods. + // However, property declarations disallow computed names in general, + // and accessors are not allowed in ambient contexts in general, + // so this error only really matters for methods. + if (ts.isInAmbientContext(node)) { + return checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_an_ambient_context_must_directly_refer_to_a_built_in_symbol); + } + else if (!node.body) { + 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 === 215 /* InterfaceDeclaration */) { + return checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_an_interface_must_directly_refer_to_a_built_in_symbol); + } + else if (node.parent.kind === 155 /* TypeLiteral */) { + return checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_type_literal_must_directly_refer_to_a_built_in_symbol); + } + } + function checkGrammarBreakOrContinueStatement(node) { + var current = node; + while (current) { + if (ts.isFunctionLike(current)) { + return grammarErrorOnNode(node, ts.Diagnostics.Jump_target_cannot_cross_function_boundary); + } + switch (current.kind) { + case 207 /* LabeledStatement */: + if (node.label && current.label.text === node.label.text) { + // found matching label - verify that label usage is correct + // continue can only target labels that are on iteration statements + var isMisplacedContinueLabel = node.kind === 202 /* 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); + } + return false; + } + break; + case 206 /* SwitchStatement */: + if (node.kind === 203 /* BreakStatement */ && !node.label) { + // unlabeled break within switch statement - ok + return false; + } + break; + default: + if (ts.isIterationStatement(current, /*lookInLabeledStatement*/ false) && !node.label) { + // unlabeled break or continue within iteration statement - ok + return false; + } + break; + } + current = current.parent; + } + if (node.label) { + var message = node.kind === 203 /* BreakStatement */ + ? ts.Diagnostics.A_break_statement_can_only_jump_to_a_label_of_an_enclosing_statement + : ts.Diagnostics.A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement; + return grammarErrorOnNode(node, message); + } + else { + var message = node.kind === 203 /* BreakStatement */ + ? ts.Diagnostics.A_break_statement_can_only_be_used_within_an_enclosing_iteration_or_switch_statement + : ts.Diagnostics.A_continue_statement_can_only_be_used_within_an_enclosing_iteration_statement; + return grammarErrorOnNode(node, message); + } + } + function checkGrammarBindingElement(node) { + if (node.dotDotDotToken) { + var elements = node.parent.elements; + 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 === 162 /* ArrayBindingPattern */ || node.name.kind === 161 /* ObjectBindingPattern */) { + return grammarErrorOnNode(node.name, ts.Diagnostics.A_rest_element_cannot_contain_a_binding_pattern); + } + if (node.initializer) { + // Error on equals token which immediate precedes the initializer + return grammarErrorAtPos(ts.getSourceFileOfNode(node), node.initializer.pos - 1, 1, ts.Diagnostics.A_rest_element_cannot_have_an_initializer); + } + } + } + function checkGrammarVariableDeclaration(node) { + if (node.parent.parent.kind !== 200 /* ForInStatement */ && node.parent.parent.kind !== 201 /* ForOfStatement */) { + if (ts.isInAmbientContext(node)) { + if (node.initializer) { + // Error on equals token which immediate precedes the initializer + var equalsTokenLength = "=".length; + return grammarErrorAtPos(ts.getSourceFileOfNode(node), node.initializer.pos - equalsTokenLength, equalsTokenLength, ts.Diagnostics.Initializers_are_not_allowed_in_ambient_contexts); + } + } + else if (!node.initializer) { + if (ts.isBindingPattern(node.name) && !ts.isBindingPattern(node.parent)) { + return grammarErrorOnNode(node, ts.Diagnostics.A_destructuring_declaration_must_have_an_initializer); + } + if (ts.isConst(node)) { + return grammarErrorOnNode(node, ts.Diagnostics.const_declarations_must_be_initialized); + } + } + } + var checkLetConstNames = languageVersion >= 2 /* ES6 */ && (ts.isLet(node) || ts.isConst(node)); + // 1. LexicalDeclaration : LetOrConst BindingList ; + // It is a Syntax Error if the BoundNames of BindingList contains "let". + // 2. ForDeclaration: ForDeclaration : LetOrConst ForBinding + // It is a Syntax Error if the BoundNames of ForDeclaration contains "let". + // It is a SyntaxError if a VariableDeclaration or VariableDeclarationNoIn occurs within strict code + // and its Identifier is eval or arguments + return checkLetConstNames && checkGrammarNameInLetOrConstDeclarations(node.name); + } + function checkGrammarNameInLetOrConstDeclarations(name) { + if (name.kind === 69 /* Identifier */) { + if (name.text === "let") { + return grammarErrorOnNode(name, ts.Diagnostics.let_is_not_allowed_to_be_used_as_a_name_in_let_or_const_declarations); + } + } + else { + var elements = name.elements; + for (var _i = 0; _i < elements.length; _i++) { + var element = elements[_i]; + if (element.kind !== 187 /* OmittedExpression */) { + checkGrammarNameInLetOrConstDeclarations(element.name); + } + } + } + } + function checkGrammarVariableDeclarationList(declarationList) { + var declarations = declarationList.declarations; + if (checkGrammarForDisallowedTrailingComma(declarationList.declarations)) { + return true; + } + if (!declarationList.declarations.length) { + return grammarErrorAtPos(ts.getSourceFileOfNode(declarationList), declarations.pos, declarations.end - declarations.pos, ts.Diagnostics.Variable_declaration_list_cannot_be_empty); + } + } + function allowLetAndConstDeclarations(parent) { + switch (parent.kind) { + case 196 /* IfStatement */: + case 197 /* DoStatement */: + case 198 /* WhileStatement */: + case 205 /* WithStatement */: + case 199 /* ForStatement */: + case 200 /* ForInStatement */: + case 201 /* ForOfStatement */: + return false; + case 207 /* LabeledStatement */: + return allowLetAndConstDeclarations(parent.parent); + } + return true; + } + function checkGrammarForDisallowedLetOrConstStatement(node) { + if (!allowLetAndConstDeclarations(node.parent)) { + if (ts.isLet(node.declarationList)) { + return grammarErrorOnNode(node, ts.Diagnostics.let_declarations_can_only_be_declared_inside_a_block); + } + else if (ts.isConst(node.declarationList)) { + return grammarErrorOnNode(node, ts.Diagnostics.const_declarations_can_only_be_declared_inside_a_block); + } + } + } + function isIntegerLiteral(expression) { + if (expression.kind === 179 /* PrefixUnaryExpression */) { + var unaryExpression = expression; + if (unaryExpression.operator === 35 /* PlusToken */ || unaryExpression.operator === 36 /* MinusToken */) { + expression = unaryExpression.operand; + } + } + if (expression.kind === 8 /* NumericLiteral */) { + // Allows for scientific notation since literalExpression.text was formed by + // coercing a number to a string. Sometimes this coercion can yield a string + // in scientific notation. + // We also don't need special logic for hex because a hex integer is converted + // to decimal when it is coerced. + return /^[0-9]+([eE]\+?[0-9]+)?$/.test(expression.text); + } + return false; + } + function hasParseDiagnostics(sourceFile) { + return sourceFile.parseDiagnostics.length > 0; + } + function grammarErrorOnFirstToken(node, message, arg0, arg1, arg2) { + var sourceFile = ts.getSourceFileOfNode(node); + if (!hasParseDiagnostics(sourceFile)) { + var span = ts.getSpanOfTokenAtPosition(sourceFile, node.pos); + diagnostics.add(ts.createFileDiagnostic(sourceFile, span.start, span.length, message, arg0, arg1, arg2)); + return true; + } + } + function grammarErrorAtPos(sourceFile, start, length, message, arg0, arg1, arg2) { + if (!hasParseDiagnostics(sourceFile)) { + diagnostics.add(ts.createFileDiagnostic(sourceFile, start, length, message, arg0, arg1, arg2)); + return true; + } + } + function grammarErrorOnNode(node, message, arg0, arg1, arg2) { + var sourceFile = ts.getSourceFileOfNode(node); + if (!hasParseDiagnostics(sourceFile)) { + diagnostics.add(ts.createDiagnosticForNode(node, message, arg0, arg1, arg2)); + return true; + } + } + function isEvalOrArgumentsIdentifier(node) { + return node.kind === 69 /* Identifier */ && + (node.text === "eval" || node.text === "arguments"); + } + function checkGrammarConstructorTypeParameters(node) { + if (node.typeParameters) { + return grammarErrorAtPos(ts.getSourceFileOfNode(node), node.typeParameters.pos, node.typeParameters.end - node.typeParameters.pos, ts.Diagnostics.Type_parameters_cannot_appear_on_a_constructor_declaration); + } + } + function checkGrammarConstructorTypeAnnotation(node) { + if (node.type) { + return grammarErrorOnNode(node.type, ts.Diagnostics.Type_annotation_cannot_appear_on_a_constructor_declaration); + } + } + function checkGrammarProperty(node) { + if (ts.isClassLike(node.parent)) { + if (checkGrammarForInvalidQuestionMark(node, node.questionToken, ts.Diagnostics.A_class_member_cannot_be_declared_optional) || + checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_class_property_declaration_must_directly_refer_to_a_built_in_symbol)) { + return true; + } + } + else if (node.parent.kind === 215 /* InterfaceDeclaration */) { + if (checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_an_interface_must_directly_refer_to_a_built_in_symbol)) { + return true; + } + } + else if (node.parent.kind === 155 /* TypeLiteral */) { + if (checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_type_literal_must_directly_refer_to_a_built_in_symbol)) { + return true; + } + } + if (ts.isInAmbientContext(node) && node.initializer) { + return grammarErrorOnFirstToken(node.initializer, ts.Diagnostics.Initializers_are_not_allowed_in_ambient_contexts); + } + } + function checkGrammarTopLevelElementForRequiredDeclareModifier(node) { + // A declare modifier is required for any top level .d.ts declaration except export=, export default, + // interfaces and imports categories: + // + // DeclarationElement: + // ExportAssignment + // export_opt InterfaceDeclaration + // export_opt TypeAliasDeclaration + // export_opt ImportDeclaration + // export_opt ExternalImportDeclaration + // export_opt AmbientDeclaration + // + // TODO: The spec needs to be amended to reflect this grammar. + if (node.kind === 215 /* InterfaceDeclaration */ || + node.kind === 216 /* TypeAliasDeclaration */ || + node.kind === 222 /* ImportDeclaration */ || + node.kind === 221 /* ImportEqualsDeclaration */ || + node.kind === 228 /* ExportDeclaration */ || + node.kind === 227 /* ExportAssignment */ || + (node.flags & 2 /* Ambient */) || + (node.flags & (1 /* Export */ | 1024 /* Default */))) { + return false; + } + return grammarErrorOnFirstToken(node, ts.Diagnostics.A_declare_modifier_is_required_for_a_top_level_declaration_in_a_d_ts_file); + } + function checkGrammarTopLevelElementsForRequiredDeclareModifier(file) { + for (var _i = 0, _a = file.statements; _i < _a.length; _i++) { + var decl = _a[_i]; + if (ts.isDeclaration(decl) || decl.kind === 193 /* VariableStatement */) { + if (checkGrammarTopLevelElementForRequiredDeclareModifier(decl)) { + return true; + } + } + } + } + function checkGrammarSourceFile(node) { + return ts.isInAmbientContext(node) && checkGrammarTopLevelElementsForRequiredDeclareModifier(node); + } + function checkGrammarStatementInAmbientContext(node) { + if (ts.isInAmbientContext(node)) { + // An accessors is already reported about the ambient context + if (isAccessor(node.parent.kind)) { + return getNodeLinks(node).hasReportedStatementInAmbientContext = true; + } + // Find containing block which is either Block, ModuleBlock, SourceFile + var links = getNodeLinks(node); + if (!links.hasReportedStatementInAmbientContext && ts.isFunctionLike(node.parent)) { + return getNodeLinks(node).hasReportedStatementInAmbientContext = grammarErrorOnFirstToken(node, ts.Diagnostics.An_implementation_cannot_be_declared_in_ambient_contexts); + } + // We are either parented by another statement, or some sort of block. + // If we're in a block, we only want to really report an error once + // to prevent noisyness. So use a bit on the block to indicate if + // this has already been reported, and don't report if it has. + // + if (node.parent.kind === 192 /* Block */ || node.parent.kind === 219 /* ModuleBlock */ || node.parent.kind === 248 /* SourceFile */) { + var links_1 = getNodeLinks(node.parent); + // Check if the containing block ever report this error + if (!links_1.hasReportedStatementInAmbientContext) { + return links_1.hasReportedStatementInAmbientContext = grammarErrorOnFirstToken(node, ts.Diagnostics.Statements_are_not_allowed_in_ambient_contexts); + } + } + else { + } + } + } + function checkGrammarNumericLiteral(node) { + // Grammar checking + if (node.flags & 65536 /* OctalLiteral */ && languageVersion >= 1 /* ES5 */) { + return grammarErrorOnNode(node, ts.Diagnostics.Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher); + } + } + function grammarErrorAfterFirstToken(node, message, arg0, arg1, arg2) { + var sourceFile = ts.getSourceFileOfNode(node); + if (!hasParseDiagnostics(sourceFile)) { + var span = ts.getSpanOfTokenAtPosition(sourceFile, node.pos); + diagnostics.add(ts.createFileDiagnostic(sourceFile, ts.textSpanEnd(span), /*length*/ 0, message, arg0, arg1, arg2)); + return true; + } + } + } + ts.createTypeChecker = createTypeChecker; +})(ts || (ts = {})); +/// +/* @internal */ +var ts; +(function (ts) { + function getDeclarationDiagnostics(host, resolver, targetSourceFile) { + var diagnostics = []; + var jsFilePath = ts.getOwnEmitOutputFilePath(targetSourceFile, host, ".js"); + emitDeclarations(host, resolver, diagnostics, jsFilePath, targetSourceFile); + return diagnostics; + } + ts.getDeclarationDiagnostics = getDeclarationDiagnostics; + function emitDeclarations(host, resolver, diagnostics, jsFilePath, root) { + var newLine = host.getNewLine(); + var compilerOptions = host.getCompilerOptions(); + var write; + var writeLine; + var increaseIndent; + var decreaseIndent; + var writeTextOfNode; + var writer = createAndSetNewTextWriterWithSymbolWriter(); + var enclosingDeclaration; + var currentSourceFile; + var reportedDeclarationError = false; + var errorNameNode; + var emitJsDocComments = compilerOptions.removeComments ? function (declaration) { } : writeJsDocComments; + var emit = compilerOptions.stripInternal ? stripInternal : emitNode; + var moduleElementDeclarationEmitInfo = []; + var asynchronousSubModuleDeclarationEmitInfo; + // Contains the reference paths that needs to go in the declaration file. + // Collecting this separately because reference paths need to be first thing in the declaration file + // and we could be collecting these paths from multiple files into single one with --out option + var referencePathsOutput = ""; + if (root) { + // Emitting just a single file, so emit references in this file only + if (!compilerOptions.noResolve) { + var addedGlobalFileReference = false; + ts.forEach(root.referencedFiles, function (fileReference) { + var referencedFile = ts.tryResolveScriptReference(host, root, fileReference); + // All the references that are not going to be part of same file + if (referencedFile && ((referencedFile.flags & 8192 /* DeclarationFile */) || + ts.shouldEmitToOwnFile(referencedFile, compilerOptions) || + !addedGlobalFileReference)) { + writeReferencePath(referencedFile); + if (!ts.isExternalModuleOrDeclarationFile(referencedFile)) { + addedGlobalFileReference = true; + } + } + }); + } + emitSourceFile(root); + // create asynchronous output for the importDeclarations + if (moduleElementDeclarationEmitInfo.length) { + var oldWriter = writer; + ts.forEach(moduleElementDeclarationEmitInfo, function (aliasEmitInfo) { + if (aliasEmitInfo.isVisible) { + ts.Debug.assert(aliasEmitInfo.node.kind === 222 /* ImportDeclaration */); + createAndSetNewTextWriterWithSymbolWriter(); + ts.Debug.assert(aliasEmitInfo.indent === 0); + writeImportDeclaration(aliasEmitInfo.node); + aliasEmitInfo.asynchronousOutput = writer.getText(); + } + }); + setWriter(oldWriter); + } + } + else { + // Emit references corresponding to this file + var emittedReferencedFiles = []; + ts.forEach(host.getSourceFiles(), function (sourceFile) { + if (!ts.isExternalModuleOrDeclarationFile(sourceFile)) { + // Check what references need to be added + if (!compilerOptions.noResolve) { + ts.forEach(sourceFile.referencedFiles, function (fileReference) { + var referencedFile = ts.tryResolveScriptReference(host, sourceFile, fileReference); + // If the reference file is a declaration file or an external module, emit that reference + if (referencedFile && (ts.isExternalModuleOrDeclarationFile(referencedFile) && + !ts.contains(emittedReferencedFiles, referencedFile))) { + writeReferencePath(referencedFile); + emittedReferencedFiles.push(referencedFile); + } + }); + } + emitSourceFile(sourceFile); + } + }); + } + return { + reportedDeclarationError: reportedDeclarationError, + moduleElementDeclarationEmitInfo: moduleElementDeclarationEmitInfo, + synchronousDeclarationOutput: writer.getText(), + referencePathsOutput: referencePathsOutput + }; + function hasInternalAnnotation(range) { + var text = currentSourceFile.text; + var comment = text.substring(range.pos, range.end); + return comment.indexOf("@internal") >= 0; + } + function stripInternal(node) { + if (node) { + var leadingCommentRanges = ts.getLeadingCommentRanges(currentSourceFile.text, node.pos); + if (ts.forEach(leadingCommentRanges, hasInternalAnnotation)) { + return; + } + emitNode(node); + } + } + function createAndSetNewTextWriterWithSymbolWriter() { + var writer = ts.createTextWriter(newLine); + writer.trackSymbol = trackSymbol; + writer.reportInaccessibleThisError = reportInaccessibleThisError; + writer.writeKeyword = writer.write; + writer.writeOperator = writer.write; + writer.writePunctuation = writer.write; + writer.writeSpace = writer.write; + writer.writeStringLiteral = writer.writeLiteral; + writer.writeParameter = writer.write; + writer.writeSymbol = writer.write; + setWriter(writer); + return writer; + } + function setWriter(newWriter) { + writer = newWriter; + write = newWriter.write; + writeTextOfNode = newWriter.writeTextOfNode; + writeLine = newWriter.writeLine; + increaseIndent = newWriter.increaseIndent; + decreaseIndent = newWriter.decreaseIndent; + } + function writeAsynchronousModuleElements(nodes) { + var oldWriter = writer; + ts.forEach(nodes, function (declaration) { + var nodeToCheck; + if (declaration.kind === 211 /* VariableDeclaration */) { + nodeToCheck = declaration.parent.parent; + } + else if (declaration.kind === 225 /* NamedImports */ || declaration.kind === 226 /* ImportSpecifier */ || declaration.kind === 223 /* ImportClause */) { + ts.Debug.fail("We should be getting ImportDeclaration instead to write"); + } + else { + nodeToCheck = declaration; + } + var moduleElementEmitInfo = ts.forEach(moduleElementDeclarationEmitInfo, function (declEmitInfo) { return declEmitInfo.node === nodeToCheck ? declEmitInfo : undefined; }); + if (!moduleElementEmitInfo && asynchronousSubModuleDeclarationEmitInfo) { + moduleElementEmitInfo = ts.forEach(asynchronousSubModuleDeclarationEmitInfo, function (declEmitInfo) { return declEmitInfo.node === nodeToCheck ? declEmitInfo : undefined; }); + } + // If the alias was marked as not visible when we saw its declaration, we would have saved the aliasEmitInfo, but if we haven't yet visited the alias declaration + // then we don't need to write it at this point. We will write it when we actually see its declaration + // Eg. + // export function bar(a: foo.Foo) { } + // import foo = require("foo"); + // 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 === 222 /* ImportDeclaration */) { + // we have to create asynchronous output only after we have collected complete information + // because it is possible to enable multiple bindings as asynchronously visible + moduleElementEmitInfo.isVisible = true; + } + else { + createAndSetNewTextWriterWithSymbolWriter(); + for (var declarationIndent = moduleElementEmitInfo.indent; declarationIndent; declarationIndent--) { + increaseIndent(); + } + if (nodeToCheck.kind === 218 /* ModuleDeclaration */) { + ts.Debug.assert(asynchronousSubModuleDeclarationEmitInfo === undefined); + asynchronousSubModuleDeclarationEmitInfo = []; + } + writeModuleElement(nodeToCheck); + if (nodeToCheck.kind === 218 /* ModuleDeclaration */) { + moduleElementEmitInfo.subModuleElementDeclarationEmitInfo = asynchronousSubModuleDeclarationEmitInfo; + asynchronousSubModuleDeclarationEmitInfo = undefined; + } + moduleElementEmitInfo.asynchronousOutput = writer.getText(); + } + } + }); + setWriter(oldWriter); + } + function handleSymbolAccessibilityError(symbolAccesibilityResult) { + if (symbolAccesibilityResult.accessibility === 0 /* Accessible */) { + // write the aliases + if (symbolAccesibilityResult && symbolAccesibilityResult.aliasesToMakeVisible) { + writeAsynchronousModuleElements(symbolAccesibilityResult.aliasesToMakeVisible); + } + } + else { + // Report error + reportedDeclarationError = true; + var errorInfo = writer.getSymbolAccessibilityDiagnostic(symbolAccesibilityResult); + if (errorInfo) { + if (errorInfo.typeName) { + diagnostics.push(ts.createDiagnosticForNode(symbolAccesibilityResult.errorNode || errorInfo.errorNode, errorInfo.diagnosticMessage, ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, errorInfo.typeName), symbolAccesibilityResult.errorSymbolName, symbolAccesibilityResult.errorModuleName)); + } + else { + diagnostics.push(ts.createDiagnosticForNode(symbolAccesibilityResult.errorNode || errorInfo.errorNode, errorInfo.diagnosticMessage, symbolAccesibilityResult.errorSymbolName, symbolAccesibilityResult.errorModuleName)); + } + } + } + } + function trackSymbol(symbol, enclosingDeclaration, meaning) { + handleSymbolAccessibilityError(resolver.isSymbolAccessible(symbol, enclosingDeclaration, meaning)); + } + function reportInaccessibleThisError() { + if (errorNameNode) { + diagnostics.push(ts.createDiagnosticForNode(errorNameNode, ts.Diagnostics.The_inferred_type_of_0_references_an_inaccessible_this_type_A_type_annotation_is_necessary, ts.declarationNameToString(errorNameNode))); + } + } + function writeTypeOfDeclaration(declaration, type, getSymbolAccessibilityDiagnostic) { + writer.getSymbolAccessibilityDiagnostic = getSymbolAccessibilityDiagnostic; + write(": "); + if (type) { + // Write the type + emitType(type); + } + else { + errorNameNode = declaration.name; + resolver.writeTypeOfDeclaration(declaration, enclosingDeclaration, 2 /* UseTypeOfFunction */, writer); + errorNameNode = undefined; + } + } + function writeReturnTypeAtSignature(signature, getSymbolAccessibilityDiagnostic) { + writer.getSymbolAccessibilityDiagnostic = getSymbolAccessibilityDiagnostic; + write(": "); + if (signature.type) { + // Write the type + emitType(signature.type); + } + else { + errorNameNode = signature.name; + resolver.writeReturnTypeOfSignatureDeclaration(signature, enclosingDeclaration, 2 /* UseTypeOfFunction */, writer); + errorNameNode = undefined; + } + } + function emitLines(nodes) { + for (var _i = 0; _i < nodes.length; _i++) { + var node = nodes[_i]; + emit(node); + } + } + function emitSeparatedList(nodes, separator, eachNodeEmitFn, canEmitFn) { + var currentWriterPos = writer.getTextPos(); + for (var _i = 0; _i < nodes.length; _i++) { + var node = nodes[_i]; + if (!canEmitFn || canEmitFn(node)) { + if (currentWriterPos !== writer.getTextPos()) { + write(separator); + } + currentWriterPos = writer.getTextPos(); + eachNodeEmitFn(node); + } + } + } + function emitCommaList(nodes, eachNodeEmitFn, canEmitFn) { + emitSeparatedList(nodes, ", ", eachNodeEmitFn, canEmitFn); + } + function writeJsDocComments(declaration) { + if (declaration) { + var jsDocComments = ts.getJsDocComments(declaration, currentSourceFile); + ts.emitNewLineBeforeLeadingComments(currentSourceFile, writer, declaration, jsDocComments); + // jsDoc comments are emitted at /*leading comment1 */space/*leading comment*/space + ts.emitComments(currentSourceFile, writer, jsDocComments, /*trailingSeparator*/ true, newLine, ts.writeCommentRange); + } + } + function emitTypeWithNewGetSymbolAccessibilityDiagnostic(type, getSymbolAccessibilityDiagnostic) { + writer.getSymbolAccessibilityDiagnostic = getSymbolAccessibilityDiagnostic; + emitType(type); + } + function emitType(type) { + switch (type.kind) { + case 117 /* AnyKeyword */: + case 130 /* StringKeyword */: + case 128 /* NumberKeyword */: + case 120 /* BooleanKeyword */: + case 131 /* SymbolKeyword */: + case 103 /* VoidKeyword */: + case 97 /* ThisKeyword */: + case 9 /* StringLiteral */: + return writeTextOfNode(currentSourceFile, type); + case 188 /* ExpressionWithTypeArguments */: + return emitExpressionWithTypeArguments(type); + case 151 /* TypeReference */: + return emitTypeReference(type); + case 154 /* TypeQuery */: + return emitTypeQuery(type); + case 156 /* ArrayType */: + return emitArrayType(type); + case 157 /* TupleType */: + return emitTupleType(type); + case 158 /* UnionType */: + return emitUnionType(type); + case 159 /* IntersectionType */: + return emitIntersectionType(type); + case 160 /* ParenthesizedType */: + return emitParenType(type); + case 152 /* FunctionType */: + case 153 /* ConstructorType */: + return emitSignatureDeclarationWithJsDocComments(type); + case 155 /* TypeLiteral */: + return emitTypeLiteral(type); + case 69 /* Identifier */: + return emitEntityName(type); + case 135 /* QualifiedName */: + return emitEntityName(type); + case 150 /* TypePredicate */: + return emitTypePredicate(type); + } + function writeEntityName(entityName) { + if (entityName.kind === 69 /* Identifier */) { + writeTextOfNode(currentSourceFile, entityName); + } + else { + var left = entityName.kind === 135 /* QualifiedName */ ? entityName.left : entityName.expression; + var right = entityName.kind === 135 /* QualifiedName */ ? entityName.right : entityName.name; + writeEntityName(left); + write("."); + writeTextOfNode(currentSourceFile, right); + } + } + function emitEntityName(entityName) { + var visibilityResult = resolver.isEntityNameVisible(entityName, + // Aliases can be written asynchronously so use correct enclosing declaration + entityName.parent.kind === 221 /* ImportEqualsDeclaration */ ? entityName.parent : enclosingDeclaration); + handleSymbolAccessibilityError(visibilityResult); + writeEntityName(entityName); + } + function emitExpressionWithTypeArguments(node) { + if (ts.isSupportedExpressionWithTypeArguments(node)) { + ts.Debug.assert(node.expression.kind === 69 /* Identifier */ || node.expression.kind === 166 /* PropertyAccessExpression */); + emitEntityName(node.expression); + if (node.typeArguments) { + write("<"); + emitCommaList(node.typeArguments, emitType); + write(">"); + } + } + } + function emitTypeReference(type) { + emitEntityName(type.typeName); + if (type.typeArguments) { + write("<"); + emitCommaList(type.typeArguments, emitType); + write(">"); + } + } + function emitTypePredicate(type) { + writeTextOfNode(currentSourceFile, type.parameterName); + write(" is "); + emitType(type.type); + } + function emitTypeQuery(type) { + write("typeof "); + emitEntityName(type.exprName); + } + function emitArrayType(type) { + emitType(type.elementType); + write("[]"); + } + function emitTupleType(type) { + write("["); + emitCommaList(type.elementTypes, emitType); + write("]"); + } + function emitUnionType(type) { + emitSeparatedList(type.types, " | ", emitType); + } + function emitIntersectionType(type) { + emitSeparatedList(type.types, " & ", emitType); + } + function emitParenType(type) { + write("("); + emitType(type.type); + write(")"); + } + function emitTypeLiteral(type) { + write("{"); + if (type.members.length) { + writeLine(); + increaseIndent(); + // write members + emitLines(type.members); + decreaseIndent(); + } + write("}"); + } + } + function emitSourceFile(node) { + currentSourceFile = node; + enclosingDeclaration = node; + emitLines(node.statements); + } + // Return a temp variable name to be used in `export default` statements. + // The temp name will be of the form _default_counter. + // Note that export default is only allowed at most once in a module, so we + // do not need to keep track of created temp names. + function getExportDefaultTempVariableName() { + var baseName = "_default"; + if (!ts.hasProperty(currentSourceFile.identifiers, baseName)) { + return baseName; + } + var count = 0; + while (true) { + var name_18 = baseName + "_" + (++count); + if (!ts.hasProperty(currentSourceFile.identifiers, name_18)) { + return name_18; + } + } + } + function emitExportAssignment(node) { + if (node.expression.kind === 69 /* Identifier */) { + write(node.isExportEquals ? "export = " : "export default "); + writeTextOfNode(currentSourceFile, node.expression); + } + else { + // Expression + var tempVarName = getExportDefaultTempVariableName(); + write("declare var "); + write(tempVarName); + write(": "); + writer.getSymbolAccessibilityDiagnostic = getDefaultExportAccessibilityDiagnostic; + resolver.writeTypeOfExpression(node.expression, enclosingDeclaration, 2 /* UseTypeOfFunction */, writer); + write(";"); + writeLine(); + write(node.isExportEquals ? "export = " : "export default "); + write(tempVarName); + } + write(";"); + writeLine(); + // Make all the declarations visible for the export name + if (node.expression.kind === 69 /* Identifier */) { + var nodes = resolver.collectLinkedAliases(node.expression); + // write each of these declarations asynchronously + writeAsynchronousModuleElements(nodes); + } + function getDefaultExportAccessibilityDiagnostic(diagnostic) { + return { + diagnosticMessage: ts.Diagnostics.Default_export_of_the_module_has_or_is_using_private_name_0, + errorNode: node + }; + } + } + function isModuleElementVisible(node) { + return resolver.isDeclarationVisible(node); + } + function emitModuleElement(node, isModuleElementVisible) { + if (isModuleElementVisible) { + writeModuleElement(node); + } + else if (node.kind === 221 /* ImportEqualsDeclaration */ || + (node.parent.kind === 248 /* SourceFile */ && ts.isExternalModule(currentSourceFile))) { + var isVisible; + if (asynchronousSubModuleDeclarationEmitInfo && node.parent.kind !== 248 /* SourceFile */) { + // Import declaration of another module that is visited async so lets put it in right spot + asynchronousSubModuleDeclarationEmitInfo.push({ + node: node, + outputPos: writer.getTextPos(), + indent: writer.getIndent(), + isVisible: isVisible + }); + } + else { + if (node.kind === 222 /* ImportDeclaration */) { + var importDeclaration = node; + if (importDeclaration.importClause) { + isVisible = (importDeclaration.importClause.name && resolver.isDeclarationVisible(importDeclaration.importClause)) || + isVisibleNamedBinding(importDeclaration.importClause.namedBindings); + } + } + moduleElementDeclarationEmitInfo.push({ + node: node, + outputPos: writer.getTextPos(), + indent: writer.getIndent(), + isVisible: isVisible + }); + } + } + } + function writeModuleElement(node) { + switch (node.kind) { + case 213 /* FunctionDeclaration */: + return writeFunctionDeclaration(node); + case 193 /* VariableStatement */: + return writeVariableStatement(node); + case 215 /* InterfaceDeclaration */: + return writeInterfaceDeclaration(node); + case 214 /* ClassDeclaration */: + return writeClassDeclaration(node); + case 216 /* TypeAliasDeclaration */: + return writeTypeAliasDeclaration(node); + case 217 /* EnumDeclaration */: + return writeEnumDeclaration(node); + case 218 /* ModuleDeclaration */: + return writeModuleDeclaration(node); + case 221 /* ImportEqualsDeclaration */: + return writeImportEqualsDeclaration(node); + case 222 /* ImportDeclaration */: + return writeImportDeclaration(node); + default: + ts.Debug.fail("Unknown symbol kind"); + } + } + function emitModuleElementDeclarationFlags(node) { + // If the node is parented in the current source file we need to emit export declare or just export + if (node.parent === currentSourceFile) { + // If the node is exported + if (node.flags & 1 /* Export */) { + write("export "); + } + if (node.flags & 1024 /* Default */) { + write("default "); + } + else if (node.kind !== 215 /* InterfaceDeclaration */) { + write("declare "); + } + } + } + function emitClassMemberDeclarationFlags(node) { + if (node.flags & 32 /* Private */) { + write("private "); + } + else if (node.flags & 64 /* Protected */) { + write("protected "); + } + if (node.flags & 128 /* Static */) { + write("static "); + } + if (node.flags & 256 /* Abstract */) { + write("abstract "); + } + } + function writeImportEqualsDeclaration(node) { + // note usage of writer. methods instead of aliases created, just to make sure we are using + // correct writer especially to handle asynchronous alias writing + emitJsDocComments(node); + if (node.flags & 1 /* Export */) { + write("export "); + } + write("import "); + writeTextOfNode(currentSourceFile, node.name); + write(" = "); + if (ts.isInternalModuleImportEqualsDeclaration(node)) { + emitTypeWithNewGetSymbolAccessibilityDiagnostic(node.moduleReference, getImportEntityNameVisibilityError); + write(";"); + } + else { + write("require("); + writeTextOfNode(currentSourceFile, ts.getExternalModuleImportEqualsDeclarationExpression(node)); + write(");"); + } + writer.writeLine(); + function getImportEntityNameVisibilityError(symbolAccesibilityResult) { + return { + diagnosticMessage: ts.Diagnostics.Import_declaration_0_is_using_private_name_1, + errorNode: node, + typeName: node.name + }; + } + } + function isVisibleNamedBinding(namedBindings) { + if (namedBindings) { + if (namedBindings.kind === 224 /* NamespaceImport */) { + return resolver.isDeclarationVisible(namedBindings); + } + else { + return ts.forEach(namedBindings.elements, function (namedImport) { return resolver.isDeclarationVisible(namedImport); }); + } + } + } + function writeImportDeclaration(node) { + if (!node.importClause && !(node.flags & 1 /* Export */)) { + // do not write non-exported import declarations that don't have import clauses + return; + } + emitJsDocComments(node); + if (node.flags & 1 /* Export */) { + write("export "); + } + write("import "); + if (node.importClause) { + var currentWriterPos = writer.getTextPos(); + if (node.importClause.name && resolver.isDeclarationVisible(node.importClause)) { + writeTextOfNode(currentSourceFile, node.importClause.name); + } + if (node.importClause.namedBindings && isVisibleNamedBinding(node.importClause.namedBindings)) { + if (currentWriterPos !== writer.getTextPos()) { + // If the default binding was emitted, write the separated + write(", "); + } + if (node.importClause.namedBindings.kind === 224 /* NamespaceImport */) { + write("* as "); + writeTextOfNode(currentSourceFile, node.importClause.namedBindings.name); + } + else { + write("{ "); + emitCommaList(node.importClause.namedBindings.elements, emitImportOrExportSpecifier, resolver.isDeclarationVisible); + write(" }"); + } + } + write(" from "); + } + writeTextOfNode(currentSourceFile, node.moduleSpecifier); + write(";"); + writer.writeLine(); + } + function emitImportOrExportSpecifier(node) { + if (node.propertyName) { + writeTextOfNode(currentSourceFile, node.propertyName); + write(" as "); + } + writeTextOfNode(currentSourceFile, node.name); + } + function emitExportSpecifier(node) { + emitImportOrExportSpecifier(node); + // Make all the declarations visible for the export name + var nodes = resolver.collectLinkedAliases(node.propertyName || node.name); + // write each of these declarations asynchronously + writeAsynchronousModuleElements(nodes); + } + function emitExportDeclaration(node) { + emitJsDocComments(node); + write("export "); + if (node.exportClause) { + write("{ "); + emitCommaList(node.exportClause.elements, emitExportSpecifier); + write(" }"); + } + else { + write("*"); + } + if (node.moduleSpecifier) { + write(" from "); + writeTextOfNode(currentSourceFile, node.moduleSpecifier); + } + write(";"); + writer.writeLine(); + } + function writeModuleDeclaration(node) { + emitJsDocComments(node); + emitModuleElementDeclarationFlags(node); + if (node.flags & 131072 /* Namespace */) { + write("namespace "); + } + else { + write("module "); + } + writeTextOfNode(currentSourceFile, node.name); + while (node.body.kind !== 219 /* ModuleBlock */) { + node = node.body; + write("."); + writeTextOfNode(currentSourceFile, node.name); + } + var prevEnclosingDeclaration = enclosingDeclaration; + enclosingDeclaration = node; + write(" {"); + writeLine(); + increaseIndent(); + emitLines(node.body.statements); + decreaseIndent(); + write("}"); + writeLine(); + enclosingDeclaration = prevEnclosingDeclaration; + } + function writeTypeAliasDeclaration(node) { + var prevEnclosingDeclaration = enclosingDeclaration; + enclosingDeclaration = node; + emitJsDocComments(node); + emitModuleElementDeclarationFlags(node); + write("type "); + writeTextOfNode(currentSourceFile, node.name); + emitTypeParameters(node.typeParameters); + write(" = "); + emitTypeWithNewGetSymbolAccessibilityDiagnostic(node.type, getTypeAliasDeclarationVisibilityError); + write(";"); + writeLine(); + enclosingDeclaration = prevEnclosingDeclaration; + function getTypeAliasDeclarationVisibilityError(symbolAccesibilityResult) { + return { + diagnosticMessage: ts.Diagnostics.Exported_type_alias_0_has_or_is_using_private_name_1, + errorNode: node.type, + typeName: node.name + }; + } + } + function writeEnumDeclaration(node) { + emitJsDocComments(node); + emitModuleElementDeclarationFlags(node); + if (ts.isConst(node)) { + write("const "); + } + write("enum "); + writeTextOfNode(currentSourceFile, node.name); + write(" {"); + writeLine(); + increaseIndent(); + emitLines(node.members); + decreaseIndent(); + write("}"); + writeLine(); + } + function emitEnumMemberDeclaration(node) { + emitJsDocComments(node); + writeTextOfNode(currentSourceFile, node.name); + var enumMemberValue = resolver.getConstantValue(node); + if (enumMemberValue !== undefined) { + write(" = "); + write(enumMemberValue.toString()); + } + write(","); + writeLine(); + } + function isPrivateMethodTypeParameter(node) { + return node.parent.kind === 143 /* MethodDeclaration */ && (node.parent.flags & 32 /* Private */); + } + function emitTypeParameters(typeParameters) { + function emitTypeParameter(node) { + increaseIndent(); + emitJsDocComments(node); + decreaseIndent(); + writeTextOfNode(currentSourceFile, node.name); + // 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 === 152 /* FunctionType */ || + node.parent.kind === 153 /* ConstructorType */ || + (node.parent.parent && node.parent.parent.kind === 155 /* TypeLiteral */)) { + ts.Debug.assert(node.parent.kind === 143 /* MethodDeclaration */ || + node.parent.kind === 142 /* MethodSignature */ || + node.parent.kind === 152 /* FunctionType */ || + node.parent.kind === 153 /* ConstructorType */ || + node.parent.kind === 147 /* CallSignature */ || + node.parent.kind === 148 /* ConstructSignature */); + emitType(node.constraint); + } + else { + emitTypeWithNewGetSymbolAccessibilityDiagnostic(node.constraint, getTypeParameterConstraintVisibilityError); + } + } + function getTypeParameterConstraintVisibilityError(symbolAccesibilityResult) { + // Type parameter constraints are named by user so we should always be able to name it + var diagnosticMessage; + switch (node.parent.kind) { + case 214 /* ClassDeclaration */: + diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_class_has_or_is_using_private_name_1; + break; + case 215 /* InterfaceDeclaration */: + diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1; + break; + case 148 /* ConstructSignature */: + diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; + break; + case 147 /* CallSignature */: + diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; + break; + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: + if (node.parent.flags & 128 /* Static */) { + diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1; + } + else if (node.parent.parent.kind === 214 /* ClassDeclaration */) { + diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_public_method_from_exported_class_has_or_is_using_private_name_1; + } + else { + diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1; + } + break; + case 213 /* FunctionDeclaration */: + diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_function_has_or_is_using_private_name_1; + break; + default: + ts.Debug.fail("This is unknown parent for type parameter: " + node.parent.kind); + } + return { + diagnosticMessage: diagnosticMessage, + errorNode: node, + typeName: node.name + }; + } + } + if (typeParameters) { + write("<"); + emitCommaList(typeParameters, emitTypeParameter); + write(">"); + } + } + function emitHeritageClause(typeReferences, isImplementsList) { + if (typeReferences) { + write(isImplementsList ? " implements " : " extends "); + emitCommaList(typeReferences, emitTypeOfTypeReference); + } + function emitTypeOfTypeReference(node) { + if (ts.isSupportedExpressionWithTypeArguments(node)) { + emitTypeWithNewGetSymbolAccessibilityDiagnostic(node, getHeritageClauseVisibilityError); + } + else if (!isImplementsList && node.expression.kind === 93 /* NullKeyword */) { + write("null"); + } + function getHeritageClauseVisibilityError(symbolAccesibilityResult) { + var diagnosticMessage; + // Heritage clause is written by user so it can always be named + if (node.parent.parent.kind === 214 /* ClassDeclaration */) { + // Class or Interface implemented/extended is inaccessible + diagnosticMessage = isImplementsList ? + ts.Diagnostics.Implements_clause_of_exported_class_0_has_or_is_using_private_name_1 : + ts.Diagnostics.Extends_clause_of_exported_class_0_has_or_is_using_private_name_1; + } + else { + // interface is inaccessible + diagnosticMessage = ts.Diagnostics.Extends_clause_of_exported_interface_0_has_or_is_using_private_name_1; + } + return { + diagnosticMessage: diagnosticMessage, + errorNode: node, + typeName: node.parent.parent.name + }; + } + } + } + function writeClassDeclaration(node) { + function emitParameterProperties(constructorDeclaration) { + if (constructorDeclaration) { + ts.forEach(constructorDeclaration.parameters, function (param) { + if (param.flags & 112 /* AccessibilityModifier */) { + emitPropertyDeclaration(param); + } + }); + } + } + emitJsDocComments(node); + emitModuleElementDeclarationFlags(node); + if (node.flags & 256 /* Abstract */) { + write("abstract "); + } + write("class "); + writeTextOfNode(currentSourceFile, node.name); + var prevEnclosingDeclaration = enclosingDeclaration; + enclosingDeclaration = node; + emitTypeParameters(node.typeParameters); + var baseTypeNode = ts.getClassExtendsHeritageClauseElement(node); + if (baseTypeNode) { + emitHeritageClause([baseTypeNode], /*isImplementsList*/ false); + } + emitHeritageClause(ts.getClassImplementsHeritageClauseElements(node), /*isImplementsList*/ true); + write(" {"); + writeLine(); + increaseIndent(); + emitParameterProperties(ts.getFirstConstructorWithBody(node)); + emitLines(node.members); + decreaseIndent(); + write("}"); + writeLine(); + enclosingDeclaration = prevEnclosingDeclaration; + } + function writeInterfaceDeclaration(node) { + emitJsDocComments(node); + emitModuleElementDeclarationFlags(node); + write("interface "); + writeTextOfNode(currentSourceFile, node.name); + var prevEnclosingDeclaration = enclosingDeclaration; + enclosingDeclaration = node; + emitTypeParameters(node.typeParameters); + emitHeritageClause(ts.getInterfaceBaseTypeNodes(node), /*isImplementsList*/ false); + write(" {"); + writeLine(); + increaseIndent(); + emitLines(node.members); + decreaseIndent(); + write("}"); + writeLine(); + enclosingDeclaration = prevEnclosingDeclaration; + } + function emitPropertyDeclaration(node) { + if (ts.hasDynamicName(node)) { + return; + } + emitJsDocComments(node); + emitClassMemberDeclarationFlags(node); + emitVariableDeclaration(node); + write(";"); + writeLine(); + } + 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 !== 211 /* VariableDeclaration */ || resolver.isDeclarationVisible(node)) { + if (ts.isBindingPattern(node.name)) { + emitBindingPattern(node.name); + } + else { + // If this node is a computed name, it can only be a symbol, because we've already skipped + // it if it's not a well known symbol. In that case, the text of the name will be exactly + // what we want, namely the name expression enclosed in brackets. + writeTextOfNode(currentSourceFile, node.name); + // If optional property emit ? + if ((node.kind === 141 /* PropertyDeclaration */ || node.kind === 140 /* PropertySignature */) && ts.hasQuestionToken(node)) { + write("?"); + } + if ((node.kind === 141 /* PropertyDeclaration */ || node.kind === 140 /* PropertySignature */) && node.parent.kind === 155 /* TypeLiteral */) { + emitTypeOfVariableDeclarationFromTypeLiteral(node); + } + else if (!(node.flags & 32 /* Private */)) { + writeTypeOfDeclaration(node, node.type, getVariableDeclarationTypeVisibilityError); + } + } + } + function getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccesibilityResult) { + if (node.kind === 211 /* VariableDeclaration */) { + return symbolAccesibilityResult.errorModuleName ? + symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? + ts.Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : + ts.Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_private_module_2 : + ts.Diagnostics.Exported_variable_0_has_or_is_using_private_name_1; + } + else if (node.kind === 141 /* PropertyDeclaration */ || node.kind === 140 /* PropertySignature */) { + // TODO(jfreeman): Deal with computed properties in error reporting. + if (node.flags & 128 /* Static */) { + return symbolAccesibilityResult.errorModuleName ? + symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? + ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : + ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : + ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_private_name_1; + } + else if (node.parent.kind === 214 /* ClassDeclaration */) { + return symbolAccesibilityResult.errorModuleName ? + symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? + ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : + ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : + ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_private_name_1; + } + else { + // Interfaces cannot have types that cannot be named + return symbolAccesibilityResult.errorModuleName ? + ts.Diagnostics.Property_0_of_exported_interface_has_or_is_using_name_1_from_private_module_2 : + ts.Diagnostics.Property_0_of_exported_interface_has_or_is_using_private_name_1; + } + } + } + function getVariableDeclarationTypeVisibilityError(symbolAccesibilityResult) { + var diagnosticMessage = getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccesibilityResult); + return diagnosticMessage !== undefined ? { + diagnosticMessage: diagnosticMessage, + errorNode: node, + typeName: node.name + } : undefined; + } + function emitBindingPattern(bindingPattern) { + // Only select non-omitted expression from the bindingPattern's elements. + // We have to do this to avoid emitting trailing commas. + // For example: + // original: var [, c,,] = [ 2,3,4] + // emitted: declare var c: number; // instead of declare var c:number, ; + var elements = []; + for (var _i = 0, _a = bindingPattern.elements; _i < _a.length; _i++) { + var element = _a[_i]; + if (element.kind !== 187 /* OmittedExpression */) { + elements.push(element); + } + } + emitCommaList(elements, emitBindingElement); + } + function emitBindingElement(bindingElement) { + function getBindingElementTypeVisibilityError(symbolAccesibilityResult) { + var diagnosticMessage = getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccesibilityResult); + return diagnosticMessage !== undefined ? { + diagnosticMessage: diagnosticMessage, + errorNode: bindingElement, + typeName: bindingElement.name + } : undefined; + } + if (bindingElement.name) { + if (ts.isBindingPattern(bindingElement.name)) { + emitBindingPattern(bindingElement.name); + } + else { + writeTextOfNode(currentSourceFile, bindingElement.name); + writeTypeOfDeclaration(bindingElement, /*type*/ undefined, getBindingElementTypeVisibilityError); + } + } + } + } + function emitTypeOfVariableDeclarationFromTypeLiteral(node) { + // if this is property of type literal, + // or is parameter of method/call/construct/index signature of type literal + // emit only if type is specified + if (node.type) { + write(": "); + emitType(node.type); + } + } + function isVariableStatementVisible(node) { + return ts.forEach(node.declarationList.declarations, function (varDeclaration) { return resolver.isDeclarationVisible(varDeclaration); }); + } + function writeVariableStatement(node) { + emitJsDocComments(node); + emitModuleElementDeclarationFlags(node); + if (ts.isLet(node.declarationList)) { + write("let "); + } + else if (ts.isConst(node.declarationList)) { + write("const "); + } + else { + write("var "); + } + emitCommaList(node.declarationList.declarations, emitVariableDeclaration, resolver.isDeclarationVisible); + write(";"); + writeLine(); + } + function emitAccessorDeclaration(node) { + if (ts.hasDynamicName(node)) { + return; + } + var accessors = ts.getAllAccessorDeclarations(node.parent.members, node); + var accessorWithTypeAnnotation; + if (node === accessors.firstAccessor) { + emitJsDocComments(accessors.getAccessor); + emitJsDocComments(accessors.setAccessor); + emitClassMemberDeclarationFlags(node); + writeTextOfNode(currentSourceFile, node.name); + if (!(node.flags & 32 /* Private */)) { + accessorWithTypeAnnotation = node; + var type = getTypeAnnotationFromAccessor(node); + if (!type) { + // couldn't get type for the first accessor, try the another one + var anotherAccessor = node.kind === 145 /* GetAccessor */ ? accessors.setAccessor : accessors.getAccessor; + type = getTypeAnnotationFromAccessor(anotherAccessor); + if (type) { + accessorWithTypeAnnotation = anotherAccessor; + } + } + writeTypeOfDeclaration(node, type, getAccessorDeclarationTypeVisibilityError); + } + write(";"); + writeLine(); + } + function getTypeAnnotationFromAccessor(accessor) { + if (accessor) { + return accessor.kind === 145 /* GetAccessor */ + ? accessor.type // Getter - return type + : accessor.parameters.length > 0 + ? accessor.parameters[0].type // Setter parameter type + : undefined; + } + } + function getAccessorDeclarationTypeVisibilityError(symbolAccesibilityResult) { + var diagnosticMessage; + if (accessorWithTypeAnnotation.kind === 146 /* SetAccessor */) { + // Setters have to have type named and cannot infer it so, the type should always be named + if (accessorWithTypeAnnotation.parent.flags & 128 /* Static */) { + diagnosticMessage = symbolAccesibilityResult.errorModuleName ? + ts.Diagnostics.Parameter_0_of_public_static_property_setter_from_exported_class_has_or_is_using_name_1_from_private_module_2 : + ts.Diagnostics.Parameter_0_of_public_static_property_setter_from_exported_class_has_or_is_using_private_name_1; + } + else { + diagnosticMessage = symbolAccesibilityResult.errorModuleName ? + ts.Diagnostics.Parameter_0_of_public_property_setter_from_exported_class_has_or_is_using_name_1_from_private_module_2 : + ts.Diagnostics.Parameter_0_of_public_property_setter_from_exported_class_has_or_is_using_private_name_1; + } + return { + diagnosticMessage: diagnosticMessage, + errorNode: accessorWithTypeAnnotation.parameters[0], + // TODO(jfreeman): Investigate why we are passing node.name instead of node.parameters[0].name + typeName: accessorWithTypeAnnotation.name + }; + } + else { + if (accessorWithTypeAnnotation.flags & 128 /* Static */) { + diagnosticMessage = symbolAccesibilityResult.errorModuleName ? + symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? + ts.Diagnostics.Return_type_of_public_static_property_getter_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : + ts.Diagnostics.Return_type_of_public_static_property_getter_from_exported_class_has_or_is_using_name_0_from_private_module_1 : + ts.Diagnostics.Return_type_of_public_static_property_getter_from_exported_class_has_or_is_using_private_name_0; + } + else { + diagnosticMessage = symbolAccesibilityResult.errorModuleName ? + symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? + ts.Diagnostics.Return_type_of_public_property_getter_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : + ts.Diagnostics.Return_type_of_public_property_getter_from_exported_class_has_or_is_using_name_0_from_private_module_1 : + ts.Diagnostics.Return_type_of_public_property_getter_from_exported_class_has_or_is_using_private_name_0; + } + return { + diagnosticMessage: diagnosticMessage, + errorNode: accessorWithTypeAnnotation.name, + typeName: undefined + }; + } + } + } + function writeFunctionDeclaration(node) { + if (ts.hasDynamicName(node)) { + return; + } + // If we are emitting Method/Constructor it isn't moduleElement and hence already determined to be emitting + // so no need to verify if the declaration is visible + if (!resolver.isImplementationOfOverload(node)) { + emitJsDocComments(node); + if (node.kind === 213 /* FunctionDeclaration */) { + emitModuleElementDeclarationFlags(node); + } + else if (node.kind === 143 /* MethodDeclaration */) { + emitClassMemberDeclarationFlags(node); + } + if (node.kind === 213 /* FunctionDeclaration */) { + write("function "); + writeTextOfNode(currentSourceFile, node.name); + } + else if (node.kind === 144 /* Constructor */) { + write("constructor"); + } + else { + writeTextOfNode(currentSourceFile, node.name); + if (ts.hasQuestionToken(node)) { + write("?"); + } + } + emitSignatureDeclaration(node); + } + } + function emitSignatureDeclarationWithJsDocComments(node) { + emitJsDocComments(node); + emitSignatureDeclaration(node); + } + function emitSignatureDeclaration(node) { + // Construct signature or constructor type write new Signature + if (node.kind === 148 /* ConstructSignature */ || node.kind === 153 /* ConstructorType */) { + write("new "); + } + emitTypeParameters(node.typeParameters); + if (node.kind === 149 /* IndexSignature */) { + write("["); + } + else { + write("("); + } + var prevEnclosingDeclaration = enclosingDeclaration; + enclosingDeclaration = node; + // Parameters + emitCommaList(node.parameters, emitParameterDeclaration); + if (node.kind === 149 /* IndexSignature */) { + write("]"); + } + else { + write(")"); + } + // If this is not a constructor and is not private, emit the return type + var isFunctionTypeOrConstructorType = node.kind === 152 /* FunctionType */ || node.kind === 153 /* ConstructorType */; + if (isFunctionTypeOrConstructorType || node.parent.kind === 155 /* TypeLiteral */) { + // Emit type literal signature return type only if specified + if (node.type) { + write(isFunctionTypeOrConstructorType ? " => " : ": "); + emitType(node.type); + } + } + else if (node.kind !== 144 /* Constructor */ && !(node.flags & 32 /* Private */)) { + writeReturnTypeAtSignature(node, getReturnTypeVisibilityError); + } + enclosingDeclaration = prevEnclosingDeclaration; + if (!isFunctionTypeOrConstructorType) { + write(";"); + writeLine(); + } + function getReturnTypeVisibilityError(symbolAccesibilityResult) { + var diagnosticMessage; + switch (node.kind) { + case 148 /* ConstructSignature */: + // Interfaces cannot have return types that cannot be named + diagnosticMessage = symbolAccesibilityResult.errorModuleName ? + ts.Diagnostics.Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : + ts.Diagnostics.Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_0; + break; + case 147 /* CallSignature */: + // Interfaces cannot have return types that cannot be named + diagnosticMessage = symbolAccesibilityResult.errorModuleName ? + ts.Diagnostics.Return_type_of_call_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : + ts.Diagnostics.Return_type_of_call_signature_from_exported_interface_has_or_is_using_private_name_0; + break; + case 149 /* IndexSignature */: + // Interfaces cannot have return types that cannot be named + diagnosticMessage = symbolAccesibilityResult.errorModuleName ? + ts.Diagnostics.Return_type_of_index_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : + ts.Diagnostics.Return_type_of_index_signature_from_exported_interface_has_or_is_using_private_name_0; + break; + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: + if (node.flags & 128 /* Static */) { + diagnosticMessage = symbolAccesibilityResult.errorModuleName ? + symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? + ts.Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : + 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 === 214 /* ClassDeclaration */) { + diagnosticMessage = symbolAccesibilityResult.errorModuleName ? + symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? + ts.Diagnostics.Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : + ts.Diagnostics.Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_private_module_1 : + ts.Diagnostics.Return_type_of_public_method_from_exported_class_has_or_is_using_private_name_0; + } + else { + // Interfaces cannot have return types that cannot be named + diagnosticMessage = symbolAccesibilityResult.errorModuleName ? + ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : + ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0; + } + break; + case 213 /* FunctionDeclaration */: + diagnosticMessage = symbolAccesibilityResult.errorModuleName ? + symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? + ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : + ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_name_0_from_private_module_1 : + ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_private_name_0; + break; + default: + ts.Debug.fail("This is unknown kind for signature: " + node.kind); + } + return { + diagnosticMessage: diagnosticMessage, + errorNode: node.name || node + }; + } + } + function emitParameterDeclaration(node) { + increaseIndent(); + emitJsDocComments(node); + if (node.dotDotDotToken) { + write("..."); + } + if (ts.isBindingPattern(node.name)) { + // For bindingPattern, we can't simply writeTextOfNode from the source file + // because we want to omit the initializer and using writeTextOfNode will result in initializer get emitted. + // Therefore, we will have to recursively emit each element in the bindingPattern. + emitBindingPattern(node.name); + } + else { + writeTextOfNode(currentSourceFile, node.name); + } + if (resolver.isOptionalParameter(node)) { + write("?"); + } + decreaseIndent(); + if (node.parent.kind === 152 /* FunctionType */ || + node.parent.kind === 153 /* ConstructorType */ || + node.parent.parent.kind === 155 /* TypeLiteral */) { + emitTypeOfVariableDeclarationFromTypeLiteral(node); + } + else if (!(node.parent.flags & 32 /* Private */)) { + writeTypeOfDeclaration(node, node.type, getParameterDeclarationTypeVisibilityError); + } + function getParameterDeclarationTypeVisibilityError(symbolAccesibilityResult) { + var diagnosticMessage = getParameterDeclarationTypeVisibilityDiagnosticMessage(symbolAccesibilityResult); + return diagnosticMessage !== undefined ? { + diagnosticMessage: diagnosticMessage, + errorNode: node, + typeName: node.name + } : undefined; + } + function getParameterDeclarationTypeVisibilityDiagnosticMessage(symbolAccesibilityResult) { + switch (node.parent.kind) { + case 144 /* Constructor */: + return symbolAccesibilityResult.errorModuleName ? + symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? + ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : + ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_private_module_2 : + ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_private_name_1; + case 148 /* ConstructSignature */: + // Interfaces cannot have parameter types that cannot be named + return symbolAccesibilityResult.errorModuleName ? + ts.Diagnostics.Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : + ts.Diagnostics.Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; + case 147 /* CallSignature */: + // Interfaces cannot have parameter types that cannot be named + return symbolAccesibilityResult.errorModuleName ? + ts.Diagnostics.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : + ts.Diagnostics.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: + if (node.parent.flags & 128 /* Static */) { + return symbolAccesibilityResult.errorModuleName ? + symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? + ts.Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : + 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 === 214 /* ClassDeclaration */) { + return symbolAccesibilityResult.errorModuleName ? + symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? + ts.Diagnostics.Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : + ts.Diagnostics.Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_private_module_2 : + ts.Diagnostics.Parameter_0_of_public_method_from_exported_class_has_or_is_using_private_name_1; + } + else { + // Interfaces cannot have parameter types that cannot be named + return symbolAccesibilityResult.errorModuleName ? + 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 213 /* FunctionDeclaration */: + return symbolAccesibilityResult.errorModuleName ? + symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? + ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : + ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_name_1_from_private_module_2 : + ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_private_name_1; + default: + ts.Debug.fail("This is unknown parent for parameter: " + node.parent.kind); + } + } + function emitBindingPattern(bindingPattern) { + // We have to explicitly emit square bracket and bracket because these tokens are not store inside the node. + if (bindingPattern.kind === 161 /* ObjectBindingPattern */) { + write("{"); + emitCommaList(bindingPattern.elements, emitBindingElement); + write("}"); + } + else if (bindingPattern.kind === 162 /* ArrayBindingPattern */) { + write("["); + var elements = bindingPattern.elements; + emitCommaList(elements, emitBindingElement); + if (elements && elements.hasTrailingComma) { + write(", "); + } + write("]"); + } + } + function emitBindingElement(bindingElement) { + function getBindingElementTypeVisibilityError(symbolAccesibilityResult) { + var diagnosticMessage = getParameterDeclarationTypeVisibilityDiagnosticMessage(symbolAccesibilityResult); + return diagnosticMessage !== undefined ? { + diagnosticMessage: diagnosticMessage, + errorNode: bindingElement, + typeName: bindingElement.name + } : undefined; + } + if (bindingElement.kind === 187 /* OmittedExpression */) { + // If bindingElement is an omittedExpression (i.e. containing elision), + // we will emit blank space (although this may differ from users' original code, + // it allows emitSeparatedList to write separator appropriately) + // Example: + // original: function foo([, x, ,]) {} + // emit : function foo([ , x, , ]) {} + write(" "); + } + else if (bindingElement.kind === 163 /* BindingElement */) { + if (bindingElement.propertyName) { + // bindingElement has propertyName property in the following case: + // { y: [a,b,c] ...} -> bindingPattern will have a property called propertyName for "y" + // We have to explicitly emit the propertyName before descending into its binding elements. + // Example: + // original: function foo({y: [a,b,c]}) {} + // emit : declare function foo({y: [a, b, c]}: { y: [any, any, any] }) void; + writeTextOfNode(currentSourceFile, bindingElement.propertyName); + write(": "); + } + if (bindingElement.name) { + if (ts.isBindingPattern(bindingElement.name)) { + // If it is a nested binding pattern, we will recursively descend into each element and emit each one separately. + // In the case of rest element, we will omit rest element. + // Example: + // original: function foo([a, [[b]], c] = [1,[["string"]], 3]) {} + // emit : declare function foo([a, [[b]], c]: [number, [[string]], number]): void; + // original with rest: function foo([a, ...c]) {} + // emit : declare function foo([a, ...c]): void; + emitBindingPattern(bindingElement.name); + } + else { + ts.Debug.assert(bindingElement.name.kind === 69 /* Identifier */); + // If the node is just an identifier, we will simply emit the text associated with the node's name + // Example: + // original: function foo({y = 10, x}) {} + // emit : declare function foo({y, x}: {number, any}): void; + if (bindingElement.dotDotDotToken) { + write("..."); + } + writeTextOfNode(currentSourceFile, bindingElement.name); + } + } + } + } + } + function emitNode(node) { + switch (node.kind) { + case 213 /* FunctionDeclaration */: + case 218 /* ModuleDeclaration */: + case 221 /* ImportEqualsDeclaration */: + case 215 /* InterfaceDeclaration */: + case 214 /* ClassDeclaration */: + case 216 /* TypeAliasDeclaration */: + case 217 /* EnumDeclaration */: + return emitModuleElement(node, isModuleElementVisible(node)); + case 193 /* VariableStatement */: + return emitModuleElement(node, isVariableStatementVisible(node)); + case 222 /* ImportDeclaration */: + // Import declaration without import clause is visible, otherwise it is not visible + return emitModuleElement(node, /*isModuleElementVisible*/ !node.importClause); + case 228 /* ExportDeclaration */: + return emitExportDeclaration(node); + case 144 /* Constructor */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: + return writeFunctionDeclaration(node); + case 148 /* ConstructSignature */: + case 147 /* CallSignature */: + case 149 /* IndexSignature */: + return emitSignatureDeclarationWithJsDocComments(node); + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: + return emitAccessorDeclaration(node); + case 141 /* PropertyDeclaration */: + case 140 /* PropertySignature */: + return emitPropertyDeclaration(node); + case 247 /* EnumMember */: + return emitEnumMemberDeclaration(node); + case 227 /* ExportAssignment */: + return emitExportAssignment(node); + case 248 /* SourceFile */: + return emitSourceFile(node); + } + } + function writeReferencePath(referencedFile) { + var declFileName = referencedFile.flags & 8192 /* DeclarationFile */ + ? referencedFile.fileName // Declaration file, use declaration file name + : ts.shouldEmitToOwnFile(referencedFile, compilerOptions) + ? ts.getOwnEmitOutputFilePath(referencedFile, host, ".d.ts") // Own output file so get the .d.ts file + : ts.removeFileExtension(compilerOptions.outFile || compilerOptions.out) + ".d.ts"; // Global out file + declFileName = ts.getRelativePathToDirectoryOrUrl(ts.getDirectoryPath(ts.normalizeSlashes(jsFilePath)), declFileName, host.getCurrentDirectory(), host.getCanonicalFileName, + /*isAbsolutePathAnUrl*/ false); + referencePathsOutput += "/// " + newLine; + } + } + /* @internal */ + function writeDeclarationFile(jsFilePath, sourceFile, host, resolver, diagnostics) { + var emitDeclarationResult = emitDeclarations(host, resolver, diagnostics, jsFilePath, sourceFile); + // TODO(shkamat): Should we not write any declaration file if any of them can produce error, + // or should we just not write this file like we are doing now + if (!emitDeclarationResult.reportedDeclarationError) { + var declarationOutput = emitDeclarationResult.referencePathsOutput + + getDeclarationOutput(emitDeclarationResult.synchronousDeclarationOutput, emitDeclarationResult.moduleElementDeclarationEmitInfo); + ts.writeFile(host, diagnostics, ts.removeFileExtension(jsFilePath) + ".d.ts", declarationOutput, host.getCompilerOptions().emitBOM); + } + function getDeclarationOutput(synchronousDeclarationOutput, moduleElementDeclarationEmitInfo) { + var appliedSyncOutputPos = 0; + var declarationOutput = ""; + // apply asynchronous additions to the synchronous output + ts.forEach(moduleElementDeclarationEmitInfo, function (aliasEmitInfo) { + if (aliasEmitInfo.asynchronousOutput) { + declarationOutput += synchronousDeclarationOutput.substring(appliedSyncOutputPos, aliasEmitInfo.outputPos); + declarationOutput += getDeclarationOutput(aliasEmitInfo.asynchronousOutput, aliasEmitInfo.subModuleElementDeclarationEmitInfo); + appliedSyncOutputPos = aliasEmitInfo.outputPos; + } + }); + declarationOutput += synchronousDeclarationOutput.substring(appliedSyncOutputPos); + return declarationOutput; + } + } + ts.writeDeclarationFile = writeDeclarationFile; +})(ts || (ts = {})); +/// +/// +/* @internal */ +var ts; +(function (ts) { + function isExternalModuleOrDeclarationFile(sourceFile) { + return ts.isExternalModule(sourceFile) || ts.isDeclarationFile(sourceFile); + } + ts.isExternalModuleOrDeclarationFile = isExternalModuleOrDeclarationFile; + var entities = { + "quot": 0x0022, + "amp": 0x0026, + "apos": 0x0027, + "lt": 0x003C, + "gt": 0x003E, + "nbsp": 0x00A0, + "iexcl": 0x00A1, + "cent": 0x00A2, + "pound": 0x00A3, + "curren": 0x00A4, + "yen": 0x00A5, + "brvbar": 0x00A6, + "sect": 0x00A7, + "uml": 0x00A8, + "copy": 0x00A9, + "ordf": 0x00AA, + "laquo": 0x00AB, + "not": 0x00AC, + "shy": 0x00AD, + "reg": 0x00AE, + "macr": 0x00AF, + "deg": 0x00B0, + "plusmn": 0x00B1, + "sup2": 0x00B2, + "sup3": 0x00B3, + "acute": 0x00B4, + "micro": 0x00B5, + "para": 0x00B6, + "middot": 0x00B7, + "cedil": 0x00B8, + "sup1": 0x00B9, + "ordm": 0x00BA, + "raquo": 0x00BB, + "frac14": 0x00BC, + "frac12": 0x00BD, + "frac34": 0x00BE, + "iquest": 0x00BF, + "Agrave": 0x00C0, + "Aacute": 0x00C1, + "Acirc": 0x00C2, + "Atilde": 0x00C3, + "Auml": 0x00C4, + "Aring": 0x00C5, + "AElig": 0x00C6, + "Ccedil": 0x00C7, + "Egrave": 0x00C8, + "Eacute": 0x00C9, + "Ecirc": 0x00CA, + "Euml": 0x00CB, + "Igrave": 0x00CC, + "Iacute": 0x00CD, + "Icirc": 0x00CE, + "Iuml": 0x00CF, + "ETH": 0x00D0, + "Ntilde": 0x00D1, + "Ograve": 0x00D2, + "Oacute": 0x00D3, + "Ocirc": 0x00D4, + "Otilde": 0x00D5, + "Ouml": 0x00D6, + "times": 0x00D7, + "Oslash": 0x00D8, + "Ugrave": 0x00D9, + "Uacute": 0x00DA, + "Ucirc": 0x00DB, + "Uuml": 0x00DC, + "Yacute": 0x00DD, + "THORN": 0x00DE, + "szlig": 0x00DF, + "agrave": 0x00E0, + "aacute": 0x00E1, + "acirc": 0x00E2, + "atilde": 0x00E3, + "auml": 0x00E4, + "aring": 0x00E5, + "aelig": 0x00E6, + "ccedil": 0x00E7, + "egrave": 0x00E8, + "eacute": 0x00E9, + "ecirc": 0x00EA, + "euml": 0x00EB, + "igrave": 0x00EC, + "iacute": 0x00ED, + "icirc": 0x00EE, + "iuml": 0x00EF, + "eth": 0x00F0, + "ntilde": 0x00F1, + "ograve": 0x00F2, + "oacute": 0x00F3, + "ocirc": 0x00F4, + "otilde": 0x00F5, + "ouml": 0x00F6, + "divide": 0x00F7, + "oslash": 0x00F8, + "ugrave": 0x00F9, + "uacute": 0x00FA, + "ucirc": 0x00FB, + "uuml": 0x00FC, + "yacute": 0x00FD, + "thorn": 0x00FE, + "yuml": 0x00FF, + "OElig": 0x0152, + "oelig": 0x0153, + "Scaron": 0x0160, + "scaron": 0x0161, + "Yuml": 0x0178, + "fnof": 0x0192, + "circ": 0x02C6, + "tilde": 0x02DC, + "Alpha": 0x0391, + "Beta": 0x0392, + "Gamma": 0x0393, + "Delta": 0x0394, + "Epsilon": 0x0395, + "Zeta": 0x0396, + "Eta": 0x0397, + "Theta": 0x0398, + "Iota": 0x0399, + "Kappa": 0x039A, + "Lambda": 0x039B, + "Mu": 0x039C, + "Nu": 0x039D, + "Xi": 0x039E, + "Omicron": 0x039F, + "Pi": 0x03A0, + "Rho": 0x03A1, + "Sigma": 0x03A3, + "Tau": 0x03A4, + "Upsilon": 0x03A5, + "Phi": 0x03A6, + "Chi": 0x03A7, + "Psi": 0x03A8, + "Omega": 0x03A9, + "alpha": 0x03B1, + "beta": 0x03B2, + "gamma": 0x03B3, + "delta": 0x03B4, + "epsilon": 0x03B5, + "zeta": 0x03B6, + "eta": 0x03B7, + "theta": 0x03B8, + "iota": 0x03B9, + "kappa": 0x03BA, + "lambda": 0x03BB, + "mu": 0x03BC, + "nu": 0x03BD, + "xi": 0x03BE, + "omicron": 0x03BF, + "pi": 0x03C0, + "rho": 0x03C1, + "sigmaf": 0x03C2, + "sigma": 0x03C3, + "tau": 0x03C4, + "upsilon": 0x03C5, + "phi": 0x03C6, + "chi": 0x03C7, + "psi": 0x03C8, + "omega": 0x03C9, + "thetasym": 0x03D1, + "upsih": 0x03D2, + "piv": 0x03D6, + "ensp": 0x2002, + "emsp": 0x2003, + "thinsp": 0x2009, + "zwnj": 0x200C, + "zwj": 0x200D, + "lrm": 0x200E, + "rlm": 0x200F, + "ndash": 0x2013, + "mdash": 0x2014, + "lsquo": 0x2018, + "rsquo": 0x2019, + "sbquo": 0x201A, + "ldquo": 0x201C, + "rdquo": 0x201D, + "bdquo": 0x201E, + "dagger": 0x2020, + "Dagger": 0x2021, + "bull": 0x2022, + "hellip": 0x2026, + "permil": 0x2030, + "prime": 0x2032, + "Prime": 0x2033, + "lsaquo": 0x2039, + "rsaquo": 0x203A, + "oline": 0x203E, + "frasl": 0x2044, + "euro": 0x20AC, + "image": 0x2111, + "weierp": 0x2118, + "real": 0x211C, + "trade": 0x2122, + "alefsym": 0x2135, + "larr": 0x2190, + "uarr": 0x2191, + "rarr": 0x2192, + "darr": 0x2193, + "harr": 0x2194, + "crarr": 0x21B5, + "lArr": 0x21D0, + "uArr": 0x21D1, + "rArr": 0x21D2, + "dArr": 0x21D3, + "hArr": 0x21D4, + "forall": 0x2200, + "part": 0x2202, + "exist": 0x2203, + "empty": 0x2205, + "nabla": 0x2207, + "isin": 0x2208, + "notin": 0x2209, + "ni": 0x220B, + "prod": 0x220F, + "sum": 0x2211, + "minus": 0x2212, + "lowast": 0x2217, + "radic": 0x221A, + "prop": 0x221D, + "infin": 0x221E, + "ang": 0x2220, + "and": 0x2227, + "or": 0x2228, + "cap": 0x2229, + "cup": 0x222A, + "int": 0x222B, + "there4": 0x2234, + "sim": 0x223C, + "cong": 0x2245, + "asymp": 0x2248, + "ne": 0x2260, + "equiv": 0x2261, + "le": 0x2264, + "ge": 0x2265, + "sub": 0x2282, + "sup": 0x2283, + "nsub": 0x2284, + "sube": 0x2286, + "supe": 0x2287, + "oplus": 0x2295, + "otimes": 0x2297, + "perp": 0x22A5, + "sdot": 0x22C5, + "lceil": 0x2308, + "rceil": 0x2309, + "lfloor": 0x230A, + "rfloor": 0x230B, + "lang": 0x2329, + "rang": 0x232A, + "loz": 0x25CA, + "spades": 0x2660, + "clubs": 0x2663, + "hearts": 0x2665, + "diams": 0x2666 + }; + // Flags enum to track count of temp variables and a few dedicated names + var TempFlags; + (function (TempFlags) { + TempFlags[TempFlags["Auto"] = 0] = "Auto"; + TempFlags[TempFlags["CountMask"] = 268435455] = "CountMask"; + TempFlags[TempFlags["_i"] = 268435456] = "_i"; + })(TempFlags || (TempFlags = {})); + // 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) { + // emit output for the __extends helper function + var extendsHelper = "\nvar __extends = (this && this.__extends) || function (d, b) {\n for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];\n function __() { this.constructor = d; }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n};"; + // emit output for the __decorate helper function + var decorateHelper = "\nvar __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\n return c > 3 && r && Object.defineProperty(target, key, r), r;\n};"; + // emit output for the __metadata helper function + var metadataHelper = "\nvar __metadata = (this && this.__metadata) || function (k, v) {\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(k, v);\n};"; + // emit output for the __param helper function + var paramHelper = "\nvar __param = (this && this.__param) || function (paramIndex, decorator) {\n return function (target, key) { decorator(target, key, paramIndex); }\n};"; + var awaiterHelper = "\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promise, generator) {\n return new Promise(function (resolve, reject) {\n generator = generator.call(thisArg, _arguments);\n function cast(value) { return value instanceof Promise && value.constructor === Promise ? value : new Promise(function (resolve) { resolve(value); }); }\n function onfulfill(value) { try { step(\"next\", value); } catch (e) { reject(e); } }\n function onreject(value) { try { step(\"throw\", value); } catch (e) { reject(e); } }\n function step(verb, value) {\n var result = generator[verb](value);\n result.done ? resolve(result.value) : cast(result.value).then(onfulfill, onreject);\n }\n step(\"next\", void 0);\n });\n};"; + var compilerOptions = host.getCompilerOptions(); + var languageVersion = compilerOptions.target || 0 /* ES3 */; + var modulekind = compilerOptions.module ? compilerOptions.module : languageVersion === 2 /* ES6 */ ? 5 /* ES6 */ : 0 /* None */; + var sourceMapDataList = compilerOptions.sourceMap || compilerOptions.inlineSourceMap ? [] : undefined; + var diagnostics = []; + var newLine = host.getNewLine(); + var jsxDesugaring = host.getCompilerOptions().jsx !== 1 /* Preserve */; + var shouldEmitJsx = function (s) { return (s.languageVariant === 1 /* JSX */ && !jsxDesugaring); }; + if (targetSourceFile === undefined) { + ts.forEach(host.getSourceFiles(), function (sourceFile) { + if (ts.shouldEmitToOwnFile(sourceFile, compilerOptions)) { + var jsFilePath = ts.getOwnEmitOutputFilePath(sourceFile, host, shouldEmitJsx(sourceFile) ? ".jsx" : ".js"); + emitFile(jsFilePath, sourceFile); + } + }); + if (compilerOptions.outFile || compilerOptions.out) { + emitFile(compilerOptions.outFile || compilerOptions.out); + } + } + else { + // targetSourceFile is specified (e.g calling emitter from language service or calling getSemanticDiagnostic from language service) + if (ts.shouldEmitToOwnFile(targetSourceFile, compilerOptions)) { + var jsFilePath = ts.getOwnEmitOutputFilePath(targetSourceFile, host, shouldEmitJsx(targetSourceFile) ? ".jsx" : ".js"); + emitFile(jsFilePath, targetSourceFile); + } + else if (!ts.isDeclarationFile(targetSourceFile) && (compilerOptions.outFile || compilerOptions.out)) { + emitFile(compilerOptions.outFile || compilerOptions.out); + } + } + // Sort and make the unique list of diagnostics + diagnostics = ts.sortAndDeduplicateDiagnostics(diagnostics); + return { + emitSkipped: false, + diagnostics: diagnostics, + sourceMaps: sourceMapDataList + }; + function isNodeDescendentOf(node, ancestor) { + while (node) { + if (node === ancestor) + return true; + node = node.parent; + } + return false; + } + function isUniqueLocalName(name, container) { + for (var node = container; isNodeDescendentOf(node, container); node = node.nextContainer) { + if (node.locals && ts.hasProperty(node.locals, name)) { + // We conservatively include alias symbols to cover cases where they're emitted as locals + if (node.locals[name].flags & (107455 /* Value */ | 1048576 /* ExportValue */ | 8388608 /* Alias */)) { + return false; + } + } + } + return true; + } + var Jump; + (function (Jump) { + Jump[Jump["Break"] = 2] = "Break"; + Jump[Jump["Continue"] = 4] = "Continue"; + Jump[Jump["Return"] = 8] = "Return"; + })(Jump || (Jump = {})); + function setLabeledJump(state, isBreak, labelText, labelMarker) { + if (isBreak) { + if (!state.labeledNonLocalBreaks) { + state.labeledNonLocalBreaks = {}; + } + state.labeledNonLocalBreaks[labelText] = labelMarker; + } + else { + if (!state.labeledNonLocalContinues) { + state.labeledNonLocalContinues = {}; + } + state.labeledNonLocalContinues[labelText] = labelMarker; + } + } + function hoistVariableDeclarationFromLoop(state, declaration) { + if (!state.hoistedLocalVariables) { + state.hoistedLocalVariables = []; + } + visit(declaration.name); + function visit(node) { + if (node.kind === 69 /* Identifier */) { + state.hoistedLocalVariables.push(node); + } + else { + for (var _a = 0, _b = node.elements; _a < _b.length; _a++) { + var element = _b[_a]; + visit(element.name); + } + } + } + } + function emitJavaScript(jsFilePath, root) { + var writer = ts.createTextWriter(newLine); + var write = writer.write, writeTextOfNode = writer.writeTextOfNode, writeLine = writer.writeLine, increaseIndent = writer.increaseIndent, decreaseIndent = writer.decreaseIndent; + var currentSourceFile; + // name of an exporter function if file is a System external module + // System.register([...], function () {...}) + // exporting in System modules looks like: + // export var x; ... x = 1 + // => + // var x;... exporter("x", x = 1) + var exportFunctionForFile; + var generatedNameSet = {}; + var nodeToGeneratedName = []; + var computedPropertyNamesToGeneratedNames; + var convertedLoopState; + var extendsEmitted = false; + var decorateEmitted = false; + var paramEmitted = false; + var awaiterEmitted = false; + var tempFlags = 0; + var tempVariables; + var tempParameters; + var externalImports; + var exportSpecifiers; + var exportEquals; + var hasExportStars; + /** Write emitted output to disk */ + var writeEmittedFiles = writeJavaScriptFile; + var detachedCommentsInfo; + var writeComment = ts.writeCommentRange; + /** Emit a node */ + var emit = emitNodeWithCommentsAndWithoutSourcemap; + /** Called just before starting emit of a node */ + var emitStart = function (node) { }; + /** Called once the emit of the node is done */ + var emitEnd = function (node) { }; + /** Emit the text for the given token that comes after startPos + * This by default writes the text provided with the given tokenKind + * but if optional emitFn callback is provided the text is emitted using the callback instead of default text + * @param tokenKind the kind of the token to search and emit + * @param startPos the position in the source to start searching for the token + * @param emitFn if given will be invoked to emit the text instead of actual token emit */ + var emitToken = emitTokenText; + /** Called to before starting the lexical scopes as in function/class in the emitted code because of node + * @param scopeDeclaration node that starts the lexical scope + * @param scopeName Optional name of this scope instead of deducing one from the declaration node */ + var scopeEmitStart = function (scopeDeclaration, scopeName) { }; + /** Called after coming out of the scope */ + var scopeEmitEnd = function () { }; + /** Sourcemap data that will get encoded */ + var sourceMapData; + /** If removeComments is true, no leading-comments needed to be emitted **/ + var emitLeadingCommentsOfPosition = compilerOptions.removeComments ? function (pos) { } : emitLeadingCommentsOfPositionWorker; + var moduleEmitDelegates = (_a = {}, + _a[5 /* ES6 */] = emitES6Module, + _a[2 /* AMD */] = emitAMDModule, + _a[4 /* System */] = emitSystemModule, + _a[3 /* UMD */] = emitUMDModule, + _a[1 /* CommonJS */] = emitCommonJSModule, + _a + ); + if (compilerOptions.sourceMap || compilerOptions.inlineSourceMap) { + initializeEmitterWithSourceMaps(); + } + if (root) { + // Do not call emit directly. It does not set the currentSourceFile. + emitSourceFile(root); + } + else { + ts.forEach(host.getSourceFiles(), function (sourceFile) { + if (!isExternalModuleOrDeclarationFile(sourceFile)) { + emitSourceFile(sourceFile); + } + }); + } + writeLine(); + writeEmittedFiles(writer.getText(), /*writeByteOrderMark*/ compilerOptions.emitBOM); + return; + function emitSourceFile(sourceFile) { + currentSourceFile = sourceFile; + exportFunctionForFile = undefined; + emit(sourceFile); + } + function isUniqueName(name) { + return !resolver.hasGlobalName(name) && + !ts.hasProperty(currentSourceFile.identifiers, name) && + !ts.hasProperty(generatedNameSet, name); + } + // Return the next available name in the pattern _a ... _z, _0, _1, ... + // TempFlags._i or TempFlags._n may be used to express a preference for that dedicated name. + // Note that names generated by makeTempVariableName and makeUniqueName will never conflict. + function makeTempVariableName(flags) { + if (flags && !(tempFlags & flags)) { + var name_19 = flags === 268435456 /* _i */ ? "_i" : "_n"; + if (isUniqueName(name_19)) { + tempFlags |= flags; + return name_19; + } + } + while (true) { + var count = tempFlags & 268435455 /* CountMask */; + tempFlags++; + // Skip over 'i' and 'n' + if (count !== 8 && count !== 13) { + var name_20 = count < 26 ? "_" + String.fromCharCode(97 /* a */ + count) : "_" + (count - 26); + if (isUniqueName(name_20)) { + return name_20; + } + } + } + } + // Generate a name that is unique within the current file and doesn't conflict with any names + // in global scope. The name is formed by adding an '_n' suffix to the specified base name, + // where n is a positive integer. Note that names generated by makeTempVariableName and + // makeUniqueName are guaranteed to never conflict. + function makeUniqueName(baseName) { + // Find the first unique 'name_n', where n is a positive number + if (baseName.charCodeAt(baseName.length - 1) !== 95 /* _ */) { + baseName += "_"; + } + var i = 1; + while (true) { + var generatedName = baseName + i; + if (isUniqueName(generatedName)) { + return generatedNameSet[generatedName] = generatedName; + } + i++; + } + } + function generateNameForModuleOrEnum(node) { + var name = node.name.text; + // Use module/enum name itself if it is unique, otherwise make a unique variation + return isUniqueLocalName(name, node) ? name : makeUniqueName(name); + } + function generateNameForImportOrExportDeclaration(node) { + var expr = ts.getExternalModuleName(node); + var baseName = expr.kind === 9 /* StringLiteral */ ? + ts.escapeIdentifier(ts.makeIdentifierFromModuleName(expr.text)) : "module"; + return makeUniqueName(baseName); + } + function generateNameForExportDefault() { + return makeUniqueName("default"); + } + function generateNameForClassExpression() { + return makeUniqueName("class"); + } + function generateNameForNode(node) { + switch (node.kind) { + case 69 /* Identifier */: + return makeUniqueName(node.text); + case 218 /* ModuleDeclaration */: + case 217 /* EnumDeclaration */: + return generateNameForModuleOrEnum(node); + case 222 /* ImportDeclaration */: + case 228 /* ExportDeclaration */: + return generateNameForImportOrExportDeclaration(node); + case 213 /* FunctionDeclaration */: + case 214 /* ClassDeclaration */: + case 227 /* ExportAssignment */: + return generateNameForExportDefault(); + case 186 /* ClassExpression */: + return generateNameForClassExpression(); + } + } + function getGeneratedNameForNode(node) { + var id = ts.getNodeId(node); + return nodeToGeneratedName[id] || (nodeToGeneratedName[id] = ts.unescapeIdentifier(generateNameForNode(node))); + } + function initializeEmitterWithSourceMaps() { + var sourceMapDir; // The directory in which sourcemap will be + // Current source map file and its index in the sources list + var sourceMapSourceIndex = -1; + // Names and its index map + var sourceMapNameIndexMap = {}; + var sourceMapNameIndices = []; + function getSourceMapNameIndex() { + return sourceMapNameIndices.length ? ts.lastOrUndefined(sourceMapNameIndices) : -1; + } + // Last recorded and encoded spans + var lastRecordedSourceMapSpan; + var lastEncodedSourceMapSpan = { + emittedLine: 1, + emittedColumn: 1, + sourceLine: 1, + sourceColumn: 1, + sourceIndex: 0 + }; + var lastEncodedNameIndex = 0; + // Encoding for sourcemap span + function encodeLastRecordedSourceMapSpan() { + if (!lastRecordedSourceMapSpan || lastRecordedSourceMapSpan === lastEncodedSourceMapSpan) { + return; + } + var prevEncodedEmittedColumn = lastEncodedSourceMapSpan.emittedColumn; + // Line/Comma delimiters + if (lastEncodedSourceMapSpan.emittedLine === lastRecordedSourceMapSpan.emittedLine) { + // Emit comma to separate the entry + if (sourceMapData.sourceMapMappings) { + sourceMapData.sourceMapMappings += ","; + } + } + else { + // Emit line delimiters + for (var encodedLine = lastEncodedSourceMapSpan.emittedLine; encodedLine < lastRecordedSourceMapSpan.emittedLine; encodedLine++) { + sourceMapData.sourceMapMappings += ";"; + } + prevEncodedEmittedColumn = 1; + } + // 1. Relative Column 0 based + sourceMapData.sourceMapMappings += base64VLQFormatEncode(lastRecordedSourceMapSpan.emittedColumn - prevEncodedEmittedColumn); + // 2. Relative sourceIndex + sourceMapData.sourceMapMappings += base64VLQFormatEncode(lastRecordedSourceMapSpan.sourceIndex - lastEncodedSourceMapSpan.sourceIndex); + // 3. Relative sourceLine 0 based + sourceMapData.sourceMapMappings += base64VLQFormatEncode(lastRecordedSourceMapSpan.sourceLine - lastEncodedSourceMapSpan.sourceLine); + // 4. Relative sourceColumn 0 based + sourceMapData.sourceMapMappings += base64VLQFormatEncode(lastRecordedSourceMapSpan.sourceColumn - lastEncodedSourceMapSpan.sourceColumn); + // 5. Relative namePosition 0 based + if (lastRecordedSourceMapSpan.nameIndex >= 0) { + sourceMapData.sourceMapMappings += base64VLQFormatEncode(lastRecordedSourceMapSpan.nameIndex - lastEncodedNameIndex); + lastEncodedNameIndex = lastRecordedSourceMapSpan.nameIndex; + } + lastEncodedSourceMapSpan = lastRecordedSourceMapSpan; + sourceMapData.sourceMapDecodedMappings.push(lastEncodedSourceMapSpan); + function base64VLQFormatEncode(inValue) { + function base64FormatEncode(inValue) { + if (inValue < 64) { + return "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(inValue); + } + throw TypeError(inValue + ": not a 64 based value"); + } + // Add a new least significant bit that has the sign of the value. + // if negative number the least significant bit that gets added to the number has value 1 + // else least significant bit value that gets added is 0 + // eg. -1 changes to binary : 01 [1] => 3 + // +1 changes to binary : 01 [0] => 2 + if (inValue < 0) { + inValue = ((-inValue) << 1) + 1; + } + else { + inValue = inValue << 1; + } + // Encode 5 bits at a time starting from least significant bits + var encodedStr = ""; + do { + var currentDigit = inValue & 31; // 11111 + inValue = inValue >> 5; + if (inValue > 0) { + // There are still more digits to decode, set the msb (6th bit) + currentDigit = currentDigit | 32; + } + encodedStr = encodedStr + base64FormatEncode(currentDigit); + } while (inValue > 0); + return encodedStr; + } + } + function recordSourceMapSpan(pos) { + var sourceLinePos = ts.getLineAndCharacterOfPosition(currentSourceFile, pos); + // Convert the location to be one-based. + sourceLinePos.line++; + sourceLinePos.character++; + var emittedLine = writer.getLine(); + var emittedColumn = writer.getColumn(); + // If this location wasn't recorded or the location in source is going backwards, record the span + if (!lastRecordedSourceMapSpan || + lastRecordedSourceMapSpan.emittedLine !== emittedLine || + lastRecordedSourceMapSpan.emittedColumn !== emittedColumn || + (lastRecordedSourceMapSpan.sourceIndex === sourceMapSourceIndex && + (lastRecordedSourceMapSpan.sourceLine > sourceLinePos.line || + (lastRecordedSourceMapSpan.sourceLine === sourceLinePos.line && lastRecordedSourceMapSpan.sourceColumn > sourceLinePos.character)))) { + // Encode the last recordedSpan before assigning new + encodeLastRecordedSourceMapSpan(); + // New span + lastRecordedSourceMapSpan = { + emittedLine: emittedLine, + emittedColumn: emittedColumn, + sourceLine: sourceLinePos.line, + sourceColumn: sourceLinePos.character, + nameIndex: getSourceMapNameIndex(), + sourceIndex: sourceMapSourceIndex + }; + } + 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; + } + } + function recordEmitNodeStartSpan(node) { + // Get the token pos after skipping to the token (ignoring the leading trivia) + recordSourceMapSpan(ts.skipTrivia(currentSourceFile.text, node.pos)); + } + function recordEmitNodeEndSpan(node) { + recordSourceMapSpan(node.end); + } + function writeTextWithSpanRecord(tokenKind, startPos, emitFn) { + var tokenStartPos = ts.skipTrivia(currentSourceFile.text, startPos); + recordSourceMapSpan(tokenStartPos); + var tokenEndPos = emitTokenText(tokenKind, tokenStartPos, emitFn); + recordSourceMapSpan(tokenEndPos); + return tokenEndPos; + } + function recordNewSourceFileStart(node) { + // Add the file to tsFilePaths + // If sourceroot option: Use the relative path corresponding to the common directory path + // otherwise source locations relative to map file location + var sourcesDirectoryPath = compilerOptions.sourceRoot ? host.getCommonSourceDirectory() : sourceMapDir; + sourceMapData.sourceMapSources.push(ts.getRelativePathToDirectoryOrUrl(sourcesDirectoryPath, node.fileName, host.getCurrentDirectory(), host.getCanonicalFileName, + /*isAbsolutePathAnUrl*/ true)); + sourceMapSourceIndex = sourceMapData.sourceMapSources.length - 1; + // The one that can be used from program to get the actual source file + sourceMapData.inputSourceFileNames.push(node.fileName); + if (compilerOptions.inlineSources) { + if (!sourceMapData.sourceMapSourcesContent) { + sourceMapData.sourceMapSourcesContent = []; + } + sourceMapData.sourceMapSourcesContent.push(node.text); + } + } + function recordScopeNameOfNode(node, scopeName) { + function recordScopeNameIndex(scopeNameIndex) { + sourceMapNameIndices.push(scopeNameIndex); + } + function recordScopeNameStart(scopeName) { + var scopeNameIndex = -1; + if (scopeName) { + var parentIndex = getSourceMapNameIndex(); + if (parentIndex !== -1) { + // Child scopes are always shown with a dot (even if they have no name), + // unless it is a computed property. Then it is shown with brackets, + // but the brackets are included in the name. + var name_21 = node.name; + if (!name_21 || name_21.kind !== 136 /* ComputedPropertyName */) { + scopeName = "." + scopeName; + } + scopeName = sourceMapData.sourceMapNames[parentIndex] + scopeName; + } + scopeNameIndex = ts.getProperty(sourceMapNameIndexMap, scopeName); + if (scopeNameIndex === undefined) { + scopeNameIndex = sourceMapData.sourceMapNames.length; + sourceMapData.sourceMapNames.push(scopeName); + sourceMapNameIndexMap[scopeName] = scopeNameIndex; + } + } + recordScopeNameIndex(scopeNameIndex); + } + if (scopeName) { + // The scope was already given a name use it + recordScopeNameStart(scopeName); + } + else if (node.kind === 213 /* FunctionDeclaration */ || + node.kind === 173 /* FunctionExpression */ || + node.kind === 143 /* MethodDeclaration */ || + node.kind === 142 /* MethodSignature */ || + node.kind === 145 /* GetAccessor */ || + node.kind === 146 /* SetAccessor */ || + node.kind === 218 /* ModuleDeclaration */ || + node.kind === 214 /* ClassDeclaration */ || + node.kind === 217 /* EnumDeclaration */) { + // Declaration and has associated name use it + if (node.name) { + var name_22 = node.name; + // For computed property names, the text will include the brackets + scopeName = name_22.kind === 136 /* ComputedPropertyName */ + ? ts.getTextOfNode(name_22) + : node.name.text; + } + recordScopeNameStart(scopeName); + } + else { + // Block just use the name from upper level scope + recordScopeNameIndex(getSourceMapNameIndex()); + } + } + function recordScopeNameEnd() { + sourceMapNameIndices.pop(); + } + ; + function writeCommentRangeWithMap(curentSourceFile, writer, comment, newLine) { + recordSourceMapSpan(comment.pos); + ts.writeCommentRange(currentSourceFile, writer, comment, newLine); + recordSourceMapSpan(comment.end); + } + function serializeSourceMapContents(version, file, sourceRoot, sources, names, mappings, sourcesContent) { + if (typeof JSON !== "undefined") { + var map_1 = { + version: version, + file: file, + sourceRoot: sourceRoot, + sources: sources, + names: names, + mappings: mappings + }; + if (sourcesContent !== undefined) { + map_1.sourcesContent = sourcesContent; + } + return JSON.stringify(map_1); + } + return "{\"version\":" + version + ",\"file\":\"" + ts.escapeString(file) + "\",\"sourceRoot\":\"" + ts.escapeString(sourceRoot) + "\",\"sources\":[" + serializeStringArray(sources) + "],\"names\":[" + serializeStringArray(names) + "],\"mappings\":\"" + ts.escapeString(mappings) + "\" " + (sourcesContent !== undefined ? ",\"sourcesContent\":[" + serializeStringArray(sourcesContent) + "]" : "") + "}"; + function serializeStringArray(list) { + var output = ""; + for (var i = 0, n = list.length; i < n; i++) { + if (i) { + output += ","; + } + output += "\"" + ts.escapeString(list[i]) + "\""; + } + return output; + } + } + function writeJavaScriptAndSourceMapFile(emitOutput, writeByteOrderMark) { + encodeLastRecordedSourceMapSpan(); + var sourceMapText = serializeSourceMapContents(3, sourceMapData.sourceMapFile, sourceMapData.sourceMapSourceRoot, sourceMapData.sourceMapSources, sourceMapData.sourceMapNames, sourceMapData.sourceMapMappings, sourceMapData.sourceMapSourcesContent); + sourceMapDataList.push(sourceMapData); + var sourceMapUrl; + if (compilerOptions.inlineSourceMap) { + // Encode the sourceMap into the sourceMap url + var base64SourceMapText = ts.convertToBase64(sourceMapText); + sourceMapUrl = "//# sourceMappingURL=data:application/json;base64," + base64SourceMapText; + } + else { + // Write source map file + ts.writeFile(host, diagnostics, sourceMapData.sourceMapFilePath, sourceMapText, /*writeByteOrderMark*/ false); + sourceMapUrl = "//# sourceMappingURL=" + sourceMapData.jsSourceMappingURL; + } + // Write sourcemap url to the js file and write the js file + writeJavaScriptFile(emitOutput + sourceMapUrl, writeByteOrderMark); + } + // Initialize source map data + var sourceMapJsFile = ts.getBaseFileName(ts.normalizeSlashes(jsFilePath)); + sourceMapData = { + sourceMapFilePath: jsFilePath + ".map", + jsSourceMappingURL: sourceMapJsFile + ".map", + sourceMapFile: sourceMapJsFile, + sourceMapSourceRoot: compilerOptions.sourceRoot || "", + sourceMapSources: [], + inputSourceFileNames: [], + sourceMapNames: [], + sourceMapMappings: "", + sourceMapSourcesContent: undefined, + sourceMapDecodedMappings: [] + }; + // Normalize source root and make sure it has trailing "/" so that it can be used to combine paths with the + // relative paths of the sources list in the sourcemap + sourceMapData.sourceMapSourceRoot = ts.normalizeSlashes(sourceMapData.sourceMapSourceRoot); + if (sourceMapData.sourceMapSourceRoot.length && sourceMapData.sourceMapSourceRoot.charCodeAt(sourceMapData.sourceMapSourceRoot.length - 1) !== 47 /* slash */) { + sourceMapData.sourceMapSourceRoot += ts.directorySeparator; + } + if (compilerOptions.mapRoot) { + sourceMapDir = ts.normalizeSlashes(compilerOptions.mapRoot); + if (root) { + // For modules or multiple emit files the mapRoot will have directory structure like the sources + // So if src\a.ts and src\lib\b.ts are compiled together user would be moving the maps into mapRoot\a.js.map and mapRoot\lib\b.js.map + sourceMapDir = ts.getDirectoryPath(ts.getSourceFilePathInNewDir(root, host, sourceMapDir)); + } + if (!ts.isRootedDiskPath(sourceMapDir) && !ts.isUrl(sourceMapDir)) { + // The relative paths are relative to the common directory + sourceMapDir = ts.combinePaths(host.getCommonSourceDirectory(), sourceMapDir); + sourceMapData.jsSourceMappingURL = ts.getRelativePathToDirectoryOrUrl(ts.getDirectoryPath(ts.normalizePath(jsFilePath)), // get the relative sourceMapDir path based on jsFilePath + ts.combinePaths(sourceMapDir, sourceMapData.jsSourceMappingURL), // this is where user expects to see sourceMap + host.getCurrentDirectory(), host.getCanonicalFileName, + /*isAbsolutePathAnUrl*/ true); + } + else { + sourceMapData.jsSourceMappingURL = ts.combinePaths(sourceMapDir, sourceMapData.jsSourceMappingURL); + } + } + else { + sourceMapDir = ts.getDirectoryPath(ts.normalizePath(jsFilePath)); + } + function emitNodeWithSourceMap(node) { + if (node) { + if (ts.nodeIsSynthesized(node)) { + return emitNodeWithoutSourceMap(node); + } + if (node.kind !== 248 /* SourceFile */) { + recordEmitNodeStartSpan(node); + emitNodeWithoutSourceMap(node); + recordEmitNodeEndSpan(node); + } + else { + recordNewSourceFileStart(node); + emitNodeWithoutSourceMap(node); + } + } + } + function emitNodeWithCommentsAndWithSourcemap(node) { + emitNodeConsideringCommentsOption(node, emitNodeWithSourceMap); + } + writeEmittedFiles = writeJavaScriptAndSourceMapFile; + emit = emitNodeWithCommentsAndWithSourcemap; + emitStart = recordEmitNodeStartSpan; + emitEnd = recordEmitNodeEndSpan; + emitToken = writeTextWithSpanRecord; + scopeEmitStart = recordScopeNameOfNode; + scopeEmitEnd = recordScopeNameEnd; + writeComment = writeCommentRangeWithMap; + } + function writeJavaScriptFile(emitOutput, writeByteOrderMark) { + ts.writeFile(host, diagnostics, jsFilePath, emitOutput, writeByteOrderMark); + } + // Create a temporary variable with a unique unused name. + function createTempVariable(flags) { + var result = ts.createSynthesizedNode(69 /* Identifier */); + result.text = makeTempVariableName(flags); + return result; + } + function recordTempDeclaration(name) { + if (!tempVariables) { + tempVariables = []; + } + tempVariables.push(name); + } + function createAndRecordTempVariable(flags) { + var temp = createTempVariable(flags); + recordTempDeclaration(temp); + return temp; + } + function emitTempDeclarations(newLine) { + if (tempVariables) { + if (newLine) { + writeLine(); + } + else { + write(" "); + } + write("var "); + emitCommaList(tempVariables); + write(";"); + } + } + function emitTokenText(tokenKind, startPos, emitFn) { + var tokenString = ts.tokenToString(tokenKind); + if (emitFn) { + emitFn(); + } + else { + write(tokenString); + } + return startPos + tokenString.length; + } + function emitOptional(prefix, node) { + if (node) { + write(prefix); + emit(node); + } + } + function emitParenthesizedIf(node, parenthesized) { + if (parenthesized) { + write("("); + } + emit(node); + if (parenthesized) { + write(")"); + } + } + function emitTrailingCommaIfPresent(nodeList) { + if (nodeList.hasTrailingComma) { + write(","); + } + } + function emitLinePreservingList(parent, nodes, allowTrailingComma, spacesBetweenBraces) { + ts.Debug.assert(nodes.length > 0); + increaseIndent(); + if (nodeStartPositionsAreOnSameLine(parent, nodes[0])) { + if (spacesBetweenBraces) { + write(" "); + } + } + else { + writeLine(); + } + for (var i = 0, n = nodes.length; i < n; i++) { + if (i) { + if (nodeEndIsOnSameLineAsNodeStart(nodes[i - 1], nodes[i])) { + write(", "); + } + else { + write(","); + writeLine(); + } + } + emit(nodes[i]); + } + if (nodes.hasTrailingComma && allowTrailingComma) { + write(","); + } + decreaseIndent(); + if (nodeEndPositionsAreOnSameLine(parent, ts.lastOrUndefined(nodes))) { + if (spacesBetweenBraces) { + write(" "); + } + } + else { + writeLine(); + } + } + function emitList(nodes, start, count, multiLine, trailingComma, leadingComma, noTrailingNewLine, emitNode) { + if (!emitNode) { + emitNode = emit; + } + for (var i = 0; i < count; i++) { + if (multiLine) { + if (i || leadingComma) { + write(","); + } + writeLine(); + } + else { + if (i || leadingComma) { + write(", "); + } + } + var node = nodes[start + i]; + // This emitting is to make sure we emit following comment properly + // ...(x, /*comment1*/ y)... + // ^ => node.pos + // "comment1" is not considered leading comment for "y" but rather + // considered as trailing comment of the previous node. + emitTrailingCommentsOfPosition(node.pos); + emitNode(node); + leadingComma = true; + } + if (trailingComma) { + write(","); + } + if (multiLine && !noTrailingNewLine) { + writeLine(); + } + return count; + } + function emitCommaList(nodes) { + if (nodes) { + emitList(nodes, 0, nodes.length, /*multiline*/ false, /*trailingComma*/ false); + } + } + function emitLines(nodes) { + emitLinesStartingAt(nodes, /*startIndex*/ 0); + } + function emitLinesStartingAt(nodes, startIndex) { + for (var i = startIndex; i < nodes.length; i++) { + writeLine(); + emit(nodes[i]); + } + } + function isBinaryOrOctalIntegerLiteral(node, text) { + if (node.kind === 8 /* NumericLiteral */ && text.length > 1) { + switch (text.charCodeAt(1)) { + case 98 /* b */: + case 66 /* B */: + case 111 /* o */: + case 79 /* O */: + return true; + } + } + return false; + } + function emitLiteral(node) { + var text = getLiteralText(node); + if ((compilerOptions.sourceMap || compilerOptions.inlineSourceMap) && (node.kind === 9 /* StringLiteral */ || ts.isTemplateLiteralKind(node.kind))) { + writer.writeLiteral(text); + } + else if (languageVersion < 2 /* ES6 */ && isBinaryOrOctalIntegerLiteral(node, text)) { + write(node.text); + } + else { + write(text); + } + } + function getLiteralText(node) { + // 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 */ && (ts.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 (node.parent) { + return ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, node); + } + // If we can't reach the original source text, use the canonical form if it's a number, + // or an escaped quoted form of the original text if it's string-like. + switch (node.kind) { + case 9 /* StringLiteral */: + return getQuotedEscapedLiteralText("\"", node.text, "\""); + case 11 /* NoSubstitutionTemplateLiteral */: + return getQuotedEscapedLiteralText("`", node.text, "`"); + case 12 /* TemplateHead */: + return getQuotedEscapedLiteralText("`", node.text, "${"); + case 13 /* TemplateMiddle */: + return getQuotedEscapedLiteralText("}", node.text, "${"); + case 14 /* TemplateTail */: + return getQuotedEscapedLiteralText("}", node.text, "`"); + case 8 /* NumericLiteral */: + return node.text; + } + ts.Debug.fail("Literal kind '" + node.kind + "' not accounted for."); + } + function getQuotedEscapedLiteralText(leftQuote, text, rightQuote) { + return leftQuote + ts.escapeNonAsciiCharacters(ts.escapeString(text)) + rightQuote; + } + function emitDownlevelRawTemplateLiteral(node) { + // 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"); + text = ts.escapeString(text); + write("\"" + text + "\""); + } + function emitDownlevelTaggedTemplateArray(node, literalEmitter) { + write("["); + if (node.template.kind === 11 /* NoSubstitutionTemplateLiteral */) { + literalEmitter(node.template); + } + else { + literalEmitter(node.template.head); + ts.forEach(node.template.templateSpans, function (child) { + write(", "); + literalEmitter(child.literal); + }); + } + write("]"); + } + function emitDownlevelTaggedTemplate(node) { + var tempVariable = createAndRecordTempVariable(0 /* Auto */); + write("("); + emit(tempVariable); + write(" = "); + emitDownlevelTaggedTemplateArray(node, emit); + write(", "); + emit(tempVariable); + write(".raw = "); + emitDownlevelTaggedTemplateArray(node, emitDownlevelRawTemplateLiteral); + write(", "); + emitParenthesizedIf(node.tag, needsParenthesisForPropertyAccessOrInvocation(node.tag)); + write("("); + emit(tempVariable); + // Now we emit the expressions + if (node.template.kind === 183 /* TemplateExpression */) { + ts.forEach(node.template.templateSpans, function (templateSpan) { + write(", "); + var needsParens = templateSpan.expression.kind === 181 /* BinaryExpression */ + && templateSpan.expression.operatorToken.kind === 24 /* CommaToken */; + emitParenthesizedIf(templateSpan.expression, needsParens); + }); + } + write("))"); + } + function emitTemplateExpression(node) { + // In ES6 mode and above, we can simply emit each portion of a template in order, but in + // ES3 & ES5 we must convert the template expression into a series of string concatenations. + if (languageVersion >= 2 /* ES6 */) { + ts.forEachChild(node, emit); + return; + } + var emitOuterParens = ts.isExpression(node.parent) + && templateNeedsParens(node, node.parent); + if (emitOuterParens) { + write("("); + } + var headEmitted = false; + if (shouldEmitTemplateHead()) { + emitLiteral(node.head); + headEmitted = true; + } + for (var i = 0, n = node.templateSpans.length; i < n; i++) { + var templateSpan = node.templateSpans[i]; + // Check if the expression has operands and binds its operands less closely than binary '+'. + // If it does, we need to wrap 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 needsParens = templateSpan.expression.kind !== 172 /* ParenthesizedExpression */ + && comparePrecedenceToBinaryPlus(templateSpan.expression) !== 1 /* GreaterThan */; + if (i > 0 || headEmitted) { + // If this is the first span and the head was not emitted, then this templateSpan's + // expression will be the first to be emitted. Don't emit the preceding ' + ' in that + // case. + write(" + "); + } + emitParenthesizedIf(templateSpan.expression, needsParens); + // 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 (templateSpan.literal.text.length !== 0) { + write(" + "); + emitLiteral(templateSpan.literal); + } + } + if (emitOuterParens) { + write(")"); + } + function shouldEmitTemplateHead() { + // If this expression has an empty head literal and the first template span has a non-empty + // literal, then emitting the empty head literal is not necessary. + // `${ foo } and ${ bar }` + // can be emitted as + // foo + " and " + bar + // This is because it is only required that one of the first two operands in the emit + // output must be a string literal, so that the other operand and all following operands + // are forced into strings. + // + // If the first template span has an empty literal, then the head must still be emitted. + // `${ foo }${ bar }` + // must still be emitted as + // "" + foo + bar + // 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; + } + function templateNeedsParens(template, parent) { + switch (parent.kind) { + case 168 /* CallExpression */: + case 169 /* NewExpression */: + return parent.expression === template; + case 170 /* TaggedTemplateExpression */: + case 172 /* ParenthesizedExpression */: + return false; + default: + return comparePrecedenceToBinaryPlus(parent) !== -1 /* LessThan */; + } + } + /** + * Returns whether the expression has lesser, greater, + * or equal precedence to the binary '+' operator + */ + function comparePrecedenceToBinaryPlus(expression) { + // All binary expressions have lower precedence than '+' apart from '*', '/', and '%' + // which have greater precedence and '-' which has equal precedence. + // All unary operators have a higher precedence apart from yield. + // Arrow functions and conditionals have a lower precedence, + // although we convert the former into regular function expressions in ES5 mode, + // and in ES6 mode this function won't get called anyway. + // + // TODO (drosen): Note that we need to account for the upcoming 'yield' and + // spread ('...') unary operators that are anticipated for ES6. + switch (expression.kind) { + case 181 /* BinaryExpression */: + switch (expression.operatorToken.kind) { + case 37 /* AsteriskToken */: + case 39 /* SlashToken */: + case 40 /* PercentToken */: + return 1 /* GreaterThan */; + case 35 /* PlusToken */: + case 36 /* MinusToken */: + return 0 /* EqualTo */; + default: + return -1 /* LessThan */; + } + case 184 /* YieldExpression */: + case 182 /* ConditionalExpression */: + return -1 /* LessThan */; + default: + return 1 /* GreaterThan */; + } + } + } + function emitTemplateSpan(span) { + emit(span.expression); + emit(span.literal); + } + function jsxEmitReact(node) { + /// Emit a tag name, which is either '"div"' for lower-cased names, or + /// 'Div' for upper-cased or dotted names + function emitTagName(name) { + if (name.kind === 69 /* Identifier */ && ts.isIntrinsicJsxName(name.text)) { + write("\""); + emit(name); + write("\""); + } + else { + emit(name); + } + } + /// Emit an attribute name, which is quoted if it needs to be quoted. Because + /// these emit into an object literal property name, we don't need to be worried + /// about keywords, just non-identifier characters + function emitAttributeName(name) { + if (/[A-Za-z_]+[\w*]/.test(name.text)) { + write("\""); + emit(name); + write("\""); + } + else { + emit(name); + } + } + /// Emit an name/value pair for an attribute (e.g. "x: 3") + function emitJsxAttribute(node) { + emitAttributeName(node.name); + write(": "); + if (node.initializer) { + emit(node.initializer); + } + else { + write("true"); + } + } + function emitJsxElement(openingNode, children) { + var syntheticReactRef = ts.createSynthesizedNode(69 /* Identifier */); + syntheticReactRef.text = "React"; + syntheticReactRef.parent = openingNode; + // Call React.createElement(tag, ... + emitLeadingComments(openingNode); + emitExpressionIdentifier(syntheticReactRef); + write(".createElement("); + emitTagName(openingNode.tagName); + write(", "); + // Attribute list + if (openingNode.attributes.length === 0) { + // When there are no attributes, React wants "null" + write("null"); + } + else { + // Either emit one big object literal (no spread attribs), or + // a call to React.__spread + var attrs = openingNode.attributes; + if (ts.forEach(attrs, function (attr) { return attr.kind === 239 /* JsxSpreadAttribute */; })) { + emitExpressionIdentifier(syntheticReactRef); + write(".__spread("); + var haveOpenedObjectLiteral = false; + for (var i_1 = 0; i_1 < attrs.length; i_1++) { + if (attrs[i_1].kind === 239 /* JsxSpreadAttribute */) { + // If this is the first argument, we need to emit a {} as the first argument + if (i_1 === 0) { + write("{}, "); + } + if (haveOpenedObjectLiteral) { + write("}"); + haveOpenedObjectLiteral = false; + } + if (i_1 > 0) { + write(", "); + } + emit(attrs[i_1].expression); + } + else { + ts.Debug.assert(attrs[i_1].kind === 238 /* JsxAttribute */); + if (haveOpenedObjectLiteral) { + write(", "); + } + else { + haveOpenedObjectLiteral = true; + if (i_1 > 0) { + write(", "); + } + write("{"); + } + emitJsxAttribute(attrs[i_1]); + } + } + if (haveOpenedObjectLiteral) + write("}"); + write(")"); // closing paren to React.__spread( + } + else { + // One object literal with all the attributes in them + write("{"); + for (var i = 0; i < attrs.length; i++) { + if (i > 0) { + write(", "); + } + emitJsxAttribute(attrs[i]); + } + write("}"); + } + } + // Children + if (children) { + for (var i = 0; i < children.length; i++) { + // Don't emit empty expressions + if (children[i].kind === 240 /* JsxExpression */ && !(children[i].expression)) { + continue; + } + // Don't emit empty strings + if (children[i].kind === 236 /* JsxText */) { + var text = getTextToEmit(children[i]); + if (text !== undefined) { + write(", \""); + write(text); + write("\""); + } + } + else { + write(", "); + emit(children[i]); + } + } + } + // Closing paren + write(")"); // closes "React.createElement(" + emitTrailingComments(openingNode); + } + if (node.kind === 233 /* JsxElement */) { + emitJsxElement(node.openingElement, node.children); + } + else { + ts.Debug.assert(node.kind === 234 /* JsxSelfClosingElement */); + emitJsxElement(node); + } + } + function jsxEmitPreserve(node) { + function emitJsxAttribute(node) { + emit(node.name); + if (node.initializer) { + write("="); + emit(node.initializer); + } + } + function emitJsxSpreadAttribute(node) { + write("{..."); + emit(node.expression); + write("}"); + } + function emitAttributes(attribs) { + for (var i = 0, n = attribs.length; i < n; i++) { + if (i > 0) { + write(" "); + } + if (attribs[i].kind === 239 /* JsxSpreadAttribute */) { + emitJsxSpreadAttribute(attribs[i]); + } + else { + ts.Debug.assert(attribs[i].kind === 238 /* JsxAttribute */); + emitJsxAttribute(attribs[i]); + } + } + } + function emitJsxOpeningOrSelfClosingElement(node) { + write("<"); + emit(node.tagName); + if (node.attributes.length > 0 || (node.kind === 234 /* JsxSelfClosingElement */)) { + write(" "); + } + emitAttributes(node.attributes); + if (node.kind === 234 /* JsxSelfClosingElement */) { + write("/>"); + } + else { + write(">"); + } + } + function emitJsxClosingElement(node) { + write(""); + } + function emitJsxElement(node) { + emitJsxOpeningOrSelfClosingElement(node.openingElement); + for (var i = 0, n = node.children.length; i < n; i++) { + emit(node.children[i]); + } + emitJsxClosingElement(node.closingElement); + } + if (node.kind === 233 /* JsxElement */) { + emitJsxElement(node); + } + else { + ts.Debug.assert(node.kind === 234 /* JsxSelfClosingElement */); + emitJsxOpeningOrSelfClosingElement(node); + } + } + // This function specifically handles numeric/string literals for enum and accessor 'identifiers'. + // In a sense, it does not actually emit identifiers as much as it declares a name for a specific property. + // For example, this is utilized when feeding in a result to Object.defineProperty. + function emitExpressionForPropertyName(node) { + ts.Debug.assert(node.kind !== 163 /* BindingElement */); + if (node.kind === 9 /* StringLiteral */) { + emitLiteral(node); + } + else if (node.kind === 136 /* ComputedPropertyName */) { + // if this is a decorated computed property, we will need to capture the result + // of the property expression so that we can apply decorators later. This is to ensure + // we don't introduce unintended side effects: + // + // class C { + // [_a = x]() { } + // } + // + // The emit for the decorated computed property decorator is: + // + // __decorate([dec], C.prototype, _a, Object.getOwnPropertyDescriptor(C.prototype, _a)); + // + if (ts.nodeIsDecorated(node.parent)) { + if (!computedPropertyNamesToGeneratedNames) { + computedPropertyNamesToGeneratedNames = []; + } + var generatedName = computedPropertyNamesToGeneratedNames[ts.getNodeId(node)]; + if (generatedName) { + // we have already generated a variable for this node, write that value instead. + write(generatedName); + return; + } + generatedName = createAndRecordTempVariable(0 /* Auto */).text; + computedPropertyNamesToGeneratedNames[ts.getNodeId(node)] = generatedName; + write(generatedName); + write(" = "); + } + emit(node.expression); + } + else { + write("\""); + if (node.kind === 8 /* NumericLiteral */) { + write(node.text); + } + else { + writeTextOfNode(currentSourceFile, node); + } + write("\""); + } + } + function isExpressionIdentifier(node) { + var parent = node.parent; + switch (parent.kind) { + case 164 /* ArrayLiteralExpression */: + case 189 /* AsExpression */: + case 181 /* BinaryExpression */: + case 168 /* CallExpression */: + case 241 /* CaseClause */: + case 136 /* ComputedPropertyName */: + case 182 /* ConditionalExpression */: + case 139 /* Decorator */: + case 175 /* DeleteExpression */: + case 197 /* DoStatement */: + case 167 /* ElementAccessExpression */: + case 227 /* ExportAssignment */: + case 195 /* ExpressionStatement */: + case 188 /* ExpressionWithTypeArguments */: + case 199 /* ForStatement */: + case 200 /* ForInStatement */: + case 201 /* ForOfStatement */: + case 196 /* IfStatement */: + case 234 /* JsxSelfClosingElement */: + case 235 /* JsxOpeningElement */: + case 239 /* JsxSpreadAttribute */: + case 240 /* JsxExpression */: + case 169 /* NewExpression */: + case 172 /* ParenthesizedExpression */: + case 180 /* PostfixUnaryExpression */: + case 179 /* PrefixUnaryExpression */: + case 204 /* ReturnStatement */: + case 246 /* ShorthandPropertyAssignment */: + case 185 /* SpreadElementExpression */: + case 206 /* SwitchStatement */: + case 170 /* TaggedTemplateExpression */: + case 190 /* TemplateSpan */: + case 208 /* ThrowStatement */: + case 171 /* TypeAssertionExpression */: + case 176 /* TypeOfExpression */: + case 177 /* VoidExpression */: + case 198 /* WhileStatement */: + case 205 /* WithStatement */: + case 184 /* YieldExpression */: + return true; + case 163 /* BindingElement */: + case 247 /* EnumMember */: + case 138 /* Parameter */: + case 245 /* PropertyAssignment */: + case 141 /* PropertyDeclaration */: + case 211 /* VariableDeclaration */: + return parent.initializer === node; + case 166 /* PropertyAccessExpression */: + return parent.expression === node; + case 174 /* ArrowFunction */: + case 173 /* FunctionExpression */: + return parent.body === node; + case 221 /* ImportEqualsDeclaration */: + return parent.moduleReference === node; + case 135 /* QualifiedName */: + return parent.left === node; + } + return false; + } + function emitExpressionIdentifier(node) { + if (resolver.getNodeCheckFlags(node) & 2048 /* LexicalArguments */) { + write("_arguments"); + return; + } + var container = resolver.getReferencedExportContainer(node); + if (container) { + if (container.kind === 248 /* SourceFile */) { + // Identifier references module export + if (modulekind !== 5 /* ES6 */ && modulekind !== 4 /* System */) { + write("exports."); + } + } + else { + // Identifier references namespace export + write(getGeneratedNameForNode(container)); + write("."); + } + } + else { + if (modulekind !== 5 /* ES6 */) { + var declaration = resolver.getReferencedImportDeclaration(node); + if (declaration) { + if (declaration.kind === 223 /* ImportClause */) { + // Identifier references default import + write(getGeneratedNameForNode(declaration.parent)); + write(languageVersion === 0 /* ES3 */ ? "[\"default\"]" : ".default"); + return; + } + else if (declaration.kind === 226 /* ImportSpecifier */) { + // Identifier references named import + write(getGeneratedNameForNode(declaration.parent.parent.parent)); + var name_23 = declaration.propertyName || declaration.name; + var identifier = ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, name_23); + if (languageVersion === 0 /* ES3 */ && identifier === "default") { + write("[\"default\"]"); + } + else { + write("."); + write(identifier); + } + return; + } + } + } + if (languageVersion !== 2 /* ES6 */) { + var declaration = resolver.getReferencedNestedRedeclaration(node); + if (declaration) { + write(getGeneratedNameForNode(declaration.name)); + return; + } + } + } + if (ts.nodeIsSynthesized(node)) { + write(node.text); + } + else { + writeTextOfNode(currentSourceFile, node); + } + } + function isNameOfNestedRedeclaration(node) { + if (languageVersion < 2 /* ES6 */) { + var parent_6 = node.parent; + switch (parent_6.kind) { + case 163 /* BindingElement */: + case 214 /* ClassDeclaration */: + case 217 /* EnumDeclaration */: + case 211 /* VariableDeclaration */: + return parent_6.name === node && resolver.isNestedRedeclaration(parent_6); + } + } + return false; + } + function emitIdentifier(node) { + if (convertedLoopState) { + if (node.text == "arguments" && resolver.isArgumentsLocalBinding(node)) { + // in converted loop body arguments cannot be used directly. + var name_24 = convertedLoopState.argumentsName || (convertedLoopState.argumentsName = makeUniqueName("arguments")); + write(name_24); + return; + } + } + if (!node.parent) { + write(node.text); + } + else if (isExpressionIdentifier(node)) { + emitExpressionIdentifier(node); + } + else if (isNameOfNestedRedeclaration(node)) { + write(getGeneratedNameForNode(node)); + } + else if (ts.nodeIsSynthesized(node)) { + write(node.text); + } + else { + writeTextOfNode(currentSourceFile, node); + } + } + function emitThis(node) { + if (resolver.getNodeCheckFlags(node) & 2 /* LexicalThis */) { + write("_this"); + } + else { + write("this"); + } + } + function emitSuper(node) { + if (languageVersion >= 2 /* ES6 */) { + write("super"); + } + else { + var flags = resolver.getNodeCheckFlags(node); + if (flags & 256 /* SuperInstance */) { + write("_super.prototype"); + } + else { + write("_super"); + } + } + } + function emitObjectBindingPattern(node) { + write("{ "); + var elements = node.elements; + emitList(elements, 0, elements.length, /*multiLine*/ false, /*trailingComma*/ elements.hasTrailingComma); + write(" }"); + } + function emitArrayBindingPattern(node) { + write("["); + var elements = node.elements; + emitList(elements, 0, elements.length, /*multiLine*/ false, /*trailingComma*/ elements.hasTrailingComma); + write("]"); + } + function emitBindingElement(node) { + if (node.propertyName) { + emit(node.propertyName); + write(": "); + } + if (node.dotDotDotToken) { + write("..."); + } + if (ts.isBindingPattern(node.name)) { + emit(node.name); + } + else { + emitModuleMemberName(node); + } + emitOptional(" = ", node.initializer); + } + function emitSpreadElementExpression(node) { + write("..."); + emit(node.expression); + } + function emitYieldExpression(node) { + write(ts.tokenToString(114 /* YieldKeyword */)); + if (node.asteriskToken) { + write("*"); + } + if (node.expression) { + write(" "); + emit(node.expression); + } + } + function emitAwaitExpression(node) { + var needsParenthesis = needsParenthesisForAwaitExpressionAsYield(node); + if (needsParenthesis) { + write("("); + } + write(ts.tokenToString(114 /* YieldKeyword */)); + write(" "); + emit(node.expression); + if (needsParenthesis) { + write(")"); + } + } + function needsParenthesisForAwaitExpressionAsYield(node) { + if (node.parent.kind === 181 /* BinaryExpression */ && !ts.isAssignmentOperator(node.parent.operatorToken.kind)) { + return true; + } + else if (node.parent.kind === 182 /* ConditionalExpression */ && node.parent.condition === node) { + return true; + } + return false; + } + function needsParenthesisForPropertyAccessOrInvocation(node) { + switch (node.kind) { + case 69 /* Identifier */: + case 164 /* ArrayLiteralExpression */: + case 166 /* PropertyAccessExpression */: + case 167 /* ElementAccessExpression */: + case 168 /* CallExpression */: + case 172 /* ParenthesizedExpression */: + // This list is not exhaustive and only includes those cases that are relevant + // to the check in emitArrayLiteral. More cases can be added as needed. + return false; + } + return true; + } + function emitListWithSpread(elements, needsUniqueCopy, multiLine, trailingComma, useConcat) { + var pos = 0; + var group = 0; + var length = elements.length; + while (pos < length) { + // Emit using the pattern .concat(, , ...) + if (group === 1 && useConcat) { + write(".concat("); + } + else if (group > 0) { + write(", "); + } + var e = elements[pos]; + if (e.kind === 185 /* SpreadElementExpression */) { + e = e.expression; + emitParenthesizedIf(e, /*parenthesized*/ group === 0 && needsParenthesisForPropertyAccessOrInvocation(e)); + pos++; + if (pos === length && group === 0 && needsUniqueCopy && e.kind !== 164 /* ArrayLiteralExpression */) { + write(".slice()"); + } + } + else { + var i = pos; + while (i < length && elements[i].kind !== 185 /* SpreadElementExpression */) { + i++; + } + write("["); + if (multiLine) { + increaseIndent(); + } + emitList(elements, pos, i - pos, multiLine, trailingComma && i === length); + if (multiLine) { + decreaseIndent(); + } + write("]"); + pos = i; + } + group++; + } + if (group > 1) { + if (useConcat) { + write(")"); + } + } + } + function isSpreadElementExpression(node) { + return node.kind === 185 /* SpreadElementExpression */; + } + function emitArrayLiteral(node) { + var elements = node.elements; + if (elements.length === 0) { + write("[]"); + } + else if (languageVersion >= 2 /* ES6 */ || !ts.forEach(elements, isSpreadElementExpression)) { + write("["); + emitLinePreservingList(node, node.elements, elements.hasTrailingComma, /*spacesBetweenBraces:*/ false); + write("]"); + } + else { + emitListWithSpread(elements, /*needsUniqueCopy*/ true, /*multiLine*/ (node.flags & 2048 /* MultiLine */) !== 0, + /*trailingComma*/ elements.hasTrailingComma, /*useConcat*/ true); + } + } + function emitObjectLiteralBody(node, numElements) { + if (numElements === 0) { + write("{}"); + return; + } + write("{"); + if (numElements > 0) { + var properties = node.properties; + // If we are not doing a downlevel transformation for object literals, + // then try to preserve the original shape of the object literal. + // Otherwise just try to preserve the formatting. + if (numElements === properties.length) { + emitLinePreservingList(node, properties, /* allowTrailingComma */ languageVersion >= 1 /* ES5 */, /* spacesBetweenBraces */ true); + } + else { + var multiLine = (node.flags & 2048 /* MultiLine */) !== 0; + if (!multiLine) { + write(" "); + } + else { + increaseIndent(); + } + emitList(properties, 0, numElements, /*multiLine*/ multiLine, /*trailingComma*/ false); + if (!multiLine) { + write(" "); + } + else { + decreaseIndent(); + } + } + } + write("}"); + } + function emitDownlevelObjectLiteralWithComputedProperties(node, firstComputedPropertyIndex) { + var multiLine = (node.flags & 2048 /* MultiLine */) !== 0; + var properties = node.properties; + write("("); + if (multiLine) { + increaseIndent(); + } + // 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 tempVar = createAndRecordTempVariable(0 /* Auto */); + // Write out the first non-computed properties + // (or all properties if none of them are computed), + // then emit the rest through indexing on the temp variable. + emit(tempVar); + write(" = "); + emitObjectLiteralBody(node, firstComputedPropertyIndex); + for (var i = firstComputedPropertyIndex, n = properties.length; i < n; i++) { + writeComma(); + var property = properties[i]; + emitStart(property); + if (property.kind === 145 /* GetAccessor */ || property.kind === 146 /* SetAccessor */) { + // TODO (drosen): Reconcile with 'emitMemberFunctions'. + var accessors = ts.getAllAccessorDeclarations(node.properties, property); + if (property !== accessors.firstAccessor) { + continue; + } + write("Object.defineProperty("); + emit(tempVar); + write(", "); + emitStart(node.name); + emitExpressionForPropertyName(property.name); + emitEnd(property.name); + write(", {"); + increaseIndent(); + if (accessors.getAccessor) { + writeLine(); + emitLeadingComments(accessors.getAccessor); + write("get: "); + emitStart(accessors.getAccessor); + write("function "); + emitSignatureAndBody(accessors.getAccessor); + emitEnd(accessors.getAccessor); + emitTrailingComments(accessors.getAccessor); + write(","); + } + if (accessors.setAccessor) { + writeLine(); + emitLeadingComments(accessors.setAccessor); + write("set: "); + emitStart(accessors.setAccessor); + write("function "); + emitSignatureAndBody(accessors.setAccessor); + emitEnd(accessors.setAccessor); + emitTrailingComments(accessors.setAccessor); + write(","); + } + writeLine(); + write("enumerable: true,"); + writeLine(); + write("configurable: true"); + decreaseIndent(); + writeLine(); + write("})"); + emitEnd(property); + } + else { + emitLeadingComments(property); + emitStart(property.name); + emit(tempVar); + emitMemberAccessForPropertyName(property.name); + emitEnd(property.name); + write(" = "); + if (property.kind === 245 /* PropertyAssignment */) { + emit(property.initializer); + } + else if (property.kind === 246 /* ShorthandPropertyAssignment */) { + emitExpressionIdentifier(property.name); + } + else if (property.kind === 143 /* MethodDeclaration */) { + emitFunctionDeclaration(property); + } + else { + ts.Debug.fail("ObjectLiteralElement type not accounted for: " + property.kind); + } + } + emitEnd(property); + } + writeComma(); + emit(tempVar); + if (multiLine) { + decreaseIndent(); + writeLine(); + } + write(")"); + function writeComma() { + if (multiLine) { + write(","); + writeLine(); + } + else { + write(", "); + } + } + } + function emitObjectLiteral(node) { + var properties = node.properties; + if (languageVersion < 2 /* ES6 */) { + var numProperties = properties.length; + // Find the first computed property. + // Everything until that point can be emitted as part of the initial object literal. + var numInitialNonComputedProperties = numProperties; + for (var i = 0, n = properties.length; i < n; i++) { + if (properties[i].name.kind === 136 /* ComputedPropertyName */) { + numInitialNonComputedProperties = i; + break; + } + } + var hasComputedProperty = numInitialNonComputedProperties !== properties.length; + if (hasComputedProperty) { + emitDownlevelObjectLiteralWithComputedProperties(node, numInitialNonComputedProperties); + return; + } + } + // Ordinary case: either the object has no computed properties + // or we're compiling with an ES6+ target. + emitObjectLiteralBody(node, properties.length); + } + function createBinaryExpression(left, operator, right, startsOnNewLine) { + var result = ts.createSynthesizedNode(181 /* BinaryExpression */, startsOnNewLine); + result.operatorToken = ts.createSynthesizedNode(operator); + result.left = left; + result.right = right; + return result; + } + function createPropertyAccessExpression(expression, name) { + var result = ts.createSynthesizedNode(166 /* PropertyAccessExpression */); + result.expression = parenthesizeForAccess(expression); + result.dotToken = ts.createSynthesizedNode(21 /* DotToken */); + result.name = name; + return result; + } + function createElementAccessExpression(expression, argumentExpression) { + var result = ts.createSynthesizedNode(167 /* ElementAccessExpression */); + result.expression = parenthesizeForAccess(expression); + result.argumentExpression = argumentExpression; + return result; + } + function parenthesizeForAccess(expr) { + // When diagnosing whether the expression needs parentheses, the decision should be based + // on the innermost expression in a chain of nested type assertions. + while (expr.kind === 171 /* TypeAssertionExpression */ || expr.kind === 189 /* AsExpression */) { + expr = expr.expression; + } + // isLeftHandSideExpression is almost the correct criterion for when it is not necessary + // to parenthesize the expression before a dot. The known exceptions are: + // + // NewExpression: + // new C.x -> not the same as (new C).x + // NumberLiteral + // 1.x -> not the same as (1).x + // + if (ts.isLeftHandSideExpression(expr) && + expr.kind !== 169 /* NewExpression */ && + expr.kind !== 8 /* NumericLiteral */) { + return expr; + } + var node = ts.createSynthesizedNode(172 /* ParenthesizedExpression */); + node.expression = expr; + return node; + } + function emitComputedPropertyName(node) { + write("["); + emitExpressionForPropertyName(node); + write("]"); + } + function emitMethod(node) { + if (languageVersion >= 2 /* ES6 */ && node.asteriskToken) { + write("*"); + } + emit(node.name); + if (languageVersion < 2 /* ES6 */) { + write(": function "); + } + emitSignatureAndBody(node); + } + function emitPropertyAssignment(node) { + emit(node.name); + write(": "); + // This is to ensure that we emit comment in the following case: + // For example: + // obj = { + // id: /*comment1*/ ()=>void + // } + // "comment1" is not considered to be leading comment for node.initializer + // but rather a trailing comment on the previous node. + emitTrailingCommentsOfPosition(node.initializer.pos); + emit(node.initializer); + } + // Return true if identifier resolves to an exported member of a namespace + function isNamespaceExportReference(node) { + var container = resolver.getReferencedExportContainer(node); + return container && container.kind !== 248 /* SourceFile */; + } + function emitShorthandPropertyAssignment(node) { + // The name property of a short-hand property assignment is considered an expression position, so here + // we manually emit the identifier to avoid rewriting. + writeTextOfNode(currentSourceFile, node.name); + // If emitting pre-ES6 code, or if the name requires rewriting when resolved as an expression identifier, + // we emit a normal property assignment. For example: + // module m { + // export let y; + // } + // module m { + // let obj = { y }; + // } + // Here we need to emit obj = { y : m.y } regardless of the output target. + if (languageVersion < 2 /* ES6 */ || isNamespaceExportReference(node.name)) { + // Emit identifier as an identifier + write(": "); + emit(node.name); + } + if (languageVersion >= 2 /* ES6 */ && node.objectAssignmentInitializer) { + write(" = "); + emit(node.objectAssignmentInitializer); + } + } + function tryEmitConstantValue(node) { + var constantValue = tryGetConstEnumValue(node); + if (constantValue !== undefined) { + write(constantValue.toString()); + if (!compilerOptions.removeComments) { + var propertyName = node.kind === 166 /* PropertyAccessExpression */ ? ts.declarationNameToString(node.name) : ts.getTextOfNode(node.argumentExpression); + write(" /* " + propertyName + " */"); + } + return true; + } + return false; + } + function tryGetConstEnumValue(node) { + if (compilerOptions.isolatedModules) { + return undefined; + } + return node.kind === 166 /* PropertyAccessExpression */ || node.kind === 167 /* ElementAccessExpression */ + ? resolver.getConstantValue(node) + : undefined; + } + // Returns 'true' if the code was actually indented, false otherwise. + // If the code is not indented, an optional valueToWriteWhenNotIndenting will be + // emitted instead. + function indentIfOnDifferentLines(parent, node1, node2, valueToWriteWhenNotIndenting) { + var realNodesAreOnDifferentLines = !ts.nodeIsSynthesized(parent) && !nodeEndIsOnSameLineAsNodeStart(node1, node2); + // Always use a newline for synthesized code if the synthesizer desires it. + var synthesizedNodeIsOnDifferentLine = synthesizedNodeStartsOnNewLine(node2); + if (realNodesAreOnDifferentLines || synthesizedNodeIsOnDifferentLine) { + increaseIndent(); + writeLine(); + return true; + } + else { + if (valueToWriteWhenNotIndenting) { + write(valueToWriteWhenNotIndenting); + } + return false; + } + } + function emitPropertyAccess(node) { + if (tryEmitConstantValue(node)) { + return; + } + emit(node.expression); + var indentedBeforeDot = indentIfOnDifferentLines(node, node.expression, node.dotToken); + // 1 .toString is a valid property access, emit a space after the literal + // Also emit a space if expression is a integer const enum value - it will appear in generated code as numeric literal + var shouldEmitSpace; + if (!indentedBeforeDot) { + if (node.expression.kind === 8 /* NumericLiteral */) { + // check if numeric literal was originally written with a dot + var text = ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, node.expression); + shouldEmitSpace = text.indexOf(ts.tokenToString(21 /* DotToken */)) < 0; + } + else { + // check if constant enum value is integer + var constantValue = tryGetConstEnumValue(node.expression); + // isFinite handles cases when constantValue is undefined + shouldEmitSpace = isFinite(constantValue) && Math.floor(constantValue) === constantValue; + } + } + if (shouldEmitSpace) { + write(" ."); + } + else { + write("."); + } + var indentedAfterDot = indentIfOnDifferentLines(node, node.dotToken, node.name); + emit(node.name); + decreaseIndentIf(indentedBeforeDot, indentedAfterDot); + } + function emitQualifiedName(node) { + emit(node.left); + write("."); + emit(node.right); + } + function emitQualifiedNameAsExpression(node, useFallback) { + if (node.left.kind === 69 /* Identifier */) { + emitEntityNameAsExpression(node.left, useFallback); + } + else if (useFallback) { + var temp = createAndRecordTempVariable(0 /* Auto */); + write("("); + emitNodeWithoutSourceMap(temp); + write(" = "); + emitEntityNameAsExpression(node.left, /*useFallback*/ true); + write(") && "); + emitNodeWithoutSourceMap(temp); + } + else { + emitEntityNameAsExpression(node.left, /*useFallback*/ false); + } + write("."); + emit(node.right); + } + function emitEntityNameAsExpression(node, useFallback) { + switch (node.kind) { + case 69 /* Identifier */: + if (useFallback) { + write("typeof "); + emitExpressionIdentifier(node); + write(" !== 'undefined' && "); + } + emitExpressionIdentifier(node); + break; + case 135 /* QualifiedName */: + emitQualifiedNameAsExpression(node, useFallback); + break; + } + } + function emitIndexedAccess(node) { + if (tryEmitConstantValue(node)) { + return; + } + emit(node.expression); + write("["); + emit(node.argumentExpression); + write("]"); + } + function hasSpreadElement(elements) { + return ts.forEach(elements, function (e) { return e.kind === 185 /* SpreadElementExpression */; }); + } + function skipParentheses(node) { + while (node.kind === 172 /* ParenthesizedExpression */ || node.kind === 171 /* TypeAssertionExpression */ || node.kind === 189 /* AsExpression */) { + node = node.expression; + } + return node; + } + function emitCallTarget(node) { + if (node.kind === 69 /* Identifier */ || node.kind === 97 /* ThisKeyword */ || node.kind === 95 /* SuperKeyword */) { + emit(node); + return node; + } + var temp = createAndRecordTempVariable(0 /* Auto */); + write("("); + emit(temp); + write(" = "); + emit(node); + write(")"); + return temp; + } + function emitCallWithSpread(node) { + var target; + var expr = skipParentheses(node.expression); + if (expr.kind === 166 /* PropertyAccessExpression */) { + // Target will be emitted as "this" argument + target = emitCallTarget(expr.expression); + write("."); + emit(expr.name); + } + else if (expr.kind === 167 /* ElementAccessExpression */) { + // Target will be emitted as "this" argument + target = emitCallTarget(expr.expression); + write("["); + emit(expr.argumentExpression); + write("]"); + } + else if (expr.kind === 95 /* SuperKeyword */) { + target = expr; + write("_super"); + } + else { + emit(node.expression); + } + write(".apply("); + if (target) { + if (target.kind === 95 /* SuperKeyword */) { + // Calls of form super(...) and super.foo(...) + emitThis(target); + } + else { + // Calls of form obj.foo(...) + emit(target); + } + } + else { + // Calls of form foo(...) + write("void 0"); + } + write(", "); + emitListWithSpread(node.arguments, /*needsUniqueCopy*/ false, /*multiLine*/ false, /*trailingComma*/ false, /*useConcat*/ true); + write(")"); + } + function emitCallExpression(node) { + if (languageVersion < 2 /* ES6 */ && hasSpreadElement(node.arguments)) { + emitCallWithSpread(node); + return; + } + var superCall = false; + if (node.expression.kind === 95 /* SuperKeyword */) { + emitSuper(node.expression); + superCall = true; + } + else { + emit(node.expression); + superCall = node.expression.kind === 166 /* PropertyAccessExpression */ && node.expression.expression.kind === 95 /* SuperKeyword */; + } + if (superCall && languageVersion < 2 /* ES6 */) { + write(".call("); + emitThis(node.expression); + if (node.arguments.length) { + write(", "); + emitCommaList(node.arguments); + } + write(")"); + } + else { + write("("); + emitCommaList(node.arguments); + write(")"); + } + } + function emitNewExpression(node) { + write("new "); + // Spread operator logic is supported in new expressions in ES5 using a combination + // of Function.prototype.bind() and Function.prototype.apply(). + // + // Example: + // + // var args = [1, 2, 3, 4, 5]; + // new Array(...args); + // + // is compiled into the following ES5: + // + // var args = [1, 2, 3, 4, 5]; + // new (Array.bind.apply(Array, [void 0].concat(args))); + // + // The 'thisArg' to 'bind' is ignored when invoking the result of 'bind' with 'new', + // Thus, we set it to undefined ('void 0'). + if (languageVersion === 1 /* ES5 */ && + node.arguments && + hasSpreadElement(node.arguments)) { + write("("); + var target = emitCallTarget(node.expression); + write(".bind.apply("); + emit(target); + write(", [void 0].concat("); + emitListWithSpread(node.arguments, /*needsUniqueCopy*/ false, /*multiline*/ false, /*trailingComma*/ false, /*useConcat*/ false); + write(")))"); + write("()"); + } + else { + emit(node.expression); + if (node.arguments) { + write("("); + emitCommaList(node.arguments); + write(")"); + } + } + } + function emitTaggedTemplateExpression(node) { + if (languageVersion >= 2 /* ES6 */) { + emit(node.tag); + write(" "); + emit(node.template); + } + else { + emitDownlevelTaggedTemplate(node); + } + } + function emitParenExpression(node) { + // If the node is synthesized, it means the emitter put the parentheses there, + // not the user. If we didn't want them, the emitter would not have put them + // there. + if (!ts.nodeIsSynthesized(node) && node.parent.kind !== 174 /* ArrowFunction */) { + if (node.expression.kind === 171 /* TypeAssertionExpression */ || node.expression.kind === 189 /* AsExpression */) { + var operand = node.expression.expression; + // Make sure we consider all nested cast expressions, e.g.: + // (-A).x; + while (operand.kind === 171 /* TypeAssertionExpression */ || operand.kind === 189 /* AsExpression */) { + operand = operand.expression; + } + // We have an expression of the form: (SubExpr) + // Emitting this as (SubExpr) is really not desirable. We would like to emit the subexpr as is. + // Omitting the parentheses, however, could cause change in the semantics of the generated + // code if the casted expression has a lower precedence than the rest of the expression, e.g.: + // (new A).foo should be emitted as (new A).foo and not new A.foo + // (typeof A).toString() should be emitted as (typeof A).toString() and not typeof A.toString() + // new (A()) should be emitted as new (A()) and not new A() + // (function foo() { })() should be emitted as an IIF (function foo(){})() and not declaration function foo(){} () + if (operand.kind !== 179 /* PrefixUnaryExpression */ && + operand.kind !== 177 /* VoidExpression */ && + operand.kind !== 176 /* TypeOfExpression */ && + operand.kind !== 175 /* DeleteExpression */ && + operand.kind !== 180 /* PostfixUnaryExpression */ && + operand.kind !== 169 /* NewExpression */ && + !(operand.kind === 168 /* CallExpression */ && node.parent.kind === 169 /* NewExpression */) && + !(operand.kind === 173 /* FunctionExpression */ && node.parent.kind === 168 /* CallExpression */) && + !(operand.kind === 8 /* NumericLiteral */ && node.parent.kind === 166 /* PropertyAccessExpression */)) { + emit(operand); + return; + } + } + } + write("("); + emit(node.expression); + write(")"); + } + function emitDeleteExpression(node) { + write(ts.tokenToString(78 /* DeleteKeyword */)); + write(" "); + emit(node.expression); + } + function emitVoidExpression(node) { + write(ts.tokenToString(103 /* VoidKeyword */)); + write(" "); + emit(node.expression); + } + function emitTypeOfExpression(node) { + write(ts.tokenToString(101 /* TypeOfKeyword */)); + write(" "); + emit(node.expression); + } + function isNameOfExportedSourceLevelDeclarationInSystemExternalModule(node) { + if (!isCurrentFileSystemExternalModule() || node.kind !== 69 /* Identifier */ || ts.nodeIsSynthesized(node)) { + return false; + } + var isVariableDeclarationOrBindingElement = node.parent && (node.parent.kind === 211 /* VariableDeclaration */ || node.parent.kind === 163 /* BindingElement */); + var targetDeclaration = isVariableDeclarationOrBindingElement + ? node.parent + : resolver.getReferencedValueDeclaration(node); + return isSourceFileLevelDeclarationInSystemJsModule(targetDeclaration, /*isExported*/ true); + } + function emitPrefixUnaryExpression(node) { + var exportChanged = isNameOfExportedSourceLevelDeclarationInSystemExternalModule(node.operand); + if (exportChanged) { + // emit + // ++x + // as + // exports('x', ++x) + write(exportFunctionForFile + "(\""); + emitNodeWithoutSourceMap(node.operand); + write("\", "); + } + write(ts.tokenToString(node.operator)); + // In some cases, we need to emit a space between the operator and the operand. One obvious case + // is when the operator is an identifier, like delete or typeof. We also need to do this for plus + // and minus expressions in certain cases. Specifically, consider the following two cases (parens + // are just for clarity of exposition, and not part of the source code): + // + // (+(+1)) + // (+(++1)) + // + // We need to emit a space in both cases. In the first case, the absence of a space will make + // the resulting expression a prefix increment operation. And in the second, it will make the resulting + // expression a prefix increment whose operand is a plus expression - (++(+x)) + // The same is true of minus of course. + if (node.operand.kind === 179 /* PrefixUnaryExpression */) { + var operand = node.operand; + if (node.operator === 35 /* PlusToken */ && (operand.operator === 35 /* PlusToken */ || operand.operator === 41 /* PlusPlusToken */)) { + write(" "); + } + else if (node.operator === 36 /* MinusToken */ && (operand.operator === 36 /* MinusToken */ || operand.operator === 42 /* MinusMinusToken */)) { + write(" "); + } + } + emit(node.operand); + if (exportChanged) { + write(")"); + } + } + function emitPostfixUnaryExpression(node) { + var exportChanged = isNameOfExportedSourceLevelDeclarationInSystemExternalModule(node.operand); + if (exportChanged) { + // 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)' + write("(" + exportFunctionForFile + "(\""); + emitNodeWithoutSourceMap(node.operand); + write("\", "); + write(ts.tokenToString(node.operator)); + emit(node.operand); + if (node.operator === 41 /* PlusPlusToken */) { + write(") - 1)"); + } + else { + write(") + 1)"); + } + } + else { + emit(node.operand); + write(ts.tokenToString(node.operator)); + } + } + function shouldHoistDeclarationInSystemJsModule(node) { + return isSourceFileLevelDeclarationInSystemJsModule(node, /*isExported*/ false); + } + /* + * Checks if given node is a source file level declaration (not nested in module/function). + * If 'isExported' is true - then declaration must also be exported. + * This function is used in two cases: + * - check if node is a exported source file level value to determine + * if we should also export the value after its it changed + * - check if node is a source level declaration to emit it differently, + * i.e non-exported variable statement 'var x = 1' is hoisted so + * we we emit variable statement 'var' should be dropped. + */ + function isSourceFileLevelDeclarationInSystemJsModule(node, isExported) { + if (!node || !isCurrentFileSystemExternalModule()) { + return false; + } + var current = node; + while (current) { + if (current.kind === 248 /* SourceFile */) { + return !isExported || ((ts.getCombinedNodeFlags(node) & 1 /* Export */) !== 0); + } + else if (ts.isFunctionLike(current) || current.kind === 219 /* ModuleBlock */) { + return false; + } + else { + current = current.parent; + } + } + } + /** + * Emit ES7 exponentiation operator downlevel using Math.pow + * @param node a binary expression node containing exponentiationOperator (**, **=) + */ + function emitExponentiationOperator(node) { + var leftHandSideExpression = node.left; + if (node.operatorToken.kind === 60 /* AsteriskAsteriskEqualsToken */) { + var synthesizedLHS; + var shouldEmitParentheses = false; + if (ts.isElementAccessExpression(leftHandSideExpression)) { + shouldEmitParentheses = true; + write("("); + synthesizedLHS = ts.createSynthesizedNode(167 /* ElementAccessExpression */, /*startsOnNewLine*/ false); + var identifier = emitTempVariableAssignment(leftHandSideExpression.expression, /*canDefinedTempVariablesInPlaces*/ false, /*shouldEmitCommaBeforeAssignment*/ false); + synthesizedLHS.expression = identifier; + if (leftHandSideExpression.argumentExpression.kind !== 8 /* NumericLiteral */ && + leftHandSideExpression.argumentExpression.kind !== 9 /* StringLiteral */) { + var tempArgumentExpression = createAndRecordTempVariable(268435456 /* _i */); + synthesizedLHS.argumentExpression = tempArgumentExpression; + emitAssignment(tempArgumentExpression, leftHandSideExpression.argumentExpression, /*shouldEmitCommaBeforeAssignment*/ true); + } + else { + synthesizedLHS.argumentExpression = leftHandSideExpression.argumentExpression; + } + write(", "); + } + else if (ts.isPropertyAccessExpression(leftHandSideExpression)) { + shouldEmitParentheses = true; + write("("); + synthesizedLHS = ts.createSynthesizedNode(166 /* PropertyAccessExpression */, /*startsOnNewLine*/ false); + var identifier = emitTempVariableAssignment(leftHandSideExpression.expression, /*canDefinedTempVariablesInPlaces*/ false, /*shouldemitCommaBeforeAssignment*/ false); + synthesizedLHS.expression = identifier; + synthesizedLHS.dotToken = leftHandSideExpression.dotToken; + synthesizedLHS.name = leftHandSideExpression.name; + write(", "); + } + emit(synthesizedLHS || leftHandSideExpression); + write(" = "); + write("Math.pow("); + emit(synthesizedLHS || leftHandSideExpression); + write(", "); + emit(node.right); + write(")"); + if (shouldEmitParentheses) { + write(")"); + } + } + else { + write("Math.pow("); + emit(leftHandSideExpression); + write(", "); + emit(node.right); + write(")"); + } + } + function emitBinaryExpression(node) { + if (languageVersion < 2 /* ES6 */ && node.operatorToken.kind === 56 /* EqualsToken */ && + (node.left.kind === 165 /* ObjectLiteralExpression */ || node.left.kind === 164 /* ArrayLiteralExpression */)) { + emitDestructuring(node, node.parent.kind === 195 /* ExpressionStatement */); + } + else { + var exportChanged = node.operatorToken.kind >= 56 /* FirstAssignment */ && + node.operatorToken.kind <= 68 /* LastAssignment */ && + isNameOfExportedSourceLevelDeclarationInSystemExternalModule(node.left); + if (exportChanged) { + // emit assignment 'x y' as 'exports("x", x y)' + write(exportFunctionForFile + "(\""); + emitNodeWithoutSourceMap(node.left); + write("\", "); + } + if (node.operatorToken.kind === 38 /* AsteriskAsteriskToken */ || node.operatorToken.kind === 60 /* AsteriskAsteriskEqualsToken */) { + // Downleveled emit exponentiation operator using Math.pow + emitExponentiationOperator(node); + } + else { + emit(node.left); + // Add indentation before emit the operator if the operator is on different line + // For example: + // 3 + // + 2; + // emitted as + // 3 + // + 2; + var indentedBeforeOperator = indentIfOnDifferentLines(node, node.left, node.operatorToken, node.operatorToken.kind !== 24 /* CommaToken */ ? " " : undefined); + write(ts.tokenToString(node.operatorToken.kind)); + var indentedAfterOperator = indentIfOnDifferentLines(node, node.operatorToken, node.right, " "); + emit(node.right); + decreaseIndentIf(indentedBeforeOperator, indentedAfterOperator); + } + if (exportChanged) { + write(")"); + } + } + } + function synthesizedNodeStartsOnNewLine(node) { + return ts.nodeIsSynthesized(node) && node.startsOnNewLine; + } + function emitConditionalExpression(node) { + emit(node.condition); + var indentedBeforeQuestion = indentIfOnDifferentLines(node, node.condition, node.questionToken, " "); + write("?"); + var indentedAfterQuestion = indentIfOnDifferentLines(node, node.questionToken, node.whenTrue, " "); + emit(node.whenTrue); + decreaseIndentIf(indentedBeforeQuestion, indentedAfterQuestion); + var indentedBeforeColon = indentIfOnDifferentLines(node, node.whenTrue, node.colonToken, " "); + write(":"); + var indentedAfterColon = indentIfOnDifferentLines(node, node.colonToken, node.whenFalse, " "); + emit(node.whenFalse); + decreaseIndentIf(indentedBeforeColon, indentedAfterColon); + } + // Helper function to decrease the indent if we previously indented. Allows multiple + // previous indent values to be considered at a time. This also allows caller to just + // call this once, passing in all their appropriate indent values, instead of needing + // to call this helper function multiple times. + function decreaseIndentIf(value1, value2) { + if (value1) { + decreaseIndent(); + } + if (value2) { + decreaseIndent(); + } + } + function isSingleLineEmptyBlock(node) { + if (node && node.kind === 192 /* Block */) { + var block = node; + return block.statements.length === 0 && nodeEndIsOnSameLineAsNodeStart(block, block); + } + } + function emitBlock(node) { + if (isSingleLineEmptyBlock(node)) { + emitToken(15 /* OpenBraceToken */, node.pos); + write(" "); + emitToken(16 /* CloseBraceToken */, node.statements.end); + return; + } + emitToken(15 /* OpenBraceToken */, node.pos); + increaseIndent(); + scopeEmitStart(node.parent); + if (node.kind === 219 /* ModuleBlock */) { + ts.Debug.assert(node.parent.kind === 218 /* ModuleDeclaration */); + emitCaptureThisForNodeIfNecessary(node.parent); + } + emitLines(node.statements); + if (node.kind === 219 /* ModuleBlock */) { + emitTempDeclarations(/*newLine*/ true); + } + decreaseIndent(); + writeLine(); + emitToken(16 /* CloseBraceToken */, node.statements.end); + scopeEmitEnd(); + } + function emitEmbeddedStatement(node) { + if (node.kind === 192 /* Block */) { + write(" "); + emit(node); + } + else { + increaseIndent(); + writeLine(); + emit(node); + decreaseIndent(); + } + } + function emitExpressionStatement(node) { + emitParenthesizedIf(node.expression, /*parenthesized*/ node.expression.kind === 174 /* ArrowFunction */); + write(";"); + } + function emitIfStatement(node) { + var endPos = emitToken(88 /* IfKeyword */, node.pos); + write(" "); + endPos = emitToken(17 /* OpenParenToken */, endPos); + emit(node.expression); + emitToken(18 /* CloseParenToken */, node.expression.end); + emitEmbeddedStatement(node.thenStatement); + if (node.elseStatement) { + writeLine(); + emitToken(80 /* ElseKeyword */, node.thenStatement.end); + if (node.elseStatement.kind === 196 /* IfStatement */) { + write(" "); + emit(node.elseStatement); + } + else { + emitEmbeddedStatement(node.elseStatement); + } + } + } + function emitDoStatement(node) { + emitLoop(node, emitDoStatementWorker); + } + function emitDoStatementWorker(node, loop) { + write("do"); + if (loop) { + emitConvertedLoopCall(loop, /* emitAsBlock */ true); + } + else { + emitNormalLoopBody(node, /* emitAsEmbeddedStatement */ true); + } + if (node.statement.kind === 192 /* Block */) { + write(" "); + } + else { + writeLine(); + } + write("while ("); + emit(node.expression); + write(");"); + } + function emitWhileStatement(node) { + emitLoop(node, emitWhileStatementWorker); + } + function emitWhileStatementWorker(node, loop) { + write("while ("); + emit(node.expression); + write(")"); + if (loop) { + emitConvertedLoopCall(loop, /* emitAsBlock */ true); + } + else { + emitNormalLoopBody(node, /* emitAsEmbeddedStatement */ true); + } + } + /** + * Returns true if start of variable declaration list was emitted. + * Returns false if nothing was written - this can happen for source file level variable declarations + * in system modules where such variable declarations are hoisted. + */ + function tryEmitStartOfVariableDeclarationList(decl, startPos) { + if (shouldHoistVariable(decl, /*checkIfSourceFileLevelDecl*/ true)) { + // variables in variable declaration list were already hoisted + return false; + } + if (convertedLoopState && (ts.getCombinedNodeFlags(decl) & 49152 /* BlockScoped */) === 0) { + // we are inside a converted loop - this can only happen in downlevel scenarios + // record names for all variable declarations + for (var _a = 0, _b = decl.declarations; _a < _b.length; _a++) { + var varDecl = _b[_a]; + hoistVariableDeclarationFromLoop(convertedLoopState, varDecl); + } + return false; + } + var tokenKind = 102 /* VarKeyword */; + if (decl && languageVersion >= 2 /* ES6 */) { + if (ts.isLet(decl)) { + tokenKind = 108 /* LetKeyword */; + } + else if (ts.isConst(decl)) { + tokenKind = 74 /* ConstKeyword */; + } + } + if (startPos !== undefined) { + emitToken(tokenKind, startPos); + write(" "); + } + else { + switch (tokenKind) { + case 102 /* VarKeyword */: + write("var "); + break; + case 108 /* LetKeyword */: + write("let "); + break; + case 74 /* ConstKeyword */: + write("const "); + break; + } + } + return true; + } + function emitVariableDeclarationListSkippingUninitializedEntries(list) { + var started = false; + for (var _a = 0, _b = list.declarations; _a < _b.length; _a++) { + var decl = _b[_a]; + if (!decl.initializer) { + continue; + } + if (!started) { + started = true; + } + else { + write(", "); + } + emit(decl); + } + return started; + } + function shouldConvertLoopBody(node) { + return languageVersion < 2 /* ES6 */ && + (resolver.getNodeCheckFlags(node) & 65536 /* LoopWithBlockScopedBindingCapturedInFunction */) !== 0; + } + function emitLoop(node, loopEmitter) { + var shouldConvert = shouldConvertLoopBody(node); + if (!shouldConvert) { + loopEmitter(node, /* convertedLoop*/ undefined); + } + else { + var loop = convertLoopBody(node); + if (node.parent.kind === 207 /* LabeledStatement */) { + // if parent of the loop was labeled statement - attach the label to loop skipping converted loop body + emitLabelAndColon(node.parent); + } + loopEmitter(node, loop); + } + } + function convertLoopBody(node) { + var functionName = makeUniqueName("_loop"); + var loopInitializer; + switch (node.kind) { + case 199 /* ForStatement */: + case 200 /* ForInStatement */: + case 201 /* ForOfStatement */: + if (node.initializer.kind === 212 /* VariableDeclarationList */) { + loopInitializer = node.initializer; + } + break; + } + var loopParameters; + if (loopInitializer && (ts.getCombinedNodeFlags(loopInitializer) & 49152 /* BlockScoped */)) { + // if loop initializer contains block scoped variables - they should be passed to converted loop body as parameters + loopParameters = []; + for (var _a = 0, _b = loopInitializer.declarations; _a < _b.length; _a++) { + var varDeclaration = _b[_a]; + collectNames(varDeclaration.name); + } + } + var bodyIsBlock = node.statement.kind === 192 /* Block */; + var paramList = loopParameters ? loopParameters.join(", ") : ""; + writeLine(); + write("var " + functionName + " = function(" + paramList + ")"); + if (!bodyIsBlock) { + write(" {"); + writeLine(); + increaseIndent(); + } + var convertedOuterLoopState = convertedLoopState; + convertedLoopState = {}; + if (convertedOuterLoopState) { + // 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 (convertedOuterLoopState.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 = convertedOuterLoopState.argumentsName; + } + if (convertedOuterLoopState.hoistedLocalVariables) { + // we've already collected some non-block scoped variable declarations in enclosing loop + // use the same storage in nested loop + convertedLoopState.hoistedLocalVariables = convertedOuterLoopState.hoistedLocalVariables; + } + } + emitEmbeddedStatement(node.statement); + if (!bodyIsBlock) { + decreaseIndent(); + writeLine(); + write("}"); + } + write(";"); + writeLine(); + if (convertedLoopState.argumentsName) { + // if alias for arguments is set + if (convertedOuterLoopState) { + // pass it to outer converted loop + convertedOuterLoopState.argumentsName = convertedLoopState.argumentsName; + } + else { + // this is top level converted loop and we need to create an alias for 'arguments' object + write("var " + convertedLoopState.argumentsName + " = arguments;"); + writeLine(); + } + } + if (convertedLoopState.hoistedLocalVariables) { + // if hoistedLocalVariables !== undefined this means that we've possibly collected some variable declarations to be hoisted later + if (convertedOuterLoopState) { + // pass them to outer converted loop + convertedOuterLoopState.hoistedLocalVariables = convertedLoopState.hoistedLocalVariables; + } + else { + // deduplicate and hoist collected variable declarations + write("var "); + var seen; + for (var _c = 0, _d = convertedLoopState.hoistedLocalVariables; _c < _d.length; _c++) { + var id = _d[_c]; + // Don't initialize seen unless we have at least one element. + // Emit a comma to separate for all but the first element. + if (!seen) { + seen = {}; + } + else { + write(", "); + } + if (!ts.hasProperty(seen, id.text)) { + emit(id); + seen[id.text] = id.text; + } + } + write(";"); + writeLine(); + } + } + var currentLoopState = convertedLoopState; + convertedLoopState = convertedOuterLoopState; + return { functionName: functionName, paramList: paramList, state: currentLoopState }; + function collectNames(name) { + if (name.kind === 69 /* Identifier */) { + var nameText = isNameOfNestedRedeclaration(name) ? getGeneratedNameForNode(name) : name.text; + loopParameters.push(nameText); + } + else { + for (var _a = 0, _b = name.elements; _a < _b.length; _a++) { + var element = _b[_a]; + collectNames(element.name); + } + } + } + } + function emitNormalLoopBody(node, emitAsEmbeddedStatement) { + var saveAllowedNonLabeledJumps; + 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 */; + } + if (emitAsEmbeddedStatement) { + emitEmbeddedStatement(node.statement); + } + else if (node.statement.kind === 192 /* Block */) { + emitLines(node.statement.statements); + } + else { + writeLine(); + emit(node.statement); + } + if (convertedLoopState) { + convertedLoopState.allowedNonLabeledJumps = saveAllowedNonLabeledJumps; + } + } + function emitConvertedLoopCall(loop, emitAsBlock) { + if (emitAsBlock) { + write(" {"); + writeLine(); + increaseIndent(); + } + // 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()'; + var isSimpleLoop = !loop.state.nonLocalJumps && + !loop.state.labeledNonLocalBreaks && + !loop.state.labeledNonLocalContinues; + var loopResult = makeUniqueName("state"); + if (!isSimpleLoop) { + write("var " + loopResult + " = "); + } + write(loop.functionName + "(" + loop.paramList + ");"); + if (!isSimpleLoop) { + // for non simple loops we need to store result returned from converted loop function and use it to do dispatching + // converted loop function can return: + // - object - used when body of the converted loop contains return statement. Property "value" of this object stores retuned value + // - string - used to dispatch jumps. "break" and "continue" are used to non-labeled jumps, other values are used to transfer control to + // different labels + writeLine(); + if (loop.state.nonLocalJumps & 8 /* Return */) { + write("if (typeof " + loopResult + " === \"object\") "); + if (convertedLoopState) { + // we are currently nested in another converted loop - return unwrapped result + write("return " + loopResult + ";"); + // propagate 'hasReturn' flag to outer loop + convertedLoopState.nonLocalJumps |= 8 /* Return */; + } + else { + // top level converted loop - return unwrapped value + write("return " + loopResult + ".value"); + } + writeLine(); + } + if (loop.state.nonLocalJumps & 2 /* Break */) { + write("if (" + loopResult + " === \"break\") break;"); + writeLine(); + } + if (loop.state.nonLocalJumps & 4 /* Continue */) { + write("if (" + loopResult + " === \"continue\") continue;"); + writeLine(); + } + // in case of labeled breaks emit code that either breaks to some known label inside outer loop or delegates jump decision to outer loop + emitDispatchTableForLabeledJumps(loopResult, loop.state, convertedLoopState); + } + if (emitAsBlock) { + writeLine(); + decreaseIndent(); + write("}"); + } + function emitDispatchTableForLabeledJumps(loopResultVariable, currentLoop, outerLoop) { + if (!currentLoop.labeledNonLocalBreaks && !currentLoop.labeledNonLocalContinues) { + return; + } + write("switch(" + loopResultVariable + ") {"); + increaseIndent(); + emitDispatchEntriesForLabeledJumps(currentLoop.labeledNonLocalBreaks, /* isBreak */ true, loopResultVariable, outerLoop); + emitDispatchEntriesForLabeledJumps(currentLoop.labeledNonLocalContinues, /* isBreak */ false, loopResultVariable, outerLoop); + decreaseIndent(); + writeLine(); + write("}"); + } + function emitDispatchEntriesForLabeledJumps(table, isBreak, loopResultVariable, outerLoop) { + if (!table) { + return; + } + for (var labelText in table) { + var labelMarker = table[labelText]; + writeLine(); + write("case \"" + labelMarker + "\": "); + // 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])) { + if (isBreak) { + write("break "); + } + else { + write("continue "); + } + write(labelText + ";"); + } + else { + setLabeledJump(outerLoop, isBreak, labelText, labelMarker); + write("return " + loopResultVariable + ";"); + } + } + } + } + function emitForStatement(node) { + emitLoop(node, emitForStatementWorker); + } + function emitForStatementWorker(node, loop) { + var endPos = emitToken(86 /* ForKeyword */, node.pos); + write(" "); + endPos = emitToken(17 /* OpenParenToken */, endPos); + if (node.initializer && node.initializer.kind === 212 /* VariableDeclarationList */) { + var variableDeclarationList = node.initializer; + var startIsEmitted = tryEmitStartOfVariableDeclarationList(variableDeclarationList, endPos); + if (startIsEmitted) { + emitCommaList(variableDeclarationList.declarations); + } + else { + emitVariableDeclarationListSkippingUninitializedEntries(variableDeclarationList); + } + } + else if (node.initializer) { + emit(node.initializer); + } + write(";"); + emitOptional(" ", node.condition); + write(";"); + emitOptional(" ", node.incrementor); + write(")"); + if (loop) { + emitConvertedLoopCall(loop, /* emitAsBlock */ true); + } + else { + emitNormalLoopBody(node, /* emitAsEmbeddedStatement */ true); + } + } + function emitForInOrForOfStatement(node) { + if (languageVersion < 2 /* ES6 */ && node.kind === 201 /* ForOfStatement */) { + emitLoop(node, emitDownLevelForOfStatementWorker); + } + else { + emitLoop(node, emitForInOrForOfStatementWorker); + } + } + function emitForInOrForOfStatementWorker(node, loop) { + var endPos = emitToken(86 /* ForKeyword */, node.pos); + write(" "); + endPos = emitToken(17 /* OpenParenToken */, endPos); + if (node.initializer.kind === 212 /* VariableDeclarationList */) { + var variableDeclarationList = node.initializer; + if (variableDeclarationList.declarations.length >= 1) { + tryEmitStartOfVariableDeclarationList(variableDeclarationList, endPos); + emit(variableDeclarationList.declarations[0]); + } + } + else { + emit(node.initializer); + } + if (node.kind === 200 /* ForInStatement */) { + write(" in "); + } + else { + write(" of "); + } + emit(node.expression); + emitToken(18 /* CloseParenToken */, node.expression.end); + if (loop) { + emitConvertedLoopCall(loop, /* emitAsBlock */ true); + } + else { + emitNormalLoopBody(node, /* emitAsEmbeddedStatement */ true); + } + } + function emitDownLevelForOfStatement(node) { + emitLoop(node, emitDownLevelForOfStatementWorker); + } + function emitDownLevelForOfStatementWorker(node, loop) { + // The following ES6 code: + // + // for (let v of expr) { } + // + // should be emitted as + // + // for (let _i = 0, _a = expr; _i < _a.length; _i++) { + // let v = _a[_i]; + // } + // + // where _a and _i are temps emitted to capture the RHS and the counter, + // respectively. + // When the left hand side is an expression instead of a let declaration, + // the "let v" is not emitted. + // When the left hand side is a let/const, the v is renamed if there is + // another v in scope. + // Note that all assignments to the LHS are emitted in the body, including + // all destructuring. + // Note also that because an extra statement is needed to assign to the LHS, + // for-of bodies are always emitted as blocks. + var endPos = emitToken(86 /* ForKeyword */, node.pos); + write(" "); + endPos = emitToken(17 /* OpenParenToken */, endPos); + // Do not emit the LHS let declaration yet, because it might contain destructuring. + // Do not call recordTempDeclaration because we are declaring the temps + // right here. Recording means they will be declared later. + // 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 rhsIsIdentifier = node.expression.kind === 69 /* Identifier */; + var counter = createTempVariable(268435456 /* _i */); + var rhsReference = rhsIsIdentifier ? node.expression : createTempVariable(0 /* Auto */); + // This is the let keyword for the counter and rhsReference. The let keyword for + // the LHS will be emitted inside the body. + emitStart(node.expression); + write("var "); + // _i = 0 + emitNodeWithoutSourceMap(counter); + write(" = 0"); + emitEnd(node.expression); + if (!rhsIsIdentifier) { + // , _a = expr + write(", "); + emitStart(node.expression); + emitNodeWithoutSourceMap(rhsReference); + write(" = "); + emitNodeWithoutSourceMap(node.expression); + emitEnd(node.expression); + } + write("; "); + // _i < _a.length; + emitStart(node.initializer); + emitNodeWithoutSourceMap(counter); + write(" < "); + emitNodeWithCommentsAndWithoutSourcemap(rhsReference); + write(".length"); + emitEnd(node.initializer); + write("; "); + // _i++) + emitStart(node.initializer); + emitNodeWithoutSourceMap(counter); + write("++"); + emitEnd(node.initializer); + emitToken(18 /* CloseParenToken */, node.expression.end); + // Body + write(" {"); + writeLine(); + increaseIndent(); + // Initialize LHS + // let v = _a[_i]; + var rhsIterationValue = createElementAccessExpression(rhsReference, counter); + emitStart(node.initializer); + if (node.initializer.kind === 212 /* VariableDeclarationList */) { + write("var "); + var variableDeclarationList = node.initializer; + if (variableDeclarationList.declarations.length > 0) { + var declaration = variableDeclarationList.declarations[0]; + if (ts.isBindingPattern(declaration.name)) { + // This works whether the declaration is a var, let, or const. + // It will use rhsIterationValue _a[_i] as the initializer. + emitDestructuring(declaration, /*isAssignmentExpressionStatement*/ false, rhsIterationValue); + } + else { + // The following call does not include the initializer, so we have + // to emit it separately. + emitNodeWithCommentsAndWithoutSourcemap(declaration); + write(" = "); + emitNodeWithoutSourceMap(rhsIterationValue); + } + } + else { + // It's an empty declaration list. This can only happen in an error case, if the user wrote + // for (let of []) {} + emitNodeWithoutSourceMap(createTempVariable(0 /* Auto */)); + write(" = "); + emitNodeWithoutSourceMap(rhsIterationValue); + } + } + else { + // Initializer is an expression. Emit the expression in the body, so that it's + // evaluated on every iteration. + var assignmentExpression = createBinaryExpression(node.initializer, 56 /* EqualsToken */, rhsIterationValue, /*startsOnNewLine*/ false); + if (node.initializer.kind === 164 /* ArrayLiteralExpression */ || node.initializer.kind === 165 /* ObjectLiteralExpression */) { + // This is a destructuring pattern, so call emitDestructuring instead of emit. Calling emit will not work, because it will cause + // the BinaryExpression to be passed in instead of the expression statement, which will cause emitDestructuring to crash. + emitDestructuring(assignmentExpression, /*isAssignmentExpressionStatement*/ true, /*value*/ undefined); + } + else { + emitNodeWithCommentsAndWithoutSourcemap(assignmentExpression); + } + } + emitEnd(node.initializer); + write(";"); + if (loop) { + writeLine(); + emitConvertedLoopCall(loop, /* emitAsBlock */ false); + } + else { + emitNormalLoopBody(node, /* emitAsEmbeddedStatement */ false); + } + writeLine(); + decreaseIndent(); + write("}"); + } + function emitBreakOrContinueStatement(node) { + if (convertedLoopState) { + // check if we can emit break\continue as is + // it is possible if either + // - break\continue is statement 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 === 203 /* BreakStatement */ ? 2 /* Break */ : 4 /* Continue */; + var canUseBreakOrContinue = (node.label && convertedLoopState.labels && convertedLoopState.labels[node.label.text]) || + (!node.label && (convertedLoopState.allowedNonLabeledJumps & jump)); + if (!canUseBreakOrContinue) { + if (!node.label) { + if (node.kind === 203 /* BreakStatement */) { + convertedLoopState.nonLocalJumps |= 2 /* Break */; + write("return \"break\";"); + } + else { + convertedLoopState.nonLocalJumps |= 4 /* Continue */; + write("return \"continue\";"); + } + } + else { + var labelMarker; + if (node.kind === 203 /* 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); + } + write("return \"" + labelMarker + "\";"); + } + return; + } + } + emitToken(node.kind === 203 /* BreakStatement */ ? 70 /* BreakKeyword */ : 75 /* ContinueKeyword */, node.pos); + emitOptional(" ", node.label); + write(";"); + } + function emitReturnStatement(node) { + if (convertedLoopState) { + convertedLoopState.nonLocalJumps |= 8 /* Return */; + write("return { value: "); + if (node.expression) { + emit(node.expression); + } + else { + write("void 0"); + } + write(" };"); + return; + } + emitToken(94 /* ReturnKeyword */, node.pos); + emitOptional(" ", node.expression); + write(";"); + } + function emitWithStatement(node) { + write("with ("); + emit(node.expression); + write(")"); + emitEmbeddedStatement(node.statement); + } + function emitSwitchStatement(node) { + var endPos = emitToken(96 /* SwitchKeyword */, node.pos); + write(" "); + emitToken(17 /* OpenParenToken */, endPos); + emit(node.expression); + endPos = emitToken(18 /* CloseParenToken */, node.expression.end); + write(" "); + var saveAllowedNonLabeledJumps; + if (convertedLoopState) { + saveAllowedNonLabeledJumps = convertedLoopState.allowedNonLabeledJumps; + // for switch statement allow only non-labeled break + convertedLoopState.allowedNonLabeledJumps |= 2 /* Break */; + } + emitCaseBlock(node.caseBlock, endPos); + if (convertedLoopState) { + convertedLoopState.allowedNonLabeledJumps = saveAllowedNonLabeledJumps; + } + } + function emitCaseBlock(node, startPos) { + emitToken(15 /* OpenBraceToken */, startPos); + increaseIndent(); + emitLines(node.clauses); + decreaseIndent(); + writeLine(); + emitToken(16 /* CloseBraceToken */, node.clauses.end); + } + function nodeStartPositionsAreOnSameLine(node1, node2) { + return ts.getLineOfLocalPosition(currentSourceFile, ts.skipTrivia(currentSourceFile.text, node1.pos)) === + ts.getLineOfLocalPosition(currentSourceFile, ts.skipTrivia(currentSourceFile.text, node2.pos)); + } + function nodeEndPositionsAreOnSameLine(node1, node2) { + return ts.getLineOfLocalPosition(currentSourceFile, node1.end) === + ts.getLineOfLocalPosition(currentSourceFile, node2.end); + } + function nodeEndIsOnSameLineAsNodeStart(node1, node2) { + return ts.getLineOfLocalPosition(currentSourceFile, node1.end) === + ts.getLineOfLocalPosition(currentSourceFile, ts.skipTrivia(currentSourceFile.text, node2.pos)); + } + function emitCaseOrDefaultClause(node) { + if (node.kind === 241 /* CaseClause */) { + write("case "); + emit(node.expression); + write(":"); + } + else { + write("default:"); + } + if (node.statements.length === 1 && nodeStartPositionsAreOnSameLine(node, node.statements[0])) { + write(" "); + emit(node.statements[0]); + } + else { + increaseIndent(); + emitLines(node.statements); + decreaseIndent(); + } + } + function emitThrowStatement(node) { + write("throw "); + emit(node.expression); + write(";"); + } + function emitTryStatement(node) { + write("try "); + emit(node.tryBlock); + emit(node.catchClause); + if (node.finallyBlock) { + writeLine(); + write("finally "); + emit(node.finallyBlock); + } + } + function emitCatchClause(node) { + writeLine(); + var endPos = emitToken(72 /* CatchKeyword */, node.pos); + write(" "); + emitToken(17 /* OpenParenToken */, endPos); + emit(node.variableDeclaration); + emitToken(18 /* CloseParenToken */, node.variableDeclaration ? node.variableDeclaration.end : endPos); + write(" "); + emitBlock(node.block); + } + function emitDebuggerStatement(node) { + emitToken(76 /* DebuggerKeyword */, node.pos); + write(";"); + } + function emitLabelAndColon(node) { + emit(node.label); + write(": "); + } + function emitLabeledStatement(node) { + if (!ts.isIterationStatement(node.statement, /* lookInLabeledStatements */ false) || !shouldConvertLoopBody(node.statement)) { + emitLabelAndColon(node); + } + if (convertedLoopState) { + if (!convertedLoopState.labels) { + convertedLoopState.labels = {}; + } + convertedLoopState.labels[node.label.text] = node.label.text; + } + emit(node.statement); + if (convertedLoopState) { + convertedLoopState.labels[node.label.text] = undefined; + } + } + function getContainingModule(node) { + do { + node = node.parent; + } while (node && node.kind !== 218 /* ModuleDeclaration */); + return node; + } + function emitContainingModuleName(node) { + var container = getContainingModule(node); + write(container ? getGeneratedNameForNode(container) : "exports"); + } + function emitModuleMemberName(node) { + emitStart(node.name); + if (ts.getCombinedNodeFlags(node) & 1 /* Export */) { + var container = getContainingModule(node); + if (container) { + write(getGeneratedNameForNode(container)); + write("."); + } + else if (modulekind !== 5 /* ES6 */ && modulekind !== 4 /* System */) { + write("exports."); + } + } + emitNodeWithCommentsAndWithoutSourcemap(node.name); + emitEnd(node.name); + } + function createVoidZero() { + var zero = ts.createSynthesizedNode(8 /* NumericLiteral */); + zero.text = "0"; + var result = ts.createSynthesizedNode(177 /* VoidExpression */); + result.expression = zero; + return result; + } + function emitEs6ExportDefaultCompat(node) { + if (node.parent.kind === 248 /* SourceFile */) { + ts.Debug.assert(!!(node.flags & 1024 /* Default */) || node.kind === 227 /* ExportAssignment */); + // only allow export default at a source file level + if (modulekind === 1 /* CommonJS */ || modulekind === 2 /* AMD */ || modulekind === 3 /* UMD */) { + if (!currentSourceFile.symbol.exports["___esModule"]) { + if (languageVersion === 1 /* ES5 */) { + // default value of configurable, enumerable, writable are `false`. + write("Object.defineProperty(exports, \"__esModule\", { value: true });"); + writeLine(); + } + else if (languageVersion === 0 /* ES3 */) { + write("exports.__esModule = true;"); + writeLine(); + } + } + } + } + } + function emitExportMemberAssignment(node) { + if (node.flags & 1 /* Export */) { + writeLine(); + emitStart(node); + // emit call to exporter only for top level nodes + if (modulekind === 4 /* System */ && node.parent === currentSourceFile) { + // emit export default as + // export("default", ) + write(exportFunctionForFile + "(\""); + if (node.flags & 1024 /* Default */) { + write("default"); + } + else { + emitNodeWithCommentsAndWithoutSourcemap(node.name); + } + write("\", "); + emitDeclarationName(node); + write(")"); + } + else { + if (node.flags & 1024 /* Default */) { + emitEs6ExportDefaultCompat(node); + if (languageVersion === 0 /* ES3 */) { + write("exports[\"default\"]"); + } + else { + write("exports.default"); + } + } + else { + emitModuleMemberName(node); + } + write(" = "); + emitDeclarationName(node); + } + emitEnd(node); + write(";"); + } + } + function emitExportMemberAssignments(name) { + if (modulekind === 4 /* System */) { + return; + } + if (!exportEquals && exportSpecifiers && ts.hasProperty(exportSpecifiers, name.text)) { + for (var _a = 0, _b = exportSpecifiers[name.text]; _a < _b.length; _a++) { + var specifier = _b[_a]; + writeLine(); + emitStart(specifier.name); + emitContainingModuleName(specifier); + write("."); + emitNodeWithCommentsAndWithoutSourcemap(specifier.name); + emitEnd(specifier.name); + write(" = "); + emitExpressionIdentifier(name); + write(";"); + } + } + } + function emitExportSpecifierInSystemModule(specifier) { + ts.Debug.assert(modulekind === 4 /* System */); + if (!resolver.getReferencedValueDeclaration(specifier.propertyName || specifier.name) && !resolver.isValueAliasDeclaration(specifier)) { + return; + } + writeLine(); + emitStart(specifier.name); + write(exportFunctionForFile + "(\""); + emitNodeWithCommentsAndWithoutSourcemap(specifier.name); + write("\", "); + emitExpressionIdentifier(specifier.propertyName || specifier.name); + write(")"); + emitEnd(specifier.name); + write(";"); + } + /** + * Emit an assignment to a given identifier, 'name', with a given expression, 'value'. + * @param name an identifier as a left-hand-side operand of the assignment + * @param value an expression as a right-hand-side operand of the assignment + * @param shouldEmitCommaBeforeAssignment a boolean indicating whether to prefix an assignment with comma + */ + function emitAssignment(name, value, shouldEmitCommaBeforeAssignment) { + if (shouldEmitCommaBeforeAssignment) { + write(", "); + } + var exportChanged = isNameOfExportedSourceLevelDeclarationInSystemExternalModule(name); + if (exportChanged) { + write(exportFunctionForFile + "(\""); + emitNodeWithCommentsAndWithoutSourcemap(name); + write("\", "); + } + var isVariableDeclarationOrBindingElement = name.parent && (name.parent.kind === 211 /* VariableDeclaration */ || name.parent.kind === 163 /* BindingElement */); + if (isVariableDeclarationOrBindingElement) { + emitModuleMemberName(name.parent); + } + else { + emit(name); + } + write(" = "); + emit(value); + if (exportChanged) { + write(")"); + } + } + /** + * Create temporary variable, emit an assignment of the variable the given expression + * @param expression an expression to assign to the newly created temporary variable + * @param canDefineTempVariablesInPlace a boolean indicating whether you can define the temporary variable at an assignment location + * @param shouldEmitCommaBeforeAssignment a boolean indicating whether an assignment should prefix with comma + */ + function emitTempVariableAssignment(expression, canDefineTempVariablesInPlace, shouldEmitCommaBeforeAssignment) { + var identifier = createTempVariable(0 /* Auto */); + if (!canDefineTempVariablesInPlace) { + recordTempDeclaration(identifier); + } + emitAssignment(identifier, expression, shouldEmitCommaBeforeAssignment); + return identifier; + } + function emitDestructuring(root, isAssignmentExpressionStatement, value) { + var emitCount = 0; + // An exported declaration is actually emitted as an assignment (to a property on the module object), so + // temporary variables in an exported declaration need to have real declarations elsewhere + // Also temporary variables should be explicitly allocated for source level declarations when module target is system + // because actual variable declarations are hoisted + var canDefineTempVariablesInPlace = false; + if (root.kind === 211 /* VariableDeclaration */) { + var isExported = ts.getCombinedNodeFlags(root) & 1 /* Export */; + var isSourceLevelForSystemModuleKind = shouldHoistDeclarationInSystemJsModule(root); + canDefineTempVariablesInPlace = !isExported && !isSourceLevelForSystemModuleKind; + } + else if (root.kind === 138 /* Parameter */) { + canDefineTempVariablesInPlace = true; + } + if (root.kind === 181 /* BinaryExpression */) { + emitAssignmentExpression(root); + } + else { + ts.Debug.assert(!isAssignmentExpressionStatement); + emitBindingElement(root, value); + } + /** + * Ensures that there exists a declared identifier whose value holds the given expression. + * This function is useful to ensure that the expression's value can be read from in subsequent expressions. + * Unless 'reuseIdentifierExpressions' is false, 'expr' will be returned if it is just an identifier. + * + * @param expr the expression whose value needs to be bound. + * @param reuseIdentifierExpressions true if identifier expressions can simply be returned; + * false if it is necessary to always emit an identifier. + */ + function ensureIdentifier(expr, reuseIdentifierExpressions) { + if (expr.kind === 69 /* Identifier */ && reuseIdentifierExpressions) { + return expr; + } + var identifier = emitTempVariableAssignment(expr, canDefineTempVariablesInPlace, emitCount > 0); + emitCount++; + return identifier; + } + function createDefaultValueCheck(value, defaultValue) { + // The value expression will be evaluated twice, so for anything but a simple identifier + // we need to generate a temporary variable + value = ensureIdentifier(value, /*reuseIdentifierExpressions*/ true); + // Return the expression 'value === void 0 ? defaultValue : value' + var equals = ts.createSynthesizedNode(181 /* BinaryExpression */); + equals.left = value; + equals.operatorToken = ts.createSynthesizedNode(32 /* EqualsEqualsEqualsToken */); + equals.right = createVoidZero(); + return createConditionalExpression(equals, defaultValue, value); + } + function createConditionalExpression(condition, whenTrue, whenFalse) { + var cond = ts.createSynthesizedNode(182 /* ConditionalExpression */); + cond.condition = condition; + cond.questionToken = ts.createSynthesizedNode(53 /* QuestionToken */); + cond.whenTrue = whenTrue; + cond.colonToken = ts.createSynthesizedNode(54 /* ColonToken */); + cond.whenFalse = whenFalse; + return cond; + } + function createNumericLiteral(value) { + var node = ts.createSynthesizedNode(8 /* NumericLiteral */); + node.text = "" + value; + return node; + } + function createPropertyAccessForDestructuringProperty(object, propName) { + // We create a synthetic copy of the identifier in order to avoid the rewriting that might + // otherwise occur when the identifier is emitted. + var syntheticName = ts.createSynthesizedNode(propName.kind); + syntheticName.text = propName.text; + if (syntheticName.kind !== 69 /* Identifier */) { + return createElementAccessExpression(object, syntheticName); + } + return createPropertyAccessExpression(object, syntheticName); + } + function createSliceCall(value, sliceIndex) { + var call = ts.createSynthesizedNode(168 /* CallExpression */); + var sliceIdentifier = ts.createSynthesizedNode(69 /* Identifier */); + sliceIdentifier.text = "slice"; + call.expression = createPropertyAccessExpression(value, sliceIdentifier); + call.arguments = ts.createSynthesizedNodeArray(); + call.arguments[0] = createNumericLiteral(sliceIndex); + return call; + } + function emitObjectLiteralAssignment(target, value) { + var properties = target.properties; + if (properties.length !== 1) { + // For anything but a single element destructuring we need to generate a temporary + // to ensure value is evaluated exactly once. + value = ensureIdentifier(value, /*reuseIdentifierExpressions*/ true); + } + for (var _a = 0; _a < properties.length; _a++) { + var p = properties[_a]; + if (p.kind === 245 /* PropertyAssignment */ || p.kind === 246 /* ShorthandPropertyAssignment */) { + var propName = p.name; + var target_1 = p.kind === 246 /* ShorthandPropertyAssignment */ ? p : p.initializer || propName; + emitDestructuringAssignment(target_1, createPropertyAccessForDestructuringProperty(value, propName)); + } + } + } + function emitArrayLiteralAssignment(target, value) { + var elements = target.elements; + if (elements.length !== 1) { + // For anything but a single element destructuring we need to generate a temporary + // to ensure value is evaluated exactly once. + value = ensureIdentifier(value, /*reuseIdentifierExpressions*/ true); + } + for (var i = 0; i < elements.length; i++) { + var e = elements[i]; + if (e.kind !== 187 /* OmittedExpression */) { + if (e.kind !== 185 /* SpreadElementExpression */) { + emitDestructuringAssignment(e, createElementAccessExpression(value, createNumericLiteral(i))); + } + else if (i === elements.length - 1) { + emitDestructuringAssignment(e.expression, createSliceCall(value, i)); + } + } + } + } + function emitDestructuringAssignment(target, value) { + if (target.kind === 246 /* ShorthandPropertyAssignment */) { + if (target.objectAssignmentInitializer) { + value = createDefaultValueCheck(value, target.objectAssignmentInitializer); + } + target = target.name; + } + else if (target.kind === 181 /* BinaryExpression */ && target.operatorToken.kind === 56 /* EqualsToken */) { + value = createDefaultValueCheck(value, target.right); + target = target.left; + } + if (target.kind === 165 /* ObjectLiteralExpression */) { + emitObjectLiteralAssignment(target, value); + } + else if (target.kind === 164 /* ArrayLiteralExpression */) { + emitArrayLiteralAssignment(target, value); + } + else { + emitAssignment(target, value, /*shouldEmitCommaBeforeAssignment*/ emitCount > 0); + emitCount++; + } + } + function emitAssignmentExpression(root) { + var target = root.left; + var value = root.right; + if (ts.isEmptyObjectLiteralOrArrayLiteral(target)) { + emit(value); + } + else if (isAssignmentExpressionStatement) { + emitDestructuringAssignment(target, value); + } + else { + if (root.parent.kind !== 172 /* ParenthesizedExpression */) { + write("("); + } + value = ensureIdentifier(value, /*reuseIdentifierExpressions*/ true); + emitDestructuringAssignment(target, value); + write(", "); + emit(value); + if (root.parent.kind !== 172 /* ParenthesizedExpression */) { + write(")"); + } + } + } + function emitBindingElement(target, value) { + if (target.initializer) { + // Combine value and initializer + value = value ? createDefaultValueCheck(value, target.initializer) : target.initializer; + } + else if (!value) { + // Use 'void 0' in absence of value and initializer + value = createVoidZero(); + } + if (ts.isBindingPattern(target.name)) { + var pattern = target.name; + var elements = pattern.elements; + var numElements = elements.length; + if (numElements !== 1) { + // For anything other than a single-element destructuring we need to generate a temporary + // to ensure value is evaluated exactly once. Additionally, if we have zero elements + // we need to emit *something* to ensure that in case a 'var' keyword was already emitted, + // so in that case, we'll intentionally create that temporary. + value = ensureIdentifier(value, /*reuseIdentifierExpressions*/ numElements !== 0); + } + for (var i = 0; i < numElements; i++) { + var element = elements[i]; + if (pattern.kind === 161 /* ObjectBindingPattern */) { + // Rewrite element to a declaration with an initializer that fetches property + var propName = element.propertyName || element.name; + emitBindingElement(element, createPropertyAccessForDestructuringProperty(value, propName)); + } + else if (element.kind !== 187 /* OmittedExpression */) { + if (!element.dotDotDotToken) { + // Rewrite element to a declaration that accesses array element at index i + emitBindingElement(element, createElementAccessExpression(value, createNumericLiteral(i))); + } + else if (i === numElements - 1) { + emitBindingElement(element, createSliceCall(value, i)); + } + } + } + } + else { + emitAssignment(target.name, value, /*shouldEmitCommaBeforeAssignment*/ emitCount > 0); + emitCount++; + } + } + } + function emitVariableDeclaration(node) { + if (ts.isBindingPattern(node.name)) { + if (languageVersion < 2 /* ES6 */) { + emitDestructuring(node, /*isAssignmentExpressionStatement*/ false); + } + else { + emit(node.name); + emitOptional(" = ", node.initializer); + } + } + else { + var initializer = node.initializer; + if (!initializer && languageVersion < 2 /* ES6 */) { + // downlevel emit for non-initialized let bindings defined in loops + // for (...) { let x; } + // should be + // for (...) { var = void 0; } + // this is necessary to preserve ES6 semantic in scenarios like + // for (...) { let x; console.log(x); x = 1 } // assignment on one iteration should not affect other iterations + var isLetDefinedInLoop = (resolver.getNodeCheckFlags(node) & 16384 /* BlockScopedBindingInLoop */) && + (getCombinedFlagsForIdentifier(node.name) & 16384 /* Let */); + // NOTE: default initialization should not be added to let bindings in for-in\for-of statements + if (isLetDefinedInLoop && + node.parent.parent.kind !== 200 /* ForInStatement */ && + node.parent.parent.kind !== 201 /* ForOfStatement */) { + initializer = createVoidZero(); + } + } + var exportChanged = isNameOfExportedSourceLevelDeclarationInSystemExternalModule(node.name); + if (exportChanged) { + write(exportFunctionForFile + "(\""); + emitNodeWithCommentsAndWithoutSourcemap(node.name); + write("\", "); + } + emitModuleMemberName(node); + emitOptional(" = ", initializer); + if (exportChanged) { + write(")"); + } + } + } + function emitExportVariableAssignments(node) { + if (node.kind === 187 /* OmittedExpression */) { + return; + } + var name = node.name; + if (name.kind === 69 /* Identifier */) { + emitExportMemberAssignments(name); + } + else if (ts.isBindingPattern(name)) { + ts.forEach(name.elements, emitExportVariableAssignments); + } + } + function getCombinedFlagsForIdentifier(node) { + if (!node.parent || (node.parent.kind !== 211 /* VariableDeclaration */ && node.parent.kind !== 163 /* BindingElement */)) { + return 0; + } + return ts.getCombinedNodeFlags(node.parent); + } + function isES6ExportedDeclaration(node) { + return !!(node.flags & 1 /* Export */) && + modulekind === 5 /* ES6 */ && + node.parent.kind === 248 /* SourceFile */; + } + function emitVariableStatement(node) { + var startIsEmitted = false; + if (node.flags & 1 /* Export */) { + if (isES6ExportedDeclaration(node)) { + // Exported ES6 module member + write("export "); + startIsEmitted = tryEmitStartOfVariableDeclarationList(node.declarationList); + } + } + else { + startIsEmitted = tryEmitStartOfVariableDeclarationList(node.declarationList); + } + if (startIsEmitted) { + emitCommaList(node.declarationList.declarations); + write(";"); + } + else { + var atLeastOneItem = emitVariableDeclarationListSkippingUninitializedEntries(node.declarationList); + if (atLeastOneItem) { + write(";"); + } + } + if (modulekind !== 5 /* ES6 */ && node.parent === currentSourceFile) { + ts.forEach(node.declarationList.declarations, emitExportVariableAssignments); + } + } + function shouldEmitLeadingAndTrailingCommentsForVariableStatement(node) { + // If we're not exporting the variables, there's nothing special here. + // Always emit comments for these nodes. + if (!(node.flags & 1 /* Export */)) { + return true; + } + // If we are exporting, but it's a top-level ES6 module exports, + // we'll emit the declaration list verbatim, so emit comments too. + if (isES6ExportedDeclaration(node)) { + return true; + } + // Otherwise, only emit if we have at least one initializer present. + for (var _a = 0, _b = node.declarationList.declarations; _a < _b.length; _a++) { + var declaration = _b[_a]; + if (declaration.initializer) { + return true; + } + } + return false; + } + function emitParameter(node) { + if (languageVersion < 2 /* ES6 */) { + if (ts.isBindingPattern(node.name)) { + var name_25 = createTempVariable(0 /* Auto */); + if (!tempParameters) { + tempParameters = []; + } + tempParameters.push(name_25); + emit(name_25); + } + else { + emit(node.name); + } + } + else { + if (node.dotDotDotToken) { + write("..."); + } + emit(node.name); + emitOptional(" = ", node.initializer); + } + } + function emitDefaultValueAssignments(node) { + if (languageVersion < 2 /* ES6 */) { + var tempIndex = 0; + ts.forEach(node.parameters, function (parameter) { + // A rest parameter cannot have a binding pattern or an initializer, + // so let's just ignore it. + if (parameter.dotDotDotToken) { + return; + } + var paramName = parameter.name, initializer = parameter.initializer; + if (ts.isBindingPattern(paramName)) { + // 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. + var hasBindingElements = paramName.elements.length > 0; + if (hasBindingElements || initializer) { + writeLine(); + write("var "); + if (hasBindingElements) { + emitDestructuring(parameter, /*isAssignmentExpressionStatement*/ false, tempParameters[tempIndex]); + } + else { + emit(tempParameters[tempIndex]); + write(" = "); + emit(initializer); + } + write(";"); + tempIndex++; + } + } + else if (initializer) { + writeLine(); + emitStart(parameter); + write("if ("); + emitNodeWithoutSourceMap(paramName); + write(" === void 0)"); + emitEnd(parameter); + write(" { "); + emitStart(parameter); + emitNodeWithCommentsAndWithoutSourcemap(paramName); + write(" = "); + emitNodeWithCommentsAndWithoutSourcemap(initializer); + emitEnd(parameter); + write("; }"); + } + }); + } + } + function emitRestParameter(node) { + if (languageVersion < 2 /* ES6 */ && ts.hasRestParameter(node)) { + var restIndex = node.parameters.length - 1; + var restParam = node.parameters[restIndex]; + // A rest parameter cannot have a binding pattern, so let's just ignore it if it does. + if (ts.isBindingPattern(restParam.name)) { + return; + } + var tempName = createTempVariable(268435456 /* _i */).text; + writeLine(); + emitLeadingComments(restParam); + emitStart(restParam); + write("var "); + emitNodeWithCommentsAndWithoutSourcemap(restParam.name); + write(" = [];"); + emitEnd(restParam); + emitTrailingComments(restParam); + writeLine(); + write("for ("); + emitStart(restParam); + write("var " + tempName + " = " + restIndex + ";"); + emitEnd(restParam); + write(" "); + emitStart(restParam); + write(tempName + " < arguments.length;"); + emitEnd(restParam); + write(" "); + emitStart(restParam); + write(tempName + "++"); + emitEnd(restParam); + write(") {"); + increaseIndent(); + writeLine(); + emitStart(restParam); + emitNodeWithCommentsAndWithoutSourcemap(restParam.name); + write("[" + tempName + " - " + restIndex + "] = arguments[" + tempName + "];"); + emitEnd(restParam); + decreaseIndent(); + writeLine(); + write("}"); + } + } + function emitAccessor(node) { + write(node.kind === 145 /* GetAccessor */ ? "get " : "set "); + emit(node.name); + emitSignatureAndBody(node); + } + function shouldEmitAsArrowFunction(node) { + return node.kind === 174 /* ArrowFunction */ && languageVersion >= 2 /* ES6 */; + } + function emitDeclarationName(node) { + if (node.name) { + emitNodeWithCommentsAndWithoutSourcemap(node.name); + } + else { + write(getGeneratedNameForNode(node)); + } + } + function shouldEmitFunctionName(node) { + if (node.kind === 173 /* FunctionExpression */) { + // Emit name if one is present + return !!node.name; + } + if (node.kind === 213 /* FunctionDeclaration */) { + // Emit name if one is present, or emit generated name in down-level case (for export default case) + return !!node.name || languageVersion < 2 /* ES6 */; + } + } + function emitFunctionDeclaration(node) { + if (ts.nodeIsMissing(node.body)) { + return emitCommentsOnNotEmittedNode(node); + } + // TODO (yuisu) : we should not have special cases to condition emitting comments + // but have one place to fix check for these conditions. + if (node.kind !== 143 /* MethodDeclaration */ && node.kind !== 142 /* MethodSignature */ && + node.parent && node.parent.kind !== 245 /* PropertyAssignment */ && + node.parent.kind !== 168 /* CallExpression */) { + // 1. Methods will emit the comments as part of emitting method declaration + // 2. If the function is a property of object literal, emitting leading-comments + // is done by emitNodeWithoutSourceMap which then call this function. + // In particular, we would like to avoid emit comments twice in following case: + // For example: + // var obj = { + // id: + // /*comment*/ () => void + // } + // 3. If the function is an argument in call expression, emitting of comments will be + // taken care of in emit list of arguments inside of emitCallexpression + emitLeadingComments(node); + } + emitStart(node); + // For targeting below es6, emit functions-like declaration including arrow function using function keyword. + // When targeting ES6, emit arrow function natively in ES6 by omitting function keyword and using fat arrow instead + if (!shouldEmitAsArrowFunction(node)) { + if (isES6ExportedDeclaration(node)) { + write("export "); + if (node.flags & 1024 /* Default */) { + write("default "); + } + } + write("function"); + if (languageVersion >= 2 /* ES6 */ && node.asteriskToken) { + write("*"); + } + write(" "); + } + if (shouldEmitFunctionName(node)) { + emitDeclarationName(node); + } + emitSignatureAndBody(node); + if (modulekind !== 5 /* ES6 */ && node.kind === 213 /* FunctionDeclaration */ && node.parent === currentSourceFile && node.name) { + emitExportMemberAssignments(node.name); + } + emitEnd(node); + if (node.kind !== 143 /* MethodDeclaration */ && node.kind !== 142 /* MethodSignature */) { + emitTrailingComments(node); + } + } + function emitCaptureThisForNodeIfNecessary(node) { + if (resolver.getNodeCheckFlags(node) & 4 /* CaptureThis */) { + writeLine(); + emitStart(node); + write("var _this = this;"); + emitEnd(node); + } + } + function emitSignatureParameters(node) { + increaseIndent(); + write("("); + if (node) { + var parameters = node.parameters; + var omitCount = languageVersion < 2 /* ES6 */ && ts.hasRestParameter(node) ? 1 : 0; + emitList(parameters, 0, parameters.length - omitCount, /*multiLine*/ false, /*trailingComma*/ false); + } + write(")"); + decreaseIndent(); + } + function emitSignatureParametersForArrow(node) { + // Check whether the parameter list needs parentheses and preserve no-parenthesis + if (node.parameters.length === 1 && node.pos === node.parameters[0].pos) { + emit(node.parameters[0]); + return; + } + emitSignatureParameters(node); + } + function emitAsyncFunctionBodyForES6(node) { + var promiseConstructor = ts.getEntityNameFromTypeNode(node.type); + var isArrowFunction = node.kind === 174 /* ArrowFunction */; + var hasLexicalArguments = (resolver.getNodeCheckFlags(node) & 4096 /* CaptureArguments */) !== 0; + var args; + // 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. + // + // The emit for an async arrow without a lexical `arguments` binding might be: + // + // // input + // let a = async (b) => { await b; } + // + // // output + // let a = (b) => __awaiter(this, void 0, void 0, function* () { + // yield b; + // }); + // + // The emit for an async arrow with a lexical `arguments` binding might be: + // + // // input + // let a = async (b) => { await arguments[0]; } + // + // // output + // let a = (b) => __awaiter(this, arguments, void 0, function* (arguments) { + // yield arguments[0]; + // }); + // + // The emit for an async function expression without a lexical `arguments` binding + // might be: + // + // // input + // let a = async function (b) { + // await b; + // } + // + // // output + // let a = function (b) { + // return __awaiter(this, void 0, void 0, function* () { + // yield b; + // }); + // } + // + // The emit for an async function expression with a lexical `arguments` binding + // might be: + // + // // input + // let a = async function (b) { + // await arguments[0]; + // } + // + // // output + // let a = function (b) { + // return __awaiter(this, arguments, void 0, function* (_arguments) { + // yield _arguments[0]; + // }); + // } + // + // The emit for an async function expression with a lexical `arguments` binding + // and a return type annotation might be: + // + // // input + // let a = async function (b): MyPromise { + // await arguments[0]; + // } + // + // // output + // let a = function (b) { + // return __awaiter(this, arguments, MyPromise, function* (_arguments) { + // yield _arguments[0]; + // }); + // } + // + // If this is not an async arrow, emit the opening brace of the function body + // and the start of the return statement. + if (!isArrowFunction) { + write(" {"); + increaseIndent(); + writeLine(); + write("return"); + } + write(" __awaiter(this"); + if (hasLexicalArguments) { + write(", arguments"); + } + else { + write(", void 0"); + } + if (promiseConstructor) { + write(", "); + emitNodeWithoutSourceMap(promiseConstructor); + } + else { + write(", Promise"); + } + // Emit the call to __awaiter. + if (hasLexicalArguments) { + write(", function* (_arguments)"); + } + else { + write(", function* ()"); + } + // Emit the signature and body for the inner generator function. + emitFunctionBody(node); + write(")"); + // If this is not an async arrow, emit the closing brace of the outer function body. + if (!isArrowFunction) { + write(";"); + decreaseIndent(); + writeLine(); + write("}"); + } + } + function emitFunctionBody(node) { + if (!node.body) { + // There can be no body when there are parse errors. Just emit an empty block + // in that case. + write(" { }"); + } + else { + if (node.body.kind === 192 /* Block */) { + emitBlockFunctionBody(node, node.body); + } + else { + emitExpressionFunctionBody(node, node.body); + } + } + } + function emitSignatureAndBody(node) { + var saveConvertedLoopState = convertedLoopState; + var saveTempFlags = tempFlags; + var saveTempVariables = tempVariables; + var saveTempParameters = tempParameters; + convertedLoopState = undefined; + tempFlags = 0; + tempVariables = undefined; + tempParameters = undefined; + // When targeting ES6, emit arrow function natively in ES6 + if (shouldEmitAsArrowFunction(node)) { + emitSignatureParametersForArrow(node); + write(" =>"); + } + else { + emitSignatureParameters(node); + } + var isAsync = ts.isAsyncFunctionLike(node); + if (isAsync && languageVersion === 2 /* ES6 */) { + emitAsyncFunctionBodyForES6(node); + } + else { + emitFunctionBody(node); + } + if (!isES6ExportedDeclaration(node)) { + emitExportMemberAssignment(node); + } + ts.Debug.assert(convertedLoopState === undefined); + convertedLoopState = saveConvertedLoopState; + tempFlags = saveTempFlags; + tempVariables = saveTempVariables; + tempParameters = saveTempParameters; + } + // Returns true if any preamble code was emitted. + function emitFunctionBodyPreamble(node) { + emitCaptureThisForNodeIfNecessary(node); + emitDefaultValueAssignments(node); + emitRestParameter(node); + } + function emitExpressionFunctionBody(node, body) { + if (languageVersion < 2 /* ES6 */ || node.flags & 512 /* Async */) { + emitDownLevelExpressionFunctionBody(node, body); + return; + } + // For es6 and higher we can emit the expression as is. However, in the case + // where the expression might end up looking like a block when emitted, we'll + // also wrap it in parentheses first. For example if you have: a => {} + // then we need to generate: a => ({}) + write(" "); + // Unwrap all type assertions. + var current = body; + while (current.kind === 171 /* TypeAssertionExpression */) { + current = current.expression; + } + emitParenthesizedIf(body, current.kind === 165 /* ObjectLiteralExpression */); + } + function emitDownLevelExpressionFunctionBody(node, body) { + write(" {"); + scopeEmitStart(node); + increaseIndent(); + var outPos = writer.getTextPos(); + emitDetachedComments(node.body); + emitFunctionBodyPreamble(node); + var preambleEmitted = writer.getTextPos() !== outPos; + decreaseIndent(); + // If we didn't have to emit any preamble code, then attempt to keep the arrow + // function on one line. + if (!preambleEmitted && nodeStartPositionsAreOnSameLine(node, body)) { + write(" "); + emitStart(body); + write("return "); + emit(body); + emitEnd(body); + write(";"); + emitTempDeclarations(/*newLine*/ false); + write(" "); + } + else { + increaseIndent(); + writeLine(); + emitLeadingComments(node.body); + write("return "); + emit(body); + write(";"); + emitTrailingComments(node.body); + emitTempDeclarations(/*newLine*/ true); + decreaseIndent(); + writeLine(); + } + emitStart(node.body); + write("}"); + emitEnd(node.body); + scopeEmitEnd(); + } + function emitBlockFunctionBody(node, body) { + write(" {"); + scopeEmitStart(node); + var initialTextPos = writer.getTextPos(); + increaseIndent(); + emitDetachedComments(body.statements); + // Emit all the directive prologues (like "use strict"). These have to come before + // any other preamble code we write (like parameter initializers). + var startIndex = emitDirectivePrologues(body.statements, /*startWithNewLine*/ true); + emitFunctionBodyPreamble(node); + decreaseIndent(); + var preambleEmitted = writer.getTextPos() !== initialTextPos; + if (!preambleEmitted && nodeEndIsOnSameLineAsNodeStart(body, body)) { + for (var _a = 0, _b = body.statements; _a < _b.length; _a++) { + var statement = _b[_a]; + write(" "); + emit(statement); + } + emitTempDeclarations(/*newLine*/ false); + write(" "); + emitLeadingCommentsOfPosition(body.statements.end); + } + else { + increaseIndent(); + emitLinesStartingAt(body.statements, startIndex); + emitTempDeclarations(/*newLine*/ true); + writeLine(); + emitLeadingCommentsOfPosition(body.statements.end); + decreaseIndent(); + } + emitToken(16 /* CloseBraceToken */, body.statements.end); + scopeEmitEnd(); + } + function findInitialSuperCall(ctor) { + if (ctor.body) { + var statement = ctor.body.statements[0]; + if (statement && statement.kind === 195 /* ExpressionStatement */) { + var expr = statement.expression; + if (expr && expr.kind === 168 /* CallExpression */) { + var func = expr.expression; + if (func && func.kind === 95 /* SuperKeyword */) { + return statement; + } + } + } + } + } + function emitParameterPropertyAssignments(node) { + ts.forEach(node.parameters, function (param) { + if (param.flags & 112 /* AccessibilityModifier */) { + writeLine(); + emitStart(param); + emitStart(param.name); + write("this."); + emitNodeWithoutSourceMap(param.name); + emitEnd(param.name); + write(" = "); + emit(param.name); + write(";"); + emitEnd(param); + } + }); + } + function emitMemberAccessForPropertyName(memberName) { + // This does not emit source map because it is emitted by caller as caller + // is aware how the property name changes to the property access + // eg. public x = 10; becomes this.x and static x = 10 becomes className.x + if (memberName.kind === 9 /* StringLiteral */ || memberName.kind === 8 /* NumericLiteral */) { + write("["); + emitNodeWithCommentsAndWithoutSourcemap(memberName); + write("]"); + } + else if (memberName.kind === 136 /* ComputedPropertyName */) { + emitComputedPropertyName(memberName); + } + else { + write("."); + emitNodeWithCommentsAndWithoutSourcemap(memberName); + } + } + function getInitializedProperties(node, isStatic) { + var properties = []; + for (var _a = 0, _b = node.members; _a < _b.length; _a++) { + var member = _b[_a]; + if (member.kind === 141 /* PropertyDeclaration */ && isStatic === ((member.flags & 128 /* Static */) !== 0) && member.initializer) { + properties.push(member); + } + } + return properties; + } + function emitPropertyDeclarations(node, properties) { + for (var _a = 0; _a < properties.length; _a++) { + var property = properties[_a]; + emitPropertyDeclaration(node, property); + } + } + function emitPropertyDeclaration(node, property, receiver, isExpression) { + writeLine(); + emitLeadingComments(property); + emitStart(property); + emitStart(property.name); + if (receiver) { + emit(receiver); + } + else { + if (property.flags & 128 /* Static */) { + emitDeclarationName(node); + } + else { + write("this"); + } + } + emitMemberAccessForPropertyName(property.name); + emitEnd(property.name); + write(" = "); + emit(property.initializer); + if (!isExpression) { + write(";"); + } + emitEnd(property); + emitTrailingComments(property); + } + function emitMemberFunctionsForES5AndLower(node) { + ts.forEach(node.members, function (member) { + if (member.kind === 191 /* SemicolonClassElement */) { + writeLine(); + write(";"); + } + else if (member.kind === 143 /* MethodDeclaration */ || node.kind === 142 /* MethodSignature */) { + if (!member.body) { + return emitCommentsOnNotEmittedNode(member); + } + writeLine(); + emitLeadingComments(member); + emitStart(member); + emitStart(member.name); + emitClassMemberPrefix(node, member); + emitMemberAccessForPropertyName(member.name); + emitEnd(member.name); + write(" = "); + emitFunctionDeclaration(member); + emitEnd(member); + write(";"); + emitTrailingComments(member); + } + else if (member.kind === 145 /* GetAccessor */ || member.kind === 146 /* SetAccessor */) { + var accessors = ts.getAllAccessorDeclarations(node.members, member); + if (member === accessors.firstAccessor) { + writeLine(); + emitStart(member); + write("Object.defineProperty("); + emitStart(member.name); + emitClassMemberPrefix(node, member); + write(", "); + emitExpressionForPropertyName(member.name); + emitEnd(member.name); + write(", {"); + increaseIndent(); + if (accessors.getAccessor) { + writeLine(); + emitLeadingComments(accessors.getAccessor); + write("get: "); + emitStart(accessors.getAccessor); + write("function "); + emitSignatureAndBody(accessors.getAccessor); + emitEnd(accessors.getAccessor); + emitTrailingComments(accessors.getAccessor); + write(","); + } + if (accessors.setAccessor) { + writeLine(); + emitLeadingComments(accessors.setAccessor); + write("set: "); + emitStart(accessors.setAccessor); + write("function "); + emitSignatureAndBody(accessors.setAccessor); + emitEnd(accessors.setAccessor); + emitTrailingComments(accessors.setAccessor); + write(","); + } + writeLine(); + write("enumerable: true,"); + writeLine(); + write("configurable: true"); + decreaseIndent(); + writeLine(); + write("});"); + emitEnd(member); + } + } + }); + } + function emitMemberFunctionsForES6AndHigher(node) { + for (var _a = 0, _b = node.members; _a < _b.length; _a++) { + var member = _b[_a]; + if ((member.kind === 143 /* MethodDeclaration */ || node.kind === 142 /* MethodSignature */) && !member.body) { + emitCommentsOnNotEmittedNode(member); + } + else if (member.kind === 143 /* MethodDeclaration */ || + member.kind === 145 /* GetAccessor */ || + member.kind === 146 /* SetAccessor */) { + writeLine(); + emitLeadingComments(member); + emitStart(member); + if (member.flags & 128 /* Static */) { + write("static "); + } + if (member.kind === 145 /* GetAccessor */) { + write("get "); + } + else if (member.kind === 146 /* SetAccessor */) { + write("set "); + } + if (member.asteriskToken) { + write("*"); + } + emit(member.name); + emitSignatureAndBody(member); + emitEnd(member); + emitTrailingComments(member); + } + else if (member.kind === 191 /* SemicolonClassElement */) { + writeLine(); + write(";"); + } + } + } + function emitConstructor(node, baseTypeElement) { + var saveConvertedLoopState = convertedLoopState; + var saveTempFlags = tempFlags; + var saveTempVariables = tempVariables; + var saveTempParameters = tempParameters; + convertedLoopState = undefined; + tempFlags = 0; + tempVariables = undefined; + tempParameters = undefined; + emitConstructorWorker(node, baseTypeElement); + ts.Debug.assert(convertedLoopState === undefined); + convertedLoopState = saveConvertedLoopState; + tempFlags = saveTempFlags; + tempVariables = saveTempVariables; + tempParameters = saveTempParameters; + } + function emitConstructorWorker(node, baseTypeElement) { + // Check if we have property assignment inside class declaration. + // If there is property assignment, we need to emit constructor whether users define it or not + // If there is no property assignment, we can omit constructor if users do not define it + var hasInstancePropertyWithInitializer = false; + // Emit the constructor overload pinned comments + ts.forEach(node.members, function (member) { + if (member.kind === 144 /* Constructor */ && !member.body) { + emitCommentsOnNotEmittedNode(member); + } + // Check if there is any non-static property assignment + if (member.kind === 141 /* PropertyDeclaration */ && member.initializer && (member.flags & 128 /* Static */) === 0) { + hasInstancePropertyWithInitializer = true; + } + }); + var ctor = ts.getFirstConstructorWithBody(node); + // For target ES6 and above, if there is no user-defined constructor and there is no property assignment + // do not emit constructor in class declaration. + if (languageVersion >= 2 /* ES6 */ && !ctor && !hasInstancePropertyWithInitializer) { + return; + } + if (ctor) { + emitLeadingComments(ctor); + } + emitStart(ctor || node); + if (languageVersion < 2 /* ES6 */) { + write("function "); + emitDeclarationName(node); + emitSignatureParameters(ctor); + } + else { + write("constructor"); + if (ctor) { + emitSignatureParameters(ctor); + } + else { + // Based on EcmaScript6 section 14.5.14: Runtime Semantics: ClassDefinitionEvaluation. + // If constructor is empty, then, + // If ClassHeritageopt is present, then + // Let constructor be the result of parsing the String "constructor(... args){ super (...args);}" using the syntactic grammar with the goal symbol MethodDefinition. + // Else, + // Let constructor be the result of parsing the String "constructor( ){ }" using the syntactic grammar with the goal symbol MethodDefinition + if (baseTypeElement) { + write("(...args)"); + } + else { + write("()"); + } + } + } + var startIndex = 0; + write(" {"); + scopeEmitStart(node, "constructor"); + increaseIndent(); + if (ctor) { + // Emit all the directive prologues (like "use strict"). These have to come before + // any other preamble code we write (like parameter initializers). + startIndex = emitDirectivePrologues(ctor.body.statements, /*startWithNewLine*/ true); + emitDetachedComments(ctor.body.statements); + } + emitCaptureThisForNodeIfNecessary(node); + var superCall; + if (ctor) { + emitDefaultValueAssignments(ctor); + emitRestParameter(ctor); + if (baseTypeElement) { + superCall = findInitialSuperCall(ctor); + if (superCall) { + writeLine(); + emit(superCall); + } + } + emitParameterPropertyAssignments(ctor); + } + else { + if (baseTypeElement) { + writeLine(); + emitStart(baseTypeElement); + if (languageVersion < 2 /* ES6 */) { + write("_super.apply(this, arguments);"); + } + else { + write("super(...args);"); + } + emitEnd(baseTypeElement); + } + } + emitPropertyDeclarations(node, getInitializedProperties(node, /*static:*/ false)); + if (ctor) { + var statements = ctor.body.statements; + if (superCall) { + statements = statements.slice(1); + } + emitLinesStartingAt(statements, startIndex); + } + emitTempDeclarations(/*newLine*/ true); + writeLine(); + if (ctor) { + emitLeadingCommentsOfPosition(ctor.body.statements.end); + } + decreaseIndent(); + emitToken(16 /* CloseBraceToken */, ctor ? ctor.body.statements.end : node.members.end); + scopeEmitEnd(); + emitEnd(ctor || node); + if (ctor) { + emitTrailingComments(ctor); + } + } + function emitClassExpression(node) { + return emitClassLikeDeclaration(node); + } + function emitClassDeclaration(node) { + return emitClassLikeDeclaration(node); + } + function emitClassLikeDeclaration(node) { + if (languageVersion < 2 /* ES6 */) { + emitClassLikeDeclarationBelowES6(node); + } + else { + emitClassLikeDeclarationForES6AndHigher(node); + } + if (modulekind !== 5 /* ES6 */ && node.parent === currentSourceFile && node.name) { + emitExportMemberAssignments(node.name); + } + } + function emitClassLikeDeclarationForES6AndHigher(node) { + var thisNodeIsDecorated = ts.nodeIsDecorated(node); + if (node.kind === 214 /* ClassDeclaration */) { + if (thisNodeIsDecorated) { + // To preserve the correct runtime semantics when decorators are applied to the class, + // the emit needs to follow one of the following rules: + // + // * For a local class declaration: + // + // @dec class C { + // } + // + // The emit should be: + // + // let C = class { + // }; + // C = __decorate([dec], C); + // + // * For an exported class declaration: + // + // @dec export class C { + // } + // + // The emit should be: + // + // export let C = class { + // }; + // C = __decorate([dec], C); + // + // * For a default export of a class declaration with a name: + // + // @dec default export class C { + // } + // + // The emit should be: + // + // let C = class { + // } + // C = __decorate([dec], C); + // export default C; + // + // * For a default export of a class declaration without a name: + // + // @dec default export class { + // } + // + // The emit should be: + // + // let _default = class { + // } + // _default = __decorate([dec], _default); + // export default _default; + // + if (isES6ExportedDeclaration(node) && !(node.flags & 1024 /* Default */)) { + write("export "); + } + write("let "); + emitDeclarationName(node); + write(" = "); + } + else if (isES6ExportedDeclaration(node)) { + write("export "); + if (node.flags & 1024 /* Default */) { + write("default "); + } + } + } + // If the class has static properties, and it's a class expression, then we'll need + // to specialize the emit a bit. for a class expression of the form: + // + // class C { static a = 1; static b = 2; ... } + // + // We'll emit: + // + // (_temp = class C { ... }, _temp.a = 1, _temp.b = 2, _temp) + // + // This keeps the expression as an expression, while ensuring that the static parts + // of it have been initialized by the time it is used. + var staticProperties = getInitializedProperties(node, /*static:*/ true); + var isClassExpressionWithStaticProperties = staticProperties.length > 0 && node.kind === 186 /* ClassExpression */; + var tempVariable; + if (isClassExpressionWithStaticProperties) { + tempVariable = createAndRecordTempVariable(0 /* Auto */); + write("("); + increaseIndent(); + emit(tempVariable); + write(" = "); + } + write("class"); + // emit name if + // - node has a name + // - this is default export with static initializers + if ((node.name || (node.flags & 1024 /* Default */ && staticProperties.length > 0)) && !thisNodeIsDecorated) { + write(" "); + emitDeclarationName(node); + } + var baseTypeNode = ts.getClassExtendsHeritageClauseElement(node); + if (baseTypeNode) { + write(" extends "); + emit(baseTypeNode.expression); + } + write(" {"); + increaseIndent(); + scopeEmitStart(node); + writeLine(); + emitConstructor(node, baseTypeNode); + emitMemberFunctionsForES6AndHigher(node); + decreaseIndent(); + writeLine(); + emitToken(16 /* CloseBraceToken */, node.members.end); + scopeEmitEnd(); + // TODO(rbuckton): Need to go back to `let _a = class C {}` approach, removing the defineProperty call for now. + // For a decorated class, we need to assign its name (if it has one). This is because we emit + // the class as a class expression to avoid the double-binding of the identifier: + // + // let C = class { + // } + // Object.defineProperty(C, "name", { value: "C", configurable: true }); + // + if (thisNodeIsDecorated) { + write(";"); + } + // Emit static property assignment. Because classDeclaration is lexically evaluated, + // it is safe to emit static property assignment after classDeclaration + // From ES6 specification: + // 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 (isClassExpressionWithStaticProperties) { + for (var _a = 0; _a < staticProperties.length; _a++) { + var property = staticProperties[_a]; + write(","); + writeLine(); + emitPropertyDeclaration(node, property, /*receiver:*/ tempVariable, /*isExpression:*/ true); + } + write(","); + writeLine(); + emit(tempVariable); + decreaseIndent(); + write(")"); + } + else { + writeLine(); + emitPropertyDeclarations(node, staticProperties); + emitDecoratorsOfClass(node); + } + // If this is an exported class, but not on the top level (i.e. on an internal + // module), export it + if (!isES6ExportedDeclaration(node) && (node.flags & 1 /* Export */)) { + writeLine(); + emitStart(node); + emitModuleMemberName(node); + write(" = "); + emitDeclarationName(node); + emitEnd(node); + write(";"); + } + else if (isES6ExportedDeclaration(node) && (node.flags & 1024 /* Default */) && thisNodeIsDecorated) { + // if this is a top level default export of decorated class, write the export after the declaration. + writeLine(); + write("export default "); + emitDeclarationName(node); + write(";"); + } + } + function emitClassLikeDeclarationBelowES6(node) { + if (node.kind === 214 /* ClassDeclaration */) { + // source file level classes in system modules are hoisted so 'var's for them are already defined + if (!shouldHoistDeclarationInSystemJsModule(node)) { + write("var "); + } + emitDeclarationName(node); + write(" = "); + } + write("(function ("); + var baseTypeNode = ts.getClassExtendsHeritageClauseElement(node); + if (baseTypeNode) { + write("_super"); + } + write(") {"); + var saveTempFlags = tempFlags; + var saveTempVariables = tempVariables; + var saveTempParameters = tempParameters; + var saveComputedPropertyNamesToGeneratedNames = computedPropertyNamesToGeneratedNames; + var saveConvertedLoopState = convertedLoopState; + convertedLoopState = undefined; + tempFlags = 0; + tempVariables = undefined; + tempParameters = undefined; + computedPropertyNamesToGeneratedNames = undefined; + increaseIndent(); + scopeEmitStart(node); + if (baseTypeNode) { + writeLine(); + emitStart(baseTypeNode); + write("__extends("); + emitDeclarationName(node); + write(", _super);"); + emitEnd(baseTypeNode); + } + writeLine(); + emitConstructor(node, baseTypeNode); + emitMemberFunctionsForES5AndLower(node); + emitPropertyDeclarations(node, getInitializedProperties(node, /*static:*/ true)); + writeLine(); + emitDecoratorsOfClass(node); + writeLine(); + emitToken(16 /* CloseBraceToken */, node.members.end, function () { + write("return "); + emitDeclarationName(node); + }); + write(";"); + emitTempDeclarations(/*newLine*/ true); + ts.Debug.assert(convertedLoopState === undefined); + convertedLoopState = saveConvertedLoopState; + tempFlags = saveTempFlags; + tempVariables = saveTempVariables; + tempParameters = saveTempParameters; + computedPropertyNamesToGeneratedNames = saveComputedPropertyNamesToGeneratedNames; + decreaseIndent(); + writeLine(); + emitToken(16 /* CloseBraceToken */, node.members.end); + scopeEmitEnd(); + emitStart(node); + write(")("); + if (baseTypeNode) { + emit(baseTypeNode.expression); + } + write(")"); + if (node.kind === 214 /* ClassDeclaration */) { + write(";"); + } + emitEnd(node); + if (node.kind === 214 /* ClassDeclaration */) { + emitExportMemberAssignment(node); + } + } + function emitClassMemberPrefix(node, member) { + emitDeclarationName(node); + if (!(member.flags & 128 /* Static */)) { + write(".prototype"); + } + } + function emitDecoratorsOfClass(node) { + emitDecoratorsOfMembers(node, /*staticFlag*/ 0); + emitDecoratorsOfMembers(node, 128 /* Static */); + emitDecoratorsOfConstructor(node); + } + function emitDecoratorsOfConstructor(node) { + var decorators = node.decorators; + var constructor = ts.getFirstConstructorWithBody(node); + var hasDecoratedParameters = constructor && ts.forEach(constructor.parameters, ts.nodeIsDecorated); + // skip decoration of the constructor if neither it nor its parameters are decorated + if (!decorators && !hasDecoratedParameters) { + return; + } + // Emit the call to __decorate. Given the class: + // + // @dec + // class C { + // } + // + // The emit for the class is: + // + // C = __decorate([dec], C); + // + writeLine(); + emitStart(node); + emitDeclarationName(node); + write(" = __decorate(["); + increaseIndent(); + writeLine(); + var decoratorCount = decorators ? decorators.length : 0; + var argumentsWritten = emitList(decorators, 0, decoratorCount, /*multiLine*/ true, /*trailingComma*/ false, /*leadingComma*/ false, /*noTrailingNewLine*/ true, function (decorator) { + emitStart(decorator); + emit(decorator.expression); + emitEnd(decorator); + }); + argumentsWritten += emitDecoratorsOfParameters(constructor, /*leadingComma*/ argumentsWritten > 0); + emitSerializedTypeMetadata(node, /*leadingComma*/ argumentsWritten >= 0); + decreaseIndent(); + writeLine(); + write("], "); + emitDeclarationName(node); + write(");"); + emitEnd(node); + writeLine(); + } + function emitDecoratorsOfMembers(node, staticFlag) { + for (var _a = 0, _b = node.members; _a < _b.length; _a++) { + var member = _b[_a]; + // only emit members in the correct group + if ((member.flags & 128 /* Static */) !== staticFlag) { + continue; + } + // skip members that cannot be decorated (such as the constructor) + if (!ts.nodeCanBeDecorated(member)) { + continue; + } + // skip a member if it or any of its parameters are not decorated + if (!ts.nodeOrChildIsDecorated(member)) { + continue; + } + // skip an accessor declaration if it is not the first accessor + var decorators = void 0; + var functionLikeMember = void 0; + if (ts.isAccessor(member)) { + var accessors = ts.getAllAccessorDeclarations(node.members, member); + if (member !== accessors.firstAccessor) { + continue; + } + // get the decorators from the first accessor with decorators + decorators = accessors.firstAccessor.decorators; + if (!decorators && accessors.secondAccessor) { + decorators = accessors.secondAccessor.decorators; + } + // we only decorate parameters of the set accessor + functionLikeMember = accessors.setAccessor; + } + else { + decorators = member.decorators; + // we only decorate the parameters here if this is a method + if (member.kind === 143 /* MethodDeclaration */) { + functionLikeMember = member; + } + } + // Emit the call to __decorate. Given the following: + // + // class C { + // @dec method(@dec2 x) {} + // @dec get accessor() {} + // @dec prop; + // } + // + // The emit for a method is: + // + // __decorate([ + // dec, + // __param(0, dec2), + // __metadata("design:type", Function), + // __metadata("design:paramtypes", [Object]), + // __metadata("design:returntype", void 0) + // ], C.prototype, "method", undefined); + // + // The emit for an accessor is: + // + // __decorate([ + // dec + // ], C.prototype, "accessor", undefined); + // + // The emit for a property is: + // + // __decorate([ + // dec + // ], C.prototype, "prop"); + // + writeLine(); + emitStart(member); + write("__decorate(["); + increaseIndent(); + writeLine(); + var decoratorCount = decorators ? decorators.length : 0; + var argumentsWritten = emitList(decorators, 0, decoratorCount, /*multiLine*/ true, /*trailingComma*/ false, /*leadingComma*/ false, /*noTrailingNewLine*/ true, function (decorator) { + emitStart(decorator); + emit(decorator.expression); + emitEnd(decorator); + }); + argumentsWritten += emitDecoratorsOfParameters(functionLikeMember, argumentsWritten > 0); + emitSerializedTypeMetadata(member, argumentsWritten > 0); + decreaseIndent(); + writeLine(); + write("], "); + emitStart(member.name); + emitClassMemberPrefix(node, member); + write(", "); + emitExpressionForPropertyName(member.name); + emitEnd(member.name); + if (languageVersion > 0 /* ES3 */) { + if (member.kind !== 141 /* PropertyDeclaration */) { + // We emit `null` here to indicate to `__decorate` that it can invoke `Object.getOwnPropertyDescriptor` directly. + // We have this extra argument here so that we can inject an explicit property descriptor at a later date. + write(", null"); + } + else { + // We emit `void 0` here to indicate to `__decorate` that it can invoke `Object.defineProperty` directly, but that it + // should not invoke `Object.getOwnPropertyDescriptor`. + write(", void 0"); + } + } + write(");"); + emitEnd(member); + writeLine(); + } + } + function emitDecoratorsOfParameters(node, leadingComma) { + var argumentsWritten = 0; + if (node) { + var parameterIndex = 0; + for (var _a = 0, _b = node.parameters; _a < _b.length; _a++) { + var parameter = _b[_a]; + if (ts.nodeIsDecorated(parameter)) { + var decorators = parameter.decorators; + argumentsWritten += emitList(decorators, 0, decorators.length, /*multiLine*/ true, /*trailingComma*/ false, /*leadingComma*/ leadingComma, /*noTrailingNewLine*/ true, function (decorator) { + emitStart(decorator); + write("__param(" + parameterIndex + ", "); + emit(decorator.expression); + write(")"); + emitEnd(decorator); + }); + leadingComma = true; + } + ++parameterIndex; + } + } + return argumentsWritten; + } + function shouldEmitTypeMetadata(node) { + // This method determines whether to emit the "design:type" metadata based on the node's kind. + // The caller should have already tested whether the node has decorators and whether the emitDecoratorMetadata + // compiler option is set. + switch (node.kind) { + case 143 /* MethodDeclaration */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: + case 141 /* PropertyDeclaration */: + return true; + } + return false; + } + function shouldEmitReturnTypeMetadata(node) { + // This method determines whether to emit the "design:returntype" metadata based on the node's kind. + // The caller should have already tested whether the node has decorators and whether the emitDecoratorMetadata + // compiler option is set. + switch (node.kind) { + case 143 /* MethodDeclaration */: + return true; + } + return false; + } + function shouldEmitParamTypesMetadata(node) { + // This method determines whether to emit the "design:paramtypes" metadata based on the node's kind. + // The caller should have already tested whether the node has decorators and whether the emitDecoratorMetadata + // compiler option is set. + switch (node.kind) { + case 214 /* ClassDeclaration */: + case 143 /* MethodDeclaration */: + case 146 /* SetAccessor */: + return true; + } + return false; + } + /** Serializes the type of a declaration to an appropriate JS constructor value. Used by the __metadata decorator for a class member. */ + function emitSerializedTypeOfNode(node) { + // serialization of the type of a declaration uses the following rules: + // + // * The serialized type of a ClassDeclaration is "Function" + // * The serialized type of a ParameterDeclaration is the serialized type of its type annotation. + // * The serialized type of a PropertyDeclaration is the serialized type of its type annotation. + // * The serialized type of an AccessorDeclaration is the serialized type of the return type annotation of its getter or parameter type annotation of its setter. + // * The serialized type of any other FunctionLikeDeclaration is "Function". + // * The serialized type of any other node is "void 0". + // + // For rules on serializing type annotations, see `serializeTypeNode`. + switch (node.kind) { + case 214 /* ClassDeclaration */: + write("Function"); + return; + case 141 /* PropertyDeclaration */: + emitSerializedTypeNode(node.type); + return; + case 138 /* Parameter */: + emitSerializedTypeNode(node.type); + return; + case 145 /* GetAccessor */: + emitSerializedTypeNode(node.type); + return; + case 146 /* SetAccessor */: + emitSerializedTypeNode(ts.getSetAccessorTypeAnnotationNode(node)); + return; + } + if (ts.isFunctionLike(node)) { + write("Function"); + return; + } + write("void 0"); + } + function emitSerializedTypeNode(node) { + if (node) { + switch (node.kind) { + case 103 /* VoidKeyword */: + write("void 0"); + return; + case 160 /* ParenthesizedType */: + emitSerializedTypeNode(node.type); + return; + case 152 /* FunctionType */: + case 153 /* ConstructorType */: + write("Function"); + return; + case 156 /* ArrayType */: + case 157 /* TupleType */: + write("Array"); + return; + case 150 /* TypePredicate */: + case 120 /* BooleanKeyword */: + write("Boolean"); + return; + case 130 /* StringKeyword */: + case 9 /* StringLiteral */: + write("String"); + return; + case 128 /* NumberKeyword */: + write("Number"); + return; + case 131 /* SymbolKeyword */: + write("Symbol"); + return; + case 151 /* TypeReference */: + emitSerializedTypeReferenceNode(node); + return; + case 154 /* TypeQuery */: + case 155 /* TypeLiteral */: + case 158 /* UnionType */: + case 159 /* IntersectionType */: + case 117 /* AnyKeyword */: + break; + default: + ts.Debug.fail("Cannot serialize unexpected type node."); + break; + } + } + write("Object"); + } + /** Serializes a TypeReferenceNode to an appropriate JS constructor value. Used by the __metadata decorator. */ + function emitSerializedTypeReferenceNode(node) { + var location = node.parent; + while (ts.isDeclaration(location) || ts.isTypeNode(location)) { + location = location.parent; + } + // Clone the type name and parent it to a location outside of the current declaration. + var typeName = ts.cloneEntityName(node.typeName); + typeName.parent = location; + var result = resolver.getTypeReferenceSerializationKind(typeName); + switch (result) { + case ts.TypeReferenceSerializationKind.Unknown: + var temp = createAndRecordTempVariable(0 /* Auto */); + write("(typeof ("); + emitNodeWithoutSourceMap(temp); + write(" = "); + emitEntityNameAsExpression(typeName, /*useFallback*/ true); + write(") === 'function' && "); + emitNodeWithoutSourceMap(temp); + write(") || Object"); + break; + case ts.TypeReferenceSerializationKind.TypeWithConstructSignatureAndValue: + emitEntityNameAsExpression(typeName, /*useFallback*/ false); + break; + case ts.TypeReferenceSerializationKind.VoidType: + write("void 0"); + break; + case ts.TypeReferenceSerializationKind.BooleanType: + write("Boolean"); + break; + case ts.TypeReferenceSerializationKind.NumberLikeType: + write("Number"); + break; + case ts.TypeReferenceSerializationKind.StringLikeType: + write("String"); + break; + case ts.TypeReferenceSerializationKind.ArrayLikeType: + write("Array"); + break; + case ts.TypeReferenceSerializationKind.ESSymbolType: + if (languageVersion < 2 /* ES6 */) { + write("typeof Symbol === 'function' ? Symbol : Object"); + } + else { + write("Symbol"); + } + break; + case ts.TypeReferenceSerializationKind.TypeWithCallSignature: + write("Function"); + break; + case ts.TypeReferenceSerializationKind.ObjectType: + write("Object"); + break; + } + } + /** Serializes the parameter types of a function or the constructor of a class. Used by the __metadata decorator for a method or set accessor. */ + function emitSerializedParameterTypesOfNode(node) { + // serialization of parameter types uses the following rules: + // + // * If the declaration is a class, the parameters of the first constructor with a body are used. + // * If the declaration is function-like and has a body, the parameters of the function are used. + // + // For the rules on serializing the type of each parameter declaration, see `serializeTypeOfDeclaration`. + if (node) { + var valueDeclaration; + if (node.kind === 214 /* ClassDeclaration */) { + valueDeclaration = ts.getFirstConstructorWithBody(node); + } + else if (ts.isFunctionLike(node) && ts.nodeIsPresent(node.body)) { + valueDeclaration = node; + } + if (valueDeclaration) { + var parameters = valueDeclaration.parameters; + var parameterCount = parameters.length; + if (parameterCount > 0) { + for (var i = 0; i < parameterCount; i++) { + if (i > 0) { + write(", "); + } + if (parameters[i].dotDotDotToken) { + var parameterType = parameters[i].type; + if (parameterType.kind === 156 /* ArrayType */) { + parameterType = parameterType.elementType; + } + else if (parameterType.kind === 151 /* TypeReference */ && parameterType.typeArguments && parameterType.typeArguments.length === 1) { + parameterType = parameterType.typeArguments[0]; + } + else { + parameterType = undefined; + } + emitSerializedTypeNode(parameterType); + } + else { + emitSerializedTypeOfNode(parameters[i]); + } + } + } + } + } + } + /** Serializes the return type of function. Used by the __metadata decorator for a method. */ + function emitSerializedReturnTypeOfNode(node) { + if (node && ts.isFunctionLike(node) && node.type) { + emitSerializedTypeNode(node.type); + return; + } + write("void 0"); + } + function emitSerializedTypeMetadata(node, writeComma) { + // This method emits the serialized type metadata for a decorator target. + // The caller should have already tested whether the node has decorators. + var argumentsWritten = 0; + if (compilerOptions.emitDecoratorMetadata) { + if (shouldEmitTypeMetadata(node)) { + if (writeComma) { + write(", "); + } + writeLine(); + write("__metadata('design:type', "); + emitSerializedTypeOfNode(node); + write(")"); + argumentsWritten++; + } + if (shouldEmitParamTypesMetadata(node)) { + if (writeComma || argumentsWritten) { + write(", "); + } + writeLine(); + write("__metadata('design:paramtypes', ["); + emitSerializedParameterTypesOfNode(node); + write("])"); + argumentsWritten++; + } + if (shouldEmitReturnTypeMetadata(node)) { + if (writeComma || argumentsWritten) { + write(", "); + } + writeLine(); + write("__metadata('design:returntype', "); + emitSerializedReturnTypeOfNode(node); + write(")"); + argumentsWritten++; + } + } + return argumentsWritten; + } + function emitInterfaceDeclaration(node) { + emitCommentsOnNotEmittedNode(node); + } + function shouldEmitEnumDeclaration(node) { + var isConstEnum = ts.isConst(node); + return !isConstEnum || compilerOptions.preserveConstEnums || compilerOptions.isolatedModules; + } + function emitEnumDeclaration(node) { + // const enums are completely erased during compilation. + if (!shouldEmitEnumDeclaration(node)) { + return; + } + if (!shouldHoistDeclarationInSystemJsModule(node)) { + // do not emit var if variable was already hoisted + if (!(node.flags & 1 /* Export */) || isES6ExportedDeclaration(node)) { + emitStart(node); + if (isES6ExportedDeclaration(node)) { + write("export "); + } + write("var "); + emit(node.name); + emitEnd(node); + write(";"); + } + } + writeLine(); + emitStart(node); + write("(function ("); + emitStart(node.name); + write(getGeneratedNameForNode(node)); + emitEnd(node.name); + write(") {"); + increaseIndent(); + scopeEmitStart(node); + emitLines(node.members); + decreaseIndent(); + writeLine(); + emitToken(16 /* CloseBraceToken */, node.members.end); + scopeEmitEnd(); + write(")("); + emitModuleMemberName(node); + write(" || ("); + emitModuleMemberName(node); + write(" = {}));"); + emitEnd(node); + if (!isES6ExportedDeclaration(node) && node.flags & 1 /* Export */ && !shouldHoistDeclarationInSystemJsModule(node)) { + // do not emit var if variable was already hoisted + writeLine(); + emitStart(node); + write("var "); + emit(node.name); + write(" = "); + emitModuleMemberName(node); + emitEnd(node); + write(";"); + } + if (modulekind !== 5 /* ES6 */ && node.parent === currentSourceFile) { + if (modulekind === 4 /* System */ && (node.flags & 1 /* Export */)) { + // write the call to exporter for enum + writeLine(); + write(exportFunctionForFile + "(\""); + emitDeclarationName(node); + write("\", "); + emitDeclarationName(node); + write(");"); + } + emitExportMemberAssignments(node.name); + } + } + function emitEnumMember(node) { + var enumParent = node.parent; + emitStart(node); + write(getGeneratedNameForNode(enumParent)); + write("["); + write(getGeneratedNameForNode(enumParent)); + write("["); + emitExpressionForPropertyName(node.name); + write("] = "); + writeEnumMemberDeclarationValue(node); + write("] = "); + emitExpressionForPropertyName(node.name); + emitEnd(node); + write(";"); + } + function writeEnumMemberDeclarationValue(member) { + var value = resolver.getConstantValue(member); + if (value !== undefined) { + write(value.toString()); + return; + } + else if (member.initializer) { + emit(member.initializer); + } + else { + write("undefined"); + } + } + function getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration) { + if (moduleDeclaration.body.kind === 218 /* ModuleDeclaration */) { + var recursiveInnerModule = getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration.body); + return recursiveInnerModule || moduleDeclaration.body; + } + } + function shouldEmitModuleDeclaration(node) { + return ts.isInstantiatedModule(node, compilerOptions.preserveConstEnums || compilerOptions.isolatedModules); + } + function isModuleMergedWithES6Class(node) { + return languageVersion === 2 /* ES6 */ && !!(resolver.getNodeCheckFlags(node) & 32768 /* LexicalModuleMergesWithClass */); + } + function emitModuleDeclaration(node) { + // Emit only if this module is non-ambient. + var shouldEmit = shouldEmitModuleDeclaration(node); + if (!shouldEmit) { + return emitCommentsOnNotEmittedNode(node); + } + var hoistedInDeclarationScope = shouldHoistDeclarationInSystemJsModule(node); + var emitVarForModule = !hoistedInDeclarationScope && !isModuleMergedWithES6Class(node); + if (emitVarForModule) { + emitStart(node); + if (isES6ExportedDeclaration(node)) { + write("export "); + } + write("var "); + emit(node.name); + write(";"); + emitEnd(node); + writeLine(); + } + emitStart(node); + write("(function ("); + emitStart(node.name); + write(getGeneratedNameForNode(node)); + emitEnd(node.name); + write(") "); + if (node.body.kind === 219 /* ModuleBlock */) { + var saveConvertedLoopState = convertedLoopState; + var saveTempFlags = tempFlags; + var saveTempVariables = tempVariables; + convertedLoopState = undefined; + tempFlags = 0; + tempVariables = undefined; + emit(node.body); + ts.Debug.assert(convertedLoopState === undefined); + convertedLoopState = saveConvertedLoopState; + tempFlags = saveTempFlags; + tempVariables = saveTempVariables; + } + else { + write("{"); + increaseIndent(); + scopeEmitStart(node); + emitCaptureThisForNodeIfNecessary(node); + writeLine(); + emit(node.body); + decreaseIndent(); + writeLine(); + var moduleBlock = getInnerMostModuleDeclarationFromDottedModule(node).body; + emitToken(16 /* CloseBraceToken */, moduleBlock.statements.end); + scopeEmitEnd(); + } + write(")("); + // write moduleDecl = containingModule.m only if it is not exported es6 module member + if ((node.flags & 1 /* Export */) && !isES6ExportedDeclaration(node)) { + emit(node.name); + write(" = "); + } + emitModuleMemberName(node); + write(" || ("); + emitModuleMemberName(node); + write(" = {}));"); + emitEnd(node); + if (!isES6ExportedDeclaration(node) && node.name.kind === 69 /* Identifier */ && node.parent === currentSourceFile) { + if (modulekind === 4 /* System */ && (node.flags & 1 /* Export */)) { + writeLine(); + write(exportFunctionForFile + "(\""); + emitDeclarationName(node); + write("\", "); + emitDeclarationName(node); + write(");"); + } + emitExportMemberAssignments(node.name); + } + } + /* + * Some bundlers (SystemJS builder) sometimes want to rename dependencies. + * Here we check if alternative name was provided for a given moduleName and return it if possible. + */ + function tryRenameExternalModule(moduleName) { + if (currentSourceFile.renamedDependencies && ts.hasProperty(currentSourceFile.renamedDependencies, moduleName.text)) { + return "\"" + currentSourceFile.renamedDependencies[moduleName.text] + "\""; + } + return undefined; + } + function emitRequire(moduleName) { + if (moduleName.kind === 9 /* StringLiteral */) { + write("require("); + var text = tryRenameExternalModule(moduleName); + if (text) { + write(text); + } + else { + emitStart(moduleName); + emitLiteral(moduleName); + emitEnd(moduleName); + } + emitToken(18 /* CloseParenToken */, moduleName.end); + } + else { + write("require()"); + } + } + function getNamespaceDeclarationNode(node) { + if (node.kind === 221 /* ImportEqualsDeclaration */) { + return node; + } + var importClause = node.importClause; + if (importClause && importClause.namedBindings && importClause.namedBindings.kind === 224 /* NamespaceImport */) { + return importClause.namedBindings; + } + } + function isDefaultImport(node) { + return node.kind === 222 /* ImportDeclaration */ && node.importClause && !!node.importClause.name; + } + function emitExportImportAssignments(node) { + if (ts.isAliasSymbolDeclaration(node) && resolver.isValueAliasDeclaration(node)) { + emitExportMemberAssignments(node.name); + } + ts.forEachChild(node, emitExportImportAssignments); + } + function emitImportDeclaration(node) { + if (modulekind !== 5 /* ES6 */) { + return emitExternalImportDeclaration(node); + } + // ES6 import + if (node.importClause) { + var shouldEmitDefaultBindings = resolver.isReferencedAliasDeclaration(node.importClause); + var shouldEmitNamedBindings = node.importClause.namedBindings && resolver.isReferencedAliasDeclaration(node.importClause.namedBindings, /* checkChildren */ true); + if (shouldEmitDefaultBindings || shouldEmitNamedBindings) { + write("import "); + emitStart(node.importClause); + if (shouldEmitDefaultBindings) { + emit(node.importClause.name); + if (shouldEmitNamedBindings) { + write(", "); + } + } + if (shouldEmitNamedBindings) { + emitLeadingComments(node.importClause.namedBindings); + emitStart(node.importClause.namedBindings); + if (node.importClause.namedBindings.kind === 224 /* NamespaceImport */) { + write("* as "); + emit(node.importClause.namedBindings.name); + } + else { + write("{ "); + emitExportOrImportSpecifierList(node.importClause.namedBindings.elements, resolver.isReferencedAliasDeclaration); + write(" }"); + } + emitEnd(node.importClause.namedBindings); + emitTrailingComments(node.importClause.namedBindings); + } + emitEnd(node.importClause); + write(" from "); + emit(node.moduleSpecifier); + write(";"); + } + } + else { + write("import "); + emit(node.moduleSpecifier); + write(";"); + } + } + function emitExternalImportDeclaration(node) { + if (ts.contains(externalImports, node)) { + var isExportedImport = node.kind === 221 /* ImportEqualsDeclaration */ && (node.flags & 1 /* Export */) !== 0; + var namespaceDeclaration = getNamespaceDeclarationNode(node); + if (modulekind !== 2 /* AMD */) { + emitLeadingComments(node); + emitStart(node); + if (namespaceDeclaration && !isDefaultImport(node)) { + // import x = require("foo") + // import * as x from "foo" + if (!isExportedImport) + write("var "); + emitModuleMemberName(namespaceDeclaration); + write(" = "); + } + else { + // import "foo" + // import x from "foo" + // import { x, y } from "foo" + // import d, * as x from "foo" + // import d, { x, y } from "foo" + var isNakedImport = 222 /* ImportDeclaration */ && !node.importClause; + if (!isNakedImport) { + write("var "); + write(getGeneratedNameForNode(node)); + write(" = "); + } + } + emitRequire(ts.getExternalModuleName(node)); + if (namespaceDeclaration && isDefaultImport(node)) { + // import d, * as x from "foo" + write(", "); + emitModuleMemberName(namespaceDeclaration); + write(" = "); + write(getGeneratedNameForNode(node)); + } + write(";"); + emitEnd(node); + emitExportImportAssignments(node); + emitTrailingComments(node); + } + else { + if (isExportedImport) { + emitModuleMemberName(namespaceDeclaration); + write(" = "); + emit(namespaceDeclaration.name); + write(";"); + } + else if (namespaceDeclaration && isDefaultImport(node)) { + // import d, * as x from "foo" + write("var "); + emitModuleMemberName(namespaceDeclaration); + write(" = "); + write(getGeneratedNameForNode(node)); + write(";"); + } + emitExportImportAssignments(node); + } + } + } + function emitImportEqualsDeclaration(node) { + if (ts.isExternalModuleImportEqualsDeclaration(node)) { + emitExternalImportDeclaration(node); + return; + } + // preserve old compiler's behavior: emit 'var' for import declaration (even if we do not consider them referenced) when + // - current file is not external module + // - import declaration is top level and target is value imported by entity name + if (resolver.isReferencedAliasDeclaration(node) || + (!ts.isExternalModule(currentSourceFile) && resolver.isTopLevelValueImportEqualsWithEntityName(node))) { + emitLeadingComments(node); + emitStart(node); + // variable declaration for import-equals declaration can be hoisted in system modules + // in this case 'var' should be omitted and emit should contain only initialization + var variableDeclarationIsHoisted = shouldHoistVariable(node, /*checkIfSourceFileLevelDecl*/ true); + // is it top level export import v = a.b.c in system module? + // if yes - it needs to be rewritten as exporter('v', v = a.b.c) + var isExported = isSourceFileLevelDeclarationInSystemJsModule(node, /*isExported*/ true); + if (!variableDeclarationIsHoisted) { + ts.Debug.assert(!isExported); + if (isES6ExportedDeclaration(node)) { + write("export "); + write("var "); + } + else if (!(node.flags & 1 /* Export */)) { + write("var "); + } + } + if (isExported) { + write(exportFunctionForFile + "(\""); + emitNodeWithoutSourceMap(node.name); + write("\", "); + } + emitModuleMemberName(node); + write(" = "); + emit(node.moduleReference); + if (isExported) { + write(")"); + } + write(";"); + emitEnd(node); + emitExportImportAssignments(node); + emitTrailingComments(node); + } + } + function emitExportDeclaration(node) { + ts.Debug.assert(modulekind !== 4 /* System */); + if (modulekind !== 5 /* ES6 */) { + if (node.moduleSpecifier && (!node.exportClause || resolver.isValueAliasDeclaration(node))) { + emitStart(node); + var generatedName = getGeneratedNameForNode(node); + if (node.exportClause) { + // export { x, y, ... } from "foo" + if (modulekind !== 2 /* AMD */) { + write("var "); + write(generatedName); + write(" = "); + emitRequire(ts.getExternalModuleName(node)); + write(";"); + } + for (var _a = 0, _b = node.exportClause.elements; _a < _b.length; _a++) { + var specifier = _b[_a]; + if (resolver.isValueAliasDeclaration(specifier)) { + writeLine(); + emitStart(specifier); + emitContainingModuleName(specifier); + write("."); + emitNodeWithCommentsAndWithoutSourcemap(specifier.name); + write(" = "); + write(generatedName); + write("."); + emitNodeWithCommentsAndWithoutSourcemap(specifier.propertyName || specifier.name); + write(";"); + emitEnd(specifier); + } + } + } + else { + // export * from "foo" + writeLine(); + write("__export("); + if (modulekind !== 2 /* AMD */) { + emitRequire(ts.getExternalModuleName(node)); + } + else { + write(generatedName); + } + write(");"); + } + emitEnd(node); + } + } + else { + if (!node.exportClause || resolver.isValueAliasDeclaration(node)) { + write("export "); + if (node.exportClause) { + // export { x, y, ... } + write("{ "); + emitExportOrImportSpecifierList(node.exportClause.elements, resolver.isValueAliasDeclaration); + write(" }"); + } + else { + write("*"); + } + if (node.moduleSpecifier) { + write(" from "); + emit(node.moduleSpecifier); + } + write(";"); + } + } + } + function emitExportOrImportSpecifierList(specifiers, shouldEmit) { + ts.Debug.assert(modulekind === 5 /* ES6 */); + var needsComma = false; + for (var _a = 0; _a < specifiers.length; _a++) { + var specifier = specifiers[_a]; + if (shouldEmit(specifier)) { + if (needsComma) { + write(", "); + } + if (specifier.propertyName) { + emit(specifier.propertyName); + write(" as "); + } + emit(specifier.name); + needsComma = true; + } + } + } + function emitExportAssignment(node) { + if (!node.isExportEquals && resolver.isValueAliasDeclaration(node)) { + if (modulekind === 5 /* ES6 */) { + writeLine(); + emitStart(node); + write("export default "); + var expression = node.expression; + emit(expression); + if (expression.kind !== 213 /* FunctionDeclaration */ && + expression.kind !== 214 /* ClassDeclaration */) { + write(";"); + } + emitEnd(node); + } + else { + writeLine(); + emitStart(node); + if (modulekind === 4 /* System */) { + write(exportFunctionForFile + "(\"default\","); + emit(node.expression); + write(")"); + } + else { + emitEs6ExportDefaultCompat(node); + emitContainingModuleName(node); + if (languageVersion === 0 /* ES3 */) { + write("[\"default\"] = "); + } + else { + write(".default = "); + } + emit(node.expression); + } + write(";"); + emitEnd(node); + } + } + } + function collectExternalModuleInfo(sourceFile) { + externalImports = []; + exportSpecifiers = {}; + exportEquals = undefined; + hasExportStars = false; + for (var _a = 0, _b = sourceFile.statements; _a < _b.length; _a++) { + var node = _b[_a]; + switch (node.kind) { + case 222 /* 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); + } + break; + case 221 /* ImportEqualsDeclaration */: + if (node.moduleReference.kind === 232 /* ExternalModuleReference */ && resolver.isReferencedAliasDeclaration(node)) { + // import x = require("mod") where x is referenced + externalImports.push(node); + } + break; + case 228 /* ExportDeclaration */: + if (node.moduleSpecifier) { + if (!node.exportClause) { + // export * from "mod" + externalImports.push(node); + hasExportStars = true; + } + else if (resolver.isValueAliasDeclaration(node)) { + // export { x, y } from "mod" where at least one export is a value symbol + externalImports.push(node); + } + } + else { + // export { x, y } + for (var _c = 0, _d = node.exportClause.elements; _c < _d.length; _c++) { + var specifier = _d[_c]; + var name_26 = (specifier.propertyName || specifier.name).text; + (exportSpecifiers[name_26] || (exportSpecifiers[name_26] = [])).push(specifier); + } + } + break; + case 227 /* ExportAssignment */: + if (node.isExportEquals && !exportEquals) { + // export = x + exportEquals = node; + } + break; + } + } + } + function emitExportStarHelper() { + if (hasExportStars) { + writeLine(); + write("function __export(m) {"); + increaseIndent(); + writeLine(); + write("for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];"); + decreaseIndent(); + writeLine(); + write("}"); + } + } + function getLocalNameForExternalImport(node) { + var namespaceDeclaration = getNamespaceDeclarationNode(node); + if (namespaceDeclaration && !isDefaultImport(node)) { + return ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, namespaceDeclaration.name); + } + if (node.kind === 222 /* ImportDeclaration */ && node.importClause) { + return getGeneratedNameForNode(node); + } + if (node.kind === 228 /* ExportDeclaration */ && node.moduleSpecifier) { + return getGeneratedNameForNode(node); + } + } + function getExternalModuleNameText(importNode) { + var moduleName = ts.getExternalModuleName(importNode); + if (moduleName.kind === 9 /* StringLiteral */) { + return tryRenameExternalModule(moduleName) || getLiteralText(moduleName); + } + return undefined; + } + function emitVariableDeclarationsForImports() { + if (externalImports.length === 0) { + return; + } + writeLine(); + var started = false; + for (var _a = 0; _a < externalImports.length; _a++) { + var importNode = externalImports[_a]; + // do not create variable declaration for exports and imports that lack import clause + var skipNode = importNode.kind === 228 /* ExportDeclaration */ || + (importNode.kind === 222 /* ImportDeclaration */ && !importNode.importClause); + if (skipNode) { + continue; + } + if (!started) { + write("var "); + started = true; + } + else { + write(", "); + } + write(getLocalNameForExternalImport(importNode)); + } + if (started) { + write(";"); + } + } + function emitLocalStorageForExportedNamesIfNecessary(exportedDeclarations) { + // 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. + if (!hasExportStars) { + // local names set is needed only in presence of star exports + return undefined; + } + // local names set should only be added if we have anything exported + if (!exportedDeclarations && 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 _a = 0; _a < externalImports.length; _a++) { + var externalImport = externalImports[_a]; + if (externalImport.kind === 228 /* ExportDeclaration */ && externalImport.exportClause) { + hasExportDeclarationWithExportClause = true; + break; + } + } + if (!hasExportDeclarationWithExportClause) { + // we still need to emit exportStar helper + return emitExportStarFunction(/*localNames*/ undefined); + } + } + var exportedNamesStorageRef = makeUniqueName("exportedNames"); + writeLine(); + write("var " + exportedNamesStorageRef + " = {"); + increaseIndent(); + var started = false; + if (exportedDeclarations) { + for (var i = 0; i < exportedDeclarations.length; ++i) { + // write name of exported declaration, i.e 'export var x...' + writeExportedName(exportedDeclarations[i]); + } + } + if (exportSpecifiers) { + for (var n in exportSpecifiers) { + for (var _b = 0, _c = exportSpecifiers[n]; _b < _c.length; _b++) { + var specifier = _c[_b]; + // write name of export specified, i.e. 'export {x}' + writeExportedName(specifier.name); + } + } + } + for (var _d = 0; _d < externalImports.length; _d++) { + var externalImport = externalImports[_d]; + if (externalImport.kind !== 228 /* ExportDeclaration */) { + continue; + } + var exportDecl = externalImport; + if (!exportDecl.exportClause) { + // export * from ... + continue; + } + for (var _e = 0, _f = exportDecl.exportClause.elements; _e < _f.length; _e++) { + var element = _f[_e]; + // write name of indirectly exported entry, i.e. 'export {x} from ...' + writeExportedName(element.name || element.propertyName); + } + } + decreaseIndent(); + writeLine(); + write("};"); + return emitExportStarFunction(exportedNamesStorageRef); + function emitExportStarFunction(localNames) { + var exportStarFunction = makeUniqueName("exportStar"); + writeLine(); + // define an export star helper function + write("function " + exportStarFunction + "(m) {"); + increaseIndent(); + writeLine(); + write("var exports = {};"); + writeLine(); + write("for(var n in m) {"); + increaseIndent(); + writeLine(); + write("if (n !== \"default\""); + if (localNames) { + write("&& !" + localNames + ".hasOwnProperty(n)"); + } + write(") exports[n] = m[n];"); + decreaseIndent(); + writeLine(); + write("}"); + writeLine(); + write(exportFunctionForFile + "(exports);"); + decreaseIndent(); + writeLine(); + write("}"); + return exportStarFunction; + } + function writeExportedName(node) { + // do not record default exports + // they are local to module and never overwritten (explicitly skipped) by star export + if (node.kind !== 69 /* Identifier */ && node.flags & 1024 /* Default */) { + return; + } + if (started) { + write(","); + } + else { + started = true; + } + writeLine(); + write("'"); + if (node.kind === 69 /* Identifier */) { + emitNodeWithCommentsAndWithoutSourcemap(node); + } + else { + emitDeclarationName(node); + } + write("': true"); + } + } + function processTopLevelVariableAndFunctionDeclarations(node) { + // per ES6 spec: + // 15.2.1.16.4 ModuleDeclarationInstantiation() Concrete Method + // - var declarations are initialized to undefined - 14.a.ii + // - function/generator declarations are instantiated - 16.a.iv + // this means that after module is instantiated but before its evaluation + // exported functions are already accessible at import sites + // in theory we should hoist only exported functions and its dependencies + // in practice to simplify things we'll hoist all source level functions and variable declaration + // including variables declarations for module and class declarations + var hoistedVars; + var hoistedFunctionDeclarations; + var exportedDeclarations; + visit(node); + if (hoistedVars) { + writeLine(); + write("var "); + var seen = {}; + for (var i = 0; i < hoistedVars.length; ++i) { + var local = hoistedVars[i]; + var name_27 = local.kind === 69 /* Identifier */ + ? local + : local.name; + if (name_27) { + // do not emit duplicate entries (in case of declaration merging) in the list of hoisted variables + var text = ts.unescapeIdentifier(name_27.text); + if (ts.hasProperty(seen, text)) { + continue; + } + else { + seen[text] = text; + } + } + if (i !== 0) { + write(", "); + } + if (local.kind === 214 /* ClassDeclaration */ || local.kind === 218 /* ModuleDeclaration */ || local.kind === 217 /* EnumDeclaration */) { + emitDeclarationName(local); + } + else { + emit(local); + } + var flags = ts.getCombinedNodeFlags(local.kind === 69 /* Identifier */ ? local.parent : local); + if (flags & 1 /* Export */) { + if (!exportedDeclarations) { + exportedDeclarations = []; + } + exportedDeclarations.push(local); + } + } + write(";"); + } + if (hoistedFunctionDeclarations) { + for (var _a = 0; _a < hoistedFunctionDeclarations.length; _a++) { + var f = hoistedFunctionDeclarations[_a]; + writeLine(); + emit(f); + if (f.flags & 1 /* Export */) { + if (!exportedDeclarations) { + exportedDeclarations = []; + } + exportedDeclarations.push(f); + } + } + } + return exportedDeclarations; + function visit(node) { + if (node.flags & 2 /* Ambient */) { + return; + } + if (node.kind === 213 /* FunctionDeclaration */) { + if (!hoistedFunctionDeclarations) { + hoistedFunctionDeclarations = []; + } + hoistedFunctionDeclarations.push(node); + return; + } + if (node.kind === 214 /* ClassDeclaration */) { + if (!hoistedVars) { + hoistedVars = []; + } + hoistedVars.push(node); + return; + } + if (node.kind === 217 /* EnumDeclaration */) { + if (shouldEmitEnumDeclaration(node)) { + if (!hoistedVars) { + hoistedVars = []; + } + hoistedVars.push(node); + } + return; + } + if (node.kind === 218 /* ModuleDeclaration */) { + if (shouldEmitModuleDeclaration(node)) { + if (!hoistedVars) { + hoistedVars = []; + } + hoistedVars.push(node); + } + return; + } + if (node.kind === 211 /* VariableDeclaration */ || node.kind === 163 /* BindingElement */) { + if (shouldHoistVariable(node, /*checkIfSourceFileLevelDecl*/ false)) { + var name_28 = node.name; + if (name_28.kind === 69 /* Identifier */) { + if (!hoistedVars) { + hoistedVars = []; + } + hoistedVars.push(name_28); + } + else { + ts.forEachChild(name_28, visit); + } + } + return; + } + if (ts.isInternalModuleImportEqualsDeclaration(node) && resolver.isValueAliasDeclaration(node)) { + if (!hoistedVars) { + hoistedVars = []; + } + hoistedVars.push(node.name); + return; + } + if (ts.isBindingPattern(node)) { + ts.forEach(node.elements, visit); + return; + } + if (!ts.isDeclaration(node)) { + ts.forEachChild(node, visit); + } + } + } + function shouldHoistVariable(node, checkIfSourceFileLevelDecl) { + if (checkIfSourceFileLevelDecl && !shouldHoistDeclarationInSystemJsModule(node)) { + return false; + } + // hoist variable if + // - it is not block scoped + // - it is top level block scoped + // if block scoped variables are nested in some another block then + // no other functions can use them except ones that are defined at least in the same block + return (ts.getCombinedNodeFlags(node) & 49152 /* BlockScoped */) === 0 || + ts.getEnclosingBlockScopeContainer(node).kind === 248 /* SourceFile */; + } + function isCurrentFileSystemExternalModule() { + return modulekind === 4 /* System */ && ts.isExternalModule(currentSourceFile); + } + function emitSystemModuleBody(node, dependencyGroups, startIndex) { + // 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 file1; // local alias + // var y; + // function foo() { return y + file1.x(); } + // exports("foo", foo); + // return { + // setters: [ + // function(v) { file1 = v } + // ], + // execute(): function() { + // y = 1; + // console.log(y); + // } + // }; + // } + emitVariableDeclarationsForImports(); + writeLine(); + var exportedDeclarations = processTopLevelVariableAndFunctionDeclarations(node); + var exportStarFunction = emitLocalStorageForExportedNamesIfNecessary(exportedDeclarations); + writeLine(); + write("return {"); + increaseIndent(); + writeLine(); + emitSetters(exportStarFunction, dependencyGroups); + writeLine(); + emitExecute(node, startIndex); + decreaseIndent(); + writeLine(); + write("}"); // return + emitTempDeclarations(/*newLine*/ true); + } + function emitSetters(exportStarFunction, dependencyGroups) { + write("setters:["); + for (var i = 0; i < dependencyGroups.length; ++i) { + if (i !== 0) { + write(","); + } + writeLine(); + increaseIndent(); + var group = dependencyGroups[i]; + // derive a unique name for parameter from the first named entry in the group + var parameterName = makeUniqueName(ts.forEach(group, getLocalNameForExternalImport) || ""); + write("function (" + parameterName + ") {"); + increaseIndent(); + for (var _a = 0; _a < group.length; _a++) { + var entry = group[_a]; + var importVariableName = getLocalNameForExternalImport(entry) || ""; + switch (entry.kind) { + case 222 /* ImportDeclaration */: + if (!entry.importClause) { + // 'import "..."' case + // module is imported only for side-effects, no emit required + break; + } + // fall-through + case 221 /* ImportEqualsDeclaration */: + ts.Debug.assert(importVariableName !== ""); + writeLine(); + // save import into the local + write(importVariableName + " = " + parameterName + ";"); + writeLine(); + break; + case 228 /* ExportDeclaration */: + ts.Debug.assert(importVariableName !== ""); + if (entry.exportClause) { + // export {a, b as c} from 'foo' + // emit as: + // exports_({ + // "a": _["a"], + // "c": _["b"] + // }); + writeLine(); + write(exportFunctionForFile + "({"); + writeLine(); + increaseIndent(); + for (var i_2 = 0, len = entry.exportClause.elements.length; i_2 < len; ++i_2) { + if (i_2 !== 0) { + write(","); + writeLine(); + } + var e = entry.exportClause.elements[i_2]; + write("\""); + emitNodeWithCommentsAndWithoutSourcemap(e.name); + write("\": " + parameterName + "[\""); + emitNodeWithCommentsAndWithoutSourcemap(e.propertyName || e.name); + write("\"]"); + } + decreaseIndent(); + writeLine(); + write("});"); + } + else { + writeLine(); + // export * from 'foo' + // emit as: + // exportStar(_foo); + write(exportStarFunction + "(" + parameterName + ");"); + } + writeLine(); + break; + } + } + decreaseIndent(); + write("}"); + decreaseIndent(); + } + write("],"); + } + function emitExecute(node, startIndex) { + write("execute: function() {"); + increaseIndent(); + writeLine(); + for (var i = startIndex; i < node.statements.length; ++i) { + var statement = node.statements[i]; + switch (statement.kind) { + // - function declarations are not emitted because they were already hoisted + // - import declarations are not emitted since they are already handled in setters + // - export declarations with module specifiers are not emitted since they were already written in setters + // - export declarations without module specifiers are emitted preserving the order + case 213 /* FunctionDeclaration */: + case 222 /* ImportDeclaration */: + continue; + case 228 /* ExportDeclaration */: + if (!statement.moduleSpecifier) { + for (var _a = 0, _b = statement.exportClause.elements; _a < _b.length; _a++) { + var element = _b[_a]; + // write call to exporter function for every export specifier in exports list + emitExportSpecifierInSystemModule(element); + } + } + continue; + case 221 /* ImportEqualsDeclaration */: + if (!ts.isInternalModuleImportEqualsDeclaration(statement)) { + // - import equals declarations that import external modules are not emitted + continue; + } + // fall-though for import declarations that import internal modules + default: + writeLine(); + emit(statement); + } + } + decreaseIndent(); + writeLine(); + write("}"); // execute + } + function emitSystemModule(node) { + collectExternalModuleInfo(node); + // System modules has the following shape + // System.register(['dep-1', ... 'dep-n'], function(exports) {/* module body function */}) + // 'exports' here is a function 'exports(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 'emitPostfixUnaryExpression' for more details + ts.Debug.assert(!exportFunctionForFile); + // make sure that name of 'exports' function does not conflict with existing identifiers + exportFunctionForFile = makeUniqueName("exports"); + writeLine(); + write("System.register("); + if (node.moduleName) { + write("\"" + node.moduleName + "\", "); + } + write("["); + var groupIndices = {}; + var dependencyGroups = []; + for (var i = 0; i < externalImports.length; ++i) { + var text = getExternalModuleNameText(externalImports[i]); + if (ts.hasProperty(groupIndices, text)) { + // deduplicate/group entries in dependency list by the dependency name + var groupIndex = groupIndices[text]; + dependencyGroups[groupIndex].push(externalImports[i]); + continue; + } + else { + groupIndices[text] = dependencyGroups.length; + dependencyGroups.push([externalImports[i]]); + } + if (i !== 0) { + write(", "); + } + write(text); + } + write("], function(" + exportFunctionForFile + ") {"); + writeLine(); + increaseIndent(); + var startIndex = emitDirectivePrologues(node.statements, /*startWithNewLine*/ true); + emitEmitHelpers(node); + emitCaptureThisForNodeIfNecessary(node); + emitSystemModuleBody(node, dependencyGroups, startIndex); + decreaseIndent(); + writeLine(); + write("});"); + } + function getAMDDependencyNames(node, includeNonAmdDependencies) { + // names of modules with corresponding parameter in the factory function + var aliasedModuleNames = []; + // names of modules with no corresponding parameters in factory function + var unaliasedModuleNames = []; + var importAliasNames = []; // names of the parameters in the factory function; these + // parameters need to match the indexes of the corresponding + // module names in aliasedModuleNames. + // Fill in amd-dependency tags + for (var _a = 0, _b = node.amdDependencies; _a < _b.length; _a++) { + var amdDependency = _b[_a]; + if (amdDependency.name) { + aliasedModuleNames.push("\"" + amdDependency.path + "\""); + importAliasNames.push(amdDependency.name); + } + else { + unaliasedModuleNames.push("\"" + amdDependency.path + "\""); + } + } + for (var _c = 0; _c < externalImports.length; _c++) { + var importNode = externalImports[_c]; + // Find the name of the external module + var externalModuleName = getExternalModuleNameText(importNode); + // Find the name of the module alias, if there is one + var importAliasName = getLocalNameForExternalImport(importNode); + if (includeNonAmdDependencies && importAliasName) { + aliasedModuleNames.push(externalModuleName); + importAliasNames.push(importAliasName); + } + else { + unaliasedModuleNames.push(externalModuleName); + } + } + return { aliasedModuleNames: aliasedModuleNames, unaliasedModuleNames: unaliasedModuleNames, importAliasNames: importAliasNames }; + } + function emitAMDDependencies(node, includeNonAmdDependencies) { + // An AMD define function has the following shape: + // define(id?, dependencies?, factory); + // + // This has the shape of + // define(name, ["module1", "module2"], function (module1Alias) { + // The location of the alias in the parameter list in the factory function needs to + // match the position of the module name in the dependency list. + // + // To ensure this is true in cases of modules with no aliases, e.g.: + // `import "module"` or `` + // we need to add modules without alias names to the end of the dependencies list + var dependencyNames = getAMDDependencyNames(node, includeNonAmdDependencies); + emitAMDDependencyList(dependencyNames); + write(", "); + emitAMDFactoryHeader(dependencyNames); + } + function emitAMDDependencyList(_a) { + var aliasedModuleNames = _a.aliasedModuleNames, unaliasedModuleNames = _a.unaliasedModuleNames; + write("[\"require\", \"exports\""); + if (aliasedModuleNames.length) { + write(", "); + write(aliasedModuleNames.join(", ")); + } + if (unaliasedModuleNames.length) { + write(", "); + write(unaliasedModuleNames.join(", ")); + } + write("]"); + } + function emitAMDFactoryHeader(_a) { + var importAliasNames = _a.importAliasNames; + write("function (require, exports"); + if (importAliasNames.length) { + write(", "); + write(importAliasNames.join(", ")); + } + write(") {"); + } + function emitAMDModule(node) { + emitEmitHelpers(node); + collectExternalModuleInfo(node); + writeLine(); + write("define("); + if (node.moduleName) { + write("\"" + node.moduleName + "\", "); + } + emitAMDDependencies(node, /*includeNonAmdDependencies*/ true); + increaseIndent(); + var startIndex = emitDirectivePrologues(node.statements, /*startWithNewLine*/ true); + emitExportStarHelper(); + emitCaptureThisForNodeIfNecessary(node); + emitLinesStartingAt(node.statements, startIndex); + emitTempDeclarations(/*newLine*/ true); + emitExportEquals(/*emitAsReturn*/ true); + decreaseIndent(); + writeLine(); + write("});"); + } + function emitCommonJSModule(node) { + var startIndex = emitDirectivePrologues(node.statements, /*startWithNewLine*/ false); + emitEmitHelpers(node); + collectExternalModuleInfo(node); + emitExportStarHelper(); + emitCaptureThisForNodeIfNecessary(node); + emitLinesStartingAt(node.statements, startIndex); + emitTempDeclarations(/*newLine*/ true); + emitExportEquals(/*emitAsReturn*/ false); + } + function emitUMDModule(node) { + emitEmitHelpers(node); + collectExternalModuleInfo(node); + var dependencyNames = getAMDDependencyNames(node, /*includeNonAmdDependencies*/ false); + // Module is detected first to support Browserify users that load into a browser with an AMD loader + writeLines("(function (factory) {\n if (typeof module === 'object' && typeof module.exports === 'object') {\n var v = factory(require, exports); if (v !== undefined) module.exports = v;\n }\n else if (typeof define === 'function' && define.amd) {\n define("); + emitAMDDependencyList(dependencyNames); + write(", factory);"); + writeLines(" }\n})("); + emitAMDFactoryHeader(dependencyNames); + increaseIndent(); + var startIndex = emitDirectivePrologues(node.statements, /*startWithNewLine*/ true); + emitExportStarHelper(); + emitCaptureThisForNodeIfNecessary(node); + emitLinesStartingAt(node.statements, startIndex); + emitTempDeclarations(/*newLine*/ true); + emitExportEquals(/*emitAsReturn*/ true); + decreaseIndent(); + writeLine(); + write("});"); + } + function emitES6Module(node) { + externalImports = undefined; + exportSpecifiers = undefined; + exportEquals = undefined; + hasExportStars = false; + var startIndex = emitDirectivePrologues(node.statements, /*startWithNewLine*/ false); + emitEmitHelpers(node); + emitCaptureThisForNodeIfNecessary(node); + emitLinesStartingAt(node.statements, startIndex); + emitTempDeclarations(/*newLine*/ true); + // Emit exportDefault if it exists will happen as part + // or normal statement emit. + } + function emitExportEquals(emitAsReturn) { + if (exportEquals && resolver.isValueAliasDeclaration(exportEquals)) { + writeLine(); + emitStart(exportEquals); + write(emitAsReturn ? "return " : "module.exports = "); + emit(exportEquals.expression); + write(";"); + emitEnd(exportEquals); + } + } + function emitJsxElement(node) { + switch (compilerOptions.jsx) { + case 2 /* React */: + jsxEmitReact(node); + break; + case 1 /* Preserve */: + // Fall back to preserve if None was specified (we'll error earlier) + default: + jsxEmitPreserve(node); + break; + } + } + function trimReactWhitespaceAndApplyEntities(node) { + var result = undefined; + var text = ts.getTextOfNode(node, /*includeTrivia*/ true); + var firstNonWhitespace = 0; + var lastNonWhitespace = -1; + // JSX trims whitespace at the end and beginning of lines, except that the + // start/end of a tag is considered a start/end of a line only if that line is + // on the same line as the closing tag. See examples in tests/cases/conformance/jsx/tsxReactEmitWhitespace.tsx + for (var i = 0; i < text.length; i++) { + var c = text.charCodeAt(i); + if (ts.isLineBreak(c)) { + if (firstNonWhitespace !== -1 && (lastNonWhitespace - firstNonWhitespace + 1 > 0)) { + var part = text.substr(firstNonWhitespace, lastNonWhitespace - firstNonWhitespace + 1); + result = (result ? result + "\" + ' ' + \"" : "") + ts.escapeString(part); + } + firstNonWhitespace = -1; + } + else if (!ts.isWhiteSpace(c)) { + lastNonWhitespace = i; + if (firstNonWhitespace === -1) { + firstNonWhitespace = i; + } + } + } + if (firstNonWhitespace !== -1) { + var part = text.substr(firstNonWhitespace); + result = (result ? result + "\" + ' ' + \"" : "") + ts.escapeString(part); + } + if (result) { + // Replace entities like   + result = result.replace(/&(\w+);/g, function (s, m) { + if (entities[m] !== undefined) { + return String.fromCharCode(entities[m]); + } + else { + return s; + } + }); + } + return result; + } + function getTextToEmit(node) { + switch (compilerOptions.jsx) { + case 2 /* React */: + var text = trimReactWhitespaceAndApplyEntities(node); + if (text === undefined || text.length === 0) { + return undefined; + } + else { + return text; + } + case 1 /* Preserve */: + default: + return ts.getTextOfNode(node, /*includeTrivia*/ true); + } + } + function emitJsxText(node) { + switch (compilerOptions.jsx) { + case 2 /* React */: + write("\""); + write(trimReactWhitespaceAndApplyEntities(node)); + write("\""); + break; + case 1 /* Preserve */: + default: + writer.writeLiteral(ts.getTextOfNode(node, /*includeTrivia*/ true)); + break; + } + } + function emitJsxExpression(node) { + if (node.expression) { + switch (compilerOptions.jsx) { + case 1 /* Preserve */: + default: + write("{"); + emit(node.expression); + write("}"); + break; + case 2 /* React */: + emit(node.expression); + break; + } + } + } + function emitDirectivePrologues(statements, startWithNewLine) { + for (var i = 0; i < statements.length; ++i) { + if (ts.isPrologueDirective(statements[i])) { + if (startWithNewLine || i > 0) { + writeLine(); + } + emit(statements[i]); + } + else { + // return index of the first non prologue directive + return i; + } + } + return statements.length; + } + function writeLines(text) { + var lines = text.split(/\r\n|\r|\n/g); + for (var i = 0; i < lines.length; ++i) { + var line = lines[i]; + if (line.length) { + writeLine(); + write(line); + } + } + } + function emitEmitHelpers(node) { + // Only emit helpers if the user did not say otherwise. + if (!compilerOptions.noEmitHelpers) { + // Only Emit __extends function when target ES5. + // For target ES6 and above, we can emit classDeclaration as is. + if ((languageVersion < 2 /* ES6 */) && (!extendsEmitted && resolver.getNodeCheckFlags(node) & 8 /* EmitExtends */)) { + writeLines(extendsHelper); + extendsEmitted = true; + } + if (!decorateEmitted && resolver.getNodeCheckFlags(node) & 16 /* EmitDecorate */) { + writeLines(decorateHelper); + if (compilerOptions.emitDecoratorMetadata) { + writeLines(metadataHelper); + } + decorateEmitted = true; + } + if (!paramEmitted && resolver.getNodeCheckFlags(node) & 32 /* EmitParam */) { + writeLines(paramHelper); + paramEmitted = true; + } + if (!awaiterEmitted && resolver.getNodeCheckFlags(node) & 64 /* EmitAwaiter */) { + writeLines(awaiterHelper); + awaiterEmitted = true; + } + } + } + function emitSourceFileNode(node) { + // Start new file on new line + writeLine(); + emitShebang(); + emitDetachedComments(node); + if (ts.isExternalModule(node) || compilerOptions.isolatedModules) { + var emitModule = moduleEmitDelegates[modulekind] || moduleEmitDelegates[1 /* CommonJS */]; + emitModule(node); + } + else { + // emit prologue directives prior to __extends + var startIndex = emitDirectivePrologues(node.statements, /*startWithNewLine*/ false); + externalImports = undefined; + exportSpecifiers = undefined; + exportEquals = undefined; + hasExportStars = false; + emitEmitHelpers(node); + emitCaptureThisForNodeIfNecessary(node); + emitLinesStartingAt(node.statements, startIndex); + emitTempDeclarations(/*newLine*/ true); + } + emitLeadingComments(node.endOfFileToken); + } + function emitNodeWithCommentsAndWithoutSourcemap(node) { + emitNodeConsideringCommentsOption(node, emitNodeWithoutSourceMap); + } + function emitNodeConsideringCommentsOption(node, emitNodeConsideringSourcemap) { + if (node) { + if (node.flags & 2 /* Ambient */) { + return emitCommentsOnNotEmittedNode(node); + } + if (isSpecializedCommentHandling(node)) { + // This is the node that will handle its own comments and sourcemap + return emitNodeWithoutSourceMap(node); + } + var emitComments_1 = shouldEmitLeadingAndTrailingComments(node); + if (emitComments_1) { + emitLeadingComments(node); + } + emitNodeConsideringSourcemap(node); + if (emitComments_1) { + emitTrailingComments(node); + } + } + } + function emitNodeWithoutSourceMap(node) { + if (node) { + emitJavaScriptWorker(node); + } + } + function isSpecializedCommentHandling(node) { + switch (node.kind) { + // All of these entities are emitted in a specialized fashion. As such, we allow + // the specialized methods for each to handle the comments on the nodes. + case 215 /* InterfaceDeclaration */: + case 213 /* FunctionDeclaration */: + case 222 /* ImportDeclaration */: + case 221 /* ImportEqualsDeclaration */: + case 216 /* TypeAliasDeclaration */: + case 227 /* ExportAssignment */: + return true; + } + } + function shouldEmitLeadingAndTrailingComments(node) { + switch (node.kind) { + case 193 /* VariableStatement */: + return shouldEmitLeadingAndTrailingCommentsForVariableStatement(node); + case 218 /* ModuleDeclaration */: + // Only emit the leading/trailing comments for a module if we're actually + // emitting the module as well. + return shouldEmitModuleDeclaration(node); + case 217 /* EnumDeclaration */: + // Only emit the leading/trailing comments for an enum if we're actually + // emitting the module as well. + return shouldEmitEnumDeclaration(node); + } + // If the node is emitted in specialized fashion, dont emit comments as this node will handle + // emitting comments when emitting itself + ts.Debug.assert(!isSpecializedCommentHandling(node)); + // If this is the expression body of an arrow function that we're down-leveling, + // then we don't want to emit comments when we emit the body. It will have already + // been taken care of when we emitted the 'return' statement for the function + // expression body. + if (node.kind !== 192 /* Block */ && + node.parent && + node.parent.kind === 174 /* ArrowFunction */ && + node.parent.body === node && + compilerOptions.target <= 1 /* ES5 */) { + return false; + } + // Emit comments for everything else. + return true; + } + function emitJavaScriptWorker(node) { + // Check if the node can be emitted regardless of the ScriptTarget + switch (node.kind) { + case 69 /* Identifier */: + return emitIdentifier(node); + case 138 /* Parameter */: + return emitParameter(node); + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: + return emitMethod(node); + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: + return emitAccessor(node); + case 97 /* ThisKeyword */: + return emitThis(node); + case 95 /* SuperKeyword */: + return emitSuper(node); + case 93 /* NullKeyword */: + return write("null"); + case 99 /* TrueKeyword */: + return write("true"); + case 84 /* FalseKeyword */: + return write("false"); + case 8 /* NumericLiteral */: + case 9 /* StringLiteral */: + case 10 /* RegularExpressionLiteral */: + case 11 /* NoSubstitutionTemplateLiteral */: + case 12 /* TemplateHead */: + case 13 /* TemplateMiddle */: + case 14 /* TemplateTail */: + return emitLiteral(node); + case 183 /* TemplateExpression */: + return emitTemplateExpression(node); + case 190 /* TemplateSpan */: + return emitTemplateSpan(node); + case 233 /* JsxElement */: + case 234 /* JsxSelfClosingElement */: + return emitJsxElement(node); + case 236 /* JsxText */: + return emitJsxText(node); + case 240 /* JsxExpression */: + return emitJsxExpression(node); + case 135 /* QualifiedName */: + return emitQualifiedName(node); + case 161 /* ObjectBindingPattern */: + return emitObjectBindingPattern(node); + case 162 /* ArrayBindingPattern */: + return emitArrayBindingPattern(node); + case 163 /* BindingElement */: + return emitBindingElement(node); + case 164 /* ArrayLiteralExpression */: + return emitArrayLiteral(node); + case 165 /* ObjectLiteralExpression */: + return emitObjectLiteral(node); + case 245 /* PropertyAssignment */: + return emitPropertyAssignment(node); + case 246 /* ShorthandPropertyAssignment */: + return emitShorthandPropertyAssignment(node); + case 136 /* ComputedPropertyName */: + return emitComputedPropertyName(node); + case 166 /* PropertyAccessExpression */: + return emitPropertyAccess(node); + case 167 /* ElementAccessExpression */: + return emitIndexedAccess(node); + case 168 /* CallExpression */: + return emitCallExpression(node); + case 169 /* NewExpression */: + return emitNewExpression(node); + case 170 /* TaggedTemplateExpression */: + return emitTaggedTemplateExpression(node); + case 171 /* TypeAssertionExpression */: + return emit(node.expression); + case 189 /* AsExpression */: + return emit(node.expression); + case 172 /* ParenthesizedExpression */: + return emitParenExpression(node); + case 213 /* FunctionDeclaration */: + case 173 /* FunctionExpression */: + case 174 /* ArrowFunction */: + return emitFunctionDeclaration(node); + case 175 /* DeleteExpression */: + return emitDeleteExpression(node); + case 176 /* TypeOfExpression */: + return emitTypeOfExpression(node); + case 177 /* VoidExpression */: + return emitVoidExpression(node); + case 178 /* AwaitExpression */: + return emitAwaitExpression(node); + case 179 /* PrefixUnaryExpression */: + return emitPrefixUnaryExpression(node); + case 180 /* PostfixUnaryExpression */: + return emitPostfixUnaryExpression(node); + case 181 /* BinaryExpression */: + return emitBinaryExpression(node); + case 182 /* ConditionalExpression */: + return emitConditionalExpression(node); + case 185 /* SpreadElementExpression */: + return emitSpreadElementExpression(node); + case 184 /* YieldExpression */: + return emitYieldExpression(node); + case 187 /* OmittedExpression */: + return; + case 192 /* Block */: + case 219 /* ModuleBlock */: + return emitBlock(node); + case 193 /* VariableStatement */: + return emitVariableStatement(node); + case 194 /* EmptyStatement */: + return write(";"); + case 195 /* ExpressionStatement */: + return emitExpressionStatement(node); + case 196 /* IfStatement */: + return emitIfStatement(node); + case 197 /* DoStatement */: + return emitDoStatement(node); + case 198 /* WhileStatement */: + return emitWhileStatement(node); + case 199 /* ForStatement */: + return emitForStatement(node); + case 201 /* ForOfStatement */: + case 200 /* ForInStatement */: + return emitForInOrForOfStatement(node); + case 202 /* ContinueStatement */: + case 203 /* BreakStatement */: + return emitBreakOrContinueStatement(node); + case 204 /* ReturnStatement */: + return emitReturnStatement(node); + case 205 /* WithStatement */: + return emitWithStatement(node); + case 206 /* SwitchStatement */: + return emitSwitchStatement(node); + case 241 /* CaseClause */: + case 242 /* DefaultClause */: + return emitCaseOrDefaultClause(node); + case 207 /* LabeledStatement */: + return emitLabeledStatement(node); + case 208 /* ThrowStatement */: + return emitThrowStatement(node); + case 209 /* TryStatement */: + return emitTryStatement(node); + case 244 /* CatchClause */: + return emitCatchClause(node); + case 210 /* DebuggerStatement */: + return emitDebuggerStatement(node); + case 211 /* VariableDeclaration */: + return emitVariableDeclaration(node); + case 186 /* ClassExpression */: + return emitClassExpression(node); + case 214 /* ClassDeclaration */: + return emitClassDeclaration(node); + case 215 /* InterfaceDeclaration */: + return emitInterfaceDeclaration(node); + case 217 /* EnumDeclaration */: + return emitEnumDeclaration(node); + case 247 /* EnumMember */: + return emitEnumMember(node); + case 218 /* ModuleDeclaration */: + return emitModuleDeclaration(node); + case 222 /* ImportDeclaration */: + return emitImportDeclaration(node); + case 221 /* ImportEqualsDeclaration */: + return emitImportEqualsDeclaration(node); + case 228 /* ExportDeclaration */: + return emitExportDeclaration(node); + case 227 /* ExportAssignment */: + return emitExportAssignment(node); + case 248 /* SourceFile */: + return emitSourceFileNode(node); + } + } + function hasDetachedComments(pos) { + return detachedCommentsInfo !== undefined && ts.lastOrUndefined(detachedCommentsInfo).nodePos === pos; + } + function getLeadingCommentsWithoutDetachedComments() { + // get the leading comments from detachedPos + var leadingComments = ts.getLeadingCommentRanges(currentSourceFile.text, ts.lastOrUndefined(detachedCommentsInfo).detachedCommentEndPos); + if (detachedCommentsInfo.length - 1) { + detachedCommentsInfo.pop(); + } + else { + detachedCommentsInfo = undefined; + } + return leadingComments; + } + function isPinnedComments(comment) { + return currentSourceFile.text.charCodeAt(comment.pos + 1) === 42 /* asterisk */ && + currentSourceFile.text.charCodeAt(comment.pos + 2) === 33 /* exclamation */; + } + /** + * Determine if the given comment is a triple-slash + * + * @return true if the comment is a triple-slash comment else false + **/ + function isTripleSlashComment(comment) { + // Verify this is /// comment, but do the regexp match only when we first can find /// in the comment text + // so that we don't end up computing comment string and doing match for all // comments + if (currentSourceFile.text.charCodeAt(comment.pos + 1) === 47 /* slash */ && + comment.pos + 2 < comment.end && + currentSourceFile.text.charCodeAt(comment.pos + 2) === 47 /* slash */) { + var textSubStr = currentSourceFile.text.substring(comment.pos, comment.end); + return textSubStr.match(ts.fullTripleSlashReferencePathRegEx) || + textSubStr.match(ts.fullTripleSlashAMDReferencePathRegEx) ? + true : false; + } + return false; + } + function getLeadingCommentsToEmit(node) { + // Emit the leading comments only if the parent's pos doesn't match because parent should take care of emitting these comments + if (node.parent) { + if (node.parent.kind === 248 /* SourceFile */ || node.pos !== node.parent.pos) { + if (hasDetachedComments(node.pos)) { + // get comments without detached comments + return getLeadingCommentsWithoutDetachedComments(); + } + else { + // get the leading comments from the node + return ts.getLeadingCommentRangesOfNode(node, currentSourceFile); + } + } + } + } + function getTrailingCommentsToEmit(node) { + // Emit the trailing comments only if the parent's pos doesn't match because parent should take care of emitting these comments + if (node.parent) { + if (node.parent.kind === 248 /* SourceFile */ || node.end !== node.parent.end) { + return ts.getTrailingCommentRanges(currentSourceFile.text, node.end); + } + } + } + /** + * Emit comments associated with node that will not be emitted into JS file + */ + function emitCommentsOnNotEmittedNode(node) { + emitLeadingCommentsWorker(node, /*isEmittedNode:*/ false); + } + function emitLeadingComments(node) { + return emitLeadingCommentsWorker(node, /*isEmittedNode:*/ true); + } + function emitLeadingCommentsWorker(node, isEmittedNode) { + if (compilerOptions.removeComments) { + return; + } + var leadingComments; + if (isEmittedNode) { + leadingComments = getLeadingCommentsToEmit(node); + } + else { + // If the node will not be emitted in JS, remove all the comments(normal, pinned and ///) associated with the node, + // unless it is a triple slash comment at the top of the file. + // For Example: + // /// + // declare var x; + // /// + // interface F {} + // The first /// will NOT be removed while the second one will be removed eventhough both node will not be emitted + if (node.pos === 0) { + leadingComments = ts.filter(getLeadingCommentsToEmit(node), isTripleSlashComment); + } + } + ts.emitNewLineBeforeLeadingComments(currentSourceFile, writer, node, leadingComments); + // Leading comments are emitted at /*leading comment1 */space/*leading comment*/space + ts.emitComments(currentSourceFile, writer, leadingComments, /*trailingSeparator:*/ true, newLine, writeComment); + } + function emitTrailingComments(node) { + if (compilerOptions.removeComments) { + return; + } + // Emit the trailing comments only if the parent's end doesn't match + var trailingComments = getTrailingCommentsToEmit(node); + // trailing comments are emitted at space/*trailing comment1 */space/*trailing comment*/ + ts.emitComments(currentSourceFile, writer, trailingComments, /*trailingSeparator*/ false, newLine, writeComment); + } + /** + * Emit trailing comments at the position. The term trailing comment is used here to describe following comment: + * x, /comment1/ y + * ^ => pos; the function will emit "comment1" in the emitJS + */ + function emitTrailingCommentsOfPosition(pos) { + if (compilerOptions.removeComments) { + return; + } + var trailingComments = ts.getTrailingCommentRanges(currentSourceFile.text, pos); + // trailing comments are emitted at space/*trailing comment1 */space/*trailing comment*/ + ts.emitComments(currentSourceFile, writer, trailingComments, /*trailingSeparator*/ true, newLine, writeComment); + } + function emitLeadingCommentsOfPositionWorker(pos) { + if (compilerOptions.removeComments) { + return; + } + var leadingComments; + if (hasDetachedComments(pos)) { + // get comments without detached comments + leadingComments = getLeadingCommentsWithoutDetachedComments(); + } + else { + // get the leading comments from the node + leadingComments = ts.getLeadingCommentRanges(currentSourceFile.text, pos); + } + ts.emitNewLineBeforeLeadingComments(currentSourceFile, writer, { pos: pos, end: pos }, leadingComments); + // Leading comments are emitted at /*leading comment1 */space/*leading comment*/space + ts.emitComments(currentSourceFile, writer, leadingComments, /*trailingSeparator*/ true, newLine, writeComment); + } + function emitDetachedComments(node) { + var leadingComments; + if (compilerOptions.removeComments) { + // removeComments is true, only reserve pinned comment at the top of file + // For example: + // /*! Pinned Comment */ + // + // var x = 10; + if (node.pos === 0) { + leadingComments = ts.filter(ts.getLeadingCommentRanges(currentSourceFile.text, node.pos), isPinnedComments); + } + } + else { + // removeComments is false, just get detached as normal and bypass the process to filter comment + leadingComments = ts.getLeadingCommentRanges(currentSourceFile.text, node.pos); + } + if (leadingComments) { + var detachedComments = []; + var lastComment; + ts.forEach(leadingComments, function (comment) { + if (lastComment) { + var lastCommentLine = ts.getLineOfLocalPosition(currentSourceFile, lastComment.end); + var commentLine = ts.getLineOfLocalPosition(currentSourceFile, comment.pos); + if (commentLine >= lastCommentLine + 2) { + // There was a blank line between the last comment and this comment. This + // comment is not part of the copyright comments. Return what we have so + // far. + return detachedComments; + } + } + detachedComments.push(comment); + lastComment = comment; + }); + if (detachedComments.length) { + // All comments look like they could have been part of the copyright header. Make + // sure there is at least one blank line between it and the node. If not, it's not + // a copyright header. + var lastCommentLine = ts.getLineOfLocalPosition(currentSourceFile, ts.lastOrUndefined(detachedComments).end); + var nodeLine = ts.getLineOfLocalPosition(currentSourceFile, ts.skipTrivia(currentSourceFile.text, node.pos)); + if (nodeLine >= lastCommentLine + 2) { + // Valid detachedComments + ts.emitNewLineBeforeLeadingComments(currentSourceFile, writer, node, leadingComments); + ts.emitComments(currentSourceFile, writer, detachedComments, /*trailingSeparator*/ true, newLine, writeComment); + var currentDetachedCommentInfo = { nodePos: node.pos, detachedCommentEndPos: ts.lastOrUndefined(detachedComments).end }; + if (detachedCommentsInfo) { + detachedCommentsInfo.push(currentDetachedCommentInfo); + } + else { + detachedCommentsInfo = [currentDetachedCommentInfo]; + } + } + } + } + } + function emitShebang() { + var shebang = ts.getShebang(currentSourceFile.text); + if (shebang) { + write(shebang); + } + } + var _a; + } + function emitFile(jsFilePath, sourceFile) { + emitJavaScript(jsFilePath, sourceFile); + if (compilerOptions.declaration) { + ts.writeDeclarationFile(jsFilePath, sourceFile, host, resolver, diagnostics); + } + } + } + ts.emitFiles = emitFiles; +})(ts || (ts = {})); +/// +/// +/// +var ts; +(function (ts) { + /* @internal */ ts.programTime = 0; + /* @internal */ ts.emitTime = 0; + /* @internal */ ts.ioReadTime = 0; + /* @internal */ ts.ioWriteTime = 0; + /** The version of the TypeScript compiler release */ + var emptyArray = []; + ts.version = "1.8.0"; + function findConfigFile(searchPath) { + var fileName = "tsconfig.json"; + while (true) { + if (ts.sys.fileExists(fileName)) { + return fileName; + } + var parentPath = ts.getDirectoryPath(searchPath); + if (parentPath === searchPath) { + break; + } + searchPath = parentPath; + fileName = "../" + fileName; + } + return undefined; + } + ts.findConfigFile = findConfigFile; + function resolveTripleslashReference(moduleName, containingFile) { + var basePath = ts.getDirectoryPath(containingFile); + var referencedFileName = ts.isRootedDiskPath(moduleName) ? moduleName : ts.combinePaths(basePath, moduleName); + return ts.normalizePath(referencedFileName); + } + ts.resolveTripleslashReference = resolveTripleslashReference; + function resolveModuleName(moduleName, containingFile, compilerOptions, host) { + var moduleResolution = compilerOptions.moduleResolution !== undefined + ? compilerOptions.moduleResolution + : compilerOptions.module === 1 /* CommonJS */ ? 2 /* NodeJs */ : 1 /* Classic */; + switch (moduleResolution) { + case 2 /* NodeJs */: return nodeModuleNameResolver(moduleName, containingFile, host); + case 1 /* Classic */: return classicNameResolver(moduleName, containingFile, compilerOptions, host); + } + } + ts.resolveModuleName = resolveModuleName; + function nodeModuleNameResolver(moduleName, containingFile, host) { + var containingDirectory = ts.getDirectoryPath(containingFile); + if (ts.getRootLength(moduleName) !== 0 || nameStartsWithDotSlashOrDotDotSlash(moduleName)) { + var failedLookupLocations = []; + var candidate = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName)); + var resolvedFileName = loadNodeModuleFromFile(candidate, failedLookupLocations, host); + if (resolvedFileName) { + return { resolvedModule: { resolvedFileName: resolvedFileName }, failedLookupLocations: failedLookupLocations }; + } + resolvedFileName = loadNodeModuleFromDirectory(candidate, failedLookupLocations, host); + return resolvedFileName + ? { resolvedModule: { resolvedFileName: resolvedFileName }, failedLookupLocations: failedLookupLocations } + : { resolvedModule: undefined, failedLookupLocations: failedLookupLocations }; + } + else { + return loadModuleFromNodeModules(moduleName, containingDirectory, host); + } + } + ts.nodeModuleNameResolver = nodeModuleNameResolver; + function loadNodeModuleFromFile(candidate, failedLookupLocation, host) { + return ts.forEach(ts.moduleFileExtensions, tryLoad); + function tryLoad(ext) { + var fileName = ts.fileExtensionIs(candidate, ext) ? candidate : candidate + ext; + if (host.fileExists(fileName)) { + return fileName; + } + else { + failedLookupLocation.push(fileName); + return undefined; + } + } + } + function loadNodeModuleFromDirectory(candidate, failedLookupLocation, host) { + var packageJsonPath = ts.combinePaths(candidate, "package.json"); + if (host.fileExists(packageJsonPath)) { + var jsonContent; + try { + var jsonText = host.readFile(packageJsonPath); + jsonContent = jsonText ? JSON.parse(jsonText) : { typings: undefined }; + } + catch (e) { + // gracefully handle if readFile fails or returns not JSON + jsonContent = { typings: undefined }; + } + if (jsonContent.typings) { + var result = loadNodeModuleFromFile(ts.normalizePath(ts.combinePaths(candidate, jsonContent.typings)), failedLookupLocation, host); + if (result) { + return result; + } + } + } + else { + // record package json as one of failed lookup locations - in the future if this file will appear it will invalidate resolution results + failedLookupLocation.push(packageJsonPath); + } + return loadNodeModuleFromFile(ts.combinePaths(candidate, "index"), failedLookupLocation, host); + } + function loadModuleFromNodeModules(moduleName, directory, host) { + var failedLookupLocations = []; + directory = ts.normalizeSlashes(directory); + while (true) { + var baseName = ts.getBaseFileName(directory); + if (baseName !== "node_modules") { + var nodeModulesFolder = ts.combinePaths(directory, "node_modules"); + var candidate = ts.normalizePath(ts.combinePaths(nodeModulesFolder, moduleName)); + var result = loadNodeModuleFromFile(candidate, failedLookupLocations, host); + if (result) { + return { resolvedModule: { resolvedFileName: result, isExternalLibraryImport: true }, failedLookupLocations: failedLookupLocations }; + } + result = loadNodeModuleFromDirectory(candidate, failedLookupLocations, host); + if (result) { + return { resolvedModule: { resolvedFileName: result, isExternalLibraryImport: true }, failedLookupLocations: failedLookupLocations }; + } + } + var parentPath = ts.getDirectoryPath(directory); + if (parentPath === directory) { + break; + } + directory = parentPath; + } + return { resolvedModule: undefined, failedLookupLocations: failedLookupLocations }; + } + function nameStartsWithDotSlashOrDotDotSlash(name) { + var i = name.lastIndexOf("./", 1); + return i === 0 || (i === 1 && name.charCodeAt(0) === 46 /* dot */); + } + function classicNameResolver(moduleName, containingFile, compilerOptions, host) { + // module names that contain '!' are used to reference resources and are not resolved to actual files on disk + if (moduleName.indexOf("!") != -1) { + return { resolvedModule: undefined, failedLookupLocations: [] }; + } + var searchPath = ts.getDirectoryPath(containingFile); + var searchName; + var failedLookupLocations = []; + var referencedSourceFile; + while (true) { + searchName = ts.normalizePath(ts.combinePaths(searchPath, moduleName)); + referencedSourceFile = ts.forEach(ts.supportedExtensions, function (extension) { + if (extension === ".tsx" && !compilerOptions.jsx) { + // resolve .tsx files only if jsx support is enabled + // 'logical not' handles both undefined and None cases + return undefined; + } + var candidate = searchName + extension; + if (host.fileExists(candidate)) { + return candidate; + } + else { + failedLookupLocations.push(candidate); + } + }); + if (referencedSourceFile) { + break; + } + var parentPath = ts.getDirectoryPath(searchPath); + if (parentPath === searchPath) { + break; + } + searchPath = parentPath; + } + return referencedSourceFile + ? { resolvedModule: { resolvedFileName: referencedSourceFile }, failedLookupLocations: failedLookupLocations } + : { resolvedModule: undefined, failedLookupLocations: failedLookupLocations }; + } + ts.classicNameResolver = classicNameResolver; + /* @internal */ + ts.defaultInitCompilerOptions = { + module: 1 /* CommonJS */, + target: 0 /* ES3 */, + noImplicitAny: false, + outDir: "built", + rootDir: ".", + sourceMap: false + }; + function createCompilerHost(options, setParentNodes) { + var existingDirectories = {}; + function getCanonicalFileName(fileName) { + // if underlying system can distinguish between two files whose names differs only in cases then file name already in canonical form. + // otherwise use toLowerCase as a canonical form. + return ts.sys.useCaseSensitiveFileNames ? fileName : fileName.toLowerCase(); + } + // returned by CScript sys environment + var unsupportedFileEncodingErrorCode = -2147024809; + function getSourceFile(fileName, languageVersion, onError) { + var text; + try { + var start = new Date().getTime(); + text = ts.sys.readFile(fileName, options.charset); + ts.ioReadTime += new Date().getTime() - start; + } + catch (e) { + if (onError) { + onError(e.number === unsupportedFileEncodingErrorCode + ? ts.createCompilerDiagnostic(ts.Diagnostics.Unsupported_file_encoding).messageText + : e.message); + } + text = ""; + } + return text !== undefined ? ts.createSourceFile(fileName, text, languageVersion, setParentNodes) : undefined; + } + function directoryExists(directoryPath) { + if (ts.hasProperty(existingDirectories, directoryPath)) { + return true; + } + if (ts.sys.directoryExists(directoryPath)) { + existingDirectories[directoryPath] = true; + return true; + } + return false; + } + function ensureDirectoriesExist(directoryPath) { + if (directoryPath.length > ts.getRootLength(directoryPath) && !directoryExists(directoryPath)) { + var parentDirectory = ts.getDirectoryPath(directoryPath); + ensureDirectoriesExist(parentDirectory); + ts.sys.createDirectory(directoryPath); + } + } + function writeFile(fileName, data, writeByteOrderMark, onError) { + try { + var start = new Date().getTime(); + ensureDirectoriesExist(ts.getDirectoryPath(ts.normalizePath(fileName))); + ts.sys.writeFile(fileName, data, writeByteOrderMark); + ts.ioWriteTime += new Date().getTime() - start; + } + catch (e) { + if (onError) { + onError(e.message); + } + } + } + var newLine = ts.getNewLineCharacter(options); + return { + getSourceFile: getSourceFile, + getDefaultLibFileName: function (options) { return ts.combinePaths(ts.getDirectoryPath(ts.normalizePath(ts.sys.getExecutingFilePath())), ts.getDefaultLibFileName(options)); }, + writeFile: writeFile, + getCurrentDirectory: ts.memoize(function () { return ts.sys.getCurrentDirectory(); }), + useCaseSensitiveFileNames: function () { return ts.sys.useCaseSensitiveFileNames; }, + getCanonicalFileName: getCanonicalFileName, + getNewLine: function () { return newLine; }, + fileExists: function (fileName) { return ts.sys.fileExists(fileName); }, + readFile: function (fileName) { return ts.sys.readFile(fileName); } + }; + } + ts.createCompilerHost = createCompilerHost; + function getPreEmitDiagnostics(program, sourceFile, cancellationToken) { + var diagnostics = program.getOptionsDiagnostics(cancellationToken).concat(program.getSyntacticDiagnostics(sourceFile, cancellationToken), program.getGlobalDiagnostics(cancellationToken), program.getSemanticDiagnostics(sourceFile, cancellationToken)); + if (program.getCompilerOptions().declaration) { + diagnostics.concat(program.getDeclarationDiagnostics(sourceFile, cancellationToken)); + } + return ts.sortAndDeduplicateDiagnostics(diagnostics); + } + ts.getPreEmitDiagnostics = getPreEmitDiagnostics; + function flattenDiagnosticMessageText(messageText, newLine) { + if (typeof messageText === "string") { + return messageText; + } + else { + var diagnosticChain = messageText; + var result = ""; + var indent = 0; + while (diagnosticChain) { + if (indent) { + result += newLine; + for (var i = 0; i < indent; i++) { + result += " "; + } + } + result += diagnosticChain.messageText; + indent++; + diagnosticChain = diagnosticChain.next; + } + return result; + } + } + ts.flattenDiagnosticMessageText = flattenDiagnosticMessageText; + function createProgram(rootNames, options, host, oldProgram) { + var program; + var files = []; + var fileProcessingDiagnostics = ts.createDiagnosticCollection(); + var programDiagnostics = ts.createDiagnosticCollection(); + var commonSourceDirectory; + var diagnosticsProducingTypeChecker; + var noDiagnosticsTypeChecker; + var classifiableNames; + var skipDefaultLib = options.noLib; + var start = new Date().getTime(); + host = host || createCompilerHost(options); + var currentDirectory = host.getCurrentDirectory(); + var resolveModuleNamesWorker = host.resolveModuleNames + ? (function (moduleNames, containingFile) { return host.resolveModuleNames(moduleNames, containingFile); }) + : (function (moduleNames, containingFile) { return ts.map(moduleNames, function (moduleName) { return resolveModuleName(moduleName, containingFile, options, host).resolvedModule; }); }); + var filesByName = ts.createFileMap(getCanonicalFileName); + // stores 'filename -> file association' ignoring case + // used to track cases when two file names differ only in casing + var filesByNameIgnoreCase = host.useCaseSensitiveFileNames() ? ts.createFileMap(function (fileName) { return fileName.toLowerCase(); }) : undefined; + if (oldProgram) { + // check properties that can affect structure of the program or module resolution strategy + // if any of these properties has changed - structure cannot be reused + var oldOptions = oldProgram.getCompilerOptions(); + if ((oldOptions.module !== options.module) || + (oldOptions.noResolve !== options.noResolve) || + (oldOptions.target !== options.target) || + (oldOptions.noLib !== options.noLib) || + (oldOptions.jsx !== options.jsx)) { + oldProgram = undefined; + } + } + if (!tryReuseStructureFromOldProgram()) { + ts.forEach(rootNames, function (name) { return processRootFile(name, false); }); + // Do not process the default library if: + // - The '--noLib' flag is used. + // - A 'no-default-lib' reference comment is encountered in + // processing the root files. + if (!skipDefaultLib) { + processRootFile(host.getDefaultLibFileName(options), true); + } + } + verifyCompilerOptions(); + // unconditionally set oldProgram to undefined to prevent it from being captured in closure + oldProgram = undefined; + ts.programTime += new Date().getTime() - start; + program = { + getRootFileNames: function () { return rootNames; }, + getSourceFile: getSourceFile, + getSourceFiles: function () { return files; }, + getCompilerOptions: function () { return options; }, + getSyntacticDiagnostics: getSyntacticDiagnostics, + getOptionsDiagnostics: getOptionsDiagnostics, + getGlobalDiagnostics: getGlobalDiagnostics, + getSemanticDiagnostics: getSemanticDiagnostics, + getDeclarationDiagnostics: getDeclarationDiagnostics, + getTypeChecker: getTypeChecker, + getClassifiableNames: getClassifiableNames, + getDiagnosticsProducingTypeChecker: getDiagnosticsProducingTypeChecker, + getCommonSourceDirectory: function () { return commonSourceDirectory; }, + emit: emit, + getCurrentDirectory: function () { return currentDirectory; }, + getNodeCount: function () { return getDiagnosticsProducingTypeChecker().getNodeCount(); }, + getIdentifierCount: function () { return getDiagnosticsProducingTypeChecker().getIdentifierCount(); }, + getSymbolCount: function () { return getDiagnosticsProducingTypeChecker().getSymbolCount(); }, + getTypeCount: function () { return getDiagnosticsProducingTypeChecker().getTypeCount(); }, + getFileProcessingDiagnostics: function () { return fileProcessingDiagnostics; } + }; + return program; + function getClassifiableNames() { + if (!classifiableNames) { + // Initialize a checker so that all our files are bound. + getTypeChecker(); + classifiableNames = {}; + for (var _i = 0; _i < files.length; _i++) { + var sourceFile = files[_i]; + ts.copyMap(sourceFile.classifiableNames, classifiableNames); + } + } + return classifiableNames; + } + function tryReuseStructureFromOldProgram() { + if (!oldProgram) { + return false; + } + ts.Debug.assert(!oldProgram.structureIsReused); + // there is an old program, check if we can reuse its structure + var oldRootNames = oldProgram.getRootFileNames(); + if (!ts.arrayIsEqualTo(oldRootNames, rootNames)) { + return false; + } + // check if program source files has changed in the way that can affect structure of the program + var newSourceFiles = []; + var normalizedAbsoluteFileNames = []; + var modifiedSourceFiles = []; + for (var _i = 0, _a = oldProgram.getSourceFiles(); _i < _a.length; _i++) { + var oldSourceFile = _a[_i]; + var newSourceFile = host.getSourceFile(oldSourceFile.fileName, options.target); + if (!newSourceFile) { + return false; + } + var normalizedAbsolutePath = ts.getNormalizedAbsolutePath(newSourceFile.fileName, currentDirectory); + normalizedAbsoluteFileNames.push(normalizedAbsolutePath); + if (oldSourceFile !== newSourceFile) { + if (oldSourceFile.hasNoDefaultLib !== newSourceFile.hasNoDefaultLib) { + // value of no-default-lib has changed + // this will affect if default library is injected into the list of files + return false; + } + // check tripleslash references + if (!ts.arrayIsEqualTo(oldSourceFile.referencedFiles, newSourceFile.referencedFiles, fileReferenceIsEqualTo)) { + // tripleslash references has changed + return false; + } + // check imports + collectExternalModuleReferences(newSourceFile); + if (!ts.arrayIsEqualTo(oldSourceFile.imports, newSourceFile.imports, moduleNameIsEqualTo)) { + // imports has changed + return false; + } + if (resolveModuleNamesWorker) { + var moduleNames = ts.map(newSourceFile.imports, function (name) { return name.text; }); + var resolutions = resolveModuleNamesWorker(moduleNames, normalizedAbsolutePath); + // ensure that module resolution results are still correct + for (var i = 0; i < moduleNames.length; ++i) { + var newResolution = resolutions[i]; + var oldResolution = ts.getResolvedModule(oldSourceFile, moduleNames[i]); + var resolutionChanged = oldResolution + ? !newResolution || + oldResolution.resolvedFileName !== newResolution.resolvedFileName || + !!oldResolution.isExternalLibraryImport !== !!newResolution.isExternalLibraryImport + : newResolution; + if (resolutionChanged) { + return false; + } + } + } + // pass the cache of module resolutions from the old source file + newSourceFile.resolvedModules = oldSourceFile.resolvedModules; + modifiedSourceFiles.push(newSourceFile); + } + else { + // file has no changes - use it as is + newSourceFile = oldSourceFile; + } + // if file has passed all checks it should be safe to reuse it + newSourceFiles.push(newSourceFile); + } + // update fileName -> file mapping + for (var i = 0, len = newSourceFiles.length; i < len; ++i) { + filesByName.set(normalizedAbsoluteFileNames[i], newSourceFiles[i]); + } + files = newSourceFiles; + fileProcessingDiagnostics = oldProgram.getFileProcessingDiagnostics(); + for (var _b = 0; _b < modifiedSourceFiles.length; _b++) { + var modifiedFile = modifiedSourceFiles[_b]; + fileProcessingDiagnostics.reattachFileDiagnostics(modifiedFile); + } + oldProgram.structureIsReused = true; + return true; + } + function getEmitHost(writeFileCallback) { + return { + getCanonicalFileName: getCanonicalFileName, + getCommonSourceDirectory: program.getCommonSourceDirectory, + getCompilerOptions: program.getCompilerOptions, + getCurrentDirectory: function () { return currentDirectory; }, + getNewLine: function () { return host.getNewLine(); }, + getSourceFile: program.getSourceFile, + getSourceFiles: program.getSourceFiles, + writeFile: writeFileCallback || (function (fileName, data, writeByteOrderMark, onError) { return host.writeFile(fileName, data, writeByteOrderMark, onError); }) + }; + } + function getDiagnosticsProducingTypeChecker() { + return diagnosticsProducingTypeChecker || (diagnosticsProducingTypeChecker = ts.createTypeChecker(program, /*produceDiagnostics:*/ true)); + } + function getTypeChecker() { + return noDiagnosticsTypeChecker || (noDiagnosticsTypeChecker = ts.createTypeChecker(program, /*produceDiagnostics:*/ false)); + } + function emit(sourceFile, writeFileCallback, cancellationToken) { + var _this = this; + return runWithCancellationToken(function () { return emitWorker(_this, sourceFile, writeFileCallback, cancellationToken); }); + } + function emitWorker(program, sourceFile, writeFileCallback, cancellationToken) { + // If the noEmitOnError flag is set, then check if we have any errors so far. If so, + // immediately bail out. Note that we pass 'undefined' for 'sourceFile' so that we + // get any preEmit diagnostics, not just the ones + if (options.noEmitOnError && getPreEmitDiagnostics(program, /*sourceFile:*/ undefined, cancellationToken).length > 0) { + return { diagnostics: [], sourceMaps: undefined, emitSkipped: true }; + } + // Create the emit resolver outside of the "emitTime" tracking code below. That way + // any cost associated with it (like type checking) are appropriate associated with + // the type-checking counter. + // + // If the -out option is specified, we should not pass the source file to getEmitResolver. + // This is because in the -out scenario all files need to be emitted, and therefore all + // files need to be type checked. And the way to specify that all files need to be type + // checked is to not pass the file to getEmitResolver. + var emitResolver = getDiagnosticsProducingTypeChecker().getEmitResolver((options.outFile || options.out) ? undefined : sourceFile); + var start = new Date().getTime(); + var emitResult = ts.emitFiles(emitResolver, getEmitHost(writeFileCallback), sourceFile); + ts.emitTime += new Date().getTime() - start; + return emitResult; + } + function getSourceFile(fileName) { + return filesByName.get(ts.getNormalizedAbsolutePath(fileName, currentDirectory)); + } + function getDiagnosticsHelper(sourceFile, getDiagnostics, cancellationToken) { + if (sourceFile) { + return getDiagnostics(sourceFile, cancellationToken); + } + var allDiagnostics = []; + ts.forEach(program.getSourceFiles(), function (sourceFile) { + if (cancellationToken) { + cancellationToken.throwIfCancellationRequested(); + } + ts.addRange(allDiagnostics, getDiagnostics(sourceFile, cancellationToken)); + }); + return ts.sortAndDeduplicateDiagnostics(allDiagnostics); + } + function getSyntacticDiagnostics(sourceFile, cancellationToken) { + return getDiagnosticsHelper(sourceFile, getSyntacticDiagnosticsForFile, cancellationToken); + } + function getSemanticDiagnostics(sourceFile, cancellationToken) { + return getDiagnosticsHelper(sourceFile, getSemanticDiagnosticsForFile, cancellationToken); + } + function getDeclarationDiagnostics(sourceFile, cancellationToken) { + return getDiagnosticsHelper(sourceFile, getDeclarationDiagnosticsForFile, cancellationToken); + } + function getSyntacticDiagnosticsForFile(sourceFile, cancellationToken) { + return sourceFile.parseDiagnostics; + } + function runWithCancellationToken(func) { + try { + return func(); + } + catch (e) { + if (e instanceof ts.OperationCanceledException) { + // We were canceled while performing the operation. Because our type checker + // might be a bad state, we need to throw it away. + // + // Note: we are overly agressive here. We do not actually *have* to throw away + // the "noDiagnosticsTypeChecker". However, for simplicity, i'd like to keep + // the lifetimes of these two TypeCheckers the same. Also, we generally only + // cancel when the user has made a change anyways. And, in that case, we (the + // program instance) will get thrown away anyways. So trying to keep one of + // these type checkers alive doesn't serve much purpose. + noDiagnosticsTypeChecker = undefined; + diagnosticsProducingTypeChecker = undefined; + } + throw e; + } + } + function getSemanticDiagnosticsForFile(sourceFile, cancellationToken) { + return runWithCancellationToken(function () { + var typeChecker = getDiagnosticsProducingTypeChecker(); + ts.Debug.assert(!!sourceFile.bindDiagnostics); + var bindDiagnostics = sourceFile.bindDiagnostics; + var checkDiagnostics = typeChecker.getDiagnostics(sourceFile, cancellationToken); + var fileProcessingDiagnosticsInFile = fileProcessingDiagnostics.getDiagnostics(sourceFile.fileName); + var programDiagnosticsInFile = programDiagnostics.getDiagnostics(sourceFile.fileName); + return bindDiagnostics.concat(checkDiagnostics).concat(fileProcessingDiagnosticsInFile).concat(programDiagnosticsInFile); + }); + } + function getDeclarationDiagnosticsForFile(sourceFile, cancellationToken) { + return runWithCancellationToken(function () { + if (!ts.isDeclarationFile(sourceFile)) { + var resolver = getDiagnosticsProducingTypeChecker().getEmitResolver(sourceFile, cancellationToken); + // Don't actually write any files since we're just getting diagnostics. + var writeFile_1 = function () { }; + return ts.getDeclarationDiagnostics(getEmitHost(writeFile_1), resolver, sourceFile); + } + }); + } + function getOptionsDiagnostics() { + var allDiagnostics = []; + ts.addRange(allDiagnostics, fileProcessingDiagnostics.getGlobalDiagnostics()); + ts.addRange(allDiagnostics, programDiagnostics.getGlobalDiagnostics()); + return ts.sortAndDeduplicateDiagnostics(allDiagnostics); + } + function getGlobalDiagnostics() { + var allDiagnostics = []; + ts.addRange(allDiagnostics, getDiagnosticsProducingTypeChecker().getGlobalDiagnostics()); + return ts.sortAndDeduplicateDiagnostics(allDiagnostics); + } + function hasExtension(fileName) { + return ts.getBaseFileName(fileName).indexOf(".") >= 0; + } + function processRootFile(fileName, isDefaultLib) { + processSourceFile(ts.normalizePath(fileName), isDefaultLib); + } + function fileReferenceIsEqualTo(a, b) { + return a.fileName === b.fileName; + } + function moduleNameIsEqualTo(a, b) { + return a.text === b.text; + } + function collectExternalModuleReferences(file) { + if (file.imports) { + return; + } + var imports; + for (var _i = 0, _a = file.statements; _i < _a.length; _i++) { + var node = _a[_i]; + collect(node, /* allowRelativeModuleNames */ true); + } + file.imports = imports || emptyArray; + function collect(node, allowRelativeModuleNames) { + switch (node.kind) { + case 222 /* ImportDeclaration */: + case 221 /* ImportEqualsDeclaration */: + case 228 /* ExportDeclaration */: + var moduleNameExpr = ts.getExternalModuleName(node); + if (!moduleNameExpr || moduleNameExpr.kind !== 9 /* StringLiteral */) { + break; + } + if (!moduleNameExpr.text) { + break; + } + if (allowRelativeModuleNames || !ts.isExternalModuleNameRelative(moduleNameExpr.text)) { + (imports || (imports = [])).push(moduleNameExpr); + } + break; + case 218 /* ModuleDeclaration */: + if (node.name.kind === 9 /* StringLiteral */ && (node.flags & 2 /* Ambient */ || ts.isDeclarationFile(file))) { + // TypeScript 1.0 spec (April 2014): 12.1.6 + // An AmbientExternalModuleDeclaration declares an external module. + // This type of declaration is permitted only in the global module. + // The StringLiteral must specify a top - level external module name. + // Relative external module names are not permitted + ts.forEachChild(node.body, function (node) { + // TypeScript 1.0 spec (April 2014): 12.1.6 + // An ExternalImportDeclaration in anAmbientExternalModuleDeclaration may reference other external modules + // only through top - level external module names. Relative external module names are not permitted. + collect(node, /* allowRelativeModuleNames */ false); + }); + } + break; + } + } + } + function processSourceFile(fileName, isDefaultLib, refFile, refPos, refEnd) { + var diagnosticArgument; + var diagnostic; + if (hasExtension(fileName)) { + if (!options.allowNonTsExtensions && !ts.forEach(ts.supportedExtensions, function (extension) { return ts.fileExtensionIs(host.getCanonicalFileName(fileName), extension); })) { + diagnostic = ts.Diagnostics.File_0_has_unsupported_extension_The_only_supported_extensions_are_1; + diagnosticArgument = [fileName, "'" + ts.supportedExtensions.join("', '") + "'"]; + } + else if (!findSourceFile(fileName, ts.getNormalizedAbsolutePath(fileName, currentDirectory), isDefaultLib, refFile, refPos, refEnd)) { + diagnostic = ts.Diagnostics.File_0_not_found; + diagnosticArgument = [fileName]; + } + else if (refFile && host.getCanonicalFileName(fileName) === host.getCanonicalFileName(refFile.fileName)) { + diagnostic = ts.Diagnostics.A_file_cannot_have_a_reference_to_itself; + diagnosticArgument = [fileName]; + } + } + else { + var nonTsFile = options.allowNonTsExtensions && findSourceFile(fileName, ts.getNormalizedAbsolutePath(fileName, currentDirectory), isDefaultLib, refFile, refPos, refEnd); + if (!nonTsFile) { + if (options.allowNonTsExtensions) { + diagnostic = ts.Diagnostics.File_0_not_found; + diagnosticArgument = [fileName]; + } + else if (!ts.forEach(ts.supportedExtensions, function (extension) { return findSourceFile(fileName + extension, ts.getNormalizedAbsolutePath(fileName + extension, currentDirectory), isDefaultLib, refFile, refPos, refEnd); })) { + diagnostic = ts.Diagnostics.File_0_not_found; + fileName += ".ts"; + diagnosticArgument = [fileName]; + } + } + } + if (diagnostic) { + if (refFile !== undefined && refEnd !== undefined && refPos !== undefined) { + fileProcessingDiagnostics.add(ts.createFileDiagnostic.apply(void 0, [refFile, refPos, refEnd - refPos, diagnostic].concat(diagnosticArgument))); + } + else { + fileProcessingDiagnostics.add(ts.createCompilerDiagnostic.apply(void 0, [diagnostic].concat(diagnosticArgument))); + } + } + } + function reportFileNamesDifferOnlyInCasingError(fileName, existingFileName, refFile, refPos, refEnd) { + if (refFile !== undefined && refPos !== undefined && refEnd !== undefined) { + fileProcessingDiagnostics.add(ts.createFileDiagnostic(refFile, refPos, refEnd - refPos, ts.Diagnostics.File_name_0_differs_from_already_included_file_name_1_only_in_casing, fileName, existingFileName)); + } + else { + fileProcessingDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.File_name_0_differs_from_already_included_file_name_1_only_in_casing, fileName, existingFileName)); + } + } + // Get source file from normalized fileName + function findSourceFile(fileName, normalizedAbsolutePath, isDefaultLib, refFile, refPos, refEnd) { + if (filesByName.contains(normalizedAbsolutePath)) { + var file_1 = filesByName.get(normalizedAbsolutePath); + // try to check if we've already seen this file but with a different casing in path + // NOTE: this only makes sense for case-insensitive file systems + if (file_1 && options.forceConsistentCasingInFileNames && ts.getNormalizedAbsolutePath(file_1.fileName, currentDirectory) !== normalizedAbsolutePath) { + reportFileNamesDifferOnlyInCasingError(fileName, file_1.fileName, refFile, refPos, refEnd); + } + return file_1; + } + // We haven't looked for this file, do so now and cache result + var file = host.getSourceFile(fileName, options.target, function (hostErrorMessage) { + if (refFile !== undefined && refPos !== undefined && refEnd !== undefined) { + fileProcessingDiagnostics.add(ts.createFileDiagnostic(refFile, refPos, refEnd - refPos, ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage)); + } + else { + fileProcessingDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage)); + } + }); + filesByName.set(normalizedAbsolutePath, file); + if (file) { + if (host.useCaseSensitiveFileNames()) { + // for case-sensitive file systems check if we've already seen some file with similar filename ignoring case + var existingFile = filesByNameIgnoreCase.get(normalizedAbsolutePath); + if (existingFile) { + reportFileNamesDifferOnlyInCasingError(fileName, existingFile.fileName, refFile, refPos, refEnd); + } + else { + filesByNameIgnoreCase.set(normalizedAbsolutePath, file); + } + } + skipDefaultLib = skipDefaultLib || file.hasNoDefaultLib; + var basePath = ts.getDirectoryPath(fileName); + if (!options.noResolve) { + processReferencedFiles(file, basePath); + } + // always process imported modules to record module name resolutions + processImportedModules(file, basePath); + if (isDefaultLib) { + file.isDefaultLib = true; + files.unshift(file); + } + else { + files.push(file); + } + } + return file; + } + function processReferencedFiles(file, basePath) { + ts.forEach(file.referencedFiles, function (ref) { + var referencedFileName = resolveTripleslashReference(ref.fileName, file.fileName); + processSourceFile(referencedFileName, /* isDefaultLib */ false, file, ref.pos, ref.end); + }); + } + function getCanonicalFileName(fileName) { + return host.getCanonicalFileName(fileName); + } + function processImportedModules(file, basePath) { + collectExternalModuleReferences(file); + if (file.imports.length) { + file.resolvedModules = {}; + var moduleNames = ts.map(file.imports, function (name) { return name.text; }); + var resolutions = resolveModuleNamesWorker(moduleNames, ts.getNormalizedAbsolutePath(file.fileName, currentDirectory)); + for (var i = 0; i < file.imports.length; ++i) { + var resolution = resolutions[i]; + ts.setResolvedModule(file, moduleNames[i], resolution); + if (resolution && !options.noResolve) { + var absoluteImportPath = ts.isRootedDiskPath(resolution.resolvedFileName) + ? resolution.resolvedFileName + : ts.getNormalizedAbsolutePath(resolution.resolvedFileName, currentDirectory); + // convert an absolute import path to path that is relative to current directory + // this was host still can locate it but files names in user output will be shorter (and thus look nicer). + var relativePath = ts.getRelativePathToDirectoryOrUrl(currentDirectory, absoluteImportPath, currentDirectory, getCanonicalFileName, false); + var importedFile = findSourceFile(relativePath, absoluteImportPath, /* isDefaultLib */ false, file, ts.skipTrivia(file.text, file.imports[i].pos), file.imports[i].end); + if (importedFile && resolution.isExternalLibraryImport) { + if (!ts.isExternalModule(importedFile)) { + var start_2 = ts.getTokenPosOfNode(file.imports[i], file); + fileProcessingDiagnostics.add(ts.createFileDiagnostic(file, start_2, file.imports[i].end - start_2, ts.Diagnostics.Exported_external_package_typings_file_0_is_not_a_module_Please_contact_the_package_author_to_update_the_package_definition, importedFile.fileName)); + } + else if (importedFile.referencedFiles.length) { + var firstRef = importedFile.referencedFiles[0]; + fileProcessingDiagnostics.add(ts.createFileDiagnostic(importedFile, firstRef.pos, firstRef.end - firstRef.pos, ts.Diagnostics.Exported_external_package_typings_file_cannot_contain_tripleslash_references_Please_contact_the_package_author_to_update_the_package_definition)); + } + } + } + } + } + else { + // no imports - drop cached module resolutions + file.resolvedModules = undefined; + } + return; + } + function computeCommonSourceDirectory(sourceFiles) { + var commonPathComponents; + ts.forEach(files, function (sourceFile) { + // Each file contributes into common source file path + if (ts.isDeclarationFile(sourceFile)) { + return; + } + var sourcePathComponents = ts.getNormalizedPathComponents(sourceFile.fileName, currentDirectory); + sourcePathComponents.pop(); // The base file name is not part of the common directory path + if (!commonPathComponents) { + // first file + commonPathComponents = sourcePathComponents; + return; + } + for (var i = 0, n = Math.min(commonPathComponents.length, sourcePathComponents.length); i < n; i++) { + if (commonPathComponents[i] !== sourcePathComponents[i]) { + if (i === 0) { + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_find_the_common_subdirectory_path_for_the_input_files)); + return; + } + // New common path found that is 0 -> i-1 + commonPathComponents.length = i; + break; + } + } + // If the sourcePathComponents was shorter than the commonPathComponents, truncate to the sourcePathComponents + if (sourcePathComponents.length < commonPathComponents.length) { + commonPathComponents.length = sourcePathComponents.length; + } + }); + return ts.getNormalizedPathFromPathComponents(commonPathComponents); + } + function checkSourceFilesBelongToPath(sourceFiles, rootDirectory) { + var allFilesBelongToPath = true; + if (sourceFiles) { + var absoluteRootDirectoryPath = host.getCanonicalFileName(ts.getNormalizedAbsolutePath(rootDirectory, currentDirectory)); + for (var _i = 0; _i < sourceFiles.length; _i++) { + var sourceFile = sourceFiles[_i]; + if (!ts.isDeclarationFile(sourceFile)) { + var absoluteSourceFilePath = host.getCanonicalFileName(ts.getNormalizedAbsolutePath(sourceFile.fileName, currentDirectory)); + if (absoluteSourceFilePath.indexOf(absoluteRootDirectoryPath) !== 0) { + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.File_0_is_not_under_rootDir_1_rootDir_is_expected_to_contain_all_source_files, sourceFile.fileName, options.rootDir)); + allFilesBelongToPath = false; + } + } + } + } + return allFilesBelongToPath; + } + function verifyCompilerOptions() { + if (options.isolatedModules) { + if (options.declaration) { + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "declaration", "isolatedModules")); + } + if (options.noEmitOnError) { + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "noEmitOnError", "isolatedModules")); + } + if (options.out) { + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "out", "isolatedModules")); + } + if (options.outFile) { + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "outFile", "isolatedModules")); + } + } + if (options.inlineSourceMap) { + if (options.sourceMap) { + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "sourceMap", "inlineSourceMap")); + } + if (options.mapRoot) { + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "mapRoot", "inlineSourceMap")); + } + if (options.sourceRoot) { + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "sourceRoot", "inlineSourceMap")); + } + } + if (options.inlineSources) { + if (!options.sourceMap && !options.inlineSourceMap) { + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_inlineSources_can_only_be_used_when_either_option_inlineSourceMap_or_option_sourceMap_is_provided)); + } + } + if (options.out && options.outFile) { + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "out", "outFile")); + } + if (!options.sourceMap && (options.mapRoot || options.sourceRoot)) { + // Error to specify --mapRoot or --sourceRoot without mapSourceFiles + if (options.mapRoot) { + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "mapRoot", "sourceMap")); + } + if (options.sourceRoot) { + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "sourceRoot", "sourceMap")); + } + return; + } + var languageVersion = options.target || 0 /* ES3 */; + var outFile = options.outFile || options.out; + var firstExternalModuleSourceFile = ts.forEach(files, function (f) { return ts.isExternalModule(f) ? f : undefined; }); + if (options.isolatedModules) { + if (!options.module && languageVersion < 2 /* ES6 */) { + 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; }); + if (firstNonExternalModuleSourceFile) { + var span = ts.getErrorSpanForNode(firstNonExternalModuleSourceFile, firstNonExternalModuleSourceFile); + programDiagnostics.add(ts.createFileDiagnostic(firstNonExternalModuleSourceFile, span.start, span.length, ts.Diagnostics.Cannot_compile_namespaces_when_the_isolatedModules_flag_is_provided)); + } + } + else if (firstExternalModuleSourceFile && languageVersion < 2 /* ES6 */ && !options.module) { + // We cannot use createDiagnosticFromNode because nodes do not have parents yet + var span = ts.getErrorSpanForNode(firstExternalModuleSourceFile, firstExternalModuleSourceFile.externalModuleIndicator); + programDiagnostics.add(ts.createFileDiagnostic(firstExternalModuleSourceFile, span.start, span.length, ts.Diagnostics.Cannot_compile_modules_unless_the_module_flag_is_provided)); + } + // Cannot specify module gen target of es6 when below es6 + if (options.module === 5 /* ES6 */ && languageVersion < 2 /* ES6 */) { + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_compile_modules_into_es2015_when_targeting_ES5_or_lower)); + } + // there has to be common source directory if user specified --outdir || --sourceRoot + // if user specified --mapRoot, there needs to be common source directory if there would be multiple files being emitted + if (options.outDir || + options.sourceRoot || + (options.mapRoot && + (!outFile || firstExternalModuleSourceFile !== undefined))) { + if (options.rootDir && checkSourceFilesBelongToPath(files, options.rootDir)) { + // If a rootDir is specified and is valid use it as the commonSourceDirectory + commonSourceDirectory = ts.getNormalizedAbsolutePath(options.rootDir, currentDirectory); + } + else { + // Compute the commonSourceDirectory from the input files + commonSourceDirectory = computeCommonSourceDirectory(files); + } + if (commonSourceDirectory && commonSourceDirectory[commonSourceDirectory.length - 1] !== ts.directorySeparator) { + // Make sure directory path ends with directory separator so this string can directly + // used to replace with "" to get the relative path of the source file and the relative path doesn't + // start with / making it rooted path + commonSourceDirectory += ts.directorySeparator; + } + } + if (options.noEmit) { + if (options.out) { + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "noEmit", "out")); + } + if (options.outFile) { + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "noEmit", "outFile")); + } + if (options.outDir) { + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "noEmit", "outDir")); + } + if (options.declaration) { + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "noEmit", "declaration")); + } + } + if (options.emitDecoratorMetadata && + !options.experimentalDecorators) { + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "emitDecoratorMetadata", "experimentalDecorators")); + } + } + } + ts.createProgram = createProgram; +})(ts || (ts = {})); +/// +/// +/// +/// +var ts; +(function (ts) { + /* @internal */ + ts.optionDeclarations = [ + { + name: "charset", + type: "string" + }, + { + name: "declaration", + shortName: "d", + type: "boolean", + description: ts.Diagnostics.Generates_corresponding_d_ts_file + }, + { + name: "diagnostics", + type: "boolean" + }, + { + name: "emitBOM", + type: "boolean" + }, + { + name: "help", + shortName: "h", + type: "boolean", + description: ts.Diagnostics.Print_this_message + }, + { + 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: { + "preserve": 1 /* Preserve */, + "react": 2 /* React */ + }, + paramType: ts.Diagnostics.KIND, + description: ts.Diagnostics.Specify_JSX_code_generation_Colon_preserve_or_react, + error: ts.Diagnostics.Argument_for_jsx_must_be_preserve_or_react + }, + { + name: "listFiles", + type: "boolean" + }, + { + name: "locale", + type: "string" + }, + { + name: "mapRoot", + type: "string", + isFilePath: true, + description: ts.Diagnostics.Specifies_the_location_where_debugger_should_locate_map_files_instead_of_generated_locations, + paramType: ts.Diagnostics.LOCATION + }, + { + name: "module", + shortName: "m", + type: { + "commonjs": 1 /* CommonJS */, + "amd": 2 /* AMD */, + "system": 4 /* System */, + "umd": 3 /* UMD */, + "es6": 5 /* ES6 */, + "es2015": 5 /* ES2015 */ + }, + description: ts.Diagnostics.Specify_module_code_generation_Colon_commonjs_amd_system_umd_or_es2015, + paramType: ts.Diagnostics.KIND, + error: ts.Diagnostics.Argument_for_module_option_must_be_commonjs_amd_system_umd_or_es2015 + }, + { + name: "newLine", + type: { + "crlf": 0 /* CarriageReturnLineFeed */, + "lf": 1 /* LineFeed */ + }, + description: ts.Diagnostics.Specifies_the_end_of_line_sequence_to_be_used_when_emitting_files_Colon_CRLF_dos_or_LF_unix, + paramType: ts.Diagnostics.NEWLINE, + error: ts.Diagnostics.Argument_for_newLine_option_must_be_CRLF_or_LF + }, + { + 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: "noImplicitAny", + type: "boolean", + description: ts.Diagnostics.Raise_error_on_expressions_and_declarations_with_an_implied_any_type + }, + { + name: "noLib", + type: "boolean" + }, + { + name: "noResolve", + type: "boolean" + }, + { + name: "skipDefaultLibCheck", + type: "boolean" + }, + { + name: "out", + type: "string", + isFilePath: false, + // for correct behaviour, please use outFile + 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: "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, + description: ts.Diagnostics.Specifies_the_root_directory_of_input_files_Use_to_control_the_output_directory_structure_with_outDir, + paramType: ts.Diagnostics.LOCATION + }, + { + name: "isolatedModules", + type: "boolean" + }, + { + name: "sourceMap", + type: "boolean", + description: ts.Diagnostics.Generates_corresponding_map_file + }, + { + name: "sourceRoot", + type: "string", + isFilePath: true, + description: ts.Diagnostics.Specifies_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: { + "es3": 0 /* ES3 */, + "es5": 1 /* ES5 */, + "es6": 2 /* ES6 */, + "es2015": 2 /* ES2015 */ + }, + description: ts.Diagnostics.Specify_ECMAScript_target_version_Colon_ES3_default_ES5_or_ES2015_experimental, + paramType: ts.Diagnostics.VERSION, + error: ts.Diagnostics.Argument_for_target_option_must_be_ES3_ES5_or_ES2015 + }, + { + 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: { + "node": 2 /* NodeJs */, + "classic": 1 /* Classic */ + }, + description: ts.Diagnostics.Specifies_module_resolution_strategy_Colon_node_Node_js_or_classic_TypeScript_pre_1_6, + error: ts.Diagnostics.Argument_for_moduleResolution_option_must_be_node_or_classic + }, + { + name: "forceConsistentCasingInFileNames", + type: "boolean", + description: ts.Diagnostics.Disallow_inconsistently_cased_references_to_the_same_file + }, + ]; + var optionNameMapCache; + /* @internal */ + function getOptionNameMap() { + if (optionNameMapCache) { + return optionNameMapCache; + } + var optionNameMap = {}; + var shortOptionNames = {}; + 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 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++]; + if (s.charCodeAt(0) === 64 /* at */) { + parseResponseFile(s.slice(1)); + } + else if (s.charCodeAt(0) === 45 /* minus */) { + s = s.slice(s.charCodeAt(1) === 45 /* minus */ ? 2 : 1).toLowerCase(); + // Try to translate short option names to their full equivalents. + if (ts.hasProperty(shortOptionNames, s)) { + s = shortOptionNames[s]; + } + if (ts.hasProperty(optionNameMap, s)) { + var opt = optionNameMap[s]; + // Check to see if no argument was provided (e.g. "--locale" is the last command-line argument). + 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++]); + break; + case "boolean": + options[opt.name] = true; + break; + case "string": + options[opt.name] = args[i++] || ""; + break; + // If not a primitive, the possible types are specified in what is effectively a map of options. + default: + var map_2 = opt.type; + var key = (args[i++] || "").toLowerCase(); + if (ts.hasProperty(map_2, key)) { + options[opt.name] = map_2[key]; + } + else { + errors.push(ts.createCompilerDiagnostic(opt.error)); + } + } + } + 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 /* space */) + pos++; + if (pos >= text.length) + break; + var start = pos; + if (text.charCodeAt(start) === 34 /* doubleQuote */) { + pos++; + while (pos < text.length && text.charCodeAt(pos) !== 34 /* doubleQuote */) + 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 /* space */) + pos++; + args.push(text.substring(start, pos)); + } + } + parseStrings(args); + } + } + ts.parseCommandLine = parseCommandLine; + /** + * Read tsconfig.json file + * @param fileName The path to the config file + */ + 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; + /** + * Parse the text of the tsconfig.json file + * @param fileName The path to the config file + * @param jsonText The text of the config file + */ + function parseConfigFileTextToJson(fileName, jsonText) { + try { + return { config: /\S/.test(jsonText) ? JSON.parse(jsonText) : {} }; + } + catch (e) { + return { error: ts.createCompilerDiagnostic(ts.Diagnostics.Failed_to_parse_file_0_Colon_1, fileName, e.message) }; + } + } + ts.parseConfigFileTextToJson = parseConfigFileTextToJson; + /** + * Parse the contents of a config file (tsconfig.json). + * @param json The contents of the config file to parse + * @param host Instance of ParseConfigHost used to enumerate files in folder. + * @param basePath A root directory to resolve relative path entries in the config + * file to. e.g. outDir + */ + function parseJsonConfigFileContent(json, host, basePath) { + var _a = convertCompilerOptionsFromJson(json["compilerOptions"], basePath), options = _a.options, errors = _a.errors; + return { + options: options, + fileNames: getFileNames(), + errors: errors + }; + function getFileNames() { + var fileNames = []; + if (ts.hasProperty(json, "files")) { + if (json["files"] instanceof Array) { + fileNames = ts.map(json["files"], function (s) { return ts.combinePaths(basePath, s); }); + } + else { + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Compiler_option_0_requires_a_value_of_type_1, "files", "Array")); + } + } + else { + var exclude = json["exclude"] instanceof Array ? ts.map(json["exclude"], ts.normalizeSlashes) : undefined; + var sysFiles = host.readDirectory(basePath, ".ts", exclude).concat(host.readDirectory(basePath, ".tsx", exclude)); + for (var i = 0; i < sysFiles.length; i++) { + var name_29 = sysFiles[i]; + if (ts.fileExtensionIs(name_29, ".d.ts")) { + var baseName = name_29.substr(0, name_29.length - ".d.ts".length); + if (!ts.contains(sysFiles, baseName + ".tsx") && !ts.contains(sysFiles, baseName + ".ts")) { + fileNames.push(name_29); + } + } + else if (ts.fileExtensionIs(name_29, ".ts")) { + if (!ts.contains(sysFiles, name_29 + "x")) { + fileNames.push(name_29); + } + } + else { + fileNames.push(name_29); + } + } + } + return fileNames; + } + } + ts.parseJsonConfigFileContent = parseJsonConfigFileContent; + function convertCompilerOptionsFromJson(jsonOptions, basePath) { + var options = {}; + var errors = []; + if (!jsonOptions) { + return { options: options, errors: errors }; + } + var optionNameMap = ts.arrayToMap(ts.optionDeclarations, function (opt) { return opt.name; }); + for (var id in jsonOptions) { + if (ts.hasProperty(optionNameMap, id)) { + var opt = optionNameMap[id]; + var optType = opt.type; + var value = jsonOptions[id]; + var expectedType = typeof optType === "string" ? optType : "string"; + if (typeof value === expectedType) { + if (typeof optType !== "string") { + var key = value.toLowerCase(); + if (ts.hasProperty(optType, key)) { + value = optType[key]; + } + else { + errors.push(ts.createCompilerDiagnostic(opt.error)); + value = 0; + } + } + if (opt.isFilePath) { + value = ts.normalizePath(ts.combinePaths(basePath, value)); + if (value === "") { + value = "."; + } + } + options[opt.name] = value; + } + else { + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Compiler_option_0_requires_a_value_of_type_1, id, expectedType)); + } + } + else { + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Unknown_compiler_option_0, id)); + } + } + return { options: options, errors: errors }; + } + ts.convertCompilerOptionsFromJson = convertCompilerOptionsFromJson; +})(ts || (ts = {})); +/* @internal */ +var ts; +(function (ts) { + var OutliningElementsCollector; + (function (OutliningElementsCollector) { + function collectElements(sourceFile) { + var elements = []; + var collapseText = "..."; + function addOutliningSpan(hintSpanNode, startElement, endElement, autoCollapse) { + if (hintSpanNode && startElement && endElement) { + var span = { + textSpan: ts.createTextSpanFromBounds(startElement.pos, endElement.end), + hintSpan: ts.createTextSpanFromBounds(hintSpanNode.getStart(), hintSpanNode.end), + bannerText: collapseText, + autoCollapse: autoCollapse + }; + elements.push(span); + } + } + function addOutliningSpanComments(commentSpan, autoCollapse) { + if (commentSpan) { + var span = { + textSpan: ts.createTextSpanFromBounds(commentSpan.pos, commentSpan.end), + hintSpan: ts.createTextSpanFromBounds(commentSpan.pos, commentSpan.end), + bannerText: collapseText, + autoCollapse: autoCollapse + }; + elements.push(span); + } + } + function addOutliningForLeadingCommentsForNode(n) { + var comments = ts.getLeadingCommentRangesOfNode(n, sourceFile); + if (comments) { + var firstSingleLineCommentStart = -1; + var lastSingleLineCommentEnd = -1; + var isFirstSingleLineComment = true; + var singleLineCommentCount = 0; + for (var _i = 0; _i < comments.length; _i++) { + var currentComment = comments[_i]; + // For single line comments, combine consecutive ones (2 or more) into + // a single span from the start of the first till the end of the last + if (currentComment.kind === 2 /* SingleLineCommentTrivia */) { + if (isFirstSingleLineComment) { + firstSingleLineCommentStart = currentComment.pos; + } + isFirstSingleLineComment = false; + lastSingleLineCommentEnd = currentComment.end; + singleLineCommentCount++; + } + else if (currentComment.kind === 3 /* MultiLineCommentTrivia */) { + combineAndAddMultipleSingleLineComments(singleLineCommentCount, firstSingleLineCommentStart, lastSingleLineCommentEnd); + addOutliningSpanComments(currentComment, /*autoCollapse*/ false); + singleLineCommentCount = 0; + lastSingleLineCommentEnd = -1; + isFirstSingleLineComment = true; + } + } + combineAndAddMultipleSingleLineComments(singleLineCommentCount, firstSingleLineCommentStart, lastSingleLineCommentEnd); + } + } + function combineAndAddMultipleSingleLineComments(count, start, end) { + // Only outline spans of two or more consecutive single line comments + if (count > 1) { + var multipleSingleLineComments = { + pos: start, + end: end, + kind: 2 /* SingleLineCommentTrivia */ + }; + addOutliningSpanComments(multipleSingleLineComments, /*autoCollapse*/ false); + } + } + function autoCollapse(node) { + return ts.isFunctionBlock(node) && node.parent.kind !== 174 /* ArrowFunction */; + } + var depth = 0; + var maxDepth = 20; + function walk(n) { + if (depth > maxDepth) { + return; + } + if (ts.isDeclaration(n)) { + addOutliningForLeadingCommentsForNode(n); + } + switch (n.kind) { + case 192 /* Block */: + if (!ts.isFunctionBlock(n)) { + var parent_7 = n.parent; + var openBrace = ts.findChildOfKind(n, 15 /* OpenBraceToken */, sourceFile); + var closeBrace = ts.findChildOfKind(n, 16 /* CloseBraceToken */, sourceFile); + // Check if the block is standalone, or 'attached' to some parent statement. + // If the latter, we want to collaps the block, but consider its hint span + // to be the entire span of the parent. + if (parent_7.kind === 197 /* DoStatement */ || + parent_7.kind === 200 /* ForInStatement */ || + parent_7.kind === 201 /* ForOfStatement */ || + parent_7.kind === 199 /* ForStatement */ || + parent_7.kind === 196 /* IfStatement */ || + parent_7.kind === 198 /* WhileStatement */ || + parent_7.kind === 205 /* WithStatement */ || + parent_7.kind === 244 /* CatchClause */) { + addOutliningSpan(parent_7, openBrace, closeBrace, autoCollapse(n)); + break; + } + if (parent_7.kind === 209 /* TryStatement */) { + // Could be the try-block, or the finally-block. + var tryStatement = parent_7; + if (tryStatement.tryBlock === n) { + addOutliningSpan(parent_7, openBrace, closeBrace, autoCollapse(n)); + break; + } + else if (tryStatement.finallyBlock === n) { + var finallyKeyword = ts.findChildOfKind(tryStatement, 85 /* FinallyKeyword */, sourceFile); + if (finallyKeyword) { + addOutliningSpan(finallyKeyword, openBrace, closeBrace, autoCollapse(n)); + break; + } + } + } + // Block was a standalone block. In this case we want to only collapse + // the span of the block, independent of any parent span. + var span = ts.createTextSpanFromBounds(n.getStart(), n.end); + elements.push({ + textSpan: span, + hintSpan: span, + bannerText: collapseText, + autoCollapse: autoCollapse(n) + }); + break; + } + // Fallthrough. + case 219 /* ModuleBlock */: { + var openBrace = ts.findChildOfKind(n, 15 /* OpenBraceToken */, sourceFile); + var closeBrace = ts.findChildOfKind(n, 16 /* CloseBraceToken */, sourceFile); + addOutliningSpan(n.parent, openBrace, closeBrace, autoCollapse(n)); + break; + } + case 214 /* ClassDeclaration */: + case 215 /* InterfaceDeclaration */: + case 217 /* EnumDeclaration */: + case 165 /* ObjectLiteralExpression */: + case 220 /* CaseBlock */: { + var openBrace = ts.findChildOfKind(n, 15 /* OpenBraceToken */, sourceFile); + var closeBrace = ts.findChildOfKind(n, 16 /* CloseBraceToken */, sourceFile); + addOutliningSpan(n, openBrace, closeBrace, autoCollapse(n)); + break; + } + case 164 /* ArrayLiteralExpression */: + var openBracket = ts.findChildOfKind(n, 19 /* OpenBracketToken */, sourceFile); + var closeBracket = ts.findChildOfKind(n, 20 /* CloseBracketToken */, sourceFile); + addOutliningSpan(n, openBracket, closeBracket, autoCollapse(n)); + break; + } + depth++; + ts.forEachChild(n, walk); + depth--; + } + walk(sourceFile); + return elements; + } + OutliningElementsCollector.collectElements = collectElements; + })(OutliningElementsCollector = ts.OutliningElementsCollector || (ts.OutliningElementsCollector = {})); +})(ts || (ts = {})); +/* @internal */ +var ts; +(function (ts) { + var NavigateTo; + (function (NavigateTo) { + function getNavigateToItems(program, cancellationToken, searchValue, maxResultCount) { + var patternMatcher = ts.createPatternMatcher(searchValue); + var rawItems = []; + // Search the declarations in all files and output matched NavigateToItem into array of NavigateToItem[] + ts.forEach(program.getSourceFiles(), function (sourceFile) { + cancellationToken.throwIfCancellationRequested(); + var nameToDeclarations = sourceFile.getNamedDeclarations(); + for (var name_30 in nameToDeclarations) { + var declarations = ts.getProperty(nameToDeclarations, name_30); + if (declarations) { + // First do a quick check to see if the name of the declaration matches the + // last portion of the (possibly) dotted name they're searching for. + var matches = patternMatcher.getMatchesForLastSegmentOfPattern(name_30); + if (!matches) { + continue; + } + for (var _i = 0; _i < declarations.length; _i++) { + var declaration = declarations[_i]; + // It was a match! If the pattern has dots in it, then also see if the + // declaration container matches as well. + if (patternMatcher.patternContainsDots) { + var containers = getContainers(declaration); + if (!containers) { + return undefined; + } + matches = patternMatcher.getMatches(containers, name_30); + if (!matches) { + continue; + } + } + var fileName = sourceFile.fileName; + var matchKind = bestMatchKind(matches); + rawItems.push({ name: name_30, fileName: fileName, matchKind: matchKind, isCaseSensitive: allMatchesAreCaseSensitive(matches), declaration: declaration }); + } + } + } + }); + rawItems.sort(compareNavigateToItems); + if (maxResultCount !== undefined) { + rawItems = rawItems.slice(0, maxResultCount); + } + var items = ts.map(rawItems, createNavigateToItem); + return items; + function allMatchesAreCaseSensitive(matches) { + ts.Debug.assert(matches.length > 0); + // This is a case sensitive match, only if all the submatches were case sensitive. + for (var _i = 0; _i < matches.length; _i++) { + var match = matches[_i]; + if (!match.isCaseSensitive) { + return false; + } + } + return true; + } + function getTextOfIdentifierOrLiteral(node) { + if (node) { + if (node.kind === 69 /* Identifier */ || + node.kind === 9 /* StringLiteral */ || + node.kind === 8 /* NumericLiteral */) { + return node.text; + } + } + return undefined; + } + function tryAddSingleDeclarationName(declaration, containers) { + if (declaration && declaration.name) { + var text = getTextOfIdentifierOrLiteral(declaration.name); + if (text !== undefined) { + containers.unshift(text); + } + else if (declaration.name.kind === 136 /* ComputedPropertyName */) { + return tryAddComputedPropertyName(declaration.name.expression, containers, /*includeLastPortion:*/ true); + } + else { + // Don't know how to add this. + return false; + } + } + return true; + } + // Only added the names of computed properties if they're simple dotted expressions, like: + // + // [X.Y.Z]() { } + function tryAddComputedPropertyName(expression, containers, includeLastPortion) { + var text = getTextOfIdentifierOrLiteral(expression); + if (text !== undefined) { + if (includeLastPortion) { + containers.unshift(text); + } + return true; + } + if (expression.kind === 166 /* PropertyAccessExpression */) { + var propertyAccess = expression; + if (includeLastPortion) { + containers.unshift(propertyAccess.name.text); + } + return tryAddComputedPropertyName(propertyAccess.expression, containers, /*includeLastPortion:*/ true); + } + return false; + } + function getContainers(declaration) { + 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 === 136 /* ComputedPropertyName */) { + if (!tryAddComputedPropertyName(declaration.name.expression, containers, /*includeLastPortion:*/ false)) { + return undefined; + } + } + // Now, walk up our containers, adding all their names to the container array. + declaration = ts.getContainerNode(declaration); + while (declaration) { + if (!tryAddSingleDeclarationName(declaration, containers)) { + return undefined; + } + declaration = ts.getContainerNode(declaration); + } + return containers; + } + function bestMatchKind(matches) { + ts.Debug.assert(matches.length > 0); + var bestMatchKind = ts.PatternMatchKind.camelCase; + for (var _i = 0; _i < matches.length; _i++) { + var match = matches[_i]; + var kind = match.kind; + if (kind < bestMatchKind) { + bestMatchKind = kind; + } + } + return bestMatchKind; + } + // This means "compare in a case insensitive manner." + var baseSensitivity = { sensitivity: "base" }; + function compareNavigateToItems(i1, i2) { + // TODO(cyrusn): get the gamut of comparisons that VS already uses here. + // Right now we just sort by kind first, and then by name of the item. + // 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); + } + function createNavigateToItem(rawItem) { + var declaration = rawItem.declaration; + var container = ts.getContainerNode(declaration); + return { + name: rawItem.name, + kind: ts.getNodeKind(declaration), + kindModifiers: ts.getNodeModifiers(declaration), + matchKind: ts.PatternMatchKind[rawItem.matchKind], + isCaseSensitive: rawItem.isCaseSensitive, + fileName: rawItem.fileName, + textSpan: ts.createTextSpanFromBounds(declaration.getStart(), declaration.getEnd()), + // TODO(jfreeman): What should be the containerName when the container has a computed name? + containerName: container && container.name ? container.name.text : "", + containerKind: container && container.name ? ts.getNodeKind(container) : "" + }; + } + } + NavigateTo.getNavigateToItems = getNavigateToItems; + })(NavigateTo = ts.NavigateTo || (ts.NavigateTo = {})); +})(ts || (ts = {})); +/// +/* @internal */ +var ts; +(function (ts) { + var NavigationBar; + (function (NavigationBar) { + function getNavigationBarItems(sourceFile) { + // If the source file has any child items, then it included in the tree + // and takes lexical ownership of all other top-level items. + var hasGlobalNode = false; + return getItemsWorker(getTopLevelNodes(sourceFile), createTopLevelItem); + function getIndent(node) { + // If we have a global node in the tree, + // then it adds an extra layer of depth to all subnodes. + var indent = hasGlobalNode ? 1 : 0; + var current = node.parent; + while (current) { + switch (current.kind) { + case 218 /* ModuleDeclaration */: + // If we have a module declared as A.B.C, it is more "intuitive" + // to say it only has a single layer of depth + do { + current = current.parent; + } while (current.kind === 218 /* ModuleDeclaration */); + // fall through + case 214 /* ClassDeclaration */: + case 217 /* EnumDeclaration */: + case 215 /* InterfaceDeclaration */: + case 213 /* FunctionDeclaration */: + indent++; + } + current = current.parent; + } + return indent; + } + function getChildNodes(nodes) { + var childNodes = []; + function visit(node) { + switch (node.kind) { + case 193 /* VariableStatement */: + ts.forEach(node.declarationList.declarations, visit); + break; + case 161 /* ObjectBindingPattern */: + case 162 /* ArrayBindingPattern */: + ts.forEach(node.elements, visit); + break; + case 228 /* ExportDeclaration */: + // Handle named exports case e.g.: + // export {a, b as B} from "mod"; + if (node.exportClause) { + ts.forEach(node.exportClause.elements, visit); + } + break; + case 222 /* ImportDeclaration */: + var importClause = node.importClause; + if (importClause) { + // Handle default import case e.g.: + // import d from "mod"; + if (importClause.name) { + childNodes.push(importClause); + } + // Handle named bindings in imports e.g.: + // import * as NS from "mod"; + // import {a, b as B} from "mod"; + if (importClause.namedBindings) { + if (importClause.namedBindings.kind === 224 /* NamespaceImport */) { + childNodes.push(importClause.namedBindings); + } + else { + ts.forEach(importClause.namedBindings.elements, visit); + } + } + } + break; + case 163 /* BindingElement */: + case 211 /* VariableDeclaration */: + if (ts.isBindingPattern(node.name)) { + visit(node.name); + break; + } + // Fall through + case 214 /* ClassDeclaration */: + case 217 /* EnumDeclaration */: + case 215 /* InterfaceDeclaration */: + case 218 /* ModuleDeclaration */: + case 213 /* FunctionDeclaration */: + case 221 /* ImportEqualsDeclaration */: + case 226 /* ImportSpecifier */: + case 230 /* ExportSpecifier */: + childNodes.push(node); + break; + } + } + //for (let i = 0, n = nodes.length; i < n; i++) { + // let node = nodes[i]; + // if (node.kind === SyntaxKind.ClassDeclaration || + // node.kind === SyntaxKind.EnumDeclaration || + // node.kind === SyntaxKind.InterfaceDeclaration || + // node.kind === SyntaxKind.ModuleDeclaration || + // node.kind === SyntaxKind.FunctionDeclaration) { + // childNodes.push(node); + // } + // else if (node.kind === SyntaxKind.VariableStatement) { + // childNodes.push.apply(childNodes, (node).declarations); + // } + //} + ts.forEach(nodes, visit); + return sortNodes(childNodes); + } + function getTopLevelNodes(node) { + var topLevelNodes = []; + topLevelNodes.push(node); + addTopLevelNodes(node.statements, topLevelNodes); + return topLevelNodes; + } + function sortNodes(nodes) { + return nodes.slice(0).sort(function (n1, n2) { + if (n1.name && n2.name) { + return ts.getPropertyNameForPropertyNameNode(n1.name).localeCompare(ts.getPropertyNameForPropertyNameNode(n2.name)); + } + else if (n1.name) { + return 1; + } + else if (n2.name) { + return -1; + } + else { + return n1.kind - n2.kind; + } + }); + } + function addTopLevelNodes(nodes, topLevelNodes) { + nodes = sortNodes(nodes); + for (var _i = 0; _i < nodes.length; _i++) { + var node = nodes[_i]; + switch (node.kind) { + case 214 /* ClassDeclaration */: + case 217 /* EnumDeclaration */: + case 215 /* InterfaceDeclaration */: + topLevelNodes.push(node); + break; + case 218 /* ModuleDeclaration */: + var moduleDeclaration = node; + topLevelNodes.push(node); + addTopLevelNodes(getInnermostModule(moduleDeclaration).body.statements, topLevelNodes); + break; + case 213 /* FunctionDeclaration */: + var functionDeclaration = node; + if (isTopLevelFunctionDeclaration(functionDeclaration)) { + topLevelNodes.push(node); + addTopLevelNodes(functionDeclaration.body.statements, topLevelNodes); + } + break; + } + } + } + function isTopLevelFunctionDeclaration(functionDeclaration) { + if (functionDeclaration.kind === 213 /* FunctionDeclaration */) { + // A function declaration is 'top level' if it contains any function declarations + // within it. + if (functionDeclaration.body && functionDeclaration.body.kind === 192 /* Block */) { + // Proper function declarations can only have identifier names + if (ts.forEach(functionDeclaration.body.statements, function (s) { return s.kind === 213 /* FunctionDeclaration */ && !isEmpty(s.name.text); })) { + return true; + } + // Or if it is not parented by another function. i.e all functions + // at module scope are 'top level'. + if (!ts.isFunctionBlock(functionDeclaration.parent)) { + return true; + } + } + } + return false; + } + function getItemsWorker(nodes, createItem) { + var items = []; + var keyToItem = {}; + for (var _i = 0; _i < nodes.length; _i++) { + var child = nodes[_i]; + var item = createItem(child); + if (item !== undefined) { + if (item.text.length > 0) { + var key = item.text + "-" + item.kind + "-" + item.indent; + var itemWithSameName = keyToItem[key]; + if (itemWithSameName) { + // We had an item with the same name. Merge these items together. + merge(itemWithSameName, item); + } + else { + keyToItem[key] = item; + items.push(item); + } + } + } + } + return items; + } + function merge(target, source) { + // First, add any spans in the source to the target. + ts.addRange(target.spans, source.spans); + if (source.childItems) { + if (!target.childItems) { + target.childItems = []; + } + // Next, recursively merge or add any children in the source as appropriate. + outer: for (var _i = 0, _a = source.childItems; _i < _a.length; _i++) { + var sourceChild = _a[_i]; + for (var _b = 0, _c = target.childItems; _b < _c.length; _b++) { + var targetChild = _c[_b]; + if (targetChild.text === sourceChild.text && targetChild.kind === sourceChild.kind) { + // Found a match. merge them. + merge(targetChild, sourceChild); + continue outer; + } + } + // Didn't find a match, just add this child to the list. + target.childItems.push(sourceChild); + } + } + } + function createChildItem(node) { + switch (node.kind) { + case 138 /* Parameter */: + if (ts.isBindingPattern(node.name)) { + break; + } + if ((node.flags & 2035 /* Modifier */) === 0) { + return undefined; + } + return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberVariableElement); + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: + return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberFunctionElement); + case 145 /* GetAccessor */: + return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberGetAccessorElement); + case 146 /* SetAccessor */: + return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberSetAccessorElement); + case 149 /* IndexSignature */: + return createItem(node, "[]", ts.ScriptElementKind.indexSignatureElement); + case 247 /* EnumMember */: + return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberVariableElement); + case 147 /* CallSignature */: + return createItem(node, "()", ts.ScriptElementKind.callSignatureElement); + case 148 /* ConstructSignature */: + return createItem(node, "new()", ts.ScriptElementKind.constructSignatureElement); + case 141 /* PropertyDeclaration */: + case 140 /* PropertySignature */: + return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberVariableElement); + case 213 /* FunctionDeclaration */: + return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.functionElement); + case 211 /* VariableDeclaration */: + case 163 /* BindingElement */: + var variableDeclarationNode; + var name_31; + if (node.kind === 163 /* BindingElement */) { + name_31 = node.name; + variableDeclarationNode = node; + // binding elements are added only for variable declarations + // bubble up to the containing variable declaration + while (variableDeclarationNode && variableDeclarationNode.kind !== 211 /* VariableDeclaration */) { + variableDeclarationNode = variableDeclarationNode.parent; + } + ts.Debug.assert(variableDeclarationNode !== undefined); + } + else { + ts.Debug.assert(!ts.isBindingPattern(node.name)); + variableDeclarationNode = node; + name_31 = node.name; + } + if (ts.isConst(variableDeclarationNode)) { + return createItem(node, getTextOfNode(name_31), ts.ScriptElementKind.constElement); + } + else if (ts.isLet(variableDeclarationNode)) { + return createItem(node, getTextOfNode(name_31), ts.ScriptElementKind.letElement); + } + else { + return createItem(node, getTextOfNode(name_31), ts.ScriptElementKind.variableElement); + } + case 144 /* Constructor */: + return createItem(node, "constructor", ts.ScriptElementKind.constructorImplementationElement); + case 230 /* ExportSpecifier */: + case 226 /* ImportSpecifier */: + case 221 /* ImportEqualsDeclaration */: + case 223 /* ImportClause */: + case 224 /* NamespaceImport */: + return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.alias); + } + return undefined; + function createItem(node, name, scriptElementKind) { + return getNavigationBarItem(name, scriptElementKind, ts.getNodeModifiers(node), [getNodeSpan(node)]); + } + } + function isEmpty(text) { + return !text || text.trim() === ""; + } + function getNavigationBarItem(text, kind, kindModifiers, spans, childItems, indent) { + if (childItems === void 0) { childItems = []; } + if (indent === void 0) { indent = 0; } + if (isEmpty(text)) { + return undefined; + } + return { + text: text, + kind: kind, + kindModifiers: kindModifiers, + spans: spans, + childItems: childItems, + indent: indent, + bolded: false, + grayed: false + }; + } + function createTopLevelItem(node) { + switch (node.kind) { + case 248 /* SourceFile */: + return createSourceFileItem(node); + case 214 /* ClassDeclaration */: + return createClassItem(node); + case 217 /* EnumDeclaration */: + return createEnumItem(node); + case 215 /* InterfaceDeclaration */: + return createIterfaceItem(node); + case 218 /* ModuleDeclaration */: + return createModuleItem(node); + case 213 /* FunctionDeclaration */: + return createFunctionItem(node); + } + return undefined; + function getModuleName(moduleDeclaration) { + // We want to maintain quotation marks. + if (moduleDeclaration.name.kind === 9 /* StringLiteral */) { + return getTextOfNode(moduleDeclaration.name); + } + // 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 === 218 /* ModuleDeclaration */) { + moduleDeclaration = moduleDeclaration.body; + result.push(moduleDeclaration.name.text); + } + return result.join("."); + } + function createModuleItem(node) { + var moduleName = getModuleName(node); + var childItems = getItemsWorker(getChildNodes(getInnermostModule(node).body.statements), createChildItem); + return getNavigationBarItem(moduleName, ts.ScriptElementKind.moduleElement, ts.getNodeModifiers(node), [getNodeSpan(node)], childItems, getIndent(node)); + } + function createFunctionItem(node) { + if (node.body && node.body.kind === 192 /* Block */) { + var childItems = getItemsWorker(sortNodes(node.body.statements), createChildItem); + return getNavigationBarItem(!node.name ? "default" : node.name.text, ts.ScriptElementKind.functionElement, ts.getNodeModifiers(node), [getNodeSpan(node)], childItems, getIndent(node)); + } + return undefined; + } + function createSourceFileItem(node) { + var childItems = getItemsWorker(getChildNodes(node.statements), createChildItem); + if (childItems === undefined || childItems.length === 0) { + return undefined; + } + hasGlobalNode = true; + var rootName = ts.isExternalModule(node) + ? "\"" + ts.escapeString(ts.getBaseFileName(ts.removeFileExtension(ts.normalizePath(node.fileName)))) + "\"" + : ""; + return getNavigationBarItem(rootName, ts.ScriptElementKind.moduleElement, ts.ScriptElementKindModifier.none, [getNodeSpan(node)], childItems); + } + function createClassItem(node) { + var childItems; + if (node.members) { + var constructor = ts.forEach(node.members, function (member) { + return member.kind === 144 /* Constructor */ && member; + }); + // Add the constructor parameters in as children of the class (for property parameters). + // Note that *all non-binding pattern named* parameters will be added to the nodes array, but parameters that + // are not properties will be filtered out later by createChildItem. + var nodes = removeDynamicallyNamedProperties(node); + if (constructor) { + ts.addRange(nodes, ts.filter(constructor.parameters, function (p) { return !ts.isBindingPattern(p.name); })); + } + childItems = getItemsWorker(sortNodes(nodes), createChildItem); + } + var nodeName = !node.name ? "default" : node.name.text; + return getNavigationBarItem(nodeName, ts.ScriptElementKind.classElement, ts.getNodeModifiers(node), [getNodeSpan(node)], childItems, getIndent(node)); + } + function createEnumItem(node) { + var childItems = getItemsWorker(sortNodes(removeComputedProperties(node)), createChildItem); + return getNavigationBarItem(node.name.text, ts.ScriptElementKind.enumElement, ts.getNodeModifiers(node), [getNodeSpan(node)], childItems, getIndent(node)); + } + function createIterfaceItem(node) { + var childItems = getItemsWorker(sortNodes(removeDynamicallyNamedProperties(node)), createChildItem); + return getNavigationBarItem(node.name.text, ts.ScriptElementKind.interfaceElement, ts.getNodeModifiers(node), [getNodeSpan(node)], childItems, getIndent(node)); + } + } + function removeComputedProperties(node) { + return ts.filter(node.members, function (member) { return member.name === undefined || member.name.kind !== 136 /* ComputedPropertyName */; }); + } + /** + * Like removeComputedProperties, but retains the properties with well known symbol names + */ + function removeDynamicallyNamedProperties(node) { + return ts.filter(node.members, function (member) { return !ts.hasDynamicName(member); }); + } + function getInnermostModule(node) { + while (node.body.kind === 218 /* ModuleDeclaration */) { + node = node.body; + } + return node; + } + function getNodeSpan(node) { + return node.kind === 248 /* SourceFile */ + ? ts.createTextSpanFromBounds(node.getFullStart(), node.getEnd()) + : ts.createTextSpanFromBounds(node.getStart(), node.getEnd()); + } + function getTextOfNode(node) { + return ts.getTextOfNodeFromSourceText(sourceFile.text, node); + } + } + NavigationBar.getNavigationBarItems = getNavigationBarItems; + })(NavigationBar = ts.NavigationBar || (ts.NavigationBar = {})); +})(ts || (ts = {})); +/* @internal */ +var ts; +(function (ts) { + // Note(cyrusn): this enum is ordered from strongest match type to weakest match type. + (function (PatternMatchKind) { + PatternMatchKind[PatternMatchKind["exact"] = 0] = "exact"; + PatternMatchKind[PatternMatchKind["prefix"] = 1] = "prefix"; + PatternMatchKind[PatternMatchKind["substring"] = 2] = "substring"; + PatternMatchKind[PatternMatchKind["camelCase"] = 3] = "camelCase"; + })(ts.PatternMatchKind || (ts.PatternMatchKind = {})); + var PatternMatchKind = ts.PatternMatchKind; + function createPatternMatch(kind, punctuationStripped, isCaseSensitive, camelCaseWeight) { + return { + kind: kind, + punctuationStripped: punctuationStripped, + isCaseSensitive: isCaseSensitive, + camelCaseWeight: camelCaseWeight + }; + } + function createPatternMatcher(pattern) { + // We'll often see the same candidate string many times when searching (For example, when + // we see the name of a module that is used everywhere, or the name of an overload). As + // such, we cache the information we compute about the candidate for the life of this + // pattern matcher so we don't have to compute it multiple times. + var stringToWordSpans = {}; + pattern = pattern.trim(); + var fullPatternSegment = createSegment(pattern); + var dotSeparatedSegments = pattern.split(".").map(function (p) { return createSegment(p.trim()); }); + var invalidPattern = dotSeparatedSegments.length === 0 || ts.forEach(dotSeparatedSegments, segmentIsInvalid); + return { + getMatches: getMatches, + getMatchesForLastSegmentOfPattern: getMatchesForLastSegmentOfPattern, + patternContainsDots: dotSeparatedSegments.length > 1 + }; + // Quick checks so we can bail out when asked to match a candidate. + function skipMatch(candidate) { + return invalidPattern || !candidate; + } + function getMatchesForLastSegmentOfPattern(candidate) { + if (skipMatch(candidate)) { + return undefined; + } + return matchSegment(candidate, ts.lastOrUndefined(dotSeparatedSegments)); + } + function getMatches(candidateContainers, candidate) { + if (skipMatch(candidate)) { + return undefined; + } + // First, check that the last part of the dot separated pattern matches the name of the + // candidate. If not, then there's no point in proceeding and doing the more + // expensive work. + var candidateMatch = matchSegment(candidate, ts.lastOrUndefined(dotSeparatedSegments)); + if (!candidateMatch) { + return undefined; + } + candidateContainers = candidateContainers || []; + // -1 because the last part was checked against the name, and only the rest + // of the parts are checked against the container. + if (dotSeparatedSegments.length - 1 > candidateContainers.length) { + // There weren't enough container parts to match against the pattern parts. + // So this definitely doesn't match. + return undefined; + } + // So far so good. Now break up the container for the candidate and check if all + // the dotted parts match up correctly. + var totalMatch = candidateMatch; + for (var i = dotSeparatedSegments.length - 2, j = candidateContainers.length - 1; i >= 0; i--, j--) { + var segment = dotSeparatedSegments[i]; + var containerName = candidateContainers[j]; + var containerMatch = matchSegment(containerName, segment); + if (!containerMatch) { + // This container didn't match the pattern piece. So there's no match at all. + return undefined; + } + ts.addRange(totalMatch, containerMatch); + } + // Success, this symbol's full name matched against the dotted name the user was asking + // about. + return totalMatch; + } + function getWordSpans(word) { + if (!ts.hasProperty(stringToWordSpans, word)) { + stringToWordSpans[word] = breakIntoWordSpans(word); + } + return stringToWordSpans[word]; + } + function matchTextChunk(candidate, chunk, punctuationStripped) { + var index = indexOfIgnoringCase(candidate, chunk.textLowerCase); + if (index === 0) { + if (chunk.text.length === candidate.length) { + // a) Check if the part matches the candidate entirely, in an case insensitive or + // sensitive manner. If it does, return that there was an exact match. + return createPatternMatch(PatternMatchKind.exact, punctuationStripped, /*isCaseSensitive:*/ candidate === chunk.text); + } + else { + // b) Check if the part is a prefix of the candidate, in a case insensitive or sensitive + // manner. If it does, return that there was a prefix match. + return createPatternMatch(PatternMatchKind.prefix, punctuationStripped, /*isCaseSensitive:*/ startsWith(candidate, chunk.text)); + } + } + var isLowercase = chunk.isLowerCase; + if (isLowercase) { + if (index > 0) { + // c) If the part is entirely lowercase, then check if it is contained anywhere in the + // candidate in a case insensitive manner. If so, return that there was a substring + // match. + // + // Note: We only have a substring match if the lowercase part is prefix match of some + // word part. That way we don't match something like 'Class' when the user types 'a'. + // But we would match 'FooAttribute' (since 'Attribute' starts with 'a'). + var wordSpans = getWordSpans(candidate); + for (var _i = 0; _i < wordSpans.length; _i++) { + var span = wordSpans[_i]; + if (partStartsWith(candidate, span, chunk.text, /*ignoreCase:*/ true)) { + return createPatternMatch(PatternMatchKind.substring, punctuationStripped, + /*isCaseSensitive:*/ partStartsWith(candidate, span, chunk.text, /*ignoreCase:*/ false)); + } + } + } + } + else { + // d) If the part was not entirely lowercase, then check if it is contained in the + // candidate in a case *sensitive* manner. If so, return that there was a substring + // match. + if (candidate.indexOf(chunk.text) > 0) { + return createPatternMatch(PatternMatchKind.substring, punctuationStripped, /*isCaseSensitive:*/ true); + } + } + if (!isLowercase) { + // e) If the part was not entirely lowercase, then attempt a camel cased match as well. + if (chunk.characterSpans.length > 0) { + var candidateParts = getWordSpans(candidate); + var camelCaseWeight = tryCamelCaseMatch(candidate, candidateParts, chunk, /*ignoreCase:*/ false); + if (camelCaseWeight !== undefined) { + return createPatternMatch(PatternMatchKind.camelCase, punctuationStripped, /*isCaseSensitive:*/ true, /*camelCaseWeight:*/ camelCaseWeight); + } + camelCaseWeight = tryCamelCaseMatch(candidate, candidateParts, chunk, /*ignoreCase:*/ true); + if (camelCaseWeight !== undefined) { + return createPatternMatch(PatternMatchKind.camelCase, punctuationStripped, /*isCaseSensitive:*/ false, /*camelCaseWeight:*/ camelCaseWeight); + } + } + } + if (isLowercase) { + // f) Is the pattern a substring of the candidate starting on one of the candidate's word boundaries? + // We could check every character boundary start of the candidate for the pattern. However, that's + // an m * n operation in the wost case. Instead, find the first instance of the pattern + // substring, and see if it starts on a capital letter. It seems unlikely that the user will try to + // filter the list based on a substring that starts on a capital letter and also with a lowercase one. + // (Pattern: fogbar, Candidate: quuxfogbarFogBar). + if (chunk.text.length < candidate.length) { + if (index > 0 && isUpperCaseLetter(candidate.charCodeAt(index))) { + return createPatternMatch(PatternMatchKind.substring, punctuationStripped, /*isCaseSensitive:*/ false); + } + } + } + return undefined; + } + function containsSpaceOrAsterisk(text) { + for (var i = 0; i < text.length; i++) { + var ch = text.charCodeAt(i); + if (ch === 32 /* space */ || ch === 42 /* asterisk */) { + return true; + } + } + return false; + } + function matchSegment(candidate, segment) { + // First check if the segment matches as is. This is also useful if the segment contains + // characters we would normally strip when splitting into parts that we also may want to + // match in the candidate. For example if the segment is "@int" and the candidate is + // "@int", then that will show up as an exact match here. + // + // Note: if the segment contains a space or an asterisk then we must assume that it's a + // multi-word segment. + if (!containsSpaceOrAsterisk(segment.totalTextChunk.text)) { + var match = matchTextChunk(candidate, segment.totalTextChunk, /*punctuationStripped:*/ false); + if (match) { + return [match]; + } + } + // The logic for pattern matching is now as follows: + // + // 1) Break the segment passed in into words. Breaking is rather simple and a + // good way to think about it that if gives you all the individual alphanumeric words + // of the pattern. + // + // 2) For each word try to match the word against the candidate value. + // + // 3) Matching is as follows: + // + // a) Check if the word matches the candidate entirely, in an case insensitive or + // sensitive manner. If it does, return that there was an exact match. + // + // b) Check if the word is a prefix of the candidate, in a case insensitive or + // sensitive manner. If it does, return that there was a prefix match. + // + // c) If the word is entirely lowercase, then check if it is contained anywhere in the + // candidate in a case insensitive manner. If so, return that there was a substring + // match. + // + // Note: We only have a substring match if the lowercase part is prefix match of + // some word part. That way we don't match something like 'Class' when the user + // types 'a'. But we would match 'FooAttribute' (since 'Attribute' starts with + // 'a'). + // + // d) If the word was not entirely lowercase, then check if it is contained in the + // candidate in a case *sensitive* manner. If so, return that there was a substring + // match. + // + // e) If the word was not entirely lowercase, then attempt a camel cased match as + // well. + // + // f) The word is all lower case. Is it a case insensitive substring of the candidate starting + // on a part boundary of the candidate? + // + // Only if all words have some sort of match is the pattern considered matched. + var subWordTextChunks = segment.subWordTextChunks; + var matches = undefined; + for (var _i = 0; _i < subWordTextChunks.length; _i++) { + var subWordTextChunk = subWordTextChunks[_i]; + // Try to match the candidate with this word + var result = matchTextChunk(candidate, subWordTextChunk, /*punctuationStripped:*/ true); + if (!result) { + return undefined; + } + matches = matches || []; + matches.push(result); + } + return matches; + } + function partStartsWith(candidate, candidateSpan, pattern, ignoreCase, patternSpan) { + var patternPartStart = patternSpan ? patternSpan.start : 0; + var patternPartLength = patternSpan ? patternSpan.length : pattern.length; + if (patternPartLength > candidateSpan.length) { + // Pattern part is longer than the candidate part. There can never be a match. + return false; + } + if (ignoreCase) { + for (var i = 0; i < patternPartLength; i++) { + var ch1 = pattern.charCodeAt(patternPartStart + i); + var ch2 = candidate.charCodeAt(candidateSpan.start + i); + if (toLowerCase(ch1) !== toLowerCase(ch2)) { + return false; + } + } + } + else { + for (var i = 0; i < patternPartLength; i++) { + var ch1 = pattern.charCodeAt(patternPartStart + i); + var ch2 = candidate.charCodeAt(candidateSpan.start + i); + if (ch1 !== ch2) { + return false; + } + } + } + return true; + } + function tryCamelCaseMatch(candidate, candidateParts, chunk, ignoreCase) { + var chunkCharacterSpans = chunk.characterSpans; + // Note: we may have more pattern parts than candidate parts. This is because multiple + // pattern parts may match a candidate part. For example "SiUI" against "SimpleUI". + // We'll have 3 pattern parts Si/U/I against two candidate parts Simple/UI. However, U + // and I will both match in UI. + var currentCandidate = 0; + var currentChunkSpan = 0; + var firstMatch = undefined; + var contiguous = undefined; + while (true) { + // Let's consider our termination cases + if (currentChunkSpan === chunkCharacterSpans.length) { + // We did match! We shall assign a weight to this + var weight = 0; + // Was this contiguous? + if (contiguous) { + weight += 1; + } + // Did we start at the beginning of the candidate? + if (firstMatch === 0) { + weight += 2; + } + return weight; + } + else if (currentCandidate === candidateParts.length) { + // No match, since we still have more of the pattern to hit + return undefined; + } + var candidatePart = candidateParts[currentCandidate]; + var gotOneMatchThisCandidate = false; + // Consider the case of matching SiUI against SimpleUIElement. The candidate parts + // will be Simple/UI/Element, and the pattern parts will be Si/U/I. We'll match 'Si' + // against 'Simple' first. Then we'll match 'U' against 'UI'. However, we want to + // still keep matching pattern parts against that candidate part. + for (; currentChunkSpan < chunkCharacterSpans.length; currentChunkSpan++) { + var chunkCharacterSpan = chunkCharacterSpans[currentChunkSpan]; + if (gotOneMatchThisCandidate) { + // We've already gotten one pattern part match in this candidate. We will + // only continue trying to consumer pattern parts if the last part and this + // part are both upper case. + if (!isUpperCaseLetter(chunk.text.charCodeAt(chunkCharacterSpans[currentChunkSpan - 1].start)) || + !isUpperCaseLetter(chunk.text.charCodeAt(chunkCharacterSpans[currentChunkSpan].start))) { + break; + } + } + if (!partStartsWith(candidate, candidatePart, chunk.text, ignoreCase, chunkCharacterSpan)) { + break; + } + gotOneMatchThisCandidate = true; + firstMatch = firstMatch === undefined ? currentCandidate : firstMatch; + // If we were contiguous, then keep that value. If we weren't, then keep that + // value. If we don't know, then set the value to 'true' as an initial match is + // obviously contiguous. + contiguous = contiguous === undefined ? true : contiguous; + candidatePart = ts.createTextSpan(candidatePart.start + chunkCharacterSpan.length, candidatePart.length - chunkCharacterSpan.length); + } + // Check if we matched anything at all. If we didn't, then we need to unset the + // contiguous bit if we currently had it set. + // If we haven't set the bit yet, then that means we haven't matched anything so + // far, and we don't want to change that. + if (!gotOneMatchThisCandidate && contiguous !== undefined) { + contiguous = false; + } + // Move onto the next candidate. + currentCandidate++; + } + } + } + ts.createPatternMatcher = createPatternMatcher; + // Helper function to compare two matches to determine which is better. Matches are first + // ordered by kind (so all prefix matches always beat all substring matches). Then, if the + // match is a camel case match, the relative weights of the match are used to determine + // which is better (with a greater weight being better). Then if the match is of the same + // type, then a case sensitive match is considered better than an insensitive one. + function patternMatchCompareTo(match1, match2) { + return compareType(match1, match2) || + compareCamelCase(match1, match2) || + compareCase(match1, match2) || + comparePunctuation(match1, match2); + } + function comparePunctuation(result1, result2) { + // Consider a match to be better if it was successful without stripping punctuation + // versus a match that had to strip punctuation to succeed. + if (result1.punctuationStripped !== result2.punctuationStripped) { + return result1.punctuationStripped ? 1 : -1; + } + return 0; + } + function compareCase(result1, result2) { + if (result1.isCaseSensitive !== result2.isCaseSensitive) { + return result1.isCaseSensitive ? -1 : 1; + } + return 0; + } + function compareType(result1, result2) { + return result1.kind - result2.kind; + } + function compareCamelCase(result1, result2) { + if (result1.kind === PatternMatchKind.camelCase && result2.kind === PatternMatchKind.camelCase) { + // Swap the values here. If result1 has a higher weight, then we want it to come + // first. + return result2.camelCaseWeight - result1.camelCaseWeight; + } + return 0; + } + function createSegment(text) { + return { + totalTextChunk: createTextChunk(text), + subWordTextChunks: breakPatternIntoTextChunks(text) + }; + } + // A segment is considered invalid if we couldn't find any words in it. + function segmentIsInvalid(segment) { + return segment.subWordTextChunks.length === 0; + } + function isUpperCaseLetter(ch) { + // Fast check for the ascii range. + if (ch >= 65 /* A */ && ch <= 90 /* Z */) { + return true; + } + if (ch < 127 /* maxAsciiCharacter */ || !ts.isUnicodeIdentifierStart(ch, 2 /* Latest */)) { + return false; + } + // TODO: find a way to determine this for any unicode characters in a + // non-allocating manner. + var str = String.fromCharCode(ch); + return str === str.toUpperCase(); + } + function isLowerCaseLetter(ch) { + // Fast check for the ascii range. + if (ch >= 97 /* a */ && ch <= 122 /* z */) { + return true; + } + if (ch < 127 /* maxAsciiCharacter */ || !ts.isUnicodeIdentifierStart(ch, 2 /* Latest */)) { + return false; + } + // TODO: find a way to determine this for any unicode characters in a + // non-allocating manner. + var str = String.fromCharCode(ch); + return str === str.toLowerCase(); + } + function containsUpperCaseLetter(string) { + for (var i = 0, n = string.length; i < n; i++) { + if (isUpperCaseLetter(string.charCodeAt(i))) { + return true; + } + } + return false; + } + function startsWith(string, search) { + for (var i = 0, n = search.length; i < n; i++) { + if (string.charCodeAt(i) !== search.charCodeAt(i)) { + return false; + } + } + return true; + } + // Assumes 'value' is already lowercase. + function indexOfIgnoringCase(string, value) { + for (var i = 0, n = string.length - value.length; i <= n; i++) { + if (startsWithIgnoringCase(string, value, i)) { + return i; + } + } + return -1; + } + // Assumes 'value' is already lowercase. + function startsWithIgnoringCase(string, value, start) { + for (var i = 0, n = value.length; i < n; i++) { + var ch1 = toLowerCase(string.charCodeAt(i + start)); + var ch2 = value.charCodeAt(i); + if (ch1 !== ch2) { + return false; + } + } + return true; + } + function toLowerCase(ch) { + // Fast convert for the ascii range. + if (ch >= 65 /* A */ && ch <= 90 /* Z */) { + return 97 /* a */ + (ch - 65 /* A */); + } + if (ch < 127 /* maxAsciiCharacter */) { + return ch; + } + // TODO: find a way to compute this for any unicode characters in a + // non-allocating manner. + return String.fromCharCode(ch).toLowerCase().charCodeAt(0); + } + function isDigit(ch) { + // TODO(cyrusn): Find a way to support this for unicode digits. + return ch >= 48 /* _0 */ && ch <= 57 /* _9 */; + } + function isWordChar(ch) { + return isUpperCaseLetter(ch) || isLowerCaseLetter(ch) || isDigit(ch) || ch === 95 /* _ */ || ch === 36 /* $ */; + } + function breakPatternIntoTextChunks(pattern) { + var result = []; + var wordStart = 0; + var wordLength = 0; + for (var i = 0; i < pattern.length; i++) { + var ch = pattern.charCodeAt(i); + if (isWordChar(ch)) { + if (wordLength++ === 0) { + wordStart = i; + } + } + else { + if (wordLength > 0) { + result.push(createTextChunk(pattern.substr(wordStart, wordLength))); + wordLength = 0; + } + } + } + if (wordLength > 0) { + result.push(createTextChunk(pattern.substr(wordStart, wordLength))); + } + return result; + } + function createTextChunk(text) { + var textLowerCase = text.toLowerCase(); + return { + text: text, + textLowerCase: textLowerCase, + isLowerCase: text === textLowerCase, + characterSpans: breakIntoCharacterSpans(text) + }; + } + /* @internal */ function breakIntoCharacterSpans(identifier) { + return breakIntoSpans(identifier, /*word:*/ false); + } + ts.breakIntoCharacterSpans = breakIntoCharacterSpans; + /* @internal */ function breakIntoWordSpans(identifier) { + return breakIntoSpans(identifier, /*word:*/ true); + } + ts.breakIntoWordSpans = breakIntoWordSpans; + function breakIntoSpans(identifier, word) { + var result = []; + var wordStart = 0; + for (var i = 1, n = identifier.length; i < n; i++) { + var lastIsDigit = isDigit(identifier.charCodeAt(i - 1)); + var currentIsDigit = isDigit(identifier.charCodeAt(i)); + var hasTransitionFromLowerToUpper = transitionFromLowerToUpper(identifier, word, i); + var hasTransitionFromUpperToLower = transitionFromUpperToLower(identifier, word, i, wordStart); + if (charIsPunctuation(identifier.charCodeAt(i - 1)) || + charIsPunctuation(identifier.charCodeAt(i)) || + lastIsDigit !== currentIsDigit || + hasTransitionFromLowerToUpper || + hasTransitionFromUpperToLower) { + if (!isAllPunctuation(identifier, wordStart, i)) { + result.push(ts.createTextSpan(wordStart, i - wordStart)); + } + wordStart = i; + } + } + if (!isAllPunctuation(identifier, wordStart, identifier.length)) { + result.push(ts.createTextSpan(wordStart, identifier.length - wordStart)); + } + return result; + } + function charIsPunctuation(ch) { + switch (ch) { + case 33 /* exclamation */: + case 34 /* doubleQuote */: + case 35 /* hash */: + case 37 /* percent */: + case 38 /* ampersand */: + case 39 /* singleQuote */: + case 40 /* openParen */: + case 41 /* closeParen */: + case 42 /* asterisk */: + case 44 /* comma */: + case 45 /* minus */: + case 46 /* dot */: + case 47 /* slash */: + case 58 /* colon */: + case 59 /* semicolon */: + case 63 /* question */: + case 64 /* at */: + case 91 /* openBracket */: + case 92 /* backslash */: + case 93 /* closeBracket */: + case 95 /* _ */: + case 123 /* openBrace */: + case 125 /* closeBrace */: + return true; + } + return false; + } + function isAllPunctuation(identifier, start, end) { + for (var i = start; i < end; i++) { + var ch = identifier.charCodeAt(i); + // We don't consider _ or $ as punctuation as there may be things with that name. + if (!charIsPunctuation(ch) || ch === 95 /* _ */ || ch === 36 /* $ */) { + return false; + } + } + return true; + } + function transitionFromUpperToLower(identifier, word, index, wordStart) { + if (word) { + // Cases this supports: + // 1) IDisposable -> I, Disposable + // 2) UIElement -> UI, Element + // 3) HTMLDocument -> HTML, Document + // + // etc. + if (index !== wordStart && + index + 1 < identifier.length) { + var currentIsUpper = isUpperCaseLetter(identifier.charCodeAt(index)); + var nextIsLower = isLowerCaseLetter(identifier.charCodeAt(index + 1)); + if (currentIsUpper && nextIsLower) { + // We have a transition from an upper to a lower letter here. But we only + // want to break if all the letters that preceded are uppercase. i.e. if we + // have "Foo" we don't want to break that into "F, oo". But if we have + // "IFoo" or "UIFoo", then we want to break that into "I, Foo" and "UI, + // Foo". i.e. the last uppercase letter belongs to the lowercase letters + // that follows. Note: this will make the following not split properly: + // "HELLOthere". However, these sorts of names do not show up in .Net + // programs. + for (var i = wordStart; i < index; i++) { + if (!isUpperCaseLetter(identifier.charCodeAt(i))) { + return false; + } + } + return true; + } + } + } + return false; + } + function transitionFromLowerToUpper(identifier, word, index) { + var lastIsUpper = isUpperCaseLetter(identifier.charCodeAt(index - 1)); + var currentIsUpper = isUpperCaseLetter(identifier.charCodeAt(index)); + // See if the casing indicates we're starting a new word. Note: if we're breaking on + // words, then just seeing an upper case character isn't enough. Instead, it has to + // be uppercase and the previous character can't be uppercase. + // + // For example, breaking "AddMetadata" on words would make: Add Metadata + // + // on characters would be: A dd M etadata + // + // Break "AM" on words would be: AM + // + // on characters would be: A M + // + // We break the search string on characters. But we break the symbol name on words. + var transition = word + ? (currentIsUpper && !lastIsUpper) + : currentIsUpper; + return transition; + } +})(ts || (ts = {})); +/// +/* @internal */ +var ts; +(function (ts) { + var SignatureHelp; + (function (SignatureHelp) { + // A partially written generic type expression is not guaranteed to have the correct syntax tree. the expression could be parsed as less than/greater than expression or a comma expression + // or some other combination depending on what the user has typed so far. For the purposes of signature help we need to consider any location after "<" as a possible generic type reference. + // To do this, the method will back parse the expression starting at the position required. it will try to parse the current expression as a generic type expression, if it did succeed it + // will return the generic identifier that started the expression (e.g. "foo" in "foo(#a, b) -> The token introduces a list, and should begin a sig help session + // Case 2: + // fo#o#(a, b)# -> The token is either not associated with a list, or ends a list, so the session should end + // 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 */) { + // 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); + var isTypeArgList = callExpression.typeArguments && callExpression.typeArguments.pos === list.pos; + ts.Debug.assert(list !== undefined); + return { + kind: isTypeArgList ? 0 /* TypeArguments */ : 1 /* CallArguments */, + invocation: callExpression, + argumentsSpan: getApplicableSpanForArguments(list), + argumentIndex: 0, + argumentCount: getArgumentCount(list) + }; + } + // findListItemInfo can return undefined if we are not in parent's argument list + // or type argument list. This includes cases where the cursor is: + // - To the right of the closing paren, non-substitution template, or template tail. + // - Between the type arguments and the arguments (greater than token) + // - On the target of the call (parent.func) + // - On the 'new' keyword in a 'new' expression + var listItemInfo = ts.findListItemInfo(node); + if (listItemInfo) { + var list = listItemInfo.list; + var isTypeArgList = callExpression.typeArguments && callExpression.typeArguments.pos === list.pos; + var argumentIndex = getArgumentIndex(list, node); + var argumentCount = getArgumentCount(list); + ts.Debug.assert(argumentIndex === 0 || argumentIndex < argumentCount, "argumentCount < argumentIndex, " + argumentCount + " < " + argumentIndex); + return { + kind: isTypeArgList ? 0 /* TypeArguments */ : 1 /* CallArguments */, + invocation: callExpression, + argumentsSpan: getApplicableSpanForArguments(list), + argumentIndex: argumentIndex, + argumentCount: argumentCount + }; + } + } + else if (node.kind === 11 /* NoSubstitutionTemplateLiteral */ && node.parent.kind === 170 /* TaggedTemplateExpression */) { + // Check if we're actually inside the template; + // otherwise we'll fall out and return undefined. + if (ts.isInsideTemplateLiteral(node, position)) { + return getArgumentListInfoForTemplate(node.parent, /*argumentIndex*/ 0); + } + } + else if (node.kind === 12 /* TemplateHead */ && node.parent.parent.kind === 170 /* TaggedTemplateExpression */) { + var templateExpression = node.parent; + var tagExpression = templateExpression.parent; + ts.Debug.assert(templateExpression.kind === 183 /* TemplateExpression */); + var argumentIndex = ts.isInsideTemplateLiteral(node, position) ? 0 : 1; + return getArgumentListInfoForTemplate(tagExpression, argumentIndex); + } + else if (node.parent.kind === 190 /* TemplateSpan */ && node.parent.parent.parent.kind === 170 /* TaggedTemplateExpression */) { + var templateSpan = node.parent; + var templateExpression = templateSpan.parent; + var tagExpression = templateExpression.parent; + ts.Debug.assert(templateExpression.kind === 183 /* TemplateExpression */); + // If we're just after a template tail, don't show signature help. + if (node.kind === 14 /* TemplateTail */ && !ts.isInsideTemplateLiteral(node, position)) { + return undefined; + } + var spanIndex = templateExpression.templateSpans.indexOf(templateSpan); + var argumentIndex = getArgumentIndexForTemplatePiece(spanIndex, node); + return getArgumentListInfoForTemplate(tagExpression, argumentIndex); + } + return undefined; + } + function getArgumentIndex(argumentsList, node) { + // The list we got back can include commas. In the presence of errors it may + // also just have nodes without commas. For example "Foo(a b c)" will have 3 + // args without commas. We want to find what index we're at. So we count + // forward until we hit ourselves, only incrementing the index if it isn't a + // comma. + // + // Note: the subtlety around trailing commas (in getArgumentCount) does not apply + // here. That's because we're only walking forward until we hit the node we're + // on. In that case, even if we're after the trailing comma, we'll still see + // that trailing comma in the list, and we'll have generated the appropriate + // arg index. + var argumentIndex = 0; + var listChildren = argumentsList.getChildren(); + for (var _i = 0; _i < listChildren.length; _i++) { + var child = listChildren[_i]; + if (child === node) { + break; + } + if (child.kind !== 24 /* CommaToken */) { + argumentIndex++; + } + } + return argumentIndex; + } + function getArgumentCount(argumentsList) { + // The argument count for a list is normally the number of non-comma children it has. + // For example, if you have "Foo(a,b)" then there will be three children of the arg + // list 'a' '' 'b'. So, in this case the arg count will be 2. However, there + // is a small subtlety. If you have "Foo(a,)", then the child list will just have + // 'a' ''. So, in the case where the last child is a comma, we increase the + // arg count by one to compensate. + // + // Note: this subtlety only applies to the last comma. If you had "Foo(a,," then + // we'll have: 'a' '' '' + // 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 */) { + argumentCount++; + } + return argumentCount; + } + // spanIndex is either the index for a given template span. + // This does not give appropriate results for a NoSubstitutionTemplateLiteral + function getArgumentIndexForTemplatePiece(spanIndex, node) { + // Because the TemplateStringsArray is the first argument, we have to offset each substitution expression by 1. + // There are three cases we can encounter: + // 1. We are precisely in the template literal (argIndex = 0). + // 2. We are in or to the right of the substitution expression (argIndex = spanIndex + 1). + // 3. We are directly to the right of the template literal, but because we look for the token on the left, + // not enough to put us in the substitution expression; we should consider ourselves part of + // the *next* span's expression by offsetting the index (argIndex = (spanIndex + 1) + 1). + // + // Example: f `# abcd $#{# 1 + 1# }# efghi ${ #"#hello"# } # ` + // ^ ^ ^ ^ ^ ^ ^ ^ ^ + // Case: 1 1 3 2 1 3 2 2 1 + ts.Debug.assert(position >= node.getStart(), "Assumed 'position' could not occur before node."); + if (ts.isTemplateLiteralKind(node.kind)) { + if (ts.isInsideTemplateLiteral(node, position)) { + return 0; + } + return spanIndex + 2; + } + return spanIndex + 1; + } + function getArgumentListInfoForTemplate(tagExpression, argumentIndex) { + // argumentCount is either 1 or (numSpans + 1) to account for the template strings array argument. + var argumentCount = tagExpression.template.kind === 11 /* NoSubstitutionTemplateLiteral */ + ? 1 + : tagExpression.template.templateSpans.length + 1; + ts.Debug.assert(argumentIndex === 0 || argumentIndex < argumentCount, "argumentCount < argumentIndex, " + argumentCount + " < " + argumentIndex); + return { + kind: 2 /* TaggedTemplateArguments */, + invocation: tagExpression, + argumentsSpan: getApplicableSpanForTaggedTemplate(tagExpression), + argumentIndex: argumentIndex, + argumentCount: argumentCount + }; + } + function getApplicableSpanForArguments(argumentsList) { + // We use full start and skip trivia on the end because we want to include trivia on + // both sides. For example, + // + // foo( /*comment */ a, b, c /*comment*/ ) + // | | + // + // The applicable span is from the first bar to the second bar (inclusive, + // but not including parentheses) + var applicableSpanStart = argumentsList.getFullStart(); + var applicableSpanEnd = ts.skipTrivia(sourceFile.text, argumentsList.getEnd(), /*stopAfterLineBreak*/ false); + return ts.createTextSpan(applicableSpanStart, applicableSpanEnd - applicableSpanStart); + } + function getApplicableSpanForTaggedTemplate(taggedTemplate) { + var template = taggedTemplate.template; + var applicableSpanStart = template.getStart(); + var applicableSpanEnd = template.getEnd(); + // We need to adjust the end position for the case where the template does not have a tail. + // Otherwise, we will not show signature help past the expression. + // For example, + // + // ` ${ 1 + 1 foo(10) + // | | + // + // 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 === 183 /* TemplateExpression */) { + var lastSpan = ts.lastOrUndefined(template.templateSpans); + if (lastSpan.literal.getFullWidth() === 0) { + applicableSpanEnd = ts.skipTrivia(sourceFile.text, applicableSpanEnd, /*stopAfterLineBreak*/ false); + } + } + return ts.createTextSpan(applicableSpanStart, applicableSpanEnd - applicableSpanStart); + } + function getContainingArgumentInfo(node) { + for (var n = node; n.kind !== 248 /* SourceFile */; n = n.parent) { + if (ts.isFunctionBlock(n)) { + return undefined; + } + // If the node is not a subspan of its parent, this is a big problem. + // There have been crashes that might be caused by this violation. + if (n.pos < n.parent.pos || n.end > n.parent.end) { + ts.Debug.fail("Node of kind " + n.kind + " is not a subspan of its parent of kind " + n.parent.kind); + } + var argumentInfo_1 = getImmediatelyContainingArgumentInfo(n); + if (argumentInfo_1) { + return argumentInfo_1; + } + } + return undefined; + } + function getChildListThatStartsWithOpenerToken(parent, openerToken, sourceFile) { + var children = parent.getChildren(sourceFile); + var indexOfOpenerToken = children.indexOf(openerToken); + ts.Debug.assert(indexOfOpenerToken >= 0 && children.length > indexOfOpenerToken + 1); + return children[indexOfOpenerToken + 1]; + } + /** + * The selectedItemIndex could be negative for several reasons. + * 1. There are too many arguments for all of the overloads + * 2. None of the overloads were type compatible + * The solution here is to try to pick the best overload by picking + * either the first one that has an appropriate number of parameters, + * or the one with the most parameters. + */ + function selectBestInvalidOverloadIndex(candidates, argumentCount) { + var maxParamsSignatureIndex = -1; + var maxParams = -1; + for (var i = 0; i < candidates.length; i++) { + var candidate = candidates[i]; + if (candidate.hasRestParameter || candidate.parameters.length >= argumentCount) { + return i; + } + if (candidate.parameters.length > maxParams) { + maxParams = candidate.parameters.length; + maxParamsSignatureIndex = i; + } + } + return maxParamsSignatureIndex; + } + function createSignatureHelpItems(candidates, bestSignature, argumentListInfo) { + var applicableSpan = argumentListInfo.argumentsSpan; + var isTypeParameterList = argumentListInfo.kind === 0 /* TypeArguments */; + var invocation = argumentListInfo.invocation; + var callTarget = ts.getInvokedExpression(invocation); + var callTargetSymbol = typeChecker.getSymbolAtLocation(callTarget); + var callTargetDisplayParts = callTargetSymbol && ts.symbolToDisplayParts(typeChecker, callTargetSymbol, /*enclosingDeclaration*/ undefined, /*meaning*/ undefined); + var items = ts.map(candidates, function (candidateSignature) { + var signatureHelpParameters; + var prefixDisplayParts = []; + var suffixDisplayParts = []; + if (callTargetDisplayParts) { + ts.addRange(prefixDisplayParts, callTargetDisplayParts); + } + if (isTypeParameterList) { + prefixDisplayParts.push(ts.punctuationPart(25 /* LessThanToken */)); + var typeParameters = candidateSignature.typeParameters; + signatureHelpParameters = typeParameters && typeParameters.length > 0 ? ts.map(typeParameters, createSignatureHelpParameterForTypeParameter) : emptyArray; + suffixDisplayParts.push(ts.punctuationPart(27 /* GreaterThanToken */)); + var parameterParts = ts.mapToDisplayParts(function (writer) { + return typeChecker.getSymbolDisplayBuilder().buildDisplayForParametersAndDelimiters(candidateSignature.parameters, writer, invocation); + }); + ts.addRange(suffixDisplayParts, parameterParts); + } + else { + var typeParameterParts = ts.mapToDisplayParts(function (writer) { + return typeChecker.getSymbolDisplayBuilder().buildDisplayForTypeParametersAndDelimiters(candidateSignature.typeParameters, writer, invocation); + }); + ts.addRange(prefixDisplayParts, typeParameterParts); + prefixDisplayParts.push(ts.punctuationPart(17 /* OpenParenToken */)); + var parameters = candidateSignature.parameters; + signatureHelpParameters = parameters.length > 0 ? ts.map(parameters, createSignatureHelpParameterForParameter) : emptyArray; + suffixDisplayParts.push(ts.punctuationPart(18 /* CloseParenToken */)); + } + var returnTypeParts = ts.mapToDisplayParts(function (writer) { + return typeChecker.getSymbolDisplayBuilder().buildReturnTypeDisplay(candidateSignature, writer, invocation); + }); + ts.addRange(suffixDisplayParts, returnTypeParts); + return { + isVariadic: candidateSignature.hasRestParameter, + prefixDisplayParts: prefixDisplayParts, + suffixDisplayParts: suffixDisplayParts, + separatorDisplayParts: [ts.punctuationPart(24 /* CommaToken */), ts.spacePart()], + parameters: signatureHelpParameters, + documentation: candidateSignature.getDocumentationComment() + }; + }); + var argumentIndex = argumentListInfo.argumentIndex; + // argumentCount is the *apparent* number of arguments. + var argumentCount = argumentListInfo.argumentCount; + var selectedItemIndex = candidates.indexOf(bestSignature); + if (selectedItemIndex < 0) { + selectedItemIndex = selectBestInvalidOverloadIndex(candidates, argumentCount); + } + ts.Debug.assert(argumentIndex === 0 || argumentIndex < argumentCount, "argumentCount < argumentIndex, " + argumentCount + " < " + argumentIndex); + return { + items: items, + applicableSpan: applicableSpan, + selectedItemIndex: selectedItemIndex, + argumentIndex: argumentIndex, + argumentCount: argumentCount + }; + function createSignatureHelpParameterForParameter(parameter) { + var displayParts = ts.mapToDisplayParts(function (writer) { + return typeChecker.getSymbolDisplayBuilder().buildParameterDisplay(parameter, writer, invocation); + }); + return { + name: parameter.name, + documentation: parameter.getDocumentationComment(), + displayParts: displayParts, + isOptional: typeChecker.isOptionalParameter(parameter.valueDeclaration) + }; + } + function createSignatureHelpParameterForTypeParameter(typeParameter) { + var displayParts = ts.mapToDisplayParts(function (writer) { + return typeChecker.getSymbolDisplayBuilder().buildTypeParameterDisplay(typeParameter, writer, invocation); + }); + return { + name: typeParameter.symbol.name, + documentation: emptyArray, + displayParts: displayParts, + isOptional: false + }; + } + } + } + SignatureHelp.getSignatureHelpItems = getSignatureHelpItems; + })(SignatureHelp = ts.SignatureHelp || (ts.SignatureHelp = {})); +})(ts || (ts = {})); +// These utilities are common to multiple language service features. +/* @internal */ +var ts; +(function (ts) { + function getEndLinePosition(line, sourceFile) { + ts.Debug.assert(line >= 0); + var lineStarts = sourceFile.getLineStarts(); + var lineIndex = line; + if (lineIndex + 1 === lineStarts.length) { + // last line - return EOF + return sourceFile.text.length - 1; + } + else { + // current line start + var start = lineStarts[lineIndex]; + // take the start position of the next line -1 = it should be some line break + var pos = lineStarts[lineIndex + 1] - 1; + ts.Debug.assert(ts.isLineBreak(sourceFile.text.charCodeAt(pos))); + // walk backwards skipping line breaks, stop the the beginning of current line. + // i.e: + // + // $ <- end of line for this position should match the start position + while (start <= pos && ts.isLineBreak(sourceFile.text.charCodeAt(pos))) { + pos--; + } + return pos; + } + } + ts.getEndLinePosition = getEndLinePosition; + function getLineStartPositionForPosition(position, sourceFile) { + var lineStarts = sourceFile.getLineStarts(); + var line = sourceFile.getLineAndCharacterOfPosition(position).line; + return lineStarts[line]; + } + ts.getLineStartPositionForPosition = getLineStartPositionForPosition; + function rangeContainsRange(r1, r2) { + return startEndContainsRange(r1.pos, r1.end, r2); + } + ts.rangeContainsRange = rangeContainsRange; + function startEndContainsRange(start, end, range) { + return start <= range.pos && end >= range.end; + } + ts.startEndContainsRange = startEndContainsRange; + function rangeContainsStartEnd(range, start, end) { + return range.pos <= start && range.end >= end; + } + ts.rangeContainsStartEnd = rangeContainsStartEnd; + function rangeOverlapsWithStartEnd(r1, start, end) { + return startEndOverlapsWithStartEnd(r1.pos, r1.end, start, end); + } + ts.rangeOverlapsWithStartEnd = rangeOverlapsWithStartEnd; + function startEndOverlapsWithStartEnd(start1, end1, start2, end2) { + var start = Math.max(start1, start2); + var end = Math.min(end1, end2); + return start < end; + } + ts.startEndOverlapsWithStartEnd = startEndOverlapsWithStartEnd; + function positionBelongsToNode(candidate, position, sourceFile) { + return candidate.end > position || !isCompletedNode(candidate, sourceFile); + } + ts.positionBelongsToNode = positionBelongsToNode; + function isCompletedNode(n, sourceFile) { + if (ts.nodeIsMissing(n)) { + return false; + } + switch (n.kind) { + case 214 /* ClassDeclaration */: + case 215 /* InterfaceDeclaration */: + case 217 /* EnumDeclaration */: + case 165 /* ObjectLiteralExpression */: + case 161 /* ObjectBindingPattern */: + case 155 /* TypeLiteral */: + case 192 /* Block */: + case 219 /* ModuleBlock */: + case 220 /* CaseBlock */: + return nodeEndsWith(n, 16 /* CloseBraceToken */, sourceFile); + case 244 /* CatchClause */: + return isCompletedNode(n.block, sourceFile); + case 169 /* NewExpression */: + if (!n.arguments) { + return true; + } + // fall through + case 168 /* CallExpression */: + case 172 /* ParenthesizedExpression */: + case 160 /* ParenthesizedType */: + return nodeEndsWith(n, 18 /* CloseParenToken */, sourceFile); + case 152 /* FunctionType */: + case 153 /* ConstructorType */: + return isCompletedNode(n.type, sourceFile); + case 144 /* Constructor */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: + case 213 /* FunctionDeclaration */: + case 173 /* FunctionExpression */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: + case 148 /* ConstructSignature */: + case 147 /* CallSignature */: + case 174 /* ArrowFunction */: + if (n.body) { + return isCompletedNode(n.body, sourceFile); + } + if (n.type) { + return isCompletedNode(n.type, sourceFile); + } + // 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 218 /* ModuleDeclaration */: + return n.body && isCompletedNode(n.body, sourceFile); + case 196 /* IfStatement */: + if (n.elseStatement) { + return isCompletedNode(n.elseStatement, sourceFile); + } + return isCompletedNode(n.thenStatement, sourceFile); + case 195 /* ExpressionStatement */: + return isCompletedNode(n.expression, sourceFile) || + hasChildOfKind(n, 23 /* SemicolonToken */); + case 164 /* ArrayLiteralExpression */: + case 162 /* ArrayBindingPattern */: + case 167 /* ElementAccessExpression */: + case 136 /* ComputedPropertyName */: + case 157 /* TupleType */: + return nodeEndsWith(n, 20 /* CloseBracketToken */, sourceFile); + case 149 /* IndexSignature */: + if (n.type) { + return isCompletedNode(n.type, sourceFile); + } + return hasChildOfKind(n, 20 /* CloseBracketToken */, sourceFile); + case 241 /* CaseClause */: + case 242 /* DefaultClause */: + // there is no such thing as terminator token for CaseClause/DefaultClause so for simplicitly always consider them non-completed + return false; + case 199 /* ForStatement */: + case 200 /* ForInStatement */: + case 201 /* ForOfStatement */: + case 198 /* WhileStatement */: + return isCompletedNode(n.statement, sourceFile); + case 197 /* 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); + if (hasWhileKeyword) { + return nodeEndsWith(n, 18 /* CloseParenToken */, sourceFile); + } + return isCompletedNode(n.statement, sourceFile); + case 154 /* TypeQuery */: + return isCompletedNode(n.exprName, sourceFile); + case 176 /* TypeOfExpression */: + case 175 /* DeleteExpression */: + case 177 /* VoidExpression */: + case 184 /* YieldExpression */: + case 185 /* SpreadElementExpression */: + var unaryWordExpression = n; + return isCompletedNode(unaryWordExpression.expression, sourceFile); + case 170 /* TaggedTemplateExpression */: + return isCompletedNode(n.template, sourceFile); + case 183 /* TemplateExpression */: + var lastSpan = ts.lastOrUndefined(n.templateSpans); + return isCompletedNode(lastSpan, sourceFile); + case 190 /* TemplateSpan */: + return ts.nodeIsPresent(n.literal); + case 179 /* PrefixUnaryExpression */: + return isCompletedNode(n.operand, sourceFile); + case 181 /* BinaryExpression */: + return isCompletedNode(n.right, sourceFile); + case 182 /* ConditionalExpression */: + return isCompletedNode(n.whenFalse, sourceFile); + default: + return true; + } + } + ts.isCompletedNode = isCompletedNode; + /* + * Checks if node ends with 'expectedLastToken'. + * If child at position 'length - 1' is 'SemicolonToken' it is skipped and 'expectedLastToken' is compared with child at position 'length - 2'. + */ + function nodeEndsWith(n, expectedLastToken, sourceFile) { + var children = n.getChildren(sourceFile); + if (children.length) { + var last = ts.lastOrUndefined(children); + if (last.kind === expectedLastToken) { + return true; + } + else if (last.kind === 23 /* SemicolonToken */ && children.length !== 1) { + return children[children.length - 2].kind === expectedLastToken; + } + } + return false; + } + function findListItemInfo(node) { + var list = findContainingList(node); + // It is possible at this point for syntaxList to be undefined, either if + // node.parent had no list child, or if none of its list children contained + // the span of node. If this happens, return undefined. The caller should + // handle this case. + if (!list) { + return undefined; + } + var children = list.getChildren(); + var listItemIndex = ts.indexOf(children, node); + return { + listItemIndex: listItemIndex, + list: list + }; + } + ts.findListItemInfo = findListItemInfo; + function hasChildOfKind(n, kind, sourceFile) { + return !!findChildOfKind(n, kind, sourceFile); + } + ts.hasChildOfKind = hasChildOfKind; + function findChildOfKind(n, kind, sourceFile) { + return ts.forEach(n.getChildren(sourceFile), function (c) { return c.kind === kind && c; }); + } + ts.findChildOfKind = findChildOfKind; + function findContainingList(node) { + // The node might be a list element (nonsynthetic) or a comma (synthetic). Either way, it will + // be parented by the container of the SyntaxList, not the SyntaxList itself. + // In order to find the list item index, we first need to locate SyntaxList itself and then search + // for the position of the relevant node (or comma). + var syntaxList = ts.forEach(node.parent.getChildren(), function (c) { + // find syntax list that covers the span of the node + if (c.kind === 271 /* SyntaxList */ && c.pos <= node.pos && c.end >= node.end) { + return c; + } + }); + // Either we didn't find an appropriate list, or the list must contain us. + ts.Debug.assert(!syntaxList || ts.contains(syntaxList.getChildren(), node)); + return syntaxList; + } + ts.findContainingList = findContainingList; + /* Gets the token whose text has range [start, end) and + * position >= start and (position < end or (position === end && token is keyword or identifier)) + */ + function getTouchingWord(sourceFile, position) { + return getTouchingToken(sourceFile, position, function (n) { return isWord(n.kind); }); + } + ts.getTouchingWord = getTouchingWord; + /* Gets the token whose text has range [start, end) and position >= start + * and (position < end or (position === end && token is keyword or identifier or numeric\string litera)) + */ + function getTouchingPropertyName(sourceFile, position) { + return getTouchingToken(sourceFile, position, function (n) { return isPropertyName(n.kind); }); + } + ts.getTouchingPropertyName = getTouchingPropertyName; + /** Returns the token if position is in [start, end) or if position === end and includeItemAtEndPosition(token) === true */ + function getTouchingToken(sourceFile, position, includeItemAtEndPosition) { + return getTokenAtPositionWorker(sourceFile, position, /*allowPositionInLeadingTrivia*/ false, includeItemAtEndPosition); + } + ts.getTouchingToken = getTouchingToken; + /** Returns a token if position is in [start-of-leading-trivia, end) */ + function getTokenAtPosition(sourceFile, position) { + return getTokenAtPositionWorker(sourceFile, position, /*allowPositionInLeadingTrivia*/ true, /*includeItemAtEndPosition*/ undefined); + } + ts.getTokenAtPosition = getTokenAtPosition; + /** Get the token whose text contains the position */ + function getTokenAtPositionWorker(sourceFile, position, allowPositionInLeadingTrivia, includeItemAtEndPosition) { + var current = sourceFile; + outer: while (true) { + if (isToken(current)) { + // exit early + return current; + } + // find the child that contains 'position' + for (var i = 0, n = current.getChildCount(sourceFile); i < n; i++) { + var child = current.getChildAt(i); + var start = allowPositionInLeadingTrivia ? child.getFullStart() : child.getStart(sourceFile); + if (start <= position) { + var end = child.getEnd(); + if (position < end || (position === end && child.kind === 1 /* EndOfFileToken */)) { + current = child; + continue outer; + } + else if (includeItemAtEndPosition && end === position) { + var previousToken = findPrecedingToken(position, sourceFile, child); + if (previousToken && includeItemAtEndPosition(previousToken)) { + return previousToken; + } + } + } + } + return current; + } + } + /** + * The token on the left of the position is the token that strictly includes the position + * or sits to the left of the cursor if it is on a boundary. For example + * + * fo|o -> will return foo + * foo |bar -> will return foo + * + */ + function findTokenOnLeftOfPosition(file, position) { + // Ideally, getTokenAtPosition should return a token. However, it is currently + // broken, so we do a check to make sure the result was indeed a token. + var tokenAtPosition = getTokenAtPosition(file, position); + if (isToken(tokenAtPosition) && position > tokenAtPosition.getStart(file) && position < tokenAtPosition.getEnd()) { + return tokenAtPosition; + } + return findPrecedingToken(position, file); + } + ts.findTokenOnLeftOfPosition = findTokenOnLeftOfPosition; + function findNextToken(previousToken, parent) { + return find(parent); + function find(n) { + if (isToken(n) && n.pos === previousToken.end) { + // this is token that starts at the end of previous token - return it + return n; + } + var children = n.getChildren(); + for (var _i = 0; _i < children.length; _i++) { + var child = children[_i]; + var shouldDiveInChildNode = + // previous token is enclosed somewhere in the child + (child.pos <= previousToken.pos && child.end > previousToken.end) || + // previous token ends exactly at the beginning of child + (child.pos === previousToken.end); + if (shouldDiveInChildNode && nodeHasTokens(child)) { + return find(child); + } + } + return undefined; + } + } + ts.findNextToken = findNextToken; + function findPrecedingToken(position, sourceFile, startNode) { + return find(startNode || sourceFile); + function findRightmostToken(n) { + if (isToken(n) || n.kind === 236 /* JsxText */) { + return n; + } + var children = n.getChildren(); + var candidate = findRightmostChildNodeWithTokens(children, /*exclusiveStartPosition*/ children.length); + return candidate && findRightmostToken(candidate); + } + function find(n) { + if (isToken(n) || n.kind === 236 /* JsxText */) { + return n; + } + var children = n.getChildren(); + for (var i = 0, len = children.length; i < len; i++) { + var child = children[i]; + // condition 'position < child.end' checks if child node end after the position + // in the example below this condition will be false for 'aaaa' and 'bbbb' and true for 'ccc' + // aaaa___bbbb___$__ccc + // after we found child node with end after the position we check if start of the node is after the position. + // if yes - then position is in the trivia and we need to look into the previous child to find the token in question. + // 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 === 236 /* JsxText */)) { + var start = child.getStart(sourceFile); + var lookInPreviousChild = (start >= position) || + (child.kind === 236 /* JsxText */ && start === child.end); // whitespace only JsxText + if (lookInPreviousChild) { + // actual start of the node is past the position - previous token should be at the end of previous child + var candidate = findRightmostChildNodeWithTokens(children, /*exclusiveStartPosition*/ i); + return candidate && findRightmostToken(candidate); + } + else { + // candidate should be in this node + return find(child); + } + } + } + ts.Debug.assert(startNode !== undefined || n.kind === 248 /* SourceFile */); + // Here we know that none of child token nodes embrace the position, + // the only known case is when position is at the end of the file. + // Try to find the rightmost token in the file without filtering. + // Namely we are skipping the check: 'position < node.end' + if (children.length) { + var candidate = findRightmostChildNodeWithTokens(children, /*exclusiveStartPosition*/ children.length); + return candidate && findRightmostToken(candidate); + } + } + /// finds last node that is considered as candidate for search (isCandidate(node) === true) starting from 'exclusiveStartPosition' + function findRightmostChildNodeWithTokens(children, exclusiveStartPosition) { + for (var i = exclusiveStartPosition - 1; i >= 0; --i) { + if (nodeHasTokens(children[i])) { + return children[i]; + } + } + } + } + ts.findPrecedingToken = findPrecedingToken; + function isInString(sourceFile, position) { + var token = getTokenAtPosition(sourceFile, position); + return token && token.kind === 9 /* StringLiteral */ && position > token.getStart(); + } + ts.isInString = isInString; + function isInComment(sourceFile, position) { + return isInCommentHelper(sourceFile, position, /*predicate*/ undefined); + } + ts.isInComment = isInComment; + /** + * Returns true if the cursor at position in sourceFile is within a comment that additionally + * satisfies predicate, and false otherwise. + */ + function isInCommentHelper(sourceFile, position, predicate) { + var token = getTokenAtPosition(sourceFile, position); + if (token && position <= token.getStart()) { + var commentRanges = ts.getLeadingCommentRanges(sourceFile.text, token.pos); + // The end marker of a single-line comment does not include the newline character. + // In the following case, we are inside a comment (^ denotes the cursor position): + // + // // asdf ^\n + // + // But for multi-line comments, we don't want to be inside the comment in the following case: + // + // /* asdf */^ + // + // Internally, we represent the end of the comment at the newline and closing '/', respectively. + return predicate ? + ts.forEach(commentRanges, function (c) { return c.pos < position && + (c.kind == 2 /* SingleLineCommentTrivia */ ? position <= c.end : position < c.end) && + predicate(c); }) : + ts.forEach(commentRanges, function (c) { return c.pos < position && + (c.kind == 2 /* SingleLineCommentTrivia */ ? position <= c.end : position < c.end); }); + } + return false; + } + ts.isInCommentHelper = isInCommentHelper; + function hasDocComment(sourceFile, position) { + var token = getTokenAtPosition(sourceFile, position); + // First, we have to see if this position actually landed in a comment. + var commentRanges = ts.getLeadingCommentRanges(sourceFile.text, token.pos); + return ts.forEach(commentRanges, jsDocPrefix); + function jsDocPrefix(c) { + var text = sourceFile.text; + return text.length >= c.pos + 3 && text[c.pos] === '/' && text[c.pos + 1] === '*' && text[c.pos + 2] === '*'; + } + } + ts.hasDocComment = hasDocComment; + /** + * Get the corresponding JSDocTag node if the position is in a jsDoc comment + */ + function getJsDocTagAtPosition(sourceFile, position) { + var node = ts.getTokenAtPosition(sourceFile, position); + if (isToken(node)) { + switch (node.kind) { + case 102 /* VarKeyword */: + case 108 /* LetKeyword */: + case 74 /* ConstKeyword */: + // if the current token is var, let or const, skip the VariableDeclarationList + node = node.parent === undefined ? undefined : node.parent.parent; + break; + default: + node = node.parent; + break; + } + } + if (node) { + var jsDocComment = node.jsDocComment; + if (jsDocComment) { + for (var _i = 0, _a = jsDocComment.tags; _i < _a.length; _i++) { + var tag = _a[_i]; + if (tag.pos <= position && position <= tag.end) { + return tag; + } + } + } + } + return undefined; + } + ts.getJsDocTagAtPosition = getJsDocTagAtPosition; + function nodeHasTokens(n) { + // If we have a token or node that has a non-zero width, it must have tokens. + // Note, that getWidth() does not take trivia into account. + return n.getWidth() !== 0; + } + function getNodeModifiers(node) { + var flags = ts.getCombinedNodeFlags(node); + var result = []; + if (flags & 32 /* Private */) + result.push(ts.ScriptElementKindModifier.privateMemberModifier); + if (flags & 64 /* Protected */) + result.push(ts.ScriptElementKindModifier.protectedMemberModifier); + if (flags & 16 /* Public */) + result.push(ts.ScriptElementKindModifier.publicMemberModifier); + if (flags & 128 /* Static */) + result.push(ts.ScriptElementKindModifier.staticModifier); + if (flags & 256 /* Abstract */) + result.push(ts.ScriptElementKindModifier.abstractModifier); + if (flags & 1 /* Export */) + result.push(ts.ScriptElementKindModifier.exportedModifier); + if (ts.isInAmbientContext(node)) + result.push(ts.ScriptElementKindModifier.ambientModifier); + return result.length > 0 ? result.join(',') : ts.ScriptElementKindModifier.none; + } + ts.getNodeModifiers = getNodeModifiers; + function getTypeArgumentOrTypeParameterList(node) { + if (node.kind === 151 /* TypeReference */ || node.kind === 168 /* CallExpression */) { + return node.typeArguments; + } + if (ts.isFunctionLike(node) || node.kind === 214 /* ClassDeclaration */ || node.kind === 215 /* InterfaceDeclaration */) { + return node.typeParameters; + } + return undefined; + } + ts.getTypeArgumentOrTypeParameterList = getTypeArgumentOrTypeParameterList; + function isToken(n) { + return n.kind >= 0 /* FirstToken */ && n.kind <= 134 /* LastToken */; + } + ts.isToken = isToken; + function isWord(kind) { + return kind === 69 /* Identifier */ || ts.isKeyword(kind); + } + ts.isWord = isWord; + function isPropertyName(kind) { + return kind === 9 /* StringLiteral */ || kind === 8 /* NumericLiteral */ || isWord(kind); + } + function isComment(kind) { + return kind === 2 /* SingleLineCommentTrivia */ || kind === 3 /* MultiLineCommentTrivia */; + } + ts.isComment = isComment; + function isStringOrRegularExpressionOrTemplateLiteral(kind) { + if (kind === 9 /* StringLiteral */ + || kind === 10 /* RegularExpressionLiteral */ + || ts.isTemplateLiteralKind(kind)) { + return true; + } + return false; + } + ts.isStringOrRegularExpressionOrTemplateLiteral = isStringOrRegularExpressionOrTemplateLiteral; + function isPunctuation(kind) { + return 15 /* FirstPunctuation */ <= kind && kind <= 68 /* LastPunctuation */; + } + ts.isPunctuation = isPunctuation; + function isInsideTemplateLiteral(node, position) { + return ts.isTemplateLiteralKind(node.kind) + && (node.getStart() < position && position < node.getEnd()) || (!!node.isUnterminated && position === node.getEnd()); + } + ts.isInsideTemplateLiteral = isInsideTemplateLiteral; + function isAccessibilityModifier(kind) { + switch (kind) { + case 112 /* PublicKeyword */: + case 110 /* PrivateKeyword */: + case 111 /* ProtectedKeyword */: + return true; + } + return false; + } + ts.isAccessibilityModifier = isAccessibilityModifier; + function compareDataObjects(dst, src) { + for (var e in dst) { + if (typeof dst[e] === "object") { + if (!compareDataObjects(dst[e], src[e])) { + return false; + } + } + else if (typeof dst[e] !== "function") { + if (dst[e] !== src[e]) { + return false; + } + } + } + return true; + } + ts.compareDataObjects = compareDataObjects; +})(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 === 138 /* Parameter */; + } + ts.isFirstDeclarationOfSymbolParameter = isFirstDeclarationOfSymbolParameter; + var displayPartWriter = getDisplayPartWriter(); + function getDisplayPartWriter() { + var displayParts; + var lineStart; + var indent; + resetWriter(); + return { + displayParts: function () { return displayParts; }, + writeKeyword: function (text) { return writeKind(text, ts.SymbolDisplayPartKind.keyword); }, + writeOperator: function (text) { return writeKind(text, ts.SymbolDisplayPartKind.operator); }, + writePunctuation: function (text) { return writeKind(text, ts.SymbolDisplayPartKind.punctuation); }, + writeSpace: function (text) { return writeKind(text, ts.SymbolDisplayPartKind.space); }, + writeStringLiteral: function (text) { return writeKind(text, ts.SymbolDisplayPartKind.stringLiteral); }, + writeParameter: function (text) { return writeKind(text, ts.SymbolDisplayPartKind.parameterName); }, + writeSymbol: writeSymbol, + writeLine: writeLine, + increaseIndent: function () { indent++; }, + decreaseIndent: function () { indent--; }, + clear: resetWriter, + trackSymbol: function () { }, + reportInaccessibleThisError: function () { } + }; + function writeIndent() { + if (lineStart) { + var indentString = ts.getIndentString(indent); + if (indentString) { + displayParts.push(displayPart(indentString, ts.SymbolDisplayPartKind.space)); + } + lineStart = false; + } + } + function writeKind(text, kind) { + writeIndent(); + displayParts.push(displayPart(text, kind)); + } + function writeSymbol(text, symbol) { + writeIndent(); + displayParts.push(symbolPart(text, symbol)); + } + function writeLine() { + displayParts.push(lineBreakPart()); + lineStart = true; + } + function resetWriter() { + displayParts = []; + lineStart = true; + indent = 0; + } + } + function symbolPart(text, symbol) { + return displayPart(text, displayPartKind(symbol), symbol); + function displayPartKind(symbol) { + var flags = symbol.flags; + if (flags & 3 /* Variable */) { + return isFirstDeclarationOfSymbolParameter(symbol) ? ts.SymbolDisplayPartKind.parameterName : ts.SymbolDisplayPartKind.localName; + } + else if (flags & 4 /* Property */) { + return ts.SymbolDisplayPartKind.propertyName; + } + else if (flags & 32768 /* GetAccessor */) { + return ts.SymbolDisplayPartKind.propertyName; + } + else if (flags & 65536 /* SetAccessor */) { + return ts.SymbolDisplayPartKind.propertyName; + } + else if (flags & 8 /* EnumMember */) { + return ts.SymbolDisplayPartKind.enumMemberName; + } + else if (flags & 16 /* Function */) { + return ts.SymbolDisplayPartKind.functionName; + } + else if (flags & 32 /* Class */) { + return ts.SymbolDisplayPartKind.className; + } + else if (flags & 64 /* Interface */) { + return ts.SymbolDisplayPartKind.interfaceName; + } + else if (flags & 384 /* Enum */) { + return ts.SymbolDisplayPartKind.enumName; + } + else if (flags & 1536 /* Module */) { + return ts.SymbolDisplayPartKind.moduleName; + } + else if (flags & 8192 /* Method */) { + return ts.SymbolDisplayPartKind.methodName; + } + else if (flags & 262144 /* TypeParameter */) { + return ts.SymbolDisplayPartKind.typeParameterName; + } + else if (flags & 524288 /* TypeAlias */) { + return ts.SymbolDisplayPartKind.aliasName; + } + else if (flags & 8388608 /* Alias */) { + return ts.SymbolDisplayPartKind.aliasName; + } + return ts.SymbolDisplayPartKind.text; + } + } + ts.symbolPart = symbolPart; + function displayPart(text, kind, symbol) { + return { + text: text, + kind: ts.SymbolDisplayPartKind[kind] + }; + } + ts.displayPart = displayPart; + function spacePart() { + return displayPart(" ", ts.SymbolDisplayPartKind.space); + } + ts.spacePart = spacePart; + function keywordPart(kind) { + return displayPart(ts.tokenToString(kind), ts.SymbolDisplayPartKind.keyword); + } + ts.keywordPart = keywordPart; + function punctuationPart(kind) { + return displayPart(ts.tokenToString(kind), ts.SymbolDisplayPartKind.punctuation); + } + ts.punctuationPart = punctuationPart; + function operatorPart(kind) { + return displayPart(ts.tokenToString(kind), ts.SymbolDisplayPartKind.operator); + } + ts.operatorPart = operatorPart; + function textOrKeywordPart(text) { + var kind = ts.stringToToken(text); + return kind === undefined + ? textPart(text) + : keywordPart(kind); + } + ts.textOrKeywordPart = textOrKeywordPart; + function textPart(text) { + return displayPart(text, ts.SymbolDisplayPartKind.text); + } + ts.textPart = textPart; + var carriageReturnLineFeed = "\r\n"; + /** + * The default is CRLF. + */ + function getNewLineOrDefaultFromHost(host) { + return host.getNewLine ? host.getNewLine() : carriageReturnLineFeed; + } + ts.getNewLineOrDefaultFromHost = getNewLineOrDefaultFromHost; + function lineBreakPart() { + return displayPart("\n", ts.SymbolDisplayPartKind.lineBreak); + } + ts.lineBreakPart = lineBreakPart; + function mapToDisplayParts(writeDisplayParts) { + writeDisplayParts(displayPartWriter); + var result = displayPartWriter.displayParts(); + displayPartWriter.clear(); + return result; + } + ts.mapToDisplayParts = mapToDisplayParts; + function typeToDisplayParts(typechecker, type, enclosingDeclaration, flags) { + return mapToDisplayParts(function (writer) { + typechecker.getSymbolDisplayBuilder().buildTypeDisplay(type, writer, enclosingDeclaration, flags); + }); + } + ts.typeToDisplayParts = typeToDisplayParts; + function symbolToDisplayParts(typeChecker, symbol, enclosingDeclaration, meaning, flags) { + return mapToDisplayParts(function (writer) { + typeChecker.getSymbolDisplayBuilder().buildSymbolDisplay(symbol, writer, enclosingDeclaration, meaning, flags); + }); + } + ts.symbolToDisplayParts = symbolToDisplayParts; + function signatureToDisplayParts(typechecker, signature, enclosingDeclaration, flags) { + return mapToDisplayParts(function (writer) { + typechecker.getSymbolDisplayBuilder().buildSignatureDisplay(signature, writer, enclosingDeclaration, flags); + }); + } + ts.signatureToDisplayParts = signatureToDisplayParts; + function getDeclaredName(typeChecker, 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 is under the cursor. + if (isImportOrExportSpecifierName(location)) { + return location.getText(); + } + // Try to get the local symbol if we're dealing with an 'export default' + // since that symbol has the "true" name. + var localExportDefaultSymbol = ts.getLocalSymbolForExportDefault(symbol); + var name = typeChecker.symbolToString(localExportDefaultSymbol || symbol); + return name; + } + ts.getDeclaredName = getDeclaredName; + function isImportOrExportSpecifierName(location) { + return location.parent && + (location.parent.kind === 226 /* ImportSpecifier */ || location.parent.kind === 230 /* ExportSpecifier */) && + location.parent.propertyName === location; + } + ts.isImportOrExportSpecifierName = isImportOrExportSpecifierName; + /** + * Strip off existed single quotes or double quotes from a given string + * + * @return non-quoted string + */ + function stripQuotes(name) { + var length = name.length; + if (length >= 2 && + name.charCodeAt(0) === name.charCodeAt(length - 1) && + (name.charCodeAt(0) === 34 /* doubleQuote */ || name.charCodeAt(0) === 39 /* singleQuote */)) { + return name.substring(1, length - 1); + } + ; + return name; + } + ts.stripQuotes = stripQuotes; +})(ts || (ts = {})); +/// +/// +/* @internal */ +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 */); + /** + * Scanner that is currently used for formatting + */ + 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 = {})); + function getFormattingScanner(sourceFile, startPos, endPos) { + ts.Debug.assert(scanner === undefined); + scanner = sourceFile.languageVariant === 1 /* JSX */ ? jsxScanner : standardScanner; + scanner.setText(sourceFile.text); + scanner.setTextPos(startPos); + var wasNewLine = true; + var leadingTrivia; + var trailingTrivia; + var savedPos; + var lastScanAction; + var lastTokenInfo; + return { + advance: advance, + readTokenInfo: readTokenInfo, + isOnToken: isOnToken, + lastTrailingTriviaWasNewLine: function () { return wasNewLine; }, + close: function () { + ts.Debug.assert(scanner !== undefined); + lastTokenInfo = undefined; + scanner.setText(undefined); + scanner = undefined; + } + }; + function advance() { + ts.Debug.assert(scanner !== undefined); + lastTokenInfo = undefined; + var isStarted = scanner.getStartPos() !== startPos; + if (isStarted) { + if (trailingTrivia) { + ts.Debug.assert(trailingTrivia.length !== 0); + wasNewLine = ts.lastOrUndefined(trailingTrivia).kind === 4 /* NewLineTrivia */; + } + else { + wasNewLine = false; + } + } + leadingTrivia = undefined; + trailingTrivia = undefined; + if (!isStarted) { + scanner.scan(); + } + var t; + var pos = scanner.getStartPos(); + // Read leading trivia and token + while (pos < endPos) { + var t_1 = scanner.getToken(); + if (!ts.isTrivia(t_1)) { + break; + } + // consume leading trivia + scanner.scan(); + var item = { + pos: pos, + end: scanner.getStartPos(), + kind: t_1 + }; + pos = scanner.getStartPos(); + if (!leadingTrivia) { + leadingTrivia = []; + } + leadingTrivia.push(item); + } + savedPos = scanner.getStartPos(); + } + function shouldRescanGreaterThanToken(node) { + if (node) { + switch (node.kind) { + case 29 /* GreaterThanEqualsToken */: + case 64 /* GreaterThanGreaterThanEqualsToken */: + case 65 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + case 45 /* GreaterThanGreaterThanGreaterThanToken */: + case 44 /* GreaterThanGreaterThanToken */: + return true; + } + } + return false; + } + function shouldRescanJsxIdentifier(node) { + if (node.parent) { + switch (node.parent.kind) { + case 238 /* JsxAttribute */: + case 235 /* JsxOpeningElement */: + case 237 /* JsxClosingElement */: + case 234 /* JsxSelfClosingElement */: + return node.kind === 69 /* Identifier */; + } + } + return false; + } + function shouldRescanSlashToken(container) { + return container.kind === 10 /* RegularExpressionLiteral */; + } + function shouldRescanTemplateToken(container) { + return container.kind === 13 /* TemplateMiddle */ || + container.kind === 14 /* TemplateTail */; + } + function startsWithSlashToken(t) { + return t === 39 /* SlashToken */ || t === 61 /* SlashEqualsToken */; + } + function readTokenInfo(n) { + ts.Debug.assert(scanner !== undefined); + if (!isOnToken()) { + // scanner is not on the token (either advance was not called yet or scanner is already past the end position) + return { + leadingTrivia: leadingTrivia, + trailingTrivia: undefined, + token: undefined + }; + } + // normally scanner returns the smallest available token + // check the kind of context node to determine if scanner should have more greedy behavior and consume more text. + var expectedScanAction = shouldRescanGreaterThanToken(n) + ? 1 /* RescanGreaterThanToken */ + : shouldRescanSlashToken(n) + ? 2 /* RescanSlashToken */ + : shouldRescanTemplateToken(n) + ? 3 /* RescanTemplateToken */ + : shouldRescanJsxIdentifier(n) + ? 4 /* RescanJsxIdentifier */ + : 0 /* Scan */; + if (lastTokenInfo && expectedScanAction === lastScanAction) { + // readTokenInfo was called before with the same expected scan action. + // No need to re-scan text, return existing 'lastTokenInfo' + // it is ok to call fixTokenKind here since it does not affect + // what portion of text is consumed. In opposize rescanning can change it, + // i.e. for '>=' when originally scanner eats just one character + // and rescanning forces it to consume more. + return fixTokenKind(lastTokenInfo, n); + } + if (scanner.getStartPos() !== savedPos) { + ts.Debug.assert(lastTokenInfo !== undefined); + // readTokenInfo was called before but scan action differs - rescan text + scanner.setTextPos(savedPos); + scanner.scan(); + } + var currentToken = scanner.getToken(); + if (expectedScanAction === 1 /* RescanGreaterThanToken */ && currentToken === 27 /* GreaterThanToken */) { + currentToken = scanner.reScanGreaterToken(); + ts.Debug.assert(n.kind === currentToken); + lastScanAction = 1 /* RescanGreaterThanToken */; + } + else if (expectedScanAction === 2 /* RescanSlashToken */ && startsWithSlashToken(currentToken)) { + currentToken = scanner.reScanSlashToken(); + ts.Debug.assert(n.kind === currentToken); + lastScanAction = 2 /* RescanSlashToken */; + } + else if (expectedScanAction === 3 /* RescanTemplateToken */ && currentToken === 16 /* CloseBraceToken */) { + currentToken = scanner.reScanTemplateToken(); + lastScanAction = 3 /* RescanTemplateToken */; + } + else if (expectedScanAction === 4 /* RescanJsxIdentifier */ && currentToken === 69 /* Identifier */) { + currentToken = scanner.scanJsxIdentifier(); + lastScanAction = 4 /* RescanJsxIdentifier */; + } + else { + lastScanAction = 0 /* Scan */; + } + var token = { + pos: scanner.getStartPos(), + end: scanner.getTextPos(), + kind: currentToken + }; + // consume trailing trivia + if (trailingTrivia) { + trailingTrivia = undefined; + } + while (scanner.getStartPos() < endPos) { + currentToken = scanner.scan(); + if (!ts.isTrivia(currentToken)) { + break; + } + var trivia = { + pos: scanner.getStartPos(), + end: scanner.getTextPos(), + kind: currentToken + }; + if (!trailingTrivia) { + trailingTrivia = []; + } + trailingTrivia.push(trivia); + if (currentToken === 4 /* NewLineTrivia */) { + // move past new line + scanner.scan(); + break; + } + } + lastTokenInfo = { + leadingTrivia: leadingTrivia, + trailingTrivia: trailingTrivia, + token: token + }; + return fixTokenKind(lastTokenInfo, n); + } + function isOnToken() { + ts.Debug.assert(scanner !== undefined); + var current = (lastTokenInfo && lastTokenInfo.token.kind) || scanner.getToken(); + var startPos = (lastTokenInfo && lastTokenInfo.token.pos) || scanner.getStartPos(); + return startPos < endPos && current !== 1 /* EndOfFileToken */ && !ts.isTrivia(current); + } + // when containing node in the tree is token + // but its kind differs from the kind that was returned by the scanner, + // then kind needs to be fixed. This might happen in cases + // when parser interprets token differently, i.e keyword treated as identifier + function fixTokenKind(tokenInfo, container) { + if (ts.isToken(container) && tokenInfo.token.kind !== container.kind) { + tokenInfo.token.kind = container.kind; + } + return tokenInfo; + } + } + formatting.getFormattingScanner = getFormattingScanner; + })(formatting = ts.formatting || (ts.formatting = {})); +})(ts || (ts = {})); +/// +/* @internal */ +var ts; +(function (ts) { + var formatting; + (function (formatting) { + var FormattingContext = (function () { + function FormattingContext(sourceFile, formattingRequestKind) { + this.sourceFile = sourceFile; + this.formattingRequestKind = formattingRequestKind; + } + FormattingContext.prototype.updateContext = function (currentRange, currentTokenParent, nextRange, nextTokenParent, commonParent) { + ts.Debug.assert(currentRange !== undefined, "currentTokenSpan is null"); + ts.Debug.assert(currentTokenParent !== undefined, "currentTokenParent is null"); + ts.Debug.assert(nextRange !== undefined, "nextTokenSpan is null"); + ts.Debug.assert(nextTokenParent !== undefined, "nextTokenParent is null"); + ts.Debug.assert(commonParent !== undefined, "commonParent is null"); + this.currentTokenSpan = currentRange; + this.currentTokenParent = currentTokenParent; + this.nextTokenSpan = nextRange; + this.nextTokenParent = nextTokenParent; + this.contextNode = commonParent; + // drop cached results + this.contextNodeAllOnSameLine = undefined; + this.nextNodeAllOnSameLine = undefined; + this.tokensAreOnSameLine = undefined; + this.contextNodeBlockIsOnOneLine = undefined; + this.nextNodeBlockIsOnOneLine = undefined; + }; + FormattingContext.prototype.ContextNodeAllOnSameLine = function () { + if (this.contextNodeAllOnSameLine === undefined) { + this.contextNodeAllOnSameLine = this.NodeIsOnOneLine(this.contextNode); + } + return this.contextNodeAllOnSameLine; + }; + FormattingContext.prototype.NextNodeAllOnSameLine = function () { + if (this.nextNodeAllOnSameLine === undefined) { + this.nextNodeAllOnSameLine = this.NodeIsOnOneLine(this.nextTokenParent); + } + return this.nextNodeAllOnSameLine; + }; + FormattingContext.prototype.TokensAreOnSameLine = function () { + if (this.tokensAreOnSameLine === undefined) { + var startLine = this.sourceFile.getLineAndCharacterOfPosition(this.currentTokenSpan.pos).line; + var endLine = this.sourceFile.getLineAndCharacterOfPosition(this.nextTokenSpan.pos).line; + this.tokensAreOnSameLine = (startLine === endLine); + } + return this.tokensAreOnSameLine; + }; + FormattingContext.prototype.ContextNodeBlockIsOnOneLine = function () { + if (this.contextNodeBlockIsOnOneLine === undefined) { + this.contextNodeBlockIsOnOneLine = this.BlockIsOnOneLine(this.contextNode); + } + return this.contextNodeBlockIsOnOneLine; + }; + FormattingContext.prototype.NextNodeBlockIsOnOneLine = function () { + if (this.nextNodeBlockIsOnOneLine === undefined) { + this.nextNodeBlockIsOnOneLine = this.BlockIsOnOneLine(this.nextTokenParent); + } + return this.nextNodeBlockIsOnOneLine; + }; + FormattingContext.prototype.NodeIsOnOneLine = function (node) { + var startLine = this.sourceFile.getLineAndCharacterOfPosition(node.getStart(this.sourceFile)).line; + var endLine = this.sourceFile.getLineAndCharacterOfPosition(node.getEnd()).line; + 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); + if (openBrace && closeBrace) { + var startLine = this.sourceFile.getLineAndCharacterOfPosition(openBrace.getEnd()).line; + var endLine = this.sourceFile.getLineAndCharacterOfPosition(closeBrace.getStart(this.sourceFile)).line; + return startLine === endLine; + } + return false; + }; + return FormattingContext; + })(); + formatting.FormattingContext = FormattingContext; + })(formatting = ts.formatting || (ts.formatting = {})); +})(ts || (ts = {})); +/// +/* @internal */ +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 = {})); +/// +/* @internal */ +var ts; +(function (ts) { + var formatting; + (function (formatting) { + var Rule = (function () { + function Rule(Descriptor, Operation, Flag) { + if (Flag === void 0) { Flag = 0 /* None */; } + this.Descriptor = Descriptor; + this.Operation = Operation; + this.Flag = Flag; + } + Rule.prototype.toString = function () { + return "[desc=" + this.Descriptor + "," + + "operation=" + this.Operation + "," + + "flag=" + this.Flag + "]"; + }; + return Rule; + })(); + formatting.Rule = Rule; + })(formatting = ts.formatting || (ts.formatting = {})); +})(ts || (ts = {})); +/// +/* @internal */ +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 = {})); +/// +/* @internal */ +var ts; +(function (ts) { + var formatting; + (function (formatting) { + var RuleDescriptor = (function () { + function RuleDescriptor(LeftTokenRange, RightTokenRange) { + this.LeftTokenRange = LeftTokenRange; + this.RightTokenRange = RightTokenRange; + } + RuleDescriptor.prototype.toString = function () { + return "[leftRange=" + this.LeftTokenRange + "," + + "rightRange=" + this.RightTokenRange + "]"; + }; + RuleDescriptor.create1 = function (left, right) { + return RuleDescriptor.create4(formatting.Shared.TokenRange.FromToken(left), formatting.Shared.TokenRange.FromToken(right)); + }; + RuleDescriptor.create2 = function (left, right) { + return RuleDescriptor.create4(left, formatting.Shared.TokenRange.FromToken(right)); + }; + RuleDescriptor.create3 = function (left, right) { + return RuleDescriptor.create4(formatting.Shared.TokenRange.FromToken(left), right); + }; + RuleDescriptor.create4 = function (left, right) { + return new RuleDescriptor(left, right); + }; + return RuleDescriptor; + })(); + formatting.RuleDescriptor = RuleDescriptor; + })(formatting = ts.formatting || (ts.formatting = {})); +})(ts || (ts = {})); +/// +/* @internal */ +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 = {})); +/// +/* @internal */ +var ts; +(function (ts) { + var formatting; + (function (formatting) { + var RuleOperation = (function () { + function RuleOperation() { + this.Context = null; + this.Action = null; + } + RuleOperation.prototype.toString = function () { + return "[context=" + this.Context + "," + + "action=" + this.Action + "]"; + }; + RuleOperation.create1 = function (action) { + return RuleOperation.create2(formatting.RuleOperationContext.Any, action); + }; + RuleOperation.create2 = function (context, action) { + var result = new RuleOperation(); + result.Context = context; + result.Action = action; + return result; + }; + return RuleOperation; + })(); + formatting.RuleOperation = RuleOperation; + })(formatting = ts.formatting || (ts.formatting = {})); +})(ts || (ts = {})); +/// +/* @internal */ +var ts; +(function (ts) { + var formatting; + (function (formatting) { + var RuleOperationContext = (function () { + function RuleOperationContext() { + var funcs = []; + for (var _i = 0; _i < arguments.length; _i++) { + funcs[_i - 0] = arguments[_i]; + } + this.customContextChecks = funcs; + } + RuleOperationContext.prototype.IsAny = function () { + return this === RuleOperationContext.Any; + }; + RuleOperationContext.prototype.InContext = function (context) { + if (this.IsAny()) { + return true; + } + for (var _i = 0, _a = this.customContextChecks; _i < _a.length; _i++) { + var check = _a[_i]; + if (!check(context)) { + return false; + } + } + return true; + }; + RuleOperationContext.Any = new RuleOperationContext(); + return RuleOperationContext; + })(); + formatting.RuleOperationContext = RuleOperationContext; + })(formatting = ts.formatting || (ts.formatting = {})); +})(ts || (ts = {})); +/// +/* @internal */ +var ts; +(function (ts) { + var formatting; + (function (formatting) { + var Rules = (function () { + function Rules() { + /// + /// Common Rules + /// + // Leave comments alone + 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.IsSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceBeforeColon = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 54 /* ColonToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 8 /* Delete */)); + this.NoSpaceBeforeQuestionMark = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 53 /* QuestionToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 8 /* Delete */)); + this.SpaceAfterColon = new formatting.Rule(formatting.RuleDescriptor.create3(54 /* ColonToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 2 /* Space */)); + this.SpaceAfterQuestionMarkInConditionalOperator = new formatting.Rule(formatting.RuleDescriptor.create3(53 /* QuestionToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsConditionalOperatorContext), 2 /* Space */)); + this.NoSpaceAfterQuestionMark = new formatting.Rule(formatting.RuleDescriptor.create3(53 /* QuestionToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.SpaceAfterSemicolon = new formatting.Rule(formatting.RuleDescriptor.create3(23 /* SemicolonToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); + // Space after }. + this.SpaceAfterCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create3(16 /* CloseBraceToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsAfterCodeBlockContext), 2 /* Space */)); + // Special case for (}, else) and (}, while) since else & while tokens are not part of the tree which makes SpaceAfterCloseBrace rule not applied + this.SpaceBetweenCloseBraceAndElse = new formatting.Rule(formatting.RuleDescriptor.create1(16 /* CloseBraceToken */, 80 /* ElseKeyword */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); + this.SpaceBetweenCloseBraceAndWhile = new formatting.Rule(formatting.RuleDescriptor.create1(16 /* CloseBraceToken */, 104 /* WhileKeyword */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); + this.NoSpaceAfterCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create3(16 /* CloseBraceToken */, formatting.Shared.TokenRange.FromTokens([18 /* CloseParenToken */, 20 /* CloseBracketToken */, 24 /* CommaToken */, 23 /* SemicolonToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + // No space for dot + this.NoSpaceBeforeDot = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 21 /* DotToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceAfterDot = new formatting.Rule(formatting.RuleDescriptor.create3(21 /* DotToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 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.IsSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceAfterCloseBracket = new formatting.Rule(formatting.RuleDescriptor.create3(20 /* CloseBracketToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, 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 */); + // 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 */]); + this.SpaceBeforeOpenBraceInTypeScriptDeclWithBlock = new formatting.Rule(formatting.RuleDescriptor.create2(this.TypeScriptOpenBraceLeftTokenRange, 15 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsTypeScriptDeclWithBlockContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), 2 /* Space */), 1 /* CanDeleteNewLines */); + // Place a space before open brace in a control flow construct + this.ControlOpenBraceLeftTokenRange = formatting.Shared.TokenRange.FromTokens([18 /* CloseParenToken */, 3 /* MultiLineCommentTrivia */, 79 /* DoKeyword */, 100 /* TryKeyword */, 85 /* FinallyKeyword */, 80 /* ElseKeyword */]); + this.SpaceBeforeOpenBraceInControl = new formatting.Rule(formatting.RuleDescriptor.create2(this.ControlOpenBraceLeftTokenRange, 15 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsControlDeclContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), 2 /* Space */), 1 /* CanDeleteNewLines */); + // Insert a space after { and before } in single-line contexts, but remove space from empty object literals {}. + this.SpaceAfterOpenBrace = new formatting.Rule(formatting.RuleDescriptor.create3(15 /* OpenBraceToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSingleLineBlockContext), 2 /* Space */)); + 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.NoSpaceBetweenEmptyBraceBrackets = new formatting.Rule(formatting.RuleDescriptor.create1(15 /* OpenBraceToken */, 16 /* CloseBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, 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 */)); + // 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 */)); + // 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.IsSameLineTokenContext, 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.IsSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceAfterUnaryPredecrementOperator = new formatting.Rule(formatting.RuleDescriptor.create3(42 /* MinusMinusToken */, formatting.Shared.TokenRange.UnaryPredecrementExpressions), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceBeforeUnaryPostincrementOperator = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.UnaryPostincrementExpressions, 41 /* PlusPlusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceBeforeUnaryPostdecrementOperator = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.UnaryPostdecrementExpressions, 42 /* MinusMinusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + // More unary operator special-casing. + // DevDiv 181814: Be careful when removing leading whitespace + // around unary operators. Examples: + // 1 - -2 --X--> 1--2 + // a + ++b --X--> a+++b + this.SpaceAfterPostincrementWhenFollowedByAdd = new formatting.Rule(formatting.RuleDescriptor.create1(41 /* PlusPlusToken */, 35 /* PlusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); + this.SpaceAfterAddWhenFollowedByUnaryPlus = new formatting.Rule(formatting.RuleDescriptor.create1(35 /* PlusToken */, 35 /* PlusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); + this.SpaceAfterAddWhenFollowedByPreincrement = new formatting.Rule(formatting.RuleDescriptor.create1(35 /* PlusToken */, 41 /* PlusPlusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); + this.SpaceAfterPostdecrementWhenFollowedBySubtract = new formatting.Rule(formatting.RuleDescriptor.create1(42 /* MinusMinusToken */, 36 /* MinusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); + this.SpaceAfterSubtractWhenFollowedByUnaryMinus = new formatting.Rule(formatting.RuleDescriptor.create1(36 /* MinusToken */, 36 /* MinusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); + this.SpaceAfterSubtractWhenFollowedByPredecrement = new formatting.Rule(formatting.RuleDescriptor.create1(36 /* MinusToken */, 42 /* MinusMinusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); + this.NoSpaceBeforeComma = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 24 /* CommaToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.SpaceAfterCertainKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([102 /* VarKeyword */, 98 /* ThrowKeyword */, 92 /* NewKeyword */, 78 /* DeleteKeyword */, 94 /* ReturnKeyword */, 101 /* TypeOfKeyword */, 119 /* AwaitKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); + this.SpaceAfterLetConstInVariableDeclaration = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([108 /* LetKeyword */, 74 /* ConstKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsStartOfVariableDeclarationList), 2 /* Space */)); + this.NoSpaceBeforeOpenParenInFuncCall = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 17 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsFunctionCallOrNewContext, Rules.IsPreviousTokenNotComma), 8 /* Delete */)); + this.SpaceAfterFunctionInFuncDecl = new formatting.Rule(formatting.RuleDescriptor.create3(87 /* FunctionKeyword */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2 /* Space */)); + this.NoSpaceBeforeOpenParenInFuncDecl = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 17 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsFunctionDeclContext), 8 /* Delete */)); + this.SpaceAfterVoidOperator = new formatting.Rule(formatting.RuleDescriptor.create3(103 /* VoidKeyword */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsVoidOpContext), 2 /* Space */)); + this.NoSpaceBetweenReturnAndSemicolon = new formatting.Rule(formatting.RuleDescriptor.create1(94 /* ReturnKeyword */, 23 /* SemicolonToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + // Add a space between statements. All keywords except (do,else,case) has open/close parens after them. + // So, we have a rule to add a space for [),Any], [do,Any], [else,Any], and [case,Any] + this.SpaceBetweenStatements = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([18 /* CloseParenToken */, 79 /* DoKeyword */, 80 /* ElseKeyword */, 71 /* CaseKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotForContext), 2 /* Space */)); + // This low-pri rule takes care of "try {" and "finally {" in case the rule SpaceBeforeOpenBraceInControl didn't execute on FormatOnEnter. + this.SpaceAfterTryFinally = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([100 /* TryKeyword */, 85 /* FinallyKeyword */]), 15 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); + // get x() {} + // set x(val) {} + this.SpaceAfterGetSetInMember = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([123 /* GetKeyword */, 129 /* SetKeyword */]), 69 /* Identifier */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2 /* Space */)); + // Special case for binary operators (that are keywords). For these we have to add a space and shouldn't follow any user options. + this.SpaceBeforeBinaryKeywordOperator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.BinaryKeywordOperators), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); + this.SpaceAfterBinaryKeywordOperator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.BinaryKeywordOperators, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); + // TypeScript-specific higher priority rules + // Treat constructor as an identifier in a function declaration, and remove spaces between constructor and following left parentheses + this.NoSpaceAfterConstructor = new formatting.Rule(formatting.RuleDescriptor.create1(121 /* ConstructorKeyword */, 17 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + // Use of module as a function call. e.g.: import m2 = module("m2"); + this.NoSpaceAfterModuleImport = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([125 /* ModuleKeyword */, 127 /* RequireKeyword */]), 17 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + // Add a space around certain TypeScript keywords + this.SpaceAfterCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([115 /* AbstractKeyword */, 73 /* ClassKeyword */, 122 /* DeclareKeyword */, 77 /* DefaultKeyword */, 81 /* EnumKeyword */, 82 /* ExportKeyword */, 83 /* ExtendsKeyword */, 123 /* GetKeyword */, 106 /* ImplementsKeyword */, 89 /* ImportKeyword */, 107 /* InterfaceKeyword */, 125 /* ModuleKeyword */, 126 /* NamespaceKeyword */, 110 /* PrivateKeyword */, 112 /* PublicKeyword */, 111 /* ProtectedKeyword */, 129 /* SetKeyword */, 113 /* StaticKeyword */, 132 /* TypeKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); + this.SpaceBeforeCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([83 /* ExtendsKeyword */, 106 /* ImplementsKeyword */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); + // Treat string literals in module names as identifiers, and add a space between the literal and the opening Brace braces, e.g.: module "m2" { + this.SpaceAfterModuleName = new formatting.Rule(formatting.RuleDescriptor.create1(9 /* StringLiteral */, 15 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsModuleDeclContext), 2 /* Space */)); + // Lambda expressions + this.SpaceAfterArrow = new formatting.Rule(formatting.RuleDescriptor.create3(34 /* EqualsGreaterThanToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); + // Optional parameters and let args + this.NoSpaceAfterEllipsis = new formatting.Rule(formatting.RuleDescriptor.create1(22 /* DotDotDotToken */, 69 /* Identifier */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceAfterOptionalParameters = new formatting.Rule(formatting.RuleDescriptor.create3(53 /* QuestionToken */, formatting.Shared.TokenRange.FromTokens([18 /* CloseParenToken */, 24 /* CommaToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 8 /* Delete */)); + // generics and type assertions + this.NoSpaceBeforeOpenAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.TypeNames, 25 /* LessThanToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), 8 /* Delete */)); + this.NoSpaceBetweenCloseParenAndAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create1(18 /* CloseParenToken */, 25 /* LessThanToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), 8 /* Delete */)); + this.NoSpaceAfterOpenAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create3(25 /* LessThanToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, 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.IsSameLineTokenContext, 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.IsSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), 8 /* Delete */)); + this.NoSpaceAfterTypeAssertion = new formatting.Rule(formatting.RuleDescriptor.create3(27 /* GreaterThanToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsTypeAssertionContext), 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.IsSameLineTokenContext, 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.IsSameLineTokenContext), 2 /* Space */)); + this.NoSpaceAfterAt = new formatting.Rule(formatting.RuleDescriptor.create3(55 /* AtToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.SpaceAfterDecorator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([115 /* AbstractKeyword */, 69 /* Identifier */, 82 /* ExportKeyword */, 77 /* DefaultKeyword */, 73 /* ClassKeyword */, 113 /* StaticKeyword */, 112 /* PublicKeyword */, 110 /* PrivateKeyword */, 111 /* ProtectedKeyword */, 123 /* GetKeyword */, 129 /* SetKeyword */, 19 /* OpenBracketToken */, 37 /* AsteriskToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsEndOfDecoratorContextOnSameLine), 2 /* Space */)); + this.NoSpaceBetweenFunctionKeywordAndStar = new formatting.Rule(formatting.RuleDescriptor.create1(87 /* FunctionKeyword */, 37 /* AsteriskToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclarationOrFunctionExpressionContext), 8 /* Delete */)); + this.SpaceAfterStarInGeneratorDeclaration = new formatting.Rule(formatting.RuleDescriptor.create3(37 /* AsteriskToken */, formatting.Shared.TokenRange.FromTokens([69 /* Identifier */, 17 /* OpenParenToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclarationOrFunctionExpressionContext), 2 /* Space */)); + this.NoSpaceBetweenYieldKeywordAndStar = new formatting.Rule(formatting.RuleDescriptor.create1(114 /* YieldKeyword */, 37 /* AsteriskToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsYieldOrYieldStarWithOperand), 8 /* Delete */)); + this.SpaceBetweenYieldOrYieldStarAndOperand = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([114 /* YieldKeyword */, 37 /* AsteriskToken */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsYieldOrYieldStarWithOperand), 2 /* Space */)); + // Async-await + this.SpaceBetweenAsyncAndOpenParen = new formatting.Rule(formatting.RuleDescriptor.create1(118 /* AsyncKeyword */, 17 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsArrowFunctionContext, Rules.IsSameLineTokenContext), 2 /* Space */)); + this.SpaceBetweenAsyncAndFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(118 /* AsyncKeyword */, 87 /* FunctionKeyword */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); + // template string + this.SpaceBetweenTagAndTemplateString = new formatting.Rule(formatting.RuleDescriptor.create3(69 /* Identifier */, formatting.Shared.TokenRange.FromTokens([11 /* NoSubstitutionTemplateLiteral */, 12 /* TemplateHead */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); + this.NoSpaceAfterTemplateHeadAndMiddle = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([12 /* TemplateHead */, 13 /* TemplateMiddle */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceBeforeTemplateMiddleAndTail = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([13 /* TemplateMiddle */, 14 /* TemplateTail */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + // These rules are higher in priority than user-configurable rules. + this.HighPriorityCommonRules = + [ + this.IgnoreBeforeComment, this.IgnoreAfterLineComment, + this.NoSpaceBeforeColon, this.SpaceAfterColon, this.NoSpaceBeforeQuestionMark, this.SpaceAfterQuestionMarkInConditionalOperator, + this.NoSpaceAfterQuestionMark, + this.NoSpaceBeforeDot, this.NoSpaceAfterDot, + this.NoSpaceAfterUnaryPrefixOperator, + this.NoSpaceAfterUnaryPreincrementOperator, this.NoSpaceAfterUnaryPredecrementOperator, + this.NoSpaceBeforeUnaryPostincrementOperator, this.NoSpaceBeforeUnaryPostdecrementOperator, + this.SpaceAfterPostincrementWhenFollowedByAdd, + this.SpaceAfterAddWhenFollowedByUnaryPlus, this.SpaceAfterAddWhenFollowedByPreincrement, + this.SpaceAfterPostdecrementWhenFollowedBySubtract, + this.SpaceAfterSubtractWhenFollowedByUnaryMinus, this.SpaceAfterSubtractWhenFollowedByPredecrement, + this.NoSpaceAfterCloseBrace, + this.SpaceAfterOpenBrace, this.SpaceBeforeCloseBrace, this.NewLineBeforeCloseBraceInBlockContext, + this.SpaceAfterCloseBrace, this.SpaceBetweenCloseBraceAndElse, this.SpaceBetweenCloseBraceAndWhile, this.NoSpaceBetweenEmptyBraceBrackets, + this.NoSpaceBetweenFunctionKeywordAndStar, this.SpaceAfterStarInGeneratorDeclaration, + this.SpaceAfterFunctionInFuncDecl, this.NewLineAfterOpenBraceInBlockContext, this.SpaceAfterGetSetInMember, + this.NoSpaceBetweenYieldKeywordAndStar, this.SpaceBetweenYieldOrYieldStarAndOperand, + this.NoSpaceBetweenReturnAndSemicolon, + this.SpaceAfterCertainKeywords, + this.SpaceAfterLetConstInVariableDeclaration, + this.NoSpaceBeforeOpenParenInFuncCall, + this.SpaceBeforeBinaryKeywordOperator, this.SpaceAfterBinaryKeywordOperator, + this.SpaceAfterVoidOperator, + this.SpaceBetweenAsyncAndOpenParen, this.SpaceBetweenAsyncAndFunctionKeyword, + this.SpaceBetweenTagAndTemplateString, this.NoSpaceAfterTemplateHeadAndMiddle, this.NoSpaceBeforeTemplateMiddleAndTail, + // TypeScript-specific rules + this.NoSpaceAfterConstructor, this.NoSpaceAfterModuleImport, + this.SpaceAfterCertainTypeScriptKeywords, this.SpaceBeforeCertainTypeScriptKeywords, + this.SpaceAfterModuleName, + this.SpaceAfterArrow, + this.NoSpaceAfterEllipsis, + this.NoSpaceAfterOptionalParameters, + this.NoSpaceBetweenEmptyInterfaceBraceBrackets, + this.NoSpaceBeforeOpenAngularBracket, + this.NoSpaceBetweenCloseParenAndAngularBracket, + this.NoSpaceAfterOpenAngularBracket, + this.NoSpaceBeforeCloseAngularBracket, + this.NoSpaceAfterCloseAngularBracket, + this.NoSpaceAfterTypeAssertion, + this.SpaceBeforeAt, + this.NoSpaceAfterAt, + this.SpaceAfterDecorator, + ]; + // These rules are lower in priority than user-configurable rules. + this.LowPriorityCommonRules = + [ + this.NoSpaceBeforeSemicolon, + this.SpaceBeforeOpenBraceInControl, this.SpaceBeforeOpenBraceInFunction, this.SpaceBeforeOpenBraceInTypeScriptDeclWithBlock, + this.NoSpaceBeforeComma, + this.NoSpaceBeforeOpenBracket, + this.NoSpaceAfterCloseBracket, + this.SpaceAfterSemicolon, + this.NoSpaceBeforeOpenParenInFuncDecl, + this.SpaceBetweenStatements, this.SpaceAfterTryFinally + ]; + /// + /// 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.IsSameLineTokenContext), 2 /* Space */)); + this.NoSpaceAfterComma = new formatting.Rule(formatting.RuleDescriptor.create3(24 /* CommaToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 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.IsSameLineTokenContext, 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.IsSameLineTokenContext, 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.IsSameLineTokenContext, 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.IsSameLineTokenContext, 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 */)); + // 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 */); + // 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 */); + // 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 */); + // 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.IsSameLineTokenContext, 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.IsSameLineTokenContext, 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.IsSameLineTokenContext), 2 /* Space */)); + this.SpaceBeforeCloseParen = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 18 /* CloseParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); + this.NoSpaceBetweenParens = new formatting.Rule(formatting.RuleDescriptor.create1(17 /* OpenParenToken */, 18 /* CloseParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceAfterOpenParen = new formatting.Rule(formatting.RuleDescriptor.create3(17 /* OpenParenToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceBeforeCloseParen = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 18 /* CloseParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 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.IsSameLineTokenContext), 2 /* Space */)); + this.SpaceBeforeCloseBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 20 /* CloseBracketToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); + this.NoSpaceBetweenBrackets = new formatting.Rule(formatting.RuleDescriptor.create1(19 /* OpenBracketToken */, 20 /* CloseBracketToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceAfterOpenBracket = new formatting.Rule(formatting.RuleDescriptor.create3(19 /* OpenBracketToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceBeforeCloseBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 20 /* CloseBracketToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + // Insert space after function keyword for anonymous functions + this.SpaceAfterAnonymousFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(87 /* FunctionKeyword */, 17 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2 /* Space */)); + this.NoSpaceAfterAnonymousFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(87 /* FunctionKeyword */, 17 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 8 /* Delete */)); + } + Rules.prototype.getRuleName = function (rule) { + var o = this; + for (var name_32 in o) { + if (o[name_32] === rule) { + return name_32; + } + } + throw new Error("Unknown rule"); + }; + /// + /// Contexts + /// + Rules.IsForContext = function (context) { + return context.contextNode.kind === 199 /* ForStatement */; + }; + Rules.IsNotForContext = function (context) { + return !Rules.IsForContext(context); + }; + Rules.IsBinaryOpContext = function (context) { + switch (context.contextNode.kind) { + case 181 /* BinaryExpression */: + case 182 /* ConditionalExpression */: + case 189 /* AsExpression */: + case 150 /* TypePredicate */: + case 158 /* UnionType */: + case 159 /* IntersectionType */: + return true; + // equals in binding elements: function foo([[x, y] = [1, 2]]) + case 163 /* BindingElement */: + // equals in type X = ... + case 216 /* TypeAliasDeclaration */: + // equal in import a = module('a'); + case 221 /* ImportEqualsDeclaration */: + // equal in let a = 0; + case 211 /* VariableDeclaration */: + // equal in p = 0; + case 138 /* Parameter */: + case 247 /* EnumMember */: + case 141 /* PropertyDeclaration */: + case 140 /* PropertySignature */: + return context.currentTokenSpan.kind === 56 /* EqualsToken */ || context.nextTokenSpan.kind === 56 /* EqualsToken */; + // "in" keyword in for (let x in []) { } + case 200 /* ForInStatement */: + return context.currentTokenSpan.kind === 90 /* InKeyword */ || context.nextTokenSpan.kind === 90 /* InKeyword */; + // Technically, "of" is not a binary operator, but format it the same way as "in" + case 201 /* ForOfStatement */: + return context.currentTokenSpan.kind === 134 /* OfKeyword */ || context.nextTokenSpan.kind === 134 /* OfKeyword */; + } + return false; + }; + Rules.IsNotBinaryOpContext = function (context) { + return !Rules.IsBinaryOpContext(context); + }; + Rules.IsConditionalOperatorContext = function (context) { + return context.contextNode.kind === 182 /* ConditionalExpression */; + }; + Rules.IsSameLineTokenOrBeforeMultilineBlockContext = function (context) { + //// This check is mainly used inside SpaceBeforeOpenBraceInControl and SpaceBeforeOpenBraceInFunction. + //// + //// Ex: + //// if (1) { .... + //// * ) and { are on the same line so apply the rule. Here we don't care whether it's same or multi block context + //// + //// Ex: + //// if (1) + //// { ... } + //// * ) and { are on differnet lines. We only need to format if the block is multiline context. So in this case we don't format. + //// + //// Ex: + //// if (1) + //// { ... + //// } + //// * ) and { are on differnet lines. We only need to format if the block is multiline context. So in this case we format. + return context.TokensAreOnSameLine() || Rules.IsBeforeMultilineBlockContext(context); + }; + // This check is done before an open brace in a control construct, a function, or a typescript block declaration + Rules.IsBeforeMultilineBlockContext = function (context) { + return Rules.IsBeforeBlockContext(context) && !(context.NextNodeAllOnSameLine() || context.NextNodeBlockIsOnOneLine()); + }; + Rules.IsMultilineBlockContext = function (context) { + return Rules.IsBlockContext(context) && !(context.ContextNodeAllOnSameLine() || context.ContextNodeBlockIsOnOneLine()); + }; + Rules.IsSingleLineBlockContext = function (context) { + return Rules.IsBlockContext(context) && (context.ContextNodeAllOnSameLine() || context.ContextNodeBlockIsOnOneLine()); + }; + Rules.IsBlockContext = function (context) { + return Rules.NodeIsBlockContext(context.contextNode); + }; + Rules.IsBeforeBlockContext = function (context) { + return Rules.NodeIsBlockContext(context.nextTokenParent); + }; + // IMPORTANT!!! This method must return true ONLY for nodes with open and close braces as immediate children + Rules.NodeIsBlockContext = function (node) { + if (Rules.NodeIsTypeScriptDeclWithBlockContext(node)) { + // This means we are in a context that looks like a block to the user, but in the grammar is actually not a node (it's a class, module, enum, object type literal, etc). + return true; + } + switch (node.kind) { + case 192 /* Block */: + case 220 /* CaseBlock */: + case 165 /* ObjectLiteralExpression */: + case 219 /* ModuleBlock */: + return true; + } + return false; + }; + Rules.IsFunctionDeclContext = function (context) { + switch (context.contextNode.kind) { + case 213 /* FunctionDeclaration */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: + //case SyntaxKind.MemberFunctionDeclaration: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: + ///case SyntaxKind.MethodSignature: + case 147 /* CallSignature */: + case 173 /* FunctionExpression */: + case 144 /* Constructor */: + case 174 /* ArrowFunction */: + //case SyntaxKind.ConstructorDeclaration: + //case SyntaxKind.SimpleArrowFunctionExpression: + //case SyntaxKind.ParenthesizedArrowFunctionExpression: + case 215 /* InterfaceDeclaration */: + return true; + } + return false; + }; + Rules.IsFunctionDeclarationOrFunctionExpressionContext = function (context) { + return context.contextNode.kind === 213 /* FunctionDeclaration */ || context.contextNode.kind === 173 /* FunctionExpression */; + }; + Rules.IsTypeScriptDeclWithBlockContext = function (context) { + return Rules.NodeIsTypeScriptDeclWithBlockContext(context.contextNode); + }; + Rules.NodeIsTypeScriptDeclWithBlockContext = function (node) { + switch (node.kind) { + case 214 /* ClassDeclaration */: + case 186 /* ClassExpression */: + case 215 /* InterfaceDeclaration */: + case 217 /* EnumDeclaration */: + case 155 /* TypeLiteral */: + case 218 /* ModuleDeclaration */: + return true; + } + return false; + }; + Rules.IsAfterCodeBlockContext = function (context) { + switch (context.currentTokenParent.kind) { + case 214 /* ClassDeclaration */: + case 218 /* ModuleDeclaration */: + case 217 /* EnumDeclaration */: + case 192 /* Block */: + case 244 /* CatchClause */: + case 219 /* ModuleBlock */: + case 206 /* SwitchStatement */: + return true; + } + return false; + }; + Rules.IsControlDeclContext = function (context) { + switch (context.contextNode.kind) { + case 196 /* IfStatement */: + case 206 /* SwitchStatement */: + case 199 /* ForStatement */: + case 200 /* ForInStatement */: + case 201 /* ForOfStatement */: + case 198 /* WhileStatement */: + case 209 /* TryStatement */: + case 197 /* DoStatement */: + case 205 /* WithStatement */: + // TODO + // case SyntaxKind.ElseClause: + case 244 /* CatchClause */: + return true; + default: + return false; + } + }; + Rules.IsObjectContext = function (context) { + return context.contextNode.kind === 165 /* ObjectLiteralExpression */; + }; + Rules.IsFunctionCallContext = function (context) { + return context.contextNode.kind === 168 /* CallExpression */; + }; + Rules.IsNewContext = function (context) { + return context.contextNode.kind === 169 /* NewExpression */; + }; + Rules.IsFunctionCallOrNewContext = function (context) { + return Rules.IsFunctionCallContext(context) || Rules.IsNewContext(context); + }; + Rules.IsPreviousTokenNotComma = function (context) { + return context.currentTokenSpan.kind !== 24 /* CommaToken */; + }; + Rules.IsArrowFunctionContext = function (context) { + return context.contextNode.kind === 174 /* ArrowFunction */; + }; + Rules.IsSameLineTokenContext = function (context) { + return context.TokensAreOnSameLine(); + }; + Rules.IsNotBeforeBlockInFunctionDeclarationContext = function (context) { + return !Rules.IsFunctionDeclContext(context) && !Rules.IsBeforeBlockContext(context); + }; + Rules.IsEndOfDecoratorContextOnSameLine = function (context) { + return context.TokensAreOnSameLine() && + context.contextNode.decorators && + Rules.NodeIsInDecoratorContext(context.currentTokenParent) && + !Rules.NodeIsInDecoratorContext(context.nextTokenParent); + }; + Rules.NodeIsInDecoratorContext = function (node) { + while (ts.isExpression(node)) { + node = node.parent; + } + return node.kind === 139 /* Decorator */; + }; + Rules.IsStartOfVariableDeclarationList = function (context) { + return context.currentTokenParent.kind === 212 /* VariableDeclarationList */ && + context.currentTokenParent.getStart(context.sourceFile) === context.currentTokenSpan.pos; + }; + Rules.IsNotFormatOnEnter = function (context) { + return context.formattingRequestKind !== 2 /* FormatOnEnter */; + }; + Rules.IsModuleDeclContext = function (context) { + return context.contextNode.kind === 218 /* ModuleDeclaration */; + }; + Rules.IsObjectTypeContext = function (context) { + return context.contextNode.kind === 155 /* TypeLiteral */; // && context.contextNode.parent.kind !== SyntaxKind.InterfaceDeclaration; + }; + Rules.IsTypeArgumentOrParameterOrAssertion = function (token, parent) { + if (token.kind !== 25 /* LessThanToken */ && token.kind !== 27 /* GreaterThanToken */) { + return false; + } + switch (parent.kind) { + case 151 /* TypeReference */: + case 171 /* TypeAssertionExpression */: + case 214 /* ClassDeclaration */: + case 186 /* ClassExpression */: + case 215 /* InterfaceDeclaration */: + case 213 /* FunctionDeclaration */: + case 173 /* FunctionExpression */: + case 174 /* ArrowFunction */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: + case 147 /* CallSignature */: + case 148 /* ConstructSignature */: + case 168 /* CallExpression */: + case 169 /* NewExpression */: + case 188 /* ExpressionWithTypeArguments */: + return true; + default: + return false; + } + }; + Rules.IsTypeArgumentOrParameterOrAssertionContext = function (context) { + return Rules.IsTypeArgumentOrParameterOrAssertion(context.currentTokenSpan, context.currentTokenParent) || + Rules.IsTypeArgumentOrParameterOrAssertion(context.nextTokenSpan, context.nextTokenParent); + }; + Rules.IsTypeAssertionContext = function (context) { + return context.contextNode.kind === 171 /* TypeAssertionExpression */; + }; + Rules.IsVoidOpContext = function (context) { + return context.currentTokenSpan.kind === 103 /* VoidKeyword */ && context.currentTokenParent.kind === 177 /* VoidExpression */; + }; + Rules.IsYieldOrYieldStarWithOperand = function (context) { + return context.contextNode.kind === 184 /* YieldExpression */ && context.contextNode.expression !== undefined; + }; + return Rules; + })(); + formatting.Rules = Rules; + })(formatting = ts.formatting || (ts.formatting = {})); +})(ts || (ts = {})); +/// +/* @internal */ +var ts; +(function (ts) { + var formatting; + (function (formatting) { + var RulesMap = (function () { + function RulesMap() { + this.map = []; + this.mapRowLength = 0; + } + RulesMap.create = function (rules) { + var result = new RulesMap(); + result.Initialize(rules); + return result; + }; + RulesMap.prototype.Initialize = function (rules) { + this.mapRowLength = 134 /* LastToken */ + 1; + this.map = new Array(this.mapRowLength * this.mapRowLength); //new Array(this.mapRowLength * this.mapRowLength); + // This array is used only during construction of the rulesbucket in the map + var rulesBucketConstructionStateList = new Array(this.map.length); //new Array(this.map.length); + this.FillRules(rules, rulesBucketConstructionStateList); + return this.map; + }; + RulesMap.prototype.FillRules = function (rules, rulesBucketConstructionStateList) { + var _this = this; + rules.forEach(function (rule) { + _this.FillRule(rule, rulesBucketConstructionStateList); + }); + }; + RulesMap.prototype.GetRuleBucketIndex = function (row, column) { + 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) { + var _this = this; + var specificRule = rule.Descriptor.LeftTokenRange !== formatting.Shared.TokenRange.Any && + rule.Descriptor.RightTokenRange !== formatting.Shared.TokenRange.Any; + rule.Descriptor.LeftTokenRange.GetTokens().forEach(function (left) { + rule.Descriptor.RightTokenRange.GetTokens().forEach(function (right) { + var rulesBucketIndex = _this.GetRuleBucketIndex(left, right); + var rulesBucket = _this.map[rulesBucketIndex]; + if (rulesBucket === undefined) { + rulesBucket = _this.map[rulesBucketIndex] = new RulesBucket(); + } + rulesBucket.AddRule(rule, specificRule, rulesBucketConstructionStateList, rulesBucketIndex); + }); + }); + }; + RulesMap.prototype.GetRule = function (context) { + var bucketIndex = this.GetRuleBucketIndex(context.currentTokenSpan.kind, context.nextTokenSpan.kind); + var bucket = this.map[bucketIndex]; + if (bucket != null) { + for (var _i = 0, _a = bucket.Rules(); _i < _a.length; _i++) { + var rule = _a[_i]; + if (rule.Operation.Context.InContext(context)) { + return rule; + } + } + } + return null; + }; + return RulesMap; + })(); + formatting.RulesMap = RulesMap; + var MaskBitSize = 5; + var Mask = 0x1f; + (function (RulesPosition) { + RulesPosition[RulesPosition["IgnoreRulesSpecific"] = 0] = "IgnoreRulesSpecific"; + RulesPosition[RulesPosition["IgnoreRulesAny"] = MaskBitSize * 1] = "IgnoreRulesAny"; + RulesPosition[RulesPosition["ContextRulesSpecific"] = MaskBitSize * 2] = "ContextRulesSpecific"; + RulesPosition[RulesPosition["ContextRulesAny"] = MaskBitSize * 3] = "ContextRulesAny"; + RulesPosition[RulesPosition["NoContextRulesSpecific"] = MaskBitSize * 4] = "NoContextRulesSpecific"; + RulesPosition[RulesPosition["NoContextRulesAny"] = MaskBitSize * 5] = "NoContextRulesAny"; + })(formatting.RulesPosition || (formatting.RulesPosition = {})); + var RulesPosition = formatting.RulesPosition; + var RulesBucketConstructionState = (function () { + function RulesBucketConstructionState() { + //// The Rules list contains all the inserted rules into a rulebucket in the following order: + //// 1- Ignore rules with specific token combination + //// 2- Ignore rules with any token combination + //// 3- Context rules with specific token combination + //// 4- Context rules with any token combination + //// 5- Non-context rules with specific token combination + //// 6- Non-context rules with any token combination + //// + //// The member rulesInsertionIndexBitmap is used to describe the number of rules + //// in each sub-bucket (above) hence can be used to know the index of where to insert + //// the next rule. It's a bitmap which contains 6 different sections each is given 5 bits. + //// + //// Example: + //// In order to insert a rule to the end of sub-bucket (3), we get the index by adding + //// the values in the bitmap segments 3rd, 2nd, and 1st. + this.rulesInsertionIndexBitmap = 0; + } + RulesBucketConstructionState.prototype.GetInsertionIndex = function (maskPosition) { + var index = 0; + var pos = 0; + var indexBitmap = this.rulesInsertionIndexBitmap; + while (pos <= maskPosition) { + index += (indexBitmap & Mask); + indexBitmap >>= MaskBitSize; + pos += MaskBitSize; + } + return index; + }; + RulesBucketConstructionState.prototype.IncreaseInsertionIndex = function (maskPosition) { + var value = (this.rulesInsertionIndexBitmap >> maskPosition) & Mask; + value++; + ts.Debug.assert((value & Mask) === value, "Adding more rules into the sub-bucket than allowed. Maximum allowed is 32 rules."); + var temp = this.rulesInsertionIndexBitmap & ~(Mask << maskPosition); + temp |= value << maskPosition; + this.rulesInsertionIndexBitmap = temp; + }; + return RulesBucketConstructionState; + })(); + formatting.RulesBucketConstructionState = RulesBucketConstructionState; + var RulesBucket = (function () { + function RulesBucket() { + this.rules = []; + } + RulesBucket.prototype.Rules = function () { + return this.rules; + }; + RulesBucket.prototype.AddRule = function (rule, specificTokens, constructionState, rulesBucketIndex) { + var position; + if (rule.Operation.Action === 1 /* Ignore */) { + position = specificTokens ? + RulesPosition.IgnoreRulesSpecific : + RulesPosition.IgnoreRulesAny; + } + else if (!rule.Operation.Context.IsAny()) { + position = specificTokens ? + RulesPosition.ContextRulesSpecific : + RulesPosition.ContextRulesAny; + } + else { + position = specificTokens ? + RulesPosition.NoContextRulesSpecific : + RulesPosition.NoContextRulesAny; + } + var state = constructionState[rulesBucketIndex]; + if (state === undefined) { + state = constructionState[rulesBucketIndex] = new RulesBucketConstructionState(); + } + var index = state.GetInsertionIndex(position); + this.rules.splice(index, 0, rule); + state.IncreaseInsertionIndex(position); + }; + return RulesBucket; + })(); + formatting.RulesBucket = RulesBucket; + })(formatting = ts.formatting || (ts.formatting = {})); +})(ts || (ts = {})); +/// +/* @internal */ +var ts; +(function (ts) { + var formatting; + (function (formatting) { + var Shared; + (function (Shared) { + var TokenRangeAccess = (function () { + function TokenRangeAccess(from, to, except) { + this.tokens = []; + for (var token = from; token <= to; token++) { + if (except.indexOf(token) < 0) { + this.tokens.push(token); + } + } + } + TokenRangeAccess.prototype.GetTokens = function () { + return this.tokens; + }; + TokenRangeAccess.prototype.Contains = function (token) { + return this.tokens.indexOf(token) >= 0; + }; + return TokenRangeAccess; + })(); + Shared.TokenRangeAccess = TokenRangeAccess; + var TokenValuesAccess = (function () { + function TokenValuesAccess(tks) { + this.tokens = tks && tks.length ? tks : []; + } + TokenValuesAccess.prototype.GetTokens = function () { + return this.tokens; + }; + TokenValuesAccess.prototype.Contains = function (token) { + return this.tokens.indexOf(token) >= 0; + }; + return TokenValuesAccess; + })(); + Shared.TokenValuesAccess = TokenValuesAccess; + var TokenSingleValueAccess = (function () { + function TokenSingleValueAccess(token) { + this.token = token; + } + TokenSingleValueAccess.prototype.GetTokens = function () { + return [this.token]; + }; + TokenSingleValueAccess.prototype.Contains = function (tokenValue) { + return tokenValue === this.token; + }; + return TokenSingleValueAccess; + })(); + Shared.TokenSingleValueAccess = TokenSingleValueAccess; + var TokenAllAccess = (function () { + function TokenAllAccess() { + } + TokenAllAccess.prototype.GetTokens = function () { + var result = []; + for (var token = 0 /* FirstToken */; token <= 134 /* LastToken */; token++) { + result.push(token); + } + return result; + }; + TokenAllAccess.prototype.Contains = function (tokenValue) { + return true; + }; + TokenAllAccess.prototype.toString = function () { + return "[allTokens]"; + }; + return TokenAllAccess; + })(); + Shared.TokenAllAccess = TokenAllAccess; + var TokenRange = (function () { + function TokenRange(tokenAccess) { + this.tokenAccess = tokenAccess; + } + TokenRange.FromToken = function (token) { + return new TokenRange(new TokenSingleValueAccess(token)); + }; + TokenRange.FromTokens = function (tokens) { + return new TokenRange(new TokenValuesAccess(tokens)); + }; + TokenRange.FromRange = function (f, to, except) { + if (except === void 0) { except = []; } + return new TokenRange(new TokenRangeAccess(f, to, except)); + }; + TokenRange.AllTokens = function () { + return new TokenRange(new TokenAllAccess()); + }; + TokenRange.prototype.GetTokens = function () { + return this.tokenAccess.GetTokens(); + }; + TokenRange.prototype.Contains = function (token) { + return this.tokenAccess.Contains(token); + }; + TokenRange.prototype.toString = function () { + return this.tokenAccess.toString(); + }; + TokenRange.Any = TokenRange.AllTokens(); + TokenRange.AnyIncludingMultilineComments = TokenRange.FromTokens(TokenRange.Any.GetTokens().concat([3 /* MultiLineCommentTrivia */])); + TokenRange.Keywords = TokenRange.FromRange(70 /* FirstKeyword */, 134 /* LastKeyword */); + TokenRange.BinaryOperators = TokenRange.FromRange(25 /* FirstBinaryOperator */, 68 /* LastBinaryOperator */); + TokenRange.BinaryKeywordOperators = TokenRange.FromTokens([90 /* InKeyword */, 91 /* InstanceOfKeyword */, 134 /* OfKeyword */, 116 /* AsKeyword */, 124 /* IsKeyword */]); + TokenRange.UnaryPrefixOperators = TokenRange.FromTokens([41 /* PlusPlusToken */, 42 /* MinusMinusToken */, 50 /* TildeToken */, 49 /* ExclamationToken */]); + TokenRange.UnaryPrefixExpressions = TokenRange.FromTokens([8 /* NumericLiteral */, 69 /* Identifier */, 17 /* OpenParenToken */, 19 /* OpenBracketToken */, 15 /* OpenBraceToken */, 97 /* ThisKeyword */, 92 /* NewKeyword */]); + TokenRange.UnaryPreincrementExpressions = TokenRange.FromTokens([69 /* Identifier */, 17 /* OpenParenToken */, 97 /* ThisKeyword */, 92 /* NewKeyword */]); + TokenRange.UnaryPostincrementExpressions = TokenRange.FromTokens([69 /* Identifier */, 18 /* CloseParenToken */, 20 /* CloseBracketToken */, 92 /* NewKeyword */]); + TokenRange.UnaryPredecrementExpressions = TokenRange.FromTokens([69 /* Identifier */, 17 /* OpenParenToken */, 97 /* ThisKeyword */, 92 /* NewKeyword */]); + TokenRange.UnaryPostdecrementExpressions = TokenRange.FromTokens([69 /* Identifier */, 18 /* CloseParenToken */, 20 /* CloseBracketToken */, 92 /* NewKeyword */]); + TokenRange.Comments = TokenRange.FromTokens([2 /* SingleLineCommentTrivia */, 3 /* MultiLineCommentTrivia */]); + TokenRange.TypeNames = TokenRange.FromTokens([69 /* Identifier */, 128 /* NumberKeyword */, 130 /* StringKeyword */, 120 /* BooleanKeyword */, 131 /* SymbolKeyword */, 103 /* VoidKeyword */, 117 /* AnyKeyword */]); + return TokenRange; + })(); + Shared.TokenRange = TokenRange; + })(Shared = formatting.Shared || (formatting.Shared = {})); + })(formatting = ts.formatting || (ts.formatting = {})); +})(ts || (ts = {})); +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/* @internal */ +var ts; +(function (ts) { + var formatting; + (function (formatting) { + var RulesProvider = (function () { + function RulesProvider() { + this.globalRules = new formatting.Rules(); + } + RulesProvider.prototype.getRuleName = function (rule) { + return this.globalRules.getRuleName(rule); + }; + RulesProvider.prototype.getRuleByName = function (name) { + return this.globalRules[name]; + }; + RulesProvider.prototype.getRulesMap = function () { + return this.rulesMap; + }; + RulesProvider.prototype.ensureUpToDate = function (options) { + // TODO: Should this be '==='? + if (this.options == null || !ts.compareDataObjects(this.options, options)) { + var activeRules = this.createActiveRules(options); + var rulesMap = formatting.RulesMap.create(activeRules); + this.activeRules = activeRules; + this.rulesMap = rulesMap; + this.options = ts.clone(options); + } + }; + RulesProvider.prototype.createActiveRules = function (options) { + var rules = this.globalRules.HighPriorityCommonRules.slice(0); + if (options.InsertSpaceAfterCommaDelimiter) { + rules.push(this.globalRules.SpaceAfterComma); + } + else { + rules.push(this.globalRules.NoSpaceAfterComma); + } + if (options.InsertSpaceAfterFunctionKeywordForAnonymousFunctions) { + rules.push(this.globalRules.SpaceAfterAnonymousFunctionKeyword); + } + else { + rules.push(this.globalRules.NoSpaceAfterAnonymousFunctionKeyword); + } + if (options.InsertSpaceAfterKeywordsInControlFlowStatements) { + rules.push(this.globalRules.SpaceAfterKeywordInControl); + } + else { + rules.push(this.globalRules.NoSpaceAfterKeywordInControl); + } + if (options.InsertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis) { + rules.push(this.globalRules.SpaceAfterOpenParen); + rules.push(this.globalRules.SpaceBeforeCloseParen); + rules.push(this.globalRules.NoSpaceBetweenParens); + } + else { + rules.push(this.globalRules.NoSpaceAfterOpenParen); + rules.push(this.globalRules.NoSpaceBeforeCloseParen); + rules.push(this.globalRules.NoSpaceBetweenParens); + } + if (options.InsertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets) { + rules.push(this.globalRules.SpaceAfterOpenBracket); + rules.push(this.globalRules.SpaceBeforeCloseBracket); + rules.push(this.globalRules.NoSpaceBetweenBrackets); + } + else { + rules.push(this.globalRules.NoSpaceAfterOpenBracket); + rules.push(this.globalRules.NoSpaceBeforeCloseBracket); + rules.push(this.globalRules.NoSpaceBetweenBrackets); + } + if (options.InsertSpaceAfterSemicolonInForStatements) { + rules.push(this.globalRules.SpaceAfterSemicolonInFor); + } + else { + rules.push(this.globalRules.NoSpaceAfterSemicolonInFor); + } + if (options.InsertSpaceBeforeAndAfterBinaryOperators) { + rules.push(this.globalRules.SpaceBeforeBinaryOperator); + rules.push(this.globalRules.SpaceAfterBinaryOperator); + } + else { + rules.push(this.globalRules.NoSpaceBeforeBinaryOperator); + rules.push(this.globalRules.NoSpaceAfterBinaryOperator); + } + if (options.PlaceOpenBraceOnNewLineForControlBlocks) { + rules.push(this.globalRules.NewLineBeforeOpenBraceInControl); + } + if (options.PlaceOpenBraceOnNewLineForFunctions) { + rules.push(this.globalRules.NewLineBeforeOpenBraceInFunction); + rules.push(this.globalRules.NewLineBeforeOpenBraceInTypeScriptDeclWithBlock); + } + rules = rules.concat(this.globalRules.LowPriorityCommonRules); + return rules; + }; + return RulesProvider; + })(); + formatting.RulesProvider = RulesProvider; + })(formatting = ts.formatting || (ts.formatting = {})); +})(ts || (ts = {})); +/// +/// +/// +/// +/* @internal */ +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) { + return []; + } + // get the span for the previous\current line + var span = { + // get start position for the previous line + pos: ts.getStartPositionOfLine(line - 1, sourceFile), + // get end position for the current line (end value is exclusive so add 1 to the result) + end: ts.getEndLinePosition(line, sourceFile) + 1 + }; + return formatSpan(span, sourceFile, options, rulesProvider, 2 /* FormatOnEnter */); + } + formatting.formatOnEnter = formatOnEnter; + function formatOnSemicolon(position, sourceFile, rulesProvider, options) { + return formatOutermostParent(position, 23 /* 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 */); + } + formatting.formatOnClosingCurly = formatOnClosingCurly; + function formatDocument(sourceFile, rulesProvider, options) { + var span = { + pos: 0, + end: sourceFile.text.length + }; + return formatSpan(span, sourceFile, options, rulesProvider, 0 /* FormatDocument */); + } + formatting.formatDocument = formatDocument; + function formatSelection(start, end, sourceFile, rulesProvider, options) { + // format from the beginning of the line + var span = { + pos: ts.getLineStartPositionForPosition(start, sourceFile), + end: end + }; + return formatSpan(span, sourceFile, options, rulesProvider, 1 /* FormatSelection */); + } + formatting.formatSelection = formatSelection; + function formatOutermostParent(position, expectedLastToken, sourceFile, options, rulesProvider, requestKind) { + var parent = findOutermostParent(position, expectedLastToken, sourceFile); + if (!parent) { + return []; + } + var span = { + pos: ts.getLineStartPositionForPosition(parent.getStart(sourceFile), sourceFile), + end: parent.end + }; + return formatSpan(span, sourceFile, options, rulesProvider, requestKind); + } + function findOutermostParent(position, expectedTokenKind, sourceFile) { + var precedingToken = ts.findPrecedingToken(position, sourceFile); + // when it is claimed that trigger character was typed at given position + // we verify that there is a token with a matching kind whose end is equal to position (because the character was just typed). + // If this condition is not hold - then trigger character was typed in some other context, + // i.e.in comment and thus should not trigger autoformatting + if (!precedingToken || + precedingToken.kind !== expectedTokenKind || + position !== precedingToken.getEnd()) { + return undefined; + } + // walk up and search for the parent node that ends at the same position with precedingToken. + // for cases like this + // + // let x = 1; + // while (true) { + // } + // after typing close curly in while statement we want to reformat just the while statement. + // However if we just walk upwards searching for the parent that has the same end value - + // we'll end up with the whole source file. isListElement allows to stop on the list element level + var current = precedingToken; + while (current && + current.parent && + current.parent.end === precedingToken.end && + !isListElement(current.parent, current)) { + current = current.parent; + } + return current; + } + // Returns true if node is a element in some list in parent + // 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 214 /* ClassDeclaration */: + case 215 /* InterfaceDeclaration */: + return ts.rangeContainsRange(parent.members, node); + case 218 /* ModuleDeclaration */: + var body = parent.body; + return body && body.kind === 192 /* Block */ && ts.rangeContainsRange(body.statements, node); + case 248 /* SourceFile */: + case 192 /* Block */: + case 219 /* ModuleBlock */: + return ts.rangeContainsRange(parent.statements, node); + case 244 /* CatchClause */: + return ts.rangeContainsRange(parent.block.statements, node); + } + return false; + } + /** find node that fully contains given text range */ + function findEnclosingNode(range, sourceFile) { + return find(sourceFile); + function find(n) { + var candidate = ts.forEachChild(n, function (c) { return ts.startEndContainsRange(c.getStart(sourceFile), c.end, range) && c; }); + if (candidate) { + var result = find(candidate); + if (result) { + return result; + } + } + return n; + } + } + /** formatting is not applied to ranges that contain parse errors. + * This function will return a predicate that for a given text range will tell + * if there are any parse errors that overlap with the range. + */ + function prepareRangeContainsErrorFunction(errors, originalRange) { + if (!errors.length) { + return rangeHasNoErrors; + } + // pick only errors that fall in range + var sorted = errors + .filter(function (d) { return ts.rangeOverlapsWithStartEnd(originalRange, d.start, d.start + d.length); }) + .sort(function (e1, e2) { return e1.start - e2.start; }); + if (!sorted.length) { + return rangeHasNoErrors; + } + var index = 0; + return function (r) { + // in current implementation sequence of arguments [r1, r2...] is monotonically increasing. + // 'index' tracks the index of the most recent error that was checked. + while (true) { + if (index >= sorted.length) { + // all errors in the range were already checked -> no error in specified range + return false; + } + var error = sorted[index]; + if (r.end <= error.start) { + // specified range ends before the error refered by 'index' - no error in range + return false; + } + if (ts.startEndOverlapsWithStartEnd(r.pos, r.end, error.start, error.start + error.length)) { + // specified range overlaps with error range + return true; + } + index++; + } + }; + function rangeHasNoErrors(r) { + return false; + } + } + /** + * Start of the original range might fall inside the comment - scanner will not yield appropriate results + * This function will look for token that is located before the start of target range + * and return its end as start position for the scanner. + */ + function getScanStartPosition(enclosingNode, originalRange, sourceFile) { + var start = enclosingNode.getStart(sourceFile); + if (start === originalRange.pos && enclosingNode.end === originalRange.end) { + return start; + } + var precedingToken = ts.findPrecedingToken(originalRange.pos, sourceFile); + if (!precedingToken) { + // no preceding token found - start from the beginning of enclosing node + return enclosingNode.pos; + } + // preceding token ends after the start of original range (i.e when originaRange.pos falls in the middle of literal) + // start from the beginning of enclosingNode to handle the entire 'originalRange' + if (precedingToken.end >= originalRange.pos) { + return enclosingNode.pos; + } + return precedingToken.end; + } + /* + * For cases like + * if (a || + * b ||$ + * c) {...} + * If we hit Enter at $ we want line ' b ||' to be indented. + * Formatting will be applied to the last two lines. + * Node that fully encloses these lines is binary expression 'a ||...'. + * Initial indentation for this node will be 0. + * Binary expressions don't introduce new indentation scopes, however it is possible + * that some parent node on the same line does - like if statement in this case. + * Note that we are considering parents only from the same line with initial node - + * if parent is on the different line - its delta was already contributed + * to the initial indentation. + */ + function getOwnOrInheritedDelta(n, options, sourceFile) { + var previousLine = -1 /* Unknown */; + var childKind = 0 /* Unknown */; + while (n) { + var line = sourceFile.getLineAndCharacterOfPosition(n.getStart(sourceFile)).line; + if (previousLine !== -1 /* Unknown */ && line !== previousLine) { + break; + } + if (formatting.SmartIndenter.shouldIndentChildNode(n.kind, childKind)) { + return options.IndentSize; + } + previousLine = line; + childKind = n.kind; + n = n.parent; + } + return 0; + } + function formatSpan(originalRange, sourceFile, options, rulesProvider, requestKind) { + var rangeContainsError = prepareRangeContainsErrorFunction(sourceFile.parseDiagnostics, originalRange); + // formatting context is used by rules provider + var formattingContext = new formatting.FormattingContext(sourceFile, requestKind); + // find the smallest node that fully wraps the range and compute the initial indentation for the node + var enclosingNode = findEnclosingNode(originalRange, sourceFile); + var formattingScanner = formatting.getFormattingScanner(sourceFile, getScanStartPosition(enclosingNode, originalRange, sourceFile), originalRange.end); + var initialIndentation = formatting.SmartIndenter.getIndentationForNode(enclosingNode, originalRange, sourceFile, options); + var previousRangeHasError; + var previousRange; + var previousParent; + var previousRangeStartLine; + var lastIndentedLine; + var indentationOnLastIndentedLine; + var edits = []; + formattingScanner.advance(); + if (formattingScanner.isOnToken()) { + var startLine = sourceFile.getLineAndCharacterOfPosition(enclosingNode.getStart(sourceFile)).line; + var undecoratedStartLine = startLine; + if (enclosingNode.decorators) { + undecoratedStartLine = sourceFile.getLineAndCharacterOfPosition(ts.getNonDecoratorTokenPosOfNode(enclosingNode, sourceFile)).line; + } + var delta = getOwnOrInheritedDelta(enclosingNode, options, sourceFile); + processNode(enclosingNode, enclosingNode, startLine, undecoratedStartLine, initialIndentation, delta); + } + formattingScanner.close(); + return edits; + // local functions + /** Tries to compute the indentation for a list element. + * If list element is not in range then + * function will pick its actual indentation + * so it can be pushed downstream as inherited indentation. + * If list element is in the range - its indentation will be equal + * to inherited indentation from its predecessors. + */ + function tryComputeIndentationForListItem(startPos, endPos, parentStartLine, range, inheritedIndentation) { + if (ts.rangeOverlapsWithStartEnd(range, startPos, endPos)) { + if (inheritedIndentation !== -1 /* Unknown */) { + return inheritedIndentation; + } + } + else { + var startLine = sourceFile.getLineAndCharacterOfPosition(startPos).line; + var startLinePosition = ts.getLineStartPositionForPosition(startPos, sourceFile); + var column = formatting.SmartIndenter.findFirstNonWhitespaceColumn(startLinePosition, startPos, sourceFile, options); + if (startLine !== parentStartLine || startPos === column) { + return column; + } + } + return -1 /* Unknown */; + } + function computeIndentation(node, startLine, inheritedIndentation, parent, parentDynamicIndentation, effectiveParentStartLine) { + var indentation = inheritedIndentation; + if (indentation === -1 /* Unknown */) { + if (isSomeBlock(node.kind)) { + // blocks should be indented in + // - other blocks + // - source file + // - switch\default clauses + if (isSomeBlock(parent.kind) || + parent.kind === 248 /* SourceFile */ || + parent.kind === 241 /* CaseClause */ || + parent.kind === 242 /* DefaultClause */) { + indentation = parentDynamicIndentation.getIndentation() + parentDynamicIndentation.getDelta(); + } + else { + indentation = parentDynamicIndentation.getIndentation(); + } + } + else { + if (formatting.SmartIndenter.childStartsOnTheSameLineWithElseInIfStatement(parent, node, startLine, sourceFile)) { + indentation = parentDynamicIndentation.getIndentation(); + } + else { + indentation = parentDynamicIndentation.getIndentation() + parentDynamicIndentation.getDelta(); + } + } + } + var delta = formatting.SmartIndenter.shouldIndentChildNode(node.kind, 0 /* Unknown */) ? options.IndentSize : 0; + if (effectiveParentStartLine === startLine) { + // if node is located on the same line with the parent + // - inherit indentation from the parent + // - push children if either parent of node itself has non-zero delta + indentation = startLine === lastIndentedLine + ? indentationOnLastIndentedLine + : parentDynamicIndentation.getIndentation(); + delta = Math.min(options.IndentSize, parentDynamicIndentation.getDelta() + delta); + } + return { + indentation: indentation, + delta: delta + }; + } + function getFirstNonDecoratorTokenOfNode(node) { + if (node.modifiers && node.modifiers.length) { + return node.modifiers[0].kind; + } + switch (node.kind) { + case 214 /* ClassDeclaration */: return 73 /* ClassKeyword */; + case 215 /* InterfaceDeclaration */: return 107 /* InterfaceKeyword */; + case 213 /* FunctionDeclaration */: return 87 /* FunctionKeyword */; + case 217 /* EnumDeclaration */: return 217 /* EnumDeclaration */; + case 145 /* GetAccessor */: return 123 /* GetKeyword */; + case 146 /* SetAccessor */: return 129 /* SetKeyword */; + case 143 /* MethodDeclaration */: + if (node.asteriskToken) { + return 37 /* AsteriskToken */; + } + // fall-through + case 141 /* PropertyDeclaration */: + case 138 /* Parameter */: + return node.name.kind; + } + } + function getDynamicIndentation(node, nodeStartLine, indentation, delta) { + return { + getIndentationForComment: function (kind, tokenIndentation) { + switch (kind) { + // preceding comment to the token that closes the indentation scope inherits the indentation from the scope + // .. { + // // comment + // } + case 16 /* CloseBraceToken */: + case 20 /* CloseBracketToken */: + case 18 /* CloseParenToken */: + return indentation + delta; + } + return tokenIndentation !== -1 /* Unknown */ ? tokenIndentation : indentation; + }, + getIndentationForToken: function (line, kind) { + if (nodeStartLine !== line && node.decorators) { + if (kind === getFirstNonDecoratorTokenOfNode(node)) { + // if this token is the first token following the list of decorators, we do not need to indent + return indentation; + } + } + 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 */: + return indentation; + default: + // if token line equals to the line of containing node (this is a first token in the node) - use node indentation + return nodeStartLine !== line ? indentation + delta : indentation; + } + }, + getIndentation: function () { return indentation; }, + getDelta: function () { return delta; }, + recomputeIndentation: function (lineAdded) { + if (node.parent && formatting.SmartIndenter.shouldIndentChildNode(node.parent.kind, node.kind)) { + if (lineAdded) { + indentation += options.IndentSize; + } + else { + indentation -= options.IndentSize; + } + if (formatting.SmartIndenter.shouldIndentChildNode(node.kind, 0 /* Unknown */)) { + delta = options.IndentSize; + } + else { + delta = 0; + } + } + } + }; + } + function processNode(node, contextNode, nodeStartLine, undecoratedNodeStartLine, indentation, delta) { + if (!ts.rangeOverlapsWithStartEnd(originalRange, node.getStart(sourceFile), node.getEnd())) { + return; + } + var nodeDynamicIndentation = getDynamicIndentation(node, nodeStartLine, indentation, delta); + // a useful observations when tracking context node + // / + // [a] + // / | \ + // [b] [c] [d] + // node 'a' is a context node for nodes 'b', 'c', 'd' + // except for the leftmost leaf token in [b] - in this case context node ('e') is located somewhere above 'a' + // this rule can be applied recursively to child nodes of 'a'. + // + // context node is set to parent node value after processing every child node + // context node is set to parent of the token after processing every token + var childContextNode = contextNode; + // if there are any tokens that logically belong to node and interleave child nodes + // such tokens will be consumed in processChildNode for for the child that follows them + ts.forEachChild(node, function (child) { + processChildNode(child, /*inheritedIndentation*/ -1 /* Unknown */, node, nodeDynamicIndentation, nodeStartLine, undecoratedNodeStartLine, /*isListElement*/ false); + }, function (nodes) { + processChildNodes(nodes, node, nodeStartLine, nodeDynamicIndentation); + }); + // proceed any tokens in the node that are located after child nodes + while (formattingScanner.isOnToken()) { + var tokenInfo = formattingScanner.readTokenInfo(node); + if (tokenInfo.token.end > node.end) { + break; + } + consumeTokenAndAdvanceScanner(tokenInfo, node, nodeDynamicIndentation); + } + function processChildNode(child, inheritedIndentation, parent, parentDynamicIndentation, parentStartLine, undecoratedParentStartLine, isListItem) { + var childStartPos = child.getStart(sourceFile); + var childStartLine = sourceFile.getLineAndCharacterOfPosition(childStartPos).line; + var undecoratedChildStartLine = childStartLine; + if (child.decorators) { + undecoratedChildStartLine = sourceFile.getLineAndCharacterOfPosition(ts.getNonDecoratorTokenPosOfNode(child, sourceFile)).line; + } + // if child is a list item - try to get its indentation + var childIndentationAmount = -1 /* Unknown */; + if (isListItem) { + childIndentationAmount = tryComputeIndentationForListItem(childStartPos, child.end, parentStartLine, originalRange, inheritedIndentation); + if (childIndentationAmount !== -1 /* Unknown */) { + inheritedIndentation = childIndentationAmount; + } + } + // child node is outside the target range - do not dive inside + if (!ts.rangeOverlapsWithStartEnd(originalRange, child.pos, child.end)) { + return inheritedIndentation; + } + if (child.getFullWidth() === 0) { + return inheritedIndentation; + } + while (formattingScanner.isOnToken()) { + // proceed any parent tokens that are located prior to child.getStart() + var tokenInfo = formattingScanner.readTokenInfo(node); + if (tokenInfo.token.end > childStartPos) { + // stop when formatting scanner advances past the beginning of the child + break; + } + consumeTokenAndAdvanceScanner(tokenInfo, node, parentDynamicIndentation); + } + if (!formattingScanner.isOnToken()) { + return inheritedIndentation; + } + if (ts.isToken(child)) { + // 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); + consumeTokenAndAdvanceScanner(tokenInfo, node, parentDynamicIndentation); + return inheritedIndentation; + } + var effectiveParentStartLine = child.kind === 139 /* Decorator */ ? childStartLine : undecoratedParentStartLine; + var childIndentation = computeIndentation(child, childStartLine, childIndentationAmount, node, parentDynamicIndentation, effectiveParentStartLine); + processNode(child, childContextNode, childStartLine, undecoratedChildStartLine, childIndentation.indentation, childIndentation.delta); + childContextNode = node; + return inheritedIndentation; + } + function processChildNodes(nodes, parent, parentStartLine, parentDynamicIndentation) { + var listStartToken = getOpenTokenForList(parent, nodes); + var listEndToken = getCloseTokenForOpenToken(listStartToken); + var listDynamicIndentation = parentDynamicIndentation; + var startLine = parentStartLine; + if (listStartToken !== 0 /* Unknown */) { + // introduce a new indentation scope for lists (including list start and end tokens) + while (formattingScanner.isOnToken()) { + var tokenInfo = formattingScanner.readTokenInfo(parent); + if (tokenInfo.token.end > nodes.pos) { + // stop when formatting scanner moves past the beginning of node list + break; + } + else if (tokenInfo.token.kind === listStartToken) { + // consume list start token + startLine = sourceFile.getLineAndCharacterOfPosition(tokenInfo.token.pos).line; + var indentation_1 = computeIndentation(tokenInfo.token, startLine, -1 /* Unknown */, parent, parentDynamicIndentation, parentStartLine); + listDynamicIndentation = getDynamicIndentation(parent, parentStartLine, indentation_1.indentation, indentation_1.delta); + consumeTokenAndAdvanceScanner(tokenInfo, parent, listDynamicIndentation); + } + else { + // consume any tokens that precede the list as child elements of 'node' using its indentation scope + consumeTokenAndAdvanceScanner(tokenInfo, parent, parentDynamicIndentation); + } + } + } + var inheritedIndentation = -1 /* Unknown */; + for (var _i = 0; _i < nodes.length; _i++) { + var child = nodes[_i]; + inheritedIndentation = processChildNode(child, inheritedIndentation, node, listDynamicIndentation, startLine, startLine, /*isListElement*/ true); + } + if (listEndToken !== 0 /* Unknown */) { + if (formattingScanner.isOnToken()) { + var tokenInfo = formattingScanner.readTokenInfo(parent); + // consume the list end token only if it is still belong to the parent + // there might be the case when current token matches end token but does not considered as one + // function (x: function) <-- + // without this check close paren will be interpreted as list end token for function expression which is wrong + if (tokenInfo.token.kind === listEndToken && ts.rangeContainsRange(parent, tokenInfo.token)) { + // consume list end token + consumeTokenAndAdvanceScanner(tokenInfo, parent, listDynamicIndentation); + } + } + } + } + function consumeTokenAndAdvanceScanner(currentTokenInfo, parent, dynamicIndentation) { + ts.Debug.assert(ts.rangeContainsRange(parent, currentTokenInfo.token)); + var lastTriviaWasNewLine = formattingScanner.lastTrailingTriviaWasNewLine(); + var indentToken = false; + if (currentTokenInfo.leadingTrivia) { + processTrivia(currentTokenInfo.leadingTrivia, parent, childContextNode, dynamicIndentation); + } + var lineAdded; + var isTokenInRange = ts.rangeContainsRange(originalRange, currentTokenInfo.token); + var tokenStart = sourceFile.getLineAndCharacterOfPosition(currentTokenInfo.token.pos); + if (isTokenInRange) { + var rangeHasError = rangeContainsError(currentTokenInfo.token); + // save previousRange since processRange will overwrite this value with current one + var savePreviousRange = previousRange; + lineAdded = processRange(currentTokenInfo.token, tokenStart, parent, childContextNode, dynamicIndentation); + if (rangeHasError) { + // do not indent comments\token if token range overlaps with some error + indentToken = false; + } + else { + if (lineAdded !== undefined) { + indentToken = lineAdded; + } + else { + // indent token only if end line of previous range does not match start line of the token + var prevEndLine = savePreviousRange && sourceFile.getLineAndCharacterOfPosition(savePreviousRange.end).line; + indentToken = lastTriviaWasNewLine && tokenStart.line !== prevEndLine; + } + } + } + if (currentTokenInfo.trailingTrivia) { + processTrivia(currentTokenInfo.trailingTrivia, parent, childContextNode, dynamicIndentation); + } + if (indentToken) { + var tokenIndentation = (isTokenInRange && !rangeContainsError(currentTokenInfo.token)) ? + dynamicIndentation.getIndentationForToken(tokenStart.line, currentTokenInfo.token.kind) : + -1 /* Unknown */; + if (currentTokenInfo.leadingTrivia) { + var commentIndentation = dynamicIndentation.getIndentationForComment(currentTokenInfo.token.kind, tokenIndentation); + var indentNextTokenOrTrivia = true; + for (var _i = 0, _a = currentTokenInfo.leadingTrivia; _i < _a.length; _i++) { + var triviaItem = _a[_i]; + if (!ts.rangeContainsRange(originalRange, triviaItem)) { + continue; + } + switch (triviaItem.kind) { + case 3 /* MultiLineCommentTrivia */: + indentMultilineComment(triviaItem, commentIndentation, /*firstLineIsIndented*/ !indentNextTokenOrTrivia); + indentNextTokenOrTrivia = false; + break; + case 2 /* SingleLineCommentTrivia */: + if (indentNextTokenOrTrivia) { + insertIndentation(triviaItem.pos, commentIndentation, /*lineAdded*/ false); + indentNextTokenOrTrivia = false; + } + break; + case 4 /* NewLineTrivia */: + indentNextTokenOrTrivia = true; + break; + } + } + } + // indent token only if is it is in target range and does not overlap with any error ranges + if (tokenIndentation !== -1 /* Unknown */) { + insertIndentation(currentTokenInfo.token.pos, tokenIndentation, lineAdded); + lastIndentedLine = tokenStart.line; + indentationOnLastIndentedLine = tokenIndentation; + } + } + formattingScanner.advance(); + childContextNode = parent; + } + } + function processTrivia(trivia, parent, contextNode, dynamicIndentation) { + for (var _i = 0; _i < trivia.length; _i++) { + var triviaItem = trivia[_i]; + if (ts.isComment(triviaItem.kind) && ts.rangeContainsRange(originalRange, triviaItem)) { + var triviaItemStart = sourceFile.getLineAndCharacterOfPosition(triviaItem.pos); + processRange(triviaItem, triviaItemStart, parent, contextNode, dynamicIndentation); + } + } + } + function processRange(range, rangeStart, parent, contextNode, dynamicIndentation) { + var rangeHasError = rangeContainsError(range); + var lineAdded; + if (!rangeHasError && !previousRangeHasError) { + if (!previousRange) { + // trim whitespaces starting from the beginning of the span up to the current line + var originalStart = sourceFile.getLineAndCharacterOfPosition(originalRange.pos); + trimTrailingWhitespacesForLines(originalStart.line, rangeStart.line); + } + else { + lineAdded = + processPair(range, rangeStart.line, parent, previousRange, previousRangeStartLine, previousParent, contextNode, dynamicIndentation); + } + } + previousRange = range; + previousParent = parent; + previousRangeStartLine = rangeStart.line; + previousRangeHasError = rangeHasError; + return lineAdded; + } + function processPair(currentItem, currentStartLine, currentParent, previousItem, previousStartLine, previousParent, contextNode, dynamicIndentation) { + formattingContext.updateContext(previousItem, previousParent, currentItem, currentParent, contextNode); + var rule = rulesProvider.getRulesMap().GetRule(formattingContext); + var trimTrailingWhitespaces; + var lineAdded; + if (rule) { + applyRuleEdits(rule, previousItem, previousStartLine, currentItem, currentStartLine); + if (rule.Operation.Action & (2 /* Space */ | 8 /* Delete */) && currentStartLine !== previousStartLine) { + lineAdded = false; + // Handle the case where the next line is moved to be the end of this line. + // In this case we don't indent the next line in the next pass. + if (currentParent.getStart(sourceFile) === currentItem.pos) { + dynamicIndentation.recomputeIndentation(/*lineAdded*/ false); + } + } + else if (rule.Operation.Action & 4 /* NewLine */ && currentStartLine === previousStartLine) { + lineAdded = true; + // Handle the case where token2 is moved to the new line. + // In this case we indent token2 in the next pass but we set + // sameLineIndent flag to notify the indenter that the indentation is within the line. + if (currentParent.getStart(sourceFile) === currentItem.pos) { + dynamicIndentation.recomputeIndentation(/*lineAdded*/ true); + } + } + // We need to trim trailing whitespace between the tokens if they were on different lines, and no rule was applied to put them on the same line + trimTrailingWhitespaces = + (rule.Operation.Action & (4 /* NewLine */ | 2 /* Space */)) && + rule.Flag !== 1 /* CanDeleteNewLines */; + } + else { + trimTrailingWhitespaces = true; + } + if (currentStartLine !== previousStartLine && trimTrailingWhitespaces) { + // We need to trim trailing whitespace between the tokens if they were on different lines, and no rule was applied to put them on the same line + trimTrailingWhitespacesForLines(previousStartLine, currentStartLine, previousItem); + } + return lineAdded; + } + function insertIndentation(pos, indentation, lineAdded) { + var indentationString = getIndentationString(indentation, options); + if (lineAdded) { + // new line is added before the token by the formatting rules + // insert indentation string at the very beginning of the token + recordReplace(pos, 0, indentationString); + } + else { + var tokenStart = sourceFile.getLineAndCharacterOfPosition(pos); + if (indentation !== tokenStart.character) { + var startLinePosition = ts.getStartPositionOfLine(tokenStart.line, sourceFile); + recordReplace(startLinePosition, tokenStart.character, indentationString); + } + } + } + function indentMultilineComment(commentRange, indentation, firstLineIsIndented) { + // split comment in lines + var startLine = sourceFile.getLineAndCharacterOfPosition(commentRange.pos).line; + var endLine = sourceFile.getLineAndCharacterOfPosition(commentRange.end).line; + var parts; + if (startLine === endLine) { + if (!firstLineIsIndented) { + // treat as single line comment + insertIndentation(commentRange.pos, indentation, /*lineAdded*/ false); + } + return; + } + else { + parts = []; + var startPos = commentRange.pos; + for (var line = startLine; line < endLine; ++line) { + var endOfLine = ts.getEndLinePosition(line, sourceFile); + parts.push({ pos: startPos, end: endOfLine }); + startPos = ts.getStartPositionOfLine(line + 1, sourceFile); + } + parts.push({ pos: startPos, end: commentRange.end }); + } + var startLinePos = ts.getStartPositionOfLine(startLine, sourceFile); + var nonWhitespaceColumnInFirstPart = formatting.SmartIndenter.findFirstNonWhitespaceCharacterAndColumn(startLinePos, parts[0].pos, sourceFile, options); + if (indentation === nonWhitespaceColumnInFirstPart.column) { + return; + } + var startIndex = 0; + if (firstLineIsIndented) { + startIndex = 1; + startLine++; + } + // shift all parts on the delta size + var delta = indentation - nonWhitespaceColumnInFirstPart.column; + for (var i = startIndex, len = parts.length; i < len; ++i, ++startLine) { + var startLinePos_1 = ts.getStartPositionOfLine(startLine, sourceFile); + var nonWhitespaceCharacterAndColumn = i === 0 + ? nonWhitespaceColumnInFirstPart + : formatting.SmartIndenter.findFirstNonWhitespaceCharacterAndColumn(parts[i].pos, parts[i].end, sourceFile, options); + var newIndentation = nonWhitespaceCharacterAndColumn.column + delta; + if (newIndentation > 0) { + var indentationString = getIndentationString(newIndentation, options); + recordReplace(startLinePos_1, nonWhitespaceCharacterAndColumn.character, indentationString); + } + else { + recordDelete(startLinePos_1, nonWhitespaceCharacterAndColumn.character); + } + } + } + function trimTrailingWhitespacesForLines(line1, line2, range) { + for (var line = line1; line < line2; ++line) { + var lineStartPosition = ts.getStartPositionOfLine(line, sourceFile); + var lineEndPosition = ts.getEndLinePosition(line, sourceFile); + // do not trim whitespaces in comments or template expression + if (range && (ts.isComment(range.kind) || ts.isStringOrRegularExpressionOrTemplateLiteral(range.kind)) && range.pos <= lineEndPosition && range.end > lineEndPosition) { + continue; + } + var pos = lineEndPosition; + while (pos >= lineStartPosition && ts.isWhiteSpace(sourceFile.text.charCodeAt(pos))) { + pos--; + } + if (pos !== lineEndPosition) { + ts.Debug.assert(pos === lineStartPosition || !ts.isWhiteSpace(sourceFile.text.charCodeAt(pos))); + recordDelete(pos + 1, lineEndPosition - pos); + } + } + } + function newTextChange(start, len, newText) { + return { span: ts.createTextSpan(start, len), newText: newText }; + } + function recordDelete(start, len) { + if (len) { + edits.push(newTextChange(start, len, "")); + } + } + function recordReplace(start, len, newText) { + if (len || newText) { + edits.push(newTextChange(start, len, newText)); + } + } + function applyRuleEdits(rule, previousRange, previousStartLine, currentRange, currentStartLine) { + var between; + switch (rule.Operation.Action) { + case 1 /* Ignore */: + // no action required + return; + case 8 /* Delete */: + if (previousRange.end !== currentRange.pos) { + // delete characters starting from t1.end up to t2.pos exclusive + recordDelete(previousRange.end, currentRange.pos - previousRange.end); + } + break; + case 4 /* NewLine */: + // exit early if we on different lines and rule cannot change number of newlines + // if line1 and line2 are on subsequent lines then no edits are required - ok to exit + // if line1 and line2 are separated with more than one newline - ok to exit since we cannot delete extra new lines + if (rule.Flag !== 1 /* CanDeleteNewLines */ && previousStartLine !== currentStartLine) { + return; + } + // 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); + } + break; + case 2 /* Space */: + // exit early if we on different lines and rule cannot change number of newlines + if (rule.Flag !== 1 /* CanDeleteNewLines */ && previousStartLine !== currentStartLine) { + return; + } + var posDelta = currentRange.pos - previousRange.end; + if (posDelta !== 1 || sourceFile.text.charCodeAt(previousRange.end) !== 32 /* space */) { + recordReplace(previousRange.end, currentRange.pos - previousRange.end, " "); + } + break; + } + } + } + function isSomeBlock(kind) { + switch (kind) { + case 192 /* Block */: + case 219 /* ModuleBlock */: + return true; + } + return false; + } + function getOpenTokenForList(node, list) { + switch (node.kind) { + case 144 /* Constructor */: + case 213 /* FunctionDeclaration */: + case 173 /* FunctionExpression */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: + case 174 /* ArrowFunction */: + if (node.typeParameters === list) { + return 25 /* LessThanToken */; + } + else if (node.parameters === list) { + return 17 /* OpenParenToken */; + } + break; + case 168 /* CallExpression */: + case 169 /* NewExpression */: + if (node.typeArguments === list) { + return 25 /* LessThanToken */; + } + else if (node.arguments === list) { + return 17 /* OpenParenToken */; + } + break; + case 151 /* TypeReference */: + if (node.typeArguments === list) { + return 25 /* LessThanToken */; + } + } + return 0 /* Unknown */; + } + function getCloseTokenForOpenToken(kind) { + switch (kind) { + case 17 /* OpenParenToken */: + return 18 /* CloseParenToken */; + case 25 /* LessThanToken */: + return 27 /* GreaterThanToken */; + } + return 0 /* Unknown */; + } + var internedSizes; + var internedTabsIndentation; + var internedSpacesIndentation; + function getIndentationString(indentation, options) { + // reset interned strings if FormatCodeOptions were changed + var resetInternedStrings = !internedSizes || (internedSizes.tabSize !== options.TabSize || internedSizes.indentSize !== options.IndentSize); + if (resetInternedStrings) { + internedSizes = { tabSize: options.TabSize, indentSize: options.IndentSize }; + internedTabsIndentation = internedSpacesIndentation = undefined; + } + if (!options.ConvertTabsToSpaces) { + var tabs = Math.floor(indentation / options.TabSize); + var spaces = indentation - tabs * options.TabSize; + var tabString; + if (!internedTabsIndentation) { + internedTabsIndentation = []; + } + if (internedTabsIndentation[tabs] === undefined) { + internedTabsIndentation[tabs] = tabString = repeat('\t', tabs); + } + else { + tabString = internedTabsIndentation[tabs]; + } + return spaces ? tabString + repeat(" ", spaces) : tabString; + } + else { + var spacesString; + var quotient = Math.floor(indentation / options.IndentSize); + var remainder = indentation % options.IndentSize; + if (!internedSpacesIndentation) { + internedSpacesIndentation = []; + } + if (internedSpacesIndentation[quotient] === undefined) { + spacesString = repeat(" ", options.IndentSize * quotient); + internedSpacesIndentation[quotient] = spacesString; + } + else { + spacesString = internedSpacesIndentation[quotient]; + } + return remainder ? spacesString + repeat(" ", remainder) : spacesString; + } + function repeat(value, count) { + var s = ""; + for (var i = 0; i < count; ++i) { + s += value; + } + return s; + } + } + formatting.getIndentationString = getIndentationString; + })(formatting = ts.formatting || (ts.formatting = {})); +})(ts || (ts = {})); +/// +/* @internal */ +var ts; +(function (ts) { + var formatting; + (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 0; // past EOF + } + // no indentation when the indent style is set to none, + // so we can return fast + if (options.IndentStyle === ts.IndentStyle.None) { + return 0; + } + var precedingToken = ts.findPrecedingToken(position, sourceFile); + if (!precedingToken) { + return 0; + } + // no indentation in string \regex\template literals + var precedingTokenIsLiteral = ts.isStringOrRegularExpressionOrTemplateLiteral(precedingToken.kind); + if (precedingTokenIsLiteral && precedingToken.getStart(sourceFile) <= position && precedingToken.end > position) { + return 0; + } + var lineAtPosition = sourceFile.getLineAndCharacterOfPosition(position).line; + // indentation is first non-whitespace character in a previous line + // for block indentation, we should look for a line which contains something that's not + // whitespace. + if (options.IndentStyle === ts.IndentStyle.Block) { + // move backwards until we find a line with a non-whitespace character, + // then find the first non-whitespace character for that line. + var current_1 = position; + while (current_1 > 0) { + var char = sourceFile.text.charCodeAt(current_1); + if (!ts.isWhiteSpace(char) && !ts.isLineBreak(char)) { + break; + } + current_1--; + } + var lineStart = ts.getLineStartPositionForPosition(current_1, sourceFile); + return SmartIndenter.findFirstNonWhitespaceColumn(lineStart, current_1, sourceFile, options); + } + if (precedingToken.kind === 24 /* CommaToken */ && precedingToken.parent.kind !== 181 /* BinaryExpression */) { + // previous token is comma that separates items in list - find the previous item and try to derive indentation from it + var actualIndentation = getActualIndentationForListItemBeforeComma(precedingToken, sourceFile, options); + if (actualIndentation !== -1 /* Unknown */) { + return actualIndentation; + } + } + // try to find node that can contribute to indentation and includes 'position' starting from 'precedingToken' + // if such node is found - compute initial indentation for 'position' inside this node + var previous; + var current = precedingToken; + var currentStart; + var indentationDelta; + while (current) { + if (ts.positionBelongsToNode(current, position, sourceFile) && shouldIndentChildNode(current.kind, previous ? previous.kind : 0 /* Unknown */)) { + currentStart = getStartLineAndCharacterForNode(current, sourceFile); + if (nextTokenIsCurlyBraceOnSameLineAsCursor(precedingToken, current, lineAtPosition, sourceFile)) { + indentationDelta = 0; + } + else { + indentationDelta = lineAtPosition !== currentStart.line ? options.IndentSize : 0; + } + break; + } + // check if current node is a list item - if yes, take indentation from it + var actualIndentation = getActualIndentationForListItem(current, sourceFile, options); + if (actualIndentation !== -1 /* Unknown */) { + return actualIndentation; + } + actualIndentation = getLineIndentationWhenExpressionIsInMultiLine(current, sourceFile, options); + if (actualIndentation !== -1 /* Unknown */) { + return actualIndentation + options.IndentSize; + } + previous = current; + current = current.parent; + } + if (!current) { + // no parent was found - return 0 to be indented on the level of SourceFile + return 0; + } + return getIndentationForNodeWorker(current, currentStart, /*ignoreActualIndentationRange*/ undefined, indentationDelta, sourceFile, options); + } + SmartIndenter.getIndentation = getIndentation; + 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 getIndentationForNodeWorker(current, currentStart, ignoreActualIndentationRange, indentationDelta, sourceFile, options) { + var parent = current.parent; + var parentStart; + // walk upwards and collect indentations for pairs of parent-child nodes + // indentation is not added if parent and child nodes start on the same line or if parent is IfStatement and child starts on the same line with 'else clause' + while (parent) { + var useActualIndentation = true; + if (ignoreActualIndentationRange) { + var start = current.getStart(sourceFile); + useActualIndentation = start < ignoreActualIndentationRange.pos || start > ignoreActualIndentationRange.end; + } + if (useActualIndentation) { + // check if current node is a list item - if yes, take indentation from it + var actualIndentation = getActualIndentationForListItem(current, sourceFile, options); + if (actualIndentation !== -1 /* Unknown */) { + return actualIndentation + indentationDelta; + } + } + parentStart = getParentStart(parent, current, sourceFile); + var parentAndChildShareLine = parentStart.line === currentStart.line || + childStartsOnTheSameLineWithElseInIfStatement(parent, current, currentStart.line, sourceFile); + if (useActualIndentation) { + // try to fetch actual indentation for current node from source text + var actualIndentation = getActualIndentationForNode(current, parent, currentStart, parentAndChildShareLine, sourceFile, options); + if (actualIndentation !== -1 /* Unknown */) { + return actualIndentation + indentationDelta; + } + actualIndentation = getLineIndentationWhenExpressionIsInMultiLine(current, sourceFile, options); + if (actualIndentation !== -1 /* Unknown */) { + return actualIndentation + indentationDelta; + } + } + // 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.kind, current.kind) && !parentAndChildShareLine) { + indentationDelta += options.IndentSize; + } + current = parent; + currentStart = parentStart; + parent = current.parent; + } + return indentationDelta; + } + function getParentStart(parent, child, sourceFile) { + var containingList = getContainingList(child, sourceFile); + if (containingList) { + return sourceFile.getLineAndCharacterOfPosition(containingList.pos); + } + return sourceFile.getLineAndCharacterOfPosition(parent.getStart(sourceFile)); + } + /* + * Function returns Value.Unknown if indentation cannot be determined + */ + function getActualIndentationForListItemBeforeComma(commaToken, sourceFile, options) { + // previous token is comma that separates items in list - find the previous item and try to derive indentation from it + var commaItemInfo = ts.findListItemInfo(commaToken); + if (commaItemInfo && commaItemInfo.listItemIndex > 0) { + return deriveActualIndentationFromList(commaItemInfo.list.getChildren(), commaItemInfo.listItemIndex - 1, sourceFile, options); + } + else { + // handle broken code gracefully + return -1 /* Unknown */; + } + } + /* + * Function returns Value.Unknown if actual indentation for node should not be used (i.e because node is nested expression) + */ + function getActualIndentationForNode(current, parent, currentLineAndChar, parentAndChildShareLine, sourceFile, options) { + // actual indentation is used for statements\declarations if one of cases below is true: + // - parent is SourceFile - by default immediate children of SourceFile are not indented except when user indents them manually + // - parent and child are not on the same line + var useActualIndentation = (ts.isDeclaration(current) || ts.isStatement(current)) && + (parent.kind === 248 /* SourceFile */ || !parentAndChildShareLine); + if (!useActualIndentation) { + return -1 /* Unknown */; + } + return findColumnForFirstNonWhitespaceCharacterInLine(currentLineAndChar, sourceFile, options); + } + function nextTokenIsCurlyBraceOnSameLineAsCursor(precedingToken, current, lineAtPosition, sourceFile) { + var nextToken = ts.findNextToken(precedingToken, current); + if (!nextToken) { + return false; + } + if (nextToken.kind === 15 /* OpenBraceToken */) { + // open braces are always indented at the parent level + return true; + } + else if (nextToken.kind === 16 /* 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 { + // $ + // } + /// and this one - not + // class A { + // $} + var nextTokenStartLine = getStartLineAndCharacterForNode(nextToken, sourceFile).line; + return lineAtPosition === nextTokenStartLine; + } + return false; + } + function getStartLineAndCharacterForNode(n, sourceFile) { + return sourceFile.getLineAndCharacterOfPosition(n.getStart(sourceFile)); + } + function childStartsOnTheSameLineWithElseInIfStatement(parent, child, childStartLine, sourceFile) { + if (parent.kind === 196 /* IfStatement */ && parent.elseStatement === child) { + var elseKeyword = ts.findChildOfKind(parent, 80 /* ElseKeyword */, sourceFile); + ts.Debug.assert(elseKeyword !== undefined); + var elseKeywordStartLine = getStartLineAndCharacterForNode(elseKeyword, sourceFile).line; + return elseKeywordStartLine === childStartLine; + } + return false; + } + SmartIndenter.childStartsOnTheSameLineWithElseInIfStatement = childStartsOnTheSameLineWithElseInIfStatement; + function getContainingList(node, sourceFile) { + if (node.parent) { + switch (node.parent.kind) { + case 151 /* TypeReference */: + if (node.parent.typeArguments && + ts.rangeContainsStartEnd(node.parent.typeArguments, node.getStart(sourceFile), node.getEnd())) { + return node.parent.typeArguments; + } + break; + case 165 /* ObjectLiteralExpression */: + return node.parent.properties; + case 164 /* ArrayLiteralExpression */: + return node.parent.elements; + case 213 /* FunctionDeclaration */: + case 173 /* FunctionExpression */: + case 174 /* ArrowFunction */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: + case 147 /* CallSignature */: + case 148 /* ConstructSignature */: { + var start = node.getStart(sourceFile); + if (node.parent.typeParameters && + ts.rangeContainsStartEnd(node.parent.typeParameters, start, node.getEnd())) { + return node.parent.typeParameters; + } + if (ts.rangeContainsStartEnd(node.parent.parameters, start, node.getEnd())) { + return node.parent.parameters; + } + break; + } + case 169 /* NewExpression */: + case 168 /* CallExpression */: { + var start = node.getStart(sourceFile); + if (node.parent.typeArguments && + ts.rangeContainsStartEnd(node.parent.typeArguments, start, node.getEnd())) { + return node.parent.typeArguments; + } + if (node.parent.arguments && + ts.rangeContainsStartEnd(node.parent.arguments, start, node.getEnd())) { + return node.parent.arguments; + } + break; + } + } + } + return undefined; + } + function getActualIndentationForListItem(node, sourceFile, options) { + var containingList = getContainingList(node, sourceFile); + return containingList ? getActualIndentationFromList(containingList) : -1 /* Unknown */; + function getActualIndentationFromList(list) { + var index = ts.indexOf(list, node); + return index !== -1 ? deriveActualIndentationFromList(list, index, sourceFile, options) : -1 /* Unknown */; + } + } + 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 */) { + return -1 /* Unknown */; + } + if (node.parent && (node.parent.kind === 168 /* CallExpression */ || + node.parent.kind === 169 /* NewExpression */) && + node.parent.expression !== node) { + var fullCallOrNewExpression = node.parent.expression; + var startingExpression = getStartingExpression(fullCallOrNewExpression); + if (fullCallOrNewExpression === startingExpression) { + return -1 /* Unknown */; + } + var fullCallOrNewExpressionEnd = sourceFile.getLineAndCharacterOfPosition(fullCallOrNewExpression.end); + var startingExpressionEnd = sourceFile.getLineAndCharacterOfPosition(startingExpression.end); + if (fullCallOrNewExpressionEnd.line === startingExpressionEnd.line) { + return -1 /* Unknown */; + } + return findColumnForFirstNonWhitespaceCharacterInLine(fullCallOrNewExpressionEnd, sourceFile, options); + } + return -1 /* Unknown */; + function getStartingExpression(node) { + while (true) { + switch (node.kind) { + case 168 /* CallExpression */: + case 169 /* NewExpression */: + case 166 /* PropertyAccessExpression */: + case 167 /* ElementAccessExpression */: + node = node.expression; + break; + default: + return node; + } + } + return node; + } + } + function deriveActualIndentationFromList(list, index, sourceFile, options) { + ts.Debug.assert(index >= 0 && index < list.length); + var node = list[index]; + // walk toward the start of the list starting from current node and check if the line is the same for all items. + // 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 */) { + continue; + } + // skip list items that ends on the same line with the current list element + var prevEndLine = sourceFile.getLineAndCharacterOfPosition(list[i].end).line; + if (prevEndLine !== lineAndCharacter.line) { + return findColumnForFirstNonWhitespaceCharacterInLine(lineAndCharacter, sourceFile, options); + } + lineAndCharacter = getStartLineAndCharacterForNode(list[i], sourceFile); + } + return -1 /* Unknown */; + } + function findColumnForFirstNonWhitespaceCharacterInLine(lineAndCharacter, sourceFile, options) { + var lineStart = sourceFile.getPositionOfLineAndCharacter(lineAndCharacter.line, 0); + return findFirstNonWhitespaceColumn(lineStart, lineStart + lineAndCharacter.character, sourceFile, options); + } + /* + Character is the actual index of the character since the beginning of the line. + Column - position of the character after expanding tabs to spaces + "0\t2$" + value of 'character' for '$' is 3 + value of 'column' for '$' is 6 (assuming that tab size is 4) + */ + function findFirstNonWhitespaceCharacterAndColumn(startPos, endPos, sourceFile, options) { + var character = 0; + var column = 0; + for (var pos = startPos; pos < endPos; ++pos) { + var ch = sourceFile.text.charCodeAt(pos); + if (!ts.isWhiteSpace(ch)) { + break; + } + if (ch === 9 /* tab */) { + column += options.TabSize + (column % options.TabSize); + } + else { + column++; + } + character++; + } + return { column: column, character: character }; + } + SmartIndenter.findFirstNonWhitespaceCharacterAndColumn = findFirstNonWhitespaceCharacterAndColumn; + function findFirstNonWhitespaceColumn(startPos, endPos, sourceFile, options) { + return findFirstNonWhitespaceCharacterAndColumn(startPos, endPos, sourceFile, options).column; + } + SmartIndenter.findFirstNonWhitespaceColumn = findFirstNonWhitespaceColumn; + function nodeContentIsAlwaysIndented(kind) { + switch (kind) { + case 195 /* ExpressionStatement */: + case 214 /* ClassDeclaration */: + case 186 /* ClassExpression */: + case 215 /* InterfaceDeclaration */: + case 217 /* EnumDeclaration */: + case 216 /* TypeAliasDeclaration */: + case 164 /* ArrayLiteralExpression */: + case 192 /* Block */: + case 219 /* ModuleBlock */: + case 165 /* ObjectLiteralExpression */: + case 155 /* TypeLiteral */: + case 157 /* TupleType */: + case 220 /* CaseBlock */: + case 242 /* DefaultClause */: + case 241 /* CaseClause */: + case 172 /* ParenthesizedExpression */: + case 166 /* PropertyAccessExpression */: + case 168 /* CallExpression */: + case 169 /* NewExpression */: + case 193 /* VariableStatement */: + case 211 /* VariableDeclaration */: + case 227 /* ExportAssignment */: + case 204 /* ReturnStatement */: + case 182 /* ConditionalExpression */: + case 162 /* ArrayBindingPattern */: + case 161 /* ObjectBindingPattern */: + case 233 /* JsxElement */: + case 234 /* JsxSelfClosingElement */: + case 142 /* MethodSignature */: + case 147 /* CallSignature */: + case 148 /* ConstructSignature */: + case 138 /* Parameter */: + case 152 /* FunctionType */: + case 153 /* ConstructorType */: + case 160 /* ParenthesizedType */: + case 170 /* TaggedTemplateExpression */: + case 178 /* AwaitExpression */: + return true; + } + return false; + } + function shouldIndentChildNode(parent, child) { + if (nodeContentIsAlwaysIndented(parent)) { + return true; + } + switch (parent) { + case 197 /* DoStatement */: + case 198 /* WhileStatement */: + case 200 /* ForInStatement */: + case 201 /* ForOfStatement */: + case 199 /* ForStatement */: + case 196 /* IfStatement */: + case 213 /* FunctionDeclaration */: + case 173 /* FunctionExpression */: + case 143 /* MethodDeclaration */: + case 174 /* ArrowFunction */: + case 144 /* Constructor */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: + return child !== 192 /* Block */; + default: + return false; + } + } + SmartIndenter.shouldIndentChildNode = shouldIndentChildNode; + })(SmartIndenter = formatting.SmartIndenter || (formatting.SmartIndenter = {})); + })(formatting = ts.formatting || (ts.formatting = {})); +})(ts || (ts = {})); +/// +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 ts; +(function (ts) { + /** The version of the language service API */ + ts.servicesVersion = "0.4"; + var ScriptSnapshot; + (function (ScriptSnapshot) { + var StringScriptSnapshot = (function () { + function StringScriptSnapshot(text) { + this.text = text; + } + StringScriptSnapshot.prototype.getText = function (start, end) { + return this.text.substring(start, end); + }; + StringScriptSnapshot.prototype.getLength = function () { + return this.text.length; + }; + StringScriptSnapshot.prototype.getChangeRange = function (oldSnapshot) { + // Text-based snapshots do not support incremental parsing. Return undefined + // to signal that to the caller. + return undefined; + }; + return StringScriptSnapshot; + })(); + function fromString(text) { + return new StringScriptSnapshot(text); + } + ScriptSnapshot.fromString = fromString; + })(ScriptSnapshot = ts.ScriptSnapshot || (ts.ScriptSnapshot = {})); + var scanner = ts.createScanner(2 /* Latest */, /*skipTrivia*/ true); + var emptyArray = []; + var jsDocTagNames = [ + "augments", + "author", + "argument", + "borrows", + "class", + "constant", + "constructor", + "constructs", + "default", + "deprecated", + "description", + "event", + "example", + "extends", + "field", + "fileOverview", + "function", + "ignore", + "inner", + "lends", + "link", + "memberOf", + "name", + "namespace", + "param", + "private", + "property", + "public", + "requires", + "returns", + "see", + "since", + "static", + "throws", + "type", + "version" + ]; + var jsDocCompletionEntries; + function createNode(kind, pos, end, flags, parent) { + var node = new (ts.getNodeConstructor(kind))(pos, end); + node.flags = flags; + node.parent = parent; + return node; + } + var NodeObject = (function () { + function NodeObject() { + } + NodeObject.prototype.getSourceFile = function () { + return ts.getSourceFileOfNode(this); + }; + NodeObject.prototype.getStart = function (sourceFile) { + return ts.getTokenPosOfNode(this, sourceFile); + }; + NodeObject.prototype.getFullStart = function () { + return this.pos; + }; + NodeObject.prototype.getEnd = function () { + return this.end; + }; + NodeObject.prototype.getWidth = function (sourceFile) { + return this.getEnd() - this.getStart(sourceFile); + }; + NodeObject.prototype.getFullWidth = function () { + return this.end - this.pos; + }; + NodeObject.prototype.getLeadingTriviaWidth = function (sourceFile) { + return this.getStart(sourceFile) - this.pos; + }; + NodeObject.prototype.getFullText = function (sourceFile) { + return (sourceFile || this.getSourceFile()).text.substring(this.pos, this.end); + }; + NodeObject.prototype.getText = function (sourceFile) { + return (sourceFile || this.getSourceFile()).text.substring(this.getStart(), this.getEnd()); + }; + NodeObject.prototype.addSyntheticNodes = function (nodes, pos, end) { + scanner.setTextPos(pos); + while (pos < end) { + var token = scanner.scan(); + var textPos = scanner.getTextPos(); + nodes.push(createNode(token, pos, textPos, 4096 /* Synthetic */, this)); + pos = textPos; + } + return pos; + }; + NodeObject.prototype.createSyntaxList = function (nodes) { + var list = createNode(271 /* SyntaxList */, nodes.pos, nodes.end, 4096 /* Synthetic */, this); + list._children = []; + var pos = nodes.pos; + for (var _i = 0; _i < nodes.length; _i++) { + var node = nodes[_i]; + if (pos < node.pos) { + pos = this.addSyntheticNodes(list._children, pos, node.pos); + } + list._children.push(node); + pos = node.end; + } + if (pos < nodes.end) { + this.addSyntheticNodes(list._children, pos, nodes.end); + } + return list; + }; + NodeObject.prototype.createChildren = function (sourceFile) { + var _this = this; + var children; + if (this.kind >= 135 /* FirstNode */) { + scanner.setText((sourceFile || this.getSourceFile()).text); + children = []; + var pos = this.pos; + var processNode = function (node) { + if (pos < node.pos) { + pos = _this.addSyntheticNodes(children, pos, node.pos); + } + children.push(node); + pos = node.end; + }; + var processNodes = function (nodes) { + if (pos < nodes.pos) { + pos = _this.addSyntheticNodes(children, pos, nodes.pos); + } + children.push(_this.createSyntaxList(nodes)); + pos = nodes.end; + }; + ts.forEachChild(this, processNode, processNodes); + if (pos < this.end) { + this.addSyntheticNodes(children, pos, this.end); + } + scanner.setText(undefined); + } + this._children = children || emptyArray; + }; + NodeObject.prototype.getChildCount = function (sourceFile) { + if (!this._children) + this.createChildren(sourceFile); + return this._children.length; + }; + NodeObject.prototype.getChildAt = function (index, sourceFile) { + if (!this._children) + this.createChildren(sourceFile); + return this._children[index]; + }; + NodeObject.prototype.getChildren = function (sourceFile) { + if (!this._children) + this.createChildren(sourceFile); + return this._children; + }; + NodeObject.prototype.getFirstToken = function (sourceFile) { + var children = this.getChildren(sourceFile); + if (!children.length) { + return undefined; + } + var child = children[0]; + return child.kind < 135 /* FirstNode */ ? child : child.getFirstToken(sourceFile); + }; + NodeObject.prototype.getLastToken = function (sourceFile) { + var children = this.getChildren(sourceFile); + var child = ts.lastOrUndefined(children); + if (!child) { + return undefined; + } + return child.kind < 135 /* FirstNode */ ? child : child.getLastToken(sourceFile); + }; + return NodeObject; + })(); + var SymbolObject = (function () { + function SymbolObject(flags, name) { + this.flags = flags; + this.name = name; + } + SymbolObject.prototype.getFlags = function () { + return this.flags; + }; + SymbolObject.prototype.getName = function () { + return this.name; + }; + SymbolObject.prototype.getDeclarations = function () { + return this.declarations; + }; + SymbolObject.prototype.getDocumentationComment = function () { + if (this.documentationComment === undefined) { + this.documentationComment = getJsDocCommentsFromDeclarations(this.declarations, this.name, !(this.flags & 4 /* Property */)); + } + return this.documentationComment; + }; + return SymbolObject; + })(); + function getJsDocCommentsFromDeclarations(declarations, name, canUseParsedParamTagComments) { + var documentationComment = []; + var docComments = getJsDocCommentsSeparatedByNewLines(); + ts.forEach(docComments, function (docComment) { + if (documentationComment.length) { + documentationComment.push(ts.lineBreakPart()); + } + documentationComment.push(docComment); + }); + return documentationComment; + function getJsDocCommentsSeparatedByNewLines() { + var paramTag = "@param"; + var jsDocCommentParts = []; + ts.forEach(declarations, function (declaration, indexOfDeclaration) { + // Make sure we are collecting doc comment from declaration once, + // In case of union property there might be same declaration multiple times + // which only varies in type parameter + // Eg. let a: Array | Array; a.length + // The property length will have two declarations of property length coming + // from Array - Array and Array + if (ts.indexOf(declarations, declaration) === indexOfDeclaration) { + var sourceFileOfDeclaration = ts.getSourceFileOfNode(declaration); + // If it is parameter - try and get the jsDoc comment with @param tag from function declaration's jsDoc comments + if (canUseParsedParamTagComments && declaration.kind === 138 /* Parameter */) { + ts.forEach(getJsDocCommentTextRange(declaration.parent, sourceFileOfDeclaration), function (jsDocCommentTextRange) { + var cleanedParamJsDocComment = getCleanedParamJsDocComment(jsDocCommentTextRange.pos, jsDocCommentTextRange.end, sourceFileOfDeclaration); + if (cleanedParamJsDocComment) { + ts.addRange(jsDocCommentParts, cleanedParamJsDocComment); + } + }); + } + // If this is left side of dotted module declaration, there is no doc comments associated with this node + if (declaration.kind === 218 /* ModuleDeclaration */ && declaration.body.kind === 218 /* ModuleDeclaration */) { + return; + } + // If this is dotted module name, get the doc comments from the parent + while (declaration.kind === 218 /* ModuleDeclaration */ && declaration.parent.kind === 218 /* ModuleDeclaration */) { + declaration = declaration.parent; + } + // Get the cleaned js doc comment text from the declaration + ts.forEach(getJsDocCommentTextRange(declaration.kind === 211 /* VariableDeclaration */ ? declaration.parent.parent : declaration, sourceFileOfDeclaration), function (jsDocCommentTextRange) { + var cleanedJsDocComment = getCleanedJsDocComment(jsDocCommentTextRange.pos, jsDocCommentTextRange.end, sourceFileOfDeclaration); + if (cleanedJsDocComment) { + ts.addRange(jsDocCommentParts, cleanedJsDocComment); + } + }); + } + }); + return jsDocCommentParts; + function getJsDocCommentTextRange(node, sourceFile) { + return ts.map(ts.getJsDocComments(node, sourceFile), function (jsDocComment) { + return { + pos: jsDocComment.pos + "/*".length, + end: jsDocComment.end - "*/".length // Trim off comment end indicator + }; + }); + } + function consumeWhiteSpacesOnTheLine(pos, end, sourceFile, maxSpacesToRemove) { + if (maxSpacesToRemove !== undefined) { + end = Math.min(end, pos + maxSpacesToRemove); + } + for (; pos < end; pos++) { + var ch = sourceFile.text.charCodeAt(pos); + if (!ts.isWhiteSpace(ch) || ts.isLineBreak(ch)) { + // Either found lineBreak or non whiteSpace + return pos; + } + } + return end; + } + function consumeLineBreaks(pos, end, sourceFile) { + while (pos < end && ts.isLineBreak(sourceFile.text.charCodeAt(pos))) { + pos++; + } + return pos; + } + function isName(pos, end, sourceFile, name) { + return pos + name.length < end && + sourceFile.text.substr(pos, name.length) === name && + (ts.isWhiteSpace(sourceFile.text.charCodeAt(pos + name.length)) || + ts.isLineBreak(sourceFile.text.charCodeAt(pos + name.length))); + } + function isParamTag(pos, end, sourceFile) { + // If it is @param tag + return isName(pos, end, sourceFile, paramTag); + } + function pushDocCommentLineText(docComments, text, blankLineCount) { + // Add the empty lines in between texts + while (blankLineCount--) { + docComments.push(ts.textPart("")); + } + docComments.push(ts.textPart(text)); + } + function getCleanedJsDocComment(pos, end, sourceFile) { + var spacesToRemoveAfterAsterisk; + var docComments = []; + var blankLineCount = 0; + var isInParamTag = false; + while (pos < end) { + var docCommentTextOfLine = ""; + // First consume leading white space + pos = consumeWhiteSpacesOnTheLine(pos, end, sourceFile); + // If the comment starts with '*' consume the spaces on this line + if (pos < end && sourceFile.text.charCodeAt(pos) === 42 /* asterisk */) { + var lineStartPos = pos + 1; + pos = consumeWhiteSpacesOnTheLine(pos + 1, end, sourceFile, spacesToRemoveAfterAsterisk); + // Set the spaces to remove after asterisk as margin if not already set + if (spacesToRemoveAfterAsterisk === undefined && pos < end && !ts.isLineBreak(sourceFile.text.charCodeAt(pos))) { + spacesToRemoveAfterAsterisk = pos - lineStartPos; + } + } + else if (spacesToRemoveAfterAsterisk === undefined) { + spacesToRemoveAfterAsterisk = 0; + } + // Analyse text on this line + while (pos < end && !ts.isLineBreak(sourceFile.text.charCodeAt(pos))) { + var ch = sourceFile.text.charAt(pos); + if (ch === "@") { + // If it is @param tag + if (isParamTag(pos, end, sourceFile)) { + isInParamTag = true; + pos += paramTag.length; + continue; + } + else { + isInParamTag = false; + } + } + // Add the ch to doc text if we arent in param tag + if (!isInParamTag) { + docCommentTextOfLine += ch; + } + // Scan next character + pos++; + } + // Continue with next line + pos = consumeLineBreaks(pos, end, sourceFile); + if (docCommentTextOfLine) { + pushDocCommentLineText(docComments, docCommentTextOfLine, blankLineCount); + blankLineCount = 0; + } + else if (!isInParamTag && docComments.length) { + // This is blank line when there is text already parsed + blankLineCount++; + } + } + return docComments; + } + function getCleanedParamJsDocComment(pos, end, sourceFile) { + var paramHelpStringMargin; + var paramDocComments = []; + while (pos < end) { + if (isParamTag(pos, end, sourceFile)) { + var blankLineCount = 0; + var recordedParamTag = false; + // Consume leading spaces + pos = consumeWhiteSpaces(pos + paramTag.length); + if (pos >= end) { + break; + } + // Ignore type expression + if (sourceFile.text.charCodeAt(pos) === 123 /* openBrace */) { + pos++; + for (var curlies = 1; pos < end; pos++) { + var charCode = sourceFile.text.charCodeAt(pos); + // { character means we need to find another } to match the found one + if (charCode === 123 /* openBrace */) { + curlies++; + continue; + } + // } char + if (charCode === 125 /* closeBrace */) { + curlies--; + if (curlies === 0) { + // We do not have any more } to match the type expression is ignored completely + pos++; + break; + } + else { + // there are more { to be matched with } + continue; + } + } + // Found start of another tag + if (charCode === 64 /* at */) { + break; + } + } + // Consume white spaces + pos = consumeWhiteSpaces(pos); + if (pos >= end) { + break; + } + } + // Parameter name + if (isName(pos, end, sourceFile, name)) { + // Found the parameter we are looking for consume white spaces + pos = consumeWhiteSpaces(pos + name.length); + if (pos >= end) { + break; + } + var paramHelpString = ""; + var firstLineParamHelpStringPos = pos; + while (pos < end) { + var ch = sourceFile.text.charCodeAt(pos); + // at line break, set this comment line text and go to next line + if (ts.isLineBreak(ch)) { + if (paramHelpString) { + pushDocCommentLineText(paramDocComments, paramHelpString, blankLineCount); + paramHelpString = ""; + blankLineCount = 0; + recordedParamTag = true; + } + else if (recordedParamTag) { + blankLineCount++; + } + // Get the pos after cleaning start of the line + setPosForParamHelpStringOnNextLine(firstLineParamHelpStringPos); + continue; + } + // Done scanning param help string - next tag found + if (ch === 64 /* at */) { + break; + } + paramHelpString += sourceFile.text.charAt(pos); + // Go to next character + pos++; + } + // If there is param help text, add it top the doc comments + if (paramHelpString) { + pushDocCommentLineText(paramDocComments, paramHelpString, blankLineCount); + } + paramHelpStringMargin = undefined; + } + // If this is the start of another tag, continue with the loop in seach of param tag with symbol name + if (sourceFile.text.charCodeAt(pos) === 64 /* at */) { + continue; + } + } + // Next character + pos++; + } + return paramDocComments; + function consumeWhiteSpaces(pos) { + while (pos < end && ts.isWhiteSpace(sourceFile.text.charCodeAt(pos))) { + pos++; + } + return pos; + } + function setPosForParamHelpStringOnNextLine(firstLineParamHelpStringPos) { + // Get the pos after consuming line breaks + pos = consumeLineBreaks(pos, end, sourceFile); + if (pos >= end) { + return; + } + if (paramHelpStringMargin === undefined) { + paramHelpStringMargin = sourceFile.getLineAndCharacterOfPosition(firstLineParamHelpStringPos).character; + } + // Now consume white spaces max + var startOfLinePos = pos; + pos = consumeWhiteSpacesOnTheLine(pos, end, sourceFile, paramHelpStringMargin); + if (pos >= end) { + return; + } + var consumedSpaces = pos - startOfLinePos; + if (consumedSpaces < paramHelpStringMargin) { + var ch = sourceFile.text.charCodeAt(pos); + if (ch === 42 /* asterisk */) { + // Consume more spaces after asterisk + pos = consumeWhiteSpacesOnTheLine(pos + 1, end, sourceFile, paramHelpStringMargin - consumedSpaces - 1); + } + } + } + } + } + } + var TypeObject = (function () { + function TypeObject(checker, flags) { + this.checker = checker; + this.flags = flags; + } + TypeObject.prototype.getFlags = function () { + return this.flags; + }; + TypeObject.prototype.getSymbol = function () { + return this.symbol; + }; + TypeObject.prototype.getProperties = function () { + return this.checker.getPropertiesOfType(this); + }; + TypeObject.prototype.getProperty = function (propertyName) { + return this.checker.getPropertyOfType(this, propertyName); + }; + TypeObject.prototype.getApparentProperties = function () { + return this.checker.getAugmentedPropertiesOfType(this); + }; + TypeObject.prototype.getCallSignatures = function () { + return this.checker.getSignaturesOfType(this, 0 /* Call */); + }; + TypeObject.prototype.getConstructSignatures = function () { + return this.checker.getSignaturesOfType(this, 1 /* Construct */); + }; + TypeObject.prototype.getStringIndexType = function () { + return this.checker.getIndexTypeOfType(this, 0 /* String */); + }; + TypeObject.prototype.getNumberIndexType = function () { + return this.checker.getIndexTypeOfType(this, 1 /* Number */); + }; + TypeObject.prototype.getBaseTypes = function () { + return this.flags & (1024 /* Class */ | 2048 /* Interface */) + ? this.checker.getBaseTypes(this) + : undefined; + }; + return TypeObject; + })(); + var SignatureObject = (function () { + function SignatureObject(checker) { + this.checker = checker; + } + SignatureObject.prototype.getDeclaration = function () { + return this.declaration; + }; + SignatureObject.prototype.getTypeParameters = function () { + return this.typeParameters; + }; + SignatureObject.prototype.getParameters = function () { + return this.parameters; + }; + SignatureObject.prototype.getReturnType = function () { + return this.checker.getReturnTypeOfSignature(this); + }; + SignatureObject.prototype.getDocumentationComment = function () { + if (this.documentationComment === undefined) { + this.documentationComment = this.declaration ? getJsDocCommentsFromDeclarations([this.declaration], + /*name*/ undefined, + /*canUseParsedParamTagComments*/ false) : []; + } + return this.documentationComment; + }; + return SignatureObject; + })(); + var SourceFileObject = (function (_super) { + __extends(SourceFileObject, _super); + function SourceFileObject() { + _super.apply(this, arguments); + } + SourceFileObject.prototype.update = function (newText, textChangeRange) { + return ts.updateSourceFile(this, newText, textChangeRange); + }; + SourceFileObject.prototype.getLineAndCharacterOfPosition = function (position) { + return ts.getLineAndCharacterOfPosition(this, position); + }; + SourceFileObject.prototype.getLineStarts = function () { + return ts.getLineStarts(this); + }; + SourceFileObject.prototype.getPositionOfLineAndCharacter = function (line, character) { + return ts.getPositionOfLineAndCharacter(this, line, character); + }; + SourceFileObject.prototype.getNamedDeclarations = function () { + if (!this.namedDeclarations) { + this.namedDeclarations = this.computeNamedDeclarations(); + } + return this.namedDeclarations; + }; + SourceFileObject.prototype.computeNamedDeclarations = function () { + var result = {}; + ts.forEachChild(this, visit); + return result; + function addDeclaration(declaration) { + var name = getDeclarationName(declaration); + if (name) { + var declarations = getDeclarations(name); + declarations.push(declaration); + } + } + function getDeclarations(name) { + return ts.getProperty(result, name) || (result[name] = []); + } + function getDeclarationName(declaration) { + if (declaration.name) { + var result_2 = getTextOfIdentifierOrLiteral(declaration.name); + if (result_2 !== undefined) { + return result_2; + } + if (declaration.name.kind === 136 /* ComputedPropertyName */) { + var expr = declaration.name.expression; + if (expr.kind === 166 /* PropertyAccessExpression */) { + return expr.name.text; + } + return getTextOfIdentifierOrLiteral(expr); + } + } + return undefined; + } + function getTextOfIdentifierOrLiteral(node) { + if (node) { + if (node.kind === 69 /* Identifier */ || + node.kind === 9 /* StringLiteral */ || + node.kind === 8 /* NumericLiteral */) { + return node.text; + } + } + return undefined; + } + function visit(node) { + switch (node.kind) { + case 213 /* FunctionDeclaration */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: + var functionDeclaration = node; + var declarationName = getDeclarationName(functionDeclaration); + if (declarationName) { + var declarations = getDeclarations(declarationName); + var lastDeclaration = ts.lastOrUndefined(declarations); + // Check whether this declaration belongs to an "overload group". + if (lastDeclaration && functionDeclaration.parent === lastDeclaration.parent && functionDeclaration.symbol === lastDeclaration.symbol) { + // Overwrite the last declaration if it was an overload + // and this one is an implementation. + if (functionDeclaration.body && !lastDeclaration.body) { + declarations[declarations.length - 1] = functionDeclaration; + } + } + else { + declarations.push(functionDeclaration); + } + ts.forEachChild(node, visit); + } + break; + case 214 /* ClassDeclaration */: + case 215 /* InterfaceDeclaration */: + case 216 /* TypeAliasDeclaration */: + case 217 /* EnumDeclaration */: + case 218 /* ModuleDeclaration */: + case 221 /* ImportEqualsDeclaration */: + case 230 /* ExportSpecifier */: + case 226 /* ImportSpecifier */: + case 221 /* ImportEqualsDeclaration */: + case 223 /* ImportClause */: + case 224 /* NamespaceImport */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: + case 155 /* TypeLiteral */: + addDeclaration(node); + // fall through + case 144 /* Constructor */: + case 193 /* VariableStatement */: + case 212 /* VariableDeclarationList */: + case 161 /* ObjectBindingPattern */: + case 162 /* ArrayBindingPattern */: + case 219 /* ModuleBlock */: + ts.forEachChild(node, visit); + break; + case 192 /* Block */: + if (ts.isFunctionBlock(node)) { + ts.forEachChild(node, visit); + } + break; + case 138 /* Parameter */: + // Only consider properties defined as constructor parameters + if (!(node.flags & 112 /* AccessibilityModifier */)) { + break; + } + // fall through + case 211 /* VariableDeclaration */: + case 163 /* BindingElement */: + if (ts.isBindingPattern(node.name)) { + ts.forEachChild(node.name, visit); + break; + } + case 247 /* EnumMember */: + case 141 /* PropertyDeclaration */: + case 140 /* PropertySignature */: + addDeclaration(node); + break; + case 228 /* ExportDeclaration */: + // Handle named exports case e.g.: + // export {a, b as B} from "mod"; + if (node.exportClause) { + ts.forEach(node.exportClause.elements, visit); + } + break; + case 222 /* ImportDeclaration */: + var importClause = node.importClause; + if (importClause) { + // Handle default import case e.g.: + // import d from "mod"; + if (importClause.name) { + addDeclaration(importClause); + } + // Handle named bindings in imports e.g.: + // import * as NS from "mod"; + // import {a, b as B} from "mod"; + if (importClause.namedBindings) { + if (importClause.namedBindings.kind === 224 /* NamespaceImport */) { + addDeclaration(importClause.namedBindings); + } + else { + ts.forEach(importClause.namedBindings.elements, visit); + } + } + } + break; + } + } + }; + return SourceFileObject; + })(NodeObject); + var TextChange = (function () { + function TextChange() { + } + return TextChange; + })(); + ts.TextChange = TextChange; + var HighlightSpanKind; + (function (HighlightSpanKind) { + HighlightSpanKind.none = "none"; + HighlightSpanKind.definition = "definition"; + HighlightSpanKind.reference = "reference"; + HighlightSpanKind.writtenReference = "writtenReference"; + })(HighlightSpanKind = ts.HighlightSpanKind || (ts.HighlightSpanKind = {})); + (function (IndentStyle) { + IndentStyle[IndentStyle["None"] = 0] = "None"; + IndentStyle[IndentStyle["Block"] = 1] = "Block"; + IndentStyle[IndentStyle["Smart"] = 2] = "Smart"; + })(ts.IndentStyle || (ts.IndentStyle = {})); + var IndentStyle = ts.IndentStyle; + (function (SymbolDisplayPartKind) { + SymbolDisplayPartKind[SymbolDisplayPartKind["aliasName"] = 0] = "aliasName"; + SymbolDisplayPartKind[SymbolDisplayPartKind["className"] = 1] = "className"; + SymbolDisplayPartKind[SymbolDisplayPartKind["enumName"] = 2] = "enumName"; + SymbolDisplayPartKind[SymbolDisplayPartKind["fieldName"] = 3] = "fieldName"; + SymbolDisplayPartKind[SymbolDisplayPartKind["interfaceName"] = 4] = "interfaceName"; + SymbolDisplayPartKind[SymbolDisplayPartKind["keyword"] = 5] = "keyword"; + SymbolDisplayPartKind[SymbolDisplayPartKind["lineBreak"] = 6] = "lineBreak"; + SymbolDisplayPartKind[SymbolDisplayPartKind["numericLiteral"] = 7] = "numericLiteral"; + SymbolDisplayPartKind[SymbolDisplayPartKind["stringLiteral"] = 8] = "stringLiteral"; + SymbolDisplayPartKind[SymbolDisplayPartKind["localName"] = 9] = "localName"; + SymbolDisplayPartKind[SymbolDisplayPartKind["methodName"] = 10] = "methodName"; + SymbolDisplayPartKind[SymbolDisplayPartKind["moduleName"] = 11] = "moduleName"; + SymbolDisplayPartKind[SymbolDisplayPartKind["operator"] = 12] = "operator"; + SymbolDisplayPartKind[SymbolDisplayPartKind["parameterName"] = 13] = "parameterName"; + SymbolDisplayPartKind[SymbolDisplayPartKind["propertyName"] = 14] = "propertyName"; + SymbolDisplayPartKind[SymbolDisplayPartKind["punctuation"] = 15] = "punctuation"; + SymbolDisplayPartKind[SymbolDisplayPartKind["space"] = 16] = "space"; + SymbolDisplayPartKind[SymbolDisplayPartKind["text"] = 17] = "text"; + SymbolDisplayPartKind[SymbolDisplayPartKind["typeParameterName"] = 18] = "typeParameterName"; + SymbolDisplayPartKind[SymbolDisplayPartKind["enumMemberName"] = 19] = "enumMemberName"; + SymbolDisplayPartKind[SymbolDisplayPartKind["functionName"] = 20] = "functionName"; + 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"; + TokenClass[TokenClass["Operator"] = 2] = "Operator"; + TokenClass[TokenClass["Comment"] = 3] = "Comment"; + TokenClass[TokenClass["Whitespace"] = 4] = "Whitespace"; + TokenClass[TokenClass["Identifier"] = 5] = "Identifier"; + TokenClass[TokenClass["NumberLiteral"] = 6] = "NumberLiteral"; + TokenClass[TokenClass["StringLiteral"] = 7] = "StringLiteral"; + TokenClass[TokenClass["RegExpLiteral"] = 8] = "RegExpLiteral"; + })(ts.TokenClass || (ts.TokenClass = {})); + var TokenClass = ts.TokenClass; + // TODO: move these to enums + var ScriptElementKind; + (function (ScriptElementKind) { + ScriptElementKind.unknown = ""; + ScriptElementKind.warning = "warning"; + // predefined type (void) or keyword (class) + ScriptElementKind.keyword = "keyword"; + // top level script node + ScriptElementKind.scriptElement = "script"; + // module foo {} + ScriptElementKind.moduleElement = "module"; + // class X {} + ScriptElementKind.classElement = "class"; + // var x = class X {} + ScriptElementKind.localClassElement = "local class"; + // interface Y {} + ScriptElementKind.interfaceElement = "interface"; + // type T = ... + ScriptElementKind.typeElement = "type"; + // enum E + ScriptElementKind.enumElement = "enum"; + // Inside module and script only + // let v = .. + ScriptElementKind.variableElement = "var"; + // Inside function + ScriptElementKind.localVariableElement = "local var"; + // Inside module and script only + // function f() { } + ScriptElementKind.functionElement = "function"; + // Inside function + ScriptElementKind.localFunctionElement = "local function"; + // class X { [public|private]* foo() {} } + ScriptElementKind.memberFunctionElement = "method"; + // class X { [public|private]* [get|set] foo:number; } + ScriptElementKind.memberGetAccessorElement = "getter"; + ScriptElementKind.memberSetAccessorElement = "setter"; + // class X { [public|private]* foo:number; } + // interface Y { foo:number; } + ScriptElementKind.memberVariableElement = "property"; + // class X { constructor() { } } + ScriptElementKind.constructorImplementationElement = "constructor"; + // interface Y { ():number; } + ScriptElementKind.callSignatureElement = "call"; + // interface Y { []:number; } + ScriptElementKind.indexSignatureElement = "index"; + // interface Y { new():Y; } + ScriptElementKind.constructSignatureElement = "construct"; + // function foo(*Y*: string) + ScriptElementKind.parameterElement = "parameter"; + ScriptElementKind.typeParameterElement = "type parameter"; + ScriptElementKind.primitiveType = "primitive type"; + ScriptElementKind.label = "label"; + ScriptElementKind.alias = "alias"; + ScriptElementKind.constElement = "const"; + ScriptElementKind.letElement = "let"; + })(ScriptElementKind = ts.ScriptElementKind || (ts.ScriptElementKind = {})); + var ScriptElementKindModifier; + (function (ScriptElementKindModifier) { + ScriptElementKindModifier.none = ""; + ScriptElementKindModifier.publicMemberModifier = "public"; + ScriptElementKindModifier.privateMemberModifier = "private"; + ScriptElementKindModifier.protectedMemberModifier = "protected"; + ScriptElementKindModifier.exportedModifier = "export"; + ScriptElementKindModifier.ambientModifier = "declare"; + ScriptElementKindModifier.staticModifier = "static"; + ScriptElementKindModifier.abstractModifier = "abstract"; + })(ScriptElementKindModifier = ts.ScriptElementKindModifier || (ts.ScriptElementKindModifier = {})); + var ClassificationTypeNames = (function () { + function ClassificationTypeNames() { + } + ClassificationTypeNames.comment = "comment"; + ClassificationTypeNames.identifier = "identifier"; + ClassificationTypeNames.keyword = "keyword"; + ClassificationTypeNames.numericLiteral = "number"; + ClassificationTypeNames.operator = "operator"; + ClassificationTypeNames.stringLiteral = "string"; + ClassificationTypeNames.whiteSpace = "whitespace"; + ClassificationTypeNames.text = "text"; + ClassificationTypeNames.punctuation = "punctuation"; + ClassificationTypeNames.className = "class name"; + ClassificationTypeNames.enumName = "enum name"; + ClassificationTypeNames.interfaceName = "interface name"; + ClassificationTypeNames.moduleName = "module name"; + ClassificationTypeNames.typeParameterName = "type parameter name"; + ClassificationTypeNames.typeAliasName = "type alias name"; + ClassificationTypeNames.parameterName = "parameter name"; + ClassificationTypeNames.docCommentTagName = "doc comment tag name"; + return ClassificationTypeNames; + })(); + 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"; + })(ts.ClassificationType || (ts.ClassificationType = {})); + var ClassificationType = ts.ClassificationType; + function displayPartsToString(displayParts) { + if (displayParts) { + return ts.map(displayParts, function (displayPart) { return displayPart.text; }).join(""); + } + return ""; + } + ts.displayPartsToString = displayPartsToString; + function isLocalVariableOrFunction(symbol) { + if (symbol.parent) { + return false; // This is exported symbol + } + return ts.forEach(symbol.declarations, function (declaration) { + // Function expressions are local + if (declaration.kind === 173 /* FunctionExpression */) { + return true; + } + if (declaration.kind !== 211 /* VariableDeclaration */ && declaration.kind !== 213 /* FunctionDeclaration */) { + return false; + } + // If the parent is not sourceFile or module block it is local variable + for (var parent_8 = declaration.parent; !ts.isFunctionBlock(parent_8); parent_8 = parent_8.parent) { + // Reached source file or module block + if (parent_8.kind === 248 /* SourceFile */ || parent_8.kind === 219 /* ModuleBlock */) { + return false; + } + } + // parent is in function block + return true; + }); + } + function getDefaultCompilerOptions() { + // Always default to "ScriptTarget.ES5" for the language service + return { + target: 1 /* ES5 */, + module: 0 /* None */, + jsx: 1 /* Preserve */ + }; + } + ts.getDefaultCompilerOptions = getDefaultCompilerOptions; + // Cache host information about scrip Should be refreshed + // at each language service public entry point, since we don't know when + // set of scripts handled by the host changes. + var HostCache = (function () { + function HostCache(host, getCanonicalFileName) { + this.host = host; + // script id => script index + this.fileNameToEntry = ts.createFileMap(getCanonicalFileName); + // Initialize the list with the root file names + var rootFileNames = host.getScriptFileNames(); + for (var _i = 0; _i < rootFileNames.length; _i++) { + var fileName = rootFileNames[_i]; + this.createEntry(fileName); + } + // store the compilation settings + this._compilationSettings = host.getCompilationSettings() || getDefaultCompilerOptions(); + } + HostCache.prototype.compilationSettings = function () { + return this._compilationSettings; + }; + HostCache.prototype.createEntry = function (fileName) { + var entry; + var scriptSnapshot = this.host.getScriptSnapshot(fileName); + if (scriptSnapshot) { + entry = { + hostFileName: fileName, + version: this.host.getScriptVersion(fileName), + scriptSnapshot: scriptSnapshot + }; + } + this.fileNameToEntry.set(fileName, entry); + return entry; + }; + HostCache.prototype.getEntry = function (fileName) { + return this.fileNameToEntry.get(fileName); + }; + HostCache.prototype.contains = function (fileName) { + return this.fileNameToEntry.contains(fileName); + }; + HostCache.prototype.getOrCreateEntry = function (fileName) { + if (this.contains(fileName)) { + return this.getEntry(fileName); + } + return this.createEntry(fileName); + }; + HostCache.prototype.getRootFileNames = function () { + var fileNames = []; + this.fileNameToEntry.forEachValue(function (value) { + if (value) { + fileNames.push(value.hostFileName); + } + }); + return fileNames; + }; + HostCache.prototype.getVersion = function (fileName) { + var file = this.getEntry(fileName); + return file && file.version; + }; + HostCache.prototype.getScriptSnapshot = function (fileName) { + var file = this.getEntry(fileName); + return file && file.scriptSnapshot; + }; + return HostCache; + })(); + var SyntaxTreeCache = (function () { + function SyntaxTreeCache(host) { + this.host = host; + } + SyntaxTreeCache.prototype.getCurrentSourceFile = function (fileName) { + var scriptSnapshot = this.host.getScriptSnapshot(fileName); + if (!scriptSnapshot) { + // The host does not know about this file. + throw new Error("Could not find file: '" + fileName + "'."); + } + var version = this.host.getScriptVersion(fileName); + var sourceFile; + if (this.currentFileName !== fileName) { + // This is a new file, just parse it + sourceFile = createLanguageServiceSourceFile(fileName, scriptSnapshot, 2 /* Latest */, version, /*setNodeParents:*/ true); + } + else if (this.currentFileVersion !== version) { + // This is the same file, just a newer version. Incrementally parse the file. + var editRange = scriptSnapshot.getChangeRange(this.currentFileScriptSnapshot); + sourceFile = updateLanguageServiceSourceFile(this.currentSourceFile, scriptSnapshot, version, editRange); + } + if (sourceFile) { + // All done, ensure state is up to date + this.currentFileVersion = version; + this.currentFileName = fileName; + this.currentFileScriptSnapshot = scriptSnapshot; + this.currentSourceFile = sourceFile; + } + return this.currentSourceFile; + }; + return SyntaxTreeCache; + })(); + function setSourceFileFields(sourceFile, scriptSnapshot, version) { + sourceFile.version = version; + sourceFile.scriptSnapshot = scriptSnapshot; + } + /* + * This function will compile source text from 'input' argument using specified compiler options. + * If not options are provided - it will use a set of default compiler options. + * Extra compiler options that will unconditionally be used by this function are: + * - isolatedModules = true + * - allowNonTsExtensions = true + * - noLib = true + * - noResolve = true + */ + function transpileModule(input, transpileOptions) { + var options = transpileOptions.compilerOptions ? ts.clone(transpileOptions.compilerOptions) : getDefaultCompilerOptions(); + options.isolatedModules = true; + // Filename can be non-ts file. + options.allowNonTsExtensions = true; + // We are not returning a sourceFile for lib file when asked by the program, + // so pass --noLib to avoid reporting a file not found error. + options.noLib = true; + // We are not doing a full typecheck, we are not resolving the whole context, + // so pass --noResolve to avoid reporting missing file errors. + options.noResolve = true; + // if jsx is specified then treat file as .tsx + var inputFileName = transpileOptions.fileName || (options.jsx ? "module.tsx" : "module.ts"); + var sourceFile = ts.createSourceFile(inputFileName, input, options.target); + if (transpileOptions.moduleName) { + sourceFile.moduleName = transpileOptions.moduleName; + } + sourceFile.renamedDependencies = transpileOptions.renamedDependencies; + var newLine = ts.getNewLineCharacter(options); + // Output + var outputText; + var sourceMapText; + // Create a compilerHost object to allow the compiler to read and write files + var compilerHost = { + getSourceFile: function (fileName, target) { return fileName === ts.normalizeSlashes(inputFileName) ? sourceFile : undefined; }, + writeFile: function (name, text, writeByteOrderMark) { + if (ts.fileExtensionIs(name, ".map")) { + ts.Debug.assert(sourceMapText === undefined, "Unexpected multiple source map outputs for the file '" + name + "'"); + sourceMapText = text; + } + else { + ts.Debug.assert(outputText === undefined, "Unexpected multiple outputs for the file: " + name); + outputText = text; + } + }, + getDefaultLibFileName: function () { return "lib.d.ts"; }, + useCaseSensitiveFileNames: function () { return false; }, + getCanonicalFileName: function (fileName) { return fileName; }, + getCurrentDirectory: function () { return ""; }, + getNewLine: function () { return newLine; }, + fileExists: function (fileName) { return fileName === inputFileName; }, + readFile: function (fileName) { return ""; } + }; + var program = ts.createProgram([inputFileName], options, compilerHost); + var diagnostics; + if (transpileOptions.reportDiagnostics) { + diagnostics = []; + ts.addRange(/*to*/ diagnostics, /*from*/ program.getSyntacticDiagnostics(sourceFile)); + ts.addRange(/*to*/ diagnostics, /*from*/ program.getOptionsDiagnostics()); + } + // Emit + program.emit(); + ts.Debug.assert(outputText !== undefined, "Output generation failed"); + return { outputText: outputText, diagnostics: diagnostics, sourceMapText: sourceMapText }; + } + ts.transpileModule = transpileModule; + /* + * This is a shortcut function for transpileModule - it accepts transpileOptions as parameters and returns only outputText part of the result. + */ + function transpile(input, compilerOptions, fileName, diagnostics, moduleName) { + var output = transpileModule(input, { compilerOptions: compilerOptions, fileName: fileName, reportDiagnostics: !!diagnostics, moduleName: moduleName }); + // addRange correctly handles cases when wither 'from' or 'to' argument is missing + ts.addRange(diagnostics, output.diagnostics); + return output.outputText; + } + ts.transpile = transpile; + function createLanguageServiceSourceFile(fileName, scriptSnapshot, scriptTarget, version, setNodeParents) { + var text = scriptSnapshot.getText(0, scriptSnapshot.getLength()); + var sourceFile = ts.createSourceFile(fileName, text, scriptTarget, setNodeParents); + setSourceFileFields(sourceFile, scriptSnapshot, version); + // after full parsing we can use table with interned strings as name table + sourceFile.nameTable = sourceFile.identifiers; + return sourceFile; + } + ts.createLanguageServiceSourceFile = createLanguageServiceSourceFile; + ts.disableIncrementalParsing = false; + function updateLanguageServiceSourceFile(sourceFile, scriptSnapshot, version, textChangeRange, aggressiveChecks) { + // If we were given a text change range, and our version or open-ness changed, then + // incrementally parse this file. + if (textChangeRange) { + if (version !== sourceFile.version) { + // Once incremental parsing is ready, then just call into this function. + if (!ts.disableIncrementalParsing) { + var newText; + // grab the fragment from the beginning of the original text to the beginning of the span + var prefix = textChangeRange.span.start !== 0 + ? sourceFile.text.substr(0, textChangeRange.span.start) + : ""; + // grab the fragment from the end of the span till the end of the original text + var suffix = ts.textSpanEnd(textChangeRange.span) !== sourceFile.text.length + ? sourceFile.text.substr(ts.textSpanEnd(textChangeRange.span)) + : ""; + if (textChangeRange.newLength === 0) { + // edit was a deletion - just combine prefix and suffix + newText = prefix && suffix ? prefix + suffix : prefix || suffix; + } + else { + // it was actual edit, fetch the fragment of new text that correspond to new span + var changedText = scriptSnapshot.getText(textChangeRange.span.start, textChangeRange.span.start + textChangeRange.newLength); + // combine prefix, changed text and suffix + newText = prefix && suffix + ? prefix + changedText + suffix + : prefix + ? (prefix + changedText) + : (changedText + suffix); + } + var newSourceFile = ts.updateSourceFile(sourceFile, newText, textChangeRange, aggressiveChecks); + setSourceFileFields(newSourceFile, scriptSnapshot, version); + // after incremental parsing nameTable might not be up-to-date + // drop it so it can be lazily recreated later + newSourceFile.nameTable = undefined; + // dispose all resources held by old script snapshot + if (sourceFile !== newSourceFile && sourceFile.scriptSnapshot) { + if (sourceFile.scriptSnapshot.dispose) { + sourceFile.scriptSnapshot.dispose(); + } + sourceFile.scriptSnapshot = undefined; + } + return newSourceFile; + } + } + } + // Otherwise, just create a new source file. + return createLanguageServiceSourceFile(sourceFile.fileName, scriptSnapshot, sourceFile.languageVersion, version, /*setNodeParents:*/ true); + } + ts.updateLanguageServiceSourceFile = updateLanguageServiceSourceFile; + function createGetCanonicalFileName(useCaseSensitivefileNames) { + return useCaseSensitivefileNames + ? (function (fileName) { return fileName; }) + : (function (fileName) { return fileName.toLowerCase(); }); + } + ts.createGetCanonicalFileName = createGetCanonicalFileName; + function createDocumentRegistry(useCaseSensitiveFileNames) { + // Maps from compiler setting target (ES3, ES5, etc.) to all the cached documents we have + // for those settings. + var buckets = {}; + var getCanonicalFileName = createGetCanonicalFileName(!!useCaseSensitiveFileNames); + function getKeyFromCompilationSettings(settings) { + return "_" + settings.target + "|" + settings.module + "|" + settings.noResolve + "|" + settings.jsx; + } + function getBucketForCompilationSettings(settings, createIfMissing) { + var key = getKeyFromCompilationSettings(settings); + var bucket = ts.lookUp(buckets, key); + if (!bucket && createIfMissing) { + buckets[key] = bucket = ts.createFileMap(getCanonicalFileName); + } + return bucket; + } + function reportStats() { + var bucketInfoArray = Object.keys(buckets).filter(function (name) { return name && name.charAt(0) === '_'; }).map(function (name) { + var entries = ts.lookUp(buckets, name); + var sourceFiles = []; + for (var i in entries) { + var entry = entries.get(i); + sourceFiles.push({ + name: i, + refCount: entry.languageServiceRefCount, + references: entry.owners.slice(0) + }); + } + sourceFiles.sort(function (x, y) { return y.refCount - x.refCount; }); + return { + bucket: name, + sourceFiles: sourceFiles + }; + }); + return JSON.stringify(bucketInfoArray, null, 2); + } + function acquireDocument(fileName, compilationSettings, scriptSnapshot, version) { + return acquireOrUpdateDocument(fileName, compilationSettings, scriptSnapshot, version, /*acquiring:*/ true); + } + function updateDocument(fileName, compilationSettings, scriptSnapshot, version) { + return acquireOrUpdateDocument(fileName, compilationSettings, scriptSnapshot, version, /*acquiring:*/ false); + } + function acquireOrUpdateDocument(fileName, compilationSettings, scriptSnapshot, version, acquiring) { + var bucket = getBucketForCompilationSettings(compilationSettings, /*createIfMissing*/ true); + var entry = bucket.get(fileName); + if (!entry) { + ts.Debug.assert(acquiring, "How could we be trying to update a document that the registry doesn't have?"); + // Have never seen this file with these settings. Create a new source file for it. + var sourceFile = createLanguageServiceSourceFile(fileName, scriptSnapshot, compilationSettings.target, version, /*setNodeParents:*/ false); + entry = { + sourceFile: sourceFile, + languageServiceRefCount: 0, + owners: [] + }; + bucket.set(fileName, entry); + } + else { + // We have an entry for this file. However, it may be for a different version of + // the script snapshot. If so, update it appropriately. Otherwise, we can just + // return it as is. + if (entry.sourceFile.version !== version) { + entry.sourceFile = updateLanguageServiceSourceFile(entry.sourceFile, scriptSnapshot, version, scriptSnapshot.getChangeRange(entry.sourceFile.scriptSnapshot)); + } + } + // If we're acquiring, then this is the first time this LS is asking for this document. + // Increase our ref count so we know there's another LS using the document. If we're + // not acquiring, then that means the LS is 'updating' the file instead, and that means + // it has already acquired the document previously. As such, we do not need to increase + // the ref count. + if (acquiring) { + entry.languageServiceRefCount++; + } + return entry.sourceFile; + } + function releaseDocument(fileName, compilationSettings) { + var bucket = getBucketForCompilationSettings(compilationSettings, false); + ts.Debug.assert(bucket !== undefined); + var entry = bucket.get(fileName); + entry.languageServiceRefCount--; + ts.Debug.assert(entry.languageServiceRefCount >= 0); + if (entry.languageServiceRefCount === 0) { + bucket.remove(fileName); + } + } + return { + acquireDocument: acquireDocument, + updateDocument: updateDocument, + releaseDocument: releaseDocument, + reportStats: reportStats + }; + } + ts.createDocumentRegistry = createDocumentRegistry; + function preProcessFile(sourceText, readImportFiles) { + if (readImportFiles === void 0) { readImportFiles = true; } + var referencedFiles = []; + var importedFiles = []; + var ambientExternalModules; + var isNoDefaultLib = false; + function processTripleSlashDirectives() { + var commentRanges = ts.getLeadingCommentRanges(sourceText, 0); + ts.forEach(commentRanges, function (commentRange) { + var comment = sourceText.substring(commentRange.pos, commentRange.end); + var referencePathMatchResult = ts.getFileReferenceFromReferencePath(comment, commentRange); + if (referencePathMatchResult) { + isNoDefaultLib = referencePathMatchResult.isNoDefaultLib; + var fileReference = referencePathMatchResult.fileReference; + if (fileReference) { + referencedFiles.push(fileReference); + } + } + }); + } + function recordAmbientExternalModule() { + if (!ambientExternalModules) { + ambientExternalModules = []; + } + ambientExternalModules.push(scanner.getTokenValue()); + } + function recordModuleName() { + var importPath = scanner.getTokenValue(); + var pos = scanner.getTokenPos(); + importedFiles.push({ + fileName: importPath, + pos: pos, + end: pos + importPath.length + }); + } + function processImport() { + scanner.setText(sourceText); + var token = scanner.scan(); + // Look for: + // import "mod"; + // import d from "mod" + // import {a as A } from "mod"; + // import * as NS from "mod" + // import d, {a, b as B} from "mod" + // import i = require("mod"); + // + // export * from "mod" + // export {a as b} from "mod" + // export import i = require("mod") + while (token !== 1 /* EndOfFileToken */) { + if (token === 122 /* DeclareKeyword */) { + // declare module "mod" + token = scanner.scan(); + if (token === 125 /* ModuleKeyword */) { + token = scanner.scan(); + if (token === 9 /* StringLiteral */) { + recordAmbientExternalModule(); + continue; + } + } + } + else if (token === 89 /* ImportKeyword */) { + token = scanner.scan(); + if (token === 9 /* StringLiteral */) { + // import "mod"; + recordModuleName(); + continue; + } + else { + if (token === 69 /* Identifier */ || ts.isKeyword(token)) { + token = scanner.scan(); + if (token === 133 /* FromKeyword */) { + token = scanner.scan(); + if (token === 9 /* StringLiteral */) { + // import d from "mod"; + recordModuleName(); + continue; + } + } + else if (token === 56 /* EqualsToken */) { + token = scanner.scan(); + if (token === 127 /* RequireKeyword */) { + token = scanner.scan(); + if (token === 17 /* OpenParenToken */) { + token = scanner.scan(); + if (token === 9 /* StringLiteral */) { + // import i = require("mod"); + recordModuleName(); + continue; + } + } + } + } + else if (token === 24 /* CommaToken */) { + // consume comma and keep going + token = scanner.scan(); + } + else { + // unknown syntax + continue; + } + } + if (token === 15 /* OpenBraceToken */) { + token = scanner.scan(); + // consume "{ a as B, c, d as D}" clauses + while (token !== 16 /* CloseBraceToken */) { + token = scanner.scan(); + } + if (token === 16 /* CloseBraceToken */) { + token = scanner.scan(); + if (token === 133 /* FromKeyword */) { + token = scanner.scan(); + if (token === 9 /* StringLiteral */) { + // import {a as A} from "mod"; + // import d, {a, b as B} from "mod" + recordModuleName(); + } + } + } + } + else if (token === 37 /* AsteriskToken */) { + token = scanner.scan(); + if (token === 116 /* AsKeyword */) { + token = scanner.scan(); + if (token === 69 /* Identifier */ || ts.isKeyword(token)) { + token = scanner.scan(); + if (token === 133 /* FromKeyword */) { + token = scanner.scan(); + if (token === 9 /* StringLiteral */) { + // import * as NS from "mod" + // import d, * as NS from "mod" + recordModuleName(); + } + } + } + } + } + } + } + else if (token === 82 /* ExportKeyword */) { + token = scanner.scan(); + if (token === 15 /* OpenBraceToken */) { + token = scanner.scan(); + // consume "{ a as B, c, d as D}" clauses + while (token !== 16 /* CloseBraceToken */) { + token = scanner.scan(); + } + if (token === 16 /* CloseBraceToken */) { + token = scanner.scan(); + if (token === 133 /* FromKeyword */) { + token = scanner.scan(); + if (token === 9 /* StringLiteral */) { + // export {a as A} from "mod"; + // export {a, b as B} from "mod" + recordModuleName(); + } + } + } + } + else if (token === 37 /* AsteriskToken */) { + token = scanner.scan(); + if (token === 133 /* FromKeyword */) { + token = scanner.scan(); + if (token === 9 /* StringLiteral */) { + // export * from "mod" + recordModuleName(); + } + } + } + else if (token === 89 /* ImportKeyword */) { + token = scanner.scan(); + if (token === 69 /* Identifier */ || ts.isKeyword(token)) { + token = scanner.scan(); + if (token === 56 /* EqualsToken */) { + token = scanner.scan(); + if (token === 127 /* RequireKeyword */) { + token = scanner.scan(); + if (token === 17 /* OpenParenToken */) { + token = scanner.scan(); + if (token === 9 /* StringLiteral */) { + // export import i = require("mod"); + recordModuleName(); + } + } + } + } + } + } + } + token = scanner.scan(); + } + scanner.setText(undefined); + } + if (readImportFiles) { + processImport(); + } + processTripleSlashDirectives(); + return { referencedFiles: referencedFiles, importedFiles: importedFiles, isLibFile: isNoDefaultLib, ambientExternalModules: ambientExternalModules }; + } + ts.preProcessFile = preProcessFile; + /// Helpers + function getTargetLabel(referenceNode, labelName) { + while (referenceNode) { + if (referenceNode.kind === 207 /* LabeledStatement */ && referenceNode.label.text === labelName) { + return referenceNode.label; + } + referenceNode = referenceNode.parent; + } + return undefined; + } + function isJumpStatementTarget(node) { + return node.kind === 69 /* Identifier */ && + (node.parent.kind === 203 /* BreakStatement */ || node.parent.kind === 202 /* ContinueStatement */) && + node.parent.label === node; + } + function isLabelOfLabeledStatement(node) { + return node.kind === 69 /* Identifier */ && + node.parent.kind === 207 /* LabeledStatement */ && + node.parent.label === node; + } + /** + * Whether or not a 'node' is preceded by a label of the given string. + * Note: 'node' cannot be a SourceFile. + */ + function isLabeledBy(node, labelName) { + for (var owner = node.parent; owner.kind === 207 /* LabeledStatement */; owner = owner.parent) { + if (owner.label.text === labelName) { + return true; + } + } + return false; + } + function isLabelName(node) { + return isLabelOfLabeledStatement(node) || isJumpStatementTarget(node); + } + function isRightSideOfQualifiedName(node) { + return node.parent.kind === 135 /* QualifiedName */ && node.parent.right === node; + } + function isRightSideOfPropertyAccess(node) { + return node && node.parent && node.parent.kind === 166 /* PropertyAccessExpression */ && node.parent.name === node; + } + function isCallExpressionTarget(node) { + if (isRightSideOfPropertyAccess(node)) { + node = node.parent; + } + return node && node.parent && node.parent.kind === 168 /* CallExpression */ && node.parent.expression === node; + } + function isNewExpressionTarget(node) { + if (isRightSideOfPropertyAccess(node)) { + node = node.parent; + } + return node && node.parent && node.parent.kind === 169 /* NewExpression */ && node.parent.expression === node; + } + function isNameOfModuleDeclaration(node) { + return node.parent.kind === 218 /* ModuleDeclaration */ && node.parent.name === node; + } + function isNameOfFunctionDeclaration(node) { + return node.kind === 69 /* Identifier */ && + ts.isFunctionLike(node.parent) && node.parent.name === node; + } + /** Returns true if node is a name of an object literal property, e.g. "a" in x = { "a": 1 } */ + function isNameOfPropertyAssignment(node) { + return (node.kind === 69 /* Identifier */ || node.kind === 9 /* StringLiteral */ || node.kind === 8 /* NumericLiteral */) && + (node.parent.kind === 245 /* PropertyAssignment */ || node.parent.kind === 246 /* ShorthandPropertyAssignment */) && node.parent.name === node; + } + function isLiteralNameOfPropertyDeclarationOrIndexAccess(node) { + if (node.kind === 9 /* StringLiteral */ || node.kind === 8 /* NumericLiteral */) { + switch (node.parent.kind) { + case 141 /* PropertyDeclaration */: + case 140 /* PropertySignature */: + case 245 /* PropertyAssignment */: + case 247 /* EnumMember */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: + case 218 /* ModuleDeclaration */: + return node.parent.name === node; + case 167 /* ElementAccessExpression */: + return node.parent.argumentExpression === node; + } + } + return false; + } + function isNameOfExternalModuleImportOrDeclaration(node) { + if (node.kind === 9 /* StringLiteral */) { + return isNameOfModuleDeclaration(node) || + (ts.isExternalModuleImportEqualsDeclaration(node.parent.parent) && ts.getExternalModuleImportEqualsDeclarationExpression(node.parent.parent) === node); + } + return false; + } + /** Returns true if the position is within a comment */ + function isInsideComment(sourceFile, token, position) { + // The position has to be: 1. in the leading trivia (before token.getStart()), and 2. within a comment + return position <= token.getStart(sourceFile) && + (isInsideCommentRange(ts.getTrailingCommentRanges(sourceFile.text, token.getFullStart())) || + isInsideCommentRange(ts.getLeadingCommentRanges(sourceFile.text, token.getFullStart()))); + function isInsideCommentRange(comments) { + return ts.forEach(comments, function (comment) { + // either we are 1. completely inside the comment, or 2. at the end of the comment + if (comment.pos < position && position < comment.end) { + return true; + } + else if (position === comment.end) { + var text = sourceFile.text; + var width = comment.end - comment.pos; + // is single line comment or just /* + if (width <= 2 || text.charCodeAt(comment.pos + 1) === 47 /* slash */) { + return true; + } + else { + // is unterminated multi-line comment + return !(text.charCodeAt(comment.end - 1) === 47 /* slash */ && + text.charCodeAt(comment.end - 2) === 42 /* asterisk */); + } + } + return false; + }); + } + } + var SemanticMeaning; + (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"; + })(SemanticMeaning || (SemanticMeaning = {})); + var BreakContinueSearchType; + (function (BreakContinueSearchType) { + BreakContinueSearchType[BreakContinueSearchType["None"] = 0] = "None"; + BreakContinueSearchType[BreakContinueSearchType["Unlabeled"] = 1] = "Unlabeled"; + BreakContinueSearchType[BreakContinueSearchType["Labeled"] = 2] = "Labeled"; + BreakContinueSearchType[BreakContinueSearchType["All"] = 3] = "All"; + })(BreakContinueSearchType || (BreakContinueSearchType = {})); + // A cache of completion entries for keywords, these do not change between sessions + var keywordCompletions = []; + for (var i = 70 /* FirstKeyword */; i <= 134 /* LastKeyword */; i++) { + keywordCompletions.push({ + name: ts.tokenToString(i), + kind: ScriptElementKind.keyword, + kindModifiers: ScriptElementKindModifier.none, + sortText: "0" + }); + } + /* @internal */ function getContainerNode(node) { + while (true) { + node = node.parent; + if (!node) { + return undefined; + } + switch (node.kind) { + case 248 /* SourceFile */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: + case 213 /* FunctionDeclaration */: + case 173 /* FunctionExpression */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: + case 214 /* ClassDeclaration */: + case 215 /* InterfaceDeclaration */: + case 217 /* EnumDeclaration */: + case 218 /* ModuleDeclaration */: + return node; + } + } + } + ts.getContainerNode = getContainerNode; + /* @internal */ function getNodeKind(node) { + switch (node.kind) { + case 218 /* ModuleDeclaration */: return ScriptElementKind.moduleElement; + case 214 /* ClassDeclaration */: return ScriptElementKind.classElement; + case 215 /* InterfaceDeclaration */: return ScriptElementKind.interfaceElement; + case 216 /* TypeAliasDeclaration */: return ScriptElementKind.typeElement; + case 217 /* EnumDeclaration */: return ScriptElementKind.enumElement; + case 211 /* VariableDeclaration */: + return ts.isConst(node) + ? ScriptElementKind.constElement + : ts.isLet(node) + ? ScriptElementKind.letElement + : ScriptElementKind.variableElement; + case 213 /* FunctionDeclaration */: return ScriptElementKind.functionElement; + case 145 /* GetAccessor */: return ScriptElementKind.memberGetAccessorElement; + case 146 /* SetAccessor */: return ScriptElementKind.memberSetAccessorElement; + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: + return ScriptElementKind.memberFunctionElement; + case 141 /* PropertyDeclaration */: + case 140 /* PropertySignature */: + return ScriptElementKind.memberVariableElement; + case 149 /* IndexSignature */: return ScriptElementKind.indexSignatureElement; + case 148 /* ConstructSignature */: return ScriptElementKind.constructSignatureElement; + case 147 /* CallSignature */: return ScriptElementKind.callSignatureElement; + case 144 /* Constructor */: return ScriptElementKind.constructorImplementationElement; + case 137 /* TypeParameter */: return ScriptElementKind.typeParameterElement; + case 247 /* EnumMember */: return ScriptElementKind.variableElement; + case 138 /* Parameter */: return (node.flags & 112 /* AccessibilityModifier */) ? ScriptElementKind.memberVariableElement : ScriptElementKind.parameterElement; + case 221 /* ImportEqualsDeclaration */: + case 226 /* ImportSpecifier */: + case 223 /* ImportClause */: + case 230 /* ExportSpecifier */: + case 224 /* NamespaceImport */: + return ScriptElementKind.alias; + } + return ScriptElementKind.unknown; + } + ts.getNodeKind = getNodeKind; + var CancellationTokenObject = (function () { + function CancellationTokenObject(cancellationToken) { + this.cancellationToken = cancellationToken; + } + CancellationTokenObject.prototype.isCancellationRequested = function () { + return this.cancellationToken && this.cancellationToken.isCancellationRequested(); + }; + CancellationTokenObject.prototype.throwIfCancellationRequested = function () { + if (this.isCancellationRequested()) { + throw new ts.OperationCanceledException(); + } + }; + return CancellationTokenObject; + })(); + function createLanguageService(host, documentRegistry) { + if (documentRegistry === void 0) { documentRegistry = createDocumentRegistry(); } + var syntaxTreeCache = new SyntaxTreeCache(host); + var ruleProvider; + var program; + var lastProjectVersion; + var useCaseSensitivefileNames = false; + var cancellationToken = new CancellationTokenObject(host.getCancellationToken && host.getCancellationToken()); + // Check if the localized messages json is set, otherwise query the host for it + if (!ts.localizedDiagnosticMessages && host.getLocalizedDiagnosticMessages) { + ts.localizedDiagnosticMessages = host.getLocalizedDiagnosticMessages(); + } + function log(message) { + if (host.log) { + host.log(message); + } + } + var getCanonicalFileName = createGetCanonicalFileName(useCaseSensitivefileNames); + function getValidSourceFile(fileName) { + fileName = ts.normalizeSlashes(fileName); + var sourceFile = program.getSourceFile(getCanonicalFileName(fileName)); + if (!sourceFile) { + throw new Error("Could not find file: '" + fileName + "'."); + } + return sourceFile; + } + function getRuleProvider(options) { + // Ensure rules are initialized and up to date wrt to formatting options + if (!ruleProvider) { + ruleProvider = new ts.formatting.RulesProvider(); + } + ruleProvider.ensureUpToDate(options); + return ruleProvider; + } + function synchronizeHostData() { + // perform fast check if host supports it + if (host.getProjectVersion) { + var hostProjectVersion = host.getProjectVersion(); + if (hostProjectVersion) { + if (lastProjectVersion === hostProjectVersion) { + return; + } + lastProjectVersion = hostProjectVersion; + } + } + // 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 + if (programUpToDate()) { + return; + } + // IMPORTANT - It is critical from this moment onward that we do not check + // cancellation tokens. We are about to mutate source files from a previous program + // instance. If we cancel midway through, we may end up in an inconsistent state where + // the program points to old source files that have been invalidated because of + // incremental parsing. + var oldSettings = program && program.getCompilerOptions(); + var newSettings = hostCache.compilationSettings(); + var changesInCompilationSettingsAffectSyntax = oldSettings && + (oldSettings.target !== newSettings.target || + oldSettings.module !== newSettings.module || + oldSettings.noResolve !== newSettings.noResolve || + oldSettings.jsx !== newSettings.jsx); + // Now create a new compiler + var compilerHost = { + getSourceFile: getOrCreateSourceFile, + getCancellationToken: function () { return cancellationToken; }, + getCanonicalFileName: getCanonicalFileName, + useCaseSensitiveFileNames: function () { return useCaseSensitivefileNames; }, + getNewLine: function () { return ts.getNewLineOrDefaultFromHost(host); }, + getDefaultLibFileName: function (options) { return host.getDefaultLibFileName(options); }, + writeFile: function (fileName, data, writeByteOrderMark) { }, + getCurrentDirectory: function () { return host.getCurrentDirectory(); }, + fileExists: function (fileName) { + // stub missing host functionality + ts.Debug.assert(!host.resolveModuleNames); + return hostCache.getOrCreateEntry(fileName) !== undefined; + }, + readFile: function (fileName) { + // stub missing host functionality + var entry = hostCache.getOrCreateEntry(fileName); + return entry && entry.scriptSnapshot.getText(0, entry.scriptSnapshot.getLength()); + } + }; + if (host.resolveModuleNames) { + compilerHost.resolveModuleNames = function (moduleNames, containingFile) { return host.resolveModuleNames(moduleNames, containingFile); }; + } + var newProgram = ts.createProgram(hostCache.getRootFileNames(), newSettings, compilerHost, program); + // Release any files we have acquired in the old program but are + // not part of the new program. + if (program) { + var oldSourceFiles = program.getSourceFiles(); + for (var _i = 0; _i < oldSourceFiles.length; _i++) { + var oldSourceFile = oldSourceFiles[_i]; + var fileName = oldSourceFile.fileName; + if (!newProgram.getSourceFile(fileName) || changesInCompilationSettingsAffectSyntax) { + documentRegistry.releaseDocument(fileName, oldSettings); + } + } + } + // hostCache is captured in the closure for 'getOrCreateSourceFile' but it should not be used past this point. + // It needs to be cleared to allow all collected snapshots to be released + hostCache = undefined; + program = newProgram; + // Make sure all the nodes in the program are both bound, and have their parent + // pointers set property. + program.getTypeChecker(); + return; + function getOrCreateSourceFile(fileName) { + ts.Debug.assert(hostCache !== undefined); + // The program is asking for this file, check first if the host can locate it. + // If the host can not locate the file, then it does not exist. return undefined + // to the program to allow reporting of errors for missing files. + var hostFileInformation = hostCache.getOrCreateEntry(fileName); + if (!hostFileInformation) { + return undefined; + } + // Check if the language version has changed since we last created a program; if they are the same, + // it is safe to reuse the souceFiles; if not, then the shape of the AST can change, and the oldSourceFile + // can not be reused. we have to dump all syntax trees and create new ones. + if (!changesInCompilationSettingsAffectSyntax) { + // Check if the old program had this file already + var oldSourceFile = program && program.getSourceFile(fileName); + if (oldSourceFile) { + // We already had a source file for this file name. Go to the registry to + // ensure that we get the right up to date version of it. We need this to + // address the following 'race'. Specifically, say we have the following: + // + // LS1 + // \ + // DocumentRegistry + // / + // LS2 + // + // Each LS has a reference to file 'foo.ts' at version 1. LS2 then updates + // it's version of 'foo.ts' to version 2. This will cause LS2 and the + // DocumentRegistry to have version 2 of the document. HOwever, LS1 will + // have version 1. And *importantly* this source file will be *corrupt*. + // The act of creating version 2 of the file irrevocably damages the version + // 1 file. + // + // So, later when we call into LS1, we need to make sure that it doesn't use + // it's source file any more, and instead defers to DocumentRegistry to get + // either version 1, version 2 (or some other version) depending on what the + // host says should be used. + return documentRegistry.updateDocument(fileName, newSettings, hostFileInformation.scriptSnapshot, hostFileInformation.version); + } + } + // Could not find this file in the old program, create a new SourceFile for it. + return documentRegistry.acquireDocument(fileName, newSettings, hostFileInformation.scriptSnapshot, hostFileInformation.version); + } + function sourceFileUpToDate(sourceFile) { + return sourceFile && sourceFile.version === hostCache.getVersion(sourceFile.fileName); + } + function programUpToDate() { + // If we haven't create a program yet, then it is not up-to-date + if (!program) { + return false; + } + // If number of files in the program do not match, it is not up-to-date + var rootFileNames = hostCache.getRootFileNames(); + if (program.getSourceFiles().length !== rootFileNames.length) { + return false; + } + // If any file is not up-to-date, then the whole program is not up-to-date + for (var _i = 0; _i < rootFileNames.length; _i++) { + var fileName = rootFileNames[_i]; + if (!sourceFileUpToDate(program.getSourceFile(fileName))) { + return false; + } + } + // If the compilation settings do no match, then the program is not up-to-date + return ts.compareDataObjects(program.getCompilerOptions(), hostCache.compilationSettings()); + } + } + function getProgram() { + synchronizeHostData(); + return program; + } + function cleanupSemanticCache() { + // TODO: Should we jettison the program (or it's type checker) here? + } + function dispose() { + if (program) { + ts.forEach(program.getSourceFiles(), function (f) { + return documentRegistry.releaseDocument(f.fileName, program.getCompilerOptions()); + }); + } + } + /// Diagnostics + function getSyntacticDiagnostics(fileName) { + synchronizeHostData(); + return program.getSyntacticDiagnostics(getValidSourceFile(fileName), cancellationToken); + } + /** + * getSemanticDiagnostiscs return array of Diagnostics. If '-d' is not enabled, only report semantic errors + * If '-d' enabled, report both semantic and emitter errors + */ + function getSemanticDiagnostics(fileName) { + synchronizeHostData(); + var targetSourceFile = getValidSourceFile(fileName); + // For JavaScript files, we don't want to report the normal typescript semantic errors. + // Instead, we just report errors for using TypeScript-only constructs from within a + // JavaScript file. + if (ts.isJavaScript(fileName)) { + return getJavaScriptSemanticDiagnostics(targetSourceFile); + } + // Only perform the action per file regardless of '-out' flag as LanguageServiceHost is expected to call this function per file. + // Therefore only get diagnostics for given file. + var semanticDiagnostics = program.getSemanticDiagnostics(targetSourceFile, cancellationToken); + if (!program.getCompilerOptions().declaration) { + return semanticDiagnostics; + } + // If '-d' is enabled, check for emitter error. One example of emitter error is export class implements non-export interface + var declarationDiagnostics = program.getDeclarationDiagnostics(targetSourceFile, cancellationToken); + return ts.concatenate(semanticDiagnostics, declarationDiagnostics); + } + function getJavaScriptSemanticDiagnostics(sourceFile) { + var diagnostics = []; + walk(sourceFile); + return diagnostics; + function walk(node) { + if (!node) { + return false; + } + switch (node.kind) { + case 221 /* ImportEqualsDeclaration */: + diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.import_can_only_be_used_in_a_ts_file)); + return true; + case 227 /* ExportAssignment */: + diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.export_can_only_be_used_in_a_ts_file)); + return true; + case 214 /* ClassDeclaration */: + var classDeclaration = node; + if (checkModifiers(classDeclaration.modifiers) || + checkTypeParameters(classDeclaration.typeParameters)) { + return true; + } + break; + case 243 /* HeritageClause */: + var heritageClause = node; + if (heritageClause.token === 106 /* ImplementsKeyword */) { + diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.implements_clauses_can_only_be_used_in_a_ts_file)); + return true; + } + break; + case 215 /* InterfaceDeclaration */: + diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.interface_declarations_can_only_be_used_in_a_ts_file)); + return true; + case 218 /* ModuleDeclaration */: + diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.module_declarations_can_only_be_used_in_a_ts_file)); + return true; + case 216 /* TypeAliasDeclaration */: + diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.type_aliases_can_only_be_used_in_a_ts_file)); + return true; + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: + case 144 /* Constructor */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: + case 173 /* FunctionExpression */: + case 213 /* FunctionDeclaration */: + case 174 /* ArrowFunction */: + case 213 /* FunctionDeclaration */: + var functionDeclaration = node; + if (checkModifiers(functionDeclaration.modifiers) || + checkTypeParameters(functionDeclaration.typeParameters) || + checkTypeAnnotation(functionDeclaration.type)) { + return true; + } + break; + case 193 /* VariableStatement */: + var variableStatement = node; + if (checkModifiers(variableStatement.modifiers)) { + return true; + } + break; + case 211 /* VariableDeclaration */: + var variableDeclaration = node; + if (checkTypeAnnotation(variableDeclaration.type)) { + return true; + } + break; + case 168 /* CallExpression */: + case 169 /* NewExpression */: + var expression = node; + if (expression.typeArguments && expression.typeArguments.length > 0) { + var start = expression.typeArguments.pos; + diagnostics.push(ts.createFileDiagnostic(sourceFile, start, expression.typeArguments.end - start, ts.Diagnostics.type_arguments_can_only_be_used_in_a_ts_file)); + return true; + } + break; + case 138 /* Parameter */: + var parameter = node; + if (parameter.modifiers) { + var start = parameter.modifiers.pos; + diagnostics.push(ts.createFileDiagnostic(sourceFile, start, parameter.modifiers.end - start, ts.Diagnostics.parameter_modifiers_can_only_be_used_in_a_ts_file)); + return true; + } + if (parameter.questionToken) { + diagnostics.push(ts.createDiagnosticForNode(parameter.questionToken, ts.Diagnostics._0_can_only_be_used_in_a_ts_file, '?')); + return true; + } + if (parameter.type) { + diagnostics.push(ts.createDiagnosticForNode(parameter.type, ts.Diagnostics.types_can_only_be_used_in_a_ts_file)); + return true; + } + break; + case 141 /* PropertyDeclaration */: + diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.property_declarations_can_only_be_used_in_a_ts_file)); + return true; + case 217 /* EnumDeclaration */: + diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.enum_declarations_can_only_be_used_in_a_ts_file)); + return true; + case 171 /* TypeAssertionExpression */: + var typeAssertionExpression = node; + diagnostics.push(ts.createDiagnosticForNode(typeAssertionExpression.type, ts.Diagnostics.type_assertion_expressions_can_only_be_used_in_a_ts_file)); + return true; + case 139 /* Decorator */: + diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.decorators_can_only_be_used_in_a_ts_file)); + return true; + } + return ts.forEachChild(node, walk); + } + function checkTypeParameters(typeParameters) { + if (typeParameters) { + var start = typeParameters.pos; + diagnostics.push(ts.createFileDiagnostic(sourceFile, start, typeParameters.end - start, ts.Diagnostics.type_parameter_declarations_can_only_be_used_in_a_ts_file)); + return true; + } + return false; + } + function checkTypeAnnotation(type) { + if (type) { + diagnostics.push(ts.createDiagnosticForNode(type, ts.Diagnostics.types_can_only_be_used_in_a_ts_file)); + return true; + } + return false; + } + function checkModifiers(modifiers) { + if (modifiers) { + for (var _i = 0; _i < modifiers.length; _i++) { + var modifier = modifiers[_i]; + switch (modifier.kind) { + case 112 /* PublicKeyword */: + case 110 /* PrivateKeyword */: + case 111 /* ProtectedKeyword */: + case 122 /* DeclareKeyword */: + diagnostics.push(ts.createDiagnosticForNode(modifier, ts.Diagnostics._0_can_only_be_used_in_a_ts_file, ts.tokenToString(modifier.kind))); + return true; + // These are all legal modifiers. + case 113 /* StaticKeyword */: + case 82 /* ExportKeyword */: + case 74 /* ConstKeyword */: + case 77 /* DefaultKeyword */: + case 115 /* AbstractKeyword */: + } + } + } + return false; + } + } + function getCompilerOptionsDiagnostics() { + synchronizeHostData(); + return program.getOptionsDiagnostics(cancellationToken).concat(program.getGlobalDiagnostics(cancellationToken)); + } + /** + * Get the name to be display in completion from a given symbol. + * + * @return undefined if the name is of external module otherwise a name with striped of any quote + */ + function getCompletionEntryDisplayNameForSymbol(symbol, target, performCharacterChecks, location) { + var displayName = ts.getDeclaredName(program.getTypeChecker(), symbol, location); + if (displayName) { + var firstCharCode = displayName.charCodeAt(0); + // First check of the displayName is not external module; if it is an external module, it is not valid entry + if ((symbol.flags & 1536 /* Namespace */) && (firstCharCode === 39 /* singleQuote */ || firstCharCode === 34 /* doubleQuote */)) { + // If the symbol is external module, don't show it in the completion list + // (i.e declare module "http" { let x; } | // <= request completion here, "http" should not be there) + return undefined; + } + } + return getCompletionEntryDisplayName(displayName, target, performCharacterChecks); + } + /** + * Get a displayName from a given for completion list, performing any necessary quotes stripping + * and checking whether the name is valid identifier name. + */ + function getCompletionEntryDisplayName(name, target, performCharacterChecks) { + if (!name) { + return undefined; + } + name = ts.stripQuotes(name); + if (!name) { + return undefined; + } + // If the user entered name for the symbol was quoted, removing the quotes is not enough, as the name could be an + // invalid identifier name. We need to check if whatever was inside the quotes is actually a valid identifier name. + // e.g "b a" is valid quoted name but when we strip off the quotes, it is invalid. + // We, thus, need to check if whatever was inside the quotes is actually a valid identifier name. + if (performCharacterChecks) { + if (!ts.isIdentifierStart(name.charCodeAt(0), target)) { + return undefined; + } + for (var i = 1, n = name.length; i < n; i++) { + if (!ts.isIdentifierPart(name.charCodeAt(i), target)) { + return undefined; + } + } + } + return name; + } + function getCompletionData(fileName, position) { + var typeChecker = program.getTypeChecker(); + var syntacticStart = new Date().getTime(); + var sourceFile = getValidSourceFile(fileName); + var isJavaScriptFile = ts.isJavaScript(fileName); + var isJsDocTagName = false; + var start = new Date().getTime(); + var currentToken = ts.getTokenAtPosition(sourceFile, position); + log("getCompletionData: Get current token: " + (new Date().getTime() - start)); + start = new Date().getTime(); + // Completion not allowed inside comments, bail out if this is the case + var insideComment = isInsideComment(sourceFile, currentToken, position); + log("getCompletionData: Is inside comment: " + (new Date().getTime() - start)); + if (insideComment) { + // The current position is next to the '@' sign, when no tag name being provided yet. + // Provide a full list of tag names + if (ts.hasDocComment(sourceFile, position) && sourceFile.text.charCodeAt(position - 1) === 64 /* at */) { + isJsDocTagName = true; + } + // Completion should work inside certain JsDoc tags. For example: + // /** @type {number | string} */ + // Completion should work in the brackets + var insideJsDocTagExpression = false; + var tag = ts.getJsDocTagAtPosition(sourceFile, position); + if (tag) { + if (tag.tagName.pos <= position && position <= tag.tagName.end) { + isJsDocTagName = true; + } + switch (tag.kind) { + case 269 /* JSDocTypeTag */: + case 267 /* JSDocParameterTag */: + case 268 /* JSDocReturnTag */: + var tagWithExpression = tag; + if (tagWithExpression.typeExpression) { + insideJsDocTagExpression = tagWithExpression.typeExpression.pos < position && position < tagWithExpression.typeExpression.end; + } + break; + } + } + if (isJsDocTagName) { + return { symbols: undefined, 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 + // comment or the plain text part of a jsDoc comment, so no completion should be available + log("Returning an empty list because completion was inside a regular comment or plain text part of a JsDoc comment."); + return undefined; + } + } + start = new Date().getTime(); + var previousToken = ts.findPrecedingToken(position, sourceFile); + log("getCompletionData: Get previous token 1: " + (new Date().getTime() - start)); + // The decision to provide completion depends on the contextToken, which is determined through the previousToken. + // Note: 'previousToken' (and thus 'contextToken') can be undefined if we are the beginning of the file + var contextToken = previousToken; + // Check if the caret is at the end of an identifier; this is a partial identifier that we want to complete: e.g. a.toS| + // Skip this partial identifier and adjust the contextToken to the token that precedes it. + if (contextToken && position <= contextToken.end && ts.isWord(contextToken.kind)) { + var start_3 = new Date().getTime(); + contextToken = ts.findPrecedingToken(contextToken.getFullStart(), sourceFile); + log("getCompletionData: Get previous token 2: " + (new Date().getTime() - start_3)); + } + // Find the node where completion is requested on. + // Also determine whether we are trying to complete with members of that node + // or attributes of a JSX tag. + var node = currentToken; + var isRightOfDot = false; + var isRightOfOpenTag = false; + var isStartingCloseTag = false; + var location = ts.getTouchingPropertyName(sourceFile, position); + if (contextToken) { + // Bail out if this is a known invalid completion location + if (isCompletionListBlocker(contextToken)) { + log("Returning an empty list because completion was requested in an invalid position."); + return undefined; + } + var parent_9 = contextToken.parent, kind = contextToken.kind; + if (kind === 21 /* DotToken */) { + if (parent_9.kind === 166 /* PropertyAccessExpression */) { + node = contextToken.parent.expression; + isRightOfDot = true; + } + else if (parent_9.kind === 135 /* QualifiedName */) { + node = contextToken.parent.left; + isRightOfDot = true; + } + else { + // There is nothing that precedes the dot, so this likely just a stray character + // or leading into a '...' token. Just bail out instead. + return undefined; + } + } + else if (sourceFile.languageVariant === 1 /* JSX */) { + if (kind === 25 /* LessThanToken */) { + isRightOfOpenTag = true; + location = contextToken; + } + else if (kind === 39 /* SlashToken */ && contextToken.parent.kind === 237 /* JsxClosingElement */) { + isStartingCloseTag = true; + } + } + } + var semanticStart = new Date().getTime(); + var isMemberCompletion; + var isNewIdentifierLocation; + var symbols = []; + if (isRightOfDot) { + getTypeScriptMemberSymbols(); + } + else if (isRightOfOpenTag) { + var tagSymbols = typeChecker.getJsxIntrinsicTagNames(); + if (tryGetGlobalSymbols()) { + symbols = tagSymbols.concat(symbols.filter(function (s) { return !!(s.flags & 107455 /* Value */); })); + } + else { + symbols = tagSymbols; + } + isMemberCompletion = true; + isNewIdentifierLocation = false; + } + else if (isStartingCloseTag) { + var tagName = contextToken.parent.parent.openingElement.tagName; + symbols = [typeChecker.getSymbolAtLocation(tagName)]; + isMemberCompletion = true; + isNewIdentifierLocation = false; + } + else { + // For JavaScript or TypeScript, if we're not after a dot, then just try to get the + // global symbols in scope. These results should be valid for either language as + // the set of symbols that can be referenced from this location. + if (!tryGetGlobalSymbols()) { + return undefined; + } + } + log("getCompletionData: Semantic work: " + (new Date().getTime() - semanticStart)); + return { symbols: symbols, isMemberCompletion: isMemberCompletion, isNewIdentifierLocation: isNewIdentifierLocation, location: location, isRightOfDot: (isRightOfDot || isRightOfOpenTag), isJsDocTagName: isJsDocTagName }; + function getTypeScriptMemberSymbols() { + // Right of dot member completion list + isMemberCompletion = true; + isNewIdentifierLocation = false; + if (node.kind === 69 /* Identifier */ || node.kind === 135 /* QualifiedName */ || node.kind === 166 /* PropertyAccessExpression */) { + var symbol = typeChecker.getSymbolAtLocation(node); + // This is an alias, follow what it aliases + if (symbol && symbol.flags & 8388608 /* Alias */) { + symbol = typeChecker.getAliasedSymbol(symbol); + } + if (symbol && symbol.flags & 1952 /* HasExports */) { + // Extract module or enum members + var exportedSymbols = typeChecker.getExportsOfModule(symbol); + ts.forEach(exportedSymbols, function (symbol) { + if (typeChecker.isValidPropertyAccess((node.parent), symbol.name)) { + symbols.push(symbol); + } + }); + } + } + var type = typeChecker.getTypeAtLocation(node); + addTypeProperties(type); + } + function addTypeProperties(type) { + if (type) { + // Filter private properties + for (var _i = 0, _a = type.getApparentProperties(); _i < _a.length; _i++) { + var symbol = _a[_i]; + if (typeChecker.isValidPropertyAccess((node.parent), symbol.name)) { + symbols.push(symbol); + } + } + if (isJavaScriptFile && type.flags & 16384 /* Union */) { + // In javascript files, for union types, we don't just get the members that + // the individual types have in common, we also include all the members that + // each individual type has. This is because we're going to add all identifiers + // anyways. So we might as well elevate the members that were at least part + // of the individual types to a higher status since we know what they are. + var unionType = type; + for (var _b = 0, _c = unionType.types; _b < _c.length; _b++) { + var elementType = _c[_b]; + addTypeProperties(elementType); + } + } + } + } + function tryGetGlobalSymbols() { + var objectLikeContainer; + var namedImportsOrExports; + var jsxContainer; + if (objectLikeContainer = tryGetObjectLikeCompletionContainer(contextToken)) { + return tryGetObjectLikeCompletionSymbols(objectLikeContainer); + } + if (namedImportsOrExports = tryGetNamedImportsOrExportsForCompletion(contextToken)) { + // cursor is in an import clause + // try to show exported member for imported module + return tryGetImportOrExportClauseCompletionSymbols(namedImportsOrExports); + } + if (jsxContainer = tryGetContainingJsxElement(contextToken)) { + var attrsType; + if ((jsxContainer.kind === 234 /* JsxSelfClosingElement */) || (jsxContainer.kind === 235 /* JsxOpeningElement */)) { + // Cursor is inside a JSX self-closing element or opening element + attrsType = typeChecker.getJsxElementAttributesType(jsxContainer); + if (attrsType) { + symbols = filterJsxAttributes(typeChecker.getPropertiesOfType(attrsType), jsxContainer.attributes); + isMemberCompletion = true; + isNewIdentifierLocation = false; + return true; + } + } + } + // Get all entities in the current scope. + isMemberCompletion = false; + isNewIdentifierLocation = isNewIdentifierDefinitionLocation(contextToken); + if (previousToken !== contextToken) { + ts.Debug.assert(!!previousToken, "Expected 'contextToken' to be defined when different from 'previousToken'."); + } + // We need to find the node that will give us an appropriate scope to begin + // aggregating completion candidates. This is achieved in 'getScopeNode' + // by finding the first node that encompasses a position, accounting for whether a node + // is "complete" to decide whether a position belongs to the node. + // + // However, at the end of an identifier, we are interested in the scope of the identifier + // itself, but fall outside of the identifier. For instance: + // + // xyz => x$ + // + // the cursor is outside of both the 'x' and the arrow function 'xyz => x', + // so 'xyz' is not returned in our results. + // + // We define 'adjustedPosition' so that we may appropriately account for + // being at the end of an identifier. The intention is that if requesting completion + // at the end of an identifier, it should be effectively equivalent to requesting completion + // anywhere inside/at the beginning of the identifier. So in the previous case, the + // 'adjustedPosition' will work as if requesting completion in the following: + // + // xyz => $x + // + // If previousToken !== contextToken, then + // - 'contextToken' was adjusted to the token prior to 'previousToken' + // because we were at the end of an identifier. + // - 'previousToken' is defined. + var adjustedPosition = previousToken !== contextToken ? + previousToken.getStart() : + position; + var scopeNode = getScopeNode(contextToken, adjustedPosition, sourceFile) || sourceFile; + /// TODO filter meaning based on the current context + var symbolMeanings = 793056 /* Type */ | 107455 /* Value */ | 1536 /* Namespace */ | 8388608 /* Alias */; + symbols = typeChecker.getSymbolsInScope(scopeNode, symbolMeanings); + return true; + } + /** + * Finds the first node that "embraces" the position, so that one may + * accurately aggregate locals from the closest containing scope. + */ + function getScopeNode(initialToken, position, sourceFile) { + var scope = initialToken; + while (scope && !ts.positionBelongsToNode(scope, position, sourceFile)) { + scope = scope.parent; + } + return scope; + } + function isCompletionListBlocker(contextToken) { + var start = new Date().getTime(); + var result = isInStringOrRegularExpressionOrTemplateLiteral(contextToken) || + isSolelyIdentifierDefinitionLocation(contextToken) || + isDotOfNumericLiteral(contextToken) || + isInJsxText(contextToken); + log("getCompletionsAtPosition: isCompletionListBlocker: " + (new Date().getTime() - start)); + return result; + } + function isInJsxText(contextToken) { + if (contextToken.kind === 236 /* JsxText */) { + return true; + } + if (contextToken.kind === 27 /* GreaterThanToken */ && contextToken.parent) { + if (contextToken.parent.kind === 235 /* JsxOpeningElement */) { + return true; + } + if (contextToken.parent.kind === 237 /* JsxClosingElement */ || contextToken.parent.kind === 234 /* JsxSelfClosingElement */) { + return contextToken.parent.parent && contextToken.parent.parent.kind === 233 /* JsxElement */; + } + } + return false; + } + function isNewIdentifierDefinitionLocation(previousToken) { + if (previousToken) { + var containingNodeKind = previousToken.parent.kind; + switch (previousToken.kind) { + case 24 /* CommaToken */: + return containingNodeKind === 168 /* CallExpression */ // func( a, | + || containingNodeKind === 144 /* Constructor */ // constructor( a, | /* public, protected, private keywords are allowed here, so show completion */ + || containingNodeKind === 169 /* NewExpression */ // new C(a, | + || containingNodeKind === 164 /* ArrayLiteralExpression */ // [a, | + || containingNodeKind === 181 /* BinaryExpression */ // let x = (a, | + || containingNodeKind === 152 /* FunctionType */; // var x: (s: string, list| + case 17 /* OpenParenToken */: + return containingNodeKind === 168 /* CallExpression */ // func( | + || containingNodeKind === 144 /* Constructor */ // constructor( | + || containingNodeKind === 169 /* NewExpression */ // new C(a| + || containingNodeKind === 172 /* ParenthesizedExpression */ // let x = (a| + || containingNodeKind === 160 /* ParenthesizedType */; // function F(pred: (a| /* this can become an arrow function, where 'a' is the argument */ + case 19 /* OpenBracketToken */: + return containingNodeKind === 164 /* ArrayLiteralExpression */ // [ | + || containingNodeKind === 149 /* IndexSignature */ // [ | : string ] + || containingNodeKind === 136 /* ComputedPropertyName */; // [ | /* this can become an index signature */ + case 125 /* ModuleKeyword */: // module | + case 126 /* NamespaceKeyword */: + return true; + case 21 /* DotToken */: + return containingNodeKind === 218 /* ModuleDeclaration */; // module A.| + case 15 /* OpenBraceToken */: + return containingNodeKind === 214 /* ClassDeclaration */; // class A{ | + case 56 /* EqualsToken */: + return containingNodeKind === 211 /* VariableDeclaration */ // let x = a| + || containingNodeKind === 181 /* BinaryExpression */; // x = a| + case 12 /* TemplateHead */: + return containingNodeKind === 183 /* TemplateExpression */; // `aa ${| + case 13 /* TemplateMiddle */: + return containingNodeKind === 190 /* TemplateSpan */; // `aa ${10} dd ${| + case 112 /* PublicKeyword */: + case 110 /* PrivateKeyword */: + case 111 /* ProtectedKeyword */: + return containingNodeKind === 141 /* PropertyDeclaration */; // class A{ public | + } + // Previous token may have been a keyword that was converted to an identifier. + switch (previousToken.getText()) { + case "public": + case "protected": + case "private": + return true; + } + } + return false; + } + function isInStringOrRegularExpressionOrTemplateLiteral(contextToken) { + if (contextToken.kind === 9 /* StringLiteral */ + || contextToken.kind === 10 /* RegularExpressionLiteral */ + || ts.isTemplateLiteralKind(contextToken.kind)) { + var start_4 = contextToken.getStart(); + var end = contextToken.getEnd(); + // To be "in" one of these literals, the position has to be: + // 1. entirely within the token text. + // 2. at the end position of an unterminated token. + // 3. at the end of a regular expression (due to trailing flags like '/foo/g'). + if (start_4 < position && position < end) { + return true; + } + if (position === end) { + return !!contextToken.isUnterminated + || contextToken.kind === 10 /* RegularExpressionLiteral */; + } + } + return false; + } + /** + * Aggregates relevant symbols for completion in object literals and object binding patterns. + * Relevant symbols are stored in the captured 'symbols' variable. + * + * @returns true if 'symbols' was successfully populated; false otherwise. + */ + function tryGetObjectLikeCompletionSymbols(objectLikeContainer) { + // We're looking up possible property names from contextual/inferred/declared type. + isMemberCompletion = true; + var typeForObject; + var existingMembers; + if (objectLikeContainer.kind === 165 /* ObjectLiteralExpression */) { + // We are completing on contextual types, but may also include properties + // other than those within the declared type. + isNewIdentifierLocation = true; + typeForObject = typeChecker.getContextualType(objectLikeContainer); + existingMembers = objectLikeContainer.properties; + } + else if (objectLikeContainer.kind === 161 /* ObjectBindingPattern */) { + // We are *only* completing on properties from the type being destructured. + isNewIdentifierLocation = false; + var rootDeclaration = ts.getRootDeclaration(objectLikeContainer.parent); + if (ts.isVariableLike(rootDeclaration)) { + // We don't want to complete using the type acquired by the shape + // of the binding pattern; we are only interested in types acquired + // through type declaration or inference. + if (rootDeclaration.initializer || rootDeclaration.type) { + typeForObject = typeChecker.getTypeAtLocation(objectLikeContainer); + existingMembers = objectLikeContainer.elements; + } + } + else { + ts.Debug.fail("Root declaration is not variable-like."); + } + } + else { + ts.Debug.fail("Expected object literal or binding pattern, got " + objectLikeContainer.kind); + } + if (!typeForObject) { + return false; + } + var typeMembers = typeChecker.getPropertiesOfType(typeForObject); + if (typeMembers && typeMembers.length > 0) { + // Add filtered items to the completion list + symbols = filterObjectMembersList(typeMembers, existingMembers); + } + return true; + } + /** + * Aggregates relevant symbols for completion in import clauses and export clauses + * whose declarations have a module specifier; for instance, symbols will be aggregated for + * + * import { | } from "moduleName"; + * export { a as foo, | } from "moduleName"; + * + * but not for + * + * export { | }; + * + * Relevant symbols are stored in the captured 'symbols' variable. + * + * @returns true if 'symbols' was successfully populated; false otherwise. + */ + function tryGetImportOrExportClauseCompletionSymbols(namedImportsOrExports) { + var declarationKind = namedImportsOrExports.kind === 225 /* NamedImports */ ? + 222 /* ImportDeclaration */ : + 228 /* ExportDeclaration */; + var importOrExportDeclaration = ts.getAncestor(namedImportsOrExports, declarationKind); + var moduleSpecifier = importOrExportDeclaration.moduleSpecifier; + if (!moduleSpecifier) { + return false; + } + isMemberCompletion = true; + isNewIdentifierLocation = false; + var exports; + var moduleSpecifierSymbol = typeChecker.getSymbolAtLocation(importOrExportDeclaration.moduleSpecifier); + if (moduleSpecifierSymbol) { + exports = typeChecker.getExportsOfModule(moduleSpecifierSymbol); + } + symbols = exports ? filterNamedImportOrExportCompletionItems(exports, namedImportsOrExports.elements) : emptyArray; + return true; + } + /** + * Returns the immediate owning object literal or binding pattern of a context token, + * on the condition that one exists and that the context implies completion should be given. + */ + function tryGetObjectLikeCompletionContainer(contextToken) { + if (contextToken) { + switch (contextToken.kind) { + case 15 /* OpenBraceToken */: // let x = { | + case 24 /* CommaToken */: + var parent_10 = contextToken.parent; + if (parent_10 && (parent_10.kind === 165 /* ObjectLiteralExpression */ || parent_10.kind === 161 /* ObjectBindingPattern */)) { + return parent_10; + } + break; + } + } + return undefined; + } + /** + * Returns the containing list of named imports or exports of a context token, + * on the condition that one exists and that the context implies completion should be given. + */ + function tryGetNamedImportsOrExportsForCompletion(contextToken) { + if (contextToken) { + switch (contextToken.kind) { + case 15 /* OpenBraceToken */: // import { | + case 24 /* CommaToken */: + switch (contextToken.parent.kind) { + case 225 /* NamedImports */: + case 229 /* NamedExports */: + return contextToken.parent; + } + } + } + return undefined; + } + function tryGetContainingJsxElement(contextToken) { + if (contextToken) { + var parent_11 = contextToken.parent; + switch (contextToken.kind) { + case 26 /* LessThanSlashToken */: + case 39 /* SlashToken */: + case 69 /* Identifier */: + case 238 /* JsxAttribute */: + case 239 /* JsxSpreadAttribute */: + if (parent_11 && (parent_11.kind === 234 /* JsxSelfClosingElement */ || parent_11.kind === 235 /* JsxOpeningElement */)) { + return parent_11; + } + else if (parent_11.kind === 238 /* JsxAttribute */) { + return parent_11.parent; + } + break; + // The context token is the closing } or " of an attribute, which means + // its parent is a JsxExpression, whose parent is a JsxAttribute, + // whose parent is a JsxOpeningLikeElement + case 9 /* StringLiteral */: + if (parent_11 && ((parent_11.kind === 238 /* JsxAttribute */) || (parent_11.kind === 239 /* JsxSpreadAttribute */))) { + return parent_11.parent; + } + break; + case 16 /* CloseBraceToken */: + if (parent_11 && + parent_11.kind === 240 /* JsxExpression */ && + parent_11.parent && + (parent_11.parent.kind === 238 /* JsxAttribute */)) { + return parent_11.parent.parent; + } + if (parent_11 && parent_11.kind === 239 /* JsxSpreadAttribute */) { + return parent_11.parent; + } + break; + } + } + return undefined; + } + function isFunction(kind) { + switch (kind) { + case 173 /* FunctionExpression */: + case 174 /* ArrowFunction */: + case 213 /* FunctionDeclaration */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: + case 147 /* CallSignature */: + case 148 /* ConstructSignature */: + case 149 /* IndexSignature */: + return true; + } + return false; + } + /** + * @returns true if we are certain that the currently edited location must define a new location; false otherwise. + */ + function isSolelyIdentifierDefinitionLocation(contextToken) { + var containingNodeKind = contextToken.parent.kind; + switch (contextToken.kind) { + case 24 /* CommaToken */: + return containingNodeKind === 211 /* VariableDeclaration */ || + containingNodeKind === 212 /* VariableDeclarationList */ || + containingNodeKind === 193 /* VariableStatement */ || + containingNodeKind === 217 /* EnumDeclaration */ || + isFunction(containingNodeKind) || + containingNodeKind === 214 /* ClassDeclaration */ || + containingNodeKind === 186 /* ClassExpression */ || + containingNodeKind === 215 /* InterfaceDeclaration */ || + containingNodeKind === 162 /* ArrayBindingPattern */ || + containingNodeKind === 216 /* TypeAliasDeclaration */; // type Map, K, | + case 21 /* DotToken */: + return containingNodeKind === 162 /* ArrayBindingPattern */; // var [.| + case 54 /* ColonToken */: + return containingNodeKind === 163 /* BindingElement */; // var {x :html| + case 19 /* OpenBracketToken */: + return containingNodeKind === 162 /* ArrayBindingPattern */; // var [x| + case 17 /* OpenParenToken */: + return containingNodeKind === 244 /* CatchClause */ || + isFunction(containingNodeKind); + case 15 /* OpenBraceToken */: + return containingNodeKind === 217 /* EnumDeclaration */ || + containingNodeKind === 215 /* InterfaceDeclaration */ || + containingNodeKind === 155 /* TypeLiteral */; // let x : { | + case 23 /* SemicolonToken */: + return containingNodeKind === 140 /* PropertySignature */ && + contextToken.parent && contextToken.parent.parent && + (contextToken.parent.parent.kind === 215 /* InterfaceDeclaration */ || + contextToken.parent.parent.kind === 155 /* TypeLiteral */); // let x : { a; | + case 25 /* LessThanToken */: + return containingNodeKind === 214 /* ClassDeclaration */ || + containingNodeKind === 186 /* ClassExpression */ || + containingNodeKind === 215 /* InterfaceDeclaration */ || + containingNodeKind === 216 /* TypeAliasDeclaration */ || + isFunction(containingNodeKind); + case 113 /* StaticKeyword */: + return containingNodeKind === 141 /* PropertyDeclaration */; + case 22 /* DotDotDotToken */: + return containingNodeKind === 138 /* Parameter */ || + (contextToken.parent && contextToken.parent.parent && + contextToken.parent.parent.kind === 162 /* ArrayBindingPattern */); // var [...z| + case 112 /* PublicKeyword */: + case 110 /* PrivateKeyword */: + case 111 /* ProtectedKeyword */: + return containingNodeKind === 138 /* Parameter */; + case 116 /* AsKeyword */: + return containingNodeKind === 226 /* ImportSpecifier */ || + containingNodeKind === 230 /* ExportSpecifier */ || + containingNodeKind === 224 /* NamespaceImport */; + case 73 /* ClassKeyword */: + case 81 /* EnumKeyword */: + case 107 /* InterfaceKeyword */: + case 87 /* FunctionKeyword */: + case 102 /* VarKeyword */: + case 123 /* GetKeyword */: + case 129 /* SetKeyword */: + case 89 /* ImportKeyword */: + case 108 /* LetKeyword */: + case 74 /* ConstKeyword */: + case 114 /* YieldKeyword */: + case 132 /* TypeKeyword */: + return true; + } + // Previous token may have been a keyword that was converted to an identifier. + switch (contextToken.getText()) { + case "abstract": + case "async": + case "class": + case "const": + case "declare": + case "enum": + case "function": + case "interface": + case "let": + case "private": + case "protected": + case "public": + case "static": + case "var": + case "yield": + return true; + } + return false; + } + function isDotOfNumericLiteral(contextToken) { + if (contextToken.kind === 8 /* NumericLiteral */) { + var text = contextToken.getFullText(); + return text.charAt(text.length - 1) === "."; + } + return false; + } + /** + * Filters out completion suggestions for named imports or exports. + * + * @param exportsOfModule The list of symbols which a module exposes. + * @param namedImportsOrExports The list of existing import/export specifiers in the import/export clause. + * + * @returns Symbols to be suggested at an import/export clause, barring those whose named imports/exports + * do not occur at the current position and have not otherwise been typed. + */ + function filterNamedImportOrExportCompletionItems(exportsOfModule, namedImportsOrExports) { + var exisingImportsOrExports = {}; + for (var _i = 0; _i < namedImportsOrExports.length; _i++) { + var element = namedImportsOrExports[_i]; + // If this is the current item we are editing right now, do not filter it out + if (element.getStart() <= position && position <= element.getEnd()) { + continue; + } + var name_33 = element.propertyName || element.name; + exisingImportsOrExports[name_33.text] = true; + } + if (ts.isEmpty(exisingImportsOrExports)) { + return exportsOfModule; + } + return ts.filter(exportsOfModule, function (e) { return !ts.lookUp(exisingImportsOrExports, e.name); }); + } + /** + * Filters out completion suggestions for named imports or exports. + * + * @returns Symbols to be suggested in an object binding pattern or object literal expression, barring those whose declarations + * do not occur at the current position and have not otherwise been typed. + */ + function filterObjectMembersList(contextualMemberSymbols, existingMembers) { + if (!existingMembers || existingMembers.length === 0) { + return contextualMemberSymbols; + } + var existingMemberNames = {}; + for (var _i = 0; _i < existingMembers.length; _i++) { + var m = existingMembers[_i]; + // Ignore omitted expressions for missing members + if (m.kind !== 245 /* PropertyAssignment */ && + m.kind !== 246 /* ShorthandPropertyAssignment */ && + m.kind !== 163 /* BindingElement */) { + continue; + } + // If this is the current item we are editing right now, do not filter it out + if (m.getStart() <= position && position <= m.getEnd()) { + continue; + } + var existingName = void 0; + if (m.kind === 163 /* BindingElement */ && m.propertyName) { + existingName = m.propertyName.text; + } + else { + // TODO(jfreeman): Account for computed property name + // NOTE: if one only performs this step when m.name is an identifier, + // things like '__proto__' are not filtered out. + existingName = m.name.text; + } + existingMemberNames[existingName] = true; + } + return ts.filter(contextualMemberSymbols, function (m) { return !ts.lookUp(existingMemberNames, m.name); }); + } + /** + * Filters out completion suggestions from 'symbols' according to existing JSX attributes. + * + * @returns Symbols to be suggested in a JSX element, barring those whose attributes + * do not occur at the current position and have not otherwise been typed. + */ + function filterJsxAttributes(symbols, attributes) { + var seenNames = {}; + for (var _i = 0; _i < attributes.length; _i++) { + var attr = attributes[_i]; + // If this is the current item we are editing right now, do not filter it out + if (attr.getStart() <= position && position <= attr.getEnd()) { + continue; + } + if (attr.kind === 238 /* JsxAttribute */) { + seenNames[attr.name.text] = true; + } + } + return ts.filter(symbols, function (a) { return !ts.lookUp(seenNames, a.name); }); + } + } + function getCompletionsAtPosition(fileName, position) { + synchronizeHostData(); + var completionData = getCompletionData(fileName, position); + if (!completionData) { + return undefined; + } + var symbols = completionData.symbols, isMemberCompletion = completionData.isMemberCompletion, isNewIdentifierLocation = completionData.isNewIdentifierLocation, location = completionData.location, isRightOfDot = completionData.isRightOfDot, isJsDocTagName = completionData.isJsDocTagName; + var entries; + if (isJsDocTagName) { + // If the current position is a jsDoc tag name, only tag names should be provided for completion + return { isMemberCompletion: false, isNewIdentifierLocation: false, entries: getAllJsDocCompletionEntries() }; + } + if (isRightOfDot && ts.isJavaScript(fileName)) { + entries = getCompletionEntriesFromSymbols(symbols); + ts.addRange(entries, getJavaScriptCompletionEntries()); + } + else { + if (!symbols || symbols.length === 0) { + return undefined; + } + entries = getCompletionEntriesFromSymbols(symbols); + } + // Add keywords if this is not a member completion list + if (!isMemberCompletion && !isJsDocTagName) { + ts.addRange(entries, keywordCompletions); + } + return { isMemberCompletion: isMemberCompletion, isNewIdentifierLocation: isNewIdentifierLocation, entries: entries }; + function getJavaScriptCompletionEntries() { + var entries = []; + var allNames = {}; + var target = program.getCompilerOptions().target; + for (var _i = 0, _a = program.getSourceFiles(); _i < _a.length; _i++) { + var sourceFile = _a[_i]; + var nameTable = getNameTable(sourceFile); + for (var name_34 in nameTable) { + if (!allNames[name_34]) { + allNames[name_34] = name_34; + var displayName = getCompletionEntryDisplayName(name_34, target, /*performCharacterChecks:*/ true); + if (displayName) { + var entry = { + name: displayName, + kind: ScriptElementKind.warning, + kindModifiers: "", + sortText: "1" + }; + entries.push(entry); + } + } + } + } + return entries; + } + function getAllJsDocCompletionEntries() { + return jsDocCompletionEntries || (jsDocCompletionEntries = ts.map(jsDocTagNames, function (tagName) { + return { + name: tagName, + kind: ScriptElementKind.keyword, + kindModifiers: "", + sortText: "0" + }; + })); + } + function createCompletionEntry(symbol, location) { + // Try to get a valid display name for this symbol, if we could not find one, then ignore it. + // We would like to only show things that can be added after a dot, so for instance numeric properties can + // not be accessed with a dot (a.1 <- invalid) + var displayName = getCompletionEntryDisplayNameForSymbol(symbol, program.getCompilerOptions().target, /*performCharacterChecks:*/ true, location); + if (!displayName) { + return undefined; + } + // TODO(drosen): Right now we just permit *all* semantic meanings when calling + // 'getSymbolKind' which is permissible given that it is backwards compatible; but + // really we should consider passing the meaning for the node so that we don't report + // that a suggestion for a value is an interface. We COULD also just do what + // 'getSymbolModifiers' does, which is to use the first declaration. + // Use a 'sortText' of 0' so that all symbol completion entries come before any other + // entries (like JavaScript identifier entries). + return { + name: displayName, + kind: getSymbolKind(symbol, location), + kindModifiers: getSymbolModifiers(symbol), + sortText: "0" + }; + } + function getCompletionEntriesFromSymbols(symbols) { + var start = new Date().getTime(); + var entries = []; + if (symbols) { + var nameToSymbol = {}; + for (var _i = 0; _i < symbols.length; _i++) { + var symbol = symbols[_i]; + var entry = createCompletionEntry(symbol, location); + if (entry) { + var id = ts.escapeIdentifier(entry.name); + if (!ts.lookUp(nameToSymbol, id)) { + entries.push(entry); + nameToSymbol[id] = symbol; + } + } + } + } + log("getCompletionsAtPosition: getCompletionEntriesFromSymbols: " + (new Date().getTime() - start)); + return entries; + } + } + function getCompletionEntryDetails(fileName, position, entryName) { + synchronizeHostData(); + // Compute all the completion symbols again. + var completionData = getCompletionData(fileName, position); + if (completionData) { + var symbols = completionData.symbols, location_2 = completionData.location; + // Find the symbol with the matching entry name. + var target = program.getCompilerOptions().target; + // We don't need to perform character checks here because we're only comparing the + // name against 'entryName' (which is known to be good), not building a new + // completion entry. + var symbol = ts.forEach(symbols, function (s) { return getCompletionEntryDisplayNameForSymbol(s, target, /*performCharacterChecks:*/ false, location_2) === entryName ? s : undefined; }); + if (symbol) { + var _a = getSymbolDisplayPartsDocumentationAndSymbolKind(symbol, getValidSourceFile(fileName), location_2, location_2, 7 /* All */), displayParts = _a.displayParts, documentation = _a.documentation, symbolKind = _a.symbolKind; + return { + name: entryName, + kindModifiers: getSymbolModifiers(symbol), + kind: symbolKind, + displayParts: displayParts, + documentation: documentation + }; + } + } + // Didn't find a symbol with this name. See if we can find a keyword instead. + var keywordCompletion = ts.forEach(keywordCompletions, function (c) { return c.name === entryName; }); + if (keywordCompletion) { + return { + name: entryName, + kind: ScriptElementKind.keyword, + kindModifiers: ScriptElementKindModifier.none, + displayParts: [ts.displayPart(entryName, SymbolDisplayPartKind.keyword)], + documentation: undefined + }; + } + return undefined; + } + // TODO(drosen): use contextual SemanticMeaning. + function getSymbolKind(symbol, location) { + var flags = symbol.getFlags(); + if (flags & 32 /* Class */) + return ts.getDeclarationOfKind(symbol, 186 /* ClassExpression */) ? + ScriptElementKind.localClassElement : ScriptElementKind.classElement; + if (flags & 384 /* Enum */) + return ScriptElementKind.enumElement; + if (flags & 524288 /* TypeAlias */) + return ScriptElementKind.typeElement; + if (flags & 64 /* Interface */) + return ScriptElementKind.interfaceElement; + if (flags & 262144 /* TypeParameter */) + return ScriptElementKind.typeParameterElement; + var result = getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar(symbol, flags, location); + if (result === ScriptElementKind.unknown) { + if (flags & 262144 /* TypeParameter */) + return ScriptElementKind.typeParameterElement; + if (flags & 8 /* EnumMember */) + return ScriptElementKind.variableElement; + if (flags & 8388608 /* Alias */) + return ScriptElementKind.alias; + if (flags & 1536 /* Module */) + return ScriptElementKind.moduleElement; + } + return result; + } + function getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar(symbol, flags, location) { + var typeChecker = program.getTypeChecker(); + if (typeChecker.isUndefinedSymbol(symbol)) { + return ScriptElementKind.variableElement; + } + if (typeChecker.isArgumentsSymbol(symbol)) { + return ScriptElementKind.localVariableElement; + } + if (flags & 3 /* Variable */) { + if (ts.isFirstDeclarationOfSymbolParameter(symbol)) { + return ScriptElementKind.parameterElement; + } + else if (symbol.valueDeclaration && ts.isConst(symbol.valueDeclaration)) { + return ScriptElementKind.constElement; + } + else if (ts.forEach(symbol.declarations, ts.isLet)) { + return ScriptElementKind.letElement; + } + return isLocalVariableOrFunction(symbol) ? ScriptElementKind.localVariableElement : ScriptElementKind.variableElement; + } + if (flags & 16 /* Function */) + return isLocalVariableOrFunction(symbol) ? ScriptElementKind.localFunctionElement : ScriptElementKind.functionElement; + if (flags & 32768 /* GetAccessor */) + return ScriptElementKind.memberGetAccessorElement; + if (flags & 65536 /* SetAccessor */) + return ScriptElementKind.memberSetAccessorElement; + if (flags & 8192 /* Method */) + return ScriptElementKind.memberFunctionElement; + if (flags & 16384 /* Constructor */) + return ScriptElementKind.constructorImplementationElement; + if (flags & 4 /* Property */) { + if (flags & 268435456 /* SyntheticProperty */) { + // If union property is result of union of non method (property/accessors/variables), it is labeled as property + var unionPropertyKind = ts.forEach(typeChecker.getRootSymbols(symbol), function (rootSymbol) { + var rootSymbolFlags = rootSymbol.getFlags(); + if (rootSymbolFlags & (98308 /* PropertyOrAccessor */ | 3 /* Variable */)) { + return ScriptElementKind.memberVariableElement; + } + ts.Debug.assert(!!(rootSymbolFlags & 8192 /* Method */)); + }); + if (!unionPropertyKind) { + // If this was union of all methods, + //make sure it has call signatures before we can label it as method + var typeOfUnionProperty = typeChecker.getTypeOfSymbolAtLocation(symbol, location); + if (typeOfUnionProperty.getCallSignatures().length) { + return ScriptElementKind.memberFunctionElement; + } + return ScriptElementKind.memberVariableElement; + } + return unionPropertyKind; + } + return ScriptElementKind.memberVariableElement; + } + return ScriptElementKind.unknown; + } + function getSymbolModifiers(symbol) { + return symbol && symbol.declarations && symbol.declarations.length > 0 + ? ts.getNodeModifiers(symbol.declarations[0]) + : ScriptElementKindModifier.none; + } + // TODO(drosen): Currently completion entry details passes the SemanticMeaning.All instead of using semanticMeaning of location + function getSymbolDisplayPartsDocumentationAndSymbolKind(symbol, sourceFile, enclosingDeclaration, location, semanticMeaning) { + if (semanticMeaning === void 0) { semanticMeaning = getMeaningFromLocation(location); } + var typeChecker = program.getTypeChecker(); + var displayParts = []; + var documentation; + var symbolFlags = symbol.flags; + var symbolKind = getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar(symbol, symbolFlags, location); + var hasAddedSymbolInfo; + var type; + // Class at constructor site need to be shown as constructor apart from property,method, vars + if (symbolKind !== ScriptElementKind.unknown || symbolFlags & 32 /* Class */ || symbolFlags & 8388608 /* Alias */) { + // If it is accessor they are allowed only if location is at name of the accessor + if (symbolKind === ScriptElementKind.memberGetAccessorElement || symbolKind === ScriptElementKind.memberSetAccessorElement) { + symbolKind = ScriptElementKind.memberVariableElement; + } + var signature; + type = typeChecker.getTypeOfSymbolAtLocation(symbol, location); + if (type) { + if (location.parent && location.parent.kind === 166 /* PropertyAccessExpression */) { + var right = location.parent.name; + // Either the location is on the right of a property access, or on the left and the right is missing + if (right === location || (right && right.getFullWidth() === 0)) { + location = location.parent; + } + } + // try get the call/construct signature from the type if it matches + var callExpression; + if (location.kind === 168 /* CallExpression */ || location.kind === 169 /* NewExpression */) { + callExpression = location; + } + else if (isCallExpressionTarget(location) || isNewExpressionTarget(location)) { + callExpression = location.parent; + } + if (callExpression) { + var candidateSignatures = []; + signature = typeChecker.getResolvedSignature(callExpression, candidateSignatures); + if (!signature && candidateSignatures.length) { + // Use the first candidate: + signature = candidateSignatures[0]; + } + var useConstructSignatures = callExpression.kind === 169 /* NewExpression */ || callExpression.expression.kind === 95 /* 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 + // either the original signature or its target, so check for either + signature = allSignatures.length ? allSignatures[0] : undefined; + } + if (signature) { + if (useConstructSignatures && (symbolFlags & 32 /* Class */)) { + // Constructor + symbolKind = ScriptElementKind.constructorImplementationElement; + addPrefixForAnyFunctionOrVar(type.symbol, symbolKind); + } + else if (symbolFlags & 8388608 /* Alias */) { + symbolKind = ScriptElementKind.alias; + pushTypePart(symbolKind); + displayParts.push(ts.spacePart()); + if (useConstructSignatures) { + displayParts.push(ts.keywordPart(92 /* NewKeyword */)); + displayParts.push(ts.spacePart()); + } + addFullSymbolName(symbol); + } + else { + addPrefixForAnyFunctionOrVar(symbol, symbolKind); + } + switch (symbolKind) { + case ScriptElementKind.memberVariableElement: + case ScriptElementKind.variableElement: + case ScriptElementKind.constElement: + case ScriptElementKind.letElement: + case ScriptElementKind.parameterElement: + case ScriptElementKind.localVariableElement: + // If it is call or construct signature of lambda's write type name + displayParts.push(ts.punctuationPart(54 /* ColonToken */)); + displayParts.push(ts.spacePart()); + if (useConstructSignatures) { + displayParts.push(ts.keywordPart(92 /* NewKeyword */)); + displayParts.push(ts.spacePart()); + } + if (!(type.flags & 65536 /* Anonymous */)) { + ts.addRange(displayParts, ts.symbolToDisplayParts(typeChecker, type.symbol, enclosingDeclaration, /*meaning*/ undefined, 1 /* WriteTypeParametersOrArguments */)); + } + addSignatureDisplayParts(signature, allSignatures, 8 /* WriteArrowStyleSignature */); + break; + default: + // Just signature + addSignatureDisplayParts(signature, allSignatures); + } + hasAddedSymbolInfo = true; + } + } + else if ((isNameOfFunctionDeclaration(location) && !(symbol.flags & 98304 /* Accessor */)) || + (location.kind === 121 /* ConstructorKeyword */ && location.parent.kind === 144 /* Constructor */)) { + // get the signature from the declaration and write it + var functionDeclaration = location.parent; + var allSignatures = functionDeclaration.kind === 144 /* Constructor */ ? type.getConstructSignatures() : type.getCallSignatures(); + if (!typeChecker.isImplementationOfOverload(functionDeclaration)) { + signature = typeChecker.getSignatureFromDeclaration(functionDeclaration); + } + else { + signature = allSignatures[0]; + } + if (functionDeclaration.kind === 144 /* Constructor */) { + // show (constructor) Type(...) signature + symbolKind = ScriptElementKind.constructorImplementationElement; + addPrefixForAnyFunctionOrVar(type.symbol, symbolKind); + } + else { + // (function/method) symbol(..signature) + addPrefixForAnyFunctionOrVar(functionDeclaration.kind === 147 /* CallSignature */ && + !(type.symbol.flags & 2048 /* TypeLiteral */ || type.symbol.flags & 4096 /* ObjectLiteral */) ? type.symbol : symbol, symbolKind); + } + addSignatureDisplayParts(signature, allSignatures); + hasAddedSymbolInfo = true; + } + } + } + if (symbolFlags & 32 /* Class */ && !hasAddedSymbolInfo) { + if (ts.getDeclarationOfKind(symbol, 186 /* ClassExpression */)) { + // Special case for class expressions because we would like to indicate that + // the class name is local to the class body (similar to function expression) + // (local class) class + pushTypePart(ScriptElementKind.localClassElement); + } + else { + // Class declaration has name which is not local. + displayParts.push(ts.keywordPart(73 /* ClassKeyword */)); + } + displayParts.push(ts.spacePart()); + addFullSymbolName(symbol); + writeTypeParametersOfSymbol(symbol, sourceFile); + } + if ((symbolFlags & 64 /* Interface */) && (semanticMeaning & 2 /* Type */)) { + addNewLineIfDisplayPartsExist(); + displayParts.push(ts.keywordPart(107 /* InterfaceKeyword */)); + displayParts.push(ts.spacePart()); + addFullSymbolName(symbol); + writeTypeParametersOfSymbol(symbol, sourceFile); + } + if (symbolFlags & 524288 /* TypeAlias */) { + addNewLineIfDisplayPartsExist(); + displayParts.push(ts.keywordPart(132 /* TypeKeyword */)); + displayParts.push(ts.spacePart()); + addFullSymbolName(symbol); + writeTypeParametersOfSymbol(symbol, sourceFile); + displayParts.push(ts.spacePart()); + displayParts.push(ts.operatorPart(56 /* EqualsToken */)); + displayParts.push(ts.spacePart()); + ts.addRange(displayParts, ts.typeToDisplayParts(typeChecker, typeChecker.getDeclaredTypeOfSymbol(symbol), enclosingDeclaration)); + } + if (symbolFlags & 384 /* Enum */) { + addNewLineIfDisplayPartsExist(); + if (ts.forEach(symbol.declarations, ts.isConstEnumDeclaration)) { + displayParts.push(ts.keywordPart(74 /* ConstKeyword */)); + displayParts.push(ts.spacePart()); + } + displayParts.push(ts.keywordPart(81 /* EnumKeyword */)); + displayParts.push(ts.spacePart()); + addFullSymbolName(symbol); + } + if (symbolFlags & 1536 /* Module */) { + addNewLineIfDisplayPartsExist(); + var declaration = ts.getDeclarationOfKind(symbol, 218 /* ModuleDeclaration */); + var isNamespace = declaration && declaration.name && declaration.name.kind === 69 /* Identifier */; + displayParts.push(ts.keywordPart(isNamespace ? 126 /* NamespaceKeyword */ : 125 /* ModuleKeyword */)); + displayParts.push(ts.spacePart()); + addFullSymbolName(symbol); + } + if ((symbolFlags & 262144 /* TypeParameter */) && (semanticMeaning & 2 /* Type */)) { + addNewLineIfDisplayPartsExist(); + displayParts.push(ts.punctuationPart(17 /* OpenParenToken */)); + displayParts.push(ts.textPart("type parameter")); + displayParts.push(ts.punctuationPart(18 /* CloseParenToken */)); + displayParts.push(ts.spacePart()); + addFullSymbolName(symbol); + displayParts.push(ts.spacePart()); + displayParts.push(ts.keywordPart(90 /* InKeyword */)); + displayParts.push(ts.spacePart()); + if (symbol.parent) { + // Class/Interface type parameter + addFullSymbolName(symbol.parent, enclosingDeclaration); + writeTypeParametersOfSymbol(symbol.parent, enclosingDeclaration); + } + else { + // Method/function type parameter + var container = ts.getContainingFunction(location); + if (container) { + var signatureDeclaration = ts.getDeclarationOfKind(symbol, 137 /* TypeParameter */).parent; + var signature = typeChecker.getSignatureFromDeclaration(signatureDeclaration); + if (signatureDeclaration.kind === 148 /* ConstructSignature */) { + displayParts.push(ts.keywordPart(92 /* NewKeyword */)); + displayParts.push(ts.spacePart()); + } + else if (signatureDeclaration.kind !== 147 /* CallSignature */ && signatureDeclaration.name) { + addFullSymbolName(signatureDeclaration.symbol); + } + ts.addRange(displayParts, ts.signatureToDisplayParts(typeChecker, signature, sourceFile, 32 /* WriteTypeArgumentsOfSignature */)); + } + else { + // Type aliash type parameter + // For example + // type list = T[]; // Both T will go through same code path + var declaration = ts.getDeclarationOfKind(symbol, 137 /* TypeParameter */).parent; + displayParts.push(ts.keywordPart(132 /* TypeKeyword */)); + displayParts.push(ts.spacePart()); + addFullSymbolName(declaration.symbol); + writeTypeParametersOfSymbol(declaration.symbol, sourceFile); + } + } + } + if (symbolFlags & 8 /* EnumMember */) { + addPrefixForAnyFunctionOrVar(symbol, "enum member"); + var declaration = symbol.declarations[0]; + if (declaration.kind === 247 /* EnumMember */) { + var constantValue = typeChecker.getConstantValue(declaration); + if (constantValue !== undefined) { + displayParts.push(ts.spacePart()); + displayParts.push(ts.operatorPart(56 /* EqualsToken */)); + displayParts.push(ts.spacePart()); + displayParts.push(ts.displayPart(constantValue.toString(), SymbolDisplayPartKind.numericLiteral)); + } + } + } + if (symbolFlags & 8388608 /* Alias */) { + addNewLineIfDisplayPartsExist(); + displayParts.push(ts.keywordPart(89 /* ImportKeyword */)); + displayParts.push(ts.spacePart()); + addFullSymbolName(symbol); + ts.forEach(symbol.declarations, function (declaration) { + if (declaration.kind === 221 /* ImportEqualsDeclaration */) { + var importEqualsDeclaration = declaration; + if (ts.isExternalModuleImportEqualsDeclaration(importEqualsDeclaration)) { + displayParts.push(ts.spacePart()); + displayParts.push(ts.operatorPart(56 /* EqualsToken */)); + displayParts.push(ts.spacePart()); + displayParts.push(ts.keywordPart(127 /* RequireKeyword */)); + displayParts.push(ts.punctuationPart(17 /* OpenParenToken */)); + displayParts.push(ts.displayPart(ts.getTextOfNode(ts.getExternalModuleImportEqualsDeclarationExpression(importEqualsDeclaration)), SymbolDisplayPartKind.stringLiteral)); + displayParts.push(ts.punctuationPart(18 /* CloseParenToken */)); + } + else { + var internalAliasSymbol = typeChecker.getSymbolAtLocation(importEqualsDeclaration.moduleReference); + if (internalAliasSymbol) { + displayParts.push(ts.spacePart()); + displayParts.push(ts.operatorPart(56 /* EqualsToken */)); + displayParts.push(ts.spacePart()); + addFullSymbolName(internalAliasSymbol, enclosingDeclaration); + } + } + return true; + } + }); + } + if (!hasAddedSymbolInfo) { + if (symbolKind !== ScriptElementKind.unknown) { + if (type) { + addPrefixForAnyFunctionOrVar(symbol, symbolKind); + // For properties, variables and local vars: show the type + if (symbolKind === ScriptElementKind.memberVariableElement || + symbolFlags & 3 /* Variable */ || + symbolKind === ScriptElementKind.localVariableElement) { + displayParts.push(ts.punctuationPart(54 /* ColonToken */)); + displayParts.push(ts.spacePart()); + // If the type is type parameter, format it specially + if (type.symbol && type.symbol.flags & 262144 /* TypeParameter */) { + var typeParameterParts = ts.mapToDisplayParts(function (writer) { + typeChecker.getSymbolDisplayBuilder().buildTypeParameterDisplay(type, writer, enclosingDeclaration); + }); + ts.addRange(displayParts, typeParameterParts); + } + else { + ts.addRange(displayParts, ts.typeToDisplayParts(typeChecker, type, enclosingDeclaration)); + } + } + else if (symbolFlags & 16 /* Function */ || + symbolFlags & 8192 /* Method */ || + symbolFlags & 16384 /* Constructor */ || + symbolFlags & 131072 /* Signature */ || + symbolFlags & 98304 /* Accessor */ || + symbolKind === ScriptElementKind.memberFunctionElement) { + var allSignatures = type.getCallSignatures(); + addSignatureDisplayParts(allSignatures[0], allSignatures); + } + } + } + else { + symbolKind = getSymbolKind(symbol, location); + } + } + if (!documentation) { + documentation = symbol.getDocumentationComment(); + } + return { displayParts: displayParts, documentation: documentation, symbolKind: symbolKind }; + function addNewLineIfDisplayPartsExist() { + if (displayParts.length) { + displayParts.push(ts.lineBreakPart()); + } + } + function addFullSymbolName(symbol, enclosingDeclaration) { + var fullSymbolDisplayParts = ts.symbolToDisplayParts(typeChecker, symbol, enclosingDeclaration || sourceFile, /*meaning*/ undefined, 1 /* WriteTypeParametersOrArguments */ | 2 /* UseOnlyExternalAliasing */); + ts.addRange(displayParts, fullSymbolDisplayParts); + } + function addPrefixForAnyFunctionOrVar(symbol, symbolKind) { + addNewLineIfDisplayPartsExist(); + if (symbolKind) { + pushTypePart(symbolKind); + displayParts.push(ts.spacePart()); + addFullSymbolName(symbol); + } + } + function pushTypePart(symbolKind) { + switch (symbolKind) { + case ScriptElementKind.variableElement: + case ScriptElementKind.functionElement: + case ScriptElementKind.letElement: + case ScriptElementKind.constElement: + case ScriptElementKind.constructorImplementationElement: + displayParts.push(ts.textOrKeywordPart(symbolKind)); + return; + default: + displayParts.push(ts.punctuationPart(17 /* OpenParenToken */)); + displayParts.push(ts.textOrKeywordPart(symbolKind)); + displayParts.push(ts.punctuationPart(18 /* CloseParenToken */)); + return; + } + } + function addSignatureDisplayParts(signature, allSignatures, flags) { + 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.displayPart((allSignatures.length - 1).toString(), SymbolDisplayPartKind.numericLiteral)); + displayParts.push(ts.spacePart()); + displayParts.push(ts.textPart(allSignatures.length === 2 ? "overload" : "overloads")); + displayParts.push(ts.punctuationPart(18 /* CloseParenToken */)); + } + documentation = signature.getDocumentationComment(); + } + function writeTypeParametersOfSymbol(symbol, enclosingDeclaration) { + var typeParameterParts = ts.mapToDisplayParts(function (writer) { + typeChecker.getSymbolDisplayBuilder().buildTypeParameterDisplayFromSymbol(symbol, writer, enclosingDeclaration); + }); + ts.addRange(displayParts, typeParameterParts); + } + } + function getQuickInfoAtPosition(fileName, position) { + synchronizeHostData(); + var sourceFile = getValidSourceFile(fileName); + var node = ts.getTouchingPropertyName(sourceFile, position); + if (!node) { + return undefined; + } + if (isLabelName(node)) { + return undefined; + } + var typeChecker = program.getTypeChecker(); + var symbol = typeChecker.getSymbolAtLocation(node); + if (!symbol) { + // Try getting just type at this position and show + switch (node.kind) { + case 69 /* Identifier */: + case 166 /* PropertyAccessExpression */: + case 135 /* QualifiedName */: + case 97 /* ThisKeyword */: + case 95 /* SuperKeyword */: + // For the identifiers/this/super etc get the type at position + var type = typeChecker.getTypeAtLocation(node); + if (type) { + return { + kind: ScriptElementKind.unknown, + kindModifiers: ScriptElementKindModifier.none, + textSpan: ts.createTextSpan(node.getStart(), node.getWidth()), + displayParts: ts.typeToDisplayParts(typeChecker, type, getContainerNode(node)), + documentation: type.symbol ? type.symbol.getDocumentationComment() : undefined + }; + } + } + return undefined; + } + var displayPartsDocumentationsAndKind = getSymbolDisplayPartsDocumentationAndSymbolKind(symbol, sourceFile, getContainerNode(node), node); + return { + kind: displayPartsDocumentationsAndKind.symbolKind, + kindModifiers: getSymbolModifiers(symbol), + textSpan: ts.createTextSpan(node.getStart(), node.getWidth()), + displayParts: displayPartsDocumentationsAndKind.displayParts, + documentation: displayPartsDocumentationsAndKind.documentation + }; + } + function createDefinitionInfo(node, symbolKind, symbolName, containerName) { + return { + fileName: node.getSourceFile().fileName, + textSpan: ts.createTextSpanFromBounds(node.getStart(), node.getEnd()), + kind: symbolKind, + name: symbolName, + containerKind: undefined, + containerName: containerName + }; + } + function getDefinitionFromSymbol(symbol, node) { + var typeChecker = program.getTypeChecker(); + var result = []; + var declarations = symbol.getDeclarations(); + var symbolName = typeChecker.symbolToString(symbol); // Do not get scoped name, just the name of the symbol + var symbolKind = getSymbolKind(symbol, node); + var containerSymbol = symbol.parent; + var containerName = containerSymbol ? typeChecker.symbolToString(containerSymbol, node) : ""; + if (!tryAddConstructSignature(symbol, node, symbolKind, symbolName, containerName, result) && + !tryAddCallSignature(symbol, node, symbolKind, symbolName, containerName, result)) { + // Just add all the declarations. + ts.forEach(declarations, function (declaration) { + result.push(createDefinitionInfo(declaration, symbolKind, symbolName, containerName)); + }); + } + return result; + function tryAddConstructSignature(symbol, location, symbolKind, symbolName, containerName, result) { + // Applicable only if we are in a new expression, or we are on a constructor declaration + // and in either case the symbol has a construct signature definition, i.e. class + if (isNewExpressionTarget(location) || location.kind === 121 /* ConstructorKeyword */) { + if (symbol.flags & 32 /* Class */) { + // Find the first class-like declaration and try to get the construct signature. + for (var _i = 0, _a = symbol.getDeclarations(); _i < _a.length; _i++) { + var declaration = _a[_i]; + if (ts.isClassLike(declaration)) { + return tryAddSignature(declaration.members, + /*selectConstructors*/ true, symbolKind, symbolName, containerName, result); + } + } + ts.Debug.fail("Expected declaration to have at least one class-like declaration"); + } + } + return false; + } + function tryAddCallSignature(symbol, location, symbolKind, symbolName, containerName, result) { + if (isCallExpressionTarget(location) || isNewExpressionTarget(location) || isNameOfFunctionDeclaration(location)) { + return tryAddSignature(symbol.declarations, /*selectConstructors*/ false, symbolKind, symbolName, containerName, result); + } + return false; + } + function tryAddSignature(signatureDeclarations, selectConstructors, symbolKind, symbolName, containerName, result) { + var declarations = []; + var definition; + ts.forEach(signatureDeclarations, function (d) { + if ((selectConstructors && d.kind === 144 /* Constructor */) || + (!selectConstructors && (d.kind === 213 /* FunctionDeclaration */ || d.kind === 143 /* MethodDeclaration */ || d.kind === 142 /* MethodSignature */))) { + declarations.push(d); + if (d.body) + definition = d; + } + }); + if (definition) { + result.push(createDefinitionInfo(definition, symbolKind, symbolName, containerName)); + return true; + } + else if (declarations.length) { + result.push(createDefinitionInfo(ts.lastOrUndefined(declarations), symbolKind, symbolName, containerName)); + return true; + } + return false; + } + } + /// Goto definition + function getDefinitionAtPosition(fileName, position) { + synchronizeHostData(); + var sourceFile = getValidSourceFile(fileName); + var node = ts.getTouchingPropertyName(sourceFile, position); + if (!node) { + return undefined; + } + // Labels + if (isJumpStatementTarget(node)) { + var labelName = node.text; + var label = getTargetLabel(node.parent, node.text); + return label ? [createDefinitionInfo(label, ScriptElementKind.label, labelName, /*containerName*/ undefined)] : undefined; + } + /// Triple slash reference comments + var comment = ts.forEach(sourceFile.referencedFiles, function (r) { return (r.pos <= position && position < r.end) ? r : undefined; }); + if (comment) { + var referenceFile = ts.tryResolveScriptReference(program, sourceFile, comment); + if (referenceFile) { + return [{ + fileName: referenceFile.fileName, + textSpan: ts.createTextSpanFromBounds(0, 0), + kind: ScriptElementKind.scriptElement, + name: comment.fileName, + containerName: undefined, + containerKind: undefined + }]; + } + return undefined; + } + var typeChecker = program.getTypeChecker(); + var symbol = typeChecker.getSymbolAtLocation(node); + // Could not find a symbol e.g. node is string or number keyword, + // or the symbol was an internal symbol and does not have a declaration e.g. undefined symbol + if (!symbol) { + return undefined; + } + // If this is an alias, and the request came at the declaration location + // get the aliased symbol instead. This allows for goto def on an import e.g. + // import {A, B} from "mod"; + // to jump to the implementation directly. + if (symbol.flags & 8388608 /* Alias */) { + var declaration = symbol.declarations[0]; + if (node.kind === 69 /* Identifier */ && node.parent === declaration) { + symbol = typeChecker.getAliasedSymbol(symbol); + } + } + // Because name in short-hand property assignment has two different meanings: property name and property value, + // using go-to-definition at such position should go to the variable declaration of the property value rather than + // go to the declaration of the property name (in this case stay at the same position). However, if go-to-definition + // is performed at the location of property access, we would like to go to definition of the property in the short-hand + // assignment. This case and others are handled by the following code. + if (node.parent.kind === 246 /* ShorthandPropertyAssignment */) { + var shorthandSymbol = typeChecker.getShorthandAssignmentValueSymbol(symbol.valueDeclaration); + if (!shorthandSymbol) { + return []; + } + var shorthandDeclarations = shorthandSymbol.getDeclarations(); + var shorthandSymbolKind = getSymbolKind(shorthandSymbol, node); + var shorthandSymbolName = typeChecker.symbolToString(shorthandSymbol); + var shorthandContainerName = typeChecker.symbolToString(symbol.parent, node); + return ts.map(shorthandDeclarations, function (declaration) { return createDefinitionInfo(declaration, shorthandSymbolKind, shorthandSymbolName, shorthandContainerName); }); + } + return getDefinitionFromSymbol(symbol, node); + } + /// Goto type + function getTypeDefinitionAtPosition(fileName, position) { + synchronizeHostData(); + var sourceFile = getValidSourceFile(fileName); + var node = ts.getTouchingPropertyName(sourceFile, position); + if (!node) { + return undefined; + } + var typeChecker = program.getTypeChecker(); + var symbol = typeChecker.getSymbolAtLocation(node); + if (!symbol) { + return undefined; + } + var type = typeChecker.getTypeOfSymbolAtLocation(symbol, node); + if (!type) { + return undefined; + } + if (type.flags & 16384 /* Union */) { + var result = []; + ts.forEach(type.types, function (t) { + if (t.symbol) { + ts.addRange(/*to*/ result, /*from*/ getDefinitionFromSymbol(t.symbol, node)); + } + }); + return result; + } + if (!type.symbol) { + return undefined; + } + return getDefinitionFromSymbol(type.symbol, node); + } + function getOccurrencesAtPosition(fileName, position) { + var results = getOccurrencesAtPositionCore(fileName, position); + if (results) { + var sourceFile = getCanonicalFileName(ts.normalizeSlashes(fileName)); + // Get occurrences only supports reporting occurrences for the file queried. So + // filter down to that list. + results = ts.filter(results, function (r) { return getCanonicalFileName(ts.normalizeSlashes(r.fileName)) === sourceFile; }); + } + return results; + } + function getDocumentHighlights(fileName, position, filesToSearch) { + synchronizeHostData(); + filesToSearch = ts.map(filesToSearch, ts.normalizeSlashes); + var sourceFilesToSearch = ts.filter(program.getSourceFiles(), function (f) { return ts.contains(filesToSearch, f.fileName); }); + var sourceFile = getValidSourceFile(fileName); + var node = ts.getTouchingWord(sourceFile, position); + if (!node) { + return undefined; + } + return getSemanticDocumentHighlights(node) || getSyntacticDocumentHighlights(node); + function getHighlightSpanForNode(node) { + var start = node.getStart(); + var end = node.getEnd(); + return { + fileName: sourceFile.fileName, + textSpan: ts.createTextSpanFromBounds(start, end), + kind: HighlightSpanKind.none + }; + } + function getSemanticDocumentHighlights(node) { + if (node.kind === 69 /* Identifier */ || + node.kind === 97 /* ThisKeyword */ || + node.kind === 95 /* SuperKeyword */ || + isLiteralNameOfPropertyDeclarationOrIndexAccess(node) || + isNameOfExternalModuleImportOrDeclaration(node)) { + var referencedSymbols = getReferencedSymbolsForNode(node, sourceFilesToSearch, /*findInStrings:*/ false, /*findInComments:*/ false); + return convertReferencedSymbols(referencedSymbols); + } + return undefined; + function convertReferencedSymbols(referencedSymbols) { + if (!referencedSymbols) { + return undefined; + } + var fileNameToDocumentHighlights = {}; + var result = []; + for (var _i = 0; _i < referencedSymbols.length; _i++) { + var referencedSymbol = referencedSymbols[_i]; + for (var _a = 0, _b = referencedSymbol.references; _a < _b.length; _a++) { + var referenceEntry = _b[_a]; + var fileName_1 = referenceEntry.fileName; + var documentHighlights = ts.getProperty(fileNameToDocumentHighlights, fileName_1); + if (!documentHighlights) { + documentHighlights = { fileName: fileName_1, highlightSpans: [] }; + fileNameToDocumentHighlights[fileName_1] = documentHighlights; + result.push(documentHighlights); + } + documentHighlights.highlightSpans.push({ + textSpan: referenceEntry.textSpan, + kind: referenceEntry.isWriteAccess ? HighlightSpanKind.writtenReference : HighlightSpanKind.reference + }); + } + } + return result; + } + } + function getSyntacticDocumentHighlights(node) { + var fileName = sourceFile.fileName; + var highlightSpans = getHighlightSpans(node); + if (!highlightSpans || highlightSpans.length === 0) { + return undefined; + } + return [{ fileName: fileName, highlightSpans: highlightSpans }]; + // returns true if 'node' is defined and has a matching 'kind'. + function hasKind(node, kind) { + return node !== undefined && node.kind === kind; + } + // Null-propagating 'parent' function. + function parent(node) { + return node && node.parent; + } + function getHighlightSpans(node) { + if (node) { + switch (node.kind) { + case 88 /* IfKeyword */: + case 80 /* ElseKeyword */: + if (hasKind(node.parent, 196 /* IfStatement */)) { + return getIfElseOccurrences(node.parent); + } + break; + case 94 /* ReturnKeyword */: + if (hasKind(node.parent, 204 /* ReturnStatement */)) { + return getReturnOccurrences(node.parent); + } + break; + case 98 /* ThrowKeyword */: + if (hasKind(node.parent, 208 /* ThrowStatement */)) { + return getThrowOccurrences(node.parent); + } + break; + case 72 /* CatchKeyword */: + if (hasKind(parent(parent(node)), 209 /* TryStatement */)) { + return getTryCatchFinallyOccurrences(node.parent.parent); + } + break; + case 100 /* TryKeyword */: + case 85 /* FinallyKeyword */: + if (hasKind(parent(node), 209 /* TryStatement */)) { + return getTryCatchFinallyOccurrences(node.parent); + } + break; + case 96 /* SwitchKeyword */: + if (hasKind(node.parent, 206 /* SwitchStatement */)) { + return getSwitchCaseDefaultOccurrences(node.parent); + } + break; + case 71 /* CaseKeyword */: + case 77 /* DefaultKeyword */: + if (hasKind(parent(parent(parent(node))), 206 /* SwitchStatement */)) { + return getSwitchCaseDefaultOccurrences(node.parent.parent.parent); + } + break; + case 70 /* BreakKeyword */: + case 75 /* ContinueKeyword */: + if (hasKind(node.parent, 203 /* BreakStatement */) || hasKind(node.parent, 202 /* ContinueStatement */)) { + return getBreakOrContinueStatementOccurrences(node.parent); + } + break; + case 86 /* ForKeyword */: + if (hasKind(node.parent, 199 /* ForStatement */) || + hasKind(node.parent, 200 /* ForInStatement */) || + hasKind(node.parent, 201 /* ForOfStatement */)) { + return getLoopBreakContinueOccurrences(node.parent); + } + break; + case 104 /* WhileKeyword */: + case 79 /* DoKeyword */: + if (hasKind(node.parent, 198 /* WhileStatement */) || hasKind(node.parent, 197 /* DoStatement */)) { + return getLoopBreakContinueOccurrences(node.parent); + } + break; + case 121 /* ConstructorKeyword */: + if (hasKind(node.parent, 144 /* Constructor */)) { + return getConstructorOccurrences(node.parent); + } + break; + case 123 /* GetKeyword */: + case 129 /* SetKeyword */: + if (hasKind(node.parent, 145 /* GetAccessor */) || hasKind(node.parent, 146 /* SetAccessor */)) { + return getGetAndSetOccurrences(node.parent); + } + break; + default: + if (ts.isModifier(node.kind) && node.parent && + (ts.isDeclaration(node.parent) || node.parent.kind === 193 /* VariableStatement */)) { + return getModifierOccurrences(node.kind, node.parent); + } + } + } + return undefined; + } + /** + * Aggregates all throw-statements within this node *without* crossing + * into function boundaries and try-blocks with catch-clauses. + */ + function aggregateOwnedThrowStatements(node) { + var statementAccumulator = []; + aggregate(node); + return statementAccumulator; + function aggregate(node) { + if (node.kind === 208 /* ThrowStatement */) { + statementAccumulator.push(node); + } + else if (node.kind === 209 /* TryStatement */) { + var tryStatement = node; + if (tryStatement.catchClause) { + aggregate(tryStatement.catchClause); + } + else { + // Exceptions thrown within a try block lacking a catch clause + // are "owned" in the current context. + aggregate(tryStatement.tryBlock); + } + if (tryStatement.finallyBlock) { + aggregate(tryStatement.finallyBlock); + } + } + else if (!ts.isFunctionLike(node)) { + ts.forEachChild(node, aggregate); + } + } + ; + } + /** + * For lack of a better name, this function takes a throw statement and returns the + * nearest ancestor that is a try-block (whose try statement has a catch clause), + * function-block, or source file. + */ + function getThrowStatementOwner(throwStatement) { + var child = throwStatement; + while (child.parent) { + var parent_12 = child.parent; + if (ts.isFunctionBlock(parent_12) || parent_12.kind === 248 /* SourceFile */) { + return parent_12; + } + // A throw-statement is only owned by a try-statement if the try-statement has + // a catch clause, and if the throw-statement occurs within the try block. + if (parent_12.kind === 209 /* TryStatement */) { + var tryStatement = parent_12; + if (tryStatement.tryBlock === child && tryStatement.catchClause) { + return child; + } + } + child = parent_12; + } + return undefined; + } + function aggregateAllBreakAndContinueStatements(node) { + var statementAccumulator = []; + aggregate(node); + return statementAccumulator; + function aggregate(node) { + if (node.kind === 203 /* BreakStatement */ || node.kind === 202 /* ContinueStatement */) { + statementAccumulator.push(node); + } + else if (!ts.isFunctionLike(node)) { + ts.forEachChild(node, aggregate); + } + } + ; + } + function ownsBreakOrContinueStatement(owner, statement) { + var actualOwner = getBreakOrContinueOwner(statement); + return actualOwner && actualOwner === owner; + } + function getBreakOrContinueOwner(statement) { + for (var node_2 = statement.parent; node_2; node_2 = node_2.parent) { + switch (node_2.kind) { + case 206 /* SwitchStatement */: + if (statement.kind === 202 /* ContinueStatement */) { + continue; + } + // Fall through. + case 199 /* ForStatement */: + case 200 /* ForInStatement */: + case 201 /* ForOfStatement */: + case 198 /* WhileStatement */: + case 197 /* DoStatement */: + if (!statement.label || isLabeledBy(node_2, statement.label.text)) { + return node_2; + } + break; + default: + // Don't cross function boundaries. + if (ts.isFunctionLike(node_2)) { + return undefined; + } + break; + } + } + return undefined; + } + function getModifierOccurrences(modifier, declaration) { + 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 === 214 /* ClassDeclaration */ || + container.kind === 186 /* ClassExpression */ || + (declaration.kind === 138 /* Parameter */ && hasKind(container, 144 /* Constructor */)))) { + return undefined; + } + } + else if (modifier === 113 /* StaticKeyword */) { + if (!(container.kind === 214 /* ClassDeclaration */ || container.kind === 186 /* ClassExpression */)) { + return undefined; + } + } + else if (modifier === 82 /* ExportKeyword */ || modifier === 122 /* DeclareKeyword */) { + if (!(container.kind === 219 /* ModuleBlock */ || container.kind === 248 /* SourceFile */)) { + return undefined; + } + } + else if (modifier === 115 /* AbstractKeyword */) { + if (!(container.kind === 214 /* ClassDeclaration */ || declaration.kind === 214 /* ClassDeclaration */)) { + return undefined; + } + } + else { + // unsupported modifier + return undefined; + } + var keywords = []; + var modifierFlag = getFlagFromModifier(modifier); + var nodes; + switch (container.kind) { + case 219 /* ModuleBlock */: + case 248 /* SourceFile */: + // Container is either a class declaration or the declaration is a classDeclaration + if (modifierFlag & 256 /* Abstract */) { + nodes = declaration.members.concat(declaration); + } + else { + nodes = container.statements; + } + break; + case 144 /* Constructor */: + nodes = container.parameters.concat(container.parent.members); + break; + case 214 /* ClassDeclaration */: + case 186 /* ClassExpression */: + nodes = container.members; + // If we're an accessibility modifier, we're in an instance member and should search + // the constructor's parameter list for instance members as well. + if (modifierFlag & 112 /* AccessibilityModifier */) { + var constructor = ts.forEach(container.members, function (member) { + return member.kind === 144 /* Constructor */ && member; + }); + if (constructor) { + nodes = nodes.concat(constructor.parameters); + } + } + else if (modifierFlag & 256 /* Abstract */) { + nodes = nodes.concat(container); + } + break; + default: + ts.Debug.fail("Invalid container kind."); + } + ts.forEach(nodes, function (node) { + if (node.modifiers && node.flags & modifierFlag) { + ts.forEach(node.modifiers, function (child) { return pushKeywordIf(keywords, child, modifier); }); + } + }); + return ts.map(keywords, getHighlightSpanForNode); + function getFlagFromModifier(modifier) { + switch (modifier) { + case 112 /* PublicKeyword */: + return 16 /* Public */; + case 110 /* PrivateKeyword */: + return 32 /* Private */; + case 111 /* ProtectedKeyword */: + return 64 /* Protected */; + case 113 /* StaticKeyword */: + return 128 /* Static */; + case 82 /* ExportKeyword */: + return 1 /* Export */; + case 122 /* DeclareKeyword */: + return 2 /* Ambient */; + case 115 /* AbstractKeyword */: + return 256 /* Abstract */; + default: + ts.Debug.fail(); + } + } + } + function pushKeywordIf(keywordList, token) { + var expected = []; + for (var _i = 2; _i < arguments.length; _i++) { + expected[_i - 2] = arguments[_i]; + } + if (token && ts.contains(expected, token.kind)) { + keywordList.push(token); + return true; + } + return false; + } + function getGetAndSetOccurrences(accessorDeclaration) { + var keywords = []; + tryPushAccessorKeyword(accessorDeclaration.symbol, 145 /* GetAccessor */); + tryPushAccessorKeyword(accessorDeclaration.symbol, 146 /* SetAccessor */); + return ts.map(keywords, getHighlightSpanForNode); + function tryPushAccessorKeyword(accessorSymbol, accessorKind) { + var accessor = ts.getDeclarationOfKind(accessorSymbol, accessorKind); + if (accessor) { + ts.forEach(accessor.getChildren(), function (child) { return pushKeywordIf(keywords, child, 123 /* GetKeyword */, 129 /* SetKeyword */); }); + } + } + } + function getConstructorOccurrences(constructorDeclaration) { + var declarations = constructorDeclaration.symbol.getDeclarations(); + var keywords = []; + ts.forEach(declarations, function (declaration) { + ts.forEach(declaration.getChildren(), function (token) { + return pushKeywordIf(keywords, token, 121 /* ConstructorKeyword */); + }); + }); + return ts.map(keywords, getHighlightSpanForNode); + } + function getLoopBreakContinueOccurrences(loopNode) { + var keywords = []; + if (pushKeywordIf(keywords, loopNode.getFirstToken(), 86 /* ForKeyword */, 104 /* WhileKeyword */, 79 /* DoKeyword */)) { + // If we succeeded and got a do-while loop, then start looking for a 'while' keyword. + if (loopNode.kind === 197 /* DoStatement */) { + var loopTokens = loopNode.getChildren(); + for (var i = loopTokens.length - 1; i >= 0; i--) { + if (pushKeywordIf(keywords, loopTokens[i], 104 /* WhileKeyword */)) { + break; + } + } + } + } + var breaksAndContinues = aggregateAllBreakAndContinueStatements(loopNode.statement); + ts.forEach(breaksAndContinues, function (statement) { + if (ownsBreakOrContinueStatement(loopNode, statement)) { + pushKeywordIf(keywords, statement.getFirstToken(), 70 /* BreakKeyword */, 75 /* ContinueKeyword */); + } + }); + return ts.map(keywords, getHighlightSpanForNode); + } + function getBreakOrContinueStatementOccurrences(breakOrContinueStatement) { + var owner = getBreakOrContinueOwner(breakOrContinueStatement); + if (owner) { + switch (owner.kind) { + case 199 /* ForStatement */: + case 200 /* ForInStatement */: + case 201 /* ForOfStatement */: + case 197 /* DoStatement */: + case 198 /* WhileStatement */: + return getLoopBreakContinueOccurrences(owner); + case 206 /* SwitchStatement */: + return getSwitchCaseDefaultOccurrences(owner); + } + } + return undefined; + } + function getSwitchCaseDefaultOccurrences(switchStatement) { + var keywords = []; + pushKeywordIf(keywords, switchStatement.getFirstToken(), 96 /* SwitchKeyword */); + // Go through each clause in the switch statement, collecting the 'case'/'default' keywords. + ts.forEach(switchStatement.caseBlock.clauses, function (clause) { + pushKeywordIf(keywords, clause.getFirstToken(), 71 /* CaseKeyword */, 77 /* DefaultKeyword */); + var breaksAndContinues = aggregateAllBreakAndContinueStatements(clause); + ts.forEach(breaksAndContinues, function (statement) { + if (ownsBreakOrContinueStatement(switchStatement, statement)) { + pushKeywordIf(keywords, statement.getFirstToken(), 70 /* BreakKeyword */); + } + }); + }); + return ts.map(keywords, getHighlightSpanForNode); + } + function getTryCatchFinallyOccurrences(tryStatement) { + var keywords = []; + pushKeywordIf(keywords, tryStatement.getFirstToken(), 100 /* TryKeyword */); + if (tryStatement.catchClause) { + pushKeywordIf(keywords, tryStatement.catchClause.getFirstToken(), 72 /* CatchKeyword */); + } + if (tryStatement.finallyBlock) { + var finallyKeyword = ts.findChildOfKind(tryStatement, 85 /* FinallyKeyword */, sourceFile); + pushKeywordIf(keywords, finallyKeyword, 85 /* FinallyKeyword */); + } + return ts.map(keywords, getHighlightSpanForNode); + } + function getThrowOccurrences(throwStatement) { + var owner = getThrowStatementOwner(throwStatement); + if (!owner) { + return undefined; + } + var keywords = []; + ts.forEach(aggregateOwnedThrowStatements(owner), function (throwStatement) { + pushKeywordIf(keywords, throwStatement.getFirstToken(), 98 /* ThrowKeyword */); + }); + // If the "owner" is a function, then we equate 'return' and 'throw' statements in their + // ability to "jump out" of the function, and include occurrences for both. + if (ts.isFunctionBlock(owner)) { + ts.forEachReturnStatement(owner, function (returnStatement) { + pushKeywordIf(keywords, returnStatement.getFirstToken(), 94 /* ReturnKeyword */); + }); + } + return ts.map(keywords, getHighlightSpanForNode); + } + 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, 192 /* Block */))) { + return undefined; + } + var keywords = []; + ts.forEachReturnStatement(func.body, function (returnStatement) { + pushKeywordIf(keywords, returnStatement.getFirstToken(), 94 /* ReturnKeyword */); + }); + // Include 'throw' statements that do not occur within a try block. + ts.forEach(aggregateOwnedThrowStatements(func.body), function (throwStatement) { + pushKeywordIf(keywords, throwStatement.getFirstToken(), 98 /* ThrowKeyword */); + }); + return ts.map(keywords, getHighlightSpanForNode); + } + function getIfElseOccurrences(ifStatement) { + var keywords = []; + // Traverse upwards through all parent if-statements linked by their else-branches. + while (hasKind(ifStatement.parent, 196 /* IfStatement */) && ifStatement.parent.elseStatement === ifStatement) { + ifStatement = ifStatement.parent; + } + // Now traverse back down through the else branches, aggregating if/else keywords of if-statements. + while (ifStatement) { + var children = ifStatement.getChildren(); + pushKeywordIf(keywords, children[0], 88 /* IfKeyword */); + // Generally the 'else' keyword is second-to-last, so we traverse backwards. + for (var i = children.length - 1; i >= 0; i--) { + if (pushKeywordIf(keywords, children[i], 80 /* ElseKeyword */)) { + break; + } + } + if (!hasKind(ifStatement.elseStatement, 196 /* IfStatement */)) { + break; + } + ifStatement = ifStatement.elseStatement; + } + var result = []; + // 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) { + var elseKeyword = keywords[i]; + var ifKeyword = keywords[i + 1]; // this *should* always be an 'if' keyword. + var shouldCombindElseAndIf = true; + // Avoid recalculating getStart() by iterating backwards. + for (var j = ifKeyword.getStart() - 1; j >= elseKeyword.end; j--) { + if (!ts.isWhiteSpace(sourceFile.text.charCodeAt(j))) { + shouldCombindElseAndIf = false; + break; + } + } + if (shouldCombindElseAndIf) { + result.push({ + fileName: fileName, + textSpan: ts.createTextSpanFromBounds(elseKeyword.getStart(), ifKeyword.end), + kind: HighlightSpanKind.reference + }); + i++; // skip the next keyword + continue; + } + } + // Ordinary case: just highlight the keyword. + result.push(getHighlightSpanForNode(keywords[i])); + } + return result; + } + } + } + /// References and Occurrences + function getOccurrencesAtPositionCore(fileName, position) { + synchronizeHostData(); + return convertDocumentHighlights(getDocumentHighlights(fileName, position, [fileName])); + function convertDocumentHighlights(documentHighlights) { + if (!documentHighlights) { + return undefined; + } + var result = []; + for (var _i = 0; _i < documentHighlights.length; _i++) { + var entry = documentHighlights[_i]; + for (var _a = 0, _b = entry.highlightSpans; _a < _b.length; _a++) { + var highlightSpan = _b[_a]; + result.push({ + fileName: entry.fileName, + textSpan: highlightSpan.textSpan, + isWriteAccess: highlightSpan.kind === HighlightSpanKind.writtenReference + }); + } + } + return result; + } + } + function convertReferences(referenceSymbols) { + if (!referenceSymbols) { + return undefined; + } + var referenceEntries = []; + for (var _i = 0; _i < referenceSymbols.length; _i++) { + var referenceSymbol = referenceSymbols[_i]; + ts.addRange(referenceEntries, referenceSymbol.references); + } + return referenceEntries; + } + function findRenameLocations(fileName, position, findInStrings, findInComments) { + var referencedSymbols = findReferencedSymbols(fileName, position, findInStrings, findInComments); + return convertReferences(referencedSymbols); + } + function getReferencesAtPosition(fileName, position) { + var referencedSymbols = findReferencedSymbols(fileName, position, /*findInStrings:*/ false, /*findInComments:*/ false); + return convertReferences(referencedSymbols); + } + function findReferences(fileName, position) { + var referencedSymbols = findReferencedSymbols(fileName, position, /*findInStrings:*/ false, /*findInComments:*/ false); + // Only include referenced symbols that have a valid definition. + return ts.filter(referencedSymbols, function (rs) { return !!rs.definition; }); + } + function findReferencedSymbols(fileName, position, findInStrings, findInComments) { + synchronizeHostData(); + var sourceFile = getValidSourceFile(fileName); + var node = ts.getTouchingPropertyName(sourceFile, position); + if (!node) { + return undefined; + } + if (node.kind !== 69 /* Identifier */ && + // TODO (drosen): This should be enabled in a later release - currently breaks rename. + //node.kind !== SyntaxKind.ThisKeyword && + //node.kind !== SyntaxKind.SuperKeyword && + !isLiteralNameOfPropertyDeclarationOrIndexAccess(node) && + !isNameOfExternalModuleImportOrDeclaration(node)) { + return undefined; + } + ts.Debug.assert(node.kind === 69 /* Identifier */ || node.kind === 8 /* NumericLiteral */ || node.kind === 9 /* StringLiteral */); + return getReferencedSymbolsForNode(node, program.getSourceFiles(), findInStrings, findInComments); + } + function getReferencedSymbolsForNode(node, sourceFiles, findInStrings, findInComments) { + var typeChecker = program.getTypeChecker(); + // Labels + if (isLabelName(node)) { + if (isJumpStatementTarget(node)) { + var labelDefinition = getTargetLabel(node.parent, node.text); + // if we have a label definition, look within its statement for references, if not, then + // the label is undefined and we have no results.. + return labelDefinition ? getLabelReferencesInNode(labelDefinition.parent, labelDefinition) : undefined; + } + else { + // it is a label definition and not a target, search within the parent labeledStatement + return getLabelReferencesInNode(node.parent, node); + } + } + if (node.kind === 97 /* ThisKeyword */) { + return getReferencesForThisKeyword(node, sourceFiles); + } + if (node.kind === 95 /* SuperKeyword */) { + return getReferencesForSuperKeyword(node); + } + var symbol = typeChecker.getSymbolAtLocation(node); + // Could not find a symbol e.g. unknown identifier + if (!symbol) { + // Can't have references to something that we have no symbol for. + return undefined; + } + var declarations = symbol.declarations; + // The symbol was an internal symbol and does not have a declaration e.g. undefined symbol + if (!declarations || !declarations.length) { + return undefined; + } + var result; + // Compute the meaning from the location and the symbol it references + var searchMeaning = getIntersectingMeaningFromDeclarations(getMeaningFromLocation(node), declarations); + // Get the text to search for. + // Note: if this is an external module symbol, the name doesn't include quotes. + var declaredName = ts.stripQuotes(ts.getDeclaredName(typeChecker, symbol, node)); + // Try to get the smallest valid scope that we can limit our search to; + // otherwise we'll need to search globally (i.e. include each file). + var scope = getSymbolScope(symbol); + // Maps from a symbol ID to the ReferencedSymbol entry in 'result'. + var symbolToIndex = []; + if (scope) { + result = []; + getReferencesInNode(scope, symbol, declaredName, node, searchMeaning, findInStrings, findInComments, result, symbolToIndex); + } + else { + var internedName = getInternedName(symbol, node, declarations); + for (var _i = 0; _i < sourceFiles.length; _i++) { + var sourceFile = sourceFiles[_i]; + cancellationToken.throwIfCancellationRequested(); + var nameTable = getNameTable(sourceFile); + if (ts.lookUp(nameTable, internedName)) { + result = result || []; + getReferencesInNode(sourceFile, symbol, declaredName, node, searchMeaning, findInStrings, findInComments, result, symbolToIndex); + } + } + } + return result; + function getDefinition(symbol) { + var info = getSymbolDisplayPartsDocumentationAndSymbolKind(symbol, node.getSourceFile(), getContainerNode(node), node); + var name = ts.map(info.displayParts, function (p) { return p.text; }).join(""); + var declarations = symbol.declarations; + if (!declarations || declarations.length === 0) { + return undefined; + } + return { + containerKind: "", + containerName: "", + name: name, + kind: info.symbolKind, + fileName: declarations[0].getSourceFile().fileName, + textSpan: ts.createTextSpan(declarations[0].getStart(), 0) + }; + } + function isImportOrExportSpecifierImportSymbol(symbol) { + return (symbol.flags & 8388608 /* Alias */) && ts.forEach(symbol.declarations, function (declaration) { + return declaration.kind === 226 /* ImportSpecifier */ || declaration.kind === 230 /* ExportSpecifier */; + }); + } + function getInternedName(symbol, location, declarations) { + // 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)) { + return location.getText(); + } + // Try to get the local symbol if we're dealing with an 'export default' + // since that symbol has the "true" name. + var localExportDefaultSymbol = ts.getLocalSymbolForExportDefault(symbol); + symbol = localExportDefaultSymbol || symbol; + return ts.stripQuotes(symbol.name); + } + /** + * Determines the smallest scope in which a symbol may have named references. + * Note that not every construct has been accounted for. This function can + * probably be improved. + * + * @returns undefined if the scope cannot be determined, implying that + * a reference to a symbol can occur anywhere. + */ + function getSymbolScope(symbol) { + // 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 === 173 /* FunctionExpression */ || valueDeclaration.kind === 186 /* ClassExpression */)) { + return valueDeclaration; + } + // If this is private property or method, the scope is the containing class + if (symbol.flags & (4 /* Property */ | 8192 /* Method */)) { + var privateDeclaration = ts.forEach(symbol.getDeclarations(), function (d) { return (d.flags & 32 /* Private */) ? d : undefined; }); + if (privateDeclaration) { + return ts.getAncestor(privateDeclaration, 214 /* ClassDeclaration */); + } + } + // If the symbol is an import we would like to find it if we are looking for what it imports. + // So consider it visibile outside its declaration scope. + if (symbol.flags & 8388608 /* Alias */) { + return undefined; + } + // if this symbol is visible from its parent container, e.g. exported, then bail out + // if symbol correspond to the union property - bail out + if (symbol.parent || (symbol.flags & 268435456 /* SyntheticProperty */)) { + return undefined; + } + var scope = undefined; + var declarations = symbol.getDeclarations(); + if (declarations) { + for (var _i = 0; _i < declarations.length; _i++) { + var declaration = declarations[_i]; + var container = getContainerNode(declaration); + if (!container) { + return undefined; + } + if (scope && scope !== container) { + // Different declarations have different containers, bail out + return undefined; + } + if (container.kind === 248 /* SourceFile */ && !ts.isExternalModule(container)) { + // This is a global variable and not an external module, any declaration defined + // within this scope is visible outside the file + return undefined; + } + // The search scope is the container node + scope = container; + } + } + return scope; + } + function getPossibleSymbolReferencePositions(sourceFile, symbolName, start, end) { + var positions = []; + /// TODO: Cache symbol existence for files to save text search + // Also, need to make this work for unicode escapes. + // Be resilient in the face of a symbol with no name or zero length name + if (!symbolName || !symbolName.length) { + return positions; + } + var text = sourceFile.text; + var sourceLength = text.length; + var symbolNameLength = symbolName.length; + var position = text.indexOf(symbolName, start); + while (position >= 0) { + cancellationToken.throwIfCancellationRequested(); + // If we are past the end, stop looking + if (position > end) + break; + // 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 */))) { + // Found a real match. Keep searching. + positions.push(position); + } + position = text.indexOf(symbolName, position + symbolNameLength + 1); + } + return positions; + } + function getLabelReferencesInNode(container, targetLabel) { + var references = []; + var sourceFile = container.getSourceFile(); + var labelName = targetLabel.text; + var possiblePositions = getPossibleSymbolReferencePositions(sourceFile, labelName, container.getStart(), container.getEnd()); + ts.forEach(possiblePositions, function (position) { + cancellationToken.throwIfCancellationRequested(); + var node = ts.getTouchingWord(sourceFile, position); + if (!node || node.getWidth() !== labelName.length) { + return; + } + // Only pick labels that are either the target label, or have a target that is the target label + if (node === targetLabel || + (isJumpStatementTarget(node) && getTargetLabel(node, labelName) === targetLabel)) { + references.push(getReferenceEntryFromNode(node)); + } + }); + var definition = { + containerKind: "", + containerName: "", + fileName: targetLabel.getSourceFile().fileName, + kind: ScriptElementKind.label, + name: labelName, + textSpan: ts.createTextSpanFromBounds(targetLabel.getStart(), targetLabel.getEnd()) + }; + return [{ definition: definition, references: references }]; + } + function isValidReferencePosition(node, searchSymbolName) { + if (node) { + // Compare the length so we filter out strict superstrings of the symbol we are looking for + switch (node.kind) { + case 69 /* Identifier */: + return node.getWidth() === searchSymbolName.length; + case 9 /* StringLiteral */: + if (isLiteralNameOfPropertyDeclarationOrIndexAccess(node) || + isNameOfExternalModuleImportOrDeclaration(node)) { + // For string literals we have two additional chars for the quotes + return node.getWidth() === searchSymbolName.length + 2; + } + break; + case 8 /* NumericLiteral */: + if (isLiteralNameOfPropertyDeclarationOrIndexAccess(node)) { + return node.getWidth() === searchSymbolName.length; + } + break; + } + } + return false; + } + /** Search within node "container" for references for a search value, where the search value is defined as a + * tuple of(searchSymbol, searchText, searchLocation, and searchMeaning). + * searchLocation: a node where the search value + */ + function getReferencesInNode(container, searchSymbol, searchText, searchLocation, searchMeaning, findInStrings, findInComments, result, symbolToIndex) { + var sourceFile = container.getSourceFile(); + var tripleSlashDirectivePrefixRegex = /^\/\/\/\s*= 0) { + var referencedSymbol = getReferencedSymbol(shorthandValueSymbol); + referencedSymbol.references.push(getReferenceEntryFromNode(referenceSymbolDeclaration.name)); + } + } + }); + } + return; + function getReferencedSymbol(symbol) { + var symbolId = ts.getSymbolId(symbol); + var index = symbolToIndex[symbolId]; + if (index === undefined) { + index = result.length; + symbolToIndex[symbolId] = index; + result.push({ + definition: getDefinition(symbol), + references: [] + }); + } + return result[index]; + } + function isInNonReferenceComment(sourceFile, position) { + return ts.isInCommentHelper(sourceFile, position, isNonReferenceComment); + function isNonReferenceComment(c) { + var commentText = sourceFile.text.substring(c.pos, c.end); + return !tripleSlashDirectivePrefixRegex.test(commentText); + } + } + } + function getReferencesForSuperKeyword(superKeyword) { + var searchSpaceNode = ts.getSuperContainer(superKeyword, /*includeFunctions*/ false); + if (!searchSpaceNode) { + return undefined; + } + // Whether 'super' occurs in a static context within a class. + var staticFlag = 128 /* Static */; + switch (searchSpaceNode.kind) { + case 141 /* PropertyDeclaration */: + case 140 /* PropertySignature */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: + case 144 /* Constructor */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: + staticFlag &= searchSpaceNode.flags; + searchSpaceNode = searchSpaceNode.parent; // re-assign to be the owning class + break; + default: + return undefined; + } + var references = []; + var sourceFile = searchSpaceNode.getSourceFile(); + var possiblePositions = getPossibleSymbolReferencePositions(sourceFile, "super", searchSpaceNode.getStart(), searchSpaceNode.getEnd()); + ts.forEach(possiblePositions, function (position) { + cancellationToken.throwIfCancellationRequested(); + var node = ts.getTouchingWord(sourceFile, position); + if (!node || node.kind !== 95 /* SuperKeyword */) { + return; + } + var container = ts.getSuperContainer(node, /*includeFunctions*/ false); + // If we have a 'super' container, we must have an enclosing class. + // Now make sure the owning class is the same as the search-space + // and has the same static qualifier as the original 'super's owner. + if (container && (128 /* Static */ & container.flags) === staticFlag && container.parent.symbol === searchSpaceNode.symbol) { + references.push(getReferenceEntryFromNode(node)); + } + }); + var definition = getDefinition(searchSpaceNode.symbol); + return [{ definition: definition, references: references }]; + } + function getReferencesForThisKeyword(thisOrSuperKeyword, sourceFiles) { + var searchSpaceNode = ts.getThisContainer(thisOrSuperKeyword, /* includeArrowFunctions */ false); + // Whether 'this' occurs in a static context within a class. + var staticFlag = 128 /* Static */; + switch (searchSpaceNode.kind) { + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: + if (ts.isObjectLiteralMethod(searchSpaceNode)) { + break; + } + // fall through + case 141 /* PropertyDeclaration */: + case 140 /* PropertySignature */: + case 144 /* Constructor */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: + staticFlag &= searchSpaceNode.flags; + searchSpaceNode = searchSpaceNode.parent; // re-assign to be the owning class + break; + case 248 /* SourceFile */: + if (ts.isExternalModule(searchSpaceNode)) { + return undefined; + } + // Fall through + case 213 /* FunctionDeclaration */: + case 173 /* FunctionExpression */: + break; + // Computed properties in classes are not handled here because references to this are illegal, + // so there is no point finding references to them. + default: + return undefined; + } + var references = []; + var possiblePositions; + if (searchSpaceNode.kind === 248 /* SourceFile */) { + ts.forEach(sourceFiles, function (sourceFile) { + possiblePositions = getPossibleSymbolReferencePositions(sourceFile, "this", sourceFile.getStart(), sourceFile.getEnd()); + getThisReferencesInFile(sourceFile, sourceFile, possiblePositions, references); + }); + } + else { + var sourceFile = searchSpaceNode.getSourceFile(); + possiblePositions = getPossibleSymbolReferencePositions(sourceFile, "this", searchSpaceNode.getStart(), searchSpaceNode.getEnd()); + getThisReferencesInFile(sourceFile, searchSpaceNode, possiblePositions, references); + } + return [{ + definition: { + containerKind: "", + containerName: "", + fileName: node.getSourceFile().fileName, + kind: ScriptElementKind.variableElement, + name: "this", + textSpan: ts.createTextSpanFromBounds(node.getStart(), node.getEnd()) + }, + references: references + }]; + function getThisReferencesInFile(sourceFile, searchSpaceNode, possiblePositions, result) { + ts.forEach(possiblePositions, function (position) { + cancellationToken.throwIfCancellationRequested(); + var node = ts.getTouchingWord(sourceFile, position); + if (!node || node.kind !== 97 /* ThisKeyword */) { + return; + } + var container = ts.getThisContainer(node, /* includeArrowFunctions */ false); + switch (searchSpaceNode.kind) { + case 173 /* FunctionExpression */: + case 213 /* FunctionDeclaration */: + if (searchSpaceNode.symbol === container.symbol) { + result.push(getReferenceEntryFromNode(node)); + } + break; + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: + if (ts.isObjectLiteralMethod(searchSpaceNode) && searchSpaceNode.symbol === container.symbol) { + result.push(getReferenceEntryFromNode(node)); + } + break; + case 186 /* ClassExpression */: + case 214 /* ClassDeclaration */: + // Make sure the container belongs to the same class + // and has the appropriate static modifier from the original container. + if (container.parent && searchSpaceNode.symbol === container.parent.symbol && (container.flags & 128 /* Static */) === staticFlag) { + result.push(getReferenceEntryFromNode(node)); + } + break; + case 248 /* SourceFile */: + if (container.kind === 248 /* SourceFile */ && !ts.isExternalModule(container)) { + result.push(getReferenceEntryFromNode(node)); + } + break; + } + }); + } + } + function populateSearchSymbolSet(symbol, location) { + // The search set contains at least the current symbol + var result = [symbol]; + // If the symbol is an alias, add what it alaises to the list + if (isImportOrExportSpecifierImportSymbol(symbol)) { + result.push(typeChecker.getAliasedSymbol(symbol)); + } + // If the location is in a context sensitive location (i.e. in an object literal) try + // to get a contextual type for it, and add the property symbol from the contextual + // type to the search set + if (isNameOfPropertyAssignment(location)) { + ts.forEach(getPropertySymbolsFromContextualType(location), function (contextualSymbol) { + ts.addRange(result, typeChecker.getRootSymbols(contextualSymbol)); + }); + /* Because in short-hand property assignment, location has two meaning : property name and as value of the property + * When we do findAllReference at the position of the short-hand property assignment, we would want to have references to position of + * property name and variable declaration of the identifier. + * Like in below example, when querying for all references for an identifier 'name', of the property assignment, the language service + * should show both 'name' in 'obj' and 'name' in variable declaration + * let name = "Foo"; + * let obj = { name }; + * In order to do that, we will populate the search set with the value symbol of the identifier as a value of the property assignment + * so that when matching with potential reference symbol, both symbols from property declaration and variable declaration + * will be included correctly. + */ + var shorthandValueSymbol = typeChecker.getShorthandAssignmentValueSymbol(location.parent); + if (shorthandValueSymbol) { + result.push(shorthandValueSymbol); + } + } + // If this is a union property, add all the symbols from all its source symbols in all unioned types. + // If the symbol is an instantiation from a another symbol (e.g. widened symbol) , add the root the list + ts.forEach(typeChecker.getRootSymbols(symbol), function (rootSymbol) { + if (rootSymbol !== symbol) { + result.push(rootSymbol); + } + // Add symbol of properties/methods of the same name in base classes and implemented interfaces definitions + if (rootSymbol.parent && rootSymbol.parent.flags & (32 /* Class */ | 64 /* Interface */)) { + getPropertySymbolsFromBaseTypes(rootSymbol.parent, rootSymbol.getName(), result); + } + }); + return result; + } + function getPropertySymbolsFromBaseTypes(symbol, propertyName, result) { + if (symbol && symbol.flags & (32 /* Class */ | 64 /* Interface */)) { + ts.forEach(symbol.getDeclarations(), function (declaration) { + if (declaration.kind === 214 /* ClassDeclaration */) { + getPropertySymbolFromTypeReference(ts.getClassExtendsHeritageClauseElement(declaration)); + ts.forEach(ts.getClassImplementsHeritageClauseElements(declaration), getPropertySymbolFromTypeReference); + } + else if (declaration.kind === 215 /* InterfaceDeclaration */) { + ts.forEach(ts.getInterfaceBaseTypeNodes(declaration), getPropertySymbolFromTypeReference); + } + }); + } + return; + function getPropertySymbolFromTypeReference(typeReference) { + if (typeReference) { + var type = typeChecker.getTypeAtLocation(typeReference); + if (type) { + var propertySymbol = typeChecker.getPropertyOfType(type, propertyName); + if (propertySymbol) { + result.push(propertySymbol); + } + // Visit the typeReference as well to see if it directly or indirectly use that property + getPropertySymbolsFromBaseTypes(type.symbol, propertyName, result); + } + } + } + } + function getRelatedSymbol(searchSymbols, referenceSymbol, referenceLocation) { + if (searchSymbols.indexOf(referenceSymbol) >= 0) { + return referenceSymbol; + } + // If the reference symbol is an alias, check if what it is aliasing is one of the search + // symbols. + if (isImportOrExportSpecifierImportSymbol(referenceSymbol)) { + var aliasedSymbol = typeChecker.getAliasedSymbol(referenceSymbol); + if (searchSymbols.indexOf(aliasedSymbol) >= 0) { + return aliasedSymbol; + } + } + // If the reference location is in an object literal, try to get the contextual type for the + // object literal, lookup the property symbol in the contextual type, and use this symbol to + // compare to our searchSymbol + if (isNameOfPropertyAssignment(referenceLocation)) { + return ts.forEach(getPropertySymbolsFromContextualType(referenceLocation), function (contextualSymbol) { + return ts.forEach(typeChecker.getRootSymbols(contextualSymbol), function (s) { return searchSymbols.indexOf(s) >= 0 ? s : undefined; }); + }); + } + // Unwrap symbols to get to the root (e.g. transient symbols as a result of widening) + // Or a union property, use its underlying unioned symbols + return ts.forEach(typeChecker.getRootSymbols(referenceSymbol), function (rootSymbol) { + // if it is in the list, then we are done + if (searchSymbols.indexOf(rootSymbol) >= 0) { + return rootSymbol; + } + // Finally, try all properties with the same name in any type the containing type extended or implemented, and + // see if any is in the list + if (rootSymbol.parent && rootSymbol.parent.flags & (32 /* Class */ | 64 /* Interface */)) { + var result_3 = []; + getPropertySymbolsFromBaseTypes(rootSymbol.parent, rootSymbol.getName(), result_3); + return ts.forEach(result_3, function (s) { return searchSymbols.indexOf(s) >= 0 ? s : undefined; }); + } + return undefined; + }); + } + function getPropertySymbolsFromContextualType(node) { + if (isNameOfPropertyAssignment(node)) { + var objectLiteral = node.parent.parent; + var contextualType = typeChecker.getContextualType(objectLiteral); + var name_35 = node.text; + if (contextualType) { + if (contextualType.flags & 16384 /* Union */) { + // This is a union type, first see if the property we are looking for is a union property (i.e. exists in all types) + // if not, search the constituent types for the property + var unionProperty = contextualType.getProperty(name_35); + if (unionProperty) { + return [unionProperty]; + } + else { + var result_4 = []; + ts.forEach(contextualType.types, function (t) { + var symbol = t.getProperty(name_35); + if (symbol) { + result_4.push(symbol); + } + }); + return result_4; + } + } + else { + var symbol_1 = contextualType.getProperty(name_35); + if (symbol_1) { + return [symbol_1]; + } + } + } + } + return undefined; + } + /** Given an initial searchMeaning, extracted from a location, widen the search scope based on the declarations + * of the corresponding symbol. e.g. if we are searching for "Foo" in value position, but "Foo" references a class + * then we need to widen the search to include type positions as well. + * On the contrary, if we are searching for "Bar" in type position and we trace bar to an interface, and an uninstantiated + * module, we want to keep the search limited to only types, as the two declarations (interface and uninstantiated module) + * do not intersect in any of the three spaces. + */ + function getIntersectingMeaningFromDeclarations(meaning, declarations) { + if (declarations) { + var lastIterationMeaning; + do { + // The result is order-sensitive, for instance if initialMeaning === Namespace, and declarations = [class, instantiated module] + // we need to consider both as they initialMeaning intersects with the module in the namespace space, and the module + // intersects with the class in the value space. + // To achieve that we will keep iterating until the result stabilizes. + // Remember the last meaning + lastIterationMeaning = meaning; + for (var _i = 0; _i < declarations.length; _i++) { + var declaration = declarations[_i]; + var declarationMeaning = getMeaningFromDeclaration(declaration); + if (declarationMeaning & meaning) { + meaning |= declarationMeaning; + } + } + } while (meaning !== lastIterationMeaning); + } + return meaning; + } + } + function getReferenceEntryFromNode(node) { + var start = node.getStart(); + var end = node.getEnd(); + if (node.kind === 9 /* StringLiteral */) { + start += 1; + end -= 1; + } + return { + fileName: node.getSourceFile().fileName, + textSpan: ts.createTextSpanFromBounds(start, end), + isWriteAccess: isWriteAccess(node) + }; + } + /** 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)) { + return true; + } + var parent = node.parent; + if (parent) { + if (parent.kind === 180 /* PostfixUnaryExpression */ || parent.kind === 179 /* PrefixUnaryExpression */) { + return true; + } + else if (parent.kind === 181 /* BinaryExpression */ && parent.left === node) { + var operator = parent.operatorToken.kind; + return 56 /* FirstAssignment */ <= operator && operator <= 68 /* LastAssignment */; + } + } + return false; + } + /// NavigateTo + function getNavigateToItems(searchValue, maxResultCount) { + synchronizeHostData(); + return ts.NavigateTo.getNavigateToItems(program, cancellationToken, searchValue, maxResultCount); + } + function containErrors(diagnostics) { + return ts.forEach(diagnostics, function (diagnostic) { return diagnostic.category === ts.DiagnosticCategory.Error; }); + } + function getEmitOutput(fileName) { + synchronizeHostData(); + var sourceFile = getValidSourceFile(fileName); + var outputFiles = []; + function writeFile(fileName, data, writeByteOrderMark) { + outputFiles.push({ + name: fileName, + writeByteOrderMark: writeByteOrderMark, + text: data + }); + } + var emitOutput = program.emit(sourceFile, writeFile, cancellationToken); + return { + outputFiles: outputFiles, + emitSkipped: emitOutput.emitSkipped + }; + } + function getMeaningFromDeclaration(node) { + switch (node.kind) { + case 138 /* Parameter */: + case 211 /* VariableDeclaration */: + case 163 /* BindingElement */: + case 141 /* PropertyDeclaration */: + case 140 /* PropertySignature */: + case 245 /* PropertyAssignment */: + case 246 /* ShorthandPropertyAssignment */: + case 247 /* EnumMember */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: + case 144 /* Constructor */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: + case 213 /* FunctionDeclaration */: + case 173 /* FunctionExpression */: + case 174 /* ArrowFunction */: + case 244 /* CatchClause */: + return 1 /* Value */; + case 137 /* TypeParameter */: + case 215 /* InterfaceDeclaration */: + case 216 /* TypeAliasDeclaration */: + case 155 /* TypeLiteral */: + return 2 /* Type */; + case 214 /* ClassDeclaration */: + case 217 /* EnumDeclaration */: + return 1 /* Value */ | 2 /* Type */; + case 218 /* ModuleDeclaration */: + if (node.name.kind === 9 /* StringLiteral */) { + return 4 /* Namespace */ | 1 /* Value */; + } + else if (ts.getModuleInstanceState(node) === 1 /* Instantiated */) { + return 4 /* Namespace */ | 1 /* Value */; + } + else { + return 4 /* Namespace */; + } + case 225 /* NamedImports */: + case 226 /* ImportSpecifier */: + case 221 /* ImportEqualsDeclaration */: + case 222 /* ImportDeclaration */: + case 227 /* ExportAssignment */: + case 228 /* ExportDeclaration */: + return 1 /* Value */ | 2 /* Type */ | 4 /* Namespace */; + // An external module can be a Value + case 248 /* SourceFile */: + return 4 /* Namespace */ | 1 /* Value */; + } + return 1 /* Value */ | 2 /* Type */ | 4 /* Namespace */; + ts.Debug.fail("Unknown declaration type"); + } + function isTypeReference(node) { + if (ts.isRightSideOfQualifiedNameOrPropertyAccess(node)) { + node = node.parent; + } + return node.parent.kind === 151 /* TypeReference */ || + (node.parent.kind === 188 /* ExpressionWithTypeArguments */ && !ts.isExpressionWithTypeArgumentsInClassExtendsClause(node.parent)) || + node.kind === 97 /* ThisKeyword */ && !ts.isExpression(node); + } + function isNamespaceReference(node) { + return isQualifiedNameNamespaceReference(node) || isPropertyAccessNamespaceReference(node); + } + function isPropertyAccessNamespaceReference(node) { + var root = node; + var isLastClause = true; + if (root.parent.kind === 166 /* PropertyAccessExpression */) { + while (root.parent && root.parent.kind === 166 /* PropertyAccessExpression */) { + root = root.parent; + } + isLastClause = root.name === node; + } + if (!isLastClause && root.parent.kind === 188 /* ExpressionWithTypeArguments */ && root.parent.parent.kind === 243 /* HeritageClause */) { + var decl = root.parent.parent.parent; + return (decl.kind === 214 /* ClassDeclaration */ && root.parent.parent.token === 106 /* ImplementsKeyword */) || + (decl.kind === 215 /* InterfaceDeclaration */ && root.parent.parent.token === 83 /* ExtendsKeyword */); + } + return false; + } + function isQualifiedNameNamespaceReference(node) { + var root = node; + var isLastClause = true; + if (root.parent.kind === 135 /* QualifiedName */) { + while (root.parent && root.parent.kind === 135 /* QualifiedName */) { + root = root.parent; + } + isLastClause = root.right === node; + } + return root.parent.kind === 151 /* TypeReference */ && !isLastClause; + } + function isInRightSideOfImport(node) { + while (node.parent.kind === 135 /* QualifiedName */) { + node = node.parent; + } + return ts.isInternalModuleImportEqualsDeclaration(node.parent) && node.parent.moduleReference === node; + } + function getMeaningFromRightHandSideOfImportEquals(node) { + ts.Debug.assert(node.kind === 69 /* Identifier */); + // import a = |b|; // Namespace + // import a = |b.c|; // Value, type, namespace + // import a = |b.c|.d; // Namespace + if (node.parent.kind === 135 /* QualifiedName */ && + node.parent.right === node && + node.parent.parent.kind === 221 /* ImportEqualsDeclaration */) { + return 1 /* Value */ | 2 /* Type */ | 4 /* Namespace */; + } + return 4 /* Namespace */; + } + function getMeaningFromLocation(node) { + if (node.parent.kind === 227 /* ExportAssignment */) { + return 1 /* Value */ | 2 /* Type */ | 4 /* Namespace */; + } + else if (isInRightSideOfImport(node)) { + return getMeaningFromRightHandSideOfImportEquals(node); + } + else if (ts.isDeclarationName(node)) { + return getMeaningFromDeclaration(node.parent); + } + else if (isTypeReference(node)) { + return 2 /* Type */; + } + else if (isNamespaceReference(node)) { + return 4 /* Namespace */; + } + else { + return 1 /* Value */; + } + } + // Signature help + /** + * This is a semantic operation. + */ + function getSignatureHelpItems(fileName, position) { + synchronizeHostData(); + var sourceFile = getValidSourceFile(fileName); + return ts.SignatureHelp.getSignatureHelpItems(program, sourceFile, position, cancellationToken); + } + /// Syntactic features + function getSourceFile(fileName) { + return syntaxTreeCache.getCurrentSourceFile(fileName); + } + function getNameOrDottedNameSpan(fileName, startPos, endPos) { + var sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName); + // Get node at the location + var node = ts.getTouchingPropertyName(sourceFile, startPos); + if (!node) { + return; + } + switch (node.kind) { + case 166 /* PropertyAccessExpression */: + case 135 /* QualifiedName */: + case 9 /* StringLiteral */: + case 84 /* FalseKeyword */: + case 99 /* TrueKeyword */: + case 93 /* NullKeyword */: + case 95 /* SuperKeyword */: + case 97 /* ThisKeyword */: + case 69 /* Identifier */: + break; + // Cant create the text span + default: + return; + } + var nodeForStartPos = node; + while (true) { + if (isRightSideOfPropertyAccess(nodeForStartPos) || isRightSideOfQualifiedName(nodeForStartPos)) { + // If on the span is in right side of the the property or qualified name, return the span from the qualified name pos to end of this node + nodeForStartPos = nodeForStartPos.parent; + } + else if (isNameOfModuleDeclaration(nodeForStartPos)) { + // 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 === 218 /* ModuleDeclaration */ && + nodeForStartPos.parent.parent.body === nodeForStartPos.parent) { + // Use parent module declarations name for start pos + nodeForStartPos = nodeForStartPos.parent.parent.name; + } + else { + // We have to use this name for start pos + break; + } + } + else { + // Is not a member expression so we have found the node for start pos + break; + } + } + return ts.createTextSpanFromBounds(nodeForStartPos.getStart(), node.getEnd()); + } + function getBreakpointStatementAtPosition(fileName, position) { + // doesn't use compiler - no need to synchronize with host + var sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName); + return ts.BreakpointResolver.spanInSourceFileAtLocation(sourceFile, position); + } + function getNavigationBarItems(fileName) { + var sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName); + return ts.NavigationBar.getNavigationBarItems(sourceFile); + } + function getSemanticClassifications(fileName, span) { + return convertClassifications(getEncodedSemanticClassifications(fileName, span)); + } + function checkForClassificationCancellation(kind) { + // We don't want to actually call back into our host on every node to find out if we've + // been canceled. That would be an enormous amount of chattyness, along with the all + // the overhead of marshalling the data to/from the host. So instead we pick a few + // reasonable node kinds to bother checking on. These node kinds represent high level + // constructs that we would expect to see commonly, but just at a far less frequent + // interval. + // + // For example, in checker.ts (around 750k) we only have around 600 of these constructs. + // 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 218 /* ModuleDeclaration */: + case 214 /* ClassDeclaration */: + case 215 /* InterfaceDeclaration */: + case 213 /* FunctionDeclaration */: + cancellationToken.throwIfCancellationRequested(); + } + } + function getEncodedSemanticClassifications(fileName, span) { + synchronizeHostData(); + var sourceFile = getValidSourceFile(fileName); + var typeChecker = program.getTypeChecker(); + var result = []; + var classifiableNames = program.getClassifiableNames(); + processNode(sourceFile); + return { spans: result, endOfLineState: 0 /* None */ }; + function pushClassification(start, length, type) { + result.push(start); + result.push(length); + result.push(type); + } + function classifySymbol(symbol, meaningAtPosition) { + var flags = symbol.getFlags(); + if ((flags & 788448 /* Classifiable */) === 0 /* None */) { + return; + } + if (flags & 32 /* Class */) { + return 11 /* className */; + } + else if (flags & 384 /* Enum */) { + return 12 /* enumName */; + } + else if (flags & 524288 /* TypeAlias */) { + return 16 /* typeAliasName */; + } + else if (meaningAtPosition & 2 /* Type */) { + if (flags & 64 /* Interface */) { + return 13 /* interfaceName */; + } + else if (flags & 262144 /* TypeParameter */) { + return 15 /* typeParameterName */; + } + } + else if (flags & 1536 /* Module */) { + // Only classify a module as such if + // - It appears in a namespace context. + // - There exists a module declaration which actually impacts the value side. + if (meaningAtPosition & 4 /* Namespace */ || + (meaningAtPosition & 1 /* Value */ && hasValueSideModule(symbol))) { + return 14 /* moduleName */; + } + } + return undefined; + /** + * Returns true if there exists a module that introduces entities on the value side. + */ + function hasValueSideModule(symbol) { + return ts.forEach(symbol.declarations, function (declaration) { + return declaration.kind === 218 /* ModuleDeclaration */ && + ts.getModuleInstanceState(declaration) === 1 /* Instantiated */; + }); + } + } + function processNode(node) { + // Only walk into nodes that intersect the requested span. + if (node && ts.textSpanIntersectsWith(span, node.getFullStart(), node.getFullWidth())) { + var kind = node.kind; + checkForClassificationCancellation(kind); + if (kind === 69 /* Identifier */ && !ts.nodeIsMissing(node)) { + var identifier = node; + // Only bother calling into the typechecker if this is an identifier that + // could possibly resolve to a type name. This makes classification run + // in a third of the time it would normally take. + if (classifiableNames[identifier.text]) { + var symbol = typeChecker.getSymbolAtLocation(node); + if (symbol) { + var type = classifySymbol(symbol, getMeaningFromLocation(node)); + if (type) { + pushClassification(node.getStart(), node.getWidth(), type); + } + } + } + } + ts.forEachChild(node, processNode); + } + } + } + function getClassificationTypeName(type) { + switch (type) { + case 1 /* comment */: return ClassificationTypeNames.comment; + case 2 /* identifier */: return ClassificationTypeNames.identifier; + case 3 /* keyword */: return ClassificationTypeNames.keyword; + case 4 /* numericLiteral */: return ClassificationTypeNames.numericLiteral; + case 5 /* operator */: return ClassificationTypeNames.operator; + case 6 /* stringLiteral */: return ClassificationTypeNames.stringLiteral; + case 8 /* whiteSpace */: return ClassificationTypeNames.whiteSpace; + case 9 /* text */: return ClassificationTypeNames.text; + case 10 /* punctuation */: return ClassificationTypeNames.punctuation; + case 11 /* className */: return ClassificationTypeNames.className; + case 12 /* enumName */: return ClassificationTypeNames.enumName; + case 13 /* interfaceName */: return ClassificationTypeNames.interfaceName; + case 14 /* moduleName */: return ClassificationTypeNames.moduleName; + case 15 /* typeParameterName */: return ClassificationTypeNames.typeParameterName; + case 16 /* typeAliasName */: return ClassificationTypeNames.typeAliasName; + case 17 /* parameterName */: return ClassificationTypeNames.parameterName; + case 18 /* docCommentTagName */: return ClassificationTypeNames.docCommentTagName; + } + } + function convertClassifications(classifications) { + ts.Debug.assert(classifications.spans.length % 3 === 0); + var dense = classifications.spans; + var result = []; + for (var i = 0, n = dense.length; i < n; i += 3) { + result.push({ + textSpan: ts.createTextSpan(dense[i], dense[i + 1]), + classificationType: getClassificationTypeName(dense[i + 2]) + }); + } + return result; + } + function getSyntacticClassifications(fileName, span) { + return convertClassifications(getEncodedSyntacticClassifications(fileName, span)); + } + function getEncodedSyntacticClassifications(fileName, span) { + // doesn't use compiler - no need to synchronize with host + var sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName); + 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 result = []; + processElement(sourceFile); + return { spans: result, endOfLineState: 0 /* None */ }; + function pushClassification(start, length, type) { + result.push(start); + result.push(length); + result.push(type); + } + function classifyLeadingTriviaAndGetTokenStart(token) { + triviaScanner.setTextPos(token.pos); + while (true) { + var start = triviaScanner.getTextPos(); + // only bother scanning if we have something that could be trivia. + if (!ts.couldStartTrivia(sourceFile.text, start)) { + return start; + } + var kind = triviaScanner.scan(); + var end = triviaScanner.getTextPos(); + var width = end - start; + // The moment we get something that isn't trivia, then stop processing. + if (!ts.isTrivia(kind)) { + return start; + } + // Don't bother with newlines/whitespace. + if (kind === 4 /* NewLineTrivia */ || kind === 5 /* WhitespaceTrivia */) { + continue; + } + // Only bother with the trivia if it at least intersects the span of interest. + if (ts.isComment(kind)) { + classifyComment(token, kind, start, width); + // Classifying a comment might cause us to reuse the trivia scanner + // (because of jsdoc comments). So after we classify the comment make + // sure we set the scanner position back to where it needs to be. + triviaScanner.setTextPos(end); + continue; + } + if (kind === 7 /* ConflictMarkerTrivia */) { + var text = sourceFile.text; + var ch = text.charCodeAt(start); + // for the <<<<<<< and >>>>>>> markers, we just add them in as comments + // in the classification stream. + if (ch === 60 /* lessThan */ || ch === 62 /* greaterThan */) { + pushClassification(start, width, 1 /* comment */); + continue; + } + // for the ======== add a comment for the first line, and then lex all + // subsequent lines up until the end of the conflict marker. + ts.Debug.assert(ch === 61 /* equals */); + classifyDisabledMergeCode(text, start, end); + } + } + } + function classifyComment(token, kind, start, width) { + if (kind === 3 /* MultiLineCommentTrivia */) { + // See if this is a doc comment. If so, we'll classify certain portions of it + // specially. + var docCommentAndDiagnostics = ts.parseIsolatedJSDocComment(sourceFile.text, start, width); + if (docCommentAndDiagnostics && docCommentAndDiagnostics.jsDocComment) { + docCommentAndDiagnostics.jsDocComment.parent = token; + classifyJSDocComment(docCommentAndDiagnostics.jsDocComment); + return; + } + } + // Simple comment. Just add as is. + pushCommentRange(start, width); + } + function pushCommentRange(start, width) { + pushClassification(start, width, 1 /* comment */); + } + function classifyJSDocComment(docComment) { + var pos = docComment.pos; + for (var _i = 0, _a = docComment.tags; _i < _a.length; _i++) { + var tag = _a[_i]; + // As we walk through each tag, classify the portion of text from the end of + // the last tag (or the start of the entire doc comment) as 'comment'. + if (tag.pos !== pos) { + pushCommentRange(pos, tag.pos - pos); + } + pushClassification(tag.atToken.pos, tag.atToken.end - tag.atToken.pos, 10 /* punctuation */); + pushClassification(tag.tagName.pos, tag.tagName.end - tag.tagName.pos, 18 /* docCommentTagName */); + pos = tag.tagName.end; + switch (tag.kind) { + case 267 /* JSDocParameterTag */: + processJSDocParameterTag(tag); + break; + case 270 /* JSDocTemplateTag */: + processJSDocTemplateTag(tag); + break; + case 269 /* JSDocTypeTag */: + processElement(tag.typeExpression); + break; + case 268 /* JSDocReturnTag */: + processElement(tag.typeExpression); + break; + } + pos = tag.end; + } + if (pos !== docComment.end) { + pushCommentRange(pos, docComment.end - pos); + } + return; + function processJSDocParameterTag(tag) { + if (tag.preParameterName) { + pushCommentRange(pos, tag.preParameterName.pos - pos); + pushClassification(tag.preParameterName.pos, tag.preParameterName.end - tag.preParameterName.pos, 17 /* parameterName */); + pos = tag.preParameterName.end; + } + if (tag.typeExpression) { + pushCommentRange(pos, tag.typeExpression.pos - pos); + processElement(tag.typeExpression); + pos = tag.typeExpression.end; + } + if (tag.postParameterName) { + pushCommentRange(pos, tag.postParameterName.pos - pos); + pushClassification(tag.postParameterName.pos, tag.postParameterName.end - tag.postParameterName.pos, 17 /* parameterName */); + pos = tag.postParameterName.end; + } + } + } + function processJSDocTemplateTag(tag) { + for (var _i = 0, _a = tag.getChildren(); _i < _a.length; _i++) { + var child = _a[_i]; + processElement(child); + } + } + function classifyDisabledMergeCode(text, start, end) { + // Classify the line that the ======= marker is on as a comment. Then just lex + // all further tokens and add them to the result. + for (var i = start; i < end; i++) { + if (ts.isLineBreak(text.charCodeAt(i))) { + break; + } + } + pushClassification(start, i - start, 1 /* comment */); + mergeConflictScanner.setTextPos(i); + while (mergeConflictScanner.getTextPos() < end) { + classifyDisabledCodeToken(); + } + } + function classifyDisabledCodeToken() { + var start = mergeConflictScanner.getTextPos(); + var tokenKind = mergeConflictScanner.scan(); + var end = mergeConflictScanner.getTextPos(); + var type = classifyTokenType(tokenKind); + if (type) { + pushClassification(start, end - start, type); + } + } + function classifyToken(token) { + if (ts.nodeIsMissing(token)) { + return; + } + var tokenStart = classifyLeadingTriviaAndGetTokenStart(token); + var tokenWidth = token.end - tokenStart; + ts.Debug.assert(tokenWidth >= 0); + if (tokenWidth > 0) { + var type = classifyTokenType(token.kind, token); + if (type) { + pushClassification(tokenStart, tokenWidth, type); + } + } + } + // for accurate classification, the actual token should be passed in. however, for + // cases like 'disabled merge code' classification, we just get the token kind and + // classify based on that instead. + function classifyTokenType(tokenKind, token) { + if (ts.isKeyword(tokenKind)) { + return 3 /* keyword */; + } + // Special case < and > If they appear in a generic context they are punctuation, + // not operators. + if (tokenKind === 25 /* LessThanToken */ || tokenKind === 27 /* 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)) { + return 10 /* punctuation */; + } + } + if (ts.isPunctuation(tokenKind)) { + if (token) { + if (tokenKind === 56 /* EqualsToken */) { + // the '=' in a variable declaration is special cased here. + if (token.parent.kind === 211 /* VariableDeclaration */ || + token.parent.kind === 141 /* PropertyDeclaration */ || + token.parent.kind === 138 /* Parameter */) { + return 5 /* operator */; + } + } + if (token.parent.kind === 181 /* BinaryExpression */ || + token.parent.kind === 179 /* PrefixUnaryExpression */ || + token.parent.kind === 180 /* PostfixUnaryExpression */ || + token.parent.kind === 182 /* ConditionalExpression */) { + return 5 /* operator */; + } + } + return 10 /* punctuation */; + } + else if (tokenKind === 8 /* NumericLiteral */) { + return 4 /* numericLiteral */; + } + else if (tokenKind === 9 /* StringLiteral */) { + return 6 /* stringLiteral */; + } + else if (tokenKind === 10 /* RegularExpressionLiteral */) { + // TODO: we should get another classification type for these literals. + return 6 /* stringLiteral */; + } + else if (ts.isTemplateLiteralKind(tokenKind)) { + // TODO (drosen): we should *also* get another classification type for these literals. + return 6 /* stringLiteral */; + } + else if (tokenKind === 69 /* Identifier */) { + if (token) { + switch (token.parent.kind) { + case 214 /* ClassDeclaration */: + if (token.parent.name === token) { + return 11 /* className */; + } + return; + case 137 /* TypeParameter */: + if (token.parent.name === token) { + return 15 /* typeParameterName */; + } + return; + case 215 /* InterfaceDeclaration */: + if (token.parent.name === token) { + return 13 /* interfaceName */; + } + return; + case 217 /* EnumDeclaration */: + if (token.parent.name === token) { + return 12 /* enumName */; + } + return; + case 218 /* ModuleDeclaration */: + if (token.parent.name === token) { + return 14 /* moduleName */; + } + return; + case 138 /* Parameter */: + if (token.parent.name === token) { + return 17 /* parameterName */; + } + return; + } + } + return 2 /* identifier */; + } + } + function processElement(element) { + if (!element) { + return; + } + // Ignore nodes that don't intersect the original span to classify. + if (ts.decodedTextSpanIntersectsWith(spanStart, spanLength, element.pos, element.getFullWidth())) { + checkForClassificationCancellation(element.kind); + var children = element.getChildren(sourceFile); + for (var i = 0, n = children.length; i < n; i++) { + var child = children[i]; + if (ts.isToken(child)) { + classifyToken(child); + } + else { + // Recurse into our child nodes. + processElement(child); + } + } + } + } + } + function getOutliningSpans(fileName) { + // doesn't use compiler - no need to synchronize with host + var sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName); + return ts.OutliningElementsCollector.collectElements(sourceFile); + } + function getBraceMatchingAtPosition(fileName, position) { + var sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName); + var result = []; + var token = ts.getTouchingToken(sourceFile, position); + if (token.getStart(sourceFile) === position) { + var matchKind = getMatchingTokenKind(token); + // Ensure that there is a corresponding token to match ours. + if (matchKind) { + var parentElement = token.parent; + var childNodes = parentElement.getChildren(sourceFile); + for (var _i = 0; _i < childNodes.length; _i++) { + var current = childNodes[_i]; + if (current.kind === matchKind) { + var range1 = ts.createTextSpan(token.getStart(sourceFile), token.getWidth(sourceFile)); + var range2 = ts.createTextSpan(current.getStart(sourceFile), current.getWidth(sourceFile)); + // We want to order the braces when we return the result. + if (range1.start < range2.start) { + result.push(range1, range2); + } + else { + result.push(range2, range1); + } + break; + } + } + } + } + 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 */; + } + return undefined; + } + } + function getIndentationAtPosition(fileName, position, editorOptions) { + var start = new Date().getTime(); + var sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName); + log("getIndentationAtPosition: getCurrentSourceFile: " + (new Date().getTime() - start)); + start = new Date().getTime(); + var result = ts.formatting.SmartIndenter.getIndentation(position, sourceFile, editorOptions); + log("getIndentationAtPosition: computeIndentation : " + (new Date().getTime() - start)); + return result; + } + function getFormattingEditsForRange(fileName, start, end, options) { + var sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName); + return ts.formatting.formatSelection(start, end, sourceFile, getRuleProvider(options), options); + } + function getFormattingEditsForDocument(fileName, options) { + var sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName); + return ts.formatting.formatDocument(sourceFile, getRuleProvider(options), options); + } + function getFormattingEditsAfterKeystroke(fileName, position, key, options) { + var sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName); + if (key === "}") { + return ts.formatting.formatOnClosingCurly(position, sourceFile, getRuleProvider(options), options); + } + else if (key === ";") { + return ts.formatting.formatOnSemicolon(position, sourceFile, getRuleProvider(options), options); + } + else if (key === "\n") { + return ts.formatting.formatOnEnter(position, sourceFile, getRuleProvider(options), options); + } + return []; + } + /** + * Checks if position points to a valid position to add JSDoc comments, and if so, + * returns the appropriate template. Otherwise returns an empty string. + * Valid positions are + * - outside of comments, statements, and expressions, and + * - preceding a: + * - function/constructor/method declaration + * - class declarations + * - variable statements + * - namespace declarations + * + * Hosts should ideally check that: + * - The line is all whitespace up to 'position' before performing the insertion. + * - If the keystroke sequence "/\*\*" induced the call, we also check that the next + * non-whitespace character is '*', which (approximately) indicates whether we added + * the second '*' to complete an existing (JSDoc) comment. + * @param fileName The file in which to perform the check. + * @param position The (character-indexed) position in the file where the check should + * be performed. + */ + function getDocCommentTemplateAtPosition(fileName, position) { + var start = new Date().getTime(); + var sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName); + // Check if in a context where we don't want to perform any insertion + if (ts.isInString(sourceFile, position) || ts.isInComment(sourceFile, position) || ts.hasDocComment(sourceFile, position)) { + return undefined; + } + var tokenAtPos = ts.getTokenAtPosition(sourceFile, position); + var tokenStart = tokenAtPos.getStart(); + if (!tokenAtPos || tokenStart < position) { + return undefined; + } + // TODO: add support for: + // - enums/enum members + // - interfaces + // - property declarations + // - potentially property assignments + var commentOwner; + findOwner: for (commentOwner = tokenAtPos; commentOwner; commentOwner = commentOwner.parent) { + switch (commentOwner.kind) { + case 213 /* FunctionDeclaration */: + case 143 /* MethodDeclaration */: + case 144 /* Constructor */: + case 214 /* ClassDeclaration */: + case 193 /* VariableStatement */: + break findOwner; + case 248 /* SourceFile */: + return undefined; + case 218 /* ModuleDeclaration */: + // If in walking up the tree, we hit a a nested namespace declaration, + // then we must be somewhere within a dotted namespace name; however we don't + // want to give back a JSDoc template for the 'b' or 'c' in 'namespace a.b.c { }'. + if (commentOwner.parent.kind === 218 /* ModuleDeclaration */) { + return undefined; + } + break findOwner; + } + } + if (!commentOwner || commentOwner.getStart() < position) { + return undefined; + } + var parameters = getParametersForJsDocOwningNode(commentOwner); + var posLineAndChar = sourceFile.getLineAndCharacterOfPosition(position); + var lineStart = sourceFile.getLineStarts()[posLineAndChar.line]; + var indentationStr = sourceFile.text.substr(lineStart, posLineAndChar.character); + // TODO: call a helper method instead once PR #4133 gets merged in. + var newLine = host.getNewLine ? host.getNewLine() : "\r\n"; + var docParams = ""; + for (var i = 0, numParams = parameters.length; i < numParams; i++) { + var currentName = parameters[i].name; + var paramName = currentName.kind === 69 /* Identifier */ ? + currentName.text : + "param" + i; + docParams += indentationStr + " * @param " + paramName + newLine; + } + // A doc comment consists of the following + // * The opening comment line + // * the first line (without a param) for the object's untagged info (this is also where the caret ends up) + // * the '@param'-tagged lines + // * TODO: other tags. + // * the closing comment line + // * if the caret was directly in front of the object, then we add an extra line and indentation. + var preamble = "/**" + newLine + + indentationStr + " * "; + var result = preamble + newLine + + docParams + + indentationStr + " */" + + (tokenStart === position ? newLine + indentationStr : ""); + return { newText: result, caretOffset: preamble.length }; + } + function getParametersForJsDocOwningNode(commentOwner) { + if (ts.isFunctionLike(commentOwner)) { + return commentOwner.parameters; + } + if (commentOwner.kind === 193 /* VariableStatement */) { + var varStatement = commentOwner; + var varDeclarations = varStatement.declarationList.declarations; + if (varDeclarations.length === 1 && varDeclarations[0].initializer) { + return getParametersFromRightHandSideOfAssignment(varDeclarations[0].initializer); + } + } + return emptyArray; + } + /** + * Digs into an an initializer or RHS operand of an assignment operation + * to get the parameters of an apt signature corresponding to a + * function expression or a class expression. + * + * @param rightHandSide the expression which may contain an appropriate set of parameters + * @returns the parameters of a signature found on the RHS if one exists; otherwise 'emptyArray'. + */ + function getParametersFromRightHandSideOfAssignment(rightHandSide) { + while (rightHandSide.kind === 172 /* ParenthesizedExpression */) { + rightHandSide = rightHandSide.expression; + } + switch (rightHandSide.kind) { + case 173 /* FunctionExpression */: + case 174 /* ArrowFunction */: + return rightHandSide.parameters; + case 186 /* ClassExpression */: + for (var _i = 0, _a = rightHandSide.members; _i < _a.length; _i++) { + var member = _a[_i]; + if (member.kind === 144 /* Constructor */) { + return member.parameters; + } + } + break; + } + return emptyArray; + } + function getTodoComments(fileName, descriptors) { + // Note: while getting todo comments seems like a syntactic operation, we actually + // treat it as a semantic operation here. This is because we expect our host to call + // this on every single file. If we treat this syntactically, then that will cause + // us to populate and throw away the tree in our syntax tree cache for each file. By + // treating this as a semantic operation, we can access any tree without throwing + // anything away. + synchronizeHostData(); + var sourceFile = getValidSourceFile(fileName); + cancellationToken.throwIfCancellationRequested(); + var fileContents = sourceFile.text; + var result = []; + if (descriptors.length > 0) { + var regExp = getTodoCommentsRegExp(); + var matchArray; + while (matchArray = regExp.exec(fileContents)) { + cancellationToken.throwIfCancellationRequested(); + // If we got a match, here is what the match array will look like. Say the source text is: + // + // " // hack 1" + // + // The result array with the regexp: will be: + // + // ["// hack 1", "// ", "hack 1", undefined, "hack"] + // + // Here are the relevant capture groups: + // 0) The full match for the entire regexp. + // 1) The preamble to the message portion. + // 2) The message portion. + // 3...N) The descriptor that was matched - by index. 'undefined' for each + // descriptor that didn't match. an actual value if it did match. + // + // i.e. 'undefined' in position 3 above means TODO(jason) didn't match. + // "hack" in position 4 means HACK did match. + var firstDescriptorCaptureIndex = 3; + ts.Debug.assert(matchArray.length === descriptors.length + firstDescriptorCaptureIndex); + var preamble = matchArray[1]; + var matchPosition = matchArray.index + preamble.length; + // OK, we have found a match in the file. This is only an acceptable match if + // it is contained within a comment. + var token = ts.getTokenAtPosition(sourceFile, matchPosition); + if (!isInsideComment(sourceFile, token, matchPosition)) { + continue; + } + var descriptor = undefined; + for (var i = 0, n = descriptors.length; i < n; i++) { + if (matchArray[i + firstDescriptorCaptureIndex]) { + descriptor = descriptors[i]; + } + } + ts.Debug.assert(descriptor !== undefined); + // We don't want to match something like 'TODOBY', so we make sure a non + // letter/digit follows the match. + if (isLetterOrDigit(fileContents.charCodeAt(matchPosition + descriptor.text.length))) { + continue; + } + var message = matchArray[2]; + result.push({ + descriptor: descriptor, + message: message, + position: matchPosition + }); + } + } + return result; + function escapeRegExp(str) { + return str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&"); + } + function getTodoCommentsRegExp() { + // NOTE: ?: means 'non-capture group'. It allows us to have groups without having to + // filter them out later in the final result array. + // TODO comments can appear in one of the following forms: + // + // 1) // TODO or /////////// TODO + // + // 2) /* TODO or /********** TODO + // + // 3) /* + // * TODO + // */ + // + // The following three regexps are used to match the start of the text up to the TODO + // comment portion. + var singleLineCommentStart = /(?:\/\/+\s*)/.source; + var multiLineCommentStart = /(?:\/\*+\s*)/.source; + var anyNumberOfSpacesAndAsterixesAtStartOfLine = /(?:^(?:\s|\*)*)/.source; + // Match any of the above three TODO comment start regexps. + // Note that the outermost group *is* a capture group. We want to capture the preamble + // so that we can determine the starting position of the TODO comment match. + var preamble = "(" + anyNumberOfSpacesAndAsterixesAtStartOfLine + "|" + singleLineCommentStart + "|" + multiLineCommentStart + ")"; + // Takes the descriptors and forms a regexp that matches them as if they were literals. + // For example, if the descriptors are "TODO(jason)" and "HACK", then this will be: + // + // (?:(TODO\(jason\))|(HACK)) + // + // Note that the outermost group is *not* a capture group, but the innermost groups + // *are* capture groups. By capturing the inner literals we can determine after + // matching which descriptor we are dealing with. + var literals = "(?:" + ts.map(descriptors, function (d) { return "(" + escapeRegExp(d.text) + ")"; }).join("|") + ")"; + // After matching a descriptor literal, the following regexp matches the rest of the + // text up to the end of the line (or */). + var endOfLineOrEndOfComment = /(?:$|\*\/)/.source; + var messageRemainder = /(?:.*?)/.source; + // This is the portion of the match we'll return as part of the TODO comment result. We + // match the literal portion up to the end of the line or end of comment. + var messagePortion = "(" + literals + messageRemainder + ")"; + var regExpString = preamble + messagePortion + endOfLineOrEndOfComment; + // The final regexp will look like this: + // /((?:\/\/+\s*)|(?:\/\*+\s*)|(?:^(?:\s|\*)*))((?:(TODO\(jason\))|(HACK))(?:.*?))(?:$|\*\/)/gim + // The flags of the regexp are important here. + // 'g' is so that we are doing a global search and can find matches several times + // in the input. + // + // 'i' is for case insensitivity (We do this to match C# TODO comment code). + // + // 'm' is so we can find matches in a multi-line input. + return new RegExp(regExpString, "gim"); + } + function isLetterOrDigit(char) { + return (char >= 97 /* a */ && char <= 122 /* z */) || + (char >= 65 /* A */ && char <= 90 /* Z */) || + (char >= 48 /* _0 */ && char <= 57 /* _9 */); + } + } + function getRenameInfo(fileName, position) { + synchronizeHostData(); + var sourceFile = getValidSourceFile(fileName); + var typeChecker = program.getTypeChecker(); + var node = ts.getTouchingWord(sourceFile, position); + // Can only rename an identifier. + if (node && node.kind === 69 /* Identifier */) { + var symbol = typeChecker.getSymbolAtLocation(node); + // Only allow a symbol to be renamed if it actually has at least one declaration. + if (symbol) { + var declarations = symbol.getDeclarations(); + if (declarations && declarations.length > 0) { + // Disallow rename for elements that are defined in the standard TypeScript library. + var defaultLibFileName = host.getDefaultLibFileName(host.getCompilationSettings()); + if (defaultLibFileName) { + for (var _i = 0; _i < declarations.length; _i++) { + var current = declarations[_i]; + var sourceFile_2 = current.getSourceFile(); + var canonicalName = getCanonicalFileName(ts.normalizePath(sourceFile_2.fileName)); + if (sourceFile_2 && getCanonicalFileName(ts.normalizePath(sourceFile_2.fileName)) === getCanonicalFileName(ts.normalizePath(defaultLibFileName))) { + return getRenameInfoError(ts.getLocaleSpecificMessage(ts.Diagnostics.You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library)); + } + } + } + var displayName = ts.stripQuotes(ts.getDeclaredName(typeChecker, symbol, node)); + var kind = getSymbolKind(symbol, node); + if (kind) { + return { + canRename: true, + localizedErrorMessage: undefined, + displayName: displayName, + fullDisplayName: typeChecker.getFullyQualifiedName(symbol), + kind: kind, + kindModifiers: getSymbolModifiers(symbol), + triggerSpan: ts.createTextSpan(node.getStart(), node.getWidth()) + }; + } + } + } + } + return getRenameInfoError(ts.getLocaleSpecificMessage(ts.Diagnostics.You_cannot_rename_this_element)); + function getRenameInfoError(localizedErrorMessage) { + return { + canRename: false, + localizedErrorMessage: localizedErrorMessage, + displayName: undefined, + fullDisplayName: undefined, + kind: undefined, + kindModifiers: undefined, + triggerSpan: undefined + }; + } + } + return { + dispose: dispose, + cleanupSemanticCache: cleanupSemanticCache, + getSyntacticDiagnostics: getSyntacticDiagnostics, + getSemanticDiagnostics: getSemanticDiagnostics, + getCompilerOptionsDiagnostics: getCompilerOptionsDiagnostics, + getSyntacticClassifications: getSyntacticClassifications, + getSemanticClassifications: getSemanticClassifications, + getEncodedSyntacticClassifications: getEncodedSyntacticClassifications, + getEncodedSemanticClassifications: getEncodedSemanticClassifications, + getCompletionsAtPosition: getCompletionsAtPosition, + getCompletionEntryDetails: getCompletionEntryDetails, + getSignatureHelpItems: getSignatureHelpItems, + getQuickInfoAtPosition: getQuickInfoAtPosition, + getDefinitionAtPosition: getDefinitionAtPosition, + getTypeDefinitionAtPosition: getTypeDefinitionAtPosition, + getReferencesAtPosition: getReferencesAtPosition, + findReferences: findReferences, + getOccurrencesAtPosition: getOccurrencesAtPosition, + getDocumentHighlights: getDocumentHighlights, + getNameOrDottedNameSpan: getNameOrDottedNameSpan, + getBreakpointStatementAtPosition: getBreakpointStatementAtPosition, + getNavigateToItems: getNavigateToItems, + getRenameInfo: getRenameInfo, + findRenameLocations: findRenameLocations, + getNavigationBarItems: getNavigationBarItems, + getOutliningSpans: getOutliningSpans, + getTodoComments: getTodoComments, + getBraceMatchingAtPosition: getBraceMatchingAtPosition, + getIndentationAtPosition: getIndentationAtPosition, + getFormattingEditsForRange: getFormattingEditsForRange, + getFormattingEditsForDocument: getFormattingEditsForDocument, + getFormattingEditsAfterKeystroke: getFormattingEditsAfterKeystroke, + getDocCommentTemplateAtPosition: getDocCommentTemplateAtPosition, + getEmitOutput: getEmitOutput, + getSourceFile: getSourceFile, + getProgram: getProgram + }; + } + ts.createLanguageService = createLanguageService; + /* @internal */ + function getNameTable(sourceFile) { + if (!sourceFile.nameTable) { + initializeNameTable(sourceFile); + } + return sourceFile.nameTable; + } + ts.getNameTable = getNameTable; + function initializeNameTable(sourceFile) { + var nameTable = {}; + walk(sourceFile); + sourceFile.nameTable = nameTable; + function walk(node) { + switch (node.kind) { + case 69 /* Identifier */: + nameTable[node.text] = node.text; + break; + case 9 /* StringLiteral */: + case 8 /* NumericLiteral */: + // We want to store any numbers/strings if they were a name that could be + // related to a declaration. So, if we have 'import x = require("something")' + // 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 === 232 /* ExternalModuleReference */ || + isArgumentOfElementAccessExpression(node)) { + nameTable[node.text] = node.text; + } + break; + default: + ts.forEachChild(node, walk); + } + } + } + function isArgumentOfElementAccessExpression(node) { + return node && + node.parent && + node.parent.kind === 167 /* ElementAccessExpression */ && + node.parent.argumentExpression === node; + } + /// Classifier + function createClassifier() { + var scanner = ts.createScanner(2 /* 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[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; + // 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 + // lines, just as we do with the end-of-line state. However, this is a burden for implementers, + // and the behavior is entirely subsumed by the syntactic classifier anyway, so we instead + // flatten any nesting when the template stack is non-empty and encode it in the end-of-line state. + // Situations in which this fails are + // 1) When template strings are nested across different lines: + // `hello ${ `world + // ` }` + // + // Where on the second line, you will get the closing of a template, + // a closing curly, and a new template. + // + // 2) When substitution expressions have curly braces and the curly brace falls on the next line: + // `hello ${ () => { + // return "world" } } ` + // + // Where on the second line, you will get the 'return' keyword, + // a string literal, and a template end consisting of '} } `'. + var templateStack = []; + /** 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 === 129 /* SetKeyword */ || + keyword2 === 121 /* ConstructorKeyword */ || + keyword2 === 113 /* StaticKeyword */) { + // Allow things like "public get", "public constructor" and "public static". + // These are all legal. + return true; + } + // Any other keyword following "public" is actually an identifier an not a real + // keyword. + return false; + } + // Assume any other keyword combination is legal. This can be refined in the future + // if there are more cases we want the classifier to be better at. + return true; + } + function convertClassifications(classifications, text) { + var entries = []; + var dense = classifications.spans; + var lastEnd = 0; + for (var i = 0, n = dense.length; i < n; i += 3) { + var start = dense[i]; + var length_3 = dense[i + 1]; + var type = dense[i + 2]; + // Make a whitespace entry between the last item and this one. + if (lastEnd >= 0) { + var whitespaceLength_1 = start - lastEnd; + if (whitespaceLength_1 > 0) { + entries.push({ length: whitespaceLength_1, classification: TokenClass.Whitespace }); + } + } + entries.push({ length: length_3, classification: convertClassification(type) }); + lastEnd = start + length_3; + } + var whitespaceLength = text.length - lastEnd; + if (whitespaceLength > 0) { + entries.push({ length: whitespaceLength, classification: TokenClass.Whitespace }); + } + return { entries: entries, finalLexState: classifications.endOfLineState }; + } + function convertClassification(type) { + switch (type) { + case 1 /* comment */: return TokenClass.Comment; + case 3 /* keyword */: return TokenClass.Keyword; + case 4 /* numericLiteral */: return TokenClass.NumberLiteral; + case 5 /* operator */: return TokenClass.Operator; + case 6 /* stringLiteral */: return TokenClass.StringLiteral; + case 8 /* whiteSpace */: return TokenClass.Whitespace; + case 10 /* punctuation */: return TokenClass.Punctuation; + case 2 /* identifier */: + case 11 /* className */: + case 12 /* enumName */: + case 13 /* interfaceName */: + case 14 /* moduleName */: + case 15 /* typeParameterName */: + case 16 /* typeAliasName */: + case 9 /* text */: + case 17 /* parameterName */: + default: + return TokenClass.Identifier; + } + } + function getClassificationsForLine(text, lexState, syntacticClassifierAbsent) { + return convertClassifications(getEncodedLexicalClassifications(text, lexState, syntacticClassifierAbsent), text); + } + // If there is a syntactic classifier ('syntacticClassifierAbsent' is false), + // we will be more conservative in order to avoid conflicting with the syntactic classifier. + function getEncodedLexicalClassifications(text, lexState, syntacticClassifierAbsent) { + var offset = 0; + var token = 0 /* Unknown */; + var lastNonTriviaToken = 0 /* Unknown */; + // Empty out the template stack for reuse. + while (templateStack.length > 0) { + templateStack.pop(); + } + // If we're in a string literal, then prepend: "\ + // (and a newline). That way when we lex we'll think we're still in a string literal. + // + // If we're in a multiline comment, then prepend: /* + // (and a newline). That way when we lex we'll think we're still in a multiline comment. + switch (lexState) { + case 3 /* InDoubleQuoteStringLiteral */: + text = '"\\\n' + text; + offset = 3; + break; + case 2 /* InSingleQuoteStringLiteral */: + text = "'\\\n" + text; + offset = 3; + break; + case 1 /* InMultiLineCommentTrivia */: + text = "/*\n" + text; + offset = 3; + break; + case 4 /* InTemplateHeadOrNoSubstitutionTemplate */: + text = "`\n" + text; + offset = 2; + break; + case 5 /* InTemplateMiddleOrTail */: + text = "}\n" + text; + offset = 2; + // fallthrough + case 6 /* InTemplateSubstitutionPosition */: + templateStack.push(12 /* TemplateHead */); + break; + } + scanner.setText(text); + var result = { + endOfLineState: 0 /* None */, + spans: [] + }; + // We can run into an unfortunate interaction between the lexical and syntactic classifier + // when the user is typing something generic. Consider the case where the user types: + // + // Foo tokens. It's a weak heuristic, but should + // work well enough in practice. + var angleBracketStack = 0; + 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 */; + } + } + else if (lastNonTriviaToken === 21 /* DotToken */ && isKeyword(token)) { + token = 69 /* Identifier */; + } + else if (isKeyword(lastNonTriviaToken) && isKeyword(token) && !canFollow(lastNonTriviaToken, token)) { + // We have two keywords in a row. Only treat the second as a keyword if + // it's a sequence that could legally occur in the language. Otherwise + // treat it as an identifier. This way, if someone writes "private var" + // we recognize that 'var' is actually an identifier here. + token = 69 /* Identifier */; + } + else if (lastNonTriviaToken === 69 /* Identifier */ && + token === 25 /* LessThanToken */) { + // Could be the start of something generic. Keep track of that by bumping + // up the current count of generic contexts we may be in. + angleBracketStack++; + } + else if (token === 27 /* 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 === 130 /* StringKeyword */ || + token === 128 /* NumberKeyword */ || + token === 120 /* BooleanKeyword */ || + token === 131 /* SymbolKeyword */) { + if (angleBracketStack > 0 && !syntacticClassifierAbsent) { + // If it looks like we're could be in something generic, don't classify this + // as a keyword. We may just get overwritten by the syntactic classifier, + // causing a noisy experience for the user. + token = 69 /* Identifier */; + } + } + else if (token === 12 /* TemplateHead */) { + templateStack.push(token); + } + else if (token === 15 /* 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 */) { + // 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 */) { + token = scanner.reScanTemplateToken(); + // Only pop on a TemplateTail; a TemplateMiddle indicates there is more for us. + if (token === 14 /* TemplateTail */) { + templateStack.pop(); + } + else { + ts.Debug.assert(token === 13 /* TemplateMiddle */, "Should have been a template middle. Was " + token); + } + } + else { + ts.Debug.assert(lastTemplateStackToken === 15 /* OpenBraceToken */, "Should have been an open brace. Was: " + token); + templateStack.pop(); + } + } + } + lastNonTriviaToken = token; + } + processToken(); + } while (token !== 1 /* EndOfFileToken */); + return result; + function processToken() { + var start = scanner.getTokenPos(); + var end = scanner.getTextPos(); + addResult(start, end, classFromKind(token)); + if (end >= text.length) { + if (token === 9 /* StringLiteral */) { + // Check to see if we finished up on a multiline string literal. + var tokenText = scanner.getTokenText(); + if (scanner.isUnterminated()) { + var lastCharIndex = tokenText.length - 1; + var numBackslashes = 0; + while (tokenText.charCodeAt(lastCharIndex - numBackslashes) === 92 /* backslash */) { + numBackslashes++; + } + // If we have an odd number of backslashes, then the multiline string is unclosed + if (numBackslashes & 1) { + var quoteChar = tokenText.charCodeAt(0); + result.endOfLineState = quoteChar === 34 /* doubleQuote */ + ? 3 /* InDoubleQuoteStringLiteral */ + : 2 /* InSingleQuoteStringLiteral */; + } + } + } + else if (token === 3 /* MultiLineCommentTrivia */) { + // Check to see if the multiline comment was unclosed. + if (scanner.isUnterminated()) { + result.endOfLineState = 1 /* InMultiLineCommentTrivia */; + } + } + else if (ts.isTemplateLiteralKind(token)) { + if (scanner.isUnterminated()) { + if (token === 14 /* TemplateTail */) { + result.endOfLineState = 5 /* InTemplateMiddleOrTail */; + } + else if (token === 11 /* NoSubstitutionTemplateLiteral */) { + result.endOfLineState = 4 /* InTemplateHeadOrNoSubstitutionTemplate */; + } + else { + ts.Debug.fail("Only 'NoSubstitutionTemplateLiteral's and 'TemplateTail's can be unterminated; got SyntaxKind #" + token); + } + } + } + else if (templateStack.length > 0 && ts.lastOrUndefined(templateStack) === 12 /* TemplateHead */) { + result.endOfLineState = 6 /* InTemplateSubstitutionPosition */; + } + } + } + function addResult(start, end, classification) { + if (classification === 8 /* whiteSpace */) { + // Don't bother with whitespace classifications. They're not needed. + return; + } + if (start === 0 && offset > 0) { + // We're classifying the first token, and this was a case where we prepended + // text. We should consider the start of this token to be at the start of + // the original text. + start += offset; + } + // All our tokens are in relation to the augmented text. Move them back to be + // relative to the original text. + start -= offset; + end -= offset; + var length = end - start; + if (length > 0) { + result.spans.push(start); + result.spans.push(length); + result.spans.push(classification); + } + } + } + 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 */: + return true; + default: + return false; + } + } + function isPrefixUnaryExpressionOperatorToken(token) { + switch (token) { + case 35 /* PlusToken */: + case 36 /* MinusToken */: + case 50 /* TildeToken */: + case 49 /* ExclamationToken */: + case 41 /* PlusPlusToken */: + case 42 /* MinusMinusToken */: + return true; + default: + return false; + } + } + function isKeyword(token) { + return token >= 70 /* FirstKeyword */ && token <= 134 /* LastKeyword */; + } + function classFromKind(token) { + if (isKeyword(token)) { + return 3 /* keyword */; + } + else if (isBinaryExpressionOperatorToken(token) || isPrefixUnaryExpressionOperatorToken(token)) { + return 5 /* operator */; + } + else if (token >= 15 /* FirstPunctuation */ && token <= 68 /* LastPunctuation */) { + return 10 /* punctuation */; + } + switch (token) { + case 8 /* NumericLiteral */: + return 4 /* numericLiteral */; + case 9 /* StringLiteral */: + return 6 /* stringLiteral */; + case 10 /* RegularExpressionLiteral */: + return 7 /* regularExpressionLiteral */; + case 7 /* ConflictMarkerTrivia */: + case 3 /* MultiLineCommentTrivia */: + case 2 /* SingleLineCommentTrivia */: + return 1 /* comment */; + case 5 /* WhitespaceTrivia */: + case 4 /* NewLineTrivia */: + return 8 /* whiteSpace */; + case 69 /* Identifier */: + default: + if (ts.isTemplateLiteralKind(token)) { + return 6 /* stringLiteral */; + } + return 2 /* identifier */; + } + } + return { + getClassificationsForLine: getClassificationsForLine, + getEncodedLexicalClassifications: getEncodedLexicalClassifications + }; + } + ts.createClassifier = createClassifier; + /** + * Get the path of the default library files (lib.d.ts) as distributed with the typescript + * node package. + * The functionality is not supported if the ts module is consumed outside of a node module. + */ + function getDefaultLibFilePath(options) { + // Check __dirname is defined and that we are on a node.js system. + if (typeof __dirname !== "undefined") { + return __dirname + ts.directorySeparator + ts.getDefaultLibFileName(options); + } + throw new Error("getDefaultLibFilePath is only supported when consumed as a node module. "); + } + ts.getDefaultLibFilePath = getDefaultLibFilePath; + function initializeServices() { + ts.objectAllocator = { + getNodeConstructor: function (kind) { + function Node(pos, end) { + this.pos = pos; + this.end = end; + this.flags = 0 /* None */; + this.parent = undefined; + } + var proto = kind === 248 /* SourceFile */ ? new SourceFileObject() : new NodeObject(); + proto.kind = kind; + Node.prototype = proto; + return Node; + }, + getSymbolConstructor: function () { return SymbolObject; }, + getTypeConstructor: function () { return TypeObject; }, + getSignatureConstructor: function () { return SignatureObject; } + }; + } + initializeServices(); +})(ts || (ts = {})); +// Copyright (c) Microsoft. All rights reserved. Licensed under the Apache License, Version 2.0. +// See LICENSE.txt in the project root for complete license information. +/// +/* @internal */ +var ts; +(function (ts) { + var BreakpointResolver; + (function (BreakpointResolver) { + /** + * Get the breakpoint span in given sourceFile + */ + function spanInSourceFileAtLocation(sourceFile, position) { + // Cannot set breakpoint in dts file + if (sourceFile.flags & 8192 /* DeclarationFile */) { + return undefined; + } + var tokenAtLocation = ts.getTokenAtPosition(sourceFile, position); + var lineOfPosition = sourceFile.getLineAndCharacterOfPosition(position).line; + if (sourceFile.getLineAndCharacterOfPosition(tokenAtLocation.getStart()).line > lineOfPosition) { + // Get previous token if the token is returned starts on new line + // eg: let x =10; |--- cursor is here + // let y = 10; + // token at position will return let keyword on second line as the token but we would like to use + // token on same line if trailing trivia (comments or white spaces on same line) part of the last token on that line + tokenAtLocation = ts.findPrecedingToken(tokenAtLocation.pos, sourceFile); + // Its a blank line + if (!tokenAtLocation || sourceFile.getLineAndCharacterOfPosition(tokenAtLocation.getEnd()).line !== lineOfPosition) { + return undefined; + } + } + // Cannot set breakpoint in ambient declarations + if (ts.isInAmbientContext(tokenAtLocation)) { + return undefined; + } + // Get the span in the node based on its syntax + return spanInNode(tokenAtLocation); + function textSpan(startNode, endNode) { + return ts.createTextSpanFromBounds(startNode.getStart(), (endNode || startNode).getEnd()); + } + function spanInNodeIfStartsOnSameLine(node, otherwiseOnNode) { + if (node && lineOfPosition === sourceFile.getLineAndCharacterOfPosition(node.getStart()).line) { + return spanInNode(node); + } + return spanInNode(otherwiseOnNode); + } + function spanInPreviousNode(node) { + return spanInNode(ts.findPrecedingToken(node.pos, sourceFile)); + } + function spanInNextNode(node) { + return spanInNode(ts.findNextToken(node, node.parent)); + } + function spanInNode(node) { + if (node) { + if (ts.isExpression(node)) { + if (node.parent.kind === 197 /* DoStatement */) { + // Set span as if on while keyword + return spanInPreviousNode(node); + } + if (node.parent.kind === 199 /* ForStatement */) { + // For now lets set the span on this expression, fix it later + return textSpan(node); + } + if (node.parent.kind === 181 /* BinaryExpression */ && node.parent.operatorToken.kind === 24 /* CommaToken */) { + // if this is comma expression, the breakpoint is possible in this expression + return textSpan(node); + } + if (node.parent.kind === 174 /* ArrowFunction */ && node.parent.body === node) { + // If this is body of arrow function, it is allowed to have the breakpoint + return textSpan(node); + } + } + switch (node.kind) { + case 193 /* VariableStatement */: + // Span on first variable declaration + return spanInVariableDeclaration(node.declarationList.declarations[0]); + case 211 /* VariableDeclaration */: + case 141 /* PropertyDeclaration */: + case 140 /* PropertySignature */: + return spanInVariableDeclaration(node); + case 138 /* Parameter */: + return spanInParameterDeclaration(node); + case 213 /* FunctionDeclaration */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: + case 144 /* Constructor */: + case 173 /* FunctionExpression */: + case 174 /* ArrowFunction */: + return spanInFunctionDeclaration(node); + case 192 /* Block */: + if (ts.isFunctionBlock(node)) { + return spanInFunctionBlock(node); + } + // Fall through + case 219 /* ModuleBlock */: + return spanInBlock(node); + case 244 /* CatchClause */: + return spanInBlock(node.block); + case 195 /* ExpressionStatement */: + // span on the expression + return textSpan(node.expression); + case 204 /* ReturnStatement */: + // span on return keyword and expression if present + return textSpan(node.getChildAt(0), node.expression); + case 198 /* WhileStatement */: + // Span on while(...) + return textSpan(node, ts.findNextToken(node.expression, node)); + case 197 /* DoStatement */: + // span in statement of the do statement + return spanInNode(node.statement); + case 210 /* DebuggerStatement */: + // span on debugger keyword + return textSpan(node.getChildAt(0)); + case 196 /* IfStatement */: + // set on if(..) span + return textSpan(node, ts.findNextToken(node.expression, node)); + case 207 /* LabeledStatement */: + // span in statement + return spanInNode(node.statement); + case 203 /* BreakStatement */: + case 202 /* ContinueStatement */: + // On break or continue keyword and label if present + return textSpan(node.getChildAt(0), node.label); + case 199 /* ForStatement */: + return spanInForStatement(node); + case 200 /* ForInStatement */: + case 201 /* ForOfStatement */: + // span on for (a in ...) + return textSpan(node, ts.findNextToken(node.expression, node)); + case 206 /* SwitchStatement */: + // span on switch(...) + return textSpan(node, ts.findNextToken(node.expression, node)); + case 241 /* CaseClause */: + case 242 /* DefaultClause */: + // span in first statement of the clause + return spanInNode(node.statements[0]); + case 209 /* TryStatement */: + // span in try block + return spanInBlock(node.tryBlock); + case 208 /* ThrowStatement */: + // span in throw ... + return textSpan(node, node.expression); + case 227 /* ExportAssignment */: + // span on export = id + return textSpan(node, node.expression); + case 221 /* ImportEqualsDeclaration */: + // import statement without including semicolon + return textSpan(node, node.moduleReference); + case 222 /* ImportDeclaration */: + // import statement without including semicolon + return textSpan(node, node.moduleSpecifier); + case 228 /* ExportDeclaration */: + // import statement without including semicolon + return textSpan(node, node.moduleSpecifier); + case 218 /* ModuleDeclaration */: + // span on complete module if it is instantiated + if (ts.getModuleInstanceState(node) !== 1 /* Instantiated */) { + return undefined; + } + case 214 /* ClassDeclaration */: + case 217 /* EnumDeclaration */: + case 247 /* EnumMember */: + case 168 /* CallExpression */: + case 169 /* NewExpression */: + // span on complete node + return textSpan(node); + case 205 /* WithStatement */: + // span in statement + return spanInNode(node.statement); + // No breakpoint in interface, type alias + case 215 /* InterfaceDeclaration */: + case 216 /* TypeAliasDeclaration */: + return undefined; + // Tokens: + case 23 /* SemicolonToken */: + case 1 /* EndOfFileToken */: + return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile)); + case 24 /* CommaToken */: + return spanInPreviousNode(node); + case 15 /* OpenBraceToken */: + return spanInOpenBraceToken(node); + case 16 /* CloseBraceToken */: + return spanInCloseBraceToken(node); + case 17 /* OpenParenToken */: + return spanInOpenParenToken(node); + case 18 /* CloseParenToken */: + return spanInCloseParenToken(node); + case 54 /* ColonToken */: + return spanInColonToken(node); + case 27 /* GreaterThanToken */: + case 25 /* LessThanToken */: + return spanInGreaterThanOrLessThanToken(node); + // Keywords: + case 104 /* WhileKeyword */: + return spanInWhileKeyword(node); + case 80 /* ElseKeyword */: + case 72 /* CatchKeyword */: + case 85 /* FinallyKeyword */: + return spanInNextNode(node); + default: + // If this is name of property assignment, set breakpoint in the initializer + if (node.parent.kind === 245 /* PropertyAssignment */ && node.parent.name === node) { + return spanInNode(node.parent.initializer); + } + // Breakpoint in type assertion goes to its operand + if (node.parent.kind === 171 /* TypeAssertionExpression */ && node.parent.type === node) { + return spanInNode(node.parent.expression); + } + // return type of function go to previous token + if (ts.isFunctionLike(node.parent) && node.parent.type === node) { + return spanInPreviousNode(node); + } + // Default go to parent to set the breakpoint + return spanInNode(node.parent); + } + } + function spanInVariableDeclaration(variableDeclaration) { + // If declaration of for in statement, just set the span in parent + if (variableDeclaration.parent.parent.kind === 200 /* ForInStatement */ || + variableDeclaration.parent.parent.kind === 201 /* ForOfStatement */) { + return spanInNode(variableDeclaration.parent.parent); + } + var isParentVariableStatement = variableDeclaration.parent.parent.kind === 193 /* VariableStatement */; + var isDeclarationOfForStatement = variableDeclaration.parent.parent.kind === 199 /* ForStatement */ && ts.contains(variableDeclaration.parent.parent.initializer.declarations, variableDeclaration); + var declarations = isParentVariableStatement + ? variableDeclaration.parent.parent.declarationList.declarations + : isDeclarationOfForStatement + ? variableDeclaration.parent.parent.initializer.declarations + : undefined; + // Breakpoint is possible in variableDeclaration only if there is initialization + if (variableDeclaration.initializer || (variableDeclaration.flags & 1 /* Export */)) { + if (declarations && declarations[0] === variableDeclaration) { + if (isParentVariableStatement) { + // First declaration - include let keyword + return textSpan(variableDeclaration.parent, variableDeclaration); + } + else { + ts.Debug.assert(isDeclarationOfForStatement); + // Include let keyword from for statement declarations in the span + return textSpan(ts.findPrecedingToken(variableDeclaration.pos, sourceFile, variableDeclaration.parent), variableDeclaration); + } + } + else { + // Span only on this declaration + return textSpan(variableDeclaration); + } + } + else if (declarations && declarations[0] !== variableDeclaration) { + // If we cant set breakpoint on this declaration, set it on previous one + var indexOfCurrentDeclaration = ts.indexOf(declarations, variableDeclaration); + return spanInVariableDeclaration(declarations[indexOfCurrentDeclaration - 1]); + } + } + function canHaveSpanInParameterDeclaration(parameter) { + // Breakpoint is possible on parameter only if it has initializer, is a rest parameter, or has public or private modifier + return !!parameter.initializer || parameter.dotDotDotToken !== undefined || + !!(parameter.flags & 16 /* Public */) || !!(parameter.flags & 32 /* Private */); + } + function spanInParameterDeclaration(parameter) { + if (canHaveSpanInParameterDeclaration(parameter)) { + return textSpan(parameter); + } + else { + var functionDeclaration = parameter.parent; + var indexOfParameter = ts.indexOf(functionDeclaration.parameters, parameter); + if (indexOfParameter) { + // Not a first parameter, go to previous parameter + return spanInParameterDeclaration(functionDeclaration.parameters[indexOfParameter - 1]); + } + else { + // Set breakpoint in the function declaration body + return spanInNode(functionDeclaration.body); + } + } + } + function canFunctionHaveSpanInWholeDeclaration(functionDeclaration) { + return !!(functionDeclaration.flags & 1 /* Export */) || + (functionDeclaration.parent.kind === 214 /* ClassDeclaration */ && functionDeclaration.kind !== 144 /* Constructor */); + } + function spanInFunctionDeclaration(functionDeclaration) { + // No breakpoints in the function signature + if (!functionDeclaration.body) { + return undefined; + } + if (canFunctionHaveSpanInWholeDeclaration(functionDeclaration)) { + // Set the span on whole function declaration + return textSpan(functionDeclaration); + } + // Set span in function body + return spanInNode(functionDeclaration.body); + } + function spanInFunctionBlock(block) { + var nodeForSpanInBlock = block.statements.length ? block.statements[0] : block.getLastToken(); + if (canFunctionHaveSpanInWholeDeclaration(block.parent)) { + return spanInNodeIfStartsOnSameLine(block.parent, nodeForSpanInBlock); + } + return spanInNode(nodeForSpanInBlock); + } + function spanInBlock(block) { + switch (block.parent.kind) { + case 218 /* ModuleDeclaration */: + if (ts.getModuleInstanceState(block.parent) !== 1 /* Instantiated */) { + return undefined; + } + // Set on parent if on same line otherwise on first statement + case 198 /* WhileStatement */: + case 196 /* IfStatement */: + case 200 /* ForInStatement */: + case 201 /* ForOfStatement */: + return spanInNodeIfStartsOnSameLine(block.parent, block.statements[0]); + // Set span on previous token if it starts on same line otherwise on the first statement of the block + case 199 /* ForStatement */: + 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 spanInForStatement(forStatement) { + if (forStatement.initializer) { + if (forStatement.initializer.kind === 212 /* VariableDeclarationList */) { + var variableDeclarationList = forStatement.initializer; + if (variableDeclarationList.declarations.length > 0) { + return spanInNode(variableDeclarationList.declarations[0]); + } + } + else { + return spanInNode(forStatement.initializer); + } + } + if (forStatement.condition) { + return textSpan(forStatement.condition); + } + if (forStatement.incrementor) { + return textSpan(forStatement.incrementor); + } + } + // Tokens: + function spanInOpenBraceToken(node) { + switch (node.parent.kind) { + case 217 /* EnumDeclaration */: + var enumDeclaration = node.parent; + return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), enumDeclaration.members.length ? enumDeclaration.members[0] : enumDeclaration.getLastToken(sourceFile)); + case 214 /* ClassDeclaration */: + var classDeclaration = node.parent; + return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), classDeclaration.members.length ? classDeclaration.members[0] : classDeclaration.getLastToken(sourceFile)); + case 220 /* CaseBlock */: + return spanInNodeIfStartsOnSameLine(node.parent.parent, node.parent.clauses[0]); + } + // Default to parent node + return spanInNode(node.parent); + } + function spanInCloseBraceToken(node) { + switch (node.parent.kind) { + case 219 /* ModuleBlock */: + // If this is not instantiated module block no bp span + if (ts.getModuleInstanceState(node.parent.parent) !== 1 /* Instantiated */) { + return undefined; + } + case 217 /* EnumDeclaration */: + case 214 /* ClassDeclaration */: + // Span on close brace token + return textSpan(node); + case 192 /* Block */: + if (ts.isFunctionBlock(node.parent)) { + // Span on close brace token + return textSpan(node); + } + // fall through. + case 244 /* CatchClause */: + return spanInNode(ts.lastOrUndefined(node.parent.statements)); + ; + case 220 /* CaseBlock */: + // breakpoint in last statement of the last clause + var caseBlock = node.parent; + var lastClause = ts.lastOrUndefined(caseBlock.clauses); + if (lastClause) { + return spanInNode(ts.lastOrUndefined(lastClause.statements)); + } + return undefined; + // Default to parent node + default: + return spanInNode(node.parent); + } + } + function spanInOpenParenToken(node) { + if (node.parent.kind === 197 /* DoStatement */) { + // Go to while keyword and do action instead + return spanInPreviousNode(node); + } + // Default to parent node + return spanInNode(node.parent); + } + function spanInCloseParenToken(node) { + // Is this close paren token of parameter list, set span in previous token + switch (node.parent.kind) { + case 173 /* FunctionExpression */: + case 213 /* FunctionDeclaration */: + case 174 /* ArrowFunction */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: + case 144 /* Constructor */: + case 198 /* WhileStatement */: + case 197 /* DoStatement */: + case 199 /* ForStatement */: + return spanInPreviousNode(node); + // Default to parent node + default: + return spanInNode(node.parent); + } + // Default to parent node + return spanInNode(node.parent); + } + function spanInColonToken(node) { + // Is this : specifying return annotation of the function declaration + if (ts.isFunctionLike(node.parent) || node.parent.kind === 245 /* PropertyAssignment */) { + return spanInPreviousNode(node); + } + return spanInNode(node.parent); + } + function spanInGreaterThanOrLessThanToken(node) { + if (node.parent.kind === 171 /* TypeAssertionExpression */) { + return spanInNode(node.parent.expression); + } + return spanInNode(node.parent); + } + function spanInWhileKeyword(node) { + if (node.parent.kind === 197 /* DoStatement */) { + // Set span on while expression + return textSpan(node, ts.findNextToken(node.parent.expression, node.parent)); + } + // Default to parent node + return spanInNode(node.parent); + } + } + } + BreakpointResolver.spanInSourceFileAtLocation = spanInSourceFileAtLocation; + })(BreakpointResolver = ts.BreakpointResolver || (ts.BreakpointResolver = {})); +})(ts || (ts = {})); +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +/// +/* @internal */ +var debugObjectHost = this; +/* @internal */ +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; + this.lineStartPositions = null; + } + 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); + // TODO: should this be '==='? + 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 scriptSnapshotShim is a COM object then property check becomes method call with no arguments + // 'in' does not have this effect + 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 shimHost is a COM object then property check will become method call with no arguments. + // 'in' does not have this effect. + 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.lookUp(resolutionsInFile, name); + return result ? { resolvedFileName: result } : undefined; + }); + }; + } + } + 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) { + // shimmed host does not support getProjectVersion + return undefined; + } + return this.shimHost.getProjectVersion(); + }; + LanguageServiceShimHostAdapter.prototype.useCaseSensitiveFileNames = function () { + return this.shimHost.useCaseSensitiveFileNames ? this.shimHost.useCaseSensitiveFileNames() : false; + }; + LanguageServiceShimHostAdapter.prototype.getCompilationSettings = function () { + var settingsJson = this.shimHost.getCompilationSettings(); + // TODO: should this be '==='? + if (settingsJson == null || settingsJson == "") { + throw Error("LanguageServiceShimHostAdapter.getCompilationSettings: empty compilationSettings"); + return null; + } + return JSON.parse(settingsJson); + }; + LanguageServiceShimHostAdapter.prototype.getScriptFileNames = function () { + var encoded = this.shimHost.getScriptFileNames(); + return this.files = JSON.parse(encoded); + }; + LanguageServiceShimHostAdapter.prototype.getScriptSnapshot = function (fileName) { + // Shim the API changes for 1.5 release. This should be removed once + // TypeScript 1.5 has shipped. + if (this.files && this.files.indexOf(fileName) < 0) { + return undefined; + } + var scriptSnapshot = this.shimHost.getScriptSnapshot(fileName); + return scriptSnapshot && new ScriptSnapshotShimAdapter(scriptSnapshot); + }; + 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.getDefaultLibFileName = function (options) { + // Wrap the API changes for 1.5 release. This try/catch + // should be removed once TypeScript 1.5 has shipped. + try { + return this.shimHost.getDefaultLibFileName(JSON.stringify(options)); + } + catch (e) { + return ""; + } + }; + return LanguageServiceShimHostAdapter; + })(); + ts.LanguageServiceShimHostAdapter = LanguageServiceShimHostAdapter; + /** A cancellation that throttles calls to the host */ + var ThrottledCancellationToken = (function () { + function ThrottledCancellationToken(hostCancellationToken) { + this.hostCancellationToken = hostCancellationToken; + // Store when we last tried to cancel. Checking cancellation can be expensive (as we have + // to marshall over to the host layer). So we only bother actually checking once enough + // time has passed. + this.lastCancellationCheckTime = 0; + } + ThrottledCancellationToken.prototype.isCancellationRequested = function () { + var time = Date.now(); + var duration = Math.abs(time - this.lastCancellationCheckTime); + if (duration > 10) { + // Check no more than once every 10 ms. + this.lastCancellationCheckTime = time; + return this.hostCancellationToken.isCancellationRequested(); + } + return false; + }; + return ThrottledCancellationToken; + })(); + var CoreServicesShimHostAdapter = (function () { + function CoreServicesShimHostAdapter(shimHost) { + this.shimHost = shimHost; + } + CoreServicesShimHostAdapter.prototype.readDirectory = function (rootDir, extension, exclude) { + // Wrap the API changes for 1.5 release. This try/catch + // should be removed once TypeScript 1.5 has shipped. + // Also consider removing the optional designation for + // the exclude param at this time. + var encoded; + try { + encoded = this.shimHost.readDirectory(rootDir, extension, JSON.stringify(exclude)); + } + catch (e) { + encoded = this.shimHost.readDirectory(rootDir, extension); + } + return JSON.parse(encoded); + }; + CoreServicesShimHostAdapter.prototype.fileExists = function (fileName) { + return this.shimHost.fileExists(fileName); + }; + CoreServicesShimHostAdapter.prototype.readFile = function (fileName) { + return this.shimHost.readFile(fileName); + }; + return CoreServicesShimHostAdapter; + })(); + ts.CoreServicesShimHostAdapter = CoreServicesShimHostAdapter; + function simpleForwardCall(logger, actionDescription, action, logPerformance) { + if (logPerformance) { + logger.log(actionDescription); + var start = Date.now(); + } + var result = action(); + if (logPerformance) { + var end = Date.now(); + 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) { + try { + var result = simpleForwardCall(logger, actionDescription, action, logPerformance); + return JSON.stringify({ 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, + /// TODO: no need for the tolowerCase call + category: ts.DiagnosticCategory[diagnostic.category].toLowerCase(), + code: diagnostic.code + }; + } + 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; + } + LanguageServiceShimObject.prototype.forwardJSONCall = function (actionDescription, action) { + return forwardJSONCall(this.logger, actionDescription, action, this.logPerformance); + }; + /// DISPOSE + /** + * Ensure (almost) deterministic release of internal Javascript resources when + * some external native objects holds onto us (e.g. Com/Interop). + */ + LanguageServiceShimObject.prototype.dispose = function (dummy) { + this.logger.log("dispose()"); + this.languageService.dispose(); + this.languageService = null; + // force a GC + if (debugObjectHost && debugObjectHost.CollectGarbage) { + debugObjectHost.CollectGarbage(); + this.logger.log("CollectGarbage()"); + } + this.logger = null; + _super.prototype.dispose.call(this, dummy); + }; + /// REFRESH + /** + * Update the list of scripts known to the compiler + */ + 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 () { + var classifications = _this.languageService.getSyntacticClassifications(fileName, ts.createTextSpan(start, length)); + return classifications; + }); + }; + LanguageServiceShimObject.prototype.getSemanticClassifications = function (fileName, start, length) { + var _this = this; + return this.forwardJSONCall("getSemanticClassifications('" + fileName + "', " + start + ", " + length + ")", function () { + var classifications = _this.languageService.getSemanticClassifications(fileName, ts.createTextSpan(start, length)); + return classifications; + }); + }; + LanguageServiceShimObject.prototype.getEncodedSyntacticClassifications = function (fileName, start, length) { + var _this = this; + return this.forwardJSONCall("getEncodedSyntacticClassifications('" + fileName + "', " + start + ", " + length + ")", function () { + // directly serialize the spans out to a string. This is much faster to decode + // on the managed side versus a full JSON array. + 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 () { + // directly serialize the spans out to a string. This is much faster to decode + // on the managed side versus a full JSON array. + 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); + }); + }; + /// QUICKINFO + /** + * Computes a string representation of the type at the requested position + * in the active file. + */ + LanguageServiceShimObject.prototype.getQuickInfoAtPosition = function (fileName, position) { + var _this = this; + return this.forwardJSONCall("getQuickInfoAtPosition('" + fileName + "', " + position + ")", function () { + var quickInfo = _this.languageService.getQuickInfoAtPosition(fileName, position); + return quickInfo; + }); + }; + /// NAMEORDOTTEDNAMESPAN + /** + * Computes span information of the name or dotted name at the requested position + * in the active file. + */ + LanguageServiceShimObject.prototype.getNameOrDottedNameSpan = function (fileName, startPos, endPos) { + var _this = this; + return this.forwardJSONCall("getNameOrDottedNameSpan('" + fileName + "', " + startPos + ", " + endPos + ")", function () { + var spanInfo = _this.languageService.getNameOrDottedNameSpan(fileName, startPos, endPos); + return spanInfo; + }); + }; + /** + * STATEMENTSPAN + * Computes span information of statement at the requested position in the active file. + */ + LanguageServiceShimObject.prototype.getBreakpointStatementAtPosition = function (fileName, position) { + var _this = this; + return this.forwardJSONCall("getBreakpointStatementAtPosition('" + fileName + "', " + position + ")", function () { + var spanInfo = _this.languageService.getBreakpointStatementAtPosition(fileName, position); + return spanInfo; + }); + }; + /// SIGNATUREHELP + LanguageServiceShimObject.prototype.getSignatureHelpItems = function (fileName, position) { + var _this = this; + return this.forwardJSONCall("getSignatureHelpItems('" + fileName + "', " + position + ")", function () { + var signatureInfo = _this.languageService.getSignatureHelpItems(fileName, position); + return signatureInfo; + }); + }; + /// GOTO DEFINITION + /** + * Computes the definition location and file for the symbol + * at the requested position. + */ + LanguageServiceShimObject.prototype.getDefinitionAtPosition = function (fileName, position) { + var _this = this; + return this.forwardJSONCall("getDefinitionAtPosition('" + fileName + "', " + position + ")", function () { + return _this.languageService.getDefinitionAtPosition(fileName, position); + }); + }; + /// GOTO Type + /** + * Computes the definition location of the type of the symbol + * at the requested 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.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); + }); + }; + /// GET BRACE MATCHING + LanguageServiceShimObject.prototype.getBraceMatchingAtPosition = function (fileName, position) { + var _this = this; + return this.forwardJSONCall("getBraceMatchingAtPosition('" + fileName + "', " + position + ")", function () { + var textRanges = _this.languageService.getBraceMatchingAtPosition(fileName, position); + return textRanges; + }); + }; + /// GET SMART INDENT + LanguageServiceShimObject.prototype.getIndentationAtPosition = function (fileName, position, options /*Services.EditorOptions*/) { + var _this = this; + return this.forwardJSONCall("getIndentationAtPosition('" + fileName + "', " + position + ")", function () { + var localOptions = JSON.parse(options); + return _this.languageService.getIndentationAtPosition(fileName, position, localOptions); + }); + }; + /// GET REFERENCES + 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)); + // workaround for VS document higlighting issue - keep only items from the initial file + var normalizedName = ts.normalizeSlashes(fileName).toLowerCase(); + return ts.filter(results, function (r) { return ts.normalizeSlashes(r.fileName).toLowerCase() === normalizedName; }); + }); + }; + /// COMPLETION LISTS + /** + * Get a string based representation of the completions + * to provide at the given source position and providing a member completion + * list if requested. + */ + LanguageServiceShimObject.prototype.getCompletionsAtPosition = function (fileName, position) { + var _this = this; + return this.forwardJSONCall("getCompletionsAtPosition('" + fileName + "', " + position + ")", function () { + var completion = _this.languageService.getCompletionsAtPosition(fileName, position); + return completion; + }); + }; + /** Get a string based representation of a completion list entry details */ + LanguageServiceShimObject.prototype.getCompletionEntryDetails = function (fileName, position, entryName) { + var _this = this; + return this.forwardJSONCall("getCompletionEntryDetails('" + fileName + "', " + position + ", " + entryName + ")", function () { + var details = _this.languageService.getCompletionEntryDetails(fileName, position, entryName); + return details; + }); + }; + LanguageServiceShimObject.prototype.getFormattingEditsForRange = function (fileName, start, end, options /*Services.FormatCodeOptions*/) { + var _this = this; + return this.forwardJSONCall("getFormattingEditsForRange('" + fileName + "', " + start + ", " + end + ")", function () { + var localOptions = JSON.parse(options); + var edits = _this.languageService.getFormattingEditsForRange(fileName, start, end, localOptions); + return edits; + }); + }; + LanguageServiceShimObject.prototype.getFormattingEditsForDocument = function (fileName, options /*Services.FormatCodeOptions*/) { + var _this = this; + return this.forwardJSONCall("getFormattingEditsForDocument('" + fileName + "')", function () { + var localOptions = JSON.parse(options); + var edits = _this.languageService.getFormattingEditsForDocument(fileName, localOptions); + return edits; + }); + }; + LanguageServiceShimObject.prototype.getFormattingEditsAfterKeystroke = function (fileName, position, key, options /*Services.FormatCodeOptions*/) { + var _this = this; + return this.forwardJSONCall("getFormattingEditsAfterKeystroke('" + fileName + "', " + position + ", '" + key + "')", function () { + var localOptions = JSON.parse(options); + var edits = _this.languageService.getFormattingEditsAfterKeystroke(fileName, position, key, localOptions); + return edits; + }); + }; + LanguageServiceShimObject.prototype.getDocCommentTemplateAtPosition = function (fileName, position) { + var _this = this; + return this.forwardJSONCall("getDocCommentTemplateAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getDocCommentTemplateAtPosition(fileName, position); }); + }; + /// NAVIGATE TO + /** Return a list of symbols that are interesting to navigate to */ + LanguageServiceShimObject.prototype.getNavigateToItems = function (searchValue, maxResultCount) { + var _this = this; + return this.forwardJSONCall("getNavigateToItems('" + searchValue + "', " + maxResultCount + ")", function () { + var items = _this.languageService.getNavigateToItems(searchValue, maxResultCount); + return items; + }); + }; + LanguageServiceShimObject.prototype.getNavigationBarItems = function (fileName) { + var _this = this; + return this.forwardJSONCall("getNavigationBarItems('" + fileName + "')", function () { + var items = _this.languageService.getNavigationBarItems(fileName); + return items; + }); + }; + LanguageServiceShimObject.prototype.getOutliningSpans = function (fileName) { + var _this = this; + return this.forwardJSONCall("getOutliningSpans('" + fileName + "')", function () { + var items = _this.languageService.getOutliningSpans(fileName); + return items; + }); + }; + LanguageServiceShimObject.prototype.getTodoComments = function (fileName, descriptors) { + var _this = this; + return this.forwardJSONCall("getTodoComments('" + fileName + "')", function () { + var items = _this.languageService.getTodoComments(fileName, JSON.parse(descriptors)); + return items; + }); + }; + /// Emit + LanguageServiceShimObject.prototype.getEmitOutput = function (fileName) { + var _this = this; + return this.forwardJSONCall("getEmitOutput('" + fileName + "')", function () { + var output = _this.languageService.getEmitOutput(fileName); + // Shim the API changes for 1.5 release. This should be removed once + // TypeScript 1.5 has shipped. + output.emitOutputStatus = output.emitSkipped ? 1 : 0; + return output; + }); + }; + 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) { + _super.call(this, factory); + this.logger = logger; + this.logPerformance = false; + this.classifier = ts.createClassifier(); + } + 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); + }; + /// COLORIZATION + ClassifierShimObject.prototype.getClassificationsForLine = function (text, lexState, classifyKeywordsInGenerics) { + var classification = this.classifier.getClassificationsForLine(text, lexState, classifyKeywordsInGenerics); + var items = classification.entries; + var result = ""; + for (var i = 0; i < items.length; i++) { + result += items[i].length + "\n"; + result += items[i].classification + "\n"; + } + result += classification.finalLexState; + return result; + }; + return ClassifierShimObject; + })(ShimBase); + 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; + } + 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.getPreProcessedFileInfo = function (fileName, sourceTextSnapshot) { + return this.forwardJSONCall("getPreProcessedFileInfo('" + fileName + "')", function () { + var result = ts.preProcessFile(sourceTextSnapshot.getText(0, sourceTextSnapshot.getLength())); + var convertResult = { + referencedFiles: [], + importedFiles: [], + ambientExternalModules: result.ambientExternalModules, + isLibFile: result.isLibFile + }; + ts.forEach(result.referencedFiles, function (refFile) { + convertResult.referencedFiles.push({ + path: ts.normalizePath(refFile.fileName), + position: refFile.pos, + length: refFile.end - refFile.pos + }); + }); + ts.forEach(result.importedFiles, function (importedFile) { + convertResult.importedFiles.push({ + path: ts.normalizeSlashes(importedFile.fileName), + position: importedFile.pos, + length: importedFile.end - importedFile.pos + }); + }); + return convertResult; + }); + }; + 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: {}, + files: [], + errors: [realizeDiagnostic(result.error, '\r\n')] + }; + } + var configFile = ts.parseJsonConfigFileContent(result.config, _this.host, ts.getDirectoryPath(ts.normalizeSlashes(fileName))); + return { + options: configFile.options, + files: configFile.fileNames, + errors: realizeDiagnostics(configFile.errors, '\r\n') + }; + }); + }; + CoreServicesShimObject.prototype.getDefaultCompilationSettings = function () { + return this.forwardJSONCall("getDefaultCompilationSettings()", function () { + return ts.getDefaultCompilerOptions(); + }); + }; + return CoreServicesShimObject; + })(ShimBase); + var TypeScriptServicesFactory = (function () { + function TypeScriptServicesFactory() { + this._shims = []; + } + /* + * Returns script API version. + */ + 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()); + } + 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 () { + // Forget all the registered shims + this._shims = []; + this.documentRegistry = ts.createDocumentRegistry(); + }; + 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 = {})); +/// TODO: this is used by VS, clean this up on both sides of the interface +/* @internal */ +var TypeScript; +(function (TypeScript) { + var Services; + (function (Services) { + Services.TypeScriptServicesFactory = ts.TypeScriptServicesFactory; + })(Services = TypeScript.Services || (TypeScript.Services = {})); +})(TypeScript || (TypeScript = {})); +/* @internal */ +var toolsVersion = "1.6"; diff --git a/lib/typescriptServices.d.ts b/lib/typescriptServices.d.ts index 737ff7ab639..badaff1c3e2 100644 --- a/lib/typescriptServices.d.ts +++ b/lib/typescriptServices.d.ts @@ -13,2158 +13,2160 @@ See the Apache Version 2.0 License for specific language governing permissions and limitations under the License. ***************************************************************************** */ -declare namespace ts { - interface Map { - [index: string]: T; - } - interface FileMap { - get(fileName: string): T; - set(fileName: string, value: T): void; - contains(fileName: string): boolean; - remove(fileName: string): void; - forEachValue(f: (v: T) => void): void; - clear(): void; - } - interface TextRange { - pos: number; - end: number; - } - const enum SyntaxKind { - Unknown = 0, - EndOfFileToken = 1, - SingleLineCommentTrivia = 2, - MultiLineCommentTrivia = 3, - NewLineTrivia = 4, - WhitespaceTrivia = 5, - ShebangTrivia = 6, - 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, - RequireKeyword = 127, - NumberKeyword = 128, - SetKeyword = 129, - StringKeyword = 130, - SymbolKeyword = 131, - TypeKeyword = 132, - FromKeyword = 133, - OfKeyword = 134, - QualifiedName = 135, - ComputedPropertyName = 136, - TypeParameter = 137, - Parameter = 138, - Decorator = 139, - PropertySignature = 140, - PropertyDeclaration = 141, - MethodSignature = 142, - MethodDeclaration = 143, - Constructor = 144, - GetAccessor = 145, - SetAccessor = 146, - CallSignature = 147, - ConstructSignature = 148, - IndexSignature = 149, - TypePredicate = 150, - TypeReference = 151, - FunctionType = 152, - ConstructorType = 153, - TypeQuery = 154, - TypeLiteral = 155, - ArrayType = 156, - TupleType = 157, - UnionType = 158, - IntersectionType = 159, - ParenthesizedType = 160, - ObjectBindingPattern = 161, - ArrayBindingPattern = 162, - BindingElement = 163, - ArrayLiteralExpression = 164, - ObjectLiteralExpression = 165, - PropertyAccessExpression = 166, - ElementAccessExpression = 167, - CallExpression = 168, - NewExpression = 169, - TaggedTemplateExpression = 170, - TypeAssertionExpression = 171, - ParenthesizedExpression = 172, - FunctionExpression = 173, - ArrowFunction = 174, - DeleteExpression = 175, - TypeOfExpression = 176, - VoidExpression = 177, - AwaitExpression = 178, - PrefixUnaryExpression = 179, - PostfixUnaryExpression = 180, - BinaryExpression = 181, - ConditionalExpression = 182, - TemplateExpression = 183, - YieldExpression = 184, - SpreadElementExpression = 185, - ClassExpression = 186, - OmittedExpression = 187, - ExpressionWithTypeArguments = 188, - AsExpression = 189, - TemplateSpan = 190, - SemicolonClassElement = 191, - Block = 192, - VariableStatement = 193, - EmptyStatement = 194, - ExpressionStatement = 195, - IfStatement = 196, - DoStatement = 197, - WhileStatement = 198, - ForStatement = 199, - ForInStatement = 200, - ForOfStatement = 201, - ContinueStatement = 202, - BreakStatement = 203, - ReturnStatement = 204, - WithStatement = 205, - SwitchStatement = 206, - LabeledStatement = 207, - ThrowStatement = 208, - TryStatement = 209, - DebuggerStatement = 210, - VariableDeclaration = 211, - VariableDeclarationList = 212, - FunctionDeclaration = 213, - ClassDeclaration = 214, - InterfaceDeclaration = 215, - TypeAliasDeclaration = 216, - EnumDeclaration = 217, - ModuleDeclaration = 218, - ModuleBlock = 219, - CaseBlock = 220, - ImportEqualsDeclaration = 221, - ImportDeclaration = 222, - ImportClause = 223, - NamespaceImport = 224, - NamedImports = 225, - ImportSpecifier = 226, - ExportAssignment = 227, - ExportDeclaration = 228, - NamedExports = 229, - ExportSpecifier = 230, - MissingDeclaration = 231, - ExternalModuleReference = 232, - JsxElement = 233, - JsxSelfClosingElement = 234, - JsxOpeningElement = 235, - JsxText = 236, - JsxClosingElement = 237, - JsxAttribute = 238, - JsxSpreadAttribute = 239, - JsxExpression = 240, - CaseClause = 241, - DefaultClause = 242, - HeritageClause = 243, - CatchClause = 244, - PropertyAssignment = 245, - ShorthandPropertyAssignment = 246, - EnumMember = 247, - SourceFile = 248, - JSDocTypeExpression = 249, - JSDocAllType = 250, - JSDocUnknownType = 251, - JSDocArrayType = 252, - JSDocUnionType = 253, - JSDocTupleType = 254, - JSDocNullableType = 255, - JSDocNonNullableType = 256, - JSDocRecordType = 257, - JSDocRecordMember = 258, - JSDocTypeReference = 259, - JSDocOptionalType = 260, - JSDocFunctionType = 261, - JSDocVariadicType = 262, - JSDocConstructorType = 263, - JSDocThisType = 264, - JSDocComment = 265, - JSDocTag = 266, - JSDocParameterTag = 267, - JSDocReturnTag = 268, - JSDocTypeTag = 269, - JSDocTemplateTag = 270, - SyntaxList = 271, - Count = 272, - FirstAssignment = 56, - LastAssignment = 68, - FirstReservedWord = 70, - LastReservedWord = 105, - FirstKeyword = 70, - LastKeyword = 134, - FirstFutureReservedWord = 106, - LastFutureReservedWord = 114, - FirstTypeNode = 151, - LastTypeNode = 160, - FirstPunctuation = 15, - LastPunctuation = 68, - FirstToken = 0, - LastToken = 134, - FirstTriviaToken = 2, - LastTriviaToken = 7, - FirstLiteralToken = 8, - LastLiteralToken = 11, - FirstTemplateToken = 11, - LastTemplateToken = 14, - FirstBinaryOperator = 25, - LastBinaryOperator = 68, - FirstNode = 135, - } - const enum NodeFlags { - None = 0, - Export = 1, - Ambient = 2, - Public = 16, - Private = 32, - Protected = 64, - Static = 128, - Abstract = 256, - Async = 512, - Default = 1024, - MultiLine = 2048, - Synthetic = 4096, - DeclarationFile = 8192, - Let = 16384, - Const = 32768, - OctalLiteral = 65536, - Namespace = 131072, - ExportContext = 262144, - ContainsThis = 524288, - Modifier = 2035, - AccessibilityModifier = 112, - BlockScoped = 49152, - } - const enum JsxFlags { - None = 0, - IntrinsicNamedElement = 1, - IntrinsicIndexedElement = 2, - ClassElement = 4, - UnknownElement = 8, - IntrinsicElement = 3, - } - interface Node extends TextRange { - kind: SyntaxKind; - flags: NodeFlags; - decorators?: NodeArray; - modifiers?: ModifiersArray; - parent?: Node; - } - interface NodeArray extends Array, TextRange { - hasTrailingComma?: boolean; - } - interface ModifiersArray extends NodeArray { - flags: number; - } - interface Identifier extends PrimaryExpression { - text: string; - originalKeywordKind?: SyntaxKind; - } - interface QualifiedName extends Node { - left: EntityName; - right: Identifier; - } - type EntityName = Identifier | QualifiedName; - type DeclarationName = Identifier | LiteralExpression | ComputedPropertyName | BindingPattern; - interface Declaration extends Node { - _declarationBrand: any; - name?: DeclarationName; - } - interface ComputedPropertyName extends Node { - expression: Expression; - } - interface Decorator extends Node { - expression: LeftHandSideExpression; - } - interface TypeParameterDeclaration extends Declaration { - name: Identifier; - constraint?: TypeNode; - expression?: Expression; - } - interface SignatureDeclaration extends Declaration { - typeParameters?: NodeArray; - parameters: NodeArray; - type?: TypeNode; - } - interface VariableDeclaration extends Declaration { - parent?: VariableDeclarationList; - name: Identifier | BindingPattern; - type?: TypeNode; - initializer?: Expression; - } - interface VariableDeclarationList extends Node { - declarations: NodeArray; - } - interface ParameterDeclaration extends Declaration { - dotDotDotToken?: Node; - name: Identifier | BindingPattern; - questionToken?: Node; - type?: TypeNode; - initializer?: Expression; - } - interface BindingElement extends Declaration { - propertyName?: Identifier; - dotDotDotToken?: Node; - name: Identifier | BindingPattern; - initializer?: Expression; - } - interface PropertyDeclaration extends Declaration, ClassElement { - name: DeclarationName; - questionToken?: Node; - type?: TypeNode; - initializer?: Expression; - } - interface ObjectLiteralElement extends Declaration { - _objectLiteralBrandBrand: any; - } - interface PropertyAssignment extends ObjectLiteralElement { - _propertyAssignmentBrand: any; - name: DeclarationName; - questionToken?: Node; - initializer: Expression; - } - interface ShorthandPropertyAssignment extends ObjectLiteralElement { - name: Identifier; - questionToken?: Node; - equalsToken?: Node; - objectAssignmentInitializer?: Expression; - } - interface VariableLikeDeclaration extends Declaration { - propertyName?: Identifier; - dotDotDotToken?: Node; - name: DeclarationName; - questionToken?: Node; - type?: TypeNode; - initializer?: Expression; - } - interface BindingPattern extends Node { - elements: NodeArray; - } - /** - * Several node kinds share function-like features such as a signature, - * a name, and a body. These nodes should extend FunctionLikeDeclaration. - * Examples: - * - FunctionDeclaration - * - MethodDeclaration - * - AccessorDeclaration - */ - interface FunctionLikeDeclaration extends SignatureDeclaration { - _functionLikeDeclarationBrand: any; - asteriskToken?: Node; - questionToken?: Node; - body?: Block | Expression; - } - interface FunctionDeclaration extends FunctionLikeDeclaration, Statement { - name?: Identifier; - body?: Block; - } - interface MethodDeclaration extends FunctionLikeDeclaration, ClassElement, ObjectLiteralElement { - body?: Block; - } - interface ConstructorDeclaration extends FunctionLikeDeclaration, ClassElement { - body?: Block; - } - interface SemicolonClassElement extends ClassElement { - _semicolonClassElementBrand: any; - } - interface AccessorDeclaration extends FunctionLikeDeclaration, ClassElement, ObjectLiteralElement { - _accessorDeclarationBrand: any; - body: Block; - } - interface IndexSignatureDeclaration extends SignatureDeclaration, ClassElement { - _indexSignatureDeclarationBrand: any; - } - interface TypeNode extends Node { - _typeNodeBrand: any; - } - interface FunctionOrConstructorTypeNode extends TypeNode, SignatureDeclaration { - _functionOrConstructorTypeNodeBrand: any; - } - interface TypeReferenceNode extends TypeNode { - typeName: EntityName; - typeArguments?: NodeArray; - } - interface TypePredicateNode extends TypeNode { - parameterName: Identifier; - type: TypeNode; - } - interface TypeQueryNode extends TypeNode { - exprName: EntityName; - } - interface TypeLiteralNode extends TypeNode, Declaration { - members: NodeArray; - } - interface ArrayTypeNode extends TypeNode { - elementType: TypeNode; - } - interface TupleTypeNode extends TypeNode { - elementTypes: NodeArray; - } - interface UnionOrIntersectionTypeNode extends TypeNode { - types: NodeArray; - } - interface UnionTypeNode extends UnionOrIntersectionTypeNode { - } - interface IntersectionTypeNode extends UnionOrIntersectionTypeNode { - } - interface ParenthesizedTypeNode extends TypeNode { - type: TypeNode; - } - interface StringLiteral extends LiteralExpression, TypeNode { - _stringLiteralBrand: any; - } - interface Expression extends Node { - _expressionBrand: any; - contextualType?: Type; - } - interface UnaryExpression extends Expression { - _unaryExpressionBrand: any; - } - interface IncrementExpression extends UnaryExpression { - _incrementExpressionBrand: any; - } - interface PrefixUnaryExpression extends IncrementExpression { - operator: SyntaxKind; - operand: UnaryExpression; - } - interface PostfixUnaryExpression extends IncrementExpression { - operand: LeftHandSideExpression; - operator: SyntaxKind; - } - interface PostfixExpression extends UnaryExpression { - _postfixExpressionBrand: any; - } - interface LeftHandSideExpression extends IncrementExpression { - _leftHandSideExpressionBrand: any; - } - interface MemberExpression extends LeftHandSideExpression { - _memberExpressionBrand: any; - } - interface PrimaryExpression extends MemberExpression { - _primaryExpressionBrand: any; - } - interface DeleteExpression extends UnaryExpression { - expression: UnaryExpression; - } - interface TypeOfExpression extends UnaryExpression { - expression: UnaryExpression; - } - interface VoidExpression extends UnaryExpression { - expression: UnaryExpression; - } - interface AwaitExpression extends UnaryExpression { - expression: UnaryExpression; - } - interface YieldExpression extends Expression { - asteriskToken?: Node; - expression?: Expression; - } - interface BinaryExpression extends Expression { - left: Expression; - operatorToken: Node; - right: Expression; - } - interface ConditionalExpression extends Expression { - condition: Expression; - questionToken: Node; - whenTrue: Expression; - colonToken: Node; - whenFalse: Expression; - } - interface FunctionExpression extends PrimaryExpression, FunctionLikeDeclaration { - name?: Identifier; - body: Block | Expression; - } - interface ArrowFunction extends Expression, FunctionLikeDeclaration { - equalsGreaterThanToken: Node; - } - interface LiteralExpression extends PrimaryExpression { - text: string; - isUnterminated?: boolean; - hasExtendedUnicodeEscape?: boolean; - } - interface TemplateExpression extends PrimaryExpression { - head: LiteralExpression; - templateSpans: NodeArray; - } - interface TemplateSpan extends Node { - expression: Expression; - literal: LiteralExpression; - } - interface ParenthesizedExpression extends PrimaryExpression { - expression: Expression; - } - interface ArrayLiteralExpression extends PrimaryExpression { - elements: NodeArray; - } - interface SpreadElementExpression extends Expression { - expression: Expression; - } - interface ObjectLiteralExpression extends PrimaryExpression, Declaration { - properties: NodeArray; - } - interface PropertyAccessExpression extends MemberExpression { - expression: LeftHandSideExpression; - dotToken: Node; - name: Identifier; - } - interface ElementAccessExpression extends MemberExpression { - expression: LeftHandSideExpression; - argumentExpression?: Expression; - } - interface CallExpression extends LeftHandSideExpression { - expression: LeftHandSideExpression; - typeArguments?: NodeArray; - arguments: NodeArray; - } - interface ExpressionWithTypeArguments extends TypeNode { - expression: LeftHandSideExpression; - typeArguments?: NodeArray; - } - interface NewExpression extends CallExpression, PrimaryExpression { - } - interface TaggedTemplateExpression extends MemberExpression { - tag: LeftHandSideExpression; - template: LiteralExpression | TemplateExpression; - } - type CallLikeExpression = CallExpression | NewExpression | TaggedTemplateExpression | Decorator; - interface AsExpression extends Expression { - expression: Expression; - type: TypeNode; - } - interface TypeAssertion extends UnaryExpression { - type: TypeNode; - expression: UnaryExpression; - } - type AssertionExpression = TypeAssertion | AsExpression; - interface JsxElement extends PrimaryExpression { - openingElement: JsxOpeningElement; - children: NodeArray; - closingElement: JsxClosingElement; - } - interface JsxOpeningElement extends Expression { - _openingElementBrand?: any; - tagName: EntityName; - attributes: NodeArray; - } - interface JsxSelfClosingElement extends PrimaryExpression, JsxOpeningElement { - _selfClosingElementBrand?: any; - } - type JsxOpeningLikeElement = JsxSelfClosingElement | JsxOpeningElement; - interface JsxAttribute extends Node { - name: Identifier; - initializer?: Expression; - } - interface JsxSpreadAttribute extends Node { - expression: Expression; - } - interface JsxClosingElement extends Node { - tagName: EntityName; - } - interface JsxExpression extends Expression { - expression?: Expression; - } - interface JsxText extends Node { - _jsxTextExpressionBrand: any; - } - type JsxChild = JsxText | JsxExpression | JsxElement | JsxSelfClosingElement; - interface Statement extends Node { - _statementBrand: any; - } - interface Block extends Statement { - statements: NodeArray; - } - interface VariableStatement extends Statement { - declarationList: VariableDeclarationList; - } - interface ExpressionStatement extends Statement { - expression: Expression; - } - interface IfStatement extends Statement { - expression: Expression; - thenStatement: Statement; - elseStatement?: Statement; - } - interface IterationStatement extends Statement { - statement: Statement; - } - interface DoStatement extends IterationStatement { - expression: Expression; - } - interface WhileStatement extends IterationStatement { - expression: Expression; - } - interface ForStatement extends IterationStatement { - initializer?: VariableDeclarationList | Expression; - condition?: Expression; - incrementor?: Expression; - } - interface ForInStatement extends IterationStatement { - initializer: VariableDeclarationList | Expression; - expression: Expression; - } - interface ForOfStatement extends IterationStatement { - initializer: VariableDeclarationList | Expression; - expression: Expression; - } - interface BreakOrContinueStatement extends Statement { - label?: Identifier; - } - interface ReturnStatement extends Statement { - expression?: Expression; - } - interface WithStatement extends Statement { - expression: Expression; - statement: Statement; - } - interface SwitchStatement extends Statement { - expression: Expression; - caseBlock: CaseBlock; - } - interface CaseBlock extends Node { - clauses: NodeArray; - } - interface CaseClause extends Node { - expression?: Expression; - statements: NodeArray; - } - interface DefaultClause extends Node { - statements: NodeArray; - } - type CaseOrDefaultClause = CaseClause | DefaultClause; - interface LabeledStatement extends Statement { - label: Identifier; - statement: Statement; - } - interface ThrowStatement extends Statement { - expression: Expression; - } - interface TryStatement extends Statement { - tryBlock: Block; - catchClause?: CatchClause; - finallyBlock?: Block; - } - interface CatchClause extends Node { - variableDeclaration: VariableDeclaration; - block: Block; - } - interface ClassLikeDeclaration extends Declaration { - name?: Identifier; - typeParameters?: NodeArray; - heritageClauses?: NodeArray; - members: NodeArray; - } - interface ClassDeclaration extends ClassLikeDeclaration, Statement { - } - interface ClassExpression extends ClassLikeDeclaration, PrimaryExpression { - } - interface ClassElement extends Declaration { - _classElementBrand: any; - } - interface InterfaceDeclaration extends Declaration, Statement { - name: Identifier; - typeParameters?: NodeArray; - heritageClauses?: NodeArray; - members: NodeArray; - } - interface HeritageClause extends Node { - token: SyntaxKind; - types?: NodeArray; - } - interface TypeAliasDeclaration extends Declaration, Statement { - name: Identifier; - typeParameters?: NodeArray; - type: TypeNode; - } - interface EnumMember extends Declaration { - name: DeclarationName; - initializer?: Expression; - } - interface EnumDeclaration extends Declaration, Statement { - name: Identifier; - members: NodeArray; - } - interface ModuleDeclaration extends Declaration, Statement { - name: Identifier | LiteralExpression; - body: ModuleBlock | ModuleDeclaration; - } - interface ModuleBlock extends Node, Statement { - statements: NodeArray; - } - interface ImportEqualsDeclaration extends Declaration, Statement { - name: Identifier; - moduleReference: EntityName | ExternalModuleReference; - } - interface ExternalModuleReference extends Node { - expression?: Expression; - } - interface ImportDeclaration extends Statement { - importClause?: ImportClause; - moduleSpecifier: Expression; - } - interface ImportClause extends Declaration { - name?: Identifier; - namedBindings?: NamespaceImport | NamedImports; - } - interface NamespaceImport extends Declaration { - name: Identifier; - } - interface ExportDeclaration extends Declaration, Statement { - exportClause?: NamedExports; - moduleSpecifier?: Expression; - } - interface NamedImportsOrExports extends Node { - elements: NodeArray; - } - type NamedImports = NamedImportsOrExports; - type NamedExports = NamedImportsOrExports; - interface ImportOrExportSpecifier extends Declaration { - propertyName?: Identifier; - name: Identifier; - } - type ImportSpecifier = ImportOrExportSpecifier; - type ExportSpecifier = ImportOrExportSpecifier; - interface ExportAssignment extends Declaration, Statement { - isExportEquals?: boolean; - expression: Expression; - } - interface FileReference extends TextRange { - fileName: string; - } - interface CommentRange extends TextRange { - hasTrailingNewLine?: boolean; - kind: SyntaxKind; - } - interface JSDocTypeExpression extends Node { - type: JSDocType; - } - interface JSDocType extends TypeNode { - _jsDocTypeBrand: any; - } - interface JSDocAllType extends JSDocType { - _JSDocAllTypeBrand: any; - } - interface JSDocUnknownType extends JSDocType { - _JSDocUnknownTypeBrand: any; - } - interface JSDocArrayType extends JSDocType { - elementType: JSDocType; - } - interface JSDocUnionType extends JSDocType { - types: NodeArray; - } - interface JSDocTupleType extends JSDocType { - types: NodeArray; - } - interface JSDocNonNullableType extends JSDocType { - type: JSDocType; - } - interface JSDocNullableType extends JSDocType { - type: JSDocType; - } - interface JSDocRecordType extends JSDocType, TypeLiteralNode { - members: NodeArray; - } - interface JSDocTypeReference extends JSDocType { - name: EntityName; - typeArguments: NodeArray; - } - interface JSDocOptionalType extends JSDocType { - type: JSDocType; - } - interface JSDocFunctionType extends JSDocType, SignatureDeclaration { - parameters: NodeArray; - type: JSDocType; - } - interface JSDocVariadicType extends JSDocType { - type: JSDocType; - } - interface JSDocConstructorType extends JSDocType { - type: JSDocType; - } - interface JSDocThisType extends JSDocType { - type: JSDocType; - } - interface JSDocRecordMember extends PropertyDeclaration { - name: Identifier | LiteralExpression; - type?: JSDocType; - } - interface JSDocComment extends Node { - tags: NodeArray; - } - interface JSDocTag extends Node { - atToken: Node; - tagName: Identifier; - } - interface JSDocTemplateTag extends JSDocTag { - typeParameters: NodeArray; - } - interface JSDocReturnTag extends JSDocTag { - typeExpression: JSDocTypeExpression; - } - interface JSDocTypeTag extends JSDocTag { - typeExpression: JSDocTypeExpression; - } - interface JSDocParameterTag extends JSDocTag { - preParameterName?: Identifier; - typeExpression?: JSDocTypeExpression; - postParameterName?: Identifier; - isBracketed: boolean; - } - interface SourceFile extends Declaration { - statements: NodeArray; - endOfFileToken: Node; - fileName: string; - text: string; - amdDependencies: { - path: string; - name: string; - }[]; - moduleName: string; - referencedFiles: FileReference[]; - languageVariant: LanguageVariant; - /** - * lib.d.ts should have a reference comment like - * - * /// - * - * If any other file has this comment, it signals not to include lib.d.ts - * because this containing file is intended to act as a default library. - */ - hasNoDefaultLib: boolean; - languageVersion: ScriptTarget; - } - interface ScriptReferenceHost { - getCompilerOptions(): CompilerOptions; - getSourceFile(fileName: string): SourceFile; - getCurrentDirectory(): string; - } - interface ParseConfigHost { - readDirectory(rootDir: string, extension: string, exclude: string[]): string[]; - } - interface WriteFileCallback { - (fileName: string, data: string, writeByteOrderMark: boolean, onError?: (message: string) => void): void; - } - class OperationCanceledException { - } - interface CancellationToken { - isCancellationRequested(): boolean; - /** @throws OperationCanceledException if isCancellationRequested is true */ - throwIfCancellationRequested(): void; - } - interface Program extends ScriptReferenceHost { - /** - * Get a list of root file names that were passed to a 'createProgram' - */ - getRootFileNames(): string[]; - /** - * Get a list of files in the program - */ - getSourceFiles(): SourceFile[]; - /** - * Emits the JavaScript and declaration files. If targetSourceFile is not specified, then - * the JavaScript and declaration files will be produced for all the files in this program. - * If targetSourceFile is specified, then only the JavaScript and declaration for that - * specific file will be generated. - * - * If writeFile is not specified then the writeFile callback from the compiler host will be - * used for writing the JavaScript and declaration files. Otherwise, the writeFile parameter - * will be invoked when writing the JavaScript and declaration files. - */ - emit(targetSourceFile?: SourceFile, writeFile?: WriteFileCallback, cancellationToken?: CancellationToken): EmitResult; - getOptionsDiagnostics(cancellationToken?: CancellationToken): Diagnostic[]; - getGlobalDiagnostics(cancellationToken?: CancellationToken): Diagnostic[]; - getSyntacticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): Diagnostic[]; - getSemanticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): Diagnostic[]; - getDeclarationDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): Diagnostic[]; - /** - * Gets a type checker that can be used to semantically analyze source fils in the program. - */ - getTypeChecker(): TypeChecker; - } - interface SourceMapSpan { - /** Line number in the .js file. */ - emittedLine: number; - /** Column number in the .js file. */ - emittedColumn: number; - /** Line number in the .ts file. */ - sourceLine: number; - /** Column number in the .ts file. */ - sourceColumn: number; - /** Optional name (index into names array) associated with this span. */ - nameIndex?: number; - /** .ts file (index into sources array) associated with this span */ - sourceIndex: number; - } - interface SourceMapData { - sourceMapFilePath: string; - jsSourceMappingURL: string; - sourceMapFile: string; - sourceMapSourceRoot: string; - sourceMapSources: string[]; - sourceMapSourcesContent?: string[]; - inputSourceFileNames: string[]; - sourceMapNames?: string[]; - sourceMapMappings: string; - sourceMapDecodedMappings: SourceMapSpan[]; - } - /** Return code used by getEmitOutput function to indicate status of the function */ - enum ExitStatus { - Success = 0, - DiagnosticsPresent_OutputsSkipped = 1, - DiagnosticsPresent_OutputsGenerated = 2, - } - interface EmitResult { - emitSkipped: boolean; - diagnostics: Diagnostic[]; - } - interface TypeChecker { - getTypeOfSymbolAtLocation(symbol: Symbol, node: Node): Type; - getDeclaredTypeOfSymbol(symbol: Symbol): Type; - getPropertiesOfType(type: Type): Symbol[]; - getPropertyOfType(type: Type, propertyName: string): Symbol; - getSignaturesOfType(type: Type, kind: SignatureKind): Signature[]; - getIndexTypeOfType(type: Type, kind: IndexKind): Type; - getBaseTypes(type: InterfaceType): ObjectType[]; - getReturnTypeOfSignature(signature: Signature): Type; - getSymbolsInScope(location: Node, meaning: SymbolFlags): Symbol[]; - getSymbolAtLocation(node: Node): Symbol; - getShorthandAssignmentValueSymbol(location: Node): Symbol; - getTypeAtLocation(node: Node): Type; - typeToString(type: Type, enclosingDeclaration?: Node, flags?: TypeFormatFlags): string; - symbolToString(symbol: Symbol, enclosingDeclaration?: Node, meaning?: SymbolFlags): string; - getSymbolDisplayBuilder(): SymbolDisplayBuilder; - getFullyQualifiedName(symbol: Symbol): string; - getAugmentedPropertiesOfType(type: Type): Symbol[]; - getRootSymbols(symbol: Symbol): Symbol[]; - getContextualType(node: Expression): Type; - getResolvedSignature(node: CallLikeExpression, candidatesOutArray?: Signature[]): Signature; - getSignatureFromDeclaration(declaration: SignatureDeclaration): Signature; - isImplementationOfOverload(node: FunctionLikeDeclaration): boolean; - isUndefinedSymbol(symbol: Symbol): boolean; - isArgumentsSymbol(symbol: Symbol): boolean; - getConstantValue(node: EnumMember | PropertyAccessExpression | ElementAccessExpression): number; - isValidPropertyAccess(node: PropertyAccessExpression | QualifiedName, propertyName: string): boolean; - getAliasedSymbol(symbol: Symbol): Symbol; - getExportsOfModule(moduleSymbol: Symbol): Symbol[]; - getJsxElementAttributesType(elementNode: JsxOpeningLikeElement): Type; - getJsxIntrinsicTagNames(): Symbol[]; - isOptionalParameter(node: ParameterDeclaration): boolean; - } - interface SymbolDisplayBuilder { - buildTypeDisplay(type: Type, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; - buildSymbolDisplay(symbol: Symbol, writer: SymbolWriter, enclosingDeclaration?: Node, meaning?: SymbolFlags, flags?: SymbolFormatFlags): void; - buildSignatureDisplay(signatures: Signature, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; - buildParameterDisplay(parameter: Symbol, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; - buildTypeParameterDisplay(tp: TypeParameter, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; - buildTypeParameterDisplayFromSymbol(symbol: Symbol, writer: SymbolWriter, enclosingDeclaraiton?: Node, flags?: TypeFormatFlags): void; - buildDisplayForParametersAndDelimiters(parameters: Symbol[], writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; - buildDisplayForTypeParametersAndDelimiters(typeParameters: TypeParameter[], writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; - buildReturnTypeDisplay(signature: Signature, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; - } - interface SymbolWriter { - writeKeyword(text: string): void; - writeOperator(text: string): void; - writePunctuation(text: string): void; - writeSpace(text: string): void; - writeStringLiteral(text: string): void; - writeParameter(text: string): void; - writeSymbol(text: string, symbol: Symbol): void; - writeLine(): void; - increaseIndent(): void; - decreaseIndent(): void; - clear(): void; - trackSymbol(symbol: Symbol, enclosingDeclaration?: Node, meaning?: SymbolFlags): void; - reportInaccessibleThisError(): void; - } - const enum TypeFormatFlags { - None = 0, - WriteArrayAsGenericType = 1, - UseTypeOfFunction = 2, - NoTruncation = 4, - WriteArrowStyleSignature = 8, - WriteOwnNameForAnyLike = 16, - WriteTypeArgumentsOfSignature = 32, - InElementType = 64, - UseFullyQualifiedType = 128, - } - const enum SymbolFormatFlags { - None = 0, - WriteTypeParametersOrArguments = 1, - UseOnlyExternalAliasing = 2, - } - interface TypePredicate { - parameterName: string; - parameterIndex: number; - type: Type; - } - const enum SymbolFlags { - None = 0, - FunctionScopedVariable = 1, - BlockScopedVariable = 2, - Property = 4, - EnumMember = 8, - Function = 16, - Class = 32, - Interface = 64, - ConstEnum = 128, - RegularEnum = 256, - ValueModule = 512, - NamespaceModule = 1024, - TypeLiteral = 2048, - ObjectLiteral = 4096, - Method = 8192, - Constructor = 16384, - GetAccessor = 32768, - SetAccessor = 65536, - Signature = 131072, - TypeParameter = 262144, - TypeAlias = 524288, - ExportValue = 1048576, - ExportType = 2097152, - ExportNamespace = 4194304, - Alias = 8388608, - Instantiated = 16777216, - Merged = 33554432, - Transient = 67108864, - Prototype = 134217728, - SyntheticProperty = 268435456, - Optional = 536870912, - ExportStar = 1073741824, - Enum = 384, - Variable = 3, - Value = 107455, - Type = 793056, - Namespace = 1536, - Module = 1536, - Accessor = 98304, - FunctionScopedVariableExcludes = 107454, - BlockScopedVariableExcludes = 107455, - ParameterExcludes = 107455, - PropertyExcludes = 107455, - EnumMemberExcludes = 107455, - FunctionExcludes = 106927, - ClassExcludes = 899519, - InterfaceExcludes = 792960, - RegularEnumExcludes = 899327, - ConstEnumExcludes = 899967, - ValueModuleExcludes = 106639, - NamespaceModuleExcludes = 0, - MethodExcludes = 99263, - GetAccessorExcludes = 41919, - SetAccessorExcludes = 74687, - TypeParameterExcludes = 530912, - TypeAliasExcludes = 793056, - AliasExcludes = 8388608, - ModuleMember = 8914931, - ExportHasLocal = 944, - HasExports = 1952, - HasMembers = 6240, - BlockScoped = 418, - PropertyOrAccessor = 98308, - Export = 7340032, - } - interface Symbol { - flags: SymbolFlags; - name: string; - declarations?: Declaration[]; - valueDeclaration?: Declaration; - members?: SymbolTable; - exports?: SymbolTable; - } - interface SymbolTable { - [index: string]: Symbol; - } - const enum TypeFlags { - Any = 1, - String = 2, - Number = 4, - Boolean = 8, - Void = 16, - Undefined = 32, - Null = 64, - Enum = 128, - StringLiteral = 256, - TypeParameter = 512, - Class = 1024, - Interface = 2048, - Reference = 4096, - Tuple = 8192, - Union = 16384, - Intersection = 32768, - Anonymous = 65536, - Instantiated = 131072, - ObjectLiteral = 524288, - ESSymbol = 16777216, - ThisType = 33554432, - StringLike = 258, - NumberLike = 132, - ObjectType = 80896, - UnionOrIntersection = 49152, - StructuredType = 130048, - } - type DestructuringPattern = BindingPattern | ObjectLiteralExpression | ArrayLiteralExpression; - interface Type { - flags: TypeFlags; - symbol?: Symbol; - pattern?: DestructuringPattern; - } - interface StringLiteralType extends Type { - text: string; - } - interface ObjectType extends Type { - } - interface InterfaceType extends ObjectType { - typeParameters: TypeParameter[]; - outerTypeParameters: TypeParameter[]; - localTypeParameters: TypeParameter[]; - thisType: TypeParameter; - } - interface InterfaceTypeWithDeclaredMembers extends InterfaceType { - declaredProperties: Symbol[]; - declaredCallSignatures: Signature[]; - declaredConstructSignatures: Signature[]; - declaredStringIndexType: Type; - declaredNumberIndexType: Type; - } - interface TypeReference extends ObjectType { - target: GenericType; - typeArguments: Type[]; - } - interface GenericType extends InterfaceType, TypeReference { - } - interface TupleType extends ObjectType { - elementTypes: Type[]; - } - interface UnionOrIntersectionType extends Type { - types: Type[]; - } - interface UnionType extends UnionOrIntersectionType { - } - interface IntersectionType extends UnionOrIntersectionType { - } - interface TypeParameter extends Type { - constraint: Type; - } - const enum SignatureKind { - Call = 0, - Construct = 1, - } - interface Signature { - declaration: SignatureDeclaration; - typeParameters: TypeParameter[]; - parameters: Symbol[]; - typePredicate?: TypePredicate; - } - const enum IndexKind { - String = 0, - Number = 1, - } - interface DiagnosticMessage { - key: string; - category: DiagnosticCategory; - code: number; - } - /** - * A linked list of formatted diagnostic messages to be used as part of a multiline message. - * It is built from the bottom up, leaving the head to be the "main" diagnostic. - * While it seems that DiagnosticMessageChain is structurally similar to DiagnosticMessage, - * the difference is that messages are all preformatted in DMC. - */ - interface DiagnosticMessageChain { - messageText: string; - category: DiagnosticCategory; - code: number; - next?: DiagnosticMessageChain; - } - interface Diagnostic { - file: SourceFile; - start: number; - length: number; - messageText: string | DiagnosticMessageChain; - category: DiagnosticCategory; - code: number; - } - enum DiagnosticCategory { - Warning = 0, - Error = 1, - Message = 2, - } - const enum ModuleResolutionKind { - Classic = 1, - NodeJs = 2, - } - interface CompilerOptions { - allowNonTsExtensions?: boolean; - charset?: string; - declaration?: boolean; - diagnostics?: boolean; - emitBOM?: boolean; - help?: boolean; - init?: boolean; - inlineSourceMap?: boolean; - inlineSources?: boolean; - jsx?: JsxEmit; - listFiles?: boolean; - locale?: string; - mapRoot?: string; - module?: ModuleKind; - newLine?: NewLineKind; - noEmit?: boolean; - noEmitHelpers?: boolean; - noEmitOnError?: boolean; - noErrorTruncation?: boolean; - noImplicitAny?: boolean; - noLib?: boolean; - noResolve?: boolean; - out?: string; - outFile?: string; - outDir?: string; - preserveConstEnums?: boolean; - project?: string; - removeComments?: boolean; - rootDir?: string; - sourceMap?: boolean; - sourceRoot?: string; - suppressExcessPropertyErrors?: boolean; - suppressImplicitAnyIndexErrors?: boolean; - target?: ScriptTarget; - version?: boolean; - watch?: boolean; - isolatedModules?: boolean; - experimentalDecorators?: boolean; - emitDecoratorMetadata?: boolean; - moduleResolution?: ModuleResolutionKind; - [option: string]: string | number | boolean; - } - const enum ModuleKind { - None = 0, - CommonJS = 1, - AMD = 2, - UMD = 3, - System = 4, - ES6 = 5, - ES2015 = 5, - } - const enum JsxEmit { - None = 0, - Preserve = 1, - React = 2, - } - const enum NewLineKind { - CarriageReturnLineFeed = 0, - LineFeed = 1, - } - interface LineAndCharacter { - line: number; - character: number; - } - const enum ScriptTarget { - ES3 = 0, - ES5 = 1, - ES6 = 2, - ES2015 = 2, - Latest = 2, - } - const enum LanguageVariant { - Standard = 0, - JSX = 1, - } - interface ParsedCommandLine { - options: CompilerOptions; - fileNames: string[]; - errors: Diagnostic[]; - } - interface ModuleResolutionHost { - fileExists(fileName: string): boolean; - readFile(fileName: string): string; - } - interface ResolvedModule { - resolvedFileName: string; - isExternalLibraryImport?: boolean; - } - interface ResolvedModuleWithFailedLookupLocations { - resolvedModule: ResolvedModule; - failedLookupLocations: string[]; - } - interface CompilerHost extends ModuleResolutionHost { - getSourceFile(fileName: string, languageVersion: ScriptTarget, onError?: (message: string) => void): SourceFile; - getCancellationToken?(): CancellationToken; - getDefaultLibFileName(options: CompilerOptions): string; - writeFile: WriteFileCallback; - getCurrentDirectory(): string; - getCanonicalFileName(fileName: string): string; - useCaseSensitiveFileNames(): boolean; - getNewLine(): string; - resolveModuleNames?(moduleNames: string[], containingFile: string): ResolvedModule[]; - } - interface TextSpan { - start: number; - length: number; - } - interface TextChangeRange { - span: TextSpan; - newLength: number; - } -} -declare namespace ts { - interface System { - args: string[]; - newLine: string; - useCaseSensitiveFileNames: boolean; - write(s: string): void; - readFile(path: string, encoding?: string): string; - writeFile(path: string, data: string, writeByteOrderMark?: boolean): void; - watchFile?(path: string, callback: (path: string, removed?: boolean) => void): FileWatcher; - watchDirectory?(path: string, callback: (path: string) => void, recursive?: boolean): FileWatcher; - resolvePath(path: string): string; - fileExists(path: string): boolean; - directoryExists(path: string): boolean; - createDirectory(path: string): void; - getExecutingFilePath(): string; - getCurrentDirectory(): string; - readDirectory(path: string, extension?: string, exclude?: string[]): string[]; - getMemoryUsage?(): number; - exit(exitCode?: number): void; - } - interface FileWatcher { - close(): void; - } - var sys: System; -} -declare namespace ts { - interface ErrorCallback { - (message: DiagnosticMessage, length: number): void; - } - interface Scanner { - getStartPos(): number; - getToken(): SyntaxKind; - getTextPos(): number; - getTokenPos(): number; - getTokenText(): string; - getTokenValue(): string; - hasExtendedUnicodeEscape(): boolean; - hasPrecedingLineBreak(): boolean; - isIdentifier(): boolean; - isReservedWord(): boolean; - isUnterminated(): boolean; - reScanGreaterToken(): SyntaxKind; - reScanSlashToken(): SyntaxKind; - reScanTemplateToken(): SyntaxKind; - scanJsxIdentifier(): SyntaxKind; - reScanJsxToken(): SyntaxKind; - scanJsxToken(): SyntaxKind; - scan(): SyntaxKind; - setText(text: string, start?: number, length?: number): void; - setOnError(onError: ErrorCallback): void; - setScriptTarget(scriptTarget: ScriptTarget): void; - setLanguageVariant(variant: LanguageVariant): void; - setTextPos(textPos: number): void; - lookAhead(callback: () => T): T; - tryScan(callback: () => T): T; - } - function tokenToString(t: SyntaxKind): string; - function getPositionOfLineAndCharacter(sourceFile: SourceFile, line: number, character: number): number; - function getLineAndCharacterOfPosition(sourceFile: SourceFile, position: number): LineAndCharacter; - function isWhiteSpace(ch: number): boolean; - function isLineBreak(ch: number): boolean; - function couldStartTrivia(text: string, pos: number): boolean; - function getLeadingCommentRanges(text: string, pos: number): CommentRange[]; - function getTrailingCommentRanges(text: string, pos: number): CommentRange[]; - /** Optionally, get the shebang */ - function getShebang(text: string): string; - function isIdentifierStart(ch: number, languageVersion: ScriptTarget): boolean; - function isIdentifierPart(ch: number, languageVersion: ScriptTarget): boolean; - function createScanner(languageVersion: ScriptTarget, skipTrivia: boolean, languageVariant?: LanguageVariant, text?: string, onError?: ErrorCallback, start?: number, length?: number): Scanner; -} -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; - /** - * Called to merge all the changes that occurred across several versions of a script snapshot - * into a single change. i.e. if a user keeps making successive edits to a script we will - * have a text change from V1 to V2, V2 to V3, ..., Vn. - * - * This function will then merge those changes into a single change range valid between V1 and - * Vn. - */ - function collapseTextChangeRangesAcrossMultipleVersions(changes: TextChangeRange[]): TextChangeRange; - function getTypeParameterOwner(d: Declaration): Declaration; -} -declare namespace ts { - function getNodeConstructor(kind: SyntaxKind): new (pos?: number, end?: number) => Node; - 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): SourceFile; - function updateSourceFile(sourceFile: SourceFile, newText: string, textChangeRange: TextChangeRange, aggressiveChecks?: boolean): SourceFile; -} -declare namespace ts { - const version: string; - function findConfigFile(searchPath: string): string; - function resolveTripleslashReference(moduleName: string, containingFile: string): string; - function resolveModuleName(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost): ResolvedModuleWithFailedLookupLocations; - function nodeModuleNameResolver(moduleName: string, containingFile: string, 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[]; - function flattenDiagnosticMessageText(messageText: string | DiagnosticMessageChain, newLine: string): string; - function createProgram(rootNames: string[], options: CompilerOptions, host?: CompilerHost, oldProgram?: Program): Program; -} -declare namespace ts { - function parseCommandLine(commandLine: string[], readFile?: (path: string) => string): ParsedCommandLine; - /** - * Read tsconfig.json file - * @param fileName The path to the config file - */ - function readConfigFile(fileName: string, readFile: (path: string) => string): { - config?: any; - error?: Diagnostic; - }; - /** - * Parse the text of the tsconfig.json file - * @param fileName The path to the config file - * @param jsonText The text of the config file - */ - function parseConfigFileTextToJson(fileName: string, jsonText: string): { - config?: any; - error?: Diagnostic; - }; - /** - * Parse the contents of a config file (tsconfig.json). - * @param json The contents of the config file to parse - * @param host Instance of ParseConfigHost used to enumerate files in folder. - * @param basePath A root directory to resolve relative path entries in the config - * file to. e.g. outDir - */ - function parseJsonConfigFileContent(json: any, host: ParseConfigHost, basePath: string): ParsedCommandLine; - function convertCompilerOptionsFromJson(jsonOptions: any, basePath: string): { - options: CompilerOptions; - errors: Diagnostic[]; - }; -} -declare namespace ts { - /** The version of the language service API */ - let servicesVersion: string; - interface Node { - getSourceFile(): SourceFile; - getChildCount(sourceFile?: SourceFile): number; - getChildAt(index: number, sourceFile?: SourceFile): Node; - getChildren(sourceFile?: SourceFile): Node[]; - getStart(sourceFile?: SourceFile): number; - getFullStart(): number; - getEnd(): number; - getWidth(sourceFile?: SourceFile): number; - getFullWidth(): number; - getLeadingTriviaWidth(sourceFile?: SourceFile): number; - getFullText(sourceFile?: SourceFile): string; - getText(sourceFile?: SourceFile): string; - getFirstToken(sourceFile?: SourceFile): Node; - getLastToken(sourceFile?: SourceFile): Node; - } - interface Symbol { - getFlags(): SymbolFlags; - getName(): string; - getDeclarations(): Declaration[]; - getDocumentationComment(): SymbolDisplayPart[]; - } - interface Type { - getFlags(): TypeFlags; - getSymbol(): Symbol; - getProperties(): Symbol[]; - getProperty(propertyName: string): Symbol; - getApparentProperties(): Symbol[]; - getCallSignatures(): Signature[]; - getConstructSignatures(): Signature[]; - getStringIndexType(): Type; - getNumberIndexType(): Type; - getBaseTypes(): ObjectType[]; - } - interface Signature { - getDeclaration(): SignatureDeclaration; - getTypeParameters(): Type[]; - getParameters(): Symbol[]; - getReturnType(): Type; - getDocumentationComment(): SymbolDisplayPart[]; - } - interface SourceFile { - getLineAndCharacterOfPosition(pos: number): LineAndCharacter; - getLineStarts(): number[]; - getPositionOfLineAndCharacter(line: number, character: number): number; - update(newText: string, textChangeRange: TextChangeRange): SourceFile; - } - /** - * Represents an immutable snapshot of a script at a specified time.Once acquired, the - * snapshot is observably immutable. i.e. the same calls with the same parameters will return - * the same values. - */ - interface IScriptSnapshot { - /** Gets a portion of the script snapshot specified by [start, end). */ - getText(start: number, end: number): string; - /** Gets the length of this script snapshot. */ - getLength(): number; - /** - * Gets the TextChangeRange that describe how the text changed between this text and - * an older version. This information is used by the incremental parser to determine - * what sections of the script need to be re-parsed. 'undefined' can be returned if the - * change range cannot be determined. However, in that case, incremental parsing will - * not happen and the entire document will be re - parsed. - */ - getChangeRange(oldSnapshot: IScriptSnapshot): TextChangeRange; - /** Releases all resources held by this script snapshot */ - dispose?(): void; - } - module ScriptSnapshot { - function fromString(text: string): IScriptSnapshot; - } - interface PreProcessedFileInfo { - referencedFiles: FileReference[]; - importedFiles: FileReference[]; - ambientExternalModules: string[]; - isLibFile: boolean; - } - interface HostCancellationToken { - isCancellationRequested(): boolean; - } - interface LanguageServiceHost { - getCompilationSettings(): CompilerOptions; - getNewLine?(): string; - getProjectVersion?(): string; - getScriptFileNames(): string[]; - getScriptVersion(fileName: string): string; - getScriptSnapshot(fileName: string): IScriptSnapshot; - getLocalizedDiagnosticMessages?(): any; - getCancellationToken?(): HostCancellationToken; - getCurrentDirectory(): string; - getDefaultLibFileName(options: CompilerOptions): string; - log?(s: string): void; - trace?(s: string): void; - error?(s: string): void; - useCaseSensitiveFileNames?(): boolean; - resolveModuleNames?(moduleNames: string[], containingFile: string): ResolvedModule[]; - } - interface LanguageService { - cleanupSemanticCache(): void; - getSyntacticDiagnostics(fileName: string): Diagnostic[]; - getSemanticDiagnostics(fileName: string): Diagnostic[]; - getCompilerOptionsDiagnostics(): Diagnostic[]; - /** - * @deprecated Use getEncodedSyntacticClassifications instead. - */ - getSyntacticClassifications(fileName: string, span: TextSpan): ClassifiedSpan[]; - /** - * @deprecated Use getEncodedSemanticClassifications instead. - */ - getSemanticClassifications(fileName: string, span: TextSpan): ClassifiedSpan[]; - getEncodedSyntacticClassifications(fileName: string, span: TextSpan): Classifications; - getEncodedSemanticClassifications(fileName: string, span: TextSpan): Classifications; - getCompletionsAtPosition(fileName: string, position: number): CompletionInfo; - getCompletionEntryDetails(fileName: string, position: number, entryName: string): CompletionEntryDetails; - getQuickInfoAtPosition(fileName: string, position: number): QuickInfo; - getNameOrDottedNameSpan(fileName: string, startPos: number, endPos: number): TextSpan; - getBreakpointStatementAtPosition(fileName: string, position: number): TextSpan; - getSignatureHelpItems(fileName: string, position: number): SignatureHelpItems; - getRenameInfo(fileName: string, position: number): RenameInfo; - findRenameLocations(fileName: string, position: number, findInStrings: boolean, findInComments: boolean): RenameLocation[]; - getDefinitionAtPosition(fileName: string, position: number): DefinitionInfo[]; - getTypeDefinitionAtPosition(fileName: string, position: number): DefinitionInfo[]; - getReferencesAtPosition(fileName: string, position: number): ReferenceEntry[]; - findReferences(fileName: string, position: number): ReferencedSymbol[]; - getDocumentHighlights(fileName: string, position: number, filesToSearch: string[]): DocumentHighlights[]; - /** @deprecated */ - getOccurrencesAtPosition(fileName: string, position: number): ReferenceEntry[]; - getNavigateToItems(searchValue: string, maxResultCount?: number): NavigateToItem[]; - getNavigationBarItems(fileName: string): NavigationBarItem[]; - 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[]; - getDocCommentTemplateAtPosition(fileName: string, position: number): TextInsertion; - getEmitOutput(fileName: string): EmitOutput; - getProgram(): Program; - getSourceFile(fileName: string): SourceFile; - dispose(): void; - } - interface Classifications { - spans: number[]; - endOfLineState: EndOfLineState; - } - interface ClassifiedSpan { - textSpan: TextSpan; - classificationType: string; - } - interface NavigationBarItem { - text: string; - kind: string; - kindModifiers: string; - spans: TextSpan[]; - childItems: NavigationBarItem[]; - indent: number; - bolded: boolean; - grayed: boolean; - } - interface TodoCommentDescriptor { - text: string; - priority: number; - } - interface TodoComment { - descriptor: TodoCommentDescriptor; - message: string; - position: number; - } - class TextChange { - span: TextSpan; - newText: string; - } - interface TextInsertion { - newText: string; - /** The position in newText the caret should point to after the insertion. */ - caretOffset: number; - } - interface RenameLocation { - textSpan: TextSpan; - fileName: string; - } - interface ReferenceEntry { - textSpan: TextSpan; - fileName: string; - isWriteAccess: boolean; - } - interface DocumentHighlights { - fileName: string; - highlightSpans: HighlightSpan[]; - } - module HighlightSpanKind { - const none: string; - const definition: string; - const reference: string; - const writtenReference: string; - } - interface HighlightSpan { - fileName?: string; - textSpan: TextSpan; - kind: string; - } - interface NavigateToItem { - name: string; - kind: string; - kindModifiers: string; - matchKind: string; - isCaseSensitive: boolean; - fileName: string; - textSpan: TextSpan; - containerName: string; - containerKind: string; - } - interface EditorOptions { - IndentSize: number; - TabSize: number; - NewLineCharacter: string; - ConvertTabsToSpaces: boolean; - IndentStyle: IndentStyle; - } - enum IndentStyle { - None = 0, - Block = 1, - Smart = 2, - } - interface FormatCodeOptions extends EditorOptions { - InsertSpaceAfterCommaDelimiter: boolean; - InsertSpaceAfterSemicolonInForStatements: boolean; - InsertSpaceBeforeAndAfterBinaryOperators: boolean; - InsertSpaceAfterKeywordsInControlFlowStatements: boolean; - InsertSpaceAfterFunctionKeywordForAnonymousFunctions: boolean; - InsertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis: boolean; - InsertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets: boolean; - PlaceOpenBraceOnNewLineForFunctions: boolean; - PlaceOpenBraceOnNewLineForControlBlocks: boolean; - [s: string]: boolean | number | string; - } - interface DefinitionInfo { - fileName: string; - textSpan: TextSpan; - kind: string; - name: string; - containerKind: string; - containerName: string; - } - interface ReferencedSymbol { - definition: DefinitionInfo; - references: ReferenceEntry[]; - } - enum SymbolDisplayPartKind { - aliasName = 0, - className = 1, - enumName = 2, - fieldName = 3, - interfaceName = 4, - keyword = 5, - lineBreak = 6, - numericLiteral = 7, - stringLiteral = 8, - localName = 9, - methodName = 10, - moduleName = 11, - operator = 12, - parameterName = 13, - propertyName = 14, - punctuation = 15, - space = 16, - text = 17, - typeParameterName = 18, - enumMemberName = 19, - functionName = 20, - regularExpressionLiteral = 21, - } - interface SymbolDisplayPart { - text: string; - kind: string; - } - interface QuickInfo { - kind: string; - kindModifiers: string; - textSpan: TextSpan; - displayParts: SymbolDisplayPart[]; - documentation: SymbolDisplayPart[]; - } - interface RenameInfo { - canRename: boolean; - localizedErrorMessage: string; - displayName: string; - fullDisplayName: string; - kind: string; - kindModifiers: string; - triggerSpan: TextSpan; - } - interface SignatureHelpParameter { - name: string; - documentation: SymbolDisplayPart[]; - displayParts: SymbolDisplayPart[]; - isOptional: boolean; - } - /** - * Represents a single signature to show in signature help. - * The id is used for subsequent calls into the language service to ask questions about the - * signature help item in the context of any documents that have been updated. i.e. after - * an edit has happened, while signature help is still active, the host can ask important - * questions like 'what parameter is the user currently contained within?'. - */ - interface SignatureHelpItem { - isVariadic: boolean; - prefixDisplayParts: SymbolDisplayPart[]; - suffixDisplayParts: SymbolDisplayPart[]; - separatorDisplayParts: SymbolDisplayPart[]; - parameters: SignatureHelpParameter[]; - documentation: SymbolDisplayPart[]; - } - /** - * Represents a set of signature help items, and the preferred item that should be selected. - */ - interface SignatureHelpItems { - items: SignatureHelpItem[]; - applicableSpan: TextSpan; - selectedItemIndex: number; - argumentIndex: number; - argumentCount: number; - } - interface CompletionInfo { - isMemberCompletion: boolean; - isNewIdentifierLocation: boolean; - entries: CompletionEntry[]; - } - interface CompletionEntry { - name: string; - kind: string; - kindModifiers: string; - sortText: string; - } - interface CompletionEntryDetails { - name: string; - kind: string; - kindModifiers: string; - displayParts: SymbolDisplayPart[]; - documentation: SymbolDisplayPart[]; - } - interface OutliningSpan { - /** The span of the document to actually collapse. */ - textSpan: TextSpan; - /** The span of the document to display when the user hovers over the collapsed span. */ - hintSpan: TextSpan; - /** The text to display in the editor for the collapsed region. */ - bannerText: string; - /** - * Whether or not this region should be automatically collapsed when - * the 'Collapse to Definitions' command is invoked. - */ - autoCollapse: boolean; - } - interface EmitOutput { - outputFiles: OutputFile[]; - emitSkipped: boolean; - } - const enum OutputFileType { - JavaScript = 0, - SourceMap = 1, - Declaration = 2, - } - interface OutputFile { - name: string; - writeByteOrderMark: boolean; - text: string; - } - const enum EndOfLineState { - None = 0, - InMultiLineCommentTrivia = 1, - InSingleQuoteStringLiteral = 2, - InDoubleQuoteStringLiteral = 3, - InTemplateHeadOrNoSubstitutionTemplate = 4, - InTemplateMiddleOrTail = 5, - InTemplateSubstitutionPosition = 6, - } - enum TokenClass { - Punctuation = 0, - Keyword = 1, - Operator = 2, - Comment = 3, - Whitespace = 4, - Identifier = 5, - NumberLiteral = 6, - StringLiteral = 7, - RegExpLiteral = 8, - } - interface ClassificationResult { - finalLexState: EndOfLineState; - entries: ClassificationInfo[]; - } - interface ClassificationInfo { - length: number; - classification: TokenClass; - } - interface Classifier { - /** - * Gives lexical classifications of tokens on a line without any syntactic context. - * For instance, a token consisting of the text 'string' can be either an identifier - * named 'string' or the keyword 'string', however, because this classifier is not aware, - * it relies on certain heuristics to give acceptable results. For classifications where - * speed trumps accuracy, this function is preferable; however, for true accuracy, the - * syntactic classifier is ideal. In fact, in certain editing scenarios, combining the - * lexical, syntactic, and semantic classifiers may issue the best user experience. - * - * @param text The text of a line to classify. - * @param lexState The state of the lexical classifier at the end of the previous line. - * @param syntacticClassifierAbsent Whether the client is *not* using a syntactic classifier. - * If there is no syntactic classifier (syntacticClassifierAbsent=true), - * certain heuristics may be used in its place; however, if there is a - * syntactic classifier (syntacticClassifierAbsent=false), certain - * classifications which may be incorrectly categorized will be given - * back as Identifiers in order to allow the syntactic classifier to - * subsume the classification. - * @deprecated Use getLexicalClassifications instead. - */ - getClassificationsForLine(text: string, lexState: EndOfLineState, syntacticClassifierAbsent: boolean): ClassificationResult; - getEncodedLexicalClassifications(text: string, endOfLineState: EndOfLineState, syntacticClassifierAbsent: boolean): Classifications; - } - /** - * The document registry represents a store of SourceFile objects that can be shared between - * multiple LanguageService instances. A LanguageService instance holds on the SourceFile (AST) - * of files in the context. - * SourceFile objects account for most of the memory usage by the language service. Sharing - * the same DocumentRegistry instance between different instances of LanguageService allow - * for more efficient memory utilization since all projects will share at least the library - * file (lib.d.ts). - * - * A more advanced use of the document registry is to serialize sourceFile objects to disk - * and re-hydrate them when needed. - * - * To create a default DocumentRegistry, use createDocumentRegistry to create one, and pass it - * to all subsequent createLanguageService calls. - */ - interface DocumentRegistry { - /** - * Request a stored SourceFile with a given fileName and compilationSettings. - * The first call to acquire will call createLanguageServiceSourceFile to generate - * the SourceFile if was not found in the registry. - * - * @param fileName The name of the file requested - * @param compilationSettings Some compilation settings like target affects the - * shape of a the resulting SourceFile. This allows the DocumentRegistry to store - * multiple copies of the same file for different compilation settings. - * @parm scriptSnapshot Text of the file. Only used if the file was not found - * in the registry and a new one was created. - * @parm version Current version of the file. Only used if the file was not found - * in the registry and a new one was created. - */ - acquireDocument(fileName: string, compilationSettings: CompilerOptions, scriptSnapshot: IScriptSnapshot, version: string): SourceFile; - /** - * Request an updated version of an already existing SourceFile with a given fileName - * and compilationSettings. The update will in-turn call updateLanguageServiceSourceFile - * to get an updated SourceFile. - * - * @param fileName The name of the file requested - * @param compilationSettings Some compilation settings like target affects the - * shape of a the resulting SourceFile. This allows the DocumentRegistry to store - * multiple copies of the same file for different compilation settings. - * @param scriptSnapshot Text of the file. - * @param version Current version of the file. - */ - updateDocument(fileName: string, compilationSettings: CompilerOptions, scriptSnapshot: IScriptSnapshot, version: string): SourceFile; - /** - * Informs the DocumentRegistry that a file is not needed any longer. - * - * Note: It is not allowed to call release on a SourceFile that was not acquired from - * this registry originally. - * - * @param fileName The name of the file to be released - * @param compilationSettings The compilation settings used to acquire the file - */ - releaseDocument(fileName: string, compilationSettings: CompilerOptions): void; - reportStats(): string; - } - module ScriptElementKind { - const unknown: string; - const warning: string; - const keyword: string; - const scriptElement: string; - const moduleElement: string; - const classElement: string; - const localClassElement: string; - const interfaceElement: string; - const typeElement: string; - const enumElement: string; - const variableElement: string; - const localVariableElement: string; - const functionElement: string; - const localFunctionElement: string; - const memberFunctionElement: string; - const memberGetAccessorElement: string; - const memberSetAccessorElement: string; - const memberVariableElement: string; - const constructorImplementationElement: string; - const callSignatureElement: string; - const indexSignatureElement: string; - const constructSignatureElement: string; - const parameterElement: string; - const typeParameterElement: string; - const primitiveType: string; - const label: string; - const alias: string; - const constElement: string; - const letElement: string; - } - module ScriptElementKindModifier { - const none: string; - const publicMemberModifier: string; - const privateMemberModifier: string; - const protectedMemberModifier: string; - const exportedModifier: string; - const ambientModifier: string; - const staticModifier: string; - const abstractModifier: string; - } - class ClassificationTypeNames { - static comment: string; - static identifier: string; - static keyword: string; - static numericLiteral: string; - static operator: string; - static stringLiteral: string; - static whiteSpace: string; - static text: string; - static punctuation: string; - static className: string; - static enumName: string; - static interfaceName: string; - static moduleName: string; - static typeParameterName: string; - static typeAliasName: string; - static parameterName: string; - static docCommentTagName: string; - } - const enum ClassificationType { - comment = 1, - identifier = 2, - keyword = 3, - numericLiteral = 4, - operator = 5, - stringLiteral = 6, - regularExpressionLiteral = 7, - whiteSpace = 8, - text = 9, - punctuation = 10, - className = 11, - enumName = 12, - interfaceName = 13, - moduleName = 14, - typeParameterName = 15, - typeAliasName = 16, - parameterName = 17, - docCommentTagName = 18, - } - interface DisplayPartsSymbolWriter extends SymbolWriter { - displayParts(): SymbolDisplayPart[]; - } - function displayPartsToString(displayParts: SymbolDisplayPart[]): string; - function getDefaultCompilerOptions(): CompilerOptions; - interface TranspileOptions { - compilerOptions?: CompilerOptions; - fileName?: string; - reportDiagnostics?: boolean; - moduleName?: string; - renamedDependencies?: Map; - } - interface TranspileOutput { - outputText: string; - diagnostics?: Diagnostic[]; - sourceMapText?: string; - } - function transpileModule(input: string, transpileOptions: TranspileOptions): TranspileOutput; - function transpile(input: string, compilerOptions?: CompilerOptions, fileName?: string, diagnostics?: Diagnostic[], moduleName?: string): string; - function createLanguageServiceSourceFile(fileName: string, scriptSnapshot: IScriptSnapshot, scriptTarget: ScriptTarget, version: string, setNodeParents: boolean): SourceFile; - let disableIncrementalParsing: boolean; - function updateLanguageServiceSourceFile(sourceFile: SourceFile, scriptSnapshot: IScriptSnapshot, version: string, textChangeRange: TextChangeRange, aggressiveChecks?: boolean): SourceFile; - function createGetCanonicalFileName(useCaseSensitivefileNames: boolean): (fileName: string) => string; - function createDocumentRegistry(useCaseSensitiveFileNames?: boolean): DocumentRegistry; - function preProcessFile(sourceText: string, readImportFiles?: boolean): PreProcessedFileInfo; - function createLanguageService(host: LanguageServiceHost, documentRegistry?: DocumentRegistry): LanguageService; - function createClassifier(): Classifier; - /** - * Get the path of the default library files (lib.d.ts) as distributed with the typescript - * node package. - * The functionality is not supported if the ts module is consumed outside of a node module. - */ - function getDefaultLibFilePath(options: CompilerOptions): string; -} +declare namespace ts { + interface Map { + [index: string]: T; + } + interface FileMap { + get(fileName: string): T; + set(fileName: string, value: T): void; + contains(fileName: string): boolean; + remove(fileName: string): void; + forEachValue(f: (v: T) => void): void; + clear(): void; + } + interface TextRange { + pos: number; + end: number; + } + const enum SyntaxKind { + Unknown = 0, + EndOfFileToken = 1, + SingleLineCommentTrivia = 2, + MultiLineCommentTrivia = 3, + NewLineTrivia = 4, + WhitespaceTrivia = 5, + ShebangTrivia = 6, + 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, + RequireKeyword = 127, + NumberKeyword = 128, + SetKeyword = 129, + StringKeyword = 130, + SymbolKeyword = 131, + TypeKeyword = 132, + FromKeyword = 133, + OfKeyword = 134, + QualifiedName = 135, + ComputedPropertyName = 136, + TypeParameter = 137, + Parameter = 138, + Decorator = 139, + PropertySignature = 140, + PropertyDeclaration = 141, + MethodSignature = 142, + MethodDeclaration = 143, + Constructor = 144, + GetAccessor = 145, + SetAccessor = 146, + CallSignature = 147, + ConstructSignature = 148, + IndexSignature = 149, + TypePredicate = 150, + TypeReference = 151, + FunctionType = 152, + ConstructorType = 153, + TypeQuery = 154, + TypeLiteral = 155, + ArrayType = 156, + TupleType = 157, + UnionType = 158, + IntersectionType = 159, + ParenthesizedType = 160, + ObjectBindingPattern = 161, + ArrayBindingPattern = 162, + BindingElement = 163, + ArrayLiteralExpression = 164, + ObjectLiteralExpression = 165, + PropertyAccessExpression = 166, + ElementAccessExpression = 167, + CallExpression = 168, + NewExpression = 169, + TaggedTemplateExpression = 170, + TypeAssertionExpression = 171, + ParenthesizedExpression = 172, + FunctionExpression = 173, + ArrowFunction = 174, + DeleteExpression = 175, + TypeOfExpression = 176, + VoidExpression = 177, + AwaitExpression = 178, + PrefixUnaryExpression = 179, + PostfixUnaryExpression = 180, + BinaryExpression = 181, + ConditionalExpression = 182, + TemplateExpression = 183, + YieldExpression = 184, + SpreadElementExpression = 185, + ClassExpression = 186, + OmittedExpression = 187, + ExpressionWithTypeArguments = 188, + AsExpression = 189, + TemplateSpan = 190, + SemicolonClassElement = 191, + Block = 192, + VariableStatement = 193, + EmptyStatement = 194, + ExpressionStatement = 195, + IfStatement = 196, + DoStatement = 197, + WhileStatement = 198, + ForStatement = 199, + ForInStatement = 200, + ForOfStatement = 201, + ContinueStatement = 202, + BreakStatement = 203, + ReturnStatement = 204, + WithStatement = 205, + SwitchStatement = 206, + LabeledStatement = 207, + ThrowStatement = 208, + TryStatement = 209, + DebuggerStatement = 210, + VariableDeclaration = 211, + VariableDeclarationList = 212, + FunctionDeclaration = 213, + ClassDeclaration = 214, + InterfaceDeclaration = 215, + TypeAliasDeclaration = 216, + EnumDeclaration = 217, + ModuleDeclaration = 218, + ModuleBlock = 219, + CaseBlock = 220, + ImportEqualsDeclaration = 221, + ImportDeclaration = 222, + ImportClause = 223, + NamespaceImport = 224, + NamedImports = 225, + ImportSpecifier = 226, + ExportAssignment = 227, + ExportDeclaration = 228, + NamedExports = 229, + ExportSpecifier = 230, + MissingDeclaration = 231, + ExternalModuleReference = 232, + JsxElement = 233, + JsxSelfClosingElement = 234, + JsxOpeningElement = 235, + JsxText = 236, + JsxClosingElement = 237, + JsxAttribute = 238, + JsxSpreadAttribute = 239, + JsxExpression = 240, + CaseClause = 241, + DefaultClause = 242, + HeritageClause = 243, + CatchClause = 244, + PropertyAssignment = 245, + ShorthandPropertyAssignment = 246, + EnumMember = 247, + SourceFile = 248, + JSDocTypeExpression = 249, + JSDocAllType = 250, + JSDocUnknownType = 251, + JSDocArrayType = 252, + JSDocUnionType = 253, + JSDocTupleType = 254, + JSDocNullableType = 255, + JSDocNonNullableType = 256, + JSDocRecordType = 257, + JSDocRecordMember = 258, + JSDocTypeReference = 259, + JSDocOptionalType = 260, + JSDocFunctionType = 261, + JSDocVariadicType = 262, + JSDocConstructorType = 263, + JSDocThisType = 264, + JSDocComment = 265, + JSDocTag = 266, + JSDocParameterTag = 267, + JSDocReturnTag = 268, + JSDocTypeTag = 269, + JSDocTemplateTag = 270, + SyntaxList = 271, + Count = 272, + FirstAssignment = 56, + LastAssignment = 68, + FirstReservedWord = 70, + LastReservedWord = 105, + FirstKeyword = 70, + LastKeyword = 134, + FirstFutureReservedWord = 106, + LastFutureReservedWord = 114, + FirstTypeNode = 151, + LastTypeNode = 160, + FirstPunctuation = 15, + LastPunctuation = 68, + FirstToken = 0, + LastToken = 134, + FirstTriviaToken = 2, + LastTriviaToken = 7, + FirstLiteralToken = 8, + LastLiteralToken = 11, + FirstTemplateToken = 11, + LastTemplateToken = 14, + FirstBinaryOperator = 25, + LastBinaryOperator = 68, + FirstNode = 135, + } + const enum NodeFlags { + None = 0, + Export = 1, + Ambient = 2, + Public = 16, + Private = 32, + Protected = 64, + Static = 128, + Abstract = 256, + Async = 512, + Default = 1024, + MultiLine = 2048, + Synthetic = 4096, + DeclarationFile = 8192, + Let = 16384, + Const = 32768, + OctalLiteral = 65536, + Namespace = 131072, + ExportContext = 262144, + ContainsThis = 524288, + Modifier = 2035, + AccessibilityModifier = 112, + BlockScoped = 49152, + } + const enum JsxFlags { + None = 0, + IntrinsicNamedElement = 1, + IntrinsicIndexedElement = 2, + ClassElement = 4, + UnknownElement = 8, + IntrinsicElement = 3, + } + interface Node extends TextRange { + kind: SyntaxKind; + flags: NodeFlags; + decorators?: NodeArray; + modifiers?: ModifiersArray; + parent?: Node; + } + interface NodeArray extends Array, TextRange { + hasTrailingComma?: boolean; + } + interface ModifiersArray extends NodeArray { + flags: number; + } + interface Identifier extends PrimaryExpression { + text: string; + originalKeywordKind?: SyntaxKind; + } + interface QualifiedName extends Node { + left: EntityName; + right: Identifier; + } + type EntityName = Identifier | QualifiedName; + type DeclarationName = Identifier | LiteralExpression | ComputedPropertyName | BindingPattern; + interface Declaration extends Node { + _declarationBrand: any; + name?: DeclarationName; + } + interface ComputedPropertyName extends Node { + expression: Expression; + } + interface Decorator extends Node { + expression: LeftHandSideExpression; + } + interface TypeParameterDeclaration extends Declaration { + name: Identifier; + constraint?: TypeNode; + expression?: Expression; + } + interface SignatureDeclaration extends Declaration { + typeParameters?: NodeArray; + parameters: NodeArray; + type?: TypeNode; + } + interface VariableDeclaration extends Declaration { + parent?: VariableDeclarationList; + name: Identifier | BindingPattern; + type?: TypeNode; + initializer?: Expression; + } + interface VariableDeclarationList extends Node { + declarations: NodeArray; + } + interface ParameterDeclaration extends Declaration { + dotDotDotToken?: Node; + name: Identifier | BindingPattern; + questionToken?: Node; + type?: TypeNode; + initializer?: Expression; + } + interface BindingElement extends Declaration { + propertyName?: Identifier; + dotDotDotToken?: Node; + name: Identifier | BindingPattern; + initializer?: Expression; + } + interface PropertyDeclaration extends Declaration, ClassElement { + name: DeclarationName; + questionToken?: Node; + type?: TypeNode; + initializer?: Expression; + } + interface ObjectLiteralElement extends Declaration { + _objectLiteralBrandBrand: any; + } + interface PropertyAssignment extends ObjectLiteralElement { + _propertyAssignmentBrand: any; + name: DeclarationName; + questionToken?: Node; + initializer: Expression; + } + interface ShorthandPropertyAssignment extends ObjectLiteralElement { + name: Identifier; + questionToken?: Node; + equalsToken?: Node; + objectAssignmentInitializer?: Expression; + } + interface VariableLikeDeclaration extends Declaration { + propertyName?: Identifier; + dotDotDotToken?: Node; + name: DeclarationName; + questionToken?: Node; + type?: TypeNode; + initializer?: Expression; + } + interface BindingPattern extends Node { + elements: NodeArray; + } + /** + * Several node kinds share function-like features such as a signature, + * a name, and a body. These nodes should extend FunctionLikeDeclaration. + * Examples: + * - FunctionDeclaration + * - MethodDeclaration + * - AccessorDeclaration + */ + interface FunctionLikeDeclaration extends SignatureDeclaration { + _functionLikeDeclarationBrand: any; + asteriskToken?: Node; + questionToken?: Node; + body?: Block | Expression; + } + interface FunctionDeclaration extends FunctionLikeDeclaration, Statement { + name?: Identifier; + body?: Block; + } + interface MethodDeclaration extends FunctionLikeDeclaration, ClassElement, ObjectLiteralElement { + body?: Block; + } + interface ConstructorDeclaration extends FunctionLikeDeclaration, ClassElement { + body?: Block; + } + interface SemicolonClassElement extends ClassElement { + _semicolonClassElementBrand: any; + } + interface AccessorDeclaration extends FunctionLikeDeclaration, ClassElement, ObjectLiteralElement { + _accessorDeclarationBrand: any; + body: Block; + } + interface IndexSignatureDeclaration extends SignatureDeclaration, ClassElement { + _indexSignatureDeclarationBrand: any; + } + interface TypeNode extends Node { + _typeNodeBrand: any; + } + interface FunctionOrConstructorTypeNode extends TypeNode, SignatureDeclaration { + _functionOrConstructorTypeNodeBrand: any; + } + interface TypeReferenceNode extends TypeNode { + typeName: EntityName; + typeArguments?: NodeArray; + } + interface TypePredicateNode extends TypeNode { + parameterName: Identifier; + type: TypeNode; + } + interface TypeQueryNode extends TypeNode { + exprName: EntityName; + } + interface TypeLiteralNode extends TypeNode, Declaration { + members: NodeArray; + } + interface ArrayTypeNode extends TypeNode { + elementType: TypeNode; + } + interface TupleTypeNode extends TypeNode { + elementTypes: NodeArray; + } + interface UnionOrIntersectionTypeNode extends TypeNode { + types: NodeArray; + } + interface UnionTypeNode extends UnionOrIntersectionTypeNode { + } + interface IntersectionTypeNode extends UnionOrIntersectionTypeNode { + } + interface ParenthesizedTypeNode extends TypeNode { + type: TypeNode; + } + interface StringLiteral extends LiteralExpression, TypeNode { + _stringLiteralBrand: any; + } + interface Expression extends Node { + _expressionBrand: any; + contextualType?: Type; + } + interface UnaryExpression extends Expression { + _unaryExpressionBrand: any; + } + interface IncrementExpression extends UnaryExpression { + _incrementExpressionBrand: any; + } + interface PrefixUnaryExpression extends IncrementExpression { + operator: SyntaxKind; + operand: UnaryExpression; + } + interface PostfixUnaryExpression extends IncrementExpression { + operand: LeftHandSideExpression; + operator: SyntaxKind; + } + interface PostfixExpression extends UnaryExpression { + _postfixExpressionBrand: any; + } + interface LeftHandSideExpression extends IncrementExpression { + _leftHandSideExpressionBrand: any; + } + interface MemberExpression extends LeftHandSideExpression { + _memberExpressionBrand: any; + } + interface PrimaryExpression extends MemberExpression { + _primaryExpressionBrand: any; + } + interface DeleteExpression extends UnaryExpression { + expression: UnaryExpression; + } + interface TypeOfExpression extends UnaryExpression { + expression: UnaryExpression; + } + interface VoidExpression extends UnaryExpression { + expression: UnaryExpression; + } + interface AwaitExpression extends UnaryExpression { + expression: UnaryExpression; + } + interface YieldExpression extends Expression { + asteriskToken?: Node; + expression?: Expression; + } + interface BinaryExpression extends Expression { + left: Expression; + operatorToken: Node; + right: Expression; + } + interface ConditionalExpression extends Expression { + condition: Expression; + questionToken: Node; + whenTrue: Expression; + colonToken: Node; + whenFalse: Expression; + } + interface FunctionExpression extends PrimaryExpression, FunctionLikeDeclaration { + name?: Identifier; + body: Block | Expression; + } + interface ArrowFunction extends Expression, FunctionLikeDeclaration { + equalsGreaterThanToken: Node; + } + interface LiteralExpression extends PrimaryExpression { + text: string; + isUnterminated?: boolean; + hasExtendedUnicodeEscape?: boolean; + } + interface TemplateExpression extends PrimaryExpression { + head: LiteralExpression; + templateSpans: NodeArray; + } + interface TemplateSpan extends Node { + expression: Expression; + literal: LiteralExpression; + } + interface ParenthesizedExpression extends PrimaryExpression { + expression: Expression; + } + interface ArrayLiteralExpression extends PrimaryExpression { + elements: NodeArray; + } + interface SpreadElementExpression extends Expression { + expression: Expression; + } + interface ObjectLiteralExpression extends PrimaryExpression, Declaration { + properties: NodeArray; + } + interface PropertyAccessExpression extends MemberExpression { + expression: LeftHandSideExpression; + dotToken: Node; + name: Identifier; + } + interface ElementAccessExpression extends MemberExpression { + expression: LeftHandSideExpression; + argumentExpression?: Expression; + } + interface CallExpression extends LeftHandSideExpression { + expression: LeftHandSideExpression; + typeArguments?: NodeArray; + arguments: NodeArray; + } + interface ExpressionWithTypeArguments extends TypeNode { + expression: LeftHandSideExpression; + typeArguments?: NodeArray; + } + interface NewExpression extends CallExpression, PrimaryExpression { + } + interface TaggedTemplateExpression extends MemberExpression { + tag: LeftHandSideExpression; + template: LiteralExpression | TemplateExpression; + } + type CallLikeExpression = CallExpression | NewExpression | TaggedTemplateExpression | Decorator; + interface AsExpression extends Expression { + expression: Expression; + type: TypeNode; + } + interface TypeAssertion extends UnaryExpression { + type: TypeNode; + expression: UnaryExpression; + } + type AssertionExpression = TypeAssertion | AsExpression; + interface JsxElement extends PrimaryExpression { + openingElement: JsxOpeningElement; + children: NodeArray; + closingElement: JsxClosingElement; + } + interface JsxOpeningElement extends Expression { + _openingElementBrand?: any; + tagName: EntityName; + attributes: NodeArray; + } + interface JsxSelfClosingElement extends PrimaryExpression, JsxOpeningElement { + _selfClosingElementBrand?: any; + } + type JsxOpeningLikeElement = JsxSelfClosingElement | JsxOpeningElement; + interface JsxAttribute extends Node { + name: Identifier; + initializer?: Expression; + } + interface JsxSpreadAttribute extends Node { + expression: Expression; + } + interface JsxClosingElement extends Node { + tagName: EntityName; + } + interface JsxExpression extends Expression { + expression?: Expression; + } + interface JsxText extends Node { + _jsxTextExpressionBrand: any; + } + type JsxChild = JsxText | JsxExpression | JsxElement | JsxSelfClosingElement; + interface Statement extends Node { + _statementBrand: any; + } + interface Block extends Statement { + statements: NodeArray; + } + interface VariableStatement extends Statement { + declarationList: VariableDeclarationList; + } + interface ExpressionStatement extends Statement { + expression: Expression; + } + interface IfStatement extends Statement { + expression: Expression; + thenStatement: Statement; + elseStatement?: Statement; + } + interface IterationStatement extends Statement { + statement: Statement; + } + interface DoStatement extends IterationStatement { + expression: Expression; + } + interface WhileStatement extends IterationStatement { + expression: Expression; + } + interface ForStatement extends IterationStatement { + initializer?: VariableDeclarationList | Expression; + condition?: Expression; + incrementor?: Expression; + } + interface ForInStatement extends IterationStatement { + initializer: VariableDeclarationList | Expression; + expression: Expression; + } + interface ForOfStatement extends IterationStatement { + initializer: VariableDeclarationList | Expression; + expression: Expression; + } + interface BreakOrContinueStatement extends Statement { + label?: Identifier; + } + interface ReturnStatement extends Statement { + expression?: Expression; + } + interface WithStatement extends Statement { + expression: Expression; + statement: Statement; + } + interface SwitchStatement extends Statement { + expression: Expression; + caseBlock: CaseBlock; + } + interface CaseBlock extends Node { + clauses: NodeArray; + } + interface CaseClause extends Node { + expression?: Expression; + statements: NodeArray; + } + interface DefaultClause extends Node { + statements: NodeArray; + } + type CaseOrDefaultClause = CaseClause | DefaultClause; + interface LabeledStatement extends Statement { + label: Identifier; + statement: Statement; + } + interface ThrowStatement extends Statement { + expression: Expression; + } + interface TryStatement extends Statement { + tryBlock: Block; + catchClause?: CatchClause; + finallyBlock?: Block; + } + interface CatchClause extends Node { + variableDeclaration: VariableDeclaration; + block: Block; + } + interface ClassLikeDeclaration extends Declaration { + name?: Identifier; + typeParameters?: NodeArray; + heritageClauses?: NodeArray; + members: NodeArray; + } + interface ClassDeclaration extends ClassLikeDeclaration, Statement { + } + interface ClassExpression extends ClassLikeDeclaration, PrimaryExpression { + } + interface ClassElement extends Declaration { + _classElementBrand: any; + } + interface InterfaceDeclaration extends Declaration, Statement { + name: Identifier; + typeParameters?: NodeArray; + heritageClauses?: NodeArray; + members: NodeArray; + } + interface HeritageClause extends Node { + token: SyntaxKind; + types?: NodeArray; + } + interface TypeAliasDeclaration extends Declaration, Statement { + name: Identifier; + typeParameters?: NodeArray; + type: TypeNode; + } + interface EnumMember extends Declaration { + name: DeclarationName; + initializer?: Expression; + } + interface EnumDeclaration extends Declaration, Statement { + name: Identifier; + members: NodeArray; + } + interface ModuleDeclaration extends Declaration, Statement { + name: Identifier | LiteralExpression; + body: ModuleBlock | ModuleDeclaration; + } + interface ModuleBlock extends Node, Statement { + statements: NodeArray; + } + interface ImportEqualsDeclaration extends Declaration, Statement { + name: Identifier; + moduleReference: EntityName | ExternalModuleReference; + } + interface ExternalModuleReference extends Node { + expression?: Expression; + } + interface ImportDeclaration extends Statement { + importClause?: ImportClause; + moduleSpecifier: Expression; + } + interface ImportClause extends Declaration { + name?: Identifier; + namedBindings?: NamespaceImport | NamedImports; + } + interface NamespaceImport extends Declaration { + name: Identifier; + } + interface ExportDeclaration extends Declaration, Statement { + exportClause?: NamedExports; + moduleSpecifier?: Expression; + } + interface NamedImportsOrExports extends Node { + elements: NodeArray; + } + type NamedImports = NamedImportsOrExports; + type NamedExports = NamedImportsOrExports; + interface ImportOrExportSpecifier extends Declaration { + propertyName?: Identifier; + name: Identifier; + } + type ImportSpecifier = ImportOrExportSpecifier; + type ExportSpecifier = ImportOrExportSpecifier; + interface ExportAssignment extends Declaration, Statement { + isExportEquals?: boolean; + expression: Expression; + } + interface FileReference extends TextRange { + fileName: string; + } + interface CommentRange extends TextRange { + hasTrailingNewLine?: boolean; + kind: SyntaxKind; + } + interface JSDocTypeExpression extends Node { + type: JSDocType; + } + interface JSDocType extends TypeNode { + _jsDocTypeBrand: any; + } + interface JSDocAllType extends JSDocType { + _JSDocAllTypeBrand: any; + } + interface JSDocUnknownType extends JSDocType { + _JSDocUnknownTypeBrand: any; + } + interface JSDocArrayType extends JSDocType { + elementType: JSDocType; + } + interface JSDocUnionType extends JSDocType { + types: NodeArray; + } + interface JSDocTupleType extends JSDocType { + types: NodeArray; + } + interface JSDocNonNullableType extends JSDocType { + type: JSDocType; + } + interface JSDocNullableType extends JSDocType { + type: JSDocType; + } + interface JSDocRecordType extends JSDocType, TypeLiteralNode { + members: NodeArray; + } + interface JSDocTypeReference extends JSDocType { + name: EntityName; + typeArguments: NodeArray; + } + interface JSDocOptionalType extends JSDocType { + type: JSDocType; + } + interface JSDocFunctionType extends JSDocType, SignatureDeclaration { + parameters: NodeArray; + type: JSDocType; + } + interface JSDocVariadicType extends JSDocType { + type: JSDocType; + } + interface JSDocConstructorType extends JSDocType { + type: JSDocType; + } + interface JSDocThisType extends JSDocType { + type: JSDocType; + } + interface JSDocRecordMember extends PropertyDeclaration { + name: Identifier | LiteralExpression; + type?: JSDocType; + } + interface JSDocComment extends Node { + tags: NodeArray; + } + interface JSDocTag extends Node { + atToken: Node; + tagName: Identifier; + } + interface JSDocTemplateTag extends JSDocTag { + typeParameters: NodeArray; + } + interface JSDocReturnTag extends JSDocTag { + typeExpression: JSDocTypeExpression; + } + interface JSDocTypeTag extends JSDocTag { + typeExpression: JSDocTypeExpression; + } + interface JSDocParameterTag extends JSDocTag { + preParameterName?: Identifier; + typeExpression?: JSDocTypeExpression; + postParameterName?: Identifier; + isBracketed: boolean; + } + interface SourceFile extends Declaration { + statements: NodeArray; + endOfFileToken: Node; + fileName: string; + text: string; + amdDependencies: { + path: string; + name: string; + }[]; + moduleName: string; + referencedFiles: FileReference[]; + languageVariant: LanguageVariant; + /** + * lib.d.ts should have a reference comment like + * + * /// + * + * If any other file has this comment, it signals not to include lib.d.ts + * because this containing file is intended to act as a default library. + */ + hasNoDefaultLib: boolean; + languageVersion: ScriptTarget; + } + interface ScriptReferenceHost { + getCompilerOptions(): CompilerOptions; + getSourceFile(fileName: string): SourceFile; + getCurrentDirectory(): string; + } + interface ParseConfigHost { + readDirectory(rootDir: string, extension: string, exclude: string[]): string[]; + } + interface WriteFileCallback { + (fileName: string, data: string, writeByteOrderMark: boolean, onError?: (message: string) => void): void; + } + class OperationCanceledException { + } + interface CancellationToken { + isCancellationRequested(): boolean; + /** @throws OperationCanceledException if isCancellationRequested is true */ + throwIfCancellationRequested(): void; + } + interface Program extends ScriptReferenceHost { + /** + * Get a list of root file names that were passed to a 'createProgram' + */ + getRootFileNames(): string[]; + /** + * Get a list of files in the program + */ + getSourceFiles(): SourceFile[]; + /** + * Emits the JavaScript and declaration files. If targetSourceFile is not specified, then + * the JavaScript and declaration files will be produced for all the files in this program. + * If targetSourceFile is specified, then only the JavaScript and declaration for that + * specific file will be generated. + * + * If writeFile is not specified then the writeFile callback from the compiler host will be + * used for writing the JavaScript and declaration files. Otherwise, the writeFile parameter + * will be invoked when writing the JavaScript and declaration files. + */ + emit(targetSourceFile?: SourceFile, writeFile?: WriteFileCallback, cancellationToken?: CancellationToken): EmitResult; + getOptionsDiagnostics(cancellationToken?: CancellationToken): Diagnostic[]; + getGlobalDiagnostics(cancellationToken?: CancellationToken): Diagnostic[]; + getSyntacticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): Diagnostic[]; + getSemanticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): Diagnostic[]; + getDeclarationDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): Diagnostic[]; + /** + * Gets a type checker that can be used to semantically analyze source fils in the program. + */ + getTypeChecker(): TypeChecker; + } + interface SourceMapSpan { + /** Line number in the .js file. */ + emittedLine: number; + /** Column number in the .js file. */ + emittedColumn: number; + /** Line number in the .ts file. */ + sourceLine: number; + /** Column number in the .ts file. */ + sourceColumn: number; + /** Optional name (index into names array) associated with this span. */ + nameIndex?: number; + /** .ts file (index into sources array) associated with this span */ + sourceIndex: number; + } + interface SourceMapData { + sourceMapFilePath: string; + jsSourceMappingURL: string; + sourceMapFile: string; + sourceMapSourceRoot: string; + sourceMapSources: string[]; + sourceMapSourcesContent?: string[]; + inputSourceFileNames: string[]; + sourceMapNames?: string[]; + sourceMapMappings: string; + sourceMapDecodedMappings: SourceMapSpan[]; + } + /** Return code used by getEmitOutput function to indicate status of the function */ + enum ExitStatus { + Success = 0, + DiagnosticsPresent_OutputsSkipped = 1, + DiagnosticsPresent_OutputsGenerated = 2, + } + interface EmitResult { + emitSkipped: boolean; + diagnostics: Diagnostic[]; + } + interface TypeChecker { + getTypeOfSymbolAtLocation(symbol: Symbol, node: Node): Type; + getDeclaredTypeOfSymbol(symbol: Symbol): Type; + getPropertiesOfType(type: Type): Symbol[]; + getPropertyOfType(type: Type, propertyName: string): Symbol; + getSignaturesOfType(type: Type, kind: SignatureKind): Signature[]; + getIndexTypeOfType(type: Type, kind: IndexKind): Type; + getBaseTypes(type: InterfaceType): ObjectType[]; + getReturnTypeOfSignature(signature: Signature): Type; + getSymbolsInScope(location: Node, meaning: SymbolFlags): Symbol[]; + getSymbolAtLocation(node: Node): Symbol; + getShorthandAssignmentValueSymbol(location: Node): Symbol; + getTypeAtLocation(node: Node): Type; + typeToString(type: Type, enclosingDeclaration?: Node, flags?: TypeFormatFlags): string; + symbolToString(symbol: Symbol, enclosingDeclaration?: Node, meaning?: SymbolFlags): string; + getSymbolDisplayBuilder(): SymbolDisplayBuilder; + getFullyQualifiedName(symbol: Symbol): string; + getAugmentedPropertiesOfType(type: Type): Symbol[]; + getRootSymbols(symbol: Symbol): Symbol[]; + getContextualType(node: Expression): Type; + getResolvedSignature(node: CallLikeExpression, candidatesOutArray?: Signature[]): Signature; + getSignatureFromDeclaration(declaration: SignatureDeclaration): Signature; + isImplementationOfOverload(node: FunctionLikeDeclaration): boolean; + isUndefinedSymbol(symbol: Symbol): boolean; + isArgumentsSymbol(symbol: Symbol): boolean; + getConstantValue(node: EnumMember | PropertyAccessExpression | ElementAccessExpression): number; + isValidPropertyAccess(node: PropertyAccessExpression | QualifiedName, propertyName: string): boolean; + getAliasedSymbol(symbol: Symbol): Symbol; + getExportsOfModule(moduleSymbol: Symbol): Symbol[]; + getJsxElementAttributesType(elementNode: JsxOpeningLikeElement): Type; + getJsxIntrinsicTagNames(): Symbol[]; + isOptionalParameter(node: ParameterDeclaration): boolean; + } + interface SymbolDisplayBuilder { + buildTypeDisplay(type: Type, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; + buildSymbolDisplay(symbol: Symbol, writer: SymbolWriter, enclosingDeclaration?: Node, meaning?: SymbolFlags, flags?: SymbolFormatFlags): void; + buildSignatureDisplay(signatures: Signature, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; + buildParameterDisplay(parameter: Symbol, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; + buildTypeParameterDisplay(tp: TypeParameter, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; + buildTypeParameterDisplayFromSymbol(symbol: Symbol, writer: SymbolWriter, enclosingDeclaraiton?: Node, flags?: TypeFormatFlags): void; + buildDisplayForParametersAndDelimiters(parameters: Symbol[], writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; + buildDisplayForTypeParametersAndDelimiters(typeParameters: TypeParameter[], writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; + buildReturnTypeDisplay(signature: Signature, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; + } + interface SymbolWriter { + writeKeyword(text: string): void; + writeOperator(text: string): void; + writePunctuation(text: string): void; + writeSpace(text: string): void; + writeStringLiteral(text: string): void; + writeParameter(text: string): void; + writeSymbol(text: string, symbol: Symbol): void; + writeLine(): void; + increaseIndent(): void; + decreaseIndent(): void; + clear(): void; + trackSymbol(symbol: Symbol, enclosingDeclaration?: Node, meaning?: SymbolFlags): void; + reportInaccessibleThisError(): void; + } + const enum TypeFormatFlags { + None = 0, + WriteArrayAsGenericType = 1, + UseTypeOfFunction = 2, + NoTruncation = 4, + WriteArrowStyleSignature = 8, + WriteOwnNameForAnyLike = 16, + WriteTypeArgumentsOfSignature = 32, + InElementType = 64, + UseFullyQualifiedType = 128, + } + const enum SymbolFormatFlags { + None = 0, + WriteTypeParametersOrArguments = 1, + UseOnlyExternalAliasing = 2, + } + interface TypePredicate { + parameterName: string; + parameterIndex: number; + type: Type; + } + const enum SymbolFlags { + None = 0, + FunctionScopedVariable = 1, + BlockScopedVariable = 2, + Property = 4, + EnumMember = 8, + Function = 16, + Class = 32, + Interface = 64, + ConstEnum = 128, + RegularEnum = 256, + ValueModule = 512, + NamespaceModule = 1024, + TypeLiteral = 2048, + ObjectLiteral = 4096, + Method = 8192, + Constructor = 16384, + GetAccessor = 32768, + SetAccessor = 65536, + Signature = 131072, + TypeParameter = 262144, + TypeAlias = 524288, + ExportValue = 1048576, + ExportType = 2097152, + ExportNamespace = 4194304, + Alias = 8388608, + Instantiated = 16777216, + Merged = 33554432, + Transient = 67108864, + Prototype = 134217728, + SyntheticProperty = 268435456, + Optional = 536870912, + ExportStar = 1073741824, + Enum = 384, + Variable = 3, + Value = 107455, + Type = 793056, + Namespace = 1536, + Module = 1536, + Accessor = 98304, + FunctionScopedVariableExcludes = 107454, + BlockScopedVariableExcludes = 107455, + ParameterExcludes = 107455, + PropertyExcludes = 107455, + EnumMemberExcludes = 107455, + FunctionExcludes = 106927, + ClassExcludes = 899519, + InterfaceExcludes = 792960, + RegularEnumExcludes = 899327, + ConstEnumExcludes = 899967, + ValueModuleExcludes = 106639, + NamespaceModuleExcludes = 0, + MethodExcludes = 99263, + GetAccessorExcludes = 41919, + SetAccessorExcludes = 74687, + TypeParameterExcludes = 530912, + TypeAliasExcludes = 793056, + AliasExcludes = 8388608, + ModuleMember = 8914931, + ExportHasLocal = 944, + HasExports = 1952, + HasMembers = 6240, + BlockScoped = 418, + PropertyOrAccessor = 98308, + Export = 7340032, + } + interface Symbol { + flags: SymbolFlags; + name: string; + declarations?: Declaration[]; + valueDeclaration?: Declaration; + members?: SymbolTable; + exports?: SymbolTable; + } + interface SymbolTable { + [index: string]: Symbol; + } + const enum TypeFlags { + Any = 1, + String = 2, + Number = 4, + Boolean = 8, + Void = 16, + Undefined = 32, + Null = 64, + Enum = 128, + StringLiteral = 256, + TypeParameter = 512, + Class = 1024, + Interface = 2048, + Reference = 4096, + Tuple = 8192, + Union = 16384, + Intersection = 32768, + Anonymous = 65536, + Instantiated = 131072, + ObjectLiteral = 524288, + ESSymbol = 16777216, + ThisType = 33554432, + StringLike = 258, + NumberLike = 132, + ObjectType = 80896, + UnionOrIntersection = 49152, + StructuredType = 130048, + } + type DestructuringPattern = BindingPattern | ObjectLiteralExpression | ArrayLiteralExpression; + interface Type { + flags: TypeFlags; + symbol?: Symbol; + pattern?: DestructuringPattern; + } + interface StringLiteralType extends Type { + text: string; + } + interface ObjectType extends Type { + } + interface InterfaceType extends ObjectType { + typeParameters: TypeParameter[]; + outerTypeParameters: TypeParameter[]; + localTypeParameters: TypeParameter[]; + thisType: TypeParameter; + } + interface InterfaceTypeWithDeclaredMembers extends InterfaceType { + declaredProperties: Symbol[]; + declaredCallSignatures: Signature[]; + declaredConstructSignatures: Signature[]; + declaredStringIndexType: Type; + declaredNumberIndexType: Type; + } + interface TypeReference extends ObjectType { + target: GenericType; + typeArguments: Type[]; + } + interface GenericType extends InterfaceType, TypeReference { + } + interface TupleType extends ObjectType { + elementTypes: Type[]; + } + interface UnionOrIntersectionType extends Type { + types: Type[]; + } + interface UnionType extends UnionOrIntersectionType { + } + interface IntersectionType extends UnionOrIntersectionType { + } + interface TypeParameter extends Type { + constraint: Type; + } + const enum SignatureKind { + Call = 0, + Construct = 1, + } + interface Signature { + declaration: SignatureDeclaration; + typeParameters: TypeParameter[]; + parameters: Symbol[]; + typePredicate?: TypePredicate; + } + const enum IndexKind { + String = 0, + Number = 1, + } + interface DiagnosticMessage { + key: string; + category: DiagnosticCategory; + code: number; + message: string; + } + /** + * A linked list of formatted diagnostic messages to be used as part of a multiline message. + * It is built from the bottom up, leaving the head to be the "main" diagnostic. + * While it seems that DiagnosticMessageChain is structurally similar to DiagnosticMessage, + * the difference is that messages are all preformatted in DMC. + */ + interface DiagnosticMessageChain { + messageText: string; + category: DiagnosticCategory; + code: number; + next?: DiagnosticMessageChain; + } + interface Diagnostic { + file: SourceFile; + start: number; + length: number; + messageText: string | DiagnosticMessageChain; + category: DiagnosticCategory; + code: number; + } + enum DiagnosticCategory { + Warning = 0, + Error = 1, + Message = 2, + } + const enum ModuleResolutionKind { + Classic = 1, + NodeJs = 2, + } + interface CompilerOptions { + allowNonTsExtensions?: boolean; + charset?: string; + declaration?: boolean; + diagnostics?: boolean; + emitBOM?: boolean; + help?: boolean; + init?: boolean; + inlineSourceMap?: boolean; + inlineSources?: boolean; + jsx?: JsxEmit; + listFiles?: boolean; + locale?: string; + mapRoot?: string; + module?: ModuleKind; + newLine?: NewLineKind; + noEmit?: boolean; + noEmitHelpers?: boolean; + noEmitOnError?: boolean; + noErrorTruncation?: boolean; + noImplicitAny?: boolean; + noLib?: boolean; + noResolve?: boolean; + out?: string; + outFile?: string; + outDir?: string; + preserveConstEnums?: boolean; + project?: string; + removeComments?: boolean; + rootDir?: string; + sourceMap?: boolean; + sourceRoot?: string; + suppressExcessPropertyErrors?: boolean; + suppressImplicitAnyIndexErrors?: boolean; + target?: ScriptTarget; + version?: boolean; + watch?: boolean; + isolatedModules?: boolean; + experimentalDecorators?: boolean; + emitDecoratorMetadata?: boolean; + moduleResolution?: ModuleResolutionKind; + forceConsistentCasingInFileNames?: boolean; + [option: string]: string | number | boolean; + } + const enum ModuleKind { + None = 0, + CommonJS = 1, + AMD = 2, + UMD = 3, + System = 4, + ES6 = 5, + ES2015 = 5, + } + const enum JsxEmit { + None = 0, + Preserve = 1, + React = 2, + } + const enum NewLineKind { + CarriageReturnLineFeed = 0, + LineFeed = 1, + } + interface LineAndCharacter { + line: number; + character: number; + } + const enum ScriptTarget { + ES3 = 0, + ES5 = 1, + ES6 = 2, + ES2015 = 2, + Latest = 2, + } + const enum LanguageVariant { + Standard = 0, + JSX = 1, + } + interface ParsedCommandLine { + options: CompilerOptions; + fileNames: string[]; + errors: Diagnostic[]; + } + interface ModuleResolutionHost { + fileExists(fileName: string): boolean; + readFile(fileName: string): string; + } + interface ResolvedModule { + resolvedFileName: string; + isExternalLibraryImport?: boolean; + } + interface ResolvedModuleWithFailedLookupLocations { + resolvedModule: ResolvedModule; + failedLookupLocations: string[]; + } + interface CompilerHost extends ModuleResolutionHost { + getSourceFile(fileName: string, languageVersion: ScriptTarget, onError?: (message: string) => void): SourceFile; + getCancellationToken?(): CancellationToken; + getDefaultLibFileName(options: CompilerOptions): string; + writeFile: WriteFileCallback; + getCurrentDirectory(): string; + getCanonicalFileName(fileName: string): string; + useCaseSensitiveFileNames(): boolean; + getNewLine(): string; + resolveModuleNames?(moduleNames: string[], containingFile: string): ResolvedModule[]; + } + interface TextSpan { + start: number; + length: number; + } + interface TextChangeRange { + span: TextSpan; + newLength: number; + } +} +declare namespace ts { + interface System { + args: string[]; + newLine: string; + useCaseSensitiveFileNames: boolean; + write(s: string): void; + readFile(path: string, encoding?: string): string; + writeFile(path: string, data: string, writeByteOrderMark?: boolean): void; + watchFile?(path: string, callback: (path: string, removed?: boolean) => void): FileWatcher; + watchDirectory?(path: string, callback: (path: string) => void, recursive?: boolean): FileWatcher; + resolvePath(path: string): string; + fileExists(path: string): boolean; + directoryExists(path: string): boolean; + createDirectory(path: string): void; + getExecutingFilePath(): string; + getCurrentDirectory(): string; + readDirectory(path: string, extension?: string, exclude?: string[]): string[]; + getMemoryUsage?(): number; + exit(exitCode?: number): void; + } + interface FileWatcher { + close(): void; + } + var sys: System; +} +declare namespace ts { + interface ErrorCallback { + (message: DiagnosticMessage, length: number): void; + } + interface Scanner { + getStartPos(): number; + getToken(): SyntaxKind; + getTextPos(): number; + getTokenPos(): number; + getTokenText(): string; + getTokenValue(): string; + hasExtendedUnicodeEscape(): boolean; + hasPrecedingLineBreak(): boolean; + isIdentifier(): boolean; + isReservedWord(): boolean; + isUnterminated(): boolean; + reScanGreaterToken(): SyntaxKind; + reScanSlashToken(): SyntaxKind; + reScanTemplateToken(): SyntaxKind; + scanJsxIdentifier(): SyntaxKind; + reScanJsxToken(): SyntaxKind; + scanJsxToken(): SyntaxKind; + scan(): SyntaxKind; + setText(text: string, start?: number, length?: number): void; + setOnError(onError: ErrorCallback): void; + setScriptTarget(scriptTarget: ScriptTarget): void; + setLanguageVariant(variant: LanguageVariant): void; + setTextPos(textPos: number): void; + lookAhead(callback: () => T): T; + tryScan(callback: () => T): T; + } + function tokenToString(t: SyntaxKind): string; + function getPositionOfLineAndCharacter(sourceFile: SourceFile, line: number, character: number): number; + function getLineAndCharacterOfPosition(sourceFile: SourceFile, position: number): LineAndCharacter; + function isWhiteSpace(ch: number): boolean; + function isLineBreak(ch: number): boolean; + function couldStartTrivia(text: string, pos: number): boolean; + function getLeadingCommentRanges(text: string, pos: number): CommentRange[]; + function getTrailingCommentRanges(text: string, pos: number): CommentRange[]; + /** Optionally, get the shebang */ + function getShebang(text: string): string; + function isIdentifierStart(ch: number, languageVersion: ScriptTarget): boolean; + function isIdentifierPart(ch: number, languageVersion: ScriptTarget): boolean; + function createScanner(languageVersion: ScriptTarget, skipTrivia: boolean, languageVariant?: LanguageVariant, text?: string, onError?: ErrorCallback, start?: number, length?: number): Scanner; +} +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; + /** + * Called to merge all the changes that occurred across several versions of a script snapshot + * into a single change. i.e. if a user keeps making successive edits to a script we will + * have a text change from V1 to V2, V2 to V3, ..., Vn. + * + * This function will then merge those changes into a single change range valid between V1 and + * Vn. + */ + function collapseTextChangeRangesAcrossMultipleVersions(changes: TextChangeRange[]): TextChangeRange; + function getTypeParameterOwner(d: Declaration): Declaration; +} +declare namespace ts { + function getNodeConstructor(kind: SyntaxKind): new (pos?: number, end?: number) => Node; + 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): SourceFile; + function updateSourceFile(sourceFile: SourceFile, newText: string, textChangeRange: TextChangeRange, aggressiveChecks?: boolean): SourceFile; +} +declare namespace ts { + const version: string; + function findConfigFile(searchPath: string): string; + function resolveTripleslashReference(moduleName: string, containingFile: string): string; + function resolveModuleName(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost): ResolvedModuleWithFailedLookupLocations; + function nodeModuleNameResolver(moduleName: string, containingFile: string, 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[]; + function flattenDiagnosticMessageText(messageText: string | DiagnosticMessageChain, newLine: string): string; + function createProgram(rootNames: string[], options: CompilerOptions, host?: CompilerHost, oldProgram?: Program): Program; +} +declare namespace ts { + function parseCommandLine(commandLine: string[], readFile?: (path: string) => string): ParsedCommandLine; + /** + * Read tsconfig.json file + * @param fileName The path to the config file + */ + function readConfigFile(fileName: string, readFile: (path: string) => string): { + config?: any; + error?: Diagnostic; + }; + /** + * Parse the text of the tsconfig.json file + * @param fileName The path to the config file + * @param jsonText The text of the config file + */ + function parseConfigFileTextToJson(fileName: string, jsonText: string): { + config?: any; + error?: Diagnostic; + }; + /** + * Parse the contents of a config file (tsconfig.json). + * @param json The contents of the config file to parse + * @param host Instance of ParseConfigHost used to enumerate files in folder. + * @param basePath A root directory to resolve relative path entries in the config + * file to. e.g. outDir + */ + function parseJsonConfigFileContent(json: any, host: ParseConfigHost, basePath: string): ParsedCommandLine; + function convertCompilerOptionsFromJson(jsonOptions: any, basePath: string): { + options: CompilerOptions; + errors: Diagnostic[]; + }; +} +declare namespace ts { + /** The version of the language service API */ + let servicesVersion: string; + interface Node { + getSourceFile(): SourceFile; + getChildCount(sourceFile?: SourceFile): number; + getChildAt(index: number, sourceFile?: SourceFile): Node; + getChildren(sourceFile?: SourceFile): Node[]; + getStart(sourceFile?: SourceFile): number; + getFullStart(): number; + getEnd(): number; + getWidth(sourceFile?: SourceFile): number; + getFullWidth(): number; + getLeadingTriviaWidth(sourceFile?: SourceFile): number; + getFullText(sourceFile?: SourceFile): string; + getText(sourceFile?: SourceFile): string; + getFirstToken(sourceFile?: SourceFile): Node; + getLastToken(sourceFile?: SourceFile): Node; + } + interface Symbol { + getFlags(): SymbolFlags; + getName(): string; + getDeclarations(): Declaration[]; + getDocumentationComment(): SymbolDisplayPart[]; + } + interface Type { + getFlags(): TypeFlags; + getSymbol(): Symbol; + getProperties(): Symbol[]; + getProperty(propertyName: string): Symbol; + getApparentProperties(): Symbol[]; + getCallSignatures(): Signature[]; + getConstructSignatures(): Signature[]; + getStringIndexType(): Type; + getNumberIndexType(): Type; + getBaseTypes(): ObjectType[]; + } + interface Signature { + getDeclaration(): SignatureDeclaration; + getTypeParameters(): Type[]; + getParameters(): Symbol[]; + getReturnType(): Type; + getDocumentationComment(): SymbolDisplayPart[]; + } + interface SourceFile { + getLineAndCharacterOfPosition(pos: number): LineAndCharacter; + getLineStarts(): number[]; + getPositionOfLineAndCharacter(line: number, character: number): number; + update(newText: string, textChangeRange: TextChangeRange): SourceFile; + } + /** + * Represents an immutable snapshot of a script at a specified time.Once acquired, the + * snapshot is observably immutable. i.e. the same calls with the same parameters will return + * the same values. + */ + interface IScriptSnapshot { + /** Gets a portion of the script snapshot specified by [start, end). */ + getText(start: number, end: number): string; + /** Gets the length of this script snapshot. */ + getLength(): number; + /** + * Gets the TextChangeRange that describe how the text changed between this text and + * an older version. This information is used by the incremental parser to determine + * what sections of the script need to be re-parsed. 'undefined' can be returned if the + * change range cannot be determined. However, in that case, incremental parsing will + * not happen and the entire document will be re - parsed. + */ + getChangeRange(oldSnapshot: IScriptSnapshot): TextChangeRange; + /** Releases all resources held by this script snapshot */ + dispose?(): void; + } + module ScriptSnapshot { + function fromString(text: string): IScriptSnapshot; + } + interface PreProcessedFileInfo { + referencedFiles: FileReference[]; + importedFiles: FileReference[]; + ambientExternalModules: string[]; + isLibFile: boolean; + } + interface HostCancellationToken { + isCancellationRequested(): boolean; + } + interface LanguageServiceHost { + getCompilationSettings(): CompilerOptions; + getNewLine?(): string; + getProjectVersion?(): string; + getScriptFileNames(): string[]; + getScriptVersion(fileName: string): string; + getScriptSnapshot(fileName: string): IScriptSnapshot; + getLocalizedDiagnosticMessages?(): any; + getCancellationToken?(): HostCancellationToken; + getCurrentDirectory(): string; + getDefaultLibFileName(options: CompilerOptions): string; + log?(s: string): void; + trace?(s: string): void; + error?(s: string): void; + useCaseSensitiveFileNames?(): boolean; + resolveModuleNames?(moduleNames: string[], containingFile: string): ResolvedModule[]; + } + interface LanguageService { + cleanupSemanticCache(): void; + getSyntacticDiagnostics(fileName: string): Diagnostic[]; + getSemanticDiagnostics(fileName: string): Diagnostic[]; + getCompilerOptionsDiagnostics(): Diagnostic[]; + /** + * @deprecated Use getEncodedSyntacticClassifications instead. + */ + getSyntacticClassifications(fileName: string, span: TextSpan): ClassifiedSpan[]; + /** + * @deprecated Use getEncodedSemanticClassifications instead. + */ + getSemanticClassifications(fileName: string, span: TextSpan): ClassifiedSpan[]; + getEncodedSyntacticClassifications(fileName: string, span: TextSpan): Classifications; + getEncodedSemanticClassifications(fileName: string, span: TextSpan): Classifications; + getCompletionsAtPosition(fileName: string, position: number): CompletionInfo; + getCompletionEntryDetails(fileName: string, position: number, entryName: string): CompletionEntryDetails; + getQuickInfoAtPosition(fileName: string, position: number): QuickInfo; + getNameOrDottedNameSpan(fileName: string, startPos: number, endPos: number): TextSpan; + getBreakpointStatementAtPosition(fileName: string, position: number): TextSpan; + getSignatureHelpItems(fileName: string, position: number): SignatureHelpItems; + getRenameInfo(fileName: string, position: number): RenameInfo; + findRenameLocations(fileName: string, position: number, findInStrings: boolean, findInComments: boolean): RenameLocation[]; + getDefinitionAtPosition(fileName: string, position: number): DefinitionInfo[]; + getTypeDefinitionAtPosition(fileName: string, position: number): DefinitionInfo[]; + getReferencesAtPosition(fileName: string, position: number): ReferenceEntry[]; + findReferences(fileName: string, position: number): ReferencedSymbol[]; + getDocumentHighlights(fileName: string, position: number, filesToSearch: string[]): DocumentHighlights[]; + /** @deprecated */ + getOccurrencesAtPosition(fileName: string, position: number): ReferenceEntry[]; + getNavigateToItems(searchValue: string, maxResultCount?: number): NavigateToItem[]; + getNavigationBarItems(fileName: string): NavigationBarItem[]; + 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[]; + getDocCommentTemplateAtPosition(fileName: string, position: number): TextInsertion; + getEmitOutput(fileName: string): EmitOutput; + getProgram(): Program; + getSourceFile(fileName: string): SourceFile; + dispose(): void; + } + interface Classifications { + spans: number[]; + endOfLineState: EndOfLineState; + } + interface ClassifiedSpan { + textSpan: TextSpan; + classificationType: string; + } + interface NavigationBarItem { + text: string; + kind: string; + kindModifiers: string; + spans: TextSpan[]; + childItems: NavigationBarItem[]; + indent: number; + bolded: boolean; + grayed: boolean; + } + interface TodoCommentDescriptor { + text: string; + priority: number; + } + interface TodoComment { + descriptor: TodoCommentDescriptor; + message: string; + position: number; + } + class TextChange { + span: TextSpan; + newText: string; + } + interface TextInsertion { + newText: string; + /** The position in newText the caret should point to after the insertion. */ + caretOffset: number; + } + interface RenameLocation { + textSpan: TextSpan; + fileName: string; + } + interface ReferenceEntry { + textSpan: TextSpan; + fileName: string; + isWriteAccess: boolean; + } + interface DocumentHighlights { + fileName: string; + highlightSpans: HighlightSpan[]; + } + module HighlightSpanKind { + const none: string; + const definition: string; + const reference: string; + const writtenReference: string; + } + interface HighlightSpan { + fileName?: string; + textSpan: TextSpan; + kind: string; + } + interface NavigateToItem { + name: string; + kind: string; + kindModifiers: string; + matchKind: string; + isCaseSensitive: boolean; + fileName: string; + textSpan: TextSpan; + containerName: string; + containerKind: string; + } + interface EditorOptions { + IndentSize: number; + TabSize: number; + NewLineCharacter: string; + ConvertTabsToSpaces: boolean; + IndentStyle: IndentStyle; + } + enum IndentStyle { + None = 0, + Block = 1, + Smart = 2, + } + interface FormatCodeOptions extends EditorOptions { + InsertSpaceAfterCommaDelimiter: boolean; + InsertSpaceAfterSemicolonInForStatements: boolean; + InsertSpaceBeforeAndAfterBinaryOperators: boolean; + InsertSpaceAfterKeywordsInControlFlowStatements: boolean; + InsertSpaceAfterFunctionKeywordForAnonymousFunctions: boolean; + InsertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis: boolean; + InsertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets: boolean; + PlaceOpenBraceOnNewLineForFunctions: boolean; + PlaceOpenBraceOnNewLineForControlBlocks: boolean; + [s: string]: boolean | number | string; + } + interface DefinitionInfo { + fileName: string; + textSpan: TextSpan; + kind: string; + name: string; + containerKind: string; + containerName: string; + } + interface ReferencedSymbol { + definition: DefinitionInfo; + references: ReferenceEntry[]; + } + enum SymbolDisplayPartKind { + aliasName = 0, + className = 1, + enumName = 2, + fieldName = 3, + interfaceName = 4, + keyword = 5, + lineBreak = 6, + numericLiteral = 7, + stringLiteral = 8, + localName = 9, + methodName = 10, + moduleName = 11, + operator = 12, + parameterName = 13, + propertyName = 14, + punctuation = 15, + space = 16, + text = 17, + typeParameterName = 18, + enumMemberName = 19, + functionName = 20, + regularExpressionLiteral = 21, + } + interface SymbolDisplayPart { + text: string; + kind: string; + } + interface QuickInfo { + kind: string; + kindModifiers: string; + textSpan: TextSpan; + displayParts: SymbolDisplayPart[]; + documentation: SymbolDisplayPart[]; + } + interface RenameInfo { + canRename: boolean; + localizedErrorMessage: string; + displayName: string; + fullDisplayName: string; + kind: string; + kindModifiers: string; + triggerSpan: TextSpan; + } + interface SignatureHelpParameter { + name: string; + documentation: SymbolDisplayPart[]; + displayParts: SymbolDisplayPart[]; + isOptional: boolean; + } + /** + * Represents a single signature to show in signature help. + * The id is used for subsequent calls into the language service to ask questions about the + * signature help item in the context of any documents that have been updated. i.e. after + * an edit has happened, while signature help is still active, the host can ask important + * questions like 'what parameter is the user currently contained within?'. + */ + interface SignatureHelpItem { + isVariadic: boolean; + prefixDisplayParts: SymbolDisplayPart[]; + suffixDisplayParts: SymbolDisplayPart[]; + separatorDisplayParts: SymbolDisplayPart[]; + parameters: SignatureHelpParameter[]; + documentation: SymbolDisplayPart[]; + } + /** + * Represents a set of signature help items, and the preferred item that should be selected. + */ + interface SignatureHelpItems { + items: SignatureHelpItem[]; + applicableSpan: TextSpan; + selectedItemIndex: number; + argumentIndex: number; + argumentCount: number; + } + interface CompletionInfo { + isMemberCompletion: boolean; + isNewIdentifierLocation: boolean; + entries: CompletionEntry[]; + } + interface CompletionEntry { + name: string; + kind: string; + kindModifiers: string; + sortText: string; + } + interface CompletionEntryDetails { + name: string; + kind: string; + kindModifiers: string; + displayParts: SymbolDisplayPart[]; + documentation: SymbolDisplayPart[]; + } + interface OutliningSpan { + /** The span of the document to actually collapse. */ + textSpan: TextSpan; + /** The span of the document to display when the user hovers over the collapsed span. */ + hintSpan: TextSpan; + /** The text to display in the editor for the collapsed region. */ + bannerText: string; + /** + * Whether or not this region should be automatically collapsed when + * the 'Collapse to Definitions' command is invoked. + */ + autoCollapse: boolean; + } + interface EmitOutput { + outputFiles: OutputFile[]; + emitSkipped: boolean; + } + const enum OutputFileType { + JavaScript = 0, + SourceMap = 1, + Declaration = 2, + } + interface OutputFile { + name: string; + writeByteOrderMark: boolean; + text: string; + } + const enum EndOfLineState { + None = 0, + InMultiLineCommentTrivia = 1, + InSingleQuoteStringLiteral = 2, + InDoubleQuoteStringLiteral = 3, + InTemplateHeadOrNoSubstitutionTemplate = 4, + InTemplateMiddleOrTail = 5, + InTemplateSubstitutionPosition = 6, + } + enum TokenClass { + Punctuation = 0, + Keyword = 1, + Operator = 2, + Comment = 3, + Whitespace = 4, + Identifier = 5, + NumberLiteral = 6, + StringLiteral = 7, + RegExpLiteral = 8, + } + interface ClassificationResult { + finalLexState: EndOfLineState; + entries: ClassificationInfo[]; + } + interface ClassificationInfo { + length: number; + classification: TokenClass; + } + interface Classifier { + /** + * Gives lexical classifications of tokens on a line without any syntactic context. + * For instance, a token consisting of the text 'string' can be either an identifier + * named 'string' or the keyword 'string', however, because this classifier is not aware, + * it relies on certain heuristics to give acceptable results. For classifications where + * speed trumps accuracy, this function is preferable; however, for true accuracy, the + * syntactic classifier is ideal. In fact, in certain editing scenarios, combining the + * lexical, syntactic, and semantic classifiers may issue the best user experience. + * + * @param text The text of a line to classify. + * @param lexState The state of the lexical classifier at the end of the previous line. + * @param syntacticClassifierAbsent Whether the client is *not* using a syntactic classifier. + * If there is no syntactic classifier (syntacticClassifierAbsent=true), + * certain heuristics may be used in its place; however, if there is a + * syntactic classifier (syntacticClassifierAbsent=false), certain + * classifications which may be incorrectly categorized will be given + * back as Identifiers in order to allow the syntactic classifier to + * subsume the classification. + * @deprecated Use getLexicalClassifications instead. + */ + getClassificationsForLine(text: string, lexState: EndOfLineState, syntacticClassifierAbsent: boolean): ClassificationResult; + getEncodedLexicalClassifications(text: string, endOfLineState: EndOfLineState, syntacticClassifierAbsent: boolean): Classifications; + } + /** + * The document registry represents a store of SourceFile objects that can be shared between + * multiple LanguageService instances. A LanguageService instance holds on the SourceFile (AST) + * of files in the context. + * SourceFile objects account for most of the memory usage by the language service. Sharing + * the same DocumentRegistry instance between different instances of LanguageService allow + * for more efficient memory utilization since all projects will share at least the library + * file (lib.d.ts). + * + * A more advanced use of the document registry is to serialize sourceFile objects to disk + * and re-hydrate them when needed. + * + * To create a default DocumentRegistry, use createDocumentRegistry to create one, and pass it + * to all subsequent createLanguageService calls. + */ + interface DocumentRegistry { + /** + * Request a stored SourceFile with a given fileName and compilationSettings. + * The first call to acquire will call createLanguageServiceSourceFile to generate + * the SourceFile if was not found in the registry. + * + * @param fileName The name of the file requested + * @param compilationSettings Some compilation settings like target affects the + * shape of a the resulting SourceFile. This allows the DocumentRegistry to store + * multiple copies of the same file for different compilation settings. + * @parm scriptSnapshot Text of the file. Only used if the file was not found + * in the registry and a new one was created. + * @parm version Current version of the file. Only used if the file was not found + * in the registry and a new one was created. + */ + acquireDocument(fileName: string, compilationSettings: CompilerOptions, scriptSnapshot: IScriptSnapshot, version: string): SourceFile; + /** + * Request an updated version of an already existing SourceFile with a given fileName + * and compilationSettings. The update will in-turn call updateLanguageServiceSourceFile + * to get an updated SourceFile. + * + * @param fileName The name of the file requested + * @param compilationSettings Some compilation settings like target affects the + * shape of a the resulting SourceFile. This allows the DocumentRegistry to store + * multiple copies of the same file for different compilation settings. + * @param scriptSnapshot Text of the file. + * @param version Current version of the file. + */ + updateDocument(fileName: string, compilationSettings: CompilerOptions, scriptSnapshot: IScriptSnapshot, version: string): SourceFile; + /** + * Informs the DocumentRegistry that a file is not needed any longer. + * + * Note: It is not allowed to call release on a SourceFile that was not acquired from + * this registry originally. + * + * @param fileName The name of the file to be released + * @param compilationSettings The compilation settings used to acquire the file + */ + releaseDocument(fileName: string, compilationSettings: CompilerOptions): void; + reportStats(): string; + } + module ScriptElementKind { + const unknown: string; + const warning: string; + const keyword: string; + const scriptElement: string; + const moduleElement: string; + const classElement: string; + const localClassElement: string; + const interfaceElement: string; + const typeElement: string; + const enumElement: string; + const variableElement: string; + const localVariableElement: string; + const functionElement: string; + const localFunctionElement: string; + const memberFunctionElement: string; + const memberGetAccessorElement: string; + const memberSetAccessorElement: string; + const memberVariableElement: string; + const constructorImplementationElement: string; + const callSignatureElement: string; + const indexSignatureElement: string; + const constructSignatureElement: string; + const parameterElement: string; + const typeParameterElement: string; + const primitiveType: string; + const label: string; + const alias: string; + const constElement: string; + const letElement: string; + } + module ScriptElementKindModifier { + const none: string; + const publicMemberModifier: string; + const privateMemberModifier: string; + const protectedMemberModifier: string; + const exportedModifier: string; + const ambientModifier: string; + const staticModifier: string; + const abstractModifier: string; + } + class ClassificationTypeNames { + static comment: string; + static identifier: string; + static keyword: string; + static numericLiteral: string; + static operator: string; + static stringLiteral: string; + static whiteSpace: string; + static text: string; + static punctuation: string; + static className: string; + static enumName: string; + static interfaceName: string; + static moduleName: string; + static typeParameterName: string; + static typeAliasName: string; + static parameterName: string; + static docCommentTagName: string; + } + const enum ClassificationType { + comment = 1, + identifier = 2, + keyword = 3, + numericLiteral = 4, + operator = 5, + stringLiteral = 6, + regularExpressionLiteral = 7, + whiteSpace = 8, + text = 9, + punctuation = 10, + className = 11, + enumName = 12, + interfaceName = 13, + moduleName = 14, + typeParameterName = 15, + typeAliasName = 16, + parameterName = 17, + docCommentTagName = 18, + } + interface DisplayPartsSymbolWriter extends SymbolWriter { + displayParts(): SymbolDisplayPart[]; + } + function displayPartsToString(displayParts: SymbolDisplayPart[]): string; + function getDefaultCompilerOptions(): CompilerOptions; + interface TranspileOptions { + compilerOptions?: CompilerOptions; + fileName?: string; + reportDiagnostics?: boolean; + moduleName?: string; + renamedDependencies?: Map; + } + interface TranspileOutput { + outputText: string; + diagnostics?: Diagnostic[]; + sourceMapText?: string; + } + function transpileModule(input: string, transpileOptions: TranspileOptions): TranspileOutput; + function transpile(input: string, compilerOptions?: CompilerOptions, fileName?: string, diagnostics?: Diagnostic[], moduleName?: string): string; + function createLanguageServiceSourceFile(fileName: string, scriptSnapshot: IScriptSnapshot, scriptTarget: ScriptTarget, version: string, setNodeParents: boolean): SourceFile; + let disableIncrementalParsing: boolean; + function updateLanguageServiceSourceFile(sourceFile: SourceFile, scriptSnapshot: IScriptSnapshot, version: string, textChangeRange: TextChangeRange, aggressiveChecks?: boolean): SourceFile; + function createGetCanonicalFileName(useCaseSensitivefileNames: boolean): (fileName: string) => string; + function createDocumentRegistry(useCaseSensitiveFileNames?: boolean): DocumentRegistry; + function preProcessFile(sourceText: string, readImportFiles?: boolean): PreProcessedFileInfo; + function createLanguageService(host: LanguageServiceHost, documentRegistry?: DocumentRegistry): LanguageService; + function createClassifier(): Classifier; + /** + * Get the path of the default library files (lib.d.ts) as distributed with the typescript + * node package. + * The functionality is not supported if the ts module is consumed outside of a node module. + */ + function getDefaultLibFilePath(options: CompilerOptions): string; +} diff --git a/lib/typescriptServices.js b/lib/typescriptServices.js index 6551e1be180..1e0c0edad05 100644 --- a/lib/typescriptServices.js +++ b/lib/typescriptServices.js @@ -13,50336 +13,50781 @@ See the Apache Version 2.0 License for specific language governing permissions and limitations under the License. ***************************************************************************** */ -var ts; -(function (ts) { - // token > SyntaxKind.Identifer => token is a keyword - // Also, If you add a new SyntaxKind be sure to keep the `Markers` section at the bottom in sync - (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"; - // We detect and preserve #! on the first line - SyntaxKind[SyntaxKind["ShebangTrivia"] = 6] = "ShebangTrivia"; - // We detect and provide better error recovery when we encounter a git merge marker. This - // allows us to edit files with git-conflict markers in them in a much more pleasant manner. - SyntaxKind[SyntaxKind["ConflictMarkerTrivia"] = 7] = "ConflictMarkerTrivia"; - // Literals - SyntaxKind[SyntaxKind["NumericLiteral"] = 8] = "NumericLiteral"; - SyntaxKind[SyntaxKind["StringLiteral"] = 9] = "StringLiteral"; - SyntaxKind[SyntaxKind["RegularExpressionLiteral"] = 10] = "RegularExpressionLiteral"; - SyntaxKind[SyntaxKind["NoSubstitutionTemplateLiteral"] = 11] = "NoSubstitutionTemplateLiteral"; - // Pseudo-literals - SyntaxKind[SyntaxKind["TemplateHead"] = 12] = "TemplateHead"; - SyntaxKind[SyntaxKind["TemplateMiddle"] = 13] = "TemplateMiddle"; - SyntaxKind[SyntaxKind["TemplateTail"] = 14] = "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"; - // 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"; - // Identifiers - SyntaxKind[SyntaxKind["Identifier"] = 69] = "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"; - // 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"; - // 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["RequireKeyword"] = 127] = "RequireKeyword"; - SyntaxKind[SyntaxKind["NumberKeyword"] = 128] = "NumberKeyword"; - SyntaxKind[SyntaxKind["SetKeyword"] = 129] = "SetKeyword"; - SyntaxKind[SyntaxKind["StringKeyword"] = 130] = "StringKeyword"; - SyntaxKind[SyntaxKind["SymbolKeyword"] = 131] = "SymbolKeyword"; - SyntaxKind[SyntaxKind["TypeKeyword"] = 132] = "TypeKeyword"; - SyntaxKind[SyntaxKind["FromKeyword"] = 133] = "FromKeyword"; - SyntaxKind[SyntaxKind["OfKeyword"] = 134] = "OfKeyword"; - // Parse tree nodes - // Names - SyntaxKind[SyntaxKind["QualifiedName"] = 135] = "QualifiedName"; - SyntaxKind[SyntaxKind["ComputedPropertyName"] = 136] = "ComputedPropertyName"; - // Signature elements - SyntaxKind[SyntaxKind["TypeParameter"] = 137] = "TypeParameter"; - SyntaxKind[SyntaxKind["Parameter"] = 138] = "Parameter"; - SyntaxKind[SyntaxKind["Decorator"] = 139] = "Decorator"; - // TypeMember - SyntaxKind[SyntaxKind["PropertySignature"] = 140] = "PropertySignature"; - SyntaxKind[SyntaxKind["PropertyDeclaration"] = 141] = "PropertyDeclaration"; - SyntaxKind[SyntaxKind["MethodSignature"] = 142] = "MethodSignature"; - SyntaxKind[SyntaxKind["MethodDeclaration"] = 143] = "MethodDeclaration"; - SyntaxKind[SyntaxKind["Constructor"] = 144] = "Constructor"; - SyntaxKind[SyntaxKind["GetAccessor"] = 145] = "GetAccessor"; - SyntaxKind[SyntaxKind["SetAccessor"] = 146] = "SetAccessor"; - SyntaxKind[SyntaxKind["CallSignature"] = 147] = "CallSignature"; - SyntaxKind[SyntaxKind["ConstructSignature"] = 148] = "ConstructSignature"; - SyntaxKind[SyntaxKind["IndexSignature"] = 149] = "IndexSignature"; - // Type - SyntaxKind[SyntaxKind["TypePredicate"] = 150] = "TypePredicate"; - SyntaxKind[SyntaxKind["TypeReference"] = 151] = "TypeReference"; - SyntaxKind[SyntaxKind["FunctionType"] = 152] = "FunctionType"; - SyntaxKind[SyntaxKind["ConstructorType"] = 153] = "ConstructorType"; - SyntaxKind[SyntaxKind["TypeQuery"] = 154] = "TypeQuery"; - SyntaxKind[SyntaxKind["TypeLiteral"] = 155] = "TypeLiteral"; - SyntaxKind[SyntaxKind["ArrayType"] = 156] = "ArrayType"; - SyntaxKind[SyntaxKind["TupleType"] = 157] = "TupleType"; - SyntaxKind[SyntaxKind["UnionType"] = 158] = "UnionType"; - SyntaxKind[SyntaxKind["IntersectionType"] = 159] = "IntersectionType"; - SyntaxKind[SyntaxKind["ParenthesizedType"] = 160] = "ParenthesizedType"; - // Binding patterns - SyntaxKind[SyntaxKind["ObjectBindingPattern"] = 161] = "ObjectBindingPattern"; - SyntaxKind[SyntaxKind["ArrayBindingPattern"] = 162] = "ArrayBindingPattern"; - SyntaxKind[SyntaxKind["BindingElement"] = 163] = "BindingElement"; - // Expression - SyntaxKind[SyntaxKind["ArrayLiteralExpression"] = 164] = "ArrayLiteralExpression"; - SyntaxKind[SyntaxKind["ObjectLiteralExpression"] = 165] = "ObjectLiteralExpression"; - SyntaxKind[SyntaxKind["PropertyAccessExpression"] = 166] = "PropertyAccessExpression"; - SyntaxKind[SyntaxKind["ElementAccessExpression"] = 167] = "ElementAccessExpression"; - SyntaxKind[SyntaxKind["CallExpression"] = 168] = "CallExpression"; - SyntaxKind[SyntaxKind["NewExpression"] = 169] = "NewExpression"; - SyntaxKind[SyntaxKind["TaggedTemplateExpression"] = 170] = "TaggedTemplateExpression"; - SyntaxKind[SyntaxKind["TypeAssertionExpression"] = 171] = "TypeAssertionExpression"; - SyntaxKind[SyntaxKind["ParenthesizedExpression"] = 172] = "ParenthesizedExpression"; - SyntaxKind[SyntaxKind["FunctionExpression"] = 173] = "FunctionExpression"; - SyntaxKind[SyntaxKind["ArrowFunction"] = 174] = "ArrowFunction"; - SyntaxKind[SyntaxKind["DeleteExpression"] = 175] = "DeleteExpression"; - SyntaxKind[SyntaxKind["TypeOfExpression"] = 176] = "TypeOfExpression"; - SyntaxKind[SyntaxKind["VoidExpression"] = 177] = "VoidExpression"; - SyntaxKind[SyntaxKind["AwaitExpression"] = 178] = "AwaitExpression"; - SyntaxKind[SyntaxKind["PrefixUnaryExpression"] = 179] = "PrefixUnaryExpression"; - SyntaxKind[SyntaxKind["PostfixUnaryExpression"] = 180] = "PostfixUnaryExpression"; - SyntaxKind[SyntaxKind["BinaryExpression"] = 181] = "BinaryExpression"; - SyntaxKind[SyntaxKind["ConditionalExpression"] = 182] = "ConditionalExpression"; - SyntaxKind[SyntaxKind["TemplateExpression"] = 183] = "TemplateExpression"; - SyntaxKind[SyntaxKind["YieldExpression"] = 184] = "YieldExpression"; - SyntaxKind[SyntaxKind["SpreadElementExpression"] = 185] = "SpreadElementExpression"; - SyntaxKind[SyntaxKind["ClassExpression"] = 186] = "ClassExpression"; - SyntaxKind[SyntaxKind["OmittedExpression"] = 187] = "OmittedExpression"; - SyntaxKind[SyntaxKind["ExpressionWithTypeArguments"] = 188] = "ExpressionWithTypeArguments"; - SyntaxKind[SyntaxKind["AsExpression"] = 189] = "AsExpression"; - // Misc - SyntaxKind[SyntaxKind["TemplateSpan"] = 190] = "TemplateSpan"; - SyntaxKind[SyntaxKind["SemicolonClassElement"] = 191] = "SemicolonClassElement"; - // Element - SyntaxKind[SyntaxKind["Block"] = 192] = "Block"; - SyntaxKind[SyntaxKind["VariableStatement"] = 193] = "VariableStatement"; - SyntaxKind[SyntaxKind["EmptyStatement"] = 194] = "EmptyStatement"; - SyntaxKind[SyntaxKind["ExpressionStatement"] = 195] = "ExpressionStatement"; - SyntaxKind[SyntaxKind["IfStatement"] = 196] = "IfStatement"; - SyntaxKind[SyntaxKind["DoStatement"] = 197] = "DoStatement"; - SyntaxKind[SyntaxKind["WhileStatement"] = 198] = "WhileStatement"; - SyntaxKind[SyntaxKind["ForStatement"] = 199] = "ForStatement"; - SyntaxKind[SyntaxKind["ForInStatement"] = 200] = "ForInStatement"; - SyntaxKind[SyntaxKind["ForOfStatement"] = 201] = "ForOfStatement"; - SyntaxKind[SyntaxKind["ContinueStatement"] = 202] = "ContinueStatement"; - SyntaxKind[SyntaxKind["BreakStatement"] = 203] = "BreakStatement"; - SyntaxKind[SyntaxKind["ReturnStatement"] = 204] = "ReturnStatement"; - SyntaxKind[SyntaxKind["WithStatement"] = 205] = "WithStatement"; - SyntaxKind[SyntaxKind["SwitchStatement"] = 206] = "SwitchStatement"; - SyntaxKind[SyntaxKind["LabeledStatement"] = 207] = "LabeledStatement"; - SyntaxKind[SyntaxKind["ThrowStatement"] = 208] = "ThrowStatement"; - SyntaxKind[SyntaxKind["TryStatement"] = 209] = "TryStatement"; - SyntaxKind[SyntaxKind["DebuggerStatement"] = 210] = "DebuggerStatement"; - SyntaxKind[SyntaxKind["VariableDeclaration"] = 211] = "VariableDeclaration"; - SyntaxKind[SyntaxKind["VariableDeclarationList"] = 212] = "VariableDeclarationList"; - SyntaxKind[SyntaxKind["FunctionDeclaration"] = 213] = "FunctionDeclaration"; - SyntaxKind[SyntaxKind["ClassDeclaration"] = 214] = "ClassDeclaration"; - SyntaxKind[SyntaxKind["InterfaceDeclaration"] = 215] = "InterfaceDeclaration"; - SyntaxKind[SyntaxKind["TypeAliasDeclaration"] = 216] = "TypeAliasDeclaration"; - SyntaxKind[SyntaxKind["EnumDeclaration"] = 217] = "EnumDeclaration"; - SyntaxKind[SyntaxKind["ModuleDeclaration"] = 218] = "ModuleDeclaration"; - SyntaxKind[SyntaxKind["ModuleBlock"] = 219] = "ModuleBlock"; - SyntaxKind[SyntaxKind["CaseBlock"] = 220] = "CaseBlock"; - SyntaxKind[SyntaxKind["ImportEqualsDeclaration"] = 221] = "ImportEqualsDeclaration"; - SyntaxKind[SyntaxKind["ImportDeclaration"] = 222] = "ImportDeclaration"; - SyntaxKind[SyntaxKind["ImportClause"] = 223] = "ImportClause"; - SyntaxKind[SyntaxKind["NamespaceImport"] = 224] = "NamespaceImport"; - SyntaxKind[SyntaxKind["NamedImports"] = 225] = "NamedImports"; - SyntaxKind[SyntaxKind["ImportSpecifier"] = 226] = "ImportSpecifier"; - SyntaxKind[SyntaxKind["ExportAssignment"] = 227] = "ExportAssignment"; - SyntaxKind[SyntaxKind["ExportDeclaration"] = 228] = "ExportDeclaration"; - SyntaxKind[SyntaxKind["NamedExports"] = 229] = "NamedExports"; - SyntaxKind[SyntaxKind["ExportSpecifier"] = 230] = "ExportSpecifier"; - SyntaxKind[SyntaxKind["MissingDeclaration"] = 231] = "MissingDeclaration"; - // Module references - SyntaxKind[SyntaxKind["ExternalModuleReference"] = 232] = "ExternalModuleReference"; - // JSX - SyntaxKind[SyntaxKind["JsxElement"] = 233] = "JsxElement"; - SyntaxKind[SyntaxKind["JsxSelfClosingElement"] = 234] = "JsxSelfClosingElement"; - SyntaxKind[SyntaxKind["JsxOpeningElement"] = 235] = "JsxOpeningElement"; - SyntaxKind[SyntaxKind["JsxText"] = 236] = "JsxText"; - SyntaxKind[SyntaxKind["JsxClosingElement"] = 237] = "JsxClosingElement"; - SyntaxKind[SyntaxKind["JsxAttribute"] = 238] = "JsxAttribute"; - SyntaxKind[SyntaxKind["JsxSpreadAttribute"] = 239] = "JsxSpreadAttribute"; - SyntaxKind[SyntaxKind["JsxExpression"] = 240] = "JsxExpression"; - // Clauses - SyntaxKind[SyntaxKind["CaseClause"] = 241] = "CaseClause"; - SyntaxKind[SyntaxKind["DefaultClause"] = 242] = "DefaultClause"; - SyntaxKind[SyntaxKind["HeritageClause"] = 243] = "HeritageClause"; - SyntaxKind[SyntaxKind["CatchClause"] = 244] = "CatchClause"; - // Property assignments - SyntaxKind[SyntaxKind["PropertyAssignment"] = 245] = "PropertyAssignment"; - SyntaxKind[SyntaxKind["ShorthandPropertyAssignment"] = 246] = "ShorthandPropertyAssignment"; - // Enum - SyntaxKind[SyntaxKind["EnumMember"] = 247] = "EnumMember"; - // Top-level nodes - SyntaxKind[SyntaxKind["SourceFile"] = 248] = "SourceFile"; - // JSDoc nodes. - SyntaxKind[SyntaxKind["JSDocTypeExpression"] = 249] = "JSDocTypeExpression"; - // The * type. - SyntaxKind[SyntaxKind["JSDocAllType"] = 250] = "JSDocAllType"; - // The ? type. - SyntaxKind[SyntaxKind["JSDocUnknownType"] = 251] = "JSDocUnknownType"; - SyntaxKind[SyntaxKind["JSDocArrayType"] = 252] = "JSDocArrayType"; - SyntaxKind[SyntaxKind["JSDocUnionType"] = 253] = "JSDocUnionType"; - SyntaxKind[SyntaxKind["JSDocTupleType"] = 254] = "JSDocTupleType"; - SyntaxKind[SyntaxKind["JSDocNullableType"] = 255] = "JSDocNullableType"; - SyntaxKind[SyntaxKind["JSDocNonNullableType"] = 256] = "JSDocNonNullableType"; - SyntaxKind[SyntaxKind["JSDocRecordType"] = 257] = "JSDocRecordType"; - SyntaxKind[SyntaxKind["JSDocRecordMember"] = 258] = "JSDocRecordMember"; - SyntaxKind[SyntaxKind["JSDocTypeReference"] = 259] = "JSDocTypeReference"; - SyntaxKind[SyntaxKind["JSDocOptionalType"] = 260] = "JSDocOptionalType"; - SyntaxKind[SyntaxKind["JSDocFunctionType"] = 261] = "JSDocFunctionType"; - SyntaxKind[SyntaxKind["JSDocVariadicType"] = 262] = "JSDocVariadicType"; - SyntaxKind[SyntaxKind["JSDocConstructorType"] = 263] = "JSDocConstructorType"; - SyntaxKind[SyntaxKind["JSDocThisType"] = 264] = "JSDocThisType"; - SyntaxKind[SyntaxKind["JSDocComment"] = 265] = "JSDocComment"; - SyntaxKind[SyntaxKind["JSDocTag"] = 266] = "JSDocTag"; - SyntaxKind[SyntaxKind["JSDocParameterTag"] = 267] = "JSDocParameterTag"; - SyntaxKind[SyntaxKind["JSDocReturnTag"] = 268] = "JSDocReturnTag"; - SyntaxKind[SyntaxKind["JSDocTypeTag"] = 269] = "JSDocTypeTag"; - SyntaxKind[SyntaxKind["JSDocTemplateTag"] = 270] = "JSDocTemplateTag"; - // Synthesized list - SyntaxKind[SyntaxKind["SyntaxList"] = 271] = "SyntaxList"; - // Enum value count - SyntaxKind[SyntaxKind["Count"] = 272] = "Count"; - // Markers - SyntaxKind[SyntaxKind["FirstAssignment"] = 56] = "FirstAssignment"; - SyntaxKind[SyntaxKind["LastAssignment"] = 68] = "LastAssignment"; - SyntaxKind[SyntaxKind["FirstReservedWord"] = 70] = "FirstReservedWord"; - SyntaxKind[SyntaxKind["LastReservedWord"] = 105] = "LastReservedWord"; - SyntaxKind[SyntaxKind["FirstKeyword"] = 70] = "FirstKeyword"; - SyntaxKind[SyntaxKind["LastKeyword"] = 134] = "LastKeyword"; - SyntaxKind[SyntaxKind["FirstFutureReservedWord"] = 106] = "FirstFutureReservedWord"; - SyntaxKind[SyntaxKind["LastFutureReservedWord"] = 114] = "LastFutureReservedWord"; - SyntaxKind[SyntaxKind["FirstTypeNode"] = 151] = "FirstTypeNode"; - SyntaxKind[SyntaxKind["LastTypeNode"] = 160] = "LastTypeNode"; - SyntaxKind[SyntaxKind["FirstPunctuation"] = 15] = "FirstPunctuation"; - SyntaxKind[SyntaxKind["LastPunctuation"] = 68] = "LastPunctuation"; - SyntaxKind[SyntaxKind["FirstToken"] = 0] = "FirstToken"; - SyntaxKind[SyntaxKind["LastToken"] = 134] = "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"] = 135] = "FirstNode"; - })(ts.SyntaxKind || (ts.SyntaxKind = {})); - var SyntaxKind = ts.SyntaxKind; - (function (NodeFlags) { - NodeFlags[NodeFlags["None"] = 0] = "None"; - NodeFlags[NodeFlags["Export"] = 1] = "Export"; - NodeFlags[NodeFlags["Ambient"] = 2] = "Ambient"; - NodeFlags[NodeFlags["Public"] = 16] = "Public"; - NodeFlags[NodeFlags["Private"] = 32] = "Private"; - NodeFlags[NodeFlags["Protected"] = 64] = "Protected"; - NodeFlags[NodeFlags["Static"] = 128] = "Static"; - NodeFlags[NodeFlags["Abstract"] = 256] = "Abstract"; - NodeFlags[NodeFlags["Async"] = 512] = "Async"; - NodeFlags[NodeFlags["Default"] = 1024] = "Default"; - NodeFlags[NodeFlags["MultiLine"] = 2048] = "MultiLine"; - NodeFlags[NodeFlags["Synthetic"] = 4096] = "Synthetic"; - NodeFlags[NodeFlags["DeclarationFile"] = 8192] = "DeclarationFile"; - NodeFlags[NodeFlags["Let"] = 16384] = "Let"; - NodeFlags[NodeFlags["Const"] = 32768] = "Const"; - NodeFlags[NodeFlags["OctalLiteral"] = 65536] = "OctalLiteral"; - NodeFlags[NodeFlags["Namespace"] = 131072] = "Namespace"; - NodeFlags[NodeFlags["ExportContext"] = 262144] = "ExportContext"; - NodeFlags[NodeFlags["ContainsThis"] = 524288] = "ContainsThis"; - NodeFlags[NodeFlags["Modifier"] = 2035] = "Modifier"; - NodeFlags[NodeFlags["AccessibilityModifier"] = 112] = "AccessibilityModifier"; - NodeFlags[NodeFlags["BlockScoped"] = 49152] = "BlockScoped"; - })(ts.NodeFlags || (ts.NodeFlags = {})); - var NodeFlags = ts.NodeFlags; - /* @internal */ - (function (ParserContextFlags) { - ParserContextFlags[ParserContextFlags["None"] = 0] = "None"; - // If this node was parsed in a context where 'in-expressions' are not allowed. - ParserContextFlags[ParserContextFlags["DisallowIn"] = 1] = "DisallowIn"; - // If this node was parsed in the 'yield' context created when parsing a generator. - ParserContextFlags[ParserContextFlags["Yield"] = 2] = "Yield"; - // If this node was parsed as part of a decorator - ParserContextFlags[ParserContextFlags["Decorator"] = 4] = "Decorator"; - // If this node was parsed in the 'await' context created when parsing an async function. - ParserContextFlags[ParserContextFlags["Await"] = 8] = "Await"; - // If the parser encountered an error when parsing the code that created this node. Note - // the parser only sets this directly on the node it creates right after encountering the - // error. - ParserContextFlags[ParserContextFlags["ThisNodeHasError"] = 16] = "ThisNodeHasError"; - // This node was parsed in a JavaScript file and can be processed differently. For example - // its type can be specified usign a JSDoc comment. - ParserContextFlags[ParserContextFlags["JavaScriptFile"] = 32] = "JavaScriptFile"; - // Context flags set directly by the parser. - ParserContextFlags[ParserContextFlags["ParserGeneratedFlags"] = 31] = "ParserGeneratedFlags"; - // Exclude these flags when parsing a Type - ParserContextFlags[ParserContextFlags["TypeExcludesFlags"] = 10] = "TypeExcludesFlags"; - // Context flags computed by aggregating child flags upwards. - // Used during incremental parsing to determine if this node or any of its children had an - // error. Computed only once and then cached. - ParserContextFlags[ParserContextFlags["ThisNodeOrAnySubNodesHasError"] = 64] = "ThisNodeOrAnySubNodesHasError"; - // Used to know if we've computed data from children and cached it in this node. - ParserContextFlags[ParserContextFlags["HasAggregatedChildData"] = 128] = "HasAggregatedChildData"; - })(ts.ParserContextFlags || (ts.ParserContextFlags = {})); - var ParserContextFlags = ts.ParserContextFlags; - (function (JsxFlags) { - JsxFlags[JsxFlags["None"] = 0] = "None"; - JsxFlags[JsxFlags["IntrinsicNamedElement"] = 1] = "IntrinsicNamedElement"; - JsxFlags[JsxFlags["IntrinsicIndexedElement"] = 2] = "IntrinsicIndexedElement"; - JsxFlags[JsxFlags["ClassElement"] = 4] = "ClassElement"; - JsxFlags[JsxFlags["UnknownElement"] = 8] = "UnknownElement"; - JsxFlags[JsxFlags["IntrinsicElement"] = 3] = "IntrinsicElement"; - })(ts.JsxFlags || (ts.JsxFlags = {})); - var JsxFlags = ts.JsxFlags; - /* @internal */ - (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; - var OperationCanceledException = (function () { - function OperationCanceledException() { - } - return OperationCanceledException; - })(); - ts.OperationCanceledException = OperationCanceledException; - /** Return code used by getEmitOutput function to indicate status of the function */ - (function (ExitStatus) { - // Compiler ran successfully. Either this was a simple do-nothing compilation (for example, - // when -version or -help was provided, or this was a normal compilation, no diagnostics - // were produced, and all outputs were generated successfully. - ExitStatus[ExitStatus["Success"] = 0] = "Success"; - // Diagnostics were produced and because of them no code was generated. - ExitStatus[ExitStatus["DiagnosticsPresent_OutputsSkipped"] = 1] = "DiagnosticsPresent_OutputsSkipped"; - // Diagnostics were produced and outputs were generated in spite of them. - 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"; - })(ts.TypeFormatFlags || (ts.TypeFormatFlags = {})); - var TypeFormatFlags = ts.TypeFormatFlags; - (function (SymbolFormatFlags) { - SymbolFormatFlags[SymbolFormatFlags["None"] = 0] = "None"; - // Write symbols's type argument if it is instantiated symbol - // eg. class C { p: T } <-- Show p as C.p here - // var a: C; - // var p = a.p; <--- Here p is property of C so show it as C.p instead of just C.p - SymbolFormatFlags[SymbolFormatFlags["WriteTypeParametersOrArguments"] = 1] = "WriteTypeParametersOrArguments"; - // Use only external alias information to get the symbol name in the given context - // eg. module m { export class c { } } import x = m.c; - // When this flag is specified m.c will be used to refer to the class instead of alias symbol x - SymbolFormatFlags[SymbolFormatFlags["UseOnlyExternalAliasing"] = 2] = "UseOnlyExternalAliasing"; - })(ts.SymbolFormatFlags || (ts.SymbolFormatFlags = {})); - var SymbolFormatFlags = ts.SymbolFormatFlags; - /* @internal */ - (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; - /** Indicates how to serialize the name for a TypeReferenceNode when emitting decorator - * metadata */ - /* @internal */ - (function (TypeReferenceSerializationKind) { - TypeReferenceSerializationKind[TypeReferenceSerializationKind["Unknown"] = 0] = "Unknown"; - // should be emitted using a safe fallback. - TypeReferenceSerializationKind[TypeReferenceSerializationKind["TypeWithConstructSignatureAndValue"] = 1] = "TypeWithConstructSignatureAndValue"; - // function that can be reached at runtime (e.g. a `class` - // declaration or a `var` declaration for the static side - // of a type, such as the global `Promise` type in lib.d.ts). - TypeReferenceSerializationKind[TypeReferenceSerializationKind["VoidType"] = 2] = "VoidType"; - TypeReferenceSerializationKind[TypeReferenceSerializationKind["NumberLikeType"] = 3] = "NumberLikeType"; - TypeReferenceSerializationKind[TypeReferenceSerializationKind["StringLikeType"] = 4] = "StringLikeType"; - TypeReferenceSerializationKind[TypeReferenceSerializationKind["BooleanType"] = 5] = "BooleanType"; - TypeReferenceSerializationKind[TypeReferenceSerializationKind["ArrayLikeType"] = 6] = "ArrayLikeType"; - TypeReferenceSerializationKind[TypeReferenceSerializationKind["ESSymbolType"] = 7] = "ESSymbolType"; - TypeReferenceSerializationKind[TypeReferenceSerializationKind["TypeWithCallSignature"] = 8] = "TypeWithCallSignature"; - // with call signatures. - TypeReferenceSerializationKind[TypeReferenceSerializationKind["ObjectType"] = 9] = "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"] = 793056] = "Type"; - SymbolFlags[SymbolFlags["Namespace"] = 1536] = "Namespace"; - SymbolFlags[SymbolFlags["Module"] = 1536] = "Module"; - SymbolFlags[SymbolFlags["Accessor"] = 98304] = "Accessor"; - // Variables can be redeclared, but can not redeclare a block-scoped declaration with the - // same name, or any other value that is not a variable, e.g. ValueModule or Class - SymbolFlags[SymbolFlags["FunctionScopedVariableExcludes"] = 107454] = "FunctionScopedVariableExcludes"; - // Block-scoped declarations are not allowed to be re-declared - // they can not merge with anything in the value space - SymbolFlags[SymbolFlags["BlockScopedVariableExcludes"] = 107455] = "BlockScopedVariableExcludes"; - SymbolFlags[SymbolFlags["ParameterExcludes"] = 107455] = "ParameterExcludes"; - SymbolFlags[SymbolFlags["PropertyExcludes"] = 107455] = "PropertyExcludes"; - SymbolFlags[SymbolFlags["EnumMemberExcludes"] = 107455] = "EnumMemberExcludes"; - SymbolFlags[SymbolFlags["FunctionExcludes"] = 106927] = "FunctionExcludes"; - SymbolFlags[SymbolFlags["ClassExcludes"] = 899519] = "ClassExcludes"; - SymbolFlags[SymbolFlags["InterfaceExcludes"] = 792960] = "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"] = 530912] = "TypeParameterExcludes"; - SymbolFlags[SymbolFlags["TypeAliasExcludes"] = 793056] = "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"; - /* @internal */ - // The set of things we consider semantically classifiable. Used to speed up the LS during - // classification. - SymbolFlags[SymbolFlags["Classifiable"] = 788448] = "Classifiable"; - })(ts.SymbolFlags || (ts.SymbolFlags = {})); - var SymbolFlags = ts.SymbolFlags; - /* @internal */ - (function (NodeCheckFlags) { - NodeCheckFlags[NodeCheckFlags["TypeChecked"] = 1] = "TypeChecked"; - NodeCheckFlags[NodeCheckFlags["LexicalThis"] = 2] = "LexicalThis"; - NodeCheckFlags[NodeCheckFlags["CaptureThis"] = 4] = "CaptureThis"; - NodeCheckFlags[NodeCheckFlags["EmitExtends"] = 8] = "EmitExtends"; - NodeCheckFlags[NodeCheckFlags["EmitDecorate"] = 16] = "EmitDecorate"; - NodeCheckFlags[NodeCheckFlags["EmitParam"] = 32] = "EmitParam"; - NodeCheckFlags[NodeCheckFlags["EmitAwaiter"] = 64] = "EmitAwaiter"; - NodeCheckFlags[NodeCheckFlags["EmitGenerator"] = 128] = "EmitGenerator"; - NodeCheckFlags[NodeCheckFlags["SuperInstance"] = 256] = "SuperInstance"; - NodeCheckFlags[NodeCheckFlags["SuperStatic"] = 512] = "SuperStatic"; - NodeCheckFlags[NodeCheckFlags["ContextChecked"] = 1024] = "ContextChecked"; - NodeCheckFlags[NodeCheckFlags["LexicalArguments"] = 2048] = "LexicalArguments"; - NodeCheckFlags[NodeCheckFlags["CaptureArguments"] = 4096] = "CaptureArguments"; - // Values for enum members have been computed, and any errors have been reported for them. - NodeCheckFlags[NodeCheckFlags["EnumValuesComputed"] = 8192] = "EnumValuesComputed"; - NodeCheckFlags[NodeCheckFlags["BlockScopedBindingInLoop"] = 16384] = "BlockScopedBindingInLoop"; - NodeCheckFlags[NodeCheckFlags["LexicalModuleMergesWithClass"] = 32768] = "LexicalModuleMergesWithClass"; - })(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["Void"] = 16] = "Void"; - TypeFlags[TypeFlags["Undefined"] = 32] = "Undefined"; - TypeFlags[TypeFlags["Null"] = 64] = "Null"; - TypeFlags[TypeFlags["Enum"] = 128] = "Enum"; - TypeFlags[TypeFlags["StringLiteral"] = 256] = "StringLiteral"; - TypeFlags[TypeFlags["TypeParameter"] = 512] = "TypeParameter"; - TypeFlags[TypeFlags["Class"] = 1024] = "Class"; - TypeFlags[TypeFlags["Interface"] = 2048] = "Interface"; - TypeFlags[TypeFlags["Reference"] = 4096] = "Reference"; - TypeFlags[TypeFlags["Tuple"] = 8192] = "Tuple"; - TypeFlags[TypeFlags["Union"] = 16384] = "Union"; - TypeFlags[TypeFlags["Intersection"] = 32768] = "Intersection"; - TypeFlags[TypeFlags["Anonymous"] = 65536] = "Anonymous"; - TypeFlags[TypeFlags["Instantiated"] = 131072] = "Instantiated"; - /* @internal */ - TypeFlags[TypeFlags["FromSignature"] = 262144] = "FromSignature"; - TypeFlags[TypeFlags["ObjectLiteral"] = 524288] = "ObjectLiteral"; - /* @internal */ - TypeFlags[TypeFlags["FreshObjectLiteral"] = 1048576] = "FreshObjectLiteral"; - /* @internal */ - TypeFlags[TypeFlags["ContainsUndefinedOrNull"] = 2097152] = "ContainsUndefinedOrNull"; - /* @internal */ - TypeFlags[TypeFlags["ContainsObjectLiteral"] = 4194304] = "ContainsObjectLiteral"; - /* @internal */ - TypeFlags[TypeFlags["ContainsAnyFunctionType"] = 8388608] = "ContainsAnyFunctionType"; - TypeFlags[TypeFlags["ESSymbol"] = 16777216] = "ESSymbol"; - TypeFlags[TypeFlags["ThisType"] = 33554432] = "ThisType"; - /* @internal */ - TypeFlags[TypeFlags["Intrinsic"] = 16777343] = "Intrinsic"; - /* @internal */ - TypeFlags[TypeFlags["Primitive"] = 16777726] = "Primitive"; - TypeFlags[TypeFlags["StringLike"] = 258] = "StringLike"; - TypeFlags[TypeFlags["NumberLike"] = 132] = "NumberLike"; - TypeFlags[TypeFlags["ObjectType"] = 80896] = "ObjectType"; - TypeFlags[TypeFlags["UnionOrIntersection"] = 49152] = "UnionOrIntersection"; - TypeFlags[TypeFlags["StructuredType"] = 130048] = "StructuredType"; - /* @internal */ - TypeFlags[TypeFlags["RequiresWidening"] = 6291456] = "RequiresWidening"; - /* @internal */ - TypeFlags[TypeFlags["PropagatingFlags"] = 14680064] = "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 (DiagnosticCategory) { - DiagnosticCategory[DiagnosticCategory["Warning"] = 0] = "Warning"; - DiagnosticCategory[DiagnosticCategory["Error"] = 1] = "Error"; - DiagnosticCategory[DiagnosticCategory["Message"] = 2] = "Message"; - })(ts.DiagnosticCategory || (ts.DiagnosticCategory = {})); - var DiagnosticCategory = ts.DiagnosticCategory; - (function (ModuleResolutionKind) { - ModuleResolutionKind[ModuleResolutionKind["Classic"] = 1] = "Classic"; - ModuleResolutionKind[ModuleResolutionKind["NodeJs"] = 2] = "NodeJs"; - })(ts.ModuleResolutionKind || (ts.ModuleResolutionKind = {})); - var ModuleResolutionKind = ts.ModuleResolutionKind; - (function (ModuleKind) { - ModuleKind[ModuleKind["None"] = 0] = "None"; - ModuleKind[ModuleKind["CommonJS"] = 1] = "CommonJS"; - 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 (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"; - })(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; - /* @internal */ - (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"; - // Unicode 3.0 space characters - 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; -})(ts || (ts = {})); -/// -/* @internal */ -var ts; -(function (ts) { - /** - * Ternary values are defined such that - * x & y is False if either x or y is False. - * x & y is Maybe if either x or y is Maybe, but neither x or y is False. - * x & y is True if both x and y are True. - * x | y is False if both x and y are False. - * x | y is Maybe if either x or y is Maybe, but neither x or y is True. - * x | y is True if either x or y is True. - */ - (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; - function createFileMap(getCanonicalFileName) { - var files = {}; - return { - get: get, - set: set, - contains: contains, - remove: remove, - clear: clear, - forEachValue: forEachValueInMap - }; - function set(fileName, value) { - files[normalizeKey(fileName)] = value; - } - function get(fileName) { - return files[normalizeKey(fileName)]; - } - function contains(fileName) { - return hasProperty(files, normalizeKey(fileName)); - } - function remove(fileName) { - var key = normalizeKey(fileName); - delete files[key]; - } - function forEachValueInMap(f) { - forEachValue(files, f); - } - function normalizeKey(key) { - return getCanonicalFileName(normalizeSlashes(key)); - } - function clear() { - files = {}; - } - } - ts.createFileMap = createFileMap; - (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; - /** - * Iterates through 'array' by index and performs the callback on each element of array until the callback - * returns a truthy value, then returns that value. - * If no such value is found, the callback is applied to each element of array and undefined is returned. - */ - function forEach(array, callback) { - if (array) { - for (var i = 0, len = array.length; i < len; i++) { - var result = callback(array[i], i); - if (result) { - return result; - } - } - } - return undefined; - } - ts.forEach = forEach; - function contains(array, value) { - if (array) { - for (var _i = 0; _i < array.length; _i++) { - var v = array[_i]; - if (v === value) { - return true; - } - } - } - return false; - } - ts.contains = contains; - function indexOf(array, value) { - if (array) { - for (var i = 0, len = array.length; i < len; i++) { - if (array[i] === value) { - return i; - } - } - } - return -1; - } - ts.indexOf = indexOf; - function countWhere(array, predicate) { - var count = 0; - if (array) { - for (var _i = 0; _i < array.length; _i++) { - var v = array[_i]; - if (predicate(v)) { - count++; - } - } - } - return count; - } - ts.countWhere = countWhere; - function filter(array, f) { - var result; - if (array) { - result = []; - for (var _i = 0; _i < array.length; _i++) { - var item = array[_i]; - if (f(item)) { - result.push(item); - } - } - } - return result; - } - ts.filter = filter; - function map(array, f) { - var result; - if (array) { - result = []; - for (var _i = 0; _i < array.length; _i++) { - var v = array[_i]; - result.push(f(v)); - } - } - return result; - } - ts.map = map; - function concatenate(array1, array2) { - if (!array2 || !array2.length) - return array1; - if (!array1 || !array1.length) - return array2; - return array1.concat(array2); - } - ts.concatenate = concatenate; - function deduplicate(array) { - var result; - if (array) { - result = []; - for (var _i = 0; _i < array.length; _i++) { - var item = array[_i]; - if (!contains(result, item)) { - result.push(item); - } - } - } - return result; - } - ts.deduplicate = deduplicate; - function sum(array, prop) { - var result = 0; - for (var _i = 0; _i < array.length; _i++) { - var v = array[_i]; - result += v[prop]; - } - return result; - } - ts.sum = sum; - function addRange(to, from) { - if (to && from) { - for (var _i = 0; _i < from.length; _i++) { - var v = from[_i]; - to.push(v); - } - } - } - ts.addRange = addRange; - function rangeEquals(array1, array2, pos, end) { - while (pos < end) { - if (array1[pos] !== array2[pos]) { - return false; - } - pos++; - } - return true; - } - ts.rangeEquals = rangeEquals; - /** - * Returns the last element of an array if non-empty, undefined otherwise. - */ - function lastOrUndefined(array) { - if (array.length === 0) { - return undefined; - } - return array[array.length - 1]; - } - ts.lastOrUndefined = lastOrUndefined; - /** - * 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 - * number[index] exceeds number. - * @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) { - var low = 0; - var high = array.length - 1; - while (low <= high) { - var middle = low + ((high - low) >> 1); - var midValue = array[middle]; - if (midValue === value) { - return middle; - } - else if (midValue > value) { - high = middle - 1; - } - else { - low = middle + 1; - } - } - return ~low; - } - ts.binarySearch = binarySearch; - function reduceLeft(array, f, initial) { - if (array) { - var count = array.length; - if (count > 0) { - var pos = 0; - var result = arguments.length <= 2 ? array[pos++] : initial; - while (pos < count) { - result = f(result, array[pos++]); - } - return result; - } - } - return initial; - } - ts.reduceLeft = reduceLeft; - function reduceRight(array, f, initial) { - if (array) { - var pos = array.length - 1; - if (pos >= 0) { - var result = arguments.length <= 2 ? array[pos--] : initial; - while (pos >= 0) { - result = f(result, array[pos--]); - } - return result; - } - } - return initial; - } - ts.reduceRight = reduceRight; - var hasOwnProperty = Object.prototype.hasOwnProperty; - function hasProperty(map, key) { - return hasOwnProperty.call(map, key); - } - ts.hasProperty = hasProperty; - function getProperty(map, key) { - return hasOwnProperty.call(map, key) ? map[key] : undefined; - } - ts.getProperty = getProperty; - function isEmpty(map) { - for (var id in map) { - if (hasProperty(map, id)) { - return false; - } - } - return true; - } - ts.isEmpty = isEmpty; - function clone(object) { - var result = {}; - for (var id in object) { - result[id] = object[id]; - } - return result; - } - ts.clone = clone; - function extend(first, second) { - var result = {}; - for (var id in first) { - result[id] = first[id]; - } - for (var id in second) { - if (!hasProperty(result, id)) { - result[id] = second[id]; - } - } - return result; - } - ts.extend = extend; - function forEachValue(map, callback) { - var result; - for (var id in map) { - if (result = callback(map[id])) - break; - } - return result; - } - ts.forEachValue = forEachValue; - function forEachKey(map, callback) { - var result; - for (var id in map) { - if (result = callback(id)) - break; - } - return result; - } - ts.forEachKey = forEachKey; - function lookUp(map, key) { - return hasProperty(map, key) ? map[key] : undefined; - } - ts.lookUp = lookUp; - function copyMap(source, target) { - for (var p in source) { - target[p] = source[p]; - } - } - ts.copyMap = copyMap; - /** - * Creates a map from the elements of an array. - * - * @param array the array of input elements. - * @param makeKey a function that produces a key for a given element. - * - * This function makes no effort to avoid collisions; if any two elements produce - * the same key with the given 'makeKey' function, then the element with the higher - * index in the array will be the one associated with the produced key. - */ - function arrayToMap(array, makeKey) { - var result = {}; - forEach(array, function (value) { - result[makeKey(value)] = value; - }); - return result; - } - ts.arrayToMap = arrayToMap; - function memoize(callback) { - var value; - return function () { - if (callback) { - value = callback(); - callback = undefined; - } - return value; - }; - } - ts.memoize = memoize; - function formatStringFromArgs(text, args, baseIndex) { - baseIndex = baseIndex || 0; - return text.replace(/{(\d+)}/g, function (match, index) { return args[+index + baseIndex]; }); - } - ts.localizedDiagnosticMessages = undefined; - function getLocaleSpecificMessage(message) { - return ts.localizedDiagnosticMessages && ts.localizedDiagnosticMessages[message] - ? ts.localizedDiagnosticMessages[message] - : message; - } - ts.getLocaleSpecificMessage = getLocaleSpecificMessage; - function createFileDiagnostic(file, start, length, message) { - var end = start + length; - Debug.assert(start >= 0, "start must be non-negative, is " + start); - Debug.assert(length >= 0, "length must be non-negative, is " + length); - if (file) { - Debug.assert(start <= file.text.length, "start must be within the bounds of the file. " + start + " > " + file.text.length); - Debug.assert(end <= file.text.length, "end must be the bounds of the file. " + end + " > " + file.text.length); - } - var text = getLocaleSpecificMessage(message.key); - if (arguments.length > 4) { - text = formatStringFromArgs(text, arguments, 4); - } - return { - file: file, - start: start, - length: length, - messageText: text, - category: message.category, - code: message.code - }; - } - ts.createFileDiagnostic = createFileDiagnostic; - function createCompilerDiagnostic(message) { - var text = getLocaleSpecificMessage(message.key); - if (arguments.length > 1) { - text = formatStringFromArgs(text, arguments, 1); - } - return { - file: undefined, - start: undefined, - length: undefined, - messageText: text, - category: message.category, - code: message.code - }; - } - ts.createCompilerDiagnostic = createCompilerDiagnostic; - function chainDiagnosticMessages(details, message) { - var text = getLocaleSpecificMessage(message.key); - if (arguments.length > 2) { - text = formatStringFromArgs(text, arguments, 2); - } - return { - messageText: text, - category: message.category, - code: message.code, - next: details - }; - } - ts.chainDiagnosticMessages = chainDiagnosticMessages; - function concatenateDiagnosticMessageChains(headChain, tailChain) { - var lastChain = headChain; - while (lastChain.next) { - lastChain = lastChain.next; - } - lastChain.next = tailChain; - return headChain; - } - ts.concatenateDiagnosticMessageChains = concatenateDiagnosticMessageChains; - function compareValues(a, b) { - if (a === b) - return 0 /* EqualTo */; - if (a === undefined) - return -1 /* LessThan */; - if (b === undefined) - return 1 /* GreaterThan */; - return a < b ? -1 /* LessThan */ : 1 /* GreaterThan */; - } - ts.compareValues = compareValues; - function getDiagnosticFileName(diagnostic) { - return diagnostic.file ? diagnostic.file.fileName : undefined; - } - function compareDiagnostics(d1, d2) { - return compareValues(getDiagnosticFileName(d1), getDiagnosticFileName(d2)) || - compareValues(d1.start, d2.start) || - compareValues(d1.length, d2.length) || - compareValues(d1.code, d2.code) || - compareMessageText(d1.messageText, d2.messageText) || - 0 /* EqualTo */; - } - ts.compareDiagnostics = compareDiagnostics; - function compareMessageText(text1, text2) { - while (text1 && text2) { - // We still have both chains. - var string1 = typeof text1 === "string" ? text1 : text1.messageText; - var string2 = typeof text2 === "string" ? text2 : text2.messageText; - var res = compareValues(string1, string2); - if (res) { - return res; - } - text1 = typeof text1 === "string" ? undefined : text1.next; - text2 = typeof text2 === "string" ? undefined : text2.next; - } - if (!text1 && !text2) { - // if the chains are done, then these messages are the same. - return 0 /* EqualTo */; - } - // We still have one chain remaining. The shorter chain should come first. - return text1 ? 1 /* GreaterThan */ : -1 /* LessThan */; - } - function sortAndDeduplicateDiagnostics(diagnostics) { - return deduplicateSortedDiagnostics(diagnostics.sort(compareDiagnostics)); - } - ts.sortAndDeduplicateDiagnostics = sortAndDeduplicateDiagnostics; - function deduplicateSortedDiagnostics(diagnostics) { - if (diagnostics.length < 2) { - return diagnostics; - } - var newDiagnostics = [diagnostics[0]]; - var previousDiagnostic = diagnostics[0]; - for (var i = 1; i < diagnostics.length; i++) { - var currentDiagnostic = diagnostics[i]; - var isDupe = compareDiagnostics(currentDiagnostic, previousDiagnostic) === 0 /* EqualTo */; - if (!isDupe) { - newDiagnostics.push(currentDiagnostic); - previousDiagnostic = currentDiagnostic; - } - } - return newDiagnostics; - } - ts.deduplicateSortedDiagnostics = deduplicateSortedDiagnostics; - function normalizeSlashes(path) { - return path.replace(/\\/g, "/"); - } - ts.normalizeSlashes = normalizeSlashes; - // 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 */) - return 1; - var p1 = path.indexOf("/", 2); - if (p1 < 0) - return 2; - var p2 = path.indexOf("/", p1 + 1); - if (p2 < 0) - return p1 + 1; - return p2 + 1; - } - if (path.charCodeAt(1) === 58 /* colon */) { - if (path.charCodeAt(2) === 47 /* slash */) - return 3; - return 2; - } - // Per RFC 1738 'file' URI schema has the shape file:/// - // if is omitted then it is assumed that host value is 'localhost', - // however slash after the omitted is not removed. - // file:///folder1/file1 - this is a correct URI - // file://folder2/file2 - this is an incorrect URI - if (path.lastIndexOf("file:///", 0) === 0) { - return "file:///".length; - } - var idx = path.indexOf("://"); - if (idx !== -1) { - return idx + "://".length; - } - return 0; - } - ts.getRootLength = getRootLength; - ts.directorySeparator = "/"; - function getNormalizedParts(normalizedSlashedPath, rootLength) { - var parts = normalizedSlashedPath.substr(rootLength).split(ts.directorySeparator); - var normalized = []; - for (var _i = 0; _i < parts.length; _i++) { - var part = parts[_i]; - if (part !== ".") { - if (part === ".." && normalized.length > 0 && lastOrUndefined(normalized) !== "..") { - normalized.pop(); - } - else { - // A part may be an empty string (which is 'falsy') if the path had consecutive slashes, - // e.g. "path//file.ts". Drop these before re-joining the parts. - if (part) { - normalized.push(part); - } - } - } - } - return normalized; - } - function normalizePath(path) { - path = normalizeSlashes(path); - var rootLength = getRootLength(path); - var normalized = getNormalizedParts(path, rootLength); - return path.substr(0, rootLength) + normalized.join(ts.directorySeparator); - } - ts.normalizePath = normalizePath; - function getDirectoryPath(path) { - return path.substr(0, Math.max(getRootLength(path), path.lastIndexOf(ts.directorySeparator))); - } - ts.getDirectoryPath = getDirectoryPath; - function isUrl(path) { - return path && !isRootedDiskPath(path) && path.indexOf("://") !== -1; - } - ts.isUrl = isUrl; - function isRootedDiskPath(path) { - return getRootLength(path) !== 0; - } - ts.isRootedDiskPath = isRootedDiskPath; - function normalizedPathComponents(path, rootLength) { - var normalizedParts = getNormalizedParts(path, rootLength); - return [path.substr(0, rootLength)].concat(normalizedParts); - } - function getNormalizedPathComponents(path, currentDirectory) { - path = normalizeSlashes(path); - var rootLength = getRootLength(path); - if (rootLength === 0) { - // If the path is not rooted it is relative to current directory - path = combinePaths(normalizeSlashes(currentDirectory), path); - rootLength = getRootLength(path); - } - return normalizedPathComponents(path, rootLength); - } - ts.getNormalizedPathComponents = getNormalizedPathComponents; - function getNormalizedAbsolutePath(fileName, currentDirectory) { - return getNormalizedPathFromPathComponents(getNormalizedPathComponents(fileName, currentDirectory)); - } - ts.getNormalizedAbsolutePath = getNormalizedAbsolutePath; - function getNormalizedPathFromPathComponents(pathComponents) { - if (pathComponents && pathComponents.length) { - return pathComponents[0] + pathComponents.slice(1).join(ts.directorySeparator); - } - } - ts.getNormalizedPathFromPathComponents = getNormalizedPathFromPathComponents; - function getNormalizedPathComponentsOfUrl(url) { - // Get root length of http://www.website.com/folder1/foler2/ - // In this example the root is: http://www.website.com/ - // normalized path components should be ["http://www.website.com/", "folder1", "folder2"] - var urlLength = url.length; - // Initial root length is http:// part - var rootLength = url.indexOf("://") + "://".length; - while (rootLength < urlLength) { - // Consume all immediate slashes in the protocol - // eg.initial rootlength is just file:// but it needs to consume another "/" in file:/// - if (url.charCodeAt(rootLength) === 47 /* slash */) { - rootLength++; - } - else { - // non slash character means we continue proceeding to next component of root search - break; - } - } - // there are no parts after http:// just return current string as the pathComponent - if (rootLength === urlLength) { - return [url]; - } - // Find the index of "/" after website.com so the root can be http://www.website.com/ (from existing http://) - var indexOfNextSlash = url.indexOf(ts.directorySeparator, rootLength); - if (indexOfNextSlash !== -1) { - // Found the "/" after the website.com so the root is length of http://www.website.com/ - // and get components afetr the root normally like any other folder components - rootLength = indexOfNextSlash + 1; - return normalizedPathComponents(url, rootLength); - } - else { - // Can't find the host assume the rest of the string as component - // but make sure we append "/" to it as root is not joined using "/" - // eg. if url passed in was http://website.com we want to use root as [http://website.com/] - // so that other path manipulations will be correct and it can be merged with relative paths correctly - return [url + ts.directorySeparator]; - } - } - function getNormalizedPathOrUrlComponents(pathOrUrl, currentDirectory) { - if (isUrl(pathOrUrl)) { - return getNormalizedPathComponentsOfUrl(pathOrUrl); - } - else { - return getNormalizedPathComponents(pathOrUrl, currentDirectory); - } - } - function getRelativePathToDirectoryOrUrl(directoryPathOrUrl, relativeOrAbsolutePath, currentDirectory, getCanonicalFileName, isAbsolutePathAnUrl) { - var pathComponents = getNormalizedPathOrUrlComponents(relativeOrAbsolutePath, currentDirectory); - var directoryComponents = getNormalizedPathOrUrlComponents(directoryPathOrUrl, currentDirectory); - if (directoryComponents.length > 1 && lastOrUndefined(directoryComponents) === "") { - // If the directory path given was of type test/cases/ then we really need components of directory to be only till its name - // that is ["test", "cases", ""] needs to be actually ["test", "cases"] - directoryComponents.length--; - } - // Find the component that differs - for (var joinStartIndex = 0; joinStartIndex < pathComponents.length && joinStartIndex < directoryComponents.length; joinStartIndex++) { - if (getCanonicalFileName(directoryComponents[joinStartIndex]) !== getCanonicalFileName(pathComponents[joinStartIndex])) { - break; - } - } - // Get the relative path - if (joinStartIndex) { - var relativePath = ""; - var relativePathComponents = pathComponents.slice(joinStartIndex, pathComponents.length); - for (; joinStartIndex < directoryComponents.length; joinStartIndex++) { - if (directoryComponents[joinStartIndex] !== "") { - relativePath = relativePath + ".." + ts.directorySeparator; - } - } - return relativePath + relativePathComponents.join(ts.directorySeparator); - } - // Cant find the relative path, get the absolute path - var absolutePath = getNormalizedPathFromPathComponents(pathComponents); - if (isAbsolutePathAnUrl && isRootedDiskPath(absolutePath)) { - absolutePath = "file:///" + absolutePath; - } - return absolutePath; - } - ts.getRelativePathToDirectoryOrUrl = getRelativePathToDirectoryOrUrl; - function getBaseFileName(path) { - if (!path) { - return undefined; - } - var i = path.lastIndexOf(ts.directorySeparator); - return i < 0 ? path : path.substring(i + 1); - } - ts.getBaseFileName = getBaseFileName; - function combinePaths(path1, path2) { - if (!(path1 && path1.length)) - return path2; - if (!(path2 && path2.length)) - return path1; - if (getRootLength(path2) !== 0) - return path2; - if (path1.charAt(path1.length - 1) === ts.directorySeparator) - return path1 + path2; - return path1 + ts.directorySeparator + path2; - } - ts.combinePaths = combinePaths; - function fileExtensionIs(path, extension) { - var pathLen = path.length; - var extLen = extension.length; - return pathLen > extLen && path.substr(pathLen - extLen, extLen) === extension; - } - ts.fileExtensionIs = fileExtensionIs; - /** - * List of supported extensions in order of file resolution precedence. - */ - ts.supportedExtensions = [".ts", ".tsx", ".d.ts"]; - /** - * List of extensions that will be used to look for external modules. - * This list is kept separate from supportedExtensions to for cases when we'll allow to include .js files in compilation, - * but still would like to load only TypeScript files as modules - */ - ts.moduleFileExtensions = ts.supportedExtensions; - function isSupportedSourceFileName(fileName) { - if (!fileName) { - return false; - } - for (var _i = 0; _i < ts.supportedExtensions.length; _i++) { - var extension = ts.supportedExtensions[_i]; - if (fileExtensionIs(fileName, extension)) { - return true; - } - } - return false; - } - ts.isSupportedSourceFileName = isSupportedSourceFileName; - var extensionsToRemove = [".d.ts", ".ts", ".js", ".tsx", ".jsx"]; - function removeFileExtension(path) { - for (var _i = 0; _i < extensionsToRemove.length; _i++) { - var ext = extensionsToRemove[_i]; - if (fileExtensionIs(path, ext)) { - return path.substr(0, path.length - ext.length); - } - } - return path; - } - ts.removeFileExtension = removeFileExtension; - var backslashOrDoubleQuote = /[\"\\]/g; - var escapedCharsRegExp = /[\u0000-\u001f\t\v\f\b\r\n\u2028\u2029\u0085]/g; - var escapedCharsMap = { - "\0": "\\0", - "\t": "\\t", - "\v": "\\v", - "\f": "\\f", - "\b": "\\b", - "\r": "\\r", - "\n": "\\n", - "\\": "\\\\", - "\"": "\\\"", - "\u2028": "\\u2028", - "\u2029": "\\u2029", - "\u0085": "\\u0085" // nextLine - }; - function Symbol(flags, name) { - this.flags = flags; - this.name = name; - this.declarations = undefined; - } - function Type(checker, flags) { - this.flags = flags; - } - function Signature(checker) { - } - ts.objectAllocator = { - getNodeConstructor: function (kind) { - function Node(pos, end) { - this.pos = pos; - this.end = end; - this.flags = 0 /* None */; - this.parent = undefined; - } - Node.prototype = { kind: kind }; - return Node; - }, - getSymbolConstructor: function () { return Symbol; }, - 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) { - var currentAssertionLevel = 0 /* None */; - function shouldAssert(level) { - return currentAssertionLevel >= level; - } - Debug.shouldAssert = shouldAssert; - function assert(expression, message, verboseDebugInfo) { - if (!expression) { - var verboseDebugString = ""; - if (verboseDebugInfo) { - verboseDebugString = "\r\nVerbose Debug Information: " + verboseDebugInfo(); - } - throw new Error("Debug Failure. False expression: " + (message || "") + verboseDebugString); - } - } - Debug.assert = assert; - function fail(message) { - Debug.assert(false, message); - } - Debug.fail = fail; - })(Debug = ts.Debug || (ts.Debug = {})); - function copyListRemovingItem(item, list) { - var copiedList = []; - for (var _i = 0; _i < list.length; _i++) { - var e = list[_i]; - if (e !== item) { - copiedList.push(e); - } - } - return copiedList; - } - ts.copyListRemovingItem = copyListRemovingItem; -})(ts || (ts = {})); -/// -var ts; -(function (ts) { - ts.sys = (function () { - function getWScriptSystem() { - var fso = new ActiveXObject("Scripting.FileSystemObject"); - var fileStream = new ActiveXObject("ADODB.Stream"); - fileStream.Type = 2 /*text*/; - var binaryStream = new ActiveXObject("ADODB.Stream"); - binaryStream.Type = 1 /*binary*/; - var args = []; - for (var i = 0; i < WScript.Arguments.length; i++) { - args[i] = WScript.Arguments.Item(i); - } - function readFile(fileName, encoding) { - if (!fso.FileExists(fileName)) { - return undefined; - } - fileStream.Open(); - try { - if (encoding) { - fileStream.Charset = encoding; - fileStream.LoadFromFile(fileName); - } - else { - // Load file and read the first two bytes into a string with no interpretation - fileStream.Charset = "x-ansi"; - fileStream.LoadFromFile(fileName); - var bom = fileStream.ReadText(2) || ""; - // Position must be at 0 before encoding can be changed - fileStream.Position = 0; - // [0xFF,0xFE] and [0xFE,0xFF] mean utf-16 (little or big endian), otherwise default to utf-8 - fileStream.Charset = bom.length >= 2 && (bom.charCodeAt(0) === 0xFF && bom.charCodeAt(1) === 0xFE || bom.charCodeAt(0) === 0xFE && bom.charCodeAt(1) === 0xFF) ? "unicode" : "utf-8"; - } - // ReadText method always strips byte order mark from resulting string - return fileStream.ReadText(); - } - catch (e) { - throw e; - } - finally { - fileStream.Close(); - } - } - function writeFile(fileName, data, writeByteOrderMark) { - fileStream.Open(); - binaryStream.Open(); - try { - // Write characters in UTF-8 encoding - fileStream.Charset = "utf-8"; - fileStream.WriteText(data); - // If we don't want the BOM, then skip it by setting the starting location to 3 (size of BOM). - // If not, start from position 0, as the BOM will be added automatically when charset==utf8. - if (writeByteOrderMark) { - fileStream.Position = 0; - } - else { - fileStream.Position = 3; - } - fileStream.CopyTo(binaryStream); - binaryStream.SaveToFile(fileName, 2 /*overwrite*/); - } - finally { - binaryStream.Close(); - fileStream.Close(); - } - } - function getCanonicalPath(path) { - return path.toLowerCase(); - } - function getNames(collection) { - var result = []; - for (var e = new Enumerator(collection); !e.atEnd(); e.moveNext()) { - result.push(e.item().Name); - } - return result.sort(); - } - function readDirectory(path, extension, exclude) { - var result = []; - exclude = ts.map(exclude, function (s) { return getCanonicalPath(ts.combinePaths(path, s)); }); - visitDirectory(path); - return result; - function visitDirectory(path) { - var folder = fso.GetFolder(path || "."); - var files = getNames(folder.files); - for (var _i = 0; _i < files.length; _i++) { - var current = files[_i]; - var name_1 = ts.combinePaths(path, current); - if ((!extension || ts.fileExtensionIs(name_1, extension)) && !ts.contains(exclude, getCanonicalPath(name_1))) { - result.push(name_1); - } - } - var subfolders = getNames(folder.subfolders); - for (var _a = 0; _a < subfolders.length; _a++) { - var current = subfolders[_a]; - var name_2 = ts.combinePaths(path, current); - if (!ts.contains(exclude, getCanonicalPath(name_2))) { - visitDirectory(name_2); - } - } - } - } - return { - args: args, - newLine: "\r\n", - useCaseSensitiveFileNames: false, - write: function (s) { - WScript.StdOut.Write(s); - }, - readFile: readFile, - writeFile: writeFile, - resolvePath: function (path) { - return fso.GetAbsolutePathName(path); - }, - fileExists: function (path) { - return fso.FileExists(path); - }, - directoryExists: function (path) { - return fso.FolderExists(path); - }, - createDirectory: function (directoryName) { - if (!this.directoryExists(directoryName)) { - fso.CreateFolder(directoryName); - } - }, - getExecutingFilePath: function () { - return WScript.ScriptFullName; - }, - getCurrentDirectory: function () { - return new ActiveXObject("WScript.Shell").CurrentDirectory; - }, - readDirectory: readDirectory, - exit: function (exitCode) { - try { - WScript.Quit(exitCode); - } - catch (e) { - } - } - }; - } - function getNodeSystem() { - var _fs = require("fs"); - var _path = require("path"); - var _os = require("os"); - // average async stat takes about 30 microseconds - // set chunk size to do 30 files in < 1 millisecond - function createWatchedFileSet(interval, chunkSize) { - if (interval === void 0) { interval = 2500; } - if (chunkSize === void 0) { chunkSize = 30; } - var watchedFiles = []; - var nextFileToCheck = 0; - var watchTimer; - function getModifiedTime(fileName) { - return _fs.statSync(fileName).mtime; - } - function poll(checkedIndex) { - var watchedFile = watchedFiles[checkedIndex]; - if (!watchedFile) { - return; - } - _fs.stat(watchedFile.fileName, function (err, stats) { - if (err) { - watchedFile.callback(watchedFile.fileName); - } - else if (watchedFile.mtime.getTime() !== stats.mtime.getTime()) { - watchedFile.mtime = getModifiedTime(watchedFile.fileName); - watchedFile.callback(watchedFile.fileName, watchedFile.mtime.getTime() === 0); - } - }); - } - // this implementation uses polling and - // stat due to inconsistencies of fs.watch - // and efficiency of stat on modern filesystems - function startWatchTimer() { - watchTimer = setInterval(function () { - var count = 0; - var nextToCheck = nextFileToCheck; - var firstCheck = -1; - while ((count < chunkSize) && (nextToCheck !== firstCheck)) { - poll(nextToCheck); - if (firstCheck < 0) { - firstCheck = nextToCheck; - } - nextToCheck++; - if (nextToCheck === watchedFiles.length) { - nextToCheck = 0; - } - count++; - } - nextFileToCheck = nextToCheck; - }, interval); - } - function addFile(fileName, callback) { - var file = { - fileName: fileName, - callback: callback, - mtime: getModifiedTime(fileName) - }; - watchedFiles.push(file); - if (watchedFiles.length === 1) { - startWatchTimer(); - } - return file; - } - function removeFile(file) { - watchedFiles = ts.copyListRemovingItem(file, watchedFiles); - } - return { - getModifiedTime: getModifiedTime, - poll: poll, - startWatchTimer: startWatchTimer, - addFile: addFile, - removeFile: removeFile - }; - } - // REVIEW: for now this implementation uses polling. - // The advantage of polling is that it works reliably - // on all os and with network mounted files. - // For 90 referenced files, the average time to detect - // changes is 2*msInterval (by default 5 seconds). - // The overhead of this is .04 percent (1/2500) with - // average pause of < 1 millisecond (and max - // pause less than 1.5 milliseconds); question is - // do we anticipate reference sets in the 100s and - // do we care about waiting 10-20 seconds to detect - // changes for large reference sets? If so, do we want - // to increase the chunk size or decrease the interval - // time dynamically to match the large reference set? - var watchedFileSet = createWatchedFileSet(); - function isNode4OrLater() { - return parseInt(process.version.charAt(1)) >= 4; - } - 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"; - function readFile(fileName, encoding) { - if (!_fs.existsSync(fileName)) { - return undefined; - } - var buffer = _fs.readFileSync(fileName); - var len = buffer.length; - if (len >= 2 && buffer[0] === 0xFE && buffer[1] === 0xFF) { - // Big endian UTF-16 byte order mark detected. Since big endian is not supported by node.js, - // flip all byte pairs and treat as little endian. - len &= ~1; - for (var i = 0; i < len; i += 2) { - var temp = buffer[i]; - buffer[i] = buffer[i + 1]; - buffer[i + 1] = temp; - } - return buffer.toString("utf16le", 2); - } - if (len >= 2 && buffer[0] === 0xFF && buffer[1] === 0xFE) { - // Little endian UTF-16 byte order mark detected - return buffer.toString("utf16le", 2); - } - if (len >= 3 && buffer[0] === 0xEF && buffer[1] === 0xBB && buffer[2] === 0xBF) { - // UTF-8 byte order mark detected - return buffer.toString("utf8", 3); - } - // Default is UTF-8 with no byte order mark - return buffer.toString("utf8"); - } - function writeFile(fileName, data, writeByteOrderMark) { - // If a BOM is required, emit one - if (writeByteOrderMark) { - data = "\uFEFF" + data; - } - _fs.writeFileSync(fileName, data, "utf8"); - } - function getCanonicalPath(path) { - return useCaseSensitiveFileNames ? path.toLowerCase() : path; - } - function readDirectory(path, extension, exclude) { - var result = []; - exclude = ts.map(exclude, function (s) { return getCanonicalPath(ts.combinePaths(path, s)); }); - visitDirectory(path); - return result; - function visitDirectory(path) { - var files = _fs.readdirSync(path || ".").sort(); - var directories = []; - for (var _i = 0; _i < files.length; _i++) { - var current = files[_i]; - var name_3 = ts.combinePaths(path, current); - if (!ts.contains(exclude, getCanonicalPath(name_3))) { - var stat = _fs.statSync(name_3); - if (stat.isFile()) { - if (!extension || ts.fileExtensionIs(name_3, extension)) { - result.push(name_3); - } - } - else if (stat.isDirectory()) { - directories.push(name_3); - } - } - } - for (var _a = 0; _a < directories.length; _a++) { - var current = directories[_a]; - visitDirectory(current); - } - } - } - return { - args: process.argv.slice(2), - newLine: _os.EOL, - useCaseSensitiveFileNames: useCaseSensitiveFileNames, - write: function (s) { - var buffer = new Buffer(s, "utf8"); - var offset = 0; - var toWrite = buffer.length; - var written = 0; - // 1 is a standard descriptor for stdout - while ((written = _fs.writeSync(1, buffer, offset, toWrite)) < toWrite) { - offset += written; - toWrite -= written; - } - }, - readFile: readFile, - writeFile: writeFile, - watchFile: function (fileName, callback) { - // Node 4.0 stablized the `fs.watch` function on Windows which avoids polling - // and is more efficient than `fs.watchFile` (ref: https://github.com/nodejs/node/pull/2649 - // and https://github.com/Microsoft/TypeScript/issues/4643), therefore - // if the current node.js version is newer than 4, use `fs.watch` instead. - if (isNode4OrLater()) { - // Note: in node the callback of fs.watch is given only the relative file name as a parameter - return _fs.watch(fileName, function (eventName, relativeFileName) { return callback(fileName); }); - } - var watchedFile = watchedFileSet.addFile(fileName, callback); - return { - close: function () { return watchedFileSet.removeFile(watchedFile); } - }; - }, - watchDirectory: function (path, callback, recursive) { - // 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) - return _fs.watch(path, { persistent: true, recursive: !!recursive }, function (eventName, relativeFileName) { - // In watchDirectory we only care about adding and removing files (when event name is - // "rename"); changes made within files are handled by corresponding fileWatchers (when - // event name is "change") - if (eventName === "rename") { - // When deleting a file, the passed baseFileName is null - callback(!relativeFileName ? relativeFileName : ts.normalizePath(ts.combinePaths(path, relativeFileName))); - } - ; - }); - }, - resolvePath: function (path) { - return _path.resolve(path); - }, - fileExists: function (path) { - return _fs.existsSync(path); - }, - directoryExists: function (path) { - return _fs.existsSync(path) && _fs.statSync(path).isDirectory(); - }, - createDirectory: function (directoryName) { - if (!this.directoryExists(directoryName)) { - _fs.mkdirSync(directoryName); - } - }, - getExecutingFilePath: function () { - return __filename; - }, - getCurrentDirectory: function () { - return process.cwd(); - }, - readDirectory: readDirectory, - getMemoryUsage: function () { - if (global.gc) { - global.gc(); - } - return process.memoryUsage().heapUsed; - }, - exit: function (exitCode) { - process.exit(exitCode); - } - }; - } - if (typeof WScript !== "undefined" && typeof ActiveXObject === "function") { - return 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(); - } - else { - return undefined; // Unsupported host - } - })(); -})(ts || (ts = {})); -// -/// -/* @internal */ -var ts; -(function (ts) { - ts.Diagnostics = { - Unterminated_string_literal: { code: 1002, category: ts.DiagnosticCategory.Error, key: "Unterminated string literal." }, - Identifier_expected: { code: 1003, category: ts.DiagnosticCategory.Error, key: "Identifier expected." }, - _0_expected: { code: 1005, category: ts.DiagnosticCategory.Error, key: "'{0}' expected." }, - A_file_cannot_have_a_reference_to_itself: { code: 1006, category: ts.DiagnosticCategory.Error, key: "A file cannot have a reference to itself." }, - Trailing_comma_not_allowed: { code: 1009, category: ts.DiagnosticCategory.Error, key: "Trailing comma not allowed." }, - Asterisk_Slash_expected: { code: 1010, category: ts.DiagnosticCategory.Error, key: "'*/' expected." }, - Unexpected_token: { code: 1012, category: ts.DiagnosticCategory.Error, key: "Unexpected token." }, - A_rest_parameter_must_be_last_in_a_parameter_list: { code: 1014, category: ts.DiagnosticCategory.Error, key: "A rest parameter must be last in a parameter list." }, - Parameter_cannot_have_question_mark_and_initializer: { code: 1015, category: ts.DiagnosticCategory.Error, key: "Parameter cannot have question mark and initializer." }, - A_required_parameter_cannot_follow_an_optional_parameter: { code: 1016, category: ts.DiagnosticCategory.Error, key: "A required parameter cannot follow an optional parameter." }, - An_index_signature_cannot_have_a_rest_parameter: { code: 1017, category: ts.DiagnosticCategory.Error, key: "An index signature cannot have a rest parameter." }, - An_index_signature_parameter_cannot_have_an_accessibility_modifier: { code: 1018, category: ts.DiagnosticCategory.Error, key: "An index signature parameter cannot have an accessibility modifier." }, - An_index_signature_parameter_cannot_have_a_question_mark: { code: 1019, category: ts.DiagnosticCategory.Error, key: "An index signature parameter cannot have a question mark." }, - An_index_signature_parameter_cannot_have_an_initializer: { code: 1020, category: ts.DiagnosticCategory.Error, key: "An index signature parameter cannot have an initializer." }, - An_index_signature_must_have_a_type_annotation: { code: 1021, category: ts.DiagnosticCategory.Error, key: "An index signature must have a type annotation." }, - An_index_signature_parameter_must_have_a_type_annotation: { code: 1022, category: ts.DiagnosticCategory.Error, key: "An index signature parameter must have a type annotation." }, - An_index_signature_parameter_type_must_be_string_or_number: { code: 1023, category: ts.DiagnosticCategory.Error, key: "An index signature parameter type must be 'string' or 'number'." }, - Accessibility_modifier_already_seen: { code: 1028, category: ts.DiagnosticCategory.Error, key: "Accessibility modifier already seen." }, - _0_modifier_must_precede_1_modifier: { code: 1029, category: ts.DiagnosticCategory.Error, key: "'{0}' modifier must precede '{1}' modifier." }, - _0_modifier_already_seen: { code: 1030, category: ts.DiagnosticCategory.Error, key: "'{0}' modifier already seen." }, - _0_modifier_cannot_appear_on_a_class_element: { code: 1031, category: ts.DiagnosticCategory.Error, key: "'{0}' modifier cannot appear on a class element." }, - super_must_be_followed_by_an_argument_list_or_member_access: { code: 1034, category: ts.DiagnosticCategory.Error, key: "'super' must be followed by an argument list or member access." }, - Only_ambient_modules_can_use_quoted_names: { code: 1035, category: ts.DiagnosticCategory.Error, key: "Only ambient modules can use quoted names." }, - Statements_are_not_allowed_in_ambient_contexts: { code: 1036, category: ts.DiagnosticCategory.Error, key: "Statements are not allowed in ambient contexts." }, - A_declare_modifier_cannot_be_used_in_an_already_ambient_context: { code: 1038, category: ts.DiagnosticCategory.Error, key: "A 'declare' modifier cannot be used in an already ambient context." }, - Initializers_are_not_allowed_in_ambient_contexts: { code: 1039, category: ts.DiagnosticCategory.Error, key: "Initializers are not allowed in ambient contexts." }, - _0_modifier_cannot_be_used_in_an_ambient_context: { code: 1040, category: ts.DiagnosticCategory.Error, key: "'{0}' modifier cannot be used in an ambient context." }, - _0_modifier_cannot_be_used_with_a_class_declaration: { code: 1041, category: ts.DiagnosticCategory.Error, key: "'{0}' modifier cannot be used with a class declaration." }, - _0_modifier_cannot_be_used_here: { code: 1042, category: ts.DiagnosticCategory.Error, key: "'{0}' modifier cannot be used here." }, - _0_modifier_cannot_appear_on_a_data_property: { code: 1043, category: ts.DiagnosticCategory.Error, key: "'{0}' modifier cannot appear on a data property." }, - _0_modifier_cannot_appear_on_a_module_element: { code: 1044, category: ts.DiagnosticCategory.Error, key: "'{0}' modifier cannot appear on a module element." }, - A_0_modifier_cannot_be_used_with_an_interface_declaration: { code: 1045, category: ts.DiagnosticCategory.Error, key: "A '{0}' modifier cannot be used with an interface declaration." }, - A_declare_modifier_is_required_for_a_top_level_declaration_in_a_d_ts_file: { code: 1046, category: ts.DiagnosticCategory.Error, key: "A 'declare' modifier is required for a top level declaration in a .d.ts file." }, - A_rest_parameter_cannot_be_optional: { code: 1047, category: ts.DiagnosticCategory.Error, key: "A rest parameter cannot be optional." }, - A_rest_parameter_cannot_have_an_initializer: { code: 1048, category: ts.DiagnosticCategory.Error, key: "A rest parameter cannot have an initializer." }, - A_set_accessor_must_have_exactly_one_parameter: { code: 1049, category: ts.DiagnosticCategory.Error, key: "A 'set' accessor must have exactly one parameter." }, - A_set_accessor_cannot_have_an_optional_parameter: { code: 1051, category: ts.DiagnosticCategory.Error, key: "A 'set' accessor cannot have an optional parameter." }, - A_set_accessor_parameter_cannot_have_an_initializer: { code: 1052, category: ts.DiagnosticCategory.Error, key: "A 'set' accessor parameter cannot have an initializer." }, - A_set_accessor_cannot_have_rest_parameter: { code: 1053, category: ts.DiagnosticCategory.Error, key: "A 'set' accessor cannot have rest parameter." }, - A_get_accessor_cannot_have_parameters: { code: 1054, category: ts.DiagnosticCategory.Error, key: "A 'get' accessor cannot have parameters." }, - Type_0_is_not_a_valid_async_function_return_type: { code: 1055, category: ts.DiagnosticCategory.Error, key: "Type '{0}' is not a valid async function return type." }, - Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher: { code: 1056, category: ts.DiagnosticCategory.Error, key: "Accessors are only available when targeting ECMAScript 5 and higher." }, - An_async_function_or_method_must_have_a_valid_awaitable_return_type: { code: 1057, category: ts.DiagnosticCategory.Error, key: "An async function or method must have a valid awaitable return type." }, - Operand_for_await_does_not_have_a_valid_callable_then_member: { code: 1058, category: ts.DiagnosticCategory.Error, key: "Operand for 'await' does not have a valid callable 'then' member." }, - Return_expression_in_async_function_does_not_have_a_valid_callable_then_member: { code: 1059, category: ts.DiagnosticCategory.Error, key: "Return expression in async function does not have a valid callable 'then' member." }, - Expression_body_for_async_arrow_function_does_not_have_a_valid_callable_then_member: { code: 1060, category: ts.DiagnosticCategory.Error, key: "Expression body for async arrow function does not have a valid callable 'then' member." }, - Enum_member_must_have_initializer: { code: 1061, category: ts.DiagnosticCategory.Error, key: "Enum member must have initializer." }, - _0_is_referenced_directly_or_indirectly_in_the_fulfillment_callback_of_its_own_then_method: { code: 1062, category: ts.DiagnosticCategory.Error, key: "{0} is referenced directly or indirectly in the fulfillment callback of its own 'then' method." }, - An_export_assignment_cannot_be_used_in_a_namespace: { code: 1063, category: ts.DiagnosticCategory.Error, key: "An export assignment cannot be used in a namespace." }, - In_ambient_enum_declarations_member_initializer_must_be_constant_expression: { code: 1066, category: ts.DiagnosticCategory.Error, key: "In ambient enum declarations member initializer must be constant expression." }, - Unexpected_token_A_constructor_method_accessor_or_property_was_expected: { code: 1068, category: ts.DiagnosticCategory.Error, key: "Unexpected token. A constructor, method, accessor, or property was expected." }, - A_0_modifier_cannot_be_used_with_an_import_declaration: { code: 1079, category: ts.DiagnosticCategory.Error, key: "A '{0}' modifier cannot be used with an import declaration." }, - Invalid_reference_directive_syntax: { code: 1084, category: ts.DiagnosticCategory.Error, key: "Invalid 'reference' directive syntax." }, - Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher: { code: 1085, category: ts.DiagnosticCategory.Error, key: "Octal literals are not available when targeting ECMAScript 5 and higher." }, - An_accessor_cannot_be_declared_in_an_ambient_context: { code: 1086, category: ts.DiagnosticCategory.Error, key: "An accessor cannot be declared in an ambient context." }, - _0_modifier_cannot_appear_on_a_constructor_declaration: { code: 1089, category: ts.DiagnosticCategory.Error, key: "'{0}' modifier cannot appear on a constructor declaration." }, - _0_modifier_cannot_appear_on_a_parameter: { code: 1090, category: ts.DiagnosticCategory.Error, key: "'{0}' modifier cannot appear on a parameter." }, - Only_a_single_variable_declaration_is_allowed_in_a_for_in_statement: { code: 1091, category: ts.DiagnosticCategory.Error, key: "Only a single variable declaration is allowed in a 'for...in' statement." }, - Type_parameters_cannot_appear_on_a_constructor_declaration: { code: 1092, category: ts.DiagnosticCategory.Error, key: "Type parameters cannot appear on a constructor declaration." }, - Type_annotation_cannot_appear_on_a_constructor_declaration: { code: 1093, category: ts.DiagnosticCategory.Error, key: "Type annotation cannot appear on a constructor declaration." }, - An_accessor_cannot_have_type_parameters: { code: 1094, category: ts.DiagnosticCategory.Error, key: "An accessor cannot have type parameters." }, - A_set_accessor_cannot_have_a_return_type_annotation: { code: 1095, category: ts.DiagnosticCategory.Error, key: "A 'set' accessor cannot have a return type annotation." }, - An_index_signature_must_have_exactly_one_parameter: { code: 1096, category: ts.DiagnosticCategory.Error, key: "An index signature must have exactly one parameter." }, - _0_list_cannot_be_empty: { code: 1097, category: ts.DiagnosticCategory.Error, key: "'{0}' list cannot be empty." }, - Type_parameter_list_cannot_be_empty: { code: 1098, category: ts.DiagnosticCategory.Error, key: "Type parameter list cannot be empty." }, - Type_argument_list_cannot_be_empty: { code: 1099, category: ts.DiagnosticCategory.Error, key: "Type argument list cannot be empty." }, - Invalid_use_of_0_in_strict_mode: { code: 1100, category: ts.DiagnosticCategory.Error, key: "Invalid use of '{0}' in strict mode." }, - with_statements_are_not_allowed_in_strict_mode: { code: 1101, category: ts.DiagnosticCategory.Error, key: "'with' statements are not allowed in strict mode." }, - delete_cannot_be_called_on_an_identifier_in_strict_mode: { code: 1102, category: ts.DiagnosticCategory.Error, key: "'delete' cannot be called on an identifier in strict mode." }, - A_continue_statement_can_only_be_used_within_an_enclosing_iteration_statement: { code: 1104, category: ts.DiagnosticCategory.Error, key: "A 'continue' statement can only be used within an enclosing iteration statement." }, - A_break_statement_can_only_be_used_within_an_enclosing_iteration_or_switch_statement: { code: 1105, category: ts.DiagnosticCategory.Error, key: "A 'break' statement can only be used within an enclosing iteration or switch statement." }, - Jump_target_cannot_cross_function_boundary: { code: 1107, category: ts.DiagnosticCategory.Error, key: "Jump target cannot cross function boundary." }, - A_return_statement_can_only_be_used_within_a_function_body: { code: 1108, category: ts.DiagnosticCategory.Error, key: "A 'return' statement can only be used within a function body." }, - Expression_expected: { code: 1109, category: ts.DiagnosticCategory.Error, key: "Expression expected." }, - Type_expected: { code: 1110, category: ts.DiagnosticCategory.Error, key: "Type expected." }, - A_class_member_cannot_be_declared_optional: { code: 1112, category: ts.DiagnosticCategory.Error, key: "A class member cannot be declared optional." }, - A_default_clause_cannot_appear_more_than_once_in_a_switch_statement: { code: 1113, category: ts.DiagnosticCategory.Error, key: "A 'default' clause cannot appear more than once in a 'switch' statement." }, - Duplicate_label_0: { code: 1114, category: ts.DiagnosticCategory.Error, key: "Duplicate label '{0}'" }, - A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement: { code: 1115, category: ts.DiagnosticCategory.Error, key: "A 'continue' statement can only jump to a label of an enclosing iteration statement." }, - A_break_statement_can_only_jump_to_a_label_of_an_enclosing_statement: { code: 1116, category: ts.DiagnosticCategory.Error, key: "A 'break' statement can only jump to a label of an enclosing statement." }, - An_object_literal_cannot_have_multiple_properties_with_the_same_name_in_strict_mode: { code: 1117, category: ts.DiagnosticCategory.Error, key: "An object literal cannot have multiple properties with the same name in strict mode." }, - An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name: { code: 1118, category: ts.DiagnosticCategory.Error, key: "An object literal cannot have multiple get/set accessors with the same name." }, - An_object_literal_cannot_have_property_and_accessor_with_the_same_name: { code: 1119, category: ts.DiagnosticCategory.Error, key: "An object literal cannot have property and accessor with the same name." }, - An_export_assignment_cannot_have_modifiers: { code: 1120, category: ts.DiagnosticCategory.Error, key: "An export assignment cannot have modifiers." }, - Octal_literals_are_not_allowed_in_strict_mode: { code: 1121, category: ts.DiagnosticCategory.Error, key: "Octal literals are not allowed in strict mode." }, - A_tuple_type_element_list_cannot_be_empty: { code: 1122, category: ts.DiagnosticCategory.Error, key: "A tuple type element list cannot be empty." }, - Variable_declaration_list_cannot_be_empty: { code: 1123, category: ts.DiagnosticCategory.Error, key: "Variable declaration list cannot be empty." }, - Digit_expected: { code: 1124, category: ts.DiagnosticCategory.Error, key: "Digit expected." }, - Hexadecimal_digit_expected: { code: 1125, category: ts.DiagnosticCategory.Error, key: "Hexadecimal digit expected." }, - Unexpected_end_of_text: { code: 1126, category: ts.DiagnosticCategory.Error, key: "Unexpected end of text." }, - Invalid_character: { code: 1127, category: ts.DiagnosticCategory.Error, key: "Invalid character." }, - Declaration_or_statement_expected: { code: 1128, category: ts.DiagnosticCategory.Error, key: "Declaration or statement expected." }, - Statement_expected: { code: 1129, category: ts.DiagnosticCategory.Error, key: "Statement expected." }, - case_or_default_expected: { code: 1130, category: ts.DiagnosticCategory.Error, key: "'case' or 'default' expected." }, - Property_or_signature_expected: { code: 1131, category: ts.DiagnosticCategory.Error, key: "Property or signature expected." }, - Enum_member_expected: { code: 1132, category: ts.DiagnosticCategory.Error, key: "Enum member expected." }, - Variable_declaration_expected: { code: 1134, category: ts.DiagnosticCategory.Error, key: "Variable declaration expected." }, - Argument_expression_expected: { code: 1135, category: ts.DiagnosticCategory.Error, key: "Argument expression expected." }, - Property_assignment_expected: { code: 1136, category: ts.DiagnosticCategory.Error, key: "Property assignment expected." }, - Expression_or_comma_expected: { code: 1137, category: ts.DiagnosticCategory.Error, key: "Expression or comma expected." }, - Parameter_declaration_expected: { code: 1138, category: ts.DiagnosticCategory.Error, key: "Parameter declaration expected." }, - Type_parameter_declaration_expected: { code: 1139, category: ts.DiagnosticCategory.Error, key: "Type parameter declaration expected." }, - Type_argument_expected: { code: 1140, category: ts.DiagnosticCategory.Error, key: "Type argument expected." }, - String_literal_expected: { code: 1141, category: ts.DiagnosticCategory.Error, key: "String literal expected." }, - Line_break_not_permitted_here: { code: 1142, category: ts.DiagnosticCategory.Error, key: "Line break not permitted here." }, - or_expected: { code: 1144, category: ts.DiagnosticCategory.Error, key: "'{' or ';' expected." }, - Modifiers_not_permitted_on_index_signature_members: { code: 1145, category: ts.DiagnosticCategory.Error, key: "Modifiers not permitted on index signature members." }, - Declaration_expected: { code: 1146, category: ts.DiagnosticCategory.Error, key: "Declaration expected." }, - Import_declarations_in_a_namespace_cannot_reference_a_module: { code: 1147, category: ts.DiagnosticCategory.Error, key: "Import declarations in a namespace cannot reference a module." }, - Cannot_compile_modules_unless_the_module_flag_is_provided: { code: 1148, category: ts.DiagnosticCategory.Error, key: "Cannot compile modules unless the '--module' flag is provided." }, - File_name_0_differs_from_already_included_file_name_1_only_in_casing: { code: 1149, category: ts.DiagnosticCategory.Error, key: "File name '{0}' differs from already included file name '{1}' only in casing" }, - new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead: { code: 1150, category: ts.DiagnosticCategory.Error, key: "'new T[]' cannot be used to create an array. Use 'new Array()' instead." }, - const_declarations_must_be_initialized: { code: 1155, category: ts.DiagnosticCategory.Error, key: "'const' declarations must be initialized" }, - const_declarations_can_only_be_declared_inside_a_block: { code: 1156, category: ts.DiagnosticCategory.Error, key: "'const' declarations can only be declared inside a block." }, - let_declarations_can_only_be_declared_inside_a_block: { code: 1157, category: ts.DiagnosticCategory.Error, key: "'let' declarations can only be declared inside a block." }, - Unterminated_template_literal: { code: 1160, category: ts.DiagnosticCategory.Error, key: "Unterminated template literal." }, - Unterminated_regular_expression_literal: { code: 1161, category: ts.DiagnosticCategory.Error, key: "Unterminated regular expression literal." }, - An_object_member_cannot_be_declared_optional: { code: 1162, category: ts.DiagnosticCategory.Error, key: "An object member cannot be declared optional." }, - A_yield_expression_is_only_allowed_in_a_generator_body: { code: 1163, category: ts.DiagnosticCategory.Error, key: "A 'yield' expression is only allowed in a generator body." }, - Computed_property_names_are_not_allowed_in_enums: { code: 1164, category: ts.DiagnosticCategory.Error, key: "Computed property names are not allowed in enums." }, - A_computed_property_name_in_an_ambient_context_must_directly_refer_to_a_built_in_symbol: { code: 1165, category: ts.DiagnosticCategory.Error, key: "A computed property name in an ambient context must directly refer to a built-in symbol." }, - A_computed_property_name_in_a_class_property_declaration_must_directly_refer_to_a_built_in_symbol: { code: 1166, category: ts.DiagnosticCategory.Error, key: "A computed property name in a class property declaration must directly refer to a built-in symbol." }, - A_computed_property_name_in_a_method_overload_must_directly_refer_to_a_built_in_symbol: { code: 1168, category: ts.DiagnosticCategory.Error, key: "A computed property name in a method overload must directly refer to a built-in symbol." }, - A_computed_property_name_in_an_interface_must_directly_refer_to_a_built_in_symbol: { code: 1169, category: ts.DiagnosticCategory.Error, key: "A computed property name in an interface must directly refer to a built-in symbol." }, - A_computed_property_name_in_a_type_literal_must_directly_refer_to_a_built_in_symbol: { code: 1170, category: ts.DiagnosticCategory.Error, key: "A computed property name in a type literal must directly refer to a built-in symbol." }, - A_comma_expression_is_not_allowed_in_a_computed_property_name: { code: 1171, category: ts.DiagnosticCategory.Error, key: "A comma expression is not allowed in a computed property name." }, - extends_clause_already_seen: { code: 1172, category: ts.DiagnosticCategory.Error, key: "'extends' clause already seen." }, - extends_clause_must_precede_implements_clause: { code: 1173, category: ts.DiagnosticCategory.Error, key: "'extends' clause must precede 'implements' clause." }, - Classes_can_only_extend_a_single_class: { code: 1174, category: ts.DiagnosticCategory.Error, key: "Classes can only extend a single class." }, - implements_clause_already_seen: { code: 1175, category: ts.DiagnosticCategory.Error, key: "'implements' clause already seen." }, - Interface_declaration_cannot_have_implements_clause: { code: 1176, category: ts.DiagnosticCategory.Error, key: "Interface declaration cannot have 'implements' clause." }, - Binary_digit_expected: { code: 1177, category: ts.DiagnosticCategory.Error, key: "Binary digit expected." }, - Octal_digit_expected: { code: 1178, category: ts.DiagnosticCategory.Error, key: "Octal digit expected." }, - Unexpected_token_expected: { code: 1179, category: ts.DiagnosticCategory.Error, key: "Unexpected token. '{' expected." }, - Property_destructuring_pattern_expected: { code: 1180, category: ts.DiagnosticCategory.Error, key: "Property destructuring pattern expected." }, - Array_element_destructuring_pattern_expected: { code: 1181, category: ts.DiagnosticCategory.Error, key: "Array element destructuring pattern expected." }, - A_destructuring_declaration_must_have_an_initializer: { code: 1182, category: ts.DiagnosticCategory.Error, key: "A destructuring declaration must have an initializer." }, - An_implementation_cannot_be_declared_in_ambient_contexts: { code: 1183, category: ts.DiagnosticCategory.Error, key: "An implementation cannot be declared in ambient contexts." }, - Modifiers_cannot_appear_here: { code: 1184, category: ts.DiagnosticCategory.Error, key: "Modifiers cannot appear here." }, - Merge_conflict_marker_encountered: { code: 1185, category: ts.DiagnosticCategory.Error, key: "Merge conflict marker encountered." }, - A_rest_element_cannot_have_an_initializer: { code: 1186, category: ts.DiagnosticCategory.Error, key: "A rest element cannot have an initializer." }, - A_parameter_property_may_not_be_a_binding_pattern: { code: 1187, category: ts.DiagnosticCategory.Error, key: "A parameter property may not be a binding pattern." }, - Only_a_single_variable_declaration_is_allowed_in_a_for_of_statement: { code: 1188, category: ts.DiagnosticCategory.Error, key: "Only a single variable declaration is allowed in a 'for...of' statement." }, - The_variable_declaration_of_a_for_in_statement_cannot_have_an_initializer: { code: 1189, category: ts.DiagnosticCategory.Error, key: "The variable declaration of a 'for...in' statement cannot have an initializer." }, - The_variable_declaration_of_a_for_of_statement_cannot_have_an_initializer: { code: 1190, category: ts.DiagnosticCategory.Error, key: "The variable declaration of a 'for...of' statement cannot have an initializer." }, - An_import_declaration_cannot_have_modifiers: { code: 1191, category: ts.DiagnosticCategory.Error, key: "An import declaration cannot have modifiers." }, - Module_0_has_no_default_export: { code: 1192, category: ts.DiagnosticCategory.Error, key: "Module '{0}' has no default export." }, - An_export_declaration_cannot_have_modifiers: { code: 1193, category: ts.DiagnosticCategory.Error, key: "An export declaration cannot have modifiers." }, - Export_declarations_are_not_permitted_in_a_namespace: { code: 1194, category: ts.DiagnosticCategory.Error, key: "Export declarations are not permitted in a namespace." }, - Catch_clause_variable_name_must_be_an_identifier: { code: 1195, category: ts.DiagnosticCategory.Error, key: "Catch clause variable name must be an identifier." }, - Catch_clause_variable_cannot_have_a_type_annotation: { code: 1196, category: ts.DiagnosticCategory.Error, key: "Catch clause variable cannot have a type annotation." }, - Catch_clause_variable_cannot_have_an_initializer: { code: 1197, category: ts.DiagnosticCategory.Error, key: "Catch clause variable cannot have an initializer." }, - An_extended_Unicode_escape_value_must_be_between_0x0_and_0x10FFFF_inclusive: { code: 1198, category: ts.DiagnosticCategory.Error, key: "An extended Unicode escape value must be between 0x0 and 0x10FFFF inclusive." }, - Unterminated_Unicode_escape_sequence: { code: 1199, category: ts.DiagnosticCategory.Error, key: "Unterminated Unicode escape sequence." }, - Line_terminator_not_permitted_before_arrow: { code: 1200, category: ts.DiagnosticCategory.Error, key: "Line terminator not permitted before arrow." }, - Import_assignment_cannot_be_used_when_targeting_ECMAScript_6_modules_Consider_using_import_Asterisk_as_ns_from_mod_import_a_from_mod_import_d_from_mod_or_another_module_format_instead: { code: 1202, category: ts.DiagnosticCategory.Error, key: "Import assignment cannot be used when targeting ECMAScript 6 modules. Consider using 'import * as ns from \"mod\"', 'import {a} from \"mod\"', 'import d from \"mod\"', or another module format instead." }, - Export_assignment_cannot_be_used_when_targeting_ECMAScript_6_modules_Consider_using_export_default_or_another_module_format_instead: { code: 1203, category: ts.DiagnosticCategory.Error, key: "Export assignment cannot be used when targeting ECMAScript 6 modules. Consider using 'export default' or another module format instead." }, - Cannot_compile_modules_into_es2015_when_targeting_ES5_or_lower: { code: 1204, category: ts.DiagnosticCategory.Error, key: "Cannot compile modules into 'es2015' when targeting 'ES5' or lower." }, - Decorators_are_not_valid_here: { code: 1206, category: ts.DiagnosticCategory.Error, key: "Decorators are not valid here." }, - Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name: { code: 1207, category: ts.DiagnosticCategory.Error, key: "Decorators cannot be applied to multiple get/set accessors of the same name." }, - Cannot_compile_namespaces_when_the_isolatedModules_flag_is_provided: { code: 1208, category: ts.DiagnosticCategory.Error, key: "Cannot compile namespaces when the '--isolatedModules' flag is provided." }, - Ambient_const_enums_are_not_allowed_when_the_isolatedModules_flag_is_provided: { code: 1209, category: ts.DiagnosticCategory.Error, key: "Ambient const enums are not allowed when the '--isolatedModules' flag is provided." }, - Invalid_use_of_0_Class_definitions_are_automatically_in_strict_mode: { code: 1210, category: ts.DiagnosticCategory.Error, key: "Invalid use of '{0}'. Class definitions are automatically in strict mode." }, - A_class_declaration_without_the_default_modifier_must_have_a_name: { code: 1211, category: ts.DiagnosticCategory.Error, key: "A class declaration without the 'default' modifier must have a name" }, - Identifier_expected_0_is_a_reserved_word_in_strict_mode: { code: 1212, category: ts.DiagnosticCategory.Error, key: "Identifier expected. '{0}' is a reserved word in strict mode" }, - Identifier_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_strict_mode: { code: 1213, category: ts.DiagnosticCategory.Error, key: "Identifier expected. '{0}' is a reserved word in strict mode. Class definitions are automatically in strict mode." }, - Identifier_expected_0_is_a_reserved_word_in_strict_mode_Modules_are_automatically_in_strict_mode: { code: 1214, category: ts.DiagnosticCategory.Error, key: "Identifier expected. '{0}' is a reserved word in strict mode. Modules are automatically in strict mode." }, - Invalid_use_of_0_Modules_are_automatically_in_strict_mode: { code: 1215, category: ts.DiagnosticCategory.Error, key: "Invalid use of '{0}'. Modules are automatically in strict mode." }, - Export_assignment_is_not_supported_when_module_flag_is_system: { code: 1218, category: ts.DiagnosticCategory.Error, key: "Export assignment is not supported when '--module' flag is 'system'." }, - Experimental_support_for_decorators_is_a_feature_that_is_subject_to_change_in_a_future_release_Specify_experimentalDecorators_to_remove_this_warning: { code: 1219, category: ts.DiagnosticCategory.Error, key: "Experimental support for decorators is a feature that is subject to change in a future release. Specify '--experimentalDecorators' to remove this warning." }, - Generators_are_only_available_when_targeting_ECMAScript_6_or_higher: { code: 1220, category: ts.DiagnosticCategory.Error, key: "Generators are only available when targeting ECMAScript 6 or higher." }, - Generators_are_not_allowed_in_an_ambient_context: { code: 1221, category: ts.DiagnosticCategory.Error, key: "Generators are not allowed in an ambient context." }, - An_overload_signature_cannot_be_declared_as_a_generator: { code: 1222, category: ts.DiagnosticCategory.Error, key: "An overload signature cannot be declared as a generator." }, - _0_tag_already_specified: { code: 1223, category: ts.DiagnosticCategory.Error, key: "'{0}' tag already specified." }, - Signature_0_must_have_a_type_predicate: { code: 1224, category: ts.DiagnosticCategory.Error, key: "Signature '{0}' must have a type predicate." }, - Cannot_find_parameter_0: { code: 1225, category: ts.DiagnosticCategory.Error, key: "Cannot find parameter '{0}'." }, - Type_predicate_0_is_not_assignable_to_1: { code: 1226, category: ts.DiagnosticCategory.Error, key: "Type predicate '{0}' is not assignable to '{1}'." }, - Parameter_0_is_not_in_the_same_position_as_parameter_1: { code: 1227, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' is not in the same position as parameter '{1}'." }, - A_type_predicate_is_only_allowed_in_return_type_position_for_functions_and_methods: { code: 1228, category: ts.DiagnosticCategory.Error, key: "A type predicate is only allowed in return type position for functions and methods." }, - A_type_predicate_cannot_reference_a_rest_parameter: { code: 1229, category: ts.DiagnosticCategory.Error, key: "A type predicate cannot reference a rest parameter." }, - A_type_predicate_cannot_reference_element_0_in_a_binding_pattern: { code: 1230, category: ts.DiagnosticCategory.Error, key: "A type predicate cannot reference element '{0}' in a binding pattern." }, - An_export_assignment_can_only_be_used_in_a_module: { code: 1231, category: ts.DiagnosticCategory.Error, key: "An export assignment can only be used in a module." }, - An_import_declaration_can_only_be_used_in_a_namespace_or_module: { code: 1232, category: ts.DiagnosticCategory.Error, key: "An import declaration can only be used in a namespace or module." }, - An_export_declaration_can_only_be_used_in_a_module: { code: 1233, category: ts.DiagnosticCategory.Error, key: "An export declaration can only be used in a module." }, - An_ambient_module_declaration_is_only_allowed_at_the_top_level_in_a_file: { code: 1234, category: ts.DiagnosticCategory.Error, key: "An ambient module declaration is only allowed at the top level in a file." }, - A_namespace_declaration_is_only_allowed_in_a_namespace_or_module: { code: 1235, category: ts.DiagnosticCategory.Error, key: "A namespace declaration is only allowed in a namespace or module." }, - The_return_type_of_a_property_decorator_function_must_be_either_void_or_any: { code: 1236, category: ts.DiagnosticCategory.Error, key: "The return type of a property decorator function must be either 'void' or 'any'." }, - The_return_type_of_a_parameter_decorator_function_must_be_either_void_or_any: { code: 1237, category: ts.DiagnosticCategory.Error, key: "The return type of a parameter decorator function must be either 'void' or 'any'." }, - Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression: { code: 1238, category: ts.DiagnosticCategory.Error, key: "Unable to resolve signature of class decorator when called as an expression." }, - Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression: { code: 1239, category: ts.DiagnosticCategory.Error, key: "Unable to resolve signature of parameter decorator when called as an expression." }, - Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression: { code: 1240, category: ts.DiagnosticCategory.Error, key: "Unable to resolve signature of property decorator when called as an expression." }, - Unable_to_resolve_signature_of_method_decorator_when_called_as_an_expression: { code: 1241, category: ts.DiagnosticCategory.Error, key: "Unable to resolve signature of method decorator when called as an expression." }, - abstract_modifier_can_only_appear_on_a_class_or_method_declaration: { code: 1242, category: ts.DiagnosticCategory.Error, key: "'abstract' modifier can only appear on a class or method declaration." }, - _0_modifier_cannot_be_used_with_1_modifier: { code: 1243, category: ts.DiagnosticCategory.Error, key: "'{0}' modifier cannot be used with '{1}' modifier." }, - Abstract_methods_can_only_appear_within_an_abstract_class: { code: 1244, category: ts.DiagnosticCategory.Error, key: "Abstract methods can only appear within an abstract class." }, - Method_0_cannot_have_an_implementation_because_it_is_marked_abstract: { code: 1245, category: ts.DiagnosticCategory.Error, key: "Method '{0}' cannot have an implementation because it is marked abstract." }, - with_statements_are_not_allowed_in_an_async_function_block: { code: 1300, category: ts.DiagnosticCategory.Error, key: "'with' statements are not allowed in an async function block." }, - await_expression_is_only_allowed_within_an_async_function: { code: 1308, category: ts.DiagnosticCategory.Error, key: "'await' expression is only allowed within an async function." }, - Async_functions_are_only_available_when_targeting_ECMAScript_6_and_higher: { code: 1311, category: ts.DiagnosticCategory.Error, key: "Async functions are only available when targeting ECMAScript 6 and higher." }, - can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment: { code: 1312, category: ts.DiagnosticCategory.Error, key: "'=' can only be used in an object literal property inside a destructuring assignment." }, - Duplicate_identifier_0: { code: 2300, category: ts.DiagnosticCategory.Error, key: "Duplicate identifier '{0}'." }, - Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor: { code: 2301, category: ts.DiagnosticCategory.Error, key: "Initializer of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor." }, - Static_members_cannot_reference_class_type_parameters: { code: 2302, category: ts.DiagnosticCategory.Error, key: "Static members cannot reference class type parameters." }, - Circular_definition_of_import_alias_0: { code: 2303, category: ts.DiagnosticCategory.Error, key: "Circular definition of import alias '{0}'." }, - Cannot_find_name_0: { code: 2304, category: ts.DiagnosticCategory.Error, key: "Cannot find name '{0}'." }, - Module_0_has_no_exported_member_1: { code: 2305, category: ts.DiagnosticCategory.Error, key: "Module '{0}' has no exported member '{1}'." }, - File_0_is_not_a_module: { code: 2306, category: ts.DiagnosticCategory.Error, key: "File '{0}' is not a module." }, - Cannot_find_module_0: { code: 2307, category: ts.DiagnosticCategory.Error, key: "Cannot find module '{0}'." }, - An_export_assignment_cannot_be_used_in_a_module_with_other_exported_elements: { code: 2309, category: ts.DiagnosticCategory.Error, key: "An export assignment cannot be used in a module with other exported elements." }, - Type_0_recursively_references_itself_as_a_base_type: { code: 2310, category: ts.DiagnosticCategory.Error, key: "Type '{0}' recursively references itself as a base type." }, - A_class_may_only_extend_another_class: { code: 2311, category: ts.DiagnosticCategory.Error, key: "A class may only extend another class." }, - An_interface_may_only_extend_a_class_or_another_interface: { code: 2312, category: ts.DiagnosticCategory.Error, key: "An interface may only extend a class or another interface." }, - Constraint_of_a_type_parameter_cannot_reference_any_type_parameter_from_the_same_type_parameter_list: { code: 2313, category: ts.DiagnosticCategory.Error, key: "Constraint of a type parameter cannot reference any type parameter from the same type parameter list." }, - Generic_type_0_requires_1_type_argument_s: { code: 2314, category: ts.DiagnosticCategory.Error, key: "Generic type '{0}' requires {1} type argument(s)." }, - Type_0_is_not_generic: { code: 2315, category: ts.DiagnosticCategory.Error, key: "Type '{0}' is not generic." }, - Global_type_0_must_be_a_class_or_interface_type: { code: 2316, category: ts.DiagnosticCategory.Error, key: "Global type '{0}' must be a class or interface type." }, - Global_type_0_must_have_1_type_parameter_s: { code: 2317, category: ts.DiagnosticCategory.Error, key: "Global type '{0}' must have {1} type parameter(s)." }, - Cannot_find_global_type_0: { code: 2318, category: ts.DiagnosticCategory.Error, key: "Cannot find global type '{0}'." }, - Named_property_0_of_types_1_and_2_are_not_identical: { code: 2319, category: ts.DiagnosticCategory.Error, key: "Named property '{0}' of types '{1}' and '{2}' are not identical." }, - Interface_0_cannot_simultaneously_extend_types_1_and_2: { code: 2320, category: ts.DiagnosticCategory.Error, key: "Interface '{0}' cannot simultaneously extend types '{1}' and '{2}'." }, - Excessive_stack_depth_comparing_types_0_and_1: { code: 2321, category: ts.DiagnosticCategory.Error, key: "Excessive stack depth comparing types '{0}' and '{1}'." }, - Type_0_is_not_assignable_to_type_1: { code: 2322, category: ts.DiagnosticCategory.Error, key: "Type '{0}' is not assignable to type '{1}'." }, - Property_0_is_missing_in_type_1: { code: 2324, category: ts.DiagnosticCategory.Error, key: "Property '{0}' is missing in type '{1}'." }, - Property_0_is_private_in_type_1_but_not_in_type_2: { code: 2325, category: ts.DiagnosticCategory.Error, key: "Property '{0}' is private in type '{1}' but not in type '{2}'." }, - Types_of_property_0_are_incompatible: { code: 2326, category: ts.DiagnosticCategory.Error, key: "Types of property '{0}' are incompatible." }, - Property_0_is_optional_in_type_1_but_required_in_type_2: { code: 2327, category: ts.DiagnosticCategory.Error, key: "Property '{0}' is optional in type '{1}' but required in type '{2}'." }, - Types_of_parameters_0_and_1_are_incompatible: { code: 2328, category: ts.DiagnosticCategory.Error, key: "Types of parameters '{0}' and '{1}' are incompatible." }, - Index_signature_is_missing_in_type_0: { code: 2329, category: ts.DiagnosticCategory.Error, key: "Index signature is missing in type '{0}'." }, - Index_signatures_are_incompatible: { code: 2330, category: ts.DiagnosticCategory.Error, key: "Index signatures are incompatible." }, - this_cannot_be_referenced_in_a_module_or_namespace_body: { code: 2331, category: ts.DiagnosticCategory.Error, key: "'this' cannot be referenced in a module or namespace body." }, - this_cannot_be_referenced_in_current_location: { code: 2332, category: ts.DiagnosticCategory.Error, key: "'this' cannot be referenced in current location." }, - this_cannot_be_referenced_in_constructor_arguments: { code: 2333, category: ts.DiagnosticCategory.Error, key: "'this' cannot be referenced in constructor arguments." }, - this_cannot_be_referenced_in_a_static_property_initializer: { code: 2334, category: ts.DiagnosticCategory.Error, key: "'this' cannot be referenced in a static property initializer." }, - super_can_only_be_referenced_in_a_derived_class: { code: 2335, category: ts.DiagnosticCategory.Error, key: "'super' can only be referenced in a derived class." }, - super_cannot_be_referenced_in_constructor_arguments: { code: 2336, category: ts.DiagnosticCategory.Error, key: "'super' cannot be referenced in constructor arguments." }, - Super_calls_are_not_permitted_outside_constructors_or_in_nested_functions_inside_constructors: { code: 2337, category: ts.DiagnosticCategory.Error, key: "Super calls are not permitted outside constructors or in nested functions inside constructors." }, - super_property_access_is_permitted_only_in_a_constructor_member_function_or_member_accessor_of_a_derived_class: { code: 2338, category: ts.DiagnosticCategory.Error, key: "'super' property access is permitted only in a constructor, member function, or member accessor of a derived class." }, - Property_0_does_not_exist_on_type_1: { code: 2339, category: ts.DiagnosticCategory.Error, key: "Property '{0}' does not exist on type '{1}'." }, - Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword: { code: 2340, category: ts.DiagnosticCategory.Error, key: "Only public and protected methods of the base class are accessible via the 'super' keyword." }, - Property_0_is_private_and_only_accessible_within_class_1: { code: 2341, category: ts.DiagnosticCategory.Error, key: "Property '{0}' is private and only accessible within class '{1}'." }, - An_index_expression_argument_must_be_of_type_string_number_symbol_or_any: { code: 2342, category: ts.DiagnosticCategory.Error, key: "An index expression argument must be of type 'string', 'number', 'symbol', or 'any'." }, - Type_0_does_not_satisfy_the_constraint_1: { code: 2344, category: ts.DiagnosticCategory.Error, key: "Type '{0}' does not satisfy the constraint '{1}'." }, - Argument_of_type_0_is_not_assignable_to_parameter_of_type_1: { code: 2345, category: ts.DiagnosticCategory.Error, key: "Argument of type '{0}' is not assignable to parameter of type '{1}'." }, - Supplied_parameters_do_not_match_any_signature_of_call_target: { code: 2346, category: ts.DiagnosticCategory.Error, key: "Supplied parameters do not match any signature of call target." }, - Untyped_function_calls_may_not_accept_type_arguments: { code: 2347, category: ts.DiagnosticCategory.Error, key: "Untyped function calls may not accept type arguments." }, - Value_of_type_0_is_not_callable_Did_you_mean_to_include_new: { code: 2348, category: ts.DiagnosticCategory.Error, key: "Value of type '{0}' is not callable. Did you mean to include 'new'?" }, - Cannot_invoke_an_expression_whose_type_lacks_a_call_signature: { code: 2349, category: ts.DiagnosticCategory.Error, key: "Cannot invoke an expression whose type lacks a call signature." }, - Only_a_void_function_can_be_called_with_the_new_keyword: { code: 2350, category: ts.DiagnosticCategory.Error, key: "Only a void function can be called with the 'new' keyword." }, - Cannot_use_new_with_an_expression_whose_type_lacks_a_call_or_construct_signature: { code: 2351, category: ts.DiagnosticCategory.Error, key: "Cannot use 'new' with an expression whose type lacks a call or construct signature." }, - Neither_type_0_nor_type_1_is_assignable_to_the_other: { code: 2352, category: ts.DiagnosticCategory.Error, key: "Neither type '{0}' nor type '{1}' is assignable to the other." }, - Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1: { code: 2353, category: ts.DiagnosticCategory.Error, key: "Object literal may only specify known properties, and '{0}' does not exist in type '{1}'." }, - No_best_common_type_exists_among_return_expressions: { code: 2354, category: ts.DiagnosticCategory.Error, key: "No best common type exists among return expressions." }, - A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value_or_consist_of_a_single_throw_statement: { code: 2355, category: ts.DiagnosticCategory.Error, key: "A function whose declared type is neither 'void' nor 'any' must return a value or consist of a single 'throw' statement." }, - An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type: { code: 2356, category: ts.DiagnosticCategory.Error, key: "An arithmetic operand must be of type 'any', 'number' or an enum type." }, - The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_property_or_indexer: { code: 2357, category: ts.DiagnosticCategory.Error, key: "The operand of an increment or decrement operator must be a variable, property or indexer." }, - The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_parameter: { code: 2358, category: ts.DiagnosticCategory.Error, key: "The left-hand side of an 'instanceof' expression must be of type 'any', an object type or a type parameter." }, - The_right_hand_side_of_an_instanceof_expression_must_be_of_type_any_or_of_a_type_assignable_to_the_Function_interface_type: { code: 2359, category: ts.DiagnosticCategory.Error, key: "The right-hand side of an 'instanceof' expression must be of type 'any' or of a type assignable to the 'Function' interface type." }, - The_left_hand_side_of_an_in_expression_must_be_of_type_any_string_number_or_symbol: { code: 2360, category: ts.DiagnosticCategory.Error, key: "The left-hand side of an 'in' expression must be of type 'any', 'string', 'number', or 'symbol'." }, - The_right_hand_side_of_an_in_expression_must_be_of_type_any_an_object_type_or_a_type_parameter: { code: 2361, category: ts.DiagnosticCategory.Error, key: "The right-hand side of an 'in' expression must be of type 'any', an object type or a type parameter" }, - The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type: { code: 2362, category: ts.DiagnosticCategory.Error, key: "The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type." }, - The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type: { code: 2363, category: ts.DiagnosticCategory.Error, key: "The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type." }, - Invalid_left_hand_side_of_assignment_expression: { code: 2364, category: ts.DiagnosticCategory.Error, key: "Invalid left-hand side of assignment expression." }, - Operator_0_cannot_be_applied_to_types_1_and_2: { code: 2365, category: ts.DiagnosticCategory.Error, key: "Operator '{0}' cannot be applied to types '{1}' and '{2}'." }, - Type_parameter_name_cannot_be_0: { code: 2368, category: ts.DiagnosticCategory.Error, key: "Type parameter name cannot be '{0}'" }, - A_parameter_property_is_only_allowed_in_a_constructor_implementation: { code: 2369, category: ts.DiagnosticCategory.Error, key: "A parameter property is only allowed in a constructor implementation." }, - A_rest_parameter_must_be_of_an_array_type: { code: 2370, category: ts.DiagnosticCategory.Error, key: "A rest parameter must be of an array type." }, - A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation: { code: 2371, category: ts.DiagnosticCategory.Error, key: "A parameter initializer is only allowed in a function or constructor implementation." }, - Parameter_0_cannot_be_referenced_in_its_initializer: { code: 2372, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' cannot be referenced in its initializer." }, - Initializer_of_parameter_0_cannot_reference_identifier_1_declared_after_it: { code: 2373, category: ts.DiagnosticCategory.Error, key: "Initializer of parameter '{0}' cannot reference identifier '{1}' declared after it." }, - Duplicate_string_index_signature: { code: 2374, category: ts.DiagnosticCategory.Error, key: "Duplicate string index signature." }, - Duplicate_number_index_signature: { code: 2375, category: ts.DiagnosticCategory.Error, key: "Duplicate number index signature." }, - A_super_call_must_be_the_first_statement_in_the_constructor_when_a_class_contains_initialized_properties_or_has_parameter_properties: { code: 2376, category: ts.DiagnosticCategory.Error, key: "A 'super' call must be the first statement in the constructor when a class contains initialized properties or has parameter properties." }, - Constructors_for_derived_classes_must_contain_a_super_call: { code: 2377, category: ts.DiagnosticCategory.Error, key: "Constructors for derived classes must contain a 'super' call." }, - A_get_accessor_must_return_a_value_or_consist_of_a_single_throw_statement: { code: 2378, category: ts.DiagnosticCategory.Error, key: "A 'get' accessor must return a value or consist of a single 'throw' statement." }, - Getter_and_setter_accessors_do_not_agree_in_visibility: { code: 2379, category: ts.DiagnosticCategory.Error, key: "Getter and setter accessors do not agree in visibility." }, - get_and_set_accessor_must_have_the_same_type: { code: 2380, category: ts.DiagnosticCategory.Error, key: "'get' and 'set' accessor must have the same type." }, - A_signature_with_an_implementation_cannot_use_a_string_literal_type: { code: 2381, category: ts.DiagnosticCategory.Error, key: "A signature with an implementation cannot use a string literal type." }, - Specialized_overload_signature_is_not_assignable_to_any_non_specialized_signature: { code: 2382, category: ts.DiagnosticCategory.Error, key: "Specialized overload signature is not assignable to any non-specialized signature." }, - Overload_signatures_must_all_be_exported_or_not_exported: { code: 2383, category: ts.DiagnosticCategory.Error, key: "Overload signatures must all be exported or not exported." }, - Overload_signatures_must_all_be_ambient_or_non_ambient: { code: 2384, category: ts.DiagnosticCategory.Error, key: "Overload signatures must all be ambient or non-ambient." }, - Overload_signatures_must_all_be_public_private_or_protected: { code: 2385, category: ts.DiagnosticCategory.Error, key: "Overload signatures must all be public, private or protected." }, - Overload_signatures_must_all_be_optional_or_required: { code: 2386, category: ts.DiagnosticCategory.Error, key: "Overload signatures must all be optional or required." }, - Function_overload_must_be_static: { code: 2387, category: ts.DiagnosticCategory.Error, key: "Function overload must be static." }, - Function_overload_must_not_be_static: { code: 2388, category: ts.DiagnosticCategory.Error, key: "Function overload must not be static." }, - Function_implementation_name_must_be_0: { code: 2389, category: ts.DiagnosticCategory.Error, key: "Function implementation name must be '{0}'." }, - Constructor_implementation_is_missing: { code: 2390, category: ts.DiagnosticCategory.Error, key: "Constructor implementation is missing." }, - Function_implementation_is_missing_or_not_immediately_following_the_declaration: { code: 2391, category: ts.DiagnosticCategory.Error, key: "Function implementation is missing or not immediately following the declaration." }, - Multiple_constructor_implementations_are_not_allowed: { code: 2392, category: ts.DiagnosticCategory.Error, key: "Multiple constructor implementations are not allowed." }, - Duplicate_function_implementation: { code: 2393, category: ts.DiagnosticCategory.Error, key: "Duplicate function implementation." }, - Overload_signature_is_not_compatible_with_function_implementation: { code: 2394, category: ts.DiagnosticCategory.Error, key: "Overload signature is not compatible with function implementation." }, - Individual_declarations_in_merged_declaration_0_must_be_all_exported_or_all_local: { code: 2395, category: ts.DiagnosticCategory.Error, key: "Individual declarations in merged declaration '{0}' must be all exported or all local." }, - Duplicate_identifier_arguments_Compiler_uses_arguments_to_initialize_rest_parameters: { code: 2396, category: ts.DiagnosticCategory.Error, key: "Duplicate identifier 'arguments'. Compiler uses 'arguments' to initialize rest parameters." }, - Duplicate_identifier_this_Compiler_uses_variable_declaration_this_to_capture_this_reference: { code: 2399, category: ts.DiagnosticCategory.Error, key: "Duplicate identifier '_this'. Compiler uses variable declaration '_this' to capture 'this' reference." }, - Expression_resolves_to_variable_declaration_this_that_compiler_uses_to_capture_this_reference: { code: 2400, category: ts.DiagnosticCategory.Error, key: "Expression resolves to variable declaration '_this' that compiler uses to capture 'this' reference." }, - Duplicate_identifier_super_Compiler_uses_super_to_capture_base_class_reference: { code: 2401, category: ts.DiagnosticCategory.Error, key: "Duplicate identifier '_super'. Compiler uses '_super' to capture base class reference." }, - Expression_resolves_to_super_that_compiler_uses_to_capture_base_class_reference: { code: 2402, category: ts.DiagnosticCategory.Error, key: "Expression resolves to '_super' that compiler uses to capture base class reference." }, - Subsequent_variable_declarations_must_have_the_same_type_Variable_0_must_be_of_type_1_but_here_has_type_2: { code: 2403, category: ts.DiagnosticCategory.Error, key: "Subsequent variable declarations must have the same type. Variable '{0}' must be of type '{1}', but here has type '{2}'." }, - The_left_hand_side_of_a_for_in_statement_cannot_use_a_type_annotation: { code: 2404, category: ts.DiagnosticCategory.Error, key: "The left-hand side of a 'for...in' statement cannot use a type annotation." }, - The_left_hand_side_of_a_for_in_statement_must_be_of_type_string_or_any: { code: 2405, category: ts.DiagnosticCategory.Error, key: "The left-hand side of a 'for...in' statement must be of type 'string' or 'any'." }, - Invalid_left_hand_side_in_for_in_statement: { code: 2406, category: ts.DiagnosticCategory.Error, key: "Invalid left-hand side in 'for...in' statement." }, - The_right_hand_side_of_a_for_in_statement_must_be_of_type_any_an_object_type_or_a_type_parameter: { code: 2407, category: ts.DiagnosticCategory.Error, key: "The right-hand side of a 'for...in' statement must be of type 'any', an object type or a type parameter." }, - Setters_cannot_return_a_value: { code: 2408, category: ts.DiagnosticCategory.Error, key: "Setters cannot return a value." }, - Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class: { code: 2409, category: ts.DiagnosticCategory.Error, key: "Return type of constructor signature must be assignable to the instance type of the class" }, - All_symbols_within_a_with_block_will_be_resolved_to_any: { code: 2410, category: ts.DiagnosticCategory.Error, key: "All symbols within a 'with' block will be resolved to 'any'." }, - Property_0_of_type_1_is_not_assignable_to_string_index_type_2: { code: 2411, category: ts.DiagnosticCategory.Error, key: "Property '{0}' of type '{1}' is not assignable to string index type '{2}'." }, - Property_0_of_type_1_is_not_assignable_to_numeric_index_type_2: { code: 2412, category: ts.DiagnosticCategory.Error, key: "Property '{0}' of type '{1}' is not assignable to numeric index type '{2}'." }, - Numeric_index_type_0_is_not_assignable_to_string_index_type_1: { code: 2413, category: ts.DiagnosticCategory.Error, key: "Numeric index type '{0}' is not assignable to string index type '{1}'." }, - Class_name_cannot_be_0: { code: 2414, category: ts.DiagnosticCategory.Error, key: "Class name cannot be '{0}'" }, - Class_0_incorrectly_extends_base_class_1: { code: 2415, category: ts.DiagnosticCategory.Error, key: "Class '{0}' incorrectly extends base class '{1}'." }, - Class_static_side_0_incorrectly_extends_base_class_static_side_1: { code: 2417, category: ts.DiagnosticCategory.Error, key: "Class static side '{0}' incorrectly extends base class static side '{1}'." }, - Type_name_0_in_extends_clause_does_not_reference_constructor_function_for_0: { code: 2419, category: ts.DiagnosticCategory.Error, key: "Type name '{0}' in extends clause does not reference constructor function for '{0}'." }, - Class_0_incorrectly_implements_interface_1: { code: 2420, category: ts.DiagnosticCategory.Error, key: "Class '{0}' incorrectly implements interface '{1}'." }, - A_class_may_only_implement_another_class_or_interface: { code: 2422, category: ts.DiagnosticCategory.Error, key: "A class may only implement another class or interface." }, - Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_accessor: { code: 2423, category: ts.DiagnosticCategory.Error, key: "Class '{0}' defines instance member function '{1}', but extended class '{2}' defines it as instance member accessor." }, - Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_property: { code: 2424, category: ts.DiagnosticCategory.Error, key: "Class '{0}' defines instance member function '{1}', but extended class '{2}' defines it as instance member property." }, - Class_0_defines_instance_member_property_1_but_extended_class_2_defines_it_as_instance_member_function: { code: 2425, category: ts.DiagnosticCategory.Error, key: "Class '{0}' defines instance member property '{1}', but extended class '{2}' defines it as instance member function." }, - Class_0_defines_instance_member_accessor_1_but_extended_class_2_defines_it_as_instance_member_function: { code: 2426, category: ts.DiagnosticCategory.Error, key: "Class '{0}' defines instance member accessor '{1}', but extended class '{2}' defines it as instance member function." }, - Interface_name_cannot_be_0: { code: 2427, category: ts.DiagnosticCategory.Error, key: "Interface name cannot be '{0}'" }, - All_declarations_of_an_interface_must_have_identical_type_parameters: { code: 2428, category: ts.DiagnosticCategory.Error, key: "All declarations of an interface must have identical type parameters." }, - Interface_0_incorrectly_extends_interface_1: { code: 2430, category: ts.DiagnosticCategory.Error, key: "Interface '{0}' incorrectly extends interface '{1}'." }, - Enum_name_cannot_be_0: { code: 2431, category: ts.DiagnosticCategory.Error, key: "Enum name cannot be '{0}'" }, - In_an_enum_with_multiple_declarations_only_one_declaration_can_omit_an_initializer_for_its_first_enum_element: { code: 2432, category: ts.DiagnosticCategory.Error, key: "In an enum with multiple declarations, only one declaration can omit an initializer for its first enum element." }, - A_namespace_declaration_cannot_be_in_a_different_file_from_a_class_or_function_with_which_it_is_merged: { code: 2433, category: ts.DiagnosticCategory.Error, key: "A namespace declaration cannot be in a different file from a class or function with which it is merged" }, - A_namespace_declaration_cannot_be_located_prior_to_a_class_or_function_with_which_it_is_merged: { code: 2434, category: ts.DiagnosticCategory.Error, key: "A namespace declaration cannot be located prior to a class or function with which it is merged" }, - Ambient_modules_cannot_be_nested_in_other_modules_or_namespaces: { code: 2435, category: ts.DiagnosticCategory.Error, key: "Ambient modules cannot be nested in other modules or namespaces." }, - Ambient_module_declaration_cannot_specify_relative_module_name: { code: 2436, category: ts.DiagnosticCategory.Error, key: "Ambient module declaration cannot specify relative module name." }, - Module_0_is_hidden_by_a_local_declaration_with_the_same_name: { code: 2437, category: ts.DiagnosticCategory.Error, key: "Module '{0}' is hidden by a local declaration with the same name" }, - Import_name_cannot_be_0: { code: 2438, category: ts.DiagnosticCategory.Error, key: "Import name cannot be '{0}'" }, - Import_or_export_declaration_in_an_ambient_module_declaration_cannot_reference_module_through_relative_module_name: { code: 2439, category: ts.DiagnosticCategory.Error, key: "Import or export declaration in an ambient module declaration cannot reference module through relative module name." }, - Import_declaration_conflicts_with_local_declaration_of_0: { code: 2440, category: ts.DiagnosticCategory.Error, key: "Import declaration conflicts with local declaration of '{0}'" }, - Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module: { code: 2441, category: ts.DiagnosticCategory.Error, key: "Duplicate identifier '{0}'. Compiler reserves name '{1}' in top level scope of a module." }, - Types_have_separate_declarations_of_a_private_property_0: { code: 2442, category: ts.DiagnosticCategory.Error, key: "Types have separate declarations of a private property '{0}'." }, - Property_0_is_protected_but_type_1_is_not_a_class_derived_from_2: { code: 2443, category: ts.DiagnosticCategory.Error, key: "Property '{0}' is protected but type '{1}' is not a class derived from '{2}'." }, - Property_0_is_protected_in_type_1_but_public_in_type_2: { code: 2444, category: ts.DiagnosticCategory.Error, key: "Property '{0}' is protected in type '{1}' but public in type '{2}'." }, - Property_0_is_protected_and_only_accessible_within_class_1_and_its_subclasses: { code: 2445, category: ts.DiagnosticCategory.Error, key: "Property '{0}' is protected and only accessible within class '{1}' and its subclasses." }, - Property_0_is_protected_and_only_accessible_through_an_instance_of_class_1: { code: 2446, category: ts.DiagnosticCategory.Error, key: "Property '{0}' is protected and only accessible through an instance of class '{1}'." }, - The_0_operator_is_not_allowed_for_boolean_types_Consider_using_1_instead: { code: 2447, category: ts.DiagnosticCategory.Error, key: "The '{0}' operator is not allowed for boolean types. Consider using '{1}' instead." }, - Block_scoped_variable_0_used_before_its_declaration: { code: 2448, category: ts.DiagnosticCategory.Error, key: "Block-scoped variable '{0}' used before its declaration." }, - The_operand_of_an_increment_or_decrement_operator_cannot_be_a_constant: { code: 2449, category: ts.DiagnosticCategory.Error, key: "The operand of an increment or decrement operator cannot be a constant." }, - Left_hand_side_of_assignment_expression_cannot_be_a_constant: { code: 2450, category: ts.DiagnosticCategory.Error, key: "Left-hand side of assignment expression cannot be a constant." }, - Cannot_redeclare_block_scoped_variable_0: { code: 2451, category: ts.DiagnosticCategory.Error, key: "Cannot redeclare block-scoped variable '{0}'." }, - An_enum_member_cannot_have_a_numeric_name: { code: 2452, category: ts.DiagnosticCategory.Error, key: "An enum member cannot have a numeric name." }, - The_type_argument_for_type_parameter_0_cannot_be_inferred_from_the_usage_Consider_specifying_the_type_arguments_explicitly: { code: 2453, category: ts.DiagnosticCategory.Error, key: "The type argument for type parameter '{0}' cannot be inferred from the usage. Consider specifying the type arguments explicitly." }, - Type_argument_candidate_1_is_not_a_valid_type_argument_because_it_is_not_a_supertype_of_candidate_0: { code: 2455, category: ts.DiagnosticCategory.Error, key: "Type argument candidate '{1}' is not a valid type argument because it is not a supertype of candidate '{0}'." }, - Type_alias_0_circularly_references_itself: { code: 2456, category: ts.DiagnosticCategory.Error, key: "Type alias '{0}' circularly references itself." }, - Type_alias_name_cannot_be_0: { code: 2457, category: ts.DiagnosticCategory.Error, key: "Type alias name cannot be '{0}'" }, - An_AMD_module_cannot_have_multiple_name_assignments: { code: 2458, category: ts.DiagnosticCategory.Error, key: "An AMD module cannot have multiple name assignments." }, - Type_0_has_no_property_1_and_no_string_index_signature: { code: 2459, category: ts.DiagnosticCategory.Error, key: "Type '{0}' has no property '{1}' and no string index signature." }, - Type_0_has_no_property_1: { code: 2460, category: ts.DiagnosticCategory.Error, key: "Type '{0}' has no property '{1}'." }, - Type_0_is_not_an_array_type: { code: 2461, category: ts.DiagnosticCategory.Error, key: "Type '{0}' is not an array type." }, - A_rest_element_must_be_last_in_an_array_destructuring_pattern: { code: 2462, category: ts.DiagnosticCategory.Error, key: "A rest element must be last in an array destructuring pattern" }, - A_binding_pattern_parameter_cannot_be_optional_in_an_implementation_signature: { code: 2463, category: ts.DiagnosticCategory.Error, key: "A binding pattern parameter cannot be optional in an implementation signature." }, - A_computed_property_name_must_be_of_type_string_number_symbol_or_any: { code: 2464, category: ts.DiagnosticCategory.Error, key: "A computed property name must be of type 'string', 'number', 'symbol', or 'any'." }, - this_cannot_be_referenced_in_a_computed_property_name: { code: 2465, category: ts.DiagnosticCategory.Error, key: "'this' cannot be referenced in a computed property name." }, - super_cannot_be_referenced_in_a_computed_property_name: { code: 2466, category: ts.DiagnosticCategory.Error, key: "'super' cannot be referenced in a computed property name." }, - A_computed_property_name_cannot_reference_a_type_parameter_from_its_containing_type: { code: 2467, category: ts.DiagnosticCategory.Error, key: "A computed property name cannot reference a type parameter from its containing type." }, - Cannot_find_global_value_0: { code: 2468, category: ts.DiagnosticCategory.Error, key: "Cannot find global value '{0}'." }, - The_0_operator_cannot_be_applied_to_type_symbol: { code: 2469, category: ts.DiagnosticCategory.Error, key: "The '{0}' operator cannot be applied to type 'symbol'." }, - Symbol_reference_does_not_refer_to_the_global_Symbol_constructor_object: { code: 2470, category: ts.DiagnosticCategory.Error, key: "'Symbol' reference does not refer to the global Symbol constructor object." }, - A_computed_property_name_of_the_form_0_must_be_of_type_symbol: { code: 2471, category: ts.DiagnosticCategory.Error, key: "A computed property name of the form '{0}' must be of type 'symbol'." }, - Spread_operator_in_new_expressions_is_only_available_when_targeting_ECMAScript_5_and_higher: { code: 2472, category: ts.DiagnosticCategory.Error, key: "Spread operator in 'new' expressions is only available when targeting ECMAScript 5 and higher." }, - Enum_declarations_must_all_be_const_or_non_const: { code: 2473, category: ts.DiagnosticCategory.Error, key: "Enum declarations must all be const or non-const." }, - In_const_enum_declarations_member_initializer_must_be_constant_expression: { code: 2474, category: ts.DiagnosticCategory.Error, key: "In 'const' enum declarations member initializer must be constant expression." }, - const_enums_can_only_be_used_in_property_or_index_access_expressions_or_the_right_hand_side_of_an_import_declaration_or_export_assignment: { code: 2475, category: ts.DiagnosticCategory.Error, key: "'const' enums can only be used in property or index access expressions or the right hand side of an import declaration or export assignment." }, - A_const_enum_member_can_only_be_accessed_using_a_string_literal: { code: 2476, category: ts.DiagnosticCategory.Error, key: "A const enum member can only be accessed using a string literal." }, - const_enum_member_initializer_was_evaluated_to_a_non_finite_value: { code: 2477, category: ts.DiagnosticCategory.Error, key: "'const' enum member initializer was evaluated to a non-finite value." }, - const_enum_member_initializer_was_evaluated_to_disallowed_value_NaN: { code: 2478, category: ts.DiagnosticCategory.Error, key: "'const' enum member initializer was evaluated to disallowed value 'NaN'." }, - Property_0_does_not_exist_on_const_enum_1: { code: 2479, category: ts.DiagnosticCategory.Error, key: "Property '{0}' does not exist on 'const' enum '{1}'." }, - let_is_not_allowed_to_be_used_as_a_name_in_let_or_const_declarations: { code: 2480, category: ts.DiagnosticCategory.Error, key: "'let' is not allowed to be used as a name in 'let' or 'const' declarations." }, - Cannot_initialize_outer_scoped_variable_0_in_the_same_scope_as_block_scoped_declaration_1: { code: 2481, category: ts.DiagnosticCategory.Error, key: "Cannot initialize outer scoped variable '{0}' in the same scope as block scoped declaration '{1}'." }, - The_left_hand_side_of_a_for_of_statement_cannot_use_a_type_annotation: { code: 2483, category: ts.DiagnosticCategory.Error, key: "The left-hand side of a 'for...of' statement cannot use a type annotation." }, - Export_declaration_conflicts_with_exported_declaration_of_0: { code: 2484, category: ts.DiagnosticCategory.Error, key: "Export declaration conflicts with exported declaration of '{0}'" }, - The_left_hand_side_of_a_for_of_statement_cannot_be_a_previously_defined_constant: { code: 2485, category: ts.DiagnosticCategory.Error, key: "The left-hand side of a 'for...of' statement cannot be a previously defined constant." }, - The_left_hand_side_of_a_for_in_statement_cannot_be_a_previously_defined_constant: { code: 2486, category: ts.DiagnosticCategory.Error, key: "The left-hand side of a 'for...in' statement cannot be a previously defined constant." }, - Invalid_left_hand_side_in_for_of_statement: { code: 2487, category: ts.DiagnosticCategory.Error, key: "Invalid left-hand side in 'for...of' statement." }, - Type_must_have_a_Symbol_iterator_method_that_returns_an_iterator: { code: 2488, category: ts.DiagnosticCategory.Error, key: "Type must have a '[Symbol.iterator]()' method that returns an iterator." }, - An_iterator_must_have_a_next_method: { code: 2489, category: ts.DiagnosticCategory.Error, key: "An iterator must have a 'next()' method." }, - The_type_returned_by_the_next_method_of_an_iterator_must_have_a_value_property: { code: 2490, category: ts.DiagnosticCategory.Error, key: "The type returned by the 'next()' method of an iterator must have a 'value' property." }, - The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern: { code: 2491, category: ts.DiagnosticCategory.Error, key: "The left-hand side of a 'for...in' statement cannot be a destructuring pattern." }, - Cannot_redeclare_identifier_0_in_catch_clause: { code: 2492, category: ts.DiagnosticCategory.Error, key: "Cannot redeclare identifier '{0}' in catch clause" }, - Tuple_type_0_with_length_1_cannot_be_assigned_to_tuple_with_length_2: { code: 2493, category: ts.DiagnosticCategory.Error, key: "Tuple type '{0}' with length '{1}' cannot be assigned to tuple with length '{2}'." }, - Using_a_string_in_a_for_of_statement_is_only_supported_in_ECMAScript_5_and_higher: { code: 2494, category: ts.DiagnosticCategory.Error, key: "Using a string in a 'for...of' statement is only supported in ECMAScript 5 and higher." }, - Type_0_is_not_an_array_type_or_a_string_type: { code: 2495, category: ts.DiagnosticCategory.Error, key: "Type '{0}' is not an array type or a string type." }, - The_arguments_object_cannot_be_referenced_in_an_arrow_function_in_ES3_and_ES5_Consider_using_a_standard_function_expression: { code: 2496, category: ts.DiagnosticCategory.Error, key: "The 'arguments' object cannot be referenced in an arrow function in ES3 and ES5. Consider using a standard function expression." }, - Module_0_resolves_to_a_non_module_entity_and_cannot_be_imported_using_this_construct: { code: 2497, category: ts.DiagnosticCategory.Error, key: "Module '{0}' resolves to a non-module entity and cannot be imported using this construct." }, - Module_0_uses_export_and_cannot_be_used_with_export_Asterisk: { code: 2498, category: ts.DiagnosticCategory.Error, key: "Module '{0}' uses 'export =' and cannot be used with 'export *'." }, - An_interface_can_only_extend_an_identifier_Slashqualified_name_with_optional_type_arguments: { code: 2499, category: ts.DiagnosticCategory.Error, key: "An interface can only extend an identifier/qualified-name with optional type arguments." }, - A_class_can_only_implement_an_identifier_Slashqualified_name_with_optional_type_arguments: { code: 2500, category: ts.DiagnosticCategory.Error, key: "A class can only implement an identifier/qualified-name with optional type arguments." }, - A_rest_element_cannot_contain_a_binding_pattern: { code: 2501, category: ts.DiagnosticCategory.Error, key: "A rest element cannot contain a binding pattern." }, - _0_is_referenced_directly_or_indirectly_in_its_own_type_annotation: { code: 2502, category: ts.DiagnosticCategory.Error, key: "'{0}' is referenced directly or indirectly in its own type annotation." }, - Cannot_find_namespace_0: { code: 2503, category: ts.DiagnosticCategory.Error, key: "Cannot find namespace '{0}'." }, - No_best_common_type_exists_among_yield_expressions: { code: 2504, category: ts.DiagnosticCategory.Error, key: "No best common type exists among yield expressions." }, - A_generator_cannot_have_a_void_type_annotation: { code: 2505, category: ts.DiagnosticCategory.Error, key: "A generator cannot have a 'void' type annotation." }, - _0_is_referenced_directly_or_indirectly_in_its_own_base_expression: { code: 2506, category: ts.DiagnosticCategory.Error, key: "'{0}' is referenced directly or indirectly in its own base expression." }, - Type_0_is_not_a_constructor_function_type: { code: 2507, category: ts.DiagnosticCategory.Error, key: "Type '{0}' is not a constructor function type." }, - No_base_constructor_has_the_specified_number_of_type_arguments: { code: 2508, category: ts.DiagnosticCategory.Error, key: "No base constructor has the specified number of type arguments." }, - Base_constructor_return_type_0_is_not_a_class_or_interface_type: { code: 2509, category: ts.DiagnosticCategory.Error, key: "Base constructor return type '{0}' is not a class or interface type." }, - Base_constructors_must_all_have_the_same_return_type: { code: 2510, category: ts.DiagnosticCategory.Error, key: "Base constructors must all have the same return type." }, - Cannot_create_an_instance_of_the_abstract_class_0: { code: 2511, category: ts.DiagnosticCategory.Error, key: "Cannot create an instance of the abstract class '{0}'." }, - Overload_signatures_must_all_be_abstract_or_not_abstract: { code: 2512, category: ts.DiagnosticCategory.Error, key: "Overload signatures must all be abstract or not abstract." }, - Abstract_method_0_in_class_1_cannot_be_accessed_via_super_expression: { code: 2513, category: ts.DiagnosticCategory.Error, key: "Abstract method '{0}' in class '{1}' cannot be accessed via super expression." }, - Classes_containing_abstract_methods_must_be_marked_abstract: { code: 2514, category: ts.DiagnosticCategory.Error, key: "Classes containing abstract methods must be marked abstract." }, - Non_abstract_class_0_does_not_implement_inherited_abstract_member_1_from_class_2: { code: 2515, category: ts.DiagnosticCategory.Error, key: "Non-abstract class '{0}' does not implement inherited abstract member '{1}' from class '{2}'." }, - All_declarations_of_an_abstract_method_must_be_consecutive: { code: 2516, category: ts.DiagnosticCategory.Error, key: "All declarations of an abstract method must be consecutive." }, - Cannot_assign_an_abstract_constructor_type_to_a_non_abstract_constructor_type: { code: 2517, category: ts.DiagnosticCategory.Error, key: "Cannot assign an abstract constructor type to a non-abstract constructor type." }, - Duplicate_identifier_0_Compiler_uses_declaration_1_to_support_async_functions: { code: 2520, category: ts.DiagnosticCategory.Error, key: "Duplicate identifier '{0}'. Compiler uses declaration '{1}' to support async functions." }, - Expression_resolves_to_variable_declaration_0_that_compiler_uses_to_support_async_functions: { code: 2521, category: ts.DiagnosticCategory.Error, key: "Expression resolves to variable declaration '{0}' that compiler uses to support async functions." }, - The_arguments_object_cannot_be_referenced_in_an_async_arrow_function_Consider_using_a_standard_async_function_expression: { code: 2522, category: ts.DiagnosticCategory.Error, key: "The 'arguments' object cannot be referenced in an async arrow function. Consider using a standard async function expression." }, - yield_expressions_cannot_be_used_in_a_parameter_initializer: { code: 2523, category: ts.DiagnosticCategory.Error, key: "'yield' expressions cannot be used in a parameter initializer." }, - await_expressions_cannot_be_used_in_a_parameter_initializer: { code: 2524, category: ts.DiagnosticCategory.Error, key: "'await' expressions cannot be used in a parameter initializer." }, - Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value: { code: 2525, category: ts.DiagnosticCategory.Error, key: "Initializer provides no value for this binding element and the binding element has no default value." }, - A_this_type_is_available_only_in_a_non_static_member_of_a_class_or_interface: { code: 2526, category: ts.DiagnosticCategory.Error, key: "A 'this' type is available only in a non-static member of a class or interface." }, - The_inferred_type_of_0_references_an_inaccessible_this_type_A_type_annotation_is_necessary: { code: 2527, category: ts.DiagnosticCategory.Error, key: "The inferred type of '{0}' references an inaccessible 'this' type. A type annotation is necessary." }, - A_module_cannot_have_multiple_default_exports: { code: 2528, category: ts.DiagnosticCategory.Error, key: "A module cannot have multiple default exports." }, - JSX_element_attributes_type_0_must_be_an_object_type: { code: 2600, category: ts.DiagnosticCategory.Error, key: "JSX element attributes type '{0}' must be an object type." }, - The_return_type_of_a_JSX_element_constructor_must_return_an_object_type: { code: 2601, category: ts.DiagnosticCategory.Error, key: "The return type of a JSX element constructor must return an object type." }, - JSX_element_implicitly_has_type_any_because_the_global_type_JSX_Element_does_not_exist: { code: 2602, category: ts.DiagnosticCategory.Error, key: "JSX element implicitly has type 'any' because the global type 'JSX.Element' does not exist." }, - Property_0_in_type_1_is_not_assignable_to_type_2: { code: 2603, category: ts.DiagnosticCategory.Error, key: "Property '{0}' in type '{1}' is not assignable to type '{2}'" }, - JSX_element_type_0_does_not_have_any_construct_or_call_signatures: { code: 2604, category: ts.DiagnosticCategory.Error, key: "JSX element type '{0}' does not have any construct or call signatures." }, - JSX_element_type_0_is_not_a_constructor_function_for_JSX_elements: { code: 2605, category: ts.DiagnosticCategory.Error, key: "JSX element type '{0}' is not a constructor function for JSX elements." }, - Property_0_of_JSX_spread_attribute_is_not_assignable_to_target_property: { code: 2606, category: ts.DiagnosticCategory.Error, key: "Property '{0}' of JSX spread attribute is not assignable to target property." }, - JSX_element_class_does_not_support_attributes_because_it_does_not_have_a_0_property: { code: 2607, category: ts.DiagnosticCategory.Error, key: "JSX element class does not support attributes because it does not have a '{0}' property" }, - The_global_type_JSX_0_may_not_have_more_than_one_property: { code: 2608, category: ts.DiagnosticCategory.Error, key: "The global type 'JSX.{0}' may not have more than one property" }, - Cannot_emit_namespaced_JSX_elements_in_React: { code: 2650, category: ts.DiagnosticCategory.Error, key: "Cannot emit namespaced JSX elements in React" }, - A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_enums: { code: 2651, category: ts.DiagnosticCategory.Error, key: "A member initializer in a enum declaration cannot reference members declared after it, including members defined in other enums." }, - Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_default_0_declaration_instead: { code: 2652, category: ts.DiagnosticCategory.Error, key: "Merged declaration '{0}' cannot include a default export declaration. Consider adding a separate 'export default {0}' declaration instead." }, - Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1: { code: 2653, category: ts.DiagnosticCategory.Error, key: "Non-abstract class expression does not implement inherited abstract member '{0}' from class '{1}'." }, - Exported_external_package_typings_file_cannot_contain_tripleslash_references_Please_contact_the_package_author_to_update_the_package_definition: { code: 2654, category: ts.DiagnosticCategory.Error, key: "Exported external package typings file cannot contain tripleslash references. Please contact the package author to update the package definition." }, - Exported_external_package_typings_can_only_be_in_d_ts_files_Please_contact_the_package_author_to_update_the_package_definition: { code: 2655, category: ts.DiagnosticCategory.Error, key: "Exported external package typings can only be in '.d.ts' files. Please contact the package author to update the package definition." }, - Exported_external_package_typings_file_0_is_not_a_module_Please_contact_the_package_author_to_update_the_package_definition: { code: 2656, category: ts.DiagnosticCategory.Error, key: "Exported external package typings file '{0}' is not a module. Please contact the package author to update the package definition." }, - JSX_expressions_must_have_one_parent_element: { code: 2657, category: ts.DiagnosticCategory.Error, key: "JSX expressions must have one parent element" }, - Import_declaration_0_is_using_private_name_1: { code: 4000, category: ts.DiagnosticCategory.Error, key: "Import declaration '{0}' is using private name '{1}'." }, - Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: { code: 4002, category: ts.DiagnosticCategory.Error, key: "Type parameter '{0}' of exported class has or is using private name '{1}'." }, - Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1: { code: 4004, category: ts.DiagnosticCategory.Error, key: "Type parameter '{0}' of exported interface has or is using private name '{1}'." }, - Type_parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1: { code: 4006, category: ts.DiagnosticCategory.Error, key: "Type parameter '{0}' of constructor signature from exported interface has or is using private name '{1}'." }, - Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1: { code: 4008, category: ts.DiagnosticCategory.Error, key: "Type parameter '{0}' of call signature from exported interface has or is using private name '{1}'." }, - Type_parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1: { code: 4010, category: ts.DiagnosticCategory.Error, key: "Type parameter '{0}' of public static method from exported class has or is using private name '{1}'." }, - Type_parameter_0_of_public_method_from_exported_class_has_or_is_using_private_name_1: { code: 4012, category: ts.DiagnosticCategory.Error, key: "Type parameter '{0}' of public method from exported class has or is using private name '{1}'." }, - Type_parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1: { code: 4014, category: ts.DiagnosticCategory.Error, key: "Type parameter '{0}' of method from exported interface has or is using private name '{1}'." }, - Type_parameter_0_of_exported_function_has_or_is_using_private_name_1: { code: 4016, category: ts.DiagnosticCategory.Error, key: "Type parameter '{0}' of exported function has or is using private name '{1}'." }, - Implements_clause_of_exported_class_0_has_or_is_using_private_name_1: { code: 4019, category: ts.DiagnosticCategory.Error, key: "Implements clause of exported class '{0}' has or is using private name '{1}'." }, - Extends_clause_of_exported_class_0_has_or_is_using_private_name_1: { code: 4020, category: ts.DiagnosticCategory.Error, key: "Extends clause of exported class '{0}' has or is using private name '{1}'." }, - Extends_clause_of_exported_interface_0_has_or_is_using_private_name_1: { code: 4022, category: ts.DiagnosticCategory.Error, key: "Extends clause of exported interface '{0}' has or is using private name '{1}'." }, - Exported_variable_0_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: { code: 4023, category: ts.DiagnosticCategory.Error, key: "Exported variable '{0}' has or is using name '{1}' from external module {2} but cannot be named." }, - Exported_variable_0_has_or_is_using_name_1_from_private_module_2: { code: 4024, category: ts.DiagnosticCategory.Error, key: "Exported variable '{0}' has or is using name '{1}' from private module '{2}'." }, - Exported_variable_0_has_or_is_using_private_name_1: { code: 4025, category: ts.DiagnosticCategory.Error, key: "Exported variable '{0}' has or is using private name '{1}'." }, - Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: { code: 4026, category: ts.DiagnosticCategory.Error, key: "Public static property '{0}' of exported class has or is using name '{1}' from external module {2} but cannot be named." }, - Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2: { code: 4027, category: ts.DiagnosticCategory.Error, key: "Public static property '{0}' of exported class has or is using name '{1}' from private module '{2}'." }, - Public_static_property_0_of_exported_class_has_or_is_using_private_name_1: { code: 4028, category: ts.DiagnosticCategory.Error, key: "Public static property '{0}' of exported class has or is using private name '{1}'." }, - Public_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: { code: 4029, category: ts.DiagnosticCategory.Error, key: "Public property '{0}' of exported class has or is using name '{1}' from external module {2} but cannot be named." }, - Public_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2: { code: 4030, category: ts.DiagnosticCategory.Error, key: "Public property '{0}' of exported class has or is using name '{1}' from private module '{2}'." }, - Public_property_0_of_exported_class_has_or_is_using_private_name_1: { code: 4031, category: ts.DiagnosticCategory.Error, key: "Public property '{0}' of exported class has or is using private name '{1}'." }, - Property_0_of_exported_interface_has_or_is_using_name_1_from_private_module_2: { code: 4032, category: ts.DiagnosticCategory.Error, key: "Property '{0}' of exported interface has or is using name '{1}' from private module '{2}'." }, - Property_0_of_exported_interface_has_or_is_using_private_name_1: { code: 4033, category: ts.DiagnosticCategory.Error, key: "Property '{0}' of exported interface has or is using private name '{1}'." }, - Parameter_0_of_public_static_property_setter_from_exported_class_has_or_is_using_name_1_from_private_module_2: { code: 4034, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' of public static property setter from exported class has or is using name '{1}' from private module '{2}'." }, - Parameter_0_of_public_static_property_setter_from_exported_class_has_or_is_using_private_name_1: { code: 4035, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' of public static property setter from exported class has or is using private name '{1}'." }, - Parameter_0_of_public_property_setter_from_exported_class_has_or_is_using_name_1_from_private_module_2: { code: 4036, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' of public property setter from exported class has or is using name '{1}' from private module '{2}'." }, - Parameter_0_of_public_property_setter_from_exported_class_has_or_is_using_private_name_1: { code: 4037, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' of public property setter from exported class has or is using private name '{1}'." }, - Return_type_of_public_static_property_getter_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named: { code: 4038, category: ts.DiagnosticCategory.Error, key: "Return type of public static property getter from exported class has or is using name '{0}' from external module {1} but cannot be named." }, - Return_type_of_public_static_property_getter_from_exported_class_has_or_is_using_name_0_from_private_module_1: { code: 4039, category: ts.DiagnosticCategory.Error, key: "Return type of public static property getter from exported class has or is using name '{0}' from private module '{1}'." }, - Return_type_of_public_static_property_getter_from_exported_class_has_or_is_using_private_name_0: { code: 4040, category: ts.DiagnosticCategory.Error, key: "Return type of public static property getter from exported class has or is using private name '{0}'." }, - Return_type_of_public_property_getter_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named: { code: 4041, category: ts.DiagnosticCategory.Error, key: "Return type of public property getter from exported class has or is using name '{0}' from external module {1} but cannot be named." }, - Return_type_of_public_property_getter_from_exported_class_has_or_is_using_name_0_from_private_module_1: { code: 4042, category: ts.DiagnosticCategory.Error, key: "Return type of public property getter from exported class has or is using name '{0}' from private module '{1}'." }, - Return_type_of_public_property_getter_from_exported_class_has_or_is_using_private_name_0: { code: 4043, category: ts.DiagnosticCategory.Error, key: "Return type of public property getter from exported class has or is using private name '{0}'." }, - Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1: { code: 4044, category: ts.DiagnosticCategory.Error, key: "Return type of constructor signature from exported interface has or is using name '{0}' from private module '{1}'." }, - Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_0: { code: 4045, category: ts.DiagnosticCategory.Error, key: "Return type of constructor signature from exported interface has or is using private name '{0}'." }, - Return_type_of_call_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1: { code: 4046, category: ts.DiagnosticCategory.Error, key: "Return type of call signature from exported interface has or is using name '{0}' from private module '{1}'." }, - Return_type_of_call_signature_from_exported_interface_has_or_is_using_private_name_0: { code: 4047, category: ts.DiagnosticCategory.Error, key: "Return type of call signature from exported interface has or is using private name '{0}'." }, - Return_type_of_index_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1: { code: 4048, category: ts.DiagnosticCategory.Error, key: "Return type of index signature from exported interface has or is using name '{0}' from private module '{1}'." }, - Return_type_of_index_signature_from_exported_interface_has_or_is_using_private_name_0: { code: 4049, category: ts.DiagnosticCategory.Error, key: "Return type of index signature from exported interface has or is using private name '{0}'." }, - Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named: { code: 4050, category: ts.DiagnosticCategory.Error, key: "Return type of public static method from exported class has or is using name '{0}' from external module {1} but cannot be named." }, - Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_private_module_1: { code: 4051, category: ts.DiagnosticCategory.Error, key: "Return type of public static method from exported class has or is using name '{0}' from private module '{1}'." }, - Return_type_of_public_static_method_from_exported_class_has_or_is_using_private_name_0: { code: 4052, category: ts.DiagnosticCategory.Error, key: "Return type of public static method from exported class has or is using private name '{0}'." }, - Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named: { code: 4053, category: ts.DiagnosticCategory.Error, key: "Return type of public method from exported class has or is using name '{0}' from external module {1} but cannot be named." }, - Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_private_module_1: { code: 4054, category: ts.DiagnosticCategory.Error, key: "Return type of public method from exported class has or is using name '{0}' from private module '{1}'." }, - Return_type_of_public_method_from_exported_class_has_or_is_using_private_name_0: { code: 4055, category: ts.DiagnosticCategory.Error, key: "Return type of public method from exported class has or is using private name '{0}'." }, - Return_type_of_method_from_exported_interface_has_or_is_using_name_0_from_private_module_1: { code: 4056, category: ts.DiagnosticCategory.Error, key: "Return type of method from exported interface has or is using name '{0}' from private module '{1}'." }, - Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0: { code: 4057, category: ts.DiagnosticCategory.Error, key: "Return type of method from exported interface has or is using private name '{0}'." }, - Return_type_of_exported_function_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named: { code: 4058, category: ts.DiagnosticCategory.Error, key: "Return type of exported function has or is using name '{0}' from external module {1} but cannot be named." }, - Return_type_of_exported_function_has_or_is_using_name_0_from_private_module_1: { code: 4059, category: ts.DiagnosticCategory.Error, key: "Return type of exported function has or is using name '{0}' from private module '{1}'." }, - Return_type_of_exported_function_has_or_is_using_private_name_0: { code: 4060, category: ts.DiagnosticCategory.Error, key: "Return type of exported function has or is using private name '{0}'." }, - Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: { code: 4061, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' of constructor from exported class has or is using name '{1}' from external module {2} but cannot be named." }, - Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_private_module_2: { code: 4062, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' of constructor from exported class has or is using name '{1}' from private module '{2}'." }, - Parameter_0_of_constructor_from_exported_class_has_or_is_using_private_name_1: { code: 4063, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' of constructor from exported class has or is using private name '{1}'." }, - Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2: { code: 4064, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' of constructor signature from exported interface has or is using name '{1}' from private module '{2}'." }, - Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1: { code: 4065, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' of constructor signature from exported interface has or is using private name '{1}'." }, - Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2: { code: 4066, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' of call signature from exported interface has or is using name '{1}' from private module '{2}'." }, - Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1: { code: 4067, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' of call signature from exported interface has or is using private name '{1}'." }, - Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: { code: 4068, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' of public static method from exported class has or is using name '{1}' from external module {2} but cannot be named." }, - Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_private_module_2: { code: 4069, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' of public static method from exported class has or is using name '{1}' from private module '{2}'." }, - Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1: { code: 4070, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' of public static method from exported class has or is using private name '{1}'." }, - Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: { code: 4071, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' of public method from exported class has or is using name '{1}' from external module {2} but cannot be named." }, - Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_private_module_2: { code: 4072, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' of public method from exported class has or is using name '{1}' from private module '{2}'." }, - Parameter_0_of_public_method_from_exported_class_has_or_is_using_private_name_1: { code: 4073, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' of public method from exported class has or is using private name '{1}'." }, - Parameter_0_of_method_from_exported_interface_has_or_is_using_name_1_from_private_module_2: { code: 4074, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' of method from exported interface has or is using name '{1}' from private module '{2}'." }, - Parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1: { code: 4075, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' of method from exported interface has or is using private name '{1}'." }, - Parameter_0_of_exported_function_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: { code: 4076, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' of exported function has or is using name '{1}' from external module {2} but cannot be named." }, - Parameter_0_of_exported_function_has_or_is_using_name_1_from_private_module_2: { code: 4077, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' of exported function has or is using name '{1}' from private module '{2}'." }, - Parameter_0_of_exported_function_has_or_is_using_private_name_1: { code: 4078, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' of exported function has or is using private name '{1}'." }, - Exported_type_alias_0_has_or_is_using_private_name_1: { code: 4081, category: ts.DiagnosticCategory.Error, key: "Exported type alias '{0}' has or is using private name '{1}'." }, - Default_export_of_the_module_has_or_is_using_private_name_0: { code: 4082, category: ts.DiagnosticCategory.Error, key: "Default export of the module has or is using private name '{0}'." }, - Loop_contains_block_scoped_variable_0_referenced_by_a_function_in_the_loop_This_is_only_supported_in_ECMAScript_6_or_higher: { code: 4091, category: ts.DiagnosticCategory.Error, key: "Loop contains block-scoped variable '{0}' referenced by a function in the loop. This is only supported in ECMAScript 6 or higher." }, - The_current_host_does_not_support_the_0_option: { code: 5001, category: ts.DiagnosticCategory.Error, key: "The current host does not support the '{0}' option." }, - Cannot_find_the_common_subdirectory_path_for_the_input_files: { code: 5009, category: ts.DiagnosticCategory.Error, key: "Cannot find the common subdirectory path for the input files." }, - Cannot_read_file_0_Colon_1: { code: 5012, category: ts.DiagnosticCategory.Error, key: "Cannot read file '{0}': {1}" }, - Unsupported_file_encoding: { code: 5013, category: ts.DiagnosticCategory.Error, key: "Unsupported file encoding." }, - Failed_to_parse_file_0_Colon_1: { code: 5014, category: ts.DiagnosticCategory.Error, key: "Failed to parse file '{0}': {1}." }, - Unknown_compiler_option_0: { code: 5023, category: ts.DiagnosticCategory.Error, key: "Unknown compiler option '{0}'." }, - Compiler_option_0_requires_a_value_of_type_1: { code: 5024, category: ts.DiagnosticCategory.Error, key: "Compiler option '{0}' requires a value of type {1}." }, - Could_not_write_file_0_Colon_1: { code: 5033, category: ts.DiagnosticCategory.Error, key: "Could not write file '{0}': {1}" }, - Option_project_cannot_be_mixed_with_source_files_on_a_command_line: { code: 5042, category: ts.DiagnosticCategory.Error, key: "Option 'project' cannot be mixed with source files on a command line." }, - Option_isolatedModules_can_only_be_used_when_either_option_module_is_provided_or_option_target_is_ES2015_or_higher: { code: 5047, category: ts.DiagnosticCategory.Error, key: "Option 'isolatedModules' can only be used when either option '--module' is provided or option 'target' is 'ES2015' or higher." }, - Option_inlineSources_can_only_be_used_when_either_option_inlineSourceMap_or_option_sourceMap_is_provided: { code: 5051, category: ts.DiagnosticCategory.Error, key: "Option 'inlineSources' can only be used when either option '--inlineSourceMap' or option '--sourceMap' is provided." }, - Option_0_cannot_be_specified_without_specifying_option_1: { code: 5052, category: ts.DiagnosticCategory.Error, key: "Option '{0}' cannot be specified without specifying option '{1}'." }, - Option_0_cannot_be_specified_with_option_1: { code: 5053, category: ts.DiagnosticCategory.Error, key: "Option '{0}' cannot be specified with option '{1}'." }, - A_tsconfig_json_file_is_already_defined_at_Colon_0: { code: 5054, category: ts.DiagnosticCategory.Error, key: "A 'tsconfig.json' file is already defined at: '{0}'." }, - Concatenate_and_emit_output_to_single_file: { code: 6001, category: ts.DiagnosticCategory.Message, key: "Concatenate and emit output to single file." }, - Generates_corresponding_d_ts_file: { code: 6002, category: ts.DiagnosticCategory.Message, key: "Generates corresponding '.d.ts' file." }, - Specifies_the_location_where_debugger_should_locate_map_files_instead_of_generated_locations: { code: 6003, category: ts.DiagnosticCategory.Message, key: "Specifies the location where debugger should locate map files instead of generated locations." }, - Specifies_the_location_where_debugger_should_locate_TypeScript_files_instead_of_source_locations: { code: 6004, category: ts.DiagnosticCategory.Message, key: "Specifies the location where debugger should locate TypeScript files instead of source locations." }, - Watch_input_files: { code: 6005, category: ts.DiagnosticCategory.Message, key: "Watch input files." }, - Redirect_output_structure_to_the_directory: { code: 6006, category: ts.DiagnosticCategory.Message, key: "Redirect output structure to the directory." }, - Do_not_erase_const_enum_declarations_in_generated_code: { code: 6007, category: ts.DiagnosticCategory.Message, key: "Do not erase const enum declarations in generated code." }, - Do_not_emit_outputs_if_any_errors_were_reported: { code: 6008, category: ts.DiagnosticCategory.Message, key: "Do not emit outputs if any errors were reported." }, - Do_not_emit_comments_to_output: { code: 6009, category: ts.DiagnosticCategory.Message, key: "Do not emit comments to output." }, - Do_not_emit_outputs: { code: 6010, category: ts.DiagnosticCategory.Message, key: "Do not emit outputs." }, - Specify_ECMAScript_target_version_Colon_ES3_default_ES5_or_ES2015_experimental: { code: 6015, category: ts.DiagnosticCategory.Message, key: "Specify ECMAScript target version: 'ES3' (default), 'ES5', or 'ES2015' (experimental)" }, - Specify_module_code_generation_Colon_commonjs_amd_system_umd_or_es2015: { code: 6016, category: ts.DiagnosticCategory.Message, key: "Specify module code generation: 'commonjs', 'amd', 'system', 'umd' or 'es2015'" }, - Print_this_message: { code: 6017, category: ts.DiagnosticCategory.Message, key: "Print this message." }, - Print_the_compiler_s_version: { code: 6019, category: ts.DiagnosticCategory.Message, key: "Print the compiler's version." }, - Compile_the_project_in_the_given_directory: { code: 6020, category: ts.DiagnosticCategory.Message, key: "Compile the project in the given directory." }, - Syntax_Colon_0: { code: 6023, category: ts.DiagnosticCategory.Message, key: "Syntax: {0}" }, - options: { code: 6024, category: ts.DiagnosticCategory.Message, key: "options" }, - file: { code: 6025, category: ts.DiagnosticCategory.Message, key: "file" }, - Examples_Colon_0: { code: 6026, category: ts.DiagnosticCategory.Message, key: "Examples: {0}" }, - Options_Colon: { code: 6027, category: ts.DiagnosticCategory.Message, key: "Options:" }, - Version_0: { code: 6029, category: ts.DiagnosticCategory.Message, key: "Version {0}" }, - Insert_command_line_options_and_files_from_a_file: { code: 6030, category: ts.DiagnosticCategory.Message, key: "Insert command line options and files from a file." }, - File_change_detected_Starting_incremental_compilation: { code: 6032, category: ts.DiagnosticCategory.Message, key: "File change detected. Starting incremental compilation..." }, - KIND: { code: 6034, category: ts.DiagnosticCategory.Message, key: "KIND" }, - FILE: { code: 6035, category: ts.DiagnosticCategory.Message, key: "FILE" }, - VERSION: { code: 6036, category: ts.DiagnosticCategory.Message, key: "VERSION" }, - LOCATION: { code: 6037, category: ts.DiagnosticCategory.Message, key: "LOCATION" }, - DIRECTORY: { code: 6038, category: ts.DiagnosticCategory.Message, key: "DIRECTORY" }, - Compilation_complete_Watching_for_file_changes: { code: 6042, category: ts.DiagnosticCategory.Message, key: "Compilation complete. Watching for file changes." }, - Generates_corresponding_map_file: { code: 6043, category: ts.DiagnosticCategory.Message, key: "Generates corresponding '.map' file." }, - Compiler_option_0_expects_an_argument: { code: 6044, category: ts.DiagnosticCategory.Error, key: "Compiler option '{0}' expects an argument." }, - Unterminated_quoted_string_in_response_file_0: { code: 6045, category: ts.DiagnosticCategory.Error, key: "Unterminated quoted string in response file '{0}'." }, - Argument_for_module_option_must_be_commonjs_amd_system_umd_or_es2015: { code: 6046, category: ts.DiagnosticCategory.Error, key: "Argument for '--module' option must be 'commonjs', 'amd', 'system', 'umd', or 'es2015'." }, - Argument_for_target_option_must_be_ES3_ES5_or_ES2015: { code: 6047, category: ts.DiagnosticCategory.Error, key: "Argument for '--target' option must be 'ES3', 'ES5', or 'ES2015'." }, - Locale_must_be_of_the_form_language_or_language_territory_For_example_0_or_1: { code: 6048, category: ts.DiagnosticCategory.Error, key: "Locale must be of the form or -. For example '{0}' or '{1}'." }, - Unsupported_locale_0: { code: 6049, category: ts.DiagnosticCategory.Error, key: "Unsupported locale '{0}'." }, - Unable_to_open_file_0: { code: 6050, category: ts.DiagnosticCategory.Error, key: "Unable to open file '{0}'." }, - Corrupted_locale_file_0: { code: 6051, category: ts.DiagnosticCategory.Error, key: "Corrupted locale file {0}." }, - Raise_error_on_expressions_and_declarations_with_an_implied_any_type: { code: 6052, category: ts.DiagnosticCategory.Message, key: "Raise error on expressions and declarations with an implied 'any' type." }, - File_0_not_found: { code: 6053, category: ts.DiagnosticCategory.Error, key: "File '{0}' not found." }, - File_0_has_unsupported_extension_The_only_supported_extensions_are_1: { code: 6054, category: ts.DiagnosticCategory.Error, key: "File '{0}' has unsupported extension. The only supported extensions are {1}." }, - Suppress_noImplicitAny_errors_for_indexing_objects_lacking_index_signatures: { code: 6055, category: ts.DiagnosticCategory.Message, key: "Suppress noImplicitAny errors for indexing objects lacking index signatures." }, - Do_not_emit_declarations_for_code_that_has_an_internal_annotation: { code: 6056, category: ts.DiagnosticCategory.Message, key: "Do not emit declarations for code that has an '@internal' annotation." }, - Specifies_the_root_directory_of_input_files_Use_to_control_the_output_directory_structure_with_outDir: { code: 6058, category: ts.DiagnosticCategory.Message, key: "Specifies the root directory of input files. Use to control the output directory structure with --outDir." }, - File_0_is_not_under_rootDir_1_rootDir_is_expected_to_contain_all_source_files: { code: 6059, category: ts.DiagnosticCategory.Error, key: "File '{0}' is not under 'rootDir' '{1}'. 'rootDir' is expected to contain all source files." }, - Specifies_the_end_of_line_sequence_to_be_used_when_emitting_files_Colon_CRLF_dos_or_LF_unix: { code: 6060, category: ts.DiagnosticCategory.Message, key: "Specifies the end of line sequence to be used when emitting files: 'CRLF' (dos) or 'LF' (unix)." }, - NEWLINE: { code: 6061, category: ts.DiagnosticCategory.Message, key: "NEWLINE" }, - Argument_for_newLine_option_must_be_CRLF_or_LF: { code: 6062, category: ts.DiagnosticCategory.Error, key: "Argument for '--newLine' option must be 'CRLF' or 'LF'." }, - Argument_for_moduleResolution_option_must_be_node_or_classic: { code: 6063, category: ts.DiagnosticCategory.Error, key: "Argument for '--moduleResolution' option must be 'node' or 'classic'." }, - Specify_JSX_code_generation_Colon_preserve_or_react: { code: 6080, category: ts.DiagnosticCategory.Message, key: "Specify JSX code generation: 'preserve' or 'react'" }, - Argument_for_jsx_must_be_preserve_or_react: { code: 6081, category: ts.DiagnosticCategory.Message, key: "Argument for '--jsx' must be 'preserve' or 'react'." }, - Enables_experimental_support_for_ES7_decorators: { code: 6065, category: ts.DiagnosticCategory.Message, key: "Enables experimental support for ES7 decorators." }, - Enables_experimental_support_for_emitting_type_metadata_for_decorators: { code: 6066, category: ts.DiagnosticCategory.Message, key: "Enables experimental support for emitting type metadata for decorators." }, - Enables_experimental_support_for_ES7_async_functions: { code: 6068, category: ts.DiagnosticCategory.Message, key: "Enables experimental support for ES7 async functions." }, - Specifies_module_resolution_strategy_Colon_node_Node_js_or_classic_TypeScript_pre_1_6: { code: 6069, category: ts.DiagnosticCategory.Message, key: "Specifies module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6)." }, - Initializes_a_TypeScript_project_and_creates_a_tsconfig_json_file: { code: 6070, category: ts.DiagnosticCategory.Message, key: "Initializes a TypeScript project and creates a tsconfig.json file." }, - Successfully_created_a_tsconfig_json_file: { code: 6071, category: ts.DiagnosticCategory.Message, key: "Successfully created a tsconfig.json file." }, - Suppress_excess_property_checks_for_object_literals: { code: 6072, category: ts.DiagnosticCategory.Message, key: "Suppress excess property checks for object literals." }, - Variable_0_implicitly_has_an_1_type: { code: 7005, category: ts.DiagnosticCategory.Error, key: "Variable '{0}' implicitly has an '{1}' type." }, - Parameter_0_implicitly_has_an_1_type: { code: 7006, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' implicitly has an '{1}' type." }, - Member_0_implicitly_has_an_1_type: { code: 7008, category: ts.DiagnosticCategory.Error, key: "Member '{0}' implicitly has an '{1}' type." }, - new_expression_whose_target_lacks_a_construct_signature_implicitly_has_an_any_type: { code: 7009, category: ts.DiagnosticCategory.Error, key: "'new' expression, whose target lacks a construct signature, implicitly has an 'any' type." }, - _0_which_lacks_return_type_annotation_implicitly_has_an_1_return_type: { code: 7010, category: ts.DiagnosticCategory.Error, key: "'{0}', which lacks return-type annotation, implicitly has an '{1}' return type." }, - Function_expression_which_lacks_return_type_annotation_implicitly_has_an_0_return_type: { code: 7011, category: ts.DiagnosticCategory.Error, key: "Function expression, which lacks return-type annotation, implicitly has an '{0}' return type." }, - Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type: { code: 7013, category: ts.DiagnosticCategory.Error, key: "Construct signature, which lacks return-type annotation, implicitly has an 'any' return type." }, - Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_type_annotation: { code: 7016, category: ts.DiagnosticCategory.Error, key: "Property '{0}' implicitly has type 'any', because its 'set' accessor lacks a type annotation." }, - Index_signature_of_object_type_implicitly_has_an_any_type: { code: 7017, category: ts.DiagnosticCategory.Error, key: "Index signature of object type implicitly has an 'any' type." }, - Object_literal_s_property_0_implicitly_has_an_1_type: { code: 7018, category: ts.DiagnosticCategory.Error, key: "Object literal's property '{0}' implicitly has an '{1}' type." }, - Rest_parameter_0_implicitly_has_an_any_type: { code: 7019, category: ts.DiagnosticCategory.Error, key: "Rest parameter '{0}' implicitly has an 'any[]' type." }, - Call_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type: { code: 7020, category: ts.DiagnosticCategory.Error, key: "Call signature, which lacks return-type annotation, implicitly has an 'any' return type." }, - _0_implicitly_has_type_any_because_it_does_not_have_a_type_annotation_and_is_referenced_directly_or_indirectly_in_its_own_initializer: { code: 7022, category: ts.DiagnosticCategory.Error, key: "'{0}' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer." }, - _0_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions: { code: 7023, category: ts.DiagnosticCategory.Error, key: "'{0}' implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions." }, - Function_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions: { code: 7024, category: ts.DiagnosticCategory.Error, key: "Function implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions." }, - Generator_implicitly_has_type_0_because_it_does_not_yield_any_values_Consider_supplying_a_return_type: { code: 7025, category: ts.DiagnosticCategory.Error, key: "Generator implicitly has type '{0}' because it does not yield any values. Consider supplying a return type." }, - JSX_element_implicitly_has_type_any_because_no_interface_JSX_0_exists: { code: 7026, category: ts.DiagnosticCategory.Error, key: "JSX element implicitly has type 'any' because no interface 'JSX.{0}' exists" }, - You_cannot_rename_this_element: { code: 8000, category: ts.DiagnosticCategory.Error, key: "You cannot rename this element." }, - You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library: { code: 8001, category: ts.DiagnosticCategory.Error, key: "You cannot rename elements that are defined in the standard TypeScript library." }, - 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." }, - export_can_only_be_used_in_a_ts_file: { code: 8003, category: ts.DiagnosticCategory.Error, key: "'export=' can only be used in a .ts file." }, - type_parameter_declarations_can_only_be_used_in_a_ts_file: { code: 8004, category: ts.DiagnosticCategory.Error, key: "'type parameter declarations' can only be used in a .ts file." }, - implements_clauses_can_only_be_used_in_a_ts_file: { code: 8005, category: ts.DiagnosticCategory.Error, key: "'implements clauses' can only be used in a .ts file." }, - interface_declarations_can_only_be_used_in_a_ts_file: { code: 8006, category: ts.DiagnosticCategory.Error, key: "'interface declarations' can only be used in a .ts file." }, - module_declarations_can_only_be_used_in_a_ts_file: { code: 8007, category: ts.DiagnosticCategory.Error, key: "'module declarations' can only be used in a .ts file." }, - type_aliases_can_only_be_used_in_a_ts_file: { code: 8008, category: ts.DiagnosticCategory.Error, key: "'type aliases' can only be used in a .ts file." }, - _0_can_only_be_used_in_a_ts_file: { code: 8009, category: ts.DiagnosticCategory.Error, key: "'{0}' can only be used in a .ts file." }, - types_can_only_be_used_in_a_ts_file: { code: 8010, category: ts.DiagnosticCategory.Error, key: "'types' can only be used in a .ts file." }, - type_arguments_can_only_be_used_in_a_ts_file: { code: 8011, category: ts.DiagnosticCategory.Error, key: "'type arguments' can only be used in a .ts file." }, - parameter_modifiers_can_only_be_used_in_a_ts_file: { code: 8012, category: ts.DiagnosticCategory.Error, key: "'parameter modifiers' can only be used in a .ts file." }, - property_declarations_can_only_be_used_in_a_ts_file: { code: 8014, category: ts.DiagnosticCategory.Error, key: "'property declarations' can only be used in a .ts file." }, - enum_declarations_can_only_be_used_in_a_ts_file: { code: 8015, category: ts.DiagnosticCategory.Error, key: "'enum declarations' can only be used in a .ts file." }, - type_assertion_expressions_can_only_be_used_in_a_ts_file: { code: 8016, category: ts.DiagnosticCategory.Error, key: "'type assertion expressions' can only be used in a .ts file." }, - decorators_can_only_be_used_in_a_ts_file: { code: 8017, category: ts.DiagnosticCategory.Error, key: "'decorators' can only be used in a .ts file." }, - Only_identifiers_Slashqualified_names_with_optional_type_arguments_are_currently_supported_in_a_class_extends_clauses: { code: 9002, category: ts.DiagnosticCategory.Error, key: "Only identifiers/qualified-names with optional type arguments are currently supported in a class 'extends' clauses." }, - class_expressions_are_not_currently_supported: { code: 9003, category: ts.DiagnosticCategory.Error, key: "'class' expressions are not currently supported." }, - JSX_attributes_must_only_be_assigned_a_non_empty_expression: { code: 17000, category: ts.DiagnosticCategory.Error, key: "JSX attributes must only be assigned a non-empty 'expression'." }, - JSX_elements_cannot_have_multiple_attributes_with_the_same_name: { code: 17001, category: ts.DiagnosticCategory.Error, key: "JSX elements cannot have multiple attributes with the same name." }, - Expected_corresponding_JSX_closing_tag_for_0: { code: 17002, category: ts.DiagnosticCategory.Error, key: "Expected corresponding JSX closing tag for '{0}'." }, - JSX_attribute_expected: { code: 17003, category: ts.DiagnosticCategory.Error, key: "JSX attribute expected." }, - Cannot_use_JSX_unless_the_jsx_flag_is_provided: { code: 17004, category: ts.DiagnosticCategory.Error, key: "Cannot use JSX unless the '--jsx' flag is provided." }, - A_constructor_cannot_contain_a_super_call_when_its_class_extends_null: { code: 17005, category: ts.DiagnosticCategory.Error, key: "A constructor cannot contain a 'super' call when its class extends 'null'" }, - An_unary_expression_with_the_0_operator_is_not_allowed_in_the_left_hand_side_of_an_exponentiation_expression_Consider_enclosing_the_expression_in_parentheses: { code: 17006, category: ts.DiagnosticCategory.Error, key: "An unary expression with the '{0}' operator is not allowed in the left-hand side of an exponentiation expression. Consider enclosing the expression in parentheses." }, - A_type_assertion_expression_is_not_allowed_in_the_left_hand_side_of_an_exponentiation_expression_Consider_enclosing_the_expression_in_parentheses: { code: 17007, category: ts.DiagnosticCategory.Error, key: "A type assertion expression is not allowed in the left-hand side of an exponentiation expression. Consider enclosing the expression in parentheses." } - }; -})(ts || (ts = {})); -/// -/// -var ts; -(function (ts) { - /* @internal */ - function tokenIsIdentifierOrKeyword(token) { - return token >= 69 /* Identifier */; - } - ts.tokenIsIdentifierOrKeyword = tokenIsIdentifierOrKeyword; - var textToToken = { - "abstract": 115 /* AbstractKeyword */, - "any": 117 /* AnyKeyword */, - "as": 116 /* AsKeyword */, - "boolean": 120 /* BooleanKeyword */, - "break": 70 /* BreakKeyword */, - "case": 71 /* CaseKeyword */, - "catch": 72 /* CatchKeyword */, - "class": 73 /* ClassKeyword */, - "continue": 75 /* ContinueKeyword */, - "const": 74 /* ConstKeyword */, - "constructor": 121 /* ConstructorKeyword */, - "debugger": 76 /* DebuggerKeyword */, - "declare": 122 /* DeclareKeyword */, - "default": 77 /* DefaultKeyword */, - "delete": 78 /* DeleteKeyword */, - "do": 79 /* DoKeyword */, - "else": 80 /* ElseKeyword */, - "enum": 81 /* EnumKeyword */, - "export": 82 /* ExportKeyword */, - "extends": 83 /* ExtendsKeyword */, - "false": 84 /* FalseKeyword */, - "finally": 85 /* FinallyKeyword */, - "for": 86 /* ForKeyword */, - "from": 133 /* FromKeyword */, - "function": 87 /* FunctionKeyword */, - "get": 123 /* GetKeyword */, - "if": 88 /* IfKeyword */, - "implements": 106 /* ImplementsKeyword */, - "import": 89 /* ImportKeyword */, - "in": 90 /* InKeyword */, - "instanceof": 91 /* InstanceOfKeyword */, - "interface": 107 /* InterfaceKeyword */, - "is": 124 /* IsKeyword */, - "let": 108 /* LetKeyword */, - "module": 125 /* ModuleKeyword */, - "namespace": 126 /* NamespaceKeyword */, - "new": 92 /* NewKeyword */, - "null": 93 /* NullKeyword */, - "number": 128 /* NumberKeyword */, - "package": 109 /* PackageKeyword */, - "private": 110 /* PrivateKeyword */, - "protected": 111 /* ProtectedKeyword */, - "public": 112 /* PublicKeyword */, - "require": 127 /* RequireKeyword */, - "return": 94 /* ReturnKeyword */, - "set": 129 /* SetKeyword */, - "static": 113 /* StaticKeyword */, - "string": 130 /* StringKeyword */, - "super": 95 /* SuperKeyword */, - "switch": 96 /* SwitchKeyword */, - "symbol": 131 /* SymbolKeyword */, - "this": 97 /* ThisKeyword */, - "throw": 98 /* ThrowKeyword */, - "true": 99 /* TrueKeyword */, - "try": 100 /* TryKeyword */, - "type": 132 /* TypeKeyword */, - "typeof": 101 /* TypeOfKeyword */, - "var": 102 /* VarKeyword */, - "void": 103 /* VoidKeyword */, - "while": 104 /* WhileKeyword */, - "with": 105 /* WithKeyword */, - "yield": 114 /* YieldKeyword */, - "async": 118 /* AsyncKeyword */, - "await": 119 /* AwaitKeyword */, - "of": 134 /* OfKeyword */, - "{": 15 /* OpenBraceToken */, - "}": 16 /* CloseBraceToken */, - "(": 17 /* OpenParenToken */, - ")": 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 */ - }; - /* - As per ECMAScript Language Specification 3th Edition, Section 7.6: Identifiers - IdentifierStart :: - Can contain Unicode 3.0.0 categories: - Uppercase letter (Lu), - Lowercase letter (Ll), - Titlecase letter (Lt), - Modifier letter (Lm), - Other letter (Lo), or - Letter number (Nl). - IdentifierPart :: = - Can contain IdentifierStart + Unicode 3.0.0 categories: - Non-spacing mark (Mn), - Combining spacing mark (Mc), - Decimal number (Nd), or - Connector punctuation (Pc). - - Codepoint ranges for ES3 Identifiers are extracted from the Unicode 3.0.0 specification at: - http://www.unicode.org/Public/3.0-Update/UnicodeData-3.0.0.txt - */ - 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,]; - /* - As per ECMAScript Language Specification 5th Edition, Section 7.6: ISyntaxToken Names and Identifiers - IdentifierStart :: - Can contain Unicode 6.2 categories: - Uppercase letter (Lu), - Lowercase letter (Ll), - Titlecase letter (Lt), - Modifier letter (Lm), - Other letter (Lo), or - Letter number (Nl). - IdentifierPart :: - Can contain IdentifierStart + Unicode 6.2 categories: - Non-spacing mark (Mn), - Combining spacing mark (Mc), - Decimal number (Nd), - Connector punctuation (Pc), - , or - . - - Codepoint ranges for ES5 Identifiers are extracted from the Unicode 6.2 specification at: - http://www.unicode.org/Public/6.2.0/ucd/UnicodeData.txt - */ - 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) { - // Bail out quickly if it couldn't possibly be in the map. - if (code < map[0]) { - return false; - } - // Perform binary search in one of the Unicode range maps - var lo = 0; - var hi = map.length; - var mid; - while (lo + 1 < hi) { - mid = lo + (hi - lo) / 2; - // mid has to be even to catch a range's beginning - 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; - } - /* @internal */ function isUnicodeIdentifierStart(code, languageVersion) { - return languageVersion >= 1 /* ES5 */ ? - lookupInUnicodeMap(code, unicodeES5IdentifierStart) : - lookupInUnicodeMap(code, unicodeES3IdentifierStart); - } - ts.isUnicodeIdentifierStart = isUnicodeIdentifierStart; - function isUnicodeIdentifierPart(code, languageVersion) { - return languageVersion >= 1 /* ES5 */ ? - lookupInUnicodeMap(code, unicodeES5IdentifierPart) : - lookupInUnicodeMap(code, unicodeES3IdentifierPart); - } - function makeReverseMap(source) { - var result = []; - for (var name_4 in source) { - if (source.hasOwnProperty(name_4)) { - result[source[name_4]] = name_4; - } - } - return result; - } - var tokenStrings = makeReverseMap(textToToken); - function tokenToString(t) { - return tokenStrings[t]; - } - ts.tokenToString = tokenToString; - /* @internal */ - function stringToToken(s) { - return textToToken[s]; - } - ts.stringToToken = stringToToken; - /* @internal */ - function computeLineStarts(text) { - var result = new Array(); - var pos = 0; - var lineStart = 0; - while (pos < text.length) { - var ch = text.charCodeAt(pos++); - switch (ch) { - case 13 /* carriageReturn */: - if (text.charCodeAt(pos) === 10 /* lineFeed */) { - pos++; - } - case 10 /* lineFeed */: - result.push(lineStart); - lineStart = pos; - break; - default: - if (ch > 127 /* maxAsciiCharacter */ && 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; - /* @internal */ - function computePositionOfLineAndCharacter(lineStarts, line, character) { - ts.Debug.assert(line >= 0 && line < lineStarts.length); - return lineStarts[line] + character; - } - ts.computePositionOfLineAndCharacter = computePositionOfLineAndCharacter; - /* @internal */ - function getLineStarts(sourceFile) { - return sourceFile.lineMap || (sourceFile.lineMap = computeLineStarts(sourceFile.text)); - } - ts.getLineStarts = getLineStarts; - /* @internal */ - /** - * We assume the first line starts at position 0 and 'position' is non-negative. - */ - function computeLineAndCharacterOfPosition(lineStarts, position) { - var lineNumber = ts.binarySearch(lineStarts, position); - if (lineNumber < 0) { - // If the actual position was not found, - // the binary search returns the 2's-complement of the next line start - // e.g. if the line starts at [5, 10, 23, 80] and the position requested was 20 - // then the search will return -2. - // - // We want the index of the previous line start, so we subtract 1. - // Review 2's-complement if this is confusing. - 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) { - // Note: nextLine is in the Zs space, and should be considered to be a whitespace. - // It is explicitly not a line-break as it isn't in the exact set specified by EcmaScript. - return ch === 32 /* space */ || - ch === 9 /* tab */ || - ch === 11 /* verticalTab */ || - ch === 12 /* formFeed */ || - ch === 160 /* nonBreakingSpace */ || - ch === 133 /* nextLine */ || - ch === 5760 /* ogham */ || - ch >= 8192 /* enQuad */ && ch <= 8203 /* zeroWidthSpace */ || - ch === 8239 /* narrowNoBreakSpace */ || - ch === 8287 /* mathematicalSpace */ || - ch === 12288 /* ideographicSpace */ || - ch === 65279 /* byteOrderMark */; - } - ts.isWhiteSpace = isWhiteSpace; - function isLineBreak(ch) { - // ES5 7.3: - // The ECMAScript line terminator characters are listed in Table 3. - // Table 3: Line Terminator Characters - // Code Unit Value Name Formal Name - // \u000A Line Feed - // \u000D Carriage Return - // \u2028 Line separator - // \u2029 Paragraph separator - // Only the characters in Table 3 are treated as line terminators. Other new line or line - // breaking characters are treated as white space but not as line terminators. - return ch === 10 /* lineFeed */ || - ch === 13 /* carriageReturn */ || - ch === 8232 /* lineSeparator */ || - ch === 8233 /* paragraphSeparator */; - } - ts.isLineBreak = isLineBreak; - function isDigit(ch) { - return ch >= 48 /* _0 */ && ch <= 57 /* _9 */; - } - /* @internal */ - function isOctalDigit(ch) { - return ch >= 48 /* _0 */ && ch <= 55 /* _7 */; - } - ts.isOctalDigit = isOctalDigit; - function couldStartTrivia(text, pos) { - // Keep in sync with skipTrivia - var ch = text.charCodeAt(pos); - switch (ch) { - case 13 /* carriageReturn */: - case 10 /* lineFeed */: - case 9 /* tab */: - case 11 /* verticalTab */: - case 12 /* formFeed */: - case 32 /* space */: - case 47 /* slash */: - // starts of normal trivia - case 60 /* lessThan */: - case 61 /* equals */: - case 62 /* greaterThan */: - // Starts of conflict marker trivia - return true; - case 35 /* hash */: - // Only if its the beginning can we have #! trivia - return pos === 0; - default: - return ch > 127 /* maxAsciiCharacter */; - } - } - ts.couldStartTrivia = couldStartTrivia; - /* @internal */ - function skipTrivia(text, pos, stopAfterLineBreak) { - // Keep in sync with couldStartTrivia - while (true) { - var ch = text.charCodeAt(pos); - switch (ch) { - case 13 /* carriageReturn */: - if (text.charCodeAt(pos + 1) === 10 /* lineFeed */) { - pos++; - } - case 10 /* lineFeed */: - pos++; - if (stopAfterLineBreak) { - return pos; - } - continue; - case 9 /* tab */: - case 11 /* verticalTab */: - case 12 /* formFeed */: - case 32 /* space */: - pos++; - continue; - case 47 /* slash */: - if (text.charCodeAt(pos + 1) === 47 /* slash */) { - pos += 2; - while (pos < text.length) { - if (isLineBreak(text.charCodeAt(pos))) { - break; - } - pos++; - } - continue; - } - if (text.charCodeAt(pos + 1) === 42 /* asterisk */) { - pos += 2; - while (pos < text.length) { - if (text.charCodeAt(pos) === 42 /* asterisk */ && text.charCodeAt(pos + 1) === 47 /* slash */) { - pos += 2; - break; - } - pos++; - } - continue; - } - break; - case 60 /* lessThan */: - case 61 /* equals */: - case 62 /* greaterThan */: - if (isConflictMarkerTrivia(text, pos)) { - pos = scanConflictMarkerTrivia(text, pos); - continue; - } - break; - case 35 /* hash */: - if (pos === 0 && isShebangTrivia(text, pos)) { - pos = scanShebangTrivia(text, pos); - continue; - } - break; - default: - if (ch > 127 /* maxAsciiCharacter */ && (isWhiteSpace(ch) || isLineBreak(ch))) { - pos++; - continue; - } - break; - } - return pos; - } - } - ts.skipTrivia = skipTrivia; - // All conflict markers consist of the same character repeated seven times. If it is - // a <<<<<<< or >>>>>>> marker then it is also followd by a space. - var mergeConflictMarkerLength = "<<<<<<<".length; - function isConflictMarkerTrivia(text, pos) { - ts.Debug.assert(pos >= 0); - // Conflict markers must be at the start of a line. - 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 /* equals */ || - text.charCodeAt(pos + mergeConflictMarkerLength) === 32 /* space */; - } - } - 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 /* lessThan */ || ch === 62 /* greaterThan */) { - while (pos < len && !isLineBreak(text.charCodeAt(pos))) { - pos++; - } - } - else { - ts.Debug.assert(ch === 61 /* equals */); - // Consume everything from the start of the mid-conlict marker to the start of the next - // end-conflict marker. - while (pos < len) { - var ch_1 = text.charCodeAt(pos); - if (ch_1 === 62 /* greaterThan */ && isConflictMarkerTrivia(text, pos)) { - break; - } - pos++; - } - } - return pos; - } - var shebangTriviaRegex = /^#!.*/; - function isShebangTrivia(text, pos) { - // Shebangs check must only be done at the start of the file - 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; - } - /** - * Extract comments from text prefixing the token closest following `pos`. - * The return value is an array containing a TextRange for each comment. - * Single-line comment ranges include the beginning '//' characters but not the ending line break. - * Multi - line comment ranges include the beginning '/* and ending '/' characters. - * The return value is undefined if no comments were found. - * @param trailing - * If false, whitespace is skipped until the first line break and comments between that location - * and the next token are returned. - * If true, comments occurring between the given position and the next line break are returned. - */ - function getCommentRanges(text, pos, trailing) { - var result; - var collecting = trailing || pos === 0; - while (true) { - var ch = text.charCodeAt(pos); - switch (ch) { - case 13 /* carriageReturn */: - if (text.charCodeAt(pos + 1) === 10 /* lineFeed */) { - pos++; - } - case 10 /* lineFeed */: - pos++; - if (trailing) { - return result; - } - collecting = true; - if (result && result.length) { - ts.lastOrUndefined(result).hasTrailingNewLine = true; - } - continue; - case 9 /* tab */: - case 11 /* verticalTab */: - case 12 /* formFeed */: - case 32 /* space */: - pos++; - continue; - case 47 /* slash */: - var nextChar = text.charCodeAt(pos + 1); - var hasTrailingNewLine = false; - if (nextChar === 47 /* slash */ || nextChar === 42 /* asterisk */) { - var kind = nextChar === 47 /* slash */ ? 2 /* SingleLineCommentTrivia */ : 3 /* MultiLineCommentTrivia */; - var startPos = pos; - pos += 2; - if (nextChar === 47 /* slash */) { - while (pos < text.length) { - if (isLineBreak(text.charCodeAt(pos))) { - hasTrailingNewLine = true; - break; - } - pos++; - } - } - else { - while (pos < text.length) { - if (text.charCodeAt(pos) === 42 /* asterisk */ && text.charCodeAt(pos + 1) === 47 /* slash */) { - pos += 2; - break; - } - pos++; - } - } - if (collecting) { - if (!result) { - result = []; - } - result.push({ pos: startPos, end: pos, hasTrailingNewLine: hasTrailingNewLine, kind: kind }); - } - continue; - } - break; - default: - if (ch > 127 /* maxAsciiCharacter */ && (isWhiteSpace(ch) || isLineBreak(ch))) { - if (result && result.length && isLineBreak(ch)) { - ts.lastOrUndefined(result).hasTrailingNewLine = true; - } - pos++; - continue; - } - break; - } - return result; - } - } - function getLeadingCommentRanges(text, pos) { - return getCommentRanges(text, pos, /*trailing*/ false); - } - ts.getLeadingCommentRanges = getLeadingCommentRanges; - function getTrailingCommentRanges(text, pos) { - return getCommentRanges(text, pos, /*trailing*/ true); - } - ts.getTrailingCommentRanges = getTrailingCommentRanges; - /** Optionally, get the shebang */ - function getShebang(text) { - return shebangTriviaRegex.test(text) - ? shebangTriviaRegex.exec(text)[0] - : undefined; - } - ts.getShebang = getShebang; - function isIdentifierStart(ch, languageVersion) { - return ch >= 65 /* A */ && ch <= 90 /* Z */ || ch >= 97 /* a */ && ch <= 122 /* z */ || - ch === 36 /* $ */ || ch === 95 /* _ */ || - ch > 127 /* maxAsciiCharacter */ && isUnicodeIdentifierStart(ch, languageVersion); - } - ts.isIdentifierStart = isIdentifierStart; - function isIdentifierPart(ch, languageVersion) { - return ch >= 65 /* A */ && ch <= 90 /* Z */ || ch >= 97 /* a */ && ch <= 122 /* z */ || - ch >= 48 /* _0 */ && ch <= 57 /* _9 */ || ch === 36 /* $ */ || ch === 95 /* _ */ || - ch > 127 /* maxAsciiCharacter */ && isUnicodeIdentifierPart(ch, languageVersion); - } - ts.isIdentifierPart = isIdentifierPart; - // Creates a scanner over a (possibly unspecified) range of a piece of text. - function createScanner(languageVersion, skipTrivia, languageVariant, text, onError, start, length) { - if (languageVariant === void 0) { languageVariant = 0 /* Standard */; } - // Current position (end position of text of current token) - var pos; - // end of text - var end; - // Start position of whitespace before current token - var startPos; - // Start position of text of current token - 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 /* Identifier */ || token > 105 /* LastReservedWord */; }, - isReservedWord: function () { return token >= 70 /* FirstReservedWord */ && token <= 105 /* LastReservedWord */; }, - isUnterminated: function () { return tokenIsUnterminated; }, - reScanGreaterToken: reScanGreaterToken, - reScanSlashToken: reScanSlashToken, - reScanTemplateToken: reScanTemplateToken, - scanJsxIdentifier: scanJsxIdentifier, - reScanJsxToken: reScanJsxToken, - scanJsxToken: scanJsxToken, - scan: scan, - setText: setText, - setScriptTarget: setScriptTarget, - setLanguageVariant: setLanguageVariant, - setOnError: setOnError, - setTextPos: setTextPos, - tryScan: tryScan, - lookAhead: lookAhead - }; - 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 /* dot */) { - pos++; - while (isDigit(text.charCodeAt(pos))) - pos++; - } - var end = pos; - if (text.charCodeAt(pos) === 69 /* E */ || text.charCodeAt(pos) === 101 /* e */) { - pos++; - if (text.charCodeAt(pos) === 43 /* plus */ || text.charCodeAt(pos) === 45 /* minus */) - 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)); - } - /** - * Scans the given number of hexadecimal digits in the text, - * returning -1 if the given number is unavailable. - */ - function scanExactNumberOfHexDigits(count) { - return scanHexDigits(/*minCount*/ count, /*scanAsManyAsPossible*/ false); - } - /** - * Scans as many hexadecimal digits as are available in the text, - * returning -1 if the given number of digits was unavailable. - */ - function scanMinimumNumberOfHexDigits(count) { - return scanHexDigits(/*minCount*/ count, /*scanAsManyAsPossible*/ true); - } - function scanHexDigits(minCount, scanAsManyAsPossible) { - var digits = 0; - var value = 0; - while (digits < minCount || scanAsManyAsPossible) { - var ch = text.charCodeAt(pos); - if (ch >= 48 /* _0 */ && ch <= 57 /* _9 */) { - value = value * 16 + ch - 48 /* _0 */; - } - else if (ch >= 65 /* A */ && ch <= 70 /* F */) { - value = value * 16 + ch - 65 /* A */ + 10; - } - else if (ch >= 97 /* a */ && ch <= 102 /* f */) { - value = value * 16 + ch - 97 /* a */ + 10; - } - else { - break; - } - pos++; - digits++; - } - if (digits < minCount) { - value = -1; - } - return value; - } - function scanString() { - var quote = text.charCodeAt(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 /* backslash */) { - 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; - } - /** - * Sets the current 'tokenValue' and returns a NoSubstitutionTemplateLiteral or - * a literal component of a TemplateExpression. - */ - function scanTemplateAndSetTokenValue() { - var startedWithBacktick = text.charCodeAt(pos) === 96 /* backtick */; - 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 /* NoSubstitutionTemplateLiteral */ : 14 /* TemplateTail */; - break; - } - var currChar = text.charCodeAt(pos); - // '`' - if (currChar === 96 /* backtick */) { - contents += text.substring(start, pos); - pos++; - resultingToken = startedWithBacktick ? 11 /* NoSubstitutionTemplateLiteral */ : 14 /* 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 */; - break; - } - // Escape character - if (currChar === 92 /* backslash */) { - contents += text.substring(start, pos); - contents += scanEscapeSequence(); - start = pos; - continue; - } - // Speculated ECMAScript 6 Spec 11.8.6.1: - // and LineTerminatorSequences are normalized to for Template Values - if (currChar === 13 /* carriageReturn */) { - contents += text.substring(start, pos); - pos++; - if (pos < end && text.charCodeAt(pos) === 10 /* lineFeed */) { - 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++); - switch (ch) { - case 48 /* _0 */: - return "\0"; - case 98 /* b */: - return "\b"; - case 116 /* t */: - return "\t"; - case 110 /* n */: - return "\n"; - case 118 /* v */: - return "\v"; - case 102 /* f */: - return "\f"; - case 114 /* r */: - return "\r"; - case 39 /* singleQuote */: - return "\'"; - case 34 /* doubleQuote */: - return "\""; - case 117 /* u */: - // '\u{DDDDDDDD}' - if (pos < end && text.charCodeAt(pos) === 123 /* openBrace */) { - hasExtendedUnicodeEscape = true; - pos++; - return scanExtendedUnicodeEscape(); - } - // '\uDDDD' - return scanHexadecimalEscape(/*numDigits*/ 4); - case 120 /* x */: - // '\xDD' - return scanHexadecimalEscape(/*numDigits*/ 2); - // when encountering a LineContinuation (i.e. a backslash and a line terminator sequence), - // the line terminator is interpreted to be "the empty code unit sequence". - case 13 /* carriageReturn */: - if (pos < end && text.charCodeAt(pos) === 10 /* lineFeed */) { - pos++; - } - // fall through - case 10 /* lineFeed */: - case 8232 /* lineSeparator */: - case 8233 /* paragraphSeparator */: - 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; - // Validate the value of the digit - 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 /* closeBrace */) { - // Only swallow the following character up if it's a '}'. - pos++; - } - else { - error(ts.Diagnostics.Unterminated_Unicode_escape_sequence); - isInvalidExtendedEscape = true; - } - if (isInvalidExtendedEscape) { - return ""; - } - return utf16EncodeAsString(escapedValue); - } - // Derived from the 10.1.1 UTF16Encoding of the ES6 Spec. - 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); - } - // Current character is known to be a backslash. Check for Unicode escape of the form '\uXXXX' - // and return code point value if valid Unicode escape is found. Otherwise return -1. - function peekUnicodeEscape() { - if (pos + 5 < end && text.charCodeAt(pos + 1) === 117 /* u */) { - 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 /* backslash */) { - ch = peekUnicodeEscape(); - if (!(ch >= 0 && isIdentifierPart(ch, languageVersion))) { - break; - } - result += text.substring(start, pos); - result += String.fromCharCode(ch); - // Valid Unicode escape is always six characters - pos += 6; - start = pos; - } - else { - break; - } - } - result += text.substring(start, pos); - return result; - } - function getIdentifierToken() { - // Reserved words are between 2 and 11 characters long and start with a lowercase letter - var len = tokenValue.length; - if (len >= 2 && len <= 11) { - var ch = tokenValue.charCodeAt(0); - if (ch >= 97 /* a */ && ch <= 122 /* z */ && hasOwnProperty.call(textToToken, tokenValue)) { - return token = textToToken[tokenValue]; - } - } - return token = 69 /* Identifier */; - } - function scanBinaryOrOctalDigits(base) { - 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. - var numberOfDigits = 0; - while (true) { - var ch = text.charCodeAt(pos); - var valueOfCh = ch - 48 /* _0 */; - if (!isDigit(ch) || valueOfCh >= base) { - break; - } - value = value * base + valueOfCh; - pos++; - numberOfDigits++; - } - // Invalid binaryIntegerLiteral or octalIntegerLiteral - 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 /* EndOfFileToken */; - } - var ch = text.charCodeAt(pos); - // Special handling for shebang - if (ch === 35 /* hash */ && pos === 0 && isShebangTrivia(text, pos)) { - pos = scanShebangTrivia(text, pos); - if (skipTrivia) { - continue; - } - else { - return token = 6 /* ShebangTrivia */; - } - } - switch (ch) { - case 10 /* lineFeed */: - case 13 /* carriageReturn */: - precedingLineBreak = true; - if (skipTrivia) { - pos++; - continue; - } - else { - if (ch === 13 /* carriageReturn */ && pos + 1 < end && text.charCodeAt(pos + 1) === 10 /* lineFeed */) { - // consume both CR and LF - pos += 2; - } - else { - pos++; - } - return token = 4 /* NewLineTrivia */; - } - case 9 /* tab */: - case 11 /* verticalTab */: - case 12 /* formFeed */: - case 32 /* space */: - if (skipTrivia) { - pos++; - continue; - } - else { - while (pos < end && isWhiteSpace(text.charCodeAt(pos))) { - pos++; - } - return token = 5 /* WhitespaceTrivia */; - } - 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 += 2, token = 31 /* ExclamationEqualsToken */; - } - return pos++, token = 49 /* ExclamationToken */; - case 34 /* doubleQuote */: - case 39 /* singleQuote */: - tokenValue = scanString(); - return token = 9 /* StringLiteral */; - case 96 /* backtick */: - return token = scanTemplateAndSetTokenValue(); - case 37 /* percent */: - if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 62 /* PercentEqualsToken */; - } - return pos++, token = 40 /* PercentToken */; - case 38 /* ampersand */: - if (text.charCodeAt(pos + 1) === 38 /* ampersand */) { - return pos += 2, token = 51 /* AmpersandAmpersandToken */; - } - if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 66 /* AmpersandEqualsToken */; - } - return pos++, token = 46 /* AmpersandToken */; - case 40 /* openParen */: - return pos++, token = 17 /* OpenParenToken */; - case 41 /* closeParen */: - return pos++, token = 18 /* CloseParenToken */; - case 42 /* asterisk */: - if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 59 /* AsteriskEqualsToken */; - } - if (text.charCodeAt(pos + 1) === 42 /* asterisk */) { - if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 60 /* AsteriskAsteriskEqualsToken */; - } - return pos += 2, token = 38 /* AsteriskAsteriskToken */; - } - return pos++, token = 37 /* AsteriskToken */; - case 43 /* plus */: - if (text.charCodeAt(pos + 1) === 43 /* plus */) { - return pos += 2, token = 41 /* PlusPlusToken */; - } - if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 57 /* PlusEqualsToken */; - } - return pos++, token = 35 /* PlusToken */; - case 44 /* comma */: - return pos++, token = 24 /* CommaToken */; - case 45 /* minus */: - if (text.charCodeAt(pos + 1) === 45 /* minus */) { - return pos += 2, token = 42 /* MinusMinusToken */; - } - if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 58 /* MinusEqualsToken */; - } - return pos++, token = 36 /* 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++, token = 21 /* DotToken */; - case 47 /* slash */: - // Single-line comment - if (text.charCodeAt(pos + 1) === 47 /* slash */) { - pos += 2; - while (pos < end) { - if (isLineBreak(text.charCodeAt(pos))) { - break; - } - pos++; - } - if (skipTrivia) { - continue; - } - else { - return token = 2 /* SingleLineCommentTrivia */; - } - } - // Multi-line comment - if (text.charCodeAt(pos + 1) === 42 /* asterisk */) { - pos += 2; - var commentClosed = false; - while (pos < end) { - var ch_2 = text.charCodeAt(pos); - if (ch_2 === 42 /* asterisk */ && text.charCodeAt(pos + 1) === 47 /* slash */) { - 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 /* MultiLineCommentTrivia */; - } - } - if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 61 /* SlashEqualsToken */; - } - return pos++, token = 39 /* SlashToken */; - case 48 /* _0 */: - if (pos + 2 < end && (text.charCodeAt(pos + 1) === 88 /* X */ || text.charCodeAt(pos + 1) === 120 /* x */)) { - pos += 2; - var value = scanMinimumNumberOfHexDigits(1); - if (value < 0) { - error(ts.Diagnostics.Hexadecimal_digit_expected); - value = 0; - } - tokenValue = "" + value; - return token = 8 /* NumericLiteral */; - } - else if (pos + 2 < end && (text.charCodeAt(pos + 1) === 66 /* B */ || text.charCodeAt(pos + 1) === 98 /* b */)) { - pos += 2; - var value = scanBinaryOrOctalDigits(/* base */ 2); - if (value < 0) { - error(ts.Diagnostics.Binary_digit_expected); - value = 0; - } - tokenValue = "" + value; - return token = 8 /* NumericLiteral */; - } - else if (pos + 2 < end && (text.charCodeAt(pos + 1) === 79 /* O */ || text.charCodeAt(pos + 1) === 111 /* o */)) { - pos += 2; - var value = scanBinaryOrOctalDigits(/* base */ 8); - if (value < 0) { - error(ts.Diagnostics.Octal_digit_expected); - value = 0; - } - tokenValue = "" + value; - return token = 8 /* NumericLiteral */; - } - // Try to parse as an octal - if (pos + 1 < end && isOctalDigit(text.charCodeAt(pos + 1))) { - tokenValue = "" + scanOctalDigits(); - return token = 8 /* NumericLiteral */; - } - // This fall-through is a deviation from the EcmaScript grammar. The grammar says that a leading zero - // can only be followed by an octal digit, a dot, or the end of the number literal. However, we are being - // permissive and allowing decimal digits of the form 08* and 09* (which many browsers also do). - case 49 /* _1 */: - case 50 /* _2 */: - case 51 /* _3 */: - case 52 /* _4 */: - case 53 /* _5 */: - case 54 /* _6 */: - case 55 /* _7 */: - case 56 /* _8 */: - case 57 /* _9 */: - tokenValue = "" + scanNumber(); - return token = 8 /* NumericLiteral */; - case 58 /* colon */: - return pos++, token = 54 /* ColonToken */; - case 59 /* semicolon */: - return pos++, token = 23 /* SemicolonToken */; - case 60 /* lessThan */: - if (isConflictMarkerTrivia(text, pos)) { - pos = scanConflictMarkerTrivia(text, pos, error); - if (skipTrivia) { - continue; - } - else { - return token = 7 /* ConflictMarkerTrivia */; - } - } - if (text.charCodeAt(pos + 1) === 60 /* lessThan */) { - if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 63 /* LessThanLessThanEqualsToken */; - } - return pos += 2, token = 43 /* LessThanLessThanToken */; - } - if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 28 /* 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++, token = 25 /* LessThanToken */; - case 61 /* equals */: - if (isConflictMarkerTrivia(text, pos)) { - pos = scanConflictMarkerTrivia(text, pos, error); - if (skipTrivia) { - continue; - } - else { - return token = 7 /* ConflictMarkerTrivia */; - } - } - if (text.charCodeAt(pos + 1) === 61 /* equals */) { - if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 32 /* EqualsEqualsEqualsToken */; - } - return pos += 2, token = 30 /* EqualsEqualsToken */; - } - if (text.charCodeAt(pos + 1) === 62 /* greaterThan */) { - return pos += 2, token = 34 /* EqualsGreaterThanToken */; - } - return pos++, token = 56 /* EqualsToken */; - case 62 /* greaterThan */: - if (isConflictMarkerTrivia(text, pos)) { - pos = scanConflictMarkerTrivia(text, pos, error); - if (skipTrivia) { - continue; - } - else { - return token = 7 /* ConflictMarkerTrivia */; - } - } - return pos++, token = 27 /* GreaterThanToken */; - case 63 /* question */: - return pos++, token = 53 /* QuestionToken */; - case 91 /* openBracket */: - return pos++, token = 19 /* OpenBracketToken */; - case 93 /* closeBracket */: - return pos++, token = 20 /* CloseBracketToken */; - case 94 /* caret */: - if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 68 /* CaretEqualsToken */; - } - return pos++, token = 48 /* CaretToken */; - case 123 /* openBrace */: - return pos++, token = 15 /* OpenBraceToken */; - case 124 /* bar */: - if (text.charCodeAt(pos + 1) === 124 /* bar */) { - return pos += 2, token = 52 /* BarBarToken */; - } - if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 67 /* BarEqualsToken */; - } - return pos++, token = 47 /* BarToken */; - case 125 /* closeBrace */: - return pos++, token = 16 /* CloseBraceToken */; - case 126 /* tilde */: - return pos++, token = 50 /* TildeToken */; - case 64 /* at */: - return pos++, token = 55 /* AtToken */; - case 92 /* backslash */: - var cookedChar = peekUnicodeEscape(); - if (cookedChar >= 0 && isIdentifierStart(cookedChar, languageVersion)) { - pos += 6; - tokenValue = String.fromCharCode(cookedChar) + scanIdentifierParts(); - return token = getIdentifierToken(); - } - error(ts.Diagnostics.Invalid_character); - return pos++, token = 0 /* Unknown */; - default: - if (isIdentifierStart(ch, languageVersion)) { - pos++; - while (pos < end && isIdentifierPart(ch = text.charCodeAt(pos), languageVersion)) - pos++; - tokenValue = text.substring(tokenPos, pos); - if (ch === 92 /* backslash */) { - tokenValue += scanIdentifierParts(); - } - return token = getIdentifierToken(); - } - else if (isWhiteSpace(ch)) { - pos++; - continue; - } - else if (isLineBreak(ch)) { - precedingLineBreak = true; - pos++; - continue; - } - error(ts.Diagnostics.Invalid_character); - return pos++, token = 0 /* Unknown */; - } - } - } - function reScanGreaterToken() { - if (token === 27 /* 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 += 2, token = 45 /* GreaterThanGreaterThanGreaterThanToken */; - } - if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 64 /* GreaterThanGreaterThanEqualsToken */; - } - return pos++, token = 44 /* GreaterThanGreaterThanToken */; - } - if (text.charCodeAt(pos) === 61 /* equals */) { - return pos++, token = 29 /* GreaterThanEqualsToken */; - } - } - return token; - } - function reScanSlashToken() { - if (token === 39 /* SlashToken */ || token === 61 /* SlashEqualsToken */) { - var p = tokenPos + 1; - var inEscape = false; - var inCharacterClass = false; - while (true) { - // If we reach the end of a file, or hit a newline, then this is an unterminated - // regex. Report error and return what we have so far. - 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) { - // Parsing an escape character; - // reset the flag and just advance to the next char. - inEscape = false; - } - else if (ch === 47 /* slash */ && !inCharacterClass) { - // A slash within a character class is permissible, - // but in general it signals the end of the regexp literal. - p++; - break; - } - else if (ch === 91 /* openBracket */) { - inCharacterClass = true; - } - else if (ch === 92 /* backslash */) { - inEscape = true; - } - else if (ch === 93 /* closeBracket */) { - inCharacterClass = false; - } - p++; - } - while (p < end && isIdentifierPart(text.charCodeAt(p), languageVersion)) { - p++; - } - pos = p; - tokenValue = text.substring(tokenPos, pos); - token = 10 /* RegularExpressionLiteral */; - } - return token; - } - /** - * Unconditionally back up and scan a template expression portion. - */ - function reScanTemplateToken() { - ts.Debug.assert(token === 16 /* CloseBraceToken */, "'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 /* EndOfFileToken */; - } - var char = text.charCodeAt(pos); - if (char === 60 /* lessThan */) { - if (text.charCodeAt(pos + 1) === 47 /* slash */) { - pos += 2; - return token = 26 /* LessThanSlashToken */; - } - pos++; - return token = 25 /* LessThanToken */; - } - if (char === 123 /* openBrace */) { - pos++; - return token = 15 /* OpenBraceToken */; - } - while (pos < end) { - pos++; - char = text.charCodeAt(pos); - if ((char === 123 /* openBrace */) || (char === 60 /* lessThan */)) { - break; - } - } - return token = 236 /* JsxText */; - } - // Scans a JSX identifier; these differ from normal identifiers in that - // they allow dashes - function scanJsxIdentifier() { - if (tokenIsIdentifierOrKeyword(token)) { - var firstCharPosition = pos; - while (pos < end) { - var ch = text.charCodeAt(pos); - if (ch === 45 /* minus */ || ((firstCharPosition === pos) ? isIdentifierStart(ch, languageVersion) : isIdentifierPart(ch, languageVersion))) { - pos++; - } - else { - break; - } - } - tokenValue += text.substr(firstCharPosition, pos - firstCharPosition); - } - return token; - } - 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 our callback returned something 'falsy' or we're just looking ahead, - // then unconditionally restore us to where we were. - if (!result || isLookahead) { - pos = savePos; - startPos = saveStartPos; - tokenPos = saveTokenPos; - token = saveToken; - tokenValue = saveTokenValue; - precedingLineBreak = savePrecedingLineBreak; - } - return result; - } - function lookAhead(callback) { - return speculationHelper(callback, /*isLookahead:*/ true); - } - function tryScan(callback) { - return speculationHelper(callback, /*isLookahead:*/ false); - } - 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 /* Unknown */; - precedingLineBreak = false; - tokenValue = undefined; - hasExtendedUnicodeEscape = false; - tokenIsUnterminated = false; - } - } - ts.createScanner = createScanner; -})(ts || (ts = {})); -/// -/* @internal */ -var ts; -(function (ts) { - ts.bindTime = 0; - (function (ModuleInstanceState) { - ModuleInstanceState[ModuleInstanceState["NonInstantiated"] = 0] = "NonInstantiated"; - ModuleInstanceState[ModuleInstanceState["Instantiated"] = 1] = "Instantiated"; - ModuleInstanceState[ModuleInstanceState["ConstEnumOnly"] = 2] = "ConstEnumOnly"; - })(ts.ModuleInstanceState || (ts.ModuleInstanceState = {})); - var ModuleInstanceState = ts.ModuleInstanceState; - function getModuleInstanceState(node) { - // A module is uninstantiated if it contains only - // 1. interface declarations, type alias declarations - if (node.kind === 215 /* InterfaceDeclaration */ || node.kind === 216 /* TypeAliasDeclaration */) { - return 0 /* NonInstantiated */; - } - else if (ts.isConstEnumDeclaration(node)) { - return 2 /* ConstEnumOnly */; - } - else if ((node.kind === 222 /* ImportDeclaration */ || node.kind === 221 /* ImportEqualsDeclaration */) && !(node.flags & 1 /* Export */)) { - return 0 /* NonInstantiated */; - } - else if (node.kind === 219 /* ModuleBlock */) { - var state = 0 /* NonInstantiated */; - ts.forEachChild(node, function (n) { - switch (getModuleInstanceState(n)) { - case 0 /* NonInstantiated */: - // child is non-instantiated - continue searching - return false; - case 2 /* ConstEnumOnly */: - // child is const enum only - record state and continue searching - state = 2 /* ConstEnumOnly */; - return false; - case 1 /* Instantiated */: - // child is instantiated - record state and stop - state = 1 /* Instantiated */; - return true; - } - }); - return state; - } - else if (node.kind === 218 /* ModuleDeclaration */) { - return getModuleInstanceState(node.body); - } - else { - return 1 /* Instantiated */; - } - } - ts.getModuleInstanceState = getModuleInstanceState; - var ContainerFlags; - (function (ContainerFlags) { - // The current node is not a container, and no container manipulation should happen before - // recursing into it. - ContainerFlags[ContainerFlags["None"] = 0] = "None"; - // 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... - ContainerFlags[ContainerFlags["IsContainer"] = 1] = "IsContainer"; - // 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... - ContainerFlags[ContainerFlags["IsBlockScopedContainer"] = 2] = "IsBlockScopedContainer"; - ContainerFlags[ContainerFlags["HasLocals"] = 4] = "HasLocals"; - // If the current node is a container that also container that also contains locals. Examples: - // - // Functions, Methods, Modules, Source-files. - ContainerFlags[ContainerFlags["IsContainerWithLocals"] = 5] = "IsContainerWithLocals"; - })(ContainerFlags || (ContainerFlags = {})); - function bindSourceFile(file) { - var start = new Date().getTime(); - bindSourceFileWorker(file); - ts.bindTime += new Date().getTime() - start; - } - ts.bindSourceFile = bindSourceFile; - function bindSourceFileWorker(file) { - var parent; - var container; - var blockScopeContainer; - var lastContainer; - var seenThisKeyword; - // 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). - var inStrictMode = !!file.externalModuleIndicator; - var symbolCount = 0; - var Symbol = ts.objectAllocator.getSymbolConstructor(); - var classifiableNames = {}; - if (!file.locals) { - bind(file); - file.symbolCount = symbolCount; - file.classifiableNames = classifiableNames; - } - return; - function createSymbol(flags, name) { - symbolCount++; - return new Symbol(flags, name); - } - function addDeclarationToSymbol(symbol, node, symbolFlags) { - symbol.flags |= symbolFlags; - node.symbol = symbol; - if (!symbol.declarations) { - symbol.declarations = []; - } - symbol.declarations.push(node); - if (symbolFlags & 1952 /* HasExports */ && !symbol.exports) { - symbol.exports = {}; - } - if (symbolFlags & 6240 /* HasMembers */ && !symbol.members) { - symbol.members = {}; - } - if (symbolFlags & 107455 /* Value */ && !symbol.valueDeclaration) { - 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) { - if (node.name) { - if (node.kind === 218 /* ModuleDeclaration */ && node.name.kind === 9 /* StringLiteral */) { - return "\"" + node.name.text + "\""; - } - if (node.name.kind === 136 /* ComputedPropertyName */) { - var nameExpression = node.name.expression; - ts.Debug.assert(ts.isWellKnownSymbolSyntactically(nameExpression)); - return ts.getPropertyNameForKnownSymbolName(nameExpression.name.text); - } - return node.name.text; - } - switch (node.kind) { - case 144 /* Constructor */: - return "__constructor"; - case 152 /* FunctionType */: - case 147 /* CallSignature */: - return "__call"; - case 153 /* ConstructorType */: - case 148 /* ConstructSignature */: - return "__new"; - case 149 /* IndexSignature */: - return "__index"; - case 228 /* ExportDeclaration */: - return "__export"; - case 227 /* ExportAssignment */: - return node.isExportEquals ? "export=" : "default"; - case 213 /* FunctionDeclaration */: - case 214 /* ClassDeclaration */: - return node.flags & 1024 /* Default */ ? "default" : undefined; - } - } - function getDisplayName(node) { - return node.name ? ts.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, parent, node, includes, excludes) { - ts.Debug.assert(!ts.hasDynamicName(node)); - var isDefaultExport = node.flags & 1024 /* Default */; - // The exported symbol for an export default function/class node is always named "default" - var name = isDefaultExport && parent ? "default" : getDeclarationName(node); - var symbol; - if (name !== undefined) { - // Check and see if the symbol table already has a symbol with this name. If not, - // 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. - // - // 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 = ts.hasProperty(symbolTable, name) - ? symbolTable[name] - : (symbolTable[name] = createSymbol(0 /* None */, name)); - if (name && (includes & 788448 /* Classifiable */)) { - classifiableNames[name] = name; - } - if (symbol.flags & excludes) { - if (node.name) { - node.name.parent = node; - } - // Report errors every position with duplicate declaration - // Report errors on previous encountered declarations - var message = symbol.flags & 2 /* BlockScopedVariable */ - ? ts.Diagnostics.Cannot_redeclare_block_scoped_variable_0 - : ts.Diagnostics.Duplicate_identifier_0; - ts.forEach(symbol.declarations, function (declaration) { - if (declaration.flags & 1024 /* Default */) { - message = ts.Diagnostics.A_module_cannot_have_multiple_default_exports; - } - }); - ts.forEach(symbol.declarations, function (declaration) { - file.bindDiagnostics.push(ts.createDiagnosticForNode(declaration.name || declaration, message, getDisplayName(declaration))); - }); - file.bindDiagnostics.push(ts.createDiagnosticForNode(node.name || node, message, getDisplayName(node))); - symbol = createSymbol(0 /* None */, name); - } - } - else { - symbol = createSymbol(0 /* None */, "__missing"); - } - addDeclarationToSymbol(symbol, node, includes); - symbol.parent = parent; - return symbol; - } - function declareModuleMember(node, symbolFlags, symbolExcludes) { - var hasExportModifier = ts.getCombinedNodeFlags(node) & 1 /* Export */; - if (symbolFlags & 8388608 /* Alias */) { - if (node.kind === 230 /* ExportSpecifier */ || (node.kind === 221 /* 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. - if (hasExportModifier || container.flags & 262144 /* ExportContext */) { - var exportKind = (symbolFlags & 107455 /* Value */ ? 1048576 /* ExportValue */ : 0) | - (symbolFlags & 793056 /* Type */ ? 2097152 /* ExportType */ : 0) | - (symbolFlags & 1536 /* Namespace */ ? 4194304 /* ExportNamespace */ : 0); - var 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 bindChildren(node) { - // Before we recurse into a node's chilren, we first save the existing parent, container - // and block-container. Then after we pop out of processing the children, we restore - // these saved values. - var saveParent = parent; - var saveContainer = container; - var savedBlockScopeContainer = blockScopeContainer; - // This node will now be set as the parent of all of its children as we recurse into them. - parent = node; - // 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 accidently move any stale data forward from - // a previous compilation. - var containerFlags = getContainerFlags(node); - if (containerFlags & 1 /* IsContainer */) { - container = blockScopeContainer = node; - if (containerFlags & 4 /* HasLocals */) { - container.locals = {}; - } - addToContainerChain(container); - } - else if (containerFlags & 2 /* IsBlockScopedContainer */) { - blockScopeContainer = node; - blockScopeContainer.locals = undefined; - } - if (node.kind === 215 /* InterfaceDeclaration */) { - seenThisKeyword = false; - ts.forEachChild(node, bind); - node.flags = seenThisKeyword ? node.flags | 524288 /* ContainsThis */ : node.flags & ~524288 /* ContainsThis */; - } - else { - ts.forEachChild(node, bind); - } - container = saveContainer; - parent = saveParent; - blockScopeContainer = savedBlockScopeContainer; - } - function getContainerFlags(node) { - switch (node.kind) { - case 186 /* ClassExpression */: - case 214 /* ClassDeclaration */: - case 215 /* InterfaceDeclaration */: - case 217 /* EnumDeclaration */: - case 155 /* TypeLiteral */: - case 165 /* ObjectLiteralExpression */: - return 1 /* IsContainer */; - case 147 /* CallSignature */: - case 148 /* ConstructSignature */: - case 149 /* IndexSignature */: - case 143 /* MethodDeclaration */: - case 142 /* MethodSignature */: - case 213 /* FunctionDeclaration */: - case 144 /* Constructor */: - case 145 /* GetAccessor */: - case 146 /* SetAccessor */: - case 152 /* FunctionType */: - case 153 /* ConstructorType */: - case 173 /* FunctionExpression */: - case 174 /* ArrowFunction */: - case 218 /* ModuleDeclaration */: - case 248 /* SourceFile */: - case 216 /* TypeAliasDeclaration */: - return 5 /* IsContainerWithLocals */; - case 244 /* CatchClause */: - case 199 /* ForStatement */: - case 200 /* ForInStatement */: - case 201 /* ForOfStatement */: - case 220 /* CaseBlock */: - return 2 /* IsBlockScopedContainer */; - case 192 /* Block */: - // do not treat blocks directly inside a function as a block-scoped-container. - // Locals that reside in this block should go to the function locals. Othewise 'x' - // would not appear to be a redeclaration of a block scoped local in the following - // 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 ts.isFunctionLike(node.parent) ? 0 /* None */ : 2 /* IsBlockScopedContainer */; - } - return 0 /* None */; - } - function addToContainerChain(next) { - if (lastContainer) { - lastContainer.nextContainer = next; - } - lastContainer = next; - } - function declareSymbolAndAddToSymbolTable(node, symbolFlags, symbolExcludes) { - // Just call this directly so that the return type of this function stays "void". - declareSymbolAndAddToSymbolTableWorker(node, symbolFlags, symbolExcludes); - } - function declareSymbolAndAddToSymbolTableWorker(node, symbolFlags, symbolExcludes) { - 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 218 /* ModuleDeclaration */: - return declareModuleMember(node, symbolFlags, symbolExcludes); - case 248 /* SourceFile */: - return declareSourceFileMember(node, symbolFlags, symbolExcludes); - case 186 /* ClassExpression */: - case 214 /* ClassDeclaration */: - return declareClassMember(node, symbolFlags, symbolExcludes); - case 217 /* EnumDeclaration */: - return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); - case 155 /* TypeLiteral */: - case 165 /* ObjectLiteralExpression */: - case 215 /* InterfaceDeclaration */: - // Interface/Object-types always have their children added to the 'members' of - // their container. They are only accessible through an instance of their - // container, and are never in scope otherwise (even inside the body of the - // object / type / interface declaring them). An exception is type parameters, - // which are in scope without qualification (similar to 'locals'). - return declareSymbol(container.symbol.members, container.symbol, node, symbolFlags, symbolExcludes); - case 152 /* FunctionType */: - case 153 /* ConstructorType */: - case 147 /* CallSignature */: - case 148 /* ConstructSignature */: - case 149 /* IndexSignature */: - case 143 /* MethodDeclaration */: - case 142 /* MethodSignature */: - case 144 /* Constructor */: - case 145 /* GetAccessor */: - case 146 /* SetAccessor */: - case 213 /* FunctionDeclaration */: - case 173 /* FunctionExpression */: - case 174 /* ArrowFunction */: - case 216 /* TypeAliasDeclaration */: - // All the children of these container types are never visible through another - // symbol (i.e. through another symbol's 'exports' or 'members'). Instead, - // they're only accessed 'lexically' (i.e. from code that exists underneath - // 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, undefined, node, symbolFlags, symbolExcludes); - } - } - function declareClassMember(node, symbolFlags, symbolExcludes) { - return node.flags & 128 /* Static */ - ? declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes) - : declareSymbol(container.symbol.members, container.symbol, node, symbolFlags, symbolExcludes); - } - function declareSourceFileMember(node, symbolFlags, symbolExcludes) { - return ts.isExternalModule(file) - ? declareModuleMember(node, symbolFlags, symbolExcludes) - : declareSymbol(file.locals, undefined, node, symbolFlags, symbolExcludes); - } - function isAmbientContext(node) { - while (node) { - if (node.flags & 2 /* Ambient */) { - return true; - } - node = node.parent; - } - return false; - } - function hasExportDeclarations(node) { - var body = node.kind === 248 /* SourceFile */ ? node : node.body; - if (body.kind === 248 /* SourceFile */ || body.kind === 219 /* ModuleBlock */) { - for (var _i = 0, _a = body.statements; _i < _a.length; _i++) { - var stat = _a[_i]; - if (stat.kind === 228 /* ExportDeclaration */ || stat.kind === 227 /* ExportAssignment */) { - return true; - } - } - } - return false; - } - function setExportContextFlag(node) { - // 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 (isAmbientContext(node) && !hasExportDeclarations(node)) { - node.flags |= 262144 /* ExportContext */; - } - else { - node.flags &= ~262144 /* ExportContext */; - } - } - function bindModuleDeclaration(node) { - setExportContextFlag(node); - if (node.name.kind === 9 /* StringLiteral */) { - declareSymbolAndAddToSymbolTable(node, 512 /* ValueModule */, 106639 /* ValueModuleExcludes */); - } - else { - var state = getModuleInstanceState(node); - if (state === 0 /* NonInstantiated */) { - declareSymbolAndAddToSymbolTable(node, 1024 /* NamespaceModule */, 0 /* NamespaceModuleExcludes */); - } - else { - declareSymbolAndAddToSymbolTable(node, 512 /* ValueModule */, 106639 /* ValueModuleExcludes */); - if (node.symbol.flags & (16 /* Function */ | 32 /* Class */ | 256 /* 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 { - var currentModuleIsConstEnumOnly = state === 2 /* 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) { - // For a given function symbol "<...>(...) => T" we want to generate a symbol identical - // to the one we would get for: { <...>(...): T } - // - // We do that by making an anonymous type literal symbol, and then setting the function - // symbol as its sole member. To the rest of the system, this symbol will be indistinguishable - // from an actual type literal symbol you would have gotten had you used the long form. - var symbol = createSymbol(131072 /* Signature */, getDeclarationName(node)); - addDeclarationToSymbol(symbol, node, 131072 /* Signature */); - var typeLiteralSymbol = createSymbol(2048 /* TypeLiteral */, "__type"); - addDeclarationToSymbol(typeLiteralSymbol, node, 2048 /* TypeLiteral */); - typeLiteralSymbol.members = (_a = {}, _a[symbol.name] = symbol, _a); - var _a; - } - function bindObjectLiteralExpression(node) { - var ElementKind; - (function (ElementKind) { - ElementKind[ElementKind["Property"] = 1] = "Property"; - ElementKind[ElementKind["Accessor"] = 2] = "Accessor"; - })(ElementKind || (ElementKind = {})); - if (inStrictMode) { - var seen = {}; - for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { - var prop = _a[_i]; - if (prop.name.kind !== 69 /* Identifier */) { - continue; - } - var identifier = prop.name; - // ECMA-262 11.1.5 Object Initialiser - // If previous is not undefined then throw a SyntaxError exception if any of the following conditions are true - // a.This production is contained in strict code and IsDataDescriptor(previous) is true and - // 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 - var currentKind = prop.kind === 245 /* PropertyAssignment */ || prop.kind === 246 /* ShorthandPropertyAssignment */ || prop.kind === 143 /* MethodDeclaration */ - ? 1 /* Property */ - : 2 /* Accessor */; - var existingKind = seen[identifier.text]; - if (!existingKind) { - seen[identifier.text] = currentKind; - continue; - } - if (currentKind === 1 /* Property */ && existingKind === 1 /* Property */) { - var span = ts.getErrorSpanForNode(file, identifier); - file.bindDiagnostics.push(ts.createFileDiagnostic(file, span.start, span.length, ts.Diagnostics.An_object_literal_cannot_have_multiple_properties_with_the_same_name_in_strict_mode)); - } - } - } - return bindAnonymousDeclaration(node, 4096 /* ObjectLiteral */, "__object"); - } - function bindAnonymousDeclaration(node, symbolFlags, name) { - var symbol = createSymbol(symbolFlags, name); - addDeclarationToSymbol(symbol, node, symbolFlags); - } - function bindBlockScopedDeclaration(node, symbolFlags, symbolExcludes) { - switch (blockScopeContainer.kind) { - case 218 /* ModuleDeclaration */: - declareModuleMember(node, symbolFlags, symbolExcludes); - break; - case 248 /* SourceFile */: - if (ts.isExternalModule(container)) { - declareModuleMember(node, symbolFlags, symbolExcludes); - break; - } - // fall through. - default: - if (!blockScopeContainer.locals) { - blockScopeContainer.locals = {}; - addToContainerChain(blockScopeContainer); - } - declareSymbol(blockScopeContainer.locals, undefined, node, symbolFlags, symbolExcludes); - } - } - function bindBlockScopedVariableDeclaration(node) { - bindBlockScopedDeclaration(node, 2 /* BlockScopedVariable */, 107455 /* 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) { - if (inStrictMode && - node.originalKeywordKind >= 106 /* FirstFutureReservedWord */ && - node.originalKeywordKind <= 114 /* LastFutureReservedWord */ && - !ts.isIdentifierName(node)) { - // Report error only if there are no parse errors in file - if (!file.parseDiagnostics.length) { - file.bindDiagnostics.push(ts.createDiagnosticForNode(node, getStrictModeIdentifierMessage(node), ts.declarationNameToString(node))); - } - } - } - function getStrictModeIdentifierMessage(node) { - // Provide specialized messages to help the user understand why we think they're in - // strict mode. - if (ts.getContainingClass(node)) { - return ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_strict_mode; - } - if (file.externalModuleIndicator) { - return ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode_Modules_are_automatically_in_strict_mode; - } - return ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode; - } - function checkStrictModeBinaryExpression(node) { - if (inStrictMode && ts.isLeftHandSideExpression(node.left) && ts.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) { - // 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) { - // Grammar checking - if (inStrictMode && node.expression.kind === 69 /* Identifier */) { - // When a delete operator occurs within strict mode code, a SyntaxError is thrown if its - // UnaryExpression is a direct reference to a variable, function argument, or function name - var span = ts.getErrorSpanForNode(file, node.expression); - file.bindDiagnostics.push(ts.createFileDiagnostic(file, span.start, span.length, ts.Diagnostics.delete_cannot_be_called_on_an_identifier_in_strict_mode)); - } - } - function isEvalOrArgumentsIdentifier(node) { - return node.kind === 69 /* Identifier */ && - (node.text === "eval" || node.text === "arguments"); - } - function checkStrictModeEvalOrArguments(contextNode, name) { - if (name && name.kind === 69 /* Identifier */) { - var identifier = name; - if (isEvalOrArgumentsIdentifier(identifier)) { - // We check first if the name is inside class declaration or class expression; if so give explicit message - // otherwise report generic error message. - var span = ts.getErrorSpanForNode(file, name); - file.bindDiagnostics.push(ts.createFileDiagnostic(file, span.start, span.length, getStrictModeEvalOrArgumentsMessage(contextNode), identifier.text)); - } - } - } - function getStrictModeEvalOrArgumentsMessage(node) { - // Provide specialized messages to help the user understand why we think they're in - // strict mode. - if (ts.getContainingClass(node)) { - return ts.Diagnostics.Invalid_use_of_0_Class_definitions_are_automatically_in_strict_mode; - } - if (file.externalModuleIndicator) { - return ts.Diagnostics.Invalid_use_of_0_Modules_are_automatically_in_strict_mode; - } - return ts.Diagnostics.Invalid_use_of_0_in_strict_mode; - } - function checkStrictModeFunctionName(node) { - 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 checkStrictModeNumericLiteral(node) { - if (inStrictMode && node.flags & 65536 /* OctalLiteral */) { - file.bindDiagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.Octal_literals_are_not_allowed_in_strict_mode)); - } - } - function checkStrictModePostfixUnaryExpression(node) { - // 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) { - // Grammar checking - if (inStrictMode) { - if (node.operator === 41 /* PlusPlusToken */ || node.operator === 42 /* MinusMinusToken */) { - checkStrictModeEvalOrArguments(node, node.operand); - } - } - } - function checkStrictModeWithStatement(node) { - // Grammar checking for withStatement - if (inStrictMode) { - grammarErrorOnFirstToken(node, ts.Diagnostics.with_statements_are_not_allowed_in_strict_mode); - } - } - function grammarErrorOnFirstToken(node, message, arg0, arg1, arg2) { - var span = ts.getSpanOfTokenAtPosition(file, node.pos); - file.bindDiagnostics.push(ts.createFileDiagnostic(file, span.start, span.length, message, arg0, arg1, arg2)); - } - function getDestructuringParameterName(node) { - return "__" + ts.indexOf(node.parent.parameters, node); - } - function bind(node) { - node.parent = parent; - var savedInStrictMode = inStrictMode; - if (!savedInStrictMode) { - updateStrictMode(node); - } - // 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. - bindChildren(node); - inStrictMode = savedInStrictMode; - } - function updateStrictMode(node) { - switch (node.kind) { - case 248 /* SourceFile */: - case 219 /* ModuleBlock */: - updateStrictModeStatementList(node.statements); - return; - case 192 /* Block */: - if (ts.isFunctionLike(node.parent)) { - updateStrictModeStatementList(node.statements); - } - return; - case 214 /* ClassDeclaration */: - case 186 /* ClassExpression */: - // All classes are automatically in strict mode in ES6. - inStrictMode = true; - return; - } - } - function updateStrictModeStatementList(statements) { - for (var _i = 0; _i < statements.length; _i++) { - var statement = statements[_i]; - if (!ts.isPrologueDirective(statement)) { - return; - } - if (isUseStrictPrologueDirective(statement)) { - inStrictMode = true; - return; - } - } - } - /// Should be called only on prologue directives (isPrologueDirective(node) should be true) - function isUseStrictPrologueDirective(node) { - var nodeText = ts.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) { - switch (node.kind) { - case 69 /* Identifier */: - return checkStrictModeIdentifier(node); - case 181 /* BinaryExpression */: - return checkStrictModeBinaryExpression(node); - case 244 /* CatchClause */: - return checkStrictModeCatchClause(node); - case 175 /* DeleteExpression */: - return checkStrictModeDeleteExpression(node); - case 8 /* NumericLiteral */: - return checkStrictModeNumericLiteral(node); - case 180 /* PostfixUnaryExpression */: - return checkStrictModePostfixUnaryExpression(node); - case 179 /* PrefixUnaryExpression */: - return checkStrictModePrefixUnaryExpression(node); - case 205 /* WithStatement */: - return checkStrictModeWithStatement(node); - case 97 /* ThisKeyword */: - seenThisKeyword = true; - return; - case 137 /* TypeParameter */: - return declareSymbolAndAddToSymbolTable(node, 262144 /* TypeParameter */, 530912 /* TypeParameterExcludes */); - case 138 /* Parameter */: - return bindParameter(node); - case 211 /* VariableDeclaration */: - case 163 /* BindingElement */: - return bindVariableDeclarationOrBindingElement(node); - case 141 /* PropertyDeclaration */: - case 140 /* PropertySignature */: - return bindPropertyOrMethodOrAccessor(node, 4 /* Property */ | (node.questionToken ? 536870912 /* Optional */ : 0 /* None */), 107455 /* PropertyExcludes */); - case 245 /* PropertyAssignment */: - case 246 /* ShorthandPropertyAssignment */: - return bindPropertyOrMethodOrAccessor(node, 4 /* Property */, 107455 /* PropertyExcludes */); - case 247 /* EnumMember */: - return bindPropertyOrMethodOrAccessor(node, 8 /* EnumMember */, 107455 /* EnumMemberExcludes */); - case 147 /* CallSignature */: - case 148 /* ConstructSignature */: - case 149 /* IndexSignature */: - return declareSymbolAndAddToSymbolTable(node, 131072 /* Signature */, 0 /* None */); - case 143 /* MethodDeclaration */: - case 142 /* MethodSignature */: - // If this is an ObjectLiteralExpression method, then it sits in the same space - // as other properties in the object literal. So we use SymbolFlags.PropertyExcludes - // so that it will conflict with any other object literal members with the same - // name. - return bindPropertyOrMethodOrAccessor(node, 8192 /* Method */ | (node.questionToken ? 536870912 /* Optional */ : 0 /* None */), ts.isObjectLiteralMethod(node) ? 107455 /* PropertyExcludes */ : 99263 /* MethodExcludes */); - case 213 /* FunctionDeclaration */: - checkStrictModeFunctionName(node); - return declareSymbolAndAddToSymbolTable(node, 16 /* Function */, 106927 /* FunctionExcludes */); - case 144 /* Constructor */: - return declareSymbolAndAddToSymbolTable(node, 16384 /* Constructor */, /*symbolExcludes:*/ 0 /* None */); - case 145 /* GetAccessor */: - return bindPropertyOrMethodOrAccessor(node, 32768 /* GetAccessor */, 41919 /* GetAccessorExcludes */); - case 146 /* SetAccessor */: - return bindPropertyOrMethodOrAccessor(node, 65536 /* SetAccessor */, 74687 /* SetAccessorExcludes */); - case 152 /* FunctionType */: - case 153 /* ConstructorType */: - return bindFunctionOrConstructorType(node); - case 155 /* TypeLiteral */: - return bindAnonymousDeclaration(node, 2048 /* TypeLiteral */, "__type"); - case 165 /* ObjectLiteralExpression */: - return bindObjectLiteralExpression(node); - case 173 /* FunctionExpression */: - case 174 /* ArrowFunction */: - checkStrictModeFunctionName(node); - var bindingName = node.name ? node.name.text : "__function"; - return bindAnonymousDeclaration(node, 16 /* Function */, bindingName); - case 186 /* ClassExpression */: - case 214 /* ClassDeclaration */: - return bindClassLikeDeclaration(node); - case 215 /* InterfaceDeclaration */: - return bindBlockScopedDeclaration(node, 64 /* Interface */, 792960 /* InterfaceExcludes */); - case 216 /* TypeAliasDeclaration */: - return bindBlockScopedDeclaration(node, 524288 /* TypeAlias */, 793056 /* TypeAliasExcludes */); - case 217 /* EnumDeclaration */: - return bindEnumDeclaration(node); - case 218 /* ModuleDeclaration */: - return bindModuleDeclaration(node); - case 221 /* ImportEqualsDeclaration */: - case 224 /* NamespaceImport */: - case 226 /* ImportSpecifier */: - case 230 /* ExportSpecifier */: - return declareSymbolAndAddToSymbolTable(node, 8388608 /* Alias */, 8388608 /* AliasExcludes */); - case 223 /* ImportClause */: - return bindImportClause(node); - case 228 /* ExportDeclaration */: - return bindExportDeclaration(node); - case 227 /* ExportAssignment */: - return bindExportAssignment(node); - case 248 /* SourceFile */: - return bindSourceFileIfExternalModule(); - } - } - function bindSourceFileIfExternalModule() { - setExportContextFlag(file); - if (ts.isExternalModule(file)) { - bindAnonymousDeclaration(file, 512 /* ValueModule */, "\"" + ts.removeFileExtension(file.fileName) + "\""); - } - } - function bindExportAssignment(node) { - if (!container.symbol || !container.symbol.exports) { - // Export assignment in some sort of block construct - bindAnonymousDeclaration(node, 8388608 /* Alias */, getDeclarationName(node)); - } - else if (node.expression.kind === 69 /* Identifier */) { - // An export default clause with an identifier exports all meanings of that identifier - declareSymbol(container.symbol.exports, container.symbol, node, 8388608 /* Alias */, 107455 /* PropertyExcludes */ | 8388608 /* AliasExcludes */); - } - else { - // An export default clause with an expression exports a value - declareSymbol(container.symbol.exports, container.symbol, node, 4 /* Property */, 107455 /* PropertyExcludes */ | 8388608 /* AliasExcludes */); - } - } - function bindExportDeclaration(node) { - if (!container.symbol || !container.symbol.exports) { - // Export * in some sort of block construct - bindAnonymousDeclaration(node, 1073741824 /* ExportStar */, getDeclarationName(node)); - } - else if (!node.exportClause) { - // All export * declarations are collected in an __export symbol - declareSymbol(container.symbol.exports, container.symbol, node, 1073741824 /* ExportStar */, 0 /* None */); - } - } - function bindImportClause(node) { - if (node.name) { - declareSymbolAndAddToSymbolTable(node, 8388608 /* Alias */, 8388608 /* AliasExcludes */); - } - } - function bindClassLikeDeclaration(node) { - if (node.kind === 214 /* ClassDeclaration */) { - bindBlockScopedDeclaration(node, 32 /* Class */, 899519 /* ClassExcludes */); - } - else { - var bindingName = node.name ? node.name.text : "__class"; - bindAnonymousDeclaration(node, 32 /* Class */, bindingName); - // Add name of class expression into the map for semantic classifier - if (node.name) { - classifiableNames[node.name.text] = node.name.text; - } - } - var 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. - var prototypeSymbol = createSymbol(4 /* Property */ | 134217728 /* Prototype */, "prototype"); - if (ts.hasProperty(symbol.exports, prototypeSymbol.name)) { - if (node.name) { - node.name.parent = node; - } - file.bindDiagnostics.push(ts.createDiagnosticForNode(symbol.exports[prototypeSymbol.name].declarations[0], ts.Diagnostics.Duplicate_identifier_0, prototypeSymbol.name)); - } - symbol.exports[prototypeSymbol.name] = prototypeSymbol; - prototypeSymbol.parent = symbol; - } - function bindEnumDeclaration(node) { - return ts.isConst(node) - ? bindBlockScopedDeclaration(node, 128 /* ConstEnum */, 899967 /* ConstEnumExcludes */) - : bindBlockScopedDeclaration(node, 256 /* RegularEnum */, 899327 /* RegularEnumExcludes */); - } - function bindVariableDeclarationOrBindingElement(node) { - if (inStrictMode) { - checkStrictModeEvalOrArguments(node, node.name); - } - if (!ts.isBindingPattern(node.name)) { - if (ts.isBlockOrCatchScoped(node)) { - bindBlockScopedVariableDeclaration(node); - } - else if (ts.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, 1 /* FunctionScopedVariable */, 107455 /* ParameterExcludes */); - } - else { - declareSymbolAndAddToSymbolTable(node, 1 /* FunctionScopedVariable */, 107454 /* FunctionScopedVariableExcludes */); - } - } - } - function bindParameter(node) { - 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 (ts.isBindingPattern(node.name)) { - bindAnonymousDeclaration(node, 1 /* FunctionScopedVariable */, getDestructuringParameterName(node)); - } - else { - declareSymbolAndAddToSymbolTable(node, 1 /* FunctionScopedVariable */, 107455 /* ParameterExcludes */); - } - // If this is a property-parameter, then also declare the property symbol into the - // containing class. - if (node.flags & 112 /* AccessibilityModifier */ && - node.parent.kind === 144 /* Constructor */ && - ts.isClassLike(node.parent.parent)) { - var classDeclaration = node.parent.parent; - declareSymbol(classDeclaration.symbol.members, classDeclaration.symbol, node, 4 /* Property */, 107455 /* PropertyExcludes */); - } - } - function bindPropertyOrMethodOrAccessor(node, symbolFlags, symbolExcludes) { - return ts.hasDynamicName(node) - ? bindAnonymousDeclaration(node, symbolFlags, "__computed") - : declareSymbolAndAddToSymbolTable(node, symbolFlags, symbolExcludes); - } - } -})(ts || (ts = {})); -/// -/// -/* @internal */ -var ts; -(function (ts) { - function getDeclarationOfKind(symbol, kind) { - var declarations = symbol.declarations; - if (declarations) { - for (var _i = 0; _i < declarations.length; _i++) { - var declaration = declarations[_i]; - if (declaration.kind === kind) { - return declaration; - } - } - } - return undefined; - } - ts.getDeclarationOfKind = getDeclarationOfKind; - // Pool writers to avoid needing to allocate them for every symbol we write. - var stringWriters = []; - function getSingleLineStringWriter() { - if (stringWriters.length === 0) { - var str = ""; - var writeText = function (text) { return str += text; }; - return { - string: function () { return str; }, - writeKeyword: writeText, - writeOperator: writeText, - writePunctuation: writeText, - writeSpace: writeText, - writeStringLiteral: writeText, - writeParameter: writeText, - writeSymbol: writeText, - // Completely ignore indentation for string writers. And map newlines to - // a single space. - writeLine: function () { return str += " "; }, - increaseIndent: function () { }, - decreaseIndent: function () { }, - clear: function () { return str = ""; }, - trackSymbol: function () { }, - reportInaccessibleThisError: function () { } - }; - } - return stringWriters.pop(); - } - ts.getSingleLineStringWriter = getSingleLineStringWriter; - function releaseStringWriter(writer) { - writer.clear(); - stringWriters.push(writer); - } - ts.releaseStringWriter = releaseStringWriter; - function getFullWidth(node) { - return node.end - node.pos; - } - ts.getFullWidth = getFullWidth; - function arrayIsEqualTo(array1, array2, equaler) { - if (!array1 || !array2) { - return array1 === array2; - } - if (array1.length !== array2.length) { - return false; - } - for (var i = 0; i < array1.length; ++i) { - var equals = equaler ? equaler(array1[i], array2[i]) : array1[i] === array2[i]; - if (!equals) { - return false; - } - } - return true; - } - ts.arrayIsEqualTo = arrayIsEqualTo; - function hasResolvedModule(sourceFile, moduleNameText) { - return sourceFile.resolvedModules && ts.hasProperty(sourceFile.resolvedModules, moduleNameText); - } - ts.hasResolvedModule = hasResolvedModule; - function getResolvedModule(sourceFile, moduleNameText) { - return hasResolvedModule(sourceFile, moduleNameText) ? sourceFile.resolvedModules[moduleNameText] : undefined; - } - ts.getResolvedModule = getResolvedModule; - function setResolvedModule(sourceFile, moduleNameText, resolvedModule) { - if (!sourceFile.resolvedModules) { - sourceFile.resolvedModules = {}; - } - sourceFile.resolvedModules[moduleNameText] = resolvedModule; - } - ts.setResolvedModule = setResolvedModule; - // Returns true if this node contains a parse error anywhere underneath it. - function containsParseError(node) { - aggregateChildData(node); - return (node.parserContextFlags & 64 /* ThisNodeOrAnySubNodesHasError */) !== 0; - } - ts.containsParseError = containsParseError; - function aggregateChildData(node) { - if (!(node.parserContextFlags & 128 /* HasAggregatedChildData */)) { - // A node is considered to contain a parse error if: - // a) the parser explicitly marked that it had an error - // b) any of it's children reported that it had an error. - var thisNodeOrAnySubNodesHasError = ((node.parserContextFlags & 16 /* ThisNodeHasError */) !== 0) || - ts.forEachChild(node, containsParseError); - // If so, mark ourselves accordingly. - if (thisNodeOrAnySubNodesHasError) { - node.parserContextFlags |= 64 /* ThisNodeOrAnySubNodesHasError */; - } - // Also mark that we've propogated the child information to this node. This way we can - // always consult the bit directly on this node without needing to check its children - // again. - node.parserContextFlags |= 128 /* HasAggregatedChildData */; - } - } - function getSourceFileOfNode(node) { - while (node && node.kind !== 248 /* SourceFile */) { - node = node.parent; - } - return node; - } - ts.getSourceFileOfNode = getSourceFileOfNode; - function getStartPositionOfLine(line, sourceFile) { - ts.Debug.assert(line >= 0); - return ts.getLineStarts(sourceFile)[line]; - } - ts.getStartPositionOfLine = getStartPositionOfLine; - // This is a useful function for debugging purposes. - function nodePosToString(node) { - var file = getSourceFileOfNode(node); - var loc = ts.getLineAndCharacterOfPosition(file, node.pos); - return file.fileName + "(" + (loc.line + 1) + "," + (loc.character + 1) + ")"; - } - ts.nodePosToString = nodePosToString; - function getStartPosOfNode(node) { - return node.pos; - } - ts.getStartPosOfNode = getStartPosOfNode; - // Returns true if this node is missing from the actual source code. A 'missing' node is different - // from 'undefined/defined'. When a node is undefined (which can happen for optional nodes - // in the tree), it is definitely missing. However, a node may be defined, but still be - // missing. This happens whenever the parser knows it needs to parse something, but can't - // get anything in the source code that it expects at that location. For example: - // - // let a: ; - // - // Here, the Type in the Type-Annotation is not-optional (as there is a colon in the source - // code). So the parser will attempt to parse out a type, and will create an actual node. - // However, this node will be 'missing' in the sense that no actual source-code/tokens are - // contained within it. - function nodeIsMissing(node) { - if (!node) { - return true; - } - return node.pos === node.end && node.pos >= 0 && node.kind !== 1 /* EndOfFileToken */; - } - ts.nodeIsMissing = nodeIsMissing; - function nodeIsPresent(node) { - return !nodeIsMissing(node); - } - ts.nodeIsPresent = nodeIsPresent; - function getTokenPosOfNode(node, sourceFile) { - // With nodes that have no width (i.e. 'Missing' nodes), we actually *don't* - // want to skip trivia because this will launch us forward to the next token. - if (nodeIsMissing(node)) { - return node.pos; - } - return ts.skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.pos); - } - ts.getTokenPosOfNode = getTokenPosOfNode; - function getNonDecoratorTokenPosOfNode(node, sourceFile) { - if (nodeIsMissing(node) || !node.decorators) { - return getTokenPosOfNode(node, sourceFile); - } - return ts.skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.decorators.end); - } - ts.getNonDecoratorTokenPosOfNode = getNonDecoratorTokenPosOfNode; - function getSourceTextOfNodeFromSourceFile(sourceFile, node, includeTrivia) { - if (includeTrivia === void 0) { includeTrivia = false; } - if (nodeIsMissing(node)) { - return ""; - } - var text = sourceFile.text; - return text.substring(includeTrivia ? node.pos : ts.skipTrivia(text, node.pos), node.end); - } - ts.getSourceTextOfNodeFromSourceFile = getSourceTextOfNodeFromSourceFile; - function getTextOfNodeFromSourceText(sourceText, node) { - if (nodeIsMissing(node)) { - return ""; - } - return sourceText.substring(ts.skipTrivia(sourceText, node.pos), node.end); - } - ts.getTextOfNodeFromSourceText = getTextOfNodeFromSourceText; - function getTextOfNode(node, includeTrivia) { - if (includeTrivia === void 0) { includeTrivia = false; } - return getSourceTextOfNodeFromSourceFile(getSourceFileOfNode(node), node, includeTrivia); - } - ts.getTextOfNode = getTextOfNode; - // Add an extra underscore to identifiers that start with two underscores to avoid issues with magic names like '__proto__' - function escapeIdentifier(identifier) { - return identifier.length >= 2 && identifier.charCodeAt(0) === 95 /* _ */ && identifier.charCodeAt(1) === 95 /* _ */ ? "_" + identifier : identifier; - } - ts.escapeIdentifier = escapeIdentifier; - // Remove extra underscore from escaped identifier - function unescapeIdentifier(identifier) { - return identifier.length >= 3 && identifier.charCodeAt(0) === 95 /* _ */ && identifier.charCodeAt(1) === 95 /* _ */ && identifier.charCodeAt(2) === 95 /* _ */ ? identifier.substr(1) : identifier; - } - ts.unescapeIdentifier = unescapeIdentifier; - // Make an identifier from an external module name by extracting the string after the last "/" and replacing - // all non-alphanumeric characters with underscores - function makeIdentifierFromModuleName(moduleName) { - return ts.getBaseFileName(moduleName).replace(/^(\d)/, "_$1").replace(/\W/g, "_"); - } - ts.makeIdentifierFromModuleName = makeIdentifierFromModuleName; - function isBlockOrCatchScoped(declaration) { - return (getCombinedNodeFlags(declaration) & 49152 /* BlockScoped */) !== 0 || - isCatchClauseVariableDeclaration(declaration); - } - ts.isBlockOrCatchScoped = isBlockOrCatchScoped; - // Gets the nearest enclosing block scope container that has the provided node - // as a descendant, that is not the provided node. - function getEnclosingBlockScopeContainer(node) { - var current = node.parent; - while (current) { - if (isFunctionLike(current)) { - return current; - } - switch (current.kind) { - case 248 /* SourceFile */: - case 220 /* CaseBlock */: - case 244 /* CatchClause */: - case 218 /* ModuleDeclaration */: - case 199 /* ForStatement */: - case 200 /* ForInStatement */: - case 201 /* ForOfStatement */: - return current; - case 192 /* Block */: - // function block is not considered block-scope container - // see comment in binder.ts: bind(...), case for SyntaxKind.Block - if (!isFunctionLike(current.parent)) { - return current; - } - } - current = current.parent; - } - } - ts.getEnclosingBlockScopeContainer = getEnclosingBlockScopeContainer; - function isCatchClauseVariableDeclaration(declaration) { - return declaration && - declaration.kind === 211 /* VariableDeclaration */ && - declaration.parent && - declaration.parent.kind === 244 /* CatchClause */; - } - ts.isCatchClauseVariableDeclaration = isCatchClauseVariableDeclaration; - // 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. - function declarationNameToString(name) { - return getFullWidth(name) === 0 ? "(Missing)" : getTextOfNode(name); - } - ts.declarationNameToString = declarationNameToString; - function createDiagnosticForNode(node, message, arg0, arg1, arg2) { - var sourceFile = getSourceFileOfNode(node); - var span = getErrorSpanForNode(sourceFile, node); - return ts.createFileDiagnostic(sourceFile, span.start, span.length, message, arg0, arg1, arg2); - } - ts.createDiagnosticForNode = createDiagnosticForNode; - function createDiagnosticForNodeFromMessageChain(node, messageChain) { - var sourceFile = getSourceFileOfNode(node); - var span = getErrorSpanForNode(sourceFile, node); - return { - file: sourceFile, - start: span.start, - length: span.length, - code: messageChain.code, - category: messageChain.category, - messageText: messageChain.next ? messageChain : messageChain.messageText - }; - } - ts.createDiagnosticForNodeFromMessageChain = createDiagnosticForNodeFromMessageChain; - function getSpanOfTokenAtPosition(sourceFile, pos) { - var scanner = ts.createScanner(sourceFile.languageVersion, /*skipTrivia*/ true, sourceFile.languageVariant, sourceFile.text, /*onError:*/ undefined, pos); - scanner.scan(); - var start = scanner.getTokenPos(); - return ts.createTextSpanFromBounds(start, scanner.getTextPos()); - } - ts.getSpanOfTokenAtPosition = getSpanOfTokenAtPosition; - function getErrorSpanForNode(sourceFile, node) { - var errorNode = node; - switch (node.kind) { - case 248 /* SourceFile */: - var pos_1 = ts.skipTrivia(sourceFile.text, 0, /*stopAfterLineBreak*/ false); - if (pos_1 === sourceFile.text.length) { - // file is empty - return span for the beginning of the file - return ts.createTextSpan(0, 0); - } - return getSpanOfTokenAtPosition(sourceFile, pos_1); - // This list is a work in progress. Add missing node kinds to improve their error - // spans. - case 211 /* VariableDeclaration */: - case 163 /* BindingElement */: - case 214 /* ClassDeclaration */: - case 186 /* ClassExpression */: - case 215 /* InterfaceDeclaration */: - case 218 /* ModuleDeclaration */: - case 217 /* EnumDeclaration */: - case 247 /* EnumMember */: - case 213 /* FunctionDeclaration */: - case 173 /* FunctionExpression */: - errorNode = node.name; - break; - } - if (errorNode === undefined) { - // If we don't have a better node, then just set the error on the first token of - // construct. - return getSpanOfTokenAtPosition(sourceFile, node.pos); - } - var pos = nodeIsMissing(errorNode) - ? errorNode.pos - : ts.skipTrivia(sourceFile.text, errorNode.pos); - return ts.createTextSpanFromBounds(pos, errorNode.end); - } - ts.getErrorSpanForNode = getErrorSpanForNode; - function isExternalModule(file) { - return file.externalModuleIndicator !== undefined; - } - ts.isExternalModule = isExternalModule; - function isDeclarationFile(file) { - return (file.flags & 8192 /* DeclarationFile */) !== 0; - } - ts.isDeclarationFile = isDeclarationFile; - function isConstEnumDeclaration(node) { - return node.kind === 217 /* EnumDeclaration */ && isConst(node); - } - ts.isConstEnumDeclaration = isConstEnumDeclaration; - function walkUpBindingElementsAndPatterns(node) { - while (node && (node.kind === 163 /* BindingElement */ || isBindingPattern(node))) { - node = node.parent; - } - return node; - } - // Returns the node flags for this node and all relevant parent nodes. This is done so that - // nodes like variable declarations and binding elements can returned a view of their flags - // that includes the modifiers from their container. i.e. flags like export/declare aren't - // stored on the variable declaration directly, but on the containing variable statement - // (if it has one). Similarly, flags for let/const are store on the variable declaration - // list. By calling this function, all those flags are combined so that the client can treat - // the node as if it actually had those flags. - function getCombinedNodeFlags(node) { - node = walkUpBindingElementsAndPatterns(node); - var flags = node.flags; - if (node.kind === 211 /* VariableDeclaration */) { - node = node.parent; - } - if (node && node.kind === 212 /* VariableDeclarationList */) { - flags |= node.flags; - node = node.parent; - } - if (node && node.kind === 193 /* VariableStatement */) { - flags |= node.flags; - } - return flags; - } - ts.getCombinedNodeFlags = getCombinedNodeFlags; - function isConst(node) { - return !!(getCombinedNodeFlags(node) & 32768 /* Const */); - } - ts.isConst = isConst; - function isLet(node) { - return !!(getCombinedNodeFlags(node) & 16384 /* Let */); - } - ts.isLet = isLet; - function isPrologueDirective(node) { - return node.kind === 195 /* ExpressionStatement */ && node.expression.kind === 9 /* StringLiteral */; - } - ts.isPrologueDirective = isPrologueDirective; - function getLeadingCommentRangesOfNode(node, sourceFileOfNode) { - return ts.getLeadingCommentRanges(sourceFileOfNode.text, node.pos); - } - ts.getLeadingCommentRangesOfNode = getLeadingCommentRangesOfNode; - function getJsDocComments(node, sourceFileOfNode) { - var commentRanges = (node.kind === 138 /* Parameter */ || node.kind === 137 /* TypeParameter */) ? - ts.concatenate(ts.getTrailingCommentRanges(sourceFileOfNode.text, node.pos), ts.getLeadingCommentRanges(sourceFileOfNode.text, node.pos)) : - getLeadingCommentRangesOfNode(node, sourceFileOfNode); - return ts.filter(commentRanges, isJsDocComment); - function isJsDocComment(comment) { - // True if the comment starts with '/**' but not if it is '/**/' - return sourceFileOfNode.text.charCodeAt(comment.pos + 1) === 42 /* asterisk */ && - sourceFileOfNode.text.charCodeAt(comment.pos + 2) === 42 /* asterisk */ && - sourceFileOfNode.text.charCodeAt(comment.pos + 3) !== 47 /* slash */; - } - } - ts.getJsDocComments = getJsDocComments; - ts.fullTripleSlashReferencePathRegEx = /^(\/\/\/\s*/; - ts.fullTripleSlashAMDReferencePathRegEx = /^(\/\/\/\s*/; - function isTypeNode(node) { - if (151 /* FirstTypeNode */ <= node.kind && node.kind <= 160 /* LastTypeNode */) { - return true; - } - switch (node.kind) { - case 117 /* AnyKeyword */: - case 128 /* NumberKeyword */: - case 130 /* StringKeyword */: - case 120 /* BooleanKeyword */: - case 131 /* SymbolKeyword */: - return true; - case 103 /* VoidKeyword */: - return node.parent.kind !== 177 /* VoidExpression */; - case 9 /* StringLiteral */: - // Specialized signatures can have string literals as their parameters' type names - return node.parent.kind === 138 /* Parameter */; - case 188 /* ExpressionWithTypeArguments */: - return !isExpressionWithTypeArgumentsInClassExtendsClause(node); - // Identifiers and qualified names may be type nodes, depending on their context. Climb - // above them to find the lowest container - case 69 /* Identifier */: - // If the identifier is the RHS of a qualified name, then it's a type iff its parent is. - if (node.parent.kind === 135 /* QualifiedName */ && node.parent.right === node) { - node = node.parent; - } - else if (node.parent.kind === 166 /* 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 === 135 /* QualifiedName */ || node.kind === 166 /* PropertyAccessExpression */, "'node' was expected to be a qualified name, identifier or property access in 'isTypeNode'."); - case 135 /* QualifiedName */: - case 166 /* PropertyAccessExpression */: - case 97 /* ThisKeyword */: - var parent_1 = node.parent; - if (parent_1.kind === 154 /* TypeQuery */) { - return false; - } - // Do not recursively call isTypeNode on the parent. In the example: - // - // let a: A.B.C; - // - // Calling isTypeNode would consider the qualified name A.B a type node. Only C or - // A.B.C is a type node. - if (151 /* FirstTypeNode */ <= parent_1.kind && parent_1.kind <= 160 /* LastTypeNode */) { - return true; - } - switch (parent_1.kind) { - case 188 /* ExpressionWithTypeArguments */: - return !isExpressionWithTypeArgumentsInClassExtendsClause(parent_1); - case 137 /* TypeParameter */: - return node === parent_1.constraint; - case 141 /* PropertyDeclaration */: - case 140 /* PropertySignature */: - case 138 /* Parameter */: - case 211 /* VariableDeclaration */: - return node === parent_1.type; - case 213 /* FunctionDeclaration */: - case 173 /* FunctionExpression */: - case 174 /* ArrowFunction */: - case 144 /* Constructor */: - case 143 /* MethodDeclaration */: - case 142 /* MethodSignature */: - case 145 /* GetAccessor */: - case 146 /* SetAccessor */: - return node === parent_1.type; - case 147 /* CallSignature */: - case 148 /* ConstructSignature */: - case 149 /* IndexSignature */: - return node === parent_1.type; - case 171 /* TypeAssertionExpression */: - return node === parent_1.type; - case 168 /* CallExpression */: - case 169 /* NewExpression */: - return parent_1.typeArguments && ts.indexOf(parent_1.typeArguments, node) >= 0; - case 170 /* TaggedTemplateExpression */: - // TODO (drosen): TaggedTemplateExpressions may eventually support type arguments. - return false; - } - } - return false; - } - ts.isTypeNode = isTypeNode; - // Warning: This has the same semantics as the forEach family of functions, - // in that traversal terminates in the event that 'visitor' supplies a truthy value. - function forEachReturnStatement(body, visitor) { - return traverse(body); - function traverse(node) { - switch (node.kind) { - case 204 /* ReturnStatement */: - return visitor(node); - case 220 /* CaseBlock */: - case 192 /* Block */: - case 196 /* IfStatement */: - case 197 /* DoStatement */: - case 198 /* WhileStatement */: - case 199 /* ForStatement */: - case 200 /* ForInStatement */: - case 201 /* ForOfStatement */: - case 205 /* WithStatement */: - case 206 /* SwitchStatement */: - case 241 /* CaseClause */: - case 242 /* DefaultClause */: - case 207 /* LabeledStatement */: - case 209 /* TryStatement */: - case 244 /* CatchClause */: - return ts.forEachChild(node, traverse); - } - } - } - ts.forEachReturnStatement = forEachReturnStatement; - function forEachYieldExpression(body, visitor) { - return traverse(body); - function traverse(node) { - switch (node.kind) { - case 184 /* YieldExpression */: - visitor(node); - var operand = node.expression; - if (operand) { - traverse(operand); - } - case 217 /* EnumDeclaration */: - case 215 /* InterfaceDeclaration */: - case 218 /* ModuleDeclaration */: - case 216 /* TypeAliasDeclaration */: - case 214 /* ClassDeclaration */: - case 186 /* ClassExpression */: - // These are not allowed inside a generator now, but eventually they may be allowed - // as local types. Regardless, any yield statements contained within them should be - // skipped in this traversal. - return; - default: - if (isFunctionLike(node)) { - var name_5 = node.name; - if (name_5 && name_5.kind === 136 /* ComputedPropertyName */) { - // Note that we will not include methods/accessors of a class because they would require - // first descending into the class. This is by design. - traverse(name_5.expression); - return; - } - } - else if (!isTypeNode(node)) { - // This is the general case, which should include mostly expressions and statements. - // Also includes NodeArrays. - ts.forEachChild(node, traverse); - } - } - } - } - ts.forEachYieldExpression = forEachYieldExpression; - function isVariableLike(node) { - if (node) { - switch (node.kind) { - case 163 /* BindingElement */: - case 247 /* EnumMember */: - case 138 /* Parameter */: - case 245 /* PropertyAssignment */: - case 141 /* PropertyDeclaration */: - case 140 /* PropertySignature */: - case 246 /* ShorthandPropertyAssignment */: - case 211 /* VariableDeclaration */: - return true; - } - } - return false; - } - ts.isVariableLike = isVariableLike; - function isAccessor(node) { - return node && (node.kind === 145 /* GetAccessor */ || node.kind === 146 /* SetAccessor */); - } - ts.isAccessor = isAccessor; - function isClassLike(node) { - return node && (node.kind === 214 /* ClassDeclaration */ || node.kind === 186 /* ClassExpression */); - } - ts.isClassLike = isClassLike; - function isFunctionLike(node) { - if (node) { - switch (node.kind) { - case 144 /* Constructor */: - case 173 /* FunctionExpression */: - case 213 /* FunctionDeclaration */: - case 174 /* ArrowFunction */: - case 143 /* MethodDeclaration */: - case 142 /* MethodSignature */: - case 145 /* GetAccessor */: - case 146 /* SetAccessor */: - case 147 /* CallSignature */: - case 148 /* ConstructSignature */: - case 149 /* IndexSignature */: - case 152 /* FunctionType */: - case 153 /* ConstructorType */: - return true; - } - } - return false; - } - ts.isFunctionLike = isFunctionLike; - function introducesArgumentsExoticObject(node) { - switch (node.kind) { - case 143 /* MethodDeclaration */: - case 142 /* MethodSignature */: - case 144 /* Constructor */: - case 145 /* GetAccessor */: - case 146 /* SetAccessor */: - case 213 /* FunctionDeclaration */: - case 173 /* FunctionExpression */: - return true; - } - return false; - } - ts.introducesArgumentsExoticObject = introducesArgumentsExoticObject; - function isFunctionBlock(node) { - return node && node.kind === 192 /* Block */ && isFunctionLike(node.parent); - } - ts.isFunctionBlock = isFunctionBlock; - function isObjectLiteralMethod(node) { - return node && node.kind === 143 /* MethodDeclaration */ && node.parent.kind === 165 /* ObjectLiteralExpression */; - } - ts.isObjectLiteralMethod = isObjectLiteralMethod; - function getContainingFunction(node) { - while (true) { - node = node.parent; - if (!node || isFunctionLike(node)) { - return node; - } - } - } - ts.getContainingFunction = getContainingFunction; - function getContainingClass(node) { - while (true) { - node = node.parent; - if (!node || isClassLike(node)) { - return node; - } - } - } - ts.getContainingClass = getContainingClass; - function getThisContainer(node, includeArrowFunctions) { - while (true) { - node = node.parent; - if (!node) { - return undefined; - } - switch (node.kind) { - case 136 /* ComputedPropertyName */: - // If the grandparent node is an object literal (as opposed to a class), - // then the computed property is not a 'this' container. - // A computed property name in a class needs to be a this container - // so that we can error on it. - if (isClassLike(node.parent.parent)) { - return node; - } - // If this is a computed property, then the parent should not - // make it a this container. The parent might be a property - // in an object literal, like a method or accessor. But in order for - // such a parent to be a this container, the reference must be in - // the *body* of the container. - node = node.parent; - break; - case 139 /* Decorator */: - // Decorators are always applied outside of the body of a class or method. - if (node.parent.kind === 138 /* Parameter */ && isClassElement(node.parent.parent)) { - // If the decorator's parent is a Parameter, we resolve the this container from - // the grandparent class declaration. - node = node.parent.parent; - } - else if (isClassElement(node.parent)) { - // If the decorator's parent is a class element, we resolve the 'this' container - // from the parent class declaration. - node = node.parent; - } - break; - case 174 /* ArrowFunction */: - if (!includeArrowFunctions) { - continue; - } - // Fall through - case 213 /* FunctionDeclaration */: - case 173 /* FunctionExpression */: - case 218 /* ModuleDeclaration */: - case 141 /* PropertyDeclaration */: - case 140 /* PropertySignature */: - case 143 /* MethodDeclaration */: - case 142 /* MethodSignature */: - case 144 /* Constructor */: - case 145 /* GetAccessor */: - case 146 /* SetAccessor */: - case 147 /* CallSignature */: - case 148 /* ConstructSignature */: - case 149 /* IndexSignature */: - case 217 /* EnumDeclaration */: - case 248 /* SourceFile */: - return node; - } - } - } - ts.getThisContainer = getThisContainer; - function getSuperContainer(node, includeFunctions) { - while (true) { - node = node.parent; - if (!node) - return node; - switch (node.kind) { - case 136 /* ComputedPropertyName */: - // If the grandparent node is an object literal (as opposed to a class), - // then the computed property is not a 'super' container. - // A computed property name in a class needs to be a super container - // so that we can error on it. - if (isClassLike(node.parent.parent)) { - return node; - } - // If this is a computed property, then the parent should not - // make it a super container. The parent might be a property - // in an object literal, like a method or accessor. But in order for - // such a parent to be a super container, the reference must be in - // the *body* of the container. - node = node.parent; - break; - case 139 /* Decorator */: - // Decorators are always applied outside of the body of a class or method. - if (node.parent.kind === 138 /* Parameter */ && isClassElement(node.parent.parent)) { - // If the decorator's parent is a Parameter, we resolve the this container from - // the grandparent class declaration. - node = node.parent.parent; - } - else if (isClassElement(node.parent)) { - // If the decorator's parent is a class element, we resolve the 'this' container - // from the parent class declaration. - node = node.parent; - } - break; - case 213 /* FunctionDeclaration */: - case 173 /* FunctionExpression */: - case 174 /* ArrowFunction */: - if (!includeFunctions) { - continue; - } - case 141 /* PropertyDeclaration */: - case 140 /* PropertySignature */: - case 143 /* MethodDeclaration */: - case 142 /* MethodSignature */: - case 144 /* Constructor */: - case 145 /* GetAccessor */: - case 146 /* SetAccessor */: - return node; - } - } - } - ts.getSuperContainer = getSuperContainer; - function getEntityNameFromTypeNode(node) { - if (node) { - switch (node.kind) { - case 151 /* TypeReference */: - return node.typeName; - case 188 /* ExpressionWithTypeArguments */: - return node.expression; - case 69 /* Identifier */: - case 135 /* QualifiedName */: - return node; - } - } - return undefined; - } - ts.getEntityNameFromTypeNode = getEntityNameFromTypeNode; - function getInvokedExpression(node) { - if (node.kind === 170 /* TaggedTemplateExpression */) { - return node.tag; - } - // Will either be a CallExpression, NewExpression, or Decorator. - return node.expression; - } - ts.getInvokedExpression = getInvokedExpression; - function nodeCanBeDecorated(node) { - switch (node.kind) { - case 214 /* ClassDeclaration */: - // classes are valid targets - return true; - case 141 /* PropertyDeclaration */: - // property declarations are valid if their parent is a class declaration. - return node.parent.kind === 214 /* ClassDeclaration */; - case 138 /* Parameter */: - // if the parameter's parent has a body and its grandparent is a class declaration, this is a valid target; - return node.parent.body && node.parent.parent.kind === 214 /* ClassDeclaration */; - case 145 /* GetAccessor */: - case 146 /* SetAccessor */: - case 143 /* MethodDeclaration */: - // if this method has a body and its parent is a class declaration, this is a valid target. - return node.body && node.parent.kind === 214 /* ClassDeclaration */; - } - return false; - } - ts.nodeCanBeDecorated = nodeCanBeDecorated; - function nodeIsDecorated(node) { - switch (node.kind) { - case 214 /* ClassDeclaration */: - if (node.decorators) { - return true; - } - return false; - case 141 /* PropertyDeclaration */: - case 138 /* Parameter */: - if (node.decorators) { - return true; - } - return false; - case 145 /* GetAccessor */: - if (node.body && node.decorators) { - return true; - } - return false; - case 143 /* MethodDeclaration */: - case 146 /* SetAccessor */: - if (node.body && node.decorators) { - return true; - } - return false; - } - return false; - } - ts.nodeIsDecorated = nodeIsDecorated; - function childIsDecorated(node) { - switch (node.kind) { - case 214 /* ClassDeclaration */: - return ts.forEach(node.members, nodeOrChildIsDecorated); - case 143 /* MethodDeclaration */: - case 146 /* SetAccessor */: - return ts.forEach(node.parameters, nodeIsDecorated); - } - return false; - } - ts.childIsDecorated = childIsDecorated; - function nodeOrChildIsDecorated(node) { - return nodeIsDecorated(node) || childIsDecorated(node); - } - ts.nodeOrChildIsDecorated = nodeOrChildIsDecorated; - function isPropertyAccessExpression(node) { - return node.kind === 166 /* PropertyAccessExpression */; - } - ts.isPropertyAccessExpression = isPropertyAccessExpression; - function isElementAccessExpression(node) { - return node.kind === 167 /* ElementAccessExpression */; - } - ts.isElementAccessExpression = isElementAccessExpression; - function isExpression(node) { - switch (node.kind) { - case 95 /* SuperKeyword */: - case 93 /* NullKeyword */: - case 99 /* TrueKeyword */: - case 84 /* FalseKeyword */: - case 10 /* RegularExpressionLiteral */: - case 164 /* ArrayLiteralExpression */: - case 165 /* ObjectLiteralExpression */: - case 166 /* PropertyAccessExpression */: - case 167 /* ElementAccessExpression */: - case 168 /* CallExpression */: - case 169 /* NewExpression */: - case 170 /* TaggedTemplateExpression */: - case 189 /* AsExpression */: - case 171 /* TypeAssertionExpression */: - case 172 /* ParenthesizedExpression */: - case 173 /* FunctionExpression */: - case 186 /* ClassExpression */: - case 174 /* ArrowFunction */: - case 177 /* VoidExpression */: - case 175 /* DeleteExpression */: - case 176 /* TypeOfExpression */: - case 179 /* PrefixUnaryExpression */: - case 180 /* PostfixUnaryExpression */: - case 181 /* BinaryExpression */: - case 182 /* ConditionalExpression */: - case 185 /* SpreadElementExpression */: - case 183 /* TemplateExpression */: - case 11 /* NoSubstitutionTemplateLiteral */: - case 187 /* OmittedExpression */: - case 233 /* JsxElement */: - case 234 /* JsxSelfClosingElement */: - case 184 /* YieldExpression */: - case 178 /* AwaitExpression */: - return true; - case 135 /* QualifiedName */: - while (node.parent.kind === 135 /* QualifiedName */) { - node = node.parent; - } - return node.parent.kind === 154 /* TypeQuery */; - case 69 /* Identifier */: - if (node.parent.kind === 154 /* TypeQuery */) { - return true; - } - // fall through - case 8 /* NumericLiteral */: - case 9 /* StringLiteral */: - case 97 /* ThisKeyword */: - var parent_2 = node.parent; - switch (parent_2.kind) { - case 211 /* VariableDeclaration */: - case 138 /* Parameter */: - case 141 /* PropertyDeclaration */: - case 140 /* PropertySignature */: - case 247 /* EnumMember */: - case 245 /* PropertyAssignment */: - case 163 /* BindingElement */: - return parent_2.initializer === node; - case 195 /* ExpressionStatement */: - case 196 /* IfStatement */: - case 197 /* DoStatement */: - case 198 /* WhileStatement */: - case 204 /* ReturnStatement */: - case 205 /* WithStatement */: - case 206 /* SwitchStatement */: - case 241 /* CaseClause */: - case 208 /* ThrowStatement */: - case 206 /* SwitchStatement */: - return parent_2.expression === node; - case 199 /* ForStatement */: - var forStatement = parent_2; - return (forStatement.initializer === node && forStatement.initializer.kind !== 212 /* VariableDeclarationList */) || - forStatement.condition === node || - forStatement.incrementor === node; - case 200 /* ForInStatement */: - case 201 /* ForOfStatement */: - var forInStatement = parent_2; - return (forInStatement.initializer === node && forInStatement.initializer.kind !== 212 /* VariableDeclarationList */) || - forInStatement.expression === node; - case 171 /* TypeAssertionExpression */: - case 189 /* AsExpression */: - return node === parent_2.expression; - case 190 /* TemplateSpan */: - return node === parent_2.expression; - case 136 /* ComputedPropertyName */: - return node === parent_2.expression; - case 139 /* Decorator */: - case 240 /* JsxExpression */: - case 239 /* JsxSpreadAttribute */: - return true; - case 188 /* ExpressionWithTypeArguments */: - return parent_2.expression === node && isExpressionWithTypeArgumentsInClassExtendsClause(parent_2); - default: - if (isExpression(parent_2)) { - return true; - } - } - } - return false; - } - ts.isExpression = isExpression; - function isExternalModuleNameRelative(moduleName) { - // TypeScript 1.0 spec (April 2014): 11.2.1 - // An external module name is "relative" if the first term is "." or "..". - return moduleName.substr(0, 2) === "./" || moduleName.substr(0, 3) === "../" || moduleName.substr(0, 2) === ".\\" || moduleName.substr(0, 3) === "..\\"; - } - ts.isExternalModuleNameRelative = isExternalModuleNameRelative; - function isInstantiatedModule(node, preserveConstEnums) { - var moduleState = ts.getModuleInstanceState(node); - return moduleState === 1 /* Instantiated */ || - (preserveConstEnums && moduleState === 2 /* ConstEnumOnly */); - } - ts.isInstantiatedModule = isInstantiatedModule; - function isExternalModuleImportEqualsDeclaration(node) { - return node.kind === 221 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 232 /* ExternalModuleReference */; - } - ts.isExternalModuleImportEqualsDeclaration = isExternalModuleImportEqualsDeclaration; - function getExternalModuleImportEqualsDeclarationExpression(node) { - ts.Debug.assert(isExternalModuleImportEqualsDeclaration(node)); - return node.moduleReference.expression; - } - ts.getExternalModuleImportEqualsDeclarationExpression = getExternalModuleImportEqualsDeclarationExpression; - function isInternalModuleImportEqualsDeclaration(node) { - return node.kind === 221 /* ImportEqualsDeclaration */ && node.moduleReference.kind !== 232 /* ExternalModuleReference */; - } - ts.isInternalModuleImportEqualsDeclaration = isInternalModuleImportEqualsDeclaration; - function getExternalModuleName(node) { - if (node.kind === 222 /* ImportDeclaration */) { - return node.moduleSpecifier; - } - if (node.kind === 221 /* ImportEqualsDeclaration */) { - var reference = node.moduleReference; - if (reference.kind === 232 /* ExternalModuleReference */) { - return reference.expression; - } - } - if (node.kind === 228 /* ExportDeclaration */) { - return node.moduleSpecifier; - } - } - ts.getExternalModuleName = getExternalModuleName; - function hasQuestionToken(node) { - if (node) { - switch (node.kind) { - case 138 /* Parameter */: - case 143 /* MethodDeclaration */: - case 142 /* MethodSignature */: - case 246 /* ShorthandPropertyAssignment */: - case 245 /* PropertyAssignment */: - case 141 /* PropertyDeclaration */: - case 140 /* PropertySignature */: - return node.questionToken !== undefined; - } - } - return false; - } - ts.hasQuestionToken = hasQuestionToken; - function isJSDocConstructSignature(node) { - return node.kind === 261 /* JSDocFunctionType */ && - node.parameters.length > 0 && - node.parameters[0].type.kind === 263 /* JSDocConstructorType */; - } - ts.isJSDocConstructSignature = isJSDocConstructSignature; - function getJSDocTag(node, kind) { - if (node && node.jsDocComment) { - for (var _i = 0, _a = node.jsDocComment.tags; _i < _a.length; _i++) { - var tag = _a[_i]; - if (tag.kind === kind) { - return tag; - } - } - } - } - function getJSDocTypeTag(node) { - return getJSDocTag(node, 269 /* JSDocTypeTag */); - } - ts.getJSDocTypeTag = getJSDocTypeTag; - function getJSDocReturnTag(node) { - return getJSDocTag(node, 268 /* JSDocReturnTag */); - } - ts.getJSDocReturnTag = getJSDocReturnTag; - function getJSDocTemplateTag(node) { - return getJSDocTag(node, 270 /* JSDocTemplateTag */); - } - ts.getJSDocTemplateTag = getJSDocTemplateTag; - function getCorrespondingJSDocParameterTag(parameter) { - if (parameter.name && parameter.name.kind === 69 /* Identifier */) { - // If it's a parameter, see if the parent has a jsdoc comment with an @param - // annotation. - var parameterName = parameter.name.text; - var docComment = parameter.parent.jsDocComment; - if (docComment) { - return ts.forEach(docComment.tags, function (t) { - if (t.kind === 267 /* JSDocParameterTag */) { - var parameterTag = t; - var name_6 = parameterTag.preParameterName || parameterTag.postParameterName; - if (name_6.text === parameterName) { - return t; - } - } - }); - } - } - } - ts.getCorrespondingJSDocParameterTag = getCorrespondingJSDocParameterTag; - function hasRestParameter(s) { - return isRestParameter(ts.lastOrUndefined(s.parameters)); - } - ts.hasRestParameter = hasRestParameter; - function isRestParameter(node) { - if (node) { - if (node.parserContextFlags & 32 /* JavaScriptFile */) { - if (node.type && node.type.kind === 262 /* JSDocVariadicType */) { - return true; - } - var paramTag = getCorrespondingJSDocParameterTag(node); - if (paramTag && paramTag.typeExpression) { - return paramTag.typeExpression.type.kind === 262 /* JSDocVariadicType */; - } - } - return node.dotDotDotToken !== undefined; - } - return false; - } - ts.isRestParameter = isRestParameter; - function isLiteralKind(kind) { - return 8 /* FirstLiteralToken */ <= kind && kind <= 11 /* LastLiteralToken */; - } - ts.isLiteralKind = isLiteralKind; - function isTextualLiteralKind(kind) { - return kind === 9 /* StringLiteral */ || kind === 11 /* NoSubstitutionTemplateLiteral */; - } - ts.isTextualLiteralKind = isTextualLiteralKind; - function isTemplateLiteralKind(kind) { - return 11 /* FirstTemplateToken */ <= kind && kind <= 14 /* LastTemplateToken */; - } - ts.isTemplateLiteralKind = isTemplateLiteralKind; - function isBindingPattern(node) { - return !!node && (node.kind === 162 /* ArrayBindingPattern */ || node.kind === 161 /* ObjectBindingPattern */); - } - ts.isBindingPattern = isBindingPattern; - function isInAmbientContext(node) { - while (node) { - if (node.flags & (2 /* Ambient */ | 8192 /* DeclarationFile */)) { - return true; - } - node = node.parent; - } - return false; - } - ts.isInAmbientContext = isInAmbientContext; - function isDeclaration(node) { - switch (node.kind) { - case 174 /* ArrowFunction */: - case 163 /* BindingElement */: - case 214 /* ClassDeclaration */: - case 186 /* ClassExpression */: - case 144 /* Constructor */: - case 217 /* EnumDeclaration */: - case 247 /* EnumMember */: - case 230 /* ExportSpecifier */: - case 213 /* FunctionDeclaration */: - case 173 /* FunctionExpression */: - case 145 /* GetAccessor */: - case 223 /* ImportClause */: - case 221 /* ImportEqualsDeclaration */: - case 226 /* ImportSpecifier */: - case 215 /* InterfaceDeclaration */: - case 143 /* MethodDeclaration */: - case 142 /* MethodSignature */: - case 218 /* ModuleDeclaration */: - case 224 /* NamespaceImport */: - case 138 /* Parameter */: - case 245 /* PropertyAssignment */: - case 141 /* PropertyDeclaration */: - case 140 /* PropertySignature */: - case 146 /* SetAccessor */: - case 246 /* ShorthandPropertyAssignment */: - case 216 /* TypeAliasDeclaration */: - case 137 /* TypeParameter */: - case 211 /* VariableDeclaration */: - return true; - } - return false; - } - ts.isDeclaration = isDeclaration; - function isStatement(n) { - switch (n.kind) { - case 203 /* BreakStatement */: - case 202 /* ContinueStatement */: - case 210 /* DebuggerStatement */: - case 197 /* DoStatement */: - case 195 /* ExpressionStatement */: - case 194 /* EmptyStatement */: - case 200 /* ForInStatement */: - case 201 /* ForOfStatement */: - case 199 /* ForStatement */: - case 196 /* IfStatement */: - case 207 /* LabeledStatement */: - case 204 /* ReturnStatement */: - case 206 /* SwitchStatement */: - case 98 /* ThrowKeyword */: - case 209 /* TryStatement */: - case 193 /* VariableStatement */: - case 198 /* WhileStatement */: - case 205 /* WithStatement */: - case 227 /* ExportAssignment */: - return true; - default: - return false; - } - } - ts.isStatement = isStatement; - function isClassElement(n) { - switch (n.kind) { - case 144 /* Constructor */: - case 141 /* PropertyDeclaration */: - case 143 /* MethodDeclaration */: - case 145 /* GetAccessor */: - case 146 /* SetAccessor */: - case 142 /* MethodSignature */: - case 149 /* IndexSignature */: - return true; - default: - return false; - } - } - ts.isClassElement = isClassElement; - // True if the given identifier, string literal, or number literal is the name of a declaration node - function isDeclarationName(name) { - if (name.kind !== 69 /* Identifier */ && name.kind !== 9 /* StringLiteral */ && name.kind !== 8 /* NumericLiteral */) { - return false; - } - var parent = name.parent; - if (parent.kind === 226 /* ImportSpecifier */ || parent.kind === 230 /* ExportSpecifier */) { - if (parent.propertyName) { - return true; - } - } - if (isDeclaration(parent)) { - return parent.name === name; - } - return false; - } - ts.isDeclarationName = isDeclarationName; - // Return true if the given identifier is classified as an IdentifierName - function isIdentifierName(node) { - var parent = node.parent; - switch (parent.kind) { - case 141 /* PropertyDeclaration */: - case 140 /* PropertySignature */: - case 143 /* MethodDeclaration */: - case 142 /* MethodSignature */: - case 145 /* GetAccessor */: - case 146 /* SetAccessor */: - case 247 /* EnumMember */: - case 245 /* PropertyAssignment */: - case 166 /* PropertyAccessExpression */: - // Name in member declaration or property name in property access - return parent.name === node; - case 135 /* QualifiedName */: - // Name on right hand side of dot in a type query - if (parent.right === node) { - while (parent.kind === 135 /* QualifiedName */) { - parent = parent.parent; - } - return parent.kind === 154 /* TypeQuery */; - } - return false; - case 163 /* BindingElement */: - case 226 /* ImportSpecifier */: - // Property name in binding element or import specifier - return parent.propertyName === node; - case 230 /* ExportSpecifier */: - // Any name in an export specifier - return true; - } - return false; - } - ts.isIdentifierName = isIdentifierName; - // An alias symbol is created by one of the following declarations: - // import = ... - // import from ... - // import * as from ... - // import { x as } from ... - // export { x as } from ... - // export = ... - // export default ... - function isAliasSymbolDeclaration(node) { - return node.kind === 221 /* ImportEqualsDeclaration */ || - node.kind === 223 /* ImportClause */ && !!node.name || - node.kind === 224 /* NamespaceImport */ || - node.kind === 226 /* ImportSpecifier */ || - node.kind === 230 /* ExportSpecifier */ || - node.kind === 227 /* ExportAssignment */ && node.expression.kind === 69 /* Identifier */; - } - ts.isAliasSymbolDeclaration = isAliasSymbolDeclaration; - function getClassExtendsHeritageClauseElement(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 83 /* ExtendsKeyword */); - return heritageClause && heritageClause.types.length > 0 ? heritageClause.types[0] : undefined; - } - ts.getClassExtendsHeritageClauseElement = getClassExtendsHeritageClauseElement; - function getClassImplementsHeritageClauseElements(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 106 /* ImplementsKeyword */); - return heritageClause ? heritageClause.types : undefined; - } - ts.getClassImplementsHeritageClauseElements = getClassImplementsHeritageClauseElements; - function getInterfaceBaseTypeNodes(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 83 /* ExtendsKeyword */); - return heritageClause ? heritageClause.types : undefined; - } - ts.getInterfaceBaseTypeNodes = getInterfaceBaseTypeNodes; - function getHeritageClause(clauses, kind) { - if (clauses) { - for (var _i = 0; _i < clauses.length; _i++) { - var clause = clauses[_i]; - if (clause.token === kind) { - return clause; - } - } - } - return undefined; - } - ts.getHeritageClause = getHeritageClause; - function tryResolveScriptReference(host, sourceFile, reference) { - if (!host.getCompilerOptions().noResolve) { - var referenceFileName = ts.isRootedDiskPath(reference.fileName) ? reference.fileName : ts.combinePaths(ts.getDirectoryPath(sourceFile.fileName), reference.fileName); - referenceFileName = ts.getNormalizedAbsolutePath(referenceFileName, host.getCurrentDirectory()); - return host.getSourceFile(referenceFileName); - } - } - ts.tryResolveScriptReference = tryResolveScriptReference; - function getAncestor(node, kind) { - while (node) { - if (node.kind === kind) { - return node; - } - node = node.parent; - } - return undefined; - } - ts.getAncestor = getAncestor; - function getFileReferenceFromReferencePath(comment, commentRange) { - var simpleReferenceRegEx = /^\/\/\/\s*/gim; - if (simpleReferenceRegEx.exec(comment)) { - if (isNoDefaultLibRegEx.exec(comment)) { - return { - isNoDefaultLib: true - }; - } - else { - var matchResult = ts.fullTripleSlashReferencePathRegEx.exec(comment); - if (matchResult) { - var start = commentRange.pos; - var end = commentRange.end; - return { - fileReference: { - pos: start, - end: end, - fileName: matchResult[3] - }, - isNoDefaultLib: false - }; - } - else { - return { - diagnosticMessage: ts.Diagnostics.Invalid_reference_directive_syntax, - isNoDefaultLib: false - }; - } - } - } - return undefined; - } - ts.getFileReferenceFromReferencePath = getFileReferenceFromReferencePath; - function isKeyword(token) { - return 70 /* FirstKeyword */ <= token && token <= 134 /* LastKeyword */; - } - ts.isKeyword = isKeyword; - function isTrivia(token) { - return 2 /* FirstTriviaToken */ <= token && token <= 7 /* LastTriviaToken */; - } - ts.isTrivia = isTrivia; - function isAsyncFunctionLike(node) { - return isFunctionLike(node) && (node.flags & 512 /* Async */) !== 0 && !isAccessor(node); - } - ts.isAsyncFunctionLike = isAsyncFunctionLike; - /** - * A declaration has a dynamic name if both of the following are true: - * 1. The declaration has a computed property name - * 2. The computed name is *not* expressed as Symbol., where name - * is a property of the Symbol constructor that denotes a built in - * Symbol. - */ - function hasDynamicName(declaration) { - return declaration.name && - declaration.name.kind === 136 /* ComputedPropertyName */ && - !isWellKnownSymbolSyntactically(declaration.name.expression); - } - ts.hasDynamicName = hasDynamicName; - /** - * Checks if the expression is of the form: - * Symbol.name - * where Symbol is literally the word "Symbol", and name is any identifierName - */ - function isWellKnownSymbolSyntactically(node) { - return isPropertyAccessExpression(node) && isESSymbolIdentifier(node.expression); - } - ts.isWellKnownSymbolSyntactically = isWellKnownSymbolSyntactically; - function getPropertyNameForPropertyNameNode(name) { - if (name.kind === 69 /* Identifier */ || name.kind === 9 /* StringLiteral */ || name.kind === 8 /* NumericLiteral */) { - return name.text; - } - if (name.kind === 136 /* ComputedPropertyName */) { - var nameExpression = name.expression; - if (isWellKnownSymbolSyntactically(nameExpression)) { - var rightHandSideName = nameExpression.name.text; - return getPropertyNameForKnownSymbolName(rightHandSideName); - } - } - return undefined; - } - ts.getPropertyNameForPropertyNameNode = getPropertyNameForPropertyNameNode; - function getPropertyNameForKnownSymbolName(symbolName) { - return "__@" + symbolName; - } - ts.getPropertyNameForKnownSymbolName = getPropertyNameForKnownSymbolName; - /** - * Includes the word "Symbol" with unicode escapes - */ - function isESSymbolIdentifier(node) { - return node.kind === 69 /* Identifier */ && node.text === "Symbol"; - } - ts.isESSymbolIdentifier = isESSymbolIdentifier; - function isModifier(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 113 /* StaticKeyword */: - return true; - } - return false; - } - ts.isModifier = isModifier; - function isParameterDeclaration(node) { - var root = getRootDeclaration(node); - return root.kind === 138 /* Parameter */; - } - ts.isParameterDeclaration = isParameterDeclaration; - function getRootDeclaration(node) { - while (node.kind === 163 /* BindingElement */) { - node = node.parent.parent; - } - return node; - } - ts.getRootDeclaration = getRootDeclaration; - function nodeStartsNewLexicalEnvironment(n) { - return isFunctionLike(n) || n.kind === 218 /* ModuleDeclaration */ || n.kind === 248 /* SourceFile */; - } - ts.nodeStartsNewLexicalEnvironment = nodeStartsNewLexicalEnvironment; - function cloneEntityName(node) { - if (node.kind === 69 /* Identifier */) { - var clone_1 = createSynthesizedNode(69 /* Identifier */); - clone_1.text = node.text; - return clone_1; - } - else { - var clone_2 = createSynthesizedNode(135 /* QualifiedName */); - clone_2.left = cloneEntityName(node.left); - clone_2.left.parent = clone_2; - clone_2.right = cloneEntityName(node.right); - clone_2.right.parent = clone_2; - return clone_2; - } - } - ts.cloneEntityName = cloneEntityName; - function nodeIsSynthesized(node) { - return node.pos === -1; - } - ts.nodeIsSynthesized = nodeIsSynthesized; - function createSynthesizedNode(kind, startsOnNewLine) { - var node = ts.createNode(kind, /* pos */ -1, /* end */ -1); - node.startsOnNewLine = startsOnNewLine; - return node; - } - ts.createSynthesizedNode = createSynthesizedNode; - function createSynthesizedNodeArray() { - var array = []; - array.pos = -1; - array.end = -1; - return array; - } - ts.createSynthesizedNodeArray = createSynthesizedNodeArray; - function createDiagnosticCollection() { - var nonFileDiagnostics = []; - var fileDiagnostics = {}; - var diagnosticsModified = false; - var modificationCount = 0; - return { - add: add, - getGlobalDiagnostics: getGlobalDiagnostics, - getDiagnostics: getDiagnostics, - getModificationCount: getModificationCount, - reattachFileDiagnostics: reattachFileDiagnostics - }; - function getModificationCount() { - return modificationCount; - } - function reattachFileDiagnostics(newFile) { - if (!ts.hasProperty(fileDiagnostics, newFile.fileName)) { - return; - } - for (var _i = 0, _a = fileDiagnostics[newFile.fileName]; _i < _a.length; _i++) { - var diagnostic = _a[_i]; - diagnostic.file = newFile; - } - } - function add(diagnostic) { - var diagnostics; - if (diagnostic.file) { - diagnostics = fileDiagnostics[diagnostic.file.fileName]; - if (!diagnostics) { - diagnostics = []; - fileDiagnostics[diagnostic.file.fileName] = diagnostics; - } - } - else { - diagnostics = nonFileDiagnostics; - } - diagnostics.push(diagnostic); - diagnosticsModified = true; - modificationCount++; - } - function getGlobalDiagnostics() { - sortAndDeduplicate(); - return nonFileDiagnostics; - } - function getDiagnostics(fileName) { - sortAndDeduplicate(); - if (fileName) { - return fileDiagnostics[fileName] || []; - } - var allDiagnostics = []; - function pushDiagnostic(d) { - allDiagnostics.push(d); - } - ts.forEach(nonFileDiagnostics, pushDiagnostic); - for (var key in fileDiagnostics) { - if (ts.hasProperty(fileDiagnostics, key)) { - ts.forEach(fileDiagnostics[key], pushDiagnostic); - } - } - return ts.sortAndDeduplicateDiagnostics(allDiagnostics); - } - function sortAndDeduplicate() { - if (!diagnosticsModified) { - return; - } - diagnosticsModified = false; - nonFileDiagnostics = ts.sortAndDeduplicateDiagnostics(nonFileDiagnostics); - for (var key in fileDiagnostics) { - if (ts.hasProperty(fileDiagnostics, key)) { - fileDiagnostics[key] = ts.sortAndDeduplicateDiagnostics(fileDiagnostics[key]); - } - } - } - } - ts.createDiagnosticCollection = createDiagnosticCollection; - // This consists of the first 19 unprintable ASCII characters, canonical escapes, lineSeparator, - // paragraphSeparator, and nextLine. The latter three are just desirable to suppress new lines in - // the language service. These characters should be escaped when printing, and if any characters are added, - // the map below must be updated. Note that this regexp *does not* include the 'delete' character. - // There is no reason for this other than that JSON.stringify does not handle it either. - var escapedCharsRegExp = /[\\\"\u0000-\u001f\t\v\f\b\r\n\u2028\u2029\u0085]/g; - var escapedCharsMap = { - "\0": "\\0", - "\t": "\\t", - "\v": "\\v", - "\f": "\\f", - "\b": "\\b", - "\r": "\\r", - "\n": "\\n", - "\\": "\\\\", - "\"": "\\\"", - "\u2028": "\\u2028", - "\u2029": "\\u2029", - "\u0085": "\\u0085" // nextLine - }; - /** - * Based heavily on the abstract 'Quote'/'QuoteJSONString' operation from ECMA-262 (24.3.2.2), - * but augmented for a few select characters (e.g. lineSeparator, paragraphSeparator, nextLine) - * Note that this doesn't actually wrap the input in double quotes. - */ - function escapeString(s) { - s = escapedCharsRegExp.test(s) ? s.replace(escapedCharsRegExp, getReplacement) : s; - return s; - function getReplacement(c) { - return escapedCharsMap[c] || get16BitUnicodeEscapeSequence(c.charCodeAt(0)); - } - } - ts.escapeString = escapeString; - function isIntrinsicJsxName(name) { - var ch = name.substr(0, 1); - return ch.toLowerCase() === ch; - } - ts.isIntrinsicJsxName = isIntrinsicJsxName; - function get16BitUnicodeEscapeSequence(charCode) { - var hexCharCode = charCode.toString(16).toUpperCase(); - var paddedHexCode = ("0000" + hexCharCode).slice(-4); - return "\\u" + paddedHexCode; - } - var nonAsciiCharacters = /[^\u0000-\u007F]/g; - function escapeNonAsciiCharacters(s) { - // Replace non-ASCII characters with '\uNNNN' escapes if any exist. - // Otherwise just return the original string. - return nonAsciiCharacters.test(s) ? - s.replace(nonAsciiCharacters, function (c) { return get16BitUnicodeEscapeSequence(c.charCodeAt(0)); }) : - s; - } - ts.escapeNonAsciiCharacters = escapeNonAsciiCharacters; - var indentStrings = ["", " "]; - function getIndentString(level) { - if (indentStrings[level] === undefined) { - indentStrings[level] = getIndentString(level - 1) + indentStrings[1]; - } - return indentStrings[level]; - } - ts.getIndentString = getIndentString; - function getIndentSize() { - return indentStrings[1].length; - } - ts.getIndentSize = getIndentSize; - function createTextWriter(newLine) { - var output = ""; - var indent = 0; - var lineStart = true; - var lineCount = 0; - var linePos = 0; - function write(s) { - if (s && s.length) { - if (lineStart) { - output += getIndentString(indent); - lineStart = false; - } - output += s; - } - } - function rawWrite(s) { - if (s !== undefined) { - if (lineStart) { - lineStart = false; - } - output += s; - } - } - function writeLiteral(s) { - if (s && s.length) { - write(s); - var lineStartsOfS = ts.computeLineStarts(s); - if (lineStartsOfS.length > 1) { - lineCount = lineCount + lineStartsOfS.length - 1; - linePos = output.length - s.length + ts.lastOrUndefined(lineStartsOfS); - } - } - } - function writeLine() { - if (!lineStart) { - output += newLine; - lineCount++; - linePos = output.length; - lineStart = true; - } - } - function writeTextOfNode(sourceFile, node) { - write(getSourceTextOfNodeFromSourceFile(sourceFile, node)); - } - return { - write: write, - rawWrite: rawWrite, - writeTextOfNode: writeTextOfNode, - writeLiteral: writeLiteral, - writeLine: writeLine, - increaseIndent: function () { return indent++; }, - decreaseIndent: function () { return indent--; }, - getIndent: function () { return indent; }, - getTextPos: function () { return output.length; }, - getLine: function () { return lineCount + 1; }, - getColumn: function () { return lineStart ? indent * getIndentSize() + 1 : output.length - linePos + 1; }, - getText: function () { return output; } - }; - } - ts.createTextWriter = createTextWriter; - function getOwnEmitOutputFilePath(sourceFile, host, extension) { - var compilerOptions = host.getCompilerOptions(); - var emitOutputFilePathWithoutExtension; - if (compilerOptions.outDir) { - emitOutputFilePathWithoutExtension = ts.removeFileExtension(getSourceFilePathInNewDir(sourceFile, host, compilerOptions.outDir)); - } - else { - emitOutputFilePathWithoutExtension = ts.removeFileExtension(sourceFile.fileName); - } - return emitOutputFilePathWithoutExtension + extension; - } - ts.getOwnEmitOutputFilePath = getOwnEmitOutputFilePath; - function getSourceFilePathInNewDir(sourceFile, host, newDirPath) { - var sourceFilePath = ts.getNormalizedAbsolutePath(sourceFile.fileName, host.getCurrentDirectory()); - sourceFilePath = sourceFilePath.replace(host.getCommonSourceDirectory(), ""); - return ts.combinePaths(newDirPath, sourceFilePath); - } - ts.getSourceFilePathInNewDir = getSourceFilePathInNewDir; - function writeFile(host, diagnostics, fileName, data, writeByteOrderMark) { - host.writeFile(fileName, data, writeByteOrderMark, function (hostErrorMessage) { - diagnostics.push(ts.createCompilerDiagnostic(ts.Diagnostics.Could_not_write_file_0_Colon_1, fileName, hostErrorMessage)); - }); - } - ts.writeFile = writeFile; - function getLineOfLocalPosition(currentSourceFile, pos) { - return ts.getLineAndCharacterOfPosition(currentSourceFile, pos).line; - } - ts.getLineOfLocalPosition = getLineOfLocalPosition; - function getFirstConstructorWithBody(node) { - return ts.forEach(node.members, function (member) { - if (member.kind === 144 /* Constructor */ && nodeIsPresent(member.body)) { - return member; - } - }); - } - ts.getFirstConstructorWithBody = getFirstConstructorWithBody; - function getSetAccessorTypeAnnotationNode(accessor) { - return accessor && accessor.parameters.length > 0 && accessor.parameters[0].type; - } - ts.getSetAccessorTypeAnnotationNode = getSetAccessorTypeAnnotationNode; - function shouldEmitToOwnFile(sourceFile, compilerOptions) { - if (!isDeclarationFile(sourceFile)) { - if ((isExternalModule(sourceFile) || !(compilerOptions.outFile || compilerOptions.out))) { - // 1. in-browser single file compilation scenario - // 2. non .js file - return compilerOptions.isolatedModules || !ts.fileExtensionIs(sourceFile.fileName, ".js"); - } - return false; - } - return false; - } - ts.shouldEmitToOwnFile = shouldEmitToOwnFile; - function getAllAccessorDeclarations(declarations, accessor) { - var firstAccessor; - var secondAccessor; - var getAccessor; - var setAccessor; - if (hasDynamicName(accessor)) { - firstAccessor = accessor; - if (accessor.kind === 145 /* GetAccessor */) { - getAccessor = accessor; - } - else if (accessor.kind === 146 /* SetAccessor */) { - setAccessor = accessor; - } - else { - ts.Debug.fail("Accessor has wrong kind"); - } - } - else { - ts.forEach(declarations, function (member) { - if ((member.kind === 145 /* GetAccessor */ || member.kind === 146 /* SetAccessor */) - && (member.flags & 128 /* Static */) === (accessor.flags & 128 /* Static */)) { - var memberName = getPropertyNameForPropertyNameNode(member.name); - var accessorName = getPropertyNameForPropertyNameNode(accessor.name); - if (memberName === accessorName) { - if (!firstAccessor) { - firstAccessor = member; - } - else if (!secondAccessor) { - secondAccessor = member; - } - if (member.kind === 145 /* GetAccessor */ && !getAccessor) { - getAccessor = member; - } - if (member.kind === 146 /* SetAccessor */ && !setAccessor) { - setAccessor = member; - } - } - } - }); - } - return { - firstAccessor: firstAccessor, - secondAccessor: secondAccessor, - getAccessor: getAccessor, - setAccessor: setAccessor - }; - } - ts.getAllAccessorDeclarations = getAllAccessorDeclarations; - function emitNewLineBeforeLeadingComments(currentSourceFile, writer, node, leadingComments) { - // If the leading comments start on different line than the start of node, write new line - if (leadingComments && leadingComments.length && node.pos !== leadingComments[0].pos && - getLineOfLocalPosition(currentSourceFile, node.pos) !== getLineOfLocalPosition(currentSourceFile, leadingComments[0].pos)) { - writer.writeLine(); - } - } - ts.emitNewLineBeforeLeadingComments = emitNewLineBeforeLeadingComments; - function emitComments(currentSourceFile, writer, comments, trailingSeparator, newLine, writeComment) { - var emitLeadingSpace = !trailingSeparator; - ts.forEach(comments, function (comment) { - if (emitLeadingSpace) { - writer.write(" "); - emitLeadingSpace = false; - } - writeComment(currentSourceFile, writer, comment, newLine); - if (comment.hasTrailingNewLine) { - writer.writeLine(); - } - else if (trailingSeparator) { - writer.write(" "); - } - else { - // Emit leading space to separate comment during next comment emit - emitLeadingSpace = true; - } - }); - } - ts.emitComments = emitComments; - function writeCommentRange(currentSourceFile, writer, comment, newLine) { - if (currentSourceFile.text.charCodeAt(comment.pos + 1) === 42 /* asterisk */) { - var firstCommentLineAndCharacter = ts.getLineAndCharacterOfPosition(currentSourceFile, comment.pos); - var lineCount = ts.getLineStarts(currentSourceFile).length; - var firstCommentLineIndent; - for (var pos = comment.pos, currentLine = firstCommentLineAndCharacter.line; pos < comment.end; currentLine++) { - var nextLineStart = (currentLine + 1) === lineCount - ? currentSourceFile.text.length + 1 - : getStartPositionOfLine(currentLine + 1, currentSourceFile); - if (pos !== comment.pos) { - // If we are not emitting first line, we need to write the spaces to adjust the alignment - if (firstCommentLineIndent === undefined) { - firstCommentLineIndent = calculateIndent(getStartPositionOfLine(firstCommentLineAndCharacter.line, currentSourceFile), comment.pos); - } - // These are number of spaces writer is going to write at current indent - var currentWriterIndentSpacing = writer.getIndent() * getIndentSize(); - // Number of spaces we want to be writing - // eg: Assume writer indent - // module m { - // /* starts at character 9 this is line 1 - // * starts at character pos 4 line --1 = 8 - 8 + 3 - // More left indented comment */ --2 = 8 - 8 + 2 - // class c { } - // } - // module m { - // /* this is line 1 -- Assume current writer indent 8 - // * line --3 = 8 - 4 + 5 - // More right indented comment */ --4 = 8 - 4 + 11 - // class c { } - // } - var spacesToEmit = currentWriterIndentSpacing - firstCommentLineIndent + calculateIndent(pos, nextLineStart); - if (spacesToEmit > 0) { - var numberOfSingleSpacesToEmit = spacesToEmit % getIndentSize(); - var indentSizeSpaceString = getIndentString((spacesToEmit - numberOfSingleSpacesToEmit) / getIndentSize()); - // Write indent size string ( in eg 1: = "", 2: "" , 3: string with 8 spaces 4: string with 12 spaces - writer.rawWrite(indentSizeSpaceString); - // Emit the single spaces (in eg: 1: 3 spaces, 2: 2 spaces, 3: 1 space, 4: 3 spaces) - while (numberOfSingleSpacesToEmit) { - writer.rawWrite(" "); - numberOfSingleSpacesToEmit--; - } - } - else { - // No spaces to emit write empty string - writer.rawWrite(""); - } - } - // Write the comment line text - writeTrimmedCurrentLine(pos, nextLineStart); - pos = nextLineStart; - } - } - else { - // Single line comment of style //.... - writer.write(currentSourceFile.text.substring(comment.pos, comment.end)); - } - function writeTrimmedCurrentLine(pos, nextLineStart) { - var end = Math.min(comment.end, nextLineStart - 1); - var currentLineText = currentSourceFile.text.substring(pos, end).replace(/^\s+|\s+$/g, ""); - if (currentLineText) { - // trimmed forward and ending spaces text - writer.write(currentLineText); - if (end !== comment.end) { - writer.writeLine(); - } - } - else { - // Empty string - make sure we write empty line - writer.writeLiteral(newLine); - } - } - function calculateIndent(pos, end) { - var currentLineIndent = 0; - for (; pos < end && ts.isWhiteSpace(currentSourceFile.text.charCodeAt(pos)); pos++) { - if (currentSourceFile.text.charCodeAt(pos) === 9 /* tab */) { - // Tabs = TabSize = indent size and go to next tabStop - currentLineIndent += getIndentSize() - (currentLineIndent % getIndentSize()); - } - else { - // Single space - currentLineIndent++; - } - } - return currentLineIndent; - } - } - ts.writeCommentRange = writeCommentRange; - function modifierToFlag(token) { - switch (token) { - case 113 /* StaticKeyword */: return 128 /* Static */; - case 112 /* PublicKeyword */: return 16 /* Public */; - case 111 /* ProtectedKeyword */: return 64 /* Protected */; - case 110 /* PrivateKeyword */: return 32 /* Private */; - case 115 /* AbstractKeyword */: return 256 /* Abstract */; - case 82 /* ExportKeyword */: return 1 /* Export */; - case 122 /* DeclareKeyword */: return 2 /* Ambient */; - case 74 /* ConstKeyword */: return 32768 /* Const */; - case 77 /* DefaultKeyword */: return 1024 /* Default */; - case 118 /* AsyncKeyword */: return 512 /* Async */; - } - return 0; - } - ts.modifierToFlag = modifierToFlag; - function isLeftHandSideExpression(expr) { - if (expr) { - switch (expr.kind) { - case 166 /* PropertyAccessExpression */: - case 167 /* ElementAccessExpression */: - case 169 /* NewExpression */: - case 168 /* CallExpression */: - case 233 /* JsxElement */: - case 234 /* JsxSelfClosingElement */: - case 170 /* TaggedTemplateExpression */: - case 164 /* ArrayLiteralExpression */: - case 172 /* ParenthesizedExpression */: - case 165 /* ObjectLiteralExpression */: - case 186 /* ClassExpression */: - case 173 /* FunctionExpression */: - case 69 /* Identifier */: - case 10 /* RegularExpressionLiteral */: - case 8 /* NumericLiteral */: - case 9 /* StringLiteral */: - case 11 /* NoSubstitutionTemplateLiteral */: - case 183 /* TemplateExpression */: - case 84 /* FalseKeyword */: - case 93 /* NullKeyword */: - case 97 /* ThisKeyword */: - case 99 /* TrueKeyword */: - case 95 /* SuperKeyword */: - return true; - } - } - return false; - } - ts.isLeftHandSideExpression = isLeftHandSideExpression; - function isAssignmentOperator(token) { - return token >= 56 /* FirstAssignment */ && token <= 68 /* LastAssignment */; - } - ts.isAssignmentOperator = isAssignmentOperator; - function isExpressionWithTypeArgumentsInClassExtendsClause(node) { - return node.kind === 188 /* ExpressionWithTypeArguments */ && - node.parent.token === 83 /* ExtendsKeyword */ && - isClassLike(node.parent.parent); - } - ts.isExpressionWithTypeArgumentsInClassExtendsClause = isExpressionWithTypeArgumentsInClassExtendsClause; - // Returns false if this heritage clause element's expression contains something unsupported - // (i.e. not a name or dotted name). - function isSupportedExpressionWithTypeArguments(node) { - return isSupportedExpressionWithTypeArgumentsRest(node.expression); - } - ts.isSupportedExpressionWithTypeArguments = isSupportedExpressionWithTypeArguments; - function isSupportedExpressionWithTypeArgumentsRest(node) { - if (node.kind === 69 /* Identifier */) { - return true; - } - else if (isPropertyAccessExpression(node)) { - return isSupportedExpressionWithTypeArgumentsRest(node.expression); - } - else { - return false; - } - } - function isRightSideOfQualifiedNameOrPropertyAccess(node) { - return (node.parent.kind === 135 /* QualifiedName */ && node.parent.right === node) || - (node.parent.kind === 166 /* PropertyAccessExpression */ && node.parent.name === node); - } - ts.isRightSideOfQualifiedNameOrPropertyAccess = isRightSideOfQualifiedNameOrPropertyAccess; - function isEmptyObjectLiteralOrArrayLiteral(expression) { - var kind = expression.kind; - if (kind === 165 /* ObjectLiteralExpression */) { - return expression.properties.length === 0; - } - if (kind === 164 /* ArrayLiteralExpression */) { - return expression.elements.length === 0; - } - return false; - } - ts.isEmptyObjectLiteralOrArrayLiteral = isEmptyObjectLiteralOrArrayLiteral; - function getLocalSymbolForExportDefault(symbol) { - return symbol && symbol.valueDeclaration && (symbol.valueDeclaration.flags & 1024 /* Default */) ? symbol.valueDeclaration.localSymbol : undefined; - } - ts.getLocalSymbolForExportDefault = getLocalSymbolForExportDefault; - function isJavaScript(fileName) { - return ts.fileExtensionIs(fileName, ".js"); - } - ts.isJavaScript = isJavaScript; - function isTsx(fileName) { - return ts.fileExtensionIs(fileName, ".tsx"); - } - ts.isTsx = isTsx; - /** - * Replace each instance of non-ascii characters by one, two, three, or four escape sequences - * representing the UTF-8 encoding of the character, and return the expanded char code list. - */ - function getExpandedCharCodes(input) { - var output = []; - var length = input.length; - for (var i = 0; i < length; i++) { - var charCode = input.charCodeAt(i); - // handel utf8 - if (charCode < 0x80) { - output.push(charCode); - } - else if (charCode < 0x800) { - output.push((charCode >> 6) | 192); - output.push((charCode & 63) | 128); - } - else if (charCode < 0x10000) { - output.push((charCode >> 12) | 224); - output.push(((charCode >> 6) & 63) | 128); - output.push((charCode & 63) | 128); - } - else if (charCode < 0x20000) { - output.push((charCode >> 18) | 240); - output.push(((charCode >> 12) & 63) | 128); - output.push(((charCode >> 6) & 63) | 128); - output.push((charCode & 63) | 128); - } - else { - ts.Debug.assert(false, "Unexpected code point"); - } - } - return output; - } - var base64Digits = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="; - /** - * Converts a string to a base-64 encoded ASCII string. - */ - function convertToBase64(input) { - var result = ""; - var charCodes = getExpandedCharCodes(input); - var i = 0; - var length = charCodes.length; - var byte1, byte2, byte3, byte4; - while (i < length) { - // Convert every 6-bits in the input 3 character points - // into a base64 digit - byte1 = charCodes[i] >> 2; - byte2 = (charCodes[i] & 3) << 4 | charCodes[i + 1] >> 4; - byte3 = (charCodes[i + 1] & 15) << 2 | charCodes[i + 2] >> 6; - byte4 = charCodes[i + 2] & 63; - // We are out of characters in the input, set the extra - // digits to 64 (padding character). - if (i + 1 >= length) { - byte3 = byte4 = 64; - } - else if (i + 2 >= length) { - byte4 = 64; - } - // Write to the ouput - result += base64Digits.charAt(byte1) + base64Digits.charAt(byte2) + base64Digits.charAt(byte3) + base64Digits.charAt(byte4); - i += 3; - } - return result; - } - ts.convertToBase64 = convertToBase64; - var carriageReturnLineFeed = "\r\n"; - var lineFeed = "\n"; - function getNewLineCharacter(options) { - if (options.newLine === 0 /* CarriageReturnLineFeed */) { - return carriageReturnLineFeed; - } - else if (options.newLine === 1 /* LineFeed */) { - return lineFeed; - } - else if (ts.sys) { - return ts.sys.newLine; - } - return carriageReturnLineFeed; - } - ts.getNewLineCharacter = getNewLineCharacter; -})(ts || (ts = {})); -var ts; -(function (ts) { - function getDefaultLibFileName(options) { - return options.target === 2 /* ES6 */ ? "lib.es6.d.ts" : "lib.d.ts"; - } - ts.getDefaultLibFileName = getDefaultLibFileName; - function textSpanEnd(span) { - return span.start + span.length; - } - ts.textSpanEnd = textSpanEnd; - function textSpanIsEmpty(span) { - return span.length === 0; - } - ts.textSpanIsEmpty = textSpanIsEmpty; - function textSpanContainsPosition(span, position) { - return position >= span.start && position < textSpanEnd(span); - } - ts.textSpanContainsPosition = textSpanContainsPosition; - // Returns true if 'span' contains 'other'. - function textSpanContainsTextSpan(span, other) { - return other.start >= span.start && textSpanEnd(other) <= textSpanEnd(span); - } - ts.textSpanContainsTextSpan = textSpanContainsTextSpan; - function textSpanOverlapsWith(span, other) { - var overlapStart = Math.max(span.start, other.start); - var overlapEnd = Math.min(textSpanEnd(span), textSpanEnd(other)); - return overlapStart < overlapEnd; - } - ts.textSpanOverlapsWith = textSpanOverlapsWith; - function textSpanOverlap(span1, span2) { - var overlapStart = Math.max(span1.start, span2.start); - var overlapEnd = Math.min(textSpanEnd(span1), textSpanEnd(span2)); - if (overlapStart < overlapEnd) { - return createTextSpanFromBounds(overlapStart, overlapEnd); - } - return undefined; - } - ts.textSpanOverlap = textSpanOverlap; - function textSpanIntersectsWithTextSpan(span, other) { - return other.start <= textSpanEnd(span) && textSpanEnd(other) >= span.start; - } - ts.textSpanIntersectsWithTextSpan = textSpanIntersectsWithTextSpan; - function textSpanIntersectsWith(span, start, length) { - var end = start + length; - return start <= textSpanEnd(span) && end >= span.start; - } - ts.textSpanIntersectsWith = textSpanIntersectsWith; - function decodedTextSpanIntersectsWith(start1, length1, start2, length2) { - var end1 = start1 + length1; - var end2 = start2 + length2; - return start2 <= end1 && end2 >= start1; - } - ts.decodedTextSpanIntersectsWith = decodedTextSpanIntersectsWith; - function textSpanIntersectsWithPosition(span, position) { - return position <= textSpanEnd(span) && position >= span.start; - } - ts.textSpanIntersectsWithPosition = textSpanIntersectsWithPosition; - function textSpanIntersection(span1, span2) { - var intersectStart = Math.max(span1.start, span2.start); - var intersectEnd = Math.min(textSpanEnd(span1), textSpanEnd(span2)); - if (intersectStart <= intersectEnd) { - return createTextSpanFromBounds(intersectStart, intersectEnd); - } - return undefined; - } - ts.textSpanIntersection = textSpanIntersection; - function createTextSpan(start, length) { - if (start < 0) { - throw new Error("start < 0"); - } - if (length < 0) { - throw new Error("length < 0"); - } - return { start: start, length: length }; - } - ts.createTextSpan = createTextSpan; - function createTextSpanFromBounds(start, end) { - return createTextSpan(start, end - start); - } - ts.createTextSpanFromBounds = createTextSpanFromBounds; - function textChangeRangeNewSpan(range) { - return createTextSpan(range.span.start, range.newLength); - } - ts.textChangeRangeNewSpan = textChangeRangeNewSpan; - function textChangeRangeIsUnchanged(range) { - return textSpanIsEmpty(range.span) && range.newLength === 0; - } - ts.textChangeRangeIsUnchanged = textChangeRangeIsUnchanged; - function createTextChangeRange(span, newLength) { - if (newLength < 0) { - throw new Error("newLength < 0"); - } - return { span: span, newLength: newLength }; - } - ts.createTextChangeRange = createTextChangeRange; - ts.unchangedTextChangeRange = createTextChangeRange(createTextSpan(0, 0), 0); - /** - * Called to merge all the changes that occurred across several versions of a script snapshot - * into a single change. i.e. if a user keeps making successive edits to a script we will - * have a text change from V1 to V2, V2 to V3, ..., Vn. - * - * This function will then merge those changes into a single change range valid between V1 and - * Vn. - */ - function collapseTextChangeRangesAcrossMultipleVersions(changes) { - if (changes.length === 0) { - return ts.unchangedTextChangeRange; - } - if (changes.length === 1) { - return changes[0]; - } - // We change from talking about { { oldStart, oldLength }, newLength } to { oldStart, oldEnd, newEnd } - // as it makes things much easier to reason about. - var change0 = changes[0]; - var oldStartN = change0.span.start; - var oldEndN = textSpanEnd(change0.span); - var newEndN = oldStartN + change0.newLength; - for (var i = 1; i < changes.length; i++) { - var nextChange = changes[i]; - // Consider the following case: - // i.e. two edits. The first represents the text change range { { 10, 50 }, 30 }. i.e. The span starting - // at 10, with length 50 is reduced to length 30. The second represents the text change range { { 30, 30 }, 40 }. - // i.e. the span starting at 30 with length 30 is increased to length 40. - // - // 0 10 20 30 40 50 60 70 80 90 100 - // ------------------------------------------------------------------------------------------------------- - // | / - // | /---- - // T1 | /---- - // | /---- - // | /---- - // ------------------------------------------------------------------------------------------------------- - // | \ - // | \ - // T2 | \ - // | \ - // | \ - // ------------------------------------------------------------------------------------------------------- - // - // Merging these turns out to not be too difficult. First, determining the new start of the change is trivial - // it's just the min of the old and new starts. i.e.: - // - // 0 10 20 30 40 50 60 70 80 90 100 - // ------------------------------------------------------------*------------------------------------------ - // | / - // | /---- - // T1 | /---- - // | /---- - // | /---- - // ----------------------------------------$-------------------$------------------------------------------ - // . | \ - // . | \ - // T2 . | \ - // . | \ - // . | \ - // ----------------------------------------------------------------------*-------------------------------- - // - // (Note the dots represent the newly inferrred start. - // Determining the new and old end is also pretty simple. Basically it boils down to paying attention to the - // absolute positions at the asterixes, and the relative change between the dollar signs. Basically, we see - // which if the two $'s precedes the other, and we move that one forward until they line up. in this case that - // means: - // - // 0 10 20 30 40 50 60 70 80 90 100 - // --------------------------------------------------------------------------------*---------------------- - // | / - // | /---- - // T1 | /---- - // | /---- - // | /---- - // ------------------------------------------------------------$------------------------------------------ - // . | \ - // . | \ - // T2 . | \ - // . | \ - // . | \ - // ----------------------------------------------------------------------*-------------------------------- - // - // In other words (in this case), we're recognizing that the second edit happened after where the first edit - // ended with a delta of 20 characters (60 - 40). Thus, if we go back in time to where the first edit started - // that's the same as if we started at char 80 instead of 60. - // - // As it so happens, the same logic applies if the second edit precedes the first edit. In that case rahter - // than pusing the first edit forward to match the second, we'll push the second edit forward to match the - // first. - // - // In this case that means we have { oldStart: 10, oldEnd: 80, newEnd: 70 } or, in TextChangeRange - // semantics: { { start: 10, length: 70 }, newLength: 60 } - // - // The math then works out as follows. - // If we have { oldStart1, oldEnd1, newEnd1 } and { oldStart2, oldEnd2, newEnd2 } then we can compute the - // final result like so: - // - // { - // oldStart3: Min(oldStart1, oldStart2), - // oldEnd3 : Max(oldEnd1, oldEnd1 + (oldEnd2 - newEnd1)), - // newEnd3 : Max(newEnd2, newEnd2 + (newEnd1 - oldEnd2)) - // } - var oldStart1 = oldStartN; - var oldEnd1 = oldEndN; - var newEnd1 = newEndN; - var oldStart2 = nextChange.span.start; - var oldEnd2 = textSpanEnd(nextChange.span); - var newEnd2 = oldStart2 + nextChange.newLength; - oldStartN = Math.min(oldStart1, oldStart2); - oldEndN = Math.max(oldEnd1, oldEnd1 + (oldEnd2 - newEnd1)); - newEndN = Math.max(newEnd2, newEnd2 + (newEnd1 - oldEnd2)); - } - return createTextChangeRange(createTextSpanFromBounds(oldStartN, oldEndN), /*newLength:*/ newEndN - oldStartN); - } - ts.collapseTextChangeRangesAcrossMultipleVersions = collapseTextChangeRangesAcrossMultipleVersions; - function getTypeParameterOwner(d) { - if (d && d.kind === 137 /* TypeParameter */) { - for (var current = d; current; current = current.parent) { - if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 215 /* InterfaceDeclaration */) { - return current; - } - } - } - } - ts.getTypeParameterOwner = getTypeParameterOwner; -})(ts || (ts = {})); -/// -/// -var ts; -(function (ts) { - var nodeConstructors = new Array(272 /* Count */); - /* @internal */ ts.parseTime = 0; - function getNodeConstructor(kind) { - return nodeConstructors[kind] || (nodeConstructors[kind] = ts.objectAllocator.getNodeConstructor(kind)); - } - ts.getNodeConstructor = getNodeConstructor; - function createNode(kind, pos, end) { - return new (getNodeConstructor(kind))(pos, end); - } - ts.createNode = createNode; - function visitNode(cbNode, node) { - if (node) { - return cbNode(node); - } - } - function visitNodeArray(cbNodes, nodes) { - if (nodes) { - return cbNodes(nodes); - } - } - function visitEachNode(cbNode, nodes) { - if (nodes) { - for (var _i = 0; _i < nodes.length; _i++) { - var node = nodes[_i]; - var result = cbNode(node); - if (result) { - return result; - } - } - } - } - // Invokes a callback for each child of the given node. The 'cbNode' callback is invoked for all child nodes - // stored in properties. If a 'cbNodes' callback is specified, it is invoked for embedded arrays; otherwise, - // embedded arrays are flattened and the 'cbNode' callback is invoked for each element. If a callback returns - // a truthy value, iteration stops and that value is returned. Otherwise, undefined is returned. - function forEachChild(node, cbNode, cbNodeArray) { - if (!node) { - return; - } - // The visitXXX functions could be written as local functions that close over the cbNode and cbNodeArray - // callback parameters, but that causes a closure allocation for each invocation with noticeable effects - // on performance. - var visitNodes = cbNodeArray ? visitNodeArray : visitEachNode; - var cbNodes = cbNodeArray || cbNode; - switch (node.kind) { - case 135 /* QualifiedName */: - return visitNode(cbNode, node.left) || - visitNode(cbNode, node.right); - case 137 /* TypeParameter */: - return visitNode(cbNode, node.name) || - visitNode(cbNode, node.constraint) || - visitNode(cbNode, node.expression); - case 246 /* ShorthandPropertyAssignment */: - return visitNodes(cbNodes, node.decorators) || - visitNodes(cbNodes, node.modifiers) || - visitNode(cbNode, node.name) || - visitNode(cbNode, node.questionToken) || - visitNode(cbNode, node.equalsToken) || - visitNode(cbNode, node.objectAssignmentInitializer); - case 138 /* Parameter */: - case 141 /* PropertyDeclaration */: - case 140 /* PropertySignature */: - case 245 /* PropertyAssignment */: - case 211 /* VariableDeclaration */: - case 163 /* BindingElement */: - return visitNodes(cbNodes, node.decorators) || - visitNodes(cbNodes, node.modifiers) || - visitNode(cbNode, node.propertyName) || - visitNode(cbNode, node.dotDotDotToken) || - visitNode(cbNode, node.name) || - visitNode(cbNode, node.questionToken) || - visitNode(cbNode, node.type) || - visitNode(cbNode, node.initializer); - case 152 /* FunctionType */: - case 153 /* ConstructorType */: - case 147 /* CallSignature */: - case 148 /* ConstructSignature */: - case 149 /* IndexSignature */: - return visitNodes(cbNodes, node.decorators) || - visitNodes(cbNodes, node.modifiers) || - visitNodes(cbNodes, node.typeParameters) || - visitNodes(cbNodes, node.parameters) || - visitNode(cbNode, node.type); - case 143 /* MethodDeclaration */: - case 142 /* MethodSignature */: - case 144 /* Constructor */: - case 145 /* GetAccessor */: - case 146 /* SetAccessor */: - case 173 /* FunctionExpression */: - case 213 /* FunctionDeclaration */: - case 174 /* ArrowFunction */: - return visitNodes(cbNodes, node.decorators) || - visitNodes(cbNodes, node.modifiers) || - visitNode(cbNode, node.asteriskToken) || - visitNode(cbNode, node.name) || - visitNode(cbNode, node.questionToken) || - visitNodes(cbNodes, node.typeParameters) || - visitNodes(cbNodes, node.parameters) || - visitNode(cbNode, node.type) || - visitNode(cbNode, node.equalsGreaterThanToken) || - visitNode(cbNode, node.body); - case 151 /* TypeReference */: - return visitNode(cbNode, node.typeName) || - visitNodes(cbNodes, node.typeArguments); - case 150 /* TypePredicate */: - return visitNode(cbNode, node.parameterName) || - visitNode(cbNode, node.type); - case 154 /* TypeQuery */: - return visitNode(cbNode, node.exprName); - case 155 /* TypeLiteral */: - return visitNodes(cbNodes, node.members); - case 156 /* ArrayType */: - return visitNode(cbNode, node.elementType); - case 157 /* TupleType */: - return visitNodes(cbNodes, node.elementTypes); - case 158 /* UnionType */: - case 159 /* IntersectionType */: - return visitNodes(cbNodes, node.types); - case 160 /* ParenthesizedType */: - return visitNode(cbNode, node.type); - case 161 /* ObjectBindingPattern */: - case 162 /* ArrayBindingPattern */: - return visitNodes(cbNodes, node.elements); - case 164 /* ArrayLiteralExpression */: - return visitNodes(cbNodes, node.elements); - case 165 /* ObjectLiteralExpression */: - return visitNodes(cbNodes, node.properties); - case 166 /* PropertyAccessExpression */: - return visitNode(cbNode, node.expression) || - visitNode(cbNode, node.dotToken) || - visitNode(cbNode, node.name); - case 167 /* ElementAccessExpression */: - return visitNode(cbNode, node.expression) || - visitNode(cbNode, node.argumentExpression); - case 168 /* CallExpression */: - case 169 /* NewExpression */: - return visitNode(cbNode, node.expression) || - visitNodes(cbNodes, node.typeArguments) || - visitNodes(cbNodes, node.arguments); - case 170 /* TaggedTemplateExpression */: - return visitNode(cbNode, node.tag) || - visitNode(cbNode, node.template); - case 171 /* TypeAssertionExpression */: - return visitNode(cbNode, node.type) || - visitNode(cbNode, node.expression); - case 172 /* ParenthesizedExpression */: - return visitNode(cbNode, node.expression); - case 175 /* DeleteExpression */: - return visitNode(cbNode, node.expression); - case 176 /* TypeOfExpression */: - return visitNode(cbNode, node.expression); - case 177 /* VoidExpression */: - return visitNode(cbNode, node.expression); - case 179 /* PrefixUnaryExpression */: - return visitNode(cbNode, node.operand); - case 184 /* YieldExpression */: - return visitNode(cbNode, node.asteriskToken) || - visitNode(cbNode, node.expression); - case 178 /* AwaitExpression */: - return visitNode(cbNode, node.expression); - case 180 /* PostfixUnaryExpression */: - return visitNode(cbNode, node.operand); - case 181 /* BinaryExpression */: - return visitNode(cbNode, node.left) || - visitNode(cbNode, node.operatorToken) || - visitNode(cbNode, node.right); - case 189 /* AsExpression */: - return visitNode(cbNode, node.expression) || - visitNode(cbNode, node.type); - case 182 /* ConditionalExpression */: - return visitNode(cbNode, node.condition) || - visitNode(cbNode, node.questionToken) || - visitNode(cbNode, node.whenTrue) || - visitNode(cbNode, node.colonToken) || - visitNode(cbNode, node.whenFalse); - case 185 /* SpreadElementExpression */: - return visitNode(cbNode, node.expression); - case 192 /* Block */: - case 219 /* ModuleBlock */: - return visitNodes(cbNodes, node.statements); - case 248 /* SourceFile */: - return visitNodes(cbNodes, node.statements) || - visitNode(cbNode, node.endOfFileToken); - case 193 /* VariableStatement */: - return visitNodes(cbNodes, node.decorators) || - visitNodes(cbNodes, node.modifiers) || - visitNode(cbNode, node.declarationList); - case 212 /* VariableDeclarationList */: - return visitNodes(cbNodes, node.declarations); - case 195 /* ExpressionStatement */: - return visitNode(cbNode, node.expression); - case 196 /* IfStatement */: - return visitNode(cbNode, node.expression) || - visitNode(cbNode, node.thenStatement) || - visitNode(cbNode, node.elseStatement); - case 197 /* DoStatement */: - return visitNode(cbNode, node.statement) || - visitNode(cbNode, node.expression); - case 198 /* WhileStatement */: - return visitNode(cbNode, node.expression) || - visitNode(cbNode, node.statement); - case 199 /* ForStatement */: - return visitNode(cbNode, node.initializer) || - visitNode(cbNode, node.condition) || - visitNode(cbNode, node.incrementor) || - visitNode(cbNode, node.statement); - case 200 /* ForInStatement */: - return visitNode(cbNode, node.initializer) || - visitNode(cbNode, node.expression) || - visitNode(cbNode, node.statement); - case 201 /* ForOfStatement */: - return visitNode(cbNode, node.initializer) || - visitNode(cbNode, node.expression) || - visitNode(cbNode, node.statement); - case 202 /* ContinueStatement */: - case 203 /* BreakStatement */: - return visitNode(cbNode, node.label); - case 204 /* ReturnStatement */: - return visitNode(cbNode, node.expression); - case 205 /* WithStatement */: - return visitNode(cbNode, node.expression) || - visitNode(cbNode, node.statement); - case 206 /* SwitchStatement */: - return visitNode(cbNode, node.expression) || - visitNode(cbNode, node.caseBlock); - case 220 /* CaseBlock */: - return visitNodes(cbNodes, node.clauses); - case 241 /* CaseClause */: - return visitNode(cbNode, node.expression) || - visitNodes(cbNodes, node.statements); - case 242 /* DefaultClause */: - return visitNodes(cbNodes, node.statements); - case 207 /* LabeledStatement */: - return visitNode(cbNode, node.label) || - visitNode(cbNode, node.statement); - case 208 /* ThrowStatement */: - return visitNode(cbNode, node.expression); - case 209 /* TryStatement */: - return visitNode(cbNode, node.tryBlock) || - visitNode(cbNode, node.catchClause) || - visitNode(cbNode, node.finallyBlock); - case 244 /* CatchClause */: - return visitNode(cbNode, node.variableDeclaration) || - visitNode(cbNode, node.block); - case 139 /* Decorator */: - return visitNode(cbNode, node.expression); - case 214 /* ClassDeclaration */: - case 186 /* ClassExpression */: - return visitNodes(cbNodes, node.decorators) || - visitNodes(cbNodes, node.modifiers) || - visitNode(cbNode, node.name) || - visitNodes(cbNodes, node.typeParameters) || - visitNodes(cbNodes, node.heritageClauses) || - visitNodes(cbNodes, node.members); - case 215 /* InterfaceDeclaration */: - return visitNodes(cbNodes, node.decorators) || - visitNodes(cbNodes, node.modifiers) || - visitNode(cbNode, node.name) || - visitNodes(cbNodes, node.typeParameters) || - visitNodes(cbNodes, node.heritageClauses) || - visitNodes(cbNodes, node.members); - case 216 /* TypeAliasDeclaration */: - return visitNodes(cbNodes, node.decorators) || - visitNodes(cbNodes, node.modifiers) || - visitNode(cbNode, node.name) || - visitNodes(cbNodes, node.typeParameters) || - visitNode(cbNode, node.type); - case 217 /* EnumDeclaration */: - return visitNodes(cbNodes, node.decorators) || - visitNodes(cbNodes, node.modifiers) || - visitNode(cbNode, node.name) || - visitNodes(cbNodes, node.members); - case 247 /* EnumMember */: - return visitNode(cbNode, node.name) || - visitNode(cbNode, node.initializer); - case 218 /* ModuleDeclaration */: - return visitNodes(cbNodes, node.decorators) || - visitNodes(cbNodes, node.modifiers) || - visitNode(cbNode, node.name) || - visitNode(cbNode, node.body); - case 221 /* ImportEqualsDeclaration */: - return visitNodes(cbNodes, node.decorators) || - visitNodes(cbNodes, node.modifiers) || - visitNode(cbNode, node.name) || - visitNode(cbNode, node.moduleReference); - case 222 /* ImportDeclaration */: - return visitNodes(cbNodes, node.decorators) || - visitNodes(cbNodes, node.modifiers) || - visitNode(cbNode, node.importClause) || - visitNode(cbNode, node.moduleSpecifier); - case 223 /* ImportClause */: - return visitNode(cbNode, node.name) || - visitNode(cbNode, node.namedBindings); - case 224 /* NamespaceImport */: - return visitNode(cbNode, node.name); - case 225 /* NamedImports */: - case 229 /* NamedExports */: - return visitNodes(cbNodes, node.elements); - case 228 /* ExportDeclaration */: - return visitNodes(cbNodes, node.decorators) || - visitNodes(cbNodes, node.modifiers) || - visitNode(cbNode, node.exportClause) || - visitNode(cbNode, node.moduleSpecifier); - case 226 /* ImportSpecifier */: - case 230 /* ExportSpecifier */: - return visitNode(cbNode, node.propertyName) || - visitNode(cbNode, node.name); - case 227 /* ExportAssignment */: - return visitNodes(cbNodes, node.decorators) || - visitNodes(cbNodes, node.modifiers) || - visitNode(cbNode, node.expression); - case 183 /* TemplateExpression */: - return visitNode(cbNode, node.head) || visitNodes(cbNodes, node.templateSpans); - case 190 /* TemplateSpan */: - return visitNode(cbNode, node.expression) || visitNode(cbNode, node.literal); - case 136 /* ComputedPropertyName */: - return visitNode(cbNode, node.expression); - case 243 /* HeritageClause */: - return visitNodes(cbNodes, node.types); - case 188 /* ExpressionWithTypeArguments */: - return visitNode(cbNode, node.expression) || - visitNodes(cbNodes, node.typeArguments); - case 232 /* ExternalModuleReference */: - return visitNode(cbNode, node.expression); - case 231 /* MissingDeclaration */: - return visitNodes(cbNodes, node.decorators); - case 233 /* JsxElement */: - return visitNode(cbNode, node.openingElement) || - visitNodes(cbNodes, node.children) || - visitNode(cbNode, node.closingElement); - case 234 /* JsxSelfClosingElement */: - case 235 /* JsxOpeningElement */: - return visitNode(cbNode, node.tagName) || - visitNodes(cbNodes, node.attributes); - case 238 /* JsxAttribute */: - return visitNode(cbNode, node.name) || - visitNode(cbNode, node.initializer); - case 239 /* JsxSpreadAttribute */: - return visitNode(cbNode, node.expression); - case 240 /* JsxExpression */: - return visitNode(cbNode, node.expression); - case 237 /* JsxClosingElement */: - return visitNode(cbNode, node.tagName); - case 249 /* JSDocTypeExpression */: - return visitNode(cbNode, node.type); - case 253 /* JSDocUnionType */: - return visitNodes(cbNodes, node.types); - case 254 /* JSDocTupleType */: - return visitNodes(cbNodes, node.types); - case 252 /* JSDocArrayType */: - return visitNode(cbNode, node.elementType); - case 256 /* JSDocNonNullableType */: - return visitNode(cbNode, node.type); - case 255 /* JSDocNullableType */: - return visitNode(cbNode, node.type); - case 257 /* JSDocRecordType */: - return visitNodes(cbNodes, node.members); - case 259 /* JSDocTypeReference */: - return visitNode(cbNode, node.name) || - visitNodes(cbNodes, node.typeArguments); - case 260 /* JSDocOptionalType */: - return visitNode(cbNode, node.type); - case 261 /* JSDocFunctionType */: - return visitNodes(cbNodes, node.parameters) || - visitNode(cbNode, node.type); - case 262 /* JSDocVariadicType */: - return visitNode(cbNode, node.type); - case 263 /* JSDocConstructorType */: - return visitNode(cbNode, node.type); - case 264 /* JSDocThisType */: - return visitNode(cbNode, node.type); - case 258 /* JSDocRecordMember */: - return visitNode(cbNode, node.name) || - visitNode(cbNode, node.type); - case 265 /* JSDocComment */: - return visitNodes(cbNodes, node.tags); - case 267 /* JSDocParameterTag */: - return visitNode(cbNode, node.preParameterName) || - visitNode(cbNode, node.typeExpression) || - visitNode(cbNode, node.postParameterName); - case 268 /* JSDocReturnTag */: - return visitNode(cbNode, node.typeExpression); - case 269 /* JSDocTypeTag */: - return visitNode(cbNode, node.typeExpression); - case 270 /* JSDocTemplateTag */: - return visitNodes(cbNodes, node.typeParameters); - } - } - ts.forEachChild = forEachChild; - function createSourceFile(fileName, sourceText, languageVersion, setParentNodes) { - if (setParentNodes === void 0) { setParentNodes = false; } - var start = new Date().getTime(); - var result = Parser.parseSourceFile(fileName, sourceText, languageVersion, /*syntaxCursor*/ undefined, setParentNodes); - ts.parseTime += new Date().getTime() - start; - return result; - } - ts.createSourceFile = createSourceFile; - // Produces a new SourceFile for the 'newText' provided. The 'textChangeRange' parameter - // indicates what changed between the 'text' that this SourceFile has and the 'newText'. - // The SourceFile will be created with the compiler attempting to reuse as many nodes from - // this file as possible. - // - // Note: this function mutates nodes from this SourceFile. That means any existing nodes - // from this SourceFile that are being held onto may change as a result (including - // becoming detached from any SourceFile). It is recommended that this SourceFile not - // be used once 'update' is called on it. - function updateSourceFile(sourceFile, newText, textChangeRange, aggressiveChecks) { - return IncrementalParser.updateSourceFile(sourceFile, newText, textChangeRange, aggressiveChecks); - } - ts.updateSourceFile = updateSourceFile; - /* @internal */ - function parseIsolatedJSDocComment(content, start, length) { - return Parser.JSDocParser.parseIsolatedJSDocComment(content, start, length); - } - ts.parseIsolatedJSDocComment = parseIsolatedJSDocComment; - /* @internal */ - // Exposed only for testing. - function parseJSDocTypeExpressionForTests(content, start, length) { - return Parser.JSDocParser.parseJSDocTypeExpressionForTests(content, start, length); - } - ts.parseJSDocTypeExpressionForTests = parseJSDocTypeExpressionForTests; - // Implement the parser as a singleton module. We do this for perf reasons because creating - // parser instances can actually be expensive enough to impact us on projects with many source - // files. - var Parser; - (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 disallowInAndDecoratorContext = 1 /* DisallowIn */ | 4 /* Decorator */; - var sourceFile; - var parseDiagnostics; - var syntaxCursor; - var token; - var sourceText; - var nodeCount; - var identifiers; - var identifierCount; - var parsingContext; - // Flags that dictate what parsing context we're in. For example: - // Whether or not we are in strict parsing mode. All that changes in strict parsing mode is - // that some tokens that would be considered identifiers may be considered keywords. - // - // When adding more parser context flags, consider which is the more common case that the - // flag will be in. This should be the 'false' state for that flag. The reason for this is - // that we don't store data in our nodes unless the value is in the *non-default* state. So, - // for example, more often than code 'allows-in' (or doesn't 'disallow-in'). We opt for - // 'disallow-in' set to 'false'. Otherwise, if we had 'allowsIn' set to 'true', then almost - // all nodes would need extra state on them to store this info. - // - // Note: 'allowIn' and 'allowYield' track 1:1 with the [in] and [yield] concepts in the ES6 - // grammar specification. - // - // An important thing about these context concepts. By default they are effectively inherited - // while parsing through every grammar production. i.e. if you don't change them, then when - // you parse a sub-production, it will have the same context values as the parent production. - // This is great most of the time. After all, consider all the 'expression' grammar productions - // and how nearly all of them pass along the 'in' and 'yield' context values: - // - // EqualityExpression[In, Yield] : - // RelationalExpression[?In, ?Yield] - // EqualityExpression[?In, ?Yield] == RelationalExpression[?In, ?Yield] - // EqualityExpression[?In, ?Yield] != RelationalExpression[?In, ?Yield] - // EqualityExpression[?In, ?Yield] === RelationalExpression[?In, ?Yield] - // EqualityExpression[?In, ?Yield] !== RelationalExpression[?In, ?Yield] - // - // Where you have to be careful is then understanding what the points are in the grammar - // where the values are *not* passed along. For example: - // - // SingleNameBinding[Yield,GeneratorParameter] - // [+GeneratorParameter]BindingIdentifier[Yield] Initializer[In]opt - // [~GeneratorParameter]BindingIdentifier[?Yield]Initializer[In, ?Yield]opt - // - // Here this is saying that if the GeneratorParameter context flag is set, that we should - // explicitly set the 'yield' context flag to false before calling into the BindingIdentifier - // and we should explicitly unset the 'yield' context flag before calling into the Initializer. - // production. Conversely, if the GeneratorParameter context flag is not set, then we - // should leave the 'yield' context flag alone. - // - // Getting this all correct is tricky and requires careful reading of the grammar to - // understand when these values should be changed versus when they should be inherited. - // - // Note: it should not be necessary to save/restore these flags during speculative/lookahead - // parsing. These context flags are naturally stored and restored through normal recursive - // descent parsing and unwinding. - var contextFlags; - // Whether or not we've had a parse error since creating the last AST node. If we have - // encountered an error, it will be stored on the next AST node we create. Parse errors - // can be broken down into three categories: - // - // 1) An error that occurred during scanning. For example, an unterminated literal, or a - // character that was completely not understood. - // - // 2) A token was expected, but was not present. This type of error is commonly produced - // by the 'parseExpected' function. - // - // 3) A token was present that no parsing function was able to consume. This type of error - // only occurs in the 'abortParsingListOrMoveToNextToken' function when the parser - // decides to skip the token. - // - // In all of these cases, we want to mark the next node as having had an error before it. - // With this mark, we can know in incremental settings if this node can be reused, or if - // we have to reparse it. If we don't keep this information around, we may just reuse the - // node. in that event we would then not produce the same errors as we did before, causing - // significant confusion problems. - // - // Note: it is necessary that this value be saved/restored during speculative/lookahead - // parsing. During lookahead parsing, we will often create a node. That node will have - // this value attached, and then this value will be set back to 'false'. If we decide to - // rewind, we must get back to the same value we had prior to the lookahead. - // - // 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) { - initializeState(fileName, _sourceText, languageVersion, _syntaxCursor); - var result = parseSourceFileWorker(fileName, languageVersion, setParentNodes); - clearState(); - return result; - } - Parser.parseSourceFile = parseSourceFile; - function initializeState(fileName, _sourceText, languageVersion, _syntaxCursor) { - sourceText = _sourceText; - syntaxCursor = _syntaxCursor; - parseDiagnostics = []; - parsingContext = 0; - identifiers = {}; - identifierCount = 0; - nodeCount = 0; - contextFlags = ts.isJavaScript(fileName) ? 32 /* JavaScriptFile */ : 0 /* None */; - parseErrorBeforeNextFinishedNode = false; - // Initialize and prime the scanner before parsing the source elements. - scanner.setText(sourceText); - scanner.setOnError(scanError); - scanner.setScriptTarget(languageVersion); - scanner.setLanguageVariant(ts.isTsx(fileName) ? 1 /* JSX */ : 0 /* Standard */); - } - function clearState() { - // Clear out the text the scanner is pointing at, so it doesn't keep anything alive unnecessarily. - scanner.setText(""); - scanner.setOnError(undefined); - // Clear any data. We don't want to accidently hold onto it for too long. - parseDiagnostics = undefined; - sourceFile = undefined; - identifiers = undefined; - syntaxCursor = undefined; - sourceText = undefined; - } - function parseSourceFileWorker(fileName, languageVersion, setParentNodes) { - sourceFile = createSourceFile(fileName, languageVersion); - // Prime the scanner. - token = nextToken(); - processReferenceComments(sourceFile); - sourceFile.statements = parseList(0 /* SourceElements */, parseStatement); - ts.Debug.assert(token === 1 /* EndOfFileToken */); - sourceFile.endOfFileToken = parseTokenNode(); - setExternalModuleIndicator(sourceFile); - sourceFile.nodeCount = nodeCount; - sourceFile.identifierCount = identifierCount; - sourceFile.identifiers = identifiers; - sourceFile.parseDiagnostics = parseDiagnostics; - if (setParentNodes) { - fixupParentReferences(sourceFile); - } - // If this is a javascript file, proactively see if we can get JSDoc comments for - // relevant nodes in the file. We'll use these to provide typing informaion if they're - // available. - if (ts.isJavaScript(fileName)) { - addJSDocComments(); - } - return sourceFile; - } - function addJSDocComments() { - forEachChild(sourceFile, visit); - return; - function visit(node) { - // Add additional cases as necessary depending on how we see JSDoc comments used - // in the wild. - switch (node.kind) { - case 193 /* VariableStatement */: - case 213 /* FunctionDeclaration */: - case 138 /* Parameter */: - addJSDocComment(node); - } - forEachChild(node, visit); - } - } - function addJSDocComment(node) { - var comments = ts.getLeadingCommentRangesOfNode(node, sourceFile); - if (comments) { - for (var _i = 0; _i < comments.length; _i++) { - var comment = comments[_i]; - var jsDocComment = JSDocParser.parseJSDocComment(node, comment.pos, comment.end - comment.pos); - if (jsDocComment) { - node.jsDocComment = jsDocComment; - } - } - } - } - function fixupParentReferences(sourceFile) { - // normally parent references are set during binding. However, for clients that only need - // a syntax tree, and no semantic features, then the binding process is an unnecessary - // overhead. This functions allows us to set all the parents, without all the expense of - // binding. - var parent = sourceFile; - forEachChild(sourceFile, visitNode); - return; - function visitNode(n) { - // walk down setting parents that differ from the parent we think it should be. This - // allows us to quickly bail out of setting parents for subtrees during incremental - // parsing - if (n.parent !== parent) { - n.parent = parent; - var saveParent = parent; - parent = n; - forEachChild(n, visitNode); - parent = saveParent; - } - } - } - Parser.fixupParentReferences = fixupParentReferences; - function createSourceFile(fileName, languageVersion) { - var sourceFile = createNode(248 /* SourceFile */, /*pos*/ 0); - sourceFile.pos = 0; - sourceFile.end = sourceText.length; - sourceFile.text = sourceText; - sourceFile.bindDiagnostics = []; - sourceFile.languageVersion = languageVersion; - sourceFile.fileName = ts.normalizePath(fileName); - sourceFile.flags = ts.fileExtensionIs(sourceFile.fileName, ".d.ts") ? 8192 /* DeclarationFile */ : 0; - sourceFile.languageVariant = ts.isTsx(sourceFile.fileName) ? 1 /* JSX */ : 0 /* Standard */; - return sourceFile; - } - function setContextFlag(val, flag) { - if (val) { - contextFlags |= flag; - } - else { - contextFlags &= ~flag; - } - } - function setDisallowInContext(val) { - setContextFlag(val, 1 /* DisallowIn */); - } - function setYieldContext(val) { - setContextFlag(val, 2 /* Yield */); - } - function setDecoratorContext(val) { - setContextFlag(val, 4 /* Decorator */); - } - function setAwaitContext(val) { - setContextFlag(val, 8 /* Await */); - } - function doOutsideOfContext(context, func) { - // contextFlagsToClear will contain only the context flags that are - // currently set that we need to temporarily clear - // We don't just blindly reset to the previous flags to ensure - // that we do not mutate cached flags for the incremental - // parser (ThisNodeHasError, ThisNodeOrAnySubNodesHasError, and - // HasAggregatedChildData). - var contextFlagsToClear = context & contextFlags; - if (contextFlagsToClear) { - // clear the requested context flags - setContextFlag(false, contextFlagsToClear); - var result = func(); - // restore the context flags we just cleared - setContextFlag(true, contextFlagsToClear); - return result; - } - // no need to do anything special as we are not in any of the requested contexts - return func(); - } - function doInsideOfContext(context, func) { - // contextFlagsToSet will contain only the context flags that - // are not currently set that we need to temporarily enable. - // We don't just blindly reset to the previous flags to ensure - // that we do not mutate cached flags for the incremental - // parser (ThisNodeHasError, ThisNodeOrAnySubNodesHasError, and - // HasAggregatedChildData). - var contextFlagsToSet = context & ~contextFlags; - if (contextFlagsToSet) { - // set the requested context flags - setContextFlag(true, contextFlagsToSet); - var result = func(); - // reset the context flags we just set - setContextFlag(false, contextFlagsToSet); - return result; - } - // no need to do anything special as we are already in all of the requested contexts - return func(); - } - function allowInAnd(func) { - return doOutsideOfContext(1 /* DisallowIn */, func); - } - function disallowInAnd(func) { - return doInsideOfContext(1 /* DisallowIn */, func); - } - function doInYieldContext(func) { - return doInsideOfContext(2 /* Yield */, func); - } - function doOutsideOfYieldContext(func) { - return doOutsideOfContext(2 /* Yield */, func); - } - function doInDecoratorContext(func) { - return doInsideOfContext(4 /* Decorator */, func); - } - function doInAwaitContext(func) { - return doInsideOfContext(8 /* Await */, func); - } - function doOutsideOfAwaitContext(func) { - return doOutsideOfContext(8 /* Await */, func); - } - function doInYieldAndAwaitContext(func) { - return doInsideOfContext(2 /* Yield */ | 8 /* Await */, func); - } - function doOutsideOfYieldAndAwaitContext(func) { - return doOutsideOfContext(2 /* Yield */ | 8 /* Await */, func); - } - function inContext(flags) { - return (contextFlags & flags) !== 0; - } - function inYieldContext() { - return inContext(2 /* Yield */); - } - function inDisallowInContext() { - return inContext(1 /* DisallowIn */); - } - function inDecoratorContext() { - return inContext(4 /* Decorator */); - } - function inAwaitContext() { - return inContext(8 /* Await */); - } - function parseErrorAtCurrentToken(message, arg0) { - var start = scanner.getTokenPos(); - var length = scanner.getTextPos() - start; - parseErrorAtPosition(start, length, message, arg0); - } - function parseErrorAtPosition(start, length, message, arg0) { - // Don't report another error if it would just be at the same position as the last error. - var lastError = ts.lastOrUndefined(parseDiagnostics); - if (!lastError || start !== lastError.start) { - parseDiagnostics.push(ts.createFileDiagnostic(sourceFile, start, length, message, arg0)); - } - // Mark that we've encountered an error. We'll set an appropriate bit on the next - // node we finish so that it can't be reused incrementally. - parseErrorBeforeNextFinishedNode = true; - } - function scanError(message, length) { - var pos = scanner.getTextPos(); - parseErrorAtPosition(pos, length || 0, message); - } - function getNodePos() { - return scanner.getStartPos(); - } - function getNodeEnd() { - return scanner.getStartPos(); - } - function nextToken() { - return token = scanner.scan(); - } - function getTokenPos(pos) { - return ts.skipTrivia(sourceText, pos); - } - function reScanGreaterToken() { - return token = scanner.reScanGreaterToken(); - } - function reScanSlashToken() { - return token = scanner.reScanSlashToken(); - } - function reScanTemplateToken() { - return token = scanner.reScanTemplateToken(); - } - function scanJsxIdentifier() { - return token = scanner.scanJsxIdentifier(); - } - function scanJsxText() { - return token = scanner.scanJsxToken(); - } - function speculationHelper(callback, isLookAhead) { - // Keep track of the state we'll need to rollback to if lookahead fails (or if the - // caller asked us to always reset our state). - var saveToken = token; - var saveParseDiagnosticsLength = parseDiagnostics.length; - var saveParseErrorBeforeNextFinishedNode = parseErrorBeforeNextFinishedNode; - // Note: it is not actually necessary to save/restore the context flags here. That's - // because the saving/restoring of these flags happens naturally through the recursive - // descent nature of our parser. However, we still store this here just so we can - // assert that that invariant holds. - var saveContextFlags = contextFlags; - // If we're only looking ahead, then tell the scanner to only lookahead as well. - // Otherwise, if we're actually speculatively parsing, then tell the scanner to do the - // same. - var result = isLookAhead - ? scanner.lookAhead(callback) - : scanner.tryScan(callback); - ts.Debug.assert(saveContextFlags === contextFlags); - // If our callback returned something 'falsy' or we're just looking ahead, - // then unconditionally restore us to where we were. - if (!result || isLookAhead) { - token = saveToken; - parseDiagnostics.length = saveParseDiagnosticsLength; - parseErrorBeforeNextFinishedNode = saveParseErrorBeforeNextFinishedNode; - } - return result; - } - // Invokes the provided callback then unconditionally restores the parser to the state it - // was in immediately prior to invoking the callback. The result of invoking the callback - // is returned from this function. - function lookAhead(callback) { - return speculationHelper(callback, /*isLookAhead*/ true); - } - // Invokes the provided callback. If the callback returns something falsy, then it restores - // the parser to the state it was in immediately prior to invoking the callback. If the - // callback returns something truthy, then the parser state is not rolled back. The result - // of invoking the callback is returned from this function. - function tryParse(callback) { - return speculationHelper(callback, /*isLookAhead*/ false); - } - // Ignore strict mode flag because we will report an error in type checker instead. - function isIdentifier() { - if (token === 69 /* Identifier */) { - return true; - } - // If we have a 'yield' keyword, and we're in the [yield] context, then 'yield' is - // considered a keyword and is not an identifier. - if (token === 114 /* YieldKeyword */ && inYieldContext()) { - return false; - } - // If we have a 'await' keyword, and we're in the [Await] context, then 'await' is - // considered a keyword and is not an identifier. - if (token === 119 /* AwaitKeyword */ && inAwaitContext()) { - return false; - } - return token > 105 /* LastReservedWord */; - } - function parseExpected(kind, diagnosticMessage, shouldAdvance) { - if (shouldAdvance === void 0) { shouldAdvance = true; } - if (token === kind) { - if (shouldAdvance) { - nextToken(); - } - return true; - } - // Report specific message if provided with one. Otherwise, report generic fallback message. - if (diagnosticMessage) { - parseErrorAtCurrentToken(diagnosticMessage); - } - else { - parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(kind)); - } - return false; - } - function parseOptional(t) { - if (token === t) { - nextToken(); - return true; - } - return false; - } - function parseOptionalToken(t) { - if (token === t) { - return parseTokenNode(); - } - return undefined; - } - function parseExpectedToken(t, reportAtCurrentPosition, diagnosticMessage, arg0) { - return parseOptionalToken(t) || - createMissingNode(t, reportAtCurrentPosition, diagnosticMessage, arg0); - } - function parseTokenNode() { - var node = createNode(token); - nextToken(); - return finishNode(node); - } - function canParseSemicolon() { - // If there's a real semicolon, then we can always parse it out. - if (token === 23 /* 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(); - } - function parseSemicolon() { - if (canParseSemicolon()) { - if (token === 23 /* SemicolonToken */) { - // consume the semicolon if it was explicitly provided. - nextToken(); - } - return true; - } - else { - return parseExpected(23 /* SemicolonToken */); - } - } - function createNode(kind, pos) { - nodeCount++; - if (!(pos >= 0)) { - pos = scanner.getStartPos(); - } - return new (nodeConstructors[kind] || (nodeConstructors[kind] = ts.objectAllocator.getNodeConstructor(kind)))(pos, pos); - } - function finishNode(node, end) { - node.end = end === undefined ? scanner.getStartPos() : end; - if (contextFlags) { - node.parserContextFlags = contextFlags; - } - // Keep track on the node if we encountered an error while parsing it. If we did, then - // we cannot reuse the node incrementally. Once we've marked this node, clear out the - // flag so that we don't mark any subsequent nodes. - if (parseErrorBeforeNextFinishedNode) { - parseErrorBeforeNextFinishedNode = false; - node.parserContextFlags |= 16 /* ThisNodeHasError */; - } - return node; - } - function createMissingNode(kind, reportAtCurrentPosition, diagnosticMessage, arg0) { - if (reportAtCurrentPosition) { - parseErrorAtPosition(scanner.getStartPos(), 0, diagnosticMessage, arg0); - } - else { - parseErrorAtCurrentToken(diagnosticMessage, arg0); - } - var result = createNode(kind, scanner.getStartPos()); - result.text = ""; - return finishNode(result); - } - function internIdentifier(text) { - text = ts.escapeIdentifier(text); - return ts.hasProperty(identifiers, text) ? identifiers[text] : (identifiers[text] = text); - } - // An identifier that starts with two underscores has an extra underscore character prepended to it to avoid issues - // with magic property names like '__proto__'. The 'identifiers' object is used to share a single string instance for - // each identifier in order to reduce memory consumption. - function createIdentifier(isIdentifier, diagnosticMessage) { - identifierCount++; - if (isIdentifier) { - var node = createNode(69 /* Identifier */); - // Store original token kind if it is not just an Identifier so we can report appropriate error later in type checker - if (token !== 69 /* Identifier */) { - node.originalKeywordKind = token; - } - node.text = internIdentifier(scanner.getTokenValue()); - nextToken(); - return finishNode(node); - } - return createMissingNode(69 /* Identifier */, /*reportAtCurrentPosition*/ false, diagnosticMessage || ts.Diagnostics.Identifier_expected); - } - function parseIdentifier(diagnosticMessage) { - return createIdentifier(isIdentifier(), diagnosticMessage); - } - function parseIdentifierName() { - return createIdentifier(ts.tokenIsIdentifierOrKeyword(token)); - } - function isLiteralPropertyName() { - return ts.tokenIsIdentifierOrKeyword(token) || - token === 9 /* StringLiteral */ || - token === 8 /* NumericLiteral */; - } - function parsePropertyNameWorker(allowComputedPropertyNames) { - if (token === 9 /* StringLiteral */ || token === 8 /* NumericLiteral */) { - return parseLiteralNode(/*internName*/ true); - } - if (allowComputedPropertyNames && token === 19 /* OpenBracketToken */) { - return parseComputedPropertyName(); - } - return parseIdentifierName(); - } - function parsePropertyName() { - return parsePropertyNameWorker(/*allowComputedPropertyNames:*/ true); - } - function parseSimplePropertyName() { - return parsePropertyNameWorker(/*allowComputedPropertyNames:*/ false); - } - function isSimplePropertyName() { - return token === 9 /* StringLiteral */ || token === 8 /* NumericLiteral */ || ts.tokenIsIdentifierOrKeyword(token); - } - function parseComputedPropertyName() { - // PropertyName [Yield]: - // LiteralPropertyName - // ComputedPropertyName[?Yield] - var node = createNode(136 /* ComputedPropertyName */); - parseExpected(19 /* OpenBracketToken */); - // We parse any expression (including a comma expression). But the grammar - // says that only an assignment expression is allowed, so the grammar checker - // will error if it sees a comma expression. - node.expression = allowInAnd(parseExpression); - parseExpected(20 /* CloseBracketToken */); - return finishNode(node); - } - function parseContextualModifier(t) { - return token === t && tryParse(nextTokenCanFollowModifier); - } - function nextTokenCanFollowModifier() { - if (token === 74 /* ConstKeyword */) { - // 'const' is only a modifier if followed by 'enum'. - return nextToken() === 81 /* EnumKeyword */; - } - if (token === 82 /* ExportKeyword */) { - nextToken(); - if (token === 77 /* DefaultKeyword */) { - return lookAhead(nextTokenIsClassOrFunction); - } - return token !== 37 /* AsteriskToken */ && token !== 15 /* OpenBraceToken */ && canFollowModifier(); - } - if (token === 77 /* DefaultKeyword */) { - return nextTokenIsClassOrFunction(); - } - if (token === 113 /* StaticKeyword */) { - nextToken(); - return canFollowModifier(); - } - nextToken(); - if (scanner.hasPrecedingLineBreak()) { - return false; - } - return canFollowModifier(); - } - function parseAnyContextualModifier() { - return ts.isModifier(token) && tryParse(nextTokenCanFollowModifier); - } - function canFollowModifier() { - return token === 19 /* OpenBracketToken */ - || token === 15 /* OpenBraceToken */ - || token === 37 /* AsteriskToken */ - || isLiteralPropertyName(); - } - function nextTokenIsClassOrFunction() { - nextToken(); - return token === 73 /* ClassKeyword */ || token === 87 /* FunctionKeyword */; - } - // True if positioned at the start of a list element - function isListElement(parsingContext, inErrorRecovery) { - var node = currentNode(parsingContext); - if (node) { - return true; - } - switch (parsingContext) { - case 0 /* SourceElements */: - case 1 /* BlockStatements */: - case 3 /* SwitchClauseStatements */: - // If we're in error recovery, then we don't want to treat ';' as an empty statement. - // The problem is that ';' can show up in far too many contexts, and if we see one - // and assume it's a statement, then we may bail out inappropriately from whatever - // 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(); - case 2 /* SwitchClauses */: - return token === 71 /* CaseKeyword */ || token === 77 /* DefaultKeyword */; - case 4 /* TypeMembers */: - return isStartOfTypeMember(); - case 5 /* ClassMembers */: - // We allow semicolons as class elements (as specified by ES6) as long as we're - // 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); - 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(); - case 12 /* ObjectLiteralMembers */: - return token === 19 /* OpenBracketToken */ || token === 37 /* AsteriskToken */ || isLiteralPropertyName(); - case 9 /* ObjectBindingElements */: - return 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 */) { - return lookAhead(isValidHeritageClauseObjectLiteral); - } - if (!inErrorRecovery) { - return isStartOfLeftHandSideExpression() && !isHeritageClauseExtendsOrImplementsKeyword(); - } - else { - // If we're in error recovery we tighten up what we're willing to match. - // That way we don't treat something like "this" as a valid heritage clause - // element during recovery. - return isIdentifier() && !isHeritageClauseExtendsOrImplementsKeyword(); - } - case 8 /* VariableDeclarations */: - return isIdentifierOrPattern(); - case 10 /* ArrayBindingElements */: - return token === 24 /* CommaToken */ || token === 22 /* DotDotDotToken */ || isIdentifierOrPattern(); - case 17 /* TypeParameters */: - return isIdentifier(); - case 11 /* ArgumentExpressions */: - case 15 /* ArrayLiteralMembers */: - return token === 24 /* CommaToken */ || token === 22 /* DotDotDotToken */ || isStartOfExpression(); - case 16 /* Parameters */: - return isStartOfParameter(); - case 18 /* TypeArguments */: - case 19 /* TupleElementTypes */: - return token === 24 /* CommaToken */ || isStartOfType(); - case 20 /* HeritageClauses */: - return isHeritageClause(); - case 21 /* ImportOrExportSpecifiers */: - return ts.tokenIsIdentifierOrKeyword(token); - case 13 /* JsxAttributes */: - return ts.tokenIsIdentifierOrKeyword(token) || token === 15 /* OpenBraceToken */; - case 14 /* JsxChildren */: - return true; - case 22 /* JSDocFunctionParameters */: - case 23 /* JSDocTypeArguments */: - case 25 /* JSDocTupleTypes */: - return JSDocParser.isJSDocType(); - case 24 /* JSDocRecordMembers */: - return isSimplePropertyName(); - } - ts.Debug.fail("Non-exhaustive case in 'isListElement'."); - } - function isValidHeritageClauseObjectLiteral() { - ts.Debug.assert(token === 15 /* OpenBraceToken */); - if (nextToken() === 16 /* CloseBraceToken */) { - // if we see "extends {}" then only treat the {} as what we're extending (and not - // the class body) if we have: - // - // extends {} { - // extends {}, - // extends {} extends - // extends {} implements - var next = nextToken(); - return next === 24 /* CommaToken */ || next === 15 /* OpenBraceToken */ || next === 83 /* ExtendsKeyword */ || next === 106 /* ImplementsKeyword */; - } - return true; - } - function nextTokenIsIdentifier() { - nextToken(); - return isIdentifier(); - } - function nextTokenIsIdentifierOrKeyword() { - nextToken(); - return ts.tokenIsIdentifierOrKeyword(token); - } - function isHeritageClauseExtendsOrImplementsKeyword() { - if (token === 106 /* ImplementsKeyword */ || - token === 83 /* ExtendsKeyword */) { - return lookAhead(nextTokenIsStartOfExpression); - } - return false; - } - function nextTokenIsStartOfExpression() { - nextToken(); - return isStartOfExpression(); - } - // True if positioned at a list terminator - function isListTerminator(kind) { - if (token === 1 /* EndOfFileToken */) { - // Being at the end of the file ends all lists. - return true; - } - switch (kind) { - case 1 /* BlockStatements */: - case 2 /* SwitchClauses */: - case 4 /* TypeMembers */: - case 5 /* ClassMembers */: - case 6 /* EnumMembers */: - case 12 /* ObjectLiteralMembers */: - case 9 /* ObjectBindingElements */: - case 21 /* ImportOrExportSpecifiers */: - return token === 16 /* CloseBraceToken */; - case 3 /* SwitchClauseStatements */: - return token === 16 /* CloseBraceToken */ || token === 71 /* CaseKeyword */ || token === 77 /* DefaultKeyword */; - case 7 /* HeritageClauseElement */: - return token === 15 /* OpenBraceToken */ || token === 83 /* ExtendsKeyword */ || token === 106 /* ImplementsKeyword */; - case 8 /* VariableDeclarations */: - return isVariableDeclaratorListTerminator(); - case 17 /* TypeParameters */: - // Tokens other than '>' are here for better error recovery - return token === 27 /* GreaterThanToken */ || token === 17 /* OpenParenToken */ || token === 15 /* OpenBraceToken */ || token === 83 /* ExtendsKeyword */ || token === 106 /* ImplementsKeyword */; - case 11 /* ArgumentExpressions */: - // Tokens other than ')' are here for better error recovery - return token === 18 /* CloseParenToken */ || token === 23 /* SemicolonToken */; - case 15 /* ArrayLiteralMembers */: - case 19 /* TupleElementTypes */: - case 10 /* ArrayBindingElements */: - return token === 20 /* 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*/; - case 18 /* TypeArguments */: - // Tokens other than '>' are here for better error recovery - return token === 27 /* GreaterThanToken */ || token === 17 /* OpenParenToken */; - case 20 /* HeritageClauses */: - return token === 15 /* OpenBraceToken */ || token === 16 /* CloseBraceToken */; - case 13 /* JsxAttributes */: - return token === 27 /* GreaterThanToken */ || token === 39 /* SlashToken */; - case 14 /* JsxChildren */: - return token === 25 /* LessThanToken */ && lookAhead(nextTokenIsSlash); - case 22 /* JSDocFunctionParameters */: - return token === 18 /* CloseParenToken */ || token === 54 /* ColonToken */ || token === 16 /* CloseBraceToken */; - case 23 /* JSDocTypeArguments */: - return token === 27 /* GreaterThanToken */ || token === 16 /* CloseBraceToken */; - case 25 /* JSDocTupleTypes */: - return token === 20 /* CloseBracketToken */ || token === 16 /* CloseBraceToken */; - case 24 /* JSDocRecordMembers */: - return token === 16 /* CloseBraceToken */; - } - } - function isVariableDeclaratorListTerminator() { - // If we can consume a semicolon (either explicitly, or with ASI), then consider us done - // with parsing the list of variable declarators. - if (canParseSemicolon()) { - return true; - } - // in the case where we're parsing the variable declarator of a 'for-in' statement, we - // are done if we see an 'in' keyword in front of us. Same with for-of - if (isInOrOfKeyword(token)) { - return true; - } - // ERROR RECOVERY TWEAK: - // 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 */) { - return true; - } - // Keep trying to parse out variable declarators. - return false; - } - // True if positioned at element or terminator of the current list or any enclosing list - function isInSomeParsingContext() { - for (var kind = 0; kind < 26 /* Count */; kind++) { - if (parsingContext & (1 << kind)) { - if (isListElement(kind, /* inErrorRecovery */ true) || isListTerminator(kind)) { - return true; - } - } - } - return false; - } - // Parses a list of elements - function parseList(kind, parseElement) { - var saveParsingContext = parsingContext; - parsingContext |= 1 << kind; - var result = []; - result.pos = getNodePos(); - while (!isListTerminator(kind)) { - if (isListElement(kind, /* inErrorRecovery */ false)) { - var element = parseListElement(kind, parseElement); - result.push(element); - continue; - } - if (abortParsingListOrMoveToNextToken(kind)) { - break; - } - } - result.end = getNodeEnd(); - parsingContext = saveParsingContext; - return result; - } - function parseListElement(parsingContext, parseElement) { - var node = currentNode(parsingContext); - if (node) { - return consumeNode(node); - } - return parseElement(); - } - function currentNode(parsingContext) { - // If there is an outstanding parse error that we've encountered, but not attached to - // some node, then we cannot get a node from the old source tree. This is because we - // want to mark the next node we encounter as being unusable. - // - // Note: This may be too conservative. Perhaps we could reuse the node and set the bit - // on it (or its leftmost child) as having the error. For now though, being conservative - // is nice and likely won't ever affect perf. - if (parseErrorBeforeNextFinishedNode) { - return undefined; - } - if (!syntaxCursor) { - // if we don't have a cursor, we could never return a node from the old tree. - return undefined; - } - var node = syntaxCursor.currentNode(scanner.getStartPos()); - // Can't reuse a missing node. - if (ts.nodeIsMissing(node)) { - return undefined; - } - // Can't reuse a node that intersected the change range. - if (node.intersectsChange) { - return undefined; - } - // Can't reuse a node that contains a parse error. This is necessary so that we - // produce the same set of errors again. - if (ts.containsParseError(node)) { - return undefined; - } - // We can only reuse a node if it was parsed under the same strict mode that we're - // currently in. i.e. if we originally parsed a node in non-strict mode, but then - // the user added 'using strict' at the top of the file, then we can't use that node - // again as the presense of strict mode may cause us to parse the tokens in the file - // differetly. - // - // Note: we *can* reuse tokens when the strict mode changes. That's because tokens - // are unaffected by strict mode. It's just the parser will decide what to do with it - // differently depending on what mode it is in. - // - // This also applies to all our other context flags as well. - var nodeContextFlags = node.parserContextFlags & 31 /* ParserGeneratedFlags */; - if (nodeContextFlags !== contextFlags) { - return undefined; - } - // Ok, we have a node that looks like it could be reused. Now verify that it is valid - // in the currest list parsing context that we're currently at. - if (!canReuseNode(node, parsingContext)) { - return undefined; - } - return node; - } - function consumeNode(node) { - // Move the scanner so it is after the node we just consumed. - scanner.setTextPos(node.end); - nextToken(); - return node; - } - function canReuseNode(node, parsingContext) { - switch (parsingContext) { - case 5 /* ClassMembers */: - return isReusableClassMember(node); - case 2 /* SwitchClauses */: - return isReusableSwitchClause(node); - case 0 /* SourceElements */: - case 1 /* BlockStatements */: - case 3 /* SwitchClauseStatements */: - return isReusableStatement(node); - case 6 /* EnumMembers */: - return isReusableEnumMember(node); - case 4 /* TypeMembers */: - return isReusableTypeMember(node); - case 8 /* VariableDeclarations */: - return isReusableVariableDeclaration(node); - case 16 /* Parameters */: - return isReusableParameter(node); - // Any other lists we do not care about reusing nodes in. But feel free to add if - // you can do so safely. Danger areas involve nodes that may involve speculative - // parsing. If speculative parsing is involved with the node, then the range the - // parser reached while looking ahead might be in the edited range (see the example - // in canReuseVariableDeclaratorNode for a good case of this). - case 20 /* HeritageClauses */: - // This would probably be safe to reuse. There is no speculative parsing with - // heritage clauses. - case 17 /* TypeParameters */: - // This would probably be safe to reuse. There is no speculative parsing with - // type parameters. Note that that's because type *parameters* only occur in - // unambiguous *type* contexts. While type *arguments* occur in very ambiguous - // *expression* contexts. - case 19 /* TupleElementTypes */: - // This would probably be safe to reuse. There is no speculative parsing with - // tuple types. - // Technically, type argument list types are probably safe to reuse. While - // speculative parsing is involved with them (since type argument lists are only - // produced from speculative parsing a < as a type argument list), we only have - // the types because speculative parsing succeeded. Thus, the lookahead never - // went past the end of the list and rewound. - case 18 /* TypeArguments */: - // Note: these are almost certainly not safe to ever reuse. Expressions commonly - // need a large amount of lookahead, and we should not reuse them as they may - // have actually intersected the edit. - case 11 /* ArgumentExpressions */: - // This is not safe to reuse for the same reason as the 'AssignmentExpression' - // cases. i.e. a property assignment may end with an expression, and thus might - // have lookahead far beyond it's old node. - case 12 /* ObjectLiteralMembers */: - // This is probably not safe to reuse. There can be speculative parsing with - // type names in a heritage clause. There can be generic names in the type - // name list, and there can be left hand side expressions (which can have type - // arguments.) - case 7 /* HeritageClauseElement */: - // Perhaps safe to reuse, but it's unlikely we'd see more than a dozen attributes - // on any given element. Same for children. - case 13 /* JsxAttributes */: - case 14 /* JsxChildren */: - } - return false; - } - function isReusableClassMember(node) { - if (node) { - switch (node.kind) { - case 144 /* Constructor */: - case 149 /* IndexSignature */: - case 145 /* GetAccessor */: - case 146 /* SetAccessor */: - case 141 /* PropertyDeclaration */: - case 191 /* SemicolonClassElement */: - return true; - case 143 /* MethodDeclaration */: - // Method declarations are not necessarily reusable. An object-literal - // may have a method calls "constructor(...)" and we must reparse that - // into an actual .ConstructorDeclaration. - var methodDeclaration = node; - var nameIsConstructor = methodDeclaration.name.kind === 69 /* Identifier */ && - methodDeclaration.name.originalKeywordKind === 121 /* ConstructorKeyword */; - return !nameIsConstructor; - } - } - return false; - } - function isReusableSwitchClause(node) { - if (node) { - switch (node.kind) { - case 241 /* CaseClause */: - case 242 /* DefaultClause */: - return true; - } - } - return false; - } - function isReusableStatement(node) { - if (node) { - switch (node.kind) { - case 213 /* FunctionDeclaration */: - case 193 /* VariableStatement */: - case 192 /* Block */: - case 196 /* IfStatement */: - case 195 /* ExpressionStatement */: - case 208 /* ThrowStatement */: - case 204 /* ReturnStatement */: - case 206 /* SwitchStatement */: - case 203 /* BreakStatement */: - case 202 /* ContinueStatement */: - case 200 /* ForInStatement */: - case 201 /* ForOfStatement */: - case 199 /* ForStatement */: - case 198 /* WhileStatement */: - case 205 /* WithStatement */: - case 194 /* EmptyStatement */: - case 209 /* TryStatement */: - case 207 /* LabeledStatement */: - case 197 /* DoStatement */: - case 210 /* DebuggerStatement */: - case 222 /* ImportDeclaration */: - case 221 /* ImportEqualsDeclaration */: - case 228 /* ExportDeclaration */: - case 227 /* ExportAssignment */: - case 218 /* ModuleDeclaration */: - case 214 /* ClassDeclaration */: - case 215 /* InterfaceDeclaration */: - case 217 /* EnumDeclaration */: - case 216 /* TypeAliasDeclaration */: - return true; - } - } - return false; - } - function isReusableEnumMember(node) { - return node.kind === 247 /* EnumMember */; - } - function isReusableTypeMember(node) { - if (node) { - switch (node.kind) { - case 148 /* ConstructSignature */: - case 142 /* MethodSignature */: - case 149 /* IndexSignature */: - case 140 /* PropertySignature */: - case 147 /* CallSignature */: - return true; - } - } - return false; - } - function isReusableVariableDeclaration(node) { - if (node.kind !== 211 /* VariableDeclaration */) { - return false; - } - // Very subtle incremental parsing bug. Consider the following code: - // - // let v = new List < A, B - // - // This is actually legal code. It's a list of variable declarators "v = new List() - // - // then we have a problem. "v = new List= 0) { - // Always preserve a trailing comma by marking it on the NodeArray - result.hasTrailingComma = true; - } - result.end = getNodeEnd(); - parsingContext = saveParsingContext; - return result; - } - function createMissingList() { - var pos = getNodePos(); - var result = []; - result.pos = pos; - result.end = pos; - return result; - } - function parseBracketedList(kind, parseElement, open, close) { - if (parseExpected(open)) { - var result = parseDelimitedList(kind, parseElement); - parseExpected(close); - return result; - } - return createMissingList(); - } - // 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(135 /* QualifiedName */, entity.pos); - node.left = entity; - node.right = parseRightSideOfDot(allowReservedWords); - entity = finishNode(node); - } - return entity; - } - function parseRightSideOfDot(allowIdentifierNames) { - // Technically a keyword is valid here as all identifiers and keywords are identifier names. - // However, often we'll encounter this in error situations when the identifier or keyword - // is actually starting another valid construct. - // - // So, we check for the following specific case: - // - // name. - // identifierOrKeyword identifierNameOrKeyword - // - // Note: the newlines are important here. For example, if that above code - // were rewritten into: - // - // name.identifierOrKeyword - // identifierNameOrKeyword - // - // Then we would consider it valid. That's because ASI would take effect and - // the code would be implicitly: "name.identifierOrKeyword; identifierNameOrKeyword". - // In the first case though, ASI will not take effect because there is not a - // line terminator after the identifier or keyword. - if (scanner.hasPrecedingLineBreak() && ts.tokenIsIdentifierOrKeyword(token)) { - var matchesPattern = lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine); - if (matchesPattern) { - // 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 */, /*reportAtCurrentToken*/ true, ts.Diagnostics.Identifier_expected); - } - } - return allowIdentifierNames ? parseIdentifierName() : parseIdentifier(); - } - function parseTemplateExpression() { - var template = createNode(183 /* TemplateExpression */); - template.head = parseLiteralNode(); - ts.Debug.assert(template.head.kind === 12 /* TemplateHead */, "Template head has wrong token kind"); - var templateSpans = []; - templateSpans.pos = getNodePos(); - do { - templateSpans.push(parseTemplateSpan()); - } while (ts.lastOrUndefined(templateSpans).literal.kind === 13 /* TemplateMiddle */); - templateSpans.end = getNodeEnd(); - template.templateSpans = templateSpans; - return finishNode(template); - } - function parseTemplateSpan() { - var span = createNode(190 /* TemplateSpan */); - span.expression = allowInAnd(parseExpression); - var literal; - if (token === 16 /* CloseBraceToken */) { - reScanTemplateToken(); - literal = parseLiteralNode(); - } - else { - literal = parseExpectedToken(14 /* TemplateTail */, /*reportAtCurrentPosition*/ false, ts.Diagnostics._0_expected, ts.tokenToString(16 /* CloseBraceToken */)); - } - span.literal = literal; - return finishNode(span); - } - function parseLiteralNode(internName) { - var node = createNode(token); - var text = scanner.getTokenValue(); - node.text = internName ? internIdentifier(text) : text; - if (scanner.hasExtendedUnicodeEscape()) { - node.hasExtendedUnicodeEscape = true; - } - if (scanner.isUnterminated()) { - node.isUnterminated = true; - } - var tokenPos = scanner.getTokenPos(); - nextToken(); - finishNode(node); - // Octal literals are not allowed in strict mode or ES5 - // Note that theoretically the following condition would hold true literals like 009, - // which is not octal.But because of how the scanner separates the tokens, we would - // never get a token like this. Instead, we would get 00 and 9 as two separate tokens. - // We also do not need to check for negatives because any prefix operator would be part of a - // parent unary expression. - if (node.kind === 8 /* NumericLiteral */ - && sourceText.charCodeAt(tokenPos) === 48 /* _0 */ - && ts.isOctalDigit(sourceText.charCodeAt(tokenPos + 1))) { - node.flags |= 65536 /* OctalLiteral */; - } - return node; - } - // TYPES - function parseTypeReferenceOrTypePredicate() { - var typeName = parseEntityName(/*allowReservedWords*/ false, ts.Diagnostics.Type_expected); - if (typeName.kind === 69 /* Identifier */ && token === 124 /* IsKeyword */ && !scanner.hasPrecedingLineBreak()) { - nextToken(); - var node_1 = createNode(150 /* TypePredicate */, typeName.pos); - node_1.parameterName = typeName; - node_1.type = parseType(); - return finishNode(node_1); - } - var node = createNode(151 /* TypeReference */, typeName.pos); - node.typeName = typeName; - if (!scanner.hasPrecedingLineBreak() && token === 25 /* LessThanToken */) { - node.typeArguments = parseBracketedList(18 /* TypeArguments */, parseType, 25 /* LessThanToken */, 27 /* GreaterThanToken */); - } - return finishNode(node); - } - function parseTypeQuery() { - var node = createNode(154 /* TypeQuery */); - parseExpected(101 /* TypeOfKeyword */); - node.exprName = parseEntityName(/*allowReservedWords*/ true); - return finishNode(node); - } - function parseTypeParameter() { - var node = createNode(137 /* TypeParameter */); - node.name = parseIdentifier(); - if (parseOptional(83 /* ExtendsKeyword */)) { - // It's not uncommon for people to write improper constraints to a generic. If the - // user writes a constraint that is an expression and not an actual type, then parse - // it out as an expression (so we can recover well), but report that a type is needed - // instead. - if (isStartOfType() || !isStartOfExpression()) { - node.constraint = parseType(); - } - else { - // It was not a type, and it looked like an expression. Parse out an expression - // here so we recover well. Note: it is important that we call parseUnaryExpression - // and not parseExpression here. If the user has: - // - // - // - // We do *not* want to consume the > as we're consuming the expression for "". - node.expression = parseUnaryExpressionOrHigher(); - } - } - return finishNode(node); - } - function parseTypeParameters() { - if (token === 25 /* LessThanToken */) { - return parseBracketedList(17 /* TypeParameters */, parseTypeParameter, 25 /* LessThanToken */, 27 /* GreaterThanToken */); - } - } - function parseParameterType() { - if (parseOptional(54 /* ColonToken */)) { - return token === 9 /* StringLiteral */ - ? parseLiteralNode(/*internName*/ true) - : parseType(); - } - return undefined; - } - function isStartOfParameter() { - return token === 22 /* DotDotDotToken */ || isIdentifierOrPattern() || ts.isModifier(token) || token === 55 /* AtToken */; - } - function setModifiers(node, modifiers) { - if (modifiers) { - node.flags |= modifiers.flags; - node.modifiers = modifiers; - } - } - function parseParameter() { - var node = createNode(138 /* Parameter */); - node.decorators = parseDecorators(); - setModifiers(node, parseModifiers()); - node.dotDotDotToken = parseOptionalToken(22 /* DotDotDotToken */); - // FormalParameter [Yield,Await]: - // BindingElement[?Yield,?Await] - node.name = parseIdentifierOrPattern(); - if (ts.getFullWidth(node.name) === 0 && node.flags === 0 && ts.isModifier(token)) { - // in cases like - // 'use strict' - // function foo(static) - // isParameter('static') === true, because of isModifier('static') - // however 'static' is not a legal identifier in a strict mode. - // so result of this function will be ParameterDeclaration (flags = 0, name = missing, type = undefined, initializer = undefined) - // and current token will not change => parsing of the enclosing parameter list will last till the end of time (or OOM) - // to avoid this we'll advance cursor to the next token. - nextToken(); - } - node.questionToken = parseOptionalToken(53 /* QuestionToken */); - node.type = parseParameterType(); - node.initializer = parseBindingElementInitializer(/*inParameter*/ true); - // Do not check for initializers in an ambient context for parameters. This is not - // a grammar error because the grammar allows arbitrary call signatures in - // an ambient context. - // It is actually not necessary for this to be an error at all. The reason is that - // function/constructor implementations are syntactically disallowed in ambient - // contexts. In addition, parameter initializers are semantically disallowed in - // overload signatures. So parameter initializers are transitively disallowed in - // ambient contexts. - return finishNode(node); - } - function parseBindingElementInitializer(inParameter) { - return inParameter ? parseParameterInitializer() : parseNonParameterInitializer(); - } - function parseParameterInitializer() { - return parseInitializer(/*inParameter*/ true); - } - function fillSignature(returnToken, yieldContext, awaitContext, requireCompleteParameterList, signature) { - var returnTokenRequired = returnToken === 34 /* EqualsGreaterThanToken */; - signature.typeParameters = parseTypeParameters(); - signature.parameters = parseParameterList(yieldContext, awaitContext, requireCompleteParameterList); - if (returnTokenRequired) { - parseExpected(returnToken); - signature.type = parseType(); - } - else if (parseOptional(returnToken)) { - signature.type = parseType(); - } - } - function parseParameterList(yieldContext, awaitContext, requireCompleteParameterList) { - // FormalParameters [Yield,Await]: (modified) - // [empty] - // FormalParameterList[?Yield,Await] - // - // FormalParameter[Yield,Await]: (modified) - // BindingElement[?Yield,Await] - // - // BindingElement [Yield,Await]: (modified) - // SingleNameBinding[?Yield,?Await] - // BindingPattern[?Yield,?Await]Initializer [In, ?Yield,?Await] opt - // - // SingleNameBinding [Yield,Await]: - // BindingIdentifier[?Yield,?Await]Initializer [In, ?Yield,?Await] opt - if (parseExpected(17 /* OpenParenToken */)) { - var savedYieldContext = inYieldContext(); - var savedAwaitContext = inAwaitContext(); - setYieldContext(yieldContext); - setAwaitContext(awaitContext); - var result = parseDelimitedList(16 /* Parameters */, parseParameter); - setYieldContext(savedYieldContext); - setAwaitContext(savedAwaitContext); - if (!parseExpected(18 /* CloseParenToken */) && requireCompleteParameterList) { - // Caller insisted that we had to end with a ) We didn't. So just return - // undefined here. - return undefined; - } - return result; - } - // We didn't even have an open paren. If the caller requires a complete parameter list, - // we definitely can't provide that. However, if they're ok with an incomplete one, - // then just return an empty set of parameters. - return requireCompleteParameterList ? undefined : createMissingList(); - } - 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 */)) { - return; - } - // Didn't have a comma. We must have a (possible ASI) semicolon. - parseSemicolon(); - } - function parseSignatureMember(kind) { - var node = createNode(kind); - if (kind === 148 /* ConstructSignature */) { - parseExpected(92 /* NewKeyword */); - } - fillSignature(54 /* ColonToken */, /*yieldContext*/ false, /*awaitContext*/ false, /*requireCompleteParameterList*/ false, node); - parseTypeMemberSemicolon(); - return finishNode(node); - } - function isIndexSignature() { - if (token !== 19 /* OpenBracketToken */) { - return false; - } - return lookAhead(isUnambiguouslyIndexSignature); - } - function isUnambiguouslyIndexSignature() { - // The only allowed sequence is: - // - // [id: - // - // However, for error recovery, we also check the following cases: - // - // [... - // [id, - // [id?, - // [id?: - // [id?] - // [public id - // [private id - // [protected id - // [] - // - nextToken(); - if (token === 22 /* DotDotDotToken */ || token === 20 /* CloseBracketToken */) { - return true; - } - if (ts.isModifier(token)) { - nextToken(); - if (isIdentifier()) { - return true; - } - } - else if (!isIdentifier()) { - return false; - } - else { - // Skip the identifier - nextToken(); - } - // 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 */) { - 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 */) { - 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 */; - } - function parseIndexSignatureDeclaration(fullStart, decorators, modifiers) { - var node = createNode(149 /* IndexSignature */, fullStart); - node.decorators = decorators; - setModifiers(node, modifiers); - node.parameters = parseBracketedList(16 /* Parameters */, parseParameter, 19 /* OpenBracketToken */, 20 /* CloseBracketToken */); - node.type = parseTypeAnnotation(); - parseTypeMemberSemicolon(); - return finishNode(node); - } - function parsePropertyOrMethodSignature() { - var fullStart = scanner.getStartPos(); - var name = parsePropertyName(); - var questionToken = parseOptionalToken(53 /* QuestionToken */); - if (token === 17 /* OpenParenToken */ || token === 25 /* LessThanToken */) { - var method = createNode(142 /* MethodSignature */, fullStart); - method.name = name; - method.questionToken = questionToken; - // Method signatues don't exist in expression contexts. So they have neither - // [Yield] nor [Await] - fillSignature(54 /* ColonToken */, /*yieldContext*/ false, /*awaitContext*/ false, /*requireCompleteParameterList*/ false, method); - parseTypeMemberSemicolon(); - return finishNode(method); - } - else { - var property = createNode(140 /* PropertySignature */, fullStart); - property.name = name; - property.questionToken = questionToken; - property.type = parseTypeAnnotation(); - parseTypeMemberSemicolon(); - return finishNode(property); - } - } - function isStartOfTypeMember() { - switch (token) { - case 17 /* OpenParenToken */: - case 25 /* LessThanToken */: - case 19 /* OpenBracketToken */: - return true; - default: - if (ts.isModifier(token)) { - var result = lookAhead(isStartOfIndexSignatureDeclaration); - if (result) { - return result; - } - } - return isLiteralPropertyName() && lookAhead(isTypeMemberWithLiteralPropertyName); - } - } - function isStartOfIndexSignatureDeclaration() { - while (ts.isModifier(token)) { - nextToken(); - } - return isIndexSignature(); - } - function isTypeMemberWithLiteralPropertyName() { - nextToken(); - return token === 17 /* OpenParenToken */ || - token === 25 /* LessThanToken */ || - token === 53 /* QuestionToken */ || - token === 54 /* ColonToken */ || - canParseSemicolon(); - } - function parseTypeMember() { - switch (token) { - case 17 /* OpenParenToken */: - case 25 /* LessThanToken */: - return parseSignatureMember(147 /* CallSignature */); - case 19 /* OpenBracketToken */: - // Indexer or computed property - return isIndexSignature() - ? parseIndexSignatureDeclaration(scanner.getStartPos(), /*decorators*/ undefined, /*modifiers*/ undefined) - : parsePropertyOrMethodSignature(); - case 92 /* NewKeyword */: - if (lookAhead(isStartOfConstructSignature)) { - return parseSignatureMember(148 /* ConstructSignature */); - } - // fall through. - case 9 /* StringLiteral */: - case 8 /* NumericLiteral */: - return parsePropertyOrMethodSignature(); - default: - // Index declaration as allowed as a type member. But as per the grammar, - // they also allow modifiers. So we have to check for an index declaration - // that might be following modifiers. This ensures that things work properly - // when incrementally parsing as the parser will produce the Index declaration - // if it has the same text regardless of whether it is inside a class or an - // object type. - if (ts.isModifier(token)) { - var result = tryParse(parseIndexSignatureWithModifiers); - if (result) { - return result; - } - } - if (ts.tokenIsIdentifierOrKeyword(token)) { - return parsePropertyOrMethodSignature(); - } - } - } - function parseIndexSignatureWithModifiers() { - var fullStart = scanner.getStartPos(); - var decorators = parseDecorators(); - var modifiers = parseModifiers(); - return isIndexSignature() - ? parseIndexSignatureDeclaration(fullStart, decorators, modifiers) - : undefined; - } - function isStartOfConstructSignature() { - nextToken(); - return token === 17 /* OpenParenToken */ || token === 25 /* LessThanToken */; - } - function parseTypeLiteral() { - var node = createNode(155 /* TypeLiteral */); - node.members = parseObjectTypeMembers(); - return finishNode(node); - } - function parseObjectTypeMembers() { - var members; - if (parseExpected(15 /* OpenBraceToken */)) { - members = parseList(4 /* TypeMembers */, parseTypeMember); - parseExpected(16 /* CloseBraceToken */); - } - else { - members = createMissingList(); - } - return members; - } - function parseTupleType() { - var node = createNode(157 /* TupleType */); - node.elementTypes = parseBracketedList(19 /* TupleElementTypes */, parseType, 19 /* OpenBracketToken */, 20 /* CloseBracketToken */); - return finishNode(node); - } - function parseParenthesizedType() { - var node = createNode(160 /* ParenthesizedType */); - parseExpected(17 /* OpenParenToken */); - node.type = parseType(); - parseExpected(18 /* CloseParenToken */); - return finishNode(node); - } - function parseFunctionOrConstructorType(kind) { - var node = createNode(kind); - if (kind === 153 /* ConstructorType */) { - parseExpected(92 /* NewKeyword */); - } - fillSignature(34 /* EqualsGreaterThanToken */, /*yieldContext*/ false, /*awaitContext*/ false, /*requireCompleteParameterList*/ false, node); - return finishNode(node); - } - function parseKeywordAndNoDot() { - var node = parseTokenNode(); - return token === 21 /* DotToken */ ? undefined : node; - } - function parseNonArrayType() { - switch (token) { - case 117 /* AnyKeyword */: - case 130 /* StringKeyword */: - case 128 /* NumberKeyword */: - case 120 /* BooleanKeyword */: - case 131 /* SymbolKeyword */: - // If these are followed by a dot, then parse these out as a dotted type reference instead. - var node = tryParse(parseKeywordAndNoDot); - return node || parseTypeReferenceOrTypePredicate(); - case 103 /* VoidKeyword */: - case 97 /* ThisKeyword */: - return parseTokenNode(); - case 101 /* TypeOfKeyword */: - return parseTypeQuery(); - case 15 /* OpenBraceToken */: - return parseTypeLiteral(); - case 19 /* OpenBracketToken */: - return parseTupleType(); - case 17 /* OpenParenToken */: - return parseParenthesizedType(); - default: - return parseTypeReferenceOrTypePredicate(); - } - } - function isStartOfType() { - switch (token) { - case 117 /* AnyKeyword */: - case 130 /* StringKeyword */: - case 128 /* NumberKeyword */: - case 120 /* BooleanKeyword */: - case 131 /* SymbolKeyword */: - case 103 /* VoidKeyword */: - case 97 /* ThisKeyword */: - case 101 /* TypeOfKeyword */: - case 15 /* OpenBraceToken */: - case 19 /* OpenBracketToken */: - case 25 /* LessThanToken */: - case 92 /* NewKeyword */: - return true; - case 17 /* 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); - default: - return isIdentifier(); - } - } - function isStartOfParenthesizedOrFunctionType() { - nextToken(); - return token === 18 /* CloseParenToken */ || isStartOfParameter() || isStartOfType(); - } - function parseArrayTypeOrHigher() { - var type = parseNonArrayType(); - while (!scanner.hasPrecedingLineBreak() && parseOptional(19 /* OpenBracketToken */)) { - parseExpected(20 /* CloseBracketToken */); - var node = createNode(156 /* ArrayType */, type.pos); - node.elementType = type; - type = finishNode(node); - } - return type; - } - function parseUnionOrIntersectionType(kind, parseConstituentType, operator) { - var type = parseConstituentType(); - if (token === operator) { - var types = [type]; - types.pos = type.pos; - while (parseOptional(operator)) { - types.push(parseConstituentType()); - } - types.end = getNodeEnd(); - var node = createNode(kind, type.pos); - node.types = types; - type = finishNode(node); - } - return type; - } - function parseIntersectionTypeOrHigher() { - return parseUnionOrIntersectionType(159 /* IntersectionType */, parseArrayTypeOrHigher, 46 /* AmpersandToken */); - } - function parseUnionTypeOrHigher() { - return parseUnionOrIntersectionType(158 /* UnionType */, parseIntersectionTypeOrHigher, 47 /* BarToken */); - } - function isStartOfFunctionType() { - if (token === 25 /* LessThanToken */) { - return true; - } - return token === 17 /* OpenParenToken */ && lookAhead(isUnambiguouslyStartOfFunctionType); - } - function isUnambiguouslyStartOfFunctionType() { - nextToken(); - if (token === 18 /* CloseParenToken */ || token === 22 /* DotDotDotToken */) { - // ( ) - // ( ... - return true; - } - if (isIdentifier() || ts.isModifier(token)) { - nextToken(); - if (token === 54 /* ColonToken */ || token === 24 /* CommaToken */ || - token === 53 /* QuestionToken */ || token === 56 /* EqualsToken */ || - isIdentifier() || ts.isModifier(token)) { - // ( id : - // ( id , - // ( id ? - // ( id = - // ( modifier id - return true; - } - if (token === 18 /* CloseParenToken */) { - nextToken(); - if (token === 34 /* EqualsGreaterThanToken */) { - // ( id ) => - return true; - } - } - } - return false; - } - function parseType() { - // The rules about 'yield' only apply to actual code/expression contexts. They don't - // apply to 'type' contexts. So we disable these parameters here before moving on. - return doOutsideOfContext(10 /* TypeExcludesFlags */, parseTypeWorker); - } - function parseTypeWorker() { - if (isStartOfFunctionType()) { - return parseFunctionOrConstructorType(152 /* FunctionType */); - } - if (token === 92 /* NewKeyword */) { - return parseFunctionOrConstructorType(153 /* ConstructorType */); - } - return parseUnionTypeOrHigher(); - } - function parseTypeAnnotation() { - return parseOptional(54 /* ColonToken */) ? parseType() : undefined; - } - // EXPRESSIONS - function isStartOfLeftHandSideExpression() { - switch (token) { - case 97 /* ThisKeyword */: - case 95 /* SuperKeyword */: - case 93 /* NullKeyword */: - case 99 /* TrueKeyword */: - case 84 /* 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 */: - return true; - default: - return isIdentifier(); - } - } - function isStartOfExpression() { - if (isStartOfLeftHandSideExpression()) { - 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 */: - // 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. - return true; - default: - // Error tolerance. If we see the start of some binary operator, we consider - // that the start of an expression. That way we'll parse out a missing identifier, - // give a good message about an identifier being missing, and then consume the - // rest of the binary expression. - if (isBinaryOperator()) { - return true; - } - return isIdentifier(); - } - } - 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 */ && - isStartOfExpression(); - } - function allowInAndParseExpression() { - return allowInAnd(parseExpression); - } - function parseExpression() { - // Expression[in]: - // AssignmentExpression[in] - // Expression[in] , AssignmentExpression[in] - // clear the decorator context when parsing Expression, as it should be unambiguous when parsing a decorator - var saveDecoratorContext = inDecoratorContext(); - if (saveDecoratorContext) { - setDecoratorContext(false); - } - var expr = parseAssignmentExpressionOrHigher(); - var operatorToken; - while ((operatorToken = parseOptionalToken(24 /* CommaToken */))) { - expr = makeBinaryExpression(expr, operatorToken, parseAssignmentExpressionOrHigher()); - } - if (saveDecoratorContext) { - setDecoratorContext(true); - } - return expr; - } - function parseInitializer(inParameter) { - if (token !== 56 /* EqualsToken */) { - // It's not uncommon during typing for the user to miss writing the '=' token. Check if - // there is no newline after the last token and if we're on an expression. If so, parse - // this as an equals-value clause with a missing equals. - // NOTE: There are two places where we allow equals-value clauses. The first is in a - // variable declarator. The second is with a parameter. For variable declarators - // 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()) { - // 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; - } - } - // Initializer[In, Yield] : - // = AssignmentExpression[?In, ?Yield] - parseExpected(56 /* EqualsToken */); - return parseAssignmentExpressionOrHigher(); - } - function parseAssignmentExpressionOrHigher() { - // AssignmentExpression[in,yield]: - // 1) ConditionalExpression[?in,?yield] - // 2) LeftHandSideExpression = AssignmentExpression[?in,?yield] - // 3) LeftHandSideExpression AssignmentOperator AssignmentExpression[?in,?yield] - // 4) ArrowFunctionExpression[?in,?yield] - // 5) [+Yield] YieldExpression[?In] - // - // Note: for ease of implementation we treat productions '2' and '3' as the same thing. - // (i.e. they're both BinaryExpressions with an assignment operator in it). - // First, do the simple check if we have a YieldExpression (production '5'). - if (isYieldExpression()) { - return parseYieldExpression(); - } - // Then, check if we have an arrow function (production '4') that starts with a parenthesized - // parameter list. If we do, we must *not* recurse for productions 1, 2 or 3. An ArrowFunction is - // not a LeftHandSideExpression, nor does it start a ConditionalExpression. So we are done - // with AssignmentExpression if we see one. - var arrowExpression = tryParseParenthesizedArrowFunctionExpression(); - if (arrowExpression) { - return arrowExpression; - } - // Now try to see if we're in production '1', '2' or '3'. A conditional expression can - // start with a LogicalOrExpression, while the assignment productions can only start with - // LeftHandSideExpressions. - // - // So, first, we try to just parse out a BinaryExpression. If we get something that is a - // LeftHandSide or higher, then we can try to parse out the assignment expression part. - // Otherwise, we try to parse out the conditional expression bit. We want to allow any - // binary expression here, so we pass in the 'lowest' precedence here so that it matches - // and consumes anything. - var expr = parseBinaryExpressionOrHigher(/*precedence*/ 0); - // 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 */) { - return parseSimpleArrowFunctionExpression(expr); - } - // Now see if we might be in cases '2' or '3'. - // If the expression was a LHS expression, and we have an assignment operator, then - // we're in '2' or '3'. Consume the assignment and return. - // - // Note: we call reScanGreaterToken so that we get an appropriately merged token - // for cases like > > = becoming >>= - if (ts.isLeftHandSideExpression(expr) && ts.isAssignmentOperator(reScanGreaterToken())) { - return makeBinaryExpression(expr, parseTokenNode(), parseAssignmentExpressionOrHigher()); - } - // It wasn't an assignment or a lambda. This is a conditional expression: - return parseConditionalExpressionRest(expr); - } - function isYieldExpression() { - if (token === 114 /* YieldKeyword */) { - // If we have a 'yield' keyword, and htis is a context where yield expressions are - // allowed, then definitely parse out a yield expression. - if (inYieldContext()) { - return true; - } - // We're in a context where 'yield expr' is not allowed. However, if we can - // definitely tell that the user was trying to parse a 'yield expr' and not - // just a normal expr that start with a 'yield' identifier, then parse out - // a 'yield expr'. We can then report an error later that they are only - // allowed in generator expressions. - // - // for example, if we see 'yield(foo)', then we'll have to treat that as an - // invocation expression of something called 'yield'. However, if we have - // 'yield foo' then that is not legal as a normal expression, so we can - // definitely recognize this as a yield expression. - // - // for now we just check if the next token is an identifier. More heuristics - // can be added here later as necessary. We just need to make sure that we - // don't accidently consume something legal. - return lookAhead(nextTokenIsIdentifierOrKeywordOrNumberOnSameLine); - } - return false; - } - function nextTokenIsIdentifierOnSameLine() { - nextToken(); - return !scanner.hasPrecedingLineBreak() && isIdentifier(); - } - function parseYieldExpression() { - var node = createNode(184 /* 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 */); - node.expression = parseAssignmentExpressionOrHigher(); - return finishNode(node); - } - else { - // if the next token is not on the same line as yield. or we don't have an '*' or - // the start of an expressin, then this is just a simple "yield" expression. - return finishNode(node); - } - } - function parseSimpleArrowFunctionExpression(identifier) { - ts.Debug.assert(token === 34 /* EqualsGreaterThanToken */, "parseSimpleArrowFunctionExpression should only have been called if we had a =>"); - var node = createNode(174 /* ArrowFunction */, identifier.pos); - var parameter = createNode(138 /* Parameter */, identifier.pos); - parameter.name = identifier; - finishNode(parameter); - node.parameters = [parameter]; - node.parameters.pos = parameter.pos; - node.parameters.end = parameter.end; - node.equalsGreaterThanToken = parseExpectedToken(34 /* EqualsGreaterThanToken */, false, ts.Diagnostics._0_expected, "=>"); - node.body = parseArrowFunctionExpressionBody(/*isAsync*/ false); - return finishNode(node); - } - function tryParseParenthesizedArrowFunctionExpression() { - var triState = isParenthesizedArrowFunctionExpression(); - if (triState === 0 /* False */) { - // It's definitely not a parenthesized arrow function expression. - return undefined; - } - // If we definitely have an arrow function, then we can just parse one, not requiring a - // following => or { token. Otherwise, we *might* have an arrow function. Try to parse - // it out, but don't allow any ambiguity, and return 'undefined' if this could be an - // expression instead. - var arrowFunction = triState === 1 /* True */ - ? parseParenthesizedArrowFunctionExpressionHead(/*allowAmbiguity*/ true) - : tryParse(parsePossibleParenthesizedArrowFunctionExpressionHead); - if (!arrowFunction) { - // Didn't appear to actually be a parenthesized arrow function. Just bail out. - return undefined; - } - var isAsync = !!(arrowFunction.flags & 512 /* Async */); - // 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 */) - ? parseArrowFunctionExpressionBody(isAsync) - : parseIdentifier(); - return finishNode(arrowFunction); - } - // True -> We definitely expect a parenthesized arrow function here. - // False -> There *cannot* be a parenthesized arrow function here. - // 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 */) { - return lookAhead(isParenthesizedArrowFunctionExpressionWorker); - } - if (token === 34 /* 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. - return 1 /* True */; - } - // Definitely not a parenthesized arrow function. - return 0 /* False */; - } - function isParenthesizedArrowFunctionExpressionWorker() { - if (token === 118 /* AsyncKeyword */) { - nextToken(); - if (scanner.hasPrecedingLineBreak()) { - return 0 /* False */; - } - if (token !== 17 /* OpenParenToken */ && token !== 25 /* LessThanToken */) { - return 0 /* False */; - } - } - var first = token; - var second = nextToken(); - if (first === 17 /* OpenParenToken */) { - if (second === 18 /* 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 */: - return 1 /* True */; - default: - return 0 /* False */; - } - } - // If encounter "([" or "({", this could be the start of a binding pattern. - // Examples: - // ([ x ]) => { } - // ({ x }) => { } - // ([ x ]) - // ({ x }) - if (second === 19 /* OpenBracketToken */ || second === 15 /* OpenBraceToken */) { - return 2 /* Unknown */; - } - // Simple case: "(..." - // This is an arrow function with a rest parameter. - if (second === 22 /* DotDotDotToken */) { - return 1 /* True */; - } - // If we had "(" followed by something that's not an identifier, - // then this definitely doesn't look like a lambda. - // Note: we could be a little more lenient and allow - // "(public" or "(private". These would not ever actually be allowed, - // but we could provide a good error message instead of bailing out. - if (!isIdentifier()) { - return 0 /* False */; - } - // If we have something like "(a:", then we must have a - // type-annotated parameter in an arrow function expression. - if (nextToken() === 54 /* ColonToken */) { - return 1 /* True */; - } - // This *could* be a parenthesized arrow function. - // Return Unknown to let the caller know. - return 2 /* Unknown */; - } - else { - ts.Debug.assert(first === 25 /* LessThanToken */); - // If we have "<" not followed by an identifier, - // then this definitely is not an arrow function. - if (!isIdentifier()) { - return 0 /* False */; - } - // JSX overrides - if (sourceFile.languageVariant === 1 /* JSX */) { - var isArrowFunctionInJsx = lookAhead(function () { - var third = nextToken(); - if (third === 83 /* ExtendsKeyword */) { - var fourth = nextToken(); - switch (fourth) { - case 56 /* EqualsToken */: - case 27 /* GreaterThanToken */: - return false; - default: - return true; - } - } - else if (third === 24 /* CommaToken */) { - return true; - } - return false; - }); - if (isArrowFunctionInJsx) { - return 1 /* True */; - } - return 0 /* False */; - } - // This *could* be a parenthesized arrow function. - return 2 /* Unknown */; - } - } - function parsePossibleParenthesizedArrowFunctionExpressionHead() { - return parseParenthesizedArrowFunctionExpressionHead(/*allowAmbiguity*/ false); - } - function parseParenthesizedArrowFunctionExpressionHead(allowAmbiguity) { - var node = createNode(174 /* ArrowFunction */); - setModifiers(node, parseModifiersForArrowFunction()); - var isAsync = !!(node.flags & 512 /* Async */); - // Arrow functions are never generators. - // - // If we're speculatively parsing a signature for a parenthesized arrow function, then - // we have to have a complete parameter list. Otherwise we might see something like - // 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); - // If we couldn't get parameters, we definitely could not parse out an arrow function. - if (!node.parameters) { - return undefined; - } - // Parsing a signature isn't enough. - // Parenthesized arrow signatures often look like other valid expressions. - // For instance: - // - "(x = 10)" is an assignment expression parsed as a signature with a default parameter value. - // - "(x,y)" is a comma expression parsed as a signature with two parameters. - // - "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 */) { - // 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 */) { - return parseFunctionBlock(/*allowYield*/ false, /*allowAwait*/ isAsync, /*ignoreMissingOpenBrace*/ false); - } - if (token !== 23 /* SemicolonToken */ && - token !== 87 /* FunctionKeyword */ && - token !== 73 /* ClassKeyword */ && - isStartOfStatement() && - !isStartOfExpressionStatement()) { - // Check if we got a plain statement (i.e. no expression-statements, no function/class expressions/declarations) - // - // Here we try to recover from a potential error situation in the case where the - // user meant to supply a block. For example, if the user wrote: - // - // a => - // let v = 0; - // } - // - // they may be missing an open brace. Check to see if that's the case so we can - // try to recover better. If we don't do this, then the next close curly we see may end - // up preemptively closing the containing construct. - // - // Note: even when 'ignoreMissingOpenBrace' is passed as true, parseBody will still error. - return parseFunctionBlock(/*allowYield*/ false, /*allowAwait*/ isAsync, /*ignoreMissingOpenBrace*/ true); - } - return isAsync - ? doInAwaitContext(parseAssignmentExpressionOrHigher) - : doOutsideOfAwaitContext(parseAssignmentExpressionOrHigher); - } - function parseConditionalExpressionRest(leftOperand) { - // Note: we are passed in an expression which was produced from parseBinaryExpressionOrHigher. - var questionToken = parseOptionalToken(53 /* QuestionToken */); - if (!questionToken) { - return leftOperand; - } - // Note: we explicitly 'allowIn' in the whenTrue part of the condition expression, and - // we do not that for the 'whenFalse' part. - var node = createNode(182 /* 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.whenFalse = parseAssignmentExpressionOrHigher(); - return finishNode(node); - } - function parseBinaryExpressionOrHigher(precedence) { - var leftOperand = parseUnaryExpressionOrHigher(); - return parseBinaryExpressionRest(precedence, leftOperand); - } - function isInOrOfKeyword(t) { - return t === 90 /* InKeyword */ || t === 134 /* OfKeyword */; - } - function parseBinaryExpressionRest(precedence, leftOperand) { - while (true) { - // We either have a binary operator here, or we're finished. We call - // reScanGreaterToken so that we merge token sequences like > and = into >= - reScanGreaterToken(); - var newPrecedence = getBinaryOperatorPrecedence(); - // Check the precedence to see if we should "take" this operator - // - For left associative operator (all operator but **), consume the operator, - // recursively call the function below, and parse binaryExpression as a rightOperand - // of the caller if the new precendence of the operator is greater then or equal to the current precendence. - // For example: - // a - b - c; - // ^token; leftOperand = b. Return b to the caller as a rightOperand - // a * b - c - // ^token; leftOperand = b. Return b to the caller as a rightOperand - // a - b * c; - // ^token; leftOperand = b. Return b * c to the caller as a rightOperand - // - For right associative operator (**), consume the operator, recursively call the function - // and parse binaryExpression as a rightOperand of the caller if the new precendence of - // the operator is strictly grater than the current precendence - // For example: - // a ** b ** c; - // ^^token; leftOperand = b. Return b ** c to the caller as a rightOperand - // a - b ** c; - // ^^token; leftOperand = b. Return b ** c to the caller as a rightOperand - // a ** b - c - // ^token; leftOperand = b. Return b to the caller as a rightOperand - var consumeCurrentOperator = token === 38 /* AsteriskAsteriskToken */ ? - newPrecedence >= precedence : - newPrecedence > precedence; - if (!consumeCurrentOperator) { - break; - } - if (token === 90 /* InKeyword */ && inDisallowInContext()) { - break; - } - if (token === 116 /* AsKeyword */) { - // Make sure we *do* perform ASI for constructs like this: - // var x = foo - // as (Bar) - // This should be parsed as an initialized variable, followed - // by a function call to 'as' with the argument 'Bar' - if (scanner.hasPrecedingLineBreak()) { - break; - } - else { - nextToken(); - leftOperand = makeAsExpression(leftOperand, parseType()); - } - } - else { - leftOperand = makeBinaryExpression(leftOperand, parseTokenNode(), parseBinaryExpressionOrHigher(newPrecedence)); - } - } - return leftOperand; - } - function isBinaryOperator() { - if (inDisallowInContext() && token === 90 /* InKeyword */) { - return false; - } - return getBinaryOperatorPrecedence() > 0; - } - function getBinaryOperatorPrecedence() { - switch (token) { - case 52 /* BarBarToken */: - return 1; - case 51 /* AmpersandAmpersandToken */: - return 2; - case 47 /* BarToken */: - return 3; - case 48 /* CaretToken */: - return 4; - case 46 /* AmpersandToken */: - return 5; - case 30 /* EqualsEqualsToken */: - case 31 /* ExclamationEqualsToken */: - case 32 /* EqualsEqualsEqualsToken */: - case 33 /* ExclamationEqualsEqualsToken */: - return 6; - case 25 /* LessThanToken */: - case 27 /* GreaterThanToken */: - case 28 /* LessThanEqualsToken */: - case 29 /* GreaterThanEqualsToken */: - case 91 /* InstanceOfKeyword */: - case 90 /* InKeyword */: - case 116 /* AsKeyword */: - return 7; - case 43 /* LessThanLessThanToken */: - case 44 /* GreaterThanGreaterThanToken */: - case 45 /* GreaterThanGreaterThanGreaterThanToken */: - return 8; - case 35 /* PlusToken */: - case 36 /* MinusToken */: - return 9; - case 37 /* AsteriskToken */: - case 39 /* SlashToken */: - case 40 /* PercentToken */: - return 10; - case 38 /* AsteriskAsteriskToken */: - return 11; - } - // -1 is lower than all other precedences. Returning it will cause binary expression - // parsing to stop. - return -1; - } - function makeBinaryExpression(left, operatorToken, right) { - var node = createNode(181 /* BinaryExpression */, left.pos); - node.left = left; - node.operatorToken = operatorToken; - node.right = right; - return finishNode(node); - } - function makeAsExpression(left, right) { - var node = createNode(189 /* AsExpression */, left.pos); - node.expression = left; - node.type = right; - return finishNode(node); - } - function parsePrefixUnaryExpression() { - var node = createNode(179 /* PrefixUnaryExpression */); - node.operator = token; - nextToken(); - node.operand = parseSimpleUnaryExpression(); - return finishNode(node); - } - function parseDeleteExpression() { - var node = createNode(175 /* DeleteExpression */); - nextToken(); - node.expression = parseSimpleUnaryExpression(); - return finishNode(node); - } - function parseTypeOfExpression() { - var node = createNode(176 /* TypeOfExpression */); - nextToken(); - node.expression = parseSimpleUnaryExpression(); - return finishNode(node); - } - function parseVoidExpression() { - var node = createNode(177 /* VoidExpression */); - nextToken(); - node.expression = parseSimpleUnaryExpression(); - return finishNode(node); - } - function isAwaitExpression() { - if (token === 119 /* AwaitKeyword */) { - if (inAwaitContext()) { - return true; - } - // here we are using similar heuristics as 'isYieldExpression' - return lookAhead(nextTokenIsIdentifierOnSameLine); - } - return false; - } - function parseAwaitExpression() { - var node = createNode(178 /* AwaitExpression */); - nextToken(); - node.expression = parseSimpleUnaryExpression(); - return finishNode(node); - } - /** - * Parse ES7 unary expression and await expression - * - * ES7 UnaryExpression: - * 1) SimpleUnaryExpression[?yield] - * 2) IncrementExpression[?yield] ** UnaryExpression[?yield] - */ - function parseUnaryExpressionOrHigher() { - if (isAwaitExpression()) { - return parseAwaitExpression(); - } - if (isIncrementExpression()) { - var incrementExpression = parseIncrementExpression(); - return token === 38 /* AsteriskAsteriskToken */ ? - parseBinaryExpressionRest(getBinaryOperatorPrecedence(), incrementExpression) : - incrementExpression; - } - var unaryOperator = token; - var simpleUnaryExpression = parseSimpleUnaryExpression(); - if (token === 38 /* AsteriskAsteriskToken */) { - var diagnostic; - var start = ts.skipTrivia(sourceText, simpleUnaryExpression.pos); - if (simpleUnaryExpression.kind === 171 /* TypeAssertionExpression */) { - parseErrorAtPosition(start, simpleUnaryExpression.end - start, ts.Diagnostics.A_type_assertion_expression_is_not_allowed_in_the_left_hand_side_of_an_exponentiation_expression_Consider_enclosing_the_expression_in_parentheses); - } - else { - parseErrorAtPosition(start, simpleUnaryExpression.end - start, ts.Diagnostics.An_unary_expression_with_the_0_operator_is_not_allowed_in_the_left_hand_side_of_an_exponentiation_expression_Consider_enclosing_the_expression_in_parentheses, ts.tokenToString(unaryOperator)); - } - } - return simpleUnaryExpression; - } - /** - * Parse ES7 simple-unary expression or higher: - * - * ES7 SimpleUnaryExpression: - * 1) IncrementExpression[?yield] - * 2) delete UnaryExpression[?yield] - * 3) void UnaryExpression[?yield] - * 4) typeof UnaryExpression[?yield] - * 5) + UnaryExpression[?yield] - * 6) - UnaryExpression[?yield] - * 7) ~ UnaryExpression[?yield] - * 8) ! UnaryExpression[?yield] - */ - function parseSimpleUnaryExpression() { - switch (token) { - case 35 /* PlusToken */: - case 36 /* MinusToken */: - case 50 /* TildeToken */: - case 49 /* ExclamationToken */: - return parsePrefixUnaryExpression(); - case 78 /* DeleteKeyword */: - return parseDeleteExpression(); - case 101 /* TypeOfKeyword */: - return parseTypeOfExpression(); - case 103 /* VoidKeyword */: - return parseVoidExpression(); - case 25 /* LessThanToken */: - // This is modified UnaryExpression grammar in TypeScript - // UnaryExpression (modified): - // < type > UnaryExpression - return parseTypeAssertion(); - default: - return parseIncrementExpression(); - } - } - /** - * Check if the current token can possibly be an ES7 increment expression. - * - * ES7 IncrementExpression: - * LeftHandSideExpression[?Yield] - * LeftHandSideExpression[?Yield][no LineTerminator here]++ - * LeftHandSideExpression[?Yield][no LineTerminator here]-- - * ++LeftHandSideExpression[?Yield] - * --LeftHandSideExpression[?Yield] - */ - function isIncrementExpression() { - // This function is called inside parseUnaryExpression to decide - // whether to call parseSimpleUnaryExpression or call parseIncrmentExpression directly - switch (token) { - case 35 /* PlusToken */: - case 36 /* MinusToken */: - case 50 /* TildeToken */: - case 49 /* ExclamationToken */: - case 78 /* DeleteKeyword */: - case 101 /* TypeOfKeyword */: - case 103 /* VoidKeyword */: - return false; - case 25 /* LessThanToken */: - // If we are not in JSX context, we are parsing TypeAssertion which is an UnaryExpression - if (sourceFile.languageVariant !== 1 /* JSX */) { - return false; - } - // We are in JSX context and the token is part of JSXElement. - // Fall through - default: - return true; - } - } - /** - * Parse ES7 IncrementExpression. IncrementExpression is used instead of ES6's PostFixExpression. - * - * ES7 IncrementExpression[yield]: - * 1) LeftHandSideExpression[?yield] - * 2) LeftHandSideExpression[?yield] [[no LineTerminator here]]++ - * 3) LeftHandSideExpression[?yield] [[no LineTerminator here]]-- - * 4) ++LeftHandSideExpression[?yield] - * 5) --LeftHandSideExpression[?yield] - * In TypeScript (2), (3) are parsed as PostfixUnaryExpression. (4), (5) are parsed as PrefixUnaryExpression - */ - function parseIncrementExpression() { - if (token === 41 /* PlusPlusToken */ || token === 42 /* MinusMinusToken */) { - var node = createNode(179 /* PrefixUnaryExpression */); - node.operator = token; - nextToken(); - node.operand = parseLeftHandSideExpressionOrHigher(); - return finishNode(node); - } - else if (sourceFile.languageVariant === 1 /* JSX */ && token === 25 /* LessThanToken */ && lookAhead(nextTokenIsIdentifierOrKeyword)) { - // JSXElement is part of primaryExpression - return parseJsxElementOrSelfClosingElement(/*inExpressionContext*/ true); - } - var expression = parseLeftHandSideExpressionOrHigher(); - ts.Debug.assert(ts.isLeftHandSideExpression(expression)); - if ((token === 41 /* PlusPlusToken */ || token === 42 /* MinusMinusToken */) && !scanner.hasPrecedingLineBreak()) { - var node = createNode(180 /* PostfixUnaryExpression */, expression.pos); - node.operand = expression; - node.operator = token; - nextToken(); - return finishNode(node); - } - return expression; - } - function parseLeftHandSideExpressionOrHigher() { - // Original Ecma: - // LeftHandSideExpression: See 11.2 - // NewExpression - // CallExpression - // - // Our simplification: - // - // LeftHandSideExpression: See 11.2 - // MemberExpression - // CallExpression - // - // See comment in parseMemberExpressionOrHigher on how we replaced NewExpression with - // MemberExpression to make our lives easier. - // - // to best understand the below code, it's important to see how CallExpression expands - // out into its own productions: - // - // CallExpression: - // MemberExpression Arguments - // CallExpression Arguments - // CallExpression[Expression] - // CallExpression.IdentifierName - // super ( ArgumentListopt ) - // super.IdentifierName - // - // Because of the recursion in these calls, we need to bottom out first. There are two - // bottom out states we can run into. Either we see 'super' which must start either of - // 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 */ - ? parseSuperExpression() - : parseMemberExpressionOrHigher(); - // Now, we *may* be complete. However, we might have consumed the start of a - // CallExpression. As such, we need to consume the rest of it here to be complete. - return parseCallExpressionRest(expression); - } - function parseMemberExpressionOrHigher() { - // Note: to make our lives simpler, we decompose the the NewExpression productions and - // place ObjectCreationExpression and FunctionExpression into PrimaryExpression. - // like so: - // - // PrimaryExpression : See 11.1 - // this - // Identifier - // Literal - // ArrayLiteral - // ObjectLiteral - // (Expression) - // FunctionExpression - // new MemberExpression Arguments? - // - // MemberExpression : See 11.2 - // PrimaryExpression - // MemberExpression[Expression] - // MemberExpression.IdentifierName - // - // CallExpression : See 11.2 - // MemberExpression - // CallExpression Arguments - // CallExpression[Expression] - // CallExpression.IdentifierName - // - // Technically this is ambiguous. i.e. CallExpression defines: - // - // CallExpression: - // CallExpression Arguments - // - // If you see: "new Foo()" - // - // Then that could be treated as a single ObjectCreationExpression, or it could be - // treated as the invocation of "new Foo". We disambiguate that in code (to match - // the original grammar) by making sure that if we see an ObjectCreationExpression - // we always consume arguments if they are there. So we treat "new Foo()" as an - // object creation only, and not at all as an invocation) Another way to think - // about this is that for every "new" that we see, we will consume an argument list if - // it is there as part of the *associated* object creation node. Any additional - // argument lists we see, will become invocation expressions. - // - // Because there are no other places in the grammar now that refer to FunctionExpression - // or ObjectCreationExpression, it is safe to push down into the PrimaryExpression - // production. - // - // Because CallExpression and MemberExpression are left recursive, we need to bottom out - // of the recursion immediately. So we parse out a primary expression to start with. - var expression = parsePrimaryExpression(); - return parseMemberExpressionRest(expression); - } - function parseSuperExpression() { - var expression = parseTokenNode(); - if (token === 17 /* OpenParenToken */ || token === 21 /* DotToken */ || token === 19 /* 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(166 /* PropertyAccessExpression */, expression.pos); - node.expression = expression; - node.dotToken = parseExpectedToken(21 /* DotToken */, /*reportAtCurrentPosition*/ false, ts.Diagnostics.super_must_be_followed_by_an_argument_list_or_member_access); - node.name = parseRightSideOfDot(/*allowIdentifierNames*/ true); - return finishNode(node); - } - function parseJsxElementOrSelfClosingElement(inExpressionContext) { - var opening = parseJsxOpeningOrSelfClosingElement(inExpressionContext); - var result; - if (opening.kind === 235 /* JsxOpeningElement */) { - var node = createNode(233 /* JsxElement */, opening.pos); - node.openingElement = opening; - node.children = parseJsxChildren(node.openingElement.tagName); - node.closingElement = parseJsxClosingElement(inExpressionContext); - result = finishNode(node); - } - else { - ts.Debug.assert(opening.kind === 234 /* JsxSelfClosingElement */); - // Nothing else to do for self-closing elements - result = opening; - } - // If the user writes the invalid code '
' in an expression context (i.e. not wrapped in - // an enclosing tag), we'll naively try to parse ^ this as a 'less than' operator and the remainder of the tag - // as garbage, which will cause the formatter to badly mangle the JSX. Perform a speculative parse of a JSX - // element if we see a < token so that we can wrap it in a synthetic binary expression so the formatter - // 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 */) { - var invalidElement = tryParse(function () { return parseJsxElementOrSelfClosingElement(/*inExpressionContext*/ true); }); - if (invalidElement) { - parseErrorAtCurrentToken(ts.Diagnostics.JSX_expressions_must_have_one_parent_element); - var badNode = createNode(181 /* BinaryExpression */, result.pos); - badNode.end = invalidElement.end; - badNode.left = result; - badNode.right = invalidElement; - badNode.operatorToken = createMissingNode(24 /* CommaToken */, /*reportAtCurrentPosition*/ false, /*diagnosticMessage*/ undefined); - badNode.operatorToken.pos = badNode.operatorToken.end = badNode.right.pos; - return badNode; - } - } - return result; - } - function parseJsxText() { - var node = createNode(236 /* JsxText */, scanner.getStartPos()); - token = scanner.scanJsxToken(); - return finishNode(node); - } - function parseJsxChild() { - switch (token) { - case 236 /* JsxText */: - return parseJsxText(); - case 15 /* OpenBraceToken */: - return parseJsxExpression(/*inExpressionContext*/ false); - case 25 /* LessThanToken */: - return parseJsxElementOrSelfClosingElement(/*inExpressionContext*/ false); - } - ts.Debug.fail("Unknown JSX child kind " + token); - } - function parseJsxChildren(openingTagName) { - var result = []; - result.pos = scanner.getStartPos(); - var saveParsingContext = parsingContext; - parsingContext |= 1 << 14 /* JsxChildren */; - while (true) { - token = scanner.reScanJsxToken(); - if (token === 26 /* LessThanSlashToken */) { - break; - } - else if (token === 1 /* EndOfFileToken */) { - parseErrorAtCurrentToken(ts.Diagnostics.Expected_corresponding_JSX_closing_tag_for_0, ts.getTextOfNodeFromSourceText(sourceText, openingTagName)); - break; - } - result.push(parseJsxChild()); - } - result.end = scanner.getTokenPos(); - parsingContext = saveParsingContext; - return result; - } - function parseJsxOpeningOrSelfClosingElement(inExpressionContext) { - var fullStart = scanner.getStartPos(); - parseExpected(25 /* LessThanToken */); - var tagName = parseJsxElementName(); - var attributes = parseList(13 /* JsxAttributes */, parseJsxAttribute); - var node; - if (token === 27 /* 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(235 /* JsxOpeningElement */, fullStart); - scanJsxText(); - } - else { - parseExpected(39 /* SlashToken */); - if (inExpressionContext) { - parseExpected(27 /* GreaterThanToken */); - } - else { - parseExpected(27 /* GreaterThanToken */, /*diagnostic*/ undefined, /*advance*/ false); - scanJsxText(); - } - node = createNode(234 /* JsxSelfClosingElement */, fullStart); - } - node.tagName = tagName; - node.attributes = attributes; - return finishNode(node); - } - function parseJsxElementName() { - scanJsxIdentifier(); - var elementName = parseIdentifierName(); - while (parseOptional(21 /* DotToken */)) { - scanJsxIdentifier(); - var node = createNode(135 /* QualifiedName */, elementName.pos); - node.left = elementName; - node.right = parseIdentifierName(); - elementName = finishNode(node); - } - return elementName; - } - function parseJsxExpression(inExpressionContext) { - var node = createNode(240 /* JsxExpression */); - parseExpected(15 /* OpenBraceToken */); - if (token !== 16 /* CloseBraceToken */) { - node.expression = parseExpression(); - } - if (inExpressionContext) { - parseExpected(16 /* CloseBraceToken */); - } - else { - parseExpected(16 /* CloseBraceToken */, /*message*/ undefined, /*advance*/ false); - scanJsxText(); - } - return finishNode(node); - } - function parseJsxAttribute() { - if (token === 15 /* OpenBraceToken */) { - return parseJsxSpreadAttribute(); - } - scanJsxIdentifier(); - var node = createNode(238 /* JsxAttribute */); - node.name = parseIdentifierName(); - if (parseOptional(56 /* EqualsToken */)) { - switch (token) { - case 9 /* StringLiteral */: - node.initializer = parseLiteralNode(); - break; - default: - node.initializer = parseJsxExpression(/*inExpressionContext*/ true); - break; - } - } - return finishNode(node); - } - function parseJsxSpreadAttribute() { - var node = createNode(239 /* JsxSpreadAttribute */); - parseExpected(15 /* OpenBraceToken */); - parseExpected(22 /* DotDotDotToken */); - node.expression = parseExpression(); - parseExpected(16 /* CloseBraceToken */); - return finishNode(node); - } - function parseJsxClosingElement(inExpressionContext) { - var node = createNode(237 /* JsxClosingElement */); - parseExpected(26 /* LessThanSlashToken */); - node.tagName = parseJsxElementName(); - if (inExpressionContext) { - parseExpected(27 /* GreaterThanToken */); - } - else { - parseExpected(27 /* GreaterThanToken */, /*diagnostic*/ undefined, /*advance*/ false); - scanJsxText(); - } - return finishNode(node); - } - function parseTypeAssertion() { - var node = createNode(171 /* TypeAssertionExpression */); - parseExpected(25 /* LessThanToken */); - node.type = parseType(); - parseExpected(27 /* GreaterThanToken */); - node.expression = parseSimpleUnaryExpression(); - return finishNode(node); - } - function parseMemberExpressionRest(expression) { - while (true) { - var dotToken = parseOptionalToken(21 /* DotToken */); - if (dotToken) { - var propertyAccess = createNode(166 /* PropertyAccessExpression */, expression.pos); - propertyAccess.expression = expression; - propertyAccess.dotToken = dotToken; - propertyAccess.name = parseRightSideOfDot(/*allowIdentifierNames*/ true); - expression = finishNode(propertyAccess); - 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(167 /* ElementAccessExpression */, expression.pos); - indexedAccess.expression = expression; - // It's not uncommon for a user to write: "new Type[]". - // Check for that common pattern and report a better error message. - if (token !== 20 /* 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 */); - expression = finishNode(indexedAccess); - continue; - } - if (token === 11 /* NoSubstitutionTemplateLiteral */ || token === 12 /* TemplateHead */) { - var tagExpression = createNode(170 /* TaggedTemplateExpression */, expression.pos); - tagExpression.tag = expression; - tagExpression.template = token === 11 /* NoSubstitutionTemplateLiteral */ - ? parseLiteralNode() - : parseTemplateExpression(); - expression = finishNode(tagExpression); - continue; - } - return expression; - } - } - function parseCallExpressionRest(expression) { - while (true) { - expression = parseMemberExpressionRest(expression); - if (token === 25 /* 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 - // stack. - var typeArguments = tryParse(parseTypeArgumentsInExpression); - if (!typeArguments) { - return expression; - } - var callExpr = createNode(168 /* CallExpression */, expression.pos); - callExpr.expression = expression; - callExpr.typeArguments = typeArguments; - callExpr.arguments = parseArgumentList(); - expression = finishNode(callExpr); - continue; - } - else if (token === 17 /* OpenParenToken */) { - var callExpr = createNode(168 /* CallExpression */, expression.pos); - callExpr.expression = expression; - callExpr.arguments = parseArgumentList(); - expression = finishNode(callExpr); - continue; - } - return expression; - } - } - function parseArgumentList() { - parseExpected(17 /* OpenParenToken */); - var result = parseDelimitedList(11 /* ArgumentExpressions */, parseArgumentExpression); - parseExpected(18 /* CloseParenToken */); - return result; - } - function parseTypeArgumentsInExpression() { - if (!parseOptional(25 /* LessThanToken */)) { - return undefined; - } - var typeArguments = parseDelimitedList(18 /* TypeArguments */, parseType); - if (!parseExpected(27 /* GreaterThanToken */)) { - // If it doesn't have the closing > then it's definitely not an type argument list. - return undefined; - } - // If we have a '<', then only parse this as a arugment list if the type arguments - // are complete and we have an open paren. if we don't, rewind and return nothing. - return typeArguments && canFollowTypeArgumentsInExpression() - ? typeArguments - : undefined; - } - function canFollowTypeArgumentsInExpression() { - switch (token) { - case 17 /* 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 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 { - // 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. - default: - // Anything else treat as an expression. - return false; - } - } - function parsePrimaryExpression() { - switch (token) { - case 8 /* NumericLiteral */: - case 9 /* StringLiteral */: - case 11 /* NoSubstitutionTemplateLiteral */: - return parseLiteralNode(); - case 97 /* ThisKeyword */: - case 95 /* SuperKeyword */: - case 93 /* NullKeyword */: - case 99 /* TrueKeyword */: - case 84 /* FalseKeyword */: - return parseTokenNode(); - case 17 /* OpenParenToken */: - return parseParenthesizedExpression(); - case 19 /* OpenBracketToken */: - return parseArrayLiteralExpression(); - case 15 /* OpenBraceToken */: - return parseObjectLiteralExpression(); - case 118 /* AsyncKeyword */: - // Async arrow functions are parsed earlier in parseAssignmentExpressionOrHigher. - // If we encounter `async [no LineTerminator here] function` then this is an async - // function; otherwise, its an identifier. - if (!lookAhead(nextTokenIsFunctionKeywordOnSameLine)) { - break; - } - return parseFunctionExpression(); - case 73 /* ClassKeyword */: - return parseClassExpression(); - case 87 /* FunctionKeyword */: - return parseFunctionExpression(); - case 92 /* NewKeyword */: - return parseNewExpression(); - case 39 /* SlashToken */: - case 61 /* SlashEqualsToken */: - if (reScanSlashToken() === 10 /* RegularExpressionLiteral */) { - return parseLiteralNode(); - } - break; - case 12 /* TemplateHead */: - return parseTemplateExpression(); - } - return parseIdentifier(ts.Diagnostics.Expression_expected); - } - function parseParenthesizedExpression() { - var node = createNode(172 /* ParenthesizedExpression */); - parseExpected(17 /* OpenParenToken */); - node.expression = allowInAnd(parseExpression); - parseExpected(18 /* CloseParenToken */); - return finishNode(node); - } - function parseSpreadElement() { - var node = createNode(185 /* SpreadElementExpression */); - parseExpected(22 /* DotDotDotToken */); - node.expression = parseAssignmentExpressionOrHigher(); - return finishNode(node); - } - function parseArgumentOrArrayLiteralElement() { - return token === 22 /* DotDotDotToken */ ? parseSpreadElement() : - token === 24 /* CommaToken */ ? createNode(187 /* OmittedExpression */) : - parseAssignmentExpressionOrHigher(); - } - function parseArgumentExpression() { - return doOutsideOfContext(disallowInAndDecoratorContext, parseArgumentOrArrayLiteralElement); - } - function parseArrayLiteralExpression() { - var node = createNode(164 /* ArrayLiteralExpression */); - parseExpected(19 /* OpenBracketToken */); - if (scanner.hasPrecedingLineBreak()) - node.flags |= 2048 /* MultiLine */; - node.elements = parseDelimitedList(15 /* ArrayLiteralMembers */, parseArgumentOrArrayLiteralElement); - parseExpected(20 /* CloseBracketToken */); - return finishNode(node); - } - function tryParseAccessorDeclaration(fullStart, decorators, modifiers) { - if (parseContextualModifier(123 /* GetKeyword */)) { - return parseAccessorDeclaration(145 /* GetAccessor */, fullStart, decorators, modifiers); - } - else if (parseContextualModifier(129 /* SetKeyword */)) { - return parseAccessorDeclaration(146 /* SetAccessor */, fullStart, decorators, modifiers); - } - return undefined; - } - function parseObjectLiteralElement() { - var fullStart = scanner.getStartPos(); - var decorators = parseDecorators(); - var modifiers = parseModifiers(); - var accessor = tryParseAccessorDeclaration(fullStart, decorators, modifiers); - if (accessor) { - return accessor; - } - var asteriskToken = parseOptionalToken(37 /* AsteriskToken */); - var tokenIsIdentifier = isIdentifier(); - var nameToken = token; - 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 */) { - return parseMethodDeclaration(fullStart, decorators, modifiers, asteriskToken, propertyName, questionToken); - } - // check if it is short-hand property assignment or normal property assignment - // NOTE: if token is EqualsToken it is interpreted as CoverInitializedName production - // CoverInitializedName[Yield] : - // IdentifierReference[?Yield] Initializer[In, ?Yield] - // this is necessary because ObjectLiteral productions are also used to cover grammar for ObjectAssignmentPattern - var isShorthandPropertyAssignment = tokenIsIdentifier && (token === 24 /* CommaToken */ || token === 16 /* CloseBraceToken */ || token === 56 /* EqualsToken */); - if (isShorthandPropertyAssignment) { - var shorthandDeclaration = createNode(246 /* ShorthandPropertyAssignment */, fullStart); - shorthandDeclaration.name = propertyName; - shorthandDeclaration.questionToken = questionToken; - var equalsToken = parseOptionalToken(56 /* EqualsToken */); - if (equalsToken) { - shorthandDeclaration.equalsToken = equalsToken; - shorthandDeclaration.objectAssignmentInitializer = allowInAnd(parseAssignmentExpressionOrHigher); - } - return finishNode(shorthandDeclaration); - } - else { - var propertyAssignment = createNode(245 /* PropertyAssignment */, fullStart); - propertyAssignment.name = propertyName; - propertyAssignment.questionToken = questionToken; - parseExpected(54 /* ColonToken */); - propertyAssignment.initializer = allowInAnd(parseAssignmentExpressionOrHigher); - return finishNode(propertyAssignment); - } - } - function parseObjectLiteralExpression() { - var node = createNode(165 /* ObjectLiteralExpression */); - parseExpected(15 /* OpenBraceToken */); - if (scanner.hasPrecedingLineBreak()) { - node.flags |= 2048 /* MultiLine */; - } - node.properties = parseDelimitedList(12 /* ObjectLiteralMembers */, parseObjectLiteralElement, /*considerSemicolonAsDelimeter*/ true); - parseExpected(16 /* CloseBraceToken */); - return finishNode(node); - } - function parseFunctionExpression() { - // GeneratorExpression: - // function* BindingIdentifier [Yield][opt](FormalParameters[Yield]){ GeneratorBody } - // - // FunctionExpression: - // function BindingIdentifier[opt](FormalParameters){ FunctionBody } - var saveDecoratorContext = inDecoratorContext(); - if (saveDecoratorContext) { - setDecoratorContext(false); - } - var node = createNode(173 /* FunctionExpression */); - setModifiers(node, parseModifiers()); - parseExpected(87 /* FunctionKeyword */); - node.asteriskToken = parseOptionalToken(37 /* AsteriskToken */); - var isGenerator = !!node.asteriskToken; - var isAsync = !!(node.flags & 512 /* Async */); - node.name = - isGenerator && isAsync ? doInYieldAndAwaitContext(parseOptionalIdentifier) : - isGenerator ? doInYieldContext(parseOptionalIdentifier) : - isAsync ? doInAwaitContext(parseOptionalIdentifier) : - parseOptionalIdentifier(); - fillSignature(54 /* ColonToken */, /*yieldContext*/ isGenerator, /*awaitContext*/ isAsync, /*requireCompleteParameterList*/ false, node); - node.body = parseFunctionBlock(/*allowYield*/ isGenerator, /*allowAwait*/ isAsync, /*ignoreMissingOpenBrace*/ false); - if (saveDecoratorContext) { - setDecoratorContext(true); - } - return finishNode(node); - } - function parseOptionalIdentifier() { - return isIdentifier() ? parseIdentifier() : undefined; - } - function parseNewExpression() { - var node = createNode(169 /* NewExpression */); - parseExpected(92 /* NewKeyword */); - node.expression = parseMemberExpressionOrHigher(); - node.typeArguments = tryParse(parseTypeArgumentsInExpression); - if (node.typeArguments || token === 17 /* OpenParenToken */) { - node.arguments = parseArgumentList(); - } - return finishNode(node); - } - // STATEMENTS - function parseBlock(ignoreMissingOpenBrace, diagnosticMessage) { - var node = createNode(192 /* Block */); - if (parseExpected(15 /* OpenBraceToken */, diagnosticMessage) || ignoreMissingOpenBrace) { - node.statements = parseList(1 /* BlockStatements */, parseStatement); - parseExpected(16 /* CloseBraceToken */); - } - else { - node.statements = createMissingList(); - } - return finishNode(node); - } - function parseFunctionBlock(allowYield, allowAwait, ignoreMissingOpenBrace, diagnosticMessage) { - var savedYieldContext = inYieldContext(); - setYieldContext(allowYield); - var savedAwaitContext = inAwaitContext(); - setAwaitContext(allowAwait); - // We may be in a [Decorator] context when parsing a function expression or - // arrow function. The body of the function is not in [Decorator] context. - var saveDecoratorContext = inDecoratorContext(); - if (saveDecoratorContext) { - setDecoratorContext(false); - } - var block = parseBlock(ignoreMissingOpenBrace, diagnosticMessage); - if (saveDecoratorContext) { - setDecoratorContext(true); - } - setYieldContext(savedYieldContext); - setAwaitContext(savedAwaitContext); - return block; - } - function parseEmptyStatement() { - var node = createNode(194 /* EmptyStatement */); - parseExpected(23 /* SemicolonToken */); - return finishNode(node); - } - function parseIfStatement() { - var node = createNode(196 /* IfStatement */); - parseExpected(88 /* IfKeyword */); - parseExpected(17 /* OpenParenToken */); - node.expression = allowInAnd(parseExpression); - parseExpected(18 /* CloseParenToken */); - node.thenStatement = parseStatement(); - node.elseStatement = parseOptional(80 /* ElseKeyword */) ? parseStatement() : undefined; - return finishNode(node); - } - function parseDoStatement() { - var node = createNode(197 /* DoStatement */); - parseExpected(79 /* DoKeyword */); - node.statement = parseStatement(); - parseExpected(104 /* WhileKeyword */); - parseExpected(17 /* OpenParenToken */); - node.expression = allowInAnd(parseExpression); - parseExpected(18 /* 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 */); - return finishNode(node); - } - function parseWhileStatement() { - var node = createNode(198 /* WhileStatement */); - parseExpected(104 /* WhileKeyword */); - parseExpected(17 /* OpenParenToken */); - node.expression = allowInAnd(parseExpression); - parseExpected(18 /* CloseParenToken */); - node.statement = parseStatement(); - return finishNode(node); - } - function parseForOrForInOrForOfStatement() { - var pos = getNodePos(); - parseExpected(86 /* ForKeyword */); - parseExpected(17 /* OpenParenToken */); - var initializer = undefined; - if (token !== 23 /* SemicolonToken */) { - if (token === 102 /* VarKeyword */ || token === 108 /* LetKeyword */ || token === 74 /* ConstKeyword */) { - initializer = parseVariableDeclarationList(/*inForStatementInitializer*/ true); - } - else { - initializer = disallowInAnd(parseExpression); - } - } - var forOrForInOrForOfStatement; - if (parseOptional(90 /* InKeyword */)) { - var forInStatement = createNode(200 /* ForInStatement */, pos); - forInStatement.initializer = initializer; - forInStatement.expression = allowInAnd(parseExpression); - parseExpected(18 /* CloseParenToken */); - forOrForInOrForOfStatement = forInStatement; - } - else if (parseOptional(134 /* OfKeyword */)) { - var forOfStatement = createNode(201 /* ForOfStatement */, pos); - forOfStatement.initializer = initializer; - forOfStatement.expression = allowInAnd(parseAssignmentExpressionOrHigher); - parseExpected(18 /* CloseParenToken */); - forOrForInOrForOfStatement = forOfStatement; - } - else { - var forStatement = createNode(199 /* ForStatement */, pos); - forStatement.initializer = initializer; - parseExpected(23 /* SemicolonToken */); - if (token !== 23 /* SemicolonToken */ && token !== 18 /* CloseParenToken */) { - forStatement.condition = allowInAnd(parseExpression); - } - parseExpected(23 /* SemicolonToken */); - if (token !== 18 /* CloseParenToken */) { - forStatement.incrementor = allowInAnd(parseExpression); - } - parseExpected(18 /* CloseParenToken */); - forOrForInOrForOfStatement = forStatement; - } - forOrForInOrForOfStatement.statement = parseStatement(); - return finishNode(forOrForInOrForOfStatement); - } - function parseBreakOrContinueStatement(kind) { - var node = createNode(kind); - parseExpected(kind === 203 /* BreakStatement */ ? 70 /* BreakKeyword */ : 75 /* ContinueKeyword */); - if (!canParseSemicolon()) { - node.label = parseIdentifier(); - } - parseSemicolon(); - return finishNode(node); - } - function parseReturnStatement() { - var node = createNode(204 /* ReturnStatement */); - parseExpected(94 /* ReturnKeyword */); - if (!canParseSemicolon()) { - node.expression = allowInAnd(parseExpression); - } - parseSemicolon(); - return finishNode(node); - } - function parseWithStatement() { - var node = createNode(205 /* WithStatement */); - parseExpected(105 /* WithKeyword */); - parseExpected(17 /* OpenParenToken */); - node.expression = allowInAnd(parseExpression); - parseExpected(18 /* CloseParenToken */); - node.statement = parseStatement(); - return finishNode(node); - } - function parseCaseClause() { - var node = createNode(241 /* CaseClause */); - parseExpected(71 /* CaseKeyword */); - node.expression = allowInAnd(parseExpression); - parseExpected(54 /* ColonToken */); - node.statements = parseList(3 /* SwitchClauseStatements */, parseStatement); - return finishNode(node); - } - function parseDefaultClause() { - var node = createNode(242 /* DefaultClause */); - parseExpected(77 /* DefaultKeyword */); - parseExpected(54 /* ColonToken */); - node.statements = parseList(3 /* SwitchClauseStatements */, parseStatement); - return finishNode(node); - } - function parseCaseOrDefaultClause() { - return token === 71 /* CaseKeyword */ ? parseCaseClause() : parseDefaultClause(); - } - function parseSwitchStatement() { - var node = createNode(206 /* SwitchStatement */); - parseExpected(96 /* SwitchKeyword */); - parseExpected(17 /* OpenParenToken */); - node.expression = allowInAnd(parseExpression); - parseExpected(18 /* CloseParenToken */); - var caseBlock = createNode(220 /* CaseBlock */, scanner.getStartPos()); - parseExpected(15 /* OpenBraceToken */); - caseBlock.clauses = parseList(2 /* SwitchClauses */, parseCaseOrDefaultClause); - parseExpected(16 /* CloseBraceToken */); - node.caseBlock = finishNode(caseBlock); - return finishNode(node); - } - function parseThrowStatement() { - // ThrowStatement[Yield] : - // throw [no LineTerminator here]Expression[In, ?Yield]; - // Because of automatic semicolon insertion, we need to report error if this - // throw could be terminated with a semicolon. Note: we can't call 'parseExpression' - // 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(208 /* ThrowStatement */); - parseExpected(98 /* ThrowKeyword */); - node.expression = scanner.hasPrecedingLineBreak() ? undefined : allowInAnd(parseExpression); - parseSemicolon(); - return finishNode(node); - } - // TODO: Review for error recovery - function parseTryStatement() { - var node = createNode(209 /* TryStatement */); - parseExpected(100 /* TryKeyword */); - node.tryBlock = parseBlock(/*ignoreMissingOpenBrace*/ false); - node.catchClause = token === 72 /* CatchKeyword */ ? parseCatchClause() : undefined; - // If we don't have a catch clause, then we must have a finally clause. Try to parse - // one out no matter what. - if (!node.catchClause || token === 85 /* FinallyKeyword */) { - parseExpected(85 /* FinallyKeyword */); - node.finallyBlock = parseBlock(/*ignoreMissingOpenBrace*/ false); - } - return finishNode(node); - } - function parseCatchClause() { - var result = createNode(244 /* CatchClause */); - parseExpected(72 /* CatchKeyword */); - if (parseExpected(17 /* OpenParenToken */)) { - result.variableDeclaration = parseVariableDeclaration(); - } - parseExpected(18 /* CloseParenToken */); - result.block = parseBlock(/*ignoreMissingOpenBrace*/ false); - return finishNode(result); - } - function parseDebuggerStatement() { - var node = createNode(210 /* DebuggerStatement */); - parseExpected(76 /* DebuggerKeyword */); - parseSemicolon(); - return finishNode(node); - } - function parseExpressionOrLabeledStatement() { - // Avoiding having to do the lookahead for a labeled statement by just trying to parse - // out an expression, seeing if it is identifier and then seeing if it is followed by - // a colon. - var fullStart = scanner.getStartPos(); - var expression = allowInAnd(parseExpression); - if (expression.kind === 69 /* Identifier */ && parseOptional(54 /* ColonToken */)) { - var labeledStatement = createNode(207 /* LabeledStatement */, fullStart); - labeledStatement.label = expression; - labeledStatement.statement = parseStatement(); - return finishNode(labeledStatement); - } - else { - var expressionStatement = createNode(195 /* ExpressionStatement */, fullStart); - expressionStatement.expression = expression; - parseSemicolon(); - return finishNode(expressionStatement); - } - } - function nextTokenIsIdentifierOrKeywordOnSameLine() { - nextToken(); - return ts.tokenIsIdentifierOrKeyword(token) && !scanner.hasPrecedingLineBreak(); - } - function nextTokenIsFunctionKeywordOnSameLine() { - nextToken(); - return token === 87 /* FunctionKeyword */ && !scanner.hasPrecedingLineBreak(); - } - function nextTokenIsIdentifierOrKeywordOrNumberOnSameLine() { - nextToken(); - return (ts.tokenIsIdentifierOrKeyword(token) || token === 8 /* NumericLiteral */) && !scanner.hasPrecedingLineBreak(); - } - function isDeclaration() { - while (true) { - switch (token) { - case 102 /* VarKeyword */: - case 108 /* LetKeyword */: - case 74 /* ConstKeyword */: - case 87 /* FunctionKeyword */: - case 73 /* ClassKeyword */: - case 81 /* EnumKeyword */: - return true; - // 'declare', 'module', 'namespace', 'interface'* and 'type' are all legal JavaScript identifiers; - // however, an identifier cannot be followed by another identifier on the same line. This is what we - // count on to parse out the respective declarations. For instance, we exploit this to say that - // - // namespace n - // - // can be none other than the beginning of a namespace declaration, but need to respect that JavaScript sees - // - // namespace - // n - // - // as the identifier 'namespace' on one line followed by the identifier 'n' on another. - // We need to look one token ahead to see if it permissible to try parsing a declaration. - // - // *Note*: 'interface' is actually a strict mode reserved word. So while - // - // "use strict" - // interface - // I {} - // - // could be legal, it would add complexity for very little gain. - case 107 /* InterfaceKeyword */: - case 132 /* TypeKeyword */: - return nextTokenIsIdentifierOnSameLine(); - case 125 /* ModuleKeyword */: - case 126 /* NamespaceKeyword */: - return nextTokenIsIdentifierOrStringLiteralOnSameLine(); - case 115 /* AbstractKeyword */: - case 118 /* AsyncKeyword */: - case 122 /* DeclareKeyword */: - case 110 /* PrivateKeyword */: - case 111 /* ProtectedKeyword */: - case 112 /* PublicKeyword */: - nextToken(); - // ASI takes effect for this modifier. - if (scanner.hasPrecedingLineBreak()) { - return false; - } - continue; - case 89 /* ImportKeyword */: - nextToken(); - return token === 9 /* StringLiteral */ || token === 37 /* AsteriskToken */ || - token === 15 /* OpenBraceToken */ || ts.tokenIsIdentifierOrKeyword(token); - case 82 /* ExportKeyword */: - nextToken(); - if (token === 56 /* EqualsToken */ || token === 37 /* AsteriskToken */ || - token === 15 /* OpenBraceToken */ || token === 77 /* DefaultKeyword */) { - return true; - } - continue; - case 113 /* StaticKeyword */: - nextToken(); - continue; - default: - return false; - } - } - } - function isStartOfDeclaration() { - return lookAhead(isDeclaration); - } - 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 */: - // '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 */: - return true; - case 74 /* ConstKeyword */: - case 82 /* ExportKeyword */: - case 89 /* ImportKeyword */: - return isStartOfDeclaration(); - case 118 /* AsyncKeyword */: - case 122 /* DeclareKeyword */: - case 107 /* InterfaceKeyword */: - case 125 /* ModuleKeyword */: - case 126 /* NamespaceKeyword */: - case 132 /* TypeKeyword */: - // When these don't start a declaration, they're an identifier in an expression statement - return true; - case 112 /* PublicKeyword */: - case 110 /* PrivateKeyword */: - case 111 /* ProtectedKeyword */: - case 113 /* StaticKeyword */: - // When these don't start a declaration, they may be the start of a class member if an identifier - // immediately follows. Otherwise they're an identifier in an expression statement. - return isStartOfDeclaration() || !lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine); - default: - return isStartOfExpression(); - } - } - function nextTokenIsIdentifierOrStartOfDestructuring() { - nextToken(); - return isIdentifier() || token === 15 /* OpenBraceToken */ || token === 19 /* OpenBracketToken */; - } - function isLetDeclaration() { - // In ES6 'let' always starts a lexical declaration if followed by an identifier or { - // or [. - return lookAhead(nextTokenIsIdentifierOrStartOfDestructuring); - } - function parseStatement() { - switch (token) { - case 23 /* SemicolonToken */: - return parseEmptyStatement(); - case 15 /* OpenBraceToken */: - return parseBlock(/*ignoreMissingOpenBrace*/ false); - case 102 /* VarKeyword */: - return parseVariableStatement(scanner.getStartPos(), /*decorators*/ undefined, /*modifiers*/ undefined); - case 108 /* LetKeyword */: - if (isLetDeclaration()) { - return parseVariableStatement(scanner.getStartPos(), /*decorators*/ undefined, /*modifiers*/ undefined); - } - break; - case 87 /* FunctionKeyword */: - return parseFunctionDeclaration(scanner.getStartPos(), /*decorators*/ undefined, /*modifiers*/ undefined); - case 73 /* ClassKeyword */: - return parseClassDeclaration(scanner.getStartPos(), /*decorators*/ undefined, /*modifiers*/ undefined); - case 88 /* IfKeyword */: - return parseIfStatement(); - case 79 /* DoKeyword */: - return parseDoStatement(); - case 104 /* WhileKeyword */: - return parseWhileStatement(); - case 86 /* ForKeyword */: - return parseForOrForInOrForOfStatement(); - case 75 /* ContinueKeyword */: - return parseBreakOrContinueStatement(202 /* ContinueStatement */); - case 70 /* BreakKeyword */: - return parseBreakOrContinueStatement(203 /* BreakStatement */); - case 94 /* ReturnKeyword */: - return parseReturnStatement(); - case 105 /* WithKeyword */: - return parseWithStatement(); - case 96 /* SwitchKeyword */: - return parseSwitchStatement(); - case 98 /* ThrowKeyword */: - return parseThrowStatement(); - case 100 /* TryKeyword */: - // Include 'catch' and 'finally' for error recovery. - case 72 /* CatchKeyword */: - case 85 /* FinallyKeyword */: - return parseTryStatement(); - case 76 /* DebuggerKeyword */: - return parseDebuggerStatement(); - case 55 /* AtToken */: - return parseDeclaration(); - case 118 /* AsyncKeyword */: - case 107 /* InterfaceKeyword */: - case 132 /* TypeKeyword */: - case 125 /* ModuleKeyword */: - case 126 /* NamespaceKeyword */: - case 122 /* DeclareKeyword */: - case 74 /* ConstKeyword */: - case 81 /* EnumKeyword */: - case 82 /* ExportKeyword */: - case 89 /* ImportKeyword */: - case 110 /* PrivateKeyword */: - case 111 /* ProtectedKeyword */: - case 112 /* PublicKeyword */: - case 115 /* AbstractKeyword */: - case 113 /* StaticKeyword */: - if (isStartOfDeclaration()) { - return parseDeclaration(); - } - break; - } - return parseExpressionOrLabeledStatement(); - } - function parseDeclaration() { - var fullStart = getNodePos(); - var decorators = parseDecorators(); - var modifiers = parseModifiers(); - switch (token) { - case 102 /* VarKeyword */: - case 108 /* LetKeyword */: - case 74 /* ConstKeyword */: - return parseVariableStatement(fullStart, decorators, modifiers); - case 87 /* FunctionKeyword */: - return parseFunctionDeclaration(fullStart, decorators, modifiers); - case 73 /* ClassKeyword */: - return parseClassDeclaration(fullStart, decorators, modifiers); - case 107 /* InterfaceKeyword */: - return parseInterfaceDeclaration(fullStart, decorators, modifiers); - case 132 /* TypeKeyword */: - return parseTypeAliasDeclaration(fullStart, decorators, modifiers); - case 81 /* EnumKeyword */: - return parseEnumDeclaration(fullStart, decorators, modifiers); - case 125 /* ModuleKeyword */: - case 126 /* NamespaceKeyword */: - return parseModuleDeclaration(fullStart, decorators, modifiers); - case 89 /* ImportKeyword */: - return parseImportDeclarationOrImportEqualsDeclaration(fullStart, decorators, modifiers); - case 82 /* ExportKeyword */: - nextToken(); - return token === 77 /* DefaultKeyword */ || token === 56 /* EqualsToken */ ? - parseExportAssignment(fullStart, decorators, modifiers) : - parseExportDeclaration(fullStart, decorators, modifiers); - default: - if (decorators || modifiers) { - // We reached this point because we encountered decorators and/or modifiers and assumed a declaration - // would follow. For recovery and error reporting purposes, return an incomplete declaration. - var node = createMissingNode(231 /* MissingDeclaration */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); - node.pos = fullStart; - node.decorators = decorators; - setModifiers(node, modifiers); - return finishNode(node); - } - } - } - function nextTokenIsIdentifierOrStringLiteralOnSameLine() { - nextToken(); - return !scanner.hasPrecedingLineBreak() && (isIdentifier() || token === 9 /* StringLiteral */); - } - function parseFunctionBlockOrSemicolon(isGenerator, isAsync, diagnosticMessage) { - if (token !== 15 /* OpenBraceToken */ && canParseSemicolon()) { - parseSemicolon(); - return; - } - return parseFunctionBlock(isGenerator, isAsync, /*ignoreMissingOpenBrace*/ false, diagnosticMessage); - } - // DECLARATIONS - function parseArrayBindingElement() { - if (token === 24 /* CommaToken */) { - return createNode(187 /* OmittedExpression */); - } - var node = createNode(163 /* BindingElement */); - node.dotDotDotToken = parseOptionalToken(22 /* DotDotDotToken */); - node.name = parseIdentifierOrPattern(); - node.initializer = parseBindingElementInitializer(/*inParameter*/ false); - return finishNode(node); - } - function parseObjectBindingElement() { - var node = createNode(163 /* BindingElement */); - // TODO(andersh): Handle computed properties - var tokenIsIdentifier = isIdentifier(); - var propertyName = parsePropertyName(); - if (tokenIsIdentifier && token !== 54 /* ColonToken */) { - node.name = propertyName; - } - else { - parseExpected(54 /* ColonToken */); - node.propertyName = propertyName; - node.name = parseIdentifierOrPattern(); - } - node.initializer = parseBindingElementInitializer(/*inParameter*/ false); - return finishNode(node); - } - function parseObjectBindingPattern() { - var node = createNode(161 /* ObjectBindingPattern */); - parseExpected(15 /* OpenBraceToken */); - node.elements = parseDelimitedList(9 /* ObjectBindingElements */, parseObjectBindingElement); - parseExpected(16 /* CloseBraceToken */); - return finishNode(node); - } - function parseArrayBindingPattern() { - var node = createNode(162 /* ArrayBindingPattern */); - parseExpected(19 /* OpenBracketToken */); - node.elements = parseDelimitedList(10 /* ArrayBindingElements */, parseArrayBindingElement); - parseExpected(20 /* CloseBracketToken */); - return finishNode(node); - } - function isIdentifierOrPattern() { - return token === 15 /* OpenBraceToken */ || token === 19 /* OpenBracketToken */ || isIdentifier(); - } - function parseIdentifierOrPattern() { - if (token === 19 /* OpenBracketToken */) { - return parseArrayBindingPattern(); - } - if (token === 15 /* OpenBraceToken */) { - return parseObjectBindingPattern(); - } - return parseIdentifier(); - } - function parseVariableDeclaration() { - var node = createNode(211 /* VariableDeclaration */); - node.name = parseIdentifierOrPattern(); - node.type = parseTypeAnnotation(); - if (!isInOrOfKeyword(token)) { - node.initializer = parseInitializer(/*inParameter*/ false); - } - return finishNode(node); - } - function parseVariableDeclarationList(inForStatementInitializer) { - var node = createNode(212 /* VariableDeclarationList */); - switch (token) { - case 102 /* VarKeyword */: - break; - case 108 /* LetKeyword */: - node.flags |= 16384 /* Let */; - break; - case 74 /* ConstKeyword */: - node.flags |= 32768 /* Const */; - break; - default: - ts.Debug.fail(); - } - nextToken(); - // The user may have written the following: - // - // for (let of X) { } - // - // In this case, we want to parse an empty declaration list, and then parse 'of' - // as a keyword. The reason this is not automatic is that 'of' is a valid identifier. - // 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 === 134 /* OfKeyword */ && lookAhead(canFollowContextualOfKeyword)) { - node.declarations = createMissingList(); - } - else { - var savedDisallowIn = inDisallowInContext(); - setDisallowInContext(inForStatementInitializer); - node.declarations = parseDelimitedList(8 /* VariableDeclarations */, parseVariableDeclaration); - setDisallowInContext(savedDisallowIn); - } - return finishNode(node); - } - function canFollowContextualOfKeyword() { - return nextTokenIsIdentifier() && nextToken() === 18 /* CloseParenToken */; - } - function parseVariableStatement(fullStart, decorators, modifiers) { - var node = createNode(193 /* VariableStatement */, fullStart); - node.decorators = decorators; - setModifiers(node, modifiers); - node.declarationList = parseVariableDeclarationList(/*inForStatementInitializer*/ false); - parseSemicolon(); - return finishNode(node); - } - function parseFunctionDeclaration(fullStart, decorators, modifiers) { - var node = createNode(213 /* FunctionDeclaration */, fullStart); - node.decorators = decorators; - setModifiers(node, modifiers); - parseExpected(87 /* FunctionKeyword */); - node.asteriskToken = parseOptionalToken(37 /* AsteriskToken */); - node.name = node.flags & 1024 /* Default */ ? parseOptionalIdentifier() : parseIdentifier(); - var isGenerator = !!node.asteriskToken; - var isAsync = !!(node.flags & 512 /* Async */); - fillSignature(54 /* ColonToken */, /*yieldContext*/ isGenerator, /*awaitContext*/ isAsync, /*requireCompleteParameterList*/ false, node); - node.body = parseFunctionBlockOrSemicolon(isGenerator, isAsync, ts.Diagnostics.or_expected); - return finishNode(node); - } - function parseConstructorDeclaration(pos, decorators, modifiers) { - var node = createNode(144 /* Constructor */, pos); - node.decorators = decorators; - setModifiers(node, modifiers); - parseExpected(121 /* ConstructorKeyword */); - fillSignature(54 /* ColonToken */, /*yieldContext*/ false, /*awaitContext*/ false, /*requireCompleteParameterList*/ false, node); - node.body = parseFunctionBlockOrSemicolon(/*isGenerator*/ false, /*isAsync*/ false, ts.Diagnostics.or_expected); - return finishNode(node); - } - function parseMethodDeclaration(fullStart, decorators, modifiers, asteriskToken, name, questionToken, diagnosticMessage) { - var method = createNode(143 /* MethodDeclaration */, fullStart); - method.decorators = decorators; - setModifiers(method, modifiers); - method.asteriskToken = asteriskToken; - method.name = name; - method.questionToken = questionToken; - var isGenerator = !!asteriskToken; - var isAsync = !!(method.flags & 512 /* Async */); - fillSignature(54 /* ColonToken */, /*yieldContext*/ isGenerator, /*awaitContext*/ isAsync, /*requireCompleteParameterList*/ false, method); - method.body = parseFunctionBlockOrSemicolon(isGenerator, isAsync, diagnosticMessage); - return finishNode(method); - } - function parsePropertyDeclaration(fullStart, decorators, modifiers, name, questionToken) { - var property = createNode(141 /* PropertyDeclaration */, fullStart); - property.decorators = decorators; - setModifiers(property, modifiers); - property.name = name; - property.questionToken = questionToken; - property.type = parseTypeAnnotation(); - // For instance properties specifically, since they are evaluated inside the constructor, - // we do *not * want to parse yield expressions, so we specifically turn the yield context - // off. The grammar would look something like this: - // - // MemberVariableDeclaration[Yield]: - // AccessibilityModifier_opt PropertyName TypeAnnotation_opt Initialiser_opt[In]; - // AccessibilityModifier_opt static_opt PropertyName TypeAnnotation_opt Initialiser_opt[In, ?Yield]; - // - // The checker may still error in the static case to explicitly disallow the yield expression. - property.initializer = modifiers && modifiers.flags & 128 /* Static */ - ? allowInAnd(parseNonParameterInitializer) - : doOutsideOfContext(2 /* Yield */ | 1 /* DisallowIn */, parseNonParameterInitializer); - parseSemicolon(); - return finishNode(property); - } - function parsePropertyOrMethodDeclaration(fullStart, decorators, modifiers) { - var asteriskToken = parseOptionalToken(37 /* 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 */) { - return parseMethodDeclaration(fullStart, decorators, modifiers, asteriskToken, name, questionToken, ts.Diagnostics.or_expected); - } - else { - return parsePropertyDeclaration(fullStart, decorators, modifiers, name, questionToken); - } - } - function parseNonParameterInitializer() { - return parseInitializer(/*inParameter*/ false); - } - function parseAccessorDeclaration(kind, fullStart, decorators, modifiers) { - var node = createNode(kind, fullStart); - node.decorators = decorators; - setModifiers(node, modifiers); - node.name = parsePropertyName(); - fillSignature(54 /* ColonToken */, /*yieldContext*/ false, /*awaitContext*/ false, /*requireCompleteParameterList*/ false, node); - node.body = parseFunctionBlockOrSemicolon(/*isGenerator*/ false, /*isAsync*/ false); - return finishNode(node); - } - function isClassMemberModifier(idToken) { - switch (idToken) { - case 112 /* PublicKeyword */: - case 110 /* PrivateKeyword */: - case 111 /* ProtectedKeyword */: - case 113 /* StaticKeyword */: - return true; - default: - return false; - } - } - function isClassMemberStart() { - var idToken; - if (token === 55 /* AtToken */) { - return true; - } - // Eat up all modifiers, but hold on to the last one in case it is actually an identifier. - while (ts.isModifier(token)) { - idToken = token; - // If the idToken is a class modifier (protected, private, public, and static), it is - // certain that we are starting to parse class member. This allows better error recovery - // Example: - // public foo() ... // true - // public @dec blah ... // true; we will then report an error later - // export public ... // true; we will then report an error later - if (isClassMemberModifier(idToken)) { - return true; - } - nextToken(); - } - if (token === 37 /* AsteriskToken */) { - return true; - } - // Try to get the first property-like token following all modifiers. - // This can either be an identifier or the 'get' or 'set' keywords. - if (isLiteralPropertyName()) { - idToken = token; - nextToken(); - } - // Index signatures and computed properties are class members; we can parse. - if (token === 19 /* 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 === 129 /* SetKeyword */ || idToken === 123 /* 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 */: - return true; - default: - // Covers - // - Semicolons (declaration termination) - // - Closing braces (end-of-class, must be declaration) - // - End-of-files (not valid, but permitted so that it gets caught later on) - // - Line-breaks (enabling *automatic semicolon insertion*) - return canParseSemicolon(); - } - } - return false; - } - function parseDecorators() { - var decorators; - while (true) { - var decoratorStart = getNodePos(); - if (!parseOptional(55 /* AtToken */)) { - break; - } - if (!decorators) { - decorators = []; - decorators.pos = scanner.getStartPos(); - } - var decorator = createNode(139 /* Decorator */, decoratorStart); - decorator.expression = doInDecoratorContext(parseLeftHandSideExpressionOrHigher); - decorators.push(finishNode(decorator)); - } - if (decorators) { - decorators.end = getNodeEnd(); - } - return decorators; - } - function parseModifiers() { - var flags = 0; - var modifiers; - while (true) { - var modifierStart = scanner.getStartPos(); - var modifierKind = token; - if (!parseAnyContextualModifier()) { - break; - } - if (!modifiers) { - modifiers = []; - modifiers.pos = modifierStart; - } - flags |= ts.modifierToFlag(modifierKind); - modifiers.push(finishNode(createNode(modifierKind, modifierStart))); - } - if (modifiers) { - modifiers.flags = flags; - modifiers.end = scanner.getStartPos(); - } - return modifiers; - } - function parseModifiersForArrowFunction() { - var flags = 0; - var modifiers; - if (token === 118 /* AsyncKeyword */) { - var modifierStart = scanner.getStartPos(); - var modifierKind = token; - nextToken(); - modifiers = []; - modifiers.pos = modifierStart; - flags |= ts.modifierToFlag(modifierKind); - modifiers.push(finishNode(createNode(modifierKind, modifierStart))); - modifiers.flags = flags; - modifiers.end = scanner.getStartPos(); - } - return modifiers; - } - function parseClassElement() { - if (token === 23 /* SemicolonToken */) { - var result = createNode(191 /* SemicolonClassElement */); - nextToken(); - return finishNode(result); - } - var fullStart = getNodePos(); - var decorators = parseDecorators(); - var modifiers = parseModifiers(); - var accessor = tryParseAccessorDeclaration(fullStart, decorators, modifiers); - if (accessor) { - return accessor; - } - if (token === 121 /* ConstructorKeyword */) { - return parseConstructorDeclaration(fullStart, decorators, modifiers); - } - if (isIndexSignature()) { - return parseIndexSignatureDeclaration(fullStart, decorators, modifiers); - } - // It is very important that we check this *after* checking indexers because - // the [ token can start an index signature or a computed property name - if (ts.tokenIsIdentifierOrKeyword(token) || - token === 9 /* StringLiteral */ || - token === 8 /* NumericLiteral */ || - token === 37 /* AsteriskToken */ || - token === 19 /* OpenBracketToken */) { - return parsePropertyOrMethodDeclaration(fullStart, decorators, modifiers); - } - if (decorators || modifiers) { - // treat this as a property declaration with a missing name. - var name_7 = createMissingNode(69 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); - return parsePropertyDeclaration(fullStart, decorators, modifiers, name_7, /*questionToken*/ undefined); - } - // 'isClassMemberStart' should have hinted not to attempt parsing. - ts.Debug.fail("Should not have attempted to parse class member declaration."); - } - function parseClassExpression() { - return parseClassDeclarationOrExpression( - /*fullStart*/ scanner.getStartPos(), - /*decorators*/ undefined, - /*modifiers*/ undefined, 186 /* ClassExpression */); - } - function parseClassDeclaration(fullStart, decorators, modifiers) { - return parseClassDeclarationOrExpression(fullStart, decorators, modifiers, 214 /* ClassDeclaration */); - } - function parseClassDeclarationOrExpression(fullStart, decorators, modifiers, kind) { - var node = createNode(kind, fullStart); - node.decorators = decorators; - setModifiers(node, modifiers); - parseExpected(73 /* ClassKeyword */); - node.name = parseNameOfClassDeclarationOrExpression(); - node.typeParameters = parseTypeParameters(); - node.heritageClauses = parseHeritageClauses(/*isClassHeritageClause*/ true); - if (parseExpected(15 /* OpenBraceToken */)) { - // ClassTail[Yield,Await] : (Modified) See 14.5 - // ClassHeritage[?Yield,?Await]opt { ClassBody[?Yield,?Await]opt } - node.members = parseClassMembers(); - parseExpected(16 /* CloseBraceToken */); - } - else { - node.members = createMissingList(); - } - return finishNode(node); - } - function parseNameOfClassDeclarationOrExpression() { - // implements is a future reserved word so - // 'class implements' might mean either - // - class expression with omitted name, 'implements' starts heritage clause - // - class with name 'implements' - // 'isImplementsClause' helps to disambiguate between these two cases - return isIdentifier() && !isImplementsClause() - ? parseIdentifier() - : undefined; - } - function isImplementsClause() { - return token === 106 /* ImplementsKeyword */ && lookAhead(nextTokenIsIdentifierOrKeyword); - } - function parseHeritageClauses(isClassHeritageClause) { - // ClassTail[Yield,Await] : (Modified) See 14.5 - // ClassHeritage[?Yield,?Await]opt { ClassBody[?Yield,?Await]opt } - if (isHeritageClause()) { - return parseList(20 /* HeritageClauses */, parseHeritageClause); - } - return undefined; - } - function parseHeritageClausesWorker() { - return parseList(20 /* HeritageClauses */, parseHeritageClause); - } - function parseHeritageClause() { - if (token === 83 /* ExtendsKeyword */ || token === 106 /* ImplementsKeyword */) { - var node = createNode(243 /* HeritageClause */); - node.token = token; - nextToken(); - node.types = parseDelimitedList(7 /* HeritageClauseElement */, parseExpressionWithTypeArguments); - return finishNode(node); - } - return undefined; - } - function parseExpressionWithTypeArguments() { - var node = createNode(188 /* ExpressionWithTypeArguments */); - node.expression = parseLeftHandSideExpressionOrHigher(); - if (token === 25 /* LessThanToken */) { - node.typeArguments = parseBracketedList(18 /* TypeArguments */, parseType, 25 /* LessThanToken */, 27 /* GreaterThanToken */); - } - return finishNode(node); - } - function isHeritageClause() { - return token === 83 /* ExtendsKeyword */ || token === 106 /* ImplementsKeyword */; - } - function parseClassMembers() { - return parseList(5 /* ClassMembers */, parseClassElement); - } - function parseInterfaceDeclaration(fullStart, decorators, modifiers) { - var node = createNode(215 /* InterfaceDeclaration */, fullStart); - node.decorators = decorators; - setModifiers(node, modifiers); - parseExpected(107 /* InterfaceKeyword */); - node.name = parseIdentifier(); - node.typeParameters = parseTypeParameters(); - node.heritageClauses = parseHeritageClauses(/*isClassHeritageClause*/ false); - node.members = parseObjectTypeMembers(); - return finishNode(node); - } - function parseTypeAliasDeclaration(fullStart, decorators, modifiers) { - var node = createNode(216 /* TypeAliasDeclaration */, fullStart); - node.decorators = decorators; - setModifiers(node, modifiers); - parseExpected(132 /* TypeKeyword */); - node.name = parseIdentifier(); - node.typeParameters = parseTypeParameters(); - parseExpected(56 /* EqualsToken */); - node.type = parseType(); - parseSemicolon(); - return 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 - // ConstantEnumMemberSection, which starts at the beginning of an enum declaration - // or any time an integer literal initializer is encountered. - function parseEnumMember() { - var node = createNode(247 /* EnumMember */, scanner.getStartPos()); - node.name = parsePropertyName(); - node.initializer = allowInAnd(parseNonParameterInitializer); - return finishNode(node); - } - function parseEnumDeclaration(fullStart, decorators, modifiers) { - var node = createNode(217 /* EnumDeclaration */, fullStart); - node.decorators = decorators; - setModifiers(node, modifiers); - parseExpected(81 /* EnumKeyword */); - node.name = parseIdentifier(); - if (parseExpected(15 /* OpenBraceToken */)) { - node.members = parseDelimitedList(6 /* EnumMembers */, parseEnumMember); - parseExpected(16 /* CloseBraceToken */); - } - else { - node.members = createMissingList(); - } - return finishNode(node); - } - function parseModuleBlock() { - var node = createNode(219 /* ModuleBlock */, scanner.getStartPos()); - if (parseExpected(15 /* OpenBraceToken */)) { - node.statements = parseList(1 /* BlockStatements */, parseStatement); - parseExpected(16 /* CloseBraceToken */); - } - else { - node.statements = createMissingList(); - } - return finishNode(node); - } - function parseModuleOrNamespaceDeclaration(fullStart, decorators, modifiers, flags) { - var node = createNode(218 /* ModuleDeclaration */, fullStart); - // If we are parsing a dotted namespace name, we want to - // propagate the 'Namespace' flag across the names if set. - var namespaceFlag = flags & 131072 /* Namespace */; - node.decorators = decorators; - setModifiers(node, modifiers); - node.flags |= flags; - node.name = parseIdentifier(); - node.body = parseOptional(21 /* DotToken */) - ? parseModuleOrNamespaceDeclaration(getNodePos(), /*decorators*/ undefined, /*modifiers*/ undefined, 1 /* Export */ | namespaceFlag) - : parseModuleBlock(); - return finishNode(node); - } - function parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers) { - var node = createNode(218 /* ModuleDeclaration */, fullStart); - node.decorators = decorators; - setModifiers(node, modifiers); - node.name = parseLiteralNode(/*internName*/ true); - node.body = parseModuleBlock(); - return finishNode(node); - } - function parseModuleDeclaration(fullStart, decorators, modifiers) { - var flags = modifiers ? modifiers.flags : 0; - if (parseOptional(126 /* NamespaceKeyword */)) { - flags |= 131072 /* Namespace */; - } - else { - parseExpected(125 /* ModuleKeyword */); - if (token === 9 /* StringLiteral */) { - return parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers); - } - } - return parseModuleOrNamespaceDeclaration(fullStart, decorators, modifiers, flags); - } - function isExternalModuleReference() { - return token === 127 /* RequireKeyword */ && - lookAhead(nextTokenIsOpenParen); - } - function nextTokenIsOpenParen() { - return nextToken() === 17 /* OpenParenToken */; - } - function nextTokenIsSlash() { - return nextToken() === 39 /* SlashToken */; - } - function nextTokenIsCommaOrFromKeyword() { - nextToken(); - return token === 24 /* CommaToken */ || - token === 133 /* FromKeyword */; - } - function parseImportDeclarationOrImportEqualsDeclaration(fullStart, decorators, modifiers) { - parseExpected(89 /* ImportKeyword */); - var afterImportPos = scanner.getStartPos(); - var identifier; - if (isIdentifier()) { - identifier = parseIdentifier(); - if (token !== 24 /* CommaToken */ && token !== 133 /* FromKeyword */) { - // ImportEquals declaration of type: - // import x = require("mod"); or - // import x = M.x; - var importEqualsDeclaration = createNode(221 /* ImportEqualsDeclaration */, fullStart); - importEqualsDeclaration.decorators = decorators; - setModifiers(importEqualsDeclaration, modifiers); - importEqualsDeclaration.name = identifier; - parseExpected(56 /* EqualsToken */); - importEqualsDeclaration.moduleReference = parseModuleReference(); - parseSemicolon(); - return finishNode(importEqualsDeclaration); - } - } - // Import statement - var importDeclaration = createNode(222 /* ImportDeclaration */, fullStart); - importDeclaration.decorators = decorators; - setModifiers(importDeclaration, modifiers); - // ImportDeclaration: - // import ImportClause from ModuleSpecifier ; - // import ModuleSpecifier; - if (identifier || - token === 37 /* AsteriskToken */ || - token === 15 /* OpenBraceToken */) { - importDeclaration.importClause = parseImportClause(identifier, afterImportPos); - parseExpected(133 /* FromKeyword */); - } - importDeclaration.moduleSpecifier = parseModuleSpecifier(); - parseSemicolon(); - return finishNode(importDeclaration); - } - function parseImportClause(identifier, fullStart) { - // ImportClause: - // ImportedDefaultBinding - // NameSpaceImport - // NamedImports - // ImportedDefaultBinding, NameSpaceImport - // ImportedDefaultBinding, NamedImports - var importClause = createNode(223 /* ImportClause */, fullStart); - if (identifier) { - // ImportedDefaultBinding: - // ImportedBinding - importClause.name = identifier; - } - // 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(225 /* NamedImports */); - } - return finishNode(importClause); - } - function parseModuleReference() { - return isExternalModuleReference() - ? parseExternalModuleReference() - : parseEntityName(/*allowReservedWords*/ false); - } - function parseExternalModuleReference() { - var node = createNode(232 /* ExternalModuleReference */); - parseExpected(127 /* RequireKeyword */); - parseExpected(17 /* OpenParenToken */); - node.expression = parseModuleSpecifier(); - parseExpected(18 /* CloseParenToken */); - return finishNode(node); - } - function parseModuleSpecifier() { - // We allow arbitrary expressions here, even though the grammar only allows string - // literals. We check to ensure that it is only a string literal later in the grammar - // walker. - var result = parseExpression(); - // Ensure the string being required is in our 'identifier' table. This will ensure - // that features like 'find refs' will look inside this file when search for its name. - if (result.kind === 9 /* StringLiteral */) { - internIdentifier(result.text); - } - return result; - } - function parseNamespaceImport() { - // NameSpaceImport: - // * as ImportedBinding - var namespaceImport = createNode(224 /* NamespaceImport */); - parseExpected(37 /* AsteriskToken */); - parseExpected(116 /* AsKeyword */); - namespaceImport.name = parseIdentifier(); - return finishNode(namespaceImport); - } - function parseNamedImportsOrExports(kind) { - var node = createNode(kind); - // NamedImports: - // { } - // { ImportsList } - // { ImportsList, } - // ImportsList: - // ImportSpecifier - // ImportsList, ImportSpecifier - node.elements = parseBracketedList(21 /* ImportOrExportSpecifiers */, kind === 225 /* NamedImports */ ? parseImportSpecifier : parseExportSpecifier, 15 /* OpenBraceToken */, 16 /* CloseBraceToken */); - return finishNode(node); - } - function parseExportSpecifier() { - return parseImportOrExportSpecifier(230 /* ExportSpecifier */); - } - function parseImportSpecifier() { - return parseImportOrExportSpecifier(226 /* ImportSpecifier */); - } - function parseImportOrExportSpecifier(kind) { - var node = createNode(kind); - // ImportSpecifier: - // BindingIdentifier - // IdentifierName as BindingIdentifier - // ExportSpecififer: - // IdentifierName - // IdentifierName as IdentifierName - var checkIdentifierIsKeyword = ts.isKeyword(token) && !isIdentifier(); - var checkIdentifierStart = scanner.getTokenPos(); - var checkIdentifierEnd = scanner.getTextPos(); - var identifierName = parseIdentifierName(); - if (token === 116 /* AsKeyword */) { - node.propertyName = identifierName; - parseExpected(116 /* AsKeyword */); - checkIdentifierIsKeyword = ts.isKeyword(token) && !isIdentifier(); - checkIdentifierStart = scanner.getTokenPos(); - checkIdentifierEnd = scanner.getTextPos(); - node.name = parseIdentifierName(); - } - else { - node.name = identifierName; - } - if (kind === 226 /* ImportSpecifier */ && checkIdentifierIsKeyword) { - // Report error identifier expected - parseErrorAtPosition(checkIdentifierStart, checkIdentifierEnd - checkIdentifierStart, ts.Diagnostics.Identifier_expected); - } - return finishNode(node); - } - function parseExportDeclaration(fullStart, decorators, modifiers) { - var node = createNode(228 /* ExportDeclaration */, fullStart); - node.decorators = decorators; - setModifiers(node, modifiers); - if (parseOptional(37 /* AsteriskToken */)) { - parseExpected(133 /* FromKeyword */); - node.moduleSpecifier = parseModuleSpecifier(); - } - else { - node.exportClause = parseNamedImportsOrExports(229 /* NamedExports */); - // It is not uncommon to accidentally omit the 'from' keyword. Additionally, in editing scenarios, - // the 'from' keyword can be parsed as a named export when the export clause is unterminated (i.e. `export { from "moduleName";`) - // If we don't have a 'from' keyword, see if we have a string literal such that ASI won't take effect. - if (token === 133 /* FromKeyword */ || (token === 9 /* StringLiteral */ && !scanner.hasPrecedingLineBreak())) { - parseExpected(133 /* FromKeyword */); - node.moduleSpecifier = parseModuleSpecifier(); - } - } - parseSemicolon(); - return finishNode(node); - } - function parseExportAssignment(fullStart, decorators, modifiers) { - var node = createNode(227 /* ExportAssignment */, fullStart); - node.decorators = decorators; - setModifiers(node, modifiers); - if (parseOptional(56 /* EqualsToken */)) { - node.isExportEquals = true; - } - else { - parseExpected(77 /* DefaultKeyword */); - } - node.expression = parseAssignmentExpressionOrHigher(); - parseSemicolon(); - return finishNode(node); - } - function processReferenceComments(sourceFile) { - var triviaScanner = ts.createScanner(sourceFile.languageVersion, /*skipTrivia*/ false, 0 /* Standard */, sourceText); - var referencedFiles = []; - var amdDependencies = []; - var amdModuleName; - // Keep scanning all the leading trivia in the file until we get to something that - // isn't trivia. Any single line comment will be analyzed to see if it is a - // reference comment. - while (true) { - var kind = triviaScanner.scan(); - if (kind === 5 /* WhitespaceTrivia */ || kind === 4 /* NewLineTrivia */ || kind === 3 /* MultiLineCommentTrivia */) { - continue; - } - if (kind !== 2 /* SingleLineCommentTrivia */) { - break; - } - var range = { pos: triviaScanner.getTokenPos(), end: triviaScanner.getTextPos(), kind: triviaScanner.getToken() }; - var comment = sourceText.substring(range.pos, range.end); - var referencePathMatchResult = ts.getFileReferenceFromReferencePath(comment, range); - if (referencePathMatchResult) { - var fileReference = referencePathMatchResult.fileReference; - sourceFile.hasNoDefaultLib = referencePathMatchResult.isNoDefaultLib; - var diagnosticMessage = referencePathMatchResult.diagnosticMessage; - if (fileReference) { - referencedFiles.push(fileReference); - } - if (diagnosticMessage) { - parseDiagnostics.push(ts.createFileDiagnostic(sourceFile, range.pos, range.end - range.pos, diagnosticMessage)); - } - } - else { - var amdModuleNameRegEx = /^\/\/\/\s*".length; - return parseErrorAtPosition(start, end - start, ts.Diagnostics.Type_argument_list_cannot_be_empty); - } - } - function parseQualifiedName(left) { - var result = createNode(135 /* QualifiedName */, left.pos); - result.left = left; - result.right = parseIdentifierName(); - return finishNode(result); - } - function parseJSDocRecordType() { - var result = createNode(257 /* JSDocRecordType */); - nextToken(); - result.members = parseDelimitedList(24 /* JSDocRecordMembers */, parseJSDocRecordMember); - checkForTrailingComma(result.members); - parseExpected(16 /* CloseBraceToken */); - return finishNode(result); - } - function parseJSDocRecordMember() { - var result = createNode(258 /* JSDocRecordMember */); - result.name = parseSimplePropertyName(); - if (token === 54 /* ColonToken */) { - nextToken(); - result.type = parseJSDocType(); - } - return finishNode(result); - } - function parseJSDocNonNullableType() { - var result = createNode(256 /* JSDocNonNullableType */); - nextToken(); - result.type = parseJSDocType(); - return finishNode(result); - } - function parseJSDocTupleType() { - var result = createNode(254 /* JSDocTupleType */); - nextToken(); - result.types = parseDelimitedList(25 /* JSDocTupleTypes */, parseJSDocType); - checkForTrailingComma(result.types); - parseExpected(20 /* CloseBracketToken */); - return finishNode(result); - } - function checkForTrailingComma(list) { - if (parseDiagnostics.length === 0 && list.hasTrailingComma) { - var start = list.end - ",".length; - parseErrorAtPosition(start, ",".length, ts.Diagnostics.Trailing_comma_not_allowed); - } - } - function parseJSDocUnionType() { - var result = createNode(253 /* JSDocUnionType */); - nextToken(); - result.types = parseJSDocTypeList(parseJSDocType()); - parseExpected(18 /* CloseParenToken */); - return finishNode(result); - } - function parseJSDocTypeList(firstType) { - ts.Debug.assert(!!firstType); - var types = []; - types.pos = firstType.pos; - types.push(firstType); - while (parseOptional(47 /* BarToken */)) { - types.push(parseJSDocType()); - } - types.end = scanner.getStartPos(); - return types; - } - function parseJSDocAllType() { - var result = createNode(250 /* JSDocAllType */); - nextToken(); - return finishNode(result); - } - function parseJSDocUnknownOrNullableType() { - var pos = scanner.getStartPos(); - // skip the ? - nextToken(); - // Need to lookahead to decide if this is a nullable or unknown type. - // Here are cases where we'll pick the unknown type: - // - // Foo(?, - // { a: ? } - // Foo(?) - // Foo - // Foo(?= - // (?| - if (token === 24 /* CommaToken */ || - token === 16 /* CloseBraceToken */ || - token === 18 /* CloseParenToken */ || - token === 27 /* GreaterThanToken */ || - token === 56 /* EqualsToken */ || - token === 47 /* BarToken */) { - var result = createNode(251 /* JSDocUnknownType */, pos); - return finishNode(result); - } - else { - var result = createNode(255 /* JSDocNullableType */, pos); - result.type = parseJSDocType(); - return finishNode(result); - } - } - function parseIsolatedJSDocComment(content, start, length) { - initializeState("file.js", content, 2 /* Latest */, /*_syntaxCursor:*/ undefined); - var jsDocComment = parseJSDocComment(/*parent:*/ undefined, start, length); - var diagnostics = parseDiagnostics; - clearState(); - return jsDocComment ? { jsDocComment: jsDocComment, diagnostics: diagnostics } : undefined; - } - JSDocParser.parseIsolatedJSDocComment = parseIsolatedJSDocComment; - function parseJSDocComment(parent, start, length) { - var comment = parseJSDocCommentWorker(start, length); - if (comment) { - fixupParentReferences(comment); - comment.parent = parent; - } - return comment; - } - JSDocParser.parseJSDocComment = parseJSDocComment; - function parseJSDocCommentWorker(start, length) { - var content = sourceText; - start = start || 0; - var end = length === undefined ? content.length : start + length; - length = end - start; - ts.Debug.assert(start >= 0); - ts.Debug.assert(start <= end); - ts.Debug.assert(end <= content.length); - var tags; - var pos; - // NOTE(cyrusn): This is essentially a handwritten scanner for JSDocComments. I - // considered using an actual Scanner, but this would complicate things. The - // scanner would need to know it was in a Doc Comment. Otherwise, it would then - // produce comments *inside* the doc comment. In the end it was just easier to - // write a simple scanner rather than go that route. - if (length >= "/** */".length) { - if (content.charCodeAt(start) === 47 /* slash */ && - content.charCodeAt(start + 1) === 42 /* asterisk */ && - content.charCodeAt(start + 2) === 42 /* asterisk */ && - content.charCodeAt(start + 3) !== 42 /* asterisk */) { - // Initially we can parse out a tag. We also have seen a starting asterisk. - // This is so that /** * @type */ doesn't parse. - var canParseTag = true; - var seenAsterisk = true; - for (pos = start + "/**".length; pos < end;) { - var ch = content.charCodeAt(pos); - pos++; - if (ch === 64 /* at */ && canParseTag) { - parseTag(); - // Once we parse out a tag, we cannot keep parsing out tags on this line. - canParseTag = false; - continue; - } - if (ts.isLineBreak(ch)) { - // After a line break, we can parse a tag, and we haven't seen as asterisk - // on the next line yet. - canParseTag = true; - seenAsterisk = false; - continue; - } - if (ts.isWhiteSpace(ch)) { - // Whitespace doesn't affect any of our parsing. - continue; - } - // Ignore the first asterisk on a line. - if (ch === 42 /* asterisk */) { - if (seenAsterisk) { - // If we've already seen an asterisk, then we can no longer parse a tag - // on this line. - canParseTag = false; - } - seenAsterisk = true; - continue; - } - // Anything else is doc comment text. We can't do anything with it. Because it - // wasn't a tag, we can no longer parse a tag on this line until we hit the next - // line break. - canParseTag = false; - } - } - } - return createJSDocComment(); - function createJSDocComment() { - if (!tags) { - return undefined; - } - var result = createNode(265 /* JSDocComment */, start); - result.tags = tags; - return finishNode(result, end); - } - function skipWhitespace() { - while (pos < end && ts.isWhiteSpace(content.charCodeAt(pos))) { - pos++; - } - } - function parseTag() { - ts.Debug.assert(content.charCodeAt(pos - 1) === 64 /* at */); - var atToken = createNode(55 /* AtToken */, pos - 1); - atToken.end = pos; - var tagName = scanIdentifier(); - if (!tagName) { - return; - } - var tag = handleTag(atToken, tagName) || handleUnknownTag(atToken, tagName); - addTag(tag); - } - function handleTag(atToken, tagName) { - if (tagName) { - switch (tagName.text) { - case "param": - return handleParamTag(atToken, tagName); - case "return": - case "returns": - return handleReturnTag(atToken, tagName); - case "template": - return handleTemplateTag(atToken, tagName); - case "type": - return handleTypeTag(atToken, tagName); - } - } - return undefined; - } - function handleUnknownTag(atToken, tagName) { - var result = createNode(266 /* JSDocTag */, atToken.pos); - result.atToken = atToken; - result.tagName = tagName; - return finishNode(result, pos); - } - function addTag(tag) { - if (tag) { - if (!tags) { - tags = []; - tags.pos = tag.pos; - } - tags.push(tag); - tags.end = tag.end; - } - } - function tryParseTypeExpression() { - skipWhitespace(); - if (content.charCodeAt(pos) !== 123 /* openBrace */) { - return undefined; - } - var typeExpression = parseJSDocTypeExpression(pos, end - pos); - pos = typeExpression.end; - return typeExpression; - } - function handleParamTag(atToken, tagName) { - var typeExpression = tryParseTypeExpression(); - skipWhitespace(); - var name; - var isBracketed; - if (content.charCodeAt(pos) === 91 /* openBracket */) { - pos++; - skipWhitespace(); - name = scanIdentifier(); - isBracketed = true; - } - else { - name = scanIdentifier(); - } - if (!name) { - parseErrorAtPosition(pos, 0, ts.Diagnostics.Identifier_expected); - } - var preName, postName; - if (typeExpression) { - postName = name; - } - else { - preName = name; - } - if (!typeExpression) { - typeExpression = tryParseTypeExpression(); - } - var result = createNode(267 /* JSDocParameterTag */, atToken.pos); - result.atToken = atToken; - result.tagName = tagName; - result.preParameterName = preName; - result.typeExpression = typeExpression; - result.postParameterName = postName; - result.isBracketed = isBracketed; - return finishNode(result, pos); - } - function handleReturnTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 268 /* JSDocReturnTag */; })) { - parseErrorAtPosition(tagName.pos, pos - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); - } - var result = createNode(268 /* JSDocReturnTag */, atToken.pos); - result.atToken = atToken; - result.tagName = tagName; - result.typeExpression = tryParseTypeExpression(); - return finishNode(result, pos); - } - function handleTypeTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 269 /* JSDocTypeTag */; })) { - parseErrorAtPosition(tagName.pos, pos - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); - } - var result = createNode(269 /* JSDocTypeTag */, atToken.pos); - result.atToken = atToken; - result.tagName = tagName; - result.typeExpression = tryParseTypeExpression(); - return finishNode(result, pos); - } - function handleTemplateTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 270 /* JSDocTemplateTag */; })) { - parseErrorAtPosition(tagName.pos, pos - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); - } - var typeParameters = []; - typeParameters.pos = pos; - while (true) { - skipWhitespace(); - var startPos = pos; - var name_8 = scanIdentifier(); - if (!name_8) { - parseErrorAtPosition(startPos, 0, ts.Diagnostics.Identifier_expected); - return undefined; - } - var typeParameter = createNode(137 /* TypeParameter */, name_8.pos); - typeParameter.name = name_8; - finishNode(typeParameter, pos); - typeParameters.push(typeParameter); - skipWhitespace(); - if (content.charCodeAt(pos) !== 44 /* comma */) { - break; - } - pos++; - } - typeParameters.end = pos; - var result = createNode(270 /* JSDocTemplateTag */, atToken.pos); - result.atToken = atToken; - result.tagName = tagName; - result.typeParameters = typeParameters; - return finishNode(result, pos); - } - function scanIdentifier() { - var startPos = pos; - for (; pos < end; pos++) { - var ch = content.charCodeAt(pos); - if (pos === startPos && ts.isIdentifierStart(ch, 2 /* Latest */)) { - continue; - } - else if (pos > startPos && ts.isIdentifierPart(ch, 2 /* Latest */)) { - continue; - } - break; - } - if (startPos === pos) { - return undefined; - } - var result = createNode(69 /* Identifier */, startPos); - result.text = content.substring(startPos, pos); - return finishNode(result, pos); - } - } - JSDocParser.parseJSDocCommentWorker = parseJSDocCommentWorker; - })(JSDocParser = Parser.JSDocParser || (Parser.JSDocParser = {})); - })(Parser || (Parser = {})); - var IncrementalParser; - (function (IncrementalParser) { - function updateSourceFile(sourceFile, newText, textChangeRange, aggressiveChecks) { - aggressiveChecks = aggressiveChecks || ts.Debug.shouldAssert(2 /* Aggressive */); - checkChangeRange(sourceFile, newText, textChangeRange, aggressiveChecks); - if (ts.textChangeRangeIsUnchanged(textChangeRange)) { - // if the text didn't change, then we can just return our current source file as-is. - return sourceFile; - } - if (sourceFile.statements.length === 0) { - // If we don't have any statements in the current source file, then there's no real - // way to incrementally parse. So just do a full parse instead. - return Parser.parseSourceFile(sourceFile.fileName, newText, sourceFile.languageVersion, /*syntaxCursor*/ undefined, /*setNodeParents*/ true); - } - // Make sure we're not trying to incrementally update a source file more than once. Once - // we do an update the original source file is considered unusbale from that point onwards. - // - // This is because we do incremental parsing in-place. i.e. we take nodes from the old - // tree and give them new positions and parents. From that point on, trusting the old - // tree at all is not possible as far too much of it may violate invariants. - var incrementalSourceFile = sourceFile; - ts.Debug.assert(!incrementalSourceFile.hasBeenIncrementallyParsed); - incrementalSourceFile.hasBeenIncrementallyParsed = true; - var oldText = sourceFile.text; - var syntaxCursor = createSyntaxCursor(sourceFile); - // Make the actual change larger so that we know to reparse anything whose lookahead - // might have intersected the change. - var changeRange = extendToAffectedRange(sourceFile, textChangeRange); - checkChangeRange(sourceFile, newText, changeRange, aggressiveChecks); - // Ensure that extending the affected range only moved the start of the change range - // earlier in the file. - ts.Debug.assert(changeRange.span.start <= textChangeRange.span.start); - ts.Debug.assert(ts.textSpanEnd(changeRange.span) === ts.textSpanEnd(textChangeRange.span)); - ts.Debug.assert(ts.textSpanEnd(ts.textChangeRangeNewSpan(changeRange)) === ts.textSpanEnd(ts.textChangeRangeNewSpan(textChangeRange))); - // The is the amount the nodes after the edit range need to be adjusted. It can be - // positive (if the edit added characters), negative (if the edit deleted characters) - // or zero (if this was a pure overwrite with nothing added/removed). - var delta = ts.textChangeRangeNewSpan(changeRange).length - changeRange.span.length; - // If we added or removed characters during the edit, then we need to go and adjust all - // the nodes after the edit. Those nodes may move forward (if we inserted chars) or they - // may move backward (if we deleted chars). - // - // Doing this helps us out in two ways. First, it means that any nodes/tokens we want - // to reuse are already at the appropriate position in the new text. That way when we - // reuse them, we don't have to figure out if they need to be adjusted. Second, it makes - // it very easy to determine if we can reuse a node. If the node's position is at where - // we are in the text, then we can reuse it. Otherwise we can't. If the node's position - // is ahead of us, then we'll need to rescan tokens. If the node's position is behind - // us, then we'll need to skip it or crumble it as appropriate - // - // We will also adjust the positions of nodes that intersect the change range as well. - // By doing this, we ensure that all the positions in the old tree are consistent, not - // just the positions of nodes entirely before/after the change range. By being - // consistent, we can then easily map from positions to nodes in the old tree easily. - // - // Also, mark any syntax elements that intersect the changed span. We know, up front, - // that we cannot reuse these elements. - updateTokenPositionsAndMarkElements(incrementalSourceFile, changeRange.span.start, ts.textSpanEnd(changeRange.span), ts.textSpanEnd(ts.textChangeRangeNewSpan(changeRange)), delta, oldText, newText, aggressiveChecks); - // Now that we've set up our internal incremental state just proceed and parse the - // source file in the normal fashion. When possible the parser will retrieve and - // reuse nodes from the old tree. - // - // Note: passing in 'true' for setNodeParents is very important. When incrementally - // parsing, we will be reusing nodes from the old tree, and placing it into new - // parents. If we don't set the parents now, we'll end up with an observably - // inconsistent tree. Setting the parents on the new tree should be very fast. We - // will immediately bail out of walking any subtrees when we can see that their parents - // are already correct. - var result = Parser.parseSourceFile(sourceFile.fileName, newText, sourceFile.languageVersion, syntaxCursor, /* setParentNode */ true); - return result; - } - IncrementalParser.updateSourceFile = updateSourceFile; - function moveElementEntirelyPastChangeRange(element, isArray, delta, oldText, newText, aggressiveChecks) { - if (isArray) { - visitArray(element); - } - else { - visitNode(element); - } - return; - function visitNode(node) { - var text = ""; - if (aggressiveChecks && shouldCheckNode(node)) { - text = oldText.substring(node.pos, node.end); - } - // Ditch any existing LS children we may have created. This way we can avoid - // moving them forward. - if (node._children) { - node._children = undefined; - } - if (node.jsDocComment) { - node.jsDocComment = undefined; - } - node.pos += delta; - node.end += delta; - if (aggressiveChecks && shouldCheckNode(node)) { - ts.Debug.assert(text === newText.substring(node.pos, node.end)); - } - forEachChild(node, visitNode, visitArray); - checkNodePositions(node, aggressiveChecks); - } - function visitArray(array) { - array._children = undefined; - array.pos += delta; - array.end += delta; - for (var _i = 0; _i < array.length; _i++) { - var node = array[_i]; - visitNode(node); - } - } - } - function shouldCheckNode(node) { - switch (node.kind) { - case 9 /* StringLiteral */: - case 8 /* NumericLiteral */: - case 69 /* Identifier */: - return true; - } - return false; - } - function adjustIntersectingElement(element, changeStart, changeRangeOldEnd, changeRangeNewEnd, delta) { - ts.Debug.assert(element.end >= changeStart, "Adjusting an element that was entirely before the change range"); - ts.Debug.assert(element.pos <= changeRangeOldEnd, "Adjusting an element that was entirely after the change range"); - ts.Debug.assert(element.pos <= element.end); - // We have an element that intersects the change range in some way. It may have its - // start, or its end (or both) in the changed range. We want to adjust any part - // that intersects such that the final tree is in a consistent state. i.e. all - // chlidren have spans within the span of their parent, and all siblings are ordered - // properly. - // We may need to update both the 'pos' and the 'end' of the element. - // If the 'pos' is before the start of the change, then we don't need to touch it. - // If it isn't, then the 'pos' must be inside the change. How we update it will - // depend if delta is positive or negative. If delta is positive then we have - // something like: - // - // -------------------AAA----------------- - // -------------------BBBCCCCCCC----------------- - // - // In this case, we consider any node that started in the change range to still be - // starting at the same position. - // - // however, if the delta is negative, then we instead have something like this: - // - // -------------------XXXYYYYYYY----------------- - // -------------------ZZZ----------------- - // - // In this case, any element that started in the 'X' range will keep its position. - // However any element htat started after that will have their pos adjusted to be - // at the end of the new range. i.e. any node that started in the 'Y' range will - // be adjusted to have their start at the end of the 'Z' range. - // - // The element will keep its position if possible. Or Move backward to the new-end - // if it's in the 'Y' range. - element.pos = Math.min(element.pos, changeRangeNewEnd); - // If the 'end' is after the change range, then we always adjust it by the delta - // amount. However, if the end is in the change range, then how we adjust it - // will depend on if delta is positive or negative. If delta is positive then we - // have something like: - // - // -------------------AAA----------------- - // -------------------BBBCCCCCCC----------------- - // - // In this case, we consider any node that ended inside the change range to keep its - // end position. - // - // however, if the delta is negative, then we instead have something like this: - // - // -------------------XXXYYYYYYY----------------- - // -------------------ZZZ----------------- - // - // In this case, any element that ended in the 'X' range will keep its position. - // However any element htat ended after that will have their pos adjusted to be - // at the end of the new range. i.e. any node that ended in the 'Y' range will - // be adjusted to have their end at the end of the 'Z' range. - if (element.end >= changeRangeOldEnd) { - // Element ends after the change range. Always adjust the end pos. - element.end += delta; - } - else { - // Element ends in the change range. The element will keep its position if - // possible. Or Move backward to the new-end if it's in the 'Y' range. - element.end = Math.min(element.end, changeRangeNewEnd); - } - ts.Debug.assert(element.pos <= element.end); - if (element.parent) { - ts.Debug.assert(element.pos >= element.parent.pos); - ts.Debug.assert(element.end <= element.parent.end); - } - } - function checkNodePositions(node, aggressiveChecks) { - if (aggressiveChecks) { - var pos = node.pos; - forEachChild(node, function (child) { - ts.Debug.assert(child.pos >= pos); - pos = child.end; - }); - ts.Debug.assert(pos <= node.end); - } - } - function updateTokenPositionsAndMarkElements(sourceFile, changeStart, changeRangeOldEnd, changeRangeNewEnd, delta, oldText, newText, aggressiveChecks) { - visitNode(sourceFile); - return; - function visitNode(child) { - ts.Debug.assert(child.pos <= child.end); - if (child.pos > changeRangeOldEnd) { - // Node is entirely past the change range. We need to move both its pos and - // end, forward or backward appropriately. - moveElementEntirelyPastChangeRange(child, /*isArray*/ false, delta, oldText, newText, aggressiveChecks); - return; - } - // Check if the element intersects the change range. If it does, then it is not - // reusable. Also, we'll need to recurse to see what constituent portions we may - // be able to use. - var fullEnd = child.end; - if (fullEnd >= changeStart) { - child.intersectsChange = true; - child._children = undefined; - // Adjust the pos or end (or both) of the intersecting element accordingly. - adjustIntersectingElement(child, changeStart, changeRangeOldEnd, changeRangeNewEnd, delta); - forEachChild(child, visitNode, visitArray); - checkNodePositions(child, aggressiveChecks); - return; - } - // Otherwise, the node is entirely before the change range. No need to do anything with it. - ts.Debug.assert(fullEnd < changeStart); - } - function visitArray(array) { - ts.Debug.assert(array.pos <= array.end); - if (array.pos > changeRangeOldEnd) { - // Array is entirely after the change range. We need to move it, and move any of - // its children. - moveElementEntirelyPastChangeRange(array, /*isArray*/ true, delta, oldText, newText, aggressiveChecks); - return; - } - // Check if the element intersects the change range. If it does, then it is not - // reusable. Also, we'll need to recurse to see what constituent portions we may - // be able to use. - var fullEnd = array.end; - if (fullEnd >= changeStart) { - array.intersectsChange = true; - 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; _i < array.length; _i++) { - var node = array[_i]; - visitNode(node); - } - return; - } - // Otherwise, the array is entirely before the change range. No need to do anything with it. - ts.Debug.assert(fullEnd < changeStart); - } - } - function extendToAffectedRange(sourceFile, changeRange) { - // Consider the following code: - // void foo() { /; } - // - // If the text changes with an insertion of / just before the semicolon then we end up with: - // void foo() { //; } - // - // If we were to just use the changeRange a is, then we would not rescan the { token - // (as it does not intersect the actual original change range). Because an edit may - // change the token touching it, we actually need to look back *at least* one token so - // that the prior token sees that change. - var maxLookahead = 1; - var start = changeRange.span.start; - // the first iteration aligns us with the change start. subsequent iteration move us to - // the left by maxLookahead tokens. We only need to do this as long as we're not at the - // start of the tree. - for (var i = 0; start > 0 && i <= maxLookahead; i++) { - var nearestNode = findNearestNodeStartingBeforeOrAtPosition(sourceFile, start); - ts.Debug.assert(nearestNode.pos <= start); - var position = nearestNode.pos; - start = Math.max(0, position - 1); - } - var finalSpan = ts.createTextSpanFromBounds(start, ts.textSpanEnd(changeRange.span)); - var finalLength = changeRange.newLength + (changeRange.span.start - start); - return ts.createTextChangeRange(finalSpan, finalLength); - } - function findNearestNodeStartingBeforeOrAtPosition(sourceFile, position) { - var bestResult = sourceFile; - var lastNodeEntirelyBeforePosition; - forEachChild(sourceFile, visit); - if (lastNodeEntirelyBeforePosition) { - var lastChildOfLastEntireNodeBeforePosition = getLastChild(lastNodeEntirelyBeforePosition); - if (lastChildOfLastEntireNodeBeforePosition.pos > bestResult.pos) { - bestResult = lastChildOfLastEntireNodeBeforePosition; - } - } - return bestResult; - function getLastChild(node) { - while (true) { - var lastChild = getLastChildWorker(node); - if (lastChild) { - node = lastChild; - } - else { - return node; - } - } - } - function getLastChildWorker(node) { - var last = undefined; - forEachChild(node, function (child) { - if (ts.nodeIsPresent(child)) { - last = child; - } - }); - return last; - } - function visit(child) { - if (ts.nodeIsMissing(child)) { - // Missing nodes are effectively invisible to us. We never even consider them - // When trying to find the nearest node before us. - return; - } - // If the child intersects this position, then this node is currently the nearest - // node that starts before the position. - if (child.pos <= position) { - if (child.pos >= bestResult.pos) { - // This node starts before the position, and is closer to the position than - // the previous best node we found. It is now the new best node. - bestResult = child; - } - // Now, the node may overlap the position, or it may end entirely before the - // position. If it overlaps with the position, then either it, or one of its - // children must be the nearest node before the position. So we can just - // recurse into this child to see if we can find something better. - if (position < child.end) { - // The nearest node is either this child, or one of the children inside - // of it. We've already marked this child as the best so far. Recurse - // in case one of the children is better. - forEachChild(child, visit); - // Once we look at the children of this node, then there's no need to - // continue any further. - return true; - } - else { - ts.Debug.assert(child.end <= position); - // The child ends entirely before this position. Say you have the following - // (where $ is the position) - // - // ? $ : <...> <...> - // - // We would want to find the nearest preceding node in "complex expr 2". - // To support that, we keep track of this node, and once we're done searching - // for a best node, we recurse down this node to see if we can find a good - // result in it. - // - // This approach allows us to quickly skip over nodes that are entirely - // before the position, while still allowing us to find any nodes in the - // last one that might be what we want. - lastNodeEntirelyBeforePosition = child; - } - } - else { - ts.Debug.assert(child.pos > position); - // We're now at a node that is entirely past the position we're searching for. - // This node (and all following nodes) could never contribute to the result, - // so just skip them by returning 'true' here. - return true; - } - } - } - function checkChangeRange(sourceFile, newText, textChangeRange, aggressiveChecks) { - var oldText = sourceFile.text; - if (textChangeRange) { - ts.Debug.assert((oldText.length - textChangeRange.span.length + textChangeRange.newLength) === newText.length); - if (aggressiveChecks || ts.Debug.shouldAssert(3 /* VeryAggressive */)) { - var oldTextPrefix = oldText.substr(0, textChangeRange.span.start); - var newTextPrefix = newText.substr(0, textChangeRange.span.start); - ts.Debug.assert(oldTextPrefix === newTextPrefix); - var oldTextSuffix = oldText.substring(ts.textSpanEnd(textChangeRange.span), oldText.length); - var newTextSuffix = newText.substring(ts.textSpanEnd(ts.textChangeRangeNewSpan(textChangeRange)), newText.length); - ts.Debug.assert(oldTextSuffix === newTextSuffix); - } - } - } - function createSyntaxCursor(sourceFile) { - var currentArray = sourceFile.statements; - var currentArrayIndex = 0; - ts.Debug.assert(currentArrayIndex < currentArray.length); - var current = currentArray[currentArrayIndex]; - var lastQueriedPosition = -1 /* Value */; - return { - currentNode: function (position) { - // Only compute the current node if the position is different than the last time - // we were asked. The parser commonly asks for the node at the same position - // twice. Once to know if can read an appropriate list element at a certain point, - // and then to actually read and consume the node. - if (position !== lastQueriedPosition) { - // Much of the time the parser will need the very next node in the array that - // we just returned a node from.So just simply check for that case and move - // forward in the array instead of searching for the node again. - if (current && current.end === position && currentArrayIndex < (currentArray.length - 1)) { - currentArrayIndex++; - current = currentArray[currentArrayIndex]; - } - // If we don't have a node, or the node we have isn't in the right position, - // then try to find a viable node at the position requested. - if (!current || current.pos !== position) { - findHighestListElementThatStartsAtPosition(position); - } - } - // Cache this query so that we don't do any extra work if the parser calls back - // into us. Note: this is very common as the parser will make pairs of calls like - // 'isListElement -> parseListElement'. If we were unable to find a node when - // called with 'isListElement', we don't want to redo the work when parseListElement - // is called immediately after. - lastQueriedPosition = position; - // Either we don'd have a node, or we have a node at the position being asked for. - ts.Debug.assert(!current || current.pos === position); - return current; - } - }; - // Finds the highest element in the tree we can find that starts at the provided position. - // The element must be a direct child of some node list in the tree. This way after we - // return it, we can easily return its next sibling in the list. - function findHighestListElementThatStartsAtPosition(position) { - // Clear out any cached state about the last node we found. - currentArray = undefined; - currentArrayIndex = -1 /* Value */; - current = undefined; - // Recurse into the source file to find the highest node at this position. - forEachChild(sourceFile, visitNode, visitArray); - return; - function visitNode(node) { - if (position >= node.pos && position < node.end) { - // Position was within this node. Keep searching deeper to find the node. - forEachChild(node, visitNode, visitArray); - // don't procede any futher in the search. - return true; - } - // position wasn't in this node, have to keep searching. - return false; - } - function visitArray(array) { - if (position >= array.pos && position < array.end) { - // position was in this array. Search through this array to see if we find a - // viable element. - for (var i = 0, n = array.length; i < n; i++) { - var child = array[i]; - if (child) { - if (child.pos === position) { - // Found the right node. We're done. - currentArray = array; - currentArrayIndex = i; - current = child; - return true; - } - else { - if (child.pos < position && position < child.end) { - // Position in somewhere within this child. Search in it and - // stop searching in this array. - forEachChild(child, visitNode, visitArray); - return true; - } - } - } - } - } - // position wasn't in this array, have to keep searching. - return false; - } - } - } - var InvalidPosition; - (function (InvalidPosition) { - InvalidPosition[InvalidPosition["Value"] = -1] = "Value"; - })(InvalidPosition || (InvalidPosition = {})); - })(IncrementalParser || (IncrementalParser = {})); -})(ts || (ts = {})); -/// -/* @internal */ -var ts; -(function (ts) { - var nextSymbolId = 1; - var nextNodeId = 1; - var nextMergeId = 1; - function getNodeId(node) { - if (!node.id) - node.id = nextNodeId++; - return node.id; - } - ts.getNodeId = getNodeId; - ts.checkTime = 0; - function getSymbolId(symbol) { - if (!symbol.id) { - symbol.id = nextSymbolId++; - } - return symbol.id; - } - ts.getSymbolId = getSymbolId; - function createTypeChecker(host, produceDiagnostics) { - // Cancellation that controls whether or not we can cancel in the middle of type checking. - // In general cancelling is *not* safe for the type checker. We might be in the middle of - // computing something, and we will leave our internals in an inconsistent state. Callers - // who set the cancellation token should catch if a cancellation exception occurs, and - // should throw away and create a new TypeChecker. - // - // Currently we only support setting the cancellation token when getting diagnostics. This - // is because diagnostics can be quite expensive, and we want to allow hosts to bail out if - // they no longer need the information (for example, if the user started editing again). - var cancellationToken; - var Symbol = ts.objectAllocator.getSymbolConstructor(); - var Type = ts.objectAllocator.getTypeConstructor(); - var Signature = ts.objectAllocator.getSignatureConstructor(); - var typeCount = 0; - var symbolCount = 0; - var emptyArray = []; - var emptySymbols = {}; - var compilerOptions = host.getCompilerOptions(); - var languageVersion = compilerOptions.target || 0 /* ES3 */; - var modulekind = compilerOptions.module ? compilerOptions.module : languageVersion === 2 /* ES6 */ ? 5 /* ES6 */ : 0 /* None */; - var emitResolver = createResolver(); - var undefinedSymbol = createSymbol(4 /* Property */ | 67108864 /* Transient */, "undefined"); - var argumentsSymbol = createSymbol(4 /* Property */ | 67108864 /* Transient */, "arguments"); - var checker = { - getNodeCount: function () { return ts.sum(host.getSourceFiles(), "nodeCount"); }, - getIdentifierCount: function () { return ts.sum(host.getSourceFiles(), "identifierCount"); }, - getSymbolCount: function () { return ts.sum(host.getSourceFiles(), "symbolCount") + symbolCount; }, - getTypeCount: function () { return typeCount; }, - isUndefinedSymbol: function (symbol) { return symbol === undefinedSymbol; }, - isArgumentsSymbol: function (symbol) { return symbol === argumentsSymbol; }, - getDiagnostics: getDiagnostics, - getGlobalDiagnostics: getGlobalDiagnostics, - // The language service will always care about the narrowed type of a symbol, because that is - // the type the language says the symbol should have. - getTypeOfSymbolAtLocation: getNarrowedTypeOfSymbol, - getDeclaredTypeOfSymbol: getDeclaredTypeOfSymbol, - getPropertiesOfType: getPropertiesOfType, - getPropertyOfType: getPropertyOfType, - getSignaturesOfType: getSignaturesOfType, - getIndexTypeOfType: getIndexTypeOfType, - getBaseTypes: getBaseTypes, - getReturnTypeOfSignature: getReturnTypeOfSignature, - getSymbolsInScope: getSymbolsInScope, - getSymbolAtLocation: getSymbolAtLocation, - getShorthandAssignmentValueSymbol: getShorthandAssignmentValueSymbol, - getTypeAtLocation: getTypeOfNode, - typeToString: typeToString, - getSymbolDisplayBuilder: getSymbolDisplayBuilder, - symbolToString: symbolToString, - getAugmentedPropertiesOfType: getAugmentedPropertiesOfType, - getRootSymbols: getRootSymbols, - getContextualType: getContextualType, - getFullyQualifiedName: getFullyQualifiedName, - getResolvedSignature: getResolvedSignature, - getConstantValue: getConstantValue, - isValidPropertyAccess: isValidPropertyAccess, - getSignatureFromDeclaration: getSignatureFromDeclaration, - isImplementationOfOverload: isImplementationOfOverload, - getAliasedSymbol: resolveAlias, - getEmitResolver: getEmitResolver, - getExportsOfModule: getExportsOfModuleAsArray, - getJsxElementAttributesType: getJsxElementAttributesType, - getJsxIntrinsicTagNames: getJsxIntrinsicTagNames, - isOptionalParameter: isOptionalParameter - }; - var unknownSymbol = createSymbol(4 /* Property */ | 67108864 /* Transient */, "unknown"); - var resolvingSymbol = createSymbol(67108864 /* Transient */, "__resolving__"); - var anyType = createIntrinsicType(1 /* Any */, "any"); - var stringType = createIntrinsicType(2 /* String */, "string"); - var numberType = createIntrinsicType(4 /* Number */, "number"); - var booleanType = createIntrinsicType(8 /* Boolean */, "boolean"); - var esSymbolType = createIntrinsicType(16777216 /* ESSymbol */, "symbol"); - var voidType = createIntrinsicType(16 /* Void */, "void"); - var undefinedType = createIntrinsicType(32 /* Undefined */ | 2097152 /* ContainsUndefinedOrNull */, "undefined"); - var nullType = createIntrinsicType(64 /* Null */ | 2097152 /* ContainsUndefinedOrNull */, "null"); - var unknownType = createIntrinsicType(1 /* Any */, "unknown"); - var circularType = createIntrinsicType(1 /* Any */, "__circular__"); - var emptyObjectType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); - var emptyGenericType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); - emptyGenericType.instantiations = {}; - var anyFunctionType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); - // The anyFunctionType contains the anyFunctionType by definition. The flag is further propagated - // in getPropagatingFlagsOfTypes, and it is checked in inferFromTypes. - anyFunctionType.flags |= 8388608 /* ContainsAnyFunctionType */; - var noConstraintType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); - var anySignature = createSignature(undefined, undefined, emptyArray, anyType, undefined, 0, false, false); - var unknownSignature = createSignature(undefined, undefined, emptyArray, unknownType, undefined, 0, false, false); - var globals = {}; - var globalESSymbolConstructorSymbol; - var getGlobalPromiseConstructorSymbol; - var globalObjectType; - var globalFunctionType; - var globalArrayType; - var globalStringType; - var globalNumberType; - var globalBooleanType; - var globalRegExpType; - var globalTemplateStringsArrayType; - var globalESSymbolType; - var jsxElementType; - /** Lazily loaded, use getJsxIntrinsicElementType() */ - var jsxIntrinsicElementsType; - var globalIterableType; - var globalIteratorType; - var globalIterableIteratorType; - var anyArrayType; - var getGlobalClassDecoratorType; - var getGlobalParameterDecoratorType; - var getGlobalPropertyDecoratorType; - var getGlobalMethodDecoratorType; - var getGlobalTypedPropertyDescriptorType; - var getGlobalPromiseType; - var tryGetGlobalPromiseType; - var getGlobalPromiseLikeType; - var getInstantiatedGlobalPromiseLikeType; - var getGlobalPromiseConstructorLikeType; - var getGlobalThenableType; - var tupleTypes = {}; - var unionTypes = {}; - var intersectionTypes = {}; - var stringLiteralTypes = {}; - var emitExtends = false; - var emitDecorate = false; - var emitParam = false; - var emitAwaiter = false; - var emitGenerator = false; - var resolutionTargets = []; - var resolutionResults = []; - var resolutionPropertyNames = []; - var mergedSymbols = []; - var symbolLinks = []; - var nodeLinks = []; - var potentialThisCollisions = []; - var awaitedTypeStack = []; - var diagnostics = ts.createDiagnosticCollection(); - var primitiveTypeInfo = { - "string": { - type: stringType, - flags: 258 /* StringLike */ - }, - "number": { - type: numberType, - flags: 132 /* NumberLike */ - }, - "boolean": { - type: booleanType, - flags: 8 /* Boolean */ - }, - "symbol": { - type: esSymbolType, - flags: 16777216 /* ESSymbol */ - } - }; - var JsxNames = { - JSX: "JSX", - IntrinsicElements: "IntrinsicElements", - ElementClass: "ElementClass", - ElementAttributesPropertyNameContainer: "ElementAttributesProperty", - Element: "Element" - }; - var subtypeRelation = {}; - var assignableRelation = {}; - var identityRelation = {}; - // This is for caching the result of getSymbolDisplayBuilder. Do not access directly. - 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 = {})); - initializeTypeChecker(); - return checker; - function getEmitResolver(sourceFile, cancellationToken) { - // Ensure we have all the type information in place for this file so that all the - // emitter questions of this resolver will return the right information. - getDiagnostics(sourceFile, cancellationToken); - return emitResolver; - } - function error(location, message, arg0, arg1, arg2) { - var diagnostic = location - ? ts.createDiagnosticForNode(location, message, arg0, arg1, arg2) - : ts.createCompilerDiagnostic(message, arg0, arg1, arg2); - diagnostics.add(diagnostic); - } - function createSymbol(flags, name) { - symbolCount++; - return new Symbol(flags, name); - } - function getExcludedSymbolFlags(flags) { - var result = 0; - if (flags & 2 /* BlockScopedVariable */) - result |= 107455 /* BlockScopedVariableExcludes */; - if (flags & 1 /* FunctionScopedVariable */) - result |= 107454 /* FunctionScopedVariableExcludes */; - if (flags & 4 /* Property */) - result |= 107455 /* PropertyExcludes */; - if (flags & 8 /* EnumMember */) - result |= 107455 /* EnumMemberExcludes */; - if (flags & 16 /* Function */) - result |= 106927 /* FunctionExcludes */; - if (flags & 32 /* Class */) - result |= 899519 /* ClassExcludes */; - if (flags & 64 /* Interface */) - result |= 792960 /* InterfaceExcludes */; - if (flags & 256 /* RegularEnum */) - result |= 899327 /* RegularEnumExcludes */; - if (flags & 128 /* ConstEnum */) - result |= 899967 /* ConstEnumExcludes */; - if (flags & 512 /* ValueModule */) - result |= 106639 /* ValueModuleExcludes */; - if (flags & 8192 /* Method */) - result |= 99263 /* MethodExcludes */; - if (flags & 32768 /* GetAccessor */) - result |= 41919 /* GetAccessorExcludes */; - if (flags & 65536 /* SetAccessor */) - result |= 74687 /* SetAccessorExcludes */; - if (flags & 262144 /* TypeParameter */) - result |= 530912 /* TypeParameterExcludes */; - if (flags & 524288 /* TypeAlias */) - result |= 793056 /* TypeAliasExcludes */; - if (flags & 8388608 /* Alias */) - result |= 8388608 /* AliasExcludes */; - return result; - } - function recordMergedSymbol(target, source) { - if (!source.mergeId) - source.mergeId = nextMergeId++; - mergedSymbols[source.mergeId] = target; - } - function cloneSymbol(symbol) { - var result = createSymbol(symbol.flags | 33554432 /* Merged */, symbol.name); - result.declarations = symbol.declarations.slice(0); - result.parent = symbol.parent; - if (symbol.valueDeclaration) - result.valueDeclaration = symbol.valueDeclaration; - if (symbol.constEnumOnlyModule) - result.constEnumOnlyModule = true; - if (symbol.members) - result.members = cloneSymbolTable(symbol.members); - if (symbol.exports) - result.exports = cloneSymbolTable(symbol.exports); - recordMergedSymbol(result, symbol); - return result; - } - function mergeSymbol(target, source) { - if (!(target.flags & getExcludedSymbolFlags(source.flags))) { - if (source.flags & 512 /* ValueModule */ && target.flags & 512 /* ValueModule */ && target.constEnumOnlyModule && !source.constEnumOnlyModule) { - // reset flag when merging instantiated module into value module that has only const enums - target.constEnumOnlyModule = false; - } - target.flags |= source.flags; - if (!target.valueDeclaration && source.valueDeclaration) - target.valueDeclaration = source.valueDeclaration; - ts.forEach(source.declarations, function (node) { - target.declarations.push(node); - }); - if (source.members) { - if (!target.members) - target.members = {}; - mergeSymbolTable(target.members, source.members); - } - if (source.exports) { - if (!target.exports) - target.exports = {}; - mergeSymbolTable(target.exports, source.exports); - } - recordMergedSymbol(target, source); - } - else { - var message = target.flags & 2 /* BlockScopedVariable */ || source.flags & 2 /* BlockScopedVariable */ - ? ts.Diagnostics.Cannot_redeclare_block_scoped_variable_0 : ts.Diagnostics.Duplicate_identifier_0; - ts.forEach(source.declarations, function (node) { - error(node.name ? node.name : node, message, symbolToString(source)); - }); - ts.forEach(target.declarations, function (node) { - error(node.name ? node.name : node, message, symbolToString(source)); - }); - } - } - function cloneSymbolTable(symbolTable) { - var result = {}; - for (var id in symbolTable) { - if (ts.hasProperty(symbolTable, id)) { - result[id] = symbolTable[id]; - } - } - return result; - } - function mergeSymbolTable(target, source) { - for (var id in source) { - if (ts.hasProperty(source, id)) { - if (!ts.hasProperty(target, id)) { - target[id] = source[id]; - } - else { - var symbol = target[id]; - if (!(symbol.flags & 33554432 /* Merged */)) { - target[id] = symbol = cloneSymbol(symbol); - } - mergeSymbol(symbol, source[id]); - } - } - } - } - function getSymbolLinks(symbol) { - if (symbol.flags & 67108864 /* Transient */) - return symbol; - var id = getSymbolId(symbol); - return symbolLinks[id] || (symbolLinks[id] = {}); - } - function getNodeLinks(node) { - var nodeId = getNodeId(node); - return nodeLinks[nodeId] || (nodeLinks[nodeId] = {}); - } - function getSourceFile(node) { - return ts.getAncestor(node, 248 /* SourceFile */); - } - function isGlobalSourceFile(node) { - return node.kind === 248 /* SourceFile */ && !ts.isExternalModule(node); - } - function getSymbol(symbols, name, meaning) { - if (meaning && ts.hasProperty(symbols, name)) { - var symbol = symbols[name]; - ts.Debug.assert((symbol.flags & 16777216 /* Instantiated */) === 0, "Should never get an instantiated symbol here."); - if (symbol.flags & meaning) { - return symbol; - } - if (symbol.flags & 8388608 /* Alias */) { - var target = resolveAlias(symbol); - // Unknown symbol means an error occurred in alias resolution, treat it as positive answer to avoid cascading errors - if (target === unknownSymbol || target.flags & meaning) { - return symbol; - } - } - } - // return undefined if we can't find a symbol. - } - function isBlockScopedNameDeclaredBeforeUse(declaration, usage) { - var declarationFile = ts.getSourceFileOfNode(declaration); - var useFile = ts.getSourceFileOfNode(usage); - if (declarationFile !== useFile) { - if (modulekind || (!compilerOptions.outFile && !compilerOptions.out)) { - // nodes are in different files and order cannot be determines - return true; - } - var sourceFiles = host.getSourceFiles(); - return ts.indexOf(sourceFiles, declarationFile) <= ts.indexOf(sourceFiles, useFile); - } - if (declaration.pos <= usage.pos) { - // declaration is before usage - // still might be illegal if usage is in the initializer of the variable declaration - return declaration.kind !== 211 /* VariableDeclaration */ || - !isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage); - } - // declaration is after usage - // can be legal if usage is deferred (i.e. inside function or in initializer of instance property) - return isUsedInFunctionOrNonStaticProperty(declaration, usage); - function isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage) { - var container = ts.getEnclosingBlockScopeContainer(declaration); - if (declaration.parent.parent.kind === 193 /* VariableStatement */ || - declaration.parent.parent.kind === 199 /* ForStatement */) { - // variable statement/for statement case, - // use site should not be inside variable declaration (initializer of declaration or binding element) - return isSameScopeDescendentOf(usage, declaration, container); - } - else if (declaration.parent.parent.kind === 201 /* ForOfStatement */ || - declaration.parent.parent.kind === 200 /* ForInStatement */) { - // ForIn/ForOf case - use site should not be used in expression part - var expression = declaration.parent.parent.expression; - return isSameScopeDescendentOf(usage, expression, container); - } - } - function isUsedInFunctionOrNonStaticProperty(declaration, usage) { - var container = ts.getEnclosingBlockScopeContainer(declaration); - var current = usage; - while (current) { - if (current === container) { - return false; - } - if (ts.isFunctionLike(current)) { - return true; - } - var initializerOfNonStaticProperty = current.parent && - current.parent.kind === 141 /* PropertyDeclaration */ && - (current.parent.flags & 128 /* Static */) === 0 && - current.parent.initializer === current; - if (initializerOfNonStaticProperty) { - return true; - } - current = current.parent; - } - return false; - } - } - // Resolve a given name for a given meaning at a given location. An error is reported if the name was not found and - // the nameNotFoundMessage argument is not undefined. Returns the resolved symbol, or undefined if no symbol with - // the given name can be found. - function resolveName(location, name, meaning, nameNotFoundMessage, nameArg) { - var result; - var lastLocation; - var propertyWithInvalidInitializer; - var errorLocation = location; - var grandparent; - loop: while (location) { - // Locals of a source file are not in scope (because they get merged into the global symbol table) - if (location.locals && !isGlobalSourceFile(location)) { - if (result = getSymbol(location.locals, name, meaning)) { - // Type parameters of a function are in scope in the entire function declaration, including the parameter - // list and return type. However, local types are only in scope in the function body. - if (!(meaning & 793056 /* Type */) || - !(result.flags & (793056 /* Type */ & ~262144 /* TypeParameter */)) || - !ts.isFunctionLike(location) || - lastLocation === location.body) { - break loop; - } - result = undefined; - } - } - switch (location.kind) { - case 248 /* SourceFile */: - if (!ts.isExternalModule(location)) - break; - case 218 /* ModuleDeclaration */: - var moduleExports = getSymbolOfNode(location).exports; - if (location.kind === 248 /* SourceFile */ || - (location.kind === 218 /* ModuleDeclaration */ && location.name.kind === 9 /* StringLiteral */)) { - // It's an external module. Because of module/namespace merging, a module's exports are in scope, - // yet we never want to treat an export specifier as putting a member in scope. Therefore, - // if the name we find is purely an export specifier, it is not actually considered in scope. - // Two things to note about this: - // 1. We have to check this without calling getSymbol. The problem with calling getSymbol - // on an export specifier is that it might find the export specifier itself, and try to - // resolve it as an alias. This will cause the checker to consider the export specifier - // a circular alias reference when it might not be. - // 2. We check === SymbolFlags.Alias in order to check that the symbol is *purely* - // an alias. If we used &, we'd be throwing out symbols that have non alias aspects, - // which is not the desired behavior. - if (ts.hasProperty(moduleExports, name) && - moduleExports[name].flags === 8388608 /* Alias */ && - ts.getDeclarationOfKind(moduleExports[name], 230 /* ExportSpecifier */)) { - break; - } - result = moduleExports["default"]; - var localSymbol = ts.getLocalSymbolForExportDefault(result); - if (result && localSymbol && (result.flags & meaning) && localSymbol.name === name) { - break loop; - } - result = undefined; - } - if (result = getSymbol(moduleExports, name, meaning & 8914931 /* ModuleMember */)) { - break loop; - } - break; - case 217 /* EnumDeclaration */: - if (result = getSymbol(getSymbolOfNode(location).exports, name, meaning & 8 /* EnumMember */)) { - break loop; - } - break; - case 141 /* PropertyDeclaration */: - case 140 /* PropertySignature */: - // TypeScript 1.0 spec (April 2014): 8.4.1 - // Initializer expressions for instance member variables are evaluated in the scope - // of the class constructor body but are not permitted to reference parameters or - // local variables of the constructor. This effectively means that entities from outer scopes - // by the same name as a constructor parameter or local variable are inaccessible - // in initializer expressions for instance member variables. - if (ts.isClassLike(location.parent) && !(location.flags & 128 /* Static */)) { - var ctor = findConstructorDeclaration(location.parent); - if (ctor && ctor.locals) { - if (getSymbol(ctor.locals, name, meaning & 107455 /* Value */)) { - // Remember the property node, it will be used later to report appropriate error - propertyWithInvalidInitializer = location; - } - } - } - break; - case 214 /* ClassDeclaration */: - case 186 /* ClassExpression */: - case 215 /* InterfaceDeclaration */: - if (result = getSymbol(getSymbolOfNode(location).members, name, meaning & 793056 /* Type */)) { - if (lastLocation && lastLocation.flags & 128 /* Static */) { - // TypeScript 1.0 spec (April 2014): 3.4.1 - // The scope of a type parameter extends over the entire declaration with which the type - // parameter list is associated, with the exception of static member declarations in classes. - error(errorLocation, ts.Diagnostics.Static_members_cannot_reference_class_type_parameters); - return undefined; - } - break loop; - } - if (location.kind === 186 /* ClassExpression */ && meaning & 32 /* Class */) { - var className = location.name; - if (className && name === className.text) { - result = location.symbol; - break loop; - } - } - break; - // It is not legal to reference a class's own type parameters from a computed property name that - // belongs to the class. For example: - // - // function foo() { return '' } - // class C { // <-- Class's own type parameter T - // [foo()]() { } // <-- Reference to T from class's own computed property - // } - // - case 136 /* ComputedPropertyName */: - grandparent = location.parent.parent; - if (ts.isClassLike(grandparent) || grandparent.kind === 215 /* InterfaceDeclaration */) { - // A reference to this grandparent's type parameters would be an error - if (result = getSymbol(getSymbolOfNode(grandparent).members, name, meaning & 793056 /* Type */)) { - error(errorLocation, ts.Diagnostics.A_computed_property_name_cannot_reference_a_type_parameter_from_its_containing_type); - return undefined; - } - } - break; - case 143 /* MethodDeclaration */: - case 142 /* MethodSignature */: - case 144 /* Constructor */: - case 145 /* GetAccessor */: - case 146 /* SetAccessor */: - case 213 /* FunctionDeclaration */: - case 174 /* ArrowFunction */: - if (meaning & 3 /* Variable */ && name === "arguments") { - result = argumentsSymbol; - break loop; - } - break; - case 173 /* FunctionExpression */: - if (meaning & 3 /* Variable */ && name === "arguments") { - result = argumentsSymbol; - break loop; - } - if (meaning & 16 /* Function */) { - var functionName = location.name; - if (functionName && name === functionName.text) { - result = location.symbol; - break loop; - } - } - break; - case 139 /* Decorator */: - // Decorators are resolved at the class declaration. Resolving at the parameter - // or member would result in looking up locals in the method. - // - // function y() {} - // class C { - // method(@y x, y) {} // <-- decorator y should be resolved at the class declaration, not the parameter. - // } - // - if (location.parent && location.parent.kind === 138 /* Parameter */) { - location = location.parent; - } - // - // function y() {} - // class C { - // @y method(x, y) {} // <-- decorator y should be resolved at the class declaration, not the method. - // } - // - if (location.parent && ts.isClassElement(location.parent)) { - location = location.parent; - } - break; - } - lastLocation = location; - location = location.parent; - } - if (!result) { - result = getSymbol(globals, name, meaning); - } - if (!result) { - if (nameNotFoundMessage) { - error(errorLocation, nameNotFoundMessage, typeof nameArg === "string" ? nameArg : ts.declarationNameToString(nameArg)); - } - return undefined; - } - // Perform extra checks only if error reporting was requested - if (nameNotFoundMessage) { - if (propertyWithInvalidInitializer) { - // We have a match, but the reference occurred within a property initializer and the identifier also binds - // to a local variable in the constructor where the code will be emitted. - var propertyName = propertyWithInvalidInitializer.name; - error(errorLocation, ts.Diagnostics.Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor, ts.declarationNameToString(propertyName), typeof nameArg === "string" ? nameArg : ts.declarationNameToString(nameArg)); - return undefined; - } - // Only check for block-scoped variable if we are looking for the - // name with variable meaning - // For example, - // declare module foo { - // interface bar {} - // } - // let foo/*1*/: foo/*2*/.bar; - // The foo at /*1*/ and /*2*/ will share same symbol with two meaning - // block - scope variable and namespace module. However, only when we - // try to resolve name in /*1*/ which is used in variable position, - // we want to check for block- scoped - if (meaning & 2 /* BlockScopedVariable */) { - var exportOrLocalSymbol = getExportSymbolOfValueSymbolIfExported(result); - if (exportOrLocalSymbol.flags & 2 /* BlockScopedVariable */) { - checkResolvedBlockScopedVariable(exportOrLocalSymbol, errorLocation); - } - } - } - return result; - } - function checkResolvedBlockScopedVariable(result, errorLocation) { - ts.Debug.assert((result.flags & 2 /* BlockScopedVariable */) !== 0); - // 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 (!isBlockScopedNameDeclaredBeforeUse(ts.getAncestor(declaration, 211 /* VariableDeclaration */), errorLocation)) { - error(errorLocation, ts.Diagnostics.Block_scoped_variable_0_used_before_its_declaration, ts.declarationNameToString(declaration.name)); - } - } - /* Starting from 'initial' node walk up the parent chain until 'stopAt' node is reached. - * If at any point current node is equal to 'parent' node - return true. - * Return false if 'stopAt' node is reached or isFunctionLike(current) === true. - */ - function isSameScopeDescendentOf(initial, parent, stopAt) { - if (!parent) { - return false; - } - for (var current = initial; current && current !== stopAt && !ts.isFunctionLike(current); current = current.parent) { - if (current === parent) { - return true; - } - } - return false; - } - function getAnyImportSyntax(node) { - if (ts.isAliasSymbolDeclaration(node)) { - if (node.kind === 221 /* ImportEqualsDeclaration */) { - return node; - } - while (node && node.kind !== 222 /* ImportDeclaration */) { - node = node.parent; - } - return node; - } - } - function getDeclarationOfAliasSymbol(symbol) { - return ts.forEach(symbol.declarations, function (d) { return ts.isAliasSymbolDeclaration(d) ? d : undefined; }); - } - function getTargetOfImportEqualsDeclaration(node) { - if (node.moduleReference.kind === 232 /* ExternalModuleReference */) { - return resolveExternalModuleSymbol(resolveExternalModuleName(node, ts.getExternalModuleImportEqualsDeclarationExpression(node))); - } - return getSymbolOfPartOfRightHandSideOfImportEquals(node.moduleReference, node); - } - function getTargetOfImportClause(node) { - var moduleSymbol = resolveExternalModuleName(node, node.parent.moduleSpecifier); - if (moduleSymbol) { - var exportDefaultSymbol = resolveSymbol(moduleSymbol.exports["default"]); - if (!exportDefaultSymbol) { - error(node.name, ts.Diagnostics.Module_0_has_no_default_export, symbolToString(moduleSymbol)); - } - return exportDefaultSymbol; - } - } - function getTargetOfNamespaceImport(node) { - var moduleSpecifier = node.parent.parent.moduleSpecifier; - return resolveESModuleSymbol(resolveExternalModuleName(node, moduleSpecifier), moduleSpecifier); - } - function getMemberOfModuleVariable(moduleSymbol, name) { - if (moduleSymbol.flags & 3 /* Variable */) { - var typeAnnotation = moduleSymbol.valueDeclaration.type; - if (typeAnnotation) { - return getPropertyOfType(getTypeFromTypeNode(typeAnnotation), name); - } - } - } - // This function creates a synthetic symbol that combines the value side of one symbol with the - // type/namespace side of another symbol. Consider this example: - // - // declare module graphics { - // interface Point { - // x: number; - // y: number; - // } - // } - // declare var graphics: { - // Point: new (x: number, y: number) => graphics.Point; - // } - // declare module "graphics" { - // export = graphics; - // } - // - // An 'import { Point } from "graphics"' needs to create a symbol that combines the value side 'Point' - // property with the type/namespace side interface 'Point'. - function combineValueAndTypeSymbols(valueSymbol, typeSymbol) { - if (valueSymbol.flags & (793056 /* Type */ | 1536 /* Namespace */)) { - return valueSymbol; - } - var result = createSymbol(valueSymbol.flags | typeSymbol.flags, valueSymbol.name); - result.declarations = ts.concatenate(valueSymbol.declarations, typeSymbol.declarations); - result.parent = valueSymbol.parent || typeSymbol.parent; - if (valueSymbol.valueDeclaration) - result.valueDeclaration = valueSymbol.valueDeclaration; - if (typeSymbol.members) - result.members = typeSymbol.members; - if (valueSymbol.exports) - result.exports = valueSymbol.exports; - return result; - } - function getExportOfModule(symbol, name) { - if (symbol.flags & 1536 /* Module */) { - var exports = getExportsOfSymbol(symbol); - if (ts.hasProperty(exports, name)) { - return resolveSymbol(exports[name]); - } - } - } - function getPropertyOfVariable(symbol, name) { - if (symbol.flags & 3 /* Variable */) { - var typeAnnotation = symbol.valueDeclaration.type; - if (typeAnnotation) { - return resolveSymbol(getPropertyOfType(getTypeFromTypeNode(typeAnnotation), name)); - } - } - } - function getExternalModuleMember(node, specifier) { - var moduleSymbol = resolveExternalModuleName(node, node.moduleSpecifier); - var targetSymbol = resolveESModuleSymbol(moduleSymbol, node.moduleSpecifier); - if (targetSymbol) { - var name_9 = specifier.propertyName || specifier.name; - if (name_9.text) { - var symbolFromModule = getExportOfModule(targetSymbol, name_9.text); - var symbolFromVariable = getPropertyOfVariable(targetSymbol, name_9.text); - var symbol = symbolFromModule && symbolFromVariable ? - combineValueAndTypeSymbols(symbolFromVariable, symbolFromModule) : - symbolFromModule || symbolFromVariable; - if (!symbol) { - error(name_9, ts.Diagnostics.Module_0_has_no_exported_member_1, getFullyQualifiedName(moduleSymbol), ts.declarationNameToString(name_9)); - } - return symbol; - } - } - } - function getTargetOfImportSpecifier(node) { - return getExternalModuleMember(node.parent.parent.parent, node); - } - function getTargetOfExportSpecifier(node) { - return node.parent.parent.moduleSpecifier ? - getExternalModuleMember(node.parent.parent, node) : - resolveEntityName(node.propertyName || node.name, 107455 /* Value */ | 793056 /* Type */ | 1536 /* Namespace */); - } - function getTargetOfExportAssignment(node) { - return resolveEntityName(node.expression, 107455 /* Value */ | 793056 /* Type */ | 1536 /* Namespace */); - } - function getTargetOfAliasDeclaration(node) { - switch (node.kind) { - case 221 /* ImportEqualsDeclaration */: - return getTargetOfImportEqualsDeclaration(node); - case 223 /* ImportClause */: - return getTargetOfImportClause(node); - case 224 /* NamespaceImport */: - return getTargetOfNamespaceImport(node); - case 226 /* ImportSpecifier */: - return getTargetOfImportSpecifier(node); - case 230 /* ExportSpecifier */: - return getTargetOfExportSpecifier(node); - case 227 /* ExportAssignment */: - return getTargetOfExportAssignment(node); - } - } - function resolveSymbol(symbol) { - return symbol && symbol.flags & 8388608 /* Alias */ && !(symbol.flags & (107455 /* Value */ | 793056 /* Type */ | 1536 /* Namespace */)) ? resolveAlias(symbol) : symbol; - } - function resolveAlias(symbol) { - ts.Debug.assert((symbol.flags & 8388608 /* Alias */) !== 0, "Should only get Alias here."); - var links = getSymbolLinks(symbol); - if (!links.target) { - links.target = resolvingSymbol; - var node = getDeclarationOfAliasSymbol(symbol); - var target = getTargetOfAliasDeclaration(node); - if (links.target === resolvingSymbol) { - links.target = target || unknownSymbol; - } - else { - error(node, ts.Diagnostics.Circular_definition_of_import_alias_0, symbolToString(symbol)); - } - } - else if (links.target === resolvingSymbol) { - links.target = unknownSymbol; - } - return links.target; - } - function markExportAsReferenced(node) { - var symbol = getSymbolOfNode(node); - var target = resolveAlias(symbol); - if (target) { - var markAlias = (target === unknownSymbol && compilerOptions.isolatedModules) || - (target !== unknownSymbol && (target.flags & 107455 /* Value */) && !isConstEnumOrConstEnumOnlyModule(target)); - if (markAlias) { - markAliasSymbolAsReferenced(symbol); - } - } - } - // When an alias symbol is referenced, we need to mark the entity it references as referenced and in turn repeat that until - // we reach a non-alias or an exported entity (which is always considered referenced). We do this by checking the target of - // the alias as an expression (which recursively takes us back here if the target references another alias). - function markAliasSymbolAsReferenced(symbol) { - var links = getSymbolLinks(symbol); - if (!links.referenced) { - links.referenced = true; - var node = getDeclarationOfAliasSymbol(symbol); - if (node.kind === 227 /* ExportAssignment */) { - // export default - checkExpressionCached(node.expression); - } - else if (node.kind === 230 /* ExportSpecifier */) { - // export { } or export { as foo } - checkExpressionCached(node.propertyName || node.name); - } - else if (ts.isInternalModuleImportEqualsDeclaration(node)) { - // import foo = - checkExpressionCached(node.moduleReference); - } - } - } - // This function is only for imports with entity names - function getSymbolOfPartOfRightHandSideOfImportEquals(entityName, importDeclaration) { - if (!importDeclaration) { - importDeclaration = ts.getAncestor(entityName, 221 /* ImportEqualsDeclaration */); - ts.Debug.assert(importDeclaration !== undefined); - } - // There are three things we might try to look for. In the following examples, - // 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)) { - entityName = entityName.parent; - } - // Check for case 1 and 3 in the above example - if (entityName.kind === 69 /* Identifier */ || entityName.parent.kind === 135 /* QualifiedName */) { - return resolveEntityName(entityName, 1536 /* Namespace */); - } - else { - // Case 2 in above example - // entityName.kind could be a QualifiedName or a Missing identifier - ts.Debug.assert(entityName.parent.kind === 221 /* ImportEqualsDeclaration */); - return resolveEntityName(entityName, 107455 /* Value */ | 793056 /* Type */ | 1536 /* Namespace */); - } - } - function getFullyQualifiedName(symbol) { - return symbol.parent ? getFullyQualifiedName(symbol.parent) + "." + symbolToString(symbol) : symbolToString(symbol); - } - // Resolves a qualified name and any involved aliases - function resolveEntityName(name, meaning, ignoreErrors) { - if (ts.nodeIsMissing(name)) { - return undefined; - } - var symbol; - if (name.kind === 69 /* Identifier */) { - var message = meaning === 1536 /* Namespace */ ? ts.Diagnostics.Cannot_find_namespace_0 : ts.Diagnostics.Cannot_find_name_0; - symbol = resolveName(name, name.text, meaning, ignoreErrors ? undefined : message, name); - if (!symbol) { - return undefined; - } - } - else if (name.kind === 135 /* QualifiedName */ || name.kind === 166 /* PropertyAccessExpression */) { - var left = name.kind === 135 /* QualifiedName */ ? name.left : name.expression; - var right = name.kind === 135 /* QualifiedName */ ? name.right : name.name; - var namespace = resolveEntityName(left, 1536 /* Namespace */, ignoreErrors); - if (!namespace || namespace === unknownSymbol || ts.nodeIsMissing(right)) { - return undefined; - } - symbol = getSymbol(getExportsOfSymbol(namespace), right.text, meaning); - if (!symbol) { - if (!ignoreErrors) { - error(right, ts.Diagnostics.Module_0_has_no_exported_member_1, getFullyQualifiedName(namespace), ts.declarationNameToString(right)); - } - return undefined; - } - } - else { - ts.Debug.fail("Unknown entity name kind."); - } - ts.Debug.assert((symbol.flags & 16777216 /* Instantiated */) === 0, "Should never get an instantiated symbol here."); - return symbol.flags & meaning ? symbol : resolveAlias(symbol); - } - function resolveExternalModuleName(location, moduleReferenceExpression) { - if (moduleReferenceExpression.kind !== 9 /* StringLiteral */) { - return; - } - var moduleReferenceLiteral = moduleReferenceExpression; - var searchPath = ts.getDirectoryPath(getSourceFile(location).fileName); - // Module names are escaped in our symbol table. However, string literal values aren't. - // Escape the name in the "require(...)" clause to ensure we find the right symbol. - var moduleName = ts.escapeIdentifier(moduleReferenceLiteral.text); - if (moduleName === undefined) { - return; - } - var isRelative = ts.isExternalModuleNameRelative(moduleName); - if (!isRelative) { - var symbol = getSymbol(globals, "\"" + moduleName + "\"", 512 /* ValueModule */); - if (symbol) { - return symbol; - } - } - var resolvedModule = ts.getResolvedModule(getSourceFile(location), moduleReferenceLiteral.text); - var sourceFile = resolvedModule && host.getSourceFile(resolvedModule.resolvedFileName); - if (sourceFile) { - if (sourceFile.symbol) { - return sourceFile.symbol; - } - error(moduleReferenceLiteral, ts.Diagnostics.File_0_is_not_a_module, sourceFile.fileName); - return; - } - error(moduleReferenceLiteral, ts.Diagnostics.Cannot_find_module_0, moduleName); - } - // An external module with an 'export =' declaration resolves to the target of the 'export =' declaration, - // and an external module with no 'export =' declaration resolves to the module itself. - function resolveExternalModuleSymbol(moduleSymbol) { - return moduleSymbol && resolveSymbol(moduleSymbol.exports["export="]) || moduleSymbol; - } - // An external module with an 'export =' declaration may be referenced as an ES6 module provided the 'export =' - // references a symbol that is at least declared as a module or a variable. The target of the 'export =' may - // combine other declarations with the module or variable (e.g. a class/module, function/module, interface/variable). - function resolveESModuleSymbol(moduleSymbol, moduleReferenceExpression) { - var symbol = resolveExternalModuleSymbol(moduleSymbol); - if (symbol && !(symbol.flags & (1536 /* Module */ | 3 /* Variable */))) { - error(moduleReferenceExpression, ts.Diagnostics.Module_0_resolves_to_a_non_module_entity_and_cannot_be_imported_using_this_construct, symbolToString(moduleSymbol)); - symbol = undefined; - } - return symbol; - } - function getExportAssignmentSymbol(moduleSymbol) { - return moduleSymbol.exports["export="]; - } - function getExportsOfModuleAsArray(moduleSymbol) { - return symbolsToArray(getExportsOfModule(moduleSymbol)); - } - function getExportsOfSymbol(symbol) { - return symbol.flags & 1536 /* Module */ ? getExportsOfModule(symbol) : symbol.exports || emptySymbols; - } - function getExportsOfModule(moduleSymbol) { - var links = getSymbolLinks(moduleSymbol); - return links.resolvedExports || (links.resolvedExports = getExportsForModule(moduleSymbol)); - } - function extendExportSymbols(target, source) { - for (var id in source) { - if (id !== "default" && !ts.hasProperty(target, id)) { - target[id] = source[id]; - } - } - } - function getExportsForModule(moduleSymbol) { - var result; - var visitedSymbols = []; - visit(moduleSymbol); - return result || 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. - function visit(symbol) { - if (symbol && symbol.flags & 1952 /* HasExports */ && !ts.contains(visitedSymbols, symbol)) { - visitedSymbols.push(symbol); - if (symbol !== moduleSymbol) { - if (!result) { - result = cloneSymbolTable(moduleSymbol.exports); - } - extendExportSymbols(result, symbol.exports); - } - // All export * declarations are collected in an __export symbol by the binder - var exportStars = symbol.exports["__export"]; - if (exportStars) { - for (var _i = 0, _a = exportStars.declarations; _i < _a.length; _i++) { - var node = _a[_i]; - visit(resolveExternalModuleName(node, node.moduleSpecifier)); - } - } - } - } - } - function getMergedSymbol(symbol) { - var merged; - return symbol && symbol.mergeId && (merged = mergedSymbols[symbol.mergeId]) ? merged : symbol; - } - function getSymbolOfNode(node) { - return getMergedSymbol(node.symbol); - } - function getParentOfSymbol(symbol) { - return getMergedSymbol(symbol.parent); - } - function getExportSymbolOfValueSymbolIfExported(symbol) { - return symbol && (symbol.flags & 1048576 /* ExportValue */) !== 0 - ? getMergedSymbol(symbol.exportSymbol) - : symbol; - } - function symbolIsValue(symbol) { - // If it is an instantiated symbol, then it is a value if the symbol it is an - // instantiation of is a value. - if (symbol.flags & 16777216 /* Instantiated */) { - return symbolIsValue(getSymbolLinks(symbol).target); - } - // If the symbol has the value flag, it is trivially a value. - if (symbol.flags & 107455 /* Value */) { - return true; - } - // If it is an alias, then it is a value if the symbol it resolves to is a value. - if (symbol.flags & 8388608 /* Alias */) { - return (resolveAlias(symbol).flags & 107455 /* Value */) !== 0; - } - return false; - } - function findConstructorDeclaration(node) { - var members = node.members; - for (var _i = 0; _i < members.length; _i++) { - var member = members[_i]; - if (member.kind === 144 /* Constructor */ && ts.nodeIsPresent(member.body)) { - return member; - } - } - } - function createType(flags) { - var result = new Type(checker, flags); - result.id = typeCount++; - return result; - } - function createIntrinsicType(kind, intrinsicName) { - var type = createType(kind); - type.intrinsicName = intrinsicName; - return type; - } - function createObjectType(kind, symbol) { - var type = createType(kind); - type.symbol = symbol; - return type; - } - // A reserved member name starts with two underscores, but the third character cannot be an underscore - // or the @ symbol. A third underscore indicates an escaped form of an identifer that started - // with at least two underscores. The @ character indicates that the name is denoted by a well known ES - // Symbol instance. - function isReservedMemberName(name) { - return name.charCodeAt(0) === 95 /* _ */ && - name.charCodeAt(1) === 95 /* _ */ && - name.charCodeAt(2) !== 95 /* _ */ && - name.charCodeAt(2) !== 64 /* at */; - } - function getNamedMembers(members) { - var result; - for (var id in members) { - if (ts.hasProperty(members, id)) { - if (!isReservedMemberName(id)) { - if (!result) - result = []; - var symbol = members[id]; - if (symbolIsValue(symbol)) { - result.push(symbol); - } - } - } - } - return result || emptyArray; - } - function setObjectTypeMembers(type, members, callSignatures, constructSignatures, stringIndexType, numberIndexType) { - type.members = members; - type.properties = getNamedMembers(members); - type.callSignatures = callSignatures; - type.constructSignatures = constructSignatures; - if (stringIndexType) - type.stringIndexType = stringIndexType; - if (numberIndexType) - type.numberIndexType = numberIndexType; - return type; - } - function createAnonymousType(symbol, members, callSignatures, constructSignatures, stringIndexType, numberIndexType) { - return setObjectTypeMembers(createObjectType(65536 /* Anonymous */, symbol), members, callSignatures, constructSignatures, stringIndexType, numberIndexType); - } - function forEachSymbolTableInScope(enclosingDeclaration, callback) { - var result; - for (var location_1 = enclosingDeclaration; location_1; location_1 = location_1.parent) { - // Locals of a source file are not in scope (because they get merged into the global symbol table) - if (location_1.locals && !isGlobalSourceFile(location_1)) { - if (result = callback(location_1.locals)) { - return result; - } - } - switch (location_1.kind) { - case 248 /* SourceFile */: - if (!ts.isExternalModule(location_1)) { - break; - } - case 218 /* ModuleDeclaration */: - if (result = callback(getSymbolOfNode(location_1).exports)) { - return result; - } - break; - case 214 /* ClassDeclaration */: - case 215 /* InterfaceDeclaration */: - if (result = callback(getSymbolOfNode(location_1).members)) { - return result; - } - break; - } - } - return callback(globals); - } - function getQualifiedLeftMeaning(rightMeaning) { - // If we are looking in value space, the parent meaning is value, other wise it is namespace - return rightMeaning === 107455 /* Value */ ? 107455 /* Value */ : 1536 /* Namespace */; - } - function getAccessibleSymbolChain(symbol, enclosingDeclaration, meaning, useOnlyExternalAliasing) { - function getAccessibleSymbolChainFromSymbolTable(symbols) { - function canQualifySymbol(symbolFromSymbolTable, meaning) { - // If the symbol is equivalent and doesn't need further qualification, this symbol is accessible - if (!needsQualification(symbolFromSymbolTable, enclosingDeclaration, meaning)) { - return true; - } - // If symbol needs qualification, make sure that parent is accessible, if it is then this symbol is accessible too - var accessibleParent = getAccessibleSymbolChain(symbolFromSymbolTable.parent, enclosingDeclaration, getQualifiedLeftMeaning(meaning), useOnlyExternalAliasing); - return !!accessibleParent; - } - function isAccessible(symbolFromSymbolTable, resolvedAliasSymbol) { - if (symbol === (resolvedAliasSymbol || symbolFromSymbolTable)) { - // if the symbolFromSymbolTable is not external module (it could be if it was determined as ambient external module and would be in globals table) - // and if symbolfrom symbolTable or alias resolution matches the symbol, - // check the symbol can be qualified, it is only then this symbol is accessible - return !ts.forEach(symbolFromSymbolTable.declarations, hasExternalModuleSymbol) && - canQualifySymbol(symbolFromSymbolTable, meaning); - } - } - // If symbol is directly available by its name in the symbol table - if (isAccessible(ts.lookUp(symbols, symbol.name))) { - return [symbol]; - } - // Check if symbol is any of the alias - return ts.forEachValue(symbols, function (symbolFromSymbolTable) { - if (symbolFromSymbolTable.flags & 8388608 /* Alias */ - && symbolFromSymbolTable.name !== "export=" - && !ts.getDeclarationOfKind(symbolFromSymbolTable, 230 /* ExportSpecifier */)) { - if (!useOnlyExternalAliasing || - // Is this external alias, then use it to name - ts.forEach(symbolFromSymbolTable.declarations, ts.isExternalModuleImportEqualsDeclaration)) { - var resolvedImportedSymbol = resolveAlias(symbolFromSymbolTable); - if (isAccessible(symbolFromSymbolTable, resolveAlias(symbolFromSymbolTable))) { - return [symbolFromSymbolTable]; - } - // Look in the exported members, if we can find accessibleSymbolChain, symbol is accessible using this chain - // but only if the symbolFromSymbolTable can be qualified - var accessibleSymbolsFromExports = resolvedImportedSymbol.exports ? getAccessibleSymbolChainFromSymbolTable(resolvedImportedSymbol.exports) : undefined; - if (accessibleSymbolsFromExports && canQualifySymbol(symbolFromSymbolTable, getQualifiedLeftMeaning(meaning))) { - return [symbolFromSymbolTable].concat(accessibleSymbolsFromExports); - } - } - } - }); - } - if (symbol) { - return forEachSymbolTableInScope(enclosingDeclaration, getAccessibleSymbolChainFromSymbolTable); - } - } - function needsQualification(symbol, enclosingDeclaration, meaning) { - var qualify = false; - forEachSymbolTableInScope(enclosingDeclaration, function (symbolTable) { - // If symbol of this name is not available in the symbol table we are ok - if (!ts.hasProperty(symbolTable, symbol.name)) { - // Continue to the next symbol table - return false; - } - // If the symbol with this name is present it should refer to the symbol - var symbolFromSymbolTable = symbolTable[symbol.name]; - if (symbolFromSymbolTable === symbol) { - // No need to qualify - return true; - } - // Qualify if the symbol from symbol table has same meaning as expected - symbolFromSymbolTable = (symbolFromSymbolTable.flags & 8388608 /* Alias */ && !ts.getDeclarationOfKind(symbolFromSymbolTable, 230 /* ExportSpecifier */)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; - if (symbolFromSymbolTable.flags & meaning) { - qualify = true; - return true; - } - // Continue to the next symbol table - return false; - }); - return qualify; - } - function isSymbolAccessible(symbol, enclosingDeclaration, meaning) { - if (symbol && enclosingDeclaration && !(symbol.flags & 262144 /* TypeParameter */)) { - var initialSymbol = symbol; - var meaningToLook = meaning; - while (symbol) { - // Symbol is accessible if it by itself is accessible - var accessibleSymbolChain = getAccessibleSymbolChain(symbol, enclosingDeclaration, meaningToLook, /*useOnlyExternalAliasing*/ false); - if (accessibleSymbolChain) { - var hasAccessibleDeclarations = hasVisibleDeclarations(accessibleSymbolChain[0]); - if (!hasAccessibleDeclarations) { - return { - accessibility: 1 /* NotAccessible */, - errorSymbolName: symbolToString(initialSymbol, enclosingDeclaration, meaning), - errorModuleName: symbol !== initialSymbol ? symbolToString(symbol, enclosingDeclaration, 1536 /* Namespace */) : undefined - }; - } - return hasAccessibleDeclarations; - } - // If we haven't got the accessible symbol, it doesn't mean the symbol is actually inaccessible. - // It could be a qualified symbol and hence verify the path - // e.g.: - // module m { - // export class c { - // } - // } - // let x: typeof m.c - // In the above example when we start with checking if typeof m.c symbol is accessible, - // we are going to see if c can be accessed in scope directly. - // But it can't, hence the accessible is going to be undefined, but that doesn't mean m.c is inaccessible - // It is accessible if the parent m is accessible because then m.c can be accessed through qualification - meaningToLook = getQualifiedLeftMeaning(meaning); - symbol = getParentOfSymbol(symbol); - } - // This could be a symbol that is not exported in the external module - // or it could be a symbol from different external module that is not aliased and hence cannot be named - var symbolExternalModule = ts.forEach(initialSymbol.declarations, getExternalModuleContainer); - if (symbolExternalModule) { - var enclosingExternalModule = getExternalModuleContainer(enclosingDeclaration); - if (symbolExternalModule !== enclosingExternalModule) { - // name from different external module that is not visible - return { - accessibility: 2 /* CannotBeNamed */, - errorSymbolName: symbolToString(initialSymbol, enclosingDeclaration, meaning), - errorModuleName: symbolToString(symbolExternalModule) - }; - } - } - // Just a local name that is not accessible - return { - accessibility: 1 /* NotAccessible */, - errorSymbolName: symbolToString(initialSymbol, enclosingDeclaration, meaning) - }; - } - return { accessibility: 0 /* Accessible */ }; - function getExternalModuleContainer(declaration) { - for (; declaration; declaration = declaration.parent) { - if (hasExternalModuleSymbol(declaration)) { - return getSymbolOfNode(declaration); - } - } - } - } - function hasExternalModuleSymbol(declaration) { - return (declaration.kind === 218 /* ModuleDeclaration */ && declaration.name.kind === 9 /* StringLiteral */) || - (declaration.kind === 248 /* SourceFile */ && ts.isExternalModule(declaration)); - } - function hasVisibleDeclarations(symbol) { - var aliasesToMakeVisible; - if (ts.forEach(symbol.declarations, function (declaration) { return !getIsDeclarationVisible(declaration); })) { - return undefined; - } - return { accessibility: 0 /* Accessible */, aliasesToMakeVisible: aliasesToMakeVisible }; - function getIsDeclarationVisible(declaration) { - if (!isDeclarationVisible(declaration)) { - // Mark the unexported alias as visible if its parent is visible - // because these kind of aliases can be used to name types in declaration file - var anyImportSyntax = getAnyImportSyntax(declaration); - if (anyImportSyntax && - !(anyImportSyntax.flags & 1 /* Export */) && - isDeclarationVisible(anyImportSyntax.parent)) { - getNodeLinks(declaration).isVisible = true; - if (aliasesToMakeVisible) { - if (!ts.contains(aliasesToMakeVisible, anyImportSyntax)) { - aliasesToMakeVisible.push(anyImportSyntax); - } - } - else { - aliasesToMakeVisible = [anyImportSyntax]; - } - return true; - } - // Declaration is not visible - return false; - } - return true; - } - } - function isEntityNameVisible(entityName, enclosingDeclaration) { - // get symbol of the first identifier of the entityName - var meaning; - if (entityName.parent.kind === 154 /* TypeQuery */) { - // Typeof value - meaning = 107455 /* Value */ | 1048576 /* ExportValue */; - } - else if (entityName.kind === 135 /* QualifiedName */ || entityName.kind === 166 /* PropertyAccessExpression */ || - entityName.parent.kind === 221 /* ImportEqualsDeclaration */) { - // Left identifier from type reference or TypeAlias - // Entity name of the import declaration - meaning = 1536 /* Namespace */; - } - else { - // Type Reference or TypeAlias entity = Identifier - meaning = 793056 /* Type */; - } - var firstIdentifier = getFirstIdentifier(entityName); - var symbol = resolveName(enclosingDeclaration, firstIdentifier.text, meaning, /*nodeNotFoundErrorMessage*/ undefined, /*nameArg*/ undefined); - // Verify if the symbol is accessible - return (symbol && hasVisibleDeclarations(symbol)) || { - accessibility: 1 /* NotAccessible */, - errorSymbolName: ts.getTextOfNode(firstIdentifier), - errorNode: firstIdentifier - }; - } - function writeKeyword(writer, kind) { - writer.writeKeyword(ts.tokenToString(kind)); - } - function writePunctuation(writer, kind) { - writer.writePunctuation(ts.tokenToString(kind)); - } - function writeSpace(writer) { - writer.writeSpace(" "); - } - function symbolToString(symbol, enclosingDeclaration, meaning) { - var writer = ts.getSingleLineStringWriter(); - getSymbolDisplayBuilder().buildSymbolDisplay(symbol, writer, enclosingDeclaration, meaning); - var result = writer.string(); - ts.releaseStringWriter(writer); - return result; - } - function signatureToString(signature, enclosingDeclaration, flags) { - var writer = ts.getSingleLineStringWriter(); - getSymbolDisplayBuilder().buildSignatureDisplay(signature, writer, enclosingDeclaration, flags); - var result = writer.string(); - ts.releaseStringWriter(writer); - return result; - } - function typeToString(type, enclosingDeclaration, flags) { - var writer = ts.getSingleLineStringWriter(); - getSymbolDisplayBuilder().buildTypeDisplay(type, writer, enclosingDeclaration, flags); - var result = writer.string(); - ts.releaseStringWriter(writer); - var maxLength = compilerOptions.noErrorTruncation || flags & 4 /* NoTruncation */ ? undefined : 100; - if (maxLength && result.length >= maxLength) { - result = result.substr(0, maxLength - "...".length) + "..."; - } - return result; - } - function getTypeAliasForTypeLiteral(type) { - if (type.symbol && type.symbol.flags & 2048 /* TypeLiteral */) { - var node = type.symbol.declarations[0].parent; - while (node.kind === 160 /* ParenthesizedType */) { - node = node.parent; - } - if (node.kind === 216 /* TypeAliasDeclaration */) { - return getSymbolOfNode(node); - } - } - return undefined; - } - function getSymbolDisplayBuilder() { - function getNameOfSymbol(symbol) { - if (symbol.declarations && symbol.declarations.length) { - var declaration = symbol.declarations[0]; - if (declaration.name) { - return ts.declarationNameToString(declaration.name); - } - switch (declaration.kind) { - case 186 /* ClassExpression */: - return "(Anonymous class)"; - case 173 /* FunctionExpression */: - case 174 /* ArrowFunction */: - return "(Anonymous function)"; - } - } - return symbol.name; - } - /** - * Writes only the name of the symbol out to the writer. Uses the original source text - * for the name of the symbol if it is available to match how the user inputted the name. - */ - function appendSymbolNameOnly(symbol, writer) { - writer.writeSymbol(getNameOfSymbol(symbol), symbol); - } - /** - * Enclosing declaration is optional when we don't want to get qualified name in the enclosing declaration scope - * Meaning needs to be specified if the enclosing declaration is given - */ - function buildSymbolDisplay(symbol, writer, enclosingDeclaration, meaning, flags, typeFlags) { - var parentSymbol; - function appendParentTypeArgumentsAndSymbolName(symbol) { - if (parentSymbol) { - // Write type arguments of instantiated class/interface here - if (flags & 1 /* WriteTypeParametersOrArguments */) { - if (symbol.flags & 16777216 /* Instantiated */) { - buildDisplayForTypeArgumentsAndDelimiters(getTypeParametersOfClassOrInterface(parentSymbol), symbol.mapper, writer, enclosingDeclaration); - } - else { - buildTypeParameterDisplayFromSymbol(parentSymbol, writer, enclosingDeclaration); - } - } - writePunctuation(writer, 21 /* DotToken */); - } - parentSymbol = symbol; - appendSymbolNameOnly(symbol, writer); - } - // Let the writer know we just wrote out a symbol. The declaration emitter writer uses - // this to determine if an import it has previously seen (and not written out) needs - // to be written to the file once the walk of the tree is complete. - // - // NOTE(cyrusn): This approach feels somewhat unfortunate. A simple pass over the tree - // up front (for example, during checking) could determine if we need to emit the imports - // and we could then access that data during declaration emit. - writer.trackSymbol(symbol, enclosingDeclaration, meaning); - function walkSymbol(symbol, meaning) { - if (symbol) { - var accessibleSymbolChain = getAccessibleSymbolChain(symbol, enclosingDeclaration, meaning, !!(flags & 2 /* UseOnlyExternalAliasing */)); - if (!accessibleSymbolChain || - needsQualification(accessibleSymbolChain[0], enclosingDeclaration, accessibleSymbolChain.length === 1 ? meaning : getQualifiedLeftMeaning(meaning))) { - // Go up and add our parent. - walkSymbol(getParentOfSymbol(accessibleSymbolChain ? accessibleSymbolChain[0] : symbol), getQualifiedLeftMeaning(meaning)); - } - if (accessibleSymbolChain) { - for (var _i = 0; _i < accessibleSymbolChain.length; _i++) { - var accessibleSymbol = accessibleSymbolChain[_i]; - appendParentTypeArgumentsAndSymbolName(accessibleSymbol); - } - } - else { - // If we didn't find accessible symbol chain for this symbol, break if this is external module - if (!parentSymbol && ts.forEach(symbol.declarations, hasExternalModuleSymbol)) { - return; - } - // if this is anonymous type break - if (symbol.flags & 2048 /* TypeLiteral */ || symbol.flags & 4096 /* ObjectLiteral */) { - return; - } - appendParentTypeArgumentsAndSymbolName(symbol); - } - } - } - // Get qualified name if the symbol is not a type parameter - // and there is an enclosing declaration or we specifically - // asked for it - var isTypeParameter = symbol.flags & 262144 /* TypeParameter */; - var typeFormatFlag = 128 /* UseFullyQualifiedType */ & typeFlags; - if (!isTypeParameter && (enclosingDeclaration || typeFormatFlag)) { - walkSymbol(symbol, meaning); - return; - } - return appendParentTypeArgumentsAndSymbolName(symbol); - } - function buildTypeDisplay(type, writer, enclosingDeclaration, globalFlags, symbolStack) { - var globalFlagsToPass = globalFlags & 16 /* WriteOwnNameForAnyLike */; - var inObjectTypeLiteral = false; - return writeType(type, globalFlags); - function writeType(type, flags) { - // Write undefined/null type as any - if (type.flags & 16777343 /* Intrinsic */) { - // Special handling for unknown / resolving types, they should show up as any and not unknown or __resolving - writer.writeKeyword(!(globalFlags & 16 /* WriteOwnNameForAnyLike */) && isTypeAny(type) - ? "any" - : type.intrinsicName); - } - else if (type.flags & 33554432 /* ThisType */) { - if (inObjectTypeLiteral) { - writer.reportInaccessibleThisError(); - } - writer.writeKeyword("this"); - } - else if (type.flags & 4096 /* Reference */) { - writeTypeReference(type, flags); - } - else if (type.flags & (1024 /* Class */ | 2048 /* Interface */ | 128 /* Enum */ | 512 /* TypeParameter */)) { - // The specified symbol flags need to be reinterpreted as type flags - buildSymbolDisplay(type.symbol, writer, enclosingDeclaration, 793056 /* Type */, 0 /* None */, flags); - } - else if (type.flags & 8192 /* Tuple */) { - writeTupleType(type); - } - else if (type.flags & 49152 /* UnionOrIntersection */) { - writeUnionOrIntersectionType(type, flags); - } - else if (type.flags & 65536 /* Anonymous */) { - writeAnonymousType(type, flags); - } - else if (type.flags & 256 /* StringLiteral */) { - writer.writeStringLiteral(type.text); - } - else { - // Should never get here - // { ... } - writePunctuation(writer, 15 /* OpenBraceToken */); - writeSpace(writer); - writePunctuation(writer, 22 /* DotDotDotToken */); - writeSpace(writer); - writePunctuation(writer, 16 /* CloseBraceToken */); - } - } - function writeTypeList(types, delimiter) { - for (var i = 0; i < types.length; i++) { - if (i > 0) { - if (delimiter !== 24 /* CommaToken */) { - writeSpace(writer); - } - writePunctuation(writer, delimiter); - writeSpace(writer); - } - writeType(types[i], delimiter === 24 /* CommaToken */ ? 0 /* None */ : 64 /* InElementType */); - } - } - function writeSymbolTypeReference(symbol, typeArguments, pos, end, flags) { - // Unnamed function expressions and arrow functions have reserved names that we don't want to display - if (symbol.flags & 32 /* Class */ || !isReservedMemberName(symbol.name)) { - buildSymbolDisplay(symbol, writer, enclosingDeclaration, 793056 /* Type */, 0 /* None */, flags); - } - if (pos < end) { - writePunctuation(writer, 25 /* LessThanToken */); - writeType(typeArguments[pos++], 0 /* None */); - while (pos < end) { - writePunctuation(writer, 24 /* CommaToken */); - writeSpace(writer); - writeType(typeArguments[pos++], 0 /* None */); - } - writePunctuation(writer, 27 /* 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 */); - } - else { - // Write the type reference in the format f
.g.C where A and B are type arguments - // for outer type parameters, and f and g are the respective declaring containers of those - // type parameters. - var outerTypeParameters = type.target.outerTypeParameters; - var i = 0; - if (outerTypeParameters) { - var length_1 = outerTypeParameters.length; - while (i < length_1) { - // Find group of type arguments for type parameters with the same declaring container. - var start = i; - var parent_3 = getParentSymbolOfTypeParameter(outerTypeParameters[i]); - do { - i++; - } while (i < length_1 && getParentSymbolOfTypeParameter(outerTypeParameters[i]) === parent_3); - // When type parameters are their own type arguments for the whole group (i.e. we have - // the default outer type arguments), we don't show the group. - if (!ts.rangeEquals(outerTypeParameters, typeArguments, start, i)) { - writeSymbolTypeReference(parent_3, typeArguments, start, i, flags); - writePunctuation(writer, 21 /* DotToken */); - } - } - } - var typeParameterCount = (type.target.typeParameters || emptyArray).length; - writeSymbolTypeReference(type.symbol, typeArguments, i, typeParameterCount, flags); - } - } - function writeTupleType(type) { - writePunctuation(writer, 19 /* OpenBracketToken */); - writeTypeList(type.elementTypes, 24 /* CommaToken */); - writePunctuation(writer, 20 /* CloseBracketToken */); - } - function writeUnionOrIntersectionType(type, flags) { - if (flags & 64 /* InElementType */) { - writePunctuation(writer, 17 /* OpenParenToken */); - } - writeTypeList(type.types, type.flags & 16384 /* Union */ ? 47 /* BarToken */ : 46 /* AmpersandToken */); - if (flags & 64 /* InElementType */) { - writePunctuation(writer, 18 /* CloseParenToken */); - } - } - function writeAnonymousType(type, flags) { - var symbol = type.symbol; - if (symbol) { - // Always use 'typeof T' for type of class, enum, and module objects - if (symbol.flags & (32 /* Class */ | 384 /* Enum */ | 512 /* ValueModule */)) { - writeTypeofSymbol(type, flags); - } - else if (shouldWriteTypeOfFunctionSymbol()) { - writeTypeofSymbol(type, flags); - } - else if (ts.contains(symbolStack, symbol)) { - // If type is an anonymous type literal in a type alias declaration, use type alias name - var typeAlias = getTypeAliasForTypeLiteral(type); - if (typeAlias) { - // The specified symbol flags need to be reinterpreted as type flags - buildSymbolDisplay(typeAlias, writer, enclosingDeclaration, 793056 /* Type */, 0 /* None */, flags); - } - else { - // Recursive usage, use any - writeKeyword(writer, 117 /* AnyKeyword */); - } - } - else { - // Since instantiations of the same anonymous type have the same symbol, tracking symbols instead - // of types allows us to catch circular references to instantiations of the same anonymous type - if (!symbolStack) { - symbolStack = []; - } - symbolStack.push(symbol); - writeLiteralType(type, flags); - symbolStack.pop(); - } - } - else { - // Anonymous types with no symbol are never circular - writeLiteralType(type, flags); - } - function shouldWriteTypeOfFunctionSymbol() { - var isStaticMethodSymbol = !!(symbol.flags & 8192 /* Method */ && - ts.forEach(symbol.declarations, function (declaration) { return declaration.flags & 128 /* Static */; })); - var isNonLocalFunctionSymbol = !!(symbol.flags & 16 /* Function */) && - (symbol.parent || - ts.forEach(symbol.declarations, function (declaration) { - return declaration.parent.kind === 248 /* SourceFile */ || declaration.parent.kind === 219 /* ModuleBlock */; - })); - if (isStaticMethodSymbol || isNonLocalFunctionSymbol) { - // typeof is allowed only for static/non local functions - return !!(flags & 2 /* UseTypeOfFunction */) || - (ts.contains(symbolStack, symbol)); // it is type of the symbol uses itself recursively - } - } - } - function writeTypeofSymbol(type, typeFormatFlags) { - writeKeyword(writer, 101 /* TypeOfKeyword */); - writeSpace(writer); - buildSymbolDisplay(type.symbol, writer, enclosingDeclaration, 107455 /* Value */, 0 /* None */, typeFormatFlags); - } - function getIndexerParameterName(type, indexKind, fallbackName) { - var declaration = getIndexDeclarationOfSymbol(type.symbol, indexKind); - if (!declaration) { - // declaration might not be found if indexer was added from the contextual type. - // in this case use fallback name - return fallbackName; - } - ts.Debug.assert(declaration.parameters.length !== 0); - return ts.declarationNameToString(declaration.parameters[0].name); - } - function writeLiteralType(type, flags) { - var resolved = resolveStructuredTypeMembers(type); - if (!resolved.properties.length && !resolved.stringIndexType && !resolved.numberIndexType) { - if (!resolved.callSignatures.length && !resolved.constructSignatures.length) { - writePunctuation(writer, 15 /* OpenBraceToken */); - writePunctuation(writer, 16 /* CloseBraceToken */); - return; - } - if (resolved.callSignatures.length === 1 && !resolved.constructSignatures.length) { - if (flags & 64 /* InElementType */) { - writePunctuation(writer, 17 /* OpenParenToken */); - } - buildSignatureDisplay(resolved.callSignatures[0], writer, enclosingDeclaration, globalFlagsToPass | 8 /* WriteArrowStyleSignature */, symbolStack); - if (flags & 64 /* InElementType */) { - writePunctuation(writer, 18 /* CloseParenToken */); - } - return; - } - if (resolved.constructSignatures.length === 1 && !resolved.callSignatures.length) { - if (flags & 64 /* InElementType */) { - writePunctuation(writer, 17 /* OpenParenToken */); - } - writeKeyword(writer, 92 /* NewKeyword */); - writeSpace(writer); - buildSignatureDisplay(resolved.constructSignatures[0], writer, enclosingDeclaration, globalFlagsToPass | 8 /* WriteArrowStyleSignature */, symbolStack); - if (flags & 64 /* InElementType */) { - writePunctuation(writer, 18 /* CloseParenToken */); - } - return; - } - } - var saveInObjectTypeLiteral = inObjectTypeLiteral; - inObjectTypeLiteral = true; - writePunctuation(writer, 15 /* 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, symbolStack); - writePunctuation(writer, 23 /* SemicolonToken */); - writer.writeLine(); - } - for (var _b = 0, _c = resolved.constructSignatures; _b < _c.length; _b++) { - var signature = _c[_b]; - writeKeyword(writer, 92 /* NewKeyword */); - writeSpace(writer); - buildSignatureDisplay(signature, writer, enclosingDeclaration, globalFlagsToPass, symbolStack); - writePunctuation(writer, 23 /* SemicolonToken */); - writer.writeLine(); - } - if (resolved.stringIndexType) { - // [x: string]: - writePunctuation(writer, 19 /* OpenBracketToken */); - writer.writeParameter(getIndexerParameterName(resolved, 0 /* String */, /*fallbackName*/ "x")); - writePunctuation(writer, 54 /* ColonToken */); - writeSpace(writer); - writeKeyword(writer, 130 /* StringKeyword */); - writePunctuation(writer, 20 /* CloseBracketToken */); - writePunctuation(writer, 54 /* ColonToken */); - writeSpace(writer); - writeType(resolved.stringIndexType, 0 /* None */); - writePunctuation(writer, 23 /* SemicolonToken */); - writer.writeLine(); - } - if (resolved.numberIndexType) { - // [x: number]: - writePunctuation(writer, 19 /* OpenBracketToken */); - writer.writeParameter(getIndexerParameterName(resolved, 1 /* Number */, /*fallbackName*/ "x")); - writePunctuation(writer, 54 /* ColonToken */); - writeSpace(writer); - writeKeyword(writer, 128 /* NumberKeyword */); - writePunctuation(writer, 20 /* CloseBracketToken */); - writePunctuation(writer, 54 /* ColonToken */); - writeSpace(writer); - writeType(resolved.numberIndexType, 0 /* None */); - writePunctuation(writer, 23 /* SemicolonToken */); - writer.writeLine(); - } - for (var _d = 0, _e = resolved.properties; _d < _e.length; _d++) { - var p = _e[_d]; - var t = getTypeOfSymbol(p); - if (p.flags & (16 /* Function */ | 8192 /* Method */) && !getPropertiesOfObjectType(t).length) { - var signatures = getSignaturesOfType(t, 0 /* Call */); - for (var _f = 0; _f < signatures.length; _f++) { - var signature = signatures[_f]; - buildSymbolDisplay(p, writer); - if (p.flags & 536870912 /* Optional */) { - writePunctuation(writer, 53 /* QuestionToken */); - } - buildSignatureDisplay(signature, writer, enclosingDeclaration, globalFlagsToPass, symbolStack); - writePunctuation(writer, 23 /* SemicolonToken */); - writer.writeLine(); - } - } - else { - buildSymbolDisplay(p, writer); - if (p.flags & 536870912 /* Optional */) { - writePunctuation(writer, 53 /* QuestionToken */); - } - writePunctuation(writer, 54 /* ColonToken */); - writeSpace(writer); - writeType(t, 0 /* None */); - writePunctuation(writer, 23 /* SemicolonToken */); - writer.writeLine(); - } - } - writer.decreaseIndent(); - writePunctuation(writer, 16 /* CloseBraceToken */); - inObjectTypeLiteral = saveInObjectTypeLiteral; - } - } - function buildTypeParameterDisplayFromSymbol(symbol, writer, enclosingDeclaraiton, flags) { - var targetSymbol = getTargetSymbol(symbol); - if (targetSymbol.flags & 32 /* Class */ || targetSymbol.flags & 64 /* Interface */ || targetSymbol.flags & 524288 /* TypeAlias */) { - buildDisplayForTypeParametersAndDelimiters(getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol), writer, enclosingDeclaraiton, flags); - } - } - function buildTypeParameterDisplay(tp, writer, enclosingDeclaration, flags, symbolStack) { - appendSymbolNameOnly(tp.symbol, writer); - var constraint = getConstraintOfTypeParameter(tp); - if (constraint) { - writeSpace(writer); - writeKeyword(writer, 83 /* ExtendsKeyword */); - writeSpace(writer); - buildTypeDisplay(constraint, writer, enclosingDeclaration, flags, symbolStack); - } - } - function buildParameterDisplay(p, writer, enclosingDeclaration, flags, symbolStack) { - var parameterNode = p.valueDeclaration; - if (ts.isRestParameter(parameterNode)) { - writePunctuation(writer, 22 /* DotDotDotToken */); - } - appendSymbolNameOnly(p, writer); - if (isOptionalParameter(parameterNode)) { - writePunctuation(writer, 53 /* QuestionToken */); - } - writePunctuation(writer, 54 /* ColonToken */); - writeSpace(writer); - buildTypeDisplay(getTypeOfSymbol(p), writer, enclosingDeclaration, flags, symbolStack); - } - function buildDisplayForTypeParametersAndDelimiters(typeParameters, writer, enclosingDeclaration, flags, symbolStack) { - if (typeParameters && typeParameters.length) { - writePunctuation(writer, 25 /* LessThanToken */); - for (var i = 0; i < typeParameters.length; i++) { - if (i > 0) { - writePunctuation(writer, 24 /* CommaToken */); - writeSpace(writer); - } - buildTypeParameterDisplay(typeParameters[i], writer, enclosingDeclaration, flags, symbolStack); - } - writePunctuation(writer, 27 /* GreaterThanToken */); - } - } - function buildDisplayForTypeArgumentsAndDelimiters(typeParameters, mapper, writer, enclosingDeclaration, flags, symbolStack) { - if (typeParameters && typeParameters.length) { - writePunctuation(writer, 25 /* LessThanToken */); - for (var i = 0; i < typeParameters.length; i++) { - if (i > 0) { - writePunctuation(writer, 24 /* CommaToken */); - writeSpace(writer); - } - buildTypeDisplay(mapper(typeParameters[i]), writer, enclosingDeclaration, 0 /* None */); - } - writePunctuation(writer, 27 /* GreaterThanToken */); - } - } - function buildDisplayForParametersAndDelimiters(parameters, writer, enclosingDeclaration, flags, symbolStack) { - writePunctuation(writer, 17 /* OpenParenToken */); - for (var i = 0; i < parameters.length; i++) { - if (i > 0) { - writePunctuation(writer, 24 /* CommaToken */); - writeSpace(writer); - } - buildParameterDisplay(parameters[i], writer, enclosingDeclaration, flags, symbolStack); - } - writePunctuation(writer, 18 /* CloseParenToken */); - } - function buildReturnTypeDisplay(signature, writer, enclosingDeclaration, flags, symbolStack) { - if (flags & 8 /* WriteArrowStyleSignature */) { - writeSpace(writer); - writePunctuation(writer, 34 /* EqualsGreaterThanToken */); - } - else { - writePunctuation(writer, 54 /* ColonToken */); - } - writeSpace(writer); - var returnType; - if (signature.typePredicate) { - writer.writeParameter(signature.typePredicate.parameterName); - writeSpace(writer); - writeKeyword(writer, 124 /* IsKeyword */); - writeSpace(writer); - returnType = signature.typePredicate.type; - } - else { - returnType = getReturnTypeOfSignature(signature); - } - buildTypeDisplay(returnType, writer, enclosingDeclaration, flags, symbolStack); - } - function buildSignatureDisplay(signature, writer, enclosingDeclaration, flags, symbolStack) { - if (signature.target && (flags & 32 /* WriteTypeArgumentsOfSignature */)) { - // Instantiated signature, write type arguments instead - // This is achieved by passing in the mapper separately - buildDisplayForTypeArgumentsAndDelimiters(signature.target.typeParameters, signature.mapper, writer, enclosingDeclaration); - } - else { - buildDisplayForTypeParametersAndDelimiters(signature.typeParameters, writer, enclosingDeclaration, flags, symbolStack); - } - buildDisplayForParametersAndDelimiters(signature.parameters, writer, enclosingDeclaration, flags, symbolStack); - buildReturnTypeDisplay(signature, writer, enclosingDeclaration, flags, symbolStack); - } - return _displayBuilder || (_displayBuilder = { - buildSymbolDisplay: buildSymbolDisplay, - buildTypeDisplay: buildTypeDisplay, - buildTypeParameterDisplay: buildTypeParameterDisplay, - buildParameterDisplay: buildParameterDisplay, - buildDisplayForParametersAndDelimiters: buildDisplayForParametersAndDelimiters, - buildDisplayForTypeParametersAndDelimiters: buildDisplayForTypeParametersAndDelimiters, - buildTypeParameterDisplayFromSymbol: buildTypeParameterDisplayFromSymbol, - buildSignatureDisplay: buildSignatureDisplay, - buildReturnTypeDisplay: buildReturnTypeDisplay - }); - } - function isDeclarationVisible(node) { - function getContainingExternalModule(node) { - for (; node; node = node.parent) { - if (node.kind === 218 /* ModuleDeclaration */) { - if (node.name.kind === 9 /* StringLiteral */) { - return node; - } - } - else if (node.kind === 248 /* SourceFile */) { - return ts.isExternalModule(node) ? node : undefined; - } - } - ts.Debug.fail("getContainingModule cant reach here"); - } - function isUsedInExportAssignment(node) { - // Get source File and see if it is external module and has export assigned symbol - var externalModule = getContainingExternalModule(node); - var exportAssignmentSymbol; - var resolvedExportSymbol; - if (externalModule) { - // This is export assigned symbol node - var externalModuleSymbol = getSymbolOfNode(externalModule); - exportAssignmentSymbol = getExportAssignmentSymbol(externalModuleSymbol); - var symbolOfNode = getSymbolOfNode(node); - if (isSymbolUsedInExportAssignment(symbolOfNode)) { - return true; - } - // if symbolOfNode is alias declaration, resolve the symbol declaration and check - if (symbolOfNode.flags & 8388608 /* Alias */) { - return isSymbolUsedInExportAssignment(resolveAlias(symbolOfNode)); - } - } - // Check if the symbol is used in export assignment - function isSymbolUsedInExportAssignment(symbol) { - if (exportAssignmentSymbol === symbol) { - return true; - } - if (exportAssignmentSymbol && !!(exportAssignmentSymbol.flags & 8388608 /* Alias */)) { - // if export assigned symbol is alias declaration, resolve the alias - resolvedExportSymbol = resolvedExportSymbol || resolveAlias(exportAssignmentSymbol); - if (resolvedExportSymbol === symbol) { - return true; - } - // Container of resolvedExportSymbol is visible - return ts.forEach(resolvedExportSymbol.declarations, function (current) { - while (current) { - if (current === node) { - return true; - } - current = current.parent; - } - }); - } - } - } - function determineIfDeclarationIsVisible() { - switch (node.kind) { - case 163 /* BindingElement */: - return isDeclarationVisible(node.parent.parent); - case 211 /* VariableDeclaration */: - if (ts.isBindingPattern(node.name) && - !node.name.elements.length) { - // If the binding pattern is empty, this variable declaration is not visible - return false; - } - // Otherwise fall through - case 218 /* ModuleDeclaration */: - case 214 /* ClassDeclaration */: - case 215 /* InterfaceDeclaration */: - case 216 /* TypeAliasDeclaration */: - case 213 /* FunctionDeclaration */: - case 217 /* EnumDeclaration */: - case 221 /* ImportEqualsDeclaration */: - var parent_4 = getDeclarationContainer(node); - // If the node is not exported or it is not ambient module element (except import declaration) - if (!(ts.getCombinedNodeFlags(node) & 1 /* Export */) && - !(node.kind !== 221 /* ImportEqualsDeclaration */ && parent_4.kind !== 248 /* SourceFile */ && ts.isInAmbientContext(parent_4))) { - return isGlobalSourceFile(parent_4); - } - // Exported members/ambient module elements (exception import declaration) are visible if parent is visible - return isDeclarationVisible(parent_4); - case 141 /* PropertyDeclaration */: - case 140 /* PropertySignature */: - case 145 /* GetAccessor */: - case 146 /* SetAccessor */: - case 143 /* MethodDeclaration */: - case 142 /* MethodSignature */: - if (node.flags & (32 /* Private */ | 64 /* Protected */)) { - // Private/protected properties/methods are not visible - return false; - } - // Public properties/methods are visible if its parents are visible, so let it fall into next case statement - case 144 /* Constructor */: - case 148 /* ConstructSignature */: - case 147 /* CallSignature */: - case 149 /* IndexSignature */: - case 138 /* Parameter */: - case 219 /* ModuleBlock */: - case 152 /* FunctionType */: - case 153 /* ConstructorType */: - case 155 /* TypeLiteral */: - case 151 /* TypeReference */: - case 156 /* ArrayType */: - case 157 /* TupleType */: - case 158 /* UnionType */: - case 159 /* IntersectionType */: - case 160 /* ParenthesizedType */: - return isDeclarationVisible(node.parent); - // Default binding, import specifier and namespace import is visible - // only on demand so by default it is not visible - case 223 /* ImportClause */: - case 224 /* NamespaceImport */: - case 226 /* ImportSpecifier */: - return false; - // Type parameters are always visible - case 137 /* TypeParameter */: - // Source file is always visible - case 248 /* SourceFile */: - return true; - // Export assignements do not create name bindings outside the module - case 227 /* ExportAssignment */: - return false; - default: - ts.Debug.fail("isDeclarationVisible unknown: SyntaxKind: " + node.kind); - } - } - if (node) { - var links = getNodeLinks(node); - if (links.isVisible === undefined) { - links.isVisible = !!determineIfDeclarationIsVisible(); - } - return links.isVisible; - } - } - function collectLinkedAliases(node) { - var exportSymbol; - if (node.parent && node.parent.kind === 227 /* ExportAssignment */) { - exportSymbol = resolveName(node.parent, node.text, 107455 /* Value */ | 793056 /* Type */ | 1536 /* Namespace */ | 8388608 /* Alias */, ts.Diagnostics.Cannot_find_name_0, node); - } - else if (node.parent.kind === 230 /* ExportSpecifier */) { - var exportSpecifier = node.parent; - exportSymbol = exportSpecifier.parent.parent.moduleSpecifier ? - getExternalModuleMember(exportSpecifier.parent.parent, exportSpecifier) : - resolveEntityName(exportSpecifier.propertyName || exportSpecifier.name, 107455 /* Value */ | 793056 /* Type */ | 1536 /* Namespace */ | 8388608 /* Alias */); - } - var result = []; - if (exportSymbol) { - buildVisibleNodeList(exportSymbol.declarations); - } - return result; - function buildVisibleNodeList(declarations) { - ts.forEach(declarations, function (declaration) { - getNodeLinks(declaration).isVisible = true; - var resultNode = getAnyImportSyntax(declaration) || declaration; - if (!ts.contains(result, resultNode)) { - result.push(resultNode); - } - if (ts.isInternalModuleImportEqualsDeclaration(declaration)) { - // Add the referenced top container visible - var internalModuleReference = declaration.moduleReference; - var firstIdentifier = getFirstIdentifier(internalModuleReference); - var importSymbol = resolveName(declaration, firstIdentifier.text, 107455 /* Value */ | 793056 /* Type */ | 1536 /* Namespace */, ts.Diagnostics.Cannot_find_name_0, firstIdentifier); - buildVisibleNodeList(importSymbol.declarations); - } - }); - } - } - /** - * Push an entry on the type resolution stack. If an entry with the given target and the given property name - * is already on the stack, and no entries in between already have a type, then a circularity has occurred. - * In this case, the result values of the existing entry and all entries pushed after it are changed to false, - * and the value false is returned. Otherwise, the new entry is just pushed onto the stack, and true is returned. - * In order to see if the same query has already been done before, the target object and the propertyName both - * must match the one passed in. - * - * @param target The symbol, type, or signature whose type is being queried - * @param propertyName The property name that should be used to query the target for its type - */ - function pushTypeResolution(target, propertyName) { - var resolutionCycleStartIndex = findResolutionCycleStartIndex(target, propertyName); - if (resolutionCycleStartIndex >= 0) { - // A cycle was found - var length_2 = resolutionTargets.length; - for (var i = resolutionCycleStartIndex; i < length_2; i++) { - resolutionResults[i] = false; - } - return false; - } - resolutionTargets.push(target); - resolutionResults.push(true); - resolutionPropertyNames.push(propertyName); - return true; - } - function findResolutionCycleStartIndex(target, propertyName) { - for (var i = resolutionTargets.length - 1; i >= 0; i--) { - if (hasType(resolutionTargets[i], resolutionPropertyNames[i])) { - return -1; - } - if (resolutionTargets[i] === target && resolutionPropertyNames[i] === propertyName) { - return i; - } - } - return -1; - } - function hasType(target, propertyName) { - if (propertyName === 0 /* Type */) { - return getSymbolLinks(target).type; - } - if (propertyName === 2 /* DeclaredType */) { - return getSymbolLinks(target).declaredType; - } - if (propertyName === 1 /* ResolvedBaseConstructorType */) { - ts.Debug.assert(!!(target.flags & 1024 /* Class */)); - return target.resolvedBaseConstructorType; - } - if (propertyName === 3 /* ResolvedReturnType */) { - return target.resolvedReturnType; - } - ts.Debug.fail("Unhandled TypeSystemPropertyName " + propertyName); - } - // Pop an entry from the type resolution stack and return its associated result value. The result value will - // be true if no circularities were detected, or false if a circularity was found. - function popTypeResolution() { - resolutionTargets.pop(); - resolutionPropertyNames.pop(); - return resolutionResults.pop(); - } - function getDeclarationContainer(node) { - node = ts.getRootDeclaration(node); - // Parent chain: - // VaribleDeclaration -> VariableDeclarationList -> VariableStatement -> 'Declaration Container' - return node.kind === 211 /* VariableDeclaration */ ? node.parent.parent.parent : node.parent; - } - function getTypeOfPrototypeProperty(prototype) { - // 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'. - var classType = getDeclaredTypeOfSymbol(prototype.parent); - return classType.typeParameters ? createTypeReference(classType, ts.map(classType.typeParameters, function (_) { return anyType; })) : classType; - } - // Return the type of the given property in the given type, or undefined if no such property exists - function getTypeOfPropertyOfType(type, name) { - var prop = getPropertyOfType(type, name); - return prop ? getTypeOfSymbol(prop) : undefined; - } - function isTypeAny(type) { - return type && (type.flags & 1 /* Any */) !== 0; - } - // Return the type of a binding element parent. We check SymbolLinks first to see if a type has been - // assigned by contextual typing. - function getTypeForBindingElementParent(node) { - var symbol = getSymbolOfNode(node); - return symbol && getSymbolLinks(symbol).type || getTypeForVariableLikeDeclaration(node); - } - // Return the inferred type for a binding element - function getTypeForBindingElement(declaration) { - var pattern = declaration.parent; - var parentType = getTypeForBindingElementParent(pattern.parent); - // If parent has the unknown (error) type, then so does this binding element - if (parentType === unknownType) { - return unknownType; - } - // If no type was specified or inferred for parent, or if the specified or inferred type is any, - // infer from the initializer of the binding element if one is present. Otherwise, go with the - // undefined or any type of the parent. - if (!parentType || isTypeAny(parentType)) { - if (declaration.initializer) { - return checkExpressionCached(declaration.initializer); - } - return parentType; - } - var type; - if (pattern.kind === 161 /* ObjectBindingPattern */) { - // Use explicitly specified property name ({ p: xxx } form), or otherwise the implied name ({ p } form) - var name_10 = declaration.propertyName || declaration.name; - // Use type of the specified property, or otherwise, for a numeric name, the type of the numeric index signature, - // or otherwise the type of the string index signature. - type = getTypeOfPropertyOfType(parentType, name_10.text) || - isNumericLiteralName(name_10.text) && getIndexTypeOfType(parentType, 1 /* Number */) || - getIndexTypeOfType(parentType, 0 /* String */); - if (!type) { - error(name_10, ts.Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(parentType), ts.declarationNameToString(name_10)); - return unknownType; - } - } - else { - // This elementType will be used if the specific property corresponding to this index is not - // present (aka the tuple element property). This call also checks that the parentType is in - // fact an iterable or array (depending on target language). - var elementType = checkIteratedTypeOrElementType(parentType, pattern, /*allowStringInput*/ false); - if (!declaration.dotDotDotToken) { - // Use specific property type when parent is a tuple or numeric index type when parent is an array - var propName = "" + ts.indexOf(pattern.elements, declaration); - type = isTupleLikeType(parentType) - ? getTypeOfPropertyOfType(parentType, propName) - : elementType; - if (!type) { - if (isTupleType(parentType)) { - error(declaration, ts.Diagnostics.Tuple_type_0_with_length_1_cannot_be_assigned_to_tuple_with_length_2, typeToString(parentType), parentType.elementTypes.length, pattern.elements.length); - } - else { - error(declaration, ts.Diagnostics.Type_0_has_no_property_1, typeToString(parentType), propName); - } - return unknownType; - } - } - else { - // Rest element has an array type with the same element type as the parent type - type = createArrayType(elementType); - } - } - return type; - } - // Return the inferred type for a variable, parameter, or property declaration - function getTypeForVariableLikeDeclaration(declaration) { - // A variable declared in a for..in statement is always of type any - if (declaration.parent.parent.kind === 200 /* ForInStatement */) { - return anyType; - } - if (declaration.parent.parent.kind === 201 /* ForOfStatement */) { - // checkRightHandSideOfForOf will return undefined if the for-of expression type was - // missing properties/signatures required to get its iteratedType (like - // [Symbol.iterator] or next). This may be because we accessed properties from anyType, - // or it may have led to an error inside getElementTypeOfIterable. - return checkRightHandSideOfForOf(declaration.parent.parent.expression) || anyType; - } - if (ts.isBindingPattern(declaration.parent)) { - return getTypeForBindingElement(declaration); - } - // Use type from type annotation if one is present - if (declaration.type) { - return getTypeFromTypeNode(declaration.type); - } - if (declaration.kind === 138 /* Parameter */) { - var func = declaration.parent; - // For a parameter of a set accessor, use the type of the get accessor if one is present - if (func.kind === 146 /* SetAccessor */ && !ts.hasDynamicName(func)) { - var getter = ts.getDeclarationOfKind(declaration.parent.symbol, 145 /* GetAccessor */); - if (getter) { - return getReturnTypeOfSignature(getSignatureFromDeclaration(getter)); - } - } - // Use contextual parameter type if one is available - var type = getContextuallyTypedParameterType(declaration); - if (type) { - return type; - } - } - // Use the type of the initializer expression if one is present - if (declaration.initializer) { - return checkExpressionCached(declaration.initializer); - } - // If it is a short-hand property assignment, use the type of the identifier - if (declaration.kind === 246 /* ShorthandPropertyAssignment */) { - return checkIdentifier(declaration.name); - } - // If the declaration specifies a binding pattern, use the type implied by the binding pattern - if (ts.isBindingPattern(declaration.name)) { - return getTypeFromBindingPattern(declaration.name, /*includePatternInType*/ false); - } - // No type specified and nothing can be inferred - return undefined; - } - // Return the type implied by a binding pattern element. This is the type of the initializer of the element if - // one is present. Otherwise, if the element is itself a binding pattern, it is the type implied by the binding - // pattern. Otherwise, it is the type any. - function getTypeFromBindingElement(element, includePatternInType) { - if (element.initializer) { - return getWidenedType(checkExpressionCached(element.initializer)); - } - if (ts.isBindingPattern(element.name)) { - return getTypeFromBindingPattern(element.name, includePatternInType); - } - return anyType; - } - // Return the type implied by an object binding pattern - function getTypeFromObjectBindingPattern(pattern, includePatternInType) { - var members = {}; - ts.forEach(pattern.elements, function (e) { - var flags = 4 /* Property */ | 67108864 /* Transient */ | (e.initializer ? 536870912 /* Optional */ : 0); - var name = e.propertyName || e.name; - var symbol = createSymbol(flags, name.text); - symbol.type = getTypeFromBindingElement(e, includePatternInType); - symbol.bindingElement = e; - members[symbol.name] = symbol; - }); - var result = createAnonymousType(undefined, members, emptyArray, emptyArray, undefined, undefined); - if (includePatternInType) { - result.pattern = pattern; - } - return result; - } - // Return the type implied by an array binding pattern - function getTypeFromArrayBindingPattern(pattern, includePatternInType) { - var elements = pattern.elements; - if (elements.length === 0 || elements[elements.length - 1].dotDotDotToken) { - return languageVersion >= 2 /* ES6 */ ? createIterableType(anyType) : anyArrayType; - } - // If the pattern has at least one element, and no rest element, then it should imply a tuple type. - var elementTypes = ts.map(elements, function (e) { return e.kind === 187 /* OmittedExpression */ ? anyType : getTypeFromBindingElement(e, includePatternInType); }); - if (includePatternInType) { - var result = createNewTupleType(elementTypes); - result.pattern = pattern; - return result; - } - return createTupleType(elementTypes); - } - // Return the type implied by a binding pattern. This is the type implied purely by the binding pattern itself - // and without regard to its context (i.e. without regard any type annotation or initializer associated with the - // declaration in which the binding pattern is contained). For example, the implied type of [x, y] is [any, any] - // and the implied type of { x, y: z = 1 } is { x: any; y: number; }. The type implied by a binding pattern is - // used as the contextual type of an initializer associated with the binding pattern. Also, for a destructuring - // parameter with no type annotation or initializer, the type implied by the binding pattern becomes the type of - // the parameter. - function getTypeFromBindingPattern(pattern, includePatternInType) { - return pattern.kind === 161 /* ObjectBindingPattern */ - ? getTypeFromObjectBindingPattern(pattern, includePatternInType) - : getTypeFromArrayBindingPattern(pattern, includePatternInType); - } - // Return the type associated with a variable, parameter, or property declaration. In the simple case this is the type - // specified in a type annotation or inferred from an initializer. However, in the case of a destructuring declaration it - // is a bit more involved. For example: - // - // var [x, s = ""] = [1, "one"]; - // - // Here, the array literal [1, "one"] is contextually typed by the type [any, string], which is the implied type of the - // binding pattern [x, s = ""]. Because the contextual type is a tuple type, the resulting type of [1, "one"] is the - // tuple type [number, string]. Thus, the type inferred for 'x' is number and the type inferred for 's' is string. - function getWidenedTypeForVariableLikeDeclaration(declaration, reportErrors) { - var type = getTypeForVariableLikeDeclaration(declaration); - if (type) { - if (reportErrors) { - reportErrorsFromWidening(declaration, type); - } - // During a normal type check we'll never get to here with a property assignment (the check of the containing - // object literal uses a different path). We exclude widening only so that language services and type verification - // tools see the actual type. - return declaration.kind !== 245 /* PropertyAssignment */ ? getWidenedType(type) : type; - } - // Rest parameters default to type any[], other parameters default to type any - type = declaration.dotDotDotToken ? anyArrayType : anyType; - // Report implicit any errors unless this is a private property within an ambient declaration - if (reportErrors && compilerOptions.noImplicitAny) { - var root = ts.getRootDeclaration(declaration); - if (!isPrivateWithinAmbient(root) && !(root.kind === 138 /* Parameter */ && isPrivateWithinAmbient(root.parent))) { - reportImplicitAnyError(declaration, type); - } - } - return type; - } - function getTypeOfVariableOrParameterOrProperty(symbol) { - var links = getSymbolLinks(symbol); - if (!links.type) { - // Handle prototype property - if (symbol.flags & 134217728 /* Prototype */) { - return links.type = getTypeOfPrototypeProperty(symbol); - } - // Handle catch clause variables - var declaration = symbol.valueDeclaration; - if (declaration.parent.kind === 244 /* CatchClause */) { - return links.type = anyType; - } - // Handle export default expressions - if (declaration.kind === 227 /* ExportAssignment */) { - return links.type = checkExpression(declaration.expression); - } - // Handle variable, parameter or property - if (!pushTypeResolution(symbol, 0 /* Type */)) { - return unknownType; - } - var type = getWidenedTypeForVariableLikeDeclaration(declaration, /*reportErrors*/ true); - if (!popTypeResolution()) { - if (symbol.valueDeclaration.type) { - // Variable has type annotation that circularly references the variable itself - type = unknownType; - error(symbol.valueDeclaration, ts.Diagnostics._0_is_referenced_directly_or_indirectly_in_its_own_type_annotation, symbolToString(symbol)); - } - else { - // Variable has initializer that circularly references the variable itself - type = anyType; - if (compilerOptions.noImplicitAny) { - error(symbol.valueDeclaration, ts.Diagnostics._0_implicitly_has_type_any_because_it_does_not_have_a_type_annotation_and_is_referenced_directly_or_indirectly_in_its_own_initializer, symbolToString(symbol)); - } - } - } - links.type = type; - } - return links.type; - } - function getAnnotatedAccessorType(accessor) { - if (accessor) { - if (accessor.kind === 145 /* GetAccessor */) { - return accessor.type && getTypeFromTypeNode(accessor.type); - } - else { - var setterTypeAnnotation = ts.getSetAccessorTypeAnnotationNode(accessor); - return setterTypeAnnotation && getTypeFromTypeNode(setterTypeAnnotation); - } - } - return undefined; - } - function getTypeOfAccessors(symbol) { - var links = getSymbolLinks(symbol); - if (!links.type) { - if (!pushTypeResolution(symbol, 0 /* Type */)) { - return unknownType; - } - var getter = ts.getDeclarationOfKind(symbol, 145 /* GetAccessor */); - var setter = ts.getDeclarationOfKind(symbol, 146 /* SetAccessor */); - var type; - // First try to see if the user specified a return type on the get-accessor. - var getterReturnType = getAnnotatedAccessorType(getter); - if (getterReturnType) { - type = getterReturnType; - } - else { - // If the user didn't specify a return type, try to use the set-accessor's parameter type. - var setterParameterType = getAnnotatedAccessorType(setter); - if (setterParameterType) { - type = setterParameterType; - } - else { - // If there are no specified types, try to infer it from the body of the get accessor if it exists. - if (getter && getter.body) { - type = getReturnTypeFromBody(getter); - } - else { - if (compilerOptions.noImplicitAny) { - error(setter, ts.Diagnostics.Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_type_annotation, symbolToString(symbol)); - } - type = anyType; - } - } - } - if (!popTypeResolution()) { - type = anyType; - if (compilerOptions.noImplicitAny) { - var getter_1 = ts.getDeclarationOfKind(symbol, 145 /* GetAccessor */); - error(getter_1, ts.Diagnostics._0_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions, symbolToString(symbol)); - } - } - links.type = type; - } - return links.type; - } - function getTypeOfFuncClassEnumModule(symbol) { - var links = getSymbolLinks(symbol); - if (!links.type) { - links.type = createObjectType(65536 /* Anonymous */, symbol); - } - return links.type; - } - function getTypeOfEnumMember(symbol) { - var links = getSymbolLinks(symbol); - if (!links.type) { - links.type = getDeclaredTypeOfEnum(getParentOfSymbol(symbol)); - } - return links.type; - } - function getTypeOfAlias(symbol) { - var links = getSymbolLinks(symbol); - if (!links.type) { - var targetSymbol = resolveAlias(symbol); - // It only makes sense to get the type of a value symbol. If the result of resolving - // the alias is not a value, then it has no type. To get the type associated with a - // type symbol, call getDeclaredTypeOfSymbol. - // This check is important because without it, a call to getTypeOfSymbol could end - // up recursively calling getTypeOfAlias, causing a stack overflow. - links.type = targetSymbol.flags & 107455 /* Value */ - ? getTypeOfSymbol(targetSymbol) - : unknownType; - } - return links.type; - } - function getTypeOfInstantiatedSymbol(symbol) { - var links = getSymbolLinks(symbol); - if (!links.type) { - links.type = instantiateType(getTypeOfSymbol(links.target), links.mapper); - } - return links.type; - } - function getTypeOfSymbol(symbol) { - if (symbol.flags & 16777216 /* Instantiated */) { - return getTypeOfInstantiatedSymbol(symbol); - } - if (symbol.flags & (3 /* Variable */ | 4 /* Property */)) { - return getTypeOfVariableOrParameterOrProperty(symbol); - } - if (symbol.flags & (16 /* Function */ | 8192 /* Method */ | 32 /* Class */ | 384 /* Enum */ | 512 /* ValueModule */)) { - return getTypeOfFuncClassEnumModule(symbol); - } - if (symbol.flags & 8 /* EnumMember */) { - return getTypeOfEnumMember(symbol); - } - if (symbol.flags & 98304 /* Accessor */) { - return getTypeOfAccessors(symbol); - } - if (symbol.flags & 8388608 /* Alias */) { - return getTypeOfAlias(symbol); - } - return unknownType; - } - function getTargetType(type) { - return type.flags & 4096 /* Reference */ ? type.target : type; - } - function hasBaseType(type, checkBase) { - return check(type); - function check(type) { - var target = getTargetType(type); - return target === checkBase || ts.forEach(getBaseTypes(target), check); - } - } - // Appends the type parameters given by a list of declarations to a set of type parameters and returns the resulting set. - // The function allocates a new array if the input type parameter set is undefined, but otherwise it modifies the set - // in-place and returns the same array. - function appendTypeParameters(typeParameters, declarations) { - for (var _i = 0; _i < declarations.length; _i++) { - var declaration = declarations[_i]; - var tp = getDeclaredTypeOfTypeParameter(getSymbolOfNode(declaration)); - if (!typeParameters) { - typeParameters = [tp]; - } - else if (!ts.contains(typeParameters, tp)) { - typeParameters.push(tp); - } - } - return typeParameters; - } - // Appends the outer type parameters of a node to a set of type parameters and returns the resulting set. The function - // allocates a new array if the input type parameter set is undefined, but otherwise it modifies the set in-place and - // returns the same array. - function appendOuterTypeParameters(typeParameters, node) { - while (true) { - node = node.parent; - if (!node) { - return typeParameters; - } - if (node.kind === 214 /* ClassDeclaration */ || node.kind === 186 /* ClassExpression */ || - node.kind === 213 /* FunctionDeclaration */ || node.kind === 173 /* FunctionExpression */ || - node.kind === 143 /* MethodDeclaration */ || node.kind === 174 /* ArrowFunction */) { - var declarations = node.typeParameters; - if (declarations) { - return appendTypeParameters(appendOuterTypeParameters(typeParameters, node), declarations); - } - } - } - } - // 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, 215 /* InterfaceDeclaration */); - return appendOuterTypeParameters(undefined, declaration); - } - // The local type parameters are the combined set of type parameters from all declarations of the class, - // interface, or type alias. - function getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol) { - var result; - for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { - var node = _a[_i]; - if (node.kind === 215 /* InterfaceDeclaration */ || node.kind === 214 /* ClassDeclaration */ || - node.kind === 186 /* ClassExpression */ || node.kind === 216 /* TypeAliasDeclaration */) { - var declaration = node; - if (declaration.typeParameters) { - result = appendTypeParameters(result, declaration.typeParameters); - } - } - } - return result; - } - // The full set of type parameters for a generic class or interface type consists of its outer type parameters plus - // its locally declared type parameters. - function getTypeParametersOfClassOrInterface(symbol) { - return ts.concatenate(getOuterTypeParametersOfClassOrInterface(symbol), getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol)); - } - function isConstructorType(type) { - return type.flags & 80896 /* ObjectType */ && getSignaturesOfType(type, 1 /* Construct */).length > 0; - } - function getBaseTypeNodeOfClass(type) { - return ts.getClassExtendsHeritageClauseElement(type.symbol.valueDeclaration); - } - function getConstructorsForTypeArguments(type, typeArgumentNodes) { - var typeArgCount = typeArgumentNodes ? typeArgumentNodes.length : 0; - return ts.filter(getSignaturesOfType(type, 1 /* Construct */), function (sig) { return (sig.typeParameters ? sig.typeParameters.length : 0) === typeArgCount; }); - } - function getInstantiatedConstructorsForTypeArguments(type, typeArgumentNodes) { - var signatures = getConstructorsForTypeArguments(type, typeArgumentNodes); - if (typeArgumentNodes) { - var typeArguments = ts.map(typeArgumentNodes, getTypeFromTypeNode); - signatures = ts.map(signatures, function (sig) { return getSignatureInstantiation(sig, typeArguments); }); - } - return signatures; - } - // The base constructor of a class can resolve to - // undefinedType if the class has no extends clause, - // 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) { - if (!type.resolvedBaseConstructorType) { - var baseTypeNode = getBaseTypeNodeOfClass(type); - if (!baseTypeNode) { - return type.resolvedBaseConstructorType = undefinedType; - } - if (!pushTypeResolution(type, 1 /* ResolvedBaseConstructorType */)) { - return unknownType; - } - var baseConstructorType = checkExpression(baseTypeNode.expression); - if (baseConstructorType.flags & 80896 /* 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); - } - if (!popTypeResolution()) { - error(type.symbol.valueDeclaration, ts.Diagnostics._0_is_referenced_directly_or_indirectly_in_its_own_base_expression, symbolToString(type.symbol)); - return type.resolvedBaseConstructorType = unknownType; - } - if (baseConstructorType !== unknownType && baseConstructorType !== nullType && !isConstructorType(baseConstructorType)) { - error(baseTypeNode.expression, ts.Diagnostics.Type_0_is_not_a_constructor_function_type, typeToString(baseConstructorType)); - return type.resolvedBaseConstructorType = unknownType; - } - type.resolvedBaseConstructorType = baseConstructorType; - } - return type.resolvedBaseConstructorType; - } - function hasClassBaseType(type) { - return !!ts.forEach(getBaseTypes(type), function (t) { return !!(t.symbol.flags & 32 /* Class */); }); - } - function getBaseTypes(type) { - var isClass = type.symbol.flags & 32 /* Class */; - var isInterface = type.symbol.flags & 64 /* Interface */; - if (!type.resolvedBaseTypes) { - if (!isClass && !isInterface) { - ts.Debug.fail("type must be class or interface"); - } - if (isClass) { - resolveBaseTypesOfClass(type); - } - if (isInterface) { - resolveBaseTypesOfInterface(type); - } - } - return type.resolvedBaseTypes; - } - function resolveBaseTypesOfClass(type) { - type.resolvedBaseTypes = type.resolvedBaseTypes || emptyArray; - var baseContructorType = getBaseConstructorTypeOfClass(type); - if (!(baseContructorType.flags & 80896 /* ObjectType */)) { - return; - } - var baseTypeNode = getBaseTypeNodeOfClass(type); - var baseType; - if (baseContructorType.symbol && baseContructorType.symbol.flags & 32 /* Class */) { - // When base constructor type is a class we know that the constructors all have the same type parameters as the - // class and all return the instance type of the class. There is no need for further checks and we can apply the - // type arguments in the same manner as a type reference to get the same error reporting experience. - baseType = getTypeFromClassOrInterfaceReference(baseTypeNode, baseContructorType.symbol); - } - else { - // The class derives from a "class-like" constructor function, check that we have at least one construct signature - // with a matching number of type parameters and use the return type of the first instantiated signature. Elsewhere - // we check that all instantiated signatures return the same type. - var constructors = getInstantiatedConstructorsForTypeArguments(baseContructorType, baseTypeNode.typeArguments); - if (!constructors.length) { - error(baseTypeNode.expression, ts.Diagnostics.No_base_constructor_has_the_specified_number_of_type_arguments); - return; - } - baseType = getReturnTypeOfSignature(constructors[0]); - } - if (baseType === unknownType) { - return; - } - if (!(getTargetType(baseType).flags & (1024 /* Class */ | 2048 /* Interface */))) { - error(baseTypeNode.expression, ts.Diagnostics.Base_constructor_return_type_0_is_not_a_class_or_interface_type, typeToString(baseType)); - return; - } - if (type === baseType || hasBaseType(baseType, type)) { - error(type.symbol.valueDeclaration, ts.Diagnostics.Type_0_recursively_references_itself_as_a_base_type, typeToString(type, /*enclosingDeclaration*/ undefined, 1 /* WriteArrayAsGenericType */)); - return; - } - if (type.resolvedBaseTypes === emptyArray) { - type.resolvedBaseTypes = [baseType]; - } - else { - type.resolvedBaseTypes.push(baseType); - } - } - function resolveBaseTypesOfInterface(type) { - type.resolvedBaseTypes = type.resolvedBaseTypes || emptyArray; - for (var _i = 0, _a = type.symbol.declarations; _i < _a.length; _i++) { - var declaration = _a[_i]; - if (declaration.kind === 215 /* InterfaceDeclaration */ && ts.getInterfaceBaseTypeNodes(declaration)) { - for (var _b = 0, _c = ts.getInterfaceBaseTypeNodes(declaration); _b < _c.length; _b++) { - var node = _c[_b]; - var baseType = getTypeFromTypeNode(node); - if (baseType !== unknownType) { - if (getTargetType(baseType).flags & (1024 /* Class */ | 2048 /* Interface */)) { - if (type !== baseType && !hasBaseType(baseType, type)) { - if (type.resolvedBaseTypes === emptyArray) { - type.resolvedBaseTypes = [baseType]; - } - else { - type.resolvedBaseTypes.push(baseType); - } - } - else { - error(declaration, ts.Diagnostics.Type_0_recursively_references_itself_as_a_base_type, typeToString(type, /*enclosingDeclaration*/ undefined, 1 /* WriteArrayAsGenericType */)); - } - } - else { - error(node, ts.Diagnostics.An_interface_may_only_extend_a_class_or_another_interface); - } - } - } - } - } - } - // Returns true if the interface given by the symbol is free of "this" references. Specifically, the result is - // true if the interface itself contains no references to "this" in its body, if all base types are interfaces, - // and if none of the base interfaces have a "this" type. - function isIndependentInterface(symbol) { - for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { - var declaration = _a[_i]; - if (declaration.kind === 215 /* InterfaceDeclaration */) { - if (declaration.flags & 524288 /* ContainsThis */) { - return false; - } - var baseTypeNodes = ts.getInterfaceBaseTypeNodes(declaration); - if (baseTypeNodes) { - for (var _b = 0; _b < baseTypeNodes.length; _b++) { - var node = baseTypeNodes[_b]; - if (ts.isSupportedExpressionWithTypeArguments(node)) { - var baseSymbol = resolveEntityName(node.expression, 793056 /* Type */, /*ignoreErrors*/ true); - if (!baseSymbol || !(baseSymbol.flags & 64 /* Interface */) || getDeclaredTypeOfClassOrInterface(baseSymbol).thisType) { - return false; - } - } - } - } - } - } - return true; - } - function getDeclaredTypeOfClassOrInterface(symbol) { - var links = getSymbolLinks(symbol); - if (!links.declaredType) { - var kind = symbol.flags & 32 /* Class */ ? 1024 /* Class */ : 2048 /* Interface */; - var type = links.declaredType = createObjectType(kind, symbol); - var outerTypeParameters = getOuterTypeParametersOfClassOrInterface(symbol); - var localTypeParameters = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol); - // A class or interface is generic if it has type parameters or a "this" type. We always give classes a "this" type - // because it is not feasible to analyze all members to determine if the "this" type escapes the class (in particular, - // property types inferred from initializers and method return types inferred from return statements are very hard - // to exhaustively analyze). We give interfaces a "this" type if we can't definitely determine that they are free of - // "this" references. - if (outerTypeParameters || localTypeParameters || kind === 1024 /* Class */ || !isIndependentInterface(symbol)) { - type.flags |= 4096 /* Reference */; - type.typeParameters = ts.concatenate(outerTypeParameters, localTypeParameters); - type.outerTypeParameters = outerTypeParameters; - type.localTypeParameters = localTypeParameters; - type.instantiations = {}; - type.instantiations[getTypeListId(type.typeParameters)] = type; - type.target = type; - type.typeArguments = type.typeParameters; - type.thisType = createType(512 /* TypeParameter */ | 33554432 /* ThisType */); - type.thisType.symbol = symbol; - type.thisType.constraint = getTypeWithThisArgument(type); - } - } - return links.declaredType; - } - function getDeclaredTypeOfTypeAlias(symbol) { - var links = getSymbolLinks(symbol); - if (!links.declaredType) { - // Note that we use the links object as the target here because the symbol object is used as the unique - // identity for resolution of the 'type' property in SymbolLinks. - if (!pushTypeResolution(symbol, 2 /* DeclaredType */)) { - return unknownType; - } - var declaration = ts.getDeclarationOfKind(symbol, 216 /* TypeAliasDeclaration */); - var type = getTypeFromTypeNode(declaration.type); - if (popTypeResolution()) { - links.typeParameters = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol); - if (links.typeParameters) { - // Initialize the instantiation cache for generic type aliases. The declared type corresponds to - // an instantiation of the type alias with the type parameters supplied as type arguments. - links.instantiations = {}; - links.instantiations[getTypeListId(links.typeParameters)] = type; - } - } - else { - type = unknownType; - error(declaration.name, ts.Diagnostics.Type_alias_0_circularly_references_itself, symbolToString(symbol)); - } - links.declaredType = type; - } - return links.declaredType; - } - function getDeclaredTypeOfEnum(symbol) { - var links = getSymbolLinks(symbol); - if (!links.declaredType) { - var type = createType(128 /* Enum */); - type.symbol = symbol; - links.declaredType = type; - } - return links.declaredType; - } - function getDeclaredTypeOfTypeParameter(symbol) { - var links = getSymbolLinks(symbol); - if (!links.declaredType) { - var type = createType(512 /* TypeParameter */); - type.symbol = symbol; - if (!ts.getDeclarationOfKind(symbol, 137 /* TypeParameter */).constraint) { - type.constraint = noConstraintType; - } - links.declaredType = type; - } - return links.declaredType; - } - function getDeclaredTypeOfAlias(symbol) { - var links = getSymbolLinks(symbol); - if (!links.declaredType) { - links.declaredType = getDeclaredTypeOfSymbol(resolveAlias(symbol)); - } - return links.declaredType; - } - function getDeclaredTypeOfSymbol(symbol) { - ts.Debug.assert((symbol.flags & 16777216 /* Instantiated */) === 0); - if (symbol.flags & (32 /* Class */ | 64 /* Interface */)) { - return getDeclaredTypeOfClassOrInterface(symbol); - } - if (symbol.flags & 524288 /* TypeAlias */) { - return getDeclaredTypeOfTypeAlias(symbol); - } - if (symbol.flags & 384 /* Enum */) { - return getDeclaredTypeOfEnum(symbol); - } - if (symbol.flags & 262144 /* TypeParameter */) { - return getDeclaredTypeOfTypeParameter(symbol); - } - if (symbol.flags & 8388608 /* Alias */) { - return getDeclaredTypeOfAlias(symbol); - } - return unknownType; - } - // A type reference is considered independent if each type argument is considered independent. - function isIndependentTypeReference(node) { - if (node.typeArguments) { - for (var _i = 0, _a = node.typeArguments; _i < _a.length; _i++) { - var typeNode = _a[_i]; - if (!isIndependentType(typeNode)) { - return false; - } - } - } - return true; - } - // A type is considered independent if it the any, string, number, boolean, symbol, or void keyword, a string - // literal type, an array with an element type that is considered independent, or a type reference that is - // considered independent. - function isIndependentType(node) { - switch (node.kind) { - case 117 /* AnyKeyword */: - case 130 /* StringKeyword */: - case 128 /* NumberKeyword */: - case 120 /* BooleanKeyword */: - case 131 /* SymbolKeyword */: - case 103 /* VoidKeyword */: - case 9 /* StringLiteral */: - return true; - case 156 /* ArrayType */: - return isIndependentType(node.elementType); - case 151 /* TypeReference */: - return isIndependentTypeReference(node); - } - return false; - } - // A variable-like declaration is considered independent (free of this references) if it has a type annotation - // that specifies an independent type, or if it has no type annotation and no initializer (and thus of type any). - function isIndependentVariableLikeDeclaration(node) { - return node.type && isIndependentType(node.type) || !node.type && !node.initializer; - } - // A function-like declaration is considered independent (free of this references) if it has a return type - // annotation that is considered independent and if each parameter is considered independent. - function isIndependentFunctionLikeDeclaration(node) { - if (node.kind !== 144 /* Constructor */ && (!node.type || !isIndependentType(node.type))) { - return false; - } - for (var _i = 0, _a = node.parameters; _i < _a.length; _i++) { - var parameter = _a[_i]; - if (!isIndependentVariableLikeDeclaration(parameter)) { - return false; - } - } - return true; - } - // Returns true if the class or interface member given by the symbol is free of "this" references. The - // function may return false for symbols that are actually free of "this" references because it is not - // feasible to perform a complete analysis in all cases. In particular, property members with types - // inferred from their initializers and function members with inferred return types are convervatively - // assumed not to be free of "this" references. - function isIndependentMember(symbol) { - if (symbol.declarations && symbol.declarations.length === 1) { - var declaration = symbol.declarations[0]; - if (declaration) { - switch (declaration.kind) { - case 141 /* PropertyDeclaration */: - case 140 /* PropertySignature */: - return isIndependentVariableLikeDeclaration(declaration); - case 143 /* MethodDeclaration */: - case 142 /* MethodSignature */: - case 144 /* Constructor */: - return isIndependentFunctionLikeDeclaration(declaration); - } - } - } - return false; - } - function createSymbolTable(symbols) { - var result = {}; - for (var _i = 0; _i < symbols.length; _i++) { - var symbol = symbols[_i]; - result[symbol.name] = symbol; - } - return result; - } - // The mappingThisOnly flag indicates that the only type parameter being mapped is "this". When the flag is true, - // we check symbols to see if we can quickly conclude they are free of "this" references, thus needing no instantiation. - function createInstantiatedSymbolTable(symbols, mapper, mappingThisOnly) { - var result = {}; - for (var _i = 0; _i < symbols.length; _i++) { - var symbol = symbols[_i]; - result[symbol.name] = mappingThisOnly && isIndependentMember(symbol) ? symbol : instantiateSymbol(symbol, mapper); - } - return result; - } - function addInheritedMembers(symbols, baseSymbols) { - for (var _i = 0; _i < baseSymbols.length; _i++) { - var s = baseSymbols[_i]; - if (!ts.hasProperty(symbols, s.name)) { - symbols[s.name] = s; - } - } - } - function addInheritedSignatures(signatures, baseSignatures) { - if (baseSignatures) { - for (var _i = 0; _i < baseSignatures.length; _i++) { - var signature = baseSignatures[_i]; - signatures.push(signature); - } - } - } - function resolveDeclaredMembers(type) { - if (!type.declaredProperties) { - var symbol = type.symbol; - type.declaredProperties = getNamedMembers(symbol.members); - type.declaredCallSignatures = getSignaturesOfSymbol(symbol.members["__call"]); - type.declaredConstructSignatures = getSignaturesOfSymbol(symbol.members["__new"]); - type.declaredStringIndexType = getIndexTypeOfSymbol(symbol, 0 /* String */); - type.declaredNumberIndexType = getIndexTypeOfSymbol(symbol, 1 /* Number */); - } - return type; - } - function getTypeWithThisArgument(type, thisArgument) { - if (type.flags & 4096 /* Reference */) { - return createTypeReference(type.target, ts.concatenate(type.typeArguments, [thisArgument || type.target.thisType])); - } - return type; - } - function resolveObjectTypeMembers(type, source, typeParameters, typeArguments) { - var mapper = identityMapper; - var members = source.symbol.members; - var callSignatures = source.declaredCallSignatures; - var constructSignatures = source.declaredConstructSignatures; - var stringIndexType = source.declaredStringIndexType; - var numberIndexType = source.declaredNumberIndexType; - if (!ts.rangeEquals(typeParameters, typeArguments, 0, typeParameters.length)) { - mapper = createTypeMapper(typeParameters, typeArguments); - members = createInstantiatedSymbolTable(source.declaredProperties, mapper, /*mappingThisOnly*/ typeParameters.length === 1); - callSignatures = instantiateList(source.declaredCallSignatures, mapper, instantiateSignature); - constructSignatures = instantiateList(source.declaredConstructSignatures, mapper, instantiateSignature); - stringIndexType = instantiateType(source.declaredStringIndexType, mapper); - numberIndexType = instantiateType(source.declaredNumberIndexType, mapper); - } - var baseTypes = getBaseTypes(source); - if (baseTypes.length) { - if (members === source.symbol.members) { - members = createSymbolTable(source.declaredProperties); - } - var thisArgument = ts.lastOrUndefined(typeArguments); - for (var _i = 0; _i < baseTypes.length; _i++) { - var baseType = baseTypes[_i]; - var instantiatedBaseType = thisArgument ? getTypeWithThisArgument(instantiateType(baseType, mapper), thisArgument) : baseType; - addInheritedMembers(members, getPropertiesOfObjectType(instantiatedBaseType)); - callSignatures = ts.concatenate(callSignatures, getSignaturesOfType(instantiatedBaseType, 0 /* Call */)); - constructSignatures = ts.concatenate(constructSignatures, getSignaturesOfType(instantiatedBaseType, 1 /* Construct */)); - stringIndexType = stringIndexType || getIndexTypeOfType(instantiatedBaseType, 0 /* String */); - numberIndexType = numberIndexType || getIndexTypeOfType(instantiatedBaseType, 1 /* Number */); - } - } - setObjectTypeMembers(type, members, callSignatures, constructSignatures, stringIndexType, numberIndexType); - } - function resolveClassOrInterfaceMembers(type) { - resolveObjectTypeMembers(type, resolveDeclaredMembers(type), emptyArray, emptyArray); - } - function resolveTypeReferenceMembers(type) { - var source = resolveDeclaredMembers(type.target); - var typeParameters = ts.concatenate(source.typeParameters, [source.thisType]); - var typeArguments = type.typeArguments && type.typeArguments.length === typeParameters.length ? - type.typeArguments : ts.concatenate(type.typeArguments, [type]); - resolveObjectTypeMembers(type, source, typeParameters, typeArguments); - } - function createSignature(declaration, typeParameters, parameters, resolvedReturnType, typePredicate, minArgumentCount, hasRestParameter, hasStringLiterals) { - var sig = new Signature(checker); - sig.declaration = declaration; - sig.typeParameters = typeParameters; - sig.parameters = parameters; - sig.resolvedReturnType = resolvedReturnType; - sig.typePredicate = typePredicate; - sig.minArgumentCount = minArgumentCount; - sig.hasRestParameter = hasRestParameter; - sig.hasStringLiterals = hasStringLiterals; - return sig; - } - function cloneSignature(sig) { - return createSignature(sig.declaration, sig.typeParameters, sig.parameters, sig.resolvedReturnType, sig.typePredicate, sig.minArgumentCount, sig.hasRestParameter, sig.hasStringLiterals); - } - function getDefaultConstructSignatures(classType) { - if (!hasClassBaseType(classType)) { - return [createSignature(undefined, classType.localTypeParameters, emptyArray, classType, undefined, 0, false, false)]; - } - var baseConstructorType = getBaseConstructorTypeOfClass(classType); - var baseSignatures = getSignaturesOfType(baseConstructorType, 1 /* Construct */); - var baseTypeNode = getBaseTypeNodeOfClass(classType); - var typeArguments = ts.map(baseTypeNode.typeArguments, getTypeFromTypeNode); - var typeArgCount = typeArguments ? typeArguments.length : 0; - var result = []; - for (var _i = 0; _i < baseSignatures.length; _i++) { - var baseSig = baseSignatures[_i]; - var typeParamCount = baseSig.typeParameters ? baseSig.typeParameters.length : 0; - if (typeParamCount === typeArgCount) { - var sig = typeParamCount ? getSignatureInstantiation(baseSig, typeArguments) : cloneSignature(baseSig); - sig.typeParameters = classType.localTypeParameters; - sig.resolvedReturnType = classType; - result.push(sig); - } - } - return result; - } - function createTupleTypeMemberSymbols(memberTypes) { - var members = {}; - for (var i = 0; i < memberTypes.length; i++) { - var symbol = createSymbol(4 /* Property */ | 67108864 /* Transient */, "" + i); - symbol.type = memberTypes[i]; - members[i] = symbol; - } - return members; - } - function resolveTupleTypeMembers(type) { - var arrayElementType = getUnionType(type.elementTypes, /*noSubtypeReduction*/ true); - // Make the tuple type itself the 'this' type by including an extra type argument - var arrayType = resolveStructuredTypeMembers(createTypeFromGenericGlobalType(globalArrayType, [arrayElementType, type])); - var members = createTupleTypeMemberSymbols(type.elementTypes); - addInheritedMembers(members, arrayType.properties); - setObjectTypeMembers(type, members, arrayType.callSignatures, arrayType.constructSignatures, arrayType.stringIndexType, arrayType.numberIndexType); - } - function findMatchingSignature(signatureList, signature, partialMatch, ignoreReturnTypes) { - for (var _i = 0; _i < signatureList.length; _i++) { - var s = signatureList[_i]; - if (compareSignatures(s, signature, partialMatch, ignoreReturnTypes, compareTypes)) { - return s; - } - } - } - function findMatchingSignatures(signatureLists, signature, listIndex) { - if (signature.typeParameters) { - // We require an exact match for generic signatures, so we only return signatures from the first - // signature list and only if they have exact matches in the other signature lists. - if (listIndex > 0) { - return undefined; - } - for (var i = 1; i < signatureLists.length; i++) { - if (!findMatchingSignature(signatureLists[i], signature, /*partialMatch*/ false, /*ignoreReturnTypes*/ false)) { - return undefined; - } - } - return [signature]; - } - var result = undefined; - for (var i = 0; i < signatureLists.length; i++) { - // Allow matching non-generic signatures to have excess parameters and different return types - var match = i === listIndex ? signature : findMatchingSignature(signatureLists[i], signature, /*partialMatch*/ true, /*ignoreReturnTypes*/ true); - if (!match) { - return undefined; - } - if (!ts.contains(result, match)) { - (result || (result = [])).push(match); - } - } - return result; - } - // The signatures of a union type are those signatures that are present in each of the constituent types. - // Generic signatures must match exactly, but non-generic signatures are allowed to have extra optional - // parameters and may differ in return types. When signatures differ in return types, the resulting return - // type is the union of the constituent return types. - function getUnionSignatures(types, kind) { - var signatureLists = ts.map(types, function (t) { return getSignaturesOfType(t, kind); }); - var result = undefined; - for (var i = 0; i < signatureLists.length; i++) { - for (var _i = 0, _a = signatureLists[i]; _i < _a.length; _i++) { - var signature = _a[_i]; - // Only process signatures with parameter lists that aren't already in the result list - if (!result || !findMatchingSignature(result, signature, /*partialMatch*/ false, /*ignoreReturnTypes*/ true)) { - var unionSignatures = findMatchingSignatures(signatureLists, signature, i); - if (unionSignatures) { - var s = signature; - // Union the result types when more than one signature matches - if (unionSignatures.length > 1) { - s = cloneSignature(signature); - // Clear resolved return type we possibly got from cloneSignature - s.resolvedReturnType = undefined; - s.unionSignatures = unionSignatures; - } - (result || (result = [])).push(s); - } - } - } - } - return result || emptyArray; - } - function getUnionIndexType(types, kind) { - var indexTypes = []; - for (var _i = 0; _i < types.length; _i++) { - var type = types[_i]; - var indexType = getIndexTypeOfType(type, kind); - if (!indexType) { - return undefined; - } - indexTypes.push(indexType); - } - return getUnionType(indexTypes); - } - function resolveUnionTypeMembers(type) { - // The members and properties collections are empty for union types. To get all properties of a union - // type use getPropertiesOfType (only the language service uses this). - var callSignatures = getUnionSignatures(type.types, 0 /* Call */); - var constructSignatures = getUnionSignatures(type.types, 1 /* Construct */); - var stringIndexType = getUnionIndexType(type.types, 0 /* String */); - var numberIndexType = getUnionIndexType(type.types, 1 /* Number */); - setObjectTypeMembers(type, emptySymbols, callSignatures, constructSignatures, stringIndexType, numberIndexType); - } - function intersectTypes(type1, type2) { - return !type1 ? type2 : !type2 ? type1 : getIntersectionType([type1, type2]); - } - function resolveIntersectionTypeMembers(type) { - // The members and properties collections are empty for intersection types. To get all properties of an - // intersection type use getPropertiesOfType (only the language service uses this). - var callSignatures = emptyArray; - var constructSignatures = emptyArray; - var stringIndexType = undefined; - var numberIndexType = undefined; - for (var _i = 0, _a = type.types; _i < _a.length; _i++) { - var t = _a[_i]; - callSignatures = ts.concatenate(callSignatures, getSignaturesOfType(t, 0 /* Call */)); - constructSignatures = ts.concatenate(constructSignatures, getSignaturesOfType(t, 1 /* Construct */)); - stringIndexType = intersectTypes(stringIndexType, getIndexTypeOfType(t, 0 /* String */)); - numberIndexType = intersectTypes(numberIndexType, getIndexTypeOfType(t, 1 /* Number */)); - } - setObjectTypeMembers(type, emptySymbols, callSignatures, constructSignatures, stringIndexType, numberIndexType); - } - function resolveAnonymousTypeMembers(type) { - var symbol = type.symbol; - var members; - var callSignatures; - var constructSignatures; - var stringIndexType; - var numberIndexType; - if (type.target) { - members = createInstantiatedSymbolTable(getPropertiesOfObjectType(type.target), type.mapper, /*mappingThisOnly*/ false); - callSignatures = instantiateList(getSignaturesOfType(type.target, 0 /* Call */), type.mapper, instantiateSignature); - constructSignatures = instantiateList(getSignaturesOfType(type.target, 1 /* Construct */), type.mapper, instantiateSignature); - stringIndexType = instantiateType(getIndexTypeOfType(type.target, 0 /* String */), type.mapper); - numberIndexType = instantiateType(getIndexTypeOfType(type.target, 1 /* Number */), type.mapper); - } - else if (symbol.flags & 2048 /* TypeLiteral */) { - members = symbol.members; - callSignatures = getSignaturesOfSymbol(members["__call"]); - constructSignatures = getSignaturesOfSymbol(members["__new"]); - stringIndexType = getIndexTypeOfSymbol(symbol, 0 /* String */); - numberIndexType = getIndexTypeOfSymbol(symbol, 1 /* Number */); - } - else { - // Combinations of function, class, enum and module - members = emptySymbols; - callSignatures = emptyArray; - constructSignatures = emptyArray; - if (symbol.flags & 1952 /* HasExports */) { - members = getExportsOfSymbol(symbol); - } - if (symbol.flags & (16 /* Function */ | 8192 /* Method */)) { - callSignatures = getSignaturesOfSymbol(symbol); - } - if (symbol.flags & 32 /* Class */) { - var classType = getDeclaredTypeOfClassOrInterface(symbol); - constructSignatures = getSignaturesOfSymbol(symbol.members["__constructor"]); - if (!constructSignatures.length) { - constructSignatures = getDefaultConstructSignatures(classType); - } - var baseConstructorType = getBaseConstructorTypeOfClass(classType); - if (baseConstructorType.flags & 80896 /* ObjectType */) { - members = createSymbolTable(getNamedMembers(members)); - addInheritedMembers(members, getPropertiesOfObjectType(baseConstructorType)); - } - } - stringIndexType = undefined; - numberIndexType = (symbol.flags & 384 /* Enum */) ? stringType : undefined; - } - setObjectTypeMembers(type, members, callSignatures, constructSignatures, stringIndexType, numberIndexType); - } - function resolveStructuredTypeMembers(type) { - if (!type.members) { - if (type.flags & 4096 /* Reference */) { - resolveTypeReferenceMembers(type); - } - else if (type.flags & (1024 /* Class */ | 2048 /* Interface */)) { - resolveClassOrInterfaceMembers(type); - } - else if (type.flags & 65536 /* Anonymous */) { - resolveAnonymousTypeMembers(type); - } - else if (type.flags & 8192 /* Tuple */) { - resolveTupleTypeMembers(type); - } - else if (type.flags & 16384 /* Union */) { - resolveUnionTypeMembers(type); - } - else if (type.flags & 32768 /* Intersection */) { - resolveIntersectionTypeMembers(type); - } - } - return type; - } - // Return properties of an object type or an empty array for other types - function getPropertiesOfObjectType(type) { - if (type.flags & 80896 /* ObjectType */) { - return resolveStructuredTypeMembers(type).properties; - } - return emptyArray; - } - // 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, name) { - if (type.flags & 80896 /* ObjectType */) { - var resolved = resolveStructuredTypeMembers(type); - if (ts.hasProperty(resolved.members, name)) { - var symbol = resolved.members[name]; - if (symbolIsValue(symbol)) { - return symbol; - } - } - } - } - function getPropertiesOfUnionOrIntersectionType(type) { - for (var _i = 0, _a = type.types; _i < _a.length; _i++) { - var current = _a[_i]; - for (var _b = 0, _c = getPropertiesOfType(current); _b < _c.length; _b++) { - var prop = _c[_b]; - getPropertyOfUnionOrIntersectionType(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 - if (type.flags & 16384 /* Union */) { - break; - } - } - return type.resolvedProperties ? symbolsToArray(type.resolvedProperties) : emptyArray; - } - function getPropertiesOfType(type) { - type = getApparentType(type); - return type.flags & 49152 /* UnionOrIntersection */ ? getPropertiesOfUnionOrIntersectionType(type) : getPropertiesOfObjectType(type); - } - /** - * For a type parameter, return the base constraint of the type parameter. For the string, number, - * boolean, and symbol primitive types, return the corresponding object types. Otherwise return the - * type itself. Note that the apparent type of a union type is the union type itself. - */ - function getApparentType(type) { - if (type.flags & 512 /* TypeParameter */) { - do { - type = getConstraintOfTypeParameter(type); - } while (type && type.flags & 512 /* TypeParameter */); - if (!type) { - type = emptyObjectType; - } - } - if (type.flags & 258 /* StringLike */) { - type = globalStringType; - } - else if (type.flags & 132 /* NumberLike */) { - type = globalNumberType; - } - else if (type.flags & 8 /* Boolean */) { - type = globalBooleanType; - } - else if (type.flags & 16777216 /* ESSymbol */) { - type = globalESSymbolType; - } - return type; - } - function createUnionOrIntersectionProperty(containingType, name) { - var types = containingType.types; - var props; - for (var _i = 0; _i < types.length; _i++) { - var current = types[_i]; - var type = getApparentType(current); - if (type !== unknownType) { - var prop = getPropertyOfType(type, name); - if (prop && !(getDeclarationFlagsFromSymbol(prop) & (32 /* Private */ | 64 /* Protected */))) { - if (!props) { - props = [prop]; - } - else if (!ts.contains(props, prop)) { - props.push(prop); - } - } - else if (containingType.flags & 16384 /* Union */) { - // A union type requires the property to be present in all constituent types - return undefined; - } - } - } - if (!props) { - return undefined; - } - if (props.length === 1) { - return props[0]; - } - var propTypes = []; - var declarations = []; - for (var _a = 0; _a < props.length; _a++) { - var prop = props[_a]; - if (prop.declarations) { - ts.addRange(declarations, prop.declarations); - } - propTypes.push(getTypeOfSymbol(prop)); - } - var result = createSymbol(4 /* Property */ | 67108864 /* Transient */ | 268435456 /* SyntheticProperty */, name); - result.containingType = containingType; - result.declarations = declarations; - result.type = containingType.flags & 16384 /* Union */ ? getUnionType(propTypes) : getIntersectionType(propTypes); - return result; - } - function getPropertyOfUnionOrIntersectionType(type, name) { - var properties = type.resolvedProperties || (type.resolvedProperties = {}); - if (ts.hasProperty(properties, name)) { - return properties[name]; - } - var property = createUnionOrIntersectionProperty(type, name); - if (property) { - properties[name] = property; - } - return property; - } - // 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 - // Object and Function as appropriate. - function getPropertyOfType(type, name) { - type = getApparentType(type); - if (type.flags & 80896 /* ObjectType */) { - var resolved = resolveStructuredTypeMembers(type); - if (ts.hasProperty(resolved.members, name)) { - var symbol = resolved.members[name]; - if (symbolIsValue(symbol)) { - return symbol; - } - } - if (resolved === anyFunctionType || resolved.callSignatures.length || resolved.constructSignatures.length) { - var symbol = getPropertyOfObjectType(globalFunctionType, name); - if (symbol) { - return symbol; - } - } - return getPropertyOfObjectType(globalObjectType, name); - } - if (type.flags & 49152 /* UnionOrIntersection */) { - return getPropertyOfUnionOrIntersectionType(type, name); - } - return undefined; - } - function getSignaturesOfStructuredType(type, kind) { - if (type.flags & 130048 /* StructuredType */) { - var resolved = resolveStructuredTypeMembers(type); - return kind === 0 /* Call */ ? resolved.callSignatures : resolved.constructSignatures; - } - return emptyArray; - } - /** - * Return the signatures of the given kind in the given type. Creates synthetic union signatures when necessary and - * maps primitive types and type parameters are to their apparent types. - */ - function getSignaturesOfType(type, kind) { - return getSignaturesOfStructuredType(getApparentType(type), kind); - } - function typeHasConstructSignatures(type) { - var apparentType = getApparentType(type); - if (apparentType.flags & (80896 /* ObjectType */ | 16384 /* Union */)) { - var resolved = resolveStructuredTypeMembers(type); - return resolved.constructSignatures.length > 0; - } - return false; - } - function typeHasCallOrConstructSignatures(type) { - var apparentType = getApparentType(type); - if (apparentType.flags & 130048 /* StructuredType */) { - var resolved = resolveStructuredTypeMembers(type); - return resolved.callSignatures.length > 0 || resolved.constructSignatures.length > 0; - } - return false; - } - function getIndexTypeOfStructuredType(type, kind) { - if (type.flags & 130048 /* StructuredType */) { - var resolved = resolveStructuredTypeMembers(type); - return kind === 0 /* String */ ? resolved.stringIndexType : resolved.numberIndexType; - } - } - // Return the index type of the given kind in the given type. Creates synthetic union index types when necessary and - // maps primitive types and type parameters are to their apparent types. - function getIndexTypeOfType(type, kind) { - return getIndexTypeOfStructuredType(getApparentType(type), kind); - } - // Return list of type parameters with duplicates removed (duplicate identifier errors are generated in the actual - // type checking functions). - function getTypeParametersFromDeclaration(typeParameterDeclarations) { - var result = []; - ts.forEach(typeParameterDeclarations, function (node) { - var tp = getDeclaredTypeOfTypeParameter(node.symbol); - if (!ts.contains(result, tp)) { - result.push(tp); - } - }); - return result; - } - function symbolsToArray(symbols) { - var result = []; - for (var id in symbols) { - if (!isReservedMemberName(id)) { - result.push(symbols[id]); - } - } - return result; - } - function isOptionalParameter(node) { - if (ts.hasQuestionToken(node)) { - return true; - } - if (node.initializer) { - var signatureDeclaration = node.parent; - var signature = getSignatureFromDeclaration(signatureDeclaration); - var parameterIndex = signatureDeclaration.parameters.indexOf(node); - ts.Debug.assert(parameterIndex >= 0); - return parameterIndex >= signature.minArgumentCount; - } - return false; - } - function getSignatureFromDeclaration(declaration) { - var links = getNodeLinks(declaration); - if (!links.resolvedSignature) { - var classType = declaration.kind === 144 /* Constructor */ ? - getDeclaredTypeOfClassOrInterface(getMergedSymbol(declaration.parent.symbol)) - : undefined; - var typeParameters = classType ? classType.localTypeParameters : - declaration.typeParameters ? getTypeParametersFromDeclaration(declaration.typeParameters) : undefined; - var parameters = []; - var hasStringLiterals = false; - var minArgumentCount = -1; - for (var i = 0, n = declaration.parameters.length; i < n; i++) { - var param = declaration.parameters[i]; - parameters.push(param.symbol); - if (param.type && param.type.kind === 9 /* StringLiteral */) { - hasStringLiterals = true; - } - if (param.initializer || param.questionToken || param.dotDotDotToken) { - if (minArgumentCount < 0) { - minArgumentCount = i; - } - } - else { - // If we see any required parameters, it means the prior ones were not in fact optional. - minArgumentCount = -1; - } - } - if (minArgumentCount < 0) { - minArgumentCount = declaration.parameters.length; - } - var returnType; - var typePredicate; - if (classType) { - returnType = classType; - } - else if (declaration.type) { - returnType = getTypeFromTypeNode(declaration.type); - if (declaration.type.kind === 150 /* TypePredicate */) { - var typePredicateNode = declaration.type; - typePredicate = { - parameterName: typePredicateNode.parameterName ? typePredicateNode.parameterName.text : undefined, - parameterIndex: typePredicateNode.parameterName ? getTypePredicateParameterIndex(declaration.parameters, typePredicateNode.parameterName) : undefined, - type: getTypeFromTypeNode(typePredicateNode.type) - }; - } - } - else { - // TypeScript 1.0 spec (April 2014): - // If only one accessor includes a type annotation, the other behaves as if it had the same type annotation. - if (declaration.kind === 145 /* GetAccessor */ && !ts.hasDynamicName(declaration)) { - var setter = ts.getDeclarationOfKind(declaration.symbol, 146 /* SetAccessor */); - returnType = getAnnotatedAccessorType(setter); - } - if (!returnType && ts.nodeIsMissing(declaration.body)) { - returnType = anyType; - } - } - links.resolvedSignature = createSignature(declaration, typeParameters, parameters, returnType, typePredicate, minArgumentCount, ts.hasRestParameter(declaration), hasStringLiterals); - } - return links.resolvedSignature; - } - function getSignaturesOfSymbol(symbol) { - if (!symbol) - return emptyArray; - var result = []; - for (var i = 0, len = symbol.declarations.length; i < len; i++) { - var node = symbol.declarations[i]; - switch (node.kind) { - case 152 /* FunctionType */: - case 153 /* ConstructorType */: - case 213 /* FunctionDeclaration */: - case 143 /* MethodDeclaration */: - case 142 /* MethodSignature */: - case 144 /* Constructor */: - case 147 /* CallSignature */: - case 148 /* ConstructSignature */: - case 149 /* IndexSignature */: - case 145 /* GetAccessor */: - case 146 /* SetAccessor */: - case 173 /* FunctionExpression */: - case 174 /* ArrowFunction */: - // Don't include signature if node is the implementation of an overloaded function. A node is considered - // an implementation node if it has a body and the previous node is of the same kind and immediately - // precedes the implementation node (i.e. has the same parent and ends where the implementation starts). - if (i > 0 && node.body) { - var previous = symbol.declarations[i - 1]; - if (node.parent === previous.parent && node.kind === previous.kind && node.pos === previous.end) { - break; - } - } - result.push(getSignatureFromDeclaration(node)); - } - } - return result; - } - function getReturnTypeOfSignature(signature) { - if (!signature.resolvedReturnType) { - if (!pushTypeResolution(signature, 3 /* ResolvedReturnType */)) { - return unknownType; - } - var type; - if (signature.target) { - type = instantiateType(getReturnTypeOfSignature(signature.target), signature.mapper); - } - else if (signature.unionSignatures) { - type = getUnionType(ts.map(signature.unionSignatures, getReturnTypeOfSignature)); - } - else { - type = getReturnTypeFromBody(signature.declaration); - } - if (!popTypeResolution()) { - type = anyType; - if (compilerOptions.noImplicitAny) { - var declaration = signature.declaration; - if (declaration.name) { - error(declaration.name, 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, ts.declarationNameToString(declaration.name)); - } - else { - error(declaration, ts.Diagnostics.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); - } - } - } - signature.resolvedReturnType = type; - } - return signature.resolvedReturnType; - } - function getRestTypeOfSignature(signature) { - if (signature.hasRestParameter) { - var type = getTypeOfSymbol(ts.lastOrUndefined(signature.parameters)); - if (type.flags & 4096 /* Reference */ && type.target === globalArrayType) { - return type.typeArguments[0]; - } - } - return anyType; - } - function getSignatureInstantiation(signature, typeArguments) { - return instantiateSignature(signature, createTypeMapper(signature.typeParameters, typeArguments), true); - } - function getErasedSignature(signature) { - if (!signature.typeParameters) - return signature; - if (!signature.erasedSignatureCache) { - if (signature.target) { - signature.erasedSignatureCache = instantiateSignature(getErasedSignature(signature.target), signature.mapper); - } - else { - signature.erasedSignatureCache = instantiateSignature(signature, createTypeEraser(signature.typeParameters), true); - } - } - return signature.erasedSignatureCache; - } - function getOrCreateTypeFromSignature(signature) { - // There are two ways to declare a construct signature, one is by declaring a class constructor - // using the constructor keyword, and the other is declaring a bare construct signature in an - // 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 === 144 /* Constructor */ || signature.declaration.kind === 148 /* ConstructSignature */; - var type = createObjectType(65536 /* Anonymous */ | 262144 /* FromSignature */); - type.members = emptySymbols; - type.properties = emptyArray; - type.callSignatures = !isConstructor ? [signature] : emptyArray; - type.constructSignatures = isConstructor ? [signature] : emptyArray; - signature.isolatedSignatureType = type; - } - return signature.isolatedSignatureType; - } - function getIndexSymbol(symbol) { - return symbol.members["__index"]; - } - function getIndexDeclarationOfSymbol(symbol, kind) { - var syntaxKind = kind === 1 /* Number */ ? 128 /* NumberKeyword */ : 130 /* StringKeyword */; - var indexSymbol = getIndexSymbol(symbol); - if (indexSymbol) { - for (var _i = 0, _a = indexSymbol.declarations; _i < _a.length; _i++) { - var decl = _a[_i]; - var node = decl; - if (node.parameters.length === 1) { - var parameter = node.parameters[0]; - if (parameter && parameter.type && parameter.type.kind === syntaxKind) { - return node; - } - } - } - } - return undefined; - } - function getIndexTypeOfSymbol(symbol, kind) { - var declaration = getIndexDeclarationOfSymbol(symbol, kind); - return declaration - ? declaration.type ? getTypeFromTypeNode(declaration.type) : anyType - : undefined; - } - function getConstraintOfTypeParameter(type) { - if (!type.constraint) { - if (type.target) { - var targetConstraint = getConstraintOfTypeParameter(type.target); - type.constraint = targetConstraint ? instantiateType(targetConstraint, type.mapper) : noConstraintType; - } - else { - type.constraint = getTypeFromTypeNode(ts.getDeclarationOfKind(type.symbol, 137 /* TypeParameter */).constraint); - } - } - return type.constraint === noConstraintType ? undefined : type.constraint; - } - function getParentSymbolOfTypeParameter(typeParameter) { - return getSymbolOfNode(ts.getDeclarationOfKind(typeParameter.symbol, 137 /* TypeParameter */).parent); - } - function getTypeListId(types) { - if (types) { - switch (types.length) { - case 1: - return "" + types[0].id; - case 2: - return types[0].id + "," + types[1].id; - default: - var result = ""; - for (var i = 0; i < types.length; i++) { - if (i > 0) { - result += ","; - } - result += types[i].id; - } - return result; - } - } - return ""; - } - // This function is used to propagate certain flags when creating new object type references and union types. - // It is only necessary to do so if a constituent type might be the undefined type, the null type, the type - // of an object literal or the anyFunctionType. This is because there are operations in the type checker - // that care about the presence of such types at arbitrary depth in a containing type. - function getPropagatingFlagsOfTypes(types) { - var result = 0; - for (var _i = 0; _i < types.length; _i++) { - var type = types[_i]; - result |= type.flags; - } - return result & 14680064 /* PropagatingFlags */; - } - function createTypeReference(target, typeArguments) { - var id = getTypeListId(typeArguments); - var type = target.instantiations[id]; - if (!type) { - var flags = 4096 /* Reference */ | (typeArguments ? getPropagatingFlagsOfTypes(typeArguments) : 0); - type = target.instantiations[id] = createObjectType(flags, target.symbol); - type.target = target; - type.typeArguments = typeArguments; - } - return type; - } - function isTypeParameterReferenceIllegalInConstraint(typeReferenceNode, typeParameterSymbol) { - var links = getNodeLinks(typeReferenceNode); - if (links.isIllegalTypeReferenceInConstraint !== undefined) { - return links.isIllegalTypeReferenceInConstraint; - } - // bubble up to the declaration - var currentNode = typeReferenceNode; - // forEach === exists - while (!ts.forEach(typeParameterSymbol.declarations, function (d) { return d.parent === currentNode.parent; })) { - currentNode = currentNode.parent; - } - // if last step was made from the type parameter this means that path has started somewhere in constraint which is illegal - links.isIllegalTypeReferenceInConstraint = currentNode.kind === 137 /* TypeParameter */; - return links.isIllegalTypeReferenceInConstraint; - } - function checkTypeParameterHasIllegalReferencesInConstraint(typeParameter) { - var typeParameterSymbol; - function check(n) { - if (n.kind === 151 /* TypeReference */ && n.typeName.kind === 69 /* Identifier */) { - var links = getNodeLinks(n); - if (links.isIllegalTypeReferenceInConstraint === undefined) { - var symbol = resolveName(typeParameter, n.typeName.text, 793056 /* Type */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined); - if (symbol && (symbol.flags & 262144 /* TypeParameter */)) { - // TypeScript 1.0 spec (April 2014): 3.4.1 - // Type parameters declared in a particular type parameter list - // may not be referenced in constraints in that type parameter list - // symbol.declaration.parent === typeParameter.parent - // -> typeParameter and symbol.declaration originate from the same type parameter list - // -> illegal for all declarations in symbol - // forEach === exists - links.isIllegalTypeReferenceInConstraint = ts.forEach(symbol.declarations, function (d) { return d.parent === typeParameter.parent; }); - } - } - if (links.isIllegalTypeReferenceInConstraint) { - error(typeParameter, ts.Diagnostics.Constraint_of_a_type_parameter_cannot_reference_any_type_parameter_from_the_same_type_parameter_list); - } - } - ts.forEachChild(n, check); - } - if (typeParameter.constraint) { - typeParameterSymbol = getSymbolOfNode(typeParameter); - check(typeParameter.constraint); - } - } - // Get type from reference to class or interface - function getTypeFromClassOrInterfaceReference(node, symbol) { - var type = getDeclaredTypeOfSymbol(symbol); - var typeParameters = type.localTypeParameters; - if (typeParameters) { - if (!node.typeArguments || node.typeArguments.length !== typeParameters.length) { - error(node, ts.Diagnostics.Generic_type_0_requires_1_type_argument_s, typeToString(type, /*enclosingDeclaration*/ undefined, 1 /* WriteArrayAsGenericType */), typeParameters.length); - return unknownType; - } - // In a type reference, the outer type parameters of the referenced class or interface are automatically - // supplied as type arguments and the type reference only specifies arguments for the local type parameters - // of the class or interface. - return createTypeReference(type, ts.concatenate(type.outerTypeParameters, ts.map(node.typeArguments, getTypeFromTypeNode))); - } - if (node.typeArguments) { - error(node, ts.Diagnostics.Type_0_is_not_generic, typeToString(type)); - return unknownType; - } - return type; - } - // Get type from reference to type alias. When a type alias is generic, the declared type of the type alias may include - // references to the type parameters of the alias. We replace those with the actual type arguments by instantiating the - // declared type. Instantiations are cached using the type identities of the type arguments as the key. - function getTypeFromTypeAliasReference(node, symbol) { - var type = getDeclaredTypeOfSymbol(symbol); - var links = getSymbolLinks(symbol); - var typeParameters = links.typeParameters; - if (typeParameters) { - if (!node.typeArguments || node.typeArguments.length !== typeParameters.length) { - error(node, ts.Diagnostics.Generic_type_0_requires_1_type_argument_s, symbolToString(symbol), typeParameters.length); - return unknownType; - } - var typeArguments = ts.map(node.typeArguments, getTypeFromTypeNode); - var id = getTypeListId(typeArguments); - return links.instantiations[id] || (links.instantiations[id] = instantiateType(type, createTypeMapper(typeParameters, typeArguments))); - } - if (node.typeArguments) { - error(node, ts.Diagnostics.Type_0_is_not_generic, symbolToString(symbol)); - return unknownType; - } - return type; - } - // Get type from reference to named type that cannot be generic (enum or type parameter) - function getTypeFromNonGenericTypeReference(node, symbol) { - if (symbol.flags & 262144 /* TypeParameter */ && isTypeParameterReferenceIllegalInConstraint(node, symbol)) { - // TypeScript 1.0 spec (April 2014): 3.4.1 - // Type parameters declared in a particular type parameter list - // may not be referenced in constraints in that type parameter list - // Implementation: such type references are resolved to 'unknown' type that usually denotes error - return unknownType; - } - if (node.typeArguments) { - error(node, ts.Diagnostics.Type_0_is_not_generic, symbolToString(symbol)); - return unknownType; - } - return getDeclaredTypeOfSymbol(symbol); - } - function getTypeFromTypeReference(node) { - var links = getNodeLinks(node); - if (!links.resolvedType) { - // We only support expressions that are simple qualified names. For other expressions this produces undefined. - var typeNameOrExpression = node.kind === 151 /* TypeReference */ ? node.typeName : - ts.isSupportedExpressionWithTypeArguments(node) ? node.expression : - undefined; - var symbol = typeNameOrExpression && resolveEntityName(typeNameOrExpression, 793056 /* Type */) || unknownSymbol; - var type = symbol === unknownSymbol ? unknownType : - symbol.flags & (32 /* Class */ | 64 /* Interface */) ? getTypeFromClassOrInterfaceReference(node, symbol) : - symbol.flags & 524288 /* TypeAlias */ ? getTypeFromTypeAliasReference(node, symbol) : - getTypeFromNonGenericTypeReference(node, symbol); - // Cache both the resolved symbol and the resolved type. The resolved symbol is needed in when we check the - // type reference in checkTypeReferenceOrExpressionWithTypeArguments. - links.resolvedSymbol = symbol; - links.resolvedType = type; - } - return links.resolvedType; - } - function getTypeFromTypeQueryNode(node) { - var links = getNodeLinks(node); - if (!links.resolvedType) { - // TypeScript 1.0 spec (April 2014): 3.6.3 - // The expression is processed as an identifier expression (section 4.3) - // or property access expression(section 4.10), - // the widened type(section 3.9) of which becomes the result. - links.resolvedType = getWidenedType(checkExpression(node.exprName)); - } - return links.resolvedType; - } - function getTypeOfGlobalSymbol(symbol, arity) { - function getTypeDeclaration(symbol) { - var declarations = symbol.declarations; - for (var _i = 0; _i < declarations.length; _i++) { - var declaration = declarations[_i]; - switch (declaration.kind) { - case 214 /* ClassDeclaration */: - case 215 /* InterfaceDeclaration */: - case 217 /* EnumDeclaration */: - return declaration; - } - } - } - if (!symbol) { - return arity ? emptyGenericType : emptyObjectType; - } - var type = getDeclaredTypeOfSymbol(symbol); - if (!(type.flags & 80896 /* ObjectType */)) { - error(getTypeDeclaration(symbol), ts.Diagnostics.Global_type_0_must_be_a_class_or_interface_type, symbol.name); - return arity ? emptyGenericType : emptyObjectType; - } - if ((type.typeParameters ? type.typeParameters.length : 0) !== arity) { - error(getTypeDeclaration(symbol), ts.Diagnostics.Global_type_0_must_have_1_type_parameter_s, symbol.name, arity); - return arity ? emptyGenericType : emptyObjectType; - } - return type; - } - function getGlobalValueSymbol(name) { - return getGlobalSymbol(name, 107455 /* Value */, ts.Diagnostics.Cannot_find_global_value_0); - } - function getGlobalTypeSymbol(name) { - return getGlobalSymbol(name, 793056 /* Type */, ts.Diagnostics.Cannot_find_global_type_0); - } - function getGlobalSymbol(name, meaning, diagnostic) { - return resolveName(undefined, name, meaning, diagnostic, name); - } - function getGlobalType(name, arity) { - if (arity === void 0) { arity = 0; } - return getTypeOfGlobalSymbol(getGlobalTypeSymbol(name), arity); - } - function tryGetGlobalType(name, arity) { - if (arity === void 0) { arity = 0; } - return getTypeOfGlobalSymbol(getGlobalSymbol(name, 793056 /* Type */, /*diagnostic*/ undefined), arity); - } - /** - * Returns a type that is inside a namespace at the global scope, e.g. - * getExportedTypeFromNamespace('JSX', 'Element') returns the JSX.Element type - */ - function getExportedTypeFromNamespace(namespace, name) { - var namespaceSymbol = getGlobalSymbol(namespace, 1536 /* Namespace */, /*diagnosticMessage*/ undefined); - var typeSymbol = namespaceSymbol && getSymbol(namespaceSymbol.exports, name, 793056 /* Type */); - return typeSymbol && getDeclaredTypeOfSymbol(typeSymbol); - } - function getGlobalESSymbolConstructorSymbol() { - return globalESSymbolConstructorSymbol || (globalESSymbolConstructorSymbol = getGlobalValueSymbol("Symbol")); - } - /** - * Creates a TypeReference for a generic `TypedPropertyDescriptor`. - */ - function createTypedPropertyDescriptorType(propertyType) { - var globalTypedPropertyDescriptorType = getGlobalTypedPropertyDescriptorType(); - return globalTypedPropertyDescriptorType !== emptyGenericType - ? createTypeReference(globalTypedPropertyDescriptorType, [propertyType]) - : emptyObjectType; - } - /** - * Instantiates a global type that is generic with some element type, and returns that instantiation. - */ - function createTypeFromGenericGlobalType(genericGlobalType, typeArguments) { - return genericGlobalType !== emptyGenericType ? createTypeReference(genericGlobalType, typeArguments) : emptyObjectType; - } - function createIterableType(elementType) { - return createTypeFromGenericGlobalType(globalIterableType, [elementType]); - } - function createIterableIteratorType(elementType) { - return createTypeFromGenericGlobalType(globalIterableIteratorType, [elementType]); - } - function createArrayType(elementType) { - return createTypeFromGenericGlobalType(globalArrayType, [elementType]); - } - function getTypeFromArrayTypeNode(node) { - var links = getNodeLinks(node); - if (!links.resolvedType) { - links.resolvedType = createArrayType(getTypeFromTypeNode(node.elementType)); - } - return links.resolvedType; - } - function createTupleType(elementTypes) { - var id = getTypeListId(elementTypes); - return tupleTypes[id] || (tupleTypes[id] = createNewTupleType(elementTypes)); - } - function createNewTupleType(elementTypes) { - var type = createObjectType(8192 /* Tuple */ | getPropagatingFlagsOfTypes(elementTypes)); - type.elementTypes = elementTypes; - return type; - } - function getTypeFromTupleTypeNode(node) { - var links = getNodeLinks(node); - if (!links.resolvedType) { - links.resolvedType = createTupleType(ts.map(node.elementTypes, getTypeFromTypeNode)); - } - return links.resolvedType; - } - function addTypeToSet(typeSet, type, typeSetKind) { - if (type.flags & typeSetKind) { - addTypesToSet(typeSet, type.types, typeSetKind); - } - else if (!ts.contains(typeSet, type)) { - typeSet.push(type); - } - } - // Add the given types to the given type set. Order is preserved, duplicates are removed, - // and nested types of the given kind are flattened into the set. - function addTypesToSet(typeSet, types, typeSetKind) { - for (var _i = 0; _i < types.length; _i++) { - var type = types[_i]; - addTypeToSet(typeSet, type, typeSetKind); - } - } - function isSubtypeOfAny(candidate, types) { - for (var i = 0, len = types.length; i < len; i++) { - if (candidate !== types[i] && isTypeSubtypeOf(candidate, types[i])) { - return true; - } - } - return false; - } - function removeSubtypes(types) { - var i = types.length; - while (i > 0) { - i--; - if (isSubtypeOfAny(types[i], types)) { - types.splice(i, 1); - } - } - } - function containsTypeAny(types) { - for (var _i = 0; _i < types.length; _i++) { - var type = types[_i]; - if (isTypeAny(type)) { - return true; - } - } - return false; - } - function removeAllButLast(types, typeToRemove) { - var i = types.length; - while (i > 0 && types.length > 1) { - i--; - if (types[i] === typeToRemove) { - types.splice(i, 1); - } - } - } - // We reduce the constituent type set to only include types that aren't subtypes of other types, unless - // the noSubtypeReduction flag is specified, in which case we perform a simple deduplication based on - // object identity. Subtype reduction is possible only when union types are known not to circularly - // reference themselves (as is the case with union types created by expression constructs such as array - // literals and the || and ?: operators). Named types can circularly reference themselves and therefore - // cannot be deduplicated during their declaration. For example, "type Item = string | (() => Item" is - // a named type that circularly references itself. - function getUnionType(types, noSubtypeReduction) { - if (types.length === 0) { - return emptyObjectType; - } - var typeSet = []; - addTypesToSet(typeSet, types, 16384 /* Union */); - if (containsTypeAny(typeSet)) { - return anyType; - } - if (noSubtypeReduction) { - removeAllButLast(typeSet, undefinedType); - removeAllButLast(typeSet, nullType); - } - else { - removeSubtypes(typeSet); - } - if (typeSet.length === 1) { - return typeSet[0]; - } - var id = getTypeListId(typeSet); - var type = unionTypes[id]; - if (!type) { - type = unionTypes[id] = createObjectType(16384 /* Union */ | getPropagatingFlagsOfTypes(typeSet)); - type.types = typeSet; - } - return type; - } - function getTypeFromUnionTypeNode(node) { - var links = getNodeLinks(node); - if (!links.resolvedType) { - links.resolvedType = getUnionType(ts.map(node.types, getTypeFromTypeNode), /*noSubtypeReduction*/ true); - } - return links.resolvedType; - } - // 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. - // Also, unlike union types, the order of the constituent types is preserved in order that overload resolution - // for intersections of types with signatures can be deterministic. - function getIntersectionType(types) { - if (types.length === 0) { - return emptyObjectType; - } - var typeSet = []; - addTypesToSet(typeSet, types, 32768 /* Intersection */); - if (containsTypeAny(typeSet)) { - return anyType; - } - if (typeSet.length === 1) { - return typeSet[0]; - } - var id = getTypeListId(typeSet); - var type = intersectionTypes[id]; - if (!type) { - type = intersectionTypes[id] = createObjectType(32768 /* Intersection */ | getPropagatingFlagsOfTypes(typeSet)); - type.types = typeSet; - } - return type; - } - function getTypeFromIntersectionTypeNode(node) { - var links = getNodeLinks(node); - if (!links.resolvedType) { - links.resolvedType = getIntersectionType(ts.map(node.types, getTypeFromTypeNode)); - } - return links.resolvedType; - } - function getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node) { - var links = getNodeLinks(node); - if (!links.resolvedType) { - // Deferred resolution of members is handled by resolveObjectTypeMembers - links.resolvedType = createObjectType(65536 /* Anonymous */, node.symbol); - } - return links.resolvedType; - } - function getStringLiteralType(node) { - if (ts.hasProperty(stringLiteralTypes, node.text)) { - return stringLiteralTypes[node.text]; - } - var type = stringLiteralTypes[node.text] = createType(256 /* StringLiteral */); - type.text = ts.getTextOfNode(node); - return type; - } - function getTypeFromStringLiteral(node) { - var links = getNodeLinks(node); - if (!links.resolvedType) { - links.resolvedType = getStringLiteralType(node); - } - return links.resolvedType; - } - function getThisType(node) { - var container = ts.getThisContainer(node, /*includeArrowFunctions*/ false); - var parent = container && container.parent; - if (parent && (ts.isClassLike(parent) || parent.kind === 215 /* InterfaceDeclaration */)) { - if (!(container.flags & 128 /* Static */)) { - return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(parent)).thisType; - } - } - error(node, ts.Diagnostics.A_this_type_is_available_only_in_a_non_static_member_of_a_class_or_interface); - return unknownType; - } - function getTypeFromThisTypeNode(node) { - var links = getNodeLinks(node); - if (!links.resolvedType) { - links.resolvedType = getThisType(node); - } - return links.resolvedType; - } - function getTypeFromTypeNode(node) { - switch (node.kind) { - case 117 /* AnyKeyword */: - return anyType; - case 130 /* StringKeyword */: - return stringType; - case 128 /* NumberKeyword */: - return numberType; - case 120 /* BooleanKeyword */: - return booleanType; - case 131 /* SymbolKeyword */: - return esSymbolType; - case 103 /* VoidKeyword */: - return voidType; - case 97 /* ThisKeyword */: - return getTypeFromThisTypeNode(node); - case 9 /* StringLiteral */: - return getTypeFromStringLiteral(node); - case 151 /* TypeReference */: - return getTypeFromTypeReference(node); - case 150 /* TypePredicate */: - return booleanType; - case 188 /* ExpressionWithTypeArguments */: - return getTypeFromTypeReference(node); - case 154 /* TypeQuery */: - return getTypeFromTypeQueryNode(node); - case 156 /* ArrayType */: - return getTypeFromArrayTypeNode(node); - case 157 /* TupleType */: - return getTypeFromTupleTypeNode(node); - case 158 /* UnionType */: - return getTypeFromUnionTypeNode(node); - case 159 /* IntersectionType */: - return getTypeFromIntersectionTypeNode(node); - case 160 /* ParenthesizedType */: - return getTypeFromTypeNode(node.type); - case 152 /* FunctionType */: - case 153 /* ConstructorType */: - case 155 /* TypeLiteral */: - return getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node); - // This function assumes that an identifier or qualified name is a type expression - // Callers should first ensure this by calling isTypeNode - case 69 /* Identifier */: - case 135 /* QualifiedName */: - var symbol = getSymbolAtLocation(node); - return symbol && getDeclaredTypeOfSymbol(symbol); - default: - return unknownType; - } - } - function instantiateList(items, mapper, instantiator) { - if (items && items.length) { - var result = []; - for (var _i = 0; _i < items.length; _i++) { - var v = items[_i]; - result.push(instantiator(v, mapper)); - } - return result; - } - return items; - } - function createUnaryTypeMapper(source, target) { - return function (t) { return t === source ? target : t; }; - } - function createBinaryTypeMapper(source1, target1, source2, target2) { - return function (t) { return t === source1 ? target1 : t === source2 ? target2 : t; }; - } - function createTypeMapper(sources, targets) { - switch (sources.length) { - case 1: return createUnaryTypeMapper(sources[0], targets[0]); - case 2: return createBinaryTypeMapper(sources[0], targets[0], sources[1], targets[1]); - } - return function (t) { - for (var i = 0; i < sources.length; i++) { - if (t === sources[i]) { - return targets[i]; - } - } - return t; - }; - } - function createUnaryTypeEraser(source) { - return function (t) { return t === source ? anyType : t; }; - } - function createBinaryTypeEraser(source1, source2) { - return function (t) { return t === source1 || t === source2 ? anyType : t; }; - } - function createTypeEraser(sources) { - switch (sources.length) { - case 1: return createUnaryTypeEraser(sources[0]); - case 2: return createBinaryTypeEraser(sources[0], sources[1]); - } - return function (t) { - for (var _i = 0; _i < sources.length; _i++) { - var source = sources[_i]; - if (t === source) { - return anyType; - } - } - return t; - }; - } - function createInferenceMapper(context) { - var mapper = function (t) { - for (var i = 0; i < context.typeParameters.length; i++) { - if (t === context.typeParameters[i]) { - context.inferences[i].isFixed = true; - return getInferredType(context, i); - } - } - return t; - }; - mapper.context = context; - return mapper; - } - function identityMapper(type) { - return type; - } - function combineTypeMappers(mapper1, mapper2) { - return function (t) { return instantiateType(mapper1(t), mapper2); }; - } - function instantiateTypeParameter(typeParameter, mapper) { - var result = createType(512 /* TypeParameter */); - result.symbol = typeParameter.symbol; - if (typeParameter.constraint) { - result.constraint = instantiateType(typeParameter.constraint, mapper); - } - else { - result.target = typeParameter; - result.mapper = mapper; - } - return result; - } - function instantiateSignature(signature, mapper, eraseTypeParameters) { - var freshTypeParameters; - var freshTypePredicate; - if (signature.typeParameters && !eraseTypeParameters) { - freshTypeParameters = instantiateList(signature.typeParameters, mapper, instantiateTypeParameter); - mapper = combineTypeMappers(createTypeMapper(signature.typeParameters, freshTypeParameters), mapper); - } - if (signature.typePredicate) { - freshTypePredicate = { - parameterName: signature.typePredicate.parameterName, - parameterIndex: signature.typePredicate.parameterIndex, - type: instantiateType(signature.typePredicate.type, mapper) - }; - } - var result = createSignature(signature.declaration, freshTypeParameters, instantiateList(signature.parameters, mapper, instantiateSymbol), instantiateType(signature.resolvedReturnType, mapper), freshTypePredicate, signature.minArgumentCount, signature.hasRestParameter, signature.hasStringLiterals); - result.target = signature; - result.mapper = mapper; - return result; - } - function instantiateSymbol(symbol, mapper) { - if (symbol.flags & 16777216 /* Instantiated */) { - var links = getSymbolLinks(symbol); - // If symbol being instantiated is itself a instantiation, fetch the original target and combine the - // type mappers. This ensures that original type identities are properly preserved and that aliases - // always reference a non-aliases. - symbol = links.target; - mapper = combineTypeMappers(links.mapper, mapper); - } - // Keep the flags from the symbol we're instantiating. Mark that is instantiated, and - // also transient so that we can just store data on it directly. - var result = createSymbol(16777216 /* Instantiated */ | 67108864 /* Transient */ | symbol.flags, symbol.name); - result.declarations = symbol.declarations; - result.parent = symbol.parent; - result.target = symbol; - result.mapper = mapper; - if (symbol.valueDeclaration) { - result.valueDeclaration = symbol.valueDeclaration; - } - return result; - } - function instantiateAnonymousType(type, mapper) { - if (mapper.instantiations) { - var cachedType = mapper.instantiations[type.id]; - if (cachedType) { - return cachedType; - } - } - else { - mapper.instantiations = []; - } - // Mark the anonymous type as instantiated such that our infinite instantiation detection logic can recognize it - var result = createObjectType(65536 /* Anonymous */ | 131072 /* Instantiated */, type.symbol); - result.target = type; - result.mapper = mapper; - mapper.instantiations[type.id] = result; - return result; - } - function instantiateType(type, mapper) { - if (type && mapper !== identityMapper) { - if (type.flags & 512 /* TypeParameter */) { - return mapper(type); - } - if (type.flags & 65536 /* Anonymous */) { - return type.symbol && type.symbol.flags & (16 /* Function */ | 8192 /* Method */ | 32 /* Class */ | 2048 /* TypeLiteral */ | 4096 /* ObjectLiteral */) ? - instantiateAnonymousType(type, mapper) : type; - } - if (type.flags & 4096 /* Reference */) { - return createTypeReference(type.target, instantiateList(type.typeArguments, mapper, instantiateType)); - } - if (type.flags & 8192 /* Tuple */) { - return createTupleType(instantiateList(type.elementTypes, mapper, instantiateType)); - } - if (type.flags & 16384 /* Union */) { - return getUnionType(instantiateList(type.types, mapper, instantiateType), /*noSubtypeReduction*/ true); - } - if (type.flags & 32768 /* Intersection */) { - return getIntersectionType(instantiateList(type.types, mapper, instantiateType)); - } - } - return type; - } - // 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 !== 143 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); - switch (node.kind) { - case 173 /* FunctionExpression */: - case 174 /* ArrowFunction */: - return isContextSensitiveFunctionLikeDeclaration(node); - case 165 /* ObjectLiteralExpression */: - return ts.forEach(node.properties, isContextSensitive); - case 164 /* ArrayLiteralExpression */: - return ts.forEach(node.elements, isContextSensitive); - case 182 /* ConditionalExpression */: - return isContextSensitive(node.whenTrue) || - isContextSensitive(node.whenFalse); - case 181 /* BinaryExpression */: - return node.operatorToken.kind === 52 /* BarBarToken */ && - (isContextSensitive(node.left) || isContextSensitive(node.right)); - case 245 /* PropertyAssignment */: - return isContextSensitive(node.initializer); - case 143 /* MethodDeclaration */: - case 142 /* MethodSignature */: - return isContextSensitiveFunctionLikeDeclaration(node); - case 172 /* ParenthesizedExpression */: - return isContextSensitive(node.expression); - } - return false; - } - function isContextSensitiveFunctionLikeDeclaration(node) { - return !node.typeParameters && node.parameters.length && !ts.forEach(node.parameters, function (p) { return p.type; }); - } - function getTypeWithoutSignatures(type) { - if (type.flags & 80896 /* ObjectType */) { - var resolved = resolveStructuredTypeMembers(type); - if (resolved.constructSignatures.length) { - var result = createObjectType(65536 /* Anonymous */, type.symbol); - result.members = resolved.members; - result.properties = resolved.properties; - result.callSignatures = emptyArray; - result.constructSignatures = emptyArray; - type = result; - } - } - return type; - } - // TYPE CHECKING - function isTypeIdenticalTo(source, target) { - return checkTypeRelatedTo(source, target, identityRelation, /*errorNode*/ undefined); - } - function compareTypes(source, target) { - return checkTypeRelatedTo(source, target, identityRelation, /*errorNode*/ undefined) ? -1 /* True */ : 0 /* False */; - } - function isTypeSubtypeOf(source, target) { - return checkTypeSubtypeOf(source, target, /*errorNode*/ undefined); - } - function isTypeAssignableTo(source, target) { - return checkTypeAssignableTo(source, target, /*errorNode*/ undefined); - } - function checkTypeSubtypeOf(source, target, errorNode, headMessage, containingMessageChain) { - return checkTypeRelatedTo(source, target, subtypeRelation, errorNode, headMessage, containingMessageChain); - } - function checkTypeAssignableTo(source, target, errorNode, headMessage, containingMessageChain) { - return checkTypeRelatedTo(source, target, assignableRelation, errorNode, headMessage, containingMessageChain); - } - function isSignatureAssignableTo(source, target) { - var sourceType = getOrCreateTypeFromSignature(source); - var targetType = getOrCreateTypeFromSignature(target); - return checkTypeRelatedTo(sourceType, targetType, assignableRelation, /*errorNode*/ undefined); - } - /** - * Checks if 'source' is related to 'target' (e.g.: is a assignable to). - * @param source The left-hand-side of the relation. - * @param target The right-hand-side of the relation. - * @param relation The relation considered. One of 'identityRelation', 'assignableRelation', or 'subTypeRelation'. - * Used as both to determine which checks are performed and as a cache of previously computed results. - * @param errorNode The suggested node upon which all errors will be reported, if defined. This may or may not be the actual node used. - * @param headMessage If the error chain should be prepended by a head message, then headMessage will be used. - * @param containingMessageChain A chain of errors to prepend any new errors found. - */ - function checkTypeRelatedTo(source, target, relation, errorNode, headMessage, containingMessageChain) { - var errorInfo; - var sourceStack; - var targetStack; - var maybeStack; - var expandingFlags; - var depth = 0; - var overflow = false; - var elaborateErrors = false; - ts.Debug.assert(relation !== identityRelation || !errorNode, "no error reporting in identity checking"); - var result = isRelatedTo(source, target, errorNode !== undefined, headMessage); - if (overflow) { - error(errorNode, ts.Diagnostics.Excessive_stack_depth_comparing_types_0_and_1, typeToString(source), typeToString(target)); - } - else if (errorInfo) { - // If we already computed this relation, but in a context where we didn't want to report errors (e.g. overload resolution), - // then we'll only have a top-level error (e.g. 'Class X does not implement interface Y') without any details. If this happened, - // request a recompuation to get a complete error message. This will be skipped if we've already done this computation in a context - // where errors were being reported. - if (errorInfo.next === undefined) { - errorInfo = undefined; - elaborateErrors = true; - isRelatedTo(source, target, errorNode !== undefined, headMessage); - } - if (containingMessageChain) { - errorInfo = ts.concatenateDiagnosticMessageChains(containingMessageChain, errorInfo); - } - diagnostics.add(ts.createDiagnosticForNodeFromMessageChain(errorNode, errorInfo)); - } - return result !== 0 /* False */; - function reportError(message, arg0, arg1, arg2) { - errorInfo = ts.chainDiagnosticMessages(errorInfo, message, arg0, arg1, arg2); - } - function reportRelationError(message, source, target) { - var sourceType = typeToString(source); - var targetType = typeToString(target); - if (sourceType === targetType) { - sourceType = typeToString(source, /*enclosingDeclaration*/ undefined, 128 /* UseFullyQualifiedType */); - targetType = typeToString(target, /*enclosingDeclaration*/ undefined, 128 /* UseFullyQualifiedType */); - } - reportError(message || ts.Diagnostics.Type_0_is_not_assignable_to_type_1, sourceType, targetType); - } - // Compare two types and return - // Ternary.True if they are related with no assumptions, - // Ternary.Maybe if they are related with assumptions of other relationships, or - // Ternary.False if they are not related. - function isRelatedTo(source, target, reportErrors, headMessage) { - var result; - // both types are the same - covers 'they are the same primitive type or both are Any' or the same type parameter cases - if (source === target) - return -1 /* True */; - if (relation === identityRelation) { - return isIdenticalTo(source, target); - } - if (isTypeAny(target)) - return -1 /* True */; - if (source === undefinedType) - return -1 /* True */; - if (source === nullType && target !== undefinedType) - return -1 /* True */; - if (source.flags & 128 /* Enum */ && target === numberType) - return -1 /* True */; - if (source.flags & 256 /* StringLiteral */ && target === stringType) - return -1 /* True */; - if (relation === assignableRelation) { - if (isTypeAny(source)) - return -1 /* True */; - if (source === numberType && target.flags & 128 /* Enum */) - return -1 /* True */; - } - if (source.flags & 1048576 /* FreshObjectLiteral */) { - if (hasExcessProperties(source, target, reportErrors)) { - if (reportErrors) { - reportRelationError(headMessage, source, target); - } - return 0 /* False */; - } - // Above we check for excess properties with respect to the entire target type. When union - // and intersection types are further deconstructed on the target side, we don't want to - // make the check again (as it might fail for a partial target type). Therefore we obtain - // the regular source type and proceed with that. - if (target.flags & 49152 /* UnionOrIntersection */) { - source = getRegularTypeOfObjectLiteral(source); - } - } - var saveErrorInfo = errorInfo; - // Note that the "each" checks must precede the "some" checks to produce the correct results - if (source.flags & 16384 /* Union */) { - if (result = eachTypeRelatedToType(source, target, reportErrors)) { - return result; - } - } - else if (target.flags & 32768 /* Intersection */) { - if (result = typeRelatedToEachType(source, target, reportErrors)) { - return result; - } - } - else { - // It is necessary to try "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 & 32768 /* Intersection */) { - // If target is a union type the following check will report errors so we suppress them here - if (result = someTypeRelatedToType(source, target, reportErrors && !(target.flags & 16384 /* Union */))) { - return result; - } - } - if (target.flags & 16384 /* Union */) { - if (result = typeRelatedToSomeType(source, target, reportErrors)) { - return result; - } - } - } - if (source.flags & 512 /* TypeParameter */) { - var constraint = getConstraintOfTypeParameter(source); - if (!constraint || constraint.flags & 1 /* Any */) { - constraint = emptyObjectType; - } - // Report constraint errors only if the constraint is not the empty object type - var reportConstraintErrors = reportErrors && constraint !== emptyObjectType; - if (result = isRelatedTo(constraint, target, reportConstraintErrors)) { - errorInfo = saveErrorInfo; - return result; - } - } - else { - if (source.flags & 4096 /* Reference */ && target.flags & 4096 /* Reference */ && source.target === target.target) { - // We have type references to same target type, see if relationship holds for all type arguments - if (result = typeArgumentsRelatedTo(source, target, reportErrors)) { - return result; - } - } - // Even if relationship doesn't hold for unions, intersections, or generic type references, - // it may hold in a structural comparison. - var apparentType = getApparentType(source); - // 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 (apparentType.flags & (80896 /* ObjectType */ | 32768 /* Intersection */) && target.flags & 80896 /* ObjectType */) { - // Report structural errors only if we haven't reported any errors yet - var reportStructuralErrors = reportErrors && errorInfo === saveErrorInfo; - if (result = objectTypeRelatedTo(apparentType, source, target, reportStructuralErrors)) { - errorInfo = saveErrorInfo; - return result; - } - } - } - if (reportErrors) { - reportRelationError(headMessage, source, target); - } - return 0 /* False */; - } - function isIdenticalTo(source, target) { - var result; - if (source.flags & 80896 /* ObjectType */ && target.flags & 80896 /* ObjectType */) { - if (source.flags & 4096 /* Reference */ && target.flags & 4096 /* Reference */ && source.target === target.target) { - // We have type references to same target type, see if all type arguments are identical - if (result = typeArgumentsRelatedTo(source, target, /*reportErrors*/ false)) { - return result; - } - } - return objectTypeRelatedTo(source, source, target, /*reportErrors*/ false); - } - if (source.flags & 512 /* TypeParameter */ && target.flags & 512 /* TypeParameter */) { - return typeParameterIdenticalTo(source, target); - } - if (source.flags & 16384 /* Union */ && target.flags & 16384 /* Union */ || - source.flags & 32768 /* Intersection */ && target.flags & 32768 /* Intersection */) { - if (result = eachTypeRelatedToSomeType(source, target)) { - if (result &= eachTypeRelatedToSomeType(target, source)) { - return result; - } - } - } - return 0 /* False */; - } - // Check if a property with the given name is known anywhere in the given type. In an object type, a property - // is considered known if the object type is empty and the check is for assignability, if the object type has - // 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, name) { - if (type.flags & 80896 /* ObjectType */) { - var resolved = resolveStructuredTypeMembers(type); - if (relation === assignableRelation && (type === globalObjectType || resolved.properties.length === 0) || - resolved.stringIndexType || resolved.numberIndexType || getPropertyOfType(type, name)) { - return true; - } - } - else if (type.flags & 49152 /* UnionOrIntersection */) { - for (var _i = 0, _a = type.types; _i < _a.length; _i++) { - var t = _a[_i]; - if (isKnownProperty(t, name)) { - return true; - } - } - } - return false; - } - function hasExcessProperties(source, target, reportErrors) { - if (someConstituentTypeHasKind(target, 80896 /* ObjectType */)) { - for (var _i = 0, _a = getPropertiesOfObjectType(source); _i < _a.length; _i++) { - var prop = _a[_i]; - if (!isKnownProperty(target, prop.name)) { - if (reportErrors) { - // We know *exactly* where things went wrong when comparing the types. - // Use this property as the error node as this will be more helpful in - // reasoning about what went wrong. - errorNode = prop.valueDeclaration; - reportError(ts.Diagnostics.Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1, symbolToString(prop), typeToString(target)); - } - return true; - } - } - } - return false; - } - function eachTypeRelatedToSomeType(source, target) { - var result = -1 /* True */; - var sourceTypes = source.types; - for (var _i = 0; _i < sourceTypes.length; _i++) { - var sourceType = sourceTypes[_i]; - var related = typeRelatedToSomeType(sourceType, target, false); - if (!related) { - return 0 /* False */; - } - result &= related; - } - return result; - } - function typeRelatedToSomeType(source, target, reportErrors) { - var targetTypes = target.types; - for (var i = 0, len = targetTypes.length; i < len; i++) { - var related = isRelatedTo(source, targetTypes[i], reportErrors && i === len - 1); - if (related) { - return related; - } - } - return 0 /* False */; - } - function typeRelatedToEachType(source, target, reportErrors) { - var result = -1 /* True */; - var targetTypes = target.types; - for (var _i = 0; _i < targetTypes.length; _i++) { - var targetType = targetTypes[_i]; - var related = isRelatedTo(source, targetType, reportErrors); - if (!related) { - return 0 /* False */; - } - result &= related; - } - return result; - } - function someTypeRelatedToType(source, target, reportErrors) { - var sourceTypes = source.types; - for (var i = 0, len = sourceTypes.length; i < len; i++) { - var related = isRelatedTo(sourceTypes[i], target, reportErrors && i === len - 1); - if (related) { - return related; - } - } - return 0 /* False */; - } - function eachTypeRelatedToType(source, target, reportErrors) { - var result = -1 /* True */; - var sourceTypes = source.types; - for (var _i = 0; _i < sourceTypes.length; _i++) { - var sourceType = sourceTypes[_i]; - var related = isRelatedTo(sourceType, target, reportErrors); - if (!related) { - return 0 /* False */; - } - result &= related; - } - return result; - } - function typeArgumentsRelatedTo(source, target, reportErrors) { - var sources = source.typeArguments || emptyArray; - var targets = target.typeArguments || emptyArray; - if (sources.length !== targets.length && relation === identityRelation) { - return 0 /* False */; - } - var result = -1 /* True */; - for (var i = 0; i < targets.length; i++) { - var related = isRelatedTo(sources[i], targets[i], reportErrors); - if (!related) { - return 0 /* False */; - } - result &= related; - } - return result; - } - function typeParameterIdenticalTo(source, target) { - if (source.symbol.name !== target.symbol.name) { - return 0 /* False */; - } - // covers case when both type parameters does not have constraint (both equal to noConstraintType) - if (source.constraint === target.constraint) { - return -1 /* True */; - } - if (source.constraint === noConstraintType || target.constraint === noConstraintType) { - return 0 /* False */; - } - return isIdenticalTo(source.constraint, target.constraint); - } - // Determine if two object types are related by structure. First, check if the result is already available in the global cache. - // Second, check if we have already started a comparison of the given two types in which case we assume the result to be true. - // Third, check if both types are part of deeply nested chains of generic type instantiations and if so assume the types are - // equal and infinitely expanding. Fourth, if we have reached a depth of 100 nested comparisons, assume we have runaway recursion - // and issue an error. Otherwise, actually compare the structure of the two types. - function objectTypeRelatedTo(apparentSource, originalSource, target, reportErrors) { - if (overflow) { - return 0 /* False */; - } - var id = relation !== identityRelation || apparentSource.id < target.id ? apparentSource.id + "," + target.id : target.id + "," + apparentSource.id; - var related = relation[id]; - if (related !== undefined) { - // If we computed this relation already and it was failed and reported, or if we're not being asked to elaborate - // errors, we can use the cached value. Otherwise, recompute the relation - if (!elaborateErrors || (related === 3 /* FailedAndReported */)) { - return related === 1 /* Succeeded */ ? -1 /* True */ : 0 /* False */; - } - } - if (depth > 0) { - for (var i = 0; i < depth; i++) { - // If source and target are already being compared, consider them related with assumptions - if (maybeStack[i][id]) { - return 1 /* Maybe */; - } - } - if (depth === 100) { - overflow = true; - return 0 /* False */; - } - } - else { - sourceStack = []; - targetStack = []; - maybeStack = []; - expandingFlags = 0; - } - sourceStack[depth] = apparentSource; - targetStack[depth] = target; - maybeStack[depth] = {}; - maybeStack[depth][id] = 1 /* Succeeded */; - depth++; - var saveExpandingFlags = expandingFlags; - if (!(expandingFlags & 1) && isDeeplyNestedGeneric(apparentSource, sourceStack, depth)) - expandingFlags |= 1; - if (!(expandingFlags & 2) && isDeeplyNestedGeneric(target, targetStack, depth)) - expandingFlags |= 2; - var result; - if (expandingFlags === 3) { - result = 1 /* Maybe */; - } - else { - result = propertiesRelatedTo(apparentSource, target, reportErrors); - if (result) { - result &= signaturesRelatedTo(apparentSource, target, 0 /* Call */, reportErrors); - if (result) { - result &= signaturesRelatedTo(apparentSource, target, 1 /* Construct */, reportErrors); - if (result) { - result &= stringIndexTypesRelatedTo(apparentSource, originalSource, target, reportErrors); - if (result) { - result &= numberIndexTypesRelatedTo(apparentSource, originalSource, target, reportErrors); - } - } - } - } - } - expandingFlags = saveExpandingFlags; - depth--; - if (result) { - var maybeCache = maybeStack[depth]; - // If result is definitely true, copy assumptions to global cache, else copy to next level up - var destinationCache = (result === -1 /* True */ || depth === 0) ? relation : maybeStack[depth - 1]; - ts.copyMap(maybeCache, destinationCache); - } - else { - // A false result goes straight into global cache (when something is false under assumptions it - // will also be false without assumptions) - relation[id] = reportErrors ? 3 /* FailedAndReported */ : 2 /* Failed */; - } - return result; - } - function propertiesRelatedTo(source, target, reportErrors) { - if (relation === identityRelation) { - return propertiesIdenticalTo(source, target); - } - var result = -1 /* True */; - var properties = getPropertiesOfObjectType(target); - var requireOptionalProperties = relation === subtypeRelation && !(source.flags & 524288 /* ObjectLiteral */); - for (var _i = 0; _i < properties.length; _i++) { - var targetProp = properties[_i]; - var sourceProp = getPropertyOfType(source, targetProp.name); - if (sourceProp !== targetProp) { - if (!sourceProp) { - if (!(targetProp.flags & 536870912 /* Optional */) || requireOptionalProperties) { - if (reportErrors) { - reportError(ts.Diagnostics.Property_0_is_missing_in_type_1, symbolToString(targetProp), typeToString(source)); - } - return 0 /* False */; - } - } - else if (!(targetProp.flags & 134217728 /* Prototype */)) { - var sourcePropFlags = getDeclarationFlagsFromSymbol(sourceProp); - var targetPropFlags = getDeclarationFlagsFromSymbol(targetProp); - if (sourcePropFlags & 32 /* Private */ || targetPropFlags & 32 /* Private */) { - if (sourceProp.valueDeclaration !== targetProp.valueDeclaration) { - if (reportErrors) { - if (sourcePropFlags & 32 /* Private */ && targetPropFlags & 32 /* Private */) { - reportError(ts.Diagnostics.Types_have_separate_declarations_of_a_private_property_0, symbolToString(targetProp)); - } - else { - reportError(ts.Diagnostics.Property_0_is_private_in_type_1_but_not_in_type_2, symbolToString(targetProp), typeToString(sourcePropFlags & 32 /* Private */ ? source : target), typeToString(sourcePropFlags & 32 /* Private */ ? target : source)); - } - } - return 0 /* False */; - } - } - else if (targetPropFlags & 64 /* Protected */) { - var sourceDeclaredInClass = sourceProp.parent && sourceProp.parent.flags & 32 /* Class */; - var sourceClass = sourceDeclaredInClass ? getDeclaredTypeOfSymbol(sourceProp.parent) : undefined; - var targetClass = getDeclaredTypeOfSymbol(targetProp.parent); - if (!sourceClass || !hasBaseType(sourceClass, targetClass)) { - if (reportErrors) { - reportError(ts.Diagnostics.Property_0_is_protected_but_type_1_is_not_a_class_derived_from_2, symbolToString(targetProp), typeToString(sourceClass || source), typeToString(targetClass)); - } - return 0 /* False */; - } - } - else if (sourcePropFlags & 64 /* Protected */) { - if (reportErrors) { - reportError(ts.Diagnostics.Property_0_is_protected_in_type_1_but_public_in_type_2, symbolToString(targetProp), typeToString(source), typeToString(target)); - } - return 0 /* False */; - } - var related = isRelatedTo(getTypeOfSymbol(sourceProp), getTypeOfSymbol(targetProp), reportErrors); - if (!related) { - if (reportErrors) { - reportError(ts.Diagnostics.Types_of_property_0_are_incompatible, symbolToString(targetProp)); - } - return 0 /* False */; - } - result &= related; - if (sourceProp.flags & 536870912 /* Optional */ && !(targetProp.flags & 536870912 /* Optional */)) { - // TypeScript 1.0 spec (April 2014): 3.8.3 - // S is a subtype of a type T, and T is a supertype of S if ... - // S' and T are object types and, for each member M in T.. - // M is a property and S' contains a property N where - // if M is a required property, N is also a required property - // (M - property in T) - // (N - property in S) - if (reportErrors) { - reportError(ts.Diagnostics.Property_0_is_optional_in_type_1_but_required_in_type_2, symbolToString(targetProp), typeToString(source), typeToString(target)); - } - return 0 /* False */; - } - } - } - } - return result; - } - function propertiesIdenticalTo(source, target) { - if (!(source.flags & 80896 /* ObjectType */ && target.flags & 80896 /* ObjectType */)) { - return 0 /* False */; - } - var sourceProperties = getPropertiesOfObjectType(source); - var targetProperties = getPropertiesOfObjectType(target); - if (sourceProperties.length !== targetProperties.length) { - return 0 /* False */; - } - var result = -1 /* True */; - for (var _i = 0; _i < sourceProperties.length; _i++) { - var sourceProp = sourceProperties[_i]; - var targetProp = getPropertyOfObjectType(target, sourceProp.name); - if (!targetProp) { - return 0 /* False */; - } - var related = compareProperties(sourceProp, targetProp, isRelatedTo); - if (!related) { - return 0 /* False */; - } - result &= related; - } - return result; - } - function signaturesRelatedTo(source, target, kind, reportErrors) { - if (relation === identityRelation) { - return signaturesIdenticalTo(source, target, kind); - } - if (target === anyFunctionType || source === anyFunctionType) { - return -1 /* True */; - } - var sourceSignatures = getSignaturesOfType(source, kind); - var targetSignatures = getSignaturesOfType(target, kind); - var result = -1 /* True */; - var saveErrorInfo = errorInfo; - if (kind === 1 /* Construct */) { - // Only want to compare the construct signatures for abstractness guarantees. - // Because the "abstractness" of a class is the same across all construct signatures - // (internally we are checking the corresponding declaration), it is enough to perform - // the check and report an error once over all pairs of source and target construct signatures. - // - // sourceSig and targetSig are (possibly) undefined. - // - // Note that in an extends-clause, targetSignatures is stripped, so the check never proceeds. - var sourceSig = sourceSignatures[0]; - var targetSig = targetSignatures[0]; - result &= abstractSignatureRelatedTo(source, sourceSig, target, targetSig); - if (result !== -1 /* True */) { - return result; - } - } - outer: for (var _i = 0; _i < targetSignatures.length; _i++) { - var t = targetSignatures[_i]; - if (!t.hasStringLiterals || target.flags & 262144 /* FromSignature */) { - var localErrors = reportErrors; - var checkedAbstractAssignability = false; - for (var _a = 0; _a < sourceSignatures.length; _a++) { - var s = sourceSignatures[_a]; - if (!s.hasStringLiterals || source.flags & 262144 /* FromSignature */) { - var related = signatureRelatedTo(s, t, localErrors); - if (related) { - result &= related; - errorInfo = saveErrorInfo; - continue outer; - } - // Only report errors from the first failure - localErrors = false; - } - } - return 0 /* False */; - } - } - return result; - function abstractSignatureRelatedTo(source, sourceSig, target, targetSig) { - if (sourceSig && targetSig) { - var sourceDecl = source.symbol && getClassLikeDeclarationOfSymbol(source.symbol); - var targetDecl = target.symbol && getClassLikeDeclarationOfSymbol(target.symbol); - if (!sourceDecl) { - // If the source object isn't itself a class declaration, it can be freely assigned, regardless - // of whether the constructed object is abstract or not. - return -1 /* True */; - } - var sourceErasedSignature = getErasedSignature(sourceSig); - var targetErasedSignature = getErasedSignature(targetSig); - var sourceReturnType = sourceErasedSignature && getReturnTypeOfSignature(sourceErasedSignature); - var targetReturnType = targetErasedSignature && getReturnTypeOfSignature(targetErasedSignature); - var sourceReturnDecl = sourceReturnType && sourceReturnType.symbol && getClassLikeDeclarationOfSymbol(sourceReturnType.symbol); - var targetReturnDecl = targetReturnType && targetReturnType.symbol && getClassLikeDeclarationOfSymbol(targetReturnType.symbol); - var sourceIsAbstract = sourceReturnDecl && sourceReturnDecl.flags & 256 /* Abstract */; - var targetIsAbstract = targetReturnDecl && targetReturnDecl.flags & 256 /* Abstract */; - if (sourceIsAbstract && !(targetIsAbstract && targetDecl)) { - // if target isn't a class-declaration type, then it can be new'd, so we forbid the assignment. - if (reportErrors) { - reportError(ts.Diagnostics.Cannot_assign_an_abstract_constructor_type_to_a_non_abstract_constructor_type); - } - return 0 /* False */; - } - } - return -1 /* True */; - } - } - function signatureRelatedTo(source, target, reportErrors) { - if (source === target) { - return -1 /* True */; - } - if (!target.hasRestParameter && source.minArgumentCount > target.parameters.length) { - return 0 /* False */; - } - var sourceMax = source.parameters.length; - var targetMax = target.parameters.length; - var checkCount; - if (source.hasRestParameter && target.hasRestParameter) { - checkCount = sourceMax > targetMax ? sourceMax : targetMax; - sourceMax--; - targetMax--; - } - else if (source.hasRestParameter) { - sourceMax--; - checkCount = targetMax; - } - else if (target.hasRestParameter) { - targetMax--; - checkCount = sourceMax; - } - else { - checkCount = sourceMax < targetMax ? sourceMax : targetMax; - } - // Spec 1.0 Section 3.8.3 & 3.8.4: - // M and N (the signatures) are instantiated using type Any as the type argument for all type parameters declared by M and N - source = getErasedSignature(source); - target = getErasedSignature(target); - var result = -1 /* True */; - for (var i = 0; i < checkCount; i++) { - var s = i < sourceMax ? getTypeOfSymbol(source.parameters[i]) : getRestTypeOfSignature(source); - var t = i < targetMax ? getTypeOfSymbol(target.parameters[i]) : getRestTypeOfSignature(target); - var saveErrorInfo = errorInfo; - var related = isRelatedTo(s, t, reportErrors); - if (!related) { - related = isRelatedTo(t, s, false); - if (!related) { - if (reportErrors) { - reportError(ts.Diagnostics.Types_of_parameters_0_and_1_are_incompatible, source.parameters[i < sourceMax ? i : sourceMax].name, target.parameters[i < targetMax ? i : targetMax].name); - } - return 0 /* False */; - } - errorInfo = saveErrorInfo; - } - result &= related; - } - if (source.typePredicate && target.typePredicate) { - var hasDifferentParameterIndex = source.typePredicate.parameterIndex !== target.typePredicate.parameterIndex; - var hasDifferentTypes; - if (hasDifferentParameterIndex || - (hasDifferentTypes = !isTypeIdenticalTo(source.typePredicate.type, target.typePredicate.type))) { - if (reportErrors) { - var sourceParamText = source.typePredicate.parameterName; - var targetParamText = target.typePredicate.parameterName; - var sourceTypeText = typeToString(source.typePredicate.type); - var targetTypeText = typeToString(target.typePredicate.type); - if (hasDifferentParameterIndex) { - reportError(ts.Diagnostics.Parameter_0_is_not_in_the_same_position_as_parameter_1, sourceParamText, targetParamText); - } - else if (hasDifferentTypes) { - reportError(ts.Diagnostics.Type_0_is_not_assignable_to_type_1, sourceTypeText, targetTypeText); - } - reportError(ts.Diagnostics.Type_predicate_0_is_not_assignable_to_1, sourceParamText + " is " + sourceTypeText, targetParamText + " is " + targetTypeText); - } - return 0 /* False */; - } - } - else if (!source.typePredicate && target.typePredicate) { - if (reportErrors) { - reportError(ts.Diagnostics.Signature_0_must_have_a_type_predicate, signatureToString(source)); - } - return 0 /* False */; - } - var targetReturnType = getReturnTypeOfSignature(target); - if (targetReturnType === voidType) - return result; - var sourceReturnType = getReturnTypeOfSignature(source); - return result & isRelatedTo(sourceReturnType, targetReturnType, reportErrors); - } - function signaturesIdenticalTo(source, target, kind) { - var sourceSignatures = getSignaturesOfType(source, kind); - var targetSignatures = getSignaturesOfType(target, kind); - if (sourceSignatures.length !== targetSignatures.length) { - return 0 /* False */; - } - var result = -1 /* True */; - for (var i = 0, len = sourceSignatures.length; i < len; ++i) { - var related = compareSignatures(sourceSignatures[i], targetSignatures[i], /*partialMatch*/ false, /*ignoreReturnTypes*/ false, isRelatedTo); - if (!related) { - return 0 /* False */; - } - result &= related; - } - return result; - } - function stringIndexTypesRelatedTo(source, originalSource, target, reportErrors) { - if (relation === identityRelation) { - return indexTypesIdenticalTo(0 /* String */, source, target); - } - var targetType = getIndexTypeOfType(target, 0 /* String */); - if (targetType) { - if ((targetType.flags & 1 /* Any */) && !(originalSource.flags & 16777726 /* Primitive */)) { - // non-primitive assignment to any is always allowed, eg - // `var x: { [index: string]: any } = { property: 12 };` - return -1 /* True */; - } - var sourceType = getIndexTypeOfType(source, 0 /* String */); - if (!sourceType) { - if (reportErrors) { - reportError(ts.Diagnostics.Index_signature_is_missing_in_type_0, typeToString(source)); - } - return 0 /* False */; - } - var related = isRelatedTo(sourceType, targetType, reportErrors); - if (!related) { - if (reportErrors) { - reportError(ts.Diagnostics.Index_signatures_are_incompatible); - } - return 0 /* False */; - } - return related; - } - return -1 /* True */; - } - function numberIndexTypesRelatedTo(source, originalSource, target, reportErrors) { - if (relation === identityRelation) { - return indexTypesIdenticalTo(1 /* Number */, source, target); - } - var targetType = getIndexTypeOfType(target, 1 /* Number */); - if (targetType) { - if ((targetType.flags & 1 /* Any */) && !(originalSource.flags & 16777726 /* Primitive */)) { - // non-primitive assignment to any is always allowed, eg - // `var x: { [index: number]: any } = { property: 12 };` - return -1 /* True */; - } - var sourceStringType = getIndexTypeOfType(source, 0 /* String */); - var sourceNumberType = getIndexTypeOfType(source, 1 /* Number */); - if (!(sourceStringType || sourceNumberType)) { - if (reportErrors) { - reportError(ts.Diagnostics.Index_signature_is_missing_in_type_0, typeToString(source)); - } - return 0 /* False */; - } - var related; - if (sourceStringType && sourceNumberType) { - // If we know for sure we're testing both string and numeric index types then only report errors from the second one - related = isRelatedTo(sourceStringType, targetType, false) || isRelatedTo(sourceNumberType, targetType, reportErrors); - } - else { - related = isRelatedTo(sourceStringType || sourceNumberType, targetType, reportErrors); - } - if (!related) { - if (reportErrors) { - reportError(ts.Diagnostics.Index_signatures_are_incompatible); - } - return 0 /* False */; - } - return related; - } - return -1 /* True */; - } - function indexTypesIdenticalTo(indexKind, source, target) { - var targetType = getIndexTypeOfType(target, indexKind); - var sourceType = getIndexTypeOfType(source, indexKind); - if (!sourceType && !targetType) { - return -1 /* True */; - } - if (sourceType && targetType) { - return isRelatedTo(sourceType, targetType); - } - return 0 /* False */; - } - } - // Return true if the given type is part of a deeply nested chain of generic instantiations. We consider this to be the case - // when structural type comparisons have been started for 10 or more instantiations of the same generic type. It is possible, - // though highly unlikely, for this test to be true in a situation where a chain of instantiations is not infinitely expanding. - // Effectively, we will generate a false positive when two types are structurally equal to at least 10 levels, but unequal at - // some level beyond that. - function isDeeplyNestedGeneric(type, stack, depth) { - // We track type references (created by createTypeReference) and instantiated types (created by instantiateType) - if (type.flags & (4096 /* Reference */ | 131072 /* Instantiated */) && depth >= 5) { - var symbol = type.symbol; - var count = 0; - for (var i = 0; i < depth; i++) { - var t = stack[i]; - if (t.flags & (4096 /* Reference */ | 131072 /* Instantiated */) && t.symbol === symbol) { - count++; - if (count >= 5) - return true; - } - } - } - return false; - } - function isPropertyIdenticalTo(sourceProp, targetProp) { - return compareProperties(sourceProp, targetProp, compareTypes) !== 0 /* False */; - } - function compareProperties(sourceProp, targetProp, compareTypes) { - // Two members are considered identical when - // - they are public properties with identical names, optionality, and types, - // - they are private or protected properties originating in the same declaration and having identical types - if (sourceProp === targetProp) { - return -1 /* True */; - } - var sourcePropAccessibility = getDeclarationFlagsFromSymbol(sourceProp) & (32 /* Private */ | 64 /* Protected */); - var targetPropAccessibility = getDeclarationFlagsFromSymbol(targetProp) & (32 /* Private */ | 64 /* Protected */); - if (sourcePropAccessibility !== targetPropAccessibility) { - return 0 /* False */; - } - if (sourcePropAccessibility) { - if (getTargetSymbol(sourceProp) !== getTargetSymbol(targetProp)) { - return 0 /* False */; - } - } - else { - if ((sourceProp.flags & 536870912 /* Optional */) !== (targetProp.flags & 536870912 /* Optional */)) { - return 0 /* False */; - } - } - return compareTypes(getTypeOfSymbol(sourceProp), getTypeOfSymbol(targetProp)); - } - function compareSignatures(source, target, partialMatch, ignoreReturnTypes, compareTypes) { - if (source === target) { - return -1 /* True */; - } - if (source.parameters.length !== target.parameters.length || - source.minArgumentCount !== target.minArgumentCount || - source.hasRestParameter !== target.hasRestParameter) { - if (!partialMatch || - source.parameters.length < target.parameters.length && !source.hasRestParameter || - source.minArgumentCount > target.minArgumentCount) { - return 0 /* False */; - } - } - var result = -1 /* True */; - if (source.typeParameters && target.typeParameters) { - if (source.typeParameters.length !== target.typeParameters.length) { - return 0 /* False */; - } - for (var i = 0, len = source.typeParameters.length; i < len; ++i) { - var related = compareTypes(source.typeParameters[i], target.typeParameters[i]); - if (!related) { - return 0 /* False */; - } - result &= related; - } - } - else if (source.typeParameters || target.typeParameters) { - return 0 /* False */; - } - // Spec 1.0 Section 3.8.3 & 3.8.4: - // M and N (the signatures) are instantiated using type Any as the type argument for all type parameters declared by M and N - source = getErasedSignature(source); - target = getErasedSignature(target); - var targetLen = target.parameters.length; - for (var i = 0; i < targetLen; i++) { - var s = isRestParameterIndex(source, i) ? getRestTypeOfSignature(source) : getTypeOfSymbol(source.parameters[i]); - var t = isRestParameterIndex(target, i) ? getRestTypeOfSignature(target) : getTypeOfSymbol(target.parameters[i]); - var related = compareTypes(s, t); - if (!related) { - return 0 /* False */; - } - result &= related; - } - if (!ignoreReturnTypes) { - result &= compareTypes(getReturnTypeOfSignature(source), getReturnTypeOfSignature(target)); - } - return result; - } - function isRestParameterIndex(signature, parameterIndex) { - return signature.hasRestParameter && parameterIndex >= signature.parameters.length - 1; - } - function isSupertypeOfEach(candidate, types) { - for (var _i = 0; _i < types.length; _i++) { - var type = types[_i]; - if (candidate !== type && !isTypeSubtypeOf(type, candidate)) - return false; - } - return true; - } - function getCommonSupertype(types) { - return ts.forEach(types, function (t) { return isSupertypeOfEach(t, types) ? t : undefined; }); - } - function reportNoCommonSupertypeError(types, errorLocation, errorMessageChainHead) { - // The downfallType/bestSupertypeDownfallType is the first type that caused a particular candidate - // to not be the common supertype. So if it weren't for this one downfallType (and possibly others), - // the type in question could have been the common supertype. - var bestSupertype; - var bestSupertypeDownfallType; - var bestSupertypeScore = 0; - for (var i = 0; i < types.length; i++) { - var score = 0; - var downfallType = undefined; - for (var j = 0; j < types.length; j++) { - if (isTypeSubtypeOf(types[j], types[i])) { - score++; - } - else if (!downfallType) { - downfallType = types[j]; - } - } - ts.Debug.assert(!!downfallType, "If there is no common supertype, each type should have a downfallType"); - if (score > bestSupertypeScore) { - bestSupertype = types[i]; - bestSupertypeDownfallType = downfallType; - bestSupertypeScore = score; - } - // types.length - 1 is the maximum score, given that getCommonSupertype returned false - if (bestSupertypeScore === types.length - 1) { - break; - } - } - // In the following errors, the {1} slot is before the {0} slot because checkTypeSubtypeOf supplies the - // subtype as the first argument to the error - checkTypeSubtypeOf(bestSupertypeDownfallType, bestSupertype, errorLocation, ts.Diagnostics.Type_argument_candidate_1_is_not_a_valid_type_argument_because_it_is_not_a_supertype_of_candidate_0, errorMessageChainHead); - } - function isArrayType(type) { - return type.flags & 4096 /* Reference */ && type.target === globalArrayType; - } - function isArrayLikeType(type) { - // A type is array-like if it is not the undefined or null type and if it is assignable to any[] - return !(type.flags & (32 /* Undefined */ | 64 /* Null */)) && isTypeAssignableTo(type, anyArrayType); - } - function isTupleLikeType(type) { - return !!getPropertyOfType(type, "0"); - } - /** - * Check if a Type was written as a tuple type literal. - * Prefer using isTupleLikeType() unless the use of `elementTypes` is required. - */ - function isTupleType(type) { - return !!(type.flags & 8192 /* Tuple */); - } - function getRegularTypeOfObjectLiteral(type) { - if (type.flags & 1048576 /* FreshObjectLiteral */) { - var regularType = type.regularType; - if (!regularType) { - regularType = createType(type.flags & ~1048576 /* FreshObjectLiteral */); - regularType.symbol = type.symbol; - regularType.members = type.members; - regularType.properties = type.properties; - regularType.callSignatures = type.callSignatures; - regularType.constructSignatures = type.constructSignatures; - regularType.stringIndexType = type.stringIndexType; - regularType.numberIndexType = type.numberIndexType; - type.regularType = regularType; - } - return regularType; - } - return type; - } - function getWidenedTypeOfObjectLiteral(type) { - var properties = getPropertiesOfObjectType(type); - var members = {}; - ts.forEach(properties, function (p) { - var propType = getTypeOfSymbol(p); - var widenedType = getWidenedType(propType); - if (propType !== widenedType) { - var symbol = createSymbol(p.flags | 67108864 /* Transient */, p.name); - symbol.declarations = p.declarations; - symbol.parent = p.parent; - symbol.type = widenedType; - symbol.target = p; - if (p.valueDeclaration) - symbol.valueDeclaration = p.valueDeclaration; - p = symbol; - } - members[p.name] = p; - }); - var stringIndexType = getIndexTypeOfType(type, 0 /* String */); - var numberIndexType = getIndexTypeOfType(type, 1 /* Number */); - if (stringIndexType) - stringIndexType = getWidenedType(stringIndexType); - if (numberIndexType) - numberIndexType = getWidenedType(numberIndexType); - return createAnonymousType(type.symbol, members, emptyArray, emptyArray, stringIndexType, numberIndexType); - } - function getWidenedType(type) { - if (type.flags & 6291456 /* RequiresWidening */) { - if (type.flags & (32 /* Undefined */ | 64 /* Null */)) { - return anyType; - } - if (type.flags & 524288 /* ObjectLiteral */) { - return getWidenedTypeOfObjectLiteral(type); - } - if (type.flags & 16384 /* Union */) { - return getUnionType(ts.map(type.types, getWidenedType), /*noSubtypeReduction*/ true); - } - if (isArrayType(type)) { - return createArrayType(getWidenedType(type.typeArguments[0])); - } - if (isTupleType(type)) { - return createTupleType(ts.map(type.elementTypes, getWidenedType)); - } - } - return type; - } - /** - * Reports implicit any errors that occur as a result of widening 'null' and 'undefined' - * to 'any'. A call to reportWideningErrorsInType is normally accompanied by a call to - * getWidenedType. But in some cases getWidenedType is called without reporting errors - * (type argument inference is an example). - * - * The return value indicates whether an error was in fact reported. The particular circumstances - * are on a best effort basis. Currently, if the null or undefined that causes widening is inside - * an object literal property (arbitrarily deeply), this function reports an error. If no error is - * reported, reportImplicitAnyError is a suitable fallback to report a general error. - */ - function reportWideningErrorsInType(type) { - var errorReported = false; - if (type.flags & 16384 /* Union */) { - for (var _i = 0, _a = type.types; _i < _a.length; _i++) { - var t = _a[_i]; - if (reportWideningErrorsInType(t)) { - errorReported = true; - } - } - } - if (isArrayType(type)) { - return reportWideningErrorsInType(type.typeArguments[0]); - } - if (isTupleType(type)) { - for (var _b = 0, _c = type.elementTypes; _b < _c.length; _b++) { - var t = _c[_b]; - if (reportWideningErrorsInType(t)) { - errorReported = true; - } - } - } - if (type.flags & 524288 /* ObjectLiteral */) { - for (var _d = 0, _e = getPropertiesOfObjectType(type); _d < _e.length; _d++) { - var p = _e[_d]; - var t = getTypeOfSymbol(p); - if (t.flags & 2097152 /* ContainsUndefinedOrNull */) { - if (!reportWideningErrorsInType(t)) { - error(p.valueDeclaration, ts.Diagnostics.Object_literal_s_property_0_implicitly_has_an_1_type, p.name, typeToString(getWidenedType(t))); - } - errorReported = true; - } - } - } - return errorReported; - } - function reportImplicitAnyError(declaration, type) { - var typeAsString = typeToString(getWidenedType(type)); - var diagnostic; - switch (declaration.kind) { - case 141 /* PropertyDeclaration */: - case 140 /* PropertySignature */: - diagnostic = ts.Diagnostics.Member_0_implicitly_has_an_1_type; - break; - case 138 /* Parameter */: - diagnostic = declaration.dotDotDotToken ? - ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type : - ts.Diagnostics.Parameter_0_implicitly_has_an_1_type; - break; - case 213 /* FunctionDeclaration */: - case 143 /* MethodDeclaration */: - case 142 /* MethodSignature */: - case 145 /* GetAccessor */: - case 146 /* SetAccessor */: - case 173 /* FunctionExpression */: - case 174 /* ArrowFunction */: - if (!declaration.name) { - error(declaration, ts.Diagnostics.Function_expression_which_lacks_return_type_annotation_implicitly_has_an_0_return_type, typeAsString); - return; - } - diagnostic = ts.Diagnostics._0_which_lacks_return_type_annotation_implicitly_has_an_1_return_type; - break; - default: - diagnostic = ts.Diagnostics.Variable_0_implicitly_has_an_1_type; - } - error(declaration, diagnostic, ts.declarationNameToString(declaration.name), typeAsString); - } - function reportErrorsFromWidening(declaration, type) { - if (produceDiagnostics && compilerOptions.noImplicitAny && type.flags & 2097152 /* ContainsUndefinedOrNull */) { - // Report implicit any error within type if possible, otherwise report error on declaration - if (!reportWideningErrorsInType(type)) { - reportImplicitAnyError(declaration, type); - } - } - } - function forEachMatchingParameterType(source, target, callback) { - var sourceMax = source.parameters.length; - var targetMax = target.parameters.length; - var count; - if (source.hasRestParameter && target.hasRestParameter) { - count = sourceMax > targetMax ? sourceMax : targetMax; - sourceMax--; - targetMax--; - } - else if (source.hasRestParameter) { - sourceMax--; - count = targetMax; - } - else if (target.hasRestParameter) { - targetMax--; - count = sourceMax; - } - else { - count = sourceMax < targetMax ? sourceMax : targetMax; - } - for (var i = 0; i < count; i++) { - var s = i < sourceMax ? getTypeOfSymbol(source.parameters[i]) : getRestTypeOfSignature(source); - var t = i < targetMax ? getTypeOfSymbol(target.parameters[i]) : getRestTypeOfSignature(target); - callback(s, t); - } - } - function createInferenceContext(typeParameters, inferUnionTypes) { - var inferences = []; - for (var _i = 0; _i < typeParameters.length; _i++) { - var unused = typeParameters[_i]; - inferences.push({ - primary: undefined, secondary: undefined, isFixed: false - }); - } - return { - typeParameters: typeParameters, - inferUnionTypes: inferUnionTypes, - inferences: inferences, - inferredTypes: new Array(typeParameters.length) - }; - } - function inferTypes(context, source, target) { - var sourceStack; - var targetStack; - var depth = 0; - var inferiority = 0; - inferFromTypes(source, target); - function isInProcess(source, target) { - for (var i = 0; i < depth; i++) { - if (source === sourceStack[i] && target === targetStack[i]) { - return true; - } - } - return false; - } - function inferFromTypes(source, target) { - if (target.flags & 512 /* TypeParameter */) { - // If target is a type parameter, make an inference, unless the source type contains - // the anyFunctionType (the wildcard type that's used to avoid contextually typing functions). - // Because the anyFunctionType is internal, it should not be exposed to the user by adding - // it as an inference candidate. Hopefully, a better candidate will come along that does - // not contain anyFunctionType when we come back to this argument for its second round - // of inference. - if (source.flags & 8388608 /* ContainsAnyFunctionType */) { - return; - } - var typeParameters = context.typeParameters; - for (var i = 0; i < typeParameters.length; i++) { - if (target === typeParameters[i]) { - var inferences = context.inferences[i]; - if (!inferences.isFixed) { - // Any inferences that are made to a type parameter in a union type are inferior - // to inferences made to a flat (non-union) type. This is because if we infer to - // T | string[], we really don't know if we should be inferring to T or not (because - // the correct constituent on the target side could be string[]). Therefore, we put - // such inferior inferences into a secondary bucket, and only use them if the primary - // bucket is empty. - var candidates = inferiority ? - inferences.secondary || (inferences.secondary = []) : - inferences.primary || (inferences.primary = []); - if (!ts.contains(candidates, source)) { - candidates.push(source); - } - } - return; - } - } - } - else if (source.flags & 4096 /* Reference */ && target.flags & 4096 /* Reference */ && source.target === target.target) { - // If source and target are references to the same generic type, infer from type arguments - var sourceTypes = source.typeArguments || emptyArray; - var targetTypes = target.typeArguments || emptyArray; - var count = sourceTypes.length < targetTypes.length ? sourceTypes.length : targetTypes.length; - for (var i = 0; i < count; i++) { - inferFromTypes(sourceTypes[i], targetTypes[i]); - } - } - else if (source.flags & 8192 /* Tuple */ && target.flags & 8192 /* Tuple */ && source.elementTypes.length === target.elementTypes.length) { - // If source and target are tuples of the same size, infer from element types - var sourceTypes = source.elementTypes; - var targetTypes = target.elementTypes; - for (var i = 0; i < sourceTypes.length; i++) { - inferFromTypes(sourceTypes[i], targetTypes[i]); - } - } - else if (target.flags & 49152 /* UnionOrIntersection */) { - var targetTypes = target.types; - var typeParameterCount = 0; - var typeParameter; - // First infer to each type in union or intersection that isn't a type parameter - for (var _i = 0; _i < targetTypes.length; _i++) { - var t = targetTypes[_i]; - if (t.flags & 512 /* TypeParameter */ && ts.contains(context.typeParameters, t)) { - typeParameter = t; - typeParameterCount++; - } - else { - inferFromTypes(source, t); - } - } - // Next, if target is a union type containing a single naked type parameter, make a - // secondary inference to that type parameter. We don't do this for intersection types - // because in a target type like Foo & T we don't know how which parts of the source type - // should be matched by Foo and which should be inferred to T. - if (target.flags & 16384 /* Union */ && typeParameterCount === 1) { - inferiority++; - inferFromTypes(source, typeParameter); - inferiority--; - } - } - else if (source.flags & 49152 /* UnionOrIntersection */) { - // Source is a union or intersection type, infer from each consituent type - var sourceTypes = source.types; - for (var _a = 0; _a < sourceTypes.length; _a++) { - var sourceType = sourceTypes[_a]; - inferFromTypes(sourceType, target); - } - } - else { - source = getApparentType(source); - if (source.flags & 80896 /* ObjectType */ && (target.flags & (4096 /* Reference */ | 8192 /* Tuple */) || - (target.flags & 65536 /* Anonymous */) && target.symbol && target.symbol.flags & (8192 /* Method */ | 2048 /* TypeLiteral */ | 32 /* Class */))) { - // If source is an object type, and target is a type reference, a tuple type, the type of a method, or a type literal, infer from members - if (isInProcess(source, target)) { - return; - } - if (isDeeplyNestedGeneric(source, sourceStack, depth) && isDeeplyNestedGeneric(target, targetStack, depth)) { - return; - } - if (depth === 0) { - sourceStack = []; - targetStack = []; - } - sourceStack[depth] = source; - targetStack[depth] = target; - depth++; - inferFromProperties(source, target); - inferFromSignatures(source, target, 0 /* Call */); - inferFromSignatures(source, target, 1 /* Construct */); - inferFromIndexTypes(source, target, 0 /* String */, 0 /* String */); - inferFromIndexTypes(source, target, 1 /* Number */, 1 /* Number */); - inferFromIndexTypes(source, target, 0 /* String */, 1 /* Number */); - depth--; - } - } - } - function inferFromProperties(source, target) { - var properties = getPropertiesOfObjectType(target); - for (var _i = 0; _i < properties.length; _i++) { - var targetProp = properties[_i]; - var sourceProp = getPropertyOfObjectType(source, targetProp.name); - if (sourceProp) { - inferFromTypes(getTypeOfSymbol(sourceProp), getTypeOfSymbol(targetProp)); - } - } - } - function inferFromSignatures(source, target, kind) { - var sourceSignatures = getSignaturesOfType(source, kind); - var targetSignatures = getSignaturesOfType(target, kind); - var sourceLen = sourceSignatures.length; - var targetLen = targetSignatures.length; - var len = sourceLen < targetLen ? sourceLen : targetLen; - for (var i = 0; i < len; i++) { - inferFromSignature(getErasedSignature(sourceSignatures[sourceLen - len + i]), getErasedSignature(targetSignatures[targetLen - len + i])); - } - } - function inferFromSignature(source, target) { - forEachMatchingParameterType(source, target, inferFromTypes); - if (source.typePredicate && target.typePredicate) { - if (target.typePredicate.parameterIndex === source.typePredicate.parameterIndex) { - // Return types from type predicates are treated as booleans. In order to infer types - // from type predicates we would need to infer using the type within the type predicate - // (i.e. 'Foo' from 'x is Foo'). - inferFromTypes(source.typePredicate.type, target.typePredicate.type); - } - } - else { - inferFromTypes(getReturnTypeOfSignature(source), getReturnTypeOfSignature(target)); - } - } - function inferFromIndexTypes(source, target, sourceKind, targetKind) { - var targetIndexType = getIndexTypeOfType(target, targetKind); - if (targetIndexType) { - var sourceIndexType = getIndexTypeOfType(source, sourceKind); - if (sourceIndexType) { - inferFromTypes(sourceIndexType, targetIndexType); - } - } - } - } - function getInferenceCandidates(context, index) { - var inferences = context.inferences[index]; - return inferences.primary || inferences.secondary || emptyArray; - } - function getInferredType(context, index) { - var inferredType = context.inferredTypes[index]; - var inferenceSucceeded; - if (!inferredType) { - var inferences = getInferenceCandidates(context, index); - if (inferences.length) { - // Infer widened union or supertype, or the unknown type for no common supertype - var unionOrSuperType = context.inferUnionTypes ? getUnionType(inferences) : getCommonSupertype(inferences); - inferredType = unionOrSuperType ? getWidenedType(unionOrSuperType) : unknownType; - inferenceSucceeded = !!unionOrSuperType; - } - else { - // Infer the empty object type when no inferences were made. It is important to remember that - // in this case, inference still succeeds, meaning there is no error for not having inference - // candidates. An inference error only occurs when there are *conflicting* candidates, i.e. - // candidates with no common supertype. - inferredType = emptyObjectType; - inferenceSucceeded = true; - } - // Only do the constraint check if inference succeeded (to prevent cascading errors) - if (inferenceSucceeded) { - var constraint = getConstraintOfTypeParameter(context.typeParameters[index]); - inferredType = constraint && !isTypeAssignableTo(inferredType, constraint) ? constraint : inferredType; - } - else if (context.failedTypeParameterIndex === undefined || context.failedTypeParameterIndex > index) { - // If inference failed, it is necessary to record the index of the failed type parameter (the one we are on). - // It might be that inference has already failed on a later type parameter on a previous call to inferTypeArguments. - // So if this failure is on preceding type parameter, this type parameter is the new failure index. - context.failedTypeParameterIndex = index; - } - context.inferredTypes[index] = inferredType; - } - return inferredType; - } - function getInferredTypes(context) { - for (var i = 0; i < context.inferredTypes.length; i++) { - getInferredType(context, i); - } - return context.inferredTypes; - } - function hasAncestor(node, kind) { - return ts.getAncestor(node, kind) !== undefined; - } - // EXPRESSION TYPE CHECKING - function getResolvedSymbol(node) { - var links = getNodeLinks(node); - if (!links.resolvedSymbol) { - links.resolvedSymbol = (!ts.nodeIsMissing(node) && resolveName(node, node.text, 107455 /* Value */ | 1048576 /* ExportValue */, ts.Diagnostics.Cannot_find_name_0, node)) || unknownSymbol; - } - return links.resolvedSymbol; - } - function isInTypeQuery(node) { - // TypeScript 1.0 spec (April 2014): 3.6.3 - // A type query consists of the keyword typeof followed by an expression. - // The expression is restricted to a single identifier or a sequence of identifiers separated by periods - while (node) { - switch (node.kind) { - case 154 /* TypeQuery */: - return true; - case 69 /* Identifier */: - case 135 /* QualifiedName */: - node = node.parent; - continue; - default: - return false; - } - } - ts.Debug.fail("should not get here"); - } - // For a union type, remove all constituent types that are of the given type kind (when isOfTypeKind is true) - // or not of the given type kind (when isOfTypeKind is false) - function removeTypesFromUnionType(type, typeKind, isOfTypeKind, allowEmptyUnionResult) { - if (type.flags & 16384 /* Union */) { - var types = type.types; - if (ts.forEach(types, function (t) { return !!(t.flags & typeKind) === isOfTypeKind; })) { - // Above we checked if we have anything to remove, now use the opposite test to do the removal - var narrowedType = getUnionType(ts.filter(types, function (t) { return !(t.flags & typeKind) === isOfTypeKind; })); - if (allowEmptyUnionResult || narrowedType !== emptyObjectType) { - return narrowedType; - } - } - } - else if (allowEmptyUnionResult && !!(type.flags & typeKind) === isOfTypeKind) { - // Use getUnionType(emptyArray) instead of emptyObjectType in case the way empty union types - // are represented ever changes. - return getUnionType(emptyArray); - } - return type; - } - function hasInitializer(node) { - return !!(node.initializer || ts.isBindingPattern(node.parent) && hasInitializer(node.parent.parent)); - } - // Check if a given variable is assigned within a given syntax node - function isVariableAssignedWithin(symbol, node) { - var links = getNodeLinks(node); - if (links.assignmentChecks) { - var cachedResult = links.assignmentChecks[symbol.id]; - if (cachedResult !== undefined) { - return cachedResult; - } - } - else { - links.assignmentChecks = {}; - } - return links.assignmentChecks[symbol.id] = isAssignedIn(node); - function isAssignedInBinaryExpression(node) { - if (node.operatorToken.kind >= 56 /* FirstAssignment */ && node.operatorToken.kind <= 68 /* LastAssignment */) { - var n = node.left; - while (n.kind === 172 /* ParenthesizedExpression */) { - n = n.expression; - } - if (n.kind === 69 /* Identifier */ && getResolvedSymbol(n) === symbol) { - return true; - } - } - return ts.forEachChild(node, isAssignedIn); - } - function isAssignedInVariableDeclaration(node) { - if (!ts.isBindingPattern(node.name) && getSymbolOfNode(node) === symbol && hasInitializer(node)) { - return true; - } - return ts.forEachChild(node, isAssignedIn); - } - function isAssignedIn(node) { - switch (node.kind) { - case 181 /* BinaryExpression */: - return isAssignedInBinaryExpression(node); - case 211 /* VariableDeclaration */: - case 163 /* BindingElement */: - return isAssignedInVariableDeclaration(node); - case 161 /* ObjectBindingPattern */: - case 162 /* ArrayBindingPattern */: - case 164 /* ArrayLiteralExpression */: - case 165 /* ObjectLiteralExpression */: - case 166 /* PropertyAccessExpression */: - case 167 /* ElementAccessExpression */: - case 168 /* CallExpression */: - case 169 /* NewExpression */: - case 171 /* TypeAssertionExpression */: - case 189 /* AsExpression */: - case 172 /* ParenthesizedExpression */: - case 179 /* PrefixUnaryExpression */: - case 175 /* DeleteExpression */: - case 178 /* AwaitExpression */: - case 176 /* TypeOfExpression */: - case 177 /* VoidExpression */: - case 180 /* PostfixUnaryExpression */: - case 184 /* YieldExpression */: - case 182 /* ConditionalExpression */: - case 185 /* SpreadElementExpression */: - case 192 /* Block */: - case 193 /* VariableStatement */: - case 195 /* ExpressionStatement */: - case 196 /* IfStatement */: - case 197 /* DoStatement */: - case 198 /* WhileStatement */: - case 199 /* ForStatement */: - case 200 /* ForInStatement */: - case 201 /* ForOfStatement */: - case 204 /* ReturnStatement */: - case 205 /* WithStatement */: - case 206 /* SwitchStatement */: - case 241 /* CaseClause */: - case 242 /* DefaultClause */: - case 207 /* LabeledStatement */: - case 208 /* ThrowStatement */: - case 209 /* TryStatement */: - case 244 /* CatchClause */: - case 233 /* JsxElement */: - case 234 /* JsxSelfClosingElement */: - case 238 /* JsxAttribute */: - case 239 /* JsxSpreadAttribute */: - case 235 /* JsxOpeningElement */: - case 240 /* JsxExpression */: - return ts.forEachChild(node, isAssignedIn); - } - return false; - } - } - // Get the narrowed type of a given symbol at a given location - function getNarrowedTypeOfSymbol(symbol, node) { - var type = getTypeOfSymbol(symbol); - // Only narrow when symbol is variable of type any or an object, union, or type parameter type - if (node && symbol.flags & 3 /* Variable */) { - if (isTypeAny(type) || type.flags & (80896 /* ObjectType */ | 16384 /* Union */ | 512 /* TypeParameter */)) { - loop: while (node.parent) { - var child = node; - node = node.parent; - var narrowedType = type; - switch (node.kind) { - case 196 /* IfStatement */: - // In a branch of an if statement, narrow based on controlling expression - if (child !== node.expression) { - narrowedType = narrowType(type, node.expression, /*assumeTrue*/ child === node.thenStatement); - } - break; - case 182 /* ConditionalExpression */: - // In a branch of a conditional expression, narrow based on controlling condition - if (child !== node.condition) { - narrowedType = narrowType(type, node.condition, /*assumeTrue*/ child === node.whenTrue); - } - break; - case 181 /* BinaryExpression */: - // In the right operand of an && or ||, narrow based on left operand - if (child === node.right) { - if (node.operatorToken.kind === 51 /* AmpersandAmpersandToken */) { - narrowedType = narrowType(type, node.left, /*assumeTrue*/ true); - } - else if (node.operatorToken.kind === 52 /* BarBarToken */) { - narrowedType = narrowType(type, node.left, /*assumeTrue*/ false); - } - } - break; - case 248 /* SourceFile */: - case 218 /* ModuleDeclaration */: - case 213 /* FunctionDeclaration */: - case 143 /* MethodDeclaration */: - case 142 /* MethodSignature */: - case 145 /* GetAccessor */: - case 146 /* SetAccessor */: - case 144 /* Constructor */: - // Stop at the first containing function or module declaration - break loop; - } - // Use narrowed type if construct contains no assignments to variable - if (narrowedType !== type) { - if (isVariableAssignedWithin(symbol, node)) { - break; - } - type = narrowedType; - } - } - } - } - return type; - function narrowTypeByEquality(type, expr, assumeTrue) { - // Check that we have 'typeof ' on the left and string literal on the right - if (expr.left.kind !== 176 /* TypeOfExpression */ || expr.right.kind !== 9 /* StringLiteral */) { - return type; - } - var left = expr.left; - var right = expr.right; - if (left.expression.kind !== 69 /* Identifier */ || getResolvedSymbol(left.expression) !== symbol) { - return type; - } - var typeInfo = primitiveTypeInfo[right.text]; - if (expr.operatorToken.kind === 33 /* ExclamationEqualsEqualsToken */) { - assumeTrue = !assumeTrue; - } - if (assumeTrue) { - // Assumed result is true. If check was not for a primitive type, remove all primitive types - if (!typeInfo) { - return removeTypesFromUnionType(type, /*typeKind*/ 258 /* StringLike */ | 132 /* NumberLike */ | 8 /* Boolean */ | 16777216 /* ESSymbol */, - /*isOfTypeKind*/ true, /*allowEmptyUnionResult*/ false); - } - // Check was for a primitive type, return that primitive type if it is a subtype - if (isTypeSubtypeOf(typeInfo.type, type)) { - return typeInfo.type; - } - // Otherwise, remove all types that aren't of the primitive type kind. This can happen when the type is - // union of enum types and other types. - return removeTypesFromUnionType(type, /*typeKind*/ typeInfo.flags, /*isOfTypeKind*/ false, /*allowEmptyUnionResult*/ false); - } - else { - // Assumed result is false. If check was for a primitive type, remove that primitive type - if (typeInfo) { - return removeTypesFromUnionType(type, /*typeKind*/ typeInfo.flags, /*isOfTypeKind*/ true, /*allowEmptyUnionResult*/ false); - } - // Otherwise we don't have enough information to do anything. - return type; - } - } - function narrowTypeByAnd(type, expr, assumeTrue) { - if (assumeTrue) { - // The assumed result is true, therefore we narrow assuming each operand to be true. - return narrowType(narrowType(type, expr.left, /*assumeTrue*/ true), expr.right, /*assumeTrue*/ true); - } - else { - // The assumed result is false. This means either the first operand was false, or the first operand was true - // and the second operand was false. We narrow with those assumptions and union the two resulting types. - return getUnionType([ - narrowType(type, expr.left, /*assumeTrue*/ false), - narrowType(narrowType(type, expr.left, /*assumeTrue*/ true), expr.right, /*assumeTrue*/ false) - ]); - } - } - function narrowTypeByOr(type, expr, assumeTrue) { - if (assumeTrue) { - // The assumed result is true. This means either the first operand was true, or the first operand was false - // and the second operand was true. We narrow with those assumptions and union the two resulting types. - return getUnionType([ - narrowType(type, expr.left, /*assumeTrue*/ true), - narrowType(narrowType(type, expr.left, /*assumeTrue*/ false), expr.right, /*assumeTrue*/ true) - ]); - } - else { - // The assumed result is false, therefore we narrow assuming each operand to be false. - return narrowType(narrowType(type, expr.left, /*assumeTrue*/ false), expr.right, /*assumeTrue*/ false); - } - } - function narrowTypeByInstanceof(type, expr, assumeTrue) { - // Check that type is not any, assumed result is true, and we have variable symbol on the left - if (isTypeAny(type) || !assumeTrue || expr.left.kind !== 69 /* Identifier */ || getResolvedSymbol(expr.left) !== symbol) { - return type; - } - // Check that right operand is a function type with a prototype property - var rightType = checkExpression(expr.right); - if (!isTypeSubtypeOf(rightType, globalFunctionType)) { - return type; - } - var targetType; - var prototypeProperty = getPropertyOfType(rightType, "prototype"); - if (prototypeProperty) { - // Target type is type of the prototype property - var prototypePropertyType = getTypeOfSymbol(prototypeProperty); - if (!isTypeAny(prototypePropertyType)) { - targetType = prototypePropertyType; - } - } - if (!targetType) { - // Target type is type of construct signature - var constructSignatures; - if (rightType.flags & 2048 /* Interface */) { - constructSignatures = resolveDeclaredMembers(rightType).declaredConstructSignatures; - } - else if (rightType.flags & 65536 /* Anonymous */) { - constructSignatures = getSignaturesOfType(rightType, 1 /* Construct */); - } - if (constructSignatures && constructSignatures.length) { - targetType = getUnionType(ts.map(constructSignatures, function (signature) { return getReturnTypeOfSignature(getErasedSignature(signature)); })); - } - } - if (targetType) { - return getNarrowedType(type, targetType); - } - return type; - } - function getNarrowedType(originalType, narrowedTypeCandidate) { - // If the current type is a union type, remove all constituents that aren't assignable to target. If that produces - // 0 candidates, fall back to the assignability check - if (originalType.flags & 16384 /* Union */) { - var assignableConstituents = ts.filter(originalType.types, function (t) { return isTypeAssignableTo(t, narrowedTypeCandidate); }); - if (assignableConstituents.length) { - return getUnionType(assignableConstituents); - } - } - if (isTypeAssignableTo(narrowedTypeCandidate, originalType)) { - // Narrow to the target type if it's assignable to the current type - return narrowedTypeCandidate; - } - return originalType; - } - function narrowTypeByTypePredicate(type, expr, assumeTrue) { - if (type.flags & 1 /* Any */) { - return type; - } - var signature = getResolvedSignature(expr); - if (signature.typePredicate && - expr.arguments[signature.typePredicate.parameterIndex] && - getSymbolAtLocation(expr.arguments[signature.typePredicate.parameterIndex]) === symbol) { - if (!assumeTrue) { - if (type.flags & 16384 /* Union */) { - return getUnionType(ts.filter(type.types, function (t) { return !isTypeSubtypeOf(t, signature.typePredicate.type); })); - } - return type; - } - return getNarrowedType(type, signature.typePredicate.type); - } - return type; - } - // Narrow the given type based on the given expression having the assumed boolean value. The returned type - // will be a subtype or the same type as the argument. - function narrowType(type, expr, assumeTrue) { - switch (expr.kind) { - case 168 /* CallExpression */: - return narrowTypeByTypePredicate(type, expr, assumeTrue); - case 172 /* ParenthesizedExpression */: - return narrowType(type, expr.expression, assumeTrue); - case 181 /* BinaryExpression */: - var operator = expr.operatorToken.kind; - if (operator === 32 /* EqualsEqualsEqualsToken */ || operator === 33 /* ExclamationEqualsEqualsToken */) { - return narrowTypeByEquality(type, expr, assumeTrue); - } - else if (operator === 51 /* AmpersandAmpersandToken */) { - return narrowTypeByAnd(type, expr, assumeTrue); - } - else if (operator === 52 /* BarBarToken */) { - return narrowTypeByOr(type, expr, assumeTrue); - } - else if (operator === 91 /* InstanceOfKeyword */) { - return narrowTypeByInstanceof(type, expr, assumeTrue); - } - break; - case 179 /* PrefixUnaryExpression */: - if (expr.operator === 49 /* ExclamationToken */) { - return narrowType(type, expr.operand, !assumeTrue); - } - break; - } - return type; - } - } - function checkIdentifier(node) { - var symbol = getResolvedSymbol(node); - // As noted in ECMAScript 6 language spec, arrow functions never have an arguments objects. - // Although in down-level emit of arrow function, we emit it using function expression which means that - // arguments objects will be bound to the inner object; emitting arrow function natively in ES6, arguments objects - // will be bound to non-arrow function that contain this arrow function. This results in inconsistent behavior. - // To avoid that we will give an error to users if they use arguments objects in arrow function so that they - // can explicitly bound arguments objects - if (symbol === argumentsSymbol) { - var container = ts.getContainingFunction(node); - if (container.kind === 174 /* ArrowFunction */) { - if (languageVersion < 2 /* ES6 */) { - error(node, ts.Diagnostics.The_arguments_object_cannot_be_referenced_in_an_arrow_function_in_ES3_and_ES5_Consider_using_a_standard_function_expression); - } - } - if (node.parserContextFlags & 8 /* Await */) { - getNodeLinks(container).flags |= 4096 /* CaptureArguments */; - getNodeLinks(node).flags |= 2048 /* LexicalArguments */; - } - } - if (symbol.flags & 8388608 /* Alias */ && !isInTypeQuery(node) && !isConstEnumOrConstEnumOnlyModule(resolveAlias(symbol))) { - markAliasSymbolAsReferenced(symbol); - } - checkCollisionWithCapturedSuperVariable(node, node); - checkCollisionWithCapturedThisVariable(node, node); - checkBlockScopedBindingCapturedInLoop(node, symbol); - return getNarrowedTypeOfSymbol(getExportSymbolOfValueSymbolIfExported(symbol), node); - } - function isInsideFunction(node, threshold) { - var current = node; - while (current && current !== threshold) { - if (ts.isFunctionLike(current)) { - return true; - } - current = current.parent; - } - return false; - } - function checkBlockScopedBindingCapturedInLoop(node, symbol) { - if (languageVersion >= 2 /* ES6 */ || - (symbol.flags & 2 /* BlockScopedVariable */) === 0 || - symbol.valueDeclaration.parent.kind === 244 /* CatchClause */) { - return; - } - // - check if binding is used in some function - // (stop the walk when reaching container of binding declaration) - // - if first check succeeded - check if variable is declared inside the loop - // nesting structure: - // (variable declaration or binding element) -> variable declaration list -> container - var container = symbol.valueDeclaration; - while (container.kind !== 212 /* VariableDeclarationList */) { - container = container.parent; - } - // get the parent of variable declaration list - container = container.parent; - if (container.kind === 193 /* VariableStatement */) { - // if parent is variable statement - get its parent - container = container.parent; - } - var inFunction = isInsideFunction(node.parent, container); - var current = container; - while (current && !ts.nodeStartsNewLexicalEnvironment(current)) { - if (isIterationStatement(current, /*lookInLabeledStatements*/ false)) { - if (inFunction) { - grammarErrorOnFirstToken(current, ts.Diagnostics.Loop_contains_block_scoped_variable_0_referenced_by_a_function_in_the_loop_This_is_only_supported_in_ECMAScript_6_or_higher, ts.declarationNameToString(node)); - } - // mark value declaration so during emit they can have a special handling - getNodeLinks(symbol.valueDeclaration).flags |= 16384 /* BlockScopedBindingInLoop */; - break; - } - current = current.parent; - } - } - function captureLexicalThis(node, container) { - getNodeLinks(node).flags |= 2 /* LexicalThis */; - if (container.kind === 141 /* PropertyDeclaration */ || container.kind === 144 /* Constructor */) { - var classNode = container.parent; - getNodeLinks(classNode).flags |= 4 /* CaptureThis */; - } - else { - getNodeLinks(container).flags |= 4 /* CaptureThis */; - } - } - function checkThisExpression(node) { - // Stop at the first arrow function so that we can - // tell whether 'this' needs to be captured. - var container = ts.getThisContainer(node, /* includeArrowFunctions */ true); - var needToCaptureLexicalThis = false; - // Now skip arrow functions to get the "real" owner of 'this'. - if (container.kind === 174 /* ArrowFunction */) { - container = ts.getThisContainer(container, /* includeArrowFunctions */ false); - // When targeting es6, arrow function lexically bind "this" so we do not need to do the work of binding "this" in emitted code - needToCaptureLexicalThis = (languageVersion < 2 /* ES6 */); - } - switch (container.kind) { - case 218 /* ModuleDeclaration */: - error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_module_or_namespace_body); - // do not return here so in case if lexical this is captured - it will be reflected in flags on NodeLinks - break; - case 217 /* EnumDeclaration */: - error(node, ts.Diagnostics.this_cannot_be_referenced_in_current_location); - // do not return here so in case if lexical this is captured - it will be reflected in flags on NodeLinks - break; - case 144 /* Constructor */: - if (isInConstructorArgumentInitializer(node, container)) { - error(node, ts.Diagnostics.this_cannot_be_referenced_in_constructor_arguments); - } - break; - case 141 /* PropertyDeclaration */: - case 140 /* PropertySignature */: - if (container.flags & 128 /* Static */) { - error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_static_property_initializer); - } - break; - case 136 /* ComputedPropertyName */: - error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_computed_property_name); - break; - } - if (needToCaptureLexicalThis) { - captureLexicalThis(node, container); - } - if (ts.isClassLike(container.parent)) { - var symbol = getSymbolOfNode(container.parent); - return container.flags & 128 /* Static */ ? getTypeOfSymbol(symbol) : getDeclaredTypeOfSymbol(symbol).thisType; - } - return anyType; - } - function isInConstructorArgumentInitializer(node, constructorDecl) { - for (var n = node; n && n !== constructorDecl; n = n.parent) { - if (n.kind === 138 /* Parameter */) { - return true; - } - } - return false; - } - function checkSuperExpression(node) { - var isCallExpression = node.parent.kind === 168 /* CallExpression */ && node.parent.expression === node; - var classDeclaration = ts.getContainingClass(node); - var classType = classDeclaration && getDeclaredTypeOfSymbol(getSymbolOfNode(classDeclaration)); - var baseClassType = classType && getBaseTypes(classType)[0]; - var container = ts.getSuperContainer(node, /*includeFunctions*/ true); - var needToCaptureLexicalThis = false; - if (!isCallExpression) { - // adjust the container reference in case if super is used inside arrow functions with arbitrary deep nesting - while (container && container.kind === 174 /* ArrowFunction */) { - container = ts.getSuperContainer(container, /*includeFunctions*/ true); - needToCaptureLexicalThis = languageVersion < 2 /* ES6 */; - } - } - var canUseSuperExpression = isLegalUsageOfSuperExpression(container); - var nodeCheckFlag = 0; - // always set NodeCheckFlags for 'super' expression node - if (canUseSuperExpression) { - if ((container.flags & 128 /* Static */) || isCallExpression) { - nodeCheckFlag = 512 /* SuperStatic */; - } - else { - nodeCheckFlag = 256 /* SuperInstance */; - } - getNodeLinks(node).flags |= nodeCheckFlag; - if (needToCaptureLexicalThis) { - // call expressions are allowed only in constructors so they should always capture correct 'this' - // super property access expressions can also appear in arrow functions - - // in this case they should also use correct lexical this - captureLexicalThis(node.parent, container); - } - } - if (!baseClassType) { - if (!classDeclaration || !ts.getClassExtendsHeritageClauseElement(classDeclaration)) { - error(node, ts.Diagnostics.super_can_only_be_referenced_in_a_derived_class); - } - return unknownType; - } - if (!canUseSuperExpression) { - if (container && container.kind === 136 /* 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 { - error(node, ts.Diagnostics.super_property_access_is_permitted_only_in_a_constructor_member_function_or_member_accessor_of_a_derived_class); - } - return unknownType; - } - if (container.kind === 144 /* Constructor */ && isInConstructorArgumentInitializer(node, container)) { - // issue custom error message for super property access in constructor arguments (to be aligned with old compiler) - error(node, ts.Diagnostics.super_cannot_be_referenced_in_constructor_arguments); - return unknownType; - } - return nodeCheckFlag === 512 /* SuperStatic */ - ? getBaseConstructorTypeOfClass(classType) - : baseClassType; - function isLegalUsageOfSuperExpression(container) { - if (!container) { - return false; - } - if (isCallExpression) { - // TS 1.0 SPEC (April 2014): 4.8.1 - // Super calls are only permitted in constructors of derived classes - return container.kind === 144 /* Constructor */; - } - else { - // TS 1.0 SPEC (April 2014) - // 'super' property access is allowed - // - 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 - if (container && ts.isClassLike(container.parent)) { - if (container.flags & 128 /* Static */) { - return container.kind === 143 /* MethodDeclaration */ || - container.kind === 142 /* MethodSignature */ || - container.kind === 145 /* GetAccessor */ || - container.kind === 146 /* SetAccessor */; - } - else { - return container.kind === 143 /* MethodDeclaration */ || - container.kind === 142 /* MethodSignature */ || - container.kind === 145 /* GetAccessor */ || - container.kind === 146 /* SetAccessor */ || - container.kind === 141 /* PropertyDeclaration */ || - container.kind === 140 /* PropertySignature */ || - container.kind === 144 /* Constructor */; - } - } - } - return false; - } - } - // Return contextual type of parameter or undefined if no contextual type is available - function getContextuallyTypedParameterType(parameter) { - var func = parameter.parent; - if (isFunctionExpressionOrArrowFunction(func) || ts.isObjectLiteralMethod(func)) { - if (isContextSensitive(func)) { - var contextualSignature = getContextualSignature(func); - if (contextualSignature) { - var funcHasRestParameters = ts.hasRestParameter(func); - var len = func.parameters.length - (funcHasRestParameters ? 1 : 0); - var indexOfParameter = ts.indexOf(func.parameters, parameter); - if (indexOfParameter < len) { - return getTypeAtPosition(contextualSignature, indexOfParameter); - } - // If last parameter is contextually rest parameter get its type - if (funcHasRestParameters && - indexOfParameter === (func.parameters.length - 1) && - isRestParameterIndex(contextualSignature, func.parameters.length - 1)) { - return getTypeOfSymbol(ts.lastOrUndefined(contextualSignature.parameters)); - } - } - } - } - return undefined; - } - // In a variable, parameter or property declaration with a type annotation, the contextual type of an initializer - // expression is the type of the variable, parameter or property. Otherwise, in a parameter declaration of a - // contextually typed function expression, the contextual type of an initializer expression is the contextual type - // of the parameter. Otherwise, in a variable or parameter declaration with a binding pattern name, the contextual - // type of an initializer expression is the type implied by the binding pattern. - function getContextualTypeForInitializerExpression(node) { - var declaration = node.parent; - if (node === declaration.initializer) { - if (declaration.type) { - return getTypeFromTypeNode(declaration.type); - } - if (declaration.kind === 138 /* Parameter */) { - var type = getContextuallyTypedParameterType(declaration); - if (type) { - return type; - } - } - if (ts.isBindingPattern(declaration.name)) { - return getTypeFromBindingPattern(declaration.name, /*includePatternInType*/ true); - } - } - return undefined; - } - function getContextualTypeForReturnExpression(node) { - var func = ts.getContainingFunction(node); - if (func && !func.asteriskToken) { - return getContextualReturnType(func); - } - return undefined; - } - function getContextualTypeForYieldOperand(node) { - var func = ts.getContainingFunction(node); - if (func) { - var contextualReturnType = getContextualReturnType(func); - if (contextualReturnType) { - return node.asteriskToken - ? contextualReturnType - : getElementTypeOfIterableIterator(contextualReturnType); - } - } - return undefined; - } - function isInParameterInitializerBeforeContainingFunction(node) { - while (node.parent && !ts.isFunctionLike(node.parent)) { - if (node.parent.kind === 138 /* Parameter */ && node.parent.initializer === node) { - return true; - } - node = node.parent; - } - return false; - } - function getContextualReturnType(functionDecl) { - // 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 === 144 /* Constructor */ || - functionDecl.kind === 145 /* GetAccessor */ && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(functionDecl.symbol, 146 /* SetAccessor */))) { - return getReturnTypeOfSignature(getSignatureFromDeclaration(functionDecl)); - } - // Otherwise, if the containing function is contextually typed by a function type with exactly one call signature - // and that call signature is non-generic, return statements are contextually typed by the return type of the signature - var signature = getContextualSignatureForFunctionLikeDeclaration(functionDecl); - if (signature) { - return getReturnTypeOfSignature(signature); - } - return undefined; - } - // In a typed function call, an argument or substitution expression is contextually typed by the type of the corresponding parameter. - function getContextualTypeForArgument(callTarget, arg) { - var args = getEffectiveCallArguments(callTarget); - var argIndex = ts.indexOf(args, arg); - if (argIndex >= 0) { - var signature = getResolvedSignature(callTarget); - return getTypeAtPosition(signature, argIndex); - } - return undefined; - } - function getContextualTypeForSubstitutionExpression(template, substitutionExpression) { - if (template.parent.kind === 170 /* TaggedTemplateExpression */) { - return getContextualTypeForArgument(template.parent, substitutionExpression); - } - return undefined; - } - function getContextualTypeForBinaryOperand(node) { - var binaryExpression = node.parent; - var operator = binaryExpression.operatorToken.kind; - if (operator >= 56 /* FirstAssignment */ && operator <= 68 /* LastAssignment */) { - // In an assignment expression, the right operand is contextually typed by the type of the left operand. - if (node === binaryExpression.right) { - return checkExpression(binaryExpression.left); - } - } - else if (operator === 52 /* BarBarToken */) { - // When an || expression has a contextual type, the operands are contextually typed by that type. When an || - // expression has no contextual type, the right operand is contextually typed by the type of the left operand. - var type = getContextualType(binaryExpression); - if (!type && node === binaryExpression.right) { - type = checkExpression(binaryExpression.left); - } - return type; - } - return undefined; - } - // Apply a mapping function to a contextual type and return the resulting type. If the contextual type - // is a union type, the mapping function is applied to each constituent type and a union of the resulting - // types is returned. - function applyToContextualType(type, mapper) { - if (!(type.flags & 16384 /* Union */)) { - return mapper(type); - } - var types = type.types; - var mappedType; - var mappedTypes; - for (var _i = 0; _i < types.length; _i++) { - var current = types[_i]; - var t = mapper(current); - if (t) { - if (!mappedType) { - mappedType = t; - } - else if (!mappedTypes) { - mappedTypes = [mappedType, t]; - } - else { - mappedTypes.push(t); - } - } - } - return mappedTypes ? getUnionType(mappedTypes) : mappedType; - } - function getTypeOfPropertyOfContextualType(type, name) { - return applyToContextualType(type, function (t) { - var prop = t.flags & 130048 /* StructuredType */ ? getPropertyOfType(t, name) : undefined; - return prop ? getTypeOfSymbol(prop) : undefined; - }); - } - function getIndexTypeOfContextualType(type, kind) { - return applyToContextualType(type, function (t) { return getIndexTypeOfStructuredType(t, kind); }); - } - // Return true if the given contextual type is a tuple-like type - function contextualTypeIsTupleLikeType(type) { - return !!(type.flags & 16384 /* Union */ ? ts.forEach(type.types, isTupleLikeType) : isTupleLikeType(type)); - } - // Return true if the given contextual type provides an index signature of the given kind - function contextualTypeHasIndexSignature(type, kind) { - return !!(type.flags & 16384 /* Union */ ? ts.forEach(type.types, function (t) { return getIndexTypeOfStructuredType(t, kind); }) : getIndexTypeOfStructuredType(type, kind)); - } - // In an object literal contextually typed by a type T, the contextual type of a property assignment is the type of - // the matching property in T, if one exists. Otherwise, it is the type of the numeric index signature in T, if one - // exists. Otherwise, it is the type of the string index signature in T, if one exists. - function getContextualTypeForObjectLiteralMethod(node) { - ts.Debug.assert(ts.isObjectLiteralMethod(node)); - if (isInsideWithStatementBody(node)) { - // We cannot answer semantic questions within a with block, do not proceed any further - return undefined; - } - return getContextualTypeForObjectLiteralElement(node); - } - function getContextualTypeForObjectLiteralElement(element) { - var objectLiteral = element.parent; - var type = getContextualType(objectLiteral); - if (type) { - if (!ts.hasDynamicName(element)) { - // For a (non-symbol) computed property, there is no reason to look up the name - // in the type. It will just be "__computed", which does not appear in any - // SymbolTable. - var symbolName = getSymbolOfNode(element).name; - var propertyType = getTypeOfPropertyOfContextualType(type, symbolName); - if (propertyType) { - return propertyType; - } - } - return isNumericName(element.name) && getIndexTypeOfContextualType(type, 1 /* Number */) || - getIndexTypeOfContextualType(type, 0 /* String */); - } - return undefined; - } - // In an array literal contextually typed by a type T, the contextual type of an element expression at index N is - // the type of the property with the numeric name N in T, if one exists. Otherwise, if T has a numeric index signature, - // it is the type of the numeric index signature in T. Otherwise, in ES6 and higher, the contextual type is the iterated - // type of T. - function getContextualTypeForElementExpression(node) { - var arrayLiteral = node.parent; - var type = getContextualType(arrayLiteral); - if (type) { - var index = ts.indexOf(arrayLiteral.elements, node); - return getTypeOfPropertyOfContextualType(type, "" + index) - || getIndexTypeOfContextualType(type, 1 /* Number */) - || (languageVersion >= 2 /* ES6 */ ? getElementTypeOfIterable(type, /*errorNode*/ undefined) : undefined); - } - return undefined; - } - // In a contextually typed conditional expression, the true/false expressions are contextually typed by the same type. - function getContextualTypeForConditionalOperand(node) { - var conditional = node.parent; - return node === conditional.whenTrue || node === conditional.whenFalse ? getContextualType(conditional) : undefined; - } - function getContextualTypeForJsxExpression(expr) { - // Contextual type only applies to JSX expressions that are in attribute assignments (not in 'Children' positions) - if (expr.parent.kind === 238 /* JsxAttribute */) { - var attrib = expr.parent; - var attrsType = getJsxElementAttributesType(attrib.parent); - if (!attrsType || isTypeAny(attrsType)) { - return undefined; - } - else { - return getTypeOfPropertyOfType(attrsType, attrib.name.text); - } - } - if (expr.kind === 239 /* JsxSpreadAttribute */) { - return getJsxElementAttributesType(expr.parent); - } - return undefined; - } - // Return the contextual type for a given expression node. During overload resolution, a contextual type may temporarily - // be "pushed" onto a node using the contextualType property. - function getContextualType(node) { - var type = getContextualTypeWorker(node); - return type && getApparentType(type); - } - function getContextualTypeWorker(node) { - if (isInsideWithStatementBody(node)) { - // We cannot answer semantic questions within a with block, do not proceed any further - return undefined; - } - if (node.contextualType) { - return node.contextualType; - } - var parent = node.parent; - switch (parent.kind) { - case 211 /* VariableDeclaration */: - case 138 /* Parameter */: - case 141 /* PropertyDeclaration */: - case 140 /* PropertySignature */: - case 163 /* BindingElement */: - return getContextualTypeForInitializerExpression(node); - case 174 /* ArrowFunction */: - case 204 /* ReturnStatement */: - return getContextualTypeForReturnExpression(node); - case 184 /* YieldExpression */: - return getContextualTypeForYieldOperand(parent); - case 168 /* CallExpression */: - case 169 /* NewExpression */: - return getContextualTypeForArgument(parent, node); - case 171 /* TypeAssertionExpression */: - case 189 /* AsExpression */: - return getTypeFromTypeNode(parent.type); - case 181 /* BinaryExpression */: - return getContextualTypeForBinaryOperand(node); - case 245 /* PropertyAssignment */: - return getContextualTypeForObjectLiteralElement(parent); - case 164 /* ArrayLiteralExpression */: - return getContextualTypeForElementExpression(node); - case 182 /* ConditionalExpression */: - return getContextualTypeForConditionalOperand(node); - case 190 /* TemplateSpan */: - ts.Debug.assert(parent.parent.kind === 183 /* TemplateExpression */); - return getContextualTypeForSubstitutionExpression(parent.parent, node); - case 172 /* ParenthesizedExpression */: - return getContextualType(parent); - case 240 /* JsxExpression */: - case 239 /* JsxSpreadAttribute */: - return getContextualTypeForJsxExpression(parent); - } - return undefined; - } - // If the given type is an object or union type, if that type has a single signature, and if - // that signature is non-generic, return the signature. Otherwise return undefined. - function getNonGenericSignature(type) { - var signatures = getSignaturesOfStructuredType(type, 0 /* Call */); - if (signatures.length === 1) { - var signature = signatures[0]; - if (!signature.typeParameters) { - return signature; - } - } - } - function isFunctionExpressionOrArrowFunction(node) { - return node.kind === 173 /* FunctionExpression */ || node.kind === 174 /* ArrowFunction */; - } - function getContextualSignatureForFunctionLikeDeclaration(node) { - // Only function expressions, arrow functions, and object literal methods are contextually typed. - return isFunctionExpressionOrArrowFunction(node) || ts.isObjectLiteralMethod(node) - ? getContextualSignature(node) - : undefined; - } - // Return the contextual signature for a given expression node. A contextual type provides a - // contextual signature if it has a single call signature and if that call signature is non-generic. - // If the contextual type is a union type, get the signature from each type possible and if they are - // 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 !== 143 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); - var type = ts.isObjectLiteralMethod(node) - ? getContextualTypeForObjectLiteralMethod(node) - : getContextualType(node); - if (!type) { - return undefined; - } - if (!(type.flags & 16384 /* Union */)) { - return getNonGenericSignature(type); - } - var signatureList; - var types = type.types; - for (var _i = 0; _i < types.length; _i++) { - var current = types[_i]; - var signature = getNonGenericSignature(current); - if (signature) { - if (!signatureList) { - // This signature will contribute to contextual union signature - signatureList = [signature]; - } - else if (!compareSignatures(signatureList[0], signature, /*partialMatch*/ false, /*ignoreReturnTypes*/ true, compareTypes)) { - // Signatures aren't identical, do not use - return undefined; - } - else { - // Use this signature for contextual union signature - signatureList.push(signature); - } - } - } - // Result is union of signatures collected (return type is union of return types of this signature set) - var result; - if (signatureList) { - result = cloneSignature(signatureList[0]); - // Clear resolved return type we possibly got from cloneSignature - result.resolvedReturnType = undefined; - result.unionSignatures = signatureList; - } - return result; - } - /** - * Detect if the mapper implies an inference context. Specifically, there are 4 possible values - * for a mapper. Let's go through each one of them: - * - * 1. undefined - this means we are not doing inferential typing, but we may do contextual typing, - * which could cause us to assign a parameter a type - * 2. identityMapper - means we want to avoid assigning a parameter a type, whether or not we are in - * inferential typing (context is undefined for the identityMapper) - * 3. a mapper created by createInferenceMapper - we are doing inferential typing, we want to assign - * types to parameters and fix type parameters (context is defined) - * 4. an instantiation mapper created by createTypeMapper or createTypeEraser - this should never be - * passed as the contextual mapper when checking an expression (context is undefined for these) - * - * isInferentialContext is detecting if we are in case 3 - */ - function isInferentialContext(mapper) { - return mapper && mapper.context; - } - // A node is an assignment target if it is on the left hand side of an '=' token, if it is parented by a property - // 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) { - var parent = node.parent; - if (parent.kind === 181 /* BinaryExpression */ && parent.operatorToken.kind === 56 /* EqualsToken */ && parent.left === node) { - return true; - } - if (parent.kind === 245 /* PropertyAssignment */) { - return isAssignmentTarget(parent.parent); - } - if (parent.kind === 164 /* ArrayLiteralExpression */) { - return isAssignmentTarget(parent); - } - return false; - } - function checkSpreadElementExpression(node, contextualMapper) { - // It is usually not safe to call checkExpressionCached if we can be contextually typing. - // You can tell that we are contextually typing because of the contextualMapper parameter. - // While it is true that a spread element can have a contextual type, it does not do anything - // with this type. It is neither affected by it, nor does it propagate it to its operand. - // So the fact that contextualMapper is passed is not important, because the operand of a spread - // element is not contextually typed. - var arrayOrIterableType = checkExpressionCached(node.expression, contextualMapper); - return checkIteratedTypeOrElementType(arrayOrIterableType, node.expression, /*allowStringInput*/ false); - } - function hasDefaultValue(node) { - return (node.kind === 163 /* BindingElement */ && !!node.initializer) || - (node.kind === 181 /* BinaryExpression */ && node.operatorToken.kind === 56 /* EqualsToken */); - } - function checkArrayLiteral(node, contextualMapper) { - var elements = node.elements; - var hasSpreadElement = false; - var elementTypes = []; - var inDestructuringPattern = isAssignmentTarget(node); - for (var _i = 0; _i < elements.length; _i++) { - var e = elements[_i]; - if (inDestructuringPattern && e.kind === 185 /* SpreadElementExpression */) { - // Given the following situation: - // var c: {}; - // [...c] = ["", 0]; - // - // c is represented in the tree as a spread element in an array literal. - // But c really functions as a rest element, and its purpose is to provide - // a contextual type for the right hand side of the assignment. Therefore, - // instead of calling checkExpression on "...c", which will give an error - // if c is not iterable/array-like, we need to act as if we are trying to - // get the contextual element type from it. So we do something similar to - // getContextualTypeForElementExpression, which will crucially not error - // 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); - if (restElementType) { - elementTypes.push(restElementType); - } - } - else { - var type = checkExpression(e, contextualMapper); - elementTypes.push(type); - } - hasSpreadElement = hasSpreadElement || e.kind === 185 /* SpreadElementExpression */; - } - if (!hasSpreadElement) { - // If array literal is actually a destructuring pattern, mark it as an implied type. We do this such - // that we get the same behavior for "var [x, y] = []" and "[x, y] = []". - if (inDestructuringPattern && elementTypes.length) { - var type = createNewTupleType(elementTypes); - type.pattern = node; - return type; - } - var contextualType = getContextualType(node); - if (contextualType && contextualTypeIsTupleLikeType(contextualType)) { - 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 === 162 /* ArrayBindingPattern */ || pattern.kind === 164 /* ArrayLiteralExpression */)) { - var patternElements = pattern.elements; - for (var i = elementTypes.length; i < patternElements.length; i++) { - var patternElement = patternElements[i]; - if (hasDefaultValue(patternElement)) { - elementTypes.push(contextualType.elementTypes[i]); - } - else { - if (patternElement.kind !== 187 /* OmittedExpression */) { - error(patternElement, ts.Diagnostics.Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value); - } - elementTypes.push(unknownType); - } - } - } - if (elementTypes.length) { - return createTupleType(elementTypes); - } - } - } - return createArrayType(elementTypes.length ? getUnionType(elementTypes) : undefinedType); - } - function isNumericName(name) { - return name.kind === 136 /* ComputedPropertyName */ ? isNumericComputedName(name) : isNumericLiteralName(name.text); - } - function isNumericComputedName(name) { - // It seems odd to consider an expression of type Any to result in a numeric name, - // but this behavior is consistent with checkIndexedAccess - return isTypeAnyOrAllConstituentTypesHaveKind(checkComputedPropertyName(name), 132 /* NumberLike */); - } - function isTypeAnyOrAllConstituentTypesHaveKind(type, kind) { - return isTypeAny(type) || allConstituentTypesHaveKind(type, kind); - } - function isNumericLiteralName(name) { - // The intent of numeric names is that - // - they are names with text in a numeric form, and that - // - setting properties/indexing with them is always equivalent to doing so with the numeric literal 'numLit', - // acquired by applying the abstract 'ToNumber' operation on the name's text. - // - // The subtlety is in the latter portion, as we cannot reliably say that anything that looks like a numeric literal is a numeric name. - // In fact, it is the case that the text of the name must be equal to 'ToString(numLit)' for this to hold. - // - // Consider the property name '"0xF00D"'. When one indexes with '0xF00D', they are actually indexing with the value of 'ToString(0xF00D)' - // according to the ECMAScript specification, so it is actually as if the user indexed with the string '"61453"'. - // Thus, the text of all numeric literals equivalent to '61543' such as '0xF00D', '0xf00D', '0170015', etc. are not valid numeric names - // because their 'ToString' representation is not equal to their original text. - // This is motivated by ECMA-262 sections 9.3.1, 9.8.1, 11.1.5, and 11.2.1. - // - // Here, we test whether 'ToString(ToNumber(name))' is exactly equal to 'name'. - // The '+' prefix operator is equivalent here to applying the abstract ToNumber operation. - // Applying the 'toString()' method on a number gives us the abstract ToString operation on a number. - // - // Note that this accepts the values 'Infinity', '-Infinity', and 'NaN', and that this is intentional. - // This is desired behavior, because when indexing with them as numeric entities, you are indexing - // with the strings '"Infinity"', '"-Infinity"', and '"NaN"' respectively. - return (+name).toString() === name; - } - function checkComputedPropertyName(node) { - var links = getNodeLinks(node.expression); - if (!links.resolvedType) { - links.resolvedType = checkExpression(node.expression); - // This will allow types number, string, symbol or any. It will also allow enums, the unknown - // type, and any union of these types (like string | number). - if (!isTypeAnyOrAllConstituentTypesHaveKind(links.resolvedType, 132 /* NumberLike */ | 258 /* StringLike */ | 16777216 /* ESSymbol */)) { - error(node, ts.Diagnostics.A_computed_property_name_must_be_of_type_string_number_symbol_or_any); - } - else { - checkThatExpressionIsProperSymbolReference(node.expression, links.resolvedType, /*reportError*/ true); - } - } - return links.resolvedType; - } - function checkObjectLiteral(node, contextualMapper) { - var inDestructuringPattern = isAssignmentTarget(node); - // Grammar checking - checkGrammarObjectLiteralExpression(node, inDestructuringPattern); - var propertiesTable = {}; - var propertiesArray = []; - var contextualType = getContextualType(node); - var contextualTypeHasPattern = contextualType && contextualType.pattern && - (contextualType.pattern.kind === 161 /* ObjectBindingPattern */ || contextualType.pattern.kind === 165 /* ObjectLiteralExpression */); - var typeFlags = 0; - for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { - var memberDecl = _a[_i]; - var member = memberDecl.symbol; - if (memberDecl.kind === 245 /* PropertyAssignment */ || - memberDecl.kind === 246 /* ShorthandPropertyAssignment */ || - ts.isObjectLiteralMethod(memberDecl)) { - var type = void 0; - if (memberDecl.kind === 245 /* PropertyAssignment */) { - type = checkPropertyAssignment(memberDecl, contextualMapper); - } - else if (memberDecl.kind === 143 /* MethodDeclaration */) { - type = checkObjectLiteralMethod(memberDecl, contextualMapper); - } - else { - ts.Debug.assert(memberDecl.kind === 246 /* ShorthandPropertyAssignment */); - type = checkExpression(memberDecl.name, contextualMapper); - } - typeFlags |= type.flags; - var prop = createSymbol(4 /* Property */ | 67108864 /* Transient */ | member.flags, member.name); - if (inDestructuringPattern) { - // If object literal is an assignment pattern and if the assignment pattern specifies a default value - // for the property, make the property optional. - var isOptional = (memberDecl.kind === 245 /* PropertyAssignment */ && hasDefaultValue(memberDecl.initializer)) || - (memberDecl.kind === 246 /* ShorthandPropertyAssignment */ && memberDecl.objectAssignmentInitializer); - if (isOptional) { - prop.flags |= 536870912 /* Optional */; - } - } - else if (contextualTypeHasPattern) { - // 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); - if (impliedProp) { - prop.flags |= impliedProp.flags & 536870912 /* Optional */; - } - else if (!compilerOptions.suppressExcessPropertyErrors) { - error(memberDecl.name, ts.Diagnostics.Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1, symbolToString(member), typeToString(contextualType)); - } - } - prop.declarations = member.declarations; - prop.parent = member.parent; - if (member.valueDeclaration) { - prop.valueDeclaration = member.valueDeclaration; - } - prop.type = type; - prop.target = member; - member = prop; - } - else { - // TypeScript 1.0 spec (April 2014) - // A get accessor declaration is processed in the same manner as - // 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 === 145 /* GetAccessor */ || memberDecl.kind === 146 /* SetAccessor */); - checkAccessorDeclaration(memberDecl); - } - if (!ts.hasDynamicName(memberDecl)) { - propertiesTable[member.name] = member; - } - propertiesArray.push(member); - } - // If object literal is contextually typed by the implied type of a binding pattern, augment the result - // type with those properties for which the binding pattern specifies a default value. - if (contextualTypeHasPattern) { - for (var _b = 0, _c = getPropertiesOfType(contextualType); _b < _c.length; _b++) { - var prop = _c[_b]; - if (!ts.hasProperty(propertiesTable, prop.name)) { - if (!(prop.flags & 536870912 /* Optional */)) { - error(prop.valueDeclaration || prop.bindingElement, ts.Diagnostics.Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value); - } - propertiesTable[prop.name] = prop; - propertiesArray.push(prop); - } - } - } - var stringIndexType = getIndexType(0 /* String */); - var numberIndexType = getIndexType(1 /* Number */); - var result = createAnonymousType(node.symbol, propertiesTable, emptyArray, emptyArray, stringIndexType, numberIndexType); - var freshObjectLiteralFlag = compilerOptions.suppressExcessPropertyErrors ? 0 : 1048576 /* FreshObjectLiteral */; - result.flags |= 524288 /* ObjectLiteral */ | 4194304 /* ContainsObjectLiteral */ | freshObjectLiteralFlag | (typeFlags & 14680064 /* PropagatingFlags */); - if (inDestructuringPattern) { - result.pattern = node; - } - return result; - function getIndexType(kind) { - if (contextualType && contextualTypeHasIndexSignature(contextualType, kind)) { - var propTypes = []; - for (var i = 0; i < propertiesArray.length; i++) { - var propertyDecl = node.properties[i]; - if (kind === 0 /* String */ || isNumericName(propertyDecl.name)) { - // Do not call getSymbolOfNode(propertyDecl), as that will get the - // original symbol for the node. We actually want to get the symbol - // created by checkObjectLiteral, since that will be appropriately - // contextually typed and resolved. - var type = getTypeOfSymbol(propertiesArray[i]); - if (!ts.contains(propTypes, type)) { - propTypes.push(type); - } - } - } - var result_1 = propTypes.length ? getUnionType(propTypes) : undefinedType; - typeFlags |= result_1.flags; - return result_1; - } - return undefined; - } - } - function checkJsxSelfClosingElement(node) { - checkJsxOpeningLikeElement(node); - return jsxElementType || anyType; - } - function tagNamesAreEquivalent(lhs, rhs) { - if (lhs.kind !== rhs.kind) { - return false; - } - if (lhs.kind === 69 /* Identifier */) { - return lhs.text === rhs.text; - } - return lhs.right.text === rhs.right.text && - tagNamesAreEquivalent(lhs.left, rhs.left); - } - function checkJsxElement(node) { - // Check attributes - checkJsxOpeningLikeElement(node.openingElement); - // Check that the closing tag matches - if (!tagNamesAreEquivalent(node.openingElement.tagName, node.closingElement.tagName)) { - error(node.closingElement, ts.Diagnostics.Expected_corresponding_JSX_closing_tag_for_0, ts.getTextOfNode(node.openingElement.tagName)); - } - else { - // Perform resolution on the closing tag so that rename/go to definition/etc work - getJsxElementTagSymbol(node.closingElement); - } - // Check children - for (var _i = 0, _a = node.children; _i < _a.length; _i++) { - var child = _a[_i]; - switch (child.kind) { - case 240 /* JsxExpression */: - checkJsxExpression(child); - break; - case 233 /* JsxElement */: - checkJsxElement(child); - break; - case 234 /* JsxSelfClosingElement */: - checkJsxSelfClosingElement(child); - break; - } - } - return jsxElementType || anyType; - } - /** - * Returns true iff the JSX element name would be a valid JS identifier, ignoring restrictions about keywords not being identifiers - */ - function isUnhyphenatedJsxName(name) { - // - is the only character supported in JSX attribute names that isn't valid in JavaScript identifiers - return name.indexOf("-") < 0; - } - /** - * Returns true iff React would emit this tag name as a string rather than an identifier or qualified name - */ - function isJsxIntrinsicIdentifier(tagName) { - if (tagName.kind === 135 /* QualifiedName */) { - return false; - } - else { - return ts.isIntrinsicJsxName(tagName.text); - } - } - function checkJsxAttribute(node, elementAttributesType, nameTable) { - var correspondingPropType = undefined; - // Look up the corresponding property for this attribute - if (elementAttributesType === emptyObjectType && isUnhyphenatedJsxName(node.name.text)) { - // If there is no 'props' property, you may not have non-"data-" attributes - error(node.parent, ts.Diagnostics.JSX_element_class_does_not_support_attributes_because_it_does_not_have_a_0_property, getJsxElementPropertiesName()); - } - else if (elementAttributesType && !isTypeAny(elementAttributesType)) { - var correspondingPropSymbol = getPropertyOfType(elementAttributesType, node.name.text); - correspondingPropType = correspondingPropSymbol && getTypeOfSymbol(correspondingPropSymbol); - if (isUnhyphenatedJsxName(node.name.text)) { - // Maybe there's a string indexer? - var indexerType = getIndexTypeOfType(elementAttributesType, 0 /* String */); - if (indexerType) { - correspondingPropType = indexerType; - } - else { - // If there's no corresponding property with this name, error - if (!correspondingPropType) { - error(node.name, ts.Diagnostics.Property_0_does_not_exist_on_type_1, node.name.text, typeToString(elementAttributesType)); - return unknownType; - } - } - } - } - var exprType; - if (node.initializer) { - exprType = checkExpression(node.initializer); - } - else { - // is sugar for - exprType = booleanType; - } - if (correspondingPropType) { - checkTypeAssignableTo(exprType, correspondingPropType, node); - } - nameTable[node.name.text] = true; - return exprType; - } - function checkJsxSpreadAttribute(node, elementAttributesType, nameTable) { - var type = checkExpression(node.expression); - var props = getPropertiesOfType(type); - for (var _i = 0; _i < props.length; _i++) { - var prop = props[_i]; - // Is there a corresponding property in the element attributes type? Skip checking of properties - // that have already been assigned to, as these are not actually pushed into the resulting type - if (!nameTable[prop.name]) { - var targetPropSym = getPropertyOfType(elementAttributesType, prop.name); - if (targetPropSym) { - var msg = ts.chainDiagnosticMessages(undefined, ts.Diagnostics.Property_0_of_JSX_spread_attribute_is_not_assignable_to_target_property, prop.name); - checkTypeAssignableTo(getTypeOfSymbol(prop), getTypeOfSymbol(targetPropSym), node, undefined, msg); - } - nameTable[prop.name] = true; - } - } - return type; - } - /// Returns the type JSX.IntrinsicElements. May return `unknownType` if that type is not present. - function getJsxIntrinsicElementsType() { - if (!jsxIntrinsicElementsType) { - jsxIntrinsicElementsType = getExportedTypeFromNamespace(JsxNames.JSX, JsxNames.IntrinsicElements) || unknownType; - } - return jsxIntrinsicElementsType; - } - /// Given a JSX opening element or self-closing element, return the symbol of the property that the tag name points to if - /// this is an intrinsic tag. This might be a named - /// property of the IntrinsicElements interface, or its string indexer. - /// If this is a class-based tag (otherwise returns undefined), returns the symbol of the class - /// type or factory function. - /// Otherwise, returns unknownSymbol. - function getJsxElementTagSymbol(node) { - var flags = 8 /* UnknownElement */; - var links = getNodeLinks(node); - if (!links.resolvedSymbol) { - if (isJsxIntrinsicIdentifier(node.tagName)) { - links.resolvedSymbol = lookupIntrinsicTag(node); - } - else { - links.resolvedSymbol = lookupClassTag(node); - } - } - return links.resolvedSymbol; - function lookupIntrinsicTag(node) { - var intrinsicElementsType = getJsxIntrinsicElementsType(); - if (intrinsicElementsType !== unknownType) { - // Property case - var intrinsicProp = getPropertyOfType(intrinsicElementsType, node.tagName.text); - if (intrinsicProp) { - links.jsxFlags |= 1 /* IntrinsicNamedElement */; - return intrinsicProp; - } - // Intrinsic string indexer case - var indexSignatureType = getIndexTypeOfType(intrinsicElementsType, 0 /* String */); - if (indexSignatureType) { - links.jsxFlags |= 2 /* IntrinsicIndexedElement */; - return intrinsicElementsType.symbol; - } - // Wasn't found - error(node, ts.Diagnostics.Property_0_does_not_exist_on_type_1, node.tagName.text, "JSX." + JsxNames.IntrinsicElements); - return unknownSymbol; - } - else { - if (compilerOptions.noImplicitAny) { - error(node, ts.Diagnostics.JSX_element_implicitly_has_type_any_because_no_interface_JSX_0_exists, JsxNames.IntrinsicElements); - } - } - } - function lookupClassTag(node) { - var valueSymbol = resolveJsxTagName(node); - // Look up the value in the current scope - if (valueSymbol && valueSymbol !== unknownSymbol) { - links.jsxFlags |= 4 /* ClassElement */; - if (valueSymbol.flags & 8388608 /* Alias */) { - markAliasSymbolAsReferenced(valueSymbol); - } - } - return valueSymbol || unknownSymbol; - } - function resolveJsxTagName(node) { - if (node.tagName.kind === 69 /* Identifier */) { - var tag = node.tagName; - var sym = getResolvedSymbol(tag); - return sym.exportSymbol || sym; - } - else { - return checkQualifiedName(node.tagName).symbol; - } - } - } - /** - * Given a JSX element that is a class element, finds the Element Instance Type. If the - * element is not a class element, or the class element type cannot be determined, returns 'undefined'. - * For example, in the element , the element instance type is `MyClass` (not `typeof MyClass`). - */ - function getJsxElementInstanceType(node) { - // There is no such thing as an instance type for a non-class element. This - // line shouldn't be hit. - ts.Debug.assert(!!(getNodeLinks(node).jsxFlags & 4 /* ClassElement */), "Should not call getJsxElementInstanceType on non-class Element"); - var classSymbol = getJsxElementTagSymbol(node); - if (classSymbol === unknownSymbol) { - // Couldn't find the class instance type. Error has already been issued - return anyType; - } - var valueType = getTypeOfSymbol(classSymbol); - if (isTypeAny(valueType)) { - // Short-circuit if the class tag is using an element type 'any' - return anyType; - } - // Resolve the signatures, preferring constructors - var signatures = getSignaturesOfType(valueType, 1 /* Construct */); - if (signatures.length === 0) { - // No construct signatures, try call signatures - signatures = getSignaturesOfType(valueType, 0 /* Call */); - if (signatures.length === 0) { - // We found no signatures at all, which is an error - error(node.tagName, ts.Diagnostics.JSX_element_type_0_does_not_have_any_construct_or_call_signatures, ts.getTextOfNode(node.tagName)); - return unknownType; - } - } - var returnType = getUnionType(signatures.map(getReturnTypeOfSignature)); - // Issue an error if this return type isn't assignable to JSX.ElementClass - var elemClassType = getJsxGlobalElementClassType(); - if (elemClassType) { - checkTypeRelatedTo(returnType, elemClassType, assignableRelation, node, ts.Diagnostics.JSX_element_type_0_is_not_a_constructor_function_for_JSX_elements); - } - return returnType; - } - /// e.g. "props" for React.d.ts, - /// or 'undefined' if ElementAttributesPropery doesn't exist (which means all - /// non-intrinsic elements' attributes type is 'any'), - /// or '' if it has 0 properties (which means every - /// non-instrinsic elements' attributes type is the element instance type) - function getJsxElementPropertiesName() { - // JSX - var jsxNamespace = getGlobalSymbol(JsxNames.JSX, 1536 /* Namespace */, /*diagnosticMessage*/ undefined); - // JSX.ElementAttributesProperty [symbol] - var attribsPropTypeSym = jsxNamespace && getSymbol(jsxNamespace.exports, JsxNames.ElementAttributesPropertyNameContainer, 793056 /* Type */); - // JSX.ElementAttributesProperty [type] - var attribPropType = attribsPropTypeSym && getDeclaredTypeOfSymbol(attribsPropTypeSym); - // The properites of JSX.ElementAttributesProperty - var attribProperties = attribPropType && getPropertiesOfType(attribPropType); - if (attribProperties) { - // Element Attributes has zero properties, so the element attributes type will be the class instance type - if (attribProperties.length === 0) { - return ""; - } - else if (attribProperties.length === 1) { - return attribProperties[0].name; - } - else { - error(attribsPropTypeSym.declarations[0], ts.Diagnostics.The_global_type_JSX_0_may_not_have_more_than_one_property, JsxNames.ElementAttributesPropertyNameContainer); - return undefined; - } - } - else { - // No interface exists, so the element attributes type will be an implicit any - return undefined; - } - } - /** - * Given an opening/self-closing element, get the 'element attributes type', i.e. the type that tells - * us which attributes are valid on a given element. - */ - function getJsxElementAttributesType(node) { - var links = getNodeLinks(node); - if (!links.resolvedJsxType) { - var sym = getJsxElementTagSymbol(node); - if (links.jsxFlags & 4 /* ClassElement */) { - var elemInstanceType = getJsxElementInstanceType(node); - if (isTypeAny(elemInstanceType)) { - return links.resolvedJsxType = elemInstanceType; - } - var propsName = getJsxElementPropertiesName(); - if (propsName === undefined) { - // There is no type ElementAttributesProperty, return 'any' - return links.resolvedJsxType = anyType; - } - else if (propsName === "") { - // If there is no e.g. 'props' member in ElementAttributesProperty, use the element class type instead - return links.resolvedJsxType = elemInstanceType; - } - else { - var attributesType = getTypeOfPropertyOfType(elemInstanceType, propsName); - if (!attributesType) { - // There is no property named 'props' on this instance type - return links.resolvedJsxType = emptyObjectType; - } - else if (isTypeAny(attributesType) || (attributesType === unknownType)) { - return links.resolvedJsxType = attributesType; - } - else if (!(attributesType.flags & 80896 /* ObjectType */)) { - error(node.tagName, ts.Diagnostics.JSX_element_attributes_type_0_must_be_an_object_type, typeToString(attributesType)); - return links.resolvedJsxType = anyType; - } - else { - return links.resolvedJsxType = attributesType; - } - } - } - else if (links.jsxFlags & 1 /* IntrinsicNamedElement */) { - return links.resolvedJsxType = getTypeOfSymbol(sym); - } - else if (links.jsxFlags & 2 /* IntrinsicIndexedElement */) { - return links.resolvedJsxType = getIndexTypeOfSymbol(sym, 0 /* String */); - } - else { - // Resolution failed, so we don't know - return links.resolvedJsxType = anyType; - } - } - return links.resolvedJsxType; - } - /** - * Given a JSX attribute, returns the symbol for the corresponds property - * of the element attributes type. Will return unknownSymbol for attributes - * that have no matching element attributes type property. - */ - function getJsxAttributePropertySymbol(attrib) { - var attributesType = getJsxElementAttributesType(attrib.parent); - var prop = getPropertyOfType(attributesType, attrib.name.text); - return prop || unknownSymbol; - } - var jsxElementClassType = undefined; - function getJsxGlobalElementClassType() { - if (!jsxElementClassType) { - jsxElementClassType = getExportedTypeFromNamespace(JsxNames.JSX, JsxNames.ElementClass); - } - return jsxElementClassType; - } - /// Returns all the properties of the Jsx.IntrinsicElements interface - function getJsxIntrinsicTagNames() { - var intrinsics = getJsxIntrinsicElementsType(); - return intrinsics ? getPropertiesOfType(intrinsics) : emptyArray; - } - function checkJsxPreconditions(errorNode) { - // Preconditions for using JSX - if ((compilerOptions.jsx || 0 /* None */) === 0 /* None */) { - error(errorNode, ts.Diagnostics.Cannot_use_JSX_unless_the_jsx_flag_is_provided); - } - if (jsxElementType === undefined) { - if (compilerOptions.noImplicitAny) { - error(errorNode, ts.Diagnostics.JSX_element_implicitly_has_type_any_because_the_global_type_JSX_Element_does_not_exist); - } - } - } - function checkJsxOpeningLikeElement(node) { - checkGrammarJsxElement(node); - checkJsxPreconditions(node); - // If we're compiling under --jsx react, the symbol 'React' should - // be marked as 'used' so we don't incorrectly elide its import. And if there - // is no 'React' symbol in scope, we should issue an error. - if (compilerOptions.jsx === 2 /* React */) { - var reactSym = resolveName(node.tagName, "React", 107455 /* Value */, ts.Diagnostics.Cannot_find_name_0, "React"); - if (reactSym) { - getSymbolLinks(reactSym).referenced = true; - } - } - var targetAttributesType = getJsxElementAttributesType(node); - var nameTable = {}; - // Process this array in right-to-left order so we know which - // attributes (mostly from spreads) are being overwritten and - // thus should have their types ignored - var sawSpreadedAny = false; - for (var i = node.attributes.length - 1; i >= 0; i--) { - if (node.attributes[i].kind === 238 /* JsxAttribute */) { - checkJsxAttribute((node.attributes[i]), targetAttributesType, nameTable); - } - else { - ts.Debug.assert(node.attributes[i].kind === 239 /* JsxSpreadAttribute */); - var spreadType = checkJsxSpreadAttribute((node.attributes[i]), targetAttributesType, nameTable); - if (isTypeAny(spreadType)) { - sawSpreadedAny = true; - } - } - } - // Check that all required properties have been provided. If an 'any' - // was spreaded in, though, assume that it provided all required properties - if (targetAttributesType && !sawSpreadedAny) { - var targetProperties = getPropertiesOfType(targetAttributesType); - for (var i = 0; i < targetProperties.length; i++) { - if (!(targetProperties[i].flags & 536870912 /* Optional */) && - nameTable[targetProperties[i].name] === undefined) { - error(node, ts.Diagnostics.Property_0_is_missing_in_type_1, targetProperties[i].name, typeToString(targetAttributesType)); - } - } - } - } - function checkJsxExpression(node) { - if (node.expression) { - return checkExpression(node.expression); - } - else { - return unknownType; - } - } - // 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 : 141 /* PropertyDeclaration */; - } - function getDeclarationFlagsFromSymbol(s) { - return s.valueDeclaration ? ts.getCombinedNodeFlags(s.valueDeclaration) : s.flags & 134217728 /* Prototype */ ? 16 /* Public */ | 128 /* Static */ : 0; - } - /** - * Check whether the requested property access is valid. - * Returns true if node is a valid property access, and false otherwise. - * @param node The node to be checked. - * @param left The left hand side of the property access (e.g.: the super in `super.foo`). - * @param type The type of left. - * @param prop The symbol for the right hand side of the property access. - */ - function checkClassPropertyAccess(node, left, type, prop) { - var flags = getDeclarationFlagsFromSymbol(prop); - var declaringClass = getDeclaredTypeOfSymbol(prop.parent); - if (left.kind === 95 /* SuperKeyword */) { - var errorNode = node.kind === 166 /* PropertyAccessExpression */ ? - node.name : - node.right; - // 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, - // a super property access is permitted and must specify a public instance member function of the base class. - // - In a static member function or static member accessor - // where this references the constructor function object of a derived class, - // a super property access is permitted and must specify a public static member function of the base class. - if (getDeclarationKindFromSymbol(prop) !== 143 /* MethodDeclaration */) { - // `prop` refers to a *property* declared in the super class - // rather than a *method*, so it does not satisfy the above criteria. - error(errorNode, ts.Diagnostics.Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword); - return false; - } - if (flags & 256 /* Abstract */) { - // A method cannot be accessed in a super property access if the method is abstract. - // This error could mask a private property access error. But, a member - // cannot simultaneously be private and abstract, so this will trigger an - // additional error elsewhere. - error(errorNode, ts.Diagnostics.Abstract_method_0_in_class_1_cannot_be_accessed_via_super_expression, symbolToString(prop), typeToString(declaringClass)); - return false; - } - } - // Public properties are otherwise accessible. - if (!(flags & (32 /* Private */ | 64 /* Protected */))) { - return true; - } - // Property is known to be private or protected at this point - // Get the declaring and enclosing class instance types - var enclosingClassDeclaration = ts.getContainingClass(node); - var enclosingClass = enclosingClassDeclaration ? getDeclaredTypeOfSymbol(getSymbolOfNode(enclosingClassDeclaration)) : undefined; - // Private property is accessible if declaring and enclosing class are the same - if (flags & 32 /* Private */) { - if (declaringClass !== enclosingClass) { - error(node, ts.Diagnostics.Property_0_is_private_and_only_accessible_within_class_1, symbolToString(prop), typeToString(declaringClass)); - return false; - } - return true; - } - // 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 */) { - return true; - } - // A protected property is accessible in the declaring class and classes derived from it - if (!enclosingClass || !hasBaseType(enclosingClass, declaringClass)) { - error(node, ts.Diagnostics.Property_0_is_protected_and_only_accessible_within_class_1_and_its_subclasses, symbolToString(prop), typeToString(declaringClass)); - return false; - } - // No further restrictions for static properties - if (flags & 128 /* Static */) { - return true; - } - // An instance property must be accessed through an instance of the enclosing class - if (type.flags & 33554432 /* ThisType */) { - // get the original type -- represented as the type constraint of the 'this' type - type = getConstraintOfTypeParameter(type); - } - // TODO: why is the first part of this check here? - if (!(getTargetType(type).flags & (1024 /* Class */ | 2048 /* Interface */) && hasBaseType(type, enclosingClass))) { - error(node, ts.Diagnostics.Property_0_is_protected_and_only_accessible_through_an_instance_of_class_1, symbolToString(prop), typeToString(enclosingClass)); - return false; - } - return true; - } - function checkPropertyAccessExpression(node) { - return checkPropertyAccessExpressionOrQualifiedName(node, node.expression, node.name); - } - function checkQualifiedName(node) { - return checkPropertyAccessExpressionOrQualifiedName(node, node.left, node.right); - } - function checkPropertyAccessExpressionOrQualifiedName(node, left, right) { - var type = checkExpression(left); - if (isTypeAny(type)) { - return type; - } - var apparentType = getApparentType(getWidenedType(type)); - if (apparentType === unknownType) { - // handle cases when type is Type parameter with invalid constraint - return unknownType; - } - var prop = getPropertyOfType(apparentType, right.text); - if (!prop) { - if (right.text) { - error(right, ts.Diagnostics.Property_0_does_not_exist_on_type_1, ts.declarationNameToString(right), typeToString(type.flags & 33554432 /* ThisType */ ? apparentType : type)); - } - return unknownType; - } - getNodeLinks(node).resolvedSymbol = prop; - if (prop.parent && prop.parent.flags & 32 /* Class */) { - checkClassPropertyAccess(node, left, apparentType, prop); - } - return getTypeOfSymbol(prop); - } - function isValidPropertyAccess(node, propertyName) { - var left = node.kind === 166 /* PropertyAccessExpression */ - ? node.expression - : node.left; - var type = checkExpression(left); - if (type !== unknownType && !isTypeAny(type)) { - var prop = getPropertyOfType(getWidenedType(type), propertyName); - if (prop && prop.parent && prop.parent.flags & 32 /* Class */) { - return checkClassPropertyAccess(node, left, type, prop); - } - } - return true; - } - function checkIndexedAccess(node) { - // Grammar checking - if (!node.argumentExpression) { - var sourceFile = getSourceFile(node); - if (node.parent.kind === 169 /* NewExpression */ && node.parent.expression === node) { - var start = ts.skipTrivia(sourceFile.text, node.expression.end); - var end = node.end; - grammarErrorAtPos(sourceFile, start, end - start, ts.Diagnostics.new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead); - } - else { - var start = node.end - "]".length; - var end = node.end; - grammarErrorAtPos(sourceFile, start, end - start, ts.Diagnostics.Expression_expected); - } - } - // Obtain base constraint such that we can bail out if the constraint is an unknown type - var objectType = getApparentType(checkExpression(node.expression)); - var indexType = node.argumentExpression ? checkExpression(node.argumentExpression) : unknownType; - if (objectType === unknownType) { - return unknownType; - } - var isConstEnum = isConstEnumObjectType(objectType); - if (isConstEnum && - (!node.argumentExpression || node.argumentExpression.kind !== 9 /* StringLiteral */)) { - error(node.argumentExpression, ts.Diagnostics.A_const_enum_member_can_only_be_accessed_using_a_string_literal); - return unknownType; - } - // TypeScript 1.0 spec (April 2014): 4.10 Property Access - // - If IndexExpr is a string literal or a numeric literal and ObjExpr's apparent type has a property with the name - // given by that literal(converted to its string representation in the case of a numeric literal), the property access is of the type of that property. - // - Otherwise, if ObjExpr's apparent type has a numeric index signature and IndexExpr is of type Any, the Number primitive type, or an enum type, - // the property access is of the type of that index signature. - // - Otherwise, if ObjExpr's apparent type has a string index signature and IndexExpr is of type Any, the String or Number primitive type, or an enum type, - // the property access is of the type of that index signature. - // - Otherwise, if IndexExpr is of type Any, the String or Number primitive type, or an enum type, the property access is of type Any. - // See if we can index as a property. - if (node.argumentExpression) { - var name_11 = getPropertyNameForIndexedAccess(node.argumentExpression, indexType); - if (name_11 !== undefined) { - var prop = getPropertyOfType(objectType, name_11); - 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_11, symbolToString(objectType.symbol)); - return unknownType; - } - } - } - // Check for compatible indexer types. - if (isTypeAnyOrAllConstituentTypesHaveKind(indexType, 258 /* StringLike */ | 132 /* NumberLike */ | 16777216 /* ESSymbol */)) { - // Try to use a number indexer. - if (isTypeAnyOrAllConstituentTypesHaveKind(indexType, 132 /* NumberLike */)) { - var numberIndexType = getIndexTypeOfType(objectType, 1 /* Number */); - if (numberIndexType) { - return numberIndexType; - } - } - // Try to use string indexing. - var stringIndexType = getIndexTypeOfType(objectType, 0 /* String */); - if (stringIndexType) { - return stringIndexType; - } - // Fall back to any. - if (compilerOptions.noImplicitAny && !compilerOptions.suppressImplicitAnyIndexErrors && !isTypeAny(objectType)) { - error(node, ts.Diagnostics.Index_signature_of_object_type_implicitly_has_an_any_type); - } - return anyType; - } - // REVIEW: Users should know the type that was actually used. - error(node, ts.Diagnostics.An_index_expression_argument_must_be_of_type_string_number_symbol_or_any); - return unknownType; - } - /** - * If indexArgumentExpression is a string literal or number literal, returns its text. - * If indexArgumentExpression is a constant value, returns its string value. - * If indexArgumentExpression is a well known symbol, returns the property name corresponding - * to this symbol, as long as it is a proper symbol reference. - * Otherwise, returns undefined. - */ - function getPropertyNameForIndexedAccess(indexArgumentExpression, indexArgumentType) { - if (indexArgumentExpression.kind === 9 /* StringLiteral */ || indexArgumentExpression.kind === 8 /* NumericLiteral */) { - return indexArgumentExpression.text; - } - if (indexArgumentExpression.kind === 167 /* ElementAccessExpression */ || indexArgumentExpression.kind === 166 /* PropertyAccessExpression */) { - var value = getConstantValue(indexArgumentExpression); - if (value !== undefined) { - return value.toString(); - } - } - if (checkThatExpressionIsProperSymbolReference(indexArgumentExpression, indexArgumentType, /*reportError*/ false)) { - var rightHandSideName = indexArgumentExpression.name.text; - return ts.getPropertyNameForKnownSymbolName(rightHandSideName); - } - return undefined; - } - /** - * A proper symbol reference requires the following: - * 1. The property access denotes a property that exists - * 2. The expression is of the form Symbol. - * 3. The property access is of the primitive type symbol. - * 4. Symbol in this context resolves to the global Symbol object - */ - function checkThatExpressionIsProperSymbolReference(expression, expressionType, reportError) { - if (expressionType === unknownType) { - // There is already an error, so no need to report one. - return false; - } - if (!ts.isWellKnownSymbolSyntactically(expression)) { - return false; - } - // Make sure the property type is the primitive symbol type - if ((expressionType.flags & 16777216 /* ESSymbol */) === 0) { - if (reportError) { - error(expression, ts.Diagnostics.A_computed_property_name_of_the_form_0_must_be_of_type_symbol, ts.getTextOfNode(expression)); - } - return false; - } - // The name is Symbol., so make sure Symbol actually resolves to the - // global Symbol object - var leftHandSide = expression.expression; - var leftHandSideSymbol = getResolvedSymbol(leftHandSide); - if (!leftHandSideSymbol) { - return false; - } - var globalESSymbol = getGlobalESSymbolConstructorSymbol(); - if (!globalESSymbol) { - // Already errored when we tried to look up the symbol - return false; - } - if (leftHandSideSymbol !== globalESSymbol) { - if (reportError) { - error(leftHandSide, ts.Diagnostics.Symbol_reference_does_not_refer_to_the_global_Symbol_constructor_object); - } - return false; - } - return true; - } - function resolveUntypedCall(node) { - if (node.kind === 170 /* TaggedTemplateExpression */) { - checkExpression(node.template); - } - else if (node.kind !== 139 /* Decorator */) { - ts.forEach(node.arguments, function (argument) { - checkExpression(argument); - }); - } - return anySignature; - } - function resolveErrorCall(node) { - resolveUntypedCall(node); - return unknownSignature; - } - // Re-order candidate signatures into the result array. Assumes the result array to be empty. - // The candidate list orders groups in reverse, but within a group signatures are kept in declaration order - // A nit here is that we reorder only signatures that belong to the same symbol, - // so order how inherited signatures are processed is still preserved. - // interface A { (x: string): void } - // interface B extends A { (x: 'foo'): string } - // let b: B; - // b('foo') // <- here overloads should be processed as [(x:'foo'): string, (x: string): void] - function reorderCandidates(signatures, result) { - var lastParent; - var lastSymbol; - var cutoffIndex = 0; - var index; - var specializedIndex = -1; - var spliceIndex; - ts.Debug.assert(!result.length); - for (var _i = 0; _i < signatures.length; _i++) { - var signature = signatures[_i]; - var symbol = signature.declaration && getSymbolOfNode(signature.declaration); - var parent_5 = signature.declaration && signature.declaration.parent; - if (!lastSymbol || symbol === lastSymbol) { - if (lastParent && parent_5 === lastParent) { - index++; - } - else { - lastParent = parent_5; - index = cutoffIndex; - } - } - else { - // 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_5; - } - lastSymbol = symbol; - // specialized signatures always need to be placed before non-specialized signatures regardless - // of the cutoff position; see GH#1133 - if (signature.hasStringLiterals) { - specializedIndex++; - spliceIndex = specializedIndex; - // The cutoff index always needs to be greater than or equal to the specialized signature index - // in order to prevent non-specialized signatures from being added before a specialized - // signature. - cutoffIndex++; - } - else { - spliceIndex = index; - } - result.splice(spliceIndex, 0, signature); - } - } - function getSpreadArgumentIndex(args) { - for (var i = 0; i < args.length; i++) { - var arg = args[i]; - if (arg && arg.kind === 185 /* SpreadElementExpression */) { - return i; - } - } - return -1; - } - function hasCorrectArity(node, args, signature) { - var adjustedArgCount; // Apparent number of arguments we will have in this call - var typeArguments; // Type arguments (undefined if none) - var callIsIncomplete; // In incomplete call we want to be lenient when we have too few arguments - var isDecorator; - var spreadArgIndex = -1; - if (node.kind === 170 /* TaggedTemplateExpression */) { - var tagExpression = node; - // Even if the call is incomplete, we'll have a missing expression as our last argument, - // so we can say the count is just the arg list length - adjustedArgCount = args.length; - typeArguments = undefined; - if (tagExpression.template.kind === 183 /* TemplateExpression */) { - // If a tagged template expression lacks a tail literal, the call is incomplete. - // Specifically, a template only can end in a TemplateTail or a Missing literal. - var templateExpression = tagExpression.template; - var lastSpan = ts.lastOrUndefined(templateExpression.templateSpans); - ts.Debug.assert(lastSpan !== undefined); // we should always have at least one span. - callIsIncomplete = ts.nodeIsMissing(lastSpan.literal) || !!lastSpan.literal.isUnterminated; - } - else { - // If the template didn't end in a backtick, or its beginning occurred right prior to EOF, - // 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 */); - callIsIncomplete = !!templateLiteral.isUnterminated; - } - } - else if (node.kind === 139 /* Decorator */) { - isDecorator = true; - typeArguments = undefined; - adjustedArgCount = getEffectiveArgumentCount(node, /*args*/ undefined, signature); - } - else { - var callExpression = node; - if (!callExpression.arguments) { - // This only happens when we have something of the form: 'new C' - ts.Debug.assert(callExpression.kind === 169 /* NewExpression */); - return signature.minArgumentCount === 0; - } - // For IDE scenarios we may have an incomplete call, so a trailing comma is tantamount to adding another argument. - adjustedArgCount = callExpression.arguments.hasTrailingComma ? args.length + 1 : args.length; - // If we are missing the close paren, the call is incomplete. - callIsIncomplete = callExpression.arguments.end === callExpression.end; - typeArguments = callExpression.typeArguments; - spreadArgIndex = getSpreadArgumentIndex(args); - } - // If the user supplied type arguments, but the number of type arguments does not match - // the declared number of type parameters, the call has an incorrect arity. - var hasRightNumberOfTypeArgs = !typeArguments || - (signature.typeParameters && typeArguments.length === signature.typeParameters.length); - if (!hasRightNumberOfTypeArgs) { - return false; - } - // If spread arguments are present, check that they correspond to a rest parameter. If so, no - // further checking is necessary. - if (spreadArgIndex >= 0) { - return isRestParameterIndex(signature, spreadArgIndex); - } - // Too many arguments implies incorrect arity. - if (!signature.hasRestParameter && adjustedArgCount > signature.parameters.length) { - return false; - } - // If the call is incomplete, we should skip the lower bound check. - var hasEnoughArguments = adjustedArgCount >= signature.minArgumentCount; - return callIsIncomplete || hasEnoughArguments; - } - // If type has a single call signature and no other members, return that signature. Otherwise, return undefined. - function getSingleCallSignature(type) { - if (type.flags & 80896 /* ObjectType */) { - var resolved = resolveStructuredTypeMembers(type); - if (resolved.callSignatures.length === 1 && resolved.constructSignatures.length === 0 && - resolved.properties.length === 0 && !resolved.stringIndexType && !resolved.numberIndexType) { - return resolved.callSignatures[0]; - } - } - return undefined; - } - // Instantiate a generic signature in the context of a non-generic signature (section 3.8.5 in TypeScript spec) - function instantiateSignatureInContextOf(signature, contextualSignature, contextualMapper) { - var context = createInferenceContext(signature.typeParameters, /*inferUnionTypes*/ true); - forEachMatchingParameterType(contextualSignature, signature, function (source, target) { - // Type parameters from outer context referenced by source type are fixed by instantiation of the source type - inferTypes(context, instantiateType(source, contextualMapper), target); - }); - return getSignatureInstantiation(signature, getInferredTypes(context)); - } - function inferTypeArguments(node, signature, args, excludeArgument, context) { - var typeParameters = signature.typeParameters; - var inferenceMapper = createInferenceMapper(context); - // Clear out all the inference results from the last time inferTypeArguments was called on this context - for (var i = 0; i < typeParameters.length; i++) { - // As an optimization, we don't have to clear (and later recompute) inferred types - // for type parameters that have already been fixed on the previous call to inferTypeArguments. - // It would be just as correct to reset all of them. But then we'd be repeating the same work - // for the type parameters that were fixed, namely the work done by getInferredType. - if (!context.inferences[i].isFixed) { - context.inferredTypes[i] = undefined; - } - } - // On this call to inferTypeArguments, we may get more inferences for certain type parameters that were not - // fixed last time. This means that a type parameter that failed inference last time may succeed this time, - // or vice versa. Therefore, the failedTypeParameterIndex is useless if it points to an unfixed type parameter, - // because it may change. So here we reset it. However, getInferredType will not revisit any type parameters - // that were previously fixed. So if a fixed type parameter failed previously, it will fail again because - // it will contain the exact same set of inferences. So if we reset the index from a fixed type parameter, - // we will lose information that we won't recover this time around. - if (context.failedTypeParameterIndex !== undefined && !context.inferences[context.failedTypeParameterIndex].isFixed) { - context.failedTypeParameterIndex = undefined; - } - // We perform two passes over the arguments. In the first pass we infer from all arguments, but use - // wildcards for all context sensitive function expressions. - var argCount = getEffectiveArgumentCount(node, args, signature); - 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 !== 187 /* OmittedExpression */) { - var paramType = getTypeAtPosition(signature, i); - var argType = getEffectiveArgumentType(node, i, arg); - // If the effective argument type is 'undefined', there is no synthetic type - // for the argument. In that case, we should check the argument. - if (argType === undefined) { - // For context sensitive arguments we pass the identityMapper, which is a signal to treat all - // context sensitive function expressions as wildcards - var mapper = excludeArgument && excludeArgument[i] !== undefined ? identityMapper : inferenceMapper; - argType = checkExpressionWithContextualType(arg, paramType, mapper); - } - inferTypes(context, argType, paramType); - } - } - // In the second pass we visit only context sensitive arguments, and only those that aren't excluded, this - // time treating function expressions normally (which may cause previously inferred type arguments to be fixed - // as we construct types for contextually typed parameters) - // Decorators will not have `excludeArgument`, as their arguments cannot be contextually typed. - // Tagged template expressions will always have `undefined` for `excludeArgument[0]`. - if (excludeArgument) { - for (var i = 0; i < argCount; i++) { - // No need to check for omitted args and template expressions, their exlusion value is always undefined - if (excludeArgument[i] === false) { - var arg = args[i]; - var paramType = getTypeAtPosition(signature, i); - inferTypes(context, checkExpressionWithContextualType(arg, paramType, inferenceMapper), paramType); - } - } - } - getInferredTypes(context); - } - function checkTypeArguments(signature, typeArguments, typeArgumentResultTypes, reportErrors, headMessage) { - var typeParameters = signature.typeParameters; - var typeArgumentsAreAssignable = true; - for (var i = 0; i < typeParameters.length; i++) { - var typeArgNode = typeArguments[i]; - var typeArgument = getTypeFromTypeNode(typeArgNode); - // Do not push on this array! It has a preallocated length - typeArgumentResultTypes[i] = typeArgument; - if (typeArgumentsAreAssignable /* so far */) { - var constraint = getConstraintOfTypeParameter(typeParameters[i]); - if (constraint) { - var errorInfo = void 0; - var typeArgumentHeadMessage = ts.Diagnostics.Type_0_does_not_satisfy_the_constraint_1; - if (reportErrors && headMessage) { - errorInfo = ts.chainDiagnosticMessages(errorInfo, typeArgumentHeadMessage); - typeArgumentHeadMessage = headMessage; - } - typeArgumentsAreAssignable = checkTypeAssignableTo(typeArgument, constraint, reportErrors ? typeArgNode : undefined, typeArgumentHeadMessage, errorInfo); - } - } - } - return typeArgumentsAreAssignable; - } - function checkApplicableSignature(node, args, signature, relation, excludeArgument, reportErrors) { - var argCount = getEffectiveArgumentCount(node, args, signature); - 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 !== 187 /* OmittedExpression */) { - // Check spread elements against rest type (from arity check we know spread argument corresponds to a rest parameter) - var paramType = getTypeAtPosition(signature, i); - var argType = getEffectiveArgumentType(node, i, arg); - // 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) { - argType = arg.kind === 9 /* StringLiteral */ && !reportErrors - ? getStringLiteralType(arg) - : checkExpressionWithContextualType(arg, paramType, excludeArgument && excludeArgument[i] ? identityMapper : undefined); - } - // Use argument expression as error location when reporting errors - var errorNode = reportErrors ? getEffectiveArgumentErrorNode(node, i, arg) : undefined; - var headMessage = ts.Diagnostics.Argument_of_type_0_is_not_assignable_to_parameter_of_type_1; - if (!checkTypeRelatedTo(argType, paramType, relation, errorNode, headMessage)) { - return false; - } - } - } - return true; - } - /** - * Returns the effective arguments for an expression that works like a function invocation. - * - * If 'node' is a CallExpression or a NewExpression, then its argument list is returned. - * If 'node' is a TaggedTemplateExpression, a new argument list is constructed from the substitution - * expressions, where the first element of the list is `undefined`. - * If 'node' is a Decorator, the argument list will be `undefined`, and its arguments and types - * will be supplied from calls to `getEffectiveArgumentCount` and `getEffectiveArgumentType`. - */ - function getEffectiveCallArguments(node) { - var args; - if (node.kind === 170 /* TaggedTemplateExpression */) { - var template = node.template; - args = [undefined]; - if (template.kind === 183 /* TemplateExpression */) { - ts.forEach(template.templateSpans, function (span) { - args.push(span.expression); - }); - } - } - else if (node.kind === 139 /* Decorator */) { - // For a decorator, we return undefined as we will determine - // the number and types of arguments for a decorator using - // `getEffectiveArgumentCount` and `getEffectiveArgumentType` below. - return undefined; - } - else { - args = node.arguments || emptyArray; - } - return args; - } - /** - * Returns the effective argument count for a node that works like a function invocation. - * If 'node' is a Decorator, the number of arguments is derived from the decoration - * target and the signature: - * If 'node.target' is a class declaration or class expression, the effective argument - * count is 1. - * If 'node.target' is a parameter declaration, the effective argument count is 3. - * If 'node.target' is a property declaration, the effective argument count is 2. - * If 'node.target' is a method or accessor declaration, the effective argument count - * is 3, although it can be 2 if the signature only accepts two arguments, allowing - * us to match a property decorator. - * Otherwise, the argument count is the length of the 'args' array. - */ - function getEffectiveArgumentCount(node, args, signature) { - if (node.kind === 139 /* Decorator */) { - switch (node.parent.kind) { - case 214 /* ClassDeclaration */: - case 186 /* ClassExpression */: - // A class decorator will have one argument (see `ClassDecorator` in core.d.ts) - return 1; - case 141 /* PropertyDeclaration */: - // A property declaration decorator will have two arguments (see - // `PropertyDecorator` in core.d.ts) - return 2; - case 143 /* MethodDeclaration */: - case 145 /* GetAccessor */: - case 146 /* SetAccessor */: - // A method or accessor declaration decorator will have two or three arguments (see - // `PropertyDecorator` and `MethodDecorator` in core.d.ts) - // If we are emitting decorators for ES3, we will only pass two arguments. - if (languageVersion === 0 /* ES3 */) { - return 2; - } - // If the method decorator signature only accepts a target and a key, we will only - // type check those arguments. - return signature.parameters.length >= 3 ? 3 : 2; - case 138 /* Parameter */: - // A parameter declaration decorator will have three arguments (see - // `ParameterDecorator` in core.d.ts) - return 3; - } - } - else { - return args.length; - } - } - /** - * Returns the effective type of the first argument to a decorator. - * If 'node' is a class declaration or class expression, the effective argument type - * is the type of the static side of the class. - * If 'node' is a parameter declaration, the effective argument type is either the type - * of the static or instance side of the class for the parameter's parent method, - * depending on whether the method is declared static. - * For a constructor, the type is always the type of the static side of the class. - * If 'node' is a property, method, or accessor declaration, the effective argument - * type is the type of the static or instance side of the parent class for class - * element, depending on whether the element is declared static. - */ - function getEffectiveDecoratorFirstArgumentType(node) { - // The first argument to a decorator is its `target`. - if (node.kind === 214 /* 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 === 138 /* Parameter */) { - // For a parameter decorator, the `target` is the parent type of the - // parameter's containing method. - node = node.parent; - if (node.kind === 144 /* Constructor */) { - var classSymbol = getSymbolOfNode(node); - return getTypeOfSymbol(classSymbol); - } - } - if (node.kind === 141 /* PropertyDeclaration */ || - node.kind === 143 /* MethodDeclaration */ || - node.kind === 145 /* GetAccessor */ || - node.kind === 146 /* SetAccessor */) { - // For a property or method decorator, the `target` is the - // "static"-side type of the parent of the member if the member is - // declared "static"; otherwise, it is the "instance"-side type of the - // parent of the member. - return getParentTypeOfClassElement(node); - } - ts.Debug.fail("Unsupported decorator target."); - return unknownType; - } - /** - * Returns the effective type for the second argument to a decorator. - * If 'node' is a parameter, its effective argument type is one of the following: - * If 'node.parent' is a constructor, the effective argument type is 'any', as we - * will emit `undefined`. - * If 'node.parent' is a member with an identifier, numeric, or string literal name, - * the effective argument type will be a string literal type for the member name. - * If 'node.parent' is a computed property name, the effective argument type will - * either be a symbol type or the string type. - * If 'node' is a member with an identifier, numeric, or string literal name, the - * effective argument type will be a string literal type for the member name. - * If 'node' is a computed property name, the effective argument type will either - * be a symbol type or the string type. - * A class decorator does not have a second argument type. - */ - function getEffectiveDecoratorSecondArgumentType(node) { - // The second argument to a decorator is its `propertyKey` - if (node.kind === 214 /* ClassDeclaration */) { - ts.Debug.fail("Class decorators should not have a second synthetic argument."); - return unknownType; - } - if (node.kind === 138 /* Parameter */) { - node = node.parent; - if (node.kind === 144 /* Constructor */) { - // For a constructor parameter decorator, the `propertyKey` will be `undefined`. - return anyType; - } - } - if (node.kind === 141 /* PropertyDeclaration */ || - node.kind === 143 /* MethodDeclaration */ || - node.kind === 145 /* GetAccessor */ || - node.kind === 146 /* SetAccessor */) { - // The `propertyKey` for a property or method decorator will be a - // string literal type if the member name is an identifier, number, or string; - // otherwise, if the member name is a computed property name it will - // be either string or symbol. - var element = node; - switch (element.name.kind) { - case 69 /* Identifier */: - case 8 /* NumericLiteral */: - case 9 /* StringLiteral */: - return getStringLiteralType(element.name); - case 136 /* ComputedPropertyName */: - var nameType = checkComputedPropertyName(element.name); - if (allConstituentTypesHaveKind(nameType, 16777216 /* ESSymbol */)) { - return nameType; - } - else { - return stringType; - } - default: - ts.Debug.fail("Unsupported property name."); - return unknownType; - } - } - ts.Debug.fail("Unsupported decorator target."); - return unknownType; - } - /** - * Returns the effective argument type for the third argument to a decorator. - * If 'node' is a parameter, the effective argument type is the number type. - * If 'node' is a method or accessor, the effective argument type is a - * `TypedPropertyDescriptor` instantiated with the type of the member. - * Class and property decorators do not have a third effective argument. - */ - function getEffectiveDecoratorThirdArgumentType(node) { - // The third argument to a decorator is either its `descriptor` for a method decorator - // or its `parameterIndex` for a paramter decorator - if (node.kind === 214 /* ClassDeclaration */) { - ts.Debug.fail("Class decorators should not have a third synthetic argument."); - return unknownType; - } - if (node.kind === 138 /* Parameter */) { - // The `parameterIndex` for a parameter decorator is always a number - return numberType; - } - if (node.kind === 141 /* PropertyDeclaration */) { - ts.Debug.fail("Property decorators should not have a third synthetic argument."); - return unknownType; - } - if (node.kind === 143 /* MethodDeclaration */ || - node.kind === 145 /* GetAccessor */ || - node.kind === 146 /* SetAccessor */) { - // The `descriptor` for a method decorator will be a `TypedPropertyDescriptor` - // for the type of the member. - var propertyType = getTypeOfNode(node); - return createTypedPropertyDescriptorType(propertyType); - } - ts.Debug.fail("Unsupported decorator target."); - return unknownType; - } - /** - * Returns the effective argument type for the provided argument to a decorator. - */ - function getEffectiveDecoratorArgumentType(node, argIndex) { - if (argIndex === 0) { - return getEffectiveDecoratorFirstArgumentType(node.parent); - } - else if (argIndex === 1) { - return getEffectiveDecoratorSecondArgumentType(node.parent); - } - else if (argIndex === 2) { - return getEffectiveDecoratorThirdArgumentType(node.parent); - } - ts.Debug.fail("Decorators should not have a fourth synthetic argument."); - return unknownType; - } - /** - * Gets the effective argument type for an argument in a call expression. - */ - function getEffectiveArgumentType(node, argIndex, arg) { - // 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 === 139 /* Decorator */) { - return getEffectiveDecoratorArgumentType(node, argIndex); - } - else if (argIndex === 0 && node.kind === 170 /* TaggedTemplateExpression */) { - return globalTemplateStringsArrayType; - } - // This is not a synthetic argument, so we return 'undefined' - // to signal that the caller needs to check the argument. - return undefined; - } - /** - * Gets the effective argument expression for an argument in a call expression. - */ - function getEffectiveArgument(node, args, argIndex) { - // For a decorator or the first argument of a tagged template expression we return undefined. - if (node.kind === 139 /* Decorator */ || - (argIndex === 0 && node.kind === 170 /* TaggedTemplateExpression */)) { - return undefined; - } - return args[argIndex]; - } - /** - * Gets the error node to use when reporting errors for an effective argument. - */ - function getEffectiveArgumentErrorNode(node, argIndex, arg) { - if (node.kind === 139 /* Decorator */) { - // For a decorator, we use the expression of the decorator for error reporting. - return node.expression; - } - else if (argIndex === 0 && node.kind === 170 /* TaggedTemplateExpression */) { - // For a the first argument of a tagged template expression, we use the template of the tag for error reporting. - return node.template; - } - else { - return arg; - } - } - function resolveCall(node, signatures, candidatesOutArray, headMessage) { - var isTaggedTemplate = node.kind === 170 /* TaggedTemplateExpression */; - var isDecorator = node.kind === 139 /* Decorator */; - var typeArguments; - if (!isTaggedTemplate && !isDecorator) { - typeArguments = node.typeArguments; - // We already perform checking on the type arguments on the class declaration itself. - if (node.expression.kind !== 95 /* SuperKeyword */) { - ts.forEach(typeArguments, checkSourceElement); - } - } - var candidates = candidatesOutArray || []; - // reorderCandidates fills up the candidates array directly - reorderCandidates(signatures, candidates); - if (!candidates.length) { - reportError(ts.Diagnostics.Supplied_parameters_do_not_match_any_signature_of_call_target); - return resolveErrorCall(node); - } - var args = getEffectiveCallArguments(node); - // The following applies to any value of 'excludeArgument[i]': - // - true: the argument at 'i' is susceptible to a one-time permanent contextual typing. - // - undefined: the argument at 'i' is *not* susceptible to permanent contextual typing. - // - false: the argument at 'i' *was* and *has been* permanently contextually typed. - // - // The idea is that we will perform type argument inference & assignability checking once - // without using the susceptible parameters that are functions, and once more for each of those - // parameters, contextually typing each as we go along. - // - // For a tagged template, then the first argument be 'undefined' if necessary - // because it represents a TemplateStringsArray. - // - // For a decorator, no arguments are susceptible to contextual typing due to the fact - // decorators are applied to a declaration by the emitter, and not to an expression. - var excludeArgument; - if (!isDecorator) { - // We do not need to call `getEffectiveArgumentCount` here as it only - // applies when calculating the number of arguments for a decorator. - for (var i = isTaggedTemplate ? 1 : 0; i < args.length; i++) { - if (isContextSensitive(args[i])) { - if (!excludeArgument) { - excludeArgument = new Array(args.length); - } - excludeArgument[i] = true; - } - } - } - // The following variables are captured and modified by calls to chooseOverload. - // If overload resolution or type argument inference fails, we want to report the - // best error possible. The best error is one which says that an argument was not - // assignable to a parameter. This implies that everything else about the overload - // was fine. So if there is any overload that is only incorrect because of an - // argument, we will report an error on that one. - // - // function foo(s: string) {} - // function foo(n: number) {} // Report argument error on this overload - // function foo() {} - // foo(true); - // - // If none of the overloads even made it that far, there are two possibilities. - // There was a problem with type arguments for some overload, in which case - // report an error on that. Or none of the overloads even had correct arity, - // in which case give an arity error. - // - // function foo(x: T, y: T) {} // Report type argument inference error - // function foo() {} - // foo(0, true); - // - var candidateForArgumentError; - var candidateForTypeArgumentError; - var resultOfFailedInference; - var result; - // 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 - // of those signatures becomes the return type of the function call. - // Otherwise, the return type of the first signature in the candidate list becomes the return - // type of the function call. - // - // Whether the call is an error is determined by assignability of the arguments. The subtype pass - // is just important for choosing the best signature. So in the case where there is only one - // signature, the subtype pass is useless. So skipping it is an optimization. - if (candidates.length > 1) { - result = chooseOverload(candidates, subtypeRelation); - } - if (!result) { - // Reinitialize these pointers for round two - candidateForArgumentError = undefined; - candidateForTypeArgumentError = undefined; - resultOfFailedInference = undefined; - result = chooseOverload(candidates, assignableRelation); - } - if (result) { - return result; - } - // No signatures were applicable. Now report errors based on the last applicable signature with - // no arguments excluded from assignability checks. - // If candidate is undefined, it means that no candidates had a suitable arity. In that case, - // skip the checkApplicableSignature check. - if (candidateForArgumentError) { - // excludeArgument is undefined, in this case also equivalent to [undefined, undefined, ...] - // The importance of excludeArgument is to prevent us from typing function expression parameters - // in arguments too early. If possible, we'd like to only type them once we know the correct - // overload. However, this matters for the case where the call is correct. When the call is - // an error, we don't need to exclude any arguments, although it would cause no harm to do so. - checkApplicableSignature(node, args, candidateForArgumentError, assignableRelation, /*excludeArgument*/ undefined, /*reportErrors*/ true); - } - else if (candidateForTypeArgumentError) { - if (!isTaggedTemplate && !isDecorator && typeArguments) { - checkTypeArguments(candidateForTypeArgumentError, node.typeArguments, [], /*reportErrors*/ true, headMessage); - } - else { - ts.Debug.assert(resultOfFailedInference.failedTypeParameterIndex >= 0); - var failedTypeParameter = candidateForTypeArgumentError.typeParameters[resultOfFailedInference.failedTypeParameterIndex]; - var inferenceCandidates = getInferenceCandidates(resultOfFailedInference, resultOfFailedInference.failedTypeParameterIndex); - var diagnosticChainHead = ts.chainDiagnosticMessages(/*details*/ undefined, // details will be provided by call to reportNoCommonSupertypeError - ts.Diagnostics.The_type_argument_for_type_parameter_0_cannot_be_inferred_from_the_usage_Consider_specifying_the_type_arguments_explicitly, typeToString(failedTypeParameter)); - if (headMessage) { - diagnosticChainHead = ts.chainDiagnosticMessages(diagnosticChainHead, headMessage); - } - reportNoCommonSupertypeError(inferenceCandidates, node.expression || node.tag, diagnosticChainHead); - } - } - else { - reportError(ts.Diagnostics.Supplied_parameters_do_not_match_any_signature_of_call_target); - } - // No signature was applicable. We have already reported the errors for the invalid signature. - // If this is a type resolution session, e.g. Language Service, try to get better information that anySignature. - // Pick the first candidate that matches the arity. This way we can get a contextual type for cases like: - // declare function f(a: { xa: number; xb: number; }); - // f({ | - if (!produceDiagnostics) { - for (var _i = 0; _i < candidates.length; _i++) { - var candidate = candidates[_i]; - if (hasCorrectArity(node, args, candidate)) { - if (candidate.typeParameters && typeArguments) { - candidate = getSignatureInstantiation(candidate, ts.map(typeArguments, getTypeFromTypeNode)); - } - return candidate; - } - } - } - return resolveErrorCall(node); - function reportError(message, arg0, arg1, arg2) { - var errorInfo; - errorInfo = ts.chainDiagnosticMessages(errorInfo, message, arg0, arg1, arg2); - if (headMessage) { - errorInfo = ts.chainDiagnosticMessages(errorInfo, headMessage); - } - diagnostics.add(ts.createDiagnosticForNodeFromMessageChain(node, errorInfo)); - } - function chooseOverload(candidates, relation) { - for (var _i = 0; _i < candidates.length; _i++) { - var originalCandidate = candidates[_i]; - if (!hasCorrectArity(node, args, originalCandidate)) { - continue; - } - var candidate = void 0; - var typeArgumentsAreValid = void 0; - var inferenceContext = originalCandidate.typeParameters - ? createInferenceContext(originalCandidate.typeParameters, /*inferUnionTypes*/ false) - : undefined; - while (true) { - candidate = originalCandidate; - if (candidate.typeParameters) { - var typeArgumentTypes = void 0; - if (typeArguments) { - typeArgumentTypes = new Array(candidate.typeParameters.length); - typeArgumentsAreValid = checkTypeArguments(candidate, typeArguments, typeArgumentTypes, /*reportErrors*/ false); - } - else { - inferTypeArguments(node, candidate, args, excludeArgument, inferenceContext); - typeArgumentsAreValid = inferenceContext.failedTypeParameterIndex === undefined; - typeArgumentTypes = inferenceContext.inferredTypes; - } - if (!typeArgumentsAreValid) { - break; - } - candidate = getSignatureInstantiation(candidate, typeArgumentTypes); - } - if (!checkApplicableSignature(node, args, candidate, relation, excludeArgument, /*reportErrors*/ false)) { - break; - } - var index = excludeArgument ? ts.indexOf(excludeArgument, true) : -1; - if (index < 0) { - return candidate; - } - excludeArgument[index] = false; - } - // A post-mortem of this iteration of the loop. The signature was not applicable, - // so we want to track it as a candidate for reporting an error. If the candidate - // had no type parameters, or had no issues related to type arguments, we can - // report an error based on the arguments. If there was an issue with type - // arguments, then we can only report an error based on the type arguments. - if (originalCandidate.typeParameters) { - var instantiatedCandidate = candidate; - if (typeArgumentsAreValid) { - candidateForArgumentError = instantiatedCandidate; - } - else { - candidateForTypeArgumentError = originalCandidate; - if (!typeArguments) { - resultOfFailedInference = inferenceContext; - } - } - } - else { - ts.Debug.assert(originalCandidate === candidate); - candidateForArgumentError = originalCandidate; - } - } - return undefined; - } - } - function resolveCallExpression(node, candidatesOutArray) { - if (node.expression.kind === 95 /* SuperKeyword */) { - var superType = checkSuperExpression(node.expression); - if (superType !== unknownType) { - // In super call, the candidate signatures are the matching arity signatures of the base constructor function instantiated - // with the type arguments specified in the extends clause. - var baseTypeNode = ts.getClassExtendsHeritageClauseElement(ts.getContainingClass(node)); - var baseConstructors = getInstantiatedConstructorsForTypeArguments(superType, baseTypeNode.typeArguments); - return resolveCall(node, baseConstructors, candidatesOutArray); - } - return resolveUntypedCall(node); - } - var funcType = checkExpression(node.expression); - var apparentType = getApparentType(funcType); - if (apparentType === unknownType) { - // Another error has already been reported - return resolveErrorCall(node); - } - // Technically, this signatures list may be incomplete. We are taking the apparent type, - // but we are not including call signatures that may have been added to the Object or - // Function interface, since they have none by default. This is a bit of a leap of faith - // that the user will not add any. - var callSignatures = getSignaturesOfType(apparentType, 0 /* Call */); - var constructSignatures = getSignaturesOfType(apparentType, 1 /* Construct */); - // TS 1.0 spec: 4.12 - // If FuncExpr is of type Any, or of an object type that has no call or construct signatures - // but is a subtype of the Function interface, the call is an untyped function call. In an - // untyped function call no TypeArgs are permitted, Args can be any argument list, no contextual - // types are provided for the argument expressions, and the result is always of type Any. - // We exclude union types because we may have a union of function types that happen to have - // no common signatures. - if (isTypeAny(funcType) || (!callSignatures.length && !constructSignatures.length && !(funcType.flags & 16384 /* Union */) && isTypeAssignableTo(funcType, globalFunctionType))) { - // The unknownType indicates that an error already occured (and was reported). No - // need to report another error in this case. - if (funcType !== unknownType && node.typeArguments) { - error(node, ts.Diagnostics.Untyped_function_calls_may_not_accept_type_arguments); - } - return resolveUntypedCall(node); - } - // If FuncExpr's apparent type(section 3.8.1) is a function type, the call is a typed function call. - // TypeScript employs overload resolution in typed function calls in order to support functions - // with multiple call signatures. - if (!callSignatures.length) { - if (constructSignatures.length) { - error(node, ts.Diagnostics.Value_of_type_0_is_not_callable_Did_you_mean_to_include_new, typeToString(funcType)); - } - else { - error(node, ts.Diagnostics.Cannot_invoke_an_expression_whose_type_lacks_a_call_signature); - } - return resolveErrorCall(node); - } - return resolveCall(node, callSignatures, candidatesOutArray); - } - function resolveNewExpression(node, candidatesOutArray) { - if (node.arguments && languageVersion < 1 /* ES5 */) { - var spreadIndex = getSpreadArgumentIndex(node.arguments); - if (spreadIndex >= 0) { - error(node.arguments[spreadIndex], ts.Diagnostics.Spread_operator_in_new_expressions_is_only_available_when_targeting_ECMAScript_5_and_higher); - } - } - var expressionType = checkExpression(node.expression); - // If expressionType's apparent type(section 3.8.1) is an object type with one or - // more construct signatures, the expression is processed in the same manner as a - // function call, but using the construct signatures as the initial set of candidate - // signatures for overload resolution. The result type of the function call becomes - // the result type of the operation. - expressionType = getApparentType(expressionType); - if (expressionType === unknownType) { - // Another error has already been reported - return resolveErrorCall(node); - } - // If the expression is a class of abstract type, then it cannot be instantiated. - // Note, only class declarations can be declared abstract. - // In the case of a merged class-module or class-interface declaration, - // only the class declaration node will have the Abstract flag set. - var valueDecl = expressionType.symbol && getClassLikeDeclarationOfSymbol(expressionType.symbol); - if (valueDecl && valueDecl.flags & 256 /* Abstract */) { - error(node, ts.Diagnostics.Cannot_create_an_instance_of_the_abstract_class_0, ts.declarationNameToString(valueDecl.name)); - return resolveErrorCall(node); - } - // TS 1.0 spec: 4.11 - // If expressionType is of type Any, Args can be any argument - // list and the result of the operation is of type Any. - if (isTypeAny(expressionType)) { - if (node.typeArguments) { - error(node, ts.Diagnostics.Untyped_function_calls_may_not_accept_type_arguments); - } - return resolveUntypedCall(node); - } - // Technically, this signatures list may be incomplete. We are taking the apparent type, - // but we are not including construct signatures that may have been added to the Object or - // Function interface, since they have none by default. This is a bit of a leap of faith - // that the user will not add any. - var constructSignatures = getSignaturesOfType(expressionType, 1 /* Construct */); - if (constructSignatures.length) { - return resolveCall(node, constructSignatures, candidatesOutArray); - } - // If expressionType's apparent type is an object type with no construct signatures but - // one or more call signatures, the expression is processed as a function call. A compile-time - // error occurs if the result of the function call is not Void. The type of the result of the - // operation is Any. - var callSignatures = getSignaturesOfType(expressionType, 0 /* Call */); - if (callSignatures.length) { - var signature = resolveCall(node, callSignatures, candidatesOutArray); - if (getReturnTypeOfSignature(signature) !== voidType) { - error(node, ts.Diagnostics.Only_a_void_function_can_be_called_with_the_new_keyword); - } - return signature; - } - error(node, ts.Diagnostics.Cannot_use_new_with_an_expression_whose_type_lacks_a_call_or_construct_signature); - return resolveErrorCall(node); - } - function resolveTaggedTemplateExpression(node, candidatesOutArray) { - var tagType = checkExpression(node.tag); - var apparentType = getApparentType(tagType); - if (apparentType === unknownType) { - // Another error has already been reported - return resolveErrorCall(node); - } - var callSignatures = getSignaturesOfType(apparentType, 0 /* Call */); - if (isTypeAny(tagType) || (!callSignatures.length && !(tagType.flags & 16384 /* Union */) && isTypeAssignableTo(tagType, globalFunctionType))) { - return resolveUntypedCall(node); - } - if (!callSignatures.length) { - error(node, ts.Diagnostics.Cannot_invoke_an_expression_whose_type_lacks_a_call_signature); - return resolveErrorCall(node); - } - return resolveCall(node, callSignatures, candidatesOutArray); - } - /** - * Gets the localized diagnostic head message to use for errors when resolving a decorator as a call expression. - */ - function getDiagnosticHeadMessageForDecoratorResolution(node) { - switch (node.parent.kind) { - case 214 /* ClassDeclaration */: - case 186 /* ClassExpression */: - return ts.Diagnostics.Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression; - case 138 /* Parameter */: - return ts.Diagnostics.Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression; - case 141 /* PropertyDeclaration */: - return ts.Diagnostics.Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression; - case 143 /* MethodDeclaration */: - case 145 /* GetAccessor */: - case 146 /* SetAccessor */: - return ts.Diagnostics.Unable_to_resolve_signature_of_method_decorator_when_called_as_an_expression; - } - } - /** - * Resolves a decorator as if it were a call expression. - */ - function resolveDecorator(node, candidatesOutArray) { - var funcType = checkExpression(node.expression); - var apparentType = getApparentType(funcType); - if (apparentType === unknownType) { - return resolveErrorCall(node); - } - var callSignatures = getSignaturesOfType(apparentType, 0 /* Call */); - if (funcType === anyType || (!callSignatures.length && !(funcType.flags & 16384 /* Union */) && isTypeAssignableTo(funcType, globalFunctionType))) { - return resolveUntypedCall(node); - } - var headMessage = getDiagnosticHeadMessageForDecoratorResolution(node); - if (!callSignatures.length) { - var errorInfo; - errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.Cannot_invoke_an_expression_whose_type_lacks_a_call_signature); - errorInfo = ts.chainDiagnosticMessages(errorInfo, headMessage); - diagnostics.add(ts.createDiagnosticForNodeFromMessageChain(node, errorInfo)); - return resolveErrorCall(node); - } - return resolveCall(node, callSignatures, candidatesOutArray, headMessage); - } - // candidatesOutArray is passed by signature help in the language service, and collectCandidates - // must fill it up with the appropriate candidate signatures - function getResolvedSignature(node, candidatesOutArray) { - var links = getNodeLinks(node); - // If getResolvedSignature has already been called, we will have cached the resolvedSignature. - // However, it is possible that either candidatesOutArray was not passed in the first time, - // or that a different candidatesOutArray was passed in. Therefore, we need to redo the work - // to correctly fill the candidatesOutArray. - if (!links.resolvedSignature || candidatesOutArray) { - links.resolvedSignature = anySignature; - if (node.kind === 168 /* CallExpression */) { - links.resolvedSignature = resolveCallExpression(node, candidatesOutArray); - } - else if (node.kind === 169 /* NewExpression */) { - links.resolvedSignature = resolveNewExpression(node, candidatesOutArray); - } - else if (node.kind === 170 /* TaggedTemplateExpression */) { - links.resolvedSignature = resolveTaggedTemplateExpression(node, candidatesOutArray); - } - else if (node.kind === 139 /* Decorator */) { - links.resolvedSignature = resolveDecorator(node, candidatesOutArray); - } - else { - ts.Debug.fail("Branch in 'getResolvedSignature' should be unreachable."); - } - } - return links.resolvedSignature; - } - /** - * Syntactically and semantically checks a call or new expression. - * @param node The call/new expression to be checked. - * @returns On success, the expression's signature's return type. On failure, anyType. - */ - function checkCallExpression(node) { - // 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 */) { - return voidType; - } - if (node.kind === 169 /* NewExpression */) { - var declaration = signature.declaration; - if (declaration && - declaration.kind !== 144 /* Constructor */ && - declaration.kind !== 148 /* ConstructSignature */ && - declaration.kind !== 153 /* ConstructorType */) { - // When resolved signature is a call signature (and not a construct signature) the result type is any - if (compilerOptions.noImplicitAny) { - error(node, ts.Diagnostics.new_expression_whose_target_lacks_a_construct_signature_implicitly_has_an_any_type); - } - return anyType; - } - } - return getReturnTypeOfSignature(signature); - } - function checkTaggedTemplateExpression(node) { - return getReturnTypeOfSignature(getResolvedSignature(node)); - } - function checkAssertion(node) { - var exprType = getRegularTypeOfObjectLiteral(checkExpression(node.expression)); - var targetType = getTypeFromTypeNode(node.type); - if (produceDiagnostics && targetType !== unknownType) { - var widenedType = getWidenedType(exprType); - if (!(isTypeAssignableTo(targetType, widenedType))) { - checkTypeAssignableTo(exprType, targetType, node, ts.Diagnostics.Neither_type_0_nor_type_1_is_assignable_to_the_other); - } - } - return targetType; - } - function getTypeAtPosition(signature, pos) { - return signature.hasRestParameter ? - pos < signature.parameters.length - 1 ? getTypeOfSymbol(signature.parameters[pos]) : getRestTypeOfSignature(signature) : - pos < signature.parameters.length ? getTypeOfSymbol(signature.parameters[pos]) : anyType; - } - function assignContextualParameterTypes(signature, context, mapper) { - var len = signature.parameters.length - (signature.hasRestParameter ? 1 : 0); - for (var i = 0; i < len; i++) { - var parameter = signature.parameters[i]; - 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); - } - } - // When contextual typing assigns a type to a parameter that contains a binding pattern, we also need to push - // the destructured type into the contained binding elements. - function assignBindingElementTypes(node) { - if (ts.isBindingPattern(node.name)) { - for (var _i = 0, _a = node.name.elements; _i < _a.length; _i++) { - var element = _a[_i]; - if (element.kind !== 187 /* OmittedExpression */) { - getSymbolLinks(getSymbolOfNode(element)).type = getTypeForBindingElement(element); - assignBindingElementTypes(element); - } - } - } - } - function assignTypeToParameterAndFixTypeParameters(parameter, contextualType, mapper) { - var links = getSymbolLinks(parameter); - if (!links.type) { - links.type = instantiateType(contextualType, mapper); - assignBindingElementTypes(parameter.valueDeclaration); - } - else if (isInferentialContext(mapper)) { - // Even if the parameter already has a type, it might be because it was given a type while - // processing the function as an argument to a prior signature during overload resolution. - // If this was the case, it may have caused some type parameters to be fixed. So here, - // we need to ensure that type parameters at the same positions get fixed again. This is - // done by calling instantiateType to attach the mapper to the contextualType, and then - // calling inferTypes to force a walk of contextualType so that all the correct fixing - // happens. The choice to pass in links.type may seem kind of arbitrary, but it serves - // to make sure that all the correct positions in contextualType are reached by the walk. - // Here is an example: - // - // interface Base { - // baseProp; - // } - // interface Derived extends Base { - // toBase(): Base; - // } - // - // var derived: Derived; - // - // declare function foo(x: T, func: (p: T) => T): T; - // declare function foo(x: T, func: (p: T) => T): T; - // - // var result = foo(derived, d => d.toBase()); - // - // We are typing d while checking the second overload. But we've already given d - // a type (Derived) from the first overload. However, we still want to fix the - // T in the second overload so that we do not infer Base as a candidate for T - // (inferring Base would make type argument inference inconsistent between the two - // overloads). - inferTypes(mapper.context, links.type, instantiateType(contextualType, mapper)); - } - } - function createPromiseType(promisedType) { - // creates a `Promise` type where `T` is the promisedType argument - var globalPromiseType = getGlobalPromiseType(); - if (globalPromiseType !== emptyGenericType) { - // if the promised type is itself a promise, get the underlying type; otherwise, fallback to the promised type - promisedType = getAwaitedType(promisedType); - return createTypeReference(globalPromiseType, [promisedType]); - } - return emptyObjectType; - } - function getReturnTypeFromBody(func, contextualMapper) { - var contextualSignature = getContextualSignatureForFunctionLikeDeclaration(func); - if (!func.body) { - return unknownType; - } - var isAsync = ts.isAsyncFunctionLike(func); - var type; - if (func.body.kind !== 192 /* Block */) { - type = checkExpressionCached(func.body, contextualMapper); - if (isAsync) { - // From within an async function you can return either a non-promise value or a promise. Any - // Promise/A+ compatible implementation will always assimilate any foreign promise, so the - // return type of the body should be unwrapped to its awaited type, which we will wrap in - // the native Promise type later in this function. - type = checkAwaitedType(type, func, ts.Diagnostics.Return_expression_in_async_function_does_not_have_a_valid_callable_then_member); - } - } - else { - var types; - var funcIsGenerator = !!func.asteriskToken; - if (funcIsGenerator) { - types = checkAndAggregateYieldOperandTypes(func.body, contextualMapper); - if (types.length === 0) { - var iterableIteratorAny = createIterableIteratorType(anyType); - if (compilerOptions.noImplicitAny) { - error(func.asteriskToken, ts.Diagnostics.Generator_implicitly_has_type_0_because_it_does_not_yield_any_values_Consider_supplying_a_return_type, typeToString(iterableIteratorAny)); - } - return iterableIteratorAny; - } - } - else { - types = checkAndAggregateReturnExpressionTypes(func.body, contextualMapper, isAsync); - if (types.length === 0) { - if (isAsync) { - // For an async function, the return type will not be void, but rather a Promise for void. - var promiseType = createPromiseType(voidType); - if (promiseType === emptyObjectType) { - error(func, ts.Diagnostics.An_async_function_or_method_must_have_a_valid_awaitable_return_type); - return unknownType; - } - return promiseType; - } - else { - return voidType; - } - } - } - // When yield/return statements are contextually typed we allow the return type to be a union type. - // Otherwise we require the yield/return expressions to have a best common supertype. - type = contextualSignature ? getUnionType(types) : getCommonSupertype(types); - if (!type) { - if (funcIsGenerator) { - error(func, ts.Diagnostics.No_best_common_type_exists_among_yield_expressions); - return createIterableIteratorType(unknownType); - } - else { - error(func, ts.Diagnostics.No_best_common_type_exists_among_return_expressions); - return unknownType; - } - } - if (funcIsGenerator) { - type = createIterableIteratorType(type); - } - } - if (!contextualSignature) { - reportErrorsFromWidening(func, type); - } - var widenedType = getWidenedType(type); - if (isAsync) { - // From within an async function you can return either a non-promise value or a promise. Any - // Promise/A+ compatible implementation will always assimilate any foreign promise, so the - // return type of the body is awaited type of the body, wrapped in a native Promise type. - var promiseType = createPromiseType(widenedType); - if (promiseType === emptyObjectType) { - error(func, ts.Diagnostics.An_async_function_or_method_must_have_a_valid_awaitable_return_type); - return unknownType; - } - return promiseType; - } - else { - return widenedType; - } - } - function checkAndAggregateYieldOperandTypes(body, contextualMapper) { - var aggregatedTypes = []; - ts.forEachYieldExpression(body, function (yieldExpression) { - var expr = yieldExpression.expression; - if (expr) { - var type = checkExpressionCached(expr, contextualMapper); - if (yieldExpression.asteriskToken) { - // A yield* expression effectively yields everything that its operand yields - type = checkElementTypeOfIterable(type, yieldExpression.expression); - } - if (!ts.contains(aggregatedTypes, type)) { - aggregatedTypes.push(type); - } - } - }); - return aggregatedTypes; - } - function checkAndAggregateReturnExpressionTypes(body, contextualMapper, isAsync) { - var aggregatedTypes = []; - ts.forEachReturnStatement(body, function (returnStatement) { - var expr = returnStatement.expression; - if (expr) { - var type = checkExpressionCached(expr, contextualMapper); - if (isAsync) { - // From within an async function you can return either a non-promise value or a promise. Any - // Promise/A+ compatible implementation will always assimilate any foreign promise, so the - // return type of the body should be unwrapped to its awaited type, which should be wrapped in - // the native Promise type by the caller. - type = checkAwaitedType(type, body.parent, ts.Diagnostics.Return_expression_in_async_function_does_not_have_a_valid_callable_then_member); - } - if (!ts.contains(aggregatedTypes, type)) { - aggregatedTypes.push(type); - } - } - }); - return aggregatedTypes; - } - function bodyContainsAReturnStatement(funcBody) { - return ts.forEachReturnStatement(funcBody, function (returnStatement) { - return true; - }); - } - function bodyContainsSingleThrowStatement(body) { - return (body.statements.length === 1) && (body.statements[0].kind === 208 /* ThrowStatement */); - } - // TypeScript Specification 1.0 (6.3) - July 2014 - // An explicitly typed function whose return type isn't the Void or the Any type - // must have at least one return statement somewhere in its body. - // An exception to this rule is if the function implementation consists of a single 'throw' statement. - function checkIfNonVoidFunctionHasReturnExpressionsOrSingleThrowStatment(func, returnType) { - if (!produceDiagnostics) { - return; - } - // Functions that return 'void' or 'any' don't need any return expressions. - if (returnType === voidType || isTypeAny(returnType)) { - return; - } - // If all we have is a function signature, or an arrow function with an expression body, then there is nothing to check. - if (ts.nodeIsMissing(func.body) || func.body.kind !== 192 /* Block */) { - return; - } - var bodyBlock = func.body; - // Ensure the body has at least one return expression. - if (bodyContainsAReturnStatement(bodyBlock)) { - return; - } - // If there are no return expressions, then we need to check if - // the function body consists solely of a throw statement; - // this is to make an exception for unimplemented functions. - if (bodyContainsSingleThrowStatement(bodyBlock)) { - return; - } - // This function does not conform to the specification. - error(func.type, ts.Diagnostics.A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value_or_consist_of_a_single_throw_statement); - } - function checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper) { - ts.Debug.assert(node.kind !== 143 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); - // Grammar checking - var hasGrammarError = checkGrammarFunctionLikeDeclaration(node); - if (!hasGrammarError && node.kind === 173 /* FunctionExpression */) { - checkGrammarForGenerator(node); - } - // The identityMapper object is used to indicate that function expressions are wildcards - if (contextualMapper === identityMapper && isContextSensitive(node)) { - return anyFunctionType; - } - var isAsync = ts.isAsyncFunctionLike(node); - if (isAsync) { - emitAwaiter = true; - } - var links = getNodeLinks(node); - var type = getTypeOfSymbol(node.symbol); - var contextSensitive = isContextSensitive(node); - var mightFixTypeParameters = contextSensitive && isInferentialContext(contextualMapper); - // Check if function expression is contextually typed and assign parameter types if so. - // See the comment in assignTypeToParameterAndFixTypeParameters to understand why we need to - // check mightFixTypeParameters. - if (mightFixTypeParameters || !(links.flags & 1024 /* ContextChecked */)) { - var contextualSignature = getContextualSignature(node); - // If a type check is started at a function expression that is an argument of a function call, obtaining the - // contextual type may recursively get back to here during overload resolution of the call. If so, we will have - // already assigned contextual types. - var contextChecked = !!(links.flags & 1024 /* ContextChecked */); - if (mightFixTypeParameters || !contextChecked) { - links.flags |= 1024 /* ContextChecked */; - if (contextualSignature) { - var signature = getSignaturesOfType(type, 0 /* Call */)[0]; - if (contextSensitive) { - assignContextualParameterTypes(signature, contextualSignature, contextualMapper || identityMapper); - } - if (mightFixTypeParameters || !node.type && !signature.resolvedReturnType) { - var returnType = getReturnTypeFromBody(node, contextualMapper); - if (!signature.resolvedReturnType) { - signature.resolvedReturnType = returnType; - } - } - } - if (!contextChecked) { - checkSignatureDeclaration(node); - } - } - } - if (produceDiagnostics && node.kind !== 143 /* MethodDeclaration */ && node.kind !== 142 /* MethodSignature */) { - checkCollisionWithCapturedSuperVariable(node, node.name); - checkCollisionWithCapturedThisVariable(node, node.name); - } - return type; - } - function checkFunctionExpressionOrObjectLiteralMethodBody(node) { - ts.Debug.assert(node.kind !== 143 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); - var isAsync = ts.isAsyncFunctionLike(node); - if (isAsync) { - emitAwaiter = true; - } - var returnType = node.type && getTypeFromTypeNode(node.type); - var promisedType; - if (returnType && isAsync) { - promisedType = checkAsyncFunctionReturnType(node); - } - if (returnType && !node.asteriskToken) { - checkIfNonVoidFunctionHasReturnExpressionsOrSingleThrowStatment(node, isAsync ? promisedType : returnType); - } - if (node.body) { - if (!node.type) { - // There are some checks that are only performed in getReturnTypeFromBody, that may produce errors - // we need. An example is the noImplicitAny errors resulting from widening the return expression - // of a function. Because checking of function expression bodies is deferred, there was never an - // appropriate time to do this during the main walk of the file (see the comment at the top of - // checkFunctionExpressionBodies). So it must be done now. - getReturnTypeOfSignature(getSignatureFromDeclaration(node)); - } - if (node.body.kind === 192 /* Block */) { - checkSourceElement(node.body); - } - else { - // From within an async function you can return either a non-promise value or a promise. Any - // Promise/A+ compatible implementation will always assimilate any foreign promise, so we - // should not be checking assignability of a promise to the return type. Instead, we need to - // check assignability of the awaited type of the expression body against the promised type of - // its return type annotation. - var exprType = checkExpression(node.body); - if (returnType) { - if (isAsync) { - var awaitedType = checkAwaitedType(exprType, node.body, ts.Diagnostics.Expression_body_for_async_arrow_function_does_not_have_a_valid_callable_then_member); - checkTypeAssignableTo(awaitedType, promisedType, node.body); - } - else { - checkTypeAssignableTo(exprType, returnType, node.body); - } - } - checkFunctionAndClassExpressionBodies(node.body); - } - } - } - function checkArithmeticOperandType(operand, type, diagnostic) { - if (!isTypeAnyOrAllConstituentTypesHaveKind(type, 132 /* NumberLike */)) { - error(operand, diagnostic); - return false; - } - return true; - } - function checkReferenceExpression(n, invalidReferenceMessage, constantVariableMessage) { - function findSymbol(n) { - var symbol = getNodeLinks(n).resolvedSymbol; - // Because we got the symbol from the resolvedSymbol property, it might be of kind - // SymbolFlags.ExportValue. In this case it is necessary to get the actual export - // symbol, which will have the correct flags set on it. - return symbol && getExportSymbolOfValueSymbolIfExported(symbol); - } - function isReferenceOrErrorExpression(n) { - // TypeScript 1.0 spec (April 2014): - // Expressions are classified as values or references. - // References are the subset of expressions that are permitted as the target of an assignment. - // Specifically, references are combinations of identifiers(section 4.3), parentheses(section 4.7), - // and property accesses(section 4.10). - // All other expression constructs described in this chapter are classified as values. - switch (n.kind) { - case 69 /* Identifier */: { - var symbol = findSymbol(n); - // TypeScript 1.0 spec (April 2014): 4.3 - // An identifier expression that references a variable or parameter is classified as a reference. - // An identifier expression that references any other kind of entity is classified as a value(and therefore cannot be the target of an assignment). - return !symbol || symbol === unknownSymbol || symbol === argumentsSymbol || (symbol.flags & 3 /* Variable */) !== 0; - } - case 166 /* PropertyAccessExpression */: { - var symbol = findSymbol(n); - // TypeScript 1.0 spec (April 2014): 4.10 - // A property access expression is always classified as a reference. - // NOTE (not in spec): assignment to enum members should not be allowed - return !symbol || symbol === unknownSymbol || (symbol.flags & ~8 /* EnumMember */) !== 0; - } - case 167 /* ElementAccessExpression */: - // old compiler doesn't check indexed access - return true; - case 172 /* ParenthesizedExpression */: - return isReferenceOrErrorExpression(n.expression); - default: - return false; - } - } - function isConstVariableReference(n) { - switch (n.kind) { - case 69 /* Identifier */: - case 166 /* PropertyAccessExpression */: { - var symbol = findSymbol(n); - return symbol && (symbol.flags & 3 /* Variable */) !== 0 && (getDeclarationFlagsFromSymbol(symbol) & 32768 /* Const */) !== 0; - } - case 167 /* ElementAccessExpression */: { - var index = n.argumentExpression; - var symbol = findSymbol(n.expression); - if (symbol && index && index.kind === 9 /* StringLiteral */) { - var name_12 = index.text; - var prop = getPropertyOfType(getTypeOfSymbol(symbol), name_12); - return prop && (prop.flags & 3 /* Variable */) !== 0 && (getDeclarationFlagsFromSymbol(prop) & 32768 /* Const */) !== 0; - } - return false; - } - case 172 /* ParenthesizedExpression */: - return isConstVariableReference(n.expression); - default: - return false; - } - } - if (!isReferenceOrErrorExpression(n)) { - error(n, invalidReferenceMessage); - return false; - } - if (isConstVariableReference(n)) { - error(n, constantVariableMessage); - return false; - } - return true; - } - function checkDeleteExpression(node) { - checkExpression(node.expression); - return booleanType; - } - function checkTypeOfExpression(node) { - checkExpression(node.expression); - return stringType; - } - function checkVoidExpression(node) { - checkExpression(node.expression); - return undefinedType; - } - function checkAwaitExpression(node) { - // Grammar checking - if (produceDiagnostics) { - if (!(node.parserContextFlags & 8 /* Await */)) { - grammarErrorOnFirstToken(node, ts.Diagnostics.await_expression_is_only_allowed_within_an_async_function); - } - if (isInParameterInitializerBeforeContainingFunction(node)) { - error(node, ts.Diagnostics.await_expressions_cannot_be_used_in_a_parameter_initializer); - } - } - var operandType = checkExpression(node.expression); - return checkAwaitedType(operandType, node); - } - function checkPrefixUnaryExpression(node) { - var operandType = checkExpression(node.operand); - switch (node.operator) { - case 35 /* PlusToken */: - case 36 /* MinusToken */: - case 50 /* TildeToken */: - if (someConstituentTypeHasKind(operandType, 16777216 /* ESSymbol */)) { - error(node.operand, ts.Diagnostics.The_0_operator_cannot_be_applied_to_type_symbol, ts.tokenToString(node.operator)); - } - return numberType; - case 49 /* ExclamationToken */: - return booleanType; - case 41 /* PlusPlusToken */: - case 42 /* MinusMinusToken */: - var ok = checkArithmeticOperandType(node.operand, operandType, ts.Diagnostics.An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type); - if (ok) { - // run check only if former checks succeeded to avoid reporting cascading errors - 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); - } - return numberType; - } - return unknownType; - } - function checkPostfixUnaryExpression(node) { - var operandType = checkExpression(node.operand); - var ok = checkArithmeticOperandType(node.operand, operandType, ts.Diagnostics.An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type); - if (ok) { - // run check only if former checks succeeded to avoid reporting cascading errors - 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); - } - return numberType; - } - // Just like isTypeOfKind below, except that it returns true if *any* constituent - // has this kind. - function someConstituentTypeHasKind(type, kind) { - if (type.flags & kind) { - return true; - } - if (type.flags & 49152 /* UnionOrIntersection */) { - var types = type.types; - for (var _i = 0; _i < types.length; _i++) { - var current = types[_i]; - if (current.flags & kind) { - return true; - } - } - return false; - } - return false; - } - // Return true if type has the given flags, or is a union or intersection type composed of types that all have those flags. - function allConstituentTypesHaveKind(type, kind) { - if (type.flags & kind) { - return true; - } - if (type.flags & 49152 /* UnionOrIntersection */) { - var types = type.types; - for (var _i = 0; _i < types.length; _i++) { - var current = types[_i]; - if (!(current.flags & kind)) { - return false; - } - } - return true; - } - return false; - } - function isConstEnumObjectType(type) { - return type.flags & (80896 /* ObjectType */ | 65536 /* Anonymous */) && type.symbol && isConstEnumSymbol(type.symbol); - } - function isConstEnumSymbol(symbol) { - return (symbol.flags & 128 /* ConstEnum */) !== 0; - } - function checkInstanceOfExpression(left, right, leftType, rightType) { - // TypeScript 1.0 spec (April 2014): 4.15.4 - // The instanceof operator requires the left operand to be of type Any, an object type, or a type parameter type, - // and the right operand to be of type Any or a subtype of the 'Function' interface type. - // The result is always of the Boolean primitive type. - // NOTE: do not raise error if leftType is unknown as related error was already reported - if (allConstituentTypesHaveKind(leftType, 16777726 /* Primitive */)) { - error(left, ts.Diagnostics.The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_parameter); - } - // NOTE: do not raise error if right is unknown as related error was already reported - if (!(isTypeAny(rightType) || isTypeSubtypeOf(rightType, globalFunctionType))) { - error(right, ts.Diagnostics.The_right_hand_side_of_an_instanceof_expression_must_be_of_type_any_or_of_a_type_assignable_to_the_Function_interface_type); - } - return booleanType; - } - function checkInExpression(left, right, leftType, rightType) { - // TypeScript 1.0 spec (April 2014): 4.15.5 - // The in operator requires the left operand to be of type Any, the String primitive type, or the Number primitive type, - // and the right operand to be of type Any, an object type, or a type parameter type. - // The result is always of the Boolean primitive type. - if (!isTypeAnyOrAllConstituentTypesHaveKind(leftType, 258 /* StringLike */ | 132 /* NumberLike */ | 16777216 /* ESSymbol */)) { - error(left, ts.Diagnostics.The_left_hand_side_of_an_in_expression_must_be_of_type_any_string_number_or_symbol); - } - if (!isTypeAnyOrAllConstituentTypesHaveKind(rightType, 80896 /* ObjectType */ | 512 /* TypeParameter */)) { - error(right, ts.Diagnostics.The_right_hand_side_of_an_in_expression_must_be_of_type_any_an_object_type_or_a_type_parameter); - } - return booleanType; - } - function checkObjectLiteralAssignment(node, sourceType, contextualMapper) { - var properties = node.properties; - for (var _i = 0; _i < properties.length; _i++) { - var p = properties[_i]; - if (p.kind === 245 /* PropertyAssignment */ || p.kind === 246 /* ShorthandPropertyAssignment */) { - // TODO(andersh): Computed property support - var name_13 = p.name; - var type = isTypeAny(sourceType) - ? sourceType - : getTypeOfPropertyOfType(sourceType, name_13.text) || - isNumericLiteralName(name_13.text) && getIndexTypeOfType(sourceType, 1 /* Number */) || - getIndexTypeOfType(sourceType, 0 /* String */); - if (type) { - if (p.kind === 246 /* ShorthandPropertyAssignment */) { - checkDestructuringAssignment(p, type); - } - else { - checkDestructuringAssignment(p.initializer || name_13, type); - } - } - else { - error(name_13, ts.Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(sourceType), ts.declarationNameToString(name_13)); - } - } - else { - error(p, ts.Diagnostics.Property_assignment_expected); - } - } - return sourceType; - } - function checkArrayLiteralAssignment(node, sourceType, contextualMapper) { - // This elementType will be used if the specific property corresponding to this index is not - // present (aka the tuple element property). This call also checks that the parentType is in - // fact an iterable or array (depending on target language). - var elementType = checkIteratedTypeOrElementType(sourceType, node, /*allowStringInput*/ false) || unknownType; - var elements = node.elements; - for (var i = 0; i < elements.length; i++) { - var e = elements[i]; - if (e.kind !== 187 /* OmittedExpression */) { - if (e.kind !== 185 /* SpreadElementExpression */) { - var propName = "" + i; - var type = isTypeAny(sourceType) - ? sourceType - : isTupleLikeType(sourceType) - ? getTypeOfPropertyOfType(sourceType, propName) - : elementType; - if (type) { - checkDestructuringAssignment(e, type, contextualMapper); - } - else { - if (isTupleType(sourceType)) { - error(e, ts.Diagnostics.Tuple_type_0_with_length_1_cannot_be_assigned_to_tuple_with_length_2, typeToString(sourceType), sourceType.elementTypes.length, elements.length); - } - else { - error(e, ts.Diagnostics.Type_0_has_no_property_1, typeToString(sourceType), propName); - } - } - } - else { - if (i < elements.length - 1) { - error(e, ts.Diagnostics.A_rest_element_must_be_last_in_an_array_destructuring_pattern); - } - else { - var restExpression = e.expression; - if (restExpression.kind === 181 /* BinaryExpression */ && restExpression.operatorToken.kind === 56 /* EqualsToken */) { - error(restExpression.operatorToken, ts.Diagnostics.A_rest_element_cannot_have_an_initializer); - } - else { - checkDestructuringAssignment(restExpression, createArrayType(elementType), contextualMapper); - } - } - } - } - } - return sourceType; - } - function checkDestructuringAssignment(exprOrAssignment, sourceType, contextualMapper) { - var target; - if (exprOrAssignment.kind === 246 /* ShorthandPropertyAssignment */) { - var prop = exprOrAssignment; - if (prop.objectAssignmentInitializer) { - checkBinaryLikeExpression(prop.name, prop.equalsToken, prop.objectAssignmentInitializer, contextualMapper); - } - target = exprOrAssignment.name; - } - else { - target = exprOrAssignment; - } - if (target.kind === 181 /* BinaryExpression */ && target.operatorToken.kind === 56 /* EqualsToken */) { - checkBinaryExpression(target, contextualMapper); - target = target.left; - } - if (target.kind === 165 /* ObjectLiteralExpression */) { - return checkObjectLiteralAssignment(target, sourceType, contextualMapper); - } - if (target.kind === 164 /* ArrayLiteralExpression */) { - return checkArrayLiteralAssignment(target, sourceType, contextualMapper); - } - return checkReferenceAssignment(target, sourceType, contextualMapper); - } - function checkReferenceAssignment(target, sourceType, contextualMapper) { - var targetType = checkExpression(target, contextualMapper); - if (checkReferenceExpression(target, ts.Diagnostics.Invalid_left_hand_side_of_assignment_expression, ts.Diagnostics.Left_hand_side_of_assignment_expression_cannot_be_a_constant)) { - checkTypeAssignableTo(sourceType, targetType, target, /*headMessage*/ undefined); - } - return sourceType; - } - function checkBinaryExpression(node, contextualMapper) { - return checkBinaryLikeExpression(node.left, node.operatorToken, node.right, contextualMapper, node); - } - function checkBinaryLikeExpression(left, operatorToken, right, contextualMapper, errorNode) { - var operator = operatorToken.kind; - if (operator === 56 /* EqualsToken */ && (left.kind === 165 /* ObjectLiteralExpression */ || left.kind === 164 /* ArrayLiteralExpression */)) { - return checkDestructuringAssignment(left, checkExpression(right, contextualMapper), contextualMapper); - } - var leftType = checkExpression(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 */: - // TypeScript 1.0 spec (April 2014): 4.19.1 - // These operators require their operands to be of type Any, the Number primitive type, - // or an enum type. Operands of an enum type are treated - // as having the primitive type Number. If one operand is the null or undefined value, - // it is treated as having the type of the other operand. - // The result is always of the Number primitive type. - if (leftType.flags & (32 /* Undefined */ | 64 /* Null */)) - leftType = rightType; - if (rightType.flags & (32 /* Undefined */ | 64 /* Null */)) - rightType = leftType; - var suggestedOperator; - // if a user tries to apply a bitwise operator to 2 boolean operands - // try and return them a helpful suggestion - if ((leftType.flags & 8 /* Boolean */) && - (rightType.flags & 8 /* Boolean */) && - (suggestedOperator = getSuggestedBooleanOperator(operatorToken.kind)) !== undefined) { - error(errorNode || operatorToken, ts.Diagnostics.The_0_operator_is_not_allowed_for_boolean_types_Consider_using_1_instead, ts.tokenToString(operatorToken.kind), ts.tokenToString(suggestedOperator)); - } - else { - // otherwise just check each operand separately and report errors as normal - var leftOk = checkArithmeticOperandType(left, leftType, ts.Diagnostics.The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type); - var rightOk = checkArithmeticOperandType(right, rightType, ts.Diagnostics.The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type); - if (leftOk && rightOk) { - checkAssignmentOperator(numberType); - } - } - return numberType; - case 35 /* PlusToken */: - case 57 /* PlusEqualsToken */: - // TypeScript 1.0 spec (April 2014): 4.19.2 - // The binary + operator requires both operands to be of the Number primitive type or an enum type, - // or at least one of the operands to be of type Any or the String primitive type. - // If one operand is the null or undefined value, it is treated as having the type of the other operand. - if (leftType.flags & (32 /* Undefined */ | 64 /* Null */)) - leftType = rightType; - if (rightType.flags & (32 /* Undefined */ | 64 /* Null */)) - rightType = leftType; - var resultType; - if (allConstituentTypesHaveKind(leftType, 132 /* NumberLike */) && allConstituentTypesHaveKind(rightType, 132 /* NumberLike */)) { - // Operands of an enum type are treated as having the primitive type Number. - // If both operands are of the Number primitive type, the result is of the Number primitive type. - resultType = numberType; - } - else { - if (allConstituentTypesHaveKind(leftType, 258 /* StringLike */) || allConstituentTypesHaveKind(rightType, 258 /* StringLike */)) { - // If one or both operands are of the String primitive type, the result is of the String primitive type. - resultType = stringType; - } - else if (isTypeAny(leftType) || isTypeAny(rightType)) { - // Otherwise, the result is of type Any. - // NOTE: unknown type here denotes error type. Old compiler treated this case as any type so do we. - resultType = leftType === unknownType || rightType === unknownType ? unknownType : anyType; - } - // Symbols are not allowed at all in arithmetic expressions - if (resultType && !checkForDisallowedESSymbolOperand(operator)) { - return resultType; - } - } - if (!resultType) { - reportOperatorError(); - return anyType; - } - if (operator === 57 /* PlusEqualsToken */) { - checkAssignmentOperator(resultType); - } - return resultType; - case 25 /* LessThanToken */: - case 27 /* GreaterThanToken */: - case 28 /* LessThanEqualsToken */: - case 29 /* GreaterThanEqualsToken */: - if (!checkForDisallowedESSymbolOperand(operator)) { - return booleanType; - } - // Fall through - case 30 /* EqualsEqualsToken */: - case 31 /* ExclamationEqualsToken */: - case 32 /* EqualsEqualsEqualsToken */: - case 33 /* ExclamationEqualsEqualsToken */: - if (!isTypeAssignableTo(leftType, rightType) && !isTypeAssignableTo(rightType, leftType)) { - reportOperatorError(); - } - return booleanType; - case 91 /* InstanceOfKeyword */: - return checkInstanceOfExpression(left, right, leftType, rightType); - case 90 /* InKeyword */: - return checkInExpression(left, right, leftType, rightType); - case 51 /* AmpersandAmpersandToken */: - return rightType; - case 52 /* BarBarToken */: - return getUnionType([leftType, rightType]); - case 56 /* EqualsToken */: - checkAssignmentOperator(rightType); - return getRegularTypeOfObjectLiteral(rightType); - case 24 /* CommaToken */: - return rightType; - } - // Return true if there was no error, false if there was an error. - function checkForDisallowedESSymbolOperand(operator) { - var offendingSymbolOperand = someConstituentTypeHasKind(leftType, 16777216 /* ESSymbol */) ? left : - someConstituentTypeHasKind(rightType, 16777216 /* ESSymbol */) ? right : - undefined; - if (offendingSymbolOperand) { - error(offendingSymbolOperand, ts.Diagnostics.The_0_operator_cannot_be_applied_to_type_symbol, ts.tokenToString(operator)); - return false; - } - return true; - } - 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 */; - default: - return undefined; - } - } - function checkAssignmentOperator(valueType) { - if (produceDiagnostics && operator >= 56 /* FirstAssignment */ && operator <= 68 /* LastAssignment */) { - // TypeScript 1.0 spec (April 2014): 4.17 - // An assignment of the form - // VarExpr = ValueExpr - // requires VarExpr to be classified as a reference - // A compound assignment furthermore requires VarExpr to be classified as a reference (section 4.1) - // and the type of the non - compound operation to be assignable to the type of VarExpr. - var ok = checkReferenceExpression(left, ts.Diagnostics.Invalid_left_hand_side_of_assignment_expression, ts.Diagnostics.Left_hand_side_of_assignment_expression_cannot_be_a_constant); - // Use default messages - if (ok) { - // to avoid cascading errors check assignability only if 'isReference' check succeeded and no errors were reported - checkTypeAssignableTo(valueType, leftType, left, /*headMessage*/ undefined); - } - } - } - function reportOperatorError() { - error(errorNode || operatorToken, ts.Diagnostics.Operator_0_cannot_be_applied_to_types_1_and_2, ts.tokenToString(operatorToken.kind), typeToString(leftType), typeToString(rightType)); - } - } - function isYieldExpressionInClass(node) { - var current = node; - var parent = node.parent; - while (parent) { - if (ts.isFunctionLike(parent) && current === parent.body) { - return false; - } - else if (ts.isClassLike(current)) { - return true; - } - current = parent; - parent = parent.parent; - } - return false; - } - function checkYieldExpression(node) { - // Grammar checking - if (produceDiagnostics) { - if (!(node.parserContextFlags & 2 /* Yield */) || isYieldExpressionInClass(node)) { - grammarErrorOnFirstToken(node, ts.Diagnostics.A_yield_expression_is_only_allowed_in_a_generator_body); - } - if (isInParameterInitializerBeforeContainingFunction(node)) { - error(node, ts.Diagnostics.yield_expressions_cannot_be_used_in_a_parameter_initializer); - } - } - if (node.expression) { - var func = ts.getContainingFunction(node); - // If the user's code is syntactically correct, the func should always have a star. After all, - // we are in a yield context. - if (func && func.asteriskToken) { - var expressionType = checkExpressionCached(node.expression, /*contextualMapper*/ undefined); - var expressionElementType; - var nodeIsYieldStar = !!node.asteriskToken; - if (nodeIsYieldStar) { - expressionElementType = checkElementTypeOfIterable(expressionType, node.expression); - } - // There is no point in doing an assignability check if the function - // has no explicit return type because the return type is directly computed - // from the yield expressions. - if (func.type) { - var signatureElementType = getElementTypeOfIterableIterator(getTypeFromTypeNode(func.type)) || anyType; - if (nodeIsYieldStar) { - checkTypeAssignableTo(expressionElementType, signatureElementType, node.expression, /*headMessage*/ undefined); - } - else { - checkTypeAssignableTo(expressionType, signatureElementType, node.expression, /*headMessage*/ undefined); - } - } - } - } - // Both yield and yield* expressions have type 'any' - return anyType; - } - function checkConditionalExpression(node, contextualMapper) { - checkExpression(node.condition); - var type1 = checkExpression(node.whenTrue, contextualMapper); - var type2 = checkExpression(node.whenFalse, contextualMapper); - return getUnionType([type1, type2]); - } - function checkTemplateExpression(node) { - // We just want to check each expressions, but we are unconcerned with - // the type of each expression, as any value may be coerced into a string. - // It is worth asking whether this is what we really want though. - // A place where we actually *are* concerned with the expressions' types are - // in tagged templates. - ts.forEach(node.templateSpans, function (templateSpan) { - checkExpression(templateSpan.expression); - }); - return stringType; - } - function checkExpressionWithContextualType(node, contextualType, contextualMapper) { - var saveContextualType = node.contextualType; - node.contextualType = contextualType; - var result = checkExpression(node, contextualMapper); - node.contextualType = saveContextualType; - return result; - } - function checkExpressionCached(node, contextualMapper) { - var links = getNodeLinks(node); - if (!links.resolvedType) { - links.resolvedType = checkExpression(node, contextualMapper); - } - return links.resolvedType; - } - function checkPropertyAssignment(node, contextualMapper) { - // 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 === 136 /* ComputedPropertyName */) { - checkComputedPropertyName(node.name); - } - return checkExpression(node.initializer, contextualMapper); - } - function checkObjectLiteralMethod(node, contextualMapper) { - // Grammar checking - checkGrammarMethod(node); - // 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 === 136 /* ComputedPropertyName */) { - checkComputedPropertyName(node.name); - } - var uninstantiatedType = checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); - return instantiateTypeWithSingleGenericCallSignature(node, uninstantiatedType, contextualMapper); - } - function instantiateTypeWithSingleGenericCallSignature(node, type, contextualMapper) { - if (isInferentialContext(contextualMapper)) { - var signature = getSingleCallSignature(type); - if (signature && signature.typeParameters) { - var contextualType = getContextualType(node); - if (contextualType) { - var contextualSignature = getSingleCallSignature(contextualType); - if (contextualSignature && !contextualSignature.typeParameters) { - return getOrCreateTypeFromSignature(instantiateSignatureInContextOf(signature, contextualSignature, contextualMapper)); - } - } - } - } - return type; - } - // Checks an expression and returns its type. The contextualMapper parameter serves two purposes: When - // contextualMapper is not undefined and not equal to the identityMapper function object it indicates that the - // expression is being inferentially typed (section 4.12.2 in spec) and provides the type mapper to use in - // conjunction with the generic contextual type. When contextualMapper is equal to the identityMapper function - // object, it serves as an indicator that all contained function and arrow expressions should be considered to - // have the wildcard function type; this form of type check is used during overload resolution to exclude - // contextually typed function and arrow expressions in the initial phase. - function checkExpression(node, contextualMapper) { - var type; - if (node.kind === 135 /* QualifiedName */) { - type = checkQualifiedName(node); - } - else { - var uninstantiatedType = checkExpressionWorker(node, contextualMapper); - type = instantiateTypeWithSingleGenericCallSignature(node, uninstantiatedType, contextualMapper); - } - if (isConstEnumObjectType(type)) { - // enum object type for const enums are only permitted in: - // - 'left' in property access - // - 'object' in indexed access - // - target in rhs of import statement - var ok = (node.parent.kind === 166 /* PropertyAccessExpression */ && node.parent.expression === node) || - (node.parent.kind === 167 /* ElementAccessExpression */ && node.parent.expression === node) || - ((node.kind === 69 /* Identifier */ || node.kind === 135 /* QualifiedName */) && isInRightSideOfImportOrExportAssignment(node)); - if (!ok) { - error(node, ts.Diagnostics.const_enums_can_only_be_used_in_property_or_index_access_expressions_or_the_right_hand_side_of_an_import_declaration_or_export_assignment); - } - } - return type; - } - function checkNumericLiteral(node) { - // Grammar checking - checkGrammarNumericLiteral(node); - return numberType; - } - function checkExpressionWorker(node, contextualMapper) { - switch (node.kind) { - case 69 /* Identifier */: - return checkIdentifier(node); - case 97 /* ThisKeyword */: - return checkThisExpression(node); - case 95 /* SuperKeyword */: - return checkSuperExpression(node); - case 93 /* NullKeyword */: - return nullType; - case 99 /* TrueKeyword */: - case 84 /* FalseKeyword */: - return booleanType; - case 8 /* NumericLiteral */: - return checkNumericLiteral(node); - case 183 /* TemplateExpression */: - return checkTemplateExpression(node); - case 9 /* StringLiteral */: - case 11 /* NoSubstitutionTemplateLiteral */: - return stringType; - case 10 /* RegularExpressionLiteral */: - return globalRegExpType; - case 164 /* ArrayLiteralExpression */: - return checkArrayLiteral(node, contextualMapper); - case 165 /* ObjectLiteralExpression */: - return checkObjectLiteral(node, contextualMapper); - case 166 /* PropertyAccessExpression */: - return checkPropertyAccessExpression(node); - case 167 /* ElementAccessExpression */: - return checkIndexedAccess(node); - case 168 /* CallExpression */: - case 169 /* NewExpression */: - return checkCallExpression(node); - case 170 /* TaggedTemplateExpression */: - return checkTaggedTemplateExpression(node); - case 172 /* ParenthesizedExpression */: - return checkExpression(node.expression, contextualMapper); - case 186 /* ClassExpression */: - return checkClassExpression(node); - case 173 /* FunctionExpression */: - case 174 /* ArrowFunction */: - return checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); - case 176 /* TypeOfExpression */: - return checkTypeOfExpression(node); - case 171 /* TypeAssertionExpression */: - case 189 /* AsExpression */: - return checkAssertion(node); - case 175 /* DeleteExpression */: - return checkDeleteExpression(node); - case 177 /* VoidExpression */: - return checkVoidExpression(node); - case 178 /* AwaitExpression */: - return checkAwaitExpression(node); - case 179 /* PrefixUnaryExpression */: - return checkPrefixUnaryExpression(node); - case 180 /* PostfixUnaryExpression */: - return checkPostfixUnaryExpression(node); - case 181 /* BinaryExpression */: - return checkBinaryExpression(node, contextualMapper); - case 182 /* ConditionalExpression */: - return checkConditionalExpression(node, contextualMapper); - case 185 /* SpreadElementExpression */: - return checkSpreadElementExpression(node, contextualMapper); - case 187 /* OmittedExpression */: - return undefinedType; - case 184 /* YieldExpression */: - return checkYieldExpression(node); - case 240 /* JsxExpression */: - return checkJsxExpression(node); - case 233 /* JsxElement */: - return checkJsxElement(node); - case 234 /* JsxSelfClosingElement */: - return checkJsxSelfClosingElement(node); - case 235 /* JsxOpeningElement */: - ts.Debug.fail("Shouldn't ever directly check a JsxOpeningElement"); - } - return unknownType; - } - // DECLARATION AND STATEMENT TYPE CHECKING - function checkTypeParameter(node) { - // Grammar Checking - if (node.expression) { - grammarErrorOnFirstToken(node.expression, ts.Diagnostics.Type_expected); - } - checkSourceElement(node.constraint); - if (produceDiagnostics) { - checkTypeParameterHasIllegalReferencesInConstraint(node); - checkTypeNameIsReserved(node.name, ts.Diagnostics.Type_parameter_name_cannot_be_0); - } - // TODO: Check multiple declarations are identical - } - function checkParameter(node) { - // Grammar checking - // It is a SyntaxError if the Identifier "eval" or the Identifier "arguments" occurs as the - // Identifier in a PropertySetParameterList of a PropertyAssignment that is contained in strict code - // or if its FunctionBody is strict code(11.1.5). - // Grammar checking - checkGrammarDecorators(node) || checkGrammarModifiers(node); - checkVariableLikeDeclaration(node); - var func = ts.getContainingFunction(node); - if (node.flags & 112 /* AccessibilityModifier */) { - func = ts.getContainingFunction(node); - if (!(func.kind === 144 /* Constructor */ && ts.nodeIsPresent(func.body))) { - error(node, ts.Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation); - } - } - if (node.questionToken && ts.isBindingPattern(node.name) && func.body) { - error(node, ts.Diagnostics.A_binding_pattern_parameter_cannot_be_optional_in_an_implementation_signature); - } - // Only check rest parameter type if it's not a binding pattern. Since binding patterns are - // not allowed in a rest parameter, we already have an error from checkGrammarParameterList. - if (node.dotDotDotToken && !ts.isBindingPattern(node.name) && !isArrayType(getTypeOfSymbol(node.symbol))) { - error(node, ts.Diagnostics.A_rest_parameter_must_be_of_an_array_type); - } - } - function isSyntacticallyValidGenerator(node) { - if (!node.asteriskToken || !node.body) { - return false; - } - return node.kind === 143 /* MethodDeclaration */ || - node.kind === 213 /* FunctionDeclaration */ || - node.kind === 173 /* FunctionExpression */; - } - function getTypePredicateParameterIndex(parameterList, parameter) { - if (parameterList) { - for (var i = 0; i < parameterList.length; i++) { - var param = parameterList[i]; - if (param.name.kind === 69 /* Identifier */ && - param.name.text === parameter.text) { - return i; - } - } - } - return -1; - } - function isInLegalTypePredicatePosition(node) { - switch (node.parent.kind) { - case 174 /* ArrowFunction */: - case 147 /* CallSignature */: - case 213 /* FunctionDeclaration */: - case 173 /* FunctionExpression */: - case 152 /* FunctionType */: - case 143 /* MethodDeclaration */: - case 142 /* MethodSignature */: - return node === node.parent.type; - } - return false; - } - function checkSignatureDeclaration(node) { - // Grammar checking - if (node.kind === 149 /* IndexSignature */) { - checkGrammarIndexSignature(node); - } - else if (node.kind === 152 /* FunctionType */ || node.kind === 213 /* FunctionDeclaration */ || node.kind === 153 /* ConstructorType */ || - node.kind === 147 /* CallSignature */ || node.kind === 144 /* Constructor */ || - node.kind === 148 /* ConstructSignature */) { - checkGrammarFunctionLikeDeclaration(node); - } - checkTypeParameters(node.typeParameters); - ts.forEach(node.parameters, checkParameter); - if (node.type) { - if (node.type.kind === 150 /* TypePredicate */) { - var typePredicate = getSignatureFromDeclaration(node).typePredicate; - var typePredicateNode = node.type; - if (isInLegalTypePredicatePosition(typePredicateNode)) { - if (typePredicate.parameterIndex >= 0) { - if (node.parameters[typePredicate.parameterIndex].dotDotDotToken) { - error(typePredicateNode.parameterName, ts.Diagnostics.A_type_predicate_cannot_reference_a_rest_parameter); - } - else { - checkTypeAssignableTo(typePredicate.type, getTypeOfNode(node.parameters[typePredicate.parameterIndex]), typePredicateNode.type); - } - } - else if (typePredicateNode.parameterName) { - var hasReportedError = false; - for (var _i = 0, _a = node.parameters; _i < _a.length; _i++) { - var param = _a[_i]; - if (hasReportedError) { - break; - } - if (param.name.kind === 161 /* ObjectBindingPattern */ || - param.name.kind === 162 /* ArrayBindingPattern */) { - (function checkBindingPattern(pattern) { - for (var _i = 0, _a = pattern.elements; _i < _a.length; _i++) { - var element = _a[_i]; - if (element.name.kind === 69 /* Identifier */ && - element.name.text === typePredicate.parameterName) { - error(typePredicateNode.parameterName, ts.Diagnostics.A_type_predicate_cannot_reference_element_0_in_a_binding_pattern, typePredicate.parameterName); - hasReportedError = true; - break; - } - else if (element.name.kind === 162 /* ArrayBindingPattern */ || - element.name.kind === 161 /* ObjectBindingPattern */) { - checkBindingPattern(element.name); - } - } - })(param.name); - } - } - if (!hasReportedError) { - error(typePredicateNode.parameterName, ts.Diagnostics.Cannot_find_parameter_0, typePredicate.parameterName); - } - } - } - else { - error(typePredicateNode, ts.Diagnostics.A_type_predicate_is_only_allowed_in_return_type_position_for_functions_and_methods); - } - } - else { - checkSourceElement(node.type); - } - } - if (produceDiagnostics) { - checkCollisionWithArgumentsInGeneratedCode(node); - if (compilerOptions.noImplicitAny && !node.type) { - switch (node.kind) { - case 148 /* ConstructSignature */: - error(node, ts.Diagnostics.Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); - break; - case 147 /* 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)) { - var returnType = getTypeFromTypeNode(node.type); - if (returnType === voidType) { - error(node.type, ts.Diagnostics.A_generator_cannot_have_a_void_type_annotation); - } - else { - var generatorElementType = getElementTypeOfIterableIterator(returnType) || anyType; - var iterableIteratorInstantiation = createIterableIteratorType(generatorElementType); - // Naively, one could check that IterableIterator is assignable to the return type annotation. - // However, that would not catch the error in the following case. - // - // interface BadGenerator extends Iterable, Iterator { } - // function* g(): BadGenerator { } // Iterable and Iterator have different types! - // - checkTypeAssignableTo(iterableIteratorInstantiation, returnType, node.type); - } - } - } - } - checkSpecializedSignatureDeclaration(node); - } - function checkTypeForDuplicateIndexSignatures(node) { - if (node.kind === 215 /* InterfaceDeclaration */) { - var nodeSymbol = getSymbolOfNode(node); - // in case of merging interface declaration it is possible that we'll enter this check procedure several times for every declaration - // to prevent this run check only for the first declaration of a given kind - if (nodeSymbol.declarations.length > 0 && nodeSymbol.declarations[0] !== node) { - return; - } - } - // TypeScript 1.0 spec (April 2014) - // 3.7.4: An object type can contain at most one string index signature and one numeric index signature. - // 8.5: A class declaration can have at most one string index member declaration and one numeric index member declaration - var indexSymbol = getIndexSymbol(getSymbolOfNode(node)); - if (indexSymbol) { - var seenNumericIndexer = false; - var seenStringIndexer = false; - for (var _i = 0, _a = indexSymbol.declarations; _i < _a.length; _i++) { - var decl = _a[_i]; - var declaration = decl; - if (declaration.parameters.length === 1 && declaration.parameters[0].type) { - switch (declaration.parameters[0].type.kind) { - case 130 /* StringKeyword */: - if (!seenStringIndexer) { - seenStringIndexer = true; - } - else { - error(declaration, ts.Diagnostics.Duplicate_string_index_signature); - } - break; - case 128 /* NumberKeyword */: - if (!seenNumericIndexer) { - seenNumericIndexer = true; - } - else { - error(declaration, ts.Diagnostics.Duplicate_number_index_signature); - } - break; - } - } - } - } - } - function checkPropertyDeclaration(node) { - // Grammar checking - checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarProperty(node) || checkGrammarComputedPropertyName(node.name); - checkVariableLikeDeclaration(node); - } - function checkMethodDeclaration(node) { - // Grammar checking - checkGrammarMethod(node) || checkGrammarComputedPropertyName(node.name); - // Grammar checking for modifiers is done inside the function checkGrammarFunctionLikeDeclaration - checkFunctionLikeDeclaration(node); - // Abstract methods cannot have an implementation. - // Extra checks are to avoid reporting multiple errors relating to the "abstractness" of the node. - if (node.flags & 256 /* Abstract */ && node.body) { - error(node, ts.Diagnostics.Method_0_cannot_have_an_implementation_because_it_is_marked_abstract, ts.declarationNameToString(node.name)); - } - } - function checkConstructorDeclaration(node) { - // Grammar check on signature of constructor and modifier of the constructor is done in checkSignatureDeclaration function. - checkSignatureDeclaration(node); - // Grammar check for checking only related to constructoDeclaration - checkGrammarConstructorTypeParameters(node) || checkGrammarConstructorTypeAnnotation(node); - checkSourceElement(node.body); - var symbol = getSymbolOfNode(node); - var firstDeclaration = ts.getDeclarationOfKind(symbol, node.kind); - // Only type check the symbol once - if (node === firstDeclaration) { - checkFunctionOrConstructorSymbol(symbol); - } - // exit early in the case of signature - super checks are not relevant to them - if (ts.nodeIsMissing(node.body)) { - return; - } - if (!produceDiagnostics) { - return; - } - function isSuperCallExpression(n) { - return n.kind === 168 /* CallExpression */ && n.expression.kind === 95 /* SuperKeyword */; - } - function containsSuperCallAsComputedPropertyName(n) { - return n.name && containsSuperCall(n.name); - } - function containsSuperCall(n) { - if (isSuperCallExpression(n)) { - return true; - } - else if (ts.isFunctionLike(n)) { - return false; - } - else if (ts.isClassLike(n)) { - return ts.forEach(n.members, containsSuperCallAsComputedPropertyName); - } - return ts.forEachChild(n, containsSuperCall); - } - function markThisReferencesAsErrors(n) { - if (n.kind === 97 /* ThisKeyword */) { - error(n, ts.Diagnostics.this_cannot_be_referenced_in_current_location); - } - else if (n.kind !== 173 /* FunctionExpression */ && n.kind !== 213 /* FunctionDeclaration */) { - ts.forEachChild(n, markThisReferencesAsErrors); - } - } - function isInstancePropertyWithInitializer(n) { - return n.kind === 141 /* PropertyDeclaration */ && - !(n.flags & 128 /* Static */) && - !!n.initializer; - } - // TS 1.0 spec (April 2014): 8.3.2 - // Constructors of classes with no extends clause may not contain super calls, whereas - // constructors of derived classes must contain at least one super call somewhere in their function body. - var containingClassDecl = node.parent; - if (ts.getClassExtendsHeritageClauseElement(containingClassDecl)) { - var containingClassSymbol = getSymbolOfNode(containingClassDecl); - var containingClassInstanceType = getDeclaredTypeOfSymbol(containingClassSymbol); - var baseConstructorType = getBaseConstructorTypeOfClass(containingClassInstanceType); - if (containsSuperCall(node.body)) { - if (baseConstructorType === nullType) { - error(node, ts.Diagnostics.A_constructor_cannot_contain_a_super_call_when_its_class_extends_null); - } - // The first statement in the body of a constructor (excluding prologue directives) must be a super call - // if both of the following are true: - // - The containing class is a derived class. - // - The constructor declares parameter properties - // or the containing class declares instance member variables with initializers. - var superCallShouldBeFirst = ts.forEach(node.parent.members, isInstancePropertyWithInitializer) || - ts.forEach(node.parameters, function (p) { return p.flags & (16 /* Public */ | 32 /* Private */ | 64 /* Protected */); }); - // Skip past any prologue directives to find the first statement - // to ensure that it was a super call. - if (superCallShouldBeFirst) { - var statements = node.body.statements; - var superCallStatement; - for (var _i = 0; _i < statements.length; _i++) { - var statement = statements[_i]; - if (statement.kind === 195 /* ExpressionStatement */ && isSuperCallExpression(statement.expression)) { - superCallStatement = statement; - break; - } - if (!ts.isPrologueDirective(statement)) { - break; - } - } - if (!superCallStatement) { - error(node, ts.Diagnostics.A_super_call_must_be_the_first_statement_in_the_constructor_when_a_class_contains_initialized_properties_or_has_parameter_properties); - } - else { - // In such a required super call, it is a compile-time error for argument expressions to reference this. - markThisReferencesAsErrors(superCallStatement.expression); - } - } - } - else if (baseConstructorType !== nullType) { - error(node, ts.Diagnostics.Constructors_for_derived_classes_must_contain_a_super_call); - } - } - } - function checkAccessorDeclaration(node) { - if (produceDiagnostics) { - // Grammar checking accessors - checkGrammarFunctionLikeDeclaration(node) || checkGrammarAccessor(node) || checkGrammarComputedPropertyName(node.name); - if (node.kind === 145 /* GetAccessor */) { - if (!ts.isInAmbientContext(node) && ts.nodeIsPresent(node.body) && !(bodyContainsAReturnStatement(node.body) || bodyContainsSingleThrowStatement(node.body))) { - error(node.name, ts.Diagnostics.A_get_accessor_must_return_a_value_or_consist_of_a_single_throw_statement); - } - } - 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 === 145 /* GetAccessor */ ? 146 /* SetAccessor */ : 145 /* GetAccessor */; - var otherAccessor = ts.getDeclarationOfKind(node.symbol, otherKind); - if (otherAccessor) { - if (((node.flags & 112 /* AccessibilityModifier */) !== (otherAccessor.flags & 112 /* AccessibilityModifier */))) { - error(node.name, ts.Diagnostics.Getter_and_setter_accessors_do_not_agree_in_visibility); - } - var currentAccessorType = getAnnotatedAccessorType(node); - var otherAccessorType = getAnnotatedAccessorType(otherAccessor); - // TypeScript 1.0 spec (April 2014): 4.5 - // If both accessors include type annotations, the specified types must be identical. - if (currentAccessorType && otherAccessorType) { - if (!isTypeIdenticalTo(currentAccessorType, otherAccessorType)) { - error(node, ts.Diagnostics.get_and_set_accessor_must_have_the_same_type); - } - } - } - } - getTypeOfAccessors(getSymbolOfNode(node)); - } - checkFunctionLikeDeclaration(node); - } - function checkMissingDeclaration(node) { - checkDecorators(node); - } - function checkTypeArgumentConstraints(typeParameters, typeArguments) { - var result = true; - for (var i = 0; i < typeParameters.length; i++) { - var constraint = getConstraintOfTypeParameter(typeParameters[i]); - if (constraint) { - var typeArgument = typeArguments[i]; - result = result && checkTypeAssignableTo(getTypeFromTypeNode(typeArgument), constraint, typeArgument, ts.Diagnostics.Type_0_does_not_satisfy_the_constraint_1); - } - } - return result; - } - function checkTypeReferenceNode(node) { - checkGrammarTypeArguments(node, node.typeArguments); - var type = getTypeFromTypeReference(node); - if (type !== unknownType && node.typeArguments) { - // Do type argument local checks only if referenced type is successfully resolved - ts.forEach(node.typeArguments, checkSourceElement); - if (produceDiagnostics) { - var symbol = getNodeLinks(node).resolvedSymbol; - var typeParameters = symbol.flags & 524288 /* TypeAlias */ ? getSymbolLinks(symbol).typeParameters : type.target.localTypeParameters; - checkTypeArgumentConstraints(typeParameters, node.typeArguments); - } - } - } - function checkTypeQuery(node) { - getTypeFromTypeQueryNode(node); - } - function checkTypeLiteral(node) { - ts.forEach(node.members, checkSourceElement); - if (produceDiagnostics) { - var type = getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node); - checkIndexConstraints(type); - checkTypeForDuplicateIndexSignatures(node); - } - } - function checkArrayType(node) { - checkSourceElement(node.elementType); - } - function checkTupleType(node) { - // Grammar checking - var hasErrorFromDisallowedTrailingComma = checkGrammarForDisallowedTrailingComma(node.elementTypes); - if (!hasErrorFromDisallowedTrailingComma && node.elementTypes.length === 0) { - grammarErrorOnNode(node, ts.Diagnostics.A_tuple_type_element_list_cannot_be_empty); - } - ts.forEach(node.elementTypes, checkSourceElement); - } - function checkUnionOrIntersectionType(node) { - ts.forEach(node.types, checkSourceElement); - } - function isPrivateWithinAmbient(node) { - return (node.flags & 32 /* Private */) && ts.isInAmbientContext(node); - } - function checkSpecializedSignatureDeclaration(signatureDeclarationNode) { - if (!produceDiagnostics) { - return; - } - var signature = getSignatureFromDeclaration(signatureDeclarationNode); - if (!signature.hasStringLiterals) { - return; - } - // TypeScript 1.0 spec (April 2014): 3.7.2.2 - // Specialized signatures are not permitted in conjunction with a function body - if (ts.nodeIsPresent(signatureDeclarationNode.body)) { - error(signatureDeclarationNode, ts.Diagnostics.A_signature_with_an_implementation_cannot_use_a_string_literal_type); - return; - } - // TypeScript 1.0 spec (April 2014): 3.7.2.4 - // Every specialized call or construct signature in an object type must be assignable - // to at least one non-specialized call or construct signature in the same object type - var signaturesToCheck; - // Unnamed (call\construct) signatures in interfaces are inherited and not shadowed so examining just node symbol won't give complete answer. - // Use declaring type to obtain full list of signatures. - if (!signatureDeclarationNode.name && signatureDeclarationNode.parent && signatureDeclarationNode.parent.kind === 215 /* InterfaceDeclaration */) { - ts.Debug.assert(signatureDeclarationNode.kind === 147 /* CallSignature */ || signatureDeclarationNode.kind === 148 /* ConstructSignature */); - var signatureKind = signatureDeclarationNode.kind === 147 /* CallSignature */ ? 0 /* Call */ : 1 /* Construct */; - var containingSymbol = getSymbolOfNode(signatureDeclarationNode.parent); - var containingType = getDeclaredTypeOfSymbol(containingSymbol); - signaturesToCheck = getSignaturesOfType(containingType, signatureKind); - } - else { - signaturesToCheck = getSignaturesOfSymbol(getSymbolOfNode(signatureDeclarationNode)); - } - for (var _i = 0; _i < signaturesToCheck.length; _i++) { - var otherSignature = signaturesToCheck[_i]; - if (!otherSignature.hasStringLiterals && isSignatureAssignableTo(signature, otherSignature)) { - return; - } - } - error(signatureDeclarationNode, ts.Diagnostics.Specialized_overload_signature_is_not_assignable_to_any_non_specialized_signature); - } - function getEffectiveDeclarationFlags(n, flagsToCheck) { - var flags = ts.getCombinedNodeFlags(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 !== 215 /* InterfaceDeclaration */ && - n.parent.kind !== 214 /* ClassDeclaration */ && - n.parent.kind !== 186 /* ClassExpression */ && - ts.isInAmbientContext(n)) { - if (!(flags & 2 /* Ambient */)) { - // It is nested in an ambient context, which means it is automatically exported - flags |= 1 /* Export */; - } - flags |= 2 /* Ambient */; - } - return flags & flagsToCheck; - } - function checkFunctionOrConstructorSymbol(symbol) { - if (!produceDiagnostics) { - return; - } - function getCanonicalOverload(overloads, implementation) { - // Consider the canonical set of flags to be the flags of the bodyDeclaration or the first declaration - // Error on all deviations from this canonical set of flags - // The caveat is that if some overloads are defined in lib.d.ts, we don't want to - // report the errors on those. To achieve this, we will say that the implementation is - // the canonical signature only if it is in the same container as the first overload - var implementationSharesContainerWithFirstOverload = implementation !== undefined && implementation.parent === overloads[0].parent; - return implementationSharesContainerWithFirstOverload ? implementation : overloads[0]; - } - function checkFlagAgreementBetweenOverloads(overloads, implementation, flagsToCheck, someOverloadFlags, allOverloadFlags) { - // Error if some overloads have a flag that is not shared by all overloads. To find the - // deviations, we XOR someOverloadFlags with allOverloadFlags - var someButNotAllOverloadFlags = someOverloadFlags ^ allOverloadFlags; - if (someButNotAllOverloadFlags !== 0) { - var canonicalFlags = getEffectiveDeclarationFlags(getCanonicalOverload(overloads, implementation), flagsToCheck); - ts.forEach(overloads, function (o) { - var deviation = getEffectiveDeclarationFlags(o, flagsToCheck) ^ canonicalFlags; - if (deviation & 1 /* Export */) { - error(o.name, ts.Diagnostics.Overload_signatures_must_all_be_exported_or_not_exported); - } - else if (deviation & 2 /* Ambient */) { - error(o.name, ts.Diagnostics.Overload_signatures_must_all_be_ambient_or_non_ambient); - } - else if (deviation & (32 /* Private */ | 64 /* Protected */)) { - error(o.name, ts.Diagnostics.Overload_signatures_must_all_be_public_private_or_protected); - } - else if (deviation & 256 /* Abstract */) { - error(o.name, ts.Diagnostics.Overload_signatures_must_all_be_abstract_or_not_abstract); - } - }); - } - } - function checkQuestionTokenAgreementBetweenOverloads(overloads, implementation, someHaveQuestionToken, allHaveQuestionToken) { - if (someHaveQuestionToken !== allHaveQuestionToken) { - var canonicalHasQuestionToken = ts.hasQuestionToken(getCanonicalOverload(overloads, implementation)); - ts.forEach(overloads, function (o) { - var deviation = ts.hasQuestionToken(o) !== canonicalHasQuestionToken; - if (deviation) { - error(o.name, ts.Diagnostics.Overload_signatures_must_all_be_optional_or_required); - } - }); - } - } - var flagsToCheck = 1 /* Export */ | 2 /* Ambient */ | 32 /* Private */ | 64 /* Protected */ | 256 /* Abstract */; - var someNodeFlags = 0; - var allNodeFlags = flagsToCheck; - var someHaveQuestionToken = false; - var allHaveQuestionToken = true; - var hasOverloads = false; - var bodyDeclaration; - var lastSeenNonAmbientDeclaration; - var previousDeclaration; - var declarations = symbol.declarations; - var isConstructor = (symbol.flags & 16384 /* Constructor */) !== 0; - function reportImplementationExpectedError(node) { - if (node.name && ts.nodeIsMissing(node.name)) { - return; - } - var seen = false; - var subsequentNode = ts.forEachChild(node.parent, function (c) { - if (seen) { - return c; - } - else { - seen = c === node; - } - }); - if (subsequentNode) { - if (subsequentNode.kind === node.kind) { - 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) { - // the only situation when this is possible (same kind\same name but different symbol) - mixed static and instance class members - ts.Debug.assert(node.kind === 143 /* MethodDeclaration */ || node.kind === 142 /* MethodSignature */); - ts.Debug.assert((node.flags & 128 /* Static */) !== (subsequentNode.flags & 128 /* Static */)); - var diagnostic = node.flags & 128 /* Static */ ? ts.Diagnostics.Function_overload_must_be_static : ts.Diagnostics.Function_overload_must_not_be_static; - error(errorNode_1, diagnostic); - return; - } - else if (ts.nodeIsPresent(subsequentNode.body)) { - error(errorNode_1, ts.Diagnostics.Function_implementation_name_must_be_0, ts.declarationNameToString(node.name)); - return; - } - } - } - var errorNode = node.name || node; - if (isConstructor) { - error(errorNode, ts.Diagnostics.Constructor_implementation_is_missing); - } - else { - // Report different errors regarding non-consecutive blocks of declarations depending on whether - // the node in question is abstract. - if (node.flags & 256 /* Abstract */) { - error(errorNode, ts.Diagnostics.All_declarations_of_an_abstract_method_must_be_consecutive); - } - else { - error(errorNode, ts.Diagnostics.Function_implementation_is_missing_or_not_immediately_following_the_declaration); - } - } - } - // when checking exported function declarations across modules check only duplicate implementations - // names and consistency of modifiers are verified when we check local symbol - var isExportSymbolInsideModule = symbol.parent && symbol.parent.flags & 1536 /* Module */; - var duplicateFunctionDeclaration = false; - var multipleConstructorImplementation = false; - for (var _i = 0; _i < declarations.length; _i++) { - var current = declarations[_i]; - var node = current; - var inAmbientContext = ts.isInAmbientContext(node); - var inAmbientContextOrInterface = node.parent.kind === 215 /* InterfaceDeclaration */ || node.parent.kind === 155 /* TypeLiteral */ || inAmbientContext; - if (inAmbientContextOrInterface) { - // check if declarations are consecutive only if they are non-ambient - // 1. ambient declarations can be interleaved - // i.e. this is legal - // declare function foo(); - // declare function bar(); - // declare function foo(); - // 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 === 213 /* FunctionDeclaration */ || node.kind === 143 /* MethodDeclaration */ || node.kind === 142 /* MethodSignature */ || node.kind === 144 /* Constructor */) { - var currentNodeFlags = getEffectiveDeclarationFlags(node, flagsToCheck); - someNodeFlags |= currentNodeFlags; - allNodeFlags &= currentNodeFlags; - someHaveQuestionToken = someHaveQuestionToken || ts.hasQuestionToken(node); - allHaveQuestionToken = allHaveQuestionToken && ts.hasQuestionToken(node); - if (ts.nodeIsPresent(node.body) && bodyDeclaration) { - if (isConstructor) { - multipleConstructorImplementation = true; - } - else { - duplicateFunctionDeclaration = true; - } - } - else if (!isExportSymbolInsideModule && previousDeclaration && previousDeclaration.parent === node.parent && previousDeclaration.end !== node.pos) { - reportImplementationExpectedError(previousDeclaration); - } - if (ts.nodeIsPresent(node.body)) { - if (!bodyDeclaration) { - bodyDeclaration = node; - } - } - else { - hasOverloads = true; - } - previousDeclaration = node; - if (!inAmbientContextOrInterface) { - lastSeenNonAmbientDeclaration = node; - } - } - } - if (multipleConstructorImplementation) { - ts.forEach(declarations, function (declaration) { - error(declaration, ts.Diagnostics.Multiple_constructor_implementations_are_not_allowed); - }); - } - if (duplicateFunctionDeclaration) { - ts.forEach(declarations, function (declaration) { - error(declaration.name, ts.Diagnostics.Duplicate_function_implementation); - }); - } - // Abstract methods can't have an implementation -- in particular, they don't need one. - if (!isExportSymbolInsideModule && lastSeenNonAmbientDeclaration && !lastSeenNonAmbientDeclaration.body && - !(lastSeenNonAmbientDeclaration.flags & 256 /* Abstract */)) { - reportImplementationExpectedError(lastSeenNonAmbientDeclaration); - } - if (hasOverloads) { - checkFlagAgreementBetweenOverloads(declarations, bodyDeclaration, flagsToCheck, someNodeFlags, allNodeFlags); - checkQuestionTokenAgreementBetweenOverloads(declarations, bodyDeclaration, someHaveQuestionToken, allHaveQuestionToken); - if (bodyDeclaration) { - var signatures = getSignaturesOfSymbol(symbol); - var bodySignature = getSignatureFromDeclaration(bodyDeclaration); - // If the implementation signature has string literals, we will have reported an error in - // checkSpecializedSignatureDeclaration - if (!bodySignature.hasStringLiterals) { - // TypeScript 1.0 spec (April 2014): 6.1 - // If a function declaration includes overloads, the overloads determine the call - // signatures of the type given to the function object - // and the function implementation signature must be assignable to that type - // - // TypeScript 1.0 spec (April 2014): 3.8.4 - // Note that specialized call and construct signatures (section 3.7.2.4) are not significant when determining assignment compatibility - // Consider checking against specialized signatures too. Not doing so creates a type hole: - // - // function g(x: "hi", y: boolean); - // function g(x: string, y: {}); - // function g(x: string, y: string) { } - // - // The implementation is completely unrelated to the specialized signature, yet we do not check this. - for (var _a = 0; _a < signatures.length; _a++) { - var signature = signatures[_a]; - if (!signature.hasStringLiterals && !isSignatureAssignableTo(bodySignature, signature)) { - error(signature.declaration, ts.Diagnostics.Overload_signature_is_not_compatible_with_function_implementation); - break; - } - } - } - } - } - } - function checkExportsOnMergedDeclarations(node) { - if (!produceDiagnostics) { - return; - } - // if localSymbol is defined on node then node itself is exported - check is required - var symbol = node.localSymbol; - if (!symbol) { - // local symbol is undefined => this declaration is non-exported. - // however symbol might contain other declarations that are exported - symbol = getSymbolOfNode(node); - if (!(symbol.flags & 7340032 /* Export */)) { - // this is a pure local symbol (all declarations are non-exported) - no need to check anything - return; - } - } - // run the check only for the first declaration in the list - if (ts.getDeclarationOfKind(symbol, node.kind) !== node) { - return; - } - // we use SymbolFlags.ExportValue, SymbolFlags.ExportType and SymbolFlags.ExportNamespace - // to denote disjoint declarationSpaces (without making new enum type). - var exportedDeclarationSpaces = 0 /* None */; - var nonExportedDeclarationSpaces = 0 /* None */; - var defaultExportedDeclarationSpaces = 0 /* None */; - for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { - var d = _a[_i]; - var declarationSpaces = getDeclarationSpaces(d); - var effectiveDeclarationFlags = getEffectiveDeclarationFlags(d, 1 /* Export */ | 1024 /* Default */); - if (effectiveDeclarationFlags & 1 /* Export */) { - if (effectiveDeclarationFlags & 1024 /* Default */) { - defaultExportedDeclarationSpaces |= declarationSpaces; - } - else { - exportedDeclarationSpaces |= declarationSpaces; - } - } - else { - nonExportedDeclarationSpaces |= declarationSpaces; - } - } - // Spaces for anyting not declared a 'default export'. - var nonDefaultExportedDeclarationSpaces = exportedDeclarationSpaces | nonExportedDeclarationSpaces; - var commonDeclarationSpacesForExportsAndLocals = exportedDeclarationSpaces & nonExportedDeclarationSpaces; - var commonDeclarationSpacesForDefaultAndNonDefault = defaultExportedDeclarationSpaces & nonDefaultExportedDeclarationSpaces; - if (commonDeclarationSpacesForExportsAndLocals || commonDeclarationSpacesForDefaultAndNonDefault) { - // declaration spaces for exported and non-exported declarations intersect - for (var _b = 0, _c = symbol.declarations; _b < _c.length; _b++) { - var d = _c[_b]; - var declarationSpaces = getDeclarationSpaces(d); - // Only error on the declarations that conributed to the intersecting spaces. - if (declarationSpaces & commonDeclarationSpacesForDefaultAndNonDefault) { - error(d.name, ts.Diagnostics.Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_default_0_declaration_instead, ts.declarationNameToString(d.name)); - } - else if (declarationSpaces & commonDeclarationSpacesForExportsAndLocals) { - error(d.name, ts.Diagnostics.Individual_declarations_in_merged_declaration_0_must_be_all_exported_or_all_local, ts.declarationNameToString(d.name)); - } - } - } - function getDeclarationSpaces(d) { - switch (d.kind) { - case 215 /* InterfaceDeclaration */: - return 2097152 /* ExportType */; - case 218 /* ModuleDeclaration */: - return d.name.kind === 9 /* StringLiteral */ || ts.getModuleInstanceState(d) !== 0 /* NonInstantiated */ - ? 4194304 /* ExportNamespace */ | 1048576 /* ExportValue */ - : 4194304 /* ExportNamespace */; - case 214 /* ClassDeclaration */: - case 217 /* EnumDeclaration */: - return 2097152 /* ExportType */ | 1048576 /* ExportValue */; - case 221 /* ImportEqualsDeclaration */: - var result = 0; - var target = resolveAlias(getSymbolOfNode(d)); - ts.forEach(target.declarations, function (d) { result |= getDeclarationSpaces(d); }); - return result; - default: - return 1048576 /* ExportValue */; - } - } - } - function checkNonThenableType(type, location, message) { - type = getWidenedType(type); - if (!isTypeAny(type) && isTypeAssignableTo(type, getGlobalThenableType())) { - if (location) { - if (!message) { - message = ts.Diagnostics.Operand_for_await_does_not_have_a_valid_callable_then_member; - } - error(location, message); - } - return unknownType; - } - return type; - } - /** - * Gets the "promised type" of a promise. - * @param type The type of the promise. - * @remarks The "promised type" of a type is the type of the "value" parameter of the "onfulfilled" callback. - */ - function getPromisedType(promise) { - // - // { // promise - // then( // thenFunction - // onfulfilled: ( // onfulfilledParameterType - // value: T // valueParameterType - // ) => any - // ): any; - // } - // - if (promise.flags & 1 /* Any */) { - return undefined; - } - if ((promise.flags & 4096 /* Reference */) && promise.target === tryGetGlobalPromiseType()) { - return promise.typeArguments[0]; - } - var globalPromiseLikeType = getInstantiatedGlobalPromiseLikeType(); - if (globalPromiseLikeType === emptyObjectType || !isTypeAssignableTo(promise, globalPromiseLikeType)) { - return undefined; - } - var thenFunction = getTypeOfPropertyOfType(promise, "then"); - if (thenFunction && (thenFunction.flags & 1 /* Any */)) { - return undefined; - } - var thenSignatures = thenFunction ? getSignaturesOfType(thenFunction, 0 /* Call */) : emptyArray; - if (thenSignatures.length === 0) { - return undefined; - } - var onfulfilledParameterType = getUnionType(ts.map(thenSignatures, getTypeOfFirstParameterOfSignature)); - if (onfulfilledParameterType.flags & 1 /* Any */) { - return undefined; - } - var onfulfilledParameterSignatures = getSignaturesOfType(onfulfilledParameterType, 0 /* Call */); - if (onfulfilledParameterSignatures.length === 0) { - return undefined; - } - var valueParameterType = getUnionType(ts.map(onfulfilledParameterSignatures, getTypeOfFirstParameterOfSignature)); - return valueParameterType; - } - function getTypeOfFirstParameterOfSignature(signature) { - return getTypeAtPosition(signature, 0); - } - /** - * Gets the "awaited type" of a type. - * @param type The type to await. - * @remarks The "awaited type" of an expression is its "promised type" if the expression is a - * Promise-like type; otherwise, it is the type of the expression. This is used to reflect - * The runtime behavior of the `await` keyword. - */ - function getAwaitedType(type) { - return checkAwaitedType(type, /*location*/ undefined, /*message*/ undefined); - } - function checkAwaitedType(type, location, message) { - return checkAwaitedTypeWorker(type); - function checkAwaitedTypeWorker(type) { - if (type.flags & 16384 /* Union */) { - var types = []; - for (var _i = 0, _a = type.types; _i < _a.length; _i++) { - var constituentType = _a[_i]; - types.push(checkAwaitedTypeWorker(constituentType)); - } - return getUnionType(types); - } - else { - var promisedType = getPromisedType(type); - if (promisedType === undefined) { - // The type was not a PromiseLike, so it could not be unwrapped any further. - // As long as the type does not have a callable "then" property, it is - // safe to return the type; otherwise, an error will have been reported in - // the call to checkNonThenableType and we will return unknownType. - // - // An example of a non-promise "thenable" might be: - // - // await { then(): void {} } - // - // The "thenable" does not match the minimal definition for a PromiseLike. When - // a Promise/A+-compatible or ES6 promise tries to adopt this value, the promise - // will never settle. We treat this as an error to help flag an early indicator - // of a runtime problem. If the user wants to return this value from an async - // function, they would need to wrap it in some other value. If they want it to - // be treated as a promise, they can cast to . - return checkNonThenableType(type, location, message); - } - else { - if (type.id === promisedType.id || awaitedTypeStack.indexOf(promisedType.id) >= 0) { - // We have a bad actor in the form of a promise whose promised type is - // the same promise type, or a mutually recursive promise. Return the - // unknown type as we cannot guess the shape. If this were the actual - // case in the JavaScript, this Promise would never resolve. - // - // An example of a bad actor with a singly-recursive promise type might - // be: - // - // interface BadPromise { - // then( - // onfulfilled: (value: BadPromise) => any, - // onrejected: (error: any) => any): BadPromise; - // } - // - // The above interface will pass the PromiseLike check, and return a - // promised type of `BadPromise`. Since this is a self reference, we - // don't want to keep recursing ad infinitum. - // - // An example of a bad actor in the form of a mutually-recursive - // promise type might be: - // - // interface BadPromiseA { - // then( - // onfulfilled: (value: BadPromiseB) => any, - // onrejected: (error: any) => any): BadPromiseB; - // } - // - // interface BadPromiseB { - // then( - // onfulfilled: (value: BadPromiseA) => any, - // onrejected: (error: any) => any): BadPromiseA; - // } - // - if (location) { - error(location, ts.Diagnostics._0_is_referenced_directly_or_indirectly_in_the_fulfillment_callback_of_its_own_then_method, symbolToString(type.symbol)); - } - return unknownType; - } - // Keep track of the type we're about to unwrap to avoid bad recursive promise types. - // See the comments above for more information. - awaitedTypeStack.push(type.id); - var awaitedType = checkAwaitedTypeWorker(promisedType); - awaitedTypeStack.pop(); - return awaitedType; - } - } - } - } - /** - * Checks the return type of an async function to ensure it is a compatible - * Promise implementation. - * @param node The signature to check - * @param returnType The return type for the function - * @remarks - * This checks that an async function has a valid Promise-compatible return type, - * and returns the *awaited type* of the promise. An async function has a valid - * Promise-compatible return type if the resolved value of the return type has a - * construct signature that takes in an `initializer` function that in turn supplies - * a `resolve` function as one of its arguments and results in an object with a - * callable `then` signature. - */ - function checkAsyncFunctionReturnType(node) { - var globalPromiseConstructorLikeType = getGlobalPromiseConstructorLikeType(); - if (globalPromiseConstructorLikeType === emptyObjectType) { - // If we couldn't resolve the global PromiseConstructorLike type we cannot verify - // compatibility with __awaiter. - return unknownType; - } - // As part of our emit for an async function, we will need to emit the entity name of - // the return type annotation as an expression. To meet the necessary runtime semantics - // for __awaiter, we must also check that the type of the declaration (e.g. the static - // side or "constructor" of the promise type) is compatible `PromiseConstructorLike`. - // - // An example might be (from lib.es6.d.ts): - // - // interface Promise { ... } - // interface PromiseConstructor { - // new (...): Promise; - // } - // declare var Promise: PromiseConstructor; - // - // When an async function declares a return type annotation of `Promise`, we - // need to get the type of the `Promise` variable declaration above, which would - // be `PromiseConstructor`. - // - // The same case applies to a class: - // - // declare class Promise { - // constructor(...); - // then(...): Promise; - // } - // - // When we get the type of the `Promise` symbol here, we get the type of the static - // side of the `Promise` class, which would be `{ new (...): Promise }`. - var promiseType = getTypeFromTypeNode(node.type); - if (promiseType === unknownType && compilerOptions.isolatedModules) { - // If we are compiling with isolatedModules, we may not be able to resolve the - // type as a value. As such, we will just return unknownType; - return unknownType; - } - var promiseConstructor = getMergedSymbol(promiseType.symbol); - if (!promiseConstructor || !symbolIsValue(promiseConstructor)) { - error(node, ts.Diagnostics.Type_0_is_not_a_valid_async_function_return_type, typeToString(promiseType)); - return unknownType; - } - // Validate the promise constructor type. - var promiseConstructorType = getTypeOfSymbol(promiseConstructor); - if (!checkTypeAssignableTo(promiseConstructorType, globalPromiseConstructorLikeType, node, ts.Diagnostics.Type_0_is_not_a_valid_async_function_return_type)) { - return unknownType; - } - // Verify there is no local declaration that could collide with the promise constructor. - var promiseName = ts.getEntityNameFromTypeNode(node.type); - var root = getFirstIdentifier(promiseName); - var rootSymbol = getSymbol(node.locals, root.text, 107455 /* Value */); - if (rootSymbol) { - error(rootSymbol.valueDeclaration, ts.Diagnostics.Duplicate_identifier_0_Compiler_uses_declaration_1_to_support_async_functions, root.text, getFullyQualifiedName(promiseConstructor)); - return unknownType; - } - // Get and return the awaited type of the return type. - return checkAwaitedType(promiseType, node, ts.Diagnostics.An_async_function_or_method_must_have_a_valid_awaitable_return_type); - } - /** Check a decorator */ - function checkDecorator(node) { - var signature = getResolvedSignature(node); - var returnType = getReturnTypeOfSignature(signature); - if (returnType.flags & 1 /* Any */) { - return; - } - var expectedReturnType; - var headMessage = getDiagnosticHeadMessageForDecoratorResolution(node); - var errorInfo; - switch (node.parent.kind) { - case 214 /* ClassDeclaration */: - var classSymbol = getSymbolOfNode(node.parent); - var classConstructorType = getTypeOfSymbol(classSymbol); - expectedReturnType = getUnionType([classConstructorType, voidType]); - break; - case 138 /* Parameter */: - expectedReturnType = voidType; - errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.The_return_type_of_a_parameter_decorator_function_must_be_either_void_or_any); - break; - case 141 /* PropertyDeclaration */: - expectedReturnType = voidType; - errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.The_return_type_of_a_property_decorator_function_must_be_either_void_or_any); - break; - case 143 /* MethodDeclaration */: - case 145 /* GetAccessor */: - case 146 /* SetAccessor */: - var methodType = getTypeOfNode(node.parent); - var descriptorType = createTypedPropertyDescriptorType(methodType); - expectedReturnType = getUnionType([descriptorType, voidType]); - break; - } - checkTypeAssignableTo(returnType, expectedReturnType, node, headMessage, errorInfo); - } - /** Checks a type reference node as an expression. */ - function checkTypeNodeAsExpression(node) { - // 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 === 151 /* TypeReference */) { - var root = getFirstIdentifier(node.typeName); - var meaning = root.parent.kind === 151 /* TypeReference */ ? 793056 /* Type */ : 1536 /* Namespace */; - // Resolve type so we know which symbol is referenced - var rootSymbol = resolveName(root, root.text, meaning | 8388608 /* Alias */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined); - // Resolved symbol is alias - if (rootSymbol && rootSymbol.flags & 8388608 /* Alias */) { - var aliasTarget = resolveAlias(rootSymbol); - // If alias has value symbol - mark alias as referenced - if (aliasTarget.flags & 107455 /* Value */ && !isConstEnumOrConstEnumOnlyModule(resolveAlias(rootSymbol))) { - markAliasSymbolAsReferenced(rootSymbol); - } - } - } - } - /** - * Checks the type annotation of an accessor declaration or property declaration as - * an expression if it is a type reference to a type with a value declaration. - */ - function checkTypeAnnotationAsExpression(node) { - switch (node.kind) { - case 141 /* PropertyDeclaration */: - checkTypeNodeAsExpression(node.type); - break; - case 138 /* Parameter */: - checkTypeNodeAsExpression(node.type); - break; - case 143 /* MethodDeclaration */: - checkTypeNodeAsExpression(node.type); - break; - case 145 /* GetAccessor */: - checkTypeNodeAsExpression(node.type); - break; - case 146 /* SetAccessor */: - checkTypeNodeAsExpression(ts.getSetAccessorTypeAnnotationNode(node)); - break; - } - } - /** Checks the type annotation of the parameters of a function/method or the constructor of a class as expressions */ - function checkParameterTypeAnnotationsAsExpressions(node) { - // ensure all type annotations with a value declaration are checked as an expression - for (var _i = 0, _a = node.parameters; _i < _a.length; _i++) { - var parameter = _a[_i]; - checkTypeAnnotationAsExpression(parameter); - } - } - /** Check the decorators of a node */ - function checkDecorators(node) { - if (!node.decorators) { - return; - } - // skip this check for nodes that cannot have decorators. These should have already had an error reported by - // checkGrammarDecorators. - if (!ts.nodeCanBeDecorated(node)) { - return; - } - if (!compilerOptions.experimentalDecorators) { - error(node, ts.Diagnostics.Experimental_support_for_decorators_is_a_feature_that_is_subject_to_change_in_a_future_release_Specify_experimentalDecorators_to_remove_this_warning); - } - 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 214 /* ClassDeclaration */: - var constructor = ts.getFirstConstructorWithBody(node); - if (constructor) { - checkParameterTypeAnnotationsAsExpressions(constructor); - } - break; - case 143 /* MethodDeclaration */: - checkParameterTypeAnnotationsAsExpressions(node); - // fall-through - case 146 /* SetAccessor */: - case 145 /* GetAccessor */: - case 141 /* PropertyDeclaration */: - case 138 /* Parameter */: - checkTypeAnnotationAsExpression(node); - break; - } - } - emitDecorate = true; - if (node.kind === 138 /* Parameter */) { - emitParam = true; - } - ts.forEach(node.decorators, checkDecorator); - } - function checkFunctionDeclaration(node) { - if (produceDiagnostics) { - checkFunctionLikeDeclaration(node) || checkGrammarForGenerator(node); - checkCollisionWithCapturedSuperVariable(node, node.name); - checkCollisionWithCapturedThisVariable(node, node.name); - checkCollisionWithRequireExportsInGeneratedCode(node, node.name); - } - } - function checkFunctionLikeDeclaration(node) { - checkDecorators(node); - checkSignatureDeclaration(node); - var isAsync = ts.isAsyncFunctionLike(node); - if (isAsync) { - emitAwaiter = true; - } - // Do not use hasDynamicName here, because that returns false for well known symbols. - // We want to perform checkComputedPropertyName for all computed properties, including - // well known symbols. - if (node.name && node.name.kind === 136 /* ComputedPropertyName */) { - // This check will account for methods in class/interface declarations, - // as well as accessors in classes/object literals - checkComputedPropertyName(node.name); - } - if (!ts.hasDynamicName(node)) { - // first we want to check the local symbol that contain this declaration - // - if node.localSymbol !== undefined - this is current declaration is exported and localSymbol points to the local symbol - // - if node.localSymbol === undefined - this node is non-exported so we can just pick the result of getSymbolOfNode - var symbol = getSymbolOfNode(node); - var localSymbol = node.localSymbol || symbol; - var firstDeclaration = ts.getDeclarationOfKind(localSymbol, node.kind); - // Only type check the symbol once - if (node === firstDeclaration) { - checkFunctionOrConstructorSymbol(localSymbol); - } - if (symbol.parent) { - // run check once for the first declaration - if (ts.getDeclarationOfKind(symbol, node.kind) === node) { - // run check on export symbol to check that modifiers agree across all exported declarations - checkFunctionOrConstructorSymbol(symbol); - } - } - } - checkSourceElement(node.body); - if (node.type && !isAccessor(node.kind) && !node.asteriskToken) { - var returnType = getTypeFromTypeNode(node.type); - var promisedType; - if (isAsync) { - promisedType = checkAsyncFunctionReturnType(node); - } - checkIfNonVoidFunctionHasReturnExpressionsOrSingleThrowStatment(node, isAsync ? promisedType : returnType); - } - if (produceDiagnostics && !node.type) { - // Report an implicit any error if there is no body, no explicit return type, and node is not a private method - // in an ambient context - if (compilerOptions.noImplicitAny && ts.nodeIsMissing(node.body) && !isPrivateWithinAmbient(node)) { - reportImplicitAnyError(node, anyType); - } - if (node.asteriskToken && ts.nodeIsPresent(node.body)) { - // A generator with a body and no type annotation can still cause errors. It can error if the - // yielded values have no common supertype, or it can give an implicit any error if it has no - // yielded values. The only way to trigger these errors is to try checking its return type. - getReturnTypeOfSignature(getSignatureFromDeclaration(node)); - } - } - } - function checkBlock(node) { - // Grammar checking for SyntaxKind.Block - if (node.kind === 192 /* Block */) { - checkGrammarStatementInAmbientContext(node); - } - ts.forEach(node.statements, checkSourceElement); - if (ts.isFunctionBlock(node) || node.kind === 219 /* ModuleBlock */) { - checkFunctionAndClassExpressionBodies(node); - } - } - function checkCollisionWithArgumentsInGeneratedCode(node) { - // no rest parameters \ declaration context \ overload - no codegen impact - if (!ts.hasRestParameter(node) || ts.isInAmbientContext(node) || ts.nodeIsMissing(node.body)) { - return; - } - ts.forEach(node.parameters, function (p) { - if (p.name && !ts.isBindingPattern(p.name) && p.name.text === argumentsSymbol.name) { - error(p, ts.Diagnostics.Duplicate_identifier_arguments_Compiler_uses_arguments_to_initialize_rest_parameters); - } - }); - } - function needCollisionCheckForIdentifier(node, identifier, name) { - if (!(identifier && identifier.text === name)) { - return false; - } - if (node.kind === 141 /* PropertyDeclaration */ || - node.kind === 140 /* PropertySignature */ || - node.kind === 143 /* MethodDeclaration */ || - node.kind === 142 /* MethodSignature */ || - node.kind === 145 /* GetAccessor */ || - node.kind === 146 /* SetAccessor */) { - // it is ok to have member named '_super' or '_this' - member access is always qualified - return false; - } - if (ts.isInAmbientContext(node)) { - // ambient context - no codegen impact - return false; - } - var root = ts.getRootDeclaration(node); - if (root.kind === 138 /* Parameter */ && ts.nodeIsMissing(root.parent.body)) { - // just an overload - no codegen impact - return false; - } - return true; - } - function checkCollisionWithCapturedThisVariable(node, name) { - if (needCollisionCheckForIdentifier(node, name, "_this")) { - potentialThisCollisions.push(node); - } - } - // this function will run after checking the source file so 'CaptureThis' is correct for all nodes - function checkIfThisIsCapturedInEnclosingScope(node) { - var current = node; - while (current) { - if (getNodeCheckFlags(current) & 4 /* CaptureThis */) { - var isDeclaration_1 = node.kind !== 69 /* Identifier */; - if (isDeclaration_1) { - error(node.name, ts.Diagnostics.Duplicate_identifier_this_Compiler_uses_variable_declaration_this_to_capture_this_reference); - } - else { - error(node, ts.Diagnostics.Expression_resolves_to_variable_declaration_this_that_compiler_uses_to_capture_this_reference); - } - return; - } - current = current.parent; - } - } - function checkCollisionWithCapturedSuperVariable(node, name) { - if (!needCollisionCheckForIdentifier(node, name, "_super")) { - return; - } - // bubble up and find containing type - var enclosingClass = ts.getContainingClass(node); - // if containing type was not found or it is ambient - exit (no codegen) - if (!enclosingClass || ts.isInAmbientContext(enclosingClass)) { - return; - } - if (ts.getClassExtendsHeritageClauseElement(enclosingClass)) { - var isDeclaration_2 = node.kind !== 69 /* Identifier */; - if (isDeclaration_2) { - error(node, ts.Diagnostics.Duplicate_identifier_super_Compiler_uses_super_to_capture_base_class_reference); - } - else { - error(node, ts.Diagnostics.Expression_resolves_to_super_that_compiler_uses_to_capture_base_class_reference); - } - } - } - function checkCollisionWithRequireExportsInGeneratedCode(node, name) { - if (!needCollisionCheckForIdentifier(node, name, "require") && !needCollisionCheckForIdentifier(node, name, "exports")) { - return; - } - // Uninstantiated modules shouldnt do this check - if (node.kind === 218 /* ModuleDeclaration */ && ts.getModuleInstanceState(node) !== 1 /* Instantiated */) { - return; - } - // In case of variable declaration, node.parent is variable statement so look at the variable statement's parent - var parent = getDeclarationContainer(node); - if (parent.kind === 248 /* SourceFile */ && ts.isExternalModule(parent)) { - // If the declaration happens to be in external module, report error that require and exports are reserved keywords - error(name, ts.Diagnostics.Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module, ts.declarationNameToString(name), ts.declarationNameToString(name)); - } - } - function checkVarDeclaredNamesNotShadowed(node) { - // - ScriptBody : StatementList - // It is a Syntax Error if any element of the LexicallyDeclaredNames of StatementList - // also occurs in the VarDeclaredNames of StatementList. - // - Block : { StatementList } - // It is a Syntax Error if any element of the LexicallyDeclaredNames of StatementList - // also occurs in the VarDeclaredNames of StatementList. - // Variable declarations are hoisted to the top of their function scope. They can shadow - // block scoped declarations, which bind tighter. this will not be flagged as duplicate definition - // by the binder as the declaration scope is different. - // A non-initialized declaration is a no-op as the block declaration will resolve before the var - // declaration. the problem is if the declaration has an initializer. this will act as a write to the - // block declared value. this is fine for let, but not const. - // Only consider declarations with initializers, uninitialized let declarations will not - // step on a let/const variable. - // Do not consider let and const declarations, as duplicate block-scoped declarations - // are handled by the binder. - // We are only looking for let declarations that step on let\const declarations from a - // different scope. e.g.: - // { - // const x = 0; // localDeclarationSymbol obtained after name resolution will correspond to this declaration - // let x = 0; // symbol for this declaration will be 'symbol' - // } - // skip block-scoped variables and parameters - if ((ts.getCombinedNodeFlags(node) & 49152 /* BlockScoped */) !== 0 || ts.isParameterDeclaration(node)) { - return; - } - // 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 === 211 /* VariableDeclaration */ && !node.initializer) { - return; - } - var symbol = getSymbolOfNode(node); - if (symbol.flags & 1 /* FunctionScopedVariable */) { - var localDeclarationSymbol = resolveName(node, node.name.text, 3 /* Variable */, /*nodeNotFoundErrorMessage*/ undefined, /*nameArg*/ undefined); - if (localDeclarationSymbol && - localDeclarationSymbol !== symbol && - localDeclarationSymbol.flags & 2 /* BlockScopedVariable */) { - if (getDeclarationFlagsFromSymbol(localDeclarationSymbol) & 49152 /* BlockScoped */) { - var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 212 /* VariableDeclarationList */); - var container = varDeclList.parent.kind === 193 /* VariableStatement */ && varDeclList.parent.parent - ? varDeclList.parent.parent - : undefined; - // names of block-scoped and function scoped variables can collide only - // if block scoped variable is defined in the function\module\source file scope (because of variable hoisting) - var namesShareScope = container && - (container.kind === 192 /* Block */ && ts.isFunctionLike(container.parent) || - container.kind === 219 /* ModuleBlock */ || - container.kind === 218 /* ModuleDeclaration */ || - container.kind === 248 /* SourceFile */); - // here we know that function scoped variable is shadowed by block scoped one - // if they are defined in the same scope - binder has already reported redeclaration error - // otherwise if variable has an initializer - show error that initialization will fail - // since LHS will be block scoped name instead of function scoped - if (!namesShareScope) { - var name_14 = symbolToString(localDeclarationSymbol); - error(node, ts.Diagnostics.Cannot_initialize_outer_scoped_variable_0_in_the_same_scope_as_block_scoped_declaration_1, name_14, name_14); - } - } - } - } - } - // Check that a parameter initializer contains no references to parameters declared to the right of itself - function checkParameterInitializer(node) { - if (ts.getRootDeclaration(node).kind !== 138 /* Parameter */) { - return; - } - var func = ts.getContainingFunction(node); - visit(node.initializer); - function visit(n) { - if (n.kind === 69 /* Identifier */) { - var referencedSymbol = getNodeLinks(n).resolvedSymbol; - // check FunctionLikeDeclaration.locals (stores parameters\function local variable) - // if it contains entry with a specified name and if this entry matches the resolved symbol - if (referencedSymbol && referencedSymbol !== unknownSymbol && getSymbol(func.locals, referencedSymbol.name, 107455 /* Value */) === referencedSymbol) { - if (referencedSymbol.valueDeclaration.kind === 138 /* Parameter */) { - if (referencedSymbol.valueDeclaration === node) { - error(n, ts.Diagnostics.Parameter_0_cannot_be_referenced_in_its_initializer, ts.declarationNameToString(node.name)); - return; - } - if (referencedSymbol.valueDeclaration.pos < node.pos) { - // legal case - parameter initializer references some parameter strictly on left of current parameter declaration - return; - } - } - error(n, ts.Diagnostics.Initializer_of_parameter_0_cannot_reference_identifier_1_declared_after_it, ts.declarationNameToString(node.name), ts.declarationNameToString(n)); - } - } - else { - ts.forEachChild(n, visit); - } - } - } - // Check variable, parameter, or property declaration - function checkVariableLikeDeclaration(node) { - checkDecorators(node); - checkSourceElement(node.type); - // For a computed property, just check the initializer and exit - // 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 === 136 /* ComputedPropertyName */) { - checkComputedPropertyName(node.name); - if (node.initializer) { - checkExpressionCached(node.initializer); - } - } - // For a binding pattern, check contained binding elements - if (ts.isBindingPattern(node.name)) { - 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 === 138 /* Parameter */ && ts.nodeIsMissing(ts.getContainingFunction(node).body)) { - error(node, ts.Diagnostics.A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation); - return; - } - // For a binding pattern, validate the initializer and exit - if (ts.isBindingPattern(node.name)) { - if (node.initializer) { - checkTypeAssignableTo(checkExpressionCached(node.initializer), getWidenedTypeForVariableLikeDeclaration(node), node, /*headMessage*/ undefined); - checkParameterInitializer(node); - } - return; - } - var symbol = getSymbolOfNode(node); - var type = getTypeOfVariableOrParameterOrProperty(symbol); - if (node === symbol.valueDeclaration) { - // Node is the primary declaration of the symbol, just validate the initializer - if (node.initializer) { - checkTypeAssignableTo(checkExpressionCached(node.initializer), type, node, /*headMessage*/ undefined); - checkParameterInitializer(node); - } - } - 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); - 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)); - } - if (node.initializer) { - checkTypeAssignableTo(checkExpressionCached(node.initializer), declarationType, node, /*headMessage*/ undefined); - } - } - if (node.kind !== 141 /* PropertyDeclaration */ && node.kind !== 140 /* PropertySignature */) { - // We know we don't have a binding pattern or computed name here - checkExportsOnMergedDeclarations(node); - if (node.kind === 211 /* VariableDeclaration */ || node.kind === 163 /* BindingElement */) { - checkVarDeclaredNamesNotShadowed(node); - } - checkCollisionWithCapturedSuperVariable(node, node.name); - checkCollisionWithCapturedThisVariable(node, node.name); - checkCollisionWithRequireExportsInGeneratedCode(node, node.name); - } - } - function checkVariableDeclaration(node) { - checkGrammarVariableDeclaration(node); - return checkVariableLikeDeclaration(node); - } - function checkBindingElement(node) { - checkGrammarBindingElement(node); - return checkVariableLikeDeclaration(node); - } - function checkVariableStatement(node) { - // Grammar checking - checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarVariableDeclarationList(node.declarationList) || checkGrammarForDisallowedLetOrConstStatement(node); - ts.forEach(node.declarationList.declarations, checkSourceElement); - } - 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 === 165 /* ObjectLiteralExpression */) { - if (ts.isAsyncFunctionLike(node)) { - if (node.modifiers.length > 1) { - return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); - } - } - else { - return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); - } - } - } - function checkExpressionStatement(node) { - // Grammar checking - checkGrammarStatementInAmbientContext(node); - checkExpression(node.expression); - } - function checkIfStatement(node) { - // Grammar checking - checkGrammarStatementInAmbientContext(node); - checkExpression(node.expression); - checkSourceElement(node.thenStatement); - checkSourceElement(node.elseStatement); - } - function checkDoStatement(node) { - // Grammar checking - checkGrammarStatementInAmbientContext(node); - checkSourceElement(node.statement); - checkExpression(node.expression); - } - function checkWhileStatement(node) { - // Grammar checking - checkGrammarStatementInAmbientContext(node); - checkExpression(node.expression); - checkSourceElement(node.statement); - } - function checkForStatement(node) { - // Grammar checking - if (!checkGrammarStatementInAmbientContext(node)) { - if (node.initializer && node.initializer.kind === 212 /* VariableDeclarationList */) { - checkGrammarVariableDeclarationList(node.initializer); - } - } - if (node.initializer) { - if (node.initializer.kind === 212 /* VariableDeclarationList */) { - ts.forEach(node.initializer.declarations, checkVariableDeclaration); - } - else { - checkExpression(node.initializer); - } - } - if (node.condition) - checkExpression(node.condition); - if (node.incrementor) - checkExpression(node.incrementor); - checkSourceElement(node.statement); - } - function checkForOfStatement(node) { - checkGrammarForInOrForOfStatement(node); - // Check the LHS and RHS - // If the LHS is a declaration, just check it as a variable declaration, which will in turn check the RHS - // 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 === 212 /* VariableDeclarationList */) { - checkForInOrForOfVariableDeclaration(node); - } - else { - var varExpr = node.initializer; - var iteratedType = checkRightHandSideOfForOf(node.expression); - // There may be a destructuring assignment on the left side - if (varExpr.kind === 164 /* ArrayLiteralExpression */ || varExpr.kind === 165 /* ObjectLiteralExpression */) { - // iteratedType may be undefined. In this case, we still want to check the structure of - // varExpr, in particular making sure it's a valid LeftHandSideExpression. But we'd like - // to short circuit the type relation checking as much as possible, so we pass the unknownType. - checkDestructuringAssignment(varExpr, iteratedType || unknownType); - } - else { - var leftType = checkExpression(varExpr); - checkReferenceExpression(varExpr, /*invalidReferenceMessage*/ ts.Diagnostics.Invalid_left_hand_side_in_for_of_statement, - /*constantVariableMessage*/ ts.Diagnostics.The_left_hand_side_of_a_for_of_statement_cannot_be_a_previously_defined_constant); - // iteratedType will be undefined if the rightType was missing properties/signatures - // required to get its iteratedType (like [Symbol.iterator] or next). This may be - // because we accessed properties from anyType, or it may have led to an error inside - // getElementTypeOfIterable. - if (iteratedType) { - checkTypeAssignableTo(iteratedType, leftType, varExpr, /*headMessage*/ undefined); - } - } - } - checkSourceElement(node.statement); - } - function checkForInStatement(node) { - // Grammar checking - checkGrammarForInOrForOfStatement(node); - // TypeScript 1.0 spec (April 2014): 5.4 - // In a 'for-in' statement of the form - // 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 === 212 /* VariableDeclarationList */) { - var variable = node.initializer.declarations[0]; - if (variable && ts.isBindingPattern(variable.name)) { - error(variable.name, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern); - } - checkForInOrForOfVariableDeclaration(node); - } - else { - // In a 'for-in' statement of the form - // for (Var in Expr) Statement - // Var must be an expression classified as a reference of type Any or the String primitive type, - // 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 === 164 /* ArrayLiteralExpression */ || varExpr.kind === 165 /* ObjectLiteralExpression */) { - error(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern); - } - else if (!isTypeAnyOrAllConstituentTypesHaveKind(leftType, 258 /* StringLike */)) { - error(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_must_be_of_type_string_or_any); - } - else { - // run check only former check succeeded to avoid cascading errors - checkReferenceExpression(varExpr, ts.Diagnostics.Invalid_left_hand_side_in_for_in_statement, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_previously_defined_constant); - } - } - var rightType = checkExpression(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, 80896 /* ObjectType */ | 512 /* TypeParameter */)) { - error(node.expression, ts.Diagnostics.The_right_hand_side_of_a_for_in_statement_must_be_of_type_any_an_object_type_or_a_type_parameter); - } - checkSourceElement(node.statement); - } - function checkForInOrForOfVariableDeclaration(iterationStatement) { - var variableDeclarationList = iterationStatement.initializer; - // checkGrammarForInOrForOfStatement will check that there is exactly one declaration. - if (variableDeclarationList.declarations.length >= 1) { - var decl = variableDeclarationList.declarations[0]; - checkVariableDeclaration(decl); - } - } - function checkRightHandSideOfForOf(rhsExpression) { - var expressionType = getTypeOfExpression(rhsExpression); - return checkIteratedTypeOrElementType(expressionType, rhsExpression, /*allowStringInput*/ true); - } - function checkIteratedTypeOrElementType(inputType, errorNode, allowStringInput) { - if (isTypeAny(inputType)) { - return inputType; - } - if (languageVersion >= 2 /* ES6 */) { - return checkElementTypeOfIterable(inputType, errorNode); - } - if (allowStringInput) { - return checkElementTypeOfArrayOrString(inputType, errorNode); - } - if (isArrayLikeType(inputType)) { - var indexType = getIndexTypeOfType(inputType, 1 /* Number */); - if (indexType) { - return indexType; - } - } - error(errorNode, ts.Diagnostics.Type_0_is_not_an_array_type, typeToString(inputType)); - return unknownType; - } - /** - * When errorNode is undefined, it means we should not report any errors. - */ - function checkElementTypeOfIterable(iterable, errorNode) { - var elementType = getElementTypeOfIterable(iterable, errorNode); - // Now even though we have extracted the iteratedType, we will have to validate that the type - // passed in is actually an Iterable. - if (errorNode && elementType) { - checkTypeAssignableTo(iterable, createIterableType(elementType), errorNode); - } - return elementType || anyType; - } - /** - * We want to treat type as an iterable, and get the type it is an iterable of. The iterable - * must have the following structure (annotated with the names of the variables below): - * - * { // iterable - * [Symbol.iterator]: { // iteratorFunction - * (): Iterator - * } - * } - * - * T is the type we are after. At every level that involves analyzing return types - * of signatures, we union the return types of all the signatures. - * - * Another thing to note is that at any step of this process, we could run into a dead end, - * meaning either the property is missing, or we run into the anyType. If either of these things - * happens, we return undefined to signal that we could not find the iterated type. If a property - * is missing, and the previous step did not result in 'any', then we also give an error if the - * caller requested it. Then the caller can decide what to do in the case where there is no iterated - * type. This is different from returning anyType, because that would signify that we have matched the - * whole pattern and that T (above) is 'any'. - */ - function getElementTypeOfIterable(type, errorNode) { - if (isTypeAny(type)) { - return undefined; - } - var typeAsIterable = type; - 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 & 4096 /* Reference */) && type.target === globalIterableType) { - typeAsIterable.iterableElementType = type.typeArguments[0]; - } - else { - var iteratorFunction = getTypeOfPropertyOfType(type, ts.getPropertyNameForKnownSymbolName("iterator")); - if (isTypeAny(iteratorFunction)) { - return undefined; - } - var iteratorFunctionSignatures = iteratorFunction ? getSignaturesOfType(iteratorFunction, 0 /* Call */) : emptyArray; - if (iteratorFunctionSignatures.length === 0) { - if (errorNode) { - error(errorNode, ts.Diagnostics.Type_must_have_a_Symbol_iterator_method_that_returns_an_iterator); - } - return undefined; - } - typeAsIterable.iterableElementType = getElementTypeOfIterator(getUnionType(ts.map(iteratorFunctionSignatures, getReturnTypeOfSignature)), errorNode); - } - } - return typeAsIterable.iterableElementType; - } - /** - * This function has very similar logic as getElementTypeOfIterable, except that it operates on - * Iterators instead of Iterables. Here is the structure: - * - * { // iterator - * next: { // iteratorNextFunction - * (): { // iteratorNextResult - * value: T // iteratorNextValue - * } - * } - * } - * - */ - function getElementTypeOfIterator(type, errorNode) { - if (isTypeAny(type)) { - return undefined; - } - var typeAsIterator = type; - 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 & 4096 /* Reference */) && type.target === globalIteratorType) { - typeAsIterator.iteratorElementType = type.typeArguments[0]; - } - else { - var iteratorNextFunction = getTypeOfPropertyOfType(type, "next"); - if (isTypeAny(iteratorNextFunction)) { - return undefined; - } - var iteratorNextFunctionSignatures = iteratorNextFunction ? getSignaturesOfType(iteratorNextFunction, 0 /* Call */) : emptyArray; - if (iteratorNextFunctionSignatures.length === 0) { - if (errorNode) { - error(errorNode, ts.Diagnostics.An_iterator_must_have_a_next_method); - } - return undefined; - } - var iteratorNextResult = getUnionType(ts.map(iteratorNextFunctionSignatures, getReturnTypeOfSignature)); - if (isTypeAny(iteratorNextResult)) { - return undefined; - } - var iteratorNextValue = getTypeOfPropertyOfType(iteratorNextResult, "value"); - if (!iteratorNextValue) { - if (errorNode) { - error(errorNode, ts.Diagnostics.The_type_returned_by_the_next_method_of_an_iterator_must_have_a_value_property); - } - return undefined; - } - typeAsIterator.iteratorElementType = iteratorNextValue; - } - } - return typeAsIterator.iteratorElementType; - } - function getElementTypeOfIterableIterator(type) { - if (isTypeAny(type)) { - return undefined; - } - // As an optimization, if the type is instantiated directly using the globalIterableIteratorType (IterableIterator), - // then just grab its type argument. - if ((type.flags & 4096 /* Reference */) && type.target === globalIterableIteratorType) { - return type.typeArguments[0]; - } - return getElementTypeOfIterable(type, /*errorNode*/ undefined) || - getElementTypeOfIterator(type, /*errorNode*/ undefined); - } - /** - * This function does the following steps: - * 1. Break up arrayOrStringType (possibly a union) into its string constituents and array constituents. - * 2. Take the element types of the array constituents. - * 3. Return the union of the element types, and string if there was a string constitutent. - * - * For example: - * string -> string - * number[] -> number - * string[] | number[] -> string | number - * string | number[] -> string | number - * string | string[] | number[] -> string | number - * - * It also errors if: - * 1. Some constituent is neither a string nor an array. - * 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 */); - // 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 = removeTypesFromUnionType(arrayOrStringType, 258 /* StringLike */, /*isTypeOfKind*/ true, /*allowEmptyUnionResult*/ true); - var hasStringConstituent = arrayOrStringType !== arrayType; - var reportedError = false; - if (hasStringConstituent) { - if (languageVersion < 1 /* ES5 */) { - error(errorNode, ts.Diagnostics.Using_a_string_in_a_for_of_statement_is_only_supported_in_ECMAScript_5_and_higher); - reportedError = true; - } - // Now that we've removed all the StringLike types, if no constituents remain, then the entire - // arrayOrStringType was a string. - if (arrayType === emptyObjectType) { - return stringType; - } - } - if (!isArrayLikeType(arrayType)) { - if (!reportedError) { - // Which error we report depends on whether there was a string constituent. For example, - // if the input type is number | string, we want to say that number is not an array type. - // But if the input was just number, we want to say that number is not an array type - // or a string type. - var diagnostic = hasStringConstituent - ? ts.Diagnostics.Type_0_is_not_an_array_type - : ts.Diagnostics.Type_0_is_not_an_array_type_or_a_string_type; - error(errorNode, diagnostic, typeToString(arrayType)); - } - return hasStringConstituent ? stringType : unknownType; - } - var arrayElementType = getIndexTypeOfType(arrayType, 1 /* Number */) || unknownType; - if (hasStringConstituent) { - // This is just an optimization for the case where arrayOrStringType is string | string[] - if (arrayElementType.flags & 258 /* StringLike */) { - return stringType; - } - return getUnionType([arrayElementType, stringType]); - } - return arrayElementType; - } - function checkBreakOrContinueStatement(node) { - // Grammar checking - checkGrammarStatementInAmbientContext(node) || checkGrammarBreakOrContinueStatement(node); - // TODO: Check that target label is valid - } - function isGetAccessorWithAnnotatatedSetAccessor(node) { - return !!(node.kind === 145 /* GetAccessor */ && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(node.symbol, 146 /* SetAccessor */))); - } - function checkReturnStatement(node) { - // Grammar checking - if (!checkGrammarStatementInAmbientContext(node)) { - var functionBlock = ts.getContainingFunction(node); - if (!functionBlock) { - grammarErrorOnFirstToken(node, ts.Diagnostics.A_return_statement_can_only_be_used_within_a_function_body); - } - } - if (node.expression) { - var func = ts.getContainingFunction(node); - if (func) { - var signature = getSignatureFromDeclaration(func); - var returnType = getReturnTypeOfSignature(signature); - var exprType = checkExpressionCached(node.expression); - if (func.asteriskToken) { - // A generator does not need its return expressions checked against its return type. - // Instead, the yield expressions are checked against the element type. - // TODO: Check return expressions of generators when return type tracking is added - // for generators. - return; - } - if (func.kind === 146 /* SetAccessor */) { - error(node.expression, ts.Diagnostics.Setters_cannot_return_a_value); - } - else if (func.kind === 144 /* Constructor */) { - if (!isTypeAssignableTo(exprType, returnType)) { - error(node.expression, ts.Diagnostics.Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class); - } - } - else if (func.type || isGetAccessorWithAnnotatatedSetAccessor(func) || signature.typePredicate) { - if (ts.isAsyncFunctionLike(func)) { - var promisedType = getPromisedType(returnType); - var awaitedType = checkAwaitedType(exprType, node.expression, ts.Diagnostics.Return_expression_in_async_function_does_not_have_a_valid_callable_then_member); - if (promisedType) { - // If the function has a return type, but promisedType is - // undefined, an error will be reported in checkAsyncFunctionReturnType - // so we don't need to report one here. - checkTypeAssignableTo(awaitedType, promisedType, node.expression); - } - } - else { - checkTypeAssignableTo(exprType, returnType, node.expression); - } - } - } - } - } - function checkWithStatement(node) { - // Grammar checking for withStatement - if (!checkGrammarStatementInAmbientContext(node)) { - if (node.parserContextFlags & 8 /* Await */) { - grammarErrorOnFirstToken(node, ts.Diagnostics.with_statements_are_not_allowed_in_an_async_function_block); - } - } - checkExpression(node.expression); - error(node.expression, ts.Diagnostics.All_symbols_within_a_with_block_will_be_resolved_to_any); - } - function checkSwitchStatement(node) { - // Grammar checking - checkGrammarStatementInAmbientContext(node); - var firstDefaultClause; - var hasDuplicateDefaultClause = false; - var expressionType = checkExpression(node.expression); - ts.forEach(node.caseBlock.clauses, function (clause) { - // Grammar check for duplicate default clauses, skip if we already report duplicate default clause - if (clause.kind === 242 /* DefaultClause */ && !hasDuplicateDefaultClause) { - if (firstDefaultClause === undefined) { - firstDefaultClause = clause; - } - else { - var sourceFile = ts.getSourceFileOfNode(node); - var start = ts.skipTrivia(sourceFile.text, clause.pos); - var end = clause.statements.length > 0 ? clause.statements[0].pos : clause.end; - grammarErrorAtPos(sourceFile, start, end - start, ts.Diagnostics.A_default_clause_cannot_appear_more_than_once_in_a_switch_statement); - hasDuplicateDefaultClause = true; - } - } - if (produceDiagnostics && clause.kind === 241 /* CaseClause */) { - var caseClause = clause; - // TypeScript 1.0 spec (April 2014):5.9 - // In a 'switch' statement, each 'case' expression must be of a type that is assignable to or from the type of the 'switch' expression. - var caseType = checkExpression(caseClause.expression); - if (!isTypeAssignableTo(expressionType, caseType)) { - // check 'expressionType isAssignableTo caseType' failed, try the reversed check and report errors if it fails - checkTypeAssignableTo(caseType, expressionType, caseClause.expression, /*headMessage*/ undefined); - } - } - ts.forEach(clause.statements, checkSourceElement); - }); - } - function checkLabeledStatement(node) { - // Grammar checking - if (!checkGrammarStatementInAmbientContext(node)) { - var current = node.parent; - while (current) { - if (ts.isFunctionLike(current)) { - break; - } - if (current.kind === 207 /* LabeledStatement */ && current.label.text === node.label.text) { - var sourceFile = ts.getSourceFileOfNode(node); - grammarErrorOnNode(node.label, ts.Diagnostics.Duplicate_label_0, ts.getTextOfNodeFromSourceText(sourceFile.text, node.label)); - break; - } - current = current.parent; - } - } - // ensure that label is unique - checkSourceElement(node.statement); - } - function checkThrowStatement(node) { - // Grammar checking - if (!checkGrammarStatementInAmbientContext(node)) { - if (node.expression === undefined) { - grammarErrorAfterFirstToken(node, ts.Diagnostics.Line_break_not_permitted_here); - } - } - if (node.expression) { - checkExpression(node.expression); - } - } - function checkTryStatement(node) { - // Grammar checking - checkGrammarStatementInAmbientContext(node); - checkBlock(node.tryBlock); - var catchClause = node.catchClause; - if (catchClause) { - // Grammar checking - if (catchClause.variableDeclaration) { - if (catchClause.variableDeclaration.name.kind !== 69 /* Identifier */) { - grammarErrorOnFirstToken(catchClause.variableDeclaration.name, ts.Diagnostics.Catch_clause_variable_name_must_be_an_identifier); - } - else if (catchClause.variableDeclaration.type) { - grammarErrorOnFirstToken(catchClause.variableDeclaration.type, ts.Diagnostics.Catch_clause_variable_cannot_have_a_type_annotation); - } - else if (catchClause.variableDeclaration.initializer) { - grammarErrorOnFirstToken(catchClause.variableDeclaration.initializer, ts.Diagnostics.Catch_clause_variable_cannot_have_an_initializer); - } - else { - var identifierName = catchClause.variableDeclaration.name.text; - var locals = catchClause.block.locals; - if (locals && ts.hasProperty(locals, identifierName)) { - var localSymbol = locals[identifierName]; - if (localSymbol && (localSymbol.flags & 2 /* BlockScopedVariable */) !== 0) { - grammarErrorOnNode(localSymbol.valueDeclaration, ts.Diagnostics.Cannot_redeclare_identifier_0_in_catch_clause, identifierName); - } - } - } - } - checkBlock(catchClause.block); - } - if (node.finallyBlock) { - checkBlock(node.finallyBlock); - } - } - function checkIndexConstraints(type) { - var declaredNumberIndexer = getIndexDeclarationOfSymbol(type.symbol, 1 /* Number */); - var declaredStringIndexer = getIndexDeclarationOfSymbol(type.symbol, 0 /* String */); - var stringIndexType = getIndexTypeOfType(type, 0 /* String */); - var numberIndexType = getIndexTypeOfType(type, 1 /* Number */); - if (stringIndexType || numberIndexType) { - ts.forEach(getPropertiesOfObjectType(type), function (prop) { - var propType = getTypeOfSymbol(prop); - checkIndexConstraintForProperty(prop, propType, type, declaredStringIndexer, stringIndexType, 0 /* String */); - checkIndexConstraintForProperty(prop, propType, type, declaredNumberIndexer, numberIndexType, 1 /* Number */); - }); - if (type.flags & 1024 /* Class */ && ts.isClassLike(type.symbol.valueDeclaration)) { - var classDeclaration = type.symbol.valueDeclaration; - for (var _i = 0, _a = classDeclaration.members; _i < _a.length; _i++) { - var member = _a[_i]; - // Only process instance properties with computed names here. - // Static properties cannot be in conflict with indexers, - // and properties with literal names were already checked. - if (!(member.flags & 128 /* Static */) && ts.hasDynamicName(member)) { - var propType = getTypeOfSymbol(member.symbol); - checkIndexConstraintForProperty(member.symbol, propType, type, declaredStringIndexer, stringIndexType, 0 /* String */); - checkIndexConstraintForProperty(member.symbol, propType, type, declaredNumberIndexer, numberIndexType, 1 /* Number */); - } - } - } - } - var errorNode; - 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 & 2048 /* Interface */)) { - var someBaseTypeHasBothIndexers = ts.forEach(getBaseTypes(type), function (base) { return getIndexTypeOfType(base, 0 /* String */) && getIndexTypeOfType(base, 1 /* Number */); }); - errorNode = someBaseTypeHasBothIndexers ? undefined : type.symbol.declarations[0]; - } - } - if (errorNode && !isTypeAssignableTo(numberIndexType, stringIndexType)) { - error(errorNode, ts.Diagnostics.Numeric_index_type_0_is_not_assignable_to_string_index_type_1, typeToString(numberIndexType), typeToString(stringIndexType)); - } - function checkIndexConstraintForProperty(prop, propertyType, containingType, indexDeclaration, indexType, indexKind) { - if (!indexType) { - return; - } - // index is numeric and property name is not valid numeric literal - if (indexKind === 1 /* Number */ && !isNumericName(prop.valueDeclaration.name)) { - return; - } - // 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 === 136 /* ComputedPropertyName */ || prop.parent === containingType.symbol) { - errorNode = prop.valueDeclaration; - } - else if (indexDeclaration) { - errorNode = indexDeclaration; - } - else if (containingType.flags & 2048 /* 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 - var someBaseClassHasBothPropertyAndIndexer = ts.forEach(getBaseTypes(containingType), function (base) { return getPropertyOfObjectType(base, prop.name) && getIndexTypeOfType(base, indexKind); }); - errorNode = someBaseClassHasBothPropertyAndIndexer ? undefined : containingType.symbol.declarations[0]; - } - if (errorNode && !isTypeAssignableTo(propertyType, indexType)) { - var errorMessage = indexKind === 0 /* String */ - ? ts.Diagnostics.Property_0_of_type_1_is_not_assignable_to_string_index_type_2 - : ts.Diagnostics.Property_0_of_type_1_is_not_assignable_to_numeric_index_type_2; - error(errorNode, errorMessage, symbolToString(prop), typeToString(propertyType), typeToString(indexType)); - } - } - } - function checkTypeNameIsReserved(name, message) { - // TS 1.0 spec (April 2014): 3.6.1 - // The predefined type keywords are reserved and cannot be used as names of user defined types. - switch (name.text) { - case "any": - case "number": - case "boolean": - case "string": - case "symbol": - case "void": - error(name, message, name.text); - } - } - // Check each type parameter and check that list has no duplicate type parameter declarations - function checkTypeParameters(typeParameterDeclarations) { - if (typeParameterDeclarations) { - for (var i = 0, n = typeParameterDeclarations.length; i < n; i++) { - var node = typeParameterDeclarations[i]; - checkTypeParameter(node); - if (produceDiagnostics) { - for (var j = 0; j < i; j++) { - if (typeParameterDeclarations[j].symbol === node.symbol) { - error(node.name, ts.Diagnostics.Duplicate_identifier_0, ts.declarationNameToString(node.name)); - } - } - } - } - } - } - function checkClassExpression(node) { - checkClassLikeDeclaration(node); - return getTypeOfSymbol(getSymbolOfNode(node)); - } - function checkClassDeclaration(node) { - if (!node.name && !(node.flags & 1024 /* Default */)) { - grammarErrorOnFirstToken(node, ts.Diagnostics.A_class_declaration_without_the_default_modifier_must_have_a_name); - } - checkClassLikeDeclaration(node); - ts.forEach(node.members, checkSourceElement); - } - function checkClassLikeDeclaration(node) { - checkGrammarClassDeclarationHeritageClauses(node); - checkDecorators(node); - if (node.name) { - checkTypeNameIsReserved(node.name, ts.Diagnostics.Class_name_cannot_be_0); - checkCollisionWithCapturedThisVariable(node, node.name); - checkCollisionWithRequireExportsInGeneratedCode(node, node.name); - } - checkTypeParameters(node.typeParameters); - checkExportsOnMergedDeclarations(node); - var symbol = getSymbolOfNode(node); - var type = getDeclaredTypeOfSymbol(symbol); - var typeWithThis = getTypeWithThisArgument(type); - var staticType = getTypeOfSymbol(symbol); - var baseTypeNode = ts.getClassExtendsHeritageClauseElement(node); - if (baseTypeNode) { - emitExtends = emitExtends || !ts.isInAmbientContext(node); - var baseTypes = getBaseTypes(type); - if (baseTypes.length && produceDiagnostics) { - var baseType = baseTypes[0]; - var staticBaseType = getBaseConstructorTypeOfClass(type); - checkSourceElement(baseTypeNode.expression); - if (baseTypeNode.typeArguments) { - ts.forEach(baseTypeNode.typeArguments, checkSourceElement); - for (var _i = 0, _a = getConstructorsForTypeArguments(staticBaseType, baseTypeNode.typeArguments); _i < _a.length; _i++) { - var constructor = _a[_i]; - if (!checkTypeArgumentConstraints(constructor.typeParameters, baseTypeNode.typeArguments)) { - break; - } - } - } - checkTypeAssignableTo(typeWithThis, getTypeWithThisArgument(baseType, type.thisType), node.name || node, ts.Diagnostics.Class_0_incorrectly_extends_base_class_1); - checkTypeAssignableTo(staticType, getTypeWithoutSignatures(staticBaseType), node.name || node, ts.Diagnostics.Class_static_side_0_incorrectly_extends_base_class_static_side_1); - if (!(staticBaseType.symbol && staticBaseType.symbol.flags & 32 /* Class */)) { - // When the static base type is a "class-like" constructor function (but not actually a class), we verify - // that all instantiated base constructor signatures return the same type. We can simply compare the type - // references (as opposed to checking the structure of the types) because elsewhere we have already checked - // that the base type is a class or interface type (and not, for example, an anonymous object type). - var constructors = getInstantiatedConstructorsForTypeArguments(staticBaseType, baseTypeNode.typeArguments); - if (ts.forEach(constructors, function (sig) { return getReturnTypeOfSignature(sig) !== baseType; })) { - error(baseTypeNode.expression, ts.Diagnostics.Base_constructors_must_all_have_the_same_return_type); - } - } - checkKindsOfPropertyMemberOverrides(type, baseType); - } - } - var implementedTypeNodes = ts.getClassImplementsHeritageClauseElements(node); - if (implementedTypeNodes) { - for (var _b = 0; _b < implementedTypeNodes.length; _b++) { - var typeRefNode = implementedTypeNodes[_b]; - if (!ts.isSupportedExpressionWithTypeArguments(typeRefNode)) { - error(typeRefNode.expression, ts.Diagnostics.A_class_can_only_implement_an_identifier_Slashqualified_name_with_optional_type_arguments); - } - checkTypeReferenceNode(typeRefNode); - if (produceDiagnostics) { - var t = getTypeFromTypeNode(typeRefNode); - if (t !== unknownType) { - var declaredType = (t.flags & 4096 /* Reference */) ? t.target : t; - if (declaredType.flags & (1024 /* Class */ | 2048 /* Interface */)) { - checkTypeAssignableTo(typeWithThis, getTypeWithThisArgument(t, type.thisType), node.name || node, ts.Diagnostics.Class_0_incorrectly_implements_interface_1); - } - else { - error(typeRefNode, ts.Diagnostics.A_class_may_only_implement_another_class_or_interface); - } - } - } - } - } - if (produceDiagnostics) { - checkIndexConstraints(type); - checkTypeForDuplicateIndexSignatures(node); - } - } - function getTargetSymbol(s) { - // if symbol is instantiated its flags are not copied from the 'target' - // so we'll need to get back original 'target' symbol to work with correct set of flags - return s.flags & 16777216 /* Instantiated */ ? getSymbolLinks(s).target : s; - } - function getClassLikeDeclarationOfSymbol(symbol) { - return ts.forEach(symbol.declarations, function (d) { return ts.isClassLike(d) ? d : undefined; }); - } - function checkKindsOfPropertyMemberOverrides(type, baseType) { - // TypeScript 1.0 spec (April 2014): 8.2.3 - // A derived class inherits all members from its base class it doesn't override. - // Inheritance means that a derived class implicitly contains all non - overridden members of the base class. - // Both public and private property members are inherited, but only public property members can be overridden. - // A property member in a derived class is said to override a property member in a base class - // when the derived class property member has the same name and kind(instance or static) - // as the base class property member. - // The type of an overriding property member must be assignable(section 3.8.4) - // to the type of the overridden property member, or otherwise a compile - time error occurs. - // Base class instance member functions can be overridden by derived class instance member functions, - // but not by other kinds of members. - // Base class instance member variables and accessors can be overridden by - // derived class instance member variables and accessors, but not by other kinds of members. - // NOTE: assignability is checked in checkClassDeclaration - var baseProperties = getPropertiesOfObjectType(baseType); - for (var _i = 0; _i < baseProperties.length; _i++) { - var baseProperty = baseProperties[_i]; - var base = getTargetSymbol(baseProperty); - if (base.flags & 134217728 /* Prototype */) { - continue; - } - var derived = getTargetSymbol(getPropertyOfObjectType(type, base.name)); - var baseDeclarationFlags = getDeclarationFlagsFromSymbol(base); - ts.Debug.assert(!!derived, "derived should point to something, even if it is the base class' declaration."); - if (derived) { - // In order to resolve whether the inherited method was overriden in the base class or not, - // we compare the Symbols obtained. Since getTargetSymbol returns the symbol on the *uninstantiated* - // type declaration, derived and base resolve to the same symbol even in the case of generic classes. - if (derived === base) { - // derived class inherits base without override/redeclaration - var derivedClassDecl = getClassLikeDeclarationOfSymbol(type.symbol); - // It is an error to inherit an abstract member without implementing it or being declared abstract. - // If there is no declaration for the derived class (as in the case of class expressions), - // then the class cannot be declared abstract. - if (baseDeclarationFlags & 256 /* Abstract */ && (!derivedClassDecl || !(derivedClassDecl.flags & 256 /* Abstract */))) { - if (derivedClassDecl.kind === 186 /* ClassExpression */) { - error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1, symbolToString(baseProperty), typeToString(baseType)); - } - else { - error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_0_does_not_implement_inherited_abstract_member_1_from_class_2, typeToString(type), symbolToString(baseProperty), typeToString(baseType)); - } - } - } - else { - // derived overrides base. - var derivedDeclarationFlags = getDeclarationFlagsFromSymbol(derived); - if ((baseDeclarationFlags & 32 /* Private */) || (derivedDeclarationFlags & 32 /* Private */)) { - // either base or derived property is private - not override, skip it - continue; - } - if ((baseDeclarationFlags & 128 /* Static */) !== (derivedDeclarationFlags & 128 /* Static */)) { - // value of 'static' is not the same for properties - not override, skip it - continue; - } - if ((base.flags & derived.flags & 8192 /* Method */) || ((base.flags & 98308 /* PropertyOrAccessor */) && (derived.flags & 98308 /* PropertyOrAccessor */))) { - // method is overridden with method or property/accessor is overridden with property/accessor - correct case - continue; - } - var errorMessage = void 0; - if (base.flags & 8192 /* Method */) { - if (derived.flags & 98304 /* Accessor */) { - errorMessage = ts.Diagnostics.Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_accessor; - } - else { - ts.Debug.assert((derived.flags & 4 /* Property */) !== 0); - errorMessage = ts.Diagnostics.Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_property; - } - } - else if (base.flags & 4 /* Property */) { - ts.Debug.assert((derived.flags & 8192 /* Method */) !== 0); - errorMessage = ts.Diagnostics.Class_0_defines_instance_member_property_1_but_extended_class_2_defines_it_as_instance_member_function; - } - else { - ts.Debug.assert((base.flags & 98304 /* Accessor */) !== 0); - ts.Debug.assert((derived.flags & 8192 /* Method */) !== 0); - errorMessage = ts.Diagnostics.Class_0_defines_instance_member_accessor_1_but_extended_class_2_defines_it_as_instance_member_function; - } - error(derived.valueDeclaration.name, errorMessage, typeToString(baseType), symbolToString(base), typeToString(type)); - } - } - } - } - function isAccessor(kind) { - return kind === 145 /* GetAccessor */ || kind === 146 /* SetAccessor */; - } - function areTypeParametersIdentical(list1, list2) { - if (!list1 && !list2) { - return true; - } - if (!list1 || !list2 || list1.length !== list2.length) { - return false; - } - // TypeScript 1.0 spec (April 2014): - // When a generic interface has multiple declarations, all declarations must have identical type parameter - // lists, i.e. identical type parameter names with identical constraints in identical order. - for (var i = 0, len = list1.length; i < len; i++) { - var tp1 = list1[i]; - var tp2 = list2[i]; - if (tp1.name.text !== tp2.name.text) { - return false; - } - if (!tp1.constraint && !tp2.constraint) { - continue; - } - if (!tp1.constraint || !tp2.constraint) { - return false; - } - if (!isTypeIdenticalTo(getTypeFromTypeNode(tp1.constraint), getTypeFromTypeNode(tp2.constraint))) { - return false; - } - } - return true; - } - function checkInheritedPropertiesAreIdentical(type, typeNode) { - var baseTypes = getBaseTypes(type); - if (baseTypes.length < 2) { - return true; - } - var seen = {}; - ts.forEach(resolveDeclaredMembers(type).declaredProperties, function (p) { seen[p.name] = { prop: p, containingType: type }; }); - var ok = true; - for (var _i = 0; _i < baseTypes.length; _i++) { - var base = baseTypes[_i]; - var properties = getPropertiesOfObjectType(getTypeWithThisArgument(base, type.thisType)); - for (var _a = 0; _a < properties.length; _a++) { - var prop = properties[_a]; - if (!ts.hasProperty(seen, prop.name)) { - seen[prop.name] = { prop: prop, containingType: base }; - } - else { - var existing = seen[prop.name]; - var isInheritedProperty = existing.containingType !== type; - if (isInheritedProperty && !isPropertyIdenticalTo(existing.prop, prop)) { - ok = false; - var typeName1 = typeToString(existing.containingType); - var typeName2 = typeToString(base); - var errorInfo = ts.chainDiagnosticMessages(undefined, ts.Diagnostics.Named_property_0_of_types_1_and_2_are_not_identical, symbolToString(prop), typeName1, typeName2); - errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.Interface_0_cannot_simultaneously_extend_types_1_and_2, typeToString(type), typeName1, typeName2); - diagnostics.add(ts.createDiagnosticForNodeFromMessageChain(typeNode, errorInfo)); - } - } - } - } - return ok; - } - function checkInterfaceDeclaration(node) { - // Grammar checking - checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarInterfaceDeclaration(node); - checkTypeParameters(node.typeParameters); - if (produceDiagnostics) { - checkTypeNameIsReserved(node.name, ts.Diagnostics.Interface_name_cannot_be_0); - checkExportsOnMergedDeclarations(node); - var symbol = getSymbolOfNode(node); - var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 215 /* InterfaceDeclaration */); - if (symbol.declarations.length > 1) { - if (node !== firstInterfaceDecl && !areTypeParametersIdentical(firstInterfaceDecl.typeParameters, node.typeParameters)) { - error(node.name, ts.Diagnostics.All_declarations_of_an_interface_must_have_identical_type_parameters); - } - } - // Only check this symbol once - if (node === firstInterfaceDecl) { - var type = getDeclaredTypeOfSymbol(symbol); - var typeWithThis = getTypeWithThisArgument(type); - // run subsequent checks only if first set succeeded - if (checkInheritedPropertiesAreIdentical(type, node.name)) { - for (var _i = 0, _a = getBaseTypes(type); _i < _a.length; _i++) { - var baseType = _a[_i]; - checkTypeAssignableTo(typeWithThis, getTypeWithThisArgument(baseType, type.thisType), node.name, ts.Diagnostics.Interface_0_incorrectly_extends_interface_1); - } - checkIndexConstraints(type); - } - } - } - ts.forEach(ts.getInterfaceBaseTypeNodes(node), function (heritageElement) { - if (!ts.isSupportedExpressionWithTypeArguments(heritageElement)) { - error(heritageElement.expression, ts.Diagnostics.An_interface_can_only_extend_an_identifier_Slashqualified_name_with_optional_type_arguments); - } - checkTypeReferenceNode(heritageElement); - }); - ts.forEach(node.members, checkSourceElement); - if (produceDiagnostics) { - checkTypeForDuplicateIndexSignatures(node); - } - } - function checkTypeAliasDeclaration(node) { - // Grammar checking - checkGrammarDecorators(node) || checkGrammarModifiers(node); - checkTypeNameIsReserved(node.name, ts.Diagnostics.Type_alias_name_cannot_be_0); - checkSourceElement(node.type); - } - function computeEnumMemberValues(node) { - var nodeLinks = getNodeLinks(node); - if (!(nodeLinks.flags & 8192 /* EnumValuesComputed */)) { - var enumSymbol = getSymbolOfNode(node); - var enumType = getDeclaredTypeOfSymbol(enumSymbol); - var autoValue = 0; // set to undefined when enum member is non-constant - var ambient = ts.isInAmbientContext(node); - var enumIsConst = ts.isConst(node); - for (var _i = 0, _a = node.members; _i < _a.length; _i++) { - var member = _a[_i]; - if (member.name.kind === 136 /* ComputedPropertyName */) { - error(member.name, ts.Diagnostics.Computed_property_names_are_not_allowed_in_enums); - } - else if (isNumericLiteralName(member.name.text)) { - error(member.name, ts.Diagnostics.An_enum_member_cannot_have_a_numeric_name); - } - var previousEnumMemberIsNonConstant = autoValue === undefined; - var initializer = member.initializer; - if (initializer) { - autoValue = computeConstantValueForEnumMemberInitializer(initializer, enumType, enumIsConst, ambient); - } - else if (ambient && !enumIsConst) { - // In ambient enum declarations that specify no const modifier, enum member declarations - // that omit a value are considered computed members (as opposed to having auto-incremented values assigned). - autoValue = undefined; - } - else if (previousEnumMemberIsNonConstant) { - // If the member declaration specifies no value, the member is considered a constant enum member. - // If the member is the first member in the enum declaration, it is assigned the value zero. - // Otherwise, it is assigned the value of the immediately preceding member plus one, - // and an error occurs if the immediately preceding member is not a constant enum member - error(member.name, ts.Diagnostics.Enum_member_must_have_initializer); - } - if (autoValue !== undefined) { - getNodeLinks(member).enumMemberValue = autoValue++; - } - } - nodeLinks.flags |= 8192 /* EnumValuesComputed */; - } - function computeConstantValueForEnumMemberInitializer(initializer, enumType, enumIsConst, ambient) { - // Controls if error should be reported after evaluation of constant value is completed - // Can be false if another more precise error was already reported during evaluation. - var reportError = true; - var value = evalConstant(initializer); - if (reportError) { - if (value === undefined) { - if (enumIsConst) { - error(initializer, ts.Diagnostics.In_const_enum_declarations_member_initializer_must_be_constant_expression); - } - else if (ambient) { - error(initializer, ts.Diagnostics.In_ambient_enum_declarations_member_initializer_must_be_constant_expression); - } - else { - // Only here do we need to check that the initializer is assignable to the enum type. - checkTypeAssignableTo(checkExpression(initializer), enumType, initializer, /*headMessage*/ undefined); - } - } - else if (enumIsConst) { - if (isNaN(value)) { - error(initializer, ts.Diagnostics.const_enum_member_initializer_was_evaluated_to_disallowed_value_NaN); - } - else if (!isFinite(value)) { - error(initializer, ts.Diagnostics.const_enum_member_initializer_was_evaluated_to_a_non_finite_value); - } - } - } - return value; - function evalConstant(e) { - switch (e.kind) { - case 179 /* 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; - } - return undefined; - case 181 /* BinaryExpression */: - var left = evalConstant(e.left); - if (left === undefined) { - return undefined; - } - var right = evalConstant(e.right); - if (right === undefined) { - 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; - } - return undefined; - case 8 /* NumericLiteral */: - return +e.text; - case 172 /* ParenthesizedExpression */: - return evalConstant(e.expression); - case 69 /* Identifier */: - case 167 /* ElementAccessExpression */: - case 166 /* PropertyAccessExpression */: - var member = initializer.parent; - var currentType = getTypeOfSymbol(getSymbolOfNode(member.parent)); - var enumType_1; - var propertyName; - if (e.kind === 69 /* Identifier */) { - // unqualified names can refer to member that reside in different declaration of the enum so just doing name resolution won't work. - // instead pick current enum type and later try to fetch member from the type - enumType_1 = currentType; - propertyName = e.text; - } - else { - var expression; - if (e.kind === 167 /* ElementAccessExpression */) { - if (e.argumentExpression === undefined || - e.argumentExpression.kind !== 9 /* StringLiteral */) { - return undefined; - } - expression = e.expression; - propertyName = e.argumentExpression.text; - } - else { - expression = e.expression; - propertyName = e.name.text; - } - // expression part in ElementAccess\PropertyAccess should be either identifier or dottedName - var current = expression; - while (current) { - if (current.kind === 69 /* Identifier */) { - break; - } - else if (current.kind === 166 /* PropertyAccessExpression */) { - current = current.expression; - } - else { - return undefined; - } - } - enumType_1 = checkExpression(expression); - // allow references to constant members of other enums - if (!(enumType_1.symbol && (enumType_1.symbol.flags & 384 /* Enum */))) { - return undefined; - } - } - if (propertyName === undefined) { - return undefined; - } - var property = getPropertyOfObjectType(enumType_1, propertyName); - if (!property || !(property.flags & 8 /* EnumMember */)) { - return undefined; - } - var propertyDecl = property.valueDeclaration; - // self references are illegal - if (member === propertyDecl) { - return undefined; - } - // illegal case: forward reference - if (!isBlockScopedNameDeclaredBeforeUse(propertyDecl, member)) { - reportError = false; - error(e, ts.Diagnostics.A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_enums); - return undefined; - } - return getNodeLinks(propertyDecl).enumMemberValue; - } - } - } - } - function checkEnumDeclaration(node) { - if (!produceDiagnostics) { - return; - } - // Grammar checking - checkGrammarDecorators(node) || checkGrammarModifiers(node); - checkTypeNameIsReserved(node.name, ts.Diagnostics.Enum_name_cannot_be_0); - checkCollisionWithCapturedThisVariable(node, node.name); - checkCollisionWithRequireExportsInGeneratedCode(node, node.name); - checkExportsOnMergedDeclarations(node); - computeEnumMemberValues(node); - var enumIsConst = ts.isConst(node); - if (compilerOptions.isolatedModules && enumIsConst && ts.isInAmbientContext(node)) { - error(node.name, ts.Diagnostics.Ambient_const_enums_are_not_allowed_when_the_isolatedModules_flag_is_provided); - } - // Spec 2014 - Section 9.3: - // It isn't possible for one enum declaration to continue the automatic numbering sequence of another, - // and when an enum type has multiple declarations, only one declaration is permitted to omit a value - // for the first member. - // - // Only perform this check once per symbol - var enumSymbol = getSymbolOfNode(node); - var firstDeclaration = ts.getDeclarationOfKind(enumSymbol, node.kind); - if (node === firstDeclaration) { - if (enumSymbol.declarations.length > 1) { - // check that const is placed\omitted on all enum declarations - ts.forEach(enumSymbol.declarations, function (decl) { - if (ts.isConstEnumDeclaration(decl) !== enumIsConst) { - error(decl.name, ts.Diagnostics.Enum_declarations_must_all_be_const_or_non_const); - } - }); - } - var seenEnumMissingInitialInitializer = false; - ts.forEach(enumSymbol.declarations, function (declaration) { - // return true if we hit a violation of the rule, false otherwise - if (declaration.kind !== 217 /* EnumDeclaration */) { - return false; - } - var enumDeclaration = declaration; - if (!enumDeclaration.members.length) { - return false; - } - var firstEnumMember = enumDeclaration.members[0]; - if (!firstEnumMember.initializer) { - if (seenEnumMissingInitialInitializer) { - error(firstEnumMember.name, ts.Diagnostics.In_an_enum_with_multiple_declarations_only_one_declaration_can_omit_an_initializer_for_its_first_enum_element); - } - else { - seenEnumMissingInitialInitializer = true; - } - } - }); - } - } - function getFirstNonAmbientClassOrFunctionDeclaration(symbol) { - var declarations = symbol.declarations; - for (var _i = 0; _i < declarations.length; _i++) { - var declaration = declarations[_i]; - if ((declaration.kind === 214 /* ClassDeclaration */ || - (declaration.kind === 213 /* FunctionDeclaration */ && ts.nodeIsPresent(declaration.body))) && - !ts.isInAmbientContext(declaration)) { - return declaration; - } - } - return undefined; - } - function inSameLexicalScope(node1, node2) { - var container1 = ts.getEnclosingBlockScopeContainer(node1); - var container2 = ts.getEnclosingBlockScopeContainer(node2); - if (isGlobalSourceFile(container1)) { - return isGlobalSourceFile(container2); - } - else if (isGlobalSourceFile(container2)) { - return false; - } - else { - return container1 === container2; - } - } - function checkModuleDeclaration(node) { - if (produceDiagnostics) { - // Grammar checking - var isAmbientExternalModule = node.name.kind === 9 /* StringLiteral */; - var contextErrorMessage = isAmbientExternalModule - ? ts.Diagnostics.An_ambient_module_declaration_is_only_allowed_at_the_top_level_in_a_file - : ts.Diagnostics.A_namespace_declaration_is_only_allowed_in_a_namespace_or_module; - if (checkGrammarModuleElementContext(node, contextErrorMessage)) { - // If we hit a module declaration in an illegal context, just bail out to avoid cascading errors. - return; - } - if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node)) { - if (!ts.isInAmbientContext(node) && node.name.kind === 9 /* StringLiteral */) { - grammarErrorOnNode(node.name, ts.Diagnostics.Only_ambient_modules_can_use_quoted_names); - } - } - checkCollisionWithCapturedThisVariable(node, node.name); - checkCollisionWithRequireExportsInGeneratedCode(node, node.name); - checkExportsOnMergedDeclarations(node); - var symbol = getSymbolOfNode(node); - // The following checks only apply on a non-ambient instantiated module declaration. - if (symbol.flags & 512 /* ValueModule */ - && symbol.declarations.length > 1 - && !ts.isInAmbientContext(node) - && ts.isInstantiatedModule(node, compilerOptions.preserveConstEnums || compilerOptions.isolatedModules)) { - var firstNonAmbientClassOrFunc = getFirstNonAmbientClassOrFunctionDeclaration(symbol); - if (firstNonAmbientClassOrFunc) { - if (ts.getSourceFileOfNode(node) !== ts.getSourceFileOfNode(firstNonAmbientClassOrFunc)) { - error(node.name, ts.Diagnostics.A_namespace_declaration_cannot_be_in_a_different_file_from_a_class_or_function_with_which_it_is_merged); - } - else if (node.pos < firstNonAmbientClassOrFunc.pos) { - error(node.name, ts.Diagnostics.A_namespace_declaration_cannot_be_located_prior_to_a_class_or_function_with_which_it_is_merged); - } - } - // 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, 214 /* ClassDeclaration */); - if (mergedClass && - inSameLexicalScope(node, mergedClass)) { - getNodeLinks(node).flags |= 32768 /* LexicalModuleMergesWithClass */; - } - } - // Checks for ambient external modules. - if (isAmbientExternalModule) { - if (!isGlobalSourceFile(node.parent)) { - error(node.name, ts.Diagnostics.Ambient_modules_cannot_be_nested_in_other_modules_or_namespaces); - } - if (ts.isExternalModuleNameRelative(node.name.text)) { - error(node.name, ts.Diagnostics.Ambient_module_declaration_cannot_specify_relative_module_name); - } - } - } - checkSourceElement(node.body); - } - function getFirstIdentifier(node) { - while (true) { - if (node.kind === 135 /* QualifiedName */) { - node = node.left; - } - else if (node.kind === 166 /* PropertyAccessExpression */) { - node = node.expression; - } - else { - break; - } - } - ts.Debug.assert(node.kind === 69 /* Identifier */); - return node; - } - function checkExternalImportOrExportDeclaration(node) { - var moduleName = ts.getExternalModuleName(node); - if (!ts.nodeIsMissing(moduleName) && moduleName.kind !== 9 /* StringLiteral */) { - error(moduleName, ts.Diagnostics.String_literal_expected); - return false; - } - var inAmbientExternalModule = node.parent.kind === 219 /* ModuleBlock */ && node.parent.parent.name.kind === 9 /* StringLiteral */; - if (node.parent.kind !== 248 /* SourceFile */ && !inAmbientExternalModule) { - error(moduleName, node.kind === 228 /* ExportDeclaration */ ? - ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace : - ts.Diagnostics.Import_declarations_in_a_namespace_cannot_reference_a_module); - return false; - } - if (inAmbientExternalModule && ts.isExternalModuleNameRelative(moduleName.text)) { - // TypeScript 1.0 spec (April 2013): 12.1.6 - // An ExternalImportDeclaration in an AmbientExternalModuleDeclaration may reference - // other external modules only through top - level external module names. - // Relative external module names are not permitted. - error(node, ts.Diagnostics.Import_or_export_declaration_in_an_ambient_module_declaration_cannot_reference_module_through_relative_module_name); - return false; - } - return true; - } - function checkAliasSymbol(node) { - var symbol = getSymbolOfNode(node); - var target = resolveAlias(symbol); - if (target !== unknownSymbol) { - var excludedMeanings = (symbol.flags & 107455 /* Value */ ? 107455 /* Value */ : 0) | - (symbol.flags & 793056 /* Type */ ? 793056 /* Type */ : 0) | - (symbol.flags & 1536 /* Namespace */ ? 1536 /* Namespace */ : 0); - if (target.flags & excludedMeanings) { - var message = node.kind === 230 /* ExportSpecifier */ ? - ts.Diagnostics.Export_declaration_conflicts_with_exported_declaration_of_0 : - ts.Diagnostics.Import_declaration_conflicts_with_local_declaration_of_0; - error(node, message, symbolToString(symbol)); - } - } - } - function checkImportBinding(node) { - checkCollisionWithCapturedThisVariable(node, node.name); - checkCollisionWithRequireExportsInGeneratedCode(node, node.name); - checkAliasSymbol(node); - } - function checkImportDeclaration(node) { - if (checkGrammarModuleElementContext(node, ts.Diagnostics.An_import_declaration_can_only_be_used_in_a_namespace_or_module)) { - // If we hit an import declaration in an illegal context, just bail out to avoid cascading errors. - return; - } - if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && (node.flags & 2035 /* Modifier */)) { - grammarErrorOnFirstToken(node, ts.Diagnostics.An_import_declaration_cannot_have_modifiers); - } - if (checkExternalImportOrExportDeclaration(node)) { - var importClause = node.importClause; - if (importClause) { - if (importClause.name) { - checkImportBinding(importClause); - } - if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 224 /* NamespaceImport */) { - checkImportBinding(importClause.namedBindings); - } - else { - ts.forEach(importClause.namedBindings.elements, checkImportBinding); - } - } - } - } - } - function checkImportEqualsDeclaration(node) { - if (checkGrammarModuleElementContext(node, ts.Diagnostics.An_import_declaration_can_only_be_used_in_a_namespace_or_module)) { - // If we hit an import declaration in an illegal context, just bail out to avoid cascading errors. - return; - } - checkGrammarDecorators(node) || checkGrammarModifiers(node); - if (ts.isInternalModuleImportEqualsDeclaration(node) || checkExternalImportOrExportDeclaration(node)) { - checkImportBinding(node); - if (node.flags & 1 /* Export */) { - markExportAsReferenced(node); - } - if (ts.isInternalModuleImportEqualsDeclaration(node)) { - var target = resolveAlias(getSymbolOfNode(node)); - if (target !== unknownSymbol) { - if (target.flags & 107455 /* Value */) { - // Target is a value symbol, check that it is not hidden by a local declaration with the same name - var moduleName = getFirstIdentifier(node.moduleReference); - if (!(resolveEntityName(moduleName, 107455 /* Value */ | 1536 /* Namespace */).flags & 1536 /* Namespace */)) { - error(moduleName, ts.Diagnostics.Module_0_is_hidden_by_a_local_declaration_with_the_same_name, ts.declarationNameToString(moduleName)); - } - } - if (target.flags & 793056 /* Type */) { - checkTypeNameIsReserved(node.name, ts.Diagnostics.Import_name_cannot_be_0); - } - } - } - else { - if (modulekind === 5 /* ES6 */ && !ts.isInAmbientContext(node)) { - // Import equals declaration is deprecated in es6 or above - grammarErrorOnNode(node, ts.Diagnostics.Import_assignment_cannot_be_used_when_targeting_ECMAScript_6_modules_Consider_using_import_Asterisk_as_ns_from_mod_import_a_from_mod_import_d_from_mod_or_another_module_format_instead); - } - } - } - } - function checkExportDeclaration(node) { - if (checkGrammarModuleElementContext(node, ts.Diagnostics.An_export_declaration_can_only_be_used_in_a_module)) { - // If we hit an export in an illegal context, just bail out to avoid cascading errors. - return; - } - if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && (node.flags & 2035 /* Modifier */)) { - grammarErrorOnFirstToken(node, ts.Diagnostics.An_export_declaration_cannot_have_modifiers); - } - if (!node.moduleSpecifier || checkExternalImportOrExportDeclaration(node)) { - if (node.exportClause) { - // export { x, y } - // export { x, y } from "foo" - ts.forEach(node.exportClause.elements, checkExportSpecifier); - var inAmbientExternalModule = node.parent.kind === 219 /* ModuleBlock */ && node.parent.parent.name.kind === 9 /* StringLiteral */; - if (node.parent.kind !== 248 /* SourceFile */ && !inAmbientExternalModule) { - error(node, ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace); - } - } - else { - // export * from "foo" - var moduleSymbol = resolveExternalModuleName(node, node.moduleSpecifier); - if (moduleSymbol && moduleSymbol.exports["export="]) { - error(node.moduleSpecifier, ts.Diagnostics.Module_0_uses_export_and_cannot_be_used_with_export_Asterisk, symbolToString(moduleSymbol)); - } - } - } - } - function checkGrammarModuleElementContext(node, errorMessage) { - if (node.parent.kind !== 248 /* SourceFile */ && node.parent.kind !== 219 /* ModuleBlock */ && node.parent.kind !== 218 /* ModuleDeclaration */) { - return grammarErrorOnFirstToken(node, errorMessage); - } - } - function checkExportSpecifier(node) { - checkAliasSymbol(node); - if (!node.parent.parent.moduleSpecifier) { - markExportAsReferenced(node); - } - } - function checkExportAssignment(node) { - if (checkGrammarModuleElementContext(node, ts.Diagnostics.An_export_assignment_can_only_be_used_in_a_module)) { - // If we hit an export assignment in an illegal context, just bail out to avoid cascading errors. - return; - } - var container = node.parent.kind === 248 /* SourceFile */ ? node.parent : node.parent.parent; - if (container.kind === 218 /* ModuleDeclaration */ && container.name.kind === 69 /* Identifier */) { - error(node, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_namespace); - return; - } - // Grammar checking - if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && (node.flags & 2035 /* Modifier */)) { - grammarErrorOnFirstToken(node, ts.Diagnostics.An_export_assignment_cannot_have_modifiers); - } - if (node.expression.kind === 69 /* Identifier */) { - markExportAsReferenced(node); - } - else { - checkExpressionCached(node.expression); - } - checkExternalModuleExports(container); - if (node.isExportEquals && !ts.isInAmbientContext(node)) { - if (modulekind === 5 /* ES6 */) { - // export assignment is not supported in es6 modules - grammarErrorOnNode(node, ts.Diagnostics.Export_assignment_cannot_be_used_when_targeting_ECMAScript_6_modules_Consider_using_export_default_or_another_module_format_instead); - } - else if (modulekind === 4 /* System */) { - // system modules does not support export assignment - grammarErrorOnNode(node, ts.Diagnostics.Export_assignment_is_not_supported_when_module_flag_is_system); - } - } - } - function getModuleStatements(node) { - if (node.kind === 248 /* SourceFile */) { - return node.statements; - } - if (node.kind === 218 /* ModuleDeclaration */ && node.body.kind === 219 /* ModuleBlock */) { - return node.body.statements; - } - return emptyArray; - } - function hasExportedMembers(moduleSymbol) { - for (var id in moduleSymbol.exports) { - if (id !== "export=") { - return true; - } - } - return false; - } - function checkExternalModuleExports(node) { - var moduleSymbol = getSymbolOfNode(node); - var links = getSymbolLinks(moduleSymbol); - if (!links.exportsChecked) { - var exportEqualsSymbol = moduleSymbol.exports["export="]; - if (exportEqualsSymbol && hasExportedMembers(moduleSymbol)) { - var declaration = getDeclarationOfAliasSymbol(exportEqualsSymbol) || exportEqualsSymbol.valueDeclaration; - error(declaration, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_module_with_other_exported_elements); - } - links.exportsChecked = true; - } - } - function checkTypePredicate(node) { - if (!isInLegalTypePredicatePosition(node)) { - error(node, ts.Diagnostics.A_type_predicate_is_only_allowed_in_return_type_position_for_functions_and_methods); - } - } - function checkSourceElement(node) { - if (!node) { - return; - } - var kind = node.kind; - if (cancellationToken) { - // Only bother checking on a few construct kinds. We don't want to be excessivly - // hitting the cancellation token on every node we check. - switch (kind) { - case 218 /* ModuleDeclaration */: - case 214 /* ClassDeclaration */: - case 215 /* InterfaceDeclaration */: - case 213 /* FunctionDeclaration */: - cancellationToken.throwIfCancellationRequested(); - } - } - switch (kind) { - case 137 /* TypeParameter */: - return checkTypeParameter(node); - case 138 /* Parameter */: - return checkParameter(node); - case 141 /* PropertyDeclaration */: - case 140 /* PropertySignature */: - return checkPropertyDeclaration(node); - case 152 /* FunctionType */: - case 153 /* ConstructorType */: - case 147 /* CallSignature */: - case 148 /* ConstructSignature */: - return checkSignatureDeclaration(node); - case 149 /* IndexSignature */: - return checkSignatureDeclaration(node); - case 143 /* MethodDeclaration */: - case 142 /* MethodSignature */: - return checkMethodDeclaration(node); - case 144 /* Constructor */: - return checkConstructorDeclaration(node); - case 145 /* GetAccessor */: - case 146 /* SetAccessor */: - return checkAccessorDeclaration(node); - case 151 /* TypeReference */: - return checkTypeReferenceNode(node); - case 150 /* TypePredicate */: - return checkTypePredicate(node); - case 154 /* TypeQuery */: - return checkTypeQuery(node); - case 155 /* TypeLiteral */: - return checkTypeLiteral(node); - case 156 /* ArrayType */: - return checkArrayType(node); - case 157 /* TupleType */: - return checkTupleType(node); - case 158 /* UnionType */: - case 159 /* IntersectionType */: - return checkUnionOrIntersectionType(node); - case 160 /* ParenthesizedType */: - return checkSourceElement(node.type); - case 213 /* FunctionDeclaration */: - return checkFunctionDeclaration(node); - case 192 /* Block */: - case 219 /* ModuleBlock */: - return checkBlock(node); - case 193 /* VariableStatement */: - return checkVariableStatement(node); - case 195 /* ExpressionStatement */: - return checkExpressionStatement(node); - case 196 /* IfStatement */: - return checkIfStatement(node); - case 197 /* DoStatement */: - return checkDoStatement(node); - case 198 /* WhileStatement */: - return checkWhileStatement(node); - case 199 /* ForStatement */: - return checkForStatement(node); - case 200 /* ForInStatement */: - return checkForInStatement(node); - case 201 /* ForOfStatement */: - return checkForOfStatement(node); - case 202 /* ContinueStatement */: - case 203 /* BreakStatement */: - return checkBreakOrContinueStatement(node); - case 204 /* ReturnStatement */: - return checkReturnStatement(node); - case 205 /* WithStatement */: - return checkWithStatement(node); - case 206 /* SwitchStatement */: - return checkSwitchStatement(node); - case 207 /* LabeledStatement */: - return checkLabeledStatement(node); - case 208 /* ThrowStatement */: - return checkThrowStatement(node); - case 209 /* TryStatement */: - return checkTryStatement(node); - case 211 /* VariableDeclaration */: - return checkVariableDeclaration(node); - case 163 /* BindingElement */: - return checkBindingElement(node); - case 214 /* ClassDeclaration */: - return checkClassDeclaration(node); - case 215 /* InterfaceDeclaration */: - return checkInterfaceDeclaration(node); - case 216 /* TypeAliasDeclaration */: - return checkTypeAliasDeclaration(node); - case 217 /* EnumDeclaration */: - return checkEnumDeclaration(node); - case 218 /* ModuleDeclaration */: - return checkModuleDeclaration(node); - case 222 /* ImportDeclaration */: - return checkImportDeclaration(node); - case 221 /* ImportEqualsDeclaration */: - return checkImportEqualsDeclaration(node); - case 228 /* ExportDeclaration */: - return checkExportDeclaration(node); - case 227 /* ExportAssignment */: - return checkExportAssignment(node); - case 194 /* EmptyStatement */: - checkGrammarStatementInAmbientContext(node); - return; - case 210 /* DebuggerStatement */: - checkGrammarStatementInAmbientContext(node); - return; - case 231 /* MissingDeclaration */: - return checkMissingDeclaration(node); - } - } - // Function and class expression bodies are checked after all statements in the enclosing body. This is - // to ensure constructs like the following are permitted: - // let foo = function () { - // let s = foo(); - // return "hello"; - // } - // Here, performing a full type check of the body of the function expression whilst in the process of - // determining the type of foo would cause foo to be given type any because of the recursive reference. - // Delaying the type check of the body ensures foo has been assigned a type. - function checkFunctionAndClassExpressionBodies(node) { - switch (node.kind) { - case 173 /* FunctionExpression */: - case 174 /* ArrowFunction */: - ts.forEach(node.parameters, checkFunctionAndClassExpressionBodies); - checkFunctionExpressionOrObjectLiteralMethodBody(node); - break; - case 186 /* ClassExpression */: - ts.forEach(node.members, checkSourceElement); - ts.forEachChild(node, checkFunctionAndClassExpressionBodies); - break; - case 143 /* MethodDeclaration */: - case 142 /* MethodSignature */: - ts.forEach(node.decorators, checkFunctionAndClassExpressionBodies); - ts.forEach(node.parameters, checkFunctionAndClassExpressionBodies); - if (ts.isObjectLiteralMethod(node)) { - checkFunctionExpressionOrObjectLiteralMethodBody(node); - } - break; - case 144 /* Constructor */: - case 145 /* GetAccessor */: - case 146 /* SetAccessor */: - case 213 /* FunctionDeclaration */: - ts.forEach(node.parameters, checkFunctionAndClassExpressionBodies); - break; - case 205 /* WithStatement */: - checkFunctionAndClassExpressionBodies(node.expression); - break; - case 139 /* Decorator */: - case 138 /* Parameter */: - case 141 /* PropertyDeclaration */: - case 140 /* PropertySignature */: - case 161 /* ObjectBindingPattern */: - case 162 /* ArrayBindingPattern */: - case 163 /* BindingElement */: - case 164 /* ArrayLiteralExpression */: - case 165 /* ObjectLiteralExpression */: - case 245 /* PropertyAssignment */: - case 166 /* PropertyAccessExpression */: - case 167 /* ElementAccessExpression */: - case 168 /* CallExpression */: - case 169 /* NewExpression */: - case 170 /* TaggedTemplateExpression */: - case 183 /* TemplateExpression */: - case 190 /* TemplateSpan */: - case 171 /* TypeAssertionExpression */: - case 189 /* AsExpression */: - case 172 /* ParenthesizedExpression */: - case 176 /* TypeOfExpression */: - case 177 /* VoidExpression */: - case 178 /* AwaitExpression */: - case 175 /* DeleteExpression */: - case 179 /* PrefixUnaryExpression */: - case 180 /* PostfixUnaryExpression */: - case 181 /* BinaryExpression */: - case 182 /* ConditionalExpression */: - case 185 /* SpreadElementExpression */: - case 184 /* YieldExpression */: - case 192 /* Block */: - case 219 /* ModuleBlock */: - case 193 /* VariableStatement */: - case 195 /* ExpressionStatement */: - case 196 /* IfStatement */: - case 197 /* DoStatement */: - case 198 /* WhileStatement */: - case 199 /* ForStatement */: - case 200 /* ForInStatement */: - case 201 /* ForOfStatement */: - case 202 /* ContinueStatement */: - case 203 /* BreakStatement */: - case 204 /* ReturnStatement */: - case 206 /* SwitchStatement */: - case 220 /* CaseBlock */: - case 241 /* CaseClause */: - case 242 /* DefaultClause */: - case 207 /* LabeledStatement */: - case 208 /* ThrowStatement */: - case 209 /* TryStatement */: - case 244 /* CatchClause */: - case 211 /* VariableDeclaration */: - case 212 /* VariableDeclarationList */: - case 214 /* ClassDeclaration */: - case 243 /* HeritageClause */: - case 188 /* ExpressionWithTypeArguments */: - case 217 /* EnumDeclaration */: - case 247 /* EnumMember */: - case 227 /* ExportAssignment */: - case 248 /* SourceFile */: - case 240 /* JsxExpression */: - case 233 /* JsxElement */: - case 234 /* JsxSelfClosingElement */: - case 238 /* JsxAttribute */: - case 239 /* JsxSpreadAttribute */: - case 235 /* JsxOpeningElement */: - ts.forEachChild(node, checkFunctionAndClassExpressionBodies); - break; - } - } - function checkSourceFile(node) { - var start = new Date().getTime(); - checkSourceFileWorker(node); - ts.checkTime += new Date().getTime() - start; - } - // Fully type check a source file and collect the relevant diagnostics. - function checkSourceFileWorker(node) { - var links = getNodeLinks(node); - if (!(links.flags & 1 /* TypeChecked */)) { - // Check whether the file has declared it is the default lib, - // and whether the user has specifically chosen to avoid checking it. - if (node.isDefaultLib && compilerOptions.skipDefaultLibCheck) { - return; - } - // Grammar checking - checkGrammarSourceFile(node); - emitExtends = false; - emitDecorate = false; - emitParam = false; - potentialThisCollisions.length = 0; - ts.forEach(node.statements, checkSourceElement); - checkFunctionAndClassExpressionBodies(node); - if (ts.isExternalModule(node)) { - checkExternalModuleExports(node); - } - if (potentialThisCollisions.length) { - ts.forEach(potentialThisCollisions, checkIfThisIsCapturedInEnclosingScope); - potentialThisCollisions.length = 0; - } - if (emitExtends) { - links.flags |= 8 /* EmitExtends */; - } - if (emitDecorate) { - links.flags |= 16 /* EmitDecorate */; - } - if (emitParam) { - links.flags |= 32 /* EmitParam */; - } - if (emitAwaiter) { - links.flags |= 64 /* EmitAwaiter */; - } - if (emitGenerator || (emitAwaiter && languageVersion < 2 /* ES6 */)) { - links.flags |= 128 /* EmitGenerator */; - } - links.flags |= 1 /* TypeChecked */; - } - } - function getDiagnostics(sourceFile, ct) { - try { - // Record the cancellation token so it can be checked later on during checkSourceElement. - // Do this in a finally block so we can ensure that it gets reset back to nothing after - // this call is done. - cancellationToken = ct; - return getDiagnosticsWorker(sourceFile); - } - finally { - cancellationToken = undefined; - } - } - function getDiagnosticsWorker(sourceFile) { - throwIfNonDiagnosticsProducing(); - if (sourceFile) { - checkSourceFile(sourceFile); - return diagnostics.getDiagnostics(sourceFile.fileName); - } - ts.forEach(host.getSourceFiles(), checkSourceFile); - return diagnostics.getDiagnostics(); - } - function getGlobalDiagnostics() { - throwIfNonDiagnosticsProducing(); - return diagnostics.getGlobalDiagnostics(); - } - function throwIfNonDiagnosticsProducing() { - if (!produceDiagnostics) { - throw new Error("Trying to get diagnostics from a type checker that does not produce them."); - } - } - // Language service support - function isInsideWithStatementBody(node) { - if (node) { - while (node.parent) { - if (node.parent.kind === 205 /* WithStatement */ && node.parent.statement === node) { - return true; - } - node = node.parent; - } - } - return false; - } - function getSymbolsInScope(location, meaning) { - var symbols = {}; - var memberFlags = 0; - if (isInsideWithStatementBody(location)) { - // We cannot answer semantic questions within a with block, do not proceed any further - return []; - } - populateSymbols(); - return symbolsToArray(symbols); - function populateSymbols() { - while (location) { - if (location.locals && !isGlobalSourceFile(location)) { - copySymbols(location.locals, meaning); - } - switch (location.kind) { - case 248 /* SourceFile */: - if (!ts.isExternalModule(location)) { - break; - } - case 218 /* ModuleDeclaration */: - copySymbols(getSymbolOfNode(location).exports, meaning & 8914931 /* ModuleMember */); - break; - case 217 /* EnumDeclaration */: - copySymbols(getSymbolOfNode(location).exports, meaning & 8 /* EnumMember */); - break; - case 186 /* ClassExpression */: - var className = location.name; - if (className) { - copySymbol(location.symbol, meaning); - } - // fall through; this fall-through is necessary because we would like to handle - // type parameter inside class expression similar to how we handle it in classDeclaration and interface Declaration - case 214 /* ClassDeclaration */: - case 215 /* InterfaceDeclaration */: - // If we didn't come from static member of class or interface, - // add the type parameters into the symbol table - // (type parameters of classDeclaration/classExpression and interface are in member property of the symbol. - // Note: that the memberFlags come from previous iteration. - if (!(memberFlags & 128 /* Static */)) { - copySymbols(getSymbolOfNode(location).members, meaning & 793056 /* Type */); - } - break; - case 173 /* FunctionExpression */: - var funcName = location.name; - if (funcName) { - copySymbol(location.symbol, meaning); - } - break; - } - if (ts.introducesArgumentsExoticObject(location)) { - copySymbol(argumentsSymbol, meaning); - } - memberFlags = location.flags; - location = location.parent; - } - copySymbols(globals, meaning); - } - /** - * Copy the given symbol into symbol tables if the symbol has the given meaning - * and it doesn't already existed in the symbol table - * @param key a key for storing in symbol table; if undefined, use symbol.name - * @param symbol the symbol to be added into symbol table - * @param meaning meaning of symbol to filter by before adding to symbol table - */ - function copySymbol(symbol, meaning) { - if (symbol.flags & meaning) { - var id = symbol.name; - // We will copy all symbol regardless of its reserved name because - // symbolsToArray will check whether the key is a reserved name and - // it will not copy symbol with reserved name to the array - if (!ts.hasProperty(symbols, id)) { - symbols[id] = symbol; - } - } - } - function copySymbols(source, meaning) { - if (meaning) { - for (var id in source) { - var symbol = source[id]; - copySymbol(symbol, meaning); - } - } - } - } - function isTypeDeclarationName(name) { - return name.kind === 69 /* Identifier */ && - isTypeDeclaration(name.parent) && - name.parent.name === name; - } - function isTypeDeclaration(node) { - switch (node.kind) { - case 137 /* TypeParameter */: - case 214 /* ClassDeclaration */: - case 215 /* InterfaceDeclaration */: - case 216 /* TypeAliasDeclaration */: - case 217 /* EnumDeclaration */: - return true; - } - } - // True if the given identifier is part of a type reference - function isTypeReferenceIdentifier(entityName) { - var node = entityName; - while (node.parent && node.parent.kind === 135 /* QualifiedName */) { - node = node.parent; - } - return node.parent && node.parent.kind === 151 /* TypeReference */; - } - function isHeritageClauseElementIdentifier(entityName) { - var node = entityName; - while (node.parent && node.parent.kind === 166 /* PropertyAccessExpression */) { - node = node.parent; - } - return node.parent && node.parent.kind === 188 /* ExpressionWithTypeArguments */; - } - function getLeftSideOfImportEqualsOrExportAssignment(nodeOnRightSide) { - while (nodeOnRightSide.parent.kind === 135 /* QualifiedName */) { - nodeOnRightSide = nodeOnRightSide.parent; - } - if (nodeOnRightSide.parent.kind === 221 /* ImportEqualsDeclaration */) { - return nodeOnRightSide.parent.moduleReference === nodeOnRightSide && nodeOnRightSide.parent; - } - if (nodeOnRightSide.parent.kind === 227 /* ExportAssignment */) { - return nodeOnRightSide.parent.expression === nodeOnRightSide && nodeOnRightSide.parent; - } - return undefined; - } - function isInRightSideOfImportOrExportAssignment(node) { - return getLeftSideOfImportEqualsOrExportAssignment(node) !== undefined; - } - function getSymbolOfEntityNameOrPropertyAccessExpression(entityName) { - if (ts.isDeclarationName(entityName)) { - return getSymbolOfNode(entityName.parent); - } - if (entityName.parent.kind === 227 /* ExportAssignment */) { - return resolveEntityName(entityName, - /*all meanings*/ 107455 /* Value */ | 793056 /* Type */ | 1536 /* Namespace */ | 8388608 /* Alias */); - } - if (entityName.kind !== 166 /* PropertyAccessExpression */) { - if (isInRightSideOfImportOrExportAssignment(entityName)) { - // Since we already checked for ExportAssignment, this really could only be an Import - return getSymbolOfPartOfRightHandSideOfImportEquals(entityName); - } - } - if (ts.isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { - entityName = entityName.parent; - } - if (isHeritageClauseElementIdentifier(entityName)) { - var meaning = 0 /* None */; - // In an interface or class, we're definitely interested in a type. - if (entityName.parent.kind === 188 /* ExpressionWithTypeArguments */) { - meaning = 793056 /* Type */; - // In a class 'extends' clause we are also looking for a value. - if (ts.isExpressionWithTypeArgumentsInClassExtendsClause(entityName.parent)) { - meaning |= 107455 /* Value */; - } - } - else { - meaning = 1536 /* Namespace */; - } - meaning |= 8388608 /* Alias */; - return resolveEntityName(entityName, meaning); - } - else if ((entityName.parent.kind === 235 /* JsxOpeningElement */) || - (entityName.parent.kind === 234 /* JsxSelfClosingElement */) || - (entityName.parent.kind === 237 /* JsxClosingElement */)) { - return getJsxElementTagSymbol(entityName.parent); - } - else if (ts.isExpression(entityName)) { - if (ts.nodeIsMissing(entityName)) { - // Missing entity name. - return undefined; - } - if (entityName.kind === 69 /* Identifier */) { - // Include aliases in the meaning, this ensures that we do not follow aliases to where they point and instead - // return the alias symbol. - var meaning = 107455 /* Value */ | 8388608 /* Alias */; - return resolveEntityName(entityName, meaning); - } - else if (entityName.kind === 166 /* PropertyAccessExpression */) { - var symbol = getNodeLinks(entityName).resolvedSymbol; - if (!symbol) { - checkPropertyAccessExpression(entityName); - } - return getNodeLinks(entityName).resolvedSymbol; - } - else if (entityName.kind === 135 /* QualifiedName */) { - var symbol = getNodeLinks(entityName).resolvedSymbol; - if (!symbol) { - checkQualifiedName(entityName); - } - return getNodeLinks(entityName).resolvedSymbol; - } - } - else if (isTypeReferenceIdentifier(entityName)) { - var meaning = entityName.parent.kind === 151 /* TypeReference */ ? 793056 /* Type */ : 1536 /* Namespace */; - // Include aliases in the meaning, this ensures that we do not follow aliases to where they point and instead - // return the alias symbol. - meaning |= 8388608 /* Alias */; - return resolveEntityName(entityName, meaning); - } - else if (entityName.parent.kind === 238 /* JsxAttribute */) { - return getJsxAttributePropertySymbol(entityName.parent); - } - if (entityName.parent.kind === 150 /* TypePredicate */) { - return resolveEntityName(entityName, /*meaning*/ 1 /* FunctionScopedVariable */); - } - // Do we want to return undefined here? - return undefined; - } - function getSymbolAtLocation(node) { - if (isInsideWithStatementBody(node)) { - // We cannot answer semantic questions within a with block, do not proceed any further - return undefined; - } - if (ts.isDeclarationName(node)) { - // This is a declaration, call getSymbolOfNode - return getSymbolOfNode(node.parent); - } - if (node.kind === 69 /* Identifier */) { - if (isInRightSideOfImportOrExportAssignment(node)) { - return node.parent.kind === 227 /* ExportAssignment */ - ? getSymbolOfEntityNameOrPropertyAccessExpression(node) - : getSymbolOfPartOfRightHandSideOfImportEquals(node); - } - else if (node.parent.kind === 163 /* BindingElement */ && - node.parent.parent.kind === 161 /* ObjectBindingPattern */ && - node === node.parent.propertyName) { - var typeOfPattern = getTypeOfNode(node.parent.parent); - var propertyDeclaration = typeOfPattern && getPropertyOfType(typeOfPattern, node.text); - if (propertyDeclaration) { - return propertyDeclaration; - } - } - } - switch (node.kind) { - case 69 /* Identifier */: - case 166 /* PropertyAccessExpression */: - case 135 /* QualifiedName */: - return getSymbolOfEntityNameOrPropertyAccessExpression(node); - case 97 /* ThisKeyword */: - case 95 /* SuperKeyword */: - var type = ts.isExpression(node) ? checkExpression(node) : getTypeFromTypeNode(node); - return type.symbol; - case 121 /* ConstructorKeyword */: - // constructor keyword for an overload, should take us to the definition if it exist - var constructorDeclaration = node.parent; - if (constructorDeclaration && constructorDeclaration.kind === 144 /* Constructor */) { - return constructorDeclaration.parent.symbol; - } - return undefined; - case 9 /* StringLiteral */: - // External module name in an import declaration - if ((ts.isExternalModuleImportEqualsDeclaration(node.parent.parent) && - ts.getExternalModuleImportEqualsDeclarationExpression(node.parent.parent) === node) || - ((node.parent.kind === 222 /* ImportDeclaration */ || node.parent.kind === 228 /* ExportDeclaration */) && - node.parent.moduleSpecifier === node)) { - return resolveExternalModuleName(node, node); - } - // Fall through - case 8 /* NumericLiteral */: - // index access - if (node.parent.kind === 167 /* ElementAccessExpression */ && node.parent.argumentExpression === node) { - var objectType = checkExpression(node.parent.expression); - if (objectType === unknownType) - return undefined; - var apparentType = getApparentType(objectType); - if (apparentType === unknownType) - return undefined; - return getPropertyOfType(apparentType, node.text); - } - break; - } - return undefined; - } - function getShorthandAssignmentValueSymbol(location) { - // The function returns a value symbol of an identifier in the short-hand property assignment. - // This is necessary as an identifier in short-hand property assignment can contains two meaning: - // property name and property value. - if (location && location.kind === 246 /* ShorthandPropertyAssignment */) { - return resolveEntityName(location.name, 107455 /* Value */); - } - return undefined; - } - function getTypeOfNode(node) { - if (isInsideWithStatementBody(node)) { - // We cannot answer semantic questions within a with block, do not proceed any further - return unknownType; - } - if (ts.isTypeNode(node)) { - return getTypeFromTypeNode(node); - } - if (ts.isExpression(node)) { - return getTypeOfExpression(node); - } - if (ts.isExpressionWithTypeArgumentsInClassExtendsClause(node)) { - // A SyntaxKind.ExpressionWithTypeArguments is considered a type node, except when it occurs in the - // extends clause of a class. We handle that case here. - return getBaseTypes(getDeclaredTypeOfSymbol(getSymbolOfNode(node.parent.parent)))[0]; - } - if (isTypeDeclaration(node)) { - // In this case, we call getSymbolOfNode instead of getSymbolAtLocation because it is a declaration - var symbol = getSymbolOfNode(node); - return getDeclaredTypeOfSymbol(symbol); - } - if (isTypeDeclarationName(node)) { - var symbol = getSymbolAtLocation(node); - return symbol && getDeclaredTypeOfSymbol(symbol); - } - if (ts.isDeclaration(node)) { - // In this case, we call getSymbolOfNode instead of getSymbolAtLocation because it is a declaration - var symbol = getSymbolOfNode(node); - return getTypeOfSymbol(symbol); - } - if (ts.isDeclarationName(node)) { - var symbol = getSymbolAtLocation(node); - return symbol && getTypeOfSymbol(symbol); - } - if (ts.isBindingPattern(node)) { - return getTypeForVariableLikeDeclaration(node.parent); - } - if (isInRightSideOfImportOrExportAssignment(node)) { - var symbol = getSymbolAtLocation(node); - var declaredType = symbol && getDeclaredTypeOfSymbol(symbol); - return declaredType !== unknownType ? declaredType : getTypeOfSymbol(symbol); - } - return unknownType; - } - function getTypeOfExpression(expr) { - if (ts.isRightSideOfQualifiedNameOrPropertyAccess(expr)) { - expr = expr.parent; - } - return checkExpression(expr); - } - /** - * Gets either the static or instance type of a class element, based on - * whether the element is declared as "static". - */ - function getParentTypeOfClassElement(node) { - var classSymbol = getSymbolOfNode(node.parent); - return node.flags & 128 /* Static */ - ? getTypeOfSymbol(classSymbol) - : getDeclaredTypeOfSymbol(classSymbol); - } - // Return the list of properties of the given type, augmented with properties from Function - // if the type has call or construct signatures - function getAugmentedPropertiesOfType(type) { - type = getApparentType(type); - var propsByName = createSymbolTable(getPropertiesOfType(type)); - if (getSignaturesOfType(type, 0 /* Call */).length || getSignaturesOfType(type, 1 /* Construct */).length) { - ts.forEach(getPropertiesOfType(globalFunctionType), function (p) { - if (!ts.hasProperty(propsByName, p.name)) { - propsByName[p.name] = p; - } - }); - } - return getNamedMembers(propsByName); - } - function getRootSymbols(symbol) { - if (symbol.flags & 268435456 /* SyntheticProperty */) { - var symbols = []; - var name_15 = symbol.name; - ts.forEach(getSymbolLinks(symbol).containingType.types, function (t) { - var symbol = getPropertyOfType(t, name_15); - if (symbol) { - symbols.push(symbol); - } - }); - return symbols; - } - else if (symbol.flags & 67108864 /* Transient */) { - var target = getSymbolLinks(symbol).target; - if (target) { - return [target]; - } - } - return [symbol]; - } - // Emitter support - // When resolved as an expression identifier, if the given node references an exported entity, return the declaration - // node of the exported entity's container. Otherwise, return undefined. - function getReferencedExportContainer(node) { - var symbol = getReferencedValueSymbol(node); - if (symbol) { - if (symbol.flags & 1048576 /* ExportValue */) { - // If we reference an exported entity within the same module declaration, then whether - // we prefix depends on the kind of entity. SymbolFlags.ExportHasLocal encompasses all the - // kinds that we do NOT prefix. - var exportSymbol = getMergedSymbol(symbol.exportSymbol); - if (exportSymbol.flags & 944 /* ExportHasLocal */) { - return undefined; - } - symbol = exportSymbol; - } - var parentSymbol = getParentOfSymbol(symbol); - if (parentSymbol) { - if (parentSymbol.flags & 512 /* ValueModule */ && parentSymbol.valueDeclaration.kind === 248 /* SourceFile */) { - return parentSymbol.valueDeclaration; - } - for (var n = node.parent; n; n = n.parent) { - if ((n.kind === 218 /* ModuleDeclaration */ || n.kind === 217 /* EnumDeclaration */) && getSymbolOfNode(n) === parentSymbol) { - return n; - } - } - } - } - } - // When resolved as an expression identifier, if the given node references an import, return the declaration of - // that import. Otherwise, return undefined. - function getReferencedImportDeclaration(node) { - var symbol = getReferencedValueSymbol(node); - return symbol && symbol.flags & 8388608 /* Alias */ ? getDeclarationOfAliasSymbol(symbol) : undefined; - } - function isStatementWithLocals(node) { - switch (node.kind) { - case 192 /* Block */: - case 220 /* CaseBlock */: - case 199 /* ForStatement */: - case 200 /* ForInStatement */: - case 201 /* ForOfStatement */: - return true; - } - return false; - } - function isNestedRedeclarationSymbol(symbol) { - if (symbol.flags & 418 /* BlockScoped */) { - var links = getSymbolLinks(symbol); - if (links.isNestedRedeclaration === undefined) { - var container = ts.getEnclosingBlockScopeContainer(symbol.valueDeclaration); - links.isNestedRedeclaration = isStatementWithLocals(container) && - !!resolveName(container.parent, symbol.name, 107455 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined); - } - return links.isNestedRedeclaration; - } - return false; - } - // When resolved as an expression identifier, if the given node references a nested block scoped entity with - // a name that hides an existing name, return the declaration of that entity. Otherwise, return undefined. - function getReferencedNestedRedeclaration(node) { - var symbol = getReferencedValueSymbol(node); - return symbol && isNestedRedeclarationSymbol(symbol) ? symbol.valueDeclaration : undefined; - } - // Return true if the given node is a declaration of a nested block scoped entity with a name that hides an - // existing name. - function isNestedRedeclaration(node) { - return isNestedRedeclarationSymbol(getSymbolOfNode(node)); - } - function isValueAliasDeclaration(node) { - switch (node.kind) { - case 221 /* ImportEqualsDeclaration */: - case 223 /* ImportClause */: - case 224 /* NamespaceImport */: - case 226 /* ImportSpecifier */: - case 230 /* ExportSpecifier */: - return isAliasResolvedToValue(getSymbolOfNode(node)); - case 228 /* ExportDeclaration */: - var exportClause = node.exportClause; - return exportClause && ts.forEach(exportClause.elements, isValueAliasDeclaration); - case 227 /* ExportAssignment */: - return node.expression && node.expression.kind === 69 /* Identifier */ ? isAliasResolvedToValue(getSymbolOfNode(node)) : true; - } - return false; - } - function isTopLevelValueImportEqualsWithEntityName(node) { - if (node.parent.kind !== 248 /* SourceFile */ || !ts.isInternalModuleImportEqualsDeclaration(node)) { - // parent is not source file or it is not reference to internal module - return false; - } - var isValue = isAliasResolvedToValue(getSymbolOfNode(node)); - return isValue && node.moduleReference && !ts.nodeIsMissing(node.moduleReference); - } - function isAliasResolvedToValue(symbol) { - var target = resolveAlias(symbol); - if (target === unknownSymbol && compilerOptions.isolatedModules) { - return true; - } - // const enums and modules that contain only const enums are not considered values from the emit perespective - // unless 'preserveConstEnums' option is set to true - return target !== unknownSymbol && - target && - target.flags & 107455 /* Value */ && - (compilerOptions.preserveConstEnums || !isConstEnumOrConstEnumOnlyModule(target)); - } - function isConstEnumOrConstEnumOnlyModule(s) { - return isConstEnumSymbol(s) || s.constEnumOnlyModule; - } - function isReferencedAliasDeclaration(node, checkChildren) { - if (ts.isAliasSymbolDeclaration(node)) { - var symbol = getSymbolOfNode(node); - if (getSymbolLinks(symbol).referenced) { - return true; - } - } - if (checkChildren) { - return ts.forEachChild(node, function (node) { return isReferencedAliasDeclaration(node, checkChildren); }); - } - return false; - } - function isImplementationOfOverload(node) { - if (ts.nodeIsPresent(node.body)) { - var symbol = getSymbolOfNode(node); - var signaturesOfSymbol = getSignaturesOfSymbol(symbol); - // If this function body corresponds to function with multiple signature, it is implementation of overload - // e.g.: function foo(a: string): string; - // function foo(a: number): number; - // function foo(a: any) { // This is implementation of the overloads - // return a; - // } - return signaturesOfSymbol.length > 1 || - // If there is single signature for the symbol, it is overload if that signature isn't coming from the node - // e.g.: function foo(a: string): string; - // function foo(a: any) { // This is implementation of the overloads - // return a; - // } - (signaturesOfSymbol.length === 1 && signaturesOfSymbol[0].declaration !== node); - } - return false; - } - function getNodeCheckFlags(node) { - return getNodeLinks(node).flags; - } - function getEnumMemberValue(node) { - computeEnumMemberValues(node.parent); - return getNodeLinks(node).enumMemberValue; - } - function getConstantValue(node) { - if (node.kind === 247 /* EnumMember */) { - return getEnumMemberValue(node); - } - var symbol = getNodeLinks(node).resolvedSymbol; - if (symbol && (symbol.flags & 8 /* EnumMember */)) { - // inline property\index accesses only for const enums - if (ts.isConstEnumDeclaration(symbol.valueDeclaration.parent)) { - return getEnumMemberValue(symbol.valueDeclaration); - } - } - return undefined; - } - function isFunctionType(type) { - return type.flags & 80896 /* ObjectType */ && getSignaturesOfType(type, 0 /* Call */).length > 0; - } - function getTypeReferenceSerializationKind(typeName) { - // Resolve the symbol as a value to ensure the type can be reached at runtime during emit. - var valueSymbol = resolveEntityName(typeName, 107455 /* Value */, /*ignoreErrors*/ true); - var constructorType = valueSymbol ? getTypeOfSymbol(valueSymbol) : undefined; - if (constructorType && isConstructorType(constructorType)) { - return ts.TypeReferenceSerializationKind.TypeWithConstructSignatureAndValue; - } - // Resolve the symbol as a type so that we can provide a more useful hint for the type serializer. - var typeSymbol = resolveEntityName(typeName, 793056 /* Type */, /*ignoreErrors*/ true); - // We might not be able to resolve type symbol so use unknown type in that case (eg error case) - if (!typeSymbol) { - return ts.TypeReferenceSerializationKind.ObjectType; - } - var type = getDeclaredTypeOfSymbol(typeSymbol); - if (type === unknownType) { - return ts.TypeReferenceSerializationKind.Unknown; - } - else if (type.flags & 1 /* Any */) { - return ts.TypeReferenceSerializationKind.ObjectType; - } - else if (allConstituentTypesHaveKind(type, 16 /* Void */)) { - return ts.TypeReferenceSerializationKind.VoidType; - } - else if (allConstituentTypesHaveKind(type, 8 /* Boolean */)) { - return ts.TypeReferenceSerializationKind.BooleanType; - } - else if (allConstituentTypesHaveKind(type, 132 /* NumberLike */)) { - return ts.TypeReferenceSerializationKind.NumberLikeType; - } - else if (allConstituentTypesHaveKind(type, 258 /* StringLike */)) { - return ts.TypeReferenceSerializationKind.StringLikeType; - } - else if (allConstituentTypesHaveKind(type, 8192 /* Tuple */)) { - return ts.TypeReferenceSerializationKind.ArrayLikeType; - } - else if (allConstituentTypesHaveKind(type, 16777216 /* ESSymbol */)) { - return ts.TypeReferenceSerializationKind.ESSymbolType; - } - else if (isFunctionType(type)) { - return ts.TypeReferenceSerializationKind.TypeWithCallSignature; - } - else if (isArrayType(type)) { - return ts.TypeReferenceSerializationKind.ArrayLikeType; - } - else { - return ts.TypeReferenceSerializationKind.ObjectType; - } - } - function writeTypeOfDeclaration(declaration, enclosingDeclaration, flags, writer) { - // Get type of the symbol if this is the valid symbol otherwise get type at location - var symbol = getSymbolOfNode(declaration); - var type = symbol && !(symbol.flags & (2048 /* TypeLiteral */ | 131072 /* Signature */)) - ? getTypeOfSymbol(symbol) - : unknownType; - getSymbolDisplayBuilder().buildTypeDisplay(type, writer, enclosingDeclaration, flags); - } - function writeReturnTypeOfSignatureDeclaration(signatureDeclaration, enclosingDeclaration, flags, writer) { - var signature = getSignatureFromDeclaration(signatureDeclaration); - getSymbolDisplayBuilder().buildTypeDisplay(getReturnTypeOfSignature(signature), writer, enclosingDeclaration, flags); - } - function writeTypeOfExpression(expr, enclosingDeclaration, flags, writer) { - var type = getTypeOfExpression(expr); - getSymbolDisplayBuilder().buildTypeDisplay(type, writer, enclosingDeclaration, flags); - } - function hasGlobalName(name) { - return ts.hasProperty(globals, name); - } - function getReferencedValueSymbol(reference) { - return getNodeLinks(reference).resolvedSymbol || - resolveName(reference, reference.text, 107455 /* Value */ | 1048576 /* ExportValue */ | 8388608 /* Alias */, - /*nodeNotFoundMessage*/ undefined, /*nameArg*/ undefined); - } - function getReferencedValueDeclaration(reference) { - ts.Debug.assert(!ts.nodeIsSynthesized(reference)); - var symbol = getReferencedValueSymbol(reference); - return symbol && getExportSymbolOfValueSymbolIfExported(symbol).valueDeclaration; - } - function instantiateSingleCallFunctionType(functionType, typeArguments) { - if (functionType === unknownType) { - return unknownType; - } - var signature = getSingleCallSignature(functionType); - if (!signature) { - return unknownType; - } - var instantiatedSignature = getSignatureInstantiation(signature, typeArguments); - return getOrCreateTypeFromSignature(instantiatedSignature); - } - function createResolver() { - return { - getReferencedExportContainer: getReferencedExportContainer, - getReferencedImportDeclaration: getReferencedImportDeclaration, - getReferencedNestedRedeclaration: getReferencedNestedRedeclaration, - isNestedRedeclaration: isNestedRedeclaration, - isValueAliasDeclaration: isValueAliasDeclaration, - hasGlobalName: hasGlobalName, - isReferencedAliasDeclaration: isReferencedAliasDeclaration, - getNodeCheckFlags: getNodeCheckFlags, - isTopLevelValueImportEqualsWithEntityName: isTopLevelValueImportEqualsWithEntityName, - isDeclarationVisible: isDeclarationVisible, - isImplementationOfOverload: isImplementationOfOverload, - writeTypeOfDeclaration: writeTypeOfDeclaration, - writeReturnTypeOfSignatureDeclaration: writeReturnTypeOfSignatureDeclaration, - writeTypeOfExpression: writeTypeOfExpression, - isSymbolAccessible: isSymbolAccessible, - isEntityNameVisible: isEntityNameVisible, - getConstantValue: getConstantValue, - collectLinkedAliases: collectLinkedAliases, - getReferencedValueDeclaration: getReferencedValueDeclaration, - getTypeReferenceSerializationKind: getTypeReferenceSerializationKind, - isOptionalParameter: isOptionalParameter - }; - } - function initializeTypeChecker() { - // Bind all source files and propagate errors - ts.forEach(host.getSourceFiles(), function (file) { - ts.bindSourceFile(file); - }); - // Initialize global symbol table - ts.forEach(host.getSourceFiles(), function (file) { - if (!ts.isExternalModule(file)) { - mergeSymbolTable(globals, file.locals); - } - }); - // Initialize special symbols - getSymbolLinks(undefinedSymbol).type = undefinedType; - getSymbolLinks(argumentsSymbol).type = getGlobalType("IArguments"); - getSymbolLinks(unknownSymbol).type = unknownType; - globals[undefinedSymbol.name] = undefinedSymbol; - // Initialize special types - globalArrayType = getGlobalType("Array", /*arity*/ 1); - globalObjectType = getGlobalType("Object"); - globalFunctionType = getGlobalType("Function"); - globalStringType = getGlobalType("String"); - globalNumberType = getGlobalType("Number"); - globalBooleanType = getGlobalType("Boolean"); - globalRegExpType = getGlobalType("RegExp"); - jsxElementType = getExportedTypeFromNamespace("JSX", JsxNames.Element); - getGlobalClassDecoratorType = ts.memoize(function () { return getGlobalType("ClassDecorator"); }); - getGlobalPropertyDecoratorType = ts.memoize(function () { return getGlobalType("PropertyDecorator"); }); - getGlobalMethodDecoratorType = ts.memoize(function () { return getGlobalType("MethodDecorator"); }); - getGlobalParameterDecoratorType = ts.memoize(function () { return getGlobalType("ParameterDecorator"); }); - getGlobalTypedPropertyDescriptorType = ts.memoize(function () { return getGlobalType("TypedPropertyDescriptor", /*arity*/ 1); }); - getGlobalPromiseType = ts.memoize(function () { return getGlobalType("Promise", /*arity*/ 1); }); - tryGetGlobalPromiseType = ts.memoize(function () { return getGlobalSymbol("Promise", 793056 /* Type */, /*diagnostic*/ undefined) && getGlobalPromiseType(); }); - getGlobalPromiseLikeType = ts.memoize(function () { return getGlobalType("PromiseLike", /*arity*/ 1); }); - getInstantiatedGlobalPromiseLikeType = ts.memoize(createInstantiatedPromiseLikeType); - getGlobalPromiseConstructorSymbol = ts.memoize(function () { return getGlobalValueSymbol("Promise"); }); - getGlobalPromiseConstructorLikeType = ts.memoize(function () { return getGlobalType("PromiseConstructorLike"); }); - getGlobalThenableType = ts.memoize(createThenableType); - // If we're in ES6 mode, load the TemplateStringsArray. - // Otherwise, default to 'unknown' for the purposes of type checking in LS scenarios. - if (languageVersion >= 2 /* ES6 */) { - globalTemplateStringsArrayType = getGlobalType("TemplateStringsArray"); - globalESSymbolType = getGlobalType("Symbol"); - globalESSymbolConstructorSymbol = getGlobalValueSymbol("Symbol"); - globalIterableType = getGlobalType("Iterable", /*arity*/ 1); - globalIteratorType = getGlobalType("Iterator", /*arity*/ 1); - globalIterableIteratorType = getGlobalType("IterableIterator", /*arity*/ 1); - } - else { - globalTemplateStringsArrayType = unknownType; - // Consider putting Symbol interface in lib.d.ts. On the plus side, putting it in lib.d.ts would make it - // extensible for Polyfilling Symbols. But putting it into lib.d.ts could also break users that have - // a global Symbol already, particularly if it is a class. - globalESSymbolType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); - globalESSymbolConstructorSymbol = undefined; - globalIterableType = emptyGenericType; - globalIteratorType = emptyGenericType; - globalIterableIteratorType = emptyGenericType; - } - anyArrayType = createArrayType(anyType); - } - function createInstantiatedPromiseLikeType() { - var promiseLikeType = getGlobalPromiseLikeType(); - if (promiseLikeType !== emptyGenericType) { - return createTypeReference(promiseLikeType, [anyType]); - } - return emptyObjectType; - } - function createThenableType() { - // build the thenable type that is used to verify against a non-promise "thenable" operand to `await`. - var thenPropertySymbol = createSymbol(67108864 /* Transient */ | 4 /* Property */, "then"); - getSymbolLinks(thenPropertySymbol).type = globalFunctionType; - var thenableType = createObjectType(65536 /* Anonymous */); - thenableType.properties = [thenPropertySymbol]; - thenableType.members = createSymbolTable(thenableType.properties); - thenableType.callSignatures = []; - thenableType.constructSignatures = []; - return thenableType; - } - // GRAMMAR CHECKING - function checkGrammarDecorators(node) { - if (!node.decorators) { - return false; - } - if (!ts.nodeCanBeDecorated(node)) { - return grammarErrorOnFirstToken(node, ts.Diagnostics.Decorators_are_not_valid_here); - } - else if (node.kind === 145 /* GetAccessor */ || node.kind === 146 /* SetAccessor */) { - var accessors = ts.getAllAccessorDeclarations(node.parent.members, node); - if (accessors.firstAccessor.decorators && node === accessors.secondAccessor) { - return grammarErrorOnFirstToken(node, ts.Diagnostics.Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name); - } - } - return false; - } - function checkGrammarModifiers(node) { - switch (node.kind) { - case 145 /* GetAccessor */: - case 146 /* SetAccessor */: - case 144 /* Constructor */: - case 141 /* PropertyDeclaration */: - case 140 /* PropertySignature */: - case 143 /* MethodDeclaration */: - case 142 /* MethodSignature */: - case 149 /* IndexSignature */: - case 218 /* ModuleDeclaration */: - case 222 /* ImportDeclaration */: - case 221 /* ImportEqualsDeclaration */: - case 228 /* ExportDeclaration */: - case 227 /* ExportAssignment */: - case 138 /* Parameter */: - break; - case 213 /* FunctionDeclaration */: - if (node.modifiers && (node.modifiers.length > 1 || node.modifiers[0].kind !== 118 /* AsyncKeyword */) && - node.parent.kind !== 219 /* ModuleBlock */ && node.parent.kind !== 248 /* SourceFile */) { - return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); - } - break; - case 214 /* ClassDeclaration */: - case 215 /* InterfaceDeclaration */: - case 193 /* VariableStatement */: - case 216 /* TypeAliasDeclaration */: - if (node.modifiers && node.parent.kind !== 219 /* ModuleBlock */ && node.parent.kind !== 248 /* SourceFile */) { - return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); - } - break; - case 217 /* EnumDeclaration */: - if (node.modifiers && (node.modifiers.length > 1 || node.modifiers[0].kind !== 74 /* ConstKeyword */) && - node.parent.kind !== 219 /* ModuleBlock */ && node.parent.kind !== 248 /* SourceFile */) { - return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); - } - break; - default: - return false; - } - if (!node.modifiers) { - return; - } - var lastStatic, lastPrivate, lastProtected, lastDeclare, lastAsync; - var flags = 0; - for (var _i = 0, _a = node.modifiers; _i < _a.length; _i++) { - var modifier = _a[_i]; - switch (modifier.kind) { - case 112 /* PublicKeyword */: - case 111 /* ProtectedKeyword */: - case 110 /* PrivateKeyword */: - var text = void 0; - if (modifier.kind === 112 /* PublicKeyword */) { - text = "public"; - } - else if (modifier.kind === 111 /* ProtectedKeyword */) { - text = "protected"; - lastProtected = modifier; - } - else { - text = "private"; - lastPrivate = modifier; - } - if (flags & 112 /* AccessibilityModifier */) { - return grammarErrorOnNode(modifier, ts.Diagnostics.Accessibility_modifier_already_seen); - } - else if (flags & 128 /* Static */) { - return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "static"); - } - else if (flags & 512 /* Async */) { - return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "async"); - } - else if (node.parent.kind === 219 /* ModuleBlock */ || node.parent.kind === 248 /* SourceFile */) { - return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_element, text); - } - else if (flags & 256 /* Abstract */) { - if (modifier.kind === 110 /* PrivateKeyword */) { - return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, text, "abstract"); - } - else { - return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "abstract"); - } - } - flags |= ts.modifierToFlag(modifier.kind); - break; - case 113 /* StaticKeyword */: - if (flags & 128 /* Static */) { - return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "static"); - } - else if (flags & 512 /* Async */) { - return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "static", "async"); - } - else if (node.parent.kind === 219 /* ModuleBlock */ || node.parent.kind === 248 /* SourceFile */) { - return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_element, "static"); - } - else if (node.kind === 138 /* Parameter */) { - return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "static"); - } - else if (flags & 256 /* Abstract */) { - return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "static", "abstract"); - } - flags |= 128 /* Static */; - lastStatic = modifier; - break; - case 82 /* ExportKeyword */: - if (flags & 1 /* Export */) { - return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "export"); - } - else if (flags & 2 /* Ambient */) { - return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "declare"); - } - else if (flags & 256 /* Abstract */) { - return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "abstract"); - } - else if (flags & 512 /* Async */) { - return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "async"); - } - else if (node.parent.kind === 214 /* ClassDeclaration */) { - return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "export"); - } - else if (node.kind === 138 /* Parameter */) { - return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "export"); - } - flags |= 1 /* Export */; - break; - case 122 /* DeclareKeyword */: - if (flags & 2 /* Ambient */) { - return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "declare"); - } - else if (flags & 512 /* Async */) { - return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); - } - else if (node.parent.kind === 214 /* ClassDeclaration */) { - return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "declare"); - } - else if (node.kind === 138 /* Parameter */) { - return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "declare"); - } - else if (ts.isInAmbientContext(node.parent) && node.parent.kind === 219 /* ModuleBlock */) { - return grammarErrorOnNode(modifier, ts.Diagnostics.A_declare_modifier_cannot_be_used_in_an_already_ambient_context); - } - flags |= 2 /* Ambient */; - lastDeclare = modifier; - break; - case 115 /* AbstractKeyword */: - if (flags & 256 /* Abstract */) { - return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "abstract"); - } - if (node.kind !== 214 /* ClassDeclaration */) { - if (node.kind !== 143 /* MethodDeclaration */) { - return grammarErrorOnNode(modifier, ts.Diagnostics.abstract_modifier_can_only_appear_on_a_class_or_method_declaration); - } - if (!(node.parent.kind === 214 /* ClassDeclaration */ && node.parent.flags & 256 /* Abstract */)) { - return grammarErrorOnNode(modifier, ts.Diagnostics.Abstract_methods_can_only_appear_within_an_abstract_class); - } - if (flags & 128 /* Static */) { - return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "static", "abstract"); - } - if (flags & 32 /* Private */) { - return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "private", "abstract"); - } - } - flags |= 256 /* Abstract */; - break; - case 118 /* AsyncKeyword */: - if (flags & 512 /* Async */) { - return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "async"); - } - else if (flags & 2 /* Ambient */ || ts.isInAmbientContext(node.parent)) { - return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); - } - else if (node.kind === 138 /* Parameter */) { - return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "async"); - } - flags |= 512 /* Async */; - lastAsync = modifier; - break; - } - } - if (node.kind === 144 /* Constructor */) { - if (flags & 128 /* Static */) { - return grammarErrorOnNode(lastStatic, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "static"); - } - if (flags & 256 /* Abstract */) { - return grammarErrorOnNode(lastStatic, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "abstract"); - } - else if (flags & 64 /* Protected */) { - return grammarErrorOnNode(lastProtected, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "protected"); - } - else if (flags & 32 /* Private */) { - return grammarErrorOnNode(lastPrivate, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "private"); - } - else if (flags & 512 /* Async */) { - return grammarErrorOnNode(lastAsync, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "async"); - } - return; - } - else if ((node.kind === 222 /* ImportDeclaration */ || node.kind === 221 /* ImportEqualsDeclaration */) && flags & 2 /* Ambient */) { - return grammarErrorOnNode(lastDeclare, ts.Diagnostics.A_0_modifier_cannot_be_used_with_an_import_declaration, "declare"); - } - else if (node.kind === 138 /* Parameter */ && (flags & 112 /* AccessibilityModifier */) && ts.isBindingPattern(node.name)) { - return grammarErrorOnNode(node, ts.Diagnostics.A_parameter_property_may_not_be_a_binding_pattern); - } - if (flags & 512 /* Async */) { - return checkGrammarAsyncModifier(node, lastAsync); - } - } - function checkGrammarAsyncModifier(node, asyncModifier) { - if (languageVersion < 2 /* ES6 */) { - return grammarErrorOnNode(asyncModifier, ts.Diagnostics.Async_functions_are_only_available_when_targeting_ECMAScript_6_and_higher); - } - switch (node.kind) { - case 143 /* MethodDeclaration */: - case 213 /* FunctionDeclaration */: - case 173 /* FunctionExpression */: - case 174 /* ArrowFunction */: - if (!node.asteriskToken) { - return false; - } - break; - } - return grammarErrorOnNode(asyncModifier, ts.Diagnostics._0_modifier_cannot_be_used_here, "async"); - } - function checkGrammarForDisallowedTrailingComma(list) { - if (list && list.hasTrailingComma) { - var start = list.end - ",".length; - var end = list.end; - var sourceFile = ts.getSourceFileOfNode(list[0]); - return grammarErrorAtPos(sourceFile, start, end - start, ts.Diagnostics.Trailing_comma_not_allowed); - } - } - function checkGrammarTypeParameterList(node, typeParameters, file) { - if (checkGrammarForDisallowedTrailingComma(typeParameters)) { - return true; - } - if (typeParameters && typeParameters.length === 0) { - var start = typeParameters.pos - "<".length; - var end = ts.skipTrivia(file.text, typeParameters.end) + ">".length; - return grammarErrorAtPos(file, start, end - start, ts.Diagnostics.Type_parameter_list_cannot_be_empty); - } - } - function checkGrammarParameterList(parameters) { - if (checkGrammarForDisallowedTrailingComma(parameters)) { - return true; - } - var seenOptionalParameter = false; - var parameterCount = parameters.length; - for (var i = 0; i < parameterCount; i++) { - var parameter = parameters[i]; - if (parameter.dotDotDotToken) { - if (i !== (parameterCount - 1)) { - return grammarErrorOnNode(parameter.dotDotDotToken, ts.Diagnostics.A_rest_parameter_must_be_last_in_a_parameter_list); - } - if (ts.isBindingPattern(parameter.name)) { - return grammarErrorOnNode(parameter.name, ts.Diagnostics.A_rest_element_cannot_contain_a_binding_pattern); - } - if (parameter.questionToken) { - return grammarErrorOnNode(parameter.questionToken, ts.Diagnostics.A_rest_parameter_cannot_be_optional); - } - if (parameter.initializer) { - return grammarErrorOnNode(parameter.name, ts.Diagnostics.A_rest_parameter_cannot_have_an_initializer); - } - } - else if (parameter.questionToken) { - seenOptionalParameter = true; - if (parameter.initializer) { - return grammarErrorOnNode(parameter.name, ts.Diagnostics.Parameter_cannot_have_question_mark_and_initializer); - } - } - else if (seenOptionalParameter && !parameter.initializer) { - return grammarErrorOnNode(parameter.name, ts.Diagnostics.A_required_parameter_cannot_follow_an_optional_parameter); - } - } - } - function checkGrammarFunctionLikeDeclaration(node) { - // Prevent cascading error by short-circuit - var file = ts.getSourceFileOfNode(node); - return checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarTypeParameterList(node, node.typeParameters, file) || - checkGrammarParameterList(node.parameters) || checkGrammarArrowFunction(node, file); - } - function checkGrammarArrowFunction(node, file) { - if (node.kind === 174 /* ArrowFunction */) { - var arrowFunction = node; - var startLine = ts.getLineAndCharacterOfPosition(file, arrowFunction.equalsGreaterThanToken.pos).line; - var endLine = ts.getLineAndCharacterOfPosition(file, arrowFunction.equalsGreaterThanToken.end).line; - if (startLine !== endLine) { - return grammarErrorOnNode(arrowFunction.equalsGreaterThanToken, ts.Diagnostics.Line_terminator_not_permitted_before_arrow); - } - } - return false; - } - function checkGrammarIndexSignatureParameters(node) { - var parameter = node.parameters[0]; - if (node.parameters.length !== 1) { - if (parameter) { - return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_must_have_exactly_one_parameter); - } - else { - return grammarErrorOnNode(node, ts.Diagnostics.An_index_signature_must_have_exactly_one_parameter); - } - } - if (parameter.dotDotDotToken) { - return grammarErrorOnNode(parameter.dotDotDotToken, ts.Diagnostics.An_index_signature_cannot_have_a_rest_parameter); - } - if (parameter.flags & 2035 /* Modifier */) { - return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_cannot_have_an_accessibility_modifier); - } - if (parameter.questionToken) { - return grammarErrorOnNode(parameter.questionToken, ts.Diagnostics.An_index_signature_parameter_cannot_have_a_question_mark); - } - if (parameter.initializer) { - return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_cannot_have_an_initializer); - } - if (!parameter.type) { - return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_must_have_a_type_annotation); - } - if (parameter.type.kind !== 130 /* StringKeyword */ && parameter.type.kind !== 128 /* NumberKeyword */) { - return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_type_must_be_string_or_number); - } - if (!node.type) { - return grammarErrorOnNode(node, ts.Diagnostics.An_index_signature_must_have_a_type_annotation); - } - } - function checkGrammarForIndexSignatureModifier(node) { - if (node.flags & 2035 /* Modifier */) { - grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_not_permitted_on_index_signature_members); - } - } - function checkGrammarIndexSignature(node) { - // Prevent cascading error by short-circuit - return checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarIndexSignatureParameters(node) || checkGrammarForIndexSignatureModifier(node); - } - function checkGrammarForAtLeastOneTypeArgument(node, typeArguments) { - if (typeArguments && typeArguments.length === 0) { - var sourceFile = ts.getSourceFileOfNode(node); - var start = typeArguments.pos - "<".length; - var end = ts.skipTrivia(sourceFile.text, typeArguments.end) + ">".length; - return grammarErrorAtPos(sourceFile, start, end - start, ts.Diagnostics.Type_argument_list_cannot_be_empty); - } - } - function checkGrammarTypeArguments(node, typeArguments) { - return checkGrammarForDisallowedTrailingComma(typeArguments) || - checkGrammarForAtLeastOneTypeArgument(node, typeArguments); - } - function checkGrammarForOmittedArgument(node, args) { - if (args) { - var sourceFile = ts.getSourceFileOfNode(node); - for (var _i = 0; _i < args.length; _i++) { - var arg = args[_i]; - if (arg.kind === 187 /* OmittedExpression */) { - return grammarErrorAtPos(sourceFile, arg.pos, 0, ts.Diagnostics.Argument_expression_expected); - } - } - } - } - function checkGrammarArguments(node, args) { - return checkGrammarForDisallowedTrailingComma(args) || - checkGrammarForOmittedArgument(node, args); - } - function checkGrammarHeritageClause(node) { - var types = node.types; - if (checkGrammarForDisallowedTrailingComma(types)) { - return true; - } - if (types && types.length === 0) { - var listType = ts.tokenToString(node.token); - var sourceFile = ts.getSourceFileOfNode(node); - return grammarErrorAtPos(sourceFile, types.pos, 0, ts.Diagnostics._0_list_cannot_be_empty, listType); - } - } - function checkGrammarClassDeclarationHeritageClauses(node) { - var seenExtendsClause = false; - var seenImplementsClause = false; - 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 (seenExtendsClause) { - return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_already_seen); - } - if (seenImplementsClause) { - return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_must_precede_implements_clause); - } - if (heritageClause.types.length > 1) { - return grammarErrorOnFirstToken(heritageClause.types[1], ts.Diagnostics.Classes_can_only_extend_a_single_class); - } - seenExtendsClause = true; - } - else { - ts.Debug.assert(heritageClause.token === 106 /* ImplementsKeyword */); - if (seenImplementsClause) { - return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.implements_clause_already_seen); - } - seenImplementsClause = true; - } - // Grammar checking heritageClause inside class declaration - checkGrammarHeritageClause(heritageClause); - } - } - } - function checkGrammarInterfaceDeclaration(node) { - var seenExtendsClause = false; - if (node.heritageClauses) { - for (var _i = 0, _a = node.heritageClauses; _i < _a.length; _i++) { - var heritageClause = _a[_i]; - if (heritageClause.token === 83 /* ExtendsKeyword */) { - if (seenExtendsClause) { - return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_already_seen); - } - seenExtendsClause = true; - } - else { - ts.Debug.assert(heritageClause.token === 106 /* ImplementsKeyword */); - return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.Interface_declaration_cannot_have_implements_clause); - } - // Grammar checking heritageClause inside class declaration - checkGrammarHeritageClause(heritageClause); - } - } - return false; - } - function checkGrammarComputedPropertyName(node) { - // If node is not a computedPropertyName, just skip the grammar checking - if (node.kind !== 136 /* ComputedPropertyName */) { - return false; - } - var computedPropertyName = node; - if (computedPropertyName.expression.kind === 181 /* BinaryExpression */ && computedPropertyName.expression.operatorToken.kind === 24 /* CommaToken */) { - return grammarErrorOnNode(computedPropertyName.expression, ts.Diagnostics.A_comma_expression_is_not_allowed_in_a_computed_property_name); - } - } - function checkGrammarForGenerator(node) { - if (node.asteriskToken) { - ts.Debug.assert(node.kind === 213 /* FunctionDeclaration */ || - node.kind === 173 /* FunctionExpression */ || - node.kind === 143 /* MethodDeclaration */); - if (ts.isInAmbientContext(node)) { - return grammarErrorOnNode(node.asteriskToken, ts.Diagnostics.Generators_are_not_allowed_in_an_ambient_context); - } - if (!node.body) { - return grammarErrorOnNode(node.asteriskToken, ts.Diagnostics.An_overload_signature_cannot_be_declared_as_a_generator); - } - if (languageVersion < 2 /* ES6 */) { - return grammarErrorOnNode(node.asteriskToken, ts.Diagnostics.Generators_are_only_available_when_targeting_ECMAScript_6_or_higher); - } - } - } - function checkGrammarForInvalidQuestionMark(node, questionToken, message) { - if (questionToken) { - return grammarErrorOnNode(questionToken, message); - } - } - function checkGrammarObjectLiteralExpression(node, inDestructuring) { - var seen = {}; - var Property = 1; - var GetAccessor = 2; - var SetAccesor = 4; - var GetOrSetAccessor = GetAccessor | SetAccesor; - for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { - var prop = _a[_i]; - var name_16 = prop.name; - if (prop.kind === 187 /* OmittedExpression */ || - name_16.kind === 136 /* ComputedPropertyName */) { - // If the name is not a ComputedPropertyName, the grammar checking will skip it - checkGrammarComputedPropertyName(name_16); - continue; - } - if (prop.kind === 246 /* ShorthandPropertyAssignment */ && !inDestructuring && prop.objectAssignmentInitializer) { - // having objectAssignmentInitializer is only valid in ObjectAssignmentPattern - // outside of destructuring it is a syntax error - return grammarErrorOnNode(prop.equalsToken, ts.Diagnostics.can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment); - } - // ECMA-262 11.1.5 Object Initialiser - // If previous is not undefined then throw a SyntaxError exception if any of the following conditions are true - // a.This production is contained in strict code and IsDataDescriptor(previous) is true and - // 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 - var currentKind = void 0; - if (prop.kind === 245 /* PropertyAssignment */ || prop.kind === 246 /* ShorthandPropertyAssignment */) { - // Grammar checking for computedPropertName and shorthandPropertyAssignment - checkGrammarForInvalidQuestionMark(prop, prop.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional); - if (name_16.kind === 8 /* NumericLiteral */) { - checkGrammarNumericLiteral(name_16); - } - currentKind = Property; - } - else if (prop.kind === 143 /* MethodDeclaration */) { - currentKind = Property; - } - else if (prop.kind === 145 /* GetAccessor */) { - currentKind = GetAccessor; - } - else if (prop.kind === 146 /* SetAccessor */) { - currentKind = SetAccesor; - } - else { - ts.Debug.fail("Unexpected syntax kind:" + prop.kind); - } - if (!ts.hasProperty(seen, name_16.text)) { - seen[name_16.text] = currentKind; - } - else { - var existingKind = seen[name_16.text]; - if (currentKind === Property && existingKind === Property) { - continue; - } - else if ((currentKind & GetOrSetAccessor) && (existingKind & GetOrSetAccessor)) { - if (existingKind !== GetOrSetAccessor && currentKind !== existingKind) { - seen[name_16.text] = currentKind | existingKind; - } - else { - return grammarErrorOnNode(name_16, ts.Diagnostics.An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name); - } - } - else { - return grammarErrorOnNode(name_16, ts.Diagnostics.An_object_literal_cannot_have_property_and_accessor_with_the_same_name); - } - } - } - } - function checkGrammarJsxElement(node) { - var seen = {}; - for (var _i = 0, _a = node.attributes; _i < _a.length; _i++) { - var attr = _a[_i]; - if (attr.kind === 239 /* JsxSpreadAttribute */) { - continue; - } - var jsxAttr = attr; - var name_17 = jsxAttr.name; - if (!ts.hasProperty(seen, name_17.text)) { - seen[name_17.text] = true; - } - else { - return grammarErrorOnNode(name_17, ts.Diagnostics.JSX_elements_cannot_have_multiple_attributes_with_the_same_name); - } - var initializer = jsxAttr.initializer; - if (initializer && initializer.kind === 240 /* JsxExpression */ && !initializer.expression) { - return grammarErrorOnNode(jsxAttr.initializer, ts.Diagnostics.JSX_attributes_must_only_be_assigned_a_non_empty_expression); - } - } - } - function checkGrammarForInOrForOfStatement(forInOrOfStatement) { - if (checkGrammarStatementInAmbientContext(forInOrOfStatement)) { - return true; - } - if (forInOrOfStatement.initializer.kind === 212 /* VariableDeclarationList */) { - var variableList = forInOrOfStatement.initializer; - if (!checkGrammarVariableDeclarationList(variableList)) { - if (variableList.declarations.length > 1) { - var diagnostic = forInOrOfStatement.kind === 200 /* ForInStatement */ - ? ts.Diagnostics.Only_a_single_variable_declaration_is_allowed_in_a_for_in_statement - : ts.Diagnostics.Only_a_single_variable_declaration_is_allowed_in_a_for_of_statement; - return grammarErrorOnFirstToken(variableList.declarations[1], diagnostic); - } - var firstDeclaration = variableList.declarations[0]; - if (firstDeclaration.initializer) { - var diagnostic = forInOrOfStatement.kind === 200 /* ForInStatement */ - ? ts.Diagnostics.The_variable_declaration_of_a_for_in_statement_cannot_have_an_initializer - : ts.Diagnostics.The_variable_declaration_of_a_for_of_statement_cannot_have_an_initializer; - return grammarErrorOnNode(firstDeclaration.name, diagnostic); - } - if (firstDeclaration.type) { - var diagnostic = forInOrOfStatement.kind === 200 /* ForInStatement */ - ? ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_use_a_type_annotation - : ts.Diagnostics.The_left_hand_side_of_a_for_of_statement_cannot_use_a_type_annotation; - return grammarErrorOnNode(firstDeclaration, diagnostic); - } - } - } - return false; - } - function checkGrammarAccessor(accessor) { - var kind = accessor.kind; - if (languageVersion < 1 /* ES5 */) { - return grammarErrorOnNode(accessor.name, ts.Diagnostics.Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher); - } - else if (ts.isInAmbientContext(accessor)) { - return grammarErrorOnNode(accessor.name, ts.Diagnostics.An_accessor_cannot_be_declared_in_an_ambient_context); - } - else if (accessor.body === undefined) { - return grammarErrorAtPos(ts.getSourceFileOfNode(accessor), accessor.end - 1, ";".length, ts.Diagnostics._0_expected, "{"); - } - else if (accessor.typeParameters) { - return grammarErrorOnNode(accessor.name, ts.Diagnostics.An_accessor_cannot_have_type_parameters); - } - else if (kind === 145 /* GetAccessor */ && accessor.parameters.length) { - return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_get_accessor_cannot_have_parameters); - } - else if (kind === 146 /* SetAccessor */) { - if (accessor.type) { - return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_set_accessor_cannot_have_a_return_type_annotation); - } - else if (accessor.parameters.length !== 1) { - return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_set_accessor_must_have_exactly_one_parameter); - } - else { - var parameter = accessor.parameters[0]; - if (parameter.dotDotDotToken) { - return grammarErrorOnNode(parameter.dotDotDotToken, ts.Diagnostics.A_set_accessor_cannot_have_rest_parameter); - } - else if (parameter.flags & 2035 /* Modifier */) { - return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation); - } - else if (parameter.questionToken) { - return grammarErrorOnNode(parameter.questionToken, ts.Diagnostics.A_set_accessor_cannot_have_an_optional_parameter); - } - else if (parameter.initializer) { - return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_set_accessor_parameter_cannot_have_an_initializer); - } - } - } - } - function checkGrammarForNonSymbolComputedProperty(node, message) { - if (node.kind === 136 /* ComputedPropertyName */ && !ts.isWellKnownSymbolSyntactically(node.expression)) { - return grammarErrorOnNode(node, message); - } - } - function checkGrammarMethod(node) { - if (checkGrammarDisallowedModifiersOnObjectLiteralExpressionMethod(node) || - checkGrammarFunctionLikeDeclaration(node) || - checkGrammarForGenerator(node)) { - return true; - } - if (node.parent.kind === 165 /* ObjectLiteralExpression */) { - if (checkGrammarForInvalidQuestionMark(node, node.questionToken, ts.Diagnostics.A_class_member_cannot_be_declared_optional)) { - return true; - } - else if (node.body === undefined) { - return grammarErrorAtPos(getSourceFile(node), node.end - 1, ";".length, ts.Diagnostics._0_expected, "{"); - } - } - if (ts.isClassLike(node.parent)) { - if (checkGrammarForInvalidQuestionMark(node, node.questionToken, ts.Diagnostics.A_class_member_cannot_be_declared_optional)) { - return true; - } - // Technically, computed properties in ambient contexts is disallowed - // for property declarations and accessors too, not just methods. - // However, property declarations disallow computed names in general, - // and accessors are not allowed in ambient contexts in general, - // so this error only really matters for methods. - if (ts.isInAmbientContext(node)) { - return checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_an_ambient_context_must_directly_refer_to_a_built_in_symbol); - } - else if (!node.body) { - 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 === 215 /* InterfaceDeclaration */) { - return checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_an_interface_must_directly_refer_to_a_built_in_symbol); - } - else if (node.parent.kind === 155 /* TypeLiteral */) { - return checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_type_literal_must_directly_refer_to_a_built_in_symbol); - } - } - function isIterationStatement(node, lookInLabeledStatements) { - switch (node.kind) { - case 199 /* ForStatement */: - case 200 /* ForInStatement */: - case 201 /* ForOfStatement */: - case 197 /* DoStatement */: - case 198 /* WhileStatement */: - return true; - case 207 /* LabeledStatement */: - return lookInLabeledStatements && isIterationStatement(node.statement, lookInLabeledStatements); - } - return false; - } - function checkGrammarBreakOrContinueStatement(node) { - var current = node; - while (current) { - if (ts.isFunctionLike(current)) { - return grammarErrorOnNode(node, ts.Diagnostics.Jump_target_cannot_cross_function_boundary); - } - switch (current.kind) { - case 207 /* LabeledStatement */: - if (node.label && current.label.text === node.label.text) { - // found matching label - verify that label usage is correct - // continue can only target labels that are on iteration statements - var isMisplacedContinueLabel = node.kind === 202 /* ContinueStatement */ - && !isIterationStatement(current.statement, /*lookInLabeledStatement*/ true); - if (isMisplacedContinueLabel) { - return grammarErrorOnNode(node, ts.Diagnostics.A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement); - } - return false; - } - break; - case 206 /* SwitchStatement */: - if (node.kind === 203 /* BreakStatement */ && !node.label) { - // unlabeled break within switch statement - ok - return false; - } - break; - default: - if (isIterationStatement(current, /*lookInLabeledStatement*/ false) && !node.label) { - // unlabeled break or continue within iteration statement - ok - return false; - } - break; - } - current = current.parent; - } - if (node.label) { - var message = node.kind === 203 /* BreakStatement */ - ? ts.Diagnostics.A_break_statement_can_only_jump_to_a_label_of_an_enclosing_statement - : ts.Diagnostics.A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement; - return grammarErrorOnNode(node, message); - } - else { - var message = node.kind === 203 /* BreakStatement */ - ? ts.Diagnostics.A_break_statement_can_only_be_used_within_an_enclosing_iteration_or_switch_statement - : ts.Diagnostics.A_continue_statement_can_only_be_used_within_an_enclosing_iteration_statement; - return grammarErrorOnNode(node, message); - } - } - function checkGrammarBindingElement(node) { - if (node.dotDotDotToken) { - var elements = node.parent.elements; - 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 === 162 /* ArrayBindingPattern */ || node.name.kind === 161 /* ObjectBindingPattern */) { - return grammarErrorOnNode(node.name, ts.Diagnostics.A_rest_element_cannot_contain_a_binding_pattern); - } - if (node.initializer) { - // Error on equals token which immediate precedes the initializer - return grammarErrorAtPos(ts.getSourceFileOfNode(node), node.initializer.pos - 1, 1, ts.Diagnostics.A_rest_element_cannot_have_an_initializer); - } - } - } - function checkGrammarVariableDeclaration(node) { - if (node.parent.parent.kind !== 200 /* ForInStatement */ && node.parent.parent.kind !== 201 /* ForOfStatement */) { - if (ts.isInAmbientContext(node)) { - if (node.initializer) { - // Error on equals token which immediate precedes the initializer - var equalsTokenLength = "=".length; - return grammarErrorAtPos(ts.getSourceFileOfNode(node), node.initializer.pos - equalsTokenLength, equalsTokenLength, ts.Diagnostics.Initializers_are_not_allowed_in_ambient_contexts); - } - } - else if (!node.initializer) { - if (ts.isBindingPattern(node.name) && !ts.isBindingPattern(node.parent)) { - return grammarErrorOnNode(node, ts.Diagnostics.A_destructuring_declaration_must_have_an_initializer); - } - if (ts.isConst(node)) { - return grammarErrorOnNode(node, ts.Diagnostics.const_declarations_must_be_initialized); - } - } - } - var checkLetConstNames = languageVersion >= 2 /* ES6 */ && (ts.isLet(node) || ts.isConst(node)); - // 1. LexicalDeclaration : LetOrConst BindingList ; - // It is a Syntax Error if the BoundNames of BindingList contains "let". - // 2. ForDeclaration: ForDeclaration : LetOrConst ForBinding - // It is a Syntax Error if the BoundNames of ForDeclaration contains "let". - // It is a SyntaxError if a VariableDeclaration or VariableDeclarationNoIn occurs within strict code - // and its Identifier is eval or arguments - return checkLetConstNames && checkGrammarNameInLetOrConstDeclarations(node.name); - } - function checkGrammarNameInLetOrConstDeclarations(name) { - if (name.kind === 69 /* Identifier */) { - if (name.text === "let") { - return grammarErrorOnNode(name, ts.Diagnostics.let_is_not_allowed_to_be_used_as_a_name_in_let_or_const_declarations); - } - } - else { - var elements = name.elements; - for (var _i = 0; _i < elements.length; _i++) { - var element = elements[_i]; - if (element.kind !== 187 /* OmittedExpression */) { - checkGrammarNameInLetOrConstDeclarations(element.name); - } - } - } - } - function checkGrammarVariableDeclarationList(declarationList) { - var declarations = declarationList.declarations; - if (checkGrammarForDisallowedTrailingComma(declarationList.declarations)) { - return true; - } - if (!declarationList.declarations.length) { - return grammarErrorAtPos(ts.getSourceFileOfNode(declarationList), declarations.pos, declarations.end - declarations.pos, ts.Diagnostics.Variable_declaration_list_cannot_be_empty); - } - } - function allowLetAndConstDeclarations(parent) { - switch (parent.kind) { - case 196 /* IfStatement */: - case 197 /* DoStatement */: - case 198 /* WhileStatement */: - case 205 /* WithStatement */: - case 199 /* ForStatement */: - case 200 /* ForInStatement */: - case 201 /* ForOfStatement */: - return false; - case 207 /* LabeledStatement */: - return allowLetAndConstDeclarations(parent.parent); - } - return true; - } - function checkGrammarForDisallowedLetOrConstStatement(node) { - if (!allowLetAndConstDeclarations(node.parent)) { - if (ts.isLet(node.declarationList)) { - return grammarErrorOnNode(node, ts.Diagnostics.let_declarations_can_only_be_declared_inside_a_block); - } - else if (ts.isConst(node.declarationList)) { - return grammarErrorOnNode(node, ts.Diagnostics.const_declarations_can_only_be_declared_inside_a_block); - } - } - } - function isIntegerLiteral(expression) { - if (expression.kind === 179 /* PrefixUnaryExpression */) { - var unaryExpression = expression; - if (unaryExpression.operator === 35 /* PlusToken */ || unaryExpression.operator === 36 /* MinusToken */) { - expression = unaryExpression.operand; - } - } - if (expression.kind === 8 /* NumericLiteral */) { - // Allows for scientific notation since literalExpression.text was formed by - // coercing a number to a string. Sometimes this coercion can yield a string - // in scientific notation. - // We also don't need special logic for hex because a hex integer is converted - // to decimal when it is coerced. - return /^[0-9]+([eE]\+?[0-9]+)?$/.test(expression.text); - } - return false; - } - function hasParseDiagnostics(sourceFile) { - return sourceFile.parseDiagnostics.length > 0; - } - function grammarErrorOnFirstToken(node, message, arg0, arg1, arg2) { - var sourceFile = ts.getSourceFileOfNode(node); - if (!hasParseDiagnostics(sourceFile)) { - var span = ts.getSpanOfTokenAtPosition(sourceFile, node.pos); - diagnostics.add(ts.createFileDiagnostic(sourceFile, span.start, span.length, message, arg0, arg1, arg2)); - return true; - } - } - function grammarErrorAtPos(sourceFile, start, length, message, arg0, arg1, arg2) { - if (!hasParseDiagnostics(sourceFile)) { - diagnostics.add(ts.createFileDiagnostic(sourceFile, start, length, message, arg0, arg1, arg2)); - return true; - } - } - function grammarErrorOnNode(node, message, arg0, arg1, arg2) { - var sourceFile = ts.getSourceFileOfNode(node); - if (!hasParseDiagnostics(sourceFile)) { - diagnostics.add(ts.createDiagnosticForNode(node, message, arg0, arg1, arg2)); - return true; - } - } - function isEvalOrArgumentsIdentifier(node) { - return node.kind === 69 /* Identifier */ && - (node.text === "eval" || node.text === "arguments"); - } - function checkGrammarConstructorTypeParameters(node) { - if (node.typeParameters) { - return grammarErrorAtPos(ts.getSourceFileOfNode(node), node.typeParameters.pos, node.typeParameters.end - node.typeParameters.pos, ts.Diagnostics.Type_parameters_cannot_appear_on_a_constructor_declaration); - } - } - function checkGrammarConstructorTypeAnnotation(node) { - if (node.type) { - return grammarErrorOnNode(node.type, ts.Diagnostics.Type_annotation_cannot_appear_on_a_constructor_declaration); - } - } - function checkGrammarProperty(node) { - if (ts.isClassLike(node.parent)) { - if (checkGrammarForInvalidQuestionMark(node, node.questionToken, ts.Diagnostics.A_class_member_cannot_be_declared_optional) || - checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_class_property_declaration_must_directly_refer_to_a_built_in_symbol)) { - return true; - } - } - else if (node.parent.kind === 215 /* InterfaceDeclaration */) { - if (checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_an_interface_must_directly_refer_to_a_built_in_symbol)) { - return true; - } - } - else if (node.parent.kind === 155 /* TypeLiteral */) { - if (checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_type_literal_must_directly_refer_to_a_built_in_symbol)) { - return true; - } - } - if (ts.isInAmbientContext(node) && node.initializer) { - return grammarErrorOnFirstToken(node.initializer, ts.Diagnostics.Initializers_are_not_allowed_in_ambient_contexts); - } - } - function checkGrammarTopLevelElementForRequiredDeclareModifier(node) { - // A declare modifier is required for any top level .d.ts declaration except export=, export default, - // interfaces and imports categories: - // - // DeclarationElement: - // ExportAssignment - // export_opt InterfaceDeclaration - // export_opt ImportDeclaration - // export_opt ExternalImportDeclaration - // export_opt AmbientDeclaration - // - if (node.kind === 215 /* InterfaceDeclaration */ || - node.kind === 222 /* ImportDeclaration */ || - node.kind === 221 /* ImportEqualsDeclaration */ || - node.kind === 228 /* ExportDeclaration */ || - node.kind === 227 /* ExportAssignment */ || - (node.flags & 2 /* Ambient */) || - (node.flags & (1 /* Export */ | 1024 /* Default */))) { - return false; - } - return grammarErrorOnFirstToken(node, ts.Diagnostics.A_declare_modifier_is_required_for_a_top_level_declaration_in_a_d_ts_file); - } - function checkGrammarTopLevelElementsForRequiredDeclareModifier(file) { - for (var _i = 0, _a = file.statements; _i < _a.length; _i++) { - var decl = _a[_i]; - if (ts.isDeclaration(decl) || decl.kind === 193 /* VariableStatement */) { - if (checkGrammarTopLevelElementForRequiredDeclareModifier(decl)) { - return true; - } - } - } - } - function checkGrammarSourceFile(node) { - return ts.isInAmbientContext(node) && checkGrammarTopLevelElementsForRequiredDeclareModifier(node); - } - function checkGrammarStatementInAmbientContext(node) { - if (ts.isInAmbientContext(node)) { - // An accessors is already reported about the ambient context - if (isAccessor(node.parent.kind)) { - return getNodeLinks(node).hasReportedStatementInAmbientContext = true; - } - // Find containing block which is either Block, ModuleBlock, SourceFile - var links = getNodeLinks(node); - if (!links.hasReportedStatementInAmbientContext && ts.isFunctionLike(node.parent)) { - return getNodeLinks(node).hasReportedStatementInAmbientContext = grammarErrorOnFirstToken(node, ts.Diagnostics.An_implementation_cannot_be_declared_in_ambient_contexts); - } - // We are either parented by another statement, or some sort of block. - // If we're in a block, we only want to really report an error once - // to prevent noisyness. So use a bit on the block to indicate if - // this has already been reported, and don't report if it has. - // - if (node.parent.kind === 192 /* Block */ || node.parent.kind === 219 /* ModuleBlock */ || node.parent.kind === 248 /* SourceFile */) { - var links_1 = getNodeLinks(node.parent); - // Check if the containing block ever report this error - if (!links_1.hasReportedStatementInAmbientContext) { - return links_1.hasReportedStatementInAmbientContext = grammarErrorOnFirstToken(node, ts.Diagnostics.Statements_are_not_allowed_in_ambient_contexts); - } - } - else { - } - } - } - function checkGrammarNumericLiteral(node) { - // Grammar checking - if (node.flags & 65536 /* OctalLiteral */ && languageVersion >= 1 /* ES5 */) { - return grammarErrorOnNode(node, ts.Diagnostics.Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher); - } - } - function grammarErrorAfterFirstToken(node, message, arg0, arg1, arg2) { - var sourceFile = ts.getSourceFileOfNode(node); - if (!hasParseDiagnostics(sourceFile)) { - var span = ts.getSpanOfTokenAtPosition(sourceFile, node.pos); - diagnostics.add(ts.createFileDiagnostic(sourceFile, ts.textSpanEnd(span), /*length*/ 0, message, arg0, arg1, arg2)); - return true; - } - } - } - ts.createTypeChecker = createTypeChecker; -})(ts || (ts = {})); -/// -/* @internal */ -var ts; -(function (ts) { - function getDeclarationDiagnostics(host, resolver, targetSourceFile) { - var diagnostics = []; - var jsFilePath = ts.getOwnEmitOutputFilePath(targetSourceFile, host, ".js"); - emitDeclarations(host, resolver, diagnostics, jsFilePath, targetSourceFile); - return diagnostics; - } - ts.getDeclarationDiagnostics = getDeclarationDiagnostics; - function emitDeclarations(host, resolver, diagnostics, jsFilePath, root) { - var newLine = host.getNewLine(); - var compilerOptions = host.getCompilerOptions(); - var write; - var writeLine; - var increaseIndent; - var decreaseIndent; - var writeTextOfNode; - var writer = createAndSetNewTextWriterWithSymbolWriter(); - var enclosingDeclaration; - var currentSourceFile; - var reportedDeclarationError = false; - var errorNameNode; - var emitJsDocComments = compilerOptions.removeComments ? function (declaration) { } : writeJsDocComments; - var emit = compilerOptions.stripInternal ? stripInternal : emitNode; - var moduleElementDeclarationEmitInfo = []; - var asynchronousSubModuleDeclarationEmitInfo; - // Contains the reference paths that needs to go in the declaration file. - // Collecting this separately because reference paths need to be first thing in the declaration file - // and we could be collecting these paths from multiple files into single one with --out option - var referencePathsOutput = ""; - if (root) { - // Emitting just a single file, so emit references in this file only - if (!compilerOptions.noResolve) { - var addedGlobalFileReference = false; - ts.forEach(root.referencedFiles, function (fileReference) { - var referencedFile = ts.tryResolveScriptReference(host, root, fileReference); - // All the references that are not going to be part of same file - if (referencedFile && ((referencedFile.flags & 8192 /* DeclarationFile */) || - ts.shouldEmitToOwnFile(referencedFile, compilerOptions) || - !addedGlobalFileReference)) { - writeReferencePath(referencedFile); - if (!ts.isExternalModuleOrDeclarationFile(referencedFile)) { - addedGlobalFileReference = true; - } - } - }); - } - emitSourceFile(root); - // create asynchronous output for the importDeclarations - if (moduleElementDeclarationEmitInfo.length) { - var oldWriter = writer; - ts.forEach(moduleElementDeclarationEmitInfo, function (aliasEmitInfo) { - if (aliasEmitInfo.isVisible) { - ts.Debug.assert(aliasEmitInfo.node.kind === 222 /* ImportDeclaration */); - createAndSetNewTextWriterWithSymbolWriter(); - ts.Debug.assert(aliasEmitInfo.indent === 0); - writeImportDeclaration(aliasEmitInfo.node); - aliasEmitInfo.asynchronousOutput = writer.getText(); - } - }); - setWriter(oldWriter); - } - } - else { - // Emit references corresponding to this file - var emittedReferencedFiles = []; - ts.forEach(host.getSourceFiles(), function (sourceFile) { - if (!ts.isExternalModuleOrDeclarationFile(sourceFile)) { - // Check what references need to be added - if (!compilerOptions.noResolve) { - ts.forEach(sourceFile.referencedFiles, function (fileReference) { - var referencedFile = ts.tryResolveScriptReference(host, sourceFile, fileReference); - // If the reference file is a declaration file or an external module, emit that reference - if (referencedFile && (ts.isExternalModuleOrDeclarationFile(referencedFile) && - !ts.contains(emittedReferencedFiles, referencedFile))) { - writeReferencePath(referencedFile); - emittedReferencedFiles.push(referencedFile); - } - }); - } - emitSourceFile(sourceFile); - } - }); - } - return { - reportedDeclarationError: reportedDeclarationError, - moduleElementDeclarationEmitInfo: moduleElementDeclarationEmitInfo, - synchronousDeclarationOutput: writer.getText(), - referencePathsOutput: referencePathsOutput - }; - function hasInternalAnnotation(range) { - var text = currentSourceFile.text; - var comment = text.substring(range.pos, range.end); - return comment.indexOf("@internal") >= 0; - } - function stripInternal(node) { - if (node) { - var leadingCommentRanges = ts.getLeadingCommentRanges(currentSourceFile.text, node.pos); - if (ts.forEach(leadingCommentRanges, hasInternalAnnotation)) { - return; - } - emitNode(node); - } - } - function createAndSetNewTextWriterWithSymbolWriter() { - var writer = ts.createTextWriter(newLine); - writer.trackSymbol = trackSymbol; - writer.reportInaccessibleThisError = reportInaccessibleThisError; - writer.writeKeyword = writer.write; - writer.writeOperator = writer.write; - writer.writePunctuation = writer.write; - writer.writeSpace = writer.write; - writer.writeStringLiteral = writer.writeLiteral; - writer.writeParameter = writer.write; - writer.writeSymbol = writer.write; - setWriter(writer); - return writer; - } - function setWriter(newWriter) { - writer = newWriter; - write = newWriter.write; - writeTextOfNode = newWriter.writeTextOfNode; - writeLine = newWriter.writeLine; - increaseIndent = newWriter.increaseIndent; - decreaseIndent = newWriter.decreaseIndent; - } - function writeAsynchronousModuleElements(nodes) { - var oldWriter = writer; - ts.forEach(nodes, function (declaration) { - var nodeToCheck; - if (declaration.kind === 211 /* VariableDeclaration */) { - nodeToCheck = declaration.parent.parent; - } - else if (declaration.kind === 225 /* NamedImports */ || declaration.kind === 226 /* ImportSpecifier */ || declaration.kind === 223 /* ImportClause */) { - ts.Debug.fail("We should be getting ImportDeclaration instead to write"); - } - else { - nodeToCheck = declaration; - } - var moduleElementEmitInfo = ts.forEach(moduleElementDeclarationEmitInfo, function (declEmitInfo) { return declEmitInfo.node === nodeToCheck ? declEmitInfo : undefined; }); - if (!moduleElementEmitInfo && asynchronousSubModuleDeclarationEmitInfo) { - moduleElementEmitInfo = ts.forEach(asynchronousSubModuleDeclarationEmitInfo, function (declEmitInfo) { return declEmitInfo.node === nodeToCheck ? declEmitInfo : undefined; }); - } - // If the alias was marked as not visible when we saw its declaration, we would have saved the aliasEmitInfo, but if we haven't yet visited the alias declaration - // then we don't need to write it at this point. We will write it when we actually see its declaration - // Eg. - // export function bar(a: foo.Foo) { } - // import foo = require("foo"); - // 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 === 222 /* ImportDeclaration */) { - // we have to create asynchronous output only after we have collected complete information - // because it is possible to enable multiple bindings as asynchronously visible - moduleElementEmitInfo.isVisible = true; - } - else { - createAndSetNewTextWriterWithSymbolWriter(); - for (var declarationIndent = moduleElementEmitInfo.indent; declarationIndent; declarationIndent--) { - increaseIndent(); - } - if (nodeToCheck.kind === 218 /* ModuleDeclaration */) { - ts.Debug.assert(asynchronousSubModuleDeclarationEmitInfo === undefined); - asynchronousSubModuleDeclarationEmitInfo = []; - } - writeModuleElement(nodeToCheck); - if (nodeToCheck.kind === 218 /* ModuleDeclaration */) { - moduleElementEmitInfo.subModuleElementDeclarationEmitInfo = asynchronousSubModuleDeclarationEmitInfo; - asynchronousSubModuleDeclarationEmitInfo = undefined; - } - moduleElementEmitInfo.asynchronousOutput = writer.getText(); - } - } - }); - setWriter(oldWriter); - } - function handleSymbolAccessibilityError(symbolAccesibilityResult) { - if (symbolAccesibilityResult.accessibility === 0 /* Accessible */) { - // write the aliases - if (symbolAccesibilityResult && symbolAccesibilityResult.aliasesToMakeVisible) { - writeAsynchronousModuleElements(symbolAccesibilityResult.aliasesToMakeVisible); - } - } - else { - // Report error - reportedDeclarationError = true; - var errorInfo = writer.getSymbolAccessibilityDiagnostic(symbolAccesibilityResult); - if (errorInfo) { - if (errorInfo.typeName) { - diagnostics.push(ts.createDiagnosticForNode(symbolAccesibilityResult.errorNode || errorInfo.errorNode, errorInfo.diagnosticMessage, ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, errorInfo.typeName), symbolAccesibilityResult.errorSymbolName, symbolAccesibilityResult.errorModuleName)); - } - else { - diagnostics.push(ts.createDiagnosticForNode(symbolAccesibilityResult.errorNode || errorInfo.errorNode, errorInfo.diagnosticMessage, symbolAccesibilityResult.errorSymbolName, symbolAccesibilityResult.errorModuleName)); - } - } - } - } - function trackSymbol(symbol, enclosingDeclaration, meaning) { - handleSymbolAccessibilityError(resolver.isSymbolAccessible(symbol, enclosingDeclaration, meaning)); - } - function reportInaccessibleThisError() { - if (errorNameNode) { - diagnostics.push(ts.createDiagnosticForNode(errorNameNode, ts.Diagnostics.The_inferred_type_of_0_references_an_inaccessible_this_type_A_type_annotation_is_necessary, ts.declarationNameToString(errorNameNode))); - } - } - function writeTypeOfDeclaration(declaration, type, getSymbolAccessibilityDiagnostic) { - writer.getSymbolAccessibilityDiagnostic = getSymbolAccessibilityDiagnostic; - write(": "); - if (type) { - // Write the type - emitType(type); - } - else { - errorNameNode = declaration.name; - resolver.writeTypeOfDeclaration(declaration, enclosingDeclaration, 2 /* UseTypeOfFunction */, writer); - errorNameNode = undefined; - } - } - function writeReturnTypeAtSignature(signature, getSymbolAccessibilityDiagnostic) { - writer.getSymbolAccessibilityDiagnostic = getSymbolAccessibilityDiagnostic; - write(": "); - if (signature.type) { - // Write the type - emitType(signature.type); - } - else { - errorNameNode = signature.name; - resolver.writeReturnTypeOfSignatureDeclaration(signature, enclosingDeclaration, 2 /* UseTypeOfFunction */, writer); - errorNameNode = undefined; - } - } - function emitLines(nodes) { - for (var _i = 0; _i < nodes.length; _i++) { - var node = nodes[_i]; - emit(node); - } - } - function emitSeparatedList(nodes, separator, eachNodeEmitFn, canEmitFn) { - var currentWriterPos = writer.getTextPos(); - for (var _i = 0; _i < nodes.length; _i++) { - var node = nodes[_i]; - if (!canEmitFn || canEmitFn(node)) { - if (currentWriterPos !== writer.getTextPos()) { - write(separator); - } - currentWriterPos = writer.getTextPos(); - eachNodeEmitFn(node); - } - } - } - function emitCommaList(nodes, eachNodeEmitFn, canEmitFn) { - emitSeparatedList(nodes, ", ", eachNodeEmitFn, canEmitFn); - } - function writeJsDocComments(declaration) { - if (declaration) { - var jsDocComments = ts.getJsDocComments(declaration, currentSourceFile); - ts.emitNewLineBeforeLeadingComments(currentSourceFile, writer, declaration, jsDocComments); - // jsDoc comments are emitted at /*leading comment1 */space/*leading comment*/space - ts.emitComments(currentSourceFile, writer, jsDocComments, /*trailingSeparator*/ true, newLine, ts.writeCommentRange); - } - } - function emitTypeWithNewGetSymbolAccessibilityDiagnostic(type, getSymbolAccessibilityDiagnostic) { - writer.getSymbolAccessibilityDiagnostic = getSymbolAccessibilityDiagnostic; - emitType(type); - } - function emitType(type) { - switch (type.kind) { - case 117 /* AnyKeyword */: - case 130 /* StringKeyword */: - case 128 /* NumberKeyword */: - case 120 /* BooleanKeyword */: - case 131 /* SymbolKeyword */: - case 103 /* VoidKeyword */: - case 97 /* ThisKeyword */: - case 9 /* StringLiteral */: - return writeTextOfNode(currentSourceFile, type); - case 188 /* ExpressionWithTypeArguments */: - return emitExpressionWithTypeArguments(type); - case 151 /* TypeReference */: - return emitTypeReference(type); - case 154 /* TypeQuery */: - return emitTypeQuery(type); - case 156 /* ArrayType */: - return emitArrayType(type); - case 157 /* TupleType */: - return emitTupleType(type); - case 158 /* UnionType */: - return emitUnionType(type); - case 159 /* IntersectionType */: - return emitIntersectionType(type); - case 160 /* ParenthesizedType */: - return emitParenType(type); - case 152 /* FunctionType */: - case 153 /* ConstructorType */: - return emitSignatureDeclarationWithJsDocComments(type); - case 155 /* TypeLiteral */: - return emitTypeLiteral(type); - case 69 /* Identifier */: - return emitEntityName(type); - case 135 /* QualifiedName */: - return emitEntityName(type); - case 150 /* TypePredicate */: - return emitTypePredicate(type); - } - function writeEntityName(entityName) { - if (entityName.kind === 69 /* Identifier */) { - writeTextOfNode(currentSourceFile, entityName); - } - else { - var left = entityName.kind === 135 /* QualifiedName */ ? entityName.left : entityName.expression; - var right = entityName.kind === 135 /* QualifiedName */ ? entityName.right : entityName.name; - writeEntityName(left); - write("."); - writeTextOfNode(currentSourceFile, right); - } - } - function emitEntityName(entityName) { - var visibilityResult = resolver.isEntityNameVisible(entityName, - // Aliases can be written asynchronously so use correct enclosing declaration - entityName.parent.kind === 221 /* ImportEqualsDeclaration */ ? entityName.parent : enclosingDeclaration); - handleSymbolAccessibilityError(visibilityResult); - writeEntityName(entityName); - } - function emitExpressionWithTypeArguments(node) { - if (ts.isSupportedExpressionWithTypeArguments(node)) { - ts.Debug.assert(node.expression.kind === 69 /* Identifier */ || node.expression.kind === 166 /* PropertyAccessExpression */); - emitEntityName(node.expression); - if (node.typeArguments) { - write("<"); - emitCommaList(node.typeArguments, emitType); - write(">"); - } - } - } - function emitTypeReference(type) { - emitEntityName(type.typeName); - if (type.typeArguments) { - write("<"); - emitCommaList(type.typeArguments, emitType); - write(">"); - } - } - function emitTypePredicate(type) { - writeTextOfNode(currentSourceFile, type.parameterName); - write(" is "); - emitType(type.type); - } - function emitTypeQuery(type) { - write("typeof "); - emitEntityName(type.exprName); - } - function emitArrayType(type) { - emitType(type.elementType); - write("[]"); - } - function emitTupleType(type) { - write("["); - emitCommaList(type.elementTypes, emitType); - write("]"); - } - function emitUnionType(type) { - emitSeparatedList(type.types, " | ", emitType); - } - function emitIntersectionType(type) { - emitSeparatedList(type.types, " & ", emitType); - } - function emitParenType(type) { - write("("); - emitType(type.type); - write(")"); - } - function emitTypeLiteral(type) { - write("{"); - if (type.members.length) { - writeLine(); - increaseIndent(); - // write members - emitLines(type.members); - decreaseIndent(); - } - write("}"); - } - } - function emitSourceFile(node) { - currentSourceFile = node; - enclosingDeclaration = node; - emitLines(node.statements); - } - // Return a temp variable name to be used in `export default` statements. - // The temp name will be of the form _default_counter. - // Note that export default is only allowed at most once in a module, so we - // do not need to keep track of created temp names. - function getExportDefaultTempVariableName() { - var baseName = "_default"; - if (!ts.hasProperty(currentSourceFile.identifiers, baseName)) { - return baseName; - } - var count = 0; - while (true) { - var name_18 = baseName + "_" + (++count); - if (!ts.hasProperty(currentSourceFile.identifiers, name_18)) { - return name_18; - } - } - } - function emitExportAssignment(node) { - if (node.expression.kind === 69 /* Identifier */) { - write(node.isExportEquals ? "export = " : "export default "); - writeTextOfNode(currentSourceFile, node.expression); - } - else { - // Expression - var tempVarName = getExportDefaultTempVariableName(); - write("declare var "); - write(tempVarName); - write(": "); - writer.getSymbolAccessibilityDiagnostic = getDefaultExportAccessibilityDiagnostic; - resolver.writeTypeOfExpression(node.expression, enclosingDeclaration, 2 /* UseTypeOfFunction */, writer); - write(";"); - writeLine(); - write(node.isExportEquals ? "export = " : "export default "); - write(tempVarName); - } - write(";"); - writeLine(); - // Make all the declarations visible for the export name - if (node.expression.kind === 69 /* Identifier */) { - var nodes = resolver.collectLinkedAliases(node.expression); - // write each of these declarations asynchronously - writeAsynchronousModuleElements(nodes); - } - function getDefaultExportAccessibilityDiagnostic(diagnostic) { - return { - diagnosticMessage: ts.Diagnostics.Default_export_of_the_module_has_or_is_using_private_name_0, - errorNode: node - }; - } - } - function isModuleElementVisible(node) { - return resolver.isDeclarationVisible(node); - } - function emitModuleElement(node, isModuleElementVisible) { - if (isModuleElementVisible) { - writeModuleElement(node); - } - else if (node.kind === 221 /* ImportEqualsDeclaration */ || - (node.parent.kind === 248 /* SourceFile */ && ts.isExternalModule(currentSourceFile))) { - var isVisible; - if (asynchronousSubModuleDeclarationEmitInfo && node.parent.kind !== 248 /* SourceFile */) { - // Import declaration of another module that is visited async so lets put it in right spot - asynchronousSubModuleDeclarationEmitInfo.push({ - node: node, - outputPos: writer.getTextPos(), - indent: writer.getIndent(), - isVisible: isVisible - }); - } - else { - if (node.kind === 222 /* ImportDeclaration */) { - var importDeclaration = node; - if (importDeclaration.importClause) { - isVisible = (importDeclaration.importClause.name && resolver.isDeclarationVisible(importDeclaration.importClause)) || - isVisibleNamedBinding(importDeclaration.importClause.namedBindings); - } - } - moduleElementDeclarationEmitInfo.push({ - node: node, - outputPos: writer.getTextPos(), - indent: writer.getIndent(), - isVisible: isVisible - }); - } - } - } - function writeModuleElement(node) { - switch (node.kind) { - case 213 /* FunctionDeclaration */: - return writeFunctionDeclaration(node); - case 193 /* VariableStatement */: - return writeVariableStatement(node); - case 215 /* InterfaceDeclaration */: - return writeInterfaceDeclaration(node); - case 214 /* ClassDeclaration */: - return writeClassDeclaration(node); - case 216 /* TypeAliasDeclaration */: - return writeTypeAliasDeclaration(node); - case 217 /* EnumDeclaration */: - return writeEnumDeclaration(node); - case 218 /* ModuleDeclaration */: - return writeModuleDeclaration(node); - case 221 /* ImportEqualsDeclaration */: - return writeImportEqualsDeclaration(node); - case 222 /* ImportDeclaration */: - return writeImportDeclaration(node); - default: - ts.Debug.fail("Unknown symbol kind"); - } - } - function emitModuleElementDeclarationFlags(node) { - // If the node is parented in the current source file we need to emit export declare or just export - if (node.parent === currentSourceFile) { - // If the node is exported - if (node.flags & 1 /* Export */) { - write("export "); - } - if (node.flags & 1024 /* Default */) { - write("default "); - } - else if (node.kind !== 215 /* InterfaceDeclaration */) { - write("declare "); - } - } - } - function emitClassMemberDeclarationFlags(node) { - if (node.flags & 32 /* Private */) { - write("private "); - } - else if (node.flags & 64 /* Protected */) { - write("protected "); - } - if (node.flags & 128 /* Static */) { - write("static "); - } - if (node.flags & 256 /* Abstract */) { - write("abstract "); - } - } - function writeImportEqualsDeclaration(node) { - // note usage of writer. methods instead of aliases created, just to make sure we are using - // correct writer especially to handle asynchronous alias writing - emitJsDocComments(node); - if (node.flags & 1 /* Export */) { - write("export "); - } - write("import "); - writeTextOfNode(currentSourceFile, node.name); - write(" = "); - if (ts.isInternalModuleImportEqualsDeclaration(node)) { - emitTypeWithNewGetSymbolAccessibilityDiagnostic(node.moduleReference, getImportEntityNameVisibilityError); - write(";"); - } - else { - write("require("); - writeTextOfNode(currentSourceFile, ts.getExternalModuleImportEqualsDeclarationExpression(node)); - write(");"); - } - writer.writeLine(); - function getImportEntityNameVisibilityError(symbolAccesibilityResult) { - return { - diagnosticMessage: ts.Diagnostics.Import_declaration_0_is_using_private_name_1, - errorNode: node, - typeName: node.name - }; - } - } - function isVisibleNamedBinding(namedBindings) { - if (namedBindings) { - if (namedBindings.kind === 224 /* NamespaceImport */) { - return resolver.isDeclarationVisible(namedBindings); - } - else { - return ts.forEach(namedBindings.elements, function (namedImport) { return resolver.isDeclarationVisible(namedImport); }); - } - } - } - function writeImportDeclaration(node) { - if (!node.importClause && !(node.flags & 1 /* Export */)) { - // do not write non-exported import declarations that don't have import clauses - return; - } - emitJsDocComments(node); - if (node.flags & 1 /* Export */) { - write("export "); - } - write("import "); - if (node.importClause) { - var currentWriterPos = writer.getTextPos(); - if (node.importClause.name && resolver.isDeclarationVisible(node.importClause)) { - writeTextOfNode(currentSourceFile, node.importClause.name); - } - if (node.importClause.namedBindings && isVisibleNamedBinding(node.importClause.namedBindings)) { - if (currentWriterPos !== writer.getTextPos()) { - // If the default binding was emitted, write the separated - write(", "); - } - if (node.importClause.namedBindings.kind === 224 /* NamespaceImport */) { - write("* as "); - writeTextOfNode(currentSourceFile, node.importClause.namedBindings.name); - } - else { - write("{ "); - emitCommaList(node.importClause.namedBindings.elements, emitImportOrExportSpecifier, resolver.isDeclarationVisible); - write(" }"); - } - } - write(" from "); - } - writeTextOfNode(currentSourceFile, node.moduleSpecifier); - write(";"); - writer.writeLine(); - } - function emitImportOrExportSpecifier(node) { - if (node.propertyName) { - writeTextOfNode(currentSourceFile, node.propertyName); - write(" as "); - } - writeTextOfNode(currentSourceFile, node.name); - } - function emitExportSpecifier(node) { - emitImportOrExportSpecifier(node); - // Make all the declarations visible for the export name - var nodes = resolver.collectLinkedAliases(node.propertyName || node.name); - // write each of these declarations asynchronously - writeAsynchronousModuleElements(nodes); - } - function emitExportDeclaration(node) { - emitJsDocComments(node); - write("export "); - if (node.exportClause) { - write("{ "); - emitCommaList(node.exportClause.elements, emitExportSpecifier); - write(" }"); - } - else { - write("*"); - } - if (node.moduleSpecifier) { - write(" from "); - writeTextOfNode(currentSourceFile, node.moduleSpecifier); - } - write(";"); - writer.writeLine(); - } - function writeModuleDeclaration(node) { - emitJsDocComments(node); - emitModuleElementDeclarationFlags(node); - if (node.flags & 131072 /* Namespace */) { - write("namespace "); - } - else { - write("module "); - } - writeTextOfNode(currentSourceFile, node.name); - while (node.body.kind !== 219 /* ModuleBlock */) { - node = node.body; - write("."); - writeTextOfNode(currentSourceFile, node.name); - } - var prevEnclosingDeclaration = enclosingDeclaration; - enclosingDeclaration = node; - write(" {"); - writeLine(); - increaseIndent(); - emitLines(node.body.statements); - decreaseIndent(); - write("}"); - writeLine(); - enclosingDeclaration = prevEnclosingDeclaration; - } - function writeTypeAliasDeclaration(node) { - var prevEnclosingDeclaration = enclosingDeclaration; - enclosingDeclaration = node; - emitJsDocComments(node); - emitModuleElementDeclarationFlags(node); - write("type "); - writeTextOfNode(currentSourceFile, node.name); - emitTypeParameters(node.typeParameters); - write(" = "); - emitTypeWithNewGetSymbolAccessibilityDiagnostic(node.type, getTypeAliasDeclarationVisibilityError); - write(";"); - writeLine(); - enclosingDeclaration = prevEnclosingDeclaration; - function getTypeAliasDeclarationVisibilityError(symbolAccesibilityResult) { - return { - diagnosticMessage: ts.Diagnostics.Exported_type_alias_0_has_or_is_using_private_name_1, - errorNode: node.type, - typeName: node.name - }; - } - } - function writeEnumDeclaration(node) { - emitJsDocComments(node); - emitModuleElementDeclarationFlags(node); - if (ts.isConst(node)) { - write("const "); - } - write("enum "); - writeTextOfNode(currentSourceFile, node.name); - write(" {"); - writeLine(); - increaseIndent(); - emitLines(node.members); - decreaseIndent(); - write("}"); - writeLine(); - } - function emitEnumMemberDeclaration(node) { - emitJsDocComments(node); - writeTextOfNode(currentSourceFile, node.name); - var enumMemberValue = resolver.getConstantValue(node); - if (enumMemberValue !== undefined) { - write(" = "); - write(enumMemberValue.toString()); - } - write(","); - writeLine(); - } - function isPrivateMethodTypeParameter(node) { - return node.parent.kind === 143 /* MethodDeclaration */ && (node.parent.flags & 32 /* Private */); - } - function emitTypeParameters(typeParameters) { - function emitTypeParameter(node) { - increaseIndent(); - emitJsDocComments(node); - decreaseIndent(); - writeTextOfNode(currentSourceFile, node.name); - // 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 === 152 /* FunctionType */ || - node.parent.kind === 153 /* ConstructorType */ || - (node.parent.parent && node.parent.parent.kind === 155 /* TypeLiteral */)) { - ts.Debug.assert(node.parent.kind === 143 /* MethodDeclaration */ || - node.parent.kind === 142 /* MethodSignature */ || - node.parent.kind === 152 /* FunctionType */ || - node.parent.kind === 153 /* ConstructorType */ || - node.parent.kind === 147 /* CallSignature */ || - node.parent.kind === 148 /* ConstructSignature */); - emitType(node.constraint); - } - else { - emitTypeWithNewGetSymbolAccessibilityDiagnostic(node.constraint, getTypeParameterConstraintVisibilityError); - } - } - function getTypeParameterConstraintVisibilityError(symbolAccesibilityResult) { - // Type parameter constraints are named by user so we should always be able to name it - var diagnosticMessage; - switch (node.parent.kind) { - case 214 /* ClassDeclaration */: - diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_class_has_or_is_using_private_name_1; - break; - case 215 /* InterfaceDeclaration */: - diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1; - break; - case 148 /* ConstructSignature */: - diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; - break; - case 147 /* CallSignature */: - diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; - break; - case 143 /* MethodDeclaration */: - case 142 /* MethodSignature */: - if (node.parent.flags & 128 /* Static */) { - diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1; - } - else if (node.parent.parent.kind === 214 /* ClassDeclaration */) { - diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_public_method_from_exported_class_has_or_is_using_private_name_1; - } - else { - diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1; - } - break; - case 213 /* FunctionDeclaration */: - diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_function_has_or_is_using_private_name_1; - break; - default: - ts.Debug.fail("This is unknown parent for type parameter: " + node.parent.kind); - } - return { - diagnosticMessage: diagnosticMessage, - errorNode: node, - typeName: node.name - }; - } - } - if (typeParameters) { - write("<"); - emitCommaList(typeParameters, emitTypeParameter); - write(">"); - } - } - function emitHeritageClause(typeReferences, isImplementsList) { - if (typeReferences) { - write(isImplementsList ? " implements " : " extends "); - emitCommaList(typeReferences, emitTypeOfTypeReference); - } - function emitTypeOfTypeReference(node) { - if (ts.isSupportedExpressionWithTypeArguments(node)) { - emitTypeWithNewGetSymbolAccessibilityDiagnostic(node, getHeritageClauseVisibilityError); - } - else if (!isImplementsList && node.expression.kind === 93 /* NullKeyword */) { - write("null"); - } - function getHeritageClauseVisibilityError(symbolAccesibilityResult) { - var diagnosticMessage; - // Heritage clause is written by user so it can always be named - if (node.parent.parent.kind === 214 /* ClassDeclaration */) { - // Class or Interface implemented/extended is inaccessible - diagnosticMessage = isImplementsList ? - ts.Diagnostics.Implements_clause_of_exported_class_0_has_or_is_using_private_name_1 : - ts.Diagnostics.Extends_clause_of_exported_class_0_has_or_is_using_private_name_1; - } - else { - // interface is inaccessible - diagnosticMessage = ts.Diagnostics.Extends_clause_of_exported_interface_0_has_or_is_using_private_name_1; - } - return { - diagnosticMessage: diagnosticMessage, - errorNode: node, - typeName: node.parent.parent.name - }; - } - } - } - function writeClassDeclaration(node) { - function emitParameterProperties(constructorDeclaration) { - if (constructorDeclaration) { - ts.forEach(constructorDeclaration.parameters, function (param) { - if (param.flags & 112 /* AccessibilityModifier */) { - emitPropertyDeclaration(param); - } - }); - } - } - emitJsDocComments(node); - emitModuleElementDeclarationFlags(node); - if (node.flags & 256 /* Abstract */) { - write("abstract "); - } - write("class "); - writeTextOfNode(currentSourceFile, node.name); - var prevEnclosingDeclaration = enclosingDeclaration; - enclosingDeclaration = node; - emitTypeParameters(node.typeParameters); - var baseTypeNode = ts.getClassExtendsHeritageClauseElement(node); - if (baseTypeNode) { - emitHeritageClause([baseTypeNode], /*isImplementsList*/ false); - } - emitHeritageClause(ts.getClassImplementsHeritageClauseElements(node), /*isImplementsList*/ true); - write(" {"); - writeLine(); - increaseIndent(); - emitParameterProperties(ts.getFirstConstructorWithBody(node)); - emitLines(node.members); - decreaseIndent(); - write("}"); - writeLine(); - enclosingDeclaration = prevEnclosingDeclaration; - } - function writeInterfaceDeclaration(node) { - emitJsDocComments(node); - emitModuleElementDeclarationFlags(node); - write("interface "); - writeTextOfNode(currentSourceFile, node.name); - var prevEnclosingDeclaration = enclosingDeclaration; - enclosingDeclaration = node; - emitTypeParameters(node.typeParameters); - emitHeritageClause(ts.getInterfaceBaseTypeNodes(node), /*isImplementsList*/ false); - write(" {"); - writeLine(); - increaseIndent(); - emitLines(node.members); - decreaseIndent(); - write("}"); - writeLine(); - enclosingDeclaration = prevEnclosingDeclaration; - } - function emitPropertyDeclaration(node) { - if (ts.hasDynamicName(node)) { - return; - } - emitJsDocComments(node); - emitClassMemberDeclarationFlags(node); - emitVariableDeclaration(node); - write(";"); - writeLine(); - } - 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 !== 211 /* VariableDeclaration */ || resolver.isDeclarationVisible(node)) { - if (ts.isBindingPattern(node.name)) { - emitBindingPattern(node.name); - } - else { - // If this node is a computed name, it can only be a symbol, because we've already skipped - // it if it's not a well known symbol. In that case, the text of the name will be exactly - // what we want, namely the name expression enclosed in brackets. - writeTextOfNode(currentSourceFile, node.name); - // If optional property emit ? - if ((node.kind === 141 /* PropertyDeclaration */ || node.kind === 140 /* PropertySignature */) && ts.hasQuestionToken(node)) { - write("?"); - } - if ((node.kind === 141 /* PropertyDeclaration */ || node.kind === 140 /* PropertySignature */) && node.parent.kind === 155 /* TypeLiteral */) { - emitTypeOfVariableDeclarationFromTypeLiteral(node); - } - else if (!(node.flags & 32 /* Private */)) { - writeTypeOfDeclaration(node, node.type, getVariableDeclarationTypeVisibilityError); - } - } - } - function getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccesibilityResult) { - if (node.kind === 211 /* VariableDeclaration */) { - return symbolAccesibilityResult.errorModuleName ? - symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? - ts.Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : - ts.Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_private_module_2 : - ts.Diagnostics.Exported_variable_0_has_or_is_using_private_name_1; - } - else if (node.kind === 141 /* PropertyDeclaration */ || node.kind === 140 /* PropertySignature */) { - // TODO(jfreeman): Deal with computed properties in error reporting. - if (node.flags & 128 /* Static */) { - return symbolAccesibilityResult.errorModuleName ? - symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? - ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : - ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : - ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_private_name_1; - } - else if (node.parent.kind === 214 /* ClassDeclaration */) { - return symbolAccesibilityResult.errorModuleName ? - symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? - ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : - ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : - ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_private_name_1; - } - else { - // Interfaces cannot have types that cannot be named - return symbolAccesibilityResult.errorModuleName ? - ts.Diagnostics.Property_0_of_exported_interface_has_or_is_using_name_1_from_private_module_2 : - ts.Diagnostics.Property_0_of_exported_interface_has_or_is_using_private_name_1; - } - } - } - function getVariableDeclarationTypeVisibilityError(symbolAccesibilityResult) { - var diagnosticMessage = getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccesibilityResult); - return diagnosticMessage !== undefined ? { - diagnosticMessage: diagnosticMessage, - errorNode: node, - typeName: node.name - } : undefined; - } - function emitBindingPattern(bindingPattern) { - // Only select non-omitted expression from the bindingPattern's elements. - // We have to do this to avoid emitting trailing commas. - // For example: - // original: var [, c,,] = [ 2,3,4] - // emitted: declare var c: number; // instead of declare var c:number, ; - var elements = []; - for (var _i = 0, _a = bindingPattern.elements; _i < _a.length; _i++) { - var element = _a[_i]; - if (element.kind !== 187 /* OmittedExpression */) { - elements.push(element); - } - } - emitCommaList(elements, emitBindingElement); - } - function emitBindingElement(bindingElement) { - function getBindingElementTypeVisibilityError(symbolAccesibilityResult) { - var diagnosticMessage = getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccesibilityResult); - return diagnosticMessage !== undefined ? { - diagnosticMessage: diagnosticMessage, - errorNode: bindingElement, - typeName: bindingElement.name - } : undefined; - } - if (bindingElement.name) { - if (ts.isBindingPattern(bindingElement.name)) { - emitBindingPattern(bindingElement.name); - } - else { - writeTextOfNode(currentSourceFile, bindingElement.name); - writeTypeOfDeclaration(bindingElement, /*type*/ undefined, getBindingElementTypeVisibilityError); - } - } - } - } - function emitTypeOfVariableDeclarationFromTypeLiteral(node) { - // if this is property of type literal, - // or is parameter of method/call/construct/index signature of type literal - // emit only if type is specified - if (node.type) { - write(": "); - emitType(node.type); - } - } - function isVariableStatementVisible(node) { - return ts.forEach(node.declarationList.declarations, function (varDeclaration) { return resolver.isDeclarationVisible(varDeclaration); }); - } - function writeVariableStatement(node) { - emitJsDocComments(node); - emitModuleElementDeclarationFlags(node); - if (ts.isLet(node.declarationList)) { - write("let "); - } - else if (ts.isConst(node.declarationList)) { - write("const "); - } - else { - write("var "); - } - emitCommaList(node.declarationList.declarations, emitVariableDeclaration, resolver.isDeclarationVisible); - write(";"); - writeLine(); - } - function emitAccessorDeclaration(node) { - if (ts.hasDynamicName(node)) { - return; - } - var accessors = ts.getAllAccessorDeclarations(node.parent.members, node); - var accessorWithTypeAnnotation; - if (node === accessors.firstAccessor) { - emitJsDocComments(accessors.getAccessor); - emitJsDocComments(accessors.setAccessor); - emitClassMemberDeclarationFlags(node); - writeTextOfNode(currentSourceFile, node.name); - if (!(node.flags & 32 /* Private */)) { - accessorWithTypeAnnotation = node; - var type = getTypeAnnotationFromAccessor(node); - if (!type) { - // couldn't get type for the first accessor, try the another one - var anotherAccessor = node.kind === 145 /* GetAccessor */ ? accessors.setAccessor : accessors.getAccessor; - type = getTypeAnnotationFromAccessor(anotherAccessor); - if (type) { - accessorWithTypeAnnotation = anotherAccessor; - } - } - writeTypeOfDeclaration(node, type, getAccessorDeclarationTypeVisibilityError); - } - write(";"); - writeLine(); - } - function getTypeAnnotationFromAccessor(accessor) { - if (accessor) { - return accessor.kind === 145 /* GetAccessor */ - ? accessor.type // Getter - return type - : accessor.parameters.length > 0 - ? accessor.parameters[0].type // Setter parameter type - : undefined; - } - } - function getAccessorDeclarationTypeVisibilityError(symbolAccesibilityResult) { - var diagnosticMessage; - if (accessorWithTypeAnnotation.kind === 146 /* SetAccessor */) { - // Setters have to have type named and cannot infer it so, the type should always be named - if (accessorWithTypeAnnotation.parent.flags & 128 /* Static */) { - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? - ts.Diagnostics.Parameter_0_of_public_static_property_setter_from_exported_class_has_or_is_using_name_1_from_private_module_2 : - ts.Diagnostics.Parameter_0_of_public_static_property_setter_from_exported_class_has_or_is_using_private_name_1; - } - else { - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? - ts.Diagnostics.Parameter_0_of_public_property_setter_from_exported_class_has_or_is_using_name_1_from_private_module_2 : - ts.Diagnostics.Parameter_0_of_public_property_setter_from_exported_class_has_or_is_using_private_name_1; - } - return { - diagnosticMessage: diagnosticMessage, - errorNode: accessorWithTypeAnnotation.parameters[0], - // TODO(jfreeman): Investigate why we are passing node.name instead of node.parameters[0].name - typeName: accessorWithTypeAnnotation.name - }; - } - else { - if (accessorWithTypeAnnotation.flags & 128 /* Static */) { - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? - symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? - ts.Diagnostics.Return_type_of_public_static_property_getter_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : - ts.Diagnostics.Return_type_of_public_static_property_getter_from_exported_class_has_or_is_using_name_0_from_private_module_1 : - ts.Diagnostics.Return_type_of_public_static_property_getter_from_exported_class_has_or_is_using_private_name_0; - } - else { - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? - symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? - ts.Diagnostics.Return_type_of_public_property_getter_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : - ts.Diagnostics.Return_type_of_public_property_getter_from_exported_class_has_or_is_using_name_0_from_private_module_1 : - ts.Diagnostics.Return_type_of_public_property_getter_from_exported_class_has_or_is_using_private_name_0; - } - return { - diagnosticMessage: diagnosticMessage, - errorNode: accessorWithTypeAnnotation.name, - typeName: undefined - }; - } - } - } - function writeFunctionDeclaration(node) { - if (ts.hasDynamicName(node)) { - return; - } - // If we are emitting Method/Constructor it isn't moduleElement and hence already determined to be emitting - // so no need to verify if the declaration is visible - if (!resolver.isImplementationOfOverload(node)) { - emitJsDocComments(node); - if (node.kind === 213 /* FunctionDeclaration */) { - emitModuleElementDeclarationFlags(node); - } - else if (node.kind === 143 /* MethodDeclaration */) { - emitClassMemberDeclarationFlags(node); - } - if (node.kind === 213 /* FunctionDeclaration */) { - write("function "); - writeTextOfNode(currentSourceFile, node.name); - } - else if (node.kind === 144 /* Constructor */) { - write("constructor"); - } - else { - writeTextOfNode(currentSourceFile, node.name); - if (ts.hasQuestionToken(node)) { - write("?"); - } - } - emitSignatureDeclaration(node); - } - } - function emitSignatureDeclarationWithJsDocComments(node) { - emitJsDocComments(node); - emitSignatureDeclaration(node); - } - function emitSignatureDeclaration(node) { - // Construct signature or constructor type write new Signature - if (node.kind === 148 /* ConstructSignature */ || node.kind === 153 /* ConstructorType */) { - write("new "); - } - emitTypeParameters(node.typeParameters); - if (node.kind === 149 /* IndexSignature */) { - write("["); - } - else { - write("("); - } - var prevEnclosingDeclaration = enclosingDeclaration; - enclosingDeclaration = node; - // Parameters - emitCommaList(node.parameters, emitParameterDeclaration); - if (node.kind === 149 /* IndexSignature */) { - write("]"); - } - else { - write(")"); - } - // If this is not a constructor and is not private, emit the return type - var isFunctionTypeOrConstructorType = node.kind === 152 /* FunctionType */ || node.kind === 153 /* ConstructorType */; - if (isFunctionTypeOrConstructorType || node.parent.kind === 155 /* TypeLiteral */) { - // Emit type literal signature return type only if specified - if (node.type) { - write(isFunctionTypeOrConstructorType ? " => " : ": "); - emitType(node.type); - } - } - else if (node.kind !== 144 /* Constructor */ && !(node.flags & 32 /* Private */)) { - writeReturnTypeAtSignature(node, getReturnTypeVisibilityError); - } - enclosingDeclaration = prevEnclosingDeclaration; - if (!isFunctionTypeOrConstructorType) { - write(";"); - writeLine(); - } - function getReturnTypeVisibilityError(symbolAccesibilityResult) { - var diagnosticMessage; - switch (node.kind) { - case 148 /* ConstructSignature */: - // Interfaces cannot have return types that cannot be named - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? - ts.Diagnostics.Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : - ts.Diagnostics.Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_0; - break; - case 147 /* CallSignature */: - // Interfaces cannot have return types that cannot be named - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? - ts.Diagnostics.Return_type_of_call_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : - ts.Diagnostics.Return_type_of_call_signature_from_exported_interface_has_or_is_using_private_name_0; - break; - case 149 /* IndexSignature */: - // Interfaces cannot have return types that cannot be named - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? - ts.Diagnostics.Return_type_of_index_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : - ts.Diagnostics.Return_type_of_index_signature_from_exported_interface_has_or_is_using_private_name_0; - break; - case 143 /* MethodDeclaration */: - case 142 /* MethodSignature */: - if (node.flags & 128 /* Static */) { - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? - symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? - ts.Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : - 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 === 214 /* ClassDeclaration */) { - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? - symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? - ts.Diagnostics.Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : - ts.Diagnostics.Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_private_module_1 : - ts.Diagnostics.Return_type_of_public_method_from_exported_class_has_or_is_using_private_name_0; - } - else { - // Interfaces cannot have return types that cannot be named - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? - ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : - ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0; - } - break; - case 213 /* FunctionDeclaration */: - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? - symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? - ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : - ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_name_0_from_private_module_1 : - ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_private_name_0; - break; - default: - ts.Debug.fail("This is unknown kind for signature: " + node.kind); - } - return { - diagnosticMessage: diagnosticMessage, - errorNode: node.name || node - }; - } - } - function emitParameterDeclaration(node) { - increaseIndent(); - emitJsDocComments(node); - if (node.dotDotDotToken) { - write("..."); - } - if (ts.isBindingPattern(node.name)) { - // For bindingPattern, we can't simply writeTextOfNode from the source file - // because we want to omit the initializer and using writeTextOfNode will result in initializer get emitted. - // Therefore, we will have to recursively emit each element in the bindingPattern. - emitBindingPattern(node.name); - } - else { - writeTextOfNode(currentSourceFile, node.name); - } - if (resolver.isOptionalParameter(node)) { - write("?"); - } - decreaseIndent(); - if (node.parent.kind === 152 /* FunctionType */ || - node.parent.kind === 153 /* ConstructorType */ || - node.parent.parent.kind === 155 /* TypeLiteral */) { - emitTypeOfVariableDeclarationFromTypeLiteral(node); - } - else if (!(node.parent.flags & 32 /* Private */)) { - writeTypeOfDeclaration(node, node.type, getParameterDeclarationTypeVisibilityError); - } - function getParameterDeclarationTypeVisibilityError(symbolAccesibilityResult) { - var diagnosticMessage = getParameterDeclarationTypeVisibilityDiagnosticMessage(symbolAccesibilityResult); - return diagnosticMessage !== undefined ? { - diagnosticMessage: diagnosticMessage, - errorNode: node, - typeName: node.name - } : undefined; - } - function getParameterDeclarationTypeVisibilityDiagnosticMessage(symbolAccesibilityResult) { - switch (node.parent.kind) { - case 144 /* Constructor */: - return symbolAccesibilityResult.errorModuleName ? - symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? - ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : - ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_private_module_2 : - ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_private_name_1; - case 148 /* ConstructSignature */: - // Interfaces cannot have parameter types that cannot be named - return symbolAccesibilityResult.errorModuleName ? - ts.Diagnostics.Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : - ts.Diagnostics.Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; - case 147 /* CallSignature */: - // Interfaces cannot have parameter types that cannot be named - return symbolAccesibilityResult.errorModuleName ? - ts.Diagnostics.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : - ts.Diagnostics.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; - case 143 /* MethodDeclaration */: - case 142 /* MethodSignature */: - if (node.parent.flags & 128 /* Static */) { - return symbolAccesibilityResult.errorModuleName ? - symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? - ts.Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : - 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 === 214 /* ClassDeclaration */) { - return symbolAccesibilityResult.errorModuleName ? - symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? - ts.Diagnostics.Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : - ts.Diagnostics.Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_private_module_2 : - ts.Diagnostics.Parameter_0_of_public_method_from_exported_class_has_or_is_using_private_name_1; - } - else { - // Interfaces cannot have parameter types that cannot be named - return symbolAccesibilityResult.errorModuleName ? - 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 213 /* FunctionDeclaration */: - return symbolAccesibilityResult.errorModuleName ? - symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? - ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : - ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_name_1_from_private_module_2 : - ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_private_name_1; - default: - ts.Debug.fail("This is unknown parent for parameter: " + node.parent.kind); - } - } - function emitBindingPattern(bindingPattern) { - // We have to explicitly emit square bracket and bracket because these tokens are not store inside the node. - if (bindingPattern.kind === 161 /* ObjectBindingPattern */) { - write("{"); - emitCommaList(bindingPattern.elements, emitBindingElement); - write("}"); - } - else if (bindingPattern.kind === 162 /* ArrayBindingPattern */) { - write("["); - var elements = bindingPattern.elements; - emitCommaList(elements, emitBindingElement); - if (elements && elements.hasTrailingComma) { - write(", "); - } - write("]"); - } - } - function emitBindingElement(bindingElement) { - function getBindingElementTypeVisibilityError(symbolAccesibilityResult) { - var diagnosticMessage = getParameterDeclarationTypeVisibilityDiagnosticMessage(symbolAccesibilityResult); - return diagnosticMessage !== undefined ? { - diagnosticMessage: diagnosticMessage, - errorNode: bindingElement, - typeName: bindingElement.name - } : undefined; - } - if (bindingElement.kind === 187 /* OmittedExpression */) { - // If bindingElement is an omittedExpression (i.e. containing elision), - // we will emit blank space (although this may differ from users' original code, - // it allows emitSeparatedList to write separator appropriately) - // Example: - // original: function foo([, x, ,]) {} - // emit : function foo([ , x, , ]) {} - write(" "); - } - else if (bindingElement.kind === 163 /* BindingElement */) { - if (bindingElement.propertyName) { - // bindingElement has propertyName property in the following case: - // { y: [a,b,c] ...} -> bindingPattern will have a property called propertyName for "y" - // We have to explicitly emit the propertyName before descending into its binding elements. - // Example: - // original: function foo({y: [a,b,c]}) {} - // emit : declare function foo({y: [a, b, c]}: { y: [any, any, any] }) void; - writeTextOfNode(currentSourceFile, bindingElement.propertyName); - write(": "); - } - if (bindingElement.name) { - if (ts.isBindingPattern(bindingElement.name)) { - // If it is a nested binding pattern, we will recursively descend into each element and emit each one separately. - // In the case of rest element, we will omit rest element. - // Example: - // original: function foo([a, [[b]], c] = [1,[["string"]], 3]) {} - // emit : declare function foo([a, [[b]], c]: [number, [[string]], number]): void; - // original with rest: function foo([a, ...c]) {} - // emit : declare function foo([a, ...c]): void; - emitBindingPattern(bindingElement.name); - } - else { - ts.Debug.assert(bindingElement.name.kind === 69 /* Identifier */); - // If the node is just an identifier, we will simply emit the text associated with the node's name - // Example: - // original: function foo({y = 10, x}) {} - // emit : declare function foo({y, x}: {number, any}): void; - if (bindingElement.dotDotDotToken) { - write("..."); - } - writeTextOfNode(currentSourceFile, bindingElement.name); - } - } - } - } - } - function emitNode(node) { - switch (node.kind) { - case 213 /* FunctionDeclaration */: - case 218 /* ModuleDeclaration */: - case 221 /* ImportEqualsDeclaration */: - case 215 /* InterfaceDeclaration */: - case 214 /* ClassDeclaration */: - case 216 /* TypeAliasDeclaration */: - case 217 /* EnumDeclaration */: - return emitModuleElement(node, isModuleElementVisible(node)); - case 193 /* VariableStatement */: - return emitModuleElement(node, isVariableStatementVisible(node)); - case 222 /* ImportDeclaration */: - // Import declaration without import clause is visible, otherwise it is not visible - return emitModuleElement(node, /*isModuleElementVisible*/ !node.importClause); - case 228 /* ExportDeclaration */: - return emitExportDeclaration(node); - case 144 /* Constructor */: - case 143 /* MethodDeclaration */: - case 142 /* MethodSignature */: - return writeFunctionDeclaration(node); - case 148 /* ConstructSignature */: - case 147 /* CallSignature */: - case 149 /* IndexSignature */: - return emitSignatureDeclarationWithJsDocComments(node); - case 145 /* GetAccessor */: - case 146 /* SetAccessor */: - return emitAccessorDeclaration(node); - case 141 /* PropertyDeclaration */: - case 140 /* PropertySignature */: - return emitPropertyDeclaration(node); - case 247 /* EnumMember */: - return emitEnumMemberDeclaration(node); - case 227 /* ExportAssignment */: - return emitExportAssignment(node); - case 248 /* SourceFile */: - return emitSourceFile(node); - } - } - function writeReferencePath(referencedFile) { - var declFileName = referencedFile.flags & 8192 /* DeclarationFile */ - ? referencedFile.fileName // Declaration file, use declaration file name - : ts.shouldEmitToOwnFile(referencedFile, compilerOptions) - ? ts.getOwnEmitOutputFilePath(referencedFile, host, ".d.ts") // Own output file so get the .d.ts file - : ts.removeFileExtension(compilerOptions.outFile || compilerOptions.out) + ".d.ts"; // Global out file - declFileName = ts.getRelativePathToDirectoryOrUrl(ts.getDirectoryPath(ts.normalizeSlashes(jsFilePath)), declFileName, host.getCurrentDirectory(), host.getCanonicalFileName, - /*isAbsolutePathAnUrl*/ false); - referencePathsOutput += "/// " + newLine; - } - } - /* @internal */ - function writeDeclarationFile(jsFilePath, sourceFile, host, resolver, diagnostics) { - var emitDeclarationResult = emitDeclarations(host, resolver, diagnostics, jsFilePath, sourceFile); - // TODO(shkamat): Should we not write any declaration file if any of them can produce error, - // or should we just not write this file like we are doing now - if (!emitDeclarationResult.reportedDeclarationError) { - var declarationOutput = emitDeclarationResult.referencePathsOutput - + getDeclarationOutput(emitDeclarationResult.synchronousDeclarationOutput, emitDeclarationResult.moduleElementDeclarationEmitInfo); - ts.writeFile(host, diagnostics, ts.removeFileExtension(jsFilePath) + ".d.ts", declarationOutput, host.getCompilerOptions().emitBOM); - } - function getDeclarationOutput(synchronousDeclarationOutput, moduleElementDeclarationEmitInfo) { - var appliedSyncOutputPos = 0; - var declarationOutput = ""; - // apply asynchronous additions to the synchronous output - ts.forEach(moduleElementDeclarationEmitInfo, function (aliasEmitInfo) { - if (aliasEmitInfo.asynchronousOutput) { - declarationOutput += synchronousDeclarationOutput.substring(appliedSyncOutputPos, aliasEmitInfo.outputPos); - declarationOutput += getDeclarationOutput(aliasEmitInfo.asynchronousOutput, aliasEmitInfo.subModuleElementDeclarationEmitInfo); - appliedSyncOutputPos = aliasEmitInfo.outputPos; - } - }); - declarationOutput += synchronousDeclarationOutput.substring(appliedSyncOutputPos); - return declarationOutput; - } - } - ts.writeDeclarationFile = writeDeclarationFile; -})(ts || (ts = {})); -/// -/// -/* @internal */ -var ts; -(function (ts) { - function isExternalModuleOrDeclarationFile(sourceFile) { - return ts.isExternalModule(sourceFile) || ts.isDeclarationFile(sourceFile); - } - ts.isExternalModuleOrDeclarationFile = isExternalModuleOrDeclarationFile; - var entities = { - "quot": 0x0022, - "amp": 0x0026, - "apos": 0x0027, - "lt": 0x003C, - "gt": 0x003E, - "nbsp": 0x00A0, - "iexcl": 0x00A1, - "cent": 0x00A2, - "pound": 0x00A3, - "curren": 0x00A4, - "yen": 0x00A5, - "brvbar": 0x00A6, - "sect": 0x00A7, - "uml": 0x00A8, - "copy": 0x00A9, - "ordf": 0x00AA, - "laquo": 0x00AB, - "not": 0x00AC, - "shy": 0x00AD, - "reg": 0x00AE, - "macr": 0x00AF, - "deg": 0x00B0, - "plusmn": 0x00B1, - "sup2": 0x00B2, - "sup3": 0x00B3, - "acute": 0x00B4, - "micro": 0x00B5, - "para": 0x00B6, - "middot": 0x00B7, - "cedil": 0x00B8, - "sup1": 0x00B9, - "ordm": 0x00BA, - "raquo": 0x00BB, - "frac14": 0x00BC, - "frac12": 0x00BD, - "frac34": 0x00BE, - "iquest": 0x00BF, - "Agrave": 0x00C0, - "Aacute": 0x00C1, - "Acirc": 0x00C2, - "Atilde": 0x00C3, - "Auml": 0x00C4, - "Aring": 0x00C5, - "AElig": 0x00C6, - "Ccedil": 0x00C7, - "Egrave": 0x00C8, - "Eacute": 0x00C9, - "Ecirc": 0x00CA, - "Euml": 0x00CB, - "Igrave": 0x00CC, - "Iacute": 0x00CD, - "Icirc": 0x00CE, - "Iuml": 0x00CF, - "ETH": 0x00D0, - "Ntilde": 0x00D1, - "Ograve": 0x00D2, - "Oacute": 0x00D3, - "Ocirc": 0x00D4, - "Otilde": 0x00D5, - "Ouml": 0x00D6, - "times": 0x00D7, - "Oslash": 0x00D8, - "Ugrave": 0x00D9, - "Uacute": 0x00DA, - "Ucirc": 0x00DB, - "Uuml": 0x00DC, - "Yacute": 0x00DD, - "THORN": 0x00DE, - "szlig": 0x00DF, - "agrave": 0x00E0, - "aacute": 0x00E1, - "acirc": 0x00E2, - "atilde": 0x00E3, - "auml": 0x00E4, - "aring": 0x00E5, - "aelig": 0x00E6, - "ccedil": 0x00E7, - "egrave": 0x00E8, - "eacute": 0x00E9, - "ecirc": 0x00EA, - "euml": 0x00EB, - "igrave": 0x00EC, - "iacute": 0x00ED, - "icirc": 0x00EE, - "iuml": 0x00EF, - "eth": 0x00F0, - "ntilde": 0x00F1, - "ograve": 0x00F2, - "oacute": 0x00F3, - "ocirc": 0x00F4, - "otilde": 0x00F5, - "ouml": 0x00F6, - "divide": 0x00F7, - "oslash": 0x00F8, - "ugrave": 0x00F9, - "uacute": 0x00FA, - "ucirc": 0x00FB, - "uuml": 0x00FC, - "yacute": 0x00FD, - "thorn": 0x00FE, - "yuml": 0x00FF, - "OElig": 0x0152, - "oelig": 0x0153, - "Scaron": 0x0160, - "scaron": 0x0161, - "Yuml": 0x0178, - "fnof": 0x0192, - "circ": 0x02C6, - "tilde": 0x02DC, - "Alpha": 0x0391, - "Beta": 0x0392, - "Gamma": 0x0393, - "Delta": 0x0394, - "Epsilon": 0x0395, - "Zeta": 0x0396, - "Eta": 0x0397, - "Theta": 0x0398, - "Iota": 0x0399, - "Kappa": 0x039A, - "Lambda": 0x039B, - "Mu": 0x039C, - "Nu": 0x039D, - "Xi": 0x039E, - "Omicron": 0x039F, - "Pi": 0x03A0, - "Rho": 0x03A1, - "Sigma": 0x03A3, - "Tau": 0x03A4, - "Upsilon": 0x03A5, - "Phi": 0x03A6, - "Chi": 0x03A7, - "Psi": 0x03A8, - "Omega": 0x03A9, - "alpha": 0x03B1, - "beta": 0x03B2, - "gamma": 0x03B3, - "delta": 0x03B4, - "epsilon": 0x03B5, - "zeta": 0x03B6, - "eta": 0x03B7, - "theta": 0x03B8, - "iota": 0x03B9, - "kappa": 0x03BA, - "lambda": 0x03BB, - "mu": 0x03BC, - "nu": 0x03BD, - "xi": 0x03BE, - "omicron": 0x03BF, - "pi": 0x03C0, - "rho": 0x03C1, - "sigmaf": 0x03C2, - "sigma": 0x03C3, - "tau": 0x03C4, - "upsilon": 0x03C5, - "phi": 0x03C6, - "chi": 0x03C7, - "psi": 0x03C8, - "omega": 0x03C9, - "thetasym": 0x03D1, - "upsih": 0x03D2, - "piv": 0x03D6, - "ensp": 0x2002, - "emsp": 0x2003, - "thinsp": 0x2009, - "zwnj": 0x200C, - "zwj": 0x200D, - "lrm": 0x200E, - "rlm": 0x200F, - "ndash": 0x2013, - "mdash": 0x2014, - "lsquo": 0x2018, - "rsquo": 0x2019, - "sbquo": 0x201A, - "ldquo": 0x201C, - "rdquo": 0x201D, - "bdquo": 0x201E, - "dagger": 0x2020, - "Dagger": 0x2021, - "bull": 0x2022, - "hellip": 0x2026, - "permil": 0x2030, - "prime": 0x2032, - "Prime": 0x2033, - "lsaquo": 0x2039, - "rsaquo": 0x203A, - "oline": 0x203E, - "frasl": 0x2044, - "euro": 0x20AC, - "image": 0x2111, - "weierp": 0x2118, - "real": 0x211C, - "trade": 0x2122, - "alefsym": 0x2135, - "larr": 0x2190, - "uarr": 0x2191, - "rarr": 0x2192, - "darr": 0x2193, - "harr": 0x2194, - "crarr": 0x21B5, - "lArr": 0x21D0, - "uArr": 0x21D1, - "rArr": 0x21D2, - "dArr": 0x21D3, - "hArr": 0x21D4, - "forall": 0x2200, - "part": 0x2202, - "exist": 0x2203, - "empty": 0x2205, - "nabla": 0x2207, - "isin": 0x2208, - "notin": 0x2209, - "ni": 0x220B, - "prod": 0x220F, - "sum": 0x2211, - "minus": 0x2212, - "lowast": 0x2217, - "radic": 0x221A, - "prop": 0x221D, - "infin": 0x221E, - "ang": 0x2220, - "and": 0x2227, - "or": 0x2228, - "cap": 0x2229, - "cup": 0x222A, - "int": 0x222B, - "there4": 0x2234, - "sim": 0x223C, - "cong": 0x2245, - "asymp": 0x2248, - "ne": 0x2260, - "equiv": 0x2261, - "le": 0x2264, - "ge": 0x2265, - "sub": 0x2282, - "sup": 0x2283, - "nsub": 0x2284, - "sube": 0x2286, - "supe": 0x2287, - "oplus": 0x2295, - "otimes": 0x2297, - "perp": 0x22A5, - "sdot": 0x22C5, - "lceil": 0x2308, - "rceil": 0x2309, - "lfloor": 0x230A, - "rfloor": 0x230B, - "lang": 0x2329, - "rang": 0x232A, - "loz": 0x25CA, - "spades": 0x2660, - "clubs": 0x2663, - "hearts": 0x2665, - "diams": 0x2666 - }; - // Flags enum to track count of temp variables and a few dedicated names - var TempFlags; - (function (TempFlags) { - TempFlags[TempFlags["Auto"] = 0] = "Auto"; - TempFlags[TempFlags["CountMask"] = 268435455] = "CountMask"; - TempFlags[TempFlags["_i"] = 268435456] = "_i"; - })(TempFlags || (TempFlags = {})); - // 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) { - // emit output for the __extends helper function - var extendsHelper = "\nvar __extends = (this && this.__extends) || function (d, b) {\n for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];\n function __() { this.constructor = d; }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n};"; - // emit output for the __decorate helper function - var decorateHelper = "\nvar __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\n return c > 3 && r && Object.defineProperty(target, key, r), r;\n};"; - // emit output for the __metadata helper function - var metadataHelper = "\nvar __metadata = (this && this.__metadata) || function (k, v) {\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(k, v);\n};"; - // emit output for the __param helper function - var paramHelper = "\nvar __param = (this && this.__param) || function (paramIndex, decorator) {\n return function (target, key) { decorator(target, key, paramIndex); }\n};"; - var awaiterHelper = "\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promise, generator) {\n return new Promise(function (resolve, reject) {\n generator = generator.call(thisArg, _arguments);\n function cast(value) { return value instanceof Promise && value.constructor === Promise ? value : new Promise(function (resolve) { resolve(value); }); }\n function onfulfill(value) { try { step(\"next\", value); } catch (e) { reject(e); } }\n function onreject(value) { try { step(\"throw\", value); } catch (e) { reject(e); } }\n function step(verb, value) {\n var result = generator[verb](value);\n result.done ? resolve(result.value) : cast(result.value).then(onfulfill, onreject);\n }\n step(\"next\", void 0);\n });\n};"; - var compilerOptions = host.getCompilerOptions(); - var languageVersion = compilerOptions.target || 0 /* ES3 */; - var modulekind = compilerOptions.module ? compilerOptions.module : languageVersion === 2 /* ES6 */ ? 5 /* ES6 */ : 0 /* None */; - var sourceMapDataList = compilerOptions.sourceMap || compilerOptions.inlineSourceMap ? [] : undefined; - var diagnostics = []; - var newLine = host.getNewLine(); - var jsxDesugaring = host.getCompilerOptions().jsx !== 1 /* Preserve */; - var shouldEmitJsx = function (s) { return (s.languageVariant === 1 /* JSX */ && !jsxDesugaring); }; - if (targetSourceFile === undefined) { - ts.forEach(host.getSourceFiles(), function (sourceFile) { - if (ts.shouldEmitToOwnFile(sourceFile, compilerOptions)) { - var jsFilePath = ts.getOwnEmitOutputFilePath(sourceFile, host, shouldEmitJsx(sourceFile) ? ".jsx" : ".js"); - emitFile(jsFilePath, sourceFile); - } - }); - if (compilerOptions.outFile || compilerOptions.out) { - emitFile(compilerOptions.outFile || compilerOptions.out); - } - } - else { - // targetSourceFile is specified (e.g calling emitter from language service or calling getSemanticDiagnostic from language service) - if (ts.shouldEmitToOwnFile(targetSourceFile, compilerOptions)) { - var jsFilePath = ts.getOwnEmitOutputFilePath(targetSourceFile, host, shouldEmitJsx(targetSourceFile) ? ".jsx" : ".js"); - emitFile(jsFilePath, targetSourceFile); - } - else if (!ts.isDeclarationFile(targetSourceFile) && (compilerOptions.outFile || compilerOptions.out)) { - emitFile(compilerOptions.outFile || compilerOptions.out); - } - } - // Sort and make the unique list of diagnostics - diagnostics = ts.sortAndDeduplicateDiagnostics(diagnostics); - return { - emitSkipped: false, - diagnostics: diagnostics, - sourceMaps: sourceMapDataList - }; - function isNodeDescendentOf(node, ancestor) { - while (node) { - if (node === ancestor) - return true; - node = node.parent; - } - return false; - } - function isUniqueLocalName(name, container) { - for (var node = container; isNodeDescendentOf(node, container); node = node.nextContainer) { - if (node.locals && ts.hasProperty(node.locals, name)) { - // We conservatively include alias symbols to cover cases where they're emitted as locals - if (node.locals[name].flags & (107455 /* Value */ | 1048576 /* ExportValue */ | 8388608 /* Alias */)) { - return false; - } - } - } - return true; - } - function emitJavaScript(jsFilePath, root) { - var writer = ts.createTextWriter(newLine); - var write = writer.write, writeTextOfNode = writer.writeTextOfNode, writeLine = writer.writeLine, increaseIndent = writer.increaseIndent, decreaseIndent = writer.decreaseIndent; - var currentSourceFile; - // name of an exporter function if file is a System external module - // System.register([...], function () {...}) - // exporting in System modules looks like: - // export var x; ... x = 1 - // => - // var x;... exporter("x", x = 1) - var exportFunctionForFile; - var generatedNameSet = {}; - var nodeToGeneratedName = []; - var computedPropertyNamesToGeneratedNames; - var extendsEmitted = false; - var decorateEmitted = false; - var paramEmitted = false; - var awaiterEmitted = false; - var tempFlags = 0; - var tempVariables; - var tempParameters; - var externalImports; - var exportSpecifiers; - var exportEquals; - var hasExportStars; - /** Write emitted output to disk */ - var writeEmittedFiles = writeJavaScriptFile; - var detachedCommentsInfo; - var writeComment = ts.writeCommentRange; - /** Emit a node */ - var emit = emitNodeWithCommentsAndWithoutSourcemap; - /** Called just before starting emit of a node */ - var emitStart = function (node) { }; - /** Called once the emit of the node is done */ - var emitEnd = function (node) { }; - /** Emit the text for the given token that comes after startPos - * This by default writes the text provided with the given tokenKind - * but if optional emitFn callback is provided the text is emitted using the callback instead of default text - * @param tokenKind the kind of the token to search and emit - * @param startPos the position in the source to start searching for the token - * @param emitFn if given will be invoked to emit the text instead of actual token emit */ - var emitToken = emitTokenText; - /** Called to before starting the lexical scopes as in function/class in the emitted code because of node - * @param scopeDeclaration node that starts the lexical scope - * @param scopeName Optional name of this scope instead of deducing one from the declaration node */ - var scopeEmitStart = function (scopeDeclaration, scopeName) { }; - /** Called after coming out of the scope */ - var scopeEmitEnd = function () { }; - /** Sourcemap data that will get encoded */ - var sourceMapData; - /** If removeComments is true, no leading-comments needed to be emitted **/ - var emitLeadingCommentsOfPosition = compilerOptions.removeComments ? function (pos) { } : emitLeadingCommentsOfPositionWorker; - var moduleEmitDelegates = (_a = {}, - _a[5 /* ES6 */] = emitES6Module, - _a[2 /* AMD */] = emitAMDModule, - _a[4 /* System */] = emitSystemModule, - _a[3 /* UMD */] = emitUMDModule, - _a[1 /* CommonJS */] = emitCommonJSModule, - _a - ); - if (compilerOptions.sourceMap || compilerOptions.inlineSourceMap) { - initializeEmitterWithSourceMaps(); - } - if (root) { - // Do not call emit directly. It does not set the currentSourceFile. - emitSourceFile(root); - } - else { - ts.forEach(host.getSourceFiles(), function (sourceFile) { - if (!isExternalModuleOrDeclarationFile(sourceFile)) { - emitSourceFile(sourceFile); - } - }); - } - writeLine(); - writeEmittedFiles(writer.getText(), /*writeByteOrderMark*/ compilerOptions.emitBOM); - return; - function emitSourceFile(sourceFile) { - currentSourceFile = sourceFile; - exportFunctionForFile = undefined; - emit(sourceFile); - } - function isUniqueName(name) { - return !resolver.hasGlobalName(name) && - !ts.hasProperty(currentSourceFile.identifiers, name) && - !ts.hasProperty(generatedNameSet, name); - } - // Return the next available name in the pattern _a ... _z, _0, _1, ... - // TempFlags._i or TempFlags._n may be used to express a preference for that dedicated name. - // Note that names generated by makeTempVariableName and makeUniqueName will never conflict. - function makeTempVariableName(flags) { - if (flags && !(tempFlags & flags)) { - var name_19 = flags === 268435456 /* _i */ ? "_i" : "_n"; - if (isUniqueName(name_19)) { - tempFlags |= flags; - return name_19; - } - } - while (true) { - var count = tempFlags & 268435455 /* CountMask */; - tempFlags++; - // Skip over 'i' and 'n' - if (count !== 8 && count !== 13) { - var name_20 = count < 26 ? "_" + String.fromCharCode(97 /* a */ + count) : "_" + (count - 26); - if (isUniqueName(name_20)) { - return name_20; - } - } - } - } - // Generate a name that is unique within the current file and doesn't conflict with any names - // in global scope. The name is formed by adding an '_n' suffix to the specified base name, - // where n is a positive integer. Note that names generated by makeTempVariableName and - // makeUniqueName are guaranteed to never conflict. - function makeUniqueName(baseName) { - // Find the first unique 'name_n', where n is a positive number - if (baseName.charCodeAt(baseName.length - 1) !== 95 /* _ */) { - baseName += "_"; - } - var i = 1; - while (true) { - var generatedName = baseName + i; - if (isUniqueName(generatedName)) { - return generatedNameSet[generatedName] = generatedName; - } - i++; - } - } - function generateNameForModuleOrEnum(node) { - var name = node.name.text; - // Use module/enum name itself if it is unique, otherwise make a unique variation - return isUniqueLocalName(name, node) ? name : makeUniqueName(name); - } - function generateNameForImportOrExportDeclaration(node) { - var expr = ts.getExternalModuleName(node); - var baseName = expr.kind === 9 /* StringLiteral */ ? - ts.escapeIdentifier(ts.makeIdentifierFromModuleName(expr.text)) : "module"; - return makeUniqueName(baseName); - } - function generateNameForExportDefault() { - return makeUniqueName("default"); - } - function generateNameForClassExpression() { - return makeUniqueName("class"); - } - function generateNameForNode(node) { - switch (node.kind) { - case 69 /* Identifier */: - return makeUniqueName(node.text); - case 218 /* ModuleDeclaration */: - case 217 /* EnumDeclaration */: - return generateNameForModuleOrEnum(node); - case 222 /* ImportDeclaration */: - case 228 /* ExportDeclaration */: - return generateNameForImportOrExportDeclaration(node); - case 213 /* FunctionDeclaration */: - case 214 /* ClassDeclaration */: - case 227 /* ExportAssignment */: - return generateNameForExportDefault(); - case 186 /* ClassExpression */: - return generateNameForClassExpression(); - } - } - function getGeneratedNameForNode(node) { - var id = ts.getNodeId(node); - return nodeToGeneratedName[id] || (nodeToGeneratedName[id] = ts.unescapeIdentifier(generateNameForNode(node))); - } - function initializeEmitterWithSourceMaps() { - var sourceMapDir; // The directory in which sourcemap will be - // Current source map file and its index in the sources list - var sourceMapSourceIndex = -1; - // Names and its index map - var sourceMapNameIndexMap = {}; - var sourceMapNameIndices = []; - function getSourceMapNameIndex() { - return sourceMapNameIndices.length ? ts.lastOrUndefined(sourceMapNameIndices) : -1; - } - // Last recorded and encoded spans - var lastRecordedSourceMapSpan; - var lastEncodedSourceMapSpan = { - emittedLine: 1, - emittedColumn: 1, - sourceLine: 1, - sourceColumn: 1, - sourceIndex: 0 - }; - var lastEncodedNameIndex = 0; - // Encoding for sourcemap span - function encodeLastRecordedSourceMapSpan() { - if (!lastRecordedSourceMapSpan || lastRecordedSourceMapSpan === lastEncodedSourceMapSpan) { - return; - } - var prevEncodedEmittedColumn = lastEncodedSourceMapSpan.emittedColumn; - // Line/Comma delimiters - if (lastEncodedSourceMapSpan.emittedLine === lastRecordedSourceMapSpan.emittedLine) { - // Emit comma to separate the entry - if (sourceMapData.sourceMapMappings) { - sourceMapData.sourceMapMappings += ","; - } - } - else { - // Emit line delimiters - for (var encodedLine = lastEncodedSourceMapSpan.emittedLine; encodedLine < lastRecordedSourceMapSpan.emittedLine; encodedLine++) { - sourceMapData.sourceMapMappings += ";"; - } - prevEncodedEmittedColumn = 1; - } - // 1. Relative Column 0 based - sourceMapData.sourceMapMappings += base64VLQFormatEncode(lastRecordedSourceMapSpan.emittedColumn - prevEncodedEmittedColumn); - // 2. Relative sourceIndex - sourceMapData.sourceMapMappings += base64VLQFormatEncode(lastRecordedSourceMapSpan.sourceIndex - lastEncodedSourceMapSpan.sourceIndex); - // 3. Relative sourceLine 0 based - sourceMapData.sourceMapMappings += base64VLQFormatEncode(lastRecordedSourceMapSpan.sourceLine - lastEncodedSourceMapSpan.sourceLine); - // 4. Relative sourceColumn 0 based - sourceMapData.sourceMapMappings += base64VLQFormatEncode(lastRecordedSourceMapSpan.sourceColumn - lastEncodedSourceMapSpan.sourceColumn); - // 5. Relative namePosition 0 based - if (lastRecordedSourceMapSpan.nameIndex >= 0) { - sourceMapData.sourceMapMappings += base64VLQFormatEncode(lastRecordedSourceMapSpan.nameIndex - lastEncodedNameIndex); - lastEncodedNameIndex = lastRecordedSourceMapSpan.nameIndex; - } - lastEncodedSourceMapSpan = lastRecordedSourceMapSpan; - sourceMapData.sourceMapDecodedMappings.push(lastEncodedSourceMapSpan); - function base64VLQFormatEncode(inValue) { - function base64FormatEncode(inValue) { - if (inValue < 64) { - return "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(inValue); - } - throw TypeError(inValue + ": not a 64 based value"); - } - // Add a new least significant bit that has the sign of the value. - // if negative number the least significant bit that gets added to the number has value 1 - // else least significant bit value that gets added is 0 - // eg. -1 changes to binary : 01 [1] => 3 - // +1 changes to binary : 01 [0] => 2 - if (inValue < 0) { - inValue = ((-inValue) << 1) + 1; - } - else { - inValue = inValue << 1; - } - // Encode 5 bits at a time starting from least significant bits - var encodedStr = ""; - do { - var currentDigit = inValue & 31; // 11111 - inValue = inValue >> 5; - if (inValue > 0) { - // There are still more digits to decode, set the msb (6th bit) - currentDigit = currentDigit | 32; - } - encodedStr = encodedStr + base64FormatEncode(currentDigit); - } while (inValue > 0); - return encodedStr; - } - } - function recordSourceMapSpan(pos) { - var sourceLinePos = ts.getLineAndCharacterOfPosition(currentSourceFile, pos); - // Convert the location to be one-based. - sourceLinePos.line++; - sourceLinePos.character++; - var emittedLine = writer.getLine(); - var emittedColumn = writer.getColumn(); - // If this location wasn't recorded or the location in source is going backwards, record the span - if (!lastRecordedSourceMapSpan || - lastRecordedSourceMapSpan.emittedLine !== emittedLine || - lastRecordedSourceMapSpan.emittedColumn !== emittedColumn || - (lastRecordedSourceMapSpan.sourceIndex === sourceMapSourceIndex && - (lastRecordedSourceMapSpan.sourceLine > sourceLinePos.line || - (lastRecordedSourceMapSpan.sourceLine === sourceLinePos.line && lastRecordedSourceMapSpan.sourceColumn > sourceLinePos.character)))) { - // Encode the last recordedSpan before assigning new - encodeLastRecordedSourceMapSpan(); - // New span - lastRecordedSourceMapSpan = { - emittedLine: emittedLine, - emittedColumn: emittedColumn, - sourceLine: sourceLinePos.line, - sourceColumn: sourceLinePos.character, - nameIndex: getSourceMapNameIndex(), - sourceIndex: sourceMapSourceIndex - }; - } - 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; - } - } - function recordEmitNodeStartSpan(node) { - // Get the token pos after skipping to the token (ignoring the leading trivia) - recordSourceMapSpan(ts.skipTrivia(currentSourceFile.text, node.pos)); - } - function recordEmitNodeEndSpan(node) { - recordSourceMapSpan(node.end); - } - function writeTextWithSpanRecord(tokenKind, startPos, emitFn) { - var tokenStartPos = ts.skipTrivia(currentSourceFile.text, startPos); - recordSourceMapSpan(tokenStartPos); - var tokenEndPos = emitTokenText(tokenKind, tokenStartPos, emitFn); - recordSourceMapSpan(tokenEndPos); - return tokenEndPos; - } - function recordNewSourceFileStart(node) { - // Add the file to tsFilePaths - // If sourceroot option: Use the relative path corresponding to the common directory path - // otherwise source locations relative to map file location - var sourcesDirectoryPath = compilerOptions.sourceRoot ? host.getCommonSourceDirectory() : sourceMapDir; - sourceMapData.sourceMapSources.push(ts.getRelativePathToDirectoryOrUrl(sourcesDirectoryPath, node.fileName, host.getCurrentDirectory(), host.getCanonicalFileName, - /*isAbsolutePathAnUrl*/ true)); - sourceMapSourceIndex = sourceMapData.sourceMapSources.length - 1; - // The one that can be used from program to get the actual source file - sourceMapData.inputSourceFileNames.push(node.fileName); - if (compilerOptions.inlineSources) { - if (!sourceMapData.sourceMapSourcesContent) { - sourceMapData.sourceMapSourcesContent = []; - } - sourceMapData.sourceMapSourcesContent.push(node.text); - } - } - function recordScopeNameOfNode(node, scopeName) { - function recordScopeNameIndex(scopeNameIndex) { - sourceMapNameIndices.push(scopeNameIndex); - } - function recordScopeNameStart(scopeName) { - var scopeNameIndex = -1; - if (scopeName) { - var parentIndex = getSourceMapNameIndex(); - if (parentIndex !== -1) { - // Child scopes are always shown with a dot (even if they have no name), - // unless it is a computed property. Then it is shown with brackets, - // but the brackets are included in the name. - var name_21 = node.name; - if (!name_21 || name_21.kind !== 136 /* ComputedPropertyName */) { - scopeName = "." + scopeName; - } - scopeName = sourceMapData.sourceMapNames[parentIndex] + scopeName; - } - scopeNameIndex = ts.getProperty(sourceMapNameIndexMap, scopeName); - if (scopeNameIndex === undefined) { - scopeNameIndex = sourceMapData.sourceMapNames.length; - sourceMapData.sourceMapNames.push(scopeName); - sourceMapNameIndexMap[scopeName] = scopeNameIndex; - } - } - recordScopeNameIndex(scopeNameIndex); - } - if (scopeName) { - // The scope was already given a name use it - recordScopeNameStart(scopeName); - } - else if (node.kind === 213 /* FunctionDeclaration */ || - node.kind === 173 /* FunctionExpression */ || - node.kind === 143 /* MethodDeclaration */ || - node.kind === 142 /* MethodSignature */ || - node.kind === 145 /* GetAccessor */ || - node.kind === 146 /* SetAccessor */ || - node.kind === 218 /* ModuleDeclaration */ || - node.kind === 214 /* ClassDeclaration */ || - node.kind === 217 /* EnumDeclaration */) { - // Declaration and has associated name use it - if (node.name) { - var name_22 = node.name; - // For computed property names, the text will include the brackets - scopeName = name_22.kind === 136 /* ComputedPropertyName */ - ? ts.getTextOfNode(name_22) - : node.name.text; - } - recordScopeNameStart(scopeName); - } - else { - // Block just use the name from upper level scope - recordScopeNameIndex(getSourceMapNameIndex()); - } - } - function recordScopeNameEnd() { - sourceMapNameIndices.pop(); - } - ; - function writeCommentRangeWithMap(curentSourceFile, writer, comment, newLine) { - recordSourceMapSpan(comment.pos); - ts.writeCommentRange(currentSourceFile, writer, comment, newLine); - recordSourceMapSpan(comment.end); - } - function serializeSourceMapContents(version, file, sourceRoot, sources, names, mappings, sourcesContent) { - if (typeof JSON !== "undefined") { - var map_1 = { - version: version, - file: file, - sourceRoot: sourceRoot, - sources: sources, - names: names, - mappings: mappings - }; - if (sourcesContent !== undefined) { - map_1.sourcesContent = sourcesContent; - } - return JSON.stringify(map_1); - } - return "{\"version\":" + version + ",\"file\":\"" + ts.escapeString(file) + "\",\"sourceRoot\":\"" + ts.escapeString(sourceRoot) + "\",\"sources\":[" + serializeStringArray(sources) + "],\"names\":[" + serializeStringArray(names) + "],\"mappings\":\"" + ts.escapeString(mappings) + "\" " + (sourcesContent !== undefined ? ",\"sourcesContent\":[" + serializeStringArray(sourcesContent) + "]" : "") + "}"; - function serializeStringArray(list) { - var output = ""; - for (var i = 0, n = list.length; i < n; i++) { - if (i) { - output += ","; - } - output += "\"" + ts.escapeString(list[i]) + "\""; - } - return output; - } - } - function writeJavaScriptAndSourceMapFile(emitOutput, writeByteOrderMark) { - encodeLastRecordedSourceMapSpan(); - var sourceMapText = serializeSourceMapContents(3, sourceMapData.sourceMapFile, sourceMapData.sourceMapSourceRoot, sourceMapData.sourceMapSources, sourceMapData.sourceMapNames, sourceMapData.sourceMapMappings, sourceMapData.sourceMapSourcesContent); - sourceMapDataList.push(sourceMapData); - var sourceMapUrl; - if (compilerOptions.inlineSourceMap) { - // Encode the sourceMap into the sourceMap url - var base64SourceMapText = ts.convertToBase64(sourceMapText); - sourceMapUrl = "//# sourceMappingURL=data:application/json;base64," + base64SourceMapText; - } - else { - // Write source map file - ts.writeFile(host, diagnostics, sourceMapData.sourceMapFilePath, sourceMapText, /*writeByteOrderMark*/ false); - sourceMapUrl = "//# sourceMappingURL=" + sourceMapData.jsSourceMappingURL; - } - // Write sourcemap url to the js file and write the js file - writeJavaScriptFile(emitOutput + sourceMapUrl, writeByteOrderMark); - } - // Initialize source map data - var sourceMapJsFile = ts.getBaseFileName(ts.normalizeSlashes(jsFilePath)); - sourceMapData = { - sourceMapFilePath: jsFilePath + ".map", - jsSourceMappingURL: sourceMapJsFile + ".map", - sourceMapFile: sourceMapJsFile, - sourceMapSourceRoot: compilerOptions.sourceRoot || "", - sourceMapSources: [], - inputSourceFileNames: [], - sourceMapNames: [], - sourceMapMappings: "", - sourceMapSourcesContent: undefined, - sourceMapDecodedMappings: [] - }; - // Normalize source root and make sure it has trailing "/" so that it can be used to combine paths with the - // relative paths of the sources list in the sourcemap - sourceMapData.sourceMapSourceRoot = ts.normalizeSlashes(sourceMapData.sourceMapSourceRoot); - if (sourceMapData.sourceMapSourceRoot.length && sourceMapData.sourceMapSourceRoot.charCodeAt(sourceMapData.sourceMapSourceRoot.length - 1) !== 47 /* slash */) { - sourceMapData.sourceMapSourceRoot += ts.directorySeparator; - } - if (compilerOptions.mapRoot) { - sourceMapDir = ts.normalizeSlashes(compilerOptions.mapRoot); - if (root) { - // For modules or multiple emit files the mapRoot will have directory structure like the sources - // So if src\a.ts and src\lib\b.ts are compiled together user would be moving the maps into mapRoot\a.js.map and mapRoot\lib\b.js.map - sourceMapDir = ts.getDirectoryPath(ts.getSourceFilePathInNewDir(root, host, sourceMapDir)); - } - if (!ts.isRootedDiskPath(sourceMapDir) && !ts.isUrl(sourceMapDir)) { - // The relative paths are relative to the common directory - sourceMapDir = ts.combinePaths(host.getCommonSourceDirectory(), sourceMapDir); - sourceMapData.jsSourceMappingURL = ts.getRelativePathToDirectoryOrUrl(ts.getDirectoryPath(ts.normalizePath(jsFilePath)), // get the relative sourceMapDir path based on jsFilePath - ts.combinePaths(sourceMapDir, sourceMapData.jsSourceMappingURL), // this is where user expects to see sourceMap - host.getCurrentDirectory(), host.getCanonicalFileName, - /*isAbsolutePathAnUrl*/ true); - } - else { - sourceMapData.jsSourceMappingURL = ts.combinePaths(sourceMapDir, sourceMapData.jsSourceMappingURL); - } - } - else { - sourceMapDir = ts.getDirectoryPath(ts.normalizePath(jsFilePath)); - } - function emitNodeWithSourceMap(node) { - if (node) { - if (ts.nodeIsSynthesized(node)) { - return emitNodeWithoutSourceMap(node); - } - if (node.kind !== 248 /* SourceFile */) { - recordEmitNodeStartSpan(node); - emitNodeWithoutSourceMap(node); - recordEmitNodeEndSpan(node); - } - else { - recordNewSourceFileStart(node); - emitNodeWithoutSourceMap(node); - } - } - } - function emitNodeWithCommentsAndWithSourcemap(node) { - emitNodeConsideringCommentsOption(node, emitNodeWithSourceMap); - } - writeEmittedFiles = writeJavaScriptAndSourceMapFile; - emit = emitNodeWithCommentsAndWithSourcemap; - emitStart = recordEmitNodeStartSpan; - emitEnd = recordEmitNodeEndSpan; - emitToken = writeTextWithSpanRecord; - scopeEmitStart = recordScopeNameOfNode; - scopeEmitEnd = recordScopeNameEnd; - writeComment = writeCommentRangeWithMap; - } - function writeJavaScriptFile(emitOutput, writeByteOrderMark) { - ts.writeFile(host, diagnostics, jsFilePath, emitOutput, writeByteOrderMark); - } - // Create a temporary variable with a unique unused name. - function createTempVariable(flags) { - var result = ts.createSynthesizedNode(69 /* Identifier */); - result.text = makeTempVariableName(flags); - return result; - } - function recordTempDeclaration(name) { - if (!tempVariables) { - tempVariables = []; - } - tempVariables.push(name); - } - function createAndRecordTempVariable(flags) { - var temp = createTempVariable(flags); - recordTempDeclaration(temp); - return temp; - } - function emitTempDeclarations(newLine) { - if (tempVariables) { - if (newLine) { - writeLine(); - } - else { - write(" "); - } - write("var "); - emitCommaList(tempVariables); - write(";"); - } - } - function emitTokenText(tokenKind, startPos, emitFn) { - var tokenString = ts.tokenToString(tokenKind); - if (emitFn) { - emitFn(); - } - else { - write(tokenString); - } - return startPos + tokenString.length; - } - function emitOptional(prefix, node) { - if (node) { - write(prefix); - emit(node); - } - } - function emitParenthesizedIf(node, parenthesized) { - if (parenthesized) { - write("("); - } - emit(node); - if (parenthesized) { - write(")"); - } - } - function emitTrailingCommaIfPresent(nodeList) { - if (nodeList.hasTrailingComma) { - write(","); - } - } - function emitLinePreservingList(parent, nodes, allowTrailingComma, spacesBetweenBraces) { - ts.Debug.assert(nodes.length > 0); - increaseIndent(); - if (nodeStartPositionsAreOnSameLine(parent, nodes[0])) { - if (spacesBetweenBraces) { - write(" "); - } - } - else { - writeLine(); - } - for (var i = 0, n = nodes.length; i < n; i++) { - if (i) { - if (nodeEndIsOnSameLineAsNodeStart(nodes[i - 1], nodes[i])) { - write(", "); - } - else { - write(","); - writeLine(); - } - } - emit(nodes[i]); - } - if (nodes.hasTrailingComma && allowTrailingComma) { - write(","); - } - decreaseIndent(); - if (nodeEndPositionsAreOnSameLine(parent, ts.lastOrUndefined(nodes))) { - if (spacesBetweenBraces) { - write(" "); - } - } - else { - writeLine(); - } - } - function emitList(nodes, start, count, multiLine, trailingComma, leadingComma, noTrailingNewLine, emitNode) { - if (!emitNode) { - emitNode = emit; - } - for (var i = 0; i < count; i++) { - if (multiLine) { - if (i || leadingComma) { - write(","); - } - writeLine(); - } - else { - if (i || leadingComma) { - write(", "); - } - } - var node = nodes[start + i]; - // This emitting is to make sure we emit following comment properly - // ...(x, /*comment1*/ y)... - // ^ => node.pos - // "comment1" is not considered leading comment for "y" but rather - // considered as trailing comment of the previous node. - emitTrailingCommentsOfPosition(node.pos); - emitNode(node); - leadingComma = true; - } - if (trailingComma) { - write(","); - } - if (multiLine && !noTrailingNewLine) { - writeLine(); - } - return count; - } - function emitCommaList(nodes) { - if (nodes) { - emitList(nodes, 0, nodes.length, /*multiline*/ false, /*trailingComma*/ false); - } - } - function emitLines(nodes) { - emitLinesStartingAt(nodes, /*startIndex*/ 0); - } - function emitLinesStartingAt(nodes, startIndex) { - for (var i = startIndex; i < nodes.length; i++) { - writeLine(); - emit(nodes[i]); - } - } - function isBinaryOrOctalIntegerLiteral(node, text) { - if (node.kind === 8 /* NumericLiteral */ && text.length > 1) { - switch (text.charCodeAt(1)) { - case 98 /* b */: - case 66 /* B */: - case 111 /* o */: - case 79 /* O */: - return true; - } - } - return false; - } - function emitLiteral(node) { - var text = getLiteralText(node); - if ((compilerOptions.sourceMap || compilerOptions.inlineSourceMap) && (node.kind === 9 /* StringLiteral */ || ts.isTemplateLiteralKind(node.kind))) { - writer.writeLiteral(text); - } - else if (languageVersion < 2 /* ES6 */ && isBinaryOrOctalIntegerLiteral(node, text)) { - write(node.text); - } - else { - write(text); - } - } - function getLiteralText(node) { - // 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 */ && (ts.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 (node.parent) { - return ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, node); - } - // If we can't reach the original source text, use the canonical form if it's a number, - // or an escaped quoted form of the original text if it's string-like. - switch (node.kind) { - case 9 /* StringLiteral */: - return getQuotedEscapedLiteralText("\"", node.text, "\""); - case 11 /* NoSubstitutionTemplateLiteral */: - return getQuotedEscapedLiteralText("`", node.text, "`"); - case 12 /* TemplateHead */: - return getQuotedEscapedLiteralText("`", node.text, "${"); - case 13 /* TemplateMiddle */: - return getQuotedEscapedLiteralText("}", node.text, "${"); - case 14 /* TemplateTail */: - return getQuotedEscapedLiteralText("}", node.text, "`"); - case 8 /* NumericLiteral */: - return node.text; - } - ts.Debug.fail("Literal kind '" + node.kind + "' not accounted for."); - } - function getQuotedEscapedLiteralText(leftQuote, text, rightQuote) { - return leftQuote + ts.escapeNonAsciiCharacters(ts.escapeString(text)) + rightQuote; - } - function emitDownlevelRawTemplateLiteral(node) { - // 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"); - text = ts.escapeString(text); - write("\"" + text + "\""); - } - function emitDownlevelTaggedTemplateArray(node, literalEmitter) { - write("["); - if (node.template.kind === 11 /* NoSubstitutionTemplateLiteral */) { - literalEmitter(node.template); - } - else { - literalEmitter(node.template.head); - ts.forEach(node.template.templateSpans, function (child) { - write(", "); - literalEmitter(child.literal); - }); - } - write("]"); - } - function emitDownlevelTaggedTemplate(node) { - var tempVariable = createAndRecordTempVariable(0 /* Auto */); - write("("); - emit(tempVariable); - write(" = "); - emitDownlevelTaggedTemplateArray(node, emit); - write(", "); - emit(tempVariable); - write(".raw = "); - emitDownlevelTaggedTemplateArray(node, emitDownlevelRawTemplateLiteral); - write(", "); - emitParenthesizedIf(node.tag, needsParenthesisForPropertyAccessOrInvocation(node.tag)); - write("("); - emit(tempVariable); - // Now we emit the expressions - if (node.template.kind === 183 /* TemplateExpression */) { - ts.forEach(node.template.templateSpans, function (templateSpan) { - write(", "); - var needsParens = templateSpan.expression.kind === 181 /* BinaryExpression */ - && templateSpan.expression.operatorToken.kind === 24 /* CommaToken */; - emitParenthesizedIf(templateSpan.expression, needsParens); - }); - } - write("))"); - } - function emitTemplateExpression(node) { - // In ES6 mode and above, we can simply emit each portion of a template in order, but in - // ES3 & ES5 we must convert the template expression into a series of string concatenations. - if (languageVersion >= 2 /* ES6 */) { - ts.forEachChild(node, emit); - return; - } - var emitOuterParens = ts.isExpression(node.parent) - && templateNeedsParens(node, node.parent); - if (emitOuterParens) { - write("("); - } - var headEmitted = false; - if (shouldEmitTemplateHead()) { - emitLiteral(node.head); - headEmitted = true; - } - for (var i = 0, n = node.templateSpans.length; i < n; i++) { - var templateSpan = node.templateSpans[i]; - // Check if the expression has operands and binds its operands less closely than binary '+'. - // If it does, we need to wrap 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 needsParens = templateSpan.expression.kind !== 172 /* ParenthesizedExpression */ - && comparePrecedenceToBinaryPlus(templateSpan.expression) !== 1 /* GreaterThan */; - if (i > 0 || headEmitted) { - // If this is the first span and the head was not emitted, then this templateSpan's - // expression will be the first to be emitted. Don't emit the preceding ' + ' in that - // case. - write(" + "); - } - emitParenthesizedIf(templateSpan.expression, needsParens); - // 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 (templateSpan.literal.text.length !== 0) { - write(" + "); - emitLiteral(templateSpan.literal); - } - } - if (emitOuterParens) { - write(")"); - } - function shouldEmitTemplateHead() { - // If this expression has an empty head literal and the first template span has a non-empty - // literal, then emitting the empty head literal is not necessary. - // `${ foo } and ${ bar }` - // can be emitted as - // foo + " and " + bar - // This is because it is only required that one of the first two operands in the emit - // output must be a string literal, so that the other operand and all following operands - // are forced into strings. - // - // If the first template span has an empty literal, then the head must still be emitted. - // `${ foo }${ bar }` - // must still be emitted as - // "" + foo + bar - // 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; - } - function templateNeedsParens(template, parent) { - switch (parent.kind) { - case 168 /* CallExpression */: - case 169 /* NewExpression */: - return parent.expression === template; - case 170 /* TaggedTemplateExpression */: - case 172 /* ParenthesizedExpression */: - return false; - default: - return comparePrecedenceToBinaryPlus(parent) !== -1 /* LessThan */; - } - } - /** - * Returns whether the expression has lesser, greater, - * or equal precedence to the binary '+' operator - */ - function comparePrecedenceToBinaryPlus(expression) { - // All binary expressions have lower precedence than '+' apart from '*', '/', and '%' - // which have greater precedence and '-' which has equal precedence. - // All unary operators have a higher precedence apart from yield. - // Arrow functions and conditionals have a lower precedence, - // although we convert the former into regular function expressions in ES5 mode, - // and in ES6 mode this function won't get called anyway. - // - // TODO (drosen): Note that we need to account for the upcoming 'yield' and - // spread ('...') unary operators that are anticipated for ES6. - switch (expression.kind) { - case 181 /* BinaryExpression */: - switch (expression.operatorToken.kind) { - case 37 /* AsteriskToken */: - case 39 /* SlashToken */: - case 40 /* PercentToken */: - return 1 /* GreaterThan */; - case 35 /* PlusToken */: - case 36 /* MinusToken */: - return 0 /* EqualTo */; - default: - return -1 /* LessThan */; - } - case 184 /* YieldExpression */: - case 182 /* ConditionalExpression */: - return -1 /* LessThan */; - default: - return 1 /* GreaterThan */; - } - } - } - function emitTemplateSpan(span) { - emit(span.expression); - emit(span.literal); - } - function jsxEmitReact(node) { - /// Emit a tag name, which is either '"div"' for lower-cased names, or - /// 'Div' for upper-cased or dotted names - function emitTagName(name) { - if (name.kind === 69 /* Identifier */ && ts.isIntrinsicJsxName(name.text)) { - write("\""); - emit(name); - write("\""); - } - else { - emit(name); - } - } - /// Emit an attribute name, which is quoted if it needs to be quoted. Because - /// these emit into an object literal property name, we don't need to be worried - /// about keywords, just non-identifier characters - function emitAttributeName(name) { - if (/[A-Za-z_]+[\w*]/.test(name.text)) { - write("\""); - emit(name); - write("\""); - } - else { - emit(name); - } - } - /// Emit an name/value pair for an attribute (e.g. "x: 3") - function emitJsxAttribute(node) { - emitAttributeName(node.name); - write(": "); - if (node.initializer) { - emit(node.initializer); - } - else { - write("true"); - } - } - function emitJsxElement(openingNode, children) { - var syntheticReactRef = ts.createSynthesizedNode(69 /* Identifier */); - syntheticReactRef.text = "React"; - syntheticReactRef.parent = openingNode; - // Call React.createElement(tag, ... - emitLeadingComments(openingNode); - emitExpressionIdentifier(syntheticReactRef); - write(".createElement("); - emitTagName(openingNode.tagName); - write(", "); - // Attribute list - if (openingNode.attributes.length === 0) { - // When there are no attributes, React wants "null" - write("null"); - } - else { - // Either emit one big object literal (no spread attribs), or - // a call to React.__spread - var attrs = openingNode.attributes; - if (ts.forEach(attrs, function (attr) { return attr.kind === 239 /* JsxSpreadAttribute */; })) { - emitExpressionIdentifier(syntheticReactRef); - write(".__spread("); - var haveOpenedObjectLiteral = false; - for (var i_1 = 0; i_1 < attrs.length; i_1++) { - if (attrs[i_1].kind === 239 /* JsxSpreadAttribute */) { - // If this is the first argument, we need to emit a {} as the first argument - if (i_1 === 0) { - write("{}, "); - } - if (haveOpenedObjectLiteral) { - write("}"); - haveOpenedObjectLiteral = false; - } - if (i_1 > 0) { - write(", "); - } - emit(attrs[i_1].expression); - } - else { - ts.Debug.assert(attrs[i_1].kind === 238 /* JsxAttribute */); - if (haveOpenedObjectLiteral) { - write(", "); - } - else { - haveOpenedObjectLiteral = true; - if (i_1 > 0) { - write(", "); - } - write("{"); - } - emitJsxAttribute(attrs[i_1]); - } - } - if (haveOpenedObjectLiteral) - write("}"); - write(")"); // closing paren to React.__spread( - } - else { - // One object literal with all the attributes in them - write("{"); - for (var i = 0; i < attrs.length; i++) { - if (i > 0) { - write(", "); - } - emitJsxAttribute(attrs[i]); - } - write("}"); - } - } - // Children - if (children) { - for (var i = 0; i < children.length; i++) { - // Don't emit empty expressions - if (children[i].kind === 240 /* JsxExpression */ && !(children[i].expression)) { - continue; - } - // Don't emit empty strings - if (children[i].kind === 236 /* JsxText */) { - var text = getTextToEmit(children[i]); - if (text !== undefined) { - write(", \""); - write(text); - write("\""); - } - } - else { - write(", "); - emit(children[i]); - } - } - } - // Closing paren - write(")"); // closes "React.createElement(" - emitTrailingComments(openingNode); - } - if (node.kind === 233 /* JsxElement */) { - emitJsxElement(node.openingElement, node.children); - } - else { - ts.Debug.assert(node.kind === 234 /* JsxSelfClosingElement */); - emitJsxElement(node); - } - } - function jsxEmitPreserve(node) { - function emitJsxAttribute(node) { - emit(node.name); - if (node.initializer) { - write("="); - emit(node.initializer); - } - } - function emitJsxSpreadAttribute(node) { - write("{..."); - emit(node.expression); - write("}"); - } - function emitAttributes(attribs) { - for (var i = 0, n = attribs.length; i < n; i++) { - if (i > 0) { - write(" "); - } - if (attribs[i].kind === 239 /* JsxSpreadAttribute */) { - emitJsxSpreadAttribute(attribs[i]); - } - else { - ts.Debug.assert(attribs[i].kind === 238 /* JsxAttribute */); - emitJsxAttribute(attribs[i]); - } - } - } - function emitJsxOpeningOrSelfClosingElement(node) { - write("<"); - emit(node.tagName); - if (node.attributes.length > 0 || (node.kind === 234 /* JsxSelfClosingElement */)) { - write(" "); - } - emitAttributes(node.attributes); - if (node.kind === 234 /* JsxSelfClosingElement */) { - write("/>"); - } - else { - write(">"); - } - } - function emitJsxClosingElement(node) { - write(""); - } - function emitJsxElement(node) { - emitJsxOpeningOrSelfClosingElement(node.openingElement); - for (var i = 0, n = node.children.length; i < n; i++) { - emit(node.children[i]); - } - emitJsxClosingElement(node.closingElement); - } - if (node.kind === 233 /* JsxElement */) { - emitJsxElement(node); - } - else { - ts.Debug.assert(node.kind === 234 /* JsxSelfClosingElement */); - emitJsxOpeningOrSelfClosingElement(node); - } - } - // This function specifically handles numeric/string literals for enum and accessor 'identifiers'. - // In a sense, it does not actually emit identifiers as much as it declares a name for a specific property. - // For example, this is utilized when feeding in a result to Object.defineProperty. - function emitExpressionForPropertyName(node) { - ts.Debug.assert(node.kind !== 163 /* BindingElement */); - if (node.kind === 9 /* StringLiteral */) { - emitLiteral(node); - } - else if (node.kind === 136 /* ComputedPropertyName */) { - // if this is a decorated computed property, we will need to capture the result - // of the property expression so that we can apply decorators later. This is to ensure - // we don't introduce unintended side effects: - // - // class C { - // [_a = x]() { } - // } - // - // The emit for the decorated computed property decorator is: - // - // __decorate([dec], C.prototype, _a, Object.getOwnPropertyDescriptor(C.prototype, _a)); - // - if (ts.nodeIsDecorated(node.parent)) { - if (!computedPropertyNamesToGeneratedNames) { - computedPropertyNamesToGeneratedNames = []; - } - var generatedName = computedPropertyNamesToGeneratedNames[ts.getNodeId(node)]; - if (generatedName) { - // we have already generated a variable for this node, write that value instead. - write(generatedName); - return; - } - generatedName = createAndRecordTempVariable(0 /* Auto */).text; - computedPropertyNamesToGeneratedNames[ts.getNodeId(node)] = generatedName; - write(generatedName); - write(" = "); - } - emit(node.expression); - } - else { - write("\""); - if (node.kind === 8 /* NumericLiteral */) { - write(node.text); - } - else { - writeTextOfNode(currentSourceFile, node); - } - write("\""); - } - } - function isExpressionIdentifier(node) { - var parent = node.parent; - switch (parent.kind) { - case 164 /* ArrayLiteralExpression */: - case 189 /* AsExpression */: - case 181 /* BinaryExpression */: - case 168 /* CallExpression */: - case 241 /* CaseClause */: - case 136 /* ComputedPropertyName */: - case 182 /* ConditionalExpression */: - case 139 /* Decorator */: - case 175 /* DeleteExpression */: - case 197 /* DoStatement */: - case 167 /* ElementAccessExpression */: - case 227 /* ExportAssignment */: - case 195 /* ExpressionStatement */: - case 188 /* ExpressionWithTypeArguments */: - case 199 /* ForStatement */: - case 200 /* ForInStatement */: - case 201 /* ForOfStatement */: - case 196 /* IfStatement */: - case 234 /* JsxSelfClosingElement */: - case 235 /* JsxOpeningElement */: - case 239 /* JsxSpreadAttribute */: - case 240 /* JsxExpression */: - case 169 /* NewExpression */: - case 172 /* ParenthesizedExpression */: - case 180 /* PostfixUnaryExpression */: - case 179 /* PrefixUnaryExpression */: - case 204 /* ReturnStatement */: - case 246 /* ShorthandPropertyAssignment */: - case 185 /* SpreadElementExpression */: - case 206 /* SwitchStatement */: - case 170 /* TaggedTemplateExpression */: - case 190 /* TemplateSpan */: - case 208 /* ThrowStatement */: - case 171 /* TypeAssertionExpression */: - case 176 /* TypeOfExpression */: - case 177 /* VoidExpression */: - case 198 /* WhileStatement */: - case 205 /* WithStatement */: - case 184 /* YieldExpression */: - return true; - case 163 /* BindingElement */: - case 247 /* EnumMember */: - case 138 /* Parameter */: - case 245 /* PropertyAssignment */: - case 141 /* PropertyDeclaration */: - case 211 /* VariableDeclaration */: - return parent.initializer === node; - case 166 /* PropertyAccessExpression */: - return parent.expression === node; - case 174 /* ArrowFunction */: - case 173 /* FunctionExpression */: - return parent.body === node; - case 221 /* ImportEqualsDeclaration */: - return parent.moduleReference === node; - case 135 /* QualifiedName */: - return parent.left === node; - } - return false; - } - function emitExpressionIdentifier(node) { - if (resolver.getNodeCheckFlags(node) & 2048 /* LexicalArguments */) { - write("_arguments"); - return; - } - var container = resolver.getReferencedExportContainer(node); - if (container) { - if (container.kind === 248 /* SourceFile */) { - // Identifier references module export - if (modulekind !== 5 /* ES6 */ && modulekind !== 4 /* System */) { - write("exports."); - } - } - else { - // Identifier references namespace export - write(getGeneratedNameForNode(container)); - write("."); - } - } - else { - if (modulekind !== 5 /* ES6 */) { - var declaration = resolver.getReferencedImportDeclaration(node); - if (declaration) { - if (declaration.kind === 223 /* ImportClause */) { - // Identifier references default import - write(getGeneratedNameForNode(declaration.parent)); - write(languageVersion === 0 /* ES3 */ ? "[\"default\"]" : ".default"); - return; - } - else if (declaration.kind === 226 /* ImportSpecifier */) { - // Identifier references named import - write(getGeneratedNameForNode(declaration.parent.parent.parent)); - var name_23 = declaration.propertyName || declaration.name; - var identifier = ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, name_23); - if (languageVersion === 0 /* ES3 */ && identifier === "default") { - write("[\"default\"]"); - } - else { - write("."); - write(identifier); - } - return; - } - } - } - if (languageVersion !== 2 /* ES6 */) { - var declaration = resolver.getReferencedNestedRedeclaration(node); - if (declaration) { - write(getGeneratedNameForNode(declaration.name)); - return; - } - } - } - if (ts.nodeIsSynthesized(node)) { - write(node.text); - } - else { - writeTextOfNode(currentSourceFile, node); - } - } - function isNameOfNestedRedeclaration(node) { - if (languageVersion < 2 /* ES6 */) { - var parent_6 = node.parent; - switch (parent_6.kind) { - case 163 /* BindingElement */: - case 214 /* ClassDeclaration */: - case 217 /* EnumDeclaration */: - case 211 /* VariableDeclaration */: - return parent_6.name === node && resolver.isNestedRedeclaration(parent_6); - } - } - return false; - } - function emitIdentifier(node) { - if (!node.parent) { - write(node.text); - } - else if (isExpressionIdentifier(node)) { - emitExpressionIdentifier(node); - } - else if (isNameOfNestedRedeclaration(node)) { - write(getGeneratedNameForNode(node)); - } - else if (ts.nodeIsSynthesized(node)) { - write(node.text); - } - else { - writeTextOfNode(currentSourceFile, node); - } - } - function emitThis(node) { - if (resolver.getNodeCheckFlags(node) & 2 /* LexicalThis */) { - write("_this"); - } - else { - write("this"); - } - } - function emitSuper(node) { - if (languageVersion >= 2 /* ES6 */) { - write("super"); - } - else { - var flags = resolver.getNodeCheckFlags(node); - if (flags & 256 /* SuperInstance */) { - write("_super.prototype"); - } - else { - write("_super"); - } - } - } - function emitObjectBindingPattern(node) { - write("{ "); - var elements = node.elements; - emitList(elements, 0, elements.length, /*multiLine*/ false, /*trailingComma*/ elements.hasTrailingComma); - write(" }"); - } - function emitArrayBindingPattern(node) { - write("["); - var elements = node.elements; - emitList(elements, 0, elements.length, /*multiLine*/ false, /*trailingComma*/ elements.hasTrailingComma); - write("]"); - } - function emitBindingElement(node) { - if (node.propertyName) { - emit(node.propertyName); - write(": "); - } - if (node.dotDotDotToken) { - write("..."); - } - if (ts.isBindingPattern(node.name)) { - emit(node.name); - } - else { - emitModuleMemberName(node); - } - emitOptional(" = ", node.initializer); - } - function emitSpreadElementExpression(node) { - write("..."); - emit(node.expression); - } - function emitYieldExpression(node) { - write(ts.tokenToString(114 /* YieldKeyword */)); - if (node.asteriskToken) { - write("*"); - } - if (node.expression) { - write(" "); - emit(node.expression); - } - } - function emitAwaitExpression(node) { - var needsParenthesis = needsParenthesisForAwaitExpressionAsYield(node); - if (needsParenthesis) { - write("("); - } - write(ts.tokenToString(114 /* YieldKeyword */)); - write(" "); - emit(node.expression); - if (needsParenthesis) { - write(")"); - } - } - function needsParenthesisForAwaitExpressionAsYield(node) { - if (node.parent.kind === 181 /* BinaryExpression */ && !ts.isAssignmentOperator(node.parent.operatorToken.kind)) { - return true; - } - else if (node.parent.kind === 182 /* ConditionalExpression */ && node.parent.condition === node) { - return true; - } - return false; - } - function needsParenthesisForPropertyAccessOrInvocation(node) { - switch (node.kind) { - case 69 /* Identifier */: - case 164 /* ArrayLiteralExpression */: - case 166 /* PropertyAccessExpression */: - case 167 /* ElementAccessExpression */: - case 168 /* CallExpression */: - case 172 /* ParenthesizedExpression */: - // This list is not exhaustive and only includes those cases that are relevant - // to the check in emitArrayLiteral. More cases can be added as needed. - return false; - } - return true; - } - function emitListWithSpread(elements, needsUniqueCopy, multiLine, trailingComma, useConcat) { - var pos = 0; - var group = 0; - var length = elements.length; - while (pos < length) { - // Emit using the pattern .concat(, , ...) - if (group === 1 && useConcat) { - write(".concat("); - } - else if (group > 0) { - write(", "); - } - var e = elements[pos]; - if (e.kind === 185 /* SpreadElementExpression */) { - e = e.expression; - emitParenthesizedIf(e, /*parenthesized*/ group === 0 && needsParenthesisForPropertyAccessOrInvocation(e)); - pos++; - if (pos === length && group === 0 && needsUniqueCopy && e.kind !== 164 /* ArrayLiteralExpression */) { - write(".slice()"); - } - } - else { - var i = pos; - while (i < length && elements[i].kind !== 185 /* SpreadElementExpression */) { - i++; - } - write("["); - if (multiLine) { - increaseIndent(); - } - emitList(elements, pos, i - pos, multiLine, trailingComma && i === length); - if (multiLine) { - decreaseIndent(); - } - write("]"); - pos = i; - } - group++; - } - if (group > 1) { - if (useConcat) { - write(")"); - } - } - } - function isSpreadElementExpression(node) { - return node.kind === 185 /* SpreadElementExpression */; - } - function emitArrayLiteral(node) { - var elements = node.elements; - if (elements.length === 0) { - write("[]"); - } - else if (languageVersion >= 2 /* ES6 */ || !ts.forEach(elements, isSpreadElementExpression)) { - write("["); - emitLinePreservingList(node, node.elements, elements.hasTrailingComma, /*spacesBetweenBraces:*/ false); - write("]"); - } - else { - emitListWithSpread(elements, /*needsUniqueCopy*/ true, /*multiLine*/ (node.flags & 2048 /* MultiLine */) !== 0, - /*trailingComma*/ elements.hasTrailingComma, /*useConcat*/ true); - } - } - function emitObjectLiteralBody(node, numElements) { - if (numElements === 0) { - write("{}"); - return; - } - write("{"); - if (numElements > 0) { - var properties = node.properties; - // If we are not doing a downlevel transformation for object literals, - // then try to preserve the original shape of the object literal. - // Otherwise just try to preserve the formatting. - if (numElements === properties.length) { - emitLinePreservingList(node, properties, /* allowTrailingComma */ languageVersion >= 1 /* ES5 */, /* spacesBetweenBraces */ true); - } - else { - var multiLine = (node.flags & 2048 /* MultiLine */) !== 0; - if (!multiLine) { - write(" "); - } - else { - increaseIndent(); - } - emitList(properties, 0, numElements, /*multiLine*/ multiLine, /*trailingComma*/ false); - if (!multiLine) { - write(" "); - } - else { - decreaseIndent(); - } - } - } - write("}"); - } - function emitDownlevelObjectLiteralWithComputedProperties(node, firstComputedPropertyIndex) { - var multiLine = (node.flags & 2048 /* MultiLine */) !== 0; - var properties = node.properties; - write("("); - if (multiLine) { - increaseIndent(); - } - // 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 tempVar = createAndRecordTempVariable(0 /* Auto */); - // Write out the first non-computed properties - // (or all properties if none of them are computed), - // then emit the rest through indexing on the temp variable. - emit(tempVar); - write(" = "); - emitObjectLiteralBody(node, firstComputedPropertyIndex); - for (var i = firstComputedPropertyIndex, n = properties.length; i < n; i++) { - writeComma(); - var property = properties[i]; - emitStart(property); - if (property.kind === 145 /* GetAccessor */ || property.kind === 146 /* SetAccessor */) { - // TODO (drosen): Reconcile with 'emitMemberFunctions'. - var accessors = ts.getAllAccessorDeclarations(node.properties, property); - if (property !== accessors.firstAccessor) { - continue; - } - write("Object.defineProperty("); - emit(tempVar); - write(", "); - emitStart(node.name); - emitExpressionForPropertyName(property.name); - emitEnd(property.name); - write(", {"); - increaseIndent(); - if (accessors.getAccessor) { - writeLine(); - emitLeadingComments(accessors.getAccessor); - write("get: "); - emitStart(accessors.getAccessor); - write("function "); - emitSignatureAndBody(accessors.getAccessor); - emitEnd(accessors.getAccessor); - emitTrailingComments(accessors.getAccessor); - write(","); - } - if (accessors.setAccessor) { - writeLine(); - emitLeadingComments(accessors.setAccessor); - write("set: "); - emitStart(accessors.setAccessor); - write("function "); - emitSignatureAndBody(accessors.setAccessor); - emitEnd(accessors.setAccessor); - emitTrailingComments(accessors.setAccessor); - write(","); - } - writeLine(); - write("enumerable: true,"); - writeLine(); - write("configurable: true"); - decreaseIndent(); - writeLine(); - write("})"); - emitEnd(property); - } - else { - emitLeadingComments(property); - emitStart(property.name); - emit(tempVar); - emitMemberAccessForPropertyName(property.name); - emitEnd(property.name); - write(" = "); - if (property.kind === 245 /* PropertyAssignment */) { - emit(property.initializer); - } - else if (property.kind === 246 /* ShorthandPropertyAssignment */) { - emitExpressionIdentifier(property.name); - } - else if (property.kind === 143 /* MethodDeclaration */) { - emitFunctionDeclaration(property); - } - else { - ts.Debug.fail("ObjectLiteralElement type not accounted for: " + property.kind); - } - } - emitEnd(property); - } - writeComma(); - emit(tempVar); - if (multiLine) { - decreaseIndent(); - writeLine(); - } - write(")"); - function writeComma() { - if (multiLine) { - write(","); - writeLine(); - } - else { - write(", "); - } - } - } - function emitObjectLiteral(node) { - var properties = node.properties; - if (languageVersion < 2 /* ES6 */) { - var numProperties = properties.length; - // Find the first computed property. - // Everything until that point can be emitted as part of the initial object literal. - var numInitialNonComputedProperties = numProperties; - for (var i = 0, n = properties.length; i < n; i++) { - if (properties[i].name.kind === 136 /* ComputedPropertyName */) { - numInitialNonComputedProperties = i; - break; - } - } - var hasComputedProperty = numInitialNonComputedProperties !== properties.length; - if (hasComputedProperty) { - emitDownlevelObjectLiteralWithComputedProperties(node, numInitialNonComputedProperties); - return; - } - } - // Ordinary case: either the object has no computed properties - // or we're compiling with an ES6+ target. - emitObjectLiteralBody(node, properties.length); - } - function createBinaryExpression(left, operator, right, startsOnNewLine) { - var result = ts.createSynthesizedNode(181 /* BinaryExpression */, startsOnNewLine); - result.operatorToken = ts.createSynthesizedNode(operator); - result.left = left; - result.right = right; - return result; - } - function createPropertyAccessExpression(expression, name) { - var result = ts.createSynthesizedNode(166 /* PropertyAccessExpression */); - result.expression = parenthesizeForAccess(expression); - result.dotToken = ts.createSynthesizedNode(21 /* DotToken */); - result.name = name; - return result; - } - function createElementAccessExpression(expression, argumentExpression) { - var result = ts.createSynthesizedNode(167 /* ElementAccessExpression */); - result.expression = parenthesizeForAccess(expression); - result.argumentExpression = argumentExpression; - return result; - } - function parenthesizeForAccess(expr) { - // When diagnosing whether the expression needs parentheses, the decision should be based - // on the innermost expression in a chain of nested type assertions. - while (expr.kind === 171 /* TypeAssertionExpression */ || expr.kind === 189 /* AsExpression */) { - expr = expr.expression; - } - // isLeftHandSideExpression is almost the correct criterion for when it is not necessary - // to parenthesize the expression before a dot. The known exceptions are: - // - // NewExpression: - // new C.x -> not the same as (new C).x - // NumberLiteral - // 1.x -> not the same as (1).x - // - if (ts.isLeftHandSideExpression(expr) && - expr.kind !== 169 /* NewExpression */ && - expr.kind !== 8 /* NumericLiteral */) { - return expr; - } - var node = ts.createSynthesizedNode(172 /* ParenthesizedExpression */); - node.expression = expr; - return node; - } - function emitComputedPropertyName(node) { - write("["); - emitExpressionForPropertyName(node); - write("]"); - } - function emitMethod(node) { - if (languageVersion >= 2 /* ES6 */ && node.asteriskToken) { - write("*"); - } - emit(node.name); - if (languageVersion < 2 /* ES6 */) { - write(": function "); - } - emitSignatureAndBody(node); - } - function emitPropertyAssignment(node) { - emit(node.name); - write(": "); - // This is to ensure that we emit comment in the following case: - // For example: - // obj = { - // id: /*comment1*/ ()=>void - // } - // "comment1" is not considered to be leading comment for node.initializer - // but rather a trailing comment on the previous node. - emitTrailingCommentsOfPosition(node.initializer.pos); - emit(node.initializer); - } - // Return true if identifier resolves to an exported member of a namespace - function isNamespaceExportReference(node) { - var container = resolver.getReferencedExportContainer(node); - return container && container.kind !== 248 /* SourceFile */; - } - function emitShorthandPropertyAssignment(node) { - // The name property of a short-hand property assignment is considered an expression position, so here - // we manually emit the identifier to avoid rewriting. - writeTextOfNode(currentSourceFile, node.name); - // If emitting pre-ES6 code, or if the name requires rewriting when resolved as an expression identifier, - // we emit a normal property assignment. For example: - // module m { - // export let y; - // } - // module m { - // let obj = { y }; - // } - // Here we need to emit obj = { y : m.y } regardless of the output target. - if (languageVersion < 2 /* ES6 */ || isNamespaceExportReference(node.name)) { - // Emit identifier as an identifier - write(": "); - emit(node.name); - } - if (languageVersion >= 2 /* ES6 */ && node.objectAssignmentInitializer) { - write(" = "); - emit(node.objectAssignmentInitializer); - } - } - function tryEmitConstantValue(node) { - var constantValue = tryGetConstEnumValue(node); - if (constantValue !== undefined) { - write(constantValue.toString()); - if (!compilerOptions.removeComments) { - var propertyName = node.kind === 166 /* PropertyAccessExpression */ ? ts.declarationNameToString(node.name) : ts.getTextOfNode(node.argumentExpression); - write(" /* " + propertyName + " */"); - } - return true; - } - return false; - } - function tryGetConstEnumValue(node) { - if (compilerOptions.isolatedModules) { - return undefined; - } - return node.kind === 166 /* PropertyAccessExpression */ || node.kind === 167 /* ElementAccessExpression */ - ? resolver.getConstantValue(node) - : undefined; - } - // Returns 'true' if the code was actually indented, false otherwise. - // If the code is not indented, an optional valueToWriteWhenNotIndenting will be - // emitted instead. - function indentIfOnDifferentLines(parent, node1, node2, valueToWriteWhenNotIndenting) { - var realNodesAreOnDifferentLines = !ts.nodeIsSynthesized(parent) && !nodeEndIsOnSameLineAsNodeStart(node1, node2); - // Always use a newline for synthesized code if the synthesizer desires it. - var synthesizedNodeIsOnDifferentLine = synthesizedNodeStartsOnNewLine(node2); - if (realNodesAreOnDifferentLines || synthesizedNodeIsOnDifferentLine) { - increaseIndent(); - writeLine(); - return true; - } - else { - if (valueToWriteWhenNotIndenting) { - write(valueToWriteWhenNotIndenting); - } - return false; - } - } - function emitPropertyAccess(node) { - if (tryEmitConstantValue(node)) { - return; - } - emit(node.expression); - var indentedBeforeDot = indentIfOnDifferentLines(node, node.expression, node.dotToken); - // 1 .toString is a valid property access, emit a space after the literal - // Also emit a space if expression is a integer const enum value - it will appear in generated code as numeric literal - var shouldEmitSpace; - if (!indentedBeforeDot) { - if (node.expression.kind === 8 /* NumericLiteral */) { - // check if numeric literal was originally written with a dot - var text = ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, node.expression); - shouldEmitSpace = text.indexOf(ts.tokenToString(21 /* DotToken */)) < 0; - } - else { - // check if constant enum value is integer - var constantValue = tryGetConstEnumValue(node.expression); - // isFinite handles cases when constantValue is undefined - shouldEmitSpace = isFinite(constantValue) && Math.floor(constantValue) === constantValue; - } - } - if (shouldEmitSpace) { - write(" ."); - } - else { - write("."); - } - var indentedAfterDot = indentIfOnDifferentLines(node, node.dotToken, node.name); - emit(node.name); - decreaseIndentIf(indentedBeforeDot, indentedAfterDot); - } - function emitQualifiedName(node) { - emit(node.left); - write("."); - emit(node.right); - } - function emitQualifiedNameAsExpression(node, useFallback) { - if (node.left.kind === 69 /* Identifier */) { - emitEntityNameAsExpression(node.left, useFallback); - } - else if (useFallback) { - var temp = createAndRecordTempVariable(0 /* Auto */); - write("("); - emitNodeWithoutSourceMap(temp); - write(" = "); - emitEntityNameAsExpression(node.left, /*useFallback*/ true); - write(") && "); - emitNodeWithoutSourceMap(temp); - } - else { - emitEntityNameAsExpression(node.left, /*useFallback*/ false); - } - write("."); - emit(node.right); - } - function emitEntityNameAsExpression(node, useFallback) { - switch (node.kind) { - case 69 /* Identifier */: - if (useFallback) { - write("typeof "); - emitExpressionIdentifier(node); - write(" !== 'undefined' && "); - } - emitExpressionIdentifier(node); - break; - case 135 /* QualifiedName */: - emitQualifiedNameAsExpression(node, useFallback); - break; - } - } - function emitIndexedAccess(node) { - if (tryEmitConstantValue(node)) { - return; - } - emit(node.expression); - write("["); - emit(node.argumentExpression); - write("]"); - } - function hasSpreadElement(elements) { - return ts.forEach(elements, function (e) { return e.kind === 185 /* SpreadElementExpression */; }); - } - function skipParentheses(node) { - while (node.kind === 172 /* ParenthesizedExpression */ || node.kind === 171 /* TypeAssertionExpression */ || node.kind === 189 /* AsExpression */) { - node = node.expression; - } - return node; - } - function emitCallTarget(node) { - if (node.kind === 69 /* Identifier */ || node.kind === 97 /* ThisKeyword */ || node.kind === 95 /* SuperKeyword */) { - emit(node); - return node; - } - var temp = createAndRecordTempVariable(0 /* Auto */); - write("("); - emit(temp); - write(" = "); - emit(node); - write(")"); - return temp; - } - function emitCallWithSpread(node) { - var target; - var expr = skipParentheses(node.expression); - if (expr.kind === 166 /* PropertyAccessExpression */) { - // Target will be emitted as "this" argument - target = emitCallTarget(expr.expression); - write("."); - emit(expr.name); - } - else if (expr.kind === 167 /* ElementAccessExpression */) { - // Target will be emitted as "this" argument - target = emitCallTarget(expr.expression); - write("["); - emit(expr.argumentExpression); - write("]"); - } - else if (expr.kind === 95 /* SuperKeyword */) { - target = expr; - write("_super"); - } - else { - emit(node.expression); - } - write(".apply("); - if (target) { - if (target.kind === 95 /* SuperKeyword */) { - // Calls of form super(...) and super.foo(...) - emitThis(target); - } - else { - // Calls of form obj.foo(...) - emit(target); - } - } - else { - // Calls of form foo(...) - write("void 0"); - } - write(", "); - emitListWithSpread(node.arguments, /*needsUniqueCopy*/ false, /*multiLine*/ false, /*trailingComma*/ false, /*useConcat*/ true); - write(")"); - } - function emitCallExpression(node) { - if (languageVersion < 2 /* ES6 */ && hasSpreadElement(node.arguments)) { - emitCallWithSpread(node); - return; - } - var superCall = false; - if (node.expression.kind === 95 /* SuperKeyword */) { - emitSuper(node.expression); - superCall = true; - } - else { - emit(node.expression); - superCall = node.expression.kind === 166 /* PropertyAccessExpression */ && node.expression.expression.kind === 95 /* SuperKeyword */; - } - if (superCall && languageVersion < 2 /* ES6 */) { - write(".call("); - emitThis(node.expression); - if (node.arguments.length) { - write(", "); - emitCommaList(node.arguments); - } - write(")"); - } - else { - write("("); - emitCommaList(node.arguments); - write(")"); - } - } - function emitNewExpression(node) { - write("new "); - // Spread operator logic is supported in new expressions in ES5 using a combination - // of Function.prototype.bind() and Function.prototype.apply(). - // - // Example: - // - // var args = [1, 2, 3, 4, 5]; - // new Array(...args); - // - // is compiled into the following ES5: - // - // var args = [1, 2, 3, 4, 5]; - // new (Array.bind.apply(Array, [void 0].concat(args))); - // - // The 'thisArg' to 'bind' is ignored when invoking the result of 'bind' with 'new', - // Thus, we set it to undefined ('void 0'). - if (languageVersion === 1 /* ES5 */ && - node.arguments && - hasSpreadElement(node.arguments)) { - write("("); - var target = emitCallTarget(node.expression); - write(".bind.apply("); - emit(target); - write(", [void 0].concat("); - emitListWithSpread(node.arguments, /*needsUniqueCopy*/ false, /*multiline*/ false, /*trailingComma*/ false, /*useConcat*/ false); - write(")))"); - write("()"); - } - else { - emit(node.expression); - if (node.arguments) { - write("("); - emitCommaList(node.arguments); - write(")"); - } - } - } - function emitTaggedTemplateExpression(node) { - if (languageVersion >= 2 /* ES6 */) { - emit(node.tag); - write(" "); - emit(node.template); - } - else { - emitDownlevelTaggedTemplate(node); - } - } - function emitParenExpression(node) { - // If the node is synthesized, it means the emitter put the parentheses there, - // not the user. If we didn't want them, the emitter would not have put them - // there. - if (!ts.nodeIsSynthesized(node) && node.parent.kind !== 174 /* ArrowFunction */) { - if (node.expression.kind === 171 /* TypeAssertionExpression */ || node.expression.kind === 189 /* AsExpression */) { - var operand = node.expression.expression; - // Make sure we consider all nested cast expressions, e.g.: - // (-A).x; - while (operand.kind === 171 /* TypeAssertionExpression */ || operand.kind === 189 /* AsExpression */) { - operand = operand.expression; - } - // We have an expression of the form: (SubExpr) - // Emitting this as (SubExpr) is really not desirable. We would like to emit the subexpr as is. - // Omitting the parentheses, however, could cause change in the semantics of the generated - // code if the casted expression has a lower precedence than the rest of the expression, e.g.: - // (new A).foo should be emitted as (new A).foo and not new A.foo - // (typeof A).toString() should be emitted as (typeof A).toString() and not typeof A.toString() - // new (A()) should be emitted as new (A()) and not new A() - // (function foo() { })() should be emitted as an IIF (function foo(){})() and not declaration function foo(){} () - if (operand.kind !== 179 /* PrefixUnaryExpression */ && - operand.kind !== 177 /* VoidExpression */ && - operand.kind !== 176 /* TypeOfExpression */ && - operand.kind !== 175 /* DeleteExpression */ && - operand.kind !== 180 /* PostfixUnaryExpression */ && - operand.kind !== 169 /* NewExpression */ && - !(operand.kind === 168 /* CallExpression */ && node.parent.kind === 169 /* NewExpression */) && - !(operand.kind === 173 /* FunctionExpression */ && node.parent.kind === 168 /* CallExpression */) && - !(operand.kind === 8 /* NumericLiteral */ && node.parent.kind === 166 /* PropertyAccessExpression */)) { - emit(operand); - return; - } - } - } - write("("); - emit(node.expression); - write(")"); - } - function emitDeleteExpression(node) { - write(ts.tokenToString(78 /* DeleteKeyword */)); - write(" "); - emit(node.expression); - } - function emitVoidExpression(node) { - write(ts.tokenToString(103 /* VoidKeyword */)); - write(" "); - emit(node.expression); - } - function emitTypeOfExpression(node) { - write(ts.tokenToString(101 /* TypeOfKeyword */)); - write(" "); - emit(node.expression); - } - function isNameOfExportedSourceLevelDeclarationInSystemExternalModule(node) { - if (!isCurrentFileSystemExternalModule() || node.kind !== 69 /* Identifier */ || ts.nodeIsSynthesized(node)) { - return false; - } - var isVariableDeclarationOrBindingElement = node.parent && (node.parent.kind === 211 /* VariableDeclaration */ || node.parent.kind === 163 /* BindingElement */); - var targetDeclaration = isVariableDeclarationOrBindingElement - ? node.parent - : resolver.getReferencedValueDeclaration(node); - return isSourceFileLevelDeclarationInSystemJsModule(targetDeclaration, /*isExported*/ true); - } - function emitPrefixUnaryExpression(node) { - var exportChanged = isNameOfExportedSourceLevelDeclarationInSystemExternalModule(node.operand); - if (exportChanged) { - // emit - // ++x - // as - // exports('x', ++x) - write(exportFunctionForFile + "(\""); - emitNodeWithoutSourceMap(node.operand); - write("\", "); - } - write(ts.tokenToString(node.operator)); - // In some cases, we need to emit a space between the operator and the operand. One obvious case - // is when the operator is an identifier, like delete or typeof. We also need to do this for plus - // and minus expressions in certain cases. Specifically, consider the following two cases (parens - // are just for clarity of exposition, and not part of the source code): - // - // (+(+1)) - // (+(++1)) - // - // We need to emit a space in both cases. In the first case, the absence of a space will make - // the resulting expression a prefix increment operation. And in the second, it will make the resulting - // expression a prefix increment whose operand is a plus expression - (++(+x)) - // The same is true of minus of course. - if (node.operand.kind === 179 /* PrefixUnaryExpression */) { - var operand = node.operand; - if (node.operator === 35 /* PlusToken */ && (operand.operator === 35 /* PlusToken */ || operand.operator === 41 /* PlusPlusToken */)) { - write(" "); - } - else if (node.operator === 36 /* MinusToken */ && (operand.operator === 36 /* MinusToken */ || operand.operator === 42 /* MinusMinusToken */)) { - write(" "); - } - } - emit(node.operand); - if (exportChanged) { - write(")"); - } - } - function emitPostfixUnaryExpression(node) { - var exportChanged = isNameOfExportedSourceLevelDeclarationInSystemExternalModule(node.operand); - if (exportChanged) { - // 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)' - write("(" + exportFunctionForFile + "(\""); - emitNodeWithoutSourceMap(node.operand); - write("\", "); - write(ts.tokenToString(node.operator)); - emit(node.operand); - if (node.operator === 41 /* PlusPlusToken */) { - write(") - 1)"); - } - else { - write(") + 1)"); - } - } - else { - emit(node.operand); - write(ts.tokenToString(node.operator)); - } - } - function shouldHoistDeclarationInSystemJsModule(node) { - return isSourceFileLevelDeclarationInSystemJsModule(node, /*isExported*/ false); - } - /* - * Checks if given node is a source file level declaration (not nested in module/function). - * If 'isExported' is true - then declaration must also be exported. - * This function is used in two cases: - * - check if node is a exported source file level value to determine - * if we should also export the value after its it changed - * - check if node is a source level declaration to emit it differently, - * i.e non-exported variable statement 'var x = 1' is hoisted so - * we we emit variable statement 'var' should be dropped. - */ - function isSourceFileLevelDeclarationInSystemJsModule(node, isExported) { - if (!node || !isCurrentFileSystemExternalModule()) { - return false; - } - var current = node; - while (current) { - if (current.kind === 248 /* SourceFile */) { - return !isExported || ((ts.getCombinedNodeFlags(node) & 1 /* Export */) !== 0); - } - else if (ts.isFunctionLike(current) || current.kind === 219 /* ModuleBlock */) { - return false; - } - else { - current = current.parent; - } - } - } - /** - * Emit ES7 exponentiation operator downlevel using Math.pow - * @param node a binary expression node containing exponentiationOperator (**, **=) - */ - function emitExponentiationOperator(node) { - var leftHandSideExpression = node.left; - if (node.operatorToken.kind === 60 /* AsteriskAsteriskEqualsToken */) { - var synthesizedLHS; - var shouldEmitParentheses = false; - if (ts.isElementAccessExpression(leftHandSideExpression)) { - shouldEmitParentheses = true; - write("("); - synthesizedLHS = ts.createSynthesizedNode(167 /* ElementAccessExpression */, /*startsOnNewLine*/ false); - var identifier = emitTempVariableAssignment(leftHandSideExpression.expression, /*canDefinedTempVariablesInPlaces*/ false, /*shouldEmitCommaBeforeAssignment*/ false); - synthesizedLHS.expression = identifier; - if (leftHandSideExpression.argumentExpression.kind !== 8 /* NumericLiteral */ && - leftHandSideExpression.argumentExpression.kind !== 9 /* StringLiteral */) { - var tempArgumentExpression = createAndRecordTempVariable(268435456 /* _i */); - synthesizedLHS.argumentExpression = tempArgumentExpression; - emitAssignment(tempArgumentExpression, leftHandSideExpression.argumentExpression, /*shouldEmitCommaBeforeAssignment*/ true); - } - else { - synthesizedLHS.argumentExpression = leftHandSideExpression.argumentExpression; - } - write(", "); - } - else if (ts.isPropertyAccessExpression(leftHandSideExpression)) { - shouldEmitParentheses = true; - write("("); - synthesizedLHS = ts.createSynthesizedNode(166 /* PropertyAccessExpression */, /*startsOnNewLine*/ false); - var identifier = emitTempVariableAssignment(leftHandSideExpression.expression, /*canDefinedTempVariablesInPlaces*/ false, /*shouldemitCommaBeforeAssignment*/ false); - synthesizedLHS.expression = identifier; - synthesizedLHS.dotToken = leftHandSideExpression.dotToken; - synthesizedLHS.name = leftHandSideExpression.name; - write(", "); - } - emit(synthesizedLHS || leftHandSideExpression); - write(" = "); - write("Math.pow("); - emit(synthesizedLHS || leftHandSideExpression); - write(", "); - emit(node.right); - write(")"); - if (shouldEmitParentheses) { - write(")"); - } - } - else { - write("Math.pow("); - emit(leftHandSideExpression); - write(", "); - emit(node.right); - write(")"); - } - } - function emitBinaryExpression(node) { - if (languageVersion < 2 /* ES6 */ && node.operatorToken.kind === 56 /* EqualsToken */ && - (node.left.kind === 165 /* ObjectLiteralExpression */ || node.left.kind === 164 /* ArrayLiteralExpression */)) { - emitDestructuring(node, node.parent.kind === 195 /* ExpressionStatement */); - } - else { - var exportChanged = node.operatorToken.kind >= 56 /* FirstAssignment */ && - node.operatorToken.kind <= 68 /* LastAssignment */ && - isNameOfExportedSourceLevelDeclarationInSystemExternalModule(node.left); - if (exportChanged) { - // emit assignment 'x y' as 'exports("x", x y)' - write(exportFunctionForFile + "(\""); - emitNodeWithoutSourceMap(node.left); - write("\", "); - } - if (node.operatorToken.kind === 38 /* AsteriskAsteriskToken */ || node.operatorToken.kind === 60 /* AsteriskAsteriskEqualsToken */) { - // Downleveled emit exponentiation operator using Math.pow - emitExponentiationOperator(node); - } - else { - emit(node.left); - // Add indentation before emit the operator if the operator is on different line - // For example: - // 3 - // + 2; - // emitted as - // 3 - // + 2; - var indentedBeforeOperator = indentIfOnDifferentLines(node, node.left, node.operatorToken, node.operatorToken.kind !== 24 /* CommaToken */ ? " " : undefined); - write(ts.tokenToString(node.operatorToken.kind)); - var indentedAfterOperator = indentIfOnDifferentLines(node, node.operatorToken, node.right, " "); - emit(node.right); - decreaseIndentIf(indentedBeforeOperator, indentedAfterOperator); - } - if (exportChanged) { - write(")"); - } - } - } - function synthesizedNodeStartsOnNewLine(node) { - return ts.nodeIsSynthesized(node) && node.startsOnNewLine; - } - function emitConditionalExpression(node) { - emit(node.condition); - var indentedBeforeQuestion = indentIfOnDifferentLines(node, node.condition, node.questionToken, " "); - write("?"); - var indentedAfterQuestion = indentIfOnDifferentLines(node, node.questionToken, node.whenTrue, " "); - emit(node.whenTrue); - decreaseIndentIf(indentedBeforeQuestion, indentedAfterQuestion); - var indentedBeforeColon = indentIfOnDifferentLines(node, node.whenTrue, node.colonToken, " "); - write(":"); - var indentedAfterColon = indentIfOnDifferentLines(node, node.colonToken, node.whenFalse, " "); - emit(node.whenFalse); - decreaseIndentIf(indentedBeforeColon, indentedAfterColon); - } - // Helper function to decrease the indent if we previously indented. Allows multiple - // previous indent values to be considered at a time. This also allows caller to just - // call this once, passing in all their appropriate indent values, instead of needing - // to call this helper function multiple times. - function decreaseIndentIf(value1, value2) { - if (value1) { - decreaseIndent(); - } - if (value2) { - decreaseIndent(); - } - } - function isSingleLineEmptyBlock(node) { - if (node && node.kind === 192 /* Block */) { - var block = node; - return block.statements.length === 0 && nodeEndIsOnSameLineAsNodeStart(block, block); - } - } - function emitBlock(node) { - if (isSingleLineEmptyBlock(node)) { - emitToken(15 /* OpenBraceToken */, node.pos); - write(" "); - emitToken(16 /* CloseBraceToken */, node.statements.end); - return; - } - emitToken(15 /* OpenBraceToken */, node.pos); - increaseIndent(); - scopeEmitStart(node.parent); - if (node.kind === 219 /* ModuleBlock */) { - ts.Debug.assert(node.parent.kind === 218 /* ModuleDeclaration */); - emitCaptureThisForNodeIfNecessary(node.parent); - } - emitLines(node.statements); - if (node.kind === 219 /* ModuleBlock */) { - emitTempDeclarations(/*newLine*/ true); - } - decreaseIndent(); - writeLine(); - emitToken(16 /* CloseBraceToken */, node.statements.end); - scopeEmitEnd(); - } - function emitEmbeddedStatement(node) { - if (node.kind === 192 /* Block */) { - write(" "); - emit(node); - } - else { - increaseIndent(); - writeLine(); - emit(node); - decreaseIndent(); - } - } - function emitExpressionStatement(node) { - emitParenthesizedIf(node.expression, /*parenthesized*/ node.expression.kind === 174 /* ArrowFunction */); - write(";"); - } - function emitIfStatement(node) { - var endPos = emitToken(88 /* IfKeyword */, node.pos); - write(" "); - endPos = emitToken(17 /* OpenParenToken */, endPos); - emit(node.expression); - emitToken(18 /* CloseParenToken */, node.expression.end); - emitEmbeddedStatement(node.thenStatement); - if (node.elseStatement) { - writeLine(); - emitToken(80 /* ElseKeyword */, node.thenStatement.end); - if (node.elseStatement.kind === 196 /* IfStatement */) { - write(" "); - emit(node.elseStatement); - } - else { - emitEmbeddedStatement(node.elseStatement); - } - } - } - function emitDoStatement(node) { - write("do"); - emitEmbeddedStatement(node.statement); - if (node.statement.kind === 192 /* Block */) { - write(" "); - } - else { - writeLine(); - } - write("while ("); - emit(node.expression); - write(");"); - } - function emitWhileStatement(node) { - write("while ("); - emit(node.expression); - write(")"); - emitEmbeddedStatement(node.statement); - } - /** - * Returns true if start of variable declaration list was emitted. - * Returns false if nothing was written - this can happen for source file level variable declarations - * in system modules where such variable declarations are hoisted. - */ - function tryEmitStartOfVariableDeclarationList(decl, startPos) { - if (shouldHoistVariable(decl, /*checkIfSourceFileLevelDecl*/ true)) { - // variables in variable declaration list were already hoisted - return false; - } - var tokenKind = 102 /* VarKeyword */; - if (decl && languageVersion >= 2 /* ES6 */) { - if (ts.isLet(decl)) { - tokenKind = 108 /* LetKeyword */; - } - else if (ts.isConst(decl)) { - tokenKind = 74 /* ConstKeyword */; - } - } - if (startPos !== undefined) { - emitToken(tokenKind, startPos); - write(" "); - } - else { - switch (tokenKind) { - case 102 /* VarKeyword */: - write("var "); - break; - case 108 /* LetKeyword */: - write("let "); - break; - case 74 /* ConstKeyword */: - write("const "); - break; - } - } - return true; - } - function emitVariableDeclarationListSkippingUninitializedEntries(list) { - var started = false; - for (var _a = 0, _b = list.declarations; _a < _b.length; _a++) { - var decl = _b[_a]; - if (!decl.initializer) { - continue; - } - if (!started) { - started = true; - } - else { - write(", "); - } - emit(decl); - } - return started; - } - function emitForStatement(node) { - var endPos = emitToken(86 /* ForKeyword */, node.pos); - write(" "); - endPos = emitToken(17 /* OpenParenToken */, endPos); - if (node.initializer && node.initializer.kind === 212 /* VariableDeclarationList */) { - var variableDeclarationList = node.initializer; - var startIsEmitted = tryEmitStartOfVariableDeclarationList(variableDeclarationList, endPos); - if (startIsEmitted) { - emitCommaList(variableDeclarationList.declarations); - } - else { - emitVariableDeclarationListSkippingUninitializedEntries(variableDeclarationList); - } - } - else if (node.initializer) { - emit(node.initializer); - } - write(";"); - emitOptional(" ", node.condition); - write(";"); - emitOptional(" ", node.incrementor); - write(")"); - emitEmbeddedStatement(node.statement); - } - function emitForInOrForOfStatement(node) { - if (languageVersion < 2 /* ES6 */ && node.kind === 201 /* ForOfStatement */) { - return emitDownLevelForOfStatement(node); - } - var endPos = emitToken(86 /* ForKeyword */, node.pos); - write(" "); - endPos = emitToken(17 /* OpenParenToken */, endPos); - if (node.initializer.kind === 212 /* VariableDeclarationList */) { - var variableDeclarationList = node.initializer; - if (variableDeclarationList.declarations.length >= 1) { - tryEmitStartOfVariableDeclarationList(variableDeclarationList, endPos); - emit(variableDeclarationList.declarations[0]); - } - } - else { - emit(node.initializer); - } - if (node.kind === 200 /* ForInStatement */) { - write(" in "); - } - else { - write(" of "); - } - emit(node.expression); - emitToken(18 /* CloseParenToken */, node.expression.end); - emitEmbeddedStatement(node.statement); - } - function emitDownLevelForOfStatement(node) { - // The following ES6 code: - // - // for (let v of expr) { } - // - // should be emitted as - // - // for (let _i = 0, _a = expr; _i < _a.length; _i++) { - // let v = _a[_i]; - // } - // - // where _a and _i are temps emitted to capture the RHS and the counter, - // respectively. - // When the left hand side is an expression instead of a let declaration, - // the "let v" is not emitted. - // When the left hand side is a let/const, the v is renamed if there is - // another v in scope. - // Note that all assignments to the LHS are emitted in the body, including - // all destructuring. - // Note also that because an extra statement is needed to assign to the LHS, - // for-of bodies are always emitted as blocks. - var endPos = emitToken(86 /* ForKeyword */, node.pos); - write(" "); - endPos = emitToken(17 /* OpenParenToken */, endPos); - // Do not emit the LHS let declaration yet, because it might contain destructuring. - // Do not call recordTempDeclaration because we are declaring the temps - // right here. Recording means they will be declared later. - // 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 rhsIsIdentifier = node.expression.kind === 69 /* Identifier */; - var counter = createTempVariable(268435456 /* _i */); - var rhsReference = rhsIsIdentifier ? node.expression : createTempVariable(0 /* Auto */); - // This is the let keyword for the counter and rhsReference. The let keyword for - // the LHS will be emitted inside the body. - emitStart(node.expression); - write("var "); - // _i = 0 - emitNodeWithoutSourceMap(counter); - write(" = 0"); - emitEnd(node.expression); - if (!rhsIsIdentifier) { - // , _a = expr - write(", "); - emitStart(node.expression); - emitNodeWithoutSourceMap(rhsReference); - write(" = "); - emitNodeWithoutSourceMap(node.expression); - emitEnd(node.expression); - } - write("; "); - // _i < _a.length; - emitStart(node.initializer); - emitNodeWithoutSourceMap(counter); - write(" < "); - emitNodeWithCommentsAndWithoutSourcemap(rhsReference); - write(".length"); - emitEnd(node.initializer); - write("; "); - // _i++) - emitStart(node.initializer); - emitNodeWithoutSourceMap(counter); - write("++"); - emitEnd(node.initializer); - emitToken(18 /* CloseParenToken */, node.expression.end); - // Body - write(" {"); - writeLine(); - increaseIndent(); - // Initialize LHS - // let v = _a[_i]; - var rhsIterationValue = createElementAccessExpression(rhsReference, counter); - emitStart(node.initializer); - if (node.initializer.kind === 212 /* VariableDeclarationList */) { - write("var "); - var variableDeclarationList = node.initializer; - if (variableDeclarationList.declarations.length > 0) { - var declaration = variableDeclarationList.declarations[0]; - if (ts.isBindingPattern(declaration.name)) { - // This works whether the declaration is a var, let, or const. - // It will use rhsIterationValue _a[_i] as the initializer. - emitDestructuring(declaration, /*isAssignmentExpressionStatement*/ false, rhsIterationValue); - } - else { - // The following call does not include the initializer, so we have - // to emit it separately. - emitNodeWithCommentsAndWithoutSourcemap(declaration); - write(" = "); - emitNodeWithoutSourceMap(rhsIterationValue); - } - } - else { - // It's an empty declaration list. This can only happen in an error case, if the user wrote - // for (let of []) {} - emitNodeWithoutSourceMap(createTempVariable(0 /* Auto */)); - write(" = "); - emitNodeWithoutSourceMap(rhsIterationValue); - } - } - else { - // Initializer is an expression. Emit the expression in the body, so that it's - // evaluated on every iteration. - var assignmentExpression = createBinaryExpression(node.initializer, 56 /* EqualsToken */, rhsIterationValue, /*startsOnNewLine*/ false); - if (node.initializer.kind === 164 /* ArrayLiteralExpression */ || node.initializer.kind === 165 /* ObjectLiteralExpression */) { - // This is a destructuring pattern, so call emitDestructuring instead of emit. Calling emit will not work, because it will cause - // the BinaryExpression to be passed in instead of the expression statement, which will cause emitDestructuring to crash. - emitDestructuring(assignmentExpression, /*isAssignmentExpressionStatement*/ true, /*value*/ undefined); - } - else { - emitNodeWithCommentsAndWithoutSourcemap(assignmentExpression); - } - } - emitEnd(node.initializer); - write(";"); - if (node.statement.kind === 192 /* Block */) { - emitLines(node.statement.statements); - } - else { - writeLine(); - emit(node.statement); - } - writeLine(); - decreaseIndent(); - write("}"); - } - function emitBreakOrContinueStatement(node) { - emitToken(node.kind === 203 /* BreakStatement */ ? 70 /* BreakKeyword */ : 75 /* ContinueKeyword */, node.pos); - emitOptional(" ", node.label); - write(";"); - } - function emitReturnStatement(node) { - emitToken(94 /* ReturnKeyword */, node.pos); - emitOptional(" ", node.expression); - write(";"); - } - function emitWithStatement(node) { - write("with ("); - emit(node.expression); - write(")"); - emitEmbeddedStatement(node.statement); - } - function emitSwitchStatement(node) { - var endPos = emitToken(96 /* SwitchKeyword */, node.pos); - write(" "); - emitToken(17 /* OpenParenToken */, endPos); - emit(node.expression); - endPos = emitToken(18 /* CloseParenToken */, node.expression.end); - write(" "); - emitCaseBlock(node.caseBlock, endPos); - } - function emitCaseBlock(node, startPos) { - emitToken(15 /* OpenBraceToken */, startPos); - increaseIndent(); - emitLines(node.clauses); - decreaseIndent(); - writeLine(); - emitToken(16 /* CloseBraceToken */, node.clauses.end); - } - function nodeStartPositionsAreOnSameLine(node1, node2) { - return ts.getLineOfLocalPosition(currentSourceFile, ts.skipTrivia(currentSourceFile.text, node1.pos)) === - ts.getLineOfLocalPosition(currentSourceFile, ts.skipTrivia(currentSourceFile.text, node2.pos)); - } - function nodeEndPositionsAreOnSameLine(node1, node2) { - return ts.getLineOfLocalPosition(currentSourceFile, node1.end) === - ts.getLineOfLocalPosition(currentSourceFile, node2.end); - } - function nodeEndIsOnSameLineAsNodeStart(node1, node2) { - return ts.getLineOfLocalPosition(currentSourceFile, node1.end) === - ts.getLineOfLocalPosition(currentSourceFile, ts.skipTrivia(currentSourceFile.text, node2.pos)); - } - function emitCaseOrDefaultClause(node) { - if (node.kind === 241 /* CaseClause */) { - write("case "); - emit(node.expression); - write(":"); - } - else { - write("default:"); - } - if (node.statements.length === 1 && nodeStartPositionsAreOnSameLine(node, node.statements[0])) { - write(" "); - emit(node.statements[0]); - } - else { - increaseIndent(); - emitLines(node.statements); - decreaseIndent(); - } - } - function emitThrowStatement(node) { - write("throw "); - emit(node.expression); - write(";"); - } - function emitTryStatement(node) { - write("try "); - emit(node.tryBlock); - emit(node.catchClause); - if (node.finallyBlock) { - writeLine(); - write("finally "); - emit(node.finallyBlock); - } - } - function emitCatchClause(node) { - writeLine(); - var endPos = emitToken(72 /* CatchKeyword */, node.pos); - write(" "); - emitToken(17 /* OpenParenToken */, endPos); - emit(node.variableDeclaration); - emitToken(18 /* CloseParenToken */, node.variableDeclaration ? node.variableDeclaration.end : endPos); - write(" "); - emitBlock(node.block); - } - function emitDebuggerStatement(node) { - emitToken(76 /* DebuggerKeyword */, node.pos); - write(";"); - } - function emitLabelledStatement(node) { - emit(node.label); - write(": "); - emit(node.statement); - } - function getContainingModule(node) { - do { - node = node.parent; - } while (node && node.kind !== 218 /* ModuleDeclaration */); - return node; - } - function emitContainingModuleName(node) { - var container = getContainingModule(node); - write(container ? getGeneratedNameForNode(container) : "exports"); - } - function emitModuleMemberName(node) { - emitStart(node.name); - if (ts.getCombinedNodeFlags(node) & 1 /* Export */) { - var container = getContainingModule(node); - if (container) { - write(getGeneratedNameForNode(container)); - write("."); - } - else if (modulekind !== 5 /* ES6 */ && modulekind !== 4 /* System */) { - write("exports."); - } - } - emitNodeWithCommentsAndWithoutSourcemap(node.name); - emitEnd(node.name); - } - function createVoidZero() { - var zero = ts.createSynthesizedNode(8 /* NumericLiteral */); - zero.text = "0"; - var result = ts.createSynthesizedNode(177 /* VoidExpression */); - result.expression = zero; - return result; - } - function emitEs6ExportDefaultCompat(node) { - if (node.parent.kind === 248 /* SourceFile */) { - ts.Debug.assert(!!(node.flags & 1024 /* Default */) || node.kind === 227 /* ExportAssignment */); - // only allow export default at a source file level - if (modulekind === 1 /* CommonJS */ || modulekind === 2 /* AMD */ || modulekind === 3 /* UMD */) { - if (!currentSourceFile.symbol.exports["___esModule"]) { - if (languageVersion === 1 /* ES5 */) { - // default value of configurable, enumerable, writable are `false`. - write("Object.defineProperty(exports, \"__esModule\", { value: true });"); - writeLine(); - } - else if (languageVersion === 0 /* ES3 */) { - write("exports.__esModule = true;"); - writeLine(); - } - } - } - } - } - function emitExportMemberAssignment(node) { - if (node.flags & 1 /* Export */) { - writeLine(); - emitStart(node); - // emit call to exporter only for top level nodes - if (modulekind === 4 /* System */ && node.parent === currentSourceFile) { - // emit export default as - // export("default", ) - write(exportFunctionForFile + "(\""); - if (node.flags & 1024 /* Default */) { - write("default"); - } - else { - emitNodeWithCommentsAndWithoutSourcemap(node.name); - } - write("\", "); - emitDeclarationName(node); - write(")"); - } - else { - if (node.flags & 1024 /* Default */) { - emitEs6ExportDefaultCompat(node); - if (languageVersion === 0 /* ES3 */) { - write("exports[\"default\"]"); - } - else { - write("exports.default"); - } - } - else { - emitModuleMemberName(node); - } - write(" = "); - emitDeclarationName(node); - } - emitEnd(node); - write(";"); - } - } - function emitExportMemberAssignments(name) { - if (modulekind === 4 /* System */) { - return; - } - if (!exportEquals && exportSpecifiers && ts.hasProperty(exportSpecifiers, name.text)) { - for (var _a = 0, _b = exportSpecifiers[name.text]; _a < _b.length; _a++) { - var specifier = _b[_a]; - writeLine(); - emitStart(specifier.name); - emitContainingModuleName(specifier); - write("."); - emitNodeWithCommentsAndWithoutSourcemap(specifier.name); - emitEnd(specifier.name); - write(" = "); - emitExpressionIdentifier(name); - write(";"); - } - } - } - function emitExportSpecifierInSystemModule(specifier) { - ts.Debug.assert(modulekind === 4 /* System */); - if (!resolver.getReferencedValueDeclaration(specifier.propertyName || specifier.name) && !resolver.isValueAliasDeclaration(specifier)) { - return; - } - writeLine(); - emitStart(specifier.name); - write(exportFunctionForFile + "(\""); - emitNodeWithCommentsAndWithoutSourcemap(specifier.name); - write("\", "); - emitExpressionIdentifier(specifier.propertyName || specifier.name); - write(")"); - emitEnd(specifier.name); - write(";"); - } - /** - * Emit an assignment to a given identifier, 'name', with a given expression, 'value'. - * @param name an identifier as a left-hand-side operand of the assignment - * @param value an expression as a right-hand-side operand of the assignment - * @param shouldEmitCommaBeforeAssignment a boolean indicating whether to prefix an assignment with comma - */ - function emitAssignment(name, value, shouldEmitCommaBeforeAssignment) { - if (shouldEmitCommaBeforeAssignment) { - write(", "); - } - var exportChanged = isNameOfExportedSourceLevelDeclarationInSystemExternalModule(name); - if (exportChanged) { - write(exportFunctionForFile + "(\""); - emitNodeWithCommentsAndWithoutSourcemap(name); - write("\", "); - } - var isVariableDeclarationOrBindingElement = name.parent && (name.parent.kind === 211 /* VariableDeclaration */ || name.parent.kind === 163 /* BindingElement */); - if (isVariableDeclarationOrBindingElement) { - emitModuleMemberName(name.parent); - } - else { - emit(name); - } - write(" = "); - emit(value); - if (exportChanged) { - write(")"); - } - } - /** - * Create temporary variable, emit an assignment of the variable the given expression - * @param expression an expression to assign to the newly created temporary variable - * @param canDefineTempVariablesInPlace a boolean indicating whether you can define the temporary variable at an assignment location - * @param shouldEmitCommaBeforeAssignment a boolean indicating whether an assignment should prefix with comma - */ - function emitTempVariableAssignment(expression, canDefineTempVariablesInPlace, shouldEmitCommaBeforeAssignment) { - var identifier = createTempVariable(0 /* Auto */); - if (!canDefineTempVariablesInPlace) { - recordTempDeclaration(identifier); - } - emitAssignment(identifier, expression, shouldEmitCommaBeforeAssignment); - return identifier; - } - function emitDestructuring(root, isAssignmentExpressionStatement, value) { - var emitCount = 0; - // An exported declaration is actually emitted as an assignment (to a property on the module object), so - // temporary variables in an exported declaration need to have real declarations elsewhere - // Also temporary variables should be explicitly allocated for source level declarations when module target is system - // because actual variable declarations are hoisted - var canDefineTempVariablesInPlace = false; - if (root.kind === 211 /* VariableDeclaration */) { - var isExported = ts.getCombinedNodeFlags(root) & 1 /* Export */; - var isSourceLevelForSystemModuleKind = shouldHoistDeclarationInSystemJsModule(root); - canDefineTempVariablesInPlace = !isExported && !isSourceLevelForSystemModuleKind; - } - else if (root.kind === 138 /* Parameter */) { - canDefineTempVariablesInPlace = true; - } - if (root.kind === 181 /* BinaryExpression */) { - emitAssignmentExpression(root); - } - else { - ts.Debug.assert(!isAssignmentExpressionStatement); - emitBindingElement(root, value); - } - /** - * Ensures that there exists a declared identifier whose value holds the given expression. - * This function is useful to ensure that the expression's value can be read from in subsequent expressions. - * Unless 'reuseIdentifierExpressions' is false, 'expr' will be returned if it is just an identifier. - * - * @param expr the expression whose value needs to be bound. - * @param reuseIdentifierExpressions true if identifier expressions can simply be returned; - * false if it is necessary to always emit an identifier. - */ - function ensureIdentifier(expr, reuseIdentifierExpressions) { - if (expr.kind === 69 /* Identifier */ && reuseIdentifierExpressions) { - return expr; - } - var identifier = emitTempVariableAssignment(expr, canDefineTempVariablesInPlace, emitCount > 0); - emitCount++; - return identifier; - } - function createDefaultValueCheck(value, defaultValue) { - // The value expression will be evaluated twice, so for anything but a simple identifier - // we need to generate a temporary variable - value = ensureIdentifier(value, /*reuseIdentifierExpressions*/ true); - // Return the expression 'value === void 0 ? defaultValue : value' - var equals = ts.createSynthesizedNode(181 /* BinaryExpression */); - equals.left = value; - equals.operatorToken = ts.createSynthesizedNode(32 /* EqualsEqualsEqualsToken */); - equals.right = createVoidZero(); - return createConditionalExpression(equals, defaultValue, value); - } - function createConditionalExpression(condition, whenTrue, whenFalse) { - var cond = ts.createSynthesizedNode(182 /* ConditionalExpression */); - cond.condition = condition; - cond.questionToken = ts.createSynthesizedNode(53 /* QuestionToken */); - cond.whenTrue = whenTrue; - cond.colonToken = ts.createSynthesizedNode(54 /* ColonToken */); - cond.whenFalse = whenFalse; - return cond; - } - function createNumericLiteral(value) { - var node = ts.createSynthesizedNode(8 /* NumericLiteral */); - node.text = "" + value; - return node; - } - function createPropertyAccessForDestructuringProperty(object, propName) { - // We create a synthetic copy of the identifier in order to avoid the rewriting that might - // otherwise occur when the identifier is emitted. - var syntheticName = ts.createSynthesizedNode(propName.kind); - syntheticName.text = propName.text; - if (syntheticName.kind !== 69 /* Identifier */) { - return createElementAccessExpression(object, syntheticName); - } - return createPropertyAccessExpression(object, syntheticName); - } - function createSliceCall(value, sliceIndex) { - var call = ts.createSynthesizedNode(168 /* CallExpression */); - var sliceIdentifier = ts.createSynthesizedNode(69 /* Identifier */); - sliceIdentifier.text = "slice"; - call.expression = createPropertyAccessExpression(value, sliceIdentifier); - call.arguments = ts.createSynthesizedNodeArray(); - call.arguments[0] = createNumericLiteral(sliceIndex); - return call; - } - function emitObjectLiteralAssignment(target, value) { - var properties = target.properties; - if (properties.length !== 1) { - // For anything but a single element destructuring we need to generate a temporary - // to ensure value is evaluated exactly once. - value = ensureIdentifier(value, /*reuseIdentifierExpressions*/ true); - } - for (var _a = 0; _a < properties.length; _a++) { - var p = properties[_a]; - if (p.kind === 245 /* PropertyAssignment */ || p.kind === 246 /* ShorthandPropertyAssignment */) { - var propName = p.name; - var target_1 = p.kind === 246 /* ShorthandPropertyAssignment */ ? p : p.initializer || propName; - emitDestructuringAssignment(target_1, createPropertyAccessForDestructuringProperty(value, propName)); - } - } - } - function emitArrayLiteralAssignment(target, value) { - var elements = target.elements; - if (elements.length !== 1) { - // For anything but a single element destructuring we need to generate a temporary - // to ensure value is evaluated exactly once. - value = ensureIdentifier(value, /*reuseIdentifierExpressions*/ true); - } - for (var i = 0; i < elements.length; i++) { - var e = elements[i]; - if (e.kind !== 187 /* OmittedExpression */) { - if (e.kind !== 185 /* SpreadElementExpression */) { - emitDestructuringAssignment(e, createElementAccessExpression(value, createNumericLiteral(i))); - } - else if (i === elements.length - 1) { - emitDestructuringAssignment(e.expression, createSliceCall(value, i)); - } - } - } - } - function emitDestructuringAssignment(target, value) { - if (target.kind === 246 /* ShorthandPropertyAssignment */) { - if (target.objectAssignmentInitializer) { - value = createDefaultValueCheck(value, target.objectAssignmentInitializer); - } - target = target.name; - } - else if (target.kind === 181 /* BinaryExpression */ && target.operatorToken.kind === 56 /* EqualsToken */) { - value = createDefaultValueCheck(value, target.right); - target = target.left; - } - if (target.kind === 165 /* ObjectLiteralExpression */) { - emitObjectLiteralAssignment(target, value); - } - else if (target.kind === 164 /* ArrayLiteralExpression */) { - emitArrayLiteralAssignment(target, value); - } - else { - emitAssignment(target, value, /*shouldEmitCommaBeforeAssignment*/ emitCount > 0); - emitCount++; - } - } - function emitAssignmentExpression(root) { - var target = root.left; - var value = root.right; - if (ts.isEmptyObjectLiteralOrArrayLiteral(target)) { - emit(value); - } - else if (isAssignmentExpressionStatement) { - emitDestructuringAssignment(target, value); - } - else { - if (root.parent.kind !== 172 /* ParenthesizedExpression */) { - write("("); - } - value = ensureIdentifier(value, /*reuseIdentifierExpressions*/ true); - emitDestructuringAssignment(target, value); - write(", "); - emit(value); - if (root.parent.kind !== 172 /* ParenthesizedExpression */) { - write(")"); - } - } - } - function emitBindingElement(target, value) { - if (target.initializer) { - // Combine value and initializer - value = value ? createDefaultValueCheck(value, target.initializer) : target.initializer; - } - else if (!value) { - // Use 'void 0' in absence of value and initializer - value = createVoidZero(); - } - if (ts.isBindingPattern(target.name)) { - var pattern = target.name; - var elements = pattern.elements; - var numElements = elements.length; - if (numElements !== 1) { - // For anything other than a single-element destructuring we need to generate a temporary - // to ensure value is evaluated exactly once. Additionally, if we have zero elements - // we need to emit *something* to ensure that in case a 'var' keyword was already emitted, - // so in that case, we'll intentionally create that temporary. - value = ensureIdentifier(value, /*reuseIdentifierExpressions*/ numElements !== 0); - } - for (var i = 0; i < numElements; i++) { - var element = elements[i]; - if (pattern.kind === 161 /* ObjectBindingPattern */) { - // Rewrite element to a declaration with an initializer that fetches property - var propName = element.propertyName || element.name; - emitBindingElement(element, createPropertyAccessForDestructuringProperty(value, propName)); - } - else if (element.kind !== 187 /* OmittedExpression */) { - if (!element.dotDotDotToken) { - // Rewrite element to a declaration that accesses array element at index i - emitBindingElement(element, createElementAccessExpression(value, createNumericLiteral(i))); - } - else if (i === numElements - 1) { - emitBindingElement(element, createSliceCall(value, i)); - } - } - } - } - else { - emitAssignment(target.name, value, /*shouldEmitCommaBeforeAssignment*/ emitCount > 0); - emitCount++; - } - } - } - function emitVariableDeclaration(node) { - if (ts.isBindingPattern(node.name)) { - if (languageVersion < 2 /* ES6 */) { - emitDestructuring(node, /*isAssignmentExpressionStatement*/ false); - } - else { - emit(node.name); - emitOptional(" = ", node.initializer); - } - } - else { - var initializer = node.initializer; - if (!initializer && languageVersion < 2 /* ES6 */) { - // downlevel emit for non-initialized let bindings defined in loops - // for (...) { let x; } - // should be - // for (...) { var = void 0; } - // this is necessary to preserve ES6 semantic in scenarios like - // for (...) { let x; console.log(x); x = 1 } // assignment on one iteration should not affect other iterations - var isUninitializedLet = (resolver.getNodeCheckFlags(node) & 16384 /* BlockScopedBindingInLoop */) && - (getCombinedFlagsForIdentifier(node.name) & 16384 /* Let */); - // NOTE: default initialization should not be added to let bindings in for-in\for-of statements - if (isUninitializedLet && - node.parent.parent.kind !== 200 /* ForInStatement */ && - node.parent.parent.kind !== 201 /* ForOfStatement */) { - initializer = createVoidZero(); - } - } - var exportChanged = isNameOfExportedSourceLevelDeclarationInSystemExternalModule(node.name); - if (exportChanged) { - write(exportFunctionForFile + "(\""); - emitNodeWithCommentsAndWithoutSourcemap(node.name); - write("\", "); - } - emitModuleMemberName(node); - emitOptional(" = ", initializer); - if (exportChanged) { - write(")"); - } - } - } - function emitExportVariableAssignments(node) { - if (node.kind === 187 /* OmittedExpression */) { - return; - } - var name = node.name; - if (name.kind === 69 /* Identifier */) { - emitExportMemberAssignments(name); - } - else if (ts.isBindingPattern(name)) { - ts.forEach(name.elements, emitExportVariableAssignments); - } - } - function getCombinedFlagsForIdentifier(node) { - if (!node.parent || (node.parent.kind !== 211 /* VariableDeclaration */ && node.parent.kind !== 163 /* BindingElement */)) { - return 0; - } - return ts.getCombinedNodeFlags(node.parent); - } - function isES6ExportedDeclaration(node) { - return !!(node.flags & 1 /* Export */) && - modulekind === 5 /* ES6 */ && - node.parent.kind === 248 /* SourceFile */; - } - function emitVariableStatement(node) { - var startIsEmitted = false; - if (node.flags & 1 /* Export */) { - if (isES6ExportedDeclaration(node)) { - // Exported ES6 module member - write("export "); - startIsEmitted = tryEmitStartOfVariableDeclarationList(node.declarationList); - } - } - else { - startIsEmitted = tryEmitStartOfVariableDeclarationList(node.declarationList); - } - if (startIsEmitted) { - emitCommaList(node.declarationList.declarations); - write(";"); - } - else { - var atLeastOneItem = emitVariableDeclarationListSkippingUninitializedEntries(node.declarationList); - if (atLeastOneItem) { - write(";"); - } - } - if (modulekind !== 5 /* ES6 */ && node.parent === currentSourceFile) { - ts.forEach(node.declarationList.declarations, emitExportVariableAssignments); - } - } - function shouldEmitLeadingAndTrailingCommentsForVariableStatement(node) { - // If we're not exporting the variables, there's nothing special here. - // Always emit comments for these nodes. - if (!(node.flags & 1 /* Export */)) { - return true; - } - // If we are exporting, but it's a top-level ES6 module exports, - // we'll emit the declaration list verbatim, so emit comments too. - if (isES6ExportedDeclaration(node)) { - return true; - } - // Otherwise, only emit if we have at least one initializer present. - for (var _a = 0, _b = node.declarationList.declarations; _a < _b.length; _a++) { - var declaration = _b[_a]; - if (declaration.initializer) { - return true; - } - } - return false; - } - function emitParameter(node) { - if (languageVersion < 2 /* ES6 */) { - if (ts.isBindingPattern(node.name)) { - var name_24 = createTempVariable(0 /* Auto */); - if (!tempParameters) { - tempParameters = []; - } - tempParameters.push(name_24); - emit(name_24); - } - else { - emit(node.name); - } - } - else { - if (node.dotDotDotToken) { - write("..."); - } - emit(node.name); - emitOptional(" = ", node.initializer); - } - } - function emitDefaultValueAssignments(node) { - if (languageVersion < 2 /* ES6 */) { - var tempIndex = 0; - ts.forEach(node.parameters, function (parameter) { - // A rest parameter cannot have a binding pattern or an initializer, - // so let's just ignore it. - if (parameter.dotDotDotToken) { - return; - } - var paramName = parameter.name, initializer = parameter.initializer; - if (ts.isBindingPattern(paramName)) { - // 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. - var hasBindingElements = paramName.elements.length > 0; - if (hasBindingElements || initializer) { - writeLine(); - write("var "); - if (hasBindingElements) { - emitDestructuring(parameter, /*isAssignmentExpressionStatement*/ false, tempParameters[tempIndex]); - } - else { - emit(tempParameters[tempIndex]); - write(" = "); - emit(initializer); - } - write(";"); - tempIndex++; - } - } - else if (initializer) { - writeLine(); - emitStart(parameter); - write("if ("); - emitNodeWithoutSourceMap(paramName); - write(" === void 0)"); - emitEnd(parameter); - write(" { "); - emitStart(parameter); - emitNodeWithCommentsAndWithoutSourcemap(paramName); - write(" = "); - emitNodeWithCommentsAndWithoutSourcemap(initializer); - emitEnd(parameter); - write("; }"); - } - }); - } - } - function emitRestParameter(node) { - if (languageVersion < 2 /* ES6 */ && ts.hasRestParameter(node)) { - var restIndex = node.parameters.length - 1; - var restParam = node.parameters[restIndex]; - // A rest parameter cannot have a binding pattern, so let's just ignore it if it does. - if (ts.isBindingPattern(restParam.name)) { - return; - } - var tempName = createTempVariable(268435456 /* _i */).text; - writeLine(); - emitLeadingComments(restParam); - emitStart(restParam); - write("var "); - emitNodeWithCommentsAndWithoutSourcemap(restParam.name); - write(" = [];"); - emitEnd(restParam); - emitTrailingComments(restParam); - writeLine(); - write("for ("); - emitStart(restParam); - write("var " + tempName + " = " + restIndex + ";"); - emitEnd(restParam); - write(" "); - emitStart(restParam); - write(tempName + " < arguments.length;"); - emitEnd(restParam); - write(" "); - emitStart(restParam); - write(tempName + "++"); - emitEnd(restParam); - write(") {"); - increaseIndent(); - writeLine(); - emitStart(restParam); - emitNodeWithCommentsAndWithoutSourcemap(restParam.name); - write("[" + tempName + " - " + restIndex + "] = arguments[" + tempName + "];"); - emitEnd(restParam); - decreaseIndent(); - writeLine(); - write("}"); - } - } - function emitAccessor(node) { - write(node.kind === 145 /* GetAccessor */ ? "get " : "set "); - emit(node.name); - emitSignatureAndBody(node); - } - function shouldEmitAsArrowFunction(node) { - return node.kind === 174 /* ArrowFunction */ && languageVersion >= 2 /* ES6 */; - } - function emitDeclarationName(node) { - if (node.name) { - emitNodeWithCommentsAndWithoutSourcemap(node.name); - } - else { - write(getGeneratedNameForNode(node)); - } - } - function shouldEmitFunctionName(node) { - if (node.kind === 173 /* FunctionExpression */) { - // Emit name if one is present - return !!node.name; - } - if (node.kind === 213 /* FunctionDeclaration */) { - // Emit name if one is present, or emit generated name in down-level case (for export default case) - return !!node.name || languageVersion < 2 /* ES6 */; - } - } - function emitFunctionDeclaration(node) { - if (ts.nodeIsMissing(node.body)) { - return emitCommentsOnNotEmittedNode(node); - } - // TODO (yuisu) : we should not have special cases to condition emitting comments - // but have one place to fix check for these conditions. - if (node.kind !== 143 /* MethodDeclaration */ && node.kind !== 142 /* MethodSignature */ && - node.parent && node.parent.kind !== 245 /* PropertyAssignment */ && - node.parent.kind !== 168 /* CallExpression */) { - // 1. Methods will emit the comments as part of emitting method declaration - // 2. If the function is a property of object literal, emitting leading-comments - // is done by emitNodeWithoutSourceMap which then call this function. - // In particular, we would like to avoid emit comments twice in following case: - // For example: - // var obj = { - // id: - // /*comment*/ () => void - // } - // 3. If the function is an argument in call expression, emitting of comments will be - // taken care of in emit list of arguments inside of emitCallexpression - emitLeadingComments(node); - } - emitStart(node); - // For targeting below es6, emit functions-like declaration including arrow function using function keyword. - // When targeting ES6, emit arrow function natively in ES6 by omitting function keyword and using fat arrow instead - if (!shouldEmitAsArrowFunction(node)) { - if (isES6ExportedDeclaration(node)) { - write("export "); - if (node.flags & 1024 /* Default */) { - write("default "); - } - } - write("function"); - if (languageVersion >= 2 /* ES6 */ && node.asteriskToken) { - write("*"); - } - write(" "); - } - if (shouldEmitFunctionName(node)) { - emitDeclarationName(node); - } - emitSignatureAndBody(node); - if (modulekind !== 5 /* ES6 */ && node.kind === 213 /* FunctionDeclaration */ && node.parent === currentSourceFile && node.name) { - emitExportMemberAssignments(node.name); - } - emitEnd(node); - if (node.kind !== 143 /* MethodDeclaration */ && node.kind !== 142 /* MethodSignature */) { - emitTrailingComments(node); - } - } - function emitCaptureThisForNodeIfNecessary(node) { - if (resolver.getNodeCheckFlags(node) & 4 /* CaptureThis */) { - writeLine(); - emitStart(node); - write("var _this = this;"); - emitEnd(node); - } - } - function emitSignatureParameters(node) { - increaseIndent(); - write("("); - if (node) { - var parameters = node.parameters; - var omitCount = languageVersion < 2 /* ES6 */ && ts.hasRestParameter(node) ? 1 : 0; - emitList(parameters, 0, parameters.length - omitCount, /*multiLine*/ false, /*trailingComma*/ false); - } - write(")"); - decreaseIndent(); - } - function emitSignatureParametersForArrow(node) { - // Check whether the parameter list needs parentheses and preserve no-parenthesis - if (node.parameters.length === 1 && node.pos === node.parameters[0].pos) { - emit(node.parameters[0]); - return; - } - emitSignatureParameters(node); - } - function emitAsyncFunctionBodyForES6(node) { - var promiseConstructor = ts.getEntityNameFromTypeNode(node.type); - var isArrowFunction = node.kind === 174 /* ArrowFunction */; - var hasLexicalArguments = (resolver.getNodeCheckFlags(node) & 4096 /* CaptureArguments */) !== 0; - var args; - // 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. - // - // The emit for an async arrow without a lexical `arguments` binding might be: - // - // // input - // let a = async (b) => { await b; } - // - // // output - // let a = (b) => __awaiter(this, void 0, void 0, function* () { - // yield b; - // }); - // - // The emit for an async arrow with a lexical `arguments` binding might be: - // - // // input - // let a = async (b) => { await arguments[0]; } - // - // // output - // let a = (b) => __awaiter(this, arguments, void 0, function* (arguments) { - // yield arguments[0]; - // }); - // - // The emit for an async function expression without a lexical `arguments` binding - // might be: - // - // // input - // let a = async function (b) { - // await b; - // } - // - // // output - // let a = function (b) { - // return __awaiter(this, void 0, void 0, function* () { - // yield b; - // }); - // } - // - // The emit for an async function expression with a lexical `arguments` binding - // might be: - // - // // input - // let a = async function (b) { - // await arguments[0]; - // } - // - // // output - // let a = function (b) { - // return __awaiter(this, arguments, void 0, function* (_arguments) { - // yield _arguments[0]; - // }); - // } - // - // The emit for an async function expression with a lexical `arguments` binding - // and a return type annotation might be: - // - // // input - // let a = async function (b): MyPromise { - // await arguments[0]; - // } - // - // // output - // let a = function (b) { - // return __awaiter(this, arguments, MyPromise, function* (_arguments) { - // yield _arguments[0]; - // }); - // } - // - // If this is not an async arrow, emit the opening brace of the function body - // and the start of the return statement. - if (!isArrowFunction) { - write(" {"); - increaseIndent(); - writeLine(); - write("return"); - } - write(" __awaiter(this"); - if (hasLexicalArguments) { - write(", arguments"); - } - else { - write(", void 0"); - } - if (promiseConstructor) { - write(", "); - emitNodeWithoutSourceMap(promiseConstructor); - } - else { - write(", Promise"); - } - // Emit the call to __awaiter. - if (hasLexicalArguments) { - write(", function* (_arguments)"); - } - else { - write(", function* ()"); - } - // Emit the signature and body for the inner generator function. - emitFunctionBody(node); - write(")"); - // If this is not an async arrow, emit the closing brace of the outer function body. - if (!isArrowFunction) { - write(";"); - decreaseIndent(); - writeLine(); - write("}"); - } - } - function emitFunctionBody(node) { - if (!node.body) { - // There can be no body when there are parse errors. Just emit an empty block - // in that case. - write(" { }"); - } - else { - if (node.body.kind === 192 /* Block */) { - emitBlockFunctionBody(node, node.body); - } - else { - emitExpressionFunctionBody(node, node.body); - } - } - } - function emitSignatureAndBody(node) { - var saveTempFlags = tempFlags; - var saveTempVariables = tempVariables; - var saveTempParameters = tempParameters; - tempFlags = 0; - tempVariables = undefined; - tempParameters = undefined; - // When targeting ES6, emit arrow function natively in ES6 - if (shouldEmitAsArrowFunction(node)) { - emitSignatureParametersForArrow(node); - write(" =>"); - } - else { - emitSignatureParameters(node); - } - var isAsync = ts.isAsyncFunctionLike(node); - if (isAsync && languageVersion === 2 /* ES6 */) { - emitAsyncFunctionBodyForES6(node); - } - else { - emitFunctionBody(node); - } - if (!isES6ExportedDeclaration(node)) { - emitExportMemberAssignment(node); - } - tempFlags = saveTempFlags; - tempVariables = saveTempVariables; - tempParameters = saveTempParameters; - } - // Returns true if any preamble code was emitted. - function emitFunctionBodyPreamble(node) { - emitCaptureThisForNodeIfNecessary(node); - emitDefaultValueAssignments(node); - emitRestParameter(node); - } - function emitExpressionFunctionBody(node, body) { - if (languageVersion < 2 /* ES6 */ || node.flags & 512 /* Async */) { - emitDownLevelExpressionFunctionBody(node, body); - return; - } - // For es6 and higher we can emit the expression as is. However, in the case - // where the expression might end up looking like a block when emitted, we'll - // also wrap it in parentheses first. For example if you have: a => {} - // then we need to generate: a => ({}) - write(" "); - // Unwrap all type assertions. - var current = body; - while (current.kind === 171 /* TypeAssertionExpression */) { - current = current.expression; - } - emitParenthesizedIf(body, current.kind === 165 /* ObjectLiteralExpression */); - } - function emitDownLevelExpressionFunctionBody(node, body) { - write(" {"); - scopeEmitStart(node); - increaseIndent(); - var outPos = writer.getTextPos(); - emitDetachedComments(node.body); - emitFunctionBodyPreamble(node); - var preambleEmitted = writer.getTextPos() !== outPos; - decreaseIndent(); - // If we didn't have to emit any preamble code, then attempt to keep the arrow - // function on one line. - if (!preambleEmitted && nodeStartPositionsAreOnSameLine(node, body)) { - write(" "); - emitStart(body); - write("return "); - emit(body); - emitEnd(body); - write(";"); - emitTempDeclarations(/*newLine*/ false); - write(" "); - } - else { - increaseIndent(); - writeLine(); - emitLeadingComments(node.body); - write("return "); - emit(body); - write(";"); - emitTrailingComments(node.body); - emitTempDeclarations(/*newLine*/ true); - decreaseIndent(); - writeLine(); - } - emitStart(node.body); - write("}"); - emitEnd(node.body); - scopeEmitEnd(); - } - function emitBlockFunctionBody(node, body) { - write(" {"); - scopeEmitStart(node); - var initialTextPos = writer.getTextPos(); - increaseIndent(); - emitDetachedComments(body.statements); - // Emit all the directive prologues (like "use strict"). These have to come before - // any other preamble code we write (like parameter initializers). - var startIndex = emitDirectivePrologues(body.statements, /*startWithNewLine*/ true); - emitFunctionBodyPreamble(node); - decreaseIndent(); - var preambleEmitted = writer.getTextPos() !== initialTextPos; - if (!preambleEmitted && nodeEndIsOnSameLineAsNodeStart(body, body)) { - for (var _a = 0, _b = body.statements; _a < _b.length; _a++) { - var statement = _b[_a]; - write(" "); - emit(statement); - } - emitTempDeclarations(/*newLine*/ false); - write(" "); - emitLeadingCommentsOfPosition(body.statements.end); - } - else { - increaseIndent(); - emitLinesStartingAt(body.statements, startIndex); - emitTempDeclarations(/*newLine*/ true); - writeLine(); - emitLeadingCommentsOfPosition(body.statements.end); - decreaseIndent(); - } - emitToken(16 /* CloseBraceToken */, body.statements.end); - scopeEmitEnd(); - } - function findInitialSuperCall(ctor) { - if (ctor.body) { - var statement = ctor.body.statements[0]; - if (statement && statement.kind === 195 /* ExpressionStatement */) { - var expr = statement.expression; - if (expr && expr.kind === 168 /* CallExpression */) { - var func = expr.expression; - if (func && func.kind === 95 /* SuperKeyword */) { - return statement; - } - } - } - } - } - function emitParameterPropertyAssignments(node) { - ts.forEach(node.parameters, function (param) { - if (param.flags & 112 /* AccessibilityModifier */) { - writeLine(); - emitStart(param); - emitStart(param.name); - write("this."); - emitNodeWithoutSourceMap(param.name); - emitEnd(param.name); - write(" = "); - emit(param.name); - write(";"); - emitEnd(param); - } - }); - } - function emitMemberAccessForPropertyName(memberName) { - // This does not emit source map because it is emitted by caller as caller - // is aware how the property name changes to the property access - // eg. public x = 10; becomes this.x and static x = 10 becomes className.x - if (memberName.kind === 9 /* StringLiteral */ || memberName.kind === 8 /* NumericLiteral */) { - write("["); - emitNodeWithCommentsAndWithoutSourcemap(memberName); - write("]"); - } - else if (memberName.kind === 136 /* ComputedPropertyName */) { - emitComputedPropertyName(memberName); - } - else { - write("."); - emitNodeWithCommentsAndWithoutSourcemap(memberName); - } - } - function getInitializedProperties(node, isStatic) { - var properties = []; - for (var _a = 0, _b = node.members; _a < _b.length; _a++) { - var member = _b[_a]; - if (member.kind === 141 /* PropertyDeclaration */ && isStatic === ((member.flags & 128 /* Static */) !== 0) && member.initializer) { - properties.push(member); - } - } - return properties; - } - function emitPropertyDeclarations(node, properties) { - for (var _a = 0; _a < properties.length; _a++) { - var property = properties[_a]; - emitPropertyDeclaration(node, property); - } - } - function emitPropertyDeclaration(node, property, receiver, isExpression) { - writeLine(); - emitLeadingComments(property); - emitStart(property); - emitStart(property.name); - if (receiver) { - emit(receiver); - } - else { - if (property.flags & 128 /* Static */) { - emitDeclarationName(node); - } - else { - write("this"); - } - } - emitMemberAccessForPropertyName(property.name); - emitEnd(property.name); - write(" = "); - emit(property.initializer); - if (!isExpression) { - write(";"); - } - emitEnd(property); - emitTrailingComments(property); - } - function emitMemberFunctionsForES5AndLower(node) { - ts.forEach(node.members, function (member) { - if (member.kind === 191 /* SemicolonClassElement */) { - writeLine(); - write(";"); - } - else if (member.kind === 143 /* MethodDeclaration */ || node.kind === 142 /* MethodSignature */) { - if (!member.body) { - return emitCommentsOnNotEmittedNode(member); - } - writeLine(); - emitLeadingComments(member); - emitStart(member); - emitStart(member.name); - emitClassMemberPrefix(node, member); - emitMemberAccessForPropertyName(member.name); - emitEnd(member.name); - write(" = "); - emitFunctionDeclaration(member); - emitEnd(member); - write(";"); - emitTrailingComments(member); - } - else if (member.kind === 145 /* GetAccessor */ || member.kind === 146 /* SetAccessor */) { - var accessors = ts.getAllAccessorDeclarations(node.members, member); - if (member === accessors.firstAccessor) { - writeLine(); - emitStart(member); - write("Object.defineProperty("); - emitStart(member.name); - emitClassMemberPrefix(node, member); - write(", "); - emitExpressionForPropertyName(member.name); - emitEnd(member.name); - write(", {"); - increaseIndent(); - if (accessors.getAccessor) { - writeLine(); - emitLeadingComments(accessors.getAccessor); - write("get: "); - emitStart(accessors.getAccessor); - write("function "); - emitSignatureAndBody(accessors.getAccessor); - emitEnd(accessors.getAccessor); - emitTrailingComments(accessors.getAccessor); - write(","); - } - if (accessors.setAccessor) { - writeLine(); - emitLeadingComments(accessors.setAccessor); - write("set: "); - emitStart(accessors.setAccessor); - write("function "); - emitSignatureAndBody(accessors.setAccessor); - emitEnd(accessors.setAccessor); - emitTrailingComments(accessors.setAccessor); - write(","); - } - writeLine(); - write("enumerable: true,"); - writeLine(); - write("configurable: true"); - decreaseIndent(); - writeLine(); - write("});"); - emitEnd(member); - } - } - }); - } - function emitMemberFunctionsForES6AndHigher(node) { - for (var _a = 0, _b = node.members; _a < _b.length; _a++) { - var member = _b[_a]; - if ((member.kind === 143 /* MethodDeclaration */ || node.kind === 142 /* MethodSignature */) && !member.body) { - emitCommentsOnNotEmittedNode(member); - } - else if (member.kind === 143 /* MethodDeclaration */ || - member.kind === 145 /* GetAccessor */ || - member.kind === 146 /* SetAccessor */) { - writeLine(); - emitLeadingComments(member); - emitStart(member); - if (member.flags & 128 /* Static */) { - write("static "); - } - if (member.kind === 145 /* GetAccessor */) { - write("get "); - } - else if (member.kind === 146 /* SetAccessor */) { - write("set "); - } - if (member.asteriskToken) { - write("*"); - } - emit(member.name); - emitSignatureAndBody(member); - emitEnd(member); - emitTrailingComments(member); - } - else if (member.kind === 191 /* SemicolonClassElement */) { - writeLine(); - write(";"); - } - } - } - function emitConstructor(node, baseTypeElement) { - var saveTempFlags = tempFlags; - var saveTempVariables = tempVariables; - var saveTempParameters = tempParameters; - tempFlags = 0; - tempVariables = undefined; - tempParameters = undefined; - emitConstructorWorker(node, baseTypeElement); - tempFlags = saveTempFlags; - tempVariables = saveTempVariables; - tempParameters = saveTempParameters; - } - function emitConstructorWorker(node, baseTypeElement) { - // Check if we have property assignment inside class declaration. - // If there is property assignment, we need to emit constructor whether users define it or not - // If there is no property assignment, we can omit constructor if users do not define it - var hasInstancePropertyWithInitializer = false; - // Emit the constructor overload pinned comments - ts.forEach(node.members, function (member) { - if (member.kind === 144 /* Constructor */ && !member.body) { - emitCommentsOnNotEmittedNode(member); - } - // Check if there is any non-static property assignment - if (member.kind === 141 /* PropertyDeclaration */ && member.initializer && (member.flags & 128 /* Static */) === 0) { - hasInstancePropertyWithInitializer = true; - } - }); - var ctor = ts.getFirstConstructorWithBody(node); - // For target ES6 and above, if there is no user-defined constructor and there is no property assignment - // do not emit constructor in class declaration. - if (languageVersion >= 2 /* ES6 */ && !ctor && !hasInstancePropertyWithInitializer) { - return; - } - if (ctor) { - emitLeadingComments(ctor); - } - emitStart(ctor || node); - if (languageVersion < 2 /* ES6 */) { - write("function "); - emitDeclarationName(node); - emitSignatureParameters(ctor); - } - else { - write("constructor"); - if (ctor) { - emitSignatureParameters(ctor); - } - else { - // Based on EcmaScript6 section 14.5.14: Runtime Semantics: ClassDefinitionEvaluation. - // If constructor is empty, then, - // If ClassHeritageopt is present, then - // Let constructor be the result of parsing the String "constructor(... args){ super (...args);}" using the syntactic grammar with the goal symbol MethodDefinition. - // Else, - // Let constructor be the result of parsing the String "constructor( ){ }" using the syntactic grammar with the goal symbol MethodDefinition - if (baseTypeElement) { - write("(...args)"); - } - else { - write("()"); - } - } - } - var startIndex = 0; - write(" {"); - scopeEmitStart(node, "constructor"); - increaseIndent(); - if (ctor) { - // Emit all the directive prologues (like "use strict"). These have to come before - // any other preamble code we write (like parameter initializers). - startIndex = emitDirectivePrologues(ctor.body.statements, /*startWithNewLine*/ true); - emitDetachedComments(ctor.body.statements); - } - emitCaptureThisForNodeIfNecessary(node); - var superCall; - if (ctor) { - emitDefaultValueAssignments(ctor); - emitRestParameter(ctor); - if (baseTypeElement) { - superCall = findInitialSuperCall(ctor); - if (superCall) { - writeLine(); - emit(superCall); - } - } - emitParameterPropertyAssignments(ctor); - } - else { - if (baseTypeElement) { - writeLine(); - emitStart(baseTypeElement); - if (languageVersion < 2 /* ES6 */) { - write("_super.apply(this, arguments);"); - } - else { - write("super(...args);"); - } - emitEnd(baseTypeElement); - } - } - emitPropertyDeclarations(node, getInitializedProperties(node, /*static:*/ false)); - if (ctor) { - var statements = ctor.body.statements; - if (superCall) { - statements = statements.slice(1); - } - emitLinesStartingAt(statements, startIndex); - } - emitTempDeclarations(/*newLine*/ true); - writeLine(); - if (ctor) { - emitLeadingCommentsOfPosition(ctor.body.statements.end); - } - decreaseIndent(); - emitToken(16 /* CloseBraceToken */, ctor ? ctor.body.statements.end : node.members.end); - scopeEmitEnd(); - emitEnd(ctor || node); - if (ctor) { - emitTrailingComments(ctor); - } - } - function emitClassExpression(node) { - return emitClassLikeDeclaration(node); - } - function emitClassDeclaration(node) { - return emitClassLikeDeclaration(node); - } - function emitClassLikeDeclaration(node) { - if (languageVersion < 2 /* ES6 */) { - emitClassLikeDeclarationBelowES6(node); - } - else { - emitClassLikeDeclarationForES6AndHigher(node); - } - if (modulekind !== 5 /* ES6 */ && node.parent === currentSourceFile && node.name) { - emitExportMemberAssignments(node.name); - } - } - function emitClassLikeDeclarationForES6AndHigher(node) { - var thisNodeIsDecorated = ts.nodeIsDecorated(node); - if (node.kind === 214 /* ClassDeclaration */) { - if (thisNodeIsDecorated) { - // To preserve the correct runtime semantics when decorators are applied to the class, - // the emit needs to follow one of the following rules: - // - // * For a local class declaration: - // - // @dec class C { - // } - // - // The emit should be: - // - // let C = class { - // }; - // C = __decorate([dec], C); - // - // * For an exported class declaration: - // - // @dec export class C { - // } - // - // The emit should be: - // - // export let C = class { - // }; - // C = __decorate([dec], C); - // - // * For a default export of a class declaration with a name: - // - // @dec default export class C { - // } - // - // The emit should be: - // - // let C = class { - // } - // C = __decorate([dec], C); - // export default C; - // - // * For a default export of a class declaration without a name: - // - // @dec default export class { - // } - // - // The emit should be: - // - // let _default = class { - // } - // _default = __decorate([dec], _default); - // export default _default; - // - if (isES6ExportedDeclaration(node) && !(node.flags & 1024 /* Default */)) { - write("export "); - } - write("let "); - emitDeclarationName(node); - write(" = "); - } - else if (isES6ExportedDeclaration(node)) { - write("export "); - if (node.flags & 1024 /* Default */) { - write("default "); - } - } - } - // If the class has static properties, and it's a class expression, then we'll need - // to specialize the emit a bit. for a class expression of the form: - // - // class C { static a = 1; static b = 2; ... } - // - // We'll emit: - // - // (_temp = class C { ... }, _temp.a = 1, _temp.b = 2, _temp) - // - // This keeps the expression as an expression, while ensuring that the static parts - // of it have been initialized by the time it is used. - var staticProperties = getInitializedProperties(node, /*static:*/ true); - var isClassExpressionWithStaticProperties = staticProperties.length > 0 && node.kind === 186 /* ClassExpression */; - var tempVariable; - if (isClassExpressionWithStaticProperties) { - tempVariable = createAndRecordTempVariable(0 /* Auto */); - write("("); - increaseIndent(); - emit(tempVariable); - write(" = "); - } - write("class"); - // emit name if - // - node has a name - // - this is default export with static initializers - if ((node.name || (node.flags & 1024 /* Default */ && staticProperties.length > 0)) && !thisNodeIsDecorated) { - write(" "); - emitDeclarationName(node); - } - var baseTypeNode = ts.getClassExtendsHeritageClauseElement(node); - if (baseTypeNode) { - write(" extends "); - emit(baseTypeNode.expression); - } - write(" {"); - increaseIndent(); - scopeEmitStart(node); - writeLine(); - emitConstructor(node, baseTypeNode); - emitMemberFunctionsForES6AndHigher(node); - decreaseIndent(); - writeLine(); - emitToken(16 /* CloseBraceToken */, node.members.end); - scopeEmitEnd(); - // TODO(rbuckton): Need to go back to `let _a = class C {}` approach, removing the defineProperty call for now. - // For a decorated class, we need to assign its name (if it has one). This is because we emit - // the class as a class expression to avoid the double-binding of the identifier: - // - // let C = class { - // } - // Object.defineProperty(C, "name", { value: "C", configurable: true }); - // - if (thisNodeIsDecorated) { - write(";"); - } - // Emit static property assignment. Because classDeclaration is lexically evaluated, - // it is safe to emit static property assignment after classDeclaration - // From ES6 specification: - // 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 (isClassExpressionWithStaticProperties) { - for (var _a = 0; _a < staticProperties.length; _a++) { - var property = staticProperties[_a]; - write(","); - writeLine(); - emitPropertyDeclaration(node, property, /*receiver:*/ tempVariable, /*isExpression:*/ true); - } - write(","); - writeLine(); - emit(tempVariable); - decreaseIndent(); - write(")"); - } - else { - writeLine(); - emitPropertyDeclarations(node, staticProperties); - emitDecoratorsOfClass(node); - } - // If this is an exported class, but not on the top level (i.e. on an internal - // module), export it - if (!isES6ExportedDeclaration(node) && (node.flags & 1 /* Export */)) { - writeLine(); - emitStart(node); - emitModuleMemberName(node); - write(" = "); - emitDeclarationName(node); - emitEnd(node); - write(";"); - } - else if (isES6ExportedDeclaration(node) && (node.flags & 1024 /* Default */) && thisNodeIsDecorated) { - // if this is a top level default export of decorated class, write the export after the declaration. - writeLine(); - write("export default "); - emitDeclarationName(node); - write(";"); - } - } - function emitClassLikeDeclarationBelowES6(node) { - if (node.kind === 214 /* ClassDeclaration */) { - // source file level classes in system modules are hoisted so 'var's for them are already defined - if (!shouldHoistDeclarationInSystemJsModule(node)) { - write("var "); - } - emitDeclarationName(node); - write(" = "); - } - write("(function ("); - var baseTypeNode = ts.getClassExtendsHeritageClauseElement(node); - if (baseTypeNode) { - write("_super"); - } - write(") {"); - var saveTempFlags = tempFlags; - var saveTempVariables = tempVariables; - var saveTempParameters = tempParameters; - var saveComputedPropertyNamesToGeneratedNames = computedPropertyNamesToGeneratedNames; - tempFlags = 0; - tempVariables = undefined; - tempParameters = undefined; - computedPropertyNamesToGeneratedNames = undefined; - increaseIndent(); - scopeEmitStart(node); - if (baseTypeNode) { - writeLine(); - emitStart(baseTypeNode); - write("__extends("); - emitDeclarationName(node); - write(", _super);"); - emitEnd(baseTypeNode); - } - writeLine(); - emitConstructor(node, baseTypeNode); - emitMemberFunctionsForES5AndLower(node); - emitPropertyDeclarations(node, getInitializedProperties(node, /*static:*/ true)); - writeLine(); - emitDecoratorsOfClass(node); - writeLine(); - emitToken(16 /* CloseBraceToken */, node.members.end, function () { - write("return "); - emitDeclarationName(node); - }); - write(";"); - emitTempDeclarations(/*newLine*/ true); - tempFlags = saveTempFlags; - tempVariables = saveTempVariables; - tempParameters = saveTempParameters; - computedPropertyNamesToGeneratedNames = saveComputedPropertyNamesToGeneratedNames; - decreaseIndent(); - writeLine(); - emitToken(16 /* CloseBraceToken */, node.members.end); - scopeEmitEnd(); - emitStart(node); - write(")("); - if (baseTypeNode) { - emit(baseTypeNode.expression); - } - write(")"); - if (node.kind === 214 /* ClassDeclaration */) { - write(";"); - } - emitEnd(node); - if (node.kind === 214 /* ClassDeclaration */) { - emitExportMemberAssignment(node); - } - } - function emitClassMemberPrefix(node, member) { - emitDeclarationName(node); - if (!(member.flags & 128 /* Static */)) { - write(".prototype"); - } - } - function emitDecoratorsOfClass(node) { - emitDecoratorsOfMembers(node, /*staticFlag*/ 0); - emitDecoratorsOfMembers(node, 128 /* Static */); - emitDecoratorsOfConstructor(node); - } - function emitDecoratorsOfConstructor(node) { - var decorators = node.decorators; - var constructor = ts.getFirstConstructorWithBody(node); - var hasDecoratedParameters = constructor && ts.forEach(constructor.parameters, ts.nodeIsDecorated); - // skip decoration of the constructor if neither it nor its parameters are decorated - if (!decorators && !hasDecoratedParameters) { - return; - } - // Emit the call to __decorate. Given the class: - // - // @dec - // class C { - // } - // - // The emit for the class is: - // - // C = __decorate([dec], C); - // - writeLine(); - emitStart(node); - emitDeclarationName(node); - write(" = __decorate(["); - increaseIndent(); - writeLine(); - var decoratorCount = decorators ? decorators.length : 0; - var argumentsWritten = emitList(decorators, 0, decoratorCount, /*multiLine*/ true, /*trailingComma*/ false, /*leadingComma*/ false, /*noTrailingNewLine*/ true, function (decorator) { - emitStart(decorator); - emit(decorator.expression); - emitEnd(decorator); - }); - argumentsWritten += emitDecoratorsOfParameters(constructor, /*leadingComma*/ argumentsWritten > 0); - emitSerializedTypeMetadata(node, /*leadingComma*/ argumentsWritten >= 0); - decreaseIndent(); - writeLine(); - write("], "); - emitDeclarationName(node); - write(");"); - emitEnd(node); - writeLine(); - } - function emitDecoratorsOfMembers(node, staticFlag) { - for (var _a = 0, _b = node.members; _a < _b.length; _a++) { - var member = _b[_a]; - // only emit members in the correct group - if ((member.flags & 128 /* Static */) !== staticFlag) { - continue; - } - // skip members that cannot be decorated (such as the constructor) - if (!ts.nodeCanBeDecorated(member)) { - continue; - } - // skip a member if it or any of its parameters are not decorated - if (!ts.nodeOrChildIsDecorated(member)) { - continue; - } - // skip an accessor declaration if it is not the first accessor - var decorators = void 0; - var functionLikeMember = void 0; - if (ts.isAccessor(member)) { - var accessors = ts.getAllAccessorDeclarations(node.members, member); - if (member !== accessors.firstAccessor) { - continue; - } - // get the decorators from the first accessor with decorators - decorators = accessors.firstAccessor.decorators; - if (!decorators && accessors.secondAccessor) { - decorators = accessors.secondAccessor.decorators; - } - // we only decorate parameters of the set accessor - functionLikeMember = accessors.setAccessor; - } - else { - decorators = member.decorators; - // we only decorate the parameters here if this is a method - if (member.kind === 143 /* MethodDeclaration */) { - functionLikeMember = member; - } - } - // Emit the call to __decorate. Given the following: - // - // class C { - // @dec method(@dec2 x) {} - // @dec get accessor() {} - // @dec prop; - // } - // - // The emit for a method is: - // - // __decorate([ - // dec, - // __param(0, dec2), - // __metadata("design:type", Function), - // __metadata("design:paramtypes", [Object]), - // __metadata("design:returntype", void 0) - // ], C.prototype, "method", undefined); - // - // The emit for an accessor is: - // - // __decorate([ - // dec - // ], C.prototype, "accessor", undefined); - // - // The emit for a property is: - // - // __decorate([ - // dec - // ], C.prototype, "prop"); - // - writeLine(); - emitStart(member); - write("__decorate(["); - increaseIndent(); - writeLine(); - var decoratorCount = decorators ? decorators.length : 0; - var argumentsWritten = emitList(decorators, 0, decoratorCount, /*multiLine*/ true, /*trailingComma*/ false, /*leadingComma*/ false, /*noTrailingNewLine*/ true, function (decorator) { - emitStart(decorator); - emit(decorator.expression); - emitEnd(decorator); - }); - argumentsWritten += emitDecoratorsOfParameters(functionLikeMember, argumentsWritten > 0); - emitSerializedTypeMetadata(member, argumentsWritten > 0); - decreaseIndent(); - writeLine(); - write("], "); - emitStart(member.name); - emitClassMemberPrefix(node, member); - write(", "); - emitExpressionForPropertyName(member.name); - emitEnd(member.name); - if (languageVersion > 0 /* ES3 */) { - if (member.kind !== 141 /* PropertyDeclaration */) { - // We emit `null` here to indicate to `__decorate` that it can invoke `Object.getOwnPropertyDescriptor` directly. - // We have this extra argument here so that we can inject an explicit property descriptor at a later date. - write(", null"); - } - else { - // We emit `void 0` here to indicate to `__decorate` that it can invoke `Object.defineProperty` directly, but that it - // should not invoke `Object.getOwnPropertyDescriptor`. - write(", void 0"); - } - } - write(");"); - emitEnd(member); - writeLine(); - } - } - function emitDecoratorsOfParameters(node, leadingComma) { - var argumentsWritten = 0; - if (node) { - var parameterIndex = 0; - for (var _a = 0, _b = node.parameters; _a < _b.length; _a++) { - var parameter = _b[_a]; - if (ts.nodeIsDecorated(parameter)) { - var decorators = parameter.decorators; - argumentsWritten += emitList(decorators, 0, decorators.length, /*multiLine*/ true, /*trailingComma*/ false, /*leadingComma*/ leadingComma, /*noTrailingNewLine*/ true, function (decorator) { - emitStart(decorator); - write("__param(" + parameterIndex + ", "); - emit(decorator.expression); - write(")"); - emitEnd(decorator); - }); - leadingComma = true; - } - ++parameterIndex; - } - } - return argumentsWritten; - } - function shouldEmitTypeMetadata(node) { - // This method determines whether to emit the "design:type" metadata based on the node's kind. - // The caller should have already tested whether the node has decorators and whether the emitDecoratorMetadata - // compiler option is set. - switch (node.kind) { - case 143 /* MethodDeclaration */: - case 145 /* GetAccessor */: - case 146 /* SetAccessor */: - case 141 /* PropertyDeclaration */: - return true; - } - return false; - } - function shouldEmitReturnTypeMetadata(node) { - // This method determines whether to emit the "design:returntype" metadata based on the node's kind. - // The caller should have already tested whether the node has decorators and whether the emitDecoratorMetadata - // compiler option is set. - switch (node.kind) { - case 143 /* MethodDeclaration */: - return true; - } - return false; - } - function shouldEmitParamTypesMetadata(node) { - // This method determines whether to emit the "design:paramtypes" metadata based on the node's kind. - // The caller should have already tested whether the node has decorators and whether the emitDecoratorMetadata - // compiler option is set. - switch (node.kind) { - case 214 /* ClassDeclaration */: - case 143 /* MethodDeclaration */: - case 146 /* SetAccessor */: - return true; - } - return false; - } - /** Serializes the type of a declaration to an appropriate JS constructor value. Used by the __metadata decorator for a class member. */ - function emitSerializedTypeOfNode(node) { - // serialization of the type of a declaration uses the following rules: - // - // * The serialized type of a ClassDeclaration is "Function" - // * The serialized type of a ParameterDeclaration is the serialized type of its type annotation. - // * The serialized type of a PropertyDeclaration is the serialized type of its type annotation. - // * The serialized type of an AccessorDeclaration is the serialized type of the return type annotation of its getter or parameter type annotation of its setter. - // * The serialized type of any other FunctionLikeDeclaration is "Function". - // * The serialized type of any other node is "void 0". - // - // For rules on serializing type annotations, see `serializeTypeNode`. - switch (node.kind) { - case 214 /* ClassDeclaration */: - write("Function"); - return; - case 141 /* PropertyDeclaration */: - emitSerializedTypeNode(node.type); - return; - case 138 /* Parameter */: - emitSerializedTypeNode(node.type); - return; - case 145 /* GetAccessor */: - emitSerializedTypeNode(node.type); - return; - case 146 /* SetAccessor */: - emitSerializedTypeNode(ts.getSetAccessorTypeAnnotationNode(node)); - return; - } - if (ts.isFunctionLike(node)) { - write("Function"); - return; - } - write("void 0"); - } - function emitSerializedTypeNode(node) { - if (node) { - switch (node.kind) { - case 103 /* VoidKeyword */: - write("void 0"); - return; - case 160 /* ParenthesizedType */: - emitSerializedTypeNode(node.type); - return; - case 152 /* FunctionType */: - case 153 /* ConstructorType */: - write("Function"); - return; - case 156 /* ArrayType */: - case 157 /* TupleType */: - write("Array"); - return; - case 150 /* TypePredicate */: - case 120 /* BooleanKeyword */: - write("Boolean"); - return; - case 130 /* StringKeyword */: - case 9 /* StringLiteral */: - write("String"); - return; - case 128 /* NumberKeyword */: - write("Number"); - return; - case 131 /* SymbolKeyword */: - write("Symbol"); - return; - case 151 /* TypeReference */: - emitSerializedTypeReferenceNode(node); - return; - case 154 /* TypeQuery */: - case 155 /* TypeLiteral */: - case 158 /* UnionType */: - case 159 /* IntersectionType */: - case 117 /* AnyKeyword */: - break; - default: - ts.Debug.fail("Cannot serialize unexpected type node."); - break; - } - } - write("Object"); - } - /** Serializes a TypeReferenceNode to an appropriate JS constructor value. Used by the __metadata decorator. */ - function emitSerializedTypeReferenceNode(node) { - var location = node.parent; - while (ts.isDeclaration(location) || ts.isTypeNode(location)) { - location = location.parent; - } - // Clone the type name and parent it to a location outside of the current declaration. - var typeName = ts.cloneEntityName(node.typeName); - typeName.parent = location; - var result = resolver.getTypeReferenceSerializationKind(typeName); - switch (result) { - case ts.TypeReferenceSerializationKind.Unknown: - var temp = createAndRecordTempVariable(0 /* Auto */); - write("(typeof ("); - emitNodeWithoutSourceMap(temp); - write(" = "); - emitEntityNameAsExpression(typeName, /*useFallback*/ true); - write(") === 'function' && "); - emitNodeWithoutSourceMap(temp); - write(") || Object"); - break; - case ts.TypeReferenceSerializationKind.TypeWithConstructSignatureAndValue: - emitEntityNameAsExpression(typeName, /*useFallback*/ false); - break; - case ts.TypeReferenceSerializationKind.VoidType: - write("void 0"); - break; - case ts.TypeReferenceSerializationKind.BooleanType: - write("Boolean"); - break; - case ts.TypeReferenceSerializationKind.NumberLikeType: - write("Number"); - break; - case ts.TypeReferenceSerializationKind.StringLikeType: - write("String"); - break; - case ts.TypeReferenceSerializationKind.ArrayLikeType: - write("Array"); - break; - case ts.TypeReferenceSerializationKind.ESSymbolType: - if (languageVersion < 2 /* ES6 */) { - write("typeof Symbol === 'function' ? Symbol : Object"); - } - else { - write("Symbol"); - } - break; - case ts.TypeReferenceSerializationKind.TypeWithCallSignature: - write("Function"); - break; - case ts.TypeReferenceSerializationKind.ObjectType: - write("Object"); - break; - } - } - /** Serializes the parameter types of a function or the constructor of a class. Used by the __metadata decorator for a method or set accessor. */ - function emitSerializedParameterTypesOfNode(node) { - // serialization of parameter types uses the following rules: - // - // * If the declaration is a class, the parameters of the first constructor with a body are used. - // * If the declaration is function-like and has a body, the parameters of the function are used. - // - // For the rules on serializing the type of each parameter declaration, see `serializeTypeOfDeclaration`. - if (node) { - var valueDeclaration; - if (node.kind === 214 /* ClassDeclaration */) { - valueDeclaration = ts.getFirstConstructorWithBody(node); - } - else if (ts.isFunctionLike(node) && ts.nodeIsPresent(node.body)) { - valueDeclaration = node; - } - if (valueDeclaration) { - var parameters = valueDeclaration.parameters; - var parameterCount = parameters.length; - if (parameterCount > 0) { - for (var i = 0; i < parameterCount; i++) { - if (i > 0) { - write(", "); - } - if (parameters[i].dotDotDotToken) { - var parameterType = parameters[i].type; - if (parameterType.kind === 156 /* ArrayType */) { - parameterType = parameterType.elementType; - } - else if (parameterType.kind === 151 /* TypeReference */ && parameterType.typeArguments && parameterType.typeArguments.length === 1) { - parameterType = parameterType.typeArguments[0]; - } - else { - parameterType = undefined; - } - emitSerializedTypeNode(parameterType); - } - else { - emitSerializedTypeOfNode(parameters[i]); - } - } - } - } - } - } - /** Serializes the return type of function. Used by the __metadata decorator for a method. */ - function emitSerializedReturnTypeOfNode(node) { - if (node && ts.isFunctionLike(node) && node.type) { - emitSerializedTypeNode(node.type); - return; - } - write("void 0"); - } - function emitSerializedTypeMetadata(node, writeComma) { - // This method emits the serialized type metadata for a decorator target. - // The caller should have already tested whether the node has decorators. - var argumentsWritten = 0; - if (compilerOptions.emitDecoratorMetadata) { - if (shouldEmitTypeMetadata(node)) { - if (writeComma) { - write(", "); - } - writeLine(); - write("__metadata('design:type', "); - emitSerializedTypeOfNode(node); - write(")"); - argumentsWritten++; - } - if (shouldEmitParamTypesMetadata(node)) { - if (writeComma || argumentsWritten) { - write(", "); - } - writeLine(); - write("__metadata('design:paramtypes', ["); - emitSerializedParameterTypesOfNode(node); - write("])"); - argumentsWritten++; - } - if (shouldEmitReturnTypeMetadata(node)) { - if (writeComma || argumentsWritten) { - write(", "); - } - writeLine(); - write("__metadata('design:returntype', "); - emitSerializedReturnTypeOfNode(node); - write(")"); - argumentsWritten++; - } - } - return argumentsWritten; - } - function emitInterfaceDeclaration(node) { - emitCommentsOnNotEmittedNode(node); - } - function shouldEmitEnumDeclaration(node) { - var isConstEnum = ts.isConst(node); - return !isConstEnum || compilerOptions.preserveConstEnums || compilerOptions.isolatedModules; - } - function emitEnumDeclaration(node) { - // const enums are completely erased during compilation. - if (!shouldEmitEnumDeclaration(node)) { - return; - } - if (!shouldHoistDeclarationInSystemJsModule(node)) { - // do not emit var if variable was already hoisted - if (!(node.flags & 1 /* Export */) || isES6ExportedDeclaration(node)) { - emitStart(node); - if (isES6ExportedDeclaration(node)) { - write("export "); - } - write("var "); - emit(node.name); - emitEnd(node); - write(";"); - } - } - writeLine(); - emitStart(node); - write("(function ("); - emitStart(node.name); - write(getGeneratedNameForNode(node)); - emitEnd(node.name); - write(") {"); - increaseIndent(); - scopeEmitStart(node); - emitLines(node.members); - decreaseIndent(); - writeLine(); - emitToken(16 /* CloseBraceToken */, node.members.end); - scopeEmitEnd(); - write(")("); - emitModuleMemberName(node); - write(" || ("); - emitModuleMemberName(node); - write(" = {}));"); - emitEnd(node); - if (!isES6ExportedDeclaration(node) && node.flags & 1 /* Export */ && !shouldHoistDeclarationInSystemJsModule(node)) { - // do not emit var if variable was already hoisted - writeLine(); - emitStart(node); - write("var "); - emit(node.name); - write(" = "); - emitModuleMemberName(node); - emitEnd(node); - write(";"); - } - if (modulekind !== 5 /* ES6 */ && node.parent === currentSourceFile) { - if (modulekind === 4 /* System */ && (node.flags & 1 /* Export */)) { - // write the call to exporter for enum - writeLine(); - write(exportFunctionForFile + "(\""); - emitDeclarationName(node); - write("\", "); - emitDeclarationName(node); - write(");"); - } - emitExportMemberAssignments(node.name); - } - } - function emitEnumMember(node) { - var enumParent = node.parent; - emitStart(node); - write(getGeneratedNameForNode(enumParent)); - write("["); - write(getGeneratedNameForNode(enumParent)); - write("["); - emitExpressionForPropertyName(node.name); - write("] = "); - writeEnumMemberDeclarationValue(node); - write("] = "); - emitExpressionForPropertyName(node.name); - emitEnd(node); - write(";"); - } - function writeEnumMemberDeclarationValue(member) { - var value = resolver.getConstantValue(member); - if (value !== undefined) { - write(value.toString()); - return; - } - else if (member.initializer) { - emit(member.initializer); - } - else { - write("undefined"); - } - } - function getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration) { - if (moduleDeclaration.body.kind === 218 /* ModuleDeclaration */) { - var recursiveInnerModule = getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration.body); - return recursiveInnerModule || moduleDeclaration.body; - } - } - function shouldEmitModuleDeclaration(node) { - return ts.isInstantiatedModule(node, compilerOptions.preserveConstEnums || compilerOptions.isolatedModules); - } - function isModuleMergedWithES6Class(node) { - return languageVersion === 2 /* ES6 */ && !!(resolver.getNodeCheckFlags(node) & 32768 /* LexicalModuleMergesWithClass */); - } - function emitModuleDeclaration(node) { - // Emit only if this module is non-ambient. - var shouldEmit = shouldEmitModuleDeclaration(node); - if (!shouldEmit) { - return emitCommentsOnNotEmittedNode(node); - } - var hoistedInDeclarationScope = shouldHoistDeclarationInSystemJsModule(node); - var emitVarForModule = !hoistedInDeclarationScope && !isModuleMergedWithES6Class(node); - if (emitVarForModule) { - emitStart(node); - if (isES6ExportedDeclaration(node)) { - write("export "); - } - write("var "); - emit(node.name); - write(";"); - emitEnd(node); - writeLine(); - } - emitStart(node); - write("(function ("); - emitStart(node.name); - write(getGeneratedNameForNode(node)); - emitEnd(node.name); - write(") "); - if (node.body.kind === 219 /* ModuleBlock */) { - var saveTempFlags = tempFlags; - var saveTempVariables = tempVariables; - tempFlags = 0; - tempVariables = undefined; - emit(node.body); - tempFlags = saveTempFlags; - tempVariables = saveTempVariables; - } - else { - write("{"); - increaseIndent(); - scopeEmitStart(node); - emitCaptureThisForNodeIfNecessary(node); - writeLine(); - emit(node.body); - decreaseIndent(); - writeLine(); - var moduleBlock = getInnerMostModuleDeclarationFromDottedModule(node).body; - emitToken(16 /* CloseBraceToken */, moduleBlock.statements.end); - scopeEmitEnd(); - } - write(")("); - // write moduleDecl = containingModule.m only if it is not exported es6 module member - if ((node.flags & 1 /* Export */) && !isES6ExportedDeclaration(node)) { - emit(node.name); - write(" = "); - } - emitModuleMemberName(node); - write(" || ("); - emitModuleMemberName(node); - write(" = {}));"); - emitEnd(node); - if (!isES6ExportedDeclaration(node) && node.name.kind === 69 /* Identifier */ && node.parent === currentSourceFile) { - if (modulekind === 4 /* System */ && (node.flags & 1 /* Export */)) { - writeLine(); - write(exportFunctionForFile + "(\""); - emitDeclarationName(node); - write("\", "); - emitDeclarationName(node); - write(");"); - } - emitExportMemberAssignments(node.name); - } - } - /* - * Some bundlers (SystemJS builder) sometimes want to rename dependencies. - * Here we check if alternative name was provided for a given moduleName and return it if possible. - */ - function tryRenameExternalModule(moduleName) { - if (currentSourceFile.renamedDependencies && ts.hasProperty(currentSourceFile.renamedDependencies, moduleName.text)) { - return "\"" + currentSourceFile.renamedDependencies[moduleName.text] + "\""; - } - return undefined; - } - function emitRequire(moduleName) { - if (moduleName.kind === 9 /* StringLiteral */) { - write("require("); - var text = tryRenameExternalModule(moduleName); - if (text) { - write(text); - } - else { - emitStart(moduleName); - emitLiteral(moduleName); - emitEnd(moduleName); - } - emitToken(18 /* CloseParenToken */, moduleName.end); - } - else { - write("require()"); - } - } - function getNamespaceDeclarationNode(node) { - if (node.kind === 221 /* ImportEqualsDeclaration */) { - return node; - } - var importClause = node.importClause; - if (importClause && importClause.namedBindings && importClause.namedBindings.kind === 224 /* NamespaceImport */) { - return importClause.namedBindings; - } - } - function isDefaultImport(node) { - return node.kind === 222 /* ImportDeclaration */ && node.importClause && !!node.importClause.name; - } - function emitExportImportAssignments(node) { - if (ts.isAliasSymbolDeclaration(node) && resolver.isValueAliasDeclaration(node)) { - emitExportMemberAssignments(node.name); - } - ts.forEachChild(node, emitExportImportAssignments); - } - function emitImportDeclaration(node) { - if (modulekind !== 5 /* ES6 */) { - return emitExternalImportDeclaration(node); - } - // ES6 import - if (node.importClause) { - var shouldEmitDefaultBindings = resolver.isReferencedAliasDeclaration(node.importClause); - var shouldEmitNamedBindings = node.importClause.namedBindings && resolver.isReferencedAliasDeclaration(node.importClause.namedBindings, /* checkChildren */ true); - if (shouldEmitDefaultBindings || shouldEmitNamedBindings) { - write("import "); - emitStart(node.importClause); - if (shouldEmitDefaultBindings) { - emit(node.importClause.name); - if (shouldEmitNamedBindings) { - write(", "); - } - } - if (shouldEmitNamedBindings) { - emitLeadingComments(node.importClause.namedBindings); - emitStart(node.importClause.namedBindings); - if (node.importClause.namedBindings.kind === 224 /* NamespaceImport */) { - write("* as "); - emit(node.importClause.namedBindings.name); - } - else { - write("{ "); - emitExportOrImportSpecifierList(node.importClause.namedBindings.elements, resolver.isReferencedAliasDeclaration); - write(" }"); - } - emitEnd(node.importClause.namedBindings); - emitTrailingComments(node.importClause.namedBindings); - } - emitEnd(node.importClause); - write(" from "); - emit(node.moduleSpecifier); - write(";"); - } - } - else { - write("import "); - emit(node.moduleSpecifier); - write(";"); - } - } - function emitExternalImportDeclaration(node) { - if (ts.contains(externalImports, node)) { - var isExportedImport = node.kind === 221 /* ImportEqualsDeclaration */ && (node.flags & 1 /* Export */) !== 0; - var namespaceDeclaration = getNamespaceDeclarationNode(node); - if (modulekind !== 2 /* AMD */) { - emitLeadingComments(node); - emitStart(node); - if (namespaceDeclaration && !isDefaultImport(node)) { - // import x = require("foo") - // import * as x from "foo" - if (!isExportedImport) - write("var "); - emitModuleMemberName(namespaceDeclaration); - write(" = "); - } - else { - // import "foo" - // import x from "foo" - // import { x, y } from "foo" - // import d, * as x from "foo" - // import d, { x, y } from "foo" - var isNakedImport = 222 /* ImportDeclaration */ && !node.importClause; - if (!isNakedImport) { - write("var "); - write(getGeneratedNameForNode(node)); - write(" = "); - } - } - emitRequire(ts.getExternalModuleName(node)); - if (namespaceDeclaration && isDefaultImport(node)) { - // import d, * as x from "foo" - write(", "); - emitModuleMemberName(namespaceDeclaration); - write(" = "); - write(getGeneratedNameForNode(node)); - } - write(";"); - emitEnd(node); - emitExportImportAssignments(node); - emitTrailingComments(node); - } - else { - if (isExportedImport) { - emitModuleMemberName(namespaceDeclaration); - write(" = "); - emit(namespaceDeclaration.name); - write(";"); - } - else if (namespaceDeclaration && isDefaultImport(node)) { - // import d, * as x from "foo" - write("var "); - emitModuleMemberName(namespaceDeclaration); - write(" = "); - write(getGeneratedNameForNode(node)); - write(";"); - } - emitExportImportAssignments(node); - } - } - } - function emitImportEqualsDeclaration(node) { - if (ts.isExternalModuleImportEqualsDeclaration(node)) { - emitExternalImportDeclaration(node); - return; - } - // preserve old compiler's behavior: emit 'var' for import declaration (even if we do not consider them referenced) when - // - current file is not external module - // - import declaration is top level and target is value imported by entity name - if (resolver.isReferencedAliasDeclaration(node) || - (!ts.isExternalModule(currentSourceFile) && resolver.isTopLevelValueImportEqualsWithEntityName(node))) { - emitLeadingComments(node); - emitStart(node); - // variable declaration for import-equals declaration can be hoisted in system modules - // in this case 'var' should be omitted and emit should contain only initialization - var variableDeclarationIsHoisted = shouldHoistVariable(node, /*checkIfSourceFileLevelDecl*/ true); - // is it top level export import v = a.b.c in system module? - // if yes - it needs to be rewritten as exporter('v', v = a.b.c) - var isExported = isSourceFileLevelDeclarationInSystemJsModule(node, /*isExported*/ true); - if (!variableDeclarationIsHoisted) { - ts.Debug.assert(!isExported); - if (isES6ExportedDeclaration(node)) { - write("export "); - write("var "); - } - else if (!(node.flags & 1 /* Export */)) { - write("var "); - } - } - if (isExported) { - write(exportFunctionForFile + "(\""); - emitNodeWithoutSourceMap(node.name); - write("\", "); - } - emitModuleMemberName(node); - write(" = "); - emit(node.moduleReference); - if (isExported) { - write(")"); - } - write(";"); - emitEnd(node); - emitExportImportAssignments(node); - emitTrailingComments(node); - } - } - function emitExportDeclaration(node) { - ts.Debug.assert(modulekind !== 4 /* System */); - if (modulekind !== 5 /* ES6 */) { - if (node.moduleSpecifier && (!node.exportClause || resolver.isValueAliasDeclaration(node))) { - emitStart(node); - var generatedName = getGeneratedNameForNode(node); - if (node.exportClause) { - // export { x, y, ... } from "foo" - if (modulekind !== 2 /* AMD */) { - write("var "); - write(generatedName); - write(" = "); - emitRequire(ts.getExternalModuleName(node)); - write(";"); - } - for (var _a = 0, _b = node.exportClause.elements; _a < _b.length; _a++) { - var specifier = _b[_a]; - if (resolver.isValueAliasDeclaration(specifier)) { - writeLine(); - emitStart(specifier); - emitContainingModuleName(specifier); - write("."); - emitNodeWithCommentsAndWithoutSourcemap(specifier.name); - write(" = "); - write(generatedName); - write("."); - emitNodeWithCommentsAndWithoutSourcemap(specifier.propertyName || specifier.name); - write(";"); - emitEnd(specifier); - } - } - } - else { - // export * from "foo" - writeLine(); - write("__export("); - if (modulekind !== 2 /* AMD */) { - emitRequire(ts.getExternalModuleName(node)); - } - else { - write(generatedName); - } - write(");"); - } - emitEnd(node); - } - } - else { - if (!node.exportClause || resolver.isValueAliasDeclaration(node)) { - write("export "); - if (node.exportClause) { - // export { x, y, ... } - write("{ "); - emitExportOrImportSpecifierList(node.exportClause.elements, resolver.isValueAliasDeclaration); - write(" }"); - } - else { - write("*"); - } - if (node.moduleSpecifier) { - write(" from "); - emit(node.moduleSpecifier); - } - write(";"); - } - } - } - function emitExportOrImportSpecifierList(specifiers, shouldEmit) { - ts.Debug.assert(modulekind === 5 /* ES6 */); - var needsComma = false; - for (var _a = 0; _a < specifiers.length; _a++) { - var specifier = specifiers[_a]; - if (shouldEmit(specifier)) { - if (needsComma) { - write(", "); - } - if (specifier.propertyName) { - emit(specifier.propertyName); - write(" as "); - } - emit(specifier.name); - needsComma = true; - } - } - } - function emitExportAssignment(node) { - if (!node.isExportEquals && resolver.isValueAliasDeclaration(node)) { - if (modulekind === 5 /* ES6 */) { - writeLine(); - emitStart(node); - write("export default "); - var expression = node.expression; - emit(expression); - if (expression.kind !== 213 /* FunctionDeclaration */ && - expression.kind !== 214 /* ClassDeclaration */) { - write(";"); - } - emitEnd(node); - } - else { - writeLine(); - emitStart(node); - if (modulekind === 4 /* System */) { - write(exportFunctionForFile + "(\"default\","); - emit(node.expression); - write(")"); - } - else { - emitEs6ExportDefaultCompat(node); - emitContainingModuleName(node); - if (languageVersion === 0 /* ES3 */) { - write("[\"default\"] = "); - } - else { - write(".default = "); - } - emit(node.expression); - } - write(";"); - emitEnd(node); - } - } - } - function collectExternalModuleInfo(sourceFile) { - externalImports = []; - exportSpecifiers = {}; - exportEquals = undefined; - hasExportStars = false; - for (var _a = 0, _b = sourceFile.statements; _a < _b.length; _a++) { - var node = _b[_a]; - switch (node.kind) { - case 222 /* 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); - } - break; - case 221 /* ImportEqualsDeclaration */: - if (node.moduleReference.kind === 232 /* ExternalModuleReference */ && resolver.isReferencedAliasDeclaration(node)) { - // import x = require("mod") where x is referenced - externalImports.push(node); - } - break; - case 228 /* ExportDeclaration */: - if (node.moduleSpecifier) { - if (!node.exportClause) { - // export * from "mod" - externalImports.push(node); - hasExportStars = true; - } - else if (resolver.isValueAliasDeclaration(node)) { - // export { x, y } from "mod" where at least one export is a value symbol - externalImports.push(node); - } - } - else { - // export { x, y } - for (var _c = 0, _d = node.exportClause.elements; _c < _d.length; _c++) { - var specifier = _d[_c]; - var name_25 = (specifier.propertyName || specifier.name).text; - (exportSpecifiers[name_25] || (exportSpecifiers[name_25] = [])).push(specifier); - } - } - break; - case 227 /* ExportAssignment */: - if (node.isExportEquals && !exportEquals) { - // export = x - exportEquals = node; - } - break; - } - } - } - function emitExportStarHelper() { - if (hasExportStars) { - writeLine(); - write("function __export(m) {"); - increaseIndent(); - writeLine(); - write("for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];"); - decreaseIndent(); - writeLine(); - write("}"); - } - } - function getLocalNameForExternalImport(node) { - var namespaceDeclaration = getNamespaceDeclarationNode(node); - if (namespaceDeclaration && !isDefaultImport(node)) { - return ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, namespaceDeclaration.name); - } - if (node.kind === 222 /* ImportDeclaration */ && node.importClause) { - return getGeneratedNameForNode(node); - } - if (node.kind === 228 /* ExportDeclaration */ && node.moduleSpecifier) { - return getGeneratedNameForNode(node); - } - } - function getExternalModuleNameText(importNode) { - var moduleName = ts.getExternalModuleName(importNode); - if (moduleName.kind === 9 /* StringLiteral */) { - return tryRenameExternalModule(moduleName) || getLiteralText(moduleName); - } - return undefined; - } - function emitVariableDeclarationsForImports() { - if (externalImports.length === 0) { - return; - } - writeLine(); - var started = false; - for (var _a = 0; _a < externalImports.length; _a++) { - var importNode = externalImports[_a]; - // do not create variable declaration for exports and imports that lack import clause - var skipNode = importNode.kind === 228 /* ExportDeclaration */ || - (importNode.kind === 222 /* ImportDeclaration */ && !importNode.importClause); - if (skipNode) { - continue; - } - if (!started) { - write("var "); - started = true; - } - else { - write(", "); - } - write(getLocalNameForExternalImport(importNode)); - } - if (started) { - write(";"); - } - } - function emitLocalStorageForExportedNamesIfNecessary(exportedDeclarations) { - // 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. - if (!hasExportStars) { - // local names set is needed only in presence of star exports - return undefined; - } - // local names set should only be added if we have anything exported - if (!exportedDeclarations && 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 _a = 0; _a < externalImports.length; _a++) { - var externalImport = externalImports[_a]; - if (externalImport.kind === 228 /* ExportDeclaration */ && externalImport.exportClause) { - hasExportDeclarationWithExportClause = true; - break; - } - } - if (!hasExportDeclarationWithExportClause) { - // we still need to emit exportStar helper - return emitExportStarFunction(/*localNames*/ undefined); - } - } - var exportedNamesStorageRef = makeUniqueName("exportedNames"); - writeLine(); - write("var " + exportedNamesStorageRef + " = {"); - increaseIndent(); - var started = false; - if (exportedDeclarations) { - for (var i = 0; i < exportedDeclarations.length; ++i) { - // write name of exported declaration, i.e 'export var x...' - writeExportedName(exportedDeclarations[i]); - } - } - if (exportSpecifiers) { - for (var n in exportSpecifiers) { - for (var _b = 0, _c = exportSpecifiers[n]; _b < _c.length; _b++) { - var specifier = _c[_b]; - // write name of export specified, i.e. 'export {x}' - writeExportedName(specifier.name); - } - } - } - for (var _d = 0; _d < externalImports.length; _d++) { - var externalImport = externalImports[_d]; - if (externalImport.kind !== 228 /* ExportDeclaration */) { - continue; - } - var exportDecl = externalImport; - if (!exportDecl.exportClause) { - // export * from ... - continue; - } - for (var _e = 0, _f = exportDecl.exportClause.elements; _e < _f.length; _e++) { - var element = _f[_e]; - // write name of indirectly exported entry, i.e. 'export {x} from ...' - writeExportedName(element.name || element.propertyName); - } - } - decreaseIndent(); - writeLine(); - write("};"); - return emitExportStarFunction(exportedNamesStorageRef); - function emitExportStarFunction(localNames) { - var exportStarFunction = makeUniqueName("exportStar"); - writeLine(); - // define an export star helper function - write("function " + exportStarFunction + "(m) {"); - increaseIndent(); - writeLine(); - write("var exports = {};"); - writeLine(); - write("for(var n in m) {"); - increaseIndent(); - writeLine(); - write("if (n !== \"default\""); - if (localNames) { - write("&& !" + localNames + ".hasOwnProperty(n)"); - } - write(") exports[n] = m[n];"); - decreaseIndent(); - writeLine(); - write("}"); - writeLine(); - write(exportFunctionForFile + "(exports);"); - decreaseIndent(); - writeLine(); - write("}"); - return exportStarFunction; - } - function writeExportedName(node) { - // do not record default exports - // they are local to module and never overwritten (explicitly skipped) by star export - if (node.kind !== 69 /* Identifier */ && node.flags & 1024 /* Default */) { - return; - } - if (started) { - write(","); - } - else { - started = true; - } - writeLine(); - write("'"); - if (node.kind === 69 /* Identifier */) { - emitNodeWithCommentsAndWithoutSourcemap(node); - } - else { - emitDeclarationName(node); - } - write("': true"); - } - } - function processTopLevelVariableAndFunctionDeclarations(node) { - // per ES6 spec: - // 15.2.1.16.4 ModuleDeclarationInstantiation() Concrete Method - // - var declarations are initialized to undefined - 14.a.ii - // - function/generator declarations are instantiated - 16.a.iv - // this means that after module is instantiated but before its evaluation - // exported functions are already accessible at import sites - // in theory we should hoist only exported functions and its dependencies - // in practice to simplify things we'll hoist all source level functions and variable declaration - // including variables declarations for module and class declarations - var hoistedVars; - var hoistedFunctionDeclarations; - var exportedDeclarations; - visit(node); - if (hoistedVars) { - writeLine(); - write("var "); - var seen = {}; - for (var i = 0; i < hoistedVars.length; ++i) { - var local = hoistedVars[i]; - var name_26 = local.kind === 69 /* Identifier */ - ? local - : local.name; - if (name_26) { - // do not emit duplicate entries (in case of declaration merging) in the list of hoisted variables - var text = ts.unescapeIdentifier(name_26.text); - if (ts.hasProperty(seen, text)) { - continue; - } - else { - seen[text] = text; - } - } - if (i !== 0) { - write(", "); - } - if (local.kind === 214 /* ClassDeclaration */ || local.kind === 218 /* ModuleDeclaration */ || local.kind === 217 /* EnumDeclaration */) { - emitDeclarationName(local); - } - else { - emit(local); - } - var flags = ts.getCombinedNodeFlags(local.kind === 69 /* Identifier */ ? local.parent : local); - if (flags & 1 /* Export */) { - if (!exportedDeclarations) { - exportedDeclarations = []; - } - exportedDeclarations.push(local); - } - } - write(";"); - } - if (hoistedFunctionDeclarations) { - for (var _a = 0; _a < hoistedFunctionDeclarations.length; _a++) { - var f = hoistedFunctionDeclarations[_a]; - writeLine(); - emit(f); - if (f.flags & 1 /* Export */) { - if (!exportedDeclarations) { - exportedDeclarations = []; - } - exportedDeclarations.push(f); - } - } - } - return exportedDeclarations; - function visit(node) { - if (node.flags & 2 /* Ambient */) { - return; - } - if (node.kind === 213 /* FunctionDeclaration */) { - if (!hoistedFunctionDeclarations) { - hoistedFunctionDeclarations = []; - } - hoistedFunctionDeclarations.push(node); - return; - } - if (node.kind === 214 /* ClassDeclaration */) { - if (!hoistedVars) { - hoistedVars = []; - } - hoistedVars.push(node); - return; - } - if (node.kind === 217 /* EnumDeclaration */) { - if (shouldEmitEnumDeclaration(node)) { - if (!hoistedVars) { - hoistedVars = []; - } - hoistedVars.push(node); - } - return; - } - if (node.kind === 218 /* ModuleDeclaration */) { - if (shouldEmitModuleDeclaration(node)) { - if (!hoistedVars) { - hoistedVars = []; - } - hoistedVars.push(node); - } - return; - } - if (node.kind === 211 /* VariableDeclaration */ || node.kind === 163 /* BindingElement */) { - if (shouldHoistVariable(node, /*checkIfSourceFileLevelDecl*/ false)) { - var name_27 = node.name; - if (name_27.kind === 69 /* Identifier */) { - if (!hoistedVars) { - hoistedVars = []; - } - hoistedVars.push(name_27); - } - else { - ts.forEachChild(name_27, visit); - } - } - return; - } - if (ts.isInternalModuleImportEqualsDeclaration(node) && resolver.isValueAliasDeclaration(node)) { - if (!hoistedVars) { - hoistedVars = []; - } - hoistedVars.push(node.name); - return; - } - if (ts.isBindingPattern(node)) { - ts.forEach(node.elements, visit); - return; - } - if (!ts.isDeclaration(node)) { - ts.forEachChild(node, visit); - } - } - } - function shouldHoistVariable(node, checkIfSourceFileLevelDecl) { - if (checkIfSourceFileLevelDecl && !shouldHoistDeclarationInSystemJsModule(node)) { - return false; - } - // hoist variable if - // - it is not block scoped - // - it is top level block scoped - // if block scoped variables are nested in some another block then - // no other functions can use them except ones that are defined at least in the same block - return (ts.getCombinedNodeFlags(node) & 49152 /* BlockScoped */) === 0 || - ts.getEnclosingBlockScopeContainer(node).kind === 248 /* SourceFile */; - } - function isCurrentFileSystemExternalModule() { - return modulekind === 4 /* System */ && ts.isExternalModule(currentSourceFile); - } - function emitSystemModuleBody(node, dependencyGroups, startIndex) { - // 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 file1; // local alias - // var y; - // function foo() { return y + file1.x(); } - // exports("foo", foo); - // return { - // setters: [ - // function(v) { file1 = v } - // ], - // execute(): function() { - // y = 1; - // console.log(y); - // } - // }; - // } - emitVariableDeclarationsForImports(); - writeLine(); - var exportedDeclarations = processTopLevelVariableAndFunctionDeclarations(node); - var exportStarFunction = emitLocalStorageForExportedNamesIfNecessary(exportedDeclarations); - writeLine(); - write("return {"); - increaseIndent(); - writeLine(); - emitSetters(exportStarFunction, dependencyGroups); - writeLine(); - emitExecute(node, startIndex); - decreaseIndent(); - writeLine(); - write("}"); // return - emitTempDeclarations(/*newLine*/ true); - } - function emitSetters(exportStarFunction, dependencyGroups) { - write("setters:["); - for (var i = 0; i < dependencyGroups.length; ++i) { - if (i !== 0) { - write(","); - } - writeLine(); - increaseIndent(); - var group = dependencyGroups[i]; - // derive a unique name for parameter from the first named entry in the group - var parameterName = makeUniqueName(ts.forEach(group, getLocalNameForExternalImport) || ""); - write("function (" + parameterName + ") {"); - increaseIndent(); - for (var _a = 0; _a < group.length; _a++) { - var entry = group[_a]; - var importVariableName = getLocalNameForExternalImport(entry) || ""; - switch (entry.kind) { - case 222 /* ImportDeclaration */: - if (!entry.importClause) { - // 'import "..."' case - // module is imported only for side-effects, no emit required - break; - } - // fall-through - case 221 /* ImportEqualsDeclaration */: - ts.Debug.assert(importVariableName !== ""); - writeLine(); - // save import into the local - write(importVariableName + " = " + parameterName + ";"); - writeLine(); - break; - case 228 /* ExportDeclaration */: - ts.Debug.assert(importVariableName !== ""); - if (entry.exportClause) { - // export {a, b as c} from 'foo' - // emit as: - // exports_({ - // "a": _["a"], - // "c": _["b"] - // }); - writeLine(); - write(exportFunctionForFile + "({"); - writeLine(); - increaseIndent(); - for (var i_2 = 0, len = entry.exportClause.elements.length; i_2 < len; ++i_2) { - if (i_2 !== 0) { - write(","); - writeLine(); - } - var e = entry.exportClause.elements[i_2]; - write("\""); - emitNodeWithCommentsAndWithoutSourcemap(e.name); - write("\": " + parameterName + "[\""); - emitNodeWithCommentsAndWithoutSourcemap(e.propertyName || e.name); - write("\"]"); - } - decreaseIndent(); - writeLine(); - write("});"); - } - else { - writeLine(); - // export * from 'foo' - // emit as: - // exportStar(_foo); - write(exportStarFunction + "(" + parameterName + ");"); - } - writeLine(); - break; - } - } - decreaseIndent(); - write("}"); - decreaseIndent(); - } - write("],"); - } - function emitExecute(node, startIndex) { - write("execute: function() {"); - increaseIndent(); - writeLine(); - for (var i = startIndex; i < node.statements.length; ++i) { - var statement = node.statements[i]; - switch (statement.kind) { - // - function declarations are not emitted because they were already hoisted - // - import declarations are not emitted since they are already handled in setters - // - export declarations with module specifiers are not emitted since they were already written in setters - // - export declarations without module specifiers are emitted preserving the order - case 213 /* FunctionDeclaration */: - case 222 /* ImportDeclaration */: - continue; - case 228 /* ExportDeclaration */: - if (!statement.moduleSpecifier) { - for (var _a = 0, _b = statement.exportClause.elements; _a < _b.length; _a++) { - var element = _b[_a]; - // write call to exporter function for every export specifier in exports list - emitExportSpecifierInSystemModule(element); - } - } - continue; - case 221 /* ImportEqualsDeclaration */: - if (!ts.isInternalModuleImportEqualsDeclaration(statement)) { - // - import equals declarations that import external modules are not emitted - continue; - } - // fall-though for import declarations that import internal modules - default: - writeLine(); - emit(statement); - } - } - decreaseIndent(); - writeLine(); - write("}"); // execute - } - function emitSystemModule(node) { - collectExternalModuleInfo(node); - // System modules has the following shape - // System.register(['dep-1', ... 'dep-n'], function(exports) {/* module body function */}) - // 'exports' here is a function 'exports(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 'emitPostfixUnaryExpression' for more details - ts.Debug.assert(!exportFunctionForFile); - // make sure that name of 'exports' function does not conflict with existing identifiers - exportFunctionForFile = makeUniqueName("exports"); - writeLine(); - write("System.register("); - if (node.moduleName) { - write("\"" + node.moduleName + "\", "); - } - write("["); - var groupIndices = {}; - var dependencyGroups = []; - for (var i = 0; i < externalImports.length; ++i) { - var text = getExternalModuleNameText(externalImports[i]); - if (ts.hasProperty(groupIndices, text)) { - // deduplicate/group entries in dependency list by the dependency name - var groupIndex = groupIndices[text]; - dependencyGroups[groupIndex].push(externalImports[i]); - continue; - } - else { - groupIndices[text] = dependencyGroups.length; - dependencyGroups.push([externalImports[i]]); - } - if (i !== 0) { - write(", "); - } - write(text); - } - write("], function(" + exportFunctionForFile + ") {"); - writeLine(); - increaseIndent(); - var startIndex = emitDirectivePrologues(node.statements, /*startWithNewLine*/ true); - emitEmitHelpers(node); - emitCaptureThisForNodeIfNecessary(node); - emitSystemModuleBody(node, dependencyGroups, startIndex); - decreaseIndent(); - writeLine(); - write("});"); - } - function getAMDDependencyNames(node, includeNonAmdDependencies) { - // names of modules with corresponding parameter in the factory function - var aliasedModuleNames = []; - // names of modules with no corresponding parameters in factory function - var unaliasedModuleNames = []; - var importAliasNames = []; // names of the parameters in the factory function; these - // parameters need to match the indexes of the corresponding - // module names in aliasedModuleNames. - // Fill in amd-dependency tags - for (var _a = 0, _b = node.amdDependencies; _a < _b.length; _a++) { - var amdDependency = _b[_a]; - if (amdDependency.name) { - aliasedModuleNames.push("\"" + amdDependency.path + "\""); - importAliasNames.push(amdDependency.name); - } - else { - unaliasedModuleNames.push("\"" + amdDependency.path + "\""); - } - } - for (var _c = 0; _c < externalImports.length; _c++) { - var importNode = externalImports[_c]; - // Find the name of the external module - var externalModuleName = getExternalModuleNameText(importNode); - // Find the name of the module alias, if there is one - var importAliasName = getLocalNameForExternalImport(importNode); - if (includeNonAmdDependencies && importAliasName) { - aliasedModuleNames.push(externalModuleName); - importAliasNames.push(importAliasName); - } - else { - unaliasedModuleNames.push(externalModuleName); - } - } - return { aliasedModuleNames: aliasedModuleNames, unaliasedModuleNames: unaliasedModuleNames, importAliasNames: importAliasNames }; - } - function emitAMDDependencies(node, includeNonAmdDependencies) { - // An AMD define function has the following shape: - // define(id?, dependencies?, factory); - // - // This has the shape of - // define(name, ["module1", "module2"], function (module1Alias) { - // The location of the alias in the parameter list in the factory function needs to - // match the position of the module name in the dependency list. - // - // To ensure this is true in cases of modules with no aliases, e.g.: - // `import "module"` or `` - // we need to add modules without alias names to the end of the dependencies list - var dependencyNames = getAMDDependencyNames(node, includeNonAmdDependencies); - emitAMDDependencyList(dependencyNames); - write(", "); - emitAMDFactoryHeader(dependencyNames); - } - function emitAMDDependencyList(_a) { - var aliasedModuleNames = _a.aliasedModuleNames, unaliasedModuleNames = _a.unaliasedModuleNames; - write("[\"require\", \"exports\""); - if (aliasedModuleNames.length) { - write(", "); - write(aliasedModuleNames.join(", ")); - } - if (unaliasedModuleNames.length) { - write(", "); - write(unaliasedModuleNames.join(", ")); - } - write("]"); - } - function emitAMDFactoryHeader(_a) { - var importAliasNames = _a.importAliasNames; - write("function (require, exports"); - if (importAliasNames.length) { - write(", "); - write(importAliasNames.join(", ")); - } - write(") {"); - } - function emitAMDModule(node) { - emitEmitHelpers(node); - collectExternalModuleInfo(node); - writeLine(); - write("define("); - if (node.moduleName) { - write("\"" + node.moduleName + "\", "); - } - emitAMDDependencies(node, /*includeNonAmdDependencies*/ true); - increaseIndent(); - var startIndex = emitDirectivePrologues(node.statements, /*startWithNewLine*/ true); - emitExportStarHelper(); - emitCaptureThisForNodeIfNecessary(node); - emitLinesStartingAt(node.statements, startIndex); - emitTempDeclarations(/*newLine*/ true); - emitExportEquals(/*emitAsReturn*/ true); - decreaseIndent(); - writeLine(); - write("});"); - } - function emitCommonJSModule(node) { - var startIndex = emitDirectivePrologues(node.statements, /*startWithNewLine*/ false); - emitEmitHelpers(node); - collectExternalModuleInfo(node); - emitExportStarHelper(); - emitCaptureThisForNodeIfNecessary(node); - emitLinesStartingAt(node.statements, startIndex); - emitTempDeclarations(/*newLine*/ true); - emitExportEquals(/*emitAsReturn*/ false); - } - function emitUMDModule(node) { - emitEmitHelpers(node); - collectExternalModuleInfo(node); - var dependencyNames = getAMDDependencyNames(node, /*includeNonAmdDependencies*/ false); - // Module is detected first to support Browserify users that load into a browser with an AMD loader - writeLines("(function (factory) {\n if (typeof module === 'object' && typeof module.exports === 'object') {\n var v = factory(require, exports); if (v !== undefined) module.exports = v;\n }\n else if (typeof define === 'function' && define.amd) {\n define("); - emitAMDDependencyList(dependencyNames); - write(", factory);"); - writeLines(" }\n})("); - emitAMDFactoryHeader(dependencyNames); - increaseIndent(); - var startIndex = emitDirectivePrologues(node.statements, /*startWithNewLine*/ true); - emitExportStarHelper(); - emitCaptureThisForNodeIfNecessary(node); - emitLinesStartingAt(node.statements, startIndex); - emitTempDeclarations(/*newLine*/ true); - emitExportEquals(/*emitAsReturn*/ true); - decreaseIndent(); - writeLine(); - write("});"); - } - function emitES6Module(node) { - externalImports = undefined; - exportSpecifiers = undefined; - exportEquals = undefined; - hasExportStars = false; - var startIndex = emitDirectivePrologues(node.statements, /*startWithNewLine*/ false); - emitEmitHelpers(node); - emitCaptureThisForNodeIfNecessary(node); - emitLinesStartingAt(node.statements, startIndex); - emitTempDeclarations(/*newLine*/ true); - // Emit exportDefault if it exists will happen as part - // or normal statement emit. - } - function emitExportEquals(emitAsReturn) { - if (exportEquals && resolver.isValueAliasDeclaration(exportEquals)) { - writeLine(); - emitStart(exportEquals); - write(emitAsReturn ? "return " : "module.exports = "); - emit(exportEquals.expression); - write(";"); - emitEnd(exportEquals); - } - } - function emitJsxElement(node) { - switch (compilerOptions.jsx) { - case 2 /* React */: - jsxEmitReact(node); - break; - case 1 /* Preserve */: - // Fall back to preserve if None was specified (we'll error earlier) - default: - jsxEmitPreserve(node); - break; - } - } - function trimReactWhitespaceAndApplyEntities(node) { - var result = undefined; - var text = ts.getTextOfNode(node, /*includeTrivia*/ true); - var firstNonWhitespace = 0; - var lastNonWhitespace = -1; - // JSX trims whitespace at the end and beginning of lines, except that the - // start/end of a tag is considered a start/end of a line only if that line is - // on the same line as the closing tag. See examples in tests/cases/conformance/jsx/tsxReactEmitWhitespace.tsx - for (var i = 0; i < text.length; i++) { - var c = text.charCodeAt(i); - if (ts.isLineBreak(c)) { - if (firstNonWhitespace !== -1 && (lastNonWhitespace - firstNonWhitespace + 1 > 0)) { - var part = text.substr(firstNonWhitespace, lastNonWhitespace - firstNonWhitespace + 1); - result = (result ? result + "\" + ' ' + \"" : "") + ts.escapeString(part); - } - firstNonWhitespace = -1; - } - else if (!ts.isWhiteSpace(c)) { - lastNonWhitespace = i; - if (firstNonWhitespace === -1) { - firstNonWhitespace = i; - } - } - } - if (firstNonWhitespace !== -1) { - var part = text.substr(firstNonWhitespace); - result = (result ? result + "\" + ' ' + \"" : "") + ts.escapeString(part); - } - if (result) { - // Replace entities like   - result = result.replace(/&(\w+);/g, function (s, m) { - if (entities[m] !== undefined) { - return String.fromCharCode(entities[m]); - } - else { - return s; - } - }); - } - return result; - } - function getTextToEmit(node) { - switch (compilerOptions.jsx) { - case 2 /* React */: - var text = trimReactWhitespaceAndApplyEntities(node); - if (text === undefined || text.length === 0) { - return undefined; - } - else { - return text; - } - case 1 /* Preserve */: - default: - return ts.getTextOfNode(node, /*includeTrivia*/ true); - } - } - function emitJsxText(node) { - switch (compilerOptions.jsx) { - case 2 /* React */: - write("\""); - write(trimReactWhitespaceAndApplyEntities(node)); - write("\""); - break; - case 1 /* Preserve */: - default: - writer.writeLiteral(ts.getTextOfNode(node, /*includeTrivia*/ true)); - break; - } - } - function emitJsxExpression(node) { - if (node.expression) { - switch (compilerOptions.jsx) { - case 1 /* Preserve */: - default: - write("{"); - emit(node.expression); - write("}"); - break; - case 2 /* React */: - emit(node.expression); - break; - } - } - } - function emitDirectivePrologues(statements, startWithNewLine) { - for (var i = 0; i < statements.length; ++i) { - if (ts.isPrologueDirective(statements[i])) { - if (startWithNewLine || i > 0) { - writeLine(); - } - emit(statements[i]); - } - else { - // return index of the first non prologue directive - return i; - } - } - return statements.length; - } - function writeLines(text) { - var lines = text.split(/\r\n|\r|\n/g); - for (var i = 0; i < lines.length; ++i) { - var line = lines[i]; - if (line.length) { - writeLine(); - write(line); - } - } - } - function emitEmitHelpers(node) { - // Only emit helpers if the user did not say otherwise. - if (!compilerOptions.noEmitHelpers) { - // Only Emit __extends function when target ES5. - // For target ES6 and above, we can emit classDeclaration as is. - if ((languageVersion < 2 /* ES6 */) && (!extendsEmitted && resolver.getNodeCheckFlags(node) & 8 /* EmitExtends */)) { - writeLines(extendsHelper); - extendsEmitted = true; - } - if (!decorateEmitted && resolver.getNodeCheckFlags(node) & 16 /* EmitDecorate */) { - writeLines(decorateHelper); - if (compilerOptions.emitDecoratorMetadata) { - writeLines(metadataHelper); - } - decorateEmitted = true; - } - if (!paramEmitted && resolver.getNodeCheckFlags(node) & 32 /* EmitParam */) { - writeLines(paramHelper); - paramEmitted = true; - } - if (!awaiterEmitted && resolver.getNodeCheckFlags(node) & 64 /* EmitAwaiter */) { - writeLines(awaiterHelper); - awaiterEmitted = true; - } - } - } - function emitSourceFileNode(node) { - // Start new file on new line - writeLine(); - emitShebang(); - emitDetachedComments(node); - if (ts.isExternalModule(node) || compilerOptions.isolatedModules) { - var emitModule = moduleEmitDelegates[modulekind] || moduleEmitDelegates[1 /* CommonJS */]; - emitModule(node); - } - else { - // emit prologue directives prior to __extends - var startIndex = emitDirectivePrologues(node.statements, /*startWithNewLine*/ false); - externalImports = undefined; - exportSpecifiers = undefined; - exportEquals = undefined; - hasExportStars = false; - emitEmitHelpers(node); - emitCaptureThisForNodeIfNecessary(node); - emitLinesStartingAt(node.statements, startIndex); - emitTempDeclarations(/*newLine*/ true); - } - emitLeadingComments(node.endOfFileToken); - } - function emitNodeWithCommentsAndWithoutSourcemap(node) { - emitNodeConsideringCommentsOption(node, emitNodeWithoutSourceMap); - } - function emitNodeConsideringCommentsOption(node, emitNodeConsideringSourcemap) { - if (node) { - if (node.flags & 2 /* Ambient */) { - return emitCommentsOnNotEmittedNode(node); - } - if (isSpecializedCommentHandling(node)) { - // This is the node that will handle its own comments and sourcemap - return emitNodeWithoutSourceMap(node); - } - var emitComments_1 = shouldEmitLeadingAndTrailingComments(node); - if (emitComments_1) { - emitLeadingComments(node); - } - emitNodeConsideringSourcemap(node); - if (emitComments_1) { - emitTrailingComments(node); - } - } - } - function emitNodeWithoutSourceMap(node) { - if (node) { - emitJavaScriptWorker(node); - } - } - function isSpecializedCommentHandling(node) { - switch (node.kind) { - // All of these entities are emitted in a specialized fashion. As such, we allow - // the specialized methods for each to handle the comments on the nodes. - case 215 /* InterfaceDeclaration */: - case 213 /* FunctionDeclaration */: - case 222 /* ImportDeclaration */: - case 221 /* ImportEqualsDeclaration */: - case 216 /* TypeAliasDeclaration */: - case 227 /* ExportAssignment */: - return true; - } - } - function shouldEmitLeadingAndTrailingComments(node) { - switch (node.kind) { - case 193 /* VariableStatement */: - return shouldEmitLeadingAndTrailingCommentsForVariableStatement(node); - case 218 /* ModuleDeclaration */: - // Only emit the leading/trailing comments for a module if we're actually - // emitting the module as well. - return shouldEmitModuleDeclaration(node); - case 217 /* EnumDeclaration */: - // Only emit the leading/trailing comments for an enum if we're actually - // emitting the module as well. - return shouldEmitEnumDeclaration(node); - } - // If the node is emitted in specialized fashion, dont emit comments as this node will handle - // emitting comments when emitting itself - ts.Debug.assert(!isSpecializedCommentHandling(node)); - // If this is the expression body of an arrow function that we're down-leveling, - // then we don't want to emit comments when we emit the body. It will have already - // been taken care of when we emitted the 'return' statement for the function - // expression body. - if (node.kind !== 192 /* Block */ && - node.parent && - node.parent.kind === 174 /* ArrowFunction */ && - node.parent.body === node && - compilerOptions.target <= 1 /* ES5 */) { - return false; - } - // Emit comments for everything else. - return true; - } - function emitJavaScriptWorker(node) { - // Check if the node can be emitted regardless of the ScriptTarget - switch (node.kind) { - case 69 /* Identifier */: - return emitIdentifier(node); - case 138 /* Parameter */: - return emitParameter(node); - case 143 /* MethodDeclaration */: - case 142 /* MethodSignature */: - return emitMethod(node); - case 145 /* GetAccessor */: - case 146 /* SetAccessor */: - return emitAccessor(node); - case 97 /* ThisKeyword */: - return emitThis(node); - case 95 /* SuperKeyword */: - return emitSuper(node); - case 93 /* NullKeyword */: - return write("null"); - case 99 /* TrueKeyword */: - return write("true"); - case 84 /* FalseKeyword */: - return write("false"); - case 8 /* NumericLiteral */: - case 9 /* StringLiteral */: - case 10 /* RegularExpressionLiteral */: - case 11 /* NoSubstitutionTemplateLiteral */: - case 12 /* TemplateHead */: - case 13 /* TemplateMiddle */: - case 14 /* TemplateTail */: - return emitLiteral(node); - case 183 /* TemplateExpression */: - return emitTemplateExpression(node); - case 190 /* TemplateSpan */: - return emitTemplateSpan(node); - case 233 /* JsxElement */: - case 234 /* JsxSelfClosingElement */: - return emitJsxElement(node); - case 236 /* JsxText */: - return emitJsxText(node); - case 240 /* JsxExpression */: - return emitJsxExpression(node); - case 135 /* QualifiedName */: - return emitQualifiedName(node); - case 161 /* ObjectBindingPattern */: - return emitObjectBindingPattern(node); - case 162 /* ArrayBindingPattern */: - return emitArrayBindingPattern(node); - case 163 /* BindingElement */: - return emitBindingElement(node); - case 164 /* ArrayLiteralExpression */: - return emitArrayLiteral(node); - case 165 /* ObjectLiteralExpression */: - return emitObjectLiteral(node); - case 245 /* PropertyAssignment */: - return emitPropertyAssignment(node); - case 246 /* ShorthandPropertyAssignment */: - return emitShorthandPropertyAssignment(node); - case 136 /* ComputedPropertyName */: - return emitComputedPropertyName(node); - case 166 /* PropertyAccessExpression */: - return emitPropertyAccess(node); - case 167 /* ElementAccessExpression */: - return emitIndexedAccess(node); - case 168 /* CallExpression */: - return emitCallExpression(node); - case 169 /* NewExpression */: - return emitNewExpression(node); - case 170 /* TaggedTemplateExpression */: - return emitTaggedTemplateExpression(node); - case 171 /* TypeAssertionExpression */: - return emit(node.expression); - case 189 /* AsExpression */: - return emit(node.expression); - case 172 /* ParenthesizedExpression */: - return emitParenExpression(node); - case 213 /* FunctionDeclaration */: - case 173 /* FunctionExpression */: - case 174 /* ArrowFunction */: - return emitFunctionDeclaration(node); - case 175 /* DeleteExpression */: - return emitDeleteExpression(node); - case 176 /* TypeOfExpression */: - return emitTypeOfExpression(node); - case 177 /* VoidExpression */: - return emitVoidExpression(node); - case 178 /* AwaitExpression */: - return emitAwaitExpression(node); - case 179 /* PrefixUnaryExpression */: - return emitPrefixUnaryExpression(node); - case 180 /* PostfixUnaryExpression */: - return emitPostfixUnaryExpression(node); - case 181 /* BinaryExpression */: - return emitBinaryExpression(node); - case 182 /* ConditionalExpression */: - return emitConditionalExpression(node); - case 185 /* SpreadElementExpression */: - return emitSpreadElementExpression(node); - case 184 /* YieldExpression */: - return emitYieldExpression(node); - case 187 /* OmittedExpression */: - return; - case 192 /* Block */: - case 219 /* ModuleBlock */: - return emitBlock(node); - case 193 /* VariableStatement */: - return emitVariableStatement(node); - case 194 /* EmptyStatement */: - return write(";"); - case 195 /* ExpressionStatement */: - return emitExpressionStatement(node); - case 196 /* IfStatement */: - return emitIfStatement(node); - case 197 /* DoStatement */: - return emitDoStatement(node); - case 198 /* WhileStatement */: - return emitWhileStatement(node); - case 199 /* ForStatement */: - return emitForStatement(node); - case 201 /* ForOfStatement */: - case 200 /* ForInStatement */: - return emitForInOrForOfStatement(node); - case 202 /* ContinueStatement */: - case 203 /* BreakStatement */: - return emitBreakOrContinueStatement(node); - case 204 /* ReturnStatement */: - return emitReturnStatement(node); - case 205 /* WithStatement */: - return emitWithStatement(node); - case 206 /* SwitchStatement */: - return emitSwitchStatement(node); - case 241 /* CaseClause */: - case 242 /* DefaultClause */: - return emitCaseOrDefaultClause(node); - case 207 /* LabeledStatement */: - return emitLabelledStatement(node); - case 208 /* ThrowStatement */: - return emitThrowStatement(node); - case 209 /* TryStatement */: - return emitTryStatement(node); - case 244 /* CatchClause */: - return emitCatchClause(node); - case 210 /* DebuggerStatement */: - return emitDebuggerStatement(node); - case 211 /* VariableDeclaration */: - return emitVariableDeclaration(node); - case 186 /* ClassExpression */: - return emitClassExpression(node); - case 214 /* ClassDeclaration */: - return emitClassDeclaration(node); - case 215 /* InterfaceDeclaration */: - return emitInterfaceDeclaration(node); - case 217 /* EnumDeclaration */: - return emitEnumDeclaration(node); - case 247 /* EnumMember */: - return emitEnumMember(node); - case 218 /* ModuleDeclaration */: - return emitModuleDeclaration(node); - case 222 /* ImportDeclaration */: - return emitImportDeclaration(node); - case 221 /* ImportEqualsDeclaration */: - return emitImportEqualsDeclaration(node); - case 228 /* ExportDeclaration */: - return emitExportDeclaration(node); - case 227 /* ExportAssignment */: - return emitExportAssignment(node); - case 248 /* SourceFile */: - return emitSourceFileNode(node); - } - } - function hasDetachedComments(pos) { - return detachedCommentsInfo !== undefined && ts.lastOrUndefined(detachedCommentsInfo).nodePos === pos; - } - function getLeadingCommentsWithoutDetachedComments() { - // get the leading comments from detachedPos - var leadingComments = ts.getLeadingCommentRanges(currentSourceFile.text, ts.lastOrUndefined(detachedCommentsInfo).detachedCommentEndPos); - if (detachedCommentsInfo.length - 1) { - detachedCommentsInfo.pop(); - } - else { - detachedCommentsInfo = undefined; - } - return leadingComments; - } - function isPinnedComments(comment) { - return currentSourceFile.text.charCodeAt(comment.pos + 1) === 42 /* asterisk */ && - currentSourceFile.text.charCodeAt(comment.pos + 2) === 33 /* exclamation */; - } - /** - * Determine if the given comment is a triple-slash - * - * @return true if the comment is a triple-slash comment else false - **/ - function isTripleSlashComment(comment) { - // Verify this is /// comment, but do the regexp match only when we first can find /// in the comment text - // so that we don't end up computing comment string and doing match for all // comments - if (currentSourceFile.text.charCodeAt(comment.pos + 1) === 47 /* slash */ && - comment.pos + 2 < comment.end && - currentSourceFile.text.charCodeAt(comment.pos + 2) === 47 /* slash */) { - var textSubStr = currentSourceFile.text.substring(comment.pos, comment.end); - return textSubStr.match(ts.fullTripleSlashReferencePathRegEx) || - textSubStr.match(ts.fullTripleSlashAMDReferencePathRegEx) ? - true : false; - } - return false; - } - function getLeadingCommentsToEmit(node) { - // Emit the leading comments only if the parent's pos doesn't match because parent should take care of emitting these comments - if (node.parent) { - if (node.parent.kind === 248 /* SourceFile */ || node.pos !== node.parent.pos) { - if (hasDetachedComments(node.pos)) { - // get comments without detached comments - return getLeadingCommentsWithoutDetachedComments(); - } - else { - // get the leading comments from the node - return ts.getLeadingCommentRangesOfNode(node, currentSourceFile); - } - } - } - } - function getTrailingCommentsToEmit(node) { - // Emit the trailing comments only if the parent's pos doesn't match because parent should take care of emitting these comments - if (node.parent) { - if (node.parent.kind === 248 /* SourceFile */ || node.end !== node.parent.end) { - return ts.getTrailingCommentRanges(currentSourceFile.text, node.end); - } - } - } - /** - * Emit comments associated with node that will not be emitted into JS file - */ - function emitCommentsOnNotEmittedNode(node) { - emitLeadingCommentsWorker(node, /*isEmittedNode:*/ false); - } - function emitLeadingComments(node) { - return emitLeadingCommentsWorker(node, /*isEmittedNode:*/ true); - } - function emitLeadingCommentsWorker(node, isEmittedNode) { - if (compilerOptions.removeComments) { - return; - } - var leadingComments; - if (isEmittedNode) { - leadingComments = getLeadingCommentsToEmit(node); - } - else { - // If the node will not be emitted in JS, remove all the comments(normal, pinned and ///) associated with the node, - // unless it is a triple slash comment at the top of the file. - // For Example: - // /// - // declare var x; - // /// - // interface F {} - // The first /// will NOT be removed while the second one will be removed eventhough both node will not be emitted - if (node.pos === 0) { - leadingComments = ts.filter(getLeadingCommentsToEmit(node), isTripleSlashComment); - } - } - ts.emitNewLineBeforeLeadingComments(currentSourceFile, writer, node, leadingComments); - // Leading comments are emitted at /*leading comment1 */space/*leading comment*/space - ts.emitComments(currentSourceFile, writer, leadingComments, /*trailingSeparator:*/ true, newLine, writeComment); - } - function emitTrailingComments(node) { - if (compilerOptions.removeComments) { - return; - } - // Emit the trailing comments only if the parent's end doesn't match - var trailingComments = getTrailingCommentsToEmit(node); - // trailing comments are emitted at space/*trailing comment1 */space/*trailing comment*/ - ts.emitComments(currentSourceFile, writer, trailingComments, /*trailingSeparator*/ false, newLine, writeComment); - } - /** - * Emit trailing comments at the position. The term trailing comment is used here to describe following comment: - * x, /comment1/ y - * ^ => pos; the function will emit "comment1" in the emitJS - */ - function emitTrailingCommentsOfPosition(pos) { - if (compilerOptions.removeComments) { - return; - } - var trailingComments = ts.getTrailingCommentRanges(currentSourceFile.text, pos); - // trailing comments are emitted at space/*trailing comment1 */space/*trailing comment*/ - ts.emitComments(currentSourceFile, writer, trailingComments, /*trailingSeparator*/ true, newLine, writeComment); - } - function emitLeadingCommentsOfPositionWorker(pos) { - if (compilerOptions.removeComments) { - return; - } - var leadingComments; - if (hasDetachedComments(pos)) { - // get comments without detached comments - leadingComments = getLeadingCommentsWithoutDetachedComments(); - } - else { - // get the leading comments from the node - leadingComments = ts.getLeadingCommentRanges(currentSourceFile.text, pos); - } - ts.emitNewLineBeforeLeadingComments(currentSourceFile, writer, { pos: pos, end: pos }, leadingComments); - // Leading comments are emitted at /*leading comment1 */space/*leading comment*/space - ts.emitComments(currentSourceFile, writer, leadingComments, /*trailingSeparator*/ true, newLine, writeComment); - } - function emitDetachedComments(node) { - var leadingComments; - if (compilerOptions.removeComments) { - // removeComments is true, only reserve pinned comment at the top of file - // For example: - // /*! Pinned Comment */ - // - // var x = 10; - if (node.pos === 0) { - leadingComments = ts.filter(ts.getLeadingCommentRanges(currentSourceFile.text, node.pos), isPinnedComments); - } - } - else { - // removeComments is false, just get detached as normal and bypass the process to filter comment - leadingComments = ts.getLeadingCommentRanges(currentSourceFile.text, node.pos); - } - if (leadingComments) { - var detachedComments = []; - var lastComment; - ts.forEach(leadingComments, function (comment) { - if (lastComment) { - var lastCommentLine = ts.getLineOfLocalPosition(currentSourceFile, lastComment.end); - var commentLine = ts.getLineOfLocalPosition(currentSourceFile, comment.pos); - if (commentLine >= lastCommentLine + 2) { - // There was a blank line between the last comment and this comment. This - // comment is not part of the copyright comments. Return what we have so - // far. - return detachedComments; - } - } - detachedComments.push(comment); - lastComment = comment; - }); - if (detachedComments.length) { - // All comments look like they could have been part of the copyright header. Make - // sure there is at least one blank line between it and the node. If not, it's not - // a copyright header. - var lastCommentLine = ts.getLineOfLocalPosition(currentSourceFile, ts.lastOrUndefined(detachedComments).end); - var nodeLine = ts.getLineOfLocalPosition(currentSourceFile, ts.skipTrivia(currentSourceFile.text, node.pos)); - if (nodeLine >= lastCommentLine + 2) { - // Valid detachedComments - ts.emitNewLineBeforeLeadingComments(currentSourceFile, writer, node, leadingComments); - ts.emitComments(currentSourceFile, writer, detachedComments, /*trailingSeparator*/ true, newLine, writeComment); - var currentDetachedCommentInfo = { nodePos: node.pos, detachedCommentEndPos: ts.lastOrUndefined(detachedComments).end }; - if (detachedCommentsInfo) { - detachedCommentsInfo.push(currentDetachedCommentInfo); - } - else { - detachedCommentsInfo = [currentDetachedCommentInfo]; - } - } - } - } - } - function emitShebang() { - var shebang = ts.getShebang(currentSourceFile.text); - if (shebang) { - write(shebang); - } - } - var _a; - } - function emitFile(jsFilePath, sourceFile) { - emitJavaScript(jsFilePath, sourceFile); - if (compilerOptions.declaration) { - ts.writeDeclarationFile(jsFilePath, sourceFile, host, resolver, diagnostics); - } - } - } - ts.emitFiles = emitFiles; -})(ts || (ts = {})); -/// -/// -/// -var ts; -(function (ts) { - /* @internal */ ts.programTime = 0; - /* @internal */ ts.emitTime = 0; - /* @internal */ ts.ioReadTime = 0; - /* @internal */ ts.ioWriteTime = 0; - /** The version of the TypeScript compiler release */ - var emptyArray = []; - ts.version = "1.8.0"; - function findConfigFile(searchPath) { - var fileName = "tsconfig.json"; - while (true) { - if (ts.sys.fileExists(fileName)) { - return fileName; - } - var parentPath = ts.getDirectoryPath(searchPath); - if (parentPath === searchPath) { - break; - } - searchPath = parentPath; - fileName = "../" + fileName; - } - return undefined; - } - ts.findConfigFile = findConfigFile; - function resolveTripleslashReference(moduleName, containingFile) { - var basePath = ts.getDirectoryPath(containingFile); - var referencedFileName = ts.isRootedDiskPath(moduleName) ? moduleName : ts.combinePaths(basePath, moduleName); - return ts.normalizePath(referencedFileName); - } - ts.resolveTripleslashReference = resolveTripleslashReference; - function resolveModuleName(moduleName, containingFile, compilerOptions, host) { - var moduleResolution = compilerOptions.moduleResolution !== undefined - ? compilerOptions.moduleResolution - : compilerOptions.module === 1 /* CommonJS */ ? 2 /* NodeJs */ : 1 /* Classic */; - switch (moduleResolution) { - case 2 /* NodeJs */: return nodeModuleNameResolver(moduleName, containingFile, host); - case 1 /* Classic */: return classicNameResolver(moduleName, containingFile, compilerOptions, host); - } - } - ts.resolveModuleName = resolveModuleName; - function nodeModuleNameResolver(moduleName, containingFile, host) { - var containingDirectory = ts.getDirectoryPath(containingFile); - if (ts.getRootLength(moduleName) !== 0 || nameStartsWithDotSlashOrDotDotSlash(moduleName)) { - var failedLookupLocations = []; - var candidate = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName)); - var resolvedFileName = loadNodeModuleFromFile(candidate, failedLookupLocations, host); - if (resolvedFileName) { - return { resolvedModule: { resolvedFileName: resolvedFileName }, failedLookupLocations: failedLookupLocations }; - } - resolvedFileName = loadNodeModuleFromDirectory(candidate, failedLookupLocations, host); - return resolvedFileName - ? { resolvedModule: { resolvedFileName: resolvedFileName }, failedLookupLocations: failedLookupLocations } - : { resolvedModule: undefined, failedLookupLocations: failedLookupLocations }; - } - else { - return loadModuleFromNodeModules(moduleName, containingDirectory, host); - } - } - ts.nodeModuleNameResolver = nodeModuleNameResolver; - function loadNodeModuleFromFile(candidate, failedLookupLocation, host) { - return ts.forEach(ts.moduleFileExtensions, tryLoad); - function tryLoad(ext) { - var fileName = ts.fileExtensionIs(candidate, ext) ? candidate : candidate + ext; - if (host.fileExists(fileName)) { - return fileName; - } - else { - failedLookupLocation.push(fileName); - return undefined; - } - } - } - function loadNodeModuleFromDirectory(candidate, failedLookupLocation, host) { - var packageJsonPath = ts.combinePaths(candidate, "package.json"); - if (host.fileExists(packageJsonPath)) { - var jsonContent; - try { - var jsonText = host.readFile(packageJsonPath); - jsonContent = jsonText ? JSON.parse(jsonText) : { typings: undefined }; - } - catch (e) { - // gracefully handle if readFile fails or returns not JSON - jsonContent = { typings: undefined }; - } - if (jsonContent.typings) { - var result = loadNodeModuleFromFile(ts.normalizePath(ts.combinePaths(candidate, jsonContent.typings)), failedLookupLocation, host); - if (result) { - return result; - } - } - } - else { - // record package json as one of failed lookup locations - in the future if this file will appear it will invalidate resolution results - failedLookupLocation.push(packageJsonPath); - } - return loadNodeModuleFromFile(ts.combinePaths(candidate, "index"), failedLookupLocation, host); - } - function loadModuleFromNodeModules(moduleName, directory, host) { - var failedLookupLocations = []; - directory = ts.normalizeSlashes(directory); - while (true) { - var baseName = ts.getBaseFileName(directory); - if (baseName !== "node_modules") { - var nodeModulesFolder = ts.combinePaths(directory, "node_modules"); - var candidate = ts.normalizePath(ts.combinePaths(nodeModulesFolder, moduleName)); - var result = loadNodeModuleFromFile(candidate, failedLookupLocations, host); - if (result) { - return { resolvedModule: { resolvedFileName: result, isExternalLibraryImport: true }, failedLookupLocations: failedLookupLocations }; - } - result = loadNodeModuleFromDirectory(candidate, failedLookupLocations, host); - if (result) { - return { resolvedModule: { resolvedFileName: result, isExternalLibraryImport: true }, failedLookupLocations: failedLookupLocations }; - } - } - var parentPath = ts.getDirectoryPath(directory); - if (parentPath === directory) { - break; - } - directory = parentPath; - } - return { resolvedModule: undefined, failedLookupLocations: failedLookupLocations }; - } - function nameStartsWithDotSlashOrDotDotSlash(name) { - var i = name.lastIndexOf("./", 1); - return i === 0 || (i === 1 && name.charCodeAt(0) === 46 /* dot */); - } - function classicNameResolver(moduleName, containingFile, compilerOptions, host) { - // module names that contain '!' are used to reference resources and are not resolved to actual files on disk - if (moduleName.indexOf("!") != -1) { - return { resolvedModule: undefined, failedLookupLocations: [] }; - } - var searchPath = ts.getDirectoryPath(containingFile); - var searchName; - var failedLookupLocations = []; - var referencedSourceFile; - while (true) { - searchName = ts.normalizePath(ts.combinePaths(searchPath, moduleName)); - referencedSourceFile = ts.forEach(ts.supportedExtensions, function (extension) { - if (extension === ".tsx" && !compilerOptions.jsx) { - // resolve .tsx files only if jsx support is enabled - // 'logical not' handles both undefined and None cases - return undefined; - } - var candidate = searchName + extension; - if (host.fileExists(candidate)) { - return candidate; - } - else { - failedLookupLocations.push(candidate); - } - }); - if (referencedSourceFile) { - break; - } - var parentPath = ts.getDirectoryPath(searchPath); - if (parentPath === searchPath) { - break; - } - searchPath = parentPath; - } - return referencedSourceFile - ? { resolvedModule: { resolvedFileName: referencedSourceFile }, failedLookupLocations: failedLookupLocations } - : { resolvedModule: undefined, failedLookupLocations: failedLookupLocations }; - } - ts.classicNameResolver = classicNameResolver; - /* @internal */ - ts.defaultInitCompilerOptions = { - module: 1 /* CommonJS */, - target: 0 /* ES3 */, - noImplicitAny: false, - outDir: "built", - rootDir: ".", - sourceMap: false - }; - function createCompilerHost(options, setParentNodes) { - var currentDirectory; - var existingDirectories = {}; - function getCanonicalFileName(fileName) { - // if underlying system can distinguish between two files whose names differs only in cases then file name already in canonical form. - // otherwise use toLowerCase as a canonical form. - return ts.sys.useCaseSensitiveFileNames ? fileName : fileName.toLowerCase(); - } - // returned by CScript sys environment - var unsupportedFileEncodingErrorCode = -2147024809; - function getSourceFile(fileName, languageVersion, onError) { - var text; - try { - var start = new Date().getTime(); - text = ts.sys.readFile(fileName, options.charset); - ts.ioReadTime += new Date().getTime() - start; - } - catch (e) { - if (onError) { - onError(e.number === unsupportedFileEncodingErrorCode - ? ts.createCompilerDiagnostic(ts.Diagnostics.Unsupported_file_encoding).messageText - : e.message); - } - text = ""; - } - return text !== undefined ? ts.createSourceFile(fileName, text, languageVersion, setParentNodes) : undefined; - } - function directoryExists(directoryPath) { - if (ts.hasProperty(existingDirectories, directoryPath)) { - return true; - } - if (ts.sys.directoryExists(directoryPath)) { - existingDirectories[directoryPath] = true; - return true; - } - return false; - } - function ensureDirectoriesExist(directoryPath) { - if (directoryPath.length > ts.getRootLength(directoryPath) && !directoryExists(directoryPath)) { - var parentDirectory = ts.getDirectoryPath(directoryPath); - ensureDirectoriesExist(parentDirectory); - ts.sys.createDirectory(directoryPath); - } - } - function writeFile(fileName, data, writeByteOrderMark, onError) { - try { - var start = new Date().getTime(); - ensureDirectoriesExist(ts.getDirectoryPath(ts.normalizePath(fileName))); - ts.sys.writeFile(fileName, data, writeByteOrderMark); - ts.ioWriteTime += new Date().getTime() - start; - } - catch (e) { - if (onError) { - onError(e.message); - } - } - } - var newLine = ts.getNewLineCharacter(options); - return { - getSourceFile: getSourceFile, - getDefaultLibFileName: function (options) { return ts.combinePaths(ts.getDirectoryPath(ts.normalizePath(ts.sys.getExecutingFilePath())), ts.getDefaultLibFileName(options)); }, - writeFile: writeFile, - getCurrentDirectory: function () { return currentDirectory || (currentDirectory = ts.sys.getCurrentDirectory()); }, - useCaseSensitiveFileNames: function () { return ts.sys.useCaseSensitiveFileNames; }, - getCanonicalFileName: getCanonicalFileName, - getNewLine: function () { return newLine; }, - fileExists: function (fileName) { return ts.sys.fileExists(fileName); }, - readFile: function (fileName) { return ts.sys.readFile(fileName); } - }; - } - ts.createCompilerHost = createCompilerHost; - function getPreEmitDiagnostics(program, sourceFile, cancellationToken) { - var diagnostics = program.getOptionsDiagnostics(cancellationToken).concat(program.getSyntacticDiagnostics(sourceFile, cancellationToken), program.getGlobalDiagnostics(cancellationToken), program.getSemanticDiagnostics(sourceFile, cancellationToken)); - if (program.getCompilerOptions().declaration) { - diagnostics.concat(program.getDeclarationDiagnostics(sourceFile, cancellationToken)); - } - return ts.sortAndDeduplicateDiagnostics(diagnostics); - } - ts.getPreEmitDiagnostics = getPreEmitDiagnostics; - function flattenDiagnosticMessageText(messageText, newLine) { - if (typeof messageText === "string") { - return messageText; - } - else { - var diagnosticChain = messageText; - var result = ""; - var indent = 0; - while (diagnosticChain) { - if (indent) { - result += newLine; - for (var i = 0; i < indent; i++) { - result += " "; - } - } - result += diagnosticChain.messageText; - indent++; - diagnosticChain = diagnosticChain.next; - } - return result; - } - } - ts.flattenDiagnosticMessageText = flattenDiagnosticMessageText; - function createProgram(rootNames, options, host, oldProgram) { - var program; - var files = []; - var fileProcessingDiagnostics = ts.createDiagnosticCollection(); - var programDiagnostics = ts.createDiagnosticCollection(); - var commonSourceDirectory; - var diagnosticsProducingTypeChecker; - var noDiagnosticsTypeChecker; - var classifiableNames; - var skipDefaultLib = options.noLib; - var start = new Date().getTime(); - host = host || createCompilerHost(options); - var resolveModuleNamesWorker = host.resolveModuleNames - ? (function (moduleNames, containingFile) { return host.resolveModuleNames(moduleNames, containingFile); }) - : (function (moduleNames, containingFile) { return ts.map(moduleNames, function (moduleName) { return resolveModuleName(moduleName, containingFile, options, host).resolvedModule; }); }); - var filesByName = ts.createFileMap(function (fileName) { return host.getCanonicalFileName(fileName); }); - if (oldProgram) { - // check properties that can affect structure of the program or module resolution strategy - // if any of these properties has changed - structure cannot be reused - var oldOptions = oldProgram.getCompilerOptions(); - if ((oldOptions.module !== options.module) || - (oldOptions.noResolve !== options.noResolve) || - (oldOptions.target !== options.target) || - (oldOptions.noLib !== options.noLib) || - (oldOptions.jsx !== options.jsx)) { - oldProgram = undefined; - } - } - if (!tryReuseStructureFromOldProgram()) { - ts.forEach(rootNames, function (name) { return processRootFile(name, false); }); - // Do not process the default library if: - // - The '--noLib' flag is used. - // - A 'no-default-lib' reference comment is encountered in - // processing the root files. - if (!skipDefaultLib) { - processRootFile(host.getDefaultLibFileName(options), true); - } - } - verifyCompilerOptions(); - // unconditionally set oldProgram to undefined to prevent it from being captured in closure - oldProgram = undefined; - ts.programTime += new Date().getTime() - start; - program = { - getRootFileNames: function () { return rootNames; }, - getSourceFile: getSourceFile, - getSourceFiles: function () { return files; }, - getCompilerOptions: function () { return options; }, - getSyntacticDiagnostics: getSyntacticDiagnostics, - getOptionsDiagnostics: getOptionsDiagnostics, - getGlobalDiagnostics: getGlobalDiagnostics, - getSemanticDiagnostics: getSemanticDiagnostics, - getDeclarationDiagnostics: getDeclarationDiagnostics, - getTypeChecker: getTypeChecker, - getClassifiableNames: getClassifiableNames, - getDiagnosticsProducingTypeChecker: getDiagnosticsProducingTypeChecker, - getCommonSourceDirectory: function () { return commonSourceDirectory; }, - emit: emit, - getCurrentDirectory: function () { return host.getCurrentDirectory(); }, - getNodeCount: function () { return getDiagnosticsProducingTypeChecker().getNodeCount(); }, - getIdentifierCount: function () { return getDiagnosticsProducingTypeChecker().getIdentifierCount(); }, - getSymbolCount: function () { return getDiagnosticsProducingTypeChecker().getSymbolCount(); }, - getTypeCount: function () { return getDiagnosticsProducingTypeChecker().getTypeCount(); }, - getFileProcessingDiagnostics: function () { return fileProcessingDiagnostics; } - }; - return program; - function getClassifiableNames() { - if (!classifiableNames) { - // Initialize a checker so that all our files are bound. - getTypeChecker(); - classifiableNames = {}; - for (var _i = 0; _i < files.length; _i++) { - var sourceFile = files[_i]; - ts.copyMap(sourceFile.classifiableNames, classifiableNames); - } - } - return classifiableNames; - } - function tryReuseStructureFromOldProgram() { - if (!oldProgram) { - return false; - } - ts.Debug.assert(!oldProgram.structureIsReused); - // there is an old program, check if we can reuse its structure - var oldRootNames = oldProgram.getRootFileNames(); - if (!ts.arrayIsEqualTo(oldRootNames, rootNames)) { - return false; - } - // check if program source files has changed in the way that can affect structure of the program - var newSourceFiles = []; - var modifiedSourceFiles = []; - for (var _i = 0, _a = oldProgram.getSourceFiles(); _i < _a.length; _i++) { - var oldSourceFile = _a[_i]; - var newSourceFile = host.getSourceFile(oldSourceFile.fileName, options.target); - if (!newSourceFile) { - return false; - } - if (oldSourceFile !== newSourceFile) { - if (oldSourceFile.hasNoDefaultLib !== newSourceFile.hasNoDefaultLib) { - // value of no-default-lib has changed - // this will affect if default library is injected into the list of files - return false; - } - // check tripleslash references - if (!ts.arrayIsEqualTo(oldSourceFile.referencedFiles, newSourceFile.referencedFiles, fileReferenceIsEqualTo)) { - // tripleslash references has changed - return false; - } - // check imports - collectExternalModuleReferences(newSourceFile); - if (!ts.arrayIsEqualTo(oldSourceFile.imports, newSourceFile.imports, moduleNameIsEqualTo)) { - // imports has changed - return false; - } - if (resolveModuleNamesWorker) { - var moduleNames = ts.map(newSourceFile.imports, function (name) { return name.text; }); - var resolutions = resolveModuleNamesWorker(moduleNames, newSourceFile.fileName); - // ensure that module resolution results are still correct - for (var i = 0; i < moduleNames.length; ++i) { - var newResolution = resolutions[i]; - var oldResolution = ts.getResolvedModule(oldSourceFile, moduleNames[i]); - var resolutionChanged = oldResolution - ? !newResolution || - oldResolution.resolvedFileName !== newResolution.resolvedFileName || - !!oldResolution.isExternalLibraryImport !== !!newResolution.isExternalLibraryImport - : newResolution; - if (resolutionChanged) { - return false; - } - } - } - // pass the cache of module resolutions from the old source file - newSourceFile.resolvedModules = oldSourceFile.resolvedModules; - modifiedSourceFiles.push(newSourceFile); - } - else { - // file has no changes - use it as is - newSourceFile = oldSourceFile; - } - // if file has passed all checks it should be safe to reuse it - newSourceFiles.push(newSourceFile); - } - // update fileName -> file mapping - for (var _b = 0; _b < newSourceFiles.length; _b++) { - var file = newSourceFiles[_b]; - filesByName.set(file.fileName, file); - } - files = newSourceFiles; - fileProcessingDiagnostics = oldProgram.getFileProcessingDiagnostics(); - for (var _c = 0; _c < modifiedSourceFiles.length; _c++) { - var modifiedFile = modifiedSourceFiles[_c]; - fileProcessingDiagnostics.reattachFileDiagnostics(modifiedFile); - } - oldProgram.structureIsReused = true; - return true; - } - function getEmitHost(writeFileCallback) { - return { - getCanonicalFileName: function (fileName) { return host.getCanonicalFileName(fileName); }, - getCommonSourceDirectory: program.getCommonSourceDirectory, - getCompilerOptions: program.getCompilerOptions, - getCurrentDirectory: function () { return host.getCurrentDirectory(); }, - getNewLine: function () { return host.getNewLine(); }, - getSourceFile: program.getSourceFile, - getSourceFiles: program.getSourceFiles, - writeFile: writeFileCallback || (function (fileName, data, writeByteOrderMark, onError) { return host.writeFile(fileName, data, writeByteOrderMark, onError); }) - }; - } - function getDiagnosticsProducingTypeChecker() { - return diagnosticsProducingTypeChecker || (diagnosticsProducingTypeChecker = ts.createTypeChecker(program, /*produceDiagnostics:*/ true)); - } - function getTypeChecker() { - return noDiagnosticsTypeChecker || (noDiagnosticsTypeChecker = ts.createTypeChecker(program, /*produceDiagnostics:*/ false)); - } - function emit(sourceFile, writeFileCallback, cancellationToken) { - var _this = this; - return runWithCancellationToken(function () { return emitWorker(_this, sourceFile, writeFileCallback, cancellationToken); }); - } - function emitWorker(program, sourceFile, writeFileCallback, cancellationToken) { - // If the noEmitOnError flag is set, then check if we have any errors so far. If so, - // immediately bail out. Note that we pass 'undefined' for 'sourceFile' so that we - // get any preEmit diagnostics, not just the ones - if (options.noEmitOnError && getPreEmitDiagnostics(program, /*sourceFile:*/ undefined, cancellationToken).length > 0) { - return { diagnostics: [], sourceMaps: undefined, emitSkipped: true }; - } - // Create the emit resolver outside of the "emitTime" tracking code below. That way - // any cost associated with it (like type checking) are appropriate associated with - // the type-checking counter. - // - // If the -out option is specified, we should not pass the source file to getEmitResolver. - // This is because in the -out scenario all files need to be emitted, and therefore all - // files need to be type checked. And the way to specify that all files need to be type - // checked is to not pass the file to getEmitResolver. - var emitResolver = getDiagnosticsProducingTypeChecker().getEmitResolver((options.outFile || options.out) ? undefined : sourceFile); - var start = new Date().getTime(); - var emitResult = ts.emitFiles(emitResolver, getEmitHost(writeFileCallback), sourceFile); - ts.emitTime += new Date().getTime() - start; - return emitResult; - } - function getSourceFile(fileName) { - // first try to use file name as is to find file - // then try to convert relative file name to absolute and use it to retrieve source file - return filesByName.get(fileName) || filesByName.get(ts.getNormalizedAbsolutePath(fileName, host.getCurrentDirectory())); - } - function getDiagnosticsHelper(sourceFile, getDiagnostics, cancellationToken) { - if (sourceFile) { - return getDiagnostics(sourceFile, cancellationToken); - } - var allDiagnostics = []; - ts.forEach(program.getSourceFiles(), function (sourceFile) { - if (cancellationToken) { - cancellationToken.throwIfCancellationRequested(); - } - ts.addRange(allDiagnostics, getDiagnostics(sourceFile, cancellationToken)); - }); - return ts.sortAndDeduplicateDiagnostics(allDiagnostics); - } - function getSyntacticDiagnostics(sourceFile, cancellationToken) { - return getDiagnosticsHelper(sourceFile, getSyntacticDiagnosticsForFile, cancellationToken); - } - function getSemanticDiagnostics(sourceFile, cancellationToken) { - return getDiagnosticsHelper(sourceFile, getSemanticDiagnosticsForFile, cancellationToken); - } - function getDeclarationDiagnostics(sourceFile, cancellationToken) { - return getDiagnosticsHelper(sourceFile, getDeclarationDiagnosticsForFile, cancellationToken); - } - function getSyntacticDiagnosticsForFile(sourceFile, cancellationToken) { - return sourceFile.parseDiagnostics; - } - function runWithCancellationToken(func) { - try { - return func(); - } - catch (e) { - if (e instanceof ts.OperationCanceledException) { - // We were canceled while performing the operation. Because our type checker - // might be a bad state, we need to throw it away. - // - // Note: we are overly agressive here. We do not actually *have* to throw away - // the "noDiagnosticsTypeChecker". However, for simplicity, i'd like to keep - // the lifetimes of these two TypeCheckers the same. Also, we generally only - // cancel when the user has made a change anyways. And, in that case, we (the - // program instance) will get thrown away anyways. So trying to keep one of - // these type checkers alive doesn't serve much purpose. - noDiagnosticsTypeChecker = undefined; - diagnosticsProducingTypeChecker = undefined; - } - throw e; - } - } - function getSemanticDiagnosticsForFile(sourceFile, cancellationToken) { - return runWithCancellationToken(function () { - var typeChecker = getDiagnosticsProducingTypeChecker(); - ts.Debug.assert(!!sourceFile.bindDiagnostics); - var bindDiagnostics = sourceFile.bindDiagnostics; - var checkDiagnostics = typeChecker.getDiagnostics(sourceFile, cancellationToken); - var fileProcessingDiagnosticsInFile = fileProcessingDiagnostics.getDiagnostics(sourceFile.fileName); - var programDiagnosticsInFile = programDiagnostics.getDiagnostics(sourceFile.fileName); - return bindDiagnostics.concat(checkDiagnostics).concat(fileProcessingDiagnosticsInFile).concat(programDiagnosticsInFile); - }); - } - function getDeclarationDiagnosticsForFile(sourceFile, cancellationToken) { - return runWithCancellationToken(function () { - if (!ts.isDeclarationFile(sourceFile)) { - var resolver = getDiagnosticsProducingTypeChecker().getEmitResolver(sourceFile, cancellationToken); - // Don't actually write any files since we're just getting diagnostics. - var writeFile_1 = function () { }; - return ts.getDeclarationDiagnostics(getEmitHost(writeFile_1), resolver, sourceFile); - } - }); - } - function getOptionsDiagnostics() { - var allDiagnostics = []; - ts.addRange(allDiagnostics, fileProcessingDiagnostics.getGlobalDiagnostics()); - ts.addRange(allDiagnostics, programDiagnostics.getGlobalDiagnostics()); - return ts.sortAndDeduplicateDiagnostics(allDiagnostics); - } - function getGlobalDiagnostics() { - var allDiagnostics = []; - ts.addRange(allDiagnostics, getDiagnosticsProducingTypeChecker().getGlobalDiagnostics()); - return ts.sortAndDeduplicateDiagnostics(allDiagnostics); - } - function hasExtension(fileName) { - return ts.getBaseFileName(fileName).indexOf(".") >= 0; - } - function processRootFile(fileName, isDefaultLib) { - processSourceFile(ts.normalizePath(fileName), isDefaultLib); - } - function fileReferenceIsEqualTo(a, b) { - return a.fileName === b.fileName; - } - function moduleNameIsEqualTo(a, b) { - return a.text === b.text; - } - function collectExternalModuleReferences(file) { - if (file.imports) { - return; - } - var imports; - for (var _i = 0, _a = file.statements; _i < _a.length; _i++) { - var node = _a[_i]; - collect(node, /* allowRelativeModuleNames */ true); - } - file.imports = imports || emptyArray; - function collect(node, allowRelativeModuleNames) { - switch (node.kind) { - case 222 /* ImportDeclaration */: - case 221 /* ImportEqualsDeclaration */: - case 228 /* ExportDeclaration */: - var moduleNameExpr = ts.getExternalModuleName(node); - if (!moduleNameExpr || moduleNameExpr.kind !== 9 /* StringLiteral */) { - break; - } - if (!moduleNameExpr.text) { - break; - } - if (allowRelativeModuleNames || !ts.isExternalModuleNameRelative(moduleNameExpr.text)) { - (imports || (imports = [])).push(moduleNameExpr); - } - break; - case 218 /* ModuleDeclaration */: - if (node.name.kind === 9 /* StringLiteral */ && (node.flags & 2 /* Ambient */ || ts.isDeclarationFile(file))) { - // TypeScript 1.0 spec (April 2014): 12.1.6 - // An AmbientExternalModuleDeclaration declares an external module. - // This type of declaration is permitted only in the global module. - // The StringLiteral must specify a top - level external module name. - // Relative external module names are not permitted - ts.forEachChild(node.body, function (node) { - // TypeScript 1.0 spec (April 2014): 12.1.6 - // An ExternalImportDeclaration in anAmbientExternalModuleDeclaration may reference other external modules - // only through top - level external module names. Relative external module names are not permitted. - collect(node, /* allowRelativeModuleNames */ false); - }); - } - break; - } - } - } - function processSourceFile(fileName, isDefaultLib, refFile, refPos, refEnd) { - var diagnosticArgument; - var diagnostic; - if (hasExtension(fileName)) { - if (!options.allowNonTsExtensions && !ts.forEach(ts.supportedExtensions, function (extension) { return ts.fileExtensionIs(host.getCanonicalFileName(fileName), extension); })) { - diagnostic = ts.Diagnostics.File_0_has_unsupported_extension_The_only_supported_extensions_are_1; - diagnosticArgument = [fileName, "'" + ts.supportedExtensions.join("', '") + "'"]; - } - else if (!findSourceFile(fileName, isDefaultLib, refFile, refPos, refEnd)) { - diagnostic = ts.Diagnostics.File_0_not_found; - diagnosticArgument = [fileName]; - } - else if (refFile && host.getCanonicalFileName(fileName) === host.getCanonicalFileName(refFile.fileName)) { - diagnostic = ts.Diagnostics.A_file_cannot_have_a_reference_to_itself; - diagnosticArgument = [fileName]; - } - } - else { - var nonTsFile = options.allowNonTsExtensions && findSourceFile(fileName, isDefaultLib, refFile, refPos, refEnd); - if (!nonTsFile) { - if (options.allowNonTsExtensions) { - diagnostic = ts.Diagnostics.File_0_not_found; - diagnosticArgument = [fileName]; - } - else if (!ts.forEach(ts.supportedExtensions, function (extension) { return findSourceFile(fileName + extension, isDefaultLib, refFile, refPos, refEnd); })) { - diagnostic = ts.Diagnostics.File_0_not_found; - fileName += ".ts"; - diagnosticArgument = [fileName]; - } - } - } - if (diagnostic) { - if (refFile !== undefined && refEnd !== undefined && refPos !== undefined) { - fileProcessingDiagnostics.add(ts.createFileDiagnostic.apply(void 0, [refFile, refPos, refEnd - refPos, diagnostic].concat(diagnosticArgument))); - } - else { - fileProcessingDiagnostics.add(ts.createCompilerDiagnostic.apply(void 0, [diagnostic].concat(diagnosticArgument))); - } - } - } - // Get source file from normalized fileName - function findSourceFile(fileName, isDefaultLib, refFile, refPos, refEnd) { - if (filesByName.contains(fileName)) { - // We've already looked for this file, use cached result - return getSourceFileFromCache(fileName, /*useAbsolutePath*/ false); - } - var normalizedAbsolutePath = ts.getNormalizedAbsolutePath(fileName, host.getCurrentDirectory()); - if (filesByName.contains(normalizedAbsolutePath)) { - var file_1 = getSourceFileFromCache(normalizedAbsolutePath, /*useAbsolutePath*/ true); - // we don't have resolution for this relative file name but the match was found by absolute file name - // store resolution for relative name as well - filesByName.set(fileName, file_1); - return file_1; - } - // We haven't looked for this file, do so now and cache result - var file = host.getSourceFile(fileName, options.target, function (hostErrorMessage) { - if (refFile !== undefined && refPos !== undefined && refEnd !== undefined) { - fileProcessingDiagnostics.add(ts.createFileDiagnostic(refFile, refPos, refEnd - refPos, ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage)); - } - else { - fileProcessingDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage)); - } - }); - filesByName.set(fileName, file); - if (file) { - skipDefaultLib = skipDefaultLib || file.hasNoDefaultLib; - // Set the source file for normalized absolute path - filesByName.set(normalizedAbsolutePath, file); - var basePath = ts.getDirectoryPath(fileName); - if (!options.noResolve) { - processReferencedFiles(file, basePath); - } - // always process imported modules to record module name resolutions - processImportedModules(file, basePath); - if (isDefaultLib) { - file.isDefaultLib = true; - files.unshift(file); - } - else { - files.push(file); - } - } - return file; - function getSourceFileFromCache(fileName, useAbsolutePath) { - var file = filesByName.get(fileName); - if (file && host.useCaseSensitiveFileNames()) { - var sourceFileName = useAbsolutePath ? ts.getNormalizedAbsolutePath(file.fileName, host.getCurrentDirectory()) : file.fileName; - if (ts.normalizeSlashes(fileName) !== ts.normalizeSlashes(sourceFileName)) { - if (refFile !== undefined && refPos !== undefined && refEnd !== undefined) { - fileProcessingDiagnostics.add(ts.createFileDiagnostic(refFile, refPos, refEnd - refPos, ts.Diagnostics.File_name_0_differs_from_already_included_file_name_1_only_in_casing, fileName, sourceFileName)); - } - else { - fileProcessingDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.File_name_0_differs_from_already_included_file_name_1_only_in_casing, fileName, sourceFileName)); - } - } - } - return file; - } - } - function processReferencedFiles(file, basePath) { - ts.forEach(file.referencedFiles, function (ref) { - var referencedFileName = resolveTripleslashReference(ref.fileName, file.fileName); - processSourceFile(referencedFileName, /* isDefaultLib */ false, file, ref.pos, ref.end); - }); - } - function processImportedModules(file, basePath) { - collectExternalModuleReferences(file); - if (file.imports.length) { - file.resolvedModules = {}; - var moduleNames = ts.map(file.imports, function (name) { return name.text; }); - var resolutions = resolveModuleNamesWorker(moduleNames, file.fileName); - for (var i = 0; i < file.imports.length; ++i) { - var resolution = resolutions[i]; - ts.setResolvedModule(file, moduleNames[i], resolution); - if (resolution && !options.noResolve) { - var importedFile = findModuleSourceFile(resolution.resolvedFileName, file.imports[i]); - if (importedFile && resolution.isExternalLibraryImport) { - if (!ts.isExternalModule(importedFile)) { - var start_2 = ts.getTokenPosOfNode(file.imports[i], file); - fileProcessingDiagnostics.add(ts.createFileDiagnostic(file, start_2, file.imports[i].end - start_2, ts.Diagnostics.Exported_external_package_typings_file_0_is_not_a_module_Please_contact_the_package_author_to_update_the_package_definition, importedFile.fileName)); - } - else if (!ts.fileExtensionIs(importedFile.fileName, ".d.ts")) { - var start_3 = ts.getTokenPosOfNode(file.imports[i], file); - fileProcessingDiagnostics.add(ts.createFileDiagnostic(file, start_3, file.imports[i].end - start_3, ts.Diagnostics.Exported_external_package_typings_can_only_be_in_d_ts_files_Please_contact_the_package_author_to_update_the_package_definition)); - } - else if (importedFile.referencedFiles.length) { - var firstRef = importedFile.referencedFiles[0]; - fileProcessingDiagnostics.add(ts.createFileDiagnostic(importedFile, firstRef.pos, firstRef.end - firstRef.pos, ts.Diagnostics.Exported_external_package_typings_file_cannot_contain_tripleslash_references_Please_contact_the_package_author_to_update_the_package_definition)); - } - } - } - } - } - else { - // no imports - drop cached module resolutions - file.resolvedModules = undefined; - } - return; - function findModuleSourceFile(fileName, nameLiteral) { - return findSourceFile(fileName, /* isDefaultLib */ false, file, ts.skipTrivia(file.text, nameLiteral.pos), nameLiteral.end); - } - } - function computeCommonSourceDirectory(sourceFiles) { - var commonPathComponents; - var currentDirectory = host.getCurrentDirectory(); - ts.forEach(files, function (sourceFile) { - // Each file contributes into common source file path - if (ts.isDeclarationFile(sourceFile)) { - return; - } - var sourcePathComponents = ts.getNormalizedPathComponents(sourceFile.fileName, currentDirectory); - sourcePathComponents.pop(); // The base file name is not part of the common directory path - if (!commonPathComponents) { - // first file - commonPathComponents = sourcePathComponents; - return; - } - for (var i = 0, n = Math.min(commonPathComponents.length, sourcePathComponents.length); i < n; i++) { - if (commonPathComponents[i] !== sourcePathComponents[i]) { - if (i === 0) { - programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_find_the_common_subdirectory_path_for_the_input_files)); - return; - } - // New common path found that is 0 -> i-1 - commonPathComponents.length = i; - break; - } - } - // If the sourcePathComponents was shorter than the commonPathComponents, truncate to the sourcePathComponents - if (sourcePathComponents.length < commonPathComponents.length) { - commonPathComponents.length = sourcePathComponents.length; - } - }); - return ts.getNormalizedPathFromPathComponents(commonPathComponents); - } - function checkSourceFilesBelongToPath(sourceFiles, rootDirectory) { - var allFilesBelongToPath = true; - if (sourceFiles) { - var currentDirectory = host.getCurrentDirectory(); - var absoluteRootDirectoryPath = host.getCanonicalFileName(ts.getNormalizedAbsolutePath(rootDirectory, currentDirectory)); - for (var _i = 0; _i < sourceFiles.length; _i++) { - var sourceFile = sourceFiles[_i]; - if (!ts.isDeclarationFile(sourceFile)) { - var absoluteSourceFilePath = host.getCanonicalFileName(ts.getNormalizedAbsolutePath(sourceFile.fileName, currentDirectory)); - if (absoluteSourceFilePath.indexOf(absoluteRootDirectoryPath) !== 0) { - programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.File_0_is_not_under_rootDir_1_rootDir_is_expected_to_contain_all_source_files, sourceFile.fileName, options.rootDir)); - allFilesBelongToPath = false; - } - } - } - } - return allFilesBelongToPath; - } - function verifyCompilerOptions() { - if (options.isolatedModules) { - if (options.declaration) { - programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "declaration", "isolatedModules")); - } - if (options.noEmitOnError) { - programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "noEmitOnError", "isolatedModules")); - } - if (options.out) { - programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "out", "isolatedModules")); - } - if (options.outFile) { - programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "outFile", "isolatedModules")); - } - } - if (options.inlineSourceMap) { - if (options.sourceMap) { - programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "sourceMap", "inlineSourceMap")); - } - if (options.mapRoot) { - programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "mapRoot", "inlineSourceMap")); - } - if (options.sourceRoot) { - programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "sourceRoot", "inlineSourceMap")); - } - } - if (options.inlineSources) { - if (!options.sourceMap && !options.inlineSourceMap) { - programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_inlineSources_can_only_be_used_when_either_option_inlineSourceMap_or_option_sourceMap_is_provided)); - } - } - if (options.out && options.outFile) { - programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "out", "outFile")); - } - if (!options.sourceMap && (options.mapRoot || options.sourceRoot)) { - // Error to specify --mapRoot or --sourceRoot without mapSourceFiles - if (options.mapRoot) { - programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "mapRoot", "sourceMap")); - } - if (options.sourceRoot) { - programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "sourceRoot", "sourceMap")); - } - return; - } - var languageVersion = options.target || 0 /* ES3 */; - var outFile = options.outFile || options.out; - var firstExternalModuleSourceFile = ts.forEach(files, function (f) { return ts.isExternalModule(f) ? f : undefined; }); - if (options.isolatedModules) { - if (!options.module && languageVersion < 2 /* ES6 */) { - 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; }); - if (firstNonExternalModuleSourceFile) { - var span = ts.getErrorSpanForNode(firstNonExternalModuleSourceFile, firstNonExternalModuleSourceFile); - programDiagnostics.add(ts.createFileDiagnostic(firstNonExternalModuleSourceFile, span.start, span.length, ts.Diagnostics.Cannot_compile_namespaces_when_the_isolatedModules_flag_is_provided)); - } - } - else if (firstExternalModuleSourceFile && languageVersion < 2 /* ES6 */ && !options.module) { - // We cannot use createDiagnosticFromNode because nodes do not have parents yet - var span = ts.getErrorSpanForNode(firstExternalModuleSourceFile, firstExternalModuleSourceFile.externalModuleIndicator); - programDiagnostics.add(ts.createFileDiagnostic(firstExternalModuleSourceFile, span.start, span.length, ts.Diagnostics.Cannot_compile_modules_unless_the_module_flag_is_provided)); - } - // Cannot specify module gen target of es6 when below es6 - if (options.module === 5 /* ES6 */ && languageVersion < 2 /* ES6 */) { - programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_compile_modules_into_es2015_when_targeting_ES5_or_lower)); - } - // there has to be common source directory if user specified --outdir || --sourceRoot - // if user specified --mapRoot, there needs to be common source directory if there would be multiple files being emitted - if (options.outDir || - options.sourceRoot || - (options.mapRoot && - (!outFile || firstExternalModuleSourceFile !== undefined))) { - if (options.rootDir && checkSourceFilesBelongToPath(files, options.rootDir)) { - // If a rootDir is specified and is valid use it as the commonSourceDirectory - commonSourceDirectory = ts.getNormalizedAbsolutePath(options.rootDir, host.getCurrentDirectory()); - } - else { - // Compute the commonSourceDirectory from the input files - commonSourceDirectory = computeCommonSourceDirectory(files); - } - if (commonSourceDirectory && commonSourceDirectory[commonSourceDirectory.length - 1] !== ts.directorySeparator) { - // Make sure directory path ends with directory separator so this string can directly - // used to replace with "" to get the relative path of the source file and the relative path doesn't - // start with / making it rooted path - commonSourceDirectory += ts.directorySeparator; - } - } - if (options.noEmit) { - if (options.out) { - programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "noEmit", "out")); - } - if (options.outFile) { - programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "noEmit", "outFile")); - } - if (options.outDir) { - programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "noEmit", "outDir")); - } - if (options.declaration) { - programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "noEmit", "declaration")); - } - } - if (options.emitDecoratorMetadata && - !options.experimentalDecorators) { - programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "emitDecoratorMetadata", "experimentalDecorators")); - } - } - } - ts.createProgram = createProgram; -})(ts || (ts = {})); -/// -/// -/// -/// -var ts; -(function (ts) { - /* @internal */ - ts.optionDeclarations = [ - { - name: "charset", - type: "string" - }, - { - name: "declaration", - shortName: "d", - type: "boolean", - description: ts.Diagnostics.Generates_corresponding_d_ts_file - }, - { - name: "diagnostics", - type: "boolean" - }, - { - name: "emitBOM", - type: "boolean" - }, - { - name: "help", - shortName: "h", - type: "boolean", - description: ts.Diagnostics.Print_this_message - }, - { - 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: { - "preserve": 1 /* Preserve */, - "react": 2 /* React */ - }, - paramType: ts.Diagnostics.KIND, - description: ts.Diagnostics.Specify_JSX_code_generation_Colon_preserve_or_react, - error: ts.Diagnostics.Argument_for_jsx_must_be_preserve_or_react - }, - { - name: "listFiles", - type: "boolean" - }, - { - name: "locale", - type: "string" - }, - { - name: "mapRoot", - type: "string", - isFilePath: true, - description: ts.Diagnostics.Specifies_the_location_where_debugger_should_locate_map_files_instead_of_generated_locations, - paramType: ts.Diagnostics.LOCATION - }, - { - name: "module", - shortName: "m", - type: { - "commonjs": 1 /* CommonJS */, - "amd": 2 /* AMD */, - "system": 4 /* System */, - "umd": 3 /* UMD */, - "es6": 5 /* ES6 */, - "es2015": 5 /* ES2015 */ - }, - description: ts.Diagnostics.Specify_module_code_generation_Colon_commonjs_amd_system_umd_or_es2015, - paramType: ts.Diagnostics.KIND, - error: ts.Diagnostics.Argument_for_module_option_must_be_commonjs_amd_system_umd_or_es2015 - }, - { - name: "newLine", - type: { - "crlf": 0 /* CarriageReturnLineFeed */, - "lf": 1 /* LineFeed */ - }, - description: ts.Diagnostics.Specifies_the_end_of_line_sequence_to_be_used_when_emitting_files_Colon_CRLF_dos_or_LF_unix, - paramType: ts.Diagnostics.NEWLINE, - error: ts.Diagnostics.Argument_for_newLine_option_must_be_CRLF_or_LF - }, - { - 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: "noImplicitAny", - type: "boolean", - description: ts.Diagnostics.Raise_error_on_expressions_and_declarations_with_an_implied_any_type - }, - { - name: "noLib", - type: "boolean" - }, - { - name: "noResolve", - type: "boolean" - }, - { - name: "skipDefaultLibCheck", - type: "boolean" - }, - { - name: "out", - type: "string", - isFilePath: false, - // for correct behaviour, please use outFile - 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: "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, - description: ts.Diagnostics.Specifies_the_root_directory_of_input_files_Use_to_control_the_output_directory_structure_with_outDir, - paramType: ts.Diagnostics.LOCATION - }, - { - name: "isolatedModules", - type: "boolean" - }, - { - name: "sourceMap", - type: "boolean", - description: ts.Diagnostics.Generates_corresponding_map_file - }, - { - name: "sourceRoot", - type: "string", - isFilePath: true, - description: ts.Diagnostics.Specifies_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: { - "es3": 0 /* ES3 */, - "es5": 1 /* ES5 */, - "es6": 2 /* ES6 */, - "es2015": 2 /* ES2015 */ - }, - description: ts.Diagnostics.Specify_ECMAScript_target_version_Colon_ES3_default_ES5_or_ES2015_experimental, - paramType: ts.Diagnostics.VERSION, - error: ts.Diagnostics.Argument_for_target_option_must_be_ES3_ES5_or_ES2015 - }, - { - 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: { - "node": 2 /* NodeJs */, - "classic": 1 /* Classic */ - }, - description: ts.Diagnostics.Specifies_module_resolution_strategy_Colon_node_Node_js_or_classic_TypeScript_pre_1_6, - error: ts.Diagnostics.Argument_for_moduleResolution_option_must_be_node_or_classic - } - ]; - var optionNameMapCache; - /* @internal */ - function getOptionNameMap() { - if (optionNameMapCache) { - return optionNameMapCache; - } - var optionNameMap = {}; - var shortOptionNames = {}; - 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 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++]; - if (s.charCodeAt(0) === 64 /* at */) { - parseResponseFile(s.slice(1)); - } - else if (s.charCodeAt(0) === 45 /* minus */) { - s = s.slice(s.charCodeAt(1) === 45 /* minus */ ? 2 : 1).toLowerCase(); - // Try to translate short option names to their full equivalents. - if (ts.hasProperty(shortOptionNames, s)) { - s = shortOptionNames[s]; - } - if (ts.hasProperty(optionNameMap, s)) { - var opt = optionNameMap[s]; - // Check to see if no argument was provided (e.g. "--locale" is the last command-line argument). - 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++]); - break; - case "boolean": - options[opt.name] = true; - break; - case "string": - options[opt.name] = args[i++] || ""; - break; - // If not a primitive, the possible types are specified in what is effectively a map of options. - default: - var map_2 = opt.type; - var key = (args[i++] || "").toLowerCase(); - if (ts.hasProperty(map_2, key)) { - options[opt.name] = map_2[key]; - } - else { - errors.push(ts.createCompilerDiagnostic(opt.error)); - } - } - } - 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 /* space */) - pos++; - if (pos >= text.length) - break; - var start = pos; - if (text.charCodeAt(start) === 34 /* doubleQuote */) { - pos++; - while (pos < text.length && text.charCodeAt(pos) !== 34 /* doubleQuote */) - 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 /* space */) - pos++; - args.push(text.substring(start, pos)); - } - } - parseStrings(args); - } - } - ts.parseCommandLine = parseCommandLine; - /** - * Read tsconfig.json file - * @param fileName The path to the config file - */ - 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; - /** - * Parse the text of the tsconfig.json file - * @param fileName The path to the config file - * @param jsonText The text of the config file - */ - function parseConfigFileTextToJson(fileName, jsonText) { - try { - return { config: /\S/.test(jsonText) ? JSON.parse(jsonText) : {} }; - } - catch (e) { - return { error: ts.createCompilerDiagnostic(ts.Diagnostics.Failed_to_parse_file_0_Colon_1, fileName, e.message) }; - } - } - ts.parseConfigFileTextToJson = parseConfigFileTextToJson; - /** - * Parse the contents of a config file (tsconfig.json). - * @param json The contents of the config file to parse - * @param host Instance of ParseConfigHost used to enumerate files in folder. - * @param basePath A root directory to resolve relative path entries in the config - * file to. e.g. outDir - */ - function parseJsonConfigFileContent(json, host, basePath) { - var _a = convertCompilerOptionsFromJson(json["compilerOptions"], basePath), options = _a.options, errors = _a.errors; - return { - options: options, - fileNames: getFileNames(), - errors: errors - }; - function getFileNames() { - var fileNames = []; - if (ts.hasProperty(json, "files")) { - if (json["files"] instanceof Array) { - fileNames = ts.map(json["files"], function (s) { return ts.combinePaths(basePath, s); }); - } - else { - errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Compiler_option_0_requires_a_value_of_type_1, "files", "Array")); - } - } - else { - var exclude = json["exclude"] instanceof Array ? ts.map(json["exclude"], ts.normalizeSlashes) : undefined; - var sysFiles = host.readDirectory(basePath, ".ts", exclude).concat(host.readDirectory(basePath, ".tsx", exclude)); - for (var i = 0; i < sysFiles.length; i++) { - var name_28 = sysFiles[i]; - if (ts.fileExtensionIs(name_28, ".d.ts")) { - var baseName = name_28.substr(0, name_28.length - ".d.ts".length); - if (!ts.contains(sysFiles, baseName + ".tsx") && !ts.contains(sysFiles, baseName + ".ts")) { - fileNames.push(name_28); - } - } - else if (ts.fileExtensionIs(name_28, ".ts")) { - if (!ts.contains(sysFiles, name_28 + "x")) { - fileNames.push(name_28); - } - } - else { - fileNames.push(name_28); - } - } - } - return fileNames; - } - } - ts.parseJsonConfigFileContent = parseJsonConfigFileContent; - function convertCompilerOptionsFromJson(jsonOptions, basePath) { - var options = {}; - var errors = []; - if (!jsonOptions) { - return { options: options, errors: errors }; - } - var optionNameMap = ts.arrayToMap(ts.optionDeclarations, function (opt) { return opt.name; }); - for (var id in jsonOptions) { - if (ts.hasProperty(optionNameMap, id)) { - var opt = optionNameMap[id]; - var optType = opt.type; - var value = jsonOptions[id]; - var expectedType = typeof optType === "string" ? optType : "string"; - if (typeof value === expectedType) { - if (typeof optType !== "string") { - var key = value.toLowerCase(); - if (ts.hasProperty(optType, key)) { - value = optType[key]; - } - else { - errors.push(ts.createCompilerDiagnostic(opt.error)); - value = 0; - } - } - if (opt.isFilePath) { - value = ts.normalizePath(ts.combinePaths(basePath, value)); - if (value === "") { - value = "."; - } - } - options[opt.name] = value; - } - else { - errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Compiler_option_0_requires_a_value_of_type_1, id, expectedType)); - } - } - else { - errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Unknown_compiler_option_0, id)); - } - } - return { options: options, errors: errors }; - } - ts.convertCompilerOptionsFromJson = convertCompilerOptionsFromJson; -})(ts || (ts = {})); -/* @internal */ -var ts; -(function (ts) { - var OutliningElementsCollector; - (function (OutliningElementsCollector) { - function collectElements(sourceFile) { - var elements = []; - var collapseText = "..."; - function addOutliningSpan(hintSpanNode, startElement, endElement, autoCollapse) { - if (hintSpanNode && startElement && endElement) { - var span = { - textSpan: ts.createTextSpanFromBounds(startElement.pos, endElement.end), - hintSpan: ts.createTextSpanFromBounds(hintSpanNode.getStart(), hintSpanNode.end), - bannerText: collapseText, - autoCollapse: autoCollapse - }; - elements.push(span); - } - } - function addOutliningSpanComments(commentSpan, autoCollapse) { - if (commentSpan) { - var span = { - textSpan: ts.createTextSpanFromBounds(commentSpan.pos, commentSpan.end), - hintSpan: ts.createTextSpanFromBounds(commentSpan.pos, commentSpan.end), - bannerText: collapseText, - autoCollapse: autoCollapse - }; - elements.push(span); - } - } - function addOutliningForLeadingCommentsForNode(n) { - var comments = ts.getLeadingCommentRangesOfNode(n, sourceFile); - if (comments) { - var firstSingleLineCommentStart = -1; - var lastSingleLineCommentEnd = -1; - var isFirstSingleLineComment = true; - var singleLineCommentCount = 0; - for (var _i = 0; _i < comments.length; _i++) { - var currentComment = comments[_i]; - // For single line comments, combine consecutive ones (2 or more) into - // a single span from the start of the first till the end of the last - if (currentComment.kind === 2 /* SingleLineCommentTrivia */) { - if (isFirstSingleLineComment) { - firstSingleLineCommentStart = currentComment.pos; - } - isFirstSingleLineComment = false; - lastSingleLineCommentEnd = currentComment.end; - singleLineCommentCount++; - } - else if (currentComment.kind === 3 /* MultiLineCommentTrivia */) { - combineAndAddMultipleSingleLineComments(singleLineCommentCount, firstSingleLineCommentStart, lastSingleLineCommentEnd); - addOutliningSpanComments(currentComment, /*autoCollapse*/ false); - singleLineCommentCount = 0; - lastSingleLineCommentEnd = -1; - isFirstSingleLineComment = true; - } - } - combineAndAddMultipleSingleLineComments(singleLineCommentCount, firstSingleLineCommentStart, lastSingleLineCommentEnd); - } - } - function combineAndAddMultipleSingleLineComments(count, start, end) { - // Only outline spans of two or more consecutive single line comments - if (count > 1) { - var multipleSingleLineComments = { - pos: start, - end: end, - kind: 2 /* SingleLineCommentTrivia */ - }; - addOutliningSpanComments(multipleSingleLineComments, /*autoCollapse*/ false); - } - } - function autoCollapse(node) { - return ts.isFunctionBlock(node) && node.parent.kind !== 174 /* ArrowFunction */; - } - var depth = 0; - var maxDepth = 20; - function walk(n) { - if (depth > maxDepth) { - return; - } - if (ts.isDeclaration(n)) { - addOutliningForLeadingCommentsForNode(n); - } - switch (n.kind) { - case 192 /* Block */: - if (!ts.isFunctionBlock(n)) { - var parent_7 = n.parent; - var openBrace = ts.findChildOfKind(n, 15 /* OpenBraceToken */, sourceFile); - var closeBrace = ts.findChildOfKind(n, 16 /* CloseBraceToken */, sourceFile); - // Check if the block is standalone, or 'attached' to some parent statement. - // If the latter, we want to collaps the block, but consider its hint span - // to be the entire span of the parent. - if (parent_7.kind === 197 /* DoStatement */ || - parent_7.kind === 200 /* ForInStatement */ || - parent_7.kind === 201 /* ForOfStatement */ || - parent_7.kind === 199 /* ForStatement */ || - parent_7.kind === 196 /* IfStatement */ || - parent_7.kind === 198 /* WhileStatement */ || - parent_7.kind === 205 /* WithStatement */ || - parent_7.kind === 244 /* CatchClause */) { - addOutliningSpan(parent_7, openBrace, closeBrace, autoCollapse(n)); - break; - } - if (parent_7.kind === 209 /* TryStatement */) { - // Could be the try-block, or the finally-block. - var tryStatement = parent_7; - if (tryStatement.tryBlock === n) { - addOutliningSpan(parent_7, openBrace, closeBrace, autoCollapse(n)); - break; - } - else if (tryStatement.finallyBlock === n) { - var finallyKeyword = ts.findChildOfKind(tryStatement, 85 /* FinallyKeyword */, sourceFile); - if (finallyKeyword) { - addOutliningSpan(finallyKeyword, openBrace, closeBrace, autoCollapse(n)); - break; - } - } - } - // Block was a standalone block. In this case we want to only collapse - // the span of the block, independent of any parent span. - var span = ts.createTextSpanFromBounds(n.getStart(), n.end); - elements.push({ - textSpan: span, - hintSpan: span, - bannerText: collapseText, - autoCollapse: autoCollapse(n) - }); - break; - } - // Fallthrough. - case 219 /* ModuleBlock */: { - var openBrace = ts.findChildOfKind(n, 15 /* OpenBraceToken */, sourceFile); - var closeBrace = ts.findChildOfKind(n, 16 /* CloseBraceToken */, sourceFile); - addOutliningSpan(n.parent, openBrace, closeBrace, autoCollapse(n)); - break; - } - case 214 /* ClassDeclaration */: - case 215 /* InterfaceDeclaration */: - case 217 /* EnumDeclaration */: - case 165 /* ObjectLiteralExpression */: - case 220 /* CaseBlock */: { - var openBrace = ts.findChildOfKind(n, 15 /* OpenBraceToken */, sourceFile); - var closeBrace = ts.findChildOfKind(n, 16 /* CloseBraceToken */, sourceFile); - addOutliningSpan(n, openBrace, closeBrace, autoCollapse(n)); - break; - } - case 164 /* ArrayLiteralExpression */: - var openBracket = ts.findChildOfKind(n, 19 /* OpenBracketToken */, sourceFile); - var closeBracket = ts.findChildOfKind(n, 20 /* CloseBracketToken */, sourceFile); - addOutliningSpan(n, openBracket, closeBracket, autoCollapse(n)); - break; - } - depth++; - ts.forEachChild(n, walk); - depth--; - } - walk(sourceFile); - return elements; - } - OutliningElementsCollector.collectElements = collectElements; - })(OutliningElementsCollector = ts.OutliningElementsCollector || (ts.OutliningElementsCollector = {})); -})(ts || (ts = {})); -/* @internal */ -var ts; -(function (ts) { - var NavigateTo; - (function (NavigateTo) { - function getNavigateToItems(program, cancellationToken, searchValue, maxResultCount) { - var patternMatcher = ts.createPatternMatcher(searchValue); - var rawItems = []; - // Search the declarations in all files and output matched NavigateToItem into array of NavigateToItem[] - ts.forEach(program.getSourceFiles(), function (sourceFile) { - cancellationToken.throwIfCancellationRequested(); - var nameToDeclarations = sourceFile.getNamedDeclarations(); - for (var name_29 in nameToDeclarations) { - var declarations = ts.getProperty(nameToDeclarations, name_29); - if (declarations) { - // First do a quick check to see if the name of the declaration matches the - // last portion of the (possibly) dotted name they're searching for. - var matches = patternMatcher.getMatchesForLastSegmentOfPattern(name_29); - if (!matches) { - continue; - } - for (var _i = 0; _i < declarations.length; _i++) { - var declaration = declarations[_i]; - // It was a match! If the pattern has dots in it, then also see if the - // declaration container matches as well. - if (patternMatcher.patternContainsDots) { - var containers = getContainers(declaration); - if (!containers) { - return undefined; - } - matches = patternMatcher.getMatches(containers, name_29); - if (!matches) { - continue; - } - } - var fileName = sourceFile.fileName; - var matchKind = bestMatchKind(matches); - rawItems.push({ name: name_29, fileName: fileName, matchKind: matchKind, isCaseSensitive: allMatchesAreCaseSensitive(matches), declaration: declaration }); - } - } - } - }); - rawItems.sort(compareNavigateToItems); - if (maxResultCount !== undefined) { - rawItems = rawItems.slice(0, maxResultCount); - } - var items = ts.map(rawItems, createNavigateToItem); - return items; - function allMatchesAreCaseSensitive(matches) { - ts.Debug.assert(matches.length > 0); - // This is a case sensitive match, only if all the submatches were case sensitive. - for (var _i = 0; _i < matches.length; _i++) { - var match = matches[_i]; - if (!match.isCaseSensitive) { - return false; - } - } - return true; - } - function getTextOfIdentifierOrLiteral(node) { - if (node) { - if (node.kind === 69 /* Identifier */ || - node.kind === 9 /* StringLiteral */ || - node.kind === 8 /* NumericLiteral */) { - return node.text; - } - } - return undefined; - } - function tryAddSingleDeclarationName(declaration, containers) { - if (declaration && declaration.name) { - var text = getTextOfIdentifierOrLiteral(declaration.name); - if (text !== undefined) { - containers.unshift(text); - } - else if (declaration.name.kind === 136 /* ComputedPropertyName */) { - return tryAddComputedPropertyName(declaration.name.expression, containers, /*includeLastPortion:*/ true); - } - else { - // Don't know how to add this. - return false; - } - } - return true; - } - // Only added the names of computed properties if they're simple dotted expressions, like: - // - // [X.Y.Z]() { } - function tryAddComputedPropertyName(expression, containers, includeLastPortion) { - var text = getTextOfIdentifierOrLiteral(expression); - if (text !== undefined) { - if (includeLastPortion) { - containers.unshift(text); - } - return true; - } - if (expression.kind === 166 /* PropertyAccessExpression */) { - var propertyAccess = expression; - if (includeLastPortion) { - containers.unshift(propertyAccess.name.text); - } - return tryAddComputedPropertyName(propertyAccess.expression, containers, /*includeLastPortion:*/ true); - } - return false; - } - function getContainers(declaration) { - 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 === 136 /* ComputedPropertyName */) { - if (!tryAddComputedPropertyName(declaration.name.expression, containers, /*includeLastPortion:*/ false)) { - return undefined; - } - } - // Now, walk up our containers, adding all their names to the container array. - declaration = ts.getContainerNode(declaration); - while (declaration) { - if (!tryAddSingleDeclarationName(declaration, containers)) { - return undefined; - } - declaration = ts.getContainerNode(declaration); - } - return containers; - } - function bestMatchKind(matches) { - ts.Debug.assert(matches.length > 0); - var bestMatchKind = ts.PatternMatchKind.camelCase; - for (var _i = 0; _i < matches.length; _i++) { - var match = matches[_i]; - var kind = match.kind; - if (kind < bestMatchKind) { - bestMatchKind = kind; - } - } - return bestMatchKind; - } - // This means "compare in a case insensitive manner." - var baseSensitivity = { sensitivity: "base" }; - function compareNavigateToItems(i1, i2) { - // TODO(cyrusn): get the gamut of comparisons that VS already uses here. - // Right now we just sort by kind first, and then by name of the item. - // 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); - } - function createNavigateToItem(rawItem) { - var declaration = rawItem.declaration; - var container = ts.getContainerNode(declaration); - return { - name: rawItem.name, - kind: ts.getNodeKind(declaration), - kindModifiers: ts.getNodeModifiers(declaration), - matchKind: ts.PatternMatchKind[rawItem.matchKind], - isCaseSensitive: rawItem.isCaseSensitive, - fileName: rawItem.fileName, - textSpan: ts.createTextSpanFromBounds(declaration.getStart(), declaration.getEnd()), - // TODO(jfreeman): What should be the containerName when the container has a computed name? - containerName: container && container.name ? container.name.text : "", - containerKind: container && container.name ? ts.getNodeKind(container) : "" - }; - } - } - NavigateTo.getNavigateToItems = getNavigateToItems; - })(NavigateTo = ts.NavigateTo || (ts.NavigateTo = {})); -})(ts || (ts = {})); -/// -/* @internal */ -var ts; -(function (ts) { - var NavigationBar; - (function (NavigationBar) { - function getNavigationBarItems(sourceFile) { - // If the source file has any child items, then it included in the tree - // and takes lexical ownership of all other top-level items. - var hasGlobalNode = false; - return getItemsWorker(getTopLevelNodes(sourceFile), createTopLevelItem); - function getIndent(node) { - // If we have a global node in the tree, - // then it adds an extra layer of depth to all subnodes. - var indent = hasGlobalNode ? 1 : 0; - var current = node.parent; - while (current) { - switch (current.kind) { - case 218 /* ModuleDeclaration */: - // If we have a module declared as A.B.C, it is more "intuitive" - // to say it only has a single layer of depth - do { - current = current.parent; - } while (current.kind === 218 /* ModuleDeclaration */); - // fall through - case 214 /* ClassDeclaration */: - case 217 /* EnumDeclaration */: - case 215 /* InterfaceDeclaration */: - case 213 /* FunctionDeclaration */: - indent++; - } - current = current.parent; - } - return indent; - } - function getChildNodes(nodes) { - var childNodes = []; - function visit(node) { - switch (node.kind) { - case 193 /* VariableStatement */: - ts.forEach(node.declarationList.declarations, visit); - break; - case 161 /* ObjectBindingPattern */: - case 162 /* ArrayBindingPattern */: - ts.forEach(node.elements, visit); - break; - case 228 /* ExportDeclaration */: - // Handle named exports case e.g.: - // export {a, b as B} from "mod"; - if (node.exportClause) { - ts.forEach(node.exportClause.elements, visit); - } - break; - case 222 /* ImportDeclaration */: - var importClause = node.importClause; - if (importClause) { - // Handle default import case e.g.: - // import d from "mod"; - if (importClause.name) { - childNodes.push(importClause); - } - // Handle named bindings in imports e.g.: - // import * as NS from "mod"; - // import {a, b as B} from "mod"; - if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 224 /* NamespaceImport */) { - childNodes.push(importClause.namedBindings); - } - else { - ts.forEach(importClause.namedBindings.elements, visit); - } - } - } - break; - case 163 /* BindingElement */: - case 211 /* VariableDeclaration */: - if (ts.isBindingPattern(node.name)) { - visit(node.name); - break; - } - // Fall through - case 214 /* ClassDeclaration */: - case 217 /* EnumDeclaration */: - case 215 /* InterfaceDeclaration */: - case 218 /* ModuleDeclaration */: - case 213 /* FunctionDeclaration */: - case 221 /* ImportEqualsDeclaration */: - case 226 /* ImportSpecifier */: - case 230 /* ExportSpecifier */: - childNodes.push(node); - break; - } - } - //for (let i = 0, n = nodes.length; i < n; i++) { - // let node = nodes[i]; - // if (node.kind === SyntaxKind.ClassDeclaration || - // node.kind === SyntaxKind.EnumDeclaration || - // node.kind === SyntaxKind.InterfaceDeclaration || - // node.kind === SyntaxKind.ModuleDeclaration || - // node.kind === SyntaxKind.FunctionDeclaration) { - // childNodes.push(node); - // } - // else if (node.kind === SyntaxKind.VariableStatement) { - // childNodes.push.apply(childNodes, (node).declarations); - // } - //} - ts.forEach(nodes, visit); - return sortNodes(childNodes); - } - function getTopLevelNodes(node) { - var topLevelNodes = []; - topLevelNodes.push(node); - addTopLevelNodes(node.statements, topLevelNodes); - return topLevelNodes; - } - function sortNodes(nodes) { - return nodes.slice(0).sort(function (n1, n2) { - if (n1.name && n2.name) { - return ts.getPropertyNameForPropertyNameNode(n1.name).localeCompare(ts.getPropertyNameForPropertyNameNode(n2.name)); - } - else if (n1.name) { - return 1; - } - else if (n2.name) { - return -1; - } - else { - return n1.kind - n2.kind; - } - }); - } - function addTopLevelNodes(nodes, topLevelNodes) { - nodes = sortNodes(nodes); - for (var _i = 0; _i < nodes.length; _i++) { - var node = nodes[_i]; - switch (node.kind) { - case 214 /* ClassDeclaration */: - case 217 /* EnumDeclaration */: - case 215 /* InterfaceDeclaration */: - topLevelNodes.push(node); - break; - case 218 /* ModuleDeclaration */: - var moduleDeclaration = node; - topLevelNodes.push(node); - addTopLevelNodes(getInnermostModule(moduleDeclaration).body.statements, topLevelNodes); - break; - case 213 /* FunctionDeclaration */: - var functionDeclaration = node; - if (isTopLevelFunctionDeclaration(functionDeclaration)) { - topLevelNodes.push(node); - addTopLevelNodes(functionDeclaration.body.statements, topLevelNodes); - } - break; - } - } - } - function isTopLevelFunctionDeclaration(functionDeclaration) { - if (functionDeclaration.kind === 213 /* FunctionDeclaration */) { - // A function declaration is 'top level' if it contains any function declarations - // within it. - if (functionDeclaration.body && functionDeclaration.body.kind === 192 /* Block */) { - // Proper function declarations can only have identifier names - if (ts.forEach(functionDeclaration.body.statements, function (s) { return s.kind === 213 /* FunctionDeclaration */ && !isEmpty(s.name.text); })) { - return true; - } - // Or if it is not parented by another function. i.e all functions - // at module scope are 'top level'. - if (!ts.isFunctionBlock(functionDeclaration.parent)) { - return true; - } - } - } - return false; - } - function getItemsWorker(nodes, createItem) { - var items = []; - var keyToItem = {}; - for (var _i = 0; _i < nodes.length; _i++) { - var child = nodes[_i]; - var item = createItem(child); - if (item !== undefined) { - if (item.text.length > 0) { - var key = item.text + "-" + item.kind + "-" + item.indent; - var itemWithSameName = keyToItem[key]; - if (itemWithSameName) { - // We had an item with the same name. Merge these items together. - merge(itemWithSameName, item); - } - else { - keyToItem[key] = item; - items.push(item); - } - } - } - } - return items; - } - function merge(target, source) { - // First, add any spans in the source to the target. - ts.addRange(target.spans, source.spans); - if (source.childItems) { - if (!target.childItems) { - target.childItems = []; - } - // Next, recursively merge or add any children in the source as appropriate. - outer: for (var _i = 0, _a = source.childItems; _i < _a.length; _i++) { - var sourceChild = _a[_i]; - for (var _b = 0, _c = target.childItems; _b < _c.length; _b++) { - var targetChild = _c[_b]; - if (targetChild.text === sourceChild.text && targetChild.kind === sourceChild.kind) { - // Found a match. merge them. - merge(targetChild, sourceChild); - continue outer; - } - } - // Didn't find a match, just add this child to the list. - target.childItems.push(sourceChild); - } - } - } - function createChildItem(node) { - switch (node.kind) { - case 138 /* Parameter */: - if (ts.isBindingPattern(node.name)) { - break; - } - if ((node.flags & 2035 /* Modifier */) === 0) { - return undefined; - } - return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberVariableElement); - case 143 /* MethodDeclaration */: - case 142 /* MethodSignature */: - return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberFunctionElement); - case 145 /* GetAccessor */: - return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberGetAccessorElement); - case 146 /* SetAccessor */: - return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberSetAccessorElement); - case 149 /* IndexSignature */: - return createItem(node, "[]", ts.ScriptElementKind.indexSignatureElement); - case 247 /* EnumMember */: - return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberVariableElement); - case 147 /* CallSignature */: - return createItem(node, "()", ts.ScriptElementKind.callSignatureElement); - case 148 /* ConstructSignature */: - return createItem(node, "new()", ts.ScriptElementKind.constructSignatureElement); - case 141 /* PropertyDeclaration */: - case 140 /* PropertySignature */: - return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberVariableElement); - case 213 /* FunctionDeclaration */: - return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.functionElement); - case 211 /* VariableDeclaration */: - case 163 /* BindingElement */: - var variableDeclarationNode; - var name_30; - if (node.kind === 163 /* BindingElement */) { - name_30 = node.name; - variableDeclarationNode = node; - // binding elements are added only for variable declarations - // bubble up to the containing variable declaration - while (variableDeclarationNode && variableDeclarationNode.kind !== 211 /* VariableDeclaration */) { - variableDeclarationNode = variableDeclarationNode.parent; - } - ts.Debug.assert(variableDeclarationNode !== undefined); - } - else { - ts.Debug.assert(!ts.isBindingPattern(node.name)); - variableDeclarationNode = node; - name_30 = node.name; - } - if (ts.isConst(variableDeclarationNode)) { - return createItem(node, getTextOfNode(name_30), ts.ScriptElementKind.constElement); - } - else if (ts.isLet(variableDeclarationNode)) { - return createItem(node, getTextOfNode(name_30), ts.ScriptElementKind.letElement); - } - else { - return createItem(node, getTextOfNode(name_30), ts.ScriptElementKind.variableElement); - } - case 144 /* Constructor */: - return createItem(node, "constructor", ts.ScriptElementKind.constructorImplementationElement); - case 230 /* ExportSpecifier */: - case 226 /* ImportSpecifier */: - case 221 /* ImportEqualsDeclaration */: - case 223 /* ImportClause */: - case 224 /* NamespaceImport */: - return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.alias); - } - return undefined; - function createItem(node, name, scriptElementKind) { - return getNavigationBarItem(name, scriptElementKind, ts.getNodeModifiers(node), [getNodeSpan(node)]); - } - } - function isEmpty(text) { - return !text || text.trim() === ""; - } - function getNavigationBarItem(text, kind, kindModifiers, spans, childItems, indent) { - if (childItems === void 0) { childItems = []; } - if (indent === void 0) { indent = 0; } - if (isEmpty(text)) { - return undefined; - } - return { - text: text, - kind: kind, - kindModifiers: kindModifiers, - spans: spans, - childItems: childItems, - indent: indent, - bolded: false, - grayed: false - }; - } - function createTopLevelItem(node) { - switch (node.kind) { - case 248 /* SourceFile */: - return createSourceFileItem(node); - case 214 /* ClassDeclaration */: - return createClassItem(node); - case 217 /* EnumDeclaration */: - return createEnumItem(node); - case 215 /* InterfaceDeclaration */: - return createIterfaceItem(node); - case 218 /* ModuleDeclaration */: - return createModuleItem(node); - case 213 /* FunctionDeclaration */: - return createFunctionItem(node); - } - return undefined; - function getModuleName(moduleDeclaration) { - // We want to maintain quotation marks. - if (moduleDeclaration.name.kind === 9 /* StringLiteral */) { - return getTextOfNode(moduleDeclaration.name); - } - // 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 === 218 /* ModuleDeclaration */) { - moduleDeclaration = moduleDeclaration.body; - result.push(moduleDeclaration.name.text); - } - return result.join("."); - } - function createModuleItem(node) { - var moduleName = getModuleName(node); - var childItems = getItemsWorker(getChildNodes(getInnermostModule(node).body.statements), createChildItem); - return getNavigationBarItem(moduleName, ts.ScriptElementKind.moduleElement, ts.getNodeModifiers(node), [getNodeSpan(node)], childItems, getIndent(node)); - } - function createFunctionItem(node) { - if (node.body && node.body.kind === 192 /* Block */) { - var childItems = getItemsWorker(sortNodes(node.body.statements), createChildItem); - return getNavigationBarItem(!node.name ? "default" : node.name.text, ts.ScriptElementKind.functionElement, ts.getNodeModifiers(node), [getNodeSpan(node)], childItems, getIndent(node)); - } - return undefined; - } - function createSourceFileItem(node) { - var childItems = getItemsWorker(getChildNodes(node.statements), createChildItem); - if (childItems === undefined || childItems.length === 0) { - return undefined; - } - hasGlobalNode = true; - var rootName = ts.isExternalModule(node) - ? "\"" + ts.escapeString(ts.getBaseFileName(ts.removeFileExtension(ts.normalizePath(node.fileName)))) + "\"" - : ""; - return getNavigationBarItem(rootName, ts.ScriptElementKind.moduleElement, ts.ScriptElementKindModifier.none, [getNodeSpan(node)], childItems); - } - function createClassItem(node) { - var childItems; - if (node.members) { - var constructor = ts.forEach(node.members, function (member) { - return member.kind === 144 /* Constructor */ && member; - }); - // Add the constructor parameters in as children of the class (for property parameters). - // Note that *all non-binding pattern named* parameters will be added to the nodes array, but parameters that - // are not properties will be filtered out later by createChildItem. - var nodes = removeDynamicallyNamedProperties(node); - if (constructor) { - ts.addRange(nodes, ts.filter(constructor.parameters, function (p) { return !ts.isBindingPattern(p.name); })); - } - childItems = getItemsWorker(sortNodes(nodes), createChildItem); - } - var nodeName = !node.name ? "default" : node.name.text; - return getNavigationBarItem(nodeName, ts.ScriptElementKind.classElement, ts.getNodeModifiers(node), [getNodeSpan(node)], childItems, getIndent(node)); - } - function createEnumItem(node) { - var childItems = getItemsWorker(sortNodes(removeComputedProperties(node)), createChildItem); - return getNavigationBarItem(node.name.text, ts.ScriptElementKind.enumElement, ts.getNodeModifiers(node), [getNodeSpan(node)], childItems, getIndent(node)); - } - function createIterfaceItem(node) { - var childItems = getItemsWorker(sortNodes(removeDynamicallyNamedProperties(node)), createChildItem); - return getNavigationBarItem(node.name.text, ts.ScriptElementKind.interfaceElement, ts.getNodeModifiers(node), [getNodeSpan(node)], childItems, getIndent(node)); - } - } - function removeComputedProperties(node) { - return ts.filter(node.members, function (member) { return member.name === undefined || member.name.kind !== 136 /* ComputedPropertyName */; }); - } - /** - * Like removeComputedProperties, but retains the properties with well known symbol names - */ - function removeDynamicallyNamedProperties(node) { - return ts.filter(node.members, function (member) { return !ts.hasDynamicName(member); }); - } - function getInnermostModule(node) { - while (node.body.kind === 218 /* ModuleDeclaration */) { - node = node.body; - } - return node; - } - function getNodeSpan(node) { - return node.kind === 248 /* SourceFile */ - ? ts.createTextSpanFromBounds(node.getFullStart(), node.getEnd()) - : ts.createTextSpanFromBounds(node.getStart(), node.getEnd()); - } - function getTextOfNode(node) { - return ts.getTextOfNodeFromSourceText(sourceFile.text, node); - } - } - NavigationBar.getNavigationBarItems = getNavigationBarItems; - })(NavigationBar = ts.NavigationBar || (ts.NavigationBar = {})); -})(ts || (ts = {})); -/* @internal */ -var ts; -(function (ts) { - // Note(cyrusn): this enum is ordered from strongest match type to weakest match type. - (function (PatternMatchKind) { - PatternMatchKind[PatternMatchKind["exact"] = 0] = "exact"; - PatternMatchKind[PatternMatchKind["prefix"] = 1] = "prefix"; - PatternMatchKind[PatternMatchKind["substring"] = 2] = "substring"; - PatternMatchKind[PatternMatchKind["camelCase"] = 3] = "camelCase"; - })(ts.PatternMatchKind || (ts.PatternMatchKind = {})); - var PatternMatchKind = ts.PatternMatchKind; - function createPatternMatch(kind, punctuationStripped, isCaseSensitive, camelCaseWeight) { - return { - kind: kind, - punctuationStripped: punctuationStripped, - isCaseSensitive: isCaseSensitive, - camelCaseWeight: camelCaseWeight - }; - } - function createPatternMatcher(pattern) { - // We'll often see the same candidate string many times when searching (For example, when - // we see the name of a module that is used everywhere, or the name of an overload). As - // such, we cache the information we compute about the candidate for the life of this - // pattern matcher so we don't have to compute it multiple times. - var stringToWordSpans = {}; - pattern = pattern.trim(); - var fullPatternSegment = createSegment(pattern); - var dotSeparatedSegments = pattern.split(".").map(function (p) { return createSegment(p.trim()); }); - var invalidPattern = dotSeparatedSegments.length === 0 || ts.forEach(dotSeparatedSegments, segmentIsInvalid); - return { - getMatches: getMatches, - getMatchesForLastSegmentOfPattern: getMatchesForLastSegmentOfPattern, - patternContainsDots: dotSeparatedSegments.length > 1 - }; - // Quick checks so we can bail out when asked to match a candidate. - function skipMatch(candidate) { - return invalidPattern || !candidate; - } - function getMatchesForLastSegmentOfPattern(candidate) { - if (skipMatch(candidate)) { - return undefined; - } - return matchSegment(candidate, ts.lastOrUndefined(dotSeparatedSegments)); - } - function getMatches(candidateContainers, candidate) { - if (skipMatch(candidate)) { - return undefined; - } - // First, check that the last part of the dot separated pattern matches the name of the - // candidate. If not, then there's no point in proceeding and doing the more - // expensive work. - var candidateMatch = matchSegment(candidate, ts.lastOrUndefined(dotSeparatedSegments)); - if (!candidateMatch) { - return undefined; - } - candidateContainers = candidateContainers || []; - // -1 because the last part was checked against the name, and only the rest - // of the parts are checked against the container. - if (dotSeparatedSegments.length - 1 > candidateContainers.length) { - // There weren't enough container parts to match against the pattern parts. - // So this definitely doesn't match. - return undefined; - } - // So far so good. Now break up the container for the candidate and check if all - // the dotted parts match up correctly. - var totalMatch = candidateMatch; - for (var i = dotSeparatedSegments.length - 2, j = candidateContainers.length - 1; i >= 0; i--, j--) { - var segment = dotSeparatedSegments[i]; - var containerName = candidateContainers[j]; - var containerMatch = matchSegment(containerName, segment); - if (!containerMatch) { - // This container didn't match the pattern piece. So there's no match at all. - return undefined; - } - ts.addRange(totalMatch, containerMatch); - } - // Success, this symbol's full name matched against the dotted name the user was asking - // about. - return totalMatch; - } - function getWordSpans(word) { - if (!ts.hasProperty(stringToWordSpans, word)) { - stringToWordSpans[word] = breakIntoWordSpans(word); - } - return stringToWordSpans[word]; - } - function matchTextChunk(candidate, chunk, punctuationStripped) { - var index = indexOfIgnoringCase(candidate, chunk.textLowerCase); - if (index === 0) { - if (chunk.text.length === candidate.length) { - // a) Check if the part matches the candidate entirely, in an case insensitive or - // sensitive manner. If it does, return that there was an exact match. - return createPatternMatch(PatternMatchKind.exact, punctuationStripped, /*isCaseSensitive:*/ candidate === chunk.text); - } - else { - // b) Check if the part is a prefix of the candidate, in a case insensitive or sensitive - // manner. If it does, return that there was a prefix match. - return createPatternMatch(PatternMatchKind.prefix, punctuationStripped, /*isCaseSensitive:*/ startsWith(candidate, chunk.text)); - } - } - var isLowercase = chunk.isLowerCase; - if (isLowercase) { - if (index > 0) { - // c) If the part is entirely lowercase, then check if it is contained anywhere in the - // candidate in a case insensitive manner. If so, return that there was a substring - // match. - // - // Note: We only have a substring match if the lowercase part is prefix match of some - // word part. That way we don't match something like 'Class' when the user types 'a'. - // But we would match 'FooAttribute' (since 'Attribute' starts with 'a'). - var wordSpans = getWordSpans(candidate); - for (var _i = 0; _i < wordSpans.length; _i++) { - var span = wordSpans[_i]; - if (partStartsWith(candidate, span, chunk.text, /*ignoreCase:*/ true)) { - return createPatternMatch(PatternMatchKind.substring, punctuationStripped, - /*isCaseSensitive:*/ partStartsWith(candidate, span, chunk.text, /*ignoreCase:*/ false)); - } - } - } - } - else { - // d) If the part was not entirely lowercase, then check if it is contained in the - // candidate in a case *sensitive* manner. If so, return that there was a substring - // match. - if (candidate.indexOf(chunk.text) > 0) { - return createPatternMatch(PatternMatchKind.substring, punctuationStripped, /*isCaseSensitive:*/ true); - } - } - if (!isLowercase) { - // e) If the part was not entirely lowercase, then attempt a camel cased match as well. - if (chunk.characterSpans.length > 0) { - var candidateParts = getWordSpans(candidate); - var camelCaseWeight = tryCamelCaseMatch(candidate, candidateParts, chunk, /*ignoreCase:*/ false); - if (camelCaseWeight !== undefined) { - return createPatternMatch(PatternMatchKind.camelCase, punctuationStripped, /*isCaseSensitive:*/ true, /*camelCaseWeight:*/ camelCaseWeight); - } - camelCaseWeight = tryCamelCaseMatch(candidate, candidateParts, chunk, /*ignoreCase:*/ true); - if (camelCaseWeight !== undefined) { - return createPatternMatch(PatternMatchKind.camelCase, punctuationStripped, /*isCaseSensitive:*/ false, /*camelCaseWeight:*/ camelCaseWeight); - } - } - } - if (isLowercase) { - // f) Is the pattern a substring of the candidate starting on one of the candidate's word boundaries? - // We could check every character boundary start of the candidate for the pattern. However, that's - // an m * n operation in the wost case. Instead, find the first instance of the pattern - // substring, and see if it starts on a capital letter. It seems unlikely that the user will try to - // filter the list based on a substring that starts on a capital letter and also with a lowercase one. - // (Pattern: fogbar, Candidate: quuxfogbarFogBar). - if (chunk.text.length < candidate.length) { - if (index > 0 && isUpperCaseLetter(candidate.charCodeAt(index))) { - return createPatternMatch(PatternMatchKind.substring, punctuationStripped, /*isCaseSensitive:*/ false); - } - } - } - return undefined; - } - function containsSpaceOrAsterisk(text) { - for (var i = 0; i < text.length; i++) { - var ch = text.charCodeAt(i); - if (ch === 32 /* space */ || ch === 42 /* asterisk */) { - return true; - } - } - return false; - } - function matchSegment(candidate, segment) { - // First check if the segment matches as is. This is also useful if the segment contains - // characters we would normally strip when splitting into parts that we also may want to - // match in the candidate. For example if the segment is "@int" and the candidate is - // "@int", then that will show up as an exact match here. - // - // Note: if the segment contains a space or an asterisk then we must assume that it's a - // multi-word segment. - if (!containsSpaceOrAsterisk(segment.totalTextChunk.text)) { - var match = matchTextChunk(candidate, segment.totalTextChunk, /*punctuationStripped:*/ false); - if (match) { - return [match]; - } - } - // The logic for pattern matching is now as follows: - // - // 1) Break the segment passed in into words. Breaking is rather simple and a - // good way to think about it that if gives you all the individual alphanumeric words - // of the pattern. - // - // 2) For each word try to match the word against the candidate value. - // - // 3) Matching is as follows: - // - // a) Check if the word matches the candidate entirely, in an case insensitive or - // sensitive manner. If it does, return that there was an exact match. - // - // b) Check if the word is a prefix of the candidate, in a case insensitive or - // sensitive manner. If it does, return that there was a prefix match. - // - // c) If the word is entirely lowercase, then check if it is contained anywhere in the - // candidate in a case insensitive manner. If so, return that there was a substring - // match. - // - // Note: We only have a substring match if the lowercase part is prefix match of - // some word part. That way we don't match something like 'Class' when the user - // types 'a'. But we would match 'FooAttribute' (since 'Attribute' starts with - // 'a'). - // - // d) If the word was not entirely lowercase, then check if it is contained in the - // candidate in a case *sensitive* manner. If so, return that there was a substring - // match. - // - // e) If the word was not entirely lowercase, then attempt a camel cased match as - // well. - // - // f) The word is all lower case. Is it a case insensitive substring of the candidate starting - // on a part boundary of the candidate? - // - // Only if all words have some sort of match is the pattern considered matched. - var subWordTextChunks = segment.subWordTextChunks; - var matches = undefined; - for (var _i = 0; _i < subWordTextChunks.length; _i++) { - var subWordTextChunk = subWordTextChunks[_i]; - // Try to match the candidate with this word - var result = matchTextChunk(candidate, subWordTextChunk, /*punctuationStripped:*/ true); - if (!result) { - return undefined; - } - matches = matches || []; - matches.push(result); - } - return matches; - } - function partStartsWith(candidate, candidateSpan, pattern, ignoreCase, patternSpan) { - var patternPartStart = patternSpan ? patternSpan.start : 0; - var patternPartLength = patternSpan ? patternSpan.length : pattern.length; - if (patternPartLength > candidateSpan.length) { - // Pattern part is longer than the candidate part. There can never be a match. - return false; - } - if (ignoreCase) { - for (var i = 0; i < patternPartLength; i++) { - var ch1 = pattern.charCodeAt(patternPartStart + i); - var ch2 = candidate.charCodeAt(candidateSpan.start + i); - if (toLowerCase(ch1) !== toLowerCase(ch2)) { - return false; - } - } - } - else { - for (var i = 0; i < patternPartLength; i++) { - var ch1 = pattern.charCodeAt(patternPartStart + i); - var ch2 = candidate.charCodeAt(candidateSpan.start + i); - if (ch1 !== ch2) { - return false; - } - } - } - return true; - } - function tryCamelCaseMatch(candidate, candidateParts, chunk, ignoreCase) { - var chunkCharacterSpans = chunk.characterSpans; - // Note: we may have more pattern parts than candidate parts. This is because multiple - // pattern parts may match a candidate part. For example "SiUI" against "SimpleUI". - // We'll have 3 pattern parts Si/U/I against two candidate parts Simple/UI. However, U - // and I will both match in UI. - var currentCandidate = 0; - var currentChunkSpan = 0; - var firstMatch = undefined; - var contiguous = undefined; - while (true) { - // Let's consider our termination cases - if (currentChunkSpan === chunkCharacterSpans.length) { - // We did match! We shall assign a weight to this - var weight = 0; - // Was this contiguous? - if (contiguous) { - weight += 1; - } - // Did we start at the beginning of the candidate? - if (firstMatch === 0) { - weight += 2; - } - return weight; - } - else if (currentCandidate === candidateParts.length) { - // No match, since we still have more of the pattern to hit - return undefined; - } - var candidatePart = candidateParts[currentCandidate]; - var gotOneMatchThisCandidate = false; - // Consider the case of matching SiUI against SimpleUIElement. The candidate parts - // will be Simple/UI/Element, and the pattern parts will be Si/U/I. We'll match 'Si' - // against 'Simple' first. Then we'll match 'U' against 'UI'. However, we want to - // still keep matching pattern parts against that candidate part. - for (; currentChunkSpan < chunkCharacterSpans.length; currentChunkSpan++) { - var chunkCharacterSpan = chunkCharacterSpans[currentChunkSpan]; - if (gotOneMatchThisCandidate) { - // We've already gotten one pattern part match in this candidate. We will - // only continue trying to consumer pattern parts if the last part and this - // part are both upper case. - if (!isUpperCaseLetter(chunk.text.charCodeAt(chunkCharacterSpans[currentChunkSpan - 1].start)) || - !isUpperCaseLetter(chunk.text.charCodeAt(chunkCharacterSpans[currentChunkSpan].start))) { - break; - } - } - if (!partStartsWith(candidate, candidatePart, chunk.text, ignoreCase, chunkCharacterSpan)) { - break; - } - gotOneMatchThisCandidate = true; - firstMatch = firstMatch === undefined ? currentCandidate : firstMatch; - // If we were contiguous, then keep that value. If we weren't, then keep that - // value. If we don't know, then set the value to 'true' as an initial match is - // obviously contiguous. - contiguous = contiguous === undefined ? true : contiguous; - candidatePart = ts.createTextSpan(candidatePart.start + chunkCharacterSpan.length, candidatePart.length - chunkCharacterSpan.length); - } - // Check if we matched anything at all. If we didn't, then we need to unset the - // contiguous bit if we currently had it set. - // If we haven't set the bit yet, then that means we haven't matched anything so - // far, and we don't want to change that. - if (!gotOneMatchThisCandidate && contiguous !== undefined) { - contiguous = false; - } - // Move onto the next candidate. - currentCandidate++; - } - } - } - ts.createPatternMatcher = createPatternMatcher; - // Helper function to compare two matches to determine which is better. Matches are first - // ordered by kind (so all prefix matches always beat all substring matches). Then, if the - // match is a camel case match, the relative weights of the match are used to determine - // which is better (with a greater weight being better). Then if the match is of the same - // type, then a case sensitive match is considered better than an insensitive one. - function patternMatchCompareTo(match1, match2) { - return compareType(match1, match2) || - compareCamelCase(match1, match2) || - compareCase(match1, match2) || - comparePunctuation(match1, match2); - } - function comparePunctuation(result1, result2) { - // Consider a match to be better if it was successful without stripping punctuation - // versus a match that had to strip punctuation to succeed. - if (result1.punctuationStripped !== result2.punctuationStripped) { - return result1.punctuationStripped ? 1 : -1; - } - return 0; - } - function compareCase(result1, result2) { - if (result1.isCaseSensitive !== result2.isCaseSensitive) { - return result1.isCaseSensitive ? -1 : 1; - } - return 0; - } - function compareType(result1, result2) { - return result1.kind - result2.kind; - } - function compareCamelCase(result1, result2) { - if (result1.kind === PatternMatchKind.camelCase && result2.kind === PatternMatchKind.camelCase) { - // Swap the values here. If result1 has a higher weight, then we want it to come - // first. - return result2.camelCaseWeight - result1.camelCaseWeight; - } - return 0; - } - function createSegment(text) { - return { - totalTextChunk: createTextChunk(text), - subWordTextChunks: breakPatternIntoTextChunks(text) - }; - } - // A segment is considered invalid if we couldn't find any words in it. - function segmentIsInvalid(segment) { - return segment.subWordTextChunks.length === 0; - } - function isUpperCaseLetter(ch) { - // Fast check for the ascii range. - if (ch >= 65 /* A */ && ch <= 90 /* Z */) { - return true; - } - if (ch < 127 /* maxAsciiCharacter */ || !ts.isUnicodeIdentifierStart(ch, 2 /* Latest */)) { - return false; - } - // TODO: find a way to determine this for any unicode characters in a - // non-allocating manner. - var str = String.fromCharCode(ch); - return str === str.toUpperCase(); - } - function isLowerCaseLetter(ch) { - // Fast check for the ascii range. - if (ch >= 97 /* a */ && ch <= 122 /* z */) { - return true; - } - if (ch < 127 /* maxAsciiCharacter */ || !ts.isUnicodeIdentifierStart(ch, 2 /* Latest */)) { - return false; - } - // TODO: find a way to determine this for any unicode characters in a - // non-allocating manner. - var str = String.fromCharCode(ch); - return str === str.toLowerCase(); - } - function containsUpperCaseLetter(string) { - for (var i = 0, n = string.length; i < n; i++) { - if (isUpperCaseLetter(string.charCodeAt(i))) { - return true; - } - } - return false; - } - function startsWith(string, search) { - for (var i = 0, n = search.length; i < n; i++) { - if (string.charCodeAt(i) !== search.charCodeAt(i)) { - return false; - } - } - return true; - } - // Assumes 'value' is already lowercase. - function indexOfIgnoringCase(string, value) { - for (var i = 0, n = string.length - value.length; i <= n; i++) { - if (startsWithIgnoringCase(string, value, i)) { - return i; - } - } - return -1; - } - // Assumes 'value' is already lowercase. - function startsWithIgnoringCase(string, value, start) { - for (var i = 0, n = value.length; i < n; i++) { - var ch1 = toLowerCase(string.charCodeAt(i + start)); - var ch2 = value.charCodeAt(i); - if (ch1 !== ch2) { - return false; - } - } - return true; - } - function toLowerCase(ch) { - // Fast convert for the ascii range. - if (ch >= 65 /* A */ && ch <= 90 /* Z */) { - return 97 /* a */ + (ch - 65 /* A */); - } - if (ch < 127 /* maxAsciiCharacter */) { - return ch; - } - // TODO: find a way to compute this for any unicode characters in a - // non-allocating manner. - return String.fromCharCode(ch).toLowerCase().charCodeAt(0); - } - function isDigit(ch) { - // TODO(cyrusn): Find a way to support this for unicode digits. - return ch >= 48 /* _0 */ && ch <= 57 /* _9 */; - } - function isWordChar(ch) { - return isUpperCaseLetter(ch) || isLowerCaseLetter(ch) || isDigit(ch) || ch === 95 /* _ */ || ch === 36 /* $ */; - } - function breakPatternIntoTextChunks(pattern) { - var result = []; - var wordStart = 0; - var wordLength = 0; - for (var i = 0; i < pattern.length; i++) { - var ch = pattern.charCodeAt(i); - if (isWordChar(ch)) { - if (wordLength++ === 0) { - wordStart = i; - } - } - else { - if (wordLength > 0) { - result.push(createTextChunk(pattern.substr(wordStart, wordLength))); - wordLength = 0; - } - } - } - if (wordLength > 0) { - result.push(createTextChunk(pattern.substr(wordStart, wordLength))); - } - return result; - } - function createTextChunk(text) { - var textLowerCase = text.toLowerCase(); - return { - text: text, - textLowerCase: textLowerCase, - isLowerCase: text === textLowerCase, - characterSpans: breakIntoCharacterSpans(text) - }; - } - /* @internal */ function breakIntoCharacterSpans(identifier) { - return breakIntoSpans(identifier, /*word:*/ false); - } - ts.breakIntoCharacterSpans = breakIntoCharacterSpans; - /* @internal */ function breakIntoWordSpans(identifier) { - return breakIntoSpans(identifier, /*word:*/ true); - } - ts.breakIntoWordSpans = breakIntoWordSpans; - function breakIntoSpans(identifier, word) { - var result = []; - var wordStart = 0; - for (var i = 1, n = identifier.length; i < n; i++) { - var lastIsDigit = isDigit(identifier.charCodeAt(i - 1)); - var currentIsDigit = isDigit(identifier.charCodeAt(i)); - var hasTransitionFromLowerToUpper = transitionFromLowerToUpper(identifier, word, i); - var hasTransitionFromUpperToLower = transitionFromUpperToLower(identifier, word, i, wordStart); - if (charIsPunctuation(identifier.charCodeAt(i - 1)) || - charIsPunctuation(identifier.charCodeAt(i)) || - lastIsDigit !== currentIsDigit || - hasTransitionFromLowerToUpper || - hasTransitionFromUpperToLower) { - if (!isAllPunctuation(identifier, wordStart, i)) { - result.push(ts.createTextSpan(wordStart, i - wordStart)); - } - wordStart = i; - } - } - if (!isAllPunctuation(identifier, wordStart, identifier.length)) { - result.push(ts.createTextSpan(wordStart, identifier.length - wordStart)); - } - return result; - } - function charIsPunctuation(ch) { - switch (ch) { - case 33 /* exclamation */: - case 34 /* doubleQuote */: - case 35 /* hash */: - case 37 /* percent */: - case 38 /* ampersand */: - case 39 /* singleQuote */: - case 40 /* openParen */: - case 41 /* closeParen */: - case 42 /* asterisk */: - case 44 /* comma */: - case 45 /* minus */: - case 46 /* dot */: - case 47 /* slash */: - case 58 /* colon */: - case 59 /* semicolon */: - case 63 /* question */: - case 64 /* at */: - case 91 /* openBracket */: - case 92 /* backslash */: - case 93 /* closeBracket */: - case 95 /* _ */: - case 123 /* openBrace */: - case 125 /* closeBrace */: - return true; - } - return false; - } - function isAllPunctuation(identifier, start, end) { - for (var i = start; i < end; i++) { - var ch = identifier.charCodeAt(i); - // We don't consider _ or $ as punctuation as there may be things with that name. - if (!charIsPunctuation(ch) || ch === 95 /* _ */ || ch === 36 /* $ */) { - return false; - } - } - return true; - } - function transitionFromUpperToLower(identifier, word, index, wordStart) { - if (word) { - // Cases this supports: - // 1) IDisposable -> I, Disposable - // 2) UIElement -> UI, Element - // 3) HTMLDocument -> HTML, Document - // - // etc. - if (index !== wordStart && - index + 1 < identifier.length) { - var currentIsUpper = isUpperCaseLetter(identifier.charCodeAt(index)); - var nextIsLower = isLowerCaseLetter(identifier.charCodeAt(index + 1)); - if (currentIsUpper && nextIsLower) { - // We have a transition from an upper to a lower letter here. But we only - // want to break if all the letters that preceded are uppercase. i.e. if we - // have "Foo" we don't want to break that into "F, oo". But if we have - // "IFoo" or "UIFoo", then we want to break that into "I, Foo" and "UI, - // Foo". i.e. the last uppercase letter belongs to the lowercase letters - // that follows. Note: this will make the following not split properly: - // "HELLOthere". However, these sorts of names do not show up in .Net - // programs. - for (var i = wordStart; i < index; i++) { - if (!isUpperCaseLetter(identifier.charCodeAt(i))) { - return false; - } - } - return true; - } - } - } - return false; - } - function transitionFromLowerToUpper(identifier, word, index) { - var lastIsUpper = isUpperCaseLetter(identifier.charCodeAt(index - 1)); - var currentIsUpper = isUpperCaseLetter(identifier.charCodeAt(index)); - // See if the casing indicates we're starting a new word. Note: if we're breaking on - // words, then just seeing an upper case character isn't enough. Instead, it has to - // be uppercase and the previous character can't be uppercase. - // - // For example, breaking "AddMetadata" on words would make: Add Metadata - // - // on characters would be: A dd M etadata - // - // Break "AM" on words would be: AM - // - // on characters would be: A M - // - // We break the search string on characters. But we break the symbol name on words. - var transition = word - ? (currentIsUpper && !lastIsUpper) - : currentIsUpper; - return transition; - } -})(ts || (ts = {})); -/// -/* @internal */ -var ts; -(function (ts) { - var SignatureHelp; - (function (SignatureHelp) { - // A partially written generic type expression is not guaranteed to have the correct syntax tree. the expression could be parsed as less than/greater than expression or a comma expression - // or some other combination depending on what the user has typed so far. For the purposes of signature help we need to consider any location after "<" as a possible generic type reference. - // To do this, the method will back parse the expression starting at the position required. it will try to parse the current expression as a generic type expression, if it did succeed it - // will return the generic identifier that started the expression (e.g. "foo" in "foo(#a, b) -> The token introduces a list, and should begin a sig help session - // Case 2: - // fo#o#(a, b)# -> The token is either not associated with a list, or ends a list, so the session should end - // 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 */) { - // 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); - var isTypeArgList = callExpression.typeArguments && callExpression.typeArguments.pos === list.pos; - ts.Debug.assert(list !== undefined); - return { - kind: isTypeArgList ? 0 /* TypeArguments */ : 1 /* CallArguments */, - invocation: callExpression, - argumentsSpan: getApplicableSpanForArguments(list), - argumentIndex: 0, - argumentCount: getArgumentCount(list) - }; - } - // findListItemInfo can return undefined if we are not in parent's argument list - // or type argument list. This includes cases where the cursor is: - // - To the right of the closing paren, non-substitution template, or template tail. - // - Between the type arguments and the arguments (greater than token) - // - On the target of the call (parent.func) - // - On the 'new' keyword in a 'new' expression - var listItemInfo = ts.findListItemInfo(node); - if (listItemInfo) { - var list = listItemInfo.list; - var isTypeArgList = callExpression.typeArguments && callExpression.typeArguments.pos === list.pos; - var argumentIndex = getArgumentIndex(list, node); - var argumentCount = getArgumentCount(list); - ts.Debug.assert(argumentIndex === 0 || argumentIndex < argumentCount, "argumentCount < argumentIndex, " + argumentCount + " < " + argumentIndex); - return { - kind: isTypeArgList ? 0 /* TypeArguments */ : 1 /* CallArguments */, - invocation: callExpression, - argumentsSpan: getApplicableSpanForArguments(list), - argumentIndex: argumentIndex, - argumentCount: argumentCount - }; - } - } - else if (node.kind === 11 /* NoSubstitutionTemplateLiteral */ && node.parent.kind === 170 /* TaggedTemplateExpression */) { - // Check if we're actually inside the template; - // otherwise we'll fall out and return undefined. - if (ts.isInsideTemplateLiteral(node, position)) { - return getArgumentListInfoForTemplate(node.parent, /*argumentIndex*/ 0); - } - } - else if (node.kind === 12 /* TemplateHead */ && node.parent.parent.kind === 170 /* TaggedTemplateExpression */) { - var templateExpression = node.parent; - var tagExpression = templateExpression.parent; - ts.Debug.assert(templateExpression.kind === 183 /* TemplateExpression */); - var argumentIndex = ts.isInsideTemplateLiteral(node, position) ? 0 : 1; - return getArgumentListInfoForTemplate(tagExpression, argumentIndex); - } - else if (node.parent.kind === 190 /* TemplateSpan */ && node.parent.parent.parent.kind === 170 /* TaggedTemplateExpression */) { - var templateSpan = node.parent; - var templateExpression = templateSpan.parent; - var tagExpression = templateExpression.parent; - ts.Debug.assert(templateExpression.kind === 183 /* TemplateExpression */); - // If we're just after a template tail, don't show signature help. - if (node.kind === 14 /* TemplateTail */ && !ts.isInsideTemplateLiteral(node, position)) { - return undefined; - } - var spanIndex = templateExpression.templateSpans.indexOf(templateSpan); - var argumentIndex = getArgumentIndexForTemplatePiece(spanIndex, node); - return getArgumentListInfoForTemplate(tagExpression, argumentIndex); - } - return undefined; - } - function getArgumentIndex(argumentsList, node) { - // The list we got back can include commas. In the presence of errors it may - // also just have nodes without commas. For example "Foo(a b c)" will have 3 - // args without commas. We want to find what index we're at. So we count - // forward until we hit ourselves, only incrementing the index if it isn't a - // comma. - // - // Note: the subtlety around trailing commas (in getArgumentCount) does not apply - // here. That's because we're only walking forward until we hit the node we're - // on. In that case, even if we're after the trailing comma, we'll still see - // that trailing comma in the list, and we'll have generated the appropriate - // arg index. - var argumentIndex = 0; - var listChildren = argumentsList.getChildren(); - for (var _i = 0; _i < listChildren.length; _i++) { - var child = listChildren[_i]; - if (child === node) { - break; - } - if (child.kind !== 24 /* CommaToken */) { - argumentIndex++; - } - } - return argumentIndex; - } - function getArgumentCount(argumentsList) { - // The argument count for a list is normally the number of non-comma children it has. - // For example, if you have "Foo(a,b)" then there will be three children of the arg - // list 'a' '' 'b'. So, in this case the arg count will be 2. However, there - // is a small subtlety. If you have "Foo(a,)", then the child list will just have - // 'a' ''. So, in the case where the last child is a comma, we increase the - // arg count by one to compensate. - // - // Note: this subtlety only applies to the last comma. If you had "Foo(a,," then - // we'll have: 'a' '' '' - // 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 */) { - argumentCount++; - } - return argumentCount; - } - // spanIndex is either the index for a given template span. - // This does not give appropriate results for a NoSubstitutionTemplateLiteral - function getArgumentIndexForTemplatePiece(spanIndex, node) { - // Because the TemplateStringsArray is the first argument, we have to offset each substitution expression by 1. - // There are three cases we can encounter: - // 1. We are precisely in the template literal (argIndex = 0). - // 2. We are in or to the right of the substitution expression (argIndex = spanIndex + 1). - // 3. We are directly to the right of the template literal, but because we look for the token on the left, - // not enough to put us in the substitution expression; we should consider ourselves part of - // the *next* span's expression by offsetting the index (argIndex = (spanIndex + 1) + 1). - // - // Example: f `# abcd $#{# 1 + 1# }# efghi ${ #"#hello"# } # ` - // ^ ^ ^ ^ ^ ^ ^ ^ ^ - // Case: 1 1 3 2 1 3 2 2 1 - ts.Debug.assert(position >= node.getStart(), "Assumed 'position' could not occur before node."); - if (ts.isTemplateLiteralKind(node.kind)) { - if (ts.isInsideTemplateLiteral(node, position)) { - return 0; - } - return spanIndex + 2; - } - return spanIndex + 1; - } - function getArgumentListInfoForTemplate(tagExpression, argumentIndex) { - // argumentCount is either 1 or (numSpans + 1) to account for the template strings array argument. - var argumentCount = tagExpression.template.kind === 11 /* NoSubstitutionTemplateLiteral */ - ? 1 - : tagExpression.template.templateSpans.length + 1; - ts.Debug.assert(argumentIndex === 0 || argumentIndex < argumentCount, "argumentCount < argumentIndex, " + argumentCount + " < " + argumentIndex); - return { - kind: 2 /* TaggedTemplateArguments */, - invocation: tagExpression, - argumentsSpan: getApplicableSpanForTaggedTemplate(tagExpression), - argumentIndex: argumentIndex, - argumentCount: argumentCount - }; - } - function getApplicableSpanForArguments(argumentsList) { - // We use full start and skip trivia on the end because we want to include trivia on - // both sides. For example, - // - // foo( /*comment */ a, b, c /*comment*/ ) - // | | - // - // The applicable span is from the first bar to the second bar (inclusive, - // but not including parentheses) - var applicableSpanStart = argumentsList.getFullStart(); - var applicableSpanEnd = ts.skipTrivia(sourceFile.text, argumentsList.getEnd(), /*stopAfterLineBreak*/ false); - return ts.createTextSpan(applicableSpanStart, applicableSpanEnd - applicableSpanStart); - } - function getApplicableSpanForTaggedTemplate(taggedTemplate) { - var template = taggedTemplate.template; - var applicableSpanStart = template.getStart(); - var applicableSpanEnd = template.getEnd(); - // We need to adjust the end position for the case where the template does not have a tail. - // Otherwise, we will not show signature help past the expression. - // For example, - // - // ` ${ 1 + 1 foo(10) - // | | - // - // 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 === 183 /* TemplateExpression */) { - var lastSpan = ts.lastOrUndefined(template.templateSpans); - if (lastSpan.literal.getFullWidth() === 0) { - applicableSpanEnd = ts.skipTrivia(sourceFile.text, applicableSpanEnd, /*stopAfterLineBreak*/ false); - } - } - return ts.createTextSpan(applicableSpanStart, applicableSpanEnd - applicableSpanStart); - } - function getContainingArgumentInfo(node) { - for (var n = node; n.kind !== 248 /* SourceFile */; n = n.parent) { - if (ts.isFunctionBlock(n)) { - return undefined; - } - // If the node is not a subspan of its parent, this is a big problem. - // There have been crashes that might be caused by this violation. - if (n.pos < n.parent.pos || n.end > n.parent.end) { - ts.Debug.fail("Node of kind " + n.kind + " is not a subspan of its parent of kind " + n.parent.kind); - } - var argumentInfo_1 = getImmediatelyContainingArgumentInfo(n); - if (argumentInfo_1) { - return argumentInfo_1; - } - } - return undefined; - } - function getChildListThatStartsWithOpenerToken(parent, openerToken, sourceFile) { - var children = parent.getChildren(sourceFile); - var indexOfOpenerToken = children.indexOf(openerToken); - ts.Debug.assert(indexOfOpenerToken >= 0 && children.length > indexOfOpenerToken + 1); - return children[indexOfOpenerToken + 1]; - } - /** - * The selectedItemIndex could be negative for several reasons. - * 1. There are too many arguments for all of the overloads - * 2. None of the overloads were type compatible - * The solution here is to try to pick the best overload by picking - * either the first one that has an appropriate number of parameters, - * or the one with the most parameters. - */ - function selectBestInvalidOverloadIndex(candidates, argumentCount) { - var maxParamsSignatureIndex = -1; - var maxParams = -1; - for (var i = 0; i < candidates.length; i++) { - var candidate = candidates[i]; - if (candidate.hasRestParameter || candidate.parameters.length >= argumentCount) { - return i; - } - if (candidate.parameters.length > maxParams) { - maxParams = candidate.parameters.length; - maxParamsSignatureIndex = i; - } - } - return maxParamsSignatureIndex; - } - function createSignatureHelpItems(candidates, bestSignature, argumentListInfo) { - var applicableSpan = argumentListInfo.argumentsSpan; - var isTypeParameterList = argumentListInfo.kind === 0 /* TypeArguments */; - var invocation = argumentListInfo.invocation; - var callTarget = ts.getInvokedExpression(invocation); - var callTargetSymbol = typeChecker.getSymbolAtLocation(callTarget); - var callTargetDisplayParts = callTargetSymbol && ts.symbolToDisplayParts(typeChecker, callTargetSymbol, /*enclosingDeclaration*/ undefined, /*meaning*/ undefined); - var items = ts.map(candidates, function (candidateSignature) { - var signatureHelpParameters; - var prefixDisplayParts = []; - var suffixDisplayParts = []; - if (callTargetDisplayParts) { - ts.addRange(prefixDisplayParts, callTargetDisplayParts); - } - if (isTypeParameterList) { - prefixDisplayParts.push(ts.punctuationPart(25 /* LessThanToken */)); - var typeParameters = candidateSignature.typeParameters; - signatureHelpParameters = typeParameters && typeParameters.length > 0 ? ts.map(typeParameters, createSignatureHelpParameterForTypeParameter) : emptyArray; - suffixDisplayParts.push(ts.punctuationPart(27 /* GreaterThanToken */)); - var parameterParts = ts.mapToDisplayParts(function (writer) { - return typeChecker.getSymbolDisplayBuilder().buildDisplayForParametersAndDelimiters(candidateSignature.parameters, writer, invocation); - }); - ts.addRange(suffixDisplayParts, parameterParts); - } - else { - var typeParameterParts = ts.mapToDisplayParts(function (writer) { - return typeChecker.getSymbolDisplayBuilder().buildDisplayForTypeParametersAndDelimiters(candidateSignature.typeParameters, writer, invocation); - }); - ts.addRange(prefixDisplayParts, typeParameterParts); - prefixDisplayParts.push(ts.punctuationPart(17 /* OpenParenToken */)); - var parameters = candidateSignature.parameters; - signatureHelpParameters = parameters.length > 0 ? ts.map(parameters, createSignatureHelpParameterForParameter) : emptyArray; - suffixDisplayParts.push(ts.punctuationPart(18 /* CloseParenToken */)); - } - var returnTypeParts = ts.mapToDisplayParts(function (writer) { - return typeChecker.getSymbolDisplayBuilder().buildReturnTypeDisplay(candidateSignature, writer, invocation); - }); - ts.addRange(suffixDisplayParts, returnTypeParts); - return { - isVariadic: candidateSignature.hasRestParameter, - prefixDisplayParts: prefixDisplayParts, - suffixDisplayParts: suffixDisplayParts, - separatorDisplayParts: [ts.punctuationPart(24 /* CommaToken */), ts.spacePart()], - parameters: signatureHelpParameters, - documentation: candidateSignature.getDocumentationComment() - }; - }); - var argumentIndex = argumentListInfo.argumentIndex; - // argumentCount is the *apparent* number of arguments. - var argumentCount = argumentListInfo.argumentCount; - var selectedItemIndex = candidates.indexOf(bestSignature); - if (selectedItemIndex < 0) { - selectedItemIndex = selectBestInvalidOverloadIndex(candidates, argumentCount); - } - ts.Debug.assert(argumentIndex === 0 || argumentIndex < argumentCount, "argumentCount < argumentIndex, " + argumentCount + " < " + argumentIndex); - return { - items: items, - applicableSpan: applicableSpan, - selectedItemIndex: selectedItemIndex, - argumentIndex: argumentIndex, - argumentCount: argumentCount - }; - function createSignatureHelpParameterForParameter(parameter) { - var displayParts = ts.mapToDisplayParts(function (writer) { - return typeChecker.getSymbolDisplayBuilder().buildParameterDisplay(parameter, writer, invocation); - }); - return { - name: parameter.name, - documentation: parameter.getDocumentationComment(), - displayParts: displayParts, - isOptional: typeChecker.isOptionalParameter(parameter.valueDeclaration) - }; - } - function createSignatureHelpParameterForTypeParameter(typeParameter) { - var displayParts = ts.mapToDisplayParts(function (writer) { - return typeChecker.getSymbolDisplayBuilder().buildTypeParameterDisplay(typeParameter, writer, invocation); - }); - return { - name: typeParameter.symbol.name, - documentation: emptyArray, - displayParts: displayParts, - isOptional: false - }; - } - } - } - SignatureHelp.getSignatureHelpItems = getSignatureHelpItems; - })(SignatureHelp = ts.SignatureHelp || (ts.SignatureHelp = {})); -})(ts || (ts = {})); -// These utilities are common to multiple language service features. -/* @internal */ -var ts; -(function (ts) { - function getEndLinePosition(line, sourceFile) { - ts.Debug.assert(line >= 0); - var lineStarts = sourceFile.getLineStarts(); - var lineIndex = line; - if (lineIndex + 1 === lineStarts.length) { - // last line - return EOF - return sourceFile.text.length - 1; - } - else { - // current line start - var start = lineStarts[lineIndex]; - // take the start position of the next line -1 = it should be some line break - var pos = lineStarts[lineIndex + 1] - 1; - ts.Debug.assert(ts.isLineBreak(sourceFile.text.charCodeAt(pos))); - // walk backwards skipping line breaks, stop the the beginning of current line. - // i.e: - // - // $ <- end of line for this position should match the start position - while (start <= pos && ts.isLineBreak(sourceFile.text.charCodeAt(pos))) { - pos--; - } - return pos; - } - } - ts.getEndLinePosition = getEndLinePosition; - function getLineStartPositionForPosition(position, sourceFile) { - var lineStarts = sourceFile.getLineStarts(); - var line = sourceFile.getLineAndCharacterOfPosition(position).line; - return lineStarts[line]; - } - ts.getLineStartPositionForPosition = getLineStartPositionForPosition; - function rangeContainsRange(r1, r2) { - return startEndContainsRange(r1.pos, r1.end, r2); - } - ts.rangeContainsRange = rangeContainsRange; - function startEndContainsRange(start, end, range) { - return start <= range.pos && end >= range.end; - } - ts.startEndContainsRange = startEndContainsRange; - function rangeContainsStartEnd(range, start, end) { - return range.pos <= start && range.end >= end; - } - ts.rangeContainsStartEnd = rangeContainsStartEnd; - function rangeOverlapsWithStartEnd(r1, start, end) { - return startEndOverlapsWithStartEnd(r1.pos, r1.end, start, end); - } - ts.rangeOverlapsWithStartEnd = rangeOverlapsWithStartEnd; - function startEndOverlapsWithStartEnd(start1, end1, start2, end2) { - var start = Math.max(start1, start2); - var end = Math.min(end1, end2); - return start < end; - } - ts.startEndOverlapsWithStartEnd = startEndOverlapsWithStartEnd; - function positionBelongsToNode(candidate, position, sourceFile) { - return candidate.end > position || !isCompletedNode(candidate, sourceFile); - } - ts.positionBelongsToNode = positionBelongsToNode; - function isCompletedNode(n, sourceFile) { - if (ts.nodeIsMissing(n)) { - return false; - } - switch (n.kind) { - case 214 /* ClassDeclaration */: - case 215 /* InterfaceDeclaration */: - case 217 /* EnumDeclaration */: - case 165 /* ObjectLiteralExpression */: - case 161 /* ObjectBindingPattern */: - case 155 /* TypeLiteral */: - case 192 /* Block */: - case 219 /* ModuleBlock */: - case 220 /* CaseBlock */: - return nodeEndsWith(n, 16 /* CloseBraceToken */, sourceFile); - case 244 /* CatchClause */: - return isCompletedNode(n.block, sourceFile); - case 169 /* NewExpression */: - if (!n.arguments) { - return true; - } - // fall through - case 168 /* CallExpression */: - case 172 /* ParenthesizedExpression */: - case 160 /* ParenthesizedType */: - return nodeEndsWith(n, 18 /* CloseParenToken */, sourceFile); - case 152 /* FunctionType */: - case 153 /* ConstructorType */: - return isCompletedNode(n.type, sourceFile); - case 144 /* Constructor */: - case 145 /* GetAccessor */: - case 146 /* SetAccessor */: - case 213 /* FunctionDeclaration */: - case 173 /* FunctionExpression */: - case 143 /* MethodDeclaration */: - case 142 /* MethodSignature */: - case 148 /* ConstructSignature */: - case 147 /* CallSignature */: - case 174 /* ArrowFunction */: - if (n.body) { - return isCompletedNode(n.body, sourceFile); - } - if (n.type) { - return isCompletedNode(n.type, sourceFile); - } - // 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 218 /* ModuleDeclaration */: - return n.body && isCompletedNode(n.body, sourceFile); - case 196 /* IfStatement */: - if (n.elseStatement) { - return isCompletedNode(n.elseStatement, sourceFile); - } - return isCompletedNode(n.thenStatement, sourceFile); - case 195 /* ExpressionStatement */: - return isCompletedNode(n.expression, sourceFile) || - hasChildOfKind(n, 23 /* SemicolonToken */); - case 164 /* ArrayLiteralExpression */: - case 162 /* ArrayBindingPattern */: - case 167 /* ElementAccessExpression */: - case 136 /* ComputedPropertyName */: - case 157 /* TupleType */: - return nodeEndsWith(n, 20 /* CloseBracketToken */, sourceFile); - case 149 /* IndexSignature */: - if (n.type) { - return isCompletedNode(n.type, sourceFile); - } - return hasChildOfKind(n, 20 /* CloseBracketToken */, sourceFile); - case 241 /* CaseClause */: - case 242 /* DefaultClause */: - // there is no such thing as terminator token for CaseClause/DefaultClause so for simplicitly always consider them non-completed - return false; - case 199 /* ForStatement */: - case 200 /* ForInStatement */: - case 201 /* ForOfStatement */: - case 198 /* WhileStatement */: - return isCompletedNode(n.statement, sourceFile); - case 197 /* 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); - if (hasWhileKeyword) { - return nodeEndsWith(n, 18 /* CloseParenToken */, sourceFile); - } - return isCompletedNode(n.statement, sourceFile); - case 154 /* TypeQuery */: - return isCompletedNode(n.exprName, sourceFile); - case 176 /* TypeOfExpression */: - case 175 /* DeleteExpression */: - case 177 /* VoidExpression */: - case 184 /* YieldExpression */: - case 185 /* SpreadElementExpression */: - var unaryWordExpression = n; - return isCompletedNode(unaryWordExpression.expression, sourceFile); - case 170 /* TaggedTemplateExpression */: - return isCompletedNode(n.template, sourceFile); - case 183 /* TemplateExpression */: - var lastSpan = ts.lastOrUndefined(n.templateSpans); - return isCompletedNode(lastSpan, sourceFile); - case 190 /* TemplateSpan */: - return ts.nodeIsPresent(n.literal); - case 179 /* PrefixUnaryExpression */: - return isCompletedNode(n.operand, sourceFile); - case 181 /* BinaryExpression */: - return isCompletedNode(n.right, sourceFile); - case 182 /* ConditionalExpression */: - return isCompletedNode(n.whenFalse, sourceFile); - default: - return true; - } - } - ts.isCompletedNode = isCompletedNode; - /* - * Checks if node ends with 'expectedLastToken'. - * If child at position 'length - 1' is 'SemicolonToken' it is skipped and 'expectedLastToken' is compared with child at position 'length - 2'. - */ - function nodeEndsWith(n, expectedLastToken, sourceFile) { - var children = n.getChildren(sourceFile); - if (children.length) { - var last = ts.lastOrUndefined(children); - if (last.kind === expectedLastToken) { - return true; - } - else if (last.kind === 23 /* SemicolonToken */ && children.length !== 1) { - return children[children.length - 2].kind === expectedLastToken; - } - } - return false; - } - function findListItemInfo(node) { - var list = findContainingList(node); - // It is possible at this point for syntaxList to be undefined, either if - // node.parent had no list child, or if none of its list children contained - // the span of node. If this happens, return undefined. The caller should - // handle this case. - if (!list) { - return undefined; - } - var children = list.getChildren(); - var listItemIndex = ts.indexOf(children, node); - return { - listItemIndex: listItemIndex, - list: list - }; - } - ts.findListItemInfo = findListItemInfo; - function hasChildOfKind(n, kind, sourceFile) { - return !!findChildOfKind(n, kind, sourceFile); - } - ts.hasChildOfKind = hasChildOfKind; - function findChildOfKind(n, kind, sourceFile) { - return ts.forEach(n.getChildren(sourceFile), function (c) { return c.kind === kind && c; }); - } - ts.findChildOfKind = findChildOfKind; - function findContainingList(node) { - // The node might be a list element (nonsynthetic) or a comma (synthetic). Either way, it will - // be parented by the container of the SyntaxList, not the SyntaxList itself. - // In order to find the list item index, we first need to locate SyntaxList itself and then search - // for the position of the relevant node (or comma). - var syntaxList = ts.forEach(node.parent.getChildren(), function (c) { - // find syntax list that covers the span of the node - if (c.kind === 271 /* SyntaxList */ && c.pos <= node.pos && c.end >= node.end) { - return c; - } - }); - // Either we didn't find an appropriate list, or the list must contain us. - ts.Debug.assert(!syntaxList || ts.contains(syntaxList.getChildren(), node)); - return syntaxList; - } - ts.findContainingList = findContainingList; - /* Gets the token whose text has range [start, end) and - * position >= start and (position < end or (position === end && token is keyword or identifier)) - */ - function getTouchingWord(sourceFile, position) { - return getTouchingToken(sourceFile, position, function (n) { return isWord(n.kind); }); - } - ts.getTouchingWord = getTouchingWord; - /* Gets the token whose text has range [start, end) and position >= start - * and (position < end or (position === end && token is keyword or identifier or numeric\string litera)) - */ - function getTouchingPropertyName(sourceFile, position) { - return getTouchingToken(sourceFile, position, function (n) { return isPropertyName(n.kind); }); - } - ts.getTouchingPropertyName = getTouchingPropertyName; - /** Returns the token if position is in [start, end) or if position === end and includeItemAtEndPosition(token) === true */ - function getTouchingToken(sourceFile, position, includeItemAtEndPosition) { - return getTokenAtPositionWorker(sourceFile, position, /*allowPositionInLeadingTrivia*/ false, includeItemAtEndPosition); - } - ts.getTouchingToken = getTouchingToken; - /** Returns a token if position is in [start-of-leading-trivia, end) */ - function getTokenAtPosition(sourceFile, position) { - return getTokenAtPositionWorker(sourceFile, position, /*allowPositionInLeadingTrivia*/ true, /*includeItemAtEndPosition*/ undefined); - } - ts.getTokenAtPosition = getTokenAtPosition; - /** Get the token whose text contains the position */ - function getTokenAtPositionWorker(sourceFile, position, allowPositionInLeadingTrivia, includeItemAtEndPosition) { - var current = sourceFile; - outer: while (true) { - if (isToken(current)) { - // exit early - return current; - } - // find the child that contains 'position' - for (var i = 0, n = current.getChildCount(sourceFile); i < n; i++) { - var child = current.getChildAt(i); - var start = allowPositionInLeadingTrivia ? child.getFullStart() : child.getStart(sourceFile); - if (start <= position) { - var end = child.getEnd(); - if (position < end || (position === end && child.kind === 1 /* EndOfFileToken */)) { - current = child; - continue outer; - } - else if (includeItemAtEndPosition && end === position) { - var previousToken = findPrecedingToken(position, sourceFile, child); - if (previousToken && includeItemAtEndPosition(previousToken)) { - return previousToken; - } - } - } - } - return current; - } - } - /** - * The token on the left of the position is the token that strictly includes the position - * or sits to the left of the cursor if it is on a boundary. For example - * - * fo|o -> will return foo - * foo |bar -> will return foo - * - */ - function findTokenOnLeftOfPosition(file, position) { - // Ideally, getTokenAtPosition should return a token. However, it is currently - // broken, so we do a check to make sure the result was indeed a token. - var tokenAtPosition = getTokenAtPosition(file, position); - if (isToken(tokenAtPosition) && position > tokenAtPosition.getStart(file) && position < tokenAtPosition.getEnd()) { - return tokenAtPosition; - } - return findPrecedingToken(position, file); - } - ts.findTokenOnLeftOfPosition = findTokenOnLeftOfPosition; - function findNextToken(previousToken, parent) { - return find(parent); - function find(n) { - if (isToken(n) && n.pos === previousToken.end) { - // this is token that starts at the end of previous token - return it - return n; - } - var children = n.getChildren(); - for (var _i = 0; _i < children.length; _i++) { - var child = children[_i]; - var shouldDiveInChildNode = - // previous token is enclosed somewhere in the child - (child.pos <= previousToken.pos && child.end > previousToken.end) || - // previous token ends exactly at the beginning of child - (child.pos === previousToken.end); - if (shouldDiveInChildNode && nodeHasTokens(child)) { - return find(child); - } - } - return undefined; - } - } - ts.findNextToken = findNextToken; - function findPrecedingToken(position, sourceFile, startNode) { - return find(startNode || sourceFile); - function findRightmostToken(n) { - if (isToken(n) || n.kind === 236 /* JsxText */) { - return n; - } - var children = n.getChildren(); - var candidate = findRightmostChildNodeWithTokens(children, /*exclusiveStartPosition*/ children.length); - return candidate && findRightmostToken(candidate); - } - function find(n) { - if (isToken(n) || n.kind === 236 /* JsxText */) { - return n; - } - var children = n.getChildren(); - for (var i = 0, len = children.length; i < len; i++) { - var child = children[i]; - // condition 'position < child.end' checks if child node end after the position - // in the example below this condition will be false for 'aaaa' and 'bbbb' and true for 'ccc' - // aaaa___bbbb___$__ccc - // after we found child node with end after the position we check if start of the node is after the position. - // if yes - then position is in the trivia and we need to look into the previous child to find the token in question. - // 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 === 236 /* JsxText */)) { - var start = child.getStart(sourceFile); - var lookInPreviousChild = (start >= position) || - (child.kind === 236 /* JsxText */ && start === child.end); // whitespace only JsxText - if (lookInPreviousChild) { - // actual start of the node is past the position - previous token should be at the end of previous child - var candidate = findRightmostChildNodeWithTokens(children, /*exclusiveStartPosition*/ i); - return candidate && findRightmostToken(candidate); - } - else { - // candidate should be in this node - return find(child); - } - } - } - ts.Debug.assert(startNode !== undefined || n.kind === 248 /* SourceFile */); - // Here we know that none of child token nodes embrace the position, - // the only known case is when position is at the end of the file. - // Try to find the rightmost token in the file without filtering. - // Namely we are skipping the check: 'position < node.end' - if (children.length) { - var candidate = findRightmostChildNodeWithTokens(children, /*exclusiveStartPosition*/ children.length); - return candidate && findRightmostToken(candidate); - } - } - /// finds last node that is considered as candidate for search (isCandidate(node) === true) starting from 'exclusiveStartPosition' - function findRightmostChildNodeWithTokens(children, exclusiveStartPosition) { - for (var i = exclusiveStartPosition - 1; i >= 0; --i) { - if (nodeHasTokens(children[i])) { - return children[i]; - } - } - } - } - ts.findPrecedingToken = findPrecedingToken; - function isInString(sourceFile, position) { - var token = getTokenAtPosition(sourceFile, position); - return token && token.kind === 9 /* StringLiteral */ && position > token.getStart(); - } - ts.isInString = isInString; - function isInComment(sourceFile, position) { - return isInCommentHelper(sourceFile, position, /*predicate*/ undefined); - } - ts.isInComment = isInComment; - /** - * Returns true if the cursor at position in sourceFile is within a comment that additionally - * satisfies predicate, and false otherwise. - */ - function isInCommentHelper(sourceFile, position, predicate) { - var token = getTokenAtPosition(sourceFile, position); - if (token && position <= token.getStart()) { - var commentRanges = ts.getLeadingCommentRanges(sourceFile.text, token.pos); - // The end marker of a single-line comment does not include the newline character. - // In the following case, we are inside a comment (^ denotes the cursor position): - // - // // asdf ^\n - // - // But for multi-line comments, we don't want to be inside the comment in the following case: - // - // /* asdf */^ - // - // Internally, we represent the end of the comment at the newline and closing '/', respectively. - return predicate ? - ts.forEach(commentRanges, function (c) { return c.pos < position && - (c.kind == 2 /* SingleLineCommentTrivia */ ? position <= c.end : position < c.end) && - predicate(c); }) : - ts.forEach(commentRanges, function (c) { return c.pos < position && - (c.kind == 2 /* SingleLineCommentTrivia */ ? position <= c.end : position < c.end); }); - } - return false; - } - ts.isInCommentHelper = isInCommentHelper; - function hasDocComment(sourceFile, position) { - var token = getTokenAtPosition(sourceFile, position); - // First, we have to see if this position actually landed in a comment. - var commentRanges = ts.getLeadingCommentRanges(sourceFile.text, token.pos); - return ts.forEach(commentRanges, jsDocPrefix); - function jsDocPrefix(c) { - var text = sourceFile.text; - return text.length >= c.pos + 3 && text[c.pos] === '/' && text[c.pos + 1] === '*' && text[c.pos + 2] === '*'; - } - } - ts.hasDocComment = hasDocComment; - /** - * Get the corresponding JSDocTag node if the position is in a jsDoc comment - */ - function getJsDocTagAtPosition(sourceFile, position) { - var node = ts.getTokenAtPosition(sourceFile, position); - if (isToken(node)) { - switch (node.kind) { - case 102 /* VarKeyword */: - case 108 /* LetKeyword */: - case 74 /* ConstKeyword */: - // if the current token is var, let or const, skip the VariableDeclarationList - node = node.parent === undefined ? undefined : node.parent.parent; - break; - default: - node = node.parent; - break; - } - } - if (node) { - var jsDocComment = node.jsDocComment; - if (jsDocComment) { - for (var _i = 0, _a = jsDocComment.tags; _i < _a.length; _i++) { - var tag = _a[_i]; - if (tag.pos <= position && position <= tag.end) { - return tag; - } - } - } - } - return undefined; - } - ts.getJsDocTagAtPosition = getJsDocTagAtPosition; - function nodeHasTokens(n) { - // If we have a token or node that has a non-zero width, it must have tokens. - // Note, that getWidth() does not take trivia into account. - return n.getWidth() !== 0; - } - function getNodeModifiers(node) { - var flags = ts.getCombinedNodeFlags(node); - var result = []; - if (flags & 32 /* Private */) - result.push(ts.ScriptElementKindModifier.privateMemberModifier); - if (flags & 64 /* Protected */) - result.push(ts.ScriptElementKindModifier.protectedMemberModifier); - if (flags & 16 /* Public */) - result.push(ts.ScriptElementKindModifier.publicMemberModifier); - if (flags & 128 /* Static */) - result.push(ts.ScriptElementKindModifier.staticModifier); - if (flags & 256 /* Abstract */) - result.push(ts.ScriptElementKindModifier.abstractModifier); - if (flags & 1 /* Export */) - result.push(ts.ScriptElementKindModifier.exportedModifier); - if (ts.isInAmbientContext(node)) - result.push(ts.ScriptElementKindModifier.ambientModifier); - return result.length > 0 ? result.join(',') : ts.ScriptElementKindModifier.none; - } - ts.getNodeModifiers = getNodeModifiers; - function getTypeArgumentOrTypeParameterList(node) { - if (node.kind === 151 /* TypeReference */ || node.kind === 168 /* CallExpression */) { - return node.typeArguments; - } - if (ts.isFunctionLike(node) || node.kind === 214 /* ClassDeclaration */ || node.kind === 215 /* InterfaceDeclaration */) { - return node.typeParameters; - } - return undefined; - } - ts.getTypeArgumentOrTypeParameterList = getTypeArgumentOrTypeParameterList; - function isToken(n) { - return n.kind >= 0 /* FirstToken */ && n.kind <= 134 /* LastToken */; - } - ts.isToken = isToken; - function isWord(kind) { - return kind === 69 /* Identifier */ || ts.isKeyword(kind); - } - ts.isWord = isWord; - function isPropertyName(kind) { - return kind === 9 /* StringLiteral */ || kind === 8 /* NumericLiteral */ || isWord(kind); - } - function isComment(kind) { - return kind === 2 /* SingleLineCommentTrivia */ || kind === 3 /* MultiLineCommentTrivia */; - } - ts.isComment = isComment; - function isStringOrRegularExpressionOrTemplateLiteral(kind) { - if (kind === 9 /* StringLiteral */ - || kind === 10 /* RegularExpressionLiteral */ - || ts.isTemplateLiteralKind(kind)) { - return true; - } - return false; - } - ts.isStringOrRegularExpressionOrTemplateLiteral = isStringOrRegularExpressionOrTemplateLiteral; - function isPunctuation(kind) { - return 15 /* FirstPunctuation */ <= kind && kind <= 68 /* LastPunctuation */; - } - ts.isPunctuation = isPunctuation; - function isInsideTemplateLiteral(node, position) { - return ts.isTemplateLiteralKind(node.kind) - && (node.getStart() < position && position < node.getEnd()) || (!!node.isUnterminated && position === node.getEnd()); - } - ts.isInsideTemplateLiteral = isInsideTemplateLiteral; - function isAccessibilityModifier(kind) { - switch (kind) { - case 112 /* PublicKeyword */: - case 110 /* PrivateKeyword */: - case 111 /* ProtectedKeyword */: - return true; - } - return false; - } - ts.isAccessibilityModifier = isAccessibilityModifier; - function compareDataObjects(dst, src) { - for (var e in dst) { - if (typeof dst[e] === "object") { - if (!compareDataObjects(dst[e], src[e])) { - return false; - } - } - else if (typeof dst[e] !== "function") { - if (dst[e] !== src[e]) { - return false; - } - } - } - return true; - } - ts.compareDataObjects = compareDataObjects; -})(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 === 138 /* Parameter */; - } - ts.isFirstDeclarationOfSymbolParameter = isFirstDeclarationOfSymbolParameter; - var displayPartWriter = getDisplayPartWriter(); - function getDisplayPartWriter() { - var displayParts; - var lineStart; - var indent; - resetWriter(); - return { - displayParts: function () { return displayParts; }, - writeKeyword: function (text) { return writeKind(text, ts.SymbolDisplayPartKind.keyword); }, - writeOperator: function (text) { return writeKind(text, ts.SymbolDisplayPartKind.operator); }, - writePunctuation: function (text) { return writeKind(text, ts.SymbolDisplayPartKind.punctuation); }, - writeSpace: function (text) { return writeKind(text, ts.SymbolDisplayPartKind.space); }, - writeStringLiteral: function (text) { return writeKind(text, ts.SymbolDisplayPartKind.stringLiteral); }, - writeParameter: function (text) { return writeKind(text, ts.SymbolDisplayPartKind.parameterName); }, - writeSymbol: writeSymbol, - writeLine: writeLine, - increaseIndent: function () { indent++; }, - decreaseIndent: function () { indent--; }, - clear: resetWriter, - trackSymbol: function () { }, - reportInaccessibleThisError: function () { } - }; - function writeIndent() { - if (lineStart) { - var indentString = ts.getIndentString(indent); - if (indentString) { - displayParts.push(displayPart(indentString, ts.SymbolDisplayPartKind.space)); - } - lineStart = false; - } - } - function writeKind(text, kind) { - writeIndent(); - displayParts.push(displayPart(text, kind)); - } - function writeSymbol(text, symbol) { - writeIndent(); - displayParts.push(symbolPart(text, symbol)); - } - function writeLine() { - displayParts.push(lineBreakPart()); - lineStart = true; - } - function resetWriter() { - displayParts = []; - lineStart = true; - indent = 0; - } - } - function symbolPart(text, symbol) { - return displayPart(text, displayPartKind(symbol), symbol); - function displayPartKind(symbol) { - var flags = symbol.flags; - if (flags & 3 /* Variable */) { - return isFirstDeclarationOfSymbolParameter(symbol) ? ts.SymbolDisplayPartKind.parameterName : ts.SymbolDisplayPartKind.localName; - } - else if (flags & 4 /* Property */) { - return ts.SymbolDisplayPartKind.propertyName; - } - else if (flags & 32768 /* GetAccessor */) { - return ts.SymbolDisplayPartKind.propertyName; - } - else if (flags & 65536 /* SetAccessor */) { - return ts.SymbolDisplayPartKind.propertyName; - } - else if (flags & 8 /* EnumMember */) { - return ts.SymbolDisplayPartKind.enumMemberName; - } - else if (flags & 16 /* Function */) { - return ts.SymbolDisplayPartKind.functionName; - } - else if (flags & 32 /* Class */) { - return ts.SymbolDisplayPartKind.className; - } - else if (flags & 64 /* Interface */) { - return ts.SymbolDisplayPartKind.interfaceName; - } - else if (flags & 384 /* Enum */) { - return ts.SymbolDisplayPartKind.enumName; - } - else if (flags & 1536 /* Module */) { - return ts.SymbolDisplayPartKind.moduleName; - } - else if (flags & 8192 /* Method */) { - return ts.SymbolDisplayPartKind.methodName; - } - else if (flags & 262144 /* TypeParameter */) { - return ts.SymbolDisplayPartKind.typeParameterName; - } - else if (flags & 524288 /* TypeAlias */) { - return ts.SymbolDisplayPartKind.aliasName; - } - else if (flags & 8388608 /* Alias */) { - return ts.SymbolDisplayPartKind.aliasName; - } - return ts.SymbolDisplayPartKind.text; - } - } - ts.symbolPart = symbolPart; - function displayPart(text, kind, symbol) { - return { - text: text, - kind: ts.SymbolDisplayPartKind[kind] - }; - } - ts.displayPart = displayPart; - function spacePart() { - return displayPart(" ", ts.SymbolDisplayPartKind.space); - } - ts.spacePart = spacePart; - function keywordPart(kind) { - return displayPart(ts.tokenToString(kind), ts.SymbolDisplayPartKind.keyword); - } - ts.keywordPart = keywordPart; - function punctuationPart(kind) { - return displayPart(ts.tokenToString(kind), ts.SymbolDisplayPartKind.punctuation); - } - ts.punctuationPart = punctuationPart; - function operatorPart(kind) { - return displayPart(ts.tokenToString(kind), ts.SymbolDisplayPartKind.operator); - } - ts.operatorPart = operatorPart; - function textOrKeywordPart(text) { - var kind = ts.stringToToken(text); - return kind === undefined - ? textPart(text) - : keywordPart(kind); - } - ts.textOrKeywordPart = textOrKeywordPart; - function textPart(text) { - return displayPart(text, ts.SymbolDisplayPartKind.text); - } - ts.textPart = textPart; - var carriageReturnLineFeed = "\r\n"; - /** - * The default is CRLF. - */ - function getNewLineOrDefaultFromHost(host) { - return host.getNewLine ? host.getNewLine() : carriageReturnLineFeed; - } - ts.getNewLineOrDefaultFromHost = getNewLineOrDefaultFromHost; - function lineBreakPart() { - return displayPart("\n", ts.SymbolDisplayPartKind.lineBreak); - } - ts.lineBreakPart = lineBreakPart; - function mapToDisplayParts(writeDisplayParts) { - writeDisplayParts(displayPartWriter); - var result = displayPartWriter.displayParts(); - displayPartWriter.clear(); - return result; - } - ts.mapToDisplayParts = mapToDisplayParts; - function typeToDisplayParts(typechecker, type, enclosingDeclaration, flags) { - return mapToDisplayParts(function (writer) { - typechecker.getSymbolDisplayBuilder().buildTypeDisplay(type, writer, enclosingDeclaration, flags); - }); - } - ts.typeToDisplayParts = typeToDisplayParts; - function symbolToDisplayParts(typeChecker, symbol, enclosingDeclaration, meaning, flags) { - return mapToDisplayParts(function (writer) { - typeChecker.getSymbolDisplayBuilder().buildSymbolDisplay(symbol, writer, enclosingDeclaration, meaning, flags); - }); - } - ts.symbolToDisplayParts = symbolToDisplayParts; - function signatureToDisplayParts(typechecker, signature, enclosingDeclaration, flags) { - return mapToDisplayParts(function (writer) { - typechecker.getSymbolDisplayBuilder().buildSignatureDisplay(signature, writer, enclosingDeclaration, flags); - }); - } - ts.signatureToDisplayParts = signatureToDisplayParts; - function getDeclaredName(typeChecker, 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 is under the cursor. - if (isImportOrExportSpecifierName(location)) { - return location.getText(); - } - // Try to get the local symbol if we're dealing with an 'export default' - // since that symbol has the "true" name. - var localExportDefaultSymbol = ts.getLocalSymbolForExportDefault(symbol); - var name = typeChecker.symbolToString(localExportDefaultSymbol || symbol); - return name; - } - ts.getDeclaredName = getDeclaredName; - function isImportOrExportSpecifierName(location) { - return location.parent && - (location.parent.kind === 226 /* ImportSpecifier */ || location.parent.kind === 230 /* ExportSpecifier */) && - location.parent.propertyName === location; - } - ts.isImportOrExportSpecifierName = isImportOrExportSpecifierName; - /** - * Strip off existed single quotes or double quotes from a given string - * - * @return non-quoted string - */ - function stripQuotes(name) { - var length = name.length; - if (length >= 2 && - name.charCodeAt(0) === name.charCodeAt(length - 1) && - (name.charCodeAt(0) === 34 /* doubleQuote */ || name.charCodeAt(0) === 39 /* singleQuote */)) { - return name.substring(1, length - 1); - } - ; - return name; - } - ts.stripQuotes = stripQuotes; -})(ts || (ts = {})); -/// -/// -/* @internal */ -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 */); - /** - * Scanner that is currently used for formatting - */ - 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 = {})); - function getFormattingScanner(sourceFile, startPos, endPos) { - ts.Debug.assert(scanner === undefined); - scanner = sourceFile.languageVariant === 1 /* JSX */ ? jsxScanner : standardScanner; - scanner.setText(sourceFile.text); - scanner.setTextPos(startPos); - var wasNewLine = true; - var leadingTrivia; - var trailingTrivia; - var savedPos; - var lastScanAction; - var lastTokenInfo; - return { - advance: advance, - readTokenInfo: readTokenInfo, - isOnToken: isOnToken, - lastTrailingTriviaWasNewLine: function () { return wasNewLine; }, - close: function () { - ts.Debug.assert(scanner !== undefined); - lastTokenInfo = undefined; - scanner.setText(undefined); - scanner = undefined; - } - }; - function advance() { - ts.Debug.assert(scanner !== undefined); - lastTokenInfo = undefined; - var isStarted = scanner.getStartPos() !== startPos; - if (isStarted) { - if (trailingTrivia) { - ts.Debug.assert(trailingTrivia.length !== 0); - wasNewLine = ts.lastOrUndefined(trailingTrivia).kind === 4 /* NewLineTrivia */; - } - else { - wasNewLine = false; - } - } - leadingTrivia = undefined; - trailingTrivia = undefined; - if (!isStarted) { - scanner.scan(); - } - var t; - var pos = scanner.getStartPos(); - // Read leading trivia and token - while (pos < endPos) { - var t_1 = scanner.getToken(); - if (!ts.isTrivia(t_1)) { - break; - } - // consume leading trivia - scanner.scan(); - var item = { - pos: pos, - end: scanner.getStartPos(), - kind: t_1 - }; - pos = scanner.getStartPos(); - if (!leadingTrivia) { - leadingTrivia = []; - } - leadingTrivia.push(item); - } - savedPos = scanner.getStartPos(); - } - function shouldRescanGreaterThanToken(node) { - if (node) { - switch (node.kind) { - case 29 /* GreaterThanEqualsToken */: - case 64 /* GreaterThanGreaterThanEqualsToken */: - case 65 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 45 /* GreaterThanGreaterThanGreaterThanToken */: - case 44 /* GreaterThanGreaterThanToken */: - return true; - } - } - return false; - } - function shouldRescanJsxIdentifier(node) { - if (node.parent) { - switch (node.parent.kind) { - case 238 /* JsxAttribute */: - case 235 /* JsxOpeningElement */: - case 237 /* JsxClosingElement */: - case 234 /* JsxSelfClosingElement */: - return node.kind === 69 /* Identifier */; - } - } - return false; - } - function shouldRescanSlashToken(container) { - return container.kind === 10 /* RegularExpressionLiteral */; - } - function shouldRescanTemplateToken(container) { - return container.kind === 13 /* TemplateMiddle */ || - container.kind === 14 /* TemplateTail */; - } - function startsWithSlashToken(t) { - return t === 39 /* SlashToken */ || t === 61 /* SlashEqualsToken */; - } - function readTokenInfo(n) { - ts.Debug.assert(scanner !== undefined); - if (!isOnToken()) { - // scanner is not on the token (either advance was not called yet or scanner is already past the end position) - return { - leadingTrivia: leadingTrivia, - trailingTrivia: undefined, - token: undefined - }; - } - // normally scanner returns the smallest available token - // check the kind of context node to determine if scanner should have more greedy behavior and consume more text. - var expectedScanAction = shouldRescanGreaterThanToken(n) - ? 1 /* RescanGreaterThanToken */ - : shouldRescanSlashToken(n) - ? 2 /* RescanSlashToken */ - : shouldRescanTemplateToken(n) - ? 3 /* RescanTemplateToken */ - : shouldRescanJsxIdentifier(n) - ? 4 /* RescanJsxIdentifier */ - : 0 /* Scan */; - if (lastTokenInfo && expectedScanAction === lastScanAction) { - // readTokenInfo was called before with the same expected scan action. - // No need to re-scan text, return existing 'lastTokenInfo' - // it is ok to call fixTokenKind here since it does not affect - // what portion of text is consumed. In opposize rescanning can change it, - // i.e. for '>=' when originally scanner eats just one character - // and rescanning forces it to consume more. - return fixTokenKind(lastTokenInfo, n); - } - if (scanner.getStartPos() !== savedPos) { - ts.Debug.assert(lastTokenInfo !== undefined); - // readTokenInfo was called before but scan action differs - rescan text - scanner.setTextPos(savedPos); - scanner.scan(); - } - var currentToken = scanner.getToken(); - if (expectedScanAction === 1 /* RescanGreaterThanToken */ && currentToken === 27 /* GreaterThanToken */) { - currentToken = scanner.reScanGreaterToken(); - ts.Debug.assert(n.kind === currentToken); - lastScanAction = 1 /* RescanGreaterThanToken */; - } - else if (expectedScanAction === 2 /* RescanSlashToken */ && startsWithSlashToken(currentToken)) { - currentToken = scanner.reScanSlashToken(); - ts.Debug.assert(n.kind === currentToken); - lastScanAction = 2 /* RescanSlashToken */; - } - else if (expectedScanAction === 3 /* RescanTemplateToken */ && currentToken === 16 /* CloseBraceToken */) { - currentToken = scanner.reScanTemplateToken(); - lastScanAction = 3 /* RescanTemplateToken */; - } - else if (expectedScanAction === 4 /* RescanJsxIdentifier */ && currentToken === 69 /* Identifier */) { - currentToken = scanner.scanJsxIdentifier(); - lastScanAction = 4 /* RescanJsxIdentifier */; - } - else { - lastScanAction = 0 /* Scan */; - } - var token = { - pos: scanner.getStartPos(), - end: scanner.getTextPos(), - kind: currentToken - }; - // consume trailing trivia - if (trailingTrivia) { - trailingTrivia = undefined; - } - while (scanner.getStartPos() < endPos) { - currentToken = scanner.scan(); - if (!ts.isTrivia(currentToken)) { - break; - } - var trivia = { - pos: scanner.getStartPos(), - end: scanner.getTextPos(), - kind: currentToken - }; - if (!trailingTrivia) { - trailingTrivia = []; - } - trailingTrivia.push(trivia); - if (currentToken === 4 /* NewLineTrivia */) { - // move past new line - scanner.scan(); - break; - } - } - lastTokenInfo = { - leadingTrivia: leadingTrivia, - trailingTrivia: trailingTrivia, - token: token - }; - return fixTokenKind(lastTokenInfo, n); - } - function isOnToken() { - ts.Debug.assert(scanner !== undefined); - var current = (lastTokenInfo && lastTokenInfo.token.kind) || scanner.getToken(); - var startPos = (lastTokenInfo && lastTokenInfo.token.pos) || scanner.getStartPos(); - return startPos < endPos && current !== 1 /* EndOfFileToken */ && !ts.isTrivia(current); - } - // when containing node in the tree is token - // but its kind differs from the kind that was returned by the scanner, - // then kind needs to be fixed. This might happen in cases - // when parser interprets token differently, i.e keyword treated as identifier - function fixTokenKind(tokenInfo, container) { - if (ts.isToken(container) && tokenInfo.token.kind !== container.kind) { - tokenInfo.token.kind = container.kind; - } - return tokenInfo; - } - } - formatting.getFormattingScanner = getFormattingScanner; - })(formatting = ts.formatting || (ts.formatting = {})); -})(ts || (ts = {})); -/// -/* @internal */ -var ts; -(function (ts) { - var formatting; - (function (formatting) { - var FormattingContext = (function () { - function FormattingContext(sourceFile, formattingRequestKind) { - this.sourceFile = sourceFile; - this.formattingRequestKind = formattingRequestKind; - } - FormattingContext.prototype.updateContext = function (currentRange, currentTokenParent, nextRange, nextTokenParent, commonParent) { - ts.Debug.assert(currentRange !== undefined, "currentTokenSpan is null"); - ts.Debug.assert(currentTokenParent !== undefined, "currentTokenParent is null"); - ts.Debug.assert(nextRange !== undefined, "nextTokenSpan is null"); - ts.Debug.assert(nextTokenParent !== undefined, "nextTokenParent is null"); - ts.Debug.assert(commonParent !== undefined, "commonParent is null"); - this.currentTokenSpan = currentRange; - this.currentTokenParent = currentTokenParent; - this.nextTokenSpan = nextRange; - this.nextTokenParent = nextTokenParent; - this.contextNode = commonParent; - // drop cached results - this.contextNodeAllOnSameLine = undefined; - this.nextNodeAllOnSameLine = undefined; - this.tokensAreOnSameLine = undefined; - this.contextNodeBlockIsOnOneLine = undefined; - this.nextNodeBlockIsOnOneLine = undefined; - }; - FormattingContext.prototype.ContextNodeAllOnSameLine = function () { - if (this.contextNodeAllOnSameLine === undefined) { - this.contextNodeAllOnSameLine = this.NodeIsOnOneLine(this.contextNode); - } - return this.contextNodeAllOnSameLine; - }; - FormattingContext.prototype.NextNodeAllOnSameLine = function () { - if (this.nextNodeAllOnSameLine === undefined) { - this.nextNodeAllOnSameLine = this.NodeIsOnOneLine(this.nextTokenParent); - } - return this.nextNodeAllOnSameLine; - }; - FormattingContext.prototype.TokensAreOnSameLine = function () { - if (this.tokensAreOnSameLine === undefined) { - var startLine = this.sourceFile.getLineAndCharacterOfPosition(this.currentTokenSpan.pos).line; - var endLine = this.sourceFile.getLineAndCharacterOfPosition(this.nextTokenSpan.pos).line; - this.tokensAreOnSameLine = (startLine === endLine); - } - return this.tokensAreOnSameLine; - }; - FormattingContext.prototype.ContextNodeBlockIsOnOneLine = function () { - if (this.contextNodeBlockIsOnOneLine === undefined) { - this.contextNodeBlockIsOnOneLine = this.BlockIsOnOneLine(this.contextNode); - } - return this.contextNodeBlockIsOnOneLine; - }; - FormattingContext.prototype.NextNodeBlockIsOnOneLine = function () { - if (this.nextNodeBlockIsOnOneLine === undefined) { - this.nextNodeBlockIsOnOneLine = this.BlockIsOnOneLine(this.nextTokenParent); - } - return this.nextNodeBlockIsOnOneLine; - }; - FormattingContext.prototype.NodeIsOnOneLine = function (node) { - var startLine = this.sourceFile.getLineAndCharacterOfPosition(node.getStart(this.sourceFile)).line; - var endLine = this.sourceFile.getLineAndCharacterOfPosition(node.getEnd()).line; - 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); - if (openBrace && closeBrace) { - var startLine = this.sourceFile.getLineAndCharacterOfPosition(openBrace.getEnd()).line; - var endLine = this.sourceFile.getLineAndCharacterOfPosition(closeBrace.getStart(this.sourceFile)).line; - return startLine === endLine; - } - return false; - }; - return FormattingContext; - })(); - formatting.FormattingContext = FormattingContext; - })(formatting = ts.formatting || (ts.formatting = {})); -})(ts || (ts = {})); -/// -/* @internal */ -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 = {})); -/// -/* @internal */ -var ts; -(function (ts) { - var formatting; - (function (formatting) { - var Rule = (function () { - function Rule(Descriptor, Operation, Flag) { - if (Flag === void 0) { Flag = 0 /* None */; } - this.Descriptor = Descriptor; - this.Operation = Operation; - this.Flag = Flag; - } - Rule.prototype.toString = function () { - return "[desc=" + this.Descriptor + "," + - "operation=" + this.Operation + "," + - "flag=" + this.Flag + "]"; - }; - return Rule; - })(); - formatting.Rule = Rule; - })(formatting = ts.formatting || (ts.formatting = {})); -})(ts || (ts = {})); -/// -/* @internal */ -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 = {})); -/// -/* @internal */ -var ts; -(function (ts) { - var formatting; - (function (formatting) { - var RuleDescriptor = (function () { - function RuleDescriptor(LeftTokenRange, RightTokenRange) { - this.LeftTokenRange = LeftTokenRange; - this.RightTokenRange = RightTokenRange; - } - RuleDescriptor.prototype.toString = function () { - return "[leftRange=" + this.LeftTokenRange + "," + - "rightRange=" + this.RightTokenRange + "]"; - }; - RuleDescriptor.create1 = function (left, right) { - return RuleDescriptor.create4(formatting.Shared.TokenRange.FromToken(left), formatting.Shared.TokenRange.FromToken(right)); - }; - RuleDescriptor.create2 = function (left, right) { - return RuleDescriptor.create4(left, formatting.Shared.TokenRange.FromToken(right)); - }; - RuleDescriptor.create3 = function (left, right) { - return RuleDescriptor.create4(formatting.Shared.TokenRange.FromToken(left), right); - }; - RuleDescriptor.create4 = function (left, right) { - return new RuleDescriptor(left, right); - }; - return RuleDescriptor; - })(); - formatting.RuleDescriptor = RuleDescriptor; - })(formatting = ts.formatting || (ts.formatting = {})); -})(ts || (ts = {})); -/// -/* @internal */ -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 = {})); -/// -/* @internal */ -var ts; -(function (ts) { - var formatting; - (function (formatting) { - var RuleOperation = (function () { - function RuleOperation() { - this.Context = null; - this.Action = null; - } - RuleOperation.prototype.toString = function () { - return "[context=" + this.Context + "," + - "action=" + this.Action + "]"; - }; - RuleOperation.create1 = function (action) { - return RuleOperation.create2(formatting.RuleOperationContext.Any, action); - }; - RuleOperation.create2 = function (context, action) { - var result = new RuleOperation(); - result.Context = context; - result.Action = action; - return result; - }; - return RuleOperation; - })(); - formatting.RuleOperation = RuleOperation; - })(formatting = ts.formatting || (ts.formatting = {})); -})(ts || (ts = {})); -/// -/* @internal */ -var ts; -(function (ts) { - var formatting; - (function (formatting) { - var RuleOperationContext = (function () { - function RuleOperationContext() { - var funcs = []; - for (var _i = 0; _i < arguments.length; _i++) { - funcs[_i - 0] = arguments[_i]; - } - this.customContextChecks = funcs; - } - RuleOperationContext.prototype.IsAny = function () { - return this === RuleOperationContext.Any; - }; - RuleOperationContext.prototype.InContext = function (context) { - if (this.IsAny()) { - return true; - } - for (var _i = 0, _a = this.customContextChecks; _i < _a.length; _i++) { - var check = _a[_i]; - if (!check(context)) { - return false; - } - } - return true; - }; - RuleOperationContext.Any = new RuleOperationContext(); - return RuleOperationContext; - })(); - formatting.RuleOperationContext = RuleOperationContext; - })(formatting = ts.formatting || (ts.formatting = {})); -})(ts || (ts = {})); -/// -/* @internal */ -var ts; -(function (ts) { - var formatting; - (function (formatting) { - var Rules = (function () { - function Rules() { - /// - /// Common Rules - /// - // Leave comments alone - 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.IsSameLineTokenContext), 8 /* Delete */)); - this.NoSpaceBeforeColon = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 54 /* ColonToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 8 /* Delete */)); - this.NoSpaceBeforeQuestionMark = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 53 /* QuestionToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 8 /* Delete */)); - this.SpaceAfterColon = new formatting.Rule(formatting.RuleDescriptor.create3(54 /* ColonToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 2 /* Space */)); - this.SpaceAfterQuestionMarkInConditionalOperator = new formatting.Rule(formatting.RuleDescriptor.create3(53 /* QuestionToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsConditionalOperatorContext), 2 /* Space */)); - this.NoSpaceAfterQuestionMark = new formatting.Rule(formatting.RuleDescriptor.create3(53 /* QuestionToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); - this.SpaceAfterSemicolon = new formatting.Rule(formatting.RuleDescriptor.create3(23 /* SemicolonToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); - // Space after }. - this.SpaceAfterCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create3(16 /* CloseBraceToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsAfterCodeBlockContext), 2 /* Space */)); - // Special case for (}, else) and (}, while) since else & while tokens are not part of the tree which makes SpaceAfterCloseBrace rule not applied - this.SpaceBetweenCloseBraceAndElse = new formatting.Rule(formatting.RuleDescriptor.create1(16 /* CloseBraceToken */, 80 /* ElseKeyword */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); - this.SpaceBetweenCloseBraceAndWhile = new formatting.Rule(formatting.RuleDescriptor.create1(16 /* CloseBraceToken */, 104 /* WhileKeyword */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); - this.NoSpaceAfterCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create3(16 /* CloseBraceToken */, formatting.Shared.TokenRange.FromTokens([18 /* CloseParenToken */, 20 /* CloseBracketToken */, 24 /* CommaToken */, 23 /* SemicolonToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); - // No space for dot - this.NoSpaceBeforeDot = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 21 /* DotToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); - this.NoSpaceAfterDot = new formatting.Rule(formatting.RuleDescriptor.create3(21 /* DotToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 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.IsSameLineTokenContext), 8 /* Delete */)); - this.NoSpaceAfterCloseBracket = new formatting.Rule(formatting.RuleDescriptor.create3(20 /* CloseBracketToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, 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 */); - // 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 */]); - this.SpaceBeforeOpenBraceInTypeScriptDeclWithBlock = new formatting.Rule(formatting.RuleDescriptor.create2(this.TypeScriptOpenBraceLeftTokenRange, 15 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsTypeScriptDeclWithBlockContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), 2 /* Space */), 1 /* CanDeleteNewLines */); - // Place a space before open brace in a control flow construct - this.ControlOpenBraceLeftTokenRange = formatting.Shared.TokenRange.FromTokens([18 /* CloseParenToken */, 3 /* MultiLineCommentTrivia */, 79 /* DoKeyword */, 100 /* TryKeyword */, 85 /* FinallyKeyword */, 80 /* ElseKeyword */]); - this.SpaceBeforeOpenBraceInControl = new formatting.Rule(formatting.RuleDescriptor.create2(this.ControlOpenBraceLeftTokenRange, 15 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsControlDeclContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), 2 /* Space */), 1 /* CanDeleteNewLines */); - // Insert a space after { and before } in single-line contexts, but remove space from empty object literals {}. - this.SpaceAfterOpenBrace = new formatting.Rule(formatting.RuleDescriptor.create3(15 /* OpenBraceToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSingleLineBlockContext), 2 /* Space */)); - 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.NoSpaceBetweenEmptyBraceBrackets = new formatting.Rule(formatting.RuleDescriptor.create1(15 /* OpenBraceToken */, 16 /* CloseBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, 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 */)); - // 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 */)); - // 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.IsSameLineTokenContext, 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.IsSameLineTokenContext), 8 /* Delete */)); - this.NoSpaceAfterUnaryPredecrementOperator = new formatting.Rule(formatting.RuleDescriptor.create3(42 /* MinusMinusToken */, formatting.Shared.TokenRange.UnaryPredecrementExpressions), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); - this.NoSpaceBeforeUnaryPostincrementOperator = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.UnaryPostincrementExpressions, 41 /* PlusPlusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); - this.NoSpaceBeforeUnaryPostdecrementOperator = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.UnaryPostdecrementExpressions, 42 /* MinusMinusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); - // More unary operator special-casing. - // DevDiv 181814: Be careful when removing leading whitespace - // around unary operators. Examples: - // 1 - -2 --X--> 1--2 - // a + ++b --X--> a+++b - this.SpaceAfterPostincrementWhenFollowedByAdd = new formatting.Rule(formatting.RuleDescriptor.create1(41 /* PlusPlusToken */, 35 /* PlusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); - this.SpaceAfterAddWhenFollowedByUnaryPlus = new formatting.Rule(formatting.RuleDescriptor.create1(35 /* PlusToken */, 35 /* PlusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); - this.SpaceAfterAddWhenFollowedByPreincrement = new formatting.Rule(formatting.RuleDescriptor.create1(35 /* PlusToken */, 41 /* PlusPlusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); - this.SpaceAfterPostdecrementWhenFollowedBySubtract = new formatting.Rule(formatting.RuleDescriptor.create1(42 /* MinusMinusToken */, 36 /* MinusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); - this.SpaceAfterSubtractWhenFollowedByUnaryMinus = new formatting.Rule(formatting.RuleDescriptor.create1(36 /* MinusToken */, 36 /* MinusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); - this.SpaceAfterSubtractWhenFollowedByPredecrement = new formatting.Rule(formatting.RuleDescriptor.create1(36 /* MinusToken */, 42 /* MinusMinusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); - this.NoSpaceBeforeComma = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 24 /* CommaToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); - this.SpaceAfterCertainKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([102 /* VarKeyword */, 98 /* ThrowKeyword */, 92 /* NewKeyword */, 78 /* DeleteKeyword */, 94 /* ReturnKeyword */, 101 /* TypeOfKeyword */, 119 /* AwaitKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); - this.SpaceAfterLetConstInVariableDeclaration = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([108 /* LetKeyword */, 74 /* ConstKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsStartOfVariableDeclarationList), 2 /* Space */)); - this.NoSpaceBeforeOpenParenInFuncCall = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 17 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsFunctionCallOrNewContext, Rules.IsPreviousTokenNotComma), 8 /* Delete */)); - this.SpaceAfterFunctionInFuncDecl = new formatting.Rule(formatting.RuleDescriptor.create3(87 /* FunctionKeyword */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2 /* Space */)); - this.NoSpaceBeforeOpenParenInFuncDecl = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 17 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsFunctionDeclContext), 8 /* Delete */)); - this.SpaceAfterVoidOperator = new formatting.Rule(formatting.RuleDescriptor.create3(103 /* VoidKeyword */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsVoidOpContext), 2 /* Space */)); - this.NoSpaceBetweenReturnAndSemicolon = new formatting.Rule(formatting.RuleDescriptor.create1(94 /* ReturnKeyword */, 23 /* SemicolonToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); - // Add a space between statements. All keywords except (do,else,case) has open/close parens after them. - // So, we have a rule to add a space for [),Any], [do,Any], [else,Any], and [case,Any] - this.SpaceBetweenStatements = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([18 /* CloseParenToken */, 79 /* DoKeyword */, 80 /* ElseKeyword */, 71 /* CaseKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotForContext), 2 /* Space */)); - // This low-pri rule takes care of "try {" and "finally {" in case the rule SpaceBeforeOpenBraceInControl didn't execute on FormatOnEnter. - this.SpaceAfterTryFinally = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([100 /* TryKeyword */, 85 /* FinallyKeyword */]), 15 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); - // get x() {} - // set x(val) {} - this.SpaceAfterGetSetInMember = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([123 /* GetKeyword */, 129 /* SetKeyword */]), 69 /* Identifier */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2 /* Space */)); - // Special case for binary operators (that are keywords). For these we have to add a space and shouldn't follow any user options. - this.SpaceBeforeBinaryKeywordOperator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.BinaryKeywordOperators), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); - this.SpaceAfterBinaryKeywordOperator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.BinaryKeywordOperators, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); - // TypeScript-specific higher priority rules - // Treat constructor as an identifier in a function declaration, and remove spaces between constructor and following left parentheses - this.NoSpaceAfterConstructor = new formatting.Rule(formatting.RuleDescriptor.create1(121 /* ConstructorKeyword */, 17 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); - // Use of module as a function call. e.g.: import m2 = module("m2"); - this.NoSpaceAfterModuleImport = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([125 /* ModuleKeyword */, 127 /* RequireKeyword */]), 17 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); - // Add a space around certain TypeScript keywords - this.SpaceAfterCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([115 /* AbstractKeyword */, 73 /* ClassKeyword */, 122 /* DeclareKeyword */, 77 /* DefaultKeyword */, 81 /* EnumKeyword */, 82 /* ExportKeyword */, 83 /* ExtendsKeyword */, 123 /* GetKeyword */, 106 /* ImplementsKeyword */, 89 /* ImportKeyword */, 107 /* InterfaceKeyword */, 125 /* ModuleKeyword */, 126 /* NamespaceKeyword */, 110 /* PrivateKeyword */, 112 /* PublicKeyword */, 111 /* ProtectedKeyword */, 129 /* SetKeyword */, 113 /* StaticKeyword */, 132 /* TypeKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); - this.SpaceBeforeCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([83 /* ExtendsKeyword */, 106 /* ImplementsKeyword */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); - // Treat string literals in module names as identifiers, and add a space between the literal and the opening Brace braces, e.g.: module "m2" { - this.SpaceAfterModuleName = new formatting.Rule(formatting.RuleDescriptor.create1(9 /* StringLiteral */, 15 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsModuleDeclContext), 2 /* Space */)); - // Lambda expressions - this.SpaceAfterArrow = new formatting.Rule(formatting.RuleDescriptor.create3(34 /* EqualsGreaterThanToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); - // Optional parameters and let args - this.NoSpaceAfterEllipsis = new formatting.Rule(formatting.RuleDescriptor.create1(22 /* DotDotDotToken */, 69 /* Identifier */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); - this.NoSpaceAfterOptionalParameters = new formatting.Rule(formatting.RuleDescriptor.create3(53 /* QuestionToken */, formatting.Shared.TokenRange.FromTokens([18 /* CloseParenToken */, 24 /* CommaToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 8 /* Delete */)); - // generics and type assertions - this.NoSpaceBeforeOpenAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.TypeNames, 25 /* LessThanToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), 8 /* Delete */)); - this.NoSpaceBetweenCloseParenAndAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create1(18 /* CloseParenToken */, 25 /* LessThanToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), 8 /* Delete */)); - this.NoSpaceAfterOpenAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create3(25 /* LessThanToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, 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.IsSameLineTokenContext, 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.IsSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), 8 /* Delete */)); - this.NoSpaceAfterTypeAssertion = new formatting.Rule(formatting.RuleDescriptor.create3(27 /* GreaterThanToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsTypeAssertionContext), 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.IsSameLineTokenContext, 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.IsSameLineTokenContext), 2 /* Space */)); - this.NoSpaceAfterAt = new formatting.Rule(formatting.RuleDescriptor.create3(55 /* AtToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); - this.SpaceAfterDecorator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([115 /* AbstractKeyword */, 69 /* Identifier */, 82 /* ExportKeyword */, 77 /* DefaultKeyword */, 73 /* ClassKeyword */, 113 /* StaticKeyword */, 112 /* PublicKeyword */, 110 /* PrivateKeyword */, 111 /* ProtectedKeyword */, 123 /* GetKeyword */, 129 /* SetKeyword */, 19 /* OpenBracketToken */, 37 /* AsteriskToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsEndOfDecoratorContextOnSameLine), 2 /* Space */)); - this.NoSpaceBetweenFunctionKeywordAndStar = new formatting.Rule(formatting.RuleDescriptor.create1(87 /* FunctionKeyword */, 37 /* AsteriskToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclarationOrFunctionExpressionContext), 8 /* Delete */)); - this.SpaceAfterStarInGeneratorDeclaration = new formatting.Rule(formatting.RuleDescriptor.create3(37 /* AsteriskToken */, formatting.Shared.TokenRange.FromTokens([69 /* Identifier */, 17 /* OpenParenToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclarationOrFunctionExpressionContext), 2 /* Space */)); - this.NoSpaceBetweenYieldKeywordAndStar = new formatting.Rule(formatting.RuleDescriptor.create1(114 /* YieldKeyword */, 37 /* AsteriskToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsYieldOrYieldStarWithOperand), 8 /* Delete */)); - this.SpaceBetweenYieldOrYieldStarAndOperand = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([114 /* YieldKeyword */, 37 /* AsteriskToken */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsYieldOrYieldStarWithOperand), 2 /* Space */)); - // Async-await - this.SpaceBetweenAsyncAndOpenParen = new formatting.Rule(formatting.RuleDescriptor.create1(118 /* AsyncKeyword */, 17 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsArrowFunctionContext, Rules.IsSameLineTokenContext), 2 /* Space */)); - this.SpaceBetweenAsyncAndFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(118 /* AsyncKeyword */, 87 /* FunctionKeyword */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); - // template string - this.SpaceBetweenTagAndTemplateString = new formatting.Rule(formatting.RuleDescriptor.create3(69 /* Identifier */, formatting.Shared.TokenRange.FromTokens([11 /* NoSubstitutionTemplateLiteral */, 12 /* TemplateHead */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); - this.NoSpaceAfterTemplateHeadAndMiddle = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([12 /* TemplateHead */, 13 /* TemplateMiddle */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); - this.NoSpaceBeforeTemplateMiddleAndTail = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([13 /* TemplateMiddle */, 14 /* TemplateTail */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); - // These rules are higher in priority than user-configurable rules. - this.HighPriorityCommonRules = - [ - this.IgnoreBeforeComment, this.IgnoreAfterLineComment, - this.NoSpaceBeforeColon, this.SpaceAfterColon, this.NoSpaceBeforeQuestionMark, this.SpaceAfterQuestionMarkInConditionalOperator, - this.NoSpaceAfterQuestionMark, - this.NoSpaceBeforeDot, this.NoSpaceAfterDot, - this.NoSpaceAfterUnaryPrefixOperator, - this.NoSpaceAfterUnaryPreincrementOperator, this.NoSpaceAfterUnaryPredecrementOperator, - this.NoSpaceBeforeUnaryPostincrementOperator, this.NoSpaceBeforeUnaryPostdecrementOperator, - this.SpaceAfterPostincrementWhenFollowedByAdd, - this.SpaceAfterAddWhenFollowedByUnaryPlus, this.SpaceAfterAddWhenFollowedByPreincrement, - this.SpaceAfterPostdecrementWhenFollowedBySubtract, - this.SpaceAfterSubtractWhenFollowedByUnaryMinus, this.SpaceAfterSubtractWhenFollowedByPredecrement, - this.NoSpaceAfterCloseBrace, - this.SpaceAfterOpenBrace, this.SpaceBeforeCloseBrace, this.NewLineBeforeCloseBraceInBlockContext, - this.SpaceAfterCloseBrace, this.SpaceBetweenCloseBraceAndElse, this.SpaceBetweenCloseBraceAndWhile, this.NoSpaceBetweenEmptyBraceBrackets, - this.NoSpaceBetweenFunctionKeywordAndStar, this.SpaceAfterStarInGeneratorDeclaration, - this.SpaceAfterFunctionInFuncDecl, this.NewLineAfterOpenBraceInBlockContext, this.SpaceAfterGetSetInMember, - this.NoSpaceBetweenYieldKeywordAndStar, this.SpaceBetweenYieldOrYieldStarAndOperand, - this.NoSpaceBetweenReturnAndSemicolon, - this.SpaceAfterCertainKeywords, - this.SpaceAfterLetConstInVariableDeclaration, - this.NoSpaceBeforeOpenParenInFuncCall, - this.SpaceBeforeBinaryKeywordOperator, this.SpaceAfterBinaryKeywordOperator, - this.SpaceAfterVoidOperator, - this.SpaceBetweenAsyncAndOpenParen, this.SpaceBetweenAsyncAndFunctionKeyword, - this.SpaceBetweenTagAndTemplateString, this.NoSpaceAfterTemplateHeadAndMiddle, this.NoSpaceBeforeTemplateMiddleAndTail, - // TypeScript-specific rules - this.NoSpaceAfterConstructor, this.NoSpaceAfterModuleImport, - this.SpaceAfterCertainTypeScriptKeywords, this.SpaceBeforeCertainTypeScriptKeywords, - this.SpaceAfterModuleName, - this.SpaceAfterArrow, - this.NoSpaceAfterEllipsis, - this.NoSpaceAfterOptionalParameters, - this.NoSpaceBetweenEmptyInterfaceBraceBrackets, - this.NoSpaceBeforeOpenAngularBracket, - this.NoSpaceBetweenCloseParenAndAngularBracket, - this.NoSpaceAfterOpenAngularBracket, - this.NoSpaceBeforeCloseAngularBracket, - this.NoSpaceAfterCloseAngularBracket, - this.NoSpaceAfterTypeAssertion, - this.SpaceBeforeAt, - this.NoSpaceAfterAt, - this.SpaceAfterDecorator, - ]; - // These rules are lower in priority than user-configurable rules. - this.LowPriorityCommonRules = - [ - this.NoSpaceBeforeSemicolon, - this.SpaceBeforeOpenBraceInControl, this.SpaceBeforeOpenBraceInFunction, this.SpaceBeforeOpenBraceInTypeScriptDeclWithBlock, - this.NoSpaceBeforeComma, - this.NoSpaceBeforeOpenBracket, - this.NoSpaceAfterCloseBracket, - this.SpaceAfterSemicolon, - this.NoSpaceBeforeOpenParenInFuncDecl, - this.SpaceBetweenStatements, this.SpaceAfterTryFinally - ]; - /// - /// 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.IsSameLineTokenContext), 2 /* Space */)); - this.NoSpaceAfterComma = new formatting.Rule(formatting.RuleDescriptor.create3(24 /* CommaToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 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.IsSameLineTokenContext, 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.IsSameLineTokenContext, 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.IsSameLineTokenContext, 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.IsSameLineTokenContext, 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 */)); - // 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 */); - // 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 */); - // 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 */); - // 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.IsSameLineTokenContext, 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.IsSameLineTokenContext, 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.IsSameLineTokenContext), 2 /* Space */)); - this.SpaceBeforeCloseParen = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 18 /* CloseParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); - this.NoSpaceBetweenParens = new formatting.Rule(formatting.RuleDescriptor.create1(17 /* OpenParenToken */, 18 /* CloseParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); - this.NoSpaceAfterOpenParen = new formatting.Rule(formatting.RuleDescriptor.create3(17 /* OpenParenToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); - this.NoSpaceBeforeCloseParen = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 18 /* CloseParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 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.IsSameLineTokenContext), 2 /* Space */)); - this.SpaceBeforeCloseBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 20 /* CloseBracketToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); - this.NoSpaceBetweenBrackets = new formatting.Rule(formatting.RuleDescriptor.create1(19 /* OpenBracketToken */, 20 /* CloseBracketToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); - this.NoSpaceAfterOpenBracket = new formatting.Rule(formatting.RuleDescriptor.create3(19 /* OpenBracketToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); - this.NoSpaceBeforeCloseBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 20 /* CloseBracketToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); - // Insert space after function keyword for anonymous functions - this.SpaceAfterAnonymousFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(87 /* FunctionKeyword */, 17 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2 /* Space */)); - this.NoSpaceAfterAnonymousFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(87 /* FunctionKeyword */, 17 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 8 /* Delete */)); - } - Rules.prototype.getRuleName = function (rule) { - var o = this; - for (var name_31 in o) { - if (o[name_31] === rule) { - return name_31; - } - } - throw new Error("Unknown rule"); - }; - /// - /// Contexts - /// - Rules.IsForContext = function (context) { - return context.contextNode.kind === 199 /* ForStatement */; - }; - Rules.IsNotForContext = function (context) { - return !Rules.IsForContext(context); - }; - Rules.IsBinaryOpContext = function (context) { - switch (context.contextNode.kind) { - case 181 /* BinaryExpression */: - case 182 /* ConditionalExpression */: - case 189 /* AsExpression */: - case 150 /* TypePredicate */: - case 158 /* UnionType */: - case 159 /* IntersectionType */: - return true; - // equals in binding elements: function foo([[x, y] = [1, 2]]) - case 163 /* BindingElement */: - // equals in type X = ... - case 216 /* TypeAliasDeclaration */: - // equal in import a = module('a'); - case 221 /* ImportEqualsDeclaration */: - // equal in let a = 0; - case 211 /* VariableDeclaration */: - // equal in p = 0; - case 138 /* Parameter */: - case 247 /* EnumMember */: - case 141 /* PropertyDeclaration */: - case 140 /* PropertySignature */: - return context.currentTokenSpan.kind === 56 /* EqualsToken */ || context.nextTokenSpan.kind === 56 /* EqualsToken */; - // "in" keyword in for (let x in []) { } - case 200 /* ForInStatement */: - return context.currentTokenSpan.kind === 90 /* InKeyword */ || context.nextTokenSpan.kind === 90 /* InKeyword */; - // Technically, "of" is not a binary operator, but format it the same way as "in" - case 201 /* ForOfStatement */: - return context.currentTokenSpan.kind === 134 /* OfKeyword */ || context.nextTokenSpan.kind === 134 /* OfKeyword */; - } - return false; - }; - Rules.IsNotBinaryOpContext = function (context) { - return !Rules.IsBinaryOpContext(context); - }; - Rules.IsConditionalOperatorContext = function (context) { - return context.contextNode.kind === 182 /* ConditionalExpression */; - }; - Rules.IsSameLineTokenOrBeforeMultilineBlockContext = function (context) { - //// This check is mainly used inside SpaceBeforeOpenBraceInControl and SpaceBeforeOpenBraceInFunction. - //// - //// Ex: - //// if (1) { .... - //// * ) and { are on the same line so apply the rule. Here we don't care whether it's same or multi block context - //// - //// Ex: - //// if (1) - //// { ... } - //// * ) and { are on differnet lines. We only need to format if the block is multiline context. So in this case we don't format. - //// - //// Ex: - //// if (1) - //// { ... - //// } - //// * ) and { are on differnet lines. We only need to format if the block is multiline context. So in this case we format. - return context.TokensAreOnSameLine() || Rules.IsBeforeMultilineBlockContext(context); - }; - // This check is done before an open brace in a control construct, a function, or a typescript block declaration - Rules.IsBeforeMultilineBlockContext = function (context) { - return Rules.IsBeforeBlockContext(context) && !(context.NextNodeAllOnSameLine() || context.NextNodeBlockIsOnOneLine()); - }; - Rules.IsMultilineBlockContext = function (context) { - return Rules.IsBlockContext(context) && !(context.ContextNodeAllOnSameLine() || context.ContextNodeBlockIsOnOneLine()); - }; - Rules.IsSingleLineBlockContext = function (context) { - return Rules.IsBlockContext(context) && (context.ContextNodeAllOnSameLine() || context.ContextNodeBlockIsOnOneLine()); - }; - Rules.IsBlockContext = function (context) { - return Rules.NodeIsBlockContext(context.contextNode); - }; - Rules.IsBeforeBlockContext = function (context) { - return Rules.NodeIsBlockContext(context.nextTokenParent); - }; - // IMPORTANT!!! This method must return true ONLY for nodes with open and close braces as immediate children - Rules.NodeIsBlockContext = function (node) { - if (Rules.NodeIsTypeScriptDeclWithBlockContext(node)) { - // This means we are in a context that looks like a block to the user, but in the grammar is actually not a node (it's a class, module, enum, object type literal, etc). - return true; - } - switch (node.kind) { - case 192 /* Block */: - case 220 /* CaseBlock */: - case 165 /* ObjectLiteralExpression */: - case 219 /* ModuleBlock */: - return true; - } - return false; - }; - Rules.IsFunctionDeclContext = function (context) { - switch (context.contextNode.kind) { - case 213 /* FunctionDeclaration */: - case 143 /* MethodDeclaration */: - case 142 /* MethodSignature */: - //case SyntaxKind.MemberFunctionDeclaration: - case 145 /* GetAccessor */: - case 146 /* SetAccessor */: - ///case SyntaxKind.MethodSignature: - case 147 /* CallSignature */: - case 173 /* FunctionExpression */: - case 144 /* Constructor */: - case 174 /* ArrowFunction */: - //case SyntaxKind.ConstructorDeclaration: - //case SyntaxKind.SimpleArrowFunctionExpression: - //case SyntaxKind.ParenthesizedArrowFunctionExpression: - case 215 /* InterfaceDeclaration */: - return true; - } - return false; - }; - Rules.IsFunctionDeclarationOrFunctionExpressionContext = function (context) { - return context.contextNode.kind === 213 /* FunctionDeclaration */ || context.contextNode.kind === 173 /* FunctionExpression */; - }; - Rules.IsTypeScriptDeclWithBlockContext = function (context) { - return Rules.NodeIsTypeScriptDeclWithBlockContext(context.contextNode); - }; - Rules.NodeIsTypeScriptDeclWithBlockContext = function (node) { - switch (node.kind) { - case 214 /* ClassDeclaration */: - case 186 /* ClassExpression */: - case 215 /* InterfaceDeclaration */: - case 217 /* EnumDeclaration */: - case 155 /* TypeLiteral */: - case 218 /* ModuleDeclaration */: - return true; - } - return false; - }; - Rules.IsAfterCodeBlockContext = function (context) { - switch (context.currentTokenParent.kind) { - case 214 /* ClassDeclaration */: - case 218 /* ModuleDeclaration */: - case 217 /* EnumDeclaration */: - case 192 /* Block */: - case 244 /* CatchClause */: - case 219 /* ModuleBlock */: - case 206 /* SwitchStatement */: - return true; - } - return false; - }; - Rules.IsControlDeclContext = function (context) { - switch (context.contextNode.kind) { - case 196 /* IfStatement */: - case 206 /* SwitchStatement */: - case 199 /* ForStatement */: - case 200 /* ForInStatement */: - case 201 /* ForOfStatement */: - case 198 /* WhileStatement */: - case 209 /* TryStatement */: - case 197 /* DoStatement */: - case 205 /* WithStatement */: - // TODO - // case SyntaxKind.ElseClause: - case 244 /* CatchClause */: - return true; - default: - return false; - } - }; - Rules.IsObjectContext = function (context) { - return context.contextNode.kind === 165 /* ObjectLiteralExpression */; - }; - Rules.IsFunctionCallContext = function (context) { - return context.contextNode.kind === 168 /* CallExpression */; - }; - Rules.IsNewContext = function (context) { - return context.contextNode.kind === 169 /* NewExpression */; - }; - Rules.IsFunctionCallOrNewContext = function (context) { - return Rules.IsFunctionCallContext(context) || Rules.IsNewContext(context); - }; - Rules.IsPreviousTokenNotComma = function (context) { - return context.currentTokenSpan.kind !== 24 /* CommaToken */; - }; - Rules.IsArrowFunctionContext = function (context) { - return context.contextNode.kind === 174 /* ArrowFunction */; - }; - Rules.IsSameLineTokenContext = function (context) { - return context.TokensAreOnSameLine(); - }; - Rules.IsNotBeforeBlockInFunctionDeclarationContext = function (context) { - return !Rules.IsFunctionDeclContext(context) && !Rules.IsBeforeBlockContext(context); - }; - Rules.IsEndOfDecoratorContextOnSameLine = function (context) { - return context.TokensAreOnSameLine() && - context.contextNode.decorators && - Rules.NodeIsInDecoratorContext(context.currentTokenParent) && - !Rules.NodeIsInDecoratorContext(context.nextTokenParent); - }; - Rules.NodeIsInDecoratorContext = function (node) { - while (ts.isExpression(node)) { - node = node.parent; - } - return node.kind === 139 /* Decorator */; - }; - Rules.IsStartOfVariableDeclarationList = function (context) { - return context.currentTokenParent.kind === 212 /* VariableDeclarationList */ && - context.currentTokenParent.getStart(context.sourceFile) === context.currentTokenSpan.pos; - }; - Rules.IsNotFormatOnEnter = function (context) { - return context.formattingRequestKind !== 2 /* FormatOnEnter */; - }; - Rules.IsModuleDeclContext = function (context) { - return context.contextNode.kind === 218 /* ModuleDeclaration */; - }; - Rules.IsObjectTypeContext = function (context) { - return context.contextNode.kind === 155 /* TypeLiteral */; // && context.contextNode.parent.kind !== SyntaxKind.InterfaceDeclaration; - }; - Rules.IsTypeArgumentOrParameterOrAssertion = function (token, parent) { - if (token.kind !== 25 /* LessThanToken */ && token.kind !== 27 /* GreaterThanToken */) { - return false; - } - switch (parent.kind) { - case 151 /* TypeReference */: - case 171 /* TypeAssertionExpression */: - case 214 /* ClassDeclaration */: - case 186 /* ClassExpression */: - case 215 /* InterfaceDeclaration */: - case 213 /* FunctionDeclaration */: - case 173 /* FunctionExpression */: - case 174 /* ArrowFunction */: - case 143 /* MethodDeclaration */: - case 142 /* MethodSignature */: - case 147 /* CallSignature */: - case 148 /* ConstructSignature */: - case 168 /* CallExpression */: - case 169 /* NewExpression */: - case 188 /* ExpressionWithTypeArguments */: - return true; - default: - return false; - } - }; - Rules.IsTypeArgumentOrParameterOrAssertionContext = function (context) { - return Rules.IsTypeArgumentOrParameterOrAssertion(context.currentTokenSpan, context.currentTokenParent) || - Rules.IsTypeArgumentOrParameterOrAssertion(context.nextTokenSpan, context.nextTokenParent); - }; - Rules.IsTypeAssertionContext = function (context) { - return context.contextNode.kind === 171 /* TypeAssertionExpression */; - }; - Rules.IsVoidOpContext = function (context) { - return context.currentTokenSpan.kind === 103 /* VoidKeyword */ && context.currentTokenParent.kind === 177 /* VoidExpression */; - }; - Rules.IsYieldOrYieldStarWithOperand = function (context) { - return context.contextNode.kind === 184 /* YieldExpression */ && context.contextNode.expression !== undefined; - }; - return Rules; - })(); - formatting.Rules = Rules; - })(formatting = ts.formatting || (ts.formatting = {})); -})(ts || (ts = {})); -/// -/* @internal */ -var ts; -(function (ts) { - var formatting; - (function (formatting) { - var RulesMap = (function () { - function RulesMap() { - this.map = []; - this.mapRowLength = 0; - } - RulesMap.create = function (rules) { - var result = new RulesMap(); - result.Initialize(rules); - return result; - }; - RulesMap.prototype.Initialize = function (rules) { - this.mapRowLength = 134 /* LastToken */ + 1; - this.map = new Array(this.mapRowLength * this.mapRowLength); //new Array(this.mapRowLength * this.mapRowLength); - // This array is used only during construction of the rulesbucket in the map - var rulesBucketConstructionStateList = new Array(this.map.length); //new Array(this.map.length); - this.FillRules(rules, rulesBucketConstructionStateList); - return this.map; - }; - RulesMap.prototype.FillRules = function (rules, rulesBucketConstructionStateList) { - var _this = this; - rules.forEach(function (rule) { - _this.FillRule(rule, rulesBucketConstructionStateList); - }); - }; - RulesMap.prototype.GetRuleBucketIndex = function (row, column) { - 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) { - var _this = this; - var specificRule = rule.Descriptor.LeftTokenRange !== formatting.Shared.TokenRange.Any && - rule.Descriptor.RightTokenRange !== formatting.Shared.TokenRange.Any; - rule.Descriptor.LeftTokenRange.GetTokens().forEach(function (left) { - rule.Descriptor.RightTokenRange.GetTokens().forEach(function (right) { - var rulesBucketIndex = _this.GetRuleBucketIndex(left, right); - var rulesBucket = _this.map[rulesBucketIndex]; - if (rulesBucket === undefined) { - rulesBucket = _this.map[rulesBucketIndex] = new RulesBucket(); - } - rulesBucket.AddRule(rule, specificRule, rulesBucketConstructionStateList, rulesBucketIndex); - }); - }); - }; - RulesMap.prototype.GetRule = function (context) { - var bucketIndex = this.GetRuleBucketIndex(context.currentTokenSpan.kind, context.nextTokenSpan.kind); - var bucket = this.map[bucketIndex]; - if (bucket != null) { - for (var _i = 0, _a = bucket.Rules(); _i < _a.length; _i++) { - var rule = _a[_i]; - if (rule.Operation.Context.InContext(context)) { - return rule; - } - } - } - return null; - }; - return RulesMap; - })(); - formatting.RulesMap = RulesMap; - var MaskBitSize = 5; - var Mask = 0x1f; - (function (RulesPosition) { - RulesPosition[RulesPosition["IgnoreRulesSpecific"] = 0] = "IgnoreRulesSpecific"; - RulesPosition[RulesPosition["IgnoreRulesAny"] = MaskBitSize * 1] = "IgnoreRulesAny"; - RulesPosition[RulesPosition["ContextRulesSpecific"] = MaskBitSize * 2] = "ContextRulesSpecific"; - RulesPosition[RulesPosition["ContextRulesAny"] = MaskBitSize * 3] = "ContextRulesAny"; - RulesPosition[RulesPosition["NoContextRulesSpecific"] = MaskBitSize * 4] = "NoContextRulesSpecific"; - RulesPosition[RulesPosition["NoContextRulesAny"] = MaskBitSize * 5] = "NoContextRulesAny"; - })(formatting.RulesPosition || (formatting.RulesPosition = {})); - var RulesPosition = formatting.RulesPosition; - var RulesBucketConstructionState = (function () { - function RulesBucketConstructionState() { - //// The Rules list contains all the inserted rules into a rulebucket in the following order: - //// 1- Ignore rules with specific token combination - //// 2- Ignore rules with any token combination - //// 3- Context rules with specific token combination - //// 4- Context rules with any token combination - //// 5- Non-context rules with specific token combination - //// 6- Non-context rules with any token combination - //// - //// The member rulesInsertionIndexBitmap is used to describe the number of rules - //// in each sub-bucket (above) hence can be used to know the index of where to insert - //// the next rule. It's a bitmap which contains 6 different sections each is given 5 bits. - //// - //// Example: - //// In order to insert a rule to the end of sub-bucket (3), we get the index by adding - //// the values in the bitmap segments 3rd, 2nd, and 1st. - this.rulesInsertionIndexBitmap = 0; - } - RulesBucketConstructionState.prototype.GetInsertionIndex = function (maskPosition) { - var index = 0; - var pos = 0; - var indexBitmap = this.rulesInsertionIndexBitmap; - while (pos <= maskPosition) { - index += (indexBitmap & Mask); - indexBitmap >>= MaskBitSize; - pos += MaskBitSize; - } - return index; - }; - RulesBucketConstructionState.prototype.IncreaseInsertionIndex = function (maskPosition) { - var value = (this.rulesInsertionIndexBitmap >> maskPosition) & Mask; - value++; - ts.Debug.assert((value & Mask) === value, "Adding more rules into the sub-bucket than allowed. Maximum allowed is 32 rules."); - var temp = this.rulesInsertionIndexBitmap & ~(Mask << maskPosition); - temp |= value << maskPosition; - this.rulesInsertionIndexBitmap = temp; - }; - return RulesBucketConstructionState; - })(); - formatting.RulesBucketConstructionState = RulesBucketConstructionState; - var RulesBucket = (function () { - function RulesBucket() { - this.rules = []; - } - RulesBucket.prototype.Rules = function () { - return this.rules; - }; - RulesBucket.prototype.AddRule = function (rule, specificTokens, constructionState, rulesBucketIndex) { - var position; - if (rule.Operation.Action === 1 /* Ignore */) { - position = specificTokens ? - RulesPosition.IgnoreRulesSpecific : - RulesPosition.IgnoreRulesAny; - } - else if (!rule.Operation.Context.IsAny()) { - position = specificTokens ? - RulesPosition.ContextRulesSpecific : - RulesPosition.ContextRulesAny; - } - else { - position = specificTokens ? - RulesPosition.NoContextRulesSpecific : - RulesPosition.NoContextRulesAny; - } - var state = constructionState[rulesBucketIndex]; - if (state === undefined) { - state = constructionState[rulesBucketIndex] = new RulesBucketConstructionState(); - } - var index = state.GetInsertionIndex(position); - this.rules.splice(index, 0, rule); - state.IncreaseInsertionIndex(position); - }; - return RulesBucket; - })(); - formatting.RulesBucket = RulesBucket; - })(formatting = ts.formatting || (ts.formatting = {})); -})(ts || (ts = {})); -/// -/* @internal */ -var ts; -(function (ts) { - var formatting; - (function (formatting) { - var Shared; - (function (Shared) { - var TokenRangeAccess = (function () { - function TokenRangeAccess(from, to, except) { - this.tokens = []; - for (var token = from; token <= to; token++) { - if (except.indexOf(token) < 0) { - this.tokens.push(token); - } - } - } - TokenRangeAccess.prototype.GetTokens = function () { - return this.tokens; - }; - TokenRangeAccess.prototype.Contains = function (token) { - return this.tokens.indexOf(token) >= 0; - }; - return TokenRangeAccess; - })(); - Shared.TokenRangeAccess = TokenRangeAccess; - var TokenValuesAccess = (function () { - function TokenValuesAccess(tks) { - this.tokens = tks && tks.length ? tks : []; - } - TokenValuesAccess.prototype.GetTokens = function () { - return this.tokens; - }; - TokenValuesAccess.prototype.Contains = function (token) { - return this.tokens.indexOf(token) >= 0; - }; - return TokenValuesAccess; - })(); - Shared.TokenValuesAccess = TokenValuesAccess; - var TokenSingleValueAccess = (function () { - function TokenSingleValueAccess(token) { - this.token = token; - } - TokenSingleValueAccess.prototype.GetTokens = function () { - return [this.token]; - }; - TokenSingleValueAccess.prototype.Contains = function (tokenValue) { - return tokenValue === this.token; - }; - return TokenSingleValueAccess; - })(); - Shared.TokenSingleValueAccess = TokenSingleValueAccess; - var TokenAllAccess = (function () { - function TokenAllAccess() { - } - TokenAllAccess.prototype.GetTokens = function () { - var result = []; - for (var token = 0 /* FirstToken */; token <= 134 /* LastToken */; token++) { - result.push(token); - } - return result; - }; - TokenAllAccess.prototype.Contains = function (tokenValue) { - return true; - }; - TokenAllAccess.prototype.toString = function () { - return "[allTokens]"; - }; - return TokenAllAccess; - })(); - Shared.TokenAllAccess = TokenAllAccess; - var TokenRange = (function () { - function TokenRange(tokenAccess) { - this.tokenAccess = tokenAccess; - } - TokenRange.FromToken = function (token) { - return new TokenRange(new TokenSingleValueAccess(token)); - }; - TokenRange.FromTokens = function (tokens) { - return new TokenRange(new TokenValuesAccess(tokens)); - }; - TokenRange.FromRange = function (f, to, except) { - if (except === void 0) { except = []; } - return new TokenRange(new TokenRangeAccess(f, to, except)); - }; - TokenRange.AllTokens = function () { - return new TokenRange(new TokenAllAccess()); - }; - TokenRange.prototype.GetTokens = function () { - return this.tokenAccess.GetTokens(); - }; - TokenRange.prototype.Contains = function (token) { - return this.tokenAccess.Contains(token); - }; - TokenRange.prototype.toString = function () { - return this.tokenAccess.toString(); - }; - TokenRange.Any = TokenRange.AllTokens(); - TokenRange.AnyIncludingMultilineComments = TokenRange.FromTokens(TokenRange.Any.GetTokens().concat([3 /* MultiLineCommentTrivia */])); - TokenRange.Keywords = TokenRange.FromRange(70 /* FirstKeyword */, 134 /* LastKeyword */); - TokenRange.BinaryOperators = TokenRange.FromRange(25 /* FirstBinaryOperator */, 68 /* LastBinaryOperator */); - TokenRange.BinaryKeywordOperators = TokenRange.FromTokens([90 /* InKeyword */, 91 /* InstanceOfKeyword */, 134 /* OfKeyword */, 116 /* AsKeyword */, 124 /* IsKeyword */]); - TokenRange.UnaryPrefixOperators = TokenRange.FromTokens([41 /* PlusPlusToken */, 42 /* MinusMinusToken */, 50 /* TildeToken */, 49 /* ExclamationToken */]); - TokenRange.UnaryPrefixExpressions = TokenRange.FromTokens([8 /* NumericLiteral */, 69 /* Identifier */, 17 /* OpenParenToken */, 19 /* OpenBracketToken */, 15 /* OpenBraceToken */, 97 /* ThisKeyword */, 92 /* NewKeyword */]); - TokenRange.UnaryPreincrementExpressions = TokenRange.FromTokens([69 /* Identifier */, 17 /* OpenParenToken */, 97 /* ThisKeyword */, 92 /* NewKeyword */]); - TokenRange.UnaryPostincrementExpressions = TokenRange.FromTokens([69 /* Identifier */, 18 /* CloseParenToken */, 20 /* CloseBracketToken */, 92 /* NewKeyword */]); - TokenRange.UnaryPredecrementExpressions = TokenRange.FromTokens([69 /* Identifier */, 17 /* OpenParenToken */, 97 /* ThisKeyword */, 92 /* NewKeyword */]); - TokenRange.UnaryPostdecrementExpressions = TokenRange.FromTokens([69 /* Identifier */, 18 /* CloseParenToken */, 20 /* CloseBracketToken */, 92 /* NewKeyword */]); - TokenRange.Comments = TokenRange.FromTokens([2 /* SingleLineCommentTrivia */, 3 /* MultiLineCommentTrivia */]); - TokenRange.TypeNames = TokenRange.FromTokens([69 /* Identifier */, 128 /* NumberKeyword */, 130 /* StringKeyword */, 120 /* BooleanKeyword */, 131 /* SymbolKeyword */, 103 /* VoidKeyword */, 117 /* AnyKeyword */]); - return TokenRange; - })(); - Shared.TokenRange = TokenRange; - })(Shared = formatting.Shared || (formatting.Shared = {})); - })(formatting = ts.formatting || (ts.formatting = {})); -})(ts || (ts = {})); -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/* @internal */ -var ts; -(function (ts) { - var formatting; - (function (formatting) { - var RulesProvider = (function () { - function RulesProvider() { - this.globalRules = new formatting.Rules(); - } - RulesProvider.prototype.getRuleName = function (rule) { - return this.globalRules.getRuleName(rule); - }; - RulesProvider.prototype.getRuleByName = function (name) { - return this.globalRules[name]; - }; - RulesProvider.prototype.getRulesMap = function () { - return this.rulesMap; - }; - RulesProvider.prototype.ensureUpToDate = function (options) { - // TODO: Should this be '==='? - if (this.options == null || !ts.compareDataObjects(this.options, options)) { - var activeRules = this.createActiveRules(options); - var rulesMap = formatting.RulesMap.create(activeRules); - this.activeRules = activeRules; - this.rulesMap = rulesMap; - this.options = ts.clone(options); - } - }; - RulesProvider.prototype.createActiveRules = function (options) { - var rules = this.globalRules.HighPriorityCommonRules.slice(0); - if (options.InsertSpaceAfterCommaDelimiter) { - rules.push(this.globalRules.SpaceAfterComma); - } - else { - rules.push(this.globalRules.NoSpaceAfterComma); - } - if (options.InsertSpaceAfterFunctionKeywordForAnonymousFunctions) { - rules.push(this.globalRules.SpaceAfterAnonymousFunctionKeyword); - } - else { - rules.push(this.globalRules.NoSpaceAfterAnonymousFunctionKeyword); - } - if (options.InsertSpaceAfterKeywordsInControlFlowStatements) { - rules.push(this.globalRules.SpaceAfterKeywordInControl); - } - else { - rules.push(this.globalRules.NoSpaceAfterKeywordInControl); - } - if (options.InsertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis) { - rules.push(this.globalRules.SpaceAfterOpenParen); - rules.push(this.globalRules.SpaceBeforeCloseParen); - rules.push(this.globalRules.NoSpaceBetweenParens); - } - else { - rules.push(this.globalRules.NoSpaceAfterOpenParen); - rules.push(this.globalRules.NoSpaceBeforeCloseParen); - rules.push(this.globalRules.NoSpaceBetweenParens); - } - if (options.InsertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets) { - rules.push(this.globalRules.SpaceAfterOpenBracket); - rules.push(this.globalRules.SpaceBeforeCloseBracket); - rules.push(this.globalRules.NoSpaceBetweenBrackets); - } - else { - rules.push(this.globalRules.NoSpaceAfterOpenBracket); - rules.push(this.globalRules.NoSpaceBeforeCloseBracket); - rules.push(this.globalRules.NoSpaceBetweenBrackets); - } - if (options.InsertSpaceAfterSemicolonInForStatements) { - rules.push(this.globalRules.SpaceAfterSemicolonInFor); - } - else { - rules.push(this.globalRules.NoSpaceAfterSemicolonInFor); - } - if (options.InsertSpaceBeforeAndAfterBinaryOperators) { - rules.push(this.globalRules.SpaceBeforeBinaryOperator); - rules.push(this.globalRules.SpaceAfterBinaryOperator); - } - else { - rules.push(this.globalRules.NoSpaceBeforeBinaryOperator); - rules.push(this.globalRules.NoSpaceAfterBinaryOperator); - } - if (options.PlaceOpenBraceOnNewLineForControlBlocks) { - rules.push(this.globalRules.NewLineBeforeOpenBraceInControl); - } - if (options.PlaceOpenBraceOnNewLineForFunctions) { - rules.push(this.globalRules.NewLineBeforeOpenBraceInFunction); - rules.push(this.globalRules.NewLineBeforeOpenBraceInTypeScriptDeclWithBlock); - } - rules = rules.concat(this.globalRules.LowPriorityCommonRules); - return rules; - }; - return RulesProvider; - })(); - formatting.RulesProvider = RulesProvider; - })(formatting = ts.formatting || (ts.formatting = {})); -})(ts || (ts = {})); -/// -/// -/// -/// -/* @internal */ -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) { - return []; - } - // get the span for the previous\current line - var span = { - // get start position for the previous line - pos: ts.getStartPositionOfLine(line - 1, sourceFile), - // get end position for the current line (end value is exclusive so add 1 to the result) - end: ts.getEndLinePosition(line, sourceFile) + 1 - }; - return formatSpan(span, sourceFile, options, rulesProvider, 2 /* FormatOnEnter */); - } - formatting.formatOnEnter = formatOnEnter; - function formatOnSemicolon(position, sourceFile, rulesProvider, options) { - return formatOutermostParent(position, 23 /* 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 */); - } - formatting.formatOnClosingCurly = formatOnClosingCurly; - function formatDocument(sourceFile, rulesProvider, options) { - var span = { - pos: 0, - end: sourceFile.text.length - }; - return formatSpan(span, sourceFile, options, rulesProvider, 0 /* FormatDocument */); - } - formatting.formatDocument = formatDocument; - function formatSelection(start, end, sourceFile, rulesProvider, options) { - // format from the beginning of the line - var span = { - pos: ts.getLineStartPositionForPosition(start, sourceFile), - end: end - }; - return formatSpan(span, sourceFile, options, rulesProvider, 1 /* FormatSelection */); - } - formatting.formatSelection = formatSelection; - function formatOutermostParent(position, expectedLastToken, sourceFile, options, rulesProvider, requestKind) { - var parent = findOutermostParent(position, expectedLastToken, sourceFile); - if (!parent) { - return []; - } - var span = { - pos: ts.getLineStartPositionForPosition(parent.getStart(sourceFile), sourceFile), - end: parent.end - }; - return formatSpan(span, sourceFile, options, rulesProvider, requestKind); - } - function findOutermostParent(position, expectedTokenKind, sourceFile) { - var precedingToken = ts.findPrecedingToken(position, sourceFile); - // when it is claimed that trigger character was typed at given position - // we verify that there is a token with a matching kind whose end is equal to position (because the character was just typed). - // If this condition is not hold - then trigger character was typed in some other context, - // i.e.in comment and thus should not trigger autoformatting - if (!precedingToken || - precedingToken.kind !== expectedTokenKind || - position !== precedingToken.getEnd()) { - return undefined; - } - // walk up and search for the parent node that ends at the same position with precedingToken. - // for cases like this - // - // let x = 1; - // while (true) { - // } - // after typing close curly in while statement we want to reformat just the while statement. - // However if we just walk upwards searching for the parent that has the same end value - - // we'll end up with the whole source file. isListElement allows to stop on the list element level - var current = precedingToken; - while (current && - current.parent && - current.parent.end === precedingToken.end && - !isListElement(current.parent, current)) { - current = current.parent; - } - return current; - } - // Returns true if node is a element in some list in parent - // 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 214 /* ClassDeclaration */: - case 215 /* InterfaceDeclaration */: - return ts.rangeContainsRange(parent.members, node); - case 218 /* ModuleDeclaration */: - var body = parent.body; - return body && body.kind === 192 /* Block */ && ts.rangeContainsRange(body.statements, node); - case 248 /* SourceFile */: - case 192 /* Block */: - case 219 /* ModuleBlock */: - return ts.rangeContainsRange(parent.statements, node); - case 244 /* CatchClause */: - return ts.rangeContainsRange(parent.block.statements, node); - } - return false; - } - /** find node that fully contains given text range */ - function findEnclosingNode(range, sourceFile) { - return find(sourceFile); - function find(n) { - var candidate = ts.forEachChild(n, function (c) { return ts.startEndContainsRange(c.getStart(sourceFile), c.end, range) && c; }); - if (candidate) { - var result = find(candidate); - if (result) { - return result; - } - } - return n; - } - } - /** formatting is not applied to ranges that contain parse errors. - * This function will return a predicate that for a given text range will tell - * if there are any parse errors that overlap with the range. - */ - function prepareRangeContainsErrorFunction(errors, originalRange) { - if (!errors.length) { - return rangeHasNoErrors; - } - // pick only errors that fall in range - var sorted = errors - .filter(function (d) { return ts.rangeOverlapsWithStartEnd(originalRange, d.start, d.start + d.length); }) - .sort(function (e1, e2) { return e1.start - e2.start; }); - if (!sorted.length) { - return rangeHasNoErrors; - } - var index = 0; - return function (r) { - // in current implementation sequence of arguments [r1, r2...] is monotonically increasing. - // 'index' tracks the index of the most recent error that was checked. - while (true) { - if (index >= sorted.length) { - // all errors in the range were already checked -> no error in specified range - return false; - } - var error = sorted[index]; - if (r.end <= error.start) { - // specified range ends before the error refered by 'index' - no error in range - return false; - } - if (ts.startEndOverlapsWithStartEnd(r.pos, r.end, error.start, error.start + error.length)) { - // specified range overlaps with error range - return true; - } - index++; - } - }; - function rangeHasNoErrors(r) { - return false; - } - } - /** - * Start of the original range might fall inside the comment - scanner will not yield appropriate results - * This function will look for token that is located before the start of target range - * and return its end as start position for the scanner. - */ - function getScanStartPosition(enclosingNode, originalRange, sourceFile) { - var start = enclosingNode.getStart(sourceFile); - if (start === originalRange.pos && enclosingNode.end === originalRange.end) { - return start; - } - var precedingToken = ts.findPrecedingToken(originalRange.pos, sourceFile); - if (!precedingToken) { - // no preceding token found - start from the beginning of enclosing node - return enclosingNode.pos; - } - // preceding token ends after the start of original range (i.e when originaRange.pos falls in the middle of literal) - // start from the beginning of enclosingNode to handle the entire 'originalRange' - if (precedingToken.end >= originalRange.pos) { - return enclosingNode.pos; - } - return precedingToken.end; - } - /* - * For cases like - * if (a || - * b ||$ - * c) {...} - * If we hit Enter at $ we want line ' b ||' to be indented. - * Formatting will be applied to the last two lines. - * Node that fully encloses these lines is binary expression 'a ||...'. - * Initial indentation for this node will be 0. - * Binary expressions don't introduce new indentation scopes, however it is possible - * that some parent node on the same line does - like if statement in this case. - * Note that we are considering parents only from the same line with initial node - - * if parent is on the different line - its delta was already contributed - * to the initial indentation. - */ - function getOwnOrInheritedDelta(n, options, sourceFile) { - var previousLine = -1 /* Unknown */; - var childKind = 0 /* Unknown */; - while (n) { - var line = sourceFile.getLineAndCharacterOfPosition(n.getStart(sourceFile)).line; - if (previousLine !== -1 /* Unknown */ && line !== previousLine) { - break; - } - if (formatting.SmartIndenter.shouldIndentChildNode(n.kind, childKind)) { - return options.IndentSize; - } - previousLine = line; - childKind = n.kind; - n = n.parent; - } - return 0; - } - function formatSpan(originalRange, sourceFile, options, rulesProvider, requestKind) { - var rangeContainsError = prepareRangeContainsErrorFunction(sourceFile.parseDiagnostics, originalRange); - // formatting context is used by rules provider - var formattingContext = new formatting.FormattingContext(sourceFile, requestKind); - // find the smallest node that fully wraps the range and compute the initial indentation for the node - var enclosingNode = findEnclosingNode(originalRange, sourceFile); - var formattingScanner = formatting.getFormattingScanner(sourceFile, getScanStartPosition(enclosingNode, originalRange, sourceFile), originalRange.end); - var initialIndentation = formatting.SmartIndenter.getIndentationForNode(enclosingNode, originalRange, sourceFile, options); - var previousRangeHasError; - var previousRange; - var previousParent; - var previousRangeStartLine; - var lastIndentedLine; - var indentationOnLastIndentedLine; - var edits = []; - formattingScanner.advance(); - if (formattingScanner.isOnToken()) { - var startLine = sourceFile.getLineAndCharacterOfPosition(enclosingNode.getStart(sourceFile)).line; - var undecoratedStartLine = startLine; - if (enclosingNode.decorators) { - undecoratedStartLine = sourceFile.getLineAndCharacterOfPosition(ts.getNonDecoratorTokenPosOfNode(enclosingNode, sourceFile)).line; - } - var delta = getOwnOrInheritedDelta(enclosingNode, options, sourceFile); - processNode(enclosingNode, enclosingNode, startLine, undecoratedStartLine, initialIndentation, delta); - } - formattingScanner.close(); - return edits; - // local functions - /** Tries to compute the indentation for a list element. - * If list element is not in range then - * function will pick its actual indentation - * so it can be pushed downstream as inherited indentation. - * If list element is in the range - its indentation will be equal - * to inherited indentation from its predecessors. - */ - function tryComputeIndentationForListItem(startPos, endPos, parentStartLine, range, inheritedIndentation) { - if (ts.rangeOverlapsWithStartEnd(range, startPos, endPos)) { - if (inheritedIndentation !== -1 /* Unknown */) { - return inheritedIndentation; - } - } - else { - var startLine = sourceFile.getLineAndCharacterOfPosition(startPos).line; - var startLinePosition = ts.getLineStartPositionForPosition(startPos, sourceFile); - var column = formatting.SmartIndenter.findFirstNonWhitespaceColumn(startLinePosition, startPos, sourceFile, options); - if (startLine !== parentStartLine || startPos === column) { - return column; - } - } - return -1 /* Unknown */; - } - function computeIndentation(node, startLine, inheritedIndentation, parent, parentDynamicIndentation, effectiveParentStartLine) { - var indentation = inheritedIndentation; - if (indentation === -1 /* Unknown */) { - if (isSomeBlock(node.kind)) { - // blocks should be indented in - // - other blocks - // - source file - // - switch\default clauses - if (isSomeBlock(parent.kind) || - parent.kind === 248 /* SourceFile */ || - parent.kind === 241 /* CaseClause */ || - parent.kind === 242 /* DefaultClause */) { - indentation = parentDynamicIndentation.getIndentation() + parentDynamicIndentation.getDelta(); - } - else { - indentation = parentDynamicIndentation.getIndentation(); - } - } - else { - if (formatting.SmartIndenter.childStartsOnTheSameLineWithElseInIfStatement(parent, node, startLine, sourceFile)) { - indentation = parentDynamicIndentation.getIndentation(); - } - else { - indentation = parentDynamicIndentation.getIndentation() + parentDynamicIndentation.getDelta(); - } - } - } - var delta = formatting.SmartIndenter.shouldIndentChildNode(node.kind, 0 /* Unknown */) ? options.IndentSize : 0; - if (effectiveParentStartLine === startLine) { - // if node is located on the same line with the parent - // - inherit indentation from the parent - // - push children if either parent of node itself has non-zero delta - indentation = startLine === lastIndentedLine - ? indentationOnLastIndentedLine - : parentDynamicIndentation.getIndentation(); - delta = Math.min(options.IndentSize, parentDynamicIndentation.getDelta() + delta); - } - return { - indentation: indentation, - delta: delta - }; - } - function getFirstNonDecoratorTokenOfNode(node) { - if (node.modifiers && node.modifiers.length) { - return node.modifiers[0].kind; - } - switch (node.kind) { - case 214 /* ClassDeclaration */: return 73 /* ClassKeyword */; - case 215 /* InterfaceDeclaration */: return 107 /* InterfaceKeyword */; - case 213 /* FunctionDeclaration */: return 87 /* FunctionKeyword */; - case 217 /* EnumDeclaration */: return 217 /* EnumDeclaration */; - case 145 /* GetAccessor */: return 123 /* GetKeyword */; - case 146 /* SetAccessor */: return 129 /* SetKeyword */; - case 143 /* MethodDeclaration */: - if (node.asteriskToken) { - return 37 /* AsteriskToken */; - } - // fall-through - case 141 /* PropertyDeclaration */: - case 138 /* Parameter */: - return node.name.kind; - } - } - function getDynamicIndentation(node, nodeStartLine, indentation, delta) { - return { - getIndentationForComment: function (kind, tokenIndentation) { - switch (kind) { - // preceding comment to the token that closes the indentation scope inherits the indentation from the scope - // .. { - // // comment - // } - case 16 /* CloseBraceToken */: - case 20 /* CloseBracketToken */: - case 18 /* CloseParenToken */: - return indentation + delta; - } - return tokenIndentation !== -1 /* Unknown */ ? tokenIndentation : indentation; - }, - getIndentationForToken: function (line, kind) { - if (nodeStartLine !== line && node.decorators) { - if (kind === getFirstNonDecoratorTokenOfNode(node)) { - // if this token is the first token following the list of decorators, we do not need to indent - return indentation; - } - } - 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 */: - return indentation; - default: - // if token line equals to the line of containing node (this is a first token in the node) - use node indentation - return nodeStartLine !== line ? indentation + delta : indentation; - } - }, - getIndentation: function () { return indentation; }, - getDelta: function () { return delta; }, - recomputeIndentation: function (lineAdded) { - if (node.parent && formatting.SmartIndenter.shouldIndentChildNode(node.parent.kind, node.kind)) { - if (lineAdded) { - indentation += options.IndentSize; - } - else { - indentation -= options.IndentSize; - } - if (formatting.SmartIndenter.shouldIndentChildNode(node.kind, 0 /* Unknown */)) { - delta = options.IndentSize; - } - else { - delta = 0; - } - } - } - }; - } - function processNode(node, contextNode, nodeStartLine, undecoratedNodeStartLine, indentation, delta) { - if (!ts.rangeOverlapsWithStartEnd(originalRange, node.getStart(sourceFile), node.getEnd())) { - return; - } - var nodeDynamicIndentation = getDynamicIndentation(node, nodeStartLine, indentation, delta); - // a useful observations when tracking context node - // / - // [a] - // / | \ - // [b] [c] [d] - // node 'a' is a context node for nodes 'b', 'c', 'd' - // except for the leftmost leaf token in [b] - in this case context node ('e') is located somewhere above 'a' - // this rule can be applied recursively to child nodes of 'a'. - // - // context node is set to parent node value after processing every child node - // context node is set to parent of the token after processing every token - var childContextNode = contextNode; - // if there are any tokens that logically belong to node and interleave child nodes - // such tokens will be consumed in processChildNode for for the child that follows them - ts.forEachChild(node, function (child) { - processChildNode(child, /*inheritedIndentation*/ -1 /* Unknown */, node, nodeDynamicIndentation, nodeStartLine, undecoratedNodeStartLine, /*isListElement*/ false); - }, function (nodes) { - processChildNodes(nodes, node, nodeStartLine, nodeDynamicIndentation); - }); - // proceed any tokens in the node that are located after child nodes - while (formattingScanner.isOnToken()) { - var tokenInfo = formattingScanner.readTokenInfo(node); - if (tokenInfo.token.end > node.end) { - break; - } - consumeTokenAndAdvanceScanner(tokenInfo, node, nodeDynamicIndentation); - } - function processChildNode(child, inheritedIndentation, parent, parentDynamicIndentation, parentStartLine, undecoratedParentStartLine, isListItem) { - var childStartPos = child.getStart(sourceFile); - var childStartLine = sourceFile.getLineAndCharacterOfPosition(childStartPos).line; - var undecoratedChildStartLine = childStartLine; - if (child.decorators) { - undecoratedChildStartLine = sourceFile.getLineAndCharacterOfPosition(ts.getNonDecoratorTokenPosOfNode(child, sourceFile)).line; - } - // if child is a list item - try to get its indentation - var childIndentationAmount = -1 /* Unknown */; - if (isListItem) { - childIndentationAmount = tryComputeIndentationForListItem(childStartPos, child.end, parentStartLine, originalRange, inheritedIndentation); - if (childIndentationAmount !== -1 /* Unknown */) { - inheritedIndentation = childIndentationAmount; - } - } - // child node is outside the target range - do not dive inside - if (!ts.rangeOverlapsWithStartEnd(originalRange, child.pos, child.end)) { - return inheritedIndentation; - } - if (child.getFullWidth() === 0) { - return inheritedIndentation; - } - while (formattingScanner.isOnToken()) { - // proceed any parent tokens that are located prior to child.getStart() - var tokenInfo = formattingScanner.readTokenInfo(node); - if (tokenInfo.token.end > childStartPos) { - // stop when formatting scanner advances past the beginning of the child - break; - } - consumeTokenAndAdvanceScanner(tokenInfo, node, parentDynamicIndentation); - } - if (!formattingScanner.isOnToken()) { - return inheritedIndentation; - } - if (ts.isToken(child)) { - // 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); - consumeTokenAndAdvanceScanner(tokenInfo, node, parentDynamicIndentation); - return inheritedIndentation; - } - var effectiveParentStartLine = child.kind === 139 /* Decorator */ ? childStartLine : undecoratedParentStartLine; - var childIndentation = computeIndentation(child, childStartLine, childIndentationAmount, node, parentDynamicIndentation, effectiveParentStartLine); - processNode(child, childContextNode, childStartLine, undecoratedChildStartLine, childIndentation.indentation, childIndentation.delta); - childContextNode = node; - return inheritedIndentation; - } - function processChildNodes(nodes, parent, parentStartLine, parentDynamicIndentation) { - var listStartToken = getOpenTokenForList(parent, nodes); - var listEndToken = getCloseTokenForOpenToken(listStartToken); - var listDynamicIndentation = parentDynamicIndentation; - var startLine = parentStartLine; - if (listStartToken !== 0 /* Unknown */) { - // introduce a new indentation scope for lists (including list start and end tokens) - while (formattingScanner.isOnToken()) { - var tokenInfo = formattingScanner.readTokenInfo(parent); - if (tokenInfo.token.end > nodes.pos) { - // stop when formatting scanner moves past the beginning of node list - break; - } - else if (tokenInfo.token.kind === listStartToken) { - // consume list start token - startLine = sourceFile.getLineAndCharacterOfPosition(tokenInfo.token.pos).line; - var indentation_1 = computeIndentation(tokenInfo.token, startLine, -1 /* Unknown */, parent, parentDynamicIndentation, parentStartLine); - listDynamicIndentation = getDynamicIndentation(parent, parentStartLine, indentation_1.indentation, indentation_1.delta); - consumeTokenAndAdvanceScanner(tokenInfo, parent, listDynamicIndentation); - } - else { - // consume any tokens that precede the list as child elements of 'node' using its indentation scope - consumeTokenAndAdvanceScanner(tokenInfo, parent, parentDynamicIndentation); - } - } - } - var inheritedIndentation = -1 /* Unknown */; - for (var _i = 0; _i < nodes.length; _i++) { - var child = nodes[_i]; - inheritedIndentation = processChildNode(child, inheritedIndentation, node, listDynamicIndentation, startLine, startLine, /*isListElement*/ true); - } - if (listEndToken !== 0 /* Unknown */) { - if (formattingScanner.isOnToken()) { - var tokenInfo = formattingScanner.readTokenInfo(parent); - // consume the list end token only if it is still belong to the parent - // there might be the case when current token matches end token but does not considered as one - // function (x: function) <-- - // without this check close paren will be interpreted as list end token for function expression which is wrong - if (tokenInfo.token.kind === listEndToken && ts.rangeContainsRange(parent, tokenInfo.token)) { - // consume list end token - consumeTokenAndAdvanceScanner(tokenInfo, parent, listDynamicIndentation); - } - } - } - } - function consumeTokenAndAdvanceScanner(currentTokenInfo, parent, dynamicIndentation) { - ts.Debug.assert(ts.rangeContainsRange(parent, currentTokenInfo.token)); - var lastTriviaWasNewLine = formattingScanner.lastTrailingTriviaWasNewLine(); - var indentToken = false; - if (currentTokenInfo.leadingTrivia) { - processTrivia(currentTokenInfo.leadingTrivia, parent, childContextNode, dynamicIndentation); - } - var lineAdded; - var isTokenInRange = ts.rangeContainsRange(originalRange, currentTokenInfo.token); - var tokenStart = sourceFile.getLineAndCharacterOfPosition(currentTokenInfo.token.pos); - if (isTokenInRange) { - var rangeHasError = rangeContainsError(currentTokenInfo.token); - // save previousRange since processRange will overwrite this value with current one - var savePreviousRange = previousRange; - lineAdded = processRange(currentTokenInfo.token, tokenStart, parent, childContextNode, dynamicIndentation); - if (rangeHasError) { - // do not indent comments\token if token range overlaps with some error - indentToken = false; - } - else { - if (lineAdded !== undefined) { - indentToken = lineAdded; - } - else { - // indent token only if end line of previous range does not match start line of the token - var prevEndLine = savePreviousRange && sourceFile.getLineAndCharacterOfPosition(savePreviousRange.end).line; - indentToken = lastTriviaWasNewLine && tokenStart.line !== prevEndLine; - } - } - } - if (currentTokenInfo.trailingTrivia) { - processTrivia(currentTokenInfo.trailingTrivia, parent, childContextNode, dynamicIndentation); - } - if (indentToken) { - var tokenIndentation = (isTokenInRange && !rangeContainsError(currentTokenInfo.token)) ? - dynamicIndentation.getIndentationForToken(tokenStart.line, currentTokenInfo.token.kind) : - -1 /* Unknown */; - if (currentTokenInfo.leadingTrivia) { - var commentIndentation = dynamicIndentation.getIndentationForComment(currentTokenInfo.token.kind, tokenIndentation); - var indentNextTokenOrTrivia = true; - for (var _i = 0, _a = currentTokenInfo.leadingTrivia; _i < _a.length; _i++) { - var triviaItem = _a[_i]; - if (!ts.rangeContainsRange(originalRange, triviaItem)) { - continue; - } - switch (triviaItem.kind) { - case 3 /* MultiLineCommentTrivia */: - indentMultilineComment(triviaItem, commentIndentation, /*firstLineIsIndented*/ !indentNextTokenOrTrivia); - indentNextTokenOrTrivia = false; - break; - case 2 /* SingleLineCommentTrivia */: - if (indentNextTokenOrTrivia) { - insertIndentation(triviaItem.pos, commentIndentation, /*lineAdded*/ false); - indentNextTokenOrTrivia = false; - } - break; - case 4 /* NewLineTrivia */: - indentNextTokenOrTrivia = true; - break; - } - } - } - // indent token only if is it is in target range and does not overlap with any error ranges - if (tokenIndentation !== -1 /* Unknown */) { - insertIndentation(currentTokenInfo.token.pos, tokenIndentation, lineAdded); - lastIndentedLine = tokenStart.line; - indentationOnLastIndentedLine = tokenIndentation; - } - } - formattingScanner.advance(); - childContextNode = parent; - } - } - function processTrivia(trivia, parent, contextNode, dynamicIndentation) { - for (var _i = 0; _i < trivia.length; _i++) { - var triviaItem = trivia[_i]; - if (ts.isComment(triviaItem.kind) && ts.rangeContainsRange(originalRange, triviaItem)) { - var triviaItemStart = sourceFile.getLineAndCharacterOfPosition(triviaItem.pos); - processRange(triviaItem, triviaItemStart, parent, contextNode, dynamicIndentation); - } - } - } - function processRange(range, rangeStart, parent, contextNode, dynamicIndentation) { - var rangeHasError = rangeContainsError(range); - var lineAdded; - if (!rangeHasError && !previousRangeHasError) { - if (!previousRange) { - // trim whitespaces starting from the beginning of the span up to the current line - var originalStart = sourceFile.getLineAndCharacterOfPosition(originalRange.pos); - trimTrailingWhitespacesForLines(originalStart.line, rangeStart.line); - } - else { - lineAdded = - processPair(range, rangeStart.line, parent, previousRange, previousRangeStartLine, previousParent, contextNode, dynamicIndentation); - } - } - previousRange = range; - previousParent = parent; - previousRangeStartLine = rangeStart.line; - previousRangeHasError = rangeHasError; - return lineAdded; - } - function processPair(currentItem, currentStartLine, currentParent, previousItem, previousStartLine, previousParent, contextNode, dynamicIndentation) { - formattingContext.updateContext(previousItem, previousParent, currentItem, currentParent, contextNode); - var rule = rulesProvider.getRulesMap().GetRule(formattingContext); - var trimTrailingWhitespaces; - var lineAdded; - if (rule) { - applyRuleEdits(rule, previousItem, previousStartLine, currentItem, currentStartLine); - if (rule.Operation.Action & (2 /* Space */ | 8 /* Delete */) && currentStartLine !== previousStartLine) { - lineAdded = false; - // Handle the case where the next line is moved to be the end of this line. - // In this case we don't indent the next line in the next pass. - if (currentParent.getStart(sourceFile) === currentItem.pos) { - dynamicIndentation.recomputeIndentation(/*lineAdded*/ false); - } - } - else if (rule.Operation.Action & 4 /* NewLine */ && currentStartLine === previousStartLine) { - lineAdded = true; - // Handle the case where token2 is moved to the new line. - // In this case we indent token2 in the next pass but we set - // sameLineIndent flag to notify the indenter that the indentation is within the line. - if (currentParent.getStart(sourceFile) === currentItem.pos) { - dynamicIndentation.recomputeIndentation(/*lineAdded*/ true); - } - } - // We need to trim trailing whitespace between the tokens if they were on different lines, and no rule was applied to put them on the same line - trimTrailingWhitespaces = - (rule.Operation.Action & (4 /* NewLine */ | 2 /* Space */)) && - rule.Flag !== 1 /* CanDeleteNewLines */; - } - else { - trimTrailingWhitespaces = true; - } - if (currentStartLine !== previousStartLine && trimTrailingWhitespaces) { - // We need to trim trailing whitespace between the tokens if they were on different lines, and no rule was applied to put them on the same line - trimTrailingWhitespacesForLines(previousStartLine, currentStartLine, previousItem); - } - return lineAdded; - } - function insertIndentation(pos, indentation, lineAdded) { - var indentationString = getIndentationString(indentation, options); - if (lineAdded) { - // new line is added before the token by the formatting rules - // insert indentation string at the very beginning of the token - recordReplace(pos, 0, indentationString); - } - else { - var tokenStart = sourceFile.getLineAndCharacterOfPosition(pos); - if (indentation !== tokenStart.character) { - var startLinePosition = ts.getStartPositionOfLine(tokenStart.line, sourceFile); - recordReplace(startLinePosition, tokenStart.character, indentationString); - } - } - } - function indentMultilineComment(commentRange, indentation, firstLineIsIndented) { - // split comment in lines - var startLine = sourceFile.getLineAndCharacterOfPosition(commentRange.pos).line; - var endLine = sourceFile.getLineAndCharacterOfPosition(commentRange.end).line; - var parts; - if (startLine === endLine) { - if (!firstLineIsIndented) { - // treat as single line comment - insertIndentation(commentRange.pos, indentation, /*lineAdded*/ false); - } - return; - } - else { - parts = []; - var startPos = commentRange.pos; - for (var line = startLine; line < endLine; ++line) { - var endOfLine = ts.getEndLinePosition(line, sourceFile); - parts.push({ pos: startPos, end: endOfLine }); - startPos = ts.getStartPositionOfLine(line + 1, sourceFile); - } - parts.push({ pos: startPos, end: commentRange.end }); - } - var startLinePos = ts.getStartPositionOfLine(startLine, sourceFile); - var nonWhitespaceColumnInFirstPart = formatting.SmartIndenter.findFirstNonWhitespaceCharacterAndColumn(startLinePos, parts[0].pos, sourceFile, options); - if (indentation === nonWhitespaceColumnInFirstPart.column) { - return; - } - var startIndex = 0; - if (firstLineIsIndented) { - startIndex = 1; - startLine++; - } - // shift all parts on the delta size - var delta = indentation - nonWhitespaceColumnInFirstPart.column; - for (var i = startIndex, len = parts.length; i < len; ++i, ++startLine) { - var startLinePos_1 = ts.getStartPositionOfLine(startLine, sourceFile); - var nonWhitespaceCharacterAndColumn = i === 0 - ? nonWhitespaceColumnInFirstPart - : formatting.SmartIndenter.findFirstNonWhitespaceCharacterAndColumn(parts[i].pos, parts[i].end, sourceFile, options); - var newIndentation = nonWhitespaceCharacterAndColumn.column + delta; - if (newIndentation > 0) { - var indentationString = getIndentationString(newIndentation, options); - recordReplace(startLinePos_1, nonWhitespaceCharacterAndColumn.character, indentationString); - } - else { - recordDelete(startLinePos_1, nonWhitespaceCharacterAndColumn.character); - } - } - } - function trimTrailingWhitespacesForLines(line1, line2, range) { - for (var line = line1; line < line2; ++line) { - var lineStartPosition = ts.getStartPositionOfLine(line, sourceFile); - var lineEndPosition = ts.getEndLinePosition(line, sourceFile); - // do not trim whitespaces in comments or template expression - if (range && (ts.isComment(range.kind) || ts.isStringOrRegularExpressionOrTemplateLiteral(range.kind)) && range.pos <= lineEndPosition && range.end > lineEndPosition) { - continue; - } - var pos = lineEndPosition; - while (pos >= lineStartPosition && ts.isWhiteSpace(sourceFile.text.charCodeAt(pos))) { - pos--; - } - if (pos !== lineEndPosition) { - ts.Debug.assert(pos === lineStartPosition || !ts.isWhiteSpace(sourceFile.text.charCodeAt(pos))); - recordDelete(pos + 1, lineEndPosition - pos); - } - } - } - function newTextChange(start, len, newText) { - return { span: ts.createTextSpan(start, len), newText: newText }; - } - function recordDelete(start, len) { - if (len) { - edits.push(newTextChange(start, len, "")); - } - } - function recordReplace(start, len, newText) { - if (len || newText) { - edits.push(newTextChange(start, len, newText)); - } - } - function applyRuleEdits(rule, previousRange, previousStartLine, currentRange, currentStartLine) { - var between; - switch (rule.Operation.Action) { - case 1 /* Ignore */: - // no action required - return; - case 8 /* Delete */: - if (previousRange.end !== currentRange.pos) { - // delete characters starting from t1.end up to t2.pos exclusive - recordDelete(previousRange.end, currentRange.pos - previousRange.end); - } - break; - case 4 /* NewLine */: - // exit early if we on different lines and rule cannot change number of newlines - // if line1 and line2 are on subsequent lines then no edits are required - ok to exit - // if line1 and line2 are separated with more than one newline - ok to exit since we cannot delete extra new lines - if (rule.Flag !== 1 /* CanDeleteNewLines */ && previousStartLine !== currentStartLine) { - return; - } - // 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); - } - break; - case 2 /* Space */: - // exit early if we on different lines and rule cannot change number of newlines - if (rule.Flag !== 1 /* CanDeleteNewLines */ && previousStartLine !== currentStartLine) { - return; - } - var posDelta = currentRange.pos - previousRange.end; - if (posDelta !== 1 || sourceFile.text.charCodeAt(previousRange.end) !== 32 /* space */) { - recordReplace(previousRange.end, currentRange.pos - previousRange.end, " "); - } - break; - } - } - } - function isSomeBlock(kind) { - switch (kind) { - case 192 /* Block */: - case 219 /* ModuleBlock */: - return true; - } - return false; - } - function getOpenTokenForList(node, list) { - switch (node.kind) { - case 144 /* Constructor */: - case 213 /* FunctionDeclaration */: - case 173 /* FunctionExpression */: - case 143 /* MethodDeclaration */: - case 142 /* MethodSignature */: - case 174 /* ArrowFunction */: - if (node.typeParameters === list) { - return 25 /* LessThanToken */; - } - else if (node.parameters === list) { - return 17 /* OpenParenToken */; - } - break; - case 168 /* CallExpression */: - case 169 /* NewExpression */: - if (node.typeArguments === list) { - return 25 /* LessThanToken */; - } - else if (node.arguments === list) { - return 17 /* OpenParenToken */; - } - break; - case 151 /* TypeReference */: - if (node.typeArguments === list) { - return 25 /* LessThanToken */; - } - } - return 0 /* Unknown */; - } - function getCloseTokenForOpenToken(kind) { - switch (kind) { - case 17 /* OpenParenToken */: - return 18 /* CloseParenToken */; - case 25 /* LessThanToken */: - return 27 /* GreaterThanToken */; - } - return 0 /* Unknown */; - } - var internedSizes; - var internedTabsIndentation; - var internedSpacesIndentation; - function getIndentationString(indentation, options) { - // reset interned strings if FormatCodeOptions were changed - var resetInternedStrings = !internedSizes || (internedSizes.tabSize !== options.TabSize || internedSizes.indentSize !== options.IndentSize); - if (resetInternedStrings) { - internedSizes = { tabSize: options.TabSize, indentSize: options.IndentSize }; - internedTabsIndentation = internedSpacesIndentation = undefined; - } - if (!options.ConvertTabsToSpaces) { - var tabs = Math.floor(indentation / options.TabSize); - var spaces = indentation - tabs * options.TabSize; - var tabString; - if (!internedTabsIndentation) { - internedTabsIndentation = []; - } - if (internedTabsIndentation[tabs] === undefined) { - internedTabsIndentation[tabs] = tabString = repeat('\t', tabs); - } - else { - tabString = internedTabsIndentation[tabs]; - } - return spaces ? tabString + repeat(" ", spaces) : tabString; - } - else { - var spacesString; - var quotient = Math.floor(indentation / options.IndentSize); - var remainder = indentation % options.IndentSize; - if (!internedSpacesIndentation) { - internedSpacesIndentation = []; - } - if (internedSpacesIndentation[quotient] === undefined) { - spacesString = repeat(" ", options.IndentSize * quotient); - internedSpacesIndentation[quotient] = spacesString; - } - else { - spacesString = internedSpacesIndentation[quotient]; - } - return remainder ? spacesString + repeat(" ", remainder) : spacesString; - } - function repeat(value, count) { - var s = ""; - for (var i = 0; i < count; ++i) { - s += value; - } - return s; - } - } - formatting.getIndentationString = getIndentationString; - })(formatting = ts.formatting || (ts.formatting = {})); -})(ts || (ts = {})); -/// -/* @internal */ -var ts; -(function (ts) { - var formatting; - (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 0; // past EOF - } - // no indentation when the indent style is set to none, - // so we can return fast - if (options.IndentStyle === ts.IndentStyle.None) { - return 0; - } - var precedingToken = ts.findPrecedingToken(position, sourceFile); - if (!precedingToken) { - return 0; - } - // no indentation in string \regex\template literals - var precedingTokenIsLiteral = ts.isStringOrRegularExpressionOrTemplateLiteral(precedingToken.kind); - if (precedingTokenIsLiteral && precedingToken.getStart(sourceFile) <= position && precedingToken.end > position) { - return 0; - } - var lineAtPosition = sourceFile.getLineAndCharacterOfPosition(position).line; - // indentation is first non-whitespace character in a previous line - // for block indentation, we should look for a line which contains something that's not - // whitespace. - if (options.IndentStyle === ts.IndentStyle.Block) { - // move backwards until we find a line with a non-whitespace character, - // then find the first non-whitespace character for that line. - var current_1 = position; - while (current_1 > 0) { - var char = sourceFile.text.charCodeAt(current_1); - if (!ts.isWhiteSpace(char) && !ts.isLineBreak(char)) { - break; - } - current_1--; - } - var lineStart = ts.getLineStartPositionForPosition(current_1, sourceFile); - return SmartIndenter.findFirstNonWhitespaceColumn(lineStart, current_1, sourceFile, options); - } - if (precedingToken.kind === 24 /* CommaToken */ && precedingToken.parent.kind !== 181 /* BinaryExpression */) { - // previous token is comma that separates items in list - find the previous item and try to derive indentation from it - var actualIndentation = getActualIndentationForListItemBeforeComma(precedingToken, sourceFile, options); - if (actualIndentation !== -1 /* Unknown */) { - return actualIndentation; - } - } - // try to find node that can contribute to indentation and includes 'position' starting from 'precedingToken' - // if such node is found - compute initial indentation for 'position' inside this node - var previous; - var current = precedingToken; - var currentStart; - var indentationDelta; - while (current) { - if (ts.positionBelongsToNode(current, position, sourceFile) && shouldIndentChildNode(current.kind, previous ? previous.kind : 0 /* Unknown */)) { - currentStart = getStartLineAndCharacterForNode(current, sourceFile); - if (nextTokenIsCurlyBraceOnSameLineAsCursor(precedingToken, current, lineAtPosition, sourceFile)) { - indentationDelta = 0; - } - else { - indentationDelta = lineAtPosition !== currentStart.line ? options.IndentSize : 0; - } - break; - } - // check if current node is a list item - if yes, take indentation from it - var actualIndentation = getActualIndentationForListItem(current, sourceFile, options); - if (actualIndentation !== -1 /* Unknown */) { - return actualIndentation; - } - actualIndentation = getLineIndentationWhenExpressionIsInMultiLine(current, sourceFile, options); - if (actualIndentation !== -1 /* Unknown */) { - return actualIndentation + options.IndentSize; - } - previous = current; - current = current.parent; - } - if (!current) { - // no parent was found - return 0 to be indented on the level of SourceFile - return 0; - } - return getIndentationForNodeWorker(current, currentStart, /*ignoreActualIndentationRange*/ undefined, indentationDelta, sourceFile, options); - } - SmartIndenter.getIndentation = getIndentation; - 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 getIndentationForNodeWorker(current, currentStart, ignoreActualIndentationRange, indentationDelta, sourceFile, options) { - var parent = current.parent; - var parentStart; - // walk upwards and collect indentations for pairs of parent-child nodes - // indentation is not added if parent and child nodes start on the same line or if parent is IfStatement and child starts on the same line with 'else clause' - while (parent) { - var useActualIndentation = true; - if (ignoreActualIndentationRange) { - var start = current.getStart(sourceFile); - useActualIndentation = start < ignoreActualIndentationRange.pos || start > ignoreActualIndentationRange.end; - } - if (useActualIndentation) { - // check if current node is a list item - if yes, take indentation from it - var actualIndentation = getActualIndentationForListItem(current, sourceFile, options); - if (actualIndentation !== -1 /* Unknown */) { - return actualIndentation + indentationDelta; - } - } - parentStart = getParentStart(parent, current, sourceFile); - var parentAndChildShareLine = parentStart.line === currentStart.line || - childStartsOnTheSameLineWithElseInIfStatement(parent, current, currentStart.line, sourceFile); - if (useActualIndentation) { - // try to fetch actual indentation for current node from source text - var actualIndentation = getActualIndentationForNode(current, parent, currentStart, parentAndChildShareLine, sourceFile, options); - if (actualIndentation !== -1 /* Unknown */) { - return actualIndentation + indentationDelta; - } - actualIndentation = getLineIndentationWhenExpressionIsInMultiLine(current, sourceFile, options); - if (actualIndentation !== -1 /* Unknown */) { - return actualIndentation + indentationDelta; - } - } - // 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.kind, current.kind) && !parentAndChildShareLine) { - indentationDelta += options.IndentSize; - } - current = parent; - currentStart = parentStart; - parent = current.parent; - } - return indentationDelta; - } - function getParentStart(parent, child, sourceFile) { - var containingList = getContainingList(child, sourceFile); - if (containingList) { - return sourceFile.getLineAndCharacterOfPosition(containingList.pos); - } - return sourceFile.getLineAndCharacterOfPosition(parent.getStart(sourceFile)); - } - /* - * Function returns Value.Unknown if indentation cannot be determined - */ - function getActualIndentationForListItemBeforeComma(commaToken, sourceFile, options) { - // previous token is comma that separates items in list - find the previous item and try to derive indentation from it - var commaItemInfo = ts.findListItemInfo(commaToken); - if (commaItemInfo && commaItemInfo.listItemIndex > 0) { - return deriveActualIndentationFromList(commaItemInfo.list.getChildren(), commaItemInfo.listItemIndex - 1, sourceFile, options); - } - else { - // handle broken code gracefully - return -1 /* Unknown */; - } - } - /* - * Function returns Value.Unknown if actual indentation for node should not be used (i.e because node is nested expression) - */ - function getActualIndentationForNode(current, parent, currentLineAndChar, parentAndChildShareLine, sourceFile, options) { - // actual indentation is used for statements\declarations if one of cases below is true: - // - parent is SourceFile - by default immediate children of SourceFile are not indented except when user indents them manually - // - parent and child are not on the same line - var useActualIndentation = (ts.isDeclaration(current) || ts.isStatement(current)) && - (parent.kind === 248 /* SourceFile */ || !parentAndChildShareLine); - if (!useActualIndentation) { - return -1 /* Unknown */; - } - return findColumnForFirstNonWhitespaceCharacterInLine(currentLineAndChar, sourceFile, options); - } - function nextTokenIsCurlyBraceOnSameLineAsCursor(precedingToken, current, lineAtPosition, sourceFile) { - var nextToken = ts.findNextToken(precedingToken, current); - if (!nextToken) { - return false; - } - if (nextToken.kind === 15 /* OpenBraceToken */) { - // open braces are always indented at the parent level - return true; - } - else if (nextToken.kind === 16 /* 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 { - // $ - // } - /// and this one - not - // class A { - // $} - var nextTokenStartLine = getStartLineAndCharacterForNode(nextToken, sourceFile).line; - return lineAtPosition === nextTokenStartLine; - } - return false; - } - function getStartLineAndCharacterForNode(n, sourceFile) { - return sourceFile.getLineAndCharacterOfPosition(n.getStart(sourceFile)); - } - function childStartsOnTheSameLineWithElseInIfStatement(parent, child, childStartLine, sourceFile) { - if (parent.kind === 196 /* IfStatement */ && parent.elseStatement === child) { - var elseKeyword = ts.findChildOfKind(parent, 80 /* ElseKeyword */, sourceFile); - ts.Debug.assert(elseKeyword !== undefined); - var elseKeywordStartLine = getStartLineAndCharacterForNode(elseKeyword, sourceFile).line; - return elseKeywordStartLine === childStartLine; - } - return false; - } - SmartIndenter.childStartsOnTheSameLineWithElseInIfStatement = childStartsOnTheSameLineWithElseInIfStatement; - function getContainingList(node, sourceFile) { - if (node.parent) { - switch (node.parent.kind) { - case 151 /* TypeReference */: - if (node.parent.typeArguments && - ts.rangeContainsStartEnd(node.parent.typeArguments, node.getStart(sourceFile), node.getEnd())) { - return node.parent.typeArguments; - } - break; - case 165 /* ObjectLiteralExpression */: - return node.parent.properties; - case 164 /* ArrayLiteralExpression */: - return node.parent.elements; - case 213 /* FunctionDeclaration */: - case 173 /* FunctionExpression */: - case 174 /* ArrowFunction */: - case 143 /* MethodDeclaration */: - case 142 /* MethodSignature */: - case 147 /* CallSignature */: - case 148 /* ConstructSignature */: { - var start = node.getStart(sourceFile); - if (node.parent.typeParameters && - ts.rangeContainsStartEnd(node.parent.typeParameters, start, node.getEnd())) { - return node.parent.typeParameters; - } - if (ts.rangeContainsStartEnd(node.parent.parameters, start, node.getEnd())) { - return node.parent.parameters; - } - break; - } - case 169 /* NewExpression */: - case 168 /* CallExpression */: { - var start = node.getStart(sourceFile); - if (node.parent.typeArguments && - ts.rangeContainsStartEnd(node.parent.typeArguments, start, node.getEnd())) { - return node.parent.typeArguments; - } - if (node.parent.arguments && - ts.rangeContainsStartEnd(node.parent.arguments, start, node.getEnd())) { - return node.parent.arguments; - } - break; - } - } - } - return undefined; - } - function getActualIndentationForListItem(node, sourceFile, options) { - var containingList = getContainingList(node, sourceFile); - return containingList ? getActualIndentationFromList(containingList) : -1 /* Unknown */; - function getActualIndentationFromList(list) { - var index = ts.indexOf(list, node); - return index !== -1 ? deriveActualIndentationFromList(list, index, sourceFile, options) : -1 /* Unknown */; - } - } - 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 */) { - return -1 /* Unknown */; - } - if (node.parent && (node.parent.kind === 168 /* CallExpression */ || - node.parent.kind === 169 /* NewExpression */) && - node.parent.expression !== node) { - var fullCallOrNewExpression = node.parent.expression; - var startingExpression = getStartingExpression(fullCallOrNewExpression); - if (fullCallOrNewExpression === startingExpression) { - return -1 /* Unknown */; - } - var fullCallOrNewExpressionEnd = sourceFile.getLineAndCharacterOfPosition(fullCallOrNewExpression.end); - var startingExpressionEnd = sourceFile.getLineAndCharacterOfPosition(startingExpression.end); - if (fullCallOrNewExpressionEnd.line === startingExpressionEnd.line) { - return -1 /* Unknown */; - } - return findColumnForFirstNonWhitespaceCharacterInLine(fullCallOrNewExpressionEnd, sourceFile, options); - } - return -1 /* Unknown */; - function getStartingExpression(node) { - while (true) { - switch (node.kind) { - case 168 /* CallExpression */: - case 169 /* NewExpression */: - case 166 /* PropertyAccessExpression */: - case 167 /* ElementAccessExpression */: - node = node.expression; - break; - default: - return node; - } - } - return node; - } - } - function deriveActualIndentationFromList(list, index, sourceFile, options) { - ts.Debug.assert(index >= 0 && index < list.length); - var node = list[index]; - // walk toward the start of the list starting from current node and check if the line is the same for all items. - // 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 */) { - continue; - } - // skip list items that ends on the same line with the current list element - var prevEndLine = sourceFile.getLineAndCharacterOfPosition(list[i].end).line; - if (prevEndLine !== lineAndCharacter.line) { - return findColumnForFirstNonWhitespaceCharacterInLine(lineAndCharacter, sourceFile, options); - } - lineAndCharacter = getStartLineAndCharacterForNode(list[i], sourceFile); - } - return -1 /* Unknown */; - } - function findColumnForFirstNonWhitespaceCharacterInLine(lineAndCharacter, sourceFile, options) { - var lineStart = sourceFile.getPositionOfLineAndCharacter(lineAndCharacter.line, 0); - return findFirstNonWhitespaceColumn(lineStart, lineStart + lineAndCharacter.character, sourceFile, options); - } - /* - Character is the actual index of the character since the beginning of the line. - Column - position of the character after expanding tabs to spaces - "0\t2$" - value of 'character' for '$' is 3 - value of 'column' for '$' is 6 (assuming that tab size is 4) - */ - function findFirstNonWhitespaceCharacterAndColumn(startPos, endPos, sourceFile, options) { - var character = 0; - var column = 0; - for (var pos = startPos; pos < endPos; ++pos) { - var ch = sourceFile.text.charCodeAt(pos); - if (!ts.isWhiteSpace(ch)) { - break; - } - if (ch === 9 /* tab */) { - column += options.TabSize + (column % options.TabSize); - } - else { - column++; - } - character++; - } - return { column: column, character: character }; - } - SmartIndenter.findFirstNonWhitespaceCharacterAndColumn = findFirstNonWhitespaceCharacterAndColumn; - function findFirstNonWhitespaceColumn(startPos, endPos, sourceFile, options) { - return findFirstNonWhitespaceCharacterAndColumn(startPos, endPos, sourceFile, options).column; - } - SmartIndenter.findFirstNonWhitespaceColumn = findFirstNonWhitespaceColumn; - function nodeContentIsAlwaysIndented(kind) { - switch (kind) { - case 195 /* ExpressionStatement */: - case 214 /* ClassDeclaration */: - case 186 /* ClassExpression */: - case 215 /* InterfaceDeclaration */: - case 217 /* EnumDeclaration */: - case 216 /* TypeAliasDeclaration */: - case 164 /* ArrayLiteralExpression */: - case 192 /* Block */: - case 219 /* ModuleBlock */: - case 165 /* ObjectLiteralExpression */: - case 155 /* TypeLiteral */: - case 157 /* TupleType */: - case 220 /* CaseBlock */: - case 242 /* DefaultClause */: - case 241 /* CaseClause */: - case 172 /* ParenthesizedExpression */: - case 166 /* PropertyAccessExpression */: - case 168 /* CallExpression */: - case 169 /* NewExpression */: - case 193 /* VariableStatement */: - case 211 /* VariableDeclaration */: - case 227 /* ExportAssignment */: - case 204 /* ReturnStatement */: - case 182 /* ConditionalExpression */: - case 162 /* ArrayBindingPattern */: - case 161 /* ObjectBindingPattern */: - case 233 /* JsxElement */: - case 234 /* JsxSelfClosingElement */: - case 142 /* MethodSignature */: - case 147 /* CallSignature */: - case 148 /* ConstructSignature */: - case 138 /* Parameter */: - case 152 /* FunctionType */: - case 153 /* ConstructorType */: - case 160 /* ParenthesizedType */: - case 170 /* TaggedTemplateExpression */: - case 178 /* AwaitExpression */: - return true; - } - return false; - } - function shouldIndentChildNode(parent, child) { - if (nodeContentIsAlwaysIndented(parent)) { - return true; - } - switch (parent) { - case 197 /* DoStatement */: - case 198 /* WhileStatement */: - case 200 /* ForInStatement */: - case 201 /* ForOfStatement */: - case 199 /* ForStatement */: - case 196 /* IfStatement */: - case 213 /* FunctionDeclaration */: - case 173 /* FunctionExpression */: - case 143 /* MethodDeclaration */: - case 174 /* ArrowFunction */: - case 144 /* Constructor */: - case 145 /* GetAccessor */: - case 146 /* SetAccessor */: - return child !== 192 /* Block */; - default: - return false; - } - } - SmartIndenter.shouldIndentChildNode = shouldIndentChildNode; - })(SmartIndenter = formatting.SmartIndenter || (formatting.SmartIndenter = {})); - })(formatting = ts.formatting || (ts.formatting = {})); -})(ts || (ts = {})); -/// -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 ts; -(function (ts) { - /** The version of the language service API */ - ts.servicesVersion = "0.4"; - var ScriptSnapshot; - (function (ScriptSnapshot) { - var StringScriptSnapshot = (function () { - function StringScriptSnapshot(text) { - this.text = text; - } - StringScriptSnapshot.prototype.getText = function (start, end) { - return this.text.substring(start, end); - }; - StringScriptSnapshot.prototype.getLength = function () { - return this.text.length; - }; - StringScriptSnapshot.prototype.getChangeRange = function (oldSnapshot) { - // Text-based snapshots do not support incremental parsing. Return undefined - // to signal that to the caller. - return undefined; - }; - return StringScriptSnapshot; - })(); - function fromString(text) { - return new StringScriptSnapshot(text); - } - ScriptSnapshot.fromString = fromString; - })(ScriptSnapshot = ts.ScriptSnapshot || (ts.ScriptSnapshot = {})); - var scanner = ts.createScanner(2 /* Latest */, /*skipTrivia*/ true); - var emptyArray = []; - var jsDocTagNames = [ - "augments", - "author", - "argument", - "borrows", - "class", - "constant", - "constructor", - "constructs", - "default", - "deprecated", - "description", - "event", - "example", - "extends", - "field", - "fileOverview", - "function", - "ignore", - "inner", - "lends", - "link", - "memberOf", - "name", - "namespace", - "param", - "private", - "property", - "public", - "requires", - "returns", - "see", - "since", - "static", - "throws", - "type", - "version" - ]; - var jsDocCompletionEntries; - function createNode(kind, pos, end, flags, parent) { - var node = new (ts.getNodeConstructor(kind))(pos, end); - node.flags = flags; - node.parent = parent; - return node; - } - var NodeObject = (function () { - function NodeObject() { - } - NodeObject.prototype.getSourceFile = function () { - return ts.getSourceFileOfNode(this); - }; - NodeObject.prototype.getStart = function (sourceFile) { - return ts.getTokenPosOfNode(this, sourceFile); - }; - NodeObject.prototype.getFullStart = function () { - return this.pos; - }; - NodeObject.prototype.getEnd = function () { - return this.end; - }; - NodeObject.prototype.getWidth = function (sourceFile) { - return this.getEnd() - this.getStart(sourceFile); - }; - NodeObject.prototype.getFullWidth = function () { - return this.end - this.pos; - }; - NodeObject.prototype.getLeadingTriviaWidth = function (sourceFile) { - return this.getStart(sourceFile) - this.pos; - }; - NodeObject.prototype.getFullText = function (sourceFile) { - return (sourceFile || this.getSourceFile()).text.substring(this.pos, this.end); - }; - NodeObject.prototype.getText = function (sourceFile) { - return (sourceFile || this.getSourceFile()).text.substring(this.getStart(), this.getEnd()); - }; - NodeObject.prototype.addSyntheticNodes = function (nodes, pos, end) { - scanner.setTextPos(pos); - while (pos < end) { - var token = scanner.scan(); - var textPos = scanner.getTextPos(); - nodes.push(createNode(token, pos, textPos, 4096 /* Synthetic */, this)); - pos = textPos; - } - return pos; - }; - NodeObject.prototype.createSyntaxList = function (nodes) { - var list = createNode(271 /* SyntaxList */, nodes.pos, nodes.end, 4096 /* Synthetic */, this); - list._children = []; - var pos = nodes.pos; - for (var _i = 0; _i < nodes.length; _i++) { - var node = nodes[_i]; - if (pos < node.pos) { - pos = this.addSyntheticNodes(list._children, pos, node.pos); - } - list._children.push(node); - pos = node.end; - } - if (pos < nodes.end) { - this.addSyntheticNodes(list._children, pos, nodes.end); - } - return list; - }; - NodeObject.prototype.createChildren = function (sourceFile) { - var _this = this; - var children; - if (this.kind >= 135 /* FirstNode */) { - scanner.setText((sourceFile || this.getSourceFile()).text); - children = []; - var pos = this.pos; - var processNode = function (node) { - if (pos < node.pos) { - pos = _this.addSyntheticNodes(children, pos, node.pos); - } - children.push(node); - pos = node.end; - }; - var processNodes = function (nodes) { - if (pos < nodes.pos) { - pos = _this.addSyntheticNodes(children, pos, nodes.pos); - } - children.push(_this.createSyntaxList(nodes)); - pos = nodes.end; - }; - ts.forEachChild(this, processNode, processNodes); - if (pos < this.end) { - this.addSyntheticNodes(children, pos, this.end); - } - scanner.setText(undefined); - } - this._children = children || emptyArray; - }; - NodeObject.prototype.getChildCount = function (sourceFile) { - if (!this._children) - this.createChildren(sourceFile); - return this._children.length; - }; - NodeObject.prototype.getChildAt = function (index, sourceFile) { - if (!this._children) - this.createChildren(sourceFile); - return this._children[index]; - }; - NodeObject.prototype.getChildren = function (sourceFile) { - if (!this._children) - this.createChildren(sourceFile); - return this._children; - }; - NodeObject.prototype.getFirstToken = function (sourceFile) { - var children = this.getChildren(sourceFile); - if (!children.length) { - return undefined; - } - var child = children[0]; - return child.kind < 135 /* FirstNode */ ? child : child.getFirstToken(sourceFile); - }; - NodeObject.prototype.getLastToken = function (sourceFile) { - var children = this.getChildren(sourceFile); - var child = ts.lastOrUndefined(children); - if (!child) { - return undefined; - } - return child.kind < 135 /* FirstNode */ ? child : child.getLastToken(sourceFile); - }; - return NodeObject; - })(); - var SymbolObject = (function () { - function SymbolObject(flags, name) { - this.flags = flags; - this.name = name; - } - SymbolObject.prototype.getFlags = function () { - return this.flags; - }; - SymbolObject.prototype.getName = function () { - return this.name; - }; - SymbolObject.prototype.getDeclarations = function () { - return this.declarations; - }; - SymbolObject.prototype.getDocumentationComment = function () { - if (this.documentationComment === undefined) { - this.documentationComment = getJsDocCommentsFromDeclarations(this.declarations, this.name, !(this.flags & 4 /* Property */)); - } - return this.documentationComment; - }; - return SymbolObject; - })(); - function getJsDocCommentsFromDeclarations(declarations, name, canUseParsedParamTagComments) { - var documentationComment = []; - var docComments = getJsDocCommentsSeparatedByNewLines(); - ts.forEach(docComments, function (docComment) { - if (documentationComment.length) { - documentationComment.push(ts.lineBreakPart()); - } - documentationComment.push(docComment); - }); - return documentationComment; - function getJsDocCommentsSeparatedByNewLines() { - var paramTag = "@param"; - var jsDocCommentParts = []; - ts.forEach(declarations, function (declaration, indexOfDeclaration) { - // Make sure we are collecting doc comment from declaration once, - // In case of union property there might be same declaration multiple times - // which only varies in type parameter - // Eg. let a: Array | Array; a.length - // The property length will have two declarations of property length coming - // from Array - Array and Array - if (ts.indexOf(declarations, declaration) === indexOfDeclaration) { - var sourceFileOfDeclaration = ts.getSourceFileOfNode(declaration); - // If it is parameter - try and get the jsDoc comment with @param tag from function declaration's jsDoc comments - if (canUseParsedParamTagComments && declaration.kind === 138 /* Parameter */) { - ts.forEach(getJsDocCommentTextRange(declaration.parent, sourceFileOfDeclaration), function (jsDocCommentTextRange) { - var cleanedParamJsDocComment = getCleanedParamJsDocComment(jsDocCommentTextRange.pos, jsDocCommentTextRange.end, sourceFileOfDeclaration); - if (cleanedParamJsDocComment) { - ts.addRange(jsDocCommentParts, cleanedParamJsDocComment); - } - }); - } - // If this is left side of dotted module declaration, there is no doc comments associated with this node - if (declaration.kind === 218 /* ModuleDeclaration */ && declaration.body.kind === 218 /* ModuleDeclaration */) { - return; - } - // If this is dotted module name, get the doc comments from the parent - while (declaration.kind === 218 /* ModuleDeclaration */ && declaration.parent.kind === 218 /* ModuleDeclaration */) { - declaration = declaration.parent; - } - // Get the cleaned js doc comment text from the declaration - ts.forEach(getJsDocCommentTextRange(declaration.kind === 211 /* VariableDeclaration */ ? declaration.parent.parent : declaration, sourceFileOfDeclaration), function (jsDocCommentTextRange) { - var cleanedJsDocComment = getCleanedJsDocComment(jsDocCommentTextRange.pos, jsDocCommentTextRange.end, sourceFileOfDeclaration); - if (cleanedJsDocComment) { - ts.addRange(jsDocCommentParts, cleanedJsDocComment); - } - }); - } - }); - return jsDocCommentParts; - function getJsDocCommentTextRange(node, sourceFile) { - return ts.map(ts.getJsDocComments(node, sourceFile), function (jsDocComment) { - return { - pos: jsDocComment.pos + "/*".length, - end: jsDocComment.end - "*/".length // Trim off comment end indicator - }; - }); - } - function consumeWhiteSpacesOnTheLine(pos, end, sourceFile, maxSpacesToRemove) { - if (maxSpacesToRemove !== undefined) { - end = Math.min(end, pos + maxSpacesToRemove); - } - for (; pos < end; pos++) { - var ch = sourceFile.text.charCodeAt(pos); - if (!ts.isWhiteSpace(ch) || ts.isLineBreak(ch)) { - // Either found lineBreak or non whiteSpace - return pos; - } - } - return end; - } - function consumeLineBreaks(pos, end, sourceFile) { - while (pos < end && ts.isLineBreak(sourceFile.text.charCodeAt(pos))) { - pos++; - } - return pos; - } - function isName(pos, end, sourceFile, name) { - return pos + name.length < end && - sourceFile.text.substr(pos, name.length) === name && - (ts.isWhiteSpace(sourceFile.text.charCodeAt(pos + name.length)) || - ts.isLineBreak(sourceFile.text.charCodeAt(pos + name.length))); - } - function isParamTag(pos, end, sourceFile) { - // If it is @param tag - return isName(pos, end, sourceFile, paramTag); - } - function pushDocCommentLineText(docComments, text, blankLineCount) { - // Add the empty lines in between texts - while (blankLineCount--) { - docComments.push(ts.textPart("")); - } - docComments.push(ts.textPart(text)); - } - function getCleanedJsDocComment(pos, end, sourceFile) { - var spacesToRemoveAfterAsterisk; - var docComments = []; - var blankLineCount = 0; - var isInParamTag = false; - while (pos < end) { - var docCommentTextOfLine = ""; - // First consume leading white space - pos = consumeWhiteSpacesOnTheLine(pos, end, sourceFile); - // If the comment starts with '*' consume the spaces on this line - if (pos < end && sourceFile.text.charCodeAt(pos) === 42 /* asterisk */) { - var lineStartPos = pos + 1; - pos = consumeWhiteSpacesOnTheLine(pos + 1, end, sourceFile, spacesToRemoveAfterAsterisk); - // Set the spaces to remove after asterisk as margin if not already set - if (spacesToRemoveAfterAsterisk === undefined && pos < end && !ts.isLineBreak(sourceFile.text.charCodeAt(pos))) { - spacesToRemoveAfterAsterisk = pos - lineStartPos; - } - } - else if (spacesToRemoveAfterAsterisk === undefined) { - spacesToRemoveAfterAsterisk = 0; - } - // Analyse text on this line - while (pos < end && !ts.isLineBreak(sourceFile.text.charCodeAt(pos))) { - var ch = sourceFile.text.charAt(pos); - if (ch === "@") { - // If it is @param tag - if (isParamTag(pos, end, sourceFile)) { - isInParamTag = true; - pos += paramTag.length; - continue; - } - else { - isInParamTag = false; - } - } - // Add the ch to doc text if we arent in param tag - if (!isInParamTag) { - docCommentTextOfLine += ch; - } - // Scan next character - pos++; - } - // Continue with next line - pos = consumeLineBreaks(pos, end, sourceFile); - if (docCommentTextOfLine) { - pushDocCommentLineText(docComments, docCommentTextOfLine, blankLineCount); - blankLineCount = 0; - } - else if (!isInParamTag && docComments.length) { - // This is blank line when there is text already parsed - blankLineCount++; - } - } - return docComments; - } - function getCleanedParamJsDocComment(pos, end, sourceFile) { - var paramHelpStringMargin; - var paramDocComments = []; - while (pos < end) { - if (isParamTag(pos, end, sourceFile)) { - var blankLineCount = 0; - var recordedParamTag = false; - // Consume leading spaces - pos = consumeWhiteSpaces(pos + paramTag.length); - if (pos >= end) { - break; - } - // Ignore type expression - if (sourceFile.text.charCodeAt(pos) === 123 /* openBrace */) { - pos++; - for (var curlies = 1; pos < end; pos++) { - var charCode = sourceFile.text.charCodeAt(pos); - // { character means we need to find another } to match the found one - if (charCode === 123 /* openBrace */) { - curlies++; - continue; - } - // } char - if (charCode === 125 /* closeBrace */) { - curlies--; - if (curlies === 0) { - // We do not have any more } to match the type expression is ignored completely - pos++; - break; - } - else { - // there are more { to be matched with } - continue; - } - } - // Found start of another tag - if (charCode === 64 /* at */) { - break; - } - } - // Consume white spaces - pos = consumeWhiteSpaces(pos); - if (pos >= end) { - break; - } - } - // Parameter name - if (isName(pos, end, sourceFile, name)) { - // Found the parameter we are looking for consume white spaces - pos = consumeWhiteSpaces(pos + name.length); - if (pos >= end) { - break; - } - var paramHelpString = ""; - var firstLineParamHelpStringPos = pos; - while (pos < end) { - var ch = sourceFile.text.charCodeAt(pos); - // at line break, set this comment line text and go to next line - if (ts.isLineBreak(ch)) { - if (paramHelpString) { - pushDocCommentLineText(paramDocComments, paramHelpString, blankLineCount); - paramHelpString = ""; - blankLineCount = 0; - recordedParamTag = true; - } - else if (recordedParamTag) { - blankLineCount++; - } - // Get the pos after cleaning start of the line - setPosForParamHelpStringOnNextLine(firstLineParamHelpStringPos); - continue; - } - // Done scanning param help string - next tag found - if (ch === 64 /* at */) { - break; - } - paramHelpString += sourceFile.text.charAt(pos); - // Go to next character - pos++; - } - // If there is param help text, add it top the doc comments - if (paramHelpString) { - pushDocCommentLineText(paramDocComments, paramHelpString, blankLineCount); - } - paramHelpStringMargin = undefined; - } - // If this is the start of another tag, continue with the loop in seach of param tag with symbol name - if (sourceFile.text.charCodeAt(pos) === 64 /* at */) { - continue; - } - } - // Next character - pos++; - } - return paramDocComments; - function consumeWhiteSpaces(pos) { - while (pos < end && ts.isWhiteSpace(sourceFile.text.charCodeAt(pos))) { - pos++; - } - return pos; - } - function setPosForParamHelpStringOnNextLine(firstLineParamHelpStringPos) { - // Get the pos after consuming line breaks - pos = consumeLineBreaks(pos, end, sourceFile); - if (pos >= end) { - return; - } - if (paramHelpStringMargin === undefined) { - paramHelpStringMargin = sourceFile.getLineAndCharacterOfPosition(firstLineParamHelpStringPos).character; - } - // Now consume white spaces max - var startOfLinePos = pos; - pos = consumeWhiteSpacesOnTheLine(pos, end, sourceFile, paramHelpStringMargin); - if (pos >= end) { - return; - } - var consumedSpaces = pos - startOfLinePos; - if (consumedSpaces < paramHelpStringMargin) { - var ch = sourceFile.text.charCodeAt(pos); - if (ch === 42 /* asterisk */) { - // Consume more spaces after asterisk - pos = consumeWhiteSpacesOnTheLine(pos + 1, end, sourceFile, paramHelpStringMargin - consumedSpaces - 1); - } - } - } - } - } - } - var TypeObject = (function () { - function TypeObject(checker, flags) { - this.checker = checker; - this.flags = flags; - } - TypeObject.prototype.getFlags = function () { - return this.flags; - }; - TypeObject.prototype.getSymbol = function () { - return this.symbol; - }; - TypeObject.prototype.getProperties = function () { - return this.checker.getPropertiesOfType(this); - }; - TypeObject.prototype.getProperty = function (propertyName) { - return this.checker.getPropertyOfType(this, propertyName); - }; - TypeObject.prototype.getApparentProperties = function () { - return this.checker.getAugmentedPropertiesOfType(this); - }; - TypeObject.prototype.getCallSignatures = function () { - return this.checker.getSignaturesOfType(this, 0 /* Call */); - }; - TypeObject.prototype.getConstructSignatures = function () { - return this.checker.getSignaturesOfType(this, 1 /* Construct */); - }; - TypeObject.prototype.getStringIndexType = function () { - return this.checker.getIndexTypeOfType(this, 0 /* String */); - }; - TypeObject.prototype.getNumberIndexType = function () { - return this.checker.getIndexTypeOfType(this, 1 /* Number */); - }; - TypeObject.prototype.getBaseTypes = function () { - return this.flags & (1024 /* Class */ | 2048 /* Interface */) - ? this.checker.getBaseTypes(this) - : undefined; - }; - return TypeObject; - })(); - var SignatureObject = (function () { - function SignatureObject(checker) { - this.checker = checker; - } - SignatureObject.prototype.getDeclaration = function () { - return this.declaration; - }; - SignatureObject.prototype.getTypeParameters = function () { - return this.typeParameters; - }; - SignatureObject.prototype.getParameters = function () { - return this.parameters; - }; - SignatureObject.prototype.getReturnType = function () { - return this.checker.getReturnTypeOfSignature(this); - }; - SignatureObject.prototype.getDocumentationComment = function () { - if (this.documentationComment === undefined) { - this.documentationComment = this.declaration ? getJsDocCommentsFromDeclarations([this.declaration], - /*name*/ undefined, - /*canUseParsedParamTagComments*/ false) : []; - } - return this.documentationComment; - }; - return SignatureObject; - })(); - var SourceFileObject = (function (_super) { - __extends(SourceFileObject, _super); - function SourceFileObject() { - _super.apply(this, arguments); - } - SourceFileObject.prototype.update = function (newText, textChangeRange) { - return ts.updateSourceFile(this, newText, textChangeRange); - }; - SourceFileObject.prototype.getLineAndCharacterOfPosition = function (position) { - return ts.getLineAndCharacterOfPosition(this, position); - }; - SourceFileObject.prototype.getLineStarts = function () { - return ts.getLineStarts(this); - }; - SourceFileObject.prototype.getPositionOfLineAndCharacter = function (line, character) { - return ts.getPositionOfLineAndCharacter(this, line, character); - }; - SourceFileObject.prototype.getNamedDeclarations = function () { - if (!this.namedDeclarations) { - this.namedDeclarations = this.computeNamedDeclarations(); - } - return this.namedDeclarations; - }; - SourceFileObject.prototype.computeNamedDeclarations = function () { - var result = {}; - ts.forEachChild(this, visit); - return result; - function addDeclaration(declaration) { - var name = getDeclarationName(declaration); - if (name) { - var declarations = getDeclarations(name); - declarations.push(declaration); - } - } - function getDeclarations(name) { - return ts.getProperty(result, name) || (result[name] = []); - } - function getDeclarationName(declaration) { - if (declaration.name) { - var result_2 = getTextOfIdentifierOrLiteral(declaration.name); - if (result_2 !== undefined) { - return result_2; - } - if (declaration.name.kind === 136 /* ComputedPropertyName */) { - var expr = declaration.name.expression; - if (expr.kind === 166 /* PropertyAccessExpression */) { - return expr.name.text; - } - return getTextOfIdentifierOrLiteral(expr); - } - } - return undefined; - } - function getTextOfIdentifierOrLiteral(node) { - if (node) { - if (node.kind === 69 /* Identifier */ || - node.kind === 9 /* StringLiteral */ || - node.kind === 8 /* NumericLiteral */) { - return node.text; - } - } - return undefined; - } - function visit(node) { - switch (node.kind) { - case 213 /* FunctionDeclaration */: - case 143 /* MethodDeclaration */: - case 142 /* MethodSignature */: - var functionDeclaration = node; - var declarationName = getDeclarationName(functionDeclaration); - if (declarationName) { - var declarations = getDeclarations(declarationName); - var lastDeclaration = ts.lastOrUndefined(declarations); - // Check whether this declaration belongs to an "overload group". - if (lastDeclaration && functionDeclaration.parent === lastDeclaration.parent && functionDeclaration.symbol === lastDeclaration.symbol) { - // Overwrite the last declaration if it was an overload - // and this one is an implementation. - if (functionDeclaration.body && !lastDeclaration.body) { - declarations[declarations.length - 1] = functionDeclaration; - } - } - else { - declarations.push(functionDeclaration); - } - ts.forEachChild(node, visit); - } - break; - case 214 /* ClassDeclaration */: - case 215 /* InterfaceDeclaration */: - case 216 /* TypeAliasDeclaration */: - case 217 /* EnumDeclaration */: - case 218 /* ModuleDeclaration */: - case 221 /* ImportEqualsDeclaration */: - case 230 /* ExportSpecifier */: - case 226 /* ImportSpecifier */: - case 221 /* ImportEqualsDeclaration */: - case 223 /* ImportClause */: - case 224 /* NamespaceImport */: - case 145 /* GetAccessor */: - case 146 /* SetAccessor */: - case 155 /* TypeLiteral */: - addDeclaration(node); - // fall through - case 144 /* Constructor */: - case 193 /* VariableStatement */: - case 212 /* VariableDeclarationList */: - case 161 /* ObjectBindingPattern */: - case 162 /* ArrayBindingPattern */: - case 219 /* ModuleBlock */: - ts.forEachChild(node, visit); - break; - case 192 /* Block */: - if (ts.isFunctionBlock(node)) { - ts.forEachChild(node, visit); - } - break; - case 138 /* Parameter */: - // Only consider properties defined as constructor parameters - if (!(node.flags & 112 /* AccessibilityModifier */)) { - break; - } - // fall through - case 211 /* VariableDeclaration */: - case 163 /* BindingElement */: - if (ts.isBindingPattern(node.name)) { - ts.forEachChild(node.name, visit); - break; - } - case 247 /* EnumMember */: - case 141 /* PropertyDeclaration */: - case 140 /* PropertySignature */: - addDeclaration(node); - break; - case 228 /* ExportDeclaration */: - // Handle named exports case e.g.: - // export {a, b as B} from "mod"; - if (node.exportClause) { - ts.forEach(node.exportClause.elements, visit); - } - break; - case 222 /* ImportDeclaration */: - var importClause = node.importClause; - if (importClause) { - // Handle default import case e.g.: - // import d from "mod"; - if (importClause.name) { - addDeclaration(importClause); - } - // Handle named bindings in imports e.g.: - // import * as NS from "mod"; - // import {a, b as B} from "mod"; - if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 224 /* NamespaceImport */) { - addDeclaration(importClause.namedBindings); - } - else { - ts.forEach(importClause.namedBindings.elements, visit); - } - } - } - break; - } - } - }; - return SourceFileObject; - })(NodeObject); - var TextChange = (function () { - function TextChange() { - } - return TextChange; - })(); - ts.TextChange = TextChange; - var HighlightSpanKind; - (function (HighlightSpanKind) { - HighlightSpanKind.none = "none"; - HighlightSpanKind.definition = "definition"; - HighlightSpanKind.reference = "reference"; - HighlightSpanKind.writtenReference = "writtenReference"; - })(HighlightSpanKind = ts.HighlightSpanKind || (ts.HighlightSpanKind = {})); - (function (IndentStyle) { - IndentStyle[IndentStyle["None"] = 0] = "None"; - IndentStyle[IndentStyle["Block"] = 1] = "Block"; - IndentStyle[IndentStyle["Smart"] = 2] = "Smart"; - })(ts.IndentStyle || (ts.IndentStyle = {})); - var IndentStyle = ts.IndentStyle; - (function (SymbolDisplayPartKind) { - SymbolDisplayPartKind[SymbolDisplayPartKind["aliasName"] = 0] = "aliasName"; - SymbolDisplayPartKind[SymbolDisplayPartKind["className"] = 1] = "className"; - SymbolDisplayPartKind[SymbolDisplayPartKind["enumName"] = 2] = "enumName"; - SymbolDisplayPartKind[SymbolDisplayPartKind["fieldName"] = 3] = "fieldName"; - SymbolDisplayPartKind[SymbolDisplayPartKind["interfaceName"] = 4] = "interfaceName"; - SymbolDisplayPartKind[SymbolDisplayPartKind["keyword"] = 5] = "keyword"; - SymbolDisplayPartKind[SymbolDisplayPartKind["lineBreak"] = 6] = "lineBreak"; - SymbolDisplayPartKind[SymbolDisplayPartKind["numericLiteral"] = 7] = "numericLiteral"; - SymbolDisplayPartKind[SymbolDisplayPartKind["stringLiteral"] = 8] = "stringLiteral"; - SymbolDisplayPartKind[SymbolDisplayPartKind["localName"] = 9] = "localName"; - SymbolDisplayPartKind[SymbolDisplayPartKind["methodName"] = 10] = "methodName"; - SymbolDisplayPartKind[SymbolDisplayPartKind["moduleName"] = 11] = "moduleName"; - SymbolDisplayPartKind[SymbolDisplayPartKind["operator"] = 12] = "operator"; - SymbolDisplayPartKind[SymbolDisplayPartKind["parameterName"] = 13] = "parameterName"; - SymbolDisplayPartKind[SymbolDisplayPartKind["propertyName"] = 14] = "propertyName"; - SymbolDisplayPartKind[SymbolDisplayPartKind["punctuation"] = 15] = "punctuation"; - SymbolDisplayPartKind[SymbolDisplayPartKind["space"] = 16] = "space"; - SymbolDisplayPartKind[SymbolDisplayPartKind["text"] = 17] = "text"; - SymbolDisplayPartKind[SymbolDisplayPartKind["typeParameterName"] = 18] = "typeParameterName"; - SymbolDisplayPartKind[SymbolDisplayPartKind["enumMemberName"] = 19] = "enumMemberName"; - SymbolDisplayPartKind[SymbolDisplayPartKind["functionName"] = 20] = "functionName"; - 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"; - TokenClass[TokenClass["Operator"] = 2] = "Operator"; - TokenClass[TokenClass["Comment"] = 3] = "Comment"; - TokenClass[TokenClass["Whitespace"] = 4] = "Whitespace"; - TokenClass[TokenClass["Identifier"] = 5] = "Identifier"; - TokenClass[TokenClass["NumberLiteral"] = 6] = "NumberLiteral"; - TokenClass[TokenClass["StringLiteral"] = 7] = "StringLiteral"; - TokenClass[TokenClass["RegExpLiteral"] = 8] = "RegExpLiteral"; - })(ts.TokenClass || (ts.TokenClass = {})); - var TokenClass = ts.TokenClass; - // TODO: move these to enums - var ScriptElementKind; - (function (ScriptElementKind) { - ScriptElementKind.unknown = ""; - ScriptElementKind.warning = "warning"; - // predefined type (void) or keyword (class) - ScriptElementKind.keyword = "keyword"; - // top level script node - ScriptElementKind.scriptElement = "script"; - // module foo {} - ScriptElementKind.moduleElement = "module"; - // class X {} - ScriptElementKind.classElement = "class"; - // var x = class X {} - ScriptElementKind.localClassElement = "local class"; - // interface Y {} - ScriptElementKind.interfaceElement = "interface"; - // type T = ... - ScriptElementKind.typeElement = "type"; - // enum E - ScriptElementKind.enumElement = "enum"; - // Inside module and script only - // let v = .. - ScriptElementKind.variableElement = "var"; - // Inside function - ScriptElementKind.localVariableElement = "local var"; - // Inside module and script only - // function f() { } - ScriptElementKind.functionElement = "function"; - // Inside function - ScriptElementKind.localFunctionElement = "local function"; - // class X { [public|private]* foo() {} } - ScriptElementKind.memberFunctionElement = "method"; - // class X { [public|private]* [get|set] foo:number; } - ScriptElementKind.memberGetAccessorElement = "getter"; - ScriptElementKind.memberSetAccessorElement = "setter"; - // class X { [public|private]* foo:number; } - // interface Y { foo:number; } - ScriptElementKind.memberVariableElement = "property"; - // class X { constructor() { } } - ScriptElementKind.constructorImplementationElement = "constructor"; - // interface Y { ():number; } - ScriptElementKind.callSignatureElement = "call"; - // interface Y { []:number; } - ScriptElementKind.indexSignatureElement = "index"; - // interface Y { new():Y; } - ScriptElementKind.constructSignatureElement = "construct"; - // function foo(*Y*: string) - ScriptElementKind.parameterElement = "parameter"; - ScriptElementKind.typeParameterElement = "type parameter"; - ScriptElementKind.primitiveType = "primitive type"; - ScriptElementKind.label = "label"; - ScriptElementKind.alias = "alias"; - ScriptElementKind.constElement = "const"; - ScriptElementKind.letElement = "let"; - })(ScriptElementKind = ts.ScriptElementKind || (ts.ScriptElementKind = {})); - var ScriptElementKindModifier; - (function (ScriptElementKindModifier) { - ScriptElementKindModifier.none = ""; - ScriptElementKindModifier.publicMemberModifier = "public"; - ScriptElementKindModifier.privateMemberModifier = "private"; - ScriptElementKindModifier.protectedMemberModifier = "protected"; - ScriptElementKindModifier.exportedModifier = "export"; - ScriptElementKindModifier.ambientModifier = "declare"; - ScriptElementKindModifier.staticModifier = "static"; - ScriptElementKindModifier.abstractModifier = "abstract"; - })(ScriptElementKindModifier = ts.ScriptElementKindModifier || (ts.ScriptElementKindModifier = {})); - var ClassificationTypeNames = (function () { - function ClassificationTypeNames() { - } - ClassificationTypeNames.comment = "comment"; - ClassificationTypeNames.identifier = "identifier"; - ClassificationTypeNames.keyword = "keyword"; - ClassificationTypeNames.numericLiteral = "number"; - ClassificationTypeNames.operator = "operator"; - ClassificationTypeNames.stringLiteral = "string"; - ClassificationTypeNames.whiteSpace = "whitespace"; - ClassificationTypeNames.text = "text"; - ClassificationTypeNames.punctuation = "punctuation"; - ClassificationTypeNames.className = "class name"; - ClassificationTypeNames.enumName = "enum name"; - ClassificationTypeNames.interfaceName = "interface name"; - ClassificationTypeNames.moduleName = "module name"; - ClassificationTypeNames.typeParameterName = "type parameter name"; - ClassificationTypeNames.typeAliasName = "type alias name"; - ClassificationTypeNames.parameterName = "parameter name"; - ClassificationTypeNames.docCommentTagName = "doc comment tag name"; - return ClassificationTypeNames; - })(); - 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"; - })(ts.ClassificationType || (ts.ClassificationType = {})); - var ClassificationType = ts.ClassificationType; - function displayPartsToString(displayParts) { - if (displayParts) { - return ts.map(displayParts, function (displayPart) { return displayPart.text; }).join(""); - } - return ""; - } - ts.displayPartsToString = displayPartsToString; - function isLocalVariableOrFunction(symbol) { - if (symbol.parent) { - return false; // This is exported symbol - } - return ts.forEach(symbol.declarations, function (declaration) { - // Function expressions are local - if (declaration.kind === 173 /* FunctionExpression */) { - return true; - } - if (declaration.kind !== 211 /* VariableDeclaration */ && declaration.kind !== 213 /* FunctionDeclaration */) { - return false; - } - // If the parent is not sourceFile or module block it is local variable - for (var parent_8 = declaration.parent; !ts.isFunctionBlock(parent_8); parent_8 = parent_8.parent) { - // Reached source file or module block - if (parent_8.kind === 248 /* SourceFile */ || parent_8.kind === 219 /* ModuleBlock */) { - return false; - } - } - // parent is in function block - return true; - }); - } - function getDefaultCompilerOptions() { - // Always default to "ScriptTarget.ES5" for the language service - return { - target: 1 /* ES5 */, - module: 0 /* None */, - jsx: 1 /* Preserve */ - }; - } - ts.getDefaultCompilerOptions = getDefaultCompilerOptions; - // Cache host information about scrip Should be refreshed - // at each language service public entry point, since we don't know when - // set of scripts handled by the host changes. - var HostCache = (function () { - function HostCache(host, getCanonicalFileName) { - this.host = host; - // script id => script index - this.fileNameToEntry = ts.createFileMap(getCanonicalFileName); - // Initialize the list with the root file names - var rootFileNames = host.getScriptFileNames(); - for (var _i = 0; _i < rootFileNames.length; _i++) { - var fileName = rootFileNames[_i]; - this.createEntry(fileName); - } - // store the compilation settings - this._compilationSettings = host.getCompilationSettings() || getDefaultCompilerOptions(); - } - HostCache.prototype.compilationSettings = function () { - return this._compilationSettings; - }; - HostCache.prototype.createEntry = function (fileName) { - var entry; - var scriptSnapshot = this.host.getScriptSnapshot(fileName); - if (scriptSnapshot) { - entry = { - hostFileName: fileName, - version: this.host.getScriptVersion(fileName), - scriptSnapshot: scriptSnapshot - }; - } - this.fileNameToEntry.set(fileName, entry); - return entry; - }; - HostCache.prototype.getEntry = function (fileName) { - return this.fileNameToEntry.get(fileName); - }; - HostCache.prototype.contains = function (fileName) { - return this.fileNameToEntry.contains(fileName); - }; - HostCache.prototype.getOrCreateEntry = function (fileName) { - if (this.contains(fileName)) { - return this.getEntry(fileName); - } - return this.createEntry(fileName); - }; - HostCache.prototype.getRootFileNames = function () { - var fileNames = []; - this.fileNameToEntry.forEachValue(function (value) { - if (value) { - fileNames.push(value.hostFileName); - } - }); - return fileNames; - }; - HostCache.prototype.getVersion = function (fileName) { - var file = this.getEntry(fileName); - return file && file.version; - }; - HostCache.prototype.getScriptSnapshot = function (fileName) { - var file = this.getEntry(fileName); - return file && file.scriptSnapshot; - }; - return HostCache; - })(); - var SyntaxTreeCache = (function () { - function SyntaxTreeCache(host) { - this.host = host; - } - SyntaxTreeCache.prototype.getCurrentSourceFile = function (fileName) { - var scriptSnapshot = this.host.getScriptSnapshot(fileName); - if (!scriptSnapshot) { - // The host does not know about this file. - throw new Error("Could not find file: '" + fileName + "'."); - } - var version = this.host.getScriptVersion(fileName); - var sourceFile; - if (this.currentFileName !== fileName) { - // This is a new file, just parse it - sourceFile = createLanguageServiceSourceFile(fileName, scriptSnapshot, 2 /* Latest */, version, /*setNodeParents:*/ true); - } - else if (this.currentFileVersion !== version) { - // This is the same file, just a newer version. Incrementally parse the file. - var editRange = scriptSnapshot.getChangeRange(this.currentFileScriptSnapshot); - sourceFile = updateLanguageServiceSourceFile(this.currentSourceFile, scriptSnapshot, version, editRange); - } - if (sourceFile) { - // All done, ensure state is up to date - this.currentFileVersion = version; - this.currentFileName = fileName; - this.currentFileScriptSnapshot = scriptSnapshot; - this.currentSourceFile = sourceFile; - } - return this.currentSourceFile; - }; - return SyntaxTreeCache; - })(); - function setSourceFileFields(sourceFile, scriptSnapshot, version) { - sourceFile.version = version; - sourceFile.scriptSnapshot = scriptSnapshot; - } - /* - * This function will compile source text from 'input' argument using specified compiler options. - * If not options are provided - it will use a set of default compiler options. - * Extra compiler options that will unconditionally be used by this function are: - * - isolatedModules = true - * - allowNonTsExtensions = true - * - noLib = true - * - noResolve = true - */ - function transpileModule(input, transpileOptions) { - var options = transpileOptions.compilerOptions ? ts.clone(transpileOptions.compilerOptions) : getDefaultCompilerOptions(); - options.isolatedModules = true; - // Filename can be non-ts file. - options.allowNonTsExtensions = true; - // We are not returning a sourceFile for lib file when asked by the program, - // so pass --noLib to avoid reporting a file not found error. - options.noLib = true; - // We are not doing a full typecheck, we are not resolving the whole context, - // so pass --noResolve to avoid reporting missing file errors. - options.noResolve = true; - // if jsx is specified then treat file as .tsx - var inputFileName = transpileOptions.fileName || (options.jsx ? "module.tsx" : "module.ts"); - var sourceFile = ts.createSourceFile(inputFileName, input, options.target); - if (transpileOptions.moduleName) { - sourceFile.moduleName = transpileOptions.moduleName; - } - sourceFile.renamedDependencies = transpileOptions.renamedDependencies; - var newLine = ts.getNewLineCharacter(options); - // Output - var outputText; - var sourceMapText; - // Create a compilerHost object to allow the compiler to read and write files - var compilerHost = { - getSourceFile: function (fileName, target) { return fileName === ts.normalizeSlashes(inputFileName) ? sourceFile : undefined; }, - writeFile: function (name, text, writeByteOrderMark) { - if (ts.fileExtensionIs(name, ".map")) { - ts.Debug.assert(sourceMapText === undefined, "Unexpected multiple source map outputs for the file '" + name + "'"); - sourceMapText = text; - } - else { - ts.Debug.assert(outputText === undefined, "Unexpected multiple outputs for the file: " + name); - outputText = text; - } - }, - getDefaultLibFileName: function () { return "lib.d.ts"; }, - useCaseSensitiveFileNames: function () { return false; }, - getCanonicalFileName: function (fileName) { return fileName; }, - getCurrentDirectory: function () { return ""; }, - getNewLine: function () { return newLine; }, - fileExists: function (fileName) { return fileName === inputFileName; }, - readFile: function (fileName) { return ""; } - }; - var program = ts.createProgram([inputFileName], options, compilerHost); - var diagnostics; - if (transpileOptions.reportDiagnostics) { - diagnostics = []; - ts.addRange(/*to*/ diagnostics, /*from*/ program.getSyntacticDiagnostics(sourceFile)); - ts.addRange(/*to*/ diagnostics, /*from*/ program.getOptionsDiagnostics()); - } - // Emit - program.emit(); - ts.Debug.assert(outputText !== undefined, "Output generation failed"); - return { outputText: outputText, diagnostics: diagnostics, sourceMapText: sourceMapText }; - } - ts.transpileModule = transpileModule; - /* - * This is a shortcut function for transpileModule - it accepts transpileOptions as parameters and returns only outputText part of the result. - */ - function transpile(input, compilerOptions, fileName, diagnostics, moduleName) { - var output = transpileModule(input, { compilerOptions: compilerOptions, fileName: fileName, reportDiagnostics: !!diagnostics, moduleName: moduleName }); - // addRange correctly handles cases when wither 'from' or 'to' argument is missing - ts.addRange(diagnostics, output.diagnostics); - return output.outputText; - } - ts.transpile = transpile; - function createLanguageServiceSourceFile(fileName, scriptSnapshot, scriptTarget, version, setNodeParents) { - var text = scriptSnapshot.getText(0, scriptSnapshot.getLength()); - var sourceFile = ts.createSourceFile(fileName, text, scriptTarget, setNodeParents); - setSourceFileFields(sourceFile, scriptSnapshot, version); - // after full parsing we can use table with interned strings as name table - sourceFile.nameTable = sourceFile.identifiers; - return sourceFile; - } - ts.createLanguageServiceSourceFile = createLanguageServiceSourceFile; - ts.disableIncrementalParsing = false; - function updateLanguageServiceSourceFile(sourceFile, scriptSnapshot, version, textChangeRange, aggressiveChecks) { - // If we were given a text change range, and our version or open-ness changed, then - // incrementally parse this file. - if (textChangeRange) { - if (version !== sourceFile.version) { - // Once incremental parsing is ready, then just call into this function. - if (!ts.disableIncrementalParsing) { - var newText; - // grab the fragment from the beginning of the original text to the beginning of the span - var prefix = textChangeRange.span.start !== 0 - ? sourceFile.text.substr(0, textChangeRange.span.start) - : ""; - // grab the fragment from the end of the span till the end of the original text - var suffix = ts.textSpanEnd(textChangeRange.span) !== sourceFile.text.length - ? sourceFile.text.substr(ts.textSpanEnd(textChangeRange.span)) - : ""; - if (textChangeRange.newLength === 0) { - // edit was a deletion - just combine prefix and suffix - newText = prefix && suffix ? prefix + suffix : prefix || suffix; - } - else { - // it was actual edit, fetch the fragment of new text that correspond to new span - var changedText = scriptSnapshot.getText(textChangeRange.span.start, textChangeRange.span.start + textChangeRange.newLength); - // combine prefix, changed text and suffix - newText = prefix && suffix - ? prefix + changedText + suffix - : prefix - ? (prefix + changedText) - : (changedText + suffix); - } - var newSourceFile = ts.updateSourceFile(sourceFile, newText, textChangeRange, aggressiveChecks); - setSourceFileFields(newSourceFile, scriptSnapshot, version); - // after incremental parsing nameTable might not be up-to-date - // drop it so it can be lazily recreated later - newSourceFile.nameTable = undefined; - // dispose all resources held by old script snapshot - if (sourceFile !== newSourceFile && sourceFile.scriptSnapshot) { - if (sourceFile.scriptSnapshot.dispose) { - sourceFile.scriptSnapshot.dispose(); - } - sourceFile.scriptSnapshot = undefined; - } - return newSourceFile; - } - } - } - // Otherwise, just create a new source file. - return createLanguageServiceSourceFile(sourceFile.fileName, scriptSnapshot, sourceFile.languageVersion, version, /*setNodeParents:*/ true); - } - ts.updateLanguageServiceSourceFile = updateLanguageServiceSourceFile; - function createGetCanonicalFileName(useCaseSensitivefileNames) { - return useCaseSensitivefileNames - ? (function (fileName) { return fileName; }) - : (function (fileName) { return fileName.toLowerCase(); }); - } - ts.createGetCanonicalFileName = createGetCanonicalFileName; - function createDocumentRegistry(useCaseSensitiveFileNames) { - // Maps from compiler setting target (ES3, ES5, etc.) to all the cached documents we have - // for those settings. - var buckets = {}; - var getCanonicalFileName = createGetCanonicalFileName(!!useCaseSensitiveFileNames); - function getKeyFromCompilationSettings(settings) { - return "_" + settings.target + "|" + settings.module + "|" + settings.noResolve + "|" + settings.jsx; - } - function getBucketForCompilationSettings(settings, createIfMissing) { - var key = getKeyFromCompilationSettings(settings); - var bucket = ts.lookUp(buckets, key); - if (!bucket && createIfMissing) { - buckets[key] = bucket = ts.createFileMap(getCanonicalFileName); - } - return bucket; - } - function reportStats() { - var bucketInfoArray = Object.keys(buckets).filter(function (name) { return name && name.charAt(0) === '_'; }).map(function (name) { - var entries = ts.lookUp(buckets, name); - var sourceFiles = []; - for (var i in entries) { - var entry = entries.get(i); - sourceFiles.push({ - name: i, - refCount: entry.languageServiceRefCount, - references: entry.owners.slice(0) - }); - } - sourceFiles.sort(function (x, y) { return y.refCount - x.refCount; }); - return { - bucket: name, - sourceFiles: sourceFiles - }; - }); - return JSON.stringify(bucketInfoArray, null, 2); - } - function acquireDocument(fileName, compilationSettings, scriptSnapshot, version) { - return acquireOrUpdateDocument(fileName, compilationSettings, scriptSnapshot, version, /*acquiring:*/ true); - } - function updateDocument(fileName, compilationSettings, scriptSnapshot, version) { - return acquireOrUpdateDocument(fileName, compilationSettings, scriptSnapshot, version, /*acquiring:*/ false); - } - function acquireOrUpdateDocument(fileName, compilationSettings, scriptSnapshot, version, acquiring) { - var bucket = getBucketForCompilationSettings(compilationSettings, /*createIfMissing*/ true); - var entry = bucket.get(fileName); - if (!entry) { - ts.Debug.assert(acquiring, "How could we be trying to update a document that the registry doesn't have?"); - // Have never seen this file with these settings. Create a new source file for it. - var sourceFile = createLanguageServiceSourceFile(fileName, scriptSnapshot, compilationSettings.target, version, /*setNodeParents:*/ false); - entry = { - sourceFile: sourceFile, - languageServiceRefCount: 0, - owners: [] - }; - bucket.set(fileName, entry); - } - else { - // We have an entry for this file. However, it may be for a different version of - // the script snapshot. If so, update it appropriately. Otherwise, we can just - // return it as is. - if (entry.sourceFile.version !== version) { - entry.sourceFile = updateLanguageServiceSourceFile(entry.sourceFile, scriptSnapshot, version, scriptSnapshot.getChangeRange(entry.sourceFile.scriptSnapshot)); - } - } - // If we're acquiring, then this is the first time this LS is asking for this document. - // Increase our ref count so we know there's another LS using the document. If we're - // not acquiring, then that means the LS is 'updating' the file instead, and that means - // it has already acquired the document previously. As such, we do not need to increase - // the ref count. - if (acquiring) { - entry.languageServiceRefCount++; - } - return entry.sourceFile; - } - function releaseDocument(fileName, compilationSettings) { - var bucket = getBucketForCompilationSettings(compilationSettings, false); - ts.Debug.assert(bucket !== undefined); - var entry = bucket.get(fileName); - entry.languageServiceRefCount--; - ts.Debug.assert(entry.languageServiceRefCount >= 0); - if (entry.languageServiceRefCount === 0) { - bucket.remove(fileName); - } - } - return { - acquireDocument: acquireDocument, - updateDocument: updateDocument, - releaseDocument: releaseDocument, - reportStats: reportStats - }; - } - ts.createDocumentRegistry = createDocumentRegistry; - function preProcessFile(sourceText, readImportFiles) { - if (readImportFiles === void 0) { readImportFiles = true; } - var referencedFiles = []; - var importedFiles = []; - var ambientExternalModules; - var isNoDefaultLib = false; - function processTripleSlashDirectives() { - var commentRanges = ts.getLeadingCommentRanges(sourceText, 0); - ts.forEach(commentRanges, function (commentRange) { - var comment = sourceText.substring(commentRange.pos, commentRange.end); - var referencePathMatchResult = ts.getFileReferenceFromReferencePath(comment, commentRange); - if (referencePathMatchResult) { - isNoDefaultLib = referencePathMatchResult.isNoDefaultLib; - var fileReference = referencePathMatchResult.fileReference; - if (fileReference) { - referencedFiles.push(fileReference); - } - } - }); - } - function recordAmbientExternalModule() { - if (!ambientExternalModules) { - ambientExternalModules = []; - } - ambientExternalModules.push(scanner.getTokenValue()); - } - function recordModuleName() { - var importPath = scanner.getTokenValue(); - var pos = scanner.getTokenPos(); - importedFiles.push({ - fileName: importPath, - pos: pos, - end: pos + importPath.length - }); - } - function processImport() { - scanner.setText(sourceText); - var token = scanner.scan(); - // Look for: - // import "mod"; - // import d from "mod" - // import {a as A } from "mod"; - // import * as NS from "mod" - // import d, {a, b as B} from "mod" - // import i = require("mod"); - // - // export * from "mod" - // export {a as b} from "mod" - // export import i = require("mod") - while (token !== 1 /* EndOfFileToken */) { - if (token === 122 /* DeclareKeyword */) { - // declare module "mod" - token = scanner.scan(); - if (token === 125 /* ModuleKeyword */) { - token = scanner.scan(); - if (token === 9 /* StringLiteral */) { - recordAmbientExternalModule(); - continue; - } - } - } - else if (token === 89 /* ImportKeyword */) { - token = scanner.scan(); - if (token === 9 /* StringLiteral */) { - // import "mod"; - recordModuleName(); - continue; - } - else { - if (token === 69 /* Identifier */ || ts.isKeyword(token)) { - token = scanner.scan(); - if (token === 133 /* FromKeyword */) { - token = scanner.scan(); - if (token === 9 /* StringLiteral */) { - // import d from "mod"; - recordModuleName(); - continue; - } - } - else if (token === 56 /* EqualsToken */) { - token = scanner.scan(); - if (token === 127 /* RequireKeyword */) { - token = scanner.scan(); - if (token === 17 /* OpenParenToken */) { - token = scanner.scan(); - if (token === 9 /* StringLiteral */) { - // import i = require("mod"); - recordModuleName(); - continue; - } - } - } - } - else if (token === 24 /* CommaToken */) { - // consume comma and keep going - token = scanner.scan(); - } - else { - // unknown syntax - continue; - } - } - if (token === 15 /* OpenBraceToken */) { - token = scanner.scan(); - // consume "{ a as B, c, d as D}" clauses - while (token !== 16 /* CloseBraceToken */) { - token = scanner.scan(); - } - if (token === 16 /* CloseBraceToken */) { - token = scanner.scan(); - if (token === 133 /* FromKeyword */) { - token = scanner.scan(); - if (token === 9 /* StringLiteral */) { - // import {a as A} from "mod"; - // import d, {a, b as B} from "mod" - recordModuleName(); - } - } - } - } - else if (token === 37 /* AsteriskToken */) { - token = scanner.scan(); - if (token === 116 /* AsKeyword */) { - token = scanner.scan(); - if (token === 69 /* Identifier */ || ts.isKeyword(token)) { - token = scanner.scan(); - if (token === 133 /* FromKeyword */) { - token = scanner.scan(); - if (token === 9 /* StringLiteral */) { - // import * as NS from "mod" - // import d, * as NS from "mod" - recordModuleName(); - } - } - } - } - } - } - } - else if (token === 82 /* ExportKeyword */) { - token = scanner.scan(); - if (token === 15 /* OpenBraceToken */) { - token = scanner.scan(); - // consume "{ a as B, c, d as D}" clauses - while (token !== 16 /* CloseBraceToken */) { - token = scanner.scan(); - } - if (token === 16 /* CloseBraceToken */) { - token = scanner.scan(); - if (token === 133 /* FromKeyword */) { - token = scanner.scan(); - if (token === 9 /* StringLiteral */) { - // export {a as A} from "mod"; - // export {a, b as B} from "mod" - recordModuleName(); - } - } - } - } - else if (token === 37 /* AsteriskToken */) { - token = scanner.scan(); - if (token === 133 /* FromKeyword */) { - token = scanner.scan(); - if (token === 9 /* StringLiteral */) { - // export * from "mod" - recordModuleName(); - } - } - } - else if (token === 89 /* ImportKeyword */) { - token = scanner.scan(); - if (token === 69 /* Identifier */ || ts.isKeyword(token)) { - token = scanner.scan(); - if (token === 56 /* EqualsToken */) { - token = scanner.scan(); - if (token === 127 /* RequireKeyword */) { - token = scanner.scan(); - if (token === 17 /* OpenParenToken */) { - token = scanner.scan(); - if (token === 9 /* StringLiteral */) { - // export import i = require("mod"); - recordModuleName(); - } - } - } - } - } - } - } - token = scanner.scan(); - } - scanner.setText(undefined); - } - if (readImportFiles) { - processImport(); - } - processTripleSlashDirectives(); - return { referencedFiles: referencedFiles, importedFiles: importedFiles, isLibFile: isNoDefaultLib, ambientExternalModules: ambientExternalModules }; - } - ts.preProcessFile = preProcessFile; - /// Helpers - function getTargetLabel(referenceNode, labelName) { - while (referenceNode) { - if (referenceNode.kind === 207 /* LabeledStatement */ && referenceNode.label.text === labelName) { - return referenceNode.label; - } - referenceNode = referenceNode.parent; - } - return undefined; - } - function isJumpStatementTarget(node) { - return node.kind === 69 /* Identifier */ && - (node.parent.kind === 203 /* BreakStatement */ || node.parent.kind === 202 /* ContinueStatement */) && - node.parent.label === node; - } - function isLabelOfLabeledStatement(node) { - return node.kind === 69 /* Identifier */ && - node.parent.kind === 207 /* LabeledStatement */ && - node.parent.label === node; - } - /** - * Whether or not a 'node' is preceded by a label of the given string. - * Note: 'node' cannot be a SourceFile. - */ - function isLabeledBy(node, labelName) { - for (var owner = node.parent; owner.kind === 207 /* LabeledStatement */; owner = owner.parent) { - if (owner.label.text === labelName) { - return true; - } - } - return false; - } - function isLabelName(node) { - return isLabelOfLabeledStatement(node) || isJumpStatementTarget(node); - } - function isRightSideOfQualifiedName(node) { - return node.parent.kind === 135 /* QualifiedName */ && node.parent.right === node; - } - function isRightSideOfPropertyAccess(node) { - return node && node.parent && node.parent.kind === 166 /* PropertyAccessExpression */ && node.parent.name === node; - } - function isCallExpressionTarget(node) { - if (isRightSideOfPropertyAccess(node)) { - node = node.parent; - } - return node && node.parent && node.parent.kind === 168 /* CallExpression */ && node.parent.expression === node; - } - function isNewExpressionTarget(node) { - if (isRightSideOfPropertyAccess(node)) { - node = node.parent; - } - return node && node.parent && node.parent.kind === 169 /* NewExpression */ && node.parent.expression === node; - } - function isNameOfModuleDeclaration(node) { - return node.parent.kind === 218 /* ModuleDeclaration */ && node.parent.name === node; - } - function isNameOfFunctionDeclaration(node) { - return node.kind === 69 /* Identifier */ && - ts.isFunctionLike(node.parent) && node.parent.name === node; - } - /** Returns true if node is a name of an object literal property, e.g. "a" in x = { "a": 1 } */ - function isNameOfPropertyAssignment(node) { - return (node.kind === 69 /* Identifier */ || node.kind === 9 /* StringLiteral */ || node.kind === 8 /* NumericLiteral */) && - (node.parent.kind === 245 /* PropertyAssignment */ || node.parent.kind === 246 /* ShorthandPropertyAssignment */) && node.parent.name === node; - } - function isLiteralNameOfPropertyDeclarationOrIndexAccess(node) { - if (node.kind === 9 /* StringLiteral */ || node.kind === 8 /* NumericLiteral */) { - switch (node.parent.kind) { - case 141 /* PropertyDeclaration */: - case 140 /* PropertySignature */: - case 245 /* PropertyAssignment */: - case 247 /* EnumMember */: - case 143 /* MethodDeclaration */: - case 142 /* MethodSignature */: - case 145 /* GetAccessor */: - case 146 /* SetAccessor */: - case 218 /* ModuleDeclaration */: - return node.parent.name === node; - case 167 /* ElementAccessExpression */: - return node.parent.argumentExpression === node; - } - } - return false; - } - function isNameOfExternalModuleImportOrDeclaration(node) { - if (node.kind === 9 /* StringLiteral */) { - return isNameOfModuleDeclaration(node) || - (ts.isExternalModuleImportEqualsDeclaration(node.parent.parent) && ts.getExternalModuleImportEqualsDeclarationExpression(node.parent.parent) === node); - } - return false; - } - /** Returns true if the position is within a comment */ - function isInsideComment(sourceFile, token, position) { - // The position has to be: 1. in the leading trivia (before token.getStart()), and 2. within a comment - return position <= token.getStart(sourceFile) && - (isInsideCommentRange(ts.getTrailingCommentRanges(sourceFile.text, token.getFullStart())) || - isInsideCommentRange(ts.getLeadingCommentRanges(sourceFile.text, token.getFullStart()))); - function isInsideCommentRange(comments) { - return ts.forEach(comments, function (comment) { - // either we are 1. completely inside the comment, or 2. at the end of the comment - if (comment.pos < position && position < comment.end) { - return true; - } - else if (position === comment.end) { - var text = sourceFile.text; - var width = comment.end - comment.pos; - // is single line comment or just /* - if (width <= 2 || text.charCodeAt(comment.pos + 1) === 47 /* slash */) { - return true; - } - else { - // is unterminated multi-line comment - return !(text.charCodeAt(comment.end - 1) === 47 /* slash */ && - text.charCodeAt(comment.end - 2) === 42 /* asterisk */); - } - } - return false; - }); - } - } - var SemanticMeaning; - (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"; - })(SemanticMeaning || (SemanticMeaning = {})); - var BreakContinueSearchType; - (function (BreakContinueSearchType) { - BreakContinueSearchType[BreakContinueSearchType["None"] = 0] = "None"; - BreakContinueSearchType[BreakContinueSearchType["Unlabeled"] = 1] = "Unlabeled"; - BreakContinueSearchType[BreakContinueSearchType["Labeled"] = 2] = "Labeled"; - BreakContinueSearchType[BreakContinueSearchType["All"] = 3] = "All"; - })(BreakContinueSearchType || (BreakContinueSearchType = {})); - // A cache of completion entries for keywords, these do not change between sessions - var keywordCompletions = []; - for (var i = 70 /* FirstKeyword */; i <= 134 /* LastKeyword */; i++) { - keywordCompletions.push({ - name: ts.tokenToString(i), - kind: ScriptElementKind.keyword, - kindModifiers: ScriptElementKindModifier.none, - sortText: "0" - }); - } - /* @internal */ function getContainerNode(node) { - while (true) { - node = node.parent; - if (!node) { - return undefined; - } - switch (node.kind) { - case 248 /* SourceFile */: - case 143 /* MethodDeclaration */: - case 142 /* MethodSignature */: - case 213 /* FunctionDeclaration */: - case 173 /* FunctionExpression */: - case 145 /* GetAccessor */: - case 146 /* SetAccessor */: - case 214 /* ClassDeclaration */: - case 215 /* InterfaceDeclaration */: - case 217 /* EnumDeclaration */: - case 218 /* ModuleDeclaration */: - return node; - } - } - } - ts.getContainerNode = getContainerNode; - /* @internal */ function getNodeKind(node) { - switch (node.kind) { - case 218 /* ModuleDeclaration */: return ScriptElementKind.moduleElement; - case 214 /* ClassDeclaration */: return ScriptElementKind.classElement; - case 215 /* InterfaceDeclaration */: return ScriptElementKind.interfaceElement; - case 216 /* TypeAliasDeclaration */: return ScriptElementKind.typeElement; - case 217 /* EnumDeclaration */: return ScriptElementKind.enumElement; - case 211 /* VariableDeclaration */: - return ts.isConst(node) - ? ScriptElementKind.constElement - : ts.isLet(node) - ? ScriptElementKind.letElement - : ScriptElementKind.variableElement; - case 213 /* FunctionDeclaration */: return ScriptElementKind.functionElement; - case 145 /* GetAccessor */: return ScriptElementKind.memberGetAccessorElement; - case 146 /* SetAccessor */: return ScriptElementKind.memberSetAccessorElement; - case 143 /* MethodDeclaration */: - case 142 /* MethodSignature */: - return ScriptElementKind.memberFunctionElement; - case 141 /* PropertyDeclaration */: - case 140 /* PropertySignature */: - return ScriptElementKind.memberVariableElement; - case 149 /* IndexSignature */: return ScriptElementKind.indexSignatureElement; - case 148 /* ConstructSignature */: return ScriptElementKind.constructSignatureElement; - case 147 /* CallSignature */: return ScriptElementKind.callSignatureElement; - case 144 /* Constructor */: return ScriptElementKind.constructorImplementationElement; - case 137 /* TypeParameter */: return ScriptElementKind.typeParameterElement; - case 247 /* EnumMember */: return ScriptElementKind.variableElement; - case 138 /* Parameter */: return (node.flags & 112 /* AccessibilityModifier */) ? ScriptElementKind.memberVariableElement : ScriptElementKind.parameterElement; - case 221 /* ImportEqualsDeclaration */: - case 226 /* ImportSpecifier */: - case 223 /* ImportClause */: - case 230 /* ExportSpecifier */: - case 224 /* NamespaceImport */: - return ScriptElementKind.alias; - } - return ScriptElementKind.unknown; - } - ts.getNodeKind = getNodeKind; - var CancellationTokenObject = (function () { - function CancellationTokenObject(cancellationToken) { - this.cancellationToken = cancellationToken; - } - CancellationTokenObject.prototype.isCancellationRequested = function () { - return this.cancellationToken && this.cancellationToken.isCancellationRequested(); - }; - CancellationTokenObject.prototype.throwIfCancellationRequested = function () { - if (this.isCancellationRequested()) { - throw new ts.OperationCanceledException(); - } - }; - return CancellationTokenObject; - })(); - function createLanguageService(host, documentRegistry) { - if (documentRegistry === void 0) { documentRegistry = createDocumentRegistry(); } - var syntaxTreeCache = new SyntaxTreeCache(host); - var ruleProvider; - var program; - var lastProjectVersion; - var useCaseSensitivefileNames = false; - var cancellationToken = new CancellationTokenObject(host.getCancellationToken && host.getCancellationToken()); - // Check if the localized messages json is set, otherwise query the host for it - if (!ts.localizedDiagnosticMessages && host.getLocalizedDiagnosticMessages) { - ts.localizedDiagnosticMessages = host.getLocalizedDiagnosticMessages(); - } - function log(message) { - if (host.log) { - host.log(message); - } - } - var getCanonicalFileName = createGetCanonicalFileName(useCaseSensitivefileNames); - function getValidSourceFile(fileName) { - fileName = ts.normalizeSlashes(fileName); - var sourceFile = program.getSourceFile(getCanonicalFileName(fileName)); - if (!sourceFile) { - throw new Error("Could not find file: '" + fileName + "'."); - } - return sourceFile; - } - function getRuleProvider(options) { - // Ensure rules are initialized and up to date wrt to formatting options - if (!ruleProvider) { - ruleProvider = new ts.formatting.RulesProvider(); - } - ruleProvider.ensureUpToDate(options); - return ruleProvider; - } - function synchronizeHostData() { - // perform fast check if host supports it - if (host.getProjectVersion) { - var hostProjectVersion = host.getProjectVersion(); - if (hostProjectVersion) { - if (lastProjectVersion === hostProjectVersion) { - return; - } - lastProjectVersion = hostProjectVersion; - } - } - // 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 - if (programUpToDate()) { - return; - } - // IMPORTANT - It is critical from this moment onward that we do not check - // cancellation tokens. We are about to mutate source files from a previous program - // instance. If we cancel midway through, we may end up in an inconsistent state where - // the program points to old source files that have been invalidated because of - // incremental parsing. - var oldSettings = program && program.getCompilerOptions(); - var newSettings = hostCache.compilationSettings(); - var changesInCompilationSettingsAffectSyntax = oldSettings && - (oldSettings.target !== newSettings.target || - oldSettings.module !== newSettings.module || - oldSettings.noResolve !== newSettings.noResolve || - oldSettings.jsx !== newSettings.jsx); - // Now create a new compiler - var compilerHost = { - getSourceFile: getOrCreateSourceFile, - getCancellationToken: function () { return cancellationToken; }, - getCanonicalFileName: getCanonicalFileName, - useCaseSensitiveFileNames: function () { return useCaseSensitivefileNames; }, - getNewLine: function () { return ts.getNewLineOrDefaultFromHost(host); }, - getDefaultLibFileName: function (options) { return host.getDefaultLibFileName(options); }, - writeFile: function (fileName, data, writeByteOrderMark) { }, - getCurrentDirectory: function () { return host.getCurrentDirectory(); }, - fileExists: function (fileName) { - // stub missing host functionality - ts.Debug.assert(!host.resolveModuleNames); - return hostCache.getOrCreateEntry(fileName) !== undefined; - }, - readFile: function (fileName) { - // stub missing host functionality - var entry = hostCache.getOrCreateEntry(fileName); - return entry && entry.scriptSnapshot.getText(0, entry.scriptSnapshot.getLength()); - } - }; - if (host.resolveModuleNames) { - compilerHost.resolveModuleNames = function (moduleNames, containingFile) { return host.resolveModuleNames(moduleNames, containingFile); }; - } - var newProgram = ts.createProgram(hostCache.getRootFileNames(), newSettings, compilerHost, program); - // Release any files we have acquired in the old program but are - // not part of the new program. - if (program) { - var oldSourceFiles = program.getSourceFiles(); - for (var _i = 0; _i < oldSourceFiles.length; _i++) { - var oldSourceFile = oldSourceFiles[_i]; - var fileName = oldSourceFile.fileName; - if (!newProgram.getSourceFile(fileName) || changesInCompilationSettingsAffectSyntax) { - documentRegistry.releaseDocument(fileName, oldSettings); - } - } - } - // hostCache is captured in the closure for 'getOrCreateSourceFile' but it should not be used past this point. - // It needs to be cleared to allow all collected snapshots to be released - hostCache = undefined; - program = newProgram; - // Make sure all the nodes in the program are both bound, and have their parent - // pointers set property. - program.getTypeChecker(); - return; - function getOrCreateSourceFile(fileName) { - ts.Debug.assert(hostCache !== undefined); - // The program is asking for this file, check first if the host can locate it. - // If the host can not locate the file, then it does not exist. return undefined - // to the program to allow reporting of errors for missing files. - var hostFileInformation = hostCache.getOrCreateEntry(fileName); - if (!hostFileInformation) { - return undefined; - } - // Check if the language version has changed since we last created a program; if they are the same, - // it is safe to reuse the souceFiles; if not, then the shape of the AST can change, and the oldSourceFile - // can not be reused. we have to dump all syntax trees and create new ones. - if (!changesInCompilationSettingsAffectSyntax) { - // Check if the old program had this file already - var oldSourceFile = program && program.getSourceFile(fileName); - if (oldSourceFile) { - // We already had a source file for this file name. Go to the registry to - // ensure that we get the right up to date version of it. We need this to - // address the following 'race'. Specifically, say we have the following: - // - // LS1 - // \ - // DocumentRegistry - // / - // LS2 - // - // Each LS has a reference to file 'foo.ts' at version 1. LS2 then updates - // it's version of 'foo.ts' to version 2. This will cause LS2 and the - // DocumentRegistry to have version 2 of the document. HOwever, LS1 will - // have version 1. And *importantly* this source file will be *corrupt*. - // The act of creating version 2 of the file irrevocably damages the version - // 1 file. - // - // So, later when we call into LS1, we need to make sure that it doesn't use - // it's source file any more, and instead defers to DocumentRegistry to get - // either version 1, version 2 (or some other version) depending on what the - // host says should be used. - return documentRegistry.updateDocument(fileName, newSettings, hostFileInformation.scriptSnapshot, hostFileInformation.version); - } - } - // Could not find this file in the old program, create a new SourceFile for it. - return documentRegistry.acquireDocument(fileName, newSettings, hostFileInformation.scriptSnapshot, hostFileInformation.version); - } - function sourceFileUpToDate(sourceFile) { - return sourceFile && sourceFile.version === hostCache.getVersion(sourceFile.fileName); - } - function programUpToDate() { - // If we haven't create a program yet, then it is not up-to-date - if (!program) { - return false; - } - // If number of files in the program do not match, it is not up-to-date - var rootFileNames = hostCache.getRootFileNames(); - if (program.getSourceFiles().length !== rootFileNames.length) { - return false; - } - // If any file is not up-to-date, then the whole program is not up-to-date - for (var _i = 0; _i < rootFileNames.length; _i++) { - var fileName = rootFileNames[_i]; - if (!sourceFileUpToDate(program.getSourceFile(fileName))) { - return false; - } - } - // If the compilation settings do no match, then the program is not up-to-date - return ts.compareDataObjects(program.getCompilerOptions(), hostCache.compilationSettings()); - } - } - function getProgram() { - synchronizeHostData(); - return program; - } - function cleanupSemanticCache() { - // TODO: Should we jettison the program (or it's type checker) here? - } - function dispose() { - if (program) { - ts.forEach(program.getSourceFiles(), function (f) { - return documentRegistry.releaseDocument(f.fileName, program.getCompilerOptions()); - }); - } - } - /// Diagnostics - function getSyntacticDiagnostics(fileName) { - synchronizeHostData(); - return program.getSyntacticDiagnostics(getValidSourceFile(fileName), cancellationToken); - } - /** - * getSemanticDiagnostiscs return array of Diagnostics. If '-d' is not enabled, only report semantic errors - * If '-d' enabled, report both semantic and emitter errors - */ - function getSemanticDiagnostics(fileName) { - synchronizeHostData(); - var targetSourceFile = getValidSourceFile(fileName); - // For JavaScript files, we don't want to report the normal typescript semantic errors. - // Instead, we just report errors for using TypeScript-only constructs from within a - // JavaScript file. - if (ts.isJavaScript(fileName)) { - return getJavaScriptSemanticDiagnostics(targetSourceFile); - } - // Only perform the action per file regardless of '-out' flag as LanguageServiceHost is expected to call this function per file. - // Therefore only get diagnostics for given file. - var semanticDiagnostics = program.getSemanticDiagnostics(targetSourceFile, cancellationToken); - if (!program.getCompilerOptions().declaration) { - return semanticDiagnostics; - } - // If '-d' is enabled, check for emitter error. One example of emitter error is export class implements non-export interface - var declarationDiagnostics = program.getDeclarationDiagnostics(targetSourceFile, cancellationToken); - return ts.concatenate(semanticDiagnostics, declarationDiagnostics); - } - function getJavaScriptSemanticDiagnostics(sourceFile) { - var diagnostics = []; - walk(sourceFile); - return diagnostics; - function walk(node) { - if (!node) { - return false; - } - switch (node.kind) { - case 221 /* ImportEqualsDeclaration */: - diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.import_can_only_be_used_in_a_ts_file)); - return true; - case 227 /* ExportAssignment */: - diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.export_can_only_be_used_in_a_ts_file)); - return true; - case 214 /* ClassDeclaration */: - var classDeclaration = node; - if (checkModifiers(classDeclaration.modifiers) || - checkTypeParameters(classDeclaration.typeParameters)) { - return true; - } - break; - case 243 /* HeritageClause */: - var heritageClause = node; - if (heritageClause.token === 106 /* ImplementsKeyword */) { - diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.implements_clauses_can_only_be_used_in_a_ts_file)); - return true; - } - break; - case 215 /* InterfaceDeclaration */: - diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.interface_declarations_can_only_be_used_in_a_ts_file)); - return true; - case 218 /* ModuleDeclaration */: - diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.module_declarations_can_only_be_used_in_a_ts_file)); - return true; - case 216 /* TypeAliasDeclaration */: - diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.type_aliases_can_only_be_used_in_a_ts_file)); - return true; - case 143 /* MethodDeclaration */: - case 142 /* MethodSignature */: - case 144 /* Constructor */: - case 145 /* GetAccessor */: - case 146 /* SetAccessor */: - case 173 /* FunctionExpression */: - case 213 /* FunctionDeclaration */: - case 174 /* ArrowFunction */: - case 213 /* FunctionDeclaration */: - var functionDeclaration = node; - if (checkModifiers(functionDeclaration.modifiers) || - checkTypeParameters(functionDeclaration.typeParameters) || - checkTypeAnnotation(functionDeclaration.type)) { - return true; - } - break; - case 193 /* VariableStatement */: - var variableStatement = node; - if (checkModifiers(variableStatement.modifiers)) { - return true; - } - break; - case 211 /* VariableDeclaration */: - var variableDeclaration = node; - if (checkTypeAnnotation(variableDeclaration.type)) { - return true; - } - break; - case 168 /* CallExpression */: - case 169 /* NewExpression */: - var expression = node; - if (expression.typeArguments && expression.typeArguments.length > 0) { - var start = expression.typeArguments.pos; - diagnostics.push(ts.createFileDiagnostic(sourceFile, start, expression.typeArguments.end - start, ts.Diagnostics.type_arguments_can_only_be_used_in_a_ts_file)); - return true; - } - break; - case 138 /* Parameter */: - var parameter = node; - if (parameter.modifiers) { - var start = parameter.modifiers.pos; - diagnostics.push(ts.createFileDiagnostic(sourceFile, start, parameter.modifiers.end - start, ts.Diagnostics.parameter_modifiers_can_only_be_used_in_a_ts_file)); - return true; - } - if (parameter.questionToken) { - diagnostics.push(ts.createDiagnosticForNode(parameter.questionToken, ts.Diagnostics._0_can_only_be_used_in_a_ts_file, '?')); - return true; - } - if (parameter.type) { - diagnostics.push(ts.createDiagnosticForNode(parameter.type, ts.Diagnostics.types_can_only_be_used_in_a_ts_file)); - return true; - } - break; - case 141 /* PropertyDeclaration */: - diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.property_declarations_can_only_be_used_in_a_ts_file)); - return true; - case 217 /* EnumDeclaration */: - diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.enum_declarations_can_only_be_used_in_a_ts_file)); - return true; - case 171 /* TypeAssertionExpression */: - var typeAssertionExpression = node; - diagnostics.push(ts.createDiagnosticForNode(typeAssertionExpression.type, ts.Diagnostics.type_assertion_expressions_can_only_be_used_in_a_ts_file)); - return true; - case 139 /* Decorator */: - diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.decorators_can_only_be_used_in_a_ts_file)); - return true; - } - return ts.forEachChild(node, walk); - } - function checkTypeParameters(typeParameters) { - if (typeParameters) { - var start = typeParameters.pos; - diagnostics.push(ts.createFileDiagnostic(sourceFile, start, typeParameters.end - start, ts.Diagnostics.type_parameter_declarations_can_only_be_used_in_a_ts_file)); - return true; - } - return false; - } - function checkTypeAnnotation(type) { - if (type) { - diagnostics.push(ts.createDiagnosticForNode(type, ts.Diagnostics.types_can_only_be_used_in_a_ts_file)); - return true; - } - return false; - } - function checkModifiers(modifiers) { - if (modifiers) { - for (var _i = 0; _i < modifiers.length; _i++) { - var modifier = modifiers[_i]; - switch (modifier.kind) { - case 112 /* PublicKeyword */: - case 110 /* PrivateKeyword */: - case 111 /* ProtectedKeyword */: - case 122 /* DeclareKeyword */: - diagnostics.push(ts.createDiagnosticForNode(modifier, ts.Diagnostics._0_can_only_be_used_in_a_ts_file, ts.tokenToString(modifier.kind))); - return true; - // These are all legal modifiers. - case 113 /* StaticKeyword */: - case 82 /* ExportKeyword */: - case 74 /* ConstKeyword */: - case 77 /* DefaultKeyword */: - case 115 /* AbstractKeyword */: - } - } - } - return false; - } - } - function getCompilerOptionsDiagnostics() { - synchronizeHostData(); - return program.getOptionsDiagnostics(cancellationToken).concat(program.getGlobalDiagnostics(cancellationToken)); - } - /** - * Get the name to be display in completion from a given symbol. - * - * @return undefined if the name is of external module otherwise a name with striped of any quote - */ - function getCompletionEntryDisplayNameForSymbol(symbol, target, performCharacterChecks, location) { - var displayName = ts.getDeclaredName(program.getTypeChecker(), symbol, location); - if (displayName) { - var firstCharCode = displayName.charCodeAt(0); - // First check of the displayName is not external module; if it is an external module, it is not valid entry - if ((symbol.flags & 1536 /* Namespace */) && (firstCharCode === 39 /* singleQuote */ || firstCharCode === 34 /* doubleQuote */)) { - // If the symbol is external module, don't show it in the completion list - // (i.e declare module "http" { let x; } | // <= request completion here, "http" should not be there) - return undefined; - } - } - return getCompletionEntryDisplayName(displayName, target, performCharacterChecks); - } - /** - * Get a displayName from a given for completion list, performing any necessary quotes stripping - * and checking whether the name is valid identifier name. - */ - function getCompletionEntryDisplayName(name, target, performCharacterChecks) { - if (!name) { - return undefined; - } - name = ts.stripQuotes(name); - if (!name) { - return undefined; - } - // If the user entered name for the symbol was quoted, removing the quotes is not enough, as the name could be an - // invalid identifier name. We need to check if whatever was inside the quotes is actually a valid identifier name. - // e.g "b a" is valid quoted name but when we strip off the quotes, it is invalid. - // We, thus, need to check if whatever was inside the quotes is actually a valid identifier name. - if (performCharacterChecks) { - if (!ts.isIdentifierStart(name.charCodeAt(0), target)) { - return undefined; - } - for (var i = 1, n = name.length; i < n; i++) { - if (!ts.isIdentifierPart(name.charCodeAt(i), target)) { - return undefined; - } - } - } - return name; - } - function getCompletionData(fileName, position) { - var typeChecker = program.getTypeChecker(); - var syntacticStart = new Date().getTime(); - var sourceFile = getValidSourceFile(fileName); - var isJavaScriptFile = ts.isJavaScript(fileName); - var isJsDocTagName = false; - var start = new Date().getTime(); - var currentToken = ts.getTokenAtPosition(sourceFile, position); - log("getCompletionData: Get current token: " + (new Date().getTime() - start)); - start = new Date().getTime(); - // Completion not allowed inside comments, bail out if this is the case - var insideComment = isInsideComment(sourceFile, currentToken, position); - log("getCompletionData: Is inside comment: " + (new Date().getTime() - start)); - if (insideComment) { - // The current position is next to the '@' sign, when no tag name being provided yet. - // Provide a full list of tag names - if (ts.hasDocComment(sourceFile, position) && sourceFile.text.charCodeAt(position - 1) === 64 /* at */) { - isJsDocTagName = true; - } - // Completion should work inside certain JsDoc tags. For example: - // /** @type {number | string} */ - // Completion should work in the brackets - var insideJsDocTagExpression = false; - var tag = ts.getJsDocTagAtPosition(sourceFile, position); - if (tag) { - if (tag.tagName.pos <= position && position <= tag.tagName.end) { - isJsDocTagName = true; - } - switch (tag.kind) { - case 269 /* JSDocTypeTag */: - case 267 /* JSDocParameterTag */: - case 268 /* JSDocReturnTag */: - var tagWithExpression = tag; - if (tagWithExpression.typeExpression) { - insideJsDocTagExpression = tagWithExpression.typeExpression.pos < position && position < tagWithExpression.typeExpression.end; - } - break; - } - } - if (isJsDocTagName) { - return { symbols: undefined, 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 - // comment or the plain text part of a jsDoc comment, so no completion should be available - log("Returning an empty list because completion was inside a regular comment or plain text part of a JsDoc comment."); - return undefined; - } - } - start = new Date().getTime(); - var previousToken = ts.findPrecedingToken(position, sourceFile); - log("getCompletionData: Get previous token 1: " + (new Date().getTime() - start)); - // The decision to provide completion depends on the contextToken, which is determined through the previousToken. - // Note: 'previousToken' (and thus 'contextToken') can be undefined if we are the beginning of the file - var contextToken = previousToken; - // Check if the caret is at the end of an identifier; this is a partial identifier that we want to complete: e.g. a.toS| - // Skip this partial identifier and adjust the contextToken to the token that precedes it. - if (contextToken && position <= contextToken.end && ts.isWord(contextToken.kind)) { - var start_4 = new Date().getTime(); - contextToken = ts.findPrecedingToken(contextToken.getFullStart(), sourceFile); - log("getCompletionData: Get previous token 2: " + (new Date().getTime() - start_4)); - } - // Find the node where completion is requested on. - // Also determine whether we are trying to complete with members of that node - // or attributes of a JSX tag. - var node = currentToken; - var isRightOfDot = false; - var isRightOfOpenTag = false; - var isStartingCloseTag = false; - var location = ts.getTouchingPropertyName(sourceFile, position); - if (contextToken) { - // Bail out if this is a known invalid completion location - if (isCompletionListBlocker(contextToken)) { - log("Returning an empty list because completion was requested in an invalid position."); - return undefined; - } - var parent_9 = contextToken.parent, kind = contextToken.kind; - if (kind === 21 /* DotToken */) { - if (parent_9.kind === 166 /* PropertyAccessExpression */) { - node = contextToken.parent.expression; - isRightOfDot = true; - } - else if (parent_9.kind === 135 /* QualifiedName */) { - node = contextToken.parent.left; - isRightOfDot = true; - } - else { - // There is nothing that precedes the dot, so this likely just a stray character - // or leading into a '...' token. Just bail out instead. - return undefined; - } - } - else if (sourceFile.languageVariant === 1 /* JSX */) { - if (kind === 25 /* LessThanToken */) { - isRightOfOpenTag = true; - location = contextToken; - } - else if (kind === 39 /* SlashToken */ && contextToken.parent.kind === 237 /* JsxClosingElement */) { - isStartingCloseTag = true; - } - } - } - var semanticStart = new Date().getTime(); - var isMemberCompletion; - var isNewIdentifierLocation; - var symbols = []; - if (isRightOfDot) { - getTypeScriptMemberSymbols(); - } - else if (isRightOfOpenTag) { - var tagSymbols = typeChecker.getJsxIntrinsicTagNames(); - if (tryGetGlobalSymbols()) { - symbols = tagSymbols.concat(symbols.filter(function (s) { return !!(s.flags & 107455 /* Value */); })); - } - else { - symbols = tagSymbols; - } - isMemberCompletion = true; - isNewIdentifierLocation = false; - } - else if (isStartingCloseTag) { - var tagName = contextToken.parent.parent.openingElement.tagName; - symbols = [typeChecker.getSymbolAtLocation(tagName)]; - isMemberCompletion = true; - isNewIdentifierLocation = false; - } - else { - // For JavaScript or TypeScript, if we're not after a dot, then just try to get the - // global symbols in scope. These results should be valid for either language as - // the set of symbols that can be referenced from this location. - if (!tryGetGlobalSymbols()) { - return undefined; - } - } - log("getCompletionData: Semantic work: " + (new Date().getTime() - semanticStart)); - return { symbols: symbols, isMemberCompletion: isMemberCompletion, isNewIdentifierLocation: isNewIdentifierLocation, location: location, isRightOfDot: (isRightOfDot || isRightOfOpenTag), isJsDocTagName: isJsDocTagName }; - function getTypeScriptMemberSymbols() { - // Right of dot member completion list - isMemberCompletion = true; - isNewIdentifierLocation = false; - if (node.kind === 69 /* Identifier */ || node.kind === 135 /* QualifiedName */ || node.kind === 166 /* PropertyAccessExpression */) { - var symbol = typeChecker.getSymbolAtLocation(node); - // This is an alias, follow what it aliases - if (symbol && symbol.flags & 8388608 /* Alias */) { - symbol = typeChecker.getAliasedSymbol(symbol); - } - if (symbol && symbol.flags & 1952 /* HasExports */) { - // Extract module or enum members - var exportedSymbols = typeChecker.getExportsOfModule(symbol); - ts.forEach(exportedSymbols, function (symbol) { - if (typeChecker.isValidPropertyAccess((node.parent), symbol.name)) { - symbols.push(symbol); - } - }); - } - } - var type = typeChecker.getTypeAtLocation(node); - addTypeProperties(type); - } - function addTypeProperties(type) { - if (type) { - // Filter private properties - for (var _i = 0, _a = type.getApparentProperties(); _i < _a.length; _i++) { - var symbol = _a[_i]; - if (typeChecker.isValidPropertyAccess((node.parent), symbol.name)) { - symbols.push(symbol); - } - } - if (isJavaScriptFile && type.flags & 16384 /* Union */) { - // In javascript files, for union types, we don't just get the members that - // the individual types have in common, we also include all the members that - // each individual type has. This is because we're going to add all identifiers - // anyways. So we might as well elevate the members that were at least part - // of the individual types to a higher status since we know what they are. - var unionType = type; - for (var _b = 0, _c = unionType.types; _b < _c.length; _b++) { - var elementType = _c[_b]; - addTypeProperties(elementType); - } - } - } - } - function tryGetGlobalSymbols() { - var objectLikeContainer; - var namedImportsOrExports; - var jsxContainer; - if (objectLikeContainer = tryGetObjectLikeCompletionContainer(contextToken)) { - return tryGetObjectLikeCompletionSymbols(objectLikeContainer); - } - if (namedImportsOrExports = tryGetNamedImportsOrExportsForCompletion(contextToken)) { - // cursor is in an import clause - // try to show exported member for imported module - return tryGetImportOrExportClauseCompletionSymbols(namedImportsOrExports); - } - if (jsxContainer = tryGetContainingJsxElement(contextToken)) { - var attrsType; - if ((jsxContainer.kind === 234 /* JsxSelfClosingElement */) || (jsxContainer.kind === 235 /* JsxOpeningElement */)) { - // Cursor is inside a JSX self-closing element or opening element - attrsType = typeChecker.getJsxElementAttributesType(jsxContainer); - if (attrsType) { - symbols = filterJsxAttributes(typeChecker.getPropertiesOfType(attrsType), jsxContainer.attributes); - isMemberCompletion = true; - isNewIdentifierLocation = false; - return true; - } - } - } - // Get all entities in the current scope. - isMemberCompletion = false; - isNewIdentifierLocation = isNewIdentifierDefinitionLocation(contextToken); - if (previousToken !== contextToken) { - ts.Debug.assert(!!previousToken, "Expected 'contextToken' to be defined when different from 'previousToken'."); - } - // We need to find the node that will give us an appropriate scope to begin - // aggregating completion candidates. This is achieved in 'getScopeNode' - // by finding the first node that encompasses a position, accounting for whether a node - // is "complete" to decide whether a position belongs to the node. - // - // However, at the end of an identifier, we are interested in the scope of the identifier - // itself, but fall outside of the identifier. For instance: - // - // xyz => x$ - // - // the cursor is outside of both the 'x' and the arrow function 'xyz => x', - // so 'xyz' is not returned in our results. - // - // We define 'adjustedPosition' so that we may appropriately account for - // being at the end of an identifier. The intention is that if requesting completion - // at the end of an identifier, it should be effectively equivalent to requesting completion - // anywhere inside/at the beginning of the identifier. So in the previous case, the - // 'adjustedPosition' will work as if requesting completion in the following: - // - // xyz => $x - // - // If previousToken !== contextToken, then - // - 'contextToken' was adjusted to the token prior to 'previousToken' - // because we were at the end of an identifier. - // - 'previousToken' is defined. - var adjustedPosition = previousToken !== contextToken ? - previousToken.getStart() : - position; - var scopeNode = getScopeNode(contextToken, adjustedPosition, sourceFile) || sourceFile; - /// TODO filter meaning based on the current context - var symbolMeanings = 793056 /* Type */ | 107455 /* Value */ | 1536 /* Namespace */ | 8388608 /* Alias */; - symbols = typeChecker.getSymbolsInScope(scopeNode, symbolMeanings); - return true; - } - /** - * Finds the first node that "embraces" the position, so that one may - * accurately aggregate locals from the closest containing scope. - */ - function getScopeNode(initialToken, position, sourceFile) { - var scope = initialToken; - while (scope && !ts.positionBelongsToNode(scope, position, sourceFile)) { - scope = scope.parent; - } - return scope; - } - function isCompletionListBlocker(contextToken) { - var start = new Date().getTime(); - var result = isInStringOrRegularExpressionOrTemplateLiteral(contextToken) || - isSolelyIdentifierDefinitionLocation(contextToken) || - isDotOfNumericLiteral(contextToken) || - isInJsxText(contextToken); - log("getCompletionsAtPosition: isCompletionListBlocker: " + (new Date().getTime() - start)); - return result; - } - function isInJsxText(contextToken) { - if (contextToken.kind === 236 /* JsxText */) { - return true; - } - if (contextToken.kind === 27 /* GreaterThanToken */ && contextToken.parent) { - if (contextToken.parent.kind === 235 /* JsxOpeningElement */) { - return true; - } - if (contextToken.parent.kind === 237 /* JsxClosingElement */ || contextToken.parent.kind === 234 /* JsxSelfClosingElement */) { - return contextToken.parent.parent && contextToken.parent.parent.kind === 233 /* JsxElement */; - } - } - return false; - } - function isNewIdentifierDefinitionLocation(previousToken) { - if (previousToken) { - var containingNodeKind = previousToken.parent.kind; - switch (previousToken.kind) { - case 24 /* CommaToken */: - return containingNodeKind === 168 /* CallExpression */ // func( a, | - || containingNodeKind === 144 /* Constructor */ // constructor( a, | /* public, protected, private keywords are allowed here, so show completion */ - || containingNodeKind === 169 /* NewExpression */ // new C(a, | - || containingNodeKind === 164 /* ArrayLiteralExpression */ // [a, | - || containingNodeKind === 181 /* BinaryExpression */ // let x = (a, | - || containingNodeKind === 152 /* FunctionType */; // var x: (s: string, list| - case 17 /* OpenParenToken */: - return containingNodeKind === 168 /* CallExpression */ // func( | - || containingNodeKind === 144 /* Constructor */ // constructor( | - || containingNodeKind === 169 /* NewExpression */ // new C(a| - || containingNodeKind === 172 /* ParenthesizedExpression */ // let x = (a| - || containingNodeKind === 160 /* ParenthesizedType */; // function F(pred: (a| /* this can become an arrow function, where 'a' is the argument */ - case 19 /* OpenBracketToken */: - return containingNodeKind === 164 /* ArrayLiteralExpression */ // [ | - || containingNodeKind === 149 /* IndexSignature */ // [ | : string ] - || containingNodeKind === 136 /* ComputedPropertyName */; // [ | /* this can become an index signature */ - case 125 /* ModuleKeyword */: // module | - case 126 /* NamespaceKeyword */: - return true; - case 21 /* DotToken */: - return containingNodeKind === 218 /* ModuleDeclaration */; // module A.| - case 15 /* OpenBraceToken */: - return containingNodeKind === 214 /* ClassDeclaration */; // class A{ | - case 56 /* EqualsToken */: - return containingNodeKind === 211 /* VariableDeclaration */ // let x = a| - || containingNodeKind === 181 /* BinaryExpression */; // x = a| - case 12 /* TemplateHead */: - return containingNodeKind === 183 /* TemplateExpression */; // `aa ${| - case 13 /* TemplateMiddle */: - return containingNodeKind === 190 /* TemplateSpan */; // `aa ${10} dd ${| - case 112 /* PublicKeyword */: - case 110 /* PrivateKeyword */: - case 111 /* ProtectedKeyword */: - return containingNodeKind === 141 /* PropertyDeclaration */; // class A{ public | - } - // Previous token may have been a keyword that was converted to an identifier. - switch (previousToken.getText()) { - case "public": - case "protected": - case "private": - return true; - } - } - return false; - } - function isInStringOrRegularExpressionOrTemplateLiteral(contextToken) { - if (contextToken.kind === 9 /* StringLiteral */ - || contextToken.kind === 10 /* RegularExpressionLiteral */ - || ts.isTemplateLiteralKind(contextToken.kind)) { - var start_5 = contextToken.getStart(); - var end = contextToken.getEnd(); - // To be "in" one of these literals, the position has to be: - // 1. entirely within the token text. - // 2. at the end position of an unterminated token. - // 3. at the end of a regular expression (due to trailing flags like '/foo/g'). - if (start_5 < position && position < end) { - return true; - } - if (position === end) { - return !!contextToken.isUnterminated - || contextToken.kind === 10 /* RegularExpressionLiteral */; - } - } - return false; - } - /** - * Aggregates relevant symbols for completion in object literals and object binding patterns. - * Relevant symbols are stored in the captured 'symbols' variable. - * - * @returns true if 'symbols' was successfully populated; false otherwise. - */ - function tryGetObjectLikeCompletionSymbols(objectLikeContainer) { - // We're looking up possible property names from contextual/inferred/declared type. - isMemberCompletion = true; - var typeForObject; - var existingMembers; - if (objectLikeContainer.kind === 165 /* ObjectLiteralExpression */) { - // We are completing on contextual types, but may also include properties - // other than those within the declared type. - isNewIdentifierLocation = true; - typeForObject = typeChecker.getContextualType(objectLikeContainer); - existingMembers = objectLikeContainer.properties; - } - else if (objectLikeContainer.kind === 161 /* ObjectBindingPattern */) { - // We are *only* completing on properties from the type being destructured. - isNewIdentifierLocation = false; - var rootDeclaration = ts.getRootDeclaration(objectLikeContainer.parent); - if (ts.isVariableLike(rootDeclaration)) { - // We don't want to complete using the type acquired by the shape - // of the binding pattern; we are only interested in types acquired - // through type declaration or inference. - if (rootDeclaration.initializer || rootDeclaration.type) { - typeForObject = typeChecker.getTypeAtLocation(objectLikeContainer); - existingMembers = objectLikeContainer.elements; - } - } - else { - ts.Debug.fail("Root declaration is not variable-like."); - } - } - else { - ts.Debug.fail("Expected object literal or binding pattern, got " + objectLikeContainer.kind); - } - if (!typeForObject) { - return false; - } - var typeMembers = typeChecker.getPropertiesOfType(typeForObject); - if (typeMembers && typeMembers.length > 0) { - // Add filtered items to the completion list - symbols = filterObjectMembersList(typeMembers, existingMembers); - } - return true; - } - /** - * Aggregates relevant symbols for completion in import clauses and export clauses - * whose declarations have a module specifier; for instance, symbols will be aggregated for - * - * import { | } from "moduleName"; - * export { a as foo, | } from "moduleName"; - * - * but not for - * - * export { | }; - * - * Relevant symbols are stored in the captured 'symbols' variable. - * - * @returns true if 'symbols' was successfully populated; false otherwise. - */ - function tryGetImportOrExportClauseCompletionSymbols(namedImportsOrExports) { - var declarationKind = namedImportsOrExports.kind === 225 /* NamedImports */ ? - 222 /* ImportDeclaration */ : - 228 /* ExportDeclaration */; - var importOrExportDeclaration = ts.getAncestor(namedImportsOrExports, declarationKind); - var moduleSpecifier = importOrExportDeclaration.moduleSpecifier; - if (!moduleSpecifier) { - return false; - } - isMemberCompletion = true; - isNewIdentifierLocation = false; - var exports; - var moduleSpecifierSymbol = typeChecker.getSymbolAtLocation(importOrExportDeclaration.moduleSpecifier); - if (moduleSpecifierSymbol) { - exports = typeChecker.getExportsOfModule(moduleSpecifierSymbol); - } - symbols = exports ? filterNamedImportOrExportCompletionItems(exports, namedImportsOrExports.elements) : emptyArray; - return true; - } - /** - * Returns the immediate owning object literal or binding pattern of a context token, - * on the condition that one exists and that the context implies completion should be given. - */ - function tryGetObjectLikeCompletionContainer(contextToken) { - if (contextToken) { - switch (contextToken.kind) { - case 15 /* OpenBraceToken */: // let x = { | - case 24 /* CommaToken */: - var parent_10 = contextToken.parent; - if (parent_10 && (parent_10.kind === 165 /* ObjectLiteralExpression */ || parent_10.kind === 161 /* ObjectBindingPattern */)) { - return parent_10; - } - break; - } - } - return undefined; - } - /** - * Returns the containing list of named imports or exports of a context token, - * on the condition that one exists and that the context implies completion should be given. - */ - function tryGetNamedImportsOrExportsForCompletion(contextToken) { - if (contextToken) { - switch (contextToken.kind) { - case 15 /* OpenBraceToken */: // import { | - case 24 /* CommaToken */: - switch (contextToken.parent.kind) { - case 225 /* NamedImports */: - case 229 /* NamedExports */: - return contextToken.parent; - } - } - } - return undefined; - } - function tryGetContainingJsxElement(contextToken) { - if (contextToken) { - var parent_11 = contextToken.parent; - switch (contextToken.kind) { - case 26 /* LessThanSlashToken */: - case 39 /* SlashToken */: - case 69 /* Identifier */: - case 238 /* JsxAttribute */: - case 239 /* JsxSpreadAttribute */: - if (parent_11 && (parent_11.kind === 234 /* JsxSelfClosingElement */ || parent_11.kind === 235 /* JsxOpeningElement */)) { - return parent_11; - } - else if (parent_11.kind === 238 /* JsxAttribute */) { - return parent_11.parent; - } - break; - // The context token is the closing } or " of an attribute, which means - // its parent is a JsxExpression, whose parent is a JsxAttribute, - // whose parent is a JsxOpeningLikeElement - case 9 /* StringLiteral */: - if (parent_11 && ((parent_11.kind === 238 /* JsxAttribute */) || (parent_11.kind === 239 /* JsxSpreadAttribute */))) { - return parent_11.parent; - } - break; - case 16 /* CloseBraceToken */: - if (parent_11 && - parent_11.kind === 240 /* JsxExpression */ && - parent_11.parent && - (parent_11.parent.kind === 238 /* JsxAttribute */)) { - return parent_11.parent.parent; - } - if (parent_11 && parent_11.kind === 239 /* JsxSpreadAttribute */) { - return parent_11.parent; - } - break; - } - } - return undefined; - } - function isFunction(kind) { - switch (kind) { - case 173 /* FunctionExpression */: - case 174 /* ArrowFunction */: - case 213 /* FunctionDeclaration */: - case 143 /* MethodDeclaration */: - case 142 /* MethodSignature */: - case 145 /* GetAccessor */: - case 146 /* SetAccessor */: - case 147 /* CallSignature */: - case 148 /* ConstructSignature */: - case 149 /* IndexSignature */: - return true; - } - return false; - } - /** - * @returns true if we are certain that the currently edited location must define a new location; false otherwise. - */ - function isSolelyIdentifierDefinitionLocation(contextToken) { - var containingNodeKind = contextToken.parent.kind; - switch (contextToken.kind) { - case 24 /* CommaToken */: - return containingNodeKind === 211 /* VariableDeclaration */ || - containingNodeKind === 212 /* VariableDeclarationList */ || - containingNodeKind === 193 /* VariableStatement */ || - containingNodeKind === 217 /* EnumDeclaration */ || - isFunction(containingNodeKind) || - containingNodeKind === 214 /* ClassDeclaration */ || - containingNodeKind === 186 /* ClassExpression */ || - containingNodeKind === 215 /* InterfaceDeclaration */ || - containingNodeKind === 162 /* ArrayBindingPattern */ || - containingNodeKind === 216 /* TypeAliasDeclaration */; // type Map, K, | - case 21 /* DotToken */: - return containingNodeKind === 162 /* ArrayBindingPattern */; // var [.| - case 54 /* ColonToken */: - return containingNodeKind === 163 /* BindingElement */; // var {x :html| - case 19 /* OpenBracketToken */: - return containingNodeKind === 162 /* ArrayBindingPattern */; // var [x| - case 17 /* OpenParenToken */: - return containingNodeKind === 244 /* CatchClause */ || - isFunction(containingNodeKind); - case 15 /* OpenBraceToken */: - return containingNodeKind === 217 /* EnumDeclaration */ || - containingNodeKind === 215 /* InterfaceDeclaration */ || - containingNodeKind === 155 /* TypeLiteral */; // let x : { | - case 23 /* SemicolonToken */: - return containingNodeKind === 140 /* PropertySignature */ && - contextToken.parent && contextToken.parent.parent && - (contextToken.parent.parent.kind === 215 /* InterfaceDeclaration */ || - contextToken.parent.parent.kind === 155 /* TypeLiteral */); // let x : { a; | - case 25 /* LessThanToken */: - return containingNodeKind === 214 /* ClassDeclaration */ || - containingNodeKind === 186 /* ClassExpression */ || - containingNodeKind === 215 /* InterfaceDeclaration */ || - containingNodeKind === 216 /* TypeAliasDeclaration */ || - isFunction(containingNodeKind); - case 113 /* StaticKeyword */: - return containingNodeKind === 141 /* PropertyDeclaration */; - case 22 /* DotDotDotToken */: - return containingNodeKind === 138 /* Parameter */ || - (contextToken.parent && contextToken.parent.parent && - contextToken.parent.parent.kind === 162 /* ArrayBindingPattern */); // var [...z| - case 112 /* PublicKeyword */: - case 110 /* PrivateKeyword */: - case 111 /* ProtectedKeyword */: - return containingNodeKind === 138 /* Parameter */; - case 116 /* AsKeyword */: - return containingNodeKind === 226 /* ImportSpecifier */ || - containingNodeKind === 230 /* ExportSpecifier */ || - containingNodeKind === 224 /* NamespaceImport */; - case 73 /* ClassKeyword */: - case 81 /* EnumKeyword */: - case 107 /* InterfaceKeyword */: - case 87 /* FunctionKeyword */: - case 102 /* VarKeyword */: - case 123 /* GetKeyword */: - case 129 /* SetKeyword */: - case 89 /* ImportKeyword */: - case 108 /* LetKeyword */: - case 74 /* ConstKeyword */: - case 114 /* YieldKeyword */: - case 132 /* TypeKeyword */: - return true; - } - // Previous token may have been a keyword that was converted to an identifier. - switch (contextToken.getText()) { - case "abstract": - case "async": - case "class": - case "const": - case "declare": - case "enum": - case "function": - case "interface": - case "let": - case "private": - case "protected": - case "public": - case "static": - case "var": - case "yield": - return true; - } - return false; - } - function isDotOfNumericLiteral(contextToken) { - if (contextToken.kind === 8 /* NumericLiteral */) { - var text = contextToken.getFullText(); - return text.charAt(text.length - 1) === "."; - } - return false; - } - /** - * Filters out completion suggestions for named imports or exports. - * - * @param exportsOfModule The list of symbols which a module exposes. - * @param namedImportsOrExports The list of existing import/export specifiers in the import/export clause. - * - * @returns Symbols to be suggested at an import/export clause, barring those whose named imports/exports - * do not occur at the current position and have not otherwise been typed. - */ - function filterNamedImportOrExportCompletionItems(exportsOfModule, namedImportsOrExports) { - var exisingImportsOrExports = {}; - for (var _i = 0; _i < namedImportsOrExports.length; _i++) { - var element = namedImportsOrExports[_i]; - // If this is the current item we are editing right now, do not filter it out - if (element.getStart() <= position && position <= element.getEnd()) { - continue; - } - var name_32 = element.propertyName || element.name; - exisingImportsOrExports[name_32.text] = true; - } - if (ts.isEmpty(exisingImportsOrExports)) { - return exportsOfModule; - } - return ts.filter(exportsOfModule, function (e) { return !ts.lookUp(exisingImportsOrExports, e.name); }); - } - /** - * Filters out completion suggestions for named imports or exports. - * - * @returns Symbols to be suggested in an object binding pattern or object literal expression, barring those whose declarations - * do not occur at the current position and have not otherwise been typed. - */ - function filterObjectMembersList(contextualMemberSymbols, existingMembers) { - if (!existingMembers || existingMembers.length === 0) { - return contextualMemberSymbols; - } - var existingMemberNames = {}; - for (var _i = 0; _i < existingMembers.length; _i++) { - var m = existingMembers[_i]; - // Ignore omitted expressions for missing members - if (m.kind !== 245 /* PropertyAssignment */ && - m.kind !== 246 /* ShorthandPropertyAssignment */ && - m.kind !== 163 /* BindingElement */) { - continue; - } - // If this is the current item we are editing right now, do not filter it out - if (m.getStart() <= position && position <= m.getEnd()) { - continue; - } - var existingName = void 0; - if (m.kind === 163 /* BindingElement */ && m.propertyName) { - existingName = m.propertyName.text; - } - else { - // TODO(jfreeman): Account for computed property name - // NOTE: if one only performs this step when m.name is an identifier, - // things like '__proto__' are not filtered out. - existingName = m.name.text; - } - existingMemberNames[existingName] = true; - } - return ts.filter(contextualMemberSymbols, function (m) { return !ts.lookUp(existingMemberNames, m.name); }); - } - /** - * Filters out completion suggestions from 'symbols' according to existing JSX attributes. - * - * @returns Symbols to be suggested in a JSX element, barring those whose attributes - * do not occur at the current position and have not otherwise been typed. - */ - function filterJsxAttributes(symbols, attributes) { - var seenNames = {}; - for (var _i = 0; _i < attributes.length; _i++) { - var attr = attributes[_i]; - // If this is the current item we are editing right now, do not filter it out - if (attr.getStart() <= position && position <= attr.getEnd()) { - continue; - } - if (attr.kind === 238 /* JsxAttribute */) { - seenNames[attr.name.text] = true; - } - } - return ts.filter(symbols, function (a) { return !ts.lookUp(seenNames, a.name); }); - } - } - function getCompletionsAtPosition(fileName, position) { - synchronizeHostData(); - var completionData = getCompletionData(fileName, position); - if (!completionData) { - return undefined; - } - var symbols = completionData.symbols, isMemberCompletion = completionData.isMemberCompletion, isNewIdentifierLocation = completionData.isNewIdentifierLocation, location = completionData.location, isRightOfDot = completionData.isRightOfDot, isJsDocTagName = completionData.isJsDocTagName; - var entries; - if (isJsDocTagName) { - // If the current position is a jsDoc tag name, only tag names should be provided for completion - return { isMemberCompletion: false, isNewIdentifierLocation: false, entries: getAllJsDocCompletionEntries() }; - } - if (isRightOfDot && ts.isJavaScript(fileName)) { - entries = getCompletionEntriesFromSymbols(symbols); - ts.addRange(entries, getJavaScriptCompletionEntries()); - } - else { - if (!symbols || symbols.length === 0) { - return undefined; - } - entries = getCompletionEntriesFromSymbols(symbols); - } - // Add keywords if this is not a member completion list - if (!isMemberCompletion && !isJsDocTagName) { - ts.addRange(entries, keywordCompletions); - } - return { isMemberCompletion: isMemberCompletion, isNewIdentifierLocation: isNewIdentifierLocation, entries: entries }; - function getJavaScriptCompletionEntries() { - var entries = []; - var allNames = {}; - var target = program.getCompilerOptions().target; - for (var _i = 0, _a = program.getSourceFiles(); _i < _a.length; _i++) { - var sourceFile = _a[_i]; - var nameTable = getNameTable(sourceFile); - for (var name_33 in nameTable) { - if (!allNames[name_33]) { - allNames[name_33] = name_33; - var displayName = getCompletionEntryDisplayName(name_33, target, /*performCharacterChecks:*/ true); - if (displayName) { - var entry = { - name: displayName, - kind: ScriptElementKind.warning, - kindModifiers: "", - sortText: "1" - }; - entries.push(entry); - } - } - } - } - return entries; - } - function getAllJsDocCompletionEntries() { - return jsDocCompletionEntries || (jsDocCompletionEntries = ts.map(jsDocTagNames, function (tagName) { - return { - name: tagName, - kind: ScriptElementKind.keyword, - kindModifiers: "", - sortText: "0" - }; - })); - } - function createCompletionEntry(symbol, location) { - // Try to get a valid display name for this symbol, if we could not find one, then ignore it. - // We would like to only show things that can be added after a dot, so for instance numeric properties can - // not be accessed with a dot (a.1 <- invalid) - var displayName = getCompletionEntryDisplayNameForSymbol(symbol, program.getCompilerOptions().target, /*performCharacterChecks:*/ true, location); - if (!displayName) { - return undefined; - } - // TODO(drosen): Right now we just permit *all* semantic meanings when calling - // 'getSymbolKind' which is permissible given that it is backwards compatible; but - // really we should consider passing the meaning for the node so that we don't report - // that a suggestion for a value is an interface. We COULD also just do what - // 'getSymbolModifiers' does, which is to use the first declaration. - // Use a 'sortText' of 0' so that all symbol completion entries come before any other - // entries (like JavaScript identifier entries). - return { - name: displayName, - kind: getSymbolKind(symbol, location), - kindModifiers: getSymbolModifiers(symbol), - sortText: "0" - }; - } - function getCompletionEntriesFromSymbols(symbols) { - var start = new Date().getTime(); - var entries = []; - if (symbols) { - var nameToSymbol = {}; - for (var _i = 0; _i < symbols.length; _i++) { - var symbol = symbols[_i]; - var entry = createCompletionEntry(symbol, location); - if (entry) { - var id = ts.escapeIdentifier(entry.name); - if (!ts.lookUp(nameToSymbol, id)) { - entries.push(entry); - nameToSymbol[id] = symbol; - } - } - } - } - log("getCompletionsAtPosition: getCompletionEntriesFromSymbols: " + (new Date().getTime() - start)); - return entries; - } - } - function getCompletionEntryDetails(fileName, position, entryName) { - synchronizeHostData(); - // Compute all the completion symbols again. - var completionData = getCompletionData(fileName, position); - if (completionData) { - var symbols = completionData.symbols, location_2 = completionData.location; - // Find the symbol with the matching entry name. - var target = program.getCompilerOptions().target; - // We don't need to perform character checks here because we're only comparing the - // name against 'entryName' (which is known to be good), not building a new - // completion entry. - var symbol = ts.forEach(symbols, function (s) { return getCompletionEntryDisplayNameForSymbol(s, target, /*performCharacterChecks:*/ false, location_2) === entryName ? s : undefined; }); - if (symbol) { - var _a = getSymbolDisplayPartsDocumentationAndSymbolKind(symbol, getValidSourceFile(fileName), location_2, location_2, 7 /* All */), displayParts = _a.displayParts, documentation = _a.documentation, symbolKind = _a.symbolKind; - return { - name: entryName, - kindModifiers: getSymbolModifiers(symbol), - kind: symbolKind, - displayParts: displayParts, - documentation: documentation - }; - } - } - // Didn't find a symbol with this name. See if we can find a keyword instead. - var keywordCompletion = ts.forEach(keywordCompletions, function (c) { return c.name === entryName; }); - if (keywordCompletion) { - return { - name: entryName, - kind: ScriptElementKind.keyword, - kindModifiers: ScriptElementKindModifier.none, - displayParts: [ts.displayPart(entryName, SymbolDisplayPartKind.keyword)], - documentation: undefined - }; - } - return undefined; - } - // TODO(drosen): use contextual SemanticMeaning. - function getSymbolKind(symbol, location) { - var flags = symbol.getFlags(); - if (flags & 32 /* Class */) - return ts.getDeclarationOfKind(symbol, 186 /* ClassExpression */) ? - ScriptElementKind.localClassElement : ScriptElementKind.classElement; - if (flags & 384 /* Enum */) - return ScriptElementKind.enumElement; - if (flags & 524288 /* TypeAlias */) - return ScriptElementKind.typeElement; - if (flags & 64 /* Interface */) - return ScriptElementKind.interfaceElement; - if (flags & 262144 /* TypeParameter */) - return ScriptElementKind.typeParameterElement; - var result = getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar(symbol, flags, location); - if (result === ScriptElementKind.unknown) { - if (flags & 262144 /* TypeParameter */) - return ScriptElementKind.typeParameterElement; - if (flags & 8 /* EnumMember */) - return ScriptElementKind.variableElement; - if (flags & 8388608 /* Alias */) - return ScriptElementKind.alias; - if (flags & 1536 /* Module */) - return ScriptElementKind.moduleElement; - } - return result; - } - function getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar(symbol, flags, location) { - var typeChecker = program.getTypeChecker(); - if (typeChecker.isUndefinedSymbol(symbol)) { - return ScriptElementKind.variableElement; - } - if (typeChecker.isArgumentsSymbol(symbol)) { - return ScriptElementKind.localVariableElement; - } - if (flags & 3 /* Variable */) { - if (ts.isFirstDeclarationOfSymbolParameter(symbol)) { - return ScriptElementKind.parameterElement; - } - else if (symbol.valueDeclaration && ts.isConst(symbol.valueDeclaration)) { - return ScriptElementKind.constElement; - } - else if (ts.forEach(symbol.declarations, ts.isLet)) { - return ScriptElementKind.letElement; - } - return isLocalVariableOrFunction(symbol) ? ScriptElementKind.localVariableElement : ScriptElementKind.variableElement; - } - if (flags & 16 /* Function */) - return isLocalVariableOrFunction(symbol) ? ScriptElementKind.localFunctionElement : ScriptElementKind.functionElement; - if (flags & 32768 /* GetAccessor */) - return ScriptElementKind.memberGetAccessorElement; - if (flags & 65536 /* SetAccessor */) - return ScriptElementKind.memberSetAccessorElement; - if (flags & 8192 /* Method */) - return ScriptElementKind.memberFunctionElement; - if (flags & 16384 /* Constructor */) - return ScriptElementKind.constructorImplementationElement; - if (flags & 4 /* Property */) { - if (flags & 268435456 /* SyntheticProperty */) { - // If union property is result of union of non method (property/accessors/variables), it is labeled as property - var unionPropertyKind = ts.forEach(typeChecker.getRootSymbols(symbol), function (rootSymbol) { - var rootSymbolFlags = rootSymbol.getFlags(); - if (rootSymbolFlags & (98308 /* PropertyOrAccessor */ | 3 /* Variable */)) { - return ScriptElementKind.memberVariableElement; - } - ts.Debug.assert(!!(rootSymbolFlags & 8192 /* Method */)); - }); - if (!unionPropertyKind) { - // If this was union of all methods, - //make sure it has call signatures before we can label it as method - var typeOfUnionProperty = typeChecker.getTypeOfSymbolAtLocation(symbol, location); - if (typeOfUnionProperty.getCallSignatures().length) { - return ScriptElementKind.memberFunctionElement; - } - return ScriptElementKind.memberVariableElement; - } - return unionPropertyKind; - } - return ScriptElementKind.memberVariableElement; - } - return ScriptElementKind.unknown; - } - function getSymbolModifiers(symbol) { - return symbol && symbol.declarations && symbol.declarations.length > 0 - ? ts.getNodeModifiers(symbol.declarations[0]) - : ScriptElementKindModifier.none; - } - // TODO(drosen): Currently completion entry details passes the SemanticMeaning.All instead of using semanticMeaning of location - function getSymbolDisplayPartsDocumentationAndSymbolKind(symbol, sourceFile, enclosingDeclaration, location, semanticMeaning) { - if (semanticMeaning === void 0) { semanticMeaning = getMeaningFromLocation(location); } - var typeChecker = program.getTypeChecker(); - var displayParts = []; - var documentation; - var symbolFlags = symbol.flags; - var symbolKind = getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar(symbol, symbolFlags, location); - var hasAddedSymbolInfo; - var type; - // Class at constructor site need to be shown as constructor apart from property,method, vars - if (symbolKind !== ScriptElementKind.unknown || symbolFlags & 32 /* Class */ || symbolFlags & 8388608 /* Alias */) { - // If it is accessor they are allowed only if location is at name of the accessor - if (symbolKind === ScriptElementKind.memberGetAccessorElement || symbolKind === ScriptElementKind.memberSetAccessorElement) { - symbolKind = ScriptElementKind.memberVariableElement; - } - var signature; - type = typeChecker.getTypeOfSymbolAtLocation(symbol, location); - if (type) { - if (location.parent && location.parent.kind === 166 /* PropertyAccessExpression */) { - var right = location.parent.name; - // Either the location is on the right of a property access, or on the left and the right is missing - if (right === location || (right && right.getFullWidth() === 0)) { - location = location.parent; - } - } - // try get the call/construct signature from the type if it matches - var callExpression; - if (location.kind === 168 /* CallExpression */ || location.kind === 169 /* NewExpression */) { - callExpression = location; - } - else if (isCallExpressionTarget(location) || isNewExpressionTarget(location)) { - callExpression = location.parent; - } - if (callExpression) { - var candidateSignatures = []; - signature = typeChecker.getResolvedSignature(callExpression, candidateSignatures); - if (!signature && candidateSignatures.length) { - // Use the first candidate: - signature = candidateSignatures[0]; - } - var useConstructSignatures = callExpression.kind === 169 /* NewExpression */ || callExpression.expression.kind === 95 /* 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 - // either the original signature or its target, so check for either - signature = allSignatures.length ? allSignatures[0] : undefined; - } - if (signature) { - if (useConstructSignatures && (symbolFlags & 32 /* Class */)) { - // Constructor - symbolKind = ScriptElementKind.constructorImplementationElement; - addPrefixForAnyFunctionOrVar(type.symbol, symbolKind); - } - else if (symbolFlags & 8388608 /* Alias */) { - symbolKind = ScriptElementKind.alias; - pushTypePart(symbolKind); - displayParts.push(ts.spacePart()); - if (useConstructSignatures) { - displayParts.push(ts.keywordPart(92 /* NewKeyword */)); - displayParts.push(ts.spacePart()); - } - addFullSymbolName(symbol); - } - else { - addPrefixForAnyFunctionOrVar(symbol, symbolKind); - } - switch (symbolKind) { - case ScriptElementKind.memberVariableElement: - case ScriptElementKind.variableElement: - case ScriptElementKind.constElement: - case ScriptElementKind.letElement: - case ScriptElementKind.parameterElement: - case ScriptElementKind.localVariableElement: - // If it is call or construct signature of lambda's write type name - displayParts.push(ts.punctuationPart(54 /* ColonToken */)); - displayParts.push(ts.spacePart()); - if (useConstructSignatures) { - displayParts.push(ts.keywordPart(92 /* NewKeyword */)); - displayParts.push(ts.spacePart()); - } - if (!(type.flags & 65536 /* Anonymous */)) { - ts.addRange(displayParts, ts.symbolToDisplayParts(typeChecker, type.symbol, enclosingDeclaration, /*meaning*/ undefined, 1 /* WriteTypeParametersOrArguments */)); - } - addSignatureDisplayParts(signature, allSignatures, 8 /* WriteArrowStyleSignature */); - break; - default: - // Just signature - addSignatureDisplayParts(signature, allSignatures); - } - hasAddedSymbolInfo = true; - } - } - else if ((isNameOfFunctionDeclaration(location) && !(symbol.flags & 98304 /* Accessor */)) || - (location.kind === 121 /* ConstructorKeyword */ && location.parent.kind === 144 /* Constructor */)) { - // get the signature from the declaration and write it - var functionDeclaration = location.parent; - var allSignatures = functionDeclaration.kind === 144 /* Constructor */ ? type.getConstructSignatures() : type.getCallSignatures(); - if (!typeChecker.isImplementationOfOverload(functionDeclaration)) { - signature = typeChecker.getSignatureFromDeclaration(functionDeclaration); - } - else { - signature = allSignatures[0]; - } - if (functionDeclaration.kind === 144 /* Constructor */) { - // show (constructor) Type(...) signature - symbolKind = ScriptElementKind.constructorImplementationElement; - addPrefixForAnyFunctionOrVar(type.symbol, symbolKind); - } - else { - // (function/method) symbol(..signature) - addPrefixForAnyFunctionOrVar(functionDeclaration.kind === 147 /* CallSignature */ && - !(type.symbol.flags & 2048 /* TypeLiteral */ || type.symbol.flags & 4096 /* ObjectLiteral */) ? type.symbol : symbol, symbolKind); - } - addSignatureDisplayParts(signature, allSignatures); - hasAddedSymbolInfo = true; - } - } - } - if (symbolFlags & 32 /* Class */ && !hasAddedSymbolInfo) { - if (ts.getDeclarationOfKind(symbol, 186 /* ClassExpression */)) { - // Special case for class expressions because we would like to indicate that - // the class name is local to the class body (similar to function expression) - // (local class) class - pushTypePart(ScriptElementKind.localClassElement); - } - else { - // Class declaration has name which is not local. - displayParts.push(ts.keywordPart(73 /* ClassKeyword */)); - } - displayParts.push(ts.spacePart()); - addFullSymbolName(symbol); - writeTypeParametersOfSymbol(symbol, sourceFile); - } - if ((symbolFlags & 64 /* Interface */) && (semanticMeaning & 2 /* Type */)) { - addNewLineIfDisplayPartsExist(); - displayParts.push(ts.keywordPart(107 /* InterfaceKeyword */)); - displayParts.push(ts.spacePart()); - addFullSymbolName(symbol); - writeTypeParametersOfSymbol(symbol, sourceFile); - } - if (symbolFlags & 524288 /* TypeAlias */) { - addNewLineIfDisplayPartsExist(); - displayParts.push(ts.keywordPart(132 /* TypeKeyword */)); - displayParts.push(ts.spacePart()); - addFullSymbolName(symbol); - writeTypeParametersOfSymbol(symbol, sourceFile); - displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(56 /* EqualsToken */)); - displayParts.push(ts.spacePart()); - ts.addRange(displayParts, ts.typeToDisplayParts(typeChecker, typeChecker.getDeclaredTypeOfSymbol(symbol), enclosingDeclaration)); - } - if (symbolFlags & 384 /* Enum */) { - addNewLineIfDisplayPartsExist(); - if (ts.forEach(symbol.declarations, ts.isConstEnumDeclaration)) { - displayParts.push(ts.keywordPart(74 /* ConstKeyword */)); - displayParts.push(ts.spacePart()); - } - displayParts.push(ts.keywordPart(81 /* EnumKeyword */)); - displayParts.push(ts.spacePart()); - addFullSymbolName(symbol); - } - if (symbolFlags & 1536 /* Module */) { - addNewLineIfDisplayPartsExist(); - var declaration = ts.getDeclarationOfKind(symbol, 218 /* ModuleDeclaration */); - var isNamespace = declaration && declaration.name && declaration.name.kind === 69 /* Identifier */; - displayParts.push(ts.keywordPart(isNamespace ? 126 /* NamespaceKeyword */ : 125 /* ModuleKeyword */)); - displayParts.push(ts.spacePart()); - addFullSymbolName(symbol); - } - if ((symbolFlags & 262144 /* TypeParameter */) && (semanticMeaning & 2 /* Type */)) { - addNewLineIfDisplayPartsExist(); - displayParts.push(ts.punctuationPart(17 /* OpenParenToken */)); - displayParts.push(ts.textPart("type parameter")); - displayParts.push(ts.punctuationPart(18 /* CloseParenToken */)); - displayParts.push(ts.spacePart()); - addFullSymbolName(symbol); - displayParts.push(ts.spacePart()); - displayParts.push(ts.keywordPart(90 /* InKeyword */)); - displayParts.push(ts.spacePart()); - if (symbol.parent) { - // Class/Interface type parameter - addFullSymbolName(symbol.parent, enclosingDeclaration); - writeTypeParametersOfSymbol(symbol.parent, enclosingDeclaration); - } - else { - // Method/function type parameter - var container = ts.getContainingFunction(location); - if (container) { - var signatureDeclaration = ts.getDeclarationOfKind(symbol, 137 /* TypeParameter */).parent; - var signature = typeChecker.getSignatureFromDeclaration(signatureDeclaration); - if (signatureDeclaration.kind === 148 /* ConstructSignature */) { - displayParts.push(ts.keywordPart(92 /* NewKeyword */)); - displayParts.push(ts.spacePart()); - } - else if (signatureDeclaration.kind !== 147 /* CallSignature */ && signatureDeclaration.name) { - addFullSymbolName(signatureDeclaration.symbol); - } - ts.addRange(displayParts, ts.signatureToDisplayParts(typeChecker, signature, sourceFile, 32 /* WriteTypeArgumentsOfSignature */)); - } - else { - // Type aliash type parameter - // For example - // type list = T[]; // Both T will go through same code path - var declaration = ts.getDeclarationOfKind(symbol, 137 /* TypeParameter */).parent; - displayParts.push(ts.keywordPart(132 /* TypeKeyword */)); - displayParts.push(ts.spacePart()); - addFullSymbolName(declaration.symbol); - writeTypeParametersOfSymbol(declaration.symbol, sourceFile); - } - } - } - if (symbolFlags & 8 /* EnumMember */) { - addPrefixForAnyFunctionOrVar(symbol, "enum member"); - var declaration = symbol.declarations[0]; - if (declaration.kind === 247 /* EnumMember */) { - var constantValue = typeChecker.getConstantValue(declaration); - if (constantValue !== undefined) { - displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(56 /* EqualsToken */)); - displayParts.push(ts.spacePart()); - displayParts.push(ts.displayPart(constantValue.toString(), SymbolDisplayPartKind.numericLiteral)); - } - } - } - if (symbolFlags & 8388608 /* Alias */) { - addNewLineIfDisplayPartsExist(); - displayParts.push(ts.keywordPart(89 /* ImportKeyword */)); - displayParts.push(ts.spacePart()); - addFullSymbolName(symbol); - ts.forEach(symbol.declarations, function (declaration) { - if (declaration.kind === 221 /* ImportEqualsDeclaration */) { - var importEqualsDeclaration = declaration; - if (ts.isExternalModuleImportEqualsDeclaration(importEqualsDeclaration)) { - displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(56 /* EqualsToken */)); - displayParts.push(ts.spacePart()); - displayParts.push(ts.keywordPart(127 /* RequireKeyword */)); - displayParts.push(ts.punctuationPart(17 /* OpenParenToken */)); - displayParts.push(ts.displayPart(ts.getTextOfNode(ts.getExternalModuleImportEqualsDeclarationExpression(importEqualsDeclaration)), SymbolDisplayPartKind.stringLiteral)); - displayParts.push(ts.punctuationPart(18 /* CloseParenToken */)); - } - else { - var internalAliasSymbol = typeChecker.getSymbolAtLocation(importEqualsDeclaration.moduleReference); - if (internalAliasSymbol) { - displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(56 /* EqualsToken */)); - displayParts.push(ts.spacePart()); - addFullSymbolName(internalAliasSymbol, enclosingDeclaration); - } - } - return true; - } - }); - } - if (!hasAddedSymbolInfo) { - if (symbolKind !== ScriptElementKind.unknown) { - if (type) { - addPrefixForAnyFunctionOrVar(symbol, symbolKind); - // For properties, variables and local vars: show the type - if (symbolKind === ScriptElementKind.memberVariableElement || - symbolFlags & 3 /* Variable */ || - symbolKind === ScriptElementKind.localVariableElement) { - displayParts.push(ts.punctuationPart(54 /* ColonToken */)); - displayParts.push(ts.spacePart()); - // If the type is type parameter, format it specially - if (type.symbol && type.symbol.flags & 262144 /* TypeParameter */) { - var typeParameterParts = ts.mapToDisplayParts(function (writer) { - typeChecker.getSymbolDisplayBuilder().buildTypeParameterDisplay(type, writer, enclosingDeclaration); - }); - ts.addRange(displayParts, typeParameterParts); - } - else { - ts.addRange(displayParts, ts.typeToDisplayParts(typeChecker, type, enclosingDeclaration)); - } - } - else if (symbolFlags & 16 /* Function */ || - symbolFlags & 8192 /* Method */ || - symbolFlags & 16384 /* Constructor */ || - symbolFlags & 131072 /* Signature */ || - symbolFlags & 98304 /* Accessor */ || - symbolKind === ScriptElementKind.memberFunctionElement) { - var allSignatures = type.getCallSignatures(); - addSignatureDisplayParts(allSignatures[0], allSignatures); - } - } - } - else { - symbolKind = getSymbolKind(symbol, location); - } - } - if (!documentation) { - documentation = symbol.getDocumentationComment(); - } - return { displayParts: displayParts, documentation: documentation, symbolKind: symbolKind }; - function addNewLineIfDisplayPartsExist() { - if (displayParts.length) { - displayParts.push(ts.lineBreakPart()); - } - } - function addFullSymbolName(symbol, enclosingDeclaration) { - var fullSymbolDisplayParts = ts.symbolToDisplayParts(typeChecker, symbol, enclosingDeclaration || sourceFile, /*meaning*/ undefined, 1 /* WriteTypeParametersOrArguments */ | 2 /* UseOnlyExternalAliasing */); - ts.addRange(displayParts, fullSymbolDisplayParts); - } - function addPrefixForAnyFunctionOrVar(symbol, symbolKind) { - addNewLineIfDisplayPartsExist(); - if (symbolKind) { - pushTypePart(symbolKind); - displayParts.push(ts.spacePart()); - addFullSymbolName(symbol); - } - } - function pushTypePart(symbolKind) { - switch (symbolKind) { - case ScriptElementKind.variableElement: - case ScriptElementKind.functionElement: - case ScriptElementKind.letElement: - case ScriptElementKind.constElement: - case ScriptElementKind.constructorImplementationElement: - displayParts.push(ts.textOrKeywordPart(symbolKind)); - return; - default: - displayParts.push(ts.punctuationPart(17 /* OpenParenToken */)); - displayParts.push(ts.textOrKeywordPart(symbolKind)); - displayParts.push(ts.punctuationPart(18 /* CloseParenToken */)); - return; - } - } - function addSignatureDisplayParts(signature, allSignatures, flags) { - 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.displayPart((allSignatures.length - 1).toString(), SymbolDisplayPartKind.numericLiteral)); - displayParts.push(ts.spacePart()); - displayParts.push(ts.textPart(allSignatures.length === 2 ? "overload" : "overloads")); - displayParts.push(ts.punctuationPart(18 /* CloseParenToken */)); - } - documentation = signature.getDocumentationComment(); - } - function writeTypeParametersOfSymbol(symbol, enclosingDeclaration) { - var typeParameterParts = ts.mapToDisplayParts(function (writer) { - typeChecker.getSymbolDisplayBuilder().buildTypeParameterDisplayFromSymbol(symbol, writer, enclosingDeclaration); - }); - ts.addRange(displayParts, typeParameterParts); - } - } - function getQuickInfoAtPosition(fileName, position) { - synchronizeHostData(); - var sourceFile = getValidSourceFile(fileName); - var node = ts.getTouchingPropertyName(sourceFile, position); - if (!node) { - return undefined; - } - if (isLabelName(node)) { - return undefined; - } - var typeChecker = program.getTypeChecker(); - var symbol = typeChecker.getSymbolAtLocation(node); - if (!symbol) { - // Try getting just type at this position and show - switch (node.kind) { - case 69 /* Identifier */: - case 166 /* PropertyAccessExpression */: - case 135 /* QualifiedName */: - case 97 /* ThisKeyword */: - case 95 /* SuperKeyword */: - // For the identifiers/this/super etc get the type at position - var type = typeChecker.getTypeAtLocation(node); - if (type) { - return { - kind: ScriptElementKind.unknown, - kindModifiers: ScriptElementKindModifier.none, - textSpan: ts.createTextSpan(node.getStart(), node.getWidth()), - displayParts: ts.typeToDisplayParts(typeChecker, type, getContainerNode(node)), - documentation: type.symbol ? type.symbol.getDocumentationComment() : undefined - }; - } - } - return undefined; - } - var displayPartsDocumentationsAndKind = getSymbolDisplayPartsDocumentationAndSymbolKind(symbol, sourceFile, getContainerNode(node), node); - return { - kind: displayPartsDocumentationsAndKind.symbolKind, - kindModifiers: getSymbolModifiers(symbol), - textSpan: ts.createTextSpan(node.getStart(), node.getWidth()), - displayParts: displayPartsDocumentationsAndKind.displayParts, - documentation: displayPartsDocumentationsAndKind.documentation - }; - } - function createDefinitionInfo(node, symbolKind, symbolName, containerName) { - return { - fileName: node.getSourceFile().fileName, - textSpan: ts.createTextSpanFromBounds(node.getStart(), node.getEnd()), - kind: symbolKind, - name: symbolName, - containerKind: undefined, - containerName: containerName - }; - } - function getDefinitionFromSymbol(symbol, node) { - var typeChecker = program.getTypeChecker(); - var result = []; - var declarations = symbol.getDeclarations(); - var symbolName = typeChecker.symbolToString(symbol); // Do not get scoped name, just the name of the symbol - var symbolKind = getSymbolKind(symbol, node); - var containerSymbol = symbol.parent; - var containerName = containerSymbol ? typeChecker.symbolToString(containerSymbol, node) : ""; - if (!tryAddConstructSignature(symbol, node, symbolKind, symbolName, containerName, result) && - !tryAddCallSignature(symbol, node, symbolKind, symbolName, containerName, result)) { - // Just add all the declarations. - ts.forEach(declarations, function (declaration) { - result.push(createDefinitionInfo(declaration, symbolKind, symbolName, containerName)); - }); - } - return result; - function tryAddConstructSignature(symbol, location, symbolKind, symbolName, containerName, result) { - // Applicable only if we are in a new expression, or we are on a constructor declaration - // and in either case the symbol has a construct signature definition, i.e. class - if (isNewExpressionTarget(location) || location.kind === 121 /* ConstructorKeyword */) { - if (symbol.flags & 32 /* Class */) { - // Find the first class-like declaration and try to get the construct signature. - for (var _i = 0, _a = symbol.getDeclarations(); _i < _a.length; _i++) { - var declaration = _a[_i]; - if (ts.isClassLike(declaration)) { - return tryAddSignature(declaration.members, - /*selectConstructors*/ true, symbolKind, symbolName, containerName, result); - } - } - ts.Debug.fail("Expected declaration to have at least one class-like declaration"); - } - } - return false; - } - function tryAddCallSignature(symbol, location, symbolKind, symbolName, containerName, result) { - if (isCallExpressionTarget(location) || isNewExpressionTarget(location) || isNameOfFunctionDeclaration(location)) { - return tryAddSignature(symbol.declarations, /*selectConstructors*/ false, symbolKind, symbolName, containerName, result); - } - return false; - } - function tryAddSignature(signatureDeclarations, selectConstructors, symbolKind, symbolName, containerName, result) { - var declarations = []; - var definition; - ts.forEach(signatureDeclarations, function (d) { - if ((selectConstructors && d.kind === 144 /* Constructor */) || - (!selectConstructors && (d.kind === 213 /* FunctionDeclaration */ || d.kind === 143 /* MethodDeclaration */ || d.kind === 142 /* MethodSignature */))) { - declarations.push(d); - if (d.body) - definition = d; - } - }); - if (definition) { - result.push(createDefinitionInfo(definition, symbolKind, symbolName, containerName)); - return true; - } - else if (declarations.length) { - result.push(createDefinitionInfo(ts.lastOrUndefined(declarations), symbolKind, symbolName, containerName)); - return true; - } - return false; - } - } - /// Goto definition - function getDefinitionAtPosition(fileName, position) { - synchronizeHostData(); - var sourceFile = getValidSourceFile(fileName); - var node = ts.getTouchingPropertyName(sourceFile, position); - if (!node) { - return undefined; - } - // Labels - if (isJumpStatementTarget(node)) { - var labelName = node.text; - var label = getTargetLabel(node.parent, node.text); - return label ? [createDefinitionInfo(label, ScriptElementKind.label, labelName, /*containerName*/ undefined)] : undefined; - } - /// Triple slash reference comments - var comment = ts.forEach(sourceFile.referencedFiles, function (r) { return (r.pos <= position && position < r.end) ? r : undefined; }); - if (comment) { - var referenceFile = ts.tryResolveScriptReference(program, sourceFile, comment); - if (referenceFile) { - return [{ - fileName: referenceFile.fileName, - textSpan: ts.createTextSpanFromBounds(0, 0), - kind: ScriptElementKind.scriptElement, - name: comment.fileName, - containerName: undefined, - containerKind: undefined - }]; - } - return undefined; - } - var typeChecker = program.getTypeChecker(); - var symbol = typeChecker.getSymbolAtLocation(node); - // Could not find a symbol e.g. node is string or number keyword, - // or the symbol was an internal symbol and does not have a declaration e.g. undefined symbol - if (!symbol) { - return undefined; - } - // If this is an alias, and the request came at the declaration location - // get the aliased symbol instead. This allows for goto def on an import e.g. - // import {A, B} from "mod"; - // to jump to the implementation directly. - if (symbol.flags & 8388608 /* Alias */) { - var declaration = symbol.declarations[0]; - if (node.kind === 69 /* Identifier */ && node.parent === declaration) { - symbol = typeChecker.getAliasedSymbol(symbol); - } - } - // Because name in short-hand property assignment has two different meanings: property name and property value, - // using go-to-definition at such position should go to the variable declaration of the property value rather than - // go to the declaration of the property name (in this case stay at the same position). However, if go-to-definition - // is performed at the location of property access, we would like to go to definition of the property in the short-hand - // assignment. This case and others are handled by the following code. - if (node.parent.kind === 246 /* ShorthandPropertyAssignment */) { - var shorthandSymbol = typeChecker.getShorthandAssignmentValueSymbol(symbol.valueDeclaration); - if (!shorthandSymbol) { - return []; - } - var shorthandDeclarations = shorthandSymbol.getDeclarations(); - var shorthandSymbolKind = getSymbolKind(shorthandSymbol, node); - var shorthandSymbolName = typeChecker.symbolToString(shorthandSymbol); - var shorthandContainerName = typeChecker.symbolToString(symbol.parent, node); - return ts.map(shorthandDeclarations, function (declaration) { return createDefinitionInfo(declaration, shorthandSymbolKind, shorthandSymbolName, shorthandContainerName); }); - } - return getDefinitionFromSymbol(symbol, node); - } - /// Goto type - function getTypeDefinitionAtPosition(fileName, position) { - synchronizeHostData(); - var sourceFile = getValidSourceFile(fileName); - var node = ts.getTouchingPropertyName(sourceFile, position); - if (!node) { - return undefined; - } - var typeChecker = program.getTypeChecker(); - var symbol = typeChecker.getSymbolAtLocation(node); - if (!symbol) { - return undefined; - } - var type = typeChecker.getTypeOfSymbolAtLocation(symbol, node); - if (!type) { - return undefined; - } - if (type.flags & 16384 /* Union */) { - var result = []; - ts.forEach(type.types, function (t) { - if (t.symbol) { - ts.addRange(/*to*/ result, /*from*/ getDefinitionFromSymbol(t.symbol, node)); - } - }); - return result; - } - if (!type.symbol) { - return undefined; - } - return getDefinitionFromSymbol(type.symbol, node); - } - function getOccurrencesAtPosition(fileName, position) { - var results = getOccurrencesAtPositionCore(fileName, position); - if (results) { - var sourceFile = getCanonicalFileName(ts.normalizeSlashes(fileName)); - // Get occurrences only supports reporting occurrences for the file queried. So - // filter down to that list. - results = ts.filter(results, function (r) { return getCanonicalFileName(ts.normalizeSlashes(r.fileName)) === sourceFile; }); - } - return results; - } - function getDocumentHighlights(fileName, position, filesToSearch) { - synchronizeHostData(); - filesToSearch = ts.map(filesToSearch, ts.normalizeSlashes); - var sourceFilesToSearch = ts.filter(program.getSourceFiles(), function (f) { return ts.contains(filesToSearch, f.fileName); }); - var sourceFile = getValidSourceFile(fileName); - var node = ts.getTouchingWord(sourceFile, position); - if (!node) { - return undefined; - } - return getSemanticDocumentHighlights(node) || getSyntacticDocumentHighlights(node); - function getHighlightSpanForNode(node) { - var start = node.getStart(); - var end = node.getEnd(); - return { - fileName: sourceFile.fileName, - textSpan: ts.createTextSpanFromBounds(start, end), - kind: HighlightSpanKind.none - }; - } - function getSemanticDocumentHighlights(node) { - if (node.kind === 69 /* Identifier */ || - node.kind === 97 /* ThisKeyword */ || - node.kind === 95 /* SuperKeyword */ || - isLiteralNameOfPropertyDeclarationOrIndexAccess(node) || - isNameOfExternalModuleImportOrDeclaration(node)) { - var referencedSymbols = getReferencedSymbolsForNode(node, sourceFilesToSearch, /*findInStrings:*/ false, /*findInComments:*/ false); - return convertReferencedSymbols(referencedSymbols); - } - return undefined; - function convertReferencedSymbols(referencedSymbols) { - if (!referencedSymbols) { - return undefined; - } - var fileNameToDocumentHighlights = {}; - var result = []; - for (var _i = 0; _i < referencedSymbols.length; _i++) { - var referencedSymbol = referencedSymbols[_i]; - for (var _a = 0, _b = referencedSymbol.references; _a < _b.length; _a++) { - var referenceEntry = _b[_a]; - var fileName_1 = referenceEntry.fileName; - var documentHighlights = ts.getProperty(fileNameToDocumentHighlights, fileName_1); - if (!documentHighlights) { - documentHighlights = { fileName: fileName_1, highlightSpans: [] }; - fileNameToDocumentHighlights[fileName_1] = documentHighlights; - result.push(documentHighlights); - } - documentHighlights.highlightSpans.push({ - textSpan: referenceEntry.textSpan, - kind: referenceEntry.isWriteAccess ? HighlightSpanKind.writtenReference : HighlightSpanKind.reference - }); - } - } - return result; - } - } - function getSyntacticDocumentHighlights(node) { - var fileName = sourceFile.fileName; - var highlightSpans = getHighlightSpans(node); - if (!highlightSpans || highlightSpans.length === 0) { - return undefined; - } - return [{ fileName: fileName, highlightSpans: highlightSpans }]; - // returns true if 'node' is defined and has a matching 'kind'. - function hasKind(node, kind) { - return node !== undefined && node.kind === kind; - } - // Null-propagating 'parent' function. - function parent(node) { - return node && node.parent; - } - function getHighlightSpans(node) { - if (node) { - switch (node.kind) { - case 88 /* IfKeyword */: - case 80 /* ElseKeyword */: - if (hasKind(node.parent, 196 /* IfStatement */)) { - return getIfElseOccurrences(node.parent); - } - break; - case 94 /* ReturnKeyword */: - if (hasKind(node.parent, 204 /* ReturnStatement */)) { - return getReturnOccurrences(node.parent); - } - break; - case 98 /* ThrowKeyword */: - if (hasKind(node.parent, 208 /* ThrowStatement */)) { - return getThrowOccurrences(node.parent); - } - break; - case 72 /* CatchKeyword */: - if (hasKind(parent(parent(node)), 209 /* TryStatement */)) { - return getTryCatchFinallyOccurrences(node.parent.parent); - } - break; - case 100 /* TryKeyword */: - case 85 /* FinallyKeyword */: - if (hasKind(parent(node), 209 /* TryStatement */)) { - return getTryCatchFinallyOccurrences(node.parent); - } - break; - case 96 /* SwitchKeyword */: - if (hasKind(node.parent, 206 /* SwitchStatement */)) { - return getSwitchCaseDefaultOccurrences(node.parent); - } - break; - case 71 /* CaseKeyword */: - case 77 /* DefaultKeyword */: - if (hasKind(parent(parent(parent(node))), 206 /* SwitchStatement */)) { - return getSwitchCaseDefaultOccurrences(node.parent.parent.parent); - } - break; - case 70 /* BreakKeyword */: - case 75 /* ContinueKeyword */: - if (hasKind(node.parent, 203 /* BreakStatement */) || hasKind(node.parent, 202 /* ContinueStatement */)) { - return getBreakOrContinueStatementOccurrences(node.parent); - } - break; - case 86 /* ForKeyword */: - if (hasKind(node.parent, 199 /* ForStatement */) || - hasKind(node.parent, 200 /* ForInStatement */) || - hasKind(node.parent, 201 /* ForOfStatement */)) { - return getLoopBreakContinueOccurrences(node.parent); - } - break; - case 104 /* WhileKeyword */: - case 79 /* DoKeyword */: - if (hasKind(node.parent, 198 /* WhileStatement */) || hasKind(node.parent, 197 /* DoStatement */)) { - return getLoopBreakContinueOccurrences(node.parent); - } - break; - case 121 /* ConstructorKeyword */: - if (hasKind(node.parent, 144 /* Constructor */)) { - return getConstructorOccurrences(node.parent); - } - break; - case 123 /* GetKeyword */: - case 129 /* SetKeyword */: - if (hasKind(node.parent, 145 /* GetAccessor */) || hasKind(node.parent, 146 /* SetAccessor */)) { - return getGetAndSetOccurrences(node.parent); - } - break; - default: - if (ts.isModifier(node.kind) && node.parent && - (ts.isDeclaration(node.parent) || node.parent.kind === 193 /* VariableStatement */)) { - return getModifierOccurrences(node.kind, node.parent); - } - } - } - return undefined; - } - /** - * Aggregates all throw-statements within this node *without* crossing - * into function boundaries and try-blocks with catch-clauses. - */ - function aggregateOwnedThrowStatements(node) { - var statementAccumulator = []; - aggregate(node); - return statementAccumulator; - function aggregate(node) { - if (node.kind === 208 /* ThrowStatement */) { - statementAccumulator.push(node); - } - else if (node.kind === 209 /* TryStatement */) { - var tryStatement = node; - if (tryStatement.catchClause) { - aggregate(tryStatement.catchClause); - } - else { - // Exceptions thrown within a try block lacking a catch clause - // are "owned" in the current context. - aggregate(tryStatement.tryBlock); - } - if (tryStatement.finallyBlock) { - aggregate(tryStatement.finallyBlock); - } - } - else if (!ts.isFunctionLike(node)) { - ts.forEachChild(node, aggregate); - } - } - ; - } - /** - * For lack of a better name, this function takes a throw statement and returns the - * nearest ancestor that is a try-block (whose try statement has a catch clause), - * function-block, or source file. - */ - function getThrowStatementOwner(throwStatement) { - var child = throwStatement; - while (child.parent) { - var parent_12 = child.parent; - if (ts.isFunctionBlock(parent_12) || parent_12.kind === 248 /* SourceFile */) { - return parent_12; - } - // A throw-statement is only owned by a try-statement if the try-statement has - // a catch clause, and if the throw-statement occurs within the try block. - if (parent_12.kind === 209 /* TryStatement */) { - var tryStatement = parent_12; - if (tryStatement.tryBlock === child && tryStatement.catchClause) { - return child; - } - } - child = parent_12; - } - return undefined; - } - function aggregateAllBreakAndContinueStatements(node) { - var statementAccumulator = []; - aggregate(node); - return statementAccumulator; - function aggregate(node) { - if (node.kind === 203 /* BreakStatement */ || node.kind === 202 /* ContinueStatement */) { - statementAccumulator.push(node); - } - else if (!ts.isFunctionLike(node)) { - ts.forEachChild(node, aggregate); - } - } - ; - } - function ownsBreakOrContinueStatement(owner, statement) { - var actualOwner = getBreakOrContinueOwner(statement); - return actualOwner && actualOwner === owner; - } - function getBreakOrContinueOwner(statement) { - for (var node_2 = statement.parent; node_2; node_2 = node_2.parent) { - switch (node_2.kind) { - case 206 /* SwitchStatement */: - if (statement.kind === 202 /* ContinueStatement */) { - continue; - } - // Fall through. - case 199 /* ForStatement */: - case 200 /* ForInStatement */: - case 201 /* ForOfStatement */: - case 198 /* WhileStatement */: - case 197 /* DoStatement */: - if (!statement.label || isLabeledBy(node_2, statement.label.text)) { - return node_2; - } - break; - default: - // Don't cross function boundaries. - if (ts.isFunctionLike(node_2)) { - return undefined; - } - break; - } - } - return undefined; - } - function getModifierOccurrences(modifier, declaration) { - 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 === 214 /* ClassDeclaration */ || - container.kind === 186 /* ClassExpression */ || - (declaration.kind === 138 /* Parameter */ && hasKind(container, 144 /* Constructor */)))) { - return undefined; - } - } - else if (modifier === 113 /* StaticKeyword */) { - if (!(container.kind === 214 /* ClassDeclaration */ || container.kind === 186 /* ClassExpression */)) { - return undefined; - } - } - else if (modifier === 82 /* ExportKeyword */ || modifier === 122 /* DeclareKeyword */) { - if (!(container.kind === 219 /* ModuleBlock */ || container.kind === 248 /* SourceFile */)) { - return undefined; - } - } - else if (modifier === 115 /* AbstractKeyword */) { - if (!(container.kind === 214 /* ClassDeclaration */ || declaration.kind === 214 /* ClassDeclaration */)) { - return undefined; - } - } - else { - // unsupported modifier - return undefined; - } - var keywords = []; - var modifierFlag = getFlagFromModifier(modifier); - var nodes; - switch (container.kind) { - case 219 /* ModuleBlock */: - case 248 /* SourceFile */: - // Container is either a class declaration or the declaration is a classDeclaration - if (modifierFlag & 256 /* Abstract */) { - nodes = declaration.members.concat(declaration); - } - else { - nodes = container.statements; - } - break; - case 144 /* Constructor */: - nodes = container.parameters.concat(container.parent.members); - break; - case 214 /* ClassDeclaration */: - case 186 /* ClassExpression */: - nodes = container.members; - // If we're an accessibility modifier, we're in an instance member and should search - // the constructor's parameter list for instance members as well. - if (modifierFlag & 112 /* AccessibilityModifier */) { - var constructor = ts.forEach(container.members, function (member) { - return member.kind === 144 /* Constructor */ && member; - }); - if (constructor) { - nodes = nodes.concat(constructor.parameters); - } - } - else if (modifierFlag & 256 /* Abstract */) { - nodes = nodes.concat(container); - } - break; - default: - ts.Debug.fail("Invalid container kind."); - } - ts.forEach(nodes, function (node) { - if (node.modifiers && node.flags & modifierFlag) { - ts.forEach(node.modifiers, function (child) { return pushKeywordIf(keywords, child, modifier); }); - } - }); - return ts.map(keywords, getHighlightSpanForNode); - function getFlagFromModifier(modifier) { - switch (modifier) { - case 112 /* PublicKeyword */: - return 16 /* Public */; - case 110 /* PrivateKeyword */: - return 32 /* Private */; - case 111 /* ProtectedKeyword */: - return 64 /* Protected */; - case 113 /* StaticKeyword */: - return 128 /* Static */; - case 82 /* ExportKeyword */: - return 1 /* Export */; - case 122 /* DeclareKeyword */: - return 2 /* Ambient */; - case 115 /* AbstractKeyword */: - return 256 /* Abstract */; - default: - ts.Debug.fail(); - } - } - } - function pushKeywordIf(keywordList, token) { - var expected = []; - for (var _i = 2; _i < arguments.length; _i++) { - expected[_i - 2] = arguments[_i]; - } - if (token && ts.contains(expected, token.kind)) { - keywordList.push(token); - return true; - } - return false; - } - function getGetAndSetOccurrences(accessorDeclaration) { - var keywords = []; - tryPushAccessorKeyword(accessorDeclaration.symbol, 145 /* GetAccessor */); - tryPushAccessorKeyword(accessorDeclaration.symbol, 146 /* SetAccessor */); - return ts.map(keywords, getHighlightSpanForNode); - function tryPushAccessorKeyword(accessorSymbol, accessorKind) { - var accessor = ts.getDeclarationOfKind(accessorSymbol, accessorKind); - if (accessor) { - ts.forEach(accessor.getChildren(), function (child) { return pushKeywordIf(keywords, child, 123 /* GetKeyword */, 129 /* SetKeyword */); }); - } - } - } - function getConstructorOccurrences(constructorDeclaration) { - var declarations = constructorDeclaration.symbol.getDeclarations(); - var keywords = []; - ts.forEach(declarations, function (declaration) { - ts.forEach(declaration.getChildren(), function (token) { - return pushKeywordIf(keywords, token, 121 /* ConstructorKeyword */); - }); - }); - return ts.map(keywords, getHighlightSpanForNode); - } - function getLoopBreakContinueOccurrences(loopNode) { - var keywords = []; - if (pushKeywordIf(keywords, loopNode.getFirstToken(), 86 /* ForKeyword */, 104 /* WhileKeyword */, 79 /* DoKeyword */)) { - // If we succeeded and got a do-while loop, then start looking for a 'while' keyword. - if (loopNode.kind === 197 /* DoStatement */) { - var loopTokens = loopNode.getChildren(); - for (var i = loopTokens.length - 1; i >= 0; i--) { - if (pushKeywordIf(keywords, loopTokens[i], 104 /* WhileKeyword */)) { - break; - } - } - } - } - var breaksAndContinues = aggregateAllBreakAndContinueStatements(loopNode.statement); - ts.forEach(breaksAndContinues, function (statement) { - if (ownsBreakOrContinueStatement(loopNode, statement)) { - pushKeywordIf(keywords, statement.getFirstToken(), 70 /* BreakKeyword */, 75 /* ContinueKeyword */); - } - }); - return ts.map(keywords, getHighlightSpanForNode); - } - function getBreakOrContinueStatementOccurrences(breakOrContinueStatement) { - var owner = getBreakOrContinueOwner(breakOrContinueStatement); - if (owner) { - switch (owner.kind) { - case 199 /* ForStatement */: - case 200 /* ForInStatement */: - case 201 /* ForOfStatement */: - case 197 /* DoStatement */: - case 198 /* WhileStatement */: - return getLoopBreakContinueOccurrences(owner); - case 206 /* SwitchStatement */: - return getSwitchCaseDefaultOccurrences(owner); - } - } - return undefined; - } - function getSwitchCaseDefaultOccurrences(switchStatement) { - var keywords = []; - pushKeywordIf(keywords, switchStatement.getFirstToken(), 96 /* SwitchKeyword */); - // Go through each clause in the switch statement, collecting the 'case'/'default' keywords. - ts.forEach(switchStatement.caseBlock.clauses, function (clause) { - pushKeywordIf(keywords, clause.getFirstToken(), 71 /* CaseKeyword */, 77 /* DefaultKeyword */); - var breaksAndContinues = aggregateAllBreakAndContinueStatements(clause); - ts.forEach(breaksAndContinues, function (statement) { - if (ownsBreakOrContinueStatement(switchStatement, statement)) { - pushKeywordIf(keywords, statement.getFirstToken(), 70 /* BreakKeyword */); - } - }); - }); - return ts.map(keywords, getHighlightSpanForNode); - } - function getTryCatchFinallyOccurrences(tryStatement) { - var keywords = []; - pushKeywordIf(keywords, tryStatement.getFirstToken(), 100 /* TryKeyword */); - if (tryStatement.catchClause) { - pushKeywordIf(keywords, tryStatement.catchClause.getFirstToken(), 72 /* CatchKeyword */); - } - if (tryStatement.finallyBlock) { - var finallyKeyword = ts.findChildOfKind(tryStatement, 85 /* FinallyKeyword */, sourceFile); - pushKeywordIf(keywords, finallyKeyword, 85 /* FinallyKeyword */); - } - return ts.map(keywords, getHighlightSpanForNode); - } - function getThrowOccurrences(throwStatement) { - var owner = getThrowStatementOwner(throwStatement); - if (!owner) { - return undefined; - } - var keywords = []; - ts.forEach(aggregateOwnedThrowStatements(owner), function (throwStatement) { - pushKeywordIf(keywords, throwStatement.getFirstToken(), 98 /* ThrowKeyword */); - }); - // If the "owner" is a function, then we equate 'return' and 'throw' statements in their - // ability to "jump out" of the function, and include occurrences for both. - if (ts.isFunctionBlock(owner)) { - ts.forEachReturnStatement(owner, function (returnStatement) { - pushKeywordIf(keywords, returnStatement.getFirstToken(), 94 /* ReturnKeyword */); - }); - } - return ts.map(keywords, getHighlightSpanForNode); - } - 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, 192 /* Block */))) { - return undefined; - } - var keywords = []; - ts.forEachReturnStatement(func.body, function (returnStatement) { - pushKeywordIf(keywords, returnStatement.getFirstToken(), 94 /* ReturnKeyword */); - }); - // Include 'throw' statements that do not occur within a try block. - ts.forEach(aggregateOwnedThrowStatements(func.body), function (throwStatement) { - pushKeywordIf(keywords, throwStatement.getFirstToken(), 98 /* ThrowKeyword */); - }); - return ts.map(keywords, getHighlightSpanForNode); - } - function getIfElseOccurrences(ifStatement) { - var keywords = []; - // Traverse upwards through all parent if-statements linked by their else-branches. - while (hasKind(ifStatement.parent, 196 /* IfStatement */) && ifStatement.parent.elseStatement === ifStatement) { - ifStatement = ifStatement.parent; - } - // Now traverse back down through the else branches, aggregating if/else keywords of if-statements. - while (ifStatement) { - var children = ifStatement.getChildren(); - pushKeywordIf(keywords, children[0], 88 /* IfKeyword */); - // Generally the 'else' keyword is second-to-last, so we traverse backwards. - for (var i = children.length - 1; i >= 0; i--) { - if (pushKeywordIf(keywords, children[i], 80 /* ElseKeyword */)) { - break; - } - } - if (!hasKind(ifStatement.elseStatement, 196 /* IfStatement */)) { - break; - } - ifStatement = ifStatement.elseStatement; - } - var result = []; - // 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) { - var elseKeyword = keywords[i]; - var ifKeyword = keywords[i + 1]; // this *should* always be an 'if' keyword. - var shouldCombindElseAndIf = true; - // Avoid recalculating getStart() by iterating backwards. - for (var j = ifKeyword.getStart() - 1; j >= elseKeyword.end; j--) { - if (!ts.isWhiteSpace(sourceFile.text.charCodeAt(j))) { - shouldCombindElseAndIf = false; - break; - } - } - if (shouldCombindElseAndIf) { - result.push({ - fileName: fileName, - textSpan: ts.createTextSpanFromBounds(elseKeyword.getStart(), ifKeyword.end), - kind: HighlightSpanKind.reference - }); - i++; // skip the next keyword - continue; - } - } - // Ordinary case: just highlight the keyword. - result.push(getHighlightSpanForNode(keywords[i])); - } - return result; - } - } - } - /// References and Occurrences - function getOccurrencesAtPositionCore(fileName, position) { - synchronizeHostData(); - return convertDocumentHighlights(getDocumentHighlights(fileName, position, [fileName])); - function convertDocumentHighlights(documentHighlights) { - if (!documentHighlights) { - return undefined; - } - var result = []; - for (var _i = 0; _i < documentHighlights.length; _i++) { - var entry = documentHighlights[_i]; - for (var _a = 0, _b = entry.highlightSpans; _a < _b.length; _a++) { - var highlightSpan = _b[_a]; - result.push({ - fileName: entry.fileName, - textSpan: highlightSpan.textSpan, - isWriteAccess: highlightSpan.kind === HighlightSpanKind.writtenReference - }); - } - } - return result; - } - } - function convertReferences(referenceSymbols) { - if (!referenceSymbols) { - return undefined; - } - var referenceEntries = []; - for (var _i = 0; _i < referenceSymbols.length; _i++) { - var referenceSymbol = referenceSymbols[_i]; - ts.addRange(referenceEntries, referenceSymbol.references); - } - return referenceEntries; - } - function findRenameLocations(fileName, position, findInStrings, findInComments) { - var referencedSymbols = findReferencedSymbols(fileName, position, findInStrings, findInComments); - return convertReferences(referencedSymbols); - } - function getReferencesAtPosition(fileName, position) { - var referencedSymbols = findReferencedSymbols(fileName, position, /*findInStrings:*/ false, /*findInComments:*/ false); - return convertReferences(referencedSymbols); - } - function findReferences(fileName, position) { - var referencedSymbols = findReferencedSymbols(fileName, position, /*findInStrings:*/ false, /*findInComments:*/ false); - // Only include referenced symbols that have a valid definition. - return ts.filter(referencedSymbols, function (rs) { return !!rs.definition; }); - } - function findReferencedSymbols(fileName, position, findInStrings, findInComments) { - synchronizeHostData(); - var sourceFile = getValidSourceFile(fileName); - var node = ts.getTouchingPropertyName(sourceFile, position); - if (!node) { - return undefined; - } - if (node.kind !== 69 /* Identifier */ && - // TODO (drosen): This should be enabled in a later release - currently breaks rename. - //node.kind !== SyntaxKind.ThisKeyword && - //node.kind !== SyntaxKind.SuperKeyword && - !isLiteralNameOfPropertyDeclarationOrIndexAccess(node) && - !isNameOfExternalModuleImportOrDeclaration(node)) { - return undefined; - } - ts.Debug.assert(node.kind === 69 /* Identifier */ || node.kind === 8 /* NumericLiteral */ || node.kind === 9 /* StringLiteral */); - return getReferencedSymbolsForNode(node, program.getSourceFiles(), findInStrings, findInComments); - } - function getReferencedSymbolsForNode(node, sourceFiles, findInStrings, findInComments) { - var typeChecker = program.getTypeChecker(); - // Labels - if (isLabelName(node)) { - if (isJumpStatementTarget(node)) { - var labelDefinition = getTargetLabel(node.parent, node.text); - // if we have a label definition, look within its statement for references, if not, then - // the label is undefined and we have no results.. - return labelDefinition ? getLabelReferencesInNode(labelDefinition.parent, labelDefinition) : undefined; - } - else { - // it is a label definition and not a target, search within the parent labeledStatement - return getLabelReferencesInNode(node.parent, node); - } - } - if (node.kind === 97 /* ThisKeyword */) { - return getReferencesForThisKeyword(node, sourceFiles); - } - if (node.kind === 95 /* SuperKeyword */) { - return getReferencesForSuperKeyword(node); - } - var symbol = typeChecker.getSymbolAtLocation(node); - // Could not find a symbol e.g. unknown identifier - if (!symbol) { - // Can't have references to something that we have no symbol for. - return undefined; - } - var declarations = symbol.declarations; - // The symbol was an internal symbol and does not have a declaration e.g. undefined symbol - if (!declarations || !declarations.length) { - return undefined; - } - var result; - // Compute the meaning from the location and the symbol it references - var searchMeaning = getIntersectingMeaningFromDeclarations(getMeaningFromLocation(node), declarations); - // Get the text to search for. - // Note: if this is an external module symbol, the name doesn't include quotes. - var declaredName = ts.stripQuotes(ts.getDeclaredName(typeChecker, symbol, node)); - // Try to get the smallest valid scope that we can limit our search to; - // otherwise we'll need to search globally (i.e. include each file). - var scope = getSymbolScope(symbol); - // Maps from a symbol ID to the ReferencedSymbol entry in 'result'. - var symbolToIndex = []; - if (scope) { - result = []; - getReferencesInNode(scope, symbol, declaredName, node, searchMeaning, findInStrings, findInComments, result, symbolToIndex); - } - else { - var internedName = getInternedName(symbol, node, declarations); - for (var _i = 0; _i < sourceFiles.length; _i++) { - var sourceFile = sourceFiles[_i]; - cancellationToken.throwIfCancellationRequested(); - var nameTable = getNameTable(sourceFile); - if (ts.lookUp(nameTable, internedName)) { - result = result || []; - getReferencesInNode(sourceFile, symbol, declaredName, node, searchMeaning, findInStrings, findInComments, result, symbolToIndex); - } - } - } - return result; - function getDefinition(symbol) { - var info = getSymbolDisplayPartsDocumentationAndSymbolKind(symbol, node.getSourceFile(), getContainerNode(node), node); - var name = ts.map(info.displayParts, function (p) { return p.text; }).join(""); - var declarations = symbol.declarations; - if (!declarations || declarations.length === 0) { - return undefined; - } - return { - containerKind: "", - containerName: "", - name: name, - kind: info.symbolKind, - fileName: declarations[0].getSourceFile().fileName, - textSpan: ts.createTextSpan(declarations[0].getStart(), 0) - }; - } - function isImportOrExportSpecifierImportSymbol(symbol) { - return (symbol.flags & 8388608 /* Alias */) && ts.forEach(symbol.declarations, function (declaration) { - return declaration.kind === 226 /* ImportSpecifier */ || declaration.kind === 230 /* ExportSpecifier */; - }); - } - function getInternedName(symbol, location, declarations) { - // 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)) { - return location.getText(); - } - // Try to get the local symbol if we're dealing with an 'export default' - // since that symbol has the "true" name. - var localExportDefaultSymbol = ts.getLocalSymbolForExportDefault(symbol); - symbol = localExportDefaultSymbol || symbol; - return ts.stripQuotes(symbol.name); - } - /** - * Determines the smallest scope in which a symbol may have named references. - * Note that not every construct has been accounted for. This function can - * probably be improved. - * - * @returns undefined if the scope cannot be determined, implying that - * a reference to a symbol can occur anywhere. - */ - function getSymbolScope(symbol) { - // 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 === 173 /* FunctionExpression */ || valueDeclaration.kind === 186 /* ClassExpression */)) { - return valueDeclaration; - } - // If this is private property or method, the scope is the containing class - if (symbol.flags & (4 /* Property */ | 8192 /* Method */)) { - var privateDeclaration = ts.forEach(symbol.getDeclarations(), function (d) { return (d.flags & 32 /* Private */) ? d : undefined; }); - if (privateDeclaration) { - return ts.getAncestor(privateDeclaration, 214 /* ClassDeclaration */); - } - } - // If the symbol is an import we would like to find it if we are looking for what it imports. - // So consider it visibile outside its declaration scope. - if (symbol.flags & 8388608 /* Alias */) { - return undefined; - } - // if this symbol is visible from its parent container, e.g. exported, then bail out - // if symbol correspond to the union property - bail out - if (symbol.parent || (symbol.flags & 268435456 /* SyntheticProperty */)) { - return undefined; - } - var scope = undefined; - var declarations = symbol.getDeclarations(); - if (declarations) { - for (var _i = 0; _i < declarations.length; _i++) { - var declaration = declarations[_i]; - var container = getContainerNode(declaration); - if (!container) { - return undefined; - } - if (scope && scope !== container) { - // Different declarations have different containers, bail out - return undefined; - } - if (container.kind === 248 /* SourceFile */ && !ts.isExternalModule(container)) { - // This is a global variable and not an external module, any declaration defined - // within this scope is visible outside the file - return undefined; - } - // The search scope is the container node - scope = container; - } - } - return scope; - } - function getPossibleSymbolReferencePositions(sourceFile, symbolName, start, end) { - var positions = []; - /// TODO: Cache symbol existence for files to save text search - // Also, need to make this work for unicode escapes. - // Be resilient in the face of a symbol with no name or zero length name - if (!symbolName || !symbolName.length) { - return positions; - } - var text = sourceFile.text; - var sourceLength = text.length; - var symbolNameLength = symbolName.length; - var position = text.indexOf(symbolName, start); - while (position >= 0) { - cancellationToken.throwIfCancellationRequested(); - // If we are past the end, stop looking - if (position > end) - break; - // 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 */))) { - // Found a real match. Keep searching. - positions.push(position); - } - position = text.indexOf(symbolName, position + symbolNameLength + 1); - } - return positions; - } - function getLabelReferencesInNode(container, targetLabel) { - var references = []; - var sourceFile = container.getSourceFile(); - var labelName = targetLabel.text; - var possiblePositions = getPossibleSymbolReferencePositions(sourceFile, labelName, container.getStart(), container.getEnd()); - ts.forEach(possiblePositions, function (position) { - cancellationToken.throwIfCancellationRequested(); - var node = ts.getTouchingWord(sourceFile, position); - if (!node || node.getWidth() !== labelName.length) { - return; - } - // Only pick labels that are either the target label, or have a target that is the target label - if (node === targetLabel || - (isJumpStatementTarget(node) && getTargetLabel(node, labelName) === targetLabel)) { - references.push(getReferenceEntryFromNode(node)); - } - }); - var definition = { - containerKind: "", - containerName: "", - fileName: targetLabel.getSourceFile().fileName, - kind: ScriptElementKind.label, - name: labelName, - textSpan: ts.createTextSpanFromBounds(targetLabel.getStart(), targetLabel.getEnd()) - }; - return [{ definition: definition, references: references }]; - } - function isValidReferencePosition(node, searchSymbolName) { - if (node) { - // Compare the length so we filter out strict superstrings of the symbol we are looking for - switch (node.kind) { - case 69 /* Identifier */: - return node.getWidth() === searchSymbolName.length; - case 9 /* StringLiteral */: - if (isLiteralNameOfPropertyDeclarationOrIndexAccess(node) || - isNameOfExternalModuleImportOrDeclaration(node)) { - // For string literals we have two additional chars for the quotes - return node.getWidth() === searchSymbolName.length + 2; - } - break; - case 8 /* NumericLiteral */: - if (isLiteralNameOfPropertyDeclarationOrIndexAccess(node)) { - return node.getWidth() === searchSymbolName.length; - } - break; - } - } - return false; - } - /** Search within node "container" for references for a search value, where the search value is defined as a - * tuple of(searchSymbol, searchText, searchLocation, and searchMeaning). - * searchLocation: a node where the search value - */ - function getReferencesInNode(container, searchSymbol, searchText, searchLocation, searchMeaning, findInStrings, findInComments, result, symbolToIndex) { - var sourceFile = container.getSourceFile(); - var tripleSlashDirectivePrefixRegex = /^\/\/\/\s*= 0) { - var referencedSymbol = getReferencedSymbol(shorthandValueSymbol); - referencedSymbol.references.push(getReferenceEntryFromNode(referenceSymbolDeclaration.name)); - } - } - }); - } - return; - function getReferencedSymbol(symbol) { - var symbolId = ts.getSymbolId(symbol); - var index = symbolToIndex[symbolId]; - if (index === undefined) { - index = result.length; - symbolToIndex[symbolId] = index; - result.push({ - definition: getDefinition(symbol), - references: [] - }); - } - return result[index]; - } - function isInNonReferenceComment(sourceFile, position) { - return ts.isInCommentHelper(sourceFile, position, isNonReferenceComment); - function isNonReferenceComment(c) { - var commentText = sourceFile.text.substring(c.pos, c.end); - return !tripleSlashDirectivePrefixRegex.test(commentText); - } - } - } - function getReferencesForSuperKeyword(superKeyword) { - var searchSpaceNode = ts.getSuperContainer(superKeyword, /*includeFunctions*/ false); - if (!searchSpaceNode) { - return undefined; - } - // Whether 'super' occurs in a static context within a class. - var staticFlag = 128 /* Static */; - switch (searchSpaceNode.kind) { - case 141 /* PropertyDeclaration */: - case 140 /* PropertySignature */: - case 143 /* MethodDeclaration */: - case 142 /* MethodSignature */: - case 144 /* Constructor */: - case 145 /* GetAccessor */: - case 146 /* SetAccessor */: - staticFlag &= searchSpaceNode.flags; - searchSpaceNode = searchSpaceNode.parent; // re-assign to be the owning class - break; - default: - return undefined; - } - var references = []; - var sourceFile = searchSpaceNode.getSourceFile(); - var possiblePositions = getPossibleSymbolReferencePositions(sourceFile, "super", searchSpaceNode.getStart(), searchSpaceNode.getEnd()); - ts.forEach(possiblePositions, function (position) { - cancellationToken.throwIfCancellationRequested(); - var node = ts.getTouchingWord(sourceFile, position); - if (!node || node.kind !== 95 /* SuperKeyword */) { - return; - } - var container = ts.getSuperContainer(node, /*includeFunctions*/ false); - // If we have a 'super' container, we must have an enclosing class. - // Now make sure the owning class is the same as the search-space - // and has the same static qualifier as the original 'super's owner. - if (container && (128 /* Static */ & container.flags) === staticFlag && container.parent.symbol === searchSpaceNode.symbol) { - references.push(getReferenceEntryFromNode(node)); - } - }); - var definition = getDefinition(searchSpaceNode.symbol); - return [{ definition: definition, references: references }]; - } - function getReferencesForThisKeyword(thisOrSuperKeyword, sourceFiles) { - var searchSpaceNode = ts.getThisContainer(thisOrSuperKeyword, /* includeArrowFunctions */ false); - // Whether 'this' occurs in a static context within a class. - var staticFlag = 128 /* Static */; - switch (searchSpaceNode.kind) { - case 143 /* MethodDeclaration */: - case 142 /* MethodSignature */: - if (ts.isObjectLiteralMethod(searchSpaceNode)) { - break; - } - // fall through - case 141 /* PropertyDeclaration */: - case 140 /* PropertySignature */: - case 144 /* Constructor */: - case 145 /* GetAccessor */: - case 146 /* SetAccessor */: - staticFlag &= searchSpaceNode.flags; - searchSpaceNode = searchSpaceNode.parent; // re-assign to be the owning class - break; - case 248 /* SourceFile */: - if (ts.isExternalModule(searchSpaceNode)) { - return undefined; - } - // Fall through - case 213 /* FunctionDeclaration */: - case 173 /* FunctionExpression */: - break; - // Computed properties in classes are not handled here because references to this are illegal, - // so there is no point finding references to them. - default: - return undefined; - } - var references = []; - var possiblePositions; - if (searchSpaceNode.kind === 248 /* SourceFile */) { - ts.forEach(sourceFiles, function (sourceFile) { - possiblePositions = getPossibleSymbolReferencePositions(sourceFile, "this", sourceFile.getStart(), sourceFile.getEnd()); - getThisReferencesInFile(sourceFile, sourceFile, possiblePositions, references); - }); - } - else { - var sourceFile = searchSpaceNode.getSourceFile(); - possiblePositions = getPossibleSymbolReferencePositions(sourceFile, "this", searchSpaceNode.getStart(), searchSpaceNode.getEnd()); - getThisReferencesInFile(sourceFile, searchSpaceNode, possiblePositions, references); - } - return [{ - definition: { - containerKind: "", - containerName: "", - fileName: node.getSourceFile().fileName, - kind: ScriptElementKind.variableElement, - name: "this", - textSpan: ts.createTextSpanFromBounds(node.getStart(), node.getEnd()) - }, - references: references - }]; - function getThisReferencesInFile(sourceFile, searchSpaceNode, possiblePositions, result) { - ts.forEach(possiblePositions, function (position) { - cancellationToken.throwIfCancellationRequested(); - var node = ts.getTouchingWord(sourceFile, position); - if (!node || node.kind !== 97 /* ThisKeyword */) { - return; - } - var container = ts.getThisContainer(node, /* includeArrowFunctions */ false); - switch (searchSpaceNode.kind) { - case 173 /* FunctionExpression */: - case 213 /* FunctionDeclaration */: - if (searchSpaceNode.symbol === container.symbol) { - result.push(getReferenceEntryFromNode(node)); - } - break; - case 143 /* MethodDeclaration */: - case 142 /* MethodSignature */: - if (ts.isObjectLiteralMethod(searchSpaceNode) && searchSpaceNode.symbol === container.symbol) { - result.push(getReferenceEntryFromNode(node)); - } - break; - case 186 /* ClassExpression */: - case 214 /* ClassDeclaration */: - // Make sure the container belongs to the same class - // and has the appropriate static modifier from the original container. - if (container.parent && searchSpaceNode.symbol === container.parent.symbol && (container.flags & 128 /* Static */) === staticFlag) { - result.push(getReferenceEntryFromNode(node)); - } - break; - case 248 /* SourceFile */: - if (container.kind === 248 /* SourceFile */ && !ts.isExternalModule(container)) { - result.push(getReferenceEntryFromNode(node)); - } - break; - } - }); - } - } - function populateSearchSymbolSet(symbol, location) { - // The search set contains at least the current symbol - var result = [symbol]; - // If the symbol is an alias, add what it alaises to the list - if (isImportOrExportSpecifierImportSymbol(symbol)) { - result.push(typeChecker.getAliasedSymbol(symbol)); - } - // If the location is in a context sensitive location (i.e. in an object literal) try - // to get a contextual type for it, and add the property symbol from the contextual - // type to the search set - if (isNameOfPropertyAssignment(location)) { - ts.forEach(getPropertySymbolsFromContextualType(location), function (contextualSymbol) { - ts.addRange(result, typeChecker.getRootSymbols(contextualSymbol)); - }); - /* Because in short-hand property assignment, location has two meaning : property name and as value of the property - * When we do findAllReference at the position of the short-hand property assignment, we would want to have references to position of - * property name and variable declaration of the identifier. - * Like in below example, when querying for all references for an identifier 'name', of the property assignment, the language service - * should show both 'name' in 'obj' and 'name' in variable declaration - * let name = "Foo"; - * let obj = { name }; - * In order to do that, we will populate the search set with the value symbol of the identifier as a value of the property assignment - * so that when matching with potential reference symbol, both symbols from property declaration and variable declaration - * will be included correctly. - */ - var shorthandValueSymbol = typeChecker.getShorthandAssignmentValueSymbol(location.parent); - if (shorthandValueSymbol) { - result.push(shorthandValueSymbol); - } - } - // If this is a union property, add all the symbols from all its source symbols in all unioned types. - // If the symbol is an instantiation from a another symbol (e.g. widened symbol) , add the root the list - ts.forEach(typeChecker.getRootSymbols(symbol), function (rootSymbol) { - if (rootSymbol !== symbol) { - result.push(rootSymbol); - } - // Add symbol of properties/methods of the same name in base classes and implemented interfaces definitions - if (rootSymbol.parent && rootSymbol.parent.flags & (32 /* Class */ | 64 /* Interface */)) { - getPropertySymbolsFromBaseTypes(rootSymbol.parent, rootSymbol.getName(), result); - } - }); - return result; - } - function getPropertySymbolsFromBaseTypes(symbol, propertyName, result) { - if (symbol && symbol.flags & (32 /* Class */ | 64 /* Interface */)) { - ts.forEach(symbol.getDeclarations(), function (declaration) { - if (declaration.kind === 214 /* ClassDeclaration */) { - getPropertySymbolFromTypeReference(ts.getClassExtendsHeritageClauseElement(declaration)); - ts.forEach(ts.getClassImplementsHeritageClauseElements(declaration), getPropertySymbolFromTypeReference); - } - else if (declaration.kind === 215 /* InterfaceDeclaration */) { - ts.forEach(ts.getInterfaceBaseTypeNodes(declaration), getPropertySymbolFromTypeReference); - } - }); - } - return; - function getPropertySymbolFromTypeReference(typeReference) { - if (typeReference) { - var type = typeChecker.getTypeAtLocation(typeReference); - if (type) { - var propertySymbol = typeChecker.getPropertyOfType(type, propertyName); - if (propertySymbol) { - result.push(propertySymbol); - } - // Visit the typeReference as well to see if it directly or indirectly use that property - getPropertySymbolsFromBaseTypes(type.symbol, propertyName, result); - } - } - } - } - function getRelatedSymbol(searchSymbols, referenceSymbol, referenceLocation) { - if (searchSymbols.indexOf(referenceSymbol) >= 0) { - return referenceSymbol; - } - // If the reference symbol is an alias, check if what it is aliasing is one of the search - // symbols. - if (isImportOrExportSpecifierImportSymbol(referenceSymbol)) { - var aliasedSymbol = typeChecker.getAliasedSymbol(referenceSymbol); - if (searchSymbols.indexOf(aliasedSymbol) >= 0) { - return aliasedSymbol; - } - } - // If the reference location is in an object literal, try to get the contextual type for the - // object literal, lookup the property symbol in the contextual type, and use this symbol to - // compare to our searchSymbol - if (isNameOfPropertyAssignment(referenceLocation)) { - return ts.forEach(getPropertySymbolsFromContextualType(referenceLocation), function (contextualSymbol) { - return ts.forEach(typeChecker.getRootSymbols(contextualSymbol), function (s) { return searchSymbols.indexOf(s) >= 0 ? s : undefined; }); - }); - } - // Unwrap symbols to get to the root (e.g. transient symbols as a result of widening) - // Or a union property, use its underlying unioned symbols - return ts.forEach(typeChecker.getRootSymbols(referenceSymbol), function (rootSymbol) { - // if it is in the list, then we are done - if (searchSymbols.indexOf(rootSymbol) >= 0) { - return rootSymbol; - } - // Finally, try all properties with the same name in any type the containing type extended or implemented, and - // see if any is in the list - if (rootSymbol.parent && rootSymbol.parent.flags & (32 /* Class */ | 64 /* Interface */)) { - var result_3 = []; - getPropertySymbolsFromBaseTypes(rootSymbol.parent, rootSymbol.getName(), result_3); - return ts.forEach(result_3, function (s) { return searchSymbols.indexOf(s) >= 0 ? s : undefined; }); - } - return undefined; - }); - } - function getPropertySymbolsFromContextualType(node) { - if (isNameOfPropertyAssignment(node)) { - var objectLiteral = node.parent.parent; - var contextualType = typeChecker.getContextualType(objectLiteral); - var name_34 = node.text; - if (contextualType) { - if (contextualType.flags & 16384 /* Union */) { - // This is a union type, first see if the property we are looking for is a union property (i.e. exists in all types) - // if not, search the constituent types for the property - var unionProperty = contextualType.getProperty(name_34); - if (unionProperty) { - return [unionProperty]; - } - else { - var result_4 = []; - ts.forEach(contextualType.types, function (t) { - var symbol = t.getProperty(name_34); - if (symbol) { - result_4.push(symbol); - } - }); - return result_4; - } - } - else { - var symbol_1 = contextualType.getProperty(name_34); - if (symbol_1) { - return [symbol_1]; - } - } - } - } - return undefined; - } - /** Given an initial searchMeaning, extracted from a location, widen the search scope based on the declarations - * of the corresponding symbol. e.g. if we are searching for "Foo" in value position, but "Foo" references a class - * then we need to widen the search to include type positions as well. - * On the contrary, if we are searching for "Bar" in type position and we trace bar to an interface, and an uninstantiated - * module, we want to keep the search limited to only types, as the two declarations (interface and uninstantiated module) - * do not intersect in any of the three spaces. - */ - function getIntersectingMeaningFromDeclarations(meaning, declarations) { - if (declarations) { - var lastIterationMeaning; - do { - // The result is order-sensitive, for instance if initialMeaning === Namespace, and declarations = [class, instantiated module] - // we need to consider both as they initialMeaning intersects with the module in the namespace space, and the module - // intersects with the class in the value space. - // To achieve that we will keep iterating until the result stabilizes. - // Remember the last meaning - lastIterationMeaning = meaning; - for (var _i = 0; _i < declarations.length; _i++) { - var declaration = declarations[_i]; - var declarationMeaning = getMeaningFromDeclaration(declaration); - if (declarationMeaning & meaning) { - meaning |= declarationMeaning; - } - } - } while (meaning !== lastIterationMeaning); - } - return meaning; - } - } - function getReferenceEntryFromNode(node) { - var start = node.getStart(); - var end = node.getEnd(); - if (node.kind === 9 /* StringLiteral */) { - start += 1; - end -= 1; - } - return { - fileName: node.getSourceFile().fileName, - textSpan: ts.createTextSpanFromBounds(start, end), - isWriteAccess: isWriteAccess(node) - }; - } - /** 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)) { - return true; - } - var parent = node.parent; - if (parent) { - if (parent.kind === 180 /* PostfixUnaryExpression */ || parent.kind === 179 /* PrefixUnaryExpression */) { - return true; - } - else if (parent.kind === 181 /* BinaryExpression */ && parent.left === node) { - var operator = parent.operatorToken.kind; - return 56 /* FirstAssignment */ <= operator && operator <= 68 /* LastAssignment */; - } - } - return false; - } - /// NavigateTo - function getNavigateToItems(searchValue, maxResultCount) { - synchronizeHostData(); - return ts.NavigateTo.getNavigateToItems(program, cancellationToken, searchValue, maxResultCount); - } - function containErrors(diagnostics) { - return ts.forEach(diagnostics, function (diagnostic) { return diagnostic.category === ts.DiagnosticCategory.Error; }); - } - function getEmitOutput(fileName) { - synchronizeHostData(); - var sourceFile = getValidSourceFile(fileName); - var outputFiles = []; - function writeFile(fileName, data, writeByteOrderMark) { - outputFiles.push({ - name: fileName, - writeByteOrderMark: writeByteOrderMark, - text: data - }); - } - var emitOutput = program.emit(sourceFile, writeFile, cancellationToken); - return { - outputFiles: outputFiles, - emitSkipped: emitOutput.emitSkipped - }; - } - function getMeaningFromDeclaration(node) { - switch (node.kind) { - case 138 /* Parameter */: - case 211 /* VariableDeclaration */: - case 163 /* BindingElement */: - case 141 /* PropertyDeclaration */: - case 140 /* PropertySignature */: - case 245 /* PropertyAssignment */: - case 246 /* ShorthandPropertyAssignment */: - case 247 /* EnumMember */: - case 143 /* MethodDeclaration */: - case 142 /* MethodSignature */: - case 144 /* Constructor */: - case 145 /* GetAccessor */: - case 146 /* SetAccessor */: - case 213 /* FunctionDeclaration */: - case 173 /* FunctionExpression */: - case 174 /* ArrowFunction */: - case 244 /* CatchClause */: - return 1 /* Value */; - case 137 /* TypeParameter */: - case 215 /* InterfaceDeclaration */: - case 216 /* TypeAliasDeclaration */: - case 155 /* TypeLiteral */: - return 2 /* Type */; - case 214 /* ClassDeclaration */: - case 217 /* EnumDeclaration */: - return 1 /* Value */ | 2 /* Type */; - case 218 /* ModuleDeclaration */: - if (node.name.kind === 9 /* StringLiteral */) { - return 4 /* Namespace */ | 1 /* Value */; - } - else if (ts.getModuleInstanceState(node) === 1 /* Instantiated */) { - return 4 /* Namespace */ | 1 /* Value */; - } - else { - return 4 /* Namespace */; - } - case 225 /* NamedImports */: - case 226 /* ImportSpecifier */: - case 221 /* ImportEqualsDeclaration */: - case 222 /* ImportDeclaration */: - case 227 /* ExportAssignment */: - case 228 /* ExportDeclaration */: - return 1 /* Value */ | 2 /* Type */ | 4 /* Namespace */; - // An external module can be a Value - case 248 /* SourceFile */: - return 4 /* Namespace */ | 1 /* Value */; - } - return 1 /* Value */ | 2 /* Type */ | 4 /* Namespace */; - ts.Debug.fail("Unknown declaration type"); - } - function isTypeReference(node) { - if (ts.isRightSideOfQualifiedNameOrPropertyAccess(node)) { - node = node.parent; - } - return node.parent.kind === 151 /* TypeReference */ || - (node.parent.kind === 188 /* ExpressionWithTypeArguments */ && !ts.isExpressionWithTypeArgumentsInClassExtendsClause(node.parent)) || - node.kind === 97 /* ThisKeyword */ && !ts.isExpression(node); - } - function isNamespaceReference(node) { - return isQualifiedNameNamespaceReference(node) || isPropertyAccessNamespaceReference(node); - } - function isPropertyAccessNamespaceReference(node) { - var root = node; - var isLastClause = true; - if (root.parent.kind === 166 /* PropertyAccessExpression */) { - while (root.parent && root.parent.kind === 166 /* PropertyAccessExpression */) { - root = root.parent; - } - isLastClause = root.name === node; - } - if (!isLastClause && root.parent.kind === 188 /* ExpressionWithTypeArguments */ && root.parent.parent.kind === 243 /* HeritageClause */) { - var decl = root.parent.parent.parent; - return (decl.kind === 214 /* ClassDeclaration */ && root.parent.parent.token === 106 /* ImplementsKeyword */) || - (decl.kind === 215 /* InterfaceDeclaration */ && root.parent.parent.token === 83 /* ExtendsKeyword */); - } - return false; - } - function isQualifiedNameNamespaceReference(node) { - var root = node; - var isLastClause = true; - if (root.parent.kind === 135 /* QualifiedName */) { - while (root.parent && root.parent.kind === 135 /* QualifiedName */) { - root = root.parent; - } - isLastClause = root.right === node; - } - return root.parent.kind === 151 /* TypeReference */ && !isLastClause; - } - function isInRightSideOfImport(node) { - while (node.parent.kind === 135 /* QualifiedName */) { - node = node.parent; - } - return ts.isInternalModuleImportEqualsDeclaration(node.parent) && node.parent.moduleReference === node; - } - function getMeaningFromRightHandSideOfImportEquals(node) { - ts.Debug.assert(node.kind === 69 /* Identifier */); - // import a = |b|; // Namespace - // import a = |b.c|; // Value, type, namespace - // import a = |b.c|.d; // Namespace - if (node.parent.kind === 135 /* QualifiedName */ && - node.parent.right === node && - node.parent.parent.kind === 221 /* ImportEqualsDeclaration */) { - return 1 /* Value */ | 2 /* Type */ | 4 /* Namespace */; - } - return 4 /* Namespace */; - } - function getMeaningFromLocation(node) { - if (node.parent.kind === 227 /* ExportAssignment */) { - return 1 /* Value */ | 2 /* Type */ | 4 /* Namespace */; - } - else if (isInRightSideOfImport(node)) { - return getMeaningFromRightHandSideOfImportEquals(node); - } - else if (ts.isDeclarationName(node)) { - return getMeaningFromDeclaration(node.parent); - } - else if (isTypeReference(node)) { - return 2 /* Type */; - } - else if (isNamespaceReference(node)) { - return 4 /* Namespace */; - } - else { - return 1 /* Value */; - } - } - // Signature help - /** - * This is a semantic operation. - */ - function getSignatureHelpItems(fileName, position) { - synchronizeHostData(); - var sourceFile = getValidSourceFile(fileName); - return ts.SignatureHelp.getSignatureHelpItems(program, sourceFile, position, cancellationToken); - } - /// Syntactic features - function getSourceFile(fileName) { - return syntaxTreeCache.getCurrentSourceFile(fileName); - } - function getNameOrDottedNameSpan(fileName, startPos, endPos) { - var sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName); - // Get node at the location - var node = ts.getTouchingPropertyName(sourceFile, startPos); - if (!node) { - return; - } - switch (node.kind) { - case 166 /* PropertyAccessExpression */: - case 135 /* QualifiedName */: - case 9 /* StringLiteral */: - case 84 /* FalseKeyword */: - case 99 /* TrueKeyword */: - case 93 /* NullKeyword */: - case 95 /* SuperKeyword */: - case 97 /* ThisKeyword */: - case 69 /* Identifier */: - break; - // Cant create the text span - default: - return; - } - var nodeForStartPos = node; - while (true) { - if (isRightSideOfPropertyAccess(nodeForStartPos) || isRightSideOfQualifiedName(nodeForStartPos)) { - // If on the span is in right side of the the property or qualified name, return the span from the qualified name pos to end of this node - nodeForStartPos = nodeForStartPos.parent; - } - else if (isNameOfModuleDeclaration(nodeForStartPos)) { - // 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 === 218 /* ModuleDeclaration */ && - nodeForStartPos.parent.parent.body === nodeForStartPos.parent) { - // Use parent module declarations name for start pos - nodeForStartPos = nodeForStartPos.parent.parent.name; - } - else { - // We have to use this name for start pos - break; - } - } - else { - // Is not a member expression so we have found the node for start pos - break; - } - } - return ts.createTextSpanFromBounds(nodeForStartPos.getStart(), node.getEnd()); - } - function getBreakpointStatementAtPosition(fileName, position) { - // doesn't use compiler - no need to synchronize with host - var sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName); - return ts.BreakpointResolver.spanInSourceFileAtLocation(sourceFile, position); - } - function getNavigationBarItems(fileName) { - var sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName); - return ts.NavigationBar.getNavigationBarItems(sourceFile); - } - function getSemanticClassifications(fileName, span) { - return convertClassifications(getEncodedSemanticClassifications(fileName, span)); - } - function checkForClassificationCancellation(kind) { - // We don't want to actually call back into our host on every node to find out if we've - // been canceled. That would be an enormous amount of chattyness, along with the all - // the overhead of marshalling the data to/from the host. So instead we pick a few - // reasonable node kinds to bother checking on. These node kinds represent high level - // constructs that we would expect to see commonly, but just at a far less frequent - // interval. - // - // For example, in checker.ts (around 750k) we only have around 600 of these constructs. - // 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 218 /* ModuleDeclaration */: - case 214 /* ClassDeclaration */: - case 215 /* InterfaceDeclaration */: - case 213 /* FunctionDeclaration */: - cancellationToken.throwIfCancellationRequested(); - } - } - function getEncodedSemanticClassifications(fileName, span) { - synchronizeHostData(); - var sourceFile = getValidSourceFile(fileName); - var typeChecker = program.getTypeChecker(); - var result = []; - var classifiableNames = program.getClassifiableNames(); - processNode(sourceFile); - return { spans: result, endOfLineState: 0 /* None */ }; - function pushClassification(start, length, type) { - result.push(start); - result.push(length); - result.push(type); - } - function classifySymbol(symbol, meaningAtPosition) { - var flags = symbol.getFlags(); - if ((flags & 788448 /* Classifiable */) === 0 /* None */) { - return; - } - if (flags & 32 /* Class */) { - return 11 /* className */; - } - else if (flags & 384 /* Enum */) { - return 12 /* enumName */; - } - else if (flags & 524288 /* TypeAlias */) { - return 16 /* typeAliasName */; - } - else if (meaningAtPosition & 2 /* Type */) { - if (flags & 64 /* Interface */) { - return 13 /* interfaceName */; - } - else if (flags & 262144 /* TypeParameter */) { - return 15 /* typeParameterName */; - } - } - else if (flags & 1536 /* Module */) { - // Only classify a module as such if - // - It appears in a namespace context. - // - There exists a module declaration which actually impacts the value side. - if (meaningAtPosition & 4 /* Namespace */ || - (meaningAtPosition & 1 /* Value */ && hasValueSideModule(symbol))) { - return 14 /* moduleName */; - } - } - return undefined; - /** - * Returns true if there exists a module that introduces entities on the value side. - */ - function hasValueSideModule(symbol) { - return ts.forEach(symbol.declarations, function (declaration) { - return declaration.kind === 218 /* ModuleDeclaration */ && - ts.getModuleInstanceState(declaration) === 1 /* Instantiated */; - }); - } - } - function processNode(node) { - // Only walk into nodes that intersect the requested span. - if (node && ts.textSpanIntersectsWith(span, node.getFullStart(), node.getFullWidth())) { - var kind = node.kind; - checkForClassificationCancellation(kind); - if (kind === 69 /* Identifier */ && !ts.nodeIsMissing(node)) { - var identifier = node; - // Only bother calling into the typechecker if this is an identifier that - // could possibly resolve to a type name. This makes classification run - // in a third of the time it would normally take. - if (classifiableNames[identifier.text]) { - var symbol = typeChecker.getSymbolAtLocation(node); - if (symbol) { - var type = classifySymbol(symbol, getMeaningFromLocation(node)); - if (type) { - pushClassification(node.getStart(), node.getWidth(), type); - } - } - } - } - ts.forEachChild(node, processNode); - } - } - } - function getClassificationTypeName(type) { - switch (type) { - case 1 /* comment */: return ClassificationTypeNames.comment; - case 2 /* identifier */: return ClassificationTypeNames.identifier; - case 3 /* keyword */: return ClassificationTypeNames.keyword; - case 4 /* numericLiteral */: return ClassificationTypeNames.numericLiteral; - case 5 /* operator */: return ClassificationTypeNames.operator; - case 6 /* stringLiteral */: return ClassificationTypeNames.stringLiteral; - case 8 /* whiteSpace */: return ClassificationTypeNames.whiteSpace; - case 9 /* text */: return ClassificationTypeNames.text; - case 10 /* punctuation */: return ClassificationTypeNames.punctuation; - case 11 /* className */: return ClassificationTypeNames.className; - case 12 /* enumName */: return ClassificationTypeNames.enumName; - case 13 /* interfaceName */: return ClassificationTypeNames.interfaceName; - case 14 /* moduleName */: return ClassificationTypeNames.moduleName; - case 15 /* typeParameterName */: return ClassificationTypeNames.typeParameterName; - case 16 /* typeAliasName */: return ClassificationTypeNames.typeAliasName; - case 17 /* parameterName */: return ClassificationTypeNames.parameterName; - case 18 /* docCommentTagName */: return ClassificationTypeNames.docCommentTagName; - } - } - function convertClassifications(classifications) { - ts.Debug.assert(classifications.spans.length % 3 === 0); - var dense = classifications.spans; - var result = []; - for (var i = 0, n = dense.length; i < n; i += 3) { - result.push({ - textSpan: ts.createTextSpan(dense[i], dense[i + 1]), - classificationType: getClassificationTypeName(dense[i + 2]) - }); - } - return result; - } - function getSyntacticClassifications(fileName, span) { - return convertClassifications(getEncodedSyntacticClassifications(fileName, span)); - } - function getEncodedSyntacticClassifications(fileName, span) { - // doesn't use compiler - no need to synchronize with host - var sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName); - 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 result = []; - processElement(sourceFile); - return { spans: result, endOfLineState: 0 /* None */ }; - function pushClassification(start, length, type) { - result.push(start); - result.push(length); - result.push(type); - } - function classifyLeadingTriviaAndGetTokenStart(token) { - triviaScanner.setTextPos(token.pos); - while (true) { - var start = triviaScanner.getTextPos(); - // only bother scanning if we have something that could be trivia. - if (!ts.couldStartTrivia(sourceFile.text, start)) { - return start; - } - var kind = triviaScanner.scan(); - var end = triviaScanner.getTextPos(); - var width = end - start; - // The moment we get something that isn't trivia, then stop processing. - if (!ts.isTrivia(kind)) { - return start; - } - // Don't bother with newlines/whitespace. - if (kind === 4 /* NewLineTrivia */ || kind === 5 /* WhitespaceTrivia */) { - continue; - } - // Only bother with the trivia if it at least intersects the span of interest. - if (ts.isComment(kind)) { - classifyComment(token, kind, start, width); - // Classifying a comment might cause us to reuse the trivia scanner - // (because of jsdoc comments). So after we classify the comment make - // sure we set the scanner position back to where it needs to be. - triviaScanner.setTextPos(end); - continue; - } - if (kind === 7 /* ConflictMarkerTrivia */) { - var text = sourceFile.text; - var ch = text.charCodeAt(start); - // for the <<<<<<< and >>>>>>> markers, we just add them in as comments - // in the classification stream. - if (ch === 60 /* lessThan */ || ch === 62 /* greaterThan */) { - pushClassification(start, width, 1 /* comment */); - continue; - } - // for the ======== add a comment for the first line, and then lex all - // subsequent lines up until the end of the conflict marker. - ts.Debug.assert(ch === 61 /* equals */); - classifyDisabledMergeCode(text, start, end); - } - } - } - function classifyComment(token, kind, start, width) { - if (kind === 3 /* MultiLineCommentTrivia */) { - // See if this is a doc comment. If so, we'll classify certain portions of it - // specially. - var docCommentAndDiagnostics = ts.parseIsolatedJSDocComment(sourceFile.text, start, width); - if (docCommentAndDiagnostics && docCommentAndDiagnostics.jsDocComment) { - docCommentAndDiagnostics.jsDocComment.parent = token; - classifyJSDocComment(docCommentAndDiagnostics.jsDocComment); - return; - } - } - // Simple comment. Just add as is. - pushCommentRange(start, width); - } - function pushCommentRange(start, width) { - pushClassification(start, width, 1 /* comment */); - } - function classifyJSDocComment(docComment) { - var pos = docComment.pos; - for (var _i = 0, _a = docComment.tags; _i < _a.length; _i++) { - var tag = _a[_i]; - // As we walk through each tag, classify the portion of text from the end of - // the last tag (or the start of the entire doc comment) as 'comment'. - if (tag.pos !== pos) { - pushCommentRange(pos, tag.pos - pos); - } - pushClassification(tag.atToken.pos, tag.atToken.end - tag.atToken.pos, 10 /* punctuation */); - pushClassification(tag.tagName.pos, tag.tagName.end - tag.tagName.pos, 18 /* docCommentTagName */); - pos = tag.tagName.end; - switch (tag.kind) { - case 267 /* JSDocParameterTag */: - processJSDocParameterTag(tag); - break; - case 270 /* JSDocTemplateTag */: - processJSDocTemplateTag(tag); - break; - case 269 /* JSDocTypeTag */: - processElement(tag.typeExpression); - break; - case 268 /* JSDocReturnTag */: - processElement(tag.typeExpression); - break; - } - pos = tag.end; - } - if (pos !== docComment.end) { - pushCommentRange(pos, docComment.end - pos); - } - return; - function processJSDocParameterTag(tag) { - if (tag.preParameterName) { - pushCommentRange(pos, tag.preParameterName.pos - pos); - pushClassification(tag.preParameterName.pos, tag.preParameterName.end - tag.preParameterName.pos, 17 /* parameterName */); - pos = tag.preParameterName.end; - } - if (tag.typeExpression) { - pushCommentRange(pos, tag.typeExpression.pos - pos); - processElement(tag.typeExpression); - pos = tag.typeExpression.end; - } - if (tag.postParameterName) { - pushCommentRange(pos, tag.postParameterName.pos - pos); - pushClassification(tag.postParameterName.pos, tag.postParameterName.end - tag.postParameterName.pos, 17 /* parameterName */); - pos = tag.postParameterName.end; - } - } - } - function processJSDocTemplateTag(tag) { - for (var _i = 0, _a = tag.getChildren(); _i < _a.length; _i++) { - var child = _a[_i]; - processElement(child); - } - } - function classifyDisabledMergeCode(text, start, end) { - // Classify the line that the ======= marker is on as a comment. Then just lex - // all further tokens and add them to the result. - for (var i = start; i < end; i++) { - if (ts.isLineBreak(text.charCodeAt(i))) { - break; - } - } - pushClassification(start, i - start, 1 /* comment */); - mergeConflictScanner.setTextPos(i); - while (mergeConflictScanner.getTextPos() < end) { - classifyDisabledCodeToken(); - } - } - function classifyDisabledCodeToken() { - var start = mergeConflictScanner.getTextPos(); - var tokenKind = mergeConflictScanner.scan(); - var end = mergeConflictScanner.getTextPos(); - var type = classifyTokenType(tokenKind); - if (type) { - pushClassification(start, end - start, type); - } - } - function classifyToken(token) { - if (ts.nodeIsMissing(token)) { - return; - } - var tokenStart = classifyLeadingTriviaAndGetTokenStart(token); - var tokenWidth = token.end - tokenStart; - ts.Debug.assert(tokenWidth >= 0); - if (tokenWidth > 0) { - var type = classifyTokenType(token.kind, token); - if (type) { - pushClassification(tokenStart, tokenWidth, type); - } - } - } - // for accurate classification, the actual token should be passed in. however, for - // cases like 'disabled merge code' classification, we just get the token kind and - // classify based on that instead. - function classifyTokenType(tokenKind, token) { - if (ts.isKeyword(tokenKind)) { - return 3 /* keyword */; - } - // Special case < and > If they appear in a generic context they are punctuation, - // not operators. - if (tokenKind === 25 /* LessThanToken */ || tokenKind === 27 /* 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)) { - return 10 /* punctuation */; - } - } - if (ts.isPunctuation(tokenKind)) { - if (token) { - if (tokenKind === 56 /* EqualsToken */) { - // the '=' in a variable declaration is special cased here. - if (token.parent.kind === 211 /* VariableDeclaration */ || - token.parent.kind === 141 /* PropertyDeclaration */ || - token.parent.kind === 138 /* Parameter */) { - return 5 /* operator */; - } - } - if (token.parent.kind === 181 /* BinaryExpression */ || - token.parent.kind === 179 /* PrefixUnaryExpression */ || - token.parent.kind === 180 /* PostfixUnaryExpression */ || - token.parent.kind === 182 /* ConditionalExpression */) { - return 5 /* operator */; - } - } - return 10 /* punctuation */; - } - else if (tokenKind === 8 /* NumericLiteral */) { - return 4 /* numericLiteral */; - } - else if (tokenKind === 9 /* StringLiteral */) { - return 6 /* stringLiteral */; - } - else if (tokenKind === 10 /* RegularExpressionLiteral */) { - // TODO: we should get another classification type for these literals. - return 6 /* stringLiteral */; - } - else if (ts.isTemplateLiteralKind(tokenKind)) { - // TODO (drosen): we should *also* get another classification type for these literals. - return 6 /* stringLiteral */; - } - else if (tokenKind === 69 /* Identifier */) { - if (token) { - switch (token.parent.kind) { - case 214 /* ClassDeclaration */: - if (token.parent.name === token) { - return 11 /* className */; - } - return; - case 137 /* TypeParameter */: - if (token.parent.name === token) { - return 15 /* typeParameterName */; - } - return; - case 215 /* InterfaceDeclaration */: - if (token.parent.name === token) { - return 13 /* interfaceName */; - } - return; - case 217 /* EnumDeclaration */: - if (token.parent.name === token) { - return 12 /* enumName */; - } - return; - case 218 /* ModuleDeclaration */: - if (token.parent.name === token) { - return 14 /* moduleName */; - } - return; - case 138 /* Parameter */: - if (token.parent.name === token) { - return 17 /* parameterName */; - } - return; - } - } - return 2 /* identifier */; - } - } - function processElement(element) { - if (!element) { - return; - } - // Ignore nodes that don't intersect the original span to classify. - if (ts.decodedTextSpanIntersectsWith(spanStart, spanLength, element.pos, element.getFullWidth())) { - checkForClassificationCancellation(element.kind); - var children = element.getChildren(sourceFile); - for (var i = 0, n = children.length; i < n; i++) { - var child = children[i]; - if (ts.isToken(child)) { - classifyToken(child); - } - else { - // Recurse into our child nodes. - processElement(child); - } - } - } - } - } - function getOutliningSpans(fileName) { - // doesn't use compiler - no need to synchronize with host - var sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName); - return ts.OutliningElementsCollector.collectElements(sourceFile); - } - function getBraceMatchingAtPosition(fileName, position) { - var sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName); - var result = []; - var token = ts.getTouchingToken(sourceFile, position); - if (token.getStart(sourceFile) === position) { - var matchKind = getMatchingTokenKind(token); - // Ensure that there is a corresponding token to match ours. - if (matchKind) { - var parentElement = token.parent; - var childNodes = parentElement.getChildren(sourceFile); - for (var _i = 0; _i < childNodes.length; _i++) { - var current = childNodes[_i]; - if (current.kind === matchKind) { - var range1 = ts.createTextSpan(token.getStart(sourceFile), token.getWidth(sourceFile)); - var range2 = ts.createTextSpan(current.getStart(sourceFile), current.getWidth(sourceFile)); - // We want to order the braces when we return the result. - if (range1.start < range2.start) { - result.push(range1, range2); - } - else { - result.push(range2, range1); - } - break; - } - } - } - } - 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 */; - } - return undefined; - } - } - function getIndentationAtPosition(fileName, position, editorOptions) { - var start = new Date().getTime(); - var sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName); - log("getIndentationAtPosition: getCurrentSourceFile: " + (new Date().getTime() - start)); - start = new Date().getTime(); - var result = ts.formatting.SmartIndenter.getIndentation(position, sourceFile, editorOptions); - log("getIndentationAtPosition: computeIndentation : " + (new Date().getTime() - start)); - return result; - } - function getFormattingEditsForRange(fileName, start, end, options) { - var sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName); - return ts.formatting.formatSelection(start, end, sourceFile, getRuleProvider(options), options); - } - function getFormattingEditsForDocument(fileName, options) { - var sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName); - return ts.formatting.formatDocument(sourceFile, getRuleProvider(options), options); - } - function getFormattingEditsAfterKeystroke(fileName, position, key, options) { - var sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName); - if (key === "}") { - return ts.formatting.formatOnClosingCurly(position, sourceFile, getRuleProvider(options), options); - } - else if (key === ";") { - return ts.formatting.formatOnSemicolon(position, sourceFile, getRuleProvider(options), options); - } - else if (key === "\n") { - return ts.formatting.formatOnEnter(position, sourceFile, getRuleProvider(options), options); - } - return []; - } - /** - * Checks if position points to a valid position to add JSDoc comments, and if so, - * returns the appropriate template. Otherwise returns an empty string. - * Valid positions are - * - outside of comments, statements, and expressions, and - * - preceding a: - * - function/constructor/method declaration - * - class declarations - * - variable statements - * - namespace declarations - * - * Hosts should ideally check that: - * - The line is all whitespace up to 'position' before performing the insertion. - * - If the keystroke sequence "/\*\*" induced the call, we also check that the next - * non-whitespace character is '*', which (approximately) indicates whether we added - * the second '*' to complete an existing (JSDoc) comment. - * @param fileName The file in which to perform the check. - * @param position The (character-indexed) position in the file where the check should - * be performed. - */ - function getDocCommentTemplateAtPosition(fileName, position) { - var start = new Date().getTime(); - var sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName); - // Check if in a context where we don't want to perform any insertion - if (ts.isInString(sourceFile, position) || ts.isInComment(sourceFile, position) || ts.hasDocComment(sourceFile, position)) { - return undefined; - } - var tokenAtPos = ts.getTokenAtPosition(sourceFile, position); - var tokenStart = tokenAtPos.getStart(); - if (!tokenAtPos || tokenStart < position) { - return undefined; - } - // TODO: add support for: - // - enums/enum members - // - interfaces - // - property declarations - // - potentially property assignments - var commentOwner; - findOwner: for (commentOwner = tokenAtPos; commentOwner; commentOwner = commentOwner.parent) { - switch (commentOwner.kind) { - case 213 /* FunctionDeclaration */: - case 143 /* MethodDeclaration */: - case 144 /* Constructor */: - case 214 /* ClassDeclaration */: - case 193 /* VariableStatement */: - break findOwner; - case 248 /* SourceFile */: - return undefined; - case 218 /* ModuleDeclaration */: - // If in walking up the tree, we hit a a nested namespace declaration, - // then we must be somewhere within a dotted namespace name; however we don't - // want to give back a JSDoc template for the 'b' or 'c' in 'namespace a.b.c { }'. - if (commentOwner.parent.kind === 218 /* ModuleDeclaration */) { - return undefined; - } - break findOwner; - } - } - if (!commentOwner || commentOwner.getStart() < position) { - return undefined; - } - var parameters = getParametersForJsDocOwningNode(commentOwner); - var posLineAndChar = sourceFile.getLineAndCharacterOfPosition(position); - var lineStart = sourceFile.getLineStarts()[posLineAndChar.line]; - var indentationStr = sourceFile.text.substr(lineStart, posLineAndChar.character); - // TODO: call a helper method instead once PR #4133 gets merged in. - var newLine = host.getNewLine ? host.getNewLine() : "\r\n"; - var docParams = ""; - for (var i = 0, numParams = parameters.length; i < numParams; i++) { - var currentName = parameters[i].name; - var paramName = currentName.kind === 69 /* Identifier */ ? - currentName.text : - "param" + i; - docParams += indentationStr + " * @param " + paramName + newLine; - } - // A doc comment consists of the following - // * The opening comment line - // * the first line (without a param) for the object's untagged info (this is also where the caret ends up) - // * the '@param'-tagged lines - // * TODO: other tags. - // * the closing comment line - // * if the caret was directly in front of the object, then we add an extra line and indentation. - var preamble = "/**" + newLine + - indentationStr + " * "; - var result = preamble + newLine + - docParams + - indentationStr + " */" + - (tokenStart === position ? newLine + indentationStr : ""); - return { newText: result, caretOffset: preamble.length }; - } - function getParametersForJsDocOwningNode(commentOwner) { - if (ts.isFunctionLike(commentOwner)) { - return commentOwner.parameters; - } - if (commentOwner.kind === 193 /* VariableStatement */) { - var varStatement = commentOwner; - var varDeclarations = varStatement.declarationList.declarations; - if (varDeclarations.length === 1 && varDeclarations[0].initializer) { - return getParametersFromRightHandSideOfAssignment(varDeclarations[0].initializer); - } - } - return emptyArray; - } - /** - * Digs into an an initializer or RHS operand of an assignment operation - * to get the parameters of an apt signature corresponding to a - * function expression or a class expression. - * - * @param rightHandSide the expression which may contain an appropriate set of parameters - * @returns the parameters of a signature found on the RHS if one exists; otherwise 'emptyArray'. - */ - function getParametersFromRightHandSideOfAssignment(rightHandSide) { - while (rightHandSide.kind === 172 /* ParenthesizedExpression */) { - rightHandSide = rightHandSide.expression; - } - switch (rightHandSide.kind) { - case 173 /* FunctionExpression */: - case 174 /* ArrowFunction */: - return rightHandSide.parameters; - case 186 /* ClassExpression */: - for (var _i = 0, _a = rightHandSide.members; _i < _a.length; _i++) { - var member = _a[_i]; - if (member.kind === 144 /* Constructor */) { - return member.parameters; - } - } - break; - } - return emptyArray; - } - function getTodoComments(fileName, descriptors) { - // Note: while getting todo comments seems like a syntactic operation, we actually - // treat it as a semantic operation here. This is because we expect our host to call - // this on every single file. If we treat this syntactically, then that will cause - // us to populate and throw away the tree in our syntax tree cache for each file. By - // treating this as a semantic operation, we can access any tree without throwing - // anything away. - synchronizeHostData(); - var sourceFile = getValidSourceFile(fileName); - cancellationToken.throwIfCancellationRequested(); - var fileContents = sourceFile.text; - var result = []; - if (descriptors.length > 0) { - var regExp = getTodoCommentsRegExp(); - var matchArray; - while (matchArray = regExp.exec(fileContents)) { - cancellationToken.throwIfCancellationRequested(); - // If we got a match, here is what the match array will look like. Say the source text is: - // - // " // hack 1" - // - // The result array with the regexp: will be: - // - // ["// hack 1", "// ", "hack 1", undefined, "hack"] - // - // Here are the relevant capture groups: - // 0) The full match for the entire regexp. - // 1) The preamble to the message portion. - // 2) The message portion. - // 3...N) The descriptor that was matched - by index. 'undefined' for each - // descriptor that didn't match. an actual value if it did match. - // - // i.e. 'undefined' in position 3 above means TODO(jason) didn't match. - // "hack" in position 4 means HACK did match. - var firstDescriptorCaptureIndex = 3; - ts.Debug.assert(matchArray.length === descriptors.length + firstDescriptorCaptureIndex); - var preamble = matchArray[1]; - var matchPosition = matchArray.index + preamble.length; - // OK, we have found a match in the file. This is only an acceptable match if - // it is contained within a comment. - var token = ts.getTokenAtPosition(sourceFile, matchPosition); - if (!isInsideComment(sourceFile, token, matchPosition)) { - continue; - } - var descriptor = undefined; - for (var i = 0, n = descriptors.length; i < n; i++) { - if (matchArray[i + firstDescriptorCaptureIndex]) { - descriptor = descriptors[i]; - } - } - ts.Debug.assert(descriptor !== undefined); - // We don't want to match something like 'TODOBY', so we make sure a non - // letter/digit follows the match. - if (isLetterOrDigit(fileContents.charCodeAt(matchPosition + descriptor.text.length))) { - continue; - } - var message = matchArray[2]; - result.push({ - descriptor: descriptor, - message: message, - position: matchPosition - }); - } - } - return result; - function escapeRegExp(str) { - return str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&"); - } - function getTodoCommentsRegExp() { - // NOTE: ?: means 'non-capture group'. It allows us to have groups without having to - // filter them out later in the final result array. - // TODO comments can appear in one of the following forms: - // - // 1) // TODO or /////////// TODO - // - // 2) /* TODO or /********** TODO - // - // 3) /* - // * TODO - // */ - // - // The following three regexps are used to match the start of the text up to the TODO - // comment portion. - var singleLineCommentStart = /(?:\/\/+\s*)/.source; - var multiLineCommentStart = /(?:\/\*+\s*)/.source; - var anyNumberOfSpacesAndAsterixesAtStartOfLine = /(?:^(?:\s|\*)*)/.source; - // Match any of the above three TODO comment start regexps. - // Note that the outermost group *is* a capture group. We want to capture the preamble - // so that we can determine the starting position of the TODO comment match. - var preamble = "(" + anyNumberOfSpacesAndAsterixesAtStartOfLine + "|" + singleLineCommentStart + "|" + multiLineCommentStart + ")"; - // Takes the descriptors and forms a regexp that matches them as if they were literals. - // For example, if the descriptors are "TODO(jason)" and "HACK", then this will be: - // - // (?:(TODO\(jason\))|(HACK)) - // - // Note that the outermost group is *not* a capture group, but the innermost groups - // *are* capture groups. By capturing the inner literals we can determine after - // matching which descriptor we are dealing with. - var literals = "(?:" + ts.map(descriptors, function (d) { return "(" + escapeRegExp(d.text) + ")"; }).join("|") + ")"; - // After matching a descriptor literal, the following regexp matches the rest of the - // text up to the end of the line (or */). - var endOfLineOrEndOfComment = /(?:$|\*\/)/.source; - var messageRemainder = /(?:.*?)/.source; - // This is the portion of the match we'll return as part of the TODO comment result. We - // match the literal portion up to the end of the line or end of comment. - var messagePortion = "(" + literals + messageRemainder + ")"; - var regExpString = preamble + messagePortion + endOfLineOrEndOfComment; - // The final regexp will look like this: - // /((?:\/\/+\s*)|(?:\/\*+\s*)|(?:^(?:\s|\*)*))((?:(TODO\(jason\))|(HACK))(?:.*?))(?:$|\*\/)/gim - // The flags of the regexp are important here. - // 'g' is so that we are doing a global search and can find matches several times - // in the input. - // - // 'i' is for case insensitivity (We do this to match C# TODO comment code). - // - // 'm' is so we can find matches in a multi-line input. - return new RegExp(regExpString, "gim"); - } - function isLetterOrDigit(char) { - return (char >= 97 /* a */ && char <= 122 /* z */) || - (char >= 65 /* A */ && char <= 90 /* Z */) || - (char >= 48 /* _0 */ && char <= 57 /* _9 */); - } - } - function getRenameInfo(fileName, position) { - synchronizeHostData(); - var sourceFile = getValidSourceFile(fileName); - var typeChecker = program.getTypeChecker(); - var node = ts.getTouchingWord(sourceFile, position); - // Can only rename an identifier. - if (node && node.kind === 69 /* Identifier */) { - var symbol = typeChecker.getSymbolAtLocation(node); - // Only allow a symbol to be renamed if it actually has at least one declaration. - if (symbol) { - var declarations = symbol.getDeclarations(); - if (declarations && declarations.length > 0) { - // Disallow rename for elements that are defined in the standard TypeScript library. - var defaultLibFileName = host.getDefaultLibFileName(host.getCompilationSettings()); - if (defaultLibFileName) { - for (var _i = 0; _i < declarations.length; _i++) { - var current = declarations[_i]; - var sourceFile_2 = current.getSourceFile(); - var canonicalName = getCanonicalFileName(ts.normalizePath(sourceFile_2.fileName)); - if (sourceFile_2 && getCanonicalFileName(ts.normalizePath(sourceFile_2.fileName)) === getCanonicalFileName(ts.normalizePath(defaultLibFileName))) { - return getRenameInfoError(ts.getLocaleSpecificMessage(ts.Diagnostics.You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library.key)); - } - } - } - var displayName = ts.stripQuotes(ts.getDeclaredName(typeChecker, symbol, node)); - var kind = getSymbolKind(symbol, node); - if (kind) { - return { - canRename: true, - localizedErrorMessage: undefined, - displayName: displayName, - fullDisplayName: typeChecker.getFullyQualifiedName(symbol), - kind: kind, - kindModifiers: getSymbolModifiers(symbol), - triggerSpan: ts.createTextSpan(node.getStart(), node.getWidth()) - }; - } - } - } - } - return getRenameInfoError(ts.getLocaleSpecificMessage(ts.Diagnostics.You_cannot_rename_this_element.key)); - function getRenameInfoError(localizedErrorMessage) { - return { - canRename: false, - localizedErrorMessage: localizedErrorMessage, - displayName: undefined, - fullDisplayName: undefined, - kind: undefined, - kindModifiers: undefined, - triggerSpan: undefined - }; - } - } - return { - dispose: dispose, - cleanupSemanticCache: cleanupSemanticCache, - getSyntacticDiagnostics: getSyntacticDiagnostics, - getSemanticDiagnostics: getSemanticDiagnostics, - getCompilerOptionsDiagnostics: getCompilerOptionsDiagnostics, - getSyntacticClassifications: getSyntacticClassifications, - getSemanticClassifications: getSemanticClassifications, - getEncodedSyntacticClassifications: getEncodedSyntacticClassifications, - getEncodedSemanticClassifications: getEncodedSemanticClassifications, - getCompletionsAtPosition: getCompletionsAtPosition, - getCompletionEntryDetails: getCompletionEntryDetails, - getSignatureHelpItems: getSignatureHelpItems, - getQuickInfoAtPosition: getQuickInfoAtPosition, - getDefinitionAtPosition: getDefinitionAtPosition, - getTypeDefinitionAtPosition: getTypeDefinitionAtPosition, - getReferencesAtPosition: getReferencesAtPosition, - findReferences: findReferences, - getOccurrencesAtPosition: getOccurrencesAtPosition, - getDocumentHighlights: getDocumentHighlights, - getNameOrDottedNameSpan: getNameOrDottedNameSpan, - getBreakpointStatementAtPosition: getBreakpointStatementAtPosition, - getNavigateToItems: getNavigateToItems, - getRenameInfo: getRenameInfo, - findRenameLocations: findRenameLocations, - getNavigationBarItems: getNavigationBarItems, - getOutliningSpans: getOutliningSpans, - getTodoComments: getTodoComments, - getBraceMatchingAtPosition: getBraceMatchingAtPosition, - getIndentationAtPosition: getIndentationAtPosition, - getFormattingEditsForRange: getFormattingEditsForRange, - getFormattingEditsForDocument: getFormattingEditsForDocument, - getFormattingEditsAfterKeystroke: getFormattingEditsAfterKeystroke, - getDocCommentTemplateAtPosition: getDocCommentTemplateAtPosition, - getEmitOutput: getEmitOutput, - getSourceFile: getSourceFile, - getProgram: getProgram - }; - } - ts.createLanguageService = createLanguageService; - /* @internal */ - function getNameTable(sourceFile) { - if (!sourceFile.nameTable) { - initializeNameTable(sourceFile); - } - return sourceFile.nameTable; - } - ts.getNameTable = getNameTable; - function initializeNameTable(sourceFile) { - var nameTable = {}; - walk(sourceFile); - sourceFile.nameTable = nameTable; - function walk(node) { - switch (node.kind) { - case 69 /* Identifier */: - nameTable[node.text] = node.text; - break; - case 9 /* StringLiteral */: - case 8 /* NumericLiteral */: - // We want to store any numbers/strings if they were a name that could be - // related to a declaration. So, if we have 'import x = require("something")' - // 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 === 232 /* ExternalModuleReference */ || - isArgumentOfElementAccessExpression(node)) { - nameTable[node.text] = node.text; - } - break; - default: - ts.forEachChild(node, walk); - } - } - } - function isArgumentOfElementAccessExpression(node) { - return node && - node.parent && - node.parent.kind === 167 /* ElementAccessExpression */ && - node.parent.argumentExpression === node; - } - /// Classifier - function createClassifier() { - var scanner = ts.createScanner(2 /* 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[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; - // 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 - // lines, just as we do with the end-of-line state. However, this is a burden for implementers, - // and the behavior is entirely subsumed by the syntactic classifier anyway, so we instead - // flatten any nesting when the template stack is non-empty and encode it in the end-of-line state. - // Situations in which this fails are - // 1) When template strings are nested across different lines: - // `hello ${ `world - // ` }` - // - // Where on the second line, you will get the closing of a template, - // a closing curly, and a new template. - // - // 2) When substitution expressions have curly braces and the curly brace falls on the next line: - // `hello ${ () => { - // return "world" } } ` - // - // Where on the second line, you will get the 'return' keyword, - // a string literal, and a template end consisting of '} } `'. - var templateStack = []; - /** 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 === 129 /* SetKeyword */ || - keyword2 === 121 /* ConstructorKeyword */ || - keyword2 === 113 /* StaticKeyword */) { - // Allow things like "public get", "public constructor" and "public static". - // These are all legal. - return true; - } - // Any other keyword following "public" is actually an identifier an not a real - // keyword. - return false; - } - // Assume any other keyword combination is legal. This can be refined in the future - // if there are more cases we want the classifier to be better at. - return true; - } - function convertClassifications(classifications, text) { - var entries = []; - var dense = classifications.spans; - var lastEnd = 0; - for (var i = 0, n = dense.length; i < n; i += 3) { - var start = dense[i]; - var length_3 = dense[i + 1]; - var type = dense[i + 2]; - // Make a whitespace entry between the last item and this one. - if (lastEnd >= 0) { - var whitespaceLength_1 = start - lastEnd; - if (whitespaceLength_1 > 0) { - entries.push({ length: whitespaceLength_1, classification: TokenClass.Whitespace }); - } - } - entries.push({ length: length_3, classification: convertClassification(type) }); - lastEnd = start + length_3; - } - var whitespaceLength = text.length - lastEnd; - if (whitespaceLength > 0) { - entries.push({ length: whitespaceLength, classification: TokenClass.Whitespace }); - } - return { entries: entries, finalLexState: classifications.endOfLineState }; - } - function convertClassification(type) { - switch (type) { - case 1 /* comment */: return TokenClass.Comment; - case 3 /* keyword */: return TokenClass.Keyword; - case 4 /* numericLiteral */: return TokenClass.NumberLiteral; - case 5 /* operator */: return TokenClass.Operator; - case 6 /* stringLiteral */: return TokenClass.StringLiteral; - case 8 /* whiteSpace */: return TokenClass.Whitespace; - case 10 /* punctuation */: return TokenClass.Punctuation; - case 2 /* identifier */: - case 11 /* className */: - case 12 /* enumName */: - case 13 /* interfaceName */: - case 14 /* moduleName */: - case 15 /* typeParameterName */: - case 16 /* typeAliasName */: - case 9 /* text */: - case 17 /* parameterName */: - default: - return TokenClass.Identifier; - } - } - function getClassificationsForLine(text, lexState, syntacticClassifierAbsent) { - return convertClassifications(getEncodedLexicalClassifications(text, lexState, syntacticClassifierAbsent), text); - } - // If there is a syntactic classifier ('syntacticClassifierAbsent' is false), - // we will be more conservative in order to avoid conflicting with the syntactic classifier. - function getEncodedLexicalClassifications(text, lexState, syntacticClassifierAbsent) { - var offset = 0; - var token = 0 /* Unknown */; - var lastNonTriviaToken = 0 /* Unknown */; - // Empty out the template stack for reuse. - while (templateStack.length > 0) { - templateStack.pop(); - } - // If we're in a string literal, then prepend: "\ - // (and a newline). That way when we lex we'll think we're still in a string literal. - // - // If we're in a multiline comment, then prepend: /* - // (and a newline). That way when we lex we'll think we're still in a multiline comment. - switch (lexState) { - case 3 /* InDoubleQuoteStringLiteral */: - text = '"\\\n' + text; - offset = 3; - break; - case 2 /* InSingleQuoteStringLiteral */: - text = "'\\\n" + text; - offset = 3; - break; - case 1 /* InMultiLineCommentTrivia */: - text = "/*\n" + text; - offset = 3; - break; - case 4 /* InTemplateHeadOrNoSubstitutionTemplate */: - text = "`\n" + text; - offset = 2; - break; - case 5 /* InTemplateMiddleOrTail */: - text = "}\n" + text; - offset = 2; - // fallthrough - case 6 /* InTemplateSubstitutionPosition */: - templateStack.push(12 /* TemplateHead */); - break; - } - scanner.setText(text); - var result = { - endOfLineState: 0 /* None */, - spans: [] - }; - // We can run into an unfortunate interaction between the lexical and syntactic classifier - // when the user is typing something generic. Consider the case where the user types: - // - // Foo tokens. It's a weak heuristic, but should - // work well enough in practice. - var angleBracketStack = 0; - 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 */; - } - } - else if (lastNonTriviaToken === 21 /* DotToken */ && isKeyword(token)) { - token = 69 /* Identifier */; - } - else if (isKeyword(lastNonTriviaToken) && isKeyword(token) && !canFollow(lastNonTriviaToken, token)) { - // We have two keywords in a row. Only treat the second as a keyword if - // it's a sequence that could legally occur in the language. Otherwise - // treat it as an identifier. This way, if someone writes "private var" - // we recognize that 'var' is actually an identifier here. - token = 69 /* Identifier */; - } - else if (lastNonTriviaToken === 69 /* Identifier */ && - token === 25 /* LessThanToken */) { - // Could be the start of something generic. Keep track of that by bumping - // up the current count of generic contexts we may be in. - angleBracketStack++; - } - else if (token === 27 /* 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 === 130 /* StringKeyword */ || - token === 128 /* NumberKeyword */ || - token === 120 /* BooleanKeyword */ || - token === 131 /* SymbolKeyword */) { - if (angleBracketStack > 0 && !syntacticClassifierAbsent) { - // If it looks like we're could be in something generic, don't classify this - // as a keyword. We may just get overwritten by the syntactic classifier, - // causing a noisy experience for the user. - token = 69 /* Identifier */; - } - } - else if (token === 12 /* TemplateHead */) { - templateStack.push(token); - } - else if (token === 15 /* 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 */) { - // 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 */) { - token = scanner.reScanTemplateToken(); - // Only pop on a TemplateTail; a TemplateMiddle indicates there is more for us. - if (token === 14 /* TemplateTail */) { - templateStack.pop(); - } - else { - ts.Debug.assert(token === 13 /* TemplateMiddle */, "Should have been a template middle. Was " + token); - } - } - else { - ts.Debug.assert(lastTemplateStackToken === 15 /* OpenBraceToken */, "Should have been an open brace. Was: " + token); - templateStack.pop(); - } - } - } - lastNonTriviaToken = token; - } - processToken(); - } while (token !== 1 /* EndOfFileToken */); - return result; - function processToken() { - var start = scanner.getTokenPos(); - var end = scanner.getTextPos(); - addResult(start, end, classFromKind(token)); - if (end >= text.length) { - if (token === 9 /* StringLiteral */) { - // Check to see if we finished up on a multiline string literal. - var tokenText = scanner.getTokenText(); - if (scanner.isUnterminated()) { - var lastCharIndex = tokenText.length - 1; - var numBackslashes = 0; - while (tokenText.charCodeAt(lastCharIndex - numBackslashes) === 92 /* backslash */) { - numBackslashes++; - } - // If we have an odd number of backslashes, then the multiline string is unclosed - if (numBackslashes & 1) { - var quoteChar = tokenText.charCodeAt(0); - result.endOfLineState = quoteChar === 34 /* doubleQuote */ - ? 3 /* InDoubleQuoteStringLiteral */ - : 2 /* InSingleQuoteStringLiteral */; - } - } - } - else if (token === 3 /* MultiLineCommentTrivia */) { - // Check to see if the multiline comment was unclosed. - if (scanner.isUnterminated()) { - result.endOfLineState = 1 /* InMultiLineCommentTrivia */; - } - } - else if (ts.isTemplateLiteralKind(token)) { - if (scanner.isUnterminated()) { - if (token === 14 /* TemplateTail */) { - result.endOfLineState = 5 /* InTemplateMiddleOrTail */; - } - else if (token === 11 /* NoSubstitutionTemplateLiteral */) { - result.endOfLineState = 4 /* InTemplateHeadOrNoSubstitutionTemplate */; - } - else { - ts.Debug.fail("Only 'NoSubstitutionTemplateLiteral's and 'TemplateTail's can be unterminated; got SyntaxKind #" + token); - } - } - } - else if (templateStack.length > 0 && ts.lastOrUndefined(templateStack) === 12 /* TemplateHead */) { - result.endOfLineState = 6 /* InTemplateSubstitutionPosition */; - } - } - } - function addResult(start, end, classification) { - if (classification === 8 /* whiteSpace */) { - // Don't bother with whitespace classifications. They're not needed. - return; - } - if (start === 0 && offset > 0) { - // We're classifying the first token, and this was a case where we prepended - // text. We should consider the start of this token to be at the start of - // the original text. - start += offset; - } - // All our tokens are in relation to the augmented text. Move them back to be - // relative to the original text. - start -= offset; - end -= offset; - var length = end - start; - if (length > 0) { - result.spans.push(start); - result.spans.push(length); - result.spans.push(classification); - } - } - } - 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 */: - return true; - default: - return false; - } - } - function isPrefixUnaryExpressionOperatorToken(token) { - switch (token) { - case 35 /* PlusToken */: - case 36 /* MinusToken */: - case 50 /* TildeToken */: - case 49 /* ExclamationToken */: - case 41 /* PlusPlusToken */: - case 42 /* MinusMinusToken */: - return true; - default: - return false; - } - } - function isKeyword(token) { - return token >= 70 /* FirstKeyword */ && token <= 134 /* LastKeyword */; - } - function classFromKind(token) { - if (isKeyword(token)) { - return 3 /* keyword */; - } - else if (isBinaryExpressionOperatorToken(token) || isPrefixUnaryExpressionOperatorToken(token)) { - return 5 /* operator */; - } - else if (token >= 15 /* FirstPunctuation */ && token <= 68 /* LastPunctuation */) { - return 10 /* punctuation */; - } - switch (token) { - case 8 /* NumericLiteral */: - return 4 /* numericLiteral */; - case 9 /* StringLiteral */: - return 6 /* stringLiteral */; - case 10 /* RegularExpressionLiteral */: - return 7 /* regularExpressionLiteral */; - case 7 /* ConflictMarkerTrivia */: - case 3 /* MultiLineCommentTrivia */: - case 2 /* SingleLineCommentTrivia */: - return 1 /* comment */; - case 5 /* WhitespaceTrivia */: - case 4 /* NewLineTrivia */: - return 8 /* whiteSpace */; - case 69 /* Identifier */: - default: - if (ts.isTemplateLiteralKind(token)) { - return 6 /* stringLiteral */; - } - return 2 /* identifier */; - } - } - return { - getClassificationsForLine: getClassificationsForLine, - getEncodedLexicalClassifications: getEncodedLexicalClassifications - }; - } - ts.createClassifier = createClassifier; - /** - * Get the path of the default library files (lib.d.ts) as distributed with the typescript - * node package. - * The functionality is not supported if the ts module is consumed outside of a node module. - */ - function getDefaultLibFilePath(options) { - // Check __dirname is defined and that we are on a node.js system. - if (typeof __dirname !== "undefined") { - return __dirname + ts.directorySeparator + ts.getDefaultLibFileName(options); - } - throw new Error("getDefaultLibFilePath is only supported when consumed as a node module. "); - } - ts.getDefaultLibFilePath = getDefaultLibFilePath; - function initializeServices() { - ts.objectAllocator = { - getNodeConstructor: function (kind) { - function Node(pos, end) { - this.pos = pos; - this.end = end; - this.flags = 0 /* None */; - this.parent = undefined; - } - var proto = kind === 248 /* SourceFile */ ? new SourceFileObject() : new NodeObject(); - proto.kind = kind; - Node.prototype = proto; - return Node; - }, - getSymbolConstructor: function () { return SymbolObject; }, - getTypeConstructor: function () { return TypeObject; }, - getSignatureConstructor: function () { return SignatureObject; } - }; - } - initializeServices(); -})(ts || (ts = {})); -// Copyright (c) Microsoft. All rights reserved. Licensed under the Apache License, Version 2.0. -// See LICENSE.txt in the project root for complete license information. -/// -/* @internal */ -var ts; -(function (ts) { - var BreakpointResolver; - (function (BreakpointResolver) { - /** - * Get the breakpoint span in given sourceFile - */ - function spanInSourceFileAtLocation(sourceFile, position) { - // Cannot set breakpoint in dts file - if (sourceFile.flags & 8192 /* DeclarationFile */) { - return undefined; - } - var tokenAtLocation = ts.getTokenAtPosition(sourceFile, position); - var lineOfPosition = sourceFile.getLineAndCharacterOfPosition(position).line; - if (sourceFile.getLineAndCharacterOfPosition(tokenAtLocation.getStart()).line > lineOfPosition) { - // Get previous token if the token is returned starts on new line - // eg: let x =10; |--- cursor is here - // let y = 10; - // token at position will return let keyword on second line as the token but we would like to use - // token on same line if trailing trivia (comments or white spaces on same line) part of the last token on that line - tokenAtLocation = ts.findPrecedingToken(tokenAtLocation.pos, sourceFile); - // Its a blank line - if (!tokenAtLocation || sourceFile.getLineAndCharacterOfPosition(tokenAtLocation.getEnd()).line !== lineOfPosition) { - return undefined; - } - } - // Cannot set breakpoint in ambient declarations - if (ts.isInAmbientContext(tokenAtLocation)) { - return undefined; - } - // Get the span in the node based on its syntax - return spanInNode(tokenAtLocation); - function textSpan(startNode, endNode) { - return ts.createTextSpanFromBounds(startNode.getStart(), (endNode || startNode).getEnd()); - } - function spanInNodeIfStartsOnSameLine(node, otherwiseOnNode) { - if (node && lineOfPosition === sourceFile.getLineAndCharacterOfPosition(node.getStart()).line) { - return spanInNode(node); - } - return spanInNode(otherwiseOnNode); - } - function spanInPreviousNode(node) { - return spanInNode(ts.findPrecedingToken(node.pos, sourceFile)); - } - function spanInNextNode(node) { - return spanInNode(ts.findNextToken(node, node.parent)); - } - function spanInNode(node) { - if (node) { - if (ts.isExpression(node)) { - if (node.parent.kind === 197 /* DoStatement */) { - // Set span as if on while keyword - return spanInPreviousNode(node); - } - if (node.parent.kind === 199 /* ForStatement */) { - // For now lets set the span on this expression, fix it later - return textSpan(node); - } - if (node.parent.kind === 181 /* BinaryExpression */ && node.parent.operatorToken.kind === 24 /* CommaToken */) { - // if this is comma expression, the breakpoint is possible in this expression - return textSpan(node); - } - if (node.parent.kind === 174 /* ArrowFunction */ && node.parent.body === node) { - // If this is body of arrow function, it is allowed to have the breakpoint - return textSpan(node); - } - } - switch (node.kind) { - case 193 /* VariableStatement */: - // Span on first variable declaration - return spanInVariableDeclaration(node.declarationList.declarations[0]); - case 211 /* VariableDeclaration */: - case 141 /* PropertyDeclaration */: - case 140 /* PropertySignature */: - return spanInVariableDeclaration(node); - case 138 /* Parameter */: - return spanInParameterDeclaration(node); - case 213 /* FunctionDeclaration */: - case 143 /* MethodDeclaration */: - case 142 /* MethodSignature */: - case 145 /* GetAccessor */: - case 146 /* SetAccessor */: - case 144 /* Constructor */: - case 173 /* FunctionExpression */: - case 174 /* ArrowFunction */: - return spanInFunctionDeclaration(node); - case 192 /* Block */: - if (ts.isFunctionBlock(node)) { - return spanInFunctionBlock(node); - } - // Fall through - case 219 /* ModuleBlock */: - return spanInBlock(node); - case 244 /* CatchClause */: - return spanInBlock(node.block); - case 195 /* ExpressionStatement */: - // span on the expression - return textSpan(node.expression); - case 204 /* ReturnStatement */: - // span on return keyword and expression if present - return textSpan(node.getChildAt(0), node.expression); - case 198 /* WhileStatement */: - // Span on while(...) - return textSpan(node, ts.findNextToken(node.expression, node)); - case 197 /* DoStatement */: - // span in statement of the do statement - return spanInNode(node.statement); - case 210 /* DebuggerStatement */: - // span on debugger keyword - return textSpan(node.getChildAt(0)); - case 196 /* IfStatement */: - // set on if(..) span - return textSpan(node, ts.findNextToken(node.expression, node)); - case 207 /* LabeledStatement */: - // span in statement - return spanInNode(node.statement); - case 203 /* BreakStatement */: - case 202 /* ContinueStatement */: - // On break or continue keyword and label if present - return textSpan(node.getChildAt(0), node.label); - case 199 /* ForStatement */: - return spanInForStatement(node); - case 200 /* ForInStatement */: - case 201 /* ForOfStatement */: - // span on for (a in ...) - return textSpan(node, ts.findNextToken(node.expression, node)); - case 206 /* SwitchStatement */: - // span on switch(...) - return textSpan(node, ts.findNextToken(node.expression, node)); - case 241 /* CaseClause */: - case 242 /* DefaultClause */: - // span in first statement of the clause - return spanInNode(node.statements[0]); - case 209 /* TryStatement */: - // span in try block - return spanInBlock(node.tryBlock); - case 208 /* ThrowStatement */: - // span in throw ... - return textSpan(node, node.expression); - case 227 /* ExportAssignment */: - // span on export = id - return textSpan(node, node.expression); - case 221 /* ImportEqualsDeclaration */: - // import statement without including semicolon - return textSpan(node, node.moduleReference); - case 222 /* ImportDeclaration */: - // import statement without including semicolon - return textSpan(node, node.moduleSpecifier); - case 228 /* ExportDeclaration */: - // import statement without including semicolon - return textSpan(node, node.moduleSpecifier); - case 218 /* ModuleDeclaration */: - // span on complete module if it is instantiated - if (ts.getModuleInstanceState(node) !== 1 /* Instantiated */) { - return undefined; - } - case 214 /* ClassDeclaration */: - case 217 /* EnumDeclaration */: - case 247 /* EnumMember */: - case 168 /* CallExpression */: - case 169 /* NewExpression */: - // span on complete node - return textSpan(node); - case 205 /* WithStatement */: - // span in statement - return spanInNode(node.statement); - // No breakpoint in interface, type alias - case 215 /* InterfaceDeclaration */: - case 216 /* TypeAliasDeclaration */: - return undefined; - // Tokens: - case 23 /* SemicolonToken */: - case 1 /* EndOfFileToken */: - return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile)); - case 24 /* CommaToken */: - return spanInPreviousNode(node); - case 15 /* OpenBraceToken */: - return spanInOpenBraceToken(node); - case 16 /* CloseBraceToken */: - return spanInCloseBraceToken(node); - case 17 /* OpenParenToken */: - return spanInOpenParenToken(node); - case 18 /* CloseParenToken */: - return spanInCloseParenToken(node); - case 54 /* ColonToken */: - return spanInColonToken(node); - case 27 /* GreaterThanToken */: - case 25 /* LessThanToken */: - return spanInGreaterThanOrLessThanToken(node); - // Keywords: - case 104 /* WhileKeyword */: - return spanInWhileKeyword(node); - case 80 /* ElseKeyword */: - case 72 /* CatchKeyword */: - case 85 /* FinallyKeyword */: - return spanInNextNode(node); - default: - // If this is name of property assignment, set breakpoint in the initializer - if (node.parent.kind === 245 /* PropertyAssignment */ && node.parent.name === node) { - return spanInNode(node.parent.initializer); - } - // Breakpoint in type assertion goes to its operand - if (node.parent.kind === 171 /* TypeAssertionExpression */ && node.parent.type === node) { - return spanInNode(node.parent.expression); - } - // return type of function go to previous token - if (ts.isFunctionLike(node.parent) && node.parent.type === node) { - return spanInPreviousNode(node); - } - // Default go to parent to set the breakpoint - return spanInNode(node.parent); - } - } - function spanInVariableDeclaration(variableDeclaration) { - // If declaration of for in statement, just set the span in parent - if (variableDeclaration.parent.parent.kind === 200 /* ForInStatement */ || - variableDeclaration.parent.parent.kind === 201 /* ForOfStatement */) { - return spanInNode(variableDeclaration.parent.parent); - } - var isParentVariableStatement = variableDeclaration.parent.parent.kind === 193 /* VariableStatement */; - var isDeclarationOfForStatement = variableDeclaration.parent.parent.kind === 199 /* ForStatement */ && ts.contains(variableDeclaration.parent.parent.initializer.declarations, variableDeclaration); - var declarations = isParentVariableStatement - ? variableDeclaration.parent.parent.declarationList.declarations - : isDeclarationOfForStatement - ? variableDeclaration.parent.parent.initializer.declarations - : undefined; - // Breakpoint is possible in variableDeclaration only if there is initialization - if (variableDeclaration.initializer || (variableDeclaration.flags & 1 /* Export */)) { - if (declarations && declarations[0] === variableDeclaration) { - if (isParentVariableStatement) { - // First declaration - include let keyword - return textSpan(variableDeclaration.parent, variableDeclaration); - } - else { - ts.Debug.assert(isDeclarationOfForStatement); - // Include let keyword from for statement declarations in the span - return textSpan(ts.findPrecedingToken(variableDeclaration.pos, sourceFile, variableDeclaration.parent), variableDeclaration); - } - } - else { - // Span only on this declaration - return textSpan(variableDeclaration); - } - } - else if (declarations && declarations[0] !== variableDeclaration) { - // If we cant set breakpoint on this declaration, set it on previous one - var indexOfCurrentDeclaration = ts.indexOf(declarations, variableDeclaration); - return spanInVariableDeclaration(declarations[indexOfCurrentDeclaration - 1]); - } - } - function canHaveSpanInParameterDeclaration(parameter) { - // Breakpoint is possible on parameter only if it has initializer, is a rest parameter, or has public or private modifier - return !!parameter.initializer || parameter.dotDotDotToken !== undefined || - !!(parameter.flags & 16 /* Public */) || !!(parameter.flags & 32 /* Private */); - } - function spanInParameterDeclaration(parameter) { - if (canHaveSpanInParameterDeclaration(parameter)) { - return textSpan(parameter); - } - else { - var functionDeclaration = parameter.parent; - var indexOfParameter = ts.indexOf(functionDeclaration.parameters, parameter); - if (indexOfParameter) { - // Not a first parameter, go to previous parameter - return spanInParameterDeclaration(functionDeclaration.parameters[indexOfParameter - 1]); - } - else { - // Set breakpoint in the function declaration body - return spanInNode(functionDeclaration.body); - } - } - } - function canFunctionHaveSpanInWholeDeclaration(functionDeclaration) { - return !!(functionDeclaration.flags & 1 /* Export */) || - (functionDeclaration.parent.kind === 214 /* ClassDeclaration */ && functionDeclaration.kind !== 144 /* Constructor */); - } - function spanInFunctionDeclaration(functionDeclaration) { - // No breakpoints in the function signature - if (!functionDeclaration.body) { - return undefined; - } - if (canFunctionHaveSpanInWholeDeclaration(functionDeclaration)) { - // Set the span on whole function declaration - return textSpan(functionDeclaration); - } - // Set span in function body - return spanInNode(functionDeclaration.body); - } - function spanInFunctionBlock(block) { - var nodeForSpanInBlock = block.statements.length ? block.statements[0] : block.getLastToken(); - if (canFunctionHaveSpanInWholeDeclaration(block.parent)) { - return spanInNodeIfStartsOnSameLine(block.parent, nodeForSpanInBlock); - } - return spanInNode(nodeForSpanInBlock); - } - function spanInBlock(block) { - switch (block.parent.kind) { - case 218 /* ModuleDeclaration */: - if (ts.getModuleInstanceState(block.parent) !== 1 /* Instantiated */) { - return undefined; - } - // Set on parent if on same line otherwise on first statement - case 198 /* WhileStatement */: - case 196 /* IfStatement */: - case 200 /* ForInStatement */: - case 201 /* ForOfStatement */: - return spanInNodeIfStartsOnSameLine(block.parent, block.statements[0]); - // Set span on previous token if it starts on same line otherwise on the first statement of the block - case 199 /* ForStatement */: - 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 spanInForStatement(forStatement) { - if (forStatement.initializer) { - if (forStatement.initializer.kind === 212 /* VariableDeclarationList */) { - var variableDeclarationList = forStatement.initializer; - if (variableDeclarationList.declarations.length > 0) { - return spanInNode(variableDeclarationList.declarations[0]); - } - } - else { - return spanInNode(forStatement.initializer); - } - } - if (forStatement.condition) { - return textSpan(forStatement.condition); - } - if (forStatement.incrementor) { - return textSpan(forStatement.incrementor); - } - } - // Tokens: - function spanInOpenBraceToken(node) { - switch (node.parent.kind) { - case 217 /* EnumDeclaration */: - var enumDeclaration = node.parent; - return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), enumDeclaration.members.length ? enumDeclaration.members[0] : enumDeclaration.getLastToken(sourceFile)); - case 214 /* ClassDeclaration */: - var classDeclaration = node.parent; - return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), classDeclaration.members.length ? classDeclaration.members[0] : classDeclaration.getLastToken(sourceFile)); - case 220 /* CaseBlock */: - return spanInNodeIfStartsOnSameLine(node.parent.parent, node.parent.clauses[0]); - } - // Default to parent node - return spanInNode(node.parent); - } - function spanInCloseBraceToken(node) { - switch (node.parent.kind) { - case 219 /* ModuleBlock */: - // If this is not instantiated module block no bp span - if (ts.getModuleInstanceState(node.parent.parent) !== 1 /* Instantiated */) { - return undefined; - } - case 217 /* EnumDeclaration */: - case 214 /* ClassDeclaration */: - // Span on close brace token - return textSpan(node); - case 192 /* Block */: - if (ts.isFunctionBlock(node.parent)) { - // Span on close brace token - return textSpan(node); - } - // fall through. - case 244 /* CatchClause */: - return spanInNode(ts.lastOrUndefined(node.parent.statements)); - ; - case 220 /* CaseBlock */: - // breakpoint in last statement of the last clause - var caseBlock = node.parent; - var lastClause = ts.lastOrUndefined(caseBlock.clauses); - if (lastClause) { - return spanInNode(ts.lastOrUndefined(lastClause.statements)); - } - return undefined; - // Default to parent node - default: - return spanInNode(node.parent); - } - } - function spanInOpenParenToken(node) { - if (node.parent.kind === 197 /* DoStatement */) { - // Go to while keyword and do action instead - return spanInPreviousNode(node); - } - // Default to parent node - return spanInNode(node.parent); - } - function spanInCloseParenToken(node) { - // Is this close paren token of parameter list, set span in previous token - switch (node.parent.kind) { - case 173 /* FunctionExpression */: - case 213 /* FunctionDeclaration */: - case 174 /* ArrowFunction */: - case 143 /* MethodDeclaration */: - case 142 /* MethodSignature */: - case 145 /* GetAccessor */: - case 146 /* SetAccessor */: - case 144 /* Constructor */: - case 198 /* WhileStatement */: - case 197 /* DoStatement */: - case 199 /* ForStatement */: - return spanInPreviousNode(node); - // Default to parent node - default: - return spanInNode(node.parent); - } - // Default to parent node - return spanInNode(node.parent); - } - function spanInColonToken(node) { - // Is this : specifying return annotation of the function declaration - if (ts.isFunctionLike(node.parent) || node.parent.kind === 245 /* PropertyAssignment */) { - return spanInPreviousNode(node); - } - return spanInNode(node.parent); - } - function spanInGreaterThanOrLessThanToken(node) { - if (node.parent.kind === 171 /* TypeAssertionExpression */) { - return spanInNode(node.parent.expression); - } - return spanInNode(node.parent); - } - function spanInWhileKeyword(node) { - if (node.parent.kind === 197 /* DoStatement */) { - // Set span on while expression - return textSpan(node, ts.findNextToken(node.parent.expression, node.parent)); - } - // Default to parent node - return spanInNode(node.parent); - } - } - } - BreakpointResolver.spanInSourceFileAtLocation = spanInSourceFileAtLocation; - })(BreakpointResolver = ts.BreakpointResolver || (ts.BreakpointResolver = {})); -})(ts || (ts = {})); -// -// Copyright (c) Microsoft Corporation. All rights reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -/// -/* @internal */ -var debugObjectHost = this; -/* @internal */ -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; - this.lineStartPositions = null; - } - 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); - // TODO: should this be '==='? - 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 scriptSnapshotShim is a COM object then property check becomes method call with no arguments - // 'in' does not have this effect - 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 shimHost is a COM object then property check will become method call with no arguments. - // 'in' does not have this effect. - 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.lookUp(resolutionsInFile, name); - return result ? { resolvedFileName: result } : undefined; - }); - }; - } - } - 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) { - // shimmed host does not support getProjectVersion - return undefined; - } - return this.shimHost.getProjectVersion(); - }; - LanguageServiceShimHostAdapter.prototype.useCaseSensitiveFileNames = function () { - return this.shimHost.useCaseSensitiveFileNames ? this.shimHost.useCaseSensitiveFileNames() : false; - }; - LanguageServiceShimHostAdapter.prototype.getCompilationSettings = function () { - var settingsJson = this.shimHost.getCompilationSettings(); - // TODO: should this be '==='? - if (settingsJson == null || settingsJson == "") { - throw Error("LanguageServiceShimHostAdapter.getCompilationSettings: empty compilationSettings"); - return null; - } - return JSON.parse(settingsJson); - }; - LanguageServiceShimHostAdapter.prototype.getScriptFileNames = function () { - var encoded = this.shimHost.getScriptFileNames(); - return this.files = JSON.parse(encoded); - }; - LanguageServiceShimHostAdapter.prototype.getScriptSnapshot = function (fileName) { - // Shim the API changes for 1.5 release. This should be removed once - // TypeScript 1.5 has shipped. - if (this.files && this.files.indexOf(fileName) < 0) { - return undefined; - } - var scriptSnapshot = this.shimHost.getScriptSnapshot(fileName); - return scriptSnapshot && new ScriptSnapshotShimAdapter(scriptSnapshot); - }; - 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.getDefaultLibFileName = function (options) { - // Wrap the API changes for 1.5 release. This try/catch - // should be removed once TypeScript 1.5 has shipped. - try { - return this.shimHost.getDefaultLibFileName(JSON.stringify(options)); - } - catch (e) { - return ""; - } - }; - return LanguageServiceShimHostAdapter; - })(); - ts.LanguageServiceShimHostAdapter = LanguageServiceShimHostAdapter; - /** A cancellation that throttles calls to the host */ - var ThrottledCancellationToken = (function () { - function ThrottledCancellationToken(hostCancellationToken) { - this.hostCancellationToken = hostCancellationToken; - // Store when we last tried to cancel. Checking cancellation can be expensive (as we have - // to marshall over to the host layer). So we only bother actually checking once enough - // time has passed. - this.lastCancellationCheckTime = 0; - } - ThrottledCancellationToken.prototype.isCancellationRequested = function () { - var time = Date.now(); - var duration = Math.abs(time - this.lastCancellationCheckTime); - if (duration > 10) { - // Check no more than once every 10 ms. - this.lastCancellationCheckTime = time; - return this.hostCancellationToken.isCancellationRequested(); - } - return false; - }; - return ThrottledCancellationToken; - })(); - var CoreServicesShimHostAdapter = (function () { - function CoreServicesShimHostAdapter(shimHost) { - this.shimHost = shimHost; - } - CoreServicesShimHostAdapter.prototype.readDirectory = function (rootDir, extension, exclude) { - // Wrap the API changes for 1.5 release. This try/catch - // should be removed once TypeScript 1.5 has shipped. - // Also consider removing the optional designation for - // the exclude param at this time. - var encoded; - try { - encoded = this.shimHost.readDirectory(rootDir, extension, JSON.stringify(exclude)); - } - catch (e) { - encoded = this.shimHost.readDirectory(rootDir, extension); - } - return JSON.parse(encoded); - }; - CoreServicesShimHostAdapter.prototype.fileExists = function (fileName) { - return this.shimHost.fileExists(fileName); - }; - CoreServicesShimHostAdapter.prototype.readFile = function (fileName) { - return this.shimHost.readFile(fileName); - }; - return CoreServicesShimHostAdapter; - })(); - ts.CoreServicesShimHostAdapter = CoreServicesShimHostAdapter; - function simpleForwardCall(logger, actionDescription, action, logPerformance) { - if (logPerformance) { - logger.log(actionDescription); - var start = Date.now(); - } - var result = action(); - if (logPerformance) { - var end = Date.now(); - 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) { - try { - var result = simpleForwardCall(logger, actionDescription, action, logPerformance); - return JSON.stringify({ 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, - /// TODO: no need for the tolowerCase call - category: ts.DiagnosticCategory[diagnostic.category].toLowerCase(), - code: diagnostic.code - }; - } - 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; - } - LanguageServiceShimObject.prototype.forwardJSONCall = function (actionDescription, action) { - return forwardJSONCall(this.logger, actionDescription, action, this.logPerformance); - }; - /// DISPOSE - /** - * Ensure (almost) deterministic release of internal Javascript resources when - * some external native objects holds onto us (e.g. Com/Interop). - */ - LanguageServiceShimObject.prototype.dispose = function (dummy) { - this.logger.log("dispose()"); - this.languageService.dispose(); - this.languageService = null; - // force a GC - if (debugObjectHost && debugObjectHost.CollectGarbage) { - debugObjectHost.CollectGarbage(); - this.logger.log("CollectGarbage()"); - } - this.logger = null; - _super.prototype.dispose.call(this, dummy); - }; - /// REFRESH - /** - * Update the list of scripts known to the compiler - */ - 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 () { - var classifications = _this.languageService.getSyntacticClassifications(fileName, ts.createTextSpan(start, length)); - return classifications; - }); - }; - LanguageServiceShimObject.prototype.getSemanticClassifications = function (fileName, start, length) { - var _this = this; - return this.forwardJSONCall("getSemanticClassifications('" + fileName + "', " + start + ", " + length + ")", function () { - var classifications = _this.languageService.getSemanticClassifications(fileName, ts.createTextSpan(start, length)); - return classifications; - }); - }; - LanguageServiceShimObject.prototype.getEncodedSyntacticClassifications = function (fileName, start, length) { - var _this = this; - return this.forwardJSONCall("getEncodedSyntacticClassifications('" + fileName + "', " + start + ", " + length + ")", function () { - // directly serialize the spans out to a string. This is much faster to decode - // on the managed side versus a full JSON array. - 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 () { - // directly serialize the spans out to a string. This is much faster to decode - // on the managed side versus a full JSON array. - 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); - }); - }; - /// QUICKINFO - /** - * Computes a string representation of the type at the requested position - * in the active file. - */ - LanguageServiceShimObject.prototype.getQuickInfoAtPosition = function (fileName, position) { - var _this = this; - return this.forwardJSONCall("getQuickInfoAtPosition('" + fileName + "', " + position + ")", function () { - var quickInfo = _this.languageService.getQuickInfoAtPosition(fileName, position); - return quickInfo; - }); - }; - /// NAMEORDOTTEDNAMESPAN - /** - * Computes span information of the name or dotted name at the requested position - * in the active file. - */ - LanguageServiceShimObject.prototype.getNameOrDottedNameSpan = function (fileName, startPos, endPos) { - var _this = this; - return this.forwardJSONCall("getNameOrDottedNameSpan('" + fileName + "', " + startPos + ", " + endPos + ")", function () { - var spanInfo = _this.languageService.getNameOrDottedNameSpan(fileName, startPos, endPos); - return spanInfo; - }); - }; - /** - * STATEMENTSPAN - * Computes span information of statement at the requested position in the active file. - */ - LanguageServiceShimObject.prototype.getBreakpointStatementAtPosition = function (fileName, position) { - var _this = this; - return this.forwardJSONCall("getBreakpointStatementAtPosition('" + fileName + "', " + position + ")", function () { - var spanInfo = _this.languageService.getBreakpointStatementAtPosition(fileName, position); - return spanInfo; - }); - }; - /// SIGNATUREHELP - LanguageServiceShimObject.prototype.getSignatureHelpItems = function (fileName, position) { - var _this = this; - return this.forwardJSONCall("getSignatureHelpItems('" + fileName + "', " + position + ")", function () { - var signatureInfo = _this.languageService.getSignatureHelpItems(fileName, position); - return signatureInfo; - }); - }; - /// GOTO DEFINITION - /** - * Computes the definition location and file for the symbol - * at the requested position. - */ - LanguageServiceShimObject.prototype.getDefinitionAtPosition = function (fileName, position) { - var _this = this; - return this.forwardJSONCall("getDefinitionAtPosition('" + fileName + "', " + position + ")", function () { - return _this.languageService.getDefinitionAtPosition(fileName, position); - }); - }; - /// GOTO Type - /** - * Computes the definition location of the type of the symbol - * at the requested 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.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); - }); - }; - /// GET BRACE MATCHING - LanguageServiceShimObject.prototype.getBraceMatchingAtPosition = function (fileName, position) { - var _this = this; - return this.forwardJSONCall("getBraceMatchingAtPosition('" + fileName + "', " + position + ")", function () { - var textRanges = _this.languageService.getBraceMatchingAtPosition(fileName, position); - return textRanges; - }); - }; - /// GET SMART INDENT - LanguageServiceShimObject.prototype.getIndentationAtPosition = function (fileName, position, options /*Services.EditorOptions*/) { - var _this = this; - return this.forwardJSONCall("getIndentationAtPosition('" + fileName + "', " + position + ")", function () { - var localOptions = JSON.parse(options); - return _this.languageService.getIndentationAtPosition(fileName, position, localOptions); - }); - }; - /// GET REFERENCES - 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)); - // workaround for VS document higlighting issue - keep only items from the initial file - var normalizedName = ts.normalizeSlashes(fileName).toLowerCase(); - return ts.filter(results, function (r) { return ts.normalizeSlashes(r.fileName).toLowerCase() === normalizedName; }); - }); - }; - /// COMPLETION LISTS - /** - * Get a string based representation of the completions - * to provide at the given source position and providing a member completion - * list if requested. - */ - LanguageServiceShimObject.prototype.getCompletionsAtPosition = function (fileName, position) { - var _this = this; - return this.forwardJSONCall("getCompletionsAtPosition('" + fileName + "', " + position + ")", function () { - var completion = _this.languageService.getCompletionsAtPosition(fileName, position); - return completion; - }); - }; - /** Get a string based representation of a completion list entry details */ - LanguageServiceShimObject.prototype.getCompletionEntryDetails = function (fileName, position, entryName) { - var _this = this; - return this.forwardJSONCall("getCompletionEntryDetails('" + fileName + "', " + position + ", " + entryName + ")", function () { - var details = _this.languageService.getCompletionEntryDetails(fileName, position, entryName); - return details; - }); - }; - LanguageServiceShimObject.prototype.getFormattingEditsForRange = function (fileName, start, end, options /*Services.FormatCodeOptions*/) { - var _this = this; - return this.forwardJSONCall("getFormattingEditsForRange('" + fileName + "', " + start + ", " + end + ")", function () { - var localOptions = JSON.parse(options); - var edits = _this.languageService.getFormattingEditsForRange(fileName, start, end, localOptions); - return edits; - }); - }; - LanguageServiceShimObject.prototype.getFormattingEditsForDocument = function (fileName, options /*Services.FormatCodeOptions*/) { - var _this = this; - return this.forwardJSONCall("getFormattingEditsForDocument('" + fileName + "')", function () { - var localOptions = JSON.parse(options); - var edits = _this.languageService.getFormattingEditsForDocument(fileName, localOptions); - return edits; - }); - }; - LanguageServiceShimObject.prototype.getFormattingEditsAfterKeystroke = function (fileName, position, key, options /*Services.FormatCodeOptions*/) { - var _this = this; - return this.forwardJSONCall("getFormattingEditsAfterKeystroke('" + fileName + "', " + position + ", '" + key + "')", function () { - var localOptions = JSON.parse(options); - var edits = _this.languageService.getFormattingEditsAfterKeystroke(fileName, position, key, localOptions); - return edits; - }); - }; - LanguageServiceShimObject.prototype.getDocCommentTemplateAtPosition = function (fileName, position) { - var _this = this; - return this.forwardJSONCall("getDocCommentTemplateAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getDocCommentTemplateAtPosition(fileName, position); }); - }; - /// NAVIGATE TO - /** Return a list of symbols that are interesting to navigate to */ - LanguageServiceShimObject.prototype.getNavigateToItems = function (searchValue, maxResultCount) { - var _this = this; - return this.forwardJSONCall("getNavigateToItems('" + searchValue + "', " + maxResultCount + ")", function () { - var items = _this.languageService.getNavigateToItems(searchValue, maxResultCount); - return items; - }); - }; - LanguageServiceShimObject.prototype.getNavigationBarItems = function (fileName) { - var _this = this; - return this.forwardJSONCall("getNavigationBarItems('" + fileName + "')", function () { - var items = _this.languageService.getNavigationBarItems(fileName); - return items; - }); - }; - LanguageServiceShimObject.prototype.getOutliningSpans = function (fileName) { - var _this = this; - return this.forwardJSONCall("getOutliningSpans('" + fileName + "')", function () { - var items = _this.languageService.getOutliningSpans(fileName); - return items; - }); - }; - LanguageServiceShimObject.prototype.getTodoComments = function (fileName, descriptors) { - var _this = this; - return this.forwardJSONCall("getTodoComments('" + fileName + "')", function () { - var items = _this.languageService.getTodoComments(fileName, JSON.parse(descriptors)); - return items; - }); - }; - /// Emit - LanguageServiceShimObject.prototype.getEmitOutput = function (fileName) { - var _this = this; - return this.forwardJSONCall("getEmitOutput('" + fileName + "')", function () { - var output = _this.languageService.getEmitOutput(fileName); - // Shim the API changes for 1.5 release. This should be removed once - // TypeScript 1.5 has shipped. - output.emitOutputStatus = output.emitSkipped ? 1 : 0; - return output; - }); - }; - 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) { - _super.call(this, factory); - this.logger = logger; - this.logPerformance = false; - this.classifier = ts.createClassifier(); - } - 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); - }; - /// COLORIZATION - ClassifierShimObject.prototype.getClassificationsForLine = function (text, lexState, classifyKeywordsInGenerics) { - var classification = this.classifier.getClassificationsForLine(text, lexState, classifyKeywordsInGenerics); - var items = classification.entries; - var result = ""; - for (var i = 0; i < items.length; i++) { - result += items[i].length + "\n"; - result += items[i].classification + "\n"; - } - result += classification.finalLexState; - return result; - }; - return ClassifierShimObject; - })(ShimBase); - 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; - } - 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.getPreProcessedFileInfo = function (fileName, sourceTextSnapshot) { - return this.forwardJSONCall("getPreProcessedFileInfo('" + fileName + "')", function () { - var result = ts.preProcessFile(sourceTextSnapshot.getText(0, sourceTextSnapshot.getLength())); - var convertResult = { - referencedFiles: [], - importedFiles: [], - ambientExternalModules: result.ambientExternalModules, - isLibFile: result.isLibFile - }; - ts.forEach(result.referencedFiles, function (refFile) { - convertResult.referencedFiles.push({ - path: ts.normalizePath(refFile.fileName), - position: refFile.pos, - length: refFile.end - refFile.pos - }); - }); - ts.forEach(result.importedFiles, function (importedFile) { - convertResult.importedFiles.push({ - path: ts.normalizeSlashes(importedFile.fileName), - position: importedFile.pos, - length: importedFile.end - importedFile.pos - }); - }); - return convertResult; - }); - }; - 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: {}, - files: [], - errors: [realizeDiagnostic(result.error, '\r\n')] - }; - } - var configFile = ts.parseJsonConfigFileContent(result.config, _this.host, ts.getDirectoryPath(ts.normalizeSlashes(fileName))); - return { - options: configFile.options, - files: configFile.fileNames, - errors: realizeDiagnostics(configFile.errors, '\r\n') - }; - }); - }; - CoreServicesShimObject.prototype.getDefaultCompilationSettings = function () { - return this.forwardJSONCall("getDefaultCompilationSettings()", function () { - return ts.getDefaultCompilerOptions(); - }); - }; - return CoreServicesShimObject; - })(ShimBase); - var TypeScriptServicesFactory = (function () { - function TypeScriptServicesFactory() { - this._shims = []; - } - /* - * Returns script API version. - */ - 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()); - } - 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 () { - // Forget all the registered shims - this._shims = []; - this.documentRegistry = ts.createDocumentRegistry(); - }; - 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 = {})); -/// TODO: this is used by VS, clean this up on both sides of the interface -/* @internal */ -var TypeScript; -(function (TypeScript) { - var Services; - (function (Services) { - Services.TypeScriptServicesFactory = ts.TypeScriptServicesFactory; - })(Services = TypeScript.Services || (TypeScript.Services = {})); -})(TypeScript || (TypeScript = {})); -/* @internal */ -var toolsVersion = "1.6"; +var ts; +(function (ts) { + // token > SyntaxKind.Identifer => token is a keyword + // Also, If you add a new SyntaxKind be sure to keep the `Markers` section at the bottom in sync + (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"; + // We detect and preserve #! on the first line + SyntaxKind[SyntaxKind["ShebangTrivia"] = 6] = "ShebangTrivia"; + // We detect and provide better error recovery when we encounter a git merge marker. This + // allows us to edit files with git-conflict markers in them in a much more pleasant manner. + SyntaxKind[SyntaxKind["ConflictMarkerTrivia"] = 7] = "ConflictMarkerTrivia"; + // Literals + SyntaxKind[SyntaxKind["NumericLiteral"] = 8] = "NumericLiteral"; + SyntaxKind[SyntaxKind["StringLiteral"] = 9] = "StringLiteral"; + SyntaxKind[SyntaxKind["RegularExpressionLiteral"] = 10] = "RegularExpressionLiteral"; + SyntaxKind[SyntaxKind["NoSubstitutionTemplateLiteral"] = 11] = "NoSubstitutionTemplateLiteral"; + // Pseudo-literals + SyntaxKind[SyntaxKind["TemplateHead"] = 12] = "TemplateHead"; + SyntaxKind[SyntaxKind["TemplateMiddle"] = 13] = "TemplateMiddle"; + SyntaxKind[SyntaxKind["TemplateTail"] = 14] = "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"; + // 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"; + // Identifiers + SyntaxKind[SyntaxKind["Identifier"] = 69] = "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"; + // 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"; + // 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["RequireKeyword"] = 127] = "RequireKeyword"; + SyntaxKind[SyntaxKind["NumberKeyword"] = 128] = "NumberKeyword"; + SyntaxKind[SyntaxKind["SetKeyword"] = 129] = "SetKeyword"; + SyntaxKind[SyntaxKind["StringKeyword"] = 130] = "StringKeyword"; + SyntaxKind[SyntaxKind["SymbolKeyword"] = 131] = "SymbolKeyword"; + SyntaxKind[SyntaxKind["TypeKeyword"] = 132] = "TypeKeyword"; + SyntaxKind[SyntaxKind["FromKeyword"] = 133] = "FromKeyword"; + SyntaxKind[SyntaxKind["OfKeyword"] = 134] = "OfKeyword"; + // Parse tree nodes + // Names + SyntaxKind[SyntaxKind["QualifiedName"] = 135] = "QualifiedName"; + SyntaxKind[SyntaxKind["ComputedPropertyName"] = 136] = "ComputedPropertyName"; + // Signature elements + SyntaxKind[SyntaxKind["TypeParameter"] = 137] = "TypeParameter"; + SyntaxKind[SyntaxKind["Parameter"] = 138] = "Parameter"; + SyntaxKind[SyntaxKind["Decorator"] = 139] = "Decorator"; + // TypeMember + SyntaxKind[SyntaxKind["PropertySignature"] = 140] = "PropertySignature"; + SyntaxKind[SyntaxKind["PropertyDeclaration"] = 141] = "PropertyDeclaration"; + SyntaxKind[SyntaxKind["MethodSignature"] = 142] = "MethodSignature"; + SyntaxKind[SyntaxKind["MethodDeclaration"] = 143] = "MethodDeclaration"; + SyntaxKind[SyntaxKind["Constructor"] = 144] = "Constructor"; + SyntaxKind[SyntaxKind["GetAccessor"] = 145] = "GetAccessor"; + SyntaxKind[SyntaxKind["SetAccessor"] = 146] = "SetAccessor"; + SyntaxKind[SyntaxKind["CallSignature"] = 147] = "CallSignature"; + SyntaxKind[SyntaxKind["ConstructSignature"] = 148] = "ConstructSignature"; + SyntaxKind[SyntaxKind["IndexSignature"] = 149] = "IndexSignature"; + // Type + SyntaxKind[SyntaxKind["TypePredicate"] = 150] = "TypePredicate"; + SyntaxKind[SyntaxKind["TypeReference"] = 151] = "TypeReference"; + SyntaxKind[SyntaxKind["FunctionType"] = 152] = "FunctionType"; + SyntaxKind[SyntaxKind["ConstructorType"] = 153] = "ConstructorType"; + SyntaxKind[SyntaxKind["TypeQuery"] = 154] = "TypeQuery"; + SyntaxKind[SyntaxKind["TypeLiteral"] = 155] = "TypeLiteral"; + SyntaxKind[SyntaxKind["ArrayType"] = 156] = "ArrayType"; + SyntaxKind[SyntaxKind["TupleType"] = 157] = "TupleType"; + SyntaxKind[SyntaxKind["UnionType"] = 158] = "UnionType"; + SyntaxKind[SyntaxKind["IntersectionType"] = 159] = "IntersectionType"; + SyntaxKind[SyntaxKind["ParenthesizedType"] = 160] = "ParenthesizedType"; + // Binding patterns + SyntaxKind[SyntaxKind["ObjectBindingPattern"] = 161] = "ObjectBindingPattern"; + SyntaxKind[SyntaxKind["ArrayBindingPattern"] = 162] = "ArrayBindingPattern"; + SyntaxKind[SyntaxKind["BindingElement"] = 163] = "BindingElement"; + // Expression + SyntaxKind[SyntaxKind["ArrayLiteralExpression"] = 164] = "ArrayLiteralExpression"; + SyntaxKind[SyntaxKind["ObjectLiteralExpression"] = 165] = "ObjectLiteralExpression"; + SyntaxKind[SyntaxKind["PropertyAccessExpression"] = 166] = "PropertyAccessExpression"; + SyntaxKind[SyntaxKind["ElementAccessExpression"] = 167] = "ElementAccessExpression"; + SyntaxKind[SyntaxKind["CallExpression"] = 168] = "CallExpression"; + SyntaxKind[SyntaxKind["NewExpression"] = 169] = "NewExpression"; + SyntaxKind[SyntaxKind["TaggedTemplateExpression"] = 170] = "TaggedTemplateExpression"; + SyntaxKind[SyntaxKind["TypeAssertionExpression"] = 171] = "TypeAssertionExpression"; + SyntaxKind[SyntaxKind["ParenthesizedExpression"] = 172] = "ParenthesizedExpression"; + SyntaxKind[SyntaxKind["FunctionExpression"] = 173] = "FunctionExpression"; + SyntaxKind[SyntaxKind["ArrowFunction"] = 174] = "ArrowFunction"; + SyntaxKind[SyntaxKind["DeleteExpression"] = 175] = "DeleteExpression"; + SyntaxKind[SyntaxKind["TypeOfExpression"] = 176] = "TypeOfExpression"; + SyntaxKind[SyntaxKind["VoidExpression"] = 177] = "VoidExpression"; + SyntaxKind[SyntaxKind["AwaitExpression"] = 178] = "AwaitExpression"; + SyntaxKind[SyntaxKind["PrefixUnaryExpression"] = 179] = "PrefixUnaryExpression"; + SyntaxKind[SyntaxKind["PostfixUnaryExpression"] = 180] = "PostfixUnaryExpression"; + SyntaxKind[SyntaxKind["BinaryExpression"] = 181] = "BinaryExpression"; + SyntaxKind[SyntaxKind["ConditionalExpression"] = 182] = "ConditionalExpression"; + SyntaxKind[SyntaxKind["TemplateExpression"] = 183] = "TemplateExpression"; + SyntaxKind[SyntaxKind["YieldExpression"] = 184] = "YieldExpression"; + SyntaxKind[SyntaxKind["SpreadElementExpression"] = 185] = "SpreadElementExpression"; + SyntaxKind[SyntaxKind["ClassExpression"] = 186] = "ClassExpression"; + SyntaxKind[SyntaxKind["OmittedExpression"] = 187] = "OmittedExpression"; + SyntaxKind[SyntaxKind["ExpressionWithTypeArguments"] = 188] = "ExpressionWithTypeArguments"; + SyntaxKind[SyntaxKind["AsExpression"] = 189] = "AsExpression"; + // Misc + SyntaxKind[SyntaxKind["TemplateSpan"] = 190] = "TemplateSpan"; + SyntaxKind[SyntaxKind["SemicolonClassElement"] = 191] = "SemicolonClassElement"; + // Element + SyntaxKind[SyntaxKind["Block"] = 192] = "Block"; + SyntaxKind[SyntaxKind["VariableStatement"] = 193] = "VariableStatement"; + SyntaxKind[SyntaxKind["EmptyStatement"] = 194] = "EmptyStatement"; + SyntaxKind[SyntaxKind["ExpressionStatement"] = 195] = "ExpressionStatement"; + SyntaxKind[SyntaxKind["IfStatement"] = 196] = "IfStatement"; + SyntaxKind[SyntaxKind["DoStatement"] = 197] = "DoStatement"; + SyntaxKind[SyntaxKind["WhileStatement"] = 198] = "WhileStatement"; + SyntaxKind[SyntaxKind["ForStatement"] = 199] = "ForStatement"; + SyntaxKind[SyntaxKind["ForInStatement"] = 200] = "ForInStatement"; + SyntaxKind[SyntaxKind["ForOfStatement"] = 201] = "ForOfStatement"; + SyntaxKind[SyntaxKind["ContinueStatement"] = 202] = "ContinueStatement"; + SyntaxKind[SyntaxKind["BreakStatement"] = 203] = "BreakStatement"; + SyntaxKind[SyntaxKind["ReturnStatement"] = 204] = "ReturnStatement"; + SyntaxKind[SyntaxKind["WithStatement"] = 205] = "WithStatement"; + SyntaxKind[SyntaxKind["SwitchStatement"] = 206] = "SwitchStatement"; + SyntaxKind[SyntaxKind["LabeledStatement"] = 207] = "LabeledStatement"; + SyntaxKind[SyntaxKind["ThrowStatement"] = 208] = "ThrowStatement"; + SyntaxKind[SyntaxKind["TryStatement"] = 209] = "TryStatement"; + SyntaxKind[SyntaxKind["DebuggerStatement"] = 210] = "DebuggerStatement"; + SyntaxKind[SyntaxKind["VariableDeclaration"] = 211] = "VariableDeclaration"; + SyntaxKind[SyntaxKind["VariableDeclarationList"] = 212] = "VariableDeclarationList"; + SyntaxKind[SyntaxKind["FunctionDeclaration"] = 213] = "FunctionDeclaration"; + SyntaxKind[SyntaxKind["ClassDeclaration"] = 214] = "ClassDeclaration"; + SyntaxKind[SyntaxKind["InterfaceDeclaration"] = 215] = "InterfaceDeclaration"; + SyntaxKind[SyntaxKind["TypeAliasDeclaration"] = 216] = "TypeAliasDeclaration"; + SyntaxKind[SyntaxKind["EnumDeclaration"] = 217] = "EnumDeclaration"; + SyntaxKind[SyntaxKind["ModuleDeclaration"] = 218] = "ModuleDeclaration"; + SyntaxKind[SyntaxKind["ModuleBlock"] = 219] = "ModuleBlock"; + SyntaxKind[SyntaxKind["CaseBlock"] = 220] = "CaseBlock"; + SyntaxKind[SyntaxKind["ImportEqualsDeclaration"] = 221] = "ImportEqualsDeclaration"; + SyntaxKind[SyntaxKind["ImportDeclaration"] = 222] = "ImportDeclaration"; + SyntaxKind[SyntaxKind["ImportClause"] = 223] = "ImportClause"; + SyntaxKind[SyntaxKind["NamespaceImport"] = 224] = "NamespaceImport"; + SyntaxKind[SyntaxKind["NamedImports"] = 225] = "NamedImports"; + SyntaxKind[SyntaxKind["ImportSpecifier"] = 226] = "ImportSpecifier"; + SyntaxKind[SyntaxKind["ExportAssignment"] = 227] = "ExportAssignment"; + SyntaxKind[SyntaxKind["ExportDeclaration"] = 228] = "ExportDeclaration"; + SyntaxKind[SyntaxKind["NamedExports"] = 229] = "NamedExports"; + SyntaxKind[SyntaxKind["ExportSpecifier"] = 230] = "ExportSpecifier"; + SyntaxKind[SyntaxKind["MissingDeclaration"] = 231] = "MissingDeclaration"; + // Module references + SyntaxKind[SyntaxKind["ExternalModuleReference"] = 232] = "ExternalModuleReference"; + // JSX + SyntaxKind[SyntaxKind["JsxElement"] = 233] = "JsxElement"; + SyntaxKind[SyntaxKind["JsxSelfClosingElement"] = 234] = "JsxSelfClosingElement"; + SyntaxKind[SyntaxKind["JsxOpeningElement"] = 235] = "JsxOpeningElement"; + SyntaxKind[SyntaxKind["JsxText"] = 236] = "JsxText"; + SyntaxKind[SyntaxKind["JsxClosingElement"] = 237] = "JsxClosingElement"; + SyntaxKind[SyntaxKind["JsxAttribute"] = 238] = "JsxAttribute"; + SyntaxKind[SyntaxKind["JsxSpreadAttribute"] = 239] = "JsxSpreadAttribute"; + SyntaxKind[SyntaxKind["JsxExpression"] = 240] = "JsxExpression"; + // Clauses + SyntaxKind[SyntaxKind["CaseClause"] = 241] = "CaseClause"; + SyntaxKind[SyntaxKind["DefaultClause"] = 242] = "DefaultClause"; + SyntaxKind[SyntaxKind["HeritageClause"] = 243] = "HeritageClause"; + SyntaxKind[SyntaxKind["CatchClause"] = 244] = "CatchClause"; + // Property assignments + SyntaxKind[SyntaxKind["PropertyAssignment"] = 245] = "PropertyAssignment"; + SyntaxKind[SyntaxKind["ShorthandPropertyAssignment"] = 246] = "ShorthandPropertyAssignment"; + // Enum + SyntaxKind[SyntaxKind["EnumMember"] = 247] = "EnumMember"; + // Top-level nodes + SyntaxKind[SyntaxKind["SourceFile"] = 248] = "SourceFile"; + // JSDoc nodes. + SyntaxKind[SyntaxKind["JSDocTypeExpression"] = 249] = "JSDocTypeExpression"; + // The * type. + SyntaxKind[SyntaxKind["JSDocAllType"] = 250] = "JSDocAllType"; + // The ? type. + SyntaxKind[SyntaxKind["JSDocUnknownType"] = 251] = "JSDocUnknownType"; + SyntaxKind[SyntaxKind["JSDocArrayType"] = 252] = "JSDocArrayType"; + SyntaxKind[SyntaxKind["JSDocUnionType"] = 253] = "JSDocUnionType"; + SyntaxKind[SyntaxKind["JSDocTupleType"] = 254] = "JSDocTupleType"; + SyntaxKind[SyntaxKind["JSDocNullableType"] = 255] = "JSDocNullableType"; + SyntaxKind[SyntaxKind["JSDocNonNullableType"] = 256] = "JSDocNonNullableType"; + SyntaxKind[SyntaxKind["JSDocRecordType"] = 257] = "JSDocRecordType"; + SyntaxKind[SyntaxKind["JSDocRecordMember"] = 258] = "JSDocRecordMember"; + SyntaxKind[SyntaxKind["JSDocTypeReference"] = 259] = "JSDocTypeReference"; + SyntaxKind[SyntaxKind["JSDocOptionalType"] = 260] = "JSDocOptionalType"; + SyntaxKind[SyntaxKind["JSDocFunctionType"] = 261] = "JSDocFunctionType"; + SyntaxKind[SyntaxKind["JSDocVariadicType"] = 262] = "JSDocVariadicType"; + SyntaxKind[SyntaxKind["JSDocConstructorType"] = 263] = "JSDocConstructorType"; + SyntaxKind[SyntaxKind["JSDocThisType"] = 264] = "JSDocThisType"; + SyntaxKind[SyntaxKind["JSDocComment"] = 265] = "JSDocComment"; + SyntaxKind[SyntaxKind["JSDocTag"] = 266] = "JSDocTag"; + SyntaxKind[SyntaxKind["JSDocParameterTag"] = 267] = "JSDocParameterTag"; + SyntaxKind[SyntaxKind["JSDocReturnTag"] = 268] = "JSDocReturnTag"; + SyntaxKind[SyntaxKind["JSDocTypeTag"] = 269] = "JSDocTypeTag"; + SyntaxKind[SyntaxKind["JSDocTemplateTag"] = 270] = "JSDocTemplateTag"; + // Synthesized list + SyntaxKind[SyntaxKind["SyntaxList"] = 271] = "SyntaxList"; + // Enum value count + SyntaxKind[SyntaxKind["Count"] = 272] = "Count"; + // Markers + SyntaxKind[SyntaxKind["FirstAssignment"] = 56] = "FirstAssignment"; + SyntaxKind[SyntaxKind["LastAssignment"] = 68] = "LastAssignment"; + SyntaxKind[SyntaxKind["FirstReservedWord"] = 70] = "FirstReservedWord"; + SyntaxKind[SyntaxKind["LastReservedWord"] = 105] = "LastReservedWord"; + SyntaxKind[SyntaxKind["FirstKeyword"] = 70] = "FirstKeyword"; + SyntaxKind[SyntaxKind["LastKeyword"] = 134] = "LastKeyword"; + SyntaxKind[SyntaxKind["FirstFutureReservedWord"] = 106] = "FirstFutureReservedWord"; + SyntaxKind[SyntaxKind["LastFutureReservedWord"] = 114] = "LastFutureReservedWord"; + SyntaxKind[SyntaxKind["FirstTypeNode"] = 151] = "FirstTypeNode"; + SyntaxKind[SyntaxKind["LastTypeNode"] = 160] = "LastTypeNode"; + SyntaxKind[SyntaxKind["FirstPunctuation"] = 15] = "FirstPunctuation"; + SyntaxKind[SyntaxKind["LastPunctuation"] = 68] = "LastPunctuation"; + SyntaxKind[SyntaxKind["FirstToken"] = 0] = "FirstToken"; + SyntaxKind[SyntaxKind["LastToken"] = 134] = "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"] = 135] = "FirstNode"; + })(ts.SyntaxKind || (ts.SyntaxKind = {})); + var SyntaxKind = ts.SyntaxKind; + (function (NodeFlags) { + NodeFlags[NodeFlags["None"] = 0] = "None"; + NodeFlags[NodeFlags["Export"] = 1] = "Export"; + NodeFlags[NodeFlags["Ambient"] = 2] = "Ambient"; + NodeFlags[NodeFlags["Public"] = 16] = "Public"; + NodeFlags[NodeFlags["Private"] = 32] = "Private"; + NodeFlags[NodeFlags["Protected"] = 64] = "Protected"; + NodeFlags[NodeFlags["Static"] = 128] = "Static"; + NodeFlags[NodeFlags["Abstract"] = 256] = "Abstract"; + NodeFlags[NodeFlags["Async"] = 512] = "Async"; + NodeFlags[NodeFlags["Default"] = 1024] = "Default"; + NodeFlags[NodeFlags["MultiLine"] = 2048] = "MultiLine"; + NodeFlags[NodeFlags["Synthetic"] = 4096] = "Synthetic"; + NodeFlags[NodeFlags["DeclarationFile"] = 8192] = "DeclarationFile"; + NodeFlags[NodeFlags["Let"] = 16384] = "Let"; + NodeFlags[NodeFlags["Const"] = 32768] = "Const"; + NodeFlags[NodeFlags["OctalLiteral"] = 65536] = "OctalLiteral"; + NodeFlags[NodeFlags["Namespace"] = 131072] = "Namespace"; + NodeFlags[NodeFlags["ExportContext"] = 262144] = "ExportContext"; + NodeFlags[NodeFlags["ContainsThis"] = 524288] = "ContainsThis"; + NodeFlags[NodeFlags["Modifier"] = 2035] = "Modifier"; + NodeFlags[NodeFlags["AccessibilityModifier"] = 112] = "AccessibilityModifier"; + NodeFlags[NodeFlags["BlockScoped"] = 49152] = "BlockScoped"; + })(ts.NodeFlags || (ts.NodeFlags = {})); + var NodeFlags = ts.NodeFlags; + /* @internal */ + (function (ParserContextFlags) { + ParserContextFlags[ParserContextFlags["None"] = 0] = "None"; + // If this node was parsed in a context where 'in-expressions' are not allowed. + ParserContextFlags[ParserContextFlags["DisallowIn"] = 1] = "DisallowIn"; + // If this node was parsed in the 'yield' context created when parsing a generator. + ParserContextFlags[ParserContextFlags["Yield"] = 2] = "Yield"; + // If this node was parsed as part of a decorator + ParserContextFlags[ParserContextFlags["Decorator"] = 4] = "Decorator"; + // If this node was parsed in the 'await' context created when parsing an async function. + ParserContextFlags[ParserContextFlags["Await"] = 8] = "Await"; + // If the parser encountered an error when parsing the code that created this node. Note + // the parser only sets this directly on the node it creates right after encountering the + // error. + ParserContextFlags[ParserContextFlags["ThisNodeHasError"] = 16] = "ThisNodeHasError"; + // This node was parsed in a JavaScript file and can be processed differently. For example + // its type can be specified usign a JSDoc comment. + ParserContextFlags[ParserContextFlags["JavaScriptFile"] = 32] = "JavaScriptFile"; + // Context flags set directly by the parser. + ParserContextFlags[ParserContextFlags["ParserGeneratedFlags"] = 31] = "ParserGeneratedFlags"; + // Exclude these flags when parsing a Type + ParserContextFlags[ParserContextFlags["TypeExcludesFlags"] = 10] = "TypeExcludesFlags"; + // Context flags computed by aggregating child flags upwards. + // Used during incremental parsing to determine if this node or any of its children had an + // error. Computed only once and then cached. + ParserContextFlags[ParserContextFlags["ThisNodeOrAnySubNodesHasError"] = 64] = "ThisNodeOrAnySubNodesHasError"; + // Used to know if we've computed data from children and cached it in this node. + ParserContextFlags[ParserContextFlags["HasAggregatedChildData"] = 128] = "HasAggregatedChildData"; + })(ts.ParserContextFlags || (ts.ParserContextFlags = {})); + var ParserContextFlags = ts.ParserContextFlags; + (function (JsxFlags) { + JsxFlags[JsxFlags["None"] = 0] = "None"; + JsxFlags[JsxFlags["IntrinsicNamedElement"] = 1] = "IntrinsicNamedElement"; + JsxFlags[JsxFlags["IntrinsicIndexedElement"] = 2] = "IntrinsicIndexedElement"; + JsxFlags[JsxFlags["ClassElement"] = 4] = "ClassElement"; + JsxFlags[JsxFlags["UnknownElement"] = 8] = "UnknownElement"; + JsxFlags[JsxFlags["IntrinsicElement"] = 3] = "IntrinsicElement"; + })(ts.JsxFlags || (ts.JsxFlags = {})); + var JsxFlags = ts.JsxFlags; + /* @internal */ + (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; + var OperationCanceledException = (function () { + function OperationCanceledException() { + } + return OperationCanceledException; + })(); + ts.OperationCanceledException = OperationCanceledException; + /** Return code used by getEmitOutput function to indicate status of the function */ + (function (ExitStatus) { + // Compiler ran successfully. Either this was a simple do-nothing compilation (for example, + // when -version or -help was provided, or this was a normal compilation, no diagnostics + // were produced, and all outputs were generated successfully. + ExitStatus[ExitStatus["Success"] = 0] = "Success"; + // Diagnostics were produced and because of them no code was generated. + ExitStatus[ExitStatus["DiagnosticsPresent_OutputsSkipped"] = 1] = "DiagnosticsPresent_OutputsSkipped"; + // Diagnostics were produced and outputs were generated in spite of them. + 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"; + })(ts.TypeFormatFlags || (ts.TypeFormatFlags = {})); + var TypeFormatFlags = ts.TypeFormatFlags; + (function (SymbolFormatFlags) { + SymbolFormatFlags[SymbolFormatFlags["None"] = 0] = "None"; + // Write symbols's type argument if it is instantiated symbol + // eg. class C { p: T } <-- Show p as C.p here + // var a: C; + // var p = a.p; <--- Here p is property of C so show it as C.p instead of just C.p + SymbolFormatFlags[SymbolFormatFlags["WriteTypeParametersOrArguments"] = 1] = "WriteTypeParametersOrArguments"; + // Use only external alias information to get the symbol name in the given context + // eg. module m { export class c { } } import x = m.c; + // When this flag is specified m.c will be used to refer to the class instead of alias symbol x + SymbolFormatFlags[SymbolFormatFlags["UseOnlyExternalAliasing"] = 2] = "UseOnlyExternalAliasing"; + })(ts.SymbolFormatFlags || (ts.SymbolFormatFlags = {})); + var SymbolFormatFlags = ts.SymbolFormatFlags; + /* @internal */ + (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; + /** Indicates how to serialize the name for a TypeReferenceNode when emitting decorator + * metadata */ + /* @internal */ + (function (TypeReferenceSerializationKind) { + TypeReferenceSerializationKind[TypeReferenceSerializationKind["Unknown"] = 0] = "Unknown"; + // should be emitted using a safe fallback. + TypeReferenceSerializationKind[TypeReferenceSerializationKind["TypeWithConstructSignatureAndValue"] = 1] = "TypeWithConstructSignatureAndValue"; + // function that can be reached at runtime (e.g. a `class` + // declaration or a `var` declaration for the static side + // of a type, such as the global `Promise` type in lib.d.ts). + TypeReferenceSerializationKind[TypeReferenceSerializationKind["VoidType"] = 2] = "VoidType"; + TypeReferenceSerializationKind[TypeReferenceSerializationKind["NumberLikeType"] = 3] = "NumberLikeType"; + TypeReferenceSerializationKind[TypeReferenceSerializationKind["StringLikeType"] = 4] = "StringLikeType"; + TypeReferenceSerializationKind[TypeReferenceSerializationKind["BooleanType"] = 5] = "BooleanType"; + TypeReferenceSerializationKind[TypeReferenceSerializationKind["ArrayLikeType"] = 6] = "ArrayLikeType"; + TypeReferenceSerializationKind[TypeReferenceSerializationKind["ESSymbolType"] = 7] = "ESSymbolType"; + TypeReferenceSerializationKind[TypeReferenceSerializationKind["TypeWithCallSignature"] = 8] = "TypeWithCallSignature"; + // with call signatures. + TypeReferenceSerializationKind[TypeReferenceSerializationKind["ObjectType"] = 9] = "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"] = 793056] = "Type"; + SymbolFlags[SymbolFlags["Namespace"] = 1536] = "Namespace"; + SymbolFlags[SymbolFlags["Module"] = 1536] = "Module"; + SymbolFlags[SymbolFlags["Accessor"] = 98304] = "Accessor"; + // Variables can be redeclared, but can not redeclare a block-scoped declaration with the + // same name, or any other value that is not a variable, e.g. ValueModule or Class + SymbolFlags[SymbolFlags["FunctionScopedVariableExcludes"] = 107454] = "FunctionScopedVariableExcludes"; + // Block-scoped declarations are not allowed to be re-declared + // they can not merge with anything in the value space + SymbolFlags[SymbolFlags["BlockScopedVariableExcludes"] = 107455] = "BlockScopedVariableExcludes"; + SymbolFlags[SymbolFlags["ParameterExcludes"] = 107455] = "ParameterExcludes"; + SymbolFlags[SymbolFlags["PropertyExcludes"] = 107455] = "PropertyExcludes"; + SymbolFlags[SymbolFlags["EnumMemberExcludes"] = 107455] = "EnumMemberExcludes"; + SymbolFlags[SymbolFlags["FunctionExcludes"] = 106927] = "FunctionExcludes"; + SymbolFlags[SymbolFlags["ClassExcludes"] = 899519] = "ClassExcludes"; + SymbolFlags[SymbolFlags["InterfaceExcludes"] = 792960] = "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"] = 530912] = "TypeParameterExcludes"; + SymbolFlags[SymbolFlags["TypeAliasExcludes"] = 793056] = "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"; + /* @internal */ + // The set of things we consider semantically classifiable. Used to speed up the LS during + // classification. + SymbolFlags[SymbolFlags["Classifiable"] = 788448] = "Classifiable"; + })(ts.SymbolFlags || (ts.SymbolFlags = {})); + var SymbolFlags = ts.SymbolFlags; + /* @internal */ + (function (NodeCheckFlags) { + NodeCheckFlags[NodeCheckFlags["TypeChecked"] = 1] = "TypeChecked"; + NodeCheckFlags[NodeCheckFlags["LexicalThis"] = 2] = "LexicalThis"; + NodeCheckFlags[NodeCheckFlags["CaptureThis"] = 4] = "CaptureThis"; + NodeCheckFlags[NodeCheckFlags["EmitExtends"] = 8] = "EmitExtends"; + NodeCheckFlags[NodeCheckFlags["EmitDecorate"] = 16] = "EmitDecorate"; + NodeCheckFlags[NodeCheckFlags["EmitParam"] = 32] = "EmitParam"; + NodeCheckFlags[NodeCheckFlags["EmitAwaiter"] = 64] = "EmitAwaiter"; + NodeCheckFlags[NodeCheckFlags["EmitGenerator"] = 128] = "EmitGenerator"; + NodeCheckFlags[NodeCheckFlags["SuperInstance"] = 256] = "SuperInstance"; + NodeCheckFlags[NodeCheckFlags["SuperStatic"] = 512] = "SuperStatic"; + NodeCheckFlags[NodeCheckFlags["ContextChecked"] = 1024] = "ContextChecked"; + NodeCheckFlags[NodeCheckFlags["LexicalArguments"] = 2048] = "LexicalArguments"; + NodeCheckFlags[NodeCheckFlags["CaptureArguments"] = 4096] = "CaptureArguments"; + // Values for enum members have been computed, and any errors have been reported for them. + NodeCheckFlags[NodeCheckFlags["EnumValuesComputed"] = 8192] = "EnumValuesComputed"; + NodeCheckFlags[NodeCheckFlags["BlockScopedBindingInLoop"] = 16384] = "BlockScopedBindingInLoop"; + NodeCheckFlags[NodeCheckFlags["LexicalModuleMergesWithClass"] = 32768] = "LexicalModuleMergesWithClass"; + NodeCheckFlags[NodeCheckFlags["LoopWithBlockScopedBindingCapturedInFunction"] = 65536] = "LoopWithBlockScopedBindingCapturedInFunction"; + })(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["Void"] = 16] = "Void"; + TypeFlags[TypeFlags["Undefined"] = 32] = "Undefined"; + TypeFlags[TypeFlags["Null"] = 64] = "Null"; + TypeFlags[TypeFlags["Enum"] = 128] = "Enum"; + TypeFlags[TypeFlags["StringLiteral"] = 256] = "StringLiteral"; + TypeFlags[TypeFlags["TypeParameter"] = 512] = "TypeParameter"; + TypeFlags[TypeFlags["Class"] = 1024] = "Class"; + TypeFlags[TypeFlags["Interface"] = 2048] = "Interface"; + TypeFlags[TypeFlags["Reference"] = 4096] = "Reference"; + TypeFlags[TypeFlags["Tuple"] = 8192] = "Tuple"; + TypeFlags[TypeFlags["Union"] = 16384] = "Union"; + TypeFlags[TypeFlags["Intersection"] = 32768] = "Intersection"; + TypeFlags[TypeFlags["Anonymous"] = 65536] = "Anonymous"; + TypeFlags[TypeFlags["Instantiated"] = 131072] = "Instantiated"; + /* @internal */ + TypeFlags[TypeFlags["FromSignature"] = 262144] = "FromSignature"; + TypeFlags[TypeFlags["ObjectLiteral"] = 524288] = "ObjectLiteral"; + /* @internal */ + TypeFlags[TypeFlags["FreshObjectLiteral"] = 1048576] = "FreshObjectLiteral"; + /* @internal */ + TypeFlags[TypeFlags["ContainsUndefinedOrNull"] = 2097152] = "ContainsUndefinedOrNull"; + /* @internal */ + TypeFlags[TypeFlags["ContainsObjectLiteral"] = 4194304] = "ContainsObjectLiteral"; + /* @internal */ + TypeFlags[TypeFlags["ContainsAnyFunctionType"] = 8388608] = "ContainsAnyFunctionType"; + TypeFlags[TypeFlags["ESSymbol"] = 16777216] = "ESSymbol"; + TypeFlags[TypeFlags["ThisType"] = 33554432] = "ThisType"; + /* @internal */ + TypeFlags[TypeFlags["Intrinsic"] = 16777343] = "Intrinsic"; + /* @internal */ + TypeFlags[TypeFlags["Primitive"] = 16777726] = "Primitive"; + TypeFlags[TypeFlags["StringLike"] = 258] = "StringLike"; + TypeFlags[TypeFlags["NumberLike"] = 132] = "NumberLike"; + TypeFlags[TypeFlags["ObjectType"] = 80896] = "ObjectType"; + TypeFlags[TypeFlags["UnionOrIntersection"] = 49152] = "UnionOrIntersection"; + TypeFlags[TypeFlags["StructuredType"] = 130048] = "StructuredType"; + /* @internal */ + TypeFlags[TypeFlags["RequiresWidening"] = 6291456] = "RequiresWidening"; + /* @internal */ + TypeFlags[TypeFlags["PropagatingFlags"] = 14680064] = "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 (DiagnosticCategory) { + DiagnosticCategory[DiagnosticCategory["Warning"] = 0] = "Warning"; + DiagnosticCategory[DiagnosticCategory["Error"] = 1] = "Error"; + DiagnosticCategory[DiagnosticCategory["Message"] = 2] = "Message"; + })(ts.DiagnosticCategory || (ts.DiagnosticCategory = {})); + var DiagnosticCategory = ts.DiagnosticCategory; + (function (ModuleResolutionKind) { + ModuleResolutionKind[ModuleResolutionKind["Classic"] = 1] = "Classic"; + ModuleResolutionKind[ModuleResolutionKind["NodeJs"] = 2] = "NodeJs"; + })(ts.ModuleResolutionKind || (ts.ModuleResolutionKind = {})); + var ModuleResolutionKind = ts.ModuleResolutionKind; + (function (ModuleKind) { + ModuleKind[ModuleKind["None"] = 0] = "None"; + ModuleKind[ModuleKind["CommonJS"] = 1] = "CommonJS"; + 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 (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"; + })(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; + /* @internal */ + (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"; + // Unicode 3.0 space characters + 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; +})(ts || (ts = {})); +/// +/* @internal */ +var ts; +(function (ts) { + /** + * Ternary values are defined such that + * x & y is False if either x or y is False. + * x & y is Maybe if either x or y is Maybe, but neither x or y is False. + * x & y is True if both x and y are True. + * x | y is False if both x and y are False. + * x | y is Maybe if either x or y is Maybe, but neither x or y is True. + * x | y is True if either x or y is True. + */ + (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; + function createFileMap(getCanonicalFileName) { + var files = {}; + return { + get: get, + set: set, + contains: contains, + remove: remove, + clear: clear, + forEachValue: forEachValueInMap + }; + function set(fileName, value) { + files[normalizeKey(fileName)] = value; + } + function get(fileName) { + return files[normalizeKey(fileName)]; + } + function contains(fileName) { + return hasProperty(files, normalizeKey(fileName)); + } + function remove(fileName) { + var key = normalizeKey(fileName); + delete files[key]; + } + function forEachValueInMap(f) { + forEachValue(files, f); + } + function normalizeKey(key) { + return getCanonicalFileName(normalizeSlashes(key)); + } + function clear() { + files = {}; + } + } + ts.createFileMap = createFileMap; + (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; + /** + * Iterates through 'array' by index and performs the callback on each element of array until the callback + * returns a truthy value, then returns that value. + * If no such value is found, the callback is applied to each element of array and undefined is returned. + */ + function forEach(array, callback) { + if (array) { + for (var i = 0, len = array.length; i < len; i++) { + var result = callback(array[i], i); + if (result) { + return result; + } + } + } + return undefined; + } + ts.forEach = forEach; + function contains(array, value) { + if (array) { + for (var _i = 0; _i < array.length; _i++) { + var v = array[_i]; + if (v === value) { + return true; + } + } + } + return false; + } + ts.contains = contains; + function indexOf(array, value) { + if (array) { + for (var i = 0, len = array.length; i < len; i++) { + if (array[i] === value) { + return i; + } + } + } + return -1; + } + ts.indexOf = indexOf; + function countWhere(array, predicate) { + var count = 0; + if (array) { + for (var _i = 0; _i < array.length; _i++) { + var v = array[_i]; + if (predicate(v)) { + count++; + } + } + } + return count; + } + ts.countWhere = countWhere; + function filter(array, f) { + var result; + if (array) { + result = []; + for (var _i = 0; _i < array.length; _i++) { + var item = array[_i]; + if (f(item)) { + result.push(item); + } + } + } + return result; + } + ts.filter = filter; + function map(array, f) { + var result; + if (array) { + result = []; + for (var _i = 0; _i < array.length; _i++) { + var v = array[_i]; + result.push(f(v)); + } + } + return result; + } + ts.map = map; + function concatenate(array1, array2) { + if (!array2 || !array2.length) + return array1; + if (!array1 || !array1.length) + return array2; + return array1.concat(array2); + } + ts.concatenate = concatenate; + function deduplicate(array) { + var result; + if (array) { + result = []; + for (var _i = 0; _i < array.length; _i++) { + var item = array[_i]; + if (!contains(result, item)) { + result.push(item); + } + } + } + return result; + } + ts.deduplicate = deduplicate; + function sum(array, prop) { + var result = 0; + for (var _i = 0; _i < array.length; _i++) { + var v = array[_i]; + result += v[prop]; + } + return result; + } + ts.sum = sum; + function addRange(to, from) { + if (to && from) { + for (var _i = 0; _i < from.length; _i++) { + var v = from[_i]; + to.push(v); + } + } + } + ts.addRange = addRange; + function rangeEquals(array1, array2, pos, end) { + while (pos < end) { + if (array1[pos] !== array2[pos]) { + return false; + } + pos++; + } + return true; + } + ts.rangeEquals = rangeEquals; + /** + * Returns the last element of an array if non-empty, undefined otherwise. + */ + function lastOrUndefined(array) { + if (array.length === 0) { + return undefined; + } + return array[array.length - 1]; + } + ts.lastOrUndefined = lastOrUndefined; + /** + * 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 + * number[index] exceeds number. + * @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) { + var low = 0; + var high = array.length - 1; + while (low <= high) { + var middle = low + ((high - low) >> 1); + var midValue = array[middle]; + if (midValue === value) { + return middle; + } + else if (midValue > value) { + high = middle - 1; + } + else { + low = middle + 1; + } + } + return ~low; + } + ts.binarySearch = binarySearch; + function reduceLeft(array, f, initial) { + if (array) { + var count = array.length; + if (count > 0) { + var pos = 0; + var result = arguments.length <= 2 ? array[pos++] : initial; + while (pos < count) { + result = f(result, array[pos++]); + } + return result; + } + } + return initial; + } + ts.reduceLeft = reduceLeft; + function reduceRight(array, f, initial) { + if (array) { + var pos = array.length - 1; + if (pos >= 0) { + var result = arguments.length <= 2 ? array[pos--] : initial; + while (pos >= 0) { + result = f(result, array[pos--]); + } + return result; + } + } + return initial; + } + ts.reduceRight = reduceRight; + var hasOwnProperty = Object.prototype.hasOwnProperty; + function hasProperty(map, key) { + return hasOwnProperty.call(map, key); + } + ts.hasProperty = hasProperty; + function getProperty(map, key) { + return hasOwnProperty.call(map, key) ? map[key] : undefined; + } + ts.getProperty = getProperty; + function isEmpty(map) { + for (var id in map) { + if (hasProperty(map, id)) { + return false; + } + } + return true; + } + ts.isEmpty = isEmpty; + function clone(object) { + var result = {}; + for (var id in object) { + result[id] = object[id]; + } + return result; + } + ts.clone = clone; + function extend(first, second) { + var result = {}; + for (var id in first) { + result[id] = first[id]; + } + for (var id in second) { + if (!hasProperty(result, id)) { + result[id] = second[id]; + } + } + return result; + } + ts.extend = extend; + function forEachValue(map, callback) { + var result; + for (var id in map) { + if (result = callback(map[id])) + break; + } + return result; + } + ts.forEachValue = forEachValue; + function forEachKey(map, callback) { + var result; + for (var id in map) { + if (result = callback(id)) + break; + } + return result; + } + ts.forEachKey = forEachKey; + function lookUp(map, key) { + return hasProperty(map, key) ? map[key] : undefined; + } + ts.lookUp = lookUp; + function copyMap(source, target) { + for (var p in source) { + target[p] = source[p]; + } + } + ts.copyMap = copyMap; + /** + * Creates a map from the elements of an array. + * + * @param array the array of input elements. + * @param makeKey a function that produces a key for a given element. + * + * This function makes no effort to avoid collisions; if any two elements produce + * the same key with the given 'makeKey' function, then the element with the higher + * index in the array will be the one associated with the produced key. + */ + function arrayToMap(array, makeKey) { + var result = {}; + forEach(array, function (value) { + result[makeKey(value)] = value; + }); + return result; + } + ts.arrayToMap = arrayToMap; + function memoize(callback) { + var value; + return function () { + if (callback) { + value = callback(); + callback = undefined; + } + return value; + }; + } + ts.memoize = memoize; + function formatStringFromArgs(text, args, baseIndex) { + baseIndex = baseIndex || 0; + return text.replace(/{(\d+)}/g, function (match, index) { return args[+index + baseIndex]; }); + } + ts.localizedDiagnosticMessages = undefined; + function getLocaleSpecificMessage(message) { + return ts.localizedDiagnosticMessages && ts.localizedDiagnosticMessages[message.key] + ? ts.localizedDiagnosticMessages[message.key] + : message.message; + } + ts.getLocaleSpecificMessage = getLocaleSpecificMessage; + function createFileDiagnostic(file, start, length, message) { + var end = start + length; + Debug.assert(start >= 0, "start must be non-negative, is " + start); + Debug.assert(length >= 0, "length must be non-negative, is " + length); + if (file) { + Debug.assert(start <= file.text.length, "start must be within the bounds of the file. " + start + " > " + file.text.length); + Debug.assert(end <= file.text.length, "end must be the bounds of the file. " + end + " > " + file.text.length); + } + var text = getLocaleSpecificMessage(message); + if (arguments.length > 4) { + text = formatStringFromArgs(text, arguments, 4); + } + return { + file: file, + start: start, + length: length, + messageText: text, + category: message.category, + code: message.code + }; + } + ts.createFileDiagnostic = createFileDiagnostic; + function createCompilerDiagnostic(message) { + var text = getLocaleSpecificMessage(message); + if (arguments.length > 1) { + text = formatStringFromArgs(text, arguments, 1); + } + return { + file: undefined, + start: undefined, + length: undefined, + messageText: text, + category: message.category, + code: message.code + }; + } + ts.createCompilerDiagnostic = createCompilerDiagnostic; + function chainDiagnosticMessages(details, message) { + var text = getLocaleSpecificMessage(message); + if (arguments.length > 2) { + text = formatStringFromArgs(text, arguments, 2); + } + return { + messageText: text, + category: message.category, + code: message.code, + next: details + }; + } + ts.chainDiagnosticMessages = chainDiagnosticMessages; + function concatenateDiagnosticMessageChains(headChain, tailChain) { + var lastChain = headChain; + while (lastChain.next) { + lastChain = lastChain.next; + } + lastChain.next = tailChain; + return headChain; + } + ts.concatenateDiagnosticMessageChains = concatenateDiagnosticMessageChains; + function compareValues(a, b) { + if (a === b) + return 0 /* EqualTo */; + if (a === undefined) + return -1 /* LessThan */; + if (b === undefined) + return 1 /* GreaterThan */; + return a < b ? -1 /* LessThan */ : 1 /* GreaterThan */; + } + ts.compareValues = compareValues; + function getDiagnosticFileName(diagnostic) { + return diagnostic.file ? diagnostic.file.fileName : undefined; + } + function compareDiagnostics(d1, d2) { + return compareValues(getDiagnosticFileName(d1), getDiagnosticFileName(d2)) || + compareValues(d1.start, d2.start) || + compareValues(d1.length, d2.length) || + compareValues(d1.code, d2.code) || + compareMessageText(d1.messageText, d2.messageText) || + 0 /* EqualTo */; + } + ts.compareDiagnostics = compareDiagnostics; + function compareMessageText(text1, text2) { + while (text1 && text2) { + // We still have both chains. + var string1 = typeof text1 === "string" ? text1 : text1.messageText; + var string2 = typeof text2 === "string" ? text2 : text2.messageText; + var res = compareValues(string1, string2); + if (res) { + return res; + } + text1 = typeof text1 === "string" ? undefined : text1.next; + text2 = typeof text2 === "string" ? undefined : text2.next; + } + if (!text1 && !text2) { + // if the chains are done, then these messages are the same. + return 0 /* EqualTo */; + } + // We still have one chain remaining. The shorter chain should come first. + return text1 ? 1 /* GreaterThan */ : -1 /* LessThan */; + } + function sortAndDeduplicateDiagnostics(diagnostics) { + return deduplicateSortedDiagnostics(diagnostics.sort(compareDiagnostics)); + } + ts.sortAndDeduplicateDiagnostics = sortAndDeduplicateDiagnostics; + function deduplicateSortedDiagnostics(diagnostics) { + if (diagnostics.length < 2) { + return diagnostics; + } + var newDiagnostics = [diagnostics[0]]; + var previousDiagnostic = diagnostics[0]; + for (var i = 1; i < diagnostics.length; i++) { + var currentDiagnostic = diagnostics[i]; + var isDupe = compareDiagnostics(currentDiagnostic, previousDiagnostic) === 0 /* EqualTo */; + if (!isDupe) { + newDiagnostics.push(currentDiagnostic); + previousDiagnostic = currentDiagnostic; + } + } + return newDiagnostics; + } + ts.deduplicateSortedDiagnostics = deduplicateSortedDiagnostics; + function normalizeSlashes(path) { + return path.replace(/\\/g, "/"); + } + ts.normalizeSlashes = normalizeSlashes; + // 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 */) + return 1; + var p1 = path.indexOf("/", 2); + if (p1 < 0) + return 2; + var p2 = path.indexOf("/", p1 + 1); + if (p2 < 0) + return p1 + 1; + return p2 + 1; + } + if (path.charCodeAt(1) === 58 /* colon */) { + if (path.charCodeAt(2) === 47 /* slash */) + return 3; + return 2; + } + // Per RFC 1738 'file' URI schema has the shape file:/// + // if is omitted then it is assumed that host value is 'localhost', + // however slash after the omitted is not removed. + // file:///folder1/file1 - this is a correct URI + // file://folder2/file2 - this is an incorrect URI + if (path.lastIndexOf("file:///", 0) === 0) { + return "file:///".length; + } + var idx = path.indexOf("://"); + if (idx !== -1) { + return idx + "://".length; + } + return 0; + } + ts.getRootLength = getRootLength; + ts.directorySeparator = "/"; + function getNormalizedParts(normalizedSlashedPath, rootLength) { + var parts = normalizedSlashedPath.substr(rootLength).split(ts.directorySeparator); + var normalized = []; + for (var _i = 0; _i < parts.length; _i++) { + var part = parts[_i]; + if (part !== ".") { + if (part === ".." && normalized.length > 0 && lastOrUndefined(normalized) !== "..") { + normalized.pop(); + } + else { + // A part may be an empty string (which is 'falsy') if the path had consecutive slashes, + // e.g. "path//file.ts". Drop these before re-joining the parts. + if (part) { + normalized.push(part); + } + } + } + } + return normalized; + } + function normalizePath(path) { + path = normalizeSlashes(path); + var rootLength = getRootLength(path); + var normalized = getNormalizedParts(path, rootLength); + return path.substr(0, rootLength) + normalized.join(ts.directorySeparator); + } + ts.normalizePath = normalizePath; + function getDirectoryPath(path) { + return path.substr(0, Math.max(getRootLength(path), path.lastIndexOf(ts.directorySeparator))); + } + ts.getDirectoryPath = getDirectoryPath; + function isUrl(path) { + return path && !isRootedDiskPath(path) && path.indexOf("://") !== -1; + } + ts.isUrl = isUrl; + function isRootedDiskPath(path) { + return getRootLength(path) !== 0; + } + ts.isRootedDiskPath = isRootedDiskPath; + function normalizedPathComponents(path, rootLength) { + var normalizedParts = getNormalizedParts(path, rootLength); + return [path.substr(0, rootLength)].concat(normalizedParts); + } + function getNormalizedPathComponents(path, currentDirectory) { + path = normalizeSlashes(path); + var rootLength = getRootLength(path); + if (rootLength === 0) { + // If the path is not rooted it is relative to current directory + path = combinePaths(normalizeSlashes(currentDirectory), path); + rootLength = getRootLength(path); + } + return normalizedPathComponents(path, rootLength); + } + ts.getNormalizedPathComponents = getNormalizedPathComponents; + function getNormalizedAbsolutePath(fileName, currentDirectory) { + return getNormalizedPathFromPathComponents(getNormalizedPathComponents(fileName, currentDirectory)); + } + ts.getNormalizedAbsolutePath = getNormalizedAbsolutePath; + function getNormalizedPathFromPathComponents(pathComponents) { + if (pathComponents && pathComponents.length) { + return pathComponents[0] + pathComponents.slice(1).join(ts.directorySeparator); + } + } + ts.getNormalizedPathFromPathComponents = getNormalizedPathFromPathComponents; + function getNormalizedPathComponentsOfUrl(url) { + // Get root length of http://www.website.com/folder1/foler2/ + // In this example the root is: http://www.website.com/ + // normalized path components should be ["http://www.website.com/", "folder1", "folder2"] + var urlLength = url.length; + // Initial root length is http:// part + var rootLength = url.indexOf("://") + "://".length; + while (rootLength < urlLength) { + // Consume all immediate slashes in the protocol + // eg.initial rootlength is just file:// but it needs to consume another "/" in file:/// + if (url.charCodeAt(rootLength) === 47 /* slash */) { + rootLength++; + } + else { + // non slash character means we continue proceeding to next component of root search + break; + } + } + // there are no parts after http:// just return current string as the pathComponent + if (rootLength === urlLength) { + return [url]; + } + // Find the index of "/" after website.com so the root can be http://www.website.com/ (from existing http://) + var indexOfNextSlash = url.indexOf(ts.directorySeparator, rootLength); + if (indexOfNextSlash !== -1) { + // Found the "/" after the website.com so the root is length of http://www.website.com/ + // and get components afetr the root normally like any other folder components + rootLength = indexOfNextSlash + 1; + return normalizedPathComponents(url, rootLength); + } + else { + // Can't find the host assume the rest of the string as component + // but make sure we append "/" to it as root is not joined using "/" + // eg. if url passed in was http://website.com we want to use root as [http://website.com/] + // so that other path manipulations will be correct and it can be merged with relative paths correctly + return [url + ts.directorySeparator]; + } + } + function getNormalizedPathOrUrlComponents(pathOrUrl, currentDirectory) { + if (isUrl(pathOrUrl)) { + return getNormalizedPathComponentsOfUrl(pathOrUrl); + } + else { + return getNormalizedPathComponents(pathOrUrl, currentDirectory); + } + } + function getRelativePathToDirectoryOrUrl(directoryPathOrUrl, relativeOrAbsolutePath, currentDirectory, getCanonicalFileName, isAbsolutePathAnUrl) { + var pathComponents = getNormalizedPathOrUrlComponents(relativeOrAbsolutePath, currentDirectory); + var directoryComponents = getNormalizedPathOrUrlComponents(directoryPathOrUrl, currentDirectory); + if (directoryComponents.length > 1 && lastOrUndefined(directoryComponents) === "") { + // If the directory path given was of type test/cases/ then we really need components of directory to be only till its name + // that is ["test", "cases", ""] needs to be actually ["test", "cases"] + directoryComponents.length--; + } + // Find the component that differs + for (var joinStartIndex = 0; joinStartIndex < pathComponents.length && joinStartIndex < directoryComponents.length; joinStartIndex++) { + if (getCanonicalFileName(directoryComponents[joinStartIndex]) !== getCanonicalFileName(pathComponents[joinStartIndex])) { + break; + } + } + // Get the relative path + if (joinStartIndex) { + var relativePath = ""; + var relativePathComponents = pathComponents.slice(joinStartIndex, pathComponents.length); + for (; joinStartIndex < directoryComponents.length; joinStartIndex++) { + if (directoryComponents[joinStartIndex] !== "") { + relativePath = relativePath + ".." + ts.directorySeparator; + } + } + return relativePath + relativePathComponents.join(ts.directorySeparator); + } + // Cant find the relative path, get the absolute path + var absolutePath = getNormalizedPathFromPathComponents(pathComponents); + if (isAbsolutePathAnUrl && isRootedDiskPath(absolutePath)) { + absolutePath = "file:///" + absolutePath; + } + return absolutePath; + } + ts.getRelativePathToDirectoryOrUrl = getRelativePathToDirectoryOrUrl; + function getBaseFileName(path) { + if (!path) { + return undefined; + } + var i = path.lastIndexOf(ts.directorySeparator); + return i < 0 ? path : path.substring(i + 1); + } + ts.getBaseFileName = getBaseFileName; + function combinePaths(path1, path2) { + if (!(path1 && path1.length)) + return path2; + if (!(path2 && path2.length)) + return path1; + if (getRootLength(path2) !== 0) + return path2; + if (path1.charAt(path1.length - 1) === ts.directorySeparator) + return path1 + path2; + return path1 + ts.directorySeparator + path2; + } + ts.combinePaths = combinePaths; + function fileExtensionIs(path, extension) { + var pathLen = path.length; + var extLen = extension.length; + return pathLen > extLen && path.substr(pathLen - extLen, extLen) === extension; + } + ts.fileExtensionIs = fileExtensionIs; + /** + * List of supported extensions in order of file resolution precedence. + */ + ts.supportedExtensions = [".ts", ".tsx", ".d.ts"]; + /** + * List of extensions that will be used to look for external modules. + * This list is kept separate from supportedExtensions to for cases when we'll allow to include .js files in compilation, + * but still would like to load only TypeScript files as modules + */ + ts.moduleFileExtensions = ts.supportedExtensions; + function isSupportedSourceFileName(fileName) { + if (!fileName) { + return false; + } + for (var _i = 0; _i < ts.supportedExtensions.length; _i++) { + var extension = ts.supportedExtensions[_i]; + if (fileExtensionIs(fileName, extension)) { + return true; + } + } + return false; + } + ts.isSupportedSourceFileName = isSupportedSourceFileName; + var extensionsToRemove = [".d.ts", ".ts", ".js", ".tsx", ".jsx"]; + function removeFileExtension(path) { + for (var _i = 0; _i < extensionsToRemove.length; _i++) { + var ext = extensionsToRemove[_i]; + if (fileExtensionIs(path, ext)) { + return path.substr(0, path.length - ext.length); + } + } + return path; + } + ts.removeFileExtension = removeFileExtension; + var backslashOrDoubleQuote = /[\"\\]/g; + var escapedCharsRegExp = /[\u0000-\u001f\t\v\f\b\r\n\u2028\u2029\u0085]/g; + var escapedCharsMap = { + "\0": "\\0", + "\t": "\\t", + "\v": "\\v", + "\f": "\\f", + "\b": "\\b", + "\r": "\\r", + "\n": "\\n", + "\\": "\\\\", + "\"": "\\\"", + "\u2028": "\\u2028", + "\u2029": "\\u2029", + "\u0085": "\\u0085" // nextLine + }; + function Symbol(flags, name) { + this.flags = flags; + this.name = name; + this.declarations = undefined; + } + function Type(checker, flags) { + this.flags = flags; + } + function Signature(checker) { + } + ts.objectAllocator = { + getNodeConstructor: function (kind) { + function Node(pos, end) { + this.pos = pos; + this.end = end; + this.flags = 0 /* None */; + this.parent = undefined; + } + Node.prototype = { kind: kind }; + return Node; + }, + getSymbolConstructor: function () { return Symbol; }, + 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) { + var currentAssertionLevel = 0 /* None */; + function shouldAssert(level) { + return currentAssertionLevel >= level; + } + Debug.shouldAssert = shouldAssert; + function assert(expression, message, verboseDebugInfo) { + if (!expression) { + var verboseDebugString = ""; + if (verboseDebugInfo) { + verboseDebugString = "\r\nVerbose Debug Information: " + verboseDebugInfo(); + } + debugger; + throw new Error("Debug Failure. False expression: " + (message || "") + verboseDebugString); + } + } + Debug.assert = assert; + function fail(message) { + Debug.assert(false, message); + } + Debug.fail = fail; + })(Debug = ts.Debug || (ts.Debug = {})); + function copyListRemovingItem(item, list) { + var copiedList = []; + for (var _i = 0; _i < list.length; _i++) { + var e = list[_i]; + if (e !== item) { + copiedList.push(e); + } + } + return copiedList; + } + ts.copyListRemovingItem = copyListRemovingItem; +})(ts || (ts = {})); +/// +var ts; +(function (ts) { + ts.sys = (function () { + function getWScriptSystem() { + var fso = new ActiveXObject("Scripting.FileSystemObject"); + var fileStream = new ActiveXObject("ADODB.Stream"); + fileStream.Type = 2 /*text*/; + var binaryStream = new ActiveXObject("ADODB.Stream"); + binaryStream.Type = 1 /*binary*/; + var args = []; + for (var i = 0; i < WScript.Arguments.length; i++) { + args[i] = WScript.Arguments.Item(i); + } + function readFile(fileName, encoding) { + if (!fso.FileExists(fileName)) { + return undefined; + } + fileStream.Open(); + try { + if (encoding) { + fileStream.Charset = encoding; + fileStream.LoadFromFile(fileName); + } + else { + // Load file and read the first two bytes into a string with no interpretation + fileStream.Charset = "x-ansi"; + fileStream.LoadFromFile(fileName); + var bom = fileStream.ReadText(2) || ""; + // Position must be at 0 before encoding can be changed + fileStream.Position = 0; + // [0xFF,0xFE] and [0xFE,0xFF] mean utf-16 (little or big endian), otherwise default to utf-8 + fileStream.Charset = bom.length >= 2 && (bom.charCodeAt(0) === 0xFF && bom.charCodeAt(1) === 0xFE || bom.charCodeAt(0) === 0xFE && bom.charCodeAt(1) === 0xFF) ? "unicode" : "utf-8"; + } + // ReadText method always strips byte order mark from resulting string + return fileStream.ReadText(); + } + catch (e) { + throw e; + } + finally { + fileStream.Close(); + } + } + function writeFile(fileName, data, writeByteOrderMark) { + fileStream.Open(); + binaryStream.Open(); + try { + // Write characters in UTF-8 encoding + fileStream.Charset = "utf-8"; + fileStream.WriteText(data); + // If we don't want the BOM, then skip it by setting the starting location to 3 (size of BOM). + // If not, start from position 0, as the BOM will be added automatically when charset==utf8. + if (writeByteOrderMark) { + fileStream.Position = 0; + } + else { + fileStream.Position = 3; + } + fileStream.CopyTo(binaryStream); + binaryStream.SaveToFile(fileName, 2 /*overwrite*/); + } + finally { + binaryStream.Close(); + fileStream.Close(); + } + } + function getCanonicalPath(path) { + return path.toLowerCase(); + } + function getNames(collection) { + var result = []; + for (var e = new Enumerator(collection); !e.atEnd(); e.moveNext()) { + result.push(e.item().Name); + } + return result.sort(); + } + function readDirectory(path, extension, exclude) { + var result = []; + exclude = ts.map(exclude, function (s) { return getCanonicalPath(ts.combinePaths(path, s)); }); + visitDirectory(path); + return result; + function visitDirectory(path) { + var folder = fso.GetFolder(path || "."); + var files = getNames(folder.files); + for (var _i = 0; _i < files.length; _i++) { + var current = files[_i]; + var name_1 = ts.combinePaths(path, current); + if ((!extension || ts.fileExtensionIs(name_1, extension)) && !ts.contains(exclude, getCanonicalPath(name_1))) { + result.push(name_1); + } + } + var subfolders = getNames(folder.subfolders); + for (var _a = 0; _a < subfolders.length; _a++) { + var current = subfolders[_a]; + var name_2 = ts.combinePaths(path, current); + if (!ts.contains(exclude, getCanonicalPath(name_2))) { + visitDirectory(name_2); + } + } + } + } + return { + args: args, + newLine: "\r\n", + useCaseSensitiveFileNames: false, + write: function (s) { + WScript.StdOut.Write(s); + }, + readFile: readFile, + writeFile: writeFile, + resolvePath: function (path) { + return fso.GetAbsolutePathName(path); + }, + fileExists: function (path) { + return fso.FileExists(path); + }, + directoryExists: function (path) { + return fso.FolderExists(path); + }, + createDirectory: function (directoryName) { + if (!this.directoryExists(directoryName)) { + fso.CreateFolder(directoryName); + } + }, + getExecutingFilePath: function () { + return WScript.ScriptFullName; + }, + getCurrentDirectory: function () { + return new ActiveXObject("WScript.Shell").CurrentDirectory; + }, + readDirectory: readDirectory, + exit: function (exitCode) { + try { + WScript.Quit(exitCode); + } + catch (e) { + } + } + }; + } + function getNodeSystem() { + var _fs = require("fs"); + var _path = require("path"); + var _os = require("os"); + // average async stat takes about 30 microseconds + // set chunk size to do 30 files in < 1 millisecond + function createWatchedFileSet(interval, chunkSize) { + if (interval === void 0) { interval = 2500; } + if (chunkSize === void 0) { chunkSize = 30; } + var watchedFiles = []; + var nextFileToCheck = 0; + var watchTimer; + function getModifiedTime(fileName) { + return _fs.statSync(fileName).mtime; + } + function poll(checkedIndex) { + var watchedFile = watchedFiles[checkedIndex]; + if (!watchedFile) { + return; + } + _fs.stat(watchedFile.fileName, function (err, stats) { + if (err) { + watchedFile.callback(watchedFile.fileName); + } + else if (watchedFile.mtime.getTime() !== stats.mtime.getTime()) { + watchedFile.mtime = getModifiedTime(watchedFile.fileName); + watchedFile.callback(watchedFile.fileName, watchedFile.mtime.getTime() === 0); + } + }); + } + // this implementation uses polling and + // stat due to inconsistencies of fs.watch + // and efficiency of stat on modern filesystems + function startWatchTimer() { + watchTimer = setInterval(function () { + var count = 0; + var nextToCheck = nextFileToCheck; + var firstCheck = -1; + while ((count < chunkSize) && (nextToCheck !== firstCheck)) { + poll(nextToCheck); + if (firstCheck < 0) { + firstCheck = nextToCheck; + } + nextToCheck++; + if (nextToCheck === watchedFiles.length) { + nextToCheck = 0; + } + count++; + } + nextFileToCheck = nextToCheck; + }, interval); + } + function addFile(fileName, callback) { + var file = { + fileName: fileName, + callback: callback, + mtime: getModifiedTime(fileName) + }; + watchedFiles.push(file); + if (watchedFiles.length === 1) { + startWatchTimer(); + } + return file; + } + function removeFile(file) { + watchedFiles = ts.copyListRemovingItem(file, watchedFiles); + } + return { + getModifiedTime: getModifiedTime, + poll: poll, + startWatchTimer: startWatchTimer, + addFile: addFile, + removeFile: removeFile + }; + } + // REVIEW: for now this implementation uses polling. + // The advantage of polling is that it works reliably + // on all os and with network mounted files. + // For 90 referenced files, the average time to detect + // changes is 2*msInterval (by default 5 seconds). + // The overhead of this is .04 percent (1/2500) with + // average pause of < 1 millisecond (and max + // pause less than 1.5 milliseconds); question is + // do we anticipate reference sets in the 100s and + // do we care about waiting 10-20 seconds to detect + // changes for large reference sets? If so, do we want + // to increase the chunk size or decrease the interval + // time dynamically to match the large reference set? + var watchedFileSet = createWatchedFileSet(); + function isNode4OrLater() { + return parseInt(process.version.charAt(1)) >= 4; + } + 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"; + function readFile(fileName, encoding) { + if (!_fs.existsSync(fileName)) { + return undefined; + } + var buffer = _fs.readFileSync(fileName); + var len = buffer.length; + if (len >= 2 && buffer[0] === 0xFE && buffer[1] === 0xFF) { + // Big endian UTF-16 byte order mark detected. Since big endian is not supported by node.js, + // flip all byte pairs and treat as little endian. + len &= ~1; + for (var i = 0; i < len; i += 2) { + var temp = buffer[i]; + buffer[i] = buffer[i + 1]; + buffer[i + 1] = temp; + } + return buffer.toString("utf16le", 2); + } + if (len >= 2 && buffer[0] === 0xFF && buffer[1] === 0xFE) { + // Little endian UTF-16 byte order mark detected + return buffer.toString("utf16le", 2); + } + if (len >= 3 && buffer[0] === 0xEF && buffer[1] === 0xBB && buffer[2] === 0xBF) { + // UTF-8 byte order mark detected + return buffer.toString("utf8", 3); + } + // Default is UTF-8 with no byte order mark + return buffer.toString("utf8"); + } + function writeFile(fileName, data, writeByteOrderMark) { + // If a BOM is required, emit one + if (writeByteOrderMark) { + data = "\uFEFF" + data; + } + _fs.writeFileSync(fileName, data, "utf8"); + } + function getCanonicalPath(path) { + return useCaseSensitiveFileNames ? path.toLowerCase() : path; + } + function readDirectory(path, extension, exclude) { + var result = []; + exclude = ts.map(exclude, function (s) { return getCanonicalPath(ts.combinePaths(path, s)); }); + visitDirectory(path); + return result; + function visitDirectory(path) { + var files = _fs.readdirSync(path || ".").sort(); + var directories = []; + for (var _i = 0; _i < files.length; _i++) { + var current = files[_i]; + var name_3 = ts.combinePaths(path, current); + if (!ts.contains(exclude, getCanonicalPath(name_3))) { + var stat = _fs.statSync(name_3); + if (stat.isFile()) { + if (!extension || ts.fileExtensionIs(name_3, extension)) { + result.push(name_3); + } + } + else if (stat.isDirectory()) { + directories.push(name_3); + } + } + } + for (var _a = 0; _a < directories.length; _a++) { + var current = directories[_a]; + visitDirectory(current); + } + } + } + return { + args: process.argv.slice(2), + newLine: _os.EOL, + useCaseSensitiveFileNames: useCaseSensitiveFileNames, + write: function (s) { + var buffer = new Buffer(s, "utf8"); + var offset = 0; + var toWrite = buffer.length; + var written = 0; + // 1 is a standard descriptor for stdout + while ((written = _fs.writeSync(1, buffer, offset, toWrite)) < toWrite) { + offset += written; + toWrite -= written; + } + }, + readFile: readFile, + writeFile: writeFile, + watchFile: function (fileName, callback) { + // Node 4.0 stablized the `fs.watch` function on Windows which avoids polling + // and is more efficient than `fs.watchFile` (ref: https://github.com/nodejs/node/pull/2649 + // and https://github.com/Microsoft/TypeScript/issues/4643), therefore + // if the current node.js version is newer than 4, use `fs.watch` instead. + if (isNode4OrLater()) { + // Note: in node the callback of fs.watch is given only the relative file name as a parameter + return _fs.watch(fileName, function (eventName, relativeFileName) { return callback(fileName); }); + } + var watchedFile = watchedFileSet.addFile(fileName, callback); + return { + close: function () { return watchedFileSet.removeFile(watchedFile); } + }; + }, + watchDirectory: function (path, callback, recursive) { + // 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) + return _fs.watch(path, { persistent: true, recursive: !!recursive }, function (eventName, relativeFileName) { + // In watchDirectory we only care about adding and removing files (when event name is + // "rename"); changes made within files are handled by corresponding fileWatchers (when + // event name is "change") + if (eventName === "rename") { + // When deleting a file, the passed baseFileName is null + callback(!relativeFileName ? relativeFileName : ts.normalizePath(ts.combinePaths(path, relativeFileName))); + } + ; + }); + }, + resolvePath: function (path) { + return _path.resolve(path); + }, + fileExists: function (path) { + return _fs.existsSync(path); + }, + directoryExists: function (path) { + return _fs.existsSync(path) && _fs.statSync(path).isDirectory(); + }, + createDirectory: function (directoryName) { + if (!this.directoryExists(directoryName)) { + _fs.mkdirSync(directoryName); + } + }, + getExecutingFilePath: function () { + return __filename; + }, + getCurrentDirectory: function () { + return process.cwd(); + }, + readDirectory: readDirectory, + getMemoryUsage: function () { + if (global.gc) { + global.gc(); + } + return process.memoryUsage().heapUsed; + }, + exit: function (exitCode) { + process.exit(exitCode); + } + }; + } + if (typeof WScript !== "undefined" && typeof ActiveXObject === "function") { + return 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(); + } + else { + return undefined; // Unsupported host + } + })(); +})(ts || (ts = {})); +// +/// +/* @internal */ +var ts; +(function (ts) { + ts.Diagnostics = { + Unterminated_string_literal: { code: 1002, category: ts.DiagnosticCategory.Error, key: "Unterminated_string_literal_1002", message: "Unterminated string literal." }, + Identifier_expected: { code: 1003, category: ts.DiagnosticCategory.Error, key: "Identifier_expected_1003", message: "Identifier expected." }, + _0_expected: { code: 1005, category: ts.DiagnosticCategory.Error, key: "_0_expected_1005", message: "'{0}' expected." }, + A_file_cannot_have_a_reference_to_itself: { code: 1006, category: ts.DiagnosticCategory.Error, key: "A_file_cannot_have_a_reference_to_itself_1006", message: "A file cannot have a reference to itself." }, + Trailing_comma_not_allowed: { code: 1009, category: ts.DiagnosticCategory.Error, key: "Trailing_comma_not_allowed_1009", message: "Trailing comma not allowed." }, + Asterisk_Slash_expected: { code: 1010, category: ts.DiagnosticCategory.Error, key: "Asterisk_Slash_expected_1010", message: "'*/' expected." }, + Unexpected_token: { code: 1012, category: ts.DiagnosticCategory.Error, key: "Unexpected_token_1012", message: "Unexpected token." }, + A_rest_parameter_must_be_last_in_a_parameter_list: { code: 1014, category: ts.DiagnosticCategory.Error, key: "A_rest_parameter_must_be_last_in_a_parameter_list_1014", message: "A rest parameter must be last in a parameter list." }, + Parameter_cannot_have_question_mark_and_initializer: { code: 1015, category: ts.DiagnosticCategory.Error, key: "Parameter_cannot_have_question_mark_and_initializer_1015", message: "Parameter cannot have question mark and initializer." }, + A_required_parameter_cannot_follow_an_optional_parameter: { code: 1016, category: ts.DiagnosticCategory.Error, key: "A_required_parameter_cannot_follow_an_optional_parameter_1016", message: "A required parameter cannot follow an optional parameter." }, + An_index_signature_cannot_have_a_rest_parameter: { code: 1017, category: ts.DiagnosticCategory.Error, key: "An_index_signature_cannot_have_a_rest_parameter_1017", message: "An index signature cannot have a rest parameter." }, + An_index_signature_parameter_cannot_have_an_accessibility_modifier: { code: 1018, category: ts.DiagnosticCategory.Error, key: "An_index_signature_parameter_cannot_have_an_accessibility_modifier_1018", message: "An index signature parameter cannot have an accessibility modifier." }, + An_index_signature_parameter_cannot_have_a_question_mark: { code: 1019, category: ts.DiagnosticCategory.Error, key: "An_index_signature_parameter_cannot_have_a_question_mark_1019", message: "An index signature parameter cannot have a question mark." }, + An_index_signature_parameter_cannot_have_an_initializer: { code: 1020, category: ts.DiagnosticCategory.Error, key: "An_index_signature_parameter_cannot_have_an_initializer_1020", message: "An index signature parameter cannot have an initializer." }, + An_index_signature_must_have_a_type_annotation: { code: 1021, category: ts.DiagnosticCategory.Error, key: "An_index_signature_must_have_a_type_annotation_1021", message: "An index signature must have a type annotation." }, + An_index_signature_parameter_must_have_a_type_annotation: { code: 1022, category: ts.DiagnosticCategory.Error, key: "An_index_signature_parameter_must_have_a_type_annotation_1022", message: "An index signature parameter must have a type annotation." }, + An_index_signature_parameter_type_must_be_string_or_number: { code: 1023, category: ts.DiagnosticCategory.Error, key: "An_index_signature_parameter_type_must_be_string_or_number_1023", message: "An index signature parameter type must be 'string' or 'number'." }, + Accessibility_modifier_already_seen: { code: 1028, category: ts.DiagnosticCategory.Error, key: "Accessibility_modifier_already_seen_1028", message: "Accessibility modifier already seen." }, + _0_modifier_must_precede_1_modifier: { code: 1029, category: ts.DiagnosticCategory.Error, key: "_0_modifier_must_precede_1_modifier_1029", message: "'{0}' modifier must precede '{1}' modifier." }, + _0_modifier_already_seen: { code: 1030, category: ts.DiagnosticCategory.Error, key: "_0_modifier_already_seen_1030", message: "'{0}' modifier already seen." }, + _0_modifier_cannot_appear_on_a_class_element: { code: 1031, category: ts.DiagnosticCategory.Error, key: "_0_modifier_cannot_appear_on_a_class_element_1031", message: "'{0}' modifier cannot appear on a class element." }, + super_must_be_followed_by_an_argument_list_or_member_access: { code: 1034, category: ts.DiagnosticCategory.Error, key: "super_must_be_followed_by_an_argument_list_or_member_access_1034", message: "'super' must be followed by an argument list or member access." }, + Only_ambient_modules_can_use_quoted_names: { code: 1035, category: ts.DiagnosticCategory.Error, key: "Only_ambient_modules_can_use_quoted_names_1035", message: "Only ambient modules can use quoted names." }, + Statements_are_not_allowed_in_ambient_contexts: { code: 1036, category: ts.DiagnosticCategory.Error, key: "Statements_are_not_allowed_in_ambient_contexts_1036", message: "Statements are not allowed in ambient contexts." }, + A_declare_modifier_cannot_be_used_in_an_already_ambient_context: { code: 1038, category: ts.DiagnosticCategory.Error, key: "A_declare_modifier_cannot_be_used_in_an_already_ambient_context_1038", message: "A 'declare' modifier cannot be used in an already ambient context." }, + Initializers_are_not_allowed_in_ambient_contexts: { code: 1039, category: ts.DiagnosticCategory.Error, key: "Initializers_are_not_allowed_in_ambient_contexts_1039", message: "Initializers are not allowed in ambient contexts." }, + _0_modifier_cannot_be_used_in_an_ambient_context: { code: 1040, category: ts.DiagnosticCategory.Error, key: "_0_modifier_cannot_be_used_in_an_ambient_context_1040", message: "'{0}' modifier cannot be used in an ambient context." }, + _0_modifier_cannot_be_used_with_a_class_declaration: { code: 1041, category: ts.DiagnosticCategory.Error, key: "_0_modifier_cannot_be_used_with_a_class_declaration_1041", message: "'{0}' modifier cannot be used with a class declaration." }, + _0_modifier_cannot_be_used_here: { code: 1042, category: ts.DiagnosticCategory.Error, key: "_0_modifier_cannot_be_used_here_1042", message: "'{0}' modifier cannot be used here." }, + _0_modifier_cannot_appear_on_a_data_property: { code: 1043, category: ts.DiagnosticCategory.Error, key: "_0_modifier_cannot_appear_on_a_data_property_1043", message: "'{0}' modifier cannot appear on a data property." }, + _0_modifier_cannot_appear_on_a_module_element: { code: 1044, category: ts.DiagnosticCategory.Error, key: "_0_modifier_cannot_appear_on_a_module_element_1044", message: "'{0}' modifier cannot appear on a module element." }, + A_0_modifier_cannot_be_used_with_an_interface_declaration: { code: 1045, category: ts.DiagnosticCategory.Error, key: "A_0_modifier_cannot_be_used_with_an_interface_declaration_1045", message: "A '{0}' modifier cannot be used with an interface declaration." }, + A_declare_modifier_is_required_for_a_top_level_declaration_in_a_d_ts_file: { code: 1046, category: ts.DiagnosticCategory.Error, key: "A_declare_modifier_is_required_for_a_top_level_declaration_in_a_d_ts_file_1046", message: "A 'declare' modifier is required for a top level declaration in a .d.ts file." }, + A_rest_parameter_cannot_be_optional: { code: 1047, category: ts.DiagnosticCategory.Error, key: "A_rest_parameter_cannot_be_optional_1047", message: "A rest parameter cannot be optional." }, + A_rest_parameter_cannot_have_an_initializer: { code: 1048, category: ts.DiagnosticCategory.Error, key: "A_rest_parameter_cannot_have_an_initializer_1048", message: "A rest parameter cannot have an initializer." }, + A_set_accessor_must_have_exactly_one_parameter: { code: 1049, category: ts.DiagnosticCategory.Error, key: "A_set_accessor_must_have_exactly_one_parameter_1049", message: "A 'set' accessor must have exactly one parameter." }, + A_set_accessor_cannot_have_an_optional_parameter: { code: 1051, category: ts.DiagnosticCategory.Error, key: "A_set_accessor_cannot_have_an_optional_parameter_1051", message: "A 'set' accessor cannot have an optional parameter." }, + A_set_accessor_parameter_cannot_have_an_initializer: { code: 1052, category: ts.DiagnosticCategory.Error, key: "A_set_accessor_parameter_cannot_have_an_initializer_1052", message: "A 'set' accessor parameter cannot have an initializer." }, + A_set_accessor_cannot_have_rest_parameter: { code: 1053, category: ts.DiagnosticCategory.Error, key: "A_set_accessor_cannot_have_rest_parameter_1053", message: "A 'set' accessor cannot have rest parameter." }, + A_get_accessor_cannot_have_parameters: { code: 1054, category: ts.DiagnosticCategory.Error, key: "A_get_accessor_cannot_have_parameters_1054", message: "A 'get' accessor cannot have parameters." }, + Type_0_is_not_a_valid_async_function_return_type: { code: 1055, category: ts.DiagnosticCategory.Error, key: "Type_0_is_not_a_valid_async_function_return_type_1055", message: "Type '{0}' is not a valid async function return type." }, + Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher: { code: 1056, category: ts.DiagnosticCategory.Error, key: "Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher_1056", message: "Accessors are only available when targeting ECMAScript 5 and higher." }, + An_async_function_or_method_must_have_a_valid_awaitable_return_type: { code: 1057, category: ts.DiagnosticCategory.Error, key: "An_async_function_or_method_must_have_a_valid_awaitable_return_type_1057", message: "An async function or method must have a valid awaitable return type." }, + Operand_for_await_does_not_have_a_valid_callable_then_member: { code: 1058, category: ts.DiagnosticCategory.Error, key: "Operand_for_await_does_not_have_a_valid_callable_then_member_1058", message: "Operand for 'await' does not have a valid callable 'then' member." }, + Return_expression_in_async_function_does_not_have_a_valid_callable_then_member: { code: 1059, category: ts.DiagnosticCategory.Error, key: "Return_expression_in_async_function_does_not_have_a_valid_callable_then_member_1059", message: "Return expression in async function does not have a valid callable 'then' member." }, + Expression_body_for_async_arrow_function_does_not_have_a_valid_callable_then_member: { code: 1060, category: ts.DiagnosticCategory.Error, key: "Expression_body_for_async_arrow_function_does_not_have_a_valid_callable_then_member_1060", message: "Expression body for async arrow function does not have a valid callable 'then' member." }, + Enum_member_must_have_initializer: { code: 1061, category: ts.DiagnosticCategory.Error, key: "Enum_member_must_have_initializer_1061", message: "Enum member must have initializer." }, + _0_is_referenced_directly_or_indirectly_in_the_fulfillment_callback_of_its_own_then_method: { code: 1062, category: ts.DiagnosticCategory.Error, key: "_0_is_referenced_directly_or_indirectly_in_the_fulfillment_callback_of_its_own_then_method_1062", message: "{0} is referenced directly or indirectly in the fulfillment callback of its own 'then' method." }, + An_export_assignment_cannot_be_used_in_a_namespace: { code: 1063, category: ts.DiagnosticCategory.Error, key: "An_export_assignment_cannot_be_used_in_a_namespace_1063", message: "An export assignment cannot be used in a namespace." }, + In_ambient_enum_declarations_member_initializer_must_be_constant_expression: { code: 1066, category: ts.DiagnosticCategory.Error, key: "In_ambient_enum_declarations_member_initializer_must_be_constant_expression_1066", message: "In ambient enum declarations member initializer must be constant expression." }, + Unexpected_token_A_constructor_method_accessor_or_property_was_expected: { code: 1068, category: ts.DiagnosticCategory.Error, key: "Unexpected_token_A_constructor_method_accessor_or_property_was_expected_1068", message: "Unexpected token. A constructor, method, accessor, or property was expected." }, + A_0_modifier_cannot_be_used_with_an_import_declaration: { code: 1079, category: ts.DiagnosticCategory.Error, key: "A_0_modifier_cannot_be_used_with_an_import_declaration_1079", message: "A '{0}' modifier cannot be used with an import declaration." }, + Invalid_reference_directive_syntax: { code: 1084, category: ts.DiagnosticCategory.Error, key: "Invalid_reference_directive_syntax_1084", message: "Invalid 'reference' directive syntax." }, + Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher: { code: 1085, category: ts.DiagnosticCategory.Error, key: "Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher_1085", message: "Octal literals are not available when targeting ECMAScript 5 and higher." }, + An_accessor_cannot_be_declared_in_an_ambient_context: { code: 1086, category: ts.DiagnosticCategory.Error, key: "An_accessor_cannot_be_declared_in_an_ambient_context_1086", message: "An accessor cannot be declared in an ambient context." }, + _0_modifier_cannot_appear_on_a_constructor_declaration: { code: 1089, category: ts.DiagnosticCategory.Error, key: "_0_modifier_cannot_appear_on_a_constructor_declaration_1089", message: "'{0}' modifier cannot appear on a constructor declaration." }, + _0_modifier_cannot_appear_on_a_parameter: { code: 1090, category: ts.DiagnosticCategory.Error, key: "_0_modifier_cannot_appear_on_a_parameter_1090", message: "'{0}' modifier cannot appear on a parameter." }, + Only_a_single_variable_declaration_is_allowed_in_a_for_in_statement: { code: 1091, category: ts.DiagnosticCategory.Error, key: "Only_a_single_variable_declaration_is_allowed_in_a_for_in_statement_1091", message: "Only a single variable declaration is allowed in a 'for...in' statement." }, + Type_parameters_cannot_appear_on_a_constructor_declaration: { code: 1092, category: ts.DiagnosticCategory.Error, key: "Type_parameters_cannot_appear_on_a_constructor_declaration_1092", message: "Type parameters cannot appear on a constructor declaration." }, + Type_annotation_cannot_appear_on_a_constructor_declaration: { code: 1093, category: ts.DiagnosticCategory.Error, key: "Type_annotation_cannot_appear_on_a_constructor_declaration_1093", message: "Type annotation cannot appear on a constructor declaration." }, + An_accessor_cannot_have_type_parameters: { code: 1094, category: ts.DiagnosticCategory.Error, key: "An_accessor_cannot_have_type_parameters_1094", message: "An accessor cannot have type parameters." }, + A_set_accessor_cannot_have_a_return_type_annotation: { code: 1095, category: ts.DiagnosticCategory.Error, key: "A_set_accessor_cannot_have_a_return_type_annotation_1095", message: "A 'set' accessor cannot have a return type annotation." }, + An_index_signature_must_have_exactly_one_parameter: { code: 1096, category: ts.DiagnosticCategory.Error, key: "An_index_signature_must_have_exactly_one_parameter_1096", message: "An index signature must have exactly one parameter." }, + _0_list_cannot_be_empty: { code: 1097, category: ts.DiagnosticCategory.Error, key: "_0_list_cannot_be_empty_1097", message: "'{0}' list cannot be empty." }, + Type_parameter_list_cannot_be_empty: { code: 1098, category: ts.DiagnosticCategory.Error, key: "Type_parameter_list_cannot_be_empty_1098", message: "Type parameter list cannot be empty." }, + Type_argument_list_cannot_be_empty: { code: 1099, category: ts.DiagnosticCategory.Error, key: "Type_argument_list_cannot_be_empty_1099", message: "Type argument list cannot be empty." }, + Invalid_use_of_0_in_strict_mode: { code: 1100, category: ts.DiagnosticCategory.Error, key: "Invalid_use_of_0_in_strict_mode_1100", message: "Invalid use of '{0}' in strict mode." }, + with_statements_are_not_allowed_in_strict_mode: { code: 1101, category: ts.DiagnosticCategory.Error, key: "with_statements_are_not_allowed_in_strict_mode_1101", message: "'with' statements are not allowed in strict mode." }, + delete_cannot_be_called_on_an_identifier_in_strict_mode: { code: 1102, category: ts.DiagnosticCategory.Error, key: "delete_cannot_be_called_on_an_identifier_in_strict_mode_1102", message: "'delete' cannot be called on an identifier in strict mode." }, + A_continue_statement_can_only_be_used_within_an_enclosing_iteration_statement: { code: 1104, category: ts.DiagnosticCategory.Error, key: "A_continue_statement_can_only_be_used_within_an_enclosing_iteration_statement_1104", message: "A 'continue' statement can only be used within an enclosing iteration statement." }, + A_break_statement_can_only_be_used_within_an_enclosing_iteration_or_switch_statement: { code: 1105, category: ts.DiagnosticCategory.Error, key: "A_break_statement_can_only_be_used_within_an_enclosing_iteration_or_switch_statement_1105", message: "A 'break' statement can only be used within an enclosing iteration or switch statement." }, + Jump_target_cannot_cross_function_boundary: { code: 1107, category: ts.DiagnosticCategory.Error, key: "Jump_target_cannot_cross_function_boundary_1107", message: "Jump target cannot cross function boundary." }, + A_return_statement_can_only_be_used_within_a_function_body: { code: 1108, category: ts.DiagnosticCategory.Error, key: "A_return_statement_can_only_be_used_within_a_function_body_1108", message: "A 'return' statement can only be used within a function body." }, + Expression_expected: { code: 1109, category: ts.DiagnosticCategory.Error, key: "Expression_expected_1109", message: "Expression expected." }, + Type_expected: { code: 1110, category: ts.DiagnosticCategory.Error, key: "Type_expected_1110", message: "Type expected." }, + A_class_member_cannot_be_declared_optional: { code: 1112, category: ts.DiagnosticCategory.Error, key: "A_class_member_cannot_be_declared_optional_1112", message: "A class member cannot be declared optional." }, + A_default_clause_cannot_appear_more_than_once_in_a_switch_statement: { code: 1113, category: ts.DiagnosticCategory.Error, key: "A_default_clause_cannot_appear_more_than_once_in_a_switch_statement_1113", message: "A 'default' clause cannot appear more than once in a 'switch' statement." }, + Duplicate_label_0: { code: 1114, category: ts.DiagnosticCategory.Error, key: "Duplicate_label_0_1114", message: "Duplicate label '{0}'" }, + A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement: { code: 1115, category: ts.DiagnosticCategory.Error, key: "A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement_1115", message: "A 'continue' statement can only jump to a label of an enclosing iteration statement." }, + A_break_statement_can_only_jump_to_a_label_of_an_enclosing_statement: { code: 1116, category: ts.DiagnosticCategory.Error, key: "A_break_statement_can_only_jump_to_a_label_of_an_enclosing_statement_1116", message: "A 'break' statement can only jump to a label of an enclosing statement." }, + An_object_literal_cannot_have_multiple_properties_with_the_same_name_in_strict_mode: { code: 1117, category: ts.DiagnosticCategory.Error, key: "An_object_literal_cannot_have_multiple_properties_with_the_same_name_in_strict_mode_1117", message: "An object literal cannot have multiple properties with the same name in strict mode." }, + An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name: { code: 1118, category: ts.DiagnosticCategory.Error, key: "An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name_1118", message: "An object literal cannot have multiple get/set accessors with the same name." }, + An_object_literal_cannot_have_property_and_accessor_with_the_same_name: { code: 1119, category: ts.DiagnosticCategory.Error, key: "An_object_literal_cannot_have_property_and_accessor_with_the_same_name_1119", message: "An object literal cannot have property and accessor with the same name." }, + An_export_assignment_cannot_have_modifiers: { code: 1120, category: ts.DiagnosticCategory.Error, key: "An_export_assignment_cannot_have_modifiers_1120", message: "An export assignment cannot have modifiers." }, + Octal_literals_are_not_allowed_in_strict_mode: { code: 1121, category: ts.DiagnosticCategory.Error, key: "Octal_literals_are_not_allowed_in_strict_mode_1121", message: "Octal literals are not allowed in strict mode." }, + A_tuple_type_element_list_cannot_be_empty: { code: 1122, category: ts.DiagnosticCategory.Error, key: "A_tuple_type_element_list_cannot_be_empty_1122", message: "A tuple type element list cannot be empty." }, + Variable_declaration_list_cannot_be_empty: { code: 1123, category: ts.DiagnosticCategory.Error, key: "Variable_declaration_list_cannot_be_empty_1123", message: "Variable declaration list cannot be empty." }, + Digit_expected: { code: 1124, category: ts.DiagnosticCategory.Error, key: "Digit_expected_1124", message: "Digit expected." }, + Hexadecimal_digit_expected: { code: 1125, category: ts.DiagnosticCategory.Error, key: "Hexadecimal_digit_expected_1125", message: "Hexadecimal digit expected." }, + Unexpected_end_of_text: { code: 1126, category: ts.DiagnosticCategory.Error, key: "Unexpected_end_of_text_1126", message: "Unexpected end of text." }, + Invalid_character: { code: 1127, category: ts.DiagnosticCategory.Error, key: "Invalid_character_1127", message: "Invalid character." }, + Declaration_or_statement_expected: { code: 1128, category: ts.DiagnosticCategory.Error, key: "Declaration_or_statement_expected_1128", message: "Declaration or statement expected." }, + Statement_expected: { code: 1129, category: ts.DiagnosticCategory.Error, key: "Statement_expected_1129", message: "Statement expected." }, + case_or_default_expected: { code: 1130, category: ts.DiagnosticCategory.Error, key: "case_or_default_expected_1130", message: "'case' or 'default' expected." }, + Property_or_signature_expected: { code: 1131, category: ts.DiagnosticCategory.Error, key: "Property_or_signature_expected_1131", message: "Property or signature expected." }, + Enum_member_expected: { code: 1132, category: ts.DiagnosticCategory.Error, key: "Enum_member_expected_1132", message: "Enum member expected." }, + Variable_declaration_expected: { code: 1134, category: ts.DiagnosticCategory.Error, key: "Variable_declaration_expected_1134", message: "Variable declaration expected." }, + Argument_expression_expected: { code: 1135, category: ts.DiagnosticCategory.Error, key: "Argument_expression_expected_1135", message: "Argument expression expected." }, + Property_assignment_expected: { code: 1136, category: ts.DiagnosticCategory.Error, key: "Property_assignment_expected_1136", message: "Property assignment expected." }, + Expression_or_comma_expected: { code: 1137, category: ts.DiagnosticCategory.Error, key: "Expression_or_comma_expected_1137", message: "Expression or comma expected." }, + Parameter_declaration_expected: { code: 1138, category: ts.DiagnosticCategory.Error, key: "Parameter_declaration_expected_1138", message: "Parameter declaration expected." }, + Type_parameter_declaration_expected: { code: 1139, category: ts.DiagnosticCategory.Error, key: "Type_parameter_declaration_expected_1139", message: "Type parameter declaration expected." }, + Type_argument_expected: { code: 1140, category: ts.DiagnosticCategory.Error, key: "Type_argument_expected_1140", message: "Type argument expected." }, + String_literal_expected: { code: 1141, category: ts.DiagnosticCategory.Error, key: "String_literal_expected_1141", message: "String literal expected." }, + Line_break_not_permitted_here: { code: 1142, category: ts.DiagnosticCategory.Error, key: "Line_break_not_permitted_here_1142", message: "Line break not permitted here." }, + or_expected: { code: 1144, category: ts.DiagnosticCategory.Error, key: "or_expected_1144", message: "'{' or ';' expected." }, + Modifiers_not_permitted_on_index_signature_members: { code: 1145, category: ts.DiagnosticCategory.Error, key: "Modifiers_not_permitted_on_index_signature_members_1145", message: "Modifiers not permitted on index signature members." }, + Declaration_expected: { code: 1146, category: ts.DiagnosticCategory.Error, key: "Declaration_expected_1146", message: "Declaration expected." }, + Import_declarations_in_a_namespace_cannot_reference_a_module: { code: 1147, category: ts.DiagnosticCategory.Error, key: "Import_declarations_in_a_namespace_cannot_reference_a_module_1147", message: "Import declarations in a namespace cannot reference a module." }, + Cannot_compile_modules_unless_the_module_flag_is_provided: { code: 1148, category: ts.DiagnosticCategory.Error, key: "Cannot_compile_modules_unless_the_module_flag_is_provided_1148", message: "Cannot compile modules unless the '--module' flag is provided." }, + File_name_0_differs_from_already_included_file_name_1_only_in_casing: { code: 1149, category: ts.DiagnosticCategory.Error, key: "File_name_0_differs_from_already_included_file_name_1_only_in_casing_1149", message: "File name '{0}' differs from already included file name '{1}' only in casing" }, + new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead: { code: 1150, category: ts.DiagnosticCategory.Error, key: "new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead_1150", message: "'new T[]' cannot be used to create an array. Use 'new Array()' instead." }, + const_declarations_must_be_initialized: { code: 1155, category: ts.DiagnosticCategory.Error, key: "const_declarations_must_be_initialized_1155", message: "'const' declarations must be initialized" }, + const_declarations_can_only_be_declared_inside_a_block: { code: 1156, category: ts.DiagnosticCategory.Error, key: "const_declarations_can_only_be_declared_inside_a_block_1156", message: "'const' declarations can only be declared inside a block." }, + let_declarations_can_only_be_declared_inside_a_block: { code: 1157, category: ts.DiagnosticCategory.Error, key: "let_declarations_can_only_be_declared_inside_a_block_1157", message: "'let' declarations can only be declared inside a block." }, + Unterminated_template_literal: { code: 1160, category: ts.DiagnosticCategory.Error, key: "Unterminated_template_literal_1160", message: "Unterminated template literal." }, + Unterminated_regular_expression_literal: { code: 1161, category: ts.DiagnosticCategory.Error, key: "Unterminated_regular_expression_literal_1161", message: "Unterminated regular expression literal." }, + An_object_member_cannot_be_declared_optional: { code: 1162, category: ts.DiagnosticCategory.Error, key: "An_object_member_cannot_be_declared_optional_1162", message: "An object member cannot be declared optional." }, + A_yield_expression_is_only_allowed_in_a_generator_body: { code: 1163, category: ts.DiagnosticCategory.Error, key: "A_yield_expression_is_only_allowed_in_a_generator_body_1163", message: "A 'yield' expression is only allowed in a generator body." }, + Computed_property_names_are_not_allowed_in_enums: { code: 1164, category: ts.DiagnosticCategory.Error, key: "Computed_property_names_are_not_allowed_in_enums_1164", message: "Computed property names are not allowed in enums." }, + A_computed_property_name_in_an_ambient_context_must_directly_refer_to_a_built_in_symbol: { code: 1165, category: ts.DiagnosticCategory.Error, key: "A_computed_property_name_in_an_ambient_context_must_directly_refer_to_a_built_in_symbol_1165", message: "A computed property name in an ambient context must directly refer to a built-in symbol." }, + A_computed_property_name_in_a_class_property_declaration_must_directly_refer_to_a_built_in_symbol: { code: 1166, category: ts.DiagnosticCategory.Error, key: "A_computed_property_name_in_a_class_property_declaration_must_directly_refer_to_a_built_in_symbol_1166", message: "A computed property name in a class property declaration must directly refer to a built-in symbol." }, + A_computed_property_name_in_a_method_overload_must_directly_refer_to_a_built_in_symbol: { code: 1168, category: ts.DiagnosticCategory.Error, key: "A_computed_property_name_in_a_method_overload_must_directly_refer_to_a_built_in_symbol_1168", message: "A computed property name in a method overload must directly refer to a built-in symbol." }, + A_computed_property_name_in_an_interface_must_directly_refer_to_a_built_in_symbol: { code: 1169, category: ts.DiagnosticCategory.Error, key: "A_computed_property_name_in_an_interface_must_directly_refer_to_a_built_in_symbol_1169", message: "A computed property name in an interface must directly refer to a built-in symbol." }, + A_computed_property_name_in_a_type_literal_must_directly_refer_to_a_built_in_symbol: { code: 1170, category: ts.DiagnosticCategory.Error, key: "A_computed_property_name_in_a_type_literal_must_directly_refer_to_a_built_in_symbol_1170", message: "A computed property name in a type literal must directly refer to a built-in symbol." }, + A_comma_expression_is_not_allowed_in_a_computed_property_name: { code: 1171, category: ts.DiagnosticCategory.Error, key: "A_comma_expression_is_not_allowed_in_a_computed_property_name_1171", message: "A comma expression is not allowed in a computed property name." }, + extends_clause_already_seen: { code: 1172, category: ts.DiagnosticCategory.Error, key: "extends_clause_already_seen_1172", message: "'extends' clause already seen." }, + extends_clause_must_precede_implements_clause: { code: 1173, category: ts.DiagnosticCategory.Error, key: "extends_clause_must_precede_implements_clause_1173", message: "'extends' clause must precede 'implements' clause." }, + Classes_can_only_extend_a_single_class: { code: 1174, category: ts.DiagnosticCategory.Error, key: "Classes_can_only_extend_a_single_class_1174", message: "Classes can only extend a single class." }, + implements_clause_already_seen: { code: 1175, category: ts.DiagnosticCategory.Error, key: "implements_clause_already_seen_1175", message: "'implements' clause already seen." }, + Interface_declaration_cannot_have_implements_clause: { code: 1176, category: ts.DiagnosticCategory.Error, key: "Interface_declaration_cannot_have_implements_clause_1176", message: "Interface declaration cannot have 'implements' clause." }, + Binary_digit_expected: { code: 1177, category: ts.DiagnosticCategory.Error, key: "Binary_digit_expected_1177", message: "Binary digit expected." }, + Octal_digit_expected: { code: 1178, category: ts.DiagnosticCategory.Error, key: "Octal_digit_expected_1178", message: "Octal digit expected." }, + Unexpected_token_expected: { code: 1179, category: ts.DiagnosticCategory.Error, key: "Unexpected_token_expected_1179", message: "Unexpected token. '{' expected." }, + Property_destructuring_pattern_expected: { code: 1180, category: ts.DiagnosticCategory.Error, key: "Property_destructuring_pattern_expected_1180", message: "Property destructuring pattern expected." }, + Array_element_destructuring_pattern_expected: { code: 1181, category: ts.DiagnosticCategory.Error, key: "Array_element_destructuring_pattern_expected_1181", message: "Array element destructuring pattern expected." }, + A_destructuring_declaration_must_have_an_initializer: { code: 1182, category: ts.DiagnosticCategory.Error, key: "A_destructuring_declaration_must_have_an_initializer_1182", message: "A destructuring declaration must have an initializer." }, + An_implementation_cannot_be_declared_in_ambient_contexts: { code: 1183, category: ts.DiagnosticCategory.Error, key: "An_implementation_cannot_be_declared_in_ambient_contexts_1183", message: "An implementation cannot be declared in ambient contexts." }, + Modifiers_cannot_appear_here: { code: 1184, category: ts.DiagnosticCategory.Error, key: "Modifiers_cannot_appear_here_1184", message: "Modifiers cannot appear here." }, + Merge_conflict_marker_encountered: { code: 1185, category: ts.DiagnosticCategory.Error, key: "Merge_conflict_marker_encountered_1185", message: "Merge conflict marker encountered." }, + A_rest_element_cannot_have_an_initializer: { code: 1186, category: ts.DiagnosticCategory.Error, key: "A_rest_element_cannot_have_an_initializer_1186", message: "A rest element cannot have an initializer." }, + A_parameter_property_may_not_be_a_binding_pattern: { code: 1187, category: ts.DiagnosticCategory.Error, key: "A_parameter_property_may_not_be_a_binding_pattern_1187", message: "A parameter property may not be a binding pattern." }, + Only_a_single_variable_declaration_is_allowed_in_a_for_of_statement: { code: 1188, category: ts.DiagnosticCategory.Error, key: "Only_a_single_variable_declaration_is_allowed_in_a_for_of_statement_1188", message: "Only a single variable declaration is allowed in a 'for...of' statement." }, + The_variable_declaration_of_a_for_in_statement_cannot_have_an_initializer: { code: 1189, category: ts.DiagnosticCategory.Error, key: "The_variable_declaration_of_a_for_in_statement_cannot_have_an_initializer_1189", message: "The variable declaration of a 'for...in' statement cannot have an initializer." }, + The_variable_declaration_of_a_for_of_statement_cannot_have_an_initializer: { code: 1190, category: ts.DiagnosticCategory.Error, key: "The_variable_declaration_of_a_for_of_statement_cannot_have_an_initializer_1190", message: "The variable declaration of a 'for...of' statement cannot have an initializer." }, + An_import_declaration_cannot_have_modifiers: { code: 1191, category: ts.DiagnosticCategory.Error, key: "An_import_declaration_cannot_have_modifiers_1191", message: "An import declaration cannot have modifiers." }, + Module_0_has_no_default_export: { code: 1192, category: ts.DiagnosticCategory.Error, key: "Module_0_has_no_default_export_1192", message: "Module '{0}' has no default export." }, + An_export_declaration_cannot_have_modifiers: { code: 1193, category: ts.DiagnosticCategory.Error, key: "An_export_declaration_cannot_have_modifiers_1193", message: "An export declaration cannot have modifiers." }, + Export_declarations_are_not_permitted_in_a_namespace: { code: 1194, category: ts.DiagnosticCategory.Error, key: "Export_declarations_are_not_permitted_in_a_namespace_1194", message: "Export declarations are not permitted in a namespace." }, + Catch_clause_variable_name_must_be_an_identifier: { code: 1195, category: ts.DiagnosticCategory.Error, key: "Catch_clause_variable_name_must_be_an_identifier_1195", message: "Catch clause variable name must be an identifier." }, + Catch_clause_variable_cannot_have_a_type_annotation: { code: 1196, category: ts.DiagnosticCategory.Error, key: "Catch_clause_variable_cannot_have_a_type_annotation_1196", message: "Catch clause variable cannot have a type annotation." }, + Catch_clause_variable_cannot_have_an_initializer: { code: 1197, category: ts.DiagnosticCategory.Error, key: "Catch_clause_variable_cannot_have_an_initializer_1197", message: "Catch clause variable cannot have an initializer." }, + An_extended_Unicode_escape_value_must_be_between_0x0_and_0x10FFFF_inclusive: { code: 1198, category: ts.DiagnosticCategory.Error, key: "An_extended_Unicode_escape_value_must_be_between_0x0_and_0x10FFFF_inclusive_1198", message: "An extended Unicode escape value must be between 0x0 and 0x10FFFF inclusive." }, + Unterminated_Unicode_escape_sequence: { code: 1199, category: ts.DiagnosticCategory.Error, key: "Unterminated_Unicode_escape_sequence_1199", message: "Unterminated Unicode escape sequence." }, + Line_terminator_not_permitted_before_arrow: { code: 1200, category: ts.DiagnosticCategory.Error, key: "Line_terminator_not_permitted_before_arrow_1200", message: "Line terminator not permitted before arrow." }, + Import_assignment_cannot_be_used_when_targeting_ECMAScript_6_modules_Consider_using_import_Asterisk_as_ns_from_mod_import_a_from_mod_import_d_from_mod_or_another_module_format_instead: { code: 1202, category: ts.DiagnosticCategory.Error, key: "Import_assignment_cannot_be_used_when_targeting_ECMAScript_6_modules_Consider_using_import_Asterisk__1202", message: "Import assignment cannot be used when targeting ECMAScript 6 modules. Consider using 'import * as ns from \"mod\"', 'import {a} from \"mod\"', 'import d from \"mod\"', or another module format instead." }, + Export_assignment_cannot_be_used_when_targeting_ECMAScript_6_modules_Consider_using_export_default_or_another_module_format_instead: { code: 1203, category: ts.DiagnosticCategory.Error, key: "Export_assignment_cannot_be_used_when_targeting_ECMAScript_6_modules_Consider_using_export_default_o_1203", message: "Export assignment cannot be used when targeting ECMAScript 6 modules. Consider using 'export default' or another module format instead." }, + Cannot_compile_modules_into_es2015_when_targeting_ES5_or_lower: { code: 1204, category: ts.DiagnosticCategory.Error, key: "Cannot_compile_modules_into_es2015_when_targeting_ES5_or_lower_1204", message: "Cannot compile modules into 'es2015' when targeting 'ES5' or lower." }, + Decorators_are_not_valid_here: { code: 1206, category: ts.DiagnosticCategory.Error, key: "Decorators_are_not_valid_here_1206", message: "Decorators are not valid here." }, + Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name: { code: 1207, category: ts.DiagnosticCategory.Error, key: "Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name_1207", message: "Decorators cannot be applied to multiple get/set accessors of the same name." }, + Cannot_compile_namespaces_when_the_isolatedModules_flag_is_provided: { code: 1208, category: ts.DiagnosticCategory.Error, key: "Cannot_compile_namespaces_when_the_isolatedModules_flag_is_provided_1208", message: "Cannot compile namespaces when the '--isolatedModules' flag is provided." }, + Ambient_const_enums_are_not_allowed_when_the_isolatedModules_flag_is_provided: { code: 1209, category: ts.DiagnosticCategory.Error, key: "Ambient_const_enums_are_not_allowed_when_the_isolatedModules_flag_is_provided_1209", message: "Ambient const enums are not allowed when the '--isolatedModules' flag is provided." }, + Invalid_use_of_0_Class_definitions_are_automatically_in_strict_mode: { code: 1210, category: ts.DiagnosticCategory.Error, key: "Invalid_use_of_0_Class_definitions_are_automatically_in_strict_mode_1210", message: "Invalid use of '{0}'. Class definitions are automatically in strict mode." }, + A_class_declaration_without_the_default_modifier_must_have_a_name: { code: 1211, category: ts.DiagnosticCategory.Error, key: "A_class_declaration_without_the_default_modifier_must_have_a_name_1211", message: "A class declaration without the 'default' modifier must have a name" }, + Identifier_expected_0_is_a_reserved_word_in_strict_mode: { code: 1212, category: ts.DiagnosticCategory.Error, key: "Identifier_expected_0_is_a_reserved_word_in_strict_mode_1212", message: "Identifier expected. '{0}' is a reserved word in strict mode" }, + Identifier_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_strict_mode: { code: 1213, category: ts.DiagnosticCategory.Error, key: "Identifier_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_stric_1213", message: "Identifier expected. '{0}' is a reserved word in strict mode. Class definitions are automatically in strict mode." }, + Identifier_expected_0_is_a_reserved_word_in_strict_mode_Modules_are_automatically_in_strict_mode: { code: 1214, category: ts.DiagnosticCategory.Error, key: "Identifier_expected_0_is_a_reserved_word_in_strict_mode_Modules_are_automatically_in_strict_mode_1214", message: "Identifier expected. '{0}' is a reserved word in strict mode. Modules are automatically in strict mode." }, + Invalid_use_of_0_Modules_are_automatically_in_strict_mode: { code: 1215, category: ts.DiagnosticCategory.Error, key: "Invalid_use_of_0_Modules_are_automatically_in_strict_mode_1215", message: "Invalid use of '{0}'. Modules are automatically in strict mode." }, + Export_assignment_is_not_supported_when_module_flag_is_system: { code: 1218, category: ts.DiagnosticCategory.Error, key: "Export_assignment_is_not_supported_when_module_flag_is_system_1218", message: "Export assignment is not supported when '--module' flag is 'system'." }, + Experimental_support_for_decorators_is_a_feature_that_is_subject_to_change_in_a_future_release_Specify_experimentalDecorators_to_remove_this_warning: { code: 1219, category: ts.DiagnosticCategory.Error, key: "Experimental_support_for_decorators_is_a_feature_that_is_subject_to_change_in_a_future_release_Speci_1219", message: "Experimental support for decorators is a feature that is subject to change in a future release. Specify '--experimentalDecorators' to remove this warning." }, + Generators_are_only_available_when_targeting_ECMAScript_6_or_higher: { code: 1220, category: ts.DiagnosticCategory.Error, key: "Generators_are_only_available_when_targeting_ECMAScript_6_or_higher_1220", message: "Generators are only available when targeting ECMAScript 6 or higher." }, + Generators_are_not_allowed_in_an_ambient_context: { code: 1221, category: ts.DiagnosticCategory.Error, key: "Generators_are_not_allowed_in_an_ambient_context_1221", message: "Generators are not allowed in an ambient context." }, + An_overload_signature_cannot_be_declared_as_a_generator: { code: 1222, category: ts.DiagnosticCategory.Error, key: "An_overload_signature_cannot_be_declared_as_a_generator_1222", message: "An overload signature cannot be declared as a generator." }, + _0_tag_already_specified: { code: 1223, category: ts.DiagnosticCategory.Error, key: "_0_tag_already_specified_1223", message: "'{0}' tag already specified." }, + Signature_0_must_have_a_type_predicate: { code: 1224, category: ts.DiagnosticCategory.Error, key: "Signature_0_must_have_a_type_predicate_1224", message: "Signature '{0}' must have a type predicate." }, + Cannot_find_parameter_0: { code: 1225, category: ts.DiagnosticCategory.Error, key: "Cannot_find_parameter_0_1225", message: "Cannot find parameter '{0}'." }, + Type_predicate_0_is_not_assignable_to_1: { code: 1226, category: ts.DiagnosticCategory.Error, key: "Type_predicate_0_is_not_assignable_to_1_1226", message: "Type predicate '{0}' is not assignable to '{1}'." }, + Parameter_0_is_not_in_the_same_position_as_parameter_1: { code: 1227, category: ts.DiagnosticCategory.Error, key: "Parameter_0_is_not_in_the_same_position_as_parameter_1_1227", message: "Parameter '{0}' is not in the same position as parameter '{1}'." }, + A_type_predicate_is_only_allowed_in_return_type_position_for_functions_and_methods: { code: 1228, category: ts.DiagnosticCategory.Error, key: "A_type_predicate_is_only_allowed_in_return_type_position_for_functions_and_methods_1228", message: "A type predicate is only allowed in return type position for functions and methods." }, + A_type_predicate_cannot_reference_a_rest_parameter: { code: 1229, category: ts.DiagnosticCategory.Error, key: "A_type_predicate_cannot_reference_a_rest_parameter_1229", message: "A type predicate cannot reference a rest parameter." }, + A_type_predicate_cannot_reference_element_0_in_a_binding_pattern: { code: 1230, category: ts.DiagnosticCategory.Error, key: "A_type_predicate_cannot_reference_element_0_in_a_binding_pattern_1230", message: "A type predicate cannot reference element '{0}' in a binding pattern." }, + An_export_assignment_can_only_be_used_in_a_module: { code: 1231, category: ts.DiagnosticCategory.Error, key: "An_export_assignment_can_only_be_used_in_a_module_1231", message: "An export assignment can only be used in a module." }, + An_import_declaration_can_only_be_used_in_a_namespace_or_module: { code: 1232, category: ts.DiagnosticCategory.Error, key: "An_import_declaration_can_only_be_used_in_a_namespace_or_module_1232", message: "An import declaration can only be used in a namespace or module." }, + An_export_declaration_can_only_be_used_in_a_module: { code: 1233, category: ts.DiagnosticCategory.Error, key: "An_export_declaration_can_only_be_used_in_a_module_1233", message: "An export declaration can only be used in a module." }, + An_ambient_module_declaration_is_only_allowed_at_the_top_level_in_a_file: { code: 1234, category: ts.DiagnosticCategory.Error, key: "An_ambient_module_declaration_is_only_allowed_at_the_top_level_in_a_file_1234", message: "An ambient module declaration is only allowed at the top level in a file." }, + A_namespace_declaration_is_only_allowed_in_a_namespace_or_module: { code: 1235, category: ts.DiagnosticCategory.Error, key: "A_namespace_declaration_is_only_allowed_in_a_namespace_or_module_1235", message: "A namespace declaration is only allowed in a namespace or module." }, + The_return_type_of_a_property_decorator_function_must_be_either_void_or_any: { code: 1236, category: ts.DiagnosticCategory.Error, key: "The_return_type_of_a_property_decorator_function_must_be_either_void_or_any_1236", message: "The return type of a property decorator function must be either 'void' or 'any'." }, + The_return_type_of_a_parameter_decorator_function_must_be_either_void_or_any: { code: 1237, category: ts.DiagnosticCategory.Error, key: "The_return_type_of_a_parameter_decorator_function_must_be_either_void_or_any_1237", message: "The return type of a parameter decorator function must be either 'void' or 'any'." }, + Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression: { code: 1238, category: ts.DiagnosticCategory.Error, key: "Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression_1238", message: "Unable to resolve signature of class decorator when called as an expression." }, + Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression: { code: 1239, category: ts.DiagnosticCategory.Error, key: "Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression_1239", message: "Unable to resolve signature of parameter decorator when called as an expression." }, + Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression: { code: 1240, category: ts.DiagnosticCategory.Error, key: "Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression_1240", message: "Unable to resolve signature of property decorator when called as an expression." }, + Unable_to_resolve_signature_of_method_decorator_when_called_as_an_expression: { code: 1241, category: ts.DiagnosticCategory.Error, key: "Unable_to_resolve_signature_of_method_decorator_when_called_as_an_expression_1241", message: "Unable to resolve signature of method decorator when called as an expression." }, + abstract_modifier_can_only_appear_on_a_class_or_method_declaration: { code: 1242, category: ts.DiagnosticCategory.Error, key: "abstract_modifier_can_only_appear_on_a_class_or_method_declaration_1242", message: "'abstract' modifier can only appear on a class or method declaration." }, + _0_modifier_cannot_be_used_with_1_modifier: { code: 1243, category: ts.DiagnosticCategory.Error, key: "_0_modifier_cannot_be_used_with_1_modifier_1243", message: "'{0}' modifier cannot be used with '{1}' modifier." }, + Abstract_methods_can_only_appear_within_an_abstract_class: { code: 1244, category: ts.DiagnosticCategory.Error, key: "Abstract_methods_can_only_appear_within_an_abstract_class_1244", message: "Abstract methods can only appear within an abstract class." }, + Method_0_cannot_have_an_implementation_because_it_is_marked_abstract: { code: 1245, category: ts.DiagnosticCategory.Error, key: "Method_0_cannot_have_an_implementation_because_it_is_marked_abstract_1245", message: "Method '{0}' cannot have an implementation because it is marked abstract." }, + with_statements_are_not_allowed_in_an_async_function_block: { code: 1300, category: ts.DiagnosticCategory.Error, key: "with_statements_are_not_allowed_in_an_async_function_block_1300", message: "'with' statements are not allowed in an async function block." }, + await_expression_is_only_allowed_within_an_async_function: { code: 1308, category: ts.DiagnosticCategory.Error, key: "await_expression_is_only_allowed_within_an_async_function_1308", message: "'await' expression is only allowed within an async function." }, + Async_functions_are_only_available_when_targeting_ECMAScript_6_and_higher: { code: 1311, category: ts.DiagnosticCategory.Error, key: "Async_functions_are_only_available_when_targeting_ECMAScript_6_and_higher_1311", message: "Async functions are only available when targeting ECMAScript 6 and higher." }, + can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment: { code: 1312, category: ts.DiagnosticCategory.Error, key: "can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment_1312", message: "'=' can only be used in an object literal property inside a destructuring assignment." }, + Duplicate_identifier_0: { code: 2300, category: ts.DiagnosticCategory.Error, key: "Duplicate_identifier_0_2300", message: "Duplicate identifier '{0}'." }, + Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor: { code: 2301, category: ts.DiagnosticCategory.Error, key: "Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor_2301", message: "Initializer of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor." }, + Static_members_cannot_reference_class_type_parameters: { code: 2302, category: ts.DiagnosticCategory.Error, key: "Static_members_cannot_reference_class_type_parameters_2302", message: "Static members cannot reference class type parameters." }, + Circular_definition_of_import_alias_0: { code: 2303, category: ts.DiagnosticCategory.Error, key: "Circular_definition_of_import_alias_0_2303", message: "Circular definition of import alias '{0}'." }, + Cannot_find_name_0: { code: 2304, category: ts.DiagnosticCategory.Error, key: "Cannot_find_name_0_2304", message: "Cannot find name '{0}'." }, + Module_0_has_no_exported_member_1: { code: 2305, category: ts.DiagnosticCategory.Error, key: "Module_0_has_no_exported_member_1_2305", message: "Module '{0}' has no exported member '{1}'." }, + File_0_is_not_a_module: { code: 2306, category: ts.DiagnosticCategory.Error, key: "File_0_is_not_a_module_2306", message: "File '{0}' is not a module." }, + Cannot_find_module_0: { code: 2307, category: ts.DiagnosticCategory.Error, key: "Cannot_find_module_0_2307", message: "Cannot find module '{0}'." }, + An_export_assignment_cannot_be_used_in_a_module_with_other_exported_elements: { code: 2309, category: ts.DiagnosticCategory.Error, key: "An_export_assignment_cannot_be_used_in_a_module_with_other_exported_elements_2309", message: "An export assignment cannot be used in a module with other exported elements." }, + Type_0_recursively_references_itself_as_a_base_type: { code: 2310, category: ts.DiagnosticCategory.Error, key: "Type_0_recursively_references_itself_as_a_base_type_2310", message: "Type '{0}' recursively references itself as a base type." }, + A_class_may_only_extend_another_class: { code: 2311, category: ts.DiagnosticCategory.Error, key: "A_class_may_only_extend_another_class_2311", message: "A class may only extend another class." }, + An_interface_may_only_extend_a_class_or_another_interface: { code: 2312, category: ts.DiagnosticCategory.Error, key: "An_interface_may_only_extend_a_class_or_another_interface_2312", message: "An interface may only extend a class or another interface." }, + Constraint_of_a_type_parameter_cannot_reference_any_type_parameter_from_the_same_type_parameter_list: { code: 2313, category: ts.DiagnosticCategory.Error, key: "Constraint_of_a_type_parameter_cannot_reference_any_type_parameter_from_the_same_type_parameter_list_2313", message: "Constraint of a type parameter cannot reference any type parameter from the same type parameter list." }, + Generic_type_0_requires_1_type_argument_s: { code: 2314, category: ts.DiagnosticCategory.Error, key: "Generic_type_0_requires_1_type_argument_s_2314", message: "Generic type '{0}' requires {1} type argument(s)." }, + Type_0_is_not_generic: { code: 2315, category: ts.DiagnosticCategory.Error, key: "Type_0_is_not_generic_2315", message: "Type '{0}' is not generic." }, + Global_type_0_must_be_a_class_or_interface_type: { code: 2316, category: ts.DiagnosticCategory.Error, key: "Global_type_0_must_be_a_class_or_interface_type_2316", message: "Global type '{0}' must be a class or interface type." }, + Global_type_0_must_have_1_type_parameter_s: { code: 2317, category: ts.DiagnosticCategory.Error, key: "Global_type_0_must_have_1_type_parameter_s_2317", message: "Global type '{0}' must have {1} type parameter(s)." }, + Cannot_find_global_type_0: { code: 2318, category: ts.DiagnosticCategory.Error, key: "Cannot_find_global_type_0_2318", message: "Cannot find global type '{0}'." }, + Named_property_0_of_types_1_and_2_are_not_identical: { code: 2319, category: ts.DiagnosticCategory.Error, key: "Named_property_0_of_types_1_and_2_are_not_identical_2319", message: "Named property '{0}' of types '{1}' and '{2}' are not identical." }, + Interface_0_cannot_simultaneously_extend_types_1_and_2: { code: 2320, category: ts.DiagnosticCategory.Error, key: "Interface_0_cannot_simultaneously_extend_types_1_and_2_2320", message: "Interface '{0}' cannot simultaneously extend types '{1}' and '{2}'." }, + Excessive_stack_depth_comparing_types_0_and_1: { code: 2321, category: ts.DiagnosticCategory.Error, key: "Excessive_stack_depth_comparing_types_0_and_1_2321", message: "Excessive stack depth comparing types '{0}' and '{1}'." }, + Type_0_is_not_assignable_to_type_1: { code: 2322, category: ts.DiagnosticCategory.Error, key: "Type_0_is_not_assignable_to_type_1_2322", message: "Type '{0}' is not assignable to type '{1}'." }, + Property_0_is_missing_in_type_1: { code: 2324, category: ts.DiagnosticCategory.Error, key: "Property_0_is_missing_in_type_1_2324", message: "Property '{0}' is missing in type '{1}'." }, + Property_0_is_private_in_type_1_but_not_in_type_2: { code: 2325, category: ts.DiagnosticCategory.Error, key: "Property_0_is_private_in_type_1_but_not_in_type_2_2325", message: "Property '{0}' is private in type '{1}' but not in type '{2}'." }, + Types_of_property_0_are_incompatible: { code: 2326, category: ts.DiagnosticCategory.Error, key: "Types_of_property_0_are_incompatible_2326", message: "Types of property '{0}' are incompatible." }, + Property_0_is_optional_in_type_1_but_required_in_type_2: { code: 2327, category: ts.DiagnosticCategory.Error, key: "Property_0_is_optional_in_type_1_but_required_in_type_2_2327", message: "Property '{0}' is optional in type '{1}' but required in type '{2}'." }, + Types_of_parameters_0_and_1_are_incompatible: { code: 2328, category: ts.DiagnosticCategory.Error, key: "Types_of_parameters_0_and_1_are_incompatible_2328", message: "Types of parameters '{0}' and '{1}' are incompatible." }, + Index_signature_is_missing_in_type_0: { code: 2329, category: ts.DiagnosticCategory.Error, key: "Index_signature_is_missing_in_type_0_2329", message: "Index signature is missing in type '{0}'." }, + Index_signatures_are_incompatible: { code: 2330, category: ts.DiagnosticCategory.Error, key: "Index_signatures_are_incompatible_2330", message: "Index signatures are incompatible." }, + this_cannot_be_referenced_in_a_module_or_namespace_body: { code: 2331, category: ts.DiagnosticCategory.Error, key: "this_cannot_be_referenced_in_a_module_or_namespace_body_2331", message: "'this' cannot be referenced in a module or namespace body." }, + this_cannot_be_referenced_in_current_location: { code: 2332, category: ts.DiagnosticCategory.Error, key: "this_cannot_be_referenced_in_current_location_2332", message: "'this' cannot be referenced in current location." }, + this_cannot_be_referenced_in_constructor_arguments: { code: 2333, category: ts.DiagnosticCategory.Error, key: "this_cannot_be_referenced_in_constructor_arguments_2333", message: "'this' cannot be referenced in constructor arguments." }, + this_cannot_be_referenced_in_a_static_property_initializer: { code: 2334, category: ts.DiagnosticCategory.Error, key: "this_cannot_be_referenced_in_a_static_property_initializer_2334", message: "'this' cannot be referenced in a static property initializer." }, + super_can_only_be_referenced_in_a_derived_class: { code: 2335, category: ts.DiagnosticCategory.Error, key: "super_can_only_be_referenced_in_a_derived_class_2335", message: "'super' can only be referenced in a derived class." }, + super_cannot_be_referenced_in_constructor_arguments: { code: 2336, category: ts.DiagnosticCategory.Error, key: "super_cannot_be_referenced_in_constructor_arguments_2336", message: "'super' cannot be referenced in constructor arguments." }, + Super_calls_are_not_permitted_outside_constructors_or_in_nested_functions_inside_constructors: { code: 2337, category: ts.DiagnosticCategory.Error, key: "Super_calls_are_not_permitted_outside_constructors_or_in_nested_functions_inside_constructors_2337", message: "Super calls are not permitted outside constructors or in nested functions inside constructors." }, + super_property_access_is_permitted_only_in_a_constructor_member_function_or_member_accessor_of_a_derived_class: { code: 2338, category: ts.DiagnosticCategory.Error, key: "super_property_access_is_permitted_only_in_a_constructor_member_function_or_member_accessor_of_a_der_2338", message: "'super' property access is permitted only in a constructor, member function, or member accessor of a derived class." }, + Property_0_does_not_exist_on_type_1: { code: 2339, category: ts.DiagnosticCategory.Error, key: "Property_0_does_not_exist_on_type_1_2339", message: "Property '{0}' does not exist on type '{1}'." }, + Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword: { code: 2340, category: ts.DiagnosticCategory.Error, key: "Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword_2340", message: "Only public and protected methods of the base class are accessible via the 'super' keyword." }, + Property_0_is_private_and_only_accessible_within_class_1: { code: 2341, category: ts.DiagnosticCategory.Error, key: "Property_0_is_private_and_only_accessible_within_class_1_2341", message: "Property '{0}' is private and only accessible within class '{1}'." }, + An_index_expression_argument_must_be_of_type_string_number_symbol_or_any: { code: 2342, category: ts.DiagnosticCategory.Error, key: "An_index_expression_argument_must_be_of_type_string_number_symbol_or_any_2342", message: "An index expression argument must be of type 'string', 'number', 'symbol', or 'any'." }, + Type_0_does_not_satisfy_the_constraint_1: { code: 2344, category: ts.DiagnosticCategory.Error, key: "Type_0_does_not_satisfy_the_constraint_1_2344", message: "Type '{0}' does not satisfy the constraint '{1}'." }, + Argument_of_type_0_is_not_assignable_to_parameter_of_type_1: { code: 2345, category: ts.DiagnosticCategory.Error, key: "Argument_of_type_0_is_not_assignable_to_parameter_of_type_1_2345", message: "Argument of type '{0}' is not assignable to parameter of type '{1}'." }, + Supplied_parameters_do_not_match_any_signature_of_call_target: { code: 2346, category: ts.DiagnosticCategory.Error, key: "Supplied_parameters_do_not_match_any_signature_of_call_target_2346", message: "Supplied parameters do not match any signature of call target." }, + Untyped_function_calls_may_not_accept_type_arguments: { code: 2347, category: ts.DiagnosticCategory.Error, key: "Untyped_function_calls_may_not_accept_type_arguments_2347", message: "Untyped function calls may not accept type arguments." }, + Value_of_type_0_is_not_callable_Did_you_mean_to_include_new: { code: 2348, category: ts.DiagnosticCategory.Error, key: "Value_of_type_0_is_not_callable_Did_you_mean_to_include_new_2348", message: "Value of type '{0}' is not callable. Did you mean to include 'new'?" }, + Cannot_invoke_an_expression_whose_type_lacks_a_call_signature: { code: 2349, category: ts.DiagnosticCategory.Error, key: "Cannot_invoke_an_expression_whose_type_lacks_a_call_signature_2349", message: "Cannot invoke an expression whose type lacks a call signature." }, + Only_a_void_function_can_be_called_with_the_new_keyword: { code: 2350, category: ts.DiagnosticCategory.Error, key: "Only_a_void_function_can_be_called_with_the_new_keyword_2350", message: "Only a void function can be called with the 'new' keyword." }, + Cannot_use_new_with_an_expression_whose_type_lacks_a_call_or_construct_signature: { code: 2351, category: ts.DiagnosticCategory.Error, key: "Cannot_use_new_with_an_expression_whose_type_lacks_a_call_or_construct_signature_2351", message: "Cannot use 'new' with an expression whose type lacks a call or construct signature." }, + Neither_type_0_nor_type_1_is_assignable_to_the_other: { code: 2352, category: ts.DiagnosticCategory.Error, key: "Neither_type_0_nor_type_1_is_assignable_to_the_other_2352", message: "Neither type '{0}' nor type '{1}' is assignable to the other." }, + Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1: { code: 2353, category: ts.DiagnosticCategory.Error, key: "Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1_2353", message: "Object literal may only specify known properties, and '{0}' does not exist in type '{1}'." }, + No_best_common_type_exists_among_return_expressions: { code: 2354, category: ts.DiagnosticCategory.Error, key: "No_best_common_type_exists_among_return_expressions_2354", message: "No best common type exists among return expressions." }, + A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value_or_consist_of_a_single_throw_statement: { code: 2355, category: ts.DiagnosticCategory.Error, key: "A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value_or_consist_of_a_single_th_2355", message: "A function whose declared type is neither 'void' nor 'any' must return a value or consist of a single 'throw' statement." }, + An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type: { code: 2356, category: ts.DiagnosticCategory.Error, key: "An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type_2356", message: "An arithmetic operand must be of type 'any', 'number' or an enum type." }, + The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_property_or_indexer: { code: 2357, category: ts.DiagnosticCategory.Error, key: "The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_property_or_indexer_2357", message: "The operand of an increment or decrement operator must be a variable, property or indexer." }, + The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_parameter: { code: 2358, category: ts.DiagnosticCategory.Error, key: "The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_paramete_2358", message: "The left-hand side of an 'instanceof' expression must be of type 'any', an object type or a type parameter." }, + The_right_hand_side_of_an_instanceof_expression_must_be_of_type_any_or_of_a_type_assignable_to_the_Function_interface_type: { code: 2359, category: ts.DiagnosticCategory.Error, key: "The_right_hand_side_of_an_instanceof_expression_must_be_of_type_any_or_of_a_type_assignable_to_the_F_2359", message: "The right-hand side of an 'instanceof' expression must be of type 'any' or of a type assignable to the 'Function' interface type." }, + The_left_hand_side_of_an_in_expression_must_be_of_type_any_string_number_or_symbol: { code: 2360, category: ts.DiagnosticCategory.Error, key: "The_left_hand_side_of_an_in_expression_must_be_of_type_any_string_number_or_symbol_2360", message: "The left-hand side of an 'in' expression must be of type 'any', 'string', 'number', or 'symbol'." }, + The_right_hand_side_of_an_in_expression_must_be_of_type_any_an_object_type_or_a_type_parameter: { code: 2361, category: ts.DiagnosticCategory.Error, key: "The_right_hand_side_of_an_in_expression_must_be_of_type_any_an_object_type_or_a_type_parameter_2361", message: "The right-hand side of an 'in' expression must be of type 'any', an object type or a type parameter" }, + The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type: { code: 2362, category: ts.DiagnosticCategory.Error, key: "The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type_2362", message: "The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type." }, + The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type: { code: 2363, category: ts.DiagnosticCategory.Error, key: "The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type_2363", message: "The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type." }, + Invalid_left_hand_side_of_assignment_expression: { code: 2364, category: ts.DiagnosticCategory.Error, key: "Invalid_left_hand_side_of_assignment_expression_2364", message: "Invalid left-hand side of assignment expression." }, + Operator_0_cannot_be_applied_to_types_1_and_2: { code: 2365, category: ts.DiagnosticCategory.Error, key: "Operator_0_cannot_be_applied_to_types_1_and_2_2365", message: "Operator '{0}' cannot be applied to types '{1}' and '{2}'." }, + Type_parameter_name_cannot_be_0: { code: 2368, category: ts.DiagnosticCategory.Error, key: "Type_parameter_name_cannot_be_0_2368", message: "Type parameter name cannot be '{0}'" }, + A_parameter_property_is_only_allowed_in_a_constructor_implementation: { code: 2369, category: ts.DiagnosticCategory.Error, key: "A_parameter_property_is_only_allowed_in_a_constructor_implementation_2369", message: "A parameter property is only allowed in a constructor implementation." }, + A_rest_parameter_must_be_of_an_array_type: { code: 2370, category: ts.DiagnosticCategory.Error, key: "A_rest_parameter_must_be_of_an_array_type_2370", message: "A rest parameter must be of an array type." }, + A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation: { code: 2371, category: ts.DiagnosticCategory.Error, key: "A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation_2371", message: "A parameter initializer is only allowed in a function or constructor implementation." }, + Parameter_0_cannot_be_referenced_in_its_initializer: { code: 2372, category: ts.DiagnosticCategory.Error, key: "Parameter_0_cannot_be_referenced_in_its_initializer_2372", message: "Parameter '{0}' cannot be referenced in its initializer." }, + Initializer_of_parameter_0_cannot_reference_identifier_1_declared_after_it: { code: 2373, category: ts.DiagnosticCategory.Error, key: "Initializer_of_parameter_0_cannot_reference_identifier_1_declared_after_it_2373", message: "Initializer of parameter '{0}' cannot reference identifier '{1}' declared after it." }, + Duplicate_string_index_signature: { code: 2374, category: ts.DiagnosticCategory.Error, key: "Duplicate_string_index_signature_2374", message: "Duplicate string index signature." }, + Duplicate_number_index_signature: { code: 2375, category: ts.DiagnosticCategory.Error, key: "Duplicate_number_index_signature_2375", message: "Duplicate number index signature." }, + A_super_call_must_be_the_first_statement_in_the_constructor_when_a_class_contains_initialized_properties_or_has_parameter_properties: { code: 2376, category: ts.DiagnosticCategory.Error, key: "A_super_call_must_be_the_first_statement_in_the_constructor_when_a_class_contains_initialized_proper_2376", message: "A 'super' call must be the first statement in the constructor when a class contains initialized properties or has parameter properties." }, + Constructors_for_derived_classes_must_contain_a_super_call: { code: 2377, category: ts.DiagnosticCategory.Error, key: "Constructors_for_derived_classes_must_contain_a_super_call_2377", message: "Constructors for derived classes must contain a 'super' call." }, + A_get_accessor_must_return_a_value_or_consist_of_a_single_throw_statement: { code: 2378, category: ts.DiagnosticCategory.Error, key: "A_get_accessor_must_return_a_value_or_consist_of_a_single_throw_statement_2378", message: "A 'get' accessor must return a value or consist of a single 'throw' statement." }, + Getter_and_setter_accessors_do_not_agree_in_visibility: { code: 2379, category: ts.DiagnosticCategory.Error, key: "Getter_and_setter_accessors_do_not_agree_in_visibility_2379", message: "Getter and setter accessors do not agree in visibility." }, + get_and_set_accessor_must_have_the_same_type: { code: 2380, category: ts.DiagnosticCategory.Error, key: "get_and_set_accessor_must_have_the_same_type_2380", message: "'get' and 'set' accessor must have the same type." }, + A_signature_with_an_implementation_cannot_use_a_string_literal_type: { code: 2381, category: ts.DiagnosticCategory.Error, key: "A_signature_with_an_implementation_cannot_use_a_string_literal_type_2381", message: "A signature with an implementation cannot use a string literal type." }, + Specialized_overload_signature_is_not_assignable_to_any_non_specialized_signature: { code: 2382, category: ts.DiagnosticCategory.Error, key: "Specialized_overload_signature_is_not_assignable_to_any_non_specialized_signature_2382", message: "Specialized overload signature is not assignable to any non-specialized signature." }, + Overload_signatures_must_all_be_exported_or_not_exported: { code: 2383, category: ts.DiagnosticCategory.Error, key: "Overload_signatures_must_all_be_exported_or_not_exported_2383", message: "Overload signatures must all be exported or not exported." }, + Overload_signatures_must_all_be_ambient_or_non_ambient: { code: 2384, category: ts.DiagnosticCategory.Error, key: "Overload_signatures_must_all_be_ambient_or_non_ambient_2384", message: "Overload signatures must all be ambient or non-ambient." }, + Overload_signatures_must_all_be_public_private_or_protected: { code: 2385, category: ts.DiagnosticCategory.Error, key: "Overload_signatures_must_all_be_public_private_or_protected_2385", message: "Overload signatures must all be public, private or protected." }, + Overload_signatures_must_all_be_optional_or_required: { code: 2386, category: ts.DiagnosticCategory.Error, key: "Overload_signatures_must_all_be_optional_or_required_2386", message: "Overload signatures must all be optional or required." }, + Function_overload_must_be_static: { code: 2387, category: ts.DiagnosticCategory.Error, key: "Function_overload_must_be_static_2387", message: "Function overload must be static." }, + Function_overload_must_not_be_static: { code: 2388, category: ts.DiagnosticCategory.Error, key: "Function_overload_must_not_be_static_2388", message: "Function overload must not be static." }, + Function_implementation_name_must_be_0: { code: 2389, category: ts.DiagnosticCategory.Error, key: "Function_implementation_name_must_be_0_2389", message: "Function implementation name must be '{0}'." }, + Constructor_implementation_is_missing: { code: 2390, category: ts.DiagnosticCategory.Error, key: "Constructor_implementation_is_missing_2390", message: "Constructor implementation is missing." }, + Function_implementation_is_missing_or_not_immediately_following_the_declaration: { code: 2391, category: ts.DiagnosticCategory.Error, key: "Function_implementation_is_missing_or_not_immediately_following_the_declaration_2391", message: "Function implementation is missing or not immediately following the declaration." }, + Multiple_constructor_implementations_are_not_allowed: { code: 2392, category: ts.DiagnosticCategory.Error, key: "Multiple_constructor_implementations_are_not_allowed_2392", message: "Multiple constructor implementations are not allowed." }, + Duplicate_function_implementation: { code: 2393, category: ts.DiagnosticCategory.Error, key: "Duplicate_function_implementation_2393", message: "Duplicate function implementation." }, + Overload_signature_is_not_compatible_with_function_implementation: { code: 2394, category: ts.DiagnosticCategory.Error, key: "Overload_signature_is_not_compatible_with_function_implementation_2394", message: "Overload signature is not compatible with function implementation." }, + Individual_declarations_in_merged_declaration_0_must_be_all_exported_or_all_local: { code: 2395, category: ts.DiagnosticCategory.Error, key: "Individual_declarations_in_merged_declaration_0_must_be_all_exported_or_all_local_2395", message: "Individual declarations in merged declaration '{0}' must be all exported or all local." }, + Duplicate_identifier_arguments_Compiler_uses_arguments_to_initialize_rest_parameters: { code: 2396, category: ts.DiagnosticCategory.Error, key: "Duplicate_identifier_arguments_Compiler_uses_arguments_to_initialize_rest_parameters_2396", message: "Duplicate identifier 'arguments'. Compiler uses 'arguments' to initialize rest parameters." }, + Duplicate_identifier_this_Compiler_uses_variable_declaration_this_to_capture_this_reference: { code: 2399, category: ts.DiagnosticCategory.Error, key: "Duplicate_identifier_this_Compiler_uses_variable_declaration_this_to_capture_this_reference_2399", message: "Duplicate identifier '_this'. Compiler uses variable declaration '_this' to capture 'this' reference." }, + Expression_resolves_to_variable_declaration_this_that_compiler_uses_to_capture_this_reference: { code: 2400, category: ts.DiagnosticCategory.Error, key: "Expression_resolves_to_variable_declaration_this_that_compiler_uses_to_capture_this_reference_2400", message: "Expression resolves to variable declaration '_this' that compiler uses to capture 'this' reference." }, + Duplicate_identifier_super_Compiler_uses_super_to_capture_base_class_reference: { code: 2401, category: ts.DiagnosticCategory.Error, key: "Duplicate_identifier_super_Compiler_uses_super_to_capture_base_class_reference_2401", message: "Duplicate identifier '_super'. Compiler uses '_super' to capture base class reference." }, + Expression_resolves_to_super_that_compiler_uses_to_capture_base_class_reference: { code: 2402, category: ts.DiagnosticCategory.Error, key: "Expression_resolves_to_super_that_compiler_uses_to_capture_base_class_reference_2402", message: "Expression resolves to '_super' that compiler uses to capture base class reference." }, + Subsequent_variable_declarations_must_have_the_same_type_Variable_0_must_be_of_type_1_but_here_has_type_2: { code: 2403, category: ts.DiagnosticCategory.Error, key: "Subsequent_variable_declarations_must_have_the_same_type_Variable_0_must_be_of_type_1_but_here_has_t_2403", message: "Subsequent variable declarations must have the same type. Variable '{0}' must be of type '{1}', but here has type '{2}'." }, + The_left_hand_side_of_a_for_in_statement_cannot_use_a_type_annotation: { code: 2404, category: ts.DiagnosticCategory.Error, key: "The_left_hand_side_of_a_for_in_statement_cannot_use_a_type_annotation_2404", message: "The left-hand side of a 'for...in' statement cannot use a type annotation." }, + The_left_hand_side_of_a_for_in_statement_must_be_of_type_string_or_any: { code: 2405, category: ts.DiagnosticCategory.Error, key: "The_left_hand_side_of_a_for_in_statement_must_be_of_type_string_or_any_2405", message: "The left-hand side of a 'for...in' statement must be of type 'string' or 'any'." }, + Invalid_left_hand_side_in_for_in_statement: { code: 2406, category: ts.DiagnosticCategory.Error, key: "Invalid_left_hand_side_in_for_in_statement_2406", message: "Invalid left-hand side in 'for...in' statement." }, + The_right_hand_side_of_a_for_in_statement_must_be_of_type_any_an_object_type_or_a_type_parameter: { code: 2407, category: ts.DiagnosticCategory.Error, key: "The_right_hand_side_of_a_for_in_statement_must_be_of_type_any_an_object_type_or_a_type_parameter_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'." }, + 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}'." }, + Class_name_cannot_be_0: { code: 2414, category: ts.DiagnosticCategory.Error, key: "Class_name_cannot_be_0_2414", message: "Class name cannot be '{0}'" }, + Class_0_incorrectly_extends_base_class_1: { code: 2415, category: ts.DiagnosticCategory.Error, key: "Class_0_incorrectly_extends_base_class_1_2415", message: "Class '{0}' incorrectly extends base class '{1}'." }, + Class_static_side_0_incorrectly_extends_base_class_static_side_1: { code: 2417, category: ts.DiagnosticCategory.Error, key: "Class_static_side_0_incorrectly_extends_base_class_static_side_1_2417", message: "Class static side '{0}' incorrectly extends base class static side '{1}'." }, + Type_name_0_in_extends_clause_does_not_reference_constructor_function_for_0: { code: 2419, category: ts.DiagnosticCategory.Error, key: "Type_name_0_in_extends_clause_does_not_reference_constructor_function_for_0_2419", message: "Type name '{0}' in extends clause does not reference constructor function for '{0}'." }, + Class_0_incorrectly_implements_interface_1: { code: 2420, category: ts.DiagnosticCategory.Error, key: "Class_0_incorrectly_implements_interface_1_2420", message: "Class '{0}' incorrectly implements interface '{1}'." }, + A_class_may_only_implement_another_class_or_interface: { code: 2422, category: ts.DiagnosticCategory.Error, key: "A_class_may_only_implement_another_class_or_interface_2422", message: "A class may only implement another class or interface." }, + Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_accessor: { code: 2423, category: ts.DiagnosticCategory.Error, key: "Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_access_2423", message: "Class '{0}' defines instance member function '{1}', but extended class '{2}' defines it as instance member accessor." }, + Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_property: { code: 2424, category: ts.DiagnosticCategory.Error, key: "Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_proper_2424", message: "Class '{0}' defines instance member function '{1}', but extended class '{2}' defines it as instance member property." }, + Class_0_defines_instance_member_property_1_but_extended_class_2_defines_it_as_instance_member_function: { code: 2425, category: ts.DiagnosticCategory.Error, key: "Class_0_defines_instance_member_property_1_but_extended_class_2_defines_it_as_instance_member_functi_2425", message: "Class '{0}' defines instance member property '{1}', but extended class '{2}' defines it as instance member function." }, + Class_0_defines_instance_member_accessor_1_but_extended_class_2_defines_it_as_instance_member_function: { code: 2426, category: ts.DiagnosticCategory.Error, key: "Class_0_defines_instance_member_accessor_1_but_extended_class_2_defines_it_as_instance_member_functi_2426", message: "Class '{0}' defines instance member accessor '{1}', but extended class '{2}' defines it as instance member function." }, + Interface_name_cannot_be_0: { code: 2427, category: ts.DiagnosticCategory.Error, key: "Interface_name_cannot_be_0_2427", message: "Interface name cannot be '{0}'" }, + All_declarations_of_an_interface_must_have_identical_type_parameters: { code: 2428, category: ts.DiagnosticCategory.Error, key: "All_declarations_of_an_interface_must_have_identical_type_parameters_2428", message: "All declarations of an interface must have identical type parameters." }, + Interface_0_incorrectly_extends_interface_1: { code: 2430, category: ts.DiagnosticCategory.Error, key: "Interface_0_incorrectly_extends_interface_1_2430", message: "Interface '{0}' incorrectly extends interface '{1}'." }, + Enum_name_cannot_be_0: { code: 2431, category: ts.DiagnosticCategory.Error, key: "Enum_name_cannot_be_0_2431", message: "Enum name cannot be '{0}'" }, + In_an_enum_with_multiple_declarations_only_one_declaration_can_omit_an_initializer_for_its_first_enum_element: { code: 2432, category: ts.DiagnosticCategory.Error, key: "In_an_enum_with_multiple_declarations_only_one_declaration_can_omit_an_initializer_for_its_first_enu_2432", message: "In an enum with multiple declarations, only one declaration can omit an initializer for its first enum element." }, + A_namespace_declaration_cannot_be_in_a_different_file_from_a_class_or_function_with_which_it_is_merged: { code: 2433, category: ts.DiagnosticCategory.Error, key: "A_namespace_declaration_cannot_be_in_a_different_file_from_a_class_or_function_with_which_it_is_merg_2433", message: "A namespace declaration cannot be in a different file from a class or function with which it is merged" }, + A_namespace_declaration_cannot_be_located_prior_to_a_class_or_function_with_which_it_is_merged: { code: 2434, category: ts.DiagnosticCategory.Error, key: "A_namespace_declaration_cannot_be_located_prior_to_a_class_or_function_with_which_it_is_merged_2434", message: "A namespace declaration cannot be located prior to a class or function with which it is merged" }, + Ambient_modules_cannot_be_nested_in_other_modules_or_namespaces: { code: 2435, category: ts.DiagnosticCategory.Error, key: "Ambient_modules_cannot_be_nested_in_other_modules_or_namespaces_2435", message: "Ambient modules cannot be nested in other modules or namespaces." }, + Ambient_module_declaration_cannot_specify_relative_module_name: { code: 2436, category: ts.DiagnosticCategory.Error, key: "Ambient_module_declaration_cannot_specify_relative_module_name_2436", message: "Ambient module declaration cannot specify relative module name." }, + Module_0_is_hidden_by_a_local_declaration_with_the_same_name: { code: 2437, category: ts.DiagnosticCategory.Error, key: "Module_0_is_hidden_by_a_local_declaration_with_the_same_name_2437", message: "Module '{0}' is hidden by a local declaration with the same name" }, + Import_name_cannot_be_0: { code: 2438, category: ts.DiagnosticCategory.Error, key: "Import_name_cannot_be_0_2438", message: "Import name cannot be '{0}'" }, + Import_or_export_declaration_in_an_ambient_module_declaration_cannot_reference_module_through_relative_module_name: { code: 2439, category: ts.DiagnosticCategory.Error, key: "Import_or_export_declaration_in_an_ambient_module_declaration_cannot_reference_module_through_relati_2439", message: "Import or export declaration in an ambient module declaration cannot reference module through relative module name." }, + Import_declaration_conflicts_with_local_declaration_of_0: { code: 2440, category: ts.DiagnosticCategory.Error, key: "Import_declaration_conflicts_with_local_declaration_of_0_2440", message: "Import declaration conflicts with local declaration of '{0}'" }, + Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module: { code: 2441, category: ts.DiagnosticCategory.Error, key: "Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module_2441", message: "Duplicate identifier '{0}'. Compiler reserves name '{1}' in top level scope of a module." }, + Types_have_separate_declarations_of_a_private_property_0: { code: 2442, category: ts.DiagnosticCategory.Error, key: "Types_have_separate_declarations_of_a_private_property_0_2442", message: "Types have separate declarations of a private property '{0}'." }, + Property_0_is_protected_but_type_1_is_not_a_class_derived_from_2: { code: 2443, category: ts.DiagnosticCategory.Error, key: "Property_0_is_protected_but_type_1_is_not_a_class_derived_from_2_2443", message: "Property '{0}' is protected but type '{1}' is not a class derived from '{2}'." }, + Property_0_is_protected_in_type_1_but_public_in_type_2: { code: 2444, category: ts.DiagnosticCategory.Error, key: "Property_0_is_protected_in_type_1_but_public_in_type_2_2444", message: "Property '{0}' is protected in type '{1}' but public in type '{2}'." }, + Property_0_is_protected_and_only_accessible_within_class_1_and_its_subclasses: { code: 2445, category: ts.DiagnosticCategory.Error, key: "Property_0_is_protected_and_only_accessible_within_class_1_and_its_subclasses_2445", message: "Property '{0}' is protected and only accessible within class '{1}' and its subclasses." }, + Property_0_is_protected_and_only_accessible_through_an_instance_of_class_1: { code: 2446, category: ts.DiagnosticCategory.Error, key: "Property_0_is_protected_and_only_accessible_through_an_instance_of_class_1_2446", message: "Property '{0}' is protected and only accessible through an instance of class '{1}'." }, + The_0_operator_is_not_allowed_for_boolean_types_Consider_using_1_instead: { code: 2447, category: ts.DiagnosticCategory.Error, key: "The_0_operator_is_not_allowed_for_boolean_types_Consider_using_1_instead_2447", message: "The '{0}' operator is not allowed for boolean types. Consider using '{1}' instead." }, + Block_scoped_variable_0_used_before_its_declaration: { code: 2448, category: ts.DiagnosticCategory.Error, key: "Block_scoped_variable_0_used_before_its_declaration_2448", message: "Block-scoped variable '{0}' used before its declaration." }, + The_operand_of_an_increment_or_decrement_operator_cannot_be_a_constant: { code: 2449, category: ts.DiagnosticCategory.Error, key: "The_operand_of_an_increment_or_decrement_operator_cannot_be_a_constant_2449", message: "The operand of an increment or decrement operator cannot be a constant." }, + Left_hand_side_of_assignment_expression_cannot_be_a_constant: { code: 2450, category: ts.DiagnosticCategory.Error, key: "Left_hand_side_of_assignment_expression_cannot_be_a_constant_2450", message: "Left-hand side of assignment expression cannot be a constant." }, + Cannot_redeclare_block_scoped_variable_0: { code: 2451, category: ts.DiagnosticCategory.Error, key: "Cannot_redeclare_block_scoped_variable_0_2451", message: "Cannot redeclare block-scoped variable '{0}'." }, + An_enum_member_cannot_have_a_numeric_name: { code: 2452, category: ts.DiagnosticCategory.Error, key: "An_enum_member_cannot_have_a_numeric_name_2452", message: "An enum member cannot have a numeric name." }, + The_type_argument_for_type_parameter_0_cannot_be_inferred_from_the_usage_Consider_specifying_the_type_arguments_explicitly: { code: 2453, category: ts.DiagnosticCategory.Error, key: "The_type_argument_for_type_parameter_0_cannot_be_inferred_from_the_usage_Consider_specifying_the_typ_2453", message: "The type argument for type parameter '{0}' cannot be inferred from the usage. Consider specifying the type arguments explicitly." }, + Type_argument_candidate_1_is_not_a_valid_type_argument_because_it_is_not_a_supertype_of_candidate_0: { code: 2455, category: ts.DiagnosticCategory.Error, key: "Type_argument_candidate_1_is_not_a_valid_type_argument_because_it_is_not_a_supertype_of_candidate_0_2455", message: "Type argument candidate '{1}' is not a valid type argument because it is not a supertype of candidate '{0}'." }, + Type_alias_0_circularly_references_itself: { code: 2456, category: ts.DiagnosticCategory.Error, key: "Type_alias_0_circularly_references_itself_2456", message: "Type alias '{0}' circularly references itself." }, + Type_alias_name_cannot_be_0: { code: 2457, category: ts.DiagnosticCategory.Error, key: "Type_alias_name_cannot_be_0_2457", message: "Type alias name cannot be '{0}'" }, + An_AMD_module_cannot_have_multiple_name_assignments: { code: 2458, category: ts.DiagnosticCategory.Error, key: "An_AMD_module_cannot_have_multiple_name_assignments_2458", message: "An AMD module cannot have multiple name assignments." }, + Type_0_has_no_property_1_and_no_string_index_signature: { code: 2459, category: ts.DiagnosticCategory.Error, key: "Type_0_has_no_property_1_and_no_string_index_signature_2459", message: "Type '{0}' has no property '{1}' and no string index signature." }, + Type_0_has_no_property_1: { code: 2460, category: ts.DiagnosticCategory.Error, key: "Type_0_has_no_property_1_2460", message: "Type '{0}' has no property '{1}'." }, + Type_0_is_not_an_array_type: { code: 2461, category: ts.DiagnosticCategory.Error, key: "Type_0_is_not_an_array_type_2461", message: "Type '{0}' is not an array type." }, + A_rest_element_must_be_last_in_an_array_destructuring_pattern: { code: 2462, category: ts.DiagnosticCategory.Error, key: "A_rest_element_must_be_last_in_an_array_destructuring_pattern_2462", message: "A rest element must be last in an array destructuring pattern" }, + A_binding_pattern_parameter_cannot_be_optional_in_an_implementation_signature: { code: 2463, category: ts.DiagnosticCategory.Error, key: "A_binding_pattern_parameter_cannot_be_optional_in_an_implementation_signature_2463", message: "A binding pattern parameter cannot be optional in an implementation signature." }, + A_computed_property_name_must_be_of_type_string_number_symbol_or_any: { code: 2464, category: ts.DiagnosticCategory.Error, key: "A_computed_property_name_must_be_of_type_string_number_symbol_or_any_2464", message: "A computed property name must be of type 'string', 'number', 'symbol', or 'any'." }, + this_cannot_be_referenced_in_a_computed_property_name: { code: 2465, category: ts.DiagnosticCategory.Error, key: "this_cannot_be_referenced_in_a_computed_property_name_2465", message: "'this' cannot be referenced in a computed property name." }, + super_cannot_be_referenced_in_a_computed_property_name: { code: 2466, category: ts.DiagnosticCategory.Error, key: "super_cannot_be_referenced_in_a_computed_property_name_2466", message: "'super' cannot be referenced in a computed property name." }, + A_computed_property_name_cannot_reference_a_type_parameter_from_its_containing_type: { code: 2467, category: ts.DiagnosticCategory.Error, key: "A_computed_property_name_cannot_reference_a_type_parameter_from_its_containing_type_2467", message: "A computed property name cannot reference a type parameter from its containing type." }, + Cannot_find_global_value_0: { code: 2468, category: ts.DiagnosticCategory.Error, key: "Cannot_find_global_value_0_2468", message: "Cannot find global value '{0}'." }, + The_0_operator_cannot_be_applied_to_type_symbol: { code: 2469, category: ts.DiagnosticCategory.Error, key: "The_0_operator_cannot_be_applied_to_type_symbol_2469", message: "The '{0}' operator cannot be applied to type 'symbol'." }, + Symbol_reference_does_not_refer_to_the_global_Symbol_constructor_object: { code: 2470, category: ts.DiagnosticCategory.Error, key: "Symbol_reference_does_not_refer_to_the_global_Symbol_constructor_object_2470", message: "'Symbol' reference does not refer to the global Symbol constructor object." }, + A_computed_property_name_of_the_form_0_must_be_of_type_symbol: { code: 2471, category: ts.DiagnosticCategory.Error, key: "A_computed_property_name_of_the_form_0_must_be_of_type_symbol_2471", message: "A computed property name of the form '{0}' must be of type 'symbol'." }, + Spread_operator_in_new_expressions_is_only_available_when_targeting_ECMAScript_5_and_higher: { code: 2472, category: ts.DiagnosticCategory.Error, key: "Spread_operator_in_new_expressions_is_only_available_when_targeting_ECMAScript_5_and_higher_2472", message: "Spread operator in 'new' expressions is only available when targeting ECMAScript 5 and higher." }, + Enum_declarations_must_all_be_const_or_non_const: { code: 2473, category: ts.DiagnosticCategory.Error, key: "Enum_declarations_must_all_be_const_or_non_const_2473", message: "Enum declarations must all be const or non-const." }, + In_const_enum_declarations_member_initializer_must_be_constant_expression: { code: 2474, category: ts.DiagnosticCategory.Error, key: "In_const_enum_declarations_member_initializer_must_be_constant_expression_2474", message: "In 'const' enum declarations member initializer must be constant expression." }, + const_enums_can_only_be_used_in_property_or_index_access_expressions_or_the_right_hand_side_of_an_import_declaration_or_export_assignment: { code: 2475, category: ts.DiagnosticCategory.Error, key: "const_enums_can_only_be_used_in_property_or_index_access_expressions_or_the_right_hand_side_of_an_im_2475", message: "'const' enums can only be used in property or index access expressions or the right hand side of an import declaration or export assignment." }, + A_const_enum_member_can_only_be_accessed_using_a_string_literal: { code: 2476, category: ts.DiagnosticCategory.Error, key: "A_const_enum_member_can_only_be_accessed_using_a_string_literal_2476", message: "A const enum member can only be accessed using a string literal." }, + const_enum_member_initializer_was_evaluated_to_a_non_finite_value: { code: 2477, category: ts.DiagnosticCategory.Error, key: "const_enum_member_initializer_was_evaluated_to_a_non_finite_value_2477", message: "'const' enum member initializer was evaluated to a non-finite value." }, + const_enum_member_initializer_was_evaluated_to_disallowed_value_NaN: { code: 2478, category: ts.DiagnosticCategory.Error, key: "const_enum_member_initializer_was_evaluated_to_disallowed_value_NaN_2478", message: "'const' enum member initializer was evaluated to disallowed value 'NaN'." }, + Property_0_does_not_exist_on_const_enum_1: { code: 2479, category: ts.DiagnosticCategory.Error, key: "Property_0_does_not_exist_on_const_enum_1_2479", message: "Property '{0}' does not exist on 'const' enum '{1}'." }, + let_is_not_allowed_to_be_used_as_a_name_in_let_or_const_declarations: { code: 2480, category: ts.DiagnosticCategory.Error, key: "let_is_not_allowed_to_be_used_as_a_name_in_let_or_const_declarations_2480", message: "'let' is not allowed to be used as a name in 'let' or 'const' declarations." }, + Cannot_initialize_outer_scoped_variable_0_in_the_same_scope_as_block_scoped_declaration_1: { code: 2481, category: ts.DiagnosticCategory.Error, key: "Cannot_initialize_outer_scoped_variable_0_in_the_same_scope_as_block_scoped_declaration_1_2481", message: "Cannot initialize outer scoped variable '{0}' in the same scope as block scoped declaration '{1}'." }, + The_left_hand_side_of_a_for_of_statement_cannot_use_a_type_annotation: { code: 2483, category: ts.DiagnosticCategory.Error, key: "The_left_hand_side_of_a_for_of_statement_cannot_use_a_type_annotation_2483", message: "The left-hand side of a 'for...of' statement cannot use a type annotation." }, + Export_declaration_conflicts_with_exported_declaration_of_0: { code: 2484, category: ts.DiagnosticCategory.Error, key: "Export_declaration_conflicts_with_exported_declaration_of_0_2484", message: "Export declaration conflicts with exported declaration of '{0}'" }, + The_left_hand_side_of_a_for_of_statement_cannot_be_a_previously_defined_constant: { code: 2485, category: ts.DiagnosticCategory.Error, key: "The_left_hand_side_of_a_for_of_statement_cannot_be_a_previously_defined_constant_2485", message: "The left-hand side of a 'for...of' statement cannot be a previously defined constant." }, + The_left_hand_side_of_a_for_in_statement_cannot_be_a_previously_defined_constant: { code: 2486, category: ts.DiagnosticCategory.Error, key: "The_left_hand_side_of_a_for_in_statement_cannot_be_a_previously_defined_constant_2486", message: "The left-hand side of a 'for...in' statement cannot be a previously defined constant." }, + Invalid_left_hand_side_in_for_of_statement: { code: 2487, category: ts.DiagnosticCategory.Error, key: "Invalid_left_hand_side_in_for_of_statement_2487", message: "Invalid left-hand side in 'for...of' statement." }, + Type_must_have_a_Symbol_iterator_method_that_returns_an_iterator: { code: 2488, category: ts.DiagnosticCategory.Error, key: "Type_must_have_a_Symbol_iterator_method_that_returns_an_iterator_2488", message: "Type must have a '[Symbol.iterator]()' method that returns an iterator." }, + An_iterator_must_have_a_next_method: { code: 2489, category: ts.DiagnosticCategory.Error, key: "An_iterator_must_have_a_next_method_2489", message: "An iterator must have a 'next()' method." }, + The_type_returned_by_the_next_method_of_an_iterator_must_have_a_value_property: { code: 2490, category: ts.DiagnosticCategory.Error, key: "The_type_returned_by_the_next_method_of_an_iterator_must_have_a_value_property_2490", message: "The type returned by the 'next()' method of an iterator must have a 'value' property." }, + The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern: { code: 2491, category: ts.DiagnosticCategory.Error, key: "The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern_2491", message: "The left-hand side of a 'for...in' statement cannot be a destructuring pattern." }, + Cannot_redeclare_identifier_0_in_catch_clause: { code: 2492, category: ts.DiagnosticCategory.Error, key: "Cannot_redeclare_identifier_0_in_catch_clause_2492", message: "Cannot redeclare identifier '{0}' in catch clause" }, + Tuple_type_0_with_length_1_cannot_be_assigned_to_tuple_with_length_2: { code: 2493, category: ts.DiagnosticCategory.Error, key: "Tuple_type_0_with_length_1_cannot_be_assigned_to_tuple_with_length_2_2493", message: "Tuple type '{0}' with length '{1}' cannot be assigned to tuple with length '{2}'." }, + Using_a_string_in_a_for_of_statement_is_only_supported_in_ECMAScript_5_and_higher: { code: 2494, category: ts.DiagnosticCategory.Error, key: "Using_a_string_in_a_for_of_statement_is_only_supported_in_ECMAScript_5_and_higher_2494", message: "Using a string in a 'for...of' statement is only supported in ECMAScript 5 and higher." }, + Type_0_is_not_an_array_type_or_a_string_type: { code: 2495, category: ts.DiagnosticCategory.Error, key: "Type_0_is_not_an_array_type_or_a_string_type_2495", message: "Type '{0}' is not an array type or a string type." }, + The_arguments_object_cannot_be_referenced_in_an_arrow_function_in_ES3_and_ES5_Consider_using_a_standard_function_expression: { code: 2496, category: ts.DiagnosticCategory.Error, key: "The_arguments_object_cannot_be_referenced_in_an_arrow_function_in_ES3_and_ES5_Consider_using_a_stand_2496", message: "The 'arguments' object cannot be referenced in an arrow function in ES3 and ES5. Consider using a standard function expression." }, + Module_0_resolves_to_a_non_module_entity_and_cannot_be_imported_using_this_construct: { code: 2497, category: ts.DiagnosticCategory.Error, key: "Module_0_resolves_to_a_non_module_entity_and_cannot_be_imported_using_this_construct_2497", message: "Module '{0}' resolves to a non-module entity and cannot be imported using this construct." }, + Module_0_uses_export_and_cannot_be_used_with_export_Asterisk: { code: 2498, category: ts.DiagnosticCategory.Error, key: "Module_0_uses_export_and_cannot_be_used_with_export_Asterisk_2498", message: "Module '{0}' uses 'export =' and cannot be used with 'export *'." }, + An_interface_can_only_extend_an_identifier_Slashqualified_name_with_optional_type_arguments: { code: 2499, category: ts.DiagnosticCategory.Error, key: "An_interface_can_only_extend_an_identifier_Slashqualified_name_with_optional_type_arguments_2499", message: "An interface can only extend an identifier/qualified-name with optional type arguments." }, + A_class_can_only_implement_an_identifier_Slashqualified_name_with_optional_type_arguments: { code: 2500, category: ts.DiagnosticCategory.Error, key: "A_class_can_only_implement_an_identifier_Slashqualified_name_with_optional_type_arguments_2500", message: "A class can only implement an identifier/qualified-name with optional type arguments." }, + A_rest_element_cannot_contain_a_binding_pattern: { code: 2501, category: ts.DiagnosticCategory.Error, key: "A_rest_element_cannot_contain_a_binding_pattern_2501", message: "A rest element cannot contain a binding pattern." }, + _0_is_referenced_directly_or_indirectly_in_its_own_type_annotation: { code: 2502, category: ts.DiagnosticCategory.Error, key: "_0_is_referenced_directly_or_indirectly_in_its_own_type_annotation_2502", message: "'{0}' is referenced directly or indirectly in its own type annotation." }, + Cannot_find_namespace_0: { code: 2503, category: ts.DiagnosticCategory.Error, key: "Cannot_find_namespace_0_2503", message: "Cannot find namespace '{0}'." }, + No_best_common_type_exists_among_yield_expressions: { code: 2504, category: ts.DiagnosticCategory.Error, key: "No_best_common_type_exists_among_yield_expressions_2504", message: "No best common type exists among yield expressions." }, + A_generator_cannot_have_a_void_type_annotation: { code: 2505, category: ts.DiagnosticCategory.Error, key: "A_generator_cannot_have_a_void_type_annotation_2505", message: "A generator cannot have a 'void' type annotation." }, + _0_is_referenced_directly_or_indirectly_in_its_own_base_expression: { code: 2506, category: ts.DiagnosticCategory.Error, key: "_0_is_referenced_directly_or_indirectly_in_its_own_base_expression_2506", message: "'{0}' is referenced directly or indirectly in its own base expression." }, + Type_0_is_not_a_constructor_function_type: { code: 2507, category: ts.DiagnosticCategory.Error, key: "Type_0_is_not_a_constructor_function_type_2507", message: "Type '{0}' is not a constructor function type." }, + No_base_constructor_has_the_specified_number_of_type_arguments: { code: 2508, category: ts.DiagnosticCategory.Error, key: "No_base_constructor_has_the_specified_number_of_type_arguments_2508", message: "No base constructor has the specified number of type arguments." }, + Base_constructor_return_type_0_is_not_a_class_or_interface_type: { code: 2509, category: ts.DiagnosticCategory.Error, key: "Base_constructor_return_type_0_is_not_a_class_or_interface_type_2509", message: "Base constructor return type '{0}' is not a class or interface type." }, + Base_constructors_must_all_have_the_same_return_type: { code: 2510, category: ts.DiagnosticCategory.Error, key: "Base_constructors_must_all_have_the_same_return_type_2510", message: "Base constructors must all have the same return type." }, + Cannot_create_an_instance_of_the_abstract_class_0: { code: 2511, category: ts.DiagnosticCategory.Error, key: "Cannot_create_an_instance_of_the_abstract_class_0_2511", message: "Cannot create an instance of the abstract class '{0}'." }, + Overload_signatures_must_all_be_abstract_or_not_abstract: { code: 2512, category: ts.DiagnosticCategory.Error, key: "Overload_signatures_must_all_be_abstract_or_not_abstract_2512", message: "Overload signatures must all be abstract or not abstract." }, + Abstract_method_0_in_class_1_cannot_be_accessed_via_super_expression: { code: 2513, category: ts.DiagnosticCategory.Error, key: "Abstract_method_0_in_class_1_cannot_be_accessed_via_super_expression_2513", message: "Abstract method '{0}' in class '{1}' cannot be accessed via super expression." }, + Classes_containing_abstract_methods_must_be_marked_abstract: { code: 2514, category: ts.DiagnosticCategory.Error, key: "Classes_containing_abstract_methods_must_be_marked_abstract_2514", message: "Classes containing abstract methods must be marked abstract." }, + Non_abstract_class_0_does_not_implement_inherited_abstract_member_1_from_class_2: { code: 2515, category: ts.DiagnosticCategory.Error, key: "Non_abstract_class_0_does_not_implement_inherited_abstract_member_1_from_class_2_2515", message: "Non-abstract class '{0}' does not implement inherited abstract member '{1}' from class '{2}'." }, + All_declarations_of_an_abstract_method_must_be_consecutive: { code: 2516, category: ts.DiagnosticCategory.Error, key: "All_declarations_of_an_abstract_method_must_be_consecutive_2516", message: "All declarations of an abstract method must be consecutive." }, + Cannot_assign_an_abstract_constructor_type_to_a_non_abstract_constructor_type: { code: 2517, category: ts.DiagnosticCategory.Error, key: "Cannot_assign_an_abstract_constructor_type_to_a_non_abstract_constructor_type_2517", message: "Cannot assign an abstract constructor type to a non-abstract constructor type." }, + Duplicate_identifier_0_Compiler_uses_declaration_1_to_support_async_functions: { code: 2520, category: ts.DiagnosticCategory.Error, key: "Duplicate_identifier_0_Compiler_uses_declaration_1_to_support_async_functions_2520", message: "Duplicate identifier '{0}'. Compiler uses declaration '{1}' to support async functions." }, + Expression_resolves_to_variable_declaration_0_that_compiler_uses_to_support_async_functions: { code: 2521, category: ts.DiagnosticCategory.Error, key: "Expression_resolves_to_variable_declaration_0_that_compiler_uses_to_support_async_functions_2521", message: "Expression resolves to variable declaration '{0}' that compiler uses to support async functions." }, + The_arguments_object_cannot_be_referenced_in_an_async_arrow_function_Consider_using_a_standard_async_function_expression: { code: 2522, category: ts.DiagnosticCategory.Error, key: "The_arguments_object_cannot_be_referenced_in_an_async_arrow_function_Consider_using_a_standard_async_2522", message: "The 'arguments' object cannot be referenced in an async arrow function. Consider using a standard async function expression." }, + yield_expressions_cannot_be_used_in_a_parameter_initializer: { code: 2523, category: ts.DiagnosticCategory.Error, key: "yield_expressions_cannot_be_used_in_a_parameter_initializer_2523", message: "'yield' expressions cannot be used in a parameter initializer." }, + await_expressions_cannot_be_used_in_a_parameter_initializer: { code: 2524, category: ts.DiagnosticCategory.Error, key: "await_expressions_cannot_be_used_in_a_parameter_initializer_2524", message: "'await' expressions cannot be used in a parameter initializer." }, + Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value: { code: 2525, category: ts.DiagnosticCategory.Error, key: "Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value_2525", message: "Initializer provides no value for this binding element and the binding element has no default value." }, + A_this_type_is_available_only_in_a_non_static_member_of_a_class_or_interface: { code: 2526, category: ts.DiagnosticCategory.Error, key: "A_this_type_is_available_only_in_a_non_static_member_of_a_class_or_interface_2526", message: "A 'this' type is available only in a non-static member of a class or interface." }, + The_inferred_type_of_0_references_an_inaccessible_this_type_A_type_annotation_is_necessary: { code: 2527, category: ts.DiagnosticCategory.Error, key: "The_inferred_type_of_0_references_an_inaccessible_this_type_A_type_annotation_is_necessary_2527", message: "The inferred type of '{0}' references an inaccessible 'this' type. A type annotation is necessary." }, + A_module_cannot_have_multiple_default_exports: { code: 2528, category: ts.DiagnosticCategory.Error, key: "A_module_cannot_have_multiple_default_exports_2528", message: "A module cannot have multiple default exports." }, + JSX_element_attributes_type_0_must_be_an_object_type: { code: 2600, category: ts.DiagnosticCategory.Error, key: "JSX_element_attributes_type_0_must_be_an_object_type_2600", message: "JSX element attributes type '{0}' must be an object type." }, + The_return_type_of_a_JSX_element_constructor_must_return_an_object_type: { code: 2601, category: ts.DiagnosticCategory.Error, key: "The_return_type_of_a_JSX_element_constructor_must_return_an_object_type_2601", message: "The return type of a JSX element constructor must return an object type." }, + JSX_element_implicitly_has_type_any_because_the_global_type_JSX_Element_does_not_exist: { code: 2602, category: ts.DiagnosticCategory.Error, key: "JSX_element_implicitly_has_type_any_because_the_global_type_JSX_Element_does_not_exist_2602", message: "JSX element implicitly has type 'any' because the global type 'JSX.Element' does not exist." }, + Property_0_in_type_1_is_not_assignable_to_type_2: { code: 2603, category: ts.DiagnosticCategory.Error, key: "Property_0_in_type_1_is_not_assignable_to_type_2_2603", message: "Property '{0}' in type '{1}' is not assignable to type '{2}'" }, + JSX_element_type_0_does_not_have_any_construct_or_call_signatures: { code: 2604, category: ts.DiagnosticCategory.Error, key: "JSX_element_type_0_does_not_have_any_construct_or_call_signatures_2604", message: "JSX element type '{0}' does not have any construct or call signatures." }, + JSX_element_type_0_is_not_a_constructor_function_for_JSX_elements: { code: 2605, category: ts.DiagnosticCategory.Error, key: "JSX_element_type_0_is_not_a_constructor_function_for_JSX_elements_2605", message: "JSX element type '{0}' is not a constructor function for JSX elements." }, + Property_0_of_JSX_spread_attribute_is_not_assignable_to_target_property: { code: 2606, category: ts.DiagnosticCategory.Error, key: "Property_0_of_JSX_spread_attribute_is_not_assignable_to_target_property_2606", message: "Property '{0}' of JSX spread attribute is not assignable to target property." }, + JSX_element_class_does_not_support_attributes_because_it_does_not_have_a_0_property: { code: 2607, category: ts.DiagnosticCategory.Error, key: "JSX_element_class_does_not_support_attributes_because_it_does_not_have_a_0_property_2607", message: "JSX element class does not support attributes because it does not have a '{0}' property" }, + The_global_type_JSX_0_may_not_have_more_than_one_property: { code: 2608, category: ts.DiagnosticCategory.Error, key: "The_global_type_JSX_0_may_not_have_more_than_one_property_2608", message: "The global type 'JSX.{0}' may not have more than one property" }, + Cannot_emit_namespaced_JSX_elements_in_React: { code: 2650, category: ts.DiagnosticCategory.Error, key: "Cannot_emit_namespaced_JSX_elements_in_React_2650", message: "Cannot emit namespaced JSX elements in React" }, + A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_enums: { code: 2651, category: ts.DiagnosticCategory.Error, key: "A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_memb_2651", message: "A member initializer in a enum declaration cannot reference members declared after it, including members defined in other enums." }, + Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_default_0_declaration_instead: { code: 2652, category: ts.DiagnosticCategory.Error, key: "Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_d_2652", message: "Merged declaration '{0}' cannot include a default export declaration. Consider adding a separate 'export default {0}' declaration instead." }, + Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1: { code: 2653, category: ts.DiagnosticCategory.Error, key: "Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1_2653", message: "Non-abstract class expression does not implement inherited abstract member '{0}' from class '{1}'." }, + Exported_external_package_typings_file_cannot_contain_tripleslash_references_Please_contact_the_package_author_to_update_the_package_definition: { code: 2654, category: ts.DiagnosticCategory.Error, key: "Exported_external_package_typings_file_cannot_contain_tripleslash_references_Please_contact_the_pack_2654", message: "Exported external package typings file cannot contain tripleslash references. Please contact the package author to update the package definition." }, + Exported_external_package_typings_file_0_is_not_a_module_Please_contact_the_package_author_to_update_the_package_definition: { code: 2656, category: ts.DiagnosticCategory.Error, key: "Exported_external_package_typings_file_0_is_not_a_module_Please_contact_the_package_author_to_update_2656", message: "Exported external package typings file '{0}' is not a module. Please contact the package author to update the package definition." }, + JSX_expressions_must_have_one_parent_element: { code: 2657, category: ts.DiagnosticCategory.Error, key: "JSX_expressions_must_have_one_parent_element_2657", message: "JSX expressions must have one parent element" }, + Import_declaration_0_is_using_private_name_1: { code: 4000, category: ts.DiagnosticCategory.Error, key: "Import_declaration_0_is_using_private_name_1_4000", message: "Import declaration '{0}' is using private name '{1}'." }, + Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: { code: 4002, category: ts.DiagnosticCategory.Error, key: "Type_parameter_0_of_exported_class_has_or_is_using_private_name_1_4002", message: "Type parameter '{0}' of exported class has or is using private name '{1}'." }, + Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1: { code: 4004, category: ts.DiagnosticCategory.Error, key: "Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1_4004", message: "Type parameter '{0}' of exported interface has or is using private name '{1}'." }, + Type_parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1: { code: 4006, category: ts.DiagnosticCategory.Error, key: "Type_parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1_4006", message: "Type parameter '{0}' of constructor signature from exported interface has or is using private name '{1}'." }, + Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1: { code: 4008, category: ts.DiagnosticCategory.Error, key: "Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1_4008", message: "Type parameter '{0}' of call signature from exported interface has or is using private name '{1}'." }, + Type_parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1: { code: 4010, category: ts.DiagnosticCategory.Error, key: "Type_parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1_4010", message: "Type parameter '{0}' of public static method from exported class has or is using private name '{1}'." }, + Type_parameter_0_of_public_method_from_exported_class_has_or_is_using_private_name_1: { code: 4012, category: ts.DiagnosticCategory.Error, key: "Type_parameter_0_of_public_method_from_exported_class_has_or_is_using_private_name_1_4012", message: "Type parameter '{0}' of public method from exported class has or is using private name '{1}'." }, + Type_parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1: { code: 4014, category: ts.DiagnosticCategory.Error, key: "Type_parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1_4014", message: "Type parameter '{0}' of method from exported interface has or is using private name '{1}'." }, + Type_parameter_0_of_exported_function_has_or_is_using_private_name_1: { code: 4016, category: ts.DiagnosticCategory.Error, key: "Type_parameter_0_of_exported_function_has_or_is_using_private_name_1_4016", message: "Type parameter '{0}' of exported function has or is using private name '{1}'." }, + Implements_clause_of_exported_class_0_has_or_is_using_private_name_1: { code: 4019, category: ts.DiagnosticCategory.Error, key: "Implements_clause_of_exported_class_0_has_or_is_using_private_name_1_4019", message: "Implements clause of exported class '{0}' has or is using private name '{1}'." }, + Extends_clause_of_exported_class_0_has_or_is_using_private_name_1: { code: 4020, category: ts.DiagnosticCategory.Error, key: "Extends_clause_of_exported_class_0_has_or_is_using_private_name_1_4020", message: "Extends clause of exported class '{0}' has or is using private name '{1}'." }, + Extends_clause_of_exported_interface_0_has_or_is_using_private_name_1: { code: 4022, category: ts.DiagnosticCategory.Error, key: "Extends_clause_of_exported_interface_0_has_or_is_using_private_name_1_4022", message: "Extends clause of exported interface '{0}' has or is using private name '{1}'." }, + Exported_variable_0_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: { code: 4023, category: ts.DiagnosticCategory.Error, key: "Exported_variable_0_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named_4023", message: "Exported variable '{0}' has or is using name '{1}' from external module {2} but cannot be named." }, + Exported_variable_0_has_or_is_using_name_1_from_private_module_2: { code: 4024, category: ts.DiagnosticCategory.Error, key: "Exported_variable_0_has_or_is_using_name_1_from_private_module_2_4024", message: "Exported variable '{0}' has or is using name '{1}' from private module '{2}'." }, + Exported_variable_0_has_or_is_using_private_name_1: { code: 4025, category: ts.DiagnosticCategory.Error, key: "Exported_variable_0_has_or_is_using_private_name_1_4025", message: "Exported variable '{0}' has or is using private name '{1}'." }, + Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: { code: 4026, category: ts.DiagnosticCategory.Error, key: "Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot__4026", message: "Public static property '{0}' of exported class has or is using name '{1}' from external module {2} but cannot be named." }, + Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2: { code: 4027, category: ts.DiagnosticCategory.Error, key: "Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2_4027", message: "Public static property '{0}' of exported class has or is using name '{1}' from private module '{2}'." }, + Public_static_property_0_of_exported_class_has_or_is_using_private_name_1: { code: 4028, category: ts.DiagnosticCategory.Error, key: "Public_static_property_0_of_exported_class_has_or_is_using_private_name_1_4028", message: "Public static property '{0}' of exported class has or is using private name '{1}'." }, + Public_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: { code: 4029, category: ts.DiagnosticCategory.Error, key: "Public_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_name_4029", message: "Public property '{0}' of exported class has or is using name '{1}' from external module {2} but cannot be named." }, + Public_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2: { code: 4030, category: ts.DiagnosticCategory.Error, key: "Public_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2_4030", message: "Public property '{0}' of exported class has or is using name '{1}' from private module '{2}'." }, + Public_property_0_of_exported_class_has_or_is_using_private_name_1: { code: 4031, category: ts.DiagnosticCategory.Error, key: "Public_property_0_of_exported_class_has_or_is_using_private_name_1_4031", message: "Public property '{0}' of exported class has or is using private name '{1}'." }, + Property_0_of_exported_interface_has_or_is_using_name_1_from_private_module_2: { code: 4032, category: ts.DiagnosticCategory.Error, key: "Property_0_of_exported_interface_has_or_is_using_name_1_from_private_module_2_4032", message: "Property '{0}' of exported interface has or is using name '{1}' from private module '{2}'." }, + Property_0_of_exported_interface_has_or_is_using_private_name_1: { code: 4033, category: ts.DiagnosticCategory.Error, key: "Property_0_of_exported_interface_has_or_is_using_private_name_1_4033", message: "Property '{0}' of exported interface has or is using private name '{1}'." }, + Parameter_0_of_public_static_property_setter_from_exported_class_has_or_is_using_name_1_from_private_module_2: { code: 4034, category: ts.DiagnosticCategory.Error, key: "Parameter_0_of_public_static_property_setter_from_exported_class_has_or_is_using_name_1_from_private_4034", message: "Parameter '{0}' of public static property setter from exported class has or is using name '{1}' from private module '{2}'." }, + Parameter_0_of_public_static_property_setter_from_exported_class_has_or_is_using_private_name_1: { code: 4035, category: ts.DiagnosticCategory.Error, key: "Parameter_0_of_public_static_property_setter_from_exported_class_has_or_is_using_private_name_1_4035", message: "Parameter '{0}' of public static property setter from exported class has or is using private name '{1}'." }, + Parameter_0_of_public_property_setter_from_exported_class_has_or_is_using_name_1_from_private_module_2: { code: 4036, category: ts.DiagnosticCategory.Error, key: "Parameter_0_of_public_property_setter_from_exported_class_has_or_is_using_name_1_from_private_module_4036", message: "Parameter '{0}' of public property setter from exported class has or is using name '{1}' from private module '{2}'." }, + Parameter_0_of_public_property_setter_from_exported_class_has_or_is_using_private_name_1: { code: 4037, category: ts.DiagnosticCategory.Error, key: "Parameter_0_of_public_property_setter_from_exported_class_has_or_is_using_private_name_1_4037", message: "Parameter '{0}' of public property setter from exported class has or is using private name '{1}'." }, + Return_type_of_public_static_property_getter_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named: { code: 4038, category: ts.DiagnosticCategory.Error, key: "Return_type_of_public_static_property_getter_from_exported_class_has_or_is_using_name_0_from_externa_4038", message: "Return type of public static property getter from exported class has or is using name '{0}' from external module {1} but cannot be named." }, + Return_type_of_public_static_property_getter_from_exported_class_has_or_is_using_name_0_from_private_module_1: { code: 4039, category: ts.DiagnosticCategory.Error, key: "Return_type_of_public_static_property_getter_from_exported_class_has_or_is_using_name_0_from_private_4039", message: "Return type of public static property getter from exported class has or is using name '{0}' from private module '{1}'." }, + Return_type_of_public_static_property_getter_from_exported_class_has_or_is_using_private_name_0: { code: 4040, category: ts.DiagnosticCategory.Error, key: "Return_type_of_public_static_property_getter_from_exported_class_has_or_is_using_private_name_0_4040", message: "Return type of public static property getter from exported class has or is using private name '{0}'." }, + Return_type_of_public_property_getter_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named: { code: 4041, category: ts.DiagnosticCategory.Error, key: "Return_type_of_public_property_getter_from_exported_class_has_or_is_using_name_0_from_external_modul_4041", message: "Return type of public property getter from exported class has or is using name '{0}' from external module {1} but cannot be named." }, + Return_type_of_public_property_getter_from_exported_class_has_or_is_using_name_0_from_private_module_1: { code: 4042, category: ts.DiagnosticCategory.Error, key: "Return_type_of_public_property_getter_from_exported_class_has_or_is_using_name_0_from_private_module_4042", message: "Return type of public property getter from exported class has or is using name '{0}' from private module '{1}'." }, + Return_type_of_public_property_getter_from_exported_class_has_or_is_using_private_name_0: { code: 4043, category: ts.DiagnosticCategory.Error, key: "Return_type_of_public_property_getter_from_exported_class_has_or_is_using_private_name_0_4043", message: "Return type of public property getter from exported class has or is using private name '{0}'." }, + Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1: { code: 4044, category: ts.DiagnosticCategory.Error, key: "Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_name_0_from_private_mod_4044", message: "Return type of constructor signature from exported interface has or is using name '{0}' from private module '{1}'." }, + Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_0: { code: 4045, category: ts.DiagnosticCategory.Error, key: "Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_0_4045", message: "Return type of constructor signature from exported interface has or is using private name '{0}'." }, + Return_type_of_call_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1: { code: 4046, category: ts.DiagnosticCategory.Error, key: "Return_type_of_call_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1_4046", message: "Return type of call signature from exported interface has or is using name '{0}' from private module '{1}'." }, + Return_type_of_call_signature_from_exported_interface_has_or_is_using_private_name_0: { code: 4047, category: ts.DiagnosticCategory.Error, key: "Return_type_of_call_signature_from_exported_interface_has_or_is_using_private_name_0_4047", message: "Return type of call signature from exported interface has or is using private name '{0}'." }, + Return_type_of_index_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1: { code: 4048, category: ts.DiagnosticCategory.Error, key: "Return_type_of_index_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1_4048", message: "Return type of index signature from exported interface has or is using name '{0}' from private module '{1}'." }, + Return_type_of_index_signature_from_exported_interface_has_or_is_using_private_name_0: { code: 4049, category: ts.DiagnosticCategory.Error, key: "Return_type_of_index_signature_from_exported_interface_has_or_is_using_private_name_0_4049", message: "Return type of index signature from exported interface has or is using private name '{0}'." }, + Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named: { code: 4050, category: ts.DiagnosticCategory.Error, key: "Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_external_module__4050", message: "Return type of public static method from exported class has or is using name '{0}' from external module {1} but cannot be named." }, + Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_private_module_1: { code: 4051, category: ts.DiagnosticCategory.Error, key: "Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_private_module_1_4051", message: "Return type of public static method from exported class has or is using name '{0}' from private module '{1}'." }, + Return_type_of_public_static_method_from_exported_class_has_or_is_using_private_name_0: { code: 4052, category: ts.DiagnosticCategory.Error, key: "Return_type_of_public_static_method_from_exported_class_has_or_is_using_private_name_0_4052", message: "Return type of public static method from exported class has or is using private name '{0}'." }, + Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named: { code: 4053, category: ts.DiagnosticCategory.Error, key: "Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_c_4053", message: "Return type of public method from exported class has or is using name '{0}' from external module {1} but cannot be named." }, + Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_private_module_1: { code: 4054, category: ts.DiagnosticCategory.Error, key: "Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_private_module_1_4054", message: "Return type of public method from exported class has or is using name '{0}' from private module '{1}'." }, + Return_type_of_public_method_from_exported_class_has_or_is_using_private_name_0: { code: 4055, category: ts.DiagnosticCategory.Error, key: "Return_type_of_public_method_from_exported_class_has_or_is_using_private_name_0_4055", message: "Return type of public method from exported class has or is using private name '{0}'." }, + Return_type_of_method_from_exported_interface_has_or_is_using_name_0_from_private_module_1: { code: 4056, category: ts.DiagnosticCategory.Error, key: "Return_type_of_method_from_exported_interface_has_or_is_using_name_0_from_private_module_1_4056", message: "Return type of method from exported interface has or is using name '{0}' from private module '{1}'." }, + Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0: { code: 4057, category: ts.DiagnosticCategory.Error, key: "Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0_4057", message: "Return type of method from exported interface has or is using private name '{0}'." }, + Return_type_of_exported_function_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named: { code: 4058, category: ts.DiagnosticCategory.Error, key: "Return_type_of_exported_function_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named_4058", message: "Return type of exported function has or is using name '{0}' from external module {1} but cannot be named." }, + Return_type_of_exported_function_has_or_is_using_name_0_from_private_module_1: { code: 4059, category: ts.DiagnosticCategory.Error, key: "Return_type_of_exported_function_has_or_is_using_name_0_from_private_module_1_4059", message: "Return type of exported function has or is using name '{0}' from private module '{1}'." }, + Return_type_of_exported_function_has_or_is_using_private_name_0: { code: 4060, category: ts.DiagnosticCategory.Error, key: "Return_type_of_exported_function_has_or_is_using_private_name_0_4060", message: "Return type of exported function has or is using private name '{0}'." }, + Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: { code: 4061, category: ts.DiagnosticCategory.Error, key: "Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_can_4061", message: "Parameter '{0}' of constructor from exported class has or is using name '{1}' from external module {2} but cannot be named." }, + Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_private_module_2: { code: 4062, category: ts.DiagnosticCategory.Error, key: "Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_private_module_2_4062", message: "Parameter '{0}' of constructor from exported class has or is using name '{1}' from private module '{2}'." }, + Parameter_0_of_constructor_from_exported_class_has_or_is_using_private_name_1: { code: 4063, category: ts.DiagnosticCategory.Error, key: "Parameter_0_of_constructor_from_exported_class_has_or_is_using_private_name_1_4063", message: "Parameter '{0}' of constructor from exported class has or is using private name '{1}'." }, + Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2: { code: 4064, category: ts.DiagnosticCategory.Error, key: "Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_name_1_from_private_mod_4064", message: "Parameter '{0}' of constructor signature from exported interface has or is using name '{1}' from private module '{2}'." }, + Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1: { code: 4065, category: ts.DiagnosticCategory.Error, key: "Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1_4065", message: "Parameter '{0}' of constructor signature from exported interface has or is using private name '{1}'." }, + Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2: { code: 4066, category: ts.DiagnosticCategory.Error, key: "Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2_4066", message: "Parameter '{0}' of call signature from exported interface has or is using name '{1}' from private module '{2}'." }, + Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1: { code: 4067, category: ts.DiagnosticCategory.Error, key: "Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1_4067", message: "Parameter '{0}' of call signature from exported interface has or is using private name '{1}'." }, + Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: { code: 4068, category: ts.DiagnosticCategory.Error, key: "Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_external_module__4068", message: "Parameter '{0}' of public static method from exported class has or is using name '{1}' from external module {2} but cannot be named." }, + Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_private_module_2: { code: 4069, category: ts.DiagnosticCategory.Error, key: "Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_private_module_2_4069", message: "Parameter '{0}' of public static method from exported class has or is using name '{1}' from private module '{2}'." }, + Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1: { code: 4070, category: ts.DiagnosticCategory.Error, key: "Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1_4070", message: "Parameter '{0}' of public static method from exported class has or is using private name '{1}'." }, + Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: { code: 4071, category: ts.DiagnosticCategory.Error, key: "Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_c_4071", message: "Parameter '{0}' of public method from exported class has or is using name '{1}' from external module {2} but cannot be named." }, + Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_private_module_2: { code: 4072, category: ts.DiagnosticCategory.Error, key: "Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_private_module_2_4072", message: "Parameter '{0}' of public method from exported class has or is using name '{1}' from private module '{2}'." }, + Parameter_0_of_public_method_from_exported_class_has_or_is_using_private_name_1: { code: 4073, category: ts.DiagnosticCategory.Error, key: "Parameter_0_of_public_method_from_exported_class_has_or_is_using_private_name_1_4073", message: "Parameter '{0}' of public method from exported class has or is using private name '{1}'." }, + Parameter_0_of_method_from_exported_interface_has_or_is_using_name_1_from_private_module_2: { code: 4074, category: ts.DiagnosticCategory.Error, key: "Parameter_0_of_method_from_exported_interface_has_or_is_using_name_1_from_private_module_2_4074", message: "Parameter '{0}' of method from exported interface has or is using name '{1}' from private module '{2}'." }, + Parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1: { code: 4075, category: ts.DiagnosticCategory.Error, key: "Parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1_4075", message: "Parameter '{0}' of method from exported interface has or is using private name '{1}'." }, + Parameter_0_of_exported_function_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: { code: 4076, category: ts.DiagnosticCategory.Error, key: "Parameter_0_of_exported_function_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named_4076", message: "Parameter '{0}' of exported function has or is using name '{1}' from external module {2} but cannot be named." }, + Parameter_0_of_exported_function_has_or_is_using_name_1_from_private_module_2: { code: 4077, category: ts.DiagnosticCategory.Error, key: "Parameter_0_of_exported_function_has_or_is_using_name_1_from_private_module_2_4077", message: "Parameter '{0}' of exported function has or is using name '{1}' from private module '{2}'." }, + Parameter_0_of_exported_function_has_or_is_using_private_name_1: { code: 4078, category: ts.DiagnosticCategory.Error, key: "Parameter_0_of_exported_function_has_or_is_using_private_name_1_4078", message: "Parameter '{0}' of exported function has or is using private name '{1}'." }, + Exported_type_alias_0_has_or_is_using_private_name_1: { code: 4081, category: ts.DiagnosticCategory.Error, key: "Exported_type_alias_0_has_or_is_using_private_name_1_4081", message: "Exported type alias '{0}' has or is using private name '{1}'." }, + Default_export_of_the_module_has_or_is_using_private_name_0: { code: 4082, category: ts.DiagnosticCategory.Error, key: "Default_export_of_the_module_has_or_is_using_private_name_0_4082", message: "Default export of the module has or is using private name '{0}'." }, + The_current_host_does_not_support_the_0_option: { code: 5001, category: ts.DiagnosticCategory.Error, key: "The_current_host_does_not_support_the_0_option_5001", message: "The current host does not support the '{0}' option." }, + Cannot_find_the_common_subdirectory_path_for_the_input_files: { code: 5009, category: ts.DiagnosticCategory.Error, key: "Cannot_find_the_common_subdirectory_path_for_the_input_files_5009", message: "Cannot find the common subdirectory path for the input files." }, + Cannot_read_file_0_Colon_1: { code: 5012, category: ts.DiagnosticCategory.Error, key: "Cannot_read_file_0_Colon_1_5012", message: "Cannot read file '{0}': {1}" }, + Unsupported_file_encoding: { code: 5013, category: ts.DiagnosticCategory.Error, key: "Unsupported_file_encoding_5013", message: "Unsupported file encoding." }, + Failed_to_parse_file_0_Colon_1: { code: 5014, category: ts.DiagnosticCategory.Error, key: "Failed_to_parse_file_0_Colon_1_5014", message: "Failed to parse file '{0}': {1}." }, + Unknown_compiler_option_0: { code: 5023, category: ts.DiagnosticCategory.Error, key: "Unknown_compiler_option_0_5023", message: "Unknown compiler option '{0}'." }, + Compiler_option_0_requires_a_value_of_type_1: { code: 5024, category: ts.DiagnosticCategory.Error, key: "Compiler_option_0_requires_a_value_of_type_1_5024", message: "Compiler option '{0}' requires a value of type {1}." }, + Could_not_write_file_0_Colon_1: { code: 5033, category: ts.DiagnosticCategory.Error, key: "Could_not_write_file_0_Colon_1_5033", message: "Could not write file '{0}': {1}" }, + Option_project_cannot_be_mixed_with_source_files_on_a_command_line: { code: 5042, category: ts.DiagnosticCategory.Error, key: "Option_project_cannot_be_mixed_with_source_files_on_a_command_line_5042", message: "Option 'project' cannot be mixed with source files on a command line." }, + Option_isolatedModules_can_only_be_used_when_either_option_module_is_provided_or_option_target_is_ES2015_or_higher: { code: 5047, category: ts.DiagnosticCategory.Error, key: "Option_isolatedModules_can_only_be_used_when_either_option_module_is_provided_or_option_target_is_ES_5047", message: "Option 'isolatedModules' can only be used when either option '--module' is provided or option 'target' is 'ES2015' or higher." }, + Option_inlineSources_can_only_be_used_when_either_option_inlineSourceMap_or_option_sourceMap_is_provided: { code: 5051, category: ts.DiagnosticCategory.Error, key: "Option_inlineSources_can_only_be_used_when_either_option_inlineSourceMap_or_option_sourceMap_is_prov_5051", message: "Option 'inlineSources' can only be used when either option '--inlineSourceMap' or option '--sourceMap' is provided." }, + Option_0_cannot_be_specified_without_specifying_option_1: { code: 5052, category: ts.DiagnosticCategory.Error, key: "Option_0_cannot_be_specified_without_specifying_option_1_5052", message: "Option '{0}' cannot be specified without specifying option '{1}'." }, + Option_0_cannot_be_specified_with_option_1: { code: 5053, category: ts.DiagnosticCategory.Error, key: "Option_0_cannot_be_specified_with_option_1_5053", message: "Option '{0}' cannot be specified with option '{1}'." }, + A_tsconfig_json_file_is_already_defined_at_Colon_0: { code: 5054, category: ts.DiagnosticCategory.Error, key: "A_tsconfig_json_file_is_already_defined_at_Colon_0_5054", message: "A 'tsconfig.json' file is already defined at: '{0}'." }, + Concatenate_and_emit_output_to_single_file: { code: 6001, category: ts.DiagnosticCategory.Message, key: "Concatenate_and_emit_output_to_single_file_6001", message: "Concatenate and emit output to single file." }, + Generates_corresponding_d_ts_file: { code: 6002, category: ts.DiagnosticCategory.Message, key: "Generates_corresponding_d_ts_file_6002", message: "Generates corresponding '.d.ts' file." }, + Specifies_the_location_where_debugger_should_locate_map_files_instead_of_generated_locations: { code: 6003, category: ts.DiagnosticCategory.Message, key: "Specifies_the_location_where_debugger_should_locate_map_files_instead_of_generated_locations_6003", message: "Specifies the location where debugger should locate map files instead of generated locations." }, + Specifies_the_location_where_debugger_should_locate_TypeScript_files_instead_of_source_locations: { code: 6004, category: ts.DiagnosticCategory.Message, key: "Specifies_the_location_where_debugger_should_locate_TypeScript_files_instead_of_source_locations_6004", message: "Specifies the location where debugger should locate TypeScript files instead of source locations." }, + Watch_input_files: { code: 6005, category: ts.DiagnosticCategory.Message, key: "Watch_input_files_6005", message: "Watch input files." }, + Redirect_output_structure_to_the_directory: { code: 6006, category: ts.DiagnosticCategory.Message, key: "Redirect_output_structure_to_the_directory_6006", message: "Redirect output structure to the directory." }, + Do_not_erase_const_enum_declarations_in_generated_code: { code: 6007, category: ts.DiagnosticCategory.Message, key: "Do_not_erase_const_enum_declarations_in_generated_code_6007", message: "Do not erase const enum declarations in generated code." }, + Do_not_emit_outputs_if_any_errors_were_reported: { code: 6008, category: ts.DiagnosticCategory.Message, key: "Do_not_emit_outputs_if_any_errors_were_reported_6008", message: "Do not emit outputs if any errors were reported." }, + Do_not_emit_comments_to_output: { code: 6009, category: ts.DiagnosticCategory.Message, key: "Do_not_emit_comments_to_output_6009", message: "Do not emit comments to output." }, + Do_not_emit_outputs: { code: 6010, category: ts.DiagnosticCategory.Message, key: "Do_not_emit_outputs_6010", message: "Do not emit outputs." }, + Specify_ECMAScript_target_version_Colon_ES3_default_ES5_or_ES2015_experimental: { code: 6015, category: ts.DiagnosticCategory.Message, key: "Specify_ECMAScript_target_version_Colon_ES3_default_ES5_or_ES2015_experimental_6015", message: "Specify ECMAScript target version: 'ES3' (default), 'ES5', or 'ES2015' (experimental)" }, + Specify_module_code_generation_Colon_commonjs_amd_system_umd_or_es2015: { code: 6016, category: ts.DiagnosticCategory.Message, key: "Specify_module_code_generation_Colon_commonjs_amd_system_umd_or_es2015_6016", message: "Specify module code generation: 'commonjs', 'amd', 'system', 'umd' or 'es2015'" }, + Print_this_message: { code: 6017, category: ts.DiagnosticCategory.Message, key: "Print_this_message_6017", message: "Print this message." }, + Print_the_compiler_s_version: { code: 6019, category: ts.DiagnosticCategory.Message, key: "Print_the_compiler_s_version_6019", message: "Print the compiler's version." }, + Compile_the_project_in_the_given_directory: { code: 6020, category: ts.DiagnosticCategory.Message, key: "Compile_the_project_in_the_given_directory_6020", message: "Compile the project in the given directory." }, + Syntax_Colon_0: { code: 6023, category: ts.DiagnosticCategory.Message, key: "Syntax_Colon_0_6023", message: "Syntax: {0}" }, + options: { code: 6024, category: ts.DiagnosticCategory.Message, key: "options_6024", message: "options" }, + file: { code: 6025, category: ts.DiagnosticCategory.Message, key: "file_6025", message: "file" }, + Examples_Colon_0: { code: 6026, category: ts.DiagnosticCategory.Message, key: "Examples_Colon_0_6026", message: "Examples: {0}" }, + Options_Colon: { code: 6027, category: ts.DiagnosticCategory.Message, key: "Options_Colon_6027", message: "Options:" }, + Version_0: { code: 6029, category: ts.DiagnosticCategory.Message, key: "Version_0_6029", message: "Version {0}" }, + Insert_command_line_options_and_files_from_a_file: { code: 6030, category: ts.DiagnosticCategory.Message, key: "Insert_command_line_options_and_files_from_a_file_6030", message: "Insert command line options and files from a file." }, + File_change_detected_Starting_incremental_compilation: { code: 6032, category: ts.DiagnosticCategory.Message, key: "File_change_detected_Starting_incremental_compilation_6032", message: "File change detected. Starting incremental compilation..." }, + KIND: { code: 6034, category: ts.DiagnosticCategory.Message, key: "KIND_6034", message: "KIND" }, + FILE: { code: 6035, category: ts.DiagnosticCategory.Message, key: "FILE_6035", message: "FILE" }, + VERSION: { code: 6036, category: ts.DiagnosticCategory.Message, key: "VERSION_6036", message: "VERSION" }, + LOCATION: { code: 6037, category: ts.DiagnosticCategory.Message, key: "LOCATION_6037", message: "LOCATION" }, + DIRECTORY: { code: 6038, category: ts.DiagnosticCategory.Message, key: "DIRECTORY_6038", message: "DIRECTORY" }, + Compilation_complete_Watching_for_file_changes: { code: 6042, category: ts.DiagnosticCategory.Message, key: "Compilation_complete_Watching_for_file_changes_6042", message: "Compilation complete. Watching for file changes." }, + Generates_corresponding_map_file: { code: 6043, category: ts.DiagnosticCategory.Message, key: "Generates_corresponding_map_file_6043", message: "Generates corresponding '.map' file." }, + Compiler_option_0_expects_an_argument: { code: 6044, category: ts.DiagnosticCategory.Error, key: "Compiler_option_0_expects_an_argument_6044", message: "Compiler option '{0}' expects an argument." }, + Unterminated_quoted_string_in_response_file_0: { code: 6045, category: ts.DiagnosticCategory.Error, key: "Unterminated_quoted_string_in_response_file_0_6045", message: "Unterminated quoted string in response file '{0}'." }, + Argument_for_module_option_must_be_commonjs_amd_system_umd_or_es2015: { code: 6046, category: ts.DiagnosticCategory.Error, key: "Argument_for_module_option_must_be_commonjs_amd_system_umd_or_es2015_6046", message: "Argument for '--module' option must be 'commonjs', 'amd', 'system', 'umd', or 'es2015'." }, + Argument_for_target_option_must_be_ES3_ES5_or_ES2015: { code: 6047, category: ts.DiagnosticCategory.Error, key: "Argument_for_target_option_must_be_ES3_ES5_or_ES2015_6047", message: "Argument for '--target' option must be 'ES3', 'ES5', or 'ES2015'." }, + Locale_must_be_of_the_form_language_or_language_territory_For_example_0_or_1: { code: 6048, category: ts.DiagnosticCategory.Error, key: "Locale_must_be_of_the_form_language_or_language_territory_For_example_0_or_1_6048", message: "Locale must be of the form or -. For example '{0}' or '{1}'." }, + Unsupported_locale_0: { code: 6049, category: ts.DiagnosticCategory.Error, key: "Unsupported_locale_0_6049", message: "Unsupported locale '{0}'." }, + Unable_to_open_file_0: { code: 6050, category: ts.DiagnosticCategory.Error, key: "Unable_to_open_file_0_6050", message: "Unable to open file '{0}'." }, + Corrupted_locale_file_0: { code: 6051, category: ts.DiagnosticCategory.Error, key: "Corrupted_locale_file_0_6051", message: "Corrupted locale file {0}." }, + Raise_error_on_expressions_and_declarations_with_an_implied_any_type: { code: 6052, category: ts.DiagnosticCategory.Message, key: "Raise_error_on_expressions_and_declarations_with_an_implied_any_type_6052", message: "Raise error on expressions and declarations with an implied 'any' type." }, + File_0_not_found: { code: 6053, category: ts.DiagnosticCategory.Error, key: "File_0_not_found_6053", message: "File '{0}' not found." }, + File_0_has_unsupported_extension_The_only_supported_extensions_are_1: { code: 6054, category: ts.DiagnosticCategory.Error, key: "File_0_has_unsupported_extension_The_only_supported_extensions_are_1_6054", message: "File '{0}' has unsupported extension. The only supported extensions are {1}." }, + Suppress_noImplicitAny_errors_for_indexing_objects_lacking_index_signatures: { code: 6055, category: ts.DiagnosticCategory.Message, key: "Suppress_noImplicitAny_errors_for_indexing_objects_lacking_index_signatures_6055", message: "Suppress noImplicitAny errors for indexing objects lacking index signatures." }, + Do_not_emit_declarations_for_code_that_has_an_internal_annotation: { code: 6056, category: ts.DiagnosticCategory.Message, key: "Do_not_emit_declarations_for_code_that_has_an_internal_annotation_6056", message: "Do not emit declarations for code that has an '@internal' annotation." }, + Specifies_the_root_directory_of_input_files_Use_to_control_the_output_directory_structure_with_outDir: { code: 6058, category: ts.DiagnosticCategory.Message, key: "Specifies_the_root_directory_of_input_files_Use_to_control_the_output_directory_structure_with_outDi_6058", message: "Specifies the root directory of input files. Use to control the output directory structure with --outDir." }, + File_0_is_not_under_rootDir_1_rootDir_is_expected_to_contain_all_source_files: { code: 6059, category: ts.DiagnosticCategory.Error, key: "File_0_is_not_under_rootDir_1_rootDir_is_expected_to_contain_all_source_files_6059", message: "File '{0}' is not under 'rootDir' '{1}'. 'rootDir' is expected to contain all source files." }, + Specifies_the_end_of_line_sequence_to_be_used_when_emitting_files_Colon_CRLF_dos_or_LF_unix: { code: 6060, category: ts.DiagnosticCategory.Message, key: "Specifies_the_end_of_line_sequence_to_be_used_when_emitting_files_Colon_CRLF_dos_or_LF_unix_6060", message: "Specifies the end of line sequence to be used when emitting files: 'CRLF' (dos) or 'LF' (unix)." }, + NEWLINE: { code: 6061, category: ts.DiagnosticCategory.Message, key: "NEWLINE_6061", message: "NEWLINE" }, + Argument_for_newLine_option_must_be_CRLF_or_LF: { code: 6062, category: ts.DiagnosticCategory.Error, key: "Argument_for_newLine_option_must_be_CRLF_or_LF_6062", message: "Argument for '--newLine' option must be 'CRLF' or 'LF'." }, + Argument_for_moduleResolution_option_must_be_node_or_classic: { code: 6063, category: ts.DiagnosticCategory.Error, key: "Argument_for_moduleResolution_option_must_be_node_or_classic_6063", message: "Argument for '--moduleResolution' option must be 'node' or 'classic'." }, + Specify_JSX_code_generation_Colon_preserve_or_react: { code: 6080, category: ts.DiagnosticCategory.Message, key: "Specify_JSX_code_generation_Colon_preserve_or_react_6080", message: "Specify JSX code generation: 'preserve' or 'react'" }, + Argument_for_jsx_must_be_preserve_or_react: { code: 6081, category: ts.DiagnosticCategory.Message, key: "Argument_for_jsx_must_be_preserve_or_react_6081", message: "Argument for '--jsx' must be 'preserve' or 'react'." }, + Enables_experimental_support_for_ES7_decorators: { code: 6065, category: ts.DiagnosticCategory.Message, key: "Enables_experimental_support_for_ES7_decorators_6065", message: "Enables experimental support for ES7 decorators." }, + Enables_experimental_support_for_emitting_type_metadata_for_decorators: { code: 6066, category: ts.DiagnosticCategory.Message, key: "Enables_experimental_support_for_emitting_type_metadata_for_decorators_6066", message: "Enables experimental support for emitting type metadata for decorators." }, + Enables_experimental_support_for_ES7_async_functions: { code: 6068, category: ts.DiagnosticCategory.Message, key: "Enables_experimental_support_for_ES7_async_functions_6068", message: "Enables experimental support for ES7 async functions." }, + Specifies_module_resolution_strategy_Colon_node_Node_js_or_classic_TypeScript_pre_1_6: { code: 6069, category: ts.DiagnosticCategory.Message, key: "Specifies_module_resolution_strategy_Colon_node_Node_js_or_classic_TypeScript_pre_1_6_6069", message: "Specifies module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6)." }, + Initializes_a_TypeScript_project_and_creates_a_tsconfig_json_file: { code: 6070, category: ts.DiagnosticCategory.Message, key: "Initializes_a_TypeScript_project_and_creates_a_tsconfig_json_file_6070", message: "Initializes a TypeScript project and creates a tsconfig.json file." }, + Successfully_created_a_tsconfig_json_file: { code: 6071, category: ts.DiagnosticCategory.Message, key: "Successfully_created_a_tsconfig_json_file_6071", message: "Successfully created a tsconfig.json file." }, + Suppress_excess_property_checks_for_object_literals: { code: 6072, category: ts.DiagnosticCategory.Message, key: "Suppress_excess_property_checks_for_object_literals_6072", message: "Suppress excess property checks for object literals." }, + Disallow_inconsistently_cased_references_to_the_same_file: { code: 6073, category: ts.DiagnosticCategory.Message, key: "Disallow_inconsistently_cased_references_to_the_same_file_6073", message: "Disallow inconsistently-cased references to the same 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." }, + new_expression_whose_target_lacks_a_construct_signature_implicitly_has_an_any_type: { code: 7009, category: ts.DiagnosticCategory.Error, key: "new_expression_whose_target_lacks_a_construct_signature_implicitly_has_an_any_type_7009", message: "'new' expression, whose target lacks a construct signature, implicitly has an 'any' type." }, + _0_which_lacks_return_type_annotation_implicitly_has_an_1_return_type: { code: 7010, category: ts.DiagnosticCategory.Error, key: "_0_which_lacks_return_type_annotation_implicitly_has_an_1_return_type_7010", message: "'{0}', which lacks return-type annotation, implicitly has an '{1}' return type." }, + Function_expression_which_lacks_return_type_annotation_implicitly_has_an_0_return_type: { code: 7011, category: ts.DiagnosticCategory.Error, key: "Function_expression_which_lacks_return_type_annotation_implicitly_has_an_0_return_type_7011", message: "Function expression, which lacks return-type annotation, implicitly has an '{0}' return type." }, + Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type: { code: 7013, category: ts.DiagnosticCategory.Error, key: "Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type_7013", message: "Construct signature, which lacks return-type annotation, implicitly has an 'any' return type." }, + Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_type_annotation: { code: 7016, category: ts.DiagnosticCategory.Error, key: "Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_type_annotation_7016", message: "Property '{0}' implicitly has type 'any', because its 'set' accessor lacks a type annotation." }, + Index_signature_of_object_type_implicitly_has_an_any_type: { code: 7017, category: ts.DiagnosticCategory.Error, key: "Index_signature_of_object_type_implicitly_has_an_any_type_7017", message: "Index signature of object type implicitly has an 'any' type." }, + Object_literal_s_property_0_implicitly_has_an_1_type: { code: 7018, category: ts.DiagnosticCategory.Error, key: "Object_literal_s_property_0_implicitly_has_an_1_type_7018", message: "Object literal's property '{0}' implicitly has an '{1}' type." }, + Rest_parameter_0_implicitly_has_an_any_type: { code: 7019, category: ts.DiagnosticCategory.Error, key: "Rest_parameter_0_implicitly_has_an_any_type_7019", message: "Rest parameter '{0}' implicitly has an 'any[]' type." }, + Call_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type: { code: 7020, category: ts.DiagnosticCategory.Error, key: "Call_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type_7020", message: "Call signature, which lacks return-type annotation, implicitly has an 'any' return type." }, + _0_implicitly_has_type_any_because_it_does_not_have_a_type_annotation_and_is_referenced_directly_or_indirectly_in_its_own_initializer: { code: 7022, category: ts.DiagnosticCategory.Error, key: "_0_implicitly_has_type_any_because_it_does_not_have_a_type_annotation_and_is_referenced_directly_or__7022", message: "'{0}' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer." }, + _0_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions: { code: 7023, category: ts.DiagnosticCategory.Error, key: "_0_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_reference_7023", message: "'{0}' implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions." }, + Function_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions: { code: 7024, category: ts.DiagnosticCategory.Error, key: "Function_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_ref_7024", message: "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." }, + Generator_implicitly_has_type_0_because_it_does_not_yield_any_values_Consider_supplying_a_return_type: { code: 7025, category: ts.DiagnosticCategory.Error, key: "Generator_implicitly_has_type_0_because_it_does_not_yield_any_values_Consider_supplying_a_return_typ_7025", message: "Generator implicitly has type '{0}' because it does not yield any values. Consider supplying a return type." }, + JSX_element_implicitly_has_type_any_because_no_interface_JSX_0_exists: { code: 7026, category: ts.DiagnosticCategory.Error, key: "JSX_element_implicitly_has_type_any_because_no_interface_JSX_0_exists_7026", message: "JSX element implicitly has type 'any' because no interface 'JSX.{0}' exists" }, + 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." }, + export_can_only_be_used_in_a_ts_file: { code: 8003, category: ts.DiagnosticCategory.Error, key: "export_can_only_be_used_in_a_ts_file_8003", message: "'export=' can only be used in a .ts file." }, + type_parameter_declarations_can_only_be_used_in_a_ts_file: { code: 8004, category: ts.DiagnosticCategory.Error, key: "type_parameter_declarations_can_only_be_used_in_a_ts_file_8004", message: "'type parameter declarations' can only be used in a .ts file." }, + implements_clauses_can_only_be_used_in_a_ts_file: { code: 8005, category: ts.DiagnosticCategory.Error, key: "implements_clauses_can_only_be_used_in_a_ts_file_8005", message: "'implements clauses' can only be used in a .ts file." }, + interface_declarations_can_only_be_used_in_a_ts_file: { code: 8006, category: ts.DiagnosticCategory.Error, key: "interface_declarations_can_only_be_used_in_a_ts_file_8006", message: "'interface declarations' can only be used in a .ts file." }, + module_declarations_can_only_be_used_in_a_ts_file: { code: 8007, category: ts.DiagnosticCategory.Error, key: "module_declarations_can_only_be_used_in_a_ts_file_8007", message: "'module declarations' can only be used in a .ts file." }, + type_aliases_can_only_be_used_in_a_ts_file: { code: 8008, category: ts.DiagnosticCategory.Error, key: "type_aliases_can_only_be_used_in_a_ts_file_8008", message: "'type aliases' can only be used in a .ts file." }, + _0_can_only_be_used_in_a_ts_file: { code: 8009, category: ts.DiagnosticCategory.Error, key: "_0_can_only_be_used_in_a_ts_file_8009", message: "'{0}' can only be used in a .ts file." }, + types_can_only_be_used_in_a_ts_file: { code: 8010, category: ts.DiagnosticCategory.Error, key: "types_can_only_be_used_in_a_ts_file_8010", message: "'types' can only be used in a .ts file." }, + type_arguments_can_only_be_used_in_a_ts_file: { code: 8011, category: ts.DiagnosticCategory.Error, key: "type_arguments_can_only_be_used_in_a_ts_file_8011", message: "'type arguments' can only be used in a .ts file." }, + parameter_modifiers_can_only_be_used_in_a_ts_file: { code: 8012, category: ts.DiagnosticCategory.Error, key: "parameter_modifiers_can_only_be_used_in_a_ts_file_8012", message: "'parameter modifiers' can only be used in a .ts file." }, + property_declarations_can_only_be_used_in_a_ts_file: { code: 8014, category: ts.DiagnosticCategory.Error, key: "property_declarations_can_only_be_used_in_a_ts_file_8014", message: "'property declarations' can only be used in a .ts file." }, + enum_declarations_can_only_be_used_in_a_ts_file: { code: 8015, category: ts.DiagnosticCategory.Error, key: "enum_declarations_can_only_be_used_in_a_ts_file_8015", message: "'enum declarations' can only be used in a .ts file." }, + type_assertion_expressions_can_only_be_used_in_a_ts_file: { code: 8016, category: ts.DiagnosticCategory.Error, key: "type_assertion_expressions_can_only_be_used_in_a_ts_file_8016", message: "'type assertion expressions' can only be used in a .ts file." }, + decorators_can_only_be_used_in_a_ts_file: { code: 8017, category: ts.DiagnosticCategory.Error, key: "decorators_can_only_be_used_in_a_ts_file_8017", message: "'decorators' can only be used in a .ts file." }, + Only_identifiers_Slashqualified_names_with_optional_type_arguments_are_currently_supported_in_a_class_extends_clauses: { code: 9002, category: ts.DiagnosticCategory.Error, key: "Only_identifiers_Slashqualified_names_with_optional_type_arguments_are_currently_supported_in_a_clas_9002", message: "Only identifiers/qualified-names with optional type arguments are currently supported in a class 'extends' clauses." }, + class_expressions_are_not_currently_supported: { code: 9003, category: ts.DiagnosticCategory.Error, key: "class_expressions_are_not_currently_supported_9003", message: "'class' expressions are not currently supported." }, + JSX_attributes_must_only_be_assigned_a_non_empty_expression: { code: 17000, category: ts.DiagnosticCategory.Error, key: "JSX_attributes_must_only_be_assigned_a_non_empty_expression_17000", message: "JSX attributes must only be assigned a non-empty 'expression'." }, + JSX_elements_cannot_have_multiple_attributes_with_the_same_name: { code: 17001, category: ts.DiagnosticCategory.Error, key: "JSX_elements_cannot_have_multiple_attributes_with_the_same_name_17001", message: "JSX elements cannot have multiple attributes with the same name." }, + Expected_corresponding_JSX_closing_tag_for_0: { code: 17002, category: ts.DiagnosticCategory.Error, key: "Expected_corresponding_JSX_closing_tag_for_0_17002", message: "Expected corresponding JSX closing tag for '{0}'." }, + JSX_attribute_expected: { code: 17003, category: ts.DiagnosticCategory.Error, key: "JSX_attribute_expected_17003", message: "JSX attribute expected." }, + Cannot_use_JSX_unless_the_jsx_flag_is_provided: { code: 17004, category: ts.DiagnosticCategory.Error, key: "Cannot_use_JSX_unless_the_jsx_flag_is_provided_17004", message: "Cannot use JSX unless the '--jsx' flag is provided." }, + A_constructor_cannot_contain_a_super_call_when_its_class_extends_null: { code: 17005, category: ts.DiagnosticCategory.Error, key: "A_constructor_cannot_contain_a_super_call_when_its_class_extends_null_17005", message: "A constructor cannot contain a 'super' call when its class extends 'null'" }, + An_unary_expression_with_the_0_operator_is_not_allowed_in_the_left_hand_side_of_an_exponentiation_expression_Consider_enclosing_the_expression_in_parentheses: { code: 17006, category: ts.DiagnosticCategory.Error, key: "An_unary_expression_with_the_0_operator_is_not_allowed_in_the_left_hand_side_of_an_exponentiation_ex_17006", message: "An unary expression with the '{0}' operator is not allowed in the left-hand side of an exponentiation expression. Consider enclosing the expression in parentheses." }, + A_type_assertion_expression_is_not_allowed_in_the_left_hand_side_of_an_exponentiation_expression_Consider_enclosing_the_expression_in_parentheses: { code: 17007, category: ts.DiagnosticCategory.Error, key: "A_type_assertion_expression_is_not_allowed_in_the_left_hand_side_of_an_exponentiation_expression_Con_17007", message: "A type assertion expression is not allowed in the left-hand side of an exponentiation expression. Consider enclosing the expression in parentheses." } + }; +})(ts || (ts = {})); +/// +/// +var ts; +(function (ts) { + /* @internal */ + function tokenIsIdentifierOrKeyword(token) { + return token >= 69 /* Identifier */; + } + ts.tokenIsIdentifierOrKeyword = tokenIsIdentifierOrKeyword; + var textToToken = { + "abstract": 115 /* AbstractKeyword */, + "any": 117 /* AnyKeyword */, + "as": 116 /* AsKeyword */, + "boolean": 120 /* BooleanKeyword */, + "break": 70 /* BreakKeyword */, + "case": 71 /* CaseKeyword */, + "catch": 72 /* CatchKeyword */, + "class": 73 /* ClassKeyword */, + "continue": 75 /* ContinueKeyword */, + "const": 74 /* ConstKeyword */, + "constructor": 121 /* ConstructorKeyword */, + "debugger": 76 /* DebuggerKeyword */, + "declare": 122 /* DeclareKeyword */, + "default": 77 /* DefaultKeyword */, + "delete": 78 /* DeleteKeyword */, + "do": 79 /* DoKeyword */, + "else": 80 /* ElseKeyword */, + "enum": 81 /* EnumKeyword */, + "export": 82 /* ExportKeyword */, + "extends": 83 /* ExtendsKeyword */, + "false": 84 /* FalseKeyword */, + "finally": 85 /* FinallyKeyword */, + "for": 86 /* ForKeyword */, + "from": 133 /* FromKeyword */, + "function": 87 /* FunctionKeyword */, + "get": 123 /* GetKeyword */, + "if": 88 /* IfKeyword */, + "implements": 106 /* ImplementsKeyword */, + "import": 89 /* ImportKeyword */, + "in": 90 /* InKeyword */, + "instanceof": 91 /* InstanceOfKeyword */, + "interface": 107 /* InterfaceKeyword */, + "is": 124 /* IsKeyword */, + "let": 108 /* LetKeyword */, + "module": 125 /* ModuleKeyword */, + "namespace": 126 /* NamespaceKeyword */, + "new": 92 /* NewKeyword */, + "null": 93 /* NullKeyword */, + "number": 128 /* NumberKeyword */, + "package": 109 /* PackageKeyword */, + "private": 110 /* PrivateKeyword */, + "protected": 111 /* ProtectedKeyword */, + "public": 112 /* PublicKeyword */, + "require": 127 /* RequireKeyword */, + "return": 94 /* ReturnKeyword */, + "set": 129 /* SetKeyword */, + "static": 113 /* StaticKeyword */, + "string": 130 /* StringKeyword */, + "super": 95 /* SuperKeyword */, + "switch": 96 /* SwitchKeyword */, + "symbol": 131 /* SymbolKeyword */, + "this": 97 /* ThisKeyword */, + "throw": 98 /* ThrowKeyword */, + "true": 99 /* TrueKeyword */, + "try": 100 /* TryKeyword */, + "type": 132 /* TypeKeyword */, + "typeof": 101 /* TypeOfKeyword */, + "var": 102 /* VarKeyword */, + "void": 103 /* VoidKeyword */, + "while": 104 /* WhileKeyword */, + "with": 105 /* WithKeyword */, + "yield": 114 /* YieldKeyword */, + "async": 118 /* AsyncKeyword */, + "await": 119 /* AwaitKeyword */, + "of": 134 /* OfKeyword */, + "{": 15 /* OpenBraceToken */, + "}": 16 /* CloseBraceToken */, + "(": 17 /* OpenParenToken */, + ")": 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 */ + }; + /* + As per ECMAScript Language Specification 3th Edition, Section 7.6: Identifiers + IdentifierStart :: + Can contain Unicode 3.0.0 categories: + Uppercase letter (Lu), + Lowercase letter (Ll), + Titlecase letter (Lt), + Modifier letter (Lm), + Other letter (Lo), or + Letter number (Nl). + IdentifierPart :: = + Can contain IdentifierStart + Unicode 3.0.0 categories: + Non-spacing mark (Mn), + Combining spacing mark (Mc), + Decimal number (Nd), or + Connector punctuation (Pc). + + Codepoint ranges for ES3 Identifiers are extracted from the Unicode 3.0.0 specification at: + http://www.unicode.org/Public/3.0-Update/UnicodeData-3.0.0.txt + */ + 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,]; + /* + As per ECMAScript Language Specification 5th Edition, Section 7.6: ISyntaxToken Names and Identifiers + IdentifierStart :: + Can contain Unicode 6.2 categories: + Uppercase letter (Lu), + Lowercase letter (Ll), + Titlecase letter (Lt), + Modifier letter (Lm), + Other letter (Lo), or + Letter number (Nl). + IdentifierPart :: + Can contain IdentifierStart + Unicode 6.2 categories: + Non-spacing mark (Mn), + Combining spacing mark (Mc), + Decimal number (Nd), + Connector punctuation (Pc), + , or + . + + Codepoint ranges for ES5 Identifiers are extracted from the Unicode 6.2 specification at: + http://www.unicode.org/Public/6.2.0/ucd/UnicodeData.txt + */ + 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) { + // Bail out quickly if it couldn't possibly be in the map. + if (code < map[0]) { + return false; + } + // Perform binary search in one of the Unicode range maps + var lo = 0; + var hi = map.length; + var mid; + while (lo + 1 < hi) { + mid = lo + (hi - lo) / 2; + // mid has to be even to catch a range's beginning + 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; + } + /* @internal */ function isUnicodeIdentifierStart(code, languageVersion) { + return languageVersion >= 1 /* ES5 */ ? + lookupInUnicodeMap(code, unicodeES5IdentifierStart) : + lookupInUnicodeMap(code, unicodeES3IdentifierStart); + } + ts.isUnicodeIdentifierStart = isUnicodeIdentifierStart; + function isUnicodeIdentifierPart(code, languageVersion) { + return languageVersion >= 1 /* ES5 */ ? + lookupInUnicodeMap(code, unicodeES5IdentifierPart) : + lookupInUnicodeMap(code, unicodeES3IdentifierPart); + } + function makeReverseMap(source) { + var result = []; + for (var name_4 in source) { + if (source.hasOwnProperty(name_4)) { + result[source[name_4]] = name_4; + } + } + return result; + } + var tokenStrings = makeReverseMap(textToToken); + function tokenToString(t) { + return tokenStrings[t]; + } + ts.tokenToString = tokenToString; + /* @internal */ + function stringToToken(s) { + return textToToken[s]; + } + ts.stringToToken = stringToToken; + /* @internal */ + function computeLineStarts(text) { + var result = new Array(); + var pos = 0; + var lineStart = 0; + while (pos < text.length) { + var ch = text.charCodeAt(pos++); + switch (ch) { + case 13 /* carriageReturn */: + if (text.charCodeAt(pos) === 10 /* lineFeed */) { + pos++; + } + case 10 /* lineFeed */: + result.push(lineStart); + lineStart = pos; + break; + default: + if (ch > 127 /* maxAsciiCharacter */ && 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; + /* @internal */ + function computePositionOfLineAndCharacter(lineStarts, line, character) { + ts.Debug.assert(line >= 0 && line < lineStarts.length); + return lineStarts[line] + character; + } + ts.computePositionOfLineAndCharacter = computePositionOfLineAndCharacter; + /* @internal */ + function getLineStarts(sourceFile) { + return sourceFile.lineMap || (sourceFile.lineMap = computeLineStarts(sourceFile.text)); + } + ts.getLineStarts = getLineStarts; + /* @internal */ + /** + * We assume the first line starts at position 0 and 'position' is non-negative. + */ + function computeLineAndCharacterOfPosition(lineStarts, position) { + var lineNumber = ts.binarySearch(lineStarts, position); + if (lineNumber < 0) { + // If the actual position was not found, + // the binary search returns the 2's-complement of the next line start + // e.g. if the line starts at [5, 10, 23, 80] and the position requested was 20 + // then the search will return -2. + // + // We want the index of the previous line start, so we subtract 1. + // Review 2's-complement if this is confusing. + 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) { + // Note: nextLine is in the Zs space, and should be considered to be a whitespace. + // It is explicitly not a line-break as it isn't in the exact set specified by EcmaScript. + return ch === 32 /* space */ || + ch === 9 /* tab */ || + ch === 11 /* verticalTab */ || + ch === 12 /* formFeed */ || + ch === 160 /* nonBreakingSpace */ || + ch === 133 /* nextLine */ || + ch === 5760 /* ogham */ || + ch >= 8192 /* enQuad */ && ch <= 8203 /* zeroWidthSpace */ || + ch === 8239 /* narrowNoBreakSpace */ || + ch === 8287 /* mathematicalSpace */ || + ch === 12288 /* ideographicSpace */ || + ch === 65279 /* byteOrderMark */; + } + ts.isWhiteSpace = isWhiteSpace; + function isLineBreak(ch) { + // ES5 7.3: + // The ECMAScript line terminator characters are listed in Table 3. + // Table 3: Line Terminator Characters + // Code Unit Value Name Formal Name + // \u000A Line Feed + // \u000D Carriage Return + // \u2028 Line separator + // \u2029 Paragraph separator + // Only the characters in Table 3 are treated as line terminators. Other new line or line + // breaking characters are treated as white space but not as line terminators. + return ch === 10 /* lineFeed */ || + ch === 13 /* carriageReturn */ || + ch === 8232 /* lineSeparator */ || + ch === 8233 /* paragraphSeparator */; + } + ts.isLineBreak = isLineBreak; + function isDigit(ch) { + return ch >= 48 /* _0 */ && ch <= 57 /* _9 */; + } + /* @internal */ + function isOctalDigit(ch) { + return ch >= 48 /* _0 */ && ch <= 55 /* _7 */; + } + ts.isOctalDigit = isOctalDigit; + function couldStartTrivia(text, pos) { + // Keep in sync with skipTrivia + var ch = text.charCodeAt(pos); + switch (ch) { + case 13 /* carriageReturn */: + case 10 /* lineFeed */: + case 9 /* tab */: + case 11 /* verticalTab */: + case 12 /* formFeed */: + case 32 /* space */: + case 47 /* slash */: + // starts of normal trivia + case 60 /* lessThan */: + case 61 /* equals */: + case 62 /* greaterThan */: + // Starts of conflict marker trivia + return true; + case 35 /* hash */: + // Only if its the beginning can we have #! trivia + return pos === 0; + default: + return ch > 127 /* maxAsciiCharacter */; + } + } + ts.couldStartTrivia = couldStartTrivia; + /* @internal */ + function skipTrivia(text, pos, stopAfterLineBreak) { + // Keep in sync with couldStartTrivia + while (true) { + var ch = text.charCodeAt(pos); + switch (ch) { + case 13 /* carriageReturn */: + if (text.charCodeAt(pos + 1) === 10 /* lineFeed */) { + pos++; + } + case 10 /* lineFeed */: + pos++; + if (stopAfterLineBreak) { + return pos; + } + continue; + case 9 /* tab */: + case 11 /* verticalTab */: + case 12 /* formFeed */: + case 32 /* space */: + pos++; + continue; + case 47 /* slash */: + if (text.charCodeAt(pos + 1) === 47 /* slash */) { + pos += 2; + while (pos < text.length) { + if (isLineBreak(text.charCodeAt(pos))) { + break; + } + pos++; + } + continue; + } + if (text.charCodeAt(pos + 1) === 42 /* asterisk */) { + pos += 2; + while (pos < text.length) { + if (text.charCodeAt(pos) === 42 /* asterisk */ && text.charCodeAt(pos + 1) === 47 /* slash */) { + pos += 2; + break; + } + pos++; + } + continue; + } + break; + case 60 /* lessThan */: + case 61 /* equals */: + case 62 /* greaterThan */: + if (isConflictMarkerTrivia(text, pos)) { + pos = scanConflictMarkerTrivia(text, pos); + continue; + } + break; + case 35 /* hash */: + if (pos === 0 && isShebangTrivia(text, pos)) { + pos = scanShebangTrivia(text, pos); + continue; + } + break; + default: + if (ch > 127 /* maxAsciiCharacter */ && (isWhiteSpace(ch) || isLineBreak(ch))) { + pos++; + continue; + } + break; + } + return pos; + } + } + ts.skipTrivia = skipTrivia; + // All conflict markers consist of the same character repeated seven times. If it is + // a <<<<<<< or >>>>>>> marker then it is also followd by a space. + var mergeConflictMarkerLength = "<<<<<<<".length; + function isConflictMarkerTrivia(text, pos) { + ts.Debug.assert(pos >= 0); + // Conflict markers must be at the start of a line. + 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 /* equals */ || + text.charCodeAt(pos + mergeConflictMarkerLength) === 32 /* space */; + } + } + 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 /* lessThan */ || ch === 62 /* greaterThan */) { + while (pos < len && !isLineBreak(text.charCodeAt(pos))) { + pos++; + } + } + else { + ts.Debug.assert(ch === 61 /* equals */); + // Consume everything from the start of the mid-conlict marker to the start of the next + // end-conflict marker. + while (pos < len) { + var ch_1 = text.charCodeAt(pos); + if (ch_1 === 62 /* greaterThan */ && isConflictMarkerTrivia(text, pos)) { + break; + } + pos++; + } + } + return pos; + } + var shebangTriviaRegex = /^#!.*/; + function isShebangTrivia(text, pos) { + // Shebangs check must only be done at the start of the file + 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; + } + /** + * Extract comments from text prefixing the token closest following `pos`. + * The return value is an array containing a TextRange for each comment. + * Single-line comment ranges include the beginning '//' characters but not the ending line break. + * Multi - line comment ranges include the beginning '/* and ending '/' characters. + * The return value is undefined if no comments were found. + * @param trailing + * If false, whitespace is skipped until the first line break and comments between that location + * and the next token are returned. + * If true, comments occurring between the given position and the next line break are returned. + */ + function getCommentRanges(text, pos, trailing) { + var result; + var collecting = trailing || pos === 0; + while (true) { + var ch = text.charCodeAt(pos); + switch (ch) { + case 13 /* carriageReturn */: + if (text.charCodeAt(pos + 1) === 10 /* lineFeed */) { + pos++; + } + case 10 /* lineFeed */: + pos++; + if (trailing) { + return result; + } + collecting = true; + if (result && result.length) { + ts.lastOrUndefined(result).hasTrailingNewLine = true; + } + continue; + case 9 /* tab */: + case 11 /* verticalTab */: + case 12 /* formFeed */: + case 32 /* space */: + pos++; + continue; + case 47 /* slash */: + var nextChar = text.charCodeAt(pos + 1); + var hasTrailingNewLine = false; + if (nextChar === 47 /* slash */ || nextChar === 42 /* asterisk */) { + var kind = nextChar === 47 /* slash */ ? 2 /* SingleLineCommentTrivia */ : 3 /* MultiLineCommentTrivia */; + var startPos = pos; + pos += 2; + if (nextChar === 47 /* slash */) { + while (pos < text.length) { + if (isLineBreak(text.charCodeAt(pos))) { + hasTrailingNewLine = true; + break; + } + pos++; + } + } + else { + while (pos < text.length) { + if (text.charCodeAt(pos) === 42 /* asterisk */ && text.charCodeAt(pos + 1) === 47 /* slash */) { + pos += 2; + break; + } + pos++; + } + } + if (collecting) { + if (!result) { + result = []; + } + result.push({ pos: startPos, end: pos, hasTrailingNewLine: hasTrailingNewLine, kind: kind }); + } + continue; + } + break; + default: + if (ch > 127 /* maxAsciiCharacter */ && (isWhiteSpace(ch) || isLineBreak(ch))) { + if (result && result.length && isLineBreak(ch)) { + ts.lastOrUndefined(result).hasTrailingNewLine = true; + } + pos++; + continue; + } + break; + } + return result; + } + } + function getLeadingCommentRanges(text, pos) { + return getCommentRanges(text, pos, /*trailing*/ false); + } + ts.getLeadingCommentRanges = getLeadingCommentRanges; + function getTrailingCommentRanges(text, pos) { + return getCommentRanges(text, pos, /*trailing*/ true); + } + ts.getTrailingCommentRanges = getTrailingCommentRanges; + /** Optionally, get the shebang */ + function getShebang(text) { + return shebangTriviaRegex.test(text) + ? shebangTriviaRegex.exec(text)[0] + : undefined; + } + ts.getShebang = getShebang; + function isIdentifierStart(ch, languageVersion) { + return ch >= 65 /* A */ && ch <= 90 /* Z */ || ch >= 97 /* a */ && ch <= 122 /* z */ || + ch === 36 /* $ */ || ch === 95 /* _ */ || + ch > 127 /* maxAsciiCharacter */ && isUnicodeIdentifierStart(ch, languageVersion); + } + ts.isIdentifierStart = isIdentifierStart; + function isIdentifierPart(ch, languageVersion) { + return ch >= 65 /* A */ && ch <= 90 /* Z */ || ch >= 97 /* a */ && ch <= 122 /* z */ || + ch >= 48 /* _0 */ && ch <= 57 /* _9 */ || ch === 36 /* $ */ || ch === 95 /* _ */ || + ch > 127 /* maxAsciiCharacter */ && isUnicodeIdentifierPart(ch, languageVersion); + } + ts.isIdentifierPart = isIdentifierPart; + // Creates a scanner over a (possibly unspecified) range of a piece of text. + function createScanner(languageVersion, skipTrivia, languageVariant, text, onError, start, length) { + if (languageVariant === void 0) { languageVariant = 0 /* Standard */; } + // Current position (end position of text of current token) + var pos; + // end of text + var end; + // Start position of whitespace before current token + var startPos; + // Start position of text of current token + 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 /* Identifier */ || token > 105 /* LastReservedWord */; }, + isReservedWord: function () { return token >= 70 /* FirstReservedWord */ && token <= 105 /* LastReservedWord */; }, + isUnterminated: function () { return tokenIsUnterminated; }, + reScanGreaterToken: reScanGreaterToken, + reScanSlashToken: reScanSlashToken, + reScanTemplateToken: reScanTemplateToken, + scanJsxIdentifier: scanJsxIdentifier, + reScanJsxToken: reScanJsxToken, + scanJsxToken: scanJsxToken, + scan: scan, + setText: setText, + setScriptTarget: setScriptTarget, + setLanguageVariant: setLanguageVariant, + setOnError: setOnError, + setTextPos: setTextPos, + tryScan: tryScan, + lookAhead: lookAhead + }; + 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 /* dot */) { + pos++; + while (isDigit(text.charCodeAt(pos))) + pos++; + } + var end = pos; + if (text.charCodeAt(pos) === 69 /* E */ || text.charCodeAt(pos) === 101 /* e */) { + pos++; + if (text.charCodeAt(pos) === 43 /* plus */ || text.charCodeAt(pos) === 45 /* minus */) + 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)); + } + /** + * Scans the given number of hexadecimal digits in the text, + * returning -1 if the given number is unavailable. + */ + function scanExactNumberOfHexDigits(count) { + return scanHexDigits(/*minCount*/ count, /*scanAsManyAsPossible*/ false); + } + /** + * Scans as many hexadecimal digits as are available in the text, + * returning -1 if the given number of digits was unavailable. + */ + function scanMinimumNumberOfHexDigits(count) { + return scanHexDigits(/*minCount*/ count, /*scanAsManyAsPossible*/ true); + } + function scanHexDigits(minCount, scanAsManyAsPossible) { + var digits = 0; + var value = 0; + while (digits < minCount || scanAsManyAsPossible) { + var ch = text.charCodeAt(pos); + if (ch >= 48 /* _0 */ && ch <= 57 /* _9 */) { + value = value * 16 + ch - 48 /* _0 */; + } + else if (ch >= 65 /* A */ && ch <= 70 /* F */) { + value = value * 16 + ch - 65 /* A */ + 10; + } + else if (ch >= 97 /* a */ && ch <= 102 /* f */) { + value = value * 16 + ch - 97 /* a */ + 10; + } + else { + break; + } + pos++; + digits++; + } + if (digits < minCount) { + value = -1; + } + return value; + } + function scanString() { + var quote = text.charCodeAt(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 /* backslash */) { + 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; + } + /** + * Sets the current 'tokenValue' and returns a NoSubstitutionTemplateLiteral or + * a literal component of a TemplateExpression. + */ + function scanTemplateAndSetTokenValue() { + var startedWithBacktick = text.charCodeAt(pos) === 96 /* backtick */; + 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 /* NoSubstitutionTemplateLiteral */ : 14 /* TemplateTail */; + break; + } + var currChar = text.charCodeAt(pos); + // '`' + if (currChar === 96 /* backtick */) { + contents += text.substring(start, pos); + pos++; + resultingToken = startedWithBacktick ? 11 /* NoSubstitutionTemplateLiteral */ : 14 /* 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 */; + break; + } + // Escape character + if (currChar === 92 /* backslash */) { + contents += text.substring(start, pos); + contents += scanEscapeSequence(); + start = pos; + continue; + } + // Speculated ECMAScript 6 Spec 11.8.6.1: + // and LineTerminatorSequences are normalized to for Template Values + if (currChar === 13 /* carriageReturn */) { + contents += text.substring(start, pos); + pos++; + if (pos < end && text.charCodeAt(pos) === 10 /* lineFeed */) { + 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++); + switch (ch) { + case 48 /* _0 */: + return "\0"; + case 98 /* b */: + return "\b"; + case 116 /* t */: + return "\t"; + case 110 /* n */: + return "\n"; + case 118 /* v */: + return "\v"; + case 102 /* f */: + return "\f"; + case 114 /* r */: + return "\r"; + case 39 /* singleQuote */: + return "\'"; + case 34 /* doubleQuote */: + return "\""; + case 117 /* u */: + // '\u{DDDDDDDD}' + if (pos < end && text.charCodeAt(pos) === 123 /* openBrace */) { + hasExtendedUnicodeEscape = true; + pos++; + return scanExtendedUnicodeEscape(); + } + // '\uDDDD' + return scanHexadecimalEscape(/*numDigits*/ 4); + case 120 /* x */: + // '\xDD' + return scanHexadecimalEscape(/*numDigits*/ 2); + // when encountering a LineContinuation (i.e. a backslash and a line terminator sequence), + // the line terminator is interpreted to be "the empty code unit sequence". + case 13 /* carriageReturn */: + if (pos < end && text.charCodeAt(pos) === 10 /* lineFeed */) { + pos++; + } + // fall through + case 10 /* lineFeed */: + case 8232 /* lineSeparator */: + case 8233 /* paragraphSeparator */: + 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; + // Validate the value of the digit + 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 /* closeBrace */) { + // Only swallow the following character up if it's a '}'. + pos++; + } + else { + error(ts.Diagnostics.Unterminated_Unicode_escape_sequence); + isInvalidExtendedEscape = true; + } + if (isInvalidExtendedEscape) { + return ""; + } + return utf16EncodeAsString(escapedValue); + } + // Derived from the 10.1.1 UTF16Encoding of the ES6 Spec. + 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); + } + // Current character is known to be a backslash. Check for Unicode escape of the form '\uXXXX' + // and return code point value if valid Unicode escape is found. Otherwise return -1. + function peekUnicodeEscape() { + if (pos + 5 < end && text.charCodeAt(pos + 1) === 117 /* u */) { + 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 /* backslash */) { + ch = peekUnicodeEscape(); + if (!(ch >= 0 && isIdentifierPart(ch, languageVersion))) { + break; + } + result += text.substring(start, pos); + result += String.fromCharCode(ch); + // Valid Unicode escape is always six characters + pos += 6; + start = pos; + } + else { + break; + } + } + result += text.substring(start, pos); + return result; + } + function getIdentifierToken() { + // Reserved words are between 2 and 11 characters long and start with a lowercase letter + var len = tokenValue.length; + if (len >= 2 && len <= 11) { + var ch = tokenValue.charCodeAt(0); + if (ch >= 97 /* a */ && ch <= 122 /* z */ && hasOwnProperty.call(textToToken, tokenValue)) { + return token = textToToken[tokenValue]; + } + } + return token = 69 /* Identifier */; + } + function scanBinaryOrOctalDigits(base) { + 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. + var numberOfDigits = 0; + while (true) { + var ch = text.charCodeAt(pos); + var valueOfCh = ch - 48 /* _0 */; + if (!isDigit(ch) || valueOfCh >= base) { + break; + } + value = value * base + valueOfCh; + pos++; + numberOfDigits++; + } + // Invalid binaryIntegerLiteral or octalIntegerLiteral + 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 /* EndOfFileToken */; + } + var ch = text.charCodeAt(pos); + // Special handling for shebang + if (ch === 35 /* hash */ && pos === 0 && isShebangTrivia(text, pos)) { + pos = scanShebangTrivia(text, pos); + if (skipTrivia) { + continue; + } + else { + return token = 6 /* ShebangTrivia */; + } + } + switch (ch) { + case 10 /* lineFeed */: + case 13 /* carriageReturn */: + precedingLineBreak = true; + if (skipTrivia) { + pos++; + continue; + } + else { + if (ch === 13 /* carriageReturn */ && pos + 1 < end && text.charCodeAt(pos + 1) === 10 /* lineFeed */) { + // consume both CR and LF + pos += 2; + } + else { + pos++; + } + return token = 4 /* NewLineTrivia */; + } + case 9 /* tab */: + case 11 /* verticalTab */: + case 12 /* formFeed */: + case 32 /* space */: + if (skipTrivia) { + pos++; + continue; + } + else { + while (pos < end && isWhiteSpace(text.charCodeAt(pos))) { + pos++; + } + return token = 5 /* WhitespaceTrivia */; + } + 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 += 2, token = 31 /* ExclamationEqualsToken */; + } + return pos++, token = 49 /* ExclamationToken */; + case 34 /* doubleQuote */: + case 39 /* singleQuote */: + tokenValue = scanString(); + return token = 9 /* StringLiteral */; + case 96 /* backtick */: + return token = scanTemplateAndSetTokenValue(); + case 37 /* percent */: + if (text.charCodeAt(pos + 1) === 61 /* equals */) { + return pos += 2, token = 62 /* PercentEqualsToken */; + } + return pos++, token = 40 /* PercentToken */; + case 38 /* ampersand */: + if (text.charCodeAt(pos + 1) === 38 /* ampersand */) { + return pos += 2, token = 51 /* AmpersandAmpersandToken */; + } + if (text.charCodeAt(pos + 1) === 61 /* equals */) { + return pos += 2, token = 66 /* AmpersandEqualsToken */; + } + return pos++, token = 46 /* AmpersandToken */; + case 40 /* openParen */: + return pos++, token = 17 /* OpenParenToken */; + case 41 /* closeParen */: + return pos++, token = 18 /* CloseParenToken */; + case 42 /* asterisk */: + if (text.charCodeAt(pos + 1) === 61 /* equals */) { + return pos += 2, token = 59 /* AsteriskEqualsToken */; + } + if (text.charCodeAt(pos + 1) === 42 /* asterisk */) { + if (text.charCodeAt(pos + 2) === 61 /* equals */) { + return pos += 3, token = 60 /* AsteriskAsteriskEqualsToken */; + } + return pos += 2, token = 38 /* AsteriskAsteriskToken */; + } + return pos++, token = 37 /* AsteriskToken */; + case 43 /* plus */: + if (text.charCodeAt(pos + 1) === 43 /* plus */) { + return pos += 2, token = 41 /* PlusPlusToken */; + } + if (text.charCodeAt(pos + 1) === 61 /* equals */) { + return pos += 2, token = 57 /* PlusEqualsToken */; + } + return pos++, token = 35 /* PlusToken */; + case 44 /* comma */: + return pos++, token = 24 /* CommaToken */; + case 45 /* minus */: + if (text.charCodeAt(pos + 1) === 45 /* minus */) { + return pos += 2, token = 42 /* MinusMinusToken */; + } + if (text.charCodeAt(pos + 1) === 61 /* equals */) { + return pos += 2, token = 58 /* MinusEqualsToken */; + } + return pos++, token = 36 /* 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++, token = 21 /* DotToken */; + case 47 /* slash */: + // Single-line comment + if (text.charCodeAt(pos + 1) === 47 /* slash */) { + pos += 2; + while (pos < end) { + if (isLineBreak(text.charCodeAt(pos))) { + break; + } + pos++; + } + if (skipTrivia) { + continue; + } + else { + return token = 2 /* SingleLineCommentTrivia */; + } + } + // Multi-line comment + if (text.charCodeAt(pos + 1) === 42 /* asterisk */) { + pos += 2; + var commentClosed = false; + while (pos < end) { + var ch_2 = text.charCodeAt(pos); + if (ch_2 === 42 /* asterisk */ && text.charCodeAt(pos + 1) === 47 /* slash */) { + 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 /* MultiLineCommentTrivia */; + } + } + if (text.charCodeAt(pos + 1) === 61 /* equals */) { + return pos += 2, token = 61 /* SlashEqualsToken */; + } + return pos++, token = 39 /* SlashToken */; + case 48 /* _0 */: + if (pos + 2 < end && (text.charCodeAt(pos + 1) === 88 /* X */ || text.charCodeAt(pos + 1) === 120 /* x */)) { + pos += 2; + var value = scanMinimumNumberOfHexDigits(1); + if (value < 0) { + error(ts.Diagnostics.Hexadecimal_digit_expected); + value = 0; + } + tokenValue = "" + value; + return token = 8 /* NumericLiteral */; + } + else if (pos + 2 < end && (text.charCodeAt(pos + 1) === 66 /* B */ || text.charCodeAt(pos + 1) === 98 /* b */)) { + pos += 2; + var value = scanBinaryOrOctalDigits(/* base */ 2); + if (value < 0) { + error(ts.Diagnostics.Binary_digit_expected); + value = 0; + } + tokenValue = "" + value; + return token = 8 /* NumericLiteral */; + } + else if (pos + 2 < end && (text.charCodeAt(pos + 1) === 79 /* O */ || text.charCodeAt(pos + 1) === 111 /* o */)) { + pos += 2; + var value = scanBinaryOrOctalDigits(/* base */ 8); + if (value < 0) { + error(ts.Diagnostics.Octal_digit_expected); + value = 0; + } + tokenValue = "" + value; + return token = 8 /* NumericLiteral */; + } + // Try to parse as an octal + if (pos + 1 < end && isOctalDigit(text.charCodeAt(pos + 1))) { + tokenValue = "" + scanOctalDigits(); + return token = 8 /* NumericLiteral */; + } + // This fall-through is a deviation from the EcmaScript grammar. The grammar says that a leading zero + // can only be followed by an octal digit, a dot, or the end of the number literal. However, we are being + // permissive and allowing decimal digits of the form 08* and 09* (which many browsers also do). + case 49 /* _1 */: + case 50 /* _2 */: + case 51 /* _3 */: + case 52 /* _4 */: + case 53 /* _5 */: + case 54 /* _6 */: + case 55 /* _7 */: + case 56 /* _8 */: + case 57 /* _9 */: + tokenValue = "" + scanNumber(); + return token = 8 /* NumericLiteral */; + case 58 /* colon */: + return pos++, token = 54 /* ColonToken */; + case 59 /* semicolon */: + return pos++, token = 23 /* SemicolonToken */; + case 60 /* lessThan */: + if (isConflictMarkerTrivia(text, pos)) { + pos = scanConflictMarkerTrivia(text, pos, error); + if (skipTrivia) { + continue; + } + else { + return token = 7 /* ConflictMarkerTrivia */; + } + } + if (text.charCodeAt(pos + 1) === 60 /* lessThan */) { + if (text.charCodeAt(pos + 2) === 61 /* equals */) { + return pos += 3, token = 63 /* LessThanLessThanEqualsToken */; + } + return pos += 2, token = 43 /* LessThanLessThanToken */; + } + if (text.charCodeAt(pos + 1) === 61 /* equals */) { + return pos += 2, token = 28 /* 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++, token = 25 /* LessThanToken */; + case 61 /* equals */: + if (isConflictMarkerTrivia(text, pos)) { + pos = scanConflictMarkerTrivia(text, pos, error); + if (skipTrivia) { + continue; + } + else { + return token = 7 /* ConflictMarkerTrivia */; + } + } + if (text.charCodeAt(pos + 1) === 61 /* equals */) { + if (text.charCodeAt(pos + 2) === 61 /* equals */) { + return pos += 3, token = 32 /* EqualsEqualsEqualsToken */; + } + return pos += 2, token = 30 /* EqualsEqualsToken */; + } + if (text.charCodeAt(pos + 1) === 62 /* greaterThan */) { + return pos += 2, token = 34 /* EqualsGreaterThanToken */; + } + return pos++, token = 56 /* EqualsToken */; + case 62 /* greaterThan */: + if (isConflictMarkerTrivia(text, pos)) { + pos = scanConflictMarkerTrivia(text, pos, error); + if (skipTrivia) { + continue; + } + else { + return token = 7 /* ConflictMarkerTrivia */; + } + } + return pos++, token = 27 /* GreaterThanToken */; + case 63 /* question */: + return pos++, token = 53 /* QuestionToken */; + case 91 /* openBracket */: + return pos++, token = 19 /* OpenBracketToken */; + case 93 /* closeBracket */: + return pos++, token = 20 /* CloseBracketToken */; + case 94 /* caret */: + if (text.charCodeAt(pos + 1) === 61 /* equals */) { + return pos += 2, token = 68 /* CaretEqualsToken */; + } + return pos++, token = 48 /* CaretToken */; + case 123 /* openBrace */: + return pos++, token = 15 /* OpenBraceToken */; + case 124 /* bar */: + if (text.charCodeAt(pos + 1) === 124 /* bar */) { + return pos += 2, token = 52 /* BarBarToken */; + } + if (text.charCodeAt(pos + 1) === 61 /* equals */) { + return pos += 2, token = 67 /* BarEqualsToken */; + } + return pos++, token = 47 /* BarToken */; + case 125 /* closeBrace */: + return pos++, token = 16 /* CloseBraceToken */; + case 126 /* tilde */: + return pos++, token = 50 /* TildeToken */; + case 64 /* at */: + return pos++, token = 55 /* AtToken */; + case 92 /* backslash */: + var cookedChar = peekUnicodeEscape(); + if (cookedChar >= 0 && isIdentifierStart(cookedChar, languageVersion)) { + pos += 6; + tokenValue = String.fromCharCode(cookedChar) + scanIdentifierParts(); + return token = getIdentifierToken(); + } + error(ts.Diagnostics.Invalid_character); + return pos++, token = 0 /* Unknown */; + default: + if (isIdentifierStart(ch, languageVersion)) { + pos++; + while (pos < end && isIdentifierPart(ch = text.charCodeAt(pos), languageVersion)) + pos++; + tokenValue = text.substring(tokenPos, pos); + if (ch === 92 /* backslash */) { + tokenValue += scanIdentifierParts(); + } + return token = getIdentifierToken(); + } + else if (isWhiteSpace(ch)) { + pos++; + continue; + } + else if (isLineBreak(ch)) { + precedingLineBreak = true; + pos++; + continue; + } + error(ts.Diagnostics.Invalid_character); + return pos++, token = 0 /* Unknown */; + } + } + } + function reScanGreaterToken() { + if (token === 27 /* 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 += 2, token = 45 /* GreaterThanGreaterThanGreaterThanToken */; + } + if (text.charCodeAt(pos + 1) === 61 /* equals */) { + return pos += 2, token = 64 /* GreaterThanGreaterThanEqualsToken */; + } + return pos++, token = 44 /* GreaterThanGreaterThanToken */; + } + if (text.charCodeAt(pos) === 61 /* equals */) { + return pos++, token = 29 /* GreaterThanEqualsToken */; + } + } + return token; + } + function reScanSlashToken() { + if (token === 39 /* SlashToken */ || token === 61 /* SlashEqualsToken */) { + var p = tokenPos + 1; + var inEscape = false; + var inCharacterClass = false; + while (true) { + // If we reach the end of a file, or hit a newline, then this is an unterminated + // regex. Report error and return what we have so far. + 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) { + // Parsing an escape character; + // reset the flag and just advance to the next char. + inEscape = false; + } + else if (ch === 47 /* slash */ && !inCharacterClass) { + // A slash within a character class is permissible, + // but in general it signals the end of the regexp literal. + p++; + break; + } + else if (ch === 91 /* openBracket */) { + inCharacterClass = true; + } + else if (ch === 92 /* backslash */) { + inEscape = true; + } + else if (ch === 93 /* closeBracket */) { + inCharacterClass = false; + } + p++; + } + while (p < end && isIdentifierPart(text.charCodeAt(p), languageVersion)) { + p++; + } + pos = p; + tokenValue = text.substring(tokenPos, pos); + token = 10 /* RegularExpressionLiteral */; + } + return token; + } + /** + * Unconditionally back up and scan a template expression portion. + */ + function reScanTemplateToken() { + ts.Debug.assert(token === 16 /* CloseBraceToken */, "'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 /* EndOfFileToken */; + } + var char = text.charCodeAt(pos); + if (char === 60 /* lessThan */) { + if (text.charCodeAt(pos + 1) === 47 /* slash */) { + pos += 2; + return token = 26 /* LessThanSlashToken */; + } + pos++; + return token = 25 /* LessThanToken */; + } + if (char === 123 /* openBrace */) { + pos++; + return token = 15 /* OpenBraceToken */; + } + while (pos < end) { + pos++; + char = text.charCodeAt(pos); + if ((char === 123 /* openBrace */) || (char === 60 /* lessThan */)) { + break; + } + } + return token = 236 /* JsxText */; + } + // Scans a JSX identifier; these differ from normal identifiers in that + // they allow dashes + function scanJsxIdentifier() { + if (tokenIsIdentifierOrKeyword(token)) { + var firstCharPosition = pos; + while (pos < end) { + var ch = text.charCodeAt(pos); + if (ch === 45 /* minus */ || ((firstCharPosition === pos) ? isIdentifierStart(ch, languageVersion) : isIdentifierPart(ch, languageVersion))) { + pos++; + } + else { + break; + } + } + tokenValue += text.substr(firstCharPosition, pos - firstCharPosition); + } + return token; + } + 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 our callback returned something 'falsy' or we're just looking ahead, + // then unconditionally restore us to where we were. + if (!result || isLookahead) { + pos = savePos; + startPos = saveStartPos; + tokenPos = saveTokenPos; + token = saveToken; + tokenValue = saveTokenValue; + precedingLineBreak = savePrecedingLineBreak; + } + return result; + } + function lookAhead(callback) { + return speculationHelper(callback, /*isLookahead:*/ true); + } + function tryScan(callback) { + return speculationHelper(callback, /*isLookahead:*/ false); + } + 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 /* Unknown */; + precedingLineBreak = false; + tokenValue = undefined; + hasExtendedUnicodeEscape = false; + tokenIsUnterminated = false; + } + } + ts.createScanner = createScanner; +})(ts || (ts = {})); +/// +/* @internal */ +var ts; +(function (ts) { + ts.bindTime = 0; + (function (ModuleInstanceState) { + ModuleInstanceState[ModuleInstanceState["NonInstantiated"] = 0] = "NonInstantiated"; + ModuleInstanceState[ModuleInstanceState["Instantiated"] = 1] = "Instantiated"; + ModuleInstanceState[ModuleInstanceState["ConstEnumOnly"] = 2] = "ConstEnumOnly"; + })(ts.ModuleInstanceState || (ts.ModuleInstanceState = {})); + var ModuleInstanceState = ts.ModuleInstanceState; + function getModuleInstanceState(node) { + // A module is uninstantiated if it contains only + // 1. interface declarations, type alias declarations + if (node.kind === 215 /* InterfaceDeclaration */ || node.kind === 216 /* TypeAliasDeclaration */) { + return 0 /* NonInstantiated */; + } + else if (ts.isConstEnumDeclaration(node)) { + return 2 /* ConstEnumOnly */; + } + else if ((node.kind === 222 /* ImportDeclaration */ || node.kind === 221 /* ImportEqualsDeclaration */) && !(node.flags & 1 /* Export */)) { + return 0 /* NonInstantiated */; + } + else if (node.kind === 219 /* ModuleBlock */) { + var state = 0 /* NonInstantiated */; + ts.forEachChild(node, function (n) { + switch (getModuleInstanceState(n)) { + case 0 /* NonInstantiated */: + // child is non-instantiated - continue searching + return false; + case 2 /* ConstEnumOnly */: + // child is const enum only - record state and continue searching + state = 2 /* ConstEnumOnly */; + return false; + case 1 /* Instantiated */: + // child is instantiated - record state and stop + state = 1 /* Instantiated */; + return true; + } + }); + return state; + } + else if (node.kind === 218 /* ModuleDeclaration */) { + return getModuleInstanceState(node.body); + } + else { + return 1 /* Instantiated */; + } + } + ts.getModuleInstanceState = getModuleInstanceState; + var ContainerFlags; + (function (ContainerFlags) { + // The current node is not a container, and no container manipulation should happen before + // recursing into it. + ContainerFlags[ContainerFlags["None"] = 0] = "None"; + // 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... + ContainerFlags[ContainerFlags["IsContainer"] = 1] = "IsContainer"; + // 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... + ContainerFlags[ContainerFlags["IsBlockScopedContainer"] = 2] = "IsBlockScopedContainer"; + ContainerFlags[ContainerFlags["HasLocals"] = 4] = "HasLocals"; + // If the current node is a container that also container that also contains locals. Examples: + // + // Functions, Methods, Modules, Source-files. + ContainerFlags[ContainerFlags["IsContainerWithLocals"] = 5] = "IsContainerWithLocals"; + })(ContainerFlags || (ContainerFlags = {})); + function bindSourceFile(file) { + var start = new Date().getTime(); + bindSourceFileWorker(file); + ts.bindTime += new Date().getTime() - start; + } + ts.bindSourceFile = bindSourceFile; + function bindSourceFileWorker(file) { + var parent; + var container; + var blockScopeContainer; + var lastContainer; + var seenThisKeyword; + // 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). + var inStrictMode = !!file.externalModuleIndicator; + var symbolCount = 0; + var Symbol = ts.objectAllocator.getSymbolConstructor(); + var classifiableNames = {}; + if (!file.locals) { + bind(file); + file.symbolCount = symbolCount; + file.classifiableNames = classifiableNames; + } + return; + function createSymbol(flags, name) { + symbolCount++; + return new Symbol(flags, name); + } + function addDeclarationToSymbol(symbol, node, symbolFlags) { + symbol.flags |= symbolFlags; + node.symbol = symbol; + if (!symbol.declarations) { + symbol.declarations = []; + } + symbol.declarations.push(node); + if (symbolFlags & 1952 /* HasExports */ && !symbol.exports) { + symbol.exports = {}; + } + if (symbolFlags & 6240 /* HasMembers */ && !symbol.members) { + symbol.members = {}; + } + if (symbolFlags & 107455 /* Value */ && !symbol.valueDeclaration) { + 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) { + if (node.name) { + if (node.kind === 218 /* ModuleDeclaration */ && node.name.kind === 9 /* StringLiteral */) { + return "\"" + node.name.text + "\""; + } + if (node.name.kind === 136 /* ComputedPropertyName */) { + var nameExpression = node.name.expression; + ts.Debug.assert(ts.isWellKnownSymbolSyntactically(nameExpression)); + return ts.getPropertyNameForKnownSymbolName(nameExpression.name.text); + } + return node.name.text; + } + switch (node.kind) { + case 144 /* Constructor */: + return "__constructor"; + case 152 /* FunctionType */: + case 147 /* CallSignature */: + return "__call"; + case 153 /* ConstructorType */: + case 148 /* ConstructSignature */: + return "__new"; + case 149 /* IndexSignature */: + return "__index"; + case 228 /* ExportDeclaration */: + return "__export"; + case 227 /* ExportAssignment */: + return node.isExportEquals ? "export=" : "default"; + case 213 /* FunctionDeclaration */: + case 214 /* ClassDeclaration */: + return node.flags & 1024 /* Default */ ? "default" : undefined; + } + } + function getDisplayName(node) { + return node.name ? ts.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, parent, node, includes, excludes) { + ts.Debug.assert(!ts.hasDynamicName(node)); + var isDefaultExport = node.flags & 1024 /* Default */; + // The exported symbol for an export default function/class node is always named "default" + var name = isDefaultExport && parent ? "default" : getDeclarationName(node); + var symbol; + if (name !== undefined) { + // Check and see if the symbol table already has a symbol with this name. If not, + // 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. + // + // 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 = ts.hasProperty(symbolTable, name) + ? symbolTable[name] + : (symbolTable[name] = createSymbol(0 /* None */, name)); + if (name && (includes & 788448 /* Classifiable */)) { + classifiableNames[name] = name; + } + if (symbol.flags & excludes) { + if (node.name) { + node.name.parent = node; + } + // Report errors every position with duplicate declaration + // Report errors on previous encountered declarations + var message = symbol.flags & 2 /* BlockScopedVariable */ + ? ts.Diagnostics.Cannot_redeclare_block_scoped_variable_0 + : ts.Diagnostics.Duplicate_identifier_0; + ts.forEach(symbol.declarations, function (declaration) { + if (declaration.flags & 1024 /* Default */) { + message = ts.Diagnostics.A_module_cannot_have_multiple_default_exports; + } + }); + ts.forEach(symbol.declarations, function (declaration) { + file.bindDiagnostics.push(ts.createDiagnosticForNode(declaration.name || declaration, message, getDisplayName(declaration))); + }); + file.bindDiagnostics.push(ts.createDiagnosticForNode(node.name || node, message, getDisplayName(node))); + symbol = createSymbol(0 /* None */, name); + } + } + else { + symbol = createSymbol(0 /* None */, "__missing"); + } + addDeclarationToSymbol(symbol, node, includes); + symbol.parent = parent; + return symbol; + } + function declareModuleMember(node, symbolFlags, symbolExcludes) { + var hasExportModifier = ts.getCombinedNodeFlags(node) & 1 /* Export */; + if (symbolFlags & 8388608 /* Alias */) { + if (node.kind === 230 /* ExportSpecifier */ || (node.kind === 221 /* 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. + if (hasExportModifier || container.flags & 262144 /* ExportContext */) { + var exportKind = (symbolFlags & 107455 /* Value */ ? 1048576 /* ExportValue */ : 0) | + (symbolFlags & 793056 /* Type */ ? 2097152 /* ExportType */ : 0) | + (symbolFlags & 1536 /* Namespace */ ? 4194304 /* ExportNamespace */ : 0); + var 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 bindChildren(node) { + // Before we recurse into a node's chilren, we first save the existing parent, container + // and block-container. Then after we pop out of processing the children, we restore + // these saved values. + var saveParent = parent; + var saveContainer = container; + var savedBlockScopeContainer = blockScopeContainer; + // This node will now be set as the parent of all of its children as we recurse into them. + parent = node; + // 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 accidently move any stale data forward from + // a previous compilation. + var containerFlags = getContainerFlags(node); + if (containerFlags & 1 /* IsContainer */) { + container = blockScopeContainer = node; + if (containerFlags & 4 /* HasLocals */) { + container.locals = {}; + } + addToContainerChain(container); + } + else if (containerFlags & 2 /* IsBlockScopedContainer */) { + blockScopeContainer = node; + blockScopeContainer.locals = undefined; + } + if (node.kind === 215 /* InterfaceDeclaration */) { + seenThisKeyword = false; + ts.forEachChild(node, bind); + node.flags = seenThisKeyword ? node.flags | 524288 /* ContainsThis */ : node.flags & ~524288 /* ContainsThis */; + } + else { + ts.forEachChild(node, bind); + } + container = saveContainer; + parent = saveParent; + blockScopeContainer = savedBlockScopeContainer; + } + function getContainerFlags(node) { + switch (node.kind) { + case 186 /* ClassExpression */: + case 214 /* ClassDeclaration */: + case 215 /* InterfaceDeclaration */: + case 217 /* EnumDeclaration */: + case 155 /* TypeLiteral */: + case 165 /* ObjectLiteralExpression */: + return 1 /* IsContainer */; + case 147 /* CallSignature */: + case 148 /* ConstructSignature */: + case 149 /* IndexSignature */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: + case 213 /* FunctionDeclaration */: + case 144 /* Constructor */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: + case 152 /* FunctionType */: + case 153 /* ConstructorType */: + case 173 /* FunctionExpression */: + case 174 /* ArrowFunction */: + case 218 /* ModuleDeclaration */: + case 248 /* SourceFile */: + case 216 /* TypeAliasDeclaration */: + return 5 /* IsContainerWithLocals */; + case 244 /* CatchClause */: + case 199 /* ForStatement */: + case 200 /* ForInStatement */: + case 201 /* ForOfStatement */: + case 220 /* CaseBlock */: + return 2 /* IsBlockScopedContainer */; + case 192 /* Block */: + // do not treat blocks directly inside a function as a block-scoped-container. + // Locals that reside in this block should go to the function locals. Othewise 'x' + // would not appear to be a redeclaration of a block scoped local in the following + // 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 ts.isFunctionLike(node.parent) ? 0 /* None */ : 2 /* IsBlockScopedContainer */; + } + return 0 /* None */; + } + function addToContainerChain(next) { + if (lastContainer) { + lastContainer.nextContainer = next; + } + lastContainer = next; + } + function declareSymbolAndAddToSymbolTable(node, symbolFlags, symbolExcludes) { + // Just call this directly so that the return type of this function stays "void". + declareSymbolAndAddToSymbolTableWorker(node, symbolFlags, symbolExcludes); + } + function declareSymbolAndAddToSymbolTableWorker(node, symbolFlags, symbolExcludes) { + 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 218 /* ModuleDeclaration */: + return declareModuleMember(node, symbolFlags, symbolExcludes); + case 248 /* SourceFile */: + return declareSourceFileMember(node, symbolFlags, symbolExcludes); + case 186 /* ClassExpression */: + case 214 /* ClassDeclaration */: + return declareClassMember(node, symbolFlags, symbolExcludes); + case 217 /* EnumDeclaration */: + return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); + case 155 /* TypeLiteral */: + case 165 /* ObjectLiteralExpression */: + case 215 /* InterfaceDeclaration */: + // Interface/Object-types always have their children added to the 'members' of + // their container. They are only accessible through an instance of their + // container, and are never in scope otherwise (even inside the body of the + // object / type / interface declaring them). An exception is type parameters, + // which are in scope without qualification (similar to 'locals'). + return declareSymbol(container.symbol.members, container.symbol, node, symbolFlags, symbolExcludes); + case 152 /* FunctionType */: + case 153 /* ConstructorType */: + case 147 /* CallSignature */: + case 148 /* ConstructSignature */: + case 149 /* IndexSignature */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: + case 144 /* Constructor */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: + case 213 /* FunctionDeclaration */: + case 173 /* FunctionExpression */: + case 174 /* ArrowFunction */: + case 216 /* TypeAliasDeclaration */: + // All the children of these container types are never visible through another + // symbol (i.e. through another symbol's 'exports' or 'members'). Instead, + // they're only accessed 'lexically' (i.e. from code that exists underneath + // 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, undefined, node, symbolFlags, symbolExcludes); + } + } + function declareClassMember(node, symbolFlags, symbolExcludes) { + return node.flags & 128 /* Static */ + ? declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes) + : declareSymbol(container.symbol.members, container.symbol, node, symbolFlags, symbolExcludes); + } + function declareSourceFileMember(node, symbolFlags, symbolExcludes) { + return ts.isExternalModule(file) + ? declareModuleMember(node, symbolFlags, symbolExcludes) + : declareSymbol(file.locals, undefined, node, symbolFlags, symbolExcludes); + } + function isAmbientContext(node) { + while (node) { + if (node.flags & 2 /* Ambient */) { + return true; + } + node = node.parent; + } + return false; + } + function hasExportDeclarations(node) { + var body = node.kind === 248 /* SourceFile */ ? node : node.body; + if (body.kind === 248 /* SourceFile */ || body.kind === 219 /* ModuleBlock */) { + for (var _i = 0, _a = body.statements; _i < _a.length; _i++) { + var stat = _a[_i]; + if (stat.kind === 228 /* ExportDeclaration */ || stat.kind === 227 /* ExportAssignment */) { + return true; + } + } + } + return false; + } + function setExportContextFlag(node) { + // 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 (isAmbientContext(node) && !hasExportDeclarations(node)) { + node.flags |= 262144 /* ExportContext */; + } + else { + node.flags &= ~262144 /* ExportContext */; + } + } + function bindModuleDeclaration(node) { + setExportContextFlag(node); + if (node.name.kind === 9 /* StringLiteral */) { + declareSymbolAndAddToSymbolTable(node, 512 /* ValueModule */, 106639 /* ValueModuleExcludes */); + } + else { + var state = getModuleInstanceState(node); + if (state === 0 /* NonInstantiated */) { + declareSymbolAndAddToSymbolTable(node, 1024 /* NamespaceModule */, 0 /* NamespaceModuleExcludes */); + } + else { + declareSymbolAndAddToSymbolTable(node, 512 /* ValueModule */, 106639 /* ValueModuleExcludes */); + if (node.symbol.flags & (16 /* Function */ | 32 /* Class */ | 256 /* 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 { + var currentModuleIsConstEnumOnly = state === 2 /* 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) { + // For a given function symbol "<...>(...) => T" we want to generate a symbol identical + // to the one we would get for: { <...>(...): T } + // + // We do that by making an anonymous type literal symbol, and then setting the function + // symbol as its sole member. To the rest of the system, this symbol will be indistinguishable + // from an actual type literal symbol you would have gotten had you used the long form. + var symbol = createSymbol(131072 /* Signature */, getDeclarationName(node)); + addDeclarationToSymbol(symbol, node, 131072 /* Signature */); + var typeLiteralSymbol = createSymbol(2048 /* TypeLiteral */, "__type"); + addDeclarationToSymbol(typeLiteralSymbol, node, 2048 /* TypeLiteral */); + typeLiteralSymbol.members = (_a = {}, _a[symbol.name] = symbol, _a); + var _a; + } + function bindObjectLiteralExpression(node) { + var ElementKind; + (function (ElementKind) { + ElementKind[ElementKind["Property"] = 1] = "Property"; + ElementKind[ElementKind["Accessor"] = 2] = "Accessor"; + })(ElementKind || (ElementKind = {})); + if (inStrictMode) { + var seen = {}; + for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { + var prop = _a[_i]; + if (prop.name.kind !== 69 /* Identifier */) { + continue; + } + var identifier = prop.name; + // ECMA-262 11.1.5 Object Initialiser + // If previous is not undefined then throw a SyntaxError exception if any of the following conditions are true + // a.This production is contained in strict code and IsDataDescriptor(previous) is true and + // 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 + var currentKind = prop.kind === 245 /* PropertyAssignment */ || prop.kind === 246 /* ShorthandPropertyAssignment */ || prop.kind === 143 /* MethodDeclaration */ + ? 1 /* Property */ + : 2 /* Accessor */; + var existingKind = seen[identifier.text]; + if (!existingKind) { + seen[identifier.text] = currentKind; + continue; + } + if (currentKind === 1 /* Property */ && existingKind === 1 /* Property */) { + var span = ts.getErrorSpanForNode(file, identifier); + file.bindDiagnostics.push(ts.createFileDiagnostic(file, span.start, span.length, ts.Diagnostics.An_object_literal_cannot_have_multiple_properties_with_the_same_name_in_strict_mode)); + } + } + } + return bindAnonymousDeclaration(node, 4096 /* ObjectLiteral */, "__object"); + } + function bindAnonymousDeclaration(node, symbolFlags, name) { + var symbol = createSymbol(symbolFlags, name); + addDeclarationToSymbol(symbol, node, symbolFlags); + } + function bindBlockScopedDeclaration(node, symbolFlags, symbolExcludes) { + switch (blockScopeContainer.kind) { + case 218 /* ModuleDeclaration */: + declareModuleMember(node, symbolFlags, symbolExcludes); + break; + case 248 /* SourceFile */: + if (ts.isExternalModule(container)) { + declareModuleMember(node, symbolFlags, symbolExcludes); + break; + } + // fall through. + default: + if (!blockScopeContainer.locals) { + blockScopeContainer.locals = {}; + addToContainerChain(blockScopeContainer); + } + declareSymbol(blockScopeContainer.locals, undefined, node, symbolFlags, symbolExcludes); + } + } + function bindBlockScopedVariableDeclaration(node) { + bindBlockScopedDeclaration(node, 2 /* BlockScopedVariable */, 107455 /* 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) { + if (inStrictMode && + node.originalKeywordKind >= 106 /* FirstFutureReservedWord */ && + node.originalKeywordKind <= 114 /* LastFutureReservedWord */ && + !ts.isIdentifierName(node)) { + // Report error only if there are no parse errors in file + if (!file.parseDiagnostics.length) { + file.bindDiagnostics.push(ts.createDiagnosticForNode(node, getStrictModeIdentifierMessage(node), ts.declarationNameToString(node))); + } + } + } + function getStrictModeIdentifierMessage(node) { + // Provide specialized messages to help the user understand why we think they're in + // strict mode. + if (ts.getContainingClass(node)) { + return ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_strict_mode; + } + if (file.externalModuleIndicator) { + return ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode_Modules_are_automatically_in_strict_mode; + } + return ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode; + } + function checkStrictModeBinaryExpression(node) { + if (inStrictMode && ts.isLeftHandSideExpression(node.left) && ts.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) { + // 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) { + // Grammar checking + if (inStrictMode && node.expression.kind === 69 /* Identifier */) { + // When a delete operator occurs within strict mode code, a SyntaxError is thrown if its + // UnaryExpression is a direct reference to a variable, function argument, or function name + var span = ts.getErrorSpanForNode(file, node.expression); + file.bindDiagnostics.push(ts.createFileDiagnostic(file, span.start, span.length, ts.Diagnostics.delete_cannot_be_called_on_an_identifier_in_strict_mode)); + } + } + function isEvalOrArgumentsIdentifier(node) { + return node.kind === 69 /* Identifier */ && + (node.text === "eval" || node.text === "arguments"); + } + function checkStrictModeEvalOrArguments(contextNode, name) { + if (name && name.kind === 69 /* Identifier */) { + var identifier = name; + if (isEvalOrArgumentsIdentifier(identifier)) { + // We check first if the name is inside class declaration or class expression; if so give explicit message + // otherwise report generic error message. + var span = ts.getErrorSpanForNode(file, name); + file.bindDiagnostics.push(ts.createFileDiagnostic(file, span.start, span.length, getStrictModeEvalOrArgumentsMessage(contextNode), identifier.text)); + } + } + } + function getStrictModeEvalOrArgumentsMessage(node) { + // Provide specialized messages to help the user understand why we think they're in + // strict mode. + if (ts.getContainingClass(node)) { + return ts.Diagnostics.Invalid_use_of_0_Class_definitions_are_automatically_in_strict_mode; + } + if (file.externalModuleIndicator) { + return ts.Diagnostics.Invalid_use_of_0_Modules_are_automatically_in_strict_mode; + } + return ts.Diagnostics.Invalid_use_of_0_in_strict_mode; + } + function checkStrictModeFunctionName(node) { + 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 checkStrictModeNumericLiteral(node) { + if (inStrictMode && node.flags & 65536 /* OctalLiteral */) { + file.bindDiagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.Octal_literals_are_not_allowed_in_strict_mode)); + } + } + function checkStrictModePostfixUnaryExpression(node) { + // 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) { + // Grammar checking + if (inStrictMode) { + if (node.operator === 41 /* PlusPlusToken */ || node.operator === 42 /* MinusMinusToken */) { + checkStrictModeEvalOrArguments(node, node.operand); + } + } + } + function checkStrictModeWithStatement(node) { + // Grammar checking for withStatement + if (inStrictMode) { + grammarErrorOnFirstToken(node, ts.Diagnostics.with_statements_are_not_allowed_in_strict_mode); + } + } + function grammarErrorOnFirstToken(node, message, arg0, arg1, arg2) { + var span = ts.getSpanOfTokenAtPosition(file, node.pos); + file.bindDiagnostics.push(ts.createFileDiagnostic(file, span.start, span.length, message, arg0, arg1, arg2)); + } + function getDestructuringParameterName(node) { + return "__" + ts.indexOf(node.parent.parameters, node); + } + function bind(node) { + node.parent = parent; + var savedInStrictMode = inStrictMode; + if (!savedInStrictMode) { + updateStrictMode(node); + } + // 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. + bindChildren(node); + inStrictMode = savedInStrictMode; + } + function updateStrictMode(node) { + switch (node.kind) { + case 248 /* SourceFile */: + case 219 /* ModuleBlock */: + updateStrictModeStatementList(node.statements); + return; + case 192 /* Block */: + if (ts.isFunctionLike(node.parent)) { + updateStrictModeStatementList(node.statements); + } + return; + case 214 /* ClassDeclaration */: + case 186 /* ClassExpression */: + // All classes are automatically in strict mode in ES6. + inStrictMode = true; + return; + } + } + function updateStrictModeStatementList(statements) { + for (var _i = 0; _i < statements.length; _i++) { + var statement = statements[_i]; + if (!ts.isPrologueDirective(statement)) { + return; + } + if (isUseStrictPrologueDirective(statement)) { + inStrictMode = true; + return; + } + } + } + /// Should be called only on prologue directives (isPrologueDirective(node) should be true) + function isUseStrictPrologueDirective(node) { + var nodeText = ts.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) { + switch (node.kind) { + case 69 /* Identifier */: + return checkStrictModeIdentifier(node); + case 181 /* BinaryExpression */: + return checkStrictModeBinaryExpression(node); + case 244 /* CatchClause */: + return checkStrictModeCatchClause(node); + case 175 /* DeleteExpression */: + return checkStrictModeDeleteExpression(node); + case 8 /* NumericLiteral */: + return checkStrictModeNumericLiteral(node); + case 180 /* PostfixUnaryExpression */: + return checkStrictModePostfixUnaryExpression(node); + case 179 /* PrefixUnaryExpression */: + return checkStrictModePrefixUnaryExpression(node); + case 205 /* WithStatement */: + return checkStrictModeWithStatement(node); + case 97 /* ThisKeyword */: + seenThisKeyword = true; + return; + case 137 /* TypeParameter */: + return declareSymbolAndAddToSymbolTable(node, 262144 /* TypeParameter */, 530912 /* TypeParameterExcludes */); + case 138 /* Parameter */: + return bindParameter(node); + case 211 /* VariableDeclaration */: + case 163 /* BindingElement */: + return bindVariableDeclarationOrBindingElement(node); + case 141 /* PropertyDeclaration */: + case 140 /* PropertySignature */: + return bindPropertyOrMethodOrAccessor(node, 4 /* Property */ | (node.questionToken ? 536870912 /* Optional */ : 0 /* None */), 107455 /* PropertyExcludes */); + case 245 /* PropertyAssignment */: + case 246 /* ShorthandPropertyAssignment */: + return bindPropertyOrMethodOrAccessor(node, 4 /* Property */, 107455 /* PropertyExcludes */); + case 247 /* EnumMember */: + return bindPropertyOrMethodOrAccessor(node, 8 /* EnumMember */, 107455 /* EnumMemberExcludes */); + case 147 /* CallSignature */: + case 148 /* ConstructSignature */: + case 149 /* IndexSignature */: + return declareSymbolAndAddToSymbolTable(node, 131072 /* Signature */, 0 /* None */); + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: + // If this is an ObjectLiteralExpression method, then it sits in the same space + // as other properties in the object literal. So we use SymbolFlags.PropertyExcludes + // so that it will conflict with any other object literal members with the same + // name. + return bindPropertyOrMethodOrAccessor(node, 8192 /* Method */ | (node.questionToken ? 536870912 /* Optional */ : 0 /* None */), ts.isObjectLiteralMethod(node) ? 107455 /* PropertyExcludes */ : 99263 /* MethodExcludes */); + case 213 /* FunctionDeclaration */: + checkStrictModeFunctionName(node); + return declareSymbolAndAddToSymbolTable(node, 16 /* Function */, 106927 /* FunctionExcludes */); + case 144 /* Constructor */: + return declareSymbolAndAddToSymbolTable(node, 16384 /* Constructor */, /*symbolExcludes:*/ 0 /* None */); + case 145 /* GetAccessor */: + return bindPropertyOrMethodOrAccessor(node, 32768 /* GetAccessor */, 41919 /* GetAccessorExcludes */); + case 146 /* SetAccessor */: + return bindPropertyOrMethodOrAccessor(node, 65536 /* SetAccessor */, 74687 /* SetAccessorExcludes */); + case 152 /* FunctionType */: + case 153 /* ConstructorType */: + return bindFunctionOrConstructorType(node); + case 155 /* TypeLiteral */: + return bindAnonymousDeclaration(node, 2048 /* TypeLiteral */, "__type"); + case 165 /* ObjectLiteralExpression */: + return bindObjectLiteralExpression(node); + case 173 /* FunctionExpression */: + case 174 /* ArrowFunction */: + checkStrictModeFunctionName(node); + var bindingName = node.name ? node.name.text : "__function"; + return bindAnonymousDeclaration(node, 16 /* Function */, bindingName); + case 186 /* ClassExpression */: + case 214 /* ClassDeclaration */: + return bindClassLikeDeclaration(node); + case 215 /* InterfaceDeclaration */: + return bindBlockScopedDeclaration(node, 64 /* Interface */, 792960 /* InterfaceExcludes */); + case 216 /* TypeAliasDeclaration */: + return bindBlockScopedDeclaration(node, 524288 /* TypeAlias */, 793056 /* TypeAliasExcludes */); + case 217 /* EnumDeclaration */: + return bindEnumDeclaration(node); + case 218 /* ModuleDeclaration */: + return bindModuleDeclaration(node); + case 221 /* ImportEqualsDeclaration */: + case 224 /* NamespaceImport */: + case 226 /* ImportSpecifier */: + case 230 /* ExportSpecifier */: + return declareSymbolAndAddToSymbolTable(node, 8388608 /* Alias */, 8388608 /* AliasExcludes */); + case 223 /* ImportClause */: + return bindImportClause(node); + case 228 /* ExportDeclaration */: + return bindExportDeclaration(node); + case 227 /* ExportAssignment */: + return bindExportAssignment(node); + case 248 /* SourceFile */: + return bindSourceFileIfExternalModule(); + } + } + function bindSourceFileIfExternalModule() { + setExportContextFlag(file); + if (ts.isExternalModule(file)) { + bindAnonymousDeclaration(file, 512 /* ValueModule */, "\"" + ts.removeFileExtension(file.fileName) + "\""); + } + } + function bindExportAssignment(node) { + if (!container.symbol || !container.symbol.exports) { + // Export assignment in some sort of block construct + bindAnonymousDeclaration(node, 8388608 /* Alias */, getDeclarationName(node)); + } + else if (node.expression.kind === 69 /* Identifier */) { + // An export default clause with an identifier exports all meanings of that identifier + declareSymbol(container.symbol.exports, container.symbol, node, 8388608 /* Alias */, 107455 /* PropertyExcludes */ | 8388608 /* AliasExcludes */); + } + else { + // An export default clause with an expression exports a value + declareSymbol(container.symbol.exports, container.symbol, node, 4 /* Property */, 107455 /* PropertyExcludes */ | 8388608 /* AliasExcludes */); + } + } + function bindExportDeclaration(node) { + if (!container.symbol || !container.symbol.exports) { + // Export * in some sort of block construct + bindAnonymousDeclaration(node, 1073741824 /* ExportStar */, getDeclarationName(node)); + } + else if (!node.exportClause) { + // All export * declarations are collected in an __export symbol + declareSymbol(container.symbol.exports, container.symbol, node, 1073741824 /* ExportStar */, 0 /* None */); + } + } + function bindImportClause(node) { + if (node.name) { + declareSymbolAndAddToSymbolTable(node, 8388608 /* Alias */, 8388608 /* AliasExcludes */); + } + } + function bindClassLikeDeclaration(node) { + if (node.kind === 214 /* ClassDeclaration */) { + bindBlockScopedDeclaration(node, 32 /* Class */, 899519 /* ClassExcludes */); + } + else { + var bindingName = node.name ? node.name.text : "__class"; + bindAnonymousDeclaration(node, 32 /* Class */, bindingName); + // Add name of class expression into the map for semantic classifier + if (node.name) { + classifiableNames[node.name.text] = node.name.text; + } + } + var 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. + var prototypeSymbol = createSymbol(4 /* Property */ | 134217728 /* Prototype */, "prototype"); + if (ts.hasProperty(symbol.exports, prototypeSymbol.name)) { + if (node.name) { + node.name.parent = node; + } + file.bindDiagnostics.push(ts.createDiagnosticForNode(symbol.exports[prototypeSymbol.name].declarations[0], ts.Diagnostics.Duplicate_identifier_0, prototypeSymbol.name)); + } + symbol.exports[prototypeSymbol.name] = prototypeSymbol; + prototypeSymbol.parent = symbol; + } + function bindEnumDeclaration(node) { + return ts.isConst(node) + ? bindBlockScopedDeclaration(node, 128 /* ConstEnum */, 899967 /* ConstEnumExcludes */) + : bindBlockScopedDeclaration(node, 256 /* RegularEnum */, 899327 /* RegularEnumExcludes */); + } + function bindVariableDeclarationOrBindingElement(node) { + if (inStrictMode) { + checkStrictModeEvalOrArguments(node, node.name); + } + if (!ts.isBindingPattern(node.name)) { + if (ts.isBlockOrCatchScoped(node)) { + bindBlockScopedVariableDeclaration(node); + } + else if (ts.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, 1 /* FunctionScopedVariable */, 107455 /* ParameterExcludes */); + } + else { + declareSymbolAndAddToSymbolTable(node, 1 /* FunctionScopedVariable */, 107454 /* FunctionScopedVariableExcludes */); + } + } + } + function bindParameter(node) { + 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 (ts.isBindingPattern(node.name)) { + bindAnonymousDeclaration(node, 1 /* FunctionScopedVariable */, getDestructuringParameterName(node)); + } + else { + declareSymbolAndAddToSymbolTable(node, 1 /* FunctionScopedVariable */, 107455 /* ParameterExcludes */); + } + // If this is a property-parameter, then also declare the property symbol into the + // containing class. + if (node.flags & 112 /* AccessibilityModifier */ && + node.parent.kind === 144 /* Constructor */ && + ts.isClassLike(node.parent.parent)) { + var classDeclaration = node.parent.parent; + declareSymbol(classDeclaration.symbol.members, classDeclaration.symbol, node, 4 /* Property */, 107455 /* PropertyExcludes */); + } + } + function bindPropertyOrMethodOrAccessor(node, symbolFlags, symbolExcludes) { + return ts.hasDynamicName(node) + ? bindAnonymousDeclaration(node, symbolFlags, "__computed") + : declareSymbolAndAddToSymbolTable(node, symbolFlags, symbolExcludes); + } + } +})(ts || (ts = {})); +/// +/// +/* @internal */ +var ts; +(function (ts) { + function getDeclarationOfKind(symbol, kind) { + var declarations = symbol.declarations; + if (declarations) { + for (var _i = 0; _i < declarations.length; _i++) { + var declaration = declarations[_i]; + if (declaration.kind === kind) { + return declaration; + } + } + } + return undefined; + } + ts.getDeclarationOfKind = getDeclarationOfKind; + // Pool writers to avoid needing to allocate them for every symbol we write. + var stringWriters = []; + function getSingleLineStringWriter() { + if (stringWriters.length === 0) { + var str = ""; + var writeText = function (text) { return str += text; }; + return { + string: function () { return str; }, + writeKeyword: writeText, + writeOperator: writeText, + writePunctuation: writeText, + writeSpace: writeText, + writeStringLiteral: writeText, + writeParameter: writeText, + writeSymbol: writeText, + // Completely ignore indentation for string writers. And map newlines to + // a single space. + writeLine: function () { return str += " "; }, + increaseIndent: function () { }, + decreaseIndent: function () { }, + clear: function () { return str = ""; }, + trackSymbol: function () { }, + reportInaccessibleThisError: function () { } + }; + } + return stringWriters.pop(); + } + ts.getSingleLineStringWriter = getSingleLineStringWriter; + function releaseStringWriter(writer) { + writer.clear(); + stringWriters.push(writer); + } + ts.releaseStringWriter = releaseStringWriter; + function getFullWidth(node) { + return node.end - node.pos; + } + ts.getFullWidth = getFullWidth; + function arrayIsEqualTo(array1, array2, equaler) { + if (!array1 || !array2) { + return array1 === array2; + } + if (array1.length !== array2.length) { + return false; + } + for (var i = 0; i < array1.length; ++i) { + var equals = equaler ? equaler(array1[i], array2[i]) : array1[i] === array2[i]; + if (!equals) { + return false; + } + } + return true; + } + ts.arrayIsEqualTo = arrayIsEqualTo; + function hasResolvedModule(sourceFile, moduleNameText) { + return sourceFile.resolvedModules && ts.hasProperty(sourceFile.resolvedModules, moduleNameText); + } + ts.hasResolvedModule = hasResolvedModule; + function getResolvedModule(sourceFile, moduleNameText) { + return hasResolvedModule(sourceFile, moduleNameText) ? sourceFile.resolvedModules[moduleNameText] : undefined; + } + ts.getResolvedModule = getResolvedModule; + function setResolvedModule(sourceFile, moduleNameText, resolvedModule) { + if (!sourceFile.resolvedModules) { + sourceFile.resolvedModules = {}; + } + sourceFile.resolvedModules[moduleNameText] = resolvedModule; + } + ts.setResolvedModule = setResolvedModule; + // Returns true if this node contains a parse error anywhere underneath it. + function containsParseError(node) { + aggregateChildData(node); + return (node.parserContextFlags & 64 /* ThisNodeOrAnySubNodesHasError */) !== 0; + } + ts.containsParseError = containsParseError; + function aggregateChildData(node) { + if (!(node.parserContextFlags & 128 /* HasAggregatedChildData */)) { + // A node is considered to contain a parse error if: + // a) the parser explicitly marked that it had an error + // b) any of it's children reported that it had an error. + var thisNodeOrAnySubNodesHasError = ((node.parserContextFlags & 16 /* ThisNodeHasError */) !== 0) || + ts.forEachChild(node, containsParseError); + // If so, mark ourselves accordingly. + if (thisNodeOrAnySubNodesHasError) { + node.parserContextFlags |= 64 /* ThisNodeOrAnySubNodesHasError */; + } + // Also mark that we've propogated the child information to this node. This way we can + // always consult the bit directly on this node without needing to check its children + // again. + node.parserContextFlags |= 128 /* HasAggregatedChildData */; + } + } + function getSourceFileOfNode(node) { + while (node && node.kind !== 248 /* SourceFile */) { + node = node.parent; + } + return node; + } + ts.getSourceFileOfNode = getSourceFileOfNode; + function getStartPositionOfLine(line, sourceFile) { + ts.Debug.assert(line >= 0); + return ts.getLineStarts(sourceFile)[line]; + } + ts.getStartPositionOfLine = getStartPositionOfLine; + // This is a useful function for debugging purposes. + function nodePosToString(node) { + var file = getSourceFileOfNode(node); + var loc = ts.getLineAndCharacterOfPosition(file, node.pos); + return file.fileName + "(" + (loc.line + 1) + "," + (loc.character + 1) + ")"; + } + ts.nodePosToString = nodePosToString; + function getStartPosOfNode(node) { + return node.pos; + } + ts.getStartPosOfNode = getStartPosOfNode; + // Returns true if this node is missing from the actual source code. A 'missing' node is different + // from 'undefined/defined'. When a node is undefined (which can happen for optional nodes + // in the tree), it is definitely missing. However, a node may be defined, but still be + // missing. This happens whenever the parser knows it needs to parse something, but can't + // get anything in the source code that it expects at that location. For example: + // + // let a: ; + // + // Here, the Type in the Type-Annotation is not-optional (as there is a colon in the source + // code). So the parser will attempt to parse out a type, and will create an actual node. + // However, this node will be 'missing' in the sense that no actual source-code/tokens are + // contained within it. + function nodeIsMissing(node) { + if (!node) { + return true; + } + return node.pos === node.end && node.pos >= 0 && node.kind !== 1 /* EndOfFileToken */; + } + ts.nodeIsMissing = nodeIsMissing; + function nodeIsPresent(node) { + return !nodeIsMissing(node); + } + ts.nodeIsPresent = nodeIsPresent; + function getTokenPosOfNode(node, sourceFile) { + // With nodes that have no width (i.e. 'Missing' nodes), we actually *don't* + // want to skip trivia because this will launch us forward to the next token. + if (nodeIsMissing(node)) { + return node.pos; + } + return ts.skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.pos); + } + ts.getTokenPosOfNode = getTokenPosOfNode; + function getNonDecoratorTokenPosOfNode(node, sourceFile) { + if (nodeIsMissing(node) || !node.decorators) { + return getTokenPosOfNode(node, sourceFile); + } + return ts.skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.decorators.end); + } + ts.getNonDecoratorTokenPosOfNode = getNonDecoratorTokenPosOfNode; + function getSourceTextOfNodeFromSourceFile(sourceFile, node, includeTrivia) { + if (includeTrivia === void 0) { includeTrivia = false; } + if (nodeIsMissing(node)) { + return ""; + } + var text = sourceFile.text; + return text.substring(includeTrivia ? node.pos : ts.skipTrivia(text, node.pos), node.end); + } + ts.getSourceTextOfNodeFromSourceFile = getSourceTextOfNodeFromSourceFile; + function getTextOfNodeFromSourceText(sourceText, node) { + if (nodeIsMissing(node)) { + return ""; + } + return sourceText.substring(ts.skipTrivia(sourceText, node.pos), node.end); + } + ts.getTextOfNodeFromSourceText = getTextOfNodeFromSourceText; + function getTextOfNode(node, includeTrivia) { + if (includeTrivia === void 0) { includeTrivia = false; } + return getSourceTextOfNodeFromSourceFile(getSourceFileOfNode(node), node, includeTrivia); + } + ts.getTextOfNode = getTextOfNode; + // Add an extra underscore to identifiers that start with two underscores to avoid issues with magic names like '__proto__' + function escapeIdentifier(identifier) { + return identifier.length >= 2 && identifier.charCodeAt(0) === 95 /* _ */ && identifier.charCodeAt(1) === 95 /* _ */ ? "_" + identifier : identifier; + } + ts.escapeIdentifier = escapeIdentifier; + // Remove extra underscore from escaped identifier + function unescapeIdentifier(identifier) { + return identifier.length >= 3 && identifier.charCodeAt(0) === 95 /* _ */ && identifier.charCodeAt(1) === 95 /* _ */ && identifier.charCodeAt(2) === 95 /* _ */ ? identifier.substr(1) : identifier; + } + ts.unescapeIdentifier = unescapeIdentifier; + // Make an identifier from an external module name by extracting the string after the last "/" and replacing + // all non-alphanumeric characters with underscores + function makeIdentifierFromModuleName(moduleName) { + return ts.getBaseFileName(moduleName).replace(/^(\d)/, "_$1").replace(/\W/g, "_"); + } + ts.makeIdentifierFromModuleName = makeIdentifierFromModuleName; + function isBlockOrCatchScoped(declaration) { + return (getCombinedNodeFlags(declaration) & 49152 /* BlockScoped */) !== 0 || + isCatchClauseVariableDeclaration(declaration); + } + ts.isBlockOrCatchScoped = isBlockOrCatchScoped; + // Gets the nearest enclosing block scope container that has the provided node + // as a descendant, that is not the provided node. + function getEnclosingBlockScopeContainer(node) { + var current = node.parent; + while (current) { + if (isFunctionLike(current)) { + return current; + } + switch (current.kind) { + case 248 /* SourceFile */: + case 220 /* CaseBlock */: + case 244 /* CatchClause */: + case 218 /* ModuleDeclaration */: + case 199 /* ForStatement */: + case 200 /* ForInStatement */: + case 201 /* ForOfStatement */: + return current; + case 192 /* Block */: + // function block is not considered block-scope container + // see comment in binder.ts: bind(...), case for SyntaxKind.Block + if (!isFunctionLike(current.parent)) { + return current; + } + } + current = current.parent; + } + } + ts.getEnclosingBlockScopeContainer = getEnclosingBlockScopeContainer; + function isCatchClauseVariableDeclaration(declaration) { + return declaration && + declaration.kind === 211 /* VariableDeclaration */ && + declaration.parent && + declaration.parent.kind === 244 /* CatchClause */; + } + ts.isCatchClauseVariableDeclaration = isCatchClauseVariableDeclaration; + // 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. + function declarationNameToString(name) { + return getFullWidth(name) === 0 ? "(Missing)" : getTextOfNode(name); + } + ts.declarationNameToString = declarationNameToString; + function createDiagnosticForNode(node, message, arg0, arg1, arg2) { + var sourceFile = getSourceFileOfNode(node); + var span = getErrorSpanForNode(sourceFile, node); + return ts.createFileDiagnostic(sourceFile, span.start, span.length, message, arg0, arg1, arg2); + } + ts.createDiagnosticForNode = createDiagnosticForNode; + function createDiagnosticForNodeFromMessageChain(node, messageChain) { + var sourceFile = getSourceFileOfNode(node); + var span = getErrorSpanForNode(sourceFile, node); + return { + file: sourceFile, + start: span.start, + length: span.length, + code: messageChain.code, + category: messageChain.category, + messageText: messageChain.next ? messageChain : messageChain.messageText + }; + } + ts.createDiagnosticForNodeFromMessageChain = createDiagnosticForNodeFromMessageChain; + function getSpanOfTokenAtPosition(sourceFile, pos) { + var scanner = ts.createScanner(sourceFile.languageVersion, /*skipTrivia*/ true, sourceFile.languageVariant, sourceFile.text, /*onError:*/ undefined, pos); + scanner.scan(); + var start = scanner.getTokenPos(); + return ts.createTextSpanFromBounds(start, scanner.getTextPos()); + } + ts.getSpanOfTokenAtPosition = getSpanOfTokenAtPosition; + function getErrorSpanForNode(sourceFile, node) { + var errorNode = node; + switch (node.kind) { + case 248 /* SourceFile */: + var pos_1 = ts.skipTrivia(sourceFile.text, 0, /*stopAfterLineBreak*/ false); + if (pos_1 === sourceFile.text.length) { + // file is empty - return span for the beginning of the file + return ts.createTextSpan(0, 0); + } + return getSpanOfTokenAtPosition(sourceFile, pos_1); + // This list is a work in progress. Add missing node kinds to improve their error + // spans. + case 211 /* VariableDeclaration */: + case 163 /* BindingElement */: + case 214 /* ClassDeclaration */: + case 186 /* ClassExpression */: + case 215 /* InterfaceDeclaration */: + case 218 /* ModuleDeclaration */: + case 217 /* EnumDeclaration */: + case 247 /* EnumMember */: + case 213 /* FunctionDeclaration */: + case 173 /* FunctionExpression */: + errorNode = node.name; + break; + } + if (errorNode === undefined) { + // If we don't have a better node, then just set the error on the first token of + // construct. + return getSpanOfTokenAtPosition(sourceFile, node.pos); + } + var pos = nodeIsMissing(errorNode) + ? errorNode.pos + : ts.skipTrivia(sourceFile.text, errorNode.pos); + return ts.createTextSpanFromBounds(pos, errorNode.end); + } + ts.getErrorSpanForNode = getErrorSpanForNode; + function isExternalModule(file) { + return file.externalModuleIndicator !== undefined; + } + ts.isExternalModule = isExternalModule; + function isDeclarationFile(file) { + return (file.flags & 8192 /* DeclarationFile */) !== 0; + } + ts.isDeclarationFile = isDeclarationFile; + function isConstEnumDeclaration(node) { + return node.kind === 217 /* EnumDeclaration */ && isConst(node); + } + ts.isConstEnumDeclaration = isConstEnumDeclaration; + function walkUpBindingElementsAndPatterns(node) { + while (node && (node.kind === 163 /* BindingElement */ || isBindingPattern(node))) { + node = node.parent; + } + return node; + } + // Returns the node flags for this node and all relevant parent nodes. This is done so that + // nodes like variable declarations and binding elements can returned a view of their flags + // that includes the modifiers from their container. i.e. flags like export/declare aren't + // stored on the variable declaration directly, but on the containing variable statement + // (if it has one). Similarly, flags for let/const are store on the variable declaration + // list. By calling this function, all those flags are combined so that the client can treat + // the node as if it actually had those flags. + function getCombinedNodeFlags(node) { + node = walkUpBindingElementsAndPatterns(node); + var flags = node.flags; + if (node.kind === 211 /* VariableDeclaration */) { + node = node.parent; + } + if (node && node.kind === 212 /* VariableDeclarationList */) { + flags |= node.flags; + node = node.parent; + } + if (node && node.kind === 193 /* VariableStatement */) { + flags |= node.flags; + } + return flags; + } + ts.getCombinedNodeFlags = getCombinedNodeFlags; + function isConst(node) { + return !!(getCombinedNodeFlags(node) & 32768 /* Const */); + } + ts.isConst = isConst; + function isLet(node) { + return !!(getCombinedNodeFlags(node) & 16384 /* Let */); + } + ts.isLet = isLet; + function isPrologueDirective(node) { + return node.kind === 195 /* ExpressionStatement */ && node.expression.kind === 9 /* StringLiteral */; + } + ts.isPrologueDirective = isPrologueDirective; + function getLeadingCommentRangesOfNode(node, sourceFileOfNode) { + return ts.getLeadingCommentRanges(sourceFileOfNode.text, node.pos); + } + ts.getLeadingCommentRangesOfNode = getLeadingCommentRangesOfNode; + function getJsDocComments(node, sourceFileOfNode) { + var commentRanges = (node.kind === 138 /* Parameter */ || node.kind === 137 /* TypeParameter */) ? + ts.concatenate(ts.getTrailingCommentRanges(sourceFileOfNode.text, node.pos), ts.getLeadingCommentRanges(sourceFileOfNode.text, node.pos)) : + getLeadingCommentRangesOfNode(node, sourceFileOfNode); + return ts.filter(commentRanges, isJsDocComment); + function isJsDocComment(comment) { + // True if the comment starts with '/**' but not if it is '/**/' + return sourceFileOfNode.text.charCodeAt(comment.pos + 1) === 42 /* asterisk */ && + sourceFileOfNode.text.charCodeAt(comment.pos + 2) === 42 /* asterisk */ && + sourceFileOfNode.text.charCodeAt(comment.pos + 3) !== 47 /* slash */; + } + } + ts.getJsDocComments = getJsDocComments; + ts.fullTripleSlashReferencePathRegEx = /^(\/\/\/\s*/; + ts.fullTripleSlashAMDReferencePathRegEx = /^(\/\/\/\s*/; + function isTypeNode(node) { + if (151 /* FirstTypeNode */ <= node.kind && node.kind <= 160 /* LastTypeNode */) { + return true; + } + switch (node.kind) { + case 117 /* AnyKeyword */: + case 128 /* NumberKeyword */: + case 130 /* StringKeyword */: + case 120 /* BooleanKeyword */: + case 131 /* SymbolKeyword */: + return true; + case 103 /* VoidKeyword */: + return node.parent.kind !== 177 /* VoidExpression */; + case 9 /* StringLiteral */: + // Specialized signatures can have string literals as their parameters' type names + return node.parent.kind === 138 /* Parameter */; + case 188 /* ExpressionWithTypeArguments */: + return !isExpressionWithTypeArgumentsInClassExtendsClause(node); + // Identifiers and qualified names may be type nodes, depending on their context. Climb + // above them to find the lowest container + case 69 /* Identifier */: + // If the identifier is the RHS of a qualified name, then it's a type iff its parent is. + if (node.parent.kind === 135 /* QualifiedName */ && node.parent.right === node) { + node = node.parent; + } + else if (node.parent.kind === 166 /* 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 === 135 /* QualifiedName */ || node.kind === 166 /* PropertyAccessExpression */, "'node' was expected to be a qualified name, identifier or property access in 'isTypeNode'."); + case 135 /* QualifiedName */: + case 166 /* PropertyAccessExpression */: + case 97 /* ThisKeyword */: + var parent_1 = node.parent; + if (parent_1.kind === 154 /* TypeQuery */) { + return false; + } + // Do not recursively call isTypeNode on the parent. In the example: + // + // let a: A.B.C; + // + // Calling isTypeNode would consider the qualified name A.B a type node. Only C or + // A.B.C is a type node. + if (151 /* FirstTypeNode */ <= parent_1.kind && parent_1.kind <= 160 /* LastTypeNode */) { + return true; + } + switch (parent_1.kind) { + case 188 /* ExpressionWithTypeArguments */: + return !isExpressionWithTypeArgumentsInClassExtendsClause(parent_1); + case 137 /* TypeParameter */: + return node === parent_1.constraint; + case 141 /* PropertyDeclaration */: + case 140 /* PropertySignature */: + case 138 /* Parameter */: + case 211 /* VariableDeclaration */: + return node === parent_1.type; + case 213 /* FunctionDeclaration */: + case 173 /* FunctionExpression */: + case 174 /* ArrowFunction */: + case 144 /* Constructor */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: + return node === parent_1.type; + case 147 /* CallSignature */: + case 148 /* ConstructSignature */: + case 149 /* IndexSignature */: + return node === parent_1.type; + case 171 /* TypeAssertionExpression */: + return node === parent_1.type; + case 168 /* CallExpression */: + case 169 /* NewExpression */: + return parent_1.typeArguments && ts.indexOf(parent_1.typeArguments, node) >= 0; + case 170 /* TaggedTemplateExpression */: + // TODO (drosen): TaggedTemplateExpressions may eventually support type arguments. + return false; + } + } + return false; + } + ts.isTypeNode = isTypeNode; + // Warning: This has the same semantics as the forEach family of functions, + // in that traversal terminates in the event that 'visitor' supplies a truthy value. + function forEachReturnStatement(body, visitor) { + return traverse(body); + function traverse(node) { + switch (node.kind) { + case 204 /* ReturnStatement */: + return visitor(node); + case 220 /* CaseBlock */: + case 192 /* Block */: + case 196 /* IfStatement */: + case 197 /* DoStatement */: + case 198 /* WhileStatement */: + case 199 /* ForStatement */: + case 200 /* ForInStatement */: + case 201 /* ForOfStatement */: + case 205 /* WithStatement */: + case 206 /* SwitchStatement */: + case 241 /* CaseClause */: + case 242 /* DefaultClause */: + case 207 /* LabeledStatement */: + case 209 /* TryStatement */: + case 244 /* CatchClause */: + return ts.forEachChild(node, traverse); + } + } + } + ts.forEachReturnStatement = forEachReturnStatement; + function forEachYieldExpression(body, visitor) { + return traverse(body); + function traverse(node) { + switch (node.kind) { + case 184 /* YieldExpression */: + visitor(node); + var operand = node.expression; + if (operand) { + traverse(operand); + } + case 217 /* EnumDeclaration */: + case 215 /* InterfaceDeclaration */: + case 218 /* ModuleDeclaration */: + case 216 /* TypeAliasDeclaration */: + case 214 /* ClassDeclaration */: + case 186 /* ClassExpression */: + // These are not allowed inside a generator now, but eventually they may be allowed + // as local types. Regardless, any yield statements contained within them should be + // skipped in this traversal. + return; + default: + if (isFunctionLike(node)) { + var name_5 = node.name; + if (name_5 && name_5.kind === 136 /* ComputedPropertyName */) { + // Note that we will not include methods/accessors of a class because they would require + // first descending into the class. This is by design. + traverse(name_5.expression); + return; + } + } + else if (!isTypeNode(node)) { + // This is the general case, which should include mostly expressions and statements. + // Also includes NodeArrays. + ts.forEachChild(node, traverse); + } + } + } + } + ts.forEachYieldExpression = forEachYieldExpression; + function isVariableLike(node) { + if (node) { + switch (node.kind) { + case 163 /* BindingElement */: + case 247 /* EnumMember */: + case 138 /* Parameter */: + case 245 /* PropertyAssignment */: + case 141 /* PropertyDeclaration */: + case 140 /* PropertySignature */: + case 246 /* ShorthandPropertyAssignment */: + case 211 /* VariableDeclaration */: + return true; + } + } + return false; + } + ts.isVariableLike = isVariableLike; + function isAccessor(node) { + return node && (node.kind === 145 /* GetAccessor */ || node.kind === 146 /* SetAccessor */); + } + ts.isAccessor = isAccessor; + function isClassLike(node) { + return node && (node.kind === 214 /* ClassDeclaration */ || node.kind === 186 /* ClassExpression */); + } + ts.isClassLike = isClassLike; + function isFunctionLike(node) { + if (node) { + switch (node.kind) { + case 144 /* Constructor */: + case 173 /* FunctionExpression */: + case 213 /* FunctionDeclaration */: + case 174 /* ArrowFunction */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: + case 147 /* CallSignature */: + case 148 /* ConstructSignature */: + case 149 /* IndexSignature */: + case 152 /* FunctionType */: + case 153 /* ConstructorType */: + return true; + } + } + return false; + } + ts.isFunctionLike = isFunctionLike; + function introducesArgumentsExoticObject(node) { + switch (node.kind) { + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: + case 144 /* Constructor */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: + case 213 /* FunctionDeclaration */: + case 173 /* FunctionExpression */: + return true; + } + return false; + } + ts.introducesArgumentsExoticObject = introducesArgumentsExoticObject; + function isIterationStatement(node, lookInLabeledStatements) { + switch (node.kind) { + case 199 /* ForStatement */: + case 200 /* ForInStatement */: + case 201 /* ForOfStatement */: + case 197 /* DoStatement */: + case 198 /* WhileStatement */: + return true; + case 207 /* LabeledStatement */: + return lookInLabeledStatements && isIterationStatement(node.statement, lookInLabeledStatements); + } + return false; + } + ts.isIterationStatement = isIterationStatement; + function isFunctionBlock(node) { + return node && node.kind === 192 /* Block */ && isFunctionLike(node.parent); + } + ts.isFunctionBlock = isFunctionBlock; + function isObjectLiteralMethod(node) { + return node && node.kind === 143 /* MethodDeclaration */ && node.parent.kind === 165 /* ObjectLiteralExpression */; + } + ts.isObjectLiteralMethod = isObjectLiteralMethod; + function getContainingFunction(node) { + while (true) { + node = node.parent; + if (!node || isFunctionLike(node)) { + return node; + } + } + } + ts.getContainingFunction = getContainingFunction; + function getContainingClass(node) { + while (true) { + node = node.parent; + if (!node || isClassLike(node)) { + return node; + } + } + } + ts.getContainingClass = getContainingClass; + function getThisContainer(node, includeArrowFunctions) { + while (true) { + node = node.parent; + if (!node) { + return undefined; + } + switch (node.kind) { + case 136 /* ComputedPropertyName */: + // If the grandparent node is an object literal (as opposed to a class), + // then the computed property is not a 'this' container. + // A computed property name in a class needs to be a this container + // so that we can error on it. + if (isClassLike(node.parent.parent)) { + return node; + } + // If this is a computed property, then the parent should not + // make it a this container. The parent might be a property + // in an object literal, like a method or accessor. But in order for + // such a parent to be a this container, the reference must be in + // the *body* of the container. + node = node.parent; + break; + case 139 /* Decorator */: + // Decorators are always applied outside of the body of a class or method. + if (node.parent.kind === 138 /* Parameter */ && isClassElement(node.parent.parent)) { + // If the decorator's parent is a Parameter, we resolve the this container from + // the grandparent class declaration. + node = node.parent.parent; + } + else if (isClassElement(node.parent)) { + // If the decorator's parent is a class element, we resolve the 'this' container + // from the parent class declaration. + node = node.parent; + } + break; + case 174 /* ArrowFunction */: + if (!includeArrowFunctions) { + continue; + } + // Fall through + case 213 /* FunctionDeclaration */: + case 173 /* FunctionExpression */: + case 218 /* ModuleDeclaration */: + case 141 /* PropertyDeclaration */: + case 140 /* PropertySignature */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: + case 144 /* Constructor */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: + case 147 /* CallSignature */: + case 148 /* ConstructSignature */: + case 149 /* IndexSignature */: + case 217 /* EnumDeclaration */: + case 248 /* SourceFile */: + return node; + } + } + } + ts.getThisContainer = getThisContainer; + function getSuperContainer(node, includeFunctions) { + while (true) { + node = node.parent; + if (!node) + return node; + switch (node.kind) { + case 136 /* ComputedPropertyName */: + // If the grandparent node is an object literal (as opposed to a class), + // then the computed property is not a 'super' container. + // A computed property name in a class needs to be a super container + // so that we can error on it. + if (isClassLike(node.parent.parent)) { + return node; + } + // If this is a computed property, then the parent should not + // make it a super container. The parent might be a property + // in an object literal, like a method or accessor. But in order for + // such a parent to be a super container, the reference must be in + // the *body* of the container. + node = node.parent; + break; + case 139 /* Decorator */: + // Decorators are always applied outside of the body of a class or method. + if (node.parent.kind === 138 /* Parameter */ && isClassElement(node.parent.parent)) { + // If the decorator's parent is a Parameter, we resolve the this container from + // the grandparent class declaration. + node = node.parent.parent; + } + else if (isClassElement(node.parent)) { + // If the decorator's parent is a class element, we resolve the 'this' container + // from the parent class declaration. + node = node.parent; + } + break; + case 213 /* FunctionDeclaration */: + case 173 /* FunctionExpression */: + case 174 /* ArrowFunction */: + if (!includeFunctions) { + continue; + } + case 141 /* PropertyDeclaration */: + case 140 /* PropertySignature */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: + case 144 /* Constructor */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: + return node; + } + } + } + ts.getSuperContainer = getSuperContainer; + function getEntityNameFromTypeNode(node) { + if (node) { + switch (node.kind) { + case 151 /* TypeReference */: + return node.typeName; + case 188 /* ExpressionWithTypeArguments */: + return node.expression; + case 69 /* Identifier */: + case 135 /* QualifiedName */: + return node; + } + } + return undefined; + } + ts.getEntityNameFromTypeNode = getEntityNameFromTypeNode; + function getInvokedExpression(node) { + if (node.kind === 170 /* TaggedTemplateExpression */) { + return node.tag; + } + // Will either be a CallExpression, NewExpression, or Decorator. + return node.expression; + } + ts.getInvokedExpression = getInvokedExpression; + function nodeCanBeDecorated(node) { + switch (node.kind) { + case 214 /* ClassDeclaration */: + // classes are valid targets + return true; + case 141 /* PropertyDeclaration */: + // property declarations are valid if their parent is a class declaration. + return node.parent.kind === 214 /* ClassDeclaration */; + case 138 /* Parameter */: + // if the parameter's parent has a body and its grandparent is a class declaration, this is a valid target; + return node.parent.body && node.parent.parent.kind === 214 /* ClassDeclaration */; + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: + case 143 /* MethodDeclaration */: + // if this method has a body and its parent is a class declaration, this is a valid target. + return node.body && node.parent.kind === 214 /* ClassDeclaration */; + } + return false; + } + ts.nodeCanBeDecorated = nodeCanBeDecorated; + function nodeIsDecorated(node) { + switch (node.kind) { + case 214 /* ClassDeclaration */: + if (node.decorators) { + return true; + } + return false; + case 141 /* PropertyDeclaration */: + case 138 /* Parameter */: + if (node.decorators) { + return true; + } + return false; + case 145 /* GetAccessor */: + if (node.body && node.decorators) { + return true; + } + return false; + case 143 /* MethodDeclaration */: + case 146 /* SetAccessor */: + if (node.body && node.decorators) { + return true; + } + return false; + } + return false; + } + ts.nodeIsDecorated = nodeIsDecorated; + function childIsDecorated(node) { + switch (node.kind) { + case 214 /* ClassDeclaration */: + return ts.forEach(node.members, nodeOrChildIsDecorated); + case 143 /* MethodDeclaration */: + case 146 /* SetAccessor */: + return ts.forEach(node.parameters, nodeIsDecorated); + } + return false; + } + ts.childIsDecorated = childIsDecorated; + function nodeOrChildIsDecorated(node) { + return nodeIsDecorated(node) || childIsDecorated(node); + } + ts.nodeOrChildIsDecorated = nodeOrChildIsDecorated; + function isPropertyAccessExpression(node) { + return node.kind === 166 /* PropertyAccessExpression */; + } + ts.isPropertyAccessExpression = isPropertyAccessExpression; + function isElementAccessExpression(node) { + return node.kind === 167 /* ElementAccessExpression */; + } + ts.isElementAccessExpression = isElementAccessExpression; + function isExpression(node) { + switch (node.kind) { + case 95 /* SuperKeyword */: + case 93 /* NullKeyword */: + case 99 /* TrueKeyword */: + case 84 /* FalseKeyword */: + case 10 /* RegularExpressionLiteral */: + case 164 /* ArrayLiteralExpression */: + case 165 /* ObjectLiteralExpression */: + case 166 /* PropertyAccessExpression */: + case 167 /* ElementAccessExpression */: + case 168 /* CallExpression */: + case 169 /* NewExpression */: + case 170 /* TaggedTemplateExpression */: + case 189 /* AsExpression */: + case 171 /* TypeAssertionExpression */: + case 172 /* ParenthesizedExpression */: + case 173 /* FunctionExpression */: + case 186 /* ClassExpression */: + case 174 /* ArrowFunction */: + case 177 /* VoidExpression */: + case 175 /* DeleteExpression */: + case 176 /* TypeOfExpression */: + case 179 /* PrefixUnaryExpression */: + case 180 /* PostfixUnaryExpression */: + case 181 /* BinaryExpression */: + case 182 /* ConditionalExpression */: + case 185 /* SpreadElementExpression */: + case 183 /* TemplateExpression */: + case 11 /* NoSubstitutionTemplateLiteral */: + case 187 /* OmittedExpression */: + case 233 /* JsxElement */: + case 234 /* JsxSelfClosingElement */: + case 184 /* YieldExpression */: + case 178 /* AwaitExpression */: + return true; + case 135 /* QualifiedName */: + while (node.parent.kind === 135 /* QualifiedName */) { + node = node.parent; + } + return node.parent.kind === 154 /* TypeQuery */; + case 69 /* Identifier */: + if (node.parent.kind === 154 /* TypeQuery */) { + return true; + } + // fall through + case 8 /* NumericLiteral */: + case 9 /* StringLiteral */: + case 97 /* ThisKeyword */: + var parent_2 = node.parent; + switch (parent_2.kind) { + case 211 /* VariableDeclaration */: + case 138 /* Parameter */: + case 141 /* PropertyDeclaration */: + case 140 /* PropertySignature */: + case 247 /* EnumMember */: + case 245 /* PropertyAssignment */: + case 163 /* BindingElement */: + return parent_2.initializer === node; + case 195 /* ExpressionStatement */: + case 196 /* IfStatement */: + case 197 /* DoStatement */: + case 198 /* WhileStatement */: + case 204 /* ReturnStatement */: + case 205 /* WithStatement */: + case 206 /* SwitchStatement */: + case 241 /* CaseClause */: + case 208 /* ThrowStatement */: + case 206 /* SwitchStatement */: + return parent_2.expression === node; + case 199 /* ForStatement */: + var forStatement = parent_2; + return (forStatement.initializer === node && forStatement.initializer.kind !== 212 /* VariableDeclarationList */) || + forStatement.condition === node || + forStatement.incrementor === node; + case 200 /* ForInStatement */: + case 201 /* ForOfStatement */: + var forInStatement = parent_2; + return (forInStatement.initializer === node && forInStatement.initializer.kind !== 212 /* VariableDeclarationList */) || + forInStatement.expression === node; + case 171 /* TypeAssertionExpression */: + case 189 /* AsExpression */: + return node === parent_2.expression; + case 190 /* TemplateSpan */: + return node === parent_2.expression; + case 136 /* ComputedPropertyName */: + return node === parent_2.expression; + case 139 /* Decorator */: + case 240 /* JsxExpression */: + case 239 /* JsxSpreadAttribute */: + return true; + case 188 /* ExpressionWithTypeArguments */: + return parent_2.expression === node && isExpressionWithTypeArgumentsInClassExtendsClause(parent_2); + default: + if (isExpression(parent_2)) { + return true; + } + } + } + return false; + } + ts.isExpression = isExpression; + function isExternalModuleNameRelative(moduleName) { + // TypeScript 1.0 spec (April 2014): 11.2.1 + // An external module name is "relative" if the first term is "." or "..". + return moduleName.substr(0, 2) === "./" || moduleName.substr(0, 3) === "../" || moduleName.substr(0, 2) === ".\\" || moduleName.substr(0, 3) === "..\\"; + } + ts.isExternalModuleNameRelative = isExternalModuleNameRelative; + function isInstantiatedModule(node, preserveConstEnums) { + var moduleState = ts.getModuleInstanceState(node); + return moduleState === 1 /* Instantiated */ || + (preserveConstEnums && moduleState === 2 /* ConstEnumOnly */); + } + ts.isInstantiatedModule = isInstantiatedModule; + function isExternalModuleImportEqualsDeclaration(node) { + return node.kind === 221 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 232 /* ExternalModuleReference */; + } + ts.isExternalModuleImportEqualsDeclaration = isExternalModuleImportEqualsDeclaration; + function getExternalModuleImportEqualsDeclarationExpression(node) { + ts.Debug.assert(isExternalModuleImportEqualsDeclaration(node)); + return node.moduleReference.expression; + } + ts.getExternalModuleImportEqualsDeclarationExpression = getExternalModuleImportEqualsDeclarationExpression; + function isInternalModuleImportEqualsDeclaration(node) { + return node.kind === 221 /* ImportEqualsDeclaration */ && node.moduleReference.kind !== 232 /* ExternalModuleReference */; + } + ts.isInternalModuleImportEqualsDeclaration = isInternalModuleImportEqualsDeclaration; + function getExternalModuleName(node) { + if (node.kind === 222 /* ImportDeclaration */) { + return node.moduleSpecifier; + } + if (node.kind === 221 /* ImportEqualsDeclaration */) { + var reference = node.moduleReference; + if (reference.kind === 232 /* ExternalModuleReference */) { + return reference.expression; + } + } + if (node.kind === 228 /* ExportDeclaration */) { + return node.moduleSpecifier; + } + } + ts.getExternalModuleName = getExternalModuleName; + function hasQuestionToken(node) { + if (node) { + switch (node.kind) { + case 138 /* Parameter */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: + case 246 /* ShorthandPropertyAssignment */: + case 245 /* PropertyAssignment */: + case 141 /* PropertyDeclaration */: + case 140 /* PropertySignature */: + return node.questionToken !== undefined; + } + } + return false; + } + ts.hasQuestionToken = hasQuestionToken; + function isJSDocConstructSignature(node) { + return node.kind === 261 /* JSDocFunctionType */ && + node.parameters.length > 0 && + node.parameters[0].type.kind === 263 /* JSDocConstructorType */; + } + ts.isJSDocConstructSignature = isJSDocConstructSignature; + function getJSDocTag(node, kind) { + if (node && node.jsDocComment) { + for (var _i = 0, _a = node.jsDocComment.tags; _i < _a.length; _i++) { + var tag = _a[_i]; + if (tag.kind === kind) { + return tag; + } + } + } + } + function getJSDocTypeTag(node) { + return getJSDocTag(node, 269 /* JSDocTypeTag */); + } + ts.getJSDocTypeTag = getJSDocTypeTag; + function getJSDocReturnTag(node) { + return getJSDocTag(node, 268 /* JSDocReturnTag */); + } + ts.getJSDocReturnTag = getJSDocReturnTag; + function getJSDocTemplateTag(node) { + return getJSDocTag(node, 270 /* JSDocTemplateTag */); + } + ts.getJSDocTemplateTag = getJSDocTemplateTag; + function getCorrespondingJSDocParameterTag(parameter) { + if (parameter.name && parameter.name.kind === 69 /* Identifier */) { + // If it's a parameter, see if the parent has a jsdoc comment with an @param + // annotation. + var parameterName = parameter.name.text; + var docComment = parameter.parent.jsDocComment; + if (docComment) { + return ts.forEach(docComment.tags, function (t) { + if (t.kind === 267 /* JSDocParameterTag */) { + var parameterTag = t; + var name_6 = parameterTag.preParameterName || parameterTag.postParameterName; + if (name_6.text === parameterName) { + return t; + } + } + }); + } + } + } + ts.getCorrespondingJSDocParameterTag = getCorrespondingJSDocParameterTag; + function hasRestParameter(s) { + return isRestParameter(ts.lastOrUndefined(s.parameters)); + } + ts.hasRestParameter = hasRestParameter; + function isRestParameter(node) { + if (node) { + if (node.parserContextFlags & 32 /* JavaScriptFile */) { + if (node.type && node.type.kind === 262 /* JSDocVariadicType */) { + return true; + } + var paramTag = getCorrespondingJSDocParameterTag(node); + if (paramTag && paramTag.typeExpression) { + return paramTag.typeExpression.type.kind === 262 /* JSDocVariadicType */; + } + } + return node.dotDotDotToken !== undefined; + } + return false; + } + ts.isRestParameter = isRestParameter; + function isLiteralKind(kind) { + return 8 /* FirstLiteralToken */ <= kind && kind <= 11 /* LastLiteralToken */; + } + ts.isLiteralKind = isLiteralKind; + function isTextualLiteralKind(kind) { + return kind === 9 /* StringLiteral */ || kind === 11 /* NoSubstitutionTemplateLiteral */; + } + ts.isTextualLiteralKind = isTextualLiteralKind; + function isTemplateLiteralKind(kind) { + return 11 /* FirstTemplateToken */ <= kind && kind <= 14 /* LastTemplateToken */; + } + ts.isTemplateLiteralKind = isTemplateLiteralKind; + function isBindingPattern(node) { + return !!node && (node.kind === 162 /* ArrayBindingPattern */ || node.kind === 161 /* ObjectBindingPattern */); + } + ts.isBindingPattern = isBindingPattern; + function isInAmbientContext(node) { + while (node) { + if (node.flags & (2 /* Ambient */ | 8192 /* DeclarationFile */)) { + return true; + } + node = node.parent; + } + return false; + } + ts.isInAmbientContext = isInAmbientContext; + function isDeclaration(node) { + switch (node.kind) { + case 174 /* ArrowFunction */: + case 163 /* BindingElement */: + case 214 /* ClassDeclaration */: + case 186 /* ClassExpression */: + case 144 /* Constructor */: + case 217 /* EnumDeclaration */: + case 247 /* EnumMember */: + case 230 /* ExportSpecifier */: + case 213 /* FunctionDeclaration */: + case 173 /* FunctionExpression */: + case 145 /* GetAccessor */: + case 223 /* ImportClause */: + case 221 /* ImportEqualsDeclaration */: + case 226 /* ImportSpecifier */: + case 215 /* InterfaceDeclaration */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: + case 218 /* ModuleDeclaration */: + case 224 /* NamespaceImport */: + case 138 /* Parameter */: + case 245 /* PropertyAssignment */: + case 141 /* PropertyDeclaration */: + case 140 /* PropertySignature */: + case 146 /* SetAccessor */: + case 246 /* ShorthandPropertyAssignment */: + case 216 /* TypeAliasDeclaration */: + case 137 /* TypeParameter */: + case 211 /* VariableDeclaration */: + return true; + } + return false; + } + ts.isDeclaration = isDeclaration; + function isStatement(n) { + switch (n.kind) { + case 203 /* BreakStatement */: + case 202 /* ContinueStatement */: + case 210 /* DebuggerStatement */: + case 197 /* DoStatement */: + case 195 /* ExpressionStatement */: + case 194 /* EmptyStatement */: + case 200 /* ForInStatement */: + case 201 /* ForOfStatement */: + case 199 /* ForStatement */: + case 196 /* IfStatement */: + case 207 /* LabeledStatement */: + case 204 /* ReturnStatement */: + case 206 /* SwitchStatement */: + case 98 /* ThrowKeyword */: + case 209 /* TryStatement */: + case 193 /* VariableStatement */: + case 198 /* WhileStatement */: + case 205 /* WithStatement */: + case 227 /* ExportAssignment */: + return true; + default: + return false; + } + } + ts.isStatement = isStatement; + function isClassElement(n) { + switch (n.kind) { + case 144 /* Constructor */: + case 141 /* PropertyDeclaration */: + case 143 /* MethodDeclaration */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: + case 142 /* MethodSignature */: + case 149 /* IndexSignature */: + return true; + default: + return false; + } + } + ts.isClassElement = isClassElement; + // True if the given identifier, string literal, or number literal is the name of a declaration node + function isDeclarationName(name) { + if (name.kind !== 69 /* Identifier */ && name.kind !== 9 /* StringLiteral */ && name.kind !== 8 /* NumericLiteral */) { + return false; + } + var parent = name.parent; + if (parent.kind === 226 /* ImportSpecifier */ || parent.kind === 230 /* ExportSpecifier */) { + if (parent.propertyName) { + return true; + } + } + if (isDeclaration(parent)) { + return parent.name === name; + } + return false; + } + ts.isDeclarationName = isDeclarationName; + // Return true if the given identifier is classified as an IdentifierName + function isIdentifierName(node) { + var parent = node.parent; + switch (parent.kind) { + case 141 /* PropertyDeclaration */: + case 140 /* PropertySignature */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: + case 247 /* EnumMember */: + case 245 /* PropertyAssignment */: + case 166 /* PropertyAccessExpression */: + // Name in member declaration or property name in property access + return parent.name === node; + case 135 /* QualifiedName */: + // Name on right hand side of dot in a type query + if (parent.right === node) { + while (parent.kind === 135 /* QualifiedName */) { + parent = parent.parent; + } + return parent.kind === 154 /* TypeQuery */; + } + return false; + case 163 /* BindingElement */: + case 226 /* ImportSpecifier */: + // Property name in binding element or import specifier + return parent.propertyName === node; + case 230 /* ExportSpecifier */: + // Any name in an export specifier + return true; + } + return false; + } + ts.isIdentifierName = isIdentifierName; + // An alias symbol is created by one of the following declarations: + // import = ... + // import from ... + // import * as from ... + // import { x as } from ... + // export { x as } from ... + // export = ... + // export default ... + function isAliasSymbolDeclaration(node) { + return node.kind === 221 /* ImportEqualsDeclaration */ || + node.kind === 223 /* ImportClause */ && !!node.name || + node.kind === 224 /* NamespaceImport */ || + node.kind === 226 /* ImportSpecifier */ || + node.kind === 230 /* ExportSpecifier */ || + node.kind === 227 /* ExportAssignment */ && node.expression.kind === 69 /* Identifier */; + } + ts.isAliasSymbolDeclaration = isAliasSymbolDeclaration; + function getClassExtendsHeritageClauseElement(node) { + var heritageClause = getHeritageClause(node.heritageClauses, 83 /* ExtendsKeyword */); + return heritageClause && heritageClause.types.length > 0 ? heritageClause.types[0] : undefined; + } + ts.getClassExtendsHeritageClauseElement = getClassExtendsHeritageClauseElement; + function getClassImplementsHeritageClauseElements(node) { + var heritageClause = getHeritageClause(node.heritageClauses, 106 /* ImplementsKeyword */); + return heritageClause ? heritageClause.types : undefined; + } + ts.getClassImplementsHeritageClauseElements = getClassImplementsHeritageClauseElements; + function getInterfaceBaseTypeNodes(node) { + var heritageClause = getHeritageClause(node.heritageClauses, 83 /* ExtendsKeyword */); + return heritageClause ? heritageClause.types : undefined; + } + ts.getInterfaceBaseTypeNodes = getInterfaceBaseTypeNodes; + function getHeritageClause(clauses, kind) { + if (clauses) { + for (var _i = 0; _i < clauses.length; _i++) { + var clause = clauses[_i]; + if (clause.token === kind) { + return clause; + } + } + } + return undefined; + } + ts.getHeritageClause = getHeritageClause; + function tryResolveScriptReference(host, sourceFile, reference) { + if (!host.getCompilerOptions().noResolve) { + var referenceFileName = ts.isRootedDiskPath(reference.fileName) ? reference.fileName : ts.combinePaths(ts.getDirectoryPath(sourceFile.fileName), reference.fileName); + referenceFileName = ts.getNormalizedAbsolutePath(referenceFileName, host.getCurrentDirectory()); + return host.getSourceFile(referenceFileName); + } + } + ts.tryResolveScriptReference = tryResolveScriptReference; + function getAncestor(node, kind) { + while (node) { + if (node.kind === kind) { + return node; + } + node = node.parent; + } + return undefined; + } + ts.getAncestor = getAncestor; + function getFileReferenceFromReferencePath(comment, commentRange) { + var simpleReferenceRegEx = /^\/\/\/\s*/gim; + if (simpleReferenceRegEx.exec(comment)) { + if (isNoDefaultLibRegEx.exec(comment)) { + return { + isNoDefaultLib: true + }; + } + else { + var matchResult = ts.fullTripleSlashReferencePathRegEx.exec(comment); + if (matchResult) { + var start = commentRange.pos; + var end = commentRange.end; + return { + fileReference: { + pos: start, + end: end, + fileName: matchResult[3] + }, + isNoDefaultLib: false + }; + } + else { + return { + diagnosticMessage: ts.Diagnostics.Invalid_reference_directive_syntax, + isNoDefaultLib: false + }; + } + } + } + return undefined; + } + ts.getFileReferenceFromReferencePath = getFileReferenceFromReferencePath; + function isKeyword(token) { + return 70 /* FirstKeyword */ <= token && token <= 134 /* LastKeyword */; + } + ts.isKeyword = isKeyword; + function isTrivia(token) { + return 2 /* FirstTriviaToken */ <= token && token <= 7 /* LastTriviaToken */; + } + ts.isTrivia = isTrivia; + function isAsyncFunctionLike(node) { + return isFunctionLike(node) && (node.flags & 512 /* Async */) !== 0 && !isAccessor(node); + } + ts.isAsyncFunctionLike = isAsyncFunctionLike; + /** + * A declaration has a dynamic name if both of the following are true: + * 1. The declaration has a computed property name + * 2. The computed name is *not* expressed as Symbol., where name + * is a property of the Symbol constructor that denotes a built in + * Symbol. + */ + function hasDynamicName(declaration) { + return declaration.name && + declaration.name.kind === 136 /* ComputedPropertyName */ && + !isWellKnownSymbolSyntactically(declaration.name.expression); + } + ts.hasDynamicName = hasDynamicName; + /** + * Checks if the expression is of the form: + * Symbol.name + * where Symbol is literally the word "Symbol", and name is any identifierName + */ + function isWellKnownSymbolSyntactically(node) { + return isPropertyAccessExpression(node) && isESSymbolIdentifier(node.expression); + } + ts.isWellKnownSymbolSyntactically = isWellKnownSymbolSyntactically; + function getPropertyNameForPropertyNameNode(name) { + if (name.kind === 69 /* Identifier */ || name.kind === 9 /* StringLiteral */ || name.kind === 8 /* NumericLiteral */) { + return name.text; + } + if (name.kind === 136 /* ComputedPropertyName */) { + var nameExpression = name.expression; + if (isWellKnownSymbolSyntactically(nameExpression)) { + var rightHandSideName = nameExpression.name.text; + return getPropertyNameForKnownSymbolName(rightHandSideName); + } + } + return undefined; + } + ts.getPropertyNameForPropertyNameNode = getPropertyNameForPropertyNameNode; + function getPropertyNameForKnownSymbolName(symbolName) { + return "__@" + symbolName; + } + ts.getPropertyNameForKnownSymbolName = getPropertyNameForKnownSymbolName; + /** + * Includes the word "Symbol" with unicode escapes + */ + function isESSymbolIdentifier(node) { + return node.kind === 69 /* Identifier */ && node.text === "Symbol"; + } + ts.isESSymbolIdentifier = isESSymbolIdentifier; + function isModifier(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 113 /* StaticKeyword */: + return true; + } + return false; + } + ts.isModifier = isModifier; + function isParameterDeclaration(node) { + var root = getRootDeclaration(node); + return root.kind === 138 /* Parameter */; + } + ts.isParameterDeclaration = isParameterDeclaration; + function getRootDeclaration(node) { + while (node.kind === 163 /* BindingElement */) { + node = node.parent.parent; + } + return node; + } + ts.getRootDeclaration = getRootDeclaration; + function nodeStartsNewLexicalEnvironment(n) { + return isFunctionLike(n) || n.kind === 218 /* ModuleDeclaration */ || n.kind === 248 /* SourceFile */; + } + ts.nodeStartsNewLexicalEnvironment = nodeStartsNewLexicalEnvironment; + function cloneEntityName(node) { + if (node.kind === 69 /* Identifier */) { + var clone_1 = createSynthesizedNode(69 /* Identifier */); + clone_1.text = node.text; + return clone_1; + } + else { + var clone_2 = createSynthesizedNode(135 /* QualifiedName */); + clone_2.left = cloneEntityName(node.left); + clone_2.left.parent = clone_2; + clone_2.right = cloneEntityName(node.right); + clone_2.right.parent = clone_2; + return clone_2; + } + } + ts.cloneEntityName = cloneEntityName; + function nodeIsSynthesized(node) { + return node.pos === -1; + } + ts.nodeIsSynthesized = nodeIsSynthesized; + function createSynthesizedNode(kind, startsOnNewLine) { + var node = ts.createNode(kind, /* pos */ -1, /* end */ -1); + node.startsOnNewLine = startsOnNewLine; + return node; + } + ts.createSynthesizedNode = createSynthesizedNode; + function createSynthesizedNodeArray() { + var array = []; + array.pos = -1; + array.end = -1; + return array; + } + ts.createSynthesizedNodeArray = createSynthesizedNodeArray; + function createDiagnosticCollection() { + var nonFileDiagnostics = []; + var fileDiagnostics = {}; + var diagnosticsModified = false; + var modificationCount = 0; + return { + add: add, + getGlobalDiagnostics: getGlobalDiagnostics, + getDiagnostics: getDiagnostics, + getModificationCount: getModificationCount, + reattachFileDiagnostics: reattachFileDiagnostics + }; + function getModificationCount() { + return modificationCount; + } + function reattachFileDiagnostics(newFile) { + if (!ts.hasProperty(fileDiagnostics, newFile.fileName)) { + return; + } + for (var _i = 0, _a = fileDiagnostics[newFile.fileName]; _i < _a.length; _i++) { + var diagnostic = _a[_i]; + diagnostic.file = newFile; + } + } + function add(diagnostic) { + var diagnostics; + if (diagnostic.file) { + diagnostics = fileDiagnostics[diagnostic.file.fileName]; + if (!diagnostics) { + diagnostics = []; + fileDiagnostics[diagnostic.file.fileName] = diagnostics; + } + } + else { + diagnostics = nonFileDiagnostics; + } + diagnostics.push(diagnostic); + diagnosticsModified = true; + modificationCount++; + } + function getGlobalDiagnostics() { + sortAndDeduplicate(); + return nonFileDiagnostics; + } + function getDiagnostics(fileName) { + sortAndDeduplicate(); + if (fileName) { + return fileDiagnostics[fileName] || []; + } + var allDiagnostics = []; + function pushDiagnostic(d) { + allDiagnostics.push(d); + } + ts.forEach(nonFileDiagnostics, pushDiagnostic); + for (var key in fileDiagnostics) { + if (ts.hasProperty(fileDiagnostics, key)) { + ts.forEach(fileDiagnostics[key], pushDiagnostic); + } + } + return ts.sortAndDeduplicateDiagnostics(allDiagnostics); + } + function sortAndDeduplicate() { + if (!diagnosticsModified) { + return; + } + diagnosticsModified = false; + nonFileDiagnostics = ts.sortAndDeduplicateDiagnostics(nonFileDiagnostics); + for (var key in fileDiagnostics) { + if (ts.hasProperty(fileDiagnostics, key)) { + fileDiagnostics[key] = ts.sortAndDeduplicateDiagnostics(fileDiagnostics[key]); + } + } + } + } + ts.createDiagnosticCollection = createDiagnosticCollection; + // This consists of the first 19 unprintable ASCII characters, canonical escapes, lineSeparator, + // paragraphSeparator, and nextLine. The latter three are just desirable to suppress new lines in + // the language service. These characters should be escaped when printing, and if any characters are added, + // the map below must be updated. Note that this regexp *does not* include the 'delete' character. + // There is no reason for this other than that JSON.stringify does not handle it either. + var escapedCharsRegExp = /[\\\"\u0000-\u001f\t\v\f\b\r\n\u2028\u2029\u0085]/g; + var escapedCharsMap = { + "\0": "\\0", + "\t": "\\t", + "\v": "\\v", + "\f": "\\f", + "\b": "\\b", + "\r": "\\r", + "\n": "\\n", + "\\": "\\\\", + "\"": "\\\"", + "\u2028": "\\u2028", + "\u2029": "\\u2029", + "\u0085": "\\u0085" // nextLine + }; + /** + * Based heavily on the abstract 'Quote'/'QuoteJSONString' operation from ECMA-262 (24.3.2.2), + * but augmented for a few select characters (e.g. lineSeparator, paragraphSeparator, nextLine) + * Note that this doesn't actually wrap the input in double quotes. + */ + function escapeString(s) { + s = escapedCharsRegExp.test(s) ? s.replace(escapedCharsRegExp, getReplacement) : s; + return s; + function getReplacement(c) { + return escapedCharsMap[c] || get16BitUnicodeEscapeSequence(c.charCodeAt(0)); + } + } + ts.escapeString = escapeString; + function isIntrinsicJsxName(name) { + var ch = name.substr(0, 1); + return ch.toLowerCase() === ch; + } + ts.isIntrinsicJsxName = isIntrinsicJsxName; + function get16BitUnicodeEscapeSequence(charCode) { + var hexCharCode = charCode.toString(16).toUpperCase(); + var paddedHexCode = ("0000" + hexCharCode).slice(-4); + return "\\u" + paddedHexCode; + } + var nonAsciiCharacters = /[^\u0000-\u007F]/g; + function escapeNonAsciiCharacters(s) { + // Replace non-ASCII characters with '\uNNNN' escapes if any exist. + // Otherwise just return the original string. + return nonAsciiCharacters.test(s) ? + s.replace(nonAsciiCharacters, function (c) { return get16BitUnicodeEscapeSequence(c.charCodeAt(0)); }) : + s; + } + ts.escapeNonAsciiCharacters = escapeNonAsciiCharacters; + var indentStrings = ["", " "]; + function getIndentString(level) { + if (indentStrings[level] === undefined) { + indentStrings[level] = getIndentString(level - 1) + indentStrings[1]; + } + return indentStrings[level]; + } + ts.getIndentString = getIndentString; + function getIndentSize() { + return indentStrings[1].length; + } + ts.getIndentSize = getIndentSize; + function createTextWriter(newLine) { + var output = ""; + var indent = 0; + var lineStart = true; + var lineCount = 0; + var linePos = 0; + function write(s) { + if (s && s.length) { + if (lineStart) { + output += getIndentString(indent); + lineStart = false; + } + output += s; + } + } + function rawWrite(s) { + if (s !== undefined) { + if (lineStart) { + lineStart = false; + } + output += s; + } + } + function writeLiteral(s) { + if (s && s.length) { + write(s); + var lineStartsOfS = ts.computeLineStarts(s); + if (lineStartsOfS.length > 1) { + lineCount = lineCount + lineStartsOfS.length - 1; + linePos = output.length - s.length + ts.lastOrUndefined(lineStartsOfS); + } + } + } + function writeLine() { + if (!lineStart) { + output += newLine; + lineCount++; + linePos = output.length; + lineStart = true; + } + } + function writeTextOfNode(sourceFile, node) { + write(getSourceTextOfNodeFromSourceFile(sourceFile, node)); + } + return { + write: write, + rawWrite: rawWrite, + writeTextOfNode: writeTextOfNode, + writeLiteral: writeLiteral, + writeLine: writeLine, + increaseIndent: function () { return indent++; }, + decreaseIndent: function () { return indent--; }, + getIndent: function () { return indent; }, + getTextPos: function () { return output.length; }, + getLine: function () { return lineCount + 1; }, + getColumn: function () { return lineStart ? indent * getIndentSize() + 1 : output.length - linePos + 1; }, + getText: function () { return output; } + }; + } + ts.createTextWriter = createTextWriter; + function getOwnEmitOutputFilePath(sourceFile, host, extension) { + var compilerOptions = host.getCompilerOptions(); + var emitOutputFilePathWithoutExtension; + if (compilerOptions.outDir) { + emitOutputFilePathWithoutExtension = ts.removeFileExtension(getSourceFilePathInNewDir(sourceFile, host, compilerOptions.outDir)); + } + else { + emitOutputFilePathWithoutExtension = ts.removeFileExtension(sourceFile.fileName); + } + return emitOutputFilePathWithoutExtension + extension; + } + ts.getOwnEmitOutputFilePath = getOwnEmitOutputFilePath; + function getSourceFilePathInNewDir(sourceFile, host, newDirPath) { + var sourceFilePath = ts.getNormalizedAbsolutePath(sourceFile.fileName, host.getCurrentDirectory()); + sourceFilePath = sourceFilePath.replace(host.getCommonSourceDirectory(), ""); + return ts.combinePaths(newDirPath, sourceFilePath); + } + ts.getSourceFilePathInNewDir = getSourceFilePathInNewDir; + function writeFile(host, diagnostics, fileName, data, writeByteOrderMark) { + host.writeFile(fileName, data, writeByteOrderMark, function (hostErrorMessage) { + diagnostics.push(ts.createCompilerDiagnostic(ts.Diagnostics.Could_not_write_file_0_Colon_1, fileName, hostErrorMessage)); + }); + } + ts.writeFile = writeFile; + function getLineOfLocalPosition(currentSourceFile, pos) { + return ts.getLineAndCharacterOfPosition(currentSourceFile, pos).line; + } + ts.getLineOfLocalPosition = getLineOfLocalPosition; + function getFirstConstructorWithBody(node) { + return ts.forEach(node.members, function (member) { + if (member.kind === 144 /* Constructor */ && nodeIsPresent(member.body)) { + return member; + } + }); + } + ts.getFirstConstructorWithBody = getFirstConstructorWithBody; + function getSetAccessorTypeAnnotationNode(accessor) { + return accessor && accessor.parameters.length > 0 && accessor.parameters[0].type; + } + ts.getSetAccessorTypeAnnotationNode = getSetAccessorTypeAnnotationNode; + function shouldEmitToOwnFile(sourceFile, compilerOptions) { + if (!isDeclarationFile(sourceFile)) { + if ((isExternalModule(sourceFile) || !(compilerOptions.outFile || compilerOptions.out))) { + // 1. in-browser single file compilation scenario + // 2. non .js file + return compilerOptions.isolatedModules || !ts.fileExtensionIs(sourceFile.fileName, ".js"); + } + return false; + } + return false; + } + ts.shouldEmitToOwnFile = shouldEmitToOwnFile; + function getAllAccessorDeclarations(declarations, accessor) { + var firstAccessor; + var secondAccessor; + var getAccessor; + var setAccessor; + if (hasDynamicName(accessor)) { + firstAccessor = accessor; + if (accessor.kind === 145 /* GetAccessor */) { + getAccessor = accessor; + } + else if (accessor.kind === 146 /* SetAccessor */) { + setAccessor = accessor; + } + else { + ts.Debug.fail("Accessor has wrong kind"); + } + } + else { + ts.forEach(declarations, function (member) { + if ((member.kind === 145 /* GetAccessor */ || member.kind === 146 /* SetAccessor */) + && (member.flags & 128 /* Static */) === (accessor.flags & 128 /* Static */)) { + var memberName = getPropertyNameForPropertyNameNode(member.name); + var accessorName = getPropertyNameForPropertyNameNode(accessor.name); + if (memberName === accessorName) { + if (!firstAccessor) { + firstAccessor = member; + } + else if (!secondAccessor) { + secondAccessor = member; + } + if (member.kind === 145 /* GetAccessor */ && !getAccessor) { + getAccessor = member; + } + if (member.kind === 146 /* SetAccessor */ && !setAccessor) { + setAccessor = member; + } + } + } + }); + } + return { + firstAccessor: firstAccessor, + secondAccessor: secondAccessor, + getAccessor: getAccessor, + setAccessor: setAccessor + }; + } + ts.getAllAccessorDeclarations = getAllAccessorDeclarations; + function emitNewLineBeforeLeadingComments(currentSourceFile, writer, node, leadingComments) { + // If the leading comments start on different line than the start of node, write new line + if (leadingComments && leadingComments.length && node.pos !== leadingComments[0].pos && + getLineOfLocalPosition(currentSourceFile, node.pos) !== getLineOfLocalPosition(currentSourceFile, leadingComments[0].pos)) { + writer.writeLine(); + } + } + ts.emitNewLineBeforeLeadingComments = emitNewLineBeforeLeadingComments; + function emitComments(currentSourceFile, writer, comments, trailingSeparator, newLine, writeComment) { + var emitLeadingSpace = !trailingSeparator; + ts.forEach(comments, function (comment) { + if (emitLeadingSpace) { + writer.write(" "); + emitLeadingSpace = false; + } + writeComment(currentSourceFile, writer, comment, newLine); + if (comment.hasTrailingNewLine) { + writer.writeLine(); + } + else if (trailingSeparator) { + writer.write(" "); + } + else { + // Emit leading space to separate comment during next comment emit + emitLeadingSpace = true; + } + }); + } + ts.emitComments = emitComments; + function writeCommentRange(currentSourceFile, writer, comment, newLine) { + if (currentSourceFile.text.charCodeAt(comment.pos + 1) === 42 /* asterisk */) { + var firstCommentLineAndCharacter = ts.getLineAndCharacterOfPosition(currentSourceFile, comment.pos); + var lineCount = ts.getLineStarts(currentSourceFile).length; + var firstCommentLineIndent; + for (var pos = comment.pos, currentLine = firstCommentLineAndCharacter.line; pos < comment.end; currentLine++) { + var nextLineStart = (currentLine + 1) === lineCount + ? currentSourceFile.text.length + 1 + : getStartPositionOfLine(currentLine + 1, currentSourceFile); + if (pos !== comment.pos) { + // If we are not emitting first line, we need to write the spaces to adjust the alignment + if (firstCommentLineIndent === undefined) { + firstCommentLineIndent = calculateIndent(getStartPositionOfLine(firstCommentLineAndCharacter.line, currentSourceFile), comment.pos); + } + // These are number of spaces writer is going to write at current indent + var currentWriterIndentSpacing = writer.getIndent() * getIndentSize(); + // Number of spaces we want to be writing + // eg: Assume writer indent + // module m { + // /* starts at character 9 this is line 1 + // * starts at character pos 4 line --1 = 8 - 8 + 3 + // More left indented comment */ --2 = 8 - 8 + 2 + // class c { } + // } + // module m { + // /* this is line 1 -- Assume current writer indent 8 + // * line --3 = 8 - 4 + 5 + // More right indented comment */ --4 = 8 - 4 + 11 + // class c { } + // } + var spacesToEmit = currentWriterIndentSpacing - firstCommentLineIndent + calculateIndent(pos, nextLineStart); + if (spacesToEmit > 0) { + var numberOfSingleSpacesToEmit = spacesToEmit % getIndentSize(); + var indentSizeSpaceString = getIndentString((spacesToEmit - numberOfSingleSpacesToEmit) / getIndentSize()); + // Write indent size string ( in eg 1: = "", 2: "" , 3: string with 8 spaces 4: string with 12 spaces + writer.rawWrite(indentSizeSpaceString); + // Emit the single spaces (in eg: 1: 3 spaces, 2: 2 spaces, 3: 1 space, 4: 3 spaces) + while (numberOfSingleSpacesToEmit) { + writer.rawWrite(" "); + numberOfSingleSpacesToEmit--; + } + } + else { + // No spaces to emit write empty string + writer.rawWrite(""); + } + } + // Write the comment line text + writeTrimmedCurrentLine(pos, nextLineStart); + pos = nextLineStart; + } + } + else { + // Single line comment of style //.... + writer.write(currentSourceFile.text.substring(comment.pos, comment.end)); + } + function writeTrimmedCurrentLine(pos, nextLineStart) { + var end = Math.min(comment.end, nextLineStart - 1); + var currentLineText = currentSourceFile.text.substring(pos, end).replace(/^\s+|\s+$/g, ""); + if (currentLineText) { + // trimmed forward and ending spaces text + writer.write(currentLineText); + if (end !== comment.end) { + writer.writeLine(); + } + } + else { + // Empty string - make sure we write empty line + writer.writeLiteral(newLine); + } + } + function calculateIndent(pos, end) { + var currentLineIndent = 0; + for (; pos < end && ts.isWhiteSpace(currentSourceFile.text.charCodeAt(pos)); pos++) { + if (currentSourceFile.text.charCodeAt(pos) === 9 /* tab */) { + // Tabs = TabSize = indent size and go to next tabStop + currentLineIndent += getIndentSize() - (currentLineIndent % getIndentSize()); + } + else { + // Single space + currentLineIndent++; + } + } + return currentLineIndent; + } + } + ts.writeCommentRange = writeCommentRange; + function modifierToFlag(token) { + switch (token) { + case 113 /* StaticKeyword */: return 128 /* Static */; + case 112 /* PublicKeyword */: return 16 /* Public */; + case 111 /* ProtectedKeyword */: return 64 /* Protected */; + case 110 /* PrivateKeyword */: return 32 /* Private */; + case 115 /* AbstractKeyword */: return 256 /* Abstract */; + case 82 /* ExportKeyword */: return 1 /* Export */; + case 122 /* DeclareKeyword */: return 2 /* Ambient */; + case 74 /* ConstKeyword */: return 32768 /* Const */; + case 77 /* DefaultKeyword */: return 1024 /* Default */; + case 118 /* AsyncKeyword */: return 512 /* Async */; + } + return 0; + } + ts.modifierToFlag = modifierToFlag; + function isLeftHandSideExpression(expr) { + if (expr) { + switch (expr.kind) { + case 166 /* PropertyAccessExpression */: + case 167 /* ElementAccessExpression */: + case 169 /* NewExpression */: + case 168 /* CallExpression */: + case 233 /* JsxElement */: + case 234 /* JsxSelfClosingElement */: + case 170 /* TaggedTemplateExpression */: + case 164 /* ArrayLiteralExpression */: + case 172 /* ParenthesizedExpression */: + case 165 /* ObjectLiteralExpression */: + case 186 /* ClassExpression */: + case 173 /* FunctionExpression */: + case 69 /* Identifier */: + case 10 /* RegularExpressionLiteral */: + case 8 /* NumericLiteral */: + case 9 /* StringLiteral */: + case 11 /* NoSubstitutionTemplateLiteral */: + case 183 /* TemplateExpression */: + case 84 /* FalseKeyword */: + case 93 /* NullKeyword */: + case 97 /* ThisKeyword */: + case 99 /* TrueKeyword */: + case 95 /* SuperKeyword */: + return true; + } + } + return false; + } + ts.isLeftHandSideExpression = isLeftHandSideExpression; + function isAssignmentOperator(token) { + return token >= 56 /* FirstAssignment */ && token <= 68 /* LastAssignment */; + } + ts.isAssignmentOperator = isAssignmentOperator; + function isExpressionWithTypeArgumentsInClassExtendsClause(node) { + return node.kind === 188 /* ExpressionWithTypeArguments */ && + node.parent.token === 83 /* ExtendsKeyword */ && + isClassLike(node.parent.parent); + } + ts.isExpressionWithTypeArgumentsInClassExtendsClause = isExpressionWithTypeArgumentsInClassExtendsClause; + // Returns false if this heritage clause element's expression contains something unsupported + // (i.e. not a name or dotted name). + function isSupportedExpressionWithTypeArguments(node) { + return isSupportedExpressionWithTypeArgumentsRest(node.expression); + } + ts.isSupportedExpressionWithTypeArguments = isSupportedExpressionWithTypeArguments; + function isSupportedExpressionWithTypeArgumentsRest(node) { + if (node.kind === 69 /* Identifier */) { + return true; + } + else if (isPropertyAccessExpression(node)) { + return isSupportedExpressionWithTypeArgumentsRest(node.expression); + } + else { + return false; + } + } + function isRightSideOfQualifiedNameOrPropertyAccess(node) { + return (node.parent.kind === 135 /* QualifiedName */ && node.parent.right === node) || + (node.parent.kind === 166 /* PropertyAccessExpression */ && node.parent.name === node); + } + ts.isRightSideOfQualifiedNameOrPropertyAccess = isRightSideOfQualifiedNameOrPropertyAccess; + function isEmptyObjectLiteralOrArrayLiteral(expression) { + var kind = expression.kind; + if (kind === 165 /* ObjectLiteralExpression */) { + return expression.properties.length === 0; + } + if (kind === 164 /* ArrayLiteralExpression */) { + return expression.elements.length === 0; + } + return false; + } + ts.isEmptyObjectLiteralOrArrayLiteral = isEmptyObjectLiteralOrArrayLiteral; + function getLocalSymbolForExportDefault(symbol) { + return symbol && symbol.valueDeclaration && (symbol.valueDeclaration.flags & 1024 /* Default */) ? symbol.valueDeclaration.localSymbol : undefined; + } + ts.getLocalSymbolForExportDefault = getLocalSymbolForExportDefault; + function isJavaScript(fileName) { + return ts.fileExtensionIs(fileName, ".js"); + } + ts.isJavaScript = isJavaScript; + function isTsx(fileName) { + return ts.fileExtensionIs(fileName, ".tsx"); + } + ts.isTsx = isTsx; + /** + * Replace each instance of non-ascii characters by one, two, three, or four escape sequences + * representing the UTF-8 encoding of the character, and return the expanded char code list. + */ + function getExpandedCharCodes(input) { + var output = []; + var length = input.length; + for (var i = 0; i < length; i++) { + var charCode = input.charCodeAt(i); + // handel utf8 + if (charCode < 0x80) { + output.push(charCode); + } + else if (charCode < 0x800) { + output.push((charCode >> 6) | 192); + output.push((charCode & 63) | 128); + } + else if (charCode < 0x10000) { + output.push((charCode >> 12) | 224); + output.push(((charCode >> 6) & 63) | 128); + output.push((charCode & 63) | 128); + } + else if (charCode < 0x20000) { + output.push((charCode >> 18) | 240); + output.push(((charCode >> 12) & 63) | 128); + output.push(((charCode >> 6) & 63) | 128); + output.push((charCode & 63) | 128); + } + else { + ts.Debug.assert(false, "Unexpected code point"); + } + } + return output; + } + var base64Digits = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="; + /** + * Converts a string to a base-64 encoded ASCII string. + */ + function convertToBase64(input) { + var result = ""; + var charCodes = getExpandedCharCodes(input); + var i = 0; + var length = charCodes.length; + var byte1, byte2, byte3, byte4; + while (i < length) { + // Convert every 6-bits in the input 3 character points + // into a base64 digit + byte1 = charCodes[i] >> 2; + byte2 = (charCodes[i] & 3) << 4 | charCodes[i + 1] >> 4; + byte3 = (charCodes[i + 1] & 15) << 2 | charCodes[i + 2] >> 6; + byte4 = charCodes[i + 2] & 63; + // We are out of characters in the input, set the extra + // digits to 64 (padding character). + if (i + 1 >= length) { + byte3 = byte4 = 64; + } + else if (i + 2 >= length) { + byte4 = 64; + } + // Write to the ouput + result += base64Digits.charAt(byte1) + base64Digits.charAt(byte2) + base64Digits.charAt(byte3) + base64Digits.charAt(byte4); + i += 3; + } + return result; + } + ts.convertToBase64 = convertToBase64; + var carriageReturnLineFeed = "\r\n"; + var lineFeed = "\n"; + function getNewLineCharacter(options) { + if (options.newLine === 0 /* CarriageReturnLineFeed */) { + return carriageReturnLineFeed; + } + else if (options.newLine === 1 /* LineFeed */) { + return lineFeed; + } + else if (ts.sys) { + return ts.sys.newLine; + } + return carriageReturnLineFeed; + } + ts.getNewLineCharacter = getNewLineCharacter; +})(ts || (ts = {})); +var ts; +(function (ts) { + function getDefaultLibFileName(options) { + return options.target === 2 /* ES6 */ ? "lib.es6.d.ts" : "lib.d.ts"; + } + ts.getDefaultLibFileName = getDefaultLibFileName; + function textSpanEnd(span) { + return span.start + span.length; + } + ts.textSpanEnd = textSpanEnd; + function textSpanIsEmpty(span) { + return span.length === 0; + } + ts.textSpanIsEmpty = textSpanIsEmpty; + function textSpanContainsPosition(span, position) { + return position >= span.start && position < textSpanEnd(span); + } + ts.textSpanContainsPosition = textSpanContainsPosition; + // Returns true if 'span' contains 'other'. + function textSpanContainsTextSpan(span, other) { + return other.start >= span.start && textSpanEnd(other) <= textSpanEnd(span); + } + ts.textSpanContainsTextSpan = textSpanContainsTextSpan; + function textSpanOverlapsWith(span, other) { + var overlapStart = Math.max(span.start, other.start); + var overlapEnd = Math.min(textSpanEnd(span), textSpanEnd(other)); + return overlapStart < overlapEnd; + } + ts.textSpanOverlapsWith = textSpanOverlapsWith; + function textSpanOverlap(span1, span2) { + var overlapStart = Math.max(span1.start, span2.start); + var overlapEnd = Math.min(textSpanEnd(span1), textSpanEnd(span2)); + if (overlapStart < overlapEnd) { + return createTextSpanFromBounds(overlapStart, overlapEnd); + } + return undefined; + } + ts.textSpanOverlap = textSpanOverlap; + function textSpanIntersectsWithTextSpan(span, other) { + return other.start <= textSpanEnd(span) && textSpanEnd(other) >= span.start; + } + ts.textSpanIntersectsWithTextSpan = textSpanIntersectsWithTextSpan; + function textSpanIntersectsWith(span, start, length) { + var end = start + length; + return start <= textSpanEnd(span) && end >= span.start; + } + ts.textSpanIntersectsWith = textSpanIntersectsWith; + function decodedTextSpanIntersectsWith(start1, length1, start2, length2) { + var end1 = start1 + length1; + var end2 = start2 + length2; + return start2 <= end1 && end2 >= start1; + } + ts.decodedTextSpanIntersectsWith = decodedTextSpanIntersectsWith; + function textSpanIntersectsWithPosition(span, position) { + return position <= textSpanEnd(span) && position >= span.start; + } + ts.textSpanIntersectsWithPosition = textSpanIntersectsWithPosition; + function textSpanIntersection(span1, span2) { + var intersectStart = Math.max(span1.start, span2.start); + var intersectEnd = Math.min(textSpanEnd(span1), textSpanEnd(span2)); + if (intersectStart <= intersectEnd) { + return createTextSpanFromBounds(intersectStart, intersectEnd); + } + return undefined; + } + ts.textSpanIntersection = textSpanIntersection; + function createTextSpan(start, length) { + if (start < 0) { + throw new Error("start < 0"); + } + if (length < 0) { + throw new Error("length < 0"); + } + return { start: start, length: length }; + } + ts.createTextSpan = createTextSpan; + function createTextSpanFromBounds(start, end) { + return createTextSpan(start, end - start); + } + ts.createTextSpanFromBounds = createTextSpanFromBounds; + function textChangeRangeNewSpan(range) { + return createTextSpan(range.span.start, range.newLength); + } + ts.textChangeRangeNewSpan = textChangeRangeNewSpan; + function textChangeRangeIsUnchanged(range) { + return textSpanIsEmpty(range.span) && range.newLength === 0; + } + ts.textChangeRangeIsUnchanged = textChangeRangeIsUnchanged; + function createTextChangeRange(span, newLength) { + if (newLength < 0) { + throw new Error("newLength < 0"); + } + return { span: span, newLength: newLength }; + } + ts.createTextChangeRange = createTextChangeRange; + ts.unchangedTextChangeRange = createTextChangeRange(createTextSpan(0, 0), 0); + /** + * Called to merge all the changes that occurred across several versions of a script snapshot + * into a single change. i.e. if a user keeps making successive edits to a script we will + * have a text change from V1 to V2, V2 to V3, ..., Vn. + * + * This function will then merge those changes into a single change range valid between V1 and + * Vn. + */ + function collapseTextChangeRangesAcrossMultipleVersions(changes) { + if (changes.length === 0) { + return ts.unchangedTextChangeRange; + } + if (changes.length === 1) { + return changes[0]; + } + // We change from talking about { { oldStart, oldLength }, newLength } to { oldStart, oldEnd, newEnd } + // as it makes things much easier to reason about. + var change0 = changes[0]; + var oldStartN = change0.span.start; + var oldEndN = textSpanEnd(change0.span); + var newEndN = oldStartN + change0.newLength; + for (var i = 1; i < changes.length; i++) { + var nextChange = changes[i]; + // Consider the following case: + // i.e. two edits. The first represents the text change range { { 10, 50 }, 30 }. i.e. The span starting + // at 10, with length 50 is reduced to length 30. The second represents the text change range { { 30, 30 }, 40 }. + // i.e. the span starting at 30 with length 30 is increased to length 40. + // + // 0 10 20 30 40 50 60 70 80 90 100 + // ------------------------------------------------------------------------------------------------------- + // | / + // | /---- + // T1 | /---- + // | /---- + // | /---- + // ------------------------------------------------------------------------------------------------------- + // | \ + // | \ + // T2 | \ + // | \ + // | \ + // ------------------------------------------------------------------------------------------------------- + // + // Merging these turns out to not be too difficult. First, determining the new start of the change is trivial + // it's just the min of the old and new starts. i.e.: + // + // 0 10 20 30 40 50 60 70 80 90 100 + // ------------------------------------------------------------*------------------------------------------ + // | / + // | /---- + // T1 | /---- + // | /---- + // | /---- + // ----------------------------------------$-------------------$------------------------------------------ + // . | \ + // . | \ + // T2 . | \ + // . | \ + // . | \ + // ----------------------------------------------------------------------*-------------------------------- + // + // (Note the dots represent the newly inferrred start. + // Determining the new and old end is also pretty simple. Basically it boils down to paying attention to the + // absolute positions at the asterixes, and the relative change between the dollar signs. Basically, we see + // which if the two $'s precedes the other, and we move that one forward until they line up. in this case that + // means: + // + // 0 10 20 30 40 50 60 70 80 90 100 + // --------------------------------------------------------------------------------*---------------------- + // | / + // | /---- + // T1 | /---- + // | /---- + // | /---- + // ------------------------------------------------------------$------------------------------------------ + // . | \ + // . | \ + // T2 . | \ + // . | \ + // . | \ + // ----------------------------------------------------------------------*-------------------------------- + // + // In other words (in this case), we're recognizing that the second edit happened after where the first edit + // ended with a delta of 20 characters (60 - 40). Thus, if we go back in time to where the first edit started + // that's the same as if we started at char 80 instead of 60. + // + // As it so happens, the same logic applies if the second edit precedes the first edit. In that case rahter + // than pusing the first edit forward to match the second, we'll push the second edit forward to match the + // first. + // + // In this case that means we have { oldStart: 10, oldEnd: 80, newEnd: 70 } or, in TextChangeRange + // semantics: { { start: 10, length: 70 }, newLength: 60 } + // + // The math then works out as follows. + // If we have { oldStart1, oldEnd1, newEnd1 } and { oldStart2, oldEnd2, newEnd2 } then we can compute the + // final result like so: + // + // { + // oldStart3: Min(oldStart1, oldStart2), + // oldEnd3 : Max(oldEnd1, oldEnd1 + (oldEnd2 - newEnd1)), + // newEnd3 : Max(newEnd2, newEnd2 + (newEnd1 - oldEnd2)) + // } + var oldStart1 = oldStartN; + var oldEnd1 = oldEndN; + var newEnd1 = newEndN; + var oldStart2 = nextChange.span.start; + var oldEnd2 = textSpanEnd(nextChange.span); + var newEnd2 = oldStart2 + nextChange.newLength; + oldStartN = Math.min(oldStart1, oldStart2); + oldEndN = Math.max(oldEnd1, oldEnd1 + (oldEnd2 - newEnd1)); + newEndN = Math.max(newEnd2, newEnd2 + (newEnd1 - oldEnd2)); + } + return createTextChangeRange(createTextSpanFromBounds(oldStartN, oldEndN), /*newLength:*/ newEndN - oldStartN); + } + ts.collapseTextChangeRangesAcrossMultipleVersions = collapseTextChangeRangesAcrossMultipleVersions; + function getTypeParameterOwner(d) { + if (d && d.kind === 137 /* TypeParameter */) { + for (var current = d; current; current = current.parent) { + if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 215 /* InterfaceDeclaration */) { + return current; + } + } + } + } + ts.getTypeParameterOwner = getTypeParameterOwner; +})(ts || (ts = {})); +/// +/// +var ts; +(function (ts) { + var nodeConstructors = new Array(272 /* Count */); + /* @internal */ ts.parseTime = 0; + function getNodeConstructor(kind) { + return nodeConstructors[kind] || (nodeConstructors[kind] = ts.objectAllocator.getNodeConstructor(kind)); + } + ts.getNodeConstructor = getNodeConstructor; + function createNode(kind, pos, end) { + return new (getNodeConstructor(kind))(pos, end); + } + ts.createNode = createNode; + function visitNode(cbNode, node) { + if (node) { + return cbNode(node); + } + } + function visitNodeArray(cbNodes, nodes) { + if (nodes) { + return cbNodes(nodes); + } + } + function visitEachNode(cbNode, nodes) { + if (nodes) { + for (var _i = 0; _i < nodes.length; _i++) { + var node = nodes[_i]; + var result = cbNode(node); + if (result) { + return result; + } + } + } + } + // Invokes a callback for each child of the given node. The 'cbNode' callback is invoked for all child nodes + // stored in properties. If a 'cbNodes' callback is specified, it is invoked for embedded arrays; otherwise, + // embedded arrays are flattened and the 'cbNode' callback is invoked for each element. If a callback returns + // a truthy value, iteration stops and that value is returned. Otherwise, undefined is returned. + function forEachChild(node, cbNode, cbNodeArray) { + if (!node) { + return; + } + // The visitXXX functions could be written as local functions that close over the cbNode and cbNodeArray + // callback parameters, but that causes a closure allocation for each invocation with noticeable effects + // on performance. + var visitNodes = cbNodeArray ? visitNodeArray : visitEachNode; + var cbNodes = cbNodeArray || cbNode; + switch (node.kind) { + case 135 /* QualifiedName */: + return visitNode(cbNode, node.left) || + visitNode(cbNode, node.right); + case 137 /* TypeParameter */: + return visitNode(cbNode, node.name) || + visitNode(cbNode, node.constraint) || + visitNode(cbNode, node.expression); + case 246 /* ShorthandPropertyAssignment */: + return visitNodes(cbNodes, node.decorators) || + visitNodes(cbNodes, node.modifiers) || + visitNode(cbNode, node.name) || + visitNode(cbNode, node.questionToken) || + visitNode(cbNode, node.equalsToken) || + visitNode(cbNode, node.objectAssignmentInitializer); + case 138 /* Parameter */: + case 141 /* PropertyDeclaration */: + case 140 /* PropertySignature */: + case 245 /* PropertyAssignment */: + case 211 /* VariableDeclaration */: + case 163 /* BindingElement */: + return visitNodes(cbNodes, node.decorators) || + visitNodes(cbNodes, node.modifiers) || + visitNode(cbNode, node.propertyName) || + visitNode(cbNode, node.dotDotDotToken) || + visitNode(cbNode, node.name) || + visitNode(cbNode, node.questionToken) || + visitNode(cbNode, node.type) || + visitNode(cbNode, node.initializer); + case 152 /* FunctionType */: + case 153 /* ConstructorType */: + case 147 /* CallSignature */: + case 148 /* ConstructSignature */: + case 149 /* IndexSignature */: + return visitNodes(cbNodes, node.decorators) || + visitNodes(cbNodes, node.modifiers) || + visitNodes(cbNodes, node.typeParameters) || + visitNodes(cbNodes, node.parameters) || + visitNode(cbNode, node.type); + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: + case 144 /* Constructor */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: + case 173 /* FunctionExpression */: + case 213 /* FunctionDeclaration */: + case 174 /* ArrowFunction */: + return visitNodes(cbNodes, node.decorators) || + visitNodes(cbNodes, node.modifiers) || + visitNode(cbNode, node.asteriskToken) || + visitNode(cbNode, node.name) || + visitNode(cbNode, node.questionToken) || + visitNodes(cbNodes, node.typeParameters) || + visitNodes(cbNodes, node.parameters) || + visitNode(cbNode, node.type) || + visitNode(cbNode, node.equalsGreaterThanToken) || + visitNode(cbNode, node.body); + case 151 /* TypeReference */: + return visitNode(cbNode, node.typeName) || + visitNodes(cbNodes, node.typeArguments); + case 150 /* TypePredicate */: + return visitNode(cbNode, node.parameterName) || + visitNode(cbNode, node.type); + case 154 /* TypeQuery */: + return visitNode(cbNode, node.exprName); + case 155 /* TypeLiteral */: + return visitNodes(cbNodes, node.members); + case 156 /* ArrayType */: + return visitNode(cbNode, node.elementType); + case 157 /* TupleType */: + return visitNodes(cbNodes, node.elementTypes); + case 158 /* UnionType */: + case 159 /* IntersectionType */: + return visitNodes(cbNodes, node.types); + case 160 /* ParenthesizedType */: + return visitNode(cbNode, node.type); + case 161 /* ObjectBindingPattern */: + case 162 /* ArrayBindingPattern */: + return visitNodes(cbNodes, node.elements); + case 164 /* ArrayLiteralExpression */: + return visitNodes(cbNodes, node.elements); + case 165 /* ObjectLiteralExpression */: + return visitNodes(cbNodes, node.properties); + case 166 /* PropertyAccessExpression */: + return visitNode(cbNode, node.expression) || + visitNode(cbNode, node.dotToken) || + visitNode(cbNode, node.name); + case 167 /* ElementAccessExpression */: + return visitNode(cbNode, node.expression) || + visitNode(cbNode, node.argumentExpression); + case 168 /* CallExpression */: + case 169 /* NewExpression */: + return visitNode(cbNode, node.expression) || + visitNodes(cbNodes, node.typeArguments) || + visitNodes(cbNodes, node.arguments); + case 170 /* TaggedTemplateExpression */: + return visitNode(cbNode, node.tag) || + visitNode(cbNode, node.template); + case 171 /* TypeAssertionExpression */: + return visitNode(cbNode, node.type) || + visitNode(cbNode, node.expression); + case 172 /* ParenthesizedExpression */: + return visitNode(cbNode, node.expression); + case 175 /* DeleteExpression */: + return visitNode(cbNode, node.expression); + case 176 /* TypeOfExpression */: + return visitNode(cbNode, node.expression); + case 177 /* VoidExpression */: + return visitNode(cbNode, node.expression); + case 179 /* PrefixUnaryExpression */: + return visitNode(cbNode, node.operand); + case 184 /* YieldExpression */: + return visitNode(cbNode, node.asteriskToken) || + visitNode(cbNode, node.expression); + case 178 /* AwaitExpression */: + return visitNode(cbNode, node.expression); + case 180 /* PostfixUnaryExpression */: + return visitNode(cbNode, node.operand); + case 181 /* BinaryExpression */: + return visitNode(cbNode, node.left) || + visitNode(cbNode, node.operatorToken) || + visitNode(cbNode, node.right); + case 189 /* AsExpression */: + return visitNode(cbNode, node.expression) || + visitNode(cbNode, node.type); + case 182 /* ConditionalExpression */: + return visitNode(cbNode, node.condition) || + visitNode(cbNode, node.questionToken) || + visitNode(cbNode, node.whenTrue) || + visitNode(cbNode, node.colonToken) || + visitNode(cbNode, node.whenFalse); + case 185 /* SpreadElementExpression */: + return visitNode(cbNode, node.expression); + case 192 /* Block */: + case 219 /* ModuleBlock */: + return visitNodes(cbNodes, node.statements); + case 248 /* SourceFile */: + return visitNodes(cbNodes, node.statements) || + visitNode(cbNode, node.endOfFileToken); + case 193 /* VariableStatement */: + return visitNodes(cbNodes, node.decorators) || + visitNodes(cbNodes, node.modifiers) || + visitNode(cbNode, node.declarationList); + case 212 /* VariableDeclarationList */: + return visitNodes(cbNodes, node.declarations); + case 195 /* ExpressionStatement */: + return visitNode(cbNode, node.expression); + case 196 /* IfStatement */: + return visitNode(cbNode, node.expression) || + visitNode(cbNode, node.thenStatement) || + visitNode(cbNode, node.elseStatement); + case 197 /* DoStatement */: + return visitNode(cbNode, node.statement) || + visitNode(cbNode, node.expression); + case 198 /* WhileStatement */: + return visitNode(cbNode, node.expression) || + visitNode(cbNode, node.statement); + case 199 /* ForStatement */: + return visitNode(cbNode, node.initializer) || + visitNode(cbNode, node.condition) || + visitNode(cbNode, node.incrementor) || + visitNode(cbNode, node.statement); + case 200 /* ForInStatement */: + return visitNode(cbNode, node.initializer) || + visitNode(cbNode, node.expression) || + visitNode(cbNode, node.statement); + case 201 /* ForOfStatement */: + return visitNode(cbNode, node.initializer) || + visitNode(cbNode, node.expression) || + visitNode(cbNode, node.statement); + case 202 /* ContinueStatement */: + case 203 /* BreakStatement */: + return visitNode(cbNode, node.label); + case 204 /* ReturnStatement */: + return visitNode(cbNode, node.expression); + case 205 /* WithStatement */: + return visitNode(cbNode, node.expression) || + visitNode(cbNode, node.statement); + case 206 /* SwitchStatement */: + return visitNode(cbNode, node.expression) || + visitNode(cbNode, node.caseBlock); + case 220 /* CaseBlock */: + return visitNodes(cbNodes, node.clauses); + case 241 /* CaseClause */: + return visitNode(cbNode, node.expression) || + visitNodes(cbNodes, node.statements); + case 242 /* DefaultClause */: + return visitNodes(cbNodes, node.statements); + case 207 /* LabeledStatement */: + return visitNode(cbNode, node.label) || + visitNode(cbNode, node.statement); + case 208 /* ThrowStatement */: + return visitNode(cbNode, node.expression); + case 209 /* TryStatement */: + return visitNode(cbNode, node.tryBlock) || + visitNode(cbNode, node.catchClause) || + visitNode(cbNode, node.finallyBlock); + case 244 /* CatchClause */: + return visitNode(cbNode, node.variableDeclaration) || + visitNode(cbNode, node.block); + case 139 /* Decorator */: + return visitNode(cbNode, node.expression); + case 214 /* ClassDeclaration */: + case 186 /* ClassExpression */: + return visitNodes(cbNodes, node.decorators) || + visitNodes(cbNodes, node.modifiers) || + visitNode(cbNode, node.name) || + visitNodes(cbNodes, node.typeParameters) || + visitNodes(cbNodes, node.heritageClauses) || + visitNodes(cbNodes, node.members); + case 215 /* InterfaceDeclaration */: + return visitNodes(cbNodes, node.decorators) || + visitNodes(cbNodes, node.modifiers) || + visitNode(cbNode, node.name) || + visitNodes(cbNodes, node.typeParameters) || + visitNodes(cbNodes, node.heritageClauses) || + visitNodes(cbNodes, node.members); + case 216 /* TypeAliasDeclaration */: + return visitNodes(cbNodes, node.decorators) || + visitNodes(cbNodes, node.modifiers) || + visitNode(cbNode, node.name) || + visitNodes(cbNodes, node.typeParameters) || + visitNode(cbNode, node.type); + case 217 /* EnumDeclaration */: + return visitNodes(cbNodes, node.decorators) || + visitNodes(cbNodes, node.modifiers) || + visitNode(cbNode, node.name) || + visitNodes(cbNodes, node.members); + case 247 /* EnumMember */: + return visitNode(cbNode, node.name) || + visitNode(cbNode, node.initializer); + case 218 /* ModuleDeclaration */: + return visitNodes(cbNodes, node.decorators) || + visitNodes(cbNodes, node.modifiers) || + visitNode(cbNode, node.name) || + visitNode(cbNode, node.body); + case 221 /* ImportEqualsDeclaration */: + return visitNodes(cbNodes, node.decorators) || + visitNodes(cbNodes, node.modifiers) || + visitNode(cbNode, node.name) || + visitNode(cbNode, node.moduleReference); + case 222 /* ImportDeclaration */: + return visitNodes(cbNodes, node.decorators) || + visitNodes(cbNodes, node.modifiers) || + visitNode(cbNode, node.importClause) || + visitNode(cbNode, node.moduleSpecifier); + case 223 /* ImportClause */: + return visitNode(cbNode, node.name) || + visitNode(cbNode, node.namedBindings); + case 224 /* NamespaceImport */: + return visitNode(cbNode, node.name); + case 225 /* NamedImports */: + case 229 /* NamedExports */: + return visitNodes(cbNodes, node.elements); + case 228 /* ExportDeclaration */: + return visitNodes(cbNodes, node.decorators) || + visitNodes(cbNodes, node.modifiers) || + visitNode(cbNode, node.exportClause) || + visitNode(cbNode, node.moduleSpecifier); + case 226 /* ImportSpecifier */: + case 230 /* ExportSpecifier */: + return visitNode(cbNode, node.propertyName) || + visitNode(cbNode, node.name); + case 227 /* ExportAssignment */: + return visitNodes(cbNodes, node.decorators) || + visitNodes(cbNodes, node.modifiers) || + visitNode(cbNode, node.expression); + case 183 /* TemplateExpression */: + return visitNode(cbNode, node.head) || visitNodes(cbNodes, node.templateSpans); + case 190 /* TemplateSpan */: + return visitNode(cbNode, node.expression) || visitNode(cbNode, node.literal); + case 136 /* ComputedPropertyName */: + return visitNode(cbNode, node.expression); + case 243 /* HeritageClause */: + return visitNodes(cbNodes, node.types); + case 188 /* ExpressionWithTypeArguments */: + return visitNode(cbNode, node.expression) || + visitNodes(cbNodes, node.typeArguments); + case 232 /* ExternalModuleReference */: + return visitNode(cbNode, node.expression); + case 231 /* MissingDeclaration */: + return visitNodes(cbNodes, node.decorators); + case 233 /* JsxElement */: + return visitNode(cbNode, node.openingElement) || + visitNodes(cbNodes, node.children) || + visitNode(cbNode, node.closingElement); + case 234 /* JsxSelfClosingElement */: + case 235 /* JsxOpeningElement */: + return visitNode(cbNode, node.tagName) || + visitNodes(cbNodes, node.attributes); + case 238 /* JsxAttribute */: + return visitNode(cbNode, node.name) || + visitNode(cbNode, node.initializer); + case 239 /* JsxSpreadAttribute */: + return visitNode(cbNode, node.expression); + case 240 /* JsxExpression */: + return visitNode(cbNode, node.expression); + case 237 /* JsxClosingElement */: + return visitNode(cbNode, node.tagName); + case 249 /* JSDocTypeExpression */: + return visitNode(cbNode, node.type); + case 253 /* JSDocUnionType */: + return visitNodes(cbNodes, node.types); + case 254 /* JSDocTupleType */: + return visitNodes(cbNodes, node.types); + case 252 /* JSDocArrayType */: + return visitNode(cbNode, node.elementType); + case 256 /* JSDocNonNullableType */: + return visitNode(cbNode, node.type); + case 255 /* JSDocNullableType */: + return visitNode(cbNode, node.type); + case 257 /* JSDocRecordType */: + return visitNodes(cbNodes, node.members); + case 259 /* JSDocTypeReference */: + return visitNode(cbNode, node.name) || + visitNodes(cbNodes, node.typeArguments); + case 260 /* JSDocOptionalType */: + return visitNode(cbNode, node.type); + case 261 /* JSDocFunctionType */: + return visitNodes(cbNodes, node.parameters) || + visitNode(cbNode, node.type); + case 262 /* JSDocVariadicType */: + return visitNode(cbNode, node.type); + case 263 /* JSDocConstructorType */: + return visitNode(cbNode, node.type); + case 264 /* JSDocThisType */: + return visitNode(cbNode, node.type); + case 258 /* JSDocRecordMember */: + return visitNode(cbNode, node.name) || + visitNode(cbNode, node.type); + case 265 /* JSDocComment */: + return visitNodes(cbNodes, node.tags); + case 267 /* JSDocParameterTag */: + return visitNode(cbNode, node.preParameterName) || + visitNode(cbNode, node.typeExpression) || + visitNode(cbNode, node.postParameterName); + case 268 /* JSDocReturnTag */: + return visitNode(cbNode, node.typeExpression); + case 269 /* JSDocTypeTag */: + return visitNode(cbNode, node.typeExpression); + case 270 /* JSDocTemplateTag */: + return visitNodes(cbNodes, node.typeParameters); + } + } + ts.forEachChild = forEachChild; + function createSourceFile(fileName, sourceText, languageVersion, setParentNodes) { + if (setParentNodes === void 0) { setParentNodes = false; } + var start = new Date().getTime(); + var result = Parser.parseSourceFile(fileName, sourceText, languageVersion, /*syntaxCursor*/ undefined, setParentNodes); + ts.parseTime += new Date().getTime() - start; + return result; + } + ts.createSourceFile = createSourceFile; + // Produces a new SourceFile for the 'newText' provided. The 'textChangeRange' parameter + // indicates what changed between the 'text' that this SourceFile has and the 'newText'. + // The SourceFile will be created with the compiler attempting to reuse as many nodes from + // this file as possible. + // + // Note: this function mutates nodes from this SourceFile. That means any existing nodes + // from this SourceFile that are being held onto may change as a result (including + // becoming detached from any SourceFile). It is recommended that this SourceFile not + // be used once 'update' is called on it. + function updateSourceFile(sourceFile, newText, textChangeRange, aggressiveChecks) { + return IncrementalParser.updateSourceFile(sourceFile, newText, textChangeRange, aggressiveChecks); + } + ts.updateSourceFile = updateSourceFile; + /* @internal */ + function parseIsolatedJSDocComment(content, start, length) { + return Parser.JSDocParser.parseIsolatedJSDocComment(content, start, length); + } + ts.parseIsolatedJSDocComment = parseIsolatedJSDocComment; + /* @internal */ + // Exposed only for testing. + function parseJSDocTypeExpressionForTests(content, start, length) { + return Parser.JSDocParser.parseJSDocTypeExpressionForTests(content, start, length); + } + ts.parseJSDocTypeExpressionForTests = parseJSDocTypeExpressionForTests; + // Implement the parser as a singleton module. We do this for perf reasons because creating + // parser instances can actually be expensive enough to impact us on projects with many source + // files. + var Parser; + (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 disallowInAndDecoratorContext = 1 /* DisallowIn */ | 4 /* Decorator */; + var sourceFile; + var parseDiagnostics; + var syntaxCursor; + var token; + var sourceText; + var nodeCount; + var identifiers; + var identifierCount; + var parsingContext; + // Flags that dictate what parsing context we're in. For example: + // Whether or not we are in strict parsing mode. All that changes in strict parsing mode is + // that some tokens that would be considered identifiers may be considered keywords. + // + // When adding more parser context flags, consider which is the more common case that the + // flag will be in. This should be the 'false' state for that flag. The reason for this is + // that we don't store data in our nodes unless the value is in the *non-default* state. So, + // for example, more often than code 'allows-in' (or doesn't 'disallow-in'). We opt for + // 'disallow-in' set to 'false'. Otherwise, if we had 'allowsIn' set to 'true', then almost + // all nodes would need extra state on them to store this info. + // + // Note: 'allowIn' and 'allowYield' track 1:1 with the [in] and [yield] concepts in the ES6 + // grammar specification. + // + // An important thing about these context concepts. By default they are effectively inherited + // while parsing through every grammar production. i.e. if you don't change them, then when + // you parse a sub-production, it will have the same context values as the parent production. + // This is great most of the time. After all, consider all the 'expression' grammar productions + // and how nearly all of them pass along the 'in' and 'yield' context values: + // + // EqualityExpression[In, Yield] : + // RelationalExpression[?In, ?Yield] + // EqualityExpression[?In, ?Yield] == RelationalExpression[?In, ?Yield] + // EqualityExpression[?In, ?Yield] != RelationalExpression[?In, ?Yield] + // EqualityExpression[?In, ?Yield] === RelationalExpression[?In, ?Yield] + // EqualityExpression[?In, ?Yield] !== RelationalExpression[?In, ?Yield] + // + // Where you have to be careful is then understanding what the points are in the grammar + // where the values are *not* passed along. For example: + // + // SingleNameBinding[Yield,GeneratorParameter] + // [+GeneratorParameter]BindingIdentifier[Yield] Initializer[In]opt + // [~GeneratorParameter]BindingIdentifier[?Yield]Initializer[In, ?Yield]opt + // + // Here this is saying that if the GeneratorParameter context flag is set, that we should + // explicitly set the 'yield' context flag to false before calling into the BindingIdentifier + // and we should explicitly unset the 'yield' context flag before calling into the Initializer. + // production. Conversely, if the GeneratorParameter context flag is not set, then we + // should leave the 'yield' context flag alone. + // + // Getting this all correct is tricky and requires careful reading of the grammar to + // understand when these values should be changed versus when they should be inherited. + // + // Note: it should not be necessary to save/restore these flags during speculative/lookahead + // parsing. These context flags are naturally stored and restored through normal recursive + // descent parsing and unwinding. + var contextFlags; + // Whether or not we've had a parse error since creating the last AST node. If we have + // encountered an error, it will be stored on the next AST node we create. Parse errors + // can be broken down into three categories: + // + // 1) An error that occurred during scanning. For example, an unterminated literal, or a + // character that was completely not understood. + // + // 2) A token was expected, but was not present. This type of error is commonly produced + // by the 'parseExpected' function. + // + // 3) A token was present that no parsing function was able to consume. This type of error + // only occurs in the 'abortParsingListOrMoveToNextToken' function when the parser + // decides to skip the token. + // + // In all of these cases, we want to mark the next node as having had an error before it. + // With this mark, we can know in incremental settings if this node can be reused, or if + // we have to reparse it. If we don't keep this information around, we may just reuse the + // node. in that event we would then not produce the same errors as we did before, causing + // significant confusion problems. + // + // Note: it is necessary that this value be saved/restored during speculative/lookahead + // parsing. During lookahead parsing, we will often create a node. That node will have + // this value attached, and then this value will be set back to 'false'. If we decide to + // rewind, we must get back to the same value we had prior to the lookahead. + // + // 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) { + initializeState(fileName, _sourceText, languageVersion, _syntaxCursor); + var result = parseSourceFileWorker(fileName, languageVersion, setParentNodes); + clearState(); + return result; + } + Parser.parseSourceFile = parseSourceFile; + function initializeState(fileName, _sourceText, languageVersion, _syntaxCursor) { + sourceText = _sourceText; + syntaxCursor = _syntaxCursor; + parseDiagnostics = []; + parsingContext = 0; + identifiers = {}; + identifierCount = 0; + nodeCount = 0; + contextFlags = ts.isJavaScript(fileName) ? 32 /* JavaScriptFile */ : 0 /* None */; + parseErrorBeforeNextFinishedNode = false; + // Initialize and prime the scanner before parsing the source elements. + scanner.setText(sourceText); + scanner.setOnError(scanError); + scanner.setScriptTarget(languageVersion); + scanner.setLanguageVariant(ts.isTsx(fileName) ? 1 /* JSX */ : 0 /* Standard */); + } + function clearState() { + // Clear out the text the scanner is pointing at, so it doesn't keep anything alive unnecessarily. + scanner.setText(""); + scanner.setOnError(undefined); + // Clear any data. We don't want to accidently hold onto it for too long. + parseDiagnostics = undefined; + sourceFile = undefined; + identifiers = undefined; + syntaxCursor = undefined; + sourceText = undefined; + } + function parseSourceFileWorker(fileName, languageVersion, setParentNodes) { + sourceFile = createSourceFile(fileName, languageVersion); + // Prime the scanner. + token = nextToken(); + processReferenceComments(sourceFile); + sourceFile.statements = parseList(0 /* SourceElements */, parseStatement); + ts.Debug.assert(token === 1 /* EndOfFileToken */); + sourceFile.endOfFileToken = parseTokenNode(); + setExternalModuleIndicator(sourceFile); + sourceFile.nodeCount = nodeCount; + sourceFile.identifierCount = identifierCount; + sourceFile.identifiers = identifiers; + sourceFile.parseDiagnostics = parseDiagnostics; + if (setParentNodes) { + fixupParentReferences(sourceFile); + } + // If this is a javascript file, proactively see if we can get JSDoc comments for + // relevant nodes in the file. We'll use these to provide typing informaion if they're + // available. + if (ts.isJavaScript(fileName)) { + addJSDocComments(); + } + return sourceFile; + } + function addJSDocComments() { + forEachChild(sourceFile, visit); + return; + function visit(node) { + // Add additional cases as necessary depending on how we see JSDoc comments used + // in the wild. + switch (node.kind) { + case 193 /* VariableStatement */: + case 213 /* FunctionDeclaration */: + case 138 /* Parameter */: + addJSDocComment(node); + } + forEachChild(node, visit); + } + } + function addJSDocComment(node) { + var comments = ts.getLeadingCommentRangesOfNode(node, sourceFile); + if (comments) { + for (var _i = 0; _i < comments.length; _i++) { + var comment = comments[_i]; + var jsDocComment = JSDocParser.parseJSDocComment(node, comment.pos, comment.end - comment.pos); + if (jsDocComment) { + node.jsDocComment = jsDocComment; + } + } + } + } + function fixupParentReferences(sourceFile) { + // normally parent references are set during binding. However, for clients that only need + // a syntax tree, and no semantic features, then the binding process is an unnecessary + // overhead. This functions allows us to set all the parents, without all the expense of + // binding. + var parent = sourceFile; + forEachChild(sourceFile, visitNode); + return; + function visitNode(n) { + // walk down setting parents that differ from the parent we think it should be. This + // allows us to quickly bail out of setting parents for subtrees during incremental + // parsing + if (n.parent !== parent) { + n.parent = parent; + var saveParent = parent; + parent = n; + forEachChild(n, visitNode); + parent = saveParent; + } + } + } + Parser.fixupParentReferences = fixupParentReferences; + function createSourceFile(fileName, languageVersion) { + var sourceFile = createNode(248 /* SourceFile */, /*pos*/ 0); + sourceFile.pos = 0; + sourceFile.end = sourceText.length; + sourceFile.text = sourceText; + sourceFile.bindDiagnostics = []; + sourceFile.languageVersion = languageVersion; + sourceFile.fileName = ts.normalizePath(fileName); + sourceFile.flags = ts.fileExtensionIs(sourceFile.fileName, ".d.ts") ? 8192 /* DeclarationFile */ : 0; + sourceFile.languageVariant = ts.isTsx(sourceFile.fileName) ? 1 /* JSX */ : 0 /* Standard */; + return sourceFile; + } + function setContextFlag(val, flag) { + if (val) { + contextFlags |= flag; + } + else { + contextFlags &= ~flag; + } + } + function setDisallowInContext(val) { + setContextFlag(val, 1 /* DisallowIn */); + } + function setYieldContext(val) { + setContextFlag(val, 2 /* Yield */); + } + function setDecoratorContext(val) { + setContextFlag(val, 4 /* Decorator */); + } + function setAwaitContext(val) { + setContextFlag(val, 8 /* Await */); + } + function doOutsideOfContext(context, func) { + // contextFlagsToClear will contain only the context flags that are + // currently set that we need to temporarily clear + // We don't just blindly reset to the previous flags to ensure + // that we do not mutate cached flags for the incremental + // parser (ThisNodeHasError, ThisNodeOrAnySubNodesHasError, and + // HasAggregatedChildData). + var contextFlagsToClear = context & contextFlags; + if (contextFlagsToClear) { + // clear the requested context flags + setContextFlag(false, contextFlagsToClear); + var result = func(); + // restore the context flags we just cleared + setContextFlag(true, contextFlagsToClear); + return result; + } + // no need to do anything special as we are not in any of the requested contexts + return func(); + } + function doInsideOfContext(context, func) { + // contextFlagsToSet will contain only the context flags that + // are not currently set that we need to temporarily enable. + // We don't just blindly reset to the previous flags to ensure + // that we do not mutate cached flags for the incremental + // parser (ThisNodeHasError, ThisNodeOrAnySubNodesHasError, and + // HasAggregatedChildData). + var contextFlagsToSet = context & ~contextFlags; + if (contextFlagsToSet) { + // set the requested context flags + setContextFlag(true, contextFlagsToSet); + var result = func(); + // reset the context flags we just set + setContextFlag(false, contextFlagsToSet); + return result; + } + // no need to do anything special as we are already in all of the requested contexts + return func(); + } + function allowInAnd(func) { + return doOutsideOfContext(1 /* DisallowIn */, func); + } + function disallowInAnd(func) { + return doInsideOfContext(1 /* DisallowIn */, func); + } + function doInYieldContext(func) { + return doInsideOfContext(2 /* Yield */, func); + } + function doOutsideOfYieldContext(func) { + return doOutsideOfContext(2 /* Yield */, func); + } + function doInDecoratorContext(func) { + return doInsideOfContext(4 /* Decorator */, func); + } + function doInAwaitContext(func) { + return doInsideOfContext(8 /* Await */, func); + } + function doOutsideOfAwaitContext(func) { + return doOutsideOfContext(8 /* Await */, func); + } + function doInYieldAndAwaitContext(func) { + return doInsideOfContext(2 /* Yield */ | 8 /* Await */, func); + } + function doOutsideOfYieldAndAwaitContext(func) { + return doOutsideOfContext(2 /* Yield */ | 8 /* Await */, func); + } + function inContext(flags) { + return (contextFlags & flags) !== 0; + } + function inYieldContext() { + return inContext(2 /* Yield */); + } + function inDisallowInContext() { + return inContext(1 /* DisallowIn */); + } + function inDecoratorContext() { + return inContext(4 /* Decorator */); + } + function inAwaitContext() { + return inContext(8 /* Await */); + } + function parseErrorAtCurrentToken(message, arg0) { + var start = scanner.getTokenPos(); + var length = scanner.getTextPos() - start; + parseErrorAtPosition(start, length, message, arg0); + } + function parseErrorAtPosition(start, length, message, arg0) { + // Don't report another error if it would just be at the same position as the last error. + var lastError = ts.lastOrUndefined(parseDiagnostics); + if (!lastError || start !== lastError.start) { + parseDiagnostics.push(ts.createFileDiagnostic(sourceFile, start, length, message, arg0)); + } + // Mark that we've encountered an error. We'll set an appropriate bit on the next + // node we finish so that it can't be reused incrementally. + parseErrorBeforeNextFinishedNode = true; + } + function scanError(message, length) { + var pos = scanner.getTextPos(); + parseErrorAtPosition(pos, length || 0, message); + } + function getNodePos() { + return scanner.getStartPos(); + } + function getNodeEnd() { + return scanner.getStartPos(); + } + function nextToken() { + return token = scanner.scan(); + } + function getTokenPos(pos) { + return ts.skipTrivia(sourceText, pos); + } + function reScanGreaterToken() { + return token = scanner.reScanGreaterToken(); + } + function reScanSlashToken() { + return token = scanner.reScanSlashToken(); + } + function reScanTemplateToken() { + return token = scanner.reScanTemplateToken(); + } + function scanJsxIdentifier() { + return token = scanner.scanJsxIdentifier(); + } + function scanJsxText() { + return token = scanner.scanJsxToken(); + } + function speculationHelper(callback, isLookAhead) { + // Keep track of the state we'll need to rollback to if lookahead fails (or if the + // caller asked us to always reset our state). + var saveToken = token; + var saveParseDiagnosticsLength = parseDiagnostics.length; + var saveParseErrorBeforeNextFinishedNode = parseErrorBeforeNextFinishedNode; + // Note: it is not actually necessary to save/restore the context flags here. That's + // because the saving/restoring of these flags happens naturally through the recursive + // descent nature of our parser. However, we still store this here just so we can + // assert that that invariant holds. + var saveContextFlags = contextFlags; + // If we're only looking ahead, then tell the scanner to only lookahead as well. + // Otherwise, if we're actually speculatively parsing, then tell the scanner to do the + // same. + var result = isLookAhead + ? scanner.lookAhead(callback) + : scanner.tryScan(callback); + ts.Debug.assert(saveContextFlags === contextFlags); + // If our callback returned something 'falsy' or we're just looking ahead, + // then unconditionally restore us to where we were. + if (!result || isLookAhead) { + token = saveToken; + parseDiagnostics.length = saveParseDiagnosticsLength; + parseErrorBeforeNextFinishedNode = saveParseErrorBeforeNextFinishedNode; + } + return result; + } + // Invokes the provided callback then unconditionally restores the parser to the state it + // was in immediately prior to invoking the callback. The result of invoking the callback + // is returned from this function. + function lookAhead(callback) { + return speculationHelper(callback, /*isLookAhead*/ true); + } + // Invokes the provided callback. If the callback returns something falsy, then it restores + // the parser to the state it was in immediately prior to invoking the callback. If the + // callback returns something truthy, then the parser state is not rolled back. The result + // of invoking the callback is returned from this function. + function tryParse(callback) { + return speculationHelper(callback, /*isLookAhead*/ false); + } + // Ignore strict mode flag because we will report an error in type checker instead. + function isIdentifier() { + if (token === 69 /* Identifier */) { + return true; + } + // If we have a 'yield' keyword, and we're in the [yield] context, then 'yield' is + // considered a keyword and is not an identifier. + if (token === 114 /* YieldKeyword */ && inYieldContext()) { + return false; + } + // If we have a 'await' keyword, and we're in the [Await] context, then 'await' is + // considered a keyword and is not an identifier. + if (token === 119 /* AwaitKeyword */ && inAwaitContext()) { + return false; + } + return token > 105 /* LastReservedWord */; + } + function parseExpected(kind, diagnosticMessage, shouldAdvance) { + if (shouldAdvance === void 0) { shouldAdvance = true; } + if (token === kind) { + if (shouldAdvance) { + nextToken(); + } + return true; + } + // Report specific message if provided with one. Otherwise, report generic fallback message. + if (diagnosticMessage) { + parseErrorAtCurrentToken(diagnosticMessage); + } + else { + parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(kind)); + } + return false; + } + function parseOptional(t) { + if (token === t) { + nextToken(); + return true; + } + return false; + } + function parseOptionalToken(t) { + if (token === t) { + return parseTokenNode(); + } + return undefined; + } + function parseExpectedToken(t, reportAtCurrentPosition, diagnosticMessage, arg0) { + return parseOptionalToken(t) || + createMissingNode(t, reportAtCurrentPosition, diagnosticMessage, arg0); + } + function parseTokenNode() { + var node = createNode(token); + nextToken(); + return finishNode(node); + } + function canParseSemicolon() { + // If there's a real semicolon, then we can always parse it out. + if (token === 23 /* 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(); + } + function parseSemicolon() { + if (canParseSemicolon()) { + if (token === 23 /* SemicolonToken */) { + // consume the semicolon if it was explicitly provided. + nextToken(); + } + return true; + } + else { + return parseExpected(23 /* SemicolonToken */); + } + } + function createNode(kind, pos) { + nodeCount++; + if (!(pos >= 0)) { + pos = scanner.getStartPos(); + } + return new (nodeConstructors[kind] || (nodeConstructors[kind] = ts.objectAllocator.getNodeConstructor(kind)))(pos, pos); + } + function finishNode(node, end) { + node.end = end === undefined ? scanner.getStartPos() : end; + if (contextFlags) { + node.parserContextFlags = contextFlags; + } + // Keep track on the node if we encountered an error while parsing it. If we did, then + // we cannot reuse the node incrementally. Once we've marked this node, clear out the + // flag so that we don't mark any subsequent nodes. + if (parseErrorBeforeNextFinishedNode) { + parseErrorBeforeNextFinishedNode = false; + node.parserContextFlags |= 16 /* ThisNodeHasError */; + } + return node; + } + function createMissingNode(kind, reportAtCurrentPosition, diagnosticMessage, arg0) { + if (reportAtCurrentPosition) { + parseErrorAtPosition(scanner.getStartPos(), 0, diagnosticMessage, arg0); + } + else { + parseErrorAtCurrentToken(diagnosticMessage, arg0); + } + var result = createNode(kind, scanner.getStartPos()); + result.text = ""; + return finishNode(result); + } + function internIdentifier(text) { + text = ts.escapeIdentifier(text); + return ts.hasProperty(identifiers, text) ? identifiers[text] : (identifiers[text] = text); + } + // An identifier that starts with two underscores has an extra underscore character prepended to it to avoid issues + // with magic property names like '__proto__'. The 'identifiers' object is used to share a single string instance for + // each identifier in order to reduce memory consumption. + function createIdentifier(isIdentifier, diagnosticMessage) { + identifierCount++; + if (isIdentifier) { + var node = createNode(69 /* Identifier */); + // Store original token kind if it is not just an Identifier so we can report appropriate error later in type checker + if (token !== 69 /* Identifier */) { + node.originalKeywordKind = token; + } + node.text = internIdentifier(scanner.getTokenValue()); + nextToken(); + return finishNode(node); + } + return createMissingNode(69 /* Identifier */, /*reportAtCurrentPosition*/ false, diagnosticMessage || ts.Diagnostics.Identifier_expected); + } + function parseIdentifier(diagnosticMessage) { + return createIdentifier(isIdentifier(), diagnosticMessage); + } + function parseIdentifierName() { + return createIdentifier(ts.tokenIsIdentifierOrKeyword(token)); + } + function isLiteralPropertyName() { + return ts.tokenIsIdentifierOrKeyword(token) || + token === 9 /* StringLiteral */ || + token === 8 /* NumericLiteral */; + } + function parsePropertyNameWorker(allowComputedPropertyNames) { + if (token === 9 /* StringLiteral */ || token === 8 /* NumericLiteral */) { + return parseLiteralNode(/*internName*/ true); + } + if (allowComputedPropertyNames && token === 19 /* OpenBracketToken */) { + return parseComputedPropertyName(); + } + return parseIdentifierName(); + } + function parsePropertyName() { + return parsePropertyNameWorker(/*allowComputedPropertyNames:*/ true); + } + function parseSimplePropertyName() { + return parsePropertyNameWorker(/*allowComputedPropertyNames:*/ false); + } + function isSimplePropertyName() { + return token === 9 /* StringLiteral */ || token === 8 /* NumericLiteral */ || ts.tokenIsIdentifierOrKeyword(token); + } + function parseComputedPropertyName() { + // PropertyName [Yield]: + // LiteralPropertyName + // ComputedPropertyName[?Yield] + var node = createNode(136 /* ComputedPropertyName */); + parseExpected(19 /* OpenBracketToken */); + // We parse any expression (including a comma expression). But the grammar + // says that only an assignment expression is allowed, so the grammar checker + // will error if it sees a comma expression. + node.expression = allowInAnd(parseExpression); + parseExpected(20 /* CloseBracketToken */); + return finishNode(node); + } + function parseContextualModifier(t) { + return token === t && tryParse(nextTokenCanFollowModifier); + } + function nextTokenCanFollowModifier() { + if (token === 74 /* ConstKeyword */) { + // 'const' is only a modifier if followed by 'enum'. + return nextToken() === 81 /* EnumKeyword */; + } + if (token === 82 /* ExportKeyword */) { + nextToken(); + if (token === 77 /* DefaultKeyword */) { + return lookAhead(nextTokenIsClassOrFunction); + } + return token !== 37 /* AsteriskToken */ && token !== 15 /* OpenBraceToken */ && canFollowModifier(); + } + if (token === 77 /* DefaultKeyword */) { + return nextTokenIsClassOrFunction(); + } + if (token === 113 /* StaticKeyword */) { + nextToken(); + return canFollowModifier(); + } + nextToken(); + if (scanner.hasPrecedingLineBreak()) { + return false; + } + return canFollowModifier(); + } + function parseAnyContextualModifier() { + return ts.isModifier(token) && tryParse(nextTokenCanFollowModifier); + } + function canFollowModifier() { + return token === 19 /* OpenBracketToken */ + || token === 15 /* OpenBraceToken */ + || token === 37 /* AsteriskToken */ + || isLiteralPropertyName(); + } + function nextTokenIsClassOrFunction() { + nextToken(); + return token === 73 /* ClassKeyword */ || token === 87 /* FunctionKeyword */; + } + // True if positioned at the start of a list element + function isListElement(parsingContext, inErrorRecovery) { + var node = currentNode(parsingContext); + if (node) { + return true; + } + switch (parsingContext) { + case 0 /* SourceElements */: + case 1 /* BlockStatements */: + case 3 /* SwitchClauseStatements */: + // If we're in error recovery, then we don't want to treat ';' as an empty statement. + // The problem is that ';' can show up in far too many contexts, and if we see one + // and assume it's a statement, then we may bail out inappropriately from whatever + // 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(); + case 2 /* SwitchClauses */: + return token === 71 /* CaseKeyword */ || token === 77 /* DefaultKeyword */; + case 4 /* TypeMembers */: + return isStartOfTypeMember(); + case 5 /* ClassMembers */: + // We allow semicolons as class elements (as specified by ES6) as long as we're + // 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); + 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(); + case 12 /* ObjectLiteralMembers */: + return token === 19 /* OpenBracketToken */ || token === 37 /* AsteriskToken */ || isLiteralPropertyName(); + case 9 /* ObjectBindingElements */: + return 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 */) { + return lookAhead(isValidHeritageClauseObjectLiteral); + } + if (!inErrorRecovery) { + return isStartOfLeftHandSideExpression() && !isHeritageClauseExtendsOrImplementsKeyword(); + } + else { + // If we're in error recovery we tighten up what we're willing to match. + // That way we don't treat something like "this" as a valid heritage clause + // element during recovery. + return isIdentifier() && !isHeritageClauseExtendsOrImplementsKeyword(); + } + case 8 /* VariableDeclarations */: + return isIdentifierOrPattern(); + case 10 /* ArrayBindingElements */: + return token === 24 /* CommaToken */ || token === 22 /* DotDotDotToken */ || isIdentifierOrPattern(); + case 17 /* TypeParameters */: + return isIdentifier(); + case 11 /* ArgumentExpressions */: + case 15 /* ArrayLiteralMembers */: + return token === 24 /* CommaToken */ || token === 22 /* DotDotDotToken */ || isStartOfExpression(); + case 16 /* Parameters */: + return isStartOfParameter(); + case 18 /* TypeArguments */: + case 19 /* TupleElementTypes */: + return token === 24 /* CommaToken */ || isStartOfType(); + case 20 /* HeritageClauses */: + return isHeritageClause(); + case 21 /* ImportOrExportSpecifiers */: + return ts.tokenIsIdentifierOrKeyword(token); + case 13 /* JsxAttributes */: + return ts.tokenIsIdentifierOrKeyword(token) || token === 15 /* OpenBraceToken */; + case 14 /* JsxChildren */: + return true; + case 22 /* JSDocFunctionParameters */: + case 23 /* JSDocTypeArguments */: + case 25 /* JSDocTupleTypes */: + return JSDocParser.isJSDocType(); + case 24 /* JSDocRecordMembers */: + return isSimplePropertyName(); + } + ts.Debug.fail("Non-exhaustive case in 'isListElement'."); + } + function isValidHeritageClauseObjectLiteral() { + ts.Debug.assert(token === 15 /* OpenBraceToken */); + if (nextToken() === 16 /* CloseBraceToken */) { + // if we see "extends {}" then only treat the {} as what we're extending (and not + // the class body) if we have: + // + // extends {} { + // extends {}, + // extends {} extends + // extends {} implements + var next = nextToken(); + return next === 24 /* CommaToken */ || next === 15 /* OpenBraceToken */ || next === 83 /* ExtendsKeyword */ || next === 106 /* ImplementsKeyword */; + } + return true; + } + function nextTokenIsIdentifier() { + nextToken(); + return isIdentifier(); + } + function nextTokenIsIdentifierOrKeyword() { + nextToken(); + return ts.tokenIsIdentifierOrKeyword(token); + } + function isHeritageClauseExtendsOrImplementsKeyword() { + if (token === 106 /* ImplementsKeyword */ || + token === 83 /* ExtendsKeyword */) { + return lookAhead(nextTokenIsStartOfExpression); + } + return false; + } + function nextTokenIsStartOfExpression() { + nextToken(); + return isStartOfExpression(); + } + // True if positioned at a list terminator + function isListTerminator(kind) { + if (token === 1 /* EndOfFileToken */) { + // Being at the end of the file ends all lists. + return true; + } + switch (kind) { + case 1 /* BlockStatements */: + case 2 /* SwitchClauses */: + case 4 /* TypeMembers */: + case 5 /* ClassMembers */: + case 6 /* EnumMembers */: + case 12 /* ObjectLiteralMembers */: + case 9 /* ObjectBindingElements */: + case 21 /* ImportOrExportSpecifiers */: + return token === 16 /* CloseBraceToken */; + case 3 /* SwitchClauseStatements */: + return token === 16 /* CloseBraceToken */ || token === 71 /* CaseKeyword */ || token === 77 /* DefaultKeyword */; + case 7 /* HeritageClauseElement */: + return token === 15 /* OpenBraceToken */ || token === 83 /* ExtendsKeyword */ || token === 106 /* ImplementsKeyword */; + case 8 /* VariableDeclarations */: + return isVariableDeclaratorListTerminator(); + case 17 /* TypeParameters */: + // Tokens other than '>' are here for better error recovery + return token === 27 /* GreaterThanToken */ || token === 17 /* OpenParenToken */ || token === 15 /* OpenBraceToken */ || token === 83 /* ExtendsKeyword */ || token === 106 /* ImplementsKeyword */; + case 11 /* ArgumentExpressions */: + // Tokens other than ')' are here for better error recovery + return token === 18 /* CloseParenToken */ || token === 23 /* SemicolonToken */; + case 15 /* ArrayLiteralMembers */: + case 19 /* TupleElementTypes */: + case 10 /* ArrayBindingElements */: + return token === 20 /* 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*/; + case 18 /* TypeArguments */: + // Tokens other than '>' are here for better error recovery + return token === 27 /* GreaterThanToken */ || token === 17 /* OpenParenToken */; + case 20 /* HeritageClauses */: + return token === 15 /* OpenBraceToken */ || token === 16 /* CloseBraceToken */; + case 13 /* JsxAttributes */: + return token === 27 /* GreaterThanToken */ || token === 39 /* SlashToken */; + case 14 /* JsxChildren */: + return token === 25 /* LessThanToken */ && lookAhead(nextTokenIsSlash); + case 22 /* JSDocFunctionParameters */: + return token === 18 /* CloseParenToken */ || token === 54 /* ColonToken */ || token === 16 /* CloseBraceToken */; + case 23 /* JSDocTypeArguments */: + return token === 27 /* GreaterThanToken */ || token === 16 /* CloseBraceToken */; + case 25 /* JSDocTupleTypes */: + return token === 20 /* CloseBracketToken */ || token === 16 /* CloseBraceToken */; + case 24 /* JSDocRecordMembers */: + return token === 16 /* CloseBraceToken */; + } + } + function isVariableDeclaratorListTerminator() { + // If we can consume a semicolon (either explicitly, or with ASI), then consider us done + // with parsing the list of variable declarators. + if (canParseSemicolon()) { + return true; + } + // in the case where we're parsing the variable declarator of a 'for-in' statement, we + // are done if we see an 'in' keyword in front of us. Same with for-of + if (isInOrOfKeyword(token)) { + return true; + } + // ERROR RECOVERY TWEAK: + // 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 */) { + return true; + } + // Keep trying to parse out variable declarators. + return false; + } + // True if positioned at element or terminator of the current list or any enclosing list + function isInSomeParsingContext() { + for (var kind = 0; kind < 26 /* Count */; kind++) { + if (parsingContext & (1 << kind)) { + if (isListElement(kind, /* inErrorRecovery */ true) || isListTerminator(kind)) { + return true; + } + } + } + return false; + } + // Parses a list of elements + function parseList(kind, parseElement) { + var saveParsingContext = parsingContext; + parsingContext |= 1 << kind; + var result = []; + result.pos = getNodePos(); + while (!isListTerminator(kind)) { + if (isListElement(kind, /* inErrorRecovery */ false)) { + var element = parseListElement(kind, parseElement); + result.push(element); + continue; + } + if (abortParsingListOrMoveToNextToken(kind)) { + break; + } + } + result.end = getNodeEnd(); + parsingContext = saveParsingContext; + return result; + } + function parseListElement(parsingContext, parseElement) { + var node = currentNode(parsingContext); + if (node) { + return consumeNode(node); + } + return parseElement(); + } + function currentNode(parsingContext) { + // If there is an outstanding parse error that we've encountered, but not attached to + // some node, then we cannot get a node from the old source tree. This is because we + // want to mark the next node we encounter as being unusable. + // + // Note: This may be too conservative. Perhaps we could reuse the node and set the bit + // on it (or its leftmost child) as having the error. For now though, being conservative + // is nice and likely won't ever affect perf. + if (parseErrorBeforeNextFinishedNode) { + return undefined; + } + if (!syntaxCursor) { + // if we don't have a cursor, we could never return a node from the old tree. + return undefined; + } + var node = syntaxCursor.currentNode(scanner.getStartPos()); + // Can't reuse a missing node. + if (ts.nodeIsMissing(node)) { + return undefined; + } + // Can't reuse a node that intersected the change range. + if (node.intersectsChange) { + return undefined; + } + // Can't reuse a node that contains a parse error. This is necessary so that we + // produce the same set of errors again. + if (ts.containsParseError(node)) { + return undefined; + } + // We can only reuse a node if it was parsed under the same strict mode that we're + // currently in. i.e. if we originally parsed a node in non-strict mode, but then + // the user added 'using strict' at the top of the file, then we can't use that node + // again as the presense of strict mode may cause us to parse the tokens in the file + // differetly. + // + // Note: we *can* reuse tokens when the strict mode changes. That's because tokens + // are unaffected by strict mode. It's just the parser will decide what to do with it + // differently depending on what mode it is in. + // + // This also applies to all our other context flags as well. + var nodeContextFlags = node.parserContextFlags & 31 /* ParserGeneratedFlags */; + if (nodeContextFlags !== contextFlags) { + return undefined; + } + // Ok, we have a node that looks like it could be reused. Now verify that it is valid + // in the currest list parsing context that we're currently at. + if (!canReuseNode(node, parsingContext)) { + return undefined; + } + return node; + } + function consumeNode(node) { + // Move the scanner so it is after the node we just consumed. + scanner.setTextPos(node.end); + nextToken(); + return node; + } + function canReuseNode(node, parsingContext) { + switch (parsingContext) { + case 5 /* ClassMembers */: + return isReusableClassMember(node); + case 2 /* SwitchClauses */: + return isReusableSwitchClause(node); + case 0 /* SourceElements */: + case 1 /* BlockStatements */: + case 3 /* SwitchClauseStatements */: + return isReusableStatement(node); + case 6 /* EnumMembers */: + return isReusableEnumMember(node); + case 4 /* TypeMembers */: + return isReusableTypeMember(node); + case 8 /* VariableDeclarations */: + return isReusableVariableDeclaration(node); + case 16 /* Parameters */: + return isReusableParameter(node); + // Any other lists we do not care about reusing nodes in. But feel free to add if + // you can do so safely. Danger areas involve nodes that may involve speculative + // parsing. If speculative parsing is involved with the node, then the range the + // parser reached while looking ahead might be in the edited range (see the example + // in canReuseVariableDeclaratorNode for a good case of this). + case 20 /* HeritageClauses */: + // This would probably be safe to reuse. There is no speculative parsing with + // heritage clauses. + case 17 /* TypeParameters */: + // This would probably be safe to reuse. There is no speculative parsing with + // type parameters. Note that that's because type *parameters* only occur in + // unambiguous *type* contexts. While type *arguments* occur in very ambiguous + // *expression* contexts. + case 19 /* TupleElementTypes */: + // This would probably be safe to reuse. There is no speculative parsing with + // tuple types. + // Technically, type argument list types are probably safe to reuse. While + // speculative parsing is involved with them (since type argument lists are only + // produced from speculative parsing a < as a type argument list), we only have + // the types because speculative parsing succeeded. Thus, the lookahead never + // went past the end of the list and rewound. + case 18 /* TypeArguments */: + // Note: these are almost certainly not safe to ever reuse. Expressions commonly + // need a large amount of lookahead, and we should not reuse them as they may + // have actually intersected the edit. + case 11 /* ArgumentExpressions */: + // This is not safe to reuse for the same reason as the 'AssignmentExpression' + // cases. i.e. a property assignment may end with an expression, and thus might + // have lookahead far beyond it's old node. + case 12 /* ObjectLiteralMembers */: + // This is probably not safe to reuse. There can be speculative parsing with + // type names in a heritage clause. There can be generic names in the type + // name list, and there can be left hand side expressions (which can have type + // arguments.) + case 7 /* HeritageClauseElement */: + // Perhaps safe to reuse, but it's unlikely we'd see more than a dozen attributes + // on any given element. Same for children. + case 13 /* JsxAttributes */: + case 14 /* JsxChildren */: + } + return false; + } + function isReusableClassMember(node) { + if (node) { + switch (node.kind) { + case 144 /* Constructor */: + case 149 /* IndexSignature */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: + case 141 /* PropertyDeclaration */: + case 191 /* SemicolonClassElement */: + return true; + case 143 /* MethodDeclaration */: + // Method declarations are not necessarily reusable. An object-literal + // may have a method calls "constructor(...)" and we must reparse that + // into an actual .ConstructorDeclaration. + var methodDeclaration = node; + var nameIsConstructor = methodDeclaration.name.kind === 69 /* Identifier */ && + methodDeclaration.name.originalKeywordKind === 121 /* ConstructorKeyword */; + return !nameIsConstructor; + } + } + return false; + } + function isReusableSwitchClause(node) { + if (node) { + switch (node.kind) { + case 241 /* CaseClause */: + case 242 /* DefaultClause */: + return true; + } + } + return false; + } + function isReusableStatement(node) { + if (node) { + switch (node.kind) { + case 213 /* FunctionDeclaration */: + case 193 /* VariableStatement */: + case 192 /* Block */: + case 196 /* IfStatement */: + case 195 /* ExpressionStatement */: + case 208 /* ThrowStatement */: + case 204 /* ReturnStatement */: + case 206 /* SwitchStatement */: + case 203 /* BreakStatement */: + case 202 /* ContinueStatement */: + case 200 /* ForInStatement */: + case 201 /* ForOfStatement */: + case 199 /* ForStatement */: + case 198 /* WhileStatement */: + case 205 /* WithStatement */: + case 194 /* EmptyStatement */: + case 209 /* TryStatement */: + case 207 /* LabeledStatement */: + case 197 /* DoStatement */: + case 210 /* DebuggerStatement */: + case 222 /* ImportDeclaration */: + case 221 /* ImportEqualsDeclaration */: + case 228 /* ExportDeclaration */: + case 227 /* ExportAssignment */: + case 218 /* ModuleDeclaration */: + case 214 /* ClassDeclaration */: + case 215 /* InterfaceDeclaration */: + case 217 /* EnumDeclaration */: + case 216 /* TypeAliasDeclaration */: + return true; + } + } + return false; + } + function isReusableEnumMember(node) { + return node.kind === 247 /* EnumMember */; + } + function isReusableTypeMember(node) { + if (node) { + switch (node.kind) { + case 148 /* ConstructSignature */: + case 142 /* MethodSignature */: + case 149 /* IndexSignature */: + case 140 /* PropertySignature */: + case 147 /* CallSignature */: + return true; + } + } + return false; + } + function isReusableVariableDeclaration(node) { + if (node.kind !== 211 /* VariableDeclaration */) { + return false; + } + // Very subtle incremental parsing bug. Consider the following code: + // + // let v = new List < A, B + // + // This is actually legal code. It's a list of variable declarators "v = new List() + // + // then we have a problem. "v = new List= 0) { + // Always preserve a trailing comma by marking it on the NodeArray + result.hasTrailingComma = true; + } + result.end = getNodeEnd(); + parsingContext = saveParsingContext; + return result; + } + function createMissingList() { + var pos = getNodePos(); + var result = []; + result.pos = pos; + result.end = pos; + return result; + } + function parseBracketedList(kind, parseElement, open, close) { + if (parseExpected(open)) { + var result = parseDelimitedList(kind, parseElement); + parseExpected(close); + return result; + } + return createMissingList(); + } + // 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(135 /* QualifiedName */, entity.pos); + node.left = entity; + node.right = parseRightSideOfDot(allowReservedWords); + entity = finishNode(node); + } + return entity; + } + function parseRightSideOfDot(allowIdentifierNames) { + // Technically a keyword is valid here as all identifiers and keywords are identifier names. + // However, often we'll encounter this in error situations when the identifier or keyword + // is actually starting another valid construct. + // + // So, we check for the following specific case: + // + // name. + // identifierOrKeyword identifierNameOrKeyword + // + // Note: the newlines are important here. For example, if that above code + // were rewritten into: + // + // name.identifierOrKeyword + // identifierNameOrKeyword + // + // Then we would consider it valid. That's because ASI would take effect and + // the code would be implicitly: "name.identifierOrKeyword; identifierNameOrKeyword". + // In the first case though, ASI will not take effect because there is not a + // line terminator after the identifier or keyword. + if (scanner.hasPrecedingLineBreak() && ts.tokenIsIdentifierOrKeyword(token)) { + var matchesPattern = lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine); + if (matchesPattern) { + // 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 */, /*reportAtCurrentToken*/ true, ts.Diagnostics.Identifier_expected); + } + } + return allowIdentifierNames ? parseIdentifierName() : parseIdentifier(); + } + function parseTemplateExpression() { + var template = createNode(183 /* TemplateExpression */); + template.head = parseLiteralNode(); + ts.Debug.assert(template.head.kind === 12 /* TemplateHead */, "Template head has wrong token kind"); + var templateSpans = []; + templateSpans.pos = getNodePos(); + do { + templateSpans.push(parseTemplateSpan()); + } while (ts.lastOrUndefined(templateSpans).literal.kind === 13 /* TemplateMiddle */); + templateSpans.end = getNodeEnd(); + template.templateSpans = templateSpans; + return finishNode(template); + } + function parseTemplateSpan() { + var span = createNode(190 /* TemplateSpan */); + span.expression = allowInAnd(parseExpression); + var literal; + if (token === 16 /* CloseBraceToken */) { + reScanTemplateToken(); + literal = parseLiteralNode(); + } + else { + literal = parseExpectedToken(14 /* TemplateTail */, /*reportAtCurrentPosition*/ false, ts.Diagnostics._0_expected, ts.tokenToString(16 /* CloseBraceToken */)); + } + span.literal = literal; + return finishNode(span); + } + function parseLiteralNode(internName) { + var node = createNode(token); + var text = scanner.getTokenValue(); + node.text = internName ? internIdentifier(text) : text; + if (scanner.hasExtendedUnicodeEscape()) { + node.hasExtendedUnicodeEscape = true; + } + if (scanner.isUnterminated()) { + node.isUnterminated = true; + } + var tokenPos = scanner.getTokenPos(); + nextToken(); + finishNode(node); + // Octal literals are not allowed in strict mode or ES5 + // Note that theoretically the following condition would hold true literals like 009, + // which is not octal.But because of how the scanner separates the tokens, we would + // never get a token like this. Instead, we would get 00 and 9 as two separate tokens. + // We also do not need to check for negatives because any prefix operator would be part of a + // parent unary expression. + if (node.kind === 8 /* NumericLiteral */ + && sourceText.charCodeAt(tokenPos) === 48 /* _0 */ + && ts.isOctalDigit(sourceText.charCodeAt(tokenPos + 1))) { + node.flags |= 65536 /* OctalLiteral */; + } + return node; + } + // TYPES + function parseTypeReferenceOrTypePredicate() { + var typeName = parseEntityName(/*allowReservedWords*/ false, ts.Diagnostics.Type_expected); + if (typeName.kind === 69 /* Identifier */ && token === 124 /* IsKeyword */ && !scanner.hasPrecedingLineBreak()) { + nextToken(); + var node_1 = createNode(150 /* TypePredicate */, typeName.pos); + node_1.parameterName = typeName; + node_1.type = parseType(); + return finishNode(node_1); + } + var node = createNode(151 /* TypeReference */, typeName.pos); + node.typeName = typeName; + if (!scanner.hasPrecedingLineBreak() && token === 25 /* LessThanToken */) { + node.typeArguments = parseBracketedList(18 /* TypeArguments */, parseType, 25 /* LessThanToken */, 27 /* GreaterThanToken */); + } + return finishNode(node); + } + function parseTypeQuery() { + var node = createNode(154 /* TypeQuery */); + parseExpected(101 /* TypeOfKeyword */); + node.exprName = parseEntityName(/*allowReservedWords*/ true); + return finishNode(node); + } + function parseTypeParameter() { + var node = createNode(137 /* TypeParameter */); + node.name = parseIdentifier(); + if (parseOptional(83 /* ExtendsKeyword */)) { + // It's not uncommon for people to write improper constraints to a generic. If the + // user writes a constraint that is an expression and not an actual type, then parse + // it out as an expression (so we can recover well), but report that a type is needed + // instead. + if (isStartOfType() || !isStartOfExpression()) { + node.constraint = parseType(); + } + else { + // It was not a type, and it looked like an expression. Parse out an expression + // here so we recover well. Note: it is important that we call parseUnaryExpression + // and not parseExpression here. If the user has: + // + // + // + // We do *not* want to consume the > as we're consuming the expression for "". + node.expression = parseUnaryExpressionOrHigher(); + } + } + return finishNode(node); + } + function parseTypeParameters() { + if (token === 25 /* LessThanToken */) { + return parseBracketedList(17 /* TypeParameters */, parseTypeParameter, 25 /* LessThanToken */, 27 /* GreaterThanToken */); + } + } + function parseParameterType() { + if (parseOptional(54 /* ColonToken */)) { + return token === 9 /* StringLiteral */ + ? parseLiteralNode(/*internName*/ true) + : parseType(); + } + return undefined; + } + function isStartOfParameter() { + return token === 22 /* DotDotDotToken */ || isIdentifierOrPattern() || ts.isModifier(token) || token === 55 /* AtToken */; + } + function setModifiers(node, modifiers) { + if (modifiers) { + node.flags |= modifiers.flags; + node.modifiers = modifiers; + } + } + function parseParameter() { + var node = createNode(138 /* Parameter */); + node.decorators = parseDecorators(); + setModifiers(node, parseModifiers()); + node.dotDotDotToken = parseOptionalToken(22 /* DotDotDotToken */); + // FormalParameter [Yield,Await]: + // BindingElement[?Yield,?Await] + node.name = parseIdentifierOrPattern(); + if (ts.getFullWidth(node.name) === 0 && node.flags === 0 && ts.isModifier(token)) { + // in cases like + // 'use strict' + // function foo(static) + // isParameter('static') === true, because of isModifier('static') + // however 'static' is not a legal identifier in a strict mode. + // so result of this function will be ParameterDeclaration (flags = 0, name = missing, type = undefined, initializer = undefined) + // and current token will not change => parsing of the enclosing parameter list will last till the end of time (or OOM) + // to avoid this we'll advance cursor to the next token. + nextToken(); + } + node.questionToken = parseOptionalToken(53 /* QuestionToken */); + node.type = parseParameterType(); + node.initializer = parseBindingElementInitializer(/*inParameter*/ true); + // Do not check for initializers in an ambient context for parameters. This is not + // a grammar error because the grammar allows arbitrary call signatures in + // an ambient context. + // It is actually not necessary for this to be an error at all. The reason is that + // function/constructor implementations are syntactically disallowed in ambient + // contexts. In addition, parameter initializers are semantically disallowed in + // overload signatures. So parameter initializers are transitively disallowed in + // ambient contexts. + return finishNode(node); + } + function parseBindingElementInitializer(inParameter) { + return inParameter ? parseParameterInitializer() : parseNonParameterInitializer(); + } + function parseParameterInitializer() { + return parseInitializer(/*inParameter*/ true); + } + function fillSignature(returnToken, yieldContext, awaitContext, requireCompleteParameterList, signature) { + var returnTokenRequired = returnToken === 34 /* EqualsGreaterThanToken */; + signature.typeParameters = parseTypeParameters(); + signature.parameters = parseParameterList(yieldContext, awaitContext, requireCompleteParameterList); + if (returnTokenRequired) { + parseExpected(returnToken); + signature.type = parseType(); + } + else if (parseOptional(returnToken)) { + signature.type = parseType(); + } + } + function parseParameterList(yieldContext, awaitContext, requireCompleteParameterList) { + // FormalParameters [Yield,Await]: (modified) + // [empty] + // FormalParameterList[?Yield,Await] + // + // FormalParameter[Yield,Await]: (modified) + // BindingElement[?Yield,Await] + // + // BindingElement [Yield,Await]: (modified) + // SingleNameBinding[?Yield,?Await] + // BindingPattern[?Yield,?Await]Initializer [In, ?Yield,?Await] opt + // + // SingleNameBinding [Yield,Await]: + // BindingIdentifier[?Yield,?Await]Initializer [In, ?Yield,?Await] opt + if (parseExpected(17 /* OpenParenToken */)) { + var savedYieldContext = inYieldContext(); + var savedAwaitContext = inAwaitContext(); + setYieldContext(yieldContext); + setAwaitContext(awaitContext); + var result = parseDelimitedList(16 /* Parameters */, parseParameter); + setYieldContext(savedYieldContext); + setAwaitContext(savedAwaitContext); + if (!parseExpected(18 /* CloseParenToken */) && requireCompleteParameterList) { + // Caller insisted that we had to end with a ) We didn't. So just return + // undefined here. + return undefined; + } + return result; + } + // We didn't even have an open paren. If the caller requires a complete parameter list, + // we definitely can't provide that. However, if they're ok with an incomplete one, + // then just return an empty set of parameters. + return requireCompleteParameterList ? undefined : createMissingList(); + } + 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 */)) { + return; + } + // Didn't have a comma. We must have a (possible ASI) semicolon. + parseSemicolon(); + } + function parseSignatureMember(kind) { + var node = createNode(kind); + if (kind === 148 /* ConstructSignature */) { + parseExpected(92 /* NewKeyword */); + } + fillSignature(54 /* ColonToken */, /*yieldContext*/ false, /*awaitContext*/ false, /*requireCompleteParameterList*/ false, node); + parseTypeMemberSemicolon(); + return finishNode(node); + } + function isIndexSignature() { + if (token !== 19 /* OpenBracketToken */) { + return false; + } + return lookAhead(isUnambiguouslyIndexSignature); + } + function isUnambiguouslyIndexSignature() { + // The only allowed sequence is: + // + // [id: + // + // However, for error recovery, we also check the following cases: + // + // [... + // [id, + // [id?, + // [id?: + // [id?] + // [public id + // [private id + // [protected id + // [] + // + nextToken(); + if (token === 22 /* DotDotDotToken */ || token === 20 /* CloseBracketToken */) { + return true; + } + if (ts.isModifier(token)) { + nextToken(); + if (isIdentifier()) { + return true; + } + } + else if (!isIdentifier()) { + return false; + } + else { + // Skip the identifier + nextToken(); + } + // 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 */) { + 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 */) { + 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 */; + } + function parseIndexSignatureDeclaration(fullStart, decorators, modifiers) { + var node = createNode(149 /* IndexSignature */, fullStart); + node.decorators = decorators; + setModifiers(node, modifiers); + node.parameters = parseBracketedList(16 /* Parameters */, parseParameter, 19 /* OpenBracketToken */, 20 /* CloseBracketToken */); + node.type = parseTypeAnnotation(); + parseTypeMemberSemicolon(); + return finishNode(node); + } + function parsePropertyOrMethodSignature() { + var fullStart = scanner.getStartPos(); + var name = parsePropertyName(); + var questionToken = parseOptionalToken(53 /* QuestionToken */); + if (token === 17 /* OpenParenToken */ || token === 25 /* LessThanToken */) { + var method = createNode(142 /* MethodSignature */, fullStart); + method.name = name; + method.questionToken = questionToken; + // Method signatues don't exist in expression contexts. So they have neither + // [Yield] nor [Await] + fillSignature(54 /* ColonToken */, /*yieldContext*/ false, /*awaitContext*/ false, /*requireCompleteParameterList*/ false, method); + parseTypeMemberSemicolon(); + return finishNode(method); + } + else { + var property = createNode(140 /* PropertySignature */, fullStart); + property.name = name; + property.questionToken = questionToken; + property.type = parseTypeAnnotation(); + parseTypeMemberSemicolon(); + return finishNode(property); + } + } + function isStartOfTypeMember() { + switch (token) { + case 17 /* OpenParenToken */: + case 25 /* LessThanToken */: + case 19 /* OpenBracketToken */: + return true; + default: + if (ts.isModifier(token)) { + var result = lookAhead(isStartOfIndexSignatureDeclaration); + if (result) { + return result; + } + } + return isLiteralPropertyName() && lookAhead(isTypeMemberWithLiteralPropertyName); + } + } + function isStartOfIndexSignatureDeclaration() { + while (ts.isModifier(token)) { + nextToken(); + } + return isIndexSignature(); + } + function isTypeMemberWithLiteralPropertyName() { + nextToken(); + return token === 17 /* OpenParenToken */ || + token === 25 /* LessThanToken */ || + token === 53 /* QuestionToken */ || + token === 54 /* ColonToken */ || + canParseSemicolon(); + } + function parseTypeMember() { + switch (token) { + case 17 /* OpenParenToken */: + case 25 /* LessThanToken */: + return parseSignatureMember(147 /* CallSignature */); + case 19 /* OpenBracketToken */: + // Indexer or computed property + return isIndexSignature() + ? parseIndexSignatureDeclaration(scanner.getStartPos(), /*decorators*/ undefined, /*modifiers*/ undefined) + : parsePropertyOrMethodSignature(); + case 92 /* NewKeyword */: + if (lookAhead(isStartOfConstructSignature)) { + return parseSignatureMember(148 /* ConstructSignature */); + } + // fall through. + case 9 /* StringLiteral */: + case 8 /* NumericLiteral */: + return parsePropertyOrMethodSignature(); + default: + // Index declaration as allowed as a type member. But as per the grammar, + // they also allow modifiers. So we have to check for an index declaration + // that might be following modifiers. This ensures that things work properly + // when incrementally parsing as the parser will produce the Index declaration + // if it has the same text regardless of whether it is inside a class or an + // object type. + if (ts.isModifier(token)) { + var result = tryParse(parseIndexSignatureWithModifiers); + if (result) { + return result; + } + } + if (ts.tokenIsIdentifierOrKeyword(token)) { + return parsePropertyOrMethodSignature(); + } + } + } + function parseIndexSignatureWithModifiers() { + var fullStart = scanner.getStartPos(); + var decorators = parseDecorators(); + var modifiers = parseModifiers(); + return isIndexSignature() + ? parseIndexSignatureDeclaration(fullStart, decorators, modifiers) + : undefined; + } + function isStartOfConstructSignature() { + nextToken(); + return token === 17 /* OpenParenToken */ || token === 25 /* LessThanToken */; + } + function parseTypeLiteral() { + var node = createNode(155 /* TypeLiteral */); + node.members = parseObjectTypeMembers(); + return finishNode(node); + } + function parseObjectTypeMembers() { + var members; + if (parseExpected(15 /* OpenBraceToken */)) { + members = parseList(4 /* TypeMembers */, parseTypeMember); + parseExpected(16 /* CloseBraceToken */); + } + else { + members = createMissingList(); + } + return members; + } + function parseTupleType() { + var node = createNode(157 /* TupleType */); + node.elementTypes = parseBracketedList(19 /* TupleElementTypes */, parseType, 19 /* OpenBracketToken */, 20 /* CloseBracketToken */); + return finishNode(node); + } + function parseParenthesizedType() { + var node = createNode(160 /* ParenthesizedType */); + parseExpected(17 /* OpenParenToken */); + node.type = parseType(); + parseExpected(18 /* CloseParenToken */); + return finishNode(node); + } + function parseFunctionOrConstructorType(kind) { + var node = createNode(kind); + if (kind === 153 /* ConstructorType */) { + parseExpected(92 /* NewKeyword */); + } + fillSignature(34 /* EqualsGreaterThanToken */, /*yieldContext*/ false, /*awaitContext*/ false, /*requireCompleteParameterList*/ false, node); + return finishNode(node); + } + function parseKeywordAndNoDot() { + var node = parseTokenNode(); + return token === 21 /* DotToken */ ? undefined : node; + } + function parseNonArrayType() { + switch (token) { + case 117 /* AnyKeyword */: + case 130 /* StringKeyword */: + case 128 /* NumberKeyword */: + case 120 /* BooleanKeyword */: + case 131 /* SymbolKeyword */: + // If these are followed by a dot, then parse these out as a dotted type reference instead. + var node = tryParse(parseKeywordAndNoDot); + return node || parseTypeReferenceOrTypePredicate(); + case 103 /* VoidKeyword */: + case 97 /* ThisKeyword */: + return parseTokenNode(); + case 101 /* TypeOfKeyword */: + return parseTypeQuery(); + case 15 /* OpenBraceToken */: + return parseTypeLiteral(); + case 19 /* OpenBracketToken */: + return parseTupleType(); + case 17 /* OpenParenToken */: + return parseParenthesizedType(); + default: + return parseTypeReferenceOrTypePredicate(); + } + } + function isStartOfType() { + switch (token) { + case 117 /* AnyKeyword */: + case 130 /* StringKeyword */: + case 128 /* NumberKeyword */: + case 120 /* BooleanKeyword */: + case 131 /* SymbolKeyword */: + case 103 /* VoidKeyword */: + case 97 /* ThisKeyword */: + case 101 /* TypeOfKeyword */: + case 15 /* OpenBraceToken */: + case 19 /* OpenBracketToken */: + case 25 /* LessThanToken */: + case 92 /* NewKeyword */: + return true; + case 17 /* 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); + default: + return isIdentifier(); + } + } + function isStartOfParenthesizedOrFunctionType() { + nextToken(); + return token === 18 /* CloseParenToken */ || isStartOfParameter() || isStartOfType(); + } + function parseArrayTypeOrHigher() { + var type = parseNonArrayType(); + while (!scanner.hasPrecedingLineBreak() && parseOptional(19 /* OpenBracketToken */)) { + parseExpected(20 /* CloseBracketToken */); + var node = createNode(156 /* ArrayType */, type.pos); + node.elementType = type; + type = finishNode(node); + } + return type; + } + function parseUnionOrIntersectionType(kind, parseConstituentType, operator) { + var type = parseConstituentType(); + if (token === operator) { + var types = [type]; + types.pos = type.pos; + while (parseOptional(operator)) { + types.push(parseConstituentType()); + } + types.end = getNodeEnd(); + var node = createNode(kind, type.pos); + node.types = types; + type = finishNode(node); + } + return type; + } + function parseIntersectionTypeOrHigher() { + return parseUnionOrIntersectionType(159 /* IntersectionType */, parseArrayTypeOrHigher, 46 /* AmpersandToken */); + } + function parseUnionTypeOrHigher() { + return parseUnionOrIntersectionType(158 /* UnionType */, parseIntersectionTypeOrHigher, 47 /* BarToken */); + } + function isStartOfFunctionType() { + if (token === 25 /* LessThanToken */) { + return true; + } + return token === 17 /* OpenParenToken */ && lookAhead(isUnambiguouslyStartOfFunctionType); + } + function isUnambiguouslyStartOfFunctionType() { + nextToken(); + if (token === 18 /* CloseParenToken */ || token === 22 /* DotDotDotToken */) { + // ( ) + // ( ... + return true; + } + if (isIdentifier() || ts.isModifier(token)) { + nextToken(); + if (token === 54 /* ColonToken */ || token === 24 /* CommaToken */ || + token === 53 /* QuestionToken */ || token === 56 /* EqualsToken */ || + isIdentifier() || ts.isModifier(token)) { + // ( id : + // ( id , + // ( id ? + // ( id = + // ( modifier id + return true; + } + if (token === 18 /* CloseParenToken */) { + nextToken(); + if (token === 34 /* EqualsGreaterThanToken */) { + // ( id ) => + return true; + } + } + } + return false; + } + function parseType() { + // The rules about 'yield' only apply to actual code/expression contexts. They don't + // apply to 'type' contexts. So we disable these parameters here before moving on. + return doOutsideOfContext(10 /* TypeExcludesFlags */, parseTypeWorker); + } + function parseTypeWorker() { + if (isStartOfFunctionType()) { + return parseFunctionOrConstructorType(152 /* FunctionType */); + } + if (token === 92 /* NewKeyword */) { + return parseFunctionOrConstructorType(153 /* ConstructorType */); + } + return parseUnionTypeOrHigher(); + } + function parseTypeAnnotation() { + return parseOptional(54 /* ColonToken */) ? parseType() : undefined; + } + // EXPRESSIONS + function isStartOfLeftHandSideExpression() { + switch (token) { + case 97 /* ThisKeyword */: + case 95 /* SuperKeyword */: + case 93 /* NullKeyword */: + case 99 /* TrueKeyword */: + case 84 /* 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 */: + return true; + default: + return isIdentifier(); + } + } + function isStartOfExpression() { + if (isStartOfLeftHandSideExpression()) { + 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 */: + // 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. + return true; + default: + // Error tolerance. If we see the start of some binary operator, we consider + // that the start of an expression. That way we'll parse out a missing identifier, + // give a good message about an identifier being missing, and then consume the + // rest of the binary expression. + if (isBinaryOperator()) { + return true; + } + return isIdentifier(); + } + } + 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 */ && + isStartOfExpression(); + } + function allowInAndParseExpression() { + return allowInAnd(parseExpression); + } + function parseExpression() { + // Expression[in]: + // AssignmentExpression[in] + // Expression[in] , AssignmentExpression[in] + // clear the decorator context when parsing Expression, as it should be unambiguous when parsing a decorator + var saveDecoratorContext = inDecoratorContext(); + if (saveDecoratorContext) { + setDecoratorContext(false); + } + var expr = parseAssignmentExpressionOrHigher(); + var operatorToken; + while ((operatorToken = parseOptionalToken(24 /* CommaToken */))) { + expr = makeBinaryExpression(expr, operatorToken, parseAssignmentExpressionOrHigher()); + } + if (saveDecoratorContext) { + setDecoratorContext(true); + } + return expr; + } + function parseInitializer(inParameter) { + if (token !== 56 /* EqualsToken */) { + // It's not uncommon during typing for the user to miss writing the '=' token. Check if + // there is no newline after the last token and if we're on an expression. If so, parse + // this as an equals-value clause with a missing equals. + // NOTE: There are two places where we allow equals-value clauses. The first is in a + // variable declarator. The second is with a parameter. For variable declarators + // 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()) { + // 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; + } + } + // Initializer[In, Yield] : + // = AssignmentExpression[?In, ?Yield] + parseExpected(56 /* EqualsToken */); + return parseAssignmentExpressionOrHigher(); + } + function parseAssignmentExpressionOrHigher() { + // AssignmentExpression[in,yield]: + // 1) ConditionalExpression[?in,?yield] + // 2) LeftHandSideExpression = AssignmentExpression[?in,?yield] + // 3) LeftHandSideExpression AssignmentOperator AssignmentExpression[?in,?yield] + // 4) ArrowFunctionExpression[?in,?yield] + // 5) [+Yield] YieldExpression[?In] + // + // Note: for ease of implementation we treat productions '2' and '3' as the same thing. + // (i.e. they're both BinaryExpressions with an assignment operator in it). + // First, do the simple check if we have a YieldExpression (production '5'). + if (isYieldExpression()) { + return parseYieldExpression(); + } + // Then, check if we have an arrow function (production '4') that starts with a parenthesized + // parameter list. If we do, we must *not* recurse for productions 1, 2 or 3. An ArrowFunction is + // not a LeftHandSideExpression, nor does it start a ConditionalExpression. So we are done + // with AssignmentExpression if we see one. + var arrowExpression = tryParseParenthesizedArrowFunctionExpression(); + if (arrowExpression) { + return arrowExpression; + } + // Now try to see if we're in production '1', '2' or '3'. A conditional expression can + // start with a LogicalOrExpression, while the assignment productions can only start with + // LeftHandSideExpressions. + // + // So, first, we try to just parse out a BinaryExpression. If we get something that is a + // LeftHandSide or higher, then we can try to parse out the assignment expression part. + // Otherwise, we try to parse out the conditional expression bit. We want to allow any + // binary expression here, so we pass in the 'lowest' precedence here so that it matches + // and consumes anything. + var expr = parseBinaryExpressionOrHigher(/*precedence*/ 0); + // 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 */) { + return parseSimpleArrowFunctionExpression(expr); + } + // Now see if we might be in cases '2' or '3'. + // If the expression was a LHS expression, and we have an assignment operator, then + // we're in '2' or '3'. Consume the assignment and return. + // + // Note: we call reScanGreaterToken so that we get an appropriately merged token + // for cases like > > = becoming >>= + if (ts.isLeftHandSideExpression(expr) && ts.isAssignmentOperator(reScanGreaterToken())) { + return makeBinaryExpression(expr, parseTokenNode(), parseAssignmentExpressionOrHigher()); + } + // It wasn't an assignment or a lambda. This is a conditional expression: + return parseConditionalExpressionRest(expr); + } + function isYieldExpression() { + if (token === 114 /* YieldKeyword */) { + // If we have a 'yield' keyword, and htis is a context where yield expressions are + // allowed, then definitely parse out a yield expression. + if (inYieldContext()) { + return true; + } + // We're in a context where 'yield expr' is not allowed. However, if we can + // definitely tell that the user was trying to parse a 'yield expr' and not + // just a normal expr that start with a 'yield' identifier, then parse out + // a 'yield expr'. We can then report an error later that they are only + // allowed in generator expressions. + // + // for example, if we see 'yield(foo)', then we'll have to treat that as an + // invocation expression of something called 'yield'. However, if we have + // 'yield foo' then that is not legal as a normal expression, so we can + // definitely recognize this as a yield expression. + // + // for now we just check if the next token is an identifier. More heuristics + // can be added here later as necessary. We just need to make sure that we + // don't accidently consume something legal. + return lookAhead(nextTokenIsIdentifierOrKeywordOrNumberOnSameLine); + } + return false; + } + function nextTokenIsIdentifierOnSameLine() { + nextToken(); + return !scanner.hasPrecedingLineBreak() && isIdentifier(); + } + function parseYieldExpression() { + var node = createNode(184 /* 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 */); + node.expression = parseAssignmentExpressionOrHigher(); + return finishNode(node); + } + else { + // if the next token is not on the same line as yield. or we don't have an '*' or + // the start of an expressin, then this is just a simple "yield" expression. + return finishNode(node); + } + } + function parseSimpleArrowFunctionExpression(identifier) { + ts.Debug.assert(token === 34 /* EqualsGreaterThanToken */, "parseSimpleArrowFunctionExpression should only have been called if we had a =>"); + var node = createNode(174 /* ArrowFunction */, identifier.pos); + var parameter = createNode(138 /* Parameter */, identifier.pos); + parameter.name = identifier; + finishNode(parameter); + node.parameters = [parameter]; + node.parameters.pos = parameter.pos; + node.parameters.end = parameter.end; + node.equalsGreaterThanToken = parseExpectedToken(34 /* EqualsGreaterThanToken */, false, ts.Diagnostics._0_expected, "=>"); + node.body = parseArrowFunctionExpressionBody(/*isAsync*/ false); + return finishNode(node); + } + function tryParseParenthesizedArrowFunctionExpression() { + var triState = isParenthesizedArrowFunctionExpression(); + if (triState === 0 /* False */) { + // It's definitely not a parenthesized arrow function expression. + return undefined; + } + // If we definitely have an arrow function, then we can just parse one, not requiring a + // following => or { token. Otherwise, we *might* have an arrow function. Try to parse + // it out, but don't allow any ambiguity, and return 'undefined' if this could be an + // expression instead. + var arrowFunction = triState === 1 /* True */ + ? parseParenthesizedArrowFunctionExpressionHead(/*allowAmbiguity*/ true) + : tryParse(parsePossibleParenthesizedArrowFunctionExpressionHead); + if (!arrowFunction) { + // Didn't appear to actually be a parenthesized arrow function. Just bail out. + return undefined; + } + var isAsync = !!(arrowFunction.flags & 512 /* Async */); + // 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 */) + ? parseArrowFunctionExpressionBody(isAsync) + : parseIdentifier(); + return finishNode(arrowFunction); + } + // True -> We definitely expect a parenthesized arrow function here. + // False -> There *cannot* be a parenthesized arrow function here. + // 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 */) { + return lookAhead(isParenthesizedArrowFunctionExpressionWorker); + } + if (token === 34 /* 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. + return 1 /* True */; + } + // Definitely not a parenthesized arrow function. + return 0 /* False */; + } + function isParenthesizedArrowFunctionExpressionWorker() { + if (token === 118 /* AsyncKeyword */) { + nextToken(); + if (scanner.hasPrecedingLineBreak()) { + return 0 /* False */; + } + if (token !== 17 /* OpenParenToken */ && token !== 25 /* LessThanToken */) { + return 0 /* False */; + } + } + var first = token; + var second = nextToken(); + if (first === 17 /* OpenParenToken */) { + if (second === 18 /* 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 */: + return 1 /* True */; + default: + return 0 /* False */; + } + } + // If encounter "([" or "({", this could be the start of a binding pattern. + // Examples: + // ([ x ]) => { } + // ({ x }) => { } + // ([ x ]) + // ({ x }) + if (second === 19 /* OpenBracketToken */ || second === 15 /* OpenBraceToken */) { + return 2 /* Unknown */; + } + // Simple case: "(..." + // This is an arrow function with a rest parameter. + if (second === 22 /* DotDotDotToken */) { + return 1 /* True */; + } + // If we had "(" followed by something that's not an identifier, + // then this definitely doesn't look like a lambda. + // Note: we could be a little more lenient and allow + // "(public" or "(private". These would not ever actually be allowed, + // but we could provide a good error message instead of bailing out. + if (!isIdentifier()) { + return 0 /* False */; + } + // If we have something like "(a:", then we must have a + // type-annotated parameter in an arrow function expression. + if (nextToken() === 54 /* ColonToken */) { + return 1 /* True */; + } + // This *could* be a parenthesized arrow function. + // Return Unknown to let the caller know. + return 2 /* Unknown */; + } + else { + ts.Debug.assert(first === 25 /* LessThanToken */); + // If we have "<" not followed by an identifier, + // then this definitely is not an arrow function. + if (!isIdentifier()) { + return 0 /* False */; + } + // JSX overrides + if (sourceFile.languageVariant === 1 /* JSX */) { + var isArrowFunctionInJsx = lookAhead(function () { + var third = nextToken(); + if (third === 83 /* ExtendsKeyword */) { + var fourth = nextToken(); + switch (fourth) { + case 56 /* EqualsToken */: + case 27 /* GreaterThanToken */: + return false; + default: + return true; + } + } + else if (third === 24 /* CommaToken */) { + return true; + } + return false; + }); + if (isArrowFunctionInJsx) { + return 1 /* True */; + } + return 0 /* False */; + } + // This *could* be a parenthesized arrow function. + return 2 /* Unknown */; + } + } + function parsePossibleParenthesizedArrowFunctionExpressionHead() { + return parseParenthesizedArrowFunctionExpressionHead(/*allowAmbiguity*/ false); + } + function parseParenthesizedArrowFunctionExpressionHead(allowAmbiguity) { + var node = createNode(174 /* ArrowFunction */); + setModifiers(node, parseModifiersForArrowFunction()); + var isAsync = !!(node.flags & 512 /* Async */); + // Arrow functions are never generators. + // + // If we're speculatively parsing a signature for a parenthesized arrow function, then + // we have to have a complete parameter list. Otherwise we might see something like + // 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); + // If we couldn't get parameters, we definitely could not parse out an arrow function. + if (!node.parameters) { + return undefined; + } + // Parsing a signature isn't enough. + // Parenthesized arrow signatures often look like other valid expressions. + // For instance: + // - "(x = 10)" is an assignment expression parsed as a signature with a default parameter value. + // - "(x,y)" is a comma expression parsed as a signature with two parameters. + // - "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 */) { + // 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 */) { + return parseFunctionBlock(/*allowYield*/ false, /*allowAwait*/ isAsync, /*ignoreMissingOpenBrace*/ false); + } + if (token !== 23 /* SemicolonToken */ && + token !== 87 /* FunctionKeyword */ && + token !== 73 /* ClassKeyword */ && + isStartOfStatement() && + !isStartOfExpressionStatement()) { + // Check if we got a plain statement (i.e. no expression-statements, no function/class expressions/declarations) + // + // Here we try to recover from a potential error situation in the case where the + // user meant to supply a block. For example, if the user wrote: + // + // a => + // let v = 0; + // } + // + // they may be missing an open brace. Check to see if that's the case so we can + // try to recover better. If we don't do this, then the next close curly we see may end + // up preemptively closing the containing construct. + // + // Note: even when 'ignoreMissingOpenBrace' is passed as true, parseBody will still error. + return parseFunctionBlock(/*allowYield*/ false, /*allowAwait*/ isAsync, /*ignoreMissingOpenBrace*/ true); + } + return isAsync + ? doInAwaitContext(parseAssignmentExpressionOrHigher) + : doOutsideOfAwaitContext(parseAssignmentExpressionOrHigher); + } + function parseConditionalExpressionRest(leftOperand) { + // Note: we are passed in an expression which was produced from parseBinaryExpressionOrHigher. + var questionToken = parseOptionalToken(53 /* QuestionToken */); + if (!questionToken) { + return leftOperand; + } + // Note: we explicitly 'allowIn' in the whenTrue part of the condition expression, and + // we do not that for the 'whenFalse' part. + var node = createNode(182 /* 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.whenFalse = parseAssignmentExpressionOrHigher(); + return finishNode(node); + } + function parseBinaryExpressionOrHigher(precedence) { + var leftOperand = parseUnaryExpressionOrHigher(); + return parseBinaryExpressionRest(precedence, leftOperand); + } + function isInOrOfKeyword(t) { + return t === 90 /* InKeyword */ || t === 134 /* OfKeyword */; + } + function parseBinaryExpressionRest(precedence, leftOperand) { + while (true) { + // We either have a binary operator here, or we're finished. We call + // reScanGreaterToken so that we merge token sequences like > and = into >= + reScanGreaterToken(); + var newPrecedence = getBinaryOperatorPrecedence(); + // Check the precedence to see if we should "take" this operator + // - For left associative operator (all operator but **), consume the operator, + // recursively call the function below, and parse binaryExpression as a rightOperand + // of the caller if the new precendence of the operator is greater then or equal to the current precendence. + // For example: + // a - b - c; + // ^token; leftOperand = b. Return b to the caller as a rightOperand + // a * b - c + // ^token; leftOperand = b. Return b to the caller as a rightOperand + // a - b * c; + // ^token; leftOperand = b. Return b * c to the caller as a rightOperand + // - For right associative operator (**), consume the operator, recursively call the function + // and parse binaryExpression as a rightOperand of the caller if the new precendence of + // the operator is strictly grater than the current precendence + // For example: + // a ** b ** c; + // ^^token; leftOperand = b. Return b ** c to the caller as a rightOperand + // a - b ** c; + // ^^token; leftOperand = b. Return b ** c to the caller as a rightOperand + // a ** b - c + // ^token; leftOperand = b. Return b to the caller as a rightOperand + var consumeCurrentOperator = token === 38 /* AsteriskAsteriskToken */ ? + newPrecedence >= precedence : + newPrecedence > precedence; + if (!consumeCurrentOperator) { + break; + } + if (token === 90 /* InKeyword */ && inDisallowInContext()) { + break; + } + if (token === 116 /* AsKeyword */) { + // Make sure we *do* perform ASI for constructs like this: + // var x = foo + // as (Bar) + // This should be parsed as an initialized variable, followed + // by a function call to 'as' with the argument 'Bar' + if (scanner.hasPrecedingLineBreak()) { + break; + } + else { + nextToken(); + leftOperand = makeAsExpression(leftOperand, parseType()); + } + } + else { + leftOperand = makeBinaryExpression(leftOperand, parseTokenNode(), parseBinaryExpressionOrHigher(newPrecedence)); + } + } + return leftOperand; + } + function isBinaryOperator() { + if (inDisallowInContext() && token === 90 /* InKeyword */) { + return false; + } + return getBinaryOperatorPrecedence() > 0; + } + function getBinaryOperatorPrecedence() { + switch (token) { + case 52 /* BarBarToken */: + return 1; + case 51 /* AmpersandAmpersandToken */: + return 2; + case 47 /* BarToken */: + return 3; + case 48 /* CaretToken */: + return 4; + case 46 /* AmpersandToken */: + return 5; + case 30 /* EqualsEqualsToken */: + case 31 /* ExclamationEqualsToken */: + case 32 /* EqualsEqualsEqualsToken */: + case 33 /* ExclamationEqualsEqualsToken */: + return 6; + case 25 /* LessThanToken */: + case 27 /* GreaterThanToken */: + case 28 /* LessThanEqualsToken */: + case 29 /* GreaterThanEqualsToken */: + case 91 /* InstanceOfKeyword */: + case 90 /* InKeyword */: + case 116 /* AsKeyword */: + return 7; + case 43 /* LessThanLessThanToken */: + case 44 /* GreaterThanGreaterThanToken */: + case 45 /* GreaterThanGreaterThanGreaterThanToken */: + return 8; + case 35 /* PlusToken */: + case 36 /* MinusToken */: + return 9; + case 37 /* AsteriskToken */: + case 39 /* SlashToken */: + case 40 /* PercentToken */: + return 10; + case 38 /* AsteriskAsteriskToken */: + return 11; + } + // -1 is lower than all other precedences. Returning it will cause binary expression + // parsing to stop. + return -1; + } + function makeBinaryExpression(left, operatorToken, right) { + var node = createNode(181 /* BinaryExpression */, left.pos); + node.left = left; + node.operatorToken = operatorToken; + node.right = right; + return finishNode(node); + } + function makeAsExpression(left, right) { + var node = createNode(189 /* AsExpression */, left.pos); + node.expression = left; + node.type = right; + return finishNode(node); + } + function parsePrefixUnaryExpression() { + var node = createNode(179 /* PrefixUnaryExpression */); + node.operator = token; + nextToken(); + node.operand = parseSimpleUnaryExpression(); + return finishNode(node); + } + function parseDeleteExpression() { + var node = createNode(175 /* DeleteExpression */); + nextToken(); + node.expression = parseSimpleUnaryExpression(); + return finishNode(node); + } + function parseTypeOfExpression() { + var node = createNode(176 /* TypeOfExpression */); + nextToken(); + node.expression = parseSimpleUnaryExpression(); + return finishNode(node); + } + function parseVoidExpression() { + var node = createNode(177 /* VoidExpression */); + nextToken(); + node.expression = parseSimpleUnaryExpression(); + return finishNode(node); + } + function isAwaitExpression() { + if (token === 119 /* AwaitKeyword */) { + if (inAwaitContext()) { + return true; + } + // here we are using similar heuristics as 'isYieldExpression' + return lookAhead(nextTokenIsIdentifierOnSameLine); + } + return false; + } + function parseAwaitExpression() { + var node = createNode(178 /* AwaitExpression */); + nextToken(); + node.expression = parseSimpleUnaryExpression(); + return finishNode(node); + } + /** + * Parse ES7 unary expression and await expression + * + * ES7 UnaryExpression: + * 1) SimpleUnaryExpression[?yield] + * 2) IncrementExpression[?yield] ** UnaryExpression[?yield] + */ + function parseUnaryExpressionOrHigher() { + if (isAwaitExpression()) { + return parseAwaitExpression(); + } + if (isIncrementExpression()) { + var incrementExpression = parseIncrementExpression(); + return token === 38 /* AsteriskAsteriskToken */ ? + parseBinaryExpressionRest(getBinaryOperatorPrecedence(), incrementExpression) : + incrementExpression; + } + var unaryOperator = token; + var simpleUnaryExpression = parseSimpleUnaryExpression(); + if (token === 38 /* AsteriskAsteriskToken */) { + var diagnostic; + var start = ts.skipTrivia(sourceText, simpleUnaryExpression.pos); + if (simpleUnaryExpression.kind === 171 /* TypeAssertionExpression */) { + parseErrorAtPosition(start, simpleUnaryExpression.end - start, ts.Diagnostics.A_type_assertion_expression_is_not_allowed_in_the_left_hand_side_of_an_exponentiation_expression_Consider_enclosing_the_expression_in_parentheses); + } + else { + parseErrorAtPosition(start, simpleUnaryExpression.end - start, ts.Diagnostics.An_unary_expression_with_the_0_operator_is_not_allowed_in_the_left_hand_side_of_an_exponentiation_expression_Consider_enclosing_the_expression_in_parentheses, ts.tokenToString(unaryOperator)); + } + } + return simpleUnaryExpression; + } + /** + * Parse ES7 simple-unary expression or higher: + * + * ES7 SimpleUnaryExpression: + * 1) IncrementExpression[?yield] + * 2) delete UnaryExpression[?yield] + * 3) void UnaryExpression[?yield] + * 4) typeof UnaryExpression[?yield] + * 5) + UnaryExpression[?yield] + * 6) - UnaryExpression[?yield] + * 7) ~ UnaryExpression[?yield] + * 8) ! UnaryExpression[?yield] + */ + function parseSimpleUnaryExpression() { + switch (token) { + case 35 /* PlusToken */: + case 36 /* MinusToken */: + case 50 /* TildeToken */: + case 49 /* ExclamationToken */: + return parsePrefixUnaryExpression(); + case 78 /* DeleteKeyword */: + return parseDeleteExpression(); + case 101 /* TypeOfKeyword */: + return parseTypeOfExpression(); + case 103 /* VoidKeyword */: + return parseVoidExpression(); + case 25 /* LessThanToken */: + // This is modified UnaryExpression grammar in TypeScript + // UnaryExpression (modified): + // < type > UnaryExpression + return parseTypeAssertion(); + default: + return parseIncrementExpression(); + } + } + /** + * Check if the current token can possibly be an ES7 increment expression. + * + * ES7 IncrementExpression: + * LeftHandSideExpression[?Yield] + * LeftHandSideExpression[?Yield][no LineTerminator here]++ + * LeftHandSideExpression[?Yield][no LineTerminator here]-- + * ++LeftHandSideExpression[?Yield] + * --LeftHandSideExpression[?Yield] + */ + function isIncrementExpression() { + // This function is called inside parseUnaryExpression to decide + // whether to call parseSimpleUnaryExpression or call parseIncrmentExpression directly + switch (token) { + case 35 /* PlusToken */: + case 36 /* MinusToken */: + case 50 /* TildeToken */: + case 49 /* ExclamationToken */: + case 78 /* DeleteKeyword */: + case 101 /* TypeOfKeyword */: + case 103 /* VoidKeyword */: + return false; + case 25 /* LessThanToken */: + // If we are not in JSX context, we are parsing TypeAssertion which is an UnaryExpression + if (sourceFile.languageVariant !== 1 /* JSX */) { + return false; + } + // We are in JSX context and the token is part of JSXElement. + // Fall through + default: + return true; + } + } + /** + * Parse ES7 IncrementExpression. IncrementExpression is used instead of ES6's PostFixExpression. + * + * ES7 IncrementExpression[yield]: + * 1) LeftHandSideExpression[?yield] + * 2) LeftHandSideExpression[?yield] [[no LineTerminator here]]++ + * 3) LeftHandSideExpression[?yield] [[no LineTerminator here]]-- + * 4) ++LeftHandSideExpression[?yield] + * 5) --LeftHandSideExpression[?yield] + * In TypeScript (2), (3) are parsed as PostfixUnaryExpression. (4), (5) are parsed as PrefixUnaryExpression + */ + function parseIncrementExpression() { + if (token === 41 /* PlusPlusToken */ || token === 42 /* MinusMinusToken */) { + var node = createNode(179 /* PrefixUnaryExpression */); + node.operator = token; + nextToken(); + node.operand = parseLeftHandSideExpressionOrHigher(); + return finishNode(node); + } + else if (sourceFile.languageVariant === 1 /* JSX */ && token === 25 /* LessThanToken */ && lookAhead(nextTokenIsIdentifierOrKeyword)) { + // JSXElement is part of primaryExpression + return parseJsxElementOrSelfClosingElement(/*inExpressionContext*/ true); + } + var expression = parseLeftHandSideExpressionOrHigher(); + ts.Debug.assert(ts.isLeftHandSideExpression(expression)); + if ((token === 41 /* PlusPlusToken */ || token === 42 /* MinusMinusToken */) && !scanner.hasPrecedingLineBreak()) { + var node = createNode(180 /* PostfixUnaryExpression */, expression.pos); + node.operand = expression; + node.operator = token; + nextToken(); + return finishNode(node); + } + return expression; + } + function parseLeftHandSideExpressionOrHigher() { + // Original Ecma: + // LeftHandSideExpression: See 11.2 + // NewExpression + // CallExpression + // + // Our simplification: + // + // LeftHandSideExpression: See 11.2 + // MemberExpression + // CallExpression + // + // See comment in parseMemberExpressionOrHigher on how we replaced NewExpression with + // MemberExpression to make our lives easier. + // + // to best understand the below code, it's important to see how CallExpression expands + // out into its own productions: + // + // CallExpression: + // MemberExpression Arguments + // CallExpression Arguments + // CallExpression[Expression] + // CallExpression.IdentifierName + // super ( ArgumentListopt ) + // super.IdentifierName + // + // Because of the recursion in these calls, we need to bottom out first. There are two + // bottom out states we can run into. Either we see 'super' which must start either of + // 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 */ + ? parseSuperExpression() + : parseMemberExpressionOrHigher(); + // Now, we *may* be complete. However, we might have consumed the start of a + // CallExpression. As such, we need to consume the rest of it here to be complete. + return parseCallExpressionRest(expression); + } + function parseMemberExpressionOrHigher() { + // Note: to make our lives simpler, we decompose the the NewExpression productions and + // place ObjectCreationExpression and FunctionExpression into PrimaryExpression. + // like so: + // + // PrimaryExpression : See 11.1 + // this + // Identifier + // Literal + // ArrayLiteral + // ObjectLiteral + // (Expression) + // FunctionExpression + // new MemberExpression Arguments? + // + // MemberExpression : See 11.2 + // PrimaryExpression + // MemberExpression[Expression] + // MemberExpression.IdentifierName + // + // CallExpression : See 11.2 + // MemberExpression + // CallExpression Arguments + // CallExpression[Expression] + // CallExpression.IdentifierName + // + // Technically this is ambiguous. i.e. CallExpression defines: + // + // CallExpression: + // CallExpression Arguments + // + // If you see: "new Foo()" + // + // Then that could be treated as a single ObjectCreationExpression, or it could be + // treated as the invocation of "new Foo". We disambiguate that in code (to match + // the original grammar) by making sure that if we see an ObjectCreationExpression + // we always consume arguments if they are there. So we treat "new Foo()" as an + // object creation only, and not at all as an invocation) Another way to think + // about this is that for every "new" that we see, we will consume an argument list if + // it is there as part of the *associated* object creation node. Any additional + // argument lists we see, will become invocation expressions. + // + // Because there are no other places in the grammar now that refer to FunctionExpression + // or ObjectCreationExpression, it is safe to push down into the PrimaryExpression + // production. + // + // Because CallExpression and MemberExpression are left recursive, we need to bottom out + // of the recursion immediately. So we parse out a primary expression to start with. + var expression = parsePrimaryExpression(); + return parseMemberExpressionRest(expression); + } + function parseSuperExpression() { + var expression = parseTokenNode(); + if (token === 17 /* OpenParenToken */ || token === 21 /* DotToken */ || token === 19 /* 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(166 /* PropertyAccessExpression */, expression.pos); + node.expression = expression; + node.dotToken = parseExpectedToken(21 /* DotToken */, /*reportAtCurrentPosition*/ false, ts.Diagnostics.super_must_be_followed_by_an_argument_list_or_member_access); + node.name = parseRightSideOfDot(/*allowIdentifierNames*/ true); + return finishNode(node); + } + function parseJsxElementOrSelfClosingElement(inExpressionContext) { + var opening = parseJsxOpeningOrSelfClosingElement(inExpressionContext); + var result; + if (opening.kind === 235 /* JsxOpeningElement */) { + var node = createNode(233 /* JsxElement */, opening.pos); + node.openingElement = opening; + node.children = parseJsxChildren(node.openingElement.tagName); + node.closingElement = parseJsxClosingElement(inExpressionContext); + result = finishNode(node); + } + else { + ts.Debug.assert(opening.kind === 234 /* JsxSelfClosingElement */); + // Nothing else to do for self-closing elements + result = opening; + } + // If the user writes the invalid code '
' in an expression context (i.e. not wrapped in + // an enclosing tag), we'll naively try to parse ^ this as a 'less than' operator and the remainder of the tag + // as garbage, which will cause the formatter to badly mangle the JSX. Perform a speculative parse of a JSX + // element if we see a < token so that we can wrap it in a synthetic binary expression so the formatter + // 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 */) { + var invalidElement = tryParse(function () { return parseJsxElementOrSelfClosingElement(/*inExpressionContext*/ true); }); + if (invalidElement) { + parseErrorAtCurrentToken(ts.Diagnostics.JSX_expressions_must_have_one_parent_element); + var badNode = createNode(181 /* BinaryExpression */, result.pos); + badNode.end = invalidElement.end; + badNode.left = result; + badNode.right = invalidElement; + badNode.operatorToken = createMissingNode(24 /* CommaToken */, /*reportAtCurrentPosition*/ false, /*diagnosticMessage*/ undefined); + badNode.operatorToken.pos = badNode.operatorToken.end = badNode.right.pos; + return badNode; + } + } + return result; + } + function parseJsxText() { + var node = createNode(236 /* JsxText */, scanner.getStartPos()); + token = scanner.scanJsxToken(); + return finishNode(node); + } + function parseJsxChild() { + switch (token) { + case 236 /* JsxText */: + return parseJsxText(); + case 15 /* OpenBraceToken */: + return parseJsxExpression(/*inExpressionContext*/ false); + case 25 /* LessThanToken */: + return parseJsxElementOrSelfClosingElement(/*inExpressionContext*/ false); + } + ts.Debug.fail("Unknown JSX child kind " + token); + } + function parseJsxChildren(openingTagName) { + var result = []; + result.pos = scanner.getStartPos(); + var saveParsingContext = parsingContext; + parsingContext |= 1 << 14 /* JsxChildren */; + while (true) { + token = scanner.reScanJsxToken(); + if (token === 26 /* LessThanSlashToken */) { + break; + } + else if (token === 1 /* EndOfFileToken */) { + parseErrorAtCurrentToken(ts.Diagnostics.Expected_corresponding_JSX_closing_tag_for_0, ts.getTextOfNodeFromSourceText(sourceText, openingTagName)); + break; + } + result.push(parseJsxChild()); + } + result.end = scanner.getTokenPos(); + parsingContext = saveParsingContext; + return result; + } + function parseJsxOpeningOrSelfClosingElement(inExpressionContext) { + var fullStart = scanner.getStartPos(); + parseExpected(25 /* LessThanToken */); + var tagName = parseJsxElementName(); + var attributes = parseList(13 /* JsxAttributes */, parseJsxAttribute); + var node; + if (token === 27 /* 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(235 /* JsxOpeningElement */, fullStart); + scanJsxText(); + } + else { + parseExpected(39 /* SlashToken */); + if (inExpressionContext) { + parseExpected(27 /* GreaterThanToken */); + } + else { + parseExpected(27 /* GreaterThanToken */, /*diagnostic*/ undefined, /*advance*/ false); + scanJsxText(); + } + node = createNode(234 /* JsxSelfClosingElement */, fullStart); + } + node.tagName = tagName; + node.attributes = attributes; + return finishNode(node); + } + function parseJsxElementName() { + scanJsxIdentifier(); + var elementName = parseIdentifierName(); + while (parseOptional(21 /* DotToken */)) { + scanJsxIdentifier(); + var node = createNode(135 /* QualifiedName */, elementName.pos); + node.left = elementName; + node.right = parseIdentifierName(); + elementName = finishNode(node); + } + return elementName; + } + function parseJsxExpression(inExpressionContext) { + var node = createNode(240 /* JsxExpression */); + parseExpected(15 /* OpenBraceToken */); + if (token !== 16 /* CloseBraceToken */) { + node.expression = parseExpression(); + } + if (inExpressionContext) { + parseExpected(16 /* CloseBraceToken */); + } + else { + parseExpected(16 /* CloseBraceToken */, /*message*/ undefined, /*advance*/ false); + scanJsxText(); + } + return finishNode(node); + } + function parseJsxAttribute() { + if (token === 15 /* OpenBraceToken */) { + return parseJsxSpreadAttribute(); + } + scanJsxIdentifier(); + var node = createNode(238 /* JsxAttribute */); + node.name = parseIdentifierName(); + if (parseOptional(56 /* EqualsToken */)) { + switch (token) { + case 9 /* StringLiteral */: + node.initializer = parseLiteralNode(); + break; + default: + node.initializer = parseJsxExpression(/*inExpressionContext*/ true); + break; + } + } + return finishNode(node); + } + function parseJsxSpreadAttribute() { + var node = createNode(239 /* JsxSpreadAttribute */); + parseExpected(15 /* OpenBraceToken */); + parseExpected(22 /* DotDotDotToken */); + node.expression = parseExpression(); + parseExpected(16 /* CloseBraceToken */); + return finishNode(node); + } + function parseJsxClosingElement(inExpressionContext) { + var node = createNode(237 /* JsxClosingElement */); + parseExpected(26 /* LessThanSlashToken */); + node.tagName = parseJsxElementName(); + if (inExpressionContext) { + parseExpected(27 /* GreaterThanToken */); + } + else { + parseExpected(27 /* GreaterThanToken */, /*diagnostic*/ undefined, /*advance*/ false); + scanJsxText(); + } + return finishNode(node); + } + function parseTypeAssertion() { + var node = createNode(171 /* TypeAssertionExpression */); + parseExpected(25 /* LessThanToken */); + node.type = parseType(); + parseExpected(27 /* GreaterThanToken */); + node.expression = parseSimpleUnaryExpression(); + return finishNode(node); + } + function parseMemberExpressionRest(expression) { + while (true) { + var dotToken = parseOptionalToken(21 /* DotToken */); + if (dotToken) { + var propertyAccess = createNode(166 /* PropertyAccessExpression */, expression.pos); + propertyAccess.expression = expression; + propertyAccess.dotToken = dotToken; + propertyAccess.name = parseRightSideOfDot(/*allowIdentifierNames*/ true); + expression = finishNode(propertyAccess); + 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(167 /* ElementAccessExpression */, expression.pos); + indexedAccess.expression = expression; + // It's not uncommon for a user to write: "new Type[]". + // Check for that common pattern and report a better error message. + if (token !== 20 /* 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 */); + expression = finishNode(indexedAccess); + continue; + } + if (token === 11 /* NoSubstitutionTemplateLiteral */ || token === 12 /* TemplateHead */) { + var tagExpression = createNode(170 /* TaggedTemplateExpression */, expression.pos); + tagExpression.tag = expression; + tagExpression.template = token === 11 /* NoSubstitutionTemplateLiteral */ + ? parseLiteralNode() + : parseTemplateExpression(); + expression = finishNode(tagExpression); + continue; + } + return expression; + } + } + function parseCallExpressionRest(expression) { + while (true) { + expression = parseMemberExpressionRest(expression); + if (token === 25 /* 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 + // stack. + var typeArguments = tryParse(parseTypeArgumentsInExpression); + if (!typeArguments) { + return expression; + } + var callExpr = createNode(168 /* CallExpression */, expression.pos); + callExpr.expression = expression; + callExpr.typeArguments = typeArguments; + callExpr.arguments = parseArgumentList(); + expression = finishNode(callExpr); + continue; + } + else if (token === 17 /* OpenParenToken */) { + var callExpr = createNode(168 /* CallExpression */, expression.pos); + callExpr.expression = expression; + callExpr.arguments = parseArgumentList(); + expression = finishNode(callExpr); + continue; + } + return expression; + } + } + function parseArgumentList() { + parseExpected(17 /* OpenParenToken */); + var result = parseDelimitedList(11 /* ArgumentExpressions */, parseArgumentExpression); + parseExpected(18 /* CloseParenToken */); + return result; + } + function parseTypeArgumentsInExpression() { + if (!parseOptional(25 /* LessThanToken */)) { + return undefined; + } + var typeArguments = parseDelimitedList(18 /* TypeArguments */, parseType); + if (!parseExpected(27 /* GreaterThanToken */)) { + // If it doesn't have the closing > then it's definitely not an type argument list. + return undefined; + } + // If we have a '<', then only parse this as a arugment list if the type arguments + // are complete and we have an open paren. if we don't, rewind and return nothing. + return typeArguments && canFollowTypeArgumentsInExpression() + ? typeArguments + : undefined; + } + function canFollowTypeArgumentsInExpression() { + switch (token) { + case 17 /* 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 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 { + // 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. + default: + // Anything else treat as an expression. + return false; + } + } + function parsePrimaryExpression() { + switch (token) { + case 8 /* NumericLiteral */: + case 9 /* StringLiteral */: + case 11 /* NoSubstitutionTemplateLiteral */: + return parseLiteralNode(); + case 97 /* ThisKeyword */: + case 95 /* SuperKeyword */: + case 93 /* NullKeyword */: + case 99 /* TrueKeyword */: + case 84 /* FalseKeyword */: + return parseTokenNode(); + case 17 /* OpenParenToken */: + return parseParenthesizedExpression(); + case 19 /* OpenBracketToken */: + return parseArrayLiteralExpression(); + case 15 /* OpenBraceToken */: + return parseObjectLiteralExpression(); + case 118 /* AsyncKeyword */: + // Async arrow functions are parsed earlier in parseAssignmentExpressionOrHigher. + // If we encounter `async [no LineTerminator here] function` then this is an async + // function; otherwise, its an identifier. + if (!lookAhead(nextTokenIsFunctionKeywordOnSameLine)) { + break; + } + return parseFunctionExpression(); + case 73 /* ClassKeyword */: + return parseClassExpression(); + case 87 /* FunctionKeyword */: + return parseFunctionExpression(); + case 92 /* NewKeyword */: + return parseNewExpression(); + case 39 /* SlashToken */: + case 61 /* SlashEqualsToken */: + if (reScanSlashToken() === 10 /* RegularExpressionLiteral */) { + return parseLiteralNode(); + } + break; + case 12 /* TemplateHead */: + return parseTemplateExpression(); + } + return parseIdentifier(ts.Diagnostics.Expression_expected); + } + function parseParenthesizedExpression() { + var node = createNode(172 /* ParenthesizedExpression */); + parseExpected(17 /* OpenParenToken */); + node.expression = allowInAnd(parseExpression); + parseExpected(18 /* CloseParenToken */); + return finishNode(node); + } + function parseSpreadElement() { + var node = createNode(185 /* SpreadElementExpression */); + parseExpected(22 /* DotDotDotToken */); + node.expression = parseAssignmentExpressionOrHigher(); + return finishNode(node); + } + function parseArgumentOrArrayLiteralElement() { + return token === 22 /* DotDotDotToken */ ? parseSpreadElement() : + token === 24 /* CommaToken */ ? createNode(187 /* OmittedExpression */) : + parseAssignmentExpressionOrHigher(); + } + function parseArgumentExpression() { + return doOutsideOfContext(disallowInAndDecoratorContext, parseArgumentOrArrayLiteralElement); + } + function parseArrayLiteralExpression() { + var node = createNode(164 /* ArrayLiteralExpression */); + parseExpected(19 /* OpenBracketToken */); + if (scanner.hasPrecedingLineBreak()) + node.flags |= 2048 /* MultiLine */; + node.elements = parseDelimitedList(15 /* ArrayLiteralMembers */, parseArgumentOrArrayLiteralElement); + parseExpected(20 /* CloseBracketToken */); + return finishNode(node); + } + function tryParseAccessorDeclaration(fullStart, decorators, modifiers) { + if (parseContextualModifier(123 /* GetKeyword */)) { + return parseAccessorDeclaration(145 /* GetAccessor */, fullStart, decorators, modifiers); + } + else if (parseContextualModifier(129 /* SetKeyword */)) { + return parseAccessorDeclaration(146 /* SetAccessor */, fullStart, decorators, modifiers); + } + return undefined; + } + function parseObjectLiteralElement() { + var fullStart = scanner.getStartPos(); + var decorators = parseDecorators(); + var modifiers = parseModifiers(); + var accessor = tryParseAccessorDeclaration(fullStart, decorators, modifiers); + if (accessor) { + return accessor; + } + var asteriskToken = parseOptionalToken(37 /* AsteriskToken */); + var tokenIsIdentifier = isIdentifier(); + var nameToken = token; + 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 */) { + return parseMethodDeclaration(fullStart, decorators, modifiers, asteriskToken, propertyName, questionToken); + } + // check if it is short-hand property assignment or normal property assignment + // NOTE: if token is EqualsToken it is interpreted as CoverInitializedName production + // CoverInitializedName[Yield] : + // IdentifierReference[?Yield] Initializer[In, ?Yield] + // this is necessary because ObjectLiteral productions are also used to cover grammar for ObjectAssignmentPattern + var isShorthandPropertyAssignment = tokenIsIdentifier && (token === 24 /* CommaToken */ || token === 16 /* CloseBraceToken */ || token === 56 /* EqualsToken */); + if (isShorthandPropertyAssignment) { + var shorthandDeclaration = createNode(246 /* ShorthandPropertyAssignment */, fullStart); + shorthandDeclaration.name = propertyName; + shorthandDeclaration.questionToken = questionToken; + var equalsToken = parseOptionalToken(56 /* EqualsToken */); + if (equalsToken) { + shorthandDeclaration.equalsToken = equalsToken; + shorthandDeclaration.objectAssignmentInitializer = allowInAnd(parseAssignmentExpressionOrHigher); + } + return finishNode(shorthandDeclaration); + } + else { + var propertyAssignment = createNode(245 /* PropertyAssignment */, fullStart); + propertyAssignment.name = propertyName; + propertyAssignment.questionToken = questionToken; + parseExpected(54 /* ColonToken */); + propertyAssignment.initializer = allowInAnd(parseAssignmentExpressionOrHigher); + return finishNode(propertyAssignment); + } + } + function parseObjectLiteralExpression() { + var node = createNode(165 /* ObjectLiteralExpression */); + parseExpected(15 /* OpenBraceToken */); + if (scanner.hasPrecedingLineBreak()) { + node.flags |= 2048 /* MultiLine */; + } + node.properties = parseDelimitedList(12 /* ObjectLiteralMembers */, parseObjectLiteralElement, /*considerSemicolonAsDelimeter*/ true); + parseExpected(16 /* CloseBraceToken */); + return finishNode(node); + } + function parseFunctionExpression() { + // GeneratorExpression: + // function* BindingIdentifier [Yield][opt](FormalParameters[Yield]){ GeneratorBody } + // + // FunctionExpression: + // function BindingIdentifier[opt](FormalParameters){ FunctionBody } + var saveDecoratorContext = inDecoratorContext(); + if (saveDecoratorContext) { + setDecoratorContext(false); + } + var node = createNode(173 /* FunctionExpression */); + setModifiers(node, parseModifiers()); + parseExpected(87 /* FunctionKeyword */); + node.asteriskToken = parseOptionalToken(37 /* AsteriskToken */); + var isGenerator = !!node.asteriskToken; + var isAsync = !!(node.flags & 512 /* Async */); + node.name = + isGenerator && isAsync ? doInYieldAndAwaitContext(parseOptionalIdentifier) : + isGenerator ? doInYieldContext(parseOptionalIdentifier) : + isAsync ? doInAwaitContext(parseOptionalIdentifier) : + parseOptionalIdentifier(); + fillSignature(54 /* ColonToken */, /*yieldContext*/ isGenerator, /*awaitContext*/ isAsync, /*requireCompleteParameterList*/ false, node); + node.body = parseFunctionBlock(/*allowYield*/ isGenerator, /*allowAwait*/ isAsync, /*ignoreMissingOpenBrace*/ false); + if (saveDecoratorContext) { + setDecoratorContext(true); + } + return finishNode(node); + } + function parseOptionalIdentifier() { + return isIdentifier() ? parseIdentifier() : undefined; + } + function parseNewExpression() { + var node = createNode(169 /* NewExpression */); + parseExpected(92 /* NewKeyword */); + node.expression = parseMemberExpressionOrHigher(); + node.typeArguments = tryParse(parseTypeArgumentsInExpression); + if (node.typeArguments || token === 17 /* OpenParenToken */) { + node.arguments = parseArgumentList(); + } + return finishNode(node); + } + // STATEMENTS + function parseBlock(ignoreMissingOpenBrace, diagnosticMessage) { + var node = createNode(192 /* Block */); + if (parseExpected(15 /* OpenBraceToken */, diagnosticMessage) || ignoreMissingOpenBrace) { + node.statements = parseList(1 /* BlockStatements */, parseStatement); + parseExpected(16 /* CloseBraceToken */); + } + else { + node.statements = createMissingList(); + } + return finishNode(node); + } + function parseFunctionBlock(allowYield, allowAwait, ignoreMissingOpenBrace, diagnosticMessage) { + var savedYieldContext = inYieldContext(); + setYieldContext(allowYield); + var savedAwaitContext = inAwaitContext(); + setAwaitContext(allowAwait); + // We may be in a [Decorator] context when parsing a function expression or + // arrow function. The body of the function is not in [Decorator] context. + var saveDecoratorContext = inDecoratorContext(); + if (saveDecoratorContext) { + setDecoratorContext(false); + } + var block = parseBlock(ignoreMissingOpenBrace, diagnosticMessage); + if (saveDecoratorContext) { + setDecoratorContext(true); + } + setYieldContext(savedYieldContext); + setAwaitContext(savedAwaitContext); + return block; + } + function parseEmptyStatement() { + var node = createNode(194 /* EmptyStatement */); + parseExpected(23 /* SemicolonToken */); + return finishNode(node); + } + function parseIfStatement() { + var node = createNode(196 /* IfStatement */); + parseExpected(88 /* IfKeyword */); + parseExpected(17 /* OpenParenToken */); + node.expression = allowInAnd(parseExpression); + parseExpected(18 /* CloseParenToken */); + node.thenStatement = parseStatement(); + node.elseStatement = parseOptional(80 /* ElseKeyword */) ? parseStatement() : undefined; + return finishNode(node); + } + function parseDoStatement() { + var node = createNode(197 /* DoStatement */); + parseExpected(79 /* DoKeyword */); + node.statement = parseStatement(); + parseExpected(104 /* WhileKeyword */); + parseExpected(17 /* OpenParenToken */); + node.expression = allowInAnd(parseExpression); + parseExpected(18 /* 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 */); + return finishNode(node); + } + function parseWhileStatement() { + var node = createNode(198 /* WhileStatement */); + parseExpected(104 /* WhileKeyword */); + parseExpected(17 /* OpenParenToken */); + node.expression = allowInAnd(parseExpression); + parseExpected(18 /* CloseParenToken */); + node.statement = parseStatement(); + return finishNode(node); + } + function parseForOrForInOrForOfStatement() { + var pos = getNodePos(); + parseExpected(86 /* ForKeyword */); + parseExpected(17 /* OpenParenToken */); + var initializer = undefined; + if (token !== 23 /* SemicolonToken */) { + if (token === 102 /* VarKeyword */ || token === 108 /* LetKeyword */ || token === 74 /* ConstKeyword */) { + initializer = parseVariableDeclarationList(/*inForStatementInitializer*/ true); + } + else { + initializer = disallowInAnd(parseExpression); + } + } + var forOrForInOrForOfStatement; + if (parseOptional(90 /* InKeyword */)) { + var forInStatement = createNode(200 /* ForInStatement */, pos); + forInStatement.initializer = initializer; + forInStatement.expression = allowInAnd(parseExpression); + parseExpected(18 /* CloseParenToken */); + forOrForInOrForOfStatement = forInStatement; + } + else if (parseOptional(134 /* OfKeyword */)) { + var forOfStatement = createNode(201 /* ForOfStatement */, pos); + forOfStatement.initializer = initializer; + forOfStatement.expression = allowInAnd(parseAssignmentExpressionOrHigher); + parseExpected(18 /* CloseParenToken */); + forOrForInOrForOfStatement = forOfStatement; + } + else { + var forStatement = createNode(199 /* ForStatement */, pos); + forStatement.initializer = initializer; + parseExpected(23 /* SemicolonToken */); + if (token !== 23 /* SemicolonToken */ && token !== 18 /* CloseParenToken */) { + forStatement.condition = allowInAnd(parseExpression); + } + parseExpected(23 /* SemicolonToken */); + if (token !== 18 /* CloseParenToken */) { + forStatement.incrementor = allowInAnd(parseExpression); + } + parseExpected(18 /* CloseParenToken */); + forOrForInOrForOfStatement = forStatement; + } + forOrForInOrForOfStatement.statement = parseStatement(); + return finishNode(forOrForInOrForOfStatement); + } + function parseBreakOrContinueStatement(kind) { + var node = createNode(kind); + parseExpected(kind === 203 /* BreakStatement */ ? 70 /* BreakKeyword */ : 75 /* ContinueKeyword */); + if (!canParseSemicolon()) { + node.label = parseIdentifier(); + } + parseSemicolon(); + return finishNode(node); + } + function parseReturnStatement() { + var node = createNode(204 /* ReturnStatement */); + parseExpected(94 /* ReturnKeyword */); + if (!canParseSemicolon()) { + node.expression = allowInAnd(parseExpression); + } + parseSemicolon(); + return finishNode(node); + } + function parseWithStatement() { + var node = createNode(205 /* WithStatement */); + parseExpected(105 /* WithKeyword */); + parseExpected(17 /* OpenParenToken */); + node.expression = allowInAnd(parseExpression); + parseExpected(18 /* CloseParenToken */); + node.statement = parseStatement(); + return finishNode(node); + } + function parseCaseClause() { + var node = createNode(241 /* CaseClause */); + parseExpected(71 /* CaseKeyword */); + node.expression = allowInAnd(parseExpression); + parseExpected(54 /* ColonToken */); + node.statements = parseList(3 /* SwitchClauseStatements */, parseStatement); + return finishNode(node); + } + function parseDefaultClause() { + var node = createNode(242 /* DefaultClause */); + parseExpected(77 /* DefaultKeyword */); + parseExpected(54 /* ColonToken */); + node.statements = parseList(3 /* SwitchClauseStatements */, parseStatement); + return finishNode(node); + } + function parseCaseOrDefaultClause() { + return token === 71 /* CaseKeyword */ ? parseCaseClause() : parseDefaultClause(); + } + function parseSwitchStatement() { + var node = createNode(206 /* SwitchStatement */); + parseExpected(96 /* SwitchKeyword */); + parseExpected(17 /* OpenParenToken */); + node.expression = allowInAnd(parseExpression); + parseExpected(18 /* CloseParenToken */); + var caseBlock = createNode(220 /* CaseBlock */, scanner.getStartPos()); + parseExpected(15 /* OpenBraceToken */); + caseBlock.clauses = parseList(2 /* SwitchClauses */, parseCaseOrDefaultClause); + parseExpected(16 /* CloseBraceToken */); + node.caseBlock = finishNode(caseBlock); + return finishNode(node); + } + function parseThrowStatement() { + // ThrowStatement[Yield] : + // throw [no LineTerminator here]Expression[In, ?Yield]; + // Because of automatic semicolon insertion, we need to report error if this + // throw could be terminated with a semicolon. Note: we can't call 'parseExpression' + // 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(208 /* ThrowStatement */); + parseExpected(98 /* ThrowKeyword */); + node.expression = scanner.hasPrecedingLineBreak() ? undefined : allowInAnd(parseExpression); + parseSemicolon(); + return finishNode(node); + } + // TODO: Review for error recovery + function parseTryStatement() { + var node = createNode(209 /* TryStatement */); + parseExpected(100 /* TryKeyword */); + node.tryBlock = parseBlock(/*ignoreMissingOpenBrace*/ false); + node.catchClause = token === 72 /* CatchKeyword */ ? parseCatchClause() : undefined; + // If we don't have a catch clause, then we must have a finally clause. Try to parse + // one out no matter what. + if (!node.catchClause || token === 85 /* FinallyKeyword */) { + parseExpected(85 /* FinallyKeyword */); + node.finallyBlock = parseBlock(/*ignoreMissingOpenBrace*/ false); + } + return finishNode(node); + } + function parseCatchClause() { + var result = createNode(244 /* CatchClause */); + parseExpected(72 /* CatchKeyword */); + if (parseExpected(17 /* OpenParenToken */)) { + result.variableDeclaration = parseVariableDeclaration(); + } + parseExpected(18 /* CloseParenToken */); + result.block = parseBlock(/*ignoreMissingOpenBrace*/ false); + return finishNode(result); + } + function parseDebuggerStatement() { + var node = createNode(210 /* DebuggerStatement */); + parseExpected(76 /* DebuggerKeyword */); + parseSemicolon(); + return finishNode(node); + } + function parseExpressionOrLabeledStatement() { + // Avoiding having to do the lookahead for a labeled statement by just trying to parse + // out an expression, seeing if it is identifier and then seeing if it is followed by + // a colon. + var fullStart = scanner.getStartPos(); + var expression = allowInAnd(parseExpression); + if (expression.kind === 69 /* Identifier */ && parseOptional(54 /* ColonToken */)) { + var labeledStatement = createNode(207 /* LabeledStatement */, fullStart); + labeledStatement.label = expression; + labeledStatement.statement = parseStatement(); + return finishNode(labeledStatement); + } + else { + var expressionStatement = createNode(195 /* ExpressionStatement */, fullStart); + expressionStatement.expression = expression; + parseSemicolon(); + return finishNode(expressionStatement); + } + } + function nextTokenIsIdentifierOrKeywordOnSameLine() { + nextToken(); + return ts.tokenIsIdentifierOrKeyword(token) && !scanner.hasPrecedingLineBreak(); + } + function nextTokenIsFunctionKeywordOnSameLine() { + nextToken(); + return token === 87 /* FunctionKeyword */ && !scanner.hasPrecedingLineBreak(); + } + function nextTokenIsIdentifierOrKeywordOrNumberOnSameLine() { + nextToken(); + return (ts.tokenIsIdentifierOrKeyword(token) || token === 8 /* NumericLiteral */) && !scanner.hasPrecedingLineBreak(); + } + function isDeclaration() { + while (true) { + switch (token) { + case 102 /* VarKeyword */: + case 108 /* LetKeyword */: + case 74 /* ConstKeyword */: + case 87 /* FunctionKeyword */: + case 73 /* ClassKeyword */: + case 81 /* EnumKeyword */: + return true; + // 'declare', 'module', 'namespace', 'interface'* and 'type' are all legal JavaScript identifiers; + // however, an identifier cannot be followed by another identifier on the same line. This is what we + // count on to parse out the respective declarations. For instance, we exploit this to say that + // + // namespace n + // + // can be none other than the beginning of a namespace declaration, but need to respect that JavaScript sees + // + // namespace + // n + // + // as the identifier 'namespace' on one line followed by the identifier 'n' on another. + // We need to look one token ahead to see if it permissible to try parsing a declaration. + // + // *Note*: 'interface' is actually a strict mode reserved word. So while + // + // "use strict" + // interface + // I {} + // + // could be legal, it would add complexity for very little gain. + case 107 /* InterfaceKeyword */: + case 132 /* TypeKeyword */: + return nextTokenIsIdentifierOnSameLine(); + case 125 /* ModuleKeyword */: + case 126 /* NamespaceKeyword */: + return nextTokenIsIdentifierOrStringLiteralOnSameLine(); + case 115 /* AbstractKeyword */: + case 118 /* AsyncKeyword */: + case 122 /* DeclareKeyword */: + case 110 /* PrivateKeyword */: + case 111 /* ProtectedKeyword */: + case 112 /* PublicKeyword */: + nextToken(); + // ASI takes effect for this modifier. + if (scanner.hasPrecedingLineBreak()) { + return false; + } + continue; + case 89 /* ImportKeyword */: + nextToken(); + return token === 9 /* StringLiteral */ || token === 37 /* AsteriskToken */ || + token === 15 /* OpenBraceToken */ || ts.tokenIsIdentifierOrKeyword(token); + case 82 /* ExportKeyword */: + nextToken(); + if (token === 56 /* EqualsToken */ || token === 37 /* AsteriskToken */ || + token === 15 /* OpenBraceToken */ || token === 77 /* DefaultKeyword */) { + return true; + } + continue; + case 113 /* StaticKeyword */: + nextToken(); + continue; + default: + return false; + } + } + } + function isStartOfDeclaration() { + return lookAhead(isDeclaration); + } + 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 */: + // '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 */: + return true; + case 74 /* ConstKeyword */: + case 82 /* ExportKeyword */: + case 89 /* ImportKeyword */: + return isStartOfDeclaration(); + case 118 /* AsyncKeyword */: + case 122 /* DeclareKeyword */: + case 107 /* InterfaceKeyword */: + case 125 /* ModuleKeyword */: + case 126 /* NamespaceKeyword */: + case 132 /* TypeKeyword */: + // When these don't start a declaration, they're an identifier in an expression statement + return true; + case 112 /* PublicKeyword */: + case 110 /* PrivateKeyword */: + case 111 /* ProtectedKeyword */: + case 113 /* StaticKeyword */: + // When these don't start a declaration, they may be the start of a class member if an identifier + // immediately follows. Otherwise they're an identifier in an expression statement. + return isStartOfDeclaration() || !lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine); + default: + return isStartOfExpression(); + } + } + function nextTokenIsIdentifierOrStartOfDestructuring() { + nextToken(); + return isIdentifier() || token === 15 /* OpenBraceToken */ || token === 19 /* OpenBracketToken */; + } + function isLetDeclaration() { + // In ES6 'let' always starts a lexical declaration if followed by an identifier or { + // or [. + return lookAhead(nextTokenIsIdentifierOrStartOfDestructuring); + } + function parseStatement() { + switch (token) { + case 23 /* SemicolonToken */: + return parseEmptyStatement(); + case 15 /* OpenBraceToken */: + return parseBlock(/*ignoreMissingOpenBrace*/ false); + case 102 /* VarKeyword */: + return parseVariableStatement(scanner.getStartPos(), /*decorators*/ undefined, /*modifiers*/ undefined); + case 108 /* LetKeyword */: + if (isLetDeclaration()) { + return parseVariableStatement(scanner.getStartPos(), /*decorators*/ undefined, /*modifiers*/ undefined); + } + break; + case 87 /* FunctionKeyword */: + return parseFunctionDeclaration(scanner.getStartPos(), /*decorators*/ undefined, /*modifiers*/ undefined); + case 73 /* ClassKeyword */: + return parseClassDeclaration(scanner.getStartPos(), /*decorators*/ undefined, /*modifiers*/ undefined); + case 88 /* IfKeyword */: + return parseIfStatement(); + case 79 /* DoKeyword */: + return parseDoStatement(); + case 104 /* WhileKeyword */: + return parseWhileStatement(); + case 86 /* ForKeyword */: + return parseForOrForInOrForOfStatement(); + case 75 /* ContinueKeyword */: + return parseBreakOrContinueStatement(202 /* ContinueStatement */); + case 70 /* BreakKeyword */: + return parseBreakOrContinueStatement(203 /* BreakStatement */); + case 94 /* ReturnKeyword */: + return parseReturnStatement(); + case 105 /* WithKeyword */: + return parseWithStatement(); + case 96 /* SwitchKeyword */: + return parseSwitchStatement(); + case 98 /* ThrowKeyword */: + return parseThrowStatement(); + case 100 /* TryKeyword */: + // Include 'catch' and 'finally' for error recovery. + case 72 /* CatchKeyword */: + case 85 /* FinallyKeyword */: + return parseTryStatement(); + case 76 /* DebuggerKeyword */: + return parseDebuggerStatement(); + case 55 /* AtToken */: + return parseDeclaration(); + case 118 /* AsyncKeyword */: + case 107 /* InterfaceKeyword */: + case 132 /* TypeKeyword */: + case 125 /* ModuleKeyword */: + case 126 /* NamespaceKeyword */: + case 122 /* DeclareKeyword */: + case 74 /* ConstKeyword */: + case 81 /* EnumKeyword */: + case 82 /* ExportKeyword */: + case 89 /* ImportKeyword */: + case 110 /* PrivateKeyword */: + case 111 /* ProtectedKeyword */: + case 112 /* PublicKeyword */: + case 115 /* AbstractKeyword */: + case 113 /* StaticKeyword */: + if (isStartOfDeclaration()) { + return parseDeclaration(); + } + break; + } + return parseExpressionOrLabeledStatement(); + } + function parseDeclaration() { + var fullStart = getNodePos(); + var decorators = parseDecorators(); + var modifiers = parseModifiers(); + switch (token) { + case 102 /* VarKeyword */: + case 108 /* LetKeyword */: + case 74 /* ConstKeyword */: + return parseVariableStatement(fullStart, decorators, modifiers); + case 87 /* FunctionKeyword */: + return parseFunctionDeclaration(fullStart, decorators, modifiers); + case 73 /* ClassKeyword */: + return parseClassDeclaration(fullStart, decorators, modifiers); + case 107 /* InterfaceKeyword */: + return parseInterfaceDeclaration(fullStart, decorators, modifiers); + case 132 /* TypeKeyword */: + return parseTypeAliasDeclaration(fullStart, decorators, modifiers); + case 81 /* EnumKeyword */: + return parseEnumDeclaration(fullStart, decorators, modifiers); + case 125 /* ModuleKeyword */: + case 126 /* NamespaceKeyword */: + return parseModuleDeclaration(fullStart, decorators, modifiers); + case 89 /* ImportKeyword */: + return parseImportDeclarationOrImportEqualsDeclaration(fullStart, decorators, modifiers); + case 82 /* ExportKeyword */: + nextToken(); + return token === 77 /* DefaultKeyword */ || token === 56 /* EqualsToken */ ? + parseExportAssignment(fullStart, decorators, modifiers) : + parseExportDeclaration(fullStart, decorators, modifiers); + default: + if (decorators || modifiers) { + // We reached this point because we encountered decorators and/or modifiers and assumed a declaration + // would follow. For recovery and error reporting purposes, return an incomplete declaration. + var node = createMissingNode(231 /* MissingDeclaration */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); + node.pos = fullStart; + node.decorators = decorators; + setModifiers(node, modifiers); + return finishNode(node); + } + } + } + function nextTokenIsIdentifierOrStringLiteralOnSameLine() { + nextToken(); + return !scanner.hasPrecedingLineBreak() && (isIdentifier() || token === 9 /* StringLiteral */); + } + function parseFunctionBlockOrSemicolon(isGenerator, isAsync, diagnosticMessage) { + if (token !== 15 /* OpenBraceToken */ && canParseSemicolon()) { + parseSemicolon(); + return; + } + return parseFunctionBlock(isGenerator, isAsync, /*ignoreMissingOpenBrace*/ false, diagnosticMessage); + } + // DECLARATIONS + function parseArrayBindingElement() { + if (token === 24 /* CommaToken */) { + return createNode(187 /* OmittedExpression */); + } + var node = createNode(163 /* BindingElement */); + node.dotDotDotToken = parseOptionalToken(22 /* DotDotDotToken */); + node.name = parseIdentifierOrPattern(); + node.initializer = parseBindingElementInitializer(/*inParameter*/ false); + return finishNode(node); + } + function parseObjectBindingElement() { + var node = createNode(163 /* BindingElement */); + // TODO(andersh): Handle computed properties + var tokenIsIdentifier = isIdentifier(); + var propertyName = parsePropertyName(); + if (tokenIsIdentifier && token !== 54 /* ColonToken */) { + node.name = propertyName; + } + else { + parseExpected(54 /* ColonToken */); + node.propertyName = propertyName; + node.name = parseIdentifierOrPattern(); + } + node.initializer = parseBindingElementInitializer(/*inParameter*/ false); + return finishNode(node); + } + function parseObjectBindingPattern() { + var node = createNode(161 /* ObjectBindingPattern */); + parseExpected(15 /* OpenBraceToken */); + node.elements = parseDelimitedList(9 /* ObjectBindingElements */, parseObjectBindingElement); + parseExpected(16 /* CloseBraceToken */); + return finishNode(node); + } + function parseArrayBindingPattern() { + var node = createNode(162 /* ArrayBindingPattern */); + parseExpected(19 /* OpenBracketToken */); + node.elements = parseDelimitedList(10 /* ArrayBindingElements */, parseArrayBindingElement); + parseExpected(20 /* CloseBracketToken */); + return finishNode(node); + } + function isIdentifierOrPattern() { + return token === 15 /* OpenBraceToken */ || token === 19 /* OpenBracketToken */ || isIdentifier(); + } + function parseIdentifierOrPattern() { + if (token === 19 /* OpenBracketToken */) { + return parseArrayBindingPattern(); + } + if (token === 15 /* OpenBraceToken */) { + return parseObjectBindingPattern(); + } + return parseIdentifier(); + } + function parseVariableDeclaration() { + var node = createNode(211 /* VariableDeclaration */); + node.name = parseIdentifierOrPattern(); + node.type = parseTypeAnnotation(); + if (!isInOrOfKeyword(token)) { + node.initializer = parseInitializer(/*inParameter*/ false); + } + return finishNode(node); + } + function parseVariableDeclarationList(inForStatementInitializer) { + var node = createNode(212 /* VariableDeclarationList */); + switch (token) { + case 102 /* VarKeyword */: + break; + case 108 /* LetKeyword */: + node.flags |= 16384 /* Let */; + break; + case 74 /* ConstKeyword */: + node.flags |= 32768 /* Const */; + break; + default: + ts.Debug.fail(); + } + nextToken(); + // The user may have written the following: + // + // for (let of X) { } + // + // In this case, we want to parse an empty declaration list, and then parse 'of' + // as a keyword. The reason this is not automatic is that 'of' is a valid identifier. + // 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 === 134 /* OfKeyword */ && lookAhead(canFollowContextualOfKeyword)) { + node.declarations = createMissingList(); + } + else { + var savedDisallowIn = inDisallowInContext(); + setDisallowInContext(inForStatementInitializer); + node.declarations = parseDelimitedList(8 /* VariableDeclarations */, parseVariableDeclaration); + setDisallowInContext(savedDisallowIn); + } + return finishNode(node); + } + function canFollowContextualOfKeyword() { + return nextTokenIsIdentifier() && nextToken() === 18 /* CloseParenToken */; + } + function parseVariableStatement(fullStart, decorators, modifiers) { + var node = createNode(193 /* VariableStatement */, fullStart); + node.decorators = decorators; + setModifiers(node, modifiers); + node.declarationList = parseVariableDeclarationList(/*inForStatementInitializer*/ false); + parseSemicolon(); + return finishNode(node); + } + function parseFunctionDeclaration(fullStart, decorators, modifiers) { + var node = createNode(213 /* FunctionDeclaration */, fullStart); + node.decorators = decorators; + setModifiers(node, modifiers); + parseExpected(87 /* FunctionKeyword */); + node.asteriskToken = parseOptionalToken(37 /* AsteriskToken */); + node.name = node.flags & 1024 /* Default */ ? parseOptionalIdentifier() : parseIdentifier(); + var isGenerator = !!node.asteriskToken; + var isAsync = !!(node.flags & 512 /* Async */); + fillSignature(54 /* ColonToken */, /*yieldContext*/ isGenerator, /*awaitContext*/ isAsync, /*requireCompleteParameterList*/ false, node); + node.body = parseFunctionBlockOrSemicolon(isGenerator, isAsync, ts.Diagnostics.or_expected); + return finishNode(node); + } + function parseConstructorDeclaration(pos, decorators, modifiers) { + var node = createNode(144 /* Constructor */, pos); + node.decorators = decorators; + setModifiers(node, modifiers); + parseExpected(121 /* ConstructorKeyword */); + fillSignature(54 /* ColonToken */, /*yieldContext*/ false, /*awaitContext*/ false, /*requireCompleteParameterList*/ false, node); + node.body = parseFunctionBlockOrSemicolon(/*isGenerator*/ false, /*isAsync*/ false, ts.Diagnostics.or_expected); + return finishNode(node); + } + function parseMethodDeclaration(fullStart, decorators, modifiers, asteriskToken, name, questionToken, diagnosticMessage) { + var method = createNode(143 /* MethodDeclaration */, fullStart); + method.decorators = decorators; + setModifiers(method, modifiers); + method.asteriskToken = asteriskToken; + method.name = name; + method.questionToken = questionToken; + var isGenerator = !!asteriskToken; + var isAsync = !!(method.flags & 512 /* Async */); + fillSignature(54 /* ColonToken */, /*yieldContext*/ isGenerator, /*awaitContext*/ isAsync, /*requireCompleteParameterList*/ false, method); + method.body = parseFunctionBlockOrSemicolon(isGenerator, isAsync, diagnosticMessage); + return finishNode(method); + } + function parsePropertyDeclaration(fullStart, decorators, modifiers, name, questionToken) { + var property = createNode(141 /* PropertyDeclaration */, fullStart); + property.decorators = decorators; + setModifiers(property, modifiers); + property.name = name; + property.questionToken = questionToken; + property.type = parseTypeAnnotation(); + // For instance properties specifically, since they are evaluated inside the constructor, + // we do *not * want to parse yield expressions, so we specifically turn the yield context + // off. The grammar would look something like this: + // + // MemberVariableDeclaration[Yield]: + // AccessibilityModifier_opt PropertyName TypeAnnotation_opt Initialiser_opt[In]; + // AccessibilityModifier_opt static_opt PropertyName TypeAnnotation_opt Initialiser_opt[In, ?Yield]; + // + // The checker may still error in the static case to explicitly disallow the yield expression. + property.initializer = modifiers && modifiers.flags & 128 /* Static */ + ? allowInAnd(parseNonParameterInitializer) + : doOutsideOfContext(2 /* Yield */ | 1 /* DisallowIn */, parseNonParameterInitializer); + parseSemicolon(); + return finishNode(property); + } + function parsePropertyOrMethodDeclaration(fullStart, decorators, modifiers) { + var asteriskToken = parseOptionalToken(37 /* 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 */) { + return parseMethodDeclaration(fullStart, decorators, modifiers, asteriskToken, name, questionToken, ts.Diagnostics.or_expected); + } + else { + return parsePropertyDeclaration(fullStart, decorators, modifiers, name, questionToken); + } + } + function parseNonParameterInitializer() { + return parseInitializer(/*inParameter*/ false); + } + function parseAccessorDeclaration(kind, fullStart, decorators, modifiers) { + var node = createNode(kind, fullStart); + node.decorators = decorators; + setModifiers(node, modifiers); + node.name = parsePropertyName(); + fillSignature(54 /* ColonToken */, /*yieldContext*/ false, /*awaitContext*/ false, /*requireCompleteParameterList*/ false, node); + node.body = parseFunctionBlockOrSemicolon(/*isGenerator*/ false, /*isAsync*/ false); + return finishNode(node); + } + function isClassMemberModifier(idToken) { + switch (idToken) { + case 112 /* PublicKeyword */: + case 110 /* PrivateKeyword */: + case 111 /* ProtectedKeyword */: + case 113 /* StaticKeyword */: + return true; + default: + return false; + } + } + function isClassMemberStart() { + var idToken; + if (token === 55 /* AtToken */) { + return true; + } + // Eat up all modifiers, but hold on to the last one in case it is actually an identifier. + while (ts.isModifier(token)) { + idToken = token; + // If the idToken is a class modifier (protected, private, public, and static), it is + // certain that we are starting to parse class member. This allows better error recovery + // Example: + // public foo() ... // true + // public @dec blah ... // true; we will then report an error later + // export public ... // true; we will then report an error later + if (isClassMemberModifier(idToken)) { + return true; + } + nextToken(); + } + if (token === 37 /* AsteriskToken */) { + return true; + } + // Try to get the first property-like token following all modifiers. + // This can either be an identifier or the 'get' or 'set' keywords. + if (isLiteralPropertyName()) { + idToken = token; + nextToken(); + } + // Index signatures and computed properties are class members; we can parse. + if (token === 19 /* 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 === 129 /* SetKeyword */ || idToken === 123 /* 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 */: + return true; + default: + // Covers + // - Semicolons (declaration termination) + // - Closing braces (end-of-class, must be declaration) + // - End-of-files (not valid, but permitted so that it gets caught later on) + // - Line-breaks (enabling *automatic semicolon insertion*) + return canParseSemicolon(); + } + } + return false; + } + function parseDecorators() { + var decorators; + while (true) { + var decoratorStart = getNodePos(); + if (!parseOptional(55 /* AtToken */)) { + break; + } + if (!decorators) { + decorators = []; + decorators.pos = scanner.getStartPos(); + } + var decorator = createNode(139 /* Decorator */, decoratorStart); + decorator.expression = doInDecoratorContext(parseLeftHandSideExpressionOrHigher); + decorators.push(finishNode(decorator)); + } + if (decorators) { + decorators.end = getNodeEnd(); + } + return decorators; + } + function parseModifiers() { + var flags = 0; + var modifiers; + while (true) { + var modifierStart = scanner.getStartPos(); + var modifierKind = token; + if (!parseAnyContextualModifier()) { + break; + } + if (!modifiers) { + modifiers = []; + modifiers.pos = modifierStart; + } + flags |= ts.modifierToFlag(modifierKind); + modifiers.push(finishNode(createNode(modifierKind, modifierStart))); + } + if (modifiers) { + modifiers.flags = flags; + modifiers.end = scanner.getStartPos(); + } + return modifiers; + } + function parseModifiersForArrowFunction() { + var flags = 0; + var modifiers; + if (token === 118 /* AsyncKeyword */) { + var modifierStart = scanner.getStartPos(); + var modifierKind = token; + nextToken(); + modifiers = []; + modifiers.pos = modifierStart; + flags |= ts.modifierToFlag(modifierKind); + modifiers.push(finishNode(createNode(modifierKind, modifierStart))); + modifiers.flags = flags; + modifiers.end = scanner.getStartPos(); + } + return modifiers; + } + function parseClassElement() { + if (token === 23 /* SemicolonToken */) { + var result = createNode(191 /* SemicolonClassElement */); + nextToken(); + return finishNode(result); + } + var fullStart = getNodePos(); + var decorators = parseDecorators(); + var modifiers = parseModifiers(); + var accessor = tryParseAccessorDeclaration(fullStart, decorators, modifiers); + if (accessor) { + return accessor; + } + if (token === 121 /* ConstructorKeyword */) { + return parseConstructorDeclaration(fullStart, decorators, modifiers); + } + if (isIndexSignature()) { + return parseIndexSignatureDeclaration(fullStart, decorators, modifiers); + } + // It is very important that we check this *after* checking indexers because + // the [ token can start an index signature or a computed property name + if (ts.tokenIsIdentifierOrKeyword(token) || + token === 9 /* StringLiteral */ || + token === 8 /* NumericLiteral */ || + token === 37 /* AsteriskToken */ || + token === 19 /* OpenBracketToken */) { + return parsePropertyOrMethodDeclaration(fullStart, decorators, modifiers); + } + if (decorators || modifiers) { + // treat this as a property declaration with a missing name. + var name_7 = createMissingNode(69 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); + return parsePropertyDeclaration(fullStart, decorators, modifiers, name_7, /*questionToken*/ undefined); + } + // 'isClassMemberStart' should have hinted not to attempt parsing. + ts.Debug.fail("Should not have attempted to parse class member declaration."); + } + function parseClassExpression() { + return parseClassDeclarationOrExpression( + /*fullStart*/ scanner.getStartPos(), + /*decorators*/ undefined, + /*modifiers*/ undefined, 186 /* ClassExpression */); + } + function parseClassDeclaration(fullStart, decorators, modifiers) { + return parseClassDeclarationOrExpression(fullStart, decorators, modifiers, 214 /* ClassDeclaration */); + } + function parseClassDeclarationOrExpression(fullStart, decorators, modifiers, kind) { + var node = createNode(kind, fullStart); + node.decorators = decorators; + setModifiers(node, modifiers); + parseExpected(73 /* ClassKeyword */); + node.name = parseNameOfClassDeclarationOrExpression(); + node.typeParameters = parseTypeParameters(); + node.heritageClauses = parseHeritageClauses(/*isClassHeritageClause*/ true); + if (parseExpected(15 /* OpenBraceToken */)) { + // ClassTail[Yield,Await] : (Modified) See 14.5 + // ClassHeritage[?Yield,?Await]opt { ClassBody[?Yield,?Await]opt } + node.members = parseClassMembers(); + parseExpected(16 /* CloseBraceToken */); + } + else { + node.members = createMissingList(); + } + return finishNode(node); + } + function parseNameOfClassDeclarationOrExpression() { + // implements is a future reserved word so + // 'class implements' might mean either + // - class expression with omitted name, 'implements' starts heritage clause + // - class with name 'implements' + // 'isImplementsClause' helps to disambiguate between these two cases + return isIdentifier() && !isImplementsClause() + ? parseIdentifier() + : undefined; + } + function isImplementsClause() { + return token === 106 /* ImplementsKeyword */ && lookAhead(nextTokenIsIdentifierOrKeyword); + } + function parseHeritageClauses(isClassHeritageClause) { + // ClassTail[Yield,Await] : (Modified) See 14.5 + // ClassHeritage[?Yield,?Await]opt { ClassBody[?Yield,?Await]opt } + if (isHeritageClause()) { + return parseList(20 /* HeritageClauses */, parseHeritageClause); + } + return undefined; + } + function parseHeritageClausesWorker() { + return parseList(20 /* HeritageClauses */, parseHeritageClause); + } + function parseHeritageClause() { + if (token === 83 /* ExtendsKeyword */ || token === 106 /* ImplementsKeyword */) { + var node = createNode(243 /* HeritageClause */); + node.token = token; + nextToken(); + node.types = parseDelimitedList(7 /* HeritageClauseElement */, parseExpressionWithTypeArguments); + return finishNode(node); + } + return undefined; + } + function parseExpressionWithTypeArguments() { + var node = createNode(188 /* ExpressionWithTypeArguments */); + node.expression = parseLeftHandSideExpressionOrHigher(); + if (token === 25 /* LessThanToken */) { + node.typeArguments = parseBracketedList(18 /* TypeArguments */, parseType, 25 /* LessThanToken */, 27 /* GreaterThanToken */); + } + return finishNode(node); + } + function isHeritageClause() { + return token === 83 /* ExtendsKeyword */ || token === 106 /* ImplementsKeyword */; + } + function parseClassMembers() { + return parseList(5 /* ClassMembers */, parseClassElement); + } + function parseInterfaceDeclaration(fullStart, decorators, modifiers) { + var node = createNode(215 /* InterfaceDeclaration */, fullStart); + node.decorators = decorators; + setModifiers(node, modifiers); + parseExpected(107 /* InterfaceKeyword */); + node.name = parseIdentifier(); + node.typeParameters = parseTypeParameters(); + node.heritageClauses = parseHeritageClauses(/*isClassHeritageClause*/ false); + node.members = parseObjectTypeMembers(); + return finishNode(node); + } + function parseTypeAliasDeclaration(fullStart, decorators, modifiers) { + var node = createNode(216 /* TypeAliasDeclaration */, fullStart); + node.decorators = decorators; + setModifiers(node, modifiers); + parseExpected(132 /* TypeKeyword */); + node.name = parseIdentifier(); + node.typeParameters = parseTypeParameters(); + parseExpected(56 /* EqualsToken */); + node.type = parseType(); + parseSemicolon(); + return 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 + // ConstantEnumMemberSection, which starts at the beginning of an enum declaration + // or any time an integer literal initializer is encountered. + function parseEnumMember() { + var node = createNode(247 /* EnumMember */, scanner.getStartPos()); + node.name = parsePropertyName(); + node.initializer = allowInAnd(parseNonParameterInitializer); + return finishNode(node); + } + function parseEnumDeclaration(fullStart, decorators, modifiers) { + var node = createNode(217 /* EnumDeclaration */, fullStart); + node.decorators = decorators; + setModifiers(node, modifiers); + parseExpected(81 /* EnumKeyword */); + node.name = parseIdentifier(); + if (parseExpected(15 /* OpenBraceToken */)) { + node.members = parseDelimitedList(6 /* EnumMembers */, parseEnumMember); + parseExpected(16 /* CloseBraceToken */); + } + else { + node.members = createMissingList(); + } + return finishNode(node); + } + function parseModuleBlock() { + var node = createNode(219 /* ModuleBlock */, scanner.getStartPos()); + if (parseExpected(15 /* OpenBraceToken */)) { + node.statements = parseList(1 /* BlockStatements */, parseStatement); + parseExpected(16 /* CloseBraceToken */); + } + else { + node.statements = createMissingList(); + } + return finishNode(node); + } + function parseModuleOrNamespaceDeclaration(fullStart, decorators, modifiers, flags) { + var node = createNode(218 /* ModuleDeclaration */, fullStart); + // If we are parsing a dotted namespace name, we want to + // propagate the 'Namespace' flag across the names if set. + var namespaceFlag = flags & 131072 /* Namespace */; + node.decorators = decorators; + setModifiers(node, modifiers); + node.flags |= flags; + node.name = parseIdentifier(); + node.body = parseOptional(21 /* DotToken */) + ? parseModuleOrNamespaceDeclaration(getNodePos(), /*decorators*/ undefined, /*modifiers*/ undefined, 1 /* Export */ | namespaceFlag) + : parseModuleBlock(); + return finishNode(node); + } + function parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers) { + var node = createNode(218 /* ModuleDeclaration */, fullStart); + node.decorators = decorators; + setModifiers(node, modifiers); + node.name = parseLiteralNode(/*internName*/ true); + node.body = parseModuleBlock(); + return finishNode(node); + } + function parseModuleDeclaration(fullStart, decorators, modifiers) { + var flags = modifiers ? modifiers.flags : 0; + if (parseOptional(126 /* NamespaceKeyword */)) { + flags |= 131072 /* Namespace */; + } + else { + parseExpected(125 /* ModuleKeyword */); + if (token === 9 /* StringLiteral */) { + return parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers); + } + } + return parseModuleOrNamespaceDeclaration(fullStart, decorators, modifiers, flags); + } + function isExternalModuleReference() { + return token === 127 /* RequireKeyword */ && + lookAhead(nextTokenIsOpenParen); + } + function nextTokenIsOpenParen() { + return nextToken() === 17 /* OpenParenToken */; + } + function nextTokenIsSlash() { + return nextToken() === 39 /* SlashToken */; + } + function nextTokenIsCommaOrFromKeyword() { + nextToken(); + return token === 24 /* CommaToken */ || + token === 133 /* FromKeyword */; + } + function parseImportDeclarationOrImportEqualsDeclaration(fullStart, decorators, modifiers) { + parseExpected(89 /* ImportKeyword */); + var afterImportPos = scanner.getStartPos(); + var identifier; + if (isIdentifier()) { + identifier = parseIdentifier(); + if (token !== 24 /* CommaToken */ && token !== 133 /* FromKeyword */) { + // ImportEquals declaration of type: + // import x = require("mod"); or + // import x = M.x; + var importEqualsDeclaration = createNode(221 /* ImportEqualsDeclaration */, fullStart); + importEqualsDeclaration.decorators = decorators; + setModifiers(importEqualsDeclaration, modifiers); + importEqualsDeclaration.name = identifier; + parseExpected(56 /* EqualsToken */); + importEqualsDeclaration.moduleReference = parseModuleReference(); + parseSemicolon(); + return finishNode(importEqualsDeclaration); + } + } + // Import statement + var importDeclaration = createNode(222 /* ImportDeclaration */, fullStart); + importDeclaration.decorators = decorators; + setModifiers(importDeclaration, modifiers); + // ImportDeclaration: + // import ImportClause from ModuleSpecifier ; + // import ModuleSpecifier; + if (identifier || + token === 37 /* AsteriskToken */ || + token === 15 /* OpenBraceToken */) { + importDeclaration.importClause = parseImportClause(identifier, afterImportPos); + parseExpected(133 /* FromKeyword */); + } + importDeclaration.moduleSpecifier = parseModuleSpecifier(); + parseSemicolon(); + return finishNode(importDeclaration); + } + function parseImportClause(identifier, fullStart) { + // ImportClause: + // ImportedDefaultBinding + // NameSpaceImport + // NamedImports + // ImportedDefaultBinding, NameSpaceImport + // ImportedDefaultBinding, NamedImports + var importClause = createNode(223 /* ImportClause */, fullStart); + if (identifier) { + // ImportedDefaultBinding: + // ImportedBinding + importClause.name = identifier; + } + // 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(225 /* NamedImports */); + } + return finishNode(importClause); + } + function parseModuleReference() { + return isExternalModuleReference() + ? parseExternalModuleReference() + : parseEntityName(/*allowReservedWords*/ false); + } + function parseExternalModuleReference() { + var node = createNode(232 /* ExternalModuleReference */); + parseExpected(127 /* RequireKeyword */); + parseExpected(17 /* OpenParenToken */); + node.expression = parseModuleSpecifier(); + parseExpected(18 /* CloseParenToken */); + return finishNode(node); + } + function parseModuleSpecifier() { + // We allow arbitrary expressions here, even though the grammar only allows string + // literals. We check to ensure that it is only a string literal later in the grammar + // walker. + var result = parseExpression(); + // Ensure the string being required is in our 'identifier' table. This will ensure + // that features like 'find refs' will look inside this file when search for its name. + if (result.kind === 9 /* StringLiteral */) { + internIdentifier(result.text); + } + return result; + } + function parseNamespaceImport() { + // NameSpaceImport: + // * as ImportedBinding + var namespaceImport = createNode(224 /* NamespaceImport */); + parseExpected(37 /* AsteriskToken */); + parseExpected(116 /* AsKeyword */); + namespaceImport.name = parseIdentifier(); + return finishNode(namespaceImport); + } + function parseNamedImportsOrExports(kind) { + var node = createNode(kind); + // NamedImports: + // { } + // { ImportsList } + // { ImportsList, } + // ImportsList: + // ImportSpecifier + // ImportsList, ImportSpecifier + node.elements = parseBracketedList(21 /* ImportOrExportSpecifiers */, kind === 225 /* NamedImports */ ? parseImportSpecifier : parseExportSpecifier, 15 /* OpenBraceToken */, 16 /* CloseBraceToken */); + return finishNode(node); + } + function parseExportSpecifier() { + return parseImportOrExportSpecifier(230 /* ExportSpecifier */); + } + function parseImportSpecifier() { + return parseImportOrExportSpecifier(226 /* ImportSpecifier */); + } + function parseImportOrExportSpecifier(kind) { + var node = createNode(kind); + // ImportSpecifier: + // BindingIdentifier + // IdentifierName as BindingIdentifier + // ExportSpecififer: + // IdentifierName + // IdentifierName as IdentifierName + var checkIdentifierIsKeyword = ts.isKeyword(token) && !isIdentifier(); + var checkIdentifierStart = scanner.getTokenPos(); + var checkIdentifierEnd = scanner.getTextPos(); + var identifierName = parseIdentifierName(); + if (token === 116 /* AsKeyword */) { + node.propertyName = identifierName; + parseExpected(116 /* AsKeyword */); + checkIdentifierIsKeyword = ts.isKeyword(token) && !isIdentifier(); + checkIdentifierStart = scanner.getTokenPos(); + checkIdentifierEnd = scanner.getTextPos(); + node.name = parseIdentifierName(); + } + else { + node.name = identifierName; + } + if (kind === 226 /* ImportSpecifier */ && checkIdentifierIsKeyword) { + // Report error identifier expected + parseErrorAtPosition(checkIdentifierStart, checkIdentifierEnd - checkIdentifierStart, ts.Diagnostics.Identifier_expected); + } + return finishNode(node); + } + function parseExportDeclaration(fullStart, decorators, modifiers) { + var node = createNode(228 /* ExportDeclaration */, fullStart); + node.decorators = decorators; + setModifiers(node, modifiers); + if (parseOptional(37 /* AsteriskToken */)) { + parseExpected(133 /* FromKeyword */); + node.moduleSpecifier = parseModuleSpecifier(); + } + else { + node.exportClause = parseNamedImportsOrExports(229 /* NamedExports */); + // It is not uncommon to accidentally omit the 'from' keyword. Additionally, in editing scenarios, + // the 'from' keyword can be parsed as a named export when the export clause is unterminated (i.e. `export { from "moduleName";`) + // If we don't have a 'from' keyword, see if we have a string literal such that ASI won't take effect. + if (token === 133 /* FromKeyword */ || (token === 9 /* StringLiteral */ && !scanner.hasPrecedingLineBreak())) { + parseExpected(133 /* FromKeyword */); + node.moduleSpecifier = parseModuleSpecifier(); + } + } + parseSemicolon(); + return finishNode(node); + } + function parseExportAssignment(fullStart, decorators, modifiers) { + var node = createNode(227 /* ExportAssignment */, fullStart); + node.decorators = decorators; + setModifiers(node, modifiers); + if (parseOptional(56 /* EqualsToken */)) { + node.isExportEquals = true; + } + else { + parseExpected(77 /* DefaultKeyword */); + } + node.expression = parseAssignmentExpressionOrHigher(); + parseSemicolon(); + return finishNode(node); + } + function processReferenceComments(sourceFile) { + var triviaScanner = ts.createScanner(sourceFile.languageVersion, /*skipTrivia*/ false, 0 /* Standard */, sourceText); + var referencedFiles = []; + var amdDependencies = []; + var amdModuleName; + // Keep scanning all the leading trivia in the file until we get to something that + // isn't trivia. Any single line comment will be analyzed to see if it is a + // reference comment. + while (true) { + var kind = triviaScanner.scan(); + if (kind === 5 /* WhitespaceTrivia */ || kind === 4 /* NewLineTrivia */ || kind === 3 /* MultiLineCommentTrivia */) { + continue; + } + if (kind !== 2 /* SingleLineCommentTrivia */) { + break; + } + var range = { pos: triviaScanner.getTokenPos(), end: triviaScanner.getTextPos(), kind: triviaScanner.getToken() }; + var comment = sourceText.substring(range.pos, range.end); + var referencePathMatchResult = ts.getFileReferenceFromReferencePath(comment, range); + if (referencePathMatchResult) { + var fileReference = referencePathMatchResult.fileReference; + sourceFile.hasNoDefaultLib = referencePathMatchResult.isNoDefaultLib; + var diagnosticMessage = referencePathMatchResult.diagnosticMessage; + if (fileReference) { + referencedFiles.push(fileReference); + } + if (diagnosticMessage) { + parseDiagnostics.push(ts.createFileDiagnostic(sourceFile, range.pos, range.end - range.pos, diagnosticMessage)); + } + } + else { + var amdModuleNameRegEx = /^\/\/\/\s*".length; + return parseErrorAtPosition(start, end - start, ts.Diagnostics.Type_argument_list_cannot_be_empty); + } + } + function parseQualifiedName(left) { + var result = createNode(135 /* QualifiedName */, left.pos); + result.left = left; + result.right = parseIdentifierName(); + return finishNode(result); + } + function parseJSDocRecordType() { + var result = createNode(257 /* JSDocRecordType */); + nextToken(); + result.members = parseDelimitedList(24 /* JSDocRecordMembers */, parseJSDocRecordMember); + checkForTrailingComma(result.members); + parseExpected(16 /* CloseBraceToken */); + return finishNode(result); + } + function parseJSDocRecordMember() { + var result = createNode(258 /* JSDocRecordMember */); + result.name = parseSimplePropertyName(); + if (token === 54 /* ColonToken */) { + nextToken(); + result.type = parseJSDocType(); + } + return finishNode(result); + } + function parseJSDocNonNullableType() { + var result = createNode(256 /* JSDocNonNullableType */); + nextToken(); + result.type = parseJSDocType(); + return finishNode(result); + } + function parseJSDocTupleType() { + var result = createNode(254 /* JSDocTupleType */); + nextToken(); + result.types = parseDelimitedList(25 /* JSDocTupleTypes */, parseJSDocType); + checkForTrailingComma(result.types); + parseExpected(20 /* CloseBracketToken */); + return finishNode(result); + } + function checkForTrailingComma(list) { + if (parseDiagnostics.length === 0 && list.hasTrailingComma) { + var start = list.end - ",".length; + parseErrorAtPosition(start, ",".length, ts.Diagnostics.Trailing_comma_not_allowed); + } + } + function parseJSDocUnionType() { + var result = createNode(253 /* JSDocUnionType */); + nextToken(); + result.types = parseJSDocTypeList(parseJSDocType()); + parseExpected(18 /* CloseParenToken */); + return finishNode(result); + } + function parseJSDocTypeList(firstType) { + ts.Debug.assert(!!firstType); + var types = []; + types.pos = firstType.pos; + types.push(firstType); + while (parseOptional(47 /* BarToken */)) { + types.push(parseJSDocType()); + } + types.end = scanner.getStartPos(); + return types; + } + function parseJSDocAllType() { + var result = createNode(250 /* JSDocAllType */); + nextToken(); + return finishNode(result); + } + function parseJSDocUnknownOrNullableType() { + var pos = scanner.getStartPos(); + // skip the ? + nextToken(); + // Need to lookahead to decide if this is a nullable or unknown type. + // Here are cases where we'll pick the unknown type: + // + // Foo(?, + // { a: ? } + // Foo(?) + // Foo + // Foo(?= + // (?| + if (token === 24 /* CommaToken */ || + token === 16 /* CloseBraceToken */ || + token === 18 /* CloseParenToken */ || + token === 27 /* GreaterThanToken */ || + token === 56 /* EqualsToken */ || + token === 47 /* BarToken */) { + var result = createNode(251 /* JSDocUnknownType */, pos); + return finishNode(result); + } + else { + var result = createNode(255 /* JSDocNullableType */, pos); + result.type = parseJSDocType(); + return finishNode(result); + } + } + function parseIsolatedJSDocComment(content, start, length) { + initializeState("file.js", content, 2 /* Latest */, /*_syntaxCursor:*/ undefined); + var jsDocComment = parseJSDocComment(/*parent:*/ undefined, start, length); + var diagnostics = parseDiagnostics; + clearState(); + return jsDocComment ? { jsDocComment: jsDocComment, diagnostics: diagnostics } : undefined; + } + JSDocParser.parseIsolatedJSDocComment = parseIsolatedJSDocComment; + function parseJSDocComment(parent, start, length) { + var comment = parseJSDocCommentWorker(start, length); + if (comment) { + fixupParentReferences(comment); + comment.parent = parent; + } + return comment; + } + JSDocParser.parseJSDocComment = parseJSDocComment; + function parseJSDocCommentWorker(start, length) { + var content = sourceText; + start = start || 0; + var end = length === undefined ? content.length : start + length; + length = end - start; + ts.Debug.assert(start >= 0); + ts.Debug.assert(start <= end); + ts.Debug.assert(end <= content.length); + var tags; + var pos; + // NOTE(cyrusn): This is essentially a handwritten scanner for JSDocComments. I + // considered using an actual Scanner, but this would complicate things. The + // scanner would need to know it was in a Doc Comment. Otherwise, it would then + // produce comments *inside* the doc comment. In the end it was just easier to + // write a simple scanner rather than go that route. + if (length >= "/** */".length) { + if (content.charCodeAt(start) === 47 /* slash */ && + content.charCodeAt(start + 1) === 42 /* asterisk */ && + content.charCodeAt(start + 2) === 42 /* asterisk */ && + content.charCodeAt(start + 3) !== 42 /* asterisk */) { + // Initially we can parse out a tag. We also have seen a starting asterisk. + // This is so that /** * @type */ doesn't parse. + var canParseTag = true; + var seenAsterisk = true; + for (pos = start + "/**".length; pos < end;) { + var ch = content.charCodeAt(pos); + pos++; + if (ch === 64 /* at */ && canParseTag) { + parseTag(); + // Once we parse out a tag, we cannot keep parsing out tags on this line. + canParseTag = false; + continue; + } + if (ts.isLineBreak(ch)) { + // After a line break, we can parse a tag, and we haven't seen as asterisk + // on the next line yet. + canParseTag = true; + seenAsterisk = false; + continue; + } + if (ts.isWhiteSpace(ch)) { + // Whitespace doesn't affect any of our parsing. + continue; + } + // Ignore the first asterisk on a line. + if (ch === 42 /* asterisk */) { + if (seenAsterisk) { + // If we've already seen an asterisk, then we can no longer parse a tag + // on this line. + canParseTag = false; + } + seenAsterisk = true; + continue; + } + // Anything else is doc comment text. We can't do anything with it. Because it + // wasn't a tag, we can no longer parse a tag on this line until we hit the next + // line break. + canParseTag = false; + } + } + } + return createJSDocComment(); + function createJSDocComment() { + if (!tags) { + return undefined; + } + var result = createNode(265 /* JSDocComment */, start); + result.tags = tags; + return finishNode(result, end); + } + function skipWhitespace() { + while (pos < end && ts.isWhiteSpace(content.charCodeAt(pos))) { + pos++; + } + } + function parseTag() { + ts.Debug.assert(content.charCodeAt(pos - 1) === 64 /* at */); + var atToken = createNode(55 /* AtToken */, pos - 1); + atToken.end = pos; + var tagName = scanIdentifier(); + if (!tagName) { + return; + } + var tag = handleTag(atToken, tagName) || handleUnknownTag(atToken, tagName); + addTag(tag); + } + function handleTag(atToken, tagName) { + if (tagName) { + switch (tagName.text) { + case "param": + return handleParamTag(atToken, tagName); + case "return": + case "returns": + return handleReturnTag(atToken, tagName); + case "template": + return handleTemplateTag(atToken, tagName); + case "type": + return handleTypeTag(atToken, tagName); + } + } + return undefined; + } + function handleUnknownTag(atToken, tagName) { + var result = createNode(266 /* JSDocTag */, atToken.pos); + result.atToken = atToken; + result.tagName = tagName; + return finishNode(result, pos); + } + function addTag(tag) { + if (tag) { + if (!tags) { + tags = []; + tags.pos = tag.pos; + } + tags.push(tag); + tags.end = tag.end; + } + } + function tryParseTypeExpression() { + skipWhitespace(); + if (content.charCodeAt(pos) !== 123 /* openBrace */) { + return undefined; + } + var typeExpression = parseJSDocTypeExpression(pos, end - pos); + pos = typeExpression.end; + return typeExpression; + } + function handleParamTag(atToken, tagName) { + var typeExpression = tryParseTypeExpression(); + skipWhitespace(); + var name; + var isBracketed; + if (content.charCodeAt(pos) === 91 /* openBracket */) { + pos++; + skipWhitespace(); + name = scanIdentifier(); + isBracketed = true; + } + else { + name = scanIdentifier(); + } + if (!name) { + parseErrorAtPosition(pos, 0, ts.Diagnostics.Identifier_expected); + } + var preName, postName; + if (typeExpression) { + postName = name; + } + else { + preName = name; + } + if (!typeExpression) { + typeExpression = tryParseTypeExpression(); + } + var result = createNode(267 /* JSDocParameterTag */, atToken.pos); + result.atToken = atToken; + result.tagName = tagName; + result.preParameterName = preName; + result.typeExpression = typeExpression; + result.postParameterName = postName; + result.isBracketed = isBracketed; + return finishNode(result, pos); + } + function handleReturnTag(atToken, tagName) { + if (ts.forEach(tags, function (t) { return t.kind === 268 /* JSDocReturnTag */; })) { + parseErrorAtPosition(tagName.pos, pos - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); + } + var result = createNode(268 /* JSDocReturnTag */, atToken.pos); + result.atToken = atToken; + result.tagName = tagName; + result.typeExpression = tryParseTypeExpression(); + return finishNode(result, pos); + } + function handleTypeTag(atToken, tagName) { + if (ts.forEach(tags, function (t) { return t.kind === 269 /* JSDocTypeTag */; })) { + parseErrorAtPosition(tagName.pos, pos - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); + } + var result = createNode(269 /* JSDocTypeTag */, atToken.pos); + result.atToken = atToken; + result.tagName = tagName; + result.typeExpression = tryParseTypeExpression(); + return finishNode(result, pos); + } + function handleTemplateTag(atToken, tagName) { + if (ts.forEach(tags, function (t) { return t.kind === 270 /* JSDocTemplateTag */; })) { + parseErrorAtPosition(tagName.pos, pos - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); + } + var typeParameters = []; + typeParameters.pos = pos; + while (true) { + skipWhitespace(); + var startPos = pos; + var name_8 = scanIdentifier(); + if (!name_8) { + parseErrorAtPosition(startPos, 0, ts.Diagnostics.Identifier_expected); + return undefined; + } + var typeParameter = createNode(137 /* TypeParameter */, name_8.pos); + typeParameter.name = name_8; + finishNode(typeParameter, pos); + typeParameters.push(typeParameter); + skipWhitespace(); + if (content.charCodeAt(pos) !== 44 /* comma */) { + break; + } + pos++; + } + typeParameters.end = pos; + var result = createNode(270 /* JSDocTemplateTag */, atToken.pos); + result.atToken = atToken; + result.tagName = tagName; + result.typeParameters = typeParameters; + return finishNode(result, pos); + } + function scanIdentifier() { + var startPos = pos; + for (; pos < end; pos++) { + var ch = content.charCodeAt(pos); + if (pos === startPos && ts.isIdentifierStart(ch, 2 /* Latest */)) { + continue; + } + else if (pos > startPos && ts.isIdentifierPart(ch, 2 /* Latest */)) { + continue; + } + break; + } + if (startPos === pos) { + return undefined; + } + var result = createNode(69 /* Identifier */, startPos); + result.text = content.substring(startPos, pos); + return finishNode(result, pos); + } + } + JSDocParser.parseJSDocCommentWorker = parseJSDocCommentWorker; + })(JSDocParser = Parser.JSDocParser || (Parser.JSDocParser = {})); + })(Parser || (Parser = {})); + var IncrementalParser; + (function (IncrementalParser) { + function updateSourceFile(sourceFile, newText, textChangeRange, aggressiveChecks) { + aggressiveChecks = aggressiveChecks || ts.Debug.shouldAssert(2 /* Aggressive */); + checkChangeRange(sourceFile, newText, textChangeRange, aggressiveChecks); + if (ts.textChangeRangeIsUnchanged(textChangeRange)) { + // if the text didn't change, then we can just return our current source file as-is. + return sourceFile; + } + if (sourceFile.statements.length === 0) { + // If we don't have any statements in the current source file, then there's no real + // way to incrementally parse. So just do a full parse instead. + return Parser.parseSourceFile(sourceFile.fileName, newText, sourceFile.languageVersion, /*syntaxCursor*/ undefined, /*setNodeParents*/ true); + } + // Make sure we're not trying to incrementally update a source file more than once. Once + // we do an update the original source file is considered unusbale from that point onwards. + // + // This is because we do incremental parsing in-place. i.e. we take nodes from the old + // tree and give them new positions and parents. From that point on, trusting the old + // tree at all is not possible as far too much of it may violate invariants. + var incrementalSourceFile = sourceFile; + ts.Debug.assert(!incrementalSourceFile.hasBeenIncrementallyParsed); + incrementalSourceFile.hasBeenIncrementallyParsed = true; + var oldText = sourceFile.text; + var syntaxCursor = createSyntaxCursor(sourceFile); + // Make the actual change larger so that we know to reparse anything whose lookahead + // might have intersected the change. + var changeRange = extendToAffectedRange(sourceFile, textChangeRange); + checkChangeRange(sourceFile, newText, changeRange, aggressiveChecks); + // Ensure that extending the affected range only moved the start of the change range + // earlier in the file. + ts.Debug.assert(changeRange.span.start <= textChangeRange.span.start); + ts.Debug.assert(ts.textSpanEnd(changeRange.span) === ts.textSpanEnd(textChangeRange.span)); + ts.Debug.assert(ts.textSpanEnd(ts.textChangeRangeNewSpan(changeRange)) === ts.textSpanEnd(ts.textChangeRangeNewSpan(textChangeRange))); + // The is the amount the nodes after the edit range need to be adjusted. It can be + // positive (if the edit added characters), negative (if the edit deleted characters) + // or zero (if this was a pure overwrite with nothing added/removed). + var delta = ts.textChangeRangeNewSpan(changeRange).length - changeRange.span.length; + // If we added or removed characters during the edit, then we need to go and adjust all + // the nodes after the edit. Those nodes may move forward (if we inserted chars) or they + // may move backward (if we deleted chars). + // + // Doing this helps us out in two ways. First, it means that any nodes/tokens we want + // to reuse are already at the appropriate position in the new text. That way when we + // reuse them, we don't have to figure out if they need to be adjusted. Second, it makes + // it very easy to determine if we can reuse a node. If the node's position is at where + // we are in the text, then we can reuse it. Otherwise we can't. If the node's position + // is ahead of us, then we'll need to rescan tokens. If the node's position is behind + // us, then we'll need to skip it or crumble it as appropriate + // + // We will also adjust the positions of nodes that intersect the change range as well. + // By doing this, we ensure that all the positions in the old tree are consistent, not + // just the positions of nodes entirely before/after the change range. By being + // consistent, we can then easily map from positions to nodes in the old tree easily. + // + // Also, mark any syntax elements that intersect the changed span. We know, up front, + // that we cannot reuse these elements. + updateTokenPositionsAndMarkElements(incrementalSourceFile, changeRange.span.start, ts.textSpanEnd(changeRange.span), ts.textSpanEnd(ts.textChangeRangeNewSpan(changeRange)), delta, oldText, newText, aggressiveChecks); + // Now that we've set up our internal incremental state just proceed and parse the + // source file in the normal fashion. When possible the parser will retrieve and + // reuse nodes from the old tree. + // + // Note: passing in 'true' for setNodeParents is very important. When incrementally + // parsing, we will be reusing nodes from the old tree, and placing it into new + // parents. If we don't set the parents now, we'll end up with an observably + // inconsistent tree. Setting the parents on the new tree should be very fast. We + // will immediately bail out of walking any subtrees when we can see that their parents + // are already correct. + var result = Parser.parseSourceFile(sourceFile.fileName, newText, sourceFile.languageVersion, syntaxCursor, /* setParentNode */ true); + return result; + } + IncrementalParser.updateSourceFile = updateSourceFile; + function moveElementEntirelyPastChangeRange(element, isArray, delta, oldText, newText, aggressiveChecks) { + if (isArray) { + visitArray(element); + } + else { + visitNode(element); + } + return; + function visitNode(node) { + var text = ""; + if (aggressiveChecks && shouldCheckNode(node)) { + text = oldText.substring(node.pos, node.end); + } + // Ditch any existing LS children we may have created. This way we can avoid + // moving them forward. + if (node._children) { + node._children = undefined; + } + if (node.jsDocComment) { + node.jsDocComment = undefined; + } + node.pos += delta; + node.end += delta; + if (aggressiveChecks && shouldCheckNode(node)) { + ts.Debug.assert(text === newText.substring(node.pos, node.end)); + } + forEachChild(node, visitNode, visitArray); + checkNodePositions(node, aggressiveChecks); + } + function visitArray(array) { + array._children = undefined; + array.pos += delta; + array.end += delta; + for (var _i = 0; _i < array.length; _i++) { + var node = array[_i]; + visitNode(node); + } + } + } + function shouldCheckNode(node) { + switch (node.kind) { + case 9 /* StringLiteral */: + case 8 /* NumericLiteral */: + case 69 /* Identifier */: + return true; + } + return false; + } + function adjustIntersectingElement(element, changeStart, changeRangeOldEnd, changeRangeNewEnd, delta) { + ts.Debug.assert(element.end >= changeStart, "Adjusting an element that was entirely before the change range"); + ts.Debug.assert(element.pos <= changeRangeOldEnd, "Adjusting an element that was entirely after the change range"); + ts.Debug.assert(element.pos <= element.end); + // We have an element that intersects the change range in some way. It may have its + // start, or its end (or both) in the changed range. We want to adjust any part + // that intersects such that the final tree is in a consistent state. i.e. all + // chlidren have spans within the span of their parent, and all siblings are ordered + // properly. + // We may need to update both the 'pos' and the 'end' of the element. + // If the 'pos' is before the start of the change, then we don't need to touch it. + // If it isn't, then the 'pos' must be inside the change. How we update it will + // depend if delta is positive or negative. If delta is positive then we have + // something like: + // + // -------------------AAA----------------- + // -------------------BBBCCCCCCC----------------- + // + // In this case, we consider any node that started in the change range to still be + // starting at the same position. + // + // however, if the delta is negative, then we instead have something like this: + // + // -------------------XXXYYYYYYY----------------- + // -------------------ZZZ----------------- + // + // In this case, any element that started in the 'X' range will keep its position. + // However any element htat started after that will have their pos adjusted to be + // at the end of the new range. i.e. any node that started in the 'Y' range will + // be adjusted to have their start at the end of the 'Z' range. + // + // The element will keep its position if possible. Or Move backward to the new-end + // if it's in the 'Y' range. + element.pos = Math.min(element.pos, changeRangeNewEnd); + // If the 'end' is after the change range, then we always adjust it by the delta + // amount. However, if the end is in the change range, then how we adjust it + // will depend on if delta is positive or negative. If delta is positive then we + // have something like: + // + // -------------------AAA----------------- + // -------------------BBBCCCCCCC----------------- + // + // In this case, we consider any node that ended inside the change range to keep its + // end position. + // + // however, if the delta is negative, then we instead have something like this: + // + // -------------------XXXYYYYYYY----------------- + // -------------------ZZZ----------------- + // + // In this case, any element that ended in the 'X' range will keep its position. + // However any element htat ended after that will have their pos adjusted to be + // at the end of the new range. i.e. any node that ended in the 'Y' range will + // be adjusted to have their end at the end of the 'Z' range. + if (element.end >= changeRangeOldEnd) { + // Element ends after the change range. Always adjust the end pos. + element.end += delta; + } + else { + // Element ends in the change range. The element will keep its position if + // possible. Or Move backward to the new-end if it's in the 'Y' range. + element.end = Math.min(element.end, changeRangeNewEnd); + } + ts.Debug.assert(element.pos <= element.end); + if (element.parent) { + ts.Debug.assert(element.pos >= element.parent.pos); + ts.Debug.assert(element.end <= element.parent.end); + } + } + function checkNodePositions(node, aggressiveChecks) { + if (aggressiveChecks) { + var pos = node.pos; + forEachChild(node, function (child) { + ts.Debug.assert(child.pos >= pos); + pos = child.end; + }); + ts.Debug.assert(pos <= node.end); + } + } + function updateTokenPositionsAndMarkElements(sourceFile, changeStart, changeRangeOldEnd, changeRangeNewEnd, delta, oldText, newText, aggressiveChecks) { + visitNode(sourceFile); + return; + function visitNode(child) { + ts.Debug.assert(child.pos <= child.end); + if (child.pos > changeRangeOldEnd) { + // Node is entirely past the change range. We need to move both its pos and + // end, forward or backward appropriately. + moveElementEntirelyPastChangeRange(child, /*isArray*/ false, delta, oldText, newText, aggressiveChecks); + return; + } + // Check if the element intersects the change range. If it does, then it is not + // reusable. Also, we'll need to recurse to see what constituent portions we may + // be able to use. + var fullEnd = child.end; + if (fullEnd >= changeStart) { + child.intersectsChange = true; + child._children = undefined; + // Adjust the pos or end (or both) of the intersecting element accordingly. + adjustIntersectingElement(child, changeStart, changeRangeOldEnd, changeRangeNewEnd, delta); + forEachChild(child, visitNode, visitArray); + checkNodePositions(child, aggressiveChecks); + return; + } + // Otherwise, the node is entirely before the change range. No need to do anything with it. + ts.Debug.assert(fullEnd < changeStart); + } + function visitArray(array) { + ts.Debug.assert(array.pos <= array.end); + if (array.pos > changeRangeOldEnd) { + // Array is entirely after the change range. We need to move it, and move any of + // its children. + moveElementEntirelyPastChangeRange(array, /*isArray*/ true, delta, oldText, newText, aggressiveChecks); + return; + } + // Check if the element intersects the change range. If it does, then it is not + // reusable. Also, we'll need to recurse to see what constituent portions we may + // be able to use. + var fullEnd = array.end; + if (fullEnd >= changeStart) { + array.intersectsChange = true; + 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; _i < array.length; _i++) { + var node = array[_i]; + visitNode(node); + } + return; + } + // Otherwise, the array is entirely before the change range. No need to do anything with it. + ts.Debug.assert(fullEnd < changeStart); + } + } + function extendToAffectedRange(sourceFile, changeRange) { + // Consider the following code: + // void foo() { /; } + // + // If the text changes with an insertion of / just before the semicolon then we end up with: + // void foo() { //; } + // + // If we were to just use the changeRange a is, then we would not rescan the { token + // (as it does not intersect the actual original change range). Because an edit may + // change the token touching it, we actually need to look back *at least* one token so + // that the prior token sees that change. + var maxLookahead = 1; + var start = changeRange.span.start; + // the first iteration aligns us with the change start. subsequent iteration move us to + // the left by maxLookahead tokens. We only need to do this as long as we're not at the + // start of the tree. + for (var i = 0; start > 0 && i <= maxLookahead; i++) { + var nearestNode = findNearestNodeStartingBeforeOrAtPosition(sourceFile, start); + ts.Debug.assert(nearestNode.pos <= start); + var position = nearestNode.pos; + start = Math.max(0, position - 1); + } + var finalSpan = ts.createTextSpanFromBounds(start, ts.textSpanEnd(changeRange.span)); + var finalLength = changeRange.newLength + (changeRange.span.start - start); + return ts.createTextChangeRange(finalSpan, finalLength); + } + function findNearestNodeStartingBeforeOrAtPosition(sourceFile, position) { + var bestResult = sourceFile; + var lastNodeEntirelyBeforePosition; + forEachChild(sourceFile, visit); + if (lastNodeEntirelyBeforePosition) { + var lastChildOfLastEntireNodeBeforePosition = getLastChild(lastNodeEntirelyBeforePosition); + if (lastChildOfLastEntireNodeBeforePosition.pos > bestResult.pos) { + bestResult = lastChildOfLastEntireNodeBeforePosition; + } + } + return bestResult; + function getLastChild(node) { + while (true) { + var lastChild = getLastChildWorker(node); + if (lastChild) { + node = lastChild; + } + else { + return node; + } + } + } + function getLastChildWorker(node) { + var last = undefined; + forEachChild(node, function (child) { + if (ts.nodeIsPresent(child)) { + last = child; + } + }); + return last; + } + function visit(child) { + if (ts.nodeIsMissing(child)) { + // Missing nodes are effectively invisible to us. We never even consider them + // When trying to find the nearest node before us. + return; + } + // If the child intersects this position, then this node is currently the nearest + // node that starts before the position. + if (child.pos <= position) { + if (child.pos >= bestResult.pos) { + // This node starts before the position, and is closer to the position than + // the previous best node we found. It is now the new best node. + bestResult = child; + } + // Now, the node may overlap the position, or it may end entirely before the + // position. If it overlaps with the position, then either it, or one of its + // children must be the nearest node before the position. So we can just + // recurse into this child to see if we can find something better. + if (position < child.end) { + // The nearest node is either this child, or one of the children inside + // of it. We've already marked this child as the best so far. Recurse + // in case one of the children is better. + forEachChild(child, visit); + // Once we look at the children of this node, then there's no need to + // continue any further. + return true; + } + else { + ts.Debug.assert(child.end <= position); + // The child ends entirely before this position. Say you have the following + // (where $ is the position) + // + // ? $ : <...> <...> + // + // We would want to find the nearest preceding node in "complex expr 2". + // To support that, we keep track of this node, and once we're done searching + // for a best node, we recurse down this node to see if we can find a good + // result in it. + // + // This approach allows us to quickly skip over nodes that are entirely + // before the position, while still allowing us to find any nodes in the + // last one that might be what we want. + lastNodeEntirelyBeforePosition = child; + } + } + else { + ts.Debug.assert(child.pos > position); + // We're now at a node that is entirely past the position we're searching for. + // This node (and all following nodes) could never contribute to the result, + // so just skip them by returning 'true' here. + return true; + } + } + } + function checkChangeRange(sourceFile, newText, textChangeRange, aggressiveChecks) { + var oldText = sourceFile.text; + if (textChangeRange) { + ts.Debug.assert((oldText.length - textChangeRange.span.length + textChangeRange.newLength) === newText.length); + if (aggressiveChecks || ts.Debug.shouldAssert(3 /* VeryAggressive */)) { + var oldTextPrefix = oldText.substr(0, textChangeRange.span.start); + var newTextPrefix = newText.substr(0, textChangeRange.span.start); + ts.Debug.assert(oldTextPrefix === newTextPrefix); + var oldTextSuffix = oldText.substring(ts.textSpanEnd(textChangeRange.span), oldText.length); + var newTextSuffix = newText.substring(ts.textSpanEnd(ts.textChangeRangeNewSpan(textChangeRange)), newText.length); + ts.Debug.assert(oldTextSuffix === newTextSuffix); + } + } + } + function createSyntaxCursor(sourceFile) { + var currentArray = sourceFile.statements; + var currentArrayIndex = 0; + ts.Debug.assert(currentArrayIndex < currentArray.length); + var current = currentArray[currentArrayIndex]; + var lastQueriedPosition = -1 /* Value */; + return { + currentNode: function (position) { + // Only compute the current node if the position is different than the last time + // we were asked. The parser commonly asks for the node at the same position + // twice. Once to know if can read an appropriate list element at a certain point, + // and then to actually read and consume the node. + if (position !== lastQueriedPosition) { + // Much of the time the parser will need the very next node in the array that + // we just returned a node from.So just simply check for that case and move + // forward in the array instead of searching for the node again. + if (current && current.end === position && currentArrayIndex < (currentArray.length - 1)) { + currentArrayIndex++; + current = currentArray[currentArrayIndex]; + } + // If we don't have a node, or the node we have isn't in the right position, + // then try to find a viable node at the position requested. + if (!current || current.pos !== position) { + findHighestListElementThatStartsAtPosition(position); + } + } + // Cache this query so that we don't do any extra work if the parser calls back + // into us. Note: this is very common as the parser will make pairs of calls like + // 'isListElement -> parseListElement'. If we were unable to find a node when + // called with 'isListElement', we don't want to redo the work when parseListElement + // is called immediately after. + lastQueriedPosition = position; + // Either we don'd have a node, or we have a node at the position being asked for. + ts.Debug.assert(!current || current.pos === position); + return current; + } + }; + // Finds the highest element in the tree we can find that starts at the provided position. + // The element must be a direct child of some node list in the tree. This way after we + // return it, we can easily return its next sibling in the list. + function findHighestListElementThatStartsAtPosition(position) { + // Clear out any cached state about the last node we found. + currentArray = undefined; + currentArrayIndex = -1 /* Value */; + current = undefined; + // Recurse into the source file to find the highest node at this position. + forEachChild(sourceFile, visitNode, visitArray); + return; + function visitNode(node) { + if (position >= node.pos && position < node.end) { + // Position was within this node. Keep searching deeper to find the node. + forEachChild(node, visitNode, visitArray); + // don't procede any futher in the search. + return true; + } + // position wasn't in this node, have to keep searching. + return false; + } + function visitArray(array) { + if (position >= array.pos && position < array.end) { + // position was in this array. Search through this array to see if we find a + // viable element. + for (var i = 0, n = array.length; i < n; i++) { + var child = array[i]; + if (child) { + if (child.pos === position) { + // Found the right node. We're done. + currentArray = array; + currentArrayIndex = i; + current = child; + return true; + } + else { + if (child.pos < position && position < child.end) { + // Position in somewhere within this child. Search in it and + // stop searching in this array. + forEachChild(child, visitNode, visitArray); + return true; + } + } + } + } + } + // position wasn't in this array, have to keep searching. + return false; + } + } + } + var InvalidPosition; + (function (InvalidPosition) { + InvalidPosition[InvalidPosition["Value"] = -1] = "Value"; + })(InvalidPosition || (InvalidPosition = {})); + })(IncrementalParser || (IncrementalParser = {})); +})(ts || (ts = {})); +/// +/* @internal */ +var ts; +(function (ts) { + var nextSymbolId = 1; + var nextNodeId = 1; + var nextMergeId = 1; + function getNodeId(node) { + if (!node.id) + node.id = nextNodeId++; + return node.id; + } + ts.getNodeId = getNodeId; + ts.checkTime = 0; + function getSymbolId(symbol) { + if (!symbol.id) { + symbol.id = nextSymbolId++; + } + return symbol.id; + } + ts.getSymbolId = getSymbolId; + function createTypeChecker(host, produceDiagnostics) { + // Cancellation that controls whether or not we can cancel in the middle of type checking. + // In general cancelling is *not* safe for the type checker. We might be in the middle of + // computing something, and we will leave our internals in an inconsistent state. Callers + // who set the cancellation token should catch if a cancellation exception occurs, and + // should throw away and create a new TypeChecker. + // + // Currently we only support setting the cancellation token when getting diagnostics. This + // is because diagnostics can be quite expensive, and we want to allow hosts to bail out if + // they no longer need the information (for example, if the user started editing again). + var cancellationToken; + var Symbol = ts.objectAllocator.getSymbolConstructor(); + var Type = ts.objectAllocator.getTypeConstructor(); + var Signature = ts.objectAllocator.getSignatureConstructor(); + var typeCount = 0; + var symbolCount = 0; + var emptyArray = []; + var emptySymbols = {}; + var compilerOptions = host.getCompilerOptions(); + var languageVersion = compilerOptions.target || 0 /* ES3 */; + var modulekind = compilerOptions.module ? compilerOptions.module : languageVersion === 2 /* ES6 */ ? 5 /* ES6 */ : 0 /* None */; + var emitResolver = createResolver(); + var undefinedSymbol = createSymbol(4 /* Property */ | 67108864 /* Transient */, "undefined"); + var argumentsSymbol = createSymbol(4 /* Property */ | 67108864 /* Transient */, "arguments"); + var checker = { + getNodeCount: function () { return ts.sum(host.getSourceFiles(), "nodeCount"); }, + getIdentifierCount: function () { return ts.sum(host.getSourceFiles(), "identifierCount"); }, + getSymbolCount: function () { return ts.sum(host.getSourceFiles(), "symbolCount") + symbolCount; }, + getTypeCount: function () { return typeCount; }, + isUndefinedSymbol: function (symbol) { return symbol === undefinedSymbol; }, + isArgumentsSymbol: function (symbol) { return symbol === argumentsSymbol; }, + getDiagnostics: getDiagnostics, + getGlobalDiagnostics: getGlobalDiagnostics, + // The language service will always care about the narrowed type of a symbol, because that is + // the type the language says the symbol should have. + getTypeOfSymbolAtLocation: getNarrowedTypeOfSymbol, + getDeclaredTypeOfSymbol: getDeclaredTypeOfSymbol, + getPropertiesOfType: getPropertiesOfType, + getPropertyOfType: getPropertyOfType, + getSignaturesOfType: getSignaturesOfType, + getIndexTypeOfType: getIndexTypeOfType, + getBaseTypes: getBaseTypes, + getReturnTypeOfSignature: getReturnTypeOfSignature, + getSymbolsInScope: getSymbolsInScope, + getSymbolAtLocation: getSymbolAtLocation, + getShorthandAssignmentValueSymbol: getShorthandAssignmentValueSymbol, + getTypeAtLocation: getTypeOfNode, + typeToString: typeToString, + getSymbolDisplayBuilder: getSymbolDisplayBuilder, + symbolToString: symbolToString, + getAugmentedPropertiesOfType: getAugmentedPropertiesOfType, + getRootSymbols: getRootSymbols, + getContextualType: getContextualType, + getFullyQualifiedName: getFullyQualifiedName, + getResolvedSignature: getResolvedSignature, + getConstantValue: getConstantValue, + isValidPropertyAccess: isValidPropertyAccess, + getSignatureFromDeclaration: getSignatureFromDeclaration, + isImplementationOfOverload: isImplementationOfOverload, + getAliasedSymbol: resolveAlias, + getEmitResolver: getEmitResolver, + getExportsOfModule: getExportsOfModuleAsArray, + getJsxElementAttributesType: getJsxElementAttributesType, + getJsxIntrinsicTagNames: getJsxIntrinsicTagNames, + isOptionalParameter: isOptionalParameter + }; + var unknownSymbol = createSymbol(4 /* Property */ | 67108864 /* Transient */, "unknown"); + var resolvingSymbol = createSymbol(67108864 /* Transient */, "__resolving__"); + var anyType = createIntrinsicType(1 /* Any */, "any"); + var stringType = createIntrinsicType(2 /* String */, "string"); + var numberType = createIntrinsicType(4 /* Number */, "number"); + var booleanType = createIntrinsicType(8 /* Boolean */, "boolean"); + var esSymbolType = createIntrinsicType(16777216 /* ESSymbol */, "symbol"); + var voidType = createIntrinsicType(16 /* Void */, "void"); + var undefinedType = createIntrinsicType(32 /* Undefined */ | 2097152 /* ContainsUndefinedOrNull */, "undefined"); + var nullType = createIntrinsicType(64 /* Null */ | 2097152 /* ContainsUndefinedOrNull */, "null"); + var unknownType = createIntrinsicType(1 /* Any */, "unknown"); + var circularType = createIntrinsicType(1 /* Any */, "__circular__"); + var emptyObjectType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); + var emptyGenericType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); + emptyGenericType.instantiations = {}; + var anyFunctionType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); + // The anyFunctionType contains the anyFunctionType by definition. The flag is further propagated + // in getPropagatingFlagsOfTypes, and it is checked in inferFromTypes. + anyFunctionType.flags |= 8388608 /* ContainsAnyFunctionType */; + var noConstraintType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); + var anySignature = createSignature(undefined, undefined, emptyArray, anyType, undefined, 0, false, false); + var unknownSignature = createSignature(undefined, undefined, emptyArray, unknownType, undefined, 0, false, false); + var globals = {}; + var globalESSymbolConstructorSymbol; + var getGlobalPromiseConstructorSymbol; + var globalObjectType; + var globalFunctionType; + var globalArrayType; + var globalStringType; + var globalNumberType; + var globalBooleanType; + var globalRegExpType; + var globalTemplateStringsArrayType; + var globalESSymbolType; + var jsxElementType; + /** Lazily loaded, use getJsxIntrinsicElementType() */ + var jsxIntrinsicElementsType; + var globalIterableType; + var globalIteratorType; + var globalIterableIteratorType; + var anyArrayType; + var getGlobalClassDecoratorType; + var getGlobalParameterDecoratorType; + var getGlobalPropertyDecoratorType; + var getGlobalMethodDecoratorType; + var getGlobalTypedPropertyDescriptorType; + var getGlobalPromiseType; + var tryGetGlobalPromiseType; + var getGlobalPromiseLikeType; + var getInstantiatedGlobalPromiseLikeType; + var getGlobalPromiseConstructorLikeType; + var getGlobalThenableType; + var tupleTypes = {}; + var unionTypes = {}; + var intersectionTypes = {}; + var stringLiteralTypes = {}; + var emitExtends = false; + var emitDecorate = false; + var emitParam = false; + var emitAwaiter = false; + var emitGenerator = false; + var resolutionTargets = []; + var resolutionResults = []; + var resolutionPropertyNames = []; + var mergedSymbols = []; + var symbolLinks = []; + var nodeLinks = []; + var potentialThisCollisions = []; + var awaitedTypeStack = []; + var diagnostics = ts.createDiagnosticCollection(); + var primitiveTypeInfo = { + "string": { + type: stringType, + flags: 258 /* StringLike */ + }, + "number": { + type: numberType, + flags: 132 /* NumberLike */ + }, + "boolean": { + type: booleanType, + flags: 8 /* Boolean */ + }, + "symbol": { + type: esSymbolType, + flags: 16777216 /* ESSymbol */ + } + }; + var JsxNames = { + JSX: "JSX", + IntrinsicElements: "IntrinsicElements", + ElementClass: "ElementClass", + ElementAttributesPropertyNameContainer: "ElementAttributesProperty", + Element: "Element" + }; + var subtypeRelation = {}; + var assignableRelation = {}; + var identityRelation = {}; + // This is for caching the result of getSymbolDisplayBuilder. Do not access directly. + 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 = {})); + initializeTypeChecker(); + return checker; + function getEmitResolver(sourceFile, cancellationToken) { + // Ensure we have all the type information in place for this file so that all the + // emitter questions of this resolver will return the right information. + getDiagnostics(sourceFile, cancellationToken); + return emitResolver; + } + function error(location, message, arg0, arg1, arg2) { + var diagnostic = location + ? ts.createDiagnosticForNode(location, message, arg0, arg1, arg2) + : ts.createCompilerDiagnostic(message, arg0, arg1, arg2); + diagnostics.add(diagnostic); + } + function createSymbol(flags, name) { + symbolCount++; + return new Symbol(flags, name); + } + function getExcludedSymbolFlags(flags) { + var result = 0; + if (flags & 2 /* BlockScopedVariable */) + result |= 107455 /* BlockScopedVariableExcludes */; + if (flags & 1 /* FunctionScopedVariable */) + result |= 107454 /* FunctionScopedVariableExcludes */; + if (flags & 4 /* Property */) + result |= 107455 /* PropertyExcludes */; + if (flags & 8 /* EnumMember */) + result |= 107455 /* EnumMemberExcludes */; + if (flags & 16 /* Function */) + result |= 106927 /* FunctionExcludes */; + if (flags & 32 /* Class */) + result |= 899519 /* ClassExcludes */; + if (flags & 64 /* Interface */) + result |= 792960 /* InterfaceExcludes */; + if (flags & 256 /* RegularEnum */) + result |= 899327 /* RegularEnumExcludes */; + if (flags & 128 /* ConstEnum */) + result |= 899967 /* ConstEnumExcludes */; + if (flags & 512 /* ValueModule */) + result |= 106639 /* ValueModuleExcludes */; + if (flags & 8192 /* Method */) + result |= 99263 /* MethodExcludes */; + if (flags & 32768 /* GetAccessor */) + result |= 41919 /* GetAccessorExcludes */; + if (flags & 65536 /* SetAccessor */) + result |= 74687 /* SetAccessorExcludes */; + if (flags & 262144 /* TypeParameter */) + result |= 530912 /* TypeParameterExcludes */; + if (flags & 524288 /* TypeAlias */) + result |= 793056 /* TypeAliasExcludes */; + if (flags & 8388608 /* Alias */) + result |= 8388608 /* AliasExcludes */; + return result; + } + function recordMergedSymbol(target, source) { + if (!source.mergeId) + source.mergeId = nextMergeId++; + mergedSymbols[source.mergeId] = target; + } + function cloneSymbol(symbol) { + var result = createSymbol(symbol.flags | 33554432 /* Merged */, symbol.name); + result.declarations = symbol.declarations.slice(0); + result.parent = symbol.parent; + if (symbol.valueDeclaration) + result.valueDeclaration = symbol.valueDeclaration; + if (symbol.constEnumOnlyModule) + result.constEnumOnlyModule = true; + if (symbol.members) + result.members = cloneSymbolTable(symbol.members); + if (symbol.exports) + result.exports = cloneSymbolTable(symbol.exports); + recordMergedSymbol(result, symbol); + return result; + } + function mergeSymbol(target, source) { + if (!(target.flags & getExcludedSymbolFlags(source.flags))) { + if (source.flags & 512 /* ValueModule */ && target.flags & 512 /* ValueModule */ && target.constEnumOnlyModule && !source.constEnumOnlyModule) { + // reset flag when merging instantiated module into value module that has only const enums + target.constEnumOnlyModule = false; + } + target.flags |= source.flags; + if (!target.valueDeclaration && source.valueDeclaration) + target.valueDeclaration = source.valueDeclaration; + ts.forEach(source.declarations, function (node) { + target.declarations.push(node); + }); + if (source.members) { + if (!target.members) + target.members = {}; + mergeSymbolTable(target.members, source.members); + } + if (source.exports) { + if (!target.exports) + target.exports = {}; + mergeSymbolTable(target.exports, source.exports); + } + recordMergedSymbol(target, source); + } + else { + var message = target.flags & 2 /* BlockScopedVariable */ || source.flags & 2 /* BlockScopedVariable */ + ? ts.Diagnostics.Cannot_redeclare_block_scoped_variable_0 : ts.Diagnostics.Duplicate_identifier_0; + ts.forEach(source.declarations, function (node) { + error(node.name ? node.name : node, message, symbolToString(source)); + }); + ts.forEach(target.declarations, function (node) { + error(node.name ? node.name : node, message, symbolToString(source)); + }); + } + } + function cloneSymbolTable(symbolTable) { + var result = {}; + for (var id in symbolTable) { + if (ts.hasProperty(symbolTable, id)) { + result[id] = symbolTable[id]; + } + } + return result; + } + function mergeSymbolTable(target, source) { + for (var id in source) { + if (ts.hasProperty(source, id)) { + if (!ts.hasProperty(target, id)) { + target[id] = source[id]; + } + else { + var symbol = target[id]; + if (!(symbol.flags & 33554432 /* Merged */)) { + target[id] = symbol = cloneSymbol(symbol); + } + mergeSymbol(symbol, source[id]); + } + } + } + } + function getSymbolLinks(symbol) { + if (symbol.flags & 67108864 /* Transient */) + return symbol; + var id = getSymbolId(symbol); + return symbolLinks[id] || (symbolLinks[id] = {}); + } + function getNodeLinks(node) { + var nodeId = getNodeId(node); + return nodeLinks[nodeId] || (nodeLinks[nodeId] = {}); + } + function getSourceFile(node) { + return ts.getAncestor(node, 248 /* SourceFile */); + } + function isGlobalSourceFile(node) { + return node.kind === 248 /* SourceFile */ && !ts.isExternalModule(node); + } + function getSymbol(symbols, name, meaning) { + if (meaning && ts.hasProperty(symbols, name)) { + var symbol = symbols[name]; + ts.Debug.assert((symbol.flags & 16777216 /* Instantiated */) === 0, "Should never get an instantiated symbol here."); + if (symbol.flags & meaning) { + return symbol; + } + if (symbol.flags & 8388608 /* Alias */) { + var target = resolveAlias(symbol); + // Unknown symbol means an error occurred in alias resolution, treat it as positive answer to avoid cascading errors + if (target === unknownSymbol || target.flags & meaning) { + return symbol; + } + } + } + // return undefined if we can't find a symbol. + } + function isBlockScopedNameDeclaredBeforeUse(declaration, usage) { + var declarationFile = ts.getSourceFileOfNode(declaration); + var useFile = ts.getSourceFileOfNode(usage); + if (declarationFile !== useFile) { + if (modulekind || (!compilerOptions.outFile && !compilerOptions.out)) { + // nodes are in different files and order cannot be determines + return true; + } + var sourceFiles = host.getSourceFiles(); + return ts.indexOf(sourceFiles, declarationFile) <= ts.indexOf(sourceFiles, useFile); + } + if (declaration.pos <= usage.pos) { + // declaration is before usage + // still might be illegal if usage is in the initializer of the variable declaration + return declaration.kind !== 211 /* VariableDeclaration */ || + !isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage); + } + // declaration is after usage + // can be legal if usage is deferred (i.e. inside function or in initializer of instance property) + return isUsedInFunctionOrNonStaticProperty(declaration, usage); + function isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage) { + var container = ts.getEnclosingBlockScopeContainer(declaration); + if (declaration.parent.parent.kind === 193 /* VariableStatement */ || + declaration.parent.parent.kind === 199 /* ForStatement */) { + // variable statement/for statement case, + // use site should not be inside variable declaration (initializer of declaration or binding element) + return isSameScopeDescendentOf(usage, declaration, container); + } + else if (declaration.parent.parent.kind === 201 /* ForOfStatement */ || + declaration.parent.parent.kind === 200 /* ForInStatement */) { + // ForIn/ForOf case - use site should not be used in expression part + var expression = declaration.parent.parent.expression; + return isSameScopeDescendentOf(usage, expression, container); + } + } + function isUsedInFunctionOrNonStaticProperty(declaration, usage) { + var container = ts.getEnclosingBlockScopeContainer(declaration); + var current = usage; + while (current) { + if (current === container) { + return false; + } + if (ts.isFunctionLike(current)) { + return true; + } + var initializerOfNonStaticProperty = current.parent && + current.parent.kind === 141 /* PropertyDeclaration */ && + (current.parent.flags & 128 /* Static */) === 0 && + current.parent.initializer === current; + if (initializerOfNonStaticProperty) { + return true; + } + current = current.parent; + } + return false; + } + } + // Resolve a given name for a given meaning at a given location. An error is reported if the name was not found and + // the nameNotFoundMessage argument is not undefined. Returns the resolved symbol, or undefined if no symbol with + // the given name can be found. + function resolveName(location, name, meaning, nameNotFoundMessage, nameArg) { + var result; + var lastLocation; + var propertyWithInvalidInitializer; + var errorLocation = location; + var grandparent; + loop: while (location) { + // Locals of a source file are not in scope (because they get merged into the global symbol table) + if (location.locals && !isGlobalSourceFile(location)) { + if (result = getSymbol(location.locals, name, meaning)) { + // Type parameters of a function are in scope in the entire function declaration, including the parameter + // list and return type. However, local types are only in scope in the function body. + if (!(meaning & 793056 /* Type */) || + !(result.flags & (793056 /* Type */ & ~262144 /* TypeParameter */)) || + !ts.isFunctionLike(location) || + lastLocation === location.body) { + break loop; + } + result = undefined; + } + } + switch (location.kind) { + case 248 /* SourceFile */: + if (!ts.isExternalModule(location)) + break; + case 218 /* ModuleDeclaration */: + var moduleExports = getSymbolOfNode(location).exports; + if (location.kind === 248 /* SourceFile */ || + (location.kind === 218 /* ModuleDeclaration */ && location.name.kind === 9 /* StringLiteral */)) { + // It's an external module. Because of module/namespace merging, a module's exports are in scope, + // yet we never want to treat an export specifier as putting a member in scope. Therefore, + // if the name we find is purely an export specifier, it is not actually considered in scope. + // Two things to note about this: + // 1. We have to check this without calling getSymbol. The problem with calling getSymbol + // on an export specifier is that it might find the export specifier itself, and try to + // resolve it as an alias. This will cause the checker to consider the export specifier + // a circular alias reference when it might not be. + // 2. We check === SymbolFlags.Alias in order to check that the symbol is *purely* + // an alias. If we used &, we'd be throwing out symbols that have non alias aspects, + // which is not the desired behavior. + if (ts.hasProperty(moduleExports, name) && + moduleExports[name].flags === 8388608 /* Alias */ && + ts.getDeclarationOfKind(moduleExports[name], 230 /* ExportSpecifier */)) { + break; + } + result = moduleExports["default"]; + var localSymbol = ts.getLocalSymbolForExportDefault(result); + if (result && localSymbol && (result.flags & meaning) && localSymbol.name === name) { + break loop; + } + result = undefined; + } + if (result = getSymbol(moduleExports, name, meaning & 8914931 /* ModuleMember */)) { + break loop; + } + break; + case 217 /* EnumDeclaration */: + if (result = getSymbol(getSymbolOfNode(location).exports, name, meaning & 8 /* EnumMember */)) { + break loop; + } + break; + case 141 /* PropertyDeclaration */: + case 140 /* PropertySignature */: + // TypeScript 1.0 spec (April 2014): 8.4.1 + // Initializer expressions for instance member variables are evaluated in the scope + // of the class constructor body but are not permitted to reference parameters or + // local variables of the constructor. This effectively means that entities from outer scopes + // by the same name as a constructor parameter or local variable are inaccessible + // in initializer expressions for instance member variables. + if (ts.isClassLike(location.parent) && !(location.flags & 128 /* Static */)) { + var ctor = findConstructorDeclaration(location.parent); + if (ctor && ctor.locals) { + if (getSymbol(ctor.locals, name, meaning & 107455 /* Value */)) { + // Remember the property node, it will be used later to report appropriate error + propertyWithInvalidInitializer = location; + } + } + } + break; + case 214 /* ClassDeclaration */: + case 186 /* ClassExpression */: + case 215 /* InterfaceDeclaration */: + if (result = getSymbol(getSymbolOfNode(location).members, name, meaning & 793056 /* Type */)) { + if (lastLocation && lastLocation.flags & 128 /* Static */) { + // TypeScript 1.0 spec (April 2014): 3.4.1 + // The scope of a type parameter extends over the entire declaration with which the type + // parameter list is associated, with the exception of static member declarations in classes. + error(errorLocation, ts.Diagnostics.Static_members_cannot_reference_class_type_parameters); + return undefined; + } + break loop; + } + if (location.kind === 186 /* ClassExpression */ && meaning & 32 /* Class */) { + var className = location.name; + if (className && name === className.text) { + result = location.symbol; + break loop; + } + } + break; + // It is not legal to reference a class's own type parameters from a computed property name that + // belongs to the class. For example: + // + // function foo() { return '' } + // class C { // <-- Class's own type parameter T + // [foo()]() { } // <-- Reference to T from class's own computed property + // } + // + case 136 /* ComputedPropertyName */: + grandparent = location.parent.parent; + if (ts.isClassLike(grandparent) || grandparent.kind === 215 /* InterfaceDeclaration */) { + // A reference to this grandparent's type parameters would be an error + if (result = getSymbol(getSymbolOfNode(grandparent).members, name, meaning & 793056 /* Type */)) { + error(errorLocation, ts.Diagnostics.A_computed_property_name_cannot_reference_a_type_parameter_from_its_containing_type); + return undefined; + } + } + break; + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: + case 144 /* Constructor */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: + case 213 /* FunctionDeclaration */: + case 174 /* ArrowFunction */: + if (meaning & 3 /* Variable */ && name === "arguments") { + result = argumentsSymbol; + break loop; + } + break; + case 173 /* FunctionExpression */: + if (meaning & 3 /* Variable */ && name === "arguments") { + result = argumentsSymbol; + break loop; + } + if (meaning & 16 /* Function */) { + var functionName = location.name; + if (functionName && name === functionName.text) { + result = location.symbol; + break loop; + } + } + break; + case 139 /* Decorator */: + // Decorators are resolved at the class declaration. Resolving at the parameter + // or member would result in looking up locals in the method. + // + // function y() {} + // class C { + // method(@y x, y) {} // <-- decorator y should be resolved at the class declaration, not the parameter. + // } + // + if (location.parent && location.parent.kind === 138 /* Parameter */) { + location = location.parent; + } + // + // function y() {} + // class C { + // @y method(x, y) {} // <-- decorator y should be resolved at the class declaration, not the method. + // } + // + if (location.parent && ts.isClassElement(location.parent)) { + location = location.parent; + } + break; + } + lastLocation = location; + location = location.parent; + } + if (!result) { + result = getSymbol(globals, name, meaning); + } + if (!result) { + if (nameNotFoundMessage) { + error(errorLocation, nameNotFoundMessage, typeof nameArg === "string" ? nameArg : ts.declarationNameToString(nameArg)); + } + return undefined; + } + // Perform extra checks only if error reporting was requested + if (nameNotFoundMessage) { + if (propertyWithInvalidInitializer) { + // We have a match, but the reference occurred within a property initializer and the identifier also binds + // to a local variable in the constructor where the code will be emitted. + var propertyName = propertyWithInvalidInitializer.name; + error(errorLocation, ts.Diagnostics.Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor, ts.declarationNameToString(propertyName), typeof nameArg === "string" ? nameArg : ts.declarationNameToString(nameArg)); + return undefined; + } + // Only check for block-scoped variable if we are looking for the + // name with variable meaning + // For example, + // declare module foo { + // interface bar {} + // } + // let foo/*1*/: foo/*2*/.bar; + // The foo at /*1*/ and /*2*/ will share same symbol with two meaning + // block - scope variable and namespace module. However, only when we + // try to resolve name in /*1*/ which is used in variable position, + // we want to check for block- scoped + if (meaning & 2 /* BlockScopedVariable */) { + var exportOrLocalSymbol = getExportSymbolOfValueSymbolIfExported(result); + if (exportOrLocalSymbol.flags & 2 /* BlockScopedVariable */) { + checkResolvedBlockScopedVariable(exportOrLocalSymbol, errorLocation); + } + } + } + return result; + } + function checkResolvedBlockScopedVariable(result, errorLocation) { + ts.Debug.assert((result.flags & 2 /* BlockScopedVariable */) !== 0); + // 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 (!isBlockScopedNameDeclaredBeforeUse(ts.getAncestor(declaration, 211 /* VariableDeclaration */), errorLocation)) { + error(errorLocation, ts.Diagnostics.Block_scoped_variable_0_used_before_its_declaration, ts.declarationNameToString(declaration.name)); + } + } + /* Starting from 'initial' node walk up the parent chain until 'stopAt' node is reached. + * If at any point current node is equal to 'parent' node - return true. + * Return false if 'stopAt' node is reached or isFunctionLike(current) === true. + */ + function isSameScopeDescendentOf(initial, parent, stopAt) { + if (!parent) { + return false; + } + for (var current = initial; current && current !== stopAt && !ts.isFunctionLike(current); current = current.parent) { + if (current === parent) { + return true; + } + } + return false; + } + function getAnyImportSyntax(node) { + if (ts.isAliasSymbolDeclaration(node)) { + if (node.kind === 221 /* ImportEqualsDeclaration */) { + return node; + } + while (node && node.kind !== 222 /* ImportDeclaration */) { + node = node.parent; + } + return node; + } + } + function getDeclarationOfAliasSymbol(symbol) { + return ts.forEach(symbol.declarations, function (d) { return ts.isAliasSymbolDeclaration(d) ? d : undefined; }); + } + function getTargetOfImportEqualsDeclaration(node) { + if (node.moduleReference.kind === 232 /* ExternalModuleReference */) { + return resolveExternalModuleSymbol(resolveExternalModuleName(node, ts.getExternalModuleImportEqualsDeclarationExpression(node))); + } + return getSymbolOfPartOfRightHandSideOfImportEquals(node.moduleReference, node); + } + function getTargetOfImportClause(node) { + var moduleSymbol = resolveExternalModuleName(node, node.parent.moduleSpecifier); + if (moduleSymbol) { + var exportDefaultSymbol = resolveSymbol(moduleSymbol.exports["default"]); + if (!exportDefaultSymbol) { + error(node.name, ts.Diagnostics.Module_0_has_no_default_export, symbolToString(moduleSymbol)); + } + return exportDefaultSymbol; + } + } + function getTargetOfNamespaceImport(node) { + var moduleSpecifier = node.parent.parent.moduleSpecifier; + return resolveESModuleSymbol(resolveExternalModuleName(node, moduleSpecifier), moduleSpecifier); + } + function getMemberOfModuleVariable(moduleSymbol, name) { + if (moduleSymbol.flags & 3 /* Variable */) { + var typeAnnotation = moduleSymbol.valueDeclaration.type; + if (typeAnnotation) { + return getPropertyOfType(getTypeFromTypeNode(typeAnnotation), name); + } + } + } + // This function creates a synthetic symbol that combines the value side of one symbol with the + // type/namespace side of another symbol. Consider this example: + // + // declare module graphics { + // interface Point { + // x: number; + // y: number; + // } + // } + // declare var graphics: { + // Point: new (x: number, y: number) => graphics.Point; + // } + // declare module "graphics" { + // export = graphics; + // } + // + // An 'import { Point } from "graphics"' needs to create a symbol that combines the value side 'Point' + // property with the type/namespace side interface 'Point'. + function combineValueAndTypeSymbols(valueSymbol, typeSymbol) { + if (valueSymbol.flags & (793056 /* Type */ | 1536 /* Namespace */)) { + return valueSymbol; + } + var result = createSymbol(valueSymbol.flags | typeSymbol.flags, valueSymbol.name); + result.declarations = ts.concatenate(valueSymbol.declarations, typeSymbol.declarations); + result.parent = valueSymbol.parent || typeSymbol.parent; + if (valueSymbol.valueDeclaration) + result.valueDeclaration = valueSymbol.valueDeclaration; + if (typeSymbol.members) + result.members = typeSymbol.members; + if (valueSymbol.exports) + result.exports = valueSymbol.exports; + return result; + } + function getExportOfModule(symbol, name) { + if (symbol.flags & 1536 /* Module */) { + var exports = getExportsOfSymbol(symbol); + if (ts.hasProperty(exports, name)) { + return resolveSymbol(exports[name]); + } + } + } + function getPropertyOfVariable(symbol, name) { + if (symbol.flags & 3 /* Variable */) { + var typeAnnotation = symbol.valueDeclaration.type; + if (typeAnnotation) { + return resolveSymbol(getPropertyOfType(getTypeFromTypeNode(typeAnnotation), name)); + } + } + } + function getExternalModuleMember(node, specifier) { + var moduleSymbol = resolveExternalModuleName(node, node.moduleSpecifier); + var targetSymbol = resolveESModuleSymbol(moduleSymbol, node.moduleSpecifier); + if (targetSymbol) { + var name_9 = specifier.propertyName || specifier.name; + if (name_9.text) { + var symbolFromModule = getExportOfModule(targetSymbol, name_9.text); + var symbolFromVariable = getPropertyOfVariable(targetSymbol, name_9.text); + var symbol = symbolFromModule && symbolFromVariable ? + combineValueAndTypeSymbols(symbolFromVariable, symbolFromModule) : + symbolFromModule || symbolFromVariable; + if (!symbol) { + error(name_9, ts.Diagnostics.Module_0_has_no_exported_member_1, getFullyQualifiedName(moduleSymbol), ts.declarationNameToString(name_9)); + } + return symbol; + } + } + } + function getTargetOfImportSpecifier(node) { + return getExternalModuleMember(node.parent.parent.parent, node); + } + function getTargetOfExportSpecifier(node) { + return node.parent.parent.moduleSpecifier ? + getExternalModuleMember(node.parent.parent, node) : + resolveEntityName(node.propertyName || node.name, 107455 /* Value */ | 793056 /* Type */ | 1536 /* Namespace */); + } + function getTargetOfExportAssignment(node) { + return resolveEntityName(node.expression, 107455 /* Value */ | 793056 /* Type */ | 1536 /* Namespace */); + } + function getTargetOfAliasDeclaration(node) { + switch (node.kind) { + case 221 /* ImportEqualsDeclaration */: + return getTargetOfImportEqualsDeclaration(node); + case 223 /* ImportClause */: + return getTargetOfImportClause(node); + case 224 /* NamespaceImport */: + return getTargetOfNamespaceImport(node); + case 226 /* ImportSpecifier */: + return getTargetOfImportSpecifier(node); + case 230 /* ExportSpecifier */: + return getTargetOfExportSpecifier(node); + case 227 /* ExportAssignment */: + return getTargetOfExportAssignment(node); + } + } + function resolveSymbol(symbol) { + return symbol && symbol.flags & 8388608 /* Alias */ && !(symbol.flags & (107455 /* Value */ | 793056 /* Type */ | 1536 /* Namespace */)) ? resolveAlias(symbol) : symbol; + } + function resolveAlias(symbol) { + ts.Debug.assert((symbol.flags & 8388608 /* Alias */) !== 0, "Should only get Alias here."); + var links = getSymbolLinks(symbol); + if (!links.target) { + links.target = resolvingSymbol; + var node = getDeclarationOfAliasSymbol(symbol); + var target = getTargetOfAliasDeclaration(node); + if (links.target === resolvingSymbol) { + links.target = target || unknownSymbol; + } + else { + error(node, ts.Diagnostics.Circular_definition_of_import_alias_0, symbolToString(symbol)); + } + } + else if (links.target === resolvingSymbol) { + links.target = unknownSymbol; + } + return links.target; + } + function markExportAsReferenced(node) { + var symbol = getSymbolOfNode(node); + var target = resolveAlias(symbol); + if (target) { + var markAlias = (target === unknownSymbol && compilerOptions.isolatedModules) || + (target !== unknownSymbol && (target.flags & 107455 /* Value */) && !isConstEnumOrConstEnumOnlyModule(target)); + if (markAlias) { + markAliasSymbolAsReferenced(symbol); + } + } + } + // When an alias symbol is referenced, we need to mark the entity it references as referenced and in turn repeat that until + // we reach a non-alias or an exported entity (which is always considered referenced). We do this by checking the target of + // the alias as an expression (which recursively takes us back here if the target references another alias). + function markAliasSymbolAsReferenced(symbol) { + var links = getSymbolLinks(symbol); + if (!links.referenced) { + links.referenced = true; + var node = getDeclarationOfAliasSymbol(symbol); + if (node.kind === 227 /* ExportAssignment */) { + // export default + checkExpressionCached(node.expression); + } + else if (node.kind === 230 /* ExportSpecifier */) { + // export { } or export { as foo } + checkExpressionCached(node.propertyName || node.name); + } + else if (ts.isInternalModuleImportEqualsDeclaration(node)) { + // import foo = + checkExpressionCached(node.moduleReference); + } + } + } + // This function is only for imports with entity names + function getSymbolOfPartOfRightHandSideOfImportEquals(entityName, importDeclaration) { + if (!importDeclaration) { + importDeclaration = ts.getAncestor(entityName, 221 /* ImportEqualsDeclaration */); + ts.Debug.assert(importDeclaration !== undefined); + } + // There are three things we might try to look for. In the following examples, + // 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)) { + entityName = entityName.parent; + } + // Check for case 1 and 3 in the above example + if (entityName.kind === 69 /* Identifier */ || entityName.parent.kind === 135 /* QualifiedName */) { + return resolveEntityName(entityName, 1536 /* Namespace */); + } + else { + // Case 2 in above example + // entityName.kind could be a QualifiedName or a Missing identifier + ts.Debug.assert(entityName.parent.kind === 221 /* ImportEqualsDeclaration */); + return resolveEntityName(entityName, 107455 /* Value */ | 793056 /* Type */ | 1536 /* Namespace */); + } + } + function getFullyQualifiedName(symbol) { + return symbol.parent ? getFullyQualifiedName(symbol.parent) + "." + symbolToString(symbol) : symbolToString(symbol); + } + // Resolves a qualified name and any involved aliases + function resolveEntityName(name, meaning, ignoreErrors) { + if (ts.nodeIsMissing(name)) { + return undefined; + } + var symbol; + if (name.kind === 69 /* Identifier */) { + var message = meaning === 1536 /* Namespace */ ? ts.Diagnostics.Cannot_find_namespace_0 : ts.Diagnostics.Cannot_find_name_0; + symbol = resolveName(name, name.text, meaning, ignoreErrors ? undefined : message, name); + if (!symbol) { + return undefined; + } + } + else if (name.kind === 135 /* QualifiedName */ || name.kind === 166 /* PropertyAccessExpression */) { + var left = name.kind === 135 /* QualifiedName */ ? name.left : name.expression; + var right = name.kind === 135 /* QualifiedName */ ? name.right : name.name; + var namespace = resolveEntityName(left, 1536 /* Namespace */, ignoreErrors); + if (!namespace || namespace === unknownSymbol || ts.nodeIsMissing(right)) { + return undefined; + } + symbol = getSymbol(getExportsOfSymbol(namespace), right.text, meaning); + if (!symbol) { + if (!ignoreErrors) { + error(right, ts.Diagnostics.Module_0_has_no_exported_member_1, getFullyQualifiedName(namespace), ts.declarationNameToString(right)); + } + return undefined; + } + } + else { + ts.Debug.fail("Unknown entity name kind."); + } + ts.Debug.assert((symbol.flags & 16777216 /* Instantiated */) === 0, "Should never get an instantiated symbol here."); + return symbol.flags & meaning ? symbol : resolveAlias(symbol); + } + function resolveExternalModuleName(location, moduleReferenceExpression) { + if (moduleReferenceExpression.kind !== 9 /* StringLiteral */) { + return; + } + var moduleReferenceLiteral = moduleReferenceExpression; + var searchPath = ts.getDirectoryPath(getSourceFile(location).fileName); + // Module names are escaped in our symbol table. However, string literal values aren't. + // Escape the name in the "require(...)" clause to ensure we find the right symbol. + var moduleName = ts.escapeIdentifier(moduleReferenceLiteral.text); + if (moduleName === undefined) { + return; + } + var isRelative = ts.isExternalModuleNameRelative(moduleName); + if (!isRelative) { + var symbol = getSymbol(globals, "\"" + moduleName + "\"", 512 /* ValueModule */); + if (symbol) { + return symbol; + } + } + var resolvedModule = ts.getResolvedModule(getSourceFile(location), moduleReferenceLiteral.text); + var sourceFile = resolvedModule && host.getSourceFile(resolvedModule.resolvedFileName); + if (sourceFile) { + if (sourceFile.symbol) { + return sourceFile.symbol; + } + error(moduleReferenceLiteral, ts.Diagnostics.File_0_is_not_a_module, sourceFile.fileName); + return; + } + error(moduleReferenceLiteral, ts.Diagnostics.Cannot_find_module_0, moduleName); + } + // An external module with an 'export =' declaration resolves to the target of the 'export =' declaration, + // and an external module with no 'export =' declaration resolves to the module itself. + function resolveExternalModuleSymbol(moduleSymbol) { + return moduleSymbol && resolveSymbol(moduleSymbol.exports["export="]) || moduleSymbol; + } + // An external module with an 'export =' declaration may be referenced as an ES6 module provided the 'export =' + // references a symbol that is at least declared as a module or a variable. The target of the 'export =' may + // combine other declarations with the module or variable (e.g. a class/module, function/module, interface/variable). + function resolveESModuleSymbol(moduleSymbol, moduleReferenceExpression) { + var symbol = resolveExternalModuleSymbol(moduleSymbol); + if (symbol && !(symbol.flags & (1536 /* Module */ | 3 /* Variable */))) { + error(moduleReferenceExpression, ts.Diagnostics.Module_0_resolves_to_a_non_module_entity_and_cannot_be_imported_using_this_construct, symbolToString(moduleSymbol)); + symbol = undefined; + } + return symbol; + } + function getExportAssignmentSymbol(moduleSymbol) { + return moduleSymbol.exports["export="]; + } + function getExportsOfModuleAsArray(moduleSymbol) { + return symbolsToArray(getExportsOfModule(moduleSymbol)); + } + function getExportsOfSymbol(symbol) { + return symbol.flags & 1536 /* Module */ ? getExportsOfModule(symbol) : symbol.exports || emptySymbols; + } + function getExportsOfModule(moduleSymbol) { + var links = getSymbolLinks(moduleSymbol); + return links.resolvedExports || (links.resolvedExports = getExportsForModule(moduleSymbol)); + } + function extendExportSymbols(target, source) { + for (var id in source) { + if (id !== "default" && !ts.hasProperty(target, id)) { + target[id] = source[id]; + } + } + } + function getExportsForModule(moduleSymbol) { + var result; + var visitedSymbols = []; + visit(moduleSymbol); + return result || 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. + function visit(symbol) { + if (symbol && symbol.flags & 1952 /* HasExports */ && !ts.contains(visitedSymbols, symbol)) { + visitedSymbols.push(symbol); + if (symbol !== moduleSymbol) { + if (!result) { + result = cloneSymbolTable(moduleSymbol.exports); + } + extendExportSymbols(result, symbol.exports); + } + // All export * declarations are collected in an __export symbol by the binder + var exportStars = symbol.exports["__export"]; + if (exportStars) { + for (var _i = 0, _a = exportStars.declarations; _i < _a.length; _i++) { + var node = _a[_i]; + visit(resolveExternalModuleName(node, node.moduleSpecifier)); + } + } + } + } + } + function getMergedSymbol(symbol) { + var merged; + return symbol && symbol.mergeId && (merged = mergedSymbols[symbol.mergeId]) ? merged : symbol; + } + function getSymbolOfNode(node) { + return getMergedSymbol(node.symbol); + } + function getParentOfSymbol(symbol) { + return getMergedSymbol(symbol.parent); + } + function getExportSymbolOfValueSymbolIfExported(symbol) { + return symbol && (symbol.flags & 1048576 /* ExportValue */) !== 0 + ? getMergedSymbol(symbol.exportSymbol) + : symbol; + } + function symbolIsValue(symbol) { + // If it is an instantiated symbol, then it is a value if the symbol it is an + // instantiation of is a value. + if (symbol.flags & 16777216 /* Instantiated */) { + return symbolIsValue(getSymbolLinks(symbol).target); + } + // If the symbol has the value flag, it is trivially a value. + if (symbol.flags & 107455 /* Value */) { + return true; + } + // If it is an alias, then it is a value if the symbol it resolves to is a value. + if (symbol.flags & 8388608 /* Alias */) { + return (resolveAlias(symbol).flags & 107455 /* Value */) !== 0; + } + return false; + } + function findConstructorDeclaration(node) { + var members = node.members; + for (var _i = 0; _i < members.length; _i++) { + var member = members[_i]; + if (member.kind === 144 /* Constructor */ && ts.nodeIsPresent(member.body)) { + return member; + } + } + } + function createType(flags) { + var result = new Type(checker, flags); + result.id = typeCount++; + return result; + } + function createIntrinsicType(kind, intrinsicName) { + var type = createType(kind); + type.intrinsicName = intrinsicName; + return type; + } + function createObjectType(kind, symbol) { + var type = createType(kind); + type.symbol = symbol; + return type; + } + // A reserved member name starts with two underscores, but the third character cannot be an underscore + // or the @ symbol. A third underscore indicates an escaped form of an identifer that started + // with at least two underscores. The @ character indicates that the name is denoted by a well known ES + // Symbol instance. + function isReservedMemberName(name) { + return name.charCodeAt(0) === 95 /* _ */ && + name.charCodeAt(1) === 95 /* _ */ && + name.charCodeAt(2) !== 95 /* _ */ && + name.charCodeAt(2) !== 64 /* at */; + } + function getNamedMembers(members) { + var result; + for (var id in members) { + if (ts.hasProperty(members, id)) { + if (!isReservedMemberName(id)) { + if (!result) + result = []; + var symbol = members[id]; + if (symbolIsValue(symbol)) { + result.push(symbol); + } + } + } + } + return result || emptyArray; + } + function setObjectTypeMembers(type, members, callSignatures, constructSignatures, stringIndexType, numberIndexType) { + type.members = members; + type.properties = getNamedMembers(members); + type.callSignatures = callSignatures; + type.constructSignatures = constructSignatures; + if (stringIndexType) + type.stringIndexType = stringIndexType; + if (numberIndexType) + type.numberIndexType = numberIndexType; + return type; + } + function createAnonymousType(symbol, members, callSignatures, constructSignatures, stringIndexType, numberIndexType) { + return setObjectTypeMembers(createObjectType(65536 /* Anonymous */, symbol), members, callSignatures, constructSignatures, stringIndexType, numberIndexType); + } + function forEachSymbolTableInScope(enclosingDeclaration, callback) { + var result; + for (var location_1 = enclosingDeclaration; location_1; location_1 = location_1.parent) { + // Locals of a source file are not in scope (because they get merged into the global symbol table) + if (location_1.locals && !isGlobalSourceFile(location_1)) { + if (result = callback(location_1.locals)) { + return result; + } + } + switch (location_1.kind) { + case 248 /* SourceFile */: + if (!ts.isExternalModule(location_1)) { + break; + } + case 218 /* ModuleDeclaration */: + if (result = callback(getSymbolOfNode(location_1).exports)) { + return result; + } + break; + case 214 /* ClassDeclaration */: + case 215 /* InterfaceDeclaration */: + if (result = callback(getSymbolOfNode(location_1).members)) { + return result; + } + break; + } + } + return callback(globals); + } + function getQualifiedLeftMeaning(rightMeaning) { + // If we are looking in value space, the parent meaning is value, other wise it is namespace + return rightMeaning === 107455 /* Value */ ? 107455 /* Value */ : 1536 /* Namespace */; + } + function getAccessibleSymbolChain(symbol, enclosingDeclaration, meaning, useOnlyExternalAliasing) { + function getAccessibleSymbolChainFromSymbolTable(symbols) { + function canQualifySymbol(symbolFromSymbolTable, meaning) { + // If the symbol is equivalent and doesn't need further qualification, this symbol is accessible + if (!needsQualification(symbolFromSymbolTable, enclosingDeclaration, meaning)) { + return true; + } + // If symbol needs qualification, make sure that parent is accessible, if it is then this symbol is accessible too + var accessibleParent = getAccessibleSymbolChain(symbolFromSymbolTable.parent, enclosingDeclaration, getQualifiedLeftMeaning(meaning), useOnlyExternalAliasing); + return !!accessibleParent; + } + function isAccessible(symbolFromSymbolTable, resolvedAliasSymbol) { + if (symbol === (resolvedAliasSymbol || symbolFromSymbolTable)) { + // if the symbolFromSymbolTable is not external module (it could be if it was determined as ambient external module and would be in globals table) + // and if symbolfrom symbolTable or alias resolution matches the symbol, + // check the symbol can be qualified, it is only then this symbol is accessible + return !ts.forEach(symbolFromSymbolTable.declarations, hasExternalModuleSymbol) && + canQualifySymbol(symbolFromSymbolTable, meaning); + } + } + // If symbol is directly available by its name in the symbol table + if (isAccessible(ts.lookUp(symbols, symbol.name))) { + return [symbol]; + } + // Check if symbol is any of the alias + return ts.forEachValue(symbols, function (symbolFromSymbolTable) { + if (symbolFromSymbolTable.flags & 8388608 /* Alias */ + && symbolFromSymbolTable.name !== "export=" + && !ts.getDeclarationOfKind(symbolFromSymbolTable, 230 /* ExportSpecifier */)) { + if (!useOnlyExternalAliasing || + // Is this external alias, then use it to name + ts.forEach(symbolFromSymbolTable.declarations, ts.isExternalModuleImportEqualsDeclaration)) { + var resolvedImportedSymbol = resolveAlias(symbolFromSymbolTable); + if (isAccessible(symbolFromSymbolTable, resolveAlias(symbolFromSymbolTable))) { + return [symbolFromSymbolTable]; + } + // Look in the exported members, if we can find accessibleSymbolChain, symbol is accessible using this chain + // but only if the symbolFromSymbolTable can be qualified + var accessibleSymbolsFromExports = resolvedImportedSymbol.exports ? getAccessibleSymbolChainFromSymbolTable(resolvedImportedSymbol.exports) : undefined; + if (accessibleSymbolsFromExports && canQualifySymbol(symbolFromSymbolTable, getQualifiedLeftMeaning(meaning))) { + return [symbolFromSymbolTable].concat(accessibleSymbolsFromExports); + } + } + } + }); + } + if (symbol) { + return forEachSymbolTableInScope(enclosingDeclaration, getAccessibleSymbolChainFromSymbolTable); + } + } + function needsQualification(symbol, enclosingDeclaration, meaning) { + var qualify = false; + forEachSymbolTableInScope(enclosingDeclaration, function (symbolTable) { + // If symbol of this name is not available in the symbol table we are ok + if (!ts.hasProperty(symbolTable, symbol.name)) { + // Continue to the next symbol table + return false; + } + // If the symbol with this name is present it should refer to the symbol + var symbolFromSymbolTable = symbolTable[symbol.name]; + if (symbolFromSymbolTable === symbol) { + // No need to qualify + return true; + } + // Qualify if the symbol from symbol table has same meaning as expected + symbolFromSymbolTable = (symbolFromSymbolTable.flags & 8388608 /* Alias */ && !ts.getDeclarationOfKind(symbolFromSymbolTable, 230 /* ExportSpecifier */)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; + if (symbolFromSymbolTable.flags & meaning) { + qualify = true; + return true; + } + // Continue to the next symbol table + return false; + }); + return qualify; + } + function isSymbolAccessible(symbol, enclosingDeclaration, meaning) { + if (symbol && enclosingDeclaration && !(symbol.flags & 262144 /* TypeParameter */)) { + var initialSymbol = symbol; + var meaningToLook = meaning; + while (symbol) { + // Symbol is accessible if it by itself is accessible + var accessibleSymbolChain = getAccessibleSymbolChain(symbol, enclosingDeclaration, meaningToLook, /*useOnlyExternalAliasing*/ false); + if (accessibleSymbolChain) { + var hasAccessibleDeclarations = hasVisibleDeclarations(accessibleSymbolChain[0]); + if (!hasAccessibleDeclarations) { + return { + accessibility: 1 /* NotAccessible */, + errorSymbolName: symbolToString(initialSymbol, enclosingDeclaration, meaning), + errorModuleName: symbol !== initialSymbol ? symbolToString(symbol, enclosingDeclaration, 1536 /* Namespace */) : undefined + }; + } + return hasAccessibleDeclarations; + } + // If we haven't got the accessible symbol, it doesn't mean the symbol is actually inaccessible. + // It could be a qualified symbol and hence verify the path + // e.g.: + // module m { + // export class c { + // } + // } + // let x: typeof m.c + // In the above example when we start with checking if typeof m.c symbol is accessible, + // we are going to see if c can be accessed in scope directly. + // But it can't, hence the accessible is going to be undefined, but that doesn't mean m.c is inaccessible + // It is accessible if the parent m is accessible because then m.c can be accessed through qualification + meaningToLook = getQualifiedLeftMeaning(meaning); + symbol = getParentOfSymbol(symbol); + } + // This could be a symbol that is not exported in the external module + // or it could be a symbol from different external module that is not aliased and hence cannot be named + var symbolExternalModule = ts.forEach(initialSymbol.declarations, getExternalModuleContainer); + if (symbolExternalModule) { + var enclosingExternalModule = getExternalModuleContainer(enclosingDeclaration); + if (symbolExternalModule !== enclosingExternalModule) { + // name from different external module that is not visible + return { + accessibility: 2 /* CannotBeNamed */, + errorSymbolName: symbolToString(initialSymbol, enclosingDeclaration, meaning), + errorModuleName: symbolToString(symbolExternalModule) + }; + } + } + // Just a local name that is not accessible + return { + accessibility: 1 /* NotAccessible */, + errorSymbolName: symbolToString(initialSymbol, enclosingDeclaration, meaning) + }; + } + return { accessibility: 0 /* Accessible */ }; + function getExternalModuleContainer(declaration) { + for (; declaration; declaration = declaration.parent) { + if (hasExternalModuleSymbol(declaration)) { + return getSymbolOfNode(declaration); + } + } + } + } + function hasExternalModuleSymbol(declaration) { + return (declaration.kind === 218 /* ModuleDeclaration */ && declaration.name.kind === 9 /* StringLiteral */) || + (declaration.kind === 248 /* SourceFile */ && ts.isExternalModule(declaration)); + } + function hasVisibleDeclarations(symbol) { + var aliasesToMakeVisible; + if (ts.forEach(symbol.declarations, function (declaration) { return !getIsDeclarationVisible(declaration); })) { + return undefined; + } + return { accessibility: 0 /* Accessible */, aliasesToMakeVisible: aliasesToMakeVisible }; + function getIsDeclarationVisible(declaration) { + if (!isDeclarationVisible(declaration)) { + // Mark the unexported alias as visible if its parent is visible + // because these kind of aliases can be used to name types in declaration file + var anyImportSyntax = getAnyImportSyntax(declaration); + if (anyImportSyntax && + !(anyImportSyntax.flags & 1 /* Export */) && + isDeclarationVisible(anyImportSyntax.parent)) { + getNodeLinks(declaration).isVisible = true; + if (aliasesToMakeVisible) { + if (!ts.contains(aliasesToMakeVisible, anyImportSyntax)) { + aliasesToMakeVisible.push(anyImportSyntax); + } + } + else { + aliasesToMakeVisible = [anyImportSyntax]; + } + return true; + } + // Declaration is not visible + return false; + } + return true; + } + } + function isEntityNameVisible(entityName, enclosingDeclaration) { + // get symbol of the first identifier of the entityName + var meaning; + if (entityName.parent.kind === 154 /* TypeQuery */) { + // Typeof value + meaning = 107455 /* Value */ | 1048576 /* ExportValue */; + } + else if (entityName.kind === 135 /* QualifiedName */ || entityName.kind === 166 /* PropertyAccessExpression */ || + entityName.parent.kind === 221 /* ImportEqualsDeclaration */) { + // Left identifier from type reference or TypeAlias + // Entity name of the import declaration + meaning = 1536 /* Namespace */; + } + else { + // Type Reference or TypeAlias entity = Identifier + meaning = 793056 /* Type */; + } + var firstIdentifier = getFirstIdentifier(entityName); + var symbol = resolveName(enclosingDeclaration, firstIdentifier.text, meaning, /*nodeNotFoundErrorMessage*/ undefined, /*nameArg*/ undefined); + // Verify if the symbol is accessible + return (symbol && hasVisibleDeclarations(symbol)) || { + accessibility: 1 /* NotAccessible */, + errorSymbolName: ts.getTextOfNode(firstIdentifier), + errorNode: firstIdentifier + }; + } + function writeKeyword(writer, kind) { + writer.writeKeyword(ts.tokenToString(kind)); + } + function writePunctuation(writer, kind) { + writer.writePunctuation(ts.tokenToString(kind)); + } + function writeSpace(writer) { + writer.writeSpace(" "); + } + function symbolToString(symbol, enclosingDeclaration, meaning) { + var writer = ts.getSingleLineStringWriter(); + getSymbolDisplayBuilder().buildSymbolDisplay(symbol, writer, enclosingDeclaration, meaning); + var result = writer.string(); + ts.releaseStringWriter(writer); + return result; + } + function signatureToString(signature, enclosingDeclaration, flags) { + var writer = ts.getSingleLineStringWriter(); + getSymbolDisplayBuilder().buildSignatureDisplay(signature, writer, enclosingDeclaration, flags); + var result = writer.string(); + ts.releaseStringWriter(writer); + return result; + } + function typeToString(type, enclosingDeclaration, flags) { + var writer = ts.getSingleLineStringWriter(); + getSymbolDisplayBuilder().buildTypeDisplay(type, writer, enclosingDeclaration, flags); + var result = writer.string(); + ts.releaseStringWriter(writer); + var maxLength = compilerOptions.noErrorTruncation || flags & 4 /* NoTruncation */ ? undefined : 100; + if (maxLength && result.length >= maxLength) { + result = result.substr(0, maxLength - "...".length) + "..."; + } + return result; + } + function getTypeAliasForTypeLiteral(type) { + if (type.symbol && type.symbol.flags & 2048 /* TypeLiteral */) { + var node = type.symbol.declarations[0].parent; + while (node.kind === 160 /* ParenthesizedType */) { + node = node.parent; + } + if (node.kind === 216 /* TypeAliasDeclaration */) { + return getSymbolOfNode(node); + } + } + return undefined; + } + function getSymbolDisplayBuilder() { + function getNameOfSymbol(symbol) { + if (symbol.declarations && symbol.declarations.length) { + var declaration = symbol.declarations[0]; + if (declaration.name) { + return ts.declarationNameToString(declaration.name); + } + switch (declaration.kind) { + case 186 /* ClassExpression */: + return "(Anonymous class)"; + case 173 /* FunctionExpression */: + case 174 /* ArrowFunction */: + return "(Anonymous function)"; + } + } + return symbol.name; + } + /** + * Writes only the name of the symbol out to the writer. Uses the original source text + * for the name of the symbol if it is available to match how the user inputted the name. + */ + function appendSymbolNameOnly(symbol, writer) { + writer.writeSymbol(getNameOfSymbol(symbol), symbol); + } + /** + * Enclosing declaration is optional when we don't want to get qualified name in the enclosing declaration scope + * Meaning needs to be specified if the enclosing declaration is given + */ + function buildSymbolDisplay(symbol, writer, enclosingDeclaration, meaning, flags, typeFlags) { + var parentSymbol; + function appendParentTypeArgumentsAndSymbolName(symbol) { + if (parentSymbol) { + // Write type arguments of instantiated class/interface here + if (flags & 1 /* WriteTypeParametersOrArguments */) { + if (symbol.flags & 16777216 /* Instantiated */) { + buildDisplayForTypeArgumentsAndDelimiters(getTypeParametersOfClassOrInterface(parentSymbol), symbol.mapper, writer, enclosingDeclaration); + } + else { + buildTypeParameterDisplayFromSymbol(parentSymbol, writer, enclosingDeclaration); + } + } + writePunctuation(writer, 21 /* DotToken */); + } + parentSymbol = symbol; + appendSymbolNameOnly(symbol, writer); + } + // Let the writer know we just wrote out a symbol. The declaration emitter writer uses + // this to determine if an import it has previously seen (and not written out) needs + // to be written to the file once the walk of the tree is complete. + // + // NOTE(cyrusn): This approach feels somewhat unfortunate. A simple pass over the tree + // up front (for example, during checking) could determine if we need to emit the imports + // and we could then access that data during declaration emit. + writer.trackSymbol(symbol, enclosingDeclaration, meaning); + function walkSymbol(symbol, meaning) { + if (symbol) { + var accessibleSymbolChain = getAccessibleSymbolChain(symbol, enclosingDeclaration, meaning, !!(flags & 2 /* UseOnlyExternalAliasing */)); + if (!accessibleSymbolChain || + needsQualification(accessibleSymbolChain[0], enclosingDeclaration, accessibleSymbolChain.length === 1 ? meaning : getQualifiedLeftMeaning(meaning))) { + // Go up and add our parent. + walkSymbol(getParentOfSymbol(accessibleSymbolChain ? accessibleSymbolChain[0] : symbol), getQualifiedLeftMeaning(meaning)); + } + if (accessibleSymbolChain) { + for (var _i = 0; _i < accessibleSymbolChain.length; _i++) { + var accessibleSymbol = accessibleSymbolChain[_i]; + appendParentTypeArgumentsAndSymbolName(accessibleSymbol); + } + } + else { + // If we didn't find accessible symbol chain for this symbol, break if this is external module + if (!parentSymbol && ts.forEach(symbol.declarations, hasExternalModuleSymbol)) { + return; + } + // if this is anonymous type break + if (symbol.flags & 2048 /* TypeLiteral */ || symbol.flags & 4096 /* ObjectLiteral */) { + return; + } + appendParentTypeArgumentsAndSymbolName(symbol); + } + } + } + // Get qualified name if the symbol is not a type parameter + // and there is an enclosing declaration or we specifically + // asked for it + var isTypeParameter = symbol.flags & 262144 /* TypeParameter */; + var typeFormatFlag = 128 /* UseFullyQualifiedType */ & typeFlags; + if (!isTypeParameter && (enclosingDeclaration || typeFormatFlag)) { + walkSymbol(symbol, meaning); + return; + } + return appendParentTypeArgumentsAndSymbolName(symbol); + } + function buildTypeDisplay(type, writer, enclosingDeclaration, globalFlags, symbolStack) { + var globalFlagsToPass = globalFlags & 16 /* WriteOwnNameForAnyLike */; + var inObjectTypeLiteral = false; + return writeType(type, globalFlags); + function writeType(type, flags) { + // Write undefined/null type as any + if (type.flags & 16777343 /* Intrinsic */) { + // Special handling for unknown / resolving types, they should show up as any and not unknown or __resolving + writer.writeKeyword(!(globalFlags & 16 /* WriteOwnNameForAnyLike */) && isTypeAny(type) + ? "any" + : type.intrinsicName); + } + else if (type.flags & 33554432 /* ThisType */) { + if (inObjectTypeLiteral) { + writer.reportInaccessibleThisError(); + } + writer.writeKeyword("this"); + } + else if (type.flags & 4096 /* Reference */) { + writeTypeReference(type, flags); + } + else if (type.flags & (1024 /* Class */ | 2048 /* Interface */ | 128 /* Enum */ | 512 /* TypeParameter */)) { + // The specified symbol flags need to be reinterpreted as type flags + buildSymbolDisplay(type.symbol, writer, enclosingDeclaration, 793056 /* Type */, 0 /* None */, flags); + } + else if (type.flags & 8192 /* Tuple */) { + writeTupleType(type); + } + else if (type.flags & 49152 /* UnionOrIntersection */) { + writeUnionOrIntersectionType(type, flags); + } + else if (type.flags & 65536 /* Anonymous */) { + writeAnonymousType(type, flags); + } + else if (type.flags & 256 /* StringLiteral */) { + writer.writeStringLiteral(type.text); + } + else { + // Should never get here + // { ... } + writePunctuation(writer, 15 /* OpenBraceToken */); + writeSpace(writer); + writePunctuation(writer, 22 /* DotDotDotToken */); + writeSpace(writer); + writePunctuation(writer, 16 /* CloseBraceToken */); + } + } + function writeTypeList(types, delimiter) { + for (var i = 0; i < types.length; i++) { + if (i > 0) { + if (delimiter !== 24 /* CommaToken */) { + writeSpace(writer); + } + writePunctuation(writer, delimiter); + writeSpace(writer); + } + writeType(types[i], delimiter === 24 /* CommaToken */ ? 0 /* None */ : 64 /* InElementType */); + } + } + function writeSymbolTypeReference(symbol, typeArguments, pos, end, flags) { + // Unnamed function expressions and arrow functions have reserved names that we don't want to display + if (symbol.flags & 32 /* Class */ || !isReservedMemberName(symbol.name)) { + buildSymbolDisplay(symbol, writer, enclosingDeclaration, 793056 /* Type */, 0 /* None */, flags); + } + if (pos < end) { + writePunctuation(writer, 25 /* LessThanToken */); + writeType(typeArguments[pos++], 0 /* None */); + while (pos < end) { + writePunctuation(writer, 24 /* CommaToken */); + writeSpace(writer); + writeType(typeArguments[pos++], 0 /* None */); + } + writePunctuation(writer, 27 /* 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 */); + } + else { + // Write the type reference in the format f
.g.C where A and B are type arguments + // for outer type parameters, and f and g are the respective declaring containers of those + // type parameters. + var outerTypeParameters = type.target.outerTypeParameters; + var i = 0; + if (outerTypeParameters) { + var length_1 = outerTypeParameters.length; + while (i < length_1) { + // Find group of type arguments for type parameters with the same declaring container. + var start = i; + var parent_3 = getParentSymbolOfTypeParameter(outerTypeParameters[i]); + do { + i++; + } while (i < length_1 && getParentSymbolOfTypeParameter(outerTypeParameters[i]) === parent_3); + // When type parameters are their own type arguments for the whole group (i.e. we have + // the default outer type arguments), we don't show the group. + if (!ts.rangeEquals(outerTypeParameters, typeArguments, start, i)) { + writeSymbolTypeReference(parent_3, typeArguments, start, i, flags); + writePunctuation(writer, 21 /* DotToken */); + } + } + } + var typeParameterCount = (type.target.typeParameters || emptyArray).length; + writeSymbolTypeReference(type.symbol, typeArguments, i, typeParameterCount, flags); + } + } + function writeTupleType(type) { + writePunctuation(writer, 19 /* OpenBracketToken */); + writeTypeList(type.elementTypes, 24 /* CommaToken */); + writePunctuation(writer, 20 /* CloseBracketToken */); + } + function writeUnionOrIntersectionType(type, flags) { + if (flags & 64 /* InElementType */) { + writePunctuation(writer, 17 /* OpenParenToken */); + } + writeTypeList(type.types, type.flags & 16384 /* Union */ ? 47 /* BarToken */ : 46 /* AmpersandToken */); + if (flags & 64 /* InElementType */) { + writePunctuation(writer, 18 /* CloseParenToken */); + } + } + function writeAnonymousType(type, flags) { + var symbol = type.symbol; + if (symbol) { + // Always use 'typeof T' for type of class, enum, and module objects + if (symbol.flags & (32 /* Class */ | 384 /* Enum */ | 512 /* ValueModule */)) { + writeTypeofSymbol(type, flags); + } + else if (shouldWriteTypeOfFunctionSymbol()) { + writeTypeofSymbol(type, flags); + } + else if (ts.contains(symbolStack, symbol)) { + // If type is an anonymous type literal in a type alias declaration, use type alias name + var typeAlias = getTypeAliasForTypeLiteral(type); + if (typeAlias) { + // The specified symbol flags need to be reinterpreted as type flags + buildSymbolDisplay(typeAlias, writer, enclosingDeclaration, 793056 /* Type */, 0 /* None */, flags); + } + else { + // Recursive usage, use any + writeKeyword(writer, 117 /* AnyKeyword */); + } + } + else { + // Since instantiations of the same anonymous type have the same symbol, tracking symbols instead + // of types allows us to catch circular references to instantiations of the same anonymous type + if (!symbolStack) { + symbolStack = []; + } + symbolStack.push(symbol); + writeLiteralType(type, flags); + symbolStack.pop(); + } + } + else { + // Anonymous types with no symbol are never circular + writeLiteralType(type, flags); + } + function shouldWriteTypeOfFunctionSymbol() { + var isStaticMethodSymbol = !!(symbol.flags & 8192 /* Method */ && + ts.forEach(symbol.declarations, function (declaration) { return declaration.flags & 128 /* Static */; })); + var isNonLocalFunctionSymbol = !!(symbol.flags & 16 /* Function */) && + (symbol.parent || + ts.forEach(symbol.declarations, function (declaration) { + return declaration.parent.kind === 248 /* SourceFile */ || declaration.parent.kind === 219 /* ModuleBlock */; + })); + if (isStaticMethodSymbol || isNonLocalFunctionSymbol) { + // typeof is allowed only for static/non local functions + return !!(flags & 2 /* UseTypeOfFunction */) || + (ts.contains(symbolStack, symbol)); // it is type of the symbol uses itself recursively + } + } + } + function writeTypeofSymbol(type, typeFormatFlags) { + writeKeyword(writer, 101 /* TypeOfKeyword */); + writeSpace(writer); + buildSymbolDisplay(type.symbol, writer, enclosingDeclaration, 107455 /* Value */, 0 /* None */, typeFormatFlags); + } + function getIndexerParameterName(type, indexKind, fallbackName) { + var declaration = getIndexDeclarationOfSymbol(type.symbol, indexKind); + if (!declaration) { + // declaration might not be found if indexer was added from the contextual type. + // in this case use fallback name + return fallbackName; + } + ts.Debug.assert(declaration.parameters.length !== 0); + return ts.declarationNameToString(declaration.parameters[0].name); + } + function writeLiteralType(type, flags) { + var resolved = resolveStructuredTypeMembers(type); + if (!resolved.properties.length && !resolved.stringIndexType && !resolved.numberIndexType) { + if (!resolved.callSignatures.length && !resolved.constructSignatures.length) { + writePunctuation(writer, 15 /* OpenBraceToken */); + writePunctuation(writer, 16 /* CloseBraceToken */); + return; + } + if (resolved.callSignatures.length === 1 && !resolved.constructSignatures.length) { + if (flags & 64 /* InElementType */) { + writePunctuation(writer, 17 /* OpenParenToken */); + } + buildSignatureDisplay(resolved.callSignatures[0], writer, enclosingDeclaration, globalFlagsToPass | 8 /* WriteArrowStyleSignature */, symbolStack); + if (flags & 64 /* InElementType */) { + writePunctuation(writer, 18 /* CloseParenToken */); + } + return; + } + if (resolved.constructSignatures.length === 1 && !resolved.callSignatures.length) { + if (flags & 64 /* InElementType */) { + writePunctuation(writer, 17 /* OpenParenToken */); + } + writeKeyword(writer, 92 /* NewKeyword */); + writeSpace(writer); + buildSignatureDisplay(resolved.constructSignatures[0], writer, enclosingDeclaration, globalFlagsToPass | 8 /* WriteArrowStyleSignature */, symbolStack); + if (flags & 64 /* InElementType */) { + writePunctuation(writer, 18 /* CloseParenToken */); + } + return; + } + } + var saveInObjectTypeLiteral = inObjectTypeLiteral; + inObjectTypeLiteral = true; + writePunctuation(writer, 15 /* 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, symbolStack); + writePunctuation(writer, 23 /* SemicolonToken */); + writer.writeLine(); + } + for (var _b = 0, _c = resolved.constructSignatures; _b < _c.length; _b++) { + var signature = _c[_b]; + writeKeyword(writer, 92 /* NewKeyword */); + writeSpace(writer); + buildSignatureDisplay(signature, writer, enclosingDeclaration, globalFlagsToPass, symbolStack); + writePunctuation(writer, 23 /* SemicolonToken */); + writer.writeLine(); + } + if (resolved.stringIndexType) { + // [x: string]: + writePunctuation(writer, 19 /* OpenBracketToken */); + writer.writeParameter(getIndexerParameterName(resolved, 0 /* String */, /*fallbackName*/ "x")); + writePunctuation(writer, 54 /* ColonToken */); + writeSpace(writer); + writeKeyword(writer, 130 /* StringKeyword */); + writePunctuation(writer, 20 /* CloseBracketToken */); + writePunctuation(writer, 54 /* ColonToken */); + writeSpace(writer); + writeType(resolved.stringIndexType, 0 /* None */); + writePunctuation(writer, 23 /* SemicolonToken */); + writer.writeLine(); + } + if (resolved.numberIndexType) { + // [x: number]: + writePunctuation(writer, 19 /* OpenBracketToken */); + writer.writeParameter(getIndexerParameterName(resolved, 1 /* Number */, /*fallbackName*/ "x")); + writePunctuation(writer, 54 /* ColonToken */); + writeSpace(writer); + writeKeyword(writer, 128 /* NumberKeyword */); + writePunctuation(writer, 20 /* CloseBracketToken */); + writePunctuation(writer, 54 /* ColonToken */); + writeSpace(writer); + writeType(resolved.numberIndexType, 0 /* None */); + writePunctuation(writer, 23 /* SemicolonToken */); + writer.writeLine(); + } + for (var _d = 0, _e = resolved.properties; _d < _e.length; _d++) { + var p = _e[_d]; + var t = getTypeOfSymbol(p); + if (p.flags & (16 /* Function */ | 8192 /* Method */) && !getPropertiesOfObjectType(t).length) { + var signatures = getSignaturesOfType(t, 0 /* Call */); + for (var _f = 0; _f < signatures.length; _f++) { + var signature = signatures[_f]; + buildSymbolDisplay(p, writer); + if (p.flags & 536870912 /* Optional */) { + writePunctuation(writer, 53 /* QuestionToken */); + } + buildSignatureDisplay(signature, writer, enclosingDeclaration, globalFlagsToPass, symbolStack); + writePunctuation(writer, 23 /* SemicolonToken */); + writer.writeLine(); + } + } + else { + buildSymbolDisplay(p, writer); + if (p.flags & 536870912 /* Optional */) { + writePunctuation(writer, 53 /* QuestionToken */); + } + writePunctuation(writer, 54 /* ColonToken */); + writeSpace(writer); + writeType(t, 0 /* None */); + writePunctuation(writer, 23 /* SemicolonToken */); + writer.writeLine(); + } + } + writer.decreaseIndent(); + writePunctuation(writer, 16 /* CloseBraceToken */); + inObjectTypeLiteral = saveInObjectTypeLiteral; + } + } + function buildTypeParameterDisplayFromSymbol(symbol, writer, enclosingDeclaraiton, flags) { + var targetSymbol = getTargetSymbol(symbol); + if (targetSymbol.flags & 32 /* Class */ || targetSymbol.flags & 64 /* Interface */ || targetSymbol.flags & 524288 /* TypeAlias */) { + buildDisplayForTypeParametersAndDelimiters(getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol), writer, enclosingDeclaraiton, flags); + } + } + function buildTypeParameterDisplay(tp, writer, enclosingDeclaration, flags, symbolStack) { + appendSymbolNameOnly(tp.symbol, writer); + var constraint = getConstraintOfTypeParameter(tp); + if (constraint) { + writeSpace(writer); + writeKeyword(writer, 83 /* ExtendsKeyword */); + writeSpace(writer); + buildTypeDisplay(constraint, writer, enclosingDeclaration, flags, symbolStack); + } + } + function buildParameterDisplay(p, writer, enclosingDeclaration, flags, symbolStack) { + var parameterNode = p.valueDeclaration; + if (ts.isRestParameter(parameterNode)) { + writePunctuation(writer, 22 /* DotDotDotToken */); + } + appendSymbolNameOnly(p, writer); + if (isOptionalParameter(parameterNode)) { + writePunctuation(writer, 53 /* QuestionToken */); + } + writePunctuation(writer, 54 /* ColonToken */); + writeSpace(writer); + buildTypeDisplay(getTypeOfSymbol(p), writer, enclosingDeclaration, flags, symbolStack); + } + function buildDisplayForTypeParametersAndDelimiters(typeParameters, writer, enclosingDeclaration, flags, symbolStack) { + if (typeParameters && typeParameters.length) { + writePunctuation(writer, 25 /* LessThanToken */); + for (var i = 0; i < typeParameters.length; i++) { + if (i > 0) { + writePunctuation(writer, 24 /* CommaToken */); + writeSpace(writer); + } + buildTypeParameterDisplay(typeParameters[i], writer, enclosingDeclaration, flags, symbolStack); + } + writePunctuation(writer, 27 /* GreaterThanToken */); + } + } + function buildDisplayForTypeArgumentsAndDelimiters(typeParameters, mapper, writer, enclosingDeclaration, flags, symbolStack) { + if (typeParameters && typeParameters.length) { + writePunctuation(writer, 25 /* LessThanToken */); + for (var i = 0; i < typeParameters.length; i++) { + if (i > 0) { + writePunctuation(writer, 24 /* CommaToken */); + writeSpace(writer); + } + buildTypeDisplay(mapper(typeParameters[i]), writer, enclosingDeclaration, 0 /* None */); + } + writePunctuation(writer, 27 /* GreaterThanToken */); + } + } + function buildDisplayForParametersAndDelimiters(parameters, writer, enclosingDeclaration, flags, symbolStack) { + writePunctuation(writer, 17 /* OpenParenToken */); + for (var i = 0; i < parameters.length; i++) { + if (i > 0) { + writePunctuation(writer, 24 /* CommaToken */); + writeSpace(writer); + } + buildParameterDisplay(parameters[i], writer, enclosingDeclaration, flags, symbolStack); + } + writePunctuation(writer, 18 /* CloseParenToken */); + } + function buildReturnTypeDisplay(signature, writer, enclosingDeclaration, flags, symbolStack) { + if (flags & 8 /* WriteArrowStyleSignature */) { + writeSpace(writer); + writePunctuation(writer, 34 /* EqualsGreaterThanToken */); + } + else { + writePunctuation(writer, 54 /* ColonToken */); + } + writeSpace(writer); + var returnType; + if (signature.typePredicate) { + writer.writeParameter(signature.typePredicate.parameterName); + writeSpace(writer); + writeKeyword(writer, 124 /* IsKeyword */); + writeSpace(writer); + returnType = signature.typePredicate.type; + } + else { + returnType = getReturnTypeOfSignature(signature); + } + buildTypeDisplay(returnType, writer, enclosingDeclaration, flags, symbolStack); + } + function buildSignatureDisplay(signature, writer, enclosingDeclaration, flags, symbolStack) { + if (signature.target && (flags & 32 /* WriteTypeArgumentsOfSignature */)) { + // Instantiated signature, write type arguments instead + // This is achieved by passing in the mapper separately + buildDisplayForTypeArgumentsAndDelimiters(signature.target.typeParameters, signature.mapper, writer, enclosingDeclaration); + } + else { + buildDisplayForTypeParametersAndDelimiters(signature.typeParameters, writer, enclosingDeclaration, flags, symbolStack); + } + buildDisplayForParametersAndDelimiters(signature.parameters, writer, enclosingDeclaration, flags, symbolStack); + buildReturnTypeDisplay(signature, writer, enclosingDeclaration, flags, symbolStack); + } + return _displayBuilder || (_displayBuilder = { + buildSymbolDisplay: buildSymbolDisplay, + buildTypeDisplay: buildTypeDisplay, + buildTypeParameterDisplay: buildTypeParameterDisplay, + buildParameterDisplay: buildParameterDisplay, + buildDisplayForParametersAndDelimiters: buildDisplayForParametersAndDelimiters, + buildDisplayForTypeParametersAndDelimiters: buildDisplayForTypeParametersAndDelimiters, + buildTypeParameterDisplayFromSymbol: buildTypeParameterDisplayFromSymbol, + buildSignatureDisplay: buildSignatureDisplay, + buildReturnTypeDisplay: buildReturnTypeDisplay + }); + } + function isDeclarationVisible(node) { + function getContainingExternalModule(node) { + for (; node; node = node.parent) { + if (node.kind === 218 /* ModuleDeclaration */) { + if (node.name.kind === 9 /* StringLiteral */) { + return node; + } + } + else if (node.kind === 248 /* SourceFile */) { + return ts.isExternalModule(node) ? node : undefined; + } + } + ts.Debug.fail("getContainingModule cant reach here"); + } + function isUsedInExportAssignment(node) { + // Get source File and see if it is external module and has export assigned symbol + var externalModule = getContainingExternalModule(node); + var exportAssignmentSymbol; + var resolvedExportSymbol; + if (externalModule) { + // This is export assigned symbol node + var externalModuleSymbol = getSymbolOfNode(externalModule); + exportAssignmentSymbol = getExportAssignmentSymbol(externalModuleSymbol); + var symbolOfNode = getSymbolOfNode(node); + if (isSymbolUsedInExportAssignment(symbolOfNode)) { + return true; + } + // if symbolOfNode is alias declaration, resolve the symbol declaration and check + if (symbolOfNode.flags & 8388608 /* Alias */) { + return isSymbolUsedInExportAssignment(resolveAlias(symbolOfNode)); + } + } + // Check if the symbol is used in export assignment + function isSymbolUsedInExportAssignment(symbol) { + if (exportAssignmentSymbol === symbol) { + return true; + } + if (exportAssignmentSymbol && !!(exportAssignmentSymbol.flags & 8388608 /* Alias */)) { + // if export assigned symbol is alias declaration, resolve the alias + resolvedExportSymbol = resolvedExportSymbol || resolveAlias(exportAssignmentSymbol); + if (resolvedExportSymbol === symbol) { + return true; + } + // Container of resolvedExportSymbol is visible + return ts.forEach(resolvedExportSymbol.declarations, function (current) { + while (current) { + if (current === node) { + return true; + } + current = current.parent; + } + }); + } + } + } + function determineIfDeclarationIsVisible() { + switch (node.kind) { + case 163 /* BindingElement */: + return isDeclarationVisible(node.parent.parent); + case 211 /* VariableDeclaration */: + if (ts.isBindingPattern(node.name) && + !node.name.elements.length) { + // If the binding pattern is empty, this variable declaration is not visible + return false; + } + // Otherwise fall through + case 218 /* ModuleDeclaration */: + case 214 /* ClassDeclaration */: + case 215 /* InterfaceDeclaration */: + case 216 /* TypeAliasDeclaration */: + case 213 /* FunctionDeclaration */: + case 217 /* EnumDeclaration */: + case 221 /* ImportEqualsDeclaration */: + var parent_4 = getDeclarationContainer(node); + // If the node is not exported or it is not ambient module element (except import declaration) + if (!(ts.getCombinedNodeFlags(node) & 1 /* Export */) && + !(node.kind !== 221 /* ImportEqualsDeclaration */ && parent_4.kind !== 248 /* SourceFile */ && ts.isInAmbientContext(parent_4))) { + return isGlobalSourceFile(parent_4); + } + // Exported members/ambient module elements (exception import declaration) are visible if parent is visible + return isDeclarationVisible(parent_4); + case 141 /* PropertyDeclaration */: + case 140 /* PropertySignature */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: + if (node.flags & (32 /* Private */ | 64 /* Protected */)) { + // Private/protected properties/methods are not visible + return false; + } + // Public properties/methods are visible if its parents are visible, so let it fall into next case statement + case 144 /* Constructor */: + case 148 /* ConstructSignature */: + case 147 /* CallSignature */: + case 149 /* IndexSignature */: + case 138 /* Parameter */: + case 219 /* ModuleBlock */: + case 152 /* FunctionType */: + case 153 /* ConstructorType */: + case 155 /* TypeLiteral */: + case 151 /* TypeReference */: + case 156 /* ArrayType */: + case 157 /* TupleType */: + case 158 /* UnionType */: + case 159 /* IntersectionType */: + case 160 /* ParenthesizedType */: + return isDeclarationVisible(node.parent); + // Default binding, import specifier and namespace import is visible + // only on demand so by default it is not visible + case 223 /* ImportClause */: + case 224 /* NamespaceImport */: + case 226 /* ImportSpecifier */: + return false; + // Type parameters are always visible + case 137 /* TypeParameter */: + // Source file is always visible + case 248 /* SourceFile */: + return true; + // Export assignements do not create name bindings outside the module + case 227 /* ExportAssignment */: + return false; + default: + ts.Debug.fail("isDeclarationVisible unknown: SyntaxKind: " + node.kind); + } + } + if (node) { + var links = getNodeLinks(node); + if (links.isVisible === undefined) { + links.isVisible = !!determineIfDeclarationIsVisible(); + } + return links.isVisible; + } + } + function collectLinkedAliases(node) { + var exportSymbol; + if (node.parent && node.parent.kind === 227 /* ExportAssignment */) { + exportSymbol = resolveName(node.parent, node.text, 107455 /* Value */ | 793056 /* Type */ | 1536 /* Namespace */ | 8388608 /* Alias */, ts.Diagnostics.Cannot_find_name_0, node); + } + else if (node.parent.kind === 230 /* ExportSpecifier */) { + var exportSpecifier = node.parent; + exportSymbol = exportSpecifier.parent.parent.moduleSpecifier ? + getExternalModuleMember(exportSpecifier.parent.parent, exportSpecifier) : + resolveEntityName(exportSpecifier.propertyName || exportSpecifier.name, 107455 /* Value */ | 793056 /* Type */ | 1536 /* Namespace */ | 8388608 /* Alias */); + } + var result = []; + if (exportSymbol) { + buildVisibleNodeList(exportSymbol.declarations); + } + return result; + function buildVisibleNodeList(declarations) { + ts.forEach(declarations, function (declaration) { + getNodeLinks(declaration).isVisible = true; + var resultNode = getAnyImportSyntax(declaration) || declaration; + if (!ts.contains(result, resultNode)) { + result.push(resultNode); + } + if (ts.isInternalModuleImportEqualsDeclaration(declaration)) { + // Add the referenced top container visible + var internalModuleReference = declaration.moduleReference; + var firstIdentifier = getFirstIdentifier(internalModuleReference); + var importSymbol = resolveName(declaration, firstIdentifier.text, 107455 /* Value */ | 793056 /* Type */ | 1536 /* Namespace */, ts.Diagnostics.Cannot_find_name_0, firstIdentifier); + buildVisibleNodeList(importSymbol.declarations); + } + }); + } + } + /** + * Push an entry on the type resolution stack. If an entry with the given target and the given property name + * is already on the stack, and no entries in between already have a type, then a circularity has occurred. + * In this case, the result values of the existing entry and all entries pushed after it are changed to false, + * and the value false is returned. Otherwise, the new entry is just pushed onto the stack, and true is returned. + * In order to see if the same query has already been done before, the target object and the propertyName both + * must match the one passed in. + * + * @param target The symbol, type, or signature whose type is being queried + * @param propertyName The property name that should be used to query the target for its type + */ + function pushTypeResolution(target, propertyName) { + var resolutionCycleStartIndex = findResolutionCycleStartIndex(target, propertyName); + if (resolutionCycleStartIndex >= 0) { + // A cycle was found + var length_2 = resolutionTargets.length; + for (var i = resolutionCycleStartIndex; i < length_2; i++) { + resolutionResults[i] = false; + } + return false; + } + resolutionTargets.push(target); + resolutionResults.push(true); + resolutionPropertyNames.push(propertyName); + return true; + } + function findResolutionCycleStartIndex(target, propertyName) { + for (var i = resolutionTargets.length - 1; i >= 0; i--) { + if (hasType(resolutionTargets[i], resolutionPropertyNames[i])) { + return -1; + } + if (resolutionTargets[i] === target && resolutionPropertyNames[i] === propertyName) { + return i; + } + } + return -1; + } + function hasType(target, propertyName) { + if (propertyName === 0 /* Type */) { + return getSymbolLinks(target).type; + } + if (propertyName === 2 /* DeclaredType */) { + return getSymbolLinks(target).declaredType; + } + if (propertyName === 1 /* ResolvedBaseConstructorType */) { + ts.Debug.assert(!!(target.flags & 1024 /* Class */)); + return target.resolvedBaseConstructorType; + } + if (propertyName === 3 /* ResolvedReturnType */) { + return target.resolvedReturnType; + } + ts.Debug.fail("Unhandled TypeSystemPropertyName " + propertyName); + } + // Pop an entry from the type resolution stack and return its associated result value. The result value will + // be true if no circularities were detected, or false if a circularity was found. + function popTypeResolution() { + resolutionTargets.pop(); + resolutionPropertyNames.pop(); + return resolutionResults.pop(); + } + function getDeclarationContainer(node) { + node = ts.getRootDeclaration(node); + // Parent chain: + // VaribleDeclaration -> VariableDeclarationList -> VariableStatement -> 'Declaration Container' + return node.kind === 211 /* VariableDeclaration */ ? node.parent.parent.parent : node.parent; + } + function getTypeOfPrototypeProperty(prototype) { + // 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'. + var classType = getDeclaredTypeOfSymbol(prototype.parent); + return classType.typeParameters ? createTypeReference(classType, ts.map(classType.typeParameters, function (_) { return anyType; })) : classType; + } + // Return the type of the given property in the given type, or undefined if no such property exists + function getTypeOfPropertyOfType(type, name) { + var prop = getPropertyOfType(type, name); + return prop ? getTypeOfSymbol(prop) : undefined; + } + function isTypeAny(type) { + return type && (type.flags & 1 /* Any */) !== 0; + } + // Return the type of a binding element parent. We check SymbolLinks first to see if a type has been + // assigned by contextual typing. + function getTypeForBindingElementParent(node) { + var symbol = getSymbolOfNode(node); + return symbol && getSymbolLinks(symbol).type || getTypeForVariableLikeDeclaration(node); + } + // Return the inferred type for a binding element + function getTypeForBindingElement(declaration) { + var pattern = declaration.parent; + var parentType = getTypeForBindingElementParent(pattern.parent); + // If parent has the unknown (error) type, then so does this binding element + if (parentType === unknownType) { + return unknownType; + } + // If no type was specified or inferred for parent, or if the specified or inferred type is any, + // infer from the initializer of the binding element if one is present. Otherwise, go with the + // undefined or any type of the parent. + if (!parentType || isTypeAny(parentType)) { + if (declaration.initializer) { + return checkExpressionCached(declaration.initializer); + } + return parentType; + } + var type; + if (pattern.kind === 161 /* ObjectBindingPattern */) { + // Use explicitly specified property name ({ p: xxx } form), or otherwise the implied name ({ p } form) + var name_10 = declaration.propertyName || declaration.name; + // Use type of the specified property, or otherwise, for a numeric name, the type of the numeric index signature, + // or otherwise the type of the string index signature. + type = getTypeOfPropertyOfType(parentType, name_10.text) || + isNumericLiteralName(name_10.text) && getIndexTypeOfType(parentType, 1 /* Number */) || + getIndexTypeOfType(parentType, 0 /* String */); + if (!type) { + error(name_10, ts.Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(parentType), ts.declarationNameToString(name_10)); + return unknownType; + } + } + else { + // This elementType will be used if the specific property corresponding to this index is not + // present (aka the tuple element property). This call also checks that the parentType is in + // fact an iterable or array (depending on target language). + var elementType = checkIteratedTypeOrElementType(parentType, pattern, /*allowStringInput*/ false); + if (!declaration.dotDotDotToken) { + // Use specific property type when parent is a tuple or numeric index type when parent is an array + var propName = "" + ts.indexOf(pattern.elements, declaration); + type = isTupleLikeType(parentType) + ? getTypeOfPropertyOfType(parentType, propName) + : elementType; + if (!type) { + if (isTupleType(parentType)) { + error(declaration, ts.Diagnostics.Tuple_type_0_with_length_1_cannot_be_assigned_to_tuple_with_length_2, typeToString(parentType), parentType.elementTypes.length, pattern.elements.length); + } + else { + error(declaration, ts.Diagnostics.Type_0_has_no_property_1, typeToString(parentType), propName); + } + return unknownType; + } + } + else { + // Rest element has an array type with the same element type as the parent type + type = createArrayType(elementType); + } + } + return type; + } + // Return the inferred type for a variable, parameter, or property declaration + function getTypeForVariableLikeDeclaration(declaration) { + // A variable declared in a for..in statement is always of type any + if (declaration.parent.parent.kind === 200 /* ForInStatement */) { + return anyType; + } + if (declaration.parent.parent.kind === 201 /* ForOfStatement */) { + // checkRightHandSideOfForOf will return undefined if the for-of expression type was + // missing properties/signatures required to get its iteratedType (like + // [Symbol.iterator] or next). This may be because we accessed properties from anyType, + // or it may have led to an error inside getElementTypeOfIterable. + return checkRightHandSideOfForOf(declaration.parent.parent.expression) || anyType; + } + if (ts.isBindingPattern(declaration.parent)) { + return getTypeForBindingElement(declaration); + } + // Use type from type annotation if one is present + if (declaration.type) { + return getTypeFromTypeNode(declaration.type); + } + if (declaration.kind === 138 /* Parameter */) { + var func = declaration.parent; + // For a parameter of a set accessor, use the type of the get accessor if one is present + if (func.kind === 146 /* SetAccessor */ && !ts.hasDynamicName(func)) { + var getter = ts.getDeclarationOfKind(declaration.parent.symbol, 145 /* GetAccessor */); + if (getter) { + return getReturnTypeOfSignature(getSignatureFromDeclaration(getter)); + } + } + // Use contextual parameter type if one is available + var type = getContextuallyTypedParameterType(declaration); + if (type) { + return type; + } + } + // Use the type of the initializer expression if one is present + if (declaration.initializer) { + return checkExpressionCached(declaration.initializer); + } + // If it is a short-hand property assignment, use the type of the identifier + if (declaration.kind === 246 /* ShorthandPropertyAssignment */) { + return checkIdentifier(declaration.name); + } + // If the declaration specifies a binding pattern, use the type implied by the binding pattern + if (ts.isBindingPattern(declaration.name)) { + return getTypeFromBindingPattern(declaration.name, /*includePatternInType*/ false); + } + // No type specified and nothing can be inferred + return undefined; + } + // Return the type implied by a binding pattern element. This is the type of the initializer of the element if + // one is present. Otherwise, if the element is itself a binding pattern, it is the type implied by the binding + // pattern. Otherwise, it is the type any. + function getTypeFromBindingElement(element, includePatternInType) { + if (element.initializer) { + return getWidenedType(checkExpressionCached(element.initializer)); + } + if (ts.isBindingPattern(element.name)) { + return getTypeFromBindingPattern(element.name, includePatternInType); + } + return anyType; + } + // Return the type implied by an object binding pattern + function getTypeFromObjectBindingPattern(pattern, includePatternInType) { + var members = {}; + ts.forEach(pattern.elements, function (e) { + var flags = 4 /* Property */ | 67108864 /* Transient */ | (e.initializer ? 536870912 /* Optional */ : 0); + var name = e.propertyName || e.name; + var symbol = createSymbol(flags, name.text); + symbol.type = getTypeFromBindingElement(e, includePatternInType); + symbol.bindingElement = e; + members[symbol.name] = symbol; + }); + var result = createAnonymousType(undefined, members, emptyArray, emptyArray, undefined, undefined); + if (includePatternInType) { + result.pattern = pattern; + } + return result; + } + // Return the type implied by an array binding pattern + function getTypeFromArrayBindingPattern(pattern, includePatternInType) { + var elements = pattern.elements; + if (elements.length === 0 || elements[elements.length - 1].dotDotDotToken) { + return languageVersion >= 2 /* ES6 */ ? createIterableType(anyType) : anyArrayType; + } + // If the pattern has at least one element, and no rest element, then it should imply a tuple type. + var elementTypes = ts.map(elements, function (e) { return e.kind === 187 /* OmittedExpression */ ? anyType : getTypeFromBindingElement(e, includePatternInType); }); + if (includePatternInType) { + var result = createNewTupleType(elementTypes); + result.pattern = pattern; + return result; + } + return createTupleType(elementTypes); + } + // Return the type implied by a binding pattern. This is the type implied purely by the binding pattern itself + // and without regard to its context (i.e. without regard any type annotation or initializer associated with the + // declaration in which the binding pattern is contained). For example, the implied type of [x, y] is [any, any] + // and the implied type of { x, y: z = 1 } is { x: any; y: number; }. The type implied by a binding pattern is + // used as the contextual type of an initializer associated with the binding pattern. Also, for a destructuring + // parameter with no type annotation or initializer, the type implied by the binding pattern becomes the type of + // the parameter. + function getTypeFromBindingPattern(pattern, includePatternInType) { + return pattern.kind === 161 /* ObjectBindingPattern */ + ? getTypeFromObjectBindingPattern(pattern, includePatternInType) + : getTypeFromArrayBindingPattern(pattern, includePatternInType); + } + // Return the type associated with a variable, parameter, or property declaration. In the simple case this is the type + // specified in a type annotation or inferred from an initializer. However, in the case of a destructuring declaration it + // is a bit more involved. For example: + // + // var [x, s = ""] = [1, "one"]; + // + // Here, the array literal [1, "one"] is contextually typed by the type [any, string], which is the implied type of the + // binding pattern [x, s = ""]. Because the contextual type is a tuple type, the resulting type of [1, "one"] is the + // tuple type [number, string]. Thus, the type inferred for 'x' is number and the type inferred for 's' is string. + function getWidenedTypeForVariableLikeDeclaration(declaration, reportErrors) { + var type = getTypeForVariableLikeDeclaration(declaration); + if (type) { + if (reportErrors) { + reportErrorsFromWidening(declaration, type); + } + // During a normal type check we'll never get to here with a property assignment (the check of the containing + // object literal uses a different path). We exclude widening only so that language services and type verification + // tools see the actual type. + return declaration.kind !== 245 /* PropertyAssignment */ ? getWidenedType(type) : type; + } + // Rest parameters default to type any[], other parameters default to type any + type = declaration.dotDotDotToken ? anyArrayType : anyType; + // Report implicit any errors unless this is a private property within an ambient declaration + if (reportErrors && compilerOptions.noImplicitAny) { + var root = ts.getRootDeclaration(declaration); + if (!isPrivateWithinAmbient(root) && !(root.kind === 138 /* Parameter */ && isPrivateWithinAmbient(root.parent))) { + reportImplicitAnyError(declaration, type); + } + } + return type; + } + function getTypeOfVariableOrParameterOrProperty(symbol) { + var links = getSymbolLinks(symbol); + if (!links.type) { + // Handle prototype property + if (symbol.flags & 134217728 /* Prototype */) { + return links.type = getTypeOfPrototypeProperty(symbol); + } + // Handle catch clause variables + var declaration = symbol.valueDeclaration; + if (declaration.parent.kind === 244 /* CatchClause */) { + return links.type = anyType; + } + // Handle export default expressions + if (declaration.kind === 227 /* ExportAssignment */) { + return links.type = checkExpression(declaration.expression); + } + // Handle variable, parameter or property + if (!pushTypeResolution(symbol, 0 /* Type */)) { + return unknownType; + } + var type = getWidenedTypeForVariableLikeDeclaration(declaration, /*reportErrors*/ true); + if (!popTypeResolution()) { + if (symbol.valueDeclaration.type) { + // Variable has type annotation that circularly references the variable itself + type = unknownType; + error(symbol.valueDeclaration, ts.Diagnostics._0_is_referenced_directly_or_indirectly_in_its_own_type_annotation, symbolToString(symbol)); + } + else { + // Variable has initializer that circularly references the variable itself + type = anyType; + if (compilerOptions.noImplicitAny) { + error(symbol.valueDeclaration, ts.Diagnostics._0_implicitly_has_type_any_because_it_does_not_have_a_type_annotation_and_is_referenced_directly_or_indirectly_in_its_own_initializer, symbolToString(symbol)); + } + } + } + links.type = type; + } + return links.type; + } + function getAnnotatedAccessorType(accessor) { + if (accessor) { + if (accessor.kind === 145 /* GetAccessor */) { + return accessor.type && getTypeFromTypeNode(accessor.type); + } + else { + var setterTypeAnnotation = ts.getSetAccessorTypeAnnotationNode(accessor); + return setterTypeAnnotation && getTypeFromTypeNode(setterTypeAnnotation); + } + } + return undefined; + } + function getTypeOfAccessors(symbol) { + var links = getSymbolLinks(symbol); + if (!links.type) { + if (!pushTypeResolution(symbol, 0 /* Type */)) { + return unknownType; + } + var getter = ts.getDeclarationOfKind(symbol, 145 /* GetAccessor */); + var setter = ts.getDeclarationOfKind(symbol, 146 /* SetAccessor */); + var type; + // First try to see if the user specified a return type on the get-accessor. + var getterReturnType = getAnnotatedAccessorType(getter); + if (getterReturnType) { + type = getterReturnType; + } + else { + // If the user didn't specify a return type, try to use the set-accessor's parameter type. + var setterParameterType = getAnnotatedAccessorType(setter); + if (setterParameterType) { + type = setterParameterType; + } + else { + // If there are no specified types, try to infer it from the body of the get accessor if it exists. + if (getter && getter.body) { + type = getReturnTypeFromBody(getter); + } + else { + if (compilerOptions.noImplicitAny) { + error(setter, ts.Diagnostics.Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_type_annotation, symbolToString(symbol)); + } + type = anyType; + } + } + } + if (!popTypeResolution()) { + type = anyType; + if (compilerOptions.noImplicitAny) { + var getter_1 = ts.getDeclarationOfKind(symbol, 145 /* GetAccessor */); + error(getter_1, ts.Diagnostics._0_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions, symbolToString(symbol)); + } + } + links.type = type; + } + return links.type; + } + function getTypeOfFuncClassEnumModule(symbol) { + var links = getSymbolLinks(symbol); + if (!links.type) { + links.type = createObjectType(65536 /* Anonymous */, symbol); + } + return links.type; + } + function getTypeOfEnumMember(symbol) { + var links = getSymbolLinks(symbol); + if (!links.type) { + links.type = getDeclaredTypeOfEnum(getParentOfSymbol(symbol)); + } + return links.type; + } + function getTypeOfAlias(symbol) { + var links = getSymbolLinks(symbol); + if (!links.type) { + var targetSymbol = resolveAlias(symbol); + // It only makes sense to get the type of a value symbol. If the result of resolving + // the alias is not a value, then it has no type. To get the type associated with a + // type symbol, call getDeclaredTypeOfSymbol. + // This check is important because without it, a call to getTypeOfSymbol could end + // up recursively calling getTypeOfAlias, causing a stack overflow. + links.type = targetSymbol.flags & 107455 /* Value */ + ? getTypeOfSymbol(targetSymbol) + : unknownType; + } + return links.type; + } + function getTypeOfInstantiatedSymbol(symbol) { + var links = getSymbolLinks(symbol); + if (!links.type) { + links.type = instantiateType(getTypeOfSymbol(links.target), links.mapper); + } + return links.type; + } + function getTypeOfSymbol(symbol) { + if (symbol.flags & 16777216 /* Instantiated */) { + return getTypeOfInstantiatedSymbol(symbol); + } + if (symbol.flags & (3 /* Variable */ | 4 /* Property */)) { + return getTypeOfVariableOrParameterOrProperty(symbol); + } + if (symbol.flags & (16 /* Function */ | 8192 /* Method */ | 32 /* Class */ | 384 /* Enum */ | 512 /* ValueModule */)) { + return getTypeOfFuncClassEnumModule(symbol); + } + if (symbol.flags & 8 /* EnumMember */) { + return getTypeOfEnumMember(symbol); + } + if (symbol.flags & 98304 /* Accessor */) { + return getTypeOfAccessors(symbol); + } + if (symbol.flags & 8388608 /* Alias */) { + return getTypeOfAlias(symbol); + } + return unknownType; + } + function getTargetType(type) { + return type.flags & 4096 /* Reference */ ? type.target : type; + } + function hasBaseType(type, checkBase) { + return check(type); + function check(type) { + var target = getTargetType(type); + return target === checkBase || ts.forEach(getBaseTypes(target), check); + } + } + // Appends the type parameters given by a list of declarations to a set of type parameters and returns the resulting set. + // The function allocates a new array if the input type parameter set is undefined, but otherwise it modifies the set + // in-place and returns the same array. + function appendTypeParameters(typeParameters, declarations) { + for (var _i = 0; _i < declarations.length; _i++) { + var declaration = declarations[_i]; + var tp = getDeclaredTypeOfTypeParameter(getSymbolOfNode(declaration)); + if (!typeParameters) { + typeParameters = [tp]; + } + else if (!ts.contains(typeParameters, tp)) { + typeParameters.push(tp); + } + } + return typeParameters; + } + // Appends the outer type parameters of a node to a set of type parameters and returns the resulting set. The function + // allocates a new array if the input type parameter set is undefined, but otherwise it modifies the set in-place and + // returns the same array. + function appendOuterTypeParameters(typeParameters, node) { + while (true) { + node = node.parent; + if (!node) { + return typeParameters; + } + if (node.kind === 214 /* ClassDeclaration */ || node.kind === 186 /* ClassExpression */ || + node.kind === 213 /* FunctionDeclaration */ || node.kind === 173 /* FunctionExpression */ || + node.kind === 143 /* MethodDeclaration */ || node.kind === 174 /* ArrowFunction */) { + var declarations = node.typeParameters; + if (declarations) { + return appendTypeParameters(appendOuterTypeParameters(typeParameters, node), declarations); + } + } + } + } + // 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, 215 /* InterfaceDeclaration */); + return appendOuterTypeParameters(undefined, declaration); + } + // The local type parameters are the combined set of type parameters from all declarations of the class, + // interface, or type alias. + function getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol) { + var result; + for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { + var node = _a[_i]; + if (node.kind === 215 /* InterfaceDeclaration */ || node.kind === 214 /* ClassDeclaration */ || + node.kind === 186 /* ClassExpression */ || node.kind === 216 /* TypeAliasDeclaration */) { + var declaration = node; + if (declaration.typeParameters) { + result = appendTypeParameters(result, declaration.typeParameters); + } + } + } + return result; + } + // The full set of type parameters for a generic class or interface type consists of its outer type parameters plus + // its locally declared type parameters. + function getTypeParametersOfClassOrInterface(symbol) { + return ts.concatenate(getOuterTypeParametersOfClassOrInterface(symbol), getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol)); + } + function isConstructorType(type) { + return type.flags & 80896 /* ObjectType */ && getSignaturesOfType(type, 1 /* Construct */).length > 0; + } + function getBaseTypeNodeOfClass(type) { + return ts.getClassExtendsHeritageClauseElement(type.symbol.valueDeclaration); + } + function getConstructorsForTypeArguments(type, typeArgumentNodes) { + var typeArgCount = typeArgumentNodes ? typeArgumentNodes.length : 0; + return ts.filter(getSignaturesOfType(type, 1 /* Construct */), function (sig) { return (sig.typeParameters ? sig.typeParameters.length : 0) === typeArgCount; }); + } + function getInstantiatedConstructorsForTypeArguments(type, typeArgumentNodes) { + var signatures = getConstructorsForTypeArguments(type, typeArgumentNodes); + if (typeArgumentNodes) { + var typeArguments = ts.map(typeArgumentNodes, getTypeFromTypeNode); + signatures = ts.map(signatures, function (sig) { return getSignatureInstantiation(sig, typeArguments); }); + } + return signatures; + } + // The base constructor of a class can resolve to + // undefinedType if the class has no extends clause, + // 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) { + if (!type.resolvedBaseConstructorType) { + var baseTypeNode = getBaseTypeNodeOfClass(type); + if (!baseTypeNode) { + return type.resolvedBaseConstructorType = undefinedType; + } + if (!pushTypeResolution(type, 1 /* ResolvedBaseConstructorType */)) { + return unknownType; + } + var baseConstructorType = checkExpression(baseTypeNode.expression); + if (baseConstructorType.flags & 80896 /* 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); + } + if (!popTypeResolution()) { + error(type.symbol.valueDeclaration, ts.Diagnostics._0_is_referenced_directly_or_indirectly_in_its_own_base_expression, symbolToString(type.symbol)); + return type.resolvedBaseConstructorType = unknownType; + } + if (baseConstructorType !== unknownType && baseConstructorType !== nullType && !isConstructorType(baseConstructorType)) { + error(baseTypeNode.expression, ts.Diagnostics.Type_0_is_not_a_constructor_function_type, typeToString(baseConstructorType)); + return type.resolvedBaseConstructorType = unknownType; + } + type.resolvedBaseConstructorType = baseConstructorType; + } + return type.resolvedBaseConstructorType; + } + function hasClassBaseType(type) { + return !!ts.forEach(getBaseTypes(type), function (t) { return !!(t.symbol.flags & 32 /* Class */); }); + } + function getBaseTypes(type) { + var isClass = type.symbol.flags & 32 /* Class */; + var isInterface = type.symbol.flags & 64 /* Interface */; + if (!type.resolvedBaseTypes) { + if (!isClass && !isInterface) { + ts.Debug.fail("type must be class or interface"); + } + if (isClass) { + resolveBaseTypesOfClass(type); + } + if (isInterface) { + resolveBaseTypesOfInterface(type); + } + } + return type.resolvedBaseTypes; + } + function resolveBaseTypesOfClass(type) { + type.resolvedBaseTypes = type.resolvedBaseTypes || emptyArray; + var baseContructorType = getBaseConstructorTypeOfClass(type); + if (!(baseContructorType.flags & 80896 /* ObjectType */)) { + return; + } + var baseTypeNode = getBaseTypeNodeOfClass(type); + var baseType; + if (baseContructorType.symbol && baseContructorType.symbol.flags & 32 /* Class */) { + // When base constructor type is a class we know that the constructors all have the same type parameters as the + // class and all return the instance type of the class. There is no need for further checks and we can apply the + // type arguments in the same manner as a type reference to get the same error reporting experience. + baseType = getTypeFromClassOrInterfaceReference(baseTypeNode, baseContructorType.symbol); + } + else { + // The class derives from a "class-like" constructor function, check that we have at least one construct signature + // with a matching number of type parameters and use the return type of the first instantiated signature. Elsewhere + // we check that all instantiated signatures return the same type. + var constructors = getInstantiatedConstructorsForTypeArguments(baseContructorType, baseTypeNode.typeArguments); + if (!constructors.length) { + error(baseTypeNode.expression, ts.Diagnostics.No_base_constructor_has_the_specified_number_of_type_arguments); + return; + } + baseType = getReturnTypeOfSignature(constructors[0]); + } + if (baseType === unknownType) { + return; + } + if (!(getTargetType(baseType).flags & (1024 /* Class */ | 2048 /* Interface */))) { + error(baseTypeNode.expression, ts.Diagnostics.Base_constructor_return_type_0_is_not_a_class_or_interface_type, typeToString(baseType)); + return; + } + if (type === baseType || hasBaseType(baseType, type)) { + error(type.symbol.valueDeclaration, ts.Diagnostics.Type_0_recursively_references_itself_as_a_base_type, typeToString(type, /*enclosingDeclaration*/ undefined, 1 /* WriteArrayAsGenericType */)); + return; + } + if (type.resolvedBaseTypes === emptyArray) { + type.resolvedBaseTypes = [baseType]; + } + else { + type.resolvedBaseTypes.push(baseType); + } + } + function resolveBaseTypesOfInterface(type) { + type.resolvedBaseTypes = type.resolvedBaseTypes || emptyArray; + for (var _i = 0, _a = type.symbol.declarations; _i < _a.length; _i++) { + var declaration = _a[_i]; + if (declaration.kind === 215 /* InterfaceDeclaration */ && ts.getInterfaceBaseTypeNodes(declaration)) { + for (var _b = 0, _c = ts.getInterfaceBaseTypeNodes(declaration); _b < _c.length; _b++) { + var node = _c[_b]; + var baseType = getTypeFromTypeNode(node); + if (baseType !== unknownType) { + if (getTargetType(baseType).flags & (1024 /* Class */ | 2048 /* Interface */)) { + if (type !== baseType && !hasBaseType(baseType, type)) { + if (type.resolvedBaseTypes === emptyArray) { + type.resolvedBaseTypes = [baseType]; + } + else { + type.resolvedBaseTypes.push(baseType); + } + } + else { + error(declaration, ts.Diagnostics.Type_0_recursively_references_itself_as_a_base_type, typeToString(type, /*enclosingDeclaration*/ undefined, 1 /* WriteArrayAsGenericType */)); + } + } + else { + error(node, ts.Diagnostics.An_interface_may_only_extend_a_class_or_another_interface); + } + } + } + } + } + } + // Returns true if the interface given by the symbol is free of "this" references. Specifically, the result is + // true if the interface itself contains no references to "this" in its body, if all base types are interfaces, + // and if none of the base interfaces have a "this" type. + function isIndependentInterface(symbol) { + for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { + var declaration = _a[_i]; + if (declaration.kind === 215 /* InterfaceDeclaration */) { + if (declaration.flags & 524288 /* ContainsThis */) { + return false; + } + var baseTypeNodes = ts.getInterfaceBaseTypeNodes(declaration); + if (baseTypeNodes) { + for (var _b = 0; _b < baseTypeNodes.length; _b++) { + var node = baseTypeNodes[_b]; + if (ts.isSupportedExpressionWithTypeArguments(node)) { + var baseSymbol = resolveEntityName(node.expression, 793056 /* Type */, /*ignoreErrors*/ true); + if (!baseSymbol || !(baseSymbol.flags & 64 /* Interface */) || getDeclaredTypeOfClassOrInterface(baseSymbol).thisType) { + return false; + } + } + } + } + } + } + return true; + } + function getDeclaredTypeOfClassOrInterface(symbol) { + var links = getSymbolLinks(symbol); + if (!links.declaredType) { + var kind = symbol.flags & 32 /* Class */ ? 1024 /* Class */ : 2048 /* Interface */; + var type = links.declaredType = createObjectType(kind, symbol); + var outerTypeParameters = getOuterTypeParametersOfClassOrInterface(symbol); + var localTypeParameters = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol); + // A class or interface is generic if it has type parameters or a "this" type. We always give classes a "this" type + // because it is not feasible to analyze all members to determine if the "this" type escapes the class (in particular, + // property types inferred from initializers and method return types inferred from return statements are very hard + // to exhaustively analyze). We give interfaces a "this" type if we can't definitely determine that they are free of + // "this" references. + if (outerTypeParameters || localTypeParameters || kind === 1024 /* Class */ || !isIndependentInterface(symbol)) { + type.flags |= 4096 /* Reference */; + type.typeParameters = ts.concatenate(outerTypeParameters, localTypeParameters); + type.outerTypeParameters = outerTypeParameters; + type.localTypeParameters = localTypeParameters; + type.instantiations = {}; + type.instantiations[getTypeListId(type.typeParameters)] = type; + type.target = type; + type.typeArguments = type.typeParameters; + type.thisType = createType(512 /* TypeParameter */ | 33554432 /* ThisType */); + type.thisType.symbol = symbol; + type.thisType.constraint = getTypeWithThisArgument(type); + } + } + return links.declaredType; + } + function getDeclaredTypeOfTypeAlias(symbol) { + var links = getSymbolLinks(symbol); + if (!links.declaredType) { + // Note that we use the links object as the target here because the symbol object is used as the unique + // identity for resolution of the 'type' property in SymbolLinks. + if (!pushTypeResolution(symbol, 2 /* DeclaredType */)) { + return unknownType; + } + var declaration = ts.getDeclarationOfKind(symbol, 216 /* TypeAliasDeclaration */); + var type = getTypeFromTypeNode(declaration.type); + if (popTypeResolution()) { + links.typeParameters = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol); + if (links.typeParameters) { + // Initialize the instantiation cache for generic type aliases. The declared type corresponds to + // an instantiation of the type alias with the type parameters supplied as type arguments. + links.instantiations = {}; + links.instantiations[getTypeListId(links.typeParameters)] = type; + } + } + else { + type = unknownType; + error(declaration.name, ts.Diagnostics.Type_alias_0_circularly_references_itself, symbolToString(symbol)); + } + links.declaredType = type; + } + return links.declaredType; + } + function getDeclaredTypeOfEnum(symbol) { + var links = getSymbolLinks(symbol); + if (!links.declaredType) { + var type = createType(128 /* Enum */); + type.symbol = symbol; + links.declaredType = type; + } + return links.declaredType; + } + function getDeclaredTypeOfTypeParameter(symbol) { + var links = getSymbolLinks(symbol); + if (!links.declaredType) { + var type = createType(512 /* TypeParameter */); + type.symbol = symbol; + if (!ts.getDeclarationOfKind(symbol, 137 /* TypeParameter */).constraint) { + type.constraint = noConstraintType; + } + links.declaredType = type; + } + return links.declaredType; + } + function getDeclaredTypeOfAlias(symbol) { + var links = getSymbolLinks(symbol); + if (!links.declaredType) { + links.declaredType = getDeclaredTypeOfSymbol(resolveAlias(symbol)); + } + return links.declaredType; + } + function getDeclaredTypeOfSymbol(symbol) { + ts.Debug.assert((symbol.flags & 16777216 /* Instantiated */) === 0); + if (symbol.flags & (32 /* Class */ | 64 /* Interface */)) { + return getDeclaredTypeOfClassOrInterface(symbol); + } + if (symbol.flags & 524288 /* TypeAlias */) { + return getDeclaredTypeOfTypeAlias(symbol); + } + if (symbol.flags & 384 /* Enum */) { + return getDeclaredTypeOfEnum(symbol); + } + if (symbol.flags & 262144 /* TypeParameter */) { + return getDeclaredTypeOfTypeParameter(symbol); + } + if (symbol.flags & 8388608 /* Alias */) { + return getDeclaredTypeOfAlias(symbol); + } + return unknownType; + } + // A type reference is considered independent if each type argument is considered independent. + function isIndependentTypeReference(node) { + if (node.typeArguments) { + for (var _i = 0, _a = node.typeArguments; _i < _a.length; _i++) { + var typeNode = _a[_i]; + if (!isIndependentType(typeNode)) { + return false; + } + } + } + return true; + } + // A type is considered independent if it the any, string, number, boolean, symbol, or void keyword, a string + // literal type, an array with an element type that is considered independent, or a type reference that is + // considered independent. + function isIndependentType(node) { + switch (node.kind) { + case 117 /* AnyKeyword */: + case 130 /* StringKeyword */: + case 128 /* NumberKeyword */: + case 120 /* BooleanKeyword */: + case 131 /* SymbolKeyword */: + case 103 /* VoidKeyword */: + case 9 /* StringLiteral */: + return true; + case 156 /* ArrayType */: + return isIndependentType(node.elementType); + case 151 /* TypeReference */: + return isIndependentTypeReference(node); + } + return false; + } + // A variable-like declaration is considered independent (free of this references) if it has a type annotation + // that specifies an independent type, or if it has no type annotation and no initializer (and thus of type any). + function isIndependentVariableLikeDeclaration(node) { + return node.type && isIndependentType(node.type) || !node.type && !node.initializer; + } + // A function-like declaration is considered independent (free of this references) if it has a return type + // annotation that is considered independent and if each parameter is considered independent. + function isIndependentFunctionLikeDeclaration(node) { + if (node.kind !== 144 /* Constructor */ && (!node.type || !isIndependentType(node.type))) { + return false; + } + for (var _i = 0, _a = node.parameters; _i < _a.length; _i++) { + var parameter = _a[_i]; + if (!isIndependentVariableLikeDeclaration(parameter)) { + return false; + } + } + return true; + } + // Returns true if the class or interface member given by the symbol is free of "this" references. The + // function may return false for symbols that are actually free of "this" references because it is not + // feasible to perform a complete analysis in all cases. In particular, property members with types + // inferred from their initializers and function members with inferred return types are convervatively + // assumed not to be free of "this" references. + function isIndependentMember(symbol) { + if (symbol.declarations && symbol.declarations.length === 1) { + var declaration = symbol.declarations[0]; + if (declaration) { + switch (declaration.kind) { + case 141 /* PropertyDeclaration */: + case 140 /* PropertySignature */: + return isIndependentVariableLikeDeclaration(declaration); + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: + case 144 /* Constructor */: + return isIndependentFunctionLikeDeclaration(declaration); + } + } + } + return false; + } + function createSymbolTable(symbols) { + var result = {}; + for (var _i = 0; _i < symbols.length; _i++) { + var symbol = symbols[_i]; + result[symbol.name] = symbol; + } + return result; + } + // The mappingThisOnly flag indicates that the only type parameter being mapped is "this". When the flag is true, + // we check symbols to see if we can quickly conclude they are free of "this" references, thus needing no instantiation. + function createInstantiatedSymbolTable(symbols, mapper, mappingThisOnly) { + var result = {}; + for (var _i = 0; _i < symbols.length; _i++) { + var symbol = symbols[_i]; + result[symbol.name] = mappingThisOnly && isIndependentMember(symbol) ? symbol : instantiateSymbol(symbol, mapper); + } + return result; + } + function addInheritedMembers(symbols, baseSymbols) { + for (var _i = 0; _i < baseSymbols.length; _i++) { + var s = baseSymbols[_i]; + if (!ts.hasProperty(symbols, s.name)) { + symbols[s.name] = s; + } + } + } + function addInheritedSignatures(signatures, baseSignatures) { + if (baseSignatures) { + for (var _i = 0; _i < baseSignatures.length; _i++) { + var signature = baseSignatures[_i]; + signatures.push(signature); + } + } + } + function resolveDeclaredMembers(type) { + if (!type.declaredProperties) { + var symbol = type.symbol; + type.declaredProperties = getNamedMembers(symbol.members); + type.declaredCallSignatures = getSignaturesOfSymbol(symbol.members["__call"]); + type.declaredConstructSignatures = getSignaturesOfSymbol(symbol.members["__new"]); + type.declaredStringIndexType = getIndexTypeOfSymbol(symbol, 0 /* String */); + type.declaredNumberIndexType = getIndexTypeOfSymbol(symbol, 1 /* Number */); + } + return type; + } + function getTypeWithThisArgument(type, thisArgument) { + if (type.flags & 4096 /* Reference */) { + return createTypeReference(type.target, ts.concatenate(type.typeArguments, [thisArgument || type.target.thisType])); + } + return type; + } + function resolveObjectTypeMembers(type, source, typeParameters, typeArguments) { + var mapper = identityMapper; + var members = source.symbol.members; + var callSignatures = source.declaredCallSignatures; + var constructSignatures = source.declaredConstructSignatures; + var stringIndexType = source.declaredStringIndexType; + var numberIndexType = source.declaredNumberIndexType; + if (!ts.rangeEquals(typeParameters, typeArguments, 0, typeParameters.length)) { + mapper = createTypeMapper(typeParameters, typeArguments); + members = createInstantiatedSymbolTable(source.declaredProperties, mapper, /*mappingThisOnly*/ typeParameters.length === 1); + callSignatures = instantiateList(source.declaredCallSignatures, mapper, instantiateSignature); + constructSignatures = instantiateList(source.declaredConstructSignatures, mapper, instantiateSignature); + stringIndexType = instantiateType(source.declaredStringIndexType, mapper); + numberIndexType = instantiateType(source.declaredNumberIndexType, mapper); + } + var baseTypes = getBaseTypes(source); + if (baseTypes.length) { + if (members === source.symbol.members) { + members = createSymbolTable(source.declaredProperties); + } + var thisArgument = ts.lastOrUndefined(typeArguments); + for (var _i = 0; _i < baseTypes.length; _i++) { + var baseType = baseTypes[_i]; + var instantiatedBaseType = thisArgument ? getTypeWithThisArgument(instantiateType(baseType, mapper), thisArgument) : baseType; + addInheritedMembers(members, getPropertiesOfObjectType(instantiatedBaseType)); + callSignatures = ts.concatenate(callSignatures, getSignaturesOfType(instantiatedBaseType, 0 /* Call */)); + constructSignatures = ts.concatenate(constructSignatures, getSignaturesOfType(instantiatedBaseType, 1 /* Construct */)); + stringIndexType = stringIndexType || getIndexTypeOfType(instantiatedBaseType, 0 /* String */); + numberIndexType = numberIndexType || getIndexTypeOfType(instantiatedBaseType, 1 /* Number */); + } + } + setObjectTypeMembers(type, members, callSignatures, constructSignatures, stringIndexType, numberIndexType); + } + function resolveClassOrInterfaceMembers(type) { + resolveObjectTypeMembers(type, resolveDeclaredMembers(type), emptyArray, emptyArray); + } + function resolveTypeReferenceMembers(type) { + var source = resolveDeclaredMembers(type.target); + var typeParameters = ts.concatenate(source.typeParameters, [source.thisType]); + var typeArguments = type.typeArguments && type.typeArguments.length === typeParameters.length ? + type.typeArguments : ts.concatenate(type.typeArguments, [type]); + resolveObjectTypeMembers(type, source, typeParameters, typeArguments); + } + function createSignature(declaration, typeParameters, parameters, resolvedReturnType, typePredicate, minArgumentCount, hasRestParameter, hasStringLiterals) { + var sig = new Signature(checker); + sig.declaration = declaration; + sig.typeParameters = typeParameters; + sig.parameters = parameters; + sig.resolvedReturnType = resolvedReturnType; + sig.typePredicate = typePredicate; + sig.minArgumentCount = minArgumentCount; + sig.hasRestParameter = hasRestParameter; + sig.hasStringLiterals = hasStringLiterals; + return sig; + } + function cloneSignature(sig) { + return createSignature(sig.declaration, sig.typeParameters, sig.parameters, sig.resolvedReturnType, sig.typePredicate, sig.minArgumentCount, sig.hasRestParameter, sig.hasStringLiterals); + } + function getDefaultConstructSignatures(classType) { + if (!hasClassBaseType(classType)) { + return [createSignature(undefined, classType.localTypeParameters, emptyArray, classType, undefined, 0, false, false)]; + } + var baseConstructorType = getBaseConstructorTypeOfClass(classType); + var baseSignatures = getSignaturesOfType(baseConstructorType, 1 /* Construct */); + var baseTypeNode = getBaseTypeNodeOfClass(classType); + var typeArguments = ts.map(baseTypeNode.typeArguments, getTypeFromTypeNode); + var typeArgCount = typeArguments ? typeArguments.length : 0; + var result = []; + for (var _i = 0; _i < baseSignatures.length; _i++) { + var baseSig = baseSignatures[_i]; + var typeParamCount = baseSig.typeParameters ? baseSig.typeParameters.length : 0; + if (typeParamCount === typeArgCount) { + var sig = typeParamCount ? getSignatureInstantiation(baseSig, typeArguments) : cloneSignature(baseSig); + sig.typeParameters = classType.localTypeParameters; + sig.resolvedReturnType = classType; + result.push(sig); + } + } + return result; + } + function createTupleTypeMemberSymbols(memberTypes) { + var members = {}; + for (var i = 0; i < memberTypes.length; i++) { + var symbol = createSymbol(4 /* Property */ | 67108864 /* Transient */, "" + i); + symbol.type = memberTypes[i]; + members[i] = symbol; + } + return members; + } + function resolveTupleTypeMembers(type) { + var arrayElementType = getUnionType(type.elementTypes, /*noSubtypeReduction*/ true); + // Make the tuple type itself the 'this' type by including an extra type argument + var arrayType = resolveStructuredTypeMembers(createTypeFromGenericGlobalType(globalArrayType, [arrayElementType, type])); + var members = createTupleTypeMemberSymbols(type.elementTypes); + addInheritedMembers(members, arrayType.properties); + setObjectTypeMembers(type, members, arrayType.callSignatures, arrayType.constructSignatures, arrayType.stringIndexType, arrayType.numberIndexType); + } + function findMatchingSignature(signatureList, signature, partialMatch, ignoreReturnTypes) { + for (var _i = 0; _i < signatureList.length; _i++) { + var s = signatureList[_i]; + if (compareSignatures(s, signature, partialMatch, ignoreReturnTypes, compareTypes)) { + return s; + } + } + } + function findMatchingSignatures(signatureLists, signature, listIndex) { + if (signature.typeParameters) { + // We require an exact match for generic signatures, so we only return signatures from the first + // signature list and only if they have exact matches in the other signature lists. + if (listIndex > 0) { + return undefined; + } + for (var i = 1; i < signatureLists.length; i++) { + if (!findMatchingSignature(signatureLists[i], signature, /*partialMatch*/ false, /*ignoreReturnTypes*/ false)) { + return undefined; + } + } + return [signature]; + } + var result = undefined; + for (var i = 0; i < signatureLists.length; i++) { + // Allow matching non-generic signatures to have excess parameters and different return types + var match = i === listIndex ? signature : findMatchingSignature(signatureLists[i], signature, /*partialMatch*/ true, /*ignoreReturnTypes*/ true); + if (!match) { + return undefined; + } + if (!ts.contains(result, match)) { + (result || (result = [])).push(match); + } + } + return result; + } + // The signatures of a union type are those signatures that are present in each of the constituent types. + // Generic signatures must match exactly, but non-generic signatures are allowed to have extra optional + // parameters and may differ in return types. When signatures differ in return types, the resulting return + // type is the union of the constituent return types. + function getUnionSignatures(types, kind) { + var signatureLists = ts.map(types, function (t) { return getSignaturesOfType(t, kind); }); + var result = undefined; + for (var i = 0; i < signatureLists.length; i++) { + for (var _i = 0, _a = signatureLists[i]; _i < _a.length; _i++) { + var signature = _a[_i]; + // Only process signatures with parameter lists that aren't already in the result list + if (!result || !findMatchingSignature(result, signature, /*partialMatch*/ false, /*ignoreReturnTypes*/ true)) { + var unionSignatures = findMatchingSignatures(signatureLists, signature, i); + if (unionSignatures) { + var s = signature; + // Union the result types when more than one signature matches + if (unionSignatures.length > 1) { + s = cloneSignature(signature); + // Clear resolved return type we possibly got from cloneSignature + s.resolvedReturnType = undefined; + s.unionSignatures = unionSignatures; + } + (result || (result = [])).push(s); + } + } + } + } + return result || emptyArray; + } + function getUnionIndexType(types, kind) { + var indexTypes = []; + for (var _i = 0; _i < types.length; _i++) { + var type = types[_i]; + var indexType = getIndexTypeOfType(type, kind); + if (!indexType) { + return undefined; + } + indexTypes.push(indexType); + } + return getUnionType(indexTypes); + } + function resolveUnionTypeMembers(type) { + // The members and properties collections are empty for union types. To get all properties of a union + // type use getPropertiesOfType (only the language service uses this). + var callSignatures = getUnionSignatures(type.types, 0 /* Call */); + var constructSignatures = getUnionSignatures(type.types, 1 /* Construct */); + var stringIndexType = getUnionIndexType(type.types, 0 /* String */); + var numberIndexType = getUnionIndexType(type.types, 1 /* Number */); + setObjectTypeMembers(type, emptySymbols, callSignatures, constructSignatures, stringIndexType, numberIndexType); + } + function intersectTypes(type1, type2) { + return !type1 ? type2 : !type2 ? type1 : getIntersectionType([type1, type2]); + } + function resolveIntersectionTypeMembers(type) { + // The members and properties collections are empty for intersection types. To get all properties of an + // intersection type use getPropertiesOfType (only the language service uses this). + var callSignatures = emptyArray; + var constructSignatures = emptyArray; + var stringIndexType = undefined; + var numberIndexType = undefined; + for (var _i = 0, _a = type.types; _i < _a.length; _i++) { + var t = _a[_i]; + callSignatures = ts.concatenate(callSignatures, getSignaturesOfType(t, 0 /* Call */)); + constructSignatures = ts.concatenate(constructSignatures, getSignaturesOfType(t, 1 /* Construct */)); + stringIndexType = intersectTypes(stringIndexType, getIndexTypeOfType(t, 0 /* String */)); + numberIndexType = intersectTypes(numberIndexType, getIndexTypeOfType(t, 1 /* Number */)); + } + setObjectTypeMembers(type, emptySymbols, callSignatures, constructSignatures, stringIndexType, numberIndexType); + } + function resolveAnonymousTypeMembers(type) { + var symbol = type.symbol; + var members; + var callSignatures; + var constructSignatures; + var stringIndexType; + var numberIndexType; + if (type.target) { + members = createInstantiatedSymbolTable(getPropertiesOfObjectType(type.target), type.mapper, /*mappingThisOnly*/ false); + callSignatures = instantiateList(getSignaturesOfType(type.target, 0 /* Call */), type.mapper, instantiateSignature); + constructSignatures = instantiateList(getSignaturesOfType(type.target, 1 /* Construct */), type.mapper, instantiateSignature); + stringIndexType = instantiateType(getIndexTypeOfType(type.target, 0 /* String */), type.mapper); + numberIndexType = instantiateType(getIndexTypeOfType(type.target, 1 /* Number */), type.mapper); + } + else if (symbol.flags & 2048 /* TypeLiteral */) { + members = symbol.members; + callSignatures = getSignaturesOfSymbol(members["__call"]); + constructSignatures = getSignaturesOfSymbol(members["__new"]); + stringIndexType = getIndexTypeOfSymbol(symbol, 0 /* String */); + numberIndexType = getIndexTypeOfSymbol(symbol, 1 /* Number */); + } + else { + // Combinations of function, class, enum and module + members = emptySymbols; + callSignatures = emptyArray; + constructSignatures = emptyArray; + if (symbol.flags & 1952 /* HasExports */) { + members = getExportsOfSymbol(symbol); + } + if (symbol.flags & (16 /* Function */ | 8192 /* Method */)) { + callSignatures = getSignaturesOfSymbol(symbol); + } + if (symbol.flags & 32 /* Class */) { + var classType = getDeclaredTypeOfClassOrInterface(symbol); + constructSignatures = getSignaturesOfSymbol(symbol.members["__constructor"]); + if (!constructSignatures.length) { + constructSignatures = getDefaultConstructSignatures(classType); + } + var baseConstructorType = getBaseConstructorTypeOfClass(classType); + if (baseConstructorType.flags & 80896 /* ObjectType */) { + members = createSymbolTable(getNamedMembers(members)); + addInheritedMembers(members, getPropertiesOfObjectType(baseConstructorType)); + } + } + stringIndexType = undefined; + numberIndexType = (symbol.flags & 384 /* Enum */) ? stringType : undefined; + } + setObjectTypeMembers(type, members, callSignatures, constructSignatures, stringIndexType, numberIndexType); + } + function resolveStructuredTypeMembers(type) { + if (!type.members) { + if (type.flags & 4096 /* Reference */) { + resolveTypeReferenceMembers(type); + } + else if (type.flags & (1024 /* Class */ | 2048 /* Interface */)) { + resolveClassOrInterfaceMembers(type); + } + else if (type.flags & 65536 /* Anonymous */) { + resolveAnonymousTypeMembers(type); + } + else if (type.flags & 8192 /* Tuple */) { + resolveTupleTypeMembers(type); + } + else if (type.flags & 16384 /* Union */) { + resolveUnionTypeMembers(type); + } + else if (type.flags & 32768 /* Intersection */) { + resolveIntersectionTypeMembers(type); + } + } + return type; + } + // Return properties of an object type or an empty array for other types + function getPropertiesOfObjectType(type) { + if (type.flags & 80896 /* ObjectType */) { + return resolveStructuredTypeMembers(type).properties; + } + return emptyArray; + } + // 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, name) { + if (type.flags & 80896 /* ObjectType */) { + var resolved = resolveStructuredTypeMembers(type); + if (ts.hasProperty(resolved.members, name)) { + var symbol = resolved.members[name]; + if (symbolIsValue(symbol)) { + return symbol; + } + } + } + } + function getPropertiesOfUnionOrIntersectionType(type) { + for (var _i = 0, _a = type.types; _i < _a.length; _i++) { + var current = _a[_i]; + for (var _b = 0, _c = getPropertiesOfType(current); _b < _c.length; _b++) { + var prop = _c[_b]; + getPropertyOfUnionOrIntersectionType(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 + if (type.flags & 16384 /* Union */) { + break; + } + } + return type.resolvedProperties ? symbolsToArray(type.resolvedProperties) : emptyArray; + } + function getPropertiesOfType(type) { + type = getApparentType(type); + return type.flags & 49152 /* UnionOrIntersection */ ? getPropertiesOfUnionOrIntersectionType(type) : getPropertiesOfObjectType(type); + } + /** + * For a type parameter, return the base constraint of the type parameter. For the string, number, + * boolean, and symbol primitive types, return the corresponding object types. Otherwise return the + * type itself. Note that the apparent type of a union type is the union type itself. + */ + function getApparentType(type) { + if (type.flags & 512 /* TypeParameter */) { + do { + type = getConstraintOfTypeParameter(type); + } while (type && type.flags & 512 /* TypeParameter */); + if (!type) { + type = emptyObjectType; + } + } + if (type.flags & 258 /* StringLike */) { + type = globalStringType; + } + else if (type.flags & 132 /* NumberLike */) { + type = globalNumberType; + } + else if (type.flags & 8 /* Boolean */) { + type = globalBooleanType; + } + else if (type.flags & 16777216 /* ESSymbol */) { + type = globalESSymbolType; + } + return type; + } + function createUnionOrIntersectionProperty(containingType, name) { + var types = containingType.types; + var props; + for (var _i = 0; _i < types.length; _i++) { + var current = types[_i]; + var type = getApparentType(current); + if (type !== unknownType) { + var prop = getPropertyOfType(type, name); + if (prop && !(getDeclarationFlagsFromSymbol(prop) & (32 /* Private */ | 64 /* Protected */))) { + if (!props) { + props = [prop]; + } + else if (!ts.contains(props, prop)) { + props.push(prop); + } + } + else if (containingType.flags & 16384 /* Union */) { + // A union type requires the property to be present in all constituent types + return undefined; + } + } + } + if (!props) { + return undefined; + } + if (props.length === 1) { + return props[0]; + } + var propTypes = []; + var declarations = []; + for (var _a = 0; _a < props.length; _a++) { + var prop = props[_a]; + if (prop.declarations) { + ts.addRange(declarations, prop.declarations); + } + propTypes.push(getTypeOfSymbol(prop)); + } + var result = createSymbol(4 /* Property */ | 67108864 /* Transient */ | 268435456 /* SyntheticProperty */, name); + result.containingType = containingType; + result.declarations = declarations; + result.type = containingType.flags & 16384 /* Union */ ? getUnionType(propTypes) : getIntersectionType(propTypes); + return result; + } + function getPropertyOfUnionOrIntersectionType(type, name) { + var properties = type.resolvedProperties || (type.resolvedProperties = {}); + if (ts.hasProperty(properties, name)) { + return properties[name]; + } + var property = createUnionOrIntersectionProperty(type, name); + if (property) { + properties[name] = property; + } + return property; + } + // 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 + // Object and Function as appropriate. + function getPropertyOfType(type, name) { + type = getApparentType(type); + if (type.flags & 80896 /* ObjectType */) { + var resolved = resolveStructuredTypeMembers(type); + if (ts.hasProperty(resolved.members, name)) { + var symbol = resolved.members[name]; + if (symbolIsValue(symbol)) { + return symbol; + } + } + if (resolved === anyFunctionType || resolved.callSignatures.length || resolved.constructSignatures.length) { + var symbol = getPropertyOfObjectType(globalFunctionType, name); + if (symbol) { + return symbol; + } + } + return getPropertyOfObjectType(globalObjectType, name); + } + if (type.flags & 49152 /* UnionOrIntersection */) { + return getPropertyOfUnionOrIntersectionType(type, name); + } + return undefined; + } + function getSignaturesOfStructuredType(type, kind) { + if (type.flags & 130048 /* StructuredType */) { + var resolved = resolveStructuredTypeMembers(type); + return kind === 0 /* Call */ ? resolved.callSignatures : resolved.constructSignatures; + } + return emptyArray; + } + /** + * Return the signatures of the given kind in the given type. Creates synthetic union signatures when necessary and + * maps primitive types and type parameters are to their apparent types. + */ + function getSignaturesOfType(type, kind) { + return getSignaturesOfStructuredType(getApparentType(type), kind); + } + function typeHasConstructSignatures(type) { + var apparentType = getApparentType(type); + if (apparentType.flags & (80896 /* ObjectType */ | 16384 /* Union */)) { + var resolved = resolveStructuredTypeMembers(type); + return resolved.constructSignatures.length > 0; + } + return false; + } + function typeHasCallOrConstructSignatures(type) { + var apparentType = getApparentType(type); + if (apparentType.flags & 130048 /* StructuredType */) { + var resolved = resolveStructuredTypeMembers(type); + return resolved.callSignatures.length > 0 || resolved.constructSignatures.length > 0; + } + return false; + } + function getIndexTypeOfStructuredType(type, kind) { + if (type.flags & 130048 /* StructuredType */) { + var resolved = resolveStructuredTypeMembers(type); + return kind === 0 /* String */ ? resolved.stringIndexType : resolved.numberIndexType; + } + } + // Return the index type of the given kind in the given type. Creates synthetic union index types when necessary and + // maps primitive types and type parameters are to their apparent types. + function getIndexTypeOfType(type, kind) { + return getIndexTypeOfStructuredType(getApparentType(type), kind); + } + // Return list of type parameters with duplicates removed (duplicate identifier errors are generated in the actual + // type checking functions). + function getTypeParametersFromDeclaration(typeParameterDeclarations) { + var result = []; + ts.forEach(typeParameterDeclarations, function (node) { + var tp = getDeclaredTypeOfTypeParameter(node.symbol); + if (!ts.contains(result, tp)) { + result.push(tp); + } + }); + return result; + } + function symbolsToArray(symbols) { + var result = []; + for (var id in symbols) { + if (!isReservedMemberName(id)) { + result.push(symbols[id]); + } + } + return result; + } + function isOptionalParameter(node) { + if (ts.hasQuestionToken(node)) { + return true; + } + if (node.initializer) { + var signatureDeclaration = node.parent; + var signature = getSignatureFromDeclaration(signatureDeclaration); + var parameterIndex = signatureDeclaration.parameters.indexOf(node); + ts.Debug.assert(parameterIndex >= 0); + return parameterIndex >= signature.minArgumentCount; + } + return false; + } + function getSignatureFromDeclaration(declaration) { + var links = getNodeLinks(declaration); + if (!links.resolvedSignature) { + var classType = declaration.kind === 144 /* Constructor */ ? + getDeclaredTypeOfClassOrInterface(getMergedSymbol(declaration.parent.symbol)) + : undefined; + var typeParameters = classType ? classType.localTypeParameters : + declaration.typeParameters ? getTypeParametersFromDeclaration(declaration.typeParameters) : undefined; + var parameters = []; + var hasStringLiterals = false; + var minArgumentCount = -1; + for (var i = 0, n = declaration.parameters.length; i < n; i++) { + var param = declaration.parameters[i]; + parameters.push(param.symbol); + if (param.type && param.type.kind === 9 /* StringLiteral */) { + hasStringLiterals = true; + } + if (param.initializer || param.questionToken || param.dotDotDotToken) { + if (minArgumentCount < 0) { + minArgumentCount = i; + } + } + else { + // If we see any required parameters, it means the prior ones were not in fact optional. + minArgumentCount = -1; + } + } + if (minArgumentCount < 0) { + minArgumentCount = declaration.parameters.length; + } + var returnType; + var typePredicate; + if (classType) { + returnType = classType; + } + else if (declaration.type) { + returnType = getTypeFromTypeNode(declaration.type); + if (declaration.type.kind === 150 /* TypePredicate */) { + var typePredicateNode = declaration.type; + typePredicate = { + parameterName: typePredicateNode.parameterName ? typePredicateNode.parameterName.text : undefined, + parameterIndex: typePredicateNode.parameterName ? getTypePredicateParameterIndex(declaration.parameters, typePredicateNode.parameterName) : undefined, + type: getTypeFromTypeNode(typePredicateNode.type) + }; + } + } + else { + // TypeScript 1.0 spec (April 2014): + // If only one accessor includes a type annotation, the other behaves as if it had the same type annotation. + if (declaration.kind === 145 /* GetAccessor */ && !ts.hasDynamicName(declaration)) { + var setter = ts.getDeclarationOfKind(declaration.symbol, 146 /* SetAccessor */); + returnType = getAnnotatedAccessorType(setter); + } + if (!returnType && ts.nodeIsMissing(declaration.body)) { + returnType = anyType; + } + } + links.resolvedSignature = createSignature(declaration, typeParameters, parameters, returnType, typePredicate, minArgumentCount, ts.hasRestParameter(declaration), hasStringLiterals); + } + return links.resolvedSignature; + } + function getSignaturesOfSymbol(symbol) { + if (!symbol) + return emptyArray; + var result = []; + for (var i = 0, len = symbol.declarations.length; i < len; i++) { + var node = symbol.declarations[i]; + switch (node.kind) { + case 152 /* FunctionType */: + case 153 /* ConstructorType */: + case 213 /* FunctionDeclaration */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: + case 144 /* Constructor */: + case 147 /* CallSignature */: + case 148 /* ConstructSignature */: + case 149 /* IndexSignature */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: + case 173 /* FunctionExpression */: + case 174 /* ArrowFunction */: + // Don't include signature if node is the implementation of an overloaded function. A node is considered + // an implementation node if it has a body and the previous node is of the same kind and immediately + // precedes the implementation node (i.e. has the same parent and ends where the implementation starts). + if (i > 0 && node.body) { + var previous = symbol.declarations[i - 1]; + if (node.parent === previous.parent && node.kind === previous.kind && node.pos === previous.end) { + break; + } + } + result.push(getSignatureFromDeclaration(node)); + } + } + return result; + } + function getReturnTypeOfSignature(signature) { + if (!signature.resolvedReturnType) { + if (!pushTypeResolution(signature, 3 /* ResolvedReturnType */)) { + return unknownType; + } + var type; + if (signature.target) { + type = instantiateType(getReturnTypeOfSignature(signature.target), signature.mapper); + } + else if (signature.unionSignatures) { + type = getUnionType(ts.map(signature.unionSignatures, getReturnTypeOfSignature)); + } + else { + type = getReturnTypeFromBody(signature.declaration); + } + if (!popTypeResolution()) { + type = anyType; + if (compilerOptions.noImplicitAny) { + var declaration = signature.declaration; + if (declaration.name) { + error(declaration.name, 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, ts.declarationNameToString(declaration.name)); + } + else { + error(declaration, ts.Diagnostics.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); + } + } + } + signature.resolvedReturnType = type; + } + return signature.resolvedReturnType; + } + function getRestTypeOfSignature(signature) { + if (signature.hasRestParameter) { + var type = getTypeOfSymbol(ts.lastOrUndefined(signature.parameters)); + if (type.flags & 4096 /* Reference */ && type.target === globalArrayType) { + return type.typeArguments[0]; + } + } + return anyType; + } + function getSignatureInstantiation(signature, typeArguments) { + return instantiateSignature(signature, createTypeMapper(signature.typeParameters, typeArguments), true); + } + function getErasedSignature(signature) { + if (!signature.typeParameters) + return signature; + if (!signature.erasedSignatureCache) { + if (signature.target) { + signature.erasedSignatureCache = instantiateSignature(getErasedSignature(signature.target), signature.mapper); + } + else { + signature.erasedSignatureCache = instantiateSignature(signature, createTypeEraser(signature.typeParameters), true); + } + } + return signature.erasedSignatureCache; + } + function getOrCreateTypeFromSignature(signature) { + // There are two ways to declare a construct signature, one is by declaring a class constructor + // using the constructor keyword, and the other is declaring a bare construct signature in an + // 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 === 144 /* Constructor */ || signature.declaration.kind === 148 /* ConstructSignature */; + var type = createObjectType(65536 /* Anonymous */ | 262144 /* FromSignature */); + type.members = emptySymbols; + type.properties = emptyArray; + type.callSignatures = !isConstructor ? [signature] : emptyArray; + type.constructSignatures = isConstructor ? [signature] : emptyArray; + signature.isolatedSignatureType = type; + } + return signature.isolatedSignatureType; + } + function getIndexSymbol(symbol) { + return symbol.members["__index"]; + } + function getIndexDeclarationOfSymbol(symbol, kind) { + var syntaxKind = kind === 1 /* Number */ ? 128 /* NumberKeyword */ : 130 /* StringKeyword */; + var indexSymbol = getIndexSymbol(symbol); + if (indexSymbol) { + for (var _i = 0, _a = indexSymbol.declarations; _i < _a.length; _i++) { + var decl = _a[_i]; + var node = decl; + if (node.parameters.length === 1) { + var parameter = node.parameters[0]; + if (parameter && parameter.type && parameter.type.kind === syntaxKind) { + return node; + } + } + } + } + return undefined; + } + function getIndexTypeOfSymbol(symbol, kind) { + var declaration = getIndexDeclarationOfSymbol(symbol, kind); + return declaration + ? declaration.type ? getTypeFromTypeNode(declaration.type) : anyType + : undefined; + } + function getConstraintOfTypeParameter(type) { + if (!type.constraint) { + if (type.target) { + var targetConstraint = getConstraintOfTypeParameter(type.target); + type.constraint = targetConstraint ? instantiateType(targetConstraint, type.mapper) : noConstraintType; + } + else { + type.constraint = getTypeFromTypeNode(ts.getDeclarationOfKind(type.symbol, 137 /* TypeParameter */).constraint); + } + } + return type.constraint === noConstraintType ? undefined : type.constraint; + } + function getParentSymbolOfTypeParameter(typeParameter) { + return getSymbolOfNode(ts.getDeclarationOfKind(typeParameter.symbol, 137 /* TypeParameter */).parent); + } + function getTypeListId(types) { + if (types) { + switch (types.length) { + case 1: + return "" + types[0].id; + case 2: + return types[0].id + "," + types[1].id; + default: + var result = ""; + for (var i = 0; i < types.length; i++) { + if (i > 0) { + result += ","; + } + result += types[i].id; + } + return result; + } + } + return ""; + } + // This function is used to propagate certain flags when creating new object type references and union types. + // It is only necessary to do so if a constituent type might be the undefined type, the null type, the type + // of an object literal or the anyFunctionType. This is because there are operations in the type checker + // that care about the presence of such types at arbitrary depth in a containing type. + function getPropagatingFlagsOfTypes(types) { + var result = 0; + for (var _i = 0; _i < types.length; _i++) { + var type = types[_i]; + result |= type.flags; + } + return result & 14680064 /* PropagatingFlags */; + } + function createTypeReference(target, typeArguments) { + var id = getTypeListId(typeArguments); + var type = target.instantiations[id]; + if (!type) { + var flags = 4096 /* Reference */ | (typeArguments ? getPropagatingFlagsOfTypes(typeArguments) : 0); + type = target.instantiations[id] = createObjectType(flags, target.symbol); + type.target = target; + type.typeArguments = typeArguments; + } + return type; + } + function isTypeParameterReferenceIllegalInConstraint(typeReferenceNode, typeParameterSymbol) { + var links = getNodeLinks(typeReferenceNode); + if (links.isIllegalTypeReferenceInConstraint !== undefined) { + return links.isIllegalTypeReferenceInConstraint; + } + // bubble up to the declaration + var currentNode = typeReferenceNode; + // forEach === exists + while (!ts.forEach(typeParameterSymbol.declarations, function (d) { return d.parent === currentNode.parent; })) { + currentNode = currentNode.parent; + } + // if last step was made from the type parameter this means that path has started somewhere in constraint which is illegal + links.isIllegalTypeReferenceInConstraint = currentNode.kind === 137 /* TypeParameter */; + return links.isIllegalTypeReferenceInConstraint; + } + function checkTypeParameterHasIllegalReferencesInConstraint(typeParameter) { + var typeParameterSymbol; + function check(n) { + if (n.kind === 151 /* TypeReference */ && n.typeName.kind === 69 /* Identifier */) { + var links = getNodeLinks(n); + if (links.isIllegalTypeReferenceInConstraint === undefined) { + var symbol = resolveName(typeParameter, n.typeName.text, 793056 /* Type */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined); + if (symbol && (symbol.flags & 262144 /* TypeParameter */)) { + // TypeScript 1.0 spec (April 2014): 3.4.1 + // Type parameters declared in a particular type parameter list + // may not be referenced in constraints in that type parameter list + // symbol.declaration.parent === typeParameter.parent + // -> typeParameter and symbol.declaration originate from the same type parameter list + // -> illegal for all declarations in symbol + // forEach === exists + links.isIllegalTypeReferenceInConstraint = ts.forEach(symbol.declarations, function (d) { return d.parent === typeParameter.parent; }); + } + } + if (links.isIllegalTypeReferenceInConstraint) { + error(typeParameter, ts.Diagnostics.Constraint_of_a_type_parameter_cannot_reference_any_type_parameter_from_the_same_type_parameter_list); + } + } + ts.forEachChild(n, check); + } + if (typeParameter.constraint) { + typeParameterSymbol = getSymbolOfNode(typeParameter); + check(typeParameter.constraint); + } + } + // Get type from reference to class or interface + function getTypeFromClassOrInterfaceReference(node, symbol) { + var type = getDeclaredTypeOfSymbol(symbol); + var typeParameters = type.localTypeParameters; + if (typeParameters) { + if (!node.typeArguments || node.typeArguments.length !== typeParameters.length) { + error(node, ts.Diagnostics.Generic_type_0_requires_1_type_argument_s, typeToString(type, /*enclosingDeclaration*/ undefined, 1 /* WriteArrayAsGenericType */), typeParameters.length); + return unknownType; + } + // In a type reference, the outer type parameters of the referenced class or interface are automatically + // supplied as type arguments and the type reference only specifies arguments for the local type parameters + // of the class or interface. + return createTypeReference(type, ts.concatenate(type.outerTypeParameters, ts.map(node.typeArguments, getTypeFromTypeNode))); + } + if (node.typeArguments) { + error(node, ts.Diagnostics.Type_0_is_not_generic, typeToString(type)); + return unknownType; + } + return type; + } + // Get type from reference to type alias. When a type alias is generic, the declared type of the type alias may include + // references to the type parameters of the alias. We replace those with the actual type arguments by instantiating the + // declared type. Instantiations are cached using the type identities of the type arguments as the key. + function getTypeFromTypeAliasReference(node, symbol) { + var type = getDeclaredTypeOfSymbol(symbol); + var links = getSymbolLinks(symbol); + var typeParameters = links.typeParameters; + if (typeParameters) { + if (!node.typeArguments || node.typeArguments.length !== typeParameters.length) { + error(node, ts.Diagnostics.Generic_type_0_requires_1_type_argument_s, symbolToString(symbol), typeParameters.length); + return unknownType; + } + var typeArguments = ts.map(node.typeArguments, getTypeFromTypeNode); + var id = getTypeListId(typeArguments); + return links.instantiations[id] || (links.instantiations[id] = instantiateType(type, createTypeMapper(typeParameters, typeArguments))); + } + if (node.typeArguments) { + error(node, ts.Diagnostics.Type_0_is_not_generic, symbolToString(symbol)); + return unknownType; + } + return type; + } + // Get type from reference to named type that cannot be generic (enum or type parameter) + function getTypeFromNonGenericTypeReference(node, symbol) { + if (symbol.flags & 262144 /* TypeParameter */ && isTypeParameterReferenceIllegalInConstraint(node, symbol)) { + // TypeScript 1.0 spec (April 2014): 3.4.1 + // Type parameters declared in a particular type parameter list + // may not be referenced in constraints in that type parameter list + // Implementation: such type references are resolved to 'unknown' type that usually denotes error + return unknownType; + } + if (node.typeArguments) { + error(node, ts.Diagnostics.Type_0_is_not_generic, symbolToString(symbol)); + return unknownType; + } + return getDeclaredTypeOfSymbol(symbol); + } + function getTypeFromTypeReference(node) { + var links = getNodeLinks(node); + if (!links.resolvedType) { + // We only support expressions that are simple qualified names. For other expressions this produces undefined. + var typeNameOrExpression = node.kind === 151 /* TypeReference */ ? node.typeName : + ts.isSupportedExpressionWithTypeArguments(node) ? node.expression : + undefined; + var symbol = typeNameOrExpression && resolveEntityName(typeNameOrExpression, 793056 /* Type */) || unknownSymbol; + var type = symbol === unknownSymbol ? unknownType : + symbol.flags & (32 /* Class */ | 64 /* Interface */) ? getTypeFromClassOrInterfaceReference(node, symbol) : + symbol.flags & 524288 /* TypeAlias */ ? getTypeFromTypeAliasReference(node, symbol) : + getTypeFromNonGenericTypeReference(node, symbol); + // Cache both the resolved symbol and the resolved type. The resolved symbol is needed in when we check the + // type reference in checkTypeReferenceOrExpressionWithTypeArguments. + links.resolvedSymbol = symbol; + links.resolvedType = type; + } + return links.resolvedType; + } + function getTypeFromTypeQueryNode(node) { + var links = getNodeLinks(node); + if (!links.resolvedType) { + // TypeScript 1.0 spec (April 2014): 3.6.3 + // The expression is processed as an identifier expression (section 4.3) + // or property access expression(section 4.10), + // the widened type(section 3.9) of which becomes the result. + links.resolvedType = getWidenedType(checkExpression(node.exprName)); + } + return links.resolvedType; + } + function getTypeOfGlobalSymbol(symbol, arity) { + function getTypeDeclaration(symbol) { + var declarations = symbol.declarations; + for (var _i = 0; _i < declarations.length; _i++) { + var declaration = declarations[_i]; + switch (declaration.kind) { + case 214 /* ClassDeclaration */: + case 215 /* InterfaceDeclaration */: + case 217 /* EnumDeclaration */: + return declaration; + } + } + } + if (!symbol) { + return arity ? emptyGenericType : emptyObjectType; + } + var type = getDeclaredTypeOfSymbol(symbol); + if (!(type.flags & 80896 /* ObjectType */)) { + error(getTypeDeclaration(symbol), ts.Diagnostics.Global_type_0_must_be_a_class_or_interface_type, symbol.name); + return arity ? emptyGenericType : emptyObjectType; + } + if ((type.typeParameters ? type.typeParameters.length : 0) !== arity) { + error(getTypeDeclaration(symbol), ts.Diagnostics.Global_type_0_must_have_1_type_parameter_s, symbol.name, arity); + return arity ? emptyGenericType : emptyObjectType; + } + return type; + } + function getGlobalValueSymbol(name) { + return getGlobalSymbol(name, 107455 /* Value */, ts.Diagnostics.Cannot_find_global_value_0); + } + function getGlobalTypeSymbol(name) { + return getGlobalSymbol(name, 793056 /* Type */, ts.Diagnostics.Cannot_find_global_type_0); + } + function getGlobalSymbol(name, meaning, diagnostic) { + return resolveName(undefined, name, meaning, diagnostic, name); + } + function getGlobalType(name, arity) { + if (arity === void 0) { arity = 0; } + return getTypeOfGlobalSymbol(getGlobalTypeSymbol(name), arity); + } + function tryGetGlobalType(name, arity) { + if (arity === void 0) { arity = 0; } + return getTypeOfGlobalSymbol(getGlobalSymbol(name, 793056 /* Type */, /*diagnostic*/ undefined), arity); + } + /** + * Returns a type that is inside a namespace at the global scope, e.g. + * getExportedTypeFromNamespace('JSX', 'Element') returns the JSX.Element type + */ + function getExportedTypeFromNamespace(namespace, name) { + var namespaceSymbol = getGlobalSymbol(namespace, 1536 /* Namespace */, /*diagnosticMessage*/ undefined); + var typeSymbol = namespaceSymbol && getSymbol(namespaceSymbol.exports, name, 793056 /* Type */); + return typeSymbol && getDeclaredTypeOfSymbol(typeSymbol); + } + function getGlobalESSymbolConstructorSymbol() { + return globalESSymbolConstructorSymbol || (globalESSymbolConstructorSymbol = getGlobalValueSymbol("Symbol")); + } + /** + * Creates a TypeReference for a generic `TypedPropertyDescriptor`. + */ + function createTypedPropertyDescriptorType(propertyType) { + var globalTypedPropertyDescriptorType = getGlobalTypedPropertyDescriptorType(); + return globalTypedPropertyDescriptorType !== emptyGenericType + ? createTypeReference(globalTypedPropertyDescriptorType, [propertyType]) + : emptyObjectType; + } + /** + * Instantiates a global type that is generic with some element type, and returns that instantiation. + */ + function createTypeFromGenericGlobalType(genericGlobalType, typeArguments) { + return genericGlobalType !== emptyGenericType ? createTypeReference(genericGlobalType, typeArguments) : emptyObjectType; + } + function createIterableType(elementType) { + return createTypeFromGenericGlobalType(globalIterableType, [elementType]); + } + function createIterableIteratorType(elementType) { + return createTypeFromGenericGlobalType(globalIterableIteratorType, [elementType]); + } + function createArrayType(elementType) { + return createTypeFromGenericGlobalType(globalArrayType, [elementType]); + } + function getTypeFromArrayTypeNode(node) { + var links = getNodeLinks(node); + if (!links.resolvedType) { + links.resolvedType = createArrayType(getTypeFromTypeNode(node.elementType)); + } + return links.resolvedType; + } + function createTupleType(elementTypes) { + var id = getTypeListId(elementTypes); + return tupleTypes[id] || (tupleTypes[id] = createNewTupleType(elementTypes)); + } + function createNewTupleType(elementTypes) { + var type = createObjectType(8192 /* Tuple */ | getPropagatingFlagsOfTypes(elementTypes)); + type.elementTypes = elementTypes; + return type; + } + function getTypeFromTupleTypeNode(node) { + var links = getNodeLinks(node); + if (!links.resolvedType) { + links.resolvedType = createTupleType(ts.map(node.elementTypes, getTypeFromTypeNode)); + } + return links.resolvedType; + } + function addTypeToSet(typeSet, type, typeSetKind) { + if (type.flags & typeSetKind) { + addTypesToSet(typeSet, type.types, typeSetKind); + } + else if (!ts.contains(typeSet, type)) { + typeSet.push(type); + } + } + // Add the given types to the given type set. Order is preserved, duplicates are removed, + // and nested types of the given kind are flattened into the set. + function addTypesToSet(typeSet, types, typeSetKind) { + for (var _i = 0; _i < types.length; _i++) { + var type = types[_i]; + addTypeToSet(typeSet, type, typeSetKind); + } + } + function isSubtypeOfAny(candidate, types) { + for (var i = 0, len = types.length; i < len; i++) { + if (candidate !== types[i] && isTypeSubtypeOf(candidate, types[i])) { + return true; + } + } + return false; + } + function removeSubtypes(types) { + var i = types.length; + while (i > 0) { + i--; + if (isSubtypeOfAny(types[i], types)) { + types.splice(i, 1); + } + } + } + function containsTypeAny(types) { + for (var _i = 0; _i < types.length; _i++) { + var type = types[_i]; + if (isTypeAny(type)) { + return true; + } + } + return false; + } + function removeAllButLast(types, typeToRemove) { + var i = types.length; + while (i > 0 && types.length > 1) { + i--; + if (types[i] === typeToRemove) { + types.splice(i, 1); + } + } + } + // We reduce the constituent type set to only include types that aren't subtypes of other types, unless + // the noSubtypeReduction flag is specified, in which case we perform a simple deduplication based on + // object identity. Subtype reduction is possible only when union types are known not to circularly + // reference themselves (as is the case with union types created by expression constructs such as array + // literals and the || and ?: operators). Named types can circularly reference themselves and therefore + // cannot be deduplicated during their declaration. For example, "type Item = string | (() => Item" is + // a named type that circularly references itself. + function getUnionType(types, noSubtypeReduction) { + if (types.length === 0) { + return emptyObjectType; + } + var typeSet = []; + addTypesToSet(typeSet, types, 16384 /* Union */); + if (containsTypeAny(typeSet)) { + return anyType; + } + if (noSubtypeReduction) { + removeAllButLast(typeSet, undefinedType); + removeAllButLast(typeSet, nullType); + } + else { + removeSubtypes(typeSet); + } + if (typeSet.length === 1) { + return typeSet[0]; + } + var id = getTypeListId(typeSet); + var type = unionTypes[id]; + if (!type) { + type = unionTypes[id] = createObjectType(16384 /* Union */ | getPropagatingFlagsOfTypes(typeSet)); + type.types = typeSet; + } + return type; + } + function getTypeFromUnionTypeNode(node) { + var links = getNodeLinks(node); + if (!links.resolvedType) { + links.resolvedType = getUnionType(ts.map(node.types, getTypeFromTypeNode), /*noSubtypeReduction*/ true); + } + return links.resolvedType; + } + // 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. + // Also, unlike union types, the order of the constituent types is preserved in order that overload resolution + // for intersections of types with signatures can be deterministic. + function getIntersectionType(types) { + if (types.length === 0) { + return emptyObjectType; + } + var typeSet = []; + addTypesToSet(typeSet, types, 32768 /* Intersection */); + if (containsTypeAny(typeSet)) { + return anyType; + } + if (typeSet.length === 1) { + return typeSet[0]; + } + var id = getTypeListId(typeSet); + var type = intersectionTypes[id]; + if (!type) { + type = intersectionTypes[id] = createObjectType(32768 /* Intersection */ | getPropagatingFlagsOfTypes(typeSet)); + type.types = typeSet; + } + return type; + } + function getTypeFromIntersectionTypeNode(node) { + var links = getNodeLinks(node); + if (!links.resolvedType) { + links.resolvedType = getIntersectionType(ts.map(node.types, getTypeFromTypeNode)); + } + return links.resolvedType; + } + function getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node) { + var links = getNodeLinks(node); + if (!links.resolvedType) { + // Deferred resolution of members is handled by resolveObjectTypeMembers + links.resolvedType = createObjectType(65536 /* Anonymous */, node.symbol); + } + return links.resolvedType; + } + function getStringLiteralType(node) { + if (ts.hasProperty(stringLiteralTypes, node.text)) { + return stringLiteralTypes[node.text]; + } + var type = stringLiteralTypes[node.text] = createType(256 /* StringLiteral */); + type.text = ts.getTextOfNode(node); + return type; + } + function getTypeFromStringLiteral(node) { + var links = getNodeLinks(node); + if (!links.resolvedType) { + links.resolvedType = getStringLiteralType(node); + } + return links.resolvedType; + } + function getThisType(node) { + var container = ts.getThisContainer(node, /*includeArrowFunctions*/ false); + var parent = container && container.parent; + if (parent && (ts.isClassLike(parent) || parent.kind === 215 /* InterfaceDeclaration */)) { + if (!(container.flags & 128 /* Static */)) { + return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(parent)).thisType; + } + } + error(node, ts.Diagnostics.A_this_type_is_available_only_in_a_non_static_member_of_a_class_or_interface); + return unknownType; + } + function getTypeFromThisTypeNode(node) { + var links = getNodeLinks(node); + if (!links.resolvedType) { + links.resolvedType = getThisType(node); + } + return links.resolvedType; + } + function getTypeFromTypeNode(node) { + switch (node.kind) { + case 117 /* AnyKeyword */: + return anyType; + case 130 /* StringKeyword */: + return stringType; + case 128 /* NumberKeyword */: + return numberType; + case 120 /* BooleanKeyword */: + return booleanType; + case 131 /* SymbolKeyword */: + return esSymbolType; + case 103 /* VoidKeyword */: + return voidType; + case 97 /* ThisKeyword */: + return getTypeFromThisTypeNode(node); + case 9 /* StringLiteral */: + return getTypeFromStringLiteral(node); + case 151 /* TypeReference */: + return getTypeFromTypeReference(node); + case 150 /* TypePredicate */: + return booleanType; + case 188 /* ExpressionWithTypeArguments */: + return getTypeFromTypeReference(node); + case 154 /* TypeQuery */: + return getTypeFromTypeQueryNode(node); + case 156 /* ArrayType */: + return getTypeFromArrayTypeNode(node); + case 157 /* TupleType */: + return getTypeFromTupleTypeNode(node); + case 158 /* UnionType */: + return getTypeFromUnionTypeNode(node); + case 159 /* IntersectionType */: + return getTypeFromIntersectionTypeNode(node); + case 160 /* ParenthesizedType */: + return getTypeFromTypeNode(node.type); + case 152 /* FunctionType */: + case 153 /* ConstructorType */: + case 155 /* TypeLiteral */: + return getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node); + // This function assumes that an identifier or qualified name is a type expression + // Callers should first ensure this by calling isTypeNode + case 69 /* Identifier */: + case 135 /* QualifiedName */: + var symbol = getSymbolAtLocation(node); + return symbol && getDeclaredTypeOfSymbol(symbol); + default: + return unknownType; + } + } + function instantiateList(items, mapper, instantiator) { + if (items && items.length) { + var result = []; + for (var _i = 0; _i < items.length; _i++) { + var v = items[_i]; + result.push(instantiator(v, mapper)); + } + return result; + } + return items; + } + function createUnaryTypeMapper(source, target) { + return function (t) { return t === source ? target : t; }; + } + function createBinaryTypeMapper(source1, target1, source2, target2) { + return function (t) { return t === source1 ? target1 : t === source2 ? target2 : t; }; + } + function createTypeMapper(sources, targets) { + switch (sources.length) { + case 1: return createUnaryTypeMapper(sources[0], targets[0]); + case 2: return createBinaryTypeMapper(sources[0], targets[0], sources[1], targets[1]); + } + return function (t) { + for (var i = 0; i < sources.length; i++) { + if (t === sources[i]) { + return targets[i]; + } + } + return t; + }; + } + function createUnaryTypeEraser(source) { + return function (t) { return t === source ? anyType : t; }; + } + function createBinaryTypeEraser(source1, source2) { + return function (t) { return t === source1 || t === source2 ? anyType : t; }; + } + function createTypeEraser(sources) { + switch (sources.length) { + case 1: return createUnaryTypeEraser(sources[0]); + case 2: return createBinaryTypeEraser(sources[0], sources[1]); + } + return function (t) { + for (var _i = 0; _i < sources.length; _i++) { + var source = sources[_i]; + if (t === source) { + return anyType; + } + } + return t; + }; + } + function createInferenceMapper(context) { + var mapper = function (t) { + for (var i = 0; i < context.typeParameters.length; i++) { + if (t === context.typeParameters[i]) { + context.inferences[i].isFixed = true; + return getInferredType(context, i); + } + } + return t; + }; + mapper.context = context; + return mapper; + } + function identityMapper(type) { + return type; + } + function combineTypeMappers(mapper1, mapper2) { + return function (t) { return instantiateType(mapper1(t), mapper2); }; + } + function instantiateTypeParameter(typeParameter, mapper) { + var result = createType(512 /* TypeParameter */); + result.symbol = typeParameter.symbol; + if (typeParameter.constraint) { + result.constraint = instantiateType(typeParameter.constraint, mapper); + } + else { + result.target = typeParameter; + result.mapper = mapper; + } + return result; + } + function instantiateSignature(signature, mapper, eraseTypeParameters) { + var freshTypeParameters; + var freshTypePredicate; + if (signature.typeParameters && !eraseTypeParameters) { + freshTypeParameters = instantiateList(signature.typeParameters, mapper, instantiateTypeParameter); + mapper = combineTypeMappers(createTypeMapper(signature.typeParameters, freshTypeParameters), mapper); + } + if (signature.typePredicate) { + freshTypePredicate = { + parameterName: signature.typePredicate.parameterName, + parameterIndex: signature.typePredicate.parameterIndex, + type: instantiateType(signature.typePredicate.type, mapper) + }; + } + var result = createSignature(signature.declaration, freshTypeParameters, instantiateList(signature.parameters, mapper, instantiateSymbol), instantiateType(signature.resolvedReturnType, mapper), freshTypePredicate, signature.minArgumentCount, signature.hasRestParameter, signature.hasStringLiterals); + result.target = signature; + result.mapper = mapper; + return result; + } + function instantiateSymbol(symbol, mapper) { + if (symbol.flags & 16777216 /* Instantiated */) { + var links = getSymbolLinks(symbol); + // If symbol being instantiated is itself a instantiation, fetch the original target and combine the + // type mappers. This ensures that original type identities are properly preserved and that aliases + // always reference a non-aliases. + symbol = links.target; + mapper = combineTypeMappers(links.mapper, mapper); + } + // Keep the flags from the symbol we're instantiating. Mark that is instantiated, and + // also transient so that we can just store data on it directly. + var result = createSymbol(16777216 /* Instantiated */ | 67108864 /* Transient */ | symbol.flags, symbol.name); + result.declarations = symbol.declarations; + result.parent = symbol.parent; + result.target = symbol; + result.mapper = mapper; + if (symbol.valueDeclaration) { + result.valueDeclaration = symbol.valueDeclaration; + } + return result; + } + function instantiateAnonymousType(type, mapper) { + if (mapper.instantiations) { + var cachedType = mapper.instantiations[type.id]; + if (cachedType) { + return cachedType; + } + } + else { + mapper.instantiations = []; + } + // Mark the anonymous type as instantiated such that our infinite instantiation detection logic can recognize it + var result = createObjectType(65536 /* Anonymous */ | 131072 /* Instantiated */, type.symbol); + result.target = type; + result.mapper = mapper; + mapper.instantiations[type.id] = result; + return result; + } + function instantiateType(type, mapper) { + if (type && mapper !== identityMapper) { + if (type.flags & 512 /* TypeParameter */) { + return mapper(type); + } + if (type.flags & 65536 /* Anonymous */) { + return type.symbol && type.symbol.flags & (16 /* Function */ | 8192 /* Method */ | 32 /* Class */ | 2048 /* TypeLiteral */ | 4096 /* ObjectLiteral */) ? + instantiateAnonymousType(type, mapper) : type; + } + if (type.flags & 4096 /* Reference */) { + return createTypeReference(type.target, instantiateList(type.typeArguments, mapper, instantiateType)); + } + if (type.flags & 8192 /* Tuple */) { + return createTupleType(instantiateList(type.elementTypes, mapper, instantiateType)); + } + if (type.flags & 16384 /* Union */) { + return getUnionType(instantiateList(type.types, mapper, instantiateType), /*noSubtypeReduction*/ true); + } + if (type.flags & 32768 /* Intersection */) { + return getIntersectionType(instantiateList(type.types, mapper, instantiateType)); + } + } + return type; + } + // 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 !== 143 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + switch (node.kind) { + case 173 /* FunctionExpression */: + case 174 /* ArrowFunction */: + return isContextSensitiveFunctionLikeDeclaration(node); + case 165 /* ObjectLiteralExpression */: + return ts.forEach(node.properties, isContextSensitive); + case 164 /* ArrayLiteralExpression */: + return ts.forEach(node.elements, isContextSensitive); + case 182 /* ConditionalExpression */: + return isContextSensitive(node.whenTrue) || + isContextSensitive(node.whenFalse); + case 181 /* BinaryExpression */: + return node.operatorToken.kind === 52 /* BarBarToken */ && + (isContextSensitive(node.left) || isContextSensitive(node.right)); + case 245 /* PropertyAssignment */: + return isContextSensitive(node.initializer); + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: + return isContextSensitiveFunctionLikeDeclaration(node); + case 172 /* ParenthesizedExpression */: + return isContextSensitive(node.expression); + } + return false; + } + function isContextSensitiveFunctionLikeDeclaration(node) { + return !node.typeParameters && node.parameters.length && !ts.forEach(node.parameters, function (p) { return p.type; }); + } + function getTypeWithoutSignatures(type) { + if (type.flags & 80896 /* ObjectType */) { + var resolved = resolveStructuredTypeMembers(type); + if (resolved.constructSignatures.length) { + var result = createObjectType(65536 /* Anonymous */, type.symbol); + result.members = resolved.members; + result.properties = resolved.properties; + result.callSignatures = emptyArray; + result.constructSignatures = emptyArray; + type = result; + } + } + return type; + } + // TYPE CHECKING + function isTypeIdenticalTo(source, target) { + return checkTypeRelatedTo(source, target, identityRelation, /*errorNode*/ undefined); + } + function compareTypes(source, target) { + return checkTypeRelatedTo(source, target, identityRelation, /*errorNode*/ undefined) ? -1 /* True */ : 0 /* False */; + } + function isTypeSubtypeOf(source, target) { + return checkTypeSubtypeOf(source, target, /*errorNode*/ undefined); + } + function isTypeAssignableTo(source, target) { + return checkTypeAssignableTo(source, target, /*errorNode*/ undefined); + } + function checkTypeSubtypeOf(source, target, errorNode, headMessage, containingMessageChain) { + return checkTypeRelatedTo(source, target, subtypeRelation, errorNode, headMessage, containingMessageChain); + } + function checkTypeAssignableTo(source, target, errorNode, headMessage, containingMessageChain) { + return checkTypeRelatedTo(source, target, assignableRelation, errorNode, headMessage, containingMessageChain); + } + function isSignatureAssignableTo(source, target) { + var sourceType = getOrCreateTypeFromSignature(source); + var targetType = getOrCreateTypeFromSignature(target); + return checkTypeRelatedTo(sourceType, targetType, assignableRelation, /*errorNode*/ undefined); + } + /** + * Checks if 'source' is related to 'target' (e.g.: is a assignable to). + * @param source The left-hand-side of the relation. + * @param target The right-hand-side of the relation. + * @param relation The relation considered. One of 'identityRelation', 'assignableRelation', or 'subTypeRelation'. + * Used as both to determine which checks are performed and as a cache of previously computed results. + * @param errorNode The suggested node upon which all errors will be reported, if defined. This may or may not be the actual node used. + * @param headMessage If the error chain should be prepended by a head message, then headMessage will be used. + * @param containingMessageChain A chain of errors to prepend any new errors found. + */ + function checkTypeRelatedTo(source, target, relation, errorNode, headMessage, containingMessageChain) { + var errorInfo; + var sourceStack; + var targetStack; + var maybeStack; + var expandingFlags; + var depth = 0; + var overflow = false; + var elaborateErrors = false; + ts.Debug.assert(relation !== identityRelation || !errorNode, "no error reporting in identity checking"); + var result = isRelatedTo(source, target, errorNode !== undefined, headMessage); + if (overflow) { + error(errorNode, ts.Diagnostics.Excessive_stack_depth_comparing_types_0_and_1, typeToString(source), typeToString(target)); + } + else if (errorInfo) { + // If we already computed this relation, but in a context where we didn't want to report errors (e.g. overload resolution), + // then we'll only have a top-level error (e.g. 'Class X does not implement interface Y') without any details. If this happened, + // request a recompuation to get a complete error message. This will be skipped if we've already done this computation in a context + // where errors were being reported. + if (errorInfo.next === undefined) { + errorInfo = undefined; + elaborateErrors = true; + isRelatedTo(source, target, errorNode !== undefined, headMessage); + } + if (containingMessageChain) { + errorInfo = ts.concatenateDiagnosticMessageChains(containingMessageChain, errorInfo); + } + diagnostics.add(ts.createDiagnosticForNodeFromMessageChain(errorNode, errorInfo)); + } + return result !== 0 /* False */; + function reportError(message, arg0, arg1, arg2) { + errorInfo = ts.chainDiagnosticMessages(errorInfo, message, arg0, arg1, arg2); + } + function reportRelationError(message, source, target) { + var sourceType = typeToString(source); + var targetType = typeToString(target); + if (sourceType === targetType) { + sourceType = typeToString(source, /*enclosingDeclaration*/ undefined, 128 /* UseFullyQualifiedType */); + targetType = typeToString(target, /*enclosingDeclaration*/ undefined, 128 /* UseFullyQualifiedType */); + } + reportError(message || ts.Diagnostics.Type_0_is_not_assignable_to_type_1, sourceType, targetType); + } + // Compare two types and return + // Ternary.True if they are related with no assumptions, + // Ternary.Maybe if they are related with assumptions of other relationships, or + // Ternary.False if they are not related. + function isRelatedTo(source, target, reportErrors, headMessage) { + var result; + // both types are the same - covers 'they are the same primitive type or both are Any' or the same type parameter cases + if (source === target) + return -1 /* True */; + if (relation === identityRelation) { + return isIdenticalTo(source, target); + } + if (isTypeAny(target)) + return -1 /* True */; + if (source === undefinedType) + return -1 /* True */; + if (source === nullType && target !== undefinedType) + return -1 /* True */; + if (source.flags & 128 /* Enum */ && target === numberType) + return -1 /* True */; + if (source.flags & 256 /* StringLiteral */ && target === stringType) + return -1 /* True */; + if (relation === assignableRelation) { + if (isTypeAny(source)) + return -1 /* True */; + if (source === numberType && target.flags & 128 /* Enum */) + return -1 /* True */; + } + if (source.flags & 1048576 /* FreshObjectLiteral */) { + if (hasExcessProperties(source, target, reportErrors)) { + if (reportErrors) { + reportRelationError(headMessage, source, target); + } + return 0 /* False */; + } + // Above we check for excess properties with respect to the entire target type. When union + // and intersection types are further deconstructed on the target side, we don't want to + // make the check again (as it might fail for a partial target type). Therefore we obtain + // the regular source type and proceed with that. + if (target.flags & 49152 /* UnionOrIntersection */) { + source = getRegularTypeOfObjectLiteral(source); + } + } + var saveErrorInfo = errorInfo; + // Note that the "each" checks must precede the "some" checks to produce the correct results + if (source.flags & 16384 /* Union */) { + if (result = eachTypeRelatedToType(source, target, reportErrors)) { + return result; + } + } + else if (target.flags & 32768 /* Intersection */) { + if (result = typeRelatedToEachType(source, target, reportErrors)) { + return result; + } + } + else { + // It is necessary to try "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 & 32768 /* Intersection */) { + // If target is a union type the following check will report errors so we suppress them here + if (result = someTypeRelatedToType(source, target, reportErrors && !(target.flags & 16384 /* Union */))) { + return result; + } + } + if (target.flags & 16384 /* Union */) { + if (result = typeRelatedToSomeType(source, target, reportErrors)) { + return result; + } + } + } + if (source.flags & 512 /* TypeParameter */) { + var constraint = getConstraintOfTypeParameter(source); + if (!constraint || constraint.flags & 1 /* Any */) { + constraint = emptyObjectType; + } + // Report constraint errors only if the constraint is not the empty object type + var reportConstraintErrors = reportErrors && constraint !== emptyObjectType; + if (result = isRelatedTo(constraint, target, reportConstraintErrors)) { + errorInfo = saveErrorInfo; + return result; + } + } + else { + if (source.flags & 4096 /* Reference */ && target.flags & 4096 /* Reference */ && source.target === target.target) { + // We have type references to same target type, see if relationship holds for all type arguments + if (result = typeArgumentsRelatedTo(source, target, reportErrors)) { + return result; + } + } + // Even if relationship doesn't hold for unions, intersections, or generic type references, + // it may hold in a structural comparison. + var apparentType = getApparentType(source); + // 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 (apparentType.flags & (80896 /* ObjectType */ | 32768 /* Intersection */) && target.flags & 80896 /* ObjectType */) { + // Report structural errors only if we haven't reported any errors yet + var reportStructuralErrors = reportErrors && errorInfo === saveErrorInfo; + if (result = objectTypeRelatedTo(apparentType, source, target, reportStructuralErrors)) { + errorInfo = saveErrorInfo; + return result; + } + } + } + if (reportErrors) { + reportRelationError(headMessage, source, target); + } + return 0 /* False */; + } + function isIdenticalTo(source, target) { + var result; + if (source.flags & 80896 /* ObjectType */ && target.flags & 80896 /* ObjectType */) { + if (source.flags & 4096 /* Reference */ && target.flags & 4096 /* Reference */ && source.target === target.target) { + // We have type references to same target type, see if all type arguments are identical + if (result = typeArgumentsRelatedTo(source, target, /*reportErrors*/ false)) { + return result; + } + } + return objectTypeRelatedTo(source, source, target, /*reportErrors*/ false); + } + if (source.flags & 512 /* TypeParameter */ && target.flags & 512 /* TypeParameter */) { + return typeParameterIdenticalTo(source, target); + } + if (source.flags & 16384 /* Union */ && target.flags & 16384 /* Union */ || + source.flags & 32768 /* Intersection */ && target.flags & 32768 /* Intersection */) { + if (result = eachTypeRelatedToSomeType(source, target)) { + if (result &= eachTypeRelatedToSomeType(target, source)) { + return result; + } + } + } + return 0 /* False */; + } + // Check if a property with the given name is known anywhere in the given type. In an object type, a property + // is considered known if the object type is empty and the check is for assignability, if the object type has + // 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, name) { + if (type.flags & 80896 /* ObjectType */) { + var resolved = resolveStructuredTypeMembers(type); + if (relation === assignableRelation && (type === globalObjectType || resolved.properties.length === 0) || + resolved.stringIndexType || resolved.numberIndexType || getPropertyOfType(type, name)) { + return true; + } + } + else if (type.flags & 49152 /* UnionOrIntersection */) { + for (var _i = 0, _a = type.types; _i < _a.length; _i++) { + var t = _a[_i]; + if (isKnownProperty(t, name)) { + return true; + } + } + } + return false; + } + function hasExcessProperties(source, target, reportErrors) { + if (someConstituentTypeHasKind(target, 80896 /* ObjectType */)) { + for (var _i = 0, _a = getPropertiesOfObjectType(source); _i < _a.length; _i++) { + var prop = _a[_i]; + if (!isKnownProperty(target, prop.name)) { + if (reportErrors) { + // We know *exactly* where things went wrong when comparing the types. + // Use this property as the error node as this will be more helpful in + // reasoning about what went wrong. + errorNode = prop.valueDeclaration; + reportError(ts.Diagnostics.Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1, symbolToString(prop), typeToString(target)); + } + return true; + } + } + } + return false; + } + function eachTypeRelatedToSomeType(source, target) { + var result = -1 /* True */; + var sourceTypes = source.types; + for (var _i = 0; _i < sourceTypes.length; _i++) { + var sourceType = sourceTypes[_i]; + var related = typeRelatedToSomeType(sourceType, target, false); + if (!related) { + return 0 /* False */; + } + result &= related; + } + return result; + } + function typeRelatedToSomeType(source, target, reportErrors) { + var targetTypes = target.types; + for (var i = 0, len = targetTypes.length; i < len; i++) { + var related = isRelatedTo(source, targetTypes[i], reportErrors && i === len - 1); + if (related) { + return related; + } + } + return 0 /* False */; + } + function typeRelatedToEachType(source, target, reportErrors) { + var result = -1 /* True */; + var targetTypes = target.types; + for (var _i = 0; _i < targetTypes.length; _i++) { + var targetType = targetTypes[_i]; + var related = isRelatedTo(source, targetType, reportErrors); + if (!related) { + return 0 /* False */; + } + result &= related; + } + return result; + } + function someTypeRelatedToType(source, target, reportErrors) { + var sourceTypes = source.types; + for (var i = 0, len = sourceTypes.length; i < len; i++) { + var related = isRelatedTo(sourceTypes[i], target, reportErrors && i === len - 1); + if (related) { + return related; + } + } + return 0 /* False */; + } + function eachTypeRelatedToType(source, target, reportErrors) { + var result = -1 /* True */; + var sourceTypes = source.types; + for (var _i = 0; _i < sourceTypes.length; _i++) { + var sourceType = sourceTypes[_i]; + var related = isRelatedTo(sourceType, target, reportErrors); + if (!related) { + return 0 /* False */; + } + result &= related; + } + return result; + } + function typeArgumentsRelatedTo(source, target, reportErrors) { + var sources = source.typeArguments || emptyArray; + var targets = target.typeArguments || emptyArray; + if (sources.length !== targets.length && relation === identityRelation) { + return 0 /* False */; + } + var result = -1 /* True */; + for (var i = 0; i < targets.length; i++) { + var related = isRelatedTo(sources[i], targets[i], reportErrors); + if (!related) { + return 0 /* False */; + } + result &= related; + } + return result; + } + function typeParameterIdenticalTo(source, target) { + if (source.symbol.name !== target.symbol.name) { + return 0 /* False */; + } + // covers case when both type parameters does not have constraint (both equal to noConstraintType) + if (source.constraint === target.constraint) { + return -1 /* True */; + } + if (source.constraint === noConstraintType || target.constraint === noConstraintType) { + return 0 /* False */; + } + return isIdenticalTo(source.constraint, target.constraint); + } + // Determine if two object types are related by structure. First, check if the result is already available in the global cache. + // Second, check if we have already started a comparison of the given two types in which case we assume the result to be true. + // Third, check if both types are part of deeply nested chains of generic type instantiations and if so assume the types are + // equal and infinitely expanding. Fourth, if we have reached a depth of 100 nested comparisons, assume we have runaway recursion + // and issue an error. Otherwise, actually compare the structure of the two types. + function objectTypeRelatedTo(apparentSource, originalSource, target, reportErrors) { + if (overflow) { + return 0 /* False */; + } + var id = relation !== identityRelation || apparentSource.id < target.id ? apparentSource.id + "," + target.id : target.id + "," + apparentSource.id; + var related = relation[id]; + if (related !== undefined) { + // If we computed this relation already and it was failed and reported, or if we're not being asked to elaborate + // errors, we can use the cached value. Otherwise, recompute the relation + if (!elaborateErrors || (related === 3 /* FailedAndReported */)) { + return related === 1 /* Succeeded */ ? -1 /* True */ : 0 /* False */; + } + } + if (depth > 0) { + for (var i = 0; i < depth; i++) { + // If source and target are already being compared, consider them related with assumptions + if (maybeStack[i][id]) { + return 1 /* Maybe */; + } + } + if (depth === 100) { + overflow = true; + return 0 /* False */; + } + } + else { + sourceStack = []; + targetStack = []; + maybeStack = []; + expandingFlags = 0; + } + sourceStack[depth] = apparentSource; + targetStack[depth] = target; + maybeStack[depth] = {}; + maybeStack[depth][id] = 1 /* Succeeded */; + depth++; + var saveExpandingFlags = expandingFlags; + if (!(expandingFlags & 1) && isDeeplyNestedGeneric(apparentSource, sourceStack, depth)) + expandingFlags |= 1; + if (!(expandingFlags & 2) && isDeeplyNestedGeneric(target, targetStack, depth)) + expandingFlags |= 2; + var result; + if (expandingFlags === 3) { + result = 1 /* Maybe */; + } + else { + result = propertiesRelatedTo(apparentSource, target, reportErrors); + if (result) { + result &= signaturesRelatedTo(apparentSource, target, 0 /* Call */, reportErrors); + if (result) { + result &= signaturesRelatedTo(apparentSource, target, 1 /* Construct */, reportErrors); + if (result) { + result &= stringIndexTypesRelatedTo(apparentSource, originalSource, target, reportErrors); + if (result) { + result &= numberIndexTypesRelatedTo(apparentSource, originalSource, target, reportErrors); + } + } + } + } + } + expandingFlags = saveExpandingFlags; + depth--; + if (result) { + var maybeCache = maybeStack[depth]; + // If result is definitely true, copy assumptions to global cache, else copy to next level up + var destinationCache = (result === -1 /* True */ || depth === 0) ? relation : maybeStack[depth - 1]; + ts.copyMap(maybeCache, destinationCache); + } + else { + // A false result goes straight into global cache (when something is false under assumptions it + // will also be false without assumptions) + relation[id] = reportErrors ? 3 /* FailedAndReported */ : 2 /* Failed */; + } + return result; + } + function propertiesRelatedTo(source, target, reportErrors) { + if (relation === identityRelation) { + return propertiesIdenticalTo(source, target); + } + var result = -1 /* True */; + var properties = getPropertiesOfObjectType(target); + var requireOptionalProperties = relation === subtypeRelation && !(source.flags & 524288 /* ObjectLiteral */); + for (var _i = 0; _i < properties.length; _i++) { + var targetProp = properties[_i]; + var sourceProp = getPropertyOfType(source, targetProp.name); + if (sourceProp !== targetProp) { + if (!sourceProp) { + if (!(targetProp.flags & 536870912 /* Optional */) || requireOptionalProperties) { + if (reportErrors) { + reportError(ts.Diagnostics.Property_0_is_missing_in_type_1, symbolToString(targetProp), typeToString(source)); + } + return 0 /* False */; + } + } + else if (!(targetProp.flags & 134217728 /* Prototype */)) { + var sourcePropFlags = getDeclarationFlagsFromSymbol(sourceProp); + var targetPropFlags = getDeclarationFlagsFromSymbol(targetProp); + if (sourcePropFlags & 32 /* Private */ || targetPropFlags & 32 /* Private */) { + if (sourceProp.valueDeclaration !== targetProp.valueDeclaration) { + if (reportErrors) { + if (sourcePropFlags & 32 /* Private */ && targetPropFlags & 32 /* Private */) { + reportError(ts.Diagnostics.Types_have_separate_declarations_of_a_private_property_0, symbolToString(targetProp)); + } + else { + reportError(ts.Diagnostics.Property_0_is_private_in_type_1_but_not_in_type_2, symbolToString(targetProp), typeToString(sourcePropFlags & 32 /* Private */ ? source : target), typeToString(sourcePropFlags & 32 /* Private */ ? target : source)); + } + } + return 0 /* False */; + } + } + else if (targetPropFlags & 64 /* Protected */) { + var sourceDeclaredInClass = sourceProp.parent && sourceProp.parent.flags & 32 /* Class */; + var sourceClass = sourceDeclaredInClass ? getDeclaredTypeOfSymbol(sourceProp.parent) : undefined; + var targetClass = getDeclaredTypeOfSymbol(targetProp.parent); + if (!sourceClass || !hasBaseType(sourceClass, targetClass)) { + if (reportErrors) { + reportError(ts.Diagnostics.Property_0_is_protected_but_type_1_is_not_a_class_derived_from_2, symbolToString(targetProp), typeToString(sourceClass || source), typeToString(targetClass)); + } + return 0 /* False */; + } + } + else if (sourcePropFlags & 64 /* Protected */) { + if (reportErrors) { + reportError(ts.Diagnostics.Property_0_is_protected_in_type_1_but_public_in_type_2, symbolToString(targetProp), typeToString(source), typeToString(target)); + } + return 0 /* False */; + } + var related = isRelatedTo(getTypeOfSymbol(sourceProp), getTypeOfSymbol(targetProp), reportErrors); + if (!related) { + if (reportErrors) { + reportError(ts.Diagnostics.Types_of_property_0_are_incompatible, symbolToString(targetProp)); + } + return 0 /* False */; + } + result &= related; + if (sourceProp.flags & 536870912 /* Optional */ && !(targetProp.flags & 536870912 /* Optional */)) { + // TypeScript 1.0 spec (April 2014): 3.8.3 + // S is a subtype of a type T, and T is a supertype of S if ... + // S' and T are object types and, for each member M in T.. + // M is a property and S' contains a property N where + // if M is a required property, N is also a required property + // (M - property in T) + // (N - property in S) + if (reportErrors) { + reportError(ts.Diagnostics.Property_0_is_optional_in_type_1_but_required_in_type_2, symbolToString(targetProp), typeToString(source), typeToString(target)); + } + return 0 /* False */; + } + } + } + } + return result; + } + function propertiesIdenticalTo(source, target) { + if (!(source.flags & 80896 /* ObjectType */ && target.flags & 80896 /* ObjectType */)) { + return 0 /* False */; + } + var sourceProperties = getPropertiesOfObjectType(source); + var targetProperties = getPropertiesOfObjectType(target); + if (sourceProperties.length !== targetProperties.length) { + return 0 /* False */; + } + var result = -1 /* True */; + for (var _i = 0; _i < sourceProperties.length; _i++) { + var sourceProp = sourceProperties[_i]; + var targetProp = getPropertyOfObjectType(target, sourceProp.name); + if (!targetProp) { + return 0 /* False */; + } + var related = compareProperties(sourceProp, targetProp, isRelatedTo); + if (!related) { + return 0 /* False */; + } + result &= related; + } + return result; + } + function signaturesRelatedTo(source, target, kind, reportErrors) { + if (relation === identityRelation) { + return signaturesIdenticalTo(source, target, kind); + } + if (target === anyFunctionType || source === anyFunctionType) { + return -1 /* True */; + } + var sourceSignatures = getSignaturesOfType(source, kind); + var targetSignatures = getSignaturesOfType(target, kind); + var result = -1 /* True */; + var saveErrorInfo = errorInfo; + if (kind === 1 /* Construct */) { + // Only want to compare the construct signatures for abstractness guarantees. + // Because the "abstractness" of a class is the same across all construct signatures + // (internally we are checking the corresponding declaration), it is enough to perform + // the check and report an error once over all pairs of source and target construct signatures. + // + // sourceSig and targetSig are (possibly) undefined. + // + // Note that in an extends-clause, targetSignatures is stripped, so the check never proceeds. + var sourceSig = sourceSignatures[0]; + var targetSig = targetSignatures[0]; + result &= abstractSignatureRelatedTo(source, sourceSig, target, targetSig); + if (result !== -1 /* True */) { + return result; + } + } + outer: for (var _i = 0; _i < targetSignatures.length; _i++) { + var t = targetSignatures[_i]; + if (!t.hasStringLiterals || target.flags & 262144 /* FromSignature */) { + var localErrors = reportErrors; + var checkedAbstractAssignability = false; + for (var _a = 0; _a < sourceSignatures.length; _a++) { + var s = sourceSignatures[_a]; + if (!s.hasStringLiterals || source.flags & 262144 /* FromSignature */) { + var related = signatureRelatedTo(s, t, localErrors); + if (related) { + result &= related; + errorInfo = saveErrorInfo; + continue outer; + } + // Only report errors from the first failure + localErrors = false; + } + } + return 0 /* False */; + } + } + return result; + function abstractSignatureRelatedTo(source, sourceSig, target, targetSig) { + if (sourceSig && targetSig) { + var sourceDecl = source.symbol && getClassLikeDeclarationOfSymbol(source.symbol); + var targetDecl = target.symbol && getClassLikeDeclarationOfSymbol(target.symbol); + if (!sourceDecl) { + // If the source object isn't itself a class declaration, it can be freely assigned, regardless + // of whether the constructed object is abstract or not. + return -1 /* True */; + } + var sourceErasedSignature = getErasedSignature(sourceSig); + var targetErasedSignature = getErasedSignature(targetSig); + var sourceReturnType = sourceErasedSignature && getReturnTypeOfSignature(sourceErasedSignature); + var targetReturnType = targetErasedSignature && getReturnTypeOfSignature(targetErasedSignature); + var sourceReturnDecl = sourceReturnType && sourceReturnType.symbol && getClassLikeDeclarationOfSymbol(sourceReturnType.symbol); + var targetReturnDecl = targetReturnType && targetReturnType.symbol && getClassLikeDeclarationOfSymbol(targetReturnType.symbol); + var sourceIsAbstract = sourceReturnDecl && sourceReturnDecl.flags & 256 /* Abstract */; + var targetIsAbstract = targetReturnDecl && targetReturnDecl.flags & 256 /* Abstract */; + if (sourceIsAbstract && !(targetIsAbstract && targetDecl)) { + // if target isn't a class-declaration type, then it can be new'd, so we forbid the assignment. + if (reportErrors) { + reportError(ts.Diagnostics.Cannot_assign_an_abstract_constructor_type_to_a_non_abstract_constructor_type); + } + return 0 /* False */; + } + } + return -1 /* True */; + } + } + function signatureRelatedTo(source, target, reportErrors) { + if (source === target) { + return -1 /* True */; + } + if (!target.hasRestParameter && source.minArgumentCount > target.parameters.length) { + return 0 /* False */; + } + var sourceMax = source.parameters.length; + var targetMax = target.parameters.length; + var checkCount; + if (source.hasRestParameter && target.hasRestParameter) { + checkCount = sourceMax > targetMax ? sourceMax : targetMax; + sourceMax--; + targetMax--; + } + else if (source.hasRestParameter) { + sourceMax--; + checkCount = targetMax; + } + else if (target.hasRestParameter) { + targetMax--; + checkCount = sourceMax; + } + else { + checkCount = sourceMax < targetMax ? sourceMax : targetMax; + } + // Spec 1.0 Section 3.8.3 & 3.8.4: + // M and N (the signatures) are instantiated using type Any as the type argument for all type parameters declared by M and N + source = getErasedSignature(source); + target = getErasedSignature(target); + var result = -1 /* True */; + for (var i = 0; i < checkCount; i++) { + var s = i < sourceMax ? getTypeOfSymbol(source.parameters[i]) : getRestTypeOfSignature(source); + var t = i < targetMax ? getTypeOfSymbol(target.parameters[i]) : getRestTypeOfSignature(target); + var saveErrorInfo = errorInfo; + var related = isRelatedTo(s, t, reportErrors); + if (!related) { + related = isRelatedTo(t, s, false); + if (!related) { + if (reportErrors) { + reportError(ts.Diagnostics.Types_of_parameters_0_and_1_are_incompatible, source.parameters[i < sourceMax ? i : sourceMax].name, target.parameters[i < targetMax ? i : targetMax].name); + } + return 0 /* False */; + } + errorInfo = saveErrorInfo; + } + result &= related; + } + if (source.typePredicate && target.typePredicate) { + var hasDifferentParameterIndex = source.typePredicate.parameterIndex !== target.typePredicate.parameterIndex; + var hasDifferentTypes; + if (hasDifferentParameterIndex || + (hasDifferentTypes = !isTypeIdenticalTo(source.typePredicate.type, target.typePredicate.type))) { + if (reportErrors) { + var sourceParamText = source.typePredicate.parameterName; + var targetParamText = target.typePredicate.parameterName; + var sourceTypeText = typeToString(source.typePredicate.type); + var targetTypeText = typeToString(target.typePredicate.type); + if (hasDifferentParameterIndex) { + reportError(ts.Diagnostics.Parameter_0_is_not_in_the_same_position_as_parameter_1, sourceParamText, targetParamText); + } + else if (hasDifferentTypes) { + reportError(ts.Diagnostics.Type_0_is_not_assignable_to_type_1, sourceTypeText, targetTypeText); + } + reportError(ts.Diagnostics.Type_predicate_0_is_not_assignable_to_1, sourceParamText + " is " + sourceTypeText, targetParamText + " is " + targetTypeText); + } + return 0 /* False */; + } + } + else if (!source.typePredicate && target.typePredicate) { + if (reportErrors) { + reportError(ts.Diagnostics.Signature_0_must_have_a_type_predicate, signatureToString(source)); + } + return 0 /* False */; + } + var targetReturnType = getReturnTypeOfSignature(target); + if (targetReturnType === voidType) + return result; + var sourceReturnType = getReturnTypeOfSignature(source); + return result & isRelatedTo(sourceReturnType, targetReturnType, reportErrors); + } + function signaturesIdenticalTo(source, target, kind) { + var sourceSignatures = getSignaturesOfType(source, kind); + var targetSignatures = getSignaturesOfType(target, kind); + if (sourceSignatures.length !== targetSignatures.length) { + return 0 /* False */; + } + var result = -1 /* True */; + for (var i = 0, len = sourceSignatures.length; i < len; ++i) { + var related = compareSignatures(sourceSignatures[i], targetSignatures[i], /*partialMatch*/ false, /*ignoreReturnTypes*/ false, isRelatedTo); + if (!related) { + return 0 /* False */; + } + result &= related; + } + return result; + } + function stringIndexTypesRelatedTo(source, originalSource, target, reportErrors) { + if (relation === identityRelation) { + return indexTypesIdenticalTo(0 /* String */, source, target); + } + var targetType = getIndexTypeOfType(target, 0 /* String */); + if (targetType) { + if ((targetType.flags & 1 /* Any */) && !(originalSource.flags & 16777726 /* Primitive */)) { + // non-primitive assignment to any is always allowed, eg + // `var x: { [index: string]: any } = { property: 12 };` + return -1 /* True */; + } + var sourceType = getIndexTypeOfType(source, 0 /* String */); + if (!sourceType) { + if (reportErrors) { + reportError(ts.Diagnostics.Index_signature_is_missing_in_type_0, typeToString(source)); + } + return 0 /* False */; + } + var related = isRelatedTo(sourceType, targetType, reportErrors); + if (!related) { + if (reportErrors) { + reportError(ts.Diagnostics.Index_signatures_are_incompatible); + } + return 0 /* False */; + } + return related; + } + return -1 /* True */; + } + function numberIndexTypesRelatedTo(source, originalSource, target, reportErrors) { + if (relation === identityRelation) { + return indexTypesIdenticalTo(1 /* Number */, source, target); + } + var targetType = getIndexTypeOfType(target, 1 /* Number */); + if (targetType) { + if ((targetType.flags & 1 /* Any */) && !(originalSource.flags & 16777726 /* Primitive */)) { + // non-primitive assignment to any is always allowed, eg + // `var x: { [index: number]: any } = { property: 12 };` + return -1 /* True */; + } + var sourceStringType = getIndexTypeOfType(source, 0 /* String */); + var sourceNumberType = getIndexTypeOfType(source, 1 /* Number */); + if (!(sourceStringType || sourceNumberType)) { + if (reportErrors) { + reportError(ts.Diagnostics.Index_signature_is_missing_in_type_0, typeToString(source)); + } + return 0 /* False */; + } + var related; + if (sourceStringType && sourceNumberType) { + // If we know for sure we're testing both string and numeric index types then only report errors from the second one + related = isRelatedTo(sourceStringType, targetType, false) || isRelatedTo(sourceNumberType, targetType, reportErrors); + } + else { + related = isRelatedTo(sourceStringType || sourceNumberType, targetType, reportErrors); + } + if (!related) { + if (reportErrors) { + reportError(ts.Diagnostics.Index_signatures_are_incompatible); + } + return 0 /* False */; + } + return related; + } + return -1 /* True */; + } + function indexTypesIdenticalTo(indexKind, source, target) { + var targetType = getIndexTypeOfType(target, indexKind); + var sourceType = getIndexTypeOfType(source, indexKind); + if (!sourceType && !targetType) { + return -1 /* True */; + } + if (sourceType && targetType) { + return isRelatedTo(sourceType, targetType); + } + return 0 /* False */; + } + } + // Return true if the given type is part of a deeply nested chain of generic instantiations. We consider this to be the case + // when structural type comparisons have been started for 10 or more instantiations of the same generic type. It is possible, + // though highly unlikely, for this test to be true in a situation where a chain of instantiations is not infinitely expanding. + // Effectively, we will generate a false positive when two types are structurally equal to at least 10 levels, but unequal at + // some level beyond that. + function isDeeplyNestedGeneric(type, stack, depth) { + // We track type references (created by createTypeReference) and instantiated types (created by instantiateType) + if (type.flags & (4096 /* Reference */ | 131072 /* Instantiated */) && depth >= 5) { + var symbol = type.symbol; + var count = 0; + for (var i = 0; i < depth; i++) { + var t = stack[i]; + if (t.flags & (4096 /* Reference */ | 131072 /* Instantiated */) && t.symbol === symbol) { + count++; + if (count >= 5) + return true; + } + } + } + return false; + } + function isPropertyIdenticalTo(sourceProp, targetProp) { + return compareProperties(sourceProp, targetProp, compareTypes) !== 0 /* False */; + } + function compareProperties(sourceProp, targetProp, compareTypes) { + // Two members are considered identical when + // - they are public properties with identical names, optionality, and types, + // - they are private or protected properties originating in the same declaration and having identical types + if (sourceProp === targetProp) { + return -1 /* True */; + } + var sourcePropAccessibility = getDeclarationFlagsFromSymbol(sourceProp) & (32 /* Private */ | 64 /* Protected */); + var targetPropAccessibility = getDeclarationFlagsFromSymbol(targetProp) & (32 /* Private */ | 64 /* Protected */); + if (sourcePropAccessibility !== targetPropAccessibility) { + return 0 /* False */; + } + if (sourcePropAccessibility) { + if (getTargetSymbol(sourceProp) !== getTargetSymbol(targetProp)) { + return 0 /* False */; + } + } + else { + if ((sourceProp.flags & 536870912 /* Optional */) !== (targetProp.flags & 536870912 /* Optional */)) { + return 0 /* False */; + } + } + return compareTypes(getTypeOfSymbol(sourceProp), getTypeOfSymbol(targetProp)); + } + function compareSignatures(source, target, partialMatch, ignoreReturnTypes, compareTypes) { + if (source === target) { + return -1 /* True */; + } + if (source.parameters.length !== target.parameters.length || + source.minArgumentCount !== target.minArgumentCount || + source.hasRestParameter !== target.hasRestParameter) { + if (!partialMatch || + source.parameters.length < target.parameters.length && !source.hasRestParameter || + source.minArgumentCount > target.minArgumentCount) { + return 0 /* False */; + } + } + var result = -1 /* True */; + if (source.typeParameters && target.typeParameters) { + if (source.typeParameters.length !== target.typeParameters.length) { + return 0 /* False */; + } + for (var i = 0, len = source.typeParameters.length; i < len; ++i) { + var related = compareTypes(source.typeParameters[i], target.typeParameters[i]); + if (!related) { + return 0 /* False */; + } + result &= related; + } + } + else if (source.typeParameters || target.typeParameters) { + return 0 /* False */; + } + // Spec 1.0 Section 3.8.3 & 3.8.4: + // M and N (the signatures) are instantiated using type Any as the type argument for all type parameters declared by M and N + source = getErasedSignature(source); + target = getErasedSignature(target); + var targetLen = target.parameters.length; + for (var i = 0; i < targetLen; i++) { + var s = isRestParameterIndex(source, i) ? getRestTypeOfSignature(source) : getTypeOfSymbol(source.parameters[i]); + var t = isRestParameterIndex(target, i) ? getRestTypeOfSignature(target) : getTypeOfSymbol(target.parameters[i]); + var related = compareTypes(s, t); + if (!related) { + return 0 /* False */; + } + result &= related; + } + if (!ignoreReturnTypes) { + result &= compareTypes(getReturnTypeOfSignature(source), getReturnTypeOfSignature(target)); + } + return result; + } + function isRestParameterIndex(signature, parameterIndex) { + return signature.hasRestParameter && parameterIndex >= signature.parameters.length - 1; + } + function isSupertypeOfEach(candidate, types) { + for (var _i = 0; _i < types.length; _i++) { + var type = types[_i]; + if (candidate !== type && !isTypeSubtypeOf(type, candidate)) + return false; + } + return true; + } + function getCommonSupertype(types) { + return ts.forEach(types, function (t) { return isSupertypeOfEach(t, types) ? t : undefined; }); + } + function reportNoCommonSupertypeError(types, errorLocation, errorMessageChainHead) { + // The downfallType/bestSupertypeDownfallType is the first type that caused a particular candidate + // to not be the common supertype. So if it weren't for this one downfallType (and possibly others), + // the type in question could have been the common supertype. + var bestSupertype; + var bestSupertypeDownfallType; + var bestSupertypeScore = 0; + for (var i = 0; i < types.length; i++) { + var score = 0; + var downfallType = undefined; + for (var j = 0; j < types.length; j++) { + if (isTypeSubtypeOf(types[j], types[i])) { + score++; + } + else if (!downfallType) { + downfallType = types[j]; + } + } + ts.Debug.assert(!!downfallType, "If there is no common supertype, each type should have a downfallType"); + if (score > bestSupertypeScore) { + bestSupertype = types[i]; + bestSupertypeDownfallType = downfallType; + bestSupertypeScore = score; + } + // types.length - 1 is the maximum score, given that getCommonSupertype returned false + if (bestSupertypeScore === types.length - 1) { + break; + } + } + // In the following errors, the {1} slot is before the {0} slot because checkTypeSubtypeOf supplies the + // subtype as the first argument to the error + checkTypeSubtypeOf(bestSupertypeDownfallType, bestSupertype, errorLocation, ts.Diagnostics.Type_argument_candidate_1_is_not_a_valid_type_argument_because_it_is_not_a_supertype_of_candidate_0, errorMessageChainHead); + } + function isArrayType(type) { + return type.flags & 4096 /* Reference */ && type.target === globalArrayType; + } + function isArrayLikeType(type) { + // A type is array-like if it is not the undefined or null type and if it is assignable to any[] + return !(type.flags & (32 /* Undefined */ | 64 /* Null */)) && isTypeAssignableTo(type, anyArrayType); + } + function isTupleLikeType(type) { + return !!getPropertyOfType(type, "0"); + } + /** + * Check if a Type was written as a tuple type literal. + * Prefer using isTupleLikeType() unless the use of `elementTypes` is required. + */ + function isTupleType(type) { + return !!(type.flags & 8192 /* Tuple */); + } + function getRegularTypeOfObjectLiteral(type) { + if (type.flags & 1048576 /* FreshObjectLiteral */) { + var regularType = type.regularType; + if (!regularType) { + regularType = createType(type.flags & ~1048576 /* FreshObjectLiteral */); + regularType.symbol = type.symbol; + regularType.members = type.members; + regularType.properties = type.properties; + regularType.callSignatures = type.callSignatures; + regularType.constructSignatures = type.constructSignatures; + regularType.stringIndexType = type.stringIndexType; + regularType.numberIndexType = type.numberIndexType; + type.regularType = regularType; + } + return regularType; + } + return type; + } + function getWidenedTypeOfObjectLiteral(type) { + var properties = getPropertiesOfObjectType(type); + var members = {}; + ts.forEach(properties, function (p) { + var propType = getTypeOfSymbol(p); + var widenedType = getWidenedType(propType); + if (propType !== widenedType) { + var symbol = createSymbol(p.flags | 67108864 /* Transient */, p.name); + symbol.declarations = p.declarations; + symbol.parent = p.parent; + symbol.type = widenedType; + symbol.target = p; + if (p.valueDeclaration) + symbol.valueDeclaration = p.valueDeclaration; + p = symbol; + } + members[p.name] = p; + }); + var stringIndexType = getIndexTypeOfType(type, 0 /* String */); + var numberIndexType = getIndexTypeOfType(type, 1 /* Number */); + if (stringIndexType) + stringIndexType = getWidenedType(stringIndexType); + if (numberIndexType) + numberIndexType = getWidenedType(numberIndexType); + return createAnonymousType(type.symbol, members, emptyArray, emptyArray, stringIndexType, numberIndexType); + } + function getWidenedType(type) { + if (type.flags & 6291456 /* RequiresWidening */) { + if (type.flags & (32 /* Undefined */ | 64 /* Null */)) { + return anyType; + } + if (type.flags & 524288 /* ObjectLiteral */) { + return getWidenedTypeOfObjectLiteral(type); + } + if (type.flags & 16384 /* Union */) { + return getUnionType(ts.map(type.types, getWidenedType), /*noSubtypeReduction*/ true); + } + if (isArrayType(type)) { + return createArrayType(getWidenedType(type.typeArguments[0])); + } + if (isTupleType(type)) { + return createTupleType(ts.map(type.elementTypes, getWidenedType)); + } + } + return type; + } + /** + * Reports implicit any errors that occur as a result of widening 'null' and 'undefined' + * to 'any'. A call to reportWideningErrorsInType is normally accompanied by a call to + * getWidenedType. But in some cases getWidenedType is called without reporting errors + * (type argument inference is an example). + * + * The return value indicates whether an error was in fact reported. The particular circumstances + * are on a best effort basis. Currently, if the null or undefined that causes widening is inside + * an object literal property (arbitrarily deeply), this function reports an error. If no error is + * reported, reportImplicitAnyError is a suitable fallback to report a general error. + */ + function reportWideningErrorsInType(type) { + var errorReported = false; + if (type.flags & 16384 /* Union */) { + for (var _i = 0, _a = type.types; _i < _a.length; _i++) { + var t = _a[_i]; + if (reportWideningErrorsInType(t)) { + errorReported = true; + } + } + } + if (isArrayType(type)) { + return reportWideningErrorsInType(type.typeArguments[0]); + } + if (isTupleType(type)) { + for (var _b = 0, _c = type.elementTypes; _b < _c.length; _b++) { + var t = _c[_b]; + if (reportWideningErrorsInType(t)) { + errorReported = true; + } + } + } + if (type.flags & 524288 /* ObjectLiteral */) { + for (var _d = 0, _e = getPropertiesOfObjectType(type); _d < _e.length; _d++) { + var p = _e[_d]; + var t = getTypeOfSymbol(p); + if (t.flags & 2097152 /* ContainsUndefinedOrNull */) { + if (!reportWideningErrorsInType(t)) { + error(p.valueDeclaration, ts.Diagnostics.Object_literal_s_property_0_implicitly_has_an_1_type, p.name, typeToString(getWidenedType(t))); + } + errorReported = true; + } + } + } + return errorReported; + } + function reportImplicitAnyError(declaration, type) { + var typeAsString = typeToString(getWidenedType(type)); + var diagnostic; + switch (declaration.kind) { + case 141 /* PropertyDeclaration */: + case 140 /* PropertySignature */: + diagnostic = ts.Diagnostics.Member_0_implicitly_has_an_1_type; + break; + case 138 /* Parameter */: + diagnostic = declaration.dotDotDotToken ? + ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type : + ts.Diagnostics.Parameter_0_implicitly_has_an_1_type; + break; + case 213 /* FunctionDeclaration */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: + case 173 /* FunctionExpression */: + case 174 /* ArrowFunction */: + if (!declaration.name) { + error(declaration, ts.Diagnostics.Function_expression_which_lacks_return_type_annotation_implicitly_has_an_0_return_type, typeAsString); + return; + } + diagnostic = ts.Diagnostics._0_which_lacks_return_type_annotation_implicitly_has_an_1_return_type; + break; + default: + diagnostic = ts.Diagnostics.Variable_0_implicitly_has_an_1_type; + } + error(declaration, diagnostic, ts.declarationNameToString(declaration.name), typeAsString); + } + function reportErrorsFromWidening(declaration, type) { + if (produceDiagnostics && compilerOptions.noImplicitAny && type.flags & 2097152 /* ContainsUndefinedOrNull */) { + // Report implicit any error within type if possible, otherwise report error on declaration + if (!reportWideningErrorsInType(type)) { + reportImplicitAnyError(declaration, type); + } + } + } + function forEachMatchingParameterType(source, target, callback) { + var sourceMax = source.parameters.length; + var targetMax = target.parameters.length; + var count; + if (source.hasRestParameter && target.hasRestParameter) { + count = sourceMax > targetMax ? sourceMax : targetMax; + sourceMax--; + targetMax--; + } + else if (source.hasRestParameter) { + sourceMax--; + count = targetMax; + } + else if (target.hasRestParameter) { + targetMax--; + count = sourceMax; + } + else { + count = sourceMax < targetMax ? sourceMax : targetMax; + } + for (var i = 0; i < count; i++) { + var s = i < sourceMax ? getTypeOfSymbol(source.parameters[i]) : getRestTypeOfSignature(source); + var t = i < targetMax ? getTypeOfSymbol(target.parameters[i]) : getRestTypeOfSignature(target); + callback(s, t); + } + } + function createInferenceContext(typeParameters, inferUnionTypes) { + var inferences = []; + for (var _i = 0; _i < typeParameters.length; _i++) { + var unused = typeParameters[_i]; + inferences.push({ + primary: undefined, secondary: undefined, isFixed: false + }); + } + return { + typeParameters: typeParameters, + inferUnionTypes: inferUnionTypes, + inferences: inferences, + inferredTypes: new Array(typeParameters.length) + }; + } + function inferTypes(context, source, target) { + var sourceStack; + var targetStack; + var depth = 0; + var inferiority = 0; + inferFromTypes(source, target); + function isInProcess(source, target) { + for (var i = 0; i < depth; i++) { + if (source === sourceStack[i] && target === targetStack[i]) { + return true; + } + } + return false; + } + function inferFromTypes(source, target) { + if (target.flags & 512 /* TypeParameter */) { + // If target is a type parameter, make an inference, unless the source type contains + // the anyFunctionType (the wildcard type that's used to avoid contextually typing functions). + // Because the anyFunctionType is internal, it should not be exposed to the user by adding + // it as an inference candidate. Hopefully, a better candidate will come along that does + // not contain anyFunctionType when we come back to this argument for its second round + // of inference. + if (source.flags & 8388608 /* ContainsAnyFunctionType */) { + return; + } + var typeParameters = context.typeParameters; + for (var i = 0; i < typeParameters.length; i++) { + if (target === typeParameters[i]) { + var inferences = context.inferences[i]; + if (!inferences.isFixed) { + // Any inferences that are made to a type parameter in a union type are inferior + // to inferences made to a flat (non-union) type. This is because if we infer to + // T | string[], we really don't know if we should be inferring to T or not (because + // the correct constituent on the target side could be string[]). Therefore, we put + // such inferior inferences into a secondary bucket, and only use them if the primary + // bucket is empty. + var candidates = inferiority ? + inferences.secondary || (inferences.secondary = []) : + inferences.primary || (inferences.primary = []); + if (!ts.contains(candidates, source)) { + candidates.push(source); + } + } + return; + } + } + } + else if (source.flags & 4096 /* Reference */ && target.flags & 4096 /* Reference */ && source.target === target.target) { + // If source and target are references to the same generic type, infer from type arguments + var sourceTypes = source.typeArguments || emptyArray; + var targetTypes = target.typeArguments || emptyArray; + var count = sourceTypes.length < targetTypes.length ? sourceTypes.length : targetTypes.length; + for (var i = 0; i < count; i++) { + inferFromTypes(sourceTypes[i], targetTypes[i]); + } + } + else if (source.flags & 8192 /* Tuple */ && target.flags & 8192 /* Tuple */ && source.elementTypes.length === target.elementTypes.length) { + // If source and target are tuples of the same size, infer from element types + var sourceTypes = source.elementTypes; + var targetTypes = target.elementTypes; + for (var i = 0; i < sourceTypes.length; i++) { + inferFromTypes(sourceTypes[i], targetTypes[i]); + } + } + else if (target.flags & 49152 /* UnionOrIntersection */) { + var targetTypes = target.types; + var typeParameterCount = 0; + var typeParameter; + // First infer to each type in union or intersection that isn't a type parameter + for (var _i = 0; _i < targetTypes.length; _i++) { + var t = targetTypes[_i]; + if (t.flags & 512 /* TypeParameter */ && ts.contains(context.typeParameters, t)) { + typeParameter = t; + typeParameterCount++; + } + else { + inferFromTypes(source, t); + } + } + // Next, if target is a union type containing a single naked type parameter, make a + // secondary inference to that type parameter. We don't do this for intersection types + // because in a target type like Foo & T we don't know how which parts of the source type + // should be matched by Foo and which should be inferred to T. + if (target.flags & 16384 /* Union */ && typeParameterCount === 1) { + inferiority++; + inferFromTypes(source, typeParameter); + inferiority--; + } + } + else if (source.flags & 49152 /* UnionOrIntersection */) { + // Source is a union or intersection type, infer from each consituent type + var sourceTypes = source.types; + for (var _a = 0; _a < sourceTypes.length; _a++) { + var sourceType = sourceTypes[_a]; + inferFromTypes(sourceType, target); + } + } + else { + source = getApparentType(source); + if (source.flags & 80896 /* ObjectType */ && (target.flags & (4096 /* Reference */ | 8192 /* Tuple */) || + (target.flags & 65536 /* Anonymous */) && target.symbol && target.symbol.flags & (8192 /* Method */ | 2048 /* TypeLiteral */ | 32 /* Class */))) { + // If source is an object type, and target is a type reference, a tuple type, the type of a method, or a type literal, infer from members + if (isInProcess(source, target)) { + return; + } + if (isDeeplyNestedGeneric(source, sourceStack, depth) && isDeeplyNestedGeneric(target, targetStack, depth)) { + return; + } + if (depth === 0) { + sourceStack = []; + targetStack = []; + } + sourceStack[depth] = source; + targetStack[depth] = target; + depth++; + inferFromProperties(source, target); + inferFromSignatures(source, target, 0 /* Call */); + inferFromSignatures(source, target, 1 /* Construct */); + inferFromIndexTypes(source, target, 0 /* String */, 0 /* String */); + inferFromIndexTypes(source, target, 1 /* Number */, 1 /* Number */); + inferFromIndexTypes(source, target, 0 /* String */, 1 /* Number */); + depth--; + } + } + } + function inferFromProperties(source, target) { + var properties = getPropertiesOfObjectType(target); + for (var _i = 0; _i < properties.length; _i++) { + var targetProp = properties[_i]; + var sourceProp = getPropertyOfObjectType(source, targetProp.name); + if (sourceProp) { + inferFromTypes(getTypeOfSymbol(sourceProp), getTypeOfSymbol(targetProp)); + } + } + } + function inferFromSignatures(source, target, kind) { + var sourceSignatures = getSignaturesOfType(source, kind); + var targetSignatures = getSignaturesOfType(target, kind); + var sourceLen = sourceSignatures.length; + var targetLen = targetSignatures.length; + var len = sourceLen < targetLen ? sourceLen : targetLen; + for (var i = 0; i < len; i++) { + inferFromSignature(getErasedSignature(sourceSignatures[sourceLen - len + i]), getErasedSignature(targetSignatures[targetLen - len + i])); + } + } + function inferFromSignature(source, target) { + forEachMatchingParameterType(source, target, inferFromTypes); + if (source.typePredicate && target.typePredicate) { + if (target.typePredicate.parameterIndex === source.typePredicate.parameterIndex) { + // Return types from type predicates are treated as booleans. In order to infer types + // from type predicates we would need to infer using the type within the type predicate + // (i.e. 'Foo' from 'x is Foo'). + inferFromTypes(source.typePredicate.type, target.typePredicate.type); + } + } + else { + inferFromTypes(getReturnTypeOfSignature(source), getReturnTypeOfSignature(target)); + } + } + function inferFromIndexTypes(source, target, sourceKind, targetKind) { + var targetIndexType = getIndexTypeOfType(target, targetKind); + if (targetIndexType) { + var sourceIndexType = getIndexTypeOfType(source, sourceKind); + if (sourceIndexType) { + inferFromTypes(sourceIndexType, targetIndexType); + } + } + } + } + function getInferenceCandidates(context, index) { + var inferences = context.inferences[index]; + return inferences.primary || inferences.secondary || emptyArray; + } + function getInferredType(context, index) { + var inferredType = context.inferredTypes[index]; + var inferenceSucceeded; + if (!inferredType) { + var inferences = getInferenceCandidates(context, index); + if (inferences.length) { + // Infer widened union or supertype, or the unknown type for no common supertype + var unionOrSuperType = context.inferUnionTypes ? getUnionType(inferences) : getCommonSupertype(inferences); + inferredType = unionOrSuperType ? getWidenedType(unionOrSuperType) : unknownType; + inferenceSucceeded = !!unionOrSuperType; + } + else { + // Infer the empty object type when no inferences were made. It is important to remember that + // in this case, inference still succeeds, meaning there is no error for not having inference + // candidates. An inference error only occurs when there are *conflicting* candidates, i.e. + // candidates with no common supertype. + inferredType = emptyObjectType; + inferenceSucceeded = true; + } + // Only do the constraint check if inference succeeded (to prevent cascading errors) + if (inferenceSucceeded) { + var constraint = getConstraintOfTypeParameter(context.typeParameters[index]); + inferredType = constraint && !isTypeAssignableTo(inferredType, constraint) ? constraint : inferredType; + } + else if (context.failedTypeParameterIndex === undefined || context.failedTypeParameterIndex > index) { + // If inference failed, it is necessary to record the index of the failed type parameter (the one we are on). + // It might be that inference has already failed on a later type parameter on a previous call to inferTypeArguments. + // So if this failure is on preceding type parameter, this type parameter is the new failure index. + context.failedTypeParameterIndex = index; + } + context.inferredTypes[index] = inferredType; + } + return inferredType; + } + function getInferredTypes(context) { + for (var i = 0; i < context.inferredTypes.length; i++) { + getInferredType(context, i); + } + return context.inferredTypes; + } + function hasAncestor(node, kind) { + return ts.getAncestor(node, kind) !== undefined; + } + // EXPRESSION TYPE CHECKING + function getResolvedSymbol(node) { + var links = getNodeLinks(node); + if (!links.resolvedSymbol) { + links.resolvedSymbol = (!ts.nodeIsMissing(node) && resolveName(node, node.text, 107455 /* Value */ | 1048576 /* ExportValue */, ts.Diagnostics.Cannot_find_name_0, node)) || unknownSymbol; + } + return links.resolvedSymbol; + } + function isInTypeQuery(node) { + // TypeScript 1.0 spec (April 2014): 3.6.3 + // A type query consists of the keyword typeof followed by an expression. + // The expression is restricted to a single identifier or a sequence of identifiers separated by periods + while (node) { + switch (node.kind) { + case 154 /* TypeQuery */: + return true; + case 69 /* Identifier */: + case 135 /* QualifiedName */: + node = node.parent; + continue; + default: + return false; + } + } + ts.Debug.fail("should not get here"); + } + // For a union type, remove all constituent types that are of the given type kind (when isOfTypeKind is true) + // or not of the given type kind (when isOfTypeKind is false) + function removeTypesFromUnionType(type, typeKind, isOfTypeKind, allowEmptyUnionResult) { + if (type.flags & 16384 /* Union */) { + var types = type.types; + if (ts.forEach(types, function (t) { return !!(t.flags & typeKind) === isOfTypeKind; })) { + // Above we checked if we have anything to remove, now use the opposite test to do the removal + var narrowedType = getUnionType(ts.filter(types, function (t) { return !(t.flags & typeKind) === isOfTypeKind; })); + if (allowEmptyUnionResult || narrowedType !== emptyObjectType) { + return narrowedType; + } + } + } + else if (allowEmptyUnionResult && !!(type.flags & typeKind) === isOfTypeKind) { + // Use getUnionType(emptyArray) instead of emptyObjectType in case the way empty union types + // are represented ever changes. + return getUnionType(emptyArray); + } + return type; + } + function hasInitializer(node) { + return !!(node.initializer || ts.isBindingPattern(node.parent) && hasInitializer(node.parent.parent)); + } + // Check if a given variable is assigned within a given syntax node + function isVariableAssignedWithin(symbol, node) { + var links = getNodeLinks(node); + if (links.assignmentChecks) { + var cachedResult = links.assignmentChecks[symbol.id]; + if (cachedResult !== undefined) { + return cachedResult; + } + } + else { + links.assignmentChecks = {}; + } + return links.assignmentChecks[symbol.id] = isAssignedIn(node); + function isAssignedInBinaryExpression(node) { + if (node.operatorToken.kind >= 56 /* FirstAssignment */ && node.operatorToken.kind <= 68 /* LastAssignment */) { + var n = node.left; + while (n.kind === 172 /* ParenthesizedExpression */) { + n = n.expression; + } + if (n.kind === 69 /* Identifier */ && getResolvedSymbol(n) === symbol) { + return true; + } + } + return ts.forEachChild(node, isAssignedIn); + } + function isAssignedInVariableDeclaration(node) { + if (!ts.isBindingPattern(node.name) && getSymbolOfNode(node) === symbol && hasInitializer(node)) { + return true; + } + return ts.forEachChild(node, isAssignedIn); + } + function isAssignedIn(node) { + switch (node.kind) { + case 181 /* BinaryExpression */: + return isAssignedInBinaryExpression(node); + case 211 /* VariableDeclaration */: + case 163 /* BindingElement */: + return isAssignedInVariableDeclaration(node); + case 161 /* ObjectBindingPattern */: + case 162 /* ArrayBindingPattern */: + case 164 /* ArrayLiteralExpression */: + case 165 /* ObjectLiteralExpression */: + case 166 /* PropertyAccessExpression */: + case 167 /* ElementAccessExpression */: + case 168 /* CallExpression */: + case 169 /* NewExpression */: + case 171 /* TypeAssertionExpression */: + case 189 /* AsExpression */: + case 172 /* ParenthesizedExpression */: + case 179 /* PrefixUnaryExpression */: + case 175 /* DeleteExpression */: + case 178 /* AwaitExpression */: + case 176 /* TypeOfExpression */: + case 177 /* VoidExpression */: + case 180 /* PostfixUnaryExpression */: + case 184 /* YieldExpression */: + case 182 /* ConditionalExpression */: + case 185 /* SpreadElementExpression */: + case 192 /* Block */: + case 193 /* VariableStatement */: + case 195 /* ExpressionStatement */: + case 196 /* IfStatement */: + case 197 /* DoStatement */: + case 198 /* WhileStatement */: + case 199 /* ForStatement */: + case 200 /* ForInStatement */: + case 201 /* ForOfStatement */: + case 204 /* ReturnStatement */: + case 205 /* WithStatement */: + case 206 /* SwitchStatement */: + case 241 /* CaseClause */: + case 242 /* DefaultClause */: + case 207 /* LabeledStatement */: + case 208 /* ThrowStatement */: + case 209 /* TryStatement */: + case 244 /* CatchClause */: + case 233 /* JsxElement */: + case 234 /* JsxSelfClosingElement */: + case 238 /* JsxAttribute */: + case 239 /* JsxSpreadAttribute */: + case 235 /* JsxOpeningElement */: + case 240 /* JsxExpression */: + return ts.forEachChild(node, isAssignedIn); + } + return false; + } + } + // Get the narrowed type of a given symbol at a given location + function getNarrowedTypeOfSymbol(symbol, node) { + var type = getTypeOfSymbol(symbol); + // Only narrow when symbol is variable of type any or an object, union, or type parameter type + if (node && symbol.flags & 3 /* Variable */) { + if (isTypeAny(type) || type.flags & (80896 /* ObjectType */ | 16384 /* Union */ | 512 /* TypeParameter */)) { + loop: while (node.parent) { + var child = node; + node = node.parent; + var narrowedType = type; + switch (node.kind) { + case 196 /* IfStatement */: + // In a branch of an if statement, narrow based on controlling expression + if (child !== node.expression) { + narrowedType = narrowType(type, node.expression, /*assumeTrue*/ child === node.thenStatement); + } + break; + case 182 /* ConditionalExpression */: + // In a branch of a conditional expression, narrow based on controlling condition + if (child !== node.condition) { + narrowedType = narrowType(type, node.condition, /*assumeTrue*/ child === node.whenTrue); + } + break; + case 181 /* BinaryExpression */: + // In the right operand of an && or ||, narrow based on left operand + if (child === node.right) { + if (node.operatorToken.kind === 51 /* AmpersandAmpersandToken */) { + narrowedType = narrowType(type, node.left, /*assumeTrue*/ true); + } + else if (node.operatorToken.kind === 52 /* BarBarToken */) { + narrowedType = narrowType(type, node.left, /*assumeTrue*/ false); + } + } + break; + case 248 /* SourceFile */: + case 218 /* ModuleDeclaration */: + case 213 /* FunctionDeclaration */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: + case 144 /* Constructor */: + // Stop at the first containing function or module declaration + break loop; + } + // Use narrowed type if construct contains no assignments to variable + if (narrowedType !== type) { + if (isVariableAssignedWithin(symbol, node)) { + break; + } + type = narrowedType; + } + } + } + } + return type; + function narrowTypeByEquality(type, expr, assumeTrue) { + // Check that we have 'typeof ' on the left and string literal on the right + if (expr.left.kind !== 176 /* TypeOfExpression */ || expr.right.kind !== 9 /* StringLiteral */) { + return type; + } + var left = expr.left; + var right = expr.right; + if (left.expression.kind !== 69 /* Identifier */ || getResolvedSymbol(left.expression) !== symbol) { + return type; + } + var typeInfo = primitiveTypeInfo[right.text]; + if (expr.operatorToken.kind === 33 /* ExclamationEqualsEqualsToken */) { + assumeTrue = !assumeTrue; + } + if (assumeTrue) { + // Assumed result is true. If check was not for a primitive type, remove all primitive types + if (!typeInfo) { + return removeTypesFromUnionType(type, /*typeKind*/ 258 /* StringLike */ | 132 /* NumberLike */ | 8 /* Boolean */ | 16777216 /* ESSymbol */, + /*isOfTypeKind*/ true, /*allowEmptyUnionResult*/ false); + } + // Check was for a primitive type, return that primitive type if it is a subtype + if (isTypeSubtypeOf(typeInfo.type, type)) { + return typeInfo.type; + } + // Otherwise, remove all types that aren't of the primitive type kind. This can happen when the type is + // union of enum types and other types. + return removeTypesFromUnionType(type, /*typeKind*/ typeInfo.flags, /*isOfTypeKind*/ false, /*allowEmptyUnionResult*/ false); + } + else { + // Assumed result is false. If check was for a primitive type, remove that primitive type + if (typeInfo) { + return removeTypesFromUnionType(type, /*typeKind*/ typeInfo.flags, /*isOfTypeKind*/ true, /*allowEmptyUnionResult*/ false); + } + // Otherwise we don't have enough information to do anything. + return type; + } + } + function narrowTypeByAnd(type, expr, assumeTrue) { + if (assumeTrue) { + // The assumed result is true, therefore we narrow assuming each operand to be true. + return narrowType(narrowType(type, expr.left, /*assumeTrue*/ true), expr.right, /*assumeTrue*/ true); + } + else { + // The assumed result is false. This means either the first operand was false, or the first operand was true + // and the second operand was false. We narrow with those assumptions and union the two resulting types. + return getUnionType([ + narrowType(type, expr.left, /*assumeTrue*/ false), + narrowType(narrowType(type, expr.left, /*assumeTrue*/ true), expr.right, /*assumeTrue*/ false) + ]); + } + } + function narrowTypeByOr(type, expr, assumeTrue) { + if (assumeTrue) { + // The assumed result is true. This means either the first operand was true, or the first operand was false + // and the second operand was true. We narrow with those assumptions and union the two resulting types. + return getUnionType([ + narrowType(type, expr.left, /*assumeTrue*/ true), + narrowType(narrowType(type, expr.left, /*assumeTrue*/ false), expr.right, /*assumeTrue*/ true) + ]); + } + else { + // The assumed result is false, therefore we narrow assuming each operand to be false. + return narrowType(narrowType(type, expr.left, /*assumeTrue*/ false), expr.right, /*assumeTrue*/ false); + } + } + function narrowTypeByInstanceof(type, expr, assumeTrue) { + // Check that type is not any, assumed result is true, and we have variable symbol on the left + if (isTypeAny(type) || !assumeTrue || expr.left.kind !== 69 /* Identifier */ || getResolvedSymbol(expr.left) !== symbol) { + return type; + } + // Check that right operand is a function type with a prototype property + var rightType = checkExpression(expr.right); + if (!isTypeSubtypeOf(rightType, globalFunctionType)) { + return type; + } + var targetType; + var prototypeProperty = getPropertyOfType(rightType, "prototype"); + if (prototypeProperty) { + // Target type is type of the prototype property + var prototypePropertyType = getTypeOfSymbol(prototypeProperty); + if (!isTypeAny(prototypePropertyType)) { + targetType = prototypePropertyType; + } + } + if (!targetType) { + // Target type is type of construct signature + var constructSignatures; + if (rightType.flags & 2048 /* Interface */) { + constructSignatures = resolveDeclaredMembers(rightType).declaredConstructSignatures; + } + else if (rightType.flags & 65536 /* Anonymous */) { + constructSignatures = getSignaturesOfType(rightType, 1 /* Construct */); + } + if (constructSignatures && constructSignatures.length) { + targetType = getUnionType(ts.map(constructSignatures, function (signature) { return getReturnTypeOfSignature(getErasedSignature(signature)); })); + } + } + if (targetType) { + return getNarrowedType(type, targetType); + } + return type; + } + function getNarrowedType(originalType, narrowedTypeCandidate) { + // If the current type is a union type, remove all constituents that aren't assignable to target. If that produces + // 0 candidates, fall back to the assignability check + if (originalType.flags & 16384 /* Union */) { + var assignableConstituents = ts.filter(originalType.types, function (t) { return isTypeAssignableTo(t, narrowedTypeCandidate); }); + if (assignableConstituents.length) { + return getUnionType(assignableConstituents); + } + } + if (isTypeAssignableTo(narrowedTypeCandidate, originalType)) { + // Narrow to the target type if it's assignable to the current type + return narrowedTypeCandidate; + } + return originalType; + } + function narrowTypeByTypePredicate(type, expr, assumeTrue) { + if (type.flags & 1 /* Any */) { + return type; + } + var signature = getResolvedSignature(expr); + if (signature.typePredicate && + expr.arguments[signature.typePredicate.parameterIndex] && + getSymbolAtLocation(expr.arguments[signature.typePredicate.parameterIndex]) === symbol) { + if (!assumeTrue) { + if (type.flags & 16384 /* Union */) { + return getUnionType(ts.filter(type.types, function (t) { return !isTypeSubtypeOf(t, signature.typePredicate.type); })); + } + return type; + } + return getNarrowedType(type, signature.typePredicate.type); + } + return type; + } + // Narrow the given type based on the given expression having the assumed boolean value. The returned type + // will be a subtype or the same type as the argument. + function narrowType(type, expr, assumeTrue) { + switch (expr.kind) { + case 168 /* CallExpression */: + return narrowTypeByTypePredicate(type, expr, assumeTrue); + case 172 /* ParenthesizedExpression */: + return narrowType(type, expr.expression, assumeTrue); + case 181 /* BinaryExpression */: + var operator = expr.operatorToken.kind; + if (operator === 32 /* EqualsEqualsEqualsToken */ || operator === 33 /* ExclamationEqualsEqualsToken */) { + return narrowTypeByEquality(type, expr, assumeTrue); + } + else if (operator === 51 /* AmpersandAmpersandToken */) { + return narrowTypeByAnd(type, expr, assumeTrue); + } + else if (operator === 52 /* BarBarToken */) { + return narrowTypeByOr(type, expr, assumeTrue); + } + else if (operator === 91 /* InstanceOfKeyword */) { + return narrowTypeByInstanceof(type, expr, assumeTrue); + } + break; + case 179 /* PrefixUnaryExpression */: + if (expr.operator === 49 /* ExclamationToken */) { + return narrowType(type, expr.operand, !assumeTrue); + } + break; + } + return type; + } + } + function checkIdentifier(node) { + var symbol = getResolvedSymbol(node); + // As noted in ECMAScript 6 language spec, arrow functions never have an arguments objects. + // Although in down-level emit of arrow function, we emit it using function expression which means that + // arguments objects will be bound to the inner object; emitting arrow function natively in ES6, arguments objects + // will be bound to non-arrow function that contain this arrow function. This results in inconsistent behavior. + // To avoid that we will give an error to users if they use arguments objects in arrow function so that they + // can explicitly bound arguments objects + if (symbol === argumentsSymbol) { + var container = ts.getContainingFunction(node); + if (container.kind === 174 /* ArrowFunction */) { + if (languageVersion < 2 /* ES6 */) { + error(node, ts.Diagnostics.The_arguments_object_cannot_be_referenced_in_an_arrow_function_in_ES3_and_ES5_Consider_using_a_standard_function_expression); + } + } + if (node.parserContextFlags & 8 /* Await */) { + getNodeLinks(container).flags |= 4096 /* CaptureArguments */; + getNodeLinks(node).flags |= 2048 /* LexicalArguments */; + } + } + if (symbol.flags & 8388608 /* Alias */ && !isInTypeQuery(node) && !isConstEnumOrConstEnumOnlyModule(resolveAlias(symbol))) { + markAliasSymbolAsReferenced(symbol); + } + checkCollisionWithCapturedSuperVariable(node, node); + checkCollisionWithCapturedThisVariable(node, node); + checkBlockScopedBindingCapturedInLoop(node, symbol); + return getNarrowedTypeOfSymbol(getExportSymbolOfValueSymbolIfExported(symbol), node); + } + function isInsideFunction(node, threshold) { + var current = node; + while (current && current !== threshold) { + if (ts.isFunctionLike(current)) { + return true; + } + current = current.parent; + } + return false; + } + function checkBlockScopedBindingCapturedInLoop(node, symbol) { + if (languageVersion >= 2 /* ES6 */ || + (symbol.flags & (2 /* BlockScopedVariable */ | 32 /* Class */)) === 0 || + symbol.valueDeclaration.parent.kind === 244 /* CatchClause */) { + return; + } + // 1. walk from the use site up to the declaration and check + // if there is anything function like between declaration and use-site (is binding/class is captured in function). + // 2. walk from the declaration up to the boundary of lexical environment and check + // if there is an iteration statement in between declaration and boundary (is binding/class declared inside iteration statement) + var container; + if (symbol.flags & 32 /* Class */) { + // get parent of class declaration + container = getClassLikeDeclarationOfSymbol(symbol).parent; + } + else { + // nesting structure: + // (variable declaration or binding element) -> variable declaration list -> container + container = symbol.valueDeclaration; + while (container.kind !== 212 /* VariableDeclarationList */) { + container = container.parent; + } + // get the parent of variable declaration list + container = container.parent; + if (container.kind === 193 /* VariableStatement */) { + // if parent is variable statement - get its parent + container = container.parent; + } + } + var inFunction = isInsideFunction(node.parent, container); + var current = container; + while (current && !ts.nodeStartsNewLexicalEnvironment(current)) { + if (ts.isIterationStatement(current, /*lookInLabeledStatements*/ false)) { + if (inFunction) { + getNodeLinks(current).flags |= 65536 /* LoopWithBlockScopedBindingCapturedInFunction */; + } + // mark value declaration so during emit they can have a special handling + getNodeLinks(symbol.valueDeclaration).flags |= 16384 /* BlockScopedBindingInLoop */; + break; + } + current = current.parent; + } + } + function captureLexicalThis(node, container) { + getNodeLinks(node).flags |= 2 /* LexicalThis */; + if (container.kind === 141 /* PropertyDeclaration */ || container.kind === 144 /* Constructor */) { + var classNode = container.parent; + getNodeLinks(classNode).flags |= 4 /* CaptureThis */; + } + else { + getNodeLinks(container).flags |= 4 /* CaptureThis */; + } + } + function checkThisExpression(node) { + // Stop at the first arrow function so that we can + // tell whether 'this' needs to be captured. + var container = ts.getThisContainer(node, /* includeArrowFunctions */ true); + var needToCaptureLexicalThis = false; + // Now skip arrow functions to get the "real" owner of 'this'. + if (container.kind === 174 /* ArrowFunction */) { + container = ts.getThisContainer(container, /* includeArrowFunctions */ false); + // When targeting es6, arrow function lexically bind "this" so we do not need to do the work of binding "this" in emitted code + needToCaptureLexicalThis = (languageVersion < 2 /* ES6 */); + } + switch (container.kind) { + case 218 /* ModuleDeclaration */: + error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_module_or_namespace_body); + // do not return here so in case if lexical this is captured - it will be reflected in flags on NodeLinks + break; + case 217 /* EnumDeclaration */: + error(node, ts.Diagnostics.this_cannot_be_referenced_in_current_location); + // do not return here so in case if lexical this is captured - it will be reflected in flags on NodeLinks + break; + case 144 /* Constructor */: + if (isInConstructorArgumentInitializer(node, container)) { + error(node, ts.Diagnostics.this_cannot_be_referenced_in_constructor_arguments); + } + break; + case 141 /* PropertyDeclaration */: + case 140 /* PropertySignature */: + if (container.flags & 128 /* Static */) { + error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_static_property_initializer); + } + break; + case 136 /* ComputedPropertyName */: + error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_computed_property_name); + break; + } + if (needToCaptureLexicalThis) { + captureLexicalThis(node, container); + } + if (ts.isClassLike(container.parent)) { + var symbol = getSymbolOfNode(container.parent); + return container.flags & 128 /* Static */ ? getTypeOfSymbol(symbol) : getDeclaredTypeOfSymbol(symbol).thisType; + } + return anyType; + } + function isInConstructorArgumentInitializer(node, constructorDecl) { + for (var n = node; n && n !== constructorDecl; n = n.parent) { + if (n.kind === 138 /* Parameter */) { + return true; + } + } + return false; + } + function checkSuperExpression(node) { + var isCallExpression = node.parent.kind === 168 /* CallExpression */ && node.parent.expression === node; + var classDeclaration = ts.getContainingClass(node); + var classType = classDeclaration && getDeclaredTypeOfSymbol(getSymbolOfNode(classDeclaration)); + var baseClassType = classType && getBaseTypes(classType)[0]; + var container = ts.getSuperContainer(node, /*includeFunctions*/ true); + var needToCaptureLexicalThis = false; + if (!isCallExpression) { + // adjust the container reference in case if super is used inside arrow functions with arbitrary deep nesting + while (container && container.kind === 174 /* ArrowFunction */) { + container = ts.getSuperContainer(container, /*includeFunctions*/ true); + needToCaptureLexicalThis = languageVersion < 2 /* ES6 */; + } + } + var canUseSuperExpression = isLegalUsageOfSuperExpression(container); + var nodeCheckFlag = 0; + // always set NodeCheckFlags for 'super' expression node + if (canUseSuperExpression) { + if ((container.flags & 128 /* Static */) || isCallExpression) { + nodeCheckFlag = 512 /* SuperStatic */; + } + else { + nodeCheckFlag = 256 /* SuperInstance */; + } + getNodeLinks(node).flags |= nodeCheckFlag; + if (needToCaptureLexicalThis) { + // call expressions are allowed only in constructors so they should always capture correct 'this' + // super property access expressions can also appear in arrow functions - + // in this case they should also use correct lexical this + captureLexicalThis(node.parent, container); + } + } + if (!baseClassType) { + if (!classDeclaration || !ts.getClassExtendsHeritageClauseElement(classDeclaration)) { + error(node, ts.Diagnostics.super_can_only_be_referenced_in_a_derived_class); + } + return unknownType; + } + if (!canUseSuperExpression) { + if (container && container.kind === 136 /* 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 { + error(node, ts.Diagnostics.super_property_access_is_permitted_only_in_a_constructor_member_function_or_member_accessor_of_a_derived_class); + } + return unknownType; + } + if (container.kind === 144 /* Constructor */ && isInConstructorArgumentInitializer(node, container)) { + // issue custom error message for super property access in constructor arguments (to be aligned with old compiler) + error(node, ts.Diagnostics.super_cannot_be_referenced_in_constructor_arguments); + return unknownType; + } + return nodeCheckFlag === 512 /* SuperStatic */ + ? getBaseConstructorTypeOfClass(classType) + : baseClassType; + function isLegalUsageOfSuperExpression(container) { + if (!container) { + return false; + } + if (isCallExpression) { + // TS 1.0 SPEC (April 2014): 4.8.1 + // Super calls are only permitted in constructors of derived classes + return container.kind === 144 /* Constructor */; + } + else { + // TS 1.0 SPEC (April 2014) + // 'super' property access is allowed + // - 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 + if (container && ts.isClassLike(container.parent)) { + if (container.flags & 128 /* Static */) { + return container.kind === 143 /* MethodDeclaration */ || + container.kind === 142 /* MethodSignature */ || + container.kind === 145 /* GetAccessor */ || + container.kind === 146 /* SetAccessor */; + } + else { + return container.kind === 143 /* MethodDeclaration */ || + container.kind === 142 /* MethodSignature */ || + container.kind === 145 /* GetAccessor */ || + container.kind === 146 /* SetAccessor */ || + container.kind === 141 /* PropertyDeclaration */ || + container.kind === 140 /* PropertySignature */ || + container.kind === 144 /* Constructor */; + } + } + } + return false; + } + } + // Return contextual type of parameter or undefined if no contextual type is available + function getContextuallyTypedParameterType(parameter) { + var func = parameter.parent; + if (isFunctionExpressionOrArrowFunction(func) || ts.isObjectLiteralMethod(func)) { + if (isContextSensitive(func)) { + var contextualSignature = getContextualSignature(func); + if (contextualSignature) { + var funcHasRestParameters = ts.hasRestParameter(func); + var len = func.parameters.length - (funcHasRestParameters ? 1 : 0); + var indexOfParameter = ts.indexOf(func.parameters, parameter); + if (indexOfParameter < len) { + return getTypeAtPosition(contextualSignature, indexOfParameter); + } + // If last parameter is contextually rest parameter get its type + if (funcHasRestParameters && + indexOfParameter === (func.parameters.length - 1) && + isRestParameterIndex(contextualSignature, func.parameters.length - 1)) { + return getTypeOfSymbol(ts.lastOrUndefined(contextualSignature.parameters)); + } + } + } + } + return undefined; + } + // In a variable, parameter or property declaration with a type annotation, the contextual type of an initializer + // expression is the type of the variable, parameter or property. Otherwise, in a parameter declaration of a + // contextually typed function expression, the contextual type of an initializer expression is the contextual type + // of the parameter. Otherwise, in a variable or parameter declaration with a binding pattern name, the contextual + // type of an initializer expression is the type implied by the binding pattern. + function getContextualTypeForInitializerExpression(node) { + var declaration = node.parent; + if (node === declaration.initializer) { + if (declaration.type) { + return getTypeFromTypeNode(declaration.type); + } + if (declaration.kind === 138 /* Parameter */) { + var type = getContextuallyTypedParameterType(declaration); + if (type) { + return type; + } + } + if (ts.isBindingPattern(declaration.name)) { + return getTypeFromBindingPattern(declaration.name, /*includePatternInType*/ true); + } + } + return undefined; + } + function getContextualTypeForReturnExpression(node) { + var func = ts.getContainingFunction(node); + if (func && !func.asteriskToken) { + return getContextualReturnType(func); + } + return undefined; + } + function getContextualTypeForYieldOperand(node) { + var func = ts.getContainingFunction(node); + if (func) { + var contextualReturnType = getContextualReturnType(func); + if (contextualReturnType) { + return node.asteriskToken + ? contextualReturnType + : getElementTypeOfIterableIterator(contextualReturnType); + } + } + return undefined; + } + function isInParameterInitializerBeforeContainingFunction(node) { + while (node.parent && !ts.isFunctionLike(node.parent)) { + if (node.parent.kind === 138 /* Parameter */ && node.parent.initializer === node) { + return true; + } + node = node.parent; + } + return false; + } + function getContextualReturnType(functionDecl) { + // 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 === 144 /* Constructor */ || + functionDecl.kind === 145 /* GetAccessor */ && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(functionDecl.symbol, 146 /* SetAccessor */))) { + return getReturnTypeOfSignature(getSignatureFromDeclaration(functionDecl)); + } + // Otherwise, if the containing function is contextually typed by a function type with exactly one call signature + // and that call signature is non-generic, return statements are contextually typed by the return type of the signature + var signature = getContextualSignatureForFunctionLikeDeclaration(functionDecl); + if (signature) { + return getReturnTypeOfSignature(signature); + } + return undefined; + } + // In a typed function call, an argument or substitution expression is contextually typed by the type of the corresponding parameter. + function getContextualTypeForArgument(callTarget, arg) { + var args = getEffectiveCallArguments(callTarget); + var argIndex = ts.indexOf(args, arg); + if (argIndex >= 0) { + var signature = getResolvedSignature(callTarget); + return getTypeAtPosition(signature, argIndex); + } + return undefined; + } + function getContextualTypeForSubstitutionExpression(template, substitutionExpression) { + if (template.parent.kind === 170 /* TaggedTemplateExpression */) { + return getContextualTypeForArgument(template.parent, substitutionExpression); + } + return undefined; + } + function getContextualTypeForBinaryOperand(node) { + var binaryExpression = node.parent; + var operator = binaryExpression.operatorToken.kind; + if (operator >= 56 /* FirstAssignment */ && operator <= 68 /* LastAssignment */) { + // In an assignment expression, the right operand is contextually typed by the type of the left operand. + if (node === binaryExpression.right) { + return checkExpression(binaryExpression.left); + } + } + else if (operator === 52 /* BarBarToken */) { + // When an || expression has a contextual type, the operands are contextually typed by that type. When an || + // expression has no contextual type, the right operand is contextually typed by the type of the left operand. + var type = getContextualType(binaryExpression); + if (!type && node === binaryExpression.right) { + type = checkExpression(binaryExpression.left); + } + return type; + } + return undefined; + } + // Apply a mapping function to a contextual type and return the resulting type. If the contextual type + // is a union type, the mapping function is applied to each constituent type and a union of the resulting + // types is returned. + function applyToContextualType(type, mapper) { + if (!(type.flags & 16384 /* Union */)) { + return mapper(type); + } + var types = type.types; + var mappedType; + var mappedTypes; + for (var _i = 0; _i < types.length; _i++) { + var current = types[_i]; + var t = mapper(current); + if (t) { + if (!mappedType) { + mappedType = t; + } + else if (!mappedTypes) { + mappedTypes = [mappedType, t]; + } + else { + mappedTypes.push(t); + } + } + } + return mappedTypes ? getUnionType(mappedTypes) : mappedType; + } + function getTypeOfPropertyOfContextualType(type, name) { + return applyToContextualType(type, function (t) { + var prop = t.flags & 130048 /* StructuredType */ ? getPropertyOfType(t, name) : undefined; + return prop ? getTypeOfSymbol(prop) : undefined; + }); + } + function getIndexTypeOfContextualType(type, kind) { + return applyToContextualType(type, function (t) { return getIndexTypeOfStructuredType(t, kind); }); + } + // Return true if the given contextual type is a tuple-like type + function contextualTypeIsTupleLikeType(type) { + return !!(type.flags & 16384 /* Union */ ? ts.forEach(type.types, isTupleLikeType) : isTupleLikeType(type)); + } + // Return true if the given contextual type provides an index signature of the given kind + function contextualTypeHasIndexSignature(type, kind) { + return !!(type.flags & 16384 /* Union */ ? ts.forEach(type.types, function (t) { return getIndexTypeOfStructuredType(t, kind); }) : getIndexTypeOfStructuredType(type, kind)); + } + // In an object literal contextually typed by a type T, the contextual type of a property assignment is the type of + // the matching property in T, if one exists. Otherwise, it is the type of the numeric index signature in T, if one + // exists. Otherwise, it is the type of the string index signature in T, if one exists. + function getContextualTypeForObjectLiteralMethod(node) { + ts.Debug.assert(ts.isObjectLiteralMethod(node)); + if (isInsideWithStatementBody(node)) { + // We cannot answer semantic questions within a with block, do not proceed any further + return undefined; + } + return getContextualTypeForObjectLiteralElement(node); + } + function getContextualTypeForObjectLiteralElement(element) { + var objectLiteral = element.parent; + var type = getContextualType(objectLiteral); + if (type) { + if (!ts.hasDynamicName(element)) { + // For a (non-symbol) computed property, there is no reason to look up the name + // in the type. It will just be "__computed", which does not appear in any + // SymbolTable. + var symbolName = getSymbolOfNode(element).name; + var propertyType = getTypeOfPropertyOfContextualType(type, symbolName); + if (propertyType) { + return propertyType; + } + } + return isNumericName(element.name) && getIndexTypeOfContextualType(type, 1 /* Number */) || + getIndexTypeOfContextualType(type, 0 /* String */); + } + return undefined; + } + // In an array literal contextually typed by a type T, the contextual type of an element expression at index N is + // the type of the property with the numeric name N in T, if one exists. Otherwise, if T has a numeric index signature, + // it is the type of the numeric index signature in T. Otherwise, in ES6 and higher, the contextual type is the iterated + // type of T. + function getContextualTypeForElementExpression(node) { + var arrayLiteral = node.parent; + var type = getContextualType(arrayLiteral); + if (type) { + var index = ts.indexOf(arrayLiteral.elements, node); + return getTypeOfPropertyOfContextualType(type, "" + index) + || getIndexTypeOfContextualType(type, 1 /* Number */) + || (languageVersion >= 2 /* ES6 */ ? getElementTypeOfIterable(type, /*errorNode*/ undefined) : undefined); + } + return undefined; + } + // In a contextually typed conditional expression, the true/false expressions are contextually typed by the same type. + function getContextualTypeForConditionalOperand(node) { + var conditional = node.parent; + return node === conditional.whenTrue || node === conditional.whenFalse ? getContextualType(conditional) : undefined; + } + function getContextualTypeForJsxExpression(expr) { + // Contextual type only applies to JSX expressions that are in attribute assignments (not in 'Children' positions) + if (expr.parent.kind === 238 /* JsxAttribute */) { + var attrib = expr.parent; + var attrsType = getJsxElementAttributesType(attrib.parent); + if (!attrsType || isTypeAny(attrsType)) { + return undefined; + } + else { + return getTypeOfPropertyOfType(attrsType, attrib.name.text); + } + } + if (expr.kind === 239 /* JsxSpreadAttribute */) { + return getJsxElementAttributesType(expr.parent); + } + return undefined; + } + // Return the contextual type for a given expression node. During overload resolution, a contextual type may temporarily + // be "pushed" onto a node using the contextualType property. + function getContextualType(node) { + var type = getContextualTypeWorker(node); + return type && getApparentType(type); + } + function getContextualTypeWorker(node) { + if (isInsideWithStatementBody(node)) { + // We cannot answer semantic questions within a with block, do not proceed any further + return undefined; + } + if (node.contextualType) { + return node.contextualType; + } + var parent = node.parent; + switch (parent.kind) { + case 211 /* VariableDeclaration */: + case 138 /* Parameter */: + case 141 /* PropertyDeclaration */: + case 140 /* PropertySignature */: + case 163 /* BindingElement */: + return getContextualTypeForInitializerExpression(node); + case 174 /* ArrowFunction */: + case 204 /* ReturnStatement */: + return getContextualTypeForReturnExpression(node); + case 184 /* YieldExpression */: + return getContextualTypeForYieldOperand(parent); + case 168 /* CallExpression */: + case 169 /* NewExpression */: + return getContextualTypeForArgument(parent, node); + case 171 /* TypeAssertionExpression */: + case 189 /* AsExpression */: + return getTypeFromTypeNode(parent.type); + case 181 /* BinaryExpression */: + return getContextualTypeForBinaryOperand(node); + case 245 /* PropertyAssignment */: + return getContextualTypeForObjectLiteralElement(parent); + case 164 /* ArrayLiteralExpression */: + return getContextualTypeForElementExpression(node); + case 182 /* ConditionalExpression */: + return getContextualTypeForConditionalOperand(node); + case 190 /* TemplateSpan */: + ts.Debug.assert(parent.parent.kind === 183 /* TemplateExpression */); + return getContextualTypeForSubstitutionExpression(parent.parent, node); + case 172 /* ParenthesizedExpression */: + return getContextualType(parent); + case 240 /* JsxExpression */: + case 239 /* JsxSpreadAttribute */: + return getContextualTypeForJsxExpression(parent); + } + return undefined; + } + // If the given type is an object or union type, if that type has a single signature, and if + // that signature is non-generic, return the signature. Otherwise return undefined. + function getNonGenericSignature(type) { + var signatures = getSignaturesOfStructuredType(type, 0 /* Call */); + if (signatures.length === 1) { + var signature = signatures[0]; + if (!signature.typeParameters) { + return signature; + } + } + } + function isFunctionExpressionOrArrowFunction(node) { + return node.kind === 173 /* FunctionExpression */ || node.kind === 174 /* ArrowFunction */; + } + function getContextualSignatureForFunctionLikeDeclaration(node) { + // Only function expressions, arrow functions, and object literal methods are contextually typed. + return isFunctionExpressionOrArrowFunction(node) || ts.isObjectLiteralMethod(node) + ? getContextualSignature(node) + : undefined; + } + // Return the contextual signature for a given expression node. A contextual type provides a + // contextual signature if it has a single call signature and if that call signature is non-generic. + // If the contextual type is a union type, get the signature from each type possible and if they are + // 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 !== 143 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + var type = ts.isObjectLiteralMethod(node) + ? getContextualTypeForObjectLiteralMethod(node) + : getContextualType(node); + if (!type) { + return undefined; + } + if (!(type.flags & 16384 /* Union */)) { + return getNonGenericSignature(type); + } + var signatureList; + var types = type.types; + for (var _i = 0; _i < types.length; _i++) { + var current = types[_i]; + var signature = getNonGenericSignature(current); + if (signature) { + if (!signatureList) { + // This signature will contribute to contextual union signature + signatureList = [signature]; + } + else if (!compareSignatures(signatureList[0], signature, /*partialMatch*/ false, /*ignoreReturnTypes*/ true, compareTypes)) { + // Signatures aren't identical, do not use + return undefined; + } + else { + // Use this signature for contextual union signature + signatureList.push(signature); + } + } + } + // Result is union of signatures collected (return type is union of return types of this signature set) + var result; + if (signatureList) { + result = cloneSignature(signatureList[0]); + // Clear resolved return type we possibly got from cloneSignature + result.resolvedReturnType = undefined; + result.unionSignatures = signatureList; + } + return result; + } + /** + * Detect if the mapper implies an inference context. Specifically, there are 4 possible values + * for a mapper. Let's go through each one of them: + * + * 1. undefined - this means we are not doing inferential typing, but we may do contextual typing, + * which could cause us to assign a parameter a type + * 2. identityMapper - means we want to avoid assigning a parameter a type, whether or not we are in + * inferential typing (context is undefined for the identityMapper) + * 3. a mapper created by createInferenceMapper - we are doing inferential typing, we want to assign + * types to parameters and fix type parameters (context is defined) + * 4. an instantiation mapper created by createTypeMapper or createTypeEraser - this should never be + * passed as the contextual mapper when checking an expression (context is undefined for these) + * + * isInferentialContext is detecting if we are in case 3 + */ + function isInferentialContext(mapper) { + return mapper && mapper.context; + } + // A node is an assignment target if it is on the left hand side of an '=' token, if it is parented by a property + // 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) { + var parent = node.parent; + if (parent.kind === 181 /* BinaryExpression */ && parent.operatorToken.kind === 56 /* EqualsToken */ && parent.left === node) { + return true; + } + if (parent.kind === 245 /* PropertyAssignment */) { + return isAssignmentTarget(parent.parent); + } + if (parent.kind === 164 /* ArrayLiteralExpression */) { + return isAssignmentTarget(parent); + } + return false; + } + function checkSpreadElementExpression(node, contextualMapper) { + // It is usually not safe to call checkExpressionCached if we can be contextually typing. + // You can tell that we are contextually typing because of the contextualMapper parameter. + // While it is true that a spread element can have a contextual type, it does not do anything + // with this type. It is neither affected by it, nor does it propagate it to its operand. + // So the fact that contextualMapper is passed is not important, because the operand of a spread + // element is not contextually typed. + var arrayOrIterableType = checkExpressionCached(node.expression, contextualMapper); + return checkIteratedTypeOrElementType(arrayOrIterableType, node.expression, /*allowStringInput*/ false); + } + function hasDefaultValue(node) { + return (node.kind === 163 /* BindingElement */ && !!node.initializer) || + (node.kind === 181 /* BinaryExpression */ && node.operatorToken.kind === 56 /* EqualsToken */); + } + function checkArrayLiteral(node, contextualMapper) { + var elements = node.elements; + var hasSpreadElement = false; + var elementTypes = []; + var inDestructuringPattern = isAssignmentTarget(node); + for (var _i = 0; _i < elements.length; _i++) { + var e = elements[_i]; + if (inDestructuringPattern && e.kind === 185 /* SpreadElementExpression */) { + // Given the following situation: + // var c: {}; + // [...c] = ["", 0]; + // + // c is represented in the tree as a spread element in an array literal. + // But c really functions as a rest element, and its purpose is to provide + // a contextual type for the right hand side of the assignment. Therefore, + // instead of calling checkExpression on "...c", which will give an error + // if c is not iterable/array-like, we need to act as if we are trying to + // get the contextual element type from it. So we do something similar to + // getContextualTypeForElementExpression, which will crucially not error + // 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); + if (restElementType) { + elementTypes.push(restElementType); + } + } + else { + var type = checkExpression(e, contextualMapper); + elementTypes.push(type); + } + hasSpreadElement = hasSpreadElement || e.kind === 185 /* SpreadElementExpression */; + } + if (!hasSpreadElement) { + // If array literal is actually a destructuring pattern, mark it as an implied type. We do this such + // that we get the same behavior for "var [x, y] = []" and "[x, y] = []". + if (inDestructuringPattern && elementTypes.length) { + var type = createNewTupleType(elementTypes); + type.pattern = node; + return type; + } + var contextualType = getContextualType(node); + if (contextualType && contextualTypeIsTupleLikeType(contextualType)) { + 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 === 162 /* ArrayBindingPattern */ || pattern.kind === 164 /* ArrayLiteralExpression */)) { + var patternElements = pattern.elements; + for (var i = elementTypes.length; i < patternElements.length; i++) { + var patternElement = patternElements[i]; + if (hasDefaultValue(patternElement)) { + elementTypes.push(contextualType.elementTypes[i]); + } + else { + if (patternElement.kind !== 187 /* OmittedExpression */) { + error(patternElement, ts.Diagnostics.Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value); + } + elementTypes.push(unknownType); + } + } + } + if (elementTypes.length) { + return createTupleType(elementTypes); + } + } + } + return createArrayType(elementTypes.length ? getUnionType(elementTypes) : undefinedType); + } + function isNumericName(name) { + return name.kind === 136 /* ComputedPropertyName */ ? isNumericComputedName(name) : isNumericLiteralName(name.text); + } + function isNumericComputedName(name) { + // It seems odd to consider an expression of type Any to result in a numeric name, + // but this behavior is consistent with checkIndexedAccess + return isTypeAnyOrAllConstituentTypesHaveKind(checkComputedPropertyName(name), 132 /* NumberLike */); + } + function isTypeAnyOrAllConstituentTypesHaveKind(type, kind) { + return isTypeAny(type) || allConstituentTypesHaveKind(type, kind); + } + function isNumericLiteralName(name) { + // The intent of numeric names is that + // - they are names with text in a numeric form, and that + // - setting properties/indexing with them is always equivalent to doing so with the numeric literal 'numLit', + // acquired by applying the abstract 'ToNumber' operation on the name's text. + // + // The subtlety is in the latter portion, as we cannot reliably say that anything that looks like a numeric literal is a numeric name. + // In fact, it is the case that the text of the name must be equal to 'ToString(numLit)' for this to hold. + // + // Consider the property name '"0xF00D"'. When one indexes with '0xF00D', they are actually indexing with the value of 'ToString(0xF00D)' + // according to the ECMAScript specification, so it is actually as if the user indexed with the string '"61453"'. + // Thus, the text of all numeric literals equivalent to '61543' such as '0xF00D', '0xf00D', '0170015', etc. are not valid numeric names + // because their 'ToString' representation is not equal to their original text. + // This is motivated by ECMA-262 sections 9.3.1, 9.8.1, 11.1.5, and 11.2.1. + // + // Here, we test whether 'ToString(ToNumber(name))' is exactly equal to 'name'. + // The '+' prefix operator is equivalent here to applying the abstract ToNumber operation. + // Applying the 'toString()' method on a number gives us the abstract ToString operation on a number. + // + // Note that this accepts the values 'Infinity', '-Infinity', and 'NaN', and that this is intentional. + // This is desired behavior, because when indexing with them as numeric entities, you are indexing + // with the strings '"Infinity"', '"-Infinity"', and '"NaN"' respectively. + return (+name).toString() === name; + } + function checkComputedPropertyName(node) { + var links = getNodeLinks(node.expression); + if (!links.resolvedType) { + links.resolvedType = checkExpression(node.expression); + // This will allow types number, string, symbol or any. It will also allow enums, the unknown + // type, and any union of these types (like string | number). + if (!isTypeAnyOrAllConstituentTypesHaveKind(links.resolvedType, 132 /* NumberLike */ | 258 /* StringLike */ | 16777216 /* ESSymbol */)) { + error(node, ts.Diagnostics.A_computed_property_name_must_be_of_type_string_number_symbol_or_any); + } + else { + checkThatExpressionIsProperSymbolReference(node.expression, links.resolvedType, /*reportError*/ true); + } + } + return links.resolvedType; + } + function checkObjectLiteral(node, contextualMapper) { + var inDestructuringPattern = isAssignmentTarget(node); + // Grammar checking + checkGrammarObjectLiteralExpression(node, inDestructuringPattern); + var propertiesTable = {}; + var propertiesArray = []; + var contextualType = getContextualType(node); + var contextualTypeHasPattern = contextualType && contextualType.pattern && + (contextualType.pattern.kind === 161 /* ObjectBindingPattern */ || contextualType.pattern.kind === 165 /* ObjectLiteralExpression */); + var typeFlags = 0; + for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { + var memberDecl = _a[_i]; + var member = memberDecl.symbol; + if (memberDecl.kind === 245 /* PropertyAssignment */ || + memberDecl.kind === 246 /* ShorthandPropertyAssignment */ || + ts.isObjectLiteralMethod(memberDecl)) { + var type = void 0; + if (memberDecl.kind === 245 /* PropertyAssignment */) { + type = checkPropertyAssignment(memberDecl, contextualMapper); + } + else if (memberDecl.kind === 143 /* MethodDeclaration */) { + type = checkObjectLiteralMethod(memberDecl, contextualMapper); + } + else { + ts.Debug.assert(memberDecl.kind === 246 /* ShorthandPropertyAssignment */); + type = checkExpression(memberDecl.name, contextualMapper); + } + typeFlags |= type.flags; + var prop = createSymbol(4 /* Property */ | 67108864 /* Transient */ | member.flags, member.name); + if (inDestructuringPattern) { + // If object literal is an assignment pattern and if the assignment pattern specifies a default value + // for the property, make the property optional. + var isOptional = (memberDecl.kind === 245 /* PropertyAssignment */ && hasDefaultValue(memberDecl.initializer)) || + (memberDecl.kind === 246 /* ShorthandPropertyAssignment */ && memberDecl.objectAssignmentInitializer); + if (isOptional) { + prop.flags |= 536870912 /* Optional */; + } + } + else if (contextualTypeHasPattern) { + // 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); + if (impliedProp) { + prop.flags |= impliedProp.flags & 536870912 /* Optional */; + } + else if (!compilerOptions.suppressExcessPropertyErrors) { + error(memberDecl.name, ts.Diagnostics.Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1, symbolToString(member), typeToString(contextualType)); + } + } + prop.declarations = member.declarations; + prop.parent = member.parent; + if (member.valueDeclaration) { + prop.valueDeclaration = member.valueDeclaration; + } + prop.type = type; + prop.target = member; + member = prop; + } + else { + // TypeScript 1.0 spec (April 2014) + // A get accessor declaration is processed in the same manner as + // 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 === 145 /* GetAccessor */ || memberDecl.kind === 146 /* SetAccessor */); + checkAccessorDeclaration(memberDecl); + } + if (!ts.hasDynamicName(memberDecl)) { + propertiesTable[member.name] = member; + } + propertiesArray.push(member); + } + // If object literal is contextually typed by the implied type of a binding pattern, augment the result + // type with those properties for which the binding pattern specifies a default value. + if (contextualTypeHasPattern) { + for (var _b = 0, _c = getPropertiesOfType(contextualType); _b < _c.length; _b++) { + var prop = _c[_b]; + if (!ts.hasProperty(propertiesTable, prop.name)) { + if (!(prop.flags & 536870912 /* Optional */)) { + error(prop.valueDeclaration || prop.bindingElement, ts.Diagnostics.Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value); + } + propertiesTable[prop.name] = prop; + propertiesArray.push(prop); + } + } + } + var stringIndexType = getIndexType(0 /* String */); + var numberIndexType = getIndexType(1 /* Number */); + var result = createAnonymousType(node.symbol, propertiesTable, emptyArray, emptyArray, stringIndexType, numberIndexType); + var freshObjectLiteralFlag = compilerOptions.suppressExcessPropertyErrors ? 0 : 1048576 /* FreshObjectLiteral */; + result.flags |= 524288 /* ObjectLiteral */ | 4194304 /* ContainsObjectLiteral */ | freshObjectLiteralFlag | (typeFlags & 14680064 /* PropagatingFlags */); + if (inDestructuringPattern) { + result.pattern = node; + } + return result; + function getIndexType(kind) { + if (contextualType && contextualTypeHasIndexSignature(contextualType, kind)) { + var propTypes = []; + for (var i = 0; i < propertiesArray.length; i++) { + var propertyDecl = node.properties[i]; + if (kind === 0 /* String */ || isNumericName(propertyDecl.name)) { + // Do not call getSymbolOfNode(propertyDecl), as that will get the + // original symbol for the node. We actually want to get the symbol + // created by checkObjectLiteral, since that will be appropriately + // contextually typed and resolved. + var type = getTypeOfSymbol(propertiesArray[i]); + if (!ts.contains(propTypes, type)) { + propTypes.push(type); + } + } + } + var result_1 = propTypes.length ? getUnionType(propTypes) : undefinedType; + typeFlags |= result_1.flags; + return result_1; + } + return undefined; + } + } + function checkJsxSelfClosingElement(node) { + checkJsxOpeningLikeElement(node); + return jsxElementType || anyType; + } + function tagNamesAreEquivalent(lhs, rhs) { + if (lhs.kind !== rhs.kind) { + return false; + } + if (lhs.kind === 69 /* Identifier */) { + return lhs.text === rhs.text; + } + return lhs.right.text === rhs.right.text && + tagNamesAreEquivalent(lhs.left, rhs.left); + } + function checkJsxElement(node) { + // Check attributes + checkJsxOpeningLikeElement(node.openingElement); + // Check that the closing tag matches + if (!tagNamesAreEquivalent(node.openingElement.tagName, node.closingElement.tagName)) { + error(node.closingElement, ts.Diagnostics.Expected_corresponding_JSX_closing_tag_for_0, ts.getTextOfNode(node.openingElement.tagName)); + } + else { + // Perform resolution on the closing tag so that rename/go to definition/etc work + getJsxElementTagSymbol(node.closingElement); + } + // Check children + for (var _i = 0, _a = node.children; _i < _a.length; _i++) { + var child = _a[_i]; + switch (child.kind) { + case 240 /* JsxExpression */: + checkJsxExpression(child); + break; + case 233 /* JsxElement */: + checkJsxElement(child); + break; + case 234 /* JsxSelfClosingElement */: + checkJsxSelfClosingElement(child); + break; + } + } + return jsxElementType || anyType; + } + /** + * Returns true iff the JSX element name would be a valid JS identifier, ignoring restrictions about keywords not being identifiers + */ + function isUnhyphenatedJsxName(name) { + // - is the only character supported in JSX attribute names that isn't valid in JavaScript identifiers + return name.indexOf("-") < 0; + } + /** + * Returns true iff React would emit this tag name as a string rather than an identifier or qualified name + */ + function isJsxIntrinsicIdentifier(tagName) { + if (tagName.kind === 135 /* QualifiedName */) { + return false; + } + else { + return ts.isIntrinsicJsxName(tagName.text); + } + } + function checkJsxAttribute(node, elementAttributesType, nameTable) { + var correspondingPropType = undefined; + // Look up the corresponding property for this attribute + if (elementAttributesType === emptyObjectType && isUnhyphenatedJsxName(node.name.text)) { + // If there is no 'props' property, you may not have non-"data-" attributes + error(node.parent, ts.Diagnostics.JSX_element_class_does_not_support_attributes_because_it_does_not_have_a_0_property, getJsxElementPropertiesName()); + } + else if (elementAttributesType && !isTypeAny(elementAttributesType)) { + var correspondingPropSymbol = getPropertyOfType(elementAttributesType, node.name.text); + correspondingPropType = correspondingPropSymbol && getTypeOfSymbol(correspondingPropSymbol); + if (isUnhyphenatedJsxName(node.name.text)) { + // Maybe there's a string indexer? + var indexerType = getIndexTypeOfType(elementAttributesType, 0 /* String */); + if (indexerType) { + correspondingPropType = indexerType; + } + else { + // If there's no corresponding property with this name, error + if (!correspondingPropType) { + error(node.name, ts.Diagnostics.Property_0_does_not_exist_on_type_1, node.name.text, typeToString(elementAttributesType)); + return unknownType; + } + } + } + } + var exprType; + if (node.initializer) { + exprType = checkExpression(node.initializer); + } + else { + // is sugar for + exprType = booleanType; + } + if (correspondingPropType) { + checkTypeAssignableTo(exprType, correspondingPropType, node); + } + nameTable[node.name.text] = true; + return exprType; + } + function checkJsxSpreadAttribute(node, elementAttributesType, nameTable) { + var type = checkExpression(node.expression); + var props = getPropertiesOfType(type); + for (var _i = 0; _i < props.length; _i++) { + var prop = props[_i]; + // Is there a corresponding property in the element attributes type? Skip checking of properties + // that have already been assigned to, as these are not actually pushed into the resulting type + if (!nameTable[prop.name]) { + var targetPropSym = getPropertyOfType(elementAttributesType, prop.name); + if (targetPropSym) { + var msg = ts.chainDiagnosticMessages(undefined, ts.Diagnostics.Property_0_of_JSX_spread_attribute_is_not_assignable_to_target_property, prop.name); + checkTypeAssignableTo(getTypeOfSymbol(prop), getTypeOfSymbol(targetPropSym), node, undefined, msg); + } + nameTable[prop.name] = true; + } + } + return type; + } + /// Returns the type JSX.IntrinsicElements. May return `unknownType` if that type is not present. + function getJsxIntrinsicElementsType() { + if (!jsxIntrinsicElementsType) { + jsxIntrinsicElementsType = getExportedTypeFromNamespace(JsxNames.JSX, JsxNames.IntrinsicElements) || unknownType; + } + return jsxIntrinsicElementsType; + } + /// Given a JSX opening element or self-closing element, return the symbol of the property that the tag name points to if + /// this is an intrinsic tag. This might be a named + /// property of the IntrinsicElements interface, or its string indexer. + /// If this is a class-based tag (otherwise returns undefined), returns the symbol of the class + /// type or factory function. + /// Otherwise, returns unknownSymbol. + function getJsxElementTagSymbol(node) { + var flags = 8 /* UnknownElement */; + var links = getNodeLinks(node); + if (!links.resolvedSymbol) { + if (isJsxIntrinsicIdentifier(node.tagName)) { + links.resolvedSymbol = lookupIntrinsicTag(node); + } + else { + links.resolvedSymbol = lookupClassTag(node); + } + } + return links.resolvedSymbol; + function lookupIntrinsicTag(node) { + var intrinsicElementsType = getJsxIntrinsicElementsType(); + if (intrinsicElementsType !== unknownType) { + // Property case + var intrinsicProp = getPropertyOfType(intrinsicElementsType, node.tagName.text); + if (intrinsicProp) { + links.jsxFlags |= 1 /* IntrinsicNamedElement */; + return intrinsicProp; + } + // Intrinsic string indexer case + var indexSignatureType = getIndexTypeOfType(intrinsicElementsType, 0 /* String */); + if (indexSignatureType) { + links.jsxFlags |= 2 /* IntrinsicIndexedElement */; + return intrinsicElementsType.symbol; + } + // Wasn't found + error(node, ts.Diagnostics.Property_0_does_not_exist_on_type_1, node.tagName.text, "JSX." + JsxNames.IntrinsicElements); + return unknownSymbol; + } + else { + if (compilerOptions.noImplicitAny) { + error(node, ts.Diagnostics.JSX_element_implicitly_has_type_any_because_no_interface_JSX_0_exists, JsxNames.IntrinsicElements); + } + } + } + function lookupClassTag(node) { + var valueSymbol = resolveJsxTagName(node); + // Look up the value in the current scope + if (valueSymbol && valueSymbol !== unknownSymbol) { + links.jsxFlags |= 4 /* ClassElement */; + if (valueSymbol.flags & 8388608 /* Alias */) { + markAliasSymbolAsReferenced(valueSymbol); + } + } + return valueSymbol || unknownSymbol; + } + function resolveJsxTagName(node) { + if (node.tagName.kind === 69 /* Identifier */) { + var tag = node.tagName; + var sym = getResolvedSymbol(tag); + return sym.exportSymbol || sym; + } + else { + return checkQualifiedName(node.tagName).symbol; + } + } + } + /** + * Given a JSX element that is a class element, finds the Element Instance Type. If the + * element is not a class element, or the class element type cannot be determined, returns 'undefined'. + * For example, in the element , the element instance type is `MyClass` (not `typeof MyClass`). + */ + function getJsxElementInstanceType(node) { + // There is no such thing as an instance type for a non-class element. This + // line shouldn't be hit. + ts.Debug.assert(!!(getNodeLinks(node).jsxFlags & 4 /* ClassElement */), "Should not call getJsxElementInstanceType on non-class Element"); + var classSymbol = getJsxElementTagSymbol(node); + if (classSymbol === unknownSymbol) { + // Couldn't find the class instance type. Error has already been issued + return anyType; + } + var valueType = getTypeOfSymbol(classSymbol); + if (isTypeAny(valueType)) { + // Short-circuit if the class tag is using an element type 'any' + return anyType; + } + // Resolve the signatures, preferring constructors + var signatures = getSignaturesOfType(valueType, 1 /* Construct */); + if (signatures.length === 0) { + // No construct signatures, try call signatures + signatures = getSignaturesOfType(valueType, 0 /* Call */); + if (signatures.length === 0) { + // We found no signatures at all, which is an error + error(node.tagName, ts.Diagnostics.JSX_element_type_0_does_not_have_any_construct_or_call_signatures, ts.getTextOfNode(node.tagName)); + return unknownType; + } + } + var returnType = getUnionType(signatures.map(getReturnTypeOfSignature)); + // Issue an error if this return type isn't assignable to JSX.ElementClass + var elemClassType = getJsxGlobalElementClassType(); + if (elemClassType) { + checkTypeRelatedTo(returnType, elemClassType, assignableRelation, node, ts.Diagnostics.JSX_element_type_0_is_not_a_constructor_function_for_JSX_elements); + } + return returnType; + } + /// e.g. "props" for React.d.ts, + /// or 'undefined' if ElementAttributesPropery doesn't exist (which means all + /// non-intrinsic elements' attributes type is 'any'), + /// or '' if it has 0 properties (which means every + /// non-instrinsic elements' attributes type is the element instance type) + function getJsxElementPropertiesName() { + // JSX + var jsxNamespace = getGlobalSymbol(JsxNames.JSX, 1536 /* Namespace */, /*diagnosticMessage*/ undefined); + // JSX.ElementAttributesProperty [symbol] + var attribsPropTypeSym = jsxNamespace && getSymbol(jsxNamespace.exports, JsxNames.ElementAttributesPropertyNameContainer, 793056 /* Type */); + // JSX.ElementAttributesProperty [type] + var attribPropType = attribsPropTypeSym && getDeclaredTypeOfSymbol(attribsPropTypeSym); + // The properites of JSX.ElementAttributesProperty + var attribProperties = attribPropType && getPropertiesOfType(attribPropType); + if (attribProperties) { + // Element Attributes has zero properties, so the element attributes type will be the class instance type + if (attribProperties.length === 0) { + return ""; + } + else if (attribProperties.length === 1) { + return attribProperties[0].name; + } + else { + error(attribsPropTypeSym.declarations[0], ts.Diagnostics.The_global_type_JSX_0_may_not_have_more_than_one_property, JsxNames.ElementAttributesPropertyNameContainer); + return undefined; + } + } + else { + // No interface exists, so the element attributes type will be an implicit any + return undefined; + } + } + /** + * Given an opening/self-closing element, get the 'element attributes type', i.e. the type that tells + * us which attributes are valid on a given element. + */ + function getJsxElementAttributesType(node) { + var links = getNodeLinks(node); + if (!links.resolvedJsxType) { + var sym = getJsxElementTagSymbol(node); + if (links.jsxFlags & 4 /* ClassElement */) { + var elemInstanceType = getJsxElementInstanceType(node); + if (isTypeAny(elemInstanceType)) { + return links.resolvedJsxType = elemInstanceType; + } + var propsName = getJsxElementPropertiesName(); + if (propsName === undefined) { + // There is no type ElementAttributesProperty, return 'any' + return links.resolvedJsxType = anyType; + } + else if (propsName === "") { + // If there is no e.g. 'props' member in ElementAttributesProperty, use the element class type instead + return links.resolvedJsxType = elemInstanceType; + } + else { + var attributesType = getTypeOfPropertyOfType(elemInstanceType, propsName); + if (!attributesType) { + // There is no property named 'props' on this instance type + return links.resolvedJsxType = emptyObjectType; + } + else if (isTypeAny(attributesType) || (attributesType === unknownType)) { + return links.resolvedJsxType = attributesType; + } + else if (!(attributesType.flags & 80896 /* ObjectType */)) { + error(node.tagName, ts.Diagnostics.JSX_element_attributes_type_0_must_be_an_object_type, typeToString(attributesType)); + return links.resolvedJsxType = anyType; + } + else { + return links.resolvedJsxType = attributesType; + } + } + } + else if (links.jsxFlags & 1 /* IntrinsicNamedElement */) { + return links.resolvedJsxType = getTypeOfSymbol(sym); + } + else if (links.jsxFlags & 2 /* IntrinsicIndexedElement */) { + return links.resolvedJsxType = getIndexTypeOfSymbol(sym, 0 /* String */); + } + else { + // Resolution failed, so we don't know + return links.resolvedJsxType = anyType; + } + } + return links.resolvedJsxType; + } + /** + * Given a JSX attribute, returns the symbol for the corresponds property + * of the element attributes type. Will return unknownSymbol for attributes + * that have no matching element attributes type property. + */ + function getJsxAttributePropertySymbol(attrib) { + var attributesType = getJsxElementAttributesType(attrib.parent); + var prop = getPropertyOfType(attributesType, attrib.name.text); + return prop || unknownSymbol; + } + var jsxElementClassType = undefined; + function getJsxGlobalElementClassType() { + if (!jsxElementClassType) { + jsxElementClassType = getExportedTypeFromNamespace(JsxNames.JSX, JsxNames.ElementClass); + } + return jsxElementClassType; + } + /// Returns all the properties of the Jsx.IntrinsicElements interface + function getJsxIntrinsicTagNames() { + var intrinsics = getJsxIntrinsicElementsType(); + return intrinsics ? getPropertiesOfType(intrinsics) : emptyArray; + } + function checkJsxPreconditions(errorNode) { + // Preconditions for using JSX + if ((compilerOptions.jsx || 0 /* None */) === 0 /* None */) { + error(errorNode, ts.Diagnostics.Cannot_use_JSX_unless_the_jsx_flag_is_provided); + } + if (jsxElementType === undefined) { + if (compilerOptions.noImplicitAny) { + error(errorNode, ts.Diagnostics.JSX_element_implicitly_has_type_any_because_the_global_type_JSX_Element_does_not_exist); + } + } + } + function checkJsxOpeningLikeElement(node) { + checkGrammarJsxElement(node); + checkJsxPreconditions(node); + // If we're compiling under --jsx react, the symbol 'React' should + // be marked as 'used' so we don't incorrectly elide its import. And if there + // is no 'React' symbol in scope, we should issue an error. + if (compilerOptions.jsx === 2 /* React */) { + var reactSym = resolveName(node.tagName, "React", 107455 /* Value */, ts.Diagnostics.Cannot_find_name_0, "React"); + if (reactSym) { + getSymbolLinks(reactSym).referenced = true; + } + } + var targetAttributesType = getJsxElementAttributesType(node); + var nameTable = {}; + // Process this array in right-to-left order so we know which + // attributes (mostly from spreads) are being overwritten and + // thus should have their types ignored + var sawSpreadedAny = false; + for (var i = node.attributes.length - 1; i >= 0; i--) { + if (node.attributes[i].kind === 238 /* JsxAttribute */) { + checkJsxAttribute((node.attributes[i]), targetAttributesType, nameTable); + } + else { + ts.Debug.assert(node.attributes[i].kind === 239 /* JsxSpreadAttribute */); + var spreadType = checkJsxSpreadAttribute((node.attributes[i]), targetAttributesType, nameTable); + if (isTypeAny(spreadType)) { + sawSpreadedAny = true; + } + } + } + // Check that all required properties have been provided. If an 'any' + // was spreaded in, though, assume that it provided all required properties + if (targetAttributesType && !sawSpreadedAny) { + var targetProperties = getPropertiesOfType(targetAttributesType); + for (var i = 0; i < targetProperties.length; i++) { + if (!(targetProperties[i].flags & 536870912 /* Optional */) && + nameTable[targetProperties[i].name] === undefined) { + error(node, ts.Diagnostics.Property_0_is_missing_in_type_1, targetProperties[i].name, typeToString(targetAttributesType)); + } + } + } + } + function checkJsxExpression(node) { + if (node.expression) { + return checkExpression(node.expression); + } + else { + return unknownType; + } + } + // 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 : 141 /* PropertyDeclaration */; + } + function getDeclarationFlagsFromSymbol(s) { + return s.valueDeclaration ? ts.getCombinedNodeFlags(s.valueDeclaration) : s.flags & 134217728 /* Prototype */ ? 16 /* Public */ | 128 /* Static */ : 0; + } + /** + * Check whether the requested property access is valid. + * Returns true if node is a valid property access, and false otherwise. + * @param node The node to be checked. + * @param left The left hand side of the property access (e.g.: the super in `super.foo`). + * @param type The type of left. + * @param prop The symbol for the right hand side of the property access. + */ + function checkClassPropertyAccess(node, left, type, prop) { + var flags = getDeclarationFlagsFromSymbol(prop); + var declaringClass = getDeclaredTypeOfSymbol(prop.parent); + if (left.kind === 95 /* SuperKeyword */) { + var errorNode = node.kind === 166 /* PropertyAccessExpression */ ? + node.name : + node.right; + // 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, + // a super property access is permitted and must specify a public instance member function of the base class. + // - In a static member function or static member accessor + // where this references the constructor function object of a derived class, + // a super property access is permitted and must specify a public static member function of the base class. + if (getDeclarationKindFromSymbol(prop) !== 143 /* MethodDeclaration */) { + // `prop` refers to a *property* declared in the super class + // rather than a *method*, so it does not satisfy the above criteria. + error(errorNode, ts.Diagnostics.Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword); + return false; + } + if (flags & 256 /* Abstract */) { + // A method cannot be accessed in a super property access if the method is abstract. + // This error could mask a private property access error. But, a member + // cannot simultaneously be private and abstract, so this will trigger an + // additional error elsewhere. + error(errorNode, ts.Diagnostics.Abstract_method_0_in_class_1_cannot_be_accessed_via_super_expression, symbolToString(prop), typeToString(declaringClass)); + return false; + } + } + // Public properties are otherwise accessible. + if (!(flags & (32 /* Private */ | 64 /* Protected */))) { + return true; + } + // Property is known to be private or protected at this point + // Get the declaring and enclosing class instance types + var enclosingClassDeclaration = ts.getContainingClass(node); + var enclosingClass = enclosingClassDeclaration ? getDeclaredTypeOfSymbol(getSymbolOfNode(enclosingClassDeclaration)) : undefined; + // Private property is accessible if declaring and enclosing class are the same + if (flags & 32 /* Private */) { + if (declaringClass !== enclosingClass) { + error(node, ts.Diagnostics.Property_0_is_private_and_only_accessible_within_class_1, symbolToString(prop), typeToString(declaringClass)); + return false; + } + return true; + } + // 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 */) { + return true; + } + // A protected property is accessible in the declaring class and classes derived from it + if (!enclosingClass || !hasBaseType(enclosingClass, declaringClass)) { + error(node, ts.Diagnostics.Property_0_is_protected_and_only_accessible_within_class_1_and_its_subclasses, symbolToString(prop), typeToString(declaringClass)); + return false; + } + // No further restrictions for static properties + if (flags & 128 /* Static */) { + return true; + } + // An instance property must be accessed through an instance of the enclosing class + if (type.flags & 33554432 /* ThisType */) { + // get the original type -- represented as the type constraint of the 'this' type + type = getConstraintOfTypeParameter(type); + } + // TODO: why is the first part of this check here? + if (!(getTargetType(type).flags & (1024 /* Class */ | 2048 /* Interface */) && hasBaseType(type, enclosingClass))) { + error(node, ts.Diagnostics.Property_0_is_protected_and_only_accessible_through_an_instance_of_class_1, symbolToString(prop), typeToString(enclosingClass)); + return false; + } + return true; + } + function checkPropertyAccessExpression(node) { + return checkPropertyAccessExpressionOrQualifiedName(node, node.expression, node.name); + } + function checkQualifiedName(node) { + return checkPropertyAccessExpressionOrQualifiedName(node, node.left, node.right); + } + function checkPropertyAccessExpressionOrQualifiedName(node, left, right) { + var type = checkExpression(left); + if (isTypeAny(type)) { + return type; + } + var apparentType = getApparentType(getWidenedType(type)); + if (apparentType === unknownType) { + // handle cases when type is Type parameter with invalid constraint + return unknownType; + } + var prop = getPropertyOfType(apparentType, right.text); + if (!prop) { + if (right.text) { + error(right, ts.Diagnostics.Property_0_does_not_exist_on_type_1, ts.declarationNameToString(right), typeToString(type.flags & 33554432 /* ThisType */ ? apparentType : type)); + } + return unknownType; + } + getNodeLinks(node).resolvedSymbol = prop; + if (prop.parent && prop.parent.flags & 32 /* Class */) { + checkClassPropertyAccess(node, left, apparentType, prop); + } + return getTypeOfSymbol(prop); + } + function isValidPropertyAccess(node, propertyName) { + var left = node.kind === 166 /* PropertyAccessExpression */ + ? node.expression + : node.left; + var type = checkExpression(left); + if (type !== unknownType && !isTypeAny(type)) { + var prop = getPropertyOfType(getWidenedType(type), propertyName); + if (prop && prop.parent && prop.parent.flags & 32 /* Class */) { + return checkClassPropertyAccess(node, left, type, prop); + } + } + return true; + } + function checkIndexedAccess(node) { + // Grammar checking + if (!node.argumentExpression) { + var sourceFile = getSourceFile(node); + if (node.parent.kind === 169 /* NewExpression */ && node.parent.expression === node) { + var start = ts.skipTrivia(sourceFile.text, node.expression.end); + var end = node.end; + grammarErrorAtPos(sourceFile, start, end - start, ts.Diagnostics.new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead); + } + else { + var start = node.end - "]".length; + var end = node.end; + grammarErrorAtPos(sourceFile, start, end - start, ts.Diagnostics.Expression_expected); + } + } + // Obtain base constraint such that we can bail out if the constraint is an unknown type + var objectType = getApparentType(checkExpression(node.expression)); + var indexType = node.argumentExpression ? checkExpression(node.argumentExpression) : unknownType; + if (objectType === unknownType) { + return unknownType; + } + var isConstEnum = isConstEnumObjectType(objectType); + if (isConstEnum && + (!node.argumentExpression || node.argumentExpression.kind !== 9 /* StringLiteral */)) { + error(node.argumentExpression, ts.Diagnostics.A_const_enum_member_can_only_be_accessed_using_a_string_literal); + return unknownType; + } + // TypeScript 1.0 spec (April 2014): 4.10 Property Access + // - If IndexExpr is a string literal or a numeric literal and ObjExpr's apparent type has a property with the name + // given by that literal(converted to its string representation in the case of a numeric literal), the property access is of the type of that property. + // - Otherwise, if ObjExpr's apparent type has a numeric index signature and IndexExpr is of type Any, the Number primitive type, or an enum type, + // the property access is of the type of that index signature. + // - Otherwise, if ObjExpr's apparent type has a string index signature and IndexExpr is of type Any, the String or Number primitive type, or an enum type, + // the property access is of the type of that index signature. + // - Otherwise, if IndexExpr is of type Any, the String or Number primitive type, or an enum type, the property access is of type Any. + // See if we can index as a property. + if (node.argumentExpression) { + var name_11 = getPropertyNameForIndexedAccess(node.argumentExpression, indexType); + if (name_11 !== undefined) { + var prop = getPropertyOfType(objectType, name_11); + 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_11, symbolToString(objectType.symbol)); + return unknownType; + } + } + } + // Check for compatible indexer types. + if (isTypeAnyOrAllConstituentTypesHaveKind(indexType, 258 /* StringLike */ | 132 /* NumberLike */ | 16777216 /* ESSymbol */)) { + // Try to use a number indexer. + if (isTypeAnyOrAllConstituentTypesHaveKind(indexType, 132 /* NumberLike */)) { + var numberIndexType = getIndexTypeOfType(objectType, 1 /* Number */); + if (numberIndexType) { + return numberIndexType; + } + } + // Try to use string indexing. + var stringIndexType = getIndexTypeOfType(objectType, 0 /* String */); + if (stringIndexType) { + return stringIndexType; + } + // Fall back to any. + if (compilerOptions.noImplicitAny && !compilerOptions.suppressImplicitAnyIndexErrors && !isTypeAny(objectType)) { + error(node, ts.Diagnostics.Index_signature_of_object_type_implicitly_has_an_any_type); + } + return anyType; + } + // REVIEW: Users should know the type that was actually used. + error(node, ts.Diagnostics.An_index_expression_argument_must_be_of_type_string_number_symbol_or_any); + return unknownType; + } + /** + * If indexArgumentExpression is a string literal or number literal, returns its text. + * If indexArgumentExpression is a constant value, returns its string value. + * If indexArgumentExpression is a well known symbol, returns the property name corresponding + * to this symbol, as long as it is a proper symbol reference. + * Otherwise, returns undefined. + */ + function getPropertyNameForIndexedAccess(indexArgumentExpression, indexArgumentType) { + if (indexArgumentExpression.kind === 9 /* StringLiteral */ || indexArgumentExpression.kind === 8 /* NumericLiteral */) { + return indexArgumentExpression.text; + } + if (indexArgumentExpression.kind === 167 /* ElementAccessExpression */ || indexArgumentExpression.kind === 166 /* PropertyAccessExpression */) { + var value = getConstantValue(indexArgumentExpression); + if (value !== undefined) { + return value.toString(); + } + } + if (checkThatExpressionIsProperSymbolReference(indexArgumentExpression, indexArgumentType, /*reportError*/ false)) { + var rightHandSideName = indexArgumentExpression.name.text; + return ts.getPropertyNameForKnownSymbolName(rightHandSideName); + } + return undefined; + } + /** + * A proper symbol reference requires the following: + * 1. The property access denotes a property that exists + * 2. The expression is of the form Symbol. + * 3. The property access is of the primitive type symbol. + * 4. Symbol in this context resolves to the global Symbol object + */ + function checkThatExpressionIsProperSymbolReference(expression, expressionType, reportError) { + if (expressionType === unknownType) { + // There is already an error, so no need to report one. + return false; + } + if (!ts.isWellKnownSymbolSyntactically(expression)) { + return false; + } + // Make sure the property type is the primitive symbol type + if ((expressionType.flags & 16777216 /* ESSymbol */) === 0) { + if (reportError) { + error(expression, ts.Diagnostics.A_computed_property_name_of_the_form_0_must_be_of_type_symbol, ts.getTextOfNode(expression)); + } + return false; + } + // The name is Symbol., so make sure Symbol actually resolves to the + // global Symbol object + var leftHandSide = expression.expression; + var leftHandSideSymbol = getResolvedSymbol(leftHandSide); + if (!leftHandSideSymbol) { + return false; + } + var globalESSymbol = getGlobalESSymbolConstructorSymbol(); + if (!globalESSymbol) { + // Already errored when we tried to look up the symbol + return false; + } + if (leftHandSideSymbol !== globalESSymbol) { + if (reportError) { + error(leftHandSide, ts.Diagnostics.Symbol_reference_does_not_refer_to_the_global_Symbol_constructor_object); + } + return false; + } + return true; + } + function resolveUntypedCall(node) { + if (node.kind === 170 /* TaggedTemplateExpression */) { + checkExpression(node.template); + } + else if (node.kind !== 139 /* Decorator */) { + ts.forEach(node.arguments, function (argument) { + checkExpression(argument); + }); + } + return anySignature; + } + function resolveErrorCall(node) { + resolveUntypedCall(node); + return unknownSignature; + } + // Re-order candidate signatures into the result array. Assumes the result array to be empty. + // The candidate list orders groups in reverse, but within a group signatures are kept in declaration order + // A nit here is that we reorder only signatures that belong to the same symbol, + // so order how inherited signatures are processed is still preserved. + // interface A { (x: string): void } + // interface B extends A { (x: 'foo'): string } + // let b: B; + // b('foo') // <- here overloads should be processed as [(x:'foo'): string, (x: string): void] + function reorderCandidates(signatures, result) { + var lastParent; + var lastSymbol; + var cutoffIndex = 0; + var index; + var specializedIndex = -1; + var spliceIndex; + ts.Debug.assert(!result.length); + for (var _i = 0; _i < signatures.length; _i++) { + var signature = signatures[_i]; + var symbol = signature.declaration && getSymbolOfNode(signature.declaration); + var parent_5 = signature.declaration && signature.declaration.parent; + if (!lastSymbol || symbol === lastSymbol) { + if (lastParent && parent_5 === lastParent) { + index++; + } + else { + lastParent = parent_5; + index = cutoffIndex; + } + } + else { + // 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_5; + } + lastSymbol = symbol; + // specialized signatures always need to be placed before non-specialized signatures regardless + // of the cutoff position; see GH#1133 + if (signature.hasStringLiterals) { + specializedIndex++; + spliceIndex = specializedIndex; + // The cutoff index always needs to be greater than or equal to the specialized signature index + // in order to prevent non-specialized signatures from being added before a specialized + // signature. + cutoffIndex++; + } + else { + spliceIndex = index; + } + result.splice(spliceIndex, 0, signature); + } + } + function getSpreadArgumentIndex(args) { + for (var i = 0; i < args.length; i++) { + var arg = args[i]; + if (arg && arg.kind === 185 /* SpreadElementExpression */) { + return i; + } + } + return -1; + } + function hasCorrectArity(node, args, signature) { + var adjustedArgCount; // Apparent number of arguments we will have in this call + var typeArguments; // Type arguments (undefined if none) + var callIsIncomplete; // In incomplete call we want to be lenient when we have too few arguments + var isDecorator; + var spreadArgIndex = -1; + if (node.kind === 170 /* TaggedTemplateExpression */) { + var tagExpression = node; + // Even if the call is incomplete, we'll have a missing expression as our last argument, + // so we can say the count is just the arg list length + adjustedArgCount = args.length; + typeArguments = undefined; + if (tagExpression.template.kind === 183 /* TemplateExpression */) { + // If a tagged template expression lacks a tail literal, the call is incomplete. + // Specifically, a template only can end in a TemplateTail or a Missing literal. + var templateExpression = tagExpression.template; + var lastSpan = ts.lastOrUndefined(templateExpression.templateSpans); + ts.Debug.assert(lastSpan !== undefined); // we should always have at least one span. + callIsIncomplete = ts.nodeIsMissing(lastSpan.literal) || !!lastSpan.literal.isUnterminated; + } + else { + // If the template didn't end in a backtick, or its beginning occurred right prior to EOF, + // 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 */); + callIsIncomplete = !!templateLiteral.isUnterminated; + } + } + else if (node.kind === 139 /* Decorator */) { + isDecorator = true; + typeArguments = undefined; + adjustedArgCount = getEffectiveArgumentCount(node, /*args*/ undefined, signature); + } + else { + var callExpression = node; + if (!callExpression.arguments) { + // This only happens when we have something of the form: 'new C' + ts.Debug.assert(callExpression.kind === 169 /* NewExpression */); + return signature.minArgumentCount === 0; + } + // For IDE scenarios we may have an incomplete call, so a trailing comma is tantamount to adding another argument. + adjustedArgCount = callExpression.arguments.hasTrailingComma ? args.length + 1 : args.length; + // If we are missing the close paren, the call is incomplete. + callIsIncomplete = callExpression.arguments.end === callExpression.end; + typeArguments = callExpression.typeArguments; + spreadArgIndex = getSpreadArgumentIndex(args); + } + // If the user supplied type arguments, but the number of type arguments does not match + // the declared number of type parameters, the call has an incorrect arity. + var hasRightNumberOfTypeArgs = !typeArguments || + (signature.typeParameters && typeArguments.length === signature.typeParameters.length); + if (!hasRightNumberOfTypeArgs) { + return false; + } + // If spread arguments are present, check that they correspond to a rest parameter. If so, no + // further checking is necessary. + if (spreadArgIndex >= 0) { + return isRestParameterIndex(signature, spreadArgIndex); + } + // Too many arguments implies incorrect arity. + if (!signature.hasRestParameter && adjustedArgCount > signature.parameters.length) { + return false; + } + // If the call is incomplete, we should skip the lower bound check. + var hasEnoughArguments = adjustedArgCount >= signature.minArgumentCount; + return callIsIncomplete || hasEnoughArguments; + } + // If type has a single call signature and no other members, return that signature. Otherwise, return undefined. + function getSingleCallSignature(type) { + if (type.flags & 80896 /* ObjectType */) { + var resolved = resolveStructuredTypeMembers(type); + if (resolved.callSignatures.length === 1 && resolved.constructSignatures.length === 0 && + resolved.properties.length === 0 && !resolved.stringIndexType && !resolved.numberIndexType) { + return resolved.callSignatures[0]; + } + } + return undefined; + } + // Instantiate a generic signature in the context of a non-generic signature (section 3.8.5 in TypeScript spec) + function instantiateSignatureInContextOf(signature, contextualSignature, contextualMapper) { + var context = createInferenceContext(signature.typeParameters, /*inferUnionTypes*/ true); + forEachMatchingParameterType(contextualSignature, signature, function (source, target) { + // Type parameters from outer context referenced by source type are fixed by instantiation of the source type + inferTypes(context, instantiateType(source, contextualMapper), target); + }); + return getSignatureInstantiation(signature, getInferredTypes(context)); + } + function inferTypeArguments(node, signature, args, excludeArgument, context) { + var typeParameters = signature.typeParameters; + var inferenceMapper = createInferenceMapper(context); + // Clear out all the inference results from the last time inferTypeArguments was called on this context + for (var i = 0; i < typeParameters.length; i++) { + // As an optimization, we don't have to clear (and later recompute) inferred types + // for type parameters that have already been fixed on the previous call to inferTypeArguments. + // It would be just as correct to reset all of them. But then we'd be repeating the same work + // for the type parameters that were fixed, namely the work done by getInferredType. + if (!context.inferences[i].isFixed) { + context.inferredTypes[i] = undefined; + } + } + // On this call to inferTypeArguments, we may get more inferences for certain type parameters that were not + // fixed last time. This means that a type parameter that failed inference last time may succeed this time, + // or vice versa. Therefore, the failedTypeParameterIndex is useless if it points to an unfixed type parameter, + // because it may change. So here we reset it. However, getInferredType will not revisit any type parameters + // that were previously fixed. So if a fixed type parameter failed previously, it will fail again because + // it will contain the exact same set of inferences. So if we reset the index from a fixed type parameter, + // we will lose information that we won't recover this time around. + if (context.failedTypeParameterIndex !== undefined && !context.inferences[context.failedTypeParameterIndex].isFixed) { + context.failedTypeParameterIndex = undefined; + } + // We perform two passes over the arguments. In the first pass we infer from all arguments, but use + // wildcards for all context sensitive function expressions. + var argCount = getEffectiveArgumentCount(node, args, signature); + 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 !== 187 /* OmittedExpression */) { + var paramType = getTypeAtPosition(signature, i); + var argType = getEffectiveArgumentType(node, i, arg); + // If the effective argument type is 'undefined', there is no synthetic type + // for the argument. In that case, we should check the argument. + if (argType === undefined) { + // For context sensitive arguments we pass the identityMapper, which is a signal to treat all + // context sensitive function expressions as wildcards + var mapper = excludeArgument && excludeArgument[i] !== undefined ? identityMapper : inferenceMapper; + argType = checkExpressionWithContextualType(arg, paramType, mapper); + } + inferTypes(context, argType, paramType); + } + } + // In the second pass we visit only context sensitive arguments, and only those that aren't excluded, this + // time treating function expressions normally (which may cause previously inferred type arguments to be fixed + // as we construct types for contextually typed parameters) + // Decorators will not have `excludeArgument`, as their arguments cannot be contextually typed. + // Tagged template expressions will always have `undefined` for `excludeArgument[0]`. + if (excludeArgument) { + for (var i = 0; i < argCount; i++) { + // No need to check for omitted args and template expressions, their exlusion value is always undefined + if (excludeArgument[i] === false) { + var arg = args[i]; + var paramType = getTypeAtPosition(signature, i); + inferTypes(context, checkExpressionWithContextualType(arg, paramType, inferenceMapper), paramType); + } + } + } + getInferredTypes(context); + } + function checkTypeArguments(signature, typeArguments, typeArgumentResultTypes, reportErrors, headMessage) { + var typeParameters = signature.typeParameters; + var typeArgumentsAreAssignable = true; + for (var i = 0; i < typeParameters.length; i++) { + var typeArgNode = typeArguments[i]; + var typeArgument = getTypeFromTypeNode(typeArgNode); + // Do not push on this array! It has a preallocated length + typeArgumentResultTypes[i] = typeArgument; + if (typeArgumentsAreAssignable /* so far */) { + var constraint = getConstraintOfTypeParameter(typeParameters[i]); + if (constraint) { + var errorInfo = void 0; + var typeArgumentHeadMessage = ts.Diagnostics.Type_0_does_not_satisfy_the_constraint_1; + if (reportErrors && headMessage) { + errorInfo = ts.chainDiagnosticMessages(errorInfo, typeArgumentHeadMessage); + typeArgumentHeadMessage = headMessage; + } + typeArgumentsAreAssignable = checkTypeAssignableTo(typeArgument, constraint, reportErrors ? typeArgNode : undefined, typeArgumentHeadMessage, errorInfo); + } + } + } + return typeArgumentsAreAssignable; + } + function checkApplicableSignature(node, args, signature, relation, excludeArgument, reportErrors) { + var argCount = getEffectiveArgumentCount(node, args, signature); + 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 !== 187 /* OmittedExpression */) { + // Check spread elements against rest type (from arity check we know spread argument corresponds to a rest parameter) + var paramType = getTypeAtPosition(signature, i); + var argType = getEffectiveArgumentType(node, i, arg); + // 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) { + argType = arg.kind === 9 /* StringLiteral */ && !reportErrors + ? getStringLiteralType(arg) + : checkExpressionWithContextualType(arg, paramType, excludeArgument && excludeArgument[i] ? identityMapper : undefined); + } + // Use argument expression as error location when reporting errors + var errorNode = reportErrors ? getEffectiveArgumentErrorNode(node, i, arg) : undefined; + var headMessage = ts.Diagnostics.Argument_of_type_0_is_not_assignable_to_parameter_of_type_1; + if (!checkTypeRelatedTo(argType, paramType, relation, errorNode, headMessage)) { + return false; + } + } + } + return true; + } + /** + * Returns the effective arguments for an expression that works like a function invocation. + * + * If 'node' is a CallExpression or a NewExpression, then its argument list is returned. + * If 'node' is a TaggedTemplateExpression, a new argument list is constructed from the substitution + * expressions, where the first element of the list is `undefined`. + * If 'node' is a Decorator, the argument list will be `undefined`, and its arguments and types + * will be supplied from calls to `getEffectiveArgumentCount` and `getEffectiveArgumentType`. + */ + function getEffectiveCallArguments(node) { + var args; + if (node.kind === 170 /* TaggedTemplateExpression */) { + var template = node.template; + args = [undefined]; + if (template.kind === 183 /* TemplateExpression */) { + ts.forEach(template.templateSpans, function (span) { + args.push(span.expression); + }); + } + } + else if (node.kind === 139 /* Decorator */) { + // For a decorator, we return undefined as we will determine + // the number and types of arguments for a decorator using + // `getEffectiveArgumentCount` and `getEffectiveArgumentType` below. + return undefined; + } + else { + args = node.arguments || emptyArray; + } + return args; + } + /** + * Returns the effective argument count for a node that works like a function invocation. + * If 'node' is a Decorator, the number of arguments is derived from the decoration + * target and the signature: + * If 'node.target' is a class declaration or class expression, the effective argument + * count is 1. + * If 'node.target' is a parameter declaration, the effective argument count is 3. + * If 'node.target' is a property declaration, the effective argument count is 2. + * If 'node.target' is a method or accessor declaration, the effective argument count + * is 3, although it can be 2 if the signature only accepts two arguments, allowing + * us to match a property decorator. + * Otherwise, the argument count is the length of the 'args' array. + */ + function getEffectiveArgumentCount(node, args, signature) { + if (node.kind === 139 /* Decorator */) { + switch (node.parent.kind) { + case 214 /* ClassDeclaration */: + case 186 /* ClassExpression */: + // A class decorator will have one argument (see `ClassDecorator` in core.d.ts) + return 1; + case 141 /* PropertyDeclaration */: + // A property declaration decorator will have two arguments (see + // `PropertyDecorator` in core.d.ts) + return 2; + case 143 /* MethodDeclaration */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: + // A method or accessor declaration decorator will have two or three arguments (see + // `PropertyDecorator` and `MethodDecorator` in core.d.ts) + // If we are emitting decorators for ES3, we will only pass two arguments. + if (languageVersion === 0 /* ES3 */) { + return 2; + } + // If the method decorator signature only accepts a target and a key, we will only + // type check those arguments. + return signature.parameters.length >= 3 ? 3 : 2; + case 138 /* Parameter */: + // A parameter declaration decorator will have three arguments (see + // `ParameterDecorator` in core.d.ts) + return 3; + } + } + else { + return args.length; + } + } + /** + * Returns the effective type of the first argument to a decorator. + * If 'node' is a class declaration or class expression, the effective argument type + * is the type of the static side of the class. + * If 'node' is a parameter declaration, the effective argument type is either the type + * of the static or instance side of the class for the parameter's parent method, + * depending on whether the method is declared static. + * For a constructor, the type is always the type of the static side of the class. + * If 'node' is a property, method, or accessor declaration, the effective argument + * type is the type of the static or instance side of the parent class for class + * element, depending on whether the element is declared static. + */ + function getEffectiveDecoratorFirstArgumentType(node) { + // The first argument to a decorator is its `target`. + if (node.kind === 214 /* 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 === 138 /* Parameter */) { + // For a parameter decorator, the `target` is the parent type of the + // parameter's containing method. + node = node.parent; + if (node.kind === 144 /* Constructor */) { + var classSymbol = getSymbolOfNode(node); + return getTypeOfSymbol(classSymbol); + } + } + if (node.kind === 141 /* PropertyDeclaration */ || + node.kind === 143 /* MethodDeclaration */ || + node.kind === 145 /* GetAccessor */ || + node.kind === 146 /* SetAccessor */) { + // For a property or method decorator, the `target` is the + // "static"-side type of the parent of the member if the member is + // declared "static"; otherwise, it is the "instance"-side type of the + // parent of the member. + return getParentTypeOfClassElement(node); + } + ts.Debug.fail("Unsupported decorator target."); + return unknownType; + } + /** + * Returns the effective type for the second argument to a decorator. + * If 'node' is a parameter, its effective argument type is one of the following: + * If 'node.parent' is a constructor, the effective argument type is 'any', as we + * will emit `undefined`. + * If 'node.parent' is a member with an identifier, numeric, or string literal name, + * the effective argument type will be a string literal type for the member name. + * If 'node.parent' is a computed property name, the effective argument type will + * either be a symbol type or the string type. + * If 'node' is a member with an identifier, numeric, or string literal name, the + * effective argument type will be a string literal type for the member name. + * If 'node' is a computed property name, the effective argument type will either + * be a symbol type or the string type. + * A class decorator does not have a second argument type. + */ + function getEffectiveDecoratorSecondArgumentType(node) { + // The second argument to a decorator is its `propertyKey` + if (node.kind === 214 /* ClassDeclaration */) { + ts.Debug.fail("Class decorators should not have a second synthetic argument."); + return unknownType; + } + if (node.kind === 138 /* Parameter */) { + node = node.parent; + if (node.kind === 144 /* Constructor */) { + // For a constructor parameter decorator, the `propertyKey` will be `undefined`. + return anyType; + } + } + if (node.kind === 141 /* PropertyDeclaration */ || + node.kind === 143 /* MethodDeclaration */ || + node.kind === 145 /* GetAccessor */ || + node.kind === 146 /* SetAccessor */) { + // The `propertyKey` for a property or method decorator will be a + // string literal type if the member name is an identifier, number, or string; + // otherwise, if the member name is a computed property name it will + // be either string or symbol. + var element = node; + switch (element.name.kind) { + case 69 /* Identifier */: + case 8 /* NumericLiteral */: + case 9 /* StringLiteral */: + return getStringLiteralType(element.name); + case 136 /* ComputedPropertyName */: + var nameType = checkComputedPropertyName(element.name); + if (allConstituentTypesHaveKind(nameType, 16777216 /* ESSymbol */)) { + return nameType; + } + else { + return stringType; + } + default: + ts.Debug.fail("Unsupported property name."); + return unknownType; + } + } + ts.Debug.fail("Unsupported decorator target."); + return unknownType; + } + /** + * Returns the effective argument type for the third argument to a decorator. + * If 'node' is a parameter, the effective argument type is the number type. + * If 'node' is a method or accessor, the effective argument type is a + * `TypedPropertyDescriptor` instantiated with the type of the member. + * Class and property decorators do not have a third effective argument. + */ + function getEffectiveDecoratorThirdArgumentType(node) { + // The third argument to a decorator is either its `descriptor` for a method decorator + // or its `parameterIndex` for a paramter decorator + if (node.kind === 214 /* ClassDeclaration */) { + ts.Debug.fail("Class decorators should not have a third synthetic argument."); + return unknownType; + } + if (node.kind === 138 /* Parameter */) { + // The `parameterIndex` for a parameter decorator is always a number + return numberType; + } + if (node.kind === 141 /* PropertyDeclaration */) { + ts.Debug.fail("Property decorators should not have a third synthetic argument."); + return unknownType; + } + if (node.kind === 143 /* MethodDeclaration */ || + node.kind === 145 /* GetAccessor */ || + node.kind === 146 /* SetAccessor */) { + // The `descriptor` for a method decorator will be a `TypedPropertyDescriptor` + // for the type of the member. + var propertyType = getTypeOfNode(node); + return createTypedPropertyDescriptorType(propertyType); + } + ts.Debug.fail("Unsupported decorator target."); + return unknownType; + } + /** + * Returns the effective argument type for the provided argument to a decorator. + */ + function getEffectiveDecoratorArgumentType(node, argIndex) { + if (argIndex === 0) { + return getEffectiveDecoratorFirstArgumentType(node.parent); + } + else if (argIndex === 1) { + return getEffectiveDecoratorSecondArgumentType(node.parent); + } + else if (argIndex === 2) { + return getEffectiveDecoratorThirdArgumentType(node.parent); + } + ts.Debug.fail("Decorators should not have a fourth synthetic argument."); + return unknownType; + } + /** + * Gets the effective argument type for an argument in a call expression. + */ + function getEffectiveArgumentType(node, argIndex, arg) { + // 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 === 139 /* Decorator */) { + return getEffectiveDecoratorArgumentType(node, argIndex); + } + else if (argIndex === 0 && node.kind === 170 /* TaggedTemplateExpression */) { + return globalTemplateStringsArrayType; + } + // This is not a synthetic argument, so we return 'undefined' + // to signal that the caller needs to check the argument. + return undefined; + } + /** + * Gets the effective argument expression for an argument in a call expression. + */ + function getEffectiveArgument(node, args, argIndex) { + // For a decorator or the first argument of a tagged template expression we return undefined. + if (node.kind === 139 /* Decorator */ || + (argIndex === 0 && node.kind === 170 /* TaggedTemplateExpression */)) { + return undefined; + } + return args[argIndex]; + } + /** + * Gets the error node to use when reporting errors for an effective argument. + */ + function getEffectiveArgumentErrorNode(node, argIndex, arg) { + if (node.kind === 139 /* Decorator */) { + // For a decorator, we use the expression of the decorator for error reporting. + return node.expression; + } + else if (argIndex === 0 && node.kind === 170 /* TaggedTemplateExpression */) { + // For a the first argument of a tagged template expression, we use the template of the tag for error reporting. + return node.template; + } + else { + return arg; + } + } + function resolveCall(node, signatures, candidatesOutArray, headMessage) { + var isTaggedTemplate = node.kind === 170 /* TaggedTemplateExpression */; + var isDecorator = node.kind === 139 /* Decorator */; + var typeArguments; + if (!isTaggedTemplate && !isDecorator) { + typeArguments = node.typeArguments; + // We already perform checking on the type arguments on the class declaration itself. + if (node.expression.kind !== 95 /* SuperKeyword */) { + ts.forEach(typeArguments, checkSourceElement); + } + } + var candidates = candidatesOutArray || []; + // reorderCandidates fills up the candidates array directly + reorderCandidates(signatures, candidates); + if (!candidates.length) { + reportError(ts.Diagnostics.Supplied_parameters_do_not_match_any_signature_of_call_target); + return resolveErrorCall(node); + } + var args = getEffectiveCallArguments(node); + // The following applies to any value of 'excludeArgument[i]': + // - true: the argument at 'i' is susceptible to a one-time permanent contextual typing. + // - undefined: the argument at 'i' is *not* susceptible to permanent contextual typing. + // - false: the argument at 'i' *was* and *has been* permanently contextually typed. + // + // The idea is that we will perform type argument inference & assignability checking once + // without using the susceptible parameters that are functions, and once more for each of those + // parameters, contextually typing each as we go along. + // + // For a tagged template, then the first argument be 'undefined' if necessary + // because it represents a TemplateStringsArray. + // + // For a decorator, no arguments are susceptible to contextual typing due to the fact + // decorators are applied to a declaration by the emitter, and not to an expression. + var excludeArgument; + if (!isDecorator) { + // We do not need to call `getEffectiveArgumentCount` here as it only + // applies when calculating the number of arguments for a decorator. + for (var i = isTaggedTemplate ? 1 : 0; i < args.length; i++) { + if (isContextSensitive(args[i])) { + if (!excludeArgument) { + excludeArgument = new Array(args.length); + } + excludeArgument[i] = true; + } + } + } + // The following variables are captured and modified by calls to chooseOverload. + // If overload resolution or type argument inference fails, we want to report the + // best error possible. The best error is one which says that an argument was not + // assignable to a parameter. This implies that everything else about the overload + // was fine. So if there is any overload that is only incorrect because of an + // argument, we will report an error on that one. + // + // function foo(s: string) {} + // function foo(n: number) {} // Report argument error on this overload + // function foo() {} + // foo(true); + // + // If none of the overloads even made it that far, there are two possibilities. + // There was a problem with type arguments for some overload, in which case + // report an error on that. Or none of the overloads even had correct arity, + // in which case give an arity error. + // + // function foo(x: T, y: T) {} // Report type argument inference error + // function foo() {} + // foo(0, true); + // + var candidateForArgumentError; + var candidateForTypeArgumentError; + var resultOfFailedInference; + var result; + // 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 + // of those signatures becomes the return type of the function call. + // Otherwise, the return type of the first signature in the candidate list becomes the return + // type of the function call. + // + // Whether the call is an error is determined by assignability of the arguments. The subtype pass + // is just important for choosing the best signature. So in the case where there is only one + // signature, the subtype pass is useless. So skipping it is an optimization. + if (candidates.length > 1) { + result = chooseOverload(candidates, subtypeRelation); + } + if (!result) { + // Reinitialize these pointers for round two + candidateForArgumentError = undefined; + candidateForTypeArgumentError = undefined; + resultOfFailedInference = undefined; + result = chooseOverload(candidates, assignableRelation); + } + if (result) { + return result; + } + // No signatures were applicable. Now report errors based on the last applicable signature with + // no arguments excluded from assignability checks. + // If candidate is undefined, it means that no candidates had a suitable arity. In that case, + // skip the checkApplicableSignature check. + if (candidateForArgumentError) { + // excludeArgument is undefined, in this case also equivalent to [undefined, undefined, ...] + // The importance of excludeArgument is to prevent us from typing function expression parameters + // in arguments too early. If possible, we'd like to only type them once we know the correct + // overload. However, this matters for the case where the call is correct. When the call is + // an error, we don't need to exclude any arguments, although it would cause no harm to do so. + checkApplicableSignature(node, args, candidateForArgumentError, assignableRelation, /*excludeArgument*/ undefined, /*reportErrors*/ true); + } + else if (candidateForTypeArgumentError) { + if (!isTaggedTemplate && !isDecorator && typeArguments) { + checkTypeArguments(candidateForTypeArgumentError, node.typeArguments, [], /*reportErrors*/ true, headMessage); + } + else { + ts.Debug.assert(resultOfFailedInference.failedTypeParameterIndex >= 0); + var failedTypeParameter = candidateForTypeArgumentError.typeParameters[resultOfFailedInference.failedTypeParameterIndex]; + var inferenceCandidates = getInferenceCandidates(resultOfFailedInference, resultOfFailedInference.failedTypeParameterIndex); + var diagnosticChainHead = ts.chainDiagnosticMessages(/*details*/ undefined, // details will be provided by call to reportNoCommonSupertypeError + ts.Diagnostics.The_type_argument_for_type_parameter_0_cannot_be_inferred_from_the_usage_Consider_specifying_the_type_arguments_explicitly, typeToString(failedTypeParameter)); + if (headMessage) { + diagnosticChainHead = ts.chainDiagnosticMessages(diagnosticChainHead, headMessage); + } + reportNoCommonSupertypeError(inferenceCandidates, node.expression || node.tag, diagnosticChainHead); + } + } + else { + reportError(ts.Diagnostics.Supplied_parameters_do_not_match_any_signature_of_call_target); + } + // No signature was applicable. We have already reported the errors for the invalid signature. + // If this is a type resolution session, e.g. Language Service, try to get better information that anySignature. + // Pick the first candidate that matches the arity. This way we can get a contextual type for cases like: + // declare function f(a: { xa: number; xb: number; }); + // f({ | + if (!produceDiagnostics) { + for (var _i = 0; _i < candidates.length; _i++) { + var candidate = candidates[_i]; + if (hasCorrectArity(node, args, candidate)) { + if (candidate.typeParameters && typeArguments) { + candidate = getSignatureInstantiation(candidate, ts.map(typeArguments, getTypeFromTypeNode)); + } + return candidate; + } + } + } + return resolveErrorCall(node); + function reportError(message, arg0, arg1, arg2) { + var errorInfo; + errorInfo = ts.chainDiagnosticMessages(errorInfo, message, arg0, arg1, arg2); + if (headMessage) { + errorInfo = ts.chainDiagnosticMessages(errorInfo, headMessage); + } + diagnostics.add(ts.createDiagnosticForNodeFromMessageChain(node, errorInfo)); + } + function chooseOverload(candidates, relation) { + for (var _i = 0; _i < candidates.length; _i++) { + var originalCandidate = candidates[_i]; + if (!hasCorrectArity(node, args, originalCandidate)) { + continue; + } + var candidate = void 0; + var typeArgumentsAreValid = void 0; + var inferenceContext = originalCandidate.typeParameters + ? createInferenceContext(originalCandidate.typeParameters, /*inferUnionTypes*/ false) + : undefined; + while (true) { + candidate = originalCandidate; + if (candidate.typeParameters) { + var typeArgumentTypes = void 0; + if (typeArguments) { + typeArgumentTypes = new Array(candidate.typeParameters.length); + typeArgumentsAreValid = checkTypeArguments(candidate, typeArguments, typeArgumentTypes, /*reportErrors*/ false); + } + else { + inferTypeArguments(node, candidate, args, excludeArgument, inferenceContext); + typeArgumentsAreValid = inferenceContext.failedTypeParameterIndex === undefined; + typeArgumentTypes = inferenceContext.inferredTypes; + } + if (!typeArgumentsAreValid) { + break; + } + candidate = getSignatureInstantiation(candidate, typeArgumentTypes); + } + if (!checkApplicableSignature(node, args, candidate, relation, excludeArgument, /*reportErrors*/ false)) { + break; + } + var index = excludeArgument ? ts.indexOf(excludeArgument, true) : -1; + if (index < 0) { + return candidate; + } + excludeArgument[index] = false; + } + // A post-mortem of this iteration of the loop. The signature was not applicable, + // so we want to track it as a candidate for reporting an error. If the candidate + // had no type parameters, or had no issues related to type arguments, we can + // report an error based on the arguments. If there was an issue with type + // arguments, then we can only report an error based on the type arguments. + if (originalCandidate.typeParameters) { + var instantiatedCandidate = candidate; + if (typeArgumentsAreValid) { + candidateForArgumentError = instantiatedCandidate; + } + else { + candidateForTypeArgumentError = originalCandidate; + if (!typeArguments) { + resultOfFailedInference = inferenceContext; + } + } + } + else { + ts.Debug.assert(originalCandidate === candidate); + candidateForArgumentError = originalCandidate; + } + } + return undefined; + } + } + function resolveCallExpression(node, candidatesOutArray) { + if (node.expression.kind === 95 /* SuperKeyword */) { + var superType = checkSuperExpression(node.expression); + if (superType !== unknownType) { + // In super call, the candidate signatures are the matching arity signatures of the base constructor function instantiated + // with the type arguments specified in the extends clause. + var baseTypeNode = ts.getClassExtendsHeritageClauseElement(ts.getContainingClass(node)); + var baseConstructors = getInstantiatedConstructorsForTypeArguments(superType, baseTypeNode.typeArguments); + return resolveCall(node, baseConstructors, candidatesOutArray); + } + return resolveUntypedCall(node); + } + var funcType = checkExpression(node.expression); + var apparentType = getApparentType(funcType); + if (apparentType === unknownType) { + // Another error has already been reported + return resolveErrorCall(node); + } + // Technically, this signatures list may be incomplete. We are taking the apparent type, + // but we are not including call signatures that may have been added to the Object or + // Function interface, since they have none by default. This is a bit of a leap of faith + // that the user will not add any. + var callSignatures = getSignaturesOfType(apparentType, 0 /* Call */); + var constructSignatures = getSignaturesOfType(apparentType, 1 /* Construct */); + // TS 1.0 spec: 4.12 + // If FuncExpr is of type Any, or of an object type that has no call or construct signatures + // but is a subtype of the Function interface, the call is an untyped function call. In an + // untyped function call no TypeArgs are permitted, Args can be any argument list, no contextual + // types are provided for the argument expressions, and the result is always of type Any. + // We exclude union types because we may have a union of function types that happen to have + // no common signatures. + if (isTypeAny(funcType) || (!callSignatures.length && !constructSignatures.length && !(funcType.flags & 16384 /* Union */) && isTypeAssignableTo(funcType, globalFunctionType))) { + // The unknownType indicates that an error already occured (and was reported). No + // need to report another error in this case. + if (funcType !== unknownType && node.typeArguments) { + error(node, ts.Diagnostics.Untyped_function_calls_may_not_accept_type_arguments); + } + return resolveUntypedCall(node); + } + // If FuncExpr's apparent type(section 3.8.1) is a function type, the call is a typed function call. + // TypeScript employs overload resolution in typed function calls in order to support functions + // with multiple call signatures. + if (!callSignatures.length) { + if (constructSignatures.length) { + error(node, ts.Diagnostics.Value_of_type_0_is_not_callable_Did_you_mean_to_include_new, typeToString(funcType)); + } + else { + error(node, ts.Diagnostics.Cannot_invoke_an_expression_whose_type_lacks_a_call_signature); + } + return resolveErrorCall(node); + } + return resolveCall(node, callSignatures, candidatesOutArray); + } + function resolveNewExpression(node, candidatesOutArray) { + if (node.arguments && languageVersion < 1 /* ES5 */) { + var spreadIndex = getSpreadArgumentIndex(node.arguments); + if (spreadIndex >= 0) { + error(node.arguments[spreadIndex], ts.Diagnostics.Spread_operator_in_new_expressions_is_only_available_when_targeting_ECMAScript_5_and_higher); + } + } + var expressionType = checkExpression(node.expression); + // If expressionType's apparent type(section 3.8.1) is an object type with one or + // more construct signatures, the expression is processed in the same manner as a + // function call, but using the construct signatures as the initial set of candidate + // signatures for overload resolution. The result type of the function call becomes + // the result type of the operation. + expressionType = getApparentType(expressionType); + if (expressionType === unknownType) { + // Another error has already been reported + return resolveErrorCall(node); + } + // If the expression is a class of abstract type, then it cannot be instantiated. + // Note, only class declarations can be declared abstract. + // In the case of a merged class-module or class-interface declaration, + // only the class declaration node will have the Abstract flag set. + var valueDecl = expressionType.symbol && getClassLikeDeclarationOfSymbol(expressionType.symbol); + if (valueDecl && valueDecl.flags & 256 /* Abstract */) { + error(node, ts.Diagnostics.Cannot_create_an_instance_of_the_abstract_class_0, ts.declarationNameToString(valueDecl.name)); + return resolveErrorCall(node); + } + // TS 1.0 spec: 4.11 + // If expressionType is of type Any, Args can be any argument + // list and the result of the operation is of type Any. + if (isTypeAny(expressionType)) { + if (node.typeArguments) { + error(node, ts.Diagnostics.Untyped_function_calls_may_not_accept_type_arguments); + } + return resolveUntypedCall(node); + } + // Technically, this signatures list may be incomplete. We are taking the apparent type, + // but we are not including construct signatures that may have been added to the Object or + // Function interface, since they have none by default. This is a bit of a leap of faith + // that the user will not add any. + var constructSignatures = getSignaturesOfType(expressionType, 1 /* Construct */); + if (constructSignatures.length) { + return resolveCall(node, constructSignatures, candidatesOutArray); + } + // If expressionType's apparent type is an object type with no construct signatures but + // one or more call signatures, the expression is processed as a function call. A compile-time + // error occurs if the result of the function call is not Void. The type of the result of the + // operation is Any. + var callSignatures = getSignaturesOfType(expressionType, 0 /* Call */); + if (callSignatures.length) { + var signature = resolveCall(node, callSignatures, candidatesOutArray); + if (getReturnTypeOfSignature(signature) !== voidType) { + error(node, ts.Diagnostics.Only_a_void_function_can_be_called_with_the_new_keyword); + } + return signature; + } + error(node, ts.Diagnostics.Cannot_use_new_with_an_expression_whose_type_lacks_a_call_or_construct_signature); + return resolveErrorCall(node); + } + function resolveTaggedTemplateExpression(node, candidatesOutArray) { + var tagType = checkExpression(node.tag); + var apparentType = getApparentType(tagType); + if (apparentType === unknownType) { + // Another error has already been reported + return resolveErrorCall(node); + } + var callSignatures = getSignaturesOfType(apparentType, 0 /* Call */); + if (isTypeAny(tagType) || (!callSignatures.length && !(tagType.flags & 16384 /* Union */) && isTypeAssignableTo(tagType, globalFunctionType))) { + return resolveUntypedCall(node); + } + if (!callSignatures.length) { + error(node, ts.Diagnostics.Cannot_invoke_an_expression_whose_type_lacks_a_call_signature); + return resolveErrorCall(node); + } + return resolveCall(node, callSignatures, candidatesOutArray); + } + /** + * Gets the localized diagnostic head message to use for errors when resolving a decorator as a call expression. + */ + function getDiagnosticHeadMessageForDecoratorResolution(node) { + switch (node.parent.kind) { + case 214 /* ClassDeclaration */: + case 186 /* ClassExpression */: + return ts.Diagnostics.Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression; + case 138 /* Parameter */: + return ts.Diagnostics.Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression; + case 141 /* PropertyDeclaration */: + return ts.Diagnostics.Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression; + case 143 /* MethodDeclaration */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: + return ts.Diagnostics.Unable_to_resolve_signature_of_method_decorator_when_called_as_an_expression; + } + } + /** + * Resolves a decorator as if it were a call expression. + */ + function resolveDecorator(node, candidatesOutArray) { + var funcType = checkExpression(node.expression); + var apparentType = getApparentType(funcType); + if (apparentType === unknownType) { + return resolveErrorCall(node); + } + var callSignatures = getSignaturesOfType(apparentType, 0 /* Call */); + if (funcType === anyType || (!callSignatures.length && !(funcType.flags & 16384 /* Union */) && isTypeAssignableTo(funcType, globalFunctionType))) { + return resolveUntypedCall(node); + } + var headMessage = getDiagnosticHeadMessageForDecoratorResolution(node); + if (!callSignatures.length) { + var errorInfo; + errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.Cannot_invoke_an_expression_whose_type_lacks_a_call_signature); + errorInfo = ts.chainDiagnosticMessages(errorInfo, headMessage); + diagnostics.add(ts.createDiagnosticForNodeFromMessageChain(node, errorInfo)); + return resolveErrorCall(node); + } + return resolveCall(node, callSignatures, candidatesOutArray, headMessage); + } + // candidatesOutArray is passed by signature help in the language service, and collectCandidates + // must fill it up with the appropriate candidate signatures + function getResolvedSignature(node, candidatesOutArray) { + var links = getNodeLinks(node); + // If getResolvedSignature has already been called, we will have cached the resolvedSignature. + // However, it is possible that either candidatesOutArray was not passed in the first time, + // or that a different candidatesOutArray was passed in. Therefore, we need to redo the work + // to correctly fill the candidatesOutArray. + if (!links.resolvedSignature || candidatesOutArray) { + links.resolvedSignature = anySignature; + if (node.kind === 168 /* CallExpression */) { + links.resolvedSignature = resolveCallExpression(node, candidatesOutArray); + } + else if (node.kind === 169 /* NewExpression */) { + links.resolvedSignature = resolveNewExpression(node, candidatesOutArray); + } + else if (node.kind === 170 /* TaggedTemplateExpression */) { + links.resolvedSignature = resolveTaggedTemplateExpression(node, candidatesOutArray); + } + else if (node.kind === 139 /* Decorator */) { + links.resolvedSignature = resolveDecorator(node, candidatesOutArray); + } + else { + ts.Debug.fail("Branch in 'getResolvedSignature' should be unreachable."); + } + } + return links.resolvedSignature; + } + /** + * Syntactically and semantically checks a call or new expression. + * @param node The call/new expression to be checked. + * @returns On success, the expression's signature's return type. On failure, anyType. + */ + function checkCallExpression(node) { + // 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 */) { + return voidType; + } + if (node.kind === 169 /* NewExpression */) { + var declaration = signature.declaration; + if (declaration && + declaration.kind !== 144 /* Constructor */ && + declaration.kind !== 148 /* ConstructSignature */ && + declaration.kind !== 153 /* ConstructorType */) { + // When resolved signature is a call signature (and not a construct signature) the result type is any + if (compilerOptions.noImplicitAny) { + error(node, ts.Diagnostics.new_expression_whose_target_lacks_a_construct_signature_implicitly_has_an_any_type); + } + return anyType; + } + } + return getReturnTypeOfSignature(signature); + } + function checkTaggedTemplateExpression(node) { + return getReturnTypeOfSignature(getResolvedSignature(node)); + } + function checkAssertion(node) { + var exprType = getRegularTypeOfObjectLiteral(checkExpression(node.expression)); + var targetType = getTypeFromTypeNode(node.type); + if (produceDiagnostics && targetType !== unknownType) { + var widenedType = getWidenedType(exprType); + if (!(isTypeAssignableTo(targetType, widenedType))) { + checkTypeAssignableTo(exprType, targetType, node, ts.Diagnostics.Neither_type_0_nor_type_1_is_assignable_to_the_other); + } + } + return targetType; + } + function getTypeAtPosition(signature, pos) { + return signature.hasRestParameter ? + pos < signature.parameters.length - 1 ? getTypeOfSymbol(signature.parameters[pos]) : getRestTypeOfSignature(signature) : + pos < signature.parameters.length ? getTypeOfSymbol(signature.parameters[pos]) : anyType; + } + function assignContextualParameterTypes(signature, context, mapper) { + var len = signature.parameters.length - (signature.hasRestParameter ? 1 : 0); + for (var i = 0; i < len; i++) { + var parameter = signature.parameters[i]; + 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); + } + } + // When contextual typing assigns a type to a parameter that contains a binding pattern, we also need to push + // the destructured type into the contained binding elements. + function assignBindingElementTypes(node) { + if (ts.isBindingPattern(node.name)) { + for (var _i = 0, _a = node.name.elements; _i < _a.length; _i++) { + var element = _a[_i]; + if (element.kind !== 187 /* OmittedExpression */) { + if (element.name.kind === 69 /* Identifier */) { + getSymbolLinks(getSymbolOfNode(element)).type = getTypeForBindingElement(element); + } + assignBindingElementTypes(element); + } + } + } + } + function assignTypeToParameterAndFixTypeParameters(parameter, contextualType, mapper) { + var links = getSymbolLinks(parameter); + if (!links.type) { + links.type = instantiateType(contextualType, mapper); + assignBindingElementTypes(parameter.valueDeclaration); + } + else if (isInferentialContext(mapper)) { + // Even if the parameter already has a type, it might be because it was given a type while + // processing the function as an argument to a prior signature during overload resolution. + // If this was the case, it may have caused some type parameters to be fixed. So here, + // we need to ensure that type parameters at the same positions get fixed again. This is + // done by calling instantiateType to attach the mapper to the contextualType, and then + // calling inferTypes to force a walk of contextualType so that all the correct fixing + // happens. The choice to pass in links.type may seem kind of arbitrary, but it serves + // to make sure that all the correct positions in contextualType are reached by the walk. + // Here is an example: + // + // interface Base { + // baseProp; + // } + // interface Derived extends Base { + // toBase(): Base; + // } + // + // var derived: Derived; + // + // declare function foo(x: T, func: (p: T) => T): T; + // declare function foo(x: T, func: (p: T) => T): T; + // + // var result = foo(derived, d => d.toBase()); + // + // We are typing d while checking the second overload. But we've already given d + // a type (Derived) from the first overload. However, we still want to fix the + // T in the second overload so that we do not infer Base as a candidate for T + // (inferring Base would make type argument inference inconsistent between the two + // overloads). + inferTypes(mapper.context, links.type, instantiateType(contextualType, mapper)); + } + } + function createPromiseType(promisedType) { + // creates a `Promise` type where `T` is the promisedType argument + var globalPromiseType = getGlobalPromiseType(); + if (globalPromiseType !== emptyGenericType) { + // if the promised type is itself a promise, get the underlying type; otherwise, fallback to the promised type + promisedType = getAwaitedType(promisedType); + return createTypeReference(globalPromiseType, [promisedType]); + } + return emptyObjectType; + } + function getReturnTypeFromBody(func, contextualMapper) { + var contextualSignature = getContextualSignatureForFunctionLikeDeclaration(func); + if (!func.body) { + return unknownType; + } + var isAsync = ts.isAsyncFunctionLike(func); + var type; + if (func.body.kind !== 192 /* Block */) { + type = checkExpressionCached(func.body, contextualMapper); + if (isAsync) { + // From within an async function you can return either a non-promise value or a promise. Any + // Promise/A+ compatible implementation will always assimilate any foreign promise, so the + // return type of the body should be unwrapped to its awaited type, which we will wrap in + // the native Promise type later in this function. + type = checkAwaitedType(type, func, ts.Diagnostics.Return_expression_in_async_function_does_not_have_a_valid_callable_then_member); + } + } + else { + var types; + var funcIsGenerator = !!func.asteriskToken; + if (funcIsGenerator) { + types = checkAndAggregateYieldOperandTypes(func.body, contextualMapper); + if (types.length === 0) { + var iterableIteratorAny = createIterableIteratorType(anyType); + if (compilerOptions.noImplicitAny) { + error(func.asteriskToken, ts.Diagnostics.Generator_implicitly_has_type_0_because_it_does_not_yield_any_values_Consider_supplying_a_return_type, typeToString(iterableIteratorAny)); + } + return iterableIteratorAny; + } + } + else { + types = checkAndAggregateReturnExpressionTypes(func.body, contextualMapper, isAsync); + if (types.length === 0) { + if (isAsync) { + // For an async function, the return type will not be void, but rather a Promise for void. + var promiseType = createPromiseType(voidType); + if (promiseType === emptyObjectType) { + error(func, ts.Diagnostics.An_async_function_or_method_must_have_a_valid_awaitable_return_type); + return unknownType; + } + return promiseType; + } + else { + return voidType; + } + } + } + // When yield/return statements are contextually typed we allow the return type to be a union type. + // Otherwise we require the yield/return expressions to have a best common supertype. + type = contextualSignature ? getUnionType(types) : getCommonSupertype(types); + if (!type) { + if (funcIsGenerator) { + error(func, ts.Diagnostics.No_best_common_type_exists_among_yield_expressions); + return createIterableIteratorType(unknownType); + } + else { + error(func, ts.Diagnostics.No_best_common_type_exists_among_return_expressions); + return unknownType; + } + } + if (funcIsGenerator) { + type = createIterableIteratorType(type); + } + } + if (!contextualSignature) { + reportErrorsFromWidening(func, type); + } + var widenedType = getWidenedType(type); + if (isAsync) { + // From within an async function you can return either a non-promise value or a promise. Any + // Promise/A+ compatible implementation will always assimilate any foreign promise, so the + // return type of the body is awaited type of the body, wrapped in a native Promise type. + var promiseType = createPromiseType(widenedType); + if (promiseType === emptyObjectType) { + error(func, ts.Diagnostics.An_async_function_or_method_must_have_a_valid_awaitable_return_type); + return unknownType; + } + return promiseType; + } + else { + return widenedType; + } + } + function checkAndAggregateYieldOperandTypes(body, contextualMapper) { + var aggregatedTypes = []; + ts.forEachYieldExpression(body, function (yieldExpression) { + var expr = yieldExpression.expression; + if (expr) { + var type = checkExpressionCached(expr, contextualMapper); + if (yieldExpression.asteriskToken) { + // A yield* expression effectively yields everything that its operand yields + type = checkElementTypeOfIterable(type, yieldExpression.expression); + } + if (!ts.contains(aggregatedTypes, type)) { + aggregatedTypes.push(type); + } + } + }); + return aggregatedTypes; + } + function checkAndAggregateReturnExpressionTypes(body, contextualMapper, isAsync) { + var aggregatedTypes = []; + ts.forEachReturnStatement(body, function (returnStatement) { + var expr = returnStatement.expression; + if (expr) { + var type = checkExpressionCached(expr, contextualMapper); + if (isAsync) { + // From within an async function you can return either a non-promise value or a promise. Any + // Promise/A+ compatible implementation will always assimilate any foreign promise, so the + // return type of the body should be unwrapped to its awaited type, which should be wrapped in + // the native Promise type by the caller. + type = checkAwaitedType(type, body.parent, ts.Diagnostics.Return_expression_in_async_function_does_not_have_a_valid_callable_then_member); + } + if (!ts.contains(aggregatedTypes, type)) { + aggregatedTypes.push(type); + } + } + }); + return aggregatedTypes; + } + function bodyContainsAReturnStatement(funcBody) { + return ts.forEachReturnStatement(funcBody, function (returnStatement) { + return true; + }); + } + function bodyContainsSingleThrowStatement(body) { + return (body.statements.length === 1) && (body.statements[0].kind === 208 /* ThrowStatement */); + } + // TypeScript Specification 1.0 (6.3) - July 2014 + // An explicitly typed function whose return type isn't the Void or the Any type + // must have at least one return statement somewhere in its body. + // An exception to this rule is if the function implementation consists of a single 'throw' statement. + function checkIfNonVoidFunctionHasReturnExpressionsOrSingleThrowStatment(func, returnType) { + if (!produceDiagnostics) { + return; + } + // Functions that return 'void' or 'any' don't need any return expressions. + if (returnType === voidType || isTypeAny(returnType)) { + return; + } + // If all we have is a function signature, or an arrow function with an expression body, then there is nothing to check. + if (ts.nodeIsMissing(func.body) || func.body.kind !== 192 /* Block */) { + return; + } + var bodyBlock = func.body; + // Ensure the body has at least one return expression. + if (bodyContainsAReturnStatement(bodyBlock)) { + return; + } + // If there are no return expressions, then we need to check if + // the function body consists solely of a throw statement; + // this is to make an exception for unimplemented functions. + if (bodyContainsSingleThrowStatement(bodyBlock)) { + return; + } + // This function does not conform to the specification. + error(func.type, ts.Diagnostics.A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value_or_consist_of_a_single_throw_statement); + } + function checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper) { + ts.Debug.assert(node.kind !== 143 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + // Grammar checking + var hasGrammarError = checkGrammarFunctionLikeDeclaration(node); + if (!hasGrammarError && node.kind === 173 /* FunctionExpression */) { + checkGrammarForGenerator(node); + } + // The identityMapper object is used to indicate that function expressions are wildcards + if (contextualMapper === identityMapper && isContextSensitive(node)) { + return anyFunctionType; + } + var isAsync = ts.isAsyncFunctionLike(node); + if (isAsync) { + emitAwaiter = true; + } + var links = getNodeLinks(node); + var type = getTypeOfSymbol(node.symbol); + var contextSensitive = isContextSensitive(node); + var mightFixTypeParameters = contextSensitive && isInferentialContext(contextualMapper); + // Check if function expression is contextually typed and assign parameter types if so. + // See the comment in assignTypeToParameterAndFixTypeParameters to understand why we need to + // check mightFixTypeParameters. + if (mightFixTypeParameters || !(links.flags & 1024 /* ContextChecked */)) { + var contextualSignature = getContextualSignature(node); + // If a type check is started at a function expression that is an argument of a function call, obtaining the + // contextual type may recursively get back to here during overload resolution of the call. If so, we will have + // already assigned contextual types. + var contextChecked = !!(links.flags & 1024 /* ContextChecked */); + if (mightFixTypeParameters || !contextChecked) { + links.flags |= 1024 /* ContextChecked */; + if (contextualSignature) { + var signature = getSignaturesOfType(type, 0 /* Call */)[0]; + if (contextSensitive) { + assignContextualParameterTypes(signature, contextualSignature, contextualMapper || identityMapper); + } + if (mightFixTypeParameters || !node.type && !signature.resolvedReturnType) { + var returnType = getReturnTypeFromBody(node, contextualMapper); + if (!signature.resolvedReturnType) { + signature.resolvedReturnType = returnType; + } + } + } + if (!contextChecked) { + checkSignatureDeclaration(node); + } + } + } + if (produceDiagnostics && node.kind !== 143 /* MethodDeclaration */ && node.kind !== 142 /* MethodSignature */) { + checkCollisionWithCapturedSuperVariable(node, node.name); + checkCollisionWithCapturedThisVariable(node, node.name); + } + return type; + } + function checkFunctionExpressionOrObjectLiteralMethodBody(node) { + ts.Debug.assert(node.kind !== 143 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + var isAsync = ts.isAsyncFunctionLike(node); + if (isAsync) { + emitAwaiter = true; + } + var returnType = node.type && getTypeFromTypeNode(node.type); + var promisedType; + if (returnType && isAsync) { + promisedType = checkAsyncFunctionReturnType(node); + } + if (returnType && !node.asteriskToken) { + checkIfNonVoidFunctionHasReturnExpressionsOrSingleThrowStatment(node, isAsync ? promisedType : returnType); + } + if (node.body) { + if (!node.type) { + // There are some checks that are only performed in getReturnTypeFromBody, that may produce errors + // we need. An example is the noImplicitAny errors resulting from widening the return expression + // of a function. Because checking of function expression bodies is deferred, there was never an + // appropriate time to do this during the main walk of the file (see the comment at the top of + // checkFunctionExpressionBodies). So it must be done now. + getReturnTypeOfSignature(getSignatureFromDeclaration(node)); + } + if (node.body.kind === 192 /* Block */) { + checkSourceElement(node.body); + } + else { + // From within an async function you can return either a non-promise value or a promise. Any + // Promise/A+ compatible implementation will always assimilate any foreign promise, so we + // should not be checking assignability of a promise to the return type. Instead, we need to + // check assignability of the awaited type of the expression body against the promised type of + // its return type annotation. + var exprType = checkExpression(node.body); + if (returnType) { + if (isAsync) { + var awaitedType = checkAwaitedType(exprType, node.body, ts.Diagnostics.Expression_body_for_async_arrow_function_does_not_have_a_valid_callable_then_member); + checkTypeAssignableTo(awaitedType, promisedType, node.body); + } + else { + checkTypeAssignableTo(exprType, returnType, node.body); + } + } + checkFunctionAndClassExpressionBodies(node.body); + } + } + } + function checkArithmeticOperandType(operand, type, diagnostic) { + if (!isTypeAnyOrAllConstituentTypesHaveKind(type, 132 /* NumberLike */)) { + error(operand, diagnostic); + return false; + } + return true; + } + function checkReferenceExpression(n, invalidReferenceMessage, constantVariableMessage) { + function findSymbol(n) { + var symbol = getNodeLinks(n).resolvedSymbol; + // Because we got the symbol from the resolvedSymbol property, it might be of kind + // SymbolFlags.ExportValue. In this case it is necessary to get the actual export + // symbol, which will have the correct flags set on it. + return symbol && getExportSymbolOfValueSymbolIfExported(symbol); + } + function isReferenceOrErrorExpression(n) { + // TypeScript 1.0 spec (April 2014): + // Expressions are classified as values or references. + // References are the subset of expressions that are permitted as the target of an assignment. + // Specifically, references are combinations of identifiers(section 4.3), parentheses(section 4.7), + // and property accesses(section 4.10). + // All other expression constructs described in this chapter are classified as values. + switch (n.kind) { + case 69 /* Identifier */: { + var symbol = findSymbol(n); + // TypeScript 1.0 spec (April 2014): 4.3 + // An identifier expression that references a variable or parameter is classified as a reference. + // An identifier expression that references any other kind of entity is classified as a value(and therefore cannot be the target of an assignment). + return !symbol || symbol === unknownSymbol || symbol === argumentsSymbol || (symbol.flags & 3 /* Variable */) !== 0; + } + case 166 /* PropertyAccessExpression */: { + var symbol = findSymbol(n); + // TypeScript 1.0 spec (April 2014): 4.10 + // A property access expression is always classified as a reference. + // NOTE (not in spec): assignment to enum members should not be allowed + return !symbol || symbol === unknownSymbol || (symbol.flags & ~8 /* EnumMember */) !== 0; + } + case 167 /* ElementAccessExpression */: + // old compiler doesn't check indexed access + return true; + case 172 /* ParenthesizedExpression */: + return isReferenceOrErrorExpression(n.expression); + default: + return false; + } + } + function isConstVariableReference(n) { + switch (n.kind) { + case 69 /* Identifier */: + case 166 /* PropertyAccessExpression */: { + var symbol = findSymbol(n); + return symbol && (symbol.flags & 3 /* Variable */) !== 0 && (getDeclarationFlagsFromSymbol(symbol) & 32768 /* Const */) !== 0; + } + case 167 /* ElementAccessExpression */: { + var index = n.argumentExpression; + var symbol = findSymbol(n.expression); + if (symbol && index && index.kind === 9 /* StringLiteral */) { + var name_12 = index.text; + var prop = getPropertyOfType(getTypeOfSymbol(symbol), name_12); + return prop && (prop.flags & 3 /* Variable */) !== 0 && (getDeclarationFlagsFromSymbol(prop) & 32768 /* Const */) !== 0; + } + return false; + } + case 172 /* ParenthesizedExpression */: + return isConstVariableReference(n.expression); + default: + return false; + } + } + if (!isReferenceOrErrorExpression(n)) { + error(n, invalidReferenceMessage); + return false; + } + if (isConstVariableReference(n)) { + error(n, constantVariableMessage); + return false; + } + return true; + } + function checkDeleteExpression(node) { + checkExpression(node.expression); + return booleanType; + } + function checkTypeOfExpression(node) { + checkExpression(node.expression); + return stringType; + } + function checkVoidExpression(node) { + checkExpression(node.expression); + return undefinedType; + } + function checkAwaitExpression(node) { + // Grammar checking + if (produceDiagnostics) { + if (!(node.parserContextFlags & 8 /* Await */)) { + grammarErrorOnFirstToken(node, ts.Diagnostics.await_expression_is_only_allowed_within_an_async_function); + } + if (isInParameterInitializerBeforeContainingFunction(node)) { + error(node, ts.Diagnostics.await_expressions_cannot_be_used_in_a_parameter_initializer); + } + } + var operandType = checkExpression(node.expression); + return checkAwaitedType(operandType, node); + } + function checkPrefixUnaryExpression(node) { + var operandType = checkExpression(node.operand); + switch (node.operator) { + case 35 /* PlusToken */: + case 36 /* MinusToken */: + case 50 /* TildeToken */: + if (someConstituentTypeHasKind(operandType, 16777216 /* ESSymbol */)) { + error(node.operand, ts.Diagnostics.The_0_operator_cannot_be_applied_to_type_symbol, ts.tokenToString(node.operator)); + } + return numberType; + case 49 /* ExclamationToken */: + return booleanType; + case 41 /* PlusPlusToken */: + case 42 /* MinusMinusToken */: + var ok = checkArithmeticOperandType(node.operand, operandType, ts.Diagnostics.An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type); + if (ok) { + // run check only if former checks succeeded to avoid reporting cascading errors + 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); + } + return numberType; + } + return unknownType; + } + function checkPostfixUnaryExpression(node) { + var operandType = checkExpression(node.operand); + var ok = checkArithmeticOperandType(node.operand, operandType, ts.Diagnostics.An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type); + if (ok) { + // run check only if former checks succeeded to avoid reporting cascading errors + 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); + } + return numberType; + } + // Just like isTypeOfKind below, except that it returns true if *any* constituent + // has this kind. + function someConstituentTypeHasKind(type, kind) { + if (type.flags & kind) { + return true; + } + if (type.flags & 49152 /* UnionOrIntersection */) { + var types = type.types; + for (var _i = 0; _i < types.length; _i++) { + var current = types[_i]; + if (current.flags & kind) { + return true; + } + } + return false; + } + return false; + } + // Return true if type has the given flags, or is a union or intersection type composed of types that all have those flags. + function allConstituentTypesHaveKind(type, kind) { + if (type.flags & kind) { + return true; + } + if (type.flags & 49152 /* UnionOrIntersection */) { + var types = type.types; + for (var _i = 0; _i < types.length; _i++) { + var current = types[_i]; + if (!(current.flags & kind)) { + return false; + } + } + return true; + } + return false; + } + function isConstEnumObjectType(type) { + return type.flags & (80896 /* ObjectType */ | 65536 /* Anonymous */) && type.symbol && isConstEnumSymbol(type.symbol); + } + function isConstEnumSymbol(symbol) { + return (symbol.flags & 128 /* ConstEnum */) !== 0; + } + function checkInstanceOfExpression(left, right, leftType, rightType) { + // TypeScript 1.0 spec (April 2014): 4.15.4 + // The instanceof operator requires the left operand to be of type Any, an object type, or a type parameter type, + // and the right operand to be of type Any or a subtype of the 'Function' interface type. + // The result is always of the Boolean primitive type. + // NOTE: do not raise error if leftType is unknown as related error was already reported + if (allConstituentTypesHaveKind(leftType, 16777726 /* Primitive */)) { + error(left, ts.Diagnostics.The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_parameter); + } + // NOTE: do not raise error if right is unknown as related error was already reported + if (!(isTypeAny(rightType) || isTypeSubtypeOf(rightType, globalFunctionType))) { + error(right, ts.Diagnostics.The_right_hand_side_of_an_instanceof_expression_must_be_of_type_any_or_of_a_type_assignable_to_the_Function_interface_type); + } + return booleanType; + } + function checkInExpression(left, right, leftType, rightType) { + // TypeScript 1.0 spec (April 2014): 4.15.5 + // The in operator requires the left operand to be of type Any, the String primitive type, or the Number primitive type, + // and the right operand to be of type Any, an object type, or a type parameter type. + // The result is always of the Boolean primitive type. + if (!isTypeAnyOrAllConstituentTypesHaveKind(leftType, 258 /* StringLike */ | 132 /* NumberLike */ | 16777216 /* ESSymbol */)) { + error(left, ts.Diagnostics.The_left_hand_side_of_an_in_expression_must_be_of_type_any_string_number_or_symbol); + } + if (!isTypeAnyOrAllConstituentTypesHaveKind(rightType, 80896 /* ObjectType */ | 512 /* TypeParameter */)) { + error(right, ts.Diagnostics.The_right_hand_side_of_an_in_expression_must_be_of_type_any_an_object_type_or_a_type_parameter); + } + return booleanType; + } + function checkObjectLiteralAssignment(node, sourceType, contextualMapper) { + var properties = node.properties; + for (var _i = 0; _i < properties.length; _i++) { + var p = properties[_i]; + if (p.kind === 245 /* PropertyAssignment */ || p.kind === 246 /* ShorthandPropertyAssignment */) { + // TODO(andersh): Computed property support + var name_13 = p.name; + var type = isTypeAny(sourceType) + ? sourceType + : getTypeOfPropertyOfType(sourceType, name_13.text) || + isNumericLiteralName(name_13.text) && getIndexTypeOfType(sourceType, 1 /* Number */) || + getIndexTypeOfType(sourceType, 0 /* String */); + if (type) { + if (p.kind === 246 /* ShorthandPropertyAssignment */) { + checkDestructuringAssignment(p, type); + } + else { + checkDestructuringAssignment(p.initializer || name_13, type); + } + } + else { + error(name_13, ts.Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(sourceType), ts.declarationNameToString(name_13)); + } + } + else { + error(p, ts.Diagnostics.Property_assignment_expected); + } + } + return sourceType; + } + function checkArrayLiteralAssignment(node, sourceType, contextualMapper) { + // This elementType will be used if the specific property corresponding to this index is not + // present (aka the tuple element property). This call also checks that the parentType is in + // fact an iterable or array (depending on target language). + var elementType = checkIteratedTypeOrElementType(sourceType, node, /*allowStringInput*/ false) || unknownType; + var elements = node.elements; + for (var i = 0; i < elements.length; i++) { + var e = elements[i]; + if (e.kind !== 187 /* OmittedExpression */) { + if (e.kind !== 185 /* SpreadElementExpression */) { + var propName = "" + i; + var type = isTypeAny(sourceType) + ? sourceType + : isTupleLikeType(sourceType) + ? getTypeOfPropertyOfType(sourceType, propName) + : elementType; + if (type) { + checkDestructuringAssignment(e, type, contextualMapper); + } + else { + if (isTupleType(sourceType)) { + error(e, ts.Diagnostics.Tuple_type_0_with_length_1_cannot_be_assigned_to_tuple_with_length_2, typeToString(sourceType), sourceType.elementTypes.length, elements.length); + } + else { + error(e, ts.Diagnostics.Type_0_has_no_property_1, typeToString(sourceType), propName); + } + } + } + else { + if (i < elements.length - 1) { + error(e, ts.Diagnostics.A_rest_element_must_be_last_in_an_array_destructuring_pattern); + } + else { + var restExpression = e.expression; + if (restExpression.kind === 181 /* BinaryExpression */ && restExpression.operatorToken.kind === 56 /* EqualsToken */) { + error(restExpression.operatorToken, ts.Diagnostics.A_rest_element_cannot_have_an_initializer); + } + else { + checkDestructuringAssignment(restExpression, createArrayType(elementType), contextualMapper); + } + } + } + } + } + return sourceType; + } + function checkDestructuringAssignment(exprOrAssignment, sourceType, contextualMapper) { + var target; + if (exprOrAssignment.kind === 246 /* ShorthandPropertyAssignment */) { + var prop = exprOrAssignment; + if (prop.objectAssignmentInitializer) { + checkBinaryLikeExpression(prop.name, prop.equalsToken, prop.objectAssignmentInitializer, contextualMapper); + } + target = exprOrAssignment.name; + } + else { + target = exprOrAssignment; + } + if (target.kind === 181 /* BinaryExpression */ && target.operatorToken.kind === 56 /* EqualsToken */) { + checkBinaryExpression(target, contextualMapper); + target = target.left; + } + if (target.kind === 165 /* ObjectLiteralExpression */) { + return checkObjectLiteralAssignment(target, sourceType, contextualMapper); + } + if (target.kind === 164 /* ArrayLiteralExpression */) { + return checkArrayLiteralAssignment(target, sourceType, contextualMapper); + } + return checkReferenceAssignment(target, sourceType, contextualMapper); + } + function checkReferenceAssignment(target, sourceType, contextualMapper) { + var targetType = checkExpression(target, contextualMapper); + if (checkReferenceExpression(target, ts.Diagnostics.Invalid_left_hand_side_of_assignment_expression, ts.Diagnostics.Left_hand_side_of_assignment_expression_cannot_be_a_constant)) { + checkTypeAssignableTo(sourceType, targetType, target, /*headMessage*/ undefined); + } + return sourceType; + } + function checkBinaryExpression(node, contextualMapper) { + return checkBinaryLikeExpression(node.left, node.operatorToken, node.right, contextualMapper, node); + } + function checkBinaryLikeExpression(left, operatorToken, right, contextualMapper, errorNode) { + var operator = operatorToken.kind; + if (operator === 56 /* EqualsToken */ && (left.kind === 165 /* ObjectLiteralExpression */ || left.kind === 164 /* ArrayLiteralExpression */)) { + return checkDestructuringAssignment(left, checkExpression(right, contextualMapper), contextualMapper); + } + var leftType = checkExpression(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 */: + // TypeScript 1.0 spec (April 2014): 4.19.1 + // These operators require their operands to be of type Any, the Number primitive type, + // or an enum type. Operands of an enum type are treated + // as having the primitive type Number. If one operand is the null or undefined value, + // it is treated as having the type of the other operand. + // The result is always of the Number primitive type. + if (leftType.flags & (32 /* Undefined */ | 64 /* Null */)) + leftType = rightType; + if (rightType.flags & (32 /* Undefined */ | 64 /* Null */)) + rightType = leftType; + var suggestedOperator; + // if a user tries to apply a bitwise operator to 2 boolean operands + // try and return them a helpful suggestion + if ((leftType.flags & 8 /* Boolean */) && + (rightType.flags & 8 /* Boolean */) && + (suggestedOperator = getSuggestedBooleanOperator(operatorToken.kind)) !== undefined) { + error(errorNode || operatorToken, ts.Diagnostics.The_0_operator_is_not_allowed_for_boolean_types_Consider_using_1_instead, ts.tokenToString(operatorToken.kind), ts.tokenToString(suggestedOperator)); + } + else { + // otherwise just check each operand separately and report errors as normal + var leftOk = checkArithmeticOperandType(left, leftType, ts.Diagnostics.The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type); + var rightOk = checkArithmeticOperandType(right, rightType, ts.Diagnostics.The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type); + if (leftOk && rightOk) { + checkAssignmentOperator(numberType); + } + } + return numberType; + case 35 /* PlusToken */: + case 57 /* PlusEqualsToken */: + // TypeScript 1.0 spec (April 2014): 4.19.2 + // The binary + operator requires both operands to be of the Number primitive type or an enum type, + // or at least one of the operands to be of type Any or the String primitive type. + // If one operand is the null or undefined value, it is treated as having the type of the other operand. + if (leftType.flags & (32 /* Undefined */ | 64 /* Null */)) + leftType = rightType; + if (rightType.flags & (32 /* Undefined */ | 64 /* Null */)) + rightType = leftType; + var resultType; + if (allConstituentTypesHaveKind(leftType, 132 /* NumberLike */) && allConstituentTypesHaveKind(rightType, 132 /* NumberLike */)) { + // Operands of an enum type are treated as having the primitive type Number. + // If both operands are of the Number primitive type, the result is of the Number primitive type. + resultType = numberType; + } + else { + if (allConstituentTypesHaveKind(leftType, 258 /* StringLike */) || allConstituentTypesHaveKind(rightType, 258 /* StringLike */)) { + // If one or both operands are of the String primitive type, the result is of the String primitive type. + resultType = stringType; + } + else if (isTypeAny(leftType) || isTypeAny(rightType)) { + // Otherwise, the result is of type Any. + // NOTE: unknown type here denotes error type. Old compiler treated this case as any type so do we. + resultType = leftType === unknownType || rightType === unknownType ? unknownType : anyType; + } + // Symbols are not allowed at all in arithmetic expressions + if (resultType && !checkForDisallowedESSymbolOperand(operator)) { + return resultType; + } + } + if (!resultType) { + reportOperatorError(); + return anyType; + } + if (operator === 57 /* PlusEqualsToken */) { + checkAssignmentOperator(resultType); + } + return resultType; + case 25 /* LessThanToken */: + case 27 /* GreaterThanToken */: + case 28 /* LessThanEqualsToken */: + case 29 /* GreaterThanEqualsToken */: + if (!checkForDisallowedESSymbolOperand(operator)) { + return booleanType; + } + // Fall through + case 30 /* EqualsEqualsToken */: + case 31 /* ExclamationEqualsToken */: + case 32 /* EqualsEqualsEqualsToken */: + case 33 /* ExclamationEqualsEqualsToken */: + if (!isTypeAssignableTo(leftType, rightType) && !isTypeAssignableTo(rightType, leftType)) { + reportOperatorError(); + } + return booleanType; + case 91 /* InstanceOfKeyword */: + return checkInstanceOfExpression(left, right, leftType, rightType); + case 90 /* InKeyword */: + return checkInExpression(left, right, leftType, rightType); + case 51 /* AmpersandAmpersandToken */: + return rightType; + case 52 /* BarBarToken */: + return getUnionType([leftType, rightType]); + case 56 /* EqualsToken */: + checkAssignmentOperator(rightType); + return getRegularTypeOfObjectLiteral(rightType); + case 24 /* CommaToken */: + return rightType; + } + // Return true if there was no error, false if there was an error. + function checkForDisallowedESSymbolOperand(operator) { + var offendingSymbolOperand = someConstituentTypeHasKind(leftType, 16777216 /* ESSymbol */) ? left : + someConstituentTypeHasKind(rightType, 16777216 /* ESSymbol */) ? right : + undefined; + if (offendingSymbolOperand) { + error(offendingSymbolOperand, ts.Diagnostics.The_0_operator_cannot_be_applied_to_type_symbol, ts.tokenToString(operator)); + return false; + } + return true; + } + 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 */; + default: + return undefined; + } + } + function checkAssignmentOperator(valueType) { + if (produceDiagnostics && operator >= 56 /* FirstAssignment */ && operator <= 68 /* LastAssignment */) { + // TypeScript 1.0 spec (April 2014): 4.17 + // An assignment of the form + // VarExpr = ValueExpr + // requires VarExpr to be classified as a reference + // A compound assignment furthermore requires VarExpr to be classified as a reference (section 4.1) + // and the type of the non - compound operation to be assignable to the type of VarExpr. + var ok = checkReferenceExpression(left, ts.Diagnostics.Invalid_left_hand_side_of_assignment_expression, ts.Diagnostics.Left_hand_side_of_assignment_expression_cannot_be_a_constant); + // Use default messages + if (ok) { + // to avoid cascading errors check assignability only if 'isReference' check succeeded and no errors were reported + checkTypeAssignableTo(valueType, leftType, left, /*headMessage*/ undefined); + } + } + } + function reportOperatorError() { + error(errorNode || operatorToken, ts.Diagnostics.Operator_0_cannot_be_applied_to_types_1_and_2, ts.tokenToString(operatorToken.kind), typeToString(leftType), typeToString(rightType)); + } + } + function isYieldExpressionInClass(node) { + var current = node; + var parent = node.parent; + while (parent) { + if (ts.isFunctionLike(parent) && current === parent.body) { + return false; + } + else if (ts.isClassLike(current)) { + return true; + } + current = parent; + parent = parent.parent; + } + return false; + } + function checkYieldExpression(node) { + // Grammar checking + if (produceDiagnostics) { + if (!(node.parserContextFlags & 2 /* Yield */) || isYieldExpressionInClass(node)) { + grammarErrorOnFirstToken(node, ts.Diagnostics.A_yield_expression_is_only_allowed_in_a_generator_body); + } + if (isInParameterInitializerBeforeContainingFunction(node)) { + error(node, ts.Diagnostics.yield_expressions_cannot_be_used_in_a_parameter_initializer); + } + } + if (node.expression) { + var func = ts.getContainingFunction(node); + // If the user's code is syntactically correct, the func should always have a star. After all, + // we are in a yield context. + if (func && func.asteriskToken) { + var expressionType = checkExpressionCached(node.expression, /*contextualMapper*/ undefined); + var expressionElementType; + var nodeIsYieldStar = !!node.asteriskToken; + if (nodeIsYieldStar) { + expressionElementType = checkElementTypeOfIterable(expressionType, node.expression); + } + // There is no point in doing an assignability check if the function + // has no explicit return type because the return type is directly computed + // from the yield expressions. + if (func.type) { + var signatureElementType = getElementTypeOfIterableIterator(getTypeFromTypeNode(func.type)) || anyType; + if (nodeIsYieldStar) { + checkTypeAssignableTo(expressionElementType, signatureElementType, node.expression, /*headMessage*/ undefined); + } + else { + checkTypeAssignableTo(expressionType, signatureElementType, node.expression, /*headMessage*/ undefined); + } + } + } + } + // Both yield and yield* expressions have type 'any' + return anyType; + } + function checkConditionalExpression(node, contextualMapper) { + checkExpression(node.condition); + var type1 = checkExpression(node.whenTrue, contextualMapper); + var type2 = checkExpression(node.whenFalse, contextualMapper); + return getUnionType([type1, type2]); + } + function checkTemplateExpression(node) { + // We just want to check each expressions, but we are unconcerned with + // the type of each expression, as any value may be coerced into a string. + // It is worth asking whether this is what we really want though. + // A place where we actually *are* concerned with the expressions' types are + // in tagged templates. + ts.forEach(node.templateSpans, function (templateSpan) { + checkExpression(templateSpan.expression); + }); + return stringType; + } + function checkExpressionWithContextualType(node, contextualType, contextualMapper) { + var saveContextualType = node.contextualType; + node.contextualType = contextualType; + var result = checkExpression(node, contextualMapper); + node.contextualType = saveContextualType; + return result; + } + function checkExpressionCached(node, contextualMapper) { + var links = getNodeLinks(node); + if (!links.resolvedType) { + links.resolvedType = checkExpression(node, contextualMapper); + } + return links.resolvedType; + } + function checkPropertyAssignment(node, contextualMapper) { + // 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 === 136 /* ComputedPropertyName */) { + checkComputedPropertyName(node.name); + } + return checkExpression(node.initializer, contextualMapper); + } + function checkObjectLiteralMethod(node, contextualMapper) { + // Grammar checking + checkGrammarMethod(node); + // 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 === 136 /* ComputedPropertyName */) { + checkComputedPropertyName(node.name); + } + var uninstantiatedType = checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); + return instantiateTypeWithSingleGenericCallSignature(node, uninstantiatedType, contextualMapper); + } + function instantiateTypeWithSingleGenericCallSignature(node, type, contextualMapper) { + if (isInferentialContext(contextualMapper)) { + var signature = getSingleCallSignature(type); + if (signature && signature.typeParameters) { + var contextualType = getContextualType(node); + if (contextualType) { + var contextualSignature = getSingleCallSignature(contextualType); + if (contextualSignature && !contextualSignature.typeParameters) { + return getOrCreateTypeFromSignature(instantiateSignatureInContextOf(signature, contextualSignature, contextualMapper)); + } + } + } + } + return type; + } + // Checks an expression and returns its type. The contextualMapper parameter serves two purposes: When + // contextualMapper is not undefined and not equal to the identityMapper function object it indicates that the + // expression is being inferentially typed (section 4.12.2 in spec) and provides the type mapper to use in + // conjunction with the generic contextual type. When contextualMapper is equal to the identityMapper function + // object, it serves as an indicator that all contained function and arrow expressions should be considered to + // have the wildcard function type; this form of type check is used during overload resolution to exclude + // contextually typed function and arrow expressions in the initial phase. + function checkExpression(node, contextualMapper) { + var type; + if (node.kind === 135 /* QualifiedName */) { + type = checkQualifiedName(node); + } + else { + var uninstantiatedType = checkExpressionWorker(node, contextualMapper); + type = instantiateTypeWithSingleGenericCallSignature(node, uninstantiatedType, contextualMapper); + } + if (isConstEnumObjectType(type)) { + // enum object type for const enums are only permitted in: + // - 'left' in property access + // - 'object' in indexed access + // - target in rhs of import statement + var ok = (node.parent.kind === 166 /* PropertyAccessExpression */ && node.parent.expression === node) || + (node.parent.kind === 167 /* ElementAccessExpression */ && node.parent.expression === node) || + ((node.kind === 69 /* Identifier */ || node.kind === 135 /* QualifiedName */) && isInRightSideOfImportOrExportAssignment(node)); + if (!ok) { + error(node, ts.Diagnostics.const_enums_can_only_be_used_in_property_or_index_access_expressions_or_the_right_hand_side_of_an_import_declaration_or_export_assignment); + } + } + return type; + } + function checkNumericLiteral(node) { + // Grammar checking + checkGrammarNumericLiteral(node); + return numberType; + } + function checkExpressionWorker(node, contextualMapper) { + switch (node.kind) { + case 69 /* Identifier */: + return checkIdentifier(node); + case 97 /* ThisKeyword */: + return checkThisExpression(node); + case 95 /* SuperKeyword */: + return checkSuperExpression(node); + case 93 /* NullKeyword */: + return nullType; + case 99 /* TrueKeyword */: + case 84 /* FalseKeyword */: + return booleanType; + case 8 /* NumericLiteral */: + return checkNumericLiteral(node); + case 183 /* TemplateExpression */: + return checkTemplateExpression(node); + case 9 /* StringLiteral */: + case 11 /* NoSubstitutionTemplateLiteral */: + return stringType; + case 10 /* RegularExpressionLiteral */: + return globalRegExpType; + case 164 /* ArrayLiteralExpression */: + return checkArrayLiteral(node, contextualMapper); + case 165 /* ObjectLiteralExpression */: + return checkObjectLiteral(node, contextualMapper); + case 166 /* PropertyAccessExpression */: + return checkPropertyAccessExpression(node); + case 167 /* ElementAccessExpression */: + return checkIndexedAccess(node); + case 168 /* CallExpression */: + case 169 /* NewExpression */: + return checkCallExpression(node); + case 170 /* TaggedTemplateExpression */: + return checkTaggedTemplateExpression(node); + case 172 /* ParenthesizedExpression */: + return checkExpression(node.expression, contextualMapper); + case 186 /* ClassExpression */: + return checkClassExpression(node); + case 173 /* FunctionExpression */: + case 174 /* ArrowFunction */: + return checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); + case 176 /* TypeOfExpression */: + return checkTypeOfExpression(node); + case 171 /* TypeAssertionExpression */: + case 189 /* AsExpression */: + return checkAssertion(node); + case 175 /* DeleteExpression */: + return checkDeleteExpression(node); + case 177 /* VoidExpression */: + return checkVoidExpression(node); + case 178 /* AwaitExpression */: + return checkAwaitExpression(node); + case 179 /* PrefixUnaryExpression */: + return checkPrefixUnaryExpression(node); + case 180 /* PostfixUnaryExpression */: + return checkPostfixUnaryExpression(node); + case 181 /* BinaryExpression */: + return checkBinaryExpression(node, contextualMapper); + case 182 /* ConditionalExpression */: + return checkConditionalExpression(node, contextualMapper); + case 185 /* SpreadElementExpression */: + return checkSpreadElementExpression(node, contextualMapper); + case 187 /* OmittedExpression */: + return undefinedType; + case 184 /* YieldExpression */: + return checkYieldExpression(node); + case 240 /* JsxExpression */: + return checkJsxExpression(node); + case 233 /* JsxElement */: + return checkJsxElement(node); + case 234 /* JsxSelfClosingElement */: + return checkJsxSelfClosingElement(node); + case 235 /* JsxOpeningElement */: + ts.Debug.fail("Shouldn't ever directly check a JsxOpeningElement"); + } + return unknownType; + } + // DECLARATION AND STATEMENT TYPE CHECKING + function checkTypeParameter(node) { + // Grammar Checking + if (node.expression) { + grammarErrorOnFirstToken(node.expression, ts.Diagnostics.Type_expected); + } + checkSourceElement(node.constraint); + if (produceDiagnostics) { + checkTypeParameterHasIllegalReferencesInConstraint(node); + checkTypeNameIsReserved(node.name, ts.Diagnostics.Type_parameter_name_cannot_be_0); + } + // TODO: Check multiple declarations are identical + } + function checkParameter(node) { + // Grammar checking + // It is a SyntaxError if the Identifier "eval" or the Identifier "arguments" occurs as the + // Identifier in a PropertySetParameterList of a PropertyAssignment that is contained in strict code + // or if its FunctionBody is strict code(11.1.5). + // Grammar checking + checkGrammarDecorators(node) || checkGrammarModifiers(node); + checkVariableLikeDeclaration(node); + var func = ts.getContainingFunction(node); + if (node.flags & 112 /* AccessibilityModifier */) { + func = ts.getContainingFunction(node); + if (!(func.kind === 144 /* Constructor */ && ts.nodeIsPresent(func.body))) { + error(node, ts.Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation); + } + } + if (node.questionToken && ts.isBindingPattern(node.name) && func.body) { + error(node, ts.Diagnostics.A_binding_pattern_parameter_cannot_be_optional_in_an_implementation_signature); + } + // Only check rest parameter type if it's not a binding pattern. Since binding patterns are + // not allowed in a rest parameter, we already have an error from checkGrammarParameterList. + if (node.dotDotDotToken && !ts.isBindingPattern(node.name) && !isArrayType(getTypeOfSymbol(node.symbol))) { + error(node, ts.Diagnostics.A_rest_parameter_must_be_of_an_array_type); + } + } + function isSyntacticallyValidGenerator(node) { + if (!node.asteriskToken || !node.body) { + return false; + } + return node.kind === 143 /* MethodDeclaration */ || + node.kind === 213 /* FunctionDeclaration */ || + node.kind === 173 /* FunctionExpression */; + } + function getTypePredicateParameterIndex(parameterList, parameter) { + if (parameterList) { + for (var i = 0; i < parameterList.length; i++) { + var param = parameterList[i]; + if (param.name.kind === 69 /* Identifier */ && + param.name.text === parameter.text) { + return i; + } + } + } + return -1; + } + function isInLegalTypePredicatePosition(node) { + switch (node.parent.kind) { + case 174 /* ArrowFunction */: + case 147 /* CallSignature */: + case 213 /* FunctionDeclaration */: + case 173 /* FunctionExpression */: + case 152 /* FunctionType */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: + return node === node.parent.type; + } + return false; + } + function checkSignatureDeclaration(node) { + // Grammar checking + if (node.kind === 149 /* IndexSignature */) { + checkGrammarIndexSignature(node); + } + else if (node.kind === 152 /* FunctionType */ || node.kind === 213 /* FunctionDeclaration */ || node.kind === 153 /* ConstructorType */ || + node.kind === 147 /* CallSignature */ || node.kind === 144 /* Constructor */ || + node.kind === 148 /* ConstructSignature */) { + checkGrammarFunctionLikeDeclaration(node); + } + checkTypeParameters(node.typeParameters); + ts.forEach(node.parameters, checkParameter); + if (node.type) { + if (node.type.kind === 150 /* TypePredicate */) { + var typePredicate = getSignatureFromDeclaration(node).typePredicate; + var typePredicateNode = node.type; + if (isInLegalTypePredicatePosition(typePredicateNode)) { + if (typePredicate.parameterIndex >= 0) { + if (node.parameters[typePredicate.parameterIndex].dotDotDotToken) { + error(typePredicateNode.parameterName, ts.Diagnostics.A_type_predicate_cannot_reference_a_rest_parameter); + } + else { + checkTypeAssignableTo(typePredicate.type, getTypeOfNode(node.parameters[typePredicate.parameterIndex]), typePredicateNode.type); + } + } + else if (typePredicateNode.parameterName) { + var hasReportedError = false; + for (var _i = 0, _a = node.parameters; _i < _a.length; _i++) { + var param = _a[_i]; + if (hasReportedError) { + break; + } + if (param.name.kind === 161 /* ObjectBindingPattern */ || + param.name.kind === 162 /* ArrayBindingPattern */) { + (function checkBindingPattern(pattern) { + for (var _i = 0, _a = pattern.elements; _i < _a.length; _i++) { + var element = _a[_i]; + if (element.name.kind === 69 /* Identifier */ && + element.name.text === typePredicate.parameterName) { + error(typePredicateNode.parameterName, ts.Diagnostics.A_type_predicate_cannot_reference_element_0_in_a_binding_pattern, typePredicate.parameterName); + hasReportedError = true; + break; + } + else if (element.name.kind === 162 /* ArrayBindingPattern */ || + element.name.kind === 161 /* ObjectBindingPattern */) { + checkBindingPattern(element.name); + } + } + })(param.name); + } + } + if (!hasReportedError) { + error(typePredicateNode.parameterName, ts.Diagnostics.Cannot_find_parameter_0, typePredicate.parameterName); + } + } + } + else { + error(typePredicateNode, ts.Diagnostics.A_type_predicate_is_only_allowed_in_return_type_position_for_functions_and_methods); + } + } + else { + checkSourceElement(node.type); + } + } + if (produceDiagnostics) { + checkCollisionWithArgumentsInGeneratedCode(node); + if (compilerOptions.noImplicitAny && !node.type) { + switch (node.kind) { + case 148 /* ConstructSignature */: + error(node, ts.Diagnostics.Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); + break; + case 147 /* 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)) { + var returnType = getTypeFromTypeNode(node.type); + if (returnType === voidType) { + error(node.type, ts.Diagnostics.A_generator_cannot_have_a_void_type_annotation); + } + else { + var generatorElementType = getElementTypeOfIterableIterator(returnType) || anyType; + var iterableIteratorInstantiation = createIterableIteratorType(generatorElementType); + // Naively, one could check that IterableIterator is assignable to the return type annotation. + // However, that would not catch the error in the following case. + // + // interface BadGenerator extends Iterable, Iterator { } + // function* g(): BadGenerator { } // Iterable and Iterator have different types! + // + checkTypeAssignableTo(iterableIteratorInstantiation, returnType, node.type); + } + } + } + } + checkSpecializedSignatureDeclaration(node); + } + function checkTypeForDuplicateIndexSignatures(node) { + if (node.kind === 215 /* InterfaceDeclaration */) { + var nodeSymbol = getSymbolOfNode(node); + // in case of merging interface declaration it is possible that we'll enter this check procedure several times for every declaration + // to prevent this run check only for the first declaration of a given kind + if (nodeSymbol.declarations.length > 0 && nodeSymbol.declarations[0] !== node) { + return; + } + } + // TypeScript 1.0 spec (April 2014) + // 3.7.4: An object type can contain at most one string index signature and one numeric index signature. + // 8.5: A class declaration can have at most one string index member declaration and one numeric index member declaration + var indexSymbol = getIndexSymbol(getSymbolOfNode(node)); + if (indexSymbol) { + var seenNumericIndexer = false; + var seenStringIndexer = false; + for (var _i = 0, _a = indexSymbol.declarations; _i < _a.length; _i++) { + var decl = _a[_i]; + var declaration = decl; + if (declaration.parameters.length === 1 && declaration.parameters[0].type) { + switch (declaration.parameters[0].type.kind) { + case 130 /* StringKeyword */: + if (!seenStringIndexer) { + seenStringIndexer = true; + } + else { + error(declaration, ts.Diagnostics.Duplicate_string_index_signature); + } + break; + case 128 /* NumberKeyword */: + if (!seenNumericIndexer) { + seenNumericIndexer = true; + } + else { + error(declaration, ts.Diagnostics.Duplicate_number_index_signature); + } + break; + } + } + } + } + } + function checkPropertyDeclaration(node) { + // Grammar checking + checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarProperty(node) || checkGrammarComputedPropertyName(node.name); + checkVariableLikeDeclaration(node); + } + function checkMethodDeclaration(node) { + // Grammar checking + checkGrammarMethod(node) || checkGrammarComputedPropertyName(node.name); + // Grammar checking for modifiers is done inside the function checkGrammarFunctionLikeDeclaration + checkFunctionLikeDeclaration(node); + // Abstract methods cannot have an implementation. + // Extra checks are to avoid reporting multiple errors relating to the "abstractness" of the node. + if (node.flags & 256 /* Abstract */ && node.body) { + error(node, ts.Diagnostics.Method_0_cannot_have_an_implementation_because_it_is_marked_abstract, ts.declarationNameToString(node.name)); + } + } + function checkConstructorDeclaration(node) { + // Grammar check on signature of constructor and modifier of the constructor is done in checkSignatureDeclaration function. + checkSignatureDeclaration(node); + // Grammar check for checking only related to constructoDeclaration + checkGrammarConstructorTypeParameters(node) || checkGrammarConstructorTypeAnnotation(node); + checkSourceElement(node.body); + var symbol = getSymbolOfNode(node); + var firstDeclaration = ts.getDeclarationOfKind(symbol, node.kind); + // Only type check the symbol once + if (node === firstDeclaration) { + checkFunctionOrConstructorSymbol(symbol); + } + // exit early in the case of signature - super checks are not relevant to them + if (ts.nodeIsMissing(node.body)) { + return; + } + if (!produceDiagnostics) { + return; + } + function isSuperCallExpression(n) { + return n.kind === 168 /* CallExpression */ && n.expression.kind === 95 /* SuperKeyword */; + } + function containsSuperCallAsComputedPropertyName(n) { + return n.name && containsSuperCall(n.name); + } + function containsSuperCall(n) { + if (isSuperCallExpression(n)) { + return true; + } + else if (ts.isFunctionLike(n)) { + return false; + } + else if (ts.isClassLike(n)) { + return ts.forEach(n.members, containsSuperCallAsComputedPropertyName); + } + return ts.forEachChild(n, containsSuperCall); + } + function markThisReferencesAsErrors(n) { + if (n.kind === 97 /* ThisKeyword */) { + error(n, ts.Diagnostics.this_cannot_be_referenced_in_current_location); + } + else if (n.kind !== 173 /* FunctionExpression */ && n.kind !== 213 /* FunctionDeclaration */) { + ts.forEachChild(n, markThisReferencesAsErrors); + } + } + function isInstancePropertyWithInitializer(n) { + return n.kind === 141 /* PropertyDeclaration */ && + !(n.flags & 128 /* Static */) && + !!n.initializer; + } + // TS 1.0 spec (April 2014): 8.3.2 + // Constructors of classes with no extends clause may not contain super calls, whereas + // constructors of derived classes must contain at least one super call somewhere in their function body. + var containingClassDecl = node.parent; + if (ts.getClassExtendsHeritageClauseElement(containingClassDecl)) { + var containingClassSymbol = getSymbolOfNode(containingClassDecl); + var containingClassInstanceType = getDeclaredTypeOfSymbol(containingClassSymbol); + var baseConstructorType = getBaseConstructorTypeOfClass(containingClassInstanceType); + if (containsSuperCall(node.body)) { + if (baseConstructorType === nullType) { + error(node, ts.Diagnostics.A_constructor_cannot_contain_a_super_call_when_its_class_extends_null); + } + // The first statement in the body of a constructor (excluding prologue directives) must be a super call + // if both of the following are true: + // - The containing class is a derived class. + // - The constructor declares parameter properties + // or the containing class declares instance member variables with initializers. + var superCallShouldBeFirst = ts.forEach(node.parent.members, isInstancePropertyWithInitializer) || + ts.forEach(node.parameters, function (p) { return p.flags & (16 /* Public */ | 32 /* Private */ | 64 /* Protected */); }); + // Skip past any prologue directives to find the first statement + // to ensure that it was a super call. + if (superCallShouldBeFirst) { + var statements = node.body.statements; + var superCallStatement; + for (var _i = 0; _i < statements.length; _i++) { + var statement = statements[_i]; + if (statement.kind === 195 /* ExpressionStatement */ && isSuperCallExpression(statement.expression)) { + superCallStatement = statement; + break; + } + if (!ts.isPrologueDirective(statement)) { + break; + } + } + if (!superCallStatement) { + error(node, ts.Diagnostics.A_super_call_must_be_the_first_statement_in_the_constructor_when_a_class_contains_initialized_properties_or_has_parameter_properties); + } + else { + // In such a required super call, it is a compile-time error for argument expressions to reference this. + markThisReferencesAsErrors(superCallStatement.expression); + } + } + } + else if (baseConstructorType !== nullType) { + error(node, ts.Diagnostics.Constructors_for_derived_classes_must_contain_a_super_call); + } + } + } + function checkAccessorDeclaration(node) { + if (produceDiagnostics) { + // Grammar checking accessors + checkGrammarFunctionLikeDeclaration(node) || checkGrammarAccessor(node) || checkGrammarComputedPropertyName(node.name); + if (node.kind === 145 /* GetAccessor */) { + if (!ts.isInAmbientContext(node) && ts.nodeIsPresent(node.body) && !(bodyContainsAReturnStatement(node.body) || bodyContainsSingleThrowStatement(node.body))) { + error(node.name, ts.Diagnostics.A_get_accessor_must_return_a_value_or_consist_of_a_single_throw_statement); + } + } + 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 === 145 /* GetAccessor */ ? 146 /* SetAccessor */ : 145 /* GetAccessor */; + var otherAccessor = ts.getDeclarationOfKind(node.symbol, otherKind); + if (otherAccessor) { + if (((node.flags & 112 /* AccessibilityModifier */) !== (otherAccessor.flags & 112 /* AccessibilityModifier */))) { + error(node.name, ts.Diagnostics.Getter_and_setter_accessors_do_not_agree_in_visibility); + } + var currentAccessorType = getAnnotatedAccessorType(node); + var otherAccessorType = getAnnotatedAccessorType(otherAccessor); + // TypeScript 1.0 spec (April 2014): 4.5 + // If both accessors include type annotations, the specified types must be identical. + if (currentAccessorType && otherAccessorType) { + if (!isTypeIdenticalTo(currentAccessorType, otherAccessorType)) { + error(node, ts.Diagnostics.get_and_set_accessor_must_have_the_same_type); + } + } + } + } + getTypeOfAccessors(getSymbolOfNode(node)); + } + checkFunctionLikeDeclaration(node); + } + function checkMissingDeclaration(node) { + checkDecorators(node); + } + function checkTypeArgumentConstraints(typeParameters, typeArguments) { + var result = true; + for (var i = 0; i < typeParameters.length; i++) { + var constraint = getConstraintOfTypeParameter(typeParameters[i]); + if (constraint) { + var typeArgument = typeArguments[i]; + result = result && checkTypeAssignableTo(getTypeFromTypeNode(typeArgument), constraint, typeArgument, ts.Diagnostics.Type_0_does_not_satisfy_the_constraint_1); + } + } + return result; + } + function checkTypeReferenceNode(node) { + checkGrammarTypeArguments(node, node.typeArguments); + var type = getTypeFromTypeReference(node); + if (type !== unknownType && node.typeArguments) { + // Do type argument local checks only if referenced type is successfully resolved + ts.forEach(node.typeArguments, checkSourceElement); + if (produceDiagnostics) { + var symbol = getNodeLinks(node).resolvedSymbol; + var typeParameters = symbol.flags & 524288 /* TypeAlias */ ? getSymbolLinks(symbol).typeParameters : type.target.localTypeParameters; + checkTypeArgumentConstraints(typeParameters, node.typeArguments); + } + } + } + function checkTypeQuery(node) { + getTypeFromTypeQueryNode(node); + } + function checkTypeLiteral(node) { + ts.forEach(node.members, checkSourceElement); + if (produceDiagnostics) { + var type = getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node); + checkIndexConstraints(type); + checkTypeForDuplicateIndexSignatures(node); + } + } + function checkArrayType(node) { + checkSourceElement(node.elementType); + } + function checkTupleType(node) { + // Grammar checking + var hasErrorFromDisallowedTrailingComma = checkGrammarForDisallowedTrailingComma(node.elementTypes); + if (!hasErrorFromDisallowedTrailingComma && node.elementTypes.length === 0) { + grammarErrorOnNode(node, ts.Diagnostics.A_tuple_type_element_list_cannot_be_empty); + } + ts.forEach(node.elementTypes, checkSourceElement); + } + function checkUnionOrIntersectionType(node) { + ts.forEach(node.types, checkSourceElement); + } + function isPrivateWithinAmbient(node) { + return (node.flags & 32 /* Private */) && ts.isInAmbientContext(node); + } + function checkSpecializedSignatureDeclaration(signatureDeclarationNode) { + if (!produceDiagnostics) { + return; + } + var signature = getSignatureFromDeclaration(signatureDeclarationNode); + if (!signature.hasStringLiterals) { + return; + } + // TypeScript 1.0 spec (April 2014): 3.7.2.2 + // Specialized signatures are not permitted in conjunction with a function body + if (ts.nodeIsPresent(signatureDeclarationNode.body)) { + error(signatureDeclarationNode, ts.Diagnostics.A_signature_with_an_implementation_cannot_use_a_string_literal_type); + return; + } + // TypeScript 1.0 spec (April 2014): 3.7.2.4 + // Every specialized call or construct signature in an object type must be assignable + // to at least one non-specialized call or construct signature in the same object type + var signaturesToCheck; + // Unnamed (call\construct) signatures in interfaces are inherited and not shadowed so examining just node symbol won't give complete answer. + // Use declaring type to obtain full list of signatures. + if (!signatureDeclarationNode.name && signatureDeclarationNode.parent && signatureDeclarationNode.parent.kind === 215 /* InterfaceDeclaration */) { + ts.Debug.assert(signatureDeclarationNode.kind === 147 /* CallSignature */ || signatureDeclarationNode.kind === 148 /* ConstructSignature */); + var signatureKind = signatureDeclarationNode.kind === 147 /* CallSignature */ ? 0 /* Call */ : 1 /* Construct */; + var containingSymbol = getSymbolOfNode(signatureDeclarationNode.parent); + var containingType = getDeclaredTypeOfSymbol(containingSymbol); + signaturesToCheck = getSignaturesOfType(containingType, signatureKind); + } + else { + signaturesToCheck = getSignaturesOfSymbol(getSymbolOfNode(signatureDeclarationNode)); + } + for (var _i = 0; _i < signaturesToCheck.length; _i++) { + var otherSignature = signaturesToCheck[_i]; + if (!otherSignature.hasStringLiterals && isSignatureAssignableTo(signature, otherSignature)) { + return; + } + } + error(signatureDeclarationNode, ts.Diagnostics.Specialized_overload_signature_is_not_assignable_to_any_non_specialized_signature); + } + function getEffectiveDeclarationFlags(n, flagsToCheck) { + var flags = ts.getCombinedNodeFlags(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 !== 215 /* InterfaceDeclaration */ && + n.parent.kind !== 214 /* ClassDeclaration */ && + n.parent.kind !== 186 /* ClassExpression */ && + ts.isInAmbientContext(n)) { + if (!(flags & 2 /* Ambient */)) { + // It is nested in an ambient context, which means it is automatically exported + flags |= 1 /* Export */; + } + flags |= 2 /* Ambient */; + } + return flags & flagsToCheck; + } + function checkFunctionOrConstructorSymbol(symbol) { + if (!produceDiagnostics) { + return; + } + function getCanonicalOverload(overloads, implementation) { + // Consider the canonical set of flags to be the flags of the bodyDeclaration or the first declaration + // Error on all deviations from this canonical set of flags + // The caveat is that if some overloads are defined in lib.d.ts, we don't want to + // report the errors on those. To achieve this, we will say that the implementation is + // the canonical signature only if it is in the same container as the first overload + var implementationSharesContainerWithFirstOverload = implementation !== undefined && implementation.parent === overloads[0].parent; + return implementationSharesContainerWithFirstOverload ? implementation : overloads[0]; + } + function checkFlagAgreementBetweenOverloads(overloads, implementation, flagsToCheck, someOverloadFlags, allOverloadFlags) { + // Error if some overloads have a flag that is not shared by all overloads. To find the + // deviations, we XOR someOverloadFlags with allOverloadFlags + var someButNotAllOverloadFlags = someOverloadFlags ^ allOverloadFlags; + if (someButNotAllOverloadFlags !== 0) { + var canonicalFlags = getEffectiveDeclarationFlags(getCanonicalOverload(overloads, implementation), flagsToCheck); + ts.forEach(overloads, function (o) { + var deviation = getEffectiveDeclarationFlags(o, flagsToCheck) ^ canonicalFlags; + if (deviation & 1 /* Export */) { + error(o.name, ts.Diagnostics.Overload_signatures_must_all_be_exported_or_not_exported); + } + else if (deviation & 2 /* Ambient */) { + error(o.name, ts.Diagnostics.Overload_signatures_must_all_be_ambient_or_non_ambient); + } + else if (deviation & (32 /* Private */ | 64 /* Protected */)) { + error(o.name, ts.Diagnostics.Overload_signatures_must_all_be_public_private_or_protected); + } + else if (deviation & 256 /* Abstract */) { + error(o.name, ts.Diagnostics.Overload_signatures_must_all_be_abstract_or_not_abstract); + } + }); + } + } + function checkQuestionTokenAgreementBetweenOverloads(overloads, implementation, someHaveQuestionToken, allHaveQuestionToken) { + if (someHaveQuestionToken !== allHaveQuestionToken) { + var canonicalHasQuestionToken = ts.hasQuestionToken(getCanonicalOverload(overloads, implementation)); + ts.forEach(overloads, function (o) { + var deviation = ts.hasQuestionToken(o) !== canonicalHasQuestionToken; + if (deviation) { + error(o.name, ts.Diagnostics.Overload_signatures_must_all_be_optional_or_required); + } + }); + } + } + var flagsToCheck = 1 /* Export */ | 2 /* Ambient */ | 32 /* Private */ | 64 /* Protected */ | 256 /* Abstract */; + var someNodeFlags = 0; + var allNodeFlags = flagsToCheck; + var someHaveQuestionToken = false; + var allHaveQuestionToken = true; + var hasOverloads = false; + var bodyDeclaration; + var lastSeenNonAmbientDeclaration; + var previousDeclaration; + var declarations = symbol.declarations; + var isConstructor = (symbol.flags & 16384 /* Constructor */) !== 0; + function reportImplementationExpectedError(node) { + if (node.name && ts.nodeIsMissing(node.name)) { + return; + } + var seen = false; + var subsequentNode = ts.forEachChild(node.parent, function (c) { + if (seen) { + return c; + } + else { + seen = c === node; + } + }); + if (subsequentNode) { + if (subsequentNode.kind === node.kind) { + 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) { + // the only situation when this is possible (same kind\same name but different symbol) - mixed static and instance class members + ts.Debug.assert(node.kind === 143 /* MethodDeclaration */ || node.kind === 142 /* MethodSignature */); + ts.Debug.assert((node.flags & 128 /* Static */) !== (subsequentNode.flags & 128 /* Static */)); + var diagnostic = node.flags & 128 /* Static */ ? ts.Diagnostics.Function_overload_must_be_static : ts.Diagnostics.Function_overload_must_not_be_static; + error(errorNode_1, diagnostic); + return; + } + else if (ts.nodeIsPresent(subsequentNode.body)) { + error(errorNode_1, ts.Diagnostics.Function_implementation_name_must_be_0, ts.declarationNameToString(node.name)); + return; + } + } + } + var errorNode = node.name || node; + if (isConstructor) { + error(errorNode, ts.Diagnostics.Constructor_implementation_is_missing); + } + else { + // Report different errors regarding non-consecutive blocks of declarations depending on whether + // the node in question is abstract. + if (node.flags & 256 /* Abstract */) { + error(errorNode, ts.Diagnostics.All_declarations_of_an_abstract_method_must_be_consecutive); + } + else { + error(errorNode, ts.Diagnostics.Function_implementation_is_missing_or_not_immediately_following_the_declaration); + } + } + } + // when checking exported function declarations across modules check only duplicate implementations + // names and consistency of modifiers are verified when we check local symbol + var isExportSymbolInsideModule = symbol.parent && symbol.parent.flags & 1536 /* Module */; + var duplicateFunctionDeclaration = false; + var multipleConstructorImplementation = false; + for (var _i = 0; _i < declarations.length; _i++) { + var current = declarations[_i]; + var node = current; + var inAmbientContext = ts.isInAmbientContext(node); + var inAmbientContextOrInterface = node.parent.kind === 215 /* InterfaceDeclaration */ || node.parent.kind === 155 /* TypeLiteral */ || inAmbientContext; + if (inAmbientContextOrInterface) { + // check if declarations are consecutive only if they are non-ambient + // 1. ambient declarations can be interleaved + // i.e. this is legal + // declare function foo(); + // declare function bar(); + // declare function foo(); + // 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 === 213 /* FunctionDeclaration */ || node.kind === 143 /* MethodDeclaration */ || node.kind === 142 /* MethodSignature */ || node.kind === 144 /* Constructor */) { + var currentNodeFlags = getEffectiveDeclarationFlags(node, flagsToCheck); + someNodeFlags |= currentNodeFlags; + allNodeFlags &= currentNodeFlags; + someHaveQuestionToken = someHaveQuestionToken || ts.hasQuestionToken(node); + allHaveQuestionToken = allHaveQuestionToken && ts.hasQuestionToken(node); + if (ts.nodeIsPresent(node.body) && bodyDeclaration) { + if (isConstructor) { + multipleConstructorImplementation = true; + } + else { + duplicateFunctionDeclaration = true; + } + } + else if (!isExportSymbolInsideModule && previousDeclaration && previousDeclaration.parent === node.parent && previousDeclaration.end !== node.pos) { + reportImplementationExpectedError(previousDeclaration); + } + if (ts.nodeIsPresent(node.body)) { + if (!bodyDeclaration) { + bodyDeclaration = node; + } + } + else { + hasOverloads = true; + } + previousDeclaration = node; + if (!inAmbientContextOrInterface) { + lastSeenNonAmbientDeclaration = node; + } + } + } + if (multipleConstructorImplementation) { + ts.forEach(declarations, function (declaration) { + error(declaration, ts.Diagnostics.Multiple_constructor_implementations_are_not_allowed); + }); + } + if (duplicateFunctionDeclaration) { + ts.forEach(declarations, function (declaration) { + error(declaration.name, ts.Diagnostics.Duplicate_function_implementation); + }); + } + // Abstract methods can't have an implementation -- in particular, they don't need one. + if (!isExportSymbolInsideModule && lastSeenNonAmbientDeclaration && !lastSeenNonAmbientDeclaration.body && + !(lastSeenNonAmbientDeclaration.flags & 256 /* Abstract */)) { + reportImplementationExpectedError(lastSeenNonAmbientDeclaration); + } + if (hasOverloads) { + checkFlagAgreementBetweenOverloads(declarations, bodyDeclaration, flagsToCheck, someNodeFlags, allNodeFlags); + checkQuestionTokenAgreementBetweenOverloads(declarations, bodyDeclaration, someHaveQuestionToken, allHaveQuestionToken); + if (bodyDeclaration) { + var signatures = getSignaturesOfSymbol(symbol); + var bodySignature = getSignatureFromDeclaration(bodyDeclaration); + // If the implementation signature has string literals, we will have reported an error in + // checkSpecializedSignatureDeclaration + if (!bodySignature.hasStringLiterals) { + // TypeScript 1.0 spec (April 2014): 6.1 + // If a function declaration includes overloads, the overloads determine the call + // signatures of the type given to the function object + // and the function implementation signature must be assignable to that type + // + // TypeScript 1.0 spec (April 2014): 3.8.4 + // Note that specialized call and construct signatures (section 3.7.2.4) are not significant when determining assignment compatibility + // Consider checking against specialized signatures too. Not doing so creates a type hole: + // + // function g(x: "hi", y: boolean); + // function g(x: string, y: {}); + // function g(x: string, y: string) { } + // + // The implementation is completely unrelated to the specialized signature, yet we do not check this. + for (var _a = 0; _a < signatures.length; _a++) { + var signature = signatures[_a]; + if (!signature.hasStringLiterals && !isSignatureAssignableTo(bodySignature, signature)) { + error(signature.declaration, ts.Diagnostics.Overload_signature_is_not_compatible_with_function_implementation); + break; + } + } + } + } + } + } + function checkExportsOnMergedDeclarations(node) { + if (!produceDiagnostics) { + return; + } + // if localSymbol is defined on node then node itself is exported - check is required + var symbol = node.localSymbol; + if (!symbol) { + // local symbol is undefined => this declaration is non-exported. + // however symbol might contain other declarations that are exported + symbol = getSymbolOfNode(node); + if (!(symbol.flags & 7340032 /* Export */)) { + // this is a pure local symbol (all declarations are non-exported) - no need to check anything + return; + } + } + // run the check only for the first declaration in the list + if (ts.getDeclarationOfKind(symbol, node.kind) !== node) { + return; + } + // we use SymbolFlags.ExportValue, SymbolFlags.ExportType and SymbolFlags.ExportNamespace + // to denote disjoint declarationSpaces (without making new enum type). + var exportedDeclarationSpaces = 0 /* None */; + var nonExportedDeclarationSpaces = 0 /* None */; + var defaultExportedDeclarationSpaces = 0 /* None */; + for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { + var d = _a[_i]; + var declarationSpaces = getDeclarationSpaces(d); + var effectiveDeclarationFlags = getEffectiveDeclarationFlags(d, 1 /* Export */ | 1024 /* Default */); + if (effectiveDeclarationFlags & 1 /* Export */) { + if (effectiveDeclarationFlags & 1024 /* Default */) { + defaultExportedDeclarationSpaces |= declarationSpaces; + } + else { + exportedDeclarationSpaces |= declarationSpaces; + } + } + else { + nonExportedDeclarationSpaces |= declarationSpaces; + } + } + // Spaces for anyting not declared a 'default export'. + var nonDefaultExportedDeclarationSpaces = exportedDeclarationSpaces | nonExportedDeclarationSpaces; + var commonDeclarationSpacesForExportsAndLocals = exportedDeclarationSpaces & nonExportedDeclarationSpaces; + var commonDeclarationSpacesForDefaultAndNonDefault = defaultExportedDeclarationSpaces & nonDefaultExportedDeclarationSpaces; + if (commonDeclarationSpacesForExportsAndLocals || commonDeclarationSpacesForDefaultAndNonDefault) { + // declaration spaces for exported and non-exported declarations intersect + for (var _b = 0, _c = symbol.declarations; _b < _c.length; _b++) { + var d = _c[_b]; + var declarationSpaces = getDeclarationSpaces(d); + // Only error on the declarations that conributed to the intersecting spaces. + if (declarationSpaces & commonDeclarationSpacesForDefaultAndNonDefault) { + error(d.name, ts.Diagnostics.Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_default_0_declaration_instead, ts.declarationNameToString(d.name)); + } + else if (declarationSpaces & commonDeclarationSpacesForExportsAndLocals) { + error(d.name, ts.Diagnostics.Individual_declarations_in_merged_declaration_0_must_be_all_exported_or_all_local, ts.declarationNameToString(d.name)); + } + } + } + function getDeclarationSpaces(d) { + switch (d.kind) { + case 215 /* InterfaceDeclaration */: + return 2097152 /* ExportType */; + case 218 /* ModuleDeclaration */: + return d.name.kind === 9 /* StringLiteral */ || ts.getModuleInstanceState(d) !== 0 /* NonInstantiated */ + ? 4194304 /* ExportNamespace */ | 1048576 /* ExportValue */ + : 4194304 /* ExportNamespace */; + case 214 /* ClassDeclaration */: + case 217 /* EnumDeclaration */: + return 2097152 /* ExportType */ | 1048576 /* ExportValue */; + case 221 /* ImportEqualsDeclaration */: + var result = 0; + var target = resolveAlias(getSymbolOfNode(d)); + ts.forEach(target.declarations, function (d) { result |= getDeclarationSpaces(d); }); + return result; + default: + return 1048576 /* ExportValue */; + } + } + } + function checkNonThenableType(type, location, message) { + type = getWidenedType(type); + if (!isTypeAny(type) && isTypeAssignableTo(type, getGlobalThenableType())) { + if (location) { + if (!message) { + message = ts.Diagnostics.Operand_for_await_does_not_have_a_valid_callable_then_member; + } + error(location, message); + } + return unknownType; + } + return type; + } + /** + * Gets the "promised type" of a promise. + * @param type The type of the promise. + * @remarks The "promised type" of a type is the type of the "value" parameter of the "onfulfilled" callback. + */ + function getPromisedType(promise) { + // + // { // promise + // then( // thenFunction + // onfulfilled: ( // onfulfilledParameterType + // value: T // valueParameterType + // ) => any + // ): any; + // } + // + if (promise.flags & 1 /* Any */) { + return undefined; + } + if ((promise.flags & 4096 /* Reference */) && promise.target === tryGetGlobalPromiseType()) { + return promise.typeArguments[0]; + } + var globalPromiseLikeType = getInstantiatedGlobalPromiseLikeType(); + if (globalPromiseLikeType === emptyObjectType || !isTypeAssignableTo(promise, globalPromiseLikeType)) { + return undefined; + } + var thenFunction = getTypeOfPropertyOfType(promise, "then"); + if (thenFunction && (thenFunction.flags & 1 /* Any */)) { + return undefined; + } + var thenSignatures = thenFunction ? getSignaturesOfType(thenFunction, 0 /* Call */) : emptyArray; + if (thenSignatures.length === 0) { + return undefined; + } + var onfulfilledParameterType = getUnionType(ts.map(thenSignatures, getTypeOfFirstParameterOfSignature)); + if (onfulfilledParameterType.flags & 1 /* Any */) { + return undefined; + } + var onfulfilledParameterSignatures = getSignaturesOfType(onfulfilledParameterType, 0 /* Call */); + if (onfulfilledParameterSignatures.length === 0) { + return undefined; + } + var valueParameterType = getUnionType(ts.map(onfulfilledParameterSignatures, getTypeOfFirstParameterOfSignature)); + return valueParameterType; + } + function getTypeOfFirstParameterOfSignature(signature) { + return getTypeAtPosition(signature, 0); + } + /** + * Gets the "awaited type" of a type. + * @param type The type to await. + * @remarks The "awaited type" of an expression is its "promised type" if the expression is a + * Promise-like type; otherwise, it is the type of the expression. This is used to reflect + * The runtime behavior of the `await` keyword. + */ + function getAwaitedType(type) { + return checkAwaitedType(type, /*location*/ undefined, /*message*/ undefined); + } + function checkAwaitedType(type, location, message) { + return checkAwaitedTypeWorker(type); + function checkAwaitedTypeWorker(type) { + if (type.flags & 16384 /* Union */) { + var types = []; + for (var _i = 0, _a = type.types; _i < _a.length; _i++) { + var constituentType = _a[_i]; + types.push(checkAwaitedTypeWorker(constituentType)); + } + return getUnionType(types); + } + else { + var promisedType = getPromisedType(type); + if (promisedType === undefined) { + // The type was not a PromiseLike, so it could not be unwrapped any further. + // As long as the type does not have a callable "then" property, it is + // safe to return the type; otherwise, an error will have been reported in + // the call to checkNonThenableType and we will return unknownType. + // + // An example of a non-promise "thenable" might be: + // + // await { then(): void {} } + // + // The "thenable" does not match the minimal definition for a PromiseLike. When + // a Promise/A+-compatible or ES6 promise tries to adopt this value, the promise + // will never settle. We treat this as an error to help flag an early indicator + // of a runtime problem. If the user wants to return this value from an async + // function, they would need to wrap it in some other value. If they want it to + // be treated as a promise, they can cast to . + return checkNonThenableType(type, location, message); + } + else { + if (type.id === promisedType.id || awaitedTypeStack.indexOf(promisedType.id) >= 0) { + // We have a bad actor in the form of a promise whose promised type is + // the same promise type, or a mutually recursive promise. Return the + // unknown type as we cannot guess the shape. If this were the actual + // case in the JavaScript, this Promise would never resolve. + // + // An example of a bad actor with a singly-recursive promise type might + // be: + // + // interface BadPromise { + // then( + // onfulfilled: (value: BadPromise) => any, + // onrejected: (error: any) => any): BadPromise; + // } + // + // The above interface will pass the PromiseLike check, and return a + // promised type of `BadPromise`. Since this is a self reference, we + // don't want to keep recursing ad infinitum. + // + // An example of a bad actor in the form of a mutually-recursive + // promise type might be: + // + // interface BadPromiseA { + // then( + // onfulfilled: (value: BadPromiseB) => any, + // onrejected: (error: any) => any): BadPromiseB; + // } + // + // interface BadPromiseB { + // then( + // onfulfilled: (value: BadPromiseA) => any, + // onrejected: (error: any) => any): BadPromiseA; + // } + // + if (location) { + error(location, ts.Diagnostics._0_is_referenced_directly_or_indirectly_in_the_fulfillment_callback_of_its_own_then_method, symbolToString(type.symbol)); + } + return unknownType; + } + // Keep track of the type we're about to unwrap to avoid bad recursive promise types. + // See the comments above for more information. + awaitedTypeStack.push(type.id); + var awaitedType = checkAwaitedTypeWorker(promisedType); + awaitedTypeStack.pop(); + return awaitedType; + } + } + } + } + /** + * Checks the return type of an async function to ensure it is a compatible + * Promise implementation. + * @param node The signature to check + * @param returnType The return type for the function + * @remarks + * This checks that an async function has a valid Promise-compatible return type, + * and returns the *awaited type* of the promise. An async function has a valid + * Promise-compatible return type if the resolved value of the return type has a + * construct signature that takes in an `initializer` function that in turn supplies + * a `resolve` function as one of its arguments and results in an object with a + * callable `then` signature. + */ + function checkAsyncFunctionReturnType(node) { + var globalPromiseConstructorLikeType = getGlobalPromiseConstructorLikeType(); + if (globalPromiseConstructorLikeType === emptyObjectType) { + // If we couldn't resolve the global PromiseConstructorLike type we cannot verify + // compatibility with __awaiter. + return unknownType; + } + // As part of our emit for an async function, we will need to emit the entity name of + // the return type annotation as an expression. To meet the necessary runtime semantics + // for __awaiter, we must also check that the type of the declaration (e.g. the static + // side or "constructor" of the promise type) is compatible `PromiseConstructorLike`. + // + // An example might be (from lib.es6.d.ts): + // + // interface Promise { ... } + // interface PromiseConstructor { + // new (...): Promise; + // } + // declare var Promise: PromiseConstructor; + // + // When an async function declares a return type annotation of `Promise`, we + // need to get the type of the `Promise` variable declaration above, which would + // be `PromiseConstructor`. + // + // The same case applies to a class: + // + // declare class Promise { + // constructor(...); + // then(...): Promise; + // } + // + // When we get the type of the `Promise` symbol here, we get the type of the static + // side of the `Promise` class, which would be `{ new (...): Promise }`. + var promiseType = getTypeFromTypeNode(node.type); + if (promiseType === unknownType && compilerOptions.isolatedModules) { + // If we are compiling with isolatedModules, we may not be able to resolve the + // type as a value. As such, we will just return unknownType; + return unknownType; + } + var promiseConstructor = getMergedSymbol(promiseType.symbol); + if (!promiseConstructor || !symbolIsValue(promiseConstructor)) { + error(node, ts.Diagnostics.Type_0_is_not_a_valid_async_function_return_type, typeToString(promiseType)); + return unknownType; + } + // Validate the promise constructor type. + var promiseConstructorType = getTypeOfSymbol(promiseConstructor); + if (!checkTypeAssignableTo(promiseConstructorType, globalPromiseConstructorLikeType, node, ts.Diagnostics.Type_0_is_not_a_valid_async_function_return_type)) { + return unknownType; + } + // Verify there is no local declaration that could collide with the promise constructor. + var promiseName = ts.getEntityNameFromTypeNode(node.type); + var root = getFirstIdentifier(promiseName); + var rootSymbol = getSymbol(node.locals, root.text, 107455 /* Value */); + if (rootSymbol) { + error(rootSymbol.valueDeclaration, ts.Diagnostics.Duplicate_identifier_0_Compiler_uses_declaration_1_to_support_async_functions, root.text, getFullyQualifiedName(promiseConstructor)); + return unknownType; + } + // Get and return the awaited type of the return type. + return checkAwaitedType(promiseType, node, ts.Diagnostics.An_async_function_or_method_must_have_a_valid_awaitable_return_type); + } + /** Check a decorator */ + function checkDecorator(node) { + var signature = getResolvedSignature(node); + var returnType = getReturnTypeOfSignature(signature); + if (returnType.flags & 1 /* Any */) { + return; + } + var expectedReturnType; + var headMessage = getDiagnosticHeadMessageForDecoratorResolution(node); + var errorInfo; + switch (node.parent.kind) { + case 214 /* ClassDeclaration */: + var classSymbol = getSymbolOfNode(node.parent); + var classConstructorType = getTypeOfSymbol(classSymbol); + expectedReturnType = getUnionType([classConstructorType, voidType]); + break; + case 138 /* Parameter */: + expectedReturnType = voidType; + errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.The_return_type_of_a_parameter_decorator_function_must_be_either_void_or_any); + break; + case 141 /* PropertyDeclaration */: + expectedReturnType = voidType; + errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.The_return_type_of_a_property_decorator_function_must_be_either_void_or_any); + break; + case 143 /* MethodDeclaration */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: + var methodType = getTypeOfNode(node.parent); + var descriptorType = createTypedPropertyDescriptorType(methodType); + expectedReturnType = getUnionType([descriptorType, voidType]); + break; + } + checkTypeAssignableTo(returnType, expectedReturnType, node, headMessage, errorInfo); + } + /** Checks a type reference node as an expression. */ + function checkTypeNodeAsExpression(node) { + // 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 === 151 /* TypeReference */) { + var root = getFirstIdentifier(node.typeName); + var meaning = root.parent.kind === 151 /* TypeReference */ ? 793056 /* Type */ : 1536 /* Namespace */; + // Resolve type so we know which symbol is referenced + var rootSymbol = resolveName(root, root.text, meaning | 8388608 /* Alias */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined); + // Resolved symbol is alias + if (rootSymbol && rootSymbol.flags & 8388608 /* Alias */) { + var aliasTarget = resolveAlias(rootSymbol); + // If alias has value symbol - mark alias as referenced + if (aliasTarget.flags & 107455 /* Value */ && !isConstEnumOrConstEnumOnlyModule(resolveAlias(rootSymbol))) { + markAliasSymbolAsReferenced(rootSymbol); + } + } + } + } + /** + * Checks the type annotation of an accessor declaration or property declaration as + * an expression if it is a type reference to a type with a value declaration. + */ + function checkTypeAnnotationAsExpression(node) { + switch (node.kind) { + case 141 /* PropertyDeclaration */: + checkTypeNodeAsExpression(node.type); + break; + case 138 /* Parameter */: + checkTypeNodeAsExpression(node.type); + break; + case 143 /* MethodDeclaration */: + checkTypeNodeAsExpression(node.type); + break; + case 145 /* GetAccessor */: + checkTypeNodeAsExpression(node.type); + break; + case 146 /* SetAccessor */: + checkTypeNodeAsExpression(ts.getSetAccessorTypeAnnotationNode(node)); + break; + } + } + /** Checks the type annotation of the parameters of a function/method or the constructor of a class as expressions */ + function checkParameterTypeAnnotationsAsExpressions(node) { + // ensure all type annotations with a value declaration are checked as an expression + for (var _i = 0, _a = node.parameters; _i < _a.length; _i++) { + var parameter = _a[_i]; + checkTypeAnnotationAsExpression(parameter); + } + } + /** Check the decorators of a node */ + function checkDecorators(node) { + if (!node.decorators) { + return; + } + // skip this check for nodes that cannot have decorators. These should have already had an error reported by + // checkGrammarDecorators. + if (!ts.nodeCanBeDecorated(node)) { + return; + } + if (!compilerOptions.experimentalDecorators) { + error(node, ts.Diagnostics.Experimental_support_for_decorators_is_a_feature_that_is_subject_to_change_in_a_future_release_Specify_experimentalDecorators_to_remove_this_warning); + } + 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 214 /* ClassDeclaration */: + var constructor = ts.getFirstConstructorWithBody(node); + if (constructor) { + checkParameterTypeAnnotationsAsExpressions(constructor); + } + break; + case 143 /* MethodDeclaration */: + checkParameterTypeAnnotationsAsExpressions(node); + // fall-through + case 146 /* SetAccessor */: + case 145 /* GetAccessor */: + case 141 /* PropertyDeclaration */: + case 138 /* Parameter */: + checkTypeAnnotationAsExpression(node); + break; + } + } + emitDecorate = true; + if (node.kind === 138 /* Parameter */) { + emitParam = true; + } + ts.forEach(node.decorators, checkDecorator); + } + function checkFunctionDeclaration(node) { + if (produceDiagnostics) { + checkFunctionLikeDeclaration(node) || checkGrammarForGenerator(node); + checkCollisionWithCapturedSuperVariable(node, node.name); + checkCollisionWithCapturedThisVariable(node, node.name); + checkCollisionWithRequireExportsInGeneratedCode(node, node.name); + } + } + function checkFunctionLikeDeclaration(node) { + checkDecorators(node); + checkSignatureDeclaration(node); + var isAsync = ts.isAsyncFunctionLike(node); + if (isAsync) { + emitAwaiter = true; + } + // Do not use hasDynamicName here, because that returns false for well known symbols. + // We want to perform checkComputedPropertyName for all computed properties, including + // well known symbols. + if (node.name && node.name.kind === 136 /* ComputedPropertyName */) { + // This check will account for methods in class/interface declarations, + // as well as accessors in classes/object literals + checkComputedPropertyName(node.name); + } + if (!ts.hasDynamicName(node)) { + // first we want to check the local symbol that contain this declaration + // - if node.localSymbol !== undefined - this is current declaration is exported and localSymbol points to the local symbol + // - if node.localSymbol === undefined - this node is non-exported so we can just pick the result of getSymbolOfNode + var symbol = getSymbolOfNode(node); + var localSymbol = node.localSymbol || symbol; + var firstDeclaration = ts.getDeclarationOfKind(localSymbol, node.kind); + // Only type check the symbol once + if (node === firstDeclaration) { + checkFunctionOrConstructorSymbol(localSymbol); + } + if (symbol.parent) { + // run check once for the first declaration + if (ts.getDeclarationOfKind(symbol, node.kind) === node) { + // run check on export symbol to check that modifiers agree across all exported declarations + checkFunctionOrConstructorSymbol(symbol); + } + } + } + checkSourceElement(node.body); + if (node.type && !isAccessor(node.kind) && !node.asteriskToken) { + var returnType = getTypeFromTypeNode(node.type); + var promisedType; + if (isAsync) { + promisedType = checkAsyncFunctionReturnType(node); + } + checkIfNonVoidFunctionHasReturnExpressionsOrSingleThrowStatment(node, isAsync ? promisedType : returnType); + } + if (produceDiagnostics && !node.type) { + // Report an implicit any error if there is no body, no explicit return type, and node is not a private method + // in an ambient context + if (compilerOptions.noImplicitAny && ts.nodeIsMissing(node.body) && !isPrivateWithinAmbient(node)) { + reportImplicitAnyError(node, anyType); + } + if (node.asteriskToken && ts.nodeIsPresent(node.body)) { + // A generator with a body and no type annotation can still cause errors. It can error if the + // yielded values have no common supertype, or it can give an implicit any error if it has no + // yielded values. The only way to trigger these errors is to try checking its return type. + getReturnTypeOfSignature(getSignatureFromDeclaration(node)); + } + } + } + function checkBlock(node) { + // Grammar checking for SyntaxKind.Block + if (node.kind === 192 /* Block */) { + checkGrammarStatementInAmbientContext(node); + } + ts.forEach(node.statements, checkSourceElement); + if (ts.isFunctionBlock(node) || node.kind === 219 /* ModuleBlock */) { + checkFunctionAndClassExpressionBodies(node); + } + } + function checkCollisionWithArgumentsInGeneratedCode(node) { + // no rest parameters \ declaration context \ overload - no codegen impact + if (!ts.hasRestParameter(node) || ts.isInAmbientContext(node) || ts.nodeIsMissing(node.body)) { + return; + } + ts.forEach(node.parameters, function (p) { + if (p.name && !ts.isBindingPattern(p.name) && p.name.text === argumentsSymbol.name) { + error(p, ts.Diagnostics.Duplicate_identifier_arguments_Compiler_uses_arguments_to_initialize_rest_parameters); + } + }); + } + function needCollisionCheckForIdentifier(node, identifier, name) { + if (!(identifier && identifier.text === name)) { + return false; + } + if (node.kind === 141 /* PropertyDeclaration */ || + node.kind === 140 /* PropertySignature */ || + node.kind === 143 /* MethodDeclaration */ || + node.kind === 142 /* MethodSignature */ || + node.kind === 145 /* GetAccessor */ || + node.kind === 146 /* SetAccessor */) { + // it is ok to have member named '_super' or '_this' - member access is always qualified + return false; + } + if (ts.isInAmbientContext(node)) { + // ambient context - no codegen impact + return false; + } + var root = ts.getRootDeclaration(node); + if (root.kind === 138 /* Parameter */ && ts.nodeIsMissing(root.parent.body)) { + // just an overload - no codegen impact + return false; + } + return true; + } + function checkCollisionWithCapturedThisVariable(node, name) { + if (needCollisionCheckForIdentifier(node, name, "_this")) { + potentialThisCollisions.push(node); + } + } + // this function will run after checking the source file so 'CaptureThis' is correct for all nodes + function checkIfThisIsCapturedInEnclosingScope(node) { + var current = node; + while (current) { + if (getNodeCheckFlags(current) & 4 /* CaptureThis */) { + var isDeclaration_1 = node.kind !== 69 /* Identifier */; + if (isDeclaration_1) { + error(node.name, ts.Diagnostics.Duplicate_identifier_this_Compiler_uses_variable_declaration_this_to_capture_this_reference); + } + else { + error(node, ts.Diagnostics.Expression_resolves_to_variable_declaration_this_that_compiler_uses_to_capture_this_reference); + } + return; + } + current = current.parent; + } + } + function checkCollisionWithCapturedSuperVariable(node, name) { + if (!needCollisionCheckForIdentifier(node, name, "_super")) { + return; + } + // bubble up and find containing type + var enclosingClass = ts.getContainingClass(node); + // if containing type was not found or it is ambient - exit (no codegen) + if (!enclosingClass || ts.isInAmbientContext(enclosingClass)) { + return; + } + if (ts.getClassExtendsHeritageClauseElement(enclosingClass)) { + var isDeclaration_2 = node.kind !== 69 /* Identifier */; + if (isDeclaration_2) { + error(node, ts.Diagnostics.Duplicate_identifier_super_Compiler_uses_super_to_capture_base_class_reference); + } + else { + error(node, ts.Diagnostics.Expression_resolves_to_super_that_compiler_uses_to_capture_base_class_reference); + } + } + } + function checkCollisionWithRequireExportsInGeneratedCode(node, name) { + if (!needCollisionCheckForIdentifier(node, name, "require") && !needCollisionCheckForIdentifier(node, name, "exports")) { + return; + } + // Uninstantiated modules shouldnt do this check + if (node.kind === 218 /* ModuleDeclaration */ && ts.getModuleInstanceState(node) !== 1 /* Instantiated */) { + return; + } + // In case of variable declaration, node.parent is variable statement so look at the variable statement's parent + var parent = getDeclarationContainer(node); + if (parent.kind === 248 /* SourceFile */ && ts.isExternalModule(parent)) { + // If the declaration happens to be in external module, report error that require and exports are reserved keywords + error(name, ts.Diagnostics.Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module, ts.declarationNameToString(name), ts.declarationNameToString(name)); + } + } + function checkVarDeclaredNamesNotShadowed(node) { + // - ScriptBody : StatementList + // It is a Syntax Error if any element of the LexicallyDeclaredNames of StatementList + // also occurs in the VarDeclaredNames of StatementList. + // - Block : { StatementList } + // It is a Syntax Error if any element of the LexicallyDeclaredNames of StatementList + // also occurs in the VarDeclaredNames of StatementList. + // Variable declarations are hoisted to the top of their function scope. They can shadow + // block scoped declarations, which bind tighter. this will not be flagged as duplicate definition + // by the binder as the declaration scope is different. + // A non-initialized declaration is a no-op as the block declaration will resolve before the var + // declaration. the problem is if the declaration has an initializer. this will act as a write to the + // block declared value. this is fine for let, but not const. + // Only consider declarations with initializers, uninitialized let declarations will not + // step on a let/const variable. + // Do not consider let and const declarations, as duplicate block-scoped declarations + // are handled by the binder. + // We are only looking for let declarations that step on let\const declarations from a + // different scope. e.g.: + // { + // const x = 0; // localDeclarationSymbol obtained after name resolution will correspond to this declaration + // let x = 0; // symbol for this declaration will be 'symbol' + // } + // skip block-scoped variables and parameters + if ((ts.getCombinedNodeFlags(node) & 49152 /* BlockScoped */) !== 0 || ts.isParameterDeclaration(node)) { + return; + } + // 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 === 211 /* VariableDeclaration */ && !node.initializer) { + return; + } + var symbol = getSymbolOfNode(node); + if (symbol.flags & 1 /* FunctionScopedVariable */) { + var localDeclarationSymbol = resolveName(node, node.name.text, 3 /* Variable */, /*nodeNotFoundErrorMessage*/ undefined, /*nameArg*/ undefined); + if (localDeclarationSymbol && + localDeclarationSymbol !== symbol && + localDeclarationSymbol.flags & 2 /* BlockScopedVariable */) { + if (getDeclarationFlagsFromSymbol(localDeclarationSymbol) & 49152 /* BlockScoped */) { + var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 212 /* VariableDeclarationList */); + var container = varDeclList.parent.kind === 193 /* VariableStatement */ && varDeclList.parent.parent + ? varDeclList.parent.parent + : undefined; + // names of block-scoped and function scoped variables can collide only + // if block scoped variable is defined in the function\module\source file scope (because of variable hoisting) + var namesShareScope = container && + (container.kind === 192 /* Block */ && ts.isFunctionLike(container.parent) || + container.kind === 219 /* ModuleBlock */ || + container.kind === 218 /* ModuleDeclaration */ || + container.kind === 248 /* SourceFile */); + // here we know that function scoped variable is shadowed by block scoped one + // if they are defined in the same scope - binder has already reported redeclaration error + // otherwise if variable has an initializer - show error that initialization will fail + // since LHS will be block scoped name instead of function scoped + if (!namesShareScope) { + var name_14 = symbolToString(localDeclarationSymbol); + error(node, ts.Diagnostics.Cannot_initialize_outer_scoped_variable_0_in_the_same_scope_as_block_scoped_declaration_1, name_14, name_14); + } + } + } + } + } + // Check that a parameter initializer contains no references to parameters declared to the right of itself + function checkParameterInitializer(node) { + if (ts.getRootDeclaration(node).kind !== 138 /* Parameter */) { + return; + } + var func = ts.getContainingFunction(node); + visit(node.initializer); + function visit(n) { + if (n.kind === 69 /* Identifier */) { + var referencedSymbol = getNodeLinks(n).resolvedSymbol; + // check FunctionLikeDeclaration.locals (stores parameters\function local variable) + // if it contains entry with a specified name and if this entry matches the resolved symbol + if (referencedSymbol && referencedSymbol !== unknownSymbol && getSymbol(func.locals, referencedSymbol.name, 107455 /* Value */) === referencedSymbol) { + if (referencedSymbol.valueDeclaration.kind === 138 /* Parameter */) { + if (referencedSymbol.valueDeclaration === node) { + error(n, ts.Diagnostics.Parameter_0_cannot_be_referenced_in_its_initializer, ts.declarationNameToString(node.name)); + return; + } + if (referencedSymbol.valueDeclaration.pos < node.pos) { + // legal case - parameter initializer references some parameter strictly on left of current parameter declaration + return; + } + } + error(n, ts.Diagnostics.Initializer_of_parameter_0_cannot_reference_identifier_1_declared_after_it, ts.declarationNameToString(node.name), ts.declarationNameToString(n)); + } + } + else { + ts.forEachChild(n, visit); + } + } + } + // Check variable, parameter, or property declaration + function checkVariableLikeDeclaration(node) { + checkDecorators(node); + checkSourceElement(node.type); + // For a computed property, just check the initializer and exit + // 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 === 136 /* ComputedPropertyName */) { + checkComputedPropertyName(node.name); + if (node.initializer) { + checkExpressionCached(node.initializer); + } + } + // For a binding pattern, check contained binding elements + if (ts.isBindingPattern(node.name)) { + 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 === 138 /* Parameter */ && ts.nodeIsMissing(ts.getContainingFunction(node).body)) { + error(node, ts.Diagnostics.A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation); + return; + } + // For a binding pattern, validate the initializer and exit + if (ts.isBindingPattern(node.name)) { + if (node.initializer) { + checkTypeAssignableTo(checkExpressionCached(node.initializer), getWidenedTypeForVariableLikeDeclaration(node), node, /*headMessage*/ undefined); + checkParameterInitializer(node); + } + return; + } + var symbol = getSymbolOfNode(node); + var type = getTypeOfVariableOrParameterOrProperty(symbol); + if (node === symbol.valueDeclaration) { + // Node is the primary declaration of the symbol, just validate the initializer + if (node.initializer) { + checkTypeAssignableTo(checkExpressionCached(node.initializer), type, node, /*headMessage*/ undefined); + checkParameterInitializer(node); + } + } + 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); + 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)); + } + if (node.initializer) { + checkTypeAssignableTo(checkExpressionCached(node.initializer), declarationType, node, /*headMessage*/ undefined); + } + } + if (node.kind !== 141 /* PropertyDeclaration */ && node.kind !== 140 /* PropertySignature */) { + // We know we don't have a binding pattern or computed name here + checkExportsOnMergedDeclarations(node); + if (node.kind === 211 /* VariableDeclaration */ || node.kind === 163 /* BindingElement */) { + checkVarDeclaredNamesNotShadowed(node); + } + checkCollisionWithCapturedSuperVariable(node, node.name); + checkCollisionWithCapturedThisVariable(node, node.name); + checkCollisionWithRequireExportsInGeneratedCode(node, node.name); + } + } + function checkVariableDeclaration(node) { + checkGrammarVariableDeclaration(node); + return checkVariableLikeDeclaration(node); + } + function checkBindingElement(node) { + checkGrammarBindingElement(node); + return checkVariableLikeDeclaration(node); + } + function checkVariableStatement(node) { + // Grammar checking + checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarVariableDeclarationList(node.declarationList) || checkGrammarForDisallowedLetOrConstStatement(node); + ts.forEach(node.declarationList.declarations, checkSourceElement); + } + 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 === 165 /* ObjectLiteralExpression */) { + if (ts.isAsyncFunctionLike(node)) { + if (node.modifiers.length > 1) { + return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); + } + } + else { + return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); + } + } + } + function checkExpressionStatement(node) { + // Grammar checking + checkGrammarStatementInAmbientContext(node); + checkExpression(node.expression); + } + function checkIfStatement(node) { + // Grammar checking + checkGrammarStatementInAmbientContext(node); + checkExpression(node.expression); + checkSourceElement(node.thenStatement); + checkSourceElement(node.elseStatement); + } + function checkDoStatement(node) { + // Grammar checking + checkGrammarStatementInAmbientContext(node); + checkSourceElement(node.statement); + checkExpression(node.expression); + } + function checkWhileStatement(node) { + // Grammar checking + checkGrammarStatementInAmbientContext(node); + checkExpression(node.expression); + checkSourceElement(node.statement); + } + function checkForStatement(node) { + // Grammar checking + if (!checkGrammarStatementInAmbientContext(node)) { + if (node.initializer && node.initializer.kind === 212 /* VariableDeclarationList */) { + checkGrammarVariableDeclarationList(node.initializer); + } + } + if (node.initializer) { + if (node.initializer.kind === 212 /* VariableDeclarationList */) { + ts.forEach(node.initializer.declarations, checkVariableDeclaration); + } + else { + checkExpression(node.initializer); + } + } + if (node.condition) + checkExpression(node.condition); + if (node.incrementor) + checkExpression(node.incrementor); + checkSourceElement(node.statement); + } + function checkForOfStatement(node) { + checkGrammarForInOrForOfStatement(node); + // Check the LHS and RHS + // If the LHS is a declaration, just check it as a variable declaration, which will in turn check the RHS + // 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 === 212 /* VariableDeclarationList */) { + checkForInOrForOfVariableDeclaration(node); + } + else { + var varExpr = node.initializer; + var iteratedType = checkRightHandSideOfForOf(node.expression); + // There may be a destructuring assignment on the left side + if (varExpr.kind === 164 /* ArrayLiteralExpression */ || varExpr.kind === 165 /* ObjectLiteralExpression */) { + // iteratedType may be undefined. In this case, we still want to check the structure of + // varExpr, in particular making sure it's a valid LeftHandSideExpression. But we'd like + // to short circuit the type relation checking as much as possible, so we pass the unknownType. + checkDestructuringAssignment(varExpr, iteratedType || unknownType); + } + else { + var leftType = checkExpression(varExpr); + checkReferenceExpression(varExpr, /*invalidReferenceMessage*/ ts.Diagnostics.Invalid_left_hand_side_in_for_of_statement, + /*constantVariableMessage*/ ts.Diagnostics.The_left_hand_side_of_a_for_of_statement_cannot_be_a_previously_defined_constant); + // iteratedType will be undefined if the rightType was missing properties/signatures + // required to get its iteratedType (like [Symbol.iterator] or next). This may be + // because we accessed properties from anyType, or it may have led to an error inside + // getElementTypeOfIterable. + if (iteratedType) { + checkTypeAssignableTo(iteratedType, leftType, varExpr, /*headMessage*/ undefined); + } + } + } + checkSourceElement(node.statement); + } + function checkForInStatement(node) { + // Grammar checking + checkGrammarForInOrForOfStatement(node); + // TypeScript 1.0 spec (April 2014): 5.4 + // In a 'for-in' statement of the form + // 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 === 212 /* VariableDeclarationList */) { + var variable = node.initializer.declarations[0]; + if (variable && ts.isBindingPattern(variable.name)) { + error(variable.name, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern); + } + checkForInOrForOfVariableDeclaration(node); + } + else { + // In a 'for-in' statement of the form + // for (Var in Expr) Statement + // Var must be an expression classified as a reference of type Any or the String primitive type, + // 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 === 164 /* ArrayLiteralExpression */ || varExpr.kind === 165 /* ObjectLiteralExpression */) { + error(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern); + } + else if (!isTypeAnyOrAllConstituentTypesHaveKind(leftType, 258 /* StringLike */)) { + error(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_must_be_of_type_string_or_any); + } + else { + // run check only former check succeeded to avoid cascading errors + checkReferenceExpression(varExpr, ts.Diagnostics.Invalid_left_hand_side_in_for_in_statement, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_previously_defined_constant); + } + } + var rightType = checkExpression(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, 80896 /* ObjectType */ | 512 /* TypeParameter */)) { + error(node.expression, ts.Diagnostics.The_right_hand_side_of_a_for_in_statement_must_be_of_type_any_an_object_type_or_a_type_parameter); + } + checkSourceElement(node.statement); + } + function checkForInOrForOfVariableDeclaration(iterationStatement) { + var variableDeclarationList = iterationStatement.initializer; + // checkGrammarForInOrForOfStatement will check that there is exactly one declaration. + if (variableDeclarationList.declarations.length >= 1) { + var decl = variableDeclarationList.declarations[0]; + checkVariableDeclaration(decl); + } + } + function checkRightHandSideOfForOf(rhsExpression) { + var expressionType = getTypeOfExpression(rhsExpression); + return checkIteratedTypeOrElementType(expressionType, rhsExpression, /*allowStringInput*/ true); + } + function checkIteratedTypeOrElementType(inputType, errorNode, allowStringInput) { + if (isTypeAny(inputType)) { + return inputType; + } + if (languageVersion >= 2 /* ES6 */) { + return checkElementTypeOfIterable(inputType, errorNode); + } + if (allowStringInput) { + return checkElementTypeOfArrayOrString(inputType, errorNode); + } + if (isArrayLikeType(inputType)) { + var indexType = getIndexTypeOfType(inputType, 1 /* Number */); + if (indexType) { + return indexType; + } + } + error(errorNode, ts.Diagnostics.Type_0_is_not_an_array_type, typeToString(inputType)); + return unknownType; + } + /** + * When errorNode is undefined, it means we should not report any errors. + */ + function checkElementTypeOfIterable(iterable, errorNode) { + var elementType = getElementTypeOfIterable(iterable, errorNode); + // Now even though we have extracted the iteratedType, we will have to validate that the type + // passed in is actually an Iterable. + if (errorNode && elementType) { + checkTypeAssignableTo(iterable, createIterableType(elementType), errorNode); + } + return elementType || anyType; + } + /** + * We want to treat type as an iterable, and get the type it is an iterable of. The iterable + * must have the following structure (annotated with the names of the variables below): + * + * { // iterable + * [Symbol.iterator]: { // iteratorFunction + * (): Iterator + * } + * } + * + * T is the type we are after. At every level that involves analyzing return types + * of signatures, we union the return types of all the signatures. + * + * Another thing to note is that at any step of this process, we could run into a dead end, + * meaning either the property is missing, or we run into the anyType. If either of these things + * happens, we return undefined to signal that we could not find the iterated type. If a property + * is missing, and the previous step did not result in 'any', then we also give an error if the + * caller requested it. Then the caller can decide what to do in the case where there is no iterated + * type. This is different from returning anyType, because that would signify that we have matched the + * whole pattern and that T (above) is 'any'. + */ + function getElementTypeOfIterable(type, errorNode) { + if (isTypeAny(type)) { + return undefined; + } + var typeAsIterable = type; + 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 & 4096 /* Reference */) && type.target === globalIterableType) { + typeAsIterable.iterableElementType = type.typeArguments[0]; + } + else { + var iteratorFunction = getTypeOfPropertyOfType(type, ts.getPropertyNameForKnownSymbolName("iterator")); + if (isTypeAny(iteratorFunction)) { + return undefined; + } + var iteratorFunctionSignatures = iteratorFunction ? getSignaturesOfType(iteratorFunction, 0 /* Call */) : emptyArray; + if (iteratorFunctionSignatures.length === 0) { + if (errorNode) { + error(errorNode, ts.Diagnostics.Type_must_have_a_Symbol_iterator_method_that_returns_an_iterator); + } + return undefined; + } + typeAsIterable.iterableElementType = getElementTypeOfIterator(getUnionType(ts.map(iteratorFunctionSignatures, getReturnTypeOfSignature)), errorNode); + } + } + return typeAsIterable.iterableElementType; + } + /** + * This function has very similar logic as getElementTypeOfIterable, except that it operates on + * Iterators instead of Iterables. Here is the structure: + * + * { // iterator + * next: { // iteratorNextFunction + * (): { // iteratorNextResult + * value: T // iteratorNextValue + * } + * } + * } + * + */ + function getElementTypeOfIterator(type, errorNode) { + if (isTypeAny(type)) { + return undefined; + } + var typeAsIterator = type; + 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 & 4096 /* Reference */) && type.target === globalIteratorType) { + typeAsIterator.iteratorElementType = type.typeArguments[0]; + } + else { + var iteratorNextFunction = getTypeOfPropertyOfType(type, "next"); + if (isTypeAny(iteratorNextFunction)) { + return undefined; + } + var iteratorNextFunctionSignatures = iteratorNextFunction ? getSignaturesOfType(iteratorNextFunction, 0 /* Call */) : emptyArray; + if (iteratorNextFunctionSignatures.length === 0) { + if (errorNode) { + error(errorNode, ts.Diagnostics.An_iterator_must_have_a_next_method); + } + return undefined; + } + var iteratorNextResult = getUnionType(ts.map(iteratorNextFunctionSignatures, getReturnTypeOfSignature)); + if (isTypeAny(iteratorNextResult)) { + return undefined; + } + var iteratorNextValue = getTypeOfPropertyOfType(iteratorNextResult, "value"); + if (!iteratorNextValue) { + if (errorNode) { + error(errorNode, ts.Diagnostics.The_type_returned_by_the_next_method_of_an_iterator_must_have_a_value_property); + } + return undefined; + } + typeAsIterator.iteratorElementType = iteratorNextValue; + } + } + return typeAsIterator.iteratorElementType; + } + function getElementTypeOfIterableIterator(type) { + if (isTypeAny(type)) { + return undefined; + } + // As an optimization, if the type is instantiated directly using the globalIterableIteratorType (IterableIterator), + // then just grab its type argument. + if ((type.flags & 4096 /* Reference */) && type.target === globalIterableIteratorType) { + return type.typeArguments[0]; + } + return getElementTypeOfIterable(type, /*errorNode*/ undefined) || + getElementTypeOfIterator(type, /*errorNode*/ undefined); + } + /** + * This function does the following steps: + * 1. Break up arrayOrStringType (possibly a union) into its string constituents and array constituents. + * 2. Take the element types of the array constituents. + * 3. Return the union of the element types, and string if there was a string constitutent. + * + * For example: + * string -> string + * number[] -> number + * string[] | number[] -> string | number + * string | number[] -> string | number + * string | string[] | number[] -> string | number + * + * It also errors if: + * 1. Some constituent is neither a string nor an array. + * 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 */); + // 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 = removeTypesFromUnionType(arrayOrStringType, 258 /* StringLike */, /*isTypeOfKind*/ true, /*allowEmptyUnionResult*/ true); + var hasStringConstituent = arrayOrStringType !== arrayType; + var reportedError = false; + if (hasStringConstituent) { + if (languageVersion < 1 /* ES5 */) { + error(errorNode, ts.Diagnostics.Using_a_string_in_a_for_of_statement_is_only_supported_in_ECMAScript_5_and_higher); + reportedError = true; + } + // Now that we've removed all the StringLike types, if no constituents remain, then the entire + // arrayOrStringType was a string. + if (arrayType === emptyObjectType) { + return stringType; + } + } + if (!isArrayLikeType(arrayType)) { + if (!reportedError) { + // Which error we report depends on whether there was a string constituent. For example, + // if the input type is number | string, we want to say that number is not an array type. + // But if the input was just number, we want to say that number is not an array type + // or a string type. + var diagnostic = hasStringConstituent + ? ts.Diagnostics.Type_0_is_not_an_array_type + : ts.Diagnostics.Type_0_is_not_an_array_type_or_a_string_type; + error(errorNode, diagnostic, typeToString(arrayType)); + } + return hasStringConstituent ? stringType : unknownType; + } + var arrayElementType = getIndexTypeOfType(arrayType, 1 /* Number */) || unknownType; + if (hasStringConstituent) { + // This is just an optimization for the case where arrayOrStringType is string | string[] + if (arrayElementType.flags & 258 /* StringLike */) { + return stringType; + } + return getUnionType([arrayElementType, stringType]); + } + return arrayElementType; + } + function checkBreakOrContinueStatement(node) { + // Grammar checking + checkGrammarStatementInAmbientContext(node) || checkGrammarBreakOrContinueStatement(node); + // TODO: Check that target label is valid + } + function isGetAccessorWithAnnotatatedSetAccessor(node) { + return !!(node.kind === 145 /* GetAccessor */ && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(node.symbol, 146 /* SetAccessor */))); + } + function checkReturnStatement(node) { + // Grammar checking + if (!checkGrammarStatementInAmbientContext(node)) { + var functionBlock = ts.getContainingFunction(node); + if (!functionBlock) { + grammarErrorOnFirstToken(node, ts.Diagnostics.A_return_statement_can_only_be_used_within_a_function_body); + } + } + if (node.expression) { + var func = ts.getContainingFunction(node); + if (func) { + var signature = getSignatureFromDeclaration(func); + var returnType = getReturnTypeOfSignature(signature); + var exprType = checkExpressionCached(node.expression); + if (func.asteriskToken) { + // A generator does not need its return expressions checked against its return type. + // Instead, the yield expressions are checked against the element type. + // TODO: Check return expressions of generators when return type tracking is added + // for generators. + return; + } + if (func.kind === 146 /* SetAccessor */) { + error(node.expression, ts.Diagnostics.Setters_cannot_return_a_value); + } + else if (func.kind === 144 /* Constructor */) { + if (!isTypeAssignableTo(exprType, returnType)) { + error(node.expression, ts.Diagnostics.Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class); + } + } + else if (func.type || isGetAccessorWithAnnotatatedSetAccessor(func) || signature.typePredicate) { + if (ts.isAsyncFunctionLike(func)) { + var promisedType = getPromisedType(returnType); + var awaitedType = checkAwaitedType(exprType, node.expression, ts.Diagnostics.Return_expression_in_async_function_does_not_have_a_valid_callable_then_member); + if (promisedType) { + // If the function has a return type, but promisedType is + // undefined, an error will be reported in checkAsyncFunctionReturnType + // so we don't need to report one here. + checkTypeAssignableTo(awaitedType, promisedType, node.expression); + } + } + else { + checkTypeAssignableTo(exprType, returnType, node.expression); + } + } + } + } + } + function checkWithStatement(node) { + // Grammar checking for withStatement + if (!checkGrammarStatementInAmbientContext(node)) { + if (node.parserContextFlags & 8 /* Await */) { + grammarErrorOnFirstToken(node, ts.Diagnostics.with_statements_are_not_allowed_in_an_async_function_block); + } + } + checkExpression(node.expression); + error(node.expression, ts.Diagnostics.All_symbols_within_a_with_block_will_be_resolved_to_any); + } + function checkSwitchStatement(node) { + // Grammar checking + checkGrammarStatementInAmbientContext(node); + var firstDefaultClause; + var hasDuplicateDefaultClause = false; + var expressionType = checkExpression(node.expression); + ts.forEach(node.caseBlock.clauses, function (clause) { + // Grammar check for duplicate default clauses, skip if we already report duplicate default clause + if (clause.kind === 242 /* DefaultClause */ && !hasDuplicateDefaultClause) { + if (firstDefaultClause === undefined) { + firstDefaultClause = clause; + } + else { + var sourceFile = ts.getSourceFileOfNode(node); + var start = ts.skipTrivia(sourceFile.text, clause.pos); + var end = clause.statements.length > 0 ? clause.statements[0].pos : clause.end; + grammarErrorAtPos(sourceFile, start, end - start, ts.Diagnostics.A_default_clause_cannot_appear_more_than_once_in_a_switch_statement); + hasDuplicateDefaultClause = true; + } + } + if (produceDiagnostics && clause.kind === 241 /* CaseClause */) { + var caseClause = clause; + // TypeScript 1.0 spec (April 2014):5.9 + // In a 'switch' statement, each 'case' expression must be of a type that is assignable to or from the type of the 'switch' expression. + var caseType = checkExpression(caseClause.expression); + if (!isTypeAssignableTo(expressionType, caseType)) { + // check 'expressionType isAssignableTo caseType' failed, try the reversed check and report errors if it fails + checkTypeAssignableTo(caseType, expressionType, caseClause.expression, /*headMessage*/ undefined); + } + } + ts.forEach(clause.statements, checkSourceElement); + }); + } + function checkLabeledStatement(node) { + // Grammar checking + if (!checkGrammarStatementInAmbientContext(node)) { + var current = node.parent; + while (current) { + if (ts.isFunctionLike(current)) { + break; + } + if (current.kind === 207 /* LabeledStatement */ && current.label.text === node.label.text) { + var sourceFile = ts.getSourceFileOfNode(node); + grammarErrorOnNode(node.label, ts.Diagnostics.Duplicate_label_0, ts.getTextOfNodeFromSourceText(sourceFile.text, node.label)); + break; + } + current = current.parent; + } + } + // ensure that label is unique + checkSourceElement(node.statement); + } + function checkThrowStatement(node) { + // Grammar checking + if (!checkGrammarStatementInAmbientContext(node)) { + if (node.expression === undefined) { + grammarErrorAfterFirstToken(node, ts.Diagnostics.Line_break_not_permitted_here); + } + } + if (node.expression) { + checkExpression(node.expression); + } + } + function checkTryStatement(node) { + // Grammar checking + checkGrammarStatementInAmbientContext(node); + checkBlock(node.tryBlock); + var catchClause = node.catchClause; + if (catchClause) { + // Grammar checking + if (catchClause.variableDeclaration) { + if (catchClause.variableDeclaration.name.kind !== 69 /* Identifier */) { + grammarErrorOnFirstToken(catchClause.variableDeclaration.name, ts.Diagnostics.Catch_clause_variable_name_must_be_an_identifier); + } + else if (catchClause.variableDeclaration.type) { + grammarErrorOnFirstToken(catchClause.variableDeclaration.type, ts.Diagnostics.Catch_clause_variable_cannot_have_a_type_annotation); + } + else if (catchClause.variableDeclaration.initializer) { + grammarErrorOnFirstToken(catchClause.variableDeclaration.initializer, ts.Diagnostics.Catch_clause_variable_cannot_have_an_initializer); + } + else { + var identifierName = catchClause.variableDeclaration.name.text; + var locals = catchClause.block.locals; + if (locals && ts.hasProperty(locals, identifierName)) { + var localSymbol = locals[identifierName]; + if (localSymbol && (localSymbol.flags & 2 /* BlockScopedVariable */) !== 0) { + grammarErrorOnNode(localSymbol.valueDeclaration, ts.Diagnostics.Cannot_redeclare_identifier_0_in_catch_clause, identifierName); + } + } + } + } + checkBlock(catchClause.block); + } + if (node.finallyBlock) { + checkBlock(node.finallyBlock); + } + } + function checkIndexConstraints(type) { + var declaredNumberIndexer = getIndexDeclarationOfSymbol(type.symbol, 1 /* Number */); + var declaredStringIndexer = getIndexDeclarationOfSymbol(type.symbol, 0 /* String */); + var stringIndexType = getIndexTypeOfType(type, 0 /* String */); + var numberIndexType = getIndexTypeOfType(type, 1 /* Number */); + if (stringIndexType || numberIndexType) { + ts.forEach(getPropertiesOfObjectType(type), function (prop) { + var propType = getTypeOfSymbol(prop); + checkIndexConstraintForProperty(prop, propType, type, declaredStringIndexer, stringIndexType, 0 /* String */); + checkIndexConstraintForProperty(prop, propType, type, declaredNumberIndexer, numberIndexType, 1 /* Number */); + }); + if (type.flags & 1024 /* Class */ && ts.isClassLike(type.symbol.valueDeclaration)) { + var classDeclaration = type.symbol.valueDeclaration; + for (var _i = 0, _a = classDeclaration.members; _i < _a.length; _i++) { + var member = _a[_i]; + // Only process instance properties with computed names here. + // Static properties cannot be in conflict with indexers, + // and properties with literal names were already checked. + if (!(member.flags & 128 /* Static */) && ts.hasDynamicName(member)) { + var propType = getTypeOfSymbol(member.symbol); + checkIndexConstraintForProperty(member.symbol, propType, type, declaredStringIndexer, stringIndexType, 0 /* String */); + checkIndexConstraintForProperty(member.symbol, propType, type, declaredNumberIndexer, numberIndexType, 1 /* Number */); + } + } + } + } + var errorNode; + 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 & 2048 /* Interface */)) { + var someBaseTypeHasBothIndexers = ts.forEach(getBaseTypes(type), function (base) { return getIndexTypeOfType(base, 0 /* String */) && getIndexTypeOfType(base, 1 /* Number */); }); + errorNode = someBaseTypeHasBothIndexers ? undefined : type.symbol.declarations[0]; + } + } + if (errorNode && !isTypeAssignableTo(numberIndexType, stringIndexType)) { + error(errorNode, ts.Diagnostics.Numeric_index_type_0_is_not_assignable_to_string_index_type_1, typeToString(numberIndexType), typeToString(stringIndexType)); + } + function checkIndexConstraintForProperty(prop, propertyType, containingType, indexDeclaration, indexType, indexKind) { + if (!indexType) { + return; + } + // index is numeric and property name is not valid numeric literal + if (indexKind === 1 /* Number */ && !isNumericName(prop.valueDeclaration.name)) { + return; + } + // 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 === 136 /* ComputedPropertyName */ || prop.parent === containingType.symbol) { + errorNode = prop.valueDeclaration; + } + else if (indexDeclaration) { + errorNode = indexDeclaration; + } + else if (containingType.flags & 2048 /* 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 + var someBaseClassHasBothPropertyAndIndexer = ts.forEach(getBaseTypes(containingType), function (base) { return getPropertyOfObjectType(base, prop.name) && getIndexTypeOfType(base, indexKind); }); + errorNode = someBaseClassHasBothPropertyAndIndexer ? undefined : containingType.symbol.declarations[0]; + } + if (errorNode && !isTypeAssignableTo(propertyType, indexType)) { + var errorMessage = indexKind === 0 /* String */ + ? ts.Diagnostics.Property_0_of_type_1_is_not_assignable_to_string_index_type_2 + : ts.Diagnostics.Property_0_of_type_1_is_not_assignable_to_numeric_index_type_2; + error(errorNode, errorMessage, symbolToString(prop), typeToString(propertyType), typeToString(indexType)); + } + } + } + function checkTypeNameIsReserved(name, message) { + // TS 1.0 spec (April 2014): 3.6.1 + // The predefined type keywords are reserved and cannot be used as names of user defined types. + switch (name.text) { + case "any": + case "number": + case "boolean": + case "string": + case "symbol": + case "void": + error(name, message, name.text); + } + } + // Check each type parameter and check that list has no duplicate type parameter declarations + function checkTypeParameters(typeParameterDeclarations) { + if (typeParameterDeclarations) { + for (var i = 0, n = typeParameterDeclarations.length; i < n; i++) { + var node = typeParameterDeclarations[i]; + checkTypeParameter(node); + if (produceDiagnostics) { + for (var j = 0; j < i; j++) { + if (typeParameterDeclarations[j].symbol === node.symbol) { + error(node.name, ts.Diagnostics.Duplicate_identifier_0, ts.declarationNameToString(node.name)); + } + } + } + } + } + } + function checkClassExpression(node) { + checkClassLikeDeclaration(node); + return getTypeOfSymbol(getSymbolOfNode(node)); + } + function checkClassDeclaration(node) { + if (!node.name && !(node.flags & 1024 /* Default */)) { + grammarErrorOnFirstToken(node, ts.Diagnostics.A_class_declaration_without_the_default_modifier_must_have_a_name); + } + checkClassLikeDeclaration(node); + ts.forEach(node.members, checkSourceElement); + } + function checkClassLikeDeclaration(node) { + checkGrammarClassDeclarationHeritageClauses(node); + checkDecorators(node); + if (node.name) { + checkTypeNameIsReserved(node.name, ts.Diagnostics.Class_name_cannot_be_0); + checkCollisionWithCapturedThisVariable(node, node.name); + checkCollisionWithRequireExportsInGeneratedCode(node, node.name); + } + checkTypeParameters(node.typeParameters); + checkExportsOnMergedDeclarations(node); + var symbol = getSymbolOfNode(node); + var type = getDeclaredTypeOfSymbol(symbol); + var typeWithThis = getTypeWithThisArgument(type); + var staticType = getTypeOfSymbol(symbol); + var baseTypeNode = ts.getClassExtendsHeritageClauseElement(node); + if (baseTypeNode) { + emitExtends = emitExtends || !ts.isInAmbientContext(node); + var baseTypes = getBaseTypes(type); + if (baseTypes.length && produceDiagnostics) { + var baseType = baseTypes[0]; + var staticBaseType = getBaseConstructorTypeOfClass(type); + checkSourceElement(baseTypeNode.expression); + if (baseTypeNode.typeArguments) { + ts.forEach(baseTypeNode.typeArguments, checkSourceElement); + for (var _i = 0, _a = getConstructorsForTypeArguments(staticBaseType, baseTypeNode.typeArguments); _i < _a.length; _i++) { + var constructor = _a[_i]; + if (!checkTypeArgumentConstraints(constructor.typeParameters, baseTypeNode.typeArguments)) { + break; + } + } + } + checkTypeAssignableTo(typeWithThis, getTypeWithThisArgument(baseType, type.thisType), node.name || node, ts.Diagnostics.Class_0_incorrectly_extends_base_class_1); + checkTypeAssignableTo(staticType, getTypeWithoutSignatures(staticBaseType), node.name || node, ts.Diagnostics.Class_static_side_0_incorrectly_extends_base_class_static_side_1); + if (!(staticBaseType.symbol && staticBaseType.symbol.flags & 32 /* Class */)) { + // When the static base type is a "class-like" constructor function (but not actually a class), we verify + // that all instantiated base constructor signatures return the same type. We can simply compare the type + // references (as opposed to checking the structure of the types) because elsewhere we have already checked + // that the base type is a class or interface type (and not, for example, an anonymous object type). + var constructors = getInstantiatedConstructorsForTypeArguments(staticBaseType, baseTypeNode.typeArguments); + if (ts.forEach(constructors, function (sig) { return getReturnTypeOfSignature(sig) !== baseType; })) { + error(baseTypeNode.expression, ts.Diagnostics.Base_constructors_must_all_have_the_same_return_type); + } + } + checkKindsOfPropertyMemberOverrides(type, baseType); + } + } + var implementedTypeNodes = ts.getClassImplementsHeritageClauseElements(node); + if (implementedTypeNodes) { + for (var _b = 0; _b < implementedTypeNodes.length; _b++) { + var typeRefNode = implementedTypeNodes[_b]; + if (!ts.isSupportedExpressionWithTypeArguments(typeRefNode)) { + error(typeRefNode.expression, ts.Diagnostics.A_class_can_only_implement_an_identifier_Slashqualified_name_with_optional_type_arguments); + } + checkTypeReferenceNode(typeRefNode); + if (produceDiagnostics) { + var t = getTypeFromTypeNode(typeRefNode); + if (t !== unknownType) { + var declaredType = (t.flags & 4096 /* Reference */) ? t.target : t; + if (declaredType.flags & (1024 /* Class */ | 2048 /* Interface */)) { + checkTypeAssignableTo(typeWithThis, getTypeWithThisArgument(t, type.thisType), node.name || node, ts.Diagnostics.Class_0_incorrectly_implements_interface_1); + } + else { + error(typeRefNode, ts.Diagnostics.A_class_may_only_implement_another_class_or_interface); + } + } + } + } + } + if (produceDiagnostics) { + checkIndexConstraints(type); + checkTypeForDuplicateIndexSignatures(node); + } + } + function getTargetSymbol(s) { + // if symbol is instantiated its flags are not copied from the 'target' + // so we'll need to get back original 'target' symbol to work with correct set of flags + return s.flags & 16777216 /* Instantiated */ ? getSymbolLinks(s).target : s; + } + function getClassLikeDeclarationOfSymbol(symbol) { + return ts.forEach(symbol.declarations, function (d) { return ts.isClassLike(d) ? d : undefined; }); + } + function checkKindsOfPropertyMemberOverrides(type, baseType) { + // TypeScript 1.0 spec (April 2014): 8.2.3 + // A derived class inherits all members from its base class it doesn't override. + // Inheritance means that a derived class implicitly contains all non - overridden members of the base class. + // Both public and private property members are inherited, but only public property members can be overridden. + // A property member in a derived class is said to override a property member in a base class + // when the derived class property member has the same name and kind(instance or static) + // as the base class property member. + // The type of an overriding property member must be assignable(section 3.8.4) + // to the type of the overridden property member, or otherwise a compile - time error occurs. + // Base class instance member functions can be overridden by derived class instance member functions, + // but not by other kinds of members. + // Base class instance member variables and accessors can be overridden by + // derived class instance member variables and accessors, but not by other kinds of members. + // NOTE: assignability is checked in checkClassDeclaration + var baseProperties = getPropertiesOfObjectType(baseType); + for (var _i = 0; _i < baseProperties.length; _i++) { + var baseProperty = baseProperties[_i]; + var base = getTargetSymbol(baseProperty); + if (base.flags & 134217728 /* Prototype */) { + continue; + } + var derived = getTargetSymbol(getPropertyOfObjectType(type, base.name)); + var baseDeclarationFlags = getDeclarationFlagsFromSymbol(base); + ts.Debug.assert(!!derived, "derived should point to something, even if it is the base class' declaration."); + if (derived) { + // In order to resolve whether the inherited method was overriden in the base class or not, + // we compare the Symbols obtained. Since getTargetSymbol returns the symbol on the *uninstantiated* + // type declaration, derived and base resolve to the same symbol even in the case of generic classes. + if (derived === base) { + // derived class inherits base without override/redeclaration + var derivedClassDecl = getClassLikeDeclarationOfSymbol(type.symbol); + // It is an error to inherit an abstract member without implementing it or being declared abstract. + // If there is no declaration for the derived class (as in the case of class expressions), + // then the class cannot be declared abstract. + if (baseDeclarationFlags & 256 /* Abstract */ && (!derivedClassDecl || !(derivedClassDecl.flags & 256 /* Abstract */))) { + if (derivedClassDecl.kind === 186 /* ClassExpression */) { + error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1, symbolToString(baseProperty), typeToString(baseType)); + } + else { + error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_0_does_not_implement_inherited_abstract_member_1_from_class_2, typeToString(type), symbolToString(baseProperty), typeToString(baseType)); + } + } + } + else { + // derived overrides base. + var derivedDeclarationFlags = getDeclarationFlagsFromSymbol(derived); + if ((baseDeclarationFlags & 32 /* Private */) || (derivedDeclarationFlags & 32 /* Private */)) { + // either base or derived property is private - not override, skip it + continue; + } + if ((baseDeclarationFlags & 128 /* Static */) !== (derivedDeclarationFlags & 128 /* Static */)) { + // value of 'static' is not the same for properties - not override, skip it + continue; + } + if ((base.flags & derived.flags & 8192 /* Method */) || ((base.flags & 98308 /* PropertyOrAccessor */) && (derived.flags & 98308 /* PropertyOrAccessor */))) { + // method is overridden with method or property/accessor is overridden with property/accessor - correct case + continue; + } + var errorMessage = void 0; + if (base.flags & 8192 /* Method */) { + if (derived.flags & 98304 /* Accessor */) { + errorMessage = ts.Diagnostics.Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_accessor; + } + else { + ts.Debug.assert((derived.flags & 4 /* Property */) !== 0); + errorMessage = ts.Diagnostics.Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_property; + } + } + else if (base.flags & 4 /* Property */) { + ts.Debug.assert((derived.flags & 8192 /* Method */) !== 0); + errorMessage = ts.Diagnostics.Class_0_defines_instance_member_property_1_but_extended_class_2_defines_it_as_instance_member_function; + } + else { + ts.Debug.assert((base.flags & 98304 /* Accessor */) !== 0); + ts.Debug.assert((derived.flags & 8192 /* Method */) !== 0); + errorMessage = ts.Diagnostics.Class_0_defines_instance_member_accessor_1_but_extended_class_2_defines_it_as_instance_member_function; + } + error(derived.valueDeclaration.name, errorMessage, typeToString(baseType), symbolToString(base), typeToString(type)); + } + } + } + } + function isAccessor(kind) { + return kind === 145 /* GetAccessor */ || kind === 146 /* SetAccessor */; + } + function areTypeParametersIdentical(list1, list2) { + if (!list1 && !list2) { + return true; + } + if (!list1 || !list2 || list1.length !== list2.length) { + return false; + } + // TypeScript 1.0 spec (April 2014): + // When a generic interface has multiple declarations, all declarations must have identical type parameter + // lists, i.e. identical type parameter names with identical constraints in identical order. + for (var i = 0, len = list1.length; i < len; i++) { + var tp1 = list1[i]; + var tp2 = list2[i]; + if (tp1.name.text !== tp2.name.text) { + return false; + } + if (!tp1.constraint && !tp2.constraint) { + continue; + } + if (!tp1.constraint || !tp2.constraint) { + return false; + } + if (!isTypeIdenticalTo(getTypeFromTypeNode(tp1.constraint), getTypeFromTypeNode(tp2.constraint))) { + return false; + } + } + return true; + } + function checkInheritedPropertiesAreIdentical(type, typeNode) { + var baseTypes = getBaseTypes(type); + if (baseTypes.length < 2) { + return true; + } + var seen = {}; + ts.forEach(resolveDeclaredMembers(type).declaredProperties, function (p) { seen[p.name] = { prop: p, containingType: type }; }); + var ok = true; + for (var _i = 0; _i < baseTypes.length; _i++) { + var base = baseTypes[_i]; + var properties = getPropertiesOfObjectType(getTypeWithThisArgument(base, type.thisType)); + for (var _a = 0; _a < properties.length; _a++) { + var prop = properties[_a]; + if (!ts.hasProperty(seen, prop.name)) { + seen[prop.name] = { prop: prop, containingType: base }; + } + else { + var existing = seen[prop.name]; + var isInheritedProperty = existing.containingType !== type; + if (isInheritedProperty && !isPropertyIdenticalTo(existing.prop, prop)) { + ok = false; + var typeName1 = typeToString(existing.containingType); + var typeName2 = typeToString(base); + var errorInfo = ts.chainDiagnosticMessages(undefined, ts.Diagnostics.Named_property_0_of_types_1_and_2_are_not_identical, symbolToString(prop), typeName1, typeName2); + errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.Interface_0_cannot_simultaneously_extend_types_1_and_2, typeToString(type), typeName1, typeName2); + diagnostics.add(ts.createDiagnosticForNodeFromMessageChain(typeNode, errorInfo)); + } + } + } + } + return ok; + } + function checkInterfaceDeclaration(node) { + // Grammar checking + checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarInterfaceDeclaration(node); + checkTypeParameters(node.typeParameters); + if (produceDiagnostics) { + checkTypeNameIsReserved(node.name, ts.Diagnostics.Interface_name_cannot_be_0); + checkExportsOnMergedDeclarations(node); + var symbol = getSymbolOfNode(node); + var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 215 /* InterfaceDeclaration */); + if (symbol.declarations.length > 1) { + if (node !== firstInterfaceDecl && !areTypeParametersIdentical(firstInterfaceDecl.typeParameters, node.typeParameters)) { + error(node.name, ts.Diagnostics.All_declarations_of_an_interface_must_have_identical_type_parameters); + } + } + // Only check this symbol once + if (node === firstInterfaceDecl) { + var type = getDeclaredTypeOfSymbol(symbol); + var typeWithThis = getTypeWithThisArgument(type); + // run subsequent checks only if first set succeeded + if (checkInheritedPropertiesAreIdentical(type, node.name)) { + for (var _i = 0, _a = getBaseTypes(type); _i < _a.length; _i++) { + var baseType = _a[_i]; + checkTypeAssignableTo(typeWithThis, getTypeWithThisArgument(baseType, type.thisType), node.name, ts.Diagnostics.Interface_0_incorrectly_extends_interface_1); + } + checkIndexConstraints(type); + } + } + } + ts.forEach(ts.getInterfaceBaseTypeNodes(node), function (heritageElement) { + if (!ts.isSupportedExpressionWithTypeArguments(heritageElement)) { + error(heritageElement.expression, ts.Diagnostics.An_interface_can_only_extend_an_identifier_Slashqualified_name_with_optional_type_arguments); + } + checkTypeReferenceNode(heritageElement); + }); + ts.forEach(node.members, checkSourceElement); + if (produceDiagnostics) { + checkTypeForDuplicateIndexSignatures(node); + } + } + function checkTypeAliasDeclaration(node) { + // Grammar checking + checkGrammarDecorators(node) || checkGrammarModifiers(node); + checkTypeNameIsReserved(node.name, ts.Diagnostics.Type_alias_name_cannot_be_0); + checkSourceElement(node.type); + } + function computeEnumMemberValues(node) { + var nodeLinks = getNodeLinks(node); + if (!(nodeLinks.flags & 8192 /* EnumValuesComputed */)) { + var enumSymbol = getSymbolOfNode(node); + var enumType = getDeclaredTypeOfSymbol(enumSymbol); + var autoValue = 0; // set to undefined when enum member is non-constant + var ambient = ts.isInAmbientContext(node); + var enumIsConst = ts.isConst(node); + for (var _i = 0, _a = node.members; _i < _a.length; _i++) { + var member = _a[_i]; + if (member.name.kind === 136 /* ComputedPropertyName */) { + error(member.name, ts.Diagnostics.Computed_property_names_are_not_allowed_in_enums); + } + else if (isNumericLiteralName(member.name.text)) { + error(member.name, ts.Diagnostics.An_enum_member_cannot_have_a_numeric_name); + } + var previousEnumMemberIsNonConstant = autoValue === undefined; + var initializer = member.initializer; + if (initializer) { + autoValue = computeConstantValueForEnumMemberInitializer(initializer, enumType, enumIsConst, ambient); + } + else if (ambient && !enumIsConst) { + // In ambient enum declarations that specify no const modifier, enum member declarations + // that omit a value are considered computed members (as opposed to having auto-incremented values assigned). + autoValue = undefined; + } + else if (previousEnumMemberIsNonConstant) { + // If the member declaration specifies no value, the member is considered a constant enum member. + // If the member is the first member in the enum declaration, it is assigned the value zero. + // Otherwise, it is assigned the value of the immediately preceding member plus one, + // and an error occurs if the immediately preceding member is not a constant enum member + error(member.name, ts.Diagnostics.Enum_member_must_have_initializer); + } + if (autoValue !== undefined) { + getNodeLinks(member).enumMemberValue = autoValue++; + } + } + nodeLinks.flags |= 8192 /* EnumValuesComputed */; + } + function computeConstantValueForEnumMemberInitializer(initializer, enumType, enumIsConst, ambient) { + // Controls if error should be reported after evaluation of constant value is completed + // Can be false if another more precise error was already reported during evaluation. + var reportError = true; + var value = evalConstant(initializer); + if (reportError) { + if (value === undefined) { + if (enumIsConst) { + error(initializer, ts.Diagnostics.In_const_enum_declarations_member_initializer_must_be_constant_expression); + } + else if (ambient) { + error(initializer, ts.Diagnostics.In_ambient_enum_declarations_member_initializer_must_be_constant_expression); + } + else { + // Only here do we need to check that the initializer is assignable to the enum type. + checkTypeAssignableTo(checkExpression(initializer), enumType, initializer, /*headMessage*/ undefined); + } + } + else if (enumIsConst) { + if (isNaN(value)) { + error(initializer, ts.Diagnostics.const_enum_member_initializer_was_evaluated_to_disallowed_value_NaN); + } + else if (!isFinite(value)) { + error(initializer, ts.Diagnostics.const_enum_member_initializer_was_evaluated_to_a_non_finite_value); + } + } + } + return value; + function evalConstant(e) { + switch (e.kind) { + case 179 /* 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; + } + return undefined; + case 181 /* BinaryExpression */: + var left = evalConstant(e.left); + if (left === undefined) { + return undefined; + } + var right = evalConstant(e.right); + if (right === undefined) { + 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; + } + return undefined; + case 8 /* NumericLiteral */: + return +e.text; + case 172 /* ParenthesizedExpression */: + return evalConstant(e.expression); + case 69 /* Identifier */: + case 167 /* ElementAccessExpression */: + case 166 /* PropertyAccessExpression */: + var member = initializer.parent; + var currentType = getTypeOfSymbol(getSymbolOfNode(member.parent)); + var enumType_1; + var propertyName; + if (e.kind === 69 /* Identifier */) { + // unqualified names can refer to member that reside in different declaration of the enum so just doing name resolution won't work. + // instead pick current enum type and later try to fetch member from the type + enumType_1 = currentType; + propertyName = e.text; + } + else { + var expression; + if (e.kind === 167 /* ElementAccessExpression */) { + if (e.argumentExpression === undefined || + e.argumentExpression.kind !== 9 /* StringLiteral */) { + return undefined; + } + expression = e.expression; + propertyName = e.argumentExpression.text; + } + else { + expression = e.expression; + propertyName = e.name.text; + } + // expression part in ElementAccess\PropertyAccess should be either identifier or dottedName + var current = expression; + while (current) { + if (current.kind === 69 /* Identifier */) { + break; + } + else if (current.kind === 166 /* PropertyAccessExpression */) { + current = current.expression; + } + else { + return undefined; + } + } + enumType_1 = checkExpression(expression); + // allow references to constant members of other enums + if (!(enumType_1.symbol && (enumType_1.symbol.flags & 384 /* Enum */))) { + return undefined; + } + } + if (propertyName === undefined) { + return undefined; + } + var property = getPropertyOfObjectType(enumType_1, propertyName); + if (!property || !(property.flags & 8 /* EnumMember */)) { + return undefined; + } + var propertyDecl = property.valueDeclaration; + // self references are illegal + if (member === propertyDecl) { + return undefined; + } + // illegal case: forward reference + if (!isBlockScopedNameDeclaredBeforeUse(propertyDecl, member)) { + reportError = false; + error(e, ts.Diagnostics.A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_enums); + return undefined; + } + return getNodeLinks(propertyDecl).enumMemberValue; + } + } + } + } + function checkEnumDeclaration(node) { + if (!produceDiagnostics) { + return; + } + // Grammar checking + checkGrammarDecorators(node) || checkGrammarModifiers(node); + checkTypeNameIsReserved(node.name, ts.Diagnostics.Enum_name_cannot_be_0); + checkCollisionWithCapturedThisVariable(node, node.name); + checkCollisionWithRequireExportsInGeneratedCode(node, node.name); + checkExportsOnMergedDeclarations(node); + computeEnumMemberValues(node); + var enumIsConst = ts.isConst(node); + if (compilerOptions.isolatedModules && enumIsConst && ts.isInAmbientContext(node)) { + error(node.name, ts.Diagnostics.Ambient_const_enums_are_not_allowed_when_the_isolatedModules_flag_is_provided); + } + // Spec 2014 - Section 9.3: + // It isn't possible for one enum declaration to continue the automatic numbering sequence of another, + // and when an enum type has multiple declarations, only one declaration is permitted to omit a value + // for the first member. + // + // Only perform this check once per symbol + var enumSymbol = getSymbolOfNode(node); + var firstDeclaration = ts.getDeclarationOfKind(enumSymbol, node.kind); + if (node === firstDeclaration) { + if (enumSymbol.declarations.length > 1) { + // check that const is placed\omitted on all enum declarations + ts.forEach(enumSymbol.declarations, function (decl) { + if (ts.isConstEnumDeclaration(decl) !== enumIsConst) { + error(decl.name, ts.Diagnostics.Enum_declarations_must_all_be_const_or_non_const); + } + }); + } + var seenEnumMissingInitialInitializer = false; + ts.forEach(enumSymbol.declarations, function (declaration) { + // return true if we hit a violation of the rule, false otherwise + if (declaration.kind !== 217 /* EnumDeclaration */) { + return false; + } + var enumDeclaration = declaration; + if (!enumDeclaration.members.length) { + return false; + } + var firstEnumMember = enumDeclaration.members[0]; + if (!firstEnumMember.initializer) { + if (seenEnumMissingInitialInitializer) { + error(firstEnumMember.name, ts.Diagnostics.In_an_enum_with_multiple_declarations_only_one_declaration_can_omit_an_initializer_for_its_first_enum_element); + } + else { + seenEnumMissingInitialInitializer = true; + } + } + }); + } + } + function getFirstNonAmbientClassOrFunctionDeclaration(symbol) { + var declarations = symbol.declarations; + for (var _i = 0; _i < declarations.length; _i++) { + var declaration = declarations[_i]; + if ((declaration.kind === 214 /* ClassDeclaration */ || + (declaration.kind === 213 /* FunctionDeclaration */ && ts.nodeIsPresent(declaration.body))) && + !ts.isInAmbientContext(declaration)) { + return declaration; + } + } + return undefined; + } + function inSameLexicalScope(node1, node2) { + var container1 = ts.getEnclosingBlockScopeContainer(node1); + var container2 = ts.getEnclosingBlockScopeContainer(node2); + if (isGlobalSourceFile(container1)) { + return isGlobalSourceFile(container2); + } + else if (isGlobalSourceFile(container2)) { + return false; + } + else { + return container1 === container2; + } + } + function checkModuleDeclaration(node) { + if (produceDiagnostics) { + // Grammar checking + var isAmbientExternalModule = node.name.kind === 9 /* StringLiteral */; + var contextErrorMessage = isAmbientExternalModule + ? ts.Diagnostics.An_ambient_module_declaration_is_only_allowed_at_the_top_level_in_a_file + : ts.Diagnostics.A_namespace_declaration_is_only_allowed_in_a_namespace_or_module; + if (checkGrammarModuleElementContext(node, contextErrorMessage)) { + // If we hit a module declaration in an illegal context, just bail out to avoid cascading errors. + return; + } + if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node)) { + if (!ts.isInAmbientContext(node) && node.name.kind === 9 /* StringLiteral */) { + grammarErrorOnNode(node.name, ts.Diagnostics.Only_ambient_modules_can_use_quoted_names); + } + } + checkCollisionWithCapturedThisVariable(node, node.name); + checkCollisionWithRequireExportsInGeneratedCode(node, node.name); + checkExportsOnMergedDeclarations(node); + var symbol = getSymbolOfNode(node); + // The following checks only apply on a non-ambient instantiated module declaration. + if (symbol.flags & 512 /* ValueModule */ + && symbol.declarations.length > 1 + && !ts.isInAmbientContext(node) + && ts.isInstantiatedModule(node, compilerOptions.preserveConstEnums || compilerOptions.isolatedModules)) { + var firstNonAmbientClassOrFunc = getFirstNonAmbientClassOrFunctionDeclaration(symbol); + if (firstNonAmbientClassOrFunc) { + if (ts.getSourceFileOfNode(node) !== ts.getSourceFileOfNode(firstNonAmbientClassOrFunc)) { + error(node.name, ts.Diagnostics.A_namespace_declaration_cannot_be_in_a_different_file_from_a_class_or_function_with_which_it_is_merged); + } + else if (node.pos < firstNonAmbientClassOrFunc.pos) { + error(node.name, ts.Diagnostics.A_namespace_declaration_cannot_be_located_prior_to_a_class_or_function_with_which_it_is_merged); + } + } + // 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, 214 /* ClassDeclaration */); + if (mergedClass && + inSameLexicalScope(node, mergedClass)) { + getNodeLinks(node).flags |= 32768 /* LexicalModuleMergesWithClass */; + } + } + // Checks for ambient external modules. + if (isAmbientExternalModule) { + if (!isGlobalSourceFile(node.parent)) { + error(node.name, ts.Diagnostics.Ambient_modules_cannot_be_nested_in_other_modules_or_namespaces); + } + if (ts.isExternalModuleNameRelative(node.name.text)) { + error(node.name, ts.Diagnostics.Ambient_module_declaration_cannot_specify_relative_module_name); + } + } + } + checkSourceElement(node.body); + } + function getFirstIdentifier(node) { + while (true) { + if (node.kind === 135 /* QualifiedName */) { + node = node.left; + } + else if (node.kind === 166 /* PropertyAccessExpression */) { + node = node.expression; + } + else { + break; + } + } + ts.Debug.assert(node.kind === 69 /* Identifier */); + return node; + } + function checkExternalImportOrExportDeclaration(node) { + var moduleName = ts.getExternalModuleName(node); + if (!ts.nodeIsMissing(moduleName) && moduleName.kind !== 9 /* StringLiteral */) { + error(moduleName, ts.Diagnostics.String_literal_expected); + return false; + } + var inAmbientExternalModule = node.parent.kind === 219 /* ModuleBlock */ && node.parent.parent.name.kind === 9 /* StringLiteral */; + if (node.parent.kind !== 248 /* SourceFile */ && !inAmbientExternalModule) { + error(moduleName, node.kind === 228 /* ExportDeclaration */ ? + ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace : + ts.Diagnostics.Import_declarations_in_a_namespace_cannot_reference_a_module); + return false; + } + if (inAmbientExternalModule && ts.isExternalModuleNameRelative(moduleName.text)) { + // TypeScript 1.0 spec (April 2013): 12.1.6 + // An ExternalImportDeclaration in an AmbientExternalModuleDeclaration may reference + // other external modules only through top - level external module names. + // Relative external module names are not permitted. + error(node, ts.Diagnostics.Import_or_export_declaration_in_an_ambient_module_declaration_cannot_reference_module_through_relative_module_name); + return false; + } + return true; + } + function checkAliasSymbol(node) { + var symbol = getSymbolOfNode(node); + var target = resolveAlias(symbol); + if (target !== unknownSymbol) { + var excludedMeanings = (symbol.flags & 107455 /* Value */ ? 107455 /* Value */ : 0) | + (symbol.flags & 793056 /* Type */ ? 793056 /* Type */ : 0) | + (symbol.flags & 1536 /* Namespace */ ? 1536 /* Namespace */ : 0); + if (target.flags & excludedMeanings) { + var message = node.kind === 230 /* ExportSpecifier */ ? + ts.Diagnostics.Export_declaration_conflicts_with_exported_declaration_of_0 : + ts.Diagnostics.Import_declaration_conflicts_with_local_declaration_of_0; + error(node, message, symbolToString(symbol)); + } + } + } + function checkImportBinding(node) { + checkCollisionWithCapturedThisVariable(node, node.name); + checkCollisionWithRequireExportsInGeneratedCode(node, node.name); + checkAliasSymbol(node); + } + function checkImportDeclaration(node) { + if (checkGrammarModuleElementContext(node, ts.Diagnostics.An_import_declaration_can_only_be_used_in_a_namespace_or_module)) { + // If we hit an import declaration in an illegal context, just bail out to avoid cascading errors. + return; + } + if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && (node.flags & 2035 /* Modifier */)) { + grammarErrorOnFirstToken(node, ts.Diagnostics.An_import_declaration_cannot_have_modifiers); + } + if (checkExternalImportOrExportDeclaration(node)) { + var importClause = node.importClause; + if (importClause) { + if (importClause.name) { + checkImportBinding(importClause); + } + if (importClause.namedBindings) { + if (importClause.namedBindings.kind === 224 /* NamespaceImport */) { + checkImportBinding(importClause.namedBindings); + } + else { + ts.forEach(importClause.namedBindings.elements, checkImportBinding); + } + } + } + } + } + function checkImportEqualsDeclaration(node) { + if (checkGrammarModuleElementContext(node, ts.Diagnostics.An_import_declaration_can_only_be_used_in_a_namespace_or_module)) { + // If we hit an import declaration in an illegal context, just bail out to avoid cascading errors. + return; + } + checkGrammarDecorators(node) || checkGrammarModifiers(node); + if (ts.isInternalModuleImportEqualsDeclaration(node) || checkExternalImportOrExportDeclaration(node)) { + checkImportBinding(node); + if (node.flags & 1 /* Export */) { + markExportAsReferenced(node); + } + if (ts.isInternalModuleImportEqualsDeclaration(node)) { + var target = resolveAlias(getSymbolOfNode(node)); + if (target !== unknownSymbol) { + if (target.flags & 107455 /* Value */) { + // Target is a value symbol, check that it is not hidden by a local declaration with the same name + var moduleName = getFirstIdentifier(node.moduleReference); + if (!(resolveEntityName(moduleName, 107455 /* Value */ | 1536 /* Namespace */).flags & 1536 /* Namespace */)) { + error(moduleName, ts.Diagnostics.Module_0_is_hidden_by_a_local_declaration_with_the_same_name, ts.declarationNameToString(moduleName)); + } + } + if (target.flags & 793056 /* Type */) { + checkTypeNameIsReserved(node.name, ts.Diagnostics.Import_name_cannot_be_0); + } + } + } + else { + if (modulekind === 5 /* ES6 */ && !ts.isInAmbientContext(node)) { + // Import equals declaration is deprecated in es6 or above + grammarErrorOnNode(node, ts.Diagnostics.Import_assignment_cannot_be_used_when_targeting_ECMAScript_6_modules_Consider_using_import_Asterisk_as_ns_from_mod_import_a_from_mod_import_d_from_mod_or_another_module_format_instead); + } + } + } + } + function checkExportDeclaration(node) { + if (checkGrammarModuleElementContext(node, ts.Diagnostics.An_export_declaration_can_only_be_used_in_a_module)) { + // If we hit an export in an illegal context, just bail out to avoid cascading errors. + return; + } + if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && (node.flags & 2035 /* Modifier */)) { + grammarErrorOnFirstToken(node, ts.Diagnostics.An_export_declaration_cannot_have_modifiers); + } + if (!node.moduleSpecifier || checkExternalImportOrExportDeclaration(node)) { + if (node.exportClause) { + // export { x, y } + // export { x, y } from "foo" + ts.forEach(node.exportClause.elements, checkExportSpecifier); + var inAmbientExternalModule = node.parent.kind === 219 /* ModuleBlock */ && node.parent.parent.name.kind === 9 /* StringLiteral */; + if (node.parent.kind !== 248 /* SourceFile */ && !inAmbientExternalModule) { + error(node, ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace); + } + } + else { + // export * from "foo" + var moduleSymbol = resolveExternalModuleName(node, node.moduleSpecifier); + if (moduleSymbol && moduleSymbol.exports["export="]) { + error(node.moduleSpecifier, ts.Diagnostics.Module_0_uses_export_and_cannot_be_used_with_export_Asterisk, symbolToString(moduleSymbol)); + } + } + } + } + function checkGrammarModuleElementContext(node, errorMessage) { + if (node.parent.kind !== 248 /* SourceFile */ && node.parent.kind !== 219 /* ModuleBlock */ && node.parent.kind !== 218 /* ModuleDeclaration */) { + return grammarErrorOnFirstToken(node, errorMessage); + } + } + function checkExportSpecifier(node) { + checkAliasSymbol(node); + if (!node.parent.parent.moduleSpecifier) { + markExportAsReferenced(node); + } + } + function checkExportAssignment(node) { + if (checkGrammarModuleElementContext(node, ts.Diagnostics.An_export_assignment_can_only_be_used_in_a_module)) { + // If we hit an export assignment in an illegal context, just bail out to avoid cascading errors. + return; + } + var container = node.parent.kind === 248 /* SourceFile */ ? node.parent : node.parent.parent; + if (container.kind === 218 /* ModuleDeclaration */ && container.name.kind === 69 /* Identifier */) { + error(node, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_namespace); + return; + } + // Grammar checking + if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && (node.flags & 2035 /* Modifier */)) { + grammarErrorOnFirstToken(node, ts.Diagnostics.An_export_assignment_cannot_have_modifiers); + } + if (node.expression.kind === 69 /* Identifier */) { + markExportAsReferenced(node); + } + else { + checkExpressionCached(node.expression); + } + checkExternalModuleExports(container); + if (node.isExportEquals && !ts.isInAmbientContext(node)) { + if (modulekind === 5 /* ES6 */) { + // export assignment is not supported in es6 modules + grammarErrorOnNode(node, ts.Diagnostics.Export_assignment_cannot_be_used_when_targeting_ECMAScript_6_modules_Consider_using_export_default_or_another_module_format_instead); + } + else if (modulekind === 4 /* System */) { + // system modules does not support export assignment + grammarErrorOnNode(node, ts.Diagnostics.Export_assignment_is_not_supported_when_module_flag_is_system); + } + } + } + function getModuleStatements(node) { + if (node.kind === 248 /* SourceFile */) { + return node.statements; + } + if (node.kind === 218 /* ModuleDeclaration */ && node.body.kind === 219 /* ModuleBlock */) { + return node.body.statements; + } + return emptyArray; + } + function hasExportedMembers(moduleSymbol) { + for (var id in moduleSymbol.exports) { + if (id !== "export=") { + return true; + } + } + return false; + } + function checkExternalModuleExports(node) { + var moduleSymbol = getSymbolOfNode(node); + var links = getSymbolLinks(moduleSymbol); + if (!links.exportsChecked) { + var exportEqualsSymbol = moduleSymbol.exports["export="]; + if (exportEqualsSymbol && hasExportedMembers(moduleSymbol)) { + var declaration = getDeclarationOfAliasSymbol(exportEqualsSymbol) || exportEqualsSymbol.valueDeclaration; + error(declaration, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_module_with_other_exported_elements); + } + links.exportsChecked = true; + } + } + function checkTypePredicate(node) { + if (!isInLegalTypePredicatePosition(node)) { + error(node, ts.Diagnostics.A_type_predicate_is_only_allowed_in_return_type_position_for_functions_and_methods); + } + } + function checkSourceElement(node) { + if (!node) { + return; + } + var kind = node.kind; + if (cancellationToken) { + // Only bother checking on a few construct kinds. We don't want to be excessivly + // hitting the cancellation token on every node we check. + switch (kind) { + case 218 /* ModuleDeclaration */: + case 214 /* ClassDeclaration */: + case 215 /* InterfaceDeclaration */: + case 213 /* FunctionDeclaration */: + cancellationToken.throwIfCancellationRequested(); + } + } + switch (kind) { + case 137 /* TypeParameter */: + return checkTypeParameter(node); + case 138 /* Parameter */: + return checkParameter(node); + case 141 /* PropertyDeclaration */: + case 140 /* PropertySignature */: + return checkPropertyDeclaration(node); + case 152 /* FunctionType */: + case 153 /* ConstructorType */: + case 147 /* CallSignature */: + case 148 /* ConstructSignature */: + return checkSignatureDeclaration(node); + case 149 /* IndexSignature */: + return checkSignatureDeclaration(node); + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: + return checkMethodDeclaration(node); + case 144 /* Constructor */: + return checkConstructorDeclaration(node); + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: + return checkAccessorDeclaration(node); + case 151 /* TypeReference */: + return checkTypeReferenceNode(node); + case 150 /* TypePredicate */: + return checkTypePredicate(node); + case 154 /* TypeQuery */: + return checkTypeQuery(node); + case 155 /* TypeLiteral */: + return checkTypeLiteral(node); + case 156 /* ArrayType */: + return checkArrayType(node); + case 157 /* TupleType */: + return checkTupleType(node); + case 158 /* UnionType */: + case 159 /* IntersectionType */: + return checkUnionOrIntersectionType(node); + case 160 /* ParenthesizedType */: + return checkSourceElement(node.type); + case 213 /* FunctionDeclaration */: + return checkFunctionDeclaration(node); + case 192 /* Block */: + case 219 /* ModuleBlock */: + return checkBlock(node); + case 193 /* VariableStatement */: + return checkVariableStatement(node); + case 195 /* ExpressionStatement */: + return checkExpressionStatement(node); + case 196 /* IfStatement */: + return checkIfStatement(node); + case 197 /* DoStatement */: + return checkDoStatement(node); + case 198 /* WhileStatement */: + return checkWhileStatement(node); + case 199 /* ForStatement */: + return checkForStatement(node); + case 200 /* ForInStatement */: + return checkForInStatement(node); + case 201 /* ForOfStatement */: + return checkForOfStatement(node); + case 202 /* ContinueStatement */: + case 203 /* BreakStatement */: + return checkBreakOrContinueStatement(node); + case 204 /* ReturnStatement */: + return checkReturnStatement(node); + case 205 /* WithStatement */: + return checkWithStatement(node); + case 206 /* SwitchStatement */: + return checkSwitchStatement(node); + case 207 /* LabeledStatement */: + return checkLabeledStatement(node); + case 208 /* ThrowStatement */: + return checkThrowStatement(node); + case 209 /* TryStatement */: + return checkTryStatement(node); + case 211 /* VariableDeclaration */: + return checkVariableDeclaration(node); + case 163 /* BindingElement */: + return checkBindingElement(node); + case 214 /* ClassDeclaration */: + return checkClassDeclaration(node); + case 215 /* InterfaceDeclaration */: + return checkInterfaceDeclaration(node); + case 216 /* TypeAliasDeclaration */: + return checkTypeAliasDeclaration(node); + case 217 /* EnumDeclaration */: + return checkEnumDeclaration(node); + case 218 /* ModuleDeclaration */: + return checkModuleDeclaration(node); + case 222 /* ImportDeclaration */: + return checkImportDeclaration(node); + case 221 /* ImportEqualsDeclaration */: + return checkImportEqualsDeclaration(node); + case 228 /* ExportDeclaration */: + return checkExportDeclaration(node); + case 227 /* ExportAssignment */: + return checkExportAssignment(node); + case 194 /* EmptyStatement */: + checkGrammarStatementInAmbientContext(node); + return; + case 210 /* DebuggerStatement */: + checkGrammarStatementInAmbientContext(node); + return; + case 231 /* MissingDeclaration */: + return checkMissingDeclaration(node); + } + } + // Function and class expression bodies are checked after all statements in the enclosing body. This is + // to ensure constructs like the following are permitted: + // let foo = function () { + // let s = foo(); + // return "hello"; + // } + // Here, performing a full type check of the body of the function expression whilst in the process of + // determining the type of foo would cause foo to be given type any because of the recursive reference. + // Delaying the type check of the body ensures foo has been assigned a type. + function checkFunctionAndClassExpressionBodies(node) { + switch (node.kind) { + case 173 /* FunctionExpression */: + case 174 /* ArrowFunction */: + ts.forEach(node.parameters, checkFunctionAndClassExpressionBodies); + checkFunctionExpressionOrObjectLiteralMethodBody(node); + break; + case 186 /* ClassExpression */: + ts.forEach(node.members, checkSourceElement); + ts.forEachChild(node, checkFunctionAndClassExpressionBodies); + break; + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: + ts.forEach(node.decorators, checkFunctionAndClassExpressionBodies); + ts.forEach(node.parameters, checkFunctionAndClassExpressionBodies); + if (ts.isObjectLiteralMethod(node)) { + checkFunctionExpressionOrObjectLiteralMethodBody(node); + } + break; + case 144 /* Constructor */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: + case 213 /* FunctionDeclaration */: + ts.forEach(node.parameters, checkFunctionAndClassExpressionBodies); + break; + case 205 /* WithStatement */: + checkFunctionAndClassExpressionBodies(node.expression); + break; + case 139 /* Decorator */: + case 138 /* Parameter */: + case 141 /* PropertyDeclaration */: + case 140 /* PropertySignature */: + case 161 /* ObjectBindingPattern */: + case 162 /* ArrayBindingPattern */: + case 163 /* BindingElement */: + case 164 /* ArrayLiteralExpression */: + case 165 /* ObjectLiteralExpression */: + case 245 /* PropertyAssignment */: + case 166 /* PropertyAccessExpression */: + case 167 /* ElementAccessExpression */: + case 168 /* CallExpression */: + case 169 /* NewExpression */: + case 170 /* TaggedTemplateExpression */: + case 183 /* TemplateExpression */: + case 190 /* TemplateSpan */: + case 171 /* TypeAssertionExpression */: + case 189 /* AsExpression */: + case 172 /* ParenthesizedExpression */: + case 176 /* TypeOfExpression */: + case 177 /* VoidExpression */: + case 178 /* AwaitExpression */: + case 175 /* DeleteExpression */: + case 179 /* PrefixUnaryExpression */: + case 180 /* PostfixUnaryExpression */: + case 181 /* BinaryExpression */: + case 182 /* ConditionalExpression */: + case 185 /* SpreadElementExpression */: + case 184 /* YieldExpression */: + case 192 /* Block */: + case 219 /* ModuleBlock */: + case 193 /* VariableStatement */: + case 195 /* ExpressionStatement */: + case 196 /* IfStatement */: + case 197 /* DoStatement */: + case 198 /* WhileStatement */: + case 199 /* ForStatement */: + case 200 /* ForInStatement */: + case 201 /* ForOfStatement */: + case 202 /* ContinueStatement */: + case 203 /* BreakStatement */: + case 204 /* ReturnStatement */: + case 206 /* SwitchStatement */: + case 220 /* CaseBlock */: + case 241 /* CaseClause */: + case 242 /* DefaultClause */: + case 207 /* LabeledStatement */: + case 208 /* ThrowStatement */: + case 209 /* TryStatement */: + case 244 /* CatchClause */: + case 211 /* VariableDeclaration */: + case 212 /* VariableDeclarationList */: + case 214 /* ClassDeclaration */: + case 243 /* HeritageClause */: + case 188 /* ExpressionWithTypeArguments */: + case 217 /* EnumDeclaration */: + case 247 /* EnumMember */: + case 227 /* ExportAssignment */: + case 248 /* SourceFile */: + case 240 /* JsxExpression */: + case 233 /* JsxElement */: + case 234 /* JsxSelfClosingElement */: + case 238 /* JsxAttribute */: + case 239 /* JsxSpreadAttribute */: + case 235 /* JsxOpeningElement */: + ts.forEachChild(node, checkFunctionAndClassExpressionBodies); + break; + } + } + function checkSourceFile(node) { + var start = new Date().getTime(); + checkSourceFileWorker(node); + ts.checkTime += new Date().getTime() - start; + } + // Fully type check a source file and collect the relevant diagnostics. + function checkSourceFileWorker(node) { + var links = getNodeLinks(node); + if (!(links.flags & 1 /* TypeChecked */)) { + // Check whether the file has declared it is the default lib, + // and whether the user has specifically chosen to avoid checking it. + if (node.isDefaultLib && compilerOptions.skipDefaultLibCheck) { + return; + } + // Grammar checking + checkGrammarSourceFile(node); + emitExtends = false; + emitDecorate = false; + emitParam = false; + potentialThisCollisions.length = 0; + ts.forEach(node.statements, checkSourceElement); + checkFunctionAndClassExpressionBodies(node); + if (ts.isExternalModule(node)) { + checkExternalModuleExports(node); + } + if (potentialThisCollisions.length) { + ts.forEach(potentialThisCollisions, checkIfThisIsCapturedInEnclosingScope); + potentialThisCollisions.length = 0; + } + if (emitExtends) { + links.flags |= 8 /* EmitExtends */; + } + if (emitDecorate) { + links.flags |= 16 /* EmitDecorate */; + } + if (emitParam) { + links.flags |= 32 /* EmitParam */; + } + if (emitAwaiter) { + links.flags |= 64 /* EmitAwaiter */; + } + if (emitGenerator || (emitAwaiter && languageVersion < 2 /* ES6 */)) { + links.flags |= 128 /* EmitGenerator */; + } + links.flags |= 1 /* TypeChecked */; + } + } + function getDiagnostics(sourceFile, ct) { + try { + // Record the cancellation token so it can be checked later on during checkSourceElement. + // Do this in a finally block so we can ensure that it gets reset back to nothing after + // this call is done. + cancellationToken = ct; + return getDiagnosticsWorker(sourceFile); + } + finally { + cancellationToken = undefined; + } + } + function getDiagnosticsWorker(sourceFile) { + throwIfNonDiagnosticsProducing(); + if (sourceFile) { + checkSourceFile(sourceFile); + return diagnostics.getDiagnostics(sourceFile.fileName); + } + ts.forEach(host.getSourceFiles(), checkSourceFile); + return diagnostics.getDiagnostics(); + } + function getGlobalDiagnostics() { + throwIfNonDiagnosticsProducing(); + return diagnostics.getGlobalDiagnostics(); + } + function throwIfNonDiagnosticsProducing() { + if (!produceDiagnostics) { + throw new Error("Trying to get diagnostics from a type checker that does not produce them."); + } + } + // Language service support + function isInsideWithStatementBody(node) { + if (node) { + while (node.parent) { + if (node.parent.kind === 205 /* WithStatement */ && node.parent.statement === node) { + return true; + } + node = node.parent; + } + } + return false; + } + function getSymbolsInScope(location, meaning) { + var symbols = {}; + var memberFlags = 0; + if (isInsideWithStatementBody(location)) { + // We cannot answer semantic questions within a with block, do not proceed any further + return []; + } + populateSymbols(); + return symbolsToArray(symbols); + function populateSymbols() { + while (location) { + if (location.locals && !isGlobalSourceFile(location)) { + copySymbols(location.locals, meaning); + } + switch (location.kind) { + case 248 /* SourceFile */: + if (!ts.isExternalModule(location)) { + break; + } + case 218 /* ModuleDeclaration */: + copySymbols(getSymbolOfNode(location).exports, meaning & 8914931 /* ModuleMember */); + break; + case 217 /* EnumDeclaration */: + copySymbols(getSymbolOfNode(location).exports, meaning & 8 /* EnumMember */); + break; + case 186 /* ClassExpression */: + var className = location.name; + if (className) { + copySymbol(location.symbol, meaning); + } + // fall through; this fall-through is necessary because we would like to handle + // type parameter inside class expression similar to how we handle it in classDeclaration and interface Declaration + case 214 /* ClassDeclaration */: + case 215 /* InterfaceDeclaration */: + // If we didn't come from static member of class or interface, + // add the type parameters into the symbol table + // (type parameters of classDeclaration/classExpression and interface are in member property of the symbol. + // Note: that the memberFlags come from previous iteration. + if (!(memberFlags & 128 /* Static */)) { + copySymbols(getSymbolOfNode(location).members, meaning & 793056 /* Type */); + } + break; + case 173 /* FunctionExpression */: + var funcName = location.name; + if (funcName) { + copySymbol(location.symbol, meaning); + } + break; + } + if (ts.introducesArgumentsExoticObject(location)) { + copySymbol(argumentsSymbol, meaning); + } + memberFlags = location.flags; + location = location.parent; + } + copySymbols(globals, meaning); + } + /** + * Copy the given symbol into symbol tables if the symbol has the given meaning + * and it doesn't already existed in the symbol table + * @param key a key for storing in symbol table; if undefined, use symbol.name + * @param symbol the symbol to be added into symbol table + * @param meaning meaning of symbol to filter by before adding to symbol table + */ + function copySymbol(symbol, meaning) { + if (symbol.flags & meaning) { + var id = symbol.name; + // We will copy all symbol regardless of its reserved name because + // symbolsToArray will check whether the key is a reserved name and + // it will not copy symbol with reserved name to the array + if (!ts.hasProperty(symbols, id)) { + symbols[id] = symbol; + } + } + } + function copySymbols(source, meaning) { + if (meaning) { + for (var id in source) { + var symbol = source[id]; + copySymbol(symbol, meaning); + } + } + } + } + function isTypeDeclarationName(name) { + return name.kind === 69 /* Identifier */ && + isTypeDeclaration(name.parent) && + name.parent.name === name; + } + function isTypeDeclaration(node) { + switch (node.kind) { + case 137 /* TypeParameter */: + case 214 /* ClassDeclaration */: + case 215 /* InterfaceDeclaration */: + case 216 /* TypeAliasDeclaration */: + case 217 /* EnumDeclaration */: + return true; + } + } + // True if the given identifier is part of a type reference + function isTypeReferenceIdentifier(entityName) { + var node = entityName; + while (node.parent && node.parent.kind === 135 /* QualifiedName */) { + node = node.parent; + } + return node.parent && node.parent.kind === 151 /* TypeReference */; + } + function isHeritageClauseElementIdentifier(entityName) { + var node = entityName; + while (node.parent && node.parent.kind === 166 /* PropertyAccessExpression */) { + node = node.parent; + } + return node.parent && node.parent.kind === 188 /* ExpressionWithTypeArguments */; + } + function getLeftSideOfImportEqualsOrExportAssignment(nodeOnRightSide) { + while (nodeOnRightSide.parent.kind === 135 /* QualifiedName */) { + nodeOnRightSide = nodeOnRightSide.parent; + } + if (nodeOnRightSide.parent.kind === 221 /* ImportEqualsDeclaration */) { + return nodeOnRightSide.parent.moduleReference === nodeOnRightSide && nodeOnRightSide.parent; + } + if (nodeOnRightSide.parent.kind === 227 /* ExportAssignment */) { + return nodeOnRightSide.parent.expression === nodeOnRightSide && nodeOnRightSide.parent; + } + return undefined; + } + function isInRightSideOfImportOrExportAssignment(node) { + return getLeftSideOfImportEqualsOrExportAssignment(node) !== undefined; + } + function getSymbolOfEntityNameOrPropertyAccessExpression(entityName) { + if (ts.isDeclarationName(entityName)) { + return getSymbolOfNode(entityName.parent); + } + if (entityName.parent.kind === 227 /* ExportAssignment */) { + return resolveEntityName(entityName, + /*all meanings*/ 107455 /* Value */ | 793056 /* Type */ | 1536 /* Namespace */ | 8388608 /* Alias */); + } + if (entityName.kind !== 166 /* PropertyAccessExpression */) { + if (isInRightSideOfImportOrExportAssignment(entityName)) { + // Since we already checked for ExportAssignment, this really could only be an Import + return getSymbolOfPartOfRightHandSideOfImportEquals(entityName); + } + } + if (ts.isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { + entityName = entityName.parent; + } + if (isHeritageClauseElementIdentifier(entityName)) { + var meaning = 0 /* None */; + // In an interface or class, we're definitely interested in a type. + if (entityName.parent.kind === 188 /* ExpressionWithTypeArguments */) { + meaning = 793056 /* Type */; + // In a class 'extends' clause we are also looking for a value. + if (ts.isExpressionWithTypeArgumentsInClassExtendsClause(entityName.parent)) { + meaning |= 107455 /* Value */; + } + } + else { + meaning = 1536 /* Namespace */; + } + meaning |= 8388608 /* Alias */; + return resolveEntityName(entityName, meaning); + } + else if ((entityName.parent.kind === 235 /* JsxOpeningElement */) || + (entityName.parent.kind === 234 /* JsxSelfClosingElement */) || + (entityName.parent.kind === 237 /* JsxClosingElement */)) { + return getJsxElementTagSymbol(entityName.parent); + } + else if (ts.isExpression(entityName)) { + if (ts.nodeIsMissing(entityName)) { + // Missing entity name. + return undefined; + } + if (entityName.kind === 69 /* Identifier */) { + // Include aliases in the meaning, this ensures that we do not follow aliases to where they point and instead + // return the alias symbol. + var meaning = 107455 /* Value */ | 8388608 /* Alias */; + return resolveEntityName(entityName, meaning); + } + else if (entityName.kind === 166 /* PropertyAccessExpression */) { + var symbol = getNodeLinks(entityName).resolvedSymbol; + if (!symbol) { + checkPropertyAccessExpression(entityName); + } + return getNodeLinks(entityName).resolvedSymbol; + } + else if (entityName.kind === 135 /* QualifiedName */) { + var symbol = getNodeLinks(entityName).resolvedSymbol; + if (!symbol) { + checkQualifiedName(entityName); + } + return getNodeLinks(entityName).resolvedSymbol; + } + } + else if (isTypeReferenceIdentifier(entityName)) { + var meaning = entityName.parent.kind === 151 /* TypeReference */ ? 793056 /* Type */ : 1536 /* Namespace */; + // Include aliases in the meaning, this ensures that we do not follow aliases to where they point and instead + // return the alias symbol. + meaning |= 8388608 /* Alias */; + return resolveEntityName(entityName, meaning); + } + else if (entityName.parent.kind === 238 /* JsxAttribute */) { + return getJsxAttributePropertySymbol(entityName.parent); + } + if (entityName.parent.kind === 150 /* TypePredicate */) { + return resolveEntityName(entityName, /*meaning*/ 1 /* FunctionScopedVariable */); + } + // Do we want to return undefined here? + return undefined; + } + function getSymbolAtLocation(node) { + if (isInsideWithStatementBody(node)) { + // We cannot answer semantic questions within a with block, do not proceed any further + return undefined; + } + if (ts.isDeclarationName(node)) { + // This is a declaration, call getSymbolOfNode + return getSymbolOfNode(node.parent); + } + if (node.kind === 69 /* Identifier */) { + if (isInRightSideOfImportOrExportAssignment(node)) { + return node.parent.kind === 227 /* ExportAssignment */ + ? getSymbolOfEntityNameOrPropertyAccessExpression(node) + : getSymbolOfPartOfRightHandSideOfImportEquals(node); + } + else if (node.parent.kind === 163 /* BindingElement */ && + node.parent.parent.kind === 161 /* ObjectBindingPattern */ && + node === node.parent.propertyName) { + var typeOfPattern = getTypeOfNode(node.parent.parent); + var propertyDeclaration = typeOfPattern && getPropertyOfType(typeOfPattern, node.text); + if (propertyDeclaration) { + return propertyDeclaration; + } + } + } + switch (node.kind) { + case 69 /* Identifier */: + case 166 /* PropertyAccessExpression */: + case 135 /* QualifiedName */: + return getSymbolOfEntityNameOrPropertyAccessExpression(node); + case 97 /* ThisKeyword */: + case 95 /* SuperKeyword */: + var type = ts.isExpression(node) ? checkExpression(node) : getTypeFromTypeNode(node); + return type.symbol; + case 121 /* ConstructorKeyword */: + // constructor keyword for an overload, should take us to the definition if it exist + var constructorDeclaration = node.parent; + if (constructorDeclaration && constructorDeclaration.kind === 144 /* Constructor */) { + return constructorDeclaration.parent.symbol; + } + return undefined; + case 9 /* StringLiteral */: + // External module name in an import declaration + if ((ts.isExternalModuleImportEqualsDeclaration(node.parent.parent) && + ts.getExternalModuleImportEqualsDeclarationExpression(node.parent.parent) === node) || + ((node.parent.kind === 222 /* ImportDeclaration */ || node.parent.kind === 228 /* ExportDeclaration */) && + node.parent.moduleSpecifier === node)) { + return resolveExternalModuleName(node, node); + } + // Fall through + case 8 /* NumericLiteral */: + // index access + if (node.parent.kind === 167 /* ElementAccessExpression */ && node.parent.argumentExpression === node) { + var objectType = checkExpression(node.parent.expression); + if (objectType === unknownType) + return undefined; + var apparentType = getApparentType(objectType); + if (apparentType === unknownType) + return undefined; + return getPropertyOfType(apparentType, node.text); + } + break; + } + return undefined; + } + function getShorthandAssignmentValueSymbol(location) { + // The function returns a value symbol of an identifier in the short-hand property assignment. + // This is necessary as an identifier in short-hand property assignment can contains two meaning: + // property name and property value. + if (location && location.kind === 246 /* ShorthandPropertyAssignment */) { + return resolveEntityName(location.name, 107455 /* Value */); + } + return undefined; + } + function getTypeOfNode(node) { + if (isInsideWithStatementBody(node)) { + // We cannot answer semantic questions within a with block, do not proceed any further + return unknownType; + } + if (ts.isTypeNode(node)) { + return getTypeFromTypeNode(node); + } + if (ts.isExpression(node)) { + return getTypeOfExpression(node); + } + if (ts.isExpressionWithTypeArgumentsInClassExtendsClause(node)) { + // A SyntaxKind.ExpressionWithTypeArguments is considered a type node, except when it occurs in the + // extends clause of a class. We handle that case here. + return getBaseTypes(getDeclaredTypeOfSymbol(getSymbolOfNode(node.parent.parent)))[0]; + } + if (isTypeDeclaration(node)) { + // In this case, we call getSymbolOfNode instead of getSymbolAtLocation because it is a declaration + var symbol = getSymbolOfNode(node); + return getDeclaredTypeOfSymbol(symbol); + } + if (isTypeDeclarationName(node)) { + var symbol = getSymbolAtLocation(node); + return symbol && getDeclaredTypeOfSymbol(symbol); + } + if (ts.isDeclaration(node)) { + // In this case, we call getSymbolOfNode instead of getSymbolAtLocation because it is a declaration + var symbol = getSymbolOfNode(node); + return getTypeOfSymbol(symbol); + } + if (ts.isDeclarationName(node)) { + var symbol = getSymbolAtLocation(node); + return symbol && getTypeOfSymbol(symbol); + } + if (ts.isBindingPattern(node)) { + return getTypeForVariableLikeDeclaration(node.parent); + } + if (isInRightSideOfImportOrExportAssignment(node)) { + var symbol = getSymbolAtLocation(node); + var declaredType = symbol && getDeclaredTypeOfSymbol(symbol); + return declaredType !== unknownType ? declaredType : getTypeOfSymbol(symbol); + } + return unknownType; + } + function getTypeOfExpression(expr) { + if (ts.isRightSideOfQualifiedNameOrPropertyAccess(expr)) { + expr = expr.parent; + } + return checkExpression(expr); + } + /** + * Gets either the static or instance type of a class element, based on + * whether the element is declared as "static". + */ + function getParentTypeOfClassElement(node) { + var classSymbol = getSymbolOfNode(node.parent); + return node.flags & 128 /* Static */ + ? getTypeOfSymbol(classSymbol) + : getDeclaredTypeOfSymbol(classSymbol); + } + // Return the list of properties of the given type, augmented with properties from Function + // if the type has call or construct signatures + function getAugmentedPropertiesOfType(type) { + type = getApparentType(type); + var propsByName = createSymbolTable(getPropertiesOfType(type)); + if (getSignaturesOfType(type, 0 /* Call */).length || getSignaturesOfType(type, 1 /* Construct */).length) { + ts.forEach(getPropertiesOfType(globalFunctionType), function (p) { + if (!ts.hasProperty(propsByName, p.name)) { + propsByName[p.name] = p; + } + }); + } + return getNamedMembers(propsByName); + } + function getRootSymbols(symbol) { + if (symbol.flags & 268435456 /* SyntheticProperty */) { + var symbols = []; + var name_15 = symbol.name; + ts.forEach(getSymbolLinks(symbol).containingType.types, function (t) { + var symbol = getPropertyOfType(t, name_15); + if (symbol) { + symbols.push(symbol); + } + }); + return symbols; + } + else if (symbol.flags & 67108864 /* Transient */) { + var target = getSymbolLinks(symbol).target; + if (target) { + return [target]; + } + } + return [symbol]; + } + // Emitter support + function isArgumentsLocalBinding(node) { + return getReferencedValueSymbol(node) === argumentsSymbol; + } + // When resolved as an expression identifier, if the given node references an exported entity, return the declaration + // node of the exported entity's container. Otherwise, return undefined. + function getReferencedExportContainer(node) { + var symbol = getReferencedValueSymbol(node); + if (symbol) { + if (symbol.flags & 1048576 /* ExportValue */) { + // If we reference an exported entity within the same module declaration, then whether + // we prefix depends on the kind of entity. SymbolFlags.ExportHasLocal encompasses all the + // kinds that we do NOT prefix. + var exportSymbol = getMergedSymbol(symbol.exportSymbol); + if (exportSymbol.flags & 944 /* ExportHasLocal */) { + return undefined; + } + symbol = exportSymbol; + } + var parentSymbol = getParentOfSymbol(symbol); + if (parentSymbol) { + if (parentSymbol.flags & 512 /* ValueModule */ && parentSymbol.valueDeclaration.kind === 248 /* SourceFile */) { + return parentSymbol.valueDeclaration; + } + for (var n = node.parent; n; n = n.parent) { + if ((n.kind === 218 /* ModuleDeclaration */ || n.kind === 217 /* EnumDeclaration */) && getSymbolOfNode(n) === parentSymbol) { + return n; + } + } + } + } + } + // When resolved as an expression identifier, if the given node references an import, return the declaration of + // that import. Otherwise, return undefined. + function getReferencedImportDeclaration(node) { + var symbol = getReferencedValueSymbol(node); + return symbol && symbol.flags & 8388608 /* Alias */ ? getDeclarationOfAliasSymbol(symbol) : undefined; + } + function isStatementWithLocals(node) { + switch (node.kind) { + case 192 /* Block */: + case 220 /* CaseBlock */: + case 199 /* ForStatement */: + case 200 /* ForInStatement */: + case 201 /* ForOfStatement */: + return true; + } + return false; + } + function isNestedRedeclarationSymbol(symbol) { + if (symbol.flags & 418 /* BlockScoped */) { + var links = getSymbolLinks(symbol); + if (links.isNestedRedeclaration === undefined) { + var container = ts.getEnclosingBlockScopeContainer(symbol.valueDeclaration); + links.isNestedRedeclaration = isStatementWithLocals(container) && + !!resolveName(container.parent, symbol.name, 107455 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined); + } + return links.isNestedRedeclaration; + } + return false; + } + // When resolved as an expression identifier, if the given node references a nested block scoped entity with + // a name that hides an existing name, return the declaration of that entity. Otherwise, return undefined. + function getReferencedNestedRedeclaration(node) { + var symbol = getReferencedValueSymbol(node); + return symbol && isNestedRedeclarationSymbol(symbol) ? symbol.valueDeclaration : undefined; + } + // Return true if the given node is a declaration of a nested block scoped entity with a name that hides an + // existing name. + function isNestedRedeclaration(node) { + return isNestedRedeclarationSymbol(getSymbolOfNode(node)); + } + function isValueAliasDeclaration(node) { + switch (node.kind) { + case 221 /* ImportEqualsDeclaration */: + case 223 /* ImportClause */: + case 224 /* NamespaceImport */: + case 226 /* ImportSpecifier */: + case 230 /* ExportSpecifier */: + return isAliasResolvedToValue(getSymbolOfNode(node)); + case 228 /* ExportDeclaration */: + var exportClause = node.exportClause; + return exportClause && ts.forEach(exportClause.elements, isValueAliasDeclaration); + case 227 /* ExportAssignment */: + return node.expression && node.expression.kind === 69 /* Identifier */ ? isAliasResolvedToValue(getSymbolOfNode(node)) : true; + } + return false; + } + function isTopLevelValueImportEqualsWithEntityName(node) { + if (node.parent.kind !== 248 /* SourceFile */ || !ts.isInternalModuleImportEqualsDeclaration(node)) { + // parent is not source file or it is not reference to internal module + return false; + } + var isValue = isAliasResolvedToValue(getSymbolOfNode(node)); + return isValue && node.moduleReference && !ts.nodeIsMissing(node.moduleReference); + } + function isAliasResolvedToValue(symbol) { + var target = resolveAlias(symbol); + if (target === unknownSymbol && compilerOptions.isolatedModules) { + return true; + } + // const enums and modules that contain only const enums are not considered values from the emit perespective + // unless 'preserveConstEnums' option is set to true + return target !== unknownSymbol && + target && + target.flags & 107455 /* Value */ && + (compilerOptions.preserveConstEnums || !isConstEnumOrConstEnumOnlyModule(target)); + } + function isConstEnumOrConstEnumOnlyModule(s) { + return isConstEnumSymbol(s) || s.constEnumOnlyModule; + } + function isReferencedAliasDeclaration(node, checkChildren) { + if (ts.isAliasSymbolDeclaration(node)) { + var symbol = getSymbolOfNode(node); + if (getSymbolLinks(symbol).referenced) { + return true; + } + } + if (checkChildren) { + return ts.forEachChild(node, function (node) { return isReferencedAliasDeclaration(node, checkChildren); }); + } + return false; + } + function isImplementationOfOverload(node) { + if (ts.nodeIsPresent(node.body)) { + var symbol = getSymbolOfNode(node); + var signaturesOfSymbol = getSignaturesOfSymbol(symbol); + // If this function body corresponds to function with multiple signature, it is implementation of overload + // e.g.: function foo(a: string): string; + // function foo(a: number): number; + // function foo(a: any) { // This is implementation of the overloads + // return a; + // } + return signaturesOfSymbol.length > 1 || + // If there is single signature for the symbol, it is overload if that signature isn't coming from the node + // e.g.: function foo(a: string): string; + // function foo(a: any) { // This is implementation of the overloads + // return a; + // } + (signaturesOfSymbol.length === 1 && signaturesOfSymbol[0].declaration !== node); + } + return false; + } + function getNodeCheckFlags(node) { + return getNodeLinks(node).flags; + } + function getEnumMemberValue(node) { + computeEnumMemberValues(node.parent); + return getNodeLinks(node).enumMemberValue; + } + function getConstantValue(node) { + if (node.kind === 247 /* EnumMember */) { + return getEnumMemberValue(node); + } + var symbol = getNodeLinks(node).resolvedSymbol; + if (symbol && (symbol.flags & 8 /* EnumMember */)) { + // inline property\index accesses only for const enums + if (ts.isConstEnumDeclaration(symbol.valueDeclaration.parent)) { + return getEnumMemberValue(symbol.valueDeclaration); + } + } + return undefined; + } + function isFunctionType(type) { + return type.flags & 80896 /* ObjectType */ && getSignaturesOfType(type, 0 /* Call */).length > 0; + } + function getTypeReferenceSerializationKind(typeName) { + // Resolve the symbol as a value to ensure the type can be reached at runtime during emit. + var valueSymbol = resolveEntityName(typeName, 107455 /* Value */, /*ignoreErrors*/ true); + var constructorType = valueSymbol ? getTypeOfSymbol(valueSymbol) : undefined; + if (constructorType && isConstructorType(constructorType)) { + return ts.TypeReferenceSerializationKind.TypeWithConstructSignatureAndValue; + } + // Resolve the symbol as a type so that we can provide a more useful hint for the type serializer. + var typeSymbol = resolveEntityName(typeName, 793056 /* Type */, /*ignoreErrors*/ true); + // We might not be able to resolve type symbol so use unknown type in that case (eg error case) + if (!typeSymbol) { + return ts.TypeReferenceSerializationKind.ObjectType; + } + var type = getDeclaredTypeOfSymbol(typeSymbol); + if (type === unknownType) { + return ts.TypeReferenceSerializationKind.Unknown; + } + else if (type.flags & 1 /* Any */) { + return ts.TypeReferenceSerializationKind.ObjectType; + } + else if (allConstituentTypesHaveKind(type, 16 /* Void */)) { + return ts.TypeReferenceSerializationKind.VoidType; + } + else if (allConstituentTypesHaveKind(type, 8 /* Boolean */)) { + return ts.TypeReferenceSerializationKind.BooleanType; + } + else if (allConstituentTypesHaveKind(type, 132 /* NumberLike */)) { + return ts.TypeReferenceSerializationKind.NumberLikeType; + } + else if (allConstituentTypesHaveKind(type, 258 /* StringLike */)) { + return ts.TypeReferenceSerializationKind.StringLikeType; + } + else if (allConstituentTypesHaveKind(type, 8192 /* Tuple */)) { + return ts.TypeReferenceSerializationKind.ArrayLikeType; + } + else if (allConstituentTypesHaveKind(type, 16777216 /* ESSymbol */)) { + return ts.TypeReferenceSerializationKind.ESSymbolType; + } + else if (isFunctionType(type)) { + return ts.TypeReferenceSerializationKind.TypeWithCallSignature; + } + else if (isArrayType(type)) { + return ts.TypeReferenceSerializationKind.ArrayLikeType; + } + else { + return ts.TypeReferenceSerializationKind.ObjectType; + } + } + function writeTypeOfDeclaration(declaration, enclosingDeclaration, flags, writer) { + // Get type of the symbol if this is the valid symbol otherwise get type at location + var symbol = getSymbolOfNode(declaration); + var type = symbol && !(symbol.flags & (2048 /* TypeLiteral */ | 131072 /* Signature */)) + ? getTypeOfSymbol(symbol) + : unknownType; + getSymbolDisplayBuilder().buildTypeDisplay(type, writer, enclosingDeclaration, flags); + } + function writeReturnTypeOfSignatureDeclaration(signatureDeclaration, enclosingDeclaration, flags, writer) { + var signature = getSignatureFromDeclaration(signatureDeclaration); + getSymbolDisplayBuilder().buildTypeDisplay(getReturnTypeOfSignature(signature), writer, enclosingDeclaration, flags); + } + function writeTypeOfExpression(expr, enclosingDeclaration, flags, writer) { + var type = getTypeOfExpression(expr); + getSymbolDisplayBuilder().buildTypeDisplay(type, writer, enclosingDeclaration, flags); + } + function hasGlobalName(name) { + return ts.hasProperty(globals, name); + } + function getReferencedValueSymbol(reference) { + return getNodeLinks(reference).resolvedSymbol || + resolveName(reference, reference.text, 107455 /* Value */ | 1048576 /* ExportValue */ | 8388608 /* Alias */, + /*nodeNotFoundMessage*/ undefined, /*nameArg*/ undefined); + } + function getReferencedValueDeclaration(reference) { + ts.Debug.assert(!ts.nodeIsSynthesized(reference)); + var symbol = getReferencedValueSymbol(reference); + return symbol && getExportSymbolOfValueSymbolIfExported(symbol).valueDeclaration; + } + function instantiateSingleCallFunctionType(functionType, typeArguments) { + if (functionType === unknownType) { + return unknownType; + } + var signature = getSingleCallSignature(functionType); + if (!signature) { + return unknownType; + } + var instantiatedSignature = getSignatureInstantiation(signature, typeArguments); + return getOrCreateTypeFromSignature(instantiatedSignature); + } + function createResolver() { + return { + getReferencedExportContainer: getReferencedExportContainer, + getReferencedImportDeclaration: getReferencedImportDeclaration, + getReferencedNestedRedeclaration: getReferencedNestedRedeclaration, + isNestedRedeclaration: isNestedRedeclaration, + isValueAliasDeclaration: isValueAliasDeclaration, + hasGlobalName: hasGlobalName, + isReferencedAliasDeclaration: isReferencedAliasDeclaration, + getNodeCheckFlags: getNodeCheckFlags, + isTopLevelValueImportEqualsWithEntityName: isTopLevelValueImportEqualsWithEntityName, + isDeclarationVisible: isDeclarationVisible, + isImplementationOfOverload: isImplementationOfOverload, + writeTypeOfDeclaration: writeTypeOfDeclaration, + writeReturnTypeOfSignatureDeclaration: writeReturnTypeOfSignatureDeclaration, + writeTypeOfExpression: writeTypeOfExpression, + isSymbolAccessible: isSymbolAccessible, + isEntityNameVisible: isEntityNameVisible, + getConstantValue: getConstantValue, + collectLinkedAliases: collectLinkedAliases, + getReferencedValueDeclaration: getReferencedValueDeclaration, + getTypeReferenceSerializationKind: getTypeReferenceSerializationKind, + isOptionalParameter: isOptionalParameter, + isArgumentsLocalBinding: isArgumentsLocalBinding + }; + } + function initializeTypeChecker() { + // Bind all source files and propagate errors + ts.forEach(host.getSourceFiles(), function (file) { + ts.bindSourceFile(file); + }); + // Initialize global symbol table + ts.forEach(host.getSourceFiles(), function (file) { + if (!ts.isExternalModule(file)) { + mergeSymbolTable(globals, file.locals); + } + }); + // Initialize special symbols + getSymbolLinks(undefinedSymbol).type = undefinedType; + getSymbolLinks(argumentsSymbol).type = getGlobalType("IArguments"); + getSymbolLinks(unknownSymbol).type = unknownType; + globals[undefinedSymbol.name] = undefinedSymbol; + // Initialize special types + globalArrayType = getGlobalType("Array", /*arity*/ 1); + globalObjectType = getGlobalType("Object"); + globalFunctionType = getGlobalType("Function"); + globalStringType = getGlobalType("String"); + globalNumberType = getGlobalType("Number"); + globalBooleanType = getGlobalType("Boolean"); + globalRegExpType = getGlobalType("RegExp"); + jsxElementType = getExportedTypeFromNamespace("JSX", JsxNames.Element); + getGlobalClassDecoratorType = ts.memoize(function () { return getGlobalType("ClassDecorator"); }); + getGlobalPropertyDecoratorType = ts.memoize(function () { return getGlobalType("PropertyDecorator"); }); + getGlobalMethodDecoratorType = ts.memoize(function () { return getGlobalType("MethodDecorator"); }); + getGlobalParameterDecoratorType = ts.memoize(function () { return getGlobalType("ParameterDecorator"); }); + getGlobalTypedPropertyDescriptorType = ts.memoize(function () { return getGlobalType("TypedPropertyDescriptor", /*arity*/ 1); }); + getGlobalPromiseType = ts.memoize(function () { return getGlobalType("Promise", /*arity*/ 1); }); + tryGetGlobalPromiseType = ts.memoize(function () { return getGlobalSymbol("Promise", 793056 /* Type */, /*diagnostic*/ undefined) && getGlobalPromiseType(); }); + getGlobalPromiseLikeType = ts.memoize(function () { return getGlobalType("PromiseLike", /*arity*/ 1); }); + getInstantiatedGlobalPromiseLikeType = ts.memoize(createInstantiatedPromiseLikeType); + getGlobalPromiseConstructorSymbol = ts.memoize(function () { return getGlobalValueSymbol("Promise"); }); + getGlobalPromiseConstructorLikeType = ts.memoize(function () { return getGlobalType("PromiseConstructorLike"); }); + getGlobalThenableType = ts.memoize(createThenableType); + // If we're in ES6 mode, load the TemplateStringsArray. + // Otherwise, default to 'unknown' for the purposes of type checking in LS scenarios. + if (languageVersion >= 2 /* ES6 */) { + globalTemplateStringsArrayType = getGlobalType("TemplateStringsArray"); + globalESSymbolType = getGlobalType("Symbol"); + globalESSymbolConstructorSymbol = getGlobalValueSymbol("Symbol"); + globalIterableType = getGlobalType("Iterable", /*arity*/ 1); + globalIteratorType = getGlobalType("Iterator", /*arity*/ 1); + globalIterableIteratorType = getGlobalType("IterableIterator", /*arity*/ 1); + } + else { + globalTemplateStringsArrayType = unknownType; + // Consider putting Symbol interface in lib.d.ts. On the plus side, putting it in lib.d.ts would make it + // extensible for Polyfilling Symbols. But putting it into lib.d.ts could also break users that have + // a global Symbol already, particularly if it is a class. + globalESSymbolType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); + globalESSymbolConstructorSymbol = undefined; + globalIterableType = emptyGenericType; + globalIteratorType = emptyGenericType; + globalIterableIteratorType = emptyGenericType; + } + anyArrayType = createArrayType(anyType); + } + function createInstantiatedPromiseLikeType() { + var promiseLikeType = getGlobalPromiseLikeType(); + if (promiseLikeType !== emptyGenericType) { + return createTypeReference(promiseLikeType, [anyType]); + } + return emptyObjectType; + } + function createThenableType() { + // build the thenable type that is used to verify against a non-promise "thenable" operand to `await`. + var thenPropertySymbol = createSymbol(67108864 /* Transient */ | 4 /* Property */, "then"); + getSymbolLinks(thenPropertySymbol).type = globalFunctionType; + var thenableType = createObjectType(65536 /* Anonymous */); + thenableType.properties = [thenPropertySymbol]; + thenableType.members = createSymbolTable(thenableType.properties); + thenableType.callSignatures = []; + thenableType.constructSignatures = []; + return thenableType; + } + // GRAMMAR CHECKING + function checkGrammarDecorators(node) { + if (!node.decorators) { + return false; + } + if (!ts.nodeCanBeDecorated(node)) { + return grammarErrorOnFirstToken(node, ts.Diagnostics.Decorators_are_not_valid_here); + } + else if (node.kind === 145 /* GetAccessor */ || node.kind === 146 /* SetAccessor */) { + var accessors = ts.getAllAccessorDeclarations(node.parent.members, node); + if (accessors.firstAccessor.decorators && node === accessors.secondAccessor) { + return grammarErrorOnFirstToken(node, ts.Diagnostics.Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name); + } + } + return false; + } + function checkGrammarModifiers(node) { + switch (node.kind) { + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: + case 144 /* Constructor */: + case 141 /* PropertyDeclaration */: + case 140 /* PropertySignature */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: + case 149 /* IndexSignature */: + case 218 /* ModuleDeclaration */: + case 222 /* ImportDeclaration */: + case 221 /* ImportEqualsDeclaration */: + case 228 /* ExportDeclaration */: + case 227 /* ExportAssignment */: + case 138 /* Parameter */: + break; + case 213 /* FunctionDeclaration */: + if (node.modifiers && (node.modifiers.length > 1 || node.modifiers[0].kind !== 118 /* AsyncKeyword */) && + node.parent.kind !== 219 /* ModuleBlock */ && node.parent.kind !== 248 /* SourceFile */) { + return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); + } + break; + case 214 /* ClassDeclaration */: + case 215 /* InterfaceDeclaration */: + case 193 /* VariableStatement */: + case 216 /* TypeAliasDeclaration */: + if (node.modifiers && node.parent.kind !== 219 /* ModuleBlock */ && node.parent.kind !== 248 /* SourceFile */) { + return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); + } + break; + case 217 /* EnumDeclaration */: + if (node.modifiers && (node.modifiers.length > 1 || node.modifiers[0].kind !== 74 /* ConstKeyword */) && + node.parent.kind !== 219 /* ModuleBlock */ && node.parent.kind !== 248 /* SourceFile */) { + return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); + } + break; + default: + return false; + } + if (!node.modifiers) { + return; + } + var lastStatic, lastPrivate, lastProtected, lastDeclare, lastAsync; + var flags = 0; + for (var _i = 0, _a = node.modifiers; _i < _a.length; _i++) { + var modifier = _a[_i]; + switch (modifier.kind) { + case 112 /* PublicKeyword */: + case 111 /* ProtectedKeyword */: + case 110 /* PrivateKeyword */: + var text = void 0; + if (modifier.kind === 112 /* PublicKeyword */) { + text = "public"; + } + else if (modifier.kind === 111 /* ProtectedKeyword */) { + text = "protected"; + lastProtected = modifier; + } + else { + text = "private"; + lastPrivate = modifier; + } + if (flags & 112 /* AccessibilityModifier */) { + return grammarErrorOnNode(modifier, ts.Diagnostics.Accessibility_modifier_already_seen); + } + else if (flags & 128 /* Static */) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "static"); + } + else if (flags & 512 /* Async */) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "async"); + } + else if (node.parent.kind === 219 /* ModuleBlock */ || node.parent.kind === 248 /* SourceFile */) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_element, text); + } + else if (flags & 256 /* Abstract */) { + if (modifier.kind === 110 /* PrivateKeyword */) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, text, "abstract"); + } + else { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "abstract"); + } + } + flags |= ts.modifierToFlag(modifier.kind); + break; + case 113 /* StaticKeyword */: + if (flags & 128 /* Static */) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "static"); + } + else if (flags & 512 /* Async */) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "static", "async"); + } + else if (node.parent.kind === 219 /* ModuleBlock */ || node.parent.kind === 248 /* SourceFile */) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_element, "static"); + } + else if (node.kind === 138 /* Parameter */) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "static"); + } + else if (flags & 256 /* Abstract */) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "static", "abstract"); + } + flags |= 128 /* Static */; + lastStatic = modifier; + break; + case 82 /* ExportKeyword */: + if (flags & 1 /* Export */) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "export"); + } + else if (flags & 2 /* Ambient */) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "declare"); + } + else if (flags & 256 /* Abstract */) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "abstract"); + } + else if (flags & 512 /* Async */) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "async"); + } + else if (node.parent.kind === 214 /* ClassDeclaration */) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "export"); + } + else if (node.kind === 138 /* Parameter */) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "export"); + } + flags |= 1 /* Export */; + break; + case 122 /* DeclareKeyword */: + if (flags & 2 /* Ambient */) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "declare"); + } + else if (flags & 512 /* Async */) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); + } + else if (node.parent.kind === 214 /* ClassDeclaration */) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "declare"); + } + else if (node.kind === 138 /* Parameter */) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "declare"); + } + else if (ts.isInAmbientContext(node.parent) && node.parent.kind === 219 /* ModuleBlock */) { + return grammarErrorOnNode(modifier, ts.Diagnostics.A_declare_modifier_cannot_be_used_in_an_already_ambient_context); + } + flags |= 2 /* Ambient */; + lastDeclare = modifier; + break; + case 115 /* AbstractKeyword */: + if (flags & 256 /* Abstract */) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "abstract"); + } + if (node.kind !== 214 /* ClassDeclaration */) { + if (node.kind !== 143 /* MethodDeclaration */) { + return grammarErrorOnNode(modifier, ts.Diagnostics.abstract_modifier_can_only_appear_on_a_class_or_method_declaration); + } + if (!(node.parent.kind === 214 /* ClassDeclaration */ && node.parent.flags & 256 /* Abstract */)) { + return grammarErrorOnNode(modifier, ts.Diagnostics.Abstract_methods_can_only_appear_within_an_abstract_class); + } + if (flags & 128 /* Static */) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "static", "abstract"); + } + if (flags & 32 /* Private */) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "private", "abstract"); + } + } + flags |= 256 /* Abstract */; + break; + case 118 /* AsyncKeyword */: + if (flags & 512 /* Async */) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "async"); + } + else if (flags & 2 /* Ambient */ || ts.isInAmbientContext(node.parent)) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); + } + else if (node.kind === 138 /* Parameter */) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "async"); + } + flags |= 512 /* Async */; + lastAsync = modifier; + break; + } + } + if (node.kind === 144 /* Constructor */) { + if (flags & 128 /* Static */) { + return grammarErrorOnNode(lastStatic, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "static"); + } + if (flags & 256 /* Abstract */) { + return grammarErrorOnNode(lastStatic, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "abstract"); + } + else if (flags & 64 /* Protected */) { + return grammarErrorOnNode(lastProtected, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "protected"); + } + else if (flags & 32 /* Private */) { + return grammarErrorOnNode(lastPrivate, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "private"); + } + else if (flags & 512 /* Async */) { + return grammarErrorOnNode(lastAsync, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "async"); + } + return; + } + else if ((node.kind === 222 /* ImportDeclaration */ || node.kind === 221 /* ImportEqualsDeclaration */) && flags & 2 /* Ambient */) { + return grammarErrorOnNode(lastDeclare, ts.Diagnostics.A_0_modifier_cannot_be_used_with_an_import_declaration, "declare"); + } + else if (node.kind === 138 /* Parameter */ && (flags & 112 /* AccessibilityModifier */) && ts.isBindingPattern(node.name)) { + return grammarErrorOnNode(node, ts.Diagnostics.A_parameter_property_may_not_be_a_binding_pattern); + } + if (flags & 512 /* Async */) { + return checkGrammarAsyncModifier(node, lastAsync); + } + } + function checkGrammarAsyncModifier(node, asyncModifier) { + if (languageVersion < 2 /* ES6 */) { + return grammarErrorOnNode(asyncModifier, ts.Diagnostics.Async_functions_are_only_available_when_targeting_ECMAScript_6_and_higher); + } + switch (node.kind) { + case 143 /* MethodDeclaration */: + case 213 /* FunctionDeclaration */: + case 173 /* FunctionExpression */: + case 174 /* ArrowFunction */: + if (!node.asteriskToken) { + return false; + } + break; + } + return grammarErrorOnNode(asyncModifier, ts.Diagnostics._0_modifier_cannot_be_used_here, "async"); + } + function checkGrammarForDisallowedTrailingComma(list) { + if (list && list.hasTrailingComma) { + var start = list.end - ",".length; + var end = list.end; + var sourceFile = ts.getSourceFileOfNode(list[0]); + return grammarErrorAtPos(sourceFile, start, end - start, ts.Diagnostics.Trailing_comma_not_allowed); + } + } + function checkGrammarTypeParameterList(node, typeParameters, file) { + if (checkGrammarForDisallowedTrailingComma(typeParameters)) { + return true; + } + if (typeParameters && typeParameters.length === 0) { + var start = typeParameters.pos - "<".length; + var end = ts.skipTrivia(file.text, typeParameters.end) + ">".length; + return grammarErrorAtPos(file, start, end - start, ts.Diagnostics.Type_parameter_list_cannot_be_empty); + } + } + function checkGrammarParameterList(parameters) { + if (checkGrammarForDisallowedTrailingComma(parameters)) { + return true; + } + var seenOptionalParameter = false; + var parameterCount = parameters.length; + for (var i = 0; i < parameterCount; i++) { + var parameter = parameters[i]; + if (parameter.dotDotDotToken) { + if (i !== (parameterCount - 1)) { + return grammarErrorOnNode(parameter.dotDotDotToken, ts.Diagnostics.A_rest_parameter_must_be_last_in_a_parameter_list); + } + if (ts.isBindingPattern(parameter.name)) { + return grammarErrorOnNode(parameter.name, ts.Diagnostics.A_rest_element_cannot_contain_a_binding_pattern); + } + if (parameter.questionToken) { + return grammarErrorOnNode(parameter.questionToken, ts.Diagnostics.A_rest_parameter_cannot_be_optional); + } + if (parameter.initializer) { + return grammarErrorOnNode(parameter.name, ts.Diagnostics.A_rest_parameter_cannot_have_an_initializer); + } + } + else if (parameter.questionToken) { + seenOptionalParameter = true; + if (parameter.initializer) { + return grammarErrorOnNode(parameter.name, ts.Diagnostics.Parameter_cannot_have_question_mark_and_initializer); + } + } + else if (seenOptionalParameter && !parameter.initializer) { + return grammarErrorOnNode(parameter.name, ts.Diagnostics.A_required_parameter_cannot_follow_an_optional_parameter); + } + } + } + function checkGrammarFunctionLikeDeclaration(node) { + // Prevent cascading error by short-circuit + var file = ts.getSourceFileOfNode(node); + return checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarTypeParameterList(node, node.typeParameters, file) || + checkGrammarParameterList(node.parameters) || checkGrammarArrowFunction(node, file); + } + function checkGrammarArrowFunction(node, file) { + if (node.kind === 174 /* ArrowFunction */) { + var arrowFunction = node; + var startLine = ts.getLineAndCharacterOfPosition(file, arrowFunction.equalsGreaterThanToken.pos).line; + var endLine = ts.getLineAndCharacterOfPosition(file, arrowFunction.equalsGreaterThanToken.end).line; + if (startLine !== endLine) { + return grammarErrorOnNode(arrowFunction.equalsGreaterThanToken, ts.Diagnostics.Line_terminator_not_permitted_before_arrow); + } + } + return false; + } + function checkGrammarIndexSignatureParameters(node) { + var parameter = node.parameters[0]; + if (node.parameters.length !== 1) { + if (parameter) { + return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_must_have_exactly_one_parameter); + } + else { + return grammarErrorOnNode(node, ts.Diagnostics.An_index_signature_must_have_exactly_one_parameter); + } + } + if (parameter.dotDotDotToken) { + return grammarErrorOnNode(parameter.dotDotDotToken, ts.Diagnostics.An_index_signature_cannot_have_a_rest_parameter); + } + if (parameter.flags & 2035 /* Modifier */) { + return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_cannot_have_an_accessibility_modifier); + } + if (parameter.questionToken) { + return grammarErrorOnNode(parameter.questionToken, ts.Diagnostics.An_index_signature_parameter_cannot_have_a_question_mark); + } + if (parameter.initializer) { + return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_cannot_have_an_initializer); + } + if (!parameter.type) { + return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_must_have_a_type_annotation); + } + if (parameter.type.kind !== 130 /* StringKeyword */ && parameter.type.kind !== 128 /* NumberKeyword */) { + return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_type_must_be_string_or_number); + } + if (!node.type) { + return grammarErrorOnNode(node, ts.Diagnostics.An_index_signature_must_have_a_type_annotation); + } + } + function checkGrammarForIndexSignatureModifier(node) { + if (node.flags & 2035 /* Modifier */) { + grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_not_permitted_on_index_signature_members); + } + } + function checkGrammarIndexSignature(node) { + // Prevent cascading error by short-circuit + return checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarIndexSignatureParameters(node) || checkGrammarForIndexSignatureModifier(node); + } + function checkGrammarForAtLeastOneTypeArgument(node, typeArguments) { + if (typeArguments && typeArguments.length === 0) { + var sourceFile = ts.getSourceFileOfNode(node); + var start = typeArguments.pos - "<".length; + var end = ts.skipTrivia(sourceFile.text, typeArguments.end) + ">".length; + return grammarErrorAtPos(sourceFile, start, end - start, ts.Diagnostics.Type_argument_list_cannot_be_empty); + } + } + function checkGrammarTypeArguments(node, typeArguments) { + return checkGrammarForDisallowedTrailingComma(typeArguments) || + checkGrammarForAtLeastOneTypeArgument(node, typeArguments); + } + function checkGrammarForOmittedArgument(node, args) { + if (args) { + var sourceFile = ts.getSourceFileOfNode(node); + for (var _i = 0; _i < args.length; _i++) { + var arg = args[_i]; + if (arg.kind === 187 /* OmittedExpression */) { + return grammarErrorAtPos(sourceFile, arg.pos, 0, ts.Diagnostics.Argument_expression_expected); + } + } + } + } + function checkGrammarArguments(node, args) { + return checkGrammarForDisallowedTrailingComma(args) || + checkGrammarForOmittedArgument(node, args); + } + function checkGrammarHeritageClause(node) { + var types = node.types; + if (checkGrammarForDisallowedTrailingComma(types)) { + return true; + } + if (types && types.length === 0) { + var listType = ts.tokenToString(node.token); + var sourceFile = ts.getSourceFileOfNode(node); + return grammarErrorAtPos(sourceFile, types.pos, 0, ts.Diagnostics._0_list_cannot_be_empty, listType); + } + } + function checkGrammarClassDeclarationHeritageClauses(node) { + var seenExtendsClause = false; + var seenImplementsClause = false; + 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 (seenExtendsClause) { + return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_already_seen); + } + if (seenImplementsClause) { + return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_must_precede_implements_clause); + } + if (heritageClause.types.length > 1) { + return grammarErrorOnFirstToken(heritageClause.types[1], ts.Diagnostics.Classes_can_only_extend_a_single_class); + } + seenExtendsClause = true; + } + else { + ts.Debug.assert(heritageClause.token === 106 /* ImplementsKeyword */); + if (seenImplementsClause) { + return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.implements_clause_already_seen); + } + seenImplementsClause = true; + } + // Grammar checking heritageClause inside class declaration + checkGrammarHeritageClause(heritageClause); + } + } + } + function checkGrammarInterfaceDeclaration(node) { + var seenExtendsClause = false; + if (node.heritageClauses) { + for (var _i = 0, _a = node.heritageClauses; _i < _a.length; _i++) { + var heritageClause = _a[_i]; + if (heritageClause.token === 83 /* ExtendsKeyword */) { + if (seenExtendsClause) { + return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_already_seen); + } + seenExtendsClause = true; + } + else { + ts.Debug.assert(heritageClause.token === 106 /* ImplementsKeyword */); + return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.Interface_declaration_cannot_have_implements_clause); + } + // Grammar checking heritageClause inside class declaration + checkGrammarHeritageClause(heritageClause); + } + } + return false; + } + function checkGrammarComputedPropertyName(node) { + // If node is not a computedPropertyName, just skip the grammar checking + if (node.kind !== 136 /* ComputedPropertyName */) { + return false; + } + var computedPropertyName = node; + if (computedPropertyName.expression.kind === 181 /* BinaryExpression */ && computedPropertyName.expression.operatorToken.kind === 24 /* CommaToken */) { + return grammarErrorOnNode(computedPropertyName.expression, ts.Diagnostics.A_comma_expression_is_not_allowed_in_a_computed_property_name); + } + } + function checkGrammarForGenerator(node) { + if (node.asteriskToken) { + ts.Debug.assert(node.kind === 213 /* FunctionDeclaration */ || + node.kind === 173 /* FunctionExpression */ || + node.kind === 143 /* MethodDeclaration */); + if (ts.isInAmbientContext(node)) { + return grammarErrorOnNode(node.asteriskToken, ts.Diagnostics.Generators_are_not_allowed_in_an_ambient_context); + } + if (!node.body) { + return grammarErrorOnNode(node.asteriskToken, ts.Diagnostics.An_overload_signature_cannot_be_declared_as_a_generator); + } + if (languageVersion < 2 /* ES6 */) { + return grammarErrorOnNode(node.asteriskToken, ts.Diagnostics.Generators_are_only_available_when_targeting_ECMAScript_6_or_higher); + } + } + } + function checkGrammarForInvalidQuestionMark(node, questionToken, message) { + if (questionToken) { + return grammarErrorOnNode(questionToken, message); + } + } + function checkGrammarObjectLiteralExpression(node, inDestructuring) { + var seen = {}; + var Property = 1; + var GetAccessor = 2; + var SetAccesor = 4; + var GetOrSetAccessor = GetAccessor | SetAccesor; + for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { + var prop = _a[_i]; + var name_16 = prop.name; + if (prop.kind === 187 /* OmittedExpression */ || + name_16.kind === 136 /* ComputedPropertyName */) { + // If the name is not a ComputedPropertyName, the grammar checking will skip it + checkGrammarComputedPropertyName(name_16); + continue; + } + if (prop.kind === 246 /* ShorthandPropertyAssignment */ && !inDestructuring && prop.objectAssignmentInitializer) { + // having objectAssignmentInitializer is only valid in ObjectAssignmentPattern + // outside of destructuring it is a syntax error + return grammarErrorOnNode(prop.equalsToken, ts.Diagnostics.can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment); + } + // ECMA-262 11.1.5 Object Initialiser + // If previous is not undefined then throw a SyntaxError exception if any of the following conditions are true + // a.This production is contained in strict code and IsDataDescriptor(previous) is true and + // 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 + var currentKind = void 0; + if (prop.kind === 245 /* PropertyAssignment */ || prop.kind === 246 /* ShorthandPropertyAssignment */) { + // Grammar checking for computedPropertName and shorthandPropertyAssignment + checkGrammarForInvalidQuestionMark(prop, prop.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional); + if (name_16.kind === 8 /* NumericLiteral */) { + checkGrammarNumericLiteral(name_16); + } + currentKind = Property; + } + else if (prop.kind === 143 /* MethodDeclaration */) { + currentKind = Property; + } + else if (prop.kind === 145 /* GetAccessor */) { + currentKind = GetAccessor; + } + else if (prop.kind === 146 /* SetAccessor */) { + currentKind = SetAccesor; + } + else { + ts.Debug.fail("Unexpected syntax kind:" + prop.kind); + } + if (!ts.hasProperty(seen, name_16.text)) { + seen[name_16.text] = currentKind; + } + else { + var existingKind = seen[name_16.text]; + if (currentKind === Property && existingKind === Property) { + continue; + } + else if ((currentKind & GetOrSetAccessor) && (existingKind & GetOrSetAccessor)) { + if (existingKind !== GetOrSetAccessor && currentKind !== existingKind) { + seen[name_16.text] = currentKind | existingKind; + } + else { + return grammarErrorOnNode(name_16, ts.Diagnostics.An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name); + } + } + else { + return grammarErrorOnNode(name_16, ts.Diagnostics.An_object_literal_cannot_have_property_and_accessor_with_the_same_name); + } + } + } + } + function checkGrammarJsxElement(node) { + var seen = {}; + for (var _i = 0, _a = node.attributes; _i < _a.length; _i++) { + var attr = _a[_i]; + if (attr.kind === 239 /* JsxSpreadAttribute */) { + continue; + } + var jsxAttr = attr; + var name_17 = jsxAttr.name; + if (!ts.hasProperty(seen, name_17.text)) { + seen[name_17.text] = true; + } + else { + return grammarErrorOnNode(name_17, ts.Diagnostics.JSX_elements_cannot_have_multiple_attributes_with_the_same_name); + } + var initializer = jsxAttr.initializer; + if (initializer && initializer.kind === 240 /* JsxExpression */ && !initializer.expression) { + return grammarErrorOnNode(jsxAttr.initializer, ts.Diagnostics.JSX_attributes_must_only_be_assigned_a_non_empty_expression); + } + } + } + function checkGrammarForInOrForOfStatement(forInOrOfStatement) { + if (checkGrammarStatementInAmbientContext(forInOrOfStatement)) { + return true; + } + if (forInOrOfStatement.initializer.kind === 212 /* VariableDeclarationList */) { + var variableList = forInOrOfStatement.initializer; + if (!checkGrammarVariableDeclarationList(variableList)) { + if (variableList.declarations.length > 1) { + var diagnostic = forInOrOfStatement.kind === 200 /* ForInStatement */ + ? ts.Diagnostics.Only_a_single_variable_declaration_is_allowed_in_a_for_in_statement + : ts.Diagnostics.Only_a_single_variable_declaration_is_allowed_in_a_for_of_statement; + return grammarErrorOnFirstToken(variableList.declarations[1], diagnostic); + } + var firstDeclaration = variableList.declarations[0]; + if (firstDeclaration.initializer) { + var diagnostic = forInOrOfStatement.kind === 200 /* ForInStatement */ + ? ts.Diagnostics.The_variable_declaration_of_a_for_in_statement_cannot_have_an_initializer + : ts.Diagnostics.The_variable_declaration_of_a_for_of_statement_cannot_have_an_initializer; + return grammarErrorOnNode(firstDeclaration.name, diagnostic); + } + if (firstDeclaration.type) { + var diagnostic = forInOrOfStatement.kind === 200 /* ForInStatement */ + ? ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_use_a_type_annotation + : ts.Diagnostics.The_left_hand_side_of_a_for_of_statement_cannot_use_a_type_annotation; + return grammarErrorOnNode(firstDeclaration, diagnostic); + } + } + } + return false; + } + function checkGrammarAccessor(accessor) { + var kind = accessor.kind; + if (languageVersion < 1 /* ES5 */) { + return grammarErrorOnNode(accessor.name, ts.Diagnostics.Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher); + } + else if (ts.isInAmbientContext(accessor)) { + return grammarErrorOnNode(accessor.name, ts.Diagnostics.An_accessor_cannot_be_declared_in_an_ambient_context); + } + else if (accessor.body === undefined) { + return grammarErrorAtPos(ts.getSourceFileOfNode(accessor), accessor.end - 1, ";".length, ts.Diagnostics._0_expected, "{"); + } + else if (accessor.typeParameters) { + return grammarErrorOnNode(accessor.name, ts.Diagnostics.An_accessor_cannot_have_type_parameters); + } + else if (kind === 145 /* GetAccessor */ && accessor.parameters.length) { + return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_get_accessor_cannot_have_parameters); + } + else if (kind === 146 /* SetAccessor */) { + if (accessor.type) { + return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_set_accessor_cannot_have_a_return_type_annotation); + } + else if (accessor.parameters.length !== 1) { + return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_set_accessor_must_have_exactly_one_parameter); + } + else { + var parameter = accessor.parameters[0]; + if (parameter.dotDotDotToken) { + return grammarErrorOnNode(parameter.dotDotDotToken, ts.Diagnostics.A_set_accessor_cannot_have_rest_parameter); + } + else if (parameter.flags & 2035 /* Modifier */) { + return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation); + } + else if (parameter.questionToken) { + return grammarErrorOnNode(parameter.questionToken, ts.Diagnostics.A_set_accessor_cannot_have_an_optional_parameter); + } + else if (parameter.initializer) { + return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_set_accessor_parameter_cannot_have_an_initializer); + } + } + } + } + function checkGrammarForNonSymbolComputedProperty(node, message) { + if (node.kind === 136 /* ComputedPropertyName */ && !ts.isWellKnownSymbolSyntactically(node.expression)) { + return grammarErrorOnNode(node, message); + } + } + function checkGrammarMethod(node) { + if (checkGrammarDisallowedModifiersOnObjectLiteralExpressionMethod(node) || + checkGrammarFunctionLikeDeclaration(node) || + checkGrammarForGenerator(node)) { + return true; + } + if (node.parent.kind === 165 /* ObjectLiteralExpression */) { + if (checkGrammarForInvalidQuestionMark(node, node.questionToken, ts.Diagnostics.A_class_member_cannot_be_declared_optional)) { + return true; + } + else if (node.body === undefined) { + return grammarErrorAtPos(getSourceFile(node), node.end - 1, ";".length, ts.Diagnostics._0_expected, "{"); + } + } + if (ts.isClassLike(node.parent)) { + if (checkGrammarForInvalidQuestionMark(node, node.questionToken, ts.Diagnostics.A_class_member_cannot_be_declared_optional)) { + return true; + } + // Technically, computed properties in ambient contexts is disallowed + // for property declarations and accessors too, not just methods. + // However, property declarations disallow computed names in general, + // and accessors are not allowed in ambient contexts in general, + // so this error only really matters for methods. + if (ts.isInAmbientContext(node)) { + return checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_an_ambient_context_must_directly_refer_to_a_built_in_symbol); + } + else if (!node.body) { + 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 === 215 /* InterfaceDeclaration */) { + return checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_an_interface_must_directly_refer_to_a_built_in_symbol); + } + else if (node.parent.kind === 155 /* TypeLiteral */) { + return checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_type_literal_must_directly_refer_to_a_built_in_symbol); + } + } + function checkGrammarBreakOrContinueStatement(node) { + var current = node; + while (current) { + if (ts.isFunctionLike(current)) { + return grammarErrorOnNode(node, ts.Diagnostics.Jump_target_cannot_cross_function_boundary); + } + switch (current.kind) { + case 207 /* LabeledStatement */: + if (node.label && current.label.text === node.label.text) { + // found matching label - verify that label usage is correct + // continue can only target labels that are on iteration statements + var isMisplacedContinueLabel = node.kind === 202 /* 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); + } + return false; + } + break; + case 206 /* SwitchStatement */: + if (node.kind === 203 /* BreakStatement */ && !node.label) { + // unlabeled break within switch statement - ok + return false; + } + break; + default: + if (ts.isIterationStatement(current, /*lookInLabeledStatement*/ false) && !node.label) { + // unlabeled break or continue within iteration statement - ok + return false; + } + break; + } + current = current.parent; + } + if (node.label) { + var message = node.kind === 203 /* BreakStatement */ + ? ts.Diagnostics.A_break_statement_can_only_jump_to_a_label_of_an_enclosing_statement + : ts.Diagnostics.A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement; + return grammarErrorOnNode(node, message); + } + else { + var message = node.kind === 203 /* BreakStatement */ + ? ts.Diagnostics.A_break_statement_can_only_be_used_within_an_enclosing_iteration_or_switch_statement + : ts.Diagnostics.A_continue_statement_can_only_be_used_within_an_enclosing_iteration_statement; + return grammarErrorOnNode(node, message); + } + } + function checkGrammarBindingElement(node) { + if (node.dotDotDotToken) { + var elements = node.parent.elements; + 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 === 162 /* ArrayBindingPattern */ || node.name.kind === 161 /* ObjectBindingPattern */) { + return grammarErrorOnNode(node.name, ts.Diagnostics.A_rest_element_cannot_contain_a_binding_pattern); + } + if (node.initializer) { + // Error on equals token which immediate precedes the initializer + return grammarErrorAtPos(ts.getSourceFileOfNode(node), node.initializer.pos - 1, 1, ts.Diagnostics.A_rest_element_cannot_have_an_initializer); + } + } + } + function checkGrammarVariableDeclaration(node) { + if (node.parent.parent.kind !== 200 /* ForInStatement */ && node.parent.parent.kind !== 201 /* ForOfStatement */) { + if (ts.isInAmbientContext(node)) { + if (node.initializer) { + // Error on equals token which immediate precedes the initializer + var equalsTokenLength = "=".length; + return grammarErrorAtPos(ts.getSourceFileOfNode(node), node.initializer.pos - equalsTokenLength, equalsTokenLength, ts.Diagnostics.Initializers_are_not_allowed_in_ambient_contexts); + } + } + else if (!node.initializer) { + if (ts.isBindingPattern(node.name) && !ts.isBindingPattern(node.parent)) { + return grammarErrorOnNode(node, ts.Diagnostics.A_destructuring_declaration_must_have_an_initializer); + } + if (ts.isConst(node)) { + return grammarErrorOnNode(node, ts.Diagnostics.const_declarations_must_be_initialized); + } + } + } + var checkLetConstNames = languageVersion >= 2 /* ES6 */ && (ts.isLet(node) || ts.isConst(node)); + // 1. LexicalDeclaration : LetOrConst BindingList ; + // It is a Syntax Error if the BoundNames of BindingList contains "let". + // 2. ForDeclaration: ForDeclaration : LetOrConst ForBinding + // It is a Syntax Error if the BoundNames of ForDeclaration contains "let". + // It is a SyntaxError if a VariableDeclaration or VariableDeclarationNoIn occurs within strict code + // and its Identifier is eval or arguments + return checkLetConstNames && checkGrammarNameInLetOrConstDeclarations(node.name); + } + function checkGrammarNameInLetOrConstDeclarations(name) { + if (name.kind === 69 /* Identifier */) { + if (name.text === "let") { + return grammarErrorOnNode(name, ts.Diagnostics.let_is_not_allowed_to_be_used_as_a_name_in_let_or_const_declarations); + } + } + else { + var elements = name.elements; + for (var _i = 0; _i < elements.length; _i++) { + var element = elements[_i]; + if (element.kind !== 187 /* OmittedExpression */) { + checkGrammarNameInLetOrConstDeclarations(element.name); + } + } + } + } + function checkGrammarVariableDeclarationList(declarationList) { + var declarations = declarationList.declarations; + if (checkGrammarForDisallowedTrailingComma(declarationList.declarations)) { + return true; + } + if (!declarationList.declarations.length) { + return grammarErrorAtPos(ts.getSourceFileOfNode(declarationList), declarations.pos, declarations.end - declarations.pos, ts.Diagnostics.Variable_declaration_list_cannot_be_empty); + } + } + function allowLetAndConstDeclarations(parent) { + switch (parent.kind) { + case 196 /* IfStatement */: + case 197 /* DoStatement */: + case 198 /* WhileStatement */: + case 205 /* WithStatement */: + case 199 /* ForStatement */: + case 200 /* ForInStatement */: + case 201 /* ForOfStatement */: + return false; + case 207 /* LabeledStatement */: + return allowLetAndConstDeclarations(parent.parent); + } + return true; + } + function checkGrammarForDisallowedLetOrConstStatement(node) { + if (!allowLetAndConstDeclarations(node.parent)) { + if (ts.isLet(node.declarationList)) { + return grammarErrorOnNode(node, ts.Diagnostics.let_declarations_can_only_be_declared_inside_a_block); + } + else if (ts.isConst(node.declarationList)) { + return grammarErrorOnNode(node, ts.Diagnostics.const_declarations_can_only_be_declared_inside_a_block); + } + } + } + function isIntegerLiteral(expression) { + if (expression.kind === 179 /* PrefixUnaryExpression */) { + var unaryExpression = expression; + if (unaryExpression.operator === 35 /* PlusToken */ || unaryExpression.operator === 36 /* MinusToken */) { + expression = unaryExpression.operand; + } + } + if (expression.kind === 8 /* NumericLiteral */) { + // Allows for scientific notation since literalExpression.text was formed by + // coercing a number to a string. Sometimes this coercion can yield a string + // in scientific notation. + // We also don't need special logic for hex because a hex integer is converted + // to decimal when it is coerced. + return /^[0-9]+([eE]\+?[0-9]+)?$/.test(expression.text); + } + return false; + } + function hasParseDiagnostics(sourceFile) { + return sourceFile.parseDiagnostics.length > 0; + } + function grammarErrorOnFirstToken(node, message, arg0, arg1, arg2) { + var sourceFile = ts.getSourceFileOfNode(node); + if (!hasParseDiagnostics(sourceFile)) { + var span = ts.getSpanOfTokenAtPosition(sourceFile, node.pos); + diagnostics.add(ts.createFileDiagnostic(sourceFile, span.start, span.length, message, arg0, arg1, arg2)); + return true; + } + } + function grammarErrorAtPos(sourceFile, start, length, message, arg0, arg1, arg2) { + if (!hasParseDiagnostics(sourceFile)) { + diagnostics.add(ts.createFileDiagnostic(sourceFile, start, length, message, arg0, arg1, arg2)); + return true; + } + } + function grammarErrorOnNode(node, message, arg0, arg1, arg2) { + var sourceFile = ts.getSourceFileOfNode(node); + if (!hasParseDiagnostics(sourceFile)) { + diagnostics.add(ts.createDiagnosticForNode(node, message, arg0, arg1, arg2)); + return true; + } + } + function isEvalOrArgumentsIdentifier(node) { + return node.kind === 69 /* Identifier */ && + (node.text === "eval" || node.text === "arguments"); + } + function checkGrammarConstructorTypeParameters(node) { + if (node.typeParameters) { + return grammarErrorAtPos(ts.getSourceFileOfNode(node), node.typeParameters.pos, node.typeParameters.end - node.typeParameters.pos, ts.Diagnostics.Type_parameters_cannot_appear_on_a_constructor_declaration); + } + } + function checkGrammarConstructorTypeAnnotation(node) { + if (node.type) { + return grammarErrorOnNode(node.type, ts.Diagnostics.Type_annotation_cannot_appear_on_a_constructor_declaration); + } + } + function checkGrammarProperty(node) { + if (ts.isClassLike(node.parent)) { + if (checkGrammarForInvalidQuestionMark(node, node.questionToken, ts.Diagnostics.A_class_member_cannot_be_declared_optional) || + checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_class_property_declaration_must_directly_refer_to_a_built_in_symbol)) { + return true; + } + } + else if (node.parent.kind === 215 /* InterfaceDeclaration */) { + if (checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_an_interface_must_directly_refer_to_a_built_in_symbol)) { + return true; + } + } + else if (node.parent.kind === 155 /* TypeLiteral */) { + if (checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_type_literal_must_directly_refer_to_a_built_in_symbol)) { + return true; + } + } + if (ts.isInAmbientContext(node) && node.initializer) { + return grammarErrorOnFirstToken(node.initializer, ts.Diagnostics.Initializers_are_not_allowed_in_ambient_contexts); + } + } + function checkGrammarTopLevelElementForRequiredDeclareModifier(node) { + // A declare modifier is required for any top level .d.ts declaration except export=, export default, + // interfaces and imports categories: + // + // DeclarationElement: + // ExportAssignment + // export_opt InterfaceDeclaration + // export_opt TypeAliasDeclaration + // export_opt ImportDeclaration + // export_opt ExternalImportDeclaration + // export_opt AmbientDeclaration + // + // TODO: The spec needs to be amended to reflect this grammar. + if (node.kind === 215 /* InterfaceDeclaration */ || + node.kind === 216 /* TypeAliasDeclaration */ || + node.kind === 222 /* ImportDeclaration */ || + node.kind === 221 /* ImportEqualsDeclaration */ || + node.kind === 228 /* ExportDeclaration */ || + node.kind === 227 /* ExportAssignment */ || + (node.flags & 2 /* Ambient */) || + (node.flags & (1 /* Export */ | 1024 /* Default */))) { + return false; + } + return grammarErrorOnFirstToken(node, ts.Diagnostics.A_declare_modifier_is_required_for_a_top_level_declaration_in_a_d_ts_file); + } + function checkGrammarTopLevelElementsForRequiredDeclareModifier(file) { + for (var _i = 0, _a = file.statements; _i < _a.length; _i++) { + var decl = _a[_i]; + if (ts.isDeclaration(decl) || decl.kind === 193 /* VariableStatement */) { + if (checkGrammarTopLevelElementForRequiredDeclareModifier(decl)) { + return true; + } + } + } + } + function checkGrammarSourceFile(node) { + return ts.isInAmbientContext(node) && checkGrammarTopLevelElementsForRequiredDeclareModifier(node); + } + function checkGrammarStatementInAmbientContext(node) { + if (ts.isInAmbientContext(node)) { + // An accessors is already reported about the ambient context + if (isAccessor(node.parent.kind)) { + return getNodeLinks(node).hasReportedStatementInAmbientContext = true; + } + // Find containing block which is either Block, ModuleBlock, SourceFile + var links = getNodeLinks(node); + if (!links.hasReportedStatementInAmbientContext && ts.isFunctionLike(node.parent)) { + return getNodeLinks(node).hasReportedStatementInAmbientContext = grammarErrorOnFirstToken(node, ts.Diagnostics.An_implementation_cannot_be_declared_in_ambient_contexts); + } + // We are either parented by another statement, or some sort of block. + // If we're in a block, we only want to really report an error once + // to prevent noisyness. So use a bit on the block to indicate if + // this has already been reported, and don't report if it has. + // + if (node.parent.kind === 192 /* Block */ || node.parent.kind === 219 /* ModuleBlock */ || node.parent.kind === 248 /* SourceFile */) { + var links_1 = getNodeLinks(node.parent); + // Check if the containing block ever report this error + if (!links_1.hasReportedStatementInAmbientContext) { + return links_1.hasReportedStatementInAmbientContext = grammarErrorOnFirstToken(node, ts.Diagnostics.Statements_are_not_allowed_in_ambient_contexts); + } + } + else { + } + } + } + function checkGrammarNumericLiteral(node) { + // Grammar checking + if (node.flags & 65536 /* OctalLiteral */ && languageVersion >= 1 /* ES5 */) { + return grammarErrorOnNode(node, ts.Diagnostics.Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher); + } + } + function grammarErrorAfterFirstToken(node, message, arg0, arg1, arg2) { + var sourceFile = ts.getSourceFileOfNode(node); + if (!hasParseDiagnostics(sourceFile)) { + var span = ts.getSpanOfTokenAtPosition(sourceFile, node.pos); + diagnostics.add(ts.createFileDiagnostic(sourceFile, ts.textSpanEnd(span), /*length*/ 0, message, arg0, arg1, arg2)); + return true; + } + } + } + ts.createTypeChecker = createTypeChecker; +})(ts || (ts = {})); +/// +/* @internal */ +var ts; +(function (ts) { + function getDeclarationDiagnostics(host, resolver, targetSourceFile) { + var diagnostics = []; + var jsFilePath = ts.getOwnEmitOutputFilePath(targetSourceFile, host, ".js"); + emitDeclarations(host, resolver, diagnostics, jsFilePath, targetSourceFile); + return diagnostics; + } + ts.getDeclarationDiagnostics = getDeclarationDiagnostics; + function emitDeclarations(host, resolver, diagnostics, jsFilePath, root) { + var newLine = host.getNewLine(); + var compilerOptions = host.getCompilerOptions(); + var write; + var writeLine; + var increaseIndent; + var decreaseIndent; + var writeTextOfNode; + var writer = createAndSetNewTextWriterWithSymbolWriter(); + var enclosingDeclaration; + var currentSourceFile; + var reportedDeclarationError = false; + var errorNameNode; + var emitJsDocComments = compilerOptions.removeComments ? function (declaration) { } : writeJsDocComments; + var emit = compilerOptions.stripInternal ? stripInternal : emitNode; + var moduleElementDeclarationEmitInfo = []; + var asynchronousSubModuleDeclarationEmitInfo; + // Contains the reference paths that needs to go in the declaration file. + // Collecting this separately because reference paths need to be first thing in the declaration file + // and we could be collecting these paths from multiple files into single one with --out option + var referencePathsOutput = ""; + if (root) { + // Emitting just a single file, so emit references in this file only + if (!compilerOptions.noResolve) { + var addedGlobalFileReference = false; + ts.forEach(root.referencedFiles, function (fileReference) { + var referencedFile = ts.tryResolveScriptReference(host, root, fileReference); + // All the references that are not going to be part of same file + if (referencedFile && ((referencedFile.flags & 8192 /* DeclarationFile */) || + ts.shouldEmitToOwnFile(referencedFile, compilerOptions) || + !addedGlobalFileReference)) { + writeReferencePath(referencedFile); + if (!ts.isExternalModuleOrDeclarationFile(referencedFile)) { + addedGlobalFileReference = true; + } + } + }); + } + emitSourceFile(root); + // create asynchronous output for the importDeclarations + if (moduleElementDeclarationEmitInfo.length) { + var oldWriter = writer; + ts.forEach(moduleElementDeclarationEmitInfo, function (aliasEmitInfo) { + if (aliasEmitInfo.isVisible) { + ts.Debug.assert(aliasEmitInfo.node.kind === 222 /* ImportDeclaration */); + createAndSetNewTextWriterWithSymbolWriter(); + ts.Debug.assert(aliasEmitInfo.indent === 0); + writeImportDeclaration(aliasEmitInfo.node); + aliasEmitInfo.asynchronousOutput = writer.getText(); + } + }); + setWriter(oldWriter); + } + } + else { + // Emit references corresponding to this file + var emittedReferencedFiles = []; + ts.forEach(host.getSourceFiles(), function (sourceFile) { + if (!ts.isExternalModuleOrDeclarationFile(sourceFile)) { + // Check what references need to be added + if (!compilerOptions.noResolve) { + ts.forEach(sourceFile.referencedFiles, function (fileReference) { + var referencedFile = ts.tryResolveScriptReference(host, sourceFile, fileReference); + // If the reference file is a declaration file or an external module, emit that reference + if (referencedFile && (ts.isExternalModuleOrDeclarationFile(referencedFile) && + !ts.contains(emittedReferencedFiles, referencedFile))) { + writeReferencePath(referencedFile); + emittedReferencedFiles.push(referencedFile); + } + }); + } + emitSourceFile(sourceFile); + } + }); + } + return { + reportedDeclarationError: reportedDeclarationError, + moduleElementDeclarationEmitInfo: moduleElementDeclarationEmitInfo, + synchronousDeclarationOutput: writer.getText(), + referencePathsOutput: referencePathsOutput + }; + function hasInternalAnnotation(range) { + var text = currentSourceFile.text; + var comment = text.substring(range.pos, range.end); + return comment.indexOf("@internal") >= 0; + } + function stripInternal(node) { + if (node) { + var leadingCommentRanges = ts.getLeadingCommentRanges(currentSourceFile.text, node.pos); + if (ts.forEach(leadingCommentRanges, hasInternalAnnotation)) { + return; + } + emitNode(node); + } + } + function createAndSetNewTextWriterWithSymbolWriter() { + var writer = ts.createTextWriter(newLine); + writer.trackSymbol = trackSymbol; + writer.reportInaccessibleThisError = reportInaccessibleThisError; + writer.writeKeyword = writer.write; + writer.writeOperator = writer.write; + writer.writePunctuation = writer.write; + writer.writeSpace = writer.write; + writer.writeStringLiteral = writer.writeLiteral; + writer.writeParameter = writer.write; + writer.writeSymbol = writer.write; + setWriter(writer); + return writer; + } + function setWriter(newWriter) { + writer = newWriter; + write = newWriter.write; + writeTextOfNode = newWriter.writeTextOfNode; + writeLine = newWriter.writeLine; + increaseIndent = newWriter.increaseIndent; + decreaseIndent = newWriter.decreaseIndent; + } + function writeAsynchronousModuleElements(nodes) { + var oldWriter = writer; + ts.forEach(nodes, function (declaration) { + var nodeToCheck; + if (declaration.kind === 211 /* VariableDeclaration */) { + nodeToCheck = declaration.parent.parent; + } + else if (declaration.kind === 225 /* NamedImports */ || declaration.kind === 226 /* ImportSpecifier */ || declaration.kind === 223 /* ImportClause */) { + ts.Debug.fail("We should be getting ImportDeclaration instead to write"); + } + else { + nodeToCheck = declaration; + } + var moduleElementEmitInfo = ts.forEach(moduleElementDeclarationEmitInfo, function (declEmitInfo) { return declEmitInfo.node === nodeToCheck ? declEmitInfo : undefined; }); + if (!moduleElementEmitInfo && asynchronousSubModuleDeclarationEmitInfo) { + moduleElementEmitInfo = ts.forEach(asynchronousSubModuleDeclarationEmitInfo, function (declEmitInfo) { return declEmitInfo.node === nodeToCheck ? declEmitInfo : undefined; }); + } + // If the alias was marked as not visible when we saw its declaration, we would have saved the aliasEmitInfo, but if we haven't yet visited the alias declaration + // then we don't need to write it at this point. We will write it when we actually see its declaration + // Eg. + // export function bar(a: foo.Foo) { } + // import foo = require("foo"); + // 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 === 222 /* ImportDeclaration */) { + // we have to create asynchronous output only after we have collected complete information + // because it is possible to enable multiple bindings as asynchronously visible + moduleElementEmitInfo.isVisible = true; + } + else { + createAndSetNewTextWriterWithSymbolWriter(); + for (var declarationIndent = moduleElementEmitInfo.indent; declarationIndent; declarationIndent--) { + increaseIndent(); + } + if (nodeToCheck.kind === 218 /* ModuleDeclaration */) { + ts.Debug.assert(asynchronousSubModuleDeclarationEmitInfo === undefined); + asynchronousSubModuleDeclarationEmitInfo = []; + } + writeModuleElement(nodeToCheck); + if (nodeToCheck.kind === 218 /* ModuleDeclaration */) { + moduleElementEmitInfo.subModuleElementDeclarationEmitInfo = asynchronousSubModuleDeclarationEmitInfo; + asynchronousSubModuleDeclarationEmitInfo = undefined; + } + moduleElementEmitInfo.asynchronousOutput = writer.getText(); + } + } + }); + setWriter(oldWriter); + } + function handleSymbolAccessibilityError(symbolAccesibilityResult) { + if (symbolAccesibilityResult.accessibility === 0 /* Accessible */) { + // write the aliases + if (symbolAccesibilityResult && symbolAccesibilityResult.aliasesToMakeVisible) { + writeAsynchronousModuleElements(symbolAccesibilityResult.aliasesToMakeVisible); + } + } + else { + // Report error + reportedDeclarationError = true; + var errorInfo = writer.getSymbolAccessibilityDiagnostic(symbolAccesibilityResult); + if (errorInfo) { + if (errorInfo.typeName) { + diagnostics.push(ts.createDiagnosticForNode(symbolAccesibilityResult.errorNode || errorInfo.errorNode, errorInfo.diagnosticMessage, ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, errorInfo.typeName), symbolAccesibilityResult.errorSymbolName, symbolAccesibilityResult.errorModuleName)); + } + else { + diagnostics.push(ts.createDiagnosticForNode(symbolAccesibilityResult.errorNode || errorInfo.errorNode, errorInfo.diagnosticMessage, symbolAccesibilityResult.errorSymbolName, symbolAccesibilityResult.errorModuleName)); + } + } + } + } + function trackSymbol(symbol, enclosingDeclaration, meaning) { + handleSymbolAccessibilityError(resolver.isSymbolAccessible(symbol, enclosingDeclaration, meaning)); + } + function reportInaccessibleThisError() { + if (errorNameNode) { + diagnostics.push(ts.createDiagnosticForNode(errorNameNode, ts.Diagnostics.The_inferred_type_of_0_references_an_inaccessible_this_type_A_type_annotation_is_necessary, ts.declarationNameToString(errorNameNode))); + } + } + function writeTypeOfDeclaration(declaration, type, getSymbolAccessibilityDiagnostic) { + writer.getSymbolAccessibilityDiagnostic = getSymbolAccessibilityDiagnostic; + write(": "); + if (type) { + // Write the type + emitType(type); + } + else { + errorNameNode = declaration.name; + resolver.writeTypeOfDeclaration(declaration, enclosingDeclaration, 2 /* UseTypeOfFunction */, writer); + errorNameNode = undefined; + } + } + function writeReturnTypeAtSignature(signature, getSymbolAccessibilityDiagnostic) { + writer.getSymbolAccessibilityDiagnostic = getSymbolAccessibilityDiagnostic; + write(": "); + if (signature.type) { + // Write the type + emitType(signature.type); + } + else { + errorNameNode = signature.name; + resolver.writeReturnTypeOfSignatureDeclaration(signature, enclosingDeclaration, 2 /* UseTypeOfFunction */, writer); + errorNameNode = undefined; + } + } + function emitLines(nodes) { + for (var _i = 0; _i < nodes.length; _i++) { + var node = nodes[_i]; + emit(node); + } + } + function emitSeparatedList(nodes, separator, eachNodeEmitFn, canEmitFn) { + var currentWriterPos = writer.getTextPos(); + for (var _i = 0; _i < nodes.length; _i++) { + var node = nodes[_i]; + if (!canEmitFn || canEmitFn(node)) { + if (currentWriterPos !== writer.getTextPos()) { + write(separator); + } + currentWriterPos = writer.getTextPos(); + eachNodeEmitFn(node); + } + } + } + function emitCommaList(nodes, eachNodeEmitFn, canEmitFn) { + emitSeparatedList(nodes, ", ", eachNodeEmitFn, canEmitFn); + } + function writeJsDocComments(declaration) { + if (declaration) { + var jsDocComments = ts.getJsDocComments(declaration, currentSourceFile); + ts.emitNewLineBeforeLeadingComments(currentSourceFile, writer, declaration, jsDocComments); + // jsDoc comments are emitted at /*leading comment1 */space/*leading comment*/space + ts.emitComments(currentSourceFile, writer, jsDocComments, /*trailingSeparator*/ true, newLine, ts.writeCommentRange); + } + } + function emitTypeWithNewGetSymbolAccessibilityDiagnostic(type, getSymbolAccessibilityDiagnostic) { + writer.getSymbolAccessibilityDiagnostic = getSymbolAccessibilityDiagnostic; + emitType(type); + } + function emitType(type) { + switch (type.kind) { + case 117 /* AnyKeyword */: + case 130 /* StringKeyword */: + case 128 /* NumberKeyword */: + case 120 /* BooleanKeyword */: + case 131 /* SymbolKeyword */: + case 103 /* VoidKeyword */: + case 97 /* ThisKeyword */: + case 9 /* StringLiteral */: + return writeTextOfNode(currentSourceFile, type); + case 188 /* ExpressionWithTypeArguments */: + return emitExpressionWithTypeArguments(type); + case 151 /* TypeReference */: + return emitTypeReference(type); + case 154 /* TypeQuery */: + return emitTypeQuery(type); + case 156 /* ArrayType */: + return emitArrayType(type); + case 157 /* TupleType */: + return emitTupleType(type); + case 158 /* UnionType */: + return emitUnionType(type); + case 159 /* IntersectionType */: + return emitIntersectionType(type); + case 160 /* ParenthesizedType */: + return emitParenType(type); + case 152 /* FunctionType */: + case 153 /* ConstructorType */: + return emitSignatureDeclarationWithJsDocComments(type); + case 155 /* TypeLiteral */: + return emitTypeLiteral(type); + case 69 /* Identifier */: + return emitEntityName(type); + case 135 /* QualifiedName */: + return emitEntityName(type); + case 150 /* TypePredicate */: + return emitTypePredicate(type); + } + function writeEntityName(entityName) { + if (entityName.kind === 69 /* Identifier */) { + writeTextOfNode(currentSourceFile, entityName); + } + else { + var left = entityName.kind === 135 /* QualifiedName */ ? entityName.left : entityName.expression; + var right = entityName.kind === 135 /* QualifiedName */ ? entityName.right : entityName.name; + writeEntityName(left); + write("."); + writeTextOfNode(currentSourceFile, right); + } + } + function emitEntityName(entityName) { + var visibilityResult = resolver.isEntityNameVisible(entityName, + // Aliases can be written asynchronously so use correct enclosing declaration + entityName.parent.kind === 221 /* ImportEqualsDeclaration */ ? entityName.parent : enclosingDeclaration); + handleSymbolAccessibilityError(visibilityResult); + writeEntityName(entityName); + } + function emitExpressionWithTypeArguments(node) { + if (ts.isSupportedExpressionWithTypeArguments(node)) { + ts.Debug.assert(node.expression.kind === 69 /* Identifier */ || node.expression.kind === 166 /* PropertyAccessExpression */); + emitEntityName(node.expression); + if (node.typeArguments) { + write("<"); + emitCommaList(node.typeArguments, emitType); + write(">"); + } + } + } + function emitTypeReference(type) { + emitEntityName(type.typeName); + if (type.typeArguments) { + write("<"); + emitCommaList(type.typeArguments, emitType); + write(">"); + } + } + function emitTypePredicate(type) { + writeTextOfNode(currentSourceFile, type.parameterName); + write(" is "); + emitType(type.type); + } + function emitTypeQuery(type) { + write("typeof "); + emitEntityName(type.exprName); + } + function emitArrayType(type) { + emitType(type.elementType); + write("[]"); + } + function emitTupleType(type) { + write("["); + emitCommaList(type.elementTypes, emitType); + write("]"); + } + function emitUnionType(type) { + emitSeparatedList(type.types, " | ", emitType); + } + function emitIntersectionType(type) { + emitSeparatedList(type.types, " & ", emitType); + } + function emitParenType(type) { + write("("); + emitType(type.type); + write(")"); + } + function emitTypeLiteral(type) { + write("{"); + if (type.members.length) { + writeLine(); + increaseIndent(); + // write members + emitLines(type.members); + decreaseIndent(); + } + write("}"); + } + } + function emitSourceFile(node) { + currentSourceFile = node; + enclosingDeclaration = node; + emitLines(node.statements); + } + // Return a temp variable name to be used in `export default` statements. + // The temp name will be of the form _default_counter. + // Note that export default is only allowed at most once in a module, so we + // do not need to keep track of created temp names. + function getExportDefaultTempVariableName() { + var baseName = "_default"; + if (!ts.hasProperty(currentSourceFile.identifiers, baseName)) { + return baseName; + } + var count = 0; + while (true) { + var name_18 = baseName + "_" + (++count); + if (!ts.hasProperty(currentSourceFile.identifiers, name_18)) { + return name_18; + } + } + } + function emitExportAssignment(node) { + if (node.expression.kind === 69 /* Identifier */) { + write(node.isExportEquals ? "export = " : "export default "); + writeTextOfNode(currentSourceFile, node.expression); + } + else { + // Expression + var tempVarName = getExportDefaultTempVariableName(); + write("declare var "); + write(tempVarName); + write(": "); + writer.getSymbolAccessibilityDiagnostic = getDefaultExportAccessibilityDiagnostic; + resolver.writeTypeOfExpression(node.expression, enclosingDeclaration, 2 /* UseTypeOfFunction */, writer); + write(";"); + writeLine(); + write(node.isExportEquals ? "export = " : "export default "); + write(tempVarName); + } + write(";"); + writeLine(); + // Make all the declarations visible for the export name + if (node.expression.kind === 69 /* Identifier */) { + var nodes = resolver.collectLinkedAliases(node.expression); + // write each of these declarations asynchronously + writeAsynchronousModuleElements(nodes); + } + function getDefaultExportAccessibilityDiagnostic(diagnostic) { + return { + diagnosticMessage: ts.Diagnostics.Default_export_of_the_module_has_or_is_using_private_name_0, + errorNode: node + }; + } + } + function isModuleElementVisible(node) { + return resolver.isDeclarationVisible(node); + } + function emitModuleElement(node, isModuleElementVisible) { + if (isModuleElementVisible) { + writeModuleElement(node); + } + else if (node.kind === 221 /* ImportEqualsDeclaration */ || + (node.parent.kind === 248 /* SourceFile */ && ts.isExternalModule(currentSourceFile))) { + var isVisible; + if (asynchronousSubModuleDeclarationEmitInfo && node.parent.kind !== 248 /* SourceFile */) { + // Import declaration of another module that is visited async so lets put it in right spot + asynchronousSubModuleDeclarationEmitInfo.push({ + node: node, + outputPos: writer.getTextPos(), + indent: writer.getIndent(), + isVisible: isVisible + }); + } + else { + if (node.kind === 222 /* ImportDeclaration */) { + var importDeclaration = node; + if (importDeclaration.importClause) { + isVisible = (importDeclaration.importClause.name && resolver.isDeclarationVisible(importDeclaration.importClause)) || + isVisibleNamedBinding(importDeclaration.importClause.namedBindings); + } + } + moduleElementDeclarationEmitInfo.push({ + node: node, + outputPos: writer.getTextPos(), + indent: writer.getIndent(), + isVisible: isVisible + }); + } + } + } + function writeModuleElement(node) { + switch (node.kind) { + case 213 /* FunctionDeclaration */: + return writeFunctionDeclaration(node); + case 193 /* VariableStatement */: + return writeVariableStatement(node); + case 215 /* InterfaceDeclaration */: + return writeInterfaceDeclaration(node); + case 214 /* ClassDeclaration */: + return writeClassDeclaration(node); + case 216 /* TypeAliasDeclaration */: + return writeTypeAliasDeclaration(node); + case 217 /* EnumDeclaration */: + return writeEnumDeclaration(node); + case 218 /* ModuleDeclaration */: + return writeModuleDeclaration(node); + case 221 /* ImportEqualsDeclaration */: + return writeImportEqualsDeclaration(node); + case 222 /* ImportDeclaration */: + return writeImportDeclaration(node); + default: + ts.Debug.fail("Unknown symbol kind"); + } + } + function emitModuleElementDeclarationFlags(node) { + // If the node is parented in the current source file we need to emit export declare or just export + if (node.parent === currentSourceFile) { + // If the node is exported + if (node.flags & 1 /* Export */) { + write("export "); + } + if (node.flags & 1024 /* Default */) { + write("default "); + } + else if (node.kind !== 215 /* InterfaceDeclaration */) { + write("declare "); + } + } + } + function emitClassMemberDeclarationFlags(node) { + if (node.flags & 32 /* Private */) { + write("private "); + } + else if (node.flags & 64 /* Protected */) { + write("protected "); + } + if (node.flags & 128 /* Static */) { + write("static "); + } + if (node.flags & 256 /* Abstract */) { + write("abstract "); + } + } + function writeImportEqualsDeclaration(node) { + // note usage of writer. methods instead of aliases created, just to make sure we are using + // correct writer especially to handle asynchronous alias writing + emitJsDocComments(node); + if (node.flags & 1 /* Export */) { + write("export "); + } + write("import "); + writeTextOfNode(currentSourceFile, node.name); + write(" = "); + if (ts.isInternalModuleImportEqualsDeclaration(node)) { + emitTypeWithNewGetSymbolAccessibilityDiagnostic(node.moduleReference, getImportEntityNameVisibilityError); + write(";"); + } + else { + write("require("); + writeTextOfNode(currentSourceFile, ts.getExternalModuleImportEqualsDeclarationExpression(node)); + write(");"); + } + writer.writeLine(); + function getImportEntityNameVisibilityError(symbolAccesibilityResult) { + return { + diagnosticMessage: ts.Diagnostics.Import_declaration_0_is_using_private_name_1, + errorNode: node, + typeName: node.name + }; + } + } + function isVisibleNamedBinding(namedBindings) { + if (namedBindings) { + if (namedBindings.kind === 224 /* NamespaceImport */) { + return resolver.isDeclarationVisible(namedBindings); + } + else { + return ts.forEach(namedBindings.elements, function (namedImport) { return resolver.isDeclarationVisible(namedImport); }); + } + } + } + function writeImportDeclaration(node) { + if (!node.importClause && !(node.flags & 1 /* Export */)) { + // do not write non-exported import declarations that don't have import clauses + return; + } + emitJsDocComments(node); + if (node.flags & 1 /* Export */) { + write("export "); + } + write("import "); + if (node.importClause) { + var currentWriterPos = writer.getTextPos(); + if (node.importClause.name && resolver.isDeclarationVisible(node.importClause)) { + writeTextOfNode(currentSourceFile, node.importClause.name); + } + if (node.importClause.namedBindings && isVisibleNamedBinding(node.importClause.namedBindings)) { + if (currentWriterPos !== writer.getTextPos()) { + // If the default binding was emitted, write the separated + write(", "); + } + if (node.importClause.namedBindings.kind === 224 /* NamespaceImport */) { + write("* as "); + writeTextOfNode(currentSourceFile, node.importClause.namedBindings.name); + } + else { + write("{ "); + emitCommaList(node.importClause.namedBindings.elements, emitImportOrExportSpecifier, resolver.isDeclarationVisible); + write(" }"); + } + } + write(" from "); + } + writeTextOfNode(currentSourceFile, node.moduleSpecifier); + write(";"); + writer.writeLine(); + } + function emitImportOrExportSpecifier(node) { + if (node.propertyName) { + writeTextOfNode(currentSourceFile, node.propertyName); + write(" as "); + } + writeTextOfNode(currentSourceFile, node.name); + } + function emitExportSpecifier(node) { + emitImportOrExportSpecifier(node); + // Make all the declarations visible for the export name + var nodes = resolver.collectLinkedAliases(node.propertyName || node.name); + // write each of these declarations asynchronously + writeAsynchronousModuleElements(nodes); + } + function emitExportDeclaration(node) { + emitJsDocComments(node); + write("export "); + if (node.exportClause) { + write("{ "); + emitCommaList(node.exportClause.elements, emitExportSpecifier); + write(" }"); + } + else { + write("*"); + } + if (node.moduleSpecifier) { + write(" from "); + writeTextOfNode(currentSourceFile, node.moduleSpecifier); + } + write(";"); + writer.writeLine(); + } + function writeModuleDeclaration(node) { + emitJsDocComments(node); + emitModuleElementDeclarationFlags(node); + if (node.flags & 131072 /* Namespace */) { + write("namespace "); + } + else { + write("module "); + } + writeTextOfNode(currentSourceFile, node.name); + while (node.body.kind !== 219 /* ModuleBlock */) { + node = node.body; + write("."); + writeTextOfNode(currentSourceFile, node.name); + } + var prevEnclosingDeclaration = enclosingDeclaration; + enclosingDeclaration = node; + write(" {"); + writeLine(); + increaseIndent(); + emitLines(node.body.statements); + decreaseIndent(); + write("}"); + writeLine(); + enclosingDeclaration = prevEnclosingDeclaration; + } + function writeTypeAliasDeclaration(node) { + var prevEnclosingDeclaration = enclosingDeclaration; + enclosingDeclaration = node; + emitJsDocComments(node); + emitModuleElementDeclarationFlags(node); + write("type "); + writeTextOfNode(currentSourceFile, node.name); + emitTypeParameters(node.typeParameters); + write(" = "); + emitTypeWithNewGetSymbolAccessibilityDiagnostic(node.type, getTypeAliasDeclarationVisibilityError); + write(";"); + writeLine(); + enclosingDeclaration = prevEnclosingDeclaration; + function getTypeAliasDeclarationVisibilityError(symbolAccesibilityResult) { + return { + diagnosticMessage: ts.Diagnostics.Exported_type_alias_0_has_or_is_using_private_name_1, + errorNode: node.type, + typeName: node.name + }; + } + } + function writeEnumDeclaration(node) { + emitJsDocComments(node); + emitModuleElementDeclarationFlags(node); + if (ts.isConst(node)) { + write("const "); + } + write("enum "); + writeTextOfNode(currentSourceFile, node.name); + write(" {"); + writeLine(); + increaseIndent(); + emitLines(node.members); + decreaseIndent(); + write("}"); + writeLine(); + } + function emitEnumMemberDeclaration(node) { + emitJsDocComments(node); + writeTextOfNode(currentSourceFile, node.name); + var enumMemberValue = resolver.getConstantValue(node); + if (enumMemberValue !== undefined) { + write(" = "); + write(enumMemberValue.toString()); + } + write(","); + writeLine(); + } + function isPrivateMethodTypeParameter(node) { + return node.parent.kind === 143 /* MethodDeclaration */ && (node.parent.flags & 32 /* Private */); + } + function emitTypeParameters(typeParameters) { + function emitTypeParameter(node) { + increaseIndent(); + emitJsDocComments(node); + decreaseIndent(); + writeTextOfNode(currentSourceFile, node.name); + // 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 === 152 /* FunctionType */ || + node.parent.kind === 153 /* ConstructorType */ || + (node.parent.parent && node.parent.parent.kind === 155 /* TypeLiteral */)) { + ts.Debug.assert(node.parent.kind === 143 /* MethodDeclaration */ || + node.parent.kind === 142 /* MethodSignature */ || + node.parent.kind === 152 /* FunctionType */ || + node.parent.kind === 153 /* ConstructorType */ || + node.parent.kind === 147 /* CallSignature */ || + node.parent.kind === 148 /* ConstructSignature */); + emitType(node.constraint); + } + else { + emitTypeWithNewGetSymbolAccessibilityDiagnostic(node.constraint, getTypeParameterConstraintVisibilityError); + } + } + function getTypeParameterConstraintVisibilityError(symbolAccesibilityResult) { + // Type parameter constraints are named by user so we should always be able to name it + var diagnosticMessage; + switch (node.parent.kind) { + case 214 /* ClassDeclaration */: + diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_class_has_or_is_using_private_name_1; + break; + case 215 /* InterfaceDeclaration */: + diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1; + break; + case 148 /* ConstructSignature */: + diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; + break; + case 147 /* CallSignature */: + diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; + break; + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: + if (node.parent.flags & 128 /* Static */) { + diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1; + } + else if (node.parent.parent.kind === 214 /* ClassDeclaration */) { + diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_public_method_from_exported_class_has_or_is_using_private_name_1; + } + else { + diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1; + } + break; + case 213 /* FunctionDeclaration */: + diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_function_has_or_is_using_private_name_1; + break; + default: + ts.Debug.fail("This is unknown parent for type parameter: " + node.parent.kind); + } + return { + diagnosticMessage: diagnosticMessage, + errorNode: node, + typeName: node.name + }; + } + } + if (typeParameters) { + write("<"); + emitCommaList(typeParameters, emitTypeParameter); + write(">"); + } + } + function emitHeritageClause(typeReferences, isImplementsList) { + if (typeReferences) { + write(isImplementsList ? " implements " : " extends "); + emitCommaList(typeReferences, emitTypeOfTypeReference); + } + function emitTypeOfTypeReference(node) { + if (ts.isSupportedExpressionWithTypeArguments(node)) { + emitTypeWithNewGetSymbolAccessibilityDiagnostic(node, getHeritageClauseVisibilityError); + } + else if (!isImplementsList && node.expression.kind === 93 /* NullKeyword */) { + write("null"); + } + function getHeritageClauseVisibilityError(symbolAccesibilityResult) { + var diagnosticMessage; + // Heritage clause is written by user so it can always be named + if (node.parent.parent.kind === 214 /* ClassDeclaration */) { + // Class or Interface implemented/extended is inaccessible + diagnosticMessage = isImplementsList ? + ts.Diagnostics.Implements_clause_of_exported_class_0_has_or_is_using_private_name_1 : + ts.Diagnostics.Extends_clause_of_exported_class_0_has_or_is_using_private_name_1; + } + else { + // interface is inaccessible + diagnosticMessage = ts.Diagnostics.Extends_clause_of_exported_interface_0_has_or_is_using_private_name_1; + } + return { + diagnosticMessage: diagnosticMessage, + errorNode: node, + typeName: node.parent.parent.name + }; + } + } + } + function writeClassDeclaration(node) { + function emitParameterProperties(constructorDeclaration) { + if (constructorDeclaration) { + ts.forEach(constructorDeclaration.parameters, function (param) { + if (param.flags & 112 /* AccessibilityModifier */) { + emitPropertyDeclaration(param); + } + }); + } + } + emitJsDocComments(node); + emitModuleElementDeclarationFlags(node); + if (node.flags & 256 /* Abstract */) { + write("abstract "); + } + write("class "); + writeTextOfNode(currentSourceFile, node.name); + var prevEnclosingDeclaration = enclosingDeclaration; + enclosingDeclaration = node; + emitTypeParameters(node.typeParameters); + var baseTypeNode = ts.getClassExtendsHeritageClauseElement(node); + if (baseTypeNode) { + emitHeritageClause([baseTypeNode], /*isImplementsList*/ false); + } + emitHeritageClause(ts.getClassImplementsHeritageClauseElements(node), /*isImplementsList*/ true); + write(" {"); + writeLine(); + increaseIndent(); + emitParameterProperties(ts.getFirstConstructorWithBody(node)); + emitLines(node.members); + decreaseIndent(); + write("}"); + writeLine(); + enclosingDeclaration = prevEnclosingDeclaration; + } + function writeInterfaceDeclaration(node) { + emitJsDocComments(node); + emitModuleElementDeclarationFlags(node); + write("interface "); + writeTextOfNode(currentSourceFile, node.name); + var prevEnclosingDeclaration = enclosingDeclaration; + enclosingDeclaration = node; + emitTypeParameters(node.typeParameters); + emitHeritageClause(ts.getInterfaceBaseTypeNodes(node), /*isImplementsList*/ false); + write(" {"); + writeLine(); + increaseIndent(); + emitLines(node.members); + decreaseIndent(); + write("}"); + writeLine(); + enclosingDeclaration = prevEnclosingDeclaration; + } + function emitPropertyDeclaration(node) { + if (ts.hasDynamicName(node)) { + return; + } + emitJsDocComments(node); + emitClassMemberDeclarationFlags(node); + emitVariableDeclaration(node); + write(";"); + writeLine(); + } + 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 !== 211 /* VariableDeclaration */ || resolver.isDeclarationVisible(node)) { + if (ts.isBindingPattern(node.name)) { + emitBindingPattern(node.name); + } + else { + // If this node is a computed name, it can only be a symbol, because we've already skipped + // it if it's not a well known symbol. In that case, the text of the name will be exactly + // what we want, namely the name expression enclosed in brackets. + writeTextOfNode(currentSourceFile, node.name); + // If optional property emit ? + if ((node.kind === 141 /* PropertyDeclaration */ || node.kind === 140 /* PropertySignature */) && ts.hasQuestionToken(node)) { + write("?"); + } + if ((node.kind === 141 /* PropertyDeclaration */ || node.kind === 140 /* PropertySignature */) && node.parent.kind === 155 /* TypeLiteral */) { + emitTypeOfVariableDeclarationFromTypeLiteral(node); + } + else if (!(node.flags & 32 /* Private */)) { + writeTypeOfDeclaration(node, node.type, getVariableDeclarationTypeVisibilityError); + } + } + } + function getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccesibilityResult) { + if (node.kind === 211 /* VariableDeclaration */) { + return symbolAccesibilityResult.errorModuleName ? + symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? + ts.Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : + ts.Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_private_module_2 : + ts.Diagnostics.Exported_variable_0_has_or_is_using_private_name_1; + } + else if (node.kind === 141 /* PropertyDeclaration */ || node.kind === 140 /* PropertySignature */) { + // TODO(jfreeman): Deal with computed properties in error reporting. + if (node.flags & 128 /* Static */) { + return symbolAccesibilityResult.errorModuleName ? + symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? + ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : + ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : + ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_private_name_1; + } + else if (node.parent.kind === 214 /* ClassDeclaration */) { + return symbolAccesibilityResult.errorModuleName ? + symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? + ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : + ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : + ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_private_name_1; + } + else { + // Interfaces cannot have types that cannot be named + return symbolAccesibilityResult.errorModuleName ? + ts.Diagnostics.Property_0_of_exported_interface_has_or_is_using_name_1_from_private_module_2 : + ts.Diagnostics.Property_0_of_exported_interface_has_or_is_using_private_name_1; + } + } + } + function getVariableDeclarationTypeVisibilityError(symbolAccesibilityResult) { + var diagnosticMessage = getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccesibilityResult); + return diagnosticMessage !== undefined ? { + diagnosticMessage: diagnosticMessage, + errorNode: node, + typeName: node.name + } : undefined; + } + function emitBindingPattern(bindingPattern) { + // Only select non-omitted expression from the bindingPattern's elements. + // We have to do this to avoid emitting trailing commas. + // For example: + // original: var [, c,,] = [ 2,3,4] + // emitted: declare var c: number; // instead of declare var c:number, ; + var elements = []; + for (var _i = 0, _a = bindingPattern.elements; _i < _a.length; _i++) { + var element = _a[_i]; + if (element.kind !== 187 /* OmittedExpression */) { + elements.push(element); + } + } + emitCommaList(elements, emitBindingElement); + } + function emitBindingElement(bindingElement) { + function getBindingElementTypeVisibilityError(symbolAccesibilityResult) { + var diagnosticMessage = getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccesibilityResult); + return diagnosticMessage !== undefined ? { + diagnosticMessage: diagnosticMessage, + errorNode: bindingElement, + typeName: bindingElement.name + } : undefined; + } + if (bindingElement.name) { + if (ts.isBindingPattern(bindingElement.name)) { + emitBindingPattern(bindingElement.name); + } + else { + writeTextOfNode(currentSourceFile, bindingElement.name); + writeTypeOfDeclaration(bindingElement, /*type*/ undefined, getBindingElementTypeVisibilityError); + } + } + } + } + function emitTypeOfVariableDeclarationFromTypeLiteral(node) { + // if this is property of type literal, + // or is parameter of method/call/construct/index signature of type literal + // emit only if type is specified + if (node.type) { + write(": "); + emitType(node.type); + } + } + function isVariableStatementVisible(node) { + return ts.forEach(node.declarationList.declarations, function (varDeclaration) { return resolver.isDeclarationVisible(varDeclaration); }); + } + function writeVariableStatement(node) { + emitJsDocComments(node); + emitModuleElementDeclarationFlags(node); + if (ts.isLet(node.declarationList)) { + write("let "); + } + else if (ts.isConst(node.declarationList)) { + write("const "); + } + else { + write("var "); + } + emitCommaList(node.declarationList.declarations, emitVariableDeclaration, resolver.isDeclarationVisible); + write(";"); + writeLine(); + } + function emitAccessorDeclaration(node) { + if (ts.hasDynamicName(node)) { + return; + } + var accessors = ts.getAllAccessorDeclarations(node.parent.members, node); + var accessorWithTypeAnnotation; + if (node === accessors.firstAccessor) { + emitJsDocComments(accessors.getAccessor); + emitJsDocComments(accessors.setAccessor); + emitClassMemberDeclarationFlags(node); + writeTextOfNode(currentSourceFile, node.name); + if (!(node.flags & 32 /* Private */)) { + accessorWithTypeAnnotation = node; + var type = getTypeAnnotationFromAccessor(node); + if (!type) { + // couldn't get type for the first accessor, try the another one + var anotherAccessor = node.kind === 145 /* GetAccessor */ ? accessors.setAccessor : accessors.getAccessor; + type = getTypeAnnotationFromAccessor(anotherAccessor); + if (type) { + accessorWithTypeAnnotation = anotherAccessor; + } + } + writeTypeOfDeclaration(node, type, getAccessorDeclarationTypeVisibilityError); + } + write(";"); + writeLine(); + } + function getTypeAnnotationFromAccessor(accessor) { + if (accessor) { + return accessor.kind === 145 /* GetAccessor */ + ? accessor.type // Getter - return type + : accessor.parameters.length > 0 + ? accessor.parameters[0].type // Setter parameter type + : undefined; + } + } + function getAccessorDeclarationTypeVisibilityError(symbolAccesibilityResult) { + var diagnosticMessage; + if (accessorWithTypeAnnotation.kind === 146 /* SetAccessor */) { + // Setters have to have type named and cannot infer it so, the type should always be named + if (accessorWithTypeAnnotation.parent.flags & 128 /* Static */) { + diagnosticMessage = symbolAccesibilityResult.errorModuleName ? + ts.Diagnostics.Parameter_0_of_public_static_property_setter_from_exported_class_has_or_is_using_name_1_from_private_module_2 : + ts.Diagnostics.Parameter_0_of_public_static_property_setter_from_exported_class_has_or_is_using_private_name_1; + } + else { + diagnosticMessage = symbolAccesibilityResult.errorModuleName ? + ts.Diagnostics.Parameter_0_of_public_property_setter_from_exported_class_has_or_is_using_name_1_from_private_module_2 : + ts.Diagnostics.Parameter_0_of_public_property_setter_from_exported_class_has_or_is_using_private_name_1; + } + return { + diagnosticMessage: diagnosticMessage, + errorNode: accessorWithTypeAnnotation.parameters[0], + // TODO(jfreeman): Investigate why we are passing node.name instead of node.parameters[0].name + typeName: accessorWithTypeAnnotation.name + }; + } + else { + if (accessorWithTypeAnnotation.flags & 128 /* Static */) { + diagnosticMessage = symbolAccesibilityResult.errorModuleName ? + symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? + ts.Diagnostics.Return_type_of_public_static_property_getter_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : + ts.Diagnostics.Return_type_of_public_static_property_getter_from_exported_class_has_or_is_using_name_0_from_private_module_1 : + ts.Diagnostics.Return_type_of_public_static_property_getter_from_exported_class_has_or_is_using_private_name_0; + } + else { + diagnosticMessage = symbolAccesibilityResult.errorModuleName ? + symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? + ts.Diagnostics.Return_type_of_public_property_getter_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : + ts.Diagnostics.Return_type_of_public_property_getter_from_exported_class_has_or_is_using_name_0_from_private_module_1 : + ts.Diagnostics.Return_type_of_public_property_getter_from_exported_class_has_or_is_using_private_name_0; + } + return { + diagnosticMessage: diagnosticMessage, + errorNode: accessorWithTypeAnnotation.name, + typeName: undefined + }; + } + } + } + function writeFunctionDeclaration(node) { + if (ts.hasDynamicName(node)) { + return; + } + // If we are emitting Method/Constructor it isn't moduleElement and hence already determined to be emitting + // so no need to verify if the declaration is visible + if (!resolver.isImplementationOfOverload(node)) { + emitJsDocComments(node); + if (node.kind === 213 /* FunctionDeclaration */) { + emitModuleElementDeclarationFlags(node); + } + else if (node.kind === 143 /* MethodDeclaration */) { + emitClassMemberDeclarationFlags(node); + } + if (node.kind === 213 /* FunctionDeclaration */) { + write("function "); + writeTextOfNode(currentSourceFile, node.name); + } + else if (node.kind === 144 /* Constructor */) { + write("constructor"); + } + else { + writeTextOfNode(currentSourceFile, node.name); + if (ts.hasQuestionToken(node)) { + write("?"); + } + } + emitSignatureDeclaration(node); + } + } + function emitSignatureDeclarationWithJsDocComments(node) { + emitJsDocComments(node); + emitSignatureDeclaration(node); + } + function emitSignatureDeclaration(node) { + // Construct signature or constructor type write new Signature + if (node.kind === 148 /* ConstructSignature */ || node.kind === 153 /* ConstructorType */) { + write("new "); + } + emitTypeParameters(node.typeParameters); + if (node.kind === 149 /* IndexSignature */) { + write("["); + } + else { + write("("); + } + var prevEnclosingDeclaration = enclosingDeclaration; + enclosingDeclaration = node; + // Parameters + emitCommaList(node.parameters, emitParameterDeclaration); + if (node.kind === 149 /* IndexSignature */) { + write("]"); + } + else { + write(")"); + } + // If this is not a constructor and is not private, emit the return type + var isFunctionTypeOrConstructorType = node.kind === 152 /* FunctionType */ || node.kind === 153 /* ConstructorType */; + if (isFunctionTypeOrConstructorType || node.parent.kind === 155 /* TypeLiteral */) { + // Emit type literal signature return type only if specified + if (node.type) { + write(isFunctionTypeOrConstructorType ? " => " : ": "); + emitType(node.type); + } + } + else if (node.kind !== 144 /* Constructor */ && !(node.flags & 32 /* Private */)) { + writeReturnTypeAtSignature(node, getReturnTypeVisibilityError); + } + enclosingDeclaration = prevEnclosingDeclaration; + if (!isFunctionTypeOrConstructorType) { + write(";"); + writeLine(); + } + function getReturnTypeVisibilityError(symbolAccesibilityResult) { + var diagnosticMessage; + switch (node.kind) { + case 148 /* ConstructSignature */: + // Interfaces cannot have return types that cannot be named + diagnosticMessage = symbolAccesibilityResult.errorModuleName ? + ts.Diagnostics.Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : + ts.Diagnostics.Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_0; + break; + case 147 /* CallSignature */: + // Interfaces cannot have return types that cannot be named + diagnosticMessage = symbolAccesibilityResult.errorModuleName ? + ts.Diagnostics.Return_type_of_call_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : + ts.Diagnostics.Return_type_of_call_signature_from_exported_interface_has_or_is_using_private_name_0; + break; + case 149 /* IndexSignature */: + // Interfaces cannot have return types that cannot be named + diagnosticMessage = symbolAccesibilityResult.errorModuleName ? + ts.Diagnostics.Return_type_of_index_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : + ts.Diagnostics.Return_type_of_index_signature_from_exported_interface_has_or_is_using_private_name_0; + break; + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: + if (node.flags & 128 /* Static */) { + diagnosticMessage = symbolAccesibilityResult.errorModuleName ? + symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? + ts.Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : + 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 === 214 /* ClassDeclaration */) { + diagnosticMessage = symbolAccesibilityResult.errorModuleName ? + symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? + ts.Diagnostics.Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : + ts.Diagnostics.Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_private_module_1 : + ts.Diagnostics.Return_type_of_public_method_from_exported_class_has_or_is_using_private_name_0; + } + else { + // Interfaces cannot have return types that cannot be named + diagnosticMessage = symbolAccesibilityResult.errorModuleName ? + ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : + ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0; + } + break; + case 213 /* FunctionDeclaration */: + diagnosticMessage = symbolAccesibilityResult.errorModuleName ? + symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? + ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : + ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_name_0_from_private_module_1 : + ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_private_name_0; + break; + default: + ts.Debug.fail("This is unknown kind for signature: " + node.kind); + } + return { + diagnosticMessage: diagnosticMessage, + errorNode: node.name || node + }; + } + } + function emitParameterDeclaration(node) { + increaseIndent(); + emitJsDocComments(node); + if (node.dotDotDotToken) { + write("..."); + } + if (ts.isBindingPattern(node.name)) { + // For bindingPattern, we can't simply writeTextOfNode from the source file + // because we want to omit the initializer and using writeTextOfNode will result in initializer get emitted. + // Therefore, we will have to recursively emit each element in the bindingPattern. + emitBindingPattern(node.name); + } + else { + writeTextOfNode(currentSourceFile, node.name); + } + if (resolver.isOptionalParameter(node)) { + write("?"); + } + decreaseIndent(); + if (node.parent.kind === 152 /* FunctionType */ || + node.parent.kind === 153 /* ConstructorType */ || + node.parent.parent.kind === 155 /* TypeLiteral */) { + emitTypeOfVariableDeclarationFromTypeLiteral(node); + } + else if (!(node.parent.flags & 32 /* Private */)) { + writeTypeOfDeclaration(node, node.type, getParameterDeclarationTypeVisibilityError); + } + function getParameterDeclarationTypeVisibilityError(symbolAccesibilityResult) { + var diagnosticMessage = getParameterDeclarationTypeVisibilityDiagnosticMessage(symbolAccesibilityResult); + return diagnosticMessage !== undefined ? { + diagnosticMessage: diagnosticMessage, + errorNode: node, + typeName: node.name + } : undefined; + } + function getParameterDeclarationTypeVisibilityDiagnosticMessage(symbolAccesibilityResult) { + switch (node.parent.kind) { + case 144 /* Constructor */: + return symbolAccesibilityResult.errorModuleName ? + symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? + ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : + ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_private_module_2 : + ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_private_name_1; + case 148 /* ConstructSignature */: + // Interfaces cannot have parameter types that cannot be named + return symbolAccesibilityResult.errorModuleName ? + ts.Diagnostics.Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : + ts.Diagnostics.Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; + case 147 /* CallSignature */: + // Interfaces cannot have parameter types that cannot be named + return symbolAccesibilityResult.errorModuleName ? + ts.Diagnostics.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : + ts.Diagnostics.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: + if (node.parent.flags & 128 /* Static */) { + return symbolAccesibilityResult.errorModuleName ? + symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? + ts.Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : + 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 === 214 /* ClassDeclaration */) { + return symbolAccesibilityResult.errorModuleName ? + symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? + ts.Diagnostics.Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : + ts.Diagnostics.Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_private_module_2 : + ts.Diagnostics.Parameter_0_of_public_method_from_exported_class_has_or_is_using_private_name_1; + } + else { + // Interfaces cannot have parameter types that cannot be named + return symbolAccesibilityResult.errorModuleName ? + 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 213 /* FunctionDeclaration */: + return symbolAccesibilityResult.errorModuleName ? + symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? + ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : + ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_name_1_from_private_module_2 : + ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_private_name_1; + default: + ts.Debug.fail("This is unknown parent for parameter: " + node.parent.kind); + } + } + function emitBindingPattern(bindingPattern) { + // We have to explicitly emit square bracket and bracket because these tokens are not store inside the node. + if (bindingPattern.kind === 161 /* ObjectBindingPattern */) { + write("{"); + emitCommaList(bindingPattern.elements, emitBindingElement); + write("}"); + } + else if (bindingPattern.kind === 162 /* ArrayBindingPattern */) { + write("["); + var elements = bindingPattern.elements; + emitCommaList(elements, emitBindingElement); + if (elements && elements.hasTrailingComma) { + write(", "); + } + write("]"); + } + } + function emitBindingElement(bindingElement) { + function getBindingElementTypeVisibilityError(symbolAccesibilityResult) { + var diagnosticMessage = getParameterDeclarationTypeVisibilityDiagnosticMessage(symbolAccesibilityResult); + return diagnosticMessage !== undefined ? { + diagnosticMessage: diagnosticMessage, + errorNode: bindingElement, + typeName: bindingElement.name + } : undefined; + } + if (bindingElement.kind === 187 /* OmittedExpression */) { + // If bindingElement is an omittedExpression (i.e. containing elision), + // we will emit blank space (although this may differ from users' original code, + // it allows emitSeparatedList to write separator appropriately) + // Example: + // original: function foo([, x, ,]) {} + // emit : function foo([ , x, , ]) {} + write(" "); + } + else if (bindingElement.kind === 163 /* BindingElement */) { + if (bindingElement.propertyName) { + // bindingElement has propertyName property in the following case: + // { y: [a,b,c] ...} -> bindingPattern will have a property called propertyName for "y" + // We have to explicitly emit the propertyName before descending into its binding elements. + // Example: + // original: function foo({y: [a,b,c]}) {} + // emit : declare function foo({y: [a, b, c]}: { y: [any, any, any] }) void; + writeTextOfNode(currentSourceFile, bindingElement.propertyName); + write(": "); + } + if (bindingElement.name) { + if (ts.isBindingPattern(bindingElement.name)) { + // If it is a nested binding pattern, we will recursively descend into each element and emit each one separately. + // In the case of rest element, we will omit rest element. + // Example: + // original: function foo([a, [[b]], c] = [1,[["string"]], 3]) {} + // emit : declare function foo([a, [[b]], c]: [number, [[string]], number]): void; + // original with rest: function foo([a, ...c]) {} + // emit : declare function foo([a, ...c]): void; + emitBindingPattern(bindingElement.name); + } + else { + ts.Debug.assert(bindingElement.name.kind === 69 /* Identifier */); + // If the node is just an identifier, we will simply emit the text associated with the node's name + // Example: + // original: function foo({y = 10, x}) {} + // emit : declare function foo({y, x}: {number, any}): void; + if (bindingElement.dotDotDotToken) { + write("..."); + } + writeTextOfNode(currentSourceFile, bindingElement.name); + } + } + } + } + } + function emitNode(node) { + switch (node.kind) { + case 213 /* FunctionDeclaration */: + case 218 /* ModuleDeclaration */: + case 221 /* ImportEqualsDeclaration */: + case 215 /* InterfaceDeclaration */: + case 214 /* ClassDeclaration */: + case 216 /* TypeAliasDeclaration */: + case 217 /* EnumDeclaration */: + return emitModuleElement(node, isModuleElementVisible(node)); + case 193 /* VariableStatement */: + return emitModuleElement(node, isVariableStatementVisible(node)); + case 222 /* ImportDeclaration */: + // Import declaration without import clause is visible, otherwise it is not visible + return emitModuleElement(node, /*isModuleElementVisible*/ !node.importClause); + case 228 /* ExportDeclaration */: + return emitExportDeclaration(node); + case 144 /* Constructor */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: + return writeFunctionDeclaration(node); + case 148 /* ConstructSignature */: + case 147 /* CallSignature */: + case 149 /* IndexSignature */: + return emitSignatureDeclarationWithJsDocComments(node); + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: + return emitAccessorDeclaration(node); + case 141 /* PropertyDeclaration */: + case 140 /* PropertySignature */: + return emitPropertyDeclaration(node); + case 247 /* EnumMember */: + return emitEnumMemberDeclaration(node); + case 227 /* ExportAssignment */: + return emitExportAssignment(node); + case 248 /* SourceFile */: + return emitSourceFile(node); + } + } + function writeReferencePath(referencedFile) { + var declFileName = referencedFile.flags & 8192 /* DeclarationFile */ + ? referencedFile.fileName // Declaration file, use declaration file name + : ts.shouldEmitToOwnFile(referencedFile, compilerOptions) + ? ts.getOwnEmitOutputFilePath(referencedFile, host, ".d.ts") // Own output file so get the .d.ts file + : ts.removeFileExtension(compilerOptions.outFile || compilerOptions.out) + ".d.ts"; // Global out file + declFileName = ts.getRelativePathToDirectoryOrUrl(ts.getDirectoryPath(ts.normalizeSlashes(jsFilePath)), declFileName, host.getCurrentDirectory(), host.getCanonicalFileName, + /*isAbsolutePathAnUrl*/ false); + referencePathsOutput += "/// " + newLine; + } + } + /* @internal */ + function writeDeclarationFile(jsFilePath, sourceFile, host, resolver, diagnostics) { + var emitDeclarationResult = emitDeclarations(host, resolver, diagnostics, jsFilePath, sourceFile); + // TODO(shkamat): Should we not write any declaration file if any of them can produce error, + // or should we just not write this file like we are doing now + if (!emitDeclarationResult.reportedDeclarationError) { + var declarationOutput = emitDeclarationResult.referencePathsOutput + + getDeclarationOutput(emitDeclarationResult.synchronousDeclarationOutput, emitDeclarationResult.moduleElementDeclarationEmitInfo); + ts.writeFile(host, diagnostics, ts.removeFileExtension(jsFilePath) + ".d.ts", declarationOutput, host.getCompilerOptions().emitBOM); + } + function getDeclarationOutput(synchronousDeclarationOutput, moduleElementDeclarationEmitInfo) { + var appliedSyncOutputPos = 0; + var declarationOutput = ""; + // apply asynchronous additions to the synchronous output + ts.forEach(moduleElementDeclarationEmitInfo, function (aliasEmitInfo) { + if (aliasEmitInfo.asynchronousOutput) { + declarationOutput += synchronousDeclarationOutput.substring(appliedSyncOutputPos, aliasEmitInfo.outputPos); + declarationOutput += getDeclarationOutput(aliasEmitInfo.asynchronousOutput, aliasEmitInfo.subModuleElementDeclarationEmitInfo); + appliedSyncOutputPos = aliasEmitInfo.outputPos; + } + }); + declarationOutput += synchronousDeclarationOutput.substring(appliedSyncOutputPos); + return declarationOutput; + } + } + ts.writeDeclarationFile = writeDeclarationFile; +})(ts || (ts = {})); +/// +/// +/* @internal */ +var ts; +(function (ts) { + function isExternalModuleOrDeclarationFile(sourceFile) { + return ts.isExternalModule(sourceFile) || ts.isDeclarationFile(sourceFile); + } + ts.isExternalModuleOrDeclarationFile = isExternalModuleOrDeclarationFile; + var entities = { + "quot": 0x0022, + "amp": 0x0026, + "apos": 0x0027, + "lt": 0x003C, + "gt": 0x003E, + "nbsp": 0x00A0, + "iexcl": 0x00A1, + "cent": 0x00A2, + "pound": 0x00A3, + "curren": 0x00A4, + "yen": 0x00A5, + "brvbar": 0x00A6, + "sect": 0x00A7, + "uml": 0x00A8, + "copy": 0x00A9, + "ordf": 0x00AA, + "laquo": 0x00AB, + "not": 0x00AC, + "shy": 0x00AD, + "reg": 0x00AE, + "macr": 0x00AF, + "deg": 0x00B0, + "plusmn": 0x00B1, + "sup2": 0x00B2, + "sup3": 0x00B3, + "acute": 0x00B4, + "micro": 0x00B5, + "para": 0x00B6, + "middot": 0x00B7, + "cedil": 0x00B8, + "sup1": 0x00B9, + "ordm": 0x00BA, + "raquo": 0x00BB, + "frac14": 0x00BC, + "frac12": 0x00BD, + "frac34": 0x00BE, + "iquest": 0x00BF, + "Agrave": 0x00C0, + "Aacute": 0x00C1, + "Acirc": 0x00C2, + "Atilde": 0x00C3, + "Auml": 0x00C4, + "Aring": 0x00C5, + "AElig": 0x00C6, + "Ccedil": 0x00C7, + "Egrave": 0x00C8, + "Eacute": 0x00C9, + "Ecirc": 0x00CA, + "Euml": 0x00CB, + "Igrave": 0x00CC, + "Iacute": 0x00CD, + "Icirc": 0x00CE, + "Iuml": 0x00CF, + "ETH": 0x00D0, + "Ntilde": 0x00D1, + "Ograve": 0x00D2, + "Oacute": 0x00D3, + "Ocirc": 0x00D4, + "Otilde": 0x00D5, + "Ouml": 0x00D6, + "times": 0x00D7, + "Oslash": 0x00D8, + "Ugrave": 0x00D9, + "Uacute": 0x00DA, + "Ucirc": 0x00DB, + "Uuml": 0x00DC, + "Yacute": 0x00DD, + "THORN": 0x00DE, + "szlig": 0x00DF, + "agrave": 0x00E0, + "aacute": 0x00E1, + "acirc": 0x00E2, + "atilde": 0x00E3, + "auml": 0x00E4, + "aring": 0x00E5, + "aelig": 0x00E6, + "ccedil": 0x00E7, + "egrave": 0x00E8, + "eacute": 0x00E9, + "ecirc": 0x00EA, + "euml": 0x00EB, + "igrave": 0x00EC, + "iacute": 0x00ED, + "icirc": 0x00EE, + "iuml": 0x00EF, + "eth": 0x00F0, + "ntilde": 0x00F1, + "ograve": 0x00F2, + "oacute": 0x00F3, + "ocirc": 0x00F4, + "otilde": 0x00F5, + "ouml": 0x00F6, + "divide": 0x00F7, + "oslash": 0x00F8, + "ugrave": 0x00F9, + "uacute": 0x00FA, + "ucirc": 0x00FB, + "uuml": 0x00FC, + "yacute": 0x00FD, + "thorn": 0x00FE, + "yuml": 0x00FF, + "OElig": 0x0152, + "oelig": 0x0153, + "Scaron": 0x0160, + "scaron": 0x0161, + "Yuml": 0x0178, + "fnof": 0x0192, + "circ": 0x02C6, + "tilde": 0x02DC, + "Alpha": 0x0391, + "Beta": 0x0392, + "Gamma": 0x0393, + "Delta": 0x0394, + "Epsilon": 0x0395, + "Zeta": 0x0396, + "Eta": 0x0397, + "Theta": 0x0398, + "Iota": 0x0399, + "Kappa": 0x039A, + "Lambda": 0x039B, + "Mu": 0x039C, + "Nu": 0x039D, + "Xi": 0x039E, + "Omicron": 0x039F, + "Pi": 0x03A0, + "Rho": 0x03A1, + "Sigma": 0x03A3, + "Tau": 0x03A4, + "Upsilon": 0x03A5, + "Phi": 0x03A6, + "Chi": 0x03A7, + "Psi": 0x03A8, + "Omega": 0x03A9, + "alpha": 0x03B1, + "beta": 0x03B2, + "gamma": 0x03B3, + "delta": 0x03B4, + "epsilon": 0x03B5, + "zeta": 0x03B6, + "eta": 0x03B7, + "theta": 0x03B8, + "iota": 0x03B9, + "kappa": 0x03BA, + "lambda": 0x03BB, + "mu": 0x03BC, + "nu": 0x03BD, + "xi": 0x03BE, + "omicron": 0x03BF, + "pi": 0x03C0, + "rho": 0x03C1, + "sigmaf": 0x03C2, + "sigma": 0x03C3, + "tau": 0x03C4, + "upsilon": 0x03C5, + "phi": 0x03C6, + "chi": 0x03C7, + "psi": 0x03C8, + "omega": 0x03C9, + "thetasym": 0x03D1, + "upsih": 0x03D2, + "piv": 0x03D6, + "ensp": 0x2002, + "emsp": 0x2003, + "thinsp": 0x2009, + "zwnj": 0x200C, + "zwj": 0x200D, + "lrm": 0x200E, + "rlm": 0x200F, + "ndash": 0x2013, + "mdash": 0x2014, + "lsquo": 0x2018, + "rsquo": 0x2019, + "sbquo": 0x201A, + "ldquo": 0x201C, + "rdquo": 0x201D, + "bdquo": 0x201E, + "dagger": 0x2020, + "Dagger": 0x2021, + "bull": 0x2022, + "hellip": 0x2026, + "permil": 0x2030, + "prime": 0x2032, + "Prime": 0x2033, + "lsaquo": 0x2039, + "rsaquo": 0x203A, + "oline": 0x203E, + "frasl": 0x2044, + "euro": 0x20AC, + "image": 0x2111, + "weierp": 0x2118, + "real": 0x211C, + "trade": 0x2122, + "alefsym": 0x2135, + "larr": 0x2190, + "uarr": 0x2191, + "rarr": 0x2192, + "darr": 0x2193, + "harr": 0x2194, + "crarr": 0x21B5, + "lArr": 0x21D0, + "uArr": 0x21D1, + "rArr": 0x21D2, + "dArr": 0x21D3, + "hArr": 0x21D4, + "forall": 0x2200, + "part": 0x2202, + "exist": 0x2203, + "empty": 0x2205, + "nabla": 0x2207, + "isin": 0x2208, + "notin": 0x2209, + "ni": 0x220B, + "prod": 0x220F, + "sum": 0x2211, + "minus": 0x2212, + "lowast": 0x2217, + "radic": 0x221A, + "prop": 0x221D, + "infin": 0x221E, + "ang": 0x2220, + "and": 0x2227, + "or": 0x2228, + "cap": 0x2229, + "cup": 0x222A, + "int": 0x222B, + "there4": 0x2234, + "sim": 0x223C, + "cong": 0x2245, + "asymp": 0x2248, + "ne": 0x2260, + "equiv": 0x2261, + "le": 0x2264, + "ge": 0x2265, + "sub": 0x2282, + "sup": 0x2283, + "nsub": 0x2284, + "sube": 0x2286, + "supe": 0x2287, + "oplus": 0x2295, + "otimes": 0x2297, + "perp": 0x22A5, + "sdot": 0x22C5, + "lceil": 0x2308, + "rceil": 0x2309, + "lfloor": 0x230A, + "rfloor": 0x230B, + "lang": 0x2329, + "rang": 0x232A, + "loz": 0x25CA, + "spades": 0x2660, + "clubs": 0x2663, + "hearts": 0x2665, + "diams": 0x2666 + }; + // Flags enum to track count of temp variables and a few dedicated names + var TempFlags; + (function (TempFlags) { + TempFlags[TempFlags["Auto"] = 0] = "Auto"; + TempFlags[TempFlags["CountMask"] = 268435455] = "CountMask"; + TempFlags[TempFlags["_i"] = 268435456] = "_i"; + })(TempFlags || (TempFlags = {})); + // 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) { + // emit output for the __extends helper function + var extendsHelper = "\nvar __extends = (this && this.__extends) || function (d, b) {\n for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];\n function __() { this.constructor = d; }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n};"; + // emit output for the __decorate helper function + var decorateHelper = "\nvar __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\n return c > 3 && r && Object.defineProperty(target, key, r), r;\n};"; + // emit output for the __metadata helper function + var metadataHelper = "\nvar __metadata = (this && this.__metadata) || function (k, v) {\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(k, v);\n};"; + // emit output for the __param helper function + var paramHelper = "\nvar __param = (this && this.__param) || function (paramIndex, decorator) {\n return function (target, key) { decorator(target, key, paramIndex); }\n};"; + var awaiterHelper = "\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promise, generator) {\n return new Promise(function (resolve, reject) {\n generator = generator.call(thisArg, _arguments);\n function cast(value) { return value instanceof Promise && value.constructor === Promise ? value : new Promise(function (resolve) { resolve(value); }); }\n function onfulfill(value) { try { step(\"next\", value); } catch (e) { reject(e); } }\n function onreject(value) { try { step(\"throw\", value); } catch (e) { reject(e); } }\n function step(verb, value) {\n var result = generator[verb](value);\n result.done ? resolve(result.value) : cast(result.value).then(onfulfill, onreject);\n }\n step(\"next\", void 0);\n });\n};"; + var compilerOptions = host.getCompilerOptions(); + var languageVersion = compilerOptions.target || 0 /* ES3 */; + var modulekind = compilerOptions.module ? compilerOptions.module : languageVersion === 2 /* ES6 */ ? 5 /* ES6 */ : 0 /* None */; + var sourceMapDataList = compilerOptions.sourceMap || compilerOptions.inlineSourceMap ? [] : undefined; + var diagnostics = []; + var newLine = host.getNewLine(); + var jsxDesugaring = host.getCompilerOptions().jsx !== 1 /* Preserve */; + var shouldEmitJsx = function (s) { return (s.languageVariant === 1 /* JSX */ && !jsxDesugaring); }; + if (targetSourceFile === undefined) { + ts.forEach(host.getSourceFiles(), function (sourceFile) { + if (ts.shouldEmitToOwnFile(sourceFile, compilerOptions)) { + var jsFilePath = ts.getOwnEmitOutputFilePath(sourceFile, host, shouldEmitJsx(sourceFile) ? ".jsx" : ".js"); + emitFile(jsFilePath, sourceFile); + } + }); + if (compilerOptions.outFile || compilerOptions.out) { + emitFile(compilerOptions.outFile || compilerOptions.out); + } + } + else { + // targetSourceFile is specified (e.g calling emitter from language service or calling getSemanticDiagnostic from language service) + if (ts.shouldEmitToOwnFile(targetSourceFile, compilerOptions)) { + var jsFilePath = ts.getOwnEmitOutputFilePath(targetSourceFile, host, shouldEmitJsx(targetSourceFile) ? ".jsx" : ".js"); + emitFile(jsFilePath, targetSourceFile); + } + else if (!ts.isDeclarationFile(targetSourceFile) && (compilerOptions.outFile || compilerOptions.out)) { + emitFile(compilerOptions.outFile || compilerOptions.out); + } + } + // Sort and make the unique list of diagnostics + diagnostics = ts.sortAndDeduplicateDiagnostics(diagnostics); + return { + emitSkipped: false, + diagnostics: diagnostics, + sourceMaps: sourceMapDataList + }; + function isNodeDescendentOf(node, ancestor) { + while (node) { + if (node === ancestor) + return true; + node = node.parent; + } + return false; + } + function isUniqueLocalName(name, container) { + for (var node = container; isNodeDescendentOf(node, container); node = node.nextContainer) { + if (node.locals && ts.hasProperty(node.locals, name)) { + // We conservatively include alias symbols to cover cases where they're emitted as locals + if (node.locals[name].flags & (107455 /* Value */ | 1048576 /* ExportValue */ | 8388608 /* Alias */)) { + return false; + } + } + } + return true; + } + var Jump; + (function (Jump) { + Jump[Jump["Break"] = 2] = "Break"; + Jump[Jump["Continue"] = 4] = "Continue"; + Jump[Jump["Return"] = 8] = "Return"; + })(Jump || (Jump = {})); + function setLabeledJump(state, isBreak, labelText, labelMarker) { + if (isBreak) { + if (!state.labeledNonLocalBreaks) { + state.labeledNonLocalBreaks = {}; + } + state.labeledNonLocalBreaks[labelText] = labelMarker; + } + else { + if (!state.labeledNonLocalContinues) { + state.labeledNonLocalContinues = {}; + } + state.labeledNonLocalContinues[labelText] = labelMarker; + } + } + function hoistVariableDeclarationFromLoop(state, declaration) { + if (!state.hoistedLocalVariables) { + state.hoistedLocalVariables = []; + } + visit(declaration.name); + function visit(node) { + if (node.kind === 69 /* Identifier */) { + state.hoistedLocalVariables.push(node); + } + else { + for (var _a = 0, _b = node.elements; _a < _b.length; _a++) { + var element = _b[_a]; + visit(element.name); + } + } + } + } + function emitJavaScript(jsFilePath, root) { + var writer = ts.createTextWriter(newLine); + var write = writer.write, writeTextOfNode = writer.writeTextOfNode, writeLine = writer.writeLine, increaseIndent = writer.increaseIndent, decreaseIndent = writer.decreaseIndent; + var currentSourceFile; + // name of an exporter function if file is a System external module + // System.register([...], function () {...}) + // exporting in System modules looks like: + // export var x; ... x = 1 + // => + // var x;... exporter("x", x = 1) + var exportFunctionForFile; + var generatedNameSet = {}; + var nodeToGeneratedName = []; + var computedPropertyNamesToGeneratedNames; + var convertedLoopState; + var extendsEmitted = false; + var decorateEmitted = false; + var paramEmitted = false; + var awaiterEmitted = false; + var tempFlags = 0; + var tempVariables; + var tempParameters; + var externalImports; + var exportSpecifiers; + var exportEquals; + var hasExportStars; + /** Write emitted output to disk */ + var writeEmittedFiles = writeJavaScriptFile; + var detachedCommentsInfo; + var writeComment = ts.writeCommentRange; + /** Emit a node */ + var emit = emitNodeWithCommentsAndWithoutSourcemap; + /** Called just before starting emit of a node */ + var emitStart = function (node) { }; + /** Called once the emit of the node is done */ + var emitEnd = function (node) { }; + /** Emit the text for the given token that comes after startPos + * This by default writes the text provided with the given tokenKind + * but if optional emitFn callback is provided the text is emitted using the callback instead of default text + * @param tokenKind the kind of the token to search and emit + * @param startPos the position in the source to start searching for the token + * @param emitFn if given will be invoked to emit the text instead of actual token emit */ + var emitToken = emitTokenText; + /** Called to before starting the lexical scopes as in function/class in the emitted code because of node + * @param scopeDeclaration node that starts the lexical scope + * @param scopeName Optional name of this scope instead of deducing one from the declaration node */ + var scopeEmitStart = function (scopeDeclaration, scopeName) { }; + /** Called after coming out of the scope */ + var scopeEmitEnd = function () { }; + /** Sourcemap data that will get encoded */ + var sourceMapData; + /** If removeComments is true, no leading-comments needed to be emitted **/ + var emitLeadingCommentsOfPosition = compilerOptions.removeComments ? function (pos) { } : emitLeadingCommentsOfPositionWorker; + var moduleEmitDelegates = (_a = {}, + _a[5 /* ES6 */] = emitES6Module, + _a[2 /* AMD */] = emitAMDModule, + _a[4 /* System */] = emitSystemModule, + _a[3 /* UMD */] = emitUMDModule, + _a[1 /* CommonJS */] = emitCommonJSModule, + _a + ); + if (compilerOptions.sourceMap || compilerOptions.inlineSourceMap) { + initializeEmitterWithSourceMaps(); + } + if (root) { + // Do not call emit directly. It does not set the currentSourceFile. + emitSourceFile(root); + } + else { + ts.forEach(host.getSourceFiles(), function (sourceFile) { + if (!isExternalModuleOrDeclarationFile(sourceFile)) { + emitSourceFile(sourceFile); + } + }); + } + writeLine(); + writeEmittedFiles(writer.getText(), /*writeByteOrderMark*/ compilerOptions.emitBOM); + return; + function emitSourceFile(sourceFile) { + currentSourceFile = sourceFile; + exportFunctionForFile = undefined; + emit(sourceFile); + } + function isUniqueName(name) { + return !resolver.hasGlobalName(name) && + !ts.hasProperty(currentSourceFile.identifiers, name) && + !ts.hasProperty(generatedNameSet, name); + } + // Return the next available name in the pattern _a ... _z, _0, _1, ... + // TempFlags._i or TempFlags._n may be used to express a preference for that dedicated name. + // Note that names generated by makeTempVariableName and makeUniqueName will never conflict. + function makeTempVariableName(flags) { + if (flags && !(tempFlags & flags)) { + var name_19 = flags === 268435456 /* _i */ ? "_i" : "_n"; + if (isUniqueName(name_19)) { + tempFlags |= flags; + return name_19; + } + } + while (true) { + var count = tempFlags & 268435455 /* CountMask */; + tempFlags++; + // Skip over 'i' and 'n' + if (count !== 8 && count !== 13) { + var name_20 = count < 26 ? "_" + String.fromCharCode(97 /* a */ + count) : "_" + (count - 26); + if (isUniqueName(name_20)) { + return name_20; + } + } + } + } + // Generate a name that is unique within the current file and doesn't conflict with any names + // in global scope. The name is formed by adding an '_n' suffix to the specified base name, + // where n is a positive integer. Note that names generated by makeTempVariableName and + // makeUniqueName are guaranteed to never conflict. + function makeUniqueName(baseName) { + // Find the first unique 'name_n', where n is a positive number + if (baseName.charCodeAt(baseName.length - 1) !== 95 /* _ */) { + baseName += "_"; + } + var i = 1; + while (true) { + var generatedName = baseName + i; + if (isUniqueName(generatedName)) { + return generatedNameSet[generatedName] = generatedName; + } + i++; + } + } + function generateNameForModuleOrEnum(node) { + var name = node.name.text; + // Use module/enum name itself if it is unique, otherwise make a unique variation + return isUniqueLocalName(name, node) ? name : makeUniqueName(name); + } + function generateNameForImportOrExportDeclaration(node) { + var expr = ts.getExternalModuleName(node); + var baseName = expr.kind === 9 /* StringLiteral */ ? + ts.escapeIdentifier(ts.makeIdentifierFromModuleName(expr.text)) : "module"; + return makeUniqueName(baseName); + } + function generateNameForExportDefault() { + return makeUniqueName("default"); + } + function generateNameForClassExpression() { + return makeUniqueName("class"); + } + function generateNameForNode(node) { + switch (node.kind) { + case 69 /* Identifier */: + return makeUniqueName(node.text); + case 218 /* ModuleDeclaration */: + case 217 /* EnumDeclaration */: + return generateNameForModuleOrEnum(node); + case 222 /* ImportDeclaration */: + case 228 /* ExportDeclaration */: + return generateNameForImportOrExportDeclaration(node); + case 213 /* FunctionDeclaration */: + case 214 /* ClassDeclaration */: + case 227 /* ExportAssignment */: + return generateNameForExportDefault(); + case 186 /* ClassExpression */: + return generateNameForClassExpression(); + } + } + function getGeneratedNameForNode(node) { + var id = ts.getNodeId(node); + return nodeToGeneratedName[id] || (nodeToGeneratedName[id] = ts.unescapeIdentifier(generateNameForNode(node))); + } + function initializeEmitterWithSourceMaps() { + var sourceMapDir; // The directory in which sourcemap will be + // Current source map file and its index in the sources list + var sourceMapSourceIndex = -1; + // Names and its index map + var sourceMapNameIndexMap = {}; + var sourceMapNameIndices = []; + function getSourceMapNameIndex() { + return sourceMapNameIndices.length ? ts.lastOrUndefined(sourceMapNameIndices) : -1; + } + // Last recorded and encoded spans + var lastRecordedSourceMapSpan; + var lastEncodedSourceMapSpan = { + emittedLine: 1, + emittedColumn: 1, + sourceLine: 1, + sourceColumn: 1, + sourceIndex: 0 + }; + var lastEncodedNameIndex = 0; + // Encoding for sourcemap span + function encodeLastRecordedSourceMapSpan() { + if (!lastRecordedSourceMapSpan || lastRecordedSourceMapSpan === lastEncodedSourceMapSpan) { + return; + } + var prevEncodedEmittedColumn = lastEncodedSourceMapSpan.emittedColumn; + // Line/Comma delimiters + if (lastEncodedSourceMapSpan.emittedLine === lastRecordedSourceMapSpan.emittedLine) { + // Emit comma to separate the entry + if (sourceMapData.sourceMapMappings) { + sourceMapData.sourceMapMappings += ","; + } + } + else { + // Emit line delimiters + for (var encodedLine = lastEncodedSourceMapSpan.emittedLine; encodedLine < lastRecordedSourceMapSpan.emittedLine; encodedLine++) { + sourceMapData.sourceMapMappings += ";"; + } + prevEncodedEmittedColumn = 1; + } + // 1. Relative Column 0 based + sourceMapData.sourceMapMappings += base64VLQFormatEncode(lastRecordedSourceMapSpan.emittedColumn - prevEncodedEmittedColumn); + // 2. Relative sourceIndex + sourceMapData.sourceMapMappings += base64VLQFormatEncode(lastRecordedSourceMapSpan.sourceIndex - lastEncodedSourceMapSpan.sourceIndex); + // 3. Relative sourceLine 0 based + sourceMapData.sourceMapMappings += base64VLQFormatEncode(lastRecordedSourceMapSpan.sourceLine - lastEncodedSourceMapSpan.sourceLine); + // 4. Relative sourceColumn 0 based + sourceMapData.sourceMapMappings += base64VLQFormatEncode(lastRecordedSourceMapSpan.sourceColumn - lastEncodedSourceMapSpan.sourceColumn); + // 5. Relative namePosition 0 based + if (lastRecordedSourceMapSpan.nameIndex >= 0) { + sourceMapData.sourceMapMappings += base64VLQFormatEncode(lastRecordedSourceMapSpan.nameIndex - lastEncodedNameIndex); + lastEncodedNameIndex = lastRecordedSourceMapSpan.nameIndex; + } + lastEncodedSourceMapSpan = lastRecordedSourceMapSpan; + sourceMapData.sourceMapDecodedMappings.push(lastEncodedSourceMapSpan); + function base64VLQFormatEncode(inValue) { + function base64FormatEncode(inValue) { + if (inValue < 64) { + return "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(inValue); + } + throw TypeError(inValue + ": not a 64 based value"); + } + // Add a new least significant bit that has the sign of the value. + // if negative number the least significant bit that gets added to the number has value 1 + // else least significant bit value that gets added is 0 + // eg. -1 changes to binary : 01 [1] => 3 + // +1 changes to binary : 01 [0] => 2 + if (inValue < 0) { + inValue = ((-inValue) << 1) + 1; + } + else { + inValue = inValue << 1; + } + // Encode 5 bits at a time starting from least significant bits + var encodedStr = ""; + do { + var currentDigit = inValue & 31; // 11111 + inValue = inValue >> 5; + if (inValue > 0) { + // There are still more digits to decode, set the msb (6th bit) + currentDigit = currentDigit | 32; + } + encodedStr = encodedStr + base64FormatEncode(currentDigit); + } while (inValue > 0); + return encodedStr; + } + } + function recordSourceMapSpan(pos) { + var sourceLinePos = ts.getLineAndCharacterOfPosition(currentSourceFile, pos); + // Convert the location to be one-based. + sourceLinePos.line++; + sourceLinePos.character++; + var emittedLine = writer.getLine(); + var emittedColumn = writer.getColumn(); + // If this location wasn't recorded or the location in source is going backwards, record the span + if (!lastRecordedSourceMapSpan || + lastRecordedSourceMapSpan.emittedLine !== emittedLine || + lastRecordedSourceMapSpan.emittedColumn !== emittedColumn || + (lastRecordedSourceMapSpan.sourceIndex === sourceMapSourceIndex && + (lastRecordedSourceMapSpan.sourceLine > sourceLinePos.line || + (lastRecordedSourceMapSpan.sourceLine === sourceLinePos.line && lastRecordedSourceMapSpan.sourceColumn > sourceLinePos.character)))) { + // Encode the last recordedSpan before assigning new + encodeLastRecordedSourceMapSpan(); + // New span + lastRecordedSourceMapSpan = { + emittedLine: emittedLine, + emittedColumn: emittedColumn, + sourceLine: sourceLinePos.line, + sourceColumn: sourceLinePos.character, + nameIndex: getSourceMapNameIndex(), + sourceIndex: sourceMapSourceIndex + }; + } + 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; + } + } + function recordEmitNodeStartSpan(node) { + // Get the token pos after skipping to the token (ignoring the leading trivia) + recordSourceMapSpan(ts.skipTrivia(currentSourceFile.text, node.pos)); + } + function recordEmitNodeEndSpan(node) { + recordSourceMapSpan(node.end); + } + function writeTextWithSpanRecord(tokenKind, startPos, emitFn) { + var tokenStartPos = ts.skipTrivia(currentSourceFile.text, startPos); + recordSourceMapSpan(tokenStartPos); + var tokenEndPos = emitTokenText(tokenKind, tokenStartPos, emitFn); + recordSourceMapSpan(tokenEndPos); + return tokenEndPos; + } + function recordNewSourceFileStart(node) { + // Add the file to tsFilePaths + // If sourceroot option: Use the relative path corresponding to the common directory path + // otherwise source locations relative to map file location + var sourcesDirectoryPath = compilerOptions.sourceRoot ? host.getCommonSourceDirectory() : sourceMapDir; + sourceMapData.sourceMapSources.push(ts.getRelativePathToDirectoryOrUrl(sourcesDirectoryPath, node.fileName, host.getCurrentDirectory(), host.getCanonicalFileName, + /*isAbsolutePathAnUrl*/ true)); + sourceMapSourceIndex = sourceMapData.sourceMapSources.length - 1; + // The one that can be used from program to get the actual source file + sourceMapData.inputSourceFileNames.push(node.fileName); + if (compilerOptions.inlineSources) { + if (!sourceMapData.sourceMapSourcesContent) { + sourceMapData.sourceMapSourcesContent = []; + } + sourceMapData.sourceMapSourcesContent.push(node.text); + } + } + function recordScopeNameOfNode(node, scopeName) { + function recordScopeNameIndex(scopeNameIndex) { + sourceMapNameIndices.push(scopeNameIndex); + } + function recordScopeNameStart(scopeName) { + var scopeNameIndex = -1; + if (scopeName) { + var parentIndex = getSourceMapNameIndex(); + if (parentIndex !== -1) { + // Child scopes are always shown with a dot (even if they have no name), + // unless it is a computed property. Then it is shown with brackets, + // but the brackets are included in the name. + var name_21 = node.name; + if (!name_21 || name_21.kind !== 136 /* ComputedPropertyName */) { + scopeName = "." + scopeName; + } + scopeName = sourceMapData.sourceMapNames[parentIndex] + scopeName; + } + scopeNameIndex = ts.getProperty(sourceMapNameIndexMap, scopeName); + if (scopeNameIndex === undefined) { + scopeNameIndex = sourceMapData.sourceMapNames.length; + sourceMapData.sourceMapNames.push(scopeName); + sourceMapNameIndexMap[scopeName] = scopeNameIndex; + } + } + recordScopeNameIndex(scopeNameIndex); + } + if (scopeName) { + // The scope was already given a name use it + recordScopeNameStart(scopeName); + } + else if (node.kind === 213 /* FunctionDeclaration */ || + node.kind === 173 /* FunctionExpression */ || + node.kind === 143 /* MethodDeclaration */ || + node.kind === 142 /* MethodSignature */ || + node.kind === 145 /* GetAccessor */ || + node.kind === 146 /* SetAccessor */ || + node.kind === 218 /* ModuleDeclaration */ || + node.kind === 214 /* ClassDeclaration */ || + node.kind === 217 /* EnumDeclaration */) { + // Declaration and has associated name use it + if (node.name) { + var name_22 = node.name; + // For computed property names, the text will include the brackets + scopeName = name_22.kind === 136 /* ComputedPropertyName */ + ? ts.getTextOfNode(name_22) + : node.name.text; + } + recordScopeNameStart(scopeName); + } + else { + // Block just use the name from upper level scope + recordScopeNameIndex(getSourceMapNameIndex()); + } + } + function recordScopeNameEnd() { + sourceMapNameIndices.pop(); + } + ; + function writeCommentRangeWithMap(curentSourceFile, writer, comment, newLine) { + recordSourceMapSpan(comment.pos); + ts.writeCommentRange(currentSourceFile, writer, comment, newLine); + recordSourceMapSpan(comment.end); + } + function serializeSourceMapContents(version, file, sourceRoot, sources, names, mappings, sourcesContent) { + if (typeof JSON !== "undefined") { + var map_1 = { + version: version, + file: file, + sourceRoot: sourceRoot, + sources: sources, + names: names, + mappings: mappings + }; + if (sourcesContent !== undefined) { + map_1.sourcesContent = sourcesContent; + } + return JSON.stringify(map_1); + } + return "{\"version\":" + version + ",\"file\":\"" + ts.escapeString(file) + "\",\"sourceRoot\":\"" + ts.escapeString(sourceRoot) + "\",\"sources\":[" + serializeStringArray(sources) + "],\"names\":[" + serializeStringArray(names) + "],\"mappings\":\"" + ts.escapeString(mappings) + "\" " + (sourcesContent !== undefined ? ",\"sourcesContent\":[" + serializeStringArray(sourcesContent) + "]" : "") + "}"; + function serializeStringArray(list) { + var output = ""; + for (var i = 0, n = list.length; i < n; i++) { + if (i) { + output += ","; + } + output += "\"" + ts.escapeString(list[i]) + "\""; + } + return output; + } + } + function writeJavaScriptAndSourceMapFile(emitOutput, writeByteOrderMark) { + encodeLastRecordedSourceMapSpan(); + var sourceMapText = serializeSourceMapContents(3, sourceMapData.sourceMapFile, sourceMapData.sourceMapSourceRoot, sourceMapData.sourceMapSources, sourceMapData.sourceMapNames, sourceMapData.sourceMapMappings, sourceMapData.sourceMapSourcesContent); + sourceMapDataList.push(sourceMapData); + var sourceMapUrl; + if (compilerOptions.inlineSourceMap) { + // Encode the sourceMap into the sourceMap url + var base64SourceMapText = ts.convertToBase64(sourceMapText); + sourceMapUrl = "//# sourceMappingURL=data:application/json;base64," + base64SourceMapText; + } + else { + // Write source map file + ts.writeFile(host, diagnostics, sourceMapData.sourceMapFilePath, sourceMapText, /*writeByteOrderMark*/ false); + sourceMapUrl = "//# sourceMappingURL=" + sourceMapData.jsSourceMappingURL; + } + // Write sourcemap url to the js file and write the js file + writeJavaScriptFile(emitOutput + sourceMapUrl, writeByteOrderMark); + } + // Initialize source map data + var sourceMapJsFile = ts.getBaseFileName(ts.normalizeSlashes(jsFilePath)); + sourceMapData = { + sourceMapFilePath: jsFilePath + ".map", + jsSourceMappingURL: sourceMapJsFile + ".map", + sourceMapFile: sourceMapJsFile, + sourceMapSourceRoot: compilerOptions.sourceRoot || "", + sourceMapSources: [], + inputSourceFileNames: [], + sourceMapNames: [], + sourceMapMappings: "", + sourceMapSourcesContent: undefined, + sourceMapDecodedMappings: [] + }; + // Normalize source root and make sure it has trailing "/" so that it can be used to combine paths with the + // relative paths of the sources list in the sourcemap + sourceMapData.sourceMapSourceRoot = ts.normalizeSlashes(sourceMapData.sourceMapSourceRoot); + if (sourceMapData.sourceMapSourceRoot.length && sourceMapData.sourceMapSourceRoot.charCodeAt(sourceMapData.sourceMapSourceRoot.length - 1) !== 47 /* slash */) { + sourceMapData.sourceMapSourceRoot += ts.directorySeparator; + } + if (compilerOptions.mapRoot) { + sourceMapDir = ts.normalizeSlashes(compilerOptions.mapRoot); + if (root) { + // For modules or multiple emit files the mapRoot will have directory structure like the sources + // So if src\a.ts and src\lib\b.ts are compiled together user would be moving the maps into mapRoot\a.js.map and mapRoot\lib\b.js.map + sourceMapDir = ts.getDirectoryPath(ts.getSourceFilePathInNewDir(root, host, sourceMapDir)); + } + if (!ts.isRootedDiskPath(sourceMapDir) && !ts.isUrl(sourceMapDir)) { + // The relative paths are relative to the common directory + sourceMapDir = ts.combinePaths(host.getCommonSourceDirectory(), sourceMapDir); + sourceMapData.jsSourceMappingURL = ts.getRelativePathToDirectoryOrUrl(ts.getDirectoryPath(ts.normalizePath(jsFilePath)), // get the relative sourceMapDir path based on jsFilePath + ts.combinePaths(sourceMapDir, sourceMapData.jsSourceMappingURL), // this is where user expects to see sourceMap + host.getCurrentDirectory(), host.getCanonicalFileName, + /*isAbsolutePathAnUrl*/ true); + } + else { + sourceMapData.jsSourceMappingURL = ts.combinePaths(sourceMapDir, sourceMapData.jsSourceMappingURL); + } + } + else { + sourceMapDir = ts.getDirectoryPath(ts.normalizePath(jsFilePath)); + } + function emitNodeWithSourceMap(node) { + if (node) { + if (ts.nodeIsSynthesized(node)) { + return emitNodeWithoutSourceMap(node); + } + if (node.kind !== 248 /* SourceFile */) { + recordEmitNodeStartSpan(node); + emitNodeWithoutSourceMap(node); + recordEmitNodeEndSpan(node); + } + else { + recordNewSourceFileStart(node); + emitNodeWithoutSourceMap(node); + } + } + } + function emitNodeWithCommentsAndWithSourcemap(node) { + emitNodeConsideringCommentsOption(node, emitNodeWithSourceMap); + } + writeEmittedFiles = writeJavaScriptAndSourceMapFile; + emit = emitNodeWithCommentsAndWithSourcemap; + emitStart = recordEmitNodeStartSpan; + emitEnd = recordEmitNodeEndSpan; + emitToken = writeTextWithSpanRecord; + scopeEmitStart = recordScopeNameOfNode; + scopeEmitEnd = recordScopeNameEnd; + writeComment = writeCommentRangeWithMap; + } + function writeJavaScriptFile(emitOutput, writeByteOrderMark) { + ts.writeFile(host, diagnostics, jsFilePath, emitOutput, writeByteOrderMark); + } + // Create a temporary variable with a unique unused name. + function createTempVariable(flags) { + var result = ts.createSynthesizedNode(69 /* Identifier */); + result.text = makeTempVariableName(flags); + return result; + } + function recordTempDeclaration(name) { + if (!tempVariables) { + tempVariables = []; + } + tempVariables.push(name); + } + function createAndRecordTempVariable(flags) { + var temp = createTempVariable(flags); + recordTempDeclaration(temp); + return temp; + } + function emitTempDeclarations(newLine) { + if (tempVariables) { + if (newLine) { + writeLine(); + } + else { + write(" "); + } + write("var "); + emitCommaList(tempVariables); + write(";"); + } + } + function emitTokenText(tokenKind, startPos, emitFn) { + var tokenString = ts.tokenToString(tokenKind); + if (emitFn) { + emitFn(); + } + else { + write(tokenString); + } + return startPos + tokenString.length; + } + function emitOptional(prefix, node) { + if (node) { + write(prefix); + emit(node); + } + } + function emitParenthesizedIf(node, parenthesized) { + if (parenthesized) { + write("("); + } + emit(node); + if (parenthesized) { + write(")"); + } + } + function emitTrailingCommaIfPresent(nodeList) { + if (nodeList.hasTrailingComma) { + write(","); + } + } + function emitLinePreservingList(parent, nodes, allowTrailingComma, spacesBetweenBraces) { + ts.Debug.assert(nodes.length > 0); + increaseIndent(); + if (nodeStartPositionsAreOnSameLine(parent, nodes[0])) { + if (spacesBetweenBraces) { + write(" "); + } + } + else { + writeLine(); + } + for (var i = 0, n = nodes.length; i < n; i++) { + if (i) { + if (nodeEndIsOnSameLineAsNodeStart(nodes[i - 1], nodes[i])) { + write(", "); + } + else { + write(","); + writeLine(); + } + } + emit(nodes[i]); + } + if (nodes.hasTrailingComma && allowTrailingComma) { + write(","); + } + decreaseIndent(); + if (nodeEndPositionsAreOnSameLine(parent, ts.lastOrUndefined(nodes))) { + if (spacesBetweenBraces) { + write(" "); + } + } + else { + writeLine(); + } + } + function emitList(nodes, start, count, multiLine, trailingComma, leadingComma, noTrailingNewLine, emitNode) { + if (!emitNode) { + emitNode = emit; + } + for (var i = 0; i < count; i++) { + if (multiLine) { + if (i || leadingComma) { + write(","); + } + writeLine(); + } + else { + if (i || leadingComma) { + write(", "); + } + } + var node = nodes[start + i]; + // This emitting is to make sure we emit following comment properly + // ...(x, /*comment1*/ y)... + // ^ => node.pos + // "comment1" is not considered leading comment for "y" but rather + // considered as trailing comment of the previous node. + emitTrailingCommentsOfPosition(node.pos); + emitNode(node); + leadingComma = true; + } + if (trailingComma) { + write(","); + } + if (multiLine && !noTrailingNewLine) { + writeLine(); + } + return count; + } + function emitCommaList(nodes) { + if (nodes) { + emitList(nodes, 0, nodes.length, /*multiline*/ false, /*trailingComma*/ false); + } + } + function emitLines(nodes) { + emitLinesStartingAt(nodes, /*startIndex*/ 0); + } + function emitLinesStartingAt(nodes, startIndex) { + for (var i = startIndex; i < nodes.length; i++) { + writeLine(); + emit(nodes[i]); + } + } + function isBinaryOrOctalIntegerLiteral(node, text) { + if (node.kind === 8 /* NumericLiteral */ && text.length > 1) { + switch (text.charCodeAt(1)) { + case 98 /* b */: + case 66 /* B */: + case 111 /* o */: + case 79 /* O */: + return true; + } + } + return false; + } + function emitLiteral(node) { + var text = getLiteralText(node); + if ((compilerOptions.sourceMap || compilerOptions.inlineSourceMap) && (node.kind === 9 /* StringLiteral */ || ts.isTemplateLiteralKind(node.kind))) { + writer.writeLiteral(text); + } + else if (languageVersion < 2 /* ES6 */ && isBinaryOrOctalIntegerLiteral(node, text)) { + write(node.text); + } + else { + write(text); + } + } + function getLiteralText(node) { + // 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 */ && (ts.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 (node.parent) { + return ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, node); + } + // If we can't reach the original source text, use the canonical form if it's a number, + // or an escaped quoted form of the original text if it's string-like. + switch (node.kind) { + case 9 /* StringLiteral */: + return getQuotedEscapedLiteralText("\"", node.text, "\""); + case 11 /* NoSubstitutionTemplateLiteral */: + return getQuotedEscapedLiteralText("`", node.text, "`"); + case 12 /* TemplateHead */: + return getQuotedEscapedLiteralText("`", node.text, "${"); + case 13 /* TemplateMiddle */: + return getQuotedEscapedLiteralText("}", node.text, "${"); + case 14 /* TemplateTail */: + return getQuotedEscapedLiteralText("}", node.text, "`"); + case 8 /* NumericLiteral */: + return node.text; + } + ts.Debug.fail("Literal kind '" + node.kind + "' not accounted for."); + } + function getQuotedEscapedLiteralText(leftQuote, text, rightQuote) { + return leftQuote + ts.escapeNonAsciiCharacters(ts.escapeString(text)) + rightQuote; + } + function emitDownlevelRawTemplateLiteral(node) { + // 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"); + text = ts.escapeString(text); + write("\"" + text + "\""); + } + function emitDownlevelTaggedTemplateArray(node, literalEmitter) { + write("["); + if (node.template.kind === 11 /* NoSubstitutionTemplateLiteral */) { + literalEmitter(node.template); + } + else { + literalEmitter(node.template.head); + ts.forEach(node.template.templateSpans, function (child) { + write(", "); + literalEmitter(child.literal); + }); + } + write("]"); + } + function emitDownlevelTaggedTemplate(node) { + var tempVariable = createAndRecordTempVariable(0 /* Auto */); + write("("); + emit(tempVariable); + write(" = "); + emitDownlevelTaggedTemplateArray(node, emit); + write(", "); + emit(tempVariable); + write(".raw = "); + emitDownlevelTaggedTemplateArray(node, emitDownlevelRawTemplateLiteral); + write(", "); + emitParenthesizedIf(node.tag, needsParenthesisForPropertyAccessOrInvocation(node.tag)); + write("("); + emit(tempVariable); + // Now we emit the expressions + if (node.template.kind === 183 /* TemplateExpression */) { + ts.forEach(node.template.templateSpans, function (templateSpan) { + write(", "); + var needsParens = templateSpan.expression.kind === 181 /* BinaryExpression */ + && templateSpan.expression.operatorToken.kind === 24 /* CommaToken */; + emitParenthesizedIf(templateSpan.expression, needsParens); + }); + } + write("))"); + } + function emitTemplateExpression(node) { + // In ES6 mode and above, we can simply emit each portion of a template in order, but in + // ES3 & ES5 we must convert the template expression into a series of string concatenations. + if (languageVersion >= 2 /* ES6 */) { + ts.forEachChild(node, emit); + return; + } + var emitOuterParens = ts.isExpression(node.parent) + && templateNeedsParens(node, node.parent); + if (emitOuterParens) { + write("("); + } + var headEmitted = false; + if (shouldEmitTemplateHead()) { + emitLiteral(node.head); + headEmitted = true; + } + for (var i = 0, n = node.templateSpans.length; i < n; i++) { + var templateSpan = node.templateSpans[i]; + // Check if the expression has operands and binds its operands less closely than binary '+'. + // If it does, we need to wrap 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 needsParens = templateSpan.expression.kind !== 172 /* ParenthesizedExpression */ + && comparePrecedenceToBinaryPlus(templateSpan.expression) !== 1 /* GreaterThan */; + if (i > 0 || headEmitted) { + // If this is the first span and the head was not emitted, then this templateSpan's + // expression will be the first to be emitted. Don't emit the preceding ' + ' in that + // case. + write(" + "); + } + emitParenthesizedIf(templateSpan.expression, needsParens); + // 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 (templateSpan.literal.text.length !== 0) { + write(" + "); + emitLiteral(templateSpan.literal); + } + } + if (emitOuterParens) { + write(")"); + } + function shouldEmitTemplateHead() { + // If this expression has an empty head literal and the first template span has a non-empty + // literal, then emitting the empty head literal is not necessary. + // `${ foo } and ${ bar }` + // can be emitted as + // foo + " and " + bar + // This is because it is only required that one of the first two operands in the emit + // output must be a string literal, so that the other operand and all following operands + // are forced into strings. + // + // If the first template span has an empty literal, then the head must still be emitted. + // `${ foo }${ bar }` + // must still be emitted as + // "" + foo + bar + // 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; + } + function templateNeedsParens(template, parent) { + switch (parent.kind) { + case 168 /* CallExpression */: + case 169 /* NewExpression */: + return parent.expression === template; + case 170 /* TaggedTemplateExpression */: + case 172 /* ParenthesizedExpression */: + return false; + default: + return comparePrecedenceToBinaryPlus(parent) !== -1 /* LessThan */; + } + } + /** + * Returns whether the expression has lesser, greater, + * or equal precedence to the binary '+' operator + */ + function comparePrecedenceToBinaryPlus(expression) { + // All binary expressions have lower precedence than '+' apart from '*', '/', and '%' + // which have greater precedence and '-' which has equal precedence. + // All unary operators have a higher precedence apart from yield. + // Arrow functions and conditionals have a lower precedence, + // although we convert the former into regular function expressions in ES5 mode, + // and in ES6 mode this function won't get called anyway. + // + // TODO (drosen): Note that we need to account for the upcoming 'yield' and + // spread ('...') unary operators that are anticipated for ES6. + switch (expression.kind) { + case 181 /* BinaryExpression */: + switch (expression.operatorToken.kind) { + case 37 /* AsteriskToken */: + case 39 /* SlashToken */: + case 40 /* PercentToken */: + return 1 /* GreaterThan */; + case 35 /* PlusToken */: + case 36 /* MinusToken */: + return 0 /* EqualTo */; + default: + return -1 /* LessThan */; + } + case 184 /* YieldExpression */: + case 182 /* ConditionalExpression */: + return -1 /* LessThan */; + default: + return 1 /* GreaterThan */; + } + } + } + function emitTemplateSpan(span) { + emit(span.expression); + emit(span.literal); + } + function jsxEmitReact(node) { + /// Emit a tag name, which is either '"div"' for lower-cased names, or + /// 'Div' for upper-cased or dotted names + function emitTagName(name) { + if (name.kind === 69 /* Identifier */ && ts.isIntrinsicJsxName(name.text)) { + write("\""); + emit(name); + write("\""); + } + else { + emit(name); + } + } + /// Emit an attribute name, which is quoted if it needs to be quoted. Because + /// these emit into an object literal property name, we don't need to be worried + /// about keywords, just non-identifier characters + function emitAttributeName(name) { + if (/[A-Za-z_]+[\w*]/.test(name.text)) { + write("\""); + emit(name); + write("\""); + } + else { + emit(name); + } + } + /// Emit an name/value pair for an attribute (e.g. "x: 3") + function emitJsxAttribute(node) { + emitAttributeName(node.name); + write(": "); + if (node.initializer) { + emit(node.initializer); + } + else { + write("true"); + } + } + function emitJsxElement(openingNode, children) { + var syntheticReactRef = ts.createSynthesizedNode(69 /* Identifier */); + syntheticReactRef.text = "React"; + syntheticReactRef.parent = openingNode; + // Call React.createElement(tag, ... + emitLeadingComments(openingNode); + emitExpressionIdentifier(syntheticReactRef); + write(".createElement("); + emitTagName(openingNode.tagName); + write(", "); + // Attribute list + if (openingNode.attributes.length === 0) { + // When there are no attributes, React wants "null" + write("null"); + } + else { + // Either emit one big object literal (no spread attribs), or + // a call to React.__spread + var attrs = openingNode.attributes; + if (ts.forEach(attrs, function (attr) { return attr.kind === 239 /* JsxSpreadAttribute */; })) { + emitExpressionIdentifier(syntheticReactRef); + write(".__spread("); + var haveOpenedObjectLiteral = false; + for (var i_1 = 0; i_1 < attrs.length; i_1++) { + if (attrs[i_1].kind === 239 /* JsxSpreadAttribute */) { + // If this is the first argument, we need to emit a {} as the first argument + if (i_1 === 0) { + write("{}, "); + } + if (haveOpenedObjectLiteral) { + write("}"); + haveOpenedObjectLiteral = false; + } + if (i_1 > 0) { + write(", "); + } + emit(attrs[i_1].expression); + } + else { + ts.Debug.assert(attrs[i_1].kind === 238 /* JsxAttribute */); + if (haveOpenedObjectLiteral) { + write(", "); + } + else { + haveOpenedObjectLiteral = true; + if (i_1 > 0) { + write(", "); + } + write("{"); + } + emitJsxAttribute(attrs[i_1]); + } + } + if (haveOpenedObjectLiteral) + write("}"); + write(")"); // closing paren to React.__spread( + } + else { + // One object literal with all the attributes in them + write("{"); + for (var i = 0; i < attrs.length; i++) { + if (i > 0) { + write(", "); + } + emitJsxAttribute(attrs[i]); + } + write("}"); + } + } + // Children + if (children) { + for (var i = 0; i < children.length; i++) { + // Don't emit empty expressions + if (children[i].kind === 240 /* JsxExpression */ && !(children[i].expression)) { + continue; + } + // Don't emit empty strings + if (children[i].kind === 236 /* JsxText */) { + var text = getTextToEmit(children[i]); + if (text !== undefined) { + write(", \""); + write(text); + write("\""); + } + } + else { + write(", "); + emit(children[i]); + } + } + } + // Closing paren + write(")"); // closes "React.createElement(" + emitTrailingComments(openingNode); + } + if (node.kind === 233 /* JsxElement */) { + emitJsxElement(node.openingElement, node.children); + } + else { + ts.Debug.assert(node.kind === 234 /* JsxSelfClosingElement */); + emitJsxElement(node); + } + } + function jsxEmitPreserve(node) { + function emitJsxAttribute(node) { + emit(node.name); + if (node.initializer) { + write("="); + emit(node.initializer); + } + } + function emitJsxSpreadAttribute(node) { + write("{..."); + emit(node.expression); + write("}"); + } + function emitAttributes(attribs) { + for (var i = 0, n = attribs.length; i < n; i++) { + if (i > 0) { + write(" "); + } + if (attribs[i].kind === 239 /* JsxSpreadAttribute */) { + emitJsxSpreadAttribute(attribs[i]); + } + else { + ts.Debug.assert(attribs[i].kind === 238 /* JsxAttribute */); + emitJsxAttribute(attribs[i]); + } + } + } + function emitJsxOpeningOrSelfClosingElement(node) { + write("<"); + emit(node.tagName); + if (node.attributes.length > 0 || (node.kind === 234 /* JsxSelfClosingElement */)) { + write(" "); + } + emitAttributes(node.attributes); + if (node.kind === 234 /* JsxSelfClosingElement */) { + write("/>"); + } + else { + write(">"); + } + } + function emitJsxClosingElement(node) { + write(""); + } + function emitJsxElement(node) { + emitJsxOpeningOrSelfClosingElement(node.openingElement); + for (var i = 0, n = node.children.length; i < n; i++) { + emit(node.children[i]); + } + emitJsxClosingElement(node.closingElement); + } + if (node.kind === 233 /* JsxElement */) { + emitJsxElement(node); + } + else { + ts.Debug.assert(node.kind === 234 /* JsxSelfClosingElement */); + emitJsxOpeningOrSelfClosingElement(node); + } + } + // This function specifically handles numeric/string literals for enum and accessor 'identifiers'. + // In a sense, it does not actually emit identifiers as much as it declares a name for a specific property. + // For example, this is utilized when feeding in a result to Object.defineProperty. + function emitExpressionForPropertyName(node) { + ts.Debug.assert(node.kind !== 163 /* BindingElement */); + if (node.kind === 9 /* StringLiteral */) { + emitLiteral(node); + } + else if (node.kind === 136 /* ComputedPropertyName */) { + // if this is a decorated computed property, we will need to capture the result + // of the property expression so that we can apply decorators later. This is to ensure + // we don't introduce unintended side effects: + // + // class C { + // [_a = x]() { } + // } + // + // The emit for the decorated computed property decorator is: + // + // __decorate([dec], C.prototype, _a, Object.getOwnPropertyDescriptor(C.prototype, _a)); + // + if (ts.nodeIsDecorated(node.parent)) { + if (!computedPropertyNamesToGeneratedNames) { + computedPropertyNamesToGeneratedNames = []; + } + var generatedName = computedPropertyNamesToGeneratedNames[ts.getNodeId(node)]; + if (generatedName) { + // we have already generated a variable for this node, write that value instead. + write(generatedName); + return; + } + generatedName = createAndRecordTempVariable(0 /* Auto */).text; + computedPropertyNamesToGeneratedNames[ts.getNodeId(node)] = generatedName; + write(generatedName); + write(" = "); + } + emit(node.expression); + } + else { + write("\""); + if (node.kind === 8 /* NumericLiteral */) { + write(node.text); + } + else { + writeTextOfNode(currentSourceFile, node); + } + write("\""); + } + } + function isExpressionIdentifier(node) { + var parent = node.parent; + switch (parent.kind) { + case 164 /* ArrayLiteralExpression */: + case 189 /* AsExpression */: + case 181 /* BinaryExpression */: + case 168 /* CallExpression */: + case 241 /* CaseClause */: + case 136 /* ComputedPropertyName */: + case 182 /* ConditionalExpression */: + case 139 /* Decorator */: + case 175 /* DeleteExpression */: + case 197 /* DoStatement */: + case 167 /* ElementAccessExpression */: + case 227 /* ExportAssignment */: + case 195 /* ExpressionStatement */: + case 188 /* ExpressionWithTypeArguments */: + case 199 /* ForStatement */: + case 200 /* ForInStatement */: + case 201 /* ForOfStatement */: + case 196 /* IfStatement */: + case 234 /* JsxSelfClosingElement */: + case 235 /* JsxOpeningElement */: + case 239 /* JsxSpreadAttribute */: + case 240 /* JsxExpression */: + case 169 /* NewExpression */: + case 172 /* ParenthesizedExpression */: + case 180 /* PostfixUnaryExpression */: + case 179 /* PrefixUnaryExpression */: + case 204 /* ReturnStatement */: + case 246 /* ShorthandPropertyAssignment */: + case 185 /* SpreadElementExpression */: + case 206 /* SwitchStatement */: + case 170 /* TaggedTemplateExpression */: + case 190 /* TemplateSpan */: + case 208 /* ThrowStatement */: + case 171 /* TypeAssertionExpression */: + case 176 /* TypeOfExpression */: + case 177 /* VoidExpression */: + case 198 /* WhileStatement */: + case 205 /* WithStatement */: + case 184 /* YieldExpression */: + return true; + case 163 /* BindingElement */: + case 247 /* EnumMember */: + case 138 /* Parameter */: + case 245 /* PropertyAssignment */: + case 141 /* PropertyDeclaration */: + case 211 /* VariableDeclaration */: + return parent.initializer === node; + case 166 /* PropertyAccessExpression */: + return parent.expression === node; + case 174 /* ArrowFunction */: + case 173 /* FunctionExpression */: + return parent.body === node; + case 221 /* ImportEqualsDeclaration */: + return parent.moduleReference === node; + case 135 /* QualifiedName */: + return parent.left === node; + } + return false; + } + function emitExpressionIdentifier(node) { + if (resolver.getNodeCheckFlags(node) & 2048 /* LexicalArguments */) { + write("_arguments"); + return; + } + var container = resolver.getReferencedExportContainer(node); + if (container) { + if (container.kind === 248 /* SourceFile */) { + // Identifier references module export + if (modulekind !== 5 /* ES6 */ && modulekind !== 4 /* System */) { + write("exports."); + } + } + else { + // Identifier references namespace export + write(getGeneratedNameForNode(container)); + write("."); + } + } + else { + if (modulekind !== 5 /* ES6 */) { + var declaration = resolver.getReferencedImportDeclaration(node); + if (declaration) { + if (declaration.kind === 223 /* ImportClause */) { + // Identifier references default import + write(getGeneratedNameForNode(declaration.parent)); + write(languageVersion === 0 /* ES3 */ ? "[\"default\"]" : ".default"); + return; + } + else if (declaration.kind === 226 /* ImportSpecifier */) { + // Identifier references named import + write(getGeneratedNameForNode(declaration.parent.parent.parent)); + var name_23 = declaration.propertyName || declaration.name; + var identifier = ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, name_23); + if (languageVersion === 0 /* ES3 */ && identifier === "default") { + write("[\"default\"]"); + } + else { + write("."); + write(identifier); + } + return; + } + } + } + if (languageVersion !== 2 /* ES6 */) { + var declaration = resolver.getReferencedNestedRedeclaration(node); + if (declaration) { + write(getGeneratedNameForNode(declaration.name)); + return; + } + } + } + if (ts.nodeIsSynthesized(node)) { + write(node.text); + } + else { + writeTextOfNode(currentSourceFile, node); + } + } + function isNameOfNestedRedeclaration(node) { + if (languageVersion < 2 /* ES6 */) { + var parent_6 = node.parent; + switch (parent_6.kind) { + case 163 /* BindingElement */: + case 214 /* ClassDeclaration */: + case 217 /* EnumDeclaration */: + case 211 /* VariableDeclaration */: + return parent_6.name === node && resolver.isNestedRedeclaration(parent_6); + } + } + return false; + } + function emitIdentifier(node) { + if (convertedLoopState) { + if (node.text == "arguments" && resolver.isArgumentsLocalBinding(node)) { + // in converted loop body arguments cannot be used directly. + var name_24 = convertedLoopState.argumentsName || (convertedLoopState.argumentsName = makeUniqueName("arguments")); + write(name_24); + return; + } + } + if (!node.parent) { + write(node.text); + } + else if (isExpressionIdentifier(node)) { + emitExpressionIdentifier(node); + } + else if (isNameOfNestedRedeclaration(node)) { + write(getGeneratedNameForNode(node)); + } + else if (ts.nodeIsSynthesized(node)) { + write(node.text); + } + else { + writeTextOfNode(currentSourceFile, node); + } + } + function emitThis(node) { + if (resolver.getNodeCheckFlags(node) & 2 /* LexicalThis */) { + write("_this"); + } + else { + write("this"); + } + } + function emitSuper(node) { + if (languageVersion >= 2 /* ES6 */) { + write("super"); + } + else { + var flags = resolver.getNodeCheckFlags(node); + if (flags & 256 /* SuperInstance */) { + write("_super.prototype"); + } + else { + write("_super"); + } + } + } + function emitObjectBindingPattern(node) { + write("{ "); + var elements = node.elements; + emitList(elements, 0, elements.length, /*multiLine*/ false, /*trailingComma*/ elements.hasTrailingComma); + write(" }"); + } + function emitArrayBindingPattern(node) { + write("["); + var elements = node.elements; + emitList(elements, 0, elements.length, /*multiLine*/ false, /*trailingComma*/ elements.hasTrailingComma); + write("]"); + } + function emitBindingElement(node) { + if (node.propertyName) { + emit(node.propertyName); + write(": "); + } + if (node.dotDotDotToken) { + write("..."); + } + if (ts.isBindingPattern(node.name)) { + emit(node.name); + } + else { + emitModuleMemberName(node); + } + emitOptional(" = ", node.initializer); + } + function emitSpreadElementExpression(node) { + write("..."); + emit(node.expression); + } + function emitYieldExpression(node) { + write(ts.tokenToString(114 /* YieldKeyword */)); + if (node.asteriskToken) { + write("*"); + } + if (node.expression) { + write(" "); + emit(node.expression); + } + } + function emitAwaitExpression(node) { + var needsParenthesis = needsParenthesisForAwaitExpressionAsYield(node); + if (needsParenthesis) { + write("("); + } + write(ts.tokenToString(114 /* YieldKeyword */)); + write(" "); + emit(node.expression); + if (needsParenthesis) { + write(")"); + } + } + function needsParenthesisForAwaitExpressionAsYield(node) { + if (node.parent.kind === 181 /* BinaryExpression */ && !ts.isAssignmentOperator(node.parent.operatorToken.kind)) { + return true; + } + else if (node.parent.kind === 182 /* ConditionalExpression */ && node.parent.condition === node) { + return true; + } + return false; + } + function needsParenthesisForPropertyAccessOrInvocation(node) { + switch (node.kind) { + case 69 /* Identifier */: + case 164 /* ArrayLiteralExpression */: + case 166 /* PropertyAccessExpression */: + case 167 /* ElementAccessExpression */: + case 168 /* CallExpression */: + case 172 /* ParenthesizedExpression */: + // This list is not exhaustive and only includes those cases that are relevant + // to the check in emitArrayLiteral. More cases can be added as needed. + return false; + } + return true; + } + function emitListWithSpread(elements, needsUniqueCopy, multiLine, trailingComma, useConcat) { + var pos = 0; + var group = 0; + var length = elements.length; + while (pos < length) { + // Emit using the pattern .concat(, , ...) + if (group === 1 && useConcat) { + write(".concat("); + } + else if (group > 0) { + write(", "); + } + var e = elements[pos]; + if (e.kind === 185 /* SpreadElementExpression */) { + e = e.expression; + emitParenthesizedIf(e, /*parenthesized*/ group === 0 && needsParenthesisForPropertyAccessOrInvocation(e)); + pos++; + if (pos === length && group === 0 && needsUniqueCopy && e.kind !== 164 /* ArrayLiteralExpression */) { + write(".slice()"); + } + } + else { + var i = pos; + while (i < length && elements[i].kind !== 185 /* SpreadElementExpression */) { + i++; + } + write("["); + if (multiLine) { + increaseIndent(); + } + emitList(elements, pos, i - pos, multiLine, trailingComma && i === length); + if (multiLine) { + decreaseIndent(); + } + write("]"); + pos = i; + } + group++; + } + if (group > 1) { + if (useConcat) { + write(")"); + } + } + } + function isSpreadElementExpression(node) { + return node.kind === 185 /* SpreadElementExpression */; + } + function emitArrayLiteral(node) { + var elements = node.elements; + if (elements.length === 0) { + write("[]"); + } + else if (languageVersion >= 2 /* ES6 */ || !ts.forEach(elements, isSpreadElementExpression)) { + write("["); + emitLinePreservingList(node, node.elements, elements.hasTrailingComma, /*spacesBetweenBraces:*/ false); + write("]"); + } + else { + emitListWithSpread(elements, /*needsUniqueCopy*/ true, /*multiLine*/ (node.flags & 2048 /* MultiLine */) !== 0, + /*trailingComma*/ elements.hasTrailingComma, /*useConcat*/ true); + } + } + function emitObjectLiteralBody(node, numElements) { + if (numElements === 0) { + write("{}"); + return; + } + write("{"); + if (numElements > 0) { + var properties = node.properties; + // If we are not doing a downlevel transformation for object literals, + // then try to preserve the original shape of the object literal. + // Otherwise just try to preserve the formatting. + if (numElements === properties.length) { + emitLinePreservingList(node, properties, /* allowTrailingComma */ languageVersion >= 1 /* ES5 */, /* spacesBetweenBraces */ true); + } + else { + var multiLine = (node.flags & 2048 /* MultiLine */) !== 0; + if (!multiLine) { + write(" "); + } + else { + increaseIndent(); + } + emitList(properties, 0, numElements, /*multiLine*/ multiLine, /*trailingComma*/ false); + if (!multiLine) { + write(" "); + } + else { + decreaseIndent(); + } + } + } + write("}"); + } + function emitDownlevelObjectLiteralWithComputedProperties(node, firstComputedPropertyIndex) { + var multiLine = (node.flags & 2048 /* MultiLine */) !== 0; + var properties = node.properties; + write("("); + if (multiLine) { + increaseIndent(); + } + // 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 tempVar = createAndRecordTempVariable(0 /* Auto */); + // Write out the first non-computed properties + // (or all properties if none of them are computed), + // then emit the rest through indexing on the temp variable. + emit(tempVar); + write(" = "); + emitObjectLiteralBody(node, firstComputedPropertyIndex); + for (var i = firstComputedPropertyIndex, n = properties.length; i < n; i++) { + writeComma(); + var property = properties[i]; + emitStart(property); + if (property.kind === 145 /* GetAccessor */ || property.kind === 146 /* SetAccessor */) { + // TODO (drosen): Reconcile with 'emitMemberFunctions'. + var accessors = ts.getAllAccessorDeclarations(node.properties, property); + if (property !== accessors.firstAccessor) { + continue; + } + write("Object.defineProperty("); + emit(tempVar); + write(", "); + emitStart(node.name); + emitExpressionForPropertyName(property.name); + emitEnd(property.name); + write(", {"); + increaseIndent(); + if (accessors.getAccessor) { + writeLine(); + emitLeadingComments(accessors.getAccessor); + write("get: "); + emitStart(accessors.getAccessor); + write("function "); + emitSignatureAndBody(accessors.getAccessor); + emitEnd(accessors.getAccessor); + emitTrailingComments(accessors.getAccessor); + write(","); + } + if (accessors.setAccessor) { + writeLine(); + emitLeadingComments(accessors.setAccessor); + write("set: "); + emitStart(accessors.setAccessor); + write("function "); + emitSignatureAndBody(accessors.setAccessor); + emitEnd(accessors.setAccessor); + emitTrailingComments(accessors.setAccessor); + write(","); + } + writeLine(); + write("enumerable: true,"); + writeLine(); + write("configurable: true"); + decreaseIndent(); + writeLine(); + write("})"); + emitEnd(property); + } + else { + emitLeadingComments(property); + emitStart(property.name); + emit(tempVar); + emitMemberAccessForPropertyName(property.name); + emitEnd(property.name); + write(" = "); + if (property.kind === 245 /* PropertyAssignment */) { + emit(property.initializer); + } + else if (property.kind === 246 /* ShorthandPropertyAssignment */) { + emitExpressionIdentifier(property.name); + } + else if (property.kind === 143 /* MethodDeclaration */) { + emitFunctionDeclaration(property); + } + else { + ts.Debug.fail("ObjectLiteralElement type not accounted for: " + property.kind); + } + } + emitEnd(property); + } + writeComma(); + emit(tempVar); + if (multiLine) { + decreaseIndent(); + writeLine(); + } + write(")"); + function writeComma() { + if (multiLine) { + write(","); + writeLine(); + } + else { + write(", "); + } + } + } + function emitObjectLiteral(node) { + var properties = node.properties; + if (languageVersion < 2 /* ES6 */) { + var numProperties = properties.length; + // Find the first computed property. + // Everything until that point can be emitted as part of the initial object literal. + var numInitialNonComputedProperties = numProperties; + for (var i = 0, n = properties.length; i < n; i++) { + if (properties[i].name.kind === 136 /* ComputedPropertyName */) { + numInitialNonComputedProperties = i; + break; + } + } + var hasComputedProperty = numInitialNonComputedProperties !== properties.length; + if (hasComputedProperty) { + emitDownlevelObjectLiteralWithComputedProperties(node, numInitialNonComputedProperties); + return; + } + } + // Ordinary case: either the object has no computed properties + // or we're compiling with an ES6+ target. + emitObjectLiteralBody(node, properties.length); + } + function createBinaryExpression(left, operator, right, startsOnNewLine) { + var result = ts.createSynthesizedNode(181 /* BinaryExpression */, startsOnNewLine); + result.operatorToken = ts.createSynthesizedNode(operator); + result.left = left; + result.right = right; + return result; + } + function createPropertyAccessExpression(expression, name) { + var result = ts.createSynthesizedNode(166 /* PropertyAccessExpression */); + result.expression = parenthesizeForAccess(expression); + result.dotToken = ts.createSynthesizedNode(21 /* DotToken */); + result.name = name; + return result; + } + function createElementAccessExpression(expression, argumentExpression) { + var result = ts.createSynthesizedNode(167 /* ElementAccessExpression */); + result.expression = parenthesizeForAccess(expression); + result.argumentExpression = argumentExpression; + return result; + } + function parenthesizeForAccess(expr) { + // When diagnosing whether the expression needs parentheses, the decision should be based + // on the innermost expression in a chain of nested type assertions. + while (expr.kind === 171 /* TypeAssertionExpression */ || expr.kind === 189 /* AsExpression */) { + expr = expr.expression; + } + // isLeftHandSideExpression is almost the correct criterion for when it is not necessary + // to parenthesize the expression before a dot. The known exceptions are: + // + // NewExpression: + // new C.x -> not the same as (new C).x + // NumberLiteral + // 1.x -> not the same as (1).x + // + if (ts.isLeftHandSideExpression(expr) && + expr.kind !== 169 /* NewExpression */ && + expr.kind !== 8 /* NumericLiteral */) { + return expr; + } + var node = ts.createSynthesizedNode(172 /* ParenthesizedExpression */); + node.expression = expr; + return node; + } + function emitComputedPropertyName(node) { + write("["); + emitExpressionForPropertyName(node); + write("]"); + } + function emitMethod(node) { + if (languageVersion >= 2 /* ES6 */ && node.asteriskToken) { + write("*"); + } + emit(node.name); + if (languageVersion < 2 /* ES6 */) { + write(": function "); + } + emitSignatureAndBody(node); + } + function emitPropertyAssignment(node) { + emit(node.name); + write(": "); + // This is to ensure that we emit comment in the following case: + // For example: + // obj = { + // id: /*comment1*/ ()=>void + // } + // "comment1" is not considered to be leading comment for node.initializer + // but rather a trailing comment on the previous node. + emitTrailingCommentsOfPosition(node.initializer.pos); + emit(node.initializer); + } + // Return true if identifier resolves to an exported member of a namespace + function isNamespaceExportReference(node) { + var container = resolver.getReferencedExportContainer(node); + return container && container.kind !== 248 /* SourceFile */; + } + function emitShorthandPropertyAssignment(node) { + // The name property of a short-hand property assignment is considered an expression position, so here + // we manually emit the identifier to avoid rewriting. + writeTextOfNode(currentSourceFile, node.name); + // If emitting pre-ES6 code, or if the name requires rewriting when resolved as an expression identifier, + // we emit a normal property assignment. For example: + // module m { + // export let y; + // } + // module m { + // let obj = { y }; + // } + // Here we need to emit obj = { y : m.y } regardless of the output target. + if (languageVersion < 2 /* ES6 */ || isNamespaceExportReference(node.name)) { + // Emit identifier as an identifier + write(": "); + emit(node.name); + } + if (languageVersion >= 2 /* ES6 */ && node.objectAssignmentInitializer) { + write(" = "); + emit(node.objectAssignmentInitializer); + } + } + function tryEmitConstantValue(node) { + var constantValue = tryGetConstEnumValue(node); + if (constantValue !== undefined) { + write(constantValue.toString()); + if (!compilerOptions.removeComments) { + var propertyName = node.kind === 166 /* PropertyAccessExpression */ ? ts.declarationNameToString(node.name) : ts.getTextOfNode(node.argumentExpression); + write(" /* " + propertyName + " */"); + } + return true; + } + return false; + } + function tryGetConstEnumValue(node) { + if (compilerOptions.isolatedModules) { + return undefined; + } + return node.kind === 166 /* PropertyAccessExpression */ || node.kind === 167 /* ElementAccessExpression */ + ? resolver.getConstantValue(node) + : undefined; + } + // Returns 'true' if the code was actually indented, false otherwise. + // If the code is not indented, an optional valueToWriteWhenNotIndenting will be + // emitted instead. + function indentIfOnDifferentLines(parent, node1, node2, valueToWriteWhenNotIndenting) { + var realNodesAreOnDifferentLines = !ts.nodeIsSynthesized(parent) && !nodeEndIsOnSameLineAsNodeStart(node1, node2); + // Always use a newline for synthesized code if the synthesizer desires it. + var synthesizedNodeIsOnDifferentLine = synthesizedNodeStartsOnNewLine(node2); + if (realNodesAreOnDifferentLines || synthesizedNodeIsOnDifferentLine) { + increaseIndent(); + writeLine(); + return true; + } + else { + if (valueToWriteWhenNotIndenting) { + write(valueToWriteWhenNotIndenting); + } + return false; + } + } + function emitPropertyAccess(node) { + if (tryEmitConstantValue(node)) { + return; + } + emit(node.expression); + var indentedBeforeDot = indentIfOnDifferentLines(node, node.expression, node.dotToken); + // 1 .toString is a valid property access, emit a space after the literal + // Also emit a space if expression is a integer const enum value - it will appear in generated code as numeric literal + var shouldEmitSpace; + if (!indentedBeforeDot) { + if (node.expression.kind === 8 /* NumericLiteral */) { + // check if numeric literal was originally written with a dot + var text = ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, node.expression); + shouldEmitSpace = text.indexOf(ts.tokenToString(21 /* DotToken */)) < 0; + } + else { + // check if constant enum value is integer + var constantValue = tryGetConstEnumValue(node.expression); + // isFinite handles cases when constantValue is undefined + shouldEmitSpace = isFinite(constantValue) && Math.floor(constantValue) === constantValue; + } + } + if (shouldEmitSpace) { + write(" ."); + } + else { + write("."); + } + var indentedAfterDot = indentIfOnDifferentLines(node, node.dotToken, node.name); + emit(node.name); + decreaseIndentIf(indentedBeforeDot, indentedAfterDot); + } + function emitQualifiedName(node) { + emit(node.left); + write("."); + emit(node.right); + } + function emitQualifiedNameAsExpression(node, useFallback) { + if (node.left.kind === 69 /* Identifier */) { + emitEntityNameAsExpression(node.left, useFallback); + } + else if (useFallback) { + var temp = createAndRecordTempVariable(0 /* Auto */); + write("("); + emitNodeWithoutSourceMap(temp); + write(" = "); + emitEntityNameAsExpression(node.left, /*useFallback*/ true); + write(") && "); + emitNodeWithoutSourceMap(temp); + } + else { + emitEntityNameAsExpression(node.left, /*useFallback*/ false); + } + write("."); + emit(node.right); + } + function emitEntityNameAsExpression(node, useFallback) { + switch (node.kind) { + case 69 /* Identifier */: + if (useFallback) { + write("typeof "); + emitExpressionIdentifier(node); + write(" !== 'undefined' && "); + } + emitExpressionIdentifier(node); + break; + case 135 /* QualifiedName */: + emitQualifiedNameAsExpression(node, useFallback); + break; + } + } + function emitIndexedAccess(node) { + if (tryEmitConstantValue(node)) { + return; + } + emit(node.expression); + write("["); + emit(node.argumentExpression); + write("]"); + } + function hasSpreadElement(elements) { + return ts.forEach(elements, function (e) { return e.kind === 185 /* SpreadElementExpression */; }); + } + function skipParentheses(node) { + while (node.kind === 172 /* ParenthesizedExpression */ || node.kind === 171 /* TypeAssertionExpression */ || node.kind === 189 /* AsExpression */) { + node = node.expression; + } + return node; + } + function emitCallTarget(node) { + if (node.kind === 69 /* Identifier */ || node.kind === 97 /* ThisKeyword */ || node.kind === 95 /* SuperKeyword */) { + emit(node); + return node; + } + var temp = createAndRecordTempVariable(0 /* Auto */); + write("("); + emit(temp); + write(" = "); + emit(node); + write(")"); + return temp; + } + function emitCallWithSpread(node) { + var target; + var expr = skipParentheses(node.expression); + if (expr.kind === 166 /* PropertyAccessExpression */) { + // Target will be emitted as "this" argument + target = emitCallTarget(expr.expression); + write("."); + emit(expr.name); + } + else if (expr.kind === 167 /* ElementAccessExpression */) { + // Target will be emitted as "this" argument + target = emitCallTarget(expr.expression); + write("["); + emit(expr.argumentExpression); + write("]"); + } + else if (expr.kind === 95 /* SuperKeyword */) { + target = expr; + write("_super"); + } + else { + emit(node.expression); + } + write(".apply("); + if (target) { + if (target.kind === 95 /* SuperKeyword */) { + // Calls of form super(...) and super.foo(...) + emitThis(target); + } + else { + // Calls of form obj.foo(...) + emit(target); + } + } + else { + // Calls of form foo(...) + write("void 0"); + } + write(", "); + emitListWithSpread(node.arguments, /*needsUniqueCopy*/ false, /*multiLine*/ false, /*trailingComma*/ false, /*useConcat*/ true); + write(")"); + } + function emitCallExpression(node) { + if (languageVersion < 2 /* ES6 */ && hasSpreadElement(node.arguments)) { + emitCallWithSpread(node); + return; + } + var superCall = false; + if (node.expression.kind === 95 /* SuperKeyword */) { + emitSuper(node.expression); + superCall = true; + } + else { + emit(node.expression); + superCall = node.expression.kind === 166 /* PropertyAccessExpression */ && node.expression.expression.kind === 95 /* SuperKeyword */; + } + if (superCall && languageVersion < 2 /* ES6 */) { + write(".call("); + emitThis(node.expression); + if (node.arguments.length) { + write(", "); + emitCommaList(node.arguments); + } + write(")"); + } + else { + write("("); + emitCommaList(node.arguments); + write(")"); + } + } + function emitNewExpression(node) { + write("new "); + // Spread operator logic is supported in new expressions in ES5 using a combination + // of Function.prototype.bind() and Function.prototype.apply(). + // + // Example: + // + // var args = [1, 2, 3, 4, 5]; + // new Array(...args); + // + // is compiled into the following ES5: + // + // var args = [1, 2, 3, 4, 5]; + // new (Array.bind.apply(Array, [void 0].concat(args))); + // + // The 'thisArg' to 'bind' is ignored when invoking the result of 'bind' with 'new', + // Thus, we set it to undefined ('void 0'). + if (languageVersion === 1 /* ES5 */ && + node.arguments && + hasSpreadElement(node.arguments)) { + write("("); + var target = emitCallTarget(node.expression); + write(".bind.apply("); + emit(target); + write(", [void 0].concat("); + emitListWithSpread(node.arguments, /*needsUniqueCopy*/ false, /*multiline*/ false, /*trailingComma*/ false, /*useConcat*/ false); + write(")))"); + write("()"); + } + else { + emit(node.expression); + if (node.arguments) { + write("("); + emitCommaList(node.arguments); + write(")"); + } + } + } + function emitTaggedTemplateExpression(node) { + if (languageVersion >= 2 /* ES6 */) { + emit(node.tag); + write(" "); + emit(node.template); + } + else { + emitDownlevelTaggedTemplate(node); + } + } + function emitParenExpression(node) { + // If the node is synthesized, it means the emitter put the parentheses there, + // not the user. If we didn't want them, the emitter would not have put them + // there. + if (!ts.nodeIsSynthesized(node) && node.parent.kind !== 174 /* ArrowFunction */) { + if (node.expression.kind === 171 /* TypeAssertionExpression */ || node.expression.kind === 189 /* AsExpression */) { + var operand = node.expression.expression; + // Make sure we consider all nested cast expressions, e.g.: + // (-A).x; + while (operand.kind === 171 /* TypeAssertionExpression */ || operand.kind === 189 /* AsExpression */) { + operand = operand.expression; + } + // We have an expression of the form: (SubExpr) + // Emitting this as (SubExpr) is really not desirable. We would like to emit the subexpr as is. + // Omitting the parentheses, however, could cause change in the semantics of the generated + // code if the casted expression has a lower precedence than the rest of the expression, e.g.: + // (new A).foo should be emitted as (new A).foo and not new A.foo + // (typeof A).toString() should be emitted as (typeof A).toString() and not typeof A.toString() + // new (A()) should be emitted as new (A()) and not new A() + // (function foo() { })() should be emitted as an IIF (function foo(){})() and not declaration function foo(){} () + if (operand.kind !== 179 /* PrefixUnaryExpression */ && + operand.kind !== 177 /* VoidExpression */ && + operand.kind !== 176 /* TypeOfExpression */ && + operand.kind !== 175 /* DeleteExpression */ && + operand.kind !== 180 /* PostfixUnaryExpression */ && + operand.kind !== 169 /* NewExpression */ && + !(operand.kind === 168 /* CallExpression */ && node.parent.kind === 169 /* NewExpression */) && + !(operand.kind === 173 /* FunctionExpression */ && node.parent.kind === 168 /* CallExpression */) && + !(operand.kind === 8 /* NumericLiteral */ && node.parent.kind === 166 /* PropertyAccessExpression */)) { + emit(operand); + return; + } + } + } + write("("); + emit(node.expression); + write(")"); + } + function emitDeleteExpression(node) { + write(ts.tokenToString(78 /* DeleteKeyword */)); + write(" "); + emit(node.expression); + } + function emitVoidExpression(node) { + write(ts.tokenToString(103 /* VoidKeyword */)); + write(" "); + emit(node.expression); + } + function emitTypeOfExpression(node) { + write(ts.tokenToString(101 /* TypeOfKeyword */)); + write(" "); + emit(node.expression); + } + function isNameOfExportedSourceLevelDeclarationInSystemExternalModule(node) { + if (!isCurrentFileSystemExternalModule() || node.kind !== 69 /* Identifier */ || ts.nodeIsSynthesized(node)) { + return false; + } + var isVariableDeclarationOrBindingElement = node.parent && (node.parent.kind === 211 /* VariableDeclaration */ || node.parent.kind === 163 /* BindingElement */); + var targetDeclaration = isVariableDeclarationOrBindingElement + ? node.parent + : resolver.getReferencedValueDeclaration(node); + return isSourceFileLevelDeclarationInSystemJsModule(targetDeclaration, /*isExported*/ true); + } + function emitPrefixUnaryExpression(node) { + var exportChanged = isNameOfExportedSourceLevelDeclarationInSystemExternalModule(node.operand); + if (exportChanged) { + // emit + // ++x + // as + // exports('x', ++x) + write(exportFunctionForFile + "(\""); + emitNodeWithoutSourceMap(node.operand); + write("\", "); + } + write(ts.tokenToString(node.operator)); + // In some cases, we need to emit a space between the operator and the operand. One obvious case + // is when the operator is an identifier, like delete or typeof. We also need to do this for plus + // and minus expressions in certain cases. Specifically, consider the following two cases (parens + // are just for clarity of exposition, and not part of the source code): + // + // (+(+1)) + // (+(++1)) + // + // We need to emit a space in both cases. In the first case, the absence of a space will make + // the resulting expression a prefix increment operation. And in the second, it will make the resulting + // expression a prefix increment whose operand is a plus expression - (++(+x)) + // The same is true of minus of course. + if (node.operand.kind === 179 /* PrefixUnaryExpression */) { + var operand = node.operand; + if (node.operator === 35 /* PlusToken */ && (operand.operator === 35 /* PlusToken */ || operand.operator === 41 /* PlusPlusToken */)) { + write(" "); + } + else if (node.operator === 36 /* MinusToken */ && (operand.operator === 36 /* MinusToken */ || operand.operator === 42 /* MinusMinusToken */)) { + write(" "); + } + } + emit(node.operand); + if (exportChanged) { + write(")"); + } + } + function emitPostfixUnaryExpression(node) { + var exportChanged = isNameOfExportedSourceLevelDeclarationInSystemExternalModule(node.operand); + if (exportChanged) { + // 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)' + write("(" + exportFunctionForFile + "(\""); + emitNodeWithoutSourceMap(node.operand); + write("\", "); + write(ts.tokenToString(node.operator)); + emit(node.operand); + if (node.operator === 41 /* PlusPlusToken */) { + write(") - 1)"); + } + else { + write(") + 1)"); + } + } + else { + emit(node.operand); + write(ts.tokenToString(node.operator)); + } + } + function shouldHoistDeclarationInSystemJsModule(node) { + return isSourceFileLevelDeclarationInSystemJsModule(node, /*isExported*/ false); + } + /* + * Checks if given node is a source file level declaration (not nested in module/function). + * If 'isExported' is true - then declaration must also be exported. + * This function is used in two cases: + * - check if node is a exported source file level value to determine + * if we should also export the value after its it changed + * - check if node is a source level declaration to emit it differently, + * i.e non-exported variable statement 'var x = 1' is hoisted so + * we we emit variable statement 'var' should be dropped. + */ + function isSourceFileLevelDeclarationInSystemJsModule(node, isExported) { + if (!node || !isCurrentFileSystemExternalModule()) { + return false; + } + var current = node; + while (current) { + if (current.kind === 248 /* SourceFile */) { + return !isExported || ((ts.getCombinedNodeFlags(node) & 1 /* Export */) !== 0); + } + else if (ts.isFunctionLike(current) || current.kind === 219 /* ModuleBlock */) { + return false; + } + else { + current = current.parent; + } + } + } + /** + * Emit ES7 exponentiation operator downlevel using Math.pow + * @param node a binary expression node containing exponentiationOperator (**, **=) + */ + function emitExponentiationOperator(node) { + var leftHandSideExpression = node.left; + if (node.operatorToken.kind === 60 /* AsteriskAsteriskEqualsToken */) { + var synthesizedLHS; + var shouldEmitParentheses = false; + if (ts.isElementAccessExpression(leftHandSideExpression)) { + shouldEmitParentheses = true; + write("("); + synthesizedLHS = ts.createSynthesizedNode(167 /* ElementAccessExpression */, /*startsOnNewLine*/ false); + var identifier = emitTempVariableAssignment(leftHandSideExpression.expression, /*canDefinedTempVariablesInPlaces*/ false, /*shouldEmitCommaBeforeAssignment*/ false); + synthesizedLHS.expression = identifier; + if (leftHandSideExpression.argumentExpression.kind !== 8 /* NumericLiteral */ && + leftHandSideExpression.argumentExpression.kind !== 9 /* StringLiteral */) { + var tempArgumentExpression = createAndRecordTempVariable(268435456 /* _i */); + synthesizedLHS.argumentExpression = tempArgumentExpression; + emitAssignment(tempArgumentExpression, leftHandSideExpression.argumentExpression, /*shouldEmitCommaBeforeAssignment*/ true); + } + else { + synthesizedLHS.argumentExpression = leftHandSideExpression.argumentExpression; + } + write(", "); + } + else if (ts.isPropertyAccessExpression(leftHandSideExpression)) { + shouldEmitParentheses = true; + write("("); + synthesizedLHS = ts.createSynthesizedNode(166 /* PropertyAccessExpression */, /*startsOnNewLine*/ false); + var identifier = emitTempVariableAssignment(leftHandSideExpression.expression, /*canDefinedTempVariablesInPlaces*/ false, /*shouldemitCommaBeforeAssignment*/ false); + synthesizedLHS.expression = identifier; + synthesizedLHS.dotToken = leftHandSideExpression.dotToken; + synthesizedLHS.name = leftHandSideExpression.name; + write(", "); + } + emit(synthesizedLHS || leftHandSideExpression); + write(" = "); + write("Math.pow("); + emit(synthesizedLHS || leftHandSideExpression); + write(", "); + emit(node.right); + write(")"); + if (shouldEmitParentheses) { + write(")"); + } + } + else { + write("Math.pow("); + emit(leftHandSideExpression); + write(", "); + emit(node.right); + write(")"); + } + } + function emitBinaryExpression(node) { + if (languageVersion < 2 /* ES6 */ && node.operatorToken.kind === 56 /* EqualsToken */ && + (node.left.kind === 165 /* ObjectLiteralExpression */ || node.left.kind === 164 /* ArrayLiteralExpression */)) { + emitDestructuring(node, node.parent.kind === 195 /* ExpressionStatement */); + } + else { + var exportChanged = node.operatorToken.kind >= 56 /* FirstAssignment */ && + node.operatorToken.kind <= 68 /* LastAssignment */ && + isNameOfExportedSourceLevelDeclarationInSystemExternalModule(node.left); + if (exportChanged) { + // emit assignment 'x y' as 'exports("x", x y)' + write(exportFunctionForFile + "(\""); + emitNodeWithoutSourceMap(node.left); + write("\", "); + } + if (node.operatorToken.kind === 38 /* AsteriskAsteriskToken */ || node.operatorToken.kind === 60 /* AsteriskAsteriskEqualsToken */) { + // Downleveled emit exponentiation operator using Math.pow + emitExponentiationOperator(node); + } + else { + emit(node.left); + // Add indentation before emit the operator if the operator is on different line + // For example: + // 3 + // + 2; + // emitted as + // 3 + // + 2; + var indentedBeforeOperator = indentIfOnDifferentLines(node, node.left, node.operatorToken, node.operatorToken.kind !== 24 /* CommaToken */ ? " " : undefined); + write(ts.tokenToString(node.operatorToken.kind)); + var indentedAfterOperator = indentIfOnDifferentLines(node, node.operatorToken, node.right, " "); + emit(node.right); + decreaseIndentIf(indentedBeforeOperator, indentedAfterOperator); + } + if (exportChanged) { + write(")"); + } + } + } + function synthesizedNodeStartsOnNewLine(node) { + return ts.nodeIsSynthesized(node) && node.startsOnNewLine; + } + function emitConditionalExpression(node) { + emit(node.condition); + var indentedBeforeQuestion = indentIfOnDifferentLines(node, node.condition, node.questionToken, " "); + write("?"); + var indentedAfterQuestion = indentIfOnDifferentLines(node, node.questionToken, node.whenTrue, " "); + emit(node.whenTrue); + decreaseIndentIf(indentedBeforeQuestion, indentedAfterQuestion); + var indentedBeforeColon = indentIfOnDifferentLines(node, node.whenTrue, node.colonToken, " "); + write(":"); + var indentedAfterColon = indentIfOnDifferentLines(node, node.colonToken, node.whenFalse, " "); + emit(node.whenFalse); + decreaseIndentIf(indentedBeforeColon, indentedAfterColon); + } + // Helper function to decrease the indent if we previously indented. Allows multiple + // previous indent values to be considered at a time. This also allows caller to just + // call this once, passing in all their appropriate indent values, instead of needing + // to call this helper function multiple times. + function decreaseIndentIf(value1, value2) { + if (value1) { + decreaseIndent(); + } + if (value2) { + decreaseIndent(); + } + } + function isSingleLineEmptyBlock(node) { + if (node && node.kind === 192 /* Block */) { + var block = node; + return block.statements.length === 0 && nodeEndIsOnSameLineAsNodeStart(block, block); + } + } + function emitBlock(node) { + if (isSingleLineEmptyBlock(node)) { + emitToken(15 /* OpenBraceToken */, node.pos); + write(" "); + emitToken(16 /* CloseBraceToken */, node.statements.end); + return; + } + emitToken(15 /* OpenBraceToken */, node.pos); + increaseIndent(); + scopeEmitStart(node.parent); + if (node.kind === 219 /* ModuleBlock */) { + ts.Debug.assert(node.parent.kind === 218 /* ModuleDeclaration */); + emitCaptureThisForNodeIfNecessary(node.parent); + } + emitLines(node.statements); + if (node.kind === 219 /* ModuleBlock */) { + emitTempDeclarations(/*newLine*/ true); + } + decreaseIndent(); + writeLine(); + emitToken(16 /* CloseBraceToken */, node.statements.end); + scopeEmitEnd(); + } + function emitEmbeddedStatement(node) { + if (node.kind === 192 /* Block */) { + write(" "); + emit(node); + } + else { + increaseIndent(); + writeLine(); + emit(node); + decreaseIndent(); + } + } + function emitExpressionStatement(node) { + emitParenthesizedIf(node.expression, /*parenthesized*/ node.expression.kind === 174 /* ArrowFunction */); + write(";"); + } + function emitIfStatement(node) { + var endPos = emitToken(88 /* IfKeyword */, node.pos); + write(" "); + endPos = emitToken(17 /* OpenParenToken */, endPos); + emit(node.expression); + emitToken(18 /* CloseParenToken */, node.expression.end); + emitEmbeddedStatement(node.thenStatement); + if (node.elseStatement) { + writeLine(); + emitToken(80 /* ElseKeyword */, node.thenStatement.end); + if (node.elseStatement.kind === 196 /* IfStatement */) { + write(" "); + emit(node.elseStatement); + } + else { + emitEmbeddedStatement(node.elseStatement); + } + } + } + function emitDoStatement(node) { + emitLoop(node, emitDoStatementWorker); + } + function emitDoStatementWorker(node, loop) { + write("do"); + if (loop) { + emitConvertedLoopCall(loop, /* emitAsBlock */ true); + } + else { + emitNormalLoopBody(node, /* emitAsEmbeddedStatement */ true); + } + if (node.statement.kind === 192 /* Block */) { + write(" "); + } + else { + writeLine(); + } + write("while ("); + emit(node.expression); + write(");"); + } + function emitWhileStatement(node) { + emitLoop(node, emitWhileStatementWorker); + } + function emitWhileStatementWorker(node, loop) { + write("while ("); + emit(node.expression); + write(")"); + if (loop) { + emitConvertedLoopCall(loop, /* emitAsBlock */ true); + } + else { + emitNormalLoopBody(node, /* emitAsEmbeddedStatement */ true); + } + } + /** + * Returns true if start of variable declaration list was emitted. + * Returns false if nothing was written - this can happen for source file level variable declarations + * in system modules where such variable declarations are hoisted. + */ + function tryEmitStartOfVariableDeclarationList(decl, startPos) { + if (shouldHoistVariable(decl, /*checkIfSourceFileLevelDecl*/ true)) { + // variables in variable declaration list were already hoisted + return false; + } + if (convertedLoopState && (ts.getCombinedNodeFlags(decl) & 49152 /* BlockScoped */) === 0) { + // we are inside a converted loop - this can only happen in downlevel scenarios + // record names for all variable declarations + for (var _a = 0, _b = decl.declarations; _a < _b.length; _a++) { + var varDecl = _b[_a]; + hoistVariableDeclarationFromLoop(convertedLoopState, varDecl); + } + return false; + } + var tokenKind = 102 /* VarKeyword */; + if (decl && languageVersion >= 2 /* ES6 */) { + if (ts.isLet(decl)) { + tokenKind = 108 /* LetKeyword */; + } + else if (ts.isConst(decl)) { + tokenKind = 74 /* ConstKeyword */; + } + } + if (startPos !== undefined) { + emitToken(tokenKind, startPos); + write(" "); + } + else { + switch (tokenKind) { + case 102 /* VarKeyword */: + write("var "); + break; + case 108 /* LetKeyword */: + write("let "); + break; + case 74 /* ConstKeyword */: + write("const "); + break; + } + } + return true; + } + function emitVariableDeclarationListSkippingUninitializedEntries(list) { + var started = false; + for (var _a = 0, _b = list.declarations; _a < _b.length; _a++) { + var decl = _b[_a]; + if (!decl.initializer) { + continue; + } + if (!started) { + started = true; + } + else { + write(", "); + } + emit(decl); + } + return started; + } + function shouldConvertLoopBody(node) { + return languageVersion < 2 /* ES6 */ && + (resolver.getNodeCheckFlags(node) & 65536 /* LoopWithBlockScopedBindingCapturedInFunction */) !== 0; + } + function emitLoop(node, loopEmitter) { + var shouldConvert = shouldConvertLoopBody(node); + if (!shouldConvert) { + loopEmitter(node, /* convertedLoop*/ undefined); + } + else { + var loop = convertLoopBody(node); + if (node.parent.kind === 207 /* LabeledStatement */) { + // if parent of the loop was labeled statement - attach the label to loop skipping converted loop body + emitLabelAndColon(node.parent); + } + loopEmitter(node, loop); + } + } + function convertLoopBody(node) { + var functionName = makeUniqueName("_loop"); + var loopInitializer; + switch (node.kind) { + case 199 /* ForStatement */: + case 200 /* ForInStatement */: + case 201 /* ForOfStatement */: + if (node.initializer.kind === 212 /* VariableDeclarationList */) { + loopInitializer = node.initializer; + } + break; + } + var loopParameters; + if (loopInitializer && (ts.getCombinedNodeFlags(loopInitializer) & 49152 /* BlockScoped */)) { + // if loop initializer contains block scoped variables - they should be passed to converted loop body as parameters + loopParameters = []; + for (var _a = 0, _b = loopInitializer.declarations; _a < _b.length; _a++) { + var varDeclaration = _b[_a]; + collectNames(varDeclaration.name); + } + } + var bodyIsBlock = node.statement.kind === 192 /* Block */; + var paramList = loopParameters ? loopParameters.join(", ") : ""; + writeLine(); + write("var " + functionName + " = function(" + paramList + ")"); + if (!bodyIsBlock) { + write(" {"); + writeLine(); + increaseIndent(); + } + var convertedOuterLoopState = convertedLoopState; + convertedLoopState = {}; + if (convertedOuterLoopState) { + // 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 (convertedOuterLoopState.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 = convertedOuterLoopState.argumentsName; + } + if (convertedOuterLoopState.hoistedLocalVariables) { + // we've already collected some non-block scoped variable declarations in enclosing loop + // use the same storage in nested loop + convertedLoopState.hoistedLocalVariables = convertedOuterLoopState.hoistedLocalVariables; + } + } + emitEmbeddedStatement(node.statement); + if (!bodyIsBlock) { + decreaseIndent(); + writeLine(); + write("}"); + } + write(";"); + writeLine(); + if (convertedLoopState.argumentsName) { + // if alias for arguments is set + if (convertedOuterLoopState) { + // pass it to outer converted loop + convertedOuterLoopState.argumentsName = convertedLoopState.argumentsName; + } + else { + // this is top level converted loop and we need to create an alias for 'arguments' object + write("var " + convertedLoopState.argumentsName + " = arguments;"); + writeLine(); + } + } + if (convertedLoopState.hoistedLocalVariables) { + // if hoistedLocalVariables !== undefined this means that we've possibly collected some variable declarations to be hoisted later + if (convertedOuterLoopState) { + // pass them to outer converted loop + convertedOuterLoopState.hoistedLocalVariables = convertedLoopState.hoistedLocalVariables; + } + else { + // deduplicate and hoist collected variable declarations + write("var "); + var seen; + for (var _c = 0, _d = convertedLoopState.hoistedLocalVariables; _c < _d.length; _c++) { + var id = _d[_c]; + // Don't initialize seen unless we have at least one element. + // Emit a comma to separate for all but the first element. + if (!seen) { + seen = {}; + } + else { + write(", "); + } + if (!ts.hasProperty(seen, id.text)) { + emit(id); + seen[id.text] = id.text; + } + } + write(";"); + writeLine(); + } + } + var currentLoopState = convertedLoopState; + convertedLoopState = convertedOuterLoopState; + return { functionName: functionName, paramList: paramList, state: currentLoopState }; + function collectNames(name) { + if (name.kind === 69 /* Identifier */) { + var nameText = isNameOfNestedRedeclaration(name) ? getGeneratedNameForNode(name) : name.text; + loopParameters.push(nameText); + } + else { + for (var _a = 0, _b = name.elements; _a < _b.length; _a++) { + var element = _b[_a]; + collectNames(element.name); + } + } + } + } + function emitNormalLoopBody(node, emitAsEmbeddedStatement) { + var saveAllowedNonLabeledJumps; + 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 */; + } + if (emitAsEmbeddedStatement) { + emitEmbeddedStatement(node.statement); + } + else if (node.statement.kind === 192 /* Block */) { + emitLines(node.statement.statements); + } + else { + writeLine(); + emit(node.statement); + } + if (convertedLoopState) { + convertedLoopState.allowedNonLabeledJumps = saveAllowedNonLabeledJumps; + } + } + function emitConvertedLoopCall(loop, emitAsBlock) { + if (emitAsBlock) { + write(" {"); + writeLine(); + increaseIndent(); + } + // 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()'; + var isSimpleLoop = !loop.state.nonLocalJumps && + !loop.state.labeledNonLocalBreaks && + !loop.state.labeledNonLocalContinues; + var loopResult = makeUniqueName("state"); + if (!isSimpleLoop) { + write("var " + loopResult + " = "); + } + write(loop.functionName + "(" + loop.paramList + ");"); + if (!isSimpleLoop) { + // for non simple loops we need to store result returned from converted loop function and use it to do dispatching + // converted loop function can return: + // - object - used when body of the converted loop contains return statement. Property "value" of this object stores retuned value + // - string - used to dispatch jumps. "break" and "continue" are used to non-labeled jumps, other values are used to transfer control to + // different labels + writeLine(); + if (loop.state.nonLocalJumps & 8 /* Return */) { + write("if (typeof " + loopResult + " === \"object\") "); + if (convertedLoopState) { + // we are currently nested in another converted loop - return unwrapped result + write("return " + loopResult + ";"); + // propagate 'hasReturn' flag to outer loop + convertedLoopState.nonLocalJumps |= 8 /* Return */; + } + else { + // top level converted loop - return unwrapped value + write("return " + loopResult + ".value"); + } + writeLine(); + } + if (loop.state.nonLocalJumps & 2 /* Break */) { + write("if (" + loopResult + " === \"break\") break;"); + writeLine(); + } + if (loop.state.nonLocalJumps & 4 /* Continue */) { + write("if (" + loopResult + " === \"continue\") continue;"); + writeLine(); + } + // in case of labeled breaks emit code that either breaks to some known label inside outer loop or delegates jump decision to outer loop + emitDispatchTableForLabeledJumps(loopResult, loop.state, convertedLoopState); + } + if (emitAsBlock) { + writeLine(); + decreaseIndent(); + write("}"); + } + function emitDispatchTableForLabeledJumps(loopResultVariable, currentLoop, outerLoop) { + if (!currentLoop.labeledNonLocalBreaks && !currentLoop.labeledNonLocalContinues) { + return; + } + write("switch(" + loopResultVariable + ") {"); + increaseIndent(); + emitDispatchEntriesForLabeledJumps(currentLoop.labeledNonLocalBreaks, /* isBreak */ true, loopResultVariable, outerLoop); + emitDispatchEntriesForLabeledJumps(currentLoop.labeledNonLocalContinues, /* isBreak */ false, loopResultVariable, outerLoop); + decreaseIndent(); + writeLine(); + write("}"); + } + function emitDispatchEntriesForLabeledJumps(table, isBreak, loopResultVariable, outerLoop) { + if (!table) { + return; + } + for (var labelText in table) { + var labelMarker = table[labelText]; + writeLine(); + write("case \"" + labelMarker + "\": "); + // 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])) { + if (isBreak) { + write("break "); + } + else { + write("continue "); + } + write(labelText + ";"); + } + else { + setLabeledJump(outerLoop, isBreak, labelText, labelMarker); + write("return " + loopResultVariable + ";"); + } + } + } + } + function emitForStatement(node) { + emitLoop(node, emitForStatementWorker); + } + function emitForStatementWorker(node, loop) { + var endPos = emitToken(86 /* ForKeyword */, node.pos); + write(" "); + endPos = emitToken(17 /* OpenParenToken */, endPos); + if (node.initializer && node.initializer.kind === 212 /* VariableDeclarationList */) { + var variableDeclarationList = node.initializer; + var startIsEmitted = tryEmitStartOfVariableDeclarationList(variableDeclarationList, endPos); + if (startIsEmitted) { + emitCommaList(variableDeclarationList.declarations); + } + else { + emitVariableDeclarationListSkippingUninitializedEntries(variableDeclarationList); + } + } + else if (node.initializer) { + emit(node.initializer); + } + write(";"); + emitOptional(" ", node.condition); + write(";"); + emitOptional(" ", node.incrementor); + write(")"); + if (loop) { + emitConvertedLoopCall(loop, /* emitAsBlock */ true); + } + else { + emitNormalLoopBody(node, /* emitAsEmbeddedStatement */ true); + } + } + function emitForInOrForOfStatement(node) { + if (languageVersion < 2 /* ES6 */ && node.kind === 201 /* ForOfStatement */) { + emitLoop(node, emitDownLevelForOfStatementWorker); + } + else { + emitLoop(node, emitForInOrForOfStatementWorker); + } + } + function emitForInOrForOfStatementWorker(node, loop) { + var endPos = emitToken(86 /* ForKeyword */, node.pos); + write(" "); + endPos = emitToken(17 /* OpenParenToken */, endPos); + if (node.initializer.kind === 212 /* VariableDeclarationList */) { + var variableDeclarationList = node.initializer; + if (variableDeclarationList.declarations.length >= 1) { + tryEmitStartOfVariableDeclarationList(variableDeclarationList, endPos); + emit(variableDeclarationList.declarations[0]); + } + } + else { + emit(node.initializer); + } + if (node.kind === 200 /* ForInStatement */) { + write(" in "); + } + else { + write(" of "); + } + emit(node.expression); + emitToken(18 /* CloseParenToken */, node.expression.end); + if (loop) { + emitConvertedLoopCall(loop, /* emitAsBlock */ true); + } + else { + emitNormalLoopBody(node, /* emitAsEmbeddedStatement */ true); + } + } + function emitDownLevelForOfStatement(node) { + emitLoop(node, emitDownLevelForOfStatementWorker); + } + function emitDownLevelForOfStatementWorker(node, loop) { + // The following ES6 code: + // + // for (let v of expr) { } + // + // should be emitted as + // + // for (let _i = 0, _a = expr; _i < _a.length; _i++) { + // let v = _a[_i]; + // } + // + // where _a and _i are temps emitted to capture the RHS and the counter, + // respectively. + // When the left hand side is an expression instead of a let declaration, + // the "let v" is not emitted. + // When the left hand side is a let/const, the v is renamed if there is + // another v in scope. + // Note that all assignments to the LHS are emitted in the body, including + // all destructuring. + // Note also that because an extra statement is needed to assign to the LHS, + // for-of bodies are always emitted as blocks. + var endPos = emitToken(86 /* ForKeyword */, node.pos); + write(" "); + endPos = emitToken(17 /* OpenParenToken */, endPos); + // Do not emit the LHS let declaration yet, because it might contain destructuring. + // Do not call recordTempDeclaration because we are declaring the temps + // right here. Recording means they will be declared later. + // 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 rhsIsIdentifier = node.expression.kind === 69 /* Identifier */; + var counter = createTempVariable(268435456 /* _i */); + var rhsReference = rhsIsIdentifier ? node.expression : createTempVariable(0 /* Auto */); + // This is the let keyword for the counter and rhsReference. The let keyword for + // the LHS will be emitted inside the body. + emitStart(node.expression); + write("var "); + // _i = 0 + emitNodeWithoutSourceMap(counter); + write(" = 0"); + emitEnd(node.expression); + if (!rhsIsIdentifier) { + // , _a = expr + write(", "); + emitStart(node.expression); + emitNodeWithoutSourceMap(rhsReference); + write(" = "); + emitNodeWithoutSourceMap(node.expression); + emitEnd(node.expression); + } + write("; "); + // _i < _a.length; + emitStart(node.initializer); + emitNodeWithoutSourceMap(counter); + write(" < "); + emitNodeWithCommentsAndWithoutSourcemap(rhsReference); + write(".length"); + emitEnd(node.initializer); + write("; "); + // _i++) + emitStart(node.initializer); + emitNodeWithoutSourceMap(counter); + write("++"); + emitEnd(node.initializer); + emitToken(18 /* CloseParenToken */, node.expression.end); + // Body + write(" {"); + writeLine(); + increaseIndent(); + // Initialize LHS + // let v = _a[_i]; + var rhsIterationValue = createElementAccessExpression(rhsReference, counter); + emitStart(node.initializer); + if (node.initializer.kind === 212 /* VariableDeclarationList */) { + write("var "); + var variableDeclarationList = node.initializer; + if (variableDeclarationList.declarations.length > 0) { + var declaration = variableDeclarationList.declarations[0]; + if (ts.isBindingPattern(declaration.name)) { + // This works whether the declaration is a var, let, or const. + // It will use rhsIterationValue _a[_i] as the initializer. + emitDestructuring(declaration, /*isAssignmentExpressionStatement*/ false, rhsIterationValue); + } + else { + // The following call does not include the initializer, so we have + // to emit it separately. + emitNodeWithCommentsAndWithoutSourcemap(declaration); + write(" = "); + emitNodeWithoutSourceMap(rhsIterationValue); + } + } + else { + // It's an empty declaration list. This can only happen in an error case, if the user wrote + // for (let of []) {} + emitNodeWithoutSourceMap(createTempVariable(0 /* Auto */)); + write(" = "); + emitNodeWithoutSourceMap(rhsIterationValue); + } + } + else { + // Initializer is an expression. Emit the expression in the body, so that it's + // evaluated on every iteration. + var assignmentExpression = createBinaryExpression(node.initializer, 56 /* EqualsToken */, rhsIterationValue, /*startsOnNewLine*/ false); + if (node.initializer.kind === 164 /* ArrayLiteralExpression */ || node.initializer.kind === 165 /* ObjectLiteralExpression */) { + // This is a destructuring pattern, so call emitDestructuring instead of emit. Calling emit will not work, because it will cause + // the BinaryExpression to be passed in instead of the expression statement, which will cause emitDestructuring to crash. + emitDestructuring(assignmentExpression, /*isAssignmentExpressionStatement*/ true, /*value*/ undefined); + } + else { + emitNodeWithCommentsAndWithoutSourcemap(assignmentExpression); + } + } + emitEnd(node.initializer); + write(";"); + if (loop) { + writeLine(); + emitConvertedLoopCall(loop, /* emitAsBlock */ false); + } + else { + emitNormalLoopBody(node, /* emitAsEmbeddedStatement */ false); + } + writeLine(); + decreaseIndent(); + write("}"); + } + function emitBreakOrContinueStatement(node) { + if (convertedLoopState) { + // check if we can emit break\continue as is + // it is possible if either + // - break\continue is statement 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 === 203 /* BreakStatement */ ? 2 /* Break */ : 4 /* Continue */; + var canUseBreakOrContinue = (node.label && convertedLoopState.labels && convertedLoopState.labels[node.label.text]) || + (!node.label && (convertedLoopState.allowedNonLabeledJumps & jump)); + if (!canUseBreakOrContinue) { + if (!node.label) { + if (node.kind === 203 /* BreakStatement */) { + convertedLoopState.nonLocalJumps |= 2 /* Break */; + write("return \"break\";"); + } + else { + convertedLoopState.nonLocalJumps |= 4 /* Continue */; + write("return \"continue\";"); + } + } + else { + var labelMarker; + if (node.kind === 203 /* 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); + } + write("return \"" + labelMarker + "\";"); + } + return; + } + } + emitToken(node.kind === 203 /* BreakStatement */ ? 70 /* BreakKeyword */ : 75 /* ContinueKeyword */, node.pos); + emitOptional(" ", node.label); + write(";"); + } + function emitReturnStatement(node) { + if (convertedLoopState) { + convertedLoopState.nonLocalJumps |= 8 /* Return */; + write("return { value: "); + if (node.expression) { + emit(node.expression); + } + else { + write("void 0"); + } + write(" };"); + return; + } + emitToken(94 /* ReturnKeyword */, node.pos); + emitOptional(" ", node.expression); + write(";"); + } + function emitWithStatement(node) { + write("with ("); + emit(node.expression); + write(")"); + emitEmbeddedStatement(node.statement); + } + function emitSwitchStatement(node) { + var endPos = emitToken(96 /* SwitchKeyword */, node.pos); + write(" "); + emitToken(17 /* OpenParenToken */, endPos); + emit(node.expression); + endPos = emitToken(18 /* CloseParenToken */, node.expression.end); + write(" "); + var saveAllowedNonLabeledJumps; + if (convertedLoopState) { + saveAllowedNonLabeledJumps = convertedLoopState.allowedNonLabeledJumps; + // for switch statement allow only non-labeled break + convertedLoopState.allowedNonLabeledJumps |= 2 /* Break */; + } + emitCaseBlock(node.caseBlock, endPos); + if (convertedLoopState) { + convertedLoopState.allowedNonLabeledJumps = saveAllowedNonLabeledJumps; + } + } + function emitCaseBlock(node, startPos) { + emitToken(15 /* OpenBraceToken */, startPos); + increaseIndent(); + emitLines(node.clauses); + decreaseIndent(); + writeLine(); + emitToken(16 /* CloseBraceToken */, node.clauses.end); + } + function nodeStartPositionsAreOnSameLine(node1, node2) { + return ts.getLineOfLocalPosition(currentSourceFile, ts.skipTrivia(currentSourceFile.text, node1.pos)) === + ts.getLineOfLocalPosition(currentSourceFile, ts.skipTrivia(currentSourceFile.text, node2.pos)); + } + function nodeEndPositionsAreOnSameLine(node1, node2) { + return ts.getLineOfLocalPosition(currentSourceFile, node1.end) === + ts.getLineOfLocalPosition(currentSourceFile, node2.end); + } + function nodeEndIsOnSameLineAsNodeStart(node1, node2) { + return ts.getLineOfLocalPosition(currentSourceFile, node1.end) === + ts.getLineOfLocalPosition(currentSourceFile, ts.skipTrivia(currentSourceFile.text, node2.pos)); + } + function emitCaseOrDefaultClause(node) { + if (node.kind === 241 /* CaseClause */) { + write("case "); + emit(node.expression); + write(":"); + } + else { + write("default:"); + } + if (node.statements.length === 1 && nodeStartPositionsAreOnSameLine(node, node.statements[0])) { + write(" "); + emit(node.statements[0]); + } + else { + increaseIndent(); + emitLines(node.statements); + decreaseIndent(); + } + } + function emitThrowStatement(node) { + write("throw "); + emit(node.expression); + write(";"); + } + function emitTryStatement(node) { + write("try "); + emit(node.tryBlock); + emit(node.catchClause); + if (node.finallyBlock) { + writeLine(); + write("finally "); + emit(node.finallyBlock); + } + } + function emitCatchClause(node) { + writeLine(); + var endPos = emitToken(72 /* CatchKeyword */, node.pos); + write(" "); + emitToken(17 /* OpenParenToken */, endPos); + emit(node.variableDeclaration); + emitToken(18 /* CloseParenToken */, node.variableDeclaration ? node.variableDeclaration.end : endPos); + write(" "); + emitBlock(node.block); + } + function emitDebuggerStatement(node) { + emitToken(76 /* DebuggerKeyword */, node.pos); + write(";"); + } + function emitLabelAndColon(node) { + emit(node.label); + write(": "); + } + function emitLabeledStatement(node) { + if (!ts.isIterationStatement(node.statement, /* lookInLabeledStatements */ false) || !shouldConvertLoopBody(node.statement)) { + emitLabelAndColon(node); + } + if (convertedLoopState) { + if (!convertedLoopState.labels) { + convertedLoopState.labels = {}; + } + convertedLoopState.labels[node.label.text] = node.label.text; + } + emit(node.statement); + if (convertedLoopState) { + convertedLoopState.labels[node.label.text] = undefined; + } + } + function getContainingModule(node) { + do { + node = node.parent; + } while (node && node.kind !== 218 /* ModuleDeclaration */); + return node; + } + function emitContainingModuleName(node) { + var container = getContainingModule(node); + write(container ? getGeneratedNameForNode(container) : "exports"); + } + function emitModuleMemberName(node) { + emitStart(node.name); + if (ts.getCombinedNodeFlags(node) & 1 /* Export */) { + var container = getContainingModule(node); + if (container) { + write(getGeneratedNameForNode(container)); + write("."); + } + else if (modulekind !== 5 /* ES6 */ && modulekind !== 4 /* System */) { + write("exports."); + } + } + emitNodeWithCommentsAndWithoutSourcemap(node.name); + emitEnd(node.name); + } + function createVoidZero() { + var zero = ts.createSynthesizedNode(8 /* NumericLiteral */); + zero.text = "0"; + var result = ts.createSynthesizedNode(177 /* VoidExpression */); + result.expression = zero; + return result; + } + function emitEs6ExportDefaultCompat(node) { + if (node.parent.kind === 248 /* SourceFile */) { + ts.Debug.assert(!!(node.flags & 1024 /* Default */) || node.kind === 227 /* ExportAssignment */); + // only allow export default at a source file level + if (modulekind === 1 /* CommonJS */ || modulekind === 2 /* AMD */ || modulekind === 3 /* UMD */) { + if (!currentSourceFile.symbol.exports["___esModule"]) { + if (languageVersion === 1 /* ES5 */) { + // default value of configurable, enumerable, writable are `false`. + write("Object.defineProperty(exports, \"__esModule\", { value: true });"); + writeLine(); + } + else if (languageVersion === 0 /* ES3 */) { + write("exports.__esModule = true;"); + writeLine(); + } + } + } + } + } + function emitExportMemberAssignment(node) { + if (node.flags & 1 /* Export */) { + writeLine(); + emitStart(node); + // emit call to exporter only for top level nodes + if (modulekind === 4 /* System */ && node.parent === currentSourceFile) { + // emit export default as + // export("default", ) + write(exportFunctionForFile + "(\""); + if (node.flags & 1024 /* Default */) { + write("default"); + } + else { + emitNodeWithCommentsAndWithoutSourcemap(node.name); + } + write("\", "); + emitDeclarationName(node); + write(")"); + } + else { + if (node.flags & 1024 /* Default */) { + emitEs6ExportDefaultCompat(node); + if (languageVersion === 0 /* ES3 */) { + write("exports[\"default\"]"); + } + else { + write("exports.default"); + } + } + else { + emitModuleMemberName(node); + } + write(" = "); + emitDeclarationName(node); + } + emitEnd(node); + write(";"); + } + } + function emitExportMemberAssignments(name) { + if (modulekind === 4 /* System */) { + return; + } + if (!exportEquals && exportSpecifiers && ts.hasProperty(exportSpecifiers, name.text)) { + for (var _a = 0, _b = exportSpecifiers[name.text]; _a < _b.length; _a++) { + var specifier = _b[_a]; + writeLine(); + emitStart(specifier.name); + emitContainingModuleName(specifier); + write("."); + emitNodeWithCommentsAndWithoutSourcemap(specifier.name); + emitEnd(specifier.name); + write(" = "); + emitExpressionIdentifier(name); + write(";"); + } + } + } + function emitExportSpecifierInSystemModule(specifier) { + ts.Debug.assert(modulekind === 4 /* System */); + if (!resolver.getReferencedValueDeclaration(specifier.propertyName || specifier.name) && !resolver.isValueAliasDeclaration(specifier)) { + return; + } + writeLine(); + emitStart(specifier.name); + write(exportFunctionForFile + "(\""); + emitNodeWithCommentsAndWithoutSourcemap(specifier.name); + write("\", "); + emitExpressionIdentifier(specifier.propertyName || specifier.name); + write(")"); + emitEnd(specifier.name); + write(";"); + } + /** + * Emit an assignment to a given identifier, 'name', with a given expression, 'value'. + * @param name an identifier as a left-hand-side operand of the assignment + * @param value an expression as a right-hand-side operand of the assignment + * @param shouldEmitCommaBeforeAssignment a boolean indicating whether to prefix an assignment with comma + */ + function emitAssignment(name, value, shouldEmitCommaBeforeAssignment) { + if (shouldEmitCommaBeforeAssignment) { + write(", "); + } + var exportChanged = isNameOfExportedSourceLevelDeclarationInSystemExternalModule(name); + if (exportChanged) { + write(exportFunctionForFile + "(\""); + emitNodeWithCommentsAndWithoutSourcemap(name); + write("\", "); + } + var isVariableDeclarationOrBindingElement = name.parent && (name.parent.kind === 211 /* VariableDeclaration */ || name.parent.kind === 163 /* BindingElement */); + if (isVariableDeclarationOrBindingElement) { + emitModuleMemberName(name.parent); + } + else { + emit(name); + } + write(" = "); + emit(value); + if (exportChanged) { + write(")"); + } + } + /** + * Create temporary variable, emit an assignment of the variable the given expression + * @param expression an expression to assign to the newly created temporary variable + * @param canDefineTempVariablesInPlace a boolean indicating whether you can define the temporary variable at an assignment location + * @param shouldEmitCommaBeforeAssignment a boolean indicating whether an assignment should prefix with comma + */ + function emitTempVariableAssignment(expression, canDefineTempVariablesInPlace, shouldEmitCommaBeforeAssignment) { + var identifier = createTempVariable(0 /* Auto */); + if (!canDefineTempVariablesInPlace) { + recordTempDeclaration(identifier); + } + emitAssignment(identifier, expression, shouldEmitCommaBeforeAssignment); + return identifier; + } + function emitDestructuring(root, isAssignmentExpressionStatement, value) { + var emitCount = 0; + // An exported declaration is actually emitted as an assignment (to a property on the module object), so + // temporary variables in an exported declaration need to have real declarations elsewhere + // Also temporary variables should be explicitly allocated for source level declarations when module target is system + // because actual variable declarations are hoisted + var canDefineTempVariablesInPlace = false; + if (root.kind === 211 /* VariableDeclaration */) { + var isExported = ts.getCombinedNodeFlags(root) & 1 /* Export */; + var isSourceLevelForSystemModuleKind = shouldHoistDeclarationInSystemJsModule(root); + canDefineTempVariablesInPlace = !isExported && !isSourceLevelForSystemModuleKind; + } + else if (root.kind === 138 /* Parameter */) { + canDefineTempVariablesInPlace = true; + } + if (root.kind === 181 /* BinaryExpression */) { + emitAssignmentExpression(root); + } + else { + ts.Debug.assert(!isAssignmentExpressionStatement); + emitBindingElement(root, value); + } + /** + * Ensures that there exists a declared identifier whose value holds the given expression. + * This function is useful to ensure that the expression's value can be read from in subsequent expressions. + * Unless 'reuseIdentifierExpressions' is false, 'expr' will be returned if it is just an identifier. + * + * @param expr the expression whose value needs to be bound. + * @param reuseIdentifierExpressions true if identifier expressions can simply be returned; + * false if it is necessary to always emit an identifier. + */ + function ensureIdentifier(expr, reuseIdentifierExpressions) { + if (expr.kind === 69 /* Identifier */ && reuseIdentifierExpressions) { + return expr; + } + var identifier = emitTempVariableAssignment(expr, canDefineTempVariablesInPlace, emitCount > 0); + emitCount++; + return identifier; + } + function createDefaultValueCheck(value, defaultValue) { + // The value expression will be evaluated twice, so for anything but a simple identifier + // we need to generate a temporary variable + value = ensureIdentifier(value, /*reuseIdentifierExpressions*/ true); + // Return the expression 'value === void 0 ? defaultValue : value' + var equals = ts.createSynthesizedNode(181 /* BinaryExpression */); + equals.left = value; + equals.operatorToken = ts.createSynthesizedNode(32 /* EqualsEqualsEqualsToken */); + equals.right = createVoidZero(); + return createConditionalExpression(equals, defaultValue, value); + } + function createConditionalExpression(condition, whenTrue, whenFalse) { + var cond = ts.createSynthesizedNode(182 /* ConditionalExpression */); + cond.condition = condition; + cond.questionToken = ts.createSynthesizedNode(53 /* QuestionToken */); + cond.whenTrue = whenTrue; + cond.colonToken = ts.createSynthesizedNode(54 /* ColonToken */); + cond.whenFalse = whenFalse; + return cond; + } + function createNumericLiteral(value) { + var node = ts.createSynthesizedNode(8 /* NumericLiteral */); + node.text = "" + value; + return node; + } + function createPropertyAccessForDestructuringProperty(object, propName) { + // We create a synthetic copy of the identifier in order to avoid the rewriting that might + // otherwise occur when the identifier is emitted. + var syntheticName = ts.createSynthesizedNode(propName.kind); + syntheticName.text = propName.text; + if (syntheticName.kind !== 69 /* Identifier */) { + return createElementAccessExpression(object, syntheticName); + } + return createPropertyAccessExpression(object, syntheticName); + } + function createSliceCall(value, sliceIndex) { + var call = ts.createSynthesizedNode(168 /* CallExpression */); + var sliceIdentifier = ts.createSynthesizedNode(69 /* Identifier */); + sliceIdentifier.text = "slice"; + call.expression = createPropertyAccessExpression(value, sliceIdentifier); + call.arguments = ts.createSynthesizedNodeArray(); + call.arguments[0] = createNumericLiteral(sliceIndex); + return call; + } + function emitObjectLiteralAssignment(target, value) { + var properties = target.properties; + if (properties.length !== 1) { + // For anything but a single element destructuring we need to generate a temporary + // to ensure value is evaluated exactly once. + value = ensureIdentifier(value, /*reuseIdentifierExpressions*/ true); + } + for (var _a = 0; _a < properties.length; _a++) { + var p = properties[_a]; + if (p.kind === 245 /* PropertyAssignment */ || p.kind === 246 /* ShorthandPropertyAssignment */) { + var propName = p.name; + var target_1 = p.kind === 246 /* ShorthandPropertyAssignment */ ? p : p.initializer || propName; + emitDestructuringAssignment(target_1, createPropertyAccessForDestructuringProperty(value, propName)); + } + } + } + function emitArrayLiteralAssignment(target, value) { + var elements = target.elements; + if (elements.length !== 1) { + // For anything but a single element destructuring we need to generate a temporary + // to ensure value is evaluated exactly once. + value = ensureIdentifier(value, /*reuseIdentifierExpressions*/ true); + } + for (var i = 0; i < elements.length; i++) { + var e = elements[i]; + if (e.kind !== 187 /* OmittedExpression */) { + if (e.kind !== 185 /* SpreadElementExpression */) { + emitDestructuringAssignment(e, createElementAccessExpression(value, createNumericLiteral(i))); + } + else if (i === elements.length - 1) { + emitDestructuringAssignment(e.expression, createSliceCall(value, i)); + } + } + } + } + function emitDestructuringAssignment(target, value) { + if (target.kind === 246 /* ShorthandPropertyAssignment */) { + if (target.objectAssignmentInitializer) { + value = createDefaultValueCheck(value, target.objectAssignmentInitializer); + } + target = target.name; + } + else if (target.kind === 181 /* BinaryExpression */ && target.operatorToken.kind === 56 /* EqualsToken */) { + value = createDefaultValueCheck(value, target.right); + target = target.left; + } + if (target.kind === 165 /* ObjectLiteralExpression */) { + emitObjectLiteralAssignment(target, value); + } + else if (target.kind === 164 /* ArrayLiteralExpression */) { + emitArrayLiteralAssignment(target, value); + } + else { + emitAssignment(target, value, /*shouldEmitCommaBeforeAssignment*/ emitCount > 0); + emitCount++; + } + } + function emitAssignmentExpression(root) { + var target = root.left; + var value = root.right; + if (ts.isEmptyObjectLiteralOrArrayLiteral(target)) { + emit(value); + } + else if (isAssignmentExpressionStatement) { + emitDestructuringAssignment(target, value); + } + else { + if (root.parent.kind !== 172 /* ParenthesizedExpression */) { + write("("); + } + value = ensureIdentifier(value, /*reuseIdentifierExpressions*/ true); + emitDestructuringAssignment(target, value); + write(", "); + emit(value); + if (root.parent.kind !== 172 /* ParenthesizedExpression */) { + write(")"); + } + } + } + function emitBindingElement(target, value) { + if (target.initializer) { + // Combine value and initializer + value = value ? createDefaultValueCheck(value, target.initializer) : target.initializer; + } + else if (!value) { + // Use 'void 0' in absence of value and initializer + value = createVoidZero(); + } + if (ts.isBindingPattern(target.name)) { + var pattern = target.name; + var elements = pattern.elements; + var numElements = elements.length; + if (numElements !== 1) { + // For anything other than a single-element destructuring we need to generate a temporary + // to ensure value is evaluated exactly once. Additionally, if we have zero elements + // we need to emit *something* to ensure that in case a 'var' keyword was already emitted, + // so in that case, we'll intentionally create that temporary. + value = ensureIdentifier(value, /*reuseIdentifierExpressions*/ numElements !== 0); + } + for (var i = 0; i < numElements; i++) { + var element = elements[i]; + if (pattern.kind === 161 /* ObjectBindingPattern */) { + // Rewrite element to a declaration with an initializer that fetches property + var propName = element.propertyName || element.name; + emitBindingElement(element, createPropertyAccessForDestructuringProperty(value, propName)); + } + else if (element.kind !== 187 /* OmittedExpression */) { + if (!element.dotDotDotToken) { + // Rewrite element to a declaration that accesses array element at index i + emitBindingElement(element, createElementAccessExpression(value, createNumericLiteral(i))); + } + else if (i === numElements - 1) { + emitBindingElement(element, createSliceCall(value, i)); + } + } + } + } + else { + emitAssignment(target.name, value, /*shouldEmitCommaBeforeAssignment*/ emitCount > 0); + emitCount++; + } + } + } + function emitVariableDeclaration(node) { + if (ts.isBindingPattern(node.name)) { + if (languageVersion < 2 /* ES6 */) { + emitDestructuring(node, /*isAssignmentExpressionStatement*/ false); + } + else { + emit(node.name); + emitOptional(" = ", node.initializer); + } + } + else { + var initializer = node.initializer; + if (!initializer && languageVersion < 2 /* ES6 */) { + // downlevel emit for non-initialized let bindings defined in loops + // for (...) { let x; } + // should be + // for (...) { var = void 0; } + // this is necessary to preserve ES6 semantic in scenarios like + // for (...) { let x; console.log(x); x = 1 } // assignment on one iteration should not affect other iterations + var isLetDefinedInLoop = (resolver.getNodeCheckFlags(node) & 16384 /* BlockScopedBindingInLoop */) && + (getCombinedFlagsForIdentifier(node.name) & 16384 /* Let */); + // NOTE: default initialization should not be added to let bindings in for-in\for-of statements + if (isLetDefinedInLoop && + node.parent.parent.kind !== 200 /* ForInStatement */ && + node.parent.parent.kind !== 201 /* ForOfStatement */) { + initializer = createVoidZero(); + } + } + var exportChanged = isNameOfExportedSourceLevelDeclarationInSystemExternalModule(node.name); + if (exportChanged) { + write(exportFunctionForFile + "(\""); + emitNodeWithCommentsAndWithoutSourcemap(node.name); + write("\", "); + } + emitModuleMemberName(node); + emitOptional(" = ", initializer); + if (exportChanged) { + write(")"); + } + } + } + function emitExportVariableAssignments(node) { + if (node.kind === 187 /* OmittedExpression */) { + return; + } + var name = node.name; + if (name.kind === 69 /* Identifier */) { + emitExportMemberAssignments(name); + } + else if (ts.isBindingPattern(name)) { + ts.forEach(name.elements, emitExportVariableAssignments); + } + } + function getCombinedFlagsForIdentifier(node) { + if (!node.parent || (node.parent.kind !== 211 /* VariableDeclaration */ && node.parent.kind !== 163 /* BindingElement */)) { + return 0; + } + return ts.getCombinedNodeFlags(node.parent); + } + function isES6ExportedDeclaration(node) { + return !!(node.flags & 1 /* Export */) && + modulekind === 5 /* ES6 */ && + node.parent.kind === 248 /* SourceFile */; + } + function emitVariableStatement(node) { + var startIsEmitted = false; + if (node.flags & 1 /* Export */) { + if (isES6ExportedDeclaration(node)) { + // Exported ES6 module member + write("export "); + startIsEmitted = tryEmitStartOfVariableDeclarationList(node.declarationList); + } + } + else { + startIsEmitted = tryEmitStartOfVariableDeclarationList(node.declarationList); + } + if (startIsEmitted) { + emitCommaList(node.declarationList.declarations); + write(";"); + } + else { + var atLeastOneItem = emitVariableDeclarationListSkippingUninitializedEntries(node.declarationList); + if (atLeastOneItem) { + write(";"); + } + } + if (modulekind !== 5 /* ES6 */ && node.parent === currentSourceFile) { + ts.forEach(node.declarationList.declarations, emitExportVariableAssignments); + } + } + function shouldEmitLeadingAndTrailingCommentsForVariableStatement(node) { + // If we're not exporting the variables, there's nothing special here. + // Always emit comments for these nodes. + if (!(node.flags & 1 /* Export */)) { + return true; + } + // If we are exporting, but it's a top-level ES6 module exports, + // we'll emit the declaration list verbatim, so emit comments too. + if (isES6ExportedDeclaration(node)) { + return true; + } + // Otherwise, only emit if we have at least one initializer present. + for (var _a = 0, _b = node.declarationList.declarations; _a < _b.length; _a++) { + var declaration = _b[_a]; + if (declaration.initializer) { + return true; + } + } + return false; + } + function emitParameter(node) { + if (languageVersion < 2 /* ES6 */) { + if (ts.isBindingPattern(node.name)) { + var name_25 = createTempVariable(0 /* Auto */); + if (!tempParameters) { + tempParameters = []; + } + tempParameters.push(name_25); + emit(name_25); + } + else { + emit(node.name); + } + } + else { + if (node.dotDotDotToken) { + write("..."); + } + emit(node.name); + emitOptional(" = ", node.initializer); + } + } + function emitDefaultValueAssignments(node) { + if (languageVersion < 2 /* ES6 */) { + var tempIndex = 0; + ts.forEach(node.parameters, function (parameter) { + // A rest parameter cannot have a binding pattern or an initializer, + // so let's just ignore it. + if (parameter.dotDotDotToken) { + return; + } + var paramName = parameter.name, initializer = parameter.initializer; + if (ts.isBindingPattern(paramName)) { + // 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. + var hasBindingElements = paramName.elements.length > 0; + if (hasBindingElements || initializer) { + writeLine(); + write("var "); + if (hasBindingElements) { + emitDestructuring(parameter, /*isAssignmentExpressionStatement*/ false, tempParameters[tempIndex]); + } + else { + emit(tempParameters[tempIndex]); + write(" = "); + emit(initializer); + } + write(";"); + tempIndex++; + } + } + else if (initializer) { + writeLine(); + emitStart(parameter); + write("if ("); + emitNodeWithoutSourceMap(paramName); + write(" === void 0)"); + emitEnd(parameter); + write(" { "); + emitStart(parameter); + emitNodeWithCommentsAndWithoutSourcemap(paramName); + write(" = "); + emitNodeWithCommentsAndWithoutSourcemap(initializer); + emitEnd(parameter); + write("; }"); + } + }); + } + } + function emitRestParameter(node) { + if (languageVersion < 2 /* ES6 */ && ts.hasRestParameter(node)) { + var restIndex = node.parameters.length - 1; + var restParam = node.parameters[restIndex]; + // A rest parameter cannot have a binding pattern, so let's just ignore it if it does. + if (ts.isBindingPattern(restParam.name)) { + return; + } + var tempName = createTempVariable(268435456 /* _i */).text; + writeLine(); + emitLeadingComments(restParam); + emitStart(restParam); + write("var "); + emitNodeWithCommentsAndWithoutSourcemap(restParam.name); + write(" = [];"); + emitEnd(restParam); + emitTrailingComments(restParam); + writeLine(); + write("for ("); + emitStart(restParam); + write("var " + tempName + " = " + restIndex + ";"); + emitEnd(restParam); + write(" "); + emitStart(restParam); + write(tempName + " < arguments.length;"); + emitEnd(restParam); + write(" "); + emitStart(restParam); + write(tempName + "++"); + emitEnd(restParam); + write(") {"); + increaseIndent(); + writeLine(); + emitStart(restParam); + emitNodeWithCommentsAndWithoutSourcemap(restParam.name); + write("[" + tempName + " - " + restIndex + "] = arguments[" + tempName + "];"); + emitEnd(restParam); + decreaseIndent(); + writeLine(); + write("}"); + } + } + function emitAccessor(node) { + write(node.kind === 145 /* GetAccessor */ ? "get " : "set "); + emit(node.name); + emitSignatureAndBody(node); + } + function shouldEmitAsArrowFunction(node) { + return node.kind === 174 /* ArrowFunction */ && languageVersion >= 2 /* ES6 */; + } + function emitDeclarationName(node) { + if (node.name) { + emitNodeWithCommentsAndWithoutSourcemap(node.name); + } + else { + write(getGeneratedNameForNode(node)); + } + } + function shouldEmitFunctionName(node) { + if (node.kind === 173 /* FunctionExpression */) { + // Emit name if one is present + return !!node.name; + } + if (node.kind === 213 /* FunctionDeclaration */) { + // Emit name if one is present, or emit generated name in down-level case (for export default case) + return !!node.name || languageVersion < 2 /* ES6 */; + } + } + function emitFunctionDeclaration(node) { + if (ts.nodeIsMissing(node.body)) { + return emitCommentsOnNotEmittedNode(node); + } + // TODO (yuisu) : we should not have special cases to condition emitting comments + // but have one place to fix check for these conditions. + if (node.kind !== 143 /* MethodDeclaration */ && node.kind !== 142 /* MethodSignature */ && + node.parent && node.parent.kind !== 245 /* PropertyAssignment */ && + node.parent.kind !== 168 /* CallExpression */) { + // 1. Methods will emit the comments as part of emitting method declaration + // 2. If the function is a property of object literal, emitting leading-comments + // is done by emitNodeWithoutSourceMap which then call this function. + // In particular, we would like to avoid emit comments twice in following case: + // For example: + // var obj = { + // id: + // /*comment*/ () => void + // } + // 3. If the function is an argument in call expression, emitting of comments will be + // taken care of in emit list of arguments inside of emitCallexpression + emitLeadingComments(node); + } + emitStart(node); + // For targeting below es6, emit functions-like declaration including arrow function using function keyword. + // When targeting ES6, emit arrow function natively in ES6 by omitting function keyword and using fat arrow instead + if (!shouldEmitAsArrowFunction(node)) { + if (isES6ExportedDeclaration(node)) { + write("export "); + if (node.flags & 1024 /* Default */) { + write("default "); + } + } + write("function"); + if (languageVersion >= 2 /* ES6 */ && node.asteriskToken) { + write("*"); + } + write(" "); + } + if (shouldEmitFunctionName(node)) { + emitDeclarationName(node); + } + emitSignatureAndBody(node); + if (modulekind !== 5 /* ES6 */ && node.kind === 213 /* FunctionDeclaration */ && node.parent === currentSourceFile && node.name) { + emitExportMemberAssignments(node.name); + } + emitEnd(node); + if (node.kind !== 143 /* MethodDeclaration */ && node.kind !== 142 /* MethodSignature */) { + emitTrailingComments(node); + } + } + function emitCaptureThisForNodeIfNecessary(node) { + if (resolver.getNodeCheckFlags(node) & 4 /* CaptureThis */) { + writeLine(); + emitStart(node); + write("var _this = this;"); + emitEnd(node); + } + } + function emitSignatureParameters(node) { + increaseIndent(); + write("("); + if (node) { + var parameters = node.parameters; + var omitCount = languageVersion < 2 /* ES6 */ && ts.hasRestParameter(node) ? 1 : 0; + emitList(parameters, 0, parameters.length - omitCount, /*multiLine*/ false, /*trailingComma*/ false); + } + write(")"); + decreaseIndent(); + } + function emitSignatureParametersForArrow(node) { + // Check whether the parameter list needs parentheses and preserve no-parenthesis + if (node.parameters.length === 1 && node.pos === node.parameters[0].pos) { + emit(node.parameters[0]); + return; + } + emitSignatureParameters(node); + } + function emitAsyncFunctionBodyForES6(node) { + var promiseConstructor = ts.getEntityNameFromTypeNode(node.type); + var isArrowFunction = node.kind === 174 /* ArrowFunction */; + var hasLexicalArguments = (resolver.getNodeCheckFlags(node) & 4096 /* CaptureArguments */) !== 0; + var args; + // 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. + // + // The emit for an async arrow without a lexical `arguments` binding might be: + // + // // input + // let a = async (b) => { await b; } + // + // // output + // let a = (b) => __awaiter(this, void 0, void 0, function* () { + // yield b; + // }); + // + // The emit for an async arrow with a lexical `arguments` binding might be: + // + // // input + // let a = async (b) => { await arguments[0]; } + // + // // output + // let a = (b) => __awaiter(this, arguments, void 0, function* (arguments) { + // yield arguments[0]; + // }); + // + // The emit for an async function expression without a lexical `arguments` binding + // might be: + // + // // input + // let a = async function (b) { + // await b; + // } + // + // // output + // let a = function (b) { + // return __awaiter(this, void 0, void 0, function* () { + // yield b; + // }); + // } + // + // The emit for an async function expression with a lexical `arguments` binding + // might be: + // + // // input + // let a = async function (b) { + // await arguments[0]; + // } + // + // // output + // let a = function (b) { + // return __awaiter(this, arguments, void 0, function* (_arguments) { + // yield _arguments[0]; + // }); + // } + // + // The emit for an async function expression with a lexical `arguments` binding + // and a return type annotation might be: + // + // // input + // let a = async function (b): MyPromise { + // await arguments[0]; + // } + // + // // output + // let a = function (b) { + // return __awaiter(this, arguments, MyPromise, function* (_arguments) { + // yield _arguments[0]; + // }); + // } + // + // If this is not an async arrow, emit the opening brace of the function body + // and the start of the return statement. + if (!isArrowFunction) { + write(" {"); + increaseIndent(); + writeLine(); + write("return"); + } + write(" __awaiter(this"); + if (hasLexicalArguments) { + write(", arguments"); + } + else { + write(", void 0"); + } + if (promiseConstructor) { + write(", "); + emitNodeWithoutSourceMap(promiseConstructor); + } + else { + write(", Promise"); + } + // Emit the call to __awaiter. + if (hasLexicalArguments) { + write(", function* (_arguments)"); + } + else { + write(", function* ()"); + } + // Emit the signature and body for the inner generator function. + emitFunctionBody(node); + write(")"); + // If this is not an async arrow, emit the closing brace of the outer function body. + if (!isArrowFunction) { + write(";"); + decreaseIndent(); + writeLine(); + write("}"); + } + } + function emitFunctionBody(node) { + if (!node.body) { + // There can be no body when there are parse errors. Just emit an empty block + // in that case. + write(" { }"); + } + else { + if (node.body.kind === 192 /* Block */) { + emitBlockFunctionBody(node, node.body); + } + else { + emitExpressionFunctionBody(node, node.body); + } + } + } + function emitSignatureAndBody(node) { + var saveConvertedLoopState = convertedLoopState; + var saveTempFlags = tempFlags; + var saveTempVariables = tempVariables; + var saveTempParameters = tempParameters; + convertedLoopState = undefined; + tempFlags = 0; + tempVariables = undefined; + tempParameters = undefined; + // When targeting ES6, emit arrow function natively in ES6 + if (shouldEmitAsArrowFunction(node)) { + emitSignatureParametersForArrow(node); + write(" =>"); + } + else { + emitSignatureParameters(node); + } + var isAsync = ts.isAsyncFunctionLike(node); + if (isAsync && languageVersion === 2 /* ES6 */) { + emitAsyncFunctionBodyForES6(node); + } + else { + emitFunctionBody(node); + } + if (!isES6ExportedDeclaration(node)) { + emitExportMemberAssignment(node); + } + ts.Debug.assert(convertedLoopState === undefined); + convertedLoopState = saveConvertedLoopState; + tempFlags = saveTempFlags; + tempVariables = saveTempVariables; + tempParameters = saveTempParameters; + } + // Returns true if any preamble code was emitted. + function emitFunctionBodyPreamble(node) { + emitCaptureThisForNodeIfNecessary(node); + emitDefaultValueAssignments(node); + emitRestParameter(node); + } + function emitExpressionFunctionBody(node, body) { + if (languageVersion < 2 /* ES6 */ || node.flags & 512 /* Async */) { + emitDownLevelExpressionFunctionBody(node, body); + return; + } + // For es6 and higher we can emit the expression as is. However, in the case + // where the expression might end up looking like a block when emitted, we'll + // also wrap it in parentheses first. For example if you have: a => {} + // then we need to generate: a => ({}) + write(" "); + // Unwrap all type assertions. + var current = body; + while (current.kind === 171 /* TypeAssertionExpression */) { + current = current.expression; + } + emitParenthesizedIf(body, current.kind === 165 /* ObjectLiteralExpression */); + } + function emitDownLevelExpressionFunctionBody(node, body) { + write(" {"); + scopeEmitStart(node); + increaseIndent(); + var outPos = writer.getTextPos(); + emitDetachedComments(node.body); + emitFunctionBodyPreamble(node); + var preambleEmitted = writer.getTextPos() !== outPos; + decreaseIndent(); + // If we didn't have to emit any preamble code, then attempt to keep the arrow + // function on one line. + if (!preambleEmitted && nodeStartPositionsAreOnSameLine(node, body)) { + write(" "); + emitStart(body); + write("return "); + emit(body); + emitEnd(body); + write(";"); + emitTempDeclarations(/*newLine*/ false); + write(" "); + } + else { + increaseIndent(); + writeLine(); + emitLeadingComments(node.body); + write("return "); + emit(body); + write(";"); + emitTrailingComments(node.body); + emitTempDeclarations(/*newLine*/ true); + decreaseIndent(); + writeLine(); + } + emitStart(node.body); + write("}"); + emitEnd(node.body); + scopeEmitEnd(); + } + function emitBlockFunctionBody(node, body) { + write(" {"); + scopeEmitStart(node); + var initialTextPos = writer.getTextPos(); + increaseIndent(); + emitDetachedComments(body.statements); + // Emit all the directive prologues (like "use strict"). These have to come before + // any other preamble code we write (like parameter initializers). + var startIndex = emitDirectivePrologues(body.statements, /*startWithNewLine*/ true); + emitFunctionBodyPreamble(node); + decreaseIndent(); + var preambleEmitted = writer.getTextPos() !== initialTextPos; + if (!preambleEmitted && nodeEndIsOnSameLineAsNodeStart(body, body)) { + for (var _a = 0, _b = body.statements; _a < _b.length; _a++) { + var statement = _b[_a]; + write(" "); + emit(statement); + } + emitTempDeclarations(/*newLine*/ false); + write(" "); + emitLeadingCommentsOfPosition(body.statements.end); + } + else { + increaseIndent(); + emitLinesStartingAt(body.statements, startIndex); + emitTempDeclarations(/*newLine*/ true); + writeLine(); + emitLeadingCommentsOfPosition(body.statements.end); + decreaseIndent(); + } + emitToken(16 /* CloseBraceToken */, body.statements.end); + scopeEmitEnd(); + } + function findInitialSuperCall(ctor) { + if (ctor.body) { + var statement = ctor.body.statements[0]; + if (statement && statement.kind === 195 /* ExpressionStatement */) { + var expr = statement.expression; + if (expr && expr.kind === 168 /* CallExpression */) { + var func = expr.expression; + if (func && func.kind === 95 /* SuperKeyword */) { + return statement; + } + } + } + } + } + function emitParameterPropertyAssignments(node) { + ts.forEach(node.parameters, function (param) { + if (param.flags & 112 /* AccessibilityModifier */) { + writeLine(); + emitStart(param); + emitStart(param.name); + write("this."); + emitNodeWithoutSourceMap(param.name); + emitEnd(param.name); + write(" = "); + emit(param.name); + write(";"); + emitEnd(param); + } + }); + } + function emitMemberAccessForPropertyName(memberName) { + // This does not emit source map because it is emitted by caller as caller + // is aware how the property name changes to the property access + // eg. public x = 10; becomes this.x and static x = 10 becomes className.x + if (memberName.kind === 9 /* StringLiteral */ || memberName.kind === 8 /* NumericLiteral */) { + write("["); + emitNodeWithCommentsAndWithoutSourcemap(memberName); + write("]"); + } + else if (memberName.kind === 136 /* ComputedPropertyName */) { + emitComputedPropertyName(memberName); + } + else { + write("."); + emitNodeWithCommentsAndWithoutSourcemap(memberName); + } + } + function getInitializedProperties(node, isStatic) { + var properties = []; + for (var _a = 0, _b = node.members; _a < _b.length; _a++) { + var member = _b[_a]; + if (member.kind === 141 /* PropertyDeclaration */ && isStatic === ((member.flags & 128 /* Static */) !== 0) && member.initializer) { + properties.push(member); + } + } + return properties; + } + function emitPropertyDeclarations(node, properties) { + for (var _a = 0; _a < properties.length; _a++) { + var property = properties[_a]; + emitPropertyDeclaration(node, property); + } + } + function emitPropertyDeclaration(node, property, receiver, isExpression) { + writeLine(); + emitLeadingComments(property); + emitStart(property); + emitStart(property.name); + if (receiver) { + emit(receiver); + } + else { + if (property.flags & 128 /* Static */) { + emitDeclarationName(node); + } + else { + write("this"); + } + } + emitMemberAccessForPropertyName(property.name); + emitEnd(property.name); + write(" = "); + emit(property.initializer); + if (!isExpression) { + write(";"); + } + emitEnd(property); + emitTrailingComments(property); + } + function emitMemberFunctionsForES5AndLower(node) { + ts.forEach(node.members, function (member) { + if (member.kind === 191 /* SemicolonClassElement */) { + writeLine(); + write(";"); + } + else if (member.kind === 143 /* MethodDeclaration */ || node.kind === 142 /* MethodSignature */) { + if (!member.body) { + return emitCommentsOnNotEmittedNode(member); + } + writeLine(); + emitLeadingComments(member); + emitStart(member); + emitStart(member.name); + emitClassMemberPrefix(node, member); + emitMemberAccessForPropertyName(member.name); + emitEnd(member.name); + write(" = "); + emitFunctionDeclaration(member); + emitEnd(member); + write(";"); + emitTrailingComments(member); + } + else if (member.kind === 145 /* GetAccessor */ || member.kind === 146 /* SetAccessor */) { + var accessors = ts.getAllAccessorDeclarations(node.members, member); + if (member === accessors.firstAccessor) { + writeLine(); + emitStart(member); + write("Object.defineProperty("); + emitStart(member.name); + emitClassMemberPrefix(node, member); + write(", "); + emitExpressionForPropertyName(member.name); + emitEnd(member.name); + write(", {"); + increaseIndent(); + if (accessors.getAccessor) { + writeLine(); + emitLeadingComments(accessors.getAccessor); + write("get: "); + emitStart(accessors.getAccessor); + write("function "); + emitSignatureAndBody(accessors.getAccessor); + emitEnd(accessors.getAccessor); + emitTrailingComments(accessors.getAccessor); + write(","); + } + if (accessors.setAccessor) { + writeLine(); + emitLeadingComments(accessors.setAccessor); + write("set: "); + emitStart(accessors.setAccessor); + write("function "); + emitSignatureAndBody(accessors.setAccessor); + emitEnd(accessors.setAccessor); + emitTrailingComments(accessors.setAccessor); + write(","); + } + writeLine(); + write("enumerable: true,"); + writeLine(); + write("configurable: true"); + decreaseIndent(); + writeLine(); + write("});"); + emitEnd(member); + } + } + }); + } + function emitMemberFunctionsForES6AndHigher(node) { + for (var _a = 0, _b = node.members; _a < _b.length; _a++) { + var member = _b[_a]; + if ((member.kind === 143 /* MethodDeclaration */ || node.kind === 142 /* MethodSignature */) && !member.body) { + emitCommentsOnNotEmittedNode(member); + } + else if (member.kind === 143 /* MethodDeclaration */ || + member.kind === 145 /* GetAccessor */ || + member.kind === 146 /* SetAccessor */) { + writeLine(); + emitLeadingComments(member); + emitStart(member); + if (member.flags & 128 /* Static */) { + write("static "); + } + if (member.kind === 145 /* GetAccessor */) { + write("get "); + } + else if (member.kind === 146 /* SetAccessor */) { + write("set "); + } + if (member.asteriskToken) { + write("*"); + } + emit(member.name); + emitSignatureAndBody(member); + emitEnd(member); + emitTrailingComments(member); + } + else if (member.kind === 191 /* SemicolonClassElement */) { + writeLine(); + write(";"); + } + } + } + function emitConstructor(node, baseTypeElement) { + var saveConvertedLoopState = convertedLoopState; + var saveTempFlags = tempFlags; + var saveTempVariables = tempVariables; + var saveTempParameters = tempParameters; + convertedLoopState = undefined; + tempFlags = 0; + tempVariables = undefined; + tempParameters = undefined; + emitConstructorWorker(node, baseTypeElement); + ts.Debug.assert(convertedLoopState === undefined); + convertedLoopState = saveConvertedLoopState; + tempFlags = saveTempFlags; + tempVariables = saveTempVariables; + tempParameters = saveTempParameters; + } + function emitConstructorWorker(node, baseTypeElement) { + // Check if we have property assignment inside class declaration. + // If there is property assignment, we need to emit constructor whether users define it or not + // If there is no property assignment, we can omit constructor if users do not define it + var hasInstancePropertyWithInitializer = false; + // Emit the constructor overload pinned comments + ts.forEach(node.members, function (member) { + if (member.kind === 144 /* Constructor */ && !member.body) { + emitCommentsOnNotEmittedNode(member); + } + // Check if there is any non-static property assignment + if (member.kind === 141 /* PropertyDeclaration */ && member.initializer && (member.flags & 128 /* Static */) === 0) { + hasInstancePropertyWithInitializer = true; + } + }); + var ctor = ts.getFirstConstructorWithBody(node); + // For target ES6 and above, if there is no user-defined constructor and there is no property assignment + // do not emit constructor in class declaration. + if (languageVersion >= 2 /* ES6 */ && !ctor && !hasInstancePropertyWithInitializer) { + return; + } + if (ctor) { + emitLeadingComments(ctor); + } + emitStart(ctor || node); + if (languageVersion < 2 /* ES6 */) { + write("function "); + emitDeclarationName(node); + emitSignatureParameters(ctor); + } + else { + write("constructor"); + if (ctor) { + emitSignatureParameters(ctor); + } + else { + // Based on EcmaScript6 section 14.5.14: Runtime Semantics: ClassDefinitionEvaluation. + // If constructor is empty, then, + // If ClassHeritageopt is present, then + // Let constructor be the result of parsing the String "constructor(... args){ super (...args);}" using the syntactic grammar with the goal symbol MethodDefinition. + // Else, + // Let constructor be the result of parsing the String "constructor( ){ }" using the syntactic grammar with the goal symbol MethodDefinition + if (baseTypeElement) { + write("(...args)"); + } + else { + write("()"); + } + } + } + var startIndex = 0; + write(" {"); + scopeEmitStart(node, "constructor"); + increaseIndent(); + if (ctor) { + // Emit all the directive prologues (like "use strict"). These have to come before + // any other preamble code we write (like parameter initializers). + startIndex = emitDirectivePrologues(ctor.body.statements, /*startWithNewLine*/ true); + emitDetachedComments(ctor.body.statements); + } + emitCaptureThisForNodeIfNecessary(node); + var superCall; + if (ctor) { + emitDefaultValueAssignments(ctor); + emitRestParameter(ctor); + if (baseTypeElement) { + superCall = findInitialSuperCall(ctor); + if (superCall) { + writeLine(); + emit(superCall); + } + } + emitParameterPropertyAssignments(ctor); + } + else { + if (baseTypeElement) { + writeLine(); + emitStart(baseTypeElement); + if (languageVersion < 2 /* ES6 */) { + write("_super.apply(this, arguments);"); + } + else { + write("super(...args);"); + } + emitEnd(baseTypeElement); + } + } + emitPropertyDeclarations(node, getInitializedProperties(node, /*static:*/ false)); + if (ctor) { + var statements = ctor.body.statements; + if (superCall) { + statements = statements.slice(1); + } + emitLinesStartingAt(statements, startIndex); + } + emitTempDeclarations(/*newLine*/ true); + writeLine(); + if (ctor) { + emitLeadingCommentsOfPosition(ctor.body.statements.end); + } + decreaseIndent(); + emitToken(16 /* CloseBraceToken */, ctor ? ctor.body.statements.end : node.members.end); + scopeEmitEnd(); + emitEnd(ctor || node); + if (ctor) { + emitTrailingComments(ctor); + } + } + function emitClassExpression(node) { + return emitClassLikeDeclaration(node); + } + function emitClassDeclaration(node) { + return emitClassLikeDeclaration(node); + } + function emitClassLikeDeclaration(node) { + if (languageVersion < 2 /* ES6 */) { + emitClassLikeDeclarationBelowES6(node); + } + else { + emitClassLikeDeclarationForES6AndHigher(node); + } + if (modulekind !== 5 /* ES6 */ && node.parent === currentSourceFile && node.name) { + emitExportMemberAssignments(node.name); + } + } + function emitClassLikeDeclarationForES6AndHigher(node) { + var thisNodeIsDecorated = ts.nodeIsDecorated(node); + if (node.kind === 214 /* ClassDeclaration */) { + if (thisNodeIsDecorated) { + // To preserve the correct runtime semantics when decorators are applied to the class, + // the emit needs to follow one of the following rules: + // + // * For a local class declaration: + // + // @dec class C { + // } + // + // The emit should be: + // + // let C = class { + // }; + // C = __decorate([dec], C); + // + // * For an exported class declaration: + // + // @dec export class C { + // } + // + // The emit should be: + // + // export let C = class { + // }; + // C = __decorate([dec], C); + // + // * For a default export of a class declaration with a name: + // + // @dec default export class C { + // } + // + // The emit should be: + // + // let C = class { + // } + // C = __decorate([dec], C); + // export default C; + // + // * For a default export of a class declaration without a name: + // + // @dec default export class { + // } + // + // The emit should be: + // + // let _default = class { + // } + // _default = __decorate([dec], _default); + // export default _default; + // + if (isES6ExportedDeclaration(node) && !(node.flags & 1024 /* Default */)) { + write("export "); + } + write("let "); + emitDeclarationName(node); + write(" = "); + } + else if (isES6ExportedDeclaration(node)) { + write("export "); + if (node.flags & 1024 /* Default */) { + write("default "); + } + } + } + // If the class has static properties, and it's a class expression, then we'll need + // to specialize the emit a bit. for a class expression of the form: + // + // class C { static a = 1; static b = 2; ... } + // + // We'll emit: + // + // (_temp = class C { ... }, _temp.a = 1, _temp.b = 2, _temp) + // + // This keeps the expression as an expression, while ensuring that the static parts + // of it have been initialized by the time it is used. + var staticProperties = getInitializedProperties(node, /*static:*/ true); + var isClassExpressionWithStaticProperties = staticProperties.length > 0 && node.kind === 186 /* ClassExpression */; + var tempVariable; + if (isClassExpressionWithStaticProperties) { + tempVariable = createAndRecordTempVariable(0 /* Auto */); + write("("); + increaseIndent(); + emit(tempVariable); + write(" = "); + } + write("class"); + // emit name if + // - node has a name + // - this is default export with static initializers + if ((node.name || (node.flags & 1024 /* Default */ && staticProperties.length > 0)) && !thisNodeIsDecorated) { + write(" "); + emitDeclarationName(node); + } + var baseTypeNode = ts.getClassExtendsHeritageClauseElement(node); + if (baseTypeNode) { + write(" extends "); + emit(baseTypeNode.expression); + } + write(" {"); + increaseIndent(); + scopeEmitStart(node); + writeLine(); + emitConstructor(node, baseTypeNode); + emitMemberFunctionsForES6AndHigher(node); + decreaseIndent(); + writeLine(); + emitToken(16 /* CloseBraceToken */, node.members.end); + scopeEmitEnd(); + // TODO(rbuckton): Need to go back to `let _a = class C {}` approach, removing the defineProperty call for now. + // For a decorated class, we need to assign its name (if it has one). This is because we emit + // the class as a class expression to avoid the double-binding of the identifier: + // + // let C = class { + // } + // Object.defineProperty(C, "name", { value: "C", configurable: true }); + // + if (thisNodeIsDecorated) { + write(";"); + } + // Emit static property assignment. Because classDeclaration is lexically evaluated, + // it is safe to emit static property assignment after classDeclaration + // From ES6 specification: + // 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 (isClassExpressionWithStaticProperties) { + for (var _a = 0; _a < staticProperties.length; _a++) { + var property = staticProperties[_a]; + write(","); + writeLine(); + emitPropertyDeclaration(node, property, /*receiver:*/ tempVariable, /*isExpression:*/ true); + } + write(","); + writeLine(); + emit(tempVariable); + decreaseIndent(); + write(")"); + } + else { + writeLine(); + emitPropertyDeclarations(node, staticProperties); + emitDecoratorsOfClass(node); + } + // If this is an exported class, but not on the top level (i.e. on an internal + // module), export it + if (!isES6ExportedDeclaration(node) && (node.flags & 1 /* Export */)) { + writeLine(); + emitStart(node); + emitModuleMemberName(node); + write(" = "); + emitDeclarationName(node); + emitEnd(node); + write(";"); + } + else if (isES6ExportedDeclaration(node) && (node.flags & 1024 /* Default */) && thisNodeIsDecorated) { + // if this is a top level default export of decorated class, write the export after the declaration. + writeLine(); + write("export default "); + emitDeclarationName(node); + write(";"); + } + } + function emitClassLikeDeclarationBelowES6(node) { + if (node.kind === 214 /* ClassDeclaration */) { + // source file level classes in system modules are hoisted so 'var's for them are already defined + if (!shouldHoistDeclarationInSystemJsModule(node)) { + write("var "); + } + emitDeclarationName(node); + write(" = "); + } + write("(function ("); + var baseTypeNode = ts.getClassExtendsHeritageClauseElement(node); + if (baseTypeNode) { + write("_super"); + } + write(") {"); + var saveTempFlags = tempFlags; + var saveTempVariables = tempVariables; + var saveTempParameters = tempParameters; + var saveComputedPropertyNamesToGeneratedNames = computedPropertyNamesToGeneratedNames; + var saveConvertedLoopState = convertedLoopState; + convertedLoopState = undefined; + tempFlags = 0; + tempVariables = undefined; + tempParameters = undefined; + computedPropertyNamesToGeneratedNames = undefined; + increaseIndent(); + scopeEmitStart(node); + if (baseTypeNode) { + writeLine(); + emitStart(baseTypeNode); + write("__extends("); + emitDeclarationName(node); + write(", _super);"); + emitEnd(baseTypeNode); + } + writeLine(); + emitConstructor(node, baseTypeNode); + emitMemberFunctionsForES5AndLower(node); + emitPropertyDeclarations(node, getInitializedProperties(node, /*static:*/ true)); + writeLine(); + emitDecoratorsOfClass(node); + writeLine(); + emitToken(16 /* CloseBraceToken */, node.members.end, function () { + write("return "); + emitDeclarationName(node); + }); + write(";"); + emitTempDeclarations(/*newLine*/ true); + ts.Debug.assert(convertedLoopState === undefined); + convertedLoopState = saveConvertedLoopState; + tempFlags = saveTempFlags; + tempVariables = saveTempVariables; + tempParameters = saveTempParameters; + computedPropertyNamesToGeneratedNames = saveComputedPropertyNamesToGeneratedNames; + decreaseIndent(); + writeLine(); + emitToken(16 /* CloseBraceToken */, node.members.end); + scopeEmitEnd(); + emitStart(node); + write(")("); + if (baseTypeNode) { + emit(baseTypeNode.expression); + } + write(")"); + if (node.kind === 214 /* ClassDeclaration */) { + write(";"); + } + emitEnd(node); + if (node.kind === 214 /* ClassDeclaration */) { + emitExportMemberAssignment(node); + } + } + function emitClassMemberPrefix(node, member) { + emitDeclarationName(node); + if (!(member.flags & 128 /* Static */)) { + write(".prototype"); + } + } + function emitDecoratorsOfClass(node) { + emitDecoratorsOfMembers(node, /*staticFlag*/ 0); + emitDecoratorsOfMembers(node, 128 /* Static */); + emitDecoratorsOfConstructor(node); + } + function emitDecoratorsOfConstructor(node) { + var decorators = node.decorators; + var constructor = ts.getFirstConstructorWithBody(node); + var hasDecoratedParameters = constructor && ts.forEach(constructor.parameters, ts.nodeIsDecorated); + // skip decoration of the constructor if neither it nor its parameters are decorated + if (!decorators && !hasDecoratedParameters) { + return; + } + // Emit the call to __decorate. Given the class: + // + // @dec + // class C { + // } + // + // The emit for the class is: + // + // C = __decorate([dec], C); + // + writeLine(); + emitStart(node); + emitDeclarationName(node); + write(" = __decorate(["); + increaseIndent(); + writeLine(); + var decoratorCount = decorators ? decorators.length : 0; + var argumentsWritten = emitList(decorators, 0, decoratorCount, /*multiLine*/ true, /*trailingComma*/ false, /*leadingComma*/ false, /*noTrailingNewLine*/ true, function (decorator) { + emitStart(decorator); + emit(decorator.expression); + emitEnd(decorator); + }); + argumentsWritten += emitDecoratorsOfParameters(constructor, /*leadingComma*/ argumentsWritten > 0); + emitSerializedTypeMetadata(node, /*leadingComma*/ argumentsWritten >= 0); + decreaseIndent(); + writeLine(); + write("], "); + emitDeclarationName(node); + write(");"); + emitEnd(node); + writeLine(); + } + function emitDecoratorsOfMembers(node, staticFlag) { + for (var _a = 0, _b = node.members; _a < _b.length; _a++) { + var member = _b[_a]; + // only emit members in the correct group + if ((member.flags & 128 /* Static */) !== staticFlag) { + continue; + } + // skip members that cannot be decorated (such as the constructor) + if (!ts.nodeCanBeDecorated(member)) { + continue; + } + // skip a member if it or any of its parameters are not decorated + if (!ts.nodeOrChildIsDecorated(member)) { + continue; + } + // skip an accessor declaration if it is not the first accessor + var decorators = void 0; + var functionLikeMember = void 0; + if (ts.isAccessor(member)) { + var accessors = ts.getAllAccessorDeclarations(node.members, member); + if (member !== accessors.firstAccessor) { + continue; + } + // get the decorators from the first accessor with decorators + decorators = accessors.firstAccessor.decorators; + if (!decorators && accessors.secondAccessor) { + decorators = accessors.secondAccessor.decorators; + } + // we only decorate parameters of the set accessor + functionLikeMember = accessors.setAccessor; + } + else { + decorators = member.decorators; + // we only decorate the parameters here if this is a method + if (member.kind === 143 /* MethodDeclaration */) { + functionLikeMember = member; + } + } + // Emit the call to __decorate. Given the following: + // + // class C { + // @dec method(@dec2 x) {} + // @dec get accessor() {} + // @dec prop; + // } + // + // The emit for a method is: + // + // __decorate([ + // dec, + // __param(0, dec2), + // __metadata("design:type", Function), + // __metadata("design:paramtypes", [Object]), + // __metadata("design:returntype", void 0) + // ], C.prototype, "method", undefined); + // + // The emit for an accessor is: + // + // __decorate([ + // dec + // ], C.prototype, "accessor", undefined); + // + // The emit for a property is: + // + // __decorate([ + // dec + // ], C.prototype, "prop"); + // + writeLine(); + emitStart(member); + write("__decorate(["); + increaseIndent(); + writeLine(); + var decoratorCount = decorators ? decorators.length : 0; + var argumentsWritten = emitList(decorators, 0, decoratorCount, /*multiLine*/ true, /*trailingComma*/ false, /*leadingComma*/ false, /*noTrailingNewLine*/ true, function (decorator) { + emitStart(decorator); + emit(decorator.expression); + emitEnd(decorator); + }); + argumentsWritten += emitDecoratorsOfParameters(functionLikeMember, argumentsWritten > 0); + emitSerializedTypeMetadata(member, argumentsWritten > 0); + decreaseIndent(); + writeLine(); + write("], "); + emitStart(member.name); + emitClassMemberPrefix(node, member); + write(", "); + emitExpressionForPropertyName(member.name); + emitEnd(member.name); + if (languageVersion > 0 /* ES3 */) { + if (member.kind !== 141 /* PropertyDeclaration */) { + // We emit `null` here to indicate to `__decorate` that it can invoke `Object.getOwnPropertyDescriptor` directly. + // We have this extra argument here so that we can inject an explicit property descriptor at a later date. + write(", null"); + } + else { + // We emit `void 0` here to indicate to `__decorate` that it can invoke `Object.defineProperty` directly, but that it + // should not invoke `Object.getOwnPropertyDescriptor`. + write(", void 0"); + } + } + write(");"); + emitEnd(member); + writeLine(); + } + } + function emitDecoratorsOfParameters(node, leadingComma) { + var argumentsWritten = 0; + if (node) { + var parameterIndex = 0; + for (var _a = 0, _b = node.parameters; _a < _b.length; _a++) { + var parameter = _b[_a]; + if (ts.nodeIsDecorated(parameter)) { + var decorators = parameter.decorators; + argumentsWritten += emitList(decorators, 0, decorators.length, /*multiLine*/ true, /*trailingComma*/ false, /*leadingComma*/ leadingComma, /*noTrailingNewLine*/ true, function (decorator) { + emitStart(decorator); + write("__param(" + parameterIndex + ", "); + emit(decorator.expression); + write(")"); + emitEnd(decorator); + }); + leadingComma = true; + } + ++parameterIndex; + } + } + return argumentsWritten; + } + function shouldEmitTypeMetadata(node) { + // This method determines whether to emit the "design:type" metadata based on the node's kind. + // The caller should have already tested whether the node has decorators and whether the emitDecoratorMetadata + // compiler option is set. + switch (node.kind) { + case 143 /* MethodDeclaration */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: + case 141 /* PropertyDeclaration */: + return true; + } + return false; + } + function shouldEmitReturnTypeMetadata(node) { + // This method determines whether to emit the "design:returntype" metadata based on the node's kind. + // The caller should have already tested whether the node has decorators and whether the emitDecoratorMetadata + // compiler option is set. + switch (node.kind) { + case 143 /* MethodDeclaration */: + return true; + } + return false; + } + function shouldEmitParamTypesMetadata(node) { + // This method determines whether to emit the "design:paramtypes" metadata based on the node's kind. + // The caller should have already tested whether the node has decorators and whether the emitDecoratorMetadata + // compiler option is set. + switch (node.kind) { + case 214 /* ClassDeclaration */: + case 143 /* MethodDeclaration */: + case 146 /* SetAccessor */: + return true; + } + return false; + } + /** Serializes the type of a declaration to an appropriate JS constructor value. Used by the __metadata decorator for a class member. */ + function emitSerializedTypeOfNode(node) { + // serialization of the type of a declaration uses the following rules: + // + // * The serialized type of a ClassDeclaration is "Function" + // * The serialized type of a ParameterDeclaration is the serialized type of its type annotation. + // * The serialized type of a PropertyDeclaration is the serialized type of its type annotation. + // * The serialized type of an AccessorDeclaration is the serialized type of the return type annotation of its getter or parameter type annotation of its setter. + // * The serialized type of any other FunctionLikeDeclaration is "Function". + // * The serialized type of any other node is "void 0". + // + // For rules on serializing type annotations, see `serializeTypeNode`. + switch (node.kind) { + case 214 /* ClassDeclaration */: + write("Function"); + return; + case 141 /* PropertyDeclaration */: + emitSerializedTypeNode(node.type); + return; + case 138 /* Parameter */: + emitSerializedTypeNode(node.type); + return; + case 145 /* GetAccessor */: + emitSerializedTypeNode(node.type); + return; + case 146 /* SetAccessor */: + emitSerializedTypeNode(ts.getSetAccessorTypeAnnotationNode(node)); + return; + } + if (ts.isFunctionLike(node)) { + write("Function"); + return; + } + write("void 0"); + } + function emitSerializedTypeNode(node) { + if (node) { + switch (node.kind) { + case 103 /* VoidKeyword */: + write("void 0"); + return; + case 160 /* ParenthesizedType */: + emitSerializedTypeNode(node.type); + return; + case 152 /* FunctionType */: + case 153 /* ConstructorType */: + write("Function"); + return; + case 156 /* ArrayType */: + case 157 /* TupleType */: + write("Array"); + return; + case 150 /* TypePredicate */: + case 120 /* BooleanKeyword */: + write("Boolean"); + return; + case 130 /* StringKeyword */: + case 9 /* StringLiteral */: + write("String"); + return; + case 128 /* NumberKeyword */: + write("Number"); + return; + case 131 /* SymbolKeyword */: + write("Symbol"); + return; + case 151 /* TypeReference */: + emitSerializedTypeReferenceNode(node); + return; + case 154 /* TypeQuery */: + case 155 /* TypeLiteral */: + case 158 /* UnionType */: + case 159 /* IntersectionType */: + case 117 /* AnyKeyword */: + break; + default: + ts.Debug.fail("Cannot serialize unexpected type node."); + break; + } + } + write("Object"); + } + /** Serializes a TypeReferenceNode to an appropriate JS constructor value. Used by the __metadata decorator. */ + function emitSerializedTypeReferenceNode(node) { + var location = node.parent; + while (ts.isDeclaration(location) || ts.isTypeNode(location)) { + location = location.parent; + } + // Clone the type name and parent it to a location outside of the current declaration. + var typeName = ts.cloneEntityName(node.typeName); + typeName.parent = location; + var result = resolver.getTypeReferenceSerializationKind(typeName); + switch (result) { + case ts.TypeReferenceSerializationKind.Unknown: + var temp = createAndRecordTempVariable(0 /* Auto */); + write("(typeof ("); + emitNodeWithoutSourceMap(temp); + write(" = "); + emitEntityNameAsExpression(typeName, /*useFallback*/ true); + write(") === 'function' && "); + emitNodeWithoutSourceMap(temp); + write(") || Object"); + break; + case ts.TypeReferenceSerializationKind.TypeWithConstructSignatureAndValue: + emitEntityNameAsExpression(typeName, /*useFallback*/ false); + break; + case ts.TypeReferenceSerializationKind.VoidType: + write("void 0"); + break; + case ts.TypeReferenceSerializationKind.BooleanType: + write("Boolean"); + break; + case ts.TypeReferenceSerializationKind.NumberLikeType: + write("Number"); + break; + case ts.TypeReferenceSerializationKind.StringLikeType: + write("String"); + break; + case ts.TypeReferenceSerializationKind.ArrayLikeType: + write("Array"); + break; + case ts.TypeReferenceSerializationKind.ESSymbolType: + if (languageVersion < 2 /* ES6 */) { + write("typeof Symbol === 'function' ? Symbol : Object"); + } + else { + write("Symbol"); + } + break; + case ts.TypeReferenceSerializationKind.TypeWithCallSignature: + write("Function"); + break; + case ts.TypeReferenceSerializationKind.ObjectType: + write("Object"); + break; + } + } + /** Serializes the parameter types of a function or the constructor of a class. Used by the __metadata decorator for a method or set accessor. */ + function emitSerializedParameterTypesOfNode(node) { + // serialization of parameter types uses the following rules: + // + // * If the declaration is a class, the parameters of the first constructor with a body are used. + // * If the declaration is function-like and has a body, the parameters of the function are used. + // + // For the rules on serializing the type of each parameter declaration, see `serializeTypeOfDeclaration`. + if (node) { + var valueDeclaration; + if (node.kind === 214 /* ClassDeclaration */) { + valueDeclaration = ts.getFirstConstructorWithBody(node); + } + else if (ts.isFunctionLike(node) && ts.nodeIsPresent(node.body)) { + valueDeclaration = node; + } + if (valueDeclaration) { + var parameters = valueDeclaration.parameters; + var parameterCount = parameters.length; + if (parameterCount > 0) { + for (var i = 0; i < parameterCount; i++) { + if (i > 0) { + write(", "); + } + if (parameters[i].dotDotDotToken) { + var parameterType = parameters[i].type; + if (parameterType.kind === 156 /* ArrayType */) { + parameterType = parameterType.elementType; + } + else if (parameterType.kind === 151 /* TypeReference */ && parameterType.typeArguments && parameterType.typeArguments.length === 1) { + parameterType = parameterType.typeArguments[0]; + } + else { + parameterType = undefined; + } + emitSerializedTypeNode(parameterType); + } + else { + emitSerializedTypeOfNode(parameters[i]); + } + } + } + } + } + } + /** Serializes the return type of function. Used by the __metadata decorator for a method. */ + function emitSerializedReturnTypeOfNode(node) { + if (node && ts.isFunctionLike(node) && node.type) { + emitSerializedTypeNode(node.type); + return; + } + write("void 0"); + } + function emitSerializedTypeMetadata(node, writeComma) { + // This method emits the serialized type metadata for a decorator target. + // The caller should have already tested whether the node has decorators. + var argumentsWritten = 0; + if (compilerOptions.emitDecoratorMetadata) { + if (shouldEmitTypeMetadata(node)) { + if (writeComma) { + write(", "); + } + writeLine(); + write("__metadata('design:type', "); + emitSerializedTypeOfNode(node); + write(")"); + argumentsWritten++; + } + if (shouldEmitParamTypesMetadata(node)) { + if (writeComma || argumentsWritten) { + write(", "); + } + writeLine(); + write("__metadata('design:paramtypes', ["); + emitSerializedParameterTypesOfNode(node); + write("])"); + argumentsWritten++; + } + if (shouldEmitReturnTypeMetadata(node)) { + if (writeComma || argumentsWritten) { + write(", "); + } + writeLine(); + write("__metadata('design:returntype', "); + emitSerializedReturnTypeOfNode(node); + write(")"); + argumentsWritten++; + } + } + return argumentsWritten; + } + function emitInterfaceDeclaration(node) { + emitCommentsOnNotEmittedNode(node); + } + function shouldEmitEnumDeclaration(node) { + var isConstEnum = ts.isConst(node); + return !isConstEnum || compilerOptions.preserveConstEnums || compilerOptions.isolatedModules; + } + function emitEnumDeclaration(node) { + // const enums are completely erased during compilation. + if (!shouldEmitEnumDeclaration(node)) { + return; + } + if (!shouldHoistDeclarationInSystemJsModule(node)) { + // do not emit var if variable was already hoisted + if (!(node.flags & 1 /* Export */) || isES6ExportedDeclaration(node)) { + emitStart(node); + if (isES6ExportedDeclaration(node)) { + write("export "); + } + write("var "); + emit(node.name); + emitEnd(node); + write(";"); + } + } + writeLine(); + emitStart(node); + write("(function ("); + emitStart(node.name); + write(getGeneratedNameForNode(node)); + emitEnd(node.name); + write(") {"); + increaseIndent(); + scopeEmitStart(node); + emitLines(node.members); + decreaseIndent(); + writeLine(); + emitToken(16 /* CloseBraceToken */, node.members.end); + scopeEmitEnd(); + write(")("); + emitModuleMemberName(node); + write(" || ("); + emitModuleMemberName(node); + write(" = {}));"); + emitEnd(node); + if (!isES6ExportedDeclaration(node) && node.flags & 1 /* Export */ && !shouldHoistDeclarationInSystemJsModule(node)) { + // do not emit var if variable was already hoisted + writeLine(); + emitStart(node); + write("var "); + emit(node.name); + write(" = "); + emitModuleMemberName(node); + emitEnd(node); + write(";"); + } + if (modulekind !== 5 /* ES6 */ && node.parent === currentSourceFile) { + if (modulekind === 4 /* System */ && (node.flags & 1 /* Export */)) { + // write the call to exporter for enum + writeLine(); + write(exportFunctionForFile + "(\""); + emitDeclarationName(node); + write("\", "); + emitDeclarationName(node); + write(");"); + } + emitExportMemberAssignments(node.name); + } + } + function emitEnumMember(node) { + var enumParent = node.parent; + emitStart(node); + write(getGeneratedNameForNode(enumParent)); + write("["); + write(getGeneratedNameForNode(enumParent)); + write("["); + emitExpressionForPropertyName(node.name); + write("] = "); + writeEnumMemberDeclarationValue(node); + write("] = "); + emitExpressionForPropertyName(node.name); + emitEnd(node); + write(";"); + } + function writeEnumMemberDeclarationValue(member) { + var value = resolver.getConstantValue(member); + if (value !== undefined) { + write(value.toString()); + return; + } + else if (member.initializer) { + emit(member.initializer); + } + else { + write("undefined"); + } + } + function getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration) { + if (moduleDeclaration.body.kind === 218 /* ModuleDeclaration */) { + var recursiveInnerModule = getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration.body); + return recursiveInnerModule || moduleDeclaration.body; + } + } + function shouldEmitModuleDeclaration(node) { + return ts.isInstantiatedModule(node, compilerOptions.preserveConstEnums || compilerOptions.isolatedModules); + } + function isModuleMergedWithES6Class(node) { + return languageVersion === 2 /* ES6 */ && !!(resolver.getNodeCheckFlags(node) & 32768 /* LexicalModuleMergesWithClass */); + } + function emitModuleDeclaration(node) { + // Emit only if this module is non-ambient. + var shouldEmit = shouldEmitModuleDeclaration(node); + if (!shouldEmit) { + return emitCommentsOnNotEmittedNode(node); + } + var hoistedInDeclarationScope = shouldHoistDeclarationInSystemJsModule(node); + var emitVarForModule = !hoistedInDeclarationScope && !isModuleMergedWithES6Class(node); + if (emitVarForModule) { + emitStart(node); + if (isES6ExportedDeclaration(node)) { + write("export "); + } + write("var "); + emit(node.name); + write(";"); + emitEnd(node); + writeLine(); + } + emitStart(node); + write("(function ("); + emitStart(node.name); + write(getGeneratedNameForNode(node)); + emitEnd(node.name); + write(") "); + if (node.body.kind === 219 /* ModuleBlock */) { + var saveConvertedLoopState = convertedLoopState; + var saveTempFlags = tempFlags; + var saveTempVariables = tempVariables; + convertedLoopState = undefined; + tempFlags = 0; + tempVariables = undefined; + emit(node.body); + ts.Debug.assert(convertedLoopState === undefined); + convertedLoopState = saveConvertedLoopState; + tempFlags = saveTempFlags; + tempVariables = saveTempVariables; + } + else { + write("{"); + increaseIndent(); + scopeEmitStart(node); + emitCaptureThisForNodeIfNecessary(node); + writeLine(); + emit(node.body); + decreaseIndent(); + writeLine(); + var moduleBlock = getInnerMostModuleDeclarationFromDottedModule(node).body; + emitToken(16 /* CloseBraceToken */, moduleBlock.statements.end); + scopeEmitEnd(); + } + write(")("); + // write moduleDecl = containingModule.m only if it is not exported es6 module member + if ((node.flags & 1 /* Export */) && !isES6ExportedDeclaration(node)) { + emit(node.name); + write(" = "); + } + emitModuleMemberName(node); + write(" || ("); + emitModuleMemberName(node); + write(" = {}));"); + emitEnd(node); + if (!isES6ExportedDeclaration(node) && node.name.kind === 69 /* Identifier */ && node.parent === currentSourceFile) { + if (modulekind === 4 /* System */ && (node.flags & 1 /* Export */)) { + writeLine(); + write(exportFunctionForFile + "(\""); + emitDeclarationName(node); + write("\", "); + emitDeclarationName(node); + write(");"); + } + emitExportMemberAssignments(node.name); + } + } + /* + * Some bundlers (SystemJS builder) sometimes want to rename dependencies. + * Here we check if alternative name was provided for a given moduleName and return it if possible. + */ + function tryRenameExternalModule(moduleName) { + if (currentSourceFile.renamedDependencies && ts.hasProperty(currentSourceFile.renamedDependencies, moduleName.text)) { + return "\"" + currentSourceFile.renamedDependencies[moduleName.text] + "\""; + } + return undefined; + } + function emitRequire(moduleName) { + if (moduleName.kind === 9 /* StringLiteral */) { + write("require("); + var text = tryRenameExternalModule(moduleName); + if (text) { + write(text); + } + else { + emitStart(moduleName); + emitLiteral(moduleName); + emitEnd(moduleName); + } + emitToken(18 /* CloseParenToken */, moduleName.end); + } + else { + write("require()"); + } + } + function getNamespaceDeclarationNode(node) { + if (node.kind === 221 /* ImportEqualsDeclaration */) { + return node; + } + var importClause = node.importClause; + if (importClause && importClause.namedBindings && importClause.namedBindings.kind === 224 /* NamespaceImport */) { + return importClause.namedBindings; + } + } + function isDefaultImport(node) { + return node.kind === 222 /* ImportDeclaration */ && node.importClause && !!node.importClause.name; + } + function emitExportImportAssignments(node) { + if (ts.isAliasSymbolDeclaration(node) && resolver.isValueAliasDeclaration(node)) { + emitExportMemberAssignments(node.name); + } + ts.forEachChild(node, emitExportImportAssignments); + } + function emitImportDeclaration(node) { + if (modulekind !== 5 /* ES6 */) { + return emitExternalImportDeclaration(node); + } + // ES6 import + if (node.importClause) { + var shouldEmitDefaultBindings = resolver.isReferencedAliasDeclaration(node.importClause); + var shouldEmitNamedBindings = node.importClause.namedBindings && resolver.isReferencedAliasDeclaration(node.importClause.namedBindings, /* checkChildren */ true); + if (shouldEmitDefaultBindings || shouldEmitNamedBindings) { + write("import "); + emitStart(node.importClause); + if (shouldEmitDefaultBindings) { + emit(node.importClause.name); + if (shouldEmitNamedBindings) { + write(", "); + } + } + if (shouldEmitNamedBindings) { + emitLeadingComments(node.importClause.namedBindings); + emitStart(node.importClause.namedBindings); + if (node.importClause.namedBindings.kind === 224 /* NamespaceImport */) { + write("* as "); + emit(node.importClause.namedBindings.name); + } + else { + write("{ "); + emitExportOrImportSpecifierList(node.importClause.namedBindings.elements, resolver.isReferencedAliasDeclaration); + write(" }"); + } + emitEnd(node.importClause.namedBindings); + emitTrailingComments(node.importClause.namedBindings); + } + emitEnd(node.importClause); + write(" from "); + emit(node.moduleSpecifier); + write(";"); + } + } + else { + write("import "); + emit(node.moduleSpecifier); + write(";"); + } + } + function emitExternalImportDeclaration(node) { + if (ts.contains(externalImports, node)) { + var isExportedImport = node.kind === 221 /* ImportEqualsDeclaration */ && (node.flags & 1 /* Export */) !== 0; + var namespaceDeclaration = getNamespaceDeclarationNode(node); + if (modulekind !== 2 /* AMD */) { + emitLeadingComments(node); + emitStart(node); + if (namespaceDeclaration && !isDefaultImport(node)) { + // import x = require("foo") + // import * as x from "foo" + if (!isExportedImport) + write("var "); + emitModuleMemberName(namespaceDeclaration); + write(" = "); + } + else { + // import "foo" + // import x from "foo" + // import { x, y } from "foo" + // import d, * as x from "foo" + // import d, { x, y } from "foo" + var isNakedImport = 222 /* ImportDeclaration */ && !node.importClause; + if (!isNakedImport) { + write("var "); + write(getGeneratedNameForNode(node)); + write(" = "); + } + } + emitRequire(ts.getExternalModuleName(node)); + if (namespaceDeclaration && isDefaultImport(node)) { + // import d, * as x from "foo" + write(", "); + emitModuleMemberName(namespaceDeclaration); + write(" = "); + write(getGeneratedNameForNode(node)); + } + write(";"); + emitEnd(node); + emitExportImportAssignments(node); + emitTrailingComments(node); + } + else { + if (isExportedImport) { + emitModuleMemberName(namespaceDeclaration); + write(" = "); + emit(namespaceDeclaration.name); + write(";"); + } + else if (namespaceDeclaration && isDefaultImport(node)) { + // import d, * as x from "foo" + write("var "); + emitModuleMemberName(namespaceDeclaration); + write(" = "); + write(getGeneratedNameForNode(node)); + write(";"); + } + emitExportImportAssignments(node); + } + } + } + function emitImportEqualsDeclaration(node) { + if (ts.isExternalModuleImportEqualsDeclaration(node)) { + emitExternalImportDeclaration(node); + return; + } + // preserve old compiler's behavior: emit 'var' for import declaration (even if we do not consider them referenced) when + // - current file is not external module + // - import declaration is top level and target is value imported by entity name + if (resolver.isReferencedAliasDeclaration(node) || + (!ts.isExternalModule(currentSourceFile) && resolver.isTopLevelValueImportEqualsWithEntityName(node))) { + emitLeadingComments(node); + emitStart(node); + // variable declaration for import-equals declaration can be hoisted in system modules + // in this case 'var' should be omitted and emit should contain only initialization + var variableDeclarationIsHoisted = shouldHoistVariable(node, /*checkIfSourceFileLevelDecl*/ true); + // is it top level export import v = a.b.c in system module? + // if yes - it needs to be rewritten as exporter('v', v = a.b.c) + var isExported = isSourceFileLevelDeclarationInSystemJsModule(node, /*isExported*/ true); + if (!variableDeclarationIsHoisted) { + ts.Debug.assert(!isExported); + if (isES6ExportedDeclaration(node)) { + write("export "); + write("var "); + } + else if (!(node.flags & 1 /* Export */)) { + write("var "); + } + } + if (isExported) { + write(exportFunctionForFile + "(\""); + emitNodeWithoutSourceMap(node.name); + write("\", "); + } + emitModuleMemberName(node); + write(" = "); + emit(node.moduleReference); + if (isExported) { + write(")"); + } + write(";"); + emitEnd(node); + emitExportImportAssignments(node); + emitTrailingComments(node); + } + } + function emitExportDeclaration(node) { + ts.Debug.assert(modulekind !== 4 /* System */); + if (modulekind !== 5 /* ES6 */) { + if (node.moduleSpecifier && (!node.exportClause || resolver.isValueAliasDeclaration(node))) { + emitStart(node); + var generatedName = getGeneratedNameForNode(node); + if (node.exportClause) { + // export { x, y, ... } from "foo" + if (modulekind !== 2 /* AMD */) { + write("var "); + write(generatedName); + write(" = "); + emitRequire(ts.getExternalModuleName(node)); + write(";"); + } + for (var _a = 0, _b = node.exportClause.elements; _a < _b.length; _a++) { + var specifier = _b[_a]; + if (resolver.isValueAliasDeclaration(specifier)) { + writeLine(); + emitStart(specifier); + emitContainingModuleName(specifier); + write("."); + emitNodeWithCommentsAndWithoutSourcemap(specifier.name); + write(" = "); + write(generatedName); + write("."); + emitNodeWithCommentsAndWithoutSourcemap(specifier.propertyName || specifier.name); + write(";"); + emitEnd(specifier); + } + } + } + else { + // export * from "foo" + writeLine(); + write("__export("); + if (modulekind !== 2 /* AMD */) { + emitRequire(ts.getExternalModuleName(node)); + } + else { + write(generatedName); + } + write(");"); + } + emitEnd(node); + } + } + else { + if (!node.exportClause || resolver.isValueAliasDeclaration(node)) { + write("export "); + if (node.exportClause) { + // export { x, y, ... } + write("{ "); + emitExportOrImportSpecifierList(node.exportClause.elements, resolver.isValueAliasDeclaration); + write(" }"); + } + else { + write("*"); + } + if (node.moduleSpecifier) { + write(" from "); + emit(node.moduleSpecifier); + } + write(";"); + } + } + } + function emitExportOrImportSpecifierList(specifiers, shouldEmit) { + ts.Debug.assert(modulekind === 5 /* ES6 */); + var needsComma = false; + for (var _a = 0; _a < specifiers.length; _a++) { + var specifier = specifiers[_a]; + if (shouldEmit(specifier)) { + if (needsComma) { + write(", "); + } + if (specifier.propertyName) { + emit(specifier.propertyName); + write(" as "); + } + emit(specifier.name); + needsComma = true; + } + } + } + function emitExportAssignment(node) { + if (!node.isExportEquals && resolver.isValueAliasDeclaration(node)) { + if (modulekind === 5 /* ES6 */) { + writeLine(); + emitStart(node); + write("export default "); + var expression = node.expression; + emit(expression); + if (expression.kind !== 213 /* FunctionDeclaration */ && + expression.kind !== 214 /* ClassDeclaration */) { + write(";"); + } + emitEnd(node); + } + else { + writeLine(); + emitStart(node); + if (modulekind === 4 /* System */) { + write(exportFunctionForFile + "(\"default\","); + emit(node.expression); + write(")"); + } + else { + emitEs6ExportDefaultCompat(node); + emitContainingModuleName(node); + if (languageVersion === 0 /* ES3 */) { + write("[\"default\"] = "); + } + else { + write(".default = "); + } + emit(node.expression); + } + write(";"); + emitEnd(node); + } + } + } + function collectExternalModuleInfo(sourceFile) { + externalImports = []; + exportSpecifiers = {}; + exportEquals = undefined; + hasExportStars = false; + for (var _a = 0, _b = sourceFile.statements; _a < _b.length; _a++) { + var node = _b[_a]; + switch (node.kind) { + case 222 /* 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); + } + break; + case 221 /* ImportEqualsDeclaration */: + if (node.moduleReference.kind === 232 /* ExternalModuleReference */ && resolver.isReferencedAliasDeclaration(node)) { + // import x = require("mod") where x is referenced + externalImports.push(node); + } + break; + case 228 /* ExportDeclaration */: + if (node.moduleSpecifier) { + if (!node.exportClause) { + // export * from "mod" + externalImports.push(node); + hasExportStars = true; + } + else if (resolver.isValueAliasDeclaration(node)) { + // export { x, y } from "mod" where at least one export is a value symbol + externalImports.push(node); + } + } + else { + // export { x, y } + for (var _c = 0, _d = node.exportClause.elements; _c < _d.length; _c++) { + var specifier = _d[_c]; + var name_26 = (specifier.propertyName || specifier.name).text; + (exportSpecifiers[name_26] || (exportSpecifiers[name_26] = [])).push(specifier); + } + } + break; + case 227 /* ExportAssignment */: + if (node.isExportEquals && !exportEquals) { + // export = x + exportEquals = node; + } + break; + } + } + } + function emitExportStarHelper() { + if (hasExportStars) { + writeLine(); + write("function __export(m) {"); + increaseIndent(); + writeLine(); + write("for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];"); + decreaseIndent(); + writeLine(); + write("}"); + } + } + function getLocalNameForExternalImport(node) { + var namespaceDeclaration = getNamespaceDeclarationNode(node); + if (namespaceDeclaration && !isDefaultImport(node)) { + return ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, namespaceDeclaration.name); + } + if (node.kind === 222 /* ImportDeclaration */ && node.importClause) { + return getGeneratedNameForNode(node); + } + if (node.kind === 228 /* ExportDeclaration */ && node.moduleSpecifier) { + return getGeneratedNameForNode(node); + } + } + function getExternalModuleNameText(importNode) { + var moduleName = ts.getExternalModuleName(importNode); + if (moduleName.kind === 9 /* StringLiteral */) { + return tryRenameExternalModule(moduleName) || getLiteralText(moduleName); + } + return undefined; + } + function emitVariableDeclarationsForImports() { + if (externalImports.length === 0) { + return; + } + writeLine(); + var started = false; + for (var _a = 0; _a < externalImports.length; _a++) { + var importNode = externalImports[_a]; + // do not create variable declaration for exports and imports that lack import clause + var skipNode = importNode.kind === 228 /* ExportDeclaration */ || + (importNode.kind === 222 /* ImportDeclaration */ && !importNode.importClause); + if (skipNode) { + continue; + } + if (!started) { + write("var "); + started = true; + } + else { + write(", "); + } + write(getLocalNameForExternalImport(importNode)); + } + if (started) { + write(";"); + } + } + function emitLocalStorageForExportedNamesIfNecessary(exportedDeclarations) { + // 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. + if (!hasExportStars) { + // local names set is needed only in presence of star exports + return undefined; + } + // local names set should only be added if we have anything exported + if (!exportedDeclarations && 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 _a = 0; _a < externalImports.length; _a++) { + var externalImport = externalImports[_a]; + if (externalImport.kind === 228 /* ExportDeclaration */ && externalImport.exportClause) { + hasExportDeclarationWithExportClause = true; + break; + } + } + if (!hasExportDeclarationWithExportClause) { + // we still need to emit exportStar helper + return emitExportStarFunction(/*localNames*/ undefined); + } + } + var exportedNamesStorageRef = makeUniqueName("exportedNames"); + writeLine(); + write("var " + exportedNamesStorageRef + " = {"); + increaseIndent(); + var started = false; + if (exportedDeclarations) { + for (var i = 0; i < exportedDeclarations.length; ++i) { + // write name of exported declaration, i.e 'export var x...' + writeExportedName(exportedDeclarations[i]); + } + } + if (exportSpecifiers) { + for (var n in exportSpecifiers) { + for (var _b = 0, _c = exportSpecifiers[n]; _b < _c.length; _b++) { + var specifier = _c[_b]; + // write name of export specified, i.e. 'export {x}' + writeExportedName(specifier.name); + } + } + } + for (var _d = 0; _d < externalImports.length; _d++) { + var externalImport = externalImports[_d]; + if (externalImport.kind !== 228 /* ExportDeclaration */) { + continue; + } + var exportDecl = externalImport; + if (!exportDecl.exportClause) { + // export * from ... + continue; + } + for (var _e = 0, _f = exportDecl.exportClause.elements; _e < _f.length; _e++) { + var element = _f[_e]; + // write name of indirectly exported entry, i.e. 'export {x} from ...' + writeExportedName(element.name || element.propertyName); + } + } + decreaseIndent(); + writeLine(); + write("};"); + return emitExportStarFunction(exportedNamesStorageRef); + function emitExportStarFunction(localNames) { + var exportStarFunction = makeUniqueName("exportStar"); + writeLine(); + // define an export star helper function + write("function " + exportStarFunction + "(m) {"); + increaseIndent(); + writeLine(); + write("var exports = {};"); + writeLine(); + write("for(var n in m) {"); + increaseIndent(); + writeLine(); + write("if (n !== \"default\""); + if (localNames) { + write("&& !" + localNames + ".hasOwnProperty(n)"); + } + write(") exports[n] = m[n];"); + decreaseIndent(); + writeLine(); + write("}"); + writeLine(); + write(exportFunctionForFile + "(exports);"); + decreaseIndent(); + writeLine(); + write("}"); + return exportStarFunction; + } + function writeExportedName(node) { + // do not record default exports + // they are local to module and never overwritten (explicitly skipped) by star export + if (node.kind !== 69 /* Identifier */ && node.flags & 1024 /* Default */) { + return; + } + if (started) { + write(","); + } + else { + started = true; + } + writeLine(); + write("'"); + if (node.kind === 69 /* Identifier */) { + emitNodeWithCommentsAndWithoutSourcemap(node); + } + else { + emitDeclarationName(node); + } + write("': true"); + } + } + function processTopLevelVariableAndFunctionDeclarations(node) { + // per ES6 spec: + // 15.2.1.16.4 ModuleDeclarationInstantiation() Concrete Method + // - var declarations are initialized to undefined - 14.a.ii + // - function/generator declarations are instantiated - 16.a.iv + // this means that after module is instantiated but before its evaluation + // exported functions are already accessible at import sites + // in theory we should hoist only exported functions and its dependencies + // in practice to simplify things we'll hoist all source level functions and variable declaration + // including variables declarations for module and class declarations + var hoistedVars; + var hoistedFunctionDeclarations; + var exportedDeclarations; + visit(node); + if (hoistedVars) { + writeLine(); + write("var "); + var seen = {}; + for (var i = 0; i < hoistedVars.length; ++i) { + var local = hoistedVars[i]; + var name_27 = local.kind === 69 /* Identifier */ + ? local + : local.name; + if (name_27) { + // do not emit duplicate entries (in case of declaration merging) in the list of hoisted variables + var text = ts.unescapeIdentifier(name_27.text); + if (ts.hasProperty(seen, text)) { + continue; + } + else { + seen[text] = text; + } + } + if (i !== 0) { + write(", "); + } + if (local.kind === 214 /* ClassDeclaration */ || local.kind === 218 /* ModuleDeclaration */ || local.kind === 217 /* EnumDeclaration */) { + emitDeclarationName(local); + } + else { + emit(local); + } + var flags = ts.getCombinedNodeFlags(local.kind === 69 /* Identifier */ ? local.parent : local); + if (flags & 1 /* Export */) { + if (!exportedDeclarations) { + exportedDeclarations = []; + } + exportedDeclarations.push(local); + } + } + write(";"); + } + if (hoistedFunctionDeclarations) { + for (var _a = 0; _a < hoistedFunctionDeclarations.length; _a++) { + var f = hoistedFunctionDeclarations[_a]; + writeLine(); + emit(f); + if (f.flags & 1 /* Export */) { + if (!exportedDeclarations) { + exportedDeclarations = []; + } + exportedDeclarations.push(f); + } + } + } + return exportedDeclarations; + function visit(node) { + if (node.flags & 2 /* Ambient */) { + return; + } + if (node.kind === 213 /* FunctionDeclaration */) { + if (!hoistedFunctionDeclarations) { + hoistedFunctionDeclarations = []; + } + hoistedFunctionDeclarations.push(node); + return; + } + if (node.kind === 214 /* ClassDeclaration */) { + if (!hoistedVars) { + hoistedVars = []; + } + hoistedVars.push(node); + return; + } + if (node.kind === 217 /* EnumDeclaration */) { + if (shouldEmitEnumDeclaration(node)) { + if (!hoistedVars) { + hoistedVars = []; + } + hoistedVars.push(node); + } + return; + } + if (node.kind === 218 /* ModuleDeclaration */) { + if (shouldEmitModuleDeclaration(node)) { + if (!hoistedVars) { + hoistedVars = []; + } + hoistedVars.push(node); + } + return; + } + if (node.kind === 211 /* VariableDeclaration */ || node.kind === 163 /* BindingElement */) { + if (shouldHoistVariable(node, /*checkIfSourceFileLevelDecl*/ false)) { + var name_28 = node.name; + if (name_28.kind === 69 /* Identifier */) { + if (!hoistedVars) { + hoistedVars = []; + } + hoistedVars.push(name_28); + } + else { + ts.forEachChild(name_28, visit); + } + } + return; + } + if (ts.isInternalModuleImportEqualsDeclaration(node) && resolver.isValueAliasDeclaration(node)) { + if (!hoistedVars) { + hoistedVars = []; + } + hoistedVars.push(node.name); + return; + } + if (ts.isBindingPattern(node)) { + ts.forEach(node.elements, visit); + return; + } + if (!ts.isDeclaration(node)) { + ts.forEachChild(node, visit); + } + } + } + function shouldHoistVariable(node, checkIfSourceFileLevelDecl) { + if (checkIfSourceFileLevelDecl && !shouldHoistDeclarationInSystemJsModule(node)) { + return false; + } + // hoist variable if + // - it is not block scoped + // - it is top level block scoped + // if block scoped variables are nested in some another block then + // no other functions can use them except ones that are defined at least in the same block + return (ts.getCombinedNodeFlags(node) & 49152 /* BlockScoped */) === 0 || + ts.getEnclosingBlockScopeContainer(node).kind === 248 /* SourceFile */; + } + function isCurrentFileSystemExternalModule() { + return modulekind === 4 /* System */ && ts.isExternalModule(currentSourceFile); + } + function emitSystemModuleBody(node, dependencyGroups, startIndex) { + // 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 file1; // local alias + // var y; + // function foo() { return y + file1.x(); } + // exports("foo", foo); + // return { + // setters: [ + // function(v) { file1 = v } + // ], + // execute(): function() { + // y = 1; + // console.log(y); + // } + // }; + // } + emitVariableDeclarationsForImports(); + writeLine(); + var exportedDeclarations = processTopLevelVariableAndFunctionDeclarations(node); + var exportStarFunction = emitLocalStorageForExportedNamesIfNecessary(exportedDeclarations); + writeLine(); + write("return {"); + increaseIndent(); + writeLine(); + emitSetters(exportStarFunction, dependencyGroups); + writeLine(); + emitExecute(node, startIndex); + decreaseIndent(); + writeLine(); + write("}"); // return + emitTempDeclarations(/*newLine*/ true); + } + function emitSetters(exportStarFunction, dependencyGroups) { + write("setters:["); + for (var i = 0; i < dependencyGroups.length; ++i) { + if (i !== 0) { + write(","); + } + writeLine(); + increaseIndent(); + var group = dependencyGroups[i]; + // derive a unique name for parameter from the first named entry in the group + var parameterName = makeUniqueName(ts.forEach(group, getLocalNameForExternalImport) || ""); + write("function (" + parameterName + ") {"); + increaseIndent(); + for (var _a = 0; _a < group.length; _a++) { + var entry = group[_a]; + var importVariableName = getLocalNameForExternalImport(entry) || ""; + switch (entry.kind) { + case 222 /* ImportDeclaration */: + if (!entry.importClause) { + // 'import "..."' case + // module is imported only for side-effects, no emit required + break; + } + // fall-through + case 221 /* ImportEqualsDeclaration */: + ts.Debug.assert(importVariableName !== ""); + writeLine(); + // save import into the local + write(importVariableName + " = " + parameterName + ";"); + writeLine(); + break; + case 228 /* ExportDeclaration */: + ts.Debug.assert(importVariableName !== ""); + if (entry.exportClause) { + // export {a, b as c} from 'foo' + // emit as: + // exports_({ + // "a": _["a"], + // "c": _["b"] + // }); + writeLine(); + write(exportFunctionForFile + "({"); + writeLine(); + increaseIndent(); + for (var i_2 = 0, len = entry.exportClause.elements.length; i_2 < len; ++i_2) { + if (i_2 !== 0) { + write(","); + writeLine(); + } + var e = entry.exportClause.elements[i_2]; + write("\""); + emitNodeWithCommentsAndWithoutSourcemap(e.name); + write("\": " + parameterName + "[\""); + emitNodeWithCommentsAndWithoutSourcemap(e.propertyName || e.name); + write("\"]"); + } + decreaseIndent(); + writeLine(); + write("});"); + } + else { + writeLine(); + // export * from 'foo' + // emit as: + // exportStar(_foo); + write(exportStarFunction + "(" + parameterName + ");"); + } + writeLine(); + break; + } + } + decreaseIndent(); + write("}"); + decreaseIndent(); + } + write("],"); + } + function emitExecute(node, startIndex) { + write("execute: function() {"); + increaseIndent(); + writeLine(); + for (var i = startIndex; i < node.statements.length; ++i) { + var statement = node.statements[i]; + switch (statement.kind) { + // - function declarations are not emitted because they were already hoisted + // - import declarations are not emitted since they are already handled in setters + // - export declarations with module specifiers are not emitted since they were already written in setters + // - export declarations without module specifiers are emitted preserving the order + case 213 /* FunctionDeclaration */: + case 222 /* ImportDeclaration */: + continue; + case 228 /* ExportDeclaration */: + if (!statement.moduleSpecifier) { + for (var _a = 0, _b = statement.exportClause.elements; _a < _b.length; _a++) { + var element = _b[_a]; + // write call to exporter function for every export specifier in exports list + emitExportSpecifierInSystemModule(element); + } + } + continue; + case 221 /* ImportEqualsDeclaration */: + if (!ts.isInternalModuleImportEqualsDeclaration(statement)) { + // - import equals declarations that import external modules are not emitted + continue; + } + // fall-though for import declarations that import internal modules + default: + writeLine(); + emit(statement); + } + } + decreaseIndent(); + writeLine(); + write("}"); // execute + } + function emitSystemModule(node) { + collectExternalModuleInfo(node); + // System modules has the following shape + // System.register(['dep-1', ... 'dep-n'], function(exports) {/* module body function */}) + // 'exports' here is a function 'exports(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 'emitPostfixUnaryExpression' for more details + ts.Debug.assert(!exportFunctionForFile); + // make sure that name of 'exports' function does not conflict with existing identifiers + exportFunctionForFile = makeUniqueName("exports"); + writeLine(); + write("System.register("); + if (node.moduleName) { + write("\"" + node.moduleName + "\", "); + } + write("["); + var groupIndices = {}; + var dependencyGroups = []; + for (var i = 0; i < externalImports.length; ++i) { + var text = getExternalModuleNameText(externalImports[i]); + if (ts.hasProperty(groupIndices, text)) { + // deduplicate/group entries in dependency list by the dependency name + var groupIndex = groupIndices[text]; + dependencyGroups[groupIndex].push(externalImports[i]); + continue; + } + else { + groupIndices[text] = dependencyGroups.length; + dependencyGroups.push([externalImports[i]]); + } + if (i !== 0) { + write(", "); + } + write(text); + } + write("], function(" + exportFunctionForFile + ") {"); + writeLine(); + increaseIndent(); + var startIndex = emitDirectivePrologues(node.statements, /*startWithNewLine*/ true); + emitEmitHelpers(node); + emitCaptureThisForNodeIfNecessary(node); + emitSystemModuleBody(node, dependencyGroups, startIndex); + decreaseIndent(); + writeLine(); + write("});"); + } + function getAMDDependencyNames(node, includeNonAmdDependencies) { + // names of modules with corresponding parameter in the factory function + var aliasedModuleNames = []; + // names of modules with no corresponding parameters in factory function + var unaliasedModuleNames = []; + var importAliasNames = []; // names of the parameters in the factory function; these + // parameters need to match the indexes of the corresponding + // module names in aliasedModuleNames. + // Fill in amd-dependency tags + for (var _a = 0, _b = node.amdDependencies; _a < _b.length; _a++) { + var amdDependency = _b[_a]; + if (amdDependency.name) { + aliasedModuleNames.push("\"" + amdDependency.path + "\""); + importAliasNames.push(amdDependency.name); + } + else { + unaliasedModuleNames.push("\"" + amdDependency.path + "\""); + } + } + for (var _c = 0; _c < externalImports.length; _c++) { + var importNode = externalImports[_c]; + // Find the name of the external module + var externalModuleName = getExternalModuleNameText(importNode); + // Find the name of the module alias, if there is one + var importAliasName = getLocalNameForExternalImport(importNode); + if (includeNonAmdDependencies && importAliasName) { + aliasedModuleNames.push(externalModuleName); + importAliasNames.push(importAliasName); + } + else { + unaliasedModuleNames.push(externalModuleName); + } + } + return { aliasedModuleNames: aliasedModuleNames, unaliasedModuleNames: unaliasedModuleNames, importAliasNames: importAliasNames }; + } + function emitAMDDependencies(node, includeNonAmdDependencies) { + // An AMD define function has the following shape: + // define(id?, dependencies?, factory); + // + // This has the shape of + // define(name, ["module1", "module2"], function (module1Alias) { + // The location of the alias in the parameter list in the factory function needs to + // match the position of the module name in the dependency list. + // + // To ensure this is true in cases of modules with no aliases, e.g.: + // `import "module"` or `` + // we need to add modules without alias names to the end of the dependencies list + var dependencyNames = getAMDDependencyNames(node, includeNonAmdDependencies); + emitAMDDependencyList(dependencyNames); + write(", "); + emitAMDFactoryHeader(dependencyNames); + } + function emitAMDDependencyList(_a) { + var aliasedModuleNames = _a.aliasedModuleNames, unaliasedModuleNames = _a.unaliasedModuleNames; + write("[\"require\", \"exports\""); + if (aliasedModuleNames.length) { + write(", "); + write(aliasedModuleNames.join(", ")); + } + if (unaliasedModuleNames.length) { + write(", "); + write(unaliasedModuleNames.join(", ")); + } + write("]"); + } + function emitAMDFactoryHeader(_a) { + var importAliasNames = _a.importAliasNames; + write("function (require, exports"); + if (importAliasNames.length) { + write(", "); + write(importAliasNames.join(", ")); + } + write(") {"); + } + function emitAMDModule(node) { + emitEmitHelpers(node); + collectExternalModuleInfo(node); + writeLine(); + write("define("); + if (node.moduleName) { + write("\"" + node.moduleName + "\", "); + } + emitAMDDependencies(node, /*includeNonAmdDependencies*/ true); + increaseIndent(); + var startIndex = emitDirectivePrologues(node.statements, /*startWithNewLine*/ true); + emitExportStarHelper(); + emitCaptureThisForNodeIfNecessary(node); + emitLinesStartingAt(node.statements, startIndex); + emitTempDeclarations(/*newLine*/ true); + emitExportEquals(/*emitAsReturn*/ true); + decreaseIndent(); + writeLine(); + write("});"); + } + function emitCommonJSModule(node) { + var startIndex = emitDirectivePrologues(node.statements, /*startWithNewLine*/ false); + emitEmitHelpers(node); + collectExternalModuleInfo(node); + emitExportStarHelper(); + emitCaptureThisForNodeIfNecessary(node); + emitLinesStartingAt(node.statements, startIndex); + emitTempDeclarations(/*newLine*/ true); + emitExportEquals(/*emitAsReturn*/ false); + } + function emitUMDModule(node) { + emitEmitHelpers(node); + collectExternalModuleInfo(node); + var dependencyNames = getAMDDependencyNames(node, /*includeNonAmdDependencies*/ false); + // Module is detected first to support Browserify users that load into a browser with an AMD loader + writeLines("(function (factory) {\n if (typeof module === 'object' && typeof module.exports === 'object') {\n var v = factory(require, exports); if (v !== undefined) module.exports = v;\n }\n else if (typeof define === 'function' && define.amd) {\n define("); + emitAMDDependencyList(dependencyNames); + write(", factory);"); + writeLines(" }\n})("); + emitAMDFactoryHeader(dependencyNames); + increaseIndent(); + var startIndex = emitDirectivePrologues(node.statements, /*startWithNewLine*/ true); + emitExportStarHelper(); + emitCaptureThisForNodeIfNecessary(node); + emitLinesStartingAt(node.statements, startIndex); + emitTempDeclarations(/*newLine*/ true); + emitExportEquals(/*emitAsReturn*/ true); + decreaseIndent(); + writeLine(); + write("});"); + } + function emitES6Module(node) { + externalImports = undefined; + exportSpecifiers = undefined; + exportEquals = undefined; + hasExportStars = false; + var startIndex = emitDirectivePrologues(node.statements, /*startWithNewLine*/ false); + emitEmitHelpers(node); + emitCaptureThisForNodeIfNecessary(node); + emitLinesStartingAt(node.statements, startIndex); + emitTempDeclarations(/*newLine*/ true); + // Emit exportDefault if it exists will happen as part + // or normal statement emit. + } + function emitExportEquals(emitAsReturn) { + if (exportEquals && resolver.isValueAliasDeclaration(exportEquals)) { + writeLine(); + emitStart(exportEquals); + write(emitAsReturn ? "return " : "module.exports = "); + emit(exportEquals.expression); + write(";"); + emitEnd(exportEquals); + } + } + function emitJsxElement(node) { + switch (compilerOptions.jsx) { + case 2 /* React */: + jsxEmitReact(node); + break; + case 1 /* Preserve */: + // Fall back to preserve if None was specified (we'll error earlier) + default: + jsxEmitPreserve(node); + break; + } + } + function trimReactWhitespaceAndApplyEntities(node) { + var result = undefined; + var text = ts.getTextOfNode(node, /*includeTrivia*/ true); + var firstNonWhitespace = 0; + var lastNonWhitespace = -1; + // JSX trims whitespace at the end and beginning of lines, except that the + // start/end of a tag is considered a start/end of a line only if that line is + // on the same line as the closing tag. See examples in tests/cases/conformance/jsx/tsxReactEmitWhitespace.tsx + for (var i = 0; i < text.length; i++) { + var c = text.charCodeAt(i); + if (ts.isLineBreak(c)) { + if (firstNonWhitespace !== -1 && (lastNonWhitespace - firstNonWhitespace + 1 > 0)) { + var part = text.substr(firstNonWhitespace, lastNonWhitespace - firstNonWhitespace + 1); + result = (result ? result + "\" + ' ' + \"" : "") + ts.escapeString(part); + } + firstNonWhitespace = -1; + } + else if (!ts.isWhiteSpace(c)) { + lastNonWhitespace = i; + if (firstNonWhitespace === -1) { + firstNonWhitespace = i; + } + } + } + if (firstNonWhitespace !== -1) { + var part = text.substr(firstNonWhitespace); + result = (result ? result + "\" + ' ' + \"" : "") + ts.escapeString(part); + } + if (result) { + // Replace entities like   + result = result.replace(/&(\w+);/g, function (s, m) { + if (entities[m] !== undefined) { + return String.fromCharCode(entities[m]); + } + else { + return s; + } + }); + } + return result; + } + function getTextToEmit(node) { + switch (compilerOptions.jsx) { + case 2 /* React */: + var text = trimReactWhitespaceAndApplyEntities(node); + if (text === undefined || text.length === 0) { + return undefined; + } + else { + return text; + } + case 1 /* Preserve */: + default: + return ts.getTextOfNode(node, /*includeTrivia*/ true); + } + } + function emitJsxText(node) { + switch (compilerOptions.jsx) { + case 2 /* React */: + write("\""); + write(trimReactWhitespaceAndApplyEntities(node)); + write("\""); + break; + case 1 /* Preserve */: + default: + writer.writeLiteral(ts.getTextOfNode(node, /*includeTrivia*/ true)); + break; + } + } + function emitJsxExpression(node) { + if (node.expression) { + switch (compilerOptions.jsx) { + case 1 /* Preserve */: + default: + write("{"); + emit(node.expression); + write("}"); + break; + case 2 /* React */: + emit(node.expression); + break; + } + } + } + function emitDirectivePrologues(statements, startWithNewLine) { + for (var i = 0; i < statements.length; ++i) { + if (ts.isPrologueDirective(statements[i])) { + if (startWithNewLine || i > 0) { + writeLine(); + } + emit(statements[i]); + } + else { + // return index of the first non prologue directive + return i; + } + } + return statements.length; + } + function writeLines(text) { + var lines = text.split(/\r\n|\r|\n/g); + for (var i = 0; i < lines.length; ++i) { + var line = lines[i]; + if (line.length) { + writeLine(); + write(line); + } + } + } + function emitEmitHelpers(node) { + // Only emit helpers if the user did not say otherwise. + if (!compilerOptions.noEmitHelpers) { + // Only Emit __extends function when target ES5. + // For target ES6 and above, we can emit classDeclaration as is. + if ((languageVersion < 2 /* ES6 */) && (!extendsEmitted && resolver.getNodeCheckFlags(node) & 8 /* EmitExtends */)) { + writeLines(extendsHelper); + extendsEmitted = true; + } + if (!decorateEmitted && resolver.getNodeCheckFlags(node) & 16 /* EmitDecorate */) { + writeLines(decorateHelper); + if (compilerOptions.emitDecoratorMetadata) { + writeLines(metadataHelper); + } + decorateEmitted = true; + } + if (!paramEmitted && resolver.getNodeCheckFlags(node) & 32 /* EmitParam */) { + writeLines(paramHelper); + paramEmitted = true; + } + if (!awaiterEmitted && resolver.getNodeCheckFlags(node) & 64 /* EmitAwaiter */) { + writeLines(awaiterHelper); + awaiterEmitted = true; + } + } + } + function emitSourceFileNode(node) { + // Start new file on new line + writeLine(); + emitShebang(); + emitDetachedComments(node); + if (ts.isExternalModule(node) || compilerOptions.isolatedModules) { + var emitModule = moduleEmitDelegates[modulekind] || moduleEmitDelegates[1 /* CommonJS */]; + emitModule(node); + } + else { + // emit prologue directives prior to __extends + var startIndex = emitDirectivePrologues(node.statements, /*startWithNewLine*/ false); + externalImports = undefined; + exportSpecifiers = undefined; + exportEquals = undefined; + hasExportStars = false; + emitEmitHelpers(node); + emitCaptureThisForNodeIfNecessary(node); + emitLinesStartingAt(node.statements, startIndex); + emitTempDeclarations(/*newLine*/ true); + } + emitLeadingComments(node.endOfFileToken); + } + function emitNodeWithCommentsAndWithoutSourcemap(node) { + emitNodeConsideringCommentsOption(node, emitNodeWithoutSourceMap); + } + function emitNodeConsideringCommentsOption(node, emitNodeConsideringSourcemap) { + if (node) { + if (node.flags & 2 /* Ambient */) { + return emitCommentsOnNotEmittedNode(node); + } + if (isSpecializedCommentHandling(node)) { + // This is the node that will handle its own comments and sourcemap + return emitNodeWithoutSourceMap(node); + } + var emitComments_1 = shouldEmitLeadingAndTrailingComments(node); + if (emitComments_1) { + emitLeadingComments(node); + } + emitNodeConsideringSourcemap(node); + if (emitComments_1) { + emitTrailingComments(node); + } + } + } + function emitNodeWithoutSourceMap(node) { + if (node) { + emitJavaScriptWorker(node); + } + } + function isSpecializedCommentHandling(node) { + switch (node.kind) { + // All of these entities are emitted in a specialized fashion. As such, we allow + // the specialized methods for each to handle the comments on the nodes. + case 215 /* InterfaceDeclaration */: + case 213 /* FunctionDeclaration */: + case 222 /* ImportDeclaration */: + case 221 /* ImportEqualsDeclaration */: + case 216 /* TypeAliasDeclaration */: + case 227 /* ExportAssignment */: + return true; + } + } + function shouldEmitLeadingAndTrailingComments(node) { + switch (node.kind) { + case 193 /* VariableStatement */: + return shouldEmitLeadingAndTrailingCommentsForVariableStatement(node); + case 218 /* ModuleDeclaration */: + // Only emit the leading/trailing comments for a module if we're actually + // emitting the module as well. + return shouldEmitModuleDeclaration(node); + case 217 /* EnumDeclaration */: + // Only emit the leading/trailing comments for an enum if we're actually + // emitting the module as well. + return shouldEmitEnumDeclaration(node); + } + // If the node is emitted in specialized fashion, dont emit comments as this node will handle + // emitting comments when emitting itself + ts.Debug.assert(!isSpecializedCommentHandling(node)); + // If this is the expression body of an arrow function that we're down-leveling, + // then we don't want to emit comments when we emit the body. It will have already + // been taken care of when we emitted the 'return' statement for the function + // expression body. + if (node.kind !== 192 /* Block */ && + node.parent && + node.parent.kind === 174 /* ArrowFunction */ && + node.parent.body === node && + compilerOptions.target <= 1 /* ES5 */) { + return false; + } + // Emit comments for everything else. + return true; + } + function emitJavaScriptWorker(node) { + // Check if the node can be emitted regardless of the ScriptTarget + switch (node.kind) { + case 69 /* Identifier */: + return emitIdentifier(node); + case 138 /* Parameter */: + return emitParameter(node); + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: + return emitMethod(node); + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: + return emitAccessor(node); + case 97 /* ThisKeyword */: + return emitThis(node); + case 95 /* SuperKeyword */: + return emitSuper(node); + case 93 /* NullKeyword */: + return write("null"); + case 99 /* TrueKeyword */: + return write("true"); + case 84 /* FalseKeyword */: + return write("false"); + case 8 /* NumericLiteral */: + case 9 /* StringLiteral */: + case 10 /* RegularExpressionLiteral */: + case 11 /* NoSubstitutionTemplateLiteral */: + case 12 /* TemplateHead */: + case 13 /* TemplateMiddle */: + case 14 /* TemplateTail */: + return emitLiteral(node); + case 183 /* TemplateExpression */: + return emitTemplateExpression(node); + case 190 /* TemplateSpan */: + return emitTemplateSpan(node); + case 233 /* JsxElement */: + case 234 /* JsxSelfClosingElement */: + return emitJsxElement(node); + case 236 /* JsxText */: + return emitJsxText(node); + case 240 /* JsxExpression */: + return emitJsxExpression(node); + case 135 /* QualifiedName */: + return emitQualifiedName(node); + case 161 /* ObjectBindingPattern */: + return emitObjectBindingPattern(node); + case 162 /* ArrayBindingPattern */: + return emitArrayBindingPattern(node); + case 163 /* BindingElement */: + return emitBindingElement(node); + case 164 /* ArrayLiteralExpression */: + return emitArrayLiteral(node); + case 165 /* ObjectLiteralExpression */: + return emitObjectLiteral(node); + case 245 /* PropertyAssignment */: + return emitPropertyAssignment(node); + case 246 /* ShorthandPropertyAssignment */: + return emitShorthandPropertyAssignment(node); + case 136 /* ComputedPropertyName */: + return emitComputedPropertyName(node); + case 166 /* PropertyAccessExpression */: + return emitPropertyAccess(node); + case 167 /* ElementAccessExpression */: + return emitIndexedAccess(node); + case 168 /* CallExpression */: + return emitCallExpression(node); + case 169 /* NewExpression */: + return emitNewExpression(node); + case 170 /* TaggedTemplateExpression */: + return emitTaggedTemplateExpression(node); + case 171 /* TypeAssertionExpression */: + return emit(node.expression); + case 189 /* AsExpression */: + return emit(node.expression); + case 172 /* ParenthesizedExpression */: + return emitParenExpression(node); + case 213 /* FunctionDeclaration */: + case 173 /* FunctionExpression */: + case 174 /* ArrowFunction */: + return emitFunctionDeclaration(node); + case 175 /* DeleteExpression */: + return emitDeleteExpression(node); + case 176 /* TypeOfExpression */: + return emitTypeOfExpression(node); + case 177 /* VoidExpression */: + return emitVoidExpression(node); + case 178 /* AwaitExpression */: + return emitAwaitExpression(node); + case 179 /* PrefixUnaryExpression */: + return emitPrefixUnaryExpression(node); + case 180 /* PostfixUnaryExpression */: + return emitPostfixUnaryExpression(node); + case 181 /* BinaryExpression */: + return emitBinaryExpression(node); + case 182 /* ConditionalExpression */: + return emitConditionalExpression(node); + case 185 /* SpreadElementExpression */: + return emitSpreadElementExpression(node); + case 184 /* YieldExpression */: + return emitYieldExpression(node); + case 187 /* OmittedExpression */: + return; + case 192 /* Block */: + case 219 /* ModuleBlock */: + return emitBlock(node); + case 193 /* VariableStatement */: + return emitVariableStatement(node); + case 194 /* EmptyStatement */: + return write(";"); + case 195 /* ExpressionStatement */: + return emitExpressionStatement(node); + case 196 /* IfStatement */: + return emitIfStatement(node); + case 197 /* DoStatement */: + return emitDoStatement(node); + case 198 /* WhileStatement */: + return emitWhileStatement(node); + case 199 /* ForStatement */: + return emitForStatement(node); + case 201 /* ForOfStatement */: + case 200 /* ForInStatement */: + return emitForInOrForOfStatement(node); + case 202 /* ContinueStatement */: + case 203 /* BreakStatement */: + return emitBreakOrContinueStatement(node); + case 204 /* ReturnStatement */: + return emitReturnStatement(node); + case 205 /* WithStatement */: + return emitWithStatement(node); + case 206 /* SwitchStatement */: + return emitSwitchStatement(node); + case 241 /* CaseClause */: + case 242 /* DefaultClause */: + return emitCaseOrDefaultClause(node); + case 207 /* LabeledStatement */: + return emitLabeledStatement(node); + case 208 /* ThrowStatement */: + return emitThrowStatement(node); + case 209 /* TryStatement */: + return emitTryStatement(node); + case 244 /* CatchClause */: + return emitCatchClause(node); + case 210 /* DebuggerStatement */: + return emitDebuggerStatement(node); + case 211 /* VariableDeclaration */: + return emitVariableDeclaration(node); + case 186 /* ClassExpression */: + return emitClassExpression(node); + case 214 /* ClassDeclaration */: + return emitClassDeclaration(node); + case 215 /* InterfaceDeclaration */: + return emitInterfaceDeclaration(node); + case 217 /* EnumDeclaration */: + return emitEnumDeclaration(node); + case 247 /* EnumMember */: + return emitEnumMember(node); + case 218 /* ModuleDeclaration */: + return emitModuleDeclaration(node); + case 222 /* ImportDeclaration */: + return emitImportDeclaration(node); + case 221 /* ImportEqualsDeclaration */: + return emitImportEqualsDeclaration(node); + case 228 /* ExportDeclaration */: + return emitExportDeclaration(node); + case 227 /* ExportAssignment */: + return emitExportAssignment(node); + case 248 /* SourceFile */: + return emitSourceFileNode(node); + } + } + function hasDetachedComments(pos) { + return detachedCommentsInfo !== undefined && ts.lastOrUndefined(detachedCommentsInfo).nodePos === pos; + } + function getLeadingCommentsWithoutDetachedComments() { + // get the leading comments from detachedPos + var leadingComments = ts.getLeadingCommentRanges(currentSourceFile.text, ts.lastOrUndefined(detachedCommentsInfo).detachedCommentEndPos); + if (detachedCommentsInfo.length - 1) { + detachedCommentsInfo.pop(); + } + else { + detachedCommentsInfo = undefined; + } + return leadingComments; + } + function isPinnedComments(comment) { + return currentSourceFile.text.charCodeAt(comment.pos + 1) === 42 /* asterisk */ && + currentSourceFile.text.charCodeAt(comment.pos + 2) === 33 /* exclamation */; + } + /** + * Determine if the given comment is a triple-slash + * + * @return true if the comment is a triple-slash comment else false + **/ + function isTripleSlashComment(comment) { + // Verify this is /// comment, but do the regexp match only when we first can find /// in the comment text + // so that we don't end up computing comment string and doing match for all // comments + if (currentSourceFile.text.charCodeAt(comment.pos + 1) === 47 /* slash */ && + comment.pos + 2 < comment.end && + currentSourceFile.text.charCodeAt(comment.pos + 2) === 47 /* slash */) { + var textSubStr = currentSourceFile.text.substring(comment.pos, comment.end); + return textSubStr.match(ts.fullTripleSlashReferencePathRegEx) || + textSubStr.match(ts.fullTripleSlashAMDReferencePathRegEx) ? + true : false; + } + return false; + } + function getLeadingCommentsToEmit(node) { + // Emit the leading comments only if the parent's pos doesn't match because parent should take care of emitting these comments + if (node.parent) { + if (node.parent.kind === 248 /* SourceFile */ || node.pos !== node.parent.pos) { + if (hasDetachedComments(node.pos)) { + // get comments without detached comments + return getLeadingCommentsWithoutDetachedComments(); + } + else { + // get the leading comments from the node + return ts.getLeadingCommentRangesOfNode(node, currentSourceFile); + } + } + } + } + function getTrailingCommentsToEmit(node) { + // Emit the trailing comments only if the parent's pos doesn't match because parent should take care of emitting these comments + if (node.parent) { + if (node.parent.kind === 248 /* SourceFile */ || node.end !== node.parent.end) { + return ts.getTrailingCommentRanges(currentSourceFile.text, node.end); + } + } + } + /** + * Emit comments associated with node that will not be emitted into JS file + */ + function emitCommentsOnNotEmittedNode(node) { + emitLeadingCommentsWorker(node, /*isEmittedNode:*/ false); + } + function emitLeadingComments(node) { + return emitLeadingCommentsWorker(node, /*isEmittedNode:*/ true); + } + function emitLeadingCommentsWorker(node, isEmittedNode) { + if (compilerOptions.removeComments) { + return; + } + var leadingComments; + if (isEmittedNode) { + leadingComments = getLeadingCommentsToEmit(node); + } + else { + // If the node will not be emitted in JS, remove all the comments(normal, pinned and ///) associated with the node, + // unless it is a triple slash comment at the top of the file. + // For Example: + // /// + // declare var x; + // /// + // interface F {} + // The first /// will NOT be removed while the second one will be removed eventhough both node will not be emitted + if (node.pos === 0) { + leadingComments = ts.filter(getLeadingCommentsToEmit(node), isTripleSlashComment); + } + } + ts.emitNewLineBeforeLeadingComments(currentSourceFile, writer, node, leadingComments); + // Leading comments are emitted at /*leading comment1 */space/*leading comment*/space + ts.emitComments(currentSourceFile, writer, leadingComments, /*trailingSeparator:*/ true, newLine, writeComment); + } + function emitTrailingComments(node) { + if (compilerOptions.removeComments) { + return; + } + // Emit the trailing comments only if the parent's end doesn't match + var trailingComments = getTrailingCommentsToEmit(node); + // trailing comments are emitted at space/*trailing comment1 */space/*trailing comment*/ + ts.emitComments(currentSourceFile, writer, trailingComments, /*trailingSeparator*/ false, newLine, writeComment); + } + /** + * Emit trailing comments at the position. The term trailing comment is used here to describe following comment: + * x, /comment1/ y + * ^ => pos; the function will emit "comment1" in the emitJS + */ + function emitTrailingCommentsOfPosition(pos) { + if (compilerOptions.removeComments) { + return; + } + var trailingComments = ts.getTrailingCommentRanges(currentSourceFile.text, pos); + // trailing comments are emitted at space/*trailing comment1 */space/*trailing comment*/ + ts.emitComments(currentSourceFile, writer, trailingComments, /*trailingSeparator*/ true, newLine, writeComment); + } + function emitLeadingCommentsOfPositionWorker(pos) { + if (compilerOptions.removeComments) { + return; + } + var leadingComments; + if (hasDetachedComments(pos)) { + // get comments without detached comments + leadingComments = getLeadingCommentsWithoutDetachedComments(); + } + else { + // get the leading comments from the node + leadingComments = ts.getLeadingCommentRanges(currentSourceFile.text, pos); + } + ts.emitNewLineBeforeLeadingComments(currentSourceFile, writer, { pos: pos, end: pos }, leadingComments); + // Leading comments are emitted at /*leading comment1 */space/*leading comment*/space + ts.emitComments(currentSourceFile, writer, leadingComments, /*trailingSeparator*/ true, newLine, writeComment); + } + function emitDetachedComments(node) { + var leadingComments; + if (compilerOptions.removeComments) { + // removeComments is true, only reserve pinned comment at the top of file + // For example: + // /*! Pinned Comment */ + // + // var x = 10; + if (node.pos === 0) { + leadingComments = ts.filter(ts.getLeadingCommentRanges(currentSourceFile.text, node.pos), isPinnedComments); + } + } + else { + // removeComments is false, just get detached as normal and bypass the process to filter comment + leadingComments = ts.getLeadingCommentRanges(currentSourceFile.text, node.pos); + } + if (leadingComments) { + var detachedComments = []; + var lastComment; + ts.forEach(leadingComments, function (comment) { + if (lastComment) { + var lastCommentLine = ts.getLineOfLocalPosition(currentSourceFile, lastComment.end); + var commentLine = ts.getLineOfLocalPosition(currentSourceFile, comment.pos); + if (commentLine >= lastCommentLine + 2) { + // There was a blank line between the last comment and this comment. This + // comment is not part of the copyright comments. Return what we have so + // far. + return detachedComments; + } + } + detachedComments.push(comment); + lastComment = comment; + }); + if (detachedComments.length) { + // All comments look like they could have been part of the copyright header. Make + // sure there is at least one blank line between it and the node. If not, it's not + // a copyright header. + var lastCommentLine = ts.getLineOfLocalPosition(currentSourceFile, ts.lastOrUndefined(detachedComments).end); + var nodeLine = ts.getLineOfLocalPosition(currentSourceFile, ts.skipTrivia(currentSourceFile.text, node.pos)); + if (nodeLine >= lastCommentLine + 2) { + // Valid detachedComments + ts.emitNewLineBeforeLeadingComments(currentSourceFile, writer, node, leadingComments); + ts.emitComments(currentSourceFile, writer, detachedComments, /*trailingSeparator*/ true, newLine, writeComment); + var currentDetachedCommentInfo = { nodePos: node.pos, detachedCommentEndPos: ts.lastOrUndefined(detachedComments).end }; + if (detachedCommentsInfo) { + detachedCommentsInfo.push(currentDetachedCommentInfo); + } + else { + detachedCommentsInfo = [currentDetachedCommentInfo]; + } + } + } + } + } + function emitShebang() { + var shebang = ts.getShebang(currentSourceFile.text); + if (shebang) { + write(shebang); + } + } + var _a; + } + function emitFile(jsFilePath, sourceFile) { + emitJavaScript(jsFilePath, sourceFile); + if (compilerOptions.declaration) { + ts.writeDeclarationFile(jsFilePath, sourceFile, host, resolver, diagnostics); + } + } + } + ts.emitFiles = emitFiles; +})(ts || (ts = {})); +/// +/// +/// +var ts; +(function (ts) { + /* @internal */ ts.programTime = 0; + /* @internal */ ts.emitTime = 0; + /* @internal */ ts.ioReadTime = 0; + /* @internal */ ts.ioWriteTime = 0; + /** The version of the TypeScript compiler release */ + var emptyArray = []; + ts.version = "1.8.0"; + function findConfigFile(searchPath) { + var fileName = "tsconfig.json"; + while (true) { + if (ts.sys.fileExists(fileName)) { + return fileName; + } + var parentPath = ts.getDirectoryPath(searchPath); + if (parentPath === searchPath) { + break; + } + searchPath = parentPath; + fileName = "../" + fileName; + } + return undefined; + } + ts.findConfigFile = findConfigFile; + function resolveTripleslashReference(moduleName, containingFile) { + var basePath = ts.getDirectoryPath(containingFile); + var referencedFileName = ts.isRootedDiskPath(moduleName) ? moduleName : ts.combinePaths(basePath, moduleName); + return ts.normalizePath(referencedFileName); + } + ts.resolveTripleslashReference = resolveTripleslashReference; + function resolveModuleName(moduleName, containingFile, compilerOptions, host) { + var moduleResolution = compilerOptions.moduleResolution !== undefined + ? compilerOptions.moduleResolution + : compilerOptions.module === 1 /* CommonJS */ ? 2 /* NodeJs */ : 1 /* Classic */; + switch (moduleResolution) { + case 2 /* NodeJs */: return nodeModuleNameResolver(moduleName, containingFile, host); + case 1 /* Classic */: return classicNameResolver(moduleName, containingFile, compilerOptions, host); + } + } + ts.resolveModuleName = resolveModuleName; + function nodeModuleNameResolver(moduleName, containingFile, host) { + var containingDirectory = ts.getDirectoryPath(containingFile); + if (ts.getRootLength(moduleName) !== 0 || nameStartsWithDotSlashOrDotDotSlash(moduleName)) { + var failedLookupLocations = []; + var candidate = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName)); + var resolvedFileName = loadNodeModuleFromFile(candidate, failedLookupLocations, host); + if (resolvedFileName) { + return { resolvedModule: { resolvedFileName: resolvedFileName }, failedLookupLocations: failedLookupLocations }; + } + resolvedFileName = loadNodeModuleFromDirectory(candidate, failedLookupLocations, host); + return resolvedFileName + ? { resolvedModule: { resolvedFileName: resolvedFileName }, failedLookupLocations: failedLookupLocations } + : { resolvedModule: undefined, failedLookupLocations: failedLookupLocations }; + } + else { + return loadModuleFromNodeModules(moduleName, containingDirectory, host); + } + } + ts.nodeModuleNameResolver = nodeModuleNameResolver; + function loadNodeModuleFromFile(candidate, failedLookupLocation, host) { + return ts.forEach(ts.moduleFileExtensions, tryLoad); + function tryLoad(ext) { + var fileName = ts.fileExtensionIs(candidate, ext) ? candidate : candidate + ext; + if (host.fileExists(fileName)) { + return fileName; + } + else { + failedLookupLocation.push(fileName); + return undefined; + } + } + } + function loadNodeModuleFromDirectory(candidate, failedLookupLocation, host) { + var packageJsonPath = ts.combinePaths(candidate, "package.json"); + if (host.fileExists(packageJsonPath)) { + var jsonContent; + try { + var jsonText = host.readFile(packageJsonPath); + jsonContent = jsonText ? JSON.parse(jsonText) : { typings: undefined }; + } + catch (e) { + // gracefully handle if readFile fails or returns not JSON + jsonContent = { typings: undefined }; + } + if (jsonContent.typings) { + var result = loadNodeModuleFromFile(ts.normalizePath(ts.combinePaths(candidate, jsonContent.typings)), failedLookupLocation, host); + if (result) { + return result; + } + } + } + else { + // record package json as one of failed lookup locations - in the future if this file will appear it will invalidate resolution results + failedLookupLocation.push(packageJsonPath); + } + return loadNodeModuleFromFile(ts.combinePaths(candidate, "index"), failedLookupLocation, host); + } + function loadModuleFromNodeModules(moduleName, directory, host) { + var failedLookupLocations = []; + directory = ts.normalizeSlashes(directory); + while (true) { + var baseName = ts.getBaseFileName(directory); + if (baseName !== "node_modules") { + var nodeModulesFolder = ts.combinePaths(directory, "node_modules"); + var candidate = ts.normalizePath(ts.combinePaths(nodeModulesFolder, moduleName)); + var result = loadNodeModuleFromFile(candidate, failedLookupLocations, host); + if (result) { + return { resolvedModule: { resolvedFileName: result, isExternalLibraryImport: true }, failedLookupLocations: failedLookupLocations }; + } + result = loadNodeModuleFromDirectory(candidate, failedLookupLocations, host); + if (result) { + return { resolvedModule: { resolvedFileName: result, isExternalLibraryImport: true }, failedLookupLocations: failedLookupLocations }; + } + } + var parentPath = ts.getDirectoryPath(directory); + if (parentPath === directory) { + break; + } + directory = parentPath; + } + return { resolvedModule: undefined, failedLookupLocations: failedLookupLocations }; + } + function nameStartsWithDotSlashOrDotDotSlash(name) { + var i = name.lastIndexOf("./", 1); + return i === 0 || (i === 1 && name.charCodeAt(0) === 46 /* dot */); + } + function classicNameResolver(moduleName, containingFile, compilerOptions, host) { + // module names that contain '!' are used to reference resources and are not resolved to actual files on disk + if (moduleName.indexOf("!") != -1) { + return { resolvedModule: undefined, failedLookupLocations: [] }; + } + var searchPath = ts.getDirectoryPath(containingFile); + var searchName; + var failedLookupLocations = []; + var referencedSourceFile; + while (true) { + searchName = ts.normalizePath(ts.combinePaths(searchPath, moduleName)); + referencedSourceFile = ts.forEach(ts.supportedExtensions, function (extension) { + if (extension === ".tsx" && !compilerOptions.jsx) { + // resolve .tsx files only if jsx support is enabled + // 'logical not' handles both undefined and None cases + return undefined; + } + var candidate = searchName + extension; + if (host.fileExists(candidate)) { + return candidate; + } + else { + failedLookupLocations.push(candidate); + } + }); + if (referencedSourceFile) { + break; + } + var parentPath = ts.getDirectoryPath(searchPath); + if (parentPath === searchPath) { + break; + } + searchPath = parentPath; + } + return referencedSourceFile + ? { resolvedModule: { resolvedFileName: referencedSourceFile }, failedLookupLocations: failedLookupLocations } + : { resolvedModule: undefined, failedLookupLocations: failedLookupLocations }; + } + ts.classicNameResolver = classicNameResolver; + /* @internal */ + ts.defaultInitCompilerOptions = { + module: 1 /* CommonJS */, + target: 0 /* ES3 */, + noImplicitAny: false, + outDir: "built", + rootDir: ".", + sourceMap: false + }; + function createCompilerHost(options, setParentNodes) { + var existingDirectories = {}; + function getCanonicalFileName(fileName) { + // if underlying system can distinguish between two files whose names differs only in cases then file name already in canonical form. + // otherwise use toLowerCase as a canonical form. + return ts.sys.useCaseSensitiveFileNames ? fileName : fileName.toLowerCase(); + } + // returned by CScript sys environment + var unsupportedFileEncodingErrorCode = -2147024809; + function getSourceFile(fileName, languageVersion, onError) { + var text; + try { + var start = new Date().getTime(); + text = ts.sys.readFile(fileName, options.charset); + ts.ioReadTime += new Date().getTime() - start; + } + catch (e) { + if (onError) { + onError(e.number === unsupportedFileEncodingErrorCode + ? ts.createCompilerDiagnostic(ts.Diagnostics.Unsupported_file_encoding).messageText + : e.message); + } + text = ""; + } + return text !== undefined ? ts.createSourceFile(fileName, text, languageVersion, setParentNodes) : undefined; + } + function directoryExists(directoryPath) { + if (ts.hasProperty(existingDirectories, directoryPath)) { + return true; + } + if (ts.sys.directoryExists(directoryPath)) { + existingDirectories[directoryPath] = true; + return true; + } + return false; + } + function ensureDirectoriesExist(directoryPath) { + if (directoryPath.length > ts.getRootLength(directoryPath) && !directoryExists(directoryPath)) { + var parentDirectory = ts.getDirectoryPath(directoryPath); + ensureDirectoriesExist(parentDirectory); + ts.sys.createDirectory(directoryPath); + } + } + function writeFile(fileName, data, writeByteOrderMark, onError) { + try { + var start = new Date().getTime(); + ensureDirectoriesExist(ts.getDirectoryPath(ts.normalizePath(fileName))); + ts.sys.writeFile(fileName, data, writeByteOrderMark); + ts.ioWriteTime += new Date().getTime() - start; + } + catch (e) { + if (onError) { + onError(e.message); + } + } + } + var newLine = ts.getNewLineCharacter(options); + return { + getSourceFile: getSourceFile, + getDefaultLibFileName: function (options) { return ts.combinePaths(ts.getDirectoryPath(ts.normalizePath(ts.sys.getExecutingFilePath())), ts.getDefaultLibFileName(options)); }, + writeFile: writeFile, + getCurrentDirectory: ts.memoize(function () { return ts.sys.getCurrentDirectory(); }), + useCaseSensitiveFileNames: function () { return ts.sys.useCaseSensitiveFileNames; }, + getCanonicalFileName: getCanonicalFileName, + getNewLine: function () { return newLine; }, + fileExists: function (fileName) { return ts.sys.fileExists(fileName); }, + readFile: function (fileName) { return ts.sys.readFile(fileName); } + }; + } + ts.createCompilerHost = createCompilerHost; + function getPreEmitDiagnostics(program, sourceFile, cancellationToken) { + var diagnostics = program.getOptionsDiagnostics(cancellationToken).concat(program.getSyntacticDiagnostics(sourceFile, cancellationToken), program.getGlobalDiagnostics(cancellationToken), program.getSemanticDiagnostics(sourceFile, cancellationToken)); + if (program.getCompilerOptions().declaration) { + diagnostics.concat(program.getDeclarationDiagnostics(sourceFile, cancellationToken)); + } + return ts.sortAndDeduplicateDiagnostics(diagnostics); + } + ts.getPreEmitDiagnostics = getPreEmitDiagnostics; + function flattenDiagnosticMessageText(messageText, newLine) { + if (typeof messageText === "string") { + return messageText; + } + else { + var diagnosticChain = messageText; + var result = ""; + var indent = 0; + while (diagnosticChain) { + if (indent) { + result += newLine; + for (var i = 0; i < indent; i++) { + result += " "; + } + } + result += diagnosticChain.messageText; + indent++; + diagnosticChain = diagnosticChain.next; + } + return result; + } + } + ts.flattenDiagnosticMessageText = flattenDiagnosticMessageText; + function createProgram(rootNames, options, host, oldProgram) { + var program; + var files = []; + var fileProcessingDiagnostics = ts.createDiagnosticCollection(); + var programDiagnostics = ts.createDiagnosticCollection(); + var commonSourceDirectory; + var diagnosticsProducingTypeChecker; + var noDiagnosticsTypeChecker; + var classifiableNames; + var skipDefaultLib = options.noLib; + var start = new Date().getTime(); + host = host || createCompilerHost(options); + var currentDirectory = host.getCurrentDirectory(); + var resolveModuleNamesWorker = host.resolveModuleNames + ? (function (moduleNames, containingFile) { return host.resolveModuleNames(moduleNames, containingFile); }) + : (function (moduleNames, containingFile) { return ts.map(moduleNames, function (moduleName) { return resolveModuleName(moduleName, containingFile, options, host).resolvedModule; }); }); + var filesByName = ts.createFileMap(getCanonicalFileName); + // stores 'filename -> file association' ignoring case + // used to track cases when two file names differ only in casing + var filesByNameIgnoreCase = host.useCaseSensitiveFileNames() ? ts.createFileMap(function (fileName) { return fileName.toLowerCase(); }) : undefined; + if (oldProgram) { + // check properties that can affect structure of the program or module resolution strategy + // if any of these properties has changed - structure cannot be reused + var oldOptions = oldProgram.getCompilerOptions(); + if ((oldOptions.module !== options.module) || + (oldOptions.noResolve !== options.noResolve) || + (oldOptions.target !== options.target) || + (oldOptions.noLib !== options.noLib) || + (oldOptions.jsx !== options.jsx)) { + oldProgram = undefined; + } + } + if (!tryReuseStructureFromOldProgram()) { + ts.forEach(rootNames, function (name) { return processRootFile(name, false); }); + // Do not process the default library if: + // - The '--noLib' flag is used. + // - A 'no-default-lib' reference comment is encountered in + // processing the root files. + if (!skipDefaultLib) { + processRootFile(host.getDefaultLibFileName(options), true); + } + } + verifyCompilerOptions(); + // unconditionally set oldProgram to undefined to prevent it from being captured in closure + oldProgram = undefined; + ts.programTime += new Date().getTime() - start; + program = { + getRootFileNames: function () { return rootNames; }, + getSourceFile: getSourceFile, + getSourceFiles: function () { return files; }, + getCompilerOptions: function () { return options; }, + getSyntacticDiagnostics: getSyntacticDiagnostics, + getOptionsDiagnostics: getOptionsDiagnostics, + getGlobalDiagnostics: getGlobalDiagnostics, + getSemanticDiagnostics: getSemanticDiagnostics, + getDeclarationDiagnostics: getDeclarationDiagnostics, + getTypeChecker: getTypeChecker, + getClassifiableNames: getClassifiableNames, + getDiagnosticsProducingTypeChecker: getDiagnosticsProducingTypeChecker, + getCommonSourceDirectory: function () { return commonSourceDirectory; }, + emit: emit, + getCurrentDirectory: function () { return currentDirectory; }, + getNodeCount: function () { return getDiagnosticsProducingTypeChecker().getNodeCount(); }, + getIdentifierCount: function () { return getDiagnosticsProducingTypeChecker().getIdentifierCount(); }, + getSymbolCount: function () { return getDiagnosticsProducingTypeChecker().getSymbolCount(); }, + getTypeCount: function () { return getDiagnosticsProducingTypeChecker().getTypeCount(); }, + getFileProcessingDiagnostics: function () { return fileProcessingDiagnostics; } + }; + return program; + function getClassifiableNames() { + if (!classifiableNames) { + // Initialize a checker so that all our files are bound. + getTypeChecker(); + classifiableNames = {}; + for (var _i = 0; _i < files.length; _i++) { + var sourceFile = files[_i]; + ts.copyMap(sourceFile.classifiableNames, classifiableNames); + } + } + return classifiableNames; + } + function tryReuseStructureFromOldProgram() { + if (!oldProgram) { + return false; + } + ts.Debug.assert(!oldProgram.structureIsReused); + // there is an old program, check if we can reuse its structure + var oldRootNames = oldProgram.getRootFileNames(); + if (!ts.arrayIsEqualTo(oldRootNames, rootNames)) { + return false; + } + // check if program source files has changed in the way that can affect structure of the program + var newSourceFiles = []; + var normalizedAbsoluteFileNames = []; + var modifiedSourceFiles = []; + for (var _i = 0, _a = oldProgram.getSourceFiles(); _i < _a.length; _i++) { + var oldSourceFile = _a[_i]; + var newSourceFile = host.getSourceFile(oldSourceFile.fileName, options.target); + if (!newSourceFile) { + return false; + } + var normalizedAbsolutePath = ts.getNormalizedAbsolutePath(newSourceFile.fileName, currentDirectory); + normalizedAbsoluteFileNames.push(normalizedAbsolutePath); + if (oldSourceFile !== newSourceFile) { + if (oldSourceFile.hasNoDefaultLib !== newSourceFile.hasNoDefaultLib) { + // value of no-default-lib has changed + // this will affect if default library is injected into the list of files + return false; + } + // check tripleslash references + if (!ts.arrayIsEqualTo(oldSourceFile.referencedFiles, newSourceFile.referencedFiles, fileReferenceIsEqualTo)) { + // tripleslash references has changed + return false; + } + // check imports + collectExternalModuleReferences(newSourceFile); + if (!ts.arrayIsEqualTo(oldSourceFile.imports, newSourceFile.imports, moduleNameIsEqualTo)) { + // imports has changed + return false; + } + if (resolveModuleNamesWorker) { + var moduleNames = ts.map(newSourceFile.imports, function (name) { return name.text; }); + var resolutions = resolveModuleNamesWorker(moduleNames, normalizedAbsolutePath); + // ensure that module resolution results are still correct + for (var i = 0; i < moduleNames.length; ++i) { + var newResolution = resolutions[i]; + var oldResolution = ts.getResolvedModule(oldSourceFile, moduleNames[i]); + var resolutionChanged = oldResolution + ? !newResolution || + oldResolution.resolvedFileName !== newResolution.resolvedFileName || + !!oldResolution.isExternalLibraryImport !== !!newResolution.isExternalLibraryImport + : newResolution; + if (resolutionChanged) { + return false; + } + } + } + // pass the cache of module resolutions from the old source file + newSourceFile.resolvedModules = oldSourceFile.resolvedModules; + modifiedSourceFiles.push(newSourceFile); + } + else { + // file has no changes - use it as is + newSourceFile = oldSourceFile; + } + // if file has passed all checks it should be safe to reuse it + newSourceFiles.push(newSourceFile); + } + // update fileName -> file mapping + for (var i = 0, len = newSourceFiles.length; i < len; ++i) { + filesByName.set(normalizedAbsoluteFileNames[i], newSourceFiles[i]); + } + files = newSourceFiles; + fileProcessingDiagnostics = oldProgram.getFileProcessingDiagnostics(); + for (var _b = 0; _b < modifiedSourceFiles.length; _b++) { + var modifiedFile = modifiedSourceFiles[_b]; + fileProcessingDiagnostics.reattachFileDiagnostics(modifiedFile); + } + oldProgram.structureIsReused = true; + return true; + } + function getEmitHost(writeFileCallback) { + return { + getCanonicalFileName: getCanonicalFileName, + getCommonSourceDirectory: program.getCommonSourceDirectory, + getCompilerOptions: program.getCompilerOptions, + getCurrentDirectory: function () { return currentDirectory; }, + getNewLine: function () { return host.getNewLine(); }, + getSourceFile: program.getSourceFile, + getSourceFiles: program.getSourceFiles, + writeFile: writeFileCallback || (function (fileName, data, writeByteOrderMark, onError) { return host.writeFile(fileName, data, writeByteOrderMark, onError); }) + }; + } + function getDiagnosticsProducingTypeChecker() { + return diagnosticsProducingTypeChecker || (diagnosticsProducingTypeChecker = ts.createTypeChecker(program, /*produceDiagnostics:*/ true)); + } + function getTypeChecker() { + return noDiagnosticsTypeChecker || (noDiagnosticsTypeChecker = ts.createTypeChecker(program, /*produceDiagnostics:*/ false)); + } + function emit(sourceFile, writeFileCallback, cancellationToken) { + var _this = this; + return runWithCancellationToken(function () { return emitWorker(_this, sourceFile, writeFileCallback, cancellationToken); }); + } + function emitWorker(program, sourceFile, writeFileCallback, cancellationToken) { + // If the noEmitOnError flag is set, then check if we have any errors so far. If so, + // immediately bail out. Note that we pass 'undefined' for 'sourceFile' so that we + // get any preEmit diagnostics, not just the ones + if (options.noEmitOnError && getPreEmitDiagnostics(program, /*sourceFile:*/ undefined, cancellationToken).length > 0) { + return { diagnostics: [], sourceMaps: undefined, emitSkipped: true }; + } + // Create the emit resolver outside of the "emitTime" tracking code below. That way + // any cost associated with it (like type checking) are appropriate associated with + // the type-checking counter. + // + // If the -out option is specified, we should not pass the source file to getEmitResolver. + // This is because in the -out scenario all files need to be emitted, and therefore all + // files need to be type checked. And the way to specify that all files need to be type + // checked is to not pass the file to getEmitResolver. + var emitResolver = getDiagnosticsProducingTypeChecker().getEmitResolver((options.outFile || options.out) ? undefined : sourceFile); + var start = new Date().getTime(); + var emitResult = ts.emitFiles(emitResolver, getEmitHost(writeFileCallback), sourceFile); + ts.emitTime += new Date().getTime() - start; + return emitResult; + } + function getSourceFile(fileName) { + return filesByName.get(ts.getNormalizedAbsolutePath(fileName, currentDirectory)); + } + function getDiagnosticsHelper(sourceFile, getDiagnostics, cancellationToken) { + if (sourceFile) { + return getDiagnostics(sourceFile, cancellationToken); + } + var allDiagnostics = []; + ts.forEach(program.getSourceFiles(), function (sourceFile) { + if (cancellationToken) { + cancellationToken.throwIfCancellationRequested(); + } + ts.addRange(allDiagnostics, getDiagnostics(sourceFile, cancellationToken)); + }); + return ts.sortAndDeduplicateDiagnostics(allDiagnostics); + } + function getSyntacticDiagnostics(sourceFile, cancellationToken) { + return getDiagnosticsHelper(sourceFile, getSyntacticDiagnosticsForFile, cancellationToken); + } + function getSemanticDiagnostics(sourceFile, cancellationToken) { + return getDiagnosticsHelper(sourceFile, getSemanticDiagnosticsForFile, cancellationToken); + } + function getDeclarationDiagnostics(sourceFile, cancellationToken) { + return getDiagnosticsHelper(sourceFile, getDeclarationDiagnosticsForFile, cancellationToken); + } + function getSyntacticDiagnosticsForFile(sourceFile, cancellationToken) { + return sourceFile.parseDiagnostics; + } + function runWithCancellationToken(func) { + try { + return func(); + } + catch (e) { + if (e instanceof ts.OperationCanceledException) { + // We were canceled while performing the operation. Because our type checker + // might be a bad state, we need to throw it away. + // + // Note: we are overly agressive here. We do not actually *have* to throw away + // the "noDiagnosticsTypeChecker". However, for simplicity, i'd like to keep + // the lifetimes of these two TypeCheckers the same. Also, we generally only + // cancel when the user has made a change anyways. And, in that case, we (the + // program instance) will get thrown away anyways. So trying to keep one of + // these type checkers alive doesn't serve much purpose. + noDiagnosticsTypeChecker = undefined; + diagnosticsProducingTypeChecker = undefined; + } + throw e; + } + } + function getSemanticDiagnosticsForFile(sourceFile, cancellationToken) { + return runWithCancellationToken(function () { + var typeChecker = getDiagnosticsProducingTypeChecker(); + ts.Debug.assert(!!sourceFile.bindDiagnostics); + var bindDiagnostics = sourceFile.bindDiagnostics; + var checkDiagnostics = typeChecker.getDiagnostics(sourceFile, cancellationToken); + var fileProcessingDiagnosticsInFile = fileProcessingDiagnostics.getDiagnostics(sourceFile.fileName); + var programDiagnosticsInFile = programDiagnostics.getDiagnostics(sourceFile.fileName); + return bindDiagnostics.concat(checkDiagnostics).concat(fileProcessingDiagnosticsInFile).concat(programDiagnosticsInFile); + }); + } + function getDeclarationDiagnosticsForFile(sourceFile, cancellationToken) { + return runWithCancellationToken(function () { + if (!ts.isDeclarationFile(sourceFile)) { + var resolver = getDiagnosticsProducingTypeChecker().getEmitResolver(sourceFile, cancellationToken); + // Don't actually write any files since we're just getting diagnostics. + var writeFile_1 = function () { }; + return ts.getDeclarationDiagnostics(getEmitHost(writeFile_1), resolver, sourceFile); + } + }); + } + function getOptionsDiagnostics() { + var allDiagnostics = []; + ts.addRange(allDiagnostics, fileProcessingDiagnostics.getGlobalDiagnostics()); + ts.addRange(allDiagnostics, programDiagnostics.getGlobalDiagnostics()); + return ts.sortAndDeduplicateDiagnostics(allDiagnostics); + } + function getGlobalDiagnostics() { + var allDiagnostics = []; + ts.addRange(allDiagnostics, getDiagnosticsProducingTypeChecker().getGlobalDiagnostics()); + return ts.sortAndDeduplicateDiagnostics(allDiagnostics); + } + function hasExtension(fileName) { + return ts.getBaseFileName(fileName).indexOf(".") >= 0; + } + function processRootFile(fileName, isDefaultLib) { + processSourceFile(ts.normalizePath(fileName), isDefaultLib); + } + function fileReferenceIsEqualTo(a, b) { + return a.fileName === b.fileName; + } + function moduleNameIsEqualTo(a, b) { + return a.text === b.text; + } + function collectExternalModuleReferences(file) { + if (file.imports) { + return; + } + var imports; + for (var _i = 0, _a = file.statements; _i < _a.length; _i++) { + var node = _a[_i]; + collect(node, /* allowRelativeModuleNames */ true); + } + file.imports = imports || emptyArray; + function collect(node, allowRelativeModuleNames) { + switch (node.kind) { + case 222 /* ImportDeclaration */: + case 221 /* ImportEqualsDeclaration */: + case 228 /* ExportDeclaration */: + var moduleNameExpr = ts.getExternalModuleName(node); + if (!moduleNameExpr || moduleNameExpr.kind !== 9 /* StringLiteral */) { + break; + } + if (!moduleNameExpr.text) { + break; + } + if (allowRelativeModuleNames || !ts.isExternalModuleNameRelative(moduleNameExpr.text)) { + (imports || (imports = [])).push(moduleNameExpr); + } + break; + case 218 /* ModuleDeclaration */: + if (node.name.kind === 9 /* StringLiteral */ && (node.flags & 2 /* Ambient */ || ts.isDeclarationFile(file))) { + // TypeScript 1.0 spec (April 2014): 12.1.6 + // An AmbientExternalModuleDeclaration declares an external module. + // This type of declaration is permitted only in the global module. + // The StringLiteral must specify a top - level external module name. + // Relative external module names are not permitted + ts.forEachChild(node.body, function (node) { + // TypeScript 1.0 spec (April 2014): 12.1.6 + // An ExternalImportDeclaration in anAmbientExternalModuleDeclaration may reference other external modules + // only through top - level external module names. Relative external module names are not permitted. + collect(node, /* allowRelativeModuleNames */ false); + }); + } + break; + } + } + } + function processSourceFile(fileName, isDefaultLib, refFile, refPos, refEnd) { + var diagnosticArgument; + var diagnostic; + if (hasExtension(fileName)) { + if (!options.allowNonTsExtensions && !ts.forEach(ts.supportedExtensions, function (extension) { return ts.fileExtensionIs(host.getCanonicalFileName(fileName), extension); })) { + diagnostic = ts.Diagnostics.File_0_has_unsupported_extension_The_only_supported_extensions_are_1; + diagnosticArgument = [fileName, "'" + ts.supportedExtensions.join("', '") + "'"]; + } + else if (!findSourceFile(fileName, ts.getNormalizedAbsolutePath(fileName, currentDirectory), isDefaultLib, refFile, refPos, refEnd)) { + diagnostic = ts.Diagnostics.File_0_not_found; + diagnosticArgument = [fileName]; + } + else if (refFile && host.getCanonicalFileName(fileName) === host.getCanonicalFileName(refFile.fileName)) { + diagnostic = ts.Diagnostics.A_file_cannot_have_a_reference_to_itself; + diagnosticArgument = [fileName]; + } + } + else { + var nonTsFile = options.allowNonTsExtensions && findSourceFile(fileName, ts.getNormalizedAbsolutePath(fileName, currentDirectory), isDefaultLib, refFile, refPos, refEnd); + if (!nonTsFile) { + if (options.allowNonTsExtensions) { + diagnostic = ts.Diagnostics.File_0_not_found; + diagnosticArgument = [fileName]; + } + else if (!ts.forEach(ts.supportedExtensions, function (extension) { return findSourceFile(fileName + extension, ts.getNormalizedAbsolutePath(fileName + extension, currentDirectory), isDefaultLib, refFile, refPos, refEnd); })) { + diagnostic = ts.Diagnostics.File_0_not_found; + fileName += ".ts"; + diagnosticArgument = [fileName]; + } + } + } + if (diagnostic) { + if (refFile !== undefined && refEnd !== undefined && refPos !== undefined) { + fileProcessingDiagnostics.add(ts.createFileDiagnostic.apply(void 0, [refFile, refPos, refEnd - refPos, diagnostic].concat(diagnosticArgument))); + } + else { + fileProcessingDiagnostics.add(ts.createCompilerDiagnostic.apply(void 0, [diagnostic].concat(diagnosticArgument))); + } + } + } + function reportFileNamesDifferOnlyInCasingError(fileName, existingFileName, refFile, refPos, refEnd) { + if (refFile !== undefined && refPos !== undefined && refEnd !== undefined) { + fileProcessingDiagnostics.add(ts.createFileDiagnostic(refFile, refPos, refEnd - refPos, ts.Diagnostics.File_name_0_differs_from_already_included_file_name_1_only_in_casing, fileName, existingFileName)); + } + else { + fileProcessingDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.File_name_0_differs_from_already_included_file_name_1_only_in_casing, fileName, existingFileName)); + } + } + // Get source file from normalized fileName + function findSourceFile(fileName, normalizedAbsolutePath, isDefaultLib, refFile, refPos, refEnd) { + if (filesByName.contains(normalizedAbsolutePath)) { + var file_1 = filesByName.get(normalizedAbsolutePath); + // try to check if we've already seen this file but with a different casing in path + // NOTE: this only makes sense for case-insensitive file systems + if (file_1 && options.forceConsistentCasingInFileNames && ts.getNormalizedAbsolutePath(file_1.fileName, currentDirectory) !== normalizedAbsolutePath) { + reportFileNamesDifferOnlyInCasingError(fileName, file_1.fileName, refFile, refPos, refEnd); + } + return file_1; + } + // We haven't looked for this file, do so now and cache result + var file = host.getSourceFile(fileName, options.target, function (hostErrorMessage) { + if (refFile !== undefined && refPos !== undefined && refEnd !== undefined) { + fileProcessingDiagnostics.add(ts.createFileDiagnostic(refFile, refPos, refEnd - refPos, ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage)); + } + else { + fileProcessingDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage)); + } + }); + filesByName.set(normalizedAbsolutePath, file); + if (file) { + if (host.useCaseSensitiveFileNames()) { + // for case-sensitive file systems check if we've already seen some file with similar filename ignoring case + var existingFile = filesByNameIgnoreCase.get(normalizedAbsolutePath); + if (existingFile) { + reportFileNamesDifferOnlyInCasingError(fileName, existingFile.fileName, refFile, refPos, refEnd); + } + else { + filesByNameIgnoreCase.set(normalizedAbsolutePath, file); + } + } + skipDefaultLib = skipDefaultLib || file.hasNoDefaultLib; + var basePath = ts.getDirectoryPath(fileName); + if (!options.noResolve) { + processReferencedFiles(file, basePath); + } + // always process imported modules to record module name resolutions + processImportedModules(file, basePath); + if (isDefaultLib) { + file.isDefaultLib = true; + files.unshift(file); + } + else { + files.push(file); + } + } + return file; + } + function processReferencedFiles(file, basePath) { + ts.forEach(file.referencedFiles, function (ref) { + var referencedFileName = resolveTripleslashReference(ref.fileName, file.fileName); + processSourceFile(referencedFileName, /* isDefaultLib */ false, file, ref.pos, ref.end); + }); + } + function getCanonicalFileName(fileName) { + return host.getCanonicalFileName(fileName); + } + function processImportedModules(file, basePath) { + collectExternalModuleReferences(file); + if (file.imports.length) { + file.resolvedModules = {}; + var moduleNames = ts.map(file.imports, function (name) { return name.text; }); + var resolutions = resolveModuleNamesWorker(moduleNames, ts.getNormalizedAbsolutePath(file.fileName, currentDirectory)); + for (var i = 0; i < file.imports.length; ++i) { + var resolution = resolutions[i]; + ts.setResolvedModule(file, moduleNames[i], resolution); + if (resolution && !options.noResolve) { + var absoluteImportPath = ts.isRootedDiskPath(resolution.resolvedFileName) + ? resolution.resolvedFileName + : ts.getNormalizedAbsolutePath(resolution.resolvedFileName, currentDirectory); + // convert an absolute import path to path that is relative to current directory + // this was host still can locate it but files names in user output will be shorter (and thus look nicer). + var relativePath = ts.getRelativePathToDirectoryOrUrl(currentDirectory, absoluteImportPath, currentDirectory, getCanonicalFileName, false); + var importedFile = findSourceFile(relativePath, absoluteImportPath, /* isDefaultLib */ false, file, ts.skipTrivia(file.text, file.imports[i].pos), file.imports[i].end); + if (importedFile && resolution.isExternalLibraryImport) { + if (!ts.isExternalModule(importedFile)) { + var start_2 = ts.getTokenPosOfNode(file.imports[i], file); + fileProcessingDiagnostics.add(ts.createFileDiagnostic(file, start_2, file.imports[i].end - start_2, ts.Diagnostics.Exported_external_package_typings_file_0_is_not_a_module_Please_contact_the_package_author_to_update_the_package_definition, importedFile.fileName)); + } + else if (importedFile.referencedFiles.length) { + var firstRef = importedFile.referencedFiles[0]; + fileProcessingDiagnostics.add(ts.createFileDiagnostic(importedFile, firstRef.pos, firstRef.end - firstRef.pos, ts.Diagnostics.Exported_external_package_typings_file_cannot_contain_tripleslash_references_Please_contact_the_package_author_to_update_the_package_definition)); + } + } + } + } + } + else { + // no imports - drop cached module resolutions + file.resolvedModules = undefined; + } + return; + } + function computeCommonSourceDirectory(sourceFiles) { + var commonPathComponents; + ts.forEach(files, function (sourceFile) { + // Each file contributes into common source file path + if (ts.isDeclarationFile(sourceFile)) { + return; + } + var sourcePathComponents = ts.getNormalizedPathComponents(sourceFile.fileName, currentDirectory); + sourcePathComponents.pop(); // The base file name is not part of the common directory path + if (!commonPathComponents) { + // first file + commonPathComponents = sourcePathComponents; + return; + } + for (var i = 0, n = Math.min(commonPathComponents.length, sourcePathComponents.length); i < n; i++) { + if (commonPathComponents[i] !== sourcePathComponents[i]) { + if (i === 0) { + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_find_the_common_subdirectory_path_for_the_input_files)); + return; + } + // New common path found that is 0 -> i-1 + commonPathComponents.length = i; + break; + } + } + // If the sourcePathComponents was shorter than the commonPathComponents, truncate to the sourcePathComponents + if (sourcePathComponents.length < commonPathComponents.length) { + commonPathComponents.length = sourcePathComponents.length; + } + }); + return ts.getNormalizedPathFromPathComponents(commonPathComponents); + } + function checkSourceFilesBelongToPath(sourceFiles, rootDirectory) { + var allFilesBelongToPath = true; + if (sourceFiles) { + var absoluteRootDirectoryPath = host.getCanonicalFileName(ts.getNormalizedAbsolutePath(rootDirectory, currentDirectory)); + for (var _i = 0; _i < sourceFiles.length; _i++) { + var sourceFile = sourceFiles[_i]; + if (!ts.isDeclarationFile(sourceFile)) { + var absoluteSourceFilePath = host.getCanonicalFileName(ts.getNormalizedAbsolutePath(sourceFile.fileName, currentDirectory)); + if (absoluteSourceFilePath.indexOf(absoluteRootDirectoryPath) !== 0) { + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.File_0_is_not_under_rootDir_1_rootDir_is_expected_to_contain_all_source_files, sourceFile.fileName, options.rootDir)); + allFilesBelongToPath = false; + } + } + } + } + return allFilesBelongToPath; + } + function verifyCompilerOptions() { + if (options.isolatedModules) { + if (options.declaration) { + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "declaration", "isolatedModules")); + } + if (options.noEmitOnError) { + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "noEmitOnError", "isolatedModules")); + } + if (options.out) { + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "out", "isolatedModules")); + } + if (options.outFile) { + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "outFile", "isolatedModules")); + } + } + if (options.inlineSourceMap) { + if (options.sourceMap) { + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "sourceMap", "inlineSourceMap")); + } + if (options.mapRoot) { + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "mapRoot", "inlineSourceMap")); + } + if (options.sourceRoot) { + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "sourceRoot", "inlineSourceMap")); + } + } + if (options.inlineSources) { + if (!options.sourceMap && !options.inlineSourceMap) { + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_inlineSources_can_only_be_used_when_either_option_inlineSourceMap_or_option_sourceMap_is_provided)); + } + } + if (options.out && options.outFile) { + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "out", "outFile")); + } + if (!options.sourceMap && (options.mapRoot || options.sourceRoot)) { + // Error to specify --mapRoot or --sourceRoot without mapSourceFiles + if (options.mapRoot) { + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "mapRoot", "sourceMap")); + } + if (options.sourceRoot) { + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "sourceRoot", "sourceMap")); + } + return; + } + var languageVersion = options.target || 0 /* ES3 */; + var outFile = options.outFile || options.out; + var firstExternalModuleSourceFile = ts.forEach(files, function (f) { return ts.isExternalModule(f) ? f : undefined; }); + if (options.isolatedModules) { + if (!options.module && languageVersion < 2 /* ES6 */) { + 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; }); + if (firstNonExternalModuleSourceFile) { + var span = ts.getErrorSpanForNode(firstNonExternalModuleSourceFile, firstNonExternalModuleSourceFile); + programDiagnostics.add(ts.createFileDiagnostic(firstNonExternalModuleSourceFile, span.start, span.length, ts.Diagnostics.Cannot_compile_namespaces_when_the_isolatedModules_flag_is_provided)); + } + } + else if (firstExternalModuleSourceFile && languageVersion < 2 /* ES6 */ && !options.module) { + // We cannot use createDiagnosticFromNode because nodes do not have parents yet + var span = ts.getErrorSpanForNode(firstExternalModuleSourceFile, firstExternalModuleSourceFile.externalModuleIndicator); + programDiagnostics.add(ts.createFileDiagnostic(firstExternalModuleSourceFile, span.start, span.length, ts.Diagnostics.Cannot_compile_modules_unless_the_module_flag_is_provided)); + } + // Cannot specify module gen target of es6 when below es6 + if (options.module === 5 /* ES6 */ && languageVersion < 2 /* ES6 */) { + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_compile_modules_into_es2015_when_targeting_ES5_or_lower)); + } + // there has to be common source directory if user specified --outdir || --sourceRoot + // if user specified --mapRoot, there needs to be common source directory if there would be multiple files being emitted + if (options.outDir || + options.sourceRoot || + (options.mapRoot && + (!outFile || firstExternalModuleSourceFile !== undefined))) { + if (options.rootDir && checkSourceFilesBelongToPath(files, options.rootDir)) { + // If a rootDir is specified and is valid use it as the commonSourceDirectory + commonSourceDirectory = ts.getNormalizedAbsolutePath(options.rootDir, currentDirectory); + } + else { + // Compute the commonSourceDirectory from the input files + commonSourceDirectory = computeCommonSourceDirectory(files); + } + if (commonSourceDirectory && commonSourceDirectory[commonSourceDirectory.length - 1] !== ts.directorySeparator) { + // Make sure directory path ends with directory separator so this string can directly + // used to replace with "" to get the relative path of the source file and the relative path doesn't + // start with / making it rooted path + commonSourceDirectory += ts.directorySeparator; + } + } + if (options.noEmit) { + if (options.out) { + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "noEmit", "out")); + } + if (options.outFile) { + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "noEmit", "outFile")); + } + if (options.outDir) { + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "noEmit", "outDir")); + } + if (options.declaration) { + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "noEmit", "declaration")); + } + } + if (options.emitDecoratorMetadata && + !options.experimentalDecorators) { + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "emitDecoratorMetadata", "experimentalDecorators")); + } + } + } + ts.createProgram = createProgram; +})(ts || (ts = {})); +/// +/// +/// +/// +var ts; +(function (ts) { + /* @internal */ + ts.optionDeclarations = [ + { + name: "charset", + type: "string" + }, + { + name: "declaration", + shortName: "d", + type: "boolean", + description: ts.Diagnostics.Generates_corresponding_d_ts_file + }, + { + name: "diagnostics", + type: "boolean" + }, + { + name: "emitBOM", + type: "boolean" + }, + { + name: "help", + shortName: "h", + type: "boolean", + description: ts.Diagnostics.Print_this_message + }, + { + 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: { + "preserve": 1 /* Preserve */, + "react": 2 /* React */ + }, + paramType: ts.Diagnostics.KIND, + description: ts.Diagnostics.Specify_JSX_code_generation_Colon_preserve_or_react, + error: ts.Diagnostics.Argument_for_jsx_must_be_preserve_or_react + }, + { + name: "listFiles", + type: "boolean" + }, + { + name: "locale", + type: "string" + }, + { + name: "mapRoot", + type: "string", + isFilePath: true, + description: ts.Diagnostics.Specifies_the_location_where_debugger_should_locate_map_files_instead_of_generated_locations, + paramType: ts.Diagnostics.LOCATION + }, + { + name: "module", + shortName: "m", + type: { + "commonjs": 1 /* CommonJS */, + "amd": 2 /* AMD */, + "system": 4 /* System */, + "umd": 3 /* UMD */, + "es6": 5 /* ES6 */, + "es2015": 5 /* ES2015 */ + }, + description: ts.Diagnostics.Specify_module_code_generation_Colon_commonjs_amd_system_umd_or_es2015, + paramType: ts.Diagnostics.KIND, + error: ts.Diagnostics.Argument_for_module_option_must_be_commonjs_amd_system_umd_or_es2015 + }, + { + name: "newLine", + type: { + "crlf": 0 /* CarriageReturnLineFeed */, + "lf": 1 /* LineFeed */ + }, + description: ts.Diagnostics.Specifies_the_end_of_line_sequence_to_be_used_when_emitting_files_Colon_CRLF_dos_or_LF_unix, + paramType: ts.Diagnostics.NEWLINE, + error: ts.Diagnostics.Argument_for_newLine_option_must_be_CRLF_or_LF + }, + { + 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: "noImplicitAny", + type: "boolean", + description: ts.Diagnostics.Raise_error_on_expressions_and_declarations_with_an_implied_any_type + }, + { + name: "noLib", + type: "boolean" + }, + { + name: "noResolve", + type: "boolean" + }, + { + name: "skipDefaultLibCheck", + type: "boolean" + }, + { + name: "out", + type: "string", + isFilePath: false, + // for correct behaviour, please use outFile + 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: "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, + description: ts.Diagnostics.Specifies_the_root_directory_of_input_files_Use_to_control_the_output_directory_structure_with_outDir, + paramType: ts.Diagnostics.LOCATION + }, + { + name: "isolatedModules", + type: "boolean" + }, + { + name: "sourceMap", + type: "boolean", + description: ts.Diagnostics.Generates_corresponding_map_file + }, + { + name: "sourceRoot", + type: "string", + isFilePath: true, + description: ts.Diagnostics.Specifies_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: { + "es3": 0 /* ES3 */, + "es5": 1 /* ES5 */, + "es6": 2 /* ES6 */, + "es2015": 2 /* ES2015 */ + }, + description: ts.Diagnostics.Specify_ECMAScript_target_version_Colon_ES3_default_ES5_or_ES2015_experimental, + paramType: ts.Diagnostics.VERSION, + error: ts.Diagnostics.Argument_for_target_option_must_be_ES3_ES5_or_ES2015 + }, + { + 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: { + "node": 2 /* NodeJs */, + "classic": 1 /* Classic */ + }, + description: ts.Diagnostics.Specifies_module_resolution_strategy_Colon_node_Node_js_or_classic_TypeScript_pre_1_6, + error: ts.Diagnostics.Argument_for_moduleResolution_option_must_be_node_or_classic + }, + { + name: "forceConsistentCasingInFileNames", + type: "boolean", + description: ts.Diagnostics.Disallow_inconsistently_cased_references_to_the_same_file + }, + ]; + var optionNameMapCache; + /* @internal */ + function getOptionNameMap() { + if (optionNameMapCache) { + return optionNameMapCache; + } + var optionNameMap = {}; + var shortOptionNames = {}; + 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 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++]; + if (s.charCodeAt(0) === 64 /* at */) { + parseResponseFile(s.slice(1)); + } + else if (s.charCodeAt(0) === 45 /* minus */) { + s = s.slice(s.charCodeAt(1) === 45 /* minus */ ? 2 : 1).toLowerCase(); + // Try to translate short option names to their full equivalents. + if (ts.hasProperty(shortOptionNames, s)) { + s = shortOptionNames[s]; + } + if (ts.hasProperty(optionNameMap, s)) { + var opt = optionNameMap[s]; + // Check to see if no argument was provided (e.g. "--locale" is the last command-line argument). + 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++]); + break; + case "boolean": + options[opt.name] = true; + break; + case "string": + options[opt.name] = args[i++] || ""; + break; + // If not a primitive, the possible types are specified in what is effectively a map of options. + default: + var map_2 = opt.type; + var key = (args[i++] || "").toLowerCase(); + if (ts.hasProperty(map_2, key)) { + options[opt.name] = map_2[key]; + } + else { + errors.push(ts.createCompilerDiagnostic(opt.error)); + } + } + } + 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 /* space */) + pos++; + if (pos >= text.length) + break; + var start = pos; + if (text.charCodeAt(start) === 34 /* doubleQuote */) { + pos++; + while (pos < text.length && text.charCodeAt(pos) !== 34 /* doubleQuote */) + 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 /* space */) + pos++; + args.push(text.substring(start, pos)); + } + } + parseStrings(args); + } + } + ts.parseCommandLine = parseCommandLine; + /** + * Read tsconfig.json file + * @param fileName The path to the config file + */ + 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; + /** + * Parse the text of the tsconfig.json file + * @param fileName The path to the config file + * @param jsonText The text of the config file + */ + function parseConfigFileTextToJson(fileName, jsonText) { + try { + return { config: /\S/.test(jsonText) ? JSON.parse(jsonText) : {} }; + } + catch (e) { + return { error: ts.createCompilerDiagnostic(ts.Diagnostics.Failed_to_parse_file_0_Colon_1, fileName, e.message) }; + } + } + ts.parseConfigFileTextToJson = parseConfigFileTextToJson; + /** + * Parse the contents of a config file (tsconfig.json). + * @param json The contents of the config file to parse + * @param host Instance of ParseConfigHost used to enumerate files in folder. + * @param basePath A root directory to resolve relative path entries in the config + * file to. e.g. outDir + */ + function parseJsonConfigFileContent(json, host, basePath) { + var _a = convertCompilerOptionsFromJson(json["compilerOptions"], basePath), options = _a.options, errors = _a.errors; + return { + options: options, + fileNames: getFileNames(), + errors: errors + }; + function getFileNames() { + var fileNames = []; + if (ts.hasProperty(json, "files")) { + if (json["files"] instanceof Array) { + fileNames = ts.map(json["files"], function (s) { return ts.combinePaths(basePath, s); }); + } + else { + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Compiler_option_0_requires_a_value_of_type_1, "files", "Array")); + } + } + else { + var exclude = json["exclude"] instanceof Array ? ts.map(json["exclude"], ts.normalizeSlashes) : undefined; + var sysFiles = host.readDirectory(basePath, ".ts", exclude).concat(host.readDirectory(basePath, ".tsx", exclude)); + for (var i = 0; i < sysFiles.length; i++) { + var name_29 = sysFiles[i]; + if (ts.fileExtensionIs(name_29, ".d.ts")) { + var baseName = name_29.substr(0, name_29.length - ".d.ts".length); + if (!ts.contains(sysFiles, baseName + ".tsx") && !ts.contains(sysFiles, baseName + ".ts")) { + fileNames.push(name_29); + } + } + else if (ts.fileExtensionIs(name_29, ".ts")) { + if (!ts.contains(sysFiles, name_29 + "x")) { + fileNames.push(name_29); + } + } + else { + fileNames.push(name_29); + } + } + } + return fileNames; + } + } + ts.parseJsonConfigFileContent = parseJsonConfigFileContent; + function convertCompilerOptionsFromJson(jsonOptions, basePath) { + var options = {}; + var errors = []; + if (!jsonOptions) { + return { options: options, errors: errors }; + } + var optionNameMap = ts.arrayToMap(ts.optionDeclarations, function (opt) { return opt.name; }); + for (var id in jsonOptions) { + if (ts.hasProperty(optionNameMap, id)) { + var opt = optionNameMap[id]; + var optType = opt.type; + var value = jsonOptions[id]; + var expectedType = typeof optType === "string" ? optType : "string"; + if (typeof value === expectedType) { + if (typeof optType !== "string") { + var key = value.toLowerCase(); + if (ts.hasProperty(optType, key)) { + value = optType[key]; + } + else { + errors.push(ts.createCompilerDiagnostic(opt.error)); + value = 0; + } + } + if (opt.isFilePath) { + value = ts.normalizePath(ts.combinePaths(basePath, value)); + if (value === "") { + value = "."; + } + } + options[opt.name] = value; + } + else { + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Compiler_option_0_requires_a_value_of_type_1, id, expectedType)); + } + } + else { + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Unknown_compiler_option_0, id)); + } + } + return { options: options, errors: errors }; + } + ts.convertCompilerOptionsFromJson = convertCompilerOptionsFromJson; +})(ts || (ts = {})); +/* @internal */ +var ts; +(function (ts) { + var OutliningElementsCollector; + (function (OutliningElementsCollector) { + function collectElements(sourceFile) { + var elements = []; + var collapseText = "..."; + function addOutliningSpan(hintSpanNode, startElement, endElement, autoCollapse) { + if (hintSpanNode && startElement && endElement) { + var span = { + textSpan: ts.createTextSpanFromBounds(startElement.pos, endElement.end), + hintSpan: ts.createTextSpanFromBounds(hintSpanNode.getStart(), hintSpanNode.end), + bannerText: collapseText, + autoCollapse: autoCollapse + }; + elements.push(span); + } + } + function addOutliningSpanComments(commentSpan, autoCollapse) { + if (commentSpan) { + var span = { + textSpan: ts.createTextSpanFromBounds(commentSpan.pos, commentSpan.end), + hintSpan: ts.createTextSpanFromBounds(commentSpan.pos, commentSpan.end), + bannerText: collapseText, + autoCollapse: autoCollapse + }; + elements.push(span); + } + } + function addOutliningForLeadingCommentsForNode(n) { + var comments = ts.getLeadingCommentRangesOfNode(n, sourceFile); + if (comments) { + var firstSingleLineCommentStart = -1; + var lastSingleLineCommentEnd = -1; + var isFirstSingleLineComment = true; + var singleLineCommentCount = 0; + for (var _i = 0; _i < comments.length; _i++) { + var currentComment = comments[_i]; + // For single line comments, combine consecutive ones (2 or more) into + // a single span from the start of the first till the end of the last + if (currentComment.kind === 2 /* SingleLineCommentTrivia */) { + if (isFirstSingleLineComment) { + firstSingleLineCommentStart = currentComment.pos; + } + isFirstSingleLineComment = false; + lastSingleLineCommentEnd = currentComment.end; + singleLineCommentCount++; + } + else if (currentComment.kind === 3 /* MultiLineCommentTrivia */) { + combineAndAddMultipleSingleLineComments(singleLineCommentCount, firstSingleLineCommentStart, lastSingleLineCommentEnd); + addOutliningSpanComments(currentComment, /*autoCollapse*/ false); + singleLineCommentCount = 0; + lastSingleLineCommentEnd = -1; + isFirstSingleLineComment = true; + } + } + combineAndAddMultipleSingleLineComments(singleLineCommentCount, firstSingleLineCommentStart, lastSingleLineCommentEnd); + } + } + function combineAndAddMultipleSingleLineComments(count, start, end) { + // Only outline spans of two or more consecutive single line comments + if (count > 1) { + var multipleSingleLineComments = { + pos: start, + end: end, + kind: 2 /* SingleLineCommentTrivia */ + }; + addOutliningSpanComments(multipleSingleLineComments, /*autoCollapse*/ false); + } + } + function autoCollapse(node) { + return ts.isFunctionBlock(node) && node.parent.kind !== 174 /* ArrowFunction */; + } + var depth = 0; + var maxDepth = 20; + function walk(n) { + if (depth > maxDepth) { + return; + } + if (ts.isDeclaration(n)) { + addOutliningForLeadingCommentsForNode(n); + } + switch (n.kind) { + case 192 /* Block */: + if (!ts.isFunctionBlock(n)) { + var parent_7 = n.parent; + var openBrace = ts.findChildOfKind(n, 15 /* OpenBraceToken */, sourceFile); + var closeBrace = ts.findChildOfKind(n, 16 /* CloseBraceToken */, sourceFile); + // Check if the block is standalone, or 'attached' to some parent statement. + // If the latter, we want to collaps the block, but consider its hint span + // to be the entire span of the parent. + if (parent_7.kind === 197 /* DoStatement */ || + parent_7.kind === 200 /* ForInStatement */ || + parent_7.kind === 201 /* ForOfStatement */ || + parent_7.kind === 199 /* ForStatement */ || + parent_7.kind === 196 /* IfStatement */ || + parent_7.kind === 198 /* WhileStatement */ || + parent_7.kind === 205 /* WithStatement */ || + parent_7.kind === 244 /* CatchClause */) { + addOutliningSpan(parent_7, openBrace, closeBrace, autoCollapse(n)); + break; + } + if (parent_7.kind === 209 /* TryStatement */) { + // Could be the try-block, or the finally-block. + var tryStatement = parent_7; + if (tryStatement.tryBlock === n) { + addOutliningSpan(parent_7, openBrace, closeBrace, autoCollapse(n)); + break; + } + else if (tryStatement.finallyBlock === n) { + var finallyKeyword = ts.findChildOfKind(tryStatement, 85 /* FinallyKeyword */, sourceFile); + if (finallyKeyword) { + addOutliningSpan(finallyKeyword, openBrace, closeBrace, autoCollapse(n)); + break; + } + } + } + // Block was a standalone block. In this case we want to only collapse + // the span of the block, independent of any parent span. + var span = ts.createTextSpanFromBounds(n.getStart(), n.end); + elements.push({ + textSpan: span, + hintSpan: span, + bannerText: collapseText, + autoCollapse: autoCollapse(n) + }); + break; + } + // Fallthrough. + case 219 /* ModuleBlock */: { + var openBrace = ts.findChildOfKind(n, 15 /* OpenBraceToken */, sourceFile); + var closeBrace = ts.findChildOfKind(n, 16 /* CloseBraceToken */, sourceFile); + addOutliningSpan(n.parent, openBrace, closeBrace, autoCollapse(n)); + break; + } + case 214 /* ClassDeclaration */: + case 215 /* InterfaceDeclaration */: + case 217 /* EnumDeclaration */: + case 165 /* ObjectLiteralExpression */: + case 220 /* CaseBlock */: { + var openBrace = ts.findChildOfKind(n, 15 /* OpenBraceToken */, sourceFile); + var closeBrace = ts.findChildOfKind(n, 16 /* CloseBraceToken */, sourceFile); + addOutliningSpan(n, openBrace, closeBrace, autoCollapse(n)); + break; + } + case 164 /* ArrayLiteralExpression */: + var openBracket = ts.findChildOfKind(n, 19 /* OpenBracketToken */, sourceFile); + var closeBracket = ts.findChildOfKind(n, 20 /* CloseBracketToken */, sourceFile); + addOutliningSpan(n, openBracket, closeBracket, autoCollapse(n)); + break; + } + depth++; + ts.forEachChild(n, walk); + depth--; + } + walk(sourceFile); + return elements; + } + OutliningElementsCollector.collectElements = collectElements; + })(OutliningElementsCollector = ts.OutliningElementsCollector || (ts.OutliningElementsCollector = {})); +})(ts || (ts = {})); +/* @internal */ +var ts; +(function (ts) { + var NavigateTo; + (function (NavigateTo) { + function getNavigateToItems(program, cancellationToken, searchValue, maxResultCount) { + var patternMatcher = ts.createPatternMatcher(searchValue); + var rawItems = []; + // Search the declarations in all files and output matched NavigateToItem into array of NavigateToItem[] + ts.forEach(program.getSourceFiles(), function (sourceFile) { + cancellationToken.throwIfCancellationRequested(); + var nameToDeclarations = sourceFile.getNamedDeclarations(); + for (var name_30 in nameToDeclarations) { + var declarations = ts.getProperty(nameToDeclarations, name_30); + if (declarations) { + // First do a quick check to see if the name of the declaration matches the + // last portion of the (possibly) dotted name they're searching for. + var matches = patternMatcher.getMatchesForLastSegmentOfPattern(name_30); + if (!matches) { + continue; + } + for (var _i = 0; _i < declarations.length; _i++) { + var declaration = declarations[_i]; + // It was a match! If the pattern has dots in it, then also see if the + // declaration container matches as well. + if (patternMatcher.patternContainsDots) { + var containers = getContainers(declaration); + if (!containers) { + return undefined; + } + matches = patternMatcher.getMatches(containers, name_30); + if (!matches) { + continue; + } + } + var fileName = sourceFile.fileName; + var matchKind = bestMatchKind(matches); + rawItems.push({ name: name_30, fileName: fileName, matchKind: matchKind, isCaseSensitive: allMatchesAreCaseSensitive(matches), declaration: declaration }); + } + } + } + }); + rawItems.sort(compareNavigateToItems); + if (maxResultCount !== undefined) { + rawItems = rawItems.slice(0, maxResultCount); + } + var items = ts.map(rawItems, createNavigateToItem); + return items; + function allMatchesAreCaseSensitive(matches) { + ts.Debug.assert(matches.length > 0); + // This is a case sensitive match, only if all the submatches were case sensitive. + for (var _i = 0; _i < matches.length; _i++) { + var match = matches[_i]; + if (!match.isCaseSensitive) { + return false; + } + } + return true; + } + function getTextOfIdentifierOrLiteral(node) { + if (node) { + if (node.kind === 69 /* Identifier */ || + node.kind === 9 /* StringLiteral */ || + node.kind === 8 /* NumericLiteral */) { + return node.text; + } + } + return undefined; + } + function tryAddSingleDeclarationName(declaration, containers) { + if (declaration && declaration.name) { + var text = getTextOfIdentifierOrLiteral(declaration.name); + if (text !== undefined) { + containers.unshift(text); + } + else if (declaration.name.kind === 136 /* ComputedPropertyName */) { + return tryAddComputedPropertyName(declaration.name.expression, containers, /*includeLastPortion:*/ true); + } + else { + // Don't know how to add this. + return false; + } + } + return true; + } + // Only added the names of computed properties if they're simple dotted expressions, like: + // + // [X.Y.Z]() { } + function tryAddComputedPropertyName(expression, containers, includeLastPortion) { + var text = getTextOfIdentifierOrLiteral(expression); + if (text !== undefined) { + if (includeLastPortion) { + containers.unshift(text); + } + return true; + } + if (expression.kind === 166 /* PropertyAccessExpression */) { + var propertyAccess = expression; + if (includeLastPortion) { + containers.unshift(propertyAccess.name.text); + } + return tryAddComputedPropertyName(propertyAccess.expression, containers, /*includeLastPortion:*/ true); + } + return false; + } + function getContainers(declaration) { + 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 === 136 /* ComputedPropertyName */) { + if (!tryAddComputedPropertyName(declaration.name.expression, containers, /*includeLastPortion:*/ false)) { + return undefined; + } + } + // Now, walk up our containers, adding all their names to the container array. + declaration = ts.getContainerNode(declaration); + while (declaration) { + if (!tryAddSingleDeclarationName(declaration, containers)) { + return undefined; + } + declaration = ts.getContainerNode(declaration); + } + return containers; + } + function bestMatchKind(matches) { + ts.Debug.assert(matches.length > 0); + var bestMatchKind = ts.PatternMatchKind.camelCase; + for (var _i = 0; _i < matches.length; _i++) { + var match = matches[_i]; + var kind = match.kind; + if (kind < bestMatchKind) { + bestMatchKind = kind; + } + } + return bestMatchKind; + } + // This means "compare in a case insensitive manner." + var baseSensitivity = { sensitivity: "base" }; + function compareNavigateToItems(i1, i2) { + // TODO(cyrusn): get the gamut of comparisons that VS already uses here. + // Right now we just sort by kind first, and then by name of the item. + // 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); + } + function createNavigateToItem(rawItem) { + var declaration = rawItem.declaration; + var container = ts.getContainerNode(declaration); + return { + name: rawItem.name, + kind: ts.getNodeKind(declaration), + kindModifiers: ts.getNodeModifiers(declaration), + matchKind: ts.PatternMatchKind[rawItem.matchKind], + isCaseSensitive: rawItem.isCaseSensitive, + fileName: rawItem.fileName, + textSpan: ts.createTextSpanFromBounds(declaration.getStart(), declaration.getEnd()), + // TODO(jfreeman): What should be the containerName when the container has a computed name? + containerName: container && container.name ? container.name.text : "", + containerKind: container && container.name ? ts.getNodeKind(container) : "" + }; + } + } + NavigateTo.getNavigateToItems = getNavigateToItems; + })(NavigateTo = ts.NavigateTo || (ts.NavigateTo = {})); +})(ts || (ts = {})); +/// +/* @internal */ +var ts; +(function (ts) { + var NavigationBar; + (function (NavigationBar) { + function getNavigationBarItems(sourceFile) { + // If the source file has any child items, then it included in the tree + // and takes lexical ownership of all other top-level items. + var hasGlobalNode = false; + return getItemsWorker(getTopLevelNodes(sourceFile), createTopLevelItem); + function getIndent(node) { + // If we have a global node in the tree, + // then it adds an extra layer of depth to all subnodes. + var indent = hasGlobalNode ? 1 : 0; + var current = node.parent; + while (current) { + switch (current.kind) { + case 218 /* ModuleDeclaration */: + // If we have a module declared as A.B.C, it is more "intuitive" + // to say it only has a single layer of depth + do { + current = current.parent; + } while (current.kind === 218 /* ModuleDeclaration */); + // fall through + case 214 /* ClassDeclaration */: + case 217 /* EnumDeclaration */: + case 215 /* InterfaceDeclaration */: + case 213 /* FunctionDeclaration */: + indent++; + } + current = current.parent; + } + return indent; + } + function getChildNodes(nodes) { + var childNodes = []; + function visit(node) { + switch (node.kind) { + case 193 /* VariableStatement */: + ts.forEach(node.declarationList.declarations, visit); + break; + case 161 /* ObjectBindingPattern */: + case 162 /* ArrayBindingPattern */: + ts.forEach(node.elements, visit); + break; + case 228 /* ExportDeclaration */: + // Handle named exports case e.g.: + // export {a, b as B} from "mod"; + if (node.exportClause) { + ts.forEach(node.exportClause.elements, visit); + } + break; + case 222 /* ImportDeclaration */: + var importClause = node.importClause; + if (importClause) { + // Handle default import case e.g.: + // import d from "mod"; + if (importClause.name) { + childNodes.push(importClause); + } + // Handle named bindings in imports e.g.: + // import * as NS from "mod"; + // import {a, b as B} from "mod"; + if (importClause.namedBindings) { + if (importClause.namedBindings.kind === 224 /* NamespaceImport */) { + childNodes.push(importClause.namedBindings); + } + else { + ts.forEach(importClause.namedBindings.elements, visit); + } + } + } + break; + case 163 /* BindingElement */: + case 211 /* VariableDeclaration */: + if (ts.isBindingPattern(node.name)) { + visit(node.name); + break; + } + // Fall through + case 214 /* ClassDeclaration */: + case 217 /* EnumDeclaration */: + case 215 /* InterfaceDeclaration */: + case 218 /* ModuleDeclaration */: + case 213 /* FunctionDeclaration */: + case 221 /* ImportEqualsDeclaration */: + case 226 /* ImportSpecifier */: + case 230 /* ExportSpecifier */: + childNodes.push(node); + break; + } + } + //for (let i = 0, n = nodes.length; i < n; i++) { + // let node = nodes[i]; + // if (node.kind === SyntaxKind.ClassDeclaration || + // node.kind === SyntaxKind.EnumDeclaration || + // node.kind === SyntaxKind.InterfaceDeclaration || + // node.kind === SyntaxKind.ModuleDeclaration || + // node.kind === SyntaxKind.FunctionDeclaration) { + // childNodes.push(node); + // } + // else if (node.kind === SyntaxKind.VariableStatement) { + // childNodes.push.apply(childNodes, (node).declarations); + // } + //} + ts.forEach(nodes, visit); + return sortNodes(childNodes); + } + function getTopLevelNodes(node) { + var topLevelNodes = []; + topLevelNodes.push(node); + addTopLevelNodes(node.statements, topLevelNodes); + return topLevelNodes; + } + function sortNodes(nodes) { + return nodes.slice(0).sort(function (n1, n2) { + if (n1.name && n2.name) { + return ts.getPropertyNameForPropertyNameNode(n1.name).localeCompare(ts.getPropertyNameForPropertyNameNode(n2.name)); + } + else if (n1.name) { + return 1; + } + else if (n2.name) { + return -1; + } + else { + return n1.kind - n2.kind; + } + }); + } + function addTopLevelNodes(nodes, topLevelNodes) { + nodes = sortNodes(nodes); + for (var _i = 0; _i < nodes.length; _i++) { + var node = nodes[_i]; + switch (node.kind) { + case 214 /* ClassDeclaration */: + case 217 /* EnumDeclaration */: + case 215 /* InterfaceDeclaration */: + topLevelNodes.push(node); + break; + case 218 /* ModuleDeclaration */: + var moduleDeclaration = node; + topLevelNodes.push(node); + addTopLevelNodes(getInnermostModule(moduleDeclaration).body.statements, topLevelNodes); + break; + case 213 /* FunctionDeclaration */: + var functionDeclaration = node; + if (isTopLevelFunctionDeclaration(functionDeclaration)) { + topLevelNodes.push(node); + addTopLevelNodes(functionDeclaration.body.statements, topLevelNodes); + } + break; + } + } + } + function isTopLevelFunctionDeclaration(functionDeclaration) { + if (functionDeclaration.kind === 213 /* FunctionDeclaration */) { + // A function declaration is 'top level' if it contains any function declarations + // within it. + if (functionDeclaration.body && functionDeclaration.body.kind === 192 /* Block */) { + // Proper function declarations can only have identifier names + if (ts.forEach(functionDeclaration.body.statements, function (s) { return s.kind === 213 /* FunctionDeclaration */ && !isEmpty(s.name.text); })) { + return true; + } + // Or if it is not parented by another function. i.e all functions + // at module scope are 'top level'. + if (!ts.isFunctionBlock(functionDeclaration.parent)) { + return true; + } + } + } + return false; + } + function getItemsWorker(nodes, createItem) { + var items = []; + var keyToItem = {}; + for (var _i = 0; _i < nodes.length; _i++) { + var child = nodes[_i]; + var item = createItem(child); + if (item !== undefined) { + if (item.text.length > 0) { + var key = item.text + "-" + item.kind + "-" + item.indent; + var itemWithSameName = keyToItem[key]; + if (itemWithSameName) { + // We had an item with the same name. Merge these items together. + merge(itemWithSameName, item); + } + else { + keyToItem[key] = item; + items.push(item); + } + } + } + } + return items; + } + function merge(target, source) { + // First, add any spans in the source to the target. + ts.addRange(target.spans, source.spans); + if (source.childItems) { + if (!target.childItems) { + target.childItems = []; + } + // Next, recursively merge or add any children in the source as appropriate. + outer: for (var _i = 0, _a = source.childItems; _i < _a.length; _i++) { + var sourceChild = _a[_i]; + for (var _b = 0, _c = target.childItems; _b < _c.length; _b++) { + var targetChild = _c[_b]; + if (targetChild.text === sourceChild.text && targetChild.kind === sourceChild.kind) { + // Found a match. merge them. + merge(targetChild, sourceChild); + continue outer; + } + } + // Didn't find a match, just add this child to the list. + target.childItems.push(sourceChild); + } + } + } + function createChildItem(node) { + switch (node.kind) { + case 138 /* Parameter */: + if (ts.isBindingPattern(node.name)) { + break; + } + if ((node.flags & 2035 /* Modifier */) === 0) { + return undefined; + } + return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberVariableElement); + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: + return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberFunctionElement); + case 145 /* GetAccessor */: + return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberGetAccessorElement); + case 146 /* SetAccessor */: + return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberSetAccessorElement); + case 149 /* IndexSignature */: + return createItem(node, "[]", ts.ScriptElementKind.indexSignatureElement); + case 247 /* EnumMember */: + return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberVariableElement); + case 147 /* CallSignature */: + return createItem(node, "()", ts.ScriptElementKind.callSignatureElement); + case 148 /* ConstructSignature */: + return createItem(node, "new()", ts.ScriptElementKind.constructSignatureElement); + case 141 /* PropertyDeclaration */: + case 140 /* PropertySignature */: + return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberVariableElement); + case 213 /* FunctionDeclaration */: + return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.functionElement); + case 211 /* VariableDeclaration */: + case 163 /* BindingElement */: + var variableDeclarationNode; + var name_31; + if (node.kind === 163 /* BindingElement */) { + name_31 = node.name; + variableDeclarationNode = node; + // binding elements are added only for variable declarations + // bubble up to the containing variable declaration + while (variableDeclarationNode && variableDeclarationNode.kind !== 211 /* VariableDeclaration */) { + variableDeclarationNode = variableDeclarationNode.parent; + } + ts.Debug.assert(variableDeclarationNode !== undefined); + } + else { + ts.Debug.assert(!ts.isBindingPattern(node.name)); + variableDeclarationNode = node; + name_31 = node.name; + } + if (ts.isConst(variableDeclarationNode)) { + return createItem(node, getTextOfNode(name_31), ts.ScriptElementKind.constElement); + } + else if (ts.isLet(variableDeclarationNode)) { + return createItem(node, getTextOfNode(name_31), ts.ScriptElementKind.letElement); + } + else { + return createItem(node, getTextOfNode(name_31), ts.ScriptElementKind.variableElement); + } + case 144 /* Constructor */: + return createItem(node, "constructor", ts.ScriptElementKind.constructorImplementationElement); + case 230 /* ExportSpecifier */: + case 226 /* ImportSpecifier */: + case 221 /* ImportEqualsDeclaration */: + case 223 /* ImportClause */: + case 224 /* NamespaceImport */: + return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.alias); + } + return undefined; + function createItem(node, name, scriptElementKind) { + return getNavigationBarItem(name, scriptElementKind, ts.getNodeModifiers(node), [getNodeSpan(node)]); + } + } + function isEmpty(text) { + return !text || text.trim() === ""; + } + function getNavigationBarItem(text, kind, kindModifiers, spans, childItems, indent) { + if (childItems === void 0) { childItems = []; } + if (indent === void 0) { indent = 0; } + if (isEmpty(text)) { + return undefined; + } + return { + text: text, + kind: kind, + kindModifiers: kindModifiers, + spans: spans, + childItems: childItems, + indent: indent, + bolded: false, + grayed: false + }; + } + function createTopLevelItem(node) { + switch (node.kind) { + case 248 /* SourceFile */: + return createSourceFileItem(node); + case 214 /* ClassDeclaration */: + return createClassItem(node); + case 217 /* EnumDeclaration */: + return createEnumItem(node); + case 215 /* InterfaceDeclaration */: + return createIterfaceItem(node); + case 218 /* ModuleDeclaration */: + return createModuleItem(node); + case 213 /* FunctionDeclaration */: + return createFunctionItem(node); + } + return undefined; + function getModuleName(moduleDeclaration) { + // We want to maintain quotation marks. + if (moduleDeclaration.name.kind === 9 /* StringLiteral */) { + return getTextOfNode(moduleDeclaration.name); + } + // 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 === 218 /* ModuleDeclaration */) { + moduleDeclaration = moduleDeclaration.body; + result.push(moduleDeclaration.name.text); + } + return result.join("."); + } + function createModuleItem(node) { + var moduleName = getModuleName(node); + var childItems = getItemsWorker(getChildNodes(getInnermostModule(node).body.statements), createChildItem); + return getNavigationBarItem(moduleName, ts.ScriptElementKind.moduleElement, ts.getNodeModifiers(node), [getNodeSpan(node)], childItems, getIndent(node)); + } + function createFunctionItem(node) { + if (node.body && node.body.kind === 192 /* Block */) { + var childItems = getItemsWorker(sortNodes(node.body.statements), createChildItem); + return getNavigationBarItem(!node.name ? "default" : node.name.text, ts.ScriptElementKind.functionElement, ts.getNodeModifiers(node), [getNodeSpan(node)], childItems, getIndent(node)); + } + return undefined; + } + function createSourceFileItem(node) { + var childItems = getItemsWorker(getChildNodes(node.statements), createChildItem); + if (childItems === undefined || childItems.length === 0) { + return undefined; + } + hasGlobalNode = true; + var rootName = ts.isExternalModule(node) + ? "\"" + ts.escapeString(ts.getBaseFileName(ts.removeFileExtension(ts.normalizePath(node.fileName)))) + "\"" + : ""; + return getNavigationBarItem(rootName, ts.ScriptElementKind.moduleElement, ts.ScriptElementKindModifier.none, [getNodeSpan(node)], childItems); + } + function createClassItem(node) { + var childItems; + if (node.members) { + var constructor = ts.forEach(node.members, function (member) { + return member.kind === 144 /* Constructor */ && member; + }); + // Add the constructor parameters in as children of the class (for property parameters). + // Note that *all non-binding pattern named* parameters will be added to the nodes array, but parameters that + // are not properties will be filtered out later by createChildItem. + var nodes = removeDynamicallyNamedProperties(node); + if (constructor) { + ts.addRange(nodes, ts.filter(constructor.parameters, function (p) { return !ts.isBindingPattern(p.name); })); + } + childItems = getItemsWorker(sortNodes(nodes), createChildItem); + } + var nodeName = !node.name ? "default" : node.name.text; + return getNavigationBarItem(nodeName, ts.ScriptElementKind.classElement, ts.getNodeModifiers(node), [getNodeSpan(node)], childItems, getIndent(node)); + } + function createEnumItem(node) { + var childItems = getItemsWorker(sortNodes(removeComputedProperties(node)), createChildItem); + return getNavigationBarItem(node.name.text, ts.ScriptElementKind.enumElement, ts.getNodeModifiers(node), [getNodeSpan(node)], childItems, getIndent(node)); + } + function createIterfaceItem(node) { + var childItems = getItemsWorker(sortNodes(removeDynamicallyNamedProperties(node)), createChildItem); + return getNavigationBarItem(node.name.text, ts.ScriptElementKind.interfaceElement, ts.getNodeModifiers(node), [getNodeSpan(node)], childItems, getIndent(node)); + } + } + function removeComputedProperties(node) { + return ts.filter(node.members, function (member) { return member.name === undefined || member.name.kind !== 136 /* ComputedPropertyName */; }); + } + /** + * Like removeComputedProperties, but retains the properties with well known symbol names + */ + function removeDynamicallyNamedProperties(node) { + return ts.filter(node.members, function (member) { return !ts.hasDynamicName(member); }); + } + function getInnermostModule(node) { + while (node.body.kind === 218 /* ModuleDeclaration */) { + node = node.body; + } + return node; + } + function getNodeSpan(node) { + return node.kind === 248 /* SourceFile */ + ? ts.createTextSpanFromBounds(node.getFullStart(), node.getEnd()) + : ts.createTextSpanFromBounds(node.getStart(), node.getEnd()); + } + function getTextOfNode(node) { + return ts.getTextOfNodeFromSourceText(sourceFile.text, node); + } + } + NavigationBar.getNavigationBarItems = getNavigationBarItems; + })(NavigationBar = ts.NavigationBar || (ts.NavigationBar = {})); +})(ts || (ts = {})); +/* @internal */ +var ts; +(function (ts) { + // Note(cyrusn): this enum is ordered from strongest match type to weakest match type. + (function (PatternMatchKind) { + PatternMatchKind[PatternMatchKind["exact"] = 0] = "exact"; + PatternMatchKind[PatternMatchKind["prefix"] = 1] = "prefix"; + PatternMatchKind[PatternMatchKind["substring"] = 2] = "substring"; + PatternMatchKind[PatternMatchKind["camelCase"] = 3] = "camelCase"; + })(ts.PatternMatchKind || (ts.PatternMatchKind = {})); + var PatternMatchKind = ts.PatternMatchKind; + function createPatternMatch(kind, punctuationStripped, isCaseSensitive, camelCaseWeight) { + return { + kind: kind, + punctuationStripped: punctuationStripped, + isCaseSensitive: isCaseSensitive, + camelCaseWeight: camelCaseWeight + }; + } + function createPatternMatcher(pattern) { + // We'll often see the same candidate string many times when searching (For example, when + // we see the name of a module that is used everywhere, or the name of an overload). As + // such, we cache the information we compute about the candidate for the life of this + // pattern matcher so we don't have to compute it multiple times. + var stringToWordSpans = {}; + pattern = pattern.trim(); + var fullPatternSegment = createSegment(pattern); + var dotSeparatedSegments = pattern.split(".").map(function (p) { return createSegment(p.trim()); }); + var invalidPattern = dotSeparatedSegments.length === 0 || ts.forEach(dotSeparatedSegments, segmentIsInvalid); + return { + getMatches: getMatches, + getMatchesForLastSegmentOfPattern: getMatchesForLastSegmentOfPattern, + patternContainsDots: dotSeparatedSegments.length > 1 + }; + // Quick checks so we can bail out when asked to match a candidate. + function skipMatch(candidate) { + return invalidPattern || !candidate; + } + function getMatchesForLastSegmentOfPattern(candidate) { + if (skipMatch(candidate)) { + return undefined; + } + return matchSegment(candidate, ts.lastOrUndefined(dotSeparatedSegments)); + } + function getMatches(candidateContainers, candidate) { + if (skipMatch(candidate)) { + return undefined; + } + // First, check that the last part of the dot separated pattern matches the name of the + // candidate. If not, then there's no point in proceeding and doing the more + // expensive work. + var candidateMatch = matchSegment(candidate, ts.lastOrUndefined(dotSeparatedSegments)); + if (!candidateMatch) { + return undefined; + } + candidateContainers = candidateContainers || []; + // -1 because the last part was checked against the name, and only the rest + // of the parts are checked against the container. + if (dotSeparatedSegments.length - 1 > candidateContainers.length) { + // There weren't enough container parts to match against the pattern parts. + // So this definitely doesn't match. + return undefined; + } + // So far so good. Now break up the container for the candidate and check if all + // the dotted parts match up correctly. + var totalMatch = candidateMatch; + for (var i = dotSeparatedSegments.length - 2, j = candidateContainers.length - 1; i >= 0; i--, j--) { + var segment = dotSeparatedSegments[i]; + var containerName = candidateContainers[j]; + var containerMatch = matchSegment(containerName, segment); + if (!containerMatch) { + // This container didn't match the pattern piece. So there's no match at all. + return undefined; + } + ts.addRange(totalMatch, containerMatch); + } + // Success, this symbol's full name matched against the dotted name the user was asking + // about. + return totalMatch; + } + function getWordSpans(word) { + if (!ts.hasProperty(stringToWordSpans, word)) { + stringToWordSpans[word] = breakIntoWordSpans(word); + } + return stringToWordSpans[word]; + } + function matchTextChunk(candidate, chunk, punctuationStripped) { + var index = indexOfIgnoringCase(candidate, chunk.textLowerCase); + if (index === 0) { + if (chunk.text.length === candidate.length) { + // a) Check if the part matches the candidate entirely, in an case insensitive or + // sensitive manner. If it does, return that there was an exact match. + return createPatternMatch(PatternMatchKind.exact, punctuationStripped, /*isCaseSensitive:*/ candidate === chunk.text); + } + else { + // b) Check if the part is a prefix of the candidate, in a case insensitive or sensitive + // manner. If it does, return that there was a prefix match. + return createPatternMatch(PatternMatchKind.prefix, punctuationStripped, /*isCaseSensitive:*/ startsWith(candidate, chunk.text)); + } + } + var isLowercase = chunk.isLowerCase; + if (isLowercase) { + if (index > 0) { + // c) If the part is entirely lowercase, then check if it is contained anywhere in the + // candidate in a case insensitive manner. If so, return that there was a substring + // match. + // + // Note: We only have a substring match if the lowercase part is prefix match of some + // word part. That way we don't match something like 'Class' when the user types 'a'. + // But we would match 'FooAttribute' (since 'Attribute' starts with 'a'). + var wordSpans = getWordSpans(candidate); + for (var _i = 0; _i < wordSpans.length; _i++) { + var span = wordSpans[_i]; + if (partStartsWith(candidate, span, chunk.text, /*ignoreCase:*/ true)) { + return createPatternMatch(PatternMatchKind.substring, punctuationStripped, + /*isCaseSensitive:*/ partStartsWith(candidate, span, chunk.text, /*ignoreCase:*/ false)); + } + } + } + } + else { + // d) If the part was not entirely lowercase, then check if it is contained in the + // candidate in a case *sensitive* manner. If so, return that there was a substring + // match. + if (candidate.indexOf(chunk.text) > 0) { + return createPatternMatch(PatternMatchKind.substring, punctuationStripped, /*isCaseSensitive:*/ true); + } + } + if (!isLowercase) { + // e) If the part was not entirely lowercase, then attempt a camel cased match as well. + if (chunk.characterSpans.length > 0) { + var candidateParts = getWordSpans(candidate); + var camelCaseWeight = tryCamelCaseMatch(candidate, candidateParts, chunk, /*ignoreCase:*/ false); + if (camelCaseWeight !== undefined) { + return createPatternMatch(PatternMatchKind.camelCase, punctuationStripped, /*isCaseSensitive:*/ true, /*camelCaseWeight:*/ camelCaseWeight); + } + camelCaseWeight = tryCamelCaseMatch(candidate, candidateParts, chunk, /*ignoreCase:*/ true); + if (camelCaseWeight !== undefined) { + return createPatternMatch(PatternMatchKind.camelCase, punctuationStripped, /*isCaseSensitive:*/ false, /*camelCaseWeight:*/ camelCaseWeight); + } + } + } + if (isLowercase) { + // f) Is the pattern a substring of the candidate starting on one of the candidate's word boundaries? + // We could check every character boundary start of the candidate for the pattern. However, that's + // an m * n operation in the wost case. Instead, find the first instance of the pattern + // substring, and see if it starts on a capital letter. It seems unlikely that the user will try to + // filter the list based on a substring that starts on a capital letter and also with a lowercase one. + // (Pattern: fogbar, Candidate: quuxfogbarFogBar). + if (chunk.text.length < candidate.length) { + if (index > 0 && isUpperCaseLetter(candidate.charCodeAt(index))) { + return createPatternMatch(PatternMatchKind.substring, punctuationStripped, /*isCaseSensitive:*/ false); + } + } + } + return undefined; + } + function containsSpaceOrAsterisk(text) { + for (var i = 0; i < text.length; i++) { + var ch = text.charCodeAt(i); + if (ch === 32 /* space */ || ch === 42 /* asterisk */) { + return true; + } + } + return false; + } + function matchSegment(candidate, segment) { + // First check if the segment matches as is. This is also useful if the segment contains + // characters we would normally strip when splitting into parts that we also may want to + // match in the candidate. For example if the segment is "@int" and the candidate is + // "@int", then that will show up as an exact match here. + // + // Note: if the segment contains a space or an asterisk then we must assume that it's a + // multi-word segment. + if (!containsSpaceOrAsterisk(segment.totalTextChunk.text)) { + var match = matchTextChunk(candidate, segment.totalTextChunk, /*punctuationStripped:*/ false); + if (match) { + return [match]; + } + } + // The logic for pattern matching is now as follows: + // + // 1) Break the segment passed in into words. Breaking is rather simple and a + // good way to think about it that if gives you all the individual alphanumeric words + // of the pattern. + // + // 2) For each word try to match the word against the candidate value. + // + // 3) Matching is as follows: + // + // a) Check if the word matches the candidate entirely, in an case insensitive or + // sensitive manner. If it does, return that there was an exact match. + // + // b) Check if the word is a prefix of the candidate, in a case insensitive or + // sensitive manner. If it does, return that there was a prefix match. + // + // c) If the word is entirely lowercase, then check if it is contained anywhere in the + // candidate in a case insensitive manner. If so, return that there was a substring + // match. + // + // Note: We only have a substring match if the lowercase part is prefix match of + // some word part. That way we don't match something like 'Class' when the user + // types 'a'. But we would match 'FooAttribute' (since 'Attribute' starts with + // 'a'). + // + // d) If the word was not entirely lowercase, then check if it is contained in the + // candidate in a case *sensitive* manner. If so, return that there was a substring + // match. + // + // e) If the word was not entirely lowercase, then attempt a camel cased match as + // well. + // + // f) The word is all lower case. Is it a case insensitive substring of the candidate starting + // on a part boundary of the candidate? + // + // Only if all words have some sort of match is the pattern considered matched. + var subWordTextChunks = segment.subWordTextChunks; + var matches = undefined; + for (var _i = 0; _i < subWordTextChunks.length; _i++) { + var subWordTextChunk = subWordTextChunks[_i]; + // Try to match the candidate with this word + var result = matchTextChunk(candidate, subWordTextChunk, /*punctuationStripped:*/ true); + if (!result) { + return undefined; + } + matches = matches || []; + matches.push(result); + } + return matches; + } + function partStartsWith(candidate, candidateSpan, pattern, ignoreCase, patternSpan) { + var patternPartStart = patternSpan ? patternSpan.start : 0; + var patternPartLength = patternSpan ? patternSpan.length : pattern.length; + if (patternPartLength > candidateSpan.length) { + // Pattern part is longer than the candidate part. There can never be a match. + return false; + } + if (ignoreCase) { + for (var i = 0; i < patternPartLength; i++) { + var ch1 = pattern.charCodeAt(patternPartStart + i); + var ch2 = candidate.charCodeAt(candidateSpan.start + i); + if (toLowerCase(ch1) !== toLowerCase(ch2)) { + return false; + } + } + } + else { + for (var i = 0; i < patternPartLength; i++) { + var ch1 = pattern.charCodeAt(patternPartStart + i); + var ch2 = candidate.charCodeAt(candidateSpan.start + i); + if (ch1 !== ch2) { + return false; + } + } + } + return true; + } + function tryCamelCaseMatch(candidate, candidateParts, chunk, ignoreCase) { + var chunkCharacterSpans = chunk.characterSpans; + // Note: we may have more pattern parts than candidate parts. This is because multiple + // pattern parts may match a candidate part. For example "SiUI" against "SimpleUI". + // We'll have 3 pattern parts Si/U/I against two candidate parts Simple/UI. However, U + // and I will both match in UI. + var currentCandidate = 0; + var currentChunkSpan = 0; + var firstMatch = undefined; + var contiguous = undefined; + while (true) { + // Let's consider our termination cases + if (currentChunkSpan === chunkCharacterSpans.length) { + // We did match! We shall assign a weight to this + var weight = 0; + // Was this contiguous? + if (contiguous) { + weight += 1; + } + // Did we start at the beginning of the candidate? + if (firstMatch === 0) { + weight += 2; + } + return weight; + } + else if (currentCandidate === candidateParts.length) { + // No match, since we still have more of the pattern to hit + return undefined; + } + var candidatePart = candidateParts[currentCandidate]; + var gotOneMatchThisCandidate = false; + // Consider the case of matching SiUI against SimpleUIElement. The candidate parts + // will be Simple/UI/Element, and the pattern parts will be Si/U/I. We'll match 'Si' + // against 'Simple' first. Then we'll match 'U' against 'UI'. However, we want to + // still keep matching pattern parts against that candidate part. + for (; currentChunkSpan < chunkCharacterSpans.length; currentChunkSpan++) { + var chunkCharacterSpan = chunkCharacterSpans[currentChunkSpan]; + if (gotOneMatchThisCandidate) { + // We've already gotten one pattern part match in this candidate. We will + // only continue trying to consumer pattern parts if the last part and this + // part are both upper case. + if (!isUpperCaseLetter(chunk.text.charCodeAt(chunkCharacterSpans[currentChunkSpan - 1].start)) || + !isUpperCaseLetter(chunk.text.charCodeAt(chunkCharacterSpans[currentChunkSpan].start))) { + break; + } + } + if (!partStartsWith(candidate, candidatePart, chunk.text, ignoreCase, chunkCharacterSpan)) { + break; + } + gotOneMatchThisCandidate = true; + firstMatch = firstMatch === undefined ? currentCandidate : firstMatch; + // If we were contiguous, then keep that value. If we weren't, then keep that + // value. If we don't know, then set the value to 'true' as an initial match is + // obviously contiguous. + contiguous = contiguous === undefined ? true : contiguous; + candidatePart = ts.createTextSpan(candidatePart.start + chunkCharacterSpan.length, candidatePart.length - chunkCharacterSpan.length); + } + // Check if we matched anything at all. If we didn't, then we need to unset the + // contiguous bit if we currently had it set. + // If we haven't set the bit yet, then that means we haven't matched anything so + // far, and we don't want to change that. + if (!gotOneMatchThisCandidate && contiguous !== undefined) { + contiguous = false; + } + // Move onto the next candidate. + currentCandidate++; + } + } + } + ts.createPatternMatcher = createPatternMatcher; + // Helper function to compare two matches to determine which is better. Matches are first + // ordered by kind (so all prefix matches always beat all substring matches). Then, if the + // match is a camel case match, the relative weights of the match are used to determine + // which is better (with a greater weight being better). Then if the match is of the same + // type, then a case sensitive match is considered better than an insensitive one. + function patternMatchCompareTo(match1, match2) { + return compareType(match1, match2) || + compareCamelCase(match1, match2) || + compareCase(match1, match2) || + comparePunctuation(match1, match2); + } + function comparePunctuation(result1, result2) { + // Consider a match to be better if it was successful without stripping punctuation + // versus a match that had to strip punctuation to succeed. + if (result1.punctuationStripped !== result2.punctuationStripped) { + return result1.punctuationStripped ? 1 : -1; + } + return 0; + } + function compareCase(result1, result2) { + if (result1.isCaseSensitive !== result2.isCaseSensitive) { + return result1.isCaseSensitive ? -1 : 1; + } + return 0; + } + function compareType(result1, result2) { + return result1.kind - result2.kind; + } + function compareCamelCase(result1, result2) { + if (result1.kind === PatternMatchKind.camelCase && result2.kind === PatternMatchKind.camelCase) { + // Swap the values here. If result1 has a higher weight, then we want it to come + // first. + return result2.camelCaseWeight - result1.camelCaseWeight; + } + return 0; + } + function createSegment(text) { + return { + totalTextChunk: createTextChunk(text), + subWordTextChunks: breakPatternIntoTextChunks(text) + }; + } + // A segment is considered invalid if we couldn't find any words in it. + function segmentIsInvalid(segment) { + return segment.subWordTextChunks.length === 0; + } + function isUpperCaseLetter(ch) { + // Fast check for the ascii range. + if (ch >= 65 /* A */ && ch <= 90 /* Z */) { + return true; + } + if (ch < 127 /* maxAsciiCharacter */ || !ts.isUnicodeIdentifierStart(ch, 2 /* Latest */)) { + return false; + } + // TODO: find a way to determine this for any unicode characters in a + // non-allocating manner. + var str = String.fromCharCode(ch); + return str === str.toUpperCase(); + } + function isLowerCaseLetter(ch) { + // Fast check for the ascii range. + if (ch >= 97 /* a */ && ch <= 122 /* z */) { + return true; + } + if (ch < 127 /* maxAsciiCharacter */ || !ts.isUnicodeIdentifierStart(ch, 2 /* Latest */)) { + return false; + } + // TODO: find a way to determine this for any unicode characters in a + // non-allocating manner. + var str = String.fromCharCode(ch); + return str === str.toLowerCase(); + } + function containsUpperCaseLetter(string) { + for (var i = 0, n = string.length; i < n; i++) { + if (isUpperCaseLetter(string.charCodeAt(i))) { + return true; + } + } + return false; + } + function startsWith(string, search) { + for (var i = 0, n = search.length; i < n; i++) { + if (string.charCodeAt(i) !== search.charCodeAt(i)) { + return false; + } + } + return true; + } + // Assumes 'value' is already lowercase. + function indexOfIgnoringCase(string, value) { + for (var i = 0, n = string.length - value.length; i <= n; i++) { + if (startsWithIgnoringCase(string, value, i)) { + return i; + } + } + return -1; + } + // Assumes 'value' is already lowercase. + function startsWithIgnoringCase(string, value, start) { + for (var i = 0, n = value.length; i < n; i++) { + var ch1 = toLowerCase(string.charCodeAt(i + start)); + var ch2 = value.charCodeAt(i); + if (ch1 !== ch2) { + return false; + } + } + return true; + } + function toLowerCase(ch) { + // Fast convert for the ascii range. + if (ch >= 65 /* A */ && ch <= 90 /* Z */) { + return 97 /* a */ + (ch - 65 /* A */); + } + if (ch < 127 /* maxAsciiCharacter */) { + return ch; + } + // TODO: find a way to compute this for any unicode characters in a + // non-allocating manner. + return String.fromCharCode(ch).toLowerCase().charCodeAt(0); + } + function isDigit(ch) { + // TODO(cyrusn): Find a way to support this for unicode digits. + return ch >= 48 /* _0 */ && ch <= 57 /* _9 */; + } + function isWordChar(ch) { + return isUpperCaseLetter(ch) || isLowerCaseLetter(ch) || isDigit(ch) || ch === 95 /* _ */ || ch === 36 /* $ */; + } + function breakPatternIntoTextChunks(pattern) { + var result = []; + var wordStart = 0; + var wordLength = 0; + for (var i = 0; i < pattern.length; i++) { + var ch = pattern.charCodeAt(i); + if (isWordChar(ch)) { + if (wordLength++ === 0) { + wordStart = i; + } + } + else { + if (wordLength > 0) { + result.push(createTextChunk(pattern.substr(wordStart, wordLength))); + wordLength = 0; + } + } + } + if (wordLength > 0) { + result.push(createTextChunk(pattern.substr(wordStart, wordLength))); + } + return result; + } + function createTextChunk(text) { + var textLowerCase = text.toLowerCase(); + return { + text: text, + textLowerCase: textLowerCase, + isLowerCase: text === textLowerCase, + characterSpans: breakIntoCharacterSpans(text) + }; + } + /* @internal */ function breakIntoCharacterSpans(identifier) { + return breakIntoSpans(identifier, /*word:*/ false); + } + ts.breakIntoCharacterSpans = breakIntoCharacterSpans; + /* @internal */ function breakIntoWordSpans(identifier) { + return breakIntoSpans(identifier, /*word:*/ true); + } + ts.breakIntoWordSpans = breakIntoWordSpans; + function breakIntoSpans(identifier, word) { + var result = []; + var wordStart = 0; + for (var i = 1, n = identifier.length; i < n; i++) { + var lastIsDigit = isDigit(identifier.charCodeAt(i - 1)); + var currentIsDigit = isDigit(identifier.charCodeAt(i)); + var hasTransitionFromLowerToUpper = transitionFromLowerToUpper(identifier, word, i); + var hasTransitionFromUpperToLower = transitionFromUpperToLower(identifier, word, i, wordStart); + if (charIsPunctuation(identifier.charCodeAt(i - 1)) || + charIsPunctuation(identifier.charCodeAt(i)) || + lastIsDigit !== currentIsDigit || + hasTransitionFromLowerToUpper || + hasTransitionFromUpperToLower) { + if (!isAllPunctuation(identifier, wordStart, i)) { + result.push(ts.createTextSpan(wordStart, i - wordStart)); + } + wordStart = i; + } + } + if (!isAllPunctuation(identifier, wordStart, identifier.length)) { + result.push(ts.createTextSpan(wordStart, identifier.length - wordStart)); + } + return result; + } + function charIsPunctuation(ch) { + switch (ch) { + case 33 /* exclamation */: + case 34 /* doubleQuote */: + case 35 /* hash */: + case 37 /* percent */: + case 38 /* ampersand */: + case 39 /* singleQuote */: + case 40 /* openParen */: + case 41 /* closeParen */: + case 42 /* asterisk */: + case 44 /* comma */: + case 45 /* minus */: + case 46 /* dot */: + case 47 /* slash */: + case 58 /* colon */: + case 59 /* semicolon */: + case 63 /* question */: + case 64 /* at */: + case 91 /* openBracket */: + case 92 /* backslash */: + case 93 /* closeBracket */: + case 95 /* _ */: + case 123 /* openBrace */: + case 125 /* closeBrace */: + return true; + } + return false; + } + function isAllPunctuation(identifier, start, end) { + for (var i = start; i < end; i++) { + var ch = identifier.charCodeAt(i); + // We don't consider _ or $ as punctuation as there may be things with that name. + if (!charIsPunctuation(ch) || ch === 95 /* _ */ || ch === 36 /* $ */) { + return false; + } + } + return true; + } + function transitionFromUpperToLower(identifier, word, index, wordStart) { + if (word) { + // Cases this supports: + // 1) IDisposable -> I, Disposable + // 2) UIElement -> UI, Element + // 3) HTMLDocument -> HTML, Document + // + // etc. + if (index !== wordStart && + index + 1 < identifier.length) { + var currentIsUpper = isUpperCaseLetter(identifier.charCodeAt(index)); + var nextIsLower = isLowerCaseLetter(identifier.charCodeAt(index + 1)); + if (currentIsUpper && nextIsLower) { + // We have a transition from an upper to a lower letter here. But we only + // want to break if all the letters that preceded are uppercase. i.e. if we + // have "Foo" we don't want to break that into "F, oo". But if we have + // "IFoo" or "UIFoo", then we want to break that into "I, Foo" and "UI, + // Foo". i.e. the last uppercase letter belongs to the lowercase letters + // that follows. Note: this will make the following not split properly: + // "HELLOthere". However, these sorts of names do not show up in .Net + // programs. + for (var i = wordStart; i < index; i++) { + if (!isUpperCaseLetter(identifier.charCodeAt(i))) { + return false; + } + } + return true; + } + } + } + return false; + } + function transitionFromLowerToUpper(identifier, word, index) { + var lastIsUpper = isUpperCaseLetter(identifier.charCodeAt(index - 1)); + var currentIsUpper = isUpperCaseLetter(identifier.charCodeAt(index)); + // See if the casing indicates we're starting a new word. Note: if we're breaking on + // words, then just seeing an upper case character isn't enough. Instead, it has to + // be uppercase and the previous character can't be uppercase. + // + // For example, breaking "AddMetadata" on words would make: Add Metadata + // + // on characters would be: A dd M etadata + // + // Break "AM" on words would be: AM + // + // on characters would be: A M + // + // We break the search string on characters. But we break the symbol name on words. + var transition = word + ? (currentIsUpper && !lastIsUpper) + : currentIsUpper; + return transition; + } +})(ts || (ts = {})); +/// +/* @internal */ +var ts; +(function (ts) { + var SignatureHelp; + (function (SignatureHelp) { + // A partially written generic type expression is not guaranteed to have the correct syntax tree. the expression could be parsed as less than/greater than expression or a comma expression + // or some other combination depending on what the user has typed so far. For the purposes of signature help we need to consider any location after "<" as a possible generic type reference. + // To do this, the method will back parse the expression starting at the position required. it will try to parse the current expression as a generic type expression, if it did succeed it + // will return the generic identifier that started the expression (e.g. "foo" in "foo(#a, b) -> The token introduces a list, and should begin a sig help session + // Case 2: + // fo#o#(a, b)# -> The token is either not associated with a list, or ends a list, so the session should end + // 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 */) { + // 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); + var isTypeArgList = callExpression.typeArguments && callExpression.typeArguments.pos === list.pos; + ts.Debug.assert(list !== undefined); + return { + kind: isTypeArgList ? 0 /* TypeArguments */ : 1 /* CallArguments */, + invocation: callExpression, + argumentsSpan: getApplicableSpanForArguments(list), + argumentIndex: 0, + argumentCount: getArgumentCount(list) + }; + } + // findListItemInfo can return undefined if we are not in parent's argument list + // or type argument list. This includes cases where the cursor is: + // - To the right of the closing paren, non-substitution template, or template tail. + // - Between the type arguments and the arguments (greater than token) + // - On the target of the call (parent.func) + // - On the 'new' keyword in a 'new' expression + var listItemInfo = ts.findListItemInfo(node); + if (listItemInfo) { + var list = listItemInfo.list; + var isTypeArgList = callExpression.typeArguments && callExpression.typeArguments.pos === list.pos; + var argumentIndex = getArgumentIndex(list, node); + var argumentCount = getArgumentCount(list); + ts.Debug.assert(argumentIndex === 0 || argumentIndex < argumentCount, "argumentCount < argumentIndex, " + argumentCount + " < " + argumentIndex); + return { + kind: isTypeArgList ? 0 /* TypeArguments */ : 1 /* CallArguments */, + invocation: callExpression, + argumentsSpan: getApplicableSpanForArguments(list), + argumentIndex: argumentIndex, + argumentCount: argumentCount + }; + } + } + else if (node.kind === 11 /* NoSubstitutionTemplateLiteral */ && node.parent.kind === 170 /* TaggedTemplateExpression */) { + // Check if we're actually inside the template; + // otherwise we'll fall out and return undefined. + if (ts.isInsideTemplateLiteral(node, position)) { + return getArgumentListInfoForTemplate(node.parent, /*argumentIndex*/ 0); + } + } + else if (node.kind === 12 /* TemplateHead */ && node.parent.parent.kind === 170 /* TaggedTemplateExpression */) { + var templateExpression = node.parent; + var tagExpression = templateExpression.parent; + ts.Debug.assert(templateExpression.kind === 183 /* TemplateExpression */); + var argumentIndex = ts.isInsideTemplateLiteral(node, position) ? 0 : 1; + return getArgumentListInfoForTemplate(tagExpression, argumentIndex); + } + else if (node.parent.kind === 190 /* TemplateSpan */ && node.parent.parent.parent.kind === 170 /* TaggedTemplateExpression */) { + var templateSpan = node.parent; + var templateExpression = templateSpan.parent; + var tagExpression = templateExpression.parent; + ts.Debug.assert(templateExpression.kind === 183 /* TemplateExpression */); + // If we're just after a template tail, don't show signature help. + if (node.kind === 14 /* TemplateTail */ && !ts.isInsideTemplateLiteral(node, position)) { + return undefined; + } + var spanIndex = templateExpression.templateSpans.indexOf(templateSpan); + var argumentIndex = getArgumentIndexForTemplatePiece(spanIndex, node); + return getArgumentListInfoForTemplate(tagExpression, argumentIndex); + } + return undefined; + } + function getArgumentIndex(argumentsList, node) { + // The list we got back can include commas. In the presence of errors it may + // also just have nodes without commas. For example "Foo(a b c)" will have 3 + // args without commas. We want to find what index we're at. So we count + // forward until we hit ourselves, only incrementing the index if it isn't a + // comma. + // + // Note: the subtlety around trailing commas (in getArgumentCount) does not apply + // here. That's because we're only walking forward until we hit the node we're + // on. In that case, even if we're after the trailing comma, we'll still see + // that trailing comma in the list, and we'll have generated the appropriate + // arg index. + var argumentIndex = 0; + var listChildren = argumentsList.getChildren(); + for (var _i = 0; _i < listChildren.length; _i++) { + var child = listChildren[_i]; + if (child === node) { + break; + } + if (child.kind !== 24 /* CommaToken */) { + argumentIndex++; + } + } + return argumentIndex; + } + function getArgumentCount(argumentsList) { + // The argument count for a list is normally the number of non-comma children it has. + // For example, if you have "Foo(a,b)" then there will be three children of the arg + // list 'a' '' 'b'. So, in this case the arg count will be 2. However, there + // is a small subtlety. If you have "Foo(a,)", then the child list will just have + // 'a' ''. So, in the case where the last child is a comma, we increase the + // arg count by one to compensate. + // + // Note: this subtlety only applies to the last comma. If you had "Foo(a,," then + // we'll have: 'a' '' '' + // 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 */) { + argumentCount++; + } + return argumentCount; + } + // spanIndex is either the index for a given template span. + // This does not give appropriate results for a NoSubstitutionTemplateLiteral + function getArgumentIndexForTemplatePiece(spanIndex, node) { + // Because the TemplateStringsArray is the first argument, we have to offset each substitution expression by 1. + // There are three cases we can encounter: + // 1. We are precisely in the template literal (argIndex = 0). + // 2. We are in or to the right of the substitution expression (argIndex = spanIndex + 1). + // 3. We are directly to the right of the template literal, but because we look for the token on the left, + // not enough to put us in the substitution expression; we should consider ourselves part of + // the *next* span's expression by offsetting the index (argIndex = (spanIndex + 1) + 1). + // + // Example: f `# abcd $#{# 1 + 1# }# efghi ${ #"#hello"# } # ` + // ^ ^ ^ ^ ^ ^ ^ ^ ^ + // Case: 1 1 3 2 1 3 2 2 1 + ts.Debug.assert(position >= node.getStart(), "Assumed 'position' could not occur before node."); + if (ts.isTemplateLiteralKind(node.kind)) { + if (ts.isInsideTemplateLiteral(node, position)) { + return 0; + } + return spanIndex + 2; + } + return spanIndex + 1; + } + function getArgumentListInfoForTemplate(tagExpression, argumentIndex) { + // argumentCount is either 1 or (numSpans + 1) to account for the template strings array argument. + var argumentCount = tagExpression.template.kind === 11 /* NoSubstitutionTemplateLiteral */ + ? 1 + : tagExpression.template.templateSpans.length + 1; + ts.Debug.assert(argumentIndex === 0 || argumentIndex < argumentCount, "argumentCount < argumentIndex, " + argumentCount + " < " + argumentIndex); + return { + kind: 2 /* TaggedTemplateArguments */, + invocation: tagExpression, + argumentsSpan: getApplicableSpanForTaggedTemplate(tagExpression), + argumentIndex: argumentIndex, + argumentCount: argumentCount + }; + } + function getApplicableSpanForArguments(argumentsList) { + // We use full start and skip trivia on the end because we want to include trivia on + // both sides. For example, + // + // foo( /*comment */ a, b, c /*comment*/ ) + // | | + // + // The applicable span is from the first bar to the second bar (inclusive, + // but not including parentheses) + var applicableSpanStart = argumentsList.getFullStart(); + var applicableSpanEnd = ts.skipTrivia(sourceFile.text, argumentsList.getEnd(), /*stopAfterLineBreak*/ false); + return ts.createTextSpan(applicableSpanStart, applicableSpanEnd - applicableSpanStart); + } + function getApplicableSpanForTaggedTemplate(taggedTemplate) { + var template = taggedTemplate.template; + var applicableSpanStart = template.getStart(); + var applicableSpanEnd = template.getEnd(); + // We need to adjust the end position for the case where the template does not have a tail. + // Otherwise, we will not show signature help past the expression. + // For example, + // + // ` ${ 1 + 1 foo(10) + // | | + // + // 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 === 183 /* TemplateExpression */) { + var lastSpan = ts.lastOrUndefined(template.templateSpans); + if (lastSpan.literal.getFullWidth() === 0) { + applicableSpanEnd = ts.skipTrivia(sourceFile.text, applicableSpanEnd, /*stopAfterLineBreak*/ false); + } + } + return ts.createTextSpan(applicableSpanStart, applicableSpanEnd - applicableSpanStart); + } + function getContainingArgumentInfo(node) { + for (var n = node; n.kind !== 248 /* SourceFile */; n = n.parent) { + if (ts.isFunctionBlock(n)) { + return undefined; + } + // If the node is not a subspan of its parent, this is a big problem. + // There have been crashes that might be caused by this violation. + if (n.pos < n.parent.pos || n.end > n.parent.end) { + ts.Debug.fail("Node of kind " + n.kind + " is not a subspan of its parent of kind " + n.parent.kind); + } + var argumentInfo_1 = getImmediatelyContainingArgumentInfo(n); + if (argumentInfo_1) { + return argumentInfo_1; + } + } + return undefined; + } + function getChildListThatStartsWithOpenerToken(parent, openerToken, sourceFile) { + var children = parent.getChildren(sourceFile); + var indexOfOpenerToken = children.indexOf(openerToken); + ts.Debug.assert(indexOfOpenerToken >= 0 && children.length > indexOfOpenerToken + 1); + return children[indexOfOpenerToken + 1]; + } + /** + * The selectedItemIndex could be negative for several reasons. + * 1. There are too many arguments for all of the overloads + * 2. None of the overloads were type compatible + * The solution here is to try to pick the best overload by picking + * either the first one that has an appropriate number of parameters, + * or the one with the most parameters. + */ + function selectBestInvalidOverloadIndex(candidates, argumentCount) { + var maxParamsSignatureIndex = -1; + var maxParams = -1; + for (var i = 0; i < candidates.length; i++) { + var candidate = candidates[i]; + if (candidate.hasRestParameter || candidate.parameters.length >= argumentCount) { + return i; + } + if (candidate.parameters.length > maxParams) { + maxParams = candidate.parameters.length; + maxParamsSignatureIndex = i; + } + } + return maxParamsSignatureIndex; + } + function createSignatureHelpItems(candidates, bestSignature, argumentListInfo) { + var applicableSpan = argumentListInfo.argumentsSpan; + var isTypeParameterList = argumentListInfo.kind === 0 /* TypeArguments */; + var invocation = argumentListInfo.invocation; + var callTarget = ts.getInvokedExpression(invocation); + var callTargetSymbol = typeChecker.getSymbolAtLocation(callTarget); + var callTargetDisplayParts = callTargetSymbol && ts.symbolToDisplayParts(typeChecker, callTargetSymbol, /*enclosingDeclaration*/ undefined, /*meaning*/ undefined); + var items = ts.map(candidates, function (candidateSignature) { + var signatureHelpParameters; + var prefixDisplayParts = []; + var suffixDisplayParts = []; + if (callTargetDisplayParts) { + ts.addRange(prefixDisplayParts, callTargetDisplayParts); + } + if (isTypeParameterList) { + prefixDisplayParts.push(ts.punctuationPart(25 /* LessThanToken */)); + var typeParameters = candidateSignature.typeParameters; + signatureHelpParameters = typeParameters && typeParameters.length > 0 ? ts.map(typeParameters, createSignatureHelpParameterForTypeParameter) : emptyArray; + suffixDisplayParts.push(ts.punctuationPart(27 /* GreaterThanToken */)); + var parameterParts = ts.mapToDisplayParts(function (writer) { + return typeChecker.getSymbolDisplayBuilder().buildDisplayForParametersAndDelimiters(candidateSignature.parameters, writer, invocation); + }); + ts.addRange(suffixDisplayParts, parameterParts); + } + else { + var typeParameterParts = ts.mapToDisplayParts(function (writer) { + return typeChecker.getSymbolDisplayBuilder().buildDisplayForTypeParametersAndDelimiters(candidateSignature.typeParameters, writer, invocation); + }); + ts.addRange(prefixDisplayParts, typeParameterParts); + prefixDisplayParts.push(ts.punctuationPart(17 /* OpenParenToken */)); + var parameters = candidateSignature.parameters; + signatureHelpParameters = parameters.length > 0 ? ts.map(parameters, createSignatureHelpParameterForParameter) : emptyArray; + suffixDisplayParts.push(ts.punctuationPart(18 /* CloseParenToken */)); + } + var returnTypeParts = ts.mapToDisplayParts(function (writer) { + return typeChecker.getSymbolDisplayBuilder().buildReturnTypeDisplay(candidateSignature, writer, invocation); + }); + ts.addRange(suffixDisplayParts, returnTypeParts); + return { + isVariadic: candidateSignature.hasRestParameter, + prefixDisplayParts: prefixDisplayParts, + suffixDisplayParts: suffixDisplayParts, + separatorDisplayParts: [ts.punctuationPart(24 /* CommaToken */), ts.spacePart()], + parameters: signatureHelpParameters, + documentation: candidateSignature.getDocumentationComment() + }; + }); + var argumentIndex = argumentListInfo.argumentIndex; + // argumentCount is the *apparent* number of arguments. + var argumentCount = argumentListInfo.argumentCount; + var selectedItemIndex = candidates.indexOf(bestSignature); + if (selectedItemIndex < 0) { + selectedItemIndex = selectBestInvalidOverloadIndex(candidates, argumentCount); + } + ts.Debug.assert(argumentIndex === 0 || argumentIndex < argumentCount, "argumentCount < argumentIndex, " + argumentCount + " < " + argumentIndex); + return { + items: items, + applicableSpan: applicableSpan, + selectedItemIndex: selectedItemIndex, + argumentIndex: argumentIndex, + argumentCount: argumentCount + }; + function createSignatureHelpParameterForParameter(parameter) { + var displayParts = ts.mapToDisplayParts(function (writer) { + return typeChecker.getSymbolDisplayBuilder().buildParameterDisplay(parameter, writer, invocation); + }); + return { + name: parameter.name, + documentation: parameter.getDocumentationComment(), + displayParts: displayParts, + isOptional: typeChecker.isOptionalParameter(parameter.valueDeclaration) + }; + } + function createSignatureHelpParameterForTypeParameter(typeParameter) { + var displayParts = ts.mapToDisplayParts(function (writer) { + return typeChecker.getSymbolDisplayBuilder().buildTypeParameterDisplay(typeParameter, writer, invocation); + }); + return { + name: typeParameter.symbol.name, + documentation: emptyArray, + displayParts: displayParts, + isOptional: false + }; + } + } + } + SignatureHelp.getSignatureHelpItems = getSignatureHelpItems; + })(SignatureHelp = ts.SignatureHelp || (ts.SignatureHelp = {})); +})(ts || (ts = {})); +// These utilities are common to multiple language service features. +/* @internal */ +var ts; +(function (ts) { + function getEndLinePosition(line, sourceFile) { + ts.Debug.assert(line >= 0); + var lineStarts = sourceFile.getLineStarts(); + var lineIndex = line; + if (lineIndex + 1 === lineStarts.length) { + // last line - return EOF + return sourceFile.text.length - 1; + } + else { + // current line start + var start = lineStarts[lineIndex]; + // take the start position of the next line -1 = it should be some line break + var pos = lineStarts[lineIndex + 1] - 1; + ts.Debug.assert(ts.isLineBreak(sourceFile.text.charCodeAt(pos))); + // walk backwards skipping line breaks, stop the the beginning of current line. + // i.e: + // + // $ <- end of line for this position should match the start position + while (start <= pos && ts.isLineBreak(sourceFile.text.charCodeAt(pos))) { + pos--; + } + return pos; + } + } + ts.getEndLinePosition = getEndLinePosition; + function getLineStartPositionForPosition(position, sourceFile) { + var lineStarts = sourceFile.getLineStarts(); + var line = sourceFile.getLineAndCharacterOfPosition(position).line; + return lineStarts[line]; + } + ts.getLineStartPositionForPosition = getLineStartPositionForPosition; + function rangeContainsRange(r1, r2) { + return startEndContainsRange(r1.pos, r1.end, r2); + } + ts.rangeContainsRange = rangeContainsRange; + function startEndContainsRange(start, end, range) { + return start <= range.pos && end >= range.end; + } + ts.startEndContainsRange = startEndContainsRange; + function rangeContainsStartEnd(range, start, end) { + return range.pos <= start && range.end >= end; + } + ts.rangeContainsStartEnd = rangeContainsStartEnd; + function rangeOverlapsWithStartEnd(r1, start, end) { + return startEndOverlapsWithStartEnd(r1.pos, r1.end, start, end); + } + ts.rangeOverlapsWithStartEnd = rangeOverlapsWithStartEnd; + function startEndOverlapsWithStartEnd(start1, end1, start2, end2) { + var start = Math.max(start1, start2); + var end = Math.min(end1, end2); + return start < end; + } + ts.startEndOverlapsWithStartEnd = startEndOverlapsWithStartEnd; + function positionBelongsToNode(candidate, position, sourceFile) { + return candidate.end > position || !isCompletedNode(candidate, sourceFile); + } + ts.positionBelongsToNode = positionBelongsToNode; + function isCompletedNode(n, sourceFile) { + if (ts.nodeIsMissing(n)) { + return false; + } + switch (n.kind) { + case 214 /* ClassDeclaration */: + case 215 /* InterfaceDeclaration */: + case 217 /* EnumDeclaration */: + case 165 /* ObjectLiteralExpression */: + case 161 /* ObjectBindingPattern */: + case 155 /* TypeLiteral */: + case 192 /* Block */: + case 219 /* ModuleBlock */: + case 220 /* CaseBlock */: + return nodeEndsWith(n, 16 /* CloseBraceToken */, sourceFile); + case 244 /* CatchClause */: + return isCompletedNode(n.block, sourceFile); + case 169 /* NewExpression */: + if (!n.arguments) { + return true; + } + // fall through + case 168 /* CallExpression */: + case 172 /* ParenthesizedExpression */: + case 160 /* ParenthesizedType */: + return nodeEndsWith(n, 18 /* CloseParenToken */, sourceFile); + case 152 /* FunctionType */: + case 153 /* ConstructorType */: + return isCompletedNode(n.type, sourceFile); + case 144 /* Constructor */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: + case 213 /* FunctionDeclaration */: + case 173 /* FunctionExpression */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: + case 148 /* ConstructSignature */: + case 147 /* CallSignature */: + case 174 /* ArrowFunction */: + if (n.body) { + return isCompletedNode(n.body, sourceFile); + } + if (n.type) { + return isCompletedNode(n.type, sourceFile); + } + // 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 218 /* ModuleDeclaration */: + return n.body && isCompletedNode(n.body, sourceFile); + case 196 /* IfStatement */: + if (n.elseStatement) { + return isCompletedNode(n.elseStatement, sourceFile); + } + return isCompletedNode(n.thenStatement, sourceFile); + case 195 /* ExpressionStatement */: + return isCompletedNode(n.expression, sourceFile) || + hasChildOfKind(n, 23 /* SemicolonToken */); + case 164 /* ArrayLiteralExpression */: + case 162 /* ArrayBindingPattern */: + case 167 /* ElementAccessExpression */: + case 136 /* ComputedPropertyName */: + case 157 /* TupleType */: + return nodeEndsWith(n, 20 /* CloseBracketToken */, sourceFile); + case 149 /* IndexSignature */: + if (n.type) { + return isCompletedNode(n.type, sourceFile); + } + return hasChildOfKind(n, 20 /* CloseBracketToken */, sourceFile); + case 241 /* CaseClause */: + case 242 /* DefaultClause */: + // there is no such thing as terminator token for CaseClause/DefaultClause so for simplicitly always consider them non-completed + return false; + case 199 /* ForStatement */: + case 200 /* ForInStatement */: + case 201 /* ForOfStatement */: + case 198 /* WhileStatement */: + return isCompletedNode(n.statement, sourceFile); + case 197 /* 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); + if (hasWhileKeyword) { + return nodeEndsWith(n, 18 /* CloseParenToken */, sourceFile); + } + return isCompletedNode(n.statement, sourceFile); + case 154 /* TypeQuery */: + return isCompletedNode(n.exprName, sourceFile); + case 176 /* TypeOfExpression */: + case 175 /* DeleteExpression */: + case 177 /* VoidExpression */: + case 184 /* YieldExpression */: + case 185 /* SpreadElementExpression */: + var unaryWordExpression = n; + return isCompletedNode(unaryWordExpression.expression, sourceFile); + case 170 /* TaggedTemplateExpression */: + return isCompletedNode(n.template, sourceFile); + case 183 /* TemplateExpression */: + var lastSpan = ts.lastOrUndefined(n.templateSpans); + return isCompletedNode(lastSpan, sourceFile); + case 190 /* TemplateSpan */: + return ts.nodeIsPresent(n.literal); + case 179 /* PrefixUnaryExpression */: + return isCompletedNode(n.operand, sourceFile); + case 181 /* BinaryExpression */: + return isCompletedNode(n.right, sourceFile); + case 182 /* ConditionalExpression */: + return isCompletedNode(n.whenFalse, sourceFile); + default: + return true; + } + } + ts.isCompletedNode = isCompletedNode; + /* + * Checks if node ends with 'expectedLastToken'. + * If child at position 'length - 1' is 'SemicolonToken' it is skipped and 'expectedLastToken' is compared with child at position 'length - 2'. + */ + function nodeEndsWith(n, expectedLastToken, sourceFile) { + var children = n.getChildren(sourceFile); + if (children.length) { + var last = ts.lastOrUndefined(children); + if (last.kind === expectedLastToken) { + return true; + } + else if (last.kind === 23 /* SemicolonToken */ && children.length !== 1) { + return children[children.length - 2].kind === expectedLastToken; + } + } + return false; + } + function findListItemInfo(node) { + var list = findContainingList(node); + // It is possible at this point for syntaxList to be undefined, either if + // node.parent had no list child, or if none of its list children contained + // the span of node. If this happens, return undefined. The caller should + // handle this case. + if (!list) { + return undefined; + } + var children = list.getChildren(); + var listItemIndex = ts.indexOf(children, node); + return { + listItemIndex: listItemIndex, + list: list + }; + } + ts.findListItemInfo = findListItemInfo; + function hasChildOfKind(n, kind, sourceFile) { + return !!findChildOfKind(n, kind, sourceFile); + } + ts.hasChildOfKind = hasChildOfKind; + function findChildOfKind(n, kind, sourceFile) { + return ts.forEach(n.getChildren(sourceFile), function (c) { return c.kind === kind && c; }); + } + ts.findChildOfKind = findChildOfKind; + function findContainingList(node) { + // The node might be a list element (nonsynthetic) or a comma (synthetic). Either way, it will + // be parented by the container of the SyntaxList, not the SyntaxList itself. + // In order to find the list item index, we first need to locate SyntaxList itself and then search + // for the position of the relevant node (or comma). + var syntaxList = ts.forEach(node.parent.getChildren(), function (c) { + // find syntax list that covers the span of the node + if (c.kind === 271 /* SyntaxList */ && c.pos <= node.pos && c.end >= node.end) { + return c; + } + }); + // Either we didn't find an appropriate list, or the list must contain us. + ts.Debug.assert(!syntaxList || ts.contains(syntaxList.getChildren(), node)); + return syntaxList; + } + ts.findContainingList = findContainingList; + /* Gets the token whose text has range [start, end) and + * position >= start and (position < end or (position === end && token is keyword or identifier)) + */ + function getTouchingWord(sourceFile, position) { + return getTouchingToken(sourceFile, position, function (n) { return isWord(n.kind); }); + } + ts.getTouchingWord = getTouchingWord; + /* Gets the token whose text has range [start, end) and position >= start + * and (position < end or (position === end && token is keyword or identifier or numeric\string litera)) + */ + function getTouchingPropertyName(sourceFile, position) { + return getTouchingToken(sourceFile, position, function (n) { return isPropertyName(n.kind); }); + } + ts.getTouchingPropertyName = getTouchingPropertyName; + /** Returns the token if position is in [start, end) or if position === end and includeItemAtEndPosition(token) === true */ + function getTouchingToken(sourceFile, position, includeItemAtEndPosition) { + return getTokenAtPositionWorker(sourceFile, position, /*allowPositionInLeadingTrivia*/ false, includeItemAtEndPosition); + } + ts.getTouchingToken = getTouchingToken; + /** Returns a token if position is in [start-of-leading-trivia, end) */ + function getTokenAtPosition(sourceFile, position) { + return getTokenAtPositionWorker(sourceFile, position, /*allowPositionInLeadingTrivia*/ true, /*includeItemAtEndPosition*/ undefined); + } + ts.getTokenAtPosition = getTokenAtPosition; + /** Get the token whose text contains the position */ + function getTokenAtPositionWorker(sourceFile, position, allowPositionInLeadingTrivia, includeItemAtEndPosition) { + var current = sourceFile; + outer: while (true) { + if (isToken(current)) { + // exit early + return current; + } + // find the child that contains 'position' + for (var i = 0, n = current.getChildCount(sourceFile); i < n; i++) { + var child = current.getChildAt(i); + var start = allowPositionInLeadingTrivia ? child.getFullStart() : child.getStart(sourceFile); + if (start <= position) { + var end = child.getEnd(); + if (position < end || (position === end && child.kind === 1 /* EndOfFileToken */)) { + current = child; + continue outer; + } + else if (includeItemAtEndPosition && end === position) { + var previousToken = findPrecedingToken(position, sourceFile, child); + if (previousToken && includeItemAtEndPosition(previousToken)) { + return previousToken; + } + } + } + } + return current; + } + } + /** + * The token on the left of the position is the token that strictly includes the position + * or sits to the left of the cursor if it is on a boundary. For example + * + * fo|o -> will return foo + * foo |bar -> will return foo + * + */ + function findTokenOnLeftOfPosition(file, position) { + // Ideally, getTokenAtPosition should return a token. However, it is currently + // broken, so we do a check to make sure the result was indeed a token. + var tokenAtPosition = getTokenAtPosition(file, position); + if (isToken(tokenAtPosition) && position > tokenAtPosition.getStart(file) && position < tokenAtPosition.getEnd()) { + return tokenAtPosition; + } + return findPrecedingToken(position, file); + } + ts.findTokenOnLeftOfPosition = findTokenOnLeftOfPosition; + function findNextToken(previousToken, parent) { + return find(parent); + function find(n) { + if (isToken(n) && n.pos === previousToken.end) { + // this is token that starts at the end of previous token - return it + return n; + } + var children = n.getChildren(); + for (var _i = 0; _i < children.length; _i++) { + var child = children[_i]; + var shouldDiveInChildNode = + // previous token is enclosed somewhere in the child + (child.pos <= previousToken.pos && child.end > previousToken.end) || + // previous token ends exactly at the beginning of child + (child.pos === previousToken.end); + if (shouldDiveInChildNode && nodeHasTokens(child)) { + return find(child); + } + } + return undefined; + } + } + ts.findNextToken = findNextToken; + function findPrecedingToken(position, sourceFile, startNode) { + return find(startNode || sourceFile); + function findRightmostToken(n) { + if (isToken(n) || n.kind === 236 /* JsxText */) { + return n; + } + var children = n.getChildren(); + var candidate = findRightmostChildNodeWithTokens(children, /*exclusiveStartPosition*/ children.length); + return candidate && findRightmostToken(candidate); + } + function find(n) { + if (isToken(n) || n.kind === 236 /* JsxText */) { + return n; + } + var children = n.getChildren(); + for (var i = 0, len = children.length; i < len; i++) { + var child = children[i]; + // condition 'position < child.end' checks if child node end after the position + // in the example below this condition will be false for 'aaaa' and 'bbbb' and true for 'ccc' + // aaaa___bbbb___$__ccc + // after we found child node with end after the position we check if start of the node is after the position. + // if yes - then position is in the trivia and we need to look into the previous child to find the token in question. + // 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 === 236 /* JsxText */)) { + var start = child.getStart(sourceFile); + var lookInPreviousChild = (start >= position) || + (child.kind === 236 /* JsxText */ && start === child.end); // whitespace only JsxText + if (lookInPreviousChild) { + // actual start of the node is past the position - previous token should be at the end of previous child + var candidate = findRightmostChildNodeWithTokens(children, /*exclusiveStartPosition*/ i); + return candidate && findRightmostToken(candidate); + } + else { + // candidate should be in this node + return find(child); + } + } + } + ts.Debug.assert(startNode !== undefined || n.kind === 248 /* SourceFile */); + // Here we know that none of child token nodes embrace the position, + // the only known case is when position is at the end of the file. + // Try to find the rightmost token in the file without filtering. + // Namely we are skipping the check: 'position < node.end' + if (children.length) { + var candidate = findRightmostChildNodeWithTokens(children, /*exclusiveStartPosition*/ children.length); + return candidate && findRightmostToken(candidate); + } + } + /// finds last node that is considered as candidate for search (isCandidate(node) === true) starting from 'exclusiveStartPosition' + function findRightmostChildNodeWithTokens(children, exclusiveStartPosition) { + for (var i = exclusiveStartPosition - 1; i >= 0; --i) { + if (nodeHasTokens(children[i])) { + return children[i]; + } + } + } + } + ts.findPrecedingToken = findPrecedingToken; + function isInString(sourceFile, position) { + var token = getTokenAtPosition(sourceFile, position); + return token && token.kind === 9 /* StringLiteral */ && position > token.getStart(); + } + ts.isInString = isInString; + function isInComment(sourceFile, position) { + return isInCommentHelper(sourceFile, position, /*predicate*/ undefined); + } + ts.isInComment = isInComment; + /** + * Returns true if the cursor at position in sourceFile is within a comment that additionally + * satisfies predicate, and false otherwise. + */ + function isInCommentHelper(sourceFile, position, predicate) { + var token = getTokenAtPosition(sourceFile, position); + if (token && position <= token.getStart()) { + var commentRanges = ts.getLeadingCommentRanges(sourceFile.text, token.pos); + // The end marker of a single-line comment does not include the newline character. + // In the following case, we are inside a comment (^ denotes the cursor position): + // + // // asdf ^\n + // + // But for multi-line comments, we don't want to be inside the comment in the following case: + // + // /* asdf */^ + // + // Internally, we represent the end of the comment at the newline and closing '/', respectively. + return predicate ? + ts.forEach(commentRanges, function (c) { return c.pos < position && + (c.kind == 2 /* SingleLineCommentTrivia */ ? position <= c.end : position < c.end) && + predicate(c); }) : + ts.forEach(commentRanges, function (c) { return c.pos < position && + (c.kind == 2 /* SingleLineCommentTrivia */ ? position <= c.end : position < c.end); }); + } + return false; + } + ts.isInCommentHelper = isInCommentHelper; + function hasDocComment(sourceFile, position) { + var token = getTokenAtPosition(sourceFile, position); + // First, we have to see if this position actually landed in a comment. + var commentRanges = ts.getLeadingCommentRanges(sourceFile.text, token.pos); + return ts.forEach(commentRanges, jsDocPrefix); + function jsDocPrefix(c) { + var text = sourceFile.text; + return text.length >= c.pos + 3 && text[c.pos] === '/' && text[c.pos + 1] === '*' && text[c.pos + 2] === '*'; + } + } + ts.hasDocComment = hasDocComment; + /** + * Get the corresponding JSDocTag node if the position is in a jsDoc comment + */ + function getJsDocTagAtPosition(sourceFile, position) { + var node = ts.getTokenAtPosition(sourceFile, position); + if (isToken(node)) { + switch (node.kind) { + case 102 /* VarKeyword */: + case 108 /* LetKeyword */: + case 74 /* ConstKeyword */: + // if the current token is var, let or const, skip the VariableDeclarationList + node = node.parent === undefined ? undefined : node.parent.parent; + break; + default: + node = node.parent; + break; + } + } + if (node) { + var jsDocComment = node.jsDocComment; + if (jsDocComment) { + for (var _i = 0, _a = jsDocComment.tags; _i < _a.length; _i++) { + var tag = _a[_i]; + if (tag.pos <= position && position <= tag.end) { + return tag; + } + } + } + } + return undefined; + } + ts.getJsDocTagAtPosition = getJsDocTagAtPosition; + function nodeHasTokens(n) { + // If we have a token or node that has a non-zero width, it must have tokens. + // Note, that getWidth() does not take trivia into account. + return n.getWidth() !== 0; + } + function getNodeModifiers(node) { + var flags = ts.getCombinedNodeFlags(node); + var result = []; + if (flags & 32 /* Private */) + result.push(ts.ScriptElementKindModifier.privateMemberModifier); + if (flags & 64 /* Protected */) + result.push(ts.ScriptElementKindModifier.protectedMemberModifier); + if (flags & 16 /* Public */) + result.push(ts.ScriptElementKindModifier.publicMemberModifier); + if (flags & 128 /* Static */) + result.push(ts.ScriptElementKindModifier.staticModifier); + if (flags & 256 /* Abstract */) + result.push(ts.ScriptElementKindModifier.abstractModifier); + if (flags & 1 /* Export */) + result.push(ts.ScriptElementKindModifier.exportedModifier); + if (ts.isInAmbientContext(node)) + result.push(ts.ScriptElementKindModifier.ambientModifier); + return result.length > 0 ? result.join(',') : ts.ScriptElementKindModifier.none; + } + ts.getNodeModifiers = getNodeModifiers; + function getTypeArgumentOrTypeParameterList(node) { + if (node.kind === 151 /* TypeReference */ || node.kind === 168 /* CallExpression */) { + return node.typeArguments; + } + if (ts.isFunctionLike(node) || node.kind === 214 /* ClassDeclaration */ || node.kind === 215 /* InterfaceDeclaration */) { + return node.typeParameters; + } + return undefined; + } + ts.getTypeArgumentOrTypeParameterList = getTypeArgumentOrTypeParameterList; + function isToken(n) { + return n.kind >= 0 /* FirstToken */ && n.kind <= 134 /* LastToken */; + } + ts.isToken = isToken; + function isWord(kind) { + return kind === 69 /* Identifier */ || ts.isKeyword(kind); + } + ts.isWord = isWord; + function isPropertyName(kind) { + return kind === 9 /* StringLiteral */ || kind === 8 /* NumericLiteral */ || isWord(kind); + } + function isComment(kind) { + return kind === 2 /* SingleLineCommentTrivia */ || kind === 3 /* MultiLineCommentTrivia */; + } + ts.isComment = isComment; + function isStringOrRegularExpressionOrTemplateLiteral(kind) { + if (kind === 9 /* StringLiteral */ + || kind === 10 /* RegularExpressionLiteral */ + || ts.isTemplateLiteralKind(kind)) { + return true; + } + return false; + } + ts.isStringOrRegularExpressionOrTemplateLiteral = isStringOrRegularExpressionOrTemplateLiteral; + function isPunctuation(kind) { + return 15 /* FirstPunctuation */ <= kind && kind <= 68 /* LastPunctuation */; + } + ts.isPunctuation = isPunctuation; + function isInsideTemplateLiteral(node, position) { + return ts.isTemplateLiteralKind(node.kind) + && (node.getStart() < position && position < node.getEnd()) || (!!node.isUnterminated && position === node.getEnd()); + } + ts.isInsideTemplateLiteral = isInsideTemplateLiteral; + function isAccessibilityModifier(kind) { + switch (kind) { + case 112 /* PublicKeyword */: + case 110 /* PrivateKeyword */: + case 111 /* ProtectedKeyword */: + return true; + } + return false; + } + ts.isAccessibilityModifier = isAccessibilityModifier; + function compareDataObjects(dst, src) { + for (var e in dst) { + if (typeof dst[e] === "object") { + if (!compareDataObjects(dst[e], src[e])) { + return false; + } + } + else if (typeof dst[e] !== "function") { + if (dst[e] !== src[e]) { + return false; + } + } + } + return true; + } + ts.compareDataObjects = compareDataObjects; +})(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 === 138 /* Parameter */; + } + ts.isFirstDeclarationOfSymbolParameter = isFirstDeclarationOfSymbolParameter; + var displayPartWriter = getDisplayPartWriter(); + function getDisplayPartWriter() { + var displayParts; + var lineStart; + var indent; + resetWriter(); + return { + displayParts: function () { return displayParts; }, + writeKeyword: function (text) { return writeKind(text, ts.SymbolDisplayPartKind.keyword); }, + writeOperator: function (text) { return writeKind(text, ts.SymbolDisplayPartKind.operator); }, + writePunctuation: function (text) { return writeKind(text, ts.SymbolDisplayPartKind.punctuation); }, + writeSpace: function (text) { return writeKind(text, ts.SymbolDisplayPartKind.space); }, + writeStringLiteral: function (text) { return writeKind(text, ts.SymbolDisplayPartKind.stringLiteral); }, + writeParameter: function (text) { return writeKind(text, ts.SymbolDisplayPartKind.parameterName); }, + writeSymbol: writeSymbol, + writeLine: writeLine, + increaseIndent: function () { indent++; }, + decreaseIndent: function () { indent--; }, + clear: resetWriter, + trackSymbol: function () { }, + reportInaccessibleThisError: function () { } + }; + function writeIndent() { + if (lineStart) { + var indentString = ts.getIndentString(indent); + if (indentString) { + displayParts.push(displayPart(indentString, ts.SymbolDisplayPartKind.space)); + } + lineStart = false; + } + } + function writeKind(text, kind) { + writeIndent(); + displayParts.push(displayPart(text, kind)); + } + function writeSymbol(text, symbol) { + writeIndent(); + displayParts.push(symbolPart(text, symbol)); + } + function writeLine() { + displayParts.push(lineBreakPart()); + lineStart = true; + } + function resetWriter() { + displayParts = []; + lineStart = true; + indent = 0; + } + } + function symbolPart(text, symbol) { + return displayPart(text, displayPartKind(symbol), symbol); + function displayPartKind(symbol) { + var flags = symbol.flags; + if (flags & 3 /* Variable */) { + return isFirstDeclarationOfSymbolParameter(symbol) ? ts.SymbolDisplayPartKind.parameterName : ts.SymbolDisplayPartKind.localName; + } + else if (flags & 4 /* Property */) { + return ts.SymbolDisplayPartKind.propertyName; + } + else if (flags & 32768 /* GetAccessor */) { + return ts.SymbolDisplayPartKind.propertyName; + } + else if (flags & 65536 /* SetAccessor */) { + return ts.SymbolDisplayPartKind.propertyName; + } + else if (flags & 8 /* EnumMember */) { + return ts.SymbolDisplayPartKind.enumMemberName; + } + else if (flags & 16 /* Function */) { + return ts.SymbolDisplayPartKind.functionName; + } + else if (flags & 32 /* Class */) { + return ts.SymbolDisplayPartKind.className; + } + else if (flags & 64 /* Interface */) { + return ts.SymbolDisplayPartKind.interfaceName; + } + else if (flags & 384 /* Enum */) { + return ts.SymbolDisplayPartKind.enumName; + } + else if (flags & 1536 /* Module */) { + return ts.SymbolDisplayPartKind.moduleName; + } + else if (flags & 8192 /* Method */) { + return ts.SymbolDisplayPartKind.methodName; + } + else if (flags & 262144 /* TypeParameter */) { + return ts.SymbolDisplayPartKind.typeParameterName; + } + else if (flags & 524288 /* TypeAlias */) { + return ts.SymbolDisplayPartKind.aliasName; + } + else if (flags & 8388608 /* Alias */) { + return ts.SymbolDisplayPartKind.aliasName; + } + return ts.SymbolDisplayPartKind.text; + } + } + ts.symbolPart = symbolPart; + function displayPart(text, kind, symbol) { + return { + text: text, + kind: ts.SymbolDisplayPartKind[kind] + }; + } + ts.displayPart = displayPart; + function spacePart() { + return displayPart(" ", ts.SymbolDisplayPartKind.space); + } + ts.spacePart = spacePart; + function keywordPart(kind) { + return displayPart(ts.tokenToString(kind), ts.SymbolDisplayPartKind.keyword); + } + ts.keywordPart = keywordPart; + function punctuationPart(kind) { + return displayPart(ts.tokenToString(kind), ts.SymbolDisplayPartKind.punctuation); + } + ts.punctuationPart = punctuationPart; + function operatorPart(kind) { + return displayPart(ts.tokenToString(kind), ts.SymbolDisplayPartKind.operator); + } + ts.operatorPart = operatorPart; + function textOrKeywordPart(text) { + var kind = ts.stringToToken(text); + return kind === undefined + ? textPart(text) + : keywordPart(kind); + } + ts.textOrKeywordPart = textOrKeywordPart; + function textPart(text) { + return displayPart(text, ts.SymbolDisplayPartKind.text); + } + ts.textPart = textPart; + var carriageReturnLineFeed = "\r\n"; + /** + * The default is CRLF. + */ + function getNewLineOrDefaultFromHost(host) { + return host.getNewLine ? host.getNewLine() : carriageReturnLineFeed; + } + ts.getNewLineOrDefaultFromHost = getNewLineOrDefaultFromHost; + function lineBreakPart() { + return displayPart("\n", ts.SymbolDisplayPartKind.lineBreak); + } + ts.lineBreakPart = lineBreakPart; + function mapToDisplayParts(writeDisplayParts) { + writeDisplayParts(displayPartWriter); + var result = displayPartWriter.displayParts(); + displayPartWriter.clear(); + return result; + } + ts.mapToDisplayParts = mapToDisplayParts; + function typeToDisplayParts(typechecker, type, enclosingDeclaration, flags) { + return mapToDisplayParts(function (writer) { + typechecker.getSymbolDisplayBuilder().buildTypeDisplay(type, writer, enclosingDeclaration, flags); + }); + } + ts.typeToDisplayParts = typeToDisplayParts; + function symbolToDisplayParts(typeChecker, symbol, enclosingDeclaration, meaning, flags) { + return mapToDisplayParts(function (writer) { + typeChecker.getSymbolDisplayBuilder().buildSymbolDisplay(symbol, writer, enclosingDeclaration, meaning, flags); + }); + } + ts.symbolToDisplayParts = symbolToDisplayParts; + function signatureToDisplayParts(typechecker, signature, enclosingDeclaration, flags) { + return mapToDisplayParts(function (writer) { + typechecker.getSymbolDisplayBuilder().buildSignatureDisplay(signature, writer, enclosingDeclaration, flags); + }); + } + ts.signatureToDisplayParts = signatureToDisplayParts; + function getDeclaredName(typeChecker, 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 is under the cursor. + if (isImportOrExportSpecifierName(location)) { + return location.getText(); + } + // Try to get the local symbol if we're dealing with an 'export default' + // since that symbol has the "true" name. + var localExportDefaultSymbol = ts.getLocalSymbolForExportDefault(symbol); + var name = typeChecker.symbolToString(localExportDefaultSymbol || symbol); + return name; + } + ts.getDeclaredName = getDeclaredName; + function isImportOrExportSpecifierName(location) { + return location.parent && + (location.parent.kind === 226 /* ImportSpecifier */ || location.parent.kind === 230 /* ExportSpecifier */) && + location.parent.propertyName === location; + } + ts.isImportOrExportSpecifierName = isImportOrExportSpecifierName; + /** + * Strip off existed single quotes or double quotes from a given string + * + * @return non-quoted string + */ + function stripQuotes(name) { + var length = name.length; + if (length >= 2 && + name.charCodeAt(0) === name.charCodeAt(length - 1) && + (name.charCodeAt(0) === 34 /* doubleQuote */ || name.charCodeAt(0) === 39 /* singleQuote */)) { + return name.substring(1, length - 1); + } + ; + return name; + } + ts.stripQuotes = stripQuotes; +})(ts || (ts = {})); +/// +/// +/* @internal */ +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 */); + /** + * Scanner that is currently used for formatting + */ + 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 = {})); + function getFormattingScanner(sourceFile, startPos, endPos) { + ts.Debug.assert(scanner === undefined); + scanner = sourceFile.languageVariant === 1 /* JSX */ ? jsxScanner : standardScanner; + scanner.setText(sourceFile.text); + scanner.setTextPos(startPos); + var wasNewLine = true; + var leadingTrivia; + var trailingTrivia; + var savedPos; + var lastScanAction; + var lastTokenInfo; + return { + advance: advance, + readTokenInfo: readTokenInfo, + isOnToken: isOnToken, + lastTrailingTriviaWasNewLine: function () { return wasNewLine; }, + close: function () { + ts.Debug.assert(scanner !== undefined); + lastTokenInfo = undefined; + scanner.setText(undefined); + scanner = undefined; + } + }; + function advance() { + ts.Debug.assert(scanner !== undefined); + lastTokenInfo = undefined; + var isStarted = scanner.getStartPos() !== startPos; + if (isStarted) { + if (trailingTrivia) { + ts.Debug.assert(trailingTrivia.length !== 0); + wasNewLine = ts.lastOrUndefined(trailingTrivia).kind === 4 /* NewLineTrivia */; + } + else { + wasNewLine = false; + } + } + leadingTrivia = undefined; + trailingTrivia = undefined; + if (!isStarted) { + scanner.scan(); + } + var t; + var pos = scanner.getStartPos(); + // Read leading trivia and token + while (pos < endPos) { + var t_1 = scanner.getToken(); + if (!ts.isTrivia(t_1)) { + break; + } + // consume leading trivia + scanner.scan(); + var item = { + pos: pos, + end: scanner.getStartPos(), + kind: t_1 + }; + pos = scanner.getStartPos(); + if (!leadingTrivia) { + leadingTrivia = []; + } + leadingTrivia.push(item); + } + savedPos = scanner.getStartPos(); + } + function shouldRescanGreaterThanToken(node) { + if (node) { + switch (node.kind) { + case 29 /* GreaterThanEqualsToken */: + case 64 /* GreaterThanGreaterThanEqualsToken */: + case 65 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + case 45 /* GreaterThanGreaterThanGreaterThanToken */: + case 44 /* GreaterThanGreaterThanToken */: + return true; + } + } + return false; + } + function shouldRescanJsxIdentifier(node) { + if (node.parent) { + switch (node.parent.kind) { + case 238 /* JsxAttribute */: + case 235 /* JsxOpeningElement */: + case 237 /* JsxClosingElement */: + case 234 /* JsxSelfClosingElement */: + return node.kind === 69 /* Identifier */; + } + } + return false; + } + function shouldRescanSlashToken(container) { + return container.kind === 10 /* RegularExpressionLiteral */; + } + function shouldRescanTemplateToken(container) { + return container.kind === 13 /* TemplateMiddle */ || + container.kind === 14 /* TemplateTail */; + } + function startsWithSlashToken(t) { + return t === 39 /* SlashToken */ || t === 61 /* SlashEqualsToken */; + } + function readTokenInfo(n) { + ts.Debug.assert(scanner !== undefined); + if (!isOnToken()) { + // scanner is not on the token (either advance was not called yet or scanner is already past the end position) + return { + leadingTrivia: leadingTrivia, + trailingTrivia: undefined, + token: undefined + }; + } + // normally scanner returns the smallest available token + // check the kind of context node to determine if scanner should have more greedy behavior and consume more text. + var expectedScanAction = shouldRescanGreaterThanToken(n) + ? 1 /* RescanGreaterThanToken */ + : shouldRescanSlashToken(n) + ? 2 /* RescanSlashToken */ + : shouldRescanTemplateToken(n) + ? 3 /* RescanTemplateToken */ + : shouldRescanJsxIdentifier(n) + ? 4 /* RescanJsxIdentifier */ + : 0 /* Scan */; + if (lastTokenInfo && expectedScanAction === lastScanAction) { + // readTokenInfo was called before with the same expected scan action. + // No need to re-scan text, return existing 'lastTokenInfo' + // it is ok to call fixTokenKind here since it does not affect + // what portion of text is consumed. In opposize rescanning can change it, + // i.e. for '>=' when originally scanner eats just one character + // and rescanning forces it to consume more. + return fixTokenKind(lastTokenInfo, n); + } + if (scanner.getStartPos() !== savedPos) { + ts.Debug.assert(lastTokenInfo !== undefined); + // readTokenInfo was called before but scan action differs - rescan text + scanner.setTextPos(savedPos); + scanner.scan(); + } + var currentToken = scanner.getToken(); + if (expectedScanAction === 1 /* RescanGreaterThanToken */ && currentToken === 27 /* GreaterThanToken */) { + currentToken = scanner.reScanGreaterToken(); + ts.Debug.assert(n.kind === currentToken); + lastScanAction = 1 /* RescanGreaterThanToken */; + } + else if (expectedScanAction === 2 /* RescanSlashToken */ && startsWithSlashToken(currentToken)) { + currentToken = scanner.reScanSlashToken(); + ts.Debug.assert(n.kind === currentToken); + lastScanAction = 2 /* RescanSlashToken */; + } + else if (expectedScanAction === 3 /* RescanTemplateToken */ && currentToken === 16 /* CloseBraceToken */) { + currentToken = scanner.reScanTemplateToken(); + lastScanAction = 3 /* RescanTemplateToken */; + } + else if (expectedScanAction === 4 /* RescanJsxIdentifier */ && currentToken === 69 /* Identifier */) { + currentToken = scanner.scanJsxIdentifier(); + lastScanAction = 4 /* RescanJsxIdentifier */; + } + else { + lastScanAction = 0 /* Scan */; + } + var token = { + pos: scanner.getStartPos(), + end: scanner.getTextPos(), + kind: currentToken + }; + // consume trailing trivia + if (trailingTrivia) { + trailingTrivia = undefined; + } + while (scanner.getStartPos() < endPos) { + currentToken = scanner.scan(); + if (!ts.isTrivia(currentToken)) { + break; + } + var trivia = { + pos: scanner.getStartPos(), + end: scanner.getTextPos(), + kind: currentToken + }; + if (!trailingTrivia) { + trailingTrivia = []; + } + trailingTrivia.push(trivia); + if (currentToken === 4 /* NewLineTrivia */) { + // move past new line + scanner.scan(); + break; + } + } + lastTokenInfo = { + leadingTrivia: leadingTrivia, + trailingTrivia: trailingTrivia, + token: token + }; + return fixTokenKind(lastTokenInfo, n); + } + function isOnToken() { + ts.Debug.assert(scanner !== undefined); + var current = (lastTokenInfo && lastTokenInfo.token.kind) || scanner.getToken(); + var startPos = (lastTokenInfo && lastTokenInfo.token.pos) || scanner.getStartPos(); + return startPos < endPos && current !== 1 /* EndOfFileToken */ && !ts.isTrivia(current); + } + // when containing node in the tree is token + // but its kind differs from the kind that was returned by the scanner, + // then kind needs to be fixed. This might happen in cases + // when parser interprets token differently, i.e keyword treated as identifier + function fixTokenKind(tokenInfo, container) { + if (ts.isToken(container) && tokenInfo.token.kind !== container.kind) { + tokenInfo.token.kind = container.kind; + } + return tokenInfo; + } + } + formatting.getFormattingScanner = getFormattingScanner; + })(formatting = ts.formatting || (ts.formatting = {})); +})(ts || (ts = {})); +/// +/* @internal */ +var ts; +(function (ts) { + var formatting; + (function (formatting) { + var FormattingContext = (function () { + function FormattingContext(sourceFile, formattingRequestKind) { + this.sourceFile = sourceFile; + this.formattingRequestKind = formattingRequestKind; + } + FormattingContext.prototype.updateContext = function (currentRange, currentTokenParent, nextRange, nextTokenParent, commonParent) { + ts.Debug.assert(currentRange !== undefined, "currentTokenSpan is null"); + ts.Debug.assert(currentTokenParent !== undefined, "currentTokenParent is null"); + ts.Debug.assert(nextRange !== undefined, "nextTokenSpan is null"); + ts.Debug.assert(nextTokenParent !== undefined, "nextTokenParent is null"); + ts.Debug.assert(commonParent !== undefined, "commonParent is null"); + this.currentTokenSpan = currentRange; + this.currentTokenParent = currentTokenParent; + this.nextTokenSpan = nextRange; + this.nextTokenParent = nextTokenParent; + this.contextNode = commonParent; + // drop cached results + this.contextNodeAllOnSameLine = undefined; + this.nextNodeAllOnSameLine = undefined; + this.tokensAreOnSameLine = undefined; + this.contextNodeBlockIsOnOneLine = undefined; + this.nextNodeBlockIsOnOneLine = undefined; + }; + FormattingContext.prototype.ContextNodeAllOnSameLine = function () { + if (this.contextNodeAllOnSameLine === undefined) { + this.contextNodeAllOnSameLine = this.NodeIsOnOneLine(this.contextNode); + } + return this.contextNodeAllOnSameLine; + }; + FormattingContext.prototype.NextNodeAllOnSameLine = function () { + if (this.nextNodeAllOnSameLine === undefined) { + this.nextNodeAllOnSameLine = this.NodeIsOnOneLine(this.nextTokenParent); + } + return this.nextNodeAllOnSameLine; + }; + FormattingContext.prototype.TokensAreOnSameLine = function () { + if (this.tokensAreOnSameLine === undefined) { + var startLine = this.sourceFile.getLineAndCharacterOfPosition(this.currentTokenSpan.pos).line; + var endLine = this.sourceFile.getLineAndCharacterOfPosition(this.nextTokenSpan.pos).line; + this.tokensAreOnSameLine = (startLine === endLine); + } + return this.tokensAreOnSameLine; + }; + FormattingContext.prototype.ContextNodeBlockIsOnOneLine = function () { + if (this.contextNodeBlockIsOnOneLine === undefined) { + this.contextNodeBlockIsOnOneLine = this.BlockIsOnOneLine(this.contextNode); + } + return this.contextNodeBlockIsOnOneLine; + }; + FormattingContext.prototype.NextNodeBlockIsOnOneLine = function () { + if (this.nextNodeBlockIsOnOneLine === undefined) { + this.nextNodeBlockIsOnOneLine = this.BlockIsOnOneLine(this.nextTokenParent); + } + return this.nextNodeBlockIsOnOneLine; + }; + FormattingContext.prototype.NodeIsOnOneLine = function (node) { + var startLine = this.sourceFile.getLineAndCharacterOfPosition(node.getStart(this.sourceFile)).line; + var endLine = this.sourceFile.getLineAndCharacterOfPosition(node.getEnd()).line; + 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); + if (openBrace && closeBrace) { + var startLine = this.sourceFile.getLineAndCharacterOfPosition(openBrace.getEnd()).line; + var endLine = this.sourceFile.getLineAndCharacterOfPosition(closeBrace.getStart(this.sourceFile)).line; + return startLine === endLine; + } + return false; + }; + return FormattingContext; + })(); + formatting.FormattingContext = FormattingContext; + })(formatting = ts.formatting || (ts.formatting = {})); +})(ts || (ts = {})); +/// +/* @internal */ +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 = {})); +/// +/* @internal */ +var ts; +(function (ts) { + var formatting; + (function (formatting) { + var Rule = (function () { + function Rule(Descriptor, Operation, Flag) { + if (Flag === void 0) { Flag = 0 /* None */; } + this.Descriptor = Descriptor; + this.Operation = Operation; + this.Flag = Flag; + } + Rule.prototype.toString = function () { + return "[desc=" + this.Descriptor + "," + + "operation=" + this.Operation + "," + + "flag=" + this.Flag + "]"; + }; + return Rule; + })(); + formatting.Rule = Rule; + })(formatting = ts.formatting || (ts.formatting = {})); +})(ts || (ts = {})); +/// +/* @internal */ +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 = {})); +/// +/* @internal */ +var ts; +(function (ts) { + var formatting; + (function (formatting) { + var RuleDescriptor = (function () { + function RuleDescriptor(LeftTokenRange, RightTokenRange) { + this.LeftTokenRange = LeftTokenRange; + this.RightTokenRange = RightTokenRange; + } + RuleDescriptor.prototype.toString = function () { + return "[leftRange=" + this.LeftTokenRange + "," + + "rightRange=" + this.RightTokenRange + "]"; + }; + RuleDescriptor.create1 = function (left, right) { + return RuleDescriptor.create4(formatting.Shared.TokenRange.FromToken(left), formatting.Shared.TokenRange.FromToken(right)); + }; + RuleDescriptor.create2 = function (left, right) { + return RuleDescriptor.create4(left, formatting.Shared.TokenRange.FromToken(right)); + }; + RuleDescriptor.create3 = function (left, right) { + return RuleDescriptor.create4(formatting.Shared.TokenRange.FromToken(left), right); + }; + RuleDescriptor.create4 = function (left, right) { + return new RuleDescriptor(left, right); + }; + return RuleDescriptor; + })(); + formatting.RuleDescriptor = RuleDescriptor; + })(formatting = ts.formatting || (ts.formatting = {})); +})(ts || (ts = {})); +/// +/* @internal */ +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 = {})); +/// +/* @internal */ +var ts; +(function (ts) { + var formatting; + (function (formatting) { + var RuleOperation = (function () { + function RuleOperation() { + this.Context = null; + this.Action = null; + } + RuleOperation.prototype.toString = function () { + return "[context=" + this.Context + "," + + "action=" + this.Action + "]"; + }; + RuleOperation.create1 = function (action) { + return RuleOperation.create2(formatting.RuleOperationContext.Any, action); + }; + RuleOperation.create2 = function (context, action) { + var result = new RuleOperation(); + result.Context = context; + result.Action = action; + return result; + }; + return RuleOperation; + })(); + formatting.RuleOperation = RuleOperation; + })(formatting = ts.formatting || (ts.formatting = {})); +})(ts || (ts = {})); +/// +/* @internal */ +var ts; +(function (ts) { + var formatting; + (function (formatting) { + var RuleOperationContext = (function () { + function RuleOperationContext() { + var funcs = []; + for (var _i = 0; _i < arguments.length; _i++) { + funcs[_i - 0] = arguments[_i]; + } + this.customContextChecks = funcs; + } + RuleOperationContext.prototype.IsAny = function () { + return this === RuleOperationContext.Any; + }; + RuleOperationContext.prototype.InContext = function (context) { + if (this.IsAny()) { + return true; + } + for (var _i = 0, _a = this.customContextChecks; _i < _a.length; _i++) { + var check = _a[_i]; + if (!check(context)) { + return false; + } + } + return true; + }; + RuleOperationContext.Any = new RuleOperationContext(); + return RuleOperationContext; + })(); + formatting.RuleOperationContext = RuleOperationContext; + })(formatting = ts.formatting || (ts.formatting = {})); +})(ts || (ts = {})); +/// +/* @internal */ +var ts; +(function (ts) { + var formatting; + (function (formatting) { + var Rules = (function () { + function Rules() { + /// + /// Common Rules + /// + // Leave comments alone + 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.IsSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceBeforeColon = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 54 /* ColonToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 8 /* Delete */)); + this.NoSpaceBeforeQuestionMark = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 53 /* QuestionToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 8 /* Delete */)); + this.SpaceAfterColon = new formatting.Rule(formatting.RuleDescriptor.create3(54 /* ColonToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 2 /* Space */)); + this.SpaceAfterQuestionMarkInConditionalOperator = new formatting.Rule(formatting.RuleDescriptor.create3(53 /* QuestionToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsConditionalOperatorContext), 2 /* Space */)); + this.NoSpaceAfterQuestionMark = new formatting.Rule(formatting.RuleDescriptor.create3(53 /* QuestionToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.SpaceAfterSemicolon = new formatting.Rule(formatting.RuleDescriptor.create3(23 /* SemicolonToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); + // Space after }. + this.SpaceAfterCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create3(16 /* CloseBraceToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsAfterCodeBlockContext), 2 /* Space */)); + // Special case for (}, else) and (}, while) since else & while tokens are not part of the tree which makes SpaceAfterCloseBrace rule not applied + this.SpaceBetweenCloseBraceAndElse = new formatting.Rule(formatting.RuleDescriptor.create1(16 /* CloseBraceToken */, 80 /* ElseKeyword */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); + this.SpaceBetweenCloseBraceAndWhile = new formatting.Rule(formatting.RuleDescriptor.create1(16 /* CloseBraceToken */, 104 /* WhileKeyword */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); + this.NoSpaceAfterCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create3(16 /* CloseBraceToken */, formatting.Shared.TokenRange.FromTokens([18 /* CloseParenToken */, 20 /* CloseBracketToken */, 24 /* CommaToken */, 23 /* SemicolonToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + // No space for dot + this.NoSpaceBeforeDot = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 21 /* DotToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceAfterDot = new formatting.Rule(formatting.RuleDescriptor.create3(21 /* DotToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 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.IsSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceAfterCloseBracket = new formatting.Rule(formatting.RuleDescriptor.create3(20 /* CloseBracketToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, 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 */); + // 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 */]); + this.SpaceBeforeOpenBraceInTypeScriptDeclWithBlock = new formatting.Rule(formatting.RuleDescriptor.create2(this.TypeScriptOpenBraceLeftTokenRange, 15 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsTypeScriptDeclWithBlockContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), 2 /* Space */), 1 /* CanDeleteNewLines */); + // Place a space before open brace in a control flow construct + this.ControlOpenBraceLeftTokenRange = formatting.Shared.TokenRange.FromTokens([18 /* CloseParenToken */, 3 /* MultiLineCommentTrivia */, 79 /* DoKeyword */, 100 /* TryKeyword */, 85 /* FinallyKeyword */, 80 /* ElseKeyword */]); + this.SpaceBeforeOpenBraceInControl = new formatting.Rule(formatting.RuleDescriptor.create2(this.ControlOpenBraceLeftTokenRange, 15 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsControlDeclContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), 2 /* Space */), 1 /* CanDeleteNewLines */); + // Insert a space after { and before } in single-line contexts, but remove space from empty object literals {}. + this.SpaceAfterOpenBrace = new formatting.Rule(formatting.RuleDescriptor.create3(15 /* OpenBraceToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSingleLineBlockContext), 2 /* Space */)); + 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.NoSpaceBetweenEmptyBraceBrackets = new formatting.Rule(formatting.RuleDescriptor.create1(15 /* OpenBraceToken */, 16 /* CloseBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, 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 */)); + // 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 */)); + // 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.IsSameLineTokenContext, 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.IsSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceAfterUnaryPredecrementOperator = new formatting.Rule(formatting.RuleDescriptor.create3(42 /* MinusMinusToken */, formatting.Shared.TokenRange.UnaryPredecrementExpressions), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceBeforeUnaryPostincrementOperator = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.UnaryPostincrementExpressions, 41 /* PlusPlusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceBeforeUnaryPostdecrementOperator = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.UnaryPostdecrementExpressions, 42 /* MinusMinusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + // More unary operator special-casing. + // DevDiv 181814: Be careful when removing leading whitespace + // around unary operators. Examples: + // 1 - -2 --X--> 1--2 + // a + ++b --X--> a+++b + this.SpaceAfterPostincrementWhenFollowedByAdd = new formatting.Rule(formatting.RuleDescriptor.create1(41 /* PlusPlusToken */, 35 /* PlusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); + this.SpaceAfterAddWhenFollowedByUnaryPlus = new formatting.Rule(formatting.RuleDescriptor.create1(35 /* PlusToken */, 35 /* PlusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); + this.SpaceAfterAddWhenFollowedByPreincrement = new formatting.Rule(formatting.RuleDescriptor.create1(35 /* PlusToken */, 41 /* PlusPlusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); + this.SpaceAfterPostdecrementWhenFollowedBySubtract = new formatting.Rule(formatting.RuleDescriptor.create1(42 /* MinusMinusToken */, 36 /* MinusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); + this.SpaceAfterSubtractWhenFollowedByUnaryMinus = new formatting.Rule(formatting.RuleDescriptor.create1(36 /* MinusToken */, 36 /* MinusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); + this.SpaceAfterSubtractWhenFollowedByPredecrement = new formatting.Rule(formatting.RuleDescriptor.create1(36 /* MinusToken */, 42 /* MinusMinusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); + this.NoSpaceBeforeComma = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 24 /* CommaToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.SpaceAfterCertainKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([102 /* VarKeyword */, 98 /* ThrowKeyword */, 92 /* NewKeyword */, 78 /* DeleteKeyword */, 94 /* ReturnKeyword */, 101 /* TypeOfKeyword */, 119 /* AwaitKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); + this.SpaceAfterLetConstInVariableDeclaration = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([108 /* LetKeyword */, 74 /* ConstKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsStartOfVariableDeclarationList), 2 /* Space */)); + this.NoSpaceBeforeOpenParenInFuncCall = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 17 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsFunctionCallOrNewContext, Rules.IsPreviousTokenNotComma), 8 /* Delete */)); + this.SpaceAfterFunctionInFuncDecl = new formatting.Rule(formatting.RuleDescriptor.create3(87 /* FunctionKeyword */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2 /* Space */)); + this.NoSpaceBeforeOpenParenInFuncDecl = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 17 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsFunctionDeclContext), 8 /* Delete */)); + this.SpaceAfterVoidOperator = new formatting.Rule(formatting.RuleDescriptor.create3(103 /* VoidKeyword */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsVoidOpContext), 2 /* Space */)); + this.NoSpaceBetweenReturnAndSemicolon = new formatting.Rule(formatting.RuleDescriptor.create1(94 /* ReturnKeyword */, 23 /* SemicolonToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + // Add a space between statements. All keywords except (do,else,case) has open/close parens after them. + // So, we have a rule to add a space for [),Any], [do,Any], [else,Any], and [case,Any] + this.SpaceBetweenStatements = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([18 /* CloseParenToken */, 79 /* DoKeyword */, 80 /* ElseKeyword */, 71 /* CaseKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotForContext), 2 /* Space */)); + // This low-pri rule takes care of "try {" and "finally {" in case the rule SpaceBeforeOpenBraceInControl didn't execute on FormatOnEnter. + this.SpaceAfterTryFinally = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([100 /* TryKeyword */, 85 /* FinallyKeyword */]), 15 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); + // get x() {} + // set x(val) {} + this.SpaceAfterGetSetInMember = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([123 /* GetKeyword */, 129 /* SetKeyword */]), 69 /* Identifier */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2 /* Space */)); + // Special case for binary operators (that are keywords). For these we have to add a space and shouldn't follow any user options. + this.SpaceBeforeBinaryKeywordOperator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.BinaryKeywordOperators), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); + this.SpaceAfterBinaryKeywordOperator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.BinaryKeywordOperators, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); + // TypeScript-specific higher priority rules + // Treat constructor as an identifier in a function declaration, and remove spaces between constructor and following left parentheses + this.NoSpaceAfterConstructor = new formatting.Rule(formatting.RuleDescriptor.create1(121 /* ConstructorKeyword */, 17 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + // Use of module as a function call. e.g.: import m2 = module("m2"); + this.NoSpaceAfterModuleImport = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([125 /* ModuleKeyword */, 127 /* RequireKeyword */]), 17 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + // Add a space around certain TypeScript keywords + this.SpaceAfterCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([115 /* AbstractKeyword */, 73 /* ClassKeyword */, 122 /* DeclareKeyword */, 77 /* DefaultKeyword */, 81 /* EnumKeyword */, 82 /* ExportKeyword */, 83 /* ExtendsKeyword */, 123 /* GetKeyword */, 106 /* ImplementsKeyword */, 89 /* ImportKeyword */, 107 /* InterfaceKeyword */, 125 /* ModuleKeyword */, 126 /* NamespaceKeyword */, 110 /* PrivateKeyword */, 112 /* PublicKeyword */, 111 /* ProtectedKeyword */, 129 /* SetKeyword */, 113 /* StaticKeyword */, 132 /* TypeKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); + this.SpaceBeforeCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([83 /* ExtendsKeyword */, 106 /* ImplementsKeyword */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); + // Treat string literals in module names as identifiers, and add a space between the literal and the opening Brace braces, e.g.: module "m2" { + this.SpaceAfterModuleName = new formatting.Rule(formatting.RuleDescriptor.create1(9 /* StringLiteral */, 15 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsModuleDeclContext), 2 /* Space */)); + // Lambda expressions + this.SpaceAfterArrow = new formatting.Rule(formatting.RuleDescriptor.create3(34 /* EqualsGreaterThanToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); + // Optional parameters and let args + this.NoSpaceAfterEllipsis = new formatting.Rule(formatting.RuleDescriptor.create1(22 /* DotDotDotToken */, 69 /* Identifier */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceAfterOptionalParameters = new formatting.Rule(formatting.RuleDescriptor.create3(53 /* QuestionToken */, formatting.Shared.TokenRange.FromTokens([18 /* CloseParenToken */, 24 /* CommaToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 8 /* Delete */)); + // generics and type assertions + this.NoSpaceBeforeOpenAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.TypeNames, 25 /* LessThanToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), 8 /* Delete */)); + this.NoSpaceBetweenCloseParenAndAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create1(18 /* CloseParenToken */, 25 /* LessThanToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), 8 /* Delete */)); + this.NoSpaceAfterOpenAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create3(25 /* LessThanToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, 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.IsSameLineTokenContext, 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.IsSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), 8 /* Delete */)); + this.NoSpaceAfterTypeAssertion = new formatting.Rule(formatting.RuleDescriptor.create3(27 /* GreaterThanToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsTypeAssertionContext), 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.IsSameLineTokenContext, 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.IsSameLineTokenContext), 2 /* Space */)); + this.NoSpaceAfterAt = new formatting.Rule(formatting.RuleDescriptor.create3(55 /* AtToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.SpaceAfterDecorator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([115 /* AbstractKeyword */, 69 /* Identifier */, 82 /* ExportKeyword */, 77 /* DefaultKeyword */, 73 /* ClassKeyword */, 113 /* StaticKeyword */, 112 /* PublicKeyword */, 110 /* PrivateKeyword */, 111 /* ProtectedKeyword */, 123 /* GetKeyword */, 129 /* SetKeyword */, 19 /* OpenBracketToken */, 37 /* AsteriskToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsEndOfDecoratorContextOnSameLine), 2 /* Space */)); + this.NoSpaceBetweenFunctionKeywordAndStar = new formatting.Rule(formatting.RuleDescriptor.create1(87 /* FunctionKeyword */, 37 /* AsteriskToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclarationOrFunctionExpressionContext), 8 /* Delete */)); + this.SpaceAfterStarInGeneratorDeclaration = new formatting.Rule(formatting.RuleDescriptor.create3(37 /* AsteriskToken */, formatting.Shared.TokenRange.FromTokens([69 /* Identifier */, 17 /* OpenParenToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclarationOrFunctionExpressionContext), 2 /* Space */)); + this.NoSpaceBetweenYieldKeywordAndStar = new formatting.Rule(formatting.RuleDescriptor.create1(114 /* YieldKeyword */, 37 /* AsteriskToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsYieldOrYieldStarWithOperand), 8 /* Delete */)); + this.SpaceBetweenYieldOrYieldStarAndOperand = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([114 /* YieldKeyword */, 37 /* AsteriskToken */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsYieldOrYieldStarWithOperand), 2 /* Space */)); + // Async-await + this.SpaceBetweenAsyncAndOpenParen = new formatting.Rule(formatting.RuleDescriptor.create1(118 /* AsyncKeyword */, 17 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsArrowFunctionContext, Rules.IsSameLineTokenContext), 2 /* Space */)); + this.SpaceBetweenAsyncAndFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(118 /* AsyncKeyword */, 87 /* FunctionKeyword */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); + // template string + this.SpaceBetweenTagAndTemplateString = new formatting.Rule(formatting.RuleDescriptor.create3(69 /* Identifier */, formatting.Shared.TokenRange.FromTokens([11 /* NoSubstitutionTemplateLiteral */, 12 /* TemplateHead */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); + this.NoSpaceAfterTemplateHeadAndMiddle = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([12 /* TemplateHead */, 13 /* TemplateMiddle */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceBeforeTemplateMiddleAndTail = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([13 /* TemplateMiddle */, 14 /* TemplateTail */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + // These rules are higher in priority than user-configurable rules. + this.HighPriorityCommonRules = + [ + this.IgnoreBeforeComment, this.IgnoreAfterLineComment, + this.NoSpaceBeforeColon, this.SpaceAfterColon, this.NoSpaceBeforeQuestionMark, this.SpaceAfterQuestionMarkInConditionalOperator, + this.NoSpaceAfterQuestionMark, + this.NoSpaceBeforeDot, this.NoSpaceAfterDot, + this.NoSpaceAfterUnaryPrefixOperator, + this.NoSpaceAfterUnaryPreincrementOperator, this.NoSpaceAfterUnaryPredecrementOperator, + this.NoSpaceBeforeUnaryPostincrementOperator, this.NoSpaceBeforeUnaryPostdecrementOperator, + this.SpaceAfterPostincrementWhenFollowedByAdd, + this.SpaceAfterAddWhenFollowedByUnaryPlus, this.SpaceAfterAddWhenFollowedByPreincrement, + this.SpaceAfterPostdecrementWhenFollowedBySubtract, + this.SpaceAfterSubtractWhenFollowedByUnaryMinus, this.SpaceAfterSubtractWhenFollowedByPredecrement, + this.NoSpaceAfterCloseBrace, + this.SpaceAfterOpenBrace, this.SpaceBeforeCloseBrace, this.NewLineBeforeCloseBraceInBlockContext, + this.SpaceAfterCloseBrace, this.SpaceBetweenCloseBraceAndElse, this.SpaceBetweenCloseBraceAndWhile, this.NoSpaceBetweenEmptyBraceBrackets, + this.NoSpaceBetweenFunctionKeywordAndStar, this.SpaceAfterStarInGeneratorDeclaration, + this.SpaceAfterFunctionInFuncDecl, this.NewLineAfterOpenBraceInBlockContext, this.SpaceAfterGetSetInMember, + this.NoSpaceBetweenYieldKeywordAndStar, this.SpaceBetweenYieldOrYieldStarAndOperand, + this.NoSpaceBetweenReturnAndSemicolon, + this.SpaceAfterCertainKeywords, + this.SpaceAfterLetConstInVariableDeclaration, + this.NoSpaceBeforeOpenParenInFuncCall, + this.SpaceBeforeBinaryKeywordOperator, this.SpaceAfterBinaryKeywordOperator, + this.SpaceAfterVoidOperator, + this.SpaceBetweenAsyncAndOpenParen, this.SpaceBetweenAsyncAndFunctionKeyword, + this.SpaceBetweenTagAndTemplateString, this.NoSpaceAfterTemplateHeadAndMiddle, this.NoSpaceBeforeTemplateMiddleAndTail, + // TypeScript-specific rules + this.NoSpaceAfterConstructor, this.NoSpaceAfterModuleImport, + this.SpaceAfterCertainTypeScriptKeywords, this.SpaceBeforeCertainTypeScriptKeywords, + this.SpaceAfterModuleName, + this.SpaceAfterArrow, + this.NoSpaceAfterEllipsis, + this.NoSpaceAfterOptionalParameters, + this.NoSpaceBetweenEmptyInterfaceBraceBrackets, + this.NoSpaceBeforeOpenAngularBracket, + this.NoSpaceBetweenCloseParenAndAngularBracket, + this.NoSpaceAfterOpenAngularBracket, + this.NoSpaceBeforeCloseAngularBracket, + this.NoSpaceAfterCloseAngularBracket, + this.NoSpaceAfterTypeAssertion, + this.SpaceBeforeAt, + this.NoSpaceAfterAt, + this.SpaceAfterDecorator, + ]; + // These rules are lower in priority than user-configurable rules. + this.LowPriorityCommonRules = + [ + this.NoSpaceBeforeSemicolon, + this.SpaceBeforeOpenBraceInControl, this.SpaceBeforeOpenBraceInFunction, this.SpaceBeforeOpenBraceInTypeScriptDeclWithBlock, + this.NoSpaceBeforeComma, + this.NoSpaceBeforeOpenBracket, + this.NoSpaceAfterCloseBracket, + this.SpaceAfterSemicolon, + this.NoSpaceBeforeOpenParenInFuncDecl, + this.SpaceBetweenStatements, this.SpaceAfterTryFinally + ]; + /// + /// 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.IsSameLineTokenContext), 2 /* Space */)); + this.NoSpaceAfterComma = new formatting.Rule(formatting.RuleDescriptor.create3(24 /* CommaToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 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.IsSameLineTokenContext, 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.IsSameLineTokenContext, 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.IsSameLineTokenContext, 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.IsSameLineTokenContext, 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 */)); + // 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 */); + // 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 */); + // 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 */); + // 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.IsSameLineTokenContext, 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.IsSameLineTokenContext, 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.IsSameLineTokenContext), 2 /* Space */)); + this.SpaceBeforeCloseParen = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 18 /* CloseParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); + this.NoSpaceBetweenParens = new formatting.Rule(formatting.RuleDescriptor.create1(17 /* OpenParenToken */, 18 /* CloseParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceAfterOpenParen = new formatting.Rule(formatting.RuleDescriptor.create3(17 /* OpenParenToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceBeforeCloseParen = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 18 /* CloseParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 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.IsSameLineTokenContext), 2 /* Space */)); + this.SpaceBeforeCloseBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 20 /* CloseBracketToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); + this.NoSpaceBetweenBrackets = new formatting.Rule(formatting.RuleDescriptor.create1(19 /* OpenBracketToken */, 20 /* CloseBracketToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceAfterOpenBracket = new formatting.Rule(formatting.RuleDescriptor.create3(19 /* OpenBracketToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceBeforeCloseBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 20 /* CloseBracketToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + // Insert space after function keyword for anonymous functions + this.SpaceAfterAnonymousFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(87 /* FunctionKeyword */, 17 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2 /* Space */)); + this.NoSpaceAfterAnonymousFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(87 /* FunctionKeyword */, 17 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 8 /* Delete */)); + } + Rules.prototype.getRuleName = function (rule) { + var o = this; + for (var name_32 in o) { + if (o[name_32] === rule) { + return name_32; + } + } + throw new Error("Unknown rule"); + }; + /// + /// Contexts + /// + Rules.IsForContext = function (context) { + return context.contextNode.kind === 199 /* ForStatement */; + }; + Rules.IsNotForContext = function (context) { + return !Rules.IsForContext(context); + }; + Rules.IsBinaryOpContext = function (context) { + switch (context.contextNode.kind) { + case 181 /* BinaryExpression */: + case 182 /* ConditionalExpression */: + case 189 /* AsExpression */: + case 150 /* TypePredicate */: + case 158 /* UnionType */: + case 159 /* IntersectionType */: + return true; + // equals in binding elements: function foo([[x, y] = [1, 2]]) + case 163 /* BindingElement */: + // equals in type X = ... + case 216 /* TypeAliasDeclaration */: + // equal in import a = module('a'); + case 221 /* ImportEqualsDeclaration */: + // equal in let a = 0; + case 211 /* VariableDeclaration */: + // equal in p = 0; + case 138 /* Parameter */: + case 247 /* EnumMember */: + case 141 /* PropertyDeclaration */: + case 140 /* PropertySignature */: + return context.currentTokenSpan.kind === 56 /* EqualsToken */ || context.nextTokenSpan.kind === 56 /* EqualsToken */; + // "in" keyword in for (let x in []) { } + case 200 /* ForInStatement */: + return context.currentTokenSpan.kind === 90 /* InKeyword */ || context.nextTokenSpan.kind === 90 /* InKeyword */; + // Technically, "of" is not a binary operator, but format it the same way as "in" + case 201 /* ForOfStatement */: + return context.currentTokenSpan.kind === 134 /* OfKeyword */ || context.nextTokenSpan.kind === 134 /* OfKeyword */; + } + return false; + }; + Rules.IsNotBinaryOpContext = function (context) { + return !Rules.IsBinaryOpContext(context); + }; + Rules.IsConditionalOperatorContext = function (context) { + return context.contextNode.kind === 182 /* ConditionalExpression */; + }; + Rules.IsSameLineTokenOrBeforeMultilineBlockContext = function (context) { + //// This check is mainly used inside SpaceBeforeOpenBraceInControl and SpaceBeforeOpenBraceInFunction. + //// + //// Ex: + //// if (1) { .... + //// * ) and { are on the same line so apply the rule. Here we don't care whether it's same or multi block context + //// + //// Ex: + //// if (1) + //// { ... } + //// * ) and { are on differnet lines. We only need to format if the block is multiline context. So in this case we don't format. + //// + //// Ex: + //// if (1) + //// { ... + //// } + //// * ) and { are on differnet lines. We only need to format if the block is multiline context. So in this case we format. + return context.TokensAreOnSameLine() || Rules.IsBeforeMultilineBlockContext(context); + }; + // This check is done before an open brace in a control construct, a function, or a typescript block declaration + Rules.IsBeforeMultilineBlockContext = function (context) { + return Rules.IsBeforeBlockContext(context) && !(context.NextNodeAllOnSameLine() || context.NextNodeBlockIsOnOneLine()); + }; + Rules.IsMultilineBlockContext = function (context) { + return Rules.IsBlockContext(context) && !(context.ContextNodeAllOnSameLine() || context.ContextNodeBlockIsOnOneLine()); + }; + Rules.IsSingleLineBlockContext = function (context) { + return Rules.IsBlockContext(context) && (context.ContextNodeAllOnSameLine() || context.ContextNodeBlockIsOnOneLine()); + }; + Rules.IsBlockContext = function (context) { + return Rules.NodeIsBlockContext(context.contextNode); + }; + Rules.IsBeforeBlockContext = function (context) { + return Rules.NodeIsBlockContext(context.nextTokenParent); + }; + // IMPORTANT!!! This method must return true ONLY for nodes with open and close braces as immediate children + Rules.NodeIsBlockContext = function (node) { + if (Rules.NodeIsTypeScriptDeclWithBlockContext(node)) { + // This means we are in a context that looks like a block to the user, but in the grammar is actually not a node (it's a class, module, enum, object type literal, etc). + return true; + } + switch (node.kind) { + case 192 /* Block */: + case 220 /* CaseBlock */: + case 165 /* ObjectLiteralExpression */: + case 219 /* ModuleBlock */: + return true; + } + return false; + }; + Rules.IsFunctionDeclContext = function (context) { + switch (context.contextNode.kind) { + case 213 /* FunctionDeclaration */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: + //case SyntaxKind.MemberFunctionDeclaration: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: + ///case SyntaxKind.MethodSignature: + case 147 /* CallSignature */: + case 173 /* FunctionExpression */: + case 144 /* Constructor */: + case 174 /* ArrowFunction */: + //case SyntaxKind.ConstructorDeclaration: + //case SyntaxKind.SimpleArrowFunctionExpression: + //case SyntaxKind.ParenthesizedArrowFunctionExpression: + case 215 /* InterfaceDeclaration */: + return true; + } + return false; + }; + Rules.IsFunctionDeclarationOrFunctionExpressionContext = function (context) { + return context.contextNode.kind === 213 /* FunctionDeclaration */ || context.contextNode.kind === 173 /* FunctionExpression */; + }; + Rules.IsTypeScriptDeclWithBlockContext = function (context) { + return Rules.NodeIsTypeScriptDeclWithBlockContext(context.contextNode); + }; + Rules.NodeIsTypeScriptDeclWithBlockContext = function (node) { + switch (node.kind) { + case 214 /* ClassDeclaration */: + case 186 /* ClassExpression */: + case 215 /* InterfaceDeclaration */: + case 217 /* EnumDeclaration */: + case 155 /* TypeLiteral */: + case 218 /* ModuleDeclaration */: + return true; + } + return false; + }; + Rules.IsAfterCodeBlockContext = function (context) { + switch (context.currentTokenParent.kind) { + case 214 /* ClassDeclaration */: + case 218 /* ModuleDeclaration */: + case 217 /* EnumDeclaration */: + case 192 /* Block */: + case 244 /* CatchClause */: + case 219 /* ModuleBlock */: + case 206 /* SwitchStatement */: + return true; + } + return false; + }; + Rules.IsControlDeclContext = function (context) { + switch (context.contextNode.kind) { + case 196 /* IfStatement */: + case 206 /* SwitchStatement */: + case 199 /* ForStatement */: + case 200 /* ForInStatement */: + case 201 /* ForOfStatement */: + case 198 /* WhileStatement */: + case 209 /* TryStatement */: + case 197 /* DoStatement */: + case 205 /* WithStatement */: + // TODO + // case SyntaxKind.ElseClause: + case 244 /* CatchClause */: + return true; + default: + return false; + } + }; + Rules.IsObjectContext = function (context) { + return context.contextNode.kind === 165 /* ObjectLiteralExpression */; + }; + Rules.IsFunctionCallContext = function (context) { + return context.contextNode.kind === 168 /* CallExpression */; + }; + Rules.IsNewContext = function (context) { + return context.contextNode.kind === 169 /* NewExpression */; + }; + Rules.IsFunctionCallOrNewContext = function (context) { + return Rules.IsFunctionCallContext(context) || Rules.IsNewContext(context); + }; + Rules.IsPreviousTokenNotComma = function (context) { + return context.currentTokenSpan.kind !== 24 /* CommaToken */; + }; + Rules.IsArrowFunctionContext = function (context) { + return context.contextNode.kind === 174 /* ArrowFunction */; + }; + Rules.IsSameLineTokenContext = function (context) { + return context.TokensAreOnSameLine(); + }; + Rules.IsNotBeforeBlockInFunctionDeclarationContext = function (context) { + return !Rules.IsFunctionDeclContext(context) && !Rules.IsBeforeBlockContext(context); + }; + Rules.IsEndOfDecoratorContextOnSameLine = function (context) { + return context.TokensAreOnSameLine() && + context.contextNode.decorators && + Rules.NodeIsInDecoratorContext(context.currentTokenParent) && + !Rules.NodeIsInDecoratorContext(context.nextTokenParent); + }; + Rules.NodeIsInDecoratorContext = function (node) { + while (ts.isExpression(node)) { + node = node.parent; + } + return node.kind === 139 /* Decorator */; + }; + Rules.IsStartOfVariableDeclarationList = function (context) { + return context.currentTokenParent.kind === 212 /* VariableDeclarationList */ && + context.currentTokenParent.getStart(context.sourceFile) === context.currentTokenSpan.pos; + }; + Rules.IsNotFormatOnEnter = function (context) { + return context.formattingRequestKind !== 2 /* FormatOnEnter */; + }; + Rules.IsModuleDeclContext = function (context) { + return context.contextNode.kind === 218 /* ModuleDeclaration */; + }; + Rules.IsObjectTypeContext = function (context) { + return context.contextNode.kind === 155 /* TypeLiteral */; // && context.contextNode.parent.kind !== SyntaxKind.InterfaceDeclaration; + }; + Rules.IsTypeArgumentOrParameterOrAssertion = function (token, parent) { + if (token.kind !== 25 /* LessThanToken */ && token.kind !== 27 /* GreaterThanToken */) { + return false; + } + switch (parent.kind) { + case 151 /* TypeReference */: + case 171 /* TypeAssertionExpression */: + case 214 /* ClassDeclaration */: + case 186 /* ClassExpression */: + case 215 /* InterfaceDeclaration */: + case 213 /* FunctionDeclaration */: + case 173 /* FunctionExpression */: + case 174 /* ArrowFunction */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: + case 147 /* CallSignature */: + case 148 /* ConstructSignature */: + case 168 /* CallExpression */: + case 169 /* NewExpression */: + case 188 /* ExpressionWithTypeArguments */: + return true; + default: + return false; + } + }; + Rules.IsTypeArgumentOrParameterOrAssertionContext = function (context) { + return Rules.IsTypeArgumentOrParameterOrAssertion(context.currentTokenSpan, context.currentTokenParent) || + Rules.IsTypeArgumentOrParameterOrAssertion(context.nextTokenSpan, context.nextTokenParent); + }; + Rules.IsTypeAssertionContext = function (context) { + return context.contextNode.kind === 171 /* TypeAssertionExpression */; + }; + Rules.IsVoidOpContext = function (context) { + return context.currentTokenSpan.kind === 103 /* VoidKeyword */ && context.currentTokenParent.kind === 177 /* VoidExpression */; + }; + Rules.IsYieldOrYieldStarWithOperand = function (context) { + return context.contextNode.kind === 184 /* YieldExpression */ && context.contextNode.expression !== undefined; + }; + return Rules; + })(); + formatting.Rules = Rules; + })(formatting = ts.formatting || (ts.formatting = {})); +})(ts || (ts = {})); +/// +/* @internal */ +var ts; +(function (ts) { + var formatting; + (function (formatting) { + var RulesMap = (function () { + function RulesMap() { + this.map = []; + this.mapRowLength = 0; + } + RulesMap.create = function (rules) { + var result = new RulesMap(); + result.Initialize(rules); + return result; + }; + RulesMap.prototype.Initialize = function (rules) { + this.mapRowLength = 134 /* LastToken */ + 1; + this.map = new Array(this.mapRowLength * this.mapRowLength); //new Array(this.mapRowLength * this.mapRowLength); + // This array is used only during construction of the rulesbucket in the map + var rulesBucketConstructionStateList = new Array(this.map.length); //new Array(this.map.length); + this.FillRules(rules, rulesBucketConstructionStateList); + return this.map; + }; + RulesMap.prototype.FillRules = function (rules, rulesBucketConstructionStateList) { + var _this = this; + rules.forEach(function (rule) { + _this.FillRule(rule, rulesBucketConstructionStateList); + }); + }; + RulesMap.prototype.GetRuleBucketIndex = function (row, column) { + 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) { + var _this = this; + var specificRule = rule.Descriptor.LeftTokenRange !== formatting.Shared.TokenRange.Any && + rule.Descriptor.RightTokenRange !== formatting.Shared.TokenRange.Any; + rule.Descriptor.LeftTokenRange.GetTokens().forEach(function (left) { + rule.Descriptor.RightTokenRange.GetTokens().forEach(function (right) { + var rulesBucketIndex = _this.GetRuleBucketIndex(left, right); + var rulesBucket = _this.map[rulesBucketIndex]; + if (rulesBucket === undefined) { + rulesBucket = _this.map[rulesBucketIndex] = new RulesBucket(); + } + rulesBucket.AddRule(rule, specificRule, rulesBucketConstructionStateList, rulesBucketIndex); + }); + }); + }; + RulesMap.prototype.GetRule = function (context) { + var bucketIndex = this.GetRuleBucketIndex(context.currentTokenSpan.kind, context.nextTokenSpan.kind); + var bucket = this.map[bucketIndex]; + if (bucket != null) { + for (var _i = 0, _a = bucket.Rules(); _i < _a.length; _i++) { + var rule = _a[_i]; + if (rule.Operation.Context.InContext(context)) { + return rule; + } + } + } + return null; + }; + return RulesMap; + })(); + formatting.RulesMap = RulesMap; + var MaskBitSize = 5; + var Mask = 0x1f; + (function (RulesPosition) { + RulesPosition[RulesPosition["IgnoreRulesSpecific"] = 0] = "IgnoreRulesSpecific"; + RulesPosition[RulesPosition["IgnoreRulesAny"] = MaskBitSize * 1] = "IgnoreRulesAny"; + RulesPosition[RulesPosition["ContextRulesSpecific"] = MaskBitSize * 2] = "ContextRulesSpecific"; + RulesPosition[RulesPosition["ContextRulesAny"] = MaskBitSize * 3] = "ContextRulesAny"; + RulesPosition[RulesPosition["NoContextRulesSpecific"] = MaskBitSize * 4] = "NoContextRulesSpecific"; + RulesPosition[RulesPosition["NoContextRulesAny"] = MaskBitSize * 5] = "NoContextRulesAny"; + })(formatting.RulesPosition || (formatting.RulesPosition = {})); + var RulesPosition = formatting.RulesPosition; + var RulesBucketConstructionState = (function () { + function RulesBucketConstructionState() { + //// The Rules list contains all the inserted rules into a rulebucket in the following order: + //// 1- Ignore rules with specific token combination + //// 2- Ignore rules with any token combination + //// 3- Context rules with specific token combination + //// 4- Context rules with any token combination + //// 5- Non-context rules with specific token combination + //// 6- Non-context rules with any token combination + //// + //// The member rulesInsertionIndexBitmap is used to describe the number of rules + //// in each sub-bucket (above) hence can be used to know the index of where to insert + //// the next rule. It's a bitmap which contains 6 different sections each is given 5 bits. + //// + //// Example: + //// In order to insert a rule to the end of sub-bucket (3), we get the index by adding + //// the values in the bitmap segments 3rd, 2nd, and 1st. + this.rulesInsertionIndexBitmap = 0; + } + RulesBucketConstructionState.prototype.GetInsertionIndex = function (maskPosition) { + var index = 0; + var pos = 0; + var indexBitmap = this.rulesInsertionIndexBitmap; + while (pos <= maskPosition) { + index += (indexBitmap & Mask); + indexBitmap >>= MaskBitSize; + pos += MaskBitSize; + } + return index; + }; + RulesBucketConstructionState.prototype.IncreaseInsertionIndex = function (maskPosition) { + var value = (this.rulesInsertionIndexBitmap >> maskPosition) & Mask; + value++; + ts.Debug.assert((value & Mask) === value, "Adding more rules into the sub-bucket than allowed. Maximum allowed is 32 rules."); + var temp = this.rulesInsertionIndexBitmap & ~(Mask << maskPosition); + temp |= value << maskPosition; + this.rulesInsertionIndexBitmap = temp; + }; + return RulesBucketConstructionState; + })(); + formatting.RulesBucketConstructionState = RulesBucketConstructionState; + var RulesBucket = (function () { + function RulesBucket() { + this.rules = []; + } + RulesBucket.prototype.Rules = function () { + return this.rules; + }; + RulesBucket.prototype.AddRule = function (rule, specificTokens, constructionState, rulesBucketIndex) { + var position; + if (rule.Operation.Action === 1 /* Ignore */) { + position = specificTokens ? + RulesPosition.IgnoreRulesSpecific : + RulesPosition.IgnoreRulesAny; + } + else if (!rule.Operation.Context.IsAny()) { + position = specificTokens ? + RulesPosition.ContextRulesSpecific : + RulesPosition.ContextRulesAny; + } + else { + position = specificTokens ? + RulesPosition.NoContextRulesSpecific : + RulesPosition.NoContextRulesAny; + } + var state = constructionState[rulesBucketIndex]; + if (state === undefined) { + state = constructionState[rulesBucketIndex] = new RulesBucketConstructionState(); + } + var index = state.GetInsertionIndex(position); + this.rules.splice(index, 0, rule); + state.IncreaseInsertionIndex(position); + }; + return RulesBucket; + })(); + formatting.RulesBucket = RulesBucket; + })(formatting = ts.formatting || (ts.formatting = {})); +})(ts || (ts = {})); +/// +/* @internal */ +var ts; +(function (ts) { + var formatting; + (function (formatting) { + var Shared; + (function (Shared) { + var TokenRangeAccess = (function () { + function TokenRangeAccess(from, to, except) { + this.tokens = []; + for (var token = from; token <= to; token++) { + if (except.indexOf(token) < 0) { + this.tokens.push(token); + } + } + } + TokenRangeAccess.prototype.GetTokens = function () { + return this.tokens; + }; + TokenRangeAccess.prototype.Contains = function (token) { + return this.tokens.indexOf(token) >= 0; + }; + return TokenRangeAccess; + })(); + Shared.TokenRangeAccess = TokenRangeAccess; + var TokenValuesAccess = (function () { + function TokenValuesAccess(tks) { + this.tokens = tks && tks.length ? tks : []; + } + TokenValuesAccess.prototype.GetTokens = function () { + return this.tokens; + }; + TokenValuesAccess.prototype.Contains = function (token) { + return this.tokens.indexOf(token) >= 0; + }; + return TokenValuesAccess; + })(); + Shared.TokenValuesAccess = TokenValuesAccess; + var TokenSingleValueAccess = (function () { + function TokenSingleValueAccess(token) { + this.token = token; + } + TokenSingleValueAccess.prototype.GetTokens = function () { + return [this.token]; + }; + TokenSingleValueAccess.prototype.Contains = function (tokenValue) { + return tokenValue === this.token; + }; + return TokenSingleValueAccess; + })(); + Shared.TokenSingleValueAccess = TokenSingleValueAccess; + var TokenAllAccess = (function () { + function TokenAllAccess() { + } + TokenAllAccess.prototype.GetTokens = function () { + var result = []; + for (var token = 0 /* FirstToken */; token <= 134 /* LastToken */; token++) { + result.push(token); + } + return result; + }; + TokenAllAccess.prototype.Contains = function (tokenValue) { + return true; + }; + TokenAllAccess.prototype.toString = function () { + return "[allTokens]"; + }; + return TokenAllAccess; + })(); + Shared.TokenAllAccess = TokenAllAccess; + var TokenRange = (function () { + function TokenRange(tokenAccess) { + this.tokenAccess = tokenAccess; + } + TokenRange.FromToken = function (token) { + return new TokenRange(new TokenSingleValueAccess(token)); + }; + TokenRange.FromTokens = function (tokens) { + return new TokenRange(new TokenValuesAccess(tokens)); + }; + TokenRange.FromRange = function (f, to, except) { + if (except === void 0) { except = []; } + return new TokenRange(new TokenRangeAccess(f, to, except)); + }; + TokenRange.AllTokens = function () { + return new TokenRange(new TokenAllAccess()); + }; + TokenRange.prototype.GetTokens = function () { + return this.tokenAccess.GetTokens(); + }; + TokenRange.prototype.Contains = function (token) { + return this.tokenAccess.Contains(token); + }; + TokenRange.prototype.toString = function () { + return this.tokenAccess.toString(); + }; + TokenRange.Any = TokenRange.AllTokens(); + TokenRange.AnyIncludingMultilineComments = TokenRange.FromTokens(TokenRange.Any.GetTokens().concat([3 /* MultiLineCommentTrivia */])); + TokenRange.Keywords = TokenRange.FromRange(70 /* FirstKeyword */, 134 /* LastKeyword */); + TokenRange.BinaryOperators = TokenRange.FromRange(25 /* FirstBinaryOperator */, 68 /* LastBinaryOperator */); + TokenRange.BinaryKeywordOperators = TokenRange.FromTokens([90 /* InKeyword */, 91 /* InstanceOfKeyword */, 134 /* OfKeyword */, 116 /* AsKeyword */, 124 /* IsKeyword */]); + TokenRange.UnaryPrefixOperators = TokenRange.FromTokens([41 /* PlusPlusToken */, 42 /* MinusMinusToken */, 50 /* TildeToken */, 49 /* ExclamationToken */]); + TokenRange.UnaryPrefixExpressions = TokenRange.FromTokens([8 /* NumericLiteral */, 69 /* Identifier */, 17 /* OpenParenToken */, 19 /* OpenBracketToken */, 15 /* OpenBraceToken */, 97 /* ThisKeyword */, 92 /* NewKeyword */]); + TokenRange.UnaryPreincrementExpressions = TokenRange.FromTokens([69 /* Identifier */, 17 /* OpenParenToken */, 97 /* ThisKeyword */, 92 /* NewKeyword */]); + TokenRange.UnaryPostincrementExpressions = TokenRange.FromTokens([69 /* Identifier */, 18 /* CloseParenToken */, 20 /* CloseBracketToken */, 92 /* NewKeyword */]); + TokenRange.UnaryPredecrementExpressions = TokenRange.FromTokens([69 /* Identifier */, 17 /* OpenParenToken */, 97 /* ThisKeyword */, 92 /* NewKeyword */]); + TokenRange.UnaryPostdecrementExpressions = TokenRange.FromTokens([69 /* Identifier */, 18 /* CloseParenToken */, 20 /* CloseBracketToken */, 92 /* NewKeyword */]); + TokenRange.Comments = TokenRange.FromTokens([2 /* SingleLineCommentTrivia */, 3 /* MultiLineCommentTrivia */]); + TokenRange.TypeNames = TokenRange.FromTokens([69 /* Identifier */, 128 /* NumberKeyword */, 130 /* StringKeyword */, 120 /* BooleanKeyword */, 131 /* SymbolKeyword */, 103 /* VoidKeyword */, 117 /* AnyKeyword */]); + return TokenRange; + })(); + Shared.TokenRange = TokenRange; + })(Shared = formatting.Shared || (formatting.Shared = {})); + })(formatting = ts.formatting || (ts.formatting = {})); +})(ts || (ts = {})); +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/* @internal */ +var ts; +(function (ts) { + var formatting; + (function (formatting) { + var RulesProvider = (function () { + function RulesProvider() { + this.globalRules = new formatting.Rules(); + } + RulesProvider.prototype.getRuleName = function (rule) { + return this.globalRules.getRuleName(rule); + }; + RulesProvider.prototype.getRuleByName = function (name) { + return this.globalRules[name]; + }; + RulesProvider.prototype.getRulesMap = function () { + return this.rulesMap; + }; + RulesProvider.prototype.ensureUpToDate = function (options) { + // TODO: Should this be '==='? + if (this.options == null || !ts.compareDataObjects(this.options, options)) { + var activeRules = this.createActiveRules(options); + var rulesMap = formatting.RulesMap.create(activeRules); + this.activeRules = activeRules; + this.rulesMap = rulesMap; + this.options = ts.clone(options); + } + }; + RulesProvider.prototype.createActiveRules = function (options) { + var rules = this.globalRules.HighPriorityCommonRules.slice(0); + if (options.InsertSpaceAfterCommaDelimiter) { + rules.push(this.globalRules.SpaceAfterComma); + } + else { + rules.push(this.globalRules.NoSpaceAfterComma); + } + if (options.InsertSpaceAfterFunctionKeywordForAnonymousFunctions) { + rules.push(this.globalRules.SpaceAfterAnonymousFunctionKeyword); + } + else { + rules.push(this.globalRules.NoSpaceAfterAnonymousFunctionKeyword); + } + if (options.InsertSpaceAfterKeywordsInControlFlowStatements) { + rules.push(this.globalRules.SpaceAfterKeywordInControl); + } + else { + rules.push(this.globalRules.NoSpaceAfterKeywordInControl); + } + if (options.InsertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis) { + rules.push(this.globalRules.SpaceAfterOpenParen); + rules.push(this.globalRules.SpaceBeforeCloseParen); + rules.push(this.globalRules.NoSpaceBetweenParens); + } + else { + rules.push(this.globalRules.NoSpaceAfterOpenParen); + rules.push(this.globalRules.NoSpaceBeforeCloseParen); + rules.push(this.globalRules.NoSpaceBetweenParens); + } + if (options.InsertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets) { + rules.push(this.globalRules.SpaceAfterOpenBracket); + rules.push(this.globalRules.SpaceBeforeCloseBracket); + rules.push(this.globalRules.NoSpaceBetweenBrackets); + } + else { + rules.push(this.globalRules.NoSpaceAfterOpenBracket); + rules.push(this.globalRules.NoSpaceBeforeCloseBracket); + rules.push(this.globalRules.NoSpaceBetweenBrackets); + } + if (options.InsertSpaceAfterSemicolonInForStatements) { + rules.push(this.globalRules.SpaceAfterSemicolonInFor); + } + else { + rules.push(this.globalRules.NoSpaceAfterSemicolonInFor); + } + if (options.InsertSpaceBeforeAndAfterBinaryOperators) { + rules.push(this.globalRules.SpaceBeforeBinaryOperator); + rules.push(this.globalRules.SpaceAfterBinaryOperator); + } + else { + rules.push(this.globalRules.NoSpaceBeforeBinaryOperator); + rules.push(this.globalRules.NoSpaceAfterBinaryOperator); + } + if (options.PlaceOpenBraceOnNewLineForControlBlocks) { + rules.push(this.globalRules.NewLineBeforeOpenBraceInControl); + } + if (options.PlaceOpenBraceOnNewLineForFunctions) { + rules.push(this.globalRules.NewLineBeforeOpenBraceInFunction); + rules.push(this.globalRules.NewLineBeforeOpenBraceInTypeScriptDeclWithBlock); + } + rules = rules.concat(this.globalRules.LowPriorityCommonRules); + return rules; + }; + return RulesProvider; + })(); + formatting.RulesProvider = RulesProvider; + })(formatting = ts.formatting || (ts.formatting = {})); +})(ts || (ts = {})); +/// +/// +/// +/// +/* @internal */ +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) { + return []; + } + // get the span for the previous\current line + var span = { + // get start position for the previous line + pos: ts.getStartPositionOfLine(line - 1, sourceFile), + // get end position for the current line (end value is exclusive so add 1 to the result) + end: ts.getEndLinePosition(line, sourceFile) + 1 + }; + return formatSpan(span, sourceFile, options, rulesProvider, 2 /* FormatOnEnter */); + } + formatting.formatOnEnter = formatOnEnter; + function formatOnSemicolon(position, sourceFile, rulesProvider, options) { + return formatOutermostParent(position, 23 /* 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 */); + } + formatting.formatOnClosingCurly = formatOnClosingCurly; + function formatDocument(sourceFile, rulesProvider, options) { + var span = { + pos: 0, + end: sourceFile.text.length + }; + return formatSpan(span, sourceFile, options, rulesProvider, 0 /* FormatDocument */); + } + formatting.formatDocument = formatDocument; + function formatSelection(start, end, sourceFile, rulesProvider, options) { + // format from the beginning of the line + var span = { + pos: ts.getLineStartPositionForPosition(start, sourceFile), + end: end + }; + return formatSpan(span, sourceFile, options, rulesProvider, 1 /* FormatSelection */); + } + formatting.formatSelection = formatSelection; + function formatOutermostParent(position, expectedLastToken, sourceFile, options, rulesProvider, requestKind) { + var parent = findOutermostParent(position, expectedLastToken, sourceFile); + if (!parent) { + return []; + } + var span = { + pos: ts.getLineStartPositionForPosition(parent.getStart(sourceFile), sourceFile), + end: parent.end + }; + return formatSpan(span, sourceFile, options, rulesProvider, requestKind); + } + function findOutermostParent(position, expectedTokenKind, sourceFile) { + var precedingToken = ts.findPrecedingToken(position, sourceFile); + // when it is claimed that trigger character was typed at given position + // we verify that there is a token with a matching kind whose end is equal to position (because the character was just typed). + // If this condition is not hold - then trigger character was typed in some other context, + // i.e.in comment and thus should not trigger autoformatting + if (!precedingToken || + precedingToken.kind !== expectedTokenKind || + position !== precedingToken.getEnd()) { + return undefined; + } + // walk up and search for the parent node that ends at the same position with precedingToken. + // for cases like this + // + // let x = 1; + // while (true) { + // } + // after typing close curly in while statement we want to reformat just the while statement. + // However if we just walk upwards searching for the parent that has the same end value - + // we'll end up with the whole source file. isListElement allows to stop on the list element level + var current = precedingToken; + while (current && + current.parent && + current.parent.end === precedingToken.end && + !isListElement(current.parent, current)) { + current = current.parent; + } + return current; + } + // Returns true if node is a element in some list in parent + // 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 214 /* ClassDeclaration */: + case 215 /* InterfaceDeclaration */: + return ts.rangeContainsRange(parent.members, node); + case 218 /* ModuleDeclaration */: + var body = parent.body; + return body && body.kind === 192 /* Block */ && ts.rangeContainsRange(body.statements, node); + case 248 /* SourceFile */: + case 192 /* Block */: + case 219 /* ModuleBlock */: + return ts.rangeContainsRange(parent.statements, node); + case 244 /* CatchClause */: + return ts.rangeContainsRange(parent.block.statements, node); + } + return false; + } + /** find node that fully contains given text range */ + function findEnclosingNode(range, sourceFile) { + return find(sourceFile); + function find(n) { + var candidate = ts.forEachChild(n, function (c) { return ts.startEndContainsRange(c.getStart(sourceFile), c.end, range) && c; }); + if (candidate) { + var result = find(candidate); + if (result) { + return result; + } + } + return n; + } + } + /** formatting is not applied to ranges that contain parse errors. + * This function will return a predicate that for a given text range will tell + * if there are any parse errors that overlap with the range. + */ + function prepareRangeContainsErrorFunction(errors, originalRange) { + if (!errors.length) { + return rangeHasNoErrors; + } + // pick only errors that fall in range + var sorted = errors + .filter(function (d) { return ts.rangeOverlapsWithStartEnd(originalRange, d.start, d.start + d.length); }) + .sort(function (e1, e2) { return e1.start - e2.start; }); + if (!sorted.length) { + return rangeHasNoErrors; + } + var index = 0; + return function (r) { + // in current implementation sequence of arguments [r1, r2...] is monotonically increasing. + // 'index' tracks the index of the most recent error that was checked. + while (true) { + if (index >= sorted.length) { + // all errors in the range were already checked -> no error in specified range + return false; + } + var error = sorted[index]; + if (r.end <= error.start) { + // specified range ends before the error refered by 'index' - no error in range + return false; + } + if (ts.startEndOverlapsWithStartEnd(r.pos, r.end, error.start, error.start + error.length)) { + // specified range overlaps with error range + return true; + } + index++; + } + }; + function rangeHasNoErrors(r) { + return false; + } + } + /** + * Start of the original range might fall inside the comment - scanner will not yield appropriate results + * This function will look for token that is located before the start of target range + * and return its end as start position for the scanner. + */ + function getScanStartPosition(enclosingNode, originalRange, sourceFile) { + var start = enclosingNode.getStart(sourceFile); + if (start === originalRange.pos && enclosingNode.end === originalRange.end) { + return start; + } + var precedingToken = ts.findPrecedingToken(originalRange.pos, sourceFile); + if (!precedingToken) { + // no preceding token found - start from the beginning of enclosing node + return enclosingNode.pos; + } + // preceding token ends after the start of original range (i.e when originaRange.pos falls in the middle of literal) + // start from the beginning of enclosingNode to handle the entire 'originalRange' + if (precedingToken.end >= originalRange.pos) { + return enclosingNode.pos; + } + return precedingToken.end; + } + /* + * For cases like + * if (a || + * b ||$ + * c) {...} + * If we hit Enter at $ we want line ' b ||' to be indented. + * Formatting will be applied to the last two lines. + * Node that fully encloses these lines is binary expression 'a ||...'. + * Initial indentation for this node will be 0. + * Binary expressions don't introduce new indentation scopes, however it is possible + * that some parent node on the same line does - like if statement in this case. + * Note that we are considering parents only from the same line with initial node - + * if parent is on the different line - its delta was already contributed + * to the initial indentation. + */ + function getOwnOrInheritedDelta(n, options, sourceFile) { + var previousLine = -1 /* Unknown */; + var childKind = 0 /* Unknown */; + while (n) { + var line = sourceFile.getLineAndCharacterOfPosition(n.getStart(sourceFile)).line; + if (previousLine !== -1 /* Unknown */ && line !== previousLine) { + break; + } + if (formatting.SmartIndenter.shouldIndentChildNode(n.kind, childKind)) { + return options.IndentSize; + } + previousLine = line; + childKind = n.kind; + n = n.parent; + } + return 0; + } + function formatSpan(originalRange, sourceFile, options, rulesProvider, requestKind) { + var rangeContainsError = prepareRangeContainsErrorFunction(sourceFile.parseDiagnostics, originalRange); + // formatting context is used by rules provider + var formattingContext = new formatting.FormattingContext(sourceFile, requestKind); + // find the smallest node that fully wraps the range and compute the initial indentation for the node + var enclosingNode = findEnclosingNode(originalRange, sourceFile); + var formattingScanner = formatting.getFormattingScanner(sourceFile, getScanStartPosition(enclosingNode, originalRange, sourceFile), originalRange.end); + var initialIndentation = formatting.SmartIndenter.getIndentationForNode(enclosingNode, originalRange, sourceFile, options); + var previousRangeHasError; + var previousRange; + var previousParent; + var previousRangeStartLine; + var lastIndentedLine; + var indentationOnLastIndentedLine; + var edits = []; + formattingScanner.advance(); + if (formattingScanner.isOnToken()) { + var startLine = sourceFile.getLineAndCharacterOfPosition(enclosingNode.getStart(sourceFile)).line; + var undecoratedStartLine = startLine; + if (enclosingNode.decorators) { + undecoratedStartLine = sourceFile.getLineAndCharacterOfPosition(ts.getNonDecoratorTokenPosOfNode(enclosingNode, sourceFile)).line; + } + var delta = getOwnOrInheritedDelta(enclosingNode, options, sourceFile); + processNode(enclosingNode, enclosingNode, startLine, undecoratedStartLine, initialIndentation, delta); + } + formattingScanner.close(); + return edits; + // local functions + /** Tries to compute the indentation for a list element. + * If list element is not in range then + * function will pick its actual indentation + * so it can be pushed downstream as inherited indentation. + * If list element is in the range - its indentation will be equal + * to inherited indentation from its predecessors. + */ + function tryComputeIndentationForListItem(startPos, endPos, parentStartLine, range, inheritedIndentation) { + if (ts.rangeOverlapsWithStartEnd(range, startPos, endPos)) { + if (inheritedIndentation !== -1 /* Unknown */) { + return inheritedIndentation; + } + } + else { + var startLine = sourceFile.getLineAndCharacterOfPosition(startPos).line; + var startLinePosition = ts.getLineStartPositionForPosition(startPos, sourceFile); + var column = formatting.SmartIndenter.findFirstNonWhitespaceColumn(startLinePosition, startPos, sourceFile, options); + if (startLine !== parentStartLine || startPos === column) { + return column; + } + } + return -1 /* Unknown */; + } + function computeIndentation(node, startLine, inheritedIndentation, parent, parentDynamicIndentation, effectiveParentStartLine) { + var indentation = inheritedIndentation; + if (indentation === -1 /* Unknown */) { + if (isSomeBlock(node.kind)) { + // blocks should be indented in + // - other blocks + // - source file + // - switch\default clauses + if (isSomeBlock(parent.kind) || + parent.kind === 248 /* SourceFile */ || + parent.kind === 241 /* CaseClause */ || + parent.kind === 242 /* DefaultClause */) { + indentation = parentDynamicIndentation.getIndentation() + parentDynamicIndentation.getDelta(); + } + else { + indentation = parentDynamicIndentation.getIndentation(); + } + } + else { + if (formatting.SmartIndenter.childStartsOnTheSameLineWithElseInIfStatement(parent, node, startLine, sourceFile)) { + indentation = parentDynamicIndentation.getIndentation(); + } + else { + indentation = parentDynamicIndentation.getIndentation() + parentDynamicIndentation.getDelta(); + } + } + } + var delta = formatting.SmartIndenter.shouldIndentChildNode(node.kind, 0 /* Unknown */) ? options.IndentSize : 0; + if (effectiveParentStartLine === startLine) { + // if node is located on the same line with the parent + // - inherit indentation from the parent + // - push children if either parent of node itself has non-zero delta + indentation = startLine === lastIndentedLine + ? indentationOnLastIndentedLine + : parentDynamicIndentation.getIndentation(); + delta = Math.min(options.IndentSize, parentDynamicIndentation.getDelta() + delta); + } + return { + indentation: indentation, + delta: delta + }; + } + function getFirstNonDecoratorTokenOfNode(node) { + if (node.modifiers && node.modifiers.length) { + return node.modifiers[0].kind; + } + switch (node.kind) { + case 214 /* ClassDeclaration */: return 73 /* ClassKeyword */; + case 215 /* InterfaceDeclaration */: return 107 /* InterfaceKeyword */; + case 213 /* FunctionDeclaration */: return 87 /* FunctionKeyword */; + case 217 /* EnumDeclaration */: return 217 /* EnumDeclaration */; + case 145 /* GetAccessor */: return 123 /* GetKeyword */; + case 146 /* SetAccessor */: return 129 /* SetKeyword */; + case 143 /* MethodDeclaration */: + if (node.asteriskToken) { + return 37 /* AsteriskToken */; + } + // fall-through + case 141 /* PropertyDeclaration */: + case 138 /* Parameter */: + return node.name.kind; + } + } + function getDynamicIndentation(node, nodeStartLine, indentation, delta) { + return { + getIndentationForComment: function (kind, tokenIndentation) { + switch (kind) { + // preceding comment to the token that closes the indentation scope inherits the indentation from the scope + // .. { + // // comment + // } + case 16 /* CloseBraceToken */: + case 20 /* CloseBracketToken */: + case 18 /* CloseParenToken */: + return indentation + delta; + } + return tokenIndentation !== -1 /* Unknown */ ? tokenIndentation : indentation; + }, + getIndentationForToken: function (line, kind) { + if (nodeStartLine !== line && node.decorators) { + if (kind === getFirstNonDecoratorTokenOfNode(node)) { + // if this token is the first token following the list of decorators, we do not need to indent + return indentation; + } + } + 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 */: + return indentation; + default: + // if token line equals to the line of containing node (this is a first token in the node) - use node indentation + return nodeStartLine !== line ? indentation + delta : indentation; + } + }, + getIndentation: function () { return indentation; }, + getDelta: function () { return delta; }, + recomputeIndentation: function (lineAdded) { + if (node.parent && formatting.SmartIndenter.shouldIndentChildNode(node.parent.kind, node.kind)) { + if (lineAdded) { + indentation += options.IndentSize; + } + else { + indentation -= options.IndentSize; + } + if (formatting.SmartIndenter.shouldIndentChildNode(node.kind, 0 /* Unknown */)) { + delta = options.IndentSize; + } + else { + delta = 0; + } + } + } + }; + } + function processNode(node, contextNode, nodeStartLine, undecoratedNodeStartLine, indentation, delta) { + if (!ts.rangeOverlapsWithStartEnd(originalRange, node.getStart(sourceFile), node.getEnd())) { + return; + } + var nodeDynamicIndentation = getDynamicIndentation(node, nodeStartLine, indentation, delta); + // a useful observations when tracking context node + // / + // [a] + // / | \ + // [b] [c] [d] + // node 'a' is a context node for nodes 'b', 'c', 'd' + // except for the leftmost leaf token in [b] - in this case context node ('e') is located somewhere above 'a' + // this rule can be applied recursively to child nodes of 'a'. + // + // context node is set to parent node value after processing every child node + // context node is set to parent of the token after processing every token + var childContextNode = contextNode; + // if there are any tokens that logically belong to node and interleave child nodes + // such tokens will be consumed in processChildNode for for the child that follows them + ts.forEachChild(node, function (child) { + processChildNode(child, /*inheritedIndentation*/ -1 /* Unknown */, node, nodeDynamicIndentation, nodeStartLine, undecoratedNodeStartLine, /*isListElement*/ false); + }, function (nodes) { + processChildNodes(nodes, node, nodeStartLine, nodeDynamicIndentation); + }); + // proceed any tokens in the node that are located after child nodes + while (formattingScanner.isOnToken()) { + var tokenInfo = formattingScanner.readTokenInfo(node); + if (tokenInfo.token.end > node.end) { + break; + } + consumeTokenAndAdvanceScanner(tokenInfo, node, nodeDynamicIndentation); + } + function processChildNode(child, inheritedIndentation, parent, parentDynamicIndentation, parentStartLine, undecoratedParentStartLine, isListItem) { + var childStartPos = child.getStart(sourceFile); + var childStartLine = sourceFile.getLineAndCharacterOfPosition(childStartPos).line; + var undecoratedChildStartLine = childStartLine; + if (child.decorators) { + undecoratedChildStartLine = sourceFile.getLineAndCharacterOfPosition(ts.getNonDecoratorTokenPosOfNode(child, sourceFile)).line; + } + // if child is a list item - try to get its indentation + var childIndentationAmount = -1 /* Unknown */; + if (isListItem) { + childIndentationAmount = tryComputeIndentationForListItem(childStartPos, child.end, parentStartLine, originalRange, inheritedIndentation); + if (childIndentationAmount !== -1 /* Unknown */) { + inheritedIndentation = childIndentationAmount; + } + } + // child node is outside the target range - do not dive inside + if (!ts.rangeOverlapsWithStartEnd(originalRange, child.pos, child.end)) { + return inheritedIndentation; + } + if (child.getFullWidth() === 0) { + return inheritedIndentation; + } + while (formattingScanner.isOnToken()) { + // proceed any parent tokens that are located prior to child.getStart() + var tokenInfo = formattingScanner.readTokenInfo(node); + if (tokenInfo.token.end > childStartPos) { + // stop when formatting scanner advances past the beginning of the child + break; + } + consumeTokenAndAdvanceScanner(tokenInfo, node, parentDynamicIndentation); + } + if (!formattingScanner.isOnToken()) { + return inheritedIndentation; + } + if (ts.isToken(child)) { + // 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); + consumeTokenAndAdvanceScanner(tokenInfo, node, parentDynamicIndentation); + return inheritedIndentation; + } + var effectiveParentStartLine = child.kind === 139 /* Decorator */ ? childStartLine : undecoratedParentStartLine; + var childIndentation = computeIndentation(child, childStartLine, childIndentationAmount, node, parentDynamicIndentation, effectiveParentStartLine); + processNode(child, childContextNode, childStartLine, undecoratedChildStartLine, childIndentation.indentation, childIndentation.delta); + childContextNode = node; + return inheritedIndentation; + } + function processChildNodes(nodes, parent, parentStartLine, parentDynamicIndentation) { + var listStartToken = getOpenTokenForList(parent, nodes); + var listEndToken = getCloseTokenForOpenToken(listStartToken); + var listDynamicIndentation = parentDynamicIndentation; + var startLine = parentStartLine; + if (listStartToken !== 0 /* Unknown */) { + // introduce a new indentation scope for lists (including list start and end tokens) + while (formattingScanner.isOnToken()) { + var tokenInfo = formattingScanner.readTokenInfo(parent); + if (tokenInfo.token.end > nodes.pos) { + // stop when formatting scanner moves past the beginning of node list + break; + } + else if (tokenInfo.token.kind === listStartToken) { + // consume list start token + startLine = sourceFile.getLineAndCharacterOfPosition(tokenInfo.token.pos).line; + var indentation_1 = computeIndentation(tokenInfo.token, startLine, -1 /* Unknown */, parent, parentDynamicIndentation, parentStartLine); + listDynamicIndentation = getDynamicIndentation(parent, parentStartLine, indentation_1.indentation, indentation_1.delta); + consumeTokenAndAdvanceScanner(tokenInfo, parent, listDynamicIndentation); + } + else { + // consume any tokens that precede the list as child elements of 'node' using its indentation scope + consumeTokenAndAdvanceScanner(tokenInfo, parent, parentDynamicIndentation); + } + } + } + var inheritedIndentation = -1 /* Unknown */; + for (var _i = 0; _i < nodes.length; _i++) { + var child = nodes[_i]; + inheritedIndentation = processChildNode(child, inheritedIndentation, node, listDynamicIndentation, startLine, startLine, /*isListElement*/ true); + } + if (listEndToken !== 0 /* Unknown */) { + if (formattingScanner.isOnToken()) { + var tokenInfo = formattingScanner.readTokenInfo(parent); + // consume the list end token only if it is still belong to the parent + // there might be the case when current token matches end token but does not considered as one + // function (x: function) <-- + // without this check close paren will be interpreted as list end token for function expression which is wrong + if (tokenInfo.token.kind === listEndToken && ts.rangeContainsRange(parent, tokenInfo.token)) { + // consume list end token + consumeTokenAndAdvanceScanner(tokenInfo, parent, listDynamicIndentation); + } + } + } + } + function consumeTokenAndAdvanceScanner(currentTokenInfo, parent, dynamicIndentation) { + ts.Debug.assert(ts.rangeContainsRange(parent, currentTokenInfo.token)); + var lastTriviaWasNewLine = formattingScanner.lastTrailingTriviaWasNewLine(); + var indentToken = false; + if (currentTokenInfo.leadingTrivia) { + processTrivia(currentTokenInfo.leadingTrivia, parent, childContextNode, dynamicIndentation); + } + var lineAdded; + var isTokenInRange = ts.rangeContainsRange(originalRange, currentTokenInfo.token); + var tokenStart = sourceFile.getLineAndCharacterOfPosition(currentTokenInfo.token.pos); + if (isTokenInRange) { + var rangeHasError = rangeContainsError(currentTokenInfo.token); + // save previousRange since processRange will overwrite this value with current one + var savePreviousRange = previousRange; + lineAdded = processRange(currentTokenInfo.token, tokenStart, parent, childContextNode, dynamicIndentation); + if (rangeHasError) { + // do not indent comments\token if token range overlaps with some error + indentToken = false; + } + else { + if (lineAdded !== undefined) { + indentToken = lineAdded; + } + else { + // indent token only if end line of previous range does not match start line of the token + var prevEndLine = savePreviousRange && sourceFile.getLineAndCharacterOfPosition(savePreviousRange.end).line; + indentToken = lastTriviaWasNewLine && tokenStart.line !== prevEndLine; + } + } + } + if (currentTokenInfo.trailingTrivia) { + processTrivia(currentTokenInfo.trailingTrivia, parent, childContextNode, dynamicIndentation); + } + if (indentToken) { + var tokenIndentation = (isTokenInRange && !rangeContainsError(currentTokenInfo.token)) ? + dynamicIndentation.getIndentationForToken(tokenStart.line, currentTokenInfo.token.kind) : + -1 /* Unknown */; + if (currentTokenInfo.leadingTrivia) { + var commentIndentation = dynamicIndentation.getIndentationForComment(currentTokenInfo.token.kind, tokenIndentation); + var indentNextTokenOrTrivia = true; + for (var _i = 0, _a = currentTokenInfo.leadingTrivia; _i < _a.length; _i++) { + var triviaItem = _a[_i]; + if (!ts.rangeContainsRange(originalRange, triviaItem)) { + continue; + } + switch (triviaItem.kind) { + case 3 /* MultiLineCommentTrivia */: + indentMultilineComment(triviaItem, commentIndentation, /*firstLineIsIndented*/ !indentNextTokenOrTrivia); + indentNextTokenOrTrivia = false; + break; + case 2 /* SingleLineCommentTrivia */: + if (indentNextTokenOrTrivia) { + insertIndentation(triviaItem.pos, commentIndentation, /*lineAdded*/ false); + indentNextTokenOrTrivia = false; + } + break; + case 4 /* NewLineTrivia */: + indentNextTokenOrTrivia = true; + break; + } + } + } + // indent token only if is it is in target range and does not overlap with any error ranges + if (tokenIndentation !== -1 /* Unknown */) { + insertIndentation(currentTokenInfo.token.pos, tokenIndentation, lineAdded); + lastIndentedLine = tokenStart.line; + indentationOnLastIndentedLine = tokenIndentation; + } + } + formattingScanner.advance(); + childContextNode = parent; + } + } + function processTrivia(trivia, parent, contextNode, dynamicIndentation) { + for (var _i = 0; _i < trivia.length; _i++) { + var triviaItem = trivia[_i]; + if (ts.isComment(triviaItem.kind) && ts.rangeContainsRange(originalRange, triviaItem)) { + var triviaItemStart = sourceFile.getLineAndCharacterOfPosition(triviaItem.pos); + processRange(triviaItem, triviaItemStart, parent, contextNode, dynamicIndentation); + } + } + } + function processRange(range, rangeStart, parent, contextNode, dynamicIndentation) { + var rangeHasError = rangeContainsError(range); + var lineAdded; + if (!rangeHasError && !previousRangeHasError) { + if (!previousRange) { + // trim whitespaces starting from the beginning of the span up to the current line + var originalStart = sourceFile.getLineAndCharacterOfPosition(originalRange.pos); + trimTrailingWhitespacesForLines(originalStart.line, rangeStart.line); + } + else { + lineAdded = + processPair(range, rangeStart.line, parent, previousRange, previousRangeStartLine, previousParent, contextNode, dynamicIndentation); + } + } + previousRange = range; + previousParent = parent; + previousRangeStartLine = rangeStart.line; + previousRangeHasError = rangeHasError; + return lineAdded; + } + function processPair(currentItem, currentStartLine, currentParent, previousItem, previousStartLine, previousParent, contextNode, dynamicIndentation) { + formattingContext.updateContext(previousItem, previousParent, currentItem, currentParent, contextNode); + var rule = rulesProvider.getRulesMap().GetRule(formattingContext); + var trimTrailingWhitespaces; + var lineAdded; + if (rule) { + applyRuleEdits(rule, previousItem, previousStartLine, currentItem, currentStartLine); + if (rule.Operation.Action & (2 /* Space */ | 8 /* Delete */) && currentStartLine !== previousStartLine) { + lineAdded = false; + // Handle the case where the next line is moved to be the end of this line. + // In this case we don't indent the next line in the next pass. + if (currentParent.getStart(sourceFile) === currentItem.pos) { + dynamicIndentation.recomputeIndentation(/*lineAdded*/ false); + } + } + else if (rule.Operation.Action & 4 /* NewLine */ && currentStartLine === previousStartLine) { + lineAdded = true; + // Handle the case where token2 is moved to the new line. + // In this case we indent token2 in the next pass but we set + // sameLineIndent flag to notify the indenter that the indentation is within the line. + if (currentParent.getStart(sourceFile) === currentItem.pos) { + dynamicIndentation.recomputeIndentation(/*lineAdded*/ true); + } + } + // We need to trim trailing whitespace between the tokens if they were on different lines, and no rule was applied to put them on the same line + trimTrailingWhitespaces = + (rule.Operation.Action & (4 /* NewLine */ | 2 /* Space */)) && + rule.Flag !== 1 /* CanDeleteNewLines */; + } + else { + trimTrailingWhitespaces = true; + } + if (currentStartLine !== previousStartLine && trimTrailingWhitespaces) { + // We need to trim trailing whitespace between the tokens if they were on different lines, and no rule was applied to put them on the same line + trimTrailingWhitespacesForLines(previousStartLine, currentStartLine, previousItem); + } + return lineAdded; + } + function insertIndentation(pos, indentation, lineAdded) { + var indentationString = getIndentationString(indentation, options); + if (lineAdded) { + // new line is added before the token by the formatting rules + // insert indentation string at the very beginning of the token + recordReplace(pos, 0, indentationString); + } + else { + var tokenStart = sourceFile.getLineAndCharacterOfPosition(pos); + if (indentation !== tokenStart.character) { + var startLinePosition = ts.getStartPositionOfLine(tokenStart.line, sourceFile); + recordReplace(startLinePosition, tokenStart.character, indentationString); + } + } + } + function indentMultilineComment(commentRange, indentation, firstLineIsIndented) { + // split comment in lines + var startLine = sourceFile.getLineAndCharacterOfPosition(commentRange.pos).line; + var endLine = sourceFile.getLineAndCharacterOfPosition(commentRange.end).line; + var parts; + if (startLine === endLine) { + if (!firstLineIsIndented) { + // treat as single line comment + insertIndentation(commentRange.pos, indentation, /*lineAdded*/ false); + } + return; + } + else { + parts = []; + var startPos = commentRange.pos; + for (var line = startLine; line < endLine; ++line) { + var endOfLine = ts.getEndLinePosition(line, sourceFile); + parts.push({ pos: startPos, end: endOfLine }); + startPos = ts.getStartPositionOfLine(line + 1, sourceFile); + } + parts.push({ pos: startPos, end: commentRange.end }); + } + var startLinePos = ts.getStartPositionOfLine(startLine, sourceFile); + var nonWhitespaceColumnInFirstPart = formatting.SmartIndenter.findFirstNonWhitespaceCharacterAndColumn(startLinePos, parts[0].pos, sourceFile, options); + if (indentation === nonWhitespaceColumnInFirstPart.column) { + return; + } + var startIndex = 0; + if (firstLineIsIndented) { + startIndex = 1; + startLine++; + } + // shift all parts on the delta size + var delta = indentation - nonWhitespaceColumnInFirstPart.column; + for (var i = startIndex, len = parts.length; i < len; ++i, ++startLine) { + var startLinePos_1 = ts.getStartPositionOfLine(startLine, sourceFile); + var nonWhitespaceCharacterAndColumn = i === 0 + ? nonWhitespaceColumnInFirstPart + : formatting.SmartIndenter.findFirstNonWhitespaceCharacterAndColumn(parts[i].pos, parts[i].end, sourceFile, options); + var newIndentation = nonWhitespaceCharacterAndColumn.column + delta; + if (newIndentation > 0) { + var indentationString = getIndentationString(newIndentation, options); + recordReplace(startLinePos_1, nonWhitespaceCharacterAndColumn.character, indentationString); + } + else { + recordDelete(startLinePos_1, nonWhitespaceCharacterAndColumn.character); + } + } + } + function trimTrailingWhitespacesForLines(line1, line2, range) { + for (var line = line1; line < line2; ++line) { + var lineStartPosition = ts.getStartPositionOfLine(line, sourceFile); + var lineEndPosition = ts.getEndLinePosition(line, sourceFile); + // do not trim whitespaces in comments or template expression + if (range && (ts.isComment(range.kind) || ts.isStringOrRegularExpressionOrTemplateLiteral(range.kind)) && range.pos <= lineEndPosition && range.end > lineEndPosition) { + continue; + } + var pos = lineEndPosition; + while (pos >= lineStartPosition && ts.isWhiteSpace(sourceFile.text.charCodeAt(pos))) { + pos--; + } + if (pos !== lineEndPosition) { + ts.Debug.assert(pos === lineStartPosition || !ts.isWhiteSpace(sourceFile.text.charCodeAt(pos))); + recordDelete(pos + 1, lineEndPosition - pos); + } + } + } + function newTextChange(start, len, newText) { + return { span: ts.createTextSpan(start, len), newText: newText }; + } + function recordDelete(start, len) { + if (len) { + edits.push(newTextChange(start, len, "")); + } + } + function recordReplace(start, len, newText) { + if (len || newText) { + edits.push(newTextChange(start, len, newText)); + } + } + function applyRuleEdits(rule, previousRange, previousStartLine, currentRange, currentStartLine) { + var between; + switch (rule.Operation.Action) { + case 1 /* Ignore */: + // no action required + return; + case 8 /* Delete */: + if (previousRange.end !== currentRange.pos) { + // delete characters starting from t1.end up to t2.pos exclusive + recordDelete(previousRange.end, currentRange.pos - previousRange.end); + } + break; + case 4 /* NewLine */: + // exit early if we on different lines and rule cannot change number of newlines + // if line1 and line2 are on subsequent lines then no edits are required - ok to exit + // if line1 and line2 are separated with more than one newline - ok to exit since we cannot delete extra new lines + if (rule.Flag !== 1 /* CanDeleteNewLines */ && previousStartLine !== currentStartLine) { + return; + } + // 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); + } + break; + case 2 /* Space */: + // exit early if we on different lines and rule cannot change number of newlines + if (rule.Flag !== 1 /* CanDeleteNewLines */ && previousStartLine !== currentStartLine) { + return; + } + var posDelta = currentRange.pos - previousRange.end; + if (posDelta !== 1 || sourceFile.text.charCodeAt(previousRange.end) !== 32 /* space */) { + recordReplace(previousRange.end, currentRange.pos - previousRange.end, " "); + } + break; + } + } + } + function isSomeBlock(kind) { + switch (kind) { + case 192 /* Block */: + case 219 /* ModuleBlock */: + return true; + } + return false; + } + function getOpenTokenForList(node, list) { + switch (node.kind) { + case 144 /* Constructor */: + case 213 /* FunctionDeclaration */: + case 173 /* FunctionExpression */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: + case 174 /* ArrowFunction */: + if (node.typeParameters === list) { + return 25 /* LessThanToken */; + } + else if (node.parameters === list) { + return 17 /* OpenParenToken */; + } + break; + case 168 /* CallExpression */: + case 169 /* NewExpression */: + if (node.typeArguments === list) { + return 25 /* LessThanToken */; + } + else if (node.arguments === list) { + return 17 /* OpenParenToken */; + } + break; + case 151 /* TypeReference */: + if (node.typeArguments === list) { + return 25 /* LessThanToken */; + } + } + return 0 /* Unknown */; + } + function getCloseTokenForOpenToken(kind) { + switch (kind) { + case 17 /* OpenParenToken */: + return 18 /* CloseParenToken */; + case 25 /* LessThanToken */: + return 27 /* GreaterThanToken */; + } + return 0 /* Unknown */; + } + var internedSizes; + var internedTabsIndentation; + var internedSpacesIndentation; + function getIndentationString(indentation, options) { + // reset interned strings if FormatCodeOptions were changed + var resetInternedStrings = !internedSizes || (internedSizes.tabSize !== options.TabSize || internedSizes.indentSize !== options.IndentSize); + if (resetInternedStrings) { + internedSizes = { tabSize: options.TabSize, indentSize: options.IndentSize }; + internedTabsIndentation = internedSpacesIndentation = undefined; + } + if (!options.ConvertTabsToSpaces) { + var tabs = Math.floor(indentation / options.TabSize); + var spaces = indentation - tabs * options.TabSize; + var tabString; + if (!internedTabsIndentation) { + internedTabsIndentation = []; + } + if (internedTabsIndentation[tabs] === undefined) { + internedTabsIndentation[tabs] = tabString = repeat('\t', tabs); + } + else { + tabString = internedTabsIndentation[tabs]; + } + return spaces ? tabString + repeat(" ", spaces) : tabString; + } + else { + var spacesString; + var quotient = Math.floor(indentation / options.IndentSize); + var remainder = indentation % options.IndentSize; + if (!internedSpacesIndentation) { + internedSpacesIndentation = []; + } + if (internedSpacesIndentation[quotient] === undefined) { + spacesString = repeat(" ", options.IndentSize * quotient); + internedSpacesIndentation[quotient] = spacesString; + } + else { + spacesString = internedSpacesIndentation[quotient]; + } + return remainder ? spacesString + repeat(" ", remainder) : spacesString; + } + function repeat(value, count) { + var s = ""; + for (var i = 0; i < count; ++i) { + s += value; + } + return s; + } + } + formatting.getIndentationString = getIndentationString; + })(formatting = ts.formatting || (ts.formatting = {})); +})(ts || (ts = {})); +/// +/* @internal */ +var ts; +(function (ts) { + var formatting; + (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 0; // past EOF + } + // no indentation when the indent style is set to none, + // so we can return fast + if (options.IndentStyle === ts.IndentStyle.None) { + return 0; + } + var precedingToken = ts.findPrecedingToken(position, sourceFile); + if (!precedingToken) { + return 0; + } + // no indentation in string \regex\template literals + var precedingTokenIsLiteral = ts.isStringOrRegularExpressionOrTemplateLiteral(precedingToken.kind); + if (precedingTokenIsLiteral && precedingToken.getStart(sourceFile) <= position && precedingToken.end > position) { + return 0; + } + var lineAtPosition = sourceFile.getLineAndCharacterOfPosition(position).line; + // indentation is first non-whitespace character in a previous line + // for block indentation, we should look for a line which contains something that's not + // whitespace. + if (options.IndentStyle === ts.IndentStyle.Block) { + // move backwards until we find a line with a non-whitespace character, + // then find the first non-whitespace character for that line. + var current_1 = position; + while (current_1 > 0) { + var char = sourceFile.text.charCodeAt(current_1); + if (!ts.isWhiteSpace(char) && !ts.isLineBreak(char)) { + break; + } + current_1--; + } + var lineStart = ts.getLineStartPositionForPosition(current_1, sourceFile); + return SmartIndenter.findFirstNonWhitespaceColumn(lineStart, current_1, sourceFile, options); + } + if (precedingToken.kind === 24 /* CommaToken */ && precedingToken.parent.kind !== 181 /* BinaryExpression */) { + // previous token is comma that separates items in list - find the previous item and try to derive indentation from it + var actualIndentation = getActualIndentationForListItemBeforeComma(precedingToken, sourceFile, options); + if (actualIndentation !== -1 /* Unknown */) { + return actualIndentation; + } + } + // try to find node that can contribute to indentation and includes 'position' starting from 'precedingToken' + // if such node is found - compute initial indentation for 'position' inside this node + var previous; + var current = precedingToken; + var currentStart; + var indentationDelta; + while (current) { + if (ts.positionBelongsToNode(current, position, sourceFile) && shouldIndentChildNode(current.kind, previous ? previous.kind : 0 /* Unknown */)) { + currentStart = getStartLineAndCharacterForNode(current, sourceFile); + if (nextTokenIsCurlyBraceOnSameLineAsCursor(precedingToken, current, lineAtPosition, sourceFile)) { + indentationDelta = 0; + } + else { + indentationDelta = lineAtPosition !== currentStart.line ? options.IndentSize : 0; + } + break; + } + // check if current node is a list item - if yes, take indentation from it + var actualIndentation = getActualIndentationForListItem(current, sourceFile, options); + if (actualIndentation !== -1 /* Unknown */) { + return actualIndentation; + } + actualIndentation = getLineIndentationWhenExpressionIsInMultiLine(current, sourceFile, options); + if (actualIndentation !== -1 /* Unknown */) { + return actualIndentation + options.IndentSize; + } + previous = current; + current = current.parent; + } + if (!current) { + // no parent was found - return 0 to be indented on the level of SourceFile + return 0; + } + return getIndentationForNodeWorker(current, currentStart, /*ignoreActualIndentationRange*/ undefined, indentationDelta, sourceFile, options); + } + SmartIndenter.getIndentation = getIndentation; + 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 getIndentationForNodeWorker(current, currentStart, ignoreActualIndentationRange, indentationDelta, sourceFile, options) { + var parent = current.parent; + var parentStart; + // walk upwards and collect indentations for pairs of parent-child nodes + // indentation is not added if parent and child nodes start on the same line or if parent is IfStatement and child starts on the same line with 'else clause' + while (parent) { + var useActualIndentation = true; + if (ignoreActualIndentationRange) { + var start = current.getStart(sourceFile); + useActualIndentation = start < ignoreActualIndentationRange.pos || start > ignoreActualIndentationRange.end; + } + if (useActualIndentation) { + // check if current node is a list item - if yes, take indentation from it + var actualIndentation = getActualIndentationForListItem(current, sourceFile, options); + if (actualIndentation !== -1 /* Unknown */) { + return actualIndentation + indentationDelta; + } + } + parentStart = getParentStart(parent, current, sourceFile); + var parentAndChildShareLine = parentStart.line === currentStart.line || + childStartsOnTheSameLineWithElseInIfStatement(parent, current, currentStart.line, sourceFile); + if (useActualIndentation) { + // try to fetch actual indentation for current node from source text + var actualIndentation = getActualIndentationForNode(current, parent, currentStart, parentAndChildShareLine, sourceFile, options); + if (actualIndentation !== -1 /* Unknown */) { + return actualIndentation + indentationDelta; + } + actualIndentation = getLineIndentationWhenExpressionIsInMultiLine(current, sourceFile, options); + if (actualIndentation !== -1 /* Unknown */) { + return actualIndentation + indentationDelta; + } + } + // 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.kind, current.kind) && !parentAndChildShareLine) { + indentationDelta += options.IndentSize; + } + current = parent; + currentStart = parentStart; + parent = current.parent; + } + return indentationDelta; + } + function getParentStart(parent, child, sourceFile) { + var containingList = getContainingList(child, sourceFile); + if (containingList) { + return sourceFile.getLineAndCharacterOfPosition(containingList.pos); + } + return sourceFile.getLineAndCharacterOfPosition(parent.getStart(sourceFile)); + } + /* + * Function returns Value.Unknown if indentation cannot be determined + */ + function getActualIndentationForListItemBeforeComma(commaToken, sourceFile, options) { + // previous token is comma that separates items in list - find the previous item and try to derive indentation from it + var commaItemInfo = ts.findListItemInfo(commaToken); + if (commaItemInfo && commaItemInfo.listItemIndex > 0) { + return deriveActualIndentationFromList(commaItemInfo.list.getChildren(), commaItemInfo.listItemIndex - 1, sourceFile, options); + } + else { + // handle broken code gracefully + return -1 /* Unknown */; + } + } + /* + * Function returns Value.Unknown if actual indentation for node should not be used (i.e because node is nested expression) + */ + function getActualIndentationForNode(current, parent, currentLineAndChar, parentAndChildShareLine, sourceFile, options) { + // actual indentation is used for statements\declarations if one of cases below is true: + // - parent is SourceFile - by default immediate children of SourceFile are not indented except when user indents them manually + // - parent and child are not on the same line + var useActualIndentation = (ts.isDeclaration(current) || ts.isStatement(current)) && + (parent.kind === 248 /* SourceFile */ || !parentAndChildShareLine); + if (!useActualIndentation) { + return -1 /* Unknown */; + } + return findColumnForFirstNonWhitespaceCharacterInLine(currentLineAndChar, sourceFile, options); + } + function nextTokenIsCurlyBraceOnSameLineAsCursor(precedingToken, current, lineAtPosition, sourceFile) { + var nextToken = ts.findNextToken(precedingToken, current); + if (!nextToken) { + return false; + } + if (nextToken.kind === 15 /* OpenBraceToken */) { + // open braces are always indented at the parent level + return true; + } + else if (nextToken.kind === 16 /* 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 { + // $ + // } + /// and this one - not + // class A { + // $} + var nextTokenStartLine = getStartLineAndCharacterForNode(nextToken, sourceFile).line; + return lineAtPosition === nextTokenStartLine; + } + return false; + } + function getStartLineAndCharacterForNode(n, sourceFile) { + return sourceFile.getLineAndCharacterOfPosition(n.getStart(sourceFile)); + } + function childStartsOnTheSameLineWithElseInIfStatement(parent, child, childStartLine, sourceFile) { + if (parent.kind === 196 /* IfStatement */ && parent.elseStatement === child) { + var elseKeyword = ts.findChildOfKind(parent, 80 /* ElseKeyword */, sourceFile); + ts.Debug.assert(elseKeyword !== undefined); + var elseKeywordStartLine = getStartLineAndCharacterForNode(elseKeyword, sourceFile).line; + return elseKeywordStartLine === childStartLine; + } + return false; + } + SmartIndenter.childStartsOnTheSameLineWithElseInIfStatement = childStartsOnTheSameLineWithElseInIfStatement; + function getContainingList(node, sourceFile) { + if (node.parent) { + switch (node.parent.kind) { + case 151 /* TypeReference */: + if (node.parent.typeArguments && + ts.rangeContainsStartEnd(node.parent.typeArguments, node.getStart(sourceFile), node.getEnd())) { + return node.parent.typeArguments; + } + break; + case 165 /* ObjectLiteralExpression */: + return node.parent.properties; + case 164 /* ArrayLiteralExpression */: + return node.parent.elements; + case 213 /* FunctionDeclaration */: + case 173 /* FunctionExpression */: + case 174 /* ArrowFunction */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: + case 147 /* CallSignature */: + case 148 /* ConstructSignature */: { + var start = node.getStart(sourceFile); + if (node.parent.typeParameters && + ts.rangeContainsStartEnd(node.parent.typeParameters, start, node.getEnd())) { + return node.parent.typeParameters; + } + if (ts.rangeContainsStartEnd(node.parent.parameters, start, node.getEnd())) { + return node.parent.parameters; + } + break; + } + case 169 /* NewExpression */: + case 168 /* CallExpression */: { + var start = node.getStart(sourceFile); + if (node.parent.typeArguments && + ts.rangeContainsStartEnd(node.parent.typeArguments, start, node.getEnd())) { + return node.parent.typeArguments; + } + if (node.parent.arguments && + ts.rangeContainsStartEnd(node.parent.arguments, start, node.getEnd())) { + return node.parent.arguments; + } + break; + } + } + } + return undefined; + } + function getActualIndentationForListItem(node, sourceFile, options) { + var containingList = getContainingList(node, sourceFile); + return containingList ? getActualIndentationFromList(containingList) : -1 /* Unknown */; + function getActualIndentationFromList(list) { + var index = ts.indexOf(list, node); + return index !== -1 ? deriveActualIndentationFromList(list, index, sourceFile, options) : -1 /* Unknown */; + } + } + 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 */) { + return -1 /* Unknown */; + } + if (node.parent && (node.parent.kind === 168 /* CallExpression */ || + node.parent.kind === 169 /* NewExpression */) && + node.parent.expression !== node) { + var fullCallOrNewExpression = node.parent.expression; + var startingExpression = getStartingExpression(fullCallOrNewExpression); + if (fullCallOrNewExpression === startingExpression) { + return -1 /* Unknown */; + } + var fullCallOrNewExpressionEnd = sourceFile.getLineAndCharacterOfPosition(fullCallOrNewExpression.end); + var startingExpressionEnd = sourceFile.getLineAndCharacterOfPosition(startingExpression.end); + if (fullCallOrNewExpressionEnd.line === startingExpressionEnd.line) { + return -1 /* Unknown */; + } + return findColumnForFirstNonWhitespaceCharacterInLine(fullCallOrNewExpressionEnd, sourceFile, options); + } + return -1 /* Unknown */; + function getStartingExpression(node) { + while (true) { + switch (node.kind) { + case 168 /* CallExpression */: + case 169 /* NewExpression */: + case 166 /* PropertyAccessExpression */: + case 167 /* ElementAccessExpression */: + node = node.expression; + break; + default: + return node; + } + } + return node; + } + } + function deriveActualIndentationFromList(list, index, sourceFile, options) { + ts.Debug.assert(index >= 0 && index < list.length); + var node = list[index]; + // walk toward the start of the list starting from current node and check if the line is the same for all items. + // 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 */) { + continue; + } + // skip list items that ends on the same line with the current list element + var prevEndLine = sourceFile.getLineAndCharacterOfPosition(list[i].end).line; + if (prevEndLine !== lineAndCharacter.line) { + return findColumnForFirstNonWhitespaceCharacterInLine(lineAndCharacter, sourceFile, options); + } + lineAndCharacter = getStartLineAndCharacterForNode(list[i], sourceFile); + } + return -1 /* Unknown */; + } + function findColumnForFirstNonWhitespaceCharacterInLine(lineAndCharacter, sourceFile, options) { + var lineStart = sourceFile.getPositionOfLineAndCharacter(lineAndCharacter.line, 0); + return findFirstNonWhitespaceColumn(lineStart, lineStart + lineAndCharacter.character, sourceFile, options); + } + /* + Character is the actual index of the character since the beginning of the line. + Column - position of the character after expanding tabs to spaces + "0\t2$" + value of 'character' for '$' is 3 + value of 'column' for '$' is 6 (assuming that tab size is 4) + */ + function findFirstNonWhitespaceCharacterAndColumn(startPos, endPos, sourceFile, options) { + var character = 0; + var column = 0; + for (var pos = startPos; pos < endPos; ++pos) { + var ch = sourceFile.text.charCodeAt(pos); + if (!ts.isWhiteSpace(ch)) { + break; + } + if (ch === 9 /* tab */) { + column += options.TabSize + (column % options.TabSize); + } + else { + column++; + } + character++; + } + return { column: column, character: character }; + } + SmartIndenter.findFirstNonWhitespaceCharacterAndColumn = findFirstNonWhitespaceCharacterAndColumn; + function findFirstNonWhitespaceColumn(startPos, endPos, sourceFile, options) { + return findFirstNonWhitespaceCharacterAndColumn(startPos, endPos, sourceFile, options).column; + } + SmartIndenter.findFirstNonWhitespaceColumn = findFirstNonWhitespaceColumn; + function nodeContentIsAlwaysIndented(kind) { + switch (kind) { + case 195 /* ExpressionStatement */: + case 214 /* ClassDeclaration */: + case 186 /* ClassExpression */: + case 215 /* InterfaceDeclaration */: + case 217 /* EnumDeclaration */: + case 216 /* TypeAliasDeclaration */: + case 164 /* ArrayLiteralExpression */: + case 192 /* Block */: + case 219 /* ModuleBlock */: + case 165 /* ObjectLiteralExpression */: + case 155 /* TypeLiteral */: + case 157 /* TupleType */: + case 220 /* CaseBlock */: + case 242 /* DefaultClause */: + case 241 /* CaseClause */: + case 172 /* ParenthesizedExpression */: + case 166 /* PropertyAccessExpression */: + case 168 /* CallExpression */: + case 169 /* NewExpression */: + case 193 /* VariableStatement */: + case 211 /* VariableDeclaration */: + case 227 /* ExportAssignment */: + case 204 /* ReturnStatement */: + case 182 /* ConditionalExpression */: + case 162 /* ArrayBindingPattern */: + case 161 /* ObjectBindingPattern */: + case 233 /* JsxElement */: + case 234 /* JsxSelfClosingElement */: + case 142 /* MethodSignature */: + case 147 /* CallSignature */: + case 148 /* ConstructSignature */: + case 138 /* Parameter */: + case 152 /* FunctionType */: + case 153 /* ConstructorType */: + case 160 /* ParenthesizedType */: + case 170 /* TaggedTemplateExpression */: + case 178 /* AwaitExpression */: + return true; + } + return false; + } + function shouldIndentChildNode(parent, child) { + if (nodeContentIsAlwaysIndented(parent)) { + return true; + } + switch (parent) { + case 197 /* DoStatement */: + case 198 /* WhileStatement */: + case 200 /* ForInStatement */: + case 201 /* ForOfStatement */: + case 199 /* ForStatement */: + case 196 /* IfStatement */: + case 213 /* FunctionDeclaration */: + case 173 /* FunctionExpression */: + case 143 /* MethodDeclaration */: + case 174 /* ArrowFunction */: + case 144 /* Constructor */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: + return child !== 192 /* Block */; + default: + return false; + } + } + SmartIndenter.shouldIndentChildNode = shouldIndentChildNode; + })(SmartIndenter = formatting.SmartIndenter || (formatting.SmartIndenter = {})); + })(formatting = ts.formatting || (ts.formatting = {})); +})(ts || (ts = {})); +/// +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 ts; +(function (ts) { + /** The version of the language service API */ + ts.servicesVersion = "0.4"; + var ScriptSnapshot; + (function (ScriptSnapshot) { + var StringScriptSnapshot = (function () { + function StringScriptSnapshot(text) { + this.text = text; + } + StringScriptSnapshot.prototype.getText = function (start, end) { + return this.text.substring(start, end); + }; + StringScriptSnapshot.prototype.getLength = function () { + return this.text.length; + }; + StringScriptSnapshot.prototype.getChangeRange = function (oldSnapshot) { + // Text-based snapshots do not support incremental parsing. Return undefined + // to signal that to the caller. + return undefined; + }; + return StringScriptSnapshot; + })(); + function fromString(text) { + return new StringScriptSnapshot(text); + } + ScriptSnapshot.fromString = fromString; + })(ScriptSnapshot = ts.ScriptSnapshot || (ts.ScriptSnapshot = {})); + var scanner = ts.createScanner(2 /* Latest */, /*skipTrivia*/ true); + var emptyArray = []; + var jsDocTagNames = [ + "augments", + "author", + "argument", + "borrows", + "class", + "constant", + "constructor", + "constructs", + "default", + "deprecated", + "description", + "event", + "example", + "extends", + "field", + "fileOverview", + "function", + "ignore", + "inner", + "lends", + "link", + "memberOf", + "name", + "namespace", + "param", + "private", + "property", + "public", + "requires", + "returns", + "see", + "since", + "static", + "throws", + "type", + "version" + ]; + var jsDocCompletionEntries; + function createNode(kind, pos, end, flags, parent) { + var node = new (ts.getNodeConstructor(kind))(pos, end); + node.flags = flags; + node.parent = parent; + return node; + } + var NodeObject = (function () { + function NodeObject() { + } + NodeObject.prototype.getSourceFile = function () { + return ts.getSourceFileOfNode(this); + }; + NodeObject.prototype.getStart = function (sourceFile) { + return ts.getTokenPosOfNode(this, sourceFile); + }; + NodeObject.prototype.getFullStart = function () { + return this.pos; + }; + NodeObject.prototype.getEnd = function () { + return this.end; + }; + NodeObject.prototype.getWidth = function (sourceFile) { + return this.getEnd() - this.getStart(sourceFile); + }; + NodeObject.prototype.getFullWidth = function () { + return this.end - this.pos; + }; + NodeObject.prototype.getLeadingTriviaWidth = function (sourceFile) { + return this.getStart(sourceFile) - this.pos; + }; + NodeObject.prototype.getFullText = function (sourceFile) { + return (sourceFile || this.getSourceFile()).text.substring(this.pos, this.end); + }; + NodeObject.prototype.getText = function (sourceFile) { + return (sourceFile || this.getSourceFile()).text.substring(this.getStart(), this.getEnd()); + }; + NodeObject.prototype.addSyntheticNodes = function (nodes, pos, end) { + scanner.setTextPos(pos); + while (pos < end) { + var token = scanner.scan(); + var textPos = scanner.getTextPos(); + nodes.push(createNode(token, pos, textPos, 4096 /* Synthetic */, this)); + pos = textPos; + } + return pos; + }; + NodeObject.prototype.createSyntaxList = function (nodes) { + var list = createNode(271 /* SyntaxList */, nodes.pos, nodes.end, 4096 /* Synthetic */, this); + list._children = []; + var pos = nodes.pos; + for (var _i = 0; _i < nodes.length; _i++) { + var node = nodes[_i]; + if (pos < node.pos) { + pos = this.addSyntheticNodes(list._children, pos, node.pos); + } + list._children.push(node); + pos = node.end; + } + if (pos < nodes.end) { + this.addSyntheticNodes(list._children, pos, nodes.end); + } + return list; + }; + NodeObject.prototype.createChildren = function (sourceFile) { + var _this = this; + var children; + if (this.kind >= 135 /* FirstNode */) { + scanner.setText((sourceFile || this.getSourceFile()).text); + children = []; + var pos = this.pos; + var processNode = function (node) { + if (pos < node.pos) { + pos = _this.addSyntheticNodes(children, pos, node.pos); + } + children.push(node); + pos = node.end; + }; + var processNodes = function (nodes) { + if (pos < nodes.pos) { + pos = _this.addSyntheticNodes(children, pos, nodes.pos); + } + children.push(_this.createSyntaxList(nodes)); + pos = nodes.end; + }; + ts.forEachChild(this, processNode, processNodes); + if (pos < this.end) { + this.addSyntheticNodes(children, pos, this.end); + } + scanner.setText(undefined); + } + this._children = children || emptyArray; + }; + NodeObject.prototype.getChildCount = function (sourceFile) { + if (!this._children) + this.createChildren(sourceFile); + return this._children.length; + }; + NodeObject.prototype.getChildAt = function (index, sourceFile) { + if (!this._children) + this.createChildren(sourceFile); + return this._children[index]; + }; + NodeObject.prototype.getChildren = function (sourceFile) { + if (!this._children) + this.createChildren(sourceFile); + return this._children; + }; + NodeObject.prototype.getFirstToken = function (sourceFile) { + var children = this.getChildren(sourceFile); + if (!children.length) { + return undefined; + } + var child = children[0]; + return child.kind < 135 /* FirstNode */ ? child : child.getFirstToken(sourceFile); + }; + NodeObject.prototype.getLastToken = function (sourceFile) { + var children = this.getChildren(sourceFile); + var child = ts.lastOrUndefined(children); + if (!child) { + return undefined; + } + return child.kind < 135 /* FirstNode */ ? child : child.getLastToken(sourceFile); + }; + return NodeObject; + })(); + var SymbolObject = (function () { + function SymbolObject(flags, name) { + this.flags = flags; + this.name = name; + } + SymbolObject.prototype.getFlags = function () { + return this.flags; + }; + SymbolObject.prototype.getName = function () { + return this.name; + }; + SymbolObject.prototype.getDeclarations = function () { + return this.declarations; + }; + SymbolObject.prototype.getDocumentationComment = function () { + if (this.documentationComment === undefined) { + this.documentationComment = getJsDocCommentsFromDeclarations(this.declarations, this.name, !(this.flags & 4 /* Property */)); + } + return this.documentationComment; + }; + return SymbolObject; + })(); + function getJsDocCommentsFromDeclarations(declarations, name, canUseParsedParamTagComments) { + var documentationComment = []; + var docComments = getJsDocCommentsSeparatedByNewLines(); + ts.forEach(docComments, function (docComment) { + if (documentationComment.length) { + documentationComment.push(ts.lineBreakPart()); + } + documentationComment.push(docComment); + }); + return documentationComment; + function getJsDocCommentsSeparatedByNewLines() { + var paramTag = "@param"; + var jsDocCommentParts = []; + ts.forEach(declarations, function (declaration, indexOfDeclaration) { + // Make sure we are collecting doc comment from declaration once, + // In case of union property there might be same declaration multiple times + // which only varies in type parameter + // Eg. let a: Array | Array; a.length + // The property length will have two declarations of property length coming + // from Array - Array and Array + if (ts.indexOf(declarations, declaration) === indexOfDeclaration) { + var sourceFileOfDeclaration = ts.getSourceFileOfNode(declaration); + // If it is parameter - try and get the jsDoc comment with @param tag from function declaration's jsDoc comments + if (canUseParsedParamTagComments && declaration.kind === 138 /* Parameter */) { + ts.forEach(getJsDocCommentTextRange(declaration.parent, sourceFileOfDeclaration), function (jsDocCommentTextRange) { + var cleanedParamJsDocComment = getCleanedParamJsDocComment(jsDocCommentTextRange.pos, jsDocCommentTextRange.end, sourceFileOfDeclaration); + if (cleanedParamJsDocComment) { + ts.addRange(jsDocCommentParts, cleanedParamJsDocComment); + } + }); + } + // If this is left side of dotted module declaration, there is no doc comments associated with this node + if (declaration.kind === 218 /* ModuleDeclaration */ && declaration.body.kind === 218 /* ModuleDeclaration */) { + return; + } + // If this is dotted module name, get the doc comments from the parent + while (declaration.kind === 218 /* ModuleDeclaration */ && declaration.parent.kind === 218 /* ModuleDeclaration */) { + declaration = declaration.parent; + } + // Get the cleaned js doc comment text from the declaration + ts.forEach(getJsDocCommentTextRange(declaration.kind === 211 /* VariableDeclaration */ ? declaration.parent.parent : declaration, sourceFileOfDeclaration), function (jsDocCommentTextRange) { + var cleanedJsDocComment = getCleanedJsDocComment(jsDocCommentTextRange.pos, jsDocCommentTextRange.end, sourceFileOfDeclaration); + if (cleanedJsDocComment) { + ts.addRange(jsDocCommentParts, cleanedJsDocComment); + } + }); + } + }); + return jsDocCommentParts; + function getJsDocCommentTextRange(node, sourceFile) { + return ts.map(ts.getJsDocComments(node, sourceFile), function (jsDocComment) { + return { + pos: jsDocComment.pos + "/*".length, + end: jsDocComment.end - "*/".length // Trim off comment end indicator + }; + }); + } + function consumeWhiteSpacesOnTheLine(pos, end, sourceFile, maxSpacesToRemove) { + if (maxSpacesToRemove !== undefined) { + end = Math.min(end, pos + maxSpacesToRemove); + } + for (; pos < end; pos++) { + var ch = sourceFile.text.charCodeAt(pos); + if (!ts.isWhiteSpace(ch) || ts.isLineBreak(ch)) { + // Either found lineBreak or non whiteSpace + return pos; + } + } + return end; + } + function consumeLineBreaks(pos, end, sourceFile) { + while (pos < end && ts.isLineBreak(sourceFile.text.charCodeAt(pos))) { + pos++; + } + return pos; + } + function isName(pos, end, sourceFile, name) { + return pos + name.length < end && + sourceFile.text.substr(pos, name.length) === name && + (ts.isWhiteSpace(sourceFile.text.charCodeAt(pos + name.length)) || + ts.isLineBreak(sourceFile.text.charCodeAt(pos + name.length))); + } + function isParamTag(pos, end, sourceFile) { + // If it is @param tag + return isName(pos, end, sourceFile, paramTag); + } + function pushDocCommentLineText(docComments, text, blankLineCount) { + // Add the empty lines in between texts + while (blankLineCount--) { + docComments.push(ts.textPart("")); + } + docComments.push(ts.textPart(text)); + } + function getCleanedJsDocComment(pos, end, sourceFile) { + var spacesToRemoveAfterAsterisk; + var docComments = []; + var blankLineCount = 0; + var isInParamTag = false; + while (pos < end) { + var docCommentTextOfLine = ""; + // First consume leading white space + pos = consumeWhiteSpacesOnTheLine(pos, end, sourceFile); + // If the comment starts with '*' consume the spaces on this line + if (pos < end && sourceFile.text.charCodeAt(pos) === 42 /* asterisk */) { + var lineStartPos = pos + 1; + pos = consumeWhiteSpacesOnTheLine(pos + 1, end, sourceFile, spacesToRemoveAfterAsterisk); + // Set the spaces to remove after asterisk as margin if not already set + if (spacesToRemoveAfterAsterisk === undefined && pos < end && !ts.isLineBreak(sourceFile.text.charCodeAt(pos))) { + spacesToRemoveAfterAsterisk = pos - lineStartPos; + } + } + else if (spacesToRemoveAfterAsterisk === undefined) { + spacesToRemoveAfterAsterisk = 0; + } + // Analyse text on this line + while (pos < end && !ts.isLineBreak(sourceFile.text.charCodeAt(pos))) { + var ch = sourceFile.text.charAt(pos); + if (ch === "@") { + // If it is @param tag + if (isParamTag(pos, end, sourceFile)) { + isInParamTag = true; + pos += paramTag.length; + continue; + } + else { + isInParamTag = false; + } + } + // Add the ch to doc text if we arent in param tag + if (!isInParamTag) { + docCommentTextOfLine += ch; + } + // Scan next character + pos++; + } + // Continue with next line + pos = consumeLineBreaks(pos, end, sourceFile); + if (docCommentTextOfLine) { + pushDocCommentLineText(docComments, docCommentTextOfLine, blankLineCount); + blankLineCount = 0; + } + else if (!isInParamTag && docComments.length) { + // This is blank line when there is text already parsed + blankLineCount++; + } + } + return docComments; + } + function getCleanedParamJsDocComment(pos, end, sourceFile) { + var paramHelpStringMargin; + var paramDocComments = []; + while (pos < end) { + if (isParamTag(pos, end, sourceFile)) { + var blankLineCount = 0; + var recordedParamTag = false; + // Consume leading spaces + pos = consumeWhiteSpaces(pos + paramTag.length); + if (pos >= end) { + break; + } + // Ignore type expression + if (sourceFile.text.charCodeAt(pos) === 123 /* openBrace */) { + pos++; + for (var curlies = 1; pos < end; pos++) { + var charCode = sourceFile.text.charCodeAt(pos); + // { character means we need to find another } to match the found one + if (charCode === 123 /* openBrace */) { + curlies++; + continue; + } + // } char + if (charCode === 125 /* closeBrace */) { + curlies--; + if (curlies === 0) { + // We do not have any more } to match the type expression is ignored completely + pos++; + break; + } + else { + // there are more { to be matched with } + continue; + } + } + // Found start of another tag + if (charCode === 64 /* at */) { + break; + } + } + // Consume white spaces + pos = consumeWhiteSpaces(pos); + if (pos >= end) { + break; + } + } + // Parameter name + if (isName(pos, end, sourceFile, name)) { + // Found the parameter we are looking for consume white spaces + pos = consumeWhiteSpaces(pos + name.length); + if (pos >= end) { + break; + } + var paramHelpString = ""; + var firstLineParamHelpStringPos = pos; + while (pos < end) { + var ch = sourceFile.text.charCodeAt(pos); + // at line break, set this comment line text and go to next line + if (ts.isLineBreak(ch)) { + if (paramHelpString) { + pushDocCommentLineText(paramDocComments, paramHelpString, blankLineCount); + paramHelpString = ""; + blankLineCount = 0; + recordedParamTag = true; + } + else if (recordedParamTag) { + blankLineCount++; + } + // Get the pos after cleaning start of the line + setPosForParamHelpStringOnNextLine(firstLineParamHelpStringPos); + continue; + } + // Done scanning param help string - next tag found + if (ch === 64 /* at */) { + break; + } + paramHelpString += sourceFile.text.charAt(pos); + // Go to next character + pos++; + } + // If there is param help text, add it top the doc comments + if (paramHelpString) { + pushDocCommentLineText(paramDocComments, paramHelpString, blankLineCount); + } + paramHelpStringMargin = undefined; + } + // If this is the start of another tag, continue with the loop in seach of param tag with symbol name + if (sourceFile.text.charCodeAt(pos) === 64 /* at */) { + continue; + } + } + // Next character + pos++; + } + return paramDocComments; + function consumeWhiteSpaces(pos) { + while (pos < end && ts.isWhiteSpace(sourceFile.text.charCodeAt(pos))) { + pos++; + } + return pos; + } + function setPosForParamHelpStringOnNextLine(firstLineParamHelpStringPos) { + // Get the pos after consuming line breaks + pos = consumeLineBreaks(pos, end, sourceFile); + if (pos >= end) { + return; + } + if (paramHelpStringMargin === undefined) { + paramHelpStringMargin = sourceFile.getLineAndCharacterOfPosition(firstLineParamHelpStringPos).character; + } + // Now consume white spaces max + var startOfLinePos = pos; + pos = consumeWhiteSpacesOnTheLine(pos, end, sourceFile, paramHelpStringMargin); + if (pos >= end) { + return; + } + var consumedSpaces = pos - startOfLinePos; + if (consumedSpaces < paramHelpStringMargin) { + var ch = sourceFile.text.charCodeAt(pos); + if (ch === 42 /* asterisk */) { + // Consume more spaces after asterisk + pos = consumeWhiteSpacesOnTheLine(pos + 1, end, sourceFile, paramHelpStringMargin - consumedSpaces - 1); + } + } + } + } + } + } + var TypeObject = (function () { + function TypeObject(checker, flags) { + this.checker = checker; + this.flags = flags; + } + TypeObject.prototype.getFlags = function () { + return this.flags; + }; + TypeObject.prototype.getSymbol = function () { + return this.symbol; + }; + TypeObject.prototype.getProperties = function () { + return this.checker.getPropertiesOfType(this); + }; + TypeObject.prototype.getProperty = function (propertyName) { + return this.checker.getPropertyOfType(this, propertyName); + }; + TypeObject.prototype.getApparentProperties = function () { + return this.checker.getAugmentedPropertiesOfType(this); + }; + TypeObject.prototype.getCallSignatures = function () { + return this.checker.getSignaturesOfType(this, 0 /* Call */); + }; + TypeObject.prototype.getConstructSignatures = function () { + return this.checker.getSignaturesOfType(this, 1 /* Construct */); + }; + TypeObject.prototype.getStringIndexType = function () { + return this.checker.getIndexTypeOfType(this, 0 /* String */); + }; + TypeObject.prototype.getNumberIndexType = function () { + return this.checker.getIndexTypeOfType(this, 1 /* Number */); + }; + TypeObject.prototype.getBaseTypes = function () { + return this.flags & (1024 /* Class */ | 2048 /* Interface */) + ? this.checker.getBaseTypes(this) + : undefined; + }; + return TypeObject; + })(); + var SignatureObject = (function () { + function SignatureObject(checker) { + this.checker = checker; + } + SignatureObject.prototype.getDeclaration = function () { + return this.declaration; + }; + SignatureObject.prototype.getTypeParameters = function () { + return this.typeParameters; + }; + SignatureObject.prototype.getParameters = function () { + return this.parameters; + }; + SignatureObject.prototype.getReturnType = function () { + return this.checker.getReturnTypeOfSignature(this); + }; + SignatureObject.prototype.getDocumentationComment = function () { + if (this.documentationComment === undefined) { + this.documentationComment = this.declaration ? getJsDocCommentsFromDeclarations([this.declaration], + /*name*/ undefined, + /*canUseParsedParamTagComments*/ false) : []; + } + return this.documentationComment; + }; + return SignatureObject; + })(); + var SourceFileObject = (function (_super) { + __extends(SourceFileObject, _super); + function SourceFileObject() { + _super.apply(this, arguments); + } + SourceFileObject.prototype.update = function (newText, textChangeRange) { + return ts.updateSourceFile(this, newText, textChangeRange); + }; + SourceFileObject.prototype.getLineAndCharacterOfPosition = function (position) { + return ts.getLineAndCharacterOfPosition(this, position); + }; + SourceFileObject.prototype.getLineStarts = function () { + return ts.getLineStarts(this); + }; + SourceFileObject.prototype.getPositionOfLineAndCharacter = function (line, character) { + return ts.getPositionOfLineAndCharacter(this, line, character); + }; + SourceFileObject.prototype.getNamedDeclarations = function () { + if (!this.namedDeclarations) { + this.namedDeclarations = this.computeNamedDeclarations(); + } + return this.namedDeclarations; + }; + SourceFileObject.prototype.computeNamedDeclarations = function () { + var result = {}; + ts.forEachChild(this, visit); + return result; + function addDeclaration(declaration) { + var name = getDeclarationName(declaration); + if (name) { + var declarations = getDeclarations(name); + declarations.push(declaration); + } + } + function getDeclarations(name) { + return ts.getProperty(result, name) || (result[name] = []); + } + function getDeclarationName(declaration) { + if (declaration.name) { + var result_2 = getTextOfIdentifierOrLiteral(declaration.name); + if (result_2 !== undefined) { + return result_2; + } + if (declaration.name.kind === 136 /* ComputedPropertyName */) { + var expr = declaration.name.expression; + if (expr.kind === 166 /* PropertyAccessExpression */) { + return expr.name.text; + } + return getTextOfIdentifierOrLiteral(expr); + } + } + return undefined; + } + function getTextOfIdentifierOrLiteral(node) { + if (node) { + if (node.kind === 69 /* Identifier */ || + node.kind === 9 /* StringLiteral */ || + node.kind === 8 /* NumericLiteral */) { + return node.text; + } + } + return undefined; + } + function visit(node) { + switch (node.kind) { + case 213 /* FunctionDeclaration */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: + var functionDeclaration = node; + var declarationName = getDeclarationName(functionDeclaration); + if (declarationName) { + var declarations = getDeclarations(declarationName); + var lastDeclaration = ts.lastOrUndefined(declarations); + // Check whether this declaration belongs to an "overload group". + if (lastDeclaration && functionDeclaration.parent === lastDeclaration.parent && functionDeclaration.symbol === lastDeclaration.symbol) { + // Overwrite the last declaration if it was an overload + // and this one is an implementation. + if (functionDeclaration.body && !lastDeclaration.body) { + declarations[declarations.length - 1] = functionDeclaration; + } + } + else { + declarations.push(functionDeclaration); + } + ts.forEachChild(node, visit); + } + break; + case 214 /* ClassDeclaration */: + case 215 /* InterfaceDeclaration */: + case 216 /* TypeAliasDeclaration */: + case 217 /* EnumDeclaration */: + case 218 /* ModuleDeclaration */: + case 221 /* ImportEqualsDeclaration */: + case 230 /* ExportSpecifier */: + case 226 /* ImportSpecifier */: + case 221 /* ImportEqualsDeclaration */: + case 223 /* ImportClause */: + case 224 /* NamespaceImport */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: + case 155 /* TypeLiteral */: + addDeclaration(node); + // fall through + case 144 /* Constructor */: + case 193 /* VariableStatement */: + case 212 /* VariableDeclarationList */: + case 161 /* ObjectBindingPattern */: + case 162 /* ArrayBindingPattern */: + case 219 /* ModuleBlock */: + ts.forEachChild(node, visit); + break; + case 192 /* Block */: + if (ts.isFunctionBlock(node)) { + ts.forEachChild(node, visit); + } + break; + case 138 /* Parameter */: + // Only consider properties defined as constructor parameters + if (!(node.flags & 112 /* AccessibilityModifier */)) { + break; + } + // fall through + case 211 /* VariableDeclaration */: + case 163 /* BindingElement */: + if (ts.isBindingPattern(node.name)) { + ts.forEachChild(node.name, visit); + break; + } + case 247 /* EnumMember */: + case 141 /* PropertyDeclaration */: + case 140 /* PropertySignature */: + addDeclaration(node); + break; + case 228 /* ExportDeclaration */: + // Handle named exports case e.g.: + // export {a, b as B} from "mod"; + if (node.exportClause) { + ts.forEach(node.exportClause.elements, visit); + } + break; + case 222 /* ImportDeclaration */: + var importClause = node.importClause; + if (importClause) { + // Handle default import case e.g.: + // import d from "mod"; + if (importClause.name) { + addDeclaration(importClause); + } + // Handle named bindings in imports e.g.: + // import * as NS from "mod"; + // import {a, b as B} from "mod"; + if (importClause.namedBindings) { + if (importClause.namedBindings.kind === 224 /* NamespaceImport */) { + addDeclaration(importClause.namedBindings); + } + else { + ts.forEach(importClause.namedBindings.elements, visit); + } + } + } + break; + } + } + }; + return SourceFileObject; + })(NodeObject); + var TextChange = (function () { + function TextChange() { + } + return TextChange; + })(); + ts.TextChange = TextChange; + var HighlightSpanKind; + (function (HighlightSpanKind) { + HighlightSpanKind.none = "none"; + HighlightSpanKind.definition = "definition"; + HighlightSpanKind.reference = "reference"; + HighlightSpanKind.writtenReference = "writtenReference"; + })(HighlightSpanKind = ts.HighlightSpanKind || (ts.HighlightSpanKind = {})); + (function (IndentStyle) { + IndentStyle[IndentStyle["None"] = 0] = "None"; + IndentStyle[IndentStyle["Block"] = 1] = "Block"; + IndentStyle[IndentStyle["Smart"] = 2] = "Smart"; + })(ts.IndentStyle || (ts.IndentStyle = {})); + var IndentStyle = ts.IndentStyle; + (function (SymbolDisplayPartKind) { + SymbolDisplayPartKind[SymbolDisplayPartKind["aliasName"] = 0] = "aliasName"; + SymbolDisplayPartKind[SymbolDisplayPartKind["className"] = 1] = "className"; + SymbolDisplayPartKind[SymbolDisplayPartKind["enumName"] = 2] = "enumName"; + SymbolDisplayPartKind[SymbolDisplayPartKind["fieldName"] = 3] = "fieldName"; + SymbolDisplayPartKind[SymbolDisplayPartKind["interfaceName"] = 4] = "interfaceName"; + SymbolDisplayPartKind[SymbolDisplayPartKind["keyword"] = 5] = "keyword"; + SymbolDisplayPartKind[SymbolDisplayPartKind["lineBreak"] = 6] = "lineBreak"; + SymbolDisplayPartKind[SymbolDisplayPartKind["numericLiteral"] = 7] = "numericLiteral"; + SymbolDisplayPartKind[SymbolDisplayPartKind["stringLiteral"] = 8] = "stringLiteral"; + SymbolDisplayPartKind[SymbolDisplayPartKind["localName"] = 9] = "localName"; + SymbolDisplayPartKind[SymbolDisplayPartKind["methodName"] = 10] = "methodName"; + SymbolDisplayPartKind[SymbolDisplayPartKind["moduleName"] = 11] = "moduleName"; + SymbolDisplayPartKind[SymbolDisplayPartKind["operator"] = 12] = "operator"; + SymbolDisplayPartKind[SymbolDisplayPartKind["parameterName"] = 13] = "parameterName"; + SymbolDisplayPartKind[SymbolDisplayPartKind["propertyName"] = 14] = "propertyName"; + SymbolDisplayPartKind[SymbolDisplayPartKind["punctuation"] = 15] = "punctuation"; + SymbolDisplayPartKind[SymbolDisplayPartKind["space"] = 16] = "space"; + SymbolDisplayPartKind[SymbolDisplayPartKind["text"] = 17] = "text"; + SymbolDisplayPartKind[SymbolDisplayPartKind["typeParameterName"] = 18] = "typeParameterName"; + SymbolDisplayPartKind[SymbolDisplayPartKind["enumMemberName"] = 19] = "enumMemberName"; + SymbolDisplayPartKind[SymbolDisplayPartKind["functionName"] = 20] = "functionName"; + 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"; + TokenClass[TokenClass["Operator"] = 2] = "Operator"; + TokenClass[TokenClass["Comment"] = 3] = "Comment"; + TokenClass[TokenClass["Whitespace"] = 4] = "Whitespace"; + TokenClass[TokenClass["Identifier"] = 5] = "Identifier"; + TokenClass[TokenClass["NumberLiteral"] = 6] = "NumberLiteral"; + TokenClass[TokenClass["StringLiteral"] = 7] = "StringLiteral"; + TokenClass[TokenClass["RegExpLiteral"] = 8] = "RegExpLiteral"; + })(ts.TokenClass || (ts.TokenClass = {})); + var TokenClass = ts.TokenClass; + // TODO: move these to enums + var ScriptElementKind; + (function (ScriptElementKind) { + ScriptElementKind.unknown = ""; + ScriptElementKind.warning = "warning"; + // predefined type (void) or keyword (class) + ScriptElementKind.keyword = "keyword"; + // top level script node + ScriptElementKind.scriptElement = "script"; + // module foo {} + ScriptElementKind.moduleElement = "module"; + // class X {} + ScriptElementKind.classElement = "class"; + // var x = class X {} + ScriptElementKind.localClassElement = "local class"; + // interface Y {} + ScriptElementKind.interfaceElement = "interface"; + // type T = ... + ScriptElementKind.typeElement = "type"; + // enum E + ScriptElementKind.enumElement = "enum"; + // Inside module and script only + // let v = .. + ScriptElementKind.variableElement = "var"; + // Inside function + ScriptElementKind.localVariableElement = "local var"; + // Inside module and script only + // function f() { } + ScriptElementKind.functionElement = "function"; + // Inside function + ScriptElementKind.localFunctionElement = "local function"; + // class X { [public|private]* foo() {} } + ScriptElementKind.memberFunctionElement = "method"; + // class X { [public|private]* [get|set] foo:number; } + ScriptElementKind.memberGetAccessorElement = "getter"; + ScriptElementKind.memberSetAccessorElement = "setter"; + // class X { [public|private]* foo:number; } + // interface Y { foo:number; } + ScriptElementKind.memberVariableElement = "property"; + // class X { constructor() { } } + ScriptElementKind.constructorImplementationElement = "constructor"; + // interface Y { ():number; } + ScriptElementKind.callSignatureElement = "call"; + // interface Y { []:number; } + ScriptElementKind.indexSignatureElement = "index"; + // interface Y { new():Y; } + ScriptElementKind.constructSignatureElement = "construct"; + // function foo(*Y*: string) + ScriptElementKind.parameterElement = "parameter"; + ScriptElementKind.typeParameterElement = "type parameter"; + ScriptElementKind.primitiveType = "primitive type"; + ScriptElementKind.label = "label"; + ScriptElementKind.alias = "alias"; + ScriptElementKind.constElement = "const"; + ScriptElementKind.letElement = "let"; + })(ScriptElementKind = ts.ScriptElementKind || (ts.ScriptElementKind = {})); + var ScriptElementKindModifier; + (function (ScriptElementKindModifier) { + ScriptElementKindModifier.none = ""; + ScriptElementKindModifier.publicMemberModifier = "public"; + ScriptElementKindModifier.privateMemberModifier = "private"; + ScriptElementKindModifier.protectedMemberModifier = "protected"; + ScriptElementKindModifier.exportedModifier = "export"; + ScriptElementKindModifier.ambientModifier = "declare"; + ScriptElementKindModifier.staticModifier = "static"; + ScriptElementKindModifier.abstractModifier = "abstract"; + })(ScriptElementKindModifier = ts.ScriptElementKindModifier || (ts.ScriptElementKindModifier = {})); + var ClassificationTypeNames = (function () { + function ClassificationTypeNames() { + } + ClassificationTypeNames.comment = "comment"; + ClassificationTypeNames.identifier = "identifier"; + ClassificationTypeNames.keyword = "keyword"; + ClassificationTypeNames.numericLiteral = "number"; + ClassificationTypeNames.operator = "operator"; + ClassificationTypeNames.stringLiteral = "string"; + ClassificationTypeNames.whiteSpace = "whitespace"; + ClassificationTypeNames.text = "text"; + ClassificationTypeNames.punctuation = "punctuation"; + ClassificationTypeNames.className = "class name"; + ClassificationTypeNames.enumName = "enum name"; + ClassificationTypeNames.interfaceName = "interface name"; + ClassificationTypeNames.moduleName = "module name"; + ClassificationTypeNames.typeParameterName = "type parameter name"; + ClassificationTypeNames.typeAliasName = "type alias name"; + ClassificationTypeNames.parameterName = "parameter name"; + ClassificationTypeNames.docCommentTagName = "doc comment tag name"; + return ClassificationTypeNames; + })(); + 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"; + })(ts.ClassificationType || (ts.ClassificationType = {})); + var ClassificationType = ts.ClassificationType; + function displayPartsToString(displayParts) { + if (displayParts) { + return ts.map(displayParts, function (displayPart) { return displayPart.text; }).join(""); + } + return ""; + } + ts.displayPartsToString = displayPartsToString; + function isLocalVariableOrFunction(symbol) { + if (symbol.parent) { + return false; // This is exported symbol + } + return ts.forEach(symbol.declarations, function (declaration) { + // Function expressions are local + if (declaration.kind === 173 /* FunctionExpression */) { + return true; + } + if (declaration.kind !== 211 /* VariableDeclaration */ && declaration.kind !== 213 /* FunctionDeclaration */) { + return false; + } + // If the parent is not sourceFile or module block it is local variable + for (var parent_8 = declaration.parent; !ts.isFunctionBlock(parent_8); parent_8 = parent_8.parent) { + // Reached source file or module block + if (parent_8.kind === 248 /* SourceFile */ || parent_8.kind === 219 /* ModuleBlock */) { + return false; + } + } + // parent is in function block + return true; + }); + } + function getDefaultCompilerOptions() { + // Always default to "ScriptTarget.ES5" for the language service + return { + target: 1 /* ES5 */, + module: 0 /* None */, + jsx: 1 /* Preserve */ + }; + } + ts.getDefaultCompilerOptions = getDefaultCompilerOptions; + // Cache host information about scrip Should be refreshed + // at each language service public entry point, since we don't know when + // set of scripts handled by the host changes. + var HostCache = (function () { + function HostCache(host, getCanonicalFileName) { + this.host = host; + // script id => script index + this.fileNameToEntry = ts.createFileMap(getCanonicalFileName); + // Initialize the list with the root file names + var rootFileNames = host.getScriptFileNames(); + for (var _i = 0; _i < rootFileNames.length; _i++) { + var fileName = rootFileNames[_i]; + this.createEntry(fileName); + } + // store the compilation settings + this._compilationSettings = host.getCompilationSettings() || getDefaultCompilerOptions(); + } + HostCache.prototype.compilationSettings = function () { + return this._compilationSettings; + }; + HostCache.prototype.createEntry = function (fileName) { + var entry; + var scriptSnapshot = this.host.getScriptSnapshot(fileName); + if (scriptSnapshot) { + entry = { + hostFileName: fileName, + version: this.host.getScriptVersion(fileName), + scriptSnapshot: scriptSnapshot + }; + } + this.fileNameToEntry.set(fileName, entry); + return entry; + }; + HostCache.prototype.getEntry = function (fileName) { + return this.fileNameToEntry.get(fileName); + }; + HostCache.prototype.contains = function (fileName) { + return this.fileNameToEntry.contains(fileName); + }; + HostCache.prototype.getOrCreateEntry = function (fileName) { + if (this.contains(fileName)) { + return this.getEntry(fileName); + } + return this.createEntry(fileName); + }; + HostCache.prototype.getRootFileNames = function () { + var fileNames = []; + this.fileNameToEntry.forEachValue(function (value) { + if (value) { + fileNames.push(value.hostFileName); + } + }); + return fileNames; + }; + HostCache.prototype.getVersion = function (fileName) { + var file = this.getEntry(fileName); + return file && file.version; + }; + HostCache.prototype.getScriptSnapshot = function (fileName) { + var file = this.getEntry(fileName); + return file && file.scriptSnapshot; + }; + return HostCache; + })(); + var SyntaxTreeCache = (function () { + function SyntaxTreeCache(host) { + this.host = host; + } + SyntaxTreeCache.prototype.getCurrentSourceFile = function (fileName) { + var scriptSnapshot = this.host.getScriptSnapshot(fileName); + if (!scriptSnapshot) { + // The host does not know about this file. + throw new Error("Could not find file: '" + fileName + "'."); + } + var version = this.host.getScriptVersion(fileName); + var sourceFile; + if (this.currentFileName !== fileName) { + // This is a new file, just parse it + sourceFile = createLanguageServiceSourceFile(fileName, scriptSnapshot, 2 /* Latest */, version, /*setNodeParents:*/ true); + } + else if (this.currentFileVersion !== version) { + // This is the same file, just a newer version. Incrementally parse the file. + var editRange = scriptSnapshot.getChangeRange(this.currentFileScriptSnapshot); + sourceFile = updateLanguageServiceSourceFile(this.currentSourceFile, scriptSnapshot, version, editRange); + } + if (sourceFile) { + // All done, ensure state is up to date + this.currentFileVersion = version; + this.currentFileName = fileName; + this.currentFileScriptSnapshot = scriptSnapshot; + this.currentSourceFile = sourceFile; + } + return this.currentSourceFile; + }; + return SyntaxTreeCache; + })(); + function setSourceFileFields(sourceFile, scriptSnapshot, version) { + sourceFile.version = version; + sourceFile.scriptSnapshot = scriptSnapshot; + } + /* + * This function will compile source text from 'input' argument using specified compiler options. + * If not options are provided - it will use a set of default compiler options. + * Extra compiler options that will unconditionally be used by this function are: + * - isolatedModules = true + * - allowNonTsExtensions = true + * - noLib = true + * - noResolve = true + */ + function transpileModule(input, transpileOptions) { + var options = transpileOptions.compilerOptions ? ts.clone(transpileOptions.compilerOptions) : getDefaultCompilerOptions(); + options.isolatedModules = true; + // Filename can be non-ts file. + options.allowNonTsExtensions = true; + // We are not returning a sourceFile for lib file when asked by the program, + // so pass --noLib to avoid reporting a file not found error. + options.noLib = true; + // We are not doing a full typecheck, we are not resolving the whole context, + // so pass --noResolve to avoid reporting missing file errors. + options.noResolve = true; + // if jsx is specified then treat file as .tsx + var inputFileName = transpileOptions.fileName || (options.jsx ? "module.tsx" : "module.ts"); + var sourceFile = ts.createSourceFile(inputFileName, input, options.target); + if (transpileOptions.moduleName) { + sourceFile.moduleName = transpileOptions.moduleName; + } + sourceFile.renamedDependencies = transpileOptions.renamedDependencies; + var newLine = ts.getNewLineCharacter(options); + // Output + var outputText; + var sourceMapText; + // Create a compilerHost object to allow the compiler to read and write files + var compilerHost = { + getSourceFile: function (fileName, target) { return fileName === ts.normalizeSlashes(inputFileName) ? sourceFile : undefined; }, + writeFile: function (name, text, writeByteOrderMark) { + if (ts.fileExtensionIs(name, ".map")) { + ts.Debug.assert(sourceMapText === undefined, "Unexpected multiple source map outputs for the file '" + name + "'"); + sourceMapText = text; + } + else { + ts.Debug.assert(outputText === undefined, "Unexpected multiple outputs for the file: " + name); + outputText = text; + } + }, + getDefaultLibFileName: function () { return "lib.d.ts"; }, + useCaseSensitiveFileNames: function () { return false; }, + getCanonicalFileName: function (fileName) { return fileName; }, + getCurrentDirectory: function () { return ""; }, + getNewLine: function () { return newLine; }, + fileExists: function (fileName) { return fileName === inputFileName; }, + readFile: function (fileName) { return ""; } + }; + var program = ts.createProgram([inputFileName], options, compilerHost); + var diagnostics; + if (transpileOptions.reportDiagnostics) { + diagnostics = []; + ts.addRange(/*to*/ diagnostics, /*from*/ program.getSyntacticDiagnostics(sourceFile)); + ts.addRange(/*to*/ diagnostics, /*from*/ program.getOptionsDiagnostics()); + } + // Emit + program.emit(); + ts.Debug.assert(outputText !== undefined, "Output generation failed"); + return { outputText: outputText, diagnostics: diagnostics, sourceMapText: sourceMapText }; + } + ts.transpileModule = transpileModule; + /* + * This is a shortcut function for transpileModule - it accepts transpileOptions as parameters and returns only outputText part of the result. + */ + function transpile(input, compilerOptions, fileName, diagnostics, moduleName) { + var output = transpileModule(input, { compilerOptions: compilerOptions, fileName: fileName, reportDiagnostics: !!diagnostics, moduleName: moduleName }); + // addRange correctly handles cases when wither 'from' or 'to' argument is missing + ts.addRange(diagnostics, output.diagnostics); + return output.outputText; + } + ts.transpile = transpile; + function createLanguageServiceSourceFile(fileName, scriptSnapshot, scriptTarget, version, setNodeParents) { + var text = scriptSnapshot.getText(0, scriptSnapshot.getLength()); + var sourceFile = ts.createSourceFile(fileName, text, scriptTarget, setNodeParents); + setSourceFileFields(sourceFile, scriptSnapshot, version); + // after full parsing we can use table with interned strings as name table + sourceFile.nameTable = sourceFile.identifiers; + return sourceFile; + } + ts.createLanguageServiceSourceFile = createLanguageServiceSourceFile; + ts.disableIncrementalParsing = false; + function updateLanguageServiceSourceFile(sourceFile, scriptSnapshot, version, textChangeRange, aggressiveChecks) { + // If we were given a text change range, and our version or open-ness changed, then + // incrementally parse this file. + if (textChangeRange) { + if (version !== sourceFile.version) { + // Once incremental parsing is ready, then just call into this function. + if (!ts.disableIncrementalParsing) { + var newText; + // grab the fragment from the beginning of the original text to the beginning of the span + var prefix = textChangeRange.span.start !== 0 + ? sourceFile.text.substr(0, textChangeRange.span.start) + : ""; + // grab the fragment from the end of the span till the end of the original text + var suffix = ts.textSpanEnd(textChangeRange.span) !== sourceFile.text.length + ? sourceFile.text.substr(ts.textSpanEnd(textChangeRange.span)) + : ""; + if (textChangeRange.newLength === 0) { + // edit was a deletion - just combine prefix and suffix + newText = prefix && suffix ? prefix + suffix : prefix || suffix; + } + else { + // it was actual edit, fetch the fragment of new text that correspond to new span + var changedText = scriptSnapshot.getText(textChangeRange.span.start, textChangeRange.span.start + textChangeRange.newLength); + // combine prefix, changed text and suffix + newText = prefix && suffix + ? prefix + changedText + suffix + : prefix + ? (prefix + changedText) + : (changedText + suffix); + } + var newSourceFile = ts.updateSourceFile(sourceFile, newText, textChangeRange, aggressiveChecks); + setSourceFileFields(newSourceFile, scriptSnapshot, version); + // after incremental parsing nameTable might not be up-to-date + // drop it so it can be lazily recreated later + newSourceFile.nameTable = undefined; + // dispose all resources held by old script snapshot + if (sourceFile !== newSourceFile && sourceFile.scriptSnapshot) { + if (sourceFile.scriptSnapshot.dispose) { + sourceFile.scriptSnapshot.dispose(); + } + sourceFile.scriptSnapshot = undefined; + } + return newSourceFile; + } + } + } + // Otherwise, just create a new source file. + return createLanguageServiceSourceFile(sourceFile.fileName, scriptSnapshot, sourceFile.languageVersion, version, /*setNodeParents:*/ true); + } + ts.updateLanguageServiceSourceFile = updateLanguageServiceSourceFile; + function createGetCanonicalFileName(useCaseSensitivefileNames) { + return useCaseSensitivefileNames + ? (function (fileName) { return fileName; }) + : (function (fileName) { return fileName.toLowerCase(); }); + } + ts.createGetCanonicalFileName = createGetCanonicalFileName; + function createDocumentRegistry(useCaseSensitiveFileNames) { + // Maps from compiler setting target (ES3, ES5, etc.) to all the cached documents we have + // for those settings. + var buckets = {}; + var getCanonicalFileName = createGetCanonicalFileName(!!useCaseSensitiveFileNames); + function getKeyFromCompilationSettings(settings) { + return "_" + settings.target + "|" + settings.module + "|" + settings.noResolve + "|" + settings.jsx; + } + function getBucketForCompilationSettings(settings, createIfMissing) { + var key = getKeyFromCompilationSettings(settings); + var bucket = ts.lookUp(buckets, key); + if (!bucket && createIfMissing) { + buckets[key] = bucket = ts.createFileMap(getCanonicalFileName); + } + return bucket; + } + function reportStats() { + var bucketInfoArray = Object.keys(buckets).filter(function (name) { return name && name.charAt(0) === '_'; }).map(function (name) { + var entries = ts.lookUp(buckets, name); + var sourceFiles = []; + for (var i in entries) { + var entry = entries.get(i); + sourceFiles.push({ + name: i, + refCount: entry.languageServiceRefCount, + references: entry.owners.slice(0) + }); + } + sourceFiles.sort(function (x, y) { return y.refCount - x.refCount; }); + return { + bucket: name, + sourceFiles: sourceFiles + }; + }); + return JSON.stringify(bucketInfoArray, null, 2); + } + function acquireDocument(fileName, compilationSettings, scriptSnapshot, version) { + return acquireOrUpdateDocument(fileName, compilationSettings, scriptSnapshot, version, /*acquiring:*/ true); + } + function updateDocument(fileName, compilationSettings, scriptSnapshot, version) { + return acquireOrUpdateDocument(fileName, compilationSettings, scriptSnapshot, version, /*acquiring:*/ false); + } + function acquireOrUpdateDocument(fileName, compilationSettings, scriptSnapshot, version, acquiring) { + var bucket = getBucketForCompilationSettings(compilationSettings, /*createIfMissing*/ true); + var entry = bucket.get(fileName); + if (!entry) { + ts.Debug.assert(acquiring, "How could we be trying to update a document that the registry doesn't have?"); + // Have never seen this file with these settings. Create a new source file for it. + var sourceFile = createLanguageServiceSourceFile(fileName, scriptSnapshot, compilationSettings.target, version, /*setNodeParents:*/ false); + entry = { + sourceFile: sourceFile, + languageServiceRefCount: 0, + owners: [] + }; + bucket.set(fileName, entry); + } + else { + // We have an entry for this file. However, it may be for a different version of + // the script snapshot. If so, update it appropriately. Otherwise, we can just + // return it as is. + if (entry.sourceFile.version !== version) { + entry.sourceFile = updateLanguageServiceSourceFile(entry.sourceFile, scriptSnapshot, version, scriptSnapshot.getChangeRange(entry.sourceFile.scriptSnapshot)); + } + } + // If we're acquiring, then this is the first time this LS is asking for this document. + // Increase our ref count so we know there's another LS using the document. If we're + // not acquiring, then that means the LS is 'updating' the file instead, and that means + // it has already acquired the document previously. As such, we do not need to increase + // the ref count. + if (acquiring) { + entry.languageServiceRefCount++; + } + return entry.sourceFile; + } + function releaseDocument(fileName, compilationSettings) { + var bucket = getBucketForCompilationSettings(compilationSettings, false); + ts.Debug.assert(bucket !== undefined); + var entry = bucket.get(fileName); + entry.languageServiceRefCount--; + ts.Debug.assert(entry.languageServiceRefCount >= 0); + if (entry.languageServiceRefCount === 0) { + bucket.remove(fileName); + } + } + return { + acquireDocument: acquireDocument, + updateDocument: updateDocument, + releaseDocument: releaseDocument, + reportStats: reportStats + }; + } + ts.createDocumentRegistry = createDocumentRegistry; + function preProcessFile(sourceText, readImportFiles) { + if (readImportFiles === void 0) { readImportFiles = true; } + var referencedFiles = []; + var importedFiles = []; + var ambientExternalModules; + var isNoDefaultLib = false; + function processTripleSlashDirectives() { + var commentRanges = ts.getLeadingCommentRanges(sourceText, 0); + ts.forEach(commentRanges, function (commentRange) { + var comment = sourceText.substring(commentRange.pos, commentRange.end); + var referencePathMatchResult = ts.getFileReferenceFromReferencePath(comment, commentRange); + if (referencePathMatchResult) { + isNoDefaultLib = referencePathMatchResult.isNoDefaultLib; + var fileReference = referencePathMatchResult.fileReference; + if (fileReference) { + referencedFiles.push(fileReference); + } + } + }); + } + function recordAmbientExternalModule() { + if (!ambientExternalModules) { + ambientExternalModules = []; + } + ambientExternalModules.push(scanner.getTokenValue()); + } + function recordModuleName() { + var importPath = scanner.getTokenValue(); + var pos = scanner.getTokenPos(); + importedFiles.push({ + fileName: importPath, + pos: pos, + end: pos + importPath.length + }); + } + function processImport() { + scanner.setText(sourceText); + var token = scanner.scan(); + // Look for: + // import "mod"; + // import d from "mod" + // import {a as A } from "mod"; + // import * as NS from "mod" + // import d, {a, b as B} from "mod" + // import i = require("mod"); + // + // export * from "mod" + // export {a as b} from "mod" + // export import i = require("mod") + while (token !== 1 /* EndOfFileToken */) { + if (token === 122 /* DeclareKeyword */) { + // declare module "mod" + token = scanner.scan(); + if (token === 125 /* ModuleKeyword */) { + token = scanner.scan(); + if (token === 9 /* StringLiteral */) { + recordAmbientExternalModule(); + continue; + } + } + } + else if (token === 89 /* ImportKeyword */) { + token = scanner.scan(); + if (token === 9 /* StringLiteral */) { + // import "mod"; + recordModuleName(); + continue; + } + else { + if (token === 69 /* Identifier */ || ts.isKeyword(token)) { + token = scanner.scan(); + if (token === 133 /* FromKeyword */) { + token = scanner.scan(); + if (token === 9 /* StringLiteral */) { + // import d from "mod"; + recordModuleName(); + continue; + } + } + else if (token === 56 /* EqualsToken */) { + token = scanner.scan(); + if (token === 127 /* RequireKeyword */) { + token = scanner.scan(); + if (token === 17 /* OpenParenToken */) { + token = scanner.scan(); + if (token === 9 /* StringLiteral */) { + // import i = require("mod"); + recordModuleName(); + continue; + } + } + } + } + else if (token === 24 /* CommaToken */) { + // consume comma and keep going + token = scanner.scan(); + } + else { + // unknown syntax + continue; + } + } + if (token === 15 /* OpenBraceToken */) { + token = scanner.scan(); + // consume "{ a as B, c, d as D}" clauses + while (token !== 16 /* CloseBraceToken */) { + token = scanner.scan(); + } + if (token === 16 /* CloseBraceToken */) { + token = scanner.scan(); + if (token === 133 /* FromKeyword */) { + token = scanner.scan(); + if (token === 9 /* StringLiteral */) { + // import {a as A} from "mod"; + // import d, {a, b as B} from "mod" + recordModuleName(); + } + } + } + } + else if (token === 37 /* AsteriskToken */) { + token = scanner.scan(); + if (token === 116 /* AsKeyword */) { + token = scanner.scan(); + if (token === 69 /* Identifier */ || ts.isKeyword(token)) { + token = scanner.scan(); + if (token === 133 /* FromKeyword */) { + token = scanner.scan(); + if (token === 9 /* StringLiteral */) { + // import * as NS from "mod" + // import d, * as NS from "mod" + recordModuleName(); + } + } + } + } + } + } + } + else if (token === 82 /* ExportKeyword */) { + token = scanner.scan(); + if (token === 15 /* OpenBraceToken */) { + token = scanner.scan(); + // consume "{ a as B, c, d as D}" clauses + while (token !== 16 /* CloseBraceToken */) { + token = scanner.scan(); + } + if (token === 16 /* CloseBraceToken */) { + token = scanner.scan(); + if (token === 133 /* FromKeyword */) { + token = scanner.scan(); + if (token === 9 /* StringLiteral */) { + // export {a as A} from "mod"; + // export {a, b as B} from "mod" + recordModuleName(); + } + } + } + } + else if (token === 37 /* AsteriskToken */) { + token = scanner.scan(); + if (token === 133 /* FromKeyword */) { + token = scanner.scan(); + if (token === 9 /* StringLiteral */) { + // export * from "mod" + recordModuleName(); + } + } + } + else if (token === 89 /* ImportKeyword */) { + token = scanner.scan(); + if (token === 69 /* Identifier */ || ts.isKeyword(token)) { + token = scanner.scan(); + if (token === 56 /* EqualsToken */) { + token = scanner.scan(); + if (token === 127 /* RequireKeyword */) { + token = scanner.scan(); + if (token === 17 /* OpenParenToken */) { + token = scanner.scan(); + if (token === 9 /* StringLiteral */) { + // export import i = require("mod"); + recordModuleName(); + } + } + } + } + } + } + } + token = scanner.scan(); + } + scanner.setText(undefined); + } + if (readImportFiles) { + processImport(); + } + processTripleSlashDirectives(); + return { referencedFiles: referencedFiles, importedFiles: importedFiles, isLibFile: isNoDefaultLib, ambientExternalModules: ambientExternalModules }; + } + ts.preProcessFile = preProcessFile; + /// Helpers + function getTargetLabel(referenceNode, labelName) { + while (referenceNode) { + if (referenceNode.kind === 207 /* LabeledStatement */ && referenceNode.label.text === labelName) { + return referenceNode.label; + } + referenceNode = referenceNode.parent; + } + return undefined; + } + function isJumpStatementTarget(node) { + return node.kind === 69 /* Identifier */ && + (node.parent.kind === 203 /* BreakStatement */ || node.parent.kind === 202 /* ContinueStatement */) && + node.parent.label === node; + } + function isLabelOfLabeledStatement(node) { + return node.kind === 69 /* Identifier */ && + node.parent.kind === 207 /* LabeledStatement */ && + node.parent.label === node; + } + /** + * Whether or not a 'node' is preceded by a label of the given string. + * Note: 'node' cannot be a SourceFile. + */ + function isLabeledBy(node, labelName) { + for (var owner = node.parent; owner.kind === 207 /* LabeledStatement */; owner = owner.parent) { + if (owner.label.text === labelName) { + return true; + } + } + return false; + } + function isLabelName(node) { + return isLabelOfLabeledStatement(node) || isJumpStatementTarget(node); + } + function isRightSideOfQualifiedName(node) { + return node.parent.kind === 135 /* QualifiedName */ && node.parent.right === node; + } + function isRightSideOfPropertyAccess(node) { + return node && node.parent && node.parent.kind === 166 /* PropertyAccessExpression */ && node.parent.name === node; + } + function isCallExpressionTarget(node) { + if (isRightSideOfPropertyAccess(node)) { + node = node.parent; + } + return node && node.parent && node.parent.kind === 168 /* CallExpression */ && node.parent.expression === node; + } + function isNewExpressionTarget(node) { + if (isRightSideOfPropertyAccess(node)) { + node = node.parent; + } + return node && node.parent && node.parent.kind === 169 /* NewExpression */ && node.parent.expression === node; + } + function isNameOfModuleDeclaration(node) { + return node.parent.kind === 218 /* ModuleDeclaration */ && node.parent.name === node; + } + function isNameOfFunctionDeclaration(node) { + return node.kind === 69 /* Identifier */ && + ts.isFunctionLike(node.parent) && node.parent.name === node; + } + /** Returns true if node is a name of an object literal property, e.g. "a" in x = { "a": 1 } */ + function isNameOfPropertyAssignment(node) { + return (node.kind === 69 /* Identifier */ || node.kind === 9 /* StringLiteral */ || node.kind === 8 /* NumericLiteral */) && + (node.parent.kind === 245 /* PropertyAssignment */ || node.parent.kind === 246 /* ShorthandPropertyAssignment */) && node.parent.name === node; + } + function isLiteralNameOfPropertyDeclarationOrIndexAccess(node) { + if (node.kind === 9 /* StringLiteral */ || node.kind === 8 /* NumericLiteral */) { + switch (node.parent.kind) { + case 141 /* PropertyDeclaration */: + case 140 /* PropertySignature */: + case 245 /* PropertyAssignment */: + case 247 /* EnumMember */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: + case 218 /* ModuleDeclaration */: + return node.parent.name === node; + case 167 /* ElementAccessExpression */: + return node.parent.argumentExpression === node; + } + } + return false; + } + function isNameOfExternalModuleImportOrDeclaration(node) { + if (node.kind === 9 /* StringLiteral */) { + return isNameOfModuleDeclaration(node) || + (ts.isExternalModuleImportEqualsDeclaration(node.parent.parent) && ts.getExternalModuleImportEqualsDeclarationExpression(node.parent.parent) === node); + } + return false; + } + /** Returns true if the position is within a comment */ + function isInsideComment(sourceFile, token, position) { + // The position has to be: 1. in the leading trivia (before token.getStart()), and 2. within a comment + return position <= token.getStart(sourceFile) && + (isInsideCommentRange(ts.getTrailingCommentRanges(sourceFile.text, token.getFullStart())) || + isInsideCommentRange(ts.getLeadingCommentRanges(sourceFile.text, token.getFullStart()))); + function isInsideCommentRange(comments) { + return ts.forEach(comments, function (comment) { + // either we are 1. completely inside the comment, or 2. at the end of the comment + if (comment.pos < position && position < comment.end) { + return true; + } + else if (position === comment.end) { + var text = sourceFile.text; + var width = comment.end - comment.pos; + // is single line comment or just /* + if (width <= 2 || text.charCodeAt(comment.pos + 1) === 47 /* slash */) { + return true; + } + else { + // is unterminated multi-line comment + return !(text.charCodeAt(comment.end - 1) === 47 /* slash */ && + text.charCodeAt(comment.end - 2) === 42 /* asterisk */); + } + } + return false; + }); + } + } + var SemanticMeaning; + (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"; + })(SemanticMeaning || (SemanticMeaning = {})); + var BreakContinueSearchType; + (function (BreakContinueSearchType) { + BreakContinueSearchType[BreakContinueSearchType["None"] = 0] = "None"; + BreakContinueSearchType[BreakContinueSearchType["Unlabeled"] = 1] = "Unlabeled"; + BreakContinueSearchType[BreakContinueSearchType["Labeled"] = 2] = "Labeled"; + BreakContinueSearchType[BreakContinueSearchType["All"] = 3] = "All"; + })(BreakContinueSearchType || (BreakContinueSearchType = {})); + // A cache of completion entries for keywords, these do not change between sessions + var keywordCompletions = []; + for (var i = 70 /* FirstKeyword */; i <= 134 /* LastKeyword */; i++) { + keywordCompletions.push({ + name: ts.tokenToString(i), + kind: ScriptElementKind.keyword, + kindModifiers: ScriptElementKindModifier.none, + sortText: "0" + }); + } + /* @internal */ function getContainerNode(node) { + while (true) { + node = node.parent; + if (!node) { + return undefined; + } + switch (node.kind) { + case 248 /* SourceFile */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: + case 213 /* FunctionDeclaration */: + case 173 /* FunctionExpression */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: + case 214 /* ClassDeclaration */: + case 215 /* InterfaceDeclaration */: + case 217 /* EnumDeclaration */: + case 218 /* ModuleDeclaration */: + return node; + } + } + } + ts.getContainerNode = getContainerNode; + /* @internal */ function getNodeKind(node) { + switch (node.kind) { + case 218 /* ModuleDeclaration */: return ScriptElementKind.moduleElement; + case 214 /* ClassDeclaration */: return ScriptElementKind.classElement; + case 215 /* InterfaceDeclaration */: return ScriptElementKind.interfaceElement; + case 216 /* TypeAliasDeclaration */: return ScriptElementKind.typeElement; + case 217 /* EnumDeclaration */: return ScriptElementKind.enumElement; + case 211 /* VariableDeclaration */: + return ts.isConst(node) + ? ScriptElementKind.constElement + : ts.isLet(node) + ? ScriptElementKind.letElement + : ScriptElementKind.variableElement; + case 213 /* FunctionDeclaration */: return ScriptElementKind.functionElement; + case 145 /* GetAccessor */: return ScriptElementKind.memberGetAccessorElement; + case 146 /* SetAccessor */: return ScriptElementKind.memberSetAccessorElement; + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: + return ScriptElementKind.memberFunctionElement; + case 141 /* PropertyDeclaration */: + case 140 /* PropertySignature */: + return ScriptElementKind.memberVariableElement; + case 149 /* IndexSignature */: return ScriptElementKind.indexSignatureElement; + case 148 /* ConstructSignature */: return ScriptElementKind.constructSignatureElement; + case 147 /* CallSignature */: return ScriptElementKind.callSignatureElement; + case 144 /* Constructor */: return ScriptElementKind.constructorImplementationElement; + case 137 /* TypeParameter */: return ScriptElementKind.typeParameterElement; + case 247 /* EnumMember */: return ScriptElementKind.variableElement; + case 138 /* Parameter */: return (node.flags & 112 /* AccessibilityModifier */) ? ScriptElementKind.memberVariableElement : ScriptElementKind.parameterElement; + case 221 /* ImportEqualsDeclaration */: + case 226 /* ImportSpecifier */: + case 223 /* ImportClause */: + case 230 /* ExportSpecifier */: + case 224 /* NamespaceImport */: + return ScriptElementKind.alias; + } + return ScriptElementKind.unknown; + } + ts.getNodeKind = getNodeKind; + var CancellationTokenObject = (function () { + function CancellationTokenObject(cancellationToken) { + this.cancellationToken = cancellationToken; + } + CancellationTokenObject.prototype.isCancellationRequested = function () { + return this.cancellationToken && this.cancellationToken.isCancellationRequested(); + }; + CancellationTokenObject.prototype.throwIfCancellationRequested = function () { + if (this.isCancellationRequested()) { + throw new ts.OperationCanceledException(); + } + }; + return CancellationTokenObject; + })(); + function createLanguageService(host, documentRegistry) { + if (documentRegistry === void 0) { documentRegistry = createDocumentRegistry(); } + var syntaxTreeCache = new SyntaxTreeCache(host); + var ruleProvider; + var program; + var lastProjectVersion; + var useCaseSensitivefileNames = false; + var cancellationToken = new CancellationTokenObject(host.getCancellationToken && host.getCancellationToken()); + // Check if the localized messages json is set, otherwise query the host for it + if (!ts.localizedDiagnosticMessages && host.getLocalizedDiagnosticMessages) { + ts.localizedDiagnosticMessages = host.getLocalizedDiagnosticMessages(); + } + function log(message) { + if (host.log) { + host.log(message); + } + } + var getCanonicalFileName = createGetCanonicalFileName(useCaseSensitivefileNames); + function getValidSourceFile(fileName) { + fileName = ts.normalizeSlashes(fileName); + var sourceFile = program.getSourceFile(getCanonicalFileName(fileName)); + if (!sourceFile) { + throw new Error("Could not find file: '" + fileName + "'."); + } + return sourceFile; + } + function getRuleProvider(options) { + // Ensure rules are initialized and up to date wrt to formatting options + if (!ruleProvider) { + ruleProvider = new ts.formatting.RulesProvider(); + } + ruleProvider.ensureUpToDate(options); + return ruleProvider; + } + function synchronizeHostData() { + // perform fast check if host supports it + if (host.getProjectVersion) { + var hostProjectVersion = host.getProjectVersion(); + if (hostProjectVersion) { + if (lastProjectVersion === hostProjectVersion) { + return; + } + lastProjectVersion = hostProjectVersion; + } + } + // 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 + if (programUpToDate()) { + return; + } + // IMPORTANT - It is critical from this moment onward that we do not check + // cancellation tokens. We are about to mutate source files from a previous program + // instance. If we cancel midway through, we may end up in an inconsistent state where + // the program points to old source files that have been invalidated because of + // incremental parsing. + var oldSettings = program && program.getCompilerOptions(); + var newSettings = hostCache.compilationSettings(); + var changesInCompilationSettingsAffectSyntax = oldSettings && + (oldSettings.target !== newSettings.target || + oldSettings.module !== newSettings.module || + oldSettings.noResolve !== newSettings.noResolve || + oldSettings.jsx !== newSettings.jsx); + // Now create a new compiler + var compilerHost = { + getSourceFile: getOrCreateSourceFile, + getCancellationToken: function () { return cancellationToken; }, + getCanonicalFileName: getCanonicalFileName, + useCaseSensitiveFileNames: function () { return useCaseSensitivefileNames; }, + getNewLine: function () { return ts.getNewLineOrDefaultFromHost(host); }, + getDefaultLibFileName: function (options) { return host.getDefaultLibFileName(options); }, + writeFile: function (fileName, data, writeByteOrderMark) { }, + getCurrentDirectory: function () { return host.getCurrentDirectory(); }, + fileExists: function (fileName) { + // stub missing host functionality + ts.Debug.assert(!host.resolveModuleNames); + return hostCache.getOrCreateEntry(fileName) !== undefined; + }, + readFile: function (fileName) { + // stub missing host functionality + var entry = hostCache.getOrCreateEntry(fileName); + return entry && entry.scriptSnapshot.getText(0, entry.scriptSnapshot.getLength()); + } + }; + if (host.resolveModuleNames) { + compilerHost.resolveModuleNames = function (moduleNames, containingFile) { return host.resolveModuleNames(moduleNames, containingFile); }; + } + var newProgram = ts.createProgram(hostCache.getRootFileNames(), newSettings, compilerHost, program); + // Release any files we have acquired in the old program but are + // not part of the new program. + if (program) { + var oldSourceFiles = program.getSourceFiles(); + for (var _i = 0; _i < oldSourceFiles.length; _i++) { + var oldSourceFile = oldSourceFiles[_i]; + var fileName = oldSourceFile.fileName; + if (!newProgram.getSourceFile(fileName) || changesInCompilationSettingsAffectSyntax) { + documentRegistry.releaseDocument(fileName, oldSettings); + } + } + } + // hostCache is captured in the closure for 'getOrCreateSourceFile' but it should not be used past this point. + // It needs to be cleared to allow all collected snapshots to be released + hostCache = undefined; + program = newProgram; + // Make sure all the nodes in the program are both bound, and have their parent + // pointers set property. + program.getTypeChecker(); + return; + function getOrCreateSourceFile(fileName) { + ts.Debug.assert(hostCache !== undefined); + // The program is asking for this file, check first if the host can locate it. + // If the host can not locate the file, then it does not exist. return undefined + // to the program to allow reporting of errors for missing files. + var hostFileInformation = hostCache.getOrCreateEntry(fileName); + if (!hostFileInformation) { + return undefined; + } + // Check if the language version has changed since we last created a program; if they are the same, + // it is safe to reuse the souceFiles; if not, then the shape of the AST can change, and the oldSourceFile + // can not be reused. we have to dump all syntax trees and create new ones. + if (!changesInCompilationSettingsAffectSyntax) { + // Check if the old program had this file already + var oldSourceFile = program && program.getSourceFile(fileName); + if (oldSourceFile) { + // We already had a source file for this file name. Go to the registry to + // ensure that we get the right up to date version of it. We need this to + // address the following 'race'. Specifically, say we have the following: + // + // LS1 + // \ + // DocumentRegistry + // / + // LS2 + // + // Each LS has a reference to file 'foo.ts' at version 1. LS2 then updates + // it's version of 'foo.ts' to version 2. This will cause LS2 and the + // DocumentRegistry to have version 2 of the document. HOwever, LS1 will + // have version 1. And *importantly* this source file will be *corrupt*. + // The act of creating version 2 of the file irrevocably damages the version + // 1 file. + // + // So, later when we call into LS1, we need to make sure that it doesn't use + // it's source file any more, and instead defers to DocumentRegistry to get + // either version 1, version 2 (or some other version) depending on what the + // host says should be used. + return documentRegistry.updateDocument(fileName, newSettings, hostFileInformation.scriptSnapshot, hostFileInformation.version); + } + } + // Could not find this file in the old program, create a new SourceFile for it. + return documentRegistry.acquireDocument(fileName, newSettings, hostFileInformation.scriptSnapshot, hostFileInformation.version); + } + function sourceFileUpToDate(sourceFile) { + return sourceFile && sourceFile.version === hostCache.getVersion(sourceFile.fileName); + } + function programUpToDate() { + // If we haven't create a program yet, then it is not up-to-date + if (!program) { + return false; + } + // If number of files in the program do not match, it is not up-to-date + var rootFileNames = hostCache.getRootFileNames(); + if (program.getSourceFiles().length !== rootFileNames.length) { + return false; + } + // If any file is not up-to-date, then the whole program is not up-to-date + for (var _i = 0; _i < rootFileNames.length; _i++) { + var fileName = rootFileNames[_i]; + if (!sourceFileUpToDate(program.getSourceFile(fileName))) { + return false; + } + } + // If the compilation settings do no match, then the program is not up-to-date + return ts.compareDataObjects(program.getCompilerOptions(), hostCache.compilationSettings()); + } + } + function getProgram() { + synchronizeHostData(); + return program; + } + function cleanupSemanticCache() { + // TODO: Should we jettison the program (or it's type checker) here? + } + function dispose() { + if (program) { + ts.forEach(program.getSourceFiles(), function (f) { + return documentRegistry.releaseDocument(f.fileName, program.getCompilerOptions()); + }); + } + } + /// Diagnostics + function getSyntacticDiagnostics(fileName) { + synchronizeHostData(); + return program.getSyntacticDiagnostics(getValidSourceFile(fileName), cancellationToken); + } + /** + * getSemanticDiagnostiscs return array of Diagnostics. If '-d' is not enabled, only report semantic errors + * If '-d' enabled, report both semantic and emitter errors + */ + function getSemanticDiagnostics(fileName) { + synchronizeHostData(); + var targetSourceFile = getValidSourceFile(fileName); + // For JavaScript files, we don't want to report the normal typescript semantic errors. + // Instead, we just report errors for using TypeScript-only constructs from within a + // JavaScript file. + if (ts.isJavaScript(fileName)) { + return getJavaScriptSemanticDiagnostics(targetSourceFile); + } + // Only perform the action per file regardless of '-out' flag as LanguageServiceHost is expected to call this function per file. + // Therefore only get diagnostics for given file. + var semanticDiagnostics = program.getSemanticDiagnostics(targetSourceFile, cancellationToken); + if (!program.getCompilerOptions().declaration) { + return semanticDiagnostics; + } + // If '-d' is enabled, check for emitter error. One example of emitter error is export class implements non-export interface + var declarationDiagnostics = program.getDeclarationDiagnostics(targetSourceFile, cancellationToken); + return ts.concatenate(semanticDiagnostics, declarationDiagnostics); + } + function getJavaScriptSemanticDiagnostics(sourceFile) { + var diagnostics = []; + walk(sourceFile); + return diagnostics; + function walk(node) { + if (!node) { + return false; + } + switch (node.kind) { + case 221 /* ImportEqualsDeclaration */: + diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.import_can_only_be_used_in_a_ts_file)); + return true; + case 227 /* ExportAssignment */: + diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.export_can_only_be_used_in_a_ts_file)); + return true; + case 214 /* ClassDeclaration */: + var classDeclaration = node; + if (checkModifiers(classDeclaration.modifiers) || + checkTypeParameters(classDeclaration.typeParameters)) { + return true; + } + break; + case 243 /* HeritageClause */: + var heritageClause = node; + if (heritageClause.token === 106 /* ImplementsKeyword */) { + diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.implements_clauses_can_only_be_used_in_a_ts_file)); + return true; + } + break; + case 215 /* InterfaceDeclaration */: + diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.interface_declarations_can_only_be_used_in_a_ts_file)); + return true; + case 218 /* ModuleDeclaration */: + diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.module_declarations_can_only_be_used_in_a_ts_file)); + return true; + case 216 /* TypeAliasDeclaration */: + diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.type_aliases_can_only_be_used_in_a_ts_file)); + return true; + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: + case 144 /* Constructor */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: + case 173 /* FunctionExpression */: + case 213 /* FunctionDeclaration */: + case 174 /* ArrowFunction */: + case 213 /* FunctionDeclaration */: + var functionDeclaration = node; + if (checkModifiers(functionDeclaration.modifiers) || + checkTypeParameters(functionDeclaration.typeParameters) || + checkTypeAnnotation(functionDeclaration.type)) { + return true; + } + break; + case 193 /* VariableStatement */: + var variableStatement = node; + if (checkModifiers(variableStatement.modifiers)) { + return true; + } + break; + case 211 /* VariableDeclaration */: + var variableDeclaration = node; + if (checkTypeAnnotation(variableDeclaration.type)) { + return true; + } + break; + case 168 /* CallExpression */: + case 169 /* NewExpression */: + var expression = node; + if (expression.typeArguments && expression.typeArguments.length > 0) { + var start = expression.typeArguments.pos; + diagnostics.push(ts.createFileDiagnostic(sourceFile, start, expression.typeArguments.end - start, ts.Diagnostics.type_arguments_can_only_be_used_in_a_ts_file)); + return true; + } + break; + case 138 /* Parameter */: + var parameter = node; + if (parameter.modifiers) { + var start = parameter.modifiers.pos; + diagnostics.push(ts.createFileDiagnostic(sourceFile, start, parameter.modifiers.end - start, ts.Diagnostics.parameter_modifiers_can_only_be_used_in_a_ts_file)); + return true; + } + if (parameter.questionToken) { + diagnostics.push(ts.createDiagnosticForNode(parameter.questionToken, ts.Diagnostics._0_can_only_be_used_in_a_ts_file, '?')); + return true; + } + if (parameter.type) { + diagnostics.push(ts.createDiagnosticForNode(parameter.type, ts.Diagnostics.types_can_only_be_used_in_a_ts_file)); + return true; + } + break; + case 141 /* PropertyDeclaration */: + diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.property_declarations_can_only_be_used_in_a_ts_file)); + return true; + case 217 /* EnumDeclaration */: + diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.enum_declarations_can_only_be_used_in_a_ts_file)); + return true; + case 171 /* TypeAssertionExpression */: + var typeAssertionExpression = node; + diagnostics.push(ts.createDiagnosticForNode(typeAssertionExpression.type, ts.Diagnostics.type_assertion_expressions_can_only_be_used_in_a_ts_file)); + return true; + case 139 /* Decorator */: + diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.decorators_can_only_be_used_in_a_ts_file)); + return true; + } + return ts.forEachChild(node, walk); + } + function checkTypeParameters(typeParameters) { + if (typeParameters) { + var start = typeParameters.pos; + diagnostics.push(ts.createFileDiagnostic(sourceFile, start, typeParameters.end - start, ts.Diagnostics.type_parameter_declarations_can_only_be_used_in_a_ts_file)); + return true; + } + return false; + } + function checkTypeAnnotation(type) { + if (type) { + diagnostics.push(ts.createDiagnosticForNode(type, ts.Diagnostics.types_can_only_be_used_in_a_ts_file)); + return true; + } + return false; + } + function checkModifiers(modifiers) { + if (modifiers) { + for (var _i = 0; _i < modifiers.length; _i++) { + var modifier = modifiers[_i]; + switch (modifier.kind) { + case 112 /* PublicKeyword */: + case 110 /* PrivateKeyword */: + case 111 /* ProtectedKeyword */: + case 122 /* DeclareKeyword */: + diagnostics.push(ts.createDiagnosticForNode(modifier, ts.Diagnostics._0_can_only_be_used_in_a_ts_file, ts.tokenToString(modifier.kind))); + return true; + // These are all legal modifiers. + case 113 /* StaticKeyword */: + case 82 /* ExportKeyword */: + case 74 /* ConstKeyword */: + case 77 /* DefaultKeyword */: + case 115 /* AbstractKeyword */: + } + } + } + return false; + } + } + function getCompilerOptionsDiagnostics() { + synchronizeHostData(); + return program.getOptionsDiagnostics(cancellationToken).concat(program.getGlobalDiagnostics(cancellationToken)); + } + /** + * Get the name to be display in completion from a given symbol. + * + * @return undefined if the name is of external module otherwise a name with striped of any quote + */ + function getCompletionEntryDisplayNameForSymbol(symbol, target, performCharacterChecks, location) { + var displayName = ts.getDeclaredName(program.getTypeChecker(), symbol, location); + if (displayName) { + var firstCharCode = displayName.charCodeAt(0); + // First check of the displayName is not external module; if it is an external module, it is not valid entry + if ((symbol.flags & 1536 /* Namespace */) && (firstCharCode === 39 /* singleQuote */ || firstCharCode === 34 /* doubleQuote */)) { + // If the symbol is external module, don't show it in the completion list + // (i.e declare module "http" { let x; } | // <= request completion here, "http" should not be there) + return undefined; + } + } + return getCompletionEntryDisplayName(displayName, target, performCharacterChecks); + } + /** + * Get a displayName from a given for completion list, performing any necessary quotes stripping + * and checking whether the name is valid identifier name. + */ + function getCompletionEntryDisplayName(name, target, performCharacterChecks) { + if (!name) { + return undefined; + } + name = ts.stripQuotes(name); + if (!name) { + return undefined; + } + // If the user entered name for the symbol was quoted, removing the quotes is not enough, as the name could be an + // invalid identifier name. We need to check if whatever was inside the quotes is actually a valid identifier name. + // e.g "b a" is valid quoted name but when we strip off the quotes, it is invalid. + // We, thus, need to check if whatever was inside the quotes is actually a valid identifier name. + if (performCharacterChecks) { + if (!ts.isIdentifierStart(name.charCodeAt(0), target)) { + return undefined; + } + for (var i = 1, n = name.length; i < n; i++) { + if (!ts.isIdentifierPart(name.charCodeAt(i), target)) { + return undefined; + } + } + } + return name; + } + function getCompletionData(fileName, position) { + var typeChecker = program.getTypeChecker(); + var syntacticStart = new Date().getTime(); + var sourceFile = getValidSourceFile(fileName); + var isJavaScriptFile = ts.isJavaScript(fileName); + var isJsDocTagName = false; + var start = new Date().getTime(); + var currentToken = ts.getTokenAtPosition(sourceFile, position); + log("getCompletionData: Get current token: " + (new Date().getTime() - start)); + start = new Date().getTime(); + // Completion not allowed inside comments, bail out if this is the case + var insideComment = isInsideComment(sourceFile, currentToken, position); + log("getCompletionData: Is inside comment: " + (new Date().getTime() - start)); + if (insideComment) { + // The current position is next to the '@' sign, when no tag name being provided yet. + // Provide a full list of tag names + if (ts.hasDocComment(sourceFile, position) && sourceFile.text.charCodeAt(position - 1) === 64 /* at */) { + isJsDocTagName = true; + } + // Completion should work inside certain JsDoc tags. For example: + // /** @type {number | string} */ + // Completion should work in the brackets + var insideJsDocTagExpression = false; + var tag = ts.getJsDocTagAtPosition(sourceFile, position); + if (tag) { + if (tag.tagName.pos <= position && position <= tag.tagName.end) { + isJsDocTagName = true; + } + switch (tag.kind) { + case 269 /* JSDocTypeTag */: + case 267 /* JSDocParameterTag */: + case 268 /* JSDocReturnTag */: + var tagWithExpression = tag; + if (tagWithExpression.typeExpression) { + insideJsDocTagExpression = tagWithExpression.typeExpression.pos < position && position < tagWithExpression.typeExpression.end; + } + break; + } + } + if (isJsDocTagName) { + return { symbols: undefined, 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 + // comment or the plain text part of a jsDoc comment, so no completion should be available + log("Returning an empty list because completion was inside a regular comment or plain text part of a JsDoc comment."); + return undefined; + } + } + start = new Date().getTime(); + var previousToken = ts.findPrecedingToken(position, sourceFile); + log("getCompletionData: Get previous token 1: " + (new Date().getTime() - start)); + // The decision to provide completion depends on the contextToken, which is determined through the previousToken. + // Note: 'previousToken' (and thus 'contextToken') can be undefined if we are the beginning of the file + var contextToken = previousToken; + // Check if the caret is at the end of an identifier; this is a partial identifier that we want to complete: e.g. a.toS| + // Skip this partial identifier and adjust the contextToken to the token that precedes it. + if (contextToken && position <= contextToken.end && ts.isWord(contextToken.kind)) { + var start_3 = new Date().getTime(); + contextToken = ts.findPrecedingToken(contextToken.getFullStart(), sourceFile); + log("getCompletionData: Get previous token 2: " + (new Date().getTime() - start_3)); + } + // Find the node where completion is requested on. + // Also determine whether we are trying to complete with members of that node + // or attributes of a JSX tag. + var node = currentToken; + var isRightOfDot = false; + var isRightOfOpenTag = false; + var isStartingCloseTag = false; + var location = ts.getTouchingPropertyName(sourceFile, position); + if (contextToken) { + // Bail out if this is a known invalid completion location + if (isCompletionListBlocker(contextToken)) { + log("Returning an empty list because completion was requested in an invalid position."); + return undefined; + } + var parent_9 = contextToken.parent, kind = contextToken.kind; + if (kind === 21 /* DotToken */) { + if (parent_9.kind === 166 /* PropertyAccessExpression */) { + node = contextToken.parent.expression; + isRightOfDot = true; + } + else if (parent_9.kind === 135 /* QualifiedName */) { + node = contextToken.parent.left; + isRightOfDot = true; + } + else { + // There is nothing that precedes the dot, so this likely just a stray character + // or leading into a '...' token. Just bail out instead. + return undefined; + } + } + else if (sourceFile.languageVariant === 1 /* JSX */) { + if (kind === 25 /* LessThanToken */) { + isRightOfOpenTag = true; + location = contextToken; + } + else if (kind === 39 /* SlashToken */ && contextToken.parent.kind === 237 /* JsxClosingElement */) { + isStartingCloseTag = true; + } + } + } + var semanticStart = new Date().getTime(); + var isMemberCompletion; + var isNewIdentifierLocation; + var symbols = []; + if (isRightOfDot) { + getTypeScriptMemberSymbols(); + } + else if (isRightOfOpenTag) { + var tagSymbols = typeChecker.getJsxIntrinsicTagNames(); + if (tryGetGlobalSymbols()) { + symbols = tagSymbols.concat(symbols.filter(function (s) { return !!(s.flags & 107455 /* Value */); })); + } + else { + symbols = tagSymbols; + } + isMemberCompletion = true; + isNewIdentifierLocation = false; + } + else if (isStartingCloseTag) { + var tagName = contextToken.parent.parent.openingElement.tagName; + symbols = [typeChecker.getSymbolAtLocation(tagName)]; + isMemberCompletion = true; + isNewIdentifierLocation = false; + } + else { + // For JavaScript or TypeScript, if we're not after a dot, then just try to get the + // global symbols in scope. These results should be valid for either language as + // the set of symbols that can be referenced from this location. + if (!tryGetGlobalSymbols()) { + return undefined; + } + } + log("getCompletionData: Semantic work: " + (new Date().getTime() - semanticStart)); + return { symbols: symbols, isMemberCompletion: isMemberCompletion, isNewIdentifierLocation: isNewIdentifierLocation, location: location, isRightOfDot: (isRightOfDot || isRightOfOpenTag), isJsDocTagName: isJsDocTagName }; + function getTypeScriptMemberSymbols() { + // Right of dot member completion list + isMemberCompletion = true; + isNewIdentifierLocation = false; + if (node.kind === 69 /* Identifier */ || node.kind === 135 /* QualifiedName */ || node.kind === 166 /* PropertyAccessExpression */) { + var symbol = typeChecker.getSymbolAtLocation(node); + // This is an alias, follow what it aliases + if (symbol && symbol.flags & 8388608 /* Alias */) { + symbol = typeChecker.getAliasedSymbol(symbol); + } + if (symbol && symbol.flags & 1952 /* HasExports */) { + // Extract module or enum members + var exportedSymbols = typeChecker.getExportsOfModule(symbol); + ts.forEach(exportedSymbols, function (symbol) { + if (typeChecker.isValidPropertyAccess((node.parent), symbol.name)) { + symbols.push(symbol); + } + }); + } + } + var type = typeChecker.getTypeAtLocation(node); + addTypeProperties(type); + } + function addTypeProperties(type) { + if (type) { + // Filter private properties + for (var _i = 0, _a = type.getApparentProperties(); _i < _a.length; _i++) { + var symbol = _a[_i]; + if (typeChecker.isValidPropertyAccess((node.parent), symbol.name)) { + symbols.push(symbol); + } + } + if (isJavaScriptFile && type.flags & 16384 /* Union */) { + // In javascript files, for union types, we don't just get the members that + // the individual types have in common, we also include all the members that + // each individual type has. This is because we're going to add all identifiers + // anyways. So we might as well elevate the members that were at least part + // of the individual types to a higher status since we know what they are. + var unionType = type; + for (var _b = 0, _c = unionType.types; _b < _c.length; _b++) { + var elementType = _c[_b]; + addTypeProperties(elementType); + } + } + } + } + function tryGetGlobalSymbols() { + var objectLikeContainer; + var namedImportsOrExports; + var jsxContainer; + if (objectLikeContainer = tryGetObjectLikeCompletionContainer(contextToken)) { + return tryGetObjectLikeCompletionSymbols(objectLikeContainer); + } + if (namedImportsOrExports = tryGetNamedImportsOrExportsForCompletion(contextToken)) { + // cursor is in an import clause + // try to show exported member for imported module + return tryGetImportOrExportClauseCompletionSymbols(namedImportsOrExports); + } + if (jsxContainer = tryGetContainingJsxElement(contextToken)) { + var attrsType; + if ((jsxContainer.kind === 234 /* JsxSelfClosingElement */) || (jsxContainer.kind === 235 /* JsxOpeningElement */)) { + // Cursor is inside a JSX self-closing element or opening element + attrsType = typeChecker.getJsxElementAttributesType(jsxContainer); + if (attrsType) { + symbols = filterJsxAttributes(typeChecker.getPropertiesOfType(attrsType), jsxContainer.attributes); + isMemberCompletion = true; + isNewIdentifierLocation = false; + return true; + } + } + } + // Get all entities in the current scope. + isMemberCompletion = false; + isNewIdentifierLocation = isNewIdentifierDefinitionLocation(contextToken); + if (previousToken !== contextToken) { + ts.Debug.assert(!!previousToken, "Expected 'contextToken' to be defined when different from 'previousToken'."); + } + // We need to find the node that will give us an appropriate scope to begin + // aggregating completion candidates. This is achieved in 'getScopeNode' + // by finding the first node that encompasses a position, accounting for whether a node + // is "complete" to decide whether a position belongs to the node. + // + // However, at the end of an identifier, we are interested in the scope of the identifier + // itself, but fall outside of the identifier. For instance: + // + // xyz => x$ + // + // the cursor is outside of both the 'x' and the arrow function 'xyz => x', + // so 'xyz' is not returned in our results. + // + // We define 'adjustedPosition' so that we may appropriately account for + // being at the end of an identifier. The intention is that if requesting completion + // at the end of an identifier, it should be effectively equivalent to requesting completion + // anywhere inside/at the beginning of the identifier. So in the previous case, the + // 'adjustedPosition' will work as if requesting completion in the following: + // + // xyz => $x + // + // If previousToken !== contextToken, then + // - 'contextToken' was adjusted to the token prior to 'previousToken' + // because we were at the end of an identifier. + // - 'previousToken' is defined. + var adjustedPosition = previousToken !== contextToken ? + previousToken.getStart() : + position; + var scopeNode = getScopeNode(contextToken, adjustedPosition, sourceFile) || sourceFile; + /// TODO filter meaning based on the current context + var symbolMeanings = 793056 /* Type */ | 107455 /* Value */ | 1536 /* Namespace */ | 8388608 /* Alias */; + symbols = typeChecker.getSymbolsInScope(scopeNode, symbolMeanings); + return true; + } + /** + * Finds the first node that "embraces" the position, so that one may + * accurately aggregate locals from the closest containing scope. + */ + function getScopeNode(initialToken, position, sourceFile) { + var scope = initialToken; + while (scope && !ts.positionBelongsToNode(scope, position, sourceFile)) { + scope = scope.parent; + } + return scope; + } + function isCompletionListBlocker(contextToken) { + var start = new Date().getTime(); + var result = isInStringOrRegularExpressionOrTemplateLiteral(contextToken) || + isSolelyIdentifierDefinitionLocation(contextToken) || + isDotOfNumericLiteral(contextToken) || + isInJsxText(contextToken); + log("getCompletionsAtPosition: isCompletionListBlocker: " + (new Date().getTime() - start)); + return result; + } + function isInJsxText(contextToken) { + if (contextToken.kind === 236 /* JsxText */) { + return true; + } + if (contextToken.kind === 27 /* GreaterThanToken */ && contextToken.parent) { + if (contextToken.parent.kind === 235 /* JsxOpeningElement */) { + return true; + } + if (contextToken.parent.kind === 237 /* JsxClosingElement */ || contextToken.parent.kind === 234 /* JsxSelfClosingElement */) { + return contextToken.parent.parent && contextToken.parent.parent.kind === 233 /* JsxElement */; + } + } + return false; + } + function isNewIdentifierDefinitionLocation(previousToken) { + if (previousToken) { + var containingNodeKind = previousToken.parent.kind; + switch (previousToken.kind) { + case 24 /* CommaToken */: + return containingNodeKind === 168 /* CallExpression */ // func( a, | + || containingNodeKind === 144 /* Constructor */ // constructor( a, | /* public, protected, private keywords are allowed here, so show completion */ + || containingNodeKind === 169 /* NewExpression */ // new C(a, | + || containingNodeKind === 164 /* ArrayLiteralExpression */ // [a, | + || containingNodeKind === 181 /* BinaryExpression */ // let x = (a, | + || containingNodeKind === 152 /* FunctionType */; // var x: (s: string, list| + case 17 /* OpenParenToken */: + return containingNodeKind === 168 /* CallExpression */ // func( | + || containingNodeKind === 144 /* Constructor */ // constructor( | + || containingNodeKind === 169 /* NewExpression */ // new C(a| + || containingNodeKind === 172 /* ParenthesizedExpression */ // let x = (a| + || containingNodeKind === 160 /* ParenthesizedType */; // function F(pred: (a| /* this can become an arrow function, where 'a' is the argument */ + case 19 /* OpenBracketToken */: + return containingNodeKind === 164 /* ArrayLiteralExpression */ // [ | + || containingNodeKind === 149 /* IndexSignature */ // [ | : string ] + || containingNodeKind === 136 /* ComputedPropertyName */; // [ | /* this can become an index signature */ + case 125 /* ModuleKeyword */: // module | + case 126 /* NamespaceKeyword */: + return true; + case 21 /* DotToken */: + return containingNodeKind === 218 /* ModuleDeclaration */; // module A.| + case 15 /* OpenBraceToken */: + return containingNodeKind === 214 /* ClassDeclaration */; // class A{ | + case 56 /* EqualsToken */: + return containingNodeKind === 211 /* VariableDeclaration */ // let x = a| + || containingNodeKind === 181 /* BinaryExpression */; // x = a| + case 12 /* TemplateHead */: + return containingNodeKind === 183 /* TemplateExpression */; // `aa ${| + case 13 /* TemplateMiddle */: + return containingNodeKind === 190 /* TemplateSpan */; // `aa ${10} dd ${| + case 112 /* PublicKeyword */: + case 110 /* PrivateKeyword */: + case 111 /* ProtectedKeyword */: + return containingNodeKind === 141 /* PropertyDeclaration */; // class A{ public | + } + // Previous token may have been a keyword that was converted to an identifier. + switch (previousToken.getText()) { + case "public": + case "protected": + case "private": + return true; + } + } + return false; + } + function isInStringOrRegularExpressionOrTemplateLiteral(contextToken) { + if (contextToken.kind === 9 /* StringLiteral */ + || contextToken.kind === 10 /* RegularExpressionLiteral */ + || ts.isTemplateLiteralKind(contextToken.kind)) { + var start_4 = contextToken.getStart(); + var end = contextToken.getEnd(); + // To be "in" one of these literals, the position has to be: + // 1. entirely within the token text. + // 2. at the end position of an unterminated token. + // 3. at the end of a regular expression (due to trailing flags like '/foo/g'). + if (start_4 < position && position < end) { + return true; + } + if (position === end) { + return !!contextToken.isUnterminated + || contextToken.kind === 10 /* RegularExpressionLiteral */; + } + } + return false; + } + /** + * Aggregates relevant symbols for completion in object literals and object binding patterns. + * Relevant symbols are stored in the captured 'symbols' variable. + * + * @returns true if 'symbols' was successfully populated; false otherwise. + */ + function tryGetObjectLikeCompletionSymbols(objectLikeContainer) { + // We're looking up possible property names from contextual/inferred/declared type. + isMemberCompletion = true; + var typeForObject; + var existingMembers; + if (objectLikeContainer.kind === 165 /* ObjectLiteralExpression */) { + // We are completing on contextual types, but may also include properties + // other than those within the declared type. + isNewIdentifierLocation = true; + typeForObject = typeChecker.getContextualType(objectLikeContainer); + existingMembers = objectLikeContainer.properties; + } + else if (objectLikeContainer.kind === 161 /* ObjectBindingPattern */) { + // We are *only* completing on properties from the type being destructured. + isNewIdentifierLocation = false; + var rootDeclaration = ts.getRootDeclaration(objectLikeContainer.parent); + if (ts.isVariableLike(rootDeclaration)) { + // We don't want to complete using the type acquired by the shape + // of the binding pattern; we are only interested in types acquired + // through type declaration or inference. + if (rootDeclaration.initializer || rootDeclaration.type) { + typeForObject = typeChecker.getTypeAtLocation(objectLikeContainer); + existingMembers = objectLikeContainer.elements; + } + } + else { + ts.Debug.fail("Root declaration is not variable-like."); + } + } + else { + ts.Debug.fail("Expected object literal or binding pattern, got " + objectLikeContainer.kind); + } + if (!typeForObject) { + return false; + } + var typeMembers = typeChecker.getPropertiesOfType(typeForObject); + if (typeMembers && typeMembers.length > 0) { + // Add filtered items to the completion list + symbols = filterObjectMembersList(typeMembers, existingMembers); + } + return true; + } + /** + * Aggregates relevant symbols for completion in import clauses and export clauses + * whose declarations have a module specifier; for instance, symbols will be aggregated for + * + * import { | } from "moduleName"; + * export { a as foo, | } from "moduleName"; + * + * but not for + * + * export { | }; + * + * Relevant symbols are stored in the captured 'symbols' variable. + * + * @returns true if 'symbols' was successfully populated; false otherwise. + */ + function tryGetImportOrExportClauseCompletionSymbols(namedImportsOrExports) { + var declarationKind = namedImportsOrExports.kind === 225 /* NamedImports */ ? + 222 /* ImportDeclaration */ : + 228 /* ExportDeclaration */; + var importOrExportDeclaration = ts.getAncestor(namedImportsOrExports, declarationKind); + var moduleSpecifier = importOrExportDeclaration.moduleSpecifier; + if (!moduleSpecifier) { + return false; + } + isMemberCompletion = true; + isNewIdentifierLocation = false; + var exports; + var moduleSpecifierSymbol = typeChecker.getSymbolAtLocation(importOrExportDeclaration.moduleSpecifier); + if (moduleSpecifierSymbol) { + exports = typeChecker.getExportsOfModule(moduleSpecifierSymbol); + } + symbols = exports ? filterNamedImportOrExportCompletionItems(exports, namedImportsOrExports.elements) : emptyArray; + return true; + } + /** + * Returns the immediate owning object literal or binding pattern of a context token, + * on the condition that one exists and that the context implies completion should be given. + */ + function tryGetObjectLikeCompletionContainer(contextToken) { + if (contextToken) { + switch (contextToken.kind) { + case 15 /* OpenBraceToken */: // let x = { | + case 24 /* CommaToken */: + var parent_10 = contextToken.parent; + if (parent_10 && (parent_10.kind === 165 /* ObjectLiteralExpression */ || parent_10.kind === 161 /* ObjectBindingPattern */)) { + return parent_10; + } + break; + } + } + return undefined; + } + /** + * Returns the containing list of named imports or exports of a context token, + * on the condition that one exists and that the context implies completion should be given. + */ + function tryGetNamedImportsOrExportsForCompletion(contextToken) { + if (contextToken) { + switch (contextToken.kind) { + case 15 /* OpenBraceToken */: // import { | + case 24 /* CommaToken */: + switch (contextToken.parent.kind) { + case 225 /* NamedImports */: + case 229 /* NamedExports */: + return contextToken.parent; + } + } + } + return undefined; + } + function tryGetContainingJsxElement(contextToken) { + if (contextToken) { + var parent_11 = contextToken.parent; + switch (contextToken.kind) { + case 26 /* LessThanSlashToken */: + case 39 /* SlashToken */: + case 69 /* Identifier */: + case 238 /* JsxAttribute */: + case 239 /* JsxSpreadAttribute */: + if (parent_11 && (parent_11.kind === 234 /* JsxSelfClosingElement */ || parent_11.kind === 235 /* JsxOpeningElement */)) { + return parent_11; + } + else if (parent_11.kind === 238 /* JsxAttribute */) { + return parent_11.parent; + } + break; + // The context token is the closing } or " of an attribute, which means + // its parent is a JsxExpression, whose parent is a JsxAttribute, + // whose parent is a JsxOpeningLikeElement + case 9 /* StringLiteral */: + if (parent_11 && ((parent_11.kind === 238 /* JsxAttribute */) || (parent_11.kind === 239 /* JsxSpreadAttribute */))) { + return parent_11.parent; + } + break; + case 16 /* CloseBraceToken */: + if (parent_11 && + parent_11.kind === 240 /* JsxExpression */ && + parent_11.parent && + (parent_11.parent.kind === 238 /* JsxAttribute */)) { + return parent_11.parent.parent; + } + if (parent_11 && parent_11.kind === 239 /* JsxSpreadAttribute */) { + return parent_11.parent; + } + break; + } + } + return undefined; + } + function isFunction(kind) { + switch (kind) { + case 173 /* FunctionExpression */: + case 174 /* ArrowFunction */: + case 213 /* FunctionDeclaration */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: + case 147 /* CallSignature */: + case 148 /* ConstructSignature */: + case 149 /* IndexSignature */: + return true; + } + return false; + } + /** + * @returns true if we are certain that the currently edited location must define a new location; false otherwise. + */ + function isSolelyIdentifierDefinitionLocation(contextToken) { + var containingNodeKind = contextToken.parent.kind; + switch (contextToken.kind) { + case 24 /* CommaToken */: + return containingNodeKind === 211 /* VariableDeclaration */ || + containingNodeKind === 212 /* VariableDeclarationList */ || + containingNodeKind === 193 /* VariableStatement */ || + containingNodeKind === 217 /* EnumDeclaration */ || + isFunction(containingNodeKind) || + containingNodeKind === 214 /* ClassDeclaration */ || + containingNodeKind === 186 /* ClassExpression */ || + containingNodeKind === 215 /* InterfaceDeclaration */ || + containingNodeKind === 162 /* ArrayBindingPattern */ || + containingNodeKind === 216 /* TypeAliasDeclaration */; // type Map, K, | + case 21 /* DotToken */: + return containingNodeKind === 162 /* ArrayBindingPattern */; // var [.| + case 54 /* ColonToken */: + return containingNodeKind === 163 /* BindingElement */; // var {x :html| + case 19 /* OpenBracketToken */: + return containingNodeKind === 162 /* ArrayBindingPattern */; // var [x| + case 17 /* OpenParenToken */: + return containingNodeKind === 244 /* CatchClause */ || + isFunction(containingNodeKind); + case 15 /* OpenBraceToken */: + return containingNodeKind === 217 /* EnumDeclaration */ || + containingNodeKind === 215 /* InterfaceDeclaration */ || + containingNodeKind === 155 /* TypeLiteral */; // let x : { | + case 23 /* SemicolonToken */: + return containingNodeKind === 140 /* PropertySignature */ && + contextToken.parent && contextToken.parent.parent && + (contextToken.parent.parent.kind === 215 /* InterfaceDeclaration */ || + contextToken.parent.parent.kind === 155 /* TypeLiteral */); // let x : { a; | + case 25 /* LessThanToken */: + return containingNodeKind === 214 /* ClassDeclaration */ || + containingNodeKind === 186 /* ClassExpression */ || + containingNodeKind === 215 /* InterfaceDeclaration */ || + containingNodeKind === 216 /* TypeAliasDeclaration */ || + isFunction(containingNodeKind); + case 113 /* StaticKeyword */: + return containingNodeKind === 141 /* PropertyDeclaration */; + case 22 /* DotDotDotToken */: + return containingNodeKind === 138 /* Parameter */ || + (contextToken.parent && contextToken.parent.parent && + contextToken.parent.parent.kind === 162 /* ArrayBindingPattern */); // var [...z| + case 112 /* PublicKeyword */: + case 110 /* PrivateKeyword */: + case 111 /* ProtectedKeyword */: + return containingNodeKind === 138 /* Parameter */; + case 116 /* AsKeyword */: + return containingNodeKind === 226 /* ImportSpecifier */ || + containingNodeKind === 230 /* ExportSpecifier */ || + containingNodeKind === 224 /* NamespaceImport */; + case 73 /* ClassKeyword */: + case 81 /* EnumKeyword */: + case 107 /* InterfaceKeyword */: + case 87 /* FunctionKeyword */: + case 102 /* VarKeyword */: + case 123 /* GetKeyword */: + case 129 /* SetKeyword */: + case 89 /* ImportKeyword */: + case 108 /* LetKeyword */: + case 74 /* ConstKeyword */: + case 114 /* YieldKeyword */: + case 132 /* TypeKeyword */: + return true; + } + // Previous token may have been a keyword that was converted to an identifier. + switch (contextToken.getText()) { + case "abstract": + case "async": + case "class": + case "const": + case "declare": + case "enum": + case "function": + case "interface": + case "let": + case "private": + case "protected": + case "public": + case "static": + case "var": + case "yield": + return true; + } + return false; + } + function isDotOfNumericLiteral(contextToken) { + if (contextToken.kind === 8 /* NumericLiteral */) { + var text = contextToken.getFullText(); + return text.charAt(text.length - 1) === "."; + } + return false; + } + /** + * Filters out completion suggestions for named imports or exports. + * + * @param exportsOfModule The list of symbols which a module exposes. + * @param namedImportsOrExports The list of existing import/export specifiers in the import/export clause. + * + * @returns Symbols to be suggested at an import/export clause, barring those whose named imports/exports + * do not occur at the current position and have not otherwise been typed. + */ + function filterNamedImportOrExportCompletionItems(exportsOfModule, namedImportsOrExports) { + var exisingImportsOrExports = {}; + for (var _i = 0; _i < namedImportsOrExports.length; _i++) { + var element = namedImportsOrExports[_i]; + // If this is the current item we are editing right now, do not filter it out + if (element.getStart() <= position && position <= element.getEnd()) { + continue; + } + var name_33 = element.propertyName || element.name; + exisingImportsOrExports[name_33.text] = true; + } + if (ts.isEmpty(exisingImportsOrExports)) { + return exportsOfModule; + } + return ts.filter(exportsOfModule, function (e) { return !ts.lookUp(exisingImportsOrExports, e.name); }); + } + /** + * Filters out completion suggestions for named imports or exports. + * + * @returns Symbols to be suggested in an object binding pattern or object literal expression, barring those whose declarations + * do not occur at the current position and have not otherwise been typed. + */ + function filterObjectMembersList(contextualMemberSymbols, existingMembers) { + if (!existingMembers || existingMembers.length === 0) { + return contextualMemberSymbols; + } + var existingMemberNames = {}; + for (var _i = 0; _i < existingMembers.length; _i++) { + var m = existingMembers[_i]; + // Ignore omitted expressions for missing members + if (m.kind !== 245 /* PropertyAssignment */ && + m.kind !== 246 /* ShorthandPropertyAssignment */ && + m.kind !== 163 /* BindingElement */) { + continue; + } + // If this is the current item we are editing right now, do not filter it out + if (m.getStart() <= position && position <= m.getEnd()) { + continue; + } + var existingName = void 0; + if (m.kind === 163 /* BindingElement */ && m.propertyName) { + existingName = m.propertyName.text; + } + else { + // TODO(jfreeman): Account for computed property name + // NOTE: if one only performs this step when m.name is an identifier, + // things like '__proto__' are not filtered out. + existingName = m.name.text; + } + existingMemberNames[existingName] = true; + } + return ts.filter(contextualMemberSymbols, function (m) { return !ts.lookUp(existingMemberNames, m.name); }); + } + /** + * Filters out completion suggestions from 'symbols' according to existing JSX attributes. + * + * @returns Symbols to be suggested in a JSX element, barring those whose attributes + * do not occur at the current position and have not otherwise been typed. + */ + function filterJsxAttributes(symbols, attributes) { + var seenNames = {}; + for (var _i = 0; _i < attributes.length; _i++) { + var attr = attributes[_i]; + // If this is the current item we are editing right now, do not filter it out + if (attr.getStart() <= position && position <= attr.getEnd()) { + continue; + } + if (attr.kind === 238 /* JsxAttribute */) { + seenNames[attr.name.text] = true; + } + } + return ts.filter(symbols, function (a) { return !ts.lookUp(seenNames, a.name); }); + } + } + function getCompletionsAtPosition(fileName, position) { + synchronizeHostData(); + var completionData = getCompletionData(fileName, position); + if (!completionData) { + return undefined; + } + var symbols = completionData.symbols, isMemberCompletion = completionData.isMemberCompletion, isNewIdentifierLocation = completionData.isNewIdentifierLocation, location = completionData.location, isRightOfDot = completionData.isRightOfDot, isJsDocTagName = completionData.isJsDocTagName; + var entries; + if (isJsDocTagName) { + // If the current position is a jsDoc tag name, only tag names should be provided for completion + return { isMemberCompletion: false, isNewIdentifierLocation: false, entries: getAllJsDocCompletionEntries() }; + } + if (isRightOfDot && ts.isJavaScript(fileName)) { + entries = getCompletionEntriesFromSymbols(symbols); + ts.addRange(entries, getJavaScriptCompletionEntries()); + } + else { + if (!symbols || symbols.length === 0) { + return undefined; + } + entries = getCompletionEntriesFromSymbols(symbols); + } + // Add keywords if this is not a member completion list + if (!isMemberCompletion && !isJsDocTagName) { + ts.addRange(entries, keywordCompletions); + } + return { isMemberCompletion: isMemberCompletion, isNewIdentifierLocation: isNewIdentifierLocation, entries: entries }; + function getJavaScriptCompletionEntries() { + var entries = []; + var allNames = {}; + var target = program.getCompilerOptions().target; + for (var _i = 0, _a = program.getSourceFiles(); _i < _a.length; _i++) { + var sourceFile = _a[_i]; + var nameTable = getNameTable(sourceFile); + for (var name_34 in nameTable) { + if (!allNames[name_34]) { + allNames[name_34] = name_34; + var displayName = getCompletionEntryDisplayName(name_34, target, /*performCharacterChecks:*/ true); + if (displayName) { + var entry = { + name: displayName, + kind: ScriptElementKind.warning, + kindModifiers: "", + sortText: "1" + }; + entries.push(entry); + } + } + } + } + return entries; + } + function getAllJsDocCompletionEntries() { + return jsDocCompletionEntries || (jsDocCompletionEntries = ts.map(jsDocTagNames, function (tagName) { + return { + name: tagName, + kind: ScriptElementKind.keyword, + kindModifiers: "", + sortText: "0" + }; + })); + } + function createCompletionEntry(symbol, location) { + // Try to get a valid display name for this symbol, if we could not find one, then ignore it. + // We would like to only show things that can be added after a dot, so for instance numeric properties can + // not be accessed with a dot (a.1 <- invalid) + var displayName = getCompletionEntryDisplayNameForSymbol(symbol, program.getCompilerOptions().target, /*performCharacterChecks:*/ true, location); + if (!displayName) { + return undefined; + } + // TODO(drosen): Right now we just permit *all* semantic meanings when calling + // 'getSymbolKind' which is permissible given that it is backwards compatible; but + // really we should consider passing the meaning for the node so that we don't report + // that a suggestion for a value is an interface. We COULD also just do what + // 'getSymbolModifiers' does, which is to use the first declaration. + // Use a 'sortText' of 0' so that all symbol completion entries come before any other + // entries (like JavaScript identifier entries). + return { + name: displayName, + kind: getSymbolKind(symbol, location), + kindModifiers: getSymbolModifiers(symbol), + sortText: "0" + }; + } + function getCompletionEntriesFromSymbols(symbols) { + var start = new Date().getTime(); + var entries = []; + if (symbols) { + var nameToSymbol = {}; + for (var _i = 0; _i < symbols.length; _i++) { + var symbol = symbols[_i]; + var entry = createCompletionEntry(symbol, location); + if (entry) { + var id = ts.escapeIdentifier(entry.name); + if (!ts.lookUp(nameToSymbol, id)) { + entries.push(entry); + nameToSymbol[id] = symbol; + } + } + } + } + log("getCompletionsAtPosition: getCompletionEntriesFromSymbols: " + (new Date().getTime() - start)); + return entries; + } + } + function getCompletionEntryDetails(fileName, position, entryName) { + synchronizeHostData(); + // Compute all the completion symbols again. + var completionData = getCompletionData(fileName, position); + if (completionData) { + var symbols = completionData.symbols, location_2 = completionData.location; + // Find the symbol with the matching entry name. + var target = program.getCompilerOptions().target; + // We don't need to perform character checks here because we're only comparing the + // name against 'entryName' (which is known to be good), not building a new + // completion entry. + var symbol = ts.forEach(symbols, function (s) { return getCompletionEntryDisplayNameForSymbol(s, target, /*performCharacterChecks:*/ false, location_2) === entryName ? s : undefined; }); + if (symbol) { + var _a = getSymbolDisplayPartsDocumentationAndSymbolKind(symbol, getValidSourceFile(fileName), location_2, location_2, 7 /* All */), displayParts = _a.displayParts, documentation = _a.documentation, symbolKind = _a.symbolKind; + return { + name: entryName, + kindModifiers: getSymbolModifiers(symbol), + kind: symbolKind, + displayParts: displayParts, + documentation: documentation + }; + } + } + // Didn't find a symbol with this name. See if we can find a keyword instead. + var keywordCompletion = ts.forEach(keywordCompletions, function (c) { return c.name === entryName; }); + if (keywordCompletion) { + return { + name: entryName, + kind: ScriptElementKind.keyword, + kindModifiers: ScriptElementKindModifier.none, + displayParts: [ts.displayPart(entryName, SymbolDisplayPartKind.keyword)], + documentation: undefined + }; + } + return undefined; + } + // TODO(drosen): use contextual SemanticMeaning. + function getSymbolKind(symbol, location) { + var flags = symbol.getFlags(); + if (flags & 32 /* Class */) + return ts.getDeclarationOfKind(symbol, 186 /* ClassExpression */) ? + ScriptElementKind.localClassElement : ScriptElementKind.classElement; + if (flags & 384 /* Enum */) + return ScriptElementKind.enumElement; + if (flags & 524288 /* TypeAlias */) + return ScriptElementKind.typeElement; + if (flags & 64 /* Interface */) + return ScriptElementKind.interfaceElement; + if (flags & 262144 /* TypeParameter */) + return ScriptElementKind.typeParameterElement; + var result = getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar(symbol, flags, location); + if (result === ScriptElementKind.unknown) { + if (flags & 262144 /* TypeParameter */) + return ScriptElementKind.typeParameterElement; + if (flags & 8 /* EnumMember */) + return ScriptElementKind.variableElement; + if (flags & 8388608 /* Alias */) + return ScriptElementKind.alias; + if (flags & 1536 /* Module */) + return ScriptElementKind.moduleElement; + } + return result; + } + function getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar(symbol, flags, location) { + var typeChecker = program.getTypeChecker(); + if (typeChecker.isUndefinedSymbol(symbol)) { + return ScriptElementKind.variableElement; + } + if (typeChecker.isArgumentsSymbol(symbol)) { + return ScriptElementKind.localVariableElement; + } + if (flags & 3 /* Variable */) { + if (ts.isFirstDeclarationOfSymbolParameter(symbol)) { + return ScriptElementKind.parameterElement; + } + else if (symbol.valueDeclaration && ts.isConst(symbol.valueDeclaration)) { + return ScriptElementKind.constElement; + } + else if (ts.forEach(symbol.declarations, ts.isLet)) { + return ScriptElementKind.letElement; + } + return isLocalVariableOrFunction(symbol) ? ScriptElementKind.localVariableElement : ScriptElementKind.variableElement; + } + if (flags & 16 /* Function */) + return isLocalVariableOrFunction(symbol) ? ScriptElementKind.localFunctionElement : ScriptElementKind.functionElement; + if (flags & 32768 /* GetAccessor */) + return ScriptElementKind.memberGetAccessorElement; + if (flags & 65536 /* SetAccessor */) + return ScriptElementKind.memberSetAccessorElement; + if (flags & 8192 /* Method */) + return ScriptElementKind.memberFunctionElement; + if (flags & 16384 /* Constructor */) + return ScriptElementKind.constructorImplementationElement; + if (flags & 4 /* Property */) { + if (flags & 268435456 /* SyntheticProperty */) { + // If union property is result of union of non method (property/accessors/variables), it is labeled as property + var unionPropertyKind = ts.forEach(typeChecker.getRootSymbols(symbol), function (rootSymbol) { + var rootSymbolFlags = rootSymbol.getFlags(); + if (rootSymbolFlags & (98308 /* PropertyOrAccessor */ | 3 /* Variable */)) { + return ScriptElementKind.memberVariableElement; + } + ts.Debug.assert(!!(rootSymbolFlags & 8192 /* Method */)); + }); + if (!unionPropertyKind) { + // If this was union of all methods, + //make sure it has call signatures before we can label it as method + var typeOfUnionProperty = typeChecker.getTypeOfSymbolAtLocation(symbol, location); + if (typeOfUnionProperty.getCallSignatures().length) { + return ScriptElementKind.memberFunctionElement; + } + return ScriptElementKind.memberVariableElement; + } + return unionPropertyKind; + } + return ScriptElementKind.memberVariableElement; + } + return ScriptElementKind.unknown; + } + function getSymbolModifiers(symbol) { + return symbol && symbol.declarations && symbol.declarations.length > 0 + ? ts.getNodeModifiers(symbol.declarations[0]) + : ScriptElementKindModifier.none; + } + // TODO(drosen): Currently completion entry details passes the SemanticMeaning.All instead of using semanticMeaning of location + function getSymbolDisplayPartsDocumentationAndSymbolKind(symbol, sourceFile, enclosingDeclaration, location, semanticMeaning) { + if (semanticMeaning === void 0) { semanticMeaning = getMeaningFromLocation(location); } + var typeChecker = program.getTypeChecker(); + var displayParts = []; + var documentation; + var symbolFlags = symbol.flags; + var symbolKind = getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar(symbol, symbolFlags, location); + var hasAddedSymbolInfo; + var type; + // Class at constructor site need to be shown as constructor apart from property,method, vars + if (symbolKind !== ScriptElementKind.unknown || symbolFlags & 32 /* Class */ || symbolFlags & 8388608 /* Alias */) { + // If it is accessor they are allowed only if location is at name of the accessor + if (symbolKind === ScriptElementKind.memberGetAccessorElement || symbolKind === ScriptElementKind.memberSetAccessorElement) { + symbolKind = ScriptElementKind.memberVariableElement; + } + var signature; + type = typeChecker.getTypeOfSymbolAtLocation(symbol, location); + if (type) { + if (location.parent && location.parent.kind === 166 /* PropertyAccessExpression */) { + var right = location.parent.name; + // Either the location is on the right of a property access, or on the left and the right is missing + if (right === location || (right && right.getFullWidth() === 0)) { + location = location.parent; + } + } + // try get the call/construct signature from the type if it matches + var callExpression; + if (location.kind === 168 /* CallExpression */ || location.kind === 169 /* NewExpression */) { + callExpression = location; + } + else if (isCallExpressionTarget(location) || isNewExpressionTarget(location)) { + callExpression = location.parent; + } + if (callExpression) { + var candidateSignatures = []; + signature = typeChecker.getResolvedSignature(callExpression, candidateSignatures); + if (!signature && candidateSignatures.length) { + // Use the first candidate: + signature = candidateSignatures[0]; + } + var useConstructSignatures = callExpression.kind === 169 /* NewExpression */ || callExpression.expression.kind === 95 /* 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 + // either the original signature or its target, so check for either + signature = allSignatures.length ? allSignatures[0] : undefined; + } + if (signature) { + if (useConstructSignatures && (symbolFlags & 32 /* Class */)) { + // Constructor + symbolKind = ScriptElementKind.constructorImplementationElement; + addPrefixForAnyFunctionOrVar(type.symbol, symbolKind); + } + else if (symbolFlags & 8388608 /* Alias */) { + symbolKind = ScriptElementKind.alias; + pushTypePart(symbolKind); + displayParts.push(ts.spacePart()); + if (useConstructSignatures) { + displayParts.push(ts.keywordPart(92 /* NewKeyword */)); + displayParts.push(ts.spacePart()); + } + addFullSymbolName(symbol); + } + else { + addPrefixForAnyFunctionOrVar(symbol, symbolKind); + } + switch (symbolKind) { + case ScriptElementKind.memberVariableElement: + case ScriptElementKind.variableElement: + case ScriptElementKind.constElement: + case ScriptElementKind.letElement: + case ScriptElementKind.parameterElement: + case ScriptElementKind.localVariableElement: + // If it is call or construct signature of lambda's write type name + displayParts.push(ts.punctuationPart(54 /* ColonToken */)); + displayParts.push(ts.spacePart()); + if (useConstructSignatures) { + displayParts.push(ts.keywordPart(92 /* NewKeyword */)); + displayParts.push(ts.spacePart()); + } + if (!(type.flags & 65536 /* Anonymous */)) { + ts.addRange(displayParts, ts.symbolToDisplayParts(typeChecker, type.symbol, enclosingDeclaration, /*meaning*/ undefined, 1 /* WriteTypeParametersOrArguments */)); + } + addSignatureDisplayParts(signature, allSignatures, 8 /* WriteArrowStyleSignature */); + break; + default: + // Just signature + addSignatureDisplayParts(signature, allSignatures); + } + hasAddedSymbolInfo = true; + } + } + else if ((isNameOfFunctionDeclaration(location) && !(symbol.flags & 98304 /* Accessor */)) || + (location.kind === 121 /* ConstructorKeyword */ && location.parent.kind === 144 /* Constructor */)) { + // get the signature from the declaration and write it + var functionDeclaration = location.parent; + var allSignatures = functionDeclaration.kind === 144 /* Constructor */ ? type.getConstructSignatures() : type.getCallSignatures(); + if (!typeChecker.isImplementationOfOverload(functionDeclaration)) { + signature = typeChecker.getSignatureFromDeclaration(functionDeclaration); + } + else { + signature = allSignatures[0]; + } + if (functionDeclaration.kind === 144 /* Constructor */) { + // show (constructor) Type(...) signature + symbolKind = ScriptElementKind.constructorImplementationElement; + addPrefixForAnyFunctionOrVar(type.symbol, symbolKind); + } + else { + // (function/method) symbol(..signature) + addPrefixForAnyFunctionOrVar(functionDeclaration.kind === 147 /* CallSignature */ && + !(type.symbol.flags & 2048 /* TypeLiteral */ || type.symbol.flags & 4096 /* ObjectLiteral */) ? type.symbol : symbol, symbolKind); + } + addSignatureDisplayParts(signature, allSignatures); + hasAddedSymbolInfo = true; + } + } + } + if (symbolFlags & 32 /* Class */ && !hasAddedSymbolInfo) { + if (ts.getDeclarationOfKind(symbol, 186 /* ClassExpression */)) { + // Special case for class expressions because we would like to indicate that + // the class name is local to the class body (similar to function expression) + // (local class) class + pushTypePart(ScriptElementKind.localClassElement); + } + else { + // Class declaration has name which is not local. + displayParts.push(ts.keywordPart(73 /* ClassKeyword */)); + } + displayParts.push(ts.spacePart()); + addFullSymbolName(symbol); + writeTypeParametersOfSymbol(symbol, sourceFile); + } + if ((symbolFlags & 64 /* Interface */) && (semanticMeaning & 2 /* Type */)) { + addNewLineIfDisplayPartsExist(); + displayParts.push(ts.keywordPart(107 /* InterfaceKeyword */)); + displayParts.push(ts.spacePart()); + addFullSymbolName(symbol); + writeTypeParametersOfSymbol(symbol, sourceFile); + } + if (symbolFlags & 524288 /* TypeAlias */) { + addNewLineIfDisplayPartsExist(); + displayParts.push(ts.keywordPart(132 /* TypeKeyword */)); + displayParts.push(ts.spacePart()); + addFullSymbolName(symbol); + writeTypeParametersOfSymbol(symbol, sourceFile); + displayParts.push(ts.spacePart()); + displayParts.push(ts.operatorPart(56 /* EqualsToken */)); + displayParts.push(ts.spacePart()); + ts.addRange(displayParts, ts.typeToDisplayParts(typeChecker, typeChecker.getDeclaredTypeOfSymbol(symbol), enclosingDeclaration)); + } + if (symbolFlags & 384 /* Enum */) { + addNewLineIfDisplayPartsExist(); + if (ts.forEach(symbol.declarations, ts.isConstEnumDeclaration)) { + displayParts.push(ts.keywordPart(74 /* ConstKeyword */)); + displayParts.push(ts.spacePart()); + } + displayParts.push(ts.keywordPart(81 /* EnumKeyword */)); + displayParts.push(ts.spacePart()); + addFullSymbolName(symbol); + } + if (symbolFlags & 1536 /* Module */) { + addNewLineIfDisplayPartsExist(); + var declaration = ts.getDeclarationOfKind(symbol, 218 /* ModuleDeclaration */); + var isNamespace = declaration && declaration.name && declaration.name.kind === 69 /* Identifier */; + displayParts.push(ts.keywordPart(isNamespace ? 126 /* NamespaceKeyword */ : 125 /* ModuleKeyword */)); + displayParts.push(ts.spacePart()); + addFullSymbolName(symbol); + } + if ((symbolFlags & 262144 /* TypeParameter */) && (semanticMeaning & 2 /* Type */)) { + addNewLineIfDisplayPartsExist(); + displayParts.push(ts.punctuationPart(17 /* OpenParenToken */)); + displayParts.push(ts.textPart("type parameter")); + displayParts.push(ts.punctuationPart(18 /* CloseParenToken */)); + displayParts.push(ts.spacePart()); + addFullSymbolName(symbol); + displayParts.push(ts.spacePart()); + displayParts.push(ts.keywordPart(90 /* InKeyword */)); + displayParts.push(ts.spacePart()); + if (symbol.parent) { + // Class/Interface type parameter + addFullSymbolName(symbol.parent, enclosingDeclaration); + writeTypeParametersOfSymbol(symbol.parent, enclosingDeclaration); + } + else { + // Method/function type parameter + var container = ts.getContainingFunction(location); + if (container) { + var signatureDeclaration = ts.getDeclarationOfKind(symbol, 137 /* TypeParameter */).parent; + var signature = typeChecker.getSignatureFromDeclaration(signatureDeclaration); + if (signatureDeclaration.kind === 148 /* ConstructSignature */) { + displayParts.push(ts.keywordPart(92 /* NewKeyword */)); + displayParts.push(ts.spacePart()); + } + else if (signatureDeclaration.kind !== 147 /* CallSignature */ && signatureDeclaration.name) { + addFullSymbolName(signatureDeclaration.symbol); + } + ts.addRange(displayParts, ts.signatureToDisplayParts(typeChecker, signature, sourceFile, 32 /* WriteTypeArgumentsOfSignature */)); + } + else { + // Type aliash type parameter + // For example + // type list = T[]; // Both T will go through same code path + var declaration = ts.getDeclarationOfKind(symbol, 137 /* TypeParameter */).parent; + displayParts.push(ts.keywordPart(132 /* TypeKeyword */)); + displayParts.push(ts.spacePart()); + addFullSymbolName(declaration.symbol); + writeTypeParametersOfSymbol(declaration.symbol, sourceFile); + } + } + } + if (symbolFlags & 8 /* EnumMember */) { + addPrefixForAnyFunctionOrVar(symbol, "enum member"); + var declaration = symbol.declarations[0]; + if (declaration.kind === 247 /* EnumMember */) { + var constantValue = typeChecker.getConstantValue(declaration); + if (constantValue !== undefined) { + displayParts.push(ts.spacePart()); + displayParts.push(ts.operatorPart(56 /* EqualsToken */)); + displayParts.push(ts.spacePart()); + displayParts.push(ts.displayPart(constantValue.toString(), SymbolDisplayPartKind.numericLiteral)); + } + } + } + if (symbolFlags & 8388608 /* Alias */) { + addNewLineIfDisplayPartsExist(); + displayParts.push(ts.keywordPart(89 /* ImportKeyword */)); + displayParts.push(ts.spacePart()); + addFullSymbolName(symbol); + ts.forEach(symbol.declarations, function (declaration) { + if (declaration.kind === 221 /* ImportEqualsDeclaration */) { + var importEqualsDeclaration = declaration; + if (ts.isExternalModuleImportEqualsDeclaration(importEqualsDeclaration)) { + displayParts.push(ts.spacePart()); + displayParts.push(ts.operatorPart(56 /* EqualsToken */)); + displayParts.push(ts.spacePart()); + displayParts.push(ts.keywordPart(127 /* RequireKeyword */)); + displayParts.push(ts.punctuationPart(17 /* OpenParenToken */)); + displayParts.push(ts.displayPart(ts.getTextOfNode(ts.getExternalModuleImportEqualsDeclarationExpression(importEqualsDeclaration)), SymbolDisplayPartKind.stringLiteral)); + displayParts.push(ts.punctuationPart(18 /* CloseParenToken */)); + } + else { + var internalAliasSymbol = typeChecker.getSymbolAtLocation(importEqualsDeclaration.moduleReference); + if (internalAliasSymbol) { + displayParts.push(ts.spacePart()); + displayParts.push(ts.operatorPart(56 /* EqualsToken */)); + displayParts.push(ts.spacePart()); + addFullSymbolName(internalAliasSymbol, enclosingDeclaration); + } + } + return true; + } + }); + } + if (!hasAddedSymbolInfo) { + if (symbolKind !== ScriptElementKind.unknown) { + if (type) { + addPrefixForAnyFunctionOrVar(symbol, symbolKind); + // For properties, variables and local vars: show the type + if (symbolKind === ScriptElementKind.memberVariableElement || + symbolFlags & 3 /* Variable */ || + symbolKind === ScriptElementKind.localVariableElement) { + displayParts.push(ts.punctuationPart(54 /* ColonToken */)); + displayParts.push(ts.spacePart()); + // If the type is type parameter, format it specially + if (type.symbol && type.symbol.flags & 262144 /* TypeParameter */) { + var typeParameterParts = ts.mapToDisplayParts(function (writer) { + typeChecker.getSymbolDisplayBuilder().buildTypeParameterDisplay(type, writer, enclosingDeclaration); + }); + ts.addRange(displayParts, typeParameterParts); + } + else { + ts.addRange(displayParts, ts.typeToDisplayParts(typeChecker, type, enclosingDeclaration)); + } + } + else if (symbolFlags & 16 /* Function */ || + symbolFlags & 8192 /* Method */ || + symbolFlags & 16384 /* Constructor */ || + symbolFlags & 131072 /* Signature */ || + symbolFlags & 98304 /* Accessor */ || + symbolKind === ScriptElementKind.memberFunctionElement) { + var allSignatures = type.getCallSignatures(); + addSignatureDisplayParts(allSignatures[0], allSignatures); + } + } + } + else { + symbolKind = getSymbolKind(symbol, location); + } + } + if (!documentation) { + documentation = symbol.getDocumentationComment(); + } + return { displayParts: displayParts, documentation: documentation, symbolKind: symbolKind }; + function addNewLineIfDisplayPartsExist() { + if (displayParts.length) { + displayParts.push(ts.lineBreakPart()); + } + } + function addFullSymbolName(symbol, enclosingDeclaration) { + var fullSymbolDisplayParts = ts.symbolToDisplayParts(typeChecker, symbol, enclosingDeclaration || sourceFile, /*meaning*/ undefined, 1 /* WriteTypeParametersOrArguments */ | 2 /* UseOnlyExternalAliasing */); + ts.addRange(displayParts, fullSymbolDisplayParts); + } + function addPrefixForAnyFunctionOrVar(symbol, symbolKind) { + addNewLineIfDisplayPartsExist(); + if (symbolKind) { + pushTypePart(symbolKind); + displayParts.push(ts.spacePart()); + addFullSymbolName(symbol); + } + } + function pushTypePart(symbolKind) { + switch (symbolKind) { + case ScriptElementKind.variableElement: + case ScriptElementKind.functionElement: + case ScriptElementKind.letElement: + case ScriptElementKind.constElement: + case ScriptElementKind.constructorImplementationElement: + displayParts.push(ts.textOrKeywordPart(symbolKind)); + return; + default: + displayParts.push(ts.punctuationPart(17 /* OpenParenToken */)); + displayParts.push(ts.textOrKeywordPart(symbolKind)); + displayParts.push(ts.punctuationPart(18 /* CloseParenToken */)); + return; + } + } + function addSignatureDisplayParts(signature, allSignatures, flags) { + 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.displayPart((allSignatures.length - 1).toString(), SymbolDisplayPartKind.numericLiteral)); + displayParts.push(ts.spacePart()); + displayParts.push(ts.textPart(allSignatures.length === 2 ? "overload" : "overloads")); + displayParts.push(ts.punctuationPart(18 /* CloseParenToken */)); + } + documentation = signature.getDocumentationComment(); + } + function writeTypeParametersOfSymbol(symbol, enclosingDeclaration) { + var typeParameterParts = ts.mapToDisplayParts(function (writer) { + typeChecker.getSymbolDisplayBuilder().buildTypeParameterDisplayFromSymbol(symbol, writer, enclosingDeclaration); + }); + ts.addRange(displayParts, typeParameterParts); + } + } + function getQuickInfoAtPosition(fileName, position) { + synchronizeHostData(); + var sourceFile = getValidSourceFile(fileName); + var node = ts.getTouchingPropertyName(sourceFile, position); + if (!node) { + return undefined; + } + if (isLabelName(node)) { + return undefined; + } + var typeChecker = program.getTypeChecker(); + var symbol = typeChecker.getSymbolAtLocation(node); + if (!symbol) { + // Try getting just type at this position and show + switch (node.kind) { + case 69 /* Identifier */: + case 166 /* PropertyAccessExpression */: + case 135 /* QualifiedName */: + case 97 /* ThisKeyword */: + case 95 /* SuperKeyword */: + // For the identifiers/this/super etc get the type at position + var type = typeChecker.getTypeAtLocation(node); + if (type) { + return { + kind: ScriptElementKind.unknown, + kindModifiers: ScriptElementKindModifier.none, + textSpan: ts.createTextSpan(node.getStart(), node.getWidth()), + displayParts: ts.typeToDisplayParts(typeChecker, type, getContainerNode(node)), + documentation: type.symbol ? type.symbol.getDocumentationComment() : undefined + }; + } + } + return undefined; + } + var displayPartsDocumentationsAndKind = getSymbolDisplayPartsDocumentationAndSymbolKind(symbol, sourceFile, getContainerNode(node), node); + return { + kind: displayPartsDocumentationsAndKind.symbolKind, + kindModifiers: getSymbolModifiers(symbol), + textSpan: ts.createTextSpan(node.getStart(), node.getWidth()), + displayParts: displayPartsDocumentationsAndKind.displayParts, + documentation: displayPartsDocumentationsAndKind.documentation + }; + } + function createDefinitionInfo(node, symbolKind, symbolName, containerName) { + return { + fileName: node.getSourceFile().fileName, + textSpan: ts.createTextSpanFromBounds(node.getStart(), node.getEnd()), + kind: symbolKind, + name: symbolName, + containerKind: undefined, + containerName: containerName + }; + } + function getDefinitionFromSymbol(symbol, node) { + var typeChecker = program.getTypeChecker(); + var result = []; + var declarations = symbol.getDeclarations(); + var symbolName = typeChecker.symbolToString(symbol); // Do not get scoped name, just the name of the symbol + var symbolKind = getSymbolKind(symbol, node); + var containerSymbol = symbol.parent; + var containerName = containerSymbol ? typeChecker.symbolToString(containerSymbol, node) : ""; + if (!tryAddConstructSignature(symbol, node, symbolKind, symbolName, containerName, result) && + !tryAddCallSignature(symbol, node, symbolKind, symbolName, containerName, result)) { + // Just add all the declarations. + ts.forEach(declarations, function (declaration) { + result.push(createDefinitionInfo(declaration, symbolKind, symbolName, containerName)); + }); + } + return result; + function tryAddConstructSignature(symbol, location, symbolKind, symbolName, containerName, result) { + // Applicable only if we are in a new expression, or we are on a constructor declaration + // and in either case the symbol has a construct signature definition, i.e. class + if (isNewExpressionTarget(location) || location.kind === 121 /* ConstructorKeyword */) { + if (symbol.flags & 32 /* Class */) { + // Find the first class-like declaration and try to get the construct signature. + for (var _i = 0, _a = symbol.getDeclarations(); _i < _a.length; _i++) { + var declaration = _a[_i]; + if (ts.isClassLike(declaration)) { + return tryAddSignature(declaration.members, + /*selectConstructors*/ true, symbolKind, symbolName, containerName, result); + } + } + ts.Debug.fail("Expected declaration to have at least one class-like declaration"); + } + } + return false; + } + function tryAddCallSignature(symbol, location, symbolKind, symbolName, containerName, result) { + if (isCallExpressionTarget(location) || isNewExpressionTarget(location) || isNameOfFunctionDeclaration(location)) { + return tryAddSignature(symbol.declarations, /*selectConstructors*/ false, symbolKind, symbolName, containerName, result); + } + return false; + } + function tryAddSignature(signatureDeclarations, selectConstructors, symbolKind, symbolName, containerName, result) { + var declarations = []; + var definition; + ts.forEach(signatureDeclarations, function (d) { + if ((selectConstructors && d.kind === 144 /* Constructor */) || + (!selectConstructors && (d.kind === 213 /* FunctionDeclaration */ || d.kind === 143 /* MethodDeclaration */ || d.kind === 142 /* MethodSignature */))) { + declarations.push(d); + if (d.body) + definition = d; + } + }); + if (definition) { + result.push(createDefinitionInfo(definition, symbolKind, symbolName, containerName)); + return true; + } + else if (declarations.length) { + result.push(createDefinitionInfo(ts.lastOrUndefined(declarations), symbolKind, symbolName, containerName)); + return true; + } + return false; + } + } + /// Goto definition + function getDefinitionAtPosition(fileName, position) { + synchronizeHostData(); + var sourceFile = getValidSourceFile(fileName); + var node = ts.getTouchingPropertyName(sourceFile, position); + if (!node) { + return undefined; + } + // Labels + if (isJumpStatementTarget(node)) { + var labelName = node.text; + var label = getTargetLabel(node.parent, node.text); + return label ? [createDefinitionInfo(label, ScriptElementKind.label, labelName, /*containerName*/ undefined)] : undefined; + } + /// Triple slash reference comments + var comment = ts.forEach(sourceFile.referencedFiles, function (r) { return (r.pos <= position && position < r.end) ? r : undefined; }); + if (comment) { + var referenceFile = ts.tryResolveScriptReference(program, sourceFile, comment); + if (referenceFile) { + return [{ + fileName: referenceFile.fileName, + textSpan: ts.createTextSpanFromBounds(0, 0), + kind: ScriptElementKind.scriptElement, + name: comment.fileName, + containerName: undefined, + containerKind: undefined + }]; + } + return undefined; + } + var typeChecker = program.getTypeChecker(); + var symbol = typeChecker.getSymbolAtLocation(node); + // Could not find a symbol e.g. node is string or number keyword, + // or the symbol was an internal symbol and does not have a declaration e.g. undefined symbol + if (!symbol) { + return undefined; + } + // If this is an alias, and the request came at the declaration location + // get the aliased symbol instead. This allows for goto def on an import e.g. + // import {A, B} from "mod"; + // to jump to the implementation directly. + if (symbol.flags & 8388608 /* Alias */) { + var declaration = symbol.declarations[0]; + if (node.kind === 69 /* Identifier */ && node.parent === declaration) { + symbol = typeChecker.getAliasedSymbol(symbol); + } + } + // Because name in short-hand property assignment has two different meanings: property name and property value, + // using go-to-definition at such position should go to the variable declaration of the property value rather than + // go to the declaration of the property name (in this case stay at the same position). However, if go-to-definition + // is performed at the location of property access, we would like to go to definition of the property in the short-hand + // assignment. This case and others are handled by the following code. + if (node.parent.kind === 246 /* ShorthandPropertyAssignment */) { + var shorthandSymbol = typeChecker.getShorthandAssignmentValueSymbol(symbol.valueDeclaration); + if (!shorthandSymbol) { + return []; + } + var shorthandDeclarations = shorthandSymbol.getDeclarations(); + var shorthandSymbolKind = getSymbolKind(shorthandSymbol, node); + var shorthandSymbolName = typeChecker.symbolToString(shorthandSymbol); + var shorthandContainerName = typeChecker.symbolToString(symbol.parent, node); + return ts.map(shorthandDeclarations, function (declaration) { return createDefinitionInfo(declaration, shorthandSymbolKind, shorthandSymbolName, shorthandContainerName); }); + } + return getDefinitionFromSymbol(symbol, node); + } + /// Goto type + function getTypeDefinitionAtPosition(fileName, position) { + synchronizeHostData(); + var sourceFile = getValidSourceFile(fileName); + var node = ts.getTouchingPropertyName(sourceFile, position); + if (!node) { + return undefined; + } + var typeChecker = program.getTypeChecker(); + var symbol = typeChecker.getSymbolAtLocation(node); + if (!symbol) { + return undefined; + } + var type = typeChecker.getTypeOfSymbolAtLocation(symbol, node); + if (!type) { + return undefined; + } + if (type.flags & 16384 /* Union */) { + var result = []; + ts.forEach(type.types, function (t) { + if (t.symbol) { + ts.addRange(/*to*/ result, /*from*/ getDefinitionFromSymbol(t.symbol, node)); + } + }); + return result; + } + if (!type.symbol) { + return undefined; + } + return getDefinitionFromSymbol(type.symbol, node); + } + function getOccurrencesAtPosition(fileName, position) { + var results = getOccurrencesAtPositionCore(fileName, position); + if (results) { + var sourceFile = getCanonicalFileName(ts.normalizeSlashes(fileName)); + // Get occurrences only supports reporting occurrences for the file queried. So + // filter down to that list. + results = ts.filter(results, function (r) { return getCanonicalFileName(ts.normalizeSlashes(r.fileName)) === sourceFile; }); + } + return results; + } + function getDocumentHighlights(fileName, position, filesToSearch) { + synchronizeHostData(); + filesToSearch = ts.map(filesToSearch, ts.normalizeSlashes); + var sourceFilesToSearch = ts.filter(program.getSourceFiles(), function (f) { return ts.contains(filesToSearch, f.fileName); }); + var sourceFile = getValidSourceFile(fileName); + var node = ts.getTouchingWord(sourceFile, position); + if (!node) { + return undefined; + } + return getSemanticDocumentHighlights(node) || getSyntacticDocumentHighlights(node); + function getHighlightSpanForNode(node) { + var start = node.getStart(); + var end = node.getEnd(); + return { + fileName: sourceFile.fileName, + textSpan: ts.createTextSpanFromBounds(start, end), + kind: HighlightSpanKind.none + }; + } + function getSemanticDocumentHighlights(node) { + if (node.kind === 69 /* Identifier */ || + node.kind === 97 /* ThisKeyword */ || + node.kind === 95 /* SuperKeyword */ || + isLiteralNameOfPropertyDeclarationOrIndexAccess(node) || + isNameOfExternalModuleImportOrDeclaration(node)) { + var referencedSymbols = getReferencedSymbolsForNode(node, sourceFilesToSearch, /*findInStrings:*/ false, /*findInComments:*/ false); + return convertReferencedSymbols(referencedSymbols); + } + return undefined; + function convertReferencedSymbols(referencedSymbols) { + if (!referencedSymbols) { + return undefined; + } + var fileNameToDocumentHighlights = {}; + var result = []; + for (var _i = 0; _i < referencedSymbols.length; _i++) { + var referencedSymbol = referencedSymbols[_i]; + for (var _a = 0, _b = referencedSymbol.references; _a < _b.length; _a++) { + var referenceEntry = _b[_a]; + var fileName_1 = referenceEntry.fileName; + var documentHighlights = ts.getProperty(fileNameToDocumentHighlights, fileName_1); + if (!documentHighlights) { + documentHighlights = { fileName: fileName_1, highlightSpans: [] }; + fileNameToDocumentHighlights[fileName_1] = documentHighlights; + result.push(documentHighlights); + } + documentHighlights.highlightSpans.push({ + textSpan: referenceEntry.textSpan, + kind: referenceEntry.isWriteAccess ? HighlightSpanKind.writtenReference : HighlightSpanKind.reference + }); + } + } + return result; + } + } + function getSyntacticDocumentHighlights(node) { + var fileName = sourceFile.fileName; + var highlightSpans = getHighlightSpans(node); + if (!highlightSpans || highlightSpans.length === 0) { + return undefined; + } + return [{ fileName: fileName, highlightSpans: highlightSpans }]; + // returns true if 'node' is defined and has a matching 'kind'. + function hasKind(node, kind) { + return node !== undefined && node.kind === kind; + } + // Null-propagating 'parent' function. + function parent(node) { + return node && node.parent; + } + function getHighlightSpans(node) { + if (node) { + switch (node.kind) { + case 88 /* IfKeyword */: + case 80 /* ElseKeyword */: + if (hasKind(node.parent, 196 /* IfStatement */)) { + return getIfElseOccurrences(node.parent); + } + break; + case 94 /* ReturnKeyword */: + if (hasKind(node.parent, 204 /* ReturnStatement */)) { + return getReturnOccurrences(node.parent); + } + break; + case 98 /* ThrowKeyword */: + if (hasKind(node.parent, 208 /* ThrowStatement */)) { + return getThrowOccurrences(node.parent); + } + break; + case 72 /* CatchKeyword */: + if (hasKind(parent(parent(node)), 209 /* TryStatement */)) { + return getTryCatchFinallyOccurrences(node.parent.parent); + } + break; + case 100 /* TryKeyword */: + case 85 /* FinallyKeyword */: + if (hasKind(parent(node), 209 /* TryStatement */)) { + return getTryCatchFinallyOccurrences(node.parent); + } + break; + case 96 /* SwitchKeyword */: + if (hasKind(node.parent, 206 /* SwitchStatement */)) { + return getSwitchCaseDefaultOccurrences(node.parent); + } + break; + case 71 /* CaseKeyword */: + case 77 /* DefaultKeyword */: + if (hasKind(parent(parent(parent(node))), 206 /* SwitchStatement */)) { + return getSwitchCaseDefaultOccurrences(node.parent.parent.parent); + } + break; + case 70 /* BreakKeyword */: + case 75 /* ContinueKeyword */: + if (hasKind(node.parent, 203 /* BreakStatement */) || hasKind(node.parent, 202 /* ContinueStatement */)) { + return getBreakOrContinueStatementOccurrences(node.parent); + } + break; + case 86 /* ForKeyword */: + if (hasKind(node.parent, 199 /* ForStatement */) || + hasKind(node.parent, 200 /* ForInStatement */) || + hasKind(node.parent, 201 /* ForOfStatement */)) { + return getLoopBreakContinueOccurrences(node.parent); + } + break; + case 104 /* WhileKeyword */: + case 79 /* DoKeyword */: + if (hasKind(node.parent, 198 /* WhileStatement */) || hasKind(node.parent, 197 /* DoStatement */)) { + return getLoopBreakContinueOccurrences(node.parent); + } + break; + case 121 /* ConstructorKeyword */: + if (hasKind(node.parent, 144 /* Constructor */)) { + return getConstructorOccurrences(node.parent); + } + break; + case 123 /* GetKeyword */: + case 129 /* SetKeyword */: + if (hasKind(node.parent, 145 /* GetAccessor */) || hasKind(node.parent, 146 /* SetAccessor */)) { + return getGetAndSetOccurrences(node.parent); + } + break; + default: + if (ts.isModifier(node.kind) && node.parent && + (ts.isDeclaration(node.parent) || node.parent.kind === 193 /* VariableStatement */)) { + return getModifierOccurrences(node.kind, node.parent); + } + } + } + return undefined; + } + /** + * Aggregates all throw-statements within this node *without* crossing + * into function boundaries and try-blocks with catch-clauses. + */ + function aggregateOwnedThrowStatements(node) { + var statementAccumulator = []; + aggregate(node); + return statementAccumulator; + function aggregate(node) { + if (node.kind === 208 /* ThrowStatement */) { + statementAccumulator.push(node); + } + else if (node.kind === 209 /* TryStatement */) { + var tryStatement = node; + if (tryStatement.catchClause) { + aggregate(tryStatement.catchClause); + } + else { + // Exceptions thrown within a try block lacking a catch clause + // are "owned" in the current context. + aggregate(tryStatement.tryBlock); + } + if (tryStatement.finallyBlock) { + aggregate(tryStatement.finallyBlock); + } + } + else if (!ts.isFunctionLike(node)) { + ts.forEachChild(node, aggregate); + } + } + ; + } + /** + * For lack of a better name, this function takes a throw statement and returns the + * nearest ancestor that is a try-block (whose try statement has a catch clause), + * function-block, or source file. + */ + function getThrowStatementOwner(throwStatement) { + var child = throwStatement; + while (child.parent) { + var parent_12 = child.parent; + if (ts.isFunctionBlock(parent_12) || parent_12.kind === 248 /* SourceFile */) { + return parent_12; + } + // A throw-statement is only owned by a try-statement if the try-statement has + // a catch clause, and if the throw-statement occurs within the try block. + if (parent_12.kind === 209 /* TryStatement */) { + var tryStatement = parent_12; + if (tryStatement.tryBlock === child && tryStatement.catchClause) { + return child; + } + } + child = parent_12; + } + return undefined; + } + function aggregateAllBreakAndContinueStatements(node) { + var statementAccumulator = []; + aggregate(node); + return statementAccumulator; + function aggregate(node) { + if (node.kind === 203 /* BreakStatement */ || node.kind === 202 /* ContinueStatement */) { + statementAccumulator.push(node); + } + else if (!ts.isFunctionLike(node)) { + ts.forEachChild(node, aggregate); + } + } + ; + } + function ownsBreakOrContinueStatement(owner, statement) { + var actualOwner = getBreakOrContinueOwner(statement); + return actualOwner && actualOwner === owner; + } + function getBreakOrContinueOwner(statement) { + for (var node_2 = statement.parent; node_2; node_2 = node_2.parent) { + switch (node_2.kind) { + case 206 /* SwitchStatement */: + if (statement.kind === 202 /* ContinueStatement */) { + continue; + } + // Fall through. + case 199 /* ForStatement */: + case 200 /* ForInStatement */: + case 201 /* ForOfStatement */: + case 198 /* WhileStatement */: + case 197 /* DoStatement */: + if (!statement.label || isLabeledBy(node_2, statement.label.text)) { + return node_2; + } + break; + default: + // Don't cross function boundaries. + if (ts.isFunctionLike(node_2)) { + return undefined; + } + break; + } + } + return undefined; + } + function getModifierOccurrences(modifier, declaration) { + 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 === 214 /* ClassDeclaration */ || + container.kind === 186 /* ClassExpression */ || + (declaration.kind === 138 /* Parameter */ && hasKind(container, 144 /* Constructor */)))) { + return undefined; + } + } + else if (modifier === 113 /* StaticKeyword */) { + if (!(container.kind === 214 /* ClassDeclaration */ || container.kind === 186 /* ClassExpression */)) { + return undefined; + } + } + else if (modifier === 82 /* ExportKeyword */ || modifier === 122 /* DeclareKeyword */) { + if (!(container.kind === 219 /* ModuleBlock */ || container.kind === 248 /* SourceFile */)) { + return undefined; + } + } + else if (modifier === 115 /* AbstractKeyword */) { + if (!(container.kind === 214 /* ClassDeclaration */ || declaration.kind === 214 /* ClassDeclaration */)) { + return undefined; + } + } + else { + // unsupported modifier + return undefined; + } + var keywords = []; + var modifierFlag = getFlagFromModifier(modifier); + var nodes; + switch (container.kind) { + case 219 /* ModuleBlock */: + case 248 /* SourceFile */: + // Container is either a class declaration or the declaration is a classDeclaration + if (modifierFlag & 256 /* Abstract */) { + nodes = declaration.members.concat(declaration); + } + else { + nodes = container.statements; + } + break; + case 144 /* Constructor */: + nodes = container.parameters.concat(container.parent.members); + break; + case 214 /* ClassDeclaration */: + case 186 /* ClassExpression */: + nodes = container.members; + // If we're an accessibility modifier, we're in an instance member and should search + // the constructor's parameter list for instance members as well. + if (modifierFlag & 112 /* AccessibilityModifier */) { + var constructor = ts.forEach(container.members, function (member) { + return member.kind === 144 /* Constructor */ && member; + }); + if (constructor) { + nodes = nodes.concat(constructor.parameters); + } + } + else if (modifierFlag & 256 /* Abstract */) { + nodes = nodes.concat(container); + } + break; + default: + ts.Debug.fail("Invalid container kind."); + } + ts.forEach(nodes, function (node) { + if (node.modifiers && node.flags & modifierFlag) { + ts.forEach(node.modifiers, function (child) { return pushKeywordIf(keywords, child, modifier); }); + } + }); + return ts.map(keywords, getHighlightSpanForNode); + function getFlagFromModifier(modifier) { + switch (modifier) { + case 112 /* PublicKeyword */: + return 16 /* Public */; + case 110 /* PrivateKeyword */: + return 32 /* Private */; + case 111 /* ProtectedKeyword */: + return 64 /* Protected */; + case 113 /* StaticKeyword */: + return 128 /* Static */; + case 82 /* ExportKeyword */: + return 1 /* Export */; + case 122 /* DeclareKeyword */: + return 2 /* Ambient */; + case 115 /* AbstractKeyword */: + return 256 /* Abstract */; + default: + ts.Debug.fail(); + } + } + } + function pushKeywordIf(keywordList, token) { + var expected = []; + for (var _i = 2; _i < arguments.length; _i++) { + expected[_i - 2] = arguments[_i]; + } + if (token && ts.contains(expected, token.kind)) { + keywordList.push(token); + return true; + } + return false; + } + function getGetAndSetOccurrences(accessorDeclaration) { + var keywords = []; + tryPushAccessorKeyword(accessorDeclaration.symbol, 145 /* GetAccessor */); + tryPushAccessorKeyword(accessorDeclaration.symbol, 146 /* SetAccessor */); + return ts.map(keywords, getHighlightSpanForNode); + function tryPushAccessorKeyword(accessorSymbol, accessorKind) { + var accessor = ts.getDeclarationOfKind(accessorSymbol, accessorKind); + if (accessor) { + ts.forEach(accessor.getChildren(), function (child) { return pushKeywordIf(keywords, child, 123 /* GetKeyword */, 129 /* SetKeyword */); }); + } + } + } + function getConstructorOccurrences(constructorDeclaration) { + var declarations = constructorDeclaration.symbol.getDeclarations(); + var keywords = []; + ts.forEach(declarations, function (declaration) { + ts.forEach(declaration.getChildren(), function (token) { + return pushKeywordIf(keywords, token, 121 /* ConstructorKeyword */); + }); + }); + return ts.map(keywords, getHighlightSpanForNode); + } + function getLoopBreakContinueOccurrences(loopNode) { + var keywords = []; + if (pushKeywordIf(keywords, loopNode.getFirstToken(), 86 /* ForKeyword */, 104 /* WhileKeyword */, 79 /* DoKeyword */)) { + // If we succeeded and got a do-while loop, then start looking for a 'while' keyword. + if (loopNode.kind === 197 /* DoStatement */) { + var loopTokens = loopNode.getChildren(); + for (var i = loopTokens.length - 1; i >= 0; i--) { + if (pushKeywordIf(keywords, loopTokens[i], 104 /* WhileKeyword */)) { + break; + } + } + } + } + var breaksAndContinues = aggregateAllBreakAndContinueStatements(loopNode.statement); + ts.forEach(breaksAndContinues, function (statement) { + if (ownsBreakOrContinueStatement(loopNode, statement)) { + pushKeywordIf(keywords, statement.getFirstToken(), 70 /* BreakKeyword */, 75 /* ContinueKeyword */); + } + }); + return ts.map(keywords, getHighlightSpanForNode); + } + function getBreakOrContinueStatementOccurrences(breakOrContinueStatement) { + var owner = getBreakOrContinueOwner(breakOrContinueStatement); + if (owner) { + switch (owner.kind) { + case 199 /* ForStatement */: + case 200 /* ForInStatement */: + case 201 /* ForOfStatement */: + case 197 /* DoStatement */: + case 198 /* WhileStatement */: + return getLoopBreakContinueOccurrences(owner); + case 206 /* SwitchStatement */: + return getSwitchCaseDefaultOccurrences(owner); + } + } + return undefined; + } + function getSwitchCaseDefaultOccurrences(switchStatement) { + var keywords = []; + pushKeywordIf(keywords, switchStatement.getFirstToken(), 96 /* SwitchKeyword */); + // Go through each clause in the switch statement, collecting the 'case'/'default' keywords. + ts.forEach(switchStatement.caseBlock.clauses, function (clause) { + pushKeywordIf(keywords, clause.getFirstToken(), 71 /* CaseKeyword */, 77 /* DefaultKeyword */); + var breaksAndContinues = aggregateAllBreakAndContinueStatements(clause); + ts.forEach(breaksAndContinues, function (statement) { + if (ownsBreakOrContinueStatement(switchStatement, statement)) { + pushKeywordIf(keywords, statement.getFirstToken(), 70 /* BreakKeyword */); + } + }); + }); + return ts.map(keywords, getHighlightSpanForNode); + } + function getTryCatchFinallyOccurrences(tryStatement) { + var keywords = []; + pushKeywordIf(keywords, tryStatement.getFirstToken(), 100 /* TryKeyword */); + if (tryStatement.catchClause) { + pushKeywordIf(keywords, tryStatement.catchClause.getFirstToken(), 72 /* CatchKeyword */); + } + if (tryStatement.finallyBlock) { + var finallyKeyword = ts.findChildOfKind(tryStatement, 85 /* FinallyKeyword */, sourceFile); + pushKeywordIf(keywords, finallyKeyword, 85 /* FinallyKeyword */); + } + return ts.map(keywords, getHighlightSpanForNode); + } + function getThrowOccurrences(throwStatement) { + var owner = getThrowStatementOwner(throwStatement); + if (!owner) { + return undefined; + } + var keywords = []; + ts.forEach(aggregateOwnedThrowStatements(owner), function (throwStatement) { + pushKeywordIf(keywords, throwStatement.getFirstToken(), 98 /* ThrowKeyword */); + }); + // If the "owner" is a function, then we equate 'return' and 'throw' statements in their + // ability to "jump out" of the function, and include occurrences for both. + if (ts.isFunctionBlock(owner)) { + ts.forEachReturnStatement(owner, function (returnStatement) { + pushKeywordIf(keywords, returnStatement.getFirstToken(), 94 /* ReturnKeyword */); + }); + } + return ts.map(keywords, getHighlightSpanForNode); + } + 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, 192 /* Block */))) { + return undefined; + } + var keywords = []; + ts.forEachReturnStatement(func.body, function (returnStatement) { + pushKeywordIf(keywords, returnStatement.getFirstToken(), 94 /* ReturnKeyword */); + }); + // Include 'throw' statements that do not occur within a try block. + ts.forEach(aggregateOwnedThrowStatements(func.body), function (throwStatement) { + pushKeywordIf(keywords, throwStatement.getFirstToken(), 98 /* ThrowKeyword */); + }); + return ts.map(keywords, getHighlightSpanForNode); + } + function getIfElseOccurrences(ifStatement) { + var keywords = []; + // Traverse upwards through all parent if-statements linked by their else-branches. + while (hasKind(ifStatement.parent, 196 /* IfStatement */) && ifStatement.parent.elseStatement === ifStatement) { + ifStatement = ifStatement.parent; + } + // Now traverse back down through the else branches, aggregating if/else keywords of if-statements. + while (ifStatement) { + var children = ifStatement.getChildren(); + pushKeywordIf(keywords, children[0], 88 /* IfKeyword */); + // Generally the 'else' keyword is second-to-last, so we traverse backwards. + for (var i = children.length - 1; i >= 0; i--) { + if (pushKeywordIf(keywords, children[i], 80 /* ElseKeyword */)) { + break; + } + } + if (!hasKind(ifStatement.elseStatement, 196 /* IfStatement */)) { + break; + } + ifStatement = ifStatement.elseStatement; + } + var result = []; + // 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) { + var elseKeyword = keywords[i]; + var ifKeyword = keywords[i + 1]; // this *should* always be an 'if' keyword. + var shouldCombindElseAndIf = true; + // Avoid recalculating getStart() by iterating backwards. + for (var j = ifKeyword.getStart() - 1; j >= elseKeyword.end; j--) { + if (!ts.isWhiteSpace(sourceFile.text.charCodeAt(j))) { + shouldCombindElseAndIf = false; + break; + } + } + if (shouldCombindElseAndIf) { + result.push({ + fileName: fileName, + textSpan: ts.createTextSpanFromBounds(elseKeyword.getStart(), ifKeyword.end), + kind: HighlightSpanKind.reference + }); + i++; // skip the next keyword + continue; + } + } + // Ordinary case: just highlight the keyword. + result.push(getHighlightSpanForNode(keywords[i])); + } + return result; + } + } + } + /// References and Occurrences + function getOccurrencesAtPositionCore(fileName, position) { + synchronizeHostData(); + return convertDocumentHighlights(getDocumentHighlights(fileName, position, [fileName])); + function convertDocumentHighlights(documentHighlights) { + if (!documentHighlights) { + return undefined; + } + var result = []; + for (var _i = 0; _i < documentHighlights.length; _i++) { + var entry = documentHighlights[_i]; + for (var _a = 0, _b = entry.highlightSpans; _a < _b.length; _a++) { + var highlightSpan = _b[_a]; + result.push({ + fileName: entry.fileName, + textSpan: highlightSpan.textSpan, + isWriteAccess: highlightSpan.kind === HighlightSpanKind.writtenReference + }); + } + } + return result; + } + } + function convertReferences(referenceSymbols) { + if (!referenceSymbols) { + return undefined; + } + var referenceEntries = []; + for (var _i = 0; _i < referenceSymbols.length; _i++) { + var referenceSymbol = referenceSymbols[_i]; + ts.addRange(referenceEntries, referenceSymbol.references); + } + return referenceEntries; + } + function findRenameLocations(fileName, position, findInStrings, findInComments) { + var referencedSymbols = findReferencedSymbols(fileName, position, findInStrings, findInComments); + return convertReferences(referencedSymbols); + } + function getReferencesAtPosition(fileName, position) { + var referencedSymbols = findReferencedSymbols(fileName, position, /*findInStrings:*/ false, /*findInComments:*/ false); + return convertReferences(referencedSymbols); + } + function findReferences(fileName, position) { + var referencedSymbols = findReferencedSymbols(fileName, position, /*findInStrings:*/ false, /*findInComments:*/ false); + // Only include referenced symbols that have a valid definition. + return ts.filter(referencedSymbols, function (rs) { return !!rs.definition; }); + } + function findReferencedSymbols(fileName, position, findInStrings, findInComments) { + synchronizeHostData(); + var sourceFile = getValidSourceFile(fileName); + var node = ts.getTouchingPropertyName(sourceFile, position); + if (!node) { + return undefined; + } + if (node.kind !== 69 /* Identifier */ && + // TODO (drosen): This should be enabled in a later release - currently breaks rename. + //node.kind !== SyntaxKind.ThisKeyword && + //node.kind !== SyntaxKind.SuperKeyword && + !isLiteralNameOfPropertyDeclarationOrIndexAccess(node) && + !isNameOfExternalModuleImportOrDeclaration(node)) { + return undefined; + } + ts.Debug.assert(node.kind === 69 /* Identifier */ || node.kind === 8 /* NumericLiteral */ || node.kind === 9 /* StringLiteral */); + return getReferencedSymbolsForNode(node, program.getSourceFiles(), findInStrings, findInComments); + } + function getReferencedSymbolsForNode(node, sourceFiles, findInStrings, findInComments) { + var typeChecker = program.getTypeChecker(); + // Labels + if (isLabelName(node)) { + if (isJumpStatementTarget(node)) { + var labelDefinition = getTargetLabel(node.parent, node.text); + // if we have a label definition, look within its statement for references, if not, then + // the label is undefined and we have no results.. + return labelDefinition ? getLabelReferencesInNode(labelDefinition.parent, labelDefinition) : undefined; + } + else { + // it is a label definition and not a target, search within the parent labeledStatement + return getLabelReferencesInNode(node.parent, node); + } + } + if (node.kind === 97 /* ThisKeyword */) { + return getReferencesForThisKeyword(node, sourceFiles); + } + if (node.kind === 95 /* SuperKeyword */) { + return getReferencesForSuperKeyword(node); + } + var symbol = typeChecker.getSymbolAtLocation(node); + // Could not find a symbol e.g. unknown identifier + if (!symbol) { + // Can't have references to something that we have no symbol for. + return undefined; + } + var declarations = symbol.declarations; + // The symbol was an internal symbol and does not have a declaration e.g. undefined symbol + if (!declarations || !declarations.length) { + return undefined; + } + var result; + // Compute the meaning from the location and the symbol it references + var searchMeaning = getIntersectingMeaningFromDeclarations(getMeaningFromLocation(node), declarations); + // Get the text to search for. + // Note: if this is an external module symbol, the name doesn't include quotes. + var declaredName = ts.stripQuotes(ts.getDeclaredName(typeChecker, symbol, node)); + // Try to get the smallest valid scope that we can limit our search to; + // otherwise we'll need to search globally (i.e. include each file). + var scope = getSymbolScope(symbol); + // Maps from a symbol ID to the ReferencedSymbol entry in 'result'. + var symbolToIndex = []; + if (scope) { + result = []; + getReferencesInNode(scope, symbol, declaredName, node, searchMeaning, findInStrings, findInComments, result, symbolToIndex); + } + else { + var internedName = getInternedName(symbol, node, declarations); + for (var _i = 0; _i < sourceFiles.length; _i++) { + var sourceFile = sourceFiles[_i]; + cancellationToken.throwIfCancellationRequested(); + var nameTable = getNameTable(sourceFile); + if (ts.lookUp(nameTable, internedName)) { + result = result || []; + getReferencesInNode(sourceFile, symbol, declaredName, node, searchMeaning, findInStrings, findInComments, result, symbolToIndex); + } + } + } + return result; + function getDefinition(symbol) { + var info = getSymbolDisplayPartsDocumentationAndSymbolKind(symbol, node.getSourceFile(), getContainerNode(node), node); + var name = ts.map(info.displayParts, function (p) { return p.text; }).join(""); + var declarations = symbol.declarations; + if (!declarations || declarations.length === 0) { + return undefined; + } + return { + containerKind: "", + containerName: "", + name: name, + kind: info.symbolKind, + fileName: declarations[0].getSourceFile().fileName, + textSpan: ts.createTextSpan(declarations[0].getStart(), 0) + }; + } + function isImportOrExportSpecifierImportSymbol(symbol) { + return (symbol.flags & 8388608 /* Alias */) && ts.forEach(symbol.declarations, function (declaration) { + return declaration.kind === 226 /* ImportSpecifier */ || declaration.kind === 230 /* ExportSpecifier */; + }); + } + function getInternedName(symbol, location, declarations) { + // 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)) { + return location.getText(); + } + // Try to get the local symbol if we're dealing with an 'export default' + // since that symbol has the "true" name. + var localExportDefaultSymbol = ts.getLocalSymbolForExportDefault(symbol); + symbol = localExportDefaultSymbol || symbol; + return ts.stripQuotes(symbol.name); + } + /** + * Determines the smallest scope in which a symbol may have named references. + * Note that not every construct has been accounted for. This function can + * probably be improved. + * + * @returns undefined if the scope cannot be determined, implying that + * a reference to a symbol can occur anywhere. + */ + function getSymbolScope(symbol) { + // 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 === 173 /* FunctionExpression */ || valueDeclaration.kind === 186 /* ClassExpression */)) { + return valueDeclaration; + } + // If this is private property or method, the scope is the containing class + if (symbol.flags & (4 /* Property */ | 8192 /* Method */)) { + var privateDeclaration = ts.forEach(symbol.getDeclarations(), function (d) { return (d.flags & 32 /* Private */) ? d : undefined; }); + if (privateDeclaration) { + return ts.getAncestor(privateDeclaration, 214 /* ClassDeclaration */); + } + } + // If the symbol is an import we would like to find it if we are looking for what it imports. + // So consider it visibile outside its declaration scope. + if (symbol.flags & 8388608 /* Alias */) { + return undefined; + } + // if this symbol is visible from its parent container, e.g. exported, then bail out + // if symbol correspond to the union property - bail out + if (symbol.parent || (symbol.flags & 268435456 /* SyntheticProperty */)) { + return undefined; + } + var scope = undefined; + var declarations = symbol.getDeclarations(); + if (declarations) { + for (var _i = 0; _i < declarations.length; _i++) { + var declaration = declarations[_i]; + var container = getContainerNode(declaration); + if (!container) { + return undefined; + } + if (scope && scope !== container) { + // Different declarations have different containers, bail out + return undefined; + } + if (container.kind === 248 /* SourceFile */ && !ts.isExternalModule(container)) { + // This is a global variable and not an external module, any declaration defined + // within this scope is visible outside the file + return undefined; + } + // The search scope is the container node + scope = container; + } + } + return scope; + } + function getPossibleSymbolReferencePositions(sourceFile, symbolName, start, end) { + var positions = []; + /// TODO: Cache symbol existence for files to save text search + // Also, need to make this work for unicode escapes. + // Be resilient in the face of a symbol with no name or zero length name + if (!symbolName || !symbolName.length) { + return positions; + } + var text = sourceFile.text; + var sourceLength = text.length; + var symbolNameLength = symbolName.length; + var position = text.indexOf(symbolName, start); + while (position >= 0) { + cancellationToken.throwIfCancellationRequested(); + // If we are past the end, stop looking + if (position > end) + break; + // 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 */))) { + // Found a real match. Keep searching. + positions.push(position); + } + position = text.indexOf(symbolName, position + symbolNameLength + 1); + } + return positions; + } + function getLabelReferencesInNode(container, targetLabel) { + var references = []; + var sourceFile = container.getSourceFile(); + var labelName = targetLabel.text; + var possiblePositions = getPossibleSymbolReferencePositions(sourceFile, labelName, container.getStart(), container.getEnd()); + ts.forEach(possiblePositions, function (position) { + cancellationToken.throwIfCancellationRequested(); + var node = ts.getTouchingWord(sourceFile, position); + if (!node || node.getWidth() !== labelName.length) { + return; + } + // Only pick labels that are either the target label, or have a target that is the target label + if (node === targetLabel || + (isJumpStatementTarget(node) && getTargetLabel(node, labelName) === targetLabel)) { + references.push(getReferenceEntryFromNode(node)); + } + }); + var definition = { + containerKind: "", + containerName: "", + fileName: targetLabel.getSourceFile().fileName, + kind: ScriptElementKind.label, + name: labelName, + textSpan: ts.createTextSpanFromBounds(targetLabel.getStart(), targetLabel.getEnd()) + }; + return [{ definition: definition, references: references }]; + } + function isValidReferencePosition(node, searchSymbolName) { + if (node) { + // Compare the length so we filter out strict superstrings of the symbol we are looking for + switch (node.kind) { + case 69 /* Identifier */: + return node.getWidth() === searchSymbolName.length; + case 9 /* StringLiteral */: + if (isLiteralNameOfPropertyDeclarationOrIndexAccess(node) || + isNameOfExternalModuleImportOrDeclaration(node)) { + // For string literals we have two additional chars for the quotes + return node.getWidth() === searchSymbolName.length + 2; + } + break; + case 8 /* NumericLiteral */: + if (isLiteralNameOfPropertyDeclarationOrIndexAccess(node)) { + return node.getWidth() === searchSymbolName.length; + } + break; + } + } + return false; + } + /** Search within node "container" for references for a search value, where the search value is defined as a + * tuple of(searchSymbol, searchText, searchLocation, and searchMeaning). + * searchLocation: a node where the search value + */ + function getReferencesInNode(container, searchSymbol, searchText, searchLocation, searchMeaning, findInStrings, findInComments, result, symbolToIndex) { + var sourceFile = container.getSourceFile(); + var tripleSlashDirectivePrefixRegex = /^\/\/\/\s*= 0) { + var referencedSymbol = getReferencedSymbol(shorthandValueSymbol); + referencedSymbol.references.push(getReferenceEntryFromNode(referenceSymbolDeclaration.name)); + } + } + }); + } + return; + function getReferencedSymbol(symbol) { + var symbolId = ts.getSymbolId(symbol); + var index = symbolToIndex[symbolId]; + if (index === undefined) { + index = result.length; + symbolToIndex[symbolId] = index; + result.push({ + definition: getDefinition(symbol), + references: [] + }); + } + return result[index]; + } + function isInNonReferenceComment(sourceFile, position) { + return ts.isInCommentHelper(sourceFile, position, isNonReferenceComment); + function isNonReferenceComment(c) { + var commentText = sourceFile.text.substring(c.pos, c.end); + return !tripleSlashDirectivePrefixRegex.test(commentText); + } + } + } + function getReferencesForSuperKeyword(superKeyword) { + var searchSpaceNode = ts.getSuperContainer(superKeyword, /*includeFunctions*/ false); + if (!searchSpaceNode) { + return undefined; + } + // Whether 'super' occurs in a static context within a class. + var staticFlag = 128 /* Static */; + switch (searchSpaceNode.kind) { + case 141 /* PropertyDeclaration */: + case 140 /* PropertySignature */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: + case 144 /* Constructor */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: + staticFlag &= searchSpaceNode.flags; + searchSpaceNode = searchSpaceNode.parent; // re-assign to be the owning class + break; + default: + return undefined; + } + var references = []; + var sourceFile = searchSpaceNode.getSourceFile(); + var possiblePositions = getPossibleSymbolReferencePositions(sourceFile, "super", searchSpaceNode.getStart(), searchSpaceNode.getEnd()); + ts.forEach(possiblePositions, function (position) { + cancellationToken.throwIfCancellationRequested(); + var node = ts.getTouchingWord(sourceFile, position); + if (!node || node.kind !== 95 /* SuperKeyword */) { + return; + } + var container = ts.getSuperContainer(node, /*includeFunctions*/ false); + // If we have a 'super' container, we must have an enclosing class. + // Now make sure the owning class is the same as the search-space + // and has the same static qualifier as the original 'super's owner. + if (container && (128 /* Static */ & container.flags) === staticFlag && container.parent.symbol === searchSpaceNode.symbol) { + references.push(getReferenceEntryFromNode(node)); + } + }); + var definition = getDefinition(searchSpaceNode.symbol); + return [{ definition: definition, references: references }]; + } + function getReferencesForThisKeyword(thisOrSuperKeyword, sourceFiles) { + var searchSpaceNode = ts.getThisContainer(thisOrSuperKeyword, /* includeArrowFunctions */ false); + // Whether 'this' occurs in a static context within a class. + var staticFlag = 128 /* Static */; + switch (searchSpaceNode.kind) { + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: + if (ts.isObjectLiteralMethod(searchSpaceNode)) { + break; + } + // fall through + case 141 /* PropertyDeclaration */: + case 140 /* PropertySignature */: + case 144 /* Constructor */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: + staticFlag &= searchSpaceNode.flags; + searchSpaceNode = searchSpaceNode.parent; // re-assign to be the owning class + break; + case 248 /* SourceFile */: + if (ts.isExternalModule(searchSpaceNode)) { + return undefined; + } + // Fall through + case 213 /* FunctionDeclaration */: + case 173 /* FunctionExpression */: + break; + // Computed properties in classes are not handled here because references to this are illegal, + // so there is no point finding references to them. + default: + return undefined; + } + var references = []; + var possiblePositions; + if (searchSpaceNode.kind === 248 /* SourceFile */) { + ts.forEach(sourceFiles, function (sourceFile) { + possiblePositions = getPossibleSymbolReferencePositions(sourceFile, "this", sourceFile.getStart(), sourceFile.getEnd()); + getThisReferencesInFile(sourceFile, sourceFile, possiblePositions, references); + }); + } + else { + var sourceFile = searchSpaceNode.getSourceFile(); + possiblePositions = getPossibleSymbolReferencePositions(sourceFile, "this", searchSpaceNode.getStart(), searchSpaceNode.getEnd()); + getThisReferencesInFile(sourceFile, searchSpaceNode, possiblePositions, references); + } + return [{ + definition: { + containerKind: "", + containerName: "", + fileName: node.getSourceFile().fileName, + kind: ScriptElementKind.variableElement, + name: "this", + textSpan: ts.createTextSpanFromBounds(node.getStart(), node.getEnd()) + }, + references: references + }]; + function getThisReferencesInFile(sourceFile, searchSpaceNode, possiblePositions, result) { + ts.forEach(possiblePositions, function (position) { + cancellationToken.throwIfCancellationRequested(); + var node = ts.getTouchingWord(sourceFile, position); + if (!node || node.kind !== 97 /* ThisKeyword */) { + return; + } + var container = ts.getThisContainer(node, /* includeArrowFunctions */ false); + switch (searchSpaceNode.kind) { + case 173 /* FunctionExpression */: + case 213 /* FunctionDeclaration */: + if (searchSpaceNode.symbol === container.symbol) { + result.push(getReferenceEntryFromNode(node)); + } + break; + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: + if (ts.isObjectLiteralMethod(searchSpaceNode) && searchSpaceNode.symbol === container.symbol) { + result.push(getReferenceEntryFromNode(node)); + } + break; + case 186 /* ClassExpression */: + case 214 /* ClassDeclaration */: + // Make sure the container belongs to the same class + // and has the appropriate static modifier from the original container. + if (container.parent && searchSpaceNode.symbol === container.parent.symbol && (container.flags & 128 /* Static */) === staticFlag) { + result.push(getReferenceEntryFromNode(node)); + } + break; + case 248 /* SourceFile */: + if (container.kind === 248 /* SourceFile */ && !ts.isExternalModule(container)) { + result.push(getReferenceEntryFromNode(node)); + } + break; + } + }); + } + } + function populateSearchSymbolSet(symbol, location) { + // The search set contains at least the current symbol + var result = [symbol]; + // If the symbol is an alias, add what it alaises to the list + if (isImportOrExportSpecifierImportSymbol(symbol)) { + result.push(typeChecker.getAliasedSymbol(symbol)); + } + // If the location is in a context sensitive location (i.e. in an object literal) try + // to get a contextual type for it, and add the property symbol from the contextual + // type to the search set + if (isNameOfPropertyAssignment(location)) { + ts.forEach(getPropertySymbolsFromContextualType(location), function (contextualSymbol) { + ts.addRange(result, typeChecker.getRootSymbols(contextualSymbol)); + }); + /* Because in short-hand property assignment, location has two meaning : property name and as value of the property + * When we do findAllReference at the position of the short-hand property assignment, we would want to have references to position of + * property name and variable declaration of the identifier. + * Like in below example, when querying for all references for an identifier 'name', of the property assignment, the language service + * should show both 'name' in 'obj' and 'name' in variable declaration + * let name = "Foo"; + * let obj = { name }; + * In order to do that, we will populate the search set with the value symbol of the identifier as a value of the property assignment + * so that when matching with potential reference symbol, both symbols from property declaration and variable declaration + * will be included correctly. + */ + var shorthandValueSymbol = typeChecker.getShorthandAssignmentValueSymbol(location.parent); + if (shorthandValueSymbol) { + result.push(shorthandValueSymbol); + } + } + // If this is a union property, add all the symbols from all its source symbols in all unioned types. + // If the symbol is an instantiation from a another symbol (e.g. widened symbol) , add the root the list + ts.forEach(typeChecker.getRootSymbols(symbol), function (rootSymbol) { + if (rootSymbol !== symbol) { + result.push(rootSymbol); + } + // Add symbol of properties/methods of the same name in base classes and implemented interfaces definitions + if (rootSymbol.parent && rootSymbol.parent.flags & (32 /* Class */ | 64 /* Interface */)) { + getPropertySymbolsFromBaseTypes(rootSymbol.parent, rootSymbol.getName(), result); + } + }); + return result; + } + function getPropertySymbolsFromBaseTypes(symbol, propertyName, result) { + if (symbol && symbol.flags & (32 /* Class */ | 64 /* Interface */)) { + ts.forEach(symbol.getDeclarations(), function (declaration) { + if (declaration.kind === 214 /* ClassDeclaration */) { + getPropertySymbolFromTypeReference(ts.getClassExtendsHeritageClauseElement(declaration)); + ts.forEach(ts.getClassImplementsHeritageClauseElements(declaration), getPropertySymbolFromTypeReference); + } + else if (declaration.kind === 215 /* InterfaceDeclaration */) { + ts.forEach(ts.getInterfaceBaseTypeNodes(declaration), getPropertySymbolFromTypeReference); + } + }); + } + return; + function getPropertySymbolFromTypeReference(typeReference) { + if (typeReference) { + var type = typeChecker.getTypeAtLocation(typeReference); + if (type) { + var propertySymbol = typeChecker.getPropertyOfType(type, propertyName); + if (propertySymbol) { + result.push(propertySymbol); + } + // Visit the typeReference as well to see if it directly or indirectly use that property + getPropertySymbolsFromBaseTypes(type.symbol, propertyName, result); + } + } + } + } + function getRelatedSymbol(searchSymbols, referenceSymbol, referenceLocation) { + if (searchSymbols.indexOf(referenceSymbol) >= 0) { + return referenceSymbol; + } + // If the reference symbol is an alias, check if what it is aliasing is one of the search + // symbols. + if (isImportOrExportSpecifierImportSymbol(referenceSymbol)) { + var aliasedSymbol = typeChecker.getAliasedSymbol(referenceSymbol); + if (searchSymbols.indexOf(aliasedSymbol) >= 0) { + return aliasedSymbol; + } + } + // If the reference location is in an object literal, try to get the contextual type for the + // object literal, lookup the property symbol in the contextual type, and use this symbol to + // compare to our searchSymbol + if (isNameOfPropertyAssignment(referenceLocation)) { + return ts.forEach(getPropertySymbolsFromContextualType(referenceLocation), function (contextualSymbol) { + return ts.forEach(typeChecker.getRootSymbols(contextualSymbol), function (s) { return searchSymbols.indexOf(s) >= 0 ? s : undefined; }); + }); + } + // Unwrap symbols to get to the root (e.g. transient symbols as a result of widening) + // Or a union property, use its underlying unioned symbols + return ts.forEach(typeChecker.getRootSymbols(referenceSymbol), function (rootSymbol) { + // if it is in the list, then we are done + if (searchSymbols.indexOf(rootSymbol) >= 0) { + return rootSymbol; + } + // Finally, try all properties with the same name in any type the containing type extended or implemented, and + // see if any is in the list + if (rootSymbol.parent && rootSymbol.parent.flags & (32 /* Class */ | 64 /* Interface */)) { + var result_3 = []; + getPropertySymbolsFromBaseTypes(rootSymbol.parent, rootSymbol.getName(), result_3); + return ts.forEach(result_3, function (s) { return searchSymbols.indexOf(s) >= 0 ? s : undefined; }); + } + return undefined; + }); + } + function getPropertySymbolsFromContextualType(node) { + if (isNameOfPropertyAssignment(node)) { + var objectLiteral = node.parent.parent; + var contextualType = typeChecker.getContextualType(objectLiteral); + var name_35 = node.text; + if (contextualType) { + if (contextualType.flags & 16384 /* Union */) { + // This is a union type, first see if the property we are looking for is a union property (i.e. exists in all types) + // if not, search the constituent types for the property + var unionProperty = contextualType.getProperty(name_35); + if (unionProperty) { + return [unionProperty]; + } + else { + var result_4 = []; + ts.forEach(contextualType.types, function (t) { + var symbol = t.getProperty(name_35); + if (symbol) { + result_4.push(symbol); + } + }); + return result_4; + } + } + else { + var symbol_1 = contextualType.getProperty(name_35); + if (symbol_1) { + return [symbol_1]; + } + } + } + } + return undefined; + } + /** Given an initial searchMeaning, extracted from a location, widen the search scope based on the declarations + * of the corresponding symbol. e.g. if we are searching for "Foo" in value position, but "Foo" references a class + * then we need to widen the search to include type positions as well. + * On the contrary, if we are searching for "Bar" in type position and we trace bar to an interface, and an uninstantiated + * module, we want to keep the search limited to only types, as the two declarations (interface and uninstantiated module) + * do not intersect in any of the three spaces. + */ + function getIntersectingMeaningFromDeclarations(meaning, declarations) { + if (declarations) { + var lastIterationMeaning; + do { + // The result is order-sensitive, for instance if initialMeaning === Namespace, and declarations = [class, instantiated module] + // we need to consider both as they initialMeaning intersects with the module in the namespace space, and the module + // intersects with the class in the value space. + // To achieve that we will keep iterating until the result stabilizes. + // Remember the last meaning + lastIterationMeaning = meaning; + for (var _i = 0; _i < declarations.length; _i++) { + var declaration = declarations[_i]; + var declarationMeaning = getMeaningFromDeclaration(declaration); + if (declarationMeaning & meaning) { + meaning |= declarationMeaning; + } + } + } while (meaning !== lastIterationMeaning); + } + return meaning; + } + } + function getReferenceEntryFromNode(node) { + var start = node.getStart(); + var end = node.getEnd(); + if (node.kind === 9 /* StringLiteral */) { + start += 1; + end -= 1; + } + return { + fileName: node.getSourceFile().fileName, + textSpan: ts.createTextSpanFromBounds(start, end), + isWriteAccess: isWriteAccess(node) + }; + } + /** 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)) { + return true; + } + var parent = node.parent; + if (parent) { + if (parent.kind === 180 /* PostfixUnaryExpression */ || parent.kind === 179 /* PrefixUnaryExpression */) { + return true; + } + else if (parent.kind === 181 /* BinaryExpression */ && parent.left === node) { + var operator = parent.operatorToken.kind; + return 56 /* FirstAssignment */ <= operator && operator <= 68 /* LastAssignment */; + } + } + return false; + } + /// NavigateTo + function getNavigateToItems(searchValue, maxResultCount) { + synchronizeHostData(); + return ts.NavigateTo.getNavigateToItems(program, cancellationToken, searchValue, maxResultCount); + } + function containErrors(diagnostics) { + return ts.forEach(diagnostics, function (diagnostic) { return diagnostic.category === ts.DiagnosticCategory.Error; }); + } + function getEmitOutput(fileName) { + synchronizeHostData(); + var sourceFile = getValidSourceFile(fileName); + var outputFiles = []; + function writeFile(fileName, data, writeByteOrderMark) { + outputFiles.push({ + name: fileName, + writeByteOrderMark: writeByteOrderMark, + text: data + }); + } + var emitOutput = program.emit(sourceFile, writeFile, cancellationToken); + return { + outputFiles: outputFiles, + emitSkipped: emitOutput.emitSkipped + }; + } + function getMeaningFromDeclaration(node) { + switch (node.kind) { + case 138 /* Parameter */: + case 211 /* VariableDeclaration */: + case 163 /* BindingElement */: + case 141 /* PropertyDeclaration */: + case 140 /* PropertySignature */: + case 245 /* PropertyAssignment */: + case 246 /* ShorthandPropertyAssignment */: + case 247 /* EnumMember */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: + case 144 /* Constructor */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: + case 213 /* FunctionDeclaration */: + case 173 /* FunctionExpression */: + case 174 /* ArrowFunction */: + case 244 /* CatchClause */: + return 1 /* Value */; + case 137 /* TypeParameter */: + case 215 /* InterfaceDeclaration */: + case 216 /* TypeAliasDeclaration */: + case 155 /* TypeLiteral */: + return 2 /* Type */; + case 214 /* ClassDeclaration */: + case 217 /* EnumDeclaration */: + return 1 /* Value */ | 2 /* Type */; + case 218 /* ModuleDeclaration */: + if (node.name.kind === 9 /* StringLiteral */) { + return 4 /* Namespace */ | 1 /* Value */; + } + else if (ts.getModuleInstanceState(node) === 1 /* Instantiated */) { + return 4 /* Namespace */ | 1 /* Value */; + } + else { + return 4 /* Namespace */; + } + case 225 /* NamedImports */: + case 226 /* ImportSpecifier */: + case 221 /* ImportEqualsDeclaration */: + case 222 /* ImportDeclaration */: + case 227 /* ExportAssignment */: + case 228 /* ExportDeclaration */: + return 1 /* Value */ | 2 /* Type */ | 4 /* Namespace */; + // An external module can be a Value + case 248 /* SourceFile */: + return 4 /* Namespace */ | 1 /* Value */; + } + return 1 /* Value */ | 2 /* Type */ | 4 /* Namespace */; + ts.Debug.fail("Unknown declaration type"); + } + function isTypeReference(node) { + if (ts.isRightSideOfQualifiedNameOrPropertyAccess(node)) { + node = node.parent; + } + return node.parent.kind === 151 /* TypeReference */ || + (node.parent.kind === 188 /* ExpressionWithTypeArguments */ && !ts.isExpressionWithTypeArgumentsInClassExtendsClause(node.parent)) || + node.kind === 97 /* ThisKeyword */ && !ts.isExpression(node); + } + function isNamespaceReference(node) { + return isQualifiedNameNamespaceReference(node) || isPropertyAccessNamespaceReference(node); + } + function isPropertyAccessNamespaceReference(node) { + var root = node; + var isLastClause = true; + if (root.parent.kind === 166 /* PropertyAccessExpression */) { + while (root.parent && root.parent.kind === 166 /* PropertyAccessExpression */) { + root = root.parent; + } + isLastClause = root.name === node; + } + if (!isLastClause && root.parent.kind === 188 /* ExpressionWithTypeArguments */ && root.parent.parent.kind === 243 /* HeritageClause */) { + var decl = root.parent.parent.parent; + return (decl.kind === 214 /* ClassDeclaration */ && root.parent.parent.token === 106 /* ImplementsKeyword */) || + (decl.kind === 215 /* InterfaceDeclaration */ && root.parent.parent.token === 83 /* ExtendsKeyword */); + } + return false; + } + function isQualifiedNameNamespaceReference(node) { + var root = node; + var isLastClause = true; + if (root.parent.kind === 135 /* QualifiedName */) { + while (root.parent && root.parent.kind === 135 /* QualifiedName */) { + root = root.parent; + } + isLastClause = root.right === node; + } + return root.parent.kind === 151 /* TypeReference */ && !isLastClause; + } + function isInRightSideOfImport(node) { + while (node.parent.kind === 135 /* QualifiedName */) { + node = node.parent; + } + return ts.isInternalModuleImportEqualsDeclaration(node.parent) && node.parent.moduleReference === node; + } + function getMeaningFromRightHandSideOfImportEquals(node) { + ts.Debug.assert(node.kind === 69 /* Identifier */); + // import a = |b|; // Namespace + // import a = |b.c|; // Value, type, namespace + // import a = |b.c|.d; // Namespace + if (node.parent.kind === 135 /* QualifiedName */ && + node.parent.right === node && + node.parent.parent.kind === 221 /* ImportEqualsDeclaration */) { + return 1 /* Value */ | 2 /* Type */ | 4 /* Namespace */; + } + return 4 /* Namespace */; + } + function getMeaningFromLocation(node) { + if (node.parent.kind === 227 /* ExportAssignment */) { + return 1 /* Value */ | 2 /* Type */ | 4 /* Namespace */; + } + else if (isInRightSideOfImport(node)) { + return getMeaningFromRightHandSideOfImportEquals(node); + } + else if (ts.isDeclarationName(node)) { + return getMeaningFromDeclaration(node.parent); + } + else if (isTypeReference(node)) { + return 2 /* Type */; + } + else if (isNamespaceReference(node)) { + return 4 /* Namespace */; + } + else { + return 1 /* Value */; + } + } + // Signature help + /** + * This is a semantic operation. + */ + function getSignatureHelpItems(fileName, position) { + synchronizeHostData(); + var sourceFile = getValidSourceFile(fileName); + return ts.SignatureHelp.getSignatureHelpItems(program, sourceFile, position, cancellationToken); + } + /// Syntactic features + function getSourceFile(fileName) { + return syntaxTreeCache.getCurrentSourceFile(fileName); + } + function getNameOrDottedNameSpan(fileName, startPos, endPos) { + var sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName); + // Get node at the location + var node = ts.getTouchingPropertyName(sourceFile, startPos); + if (!node) { + return; + } + switch (node.kind) { + case 166 /* PropertyAccessExpression */: + case 135 /* QualifiedName */: + case 9 /* StringLiteral */: + case 84 /* FalseKeyword */: + case 99 /* TrueKeyword */: + case 93 /* NullKeyword */: + case 95 /* SuperKeyword */: + case 97 /* ThisKeyword */: + case 69 /* Identifier */: + break; + // Cant create the text span + default: + return; + } + var nodeForStartPos = node; + while (true) { + if (isRightSideOfPropertyAccess(nodeForStartPos) || isRightSideOfQualifiedName(nodeForStartPos)) { + // If on the span is in right side of the the property or qualified name, return the span from the qualified name pos to end of this node + nodeForStartPos = nodeForStartPos.parent; + } + else if (isNameOfModuleDeclaration(nodeForStartPos)) { + // 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 === 218 /* ModuleDeclaration */ && + nodeForStartPos.parent.parent.body === nodeForStartPos.parent) { + // Use parent module declarations name for start pos + nodeForStartPos = nodeForStartPos.parent.parent.name; + } + else { + // We have to use this name for start pos + break; + } + } + else { + // Is not a member expression so we have found the node for start pos + break; + } + } + return ts.createTextSpanFromBounds(nodeForStartPos.getStart(), node.getEnd()); + } + function getBreakpointStatementAtPosition(fileName, position) { + // doesn't use compiler - no need to synchronize with host + var sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName); + return ts.BreakpointResolver.spanInSourceFileAtLocation(sourceFile, position); + } + function getNavigationBarItems(fileName) { + var sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName); + return ts.NavigationBar.getNavigationBarItems(sourceFile); + } + function getSemanticClassifications(fileName, span) { + return convertClassifications(getEncodedSemanticClassifications(fileName, span)); + } + function checkForClassificationCancellation(kind) { + // We don't want to actually call back into our host on every node to find out if we've + // been canceled. That would be an enormous amount of chattyness, along with the all + // the overhead of marshalling the data to/from the host. So instead we pick a few + // reasonable node kinds to bother checking on. These node kinds represent high level + // constructs that we would expect to see commonly, but just at a far less frequent + // interval. + // + // For example, in checker.ts (around 750k) we only have around 600 of these constructs. + // 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 218 /* ModuleDeclaration */: + case 214 /* ClassDeclaration */: + case 215 /* InterfaceDeclaration */: + case 213 /* FunctionDeclaration */: + cancellationToken.throwIfCancellationRequested(); + } + } + function getEncodedSemanticClassifications(fileName, span) { + synchronizeHostData(); + var sourceFile = getValidSourceFile(fileName); + var typeChecker = program.getTypeChecker(); + var result = []; + var classifiableNames = program.getClassifiableNames(); + processNode(sourceFile); + return { spans: result, endOfLineState: 0 /* None */ }; + function pushClassification(start, length, type) { + result.push(start); + result.push(length); + result.push(type); + } + function classifySymbol(symbol, meaningAtPosition) { + var flags = symbol.getFlags(); + if ((flags & 788448 /* Classifiable */) === 0 /* None */) { + return; + } + if (flags & 32 /* Class */) { + return 11 /* className */; + } + else if (flags & 384 /* Enum */) { + return 12 /* enumName */; + } + else if (flags & 524288 /* TypeAlias */) { + return 16 /* typeAliasName */; + } + else if (meaningAtPosition & 2 /* Type */) { + if (flags & 64 /* Interface */) { + return 13 /* interfaceName */; + } + else if (flags & 262144 /* TypeParameter */) { + return 15 /* typeParameterName */; + } + } + else if (flags & 1536 /* Module */) { + // Only classify a module as such if + // - It appears in a namespace context. + // - There exists a module declaration which actually impacts the value side. + if (meaningAtPosition & 4 /* Namespace */ || + (meaningAtPosition & 1 /* Value */ && hasValueSideModule(symbol))) { + return 14 /* moduleName */; + } + } + return undefined; + /** + * Returns true if there exists a module that introduces entities on the value side. + */ + function hasValueSideModule(symbol) { + return ts.forEach(symbol.declarations, function (declaration) { + return declaration.kind === 218 /* ModuleDeclaration */ && + ts.getModuleInstanceState(declaration) === 1 /* Instantiated */; + }); + } + } + function processNode(node) { + // Only walk into nodes that intersect the requested span. + if (node && ts.textSpanIntersectsWith(span, node.getFullStart(), node.getFullWidth())) { + var kind = node.kind; + checkForClassificationCancellation(kind); + if (kind === 69 /* Identifier */ && !ts.nodeIsMissing(node)) { + var identifier = node; + // Only bother calling into the typechecker if this is an identifier that + // could possibly resolve to a type name. This makes classification run + // in a third of the time it would normally take. + if (classifiableNames[identifier.text]) { + var symbol = typeChecker.getSymbolAtLocation(node); + if (symbol) { + var type = classifySymbol(symbol, getMeaningFromLocation(node)); + if (type) { + pushClassification(node.getStart(), node.getWidth(), type); + } + } + } + } + ts.forEachChild(node, processNode); + } + } + } + function getClassificationTypeName(type) { + switch (type) { + case 1 /* comment */: return ClassificationTypeNames.comment; + case 2 /* identifier */: return ClassificationTypeNames.identifier; + case 3 /* keyword */: return ClassificationTypeNames.keyword; + case 4 /* numericLiteral */: return ClassificationTypeNames.numericLiteral; + case 5 /* operator */: return ClassificationTypeNames.operator; + case 6 /* stringLiteral */: return ClassificationTypeNames.stringLiteral; + case 8 /* whiteSpace */: return ClassificationTypeNames.whiteSpace; + case 9 /* text */: return ClassificationTypeNames.text; + case 10 /* punctuation */: return ClassificationTypeNames.punctuation; + case 11 /* className */: return ClassificationTypeNames.className; + case 12 /* enumName */: return ClassificationTypeNames.enumName; + case 13 /* interfaceName */: return ClassificationTypeNames.interfaceName; + case 14 /* moduleName */: return ClassificationTypeNames.moduleName; + case 15 /* typeParameterName */: return ClassificationTypeNames.typeParameterName; + case 16 /* typeAliasName */: return ClassificationTypeNames.typeAliasName; + case 17 /* parameterName */: return ClassificationTypeNames.parameterName; + case 18 /* docCommentTagName */: return ClassificationTypeNames.docCommentTagName; + } + } + function convertClassifications(classifications) { + ts.Debug.assert(classifications.spans.length % 3 === 0); + var dense = classifications.spans; + var result = []; + for (var i = 0, n = dense.length; i < n; i += 3) { + result.push({ + textSpan: ts.createTextSpan(dense[i], dense[i + 1]), + classificationType: getClassificationTypeName(dense[i + 2]) + }); + } + return result; + } + function getSyntacticClassifications(fileName, span) { + return convertClassifications(getEncodedSyntacticClassifications(fileName, span)); + } + function getEncodedSyntacticClassifications(fileName, span) { + // doesn't use compiler - no need to synchronize with host + var sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName); + 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 result = []; + processElement(sourceFile); + return { spans: result, endOfLineState: 0 /* None */ }; + function pushClassification(start, length, type) { + result.push(start); + result.push(length); + result.push(type); + } + function classifyLeadingTriviaAndGetTokenStart(token) { + triviaScanner.setTextPos(token.pos); + while (true) { + var start = triviaScanner.getTextPos(); + // only bother scanning if we have something that could be trivia. + if (!ts.couldStartTrivia(sourceFile.text, start)) { + return start; + } + var kind = triviaScanner.scan(); + var end = triviaScanner.getTextPos(); + var width = end - start; + // The moment we get something that isn't trivia, then stop processing. + if (!ts.isTrivia(kind)) { + return start; + } + // Don't bother with newlines/whitespace. + if (kind === 4 /* NewLineTrivia */ || kind === 5 /* WhitespaceTrivia */) { + continue; + } + // Only bother with the trivia if it at least intersects the span of interest. + if (ts.isComment(kind)) { + classifyComment(token, kind, start, width); + // Classifying a comment might cause us to reuse the trivia scanner + // (because of jsdoc comments). So after we classify the comment make + // sure we set the scanner position back to where it needs to be. + triviaScanner.setTextPos(end); + continue; + } + if (kind === 7 /* ConflictMarkerTrivia */) { + var text = sourceFile.text; + var ch = text.charCodeAt(start); + // for the <<<<<<< and >>>>>>> markers, we just add them in as comments + // in the classification stream. + if (ch === 60 /* lessThan */ || ch === 62 /* greaterThan */) { + pushClassification(start, width, 1 /* comment */); + continue; + } + // for the ======== add a comment for the first line, and then lex all + // subsequent lines up until the end of the conflict marker. + ts.Debug.assert(ch === 61 /* equals */); + classifyDisabledMergeCode(text, start, end); + } + } + } + function classifyComment(token, kind, start, width) { + if (kind === 3 /* MultiLineCommentTrivia */) { + // See if this is a doc comment. If so, we'll classify certain portions of it + // specially. + var docCommentAndDiagnostics = ts.parseIsolatedJSDocComment(sourceFile.text, start, width); + if (docCommentAndDiagnostics && docCommentAndDiagnostics.jsDocComment) { + docCommentAndDiagnostics.jsDocComment.parent = token; + classifyJSDocComment(docCommentAndDiagnostics.jsDocComment); + return; + } + } + // Simple comment. Just add as is. + pushCommentRange(start, width); + } + function pushCommentRange(start, width) { + pushClassification(start, width, 1 /* comment */); + } + function classifyJSDocComment(docComment) { + var pos = docComment.pos; + for (var _i = 0, _a = docComment.tags; _i < _a.length; _i++) { + var tag = _a[_i]; + // As we walk through each tag, classify the portion of text from the end of + // the last tag (or the start of the entire doc comment) as 'comment'. + if (tag.pos !== pos) { + pushCommentRange(pos, tag.pos - pos); + } + pushClassification(tag.atToken.pos, tag.atToken.end - tag.atToken.pos, 10 /* punctuation */); + pushClassification(tag.tagName.pos, tag.tagName.end - tag.tagName.pos, 18 /* docCommentTagName */); + pos = tag.tagName.end; + switch (tag.kind) { + case 267 /* JSDocParameterTag */: + processJSDocParameterTag(tag); + break; + case 270 /* JSDocTemplateTag */: + processJSDocTemplateTag(tag); + break; + case 269 /* JSDocTypeTag */: + processElement(tag.typeExpression); + break; + case 268 /* JSDocReturnTag */: + processElement(tag.typeExpression); + break; + } + pos = tag.end; + } + if (pos !== docComment.end) { + pushCommentRange(pos, docComment.end - pos); + } + return; + function processJSDocParameterTag(tag) { + if (tag.preParameterName) { + pushCommentRange(pos, tag.preParameterName.pos - pos); + pushClassification(tag.preParameterName.pos, tag.preParameterName.end - tag.preParameterName.pos, 17 /* parameterName */); + pos = tag.preParameterName.end; + } + if (tag.typeExpression) { + pushCommentRange(pos, tag.typeExpression.pos - pos); + processElement(tag.typeExpression); + pos = tag.typeExpression.end; + } + if (tag.postParameterName) { + pushCommentRange(pos, tag.postParameterName.pos - pos); + pushClassification(tag.postParameterName.pos, tag.postParameterName.end - tag.postParameterName.pos, 17 /* parameterName */); + pos = tag.postParameterName.end; + } + } + } + function processJSDocTemplateTag(tag) { + for (var _i = 0, _a = tag.getChildren(); _i < _a.length; _i++) { + var child = _a[_i]; + processElement(child); + } + } + function classifyDisabledMergeCode(text, start, end) { + // Classify the line that the ======= marker is on as a comment. Then just lex + // all further tokens and add them to the result. + for (var i = start; i < end; i++) { + if (ts.isLineBreak(text.charCodeAt(i))) { + break; + } + } + pushClassification(start, i - start, 1 /* comment */); + mergeConflictScanner.setTextPos(i); + while (mergeConflictScanner.getTextPos() < end) { + classifyDisabledCodeToken(); + } + } + function classifyDisabledCodeToken() { + var start = mergeConflictScanner.getTextPos(); + var tokenKind = mergeConflictScanner.scan(); + var end = mergeConflictScanner.getTextPos(); + var type = classifyTokenType(tokenKind); + if (type) { + pushClassification(start, end - start, type); + } + } + function classifyToken(token) { + if (ts.nodeIsMissing(token)) { + return; + } + var tokenStart = classifyLeadingTriviaAndGetTokenStart(token); + var tokenWidth = token.end - tokenStart; + ts.Debug.assert(tokenWidth >= 0); + if (tokenWidth > 0) { + var type = classifyTokenType(token.kind, token); + if (type) { + pushClassification(tokenStart, tokenWidth, type); + } + } + } + // for accurate classification, the actual token should be passed in. however, for + // cases like 'disabled merge code' classification, we just get the token kind and + // classify based on that instead. + function classifyTokenType(tokenKind, token) { + if (ts.isKeyword(tokenKind)) { + return 3 /* keyword */; + } + // Special case < and > If they appear in a generic context they are punctuation, + // not operators. + if (tokenKind === 25 /* LessThanToken */ || tokenKind === 27 /* 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)) { + return 10 /* punctuation */; + } + } + if (ts.isPunctuation(tokenKind)) { + if (token) { + if (tokenKind === 56 /* EqualsToken */) { + // the '=' in a variable declaration is special cased here. + if (token.parent.kind === 211 /* VariableDeclaration */ || + token.parent.kind === 141 /* PropertyDeclaration */ || + token.parent.kind === 138 /* Parameter */) { + return 5 /* operator */; + } + } + if (token.parent.kind === 181 /* BinaryExpression */ || + token.parent.kind === 179 /* PrefixUnaryExpression */ || + token.parent.kind === 180 /* PostfixUnaryExpression */ || + token.parent.kind === 182 /* ConditionalExpression */) { + return 5 /* operator */; + } + } + return 10 /* punctuation */; + } + else if (tokenKind === 8 /* NumericLiteral */) { + return 4 /* numericLiteral */; + } + else if (tokenKind === 9 /* StringLiteral */) { + return 6 /* stringLiteral */; + } + else if (tokenKind === 10 /* RegularExpressionLiteral */) { + // TODO: we should get another classification type for these literals. + return 6 /* stringLiteral */; + } + else if (ts.isTemplateLiteralKind(tokenKind)) { + // TODO (drosen): we should *also* get another classification type for these literals. + return 6 /* stringLiteral */; + } + else if (tokenKind === 69 /* Identifier */) { + if (token) { + switch (token.parent.kind) { + case 214 /* ClassDeclaration */: + if (token.parent.name === token) { + return 11 /* className */; + } + return; + case 137 /* TypeParameter */: + if (token.parent.name === token) { + return 15 /* typeParameterName */; + } + return; + case 215 /* InterfaceDeclaration */: + if (token.parent.name === token) { + return 13 /* interfaceName */; + } + return; + case 217 /* EnumDeclaration */: + if (token.parent.name === token) { + return 12 /* enumName */; + } + return; + case 218 /* ModuleDeclaration */: + if (token.parent.name === token) { + return 14 /* moduleName */; + } + return; + case 138 /* Parameter */: + if (token.parent.name === token) { + return 17 /* parameterName */; + } + return; + } + } + return 2 /* identifier */; + } + } + function processElement(element) { + if (!element) { + return; + } + // Ignore nodes that don't intersect the original span to classify. + if (ts.decodedTextSpanIntersectsWith(spanStart, spanLength, element.pos, element.getFullWidth())) { + checkForClassificationCancellation(element.kind); + var children = element.getChildren(sourceFile); + for (var i = 0, n = children.length; i < n; i++) { + var child = children[i]; + if (ts.isToken(child)) { + classifyToken(child); + } + else { + // Recurse into our child nodes. + processElement(child); + } + } + } + } + } + function getOutliningSpans(fileName) { + // doesn't use compiler - no need to synchronize with host + var sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName); + return ts.OutliningElementsCollector.collectElements(sourceFile); + } + function getBraceMatchingAtPosition(fileName, position) { + var sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName); + var result = []; + var token = ts.getTouchingToken(sourceFile, position); + if (token.getStart(sourceFile) === position) { + var matchKind = getMatchingTokenKind(token); + // Ensure that there is a corresponding token to match ours. + if (matchKind) { + var parentElement = token.parent; + var childNodes = parentElement.getChildren(sourceFile); + for (var _i = 0; _i < childNodes.length; _i++) { + var current = childNodes[_i]; + if (current.kind === matchKind) { + var range1 = ts.createTextSpan(token.getStart(sourceFile), token.getWidth(sourceFile)); + var range2 = ts.createTextSpan(current.getStart(sourceFile), current.getWidth(sourceFile)); + // We want to order the braces when we return the result. + if (range1.start < range2.start) { + result.push(range1, range2); + } + else { + result.push(range2, range1); + } + break; + } + } + } + } + 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 */; + } + return undefined; + } + } + function getIndentationAtPosition(fileName, position, editorOptions) { + var start = new Date().getTime(); + var sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName); + log("getIndentationAtPosition: getCurrentSourceFile: " + (new Date().getTime() - start)); + start = new Date().getTime(); + var result = ts.formatting.SmartIndenter.getIndentation(position, sourceFile, editorOptions); + log("getIndentationAtPosition: computeIndentation : " + (new Date().getTime() - start)); + return result; + } + function getFormattingEditsForRange(fileName, start, end, options) { + var sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName); + return ts.formatting.formatSelection(start, end, sourceFile, getRuleProvider(options), options); + } + function getFormattingEditsForDocument(fileName, options) { + var sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName); + return ts.formatting.formatDocument(sourceFile, getRuleProvider(options), options); + } + function getFormattingEditsAfterKeystroke(fileName, position, key, options) { + var sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName); + if (key === "}") { + return ts.formatting.formatOnClosingCurly(position, sourceFile, getRuleProvider(options), options); + } + else if (key === ";") { + return ts.formatting.formatOnSemicolon(position, sourceFile, getRuleProvider(options), options); + } + else if (key === "\n") { + return ts.formatting.formatOnEnter(position, sourceFile, getRuleProvider(options), options); + } + return []; + } + /** + * Checks if position points to a valid position to add JSDoc comments, and if so, + * returns the appropriate template. Otherwise returns an empty string. + * Valid positions are + * - outside of comments, statements, and expressions, and + * - preceding a: + * - function/constructor/method declaration + * - class declarations + * - variable statements + * - namespace declarations + * + * Hosts should ideally check that: + * - The line is all whitespace up to 'position' before performing the insertion. + * - If the keystroke sequence "/\*\*" induced the call, we also check that the next + * non-whitespace character is '*', which (approximately) indicates whether we added + * the second '*' to complete an existing (JSDoc) comment. + * @param fileName The file in which to perform the check. + * @param position The (character-indexed) position in the file where the check should + * be performed. + */ + function getDocCommentTemplateAtPosition(fileName, position) { + var start = new Date().getTime(); + var sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName); + // Check if in a context where we don't want to perform any insertion + if (ts.isInString(sourceFile, position) || ts.isInComment(sourceFile, position) || ts.hasDocComment(sourceFile, position)) { + return undefined; + } + var tokenAtPos = ts.getTokenAtPosition(sourceFile, position); + var tokenStart = tokenAtPos.getStart(); + if (!tokenAtPos || tokenStart < position) { + return undefined; + } + // TODO: add support for: + // - enums/enum members + // - interfaces + // - property declarations + // - potentially property assignments + var commentOwner; + findOwner: for (commentOwner = tokenAtPos; commentOwner; commentOwner = commentOwner.parent) { + switch (commentOwner.kind) { + case 213 /* FunctionDeclaration */: + case 143 /* MethodDeclaration */: + case 144 /* Constructor */: + case 214 /* ClassDeclaration */: + case 193 /* VariableStatement */: + break findOwner; + case 248 /* SourceFile */: + return undefined; + case 218 /* ModuleDeclaration */: + // If in walking up the tree, we hit a a nested namespace declaration, + // then we must be somewhere within a dotted namespace name; however we don't + // want to give back a JSDoc template for the 'b' or 'c' in 'namespace a.b.c { }'. + if (commentOwner.parent.kind === 218 /* ModuleDeclaration */) { + return undefined; + } + break findOwner; + } + } + if (!commentOwner || commentOwner.getStart() < position) { + return undefined; + } + var parameters = getParametersForJsDocOwningNode(commentOwner); + var posLineAndChar = sourceFile.getLineAndCharacterOfPosition(position); + var lineStart = sourceFile.getLineStarts()[posLineAndChar.line]; + var indentationStr = sourceFile.text.substr(lineStart, posLineAndChar.character); + // TODO: call a helper method instead once PR #4133 gets merged in. + var newLine = host.getNewLine ? host.getNewLine() : "\r\n"; + var docParams = ""; + for (var i = 0, numParams = parameters.length; i < numParams; i++) { + var currentName = parameters[i].name; + var paramName = currentName.kind === 69 /* Identifier */ ? + currentName.text : + "param" + i; + docParams += indentationStr + " * @param " + paramName + newLine; + } + // A doc comment consists of the following + // * The opening comment line + // * the first line (without a param) for the object's untagged info (this is also where the caret ends up) + // * the '@param'-tagged lines + // * TODO: other tags. + // * the closing comment line + // * if the caret was directly in front of the object, then we add an extra line and indentation. + var preamble = "/**" + newLine + + indentationStr + " * "; + var result = preamble + newLine + + docParams + + indentationStr + " */" + + (tokenStart === position ? newLine + indentationStr : ""); + return { newText: result, caretOffset: preamble.length }; + } + function getParametersForJsDocOwningNode(commentOwner) { + if (ts.isFunctionLike(commentOwner)) { + return commentOwner.parameters; + } + if (commentOwner.kind === 193 /* VariableStatement */) { + var varStatement = commentOwner; + var varDeclarations = varStatement.declarationList.declarations; + if (varDeclarations.length === 1 && varDeclarations[0].initializer) { + return getParametersFromRightHandSideOfAssignment(varDeclarations[0].initializer); + } + } + return emptyArray; + } + /** + * Digs into an an initializer or RHS operand of an assignment operation + * to get the parameters of an apt signature corresponding to a + * function expression or a class expression. + * + * @param rightHandSide the expression which may contain an appropriate set of parameters + * @returns the parameters of a signature found on the RHS if one exists; otherwise 'emptyArray'. + */ + function getParametersFromRightHandSideOfAssignment(rightHandSide) { + while (rightHandSide.kind === 172 /* ParenthesizedExpression */) { + rightHandSide = rightHandSide.expression; + } + switch (rightHandSide.kind) { + case 173 /* FunctionExpression */: + case 174 /* ArrowFunction */: + return rightHandSide.parameters; + case 186 /* ClassExpression */: + for (var _i = 0, _a = rightHandSide.members; _i < _a.length; _i++) { + var member = _a[_i]; + if (member.kind === 144 /* Constructor */) { + return member.parameters; + } + } + break; + } + return emptyArray; + } + function getTodoComments(fileName, descriptors) { + // Note: while getting todo comments seems like a syntactic operation, we actually + // treat it as a semantic operation here. This is because we expect our host to call + // this on every single file. If we treat this syntactically, then that will cause + // us to populate and throw away the tree in our syntax tree cache for each file. By + // treating this as a semantic operation, we can access any tree without throwing + // anything away. + synchronizeHostData(); + var sourceFile = getValidSourceFile(fileName); + cancellationToken.throwIfCancellationRequested(); + var fileContents = sourceFile.text; + var result = []; + if (descriptors.length > 0) { + var regExp = getTodoCommentsRegExp(); + var matchArray; + while (matchArray = regExp.exec(fileContents)) { + cancellationToken.throwIfCancellationRequested(); + // If we got a match, here is what the match array will look like. Say the source text is: + // + // " // hack 1" + // + // The result array with the regexp: will be: + // + // ["// hack 1", "// ", "hack 1", undefined, "hack"] + // + // Here are the relevant capture groups: + // 0) The full match for the entire regexp. + // 1) The preamble to the message portion. + // 2) The message portion. + // 3...N) The descriptor that was matched - by index. 'undefined' for each + // descriptor that didn't match. an actual value if it did match. + // + // i.e. 'undefined' in position 3 above means TODO(jason) didn't match. + // "hack" in position 4 means HACK did match. + var firstDescriptorCaptureIndex = 3; + ts.Debug.assert(matchArray.length === descriptors.length + firstDescriptorCaptureIndex); + var preamble = matchArray[1]; + var matchPosition = matchArray.index + preamble.length; + // OK, we have found a match in the file. This is only an acceptable match if + // it is contained within a comment. + var token = ts.getTokenAtPosition(sourceFile, matchPosition); + if (!isInsideComment(sourceFile, token, matchPosition)) { + continue; + } + var descriptor = undefined; + for (var i = 0, n = descriptors.length; i < n; i++) { + if (matchArray[i + firstDescriptorCaptureIndex]) { + descriptor = descriptors[i]; + } + } + ts.Debug.assert(descriptor !== undefined); + // We don't want to match something like 'TODOBY', so we make sure a non + // letter/digit follows the match. + if (isLetterOrDigit(fileContents.charCodeAt(matchPosition + descriptor.text.length))) { + continue; + } + var message = matchArray[2]; + result.push({ + descriptor: descriptor, + message: message, + position: matchPosition + }); + } + } + return result; + function escapeRegExp(str) { + return str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&"); + } + function getTodoCommentsRegExp() { + // NOTE: ?: means 'non-capture group'. It allows us to have groups without having to + // filter them out later in the final result array. + // TODO comments can appear in one of the following forms: + // + // 1) // TODO or /////////// TODO + // + // 2) /* TODO or /********** TODO + // + // 3) /* + // * TODO + // */ + // + // The following three regexps are used to match the start of the text up to the TODO + // comment portion. + var singleLineCommentStart = /(?:\/\/+\s*)/.source; + var multiLineCommentStart = /(?:\/\*+\s*)/.source; + var anyNumberOfSpacesAndAsterixesAtStartOfLine = /(?:^(?:\s|\*)*)/.source; + // Match any of the above three TODO comment start regexps. + // Note that the outermost group *is* a capture group. We want to capture the preamble + // so that we can determine the starting position of the TODO comment match. + var preamble = "(" + anyNumberOfSpacesAndAsterixesAtStartOfLine + "|" + singleLineCommentStart + "|" + multiLineCommentStart + ")"; + // Takes the descriptors and forms a regexp that matches them as if they were literals. + // For example, if the descriptors are "TODO(jason)" and "HACK", then this will be: + // + // (?:(TODO\(jason\))|(HACK)) + // + // Note that the outermost group is *not* a capture group, but the innermost groups + // *are* capture groups. By capturing the inner literals we can determine after + // matching which descriptor we are dealing with. + var literals = "(?:" + ts.map(descriptors, function (d) { return "(" + escapeRegExp(d.text) + ")"; }).join("|") + ")"; + // After matching a descriptor literal, the following regexp matches the rest of the + // text up to the end of the line (or */). + var endOfLineOrEndOfComment = /(?:$|\*\/)/.source; + var messageRemainder = /(?:.*?)/.source; + // This is the portion of the match we'll return as part of the TODO comment result. We + // match the literal portion up to the end of the line or end of comment. + var messagePortion = "(" + literals + messageRemainder + ")"; + var regExpString = preamble + messagePortion + endOfLineOrEndOfComment; + // The final regexp will look like this: + // /((?:\/\/+\s*)|(?:\/\*+\s*)|(?:^(?:\s|\*)*))((?:(TODO\(jason\))|(HACK))(?:.*?))(?:$|\*\/)/gim + // The flags of the regexp are important here. + // 'g' is so that we are doing a global search and can find matches several times + // in the input. + // + // 'i' is for case insensitivity (We do this to match C# TODO comment code). + // + // 'm' is so we can find matches in a multi-line input. + return new RegExp(regExpString, "gim"); + } + function isLetterOrDigit(char) { + return (char >= 97 /* a */ && char <= 122 /* z */) || + (char >= 65 /* A */ && char <= 90 /* Z */) || + (char >= 48 /* _0 */ && char <= 57 /* _9 */); + } + } + function getRenameInfo(fileName, position) { + synchronizeHostData(); + var sourceFile = getValidSourceFile(fileName); + var typeChecker = program.getTypeChecker(); + var node = ts.getTouchingWord(sourceFile, position); + // Can only rename an identifier. + if (node && node.kind === 69 /* Identifier */) { + var symbol = typeChecker.getSymbolAtLocation(node); + // Only allow a symbol to be renamed if it actually has at least one declaration. + if (symbol) { + var declarations = symbol.getDeclarations(); + if (declarations && declarations.length > 0) { + // Disallow rename for elements that are defined in the standard TypeScript library. + var defaultLibFileName = host.getDefaultLibFileName(host.getCompilationSettings()); + if (defaultLibFileName) { + for (var _i = 0; _i < declarations.length; _i++) { + var current = declarations[_i]; + var sourceFile_2 = current.getSourceFile(); + var canonicalName = getCanonicalFileName(ts.normalizePath(sourceFile_2.fileName)); + if (sourceFile_2 && getCanonicalFileName(ts.normalizePath(sourceFile_2.fileName)) === getCanonicalFileName(ts.normalizePath(defaultLibFileName))) { + return getRenameInfoError(ts.getLocaleSpecificMessage(ts.Diagnostics.You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library)); + } + } + } + var displayName = ts.stripQuotes(ts.getDeclaredName(typeChecker, symbol, node)); + var kind = getSymbolKind(symbol, node); + if (kind) { + return { + canRename: true, + localizedErrorMessage: undefined, + displayName: displayName, + fullDisplayName: typeChecker.getFullyQualifiedName(symbol), + kind: kind, + kindModifiers: getSymbolModifiers(symbol), + triggerSpan: ts.createTextSpan(node.getStart(), node.getWidth()) + }; + } + } + } + } + return getRenameInfoError(ts.getLocaleSpecificMessage(ts.Diagnostics.You_cannot_rename_this_element)); + function getRenameInfoError(localizedErrorMessage) { + return { + canRename: false, + localizedErrorMessage: localizedErrorMessage, + displayName: undefined, + fullDisplayName: undefined, + kind: undefined, + kindModifiers: undefined, + triggerSpan: undefined + }; + } + } + return { + dispose: dispose, + cleanupSemanticCache: cleanupSemanticCache, + getSyntacticDiagnostics: getSyntacticDiagnostics, + getSemanticDiagnostics: getSemanticDiagnostics, + getCompilerOptionsDiagnostics: getCompilerOptionsDiagnostics, + getSyntacticClassifications: getSyntacticClassifications, + getSemanticClassifications: getSemanticClassifications, + getEncodedSyntacticClassifications: getEncodedSyntacticClassifications, + getEncodedSemanticClassifications: getEncodedSemanticClassifications, + getCompletionsAtPosition: getCompletionsAtPosition, + getCompletionEntryDetails: getCompletionEntryDetails, + getSignatureHelpItems: getSignatureHelpItems, + getQuickInfoAtPosition: getQuickInfoAtPosition, + getDefinitionAtPosition: getDefinitionAtPosition, + getTypeDefinitionAtPosition: getTypeDefinitionAtPosition, + getReferencesAtPosition: getReferencesAtPosition, + findReferences: findReferences, + getOccurrencesAtPosition: getOccurrencesAtPosition, + getDocumentHighlights: getDocumentHighlights, + getNameOrDottedNameSpan: getNameOrDottedNameSpan, + getBreakpointStatementAtPosition: getBreakpointStatementAtPosition, + getNavigateToItems: getNavigateToItems, + getRenameInfo: getRenameInfo, + findRenameLocations: findRenameLocations, + getNavigationBarItems: getNavigationBarItems, + getOutliningSpans: getOutliningSpans, + getTodoComments: getTodoComments, + getBraceMatchingAtPosition: getBraceMatchingAtPosition, + getIndentationAtPosition: getIndentationAtPosition, + getFormattingEditsForRange: getFormattingEditsForRange, + getFormattingEditsForDocument: getFormattingEditsForDocument, + getFormattingEditsAfterKeystroke: getFormattingEditsAfterKeystroke, + getDocCommentTemplateAtPosition: getDocCommentTemplateAtPosition, + getEmitOutput: getEmitOutput, + getSourceFile: getSourceFile, + getProgram: getProgram + }; + } + ts.createLanguageService = createLanguageService; + /* @internal */ + function getNameTable(sourceFile) { + if (!sourceFile.nameTable) { + initializeNameTable(sourceFile); + } + return sourceFile.nameTable; + } + ts.getNameTable = getNameTable; + function initializeNameTable(sourceFile) { + var nameTable = {}; + walk(sourceFile); + sourceFile.nameTable = nameTable; + function walk(node) { + switch (node.kind) { + case 69 /* Identifier */: + nameTable[node.text] = node.text; + break; + case 9 /* StringLiteral */: + case 8 /* NumericLiteral */: + // We want to store any numbers/strings if they were a name that could be + // related to a declaration. So, if we have 'import x = require("something")' + // 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 === 232 /* ExternalModuleReference */ || + isArgumentOfElementAccessExpression(node)) { + nameTable[node.text] = node.text; + } + break; + default: + ts.forEachChild(node, walk); + } + } + } + function isArgumentOfElementAccessExpression(node) { + return node && + node.parent && + node.parent.kind === 167 /* ElementAccessExpression */ && + node.parent.argumentExpression === node; + } + /// Classifier + function createClassifier() { + var scanner = ts.createScanner(2 /* 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[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; + // 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 + // lines, just as we do with the end-of-line state. However, this is a burden for implementers, + // and the behavior is entirely subsumed by the syntactic classifier anyway, so we instead + // flatten any nesting when the template stack is non-empty and encode it in the end-of-line state. + // Situations in which this fails are + // 1) When template strings are nested across different lines: + // `hello ${ `world + // ` }` + // + // Where on the second line, you will get the closing of a template, + // a closing curly, and a new template. + // + // 2) When substitution expressions have curly braces and the curly brace falls on the next line: + // `hello ${ () => { + // return "world" } } ` + // + // Where on the second line, you will get the 'return' keyword, + // a string literal, and a template end consisting of '} } `'. + var templateStack = []; + /** 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 === 129 /* SetKeyword */ || + keyword2 === 121 /* ConstructorKeyword */ || + keyword2 === 113 /* StaticKeyword */) { + // Allow things like "public get", "public constructor" and "public static". + // These are all legal. + return true; + } + // Any other keyword following "public" is actually an identifier an not a real + // keyword. + return false; + } + // Assume any other keyword combination is legal. This can be refined in the future + // if there are more cases we want the classifier to be better at. + return true; + } + function convertClassifications(classifications, text) { + var entries = []; + var dense = classifications.spans; + var lastEnd = 0; + for (var i = 0, n = dense.length; i < n; i += 3) { + var start = dense[i]; + var length_3 = dense[i + 1]; + var type = dense[i + 2]; + // Make a whitespace entry between the last item and this one. + if (lastEnd >= 0) { + var whitespaceLength_1 = start - lastEnd; + if (whitespaceLength_1 > 0) { + entries.push({ length: whitespaceLength_1, classification: TokenClass.Whitespace }); + } + } + entries.push({ length: length_3, classification: convertClassification(type) }); + lastEnd = start + length_3; + } + var whitespaceLength = text.length - lastEnd; + if (whitespaceLength > 0) { + entries.push({ length: whitespaceLength, classification: TokenClass.Whitespace }); + } + return { entries: entries, finalLexState: classifications.endOfLineState }; + } + function convertClassification(type) { + switch (type) { + case 1 /* comment */: return TokenClass.Comment; + case 3 /* keyword */: return TokenClass.Keyword; + case 4 /* numericLiteral */: return TokenClass.NumberLiteral; + case 5 /* operator */: return TokenClass.Operator; + case 6 /* stringLiteral */: return TokenClass.StringLiteral; + case 8 /* whiteSpace */: return TokenClass.Whitespace; + case 10 /* punctuation */: return TokenClass.Punctuation; + case 2 /* identifier */: + case 11 /* className */: + case 12 /* enumName */: + case 13 /* interfaceName */: + case 14 /* moduleName */: + case 15 /* typeParameterName */: + case 16 /* typeAliasName */: + case 9 /* text */: + case 17 /* parameterName */: + default: + return TokenClass.Identifier; + } + } + function getClassificationsForLine(text, lexState, syntacticClassifierAbsent) { + return convertClassifications(getEncodedLexicalClassifications(text, lexState, syntacticClassifierAbsent), text); + } + // If there is a syntactic classifier ('syntacticClassifierAbsent' is false), + // we will be more conservative in order to avoid conflicting with the syntactic classifier. + function getEncodedLexicalClassifications(text, lexState, syntacticClassifierAbsent) { + var offset = 0; + var token = 0 /* Unknown */; + var lastNonTriviaToken = 0 /* Unknown */; + // Empty out the template stack for reuse. + while (templateStack.length > 0) { + templateStack.pop(); + } + // If we're in a string literal, then prepend: "\ + // (and a newline). That way when we lex we'll think we're still in a string literal. + // + // If we're in a multiline comment, then prepend: /* + // (and a newline). That way when we lex we'll think we're still in a multiline comment. + switch (lexState) { + case 3 /* InDoubleQuoteStringLiteral */: + text = '"\\\n' + text; + offset = 3; + break; + case 2 /* InSingleQuoteStringLiteral */: + text = "'\\\n" + text; + offset = 3; + break; + case 1 /* InMultiLineCommentTrivia */: + text = "/*\n" + text; + offset = 3; + break; + case 4 /* InTemplateHeadOrNoSubstitutionTemplate */: + text = "`\n" + text; + offset = 2; + break; + case 5 /* InTemplateMiddleOrTail */: + text = "}\n" + text; + offset = 2; + // fallthrough + case 6 /* InTemplateSubstitutionPosition */: + templateStack.push(12 /* TemplateHead */); + break; + } + scanner.setText(text); + var result = { + endOfLineState: 0 /* None */, + spans: [] + }; + // We can run into an unfortunate interaction between the lexical and syntactic classifier + // when the user is typing something generic. Consider the case where the user types: + // + // Foo tokens. It's a weak heuristic, but should + // work well enough in practice. + var angleBracketStack = 0; + 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 */; + } + } + else if (lastNonTriviaToken === 21 /* DotToken */ && isKeyword(token)) { + token = 69 /* Identifier */; + } + else if (isKeyword(lastNonTriviaToken) && isKeyword(token) && !canFollow(lastNonTriviaToken, token)) { + // We have two keywords in a row. Only treat the second as a keyword if + // it's a sequence that could legally occur in the language. Otherwise + // treat it as an identifier. This way, if someone writes "private var" + // we recognize that 'var' is actually an identifier here. + token = 69 /* Identifier */; + } + else if (lastNonTriviaToken === 69 /* Identifier */ && + token === 25 /* LessThanToken */) { + // Could be the start of something generic. Keep track of that by bumping + // up the current count of generic contexts we may be in. + angleBracketStack++; + } + else if (token === 27 /* 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 === 130 /* StringKeyword */ || + token === 128 /* NumberKeyword */ || + token === 120 /* BooleanKeyword */ || + token === 131 /* SymbolKeyword */) { + if (angleBracketStack > 0 && !syntacticClassifierAbsent) { + // If it looks like we're could be in something generic, don't classify this + // as a keyword. We may just get overwritten by the syntactic classifier, + // causing a noisy experience for the user. + token = 69 /* Identifier */; + } + } + else if (token === 12 /* TemplateHead */) { + templateStack.push(token); + } + else if (token === 15 /* 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 */) { + // 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 */) { + token = scanner.reScanTemplateToken(); + // Only pop on a TemplateTail; a TemplateMiddle indicates there is more for us. + if (token === 14 /* TemplateTail */) { + templateStack.pop(); + } + else { + ts.Debug.assert(token === 13 /* TemplateMiddle */, "Should have been a template middle. Was " + token); + } + } + else { + ts.Debug.assert(lastTemplateStackToken === 15 /* OpenBraceToken */, "Should have been an open brace. Was: " + token); + templateStack.pop(); + } + } + } + lastNonTriviaToken = token; + } + processToken(); + } while (token !== 1 /* EndOfFileToken */); + return result; + function processToken() { + var start = scanner.getTokenPos(); + var end = scanner.getTextPos(); + addResult(start, end, classFromKind(token)); + if (end >= text.length) { + if (token === 9 /* StringLiteral */) { + // Check to see if we finished up on a multiline string literal. + var tokenText = scanner.getTokenText(); + if (scanner.isUnterminated()) { + var lastCharIndex = tokenText.length - 1; + var numBackslashes = 0; + while (tokenText.charCodeAt(lastCharIndex - numBackslashes) === 92 /* backslash */) { + numBackslashes++; + } + // If we have an odd number of backslashes, then the multiline string is unclosed + if (numBackslashes & 1) { + var quoteChar = tokenText.charCodeAt(0); + result.endOfLineState = quoteChar === 34 /* doubleQuote */ + ? 3 /* InDoubleQuoteStringLiteral */ + : 2 /* InSingleQuoteStringLiteral */; + } + } + } + else if (token === 3 /* MultiLineCommentTrivia */) { + // Check to see if the multiline comment was unclosed. + if (scanner.isUnterminated()) { + result.endOfLineState = 1 /* InMultiLineCommentTrivia */; + } + } + else if (ts.isTemplateLiteralKind(token)) { + if (scanner.isUnterminated()) { + if (token === 14 /* TemplateTail */) { + result.endOfLineState = 5 /* InTemplateMiddleOrTail */; + } + else if (token === 11 /* NoSubstitutionTemplateLiteral */) { + result.endOfLineState = 4 /* InTemplateHeadOrNoSubstitutionTemplate */; + } + else { + ts.Debug.fail("Only 'NoSubstitutionTemplateLiteral's and 'TemplateTail's can be unterminated; got SyntaxKind #" + token); + } + } + } + else if (templateStack.length > 0 && ts.lastOrUndefined(templateStack) === 12 /* TemplateHead */) { + result.endOfLineState = 6 /* InTemplateSubstitutionPosition */; + } + } + } + function addResult(start, end, classification) { + if (classification === 8 /* whiteSpace */) { + // Don't bother with whitespace classifications. They're not needed. + return; + } + if (start === 0 && offset > 0) { + // We're classifying the first token, and this was a case where we prepended + // text. We should consider the start of this token to be at the start of + // the original text. + start += offset; + } + // All our tokens are in relation to the augmented text. Move them back to be + // relative to the original text. + start -= offset; + end -= offset; + var length = end - start; + if (length > 0) { + result.spans.push(start); + result.spans.push(length); + result.spans.push(classification); + } + } + } + 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 */: + return true; + default: + return false; + } + } + function isPrefixUnaryExpressionOperatorToken(token) { + switch (token) { + case 35 /* PlusToken */: + case 36 /* MinusToken */: + case 50 /* TildeToken */: + case 49 /* ExclamationToken */: + case 41 /* PlusPlusToken */: + case 42 /* MinusMinusToken */: + return true; + default: + return false; + } + } + function isKeyword(token) { + return token >= 70 /* FirstKeyword */ && token <= 134 /* LastKeyword */; + } + function classFromKind(token) { + if (isKeyword(token)) { + return 3 /* keyword */; + } + else if (isBinaryExpressionOperatorToken(token) || isPrefixUnaryExpressionOperatorToken(token)) { + return 5 /* operator */; + } + else if (token >= 15 /* FirstPunctuation */ && token <= 68 /* LastPunctuation */) { + return 10 /* punctuation */; + } + switch (token) { + case 8 /* NumericLiteral */: + return 4 /* numericLiteral */; + case 9 /* StringLiteral */: + return 6 /* stringLiteral */; + case 10 /* RegularExpressionLiteral */: + return 7 /* regularExpressionLiteral */; + case 7 /* ConflictMarkerTrivia */: + case 3 /* MultiLineCommentTrivia */: + case 2 /* SingleLineCommentTrivia */: + return 1 /* comment */; + case 5 /* WhitespaceTrivia */: + case 4 /* NewLineTrivia */: + return 8 /* whiteSpace */; + case 69 /* Identifier */: + default: + if (ts.isTemplateLiteralKind(token)) { + return 6 /* stringLiteral */; + } + return 2 /* identifier */; + } + } + return { + getClassificationsForLine: getClassificationsForLine, + getEncodedLexicalClassifications: getEncodedLexicalClassifications + }; + } + ts.createClassifier = createClassifier; + /** + * Get the path of the default library files (lib.d.ts) as distributed with the typescript + * node package. + * The functionality is not supported if the ts module is consumed outside of a node module. + */ + function getDefaultLibFilePath(options) { + // Check __dirname is defined and that we are on a node.js system. + if (typeof __dirname !== "undefined") { + return __dirname + ts.directorySeparator + ts.getDefaultLibFileName(options); + } + throw new Error("getDefaultLibFilePath is only supported when consumed as a node module. "); + } + ts.getDefaultLibFilePath = getDefaultLibFilePath; + function initializeServices() { + ts.objectAllocator = { + getNodeConstructor: function (kind) { + function Node(pos, end) { + this.pos = pos; + this.end = end; + this.flags = 0 /* None */; + this.parent = undefined; + } + var proto = kind === 248 /* SourceFile */ ? new SourceFileObject() : new NodeObject(); + proto.kind = kind; + Node.prototype = proto; + return Node; + }, + getSymbolConstructor: function () { return SymbolObject; }, + getTypeConstructor: function () { return TypeObject; }, + getSignatureConstructor: function () { return SignatureObject; } + }; + } + initializeServices(); +})(ts || (ts = {})); +// Copyright (c) Microsoft. All rights reserved. Licensed under the Apache License, Version 2.0. +// See LICENSE.txt in the project root for complete license information. +/// +/* @internal */ +var ts; +(function (ts) { + var BreakpointResolver; + (function (BreakpointResolver) { + /** + * Get the breakpoint span in given sourceFile + */ + function spanInSourceFileAtLocation(sourceFile, position) { + // Cannot set breakpoint in dts file + if (sourceFile.flags & 8192 /* DeclarationFile */) { + return undefined; + } + var tokenAtLocation = ts.getTokenAtPosition(sourceFile, position); + var lineOfPosition = sourceFile.getLineAndCharacterOfPosition(position).line; + if (sourceFile.getLineAndCharacterOfPosition(tokenAtLocation.getStart()).line > lineOfPosition) { + // Get previous token if the token is returned starts on new line + // eg: let x =10; |--- cursor is here + // let y = 10; + // token at position will return let keyword on second line as the token but we would like to use + // token on same line if trailing trivia (comments or white spaces on same line) part of the last token on that line + tokenAtLocation = ts.findPrecedingToken(tokenAtLocation.pos, sourceFile); + // Its a blank line + if (!tokenAtLocation || sourceFile.getLineAndCharacterOfPosition(tokenAtLocation.getEnd()).line !== lineOfPosition) { + return undefined; + } + } + // Cannot set breakpoint in ambient declarations + if (ts.isInAmbientContext(tokenAtLocation)) { + return undefined; + } + // Get the span in the node based on its syntax + return spanInNode(tokenAtLocation); + function textSpan(startNode, endNode) { + return ts.createTextSpanFromBounds(startNode.getStart(), (endNode || startNode).getEnd()); + } + function spanInNodeIfStartsOnSameLine(node, otherwiseOnNode) { + if (node && lineOfPosition === sourceFile.getLineAndCharacterOfPosition(node.getStart()).line) { + return spanInNode(node); + } + return spanInNode(otherwiseOnNode); + } + function spanInPreviousNode(node) { + return spanInNode(ts.findPrecedingToken(node.pos, sourceFile)); + } + function spanInNextNode(node) { + return spanInNode(ts.findNextToken(node, node.parent)); + } + function spanInNode(node) { + if (node) { + if (ts.isExpression(node)) { + if (node.parent.kind === 197 /* DoStatement */) { + // Set span as if on while keyword + return spanInPreviousNode(node); + } + if (node.parent.kind === 199 /* ForStatement */) { + // For now lets set the span on this expression, fix it later + return textSpan(node); + } + if (node.parent.kind === 181 /* BinaryExpression */ && node.parent.operatorToken.kind === 24 /* CommaToken */) { + // if this is comma expression, the breakpoint is possible in this expression + return textSpan(node); + } + if (node.parent.kind === 174 /* ArrowFunction */ && node.parent.body === node) { + // If this is body of arrow function, it is allowed to have the breakpoint + return textSpan(node); + } + } + switch (node.kind) { + case 193 /* VariableStatement */: + // Span on first variable declaration + return spanInVariableDeclaration(node.declarationList.declarations[0]); + case 211 /* VariableDeclaration */: + case 141 /* PropertyDeclaration */: + case 140 /* PropertySignature */: + return spanInVariableDeclaration(node); + case 138 /* Parameter */: + return spanInParameterDeclaration(node); + case 213 /* FunctionDeclaration */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: + case 144 /* Constructor */: + case 173 /* FunctionExpression */: + case 174 /* ArrowFunction */: + return spanInFunctionDeclaration(node); + case 192 /* Block */: + if (ts.isFunctionBlock(node)) { + return spanInFunctionBlock(node); + } + // Fall through + case 219 /* ModuleBlock */: + return spanInBlock(node); + case 244 /* CatchClause */: + return spanInBlock(node.block); + case 195 /* ExpressionStatement */: + // span on the expression + return textSpan(node.expression); + case 204 /* ReturnStatement */: + // span on return keyword and expression if present + return textSpan(node.getChildAt(0), node.expression); + case 198 /* WhileStatement */: + // Span on while(...) + return textSpan(node, ts.findNextToken(node.expression, node)); + case 197 /* DoStatement */: + // span in statement of the do statement + return spanInNode(node.statement); + case 210 /* DebuggerStatement */: + // span on debugger keyword + return textSpan(node.getChildAt(0)); + case 196 /* IfStatement */: + // set on if(..) span + return textSpan(node, ts.findNextToken(node.expression, node)); + case 207 /* LabeledStatement */: + // span in statement + return spanInNode(node.statement); + case 203 /* BreakStatement */: + case 202 /* ContinueStatement */: + // On break or continue keyword and label if present + return textSpan(node.getChildAt(0), node.label); + case 199 /* ForStatement */: + return spanInForStatement(node); + case 200 /* ForInStatement */: + case 201 /* ForOfStatement */: + // span on for (a in ...) + return textSpan(node, ts.findNextToken(node.expression, node)); + case 206 /* SwitchStatement */: + // span on switch(...) + return textSpan(node, ts.findNextToken(node.expression, node)); + case 241 /* CaseClause */: + case 242 /* DefaultClause */: + // span in first statement of the clause + return spanInNode(node.statements[0]); + case 209 /* TryStatement */: + // span in try block + return spanInBlock(node.tryBlock); + case 208 /* ThrowStatement */: + // span in throw ... + return textSpan(node, node.expression); + case 227 /* ExportAssignment */: + // span on export = id + return textSpan(node, node.expression); + case 221 /* ImportEqualsDeclaration */: + // import statement without including semicolon + return textSpan(node, node.moduleReference); + case 222 /* ImportDeclaration */: + // import statement without including semicolon + return textSpan(node, node.moduleSpecifier); + case 228 /* ExportDeclaration */: + // import statement without including semicolon + return textSpan(node, node.moduleSpecifier); + case 218 /* ModuleDeclaration */: + // span on complete module if it is instantiated + if (ts.getModuleInstanceState(node) !== 1 /* Instantiated */) { + return undefined; + } + case 214 /* ClassDeclaration */: + case 217 /* EnumDeclaration */: + case 247 /* EnumMember */: + case 168 /* CallExpression */: + case 169 /* NewExpression */: + // span on complete node + return textSpan(node); + case 205 /* WithStatement */: + // span in statement + return spanInNode(node.statement); + // No breakpoint in interface, type alias + case 215 /* InterfaceDeclaration */: + case 216 /* TypeAliasDeclaration */: + return undefined; + // Tokens: + case 23 /* SemicolonToken */: + case 1 /* EndOfFileToken */: + return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile)); + case 24 /* CommaToken */: + return spanInPreviousNode(node); + case 15 /* OpenBraceToken */: + return spanInOpenBraceToken(node); + case 16 /* CloseBraceToken */: + return spanInCloseBraceToken(node); + case 17 /* OpenParenToken */: + return spanInOpenParenToken(node); + case 18 /* CloseParenToken */: + return spanInCloseParenToken(node); + case 54 /* ColonToken */: + return spanInColonToken(node); + case 27 /* GreaterThanToken */: + case 25 /* LessThanToken */: + return spanInGreaterThanOrLessThanToken(node); + // Keywords: + case 104 /* WhileKeyword */: + return spanInWhileKeyword(node); + case 80 /* ElseKeyword */: + case 72 /* CatchKeyword */: + case 85 /* FinallyKeyword */: + return spanInNextNode(node); + default: + // If this is name of property assignment, set breakpoint in the initializer + if (node.parent.kind === 245 /* PropertyAssignment */ && node.parent.name === node) { + return spanInNode(node.parent.initializer); + } + // Breakpoint in type assertion goes to its operand + if (node.parent.kind === 171 /* TypeAssertionExpression */ && node.parent.type === node) { + return spanInNode(node.parent.expression); + } + // return type of function go to previous token + if (ts.isFunctionLike(node.parent) && node.parent.type === node) { + return spanInPreviousNode(node); + } + // Default go to parent to set the breakpoint + return spanInNode(node.parent); + } + } + function spanInVariableDeclaration(variableDeclaration) { + // If declaration of for in statement, just set the span in parent + if (variableDeclaration.parent.parent.kind === 200 /* ForInStatement */ || + variableDeclaration.parent.parent.kind === 201 /* ForOfStatement */) { + return spanInNode(variableDeclaration.parent.parent); + } + var isParentVariableStatement = variableDeclaration.parent.parent.kind === 193 /* VariableStatement */; + var isDeclarationOfForStatement = variableDeclaration.parent.parent.kind === 199 /* ForStatement */ && ts.contains(variableDeclaration.parent.parent.initializer.declarations, variableDeclaration); + var declarations = isParentVariableStatement + ? variableDeclaration.parent.parent.declarationList.declarations + : isDeclarationOfForStatement + ? variableDeclaration.parent.parent.initializer.declarations + : undefined; + // Breakpoint is possible in variableDeclaration only if there is initialization + if (variableDeclaration.initializer || (variableDeclaration.flags & 1 /* Export */)) { + if (declarations && declarations[0] === variableDeclaration) { + if (isParentVariableStatement) { + // First declaration - include let keyword + return textSpan(variableDeclaration.parent, variableDeclaration); + } + else { + ts.Debug.assert(isDeclarationOfForStatement); + // Include let keyword from for statement declarations in the span + return textSpan(ts.findPrecedingToken(variableDeclaration.pos, sourceFile, variableDeclaration.parent), variableDeclaration); + } + } + else { + // Span only on this declaration + return textSpan(variableDeclaration); + } + } + else if (declarations && declarations[0] !== variableDeclaration) { + // If we cant set breakpoint on this declaration, set it on previous one + var indexOfCurrentDeclaration = ts.indexOf(declarations, variableDeclaration); + return spanInVariableDeclaration(declarations[indexOfCurrentDeclaration - 1]); + } + } + function canHaveSpanInParameterDeclaration(parameter) { + // Breakpoint is possible on parameter only if it has initializer, is a rest parameter, or has public or private modifier + return !!parameter.initializer || parameter.dotDotDotToken !== undefined || + !!(parameter.flags & 16 /* Public */) || !!(parameter.flags & 32 /* Private */); + } + function spanInParameterDeclaration(parameter) { + if (canHaveSpanInParameterDeclaration(parameter)) { + return textSpan(parameter); + } + else { + var functionDeclaration = parameter.parent; + var indexOfParameter = ts.indexOf(functionDeclaration.parameters, parameter); + if (indexOfParameter) { + // Not a first parameter, go to previous parameter + return spanInParameterDeclaration(functionDeclaration.parameters[indexOfParameter - 1]); + } + else { + // Set breakpoint in the function declaration body + return spanInNode(functionDeclaration.body); + } + } + } + function canFunctionHaveSpanInWholeDeclaration(functionDeclaration) { + return !!(functionDeclaration.flags & 1 /* Export */) || + (functionDeclaration.parent.kind === 214 /* ClassDeclaration */ && functionDeclaration.kind !== 144 /* Constructor */); + } + function spanInFunctionDeclaration(functionDeclaration) { + // No breakpoints in the function signature + if (!functionDeclaration.body) { + return undefined; + } + if (canFunctionHaveSpanInWholeDeclaration(functionDeclaration)) { + // Set the span on whole function declaration + return textSpan(functionDeclaration); + } + // Set span in function body + return spanInNode(functionDeclaration.body); + } + function spanInFunctionBlock(block) { + var nodeForSpanInBlock = block.statements.length ? block.statements[0] : block.getLastToken(); + if (canFunctionHaveSpanInWholeDeclaration(block.parent)) { + return spanInNodeIfStartsOnSameLine(block.parent, nodeForSpanInBlock); + } + return spanInNode(nodeForSpanInBlock); + } + function spanInBlock(block) { + switch (block.parent.kind) { + case 218 /* ModuleDeclaration */: + if (ts.getModuleInstanceState(block.parent) !== 1 /* Instantiated */) { + return undefined; + } + // Set on parent if on same line otherwise on first statement + case 198 /* WhileStatement */: + case 196 /* IfStatement */: + case 200 /* ForInStatement */: + case 201 /* ForOfStatement */: + return spanInNodeIfStartsOnSameLine(block.parent, block.statements[0]); + // Set span on previous token if it starts on same line otherwise on the first statement of the block + case 199 /* ForStatement */: + 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 spanInForStatement(forStatement) { + if (forStatement.initializer) { + if (forStatement.initializer.kind === 212 /* VariableDeclarationList */) { + var variableDeclarationList = forStatement.initializer; + if (variableDeclarationList.declarations.length > 0) { + return spanInNode(variableDeclarationList.declarations[0]); + } + } + else { + return spanInNode(forStatement.initializer); + } + } + if (forStatement.condition) { + return textSpan(forStatement.condition); + } + if (forStatement.incrementor) { + return textSpan(forStatement.incrementor); + } + } + // Tokens: + function spanInOpenBraceToken(node) { + switch (node.parent.kind) { + case 217 /* EnumDeclaration */: + var enumDeclaration = node.parent; + return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), enumDeclaration.members.length ? enumDeclaration.members[0] : enumDeclaration.getLastToken(sourceFile)); + case 214 /* ClassDeclaration */: + var classDeclaration = node.parent; + return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), classDeclaration.members.length ? classDeclaration.members[0] : classDeclaration.getLastToken(sourceFile)); + case 220 /* CaseBlock */: + return spanInNodeIfStartsOnSameLine(node.parent.parent, node.parent.clauses[0]); + } + // Default to parent node + return spanInNode(node.parent); + } + function spanInCloseBraceToken(node) { + switch (node.parent.kind) { + case 219 /* ModuleBlock */: + // If this is not instantiated module block no bp span + if (ts.getModuleInstanceState(node.parent.parent) !== 1 /* Instantiated */) { + return undefined; + } + case 217 /* EnumDeclaration */: + case 214 /* ClassDeclaration */: + // Span on close brace token + return textSpan(node); + case 192 /* Block */: + if (ts.isFunctionBlock(node.parent)) { + // Span on close brace token + return textSpan(node); + } + // fall through. + case 244 /* CatchClause */: + return spanInNode(ts.lastOrUndefined(node.parent.statements)); + ; + case 220 /* CaseBlock */: + // breakpoint in last statement of the last clause + var caseBlock = node.parent; + var lastClause = ts.lastOrUndefined(caseBlock.clauses); + if (lastClause) { + return spanInNode(ts.lastOrUndefined(lastClause.statements)); + } + return undefined; + // Default to parent node + default: + return spanInNode(node.parent); + } + } + function spanInOpenParenToken(node) { + if (node.parent.kind === 197 /* DoStatement */) { + // Go to while keyword and do action instead + return spanInPreviousNode(node); + } + // Default to parent node + return spanInNode(node.parent); + } + function spanInCloseParenToken(node) { + // Is this close paren token of parameter list, set span in previous token + switch (node.parent.kind) { + case 173 /* FunctionExpression */: + case 213 /* FunctionDeclaration */: + case 174 /* ArrowFunction */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: + case 144 /* Constructor */: + case 198 /* WhileStatement */: + case 197 /* DoStatement */: + case 199 /* ForStatement */: + return spanInPreviousNode(node); + // Default to parent node + default: + return spanInNode(node.parent); + } + // Default to parent node + return spanInNode(node.parent); + } + function spanInColonToken(node) { + // Is this : specifying return annotation of the function declaration + if (ts.isFunctionLike(node.parent) || node.parent.kind === 245 /* PropertyAssignment */) { + return spanInPreviousNode(node); + } + return spanInNode(node.parent); + } + function spanInGreaterThanOrLessThanToken(node) { + if (node.parent.kind === 171 /* TypeAssertionExpression */) { + return spanInNode(node.parent.expression); + } + return spanInNode(node.parent); + } + function spanInWhileKeyword(node) { + if (node.parent.kind === 197 /* DoStatement */) { + // Set span on while expression + return textSpan(node, ts.findNextToken(node.parent.expression, node.parent)); + } + // Default to parent node + return spanInNode(node.parent); + } + } + } + BreakpointResolver.spanInSourceFileAtLocation = spanInSourceFileAtLocation; + })(BreakpointResolver = ts.BreakpointResolver || (ts.BreakpointResolver = {})); +})(ts || (ts = {})); +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +/// +/* @internal */ +var debugObjectHost = this; +/* @internal */ +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; + this.lineStartPositions = null; + } + 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); + // TODO: should this be '==='? + 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 scriptSnapshotShim is a COM object then property check becomes method call with no arguments + // 'in' does not have this effect + 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 shimHost is a COM object then property check will become method call with no arguments. + // 'in' does not have this effect. + 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.lookUp(resolutionsInFile, name); + return result ? { resolvedFileName: result } : undefined; + }); + }; + } + } + 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) { + // shimmed host does not support getProjectVersion + return undefined; + } + return this.shimHost.getProjectVersion(); + }; + LanguageServiceShimHostAdapter.prototype.useCaseSensitiveFileNames = function () { + return this.shimHost.useCaseSensitiveFileNames ? this.shimHost.useCaseSensitiveFileNames() : false; + }; + LanguageServiceShimHostAdapter.prototype.getCompilationSettings = function () { + var settingsJson = this.shimHost.getCompilationSettings(); + // TODO: should this be '==='? + if (settingsJson == null || settingsJson == "") { + throw Error("LanguageServiceShimHostAdapter.getCompilationSettings: empty compilationSettings"); + return null; + } + return JSON.parse(settingsJson); + }; + LanguageServiceShimHostAdapter.prototype.getScriptFileNames = function () { + var encoded = this.shimHost.getScriptFileNames(); + return this.files = JSON.parse(encoded); + }; + LanguageServiceShimHostAdapter.prototype.getScriptSnapshot = function (fileName) { + // Shim the API changes for 1.5 release. This should be removed once + // TypeScript 1.5 has shipped. + if (this.files && this.files.indexOf(fileName) < 0) { + return undefined; + } + var scriptSnapshot = this.shimHost.getScriptSnapshot(fileName); + return scriptSnapshot && new ScriptSnapshotShimAdapter(scriptSnapshot); + }; + 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.getDefaultLibFileName = function (options) { + // Wrap the API changes for 1.5 release. This try/catch + // should be removed once TypeScript 1.5 has shipped. + try { + return this.shimHost.getDefaultLibFileName(JSON.stringify(options)); + } + catch (e) { + return ""; + } + }; + return LanguageServiceShimHostAdapter; + })(); + ts.LanguageServiceShimHostAdapter = LanguageServiceShimHostAdapter; + /** A cancellation that throttles calls to the host */ + var ThrottledCancellationToken = (function () { + function ThrottledCancellationToken(hostCancellationToken) { + this.hostCancellationToken = hostCancellationToken; + // Store when we last tried to cancel. Checking cancellation can be expensive (as we have + // to marshall over to the host layer). So we only bother actually checking once enough + // time has passed. + this.lastCancellationCheckTime = 0; + } + ThrottledCancellationToken.prototype.isCancellationRequested = function () { + var time = Date.now(); + var duration = Math.abs(time - this.lastCancellationCheckTime); + if (duration > 10) { + // Check no more than once every 10 ms. + this.lastCancellationCheckTime = time; + return this.hostCancellationToken.isCancellationRequested(); + } + return false; + }; + return ThrottledCancellationToken; + })(); + var CoreServicesShimHostAdapter = (function () { + function CoreServicesShimHostAdapter(shimHost) { + this.shimHost = shimHost; + } + CoreServicesShimHostAdapter.prototype.readDirectory = function (rootDir, extension, exclude) { + // Wrap the API changes for 1.5 release. This try/catch + // should be removed once TypeScript 1.5 has shipped. + // Also consider removing the optional designation for + // the exclude param at this time. + var encoded; + try { + encoded = this.shimHost.readDirectory(rootDir, extension, JSON.stringify(exclude)); + } + catch (e) { + encoded = this.shimHost.readDirectory(rootDir, extension); + } + return JSON.parse(encoded); + }; + CoreServicesShimHostAdapter.prototype.fileExists = function (fileName) { + return this.shimHost.fileExists(fileName); + }; + CoreServicesShimHostAdapter.prototype.readFile = function (fileName) { + return this.shimHost.readFile(fileName); + }; + return CoreServicesShimHostAdapter; + })(); + ts.CoreServicesShimHostAdapter = CoreServicesShimHostAdapter; + function simpleForwardCall(logger, actionDescription, action, logPerformance) { + if (logPerformance) { + logger.log(actionDescription); + var start = Date.now(); + } + var result = action(); + if (logPerformance) { + var end = Date.now(); + 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) { + try { + var result = simpleForwardCall(logger, actionDescription, action, logPerformance); + return JSON.stringify({ 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, + /// TODO: no need for the tolowerCase call + category: ts.DiagnosticCategory[diagnostic.category].toLowerCase(), + code: diagnostic.code + }; + } + 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; + } + LanguageServiceShimObject.prototype.forwardJSONCall = function (actionDescription, action) { + return forwardJSONCall(this.logger, actionDescription, action, this.logPerformance); + }; + /// DISPOSE + /** + * Ensure (almost) deterministic release of internal Javascript resources when + * some external native objects holds onto us (e.g. Com/Interop). + */ + LanguageServiceShimObject.prototype.dispose = function (dummy) { + this.logger.log("dispose()"); + this.languageService.dispose(); + this.languageService = null; + // force a GC + if (debugObjectHost && debugObjectHost.CollectGarbage) { + debugObjectHost.CollectGarbage(); + this.logger.log("CollectGarbage()"); + } + this.logger = null; + _super.prototype.dispose.call(this, dummy); + }; + /// REFRESH + /** + * Update the list of scripts known to the compiler + */ + 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 () { + var classifications = _this.languageService.getSyntacticClassifications(fileName, ts.createTextSpan(start, length)); + return classifications; + }); + }; + LanguageServiceShimObject.prototype.getSemanticClassifications = function (fileName, start, length) { + var _this = this; + return this.forwardJSONCall("getSemanticClassifications('" + fileName + "', " + start + ", " + length + ")", function () { + var classifications = _this.languageService.getSemanticClassifications(fileName, ts.createTextSpan(start, length)); + return classifications; + }); + }; + LanguageServiceShimObject.prototype.getEncodedSyntacticClassifications = function (fileName, start, length) { + var _this = this; + return this.forwardJSONCall("getEncodedSyntacticClassifications('" + fileName + "', " + start + ", " + length + ")", function () { + // directly serialize the spans out to a string. This is much faster to decode + // on the managed side versus a full JSON array. + 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 () { + // directly serialize the spans out to a string. This is much faster to decode + // on the managed side versus a full JSON array. + 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); + }); + }; + /// QUICKINFO + /** + * Computes a string representation of the type at the requested position + * in the active file. + */ + LanguageServiceShimObject.prototype.getQuickInfoAtPosition = function (fileName, position) { + var _this = this; + return this.forwardJSONCall("getQuickInfoAtPosition('" + fileName + "', " + position + ")", function () { + var quickInfo = _this.languageService.getQuickInfoAtPosition(fileName, position); + return quickInfo; + }); + }; + /// NAMEORDOTTEDNAMESPAN + /** + * Computes span information of the name or dotted name at the requested position + * in the active file. + */ + LanguageServiceShimObject.prototype.getNameOrDottedNameSpan = function (fileName, startPos, endPos) { + var _this = this; + return this.forwardJSONCall("getNameOrDottedNameSpan('" + fileName + "', " + startPos + ", " + endPos + ")", function () { + var spanInfo = _this.languageService.getNameOrDottedNameSpan(fileName, startPos, endPos); + return spanInfo; + }); + }; + /** + * STATEMENTSPAN + * Computes span information of statement at the requested position in the active file. + */ + LanguageServiceShimObject.prototype.getBreakpointStatementAtPosition = function (fileName, position) { + var _this = this; + return this.forwardJSONCall("getBreakpointStatementAtPosition('" + fileName + "', " + position + ")", function () { + var spanInfo = _this.languageService.getBreakpointStatementAtPosition(fileName, position); + return spanInfo; + }); + }; + /// SIGNATUREHELP + LanguageServiceShimObject.prototype.getSignatureHelpItems = function (fileName, position) { + var _this = this; + return this.forwardJSONCall("getSignatureHelpItems('" + fileName + "', " + position + ")", function () { + var signatureInfo = _this.languageService.getSignatureHelpItems(fileName, position); + return signatureInfo; + }); + }; + /// GOTO DEFINITION + /** + * Computes the definition location and file for the symbol + * at the requested position. + */ + LanguageServiceShimObject.prototype.getDefinitionAtPosition = function (fileName, position) { + var _this = this; + return this.forwardJSONCall("getDefinitionAtPosition('" + fileName + "', " + position + ")", function () { + return _this.languageService.getDefinitionAtPosition(fileName, position); + }); + }; + /// GOTO Type + /** + * Computes the definition location of the type of the symbol + * at the requested 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.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); + }); + }; + /// GET BRACE MATCHING + LanguageServiceShimObject.prototype.getBraceMatchingAtPosition = function (fileName, position) { + var _this = this; + return this.forwardJSONCall("getBraceMatchingAtPosition('" + fileName + "', " + position + ")", function () { + var textRanges = _this.languageService.getBraceMatchingAtPosition(fileName, position); + return textRanges; + }); + }; + /// GET SMART INDENT + LanguageServiceShimObject.prototype.getIndentationAtPosition = function (fileName, position, options /*Services.EditorOptions*/) { + var _this = this; + return this.forwardJSONCall("getIndentationAtPosition('" + fileName + "', " + position + ")", function () { + var localOptions = JSON.parse(options); + return _this.languageService.getIndentationAtPosition(fileName, position, localOptions); + }); + }; + /// GET REFERENCES + 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)); + // workaround for VS document higlighting issue - keep only items from the initial file + var normalizedName = ts.normalizeSlashes(fileName).toLowerCase(); + return ts.filter(results, function (r) { return ts.normalizeSlashes(r.fileName).toLowerCase() === normalizedName; }); + }); + }; + /// COMPLETION LISTS + /** + * Get a string based representation of the completions + * to provide at the given source position and providing a member completion + * list if requested. + */ + LanguageServiceShimObject.prototype.getCompletionsAtPosition = function (fileName, position) { + var _this = this; + return this.forwardJSONCall("getCompletionsAtPosition('" + fileName + "', " + position + ")", function () { + var completion = _this.languageService.getCompletionsAtPosition(fileName, position); + return completion; + }); + }; + /** Get a string based representation of a completion list entry details */ + LanguageServiceShimObject.prototype.getCompletionEntryDetails = function (fileName, position, entryName) { + var _this = this; + return this.forwardJSONCall("getCompletionEntryDetails('" + fileName + "', " + position + ", " + entryName + ")", function () { + var details = _this.languageService.getCompletionEntryDetails(fileName, position, entryName); + return details; + }); + }; + LanguageServiceShimObject.prototype.getFormattingEditsForRange = function (fileName, start, end, options /*Services.FormatCodeOptions*/) { + var _this = this; + return this.forwardJSONCall("getFormattingEditsForRange('" + fileName + "', " + start + ", " + end + ")", function () { + var localOptions = JSON.parse(options); + var edits = _this.languageService.getFormattingEditsForRange(fileName, start, end, localOptions); + return edits; + }); + }; + LanguageServiceShimObject.prototype.getFormattingEditsForDocument = function (fileName, options /*Services.FormatCodeOptions*/) { + var _this = this; + return this.forwardJSONCall("getFormattingEditsForDocument('" + fileName + "')", function () { + var localOptions = JSON.parse(options); + var edits = _this.languageService.getFormattingEditsForDocument(fileName, localOptions); + return edits; + }); + }; + LanguageServiceShimObject.prototype.getFormattingEditsAfterKeystroke = function (fileName, position, key, options /*Services.FormatCodeOptions*/) { + var _this = this; + return this.forwardJSONCall("getFormattingEditsAfterKeystroke('" + fileName + "', " + position + ", '" + key + "')", function () { + var localOptions = JSON.parse(options); + var edits = _this.languageService.getFormattingEditsAfterKeystroke(fileName, position, key, localOptions); + return edits; + }); + }; + LanguageServiceShimObject.prototype.getDocCommentTemplateAtPosition = function (fileName, position) { + var _this = this; + return this.forwardJSONCall("getDocCommentTemplateAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getDocCommentTemplateAtPosition(fileName, position); }); + }; + /// NAVIGATE TO + /** Return a list of symbols that are interesting to navigate to */ + LanguageServiceShimObject.prototype.getNavigateToItems = function (searchValue, maxResultCount) { + var _this = this; + return this.forwardJSONCall("getNavigateToItems('" + searchValue + "', " + maxResultCount + ")", function () { + var items = _this.languageService.getNavigateToItems(searchValue, maxResultCount); + return items; + }); + }; + LanguageServiceShimObject.prototype.getNavigationBarItems = function (fileName) { + var _this = this; + return this.forwardJSONCall("getNavigationBarItems('" + fileName + "')", function () { + var items = _this.languageService.getNavigationBarItems(fileName); + return items; + }); + }; + LanguageServiceShimObject.prototype.getOutliningSpans = function (fileName) { + var _this = this; + return this.forwardJSONCall("getOutliningSpans('" + fileName + "')", function () { + var items = _this.languageService.getOutliningSpans(fileName); + return items; + }); + }; + LanguageServiceShimObject.prototype.getTodoComments = function (fileName, descriptors) { + var _this = this; + return this.forwardJSONCall("getTodoComments('" + fileName + "')", function () { + var items = _this.languageService.getTodoComments(fileName, JSON.parse(descriptors)); + return items; + }); + }; + /// Emit + LanguageServiceShimObject.prototype.getEmitOutput = function (fileName) { + var _this = this; + return this.forwardJSONCall("getEmitOutput('" + fileName + "')", function () { + var output = _this.languageService.getEmitOutput(fileName); + // Shim the API changes for 1.5 release. This should be removed once + // TypeScript 1.5 has shipped. + output.emitOutputStatus = output.emitSkipped ? 1 : 0; + return output; + }); + }; + 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) { + _super.call(this, factory); + this.logger = logger; + this.logPerformance = false; + this.classifier = ts.createClassifier(); + } + 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); + }; + /// COLORIZATION + ClassifierShimObject.prototype.getClassificationsForLine = function (text, lexState, classifyKeywordsInGenerics) { + var classification = this.classifier.getClassificationsForLine(text, lexState, classifyKeywordsInGenerics); + var items = classification.entries; + var result = ""; + for (var i = 0; i < items.length; i++) { + result += items[i].length + "\n"; + result += items[i].classification + "\n"; + } + result += classification.finalLexState; + return result; + }; + return ClassifierShimObject; + })(ShimBase); + 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; + } + 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.getPreProcessedFileInfo = function (fileName, sourceTextSnapshot) { + return this.forwardJSONCall("getPreProcessedFileInfo('" + fileName + "')", function () { + var result = ts.preProcessFile(sourceTextSnapshot.getText(0, sourceTextSnapshot.getLength())); + var convertResult = { + referencedFiles: [], + importedFiles: [], + ambientExternalModules: result.ambientExternalModules, + isLibFile: result.isLibFile + }; + ts.forEach(result.referencedFiles, function (refFile) { + convertResult.referencedFiles.push({ + path: ts.normalizePath(refFile.fileName), + position: refFile.pos, + length: refFile.end - refFile.pos + }); + }); + ts.forEach(result.importedFiles, function (importedFile) { + convertResult.importedFiles.push({ + path: ts.normalizeSlashes(importedFile.fileName), + position: importedFile.pos, + length: importedFile.end - importedFile.pos + }); + }); + return convertResult; + }); + }; + 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: {}, + files: [], + errors: [realizeDiagnostic(result.error, '\r\n')] + }; + } + var configFile = ts.parseJsonConfigFileContent(result.config, _this.host, ts.getDirectoryPath(ts.normalizeSlashes(fileName))); + return { + options: configFile.options, + files: configFile.fileNames, + errors: realizeDiagnostics(configFile.errors, '\r\n') + }; + }); + }; + CoreServicesShimObject.prototype.getDefaultCompilationSettings = function () { + return this.forwardJSONCall("getDefaultCompilationSettings()", function () { + return ts.getDefaultCompilerOptions(); + }); + }; + return CoreServicesShimObject; + })(ShimBase); + var TypeScriptServicesFactory = (function () { + function TypeScriptServicesFactory() { + this._shims = []; + } + /* + * Returns script API version. + */ + 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()); + } + 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 () { + // Forget all the registered shims + this._shims = []; + this.documentRegistry = ts.createDocumentRegistry(); + }; + 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 = {})); +/// TODO: this is used by VS, clean this up on both sides of the interface +/* @internal */ +var TypeScript; +(function (TypeScript) { + var Services; + (function (Services) { + Services.TypeScriptServicesFactory = ts.TypeScriptServicesFactory; + })(Services = TypeScript.Services || (TypeScript.Services = {})); +})(TypeScript || (TypeScript = {})); +/* @internal */ +var toolsVersion = "1.6"; From 0d71ec3120db609a6d261e6e26201074590bfbf4 Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Wed, 28 Oct 2015 10:05:29 -0700 Subject: [PATCH 101/227] Fix #5430: Use FileMap instead of a simple Map for storing file list in tsserver --- src/server/editorServices.ts | 34 ++++++++++++++++------------------ 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/src/server/editorServices.ts b/src/server/editorServices.ts index e7d6aee8052..eb7bdb0f718 100644 --- a/src/server/editorServices.ts +++ b/src/server/editorServices.ts @@ -86,17 +86,19 @@ namespace ts.server { export class LSHost implements ts.LanguageServiceHost { ls: ts.LanguageService = null; compilationSettings: ts.CompilerOptions; - filenameToScript: ts.Map = {}; + filenameToScript: ts.FileMap; roots: ScriptInfo[] = []; private resolvedModuleNames: ts.FileMap>; private moduleResolutionHost: ts.ModuleResolutionHost; constructor(public host: ServerHost, public project: Project) { - this.resolvedModuleNames = ts.createFileMap>(ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames)) + var getCanonicalFileName = createGetCanonicalFileName(host.useCaseSensitiveFileNames); + this.resolvedModuleNames = createFileMap>(getCanonicalFileName); + this.filenameToScript = createFileMap(getCanonicalFileName); this.moduleResolutionHost = { fileExists: fileName => this.fileExists(fileName), readFile: fileName => this.host.readFile(fileName) - } + }; } resolveModuleNames(moduleNames: string[], containingFile: string): ResolvedModule[] { @@ -199,36 +201,32 @@ namespace ts.server { removeReferencedFile(info: ScriptInfo) { if (!info.isOpen) { - this.filenameToScript[info.fileName] = undefined; + this.filenameToScript.remove(info.fileName); this.resolvedModuleNames.remove(info.fileName); } } getScriptInfo(filename: string): ScriptInfo { - var scriptInfo = ts.lookUp(this.filenameToScript, filename); + var scriptInfo = this.filenameToScript.get(filename); if (!scriptInfo) { scriptInfo = this.project.openReferencedFile(filename); if (scriptInfo) { - this.filenameToScript[scriptInfo.fileName] = scriptInfo; + this.filenameToScript.set(scriptInfo.fileName, scriptInfo); } } - else { - } return scriptInfo; } addRoot(info: ScriptInfo) { - var scriptInfo = ts.lookUp(this.filenameToScript, info.fileName); - if (!scriptInfo) { - this.filenameToScript[info.fileName] = info; + if (!this.filenameToScript.contains(info.fileName)) { + this.filenameToScript.set(info.fileName, info); this.roots.push(info); } } removeRoot(info: ScriptInfo) { - var scriptInfo = ts.lookUp(this.filenameToScript, info.fileName); - if (scriptInfo) { - this.filenameToScript[info.fileName] = undefined; + if (!this.filenameToScript.contains(info.fileName)) { + this.filenameToScript.remove(info.fileName); this.roots = copyListRemovingItem(info, this.roots); this.resolvedModuleNames.remove(info.fileName); } @@ -279,7 +277,7 @@ namespace ts.server { * @param line 1 based index */ lineToTextSpan(filename: string, line: number): ts.TextSpan { - var script: ScriptInfo = this.filenameToScript[filename]; + var script: ScriptInfo = this.filenameToScript.get(filename); var index = script.snap().index; var lineInfo = index.lineNumberToInfo(line + 1); @@ -299,7 +297,7 @@ namespace ts.server { * @param offset 1 based index */ lineOffsetToPosition(filename: string, line: number, offset: number): number { - var script: ScriptInfo = this.filenameToScript[filename]; + var script: ScriptInfo = this.filenameToScript.get(filename); var index = script.snap().index; var lineInfo = index.lineNumberToInfo(line); @@ -312,7 +310,7 @@ namespace ts.server { * @param offset 1-based index */ positionToLineOffset(filename: string, position: number): ILineInfo { - var script: ScriptInfo = this.filenameToScript[filename]; + var script: ScriptInfo = this.filenameToScript.get(filename); var index = script.snap().index; var lineOffset = index.charOffsetToLineNumberAndPos(position); return { line: lineOffset.line, offset: lineOffset.offset + 1 }; @@ -386,7 +384,7 @@ namespace ts.server { } getFileNames() { - let sourceFiles = this.program.getSourceFiles(); + var sourceFiles = this.program.getSourceFiles(); return sourceFiles.map(sourceFile => sourceFile.fileName); } From d28acec24e26d0df243526e62281130094320e33 Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Wed, 28 Oct 2015 13:40:23 -0700 Subject: [PATCH 102/227] Update LKG --- lib/tsserver.js | 29 +++++++++++++---------------- 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/lib/tsserver.js b/lib/tsserver.js index 77348ce6e8a..ed62dd90686 100644 --- a/lib/tsserver.js +++ b/lib/tsserver.js @@ -42743,9 +42743,10 @@ var ts; this.host = host; this.project = project; this.ls = null; - this.filenameToScript = {}; this.roots = []; - this.resolvedModuleNames = ts.createFileMap(ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames)); + var getCanonicalFileName = ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames); + this.resolvedModuleNames = ts.createFileMap(getCanonicalFileName); + this.filenameToScript = ts.createFileMap(getCanonicalFileName); this.moduleResolutionHost = { fileExists: function (fileName) { return _this.fileExists(fileName); }, readFile: function (fileName) { return _this.host.readFile(fileName); } @@ -42824,33 +42825,29 @@ var ts; }; LSHost.prototype.removeReferencedFile = function (info) { if (!info.isOpen) { - this.filenameToScript[info.fileName] = undefined; + this.filenameToScript.remove(info.fileName); this.resolvedModuleNames.remove(info.fileName); } }; LSHost.prototype.getScriptInfo = function (filename) { - var scriptInfo = ts.lookUp(this.filenameToScript, filename); + var scriptInfo = this.filenameToScript.get(filename); if (!scriptInfo) { scriptInfo = this.project.openReferencedFile(filename); if (scriptInfo) { - this.filenameToScript[scriptInfo.fileName] = scriptInfo; + this.filenameToScript.set(scriptInfo.fileName, scriptInfo); } } - else { - } return scriptInfo; }; LSHost.prototype.addRoot = function (info) { - var scriptInfo = ts.lookUp(this.filenameToScript, info.fileName); - if (!scriptInfo) { - this.filenameToScript[info.fileName] = info; + if (!this.filenameToScript.contains(info.fileName)) { + this.filenameToScript.set(info.fileName, info); this.roots.push(info); } }; LSHost.prototype.removeRoot = function (info) { - var scriptInfo = ts.lookUp(this.filenameToScript, info.fileName); - if (scriptInfo) { - this.filenameToScript[info.fileName] = undefined; + if (!this.filenameToScript.contains(info.fileName)) { + this.filenameToScript.remove(info.fileName); this.roots = copyListRemovingItem(info, this.roots); this.resolvedModuleNames.remove(info.fileName); } @@ -42890,7 +42887,7 @@ var ts; return this.host.directoryExists(path); }; LSHost.prototype.lineToTextSpan = function (filename, line) { - var script = this.filenameToScript[filename]; + var script = this.filenameToScript.get(filename); var index = script.snap().index; var lineInfo = index.lineNumberToInfo(line + 1); var len; @@ -42904,13 +42901,13 @@ var ts; return ts.createTextSpan(lineInfo.offset, len); }; LSHost.prototype.lineOffsetToPosition = function (filename, line, offset) { - var script = this.filenameToScript[filename]; + var script = this.filenameToScript.get(filename); var index = script.snap().index; var lineInfo = index.lineNumberToInfo(line); return (lineInfo.offset + offset - 1); }; LSHost.prototype.positionToLineOffset = function (filename, position) { - var script = this.filenameToScript[filename]; + var script = this.filenameToScript.get(filename); var index = script.snap().index; var lineOffset = index.charOffsetToLineNumberAndPos(position); return { line: lineOffset.line, offset: lineOffset.offset + 1 }; From fdac86fab991fe4ca351e3686f2869423f88bb9f Mon Sep 17 00:00:00 2001 From: Ron Buckton Date: Wed, 28 Oct 2015 13:48:13 -0700 Subject: [PATCH 103/227] Linter errors --- src/compiler/checker.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 18c035412ed..0cedd245ed7 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -5479,7 +5479,7 @@ namespace ts { let targetType = getIndexTypeOfType(target, IndexKind.String); if (targetType) { if ((targetType.flags & TypeFlags.Any) && !(originalSource.flags & TypeFlags.Primitive)) { - // non-primitive assignment to any is always allowed, eg + // non-primitive assignment to any is always allowed, eg // `var x: { [index: string]: any } = { property: 12 };` return Ternary.True; } @@ -5509,7 +5509,7 @@ namespace ts { let targetType = getIndexTypeOfType(target, IndexKind.Number); if (targetType) { if ((targetType.flags & TypeFlags.Any) && !(originalSource.flags & TypeFlags.Primitive)) { - // non-primitive assignment to any is always allowed, eg + // non-primitive assignment to any is always allowed, eg // `var x: { [index: number]: any } = { property: 12 };` return Ternary.True; } @@ -6586,9 +6586,9 @@ namespace ts { return; } - // 1. walk from the use site up to the declaration and check + // 1. walk from the use site up to the declaration and check // if there is anything function like between declaration and use-site (is binding/class is captured in function). - // 2. walk from the declaration up to the boundary of lexical environment and check + // 2. walk from the declaration up to the boundary of lexical environment and check // if there is an iteration statement in between declaration and boundary (is binding/class declared inside iteration statement) let container: Node; @@ -11631,14 +11631,14 @@ namespace ts { // // When we get the type of the `Promise` symbol here, we get the type of the static // side of the `Promise` class, which would be `{ new (...): Promise }`. - + let promiseType = getTypeFromTypeNode(node.type); if (promiseType === unknownType && compilerOptions.isolatedModules) { // If we are compiling with isolatedModules, we may not be able to resolve the // type as a value. As such, we will just return unknownType; return unknownType; } - + let promiseConstructor = getNodeLinks(node.type).resolvedSymbol; if (!promiseConstructor || !symbolIsValue(promiseConstructor)) { let typeName = promiseConstructor From 062495c426e549ed68b5c75161e94e10be4ed06e Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Wed, 28 Oct 2015 13:48:32 -0700 Subject: [PATCH 104/227] naive change and new tests --- src/compiler/checker.ts | 6 +++--- .../expressions/typeGuards/typeGuardNesting.ts | 4 ++++ .../expressions/typeGuards/typeGuardRedundancy.ts | 9 +++++++++ 3 files changed, 16 insertions(+), 3 deletions(-) create mode 100644 tests/cases/conformance/expressions/typeGuards/typeGuardNesting.ts create mode 100644 tests/cases/conformance/expressions/typeGuards/typeGuardRedundancy.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 5370e7c4f02..033614d2b41 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -6369,7 +6369,7 @@ namespace ts { // Assumed result is true. If check was not for a primitive type, remove all primitive types if (!typeInfo) { return removeTypesFromUnionType(type, /*typeKind*/ TypeFlags.StringLike | TypeFlags.NumberLike | TypeFlags.Boolean | TypeFlags.ESSymbol, - /*isOfTypeKind*/ true, /*allowEmptyUnionResult*/ false); + /*isOfTypeKind*/ true, /*allowEmptyUnionResult*/ true); } // Check was for a primitive type, return that primitive type if it is a subtype if (isTypeSubtypeOf(typeInfo.type, type)) { @@ -6377,12 +6377,12 @@ namespace ts { } // Otherwise, remove all types that aren't of the primitive type kind. This can happen when the type is // union of enum types and other types. - return removeTypesFromUnionType(type, /*typeKind*/ typeInfo.flags, /*isOfTypeKind*/ false, /*allowEmptyUnionResult*/ false); + return removeTypesFromUnionType(type, /*typeKind*/ typeInfo.flags, /*isOfTypeKind*/ false, /*allowEmptyUnionResult*/ true); } else { // Assumed result is false. If check was for a primitive type, remove that primitive type if (typeInfo) { - return removeTypesFromUnionType(type, /*typeKind*/ typeInfo.flags, /*isOfTypeKind*/ true, /*allowEmptyUnionResult*/ false); + return removeTypesFromUnionType(type, /*typeKind*/ typeInfo.flags, /*isOfTypeKind*/ true, /*allowEmptyUnionResult*/ true); } // Otherwise we don't have enough information to do anything. return type; diff --git a/tests/cases/conformance/expressions/typeGuards/typeGuardNesting.ts b/tests/cases/conformance/expressions/typeGuards/typeGuardNesting.ts new file mode 100644 index 00000000000..b06b5880800 --- /dev/null +++ b/tests/cases/conformance/expressions/typeGuards/typeGuardNesting.ts @@ -0,0 +1,4 @@ +let strOrBool: string|boolean; +if ((typeof strOrBool === 'boolean' && !strOrBool) || typeof strOrBool === 'string') { + var label: string = (typeof strOrBool === 'string') ? strOrBool : "other string"; +} \ No newline at end of file diff --git a/tests/cases/conformance/expressions/typeGuards/typeGuardRedundancy.ts b/tests/cases/conformance/expressions/typeGuards/typeGuardRedundancy.ts new file mode 100644 index 00000000000..4e9e3137d78 --- /dev/null +++ b/tests/cases/conformance/expressions/typeGuards/typeGuardRedundancy.ts @@ -0,0 +1,9 @@ +var x: string|number; + +var r1 = typeof x === "string" && typeof x === "string" ? x.substr : x.toFixed; + +var r2 = !(typeof x === "string" && typeof x === "string") ? x.toFixed : x.substr; + +var r3 = typeof x === "string" || typeof x === "string" ? x.substr : x.toFixed; + +var r4 = !(typeof x === "string" || typeof x === "string") ? x.toFixed : x.substr; \ No newline at end of file From 5ce7fd9781eab50003ade49eb531329622250230 Mon Sep 17 00:00:00 2001 From: Vladimir Matveev Date: Wed, 28 Oct 2015 15:42:15 -0700 Subject: [PATCH 105/227] lint server --- Jakefile.js | 10 +- src/server/editorServices.ts | 489 ++++++++++++++++++----------------- src/server/protocol.d.ts | 176 ++++++------- src/server/server.ts | 46 ++-- src/server/session.ts | 426 +++++++++++++++--------------- 5 files changed, 583 insertions(+), 564 deletions(-) diff --git a/Jakefile.js b/Jakefile.js index a602a2c459f..fd682d075ae 100644 --- a/Jakefile.js +++ b/Jakefile.js @@ -96,7 +96,7 @@ var servicesSources = [ return path.join(servicesDirectory, f); })); -var serverSources = [ +var serverOnlySources = [ "node.d.ts", "editorServices.ts", "protocol.d.ts", @@ -104,7 +104,9 @@ var serverSources = [ "server.ts" ].map(function (f) { return path.join(serverDirectory, f); -}).concat(servicesSources); +}); + +var serverSources = serverOnlySources.concat(servicesSources); var languageServiceLibrarySources = [ "editorServices.ts", @@ -898,7 +900,9 @@ function lintFileAsync(options, path, cb) { }); } -var lintTargets = compilerSources.concat(harnessCoreSources); +var lintTargets = compilerSources + .concat(harnessCoreSources) + .concat(serverOnlySources.filter(function(p) { return path.basename(p) !== "node.d.ts"; })); desc("Runs tslint on the compiler sources"); task("lint", ["build-rules"], function() { diff --git a/src/server/editorServices.ts b/src/server/editorServices.ts index eb7bdb0f718..d2e16487d07 100644 --- a/src/server/editorServices.ts +++ b/src/server/editorServices.ts @@ -15,12 +15,12 @@ namespace ts.server { msg(s: string, type?: string): void; } - var lineCollectionCapacity = 4; + const lineCollectionCapacity = 4; function mergeFormatOptions(formatCodeOptions: FormatCodeOptions, formatOptions: protocol.FormatOptions): void { - var hasOwnProperty = Object.prototype.hasOwnProperty; + const hasOwnProperty = Object.prototype.hasOwnProperty; Object.keys(formatOptions).forEach((key) => { - var codeKey = key.charAt(0).toUpperCase() + key.substring(1); + const codeKey = key.charAt(0).toUpperCase() + key.substring(1); if (hasOwnProperty.call(formatCodeOptions, codeKey)) { formatCodeOptions[codeKey] = formatOptions[key]; } @@ -57,12 +57,12 @@ namespace ts.server { } getText() { - var snap = this.snap(); + const snap = this.snap(); return snap.getText(0, snap.getLength()); } getLineInfo(line: number) { - var snap = this.snap(); + const snap = this.snap(); return snap.index.lineNumberToInfo(line); } @@ -84,7 +84,7 @@ namespace ts.server { } export class LSHost implements ts.LanguageServiceHost { - ls: ts.LanguageService = null; + ls: ts.LanguageService; compilationSettings: ts.CompilerOptions; filenameToScript: ts.FileMap; roots: ScriptInfo[] = []; @@ -92,7 +92,7 @@ namespace ts.server { private moduleResolutionHost: ts.ModuleResolutionHost; constructor(public host: ServerHost, public project: Project) { - var getCanonicalFileName = createGetCanonicalFileName(host.useCaseSensitiveFileNames); + const getCanonicalFileName = createGetCanonicalFileName(host.useCaseSensitiveFileNames); this.resolvedModuleNames = createFileMap>(getCanonicalFileName); this.filenameToScript = createFileMap(getCanonicalFileName); this.moduleResolutionHost = { @@ -129,7 +129,7 @@ namespace ts.server { resolvedModules.push(resolution.resolvedModule); } - + // replace old results with a new one this.resolvedModuleNames.set(containingFile, newResolutions); return resolvedModules; @@ -144,7 +144,7 @@ namespace ts.server { // TODO: use lastCheckTime to track expiration for module name resolution return true; } - + // consider situation if we have no candidate locations as valid resolution. // after all there is no point to invalidate it if we have no idea where to look for the module. return resolution.failedLookupLocations.length === 0; @@ -152,12 +152,12 @@ namespace ts.server { } getDefaultLibFileName() { - var nodeModuleBinDir = ts.getDirectoryPath(ts.normalizePath(this.host.getExecutingFilePath())); + const nodeModuleBinDir = ts.getDirectoryPath(ts.normalizePath(this.host.getExecutingFilePath())); return ts.combinePaths(nodeModuleBinDir, ts.getDefaultLibFileName(this.compilationSettings)); } getScriptSnapshot(filename: string): ts.IScriptSnapshot { - var scriptInfo = this.getScriptInfo(filename); + const scriptInfo = this.getScriptInfo(filename); if (scriptInfo) { return scriptInfo.snap(); } @@ -170,10 +170,10 @@ namespace ts.server { } lineAffectsRefs(filename: string, line: number) { - var info = this.getScriptInfo(filename); - var lineInfo = info.getLineInfo(line); + const info = this.getScriptInfo(filename); + const lineInfo = info.getLineInfo(line); if (lineInfo && lineInfo.text) { - var regex = /reference|import|\/\*|\*\//; + const regex = /reference|import|\/\*|\*\//; return regex.test(lineInfo.text); } } @@ -207,7 +207,7 @@ namespace ts.server { } getScriptInfo(filename: string): ScriptInfo { - var scriptInfo = this.filenameToScript.get(filename); + let scriptInfo = this.filenameToScript.get(filename); if (!scriptInfo) { scriptInfo = this.project.openReferencedFile(filename); if (scriptInfo) { @@ -233,22 +233,22 @@ namespace ts.server { } saveTo(filename: string, tmpfilename: string) { - var script = this.getScriptInfo(filename); + const script = this.getScriptInfo(filename); if (script) { - var snap = script.snap(); + const snap = script.snap(); this.host.writeFile(tmpfilename, snap.getText(0, snap.getLength())); } } reloadScript(filename: string, tmpfilename: string, cb: () => any) { - var script = this.getScriptInfo(filename); + const script = this.getScriptInfo(filename); if (script) { script.svc.reloadFromFile(tmpfilename, cb); } } editScript(filename: string, start: number, end: number, newText: string) { - var script = this.getScriptInfo(filename); + const script = this.getScriptInfo(filename); if (script) { script.editContent(start, end, newText); return; @@ -258,14 +258,14 @@ namespace ts.server { } resolvePath(path: string): string { - var start = new Date().getTime(); - var result = this.host.resolvePath(path); + const start = new Date().getTime(); + const result = this.host.resolvePath(path); return result; } fileExists(path: string): boolean { - var start = new Date().getTime(); - var result = this.host.fileExists(path); + const start = new Date().getTime(); + const result = this.host.fileExists(path); return result; } @@ -277,16 +277,16 @@ namespace ts.server { * @param line 1 based index */ lineToTextSpan(filename: string, line: number): ts.TextSpan { - var script: ScriptInfo = this.filenameToScript.get(filename); - var index = script.snap().index; + const script: ScriptInfo = this.filenameToScript.get(filename); + const index = script.snap().index; - var lineInfo = index.lineNumberToInfo(line + 1); - var len: number; + const lineInfo = index.lineNumberToInfo(line + 1); + let len: number; if (lineInfo.leaf) { len = lineInfo.leaf.text.length; } else { - var nextLineInfo = index.lineNumberToInfo(line + 2); + const nextLineInfo = index.lineNumberToInfo(line + 2); len = nextLineInfo.offset - lineInfo.offset; } return ts.createTextSpan(lineInfo.offset, len); @@ -297,10 +297,10 @@ namespace ts.server { * @param offset 1 based index */ lineOffsetToPosition(filename: string, line: number, offset: number): number { - var script: ScriptInfo = this.filenameToScript.get(filename); - var index = script.snap().index; + const script: ScriptInfo = this.filenameToScript.get(filename); + const index = script.snap().index; - var lineInfo = index.lineNumberToInfo(line); + const lineInfo = index.lineNumberToInfo(line); // TODO: assert this offset is actually on the line return (lineInfo.offset + offset - 1); } @@ -310,36 +310,36 @@ namespace ts.server { * @param offset 1-based index */ positionToLineOffset(filename: string, position: number): ILineInfo { - var script: ScriptInfo = this.filenameToScript.get(filename); - var index = script.snap().index; - var lineOffset = index.charOffsetToLineNumberAndPos(position); + const script: ScriptInfo = this.filenameToScript.get(filename); + const index = script.snap().index; + const lineOffset = index.charOffsetToLineNumberAndPos(position); return { line: lineOffset.line, offset: lineOffset.offset + 1 }; } } // assumes normalized paths function getAbsolutePath(filename: string, directory: string) { - var rootLength = ts.getRootLength(filename); + const rootLength = ts.getRootLength(filename); if (rootLength > 0) { return filename; } else { - var splitFilename = filename.split('/'); - var splitDir = directory.split('/'); - var i = 0; - var dirTail = 0; - var sflen = splitFilename.length; - while ((i < sflen) && (splitFilename[i].charAt(0) == '.')) { - var dots = splitFilename[i]; - if (dots == '..') { + const splitFilename = filename.split("/"); + const splitDir = directory.split("/"); + let i = 0; + let dirTail = 0; + const sflen = splitFilename.length; + while ((i < sflen) && (splitFilename[i].charAt(0) == ".")) { + const dots = splitFilename[i]; + if (dots == "..") { dirTail++; } - else if (dots != '.') { + else if (dots != ".") { return undefined; } i++; } - return splitDir.slice(0, splitDir.length - dirTail).concat(splitFilename.slice(i)).join('/'); + return splitDir.slice(0, splitDir.length - dirTail).concat(splitFilename.slice(i)).join("/"); } } @@ -384,7 +384,7 @@ namespace ts.server { } getFileNames() { - var sourceFiles = this.program.getSourceFiles(); + const sourceFiles = this.program.getSourceFiles(); return sourceFiles.map(sourceFile => sourceFile.fileName); } @@ -393,7 +393,7 @@ namespace ts.server { } getSourceFileFromName(filename: string, requireOpen?: boolean) { - var info = this.projectService.getScriptInfo(filename); + const info = this.projectService.getScriptInfo(filename); if (info) { if ((!requireOpen) || info.isOpen) { return this.getSourceFile(info); @@ -412,9 +412,9 @@ namespace ts.server { updateFileMap() { this.filenameToSourceFile = {}; - var sourceFiles = this.program.getSourceFiles(); - for (var i = 0, len = sourceFiles.length; i < len; i++) { - var normFilename = ts.normalizePath(sourceFiles[i].fileName); + const sourceFiles = this.program.getSourceFiles(); + for (let i = 0, len = sourceFiles.length; i < len; i++) { + const normFilename = ts.normalizePath(sourceFiles[i].fileName); this.filenameToSourceFile[normFilename] = sourceFiles[i]; } } @@ -437,14 +437,14 @@ namespace ts.server { addRoot(info: ScriptInfo) { this.compilerService.host.addRoot(info); } - + // remove a root file from project removeRoot(info: ScriptInfo) { this.compilerService.host.removeRoot(info); } filesToString() { - var strBuilder = ""; + let strBuilder = ""; ts.forEachValue(this.filenameToSourceFile, sourceFile => { strBuilder += sourceFile.fileName + "\n"; }); return strBuilder; @@ -465,8 +465,8 @@ namespace ts.server { } function copyListRemovingItem(item: T, list: T[]) { - var copiedList: T[] = []; - for (var i = 0, len = list.length; i < len; i++) { + const copiedList: T[] = []; + for (let i = 0, len = list.length; i < len; i++) { if (list[i] != item) { copiedList.push(list[i]); } @@ -512,12 +512,12 @@ namespace ts.server { this.hostConfiguration = { formatCodeOptions: ts.clone(CompilerService.defaultFormatCodeOptions), hostInfo: "Unknown host" - } + }; } getFormatCodeOptions(file?: string) { if (file) { - var info = this.filenameToScriptInfo[file]; + const info = this.filenameToScriptInfo[file]; if (info) { return info.formatCodeOptions; } @@ -526,7 +526,7 @@ namespace ts.server { } watchedFileChanged(fileName: string) { - var info = this.filenameToScriptInfo[fileName]; + const info = this.filenameToScriptInfo[fileName]; if (!info) { this.psLogger.info("Error: got watch notification for unknown file: " + fileName); } @@ -629,7 +629,7 @@ namespace ts.server { setHostConfiguration(args: ts.server.protocol.ConfigureRequestArguments) { if (args.file) { - var info = this.filenameToScriptInfo[args.file]; + const info = this.filenameToScriptInfo[args.file]; if (info) { info.setFormatOptions(args.formatOptions); this.log("Host configuration update for file " + args.file, "Info"); @@ -652,7 +652,7 @@ namespace ts.server { } createInferredProject(root: ScriptInfo) { - var project = new Project(this); + const project = new Project(this); project.addRoot(root); let currentPath = ts.getDirectoryPath(root.fileName); @@ -687,21 +687,21 @@ namespace ts.server { if (!info.isOpen) { this.filenameToScriptInfo[info.fileName] = undefined; - var referencingProjects = this.findReferencingProjects(info); + const referencingProjects = this.findReferencingProjects(info); if (info.defaultProject) { info.defaultProject.removeRoot(info); } - for (var i = 0, len = referencingProjects.length; i < len; i++) { + for (let 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]; + for (let j = 0, flen = this.openFileRoots.length; j < flen; j++) { + const openFile = this.openFileRoots[j]; if (this.eventHandler) { this.eventHandler("context", openFile.defaultProject, openFile.fileName); } } - for (var j = 0, flen = this.openFilesReferenced.length; j < flen; j++) { - var openFile = this.openFilesReferenced[j]; + for (let j = 0, flen = this.openFilesReferenced.length; j < flen; j++) { + const openFile = this.openFilesReferenced[j]; if (this.eventHandler) { this.eventHandler("context", openFile.defaultProject, openFile.fileName); } @@ -712,8 +712,8 @@ namespace ts.server { } updateConfiguredProjectList() { - var configuredProjects: Project[] = []; - for (var i = 0, len = this.configuredProjects.length; i < len; i++) { + const configuredProjects: Project[] = []; + for (let i = 0, len = this.configuredProjects.length; i < len; i++) { if (this.configuredProjects[i].openRefCount > 0) { configuredProjects.push(this.configuredProjects[i]); } @@ -750,7 +750,7 @@ namespace ts.server { } setConfiguredProjectRoot(info: ScriptInfo) { - for (var i = 0, len = this.configuredProjects.length; i < len; i++) { + for (let i = 0, len = this.configuredProjects.length; i < len; i++) { let configuredProject = this.configuredProjects[i]; if (configuredProject.isRoot(info)) { info.defaultProject = configuredProject; @@ -773,10 +773,10 @@ namespace ts.server { else { // create new inferred project p with the newly opened file as root info.defaultProject = this.createInferredProject(info); - var openFileRoots: ScriptInfo[] = []; + const openFileRoots: ScriptInfo[] = []; // for each inferred project root r - for (var i = 0, len = this.openFileRoots.length; i < len; i++) { - var r = this.openFileRoots[i]; + for (let i = 0, len = this.openFileRoots.length; i < len; i++) { + const r = this.openFileRoots[i]; // if r referenced by the new project if (info.defaultProject.getSourceFile(r)) { // remove project rooted at r @@ -808,9 +808,9 @@ namespace ts.server { // to the disk, and the server's version of the file can be out of sync. info.svc.reloadFromFile(info.fileName); - var openFileRoots: ScriptInfo[] = []; - var removedProject: Project; - for (var i = 0, len = this.openFileRoots.length; i < len; i++) { + const openFileRoots: ScriptInfo[] = []; + let removedProject: Project; + for (let i = 0, len = this.openFileRoots.length; i < len; i++) { // if closed file is root of project if (info === this.openFileRoots[i]) { // remove that project and remember it @@ -822,9 +822,9 @@ namespace ts.server { } this.openFileRoots = openFileRoots; if (!removedProject) { - var openFileRootsConfigured: ScriptInfo[] = []; + const openFileRootsConfigured: ScriptInfo[] = []; - for (var i = 0, len = this.openFileRootsConfigured.length; i < len; i++) { + for (let i = 0, len = this.openFileRootsConfigured.length; i < len; i++) { if (info === this.openFileRootsConfigured[i]) { if (info.defaultProject.deleteOpenRef() === 0) { removedProject = info.defaultProject; @@ -839,11 +839,11 @@ namespace ts.server { } if (removedProject) { this.removeProject(removedProject); - var openFilesReferenced: ScriptInfo[] = []; - var orphanFiles: ScriptInfo[] = []; + const openFilesReferenced: ScriptInfo[] = []; + const orphanFiles: ScriptInfo[] = []; // for all open, referenced files f - for (var i = 0, len = this.openFilesReferenced.length; i < len; i++) { - var f = this.openFilesReferenced[i]; + for (let i = 0, len = this.openFilesReferenced.length; i < len; i++) { + const f = this.openFilesReferenced[i]; // if f was referenced by the removed project, remember it if (f.defaultProject === removedProject || !f.defaultProject) { f.defaultProject = undefined; @@ -856,7 +856,7 @@ namespace ts.server { } this.openFilesReferenced = openFilesReferenced; // treat orphaned files as newly opened - for (var i = 0, len = orphanFiles.length; i < len; i++) { + for (let i = 0, len = orphanFiles.length; i < len; i++) { this.addOpenFile(orphanFiles[i]); } } @@ -867,10 +867,10 @@ namespace ts.server { } findReferencingProjects(info: ScriptInfo, excludedProject?: Project) { - var referencingProjects: Project[] = []; + const referencingProjects: Project[] = []; info.defaultProject = undefined; - for (var i = 0, len = this.inferredProjects.length; i < len; i++) { - var inferredProject = this.inferredProjects[i]; + for (let i = 0, len = this.inferredProjects.length; i < len; i++) { + const inferredProject = this.inferredProjects[i]; inferredProject.updateGraph(); if (inferredProject !== excludedProject) { if (inferredProject.getSourceFile(info)) { @@ -879,8 +879,8 @@ namespace ts.server { } } } - for (var i = 0, len = this.configuredProjects.length; i < len; i++) { - var configuredProject = this.configuredProjects[i]; + for (let i = 0, len = this.configuredProjects.length; i < len; i++) { + const configuredProject = this.configuredProjects[i]; configuredProject.updateGraph(); if (configuredProject.getSourceFile(info)) { info.defaultProject = configuredProject; @@ -928,11 +928,11 @@ namespace ts.server { // project roots. For each referenced file, see if the default project still // references that file. If so, then just keep the file in the referenced list. // If not, add the file to an unattached list, to be rechecked later. - var openFilesReferenced: ScriptInfo[] = []; - for (var i = 0, len = this.openFilesReferenced.length; i < len; i++) { - var referencedFile = this.openFilesReferenced[i]; + const openFilesReferenced: ScriptInfo[] = []; + for (let i = 0, len = this.openFilesReferenced.length; i < len; i++) { + const referencedFile = this.openFilesReferenced[i]; referencedFile.defaultProject.updateGraph(); - var sourceFile = referencedFile.defaultProject.getSourceFile(referencedFile); + const sourceFile = referencedFile.defaultProject.getSourceFile(referencedFile); if (sourceFile) { openFilesReferenced.push(referencedFile); } @@ -949,11 +949,11 @@ namespace ts.server { // projects newly references the file, remove its project from the // inferred projects list (since it is no longer a root) and add // the file to the open, referenced file list. - var openFileRoots: ScriptInfo[] = []; - 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); + const openFileRoots: ScriptInfo[] = []; + for (let i = 0, len = this.openFileRoots.length; i < len; i++) { + const rootFile = this.openFileRoots[i]; + const rootedProject = rootFile.defaultProject; + const referencingProjects = this.findReferencingProjects(rootFile, rootedProject); if (rootFile.defaultProject && rootFile.defaultProject.isConfiguredProject()) { // If the root file has already been added into a configured project, @@ -980,7 +980,7 @@ namespace ts.server { // Finally, if we found any open, referenced files that are no longer // referenced by their default project, treat them as newly opened // by the editor. - for (var i = 0, len = unattachedOpenFiles.length; i < len; i++) { + for (let i = 0, len = unattachedOpenFiles.length; i < len; i++) { this.addOpenFile(unattachedOpenFiles[i]); } this.printProjects(); @@ -996,9 +996,9 @@ namespace ts.server { */ openFile(fileName: string, openedByClient: boolean) { fileName = ts.normalizePath(fileName); - var info = ts.lookUp(this.filenameToScriptInfo, fileName); + let info = ts.lookUp(this.filenameToScriptInfo, fileName); if (!info) { - var content: string; + let content: string; if (this.host.fileExists(fileName)) { content = this.host.readFile(fileName); } @@ -1008,7 +1008,7 @@ namespace ts.server { } } if (content !== undefined) { - var indentSize: number; + let indentSize: number; info = new ScriptInfo(this.host, fileName, content, openedByClient); info.setFormatOptions(this.getFormatCodeOptions()); this.filenameToScriptInfo[fileName] = info; @@ -1032,11 +1032,11 @@ namespace ts.server { // the newly opened file. findConfigFile(searchPath: string): string { while (true) { - var fileName = ts.combinePaths(searchPath, "tsconfig.json"); + const fileName = ts.combinePaths(searchPath, "tsconfig.json"); if (this.host.fileExists(fileName)) { return fileName; } - var parentPath = ts.getDirectoryPath(searchPath); + const parentPath = ts.getDirectoryPath(searchPath); if (parentPath === searchPath) { break; } @@ -1051,7 +1051,7 @@ namespace ts.server { */ openClientFile(fileName: string) { this.openOrUpdateConfiguredProjectForFile(fileName); - var info = this.openFile(fileName, true); + const info = this.openFile(fileName, true); this.addOpenFile(info); this.printProjects(); return info; @@ -1070,7 +1070,7 @@ namespace ts.server { this.log("Config file name: " + configFileName, "Info"); let project = this.findConfiguredProjectByConfigFile(configFileName); if (!project) { - var configResult = this.openConfigFile(configFileName, fileName); + const configResult = this.openConfigFile(configFileName, fileName); if (!configResult.success) { this.log("Error opening config file " + configFileName + " " + configResult.errorMsg); } @@ -1094,7 +1094,7 @@ namespace ts.server { */ closeClientFile(filename: string) { - var info = ts.lookUp(this.filenameToScriptInfo, filename); + const info = ts.lookUp(this.filenameToScriptInfo, filename); if (info) { this.closeOpenFile(info); info.isOpen = false; @@ -1103,19 +1103,19 @@ namespace ts.server { } getProjectForFile(filename: string) { - var scriptInfo = ts.lookUp(this.filenameToScriptInfo, filename); + const scriptInfo = ts.lookUp(this.filenameToScriptInfo, filename); if (scriptInfo) { return scriptInfo.defaultProject; } } printProjectsForFile(filename: string) { - var scriptInfo = ts.lookUp(this.filenameToScriptInfo, filename); + const scriptInfo = ts.lookUp(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("Projects for " + filename); + const projects = this.findReferencingProjects(scriptInfo); + for (let i = 0, len = projects.length; i < len; i++) { this.psLogger.info("Project " + i.toString()); } this.psLogger.endGroup(); @@ -1130,34 +1130,34 @@ namespace ts.server { return; } this.psLogger.startGroup(); - for (var i = 0, len = this.inferredProjects.length; i < len; i++) { - var project = this.inferredProjects[i]; + for (let i = 0, len = this.inferredProjects.length; i < len; i++) { + const 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]; + for (let i = 0, len = this.configuredProjects.length; i < len; i++) { + const 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("Open file roots of inferred projects: "); + for (let 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; + this.psLogger.info("Open files referenced by inferred or configured projects: "); + for (let i = 0, len = this.openFilesReferenced.length; i < len; i++) { + let 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("Open file roots of configured projects: "); + for (let i = 0, len = this.openFileRootsConfigured.length; i < len; i++) { this.psLogger.info(this.openFileRootsConfigured[i].fileName); } this.psLogger.endGroup(); @@ -1168,7 +1168,7 @@ namespace ts.server { } findConfiguredProjectByConfigFile(configFileName: string) { - for (var i = 0, len = this.configuredProjects.length; i < len; i++) { + for (let i = 0, len = this.configuredProjects.length; i < len; i++) { if (this.configuredProjects[i].projectFilename == configFileName) { return this.configuredProjects[i]; } @@ -1179,22 +1179,24 @@ namespace ts.server { configFileToProjectOptions(configFilename: string): { succeeded: boolean, projectOptions?: ProjectOptions, error?: ProjectOpenResult } { configFilename = ts.normalizePath(configFilename); // file references will be relative to dirPath (or absolute) - var dirPath = ts.getDirectoryPath(configFilename); - var contents = this.host.readFile(configFilename) - var rawConfig: { config?: ProjectOptions; error?: Diagnostic; } = ts.parseConfigFileTextToJson(configFilename, contents); + const dirPath = ts.getDirectoryPath(configFilename); + const contents = this.host.readFile(configFilename); + const rawConfig: { config?: ProjectOptions; error?: Diagnostic; } = ts.parseConfigFileTextToJson(configFilename, contents); if (rawConfig.error) { return { succeeded: false, error: rawConfig.error }; } else { - var parsedCommandLine = ts.parseJsonConfigFileContent(rawConfig.config, this.host, dirPath); + const parsedCommandLine = ts.parseJsonConfigFileContent(rawConfig.config, this.host, dirPath); + Debug.assert(!!parsedCommandLine.fileNames); + if (parsedCommandLine.errors && (parsedCommandLine.errors.length > 0)) { return { succeeded: false, error: { errorMsg: "tsconfig option errors" } }; } - else if (parsedCommandLine.fileNames == null) { + else if (parsedCommandLine.fileNames.length === 0) { return { succeeded: false, error: { errorMsg: "no files found" } }; } else { - var projectOptions: ProjectOptions = { + const projectOptions: ProjectOptions = { files: parsedCommandLine.fileNames, compilerOptions: parsedCommandLine.options }; @@ -1287,7 +1289,7 @@ namespace ts.server { } createProject(projectFilename: string, projectOptions?: ProjectOptions) { - var project = new Project(this, projectOptions); + const project = new Project(this, projectOptions); project.projectFilename = projectFilename; return project; } @@ -1319,14 +1321,14 @@ namespace ts.server { } isExternalModule(filename: string): boolean { - var sourceFile = this.languageService.getSourceFile(filename); + const sourceFile = this.languageService.getSourceFile(filename); return ts.isExternalModule(sourceFile); } static defaultFormatCodeOptions: ts.FormatCodeOptions = { IndentSize: 4, TabSize: 4, - NewLineCharacter: ts.sys ? ts.sys.newLine : '\n', + NewLineCharacter: ts.sys ? ts.sys.newLine : "\n", ConvertTabsToSpaces: true, IndentStyle: ts.IndentStyle.Smart, InsertSpaceAfterCommaDelimiter: true, @@ -1338,7 +1340,7 @@ namespace ts.server { InsertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets: false, PlaceOpenBraceOnNewLineForFunctions: false, PlaceOpenBraceOnNewLineForControlBlocks: false, - } + }; } export interface LineCollection { @@ -1412,17 +1414,17 @@ namespace ts.server { else { insertedText = this.initialText + this.trailingText; } - var lm = LineIndex.linesFromText(insertedText); - var lines = lm.lines; + const lm = LineIndex.linesFromText(insertedText); + const lines = lm.lines; if (lines.length > 1) { if (lines[lines.length - 1] == "") { lines.length--; } } - var branchParent: LineNode; - var lastZeroCount: LineCollection; + let branchParent: LineNode; + let lastZeroCount: LineCollection; - for (var k = this.endBranch.length - 1; k >= 0; k--) { + for (let k = this.endBranch.length - 1; k >= 0; k--) { (this.endBranch[k]).updateCounts(); if (this.endBranch[k].charCount() === 0) { lastZeroCount = this.endBranch[k]; @@ -1439,29 +1441,29 @@ namespace ts.server { } // path at least length two (root and leaf) - var insertionNode = this.startPath[this.startPath.length - 2]; - var leafNode = this.startPath[this.startPath.length - 1]; - var len = lines.length; + let insertionNode = this.startPath[this.startPath.length - 2]; + const leafNode = this.startPath[this.startPath.length - 1]; + const len = lines.length; if (len > 0) { leafNode.text = lines[0]; if (len > 1) { - var insertedNodes = new Array(len - 1); - var startNode = leafNode; - for (var i = 1, len = lines.length; i < len; i++) { + let insertedNodes = new Array(len - 1); + let startNode = leafNode; + for (let i = 1, len = lines.length; i < len; i++) { insertedNodes[i - 1] = new LineLeaf(lines[i]); } - var pathIndex = this.startPath.length - 2; + let pathIndex = this.startPath.length - 2; while (pathIndex >= 0) { insertionNode = this.startPath[pathIndex]; insertedNodes = insertionNode.insertAt(startNode, insertedNodes); pathIndex--; startNode = insertionNode; } - var insertedNodesLen = insertedNodes.length; + let insertedNodesLen = insertedNodes.length; while (insertedNodesLen > 0) { - var newRoot = new LineNode(); + const newRoot = new LineNode(); newRoot.add(this.lineIndex.root); insertedNodes = newRoot.insertAt(this.lineIndex.root, insertedNodes); insertedNodesLen = insertedNodes.length; @@ -1470,7 +1472,7 @@ namespace ts.server { this.lineIndex.root.updateCounts(); } else { - for (var j = this.startPath.length - 2; j >= 0; j--) { + for (let j = this.startPath.length - 2; j >= 0; j--) { (this.startPath[j]).updateCounts(); } } @@ -1478,7 +1480,7 @@ namespace ts.server { else { // no content for leaf node, so delete it insertionNode.remove(leafNode); - for (var j = this.startPath.length - 2; j >= 0; j--) { + for (let j = this.startPath.length - 2; j >= 0; j--) { (this.startPath[j]).updateCounts(); } } @@ -1499,7 +1501,7 @@ namespace ts.server { pre(relativeStart: number, relativeLength: number, lineCollection: LineCollection, parent: LineCollection, nodeType: CharRangeSection) { // currentNode corresponds to parent, but in the new tree - var currentNode = this.stack[this.stack.length - 1]; + const currentNode = this.stack[this.stack.length - 1]; if ((this.state === CharRangeSection.Entire) && (nodeType === CharRangeSection.Start)) { // if range is on single line, we will never make this state transition @@ -1508,7 +1510,7 @@ namespace ts.server { this.lineCollectionAtBranch = lineCollection; } - var child: LineCollection; + let child: LineCollection; function fresh(node: LineCollection): LineCollection { if (node.isLeaf()) { return new LineLeaf(""); @@ -1633,7 +1635,7 @@ namespace ts.server { } reloadFromFile(filename: string, cb?: () => any) { - var content = this.host.readFile(filename); + const content = this.host.readFile(filename); this.reload(content); if (cb) cb(); @@ -1643,13 +1645,13 @@ namespace ts.server { reload(script: string) { this.currentVersion++; this.changes = []; // history wiped out by reload - var snap = new LineIndexSnapshot(this.currentVersion, this); + const snap = new LineIndexSnapshot(this.currentVersion, this); this.versions[this.currentVersion] = snap; snap.index = new LineIndex(); - var lm = LineIndex.linesFromText(script); + const lm = LineIndex.linesFromText(script); snap.index.load(lm.lines); // REVIEW: could use linked list - for (var i = this.minVersion; i < this.currentVersion; i++) { + for (let i = this.minVersion; i < this.currentVersion; i++) { this.versions[i] = undefined; } this.minVersion = this.currentVersion; @@ -1657,11 +1659,11 @@ namespace ts.server { } getSnapshot() { - var snap = this.versions[this.currentVersion]; + let snap = this.versions[this.currentVersion]; if (this.changes.length > 0) { - var snapIndex = this.latest().index; - for (var i = 0, len = this.changes.length; i < len; i++) { - var change = this.changes[i]; + let snapIndex = this.latest().index; + for (let i = 0, len = this.changes.length; i < len; i++) { + const change = this.changes[i]; snapIndex = snapIndex.edit(change.pos, change.deleteLen, change.insertedText); } snap = new LineIndexSnapshot(this.currentVersion + 1, this); @@ -1671,9 +1673,9 @@ namespace ts.server { this.versions[snap.version] = snap; this.changes = []; if ((this.currentVersion - this.minVersion) >= ScriptVersionCache.maxVersions) { - var oldMin = this.minVersion; + const oldMin = this.minVersion; this.minVersion = (this.currentVersion - ScriptVersionCache.maxVersions) + 1; - for (var j = oldMin; j < this.minVersion; j++) { + for (let j = oldMin; j < this.minVersion; j++) { this.versions[j] = undefined; } } @@ -1684,11 +1686,11 @@ namespace ts.server { getTextChangesBetweenVersions(oldVersion: number, newVersion: number) { if (oldVersion < newVersion) { if (oldVersion >= this.minVersion) { - var textChangeRanges: ts.TextChangeRange[] = []; - for (var i = oldVersion + 1; i <= newVersion; i++) { - var snap = this.versions[i]; - for (var j = 0, len = snap.changesSincePreviousVersion.length; j < len; j++) { - var textChange = snap.changesSincePreviousVersion[j]; + const textChangeRanges: ts.TextChangeRange[] = []; + for (let i = oldVersion + 1; i <= newVersion; i++) { + const snap = this.versions[i]; + for (let j = 0, len = snap.changesSincePreviousVersion.length; j < len; j++) { + const textChange = snap.changesSincePreviousVersion[j]; textChangeRanges[textChangeRanges.length] = textChange.getTextChangeRange(); } } @@ -1704,12 +1706,12 @@ namespace ts.server { } static fromString(host: ServerHost, script: string) { - var svc = new ScriptVersionCache(); - var snap = new LineIndexSnapshot(0, svc); + const svc = new ScriptVersionCache(); + const snap = new LineIndexSnapshot(0, svc); svc.versions[svc.currentVersion] = snap; svc.host = host; snap.index = new LineIndex(); - var lm = LineIndex.linesFromText(script); + const lm = LineIndex.linesFromText(script); snap.index.load(lm.lines); return svc; } @@ -1732,9 +1734,9 @@ namespace ts.server { // this requires linear space so don't hold on to these getLineStartPositions(): number[] { - var starts: number[] = [-1]; - var count = 1; - var pos = 0; + const starts: number[] = [-1]; + let count = 1; + let pos = 0; this.index.every((ll, s, len) => { starts[count++] = pos; pos += ll.text.length; @@ -1758,7 +1760,7 @@ namespace ts.server { } } getChangeRange(oldSnapshot: ts.IScriptSnapshot): ts.TextChangeRange { - var oldSnap = oldSnapshot; + const oldSnap = oldSnapshot; return this.getTextChangeRangeSinceVersion(oldSnap.version); } } @@ -1773,9 +1775,9 @@ namespace ts.server { } lineNumberToInfo(lineNumber: number): ILineInfo { - var lineCount = this.root.lineCount(); + const lineCount = this.root.lineCount(); if (lineNumber <= lineCount) { - var lineInfo = this.root.lineNumberToInfo(lineNumber, 0); + const lineInfo = this.root.lineNumberToInfo(lineNumber, 0); lineInfo.line = lineNumber; return lineInfo; } @@ -1783,14 +1785,14 @@ namespace ts.server { return { line: lineNumber, offset: this.root.charCount() - } + }; } } load(lines: string[]) { if (lines.length > 0) { - var leaves: LineLeaf[] = []; - for (var i = 0, len = lines.length; i < len; i++) { + const leaves: LineLeaf[] = []; + for (let i = 0, len = lines.length; i < len; i++) { leaves[i] = new LineLeaf(lines[i]); } this.root = LineIndex.buildTreeFromBottom(leaves); @@ -1805,7 +1807,7 @@ namespace ts.server { } getText(rangeStart: number, rangeLength: number) { - var accum = ""; + let accum = ""; if ((rangeLength > 0) && (rangeStart < this.root.charCount())) { this.walk(rangeStart, rangeLength, { goSubtree: true, @@ -1826,7 +1828,7 @@ namespace ts.server { if (!rangeEnd) { rangeEnd = this.root.charCount(); } - var walkFns = { + const walkFns = { goSubtree: true, done: false, leaf: function (relativeStart: number, relativeLength: number, ll: LineLeaf) { @@ -1834,7 +1836,7 @@ namespace ts.server { this.done = true; } } - } + }; this.walk(rangeStart, rangeEnd - rangeStart, walkFns); return !walkFns.done; } @@ -1851,14 +1853,15 @@ namespace ts.server { } } else { + let checkText: string; if (this.checkEdits) { - var checkText = editFlat(this.getText(0, this.root.charCount()), pos, deleteLength, newText); + checkText = editFlat(this.getText(0, this.root.charCount()), pos, deleteLength, newText); } - var walker = new EditWalker(); + const walker = new EditWalker(); if (pos >= this.root.charCount()) { // insert at end pos = this.root.charCount() - 1; - var endString = this.getText(pos, 1); + const endString = this.getText(pos, 1); if (newText) { newText = endString + newText; } @@ -1870,8 +1873,8 @@ namespace ts.server { } else if (deleteLength > 0) { // check whether last characters deleted are line break - var e = pos + deleteLength; - var lineInfo = this.charOffsetToLineNumberAndPos(e); + const e = pos + deleteLength; + const lineInfo = this.charOffsetToLineNumberAndPos(e); if ((lineInfo && (lineInfo.offset === 0))) { // move range end just past line that will merge with previous line deleteLength += lineInfo.text.length; @@ -1889,7 +1892,7 @@ namespace ts.server { walker.insertLines(newText); } if (this.checkEdits) { - var updatedText = this.getText(0, this.root.charCount()); + const updatedText = this.getText(0, this.root.charCount()); Debug.assert(checkText == updatedText, "buffer edit mismatch"); } return walker.lineIndex; @@ -1897,14 +1900,14 @@ namespace ts.server { } static buildTreeFromBottom(nodes: LineCollection[]): LineNode { - var nodeCount = Math.ceil(nodes.length / lineCollectionCapacity); - var interiorNodes: LineNode[] = []; - var nodeIndex = 0; - for (var i = 0; i < nodeCount; i++) { + const nodeCount = Math.ceil(nodes.length / lineCollectionCapacity); + const interiorNodes: LineNode[] = []; + let nodeIndex = 0; + for (let i = 0; i < nodeCount; i++) { interiorNodes[i] = new LineNode(); - var charCount = 0; - var lineCount = 0; - for (var j = 0; j < lineCollectionCapacity; j++) { + let charCount = 0; + let lineCount = 0; + for (let j = 0; j < lineCollectionCapacity; j++) { if (nodeIndex < nodes.length) { interiorNodes[i].add(nodes[nodeIndex]); charCount += nodes[nodeIndex].charCount(); @@ -1927,18 +1930,18 @@ namespace ts.server { } static linesFromText(text: string) { - var lineStarts = ts.computeLineStarts(text); + const lineStarts = ts.computeLineStarts(text); if (lineStarts.length === 0) { return { lines: [], lineMap: lineStarts }; } - var lines = new Array(lineStarts.length); - var lc = lineStarts.length - 1; - for (var lmi = 0; lmi < lc; lmi++) { + const lines = new Array(lineStarts.length); + const lc = lineStarts.length - 1; + for (let lmi = 0; lmi < lc; lmi++) { lines[lmi] = text.substring(lineStarts[lmi], lineStarts[lmi + 1]); } - var endText = text.substring(lineStarts[lc]); + const endText = text.substring(lineStarts[lc]); if (endText.length > 0) { lines[lc] = endText; } @@ -1961,8 +1964,8 @@ namespace ts.server { updateCounts() { this.totalChars = 0; this.totalLines = 0; - for (var i = 0, len = this.children.length; i < len; i++) { - var child = this.children[i]; + for (let i = 0, len = this.children.length; i < len; i++) { + const child = this.children[i]; this.totalChars += child.charCount(); this.totalLines += child.lineCount(); } @@ -1993,11 +1996,11 @@ namespace ts.server { walk(rangeStart: number, rangeLength: number, walkFns: ILineIndexWalker) { // assume (rangeStart < this.totalChars) && (rangeLength <= this.totalChars) - var childIndex = 0; - var child = this.children[0]; - var childCharCount = child.charCount(); + let childIndex = 0; + let child = this.children[0]; + let childCharCount = child.charCount(); // find sub-tree containing start - var adjustedStart = rangeStart; + let adjustedStart = rangeStart; while (adjustedStart >= childCharCount) { this.skipChild(adjustedStart, rangeLength, childIndex, walkFns, CharRangeSection.PreStart); adjustedStart -= childCharCount; @@ -2015,7 +2018,7 @@ namespace ts.server { if (this.execWalk(adjustedStart, childCharCount - adjustedStart, walkFns, childIndex, CharRangeSection.Start)) { return; } - var adjustedLength = rangeLength - (childCharCount - adjustedStart); + let adjustedLength = rangeLength - (childCharCount - adjustedStart); child = this.children[++childIndex]; childCharCount = child.charCount(); while (adjustedLength > childCharCount) { @@ -2034,9 +2037,9 @@ namespace ts.server { } // Process any subtrees after the one containing range end if (walkFns.pre) { - var clen = this.children.length; + const clen = this.children.length; if (childIndex < (clen - 1)) { - for (var ej = childIndex + 1; ej < clen; ej++) { + for (let ej = childIndex + 1; ej < clen; ej++) { this.skipChild(0, 0, ej, walkFns, CharRangeSection.PostEnd); } } @@ -2044,12 +2047,12 @@ namespace ts.server { } charOffsetToLineNumberAndPos(lineNumber: number, charOffset: number): ILineInfo { - var childInfo = this.childFromCharOffset(lineNumber, charOffset); + const childInfo = this.childFromCharOffset(lineNumber, charOffset); if (!childInfo.child) { return { line: lineNumber, offset: charOffset, - } + }; } else if (childInfo.childIndex < this.children.length) { if (childInfo.child.isLeaf()) { @@ -2061,23 +2064,23 @@ namespace ts.server { }; } else { - var lineNode = (childInfo.child); + const lineNode = (childInfo.child); return lineNode.charOffsetToLineNumberAndPos(childInfo.lineNumber, childInfo.charOffset); } } else { - var lineInfo = this.lineNumberToInfo(this.lineCount(), 0); + const lineInfo = this.lineNumberToInfo(this.lineCount(), 0); return { line: this.lineCount(), offset: lineInfo.leaf.charCount() }; } } lineNumberToInfo(lineNumber: number, charOffset: number): ILineInfo { - var childInfo = this.childFromLineNumber(lineNumber, charOffset); + const childInfo = this.childFromLineNumber(lineNumber, charOffset); if (!childInfo.child) { return { line: lineNumber, offset: charOffset - } + }; } else if (childInfo.child.isLeaf()) { return { @@ -2085,20 +2088,22 @@ namespace ts.server { offset: childInfo.charOffset, text: ((childInfo.child)).text, leaf: ((childInfo.child)) - } + }; } else { - var lineNode = (childInfo.child); + const lineNode = (childInfo.child); return lineNode.lineNumberToInfo(childInfo.relativeLineNumber, childInfo.charOffset); } } childFromLineNumber(lineNumber: number, charOffset: number) { - var child: LineCollection; - var relativeLineNumber = lineNumber; - for (var i = 0, len = this.children.length; i < len; i++) { + let child: LineCollection; + let relativeLineNumber = lineNumber; + let i: number; + let len: number; + for (i = 0, len = this.children.length; i < len; i++) { child = this.children[i]; - var childLineCount = child.lineCount(); + const childLineCount = child.lineCount(); if (childLineCount >= relativeLineNumber) { break; } @@ -2116,8 +2121,10 @@ namespace ts.server { } childFromCharOffset(lineNumber: number, charOffset: number) { - var child: LineCollection; - for (var i = 0, len = this.children.length; i < len; i++) { + let child: LineCollection; + let i: number; + let len: number; + for (i = 0, len = this.children.length; i < len; i++) { child = this.children[i]; if (child.charCount() > charOffset) { break; @@ -2132,14 +2139,14 @@ namespace ts.server { childIndex: i, charOffset: charOffset, lineNumber: lineNumber - } + }; } splitAfter(childIndex: number) { - var splitNode: LineNode; - var clen = this.children.length; + let splitNode: LineNode; + const clen = this.children.length; childIndex++; - var endLength = childIndex; + const endLength = childIndex; if (childIndex < clen) { splitNode = new LineNode(); while (childIndex < clen) { @@ -2152,10 +2159,10 @@ namespace ts.server { } remove(child: LineCollection) { - var childIndex = this.findChildIndex(child); - var clen = this.children.length; + const childIndex = this.findChildIndex(child); + const clen = this.children.length; if (childIndex < (clen - 1)) { - for (var i = childIndex; i < (clen - 1); i++) { + for (let i = childIndex; i < (clen - 1); i++) { this.children[i] = this.children[i + 1]; } } @@ -2163,16 +2170,16 @@ namespace ts.server { } findChildIndex(child: LineCollection) { - var childIndex = 0; - var clen = this.children.length; + let childIndex = 0; + const clen = this.children.length; while ((this.children[childIndex] !== child) && (childIndex < clen)) childIndex++; return childIndex; } insertAt(child: LineCollection, nodes: LineCollection[]) { - var childIndex = this.findChildIndex(child); - var clen = this.children.length; - var nodeCount = nodes.length; + let childIndex = this.findChildIndex(child); + const clen = this.children.length; + const nodeCount = nodes.length; // if child is last and there is more room and only one node to place, place it if ((clen < lineCollectionCapacity) && (childIndex === (clen - 1)) && (nodeCount === 1)) { this.add(nodes[0]); @@ -2180,22 +2187,22 @@ namespace ts.server { return []; } else { - var shiftNode = this.splitAfter(childIndex); - var nodeIndex = 0; + const shiftNode = this.splitAfter(childIndex); + let nodeIndex = 0; childIndex++; while ((childIndex < lineCollectionCapacity) && (nodeIndex < nodeCount)) { this.children[childIndex++] = nodes[nodeIndex++]; } - var splitNodes: LineNode[] = []; - var splitNodeCount = 0; + let splitNodes: LineNode[] = []; + let splitNodeCount = 0; if (nodeIndex < nodeCount) { splitNodeCount = Math.ceil((nodeCount - nodeIndex) / lineCollectionCapacity); splitNodes = new Array(splitNodeCount); - var splitNodeIndex = 0; - for (var i = 0; i < splitNodeCount; i++) { + let splitNodeIndex = 0; + for (let i = 0; i < splitNodeCount; i++) { splitNodes[i] = new LineNode(); } - var splitNode = splitNodes[0]; + let splitNode = splitNodes[0]; while (nodeIndex < nodeCount) { splitNode.add(nodes[nodeIndex++]); if (splitNode.children.length === lineCollectionCapacity) { @@ -2203,7 +2210,7 @@ namespace ts.server { splitNode = splitNodes[splitNodeIndex]; } } - for (i = splitNodes.length - 1; i >= 0; i--) { + for (let i = splitNodes.length - 1; i >= 0; i--) { if (splitNodes[i].children.length === 0) { splitNodes.length--; } @@ -2213,7 +2220,7 @@ namespace ts.server { splitNodes[splitNodes.length] = shiftNode; } this.updateCounts(); - for (i = 0; i < splitNodeCount; i++) { + for (let i = 0; i < splitNodeCount; i++) { (splitNodes[i]).updateCounts(); } return splitNodes; diff --git a/src/server/protocol.d.ts b/src/server/protocol.d.ts index ce918abda3c..ad1fc5e92de 100644 --- a/src/server/protocol.d.ts +++ b/src/server/protocol.d.ts @@ -16,7 +16,7 @@ declare namespace ts.server.protocol { */ type: string; } - + /** * Client-initiated request message */ @@ -31,7 +31,7 @@ declare namespace ts.server.protocol { */ arguments?: any; } - + /** * Request to reload the project structure for all the opened files */ @@ -107,7 +107,7 @@ declare namespace ts.server.protocol { * A request to get the project information of the current file */ export interface ProjectInfoRequest extends Request { - arguments: ProjectInfoRequestArgs + arguments: ProjectInfoRequestArgs; } /** @@ -200,7 +200,7 @@ declare namespace ts.server.protocol { /** * Object found in response messages defining a span of text in source code. */ - export interface TextSpan { + export interface TextSpan { /** * First character of the definition. */ @@ -261,18 +261,18 @@ declare namespace ts.server.protocol { * in the file at a given line and column. */ export interface DocumentHighlightsRequest extends FileLocationRequest { - arguments: DocumentHighlightsRequestArgs + arguments: DocumentHighlightsRequestArgs; } export interface HighlightSpan extends TextSpan { - kind: string + kind: string; } export interface DocumentHighlightsItem { /** * File containing highlight spans. */ - file: string, + file: string; /** * Spans to highlight in file. @@ -422,76 +422,76 @@ declare namespace ts.server.protocol { * 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; - + /** 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; + 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 statemen. 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 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; - + /** Index operator */ - [key:string] : string | number | boolean; + [key: string] : string | number | boolean; } - + /** * Information found in a configure request. */ export 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?: FormatOptions; + formatOptions?: FormatOptions; } /** @@ -561,27 +561,27 @@ declare namespace ts.server.protocol { * 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. */ @@ -603,7 +603,7 @@ declare namespace ts.server.protocol { * 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. */ @@ -619,7 +619,7 @@ declare namespace ts.server.protocol { */ export interface FormatRequest extends FileLocationRequest { arguments: FormatRequestArgs; - } + } /** * Object found in response messages defining an editing @@ -638,7 +638,7 @@ declare namespace ts.server.protocol { * 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). @@ -723,7 +723,7 @@ declare namespace ts.server.protocol { * Text of an item describing the symbol. */ text: string; - + /** * The symbol's kind (such as 'className' or 'parameterName' or plain 'text'). */ @@ -773,7 +773,7 @@ declare namespace ts.server.protocol { * Display parts of the symbol (similar to quick info). */ displayParts: SymbolDisplayPart[]; - + /** * Documentation strings for the symbol. */ @@ -790,94 +790,94 @@ declare namespace ts.server.protocol { /** * Signature help information for a single parameter - */ + */ export 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. - */ + */ export interface SignatureHelpItem { - + /** * Whether the signature accepts a variable number of arguments. - */ + */ isVariadic: boolean; - + /** * The prefix display parts. - */ + */ prefixDisplayParts: SymbolDisplayPart[]; - + /** * The suffix disaply 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. */ export 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; } @@ -885,9 +885,9 @@ declare namespace ts.server.protocol { * Arguments of a signature help request. */ export interface SignatureHelpRequestArgs extends FileLocationRequestArgs { - + } - + /** * Signature help request; value of command field is "signatureHelp". * Given a file location (file, line, col), return the signature @@ -899,7 +899,7 @@ declare namespace ts.server.protocol { /** * Repsonse object for a SignatureHelpRequest. - */ + */ export interface SignatureHelpResponse extends Response { body?: SignatureHelpItems; } @@ -926,9 +926,9 @@ declare namespace ts.server.protocol { * it request for every file in this project. */ export interface GeterrForProjectRequest extends Request { - arguments: GeterrForProjectRequestArgs + arguments: GeterrForProjectRequestArgs; } - + /** * Arguments for geterr messages. */ @@ -968,12 +968,12 @@ declare namespace ts.server.protocol { * Starting file location at which text appies. */ start: Location; - + /** * The last file location at which the text applies. */ end: Location; - + /** * Text of diagnostic message. */ @@ -985,7 +985,7 @@ declare namespace ts.server.protocol { * The file for which diagnostic information is reported. */ file: string; - + /** * An array of diagnostic information items. */ @@ -999,7 +999,7 @@ declare namespace ts.server.protocol { export interface DiagnosticEvent extends Event { body?: DiagnosticEventBody; } - + /** * Arguments for reload request. */ @@ -1083,12 +1083,12 @@ declare namespace ts.server.protocol { * The symbol's name. */ name: string; - + /** * The symbol's kind (such as 'className' or 'parameterName'). */ kind: string; - + /** * exact, substring, or prefix. */ @@ -1098,39 +1098,39 @@ declare namespace ts.server.protocol { * 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. @@ -1208,7 +1208,7 @@ declare namespace ts.server.protocol { childItems?: NavigationBarItem[]; } - export interface NavBarResponse extends Response { + export interface NavBarResponse extends Response { body?: NavigationBarItem[]; } } diff --git a/src/server/server.ts b/src/server/server.ts index f48be53520e..842dfef28c0 100644 --- a/src/server/server.ts +++ b/src/server/server.ts @@ -1,13 +1,15 @@ /// /// +// used in fs.writeSync +/* tslint:disable:no-null */ namespace ts.server { - var nodeproto: typeof NodeJS._debugger = require('_debugger'); - var readline: NodeJS.ReadLine = require('readline'); - var path: NodeJS.Path = require('path'); - var fs: typeof NodeJS.fs = require('fs'); + const nodeproto: typeof NodeJS._debugger = require("_debugger"); + const readline: NodeJS.ReadLine = require("readline"); + const path: NodeJS.Path = require("path"); + const fs: typeof NodeJS.fs = require("fs"); - var rl = readline.createInterface({ + const rl = readline.createInterface({ input: process.stdin, output: process.stdout, terminal: false, @@ -68,7 +70,7 @@ namespace ts.server { } if (this.fd >= 0) { s = s + "\n"; - var prefix = Logger.padStringRight(type + " " + this.seq.toString(), " "); + const prefix = Logger.padStringRight(type + " " + this.seq.toString(), " "); if (this.firstInGroup) { s = prefix + s; this.firstInGroup = false; @@ -77,7 +79,7 @@ namespace ts.server { this.seq++; this.firstInGroup = true; } - var buf = new Buffer(s); + const buf = new Buffer(s); fs.writeSync(this.fd, buf, 0, buf.length, null); } } @@ -95,12 +97,12 @@ namespace ts.server { } listen() { - rl.on('line', (input: string) => { - var message = input.trim(); + rl.on("line", (input: string) => { + const message = input.trim(); this.onMessage(message); }); - rl.on('close', () => { + rl.on("close", () => { this.exit(); }); } @@ -112,11 +114,11 @@ namespace ts.server { } function parseLoggingEnvironmentString(logEnvStr: string): LogOptions { - var logEnv: LogOptions = {}; - var args = logEnvStr.split(' '); - for (var i = 0, len = args.length; i < (len - 1); i += 2) { - var option = args[i]; - var value = args[i + 1]; + const logEnv: LogOptions = {}; + const args = logEnvStr.split(" "); + for (let i = 0, len = args.length; i < (len - 1); i += 2) { + const option = args[i]; + const value = args[i + 1]; if (option && value) { switch (option) { case "-file": @@ -133,11 +135,11 @@ namespace ts.server { // TSS_LOG "{ level: "normal | verbose | terse", file?: string}" function createLoggerFromEnv() { - var fileName: string = undefined; - var detailLevel = "normal"; - var logEnvStr = process.env["TSS_LOG"]; + let fileName: string = undefined; + let detailLevel = "normal"; + const logEnvStr = process.env["TSS_LOG"]; if (logEnvStr) { - var logEnv = parseLoggingEnvironmentString(logEnvStr); + const logEnv = parseLoggingEnvironmentString(logEnvStr); if (logEnv.file) { fileName = logEnv.file; } @@ -153,7 +155,7 @@ namespace ts.server { // This places log file in the directory containing editorServices.js // TODO: check that this location is writable - var logger = createLoggerFromEnv(); + const logger = createLoggerFromEnv(); let pending: string[] = []; let canWrite = true; @@ -177,8 +179,8 @@ namespace ts.server { // Override sys.write because fs.writeSync is not reliable on Node 4 ts.sys.write = (s: string) => writeMessage(s); - var ioSession = new IOSession(ts.sys, logger); - process.on('uncaughtException', function(err: Error) { + const ioSession = new IOSession(ts.sys, logger); + process.on("uncaughtException", function(err: Error) { ioSession.logError(err, "unknown"); }); // Start listening diff --git a/src/server/session.ts b/src/server/session.ts index 550b551e51a..694fcebf630 100644 --- a/src/server/session.ts +++ b/src/server/session.ts @@ -4,7 +4,7 @@ /// namespace ts.server { - var spaceCache:string[] = []; + const spaceCache: string[] = []; interface StackTraceError extends Error { stack?: string; @@ -12,30 +12,31 @@ namespace ts.server { export function generateSpaces(n: number): string { if (!spaceCache[n]) { - var strBuilder = ""; - for (var i = 0; i < n; i++) { + let strBuilder = ""; + for (let i = 0; i < n; i++) { strBuilder += " "; } spaceCache[n] = strBuilder; - } + } return spaceCache[n]; } export function generateIndentString(n: number, editorOptions: EditorOptions): string { if (editorOptions.ConvertTabsToSpaces) { return generateSpaces(n); - } else { - var result = ""; - for (var i = 0; i < Math.floor(n / editorOptions.TabSize); i++) { + } + else { + let result = ""; + for (let i = 0; i < Math.floor(n / editorOptions.TabSize); i++) { result += "\t"; } - for (var i = 0; i < n % editorOptions.TabSize; i++) { + for (let i = 0; i < n % editorOptions.TabSize; i++) { result += " "; } return result; } } - + interface FileStart { file: string; start: ILineInfo; @@ -56,7 +57,7 @@ namespace ts.server { return -1; } else if (a.file == b.file) { - var n = compareNumber(a.start.line, b.start.line); + const n = compareNumber(a.start.line, b.start.line); if (n === 0) { return compareNumber(a.start.offset, b.start.offset); } @@ -66,7 +67,7 @@ namespace ts.server { return 1; } } - + function formatDiag(fileName: string, project: Project, diag: ts.Diagnostic) { return { start: project.compilerService.host.positionToLineOffset(fileName, diag.start), @@ -81,7 +82,7 @@ namespace ts.server { } function allEditsBeforePos(edits: ts.TextChange[], pos: number) { - for (var i = 0, len = edits.length; i < len; i++) { + for (let i = 0, len = edits.length; i < len; i++) { if (ts.textSpanEnd(edits[i].span) >= pos) { return false; } @@ -89,7 +90,7 @@ namespace ts.server { return true; } - export module CommandNames { + export namespace CommandNames { export const Brace = "brace"; export const Change = "change"; export const Close = "close"; @@ -119,8 +120,8 @@ namespace ts.server { export const Unknown = "unknown"; } - module Errors { - export var NoProject = new Error("No Project."); + namespace Errors { + export const NoProject = new Error("No Project."); } export interface ServerHost extends ts.System { @@ -136,13 +137,13 @@ namespace ts.server { private changeSeq = 0; constructor( - private host: ServerHost, - private byteLength: (buf: string, encoding?: string) => number, - private hrtime: (start?: number[]) => number[], + private host: ServerHost, + private byteLength: (buf: string, encoding?: string) => number, + private hrtime: (start?: number[]) => number[], private logger: Logger ) { this.projectService = - new ProjectService(host, logger, (eventName,project,fileName) => { + new ProjectService(host, logger, (eventName, project, fileName) => { this.handleEvent(eventName, project, fileName); }); } @@ -156,8 +157,8 @@ namespace ts.server { } public logError(err: Error, cmd: string) { - var typedErr = err; - var msg = "Exception on executing command " + cmd; + const typedErr = err; + let msg = "Exception on executing command " + cmd; if (typedErr.message) { msg += ":\n" + typedErr.message; if (typedErr.stack) { @@ -172,16 +173,16 @@ namespace ts.server { } public send(msg: protocol.Message) { - var json = JSON.stringify(msg); + const json = JSON.stringify(msg); if (this.logger.isVerbose()) { this.logger.info(msg.type + ": " + json); } - this.sendLineToClient('Content-Length: ' + (1 + this.byteLength(json, 'utf8')) + - '\r\n\r\n' + json); + this.sendLineToClient("Content-Length: " + (1 + this.byteLength(json, "utf8")) + + "\r\n\r\n" + json); } public event(info: any, eventName: string) { - var ev: protocol.Event = { + const ev: protocol.Event = { seq: 0, type: "event", event: eventName, @@ -191,13 +192,13 @@ namespace ts.server { } private response(info: any, cmdName: string, reqSeq = 0, errorMsg?: string) { - var res: protocol.Response = { + const res: protocol.Response = { seq: 0, type: "response", command: cmdName, request_seq: reqSeq, success: !errorMsg, - } + }; if (!errorMsg) { res.body = info; } @@ -213,10 +214,10 @@ namespace ts.server { private semanticCheck(file: string, project: Project) { try { - var diags = project.compilerService.languageService.getSemanticDiagnostics(file); + const diags = project.compilerService.languageService.getSemanticDiagnostics(file); if (diags) { - var bakedDiags = diags.map((diag) => formatDiag(file, project, diag)); + const bakedDiags = diags.map((diag) => formatDiag(file, project, diag)); this.event({ file: file, diagnostics: bakedDiags }, "semanticDiag"); } } @@ -227,9 +228,9 @@ namespace ts.server { private syntacticCheck(file: string, project: Project) { try { - var diags = project.compilerService.languageService.getSyntacticDiagnostics(file); + const diags = project.compilerService.languageService.getSyntacticDiagnostics(file); if (diags) { - var bakedDiags = diags.map((diag) => formatDiag(file, project, diag)); + const bakedDiags = diags.map((diag) => formatDiag(file, project, diag)); this.event({ file: file, diagnostics: bakedDiags }, "syntaxDiag"); } } @@ -242,7 +243,7 @@ namespace ts.server { this.syntacticCheck(file, project); this.semanticCheck(file, project); } - + private reloadProjects() { this.projectService.reloadProjects(); } @@ -267,10 +268,10 @@ namespace ts.server { clearImmediate(this.immediateId); this.immediateId = undefined; } - var index = 0; - var checkOne = () => { + let index = 0; + const checkOne = () => { if (matchSeq(seq)) { - var checkSpec = checkList[index++]; + const checkSpec = checkList[index++]; if (checkSpec.project.getSourceFileFromName(checkSpec.fileName, requireOpen)) { this.syntacticCheck(checkSpec.fileName, checkSpec.project); this.immediateId = setImmediate(() => { @@ -285,23 +286,23 @@ namespace ts.server { }); } } - } + }; if ((checkList.length > index) && (matchSeq(seq))) { this.errorTimer = setTimeout(checkOne, ms); } } private getDefinition(line: number, offset: number, fileName: string): protocol.FileSpan[] { - var file = ts.normalizePath(fileName); - var project = this.projectService.getProjectForFile(file); + const file = ts.normalizePath(fileName); + const project = this.projectService.getProjectForFile(file); if (!project) { throw Errors.NoProject; } - var compilerService = project.compilerService; - var position = compilerService.host.lineOffsetToPosition(file, line, offset); + const compilerService = project.compilerService; + const position = compilerService.host.lineOffsetToPosition(file, line, offset); - var definitions = compilerService.languageService.getDefinitionAtPosition(file, position); + const definitions = compilerService.languageService.getDefinitionAtPosition(file, position); if (!definitions) { return undefined; } @@ -314,16 +315,16 @@ namespace ts.server { } private getTypeDefinition(line: number, offset: number, fileName: string): protocol.FileSpan[] { - var file = ts.normalizePath(fileName); - var project = this.projectService.getProjectForFile(file); + const file = ts.normalizePath(fileName); + const project = this.projectService.getProjectForFile(file); if (!project) { throw Errors.NoProject; } - var compilerService = project.compilerService; - var position = compilerService.host.lineOffsetToPosition(file, line, offset); + const compilerService = project.compilerService; + const position = compilerService.host.lineOffsetToPosition(file, line, offset); - var definitions = compilerService.languageService.getTypeDefinitionAtPosition(file, position); + const definitions = compilerService.languageService.getTypeDefinitionAtPosition(file, position); if (!definitions) { return undefined; } @@ -361,7 +362,7 @@ namespace ts.server { end, file: fileName, isWriteAccess - } + }; }); } @@ -375,9 +376,9 @@ namespace ts.server { let { compilerService } = project; let position = compilerService.host.lineOffsetToPosition(fileName, line, offset); - + let documentHighlights = compilerService.languageService.getDocumentHighlights(fileName, position, filesToSearch); - + if (!documentHighlights) { return undefined; } @@ -402,12 +403,12 @@ namespace ts.server { } private getProjectInfo(fileName: string, needFileNameList: boolean): protocol.ProjectInfo { - fileName = ts.normalizePath(fileName) - let project = this.projectService.getProjectForFile(fileName) + fileName = ts.normalizePath(fileName); + let project = this.projectService.getProjectForFile(fileName); let projectInfo: protocol.ProjectInfo = { configFileName: project.projectFilename - } + }; if (needFileNameList) { projectInfo.fileNames = project.getFileNames(); @@ -416,16 +417,16 @@ namespace ts.server { return projectInfo; } - private getRenameLocations(line: number, offset: number, fileName: string,findInComments: boolean, findInStrings: boolean): protocol.RenameResponseBody { - var file = ts.normalizePath(fileName); - var project = this.projectService.getProjectForFile(file); + private getRenameLocations(line: number, offset: number, fileName: string, findInComments: boolean, findInStrings: boolean): protocol.RenameResponseBody { + const file = ts.normalizePath(fileName); + const project = this.projectService.getProjectForFile(file); if (!project) { throw Errors.NoProject; } - var compilerService = project.compilerService; - var position = compilerService.host.lineOffsetToPosition(file, line, offset); - var renameInfo = compilerService.languageService.getRenameInfo(file, position); + const compilerService = project.compilerService; + const position = compilerService.host.lineOffsetToPosition(file, line, offset); + const renameInfo = compilerService.languageService.getRenameInfo(file, position); if (!renameInfo) { return undefined; } @@ -437,12 +438,12 @@ namespace ts.server { }; } - var renameLocations = compilerService.languageService.findRenameLocations(file, position, findInStrings, findInComments); + const renameLocations = compilerService.languageService.findRenameLocations(file, position, findInStrings, findInComments); if (!renameLocations) { return undefined; } - var bakedRenameLocs = renameLocations.map(location => ({ + const bakedRenameLocs = renameLocations.map(location => ({ file: location.fileName, start: compilerService.host.positionToLineOffset(location.fileName, location.textSpan.start), end: compilerService.host.positionToLineOffset(location.fileName, ts.textSpanEnd(location.textSpan)), @@ -466,7 +467,7 @@ namespace ts.server { } } }).reduce((accum: protocol.SpanGroup[], cur: protocol.FileSpan) => { - var curFileAccum: protocol.SpanGroup; + let curFileAccum: protocol.SpanGroup; if (accum.length > 0) { curFileAccum = accum[accum.length - 1]; if (curFileAccum.file != cur.file) { @@ -487,34 +488,34 @@ namespace ts.server { private getReferences(line: number, offset: number, fileName: string): protocol.ReferencesResponseBody { // TODO: get all projects for this file; report refs for all projects deleting duplicates // can avoid duplicates by eliminating same ref file from subsequent projects - var file = ts.normalizePath(fileName); - var project = this.projectService.getProjectForFile(file); + const file = ts.normalizePath(fileName); + const project = this.projectService.getProjectForFile(file); if (!project) { throw Errors.NoProject; } - var compilerService = project.compilerService; - var position = compilerService.host.lineOffsetToPosition(file, line, offset); + const compilerService = project.compilerService; + const position = compilerService.host.lineOffsetToPosition(file, line, offset); - var references = compilerService.languageService.getReferencesAtPosition(file, position); + const references = compilerService.languageService.getReferencesAtPosition(file, position); if (!references) { return undefined; } - var nameInfo = compilerService.languageService.getQuickInfoAtPosition(file, position); + const nameInfo = compilerService.languageService.getQuickInfoAtPosition(file, position); if (!nameInfo) { return undefined; } - var displayString = ts.displayPartsToString(nameInfo.displayParts); - var nameSpan = nameInfo.textSpan; - var nameColStart = compilerService.host.positionToLineOffset(file, nameSpan.start).offset; - var nameText = compilerService.host.getScriptSnapshot(file).getText(nameSpan.start, ts.textSpanEnd(nameSpan)); - var bakedRefs: protocol.ReferencesResponseItem[] = references.map(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, ""); + const displayString = ts.displayPartsToString(nameInfo.displayParts); + const nameSpan = nameInfo.textSpan; + const nameColStart = compilerService.host.positionToLineOffset(file, nameSpan.start).offset; + const nameText = compilerService.host.getScriptSnapshot(file).getText(nameSpan.start, ts.textSpanEnd(nameSpan)); + const bakedRefs: protocol.ReferencesResponseItem[] = references.map(ref => { + const start = compilerService.host.positionToLineOffset(ref.fileName, ref.textSpan.start); + const refLineSpan = compilerService.host.lineToTextSpan(ref.fileName, start.line - 1); + const snap = compilerService.host.getScriptSnapshot(ref.fileName); + const lineText = snap.getText(refLineSpan.start, ts.textSpanEnd(refLineSpan)).replace(/\r|\n/g, ""); return { file: ref.fileName, start: start, @@ -532,26 +533,26 @@ namespace ts.server { } private openClientFile(fileName: string) { - var file = ts.normalizePath(fileName); + const file = ts.normalizePath(fileName); this.projectService.openClientFile(file); } private getQuickInfo(line: number, offset: number, fileName: string): protocol.QuickInfoResponseBody { - var file = ts.normalizePath(fileName); - var project = this.projectService.getProjectForFile(file); + const file = ts.normalizePath(fileName); + const project = this.projectService.getProjectForFile(file); if (!project) { throw Errors.NoProject; } - var compilerService = project.compilerService; - var position = compilerService.host.lineOffsetToPosition(file, line, offset); - var quickInfo = compilerService.languageService.getQuickInfoAtPosition(file, position); + const compilerService = project.compilerService; + const position = compilerService.host.lineOffsetToPosition(file, line, offset); + const quickInfo = compilerService.languageService.getQuickInfoAtPosition(file, position); if (!quickInfo) { return undefined; } - var displayString = ts.displayPartsToString(quickInfo.displayParts); - var docString = ts.displayPartsToString(quickInfo.documentation); + const displayString = ts.displayPartsToString(quickInfo.displayParts); + const docString = ts.displayPartsToString(quickInfo.documentation); return { kind: quickInfo.kind, kindModifiers: quickInfo.kindModifiers, @@ -563,18 +564,18 @@ namespace ts.server { } private getFormattingEditsForRange(line: number, offset: number, endLine: number, endOffset: number, fileName: string): protocol.CodeEdit[] { - var file = ts.normalizePath(fileName); - var project = this.projectService.getProjectForFile(file); + const file = ts.normalizePath(fileName); + const project = this.projectService.getProjectForFile(file); if (!project) { throw Errors.NoProject; } - var compilerService = project.compilerService; - var startPosition = compilerService.host.lineOffsetToPosition(file, line, offset); - var endPosition = compilerService.host.lineOffsetToPosition(file, endLine, endOffset); - + const compilerService = project.compilerService; + const startPosition = compilerService.host.lineOffsetToPosition(file, line, offset); + const endPosition = compilerService.host.lineOffsetToPosition(file, endLine, endOffset); + // TODO: avoid duplicate code (with formatonkey) - var edits = compilerService.languageService.getFormattingEditsForRange(file, startPosition, endPosition, + const edits = compilerService.languageService.getFormattingEditsForRange(file, startPosition, endPosition, this.projectService.getFormatCodeOptions(file)); if (!edits) { return undefined; @@ -590,17 +591,17 @@ namespace ts.server { } private getFormattingEditsAfterKeystroke(line: number, offset: number, key: string, fileName: string): protocol.CodeEdit[] { - var file = ts.normalizePath(fileName); + const file = ts.normalizePath(fileName); - var project = this.projectService.getProjectForFile(file); + const project = this.projectService.getProjectForFile(file); if (!project) { throw Errors.NoProject; } - var compilerService = project.compilerService; - var position = compilerService.host.lineOffsetToPosition(file, line, offset); - var formatOptions = this.projectService.getFormatCodeOptions(file); - var edits = compilerService.languageService.getFormattingEditsAfterKeystroke(file, position, key, + const compilerService = project.compilerService; + const position = compilerService.host.lineOffsetToPosition(file, line, offset); + const formatOptions = this.projectService.getFormatCodeOptions(file); + const edits = compilerService.languageService.getFormattingEditsAfterKeystroke(file, position, key, formatOptions); // Check whether we should auto-indent. This will be when // the position is on a line containing only whitespace. @@ -609,23 +610,24 @@ namespace ts.server { // only to the previous line. If all this is true, then // add edits necessary to properly indent the current line. if ((key == "\n") && ((!edits) || (edits.length === 0) || allEditsBeforePos(edits, position))) { - var scriptInfo = compilerService.host.getScriptInfo(file); + const scriptInfo = compilerService.host.getScriptInfo(file); if (scriptInfo) { - var lineInfo = scriptInfo.getLineInfo(line); + const lineInfo = scriptInfo.getLineInfo(line); if (lineInfo && (lineInfo.leaf) && (lineInfo.leaf.text)) { - var lineText = lineInfo.leaf.text; + const lineText = lineInfo.leaf.text; if (lineText.search("\\S") < 0) { // TODO: get these options from host - var editorOptions: ts.EditorOptions = { + const editorOptions: ts.EditorOptions = { IndentSize: formatOptions.IndentSize, TabSize: formatOptions.TabSize, NewLineCharacter: "\n", ConvertTabsToSpaces: formatOptions.ConvertTabsToSpaces, IndentStyle: ts.IndentStyle.Smart, }; - var preferredIndent = compilerService.languageService.getIndentationAtPosition(file, position, editorOptions); - var hasIndent = 0; - for (var i = 0, len = lineText.length; i < len; i++) { + const preferredIndent = compilerService.languageService.getIndentationAtPosition(file, position, editorOptions); + let hasIndent = 0; + let i: number, len: number; + for (i = 0, len = lineText.length; i < len; i++) { if (lineText.charAt(i) == " ") { hasIndent++; } @@ -638,7 +640,7 @@ namespace ts.server { } // i points to the first non whitespace character if (preferredIndent !== hasIndent) { - var firstNoWhiteSpacePosition = lineInfo.offset + i; + let firstNoWhiteSpacePosition = lineInfo.offset + i; edits.push({ span: ts.createTextSpanFromBounds(lineInfo.offset, firstNoWhiteSpacePosition), newText: generateIndentString(preferredIndent, editorOptions) @@ -668,16 +670,16 @@ namespace ts.server { if (!prefix) { prefix = ""; } - var file = ts.normalizePath(fileName); - var project = this.projectService.getProjectForFile(file); + const file = ts.normalizePath(fileName); + const project = this.projectService.getProjectForFile(file); if (!project) { throw Errors.NoProject; } - var compilerService = project.compilerService; - var position = compilerService.host.lineOffsetToPosition(file, line, offset); + const compilerService = project.compilerService; + const position = compilerService.host.lineOffsetToPosition(file, line, offset); - var completions = compilerService.languageService.getCompletionsAtPosition(file, position); + const completions = compilerService.languageService.getCompletionsAtPosition(file, position); if (!completions) { return undefined; } @@ -692,17 +694,17 @@ namespace ts.server { private getCompletionEntryDetails(line: number, offset: number, entryNames: string[], fileName: string): protocol.CompletionEntryDetails[] { - var file = ts.normalizePath(fileName); - var project = this.projectService.getProjectForFile(file); + const file = ts.normalizePath(fileName); + const project = this.projectService.getProjectForFile(file); if (!project) { throw Errors.NoProject; } - var compilerService = project.compilerService; - var position = compilerService.host.lineOffsetToPosition(file, line, offset); + const compilerService = project.compilerService; + const position = compilerService.host.lineOffsetToPosition(file, line, offset); return entryNames.reduce((accum: protocol.CompletionEntryDetails[], entryName: string) => { - var details = compilerService.languageService.getCompletionEntryDetails(file, position, entryName); + const details = compilerService.languageService.getCompletionEntryDetails(file, position, entryName); if (details) { accum.push(details); } @@ -711,21 +713,21 @@ namespace ts.server { } private getSignatureHelpItems(line: number, offset: number, fileName: string): protocol.SignatureHelpItems { - var file = ts.normalizePath(fileName); - var project = this.projectService.getProjectForFile(file); + const file = ts.normalizePath(fileName); + const project = this.projectService.getProjectForFile(file); if (!project) { throw Errors.NoProject; } - - var compilerService = project.compilerService; - var position = compilerService.host.lineOffsetToPosition(file, line, offset); - var helpItems = compilerService.languageService.getSignatureHelpItems(file, position); + + const compilerService = project.compilerService; + const position = compilerService.host.lineOffsetToPosition(file, line, offset); + const helpItems = compilerService.languageService.getSignatureHelpItems(file, position); if (!helpItems) { return undefined; } - - var span = helpItems.applicableSpan; - var result: protocol.SignatureHelpItems = { + + const span = helpItems.applicableSpan; + const result: protocol.SignatureHelpItems = { items: helpItems.items, applicableSpan: { start: compilerService.host.positionToLineOffset(file, span.start), @@ -734,15 +736,15 @@ namespace ts.server { selectedItemIndex: helpItems.selectedItemIndex, argumentIndex: helpItems.argumentIndex, argumentCount: helpItems.argumentCount, - } - + }; + return result; } - + private getDiagnostics(delay: number, fileNames: string[]) { - var checkList = fileNames.reduce((accum: PendingErrorCheck[], fileName: string) => { + const checkList = fileNames.reduce((accum: PendingErrorCheck[], fileName: string) => { fileName = ts.normalizePath(fileName); - var project = this.projectService.getProjectForFile(fileName); + const project = this.projectService.getProjectForFile(fileName); if (project) { accum.push({ fileName, project }); } @@ -750,17 +752,17 @@ namespace ts.server { }, []); if (checkList.length > 0) { - this.updateErrorCheck(checkList, this.changeSeq,(n) => n === this.changeSeq, delay) + this.updateErrorCheck(checkList, this.changeSeq, (n) => n === this.changeSeq, delay); } } private change(line: number, offset: number, endLine: number, endOffset: number, insertString: string, fileName: string) { - var file = ts.normalizePath(fileName); - var project = this.projectService.getProjectForFile(file); + const file = ts.normalizePath(fileName); + const project = this.projectService.getProjectForFile(file); if (project) { - var compilerService = project.compilerService; - var start = compilerService.host.lineOffsetToPosition(file, line, offset); - var end = compilerService.host.lineOffsetToPosition(file, endLine, endOffset); + const compilerService = project.compilerService; + const start = compilerService.host.lineOffsetToPosition(file, line, offset); + const end = compilerService.host.lineOffsetToPosition(file, endLine, endOffset); if (start >= 0) { compilerService.host.editScript(file, start, end, insertString); this.changeSeq++; @@ -770,9 +772,9 @@ namespace ts.server { } private reload(fileName: string, tempFileName: string, reqSeq = 0) { - var file = ts.normalizePath(fileName); - var tmpfile = ts.normalizePath(tempFileName); - var project = this.projectService.getProjectForFile(file); + const file = ts.normalizePath(fileName); + const tmpfile = ts.normalizePath(tempFileName); + const project = this.projectService.getProjectForFile(file); if (project) { this.changeSeq++; // make sure no changes happen before this one is finished @@ -783,10 +785,10 @@ namespace ts.server { } private saveToTmp(fileName: string, tempFileName: string) { - var file = ts.normalizePath(fileName); - var tmpfile = ts.normalizePath(tempFileName); + const file = ts.normalizePath(fileName); + const tmpfile = ts.normalizePath(tempFileName); - var project = this.projectService.getProjectForFile(file); + const project = this.projectService.getProjectForFile(file); if (project) { project.compilerService.host.saveTo(file, tmpfile); } @@ -794,7 +796,7 @@ namespace ts.server { private closeClientFile(fileName: string) { if (!fileName) { return; } - var file = ts.normalizePath(fileName); + const file = ts.normalizePath(fileName); this.projectService.closeClientFile(file); } @@ -803,7 +805,7 @@ namespace ts.server { return undefined; } - var compilerService = project.compilerService; + const compilerService = project.compilerService; return items.map(item => ({ text: item.text, @@ -818,14 +820,14 @@ namespace ts.server { } private getNavigationBarItems(fileName: string): protocol.NavigationBarItem[] { - var file = ts.normalizePath(fileName); - var project = this.projectService.getProjectForFile(file); + const file = ts.normalizePath(fileName); + const project = this.projectService.getProjectForFile(file); if (!project) { throw Errors.NoProject; } - var compilerService = project.compilerService; - var items = compilerService.languageService.getNavigationBarItems(file); + const compilerService = project.compilerService; + const items = compilerService.languageService.getNavigationBarItems(file); if (!items) { return undefined; } @@ -834,22 +836,22 @@ namespace ts.server { } private getNavigateToItems(searchValue: string, fileName: string, maxResultCount?: number): protocol.NavtoItem[] { - var file = ts.normalizePath(fileName); - var project = this.projectService.getProjectForFile(file); + const file = ts.normalizePath(fileName); + const project = this.projectService.getProjectForFile(file); if (!project) { throw Errors.NoProject; } - var compilerService = project.compilerService; - var navItems = compilerService.languageService.getNavigateToItems(searchValue, maxResultCount); + const compilerService = project.compilerService; + const navItems = compilerService.languageService.getNavigateToItems(searchValue, maxResultCount); if (!navItems) { return undefined; } return navItems.map((navItem) => { - var start = compilerService.host.positionToLineOffset(navItem.fileName, navItem.textSpan.start); - var end = compilerService.host.positionToLineOffset(navItem.fileName, ts.textSpanEnd(navItem.textSpan)); - var bakedItem: protocol.NavtoItem = { + const start = compilerService.host.positionToLineOffset(navItem.fileName, navItem.textSpan.start); + const end = compilerService.host.positionToLineOffset(navItem.fileName, ts.textSpanEnd(navItem.textSpan)); + const bakedItem: protocol.NavtoItem = { name: navItem.name, kind: navItem.kind, file: navItem.fileName, @@ -859,7 +861,7 @@ namespace ts.server { if (navItem.kindModifiers && (navItem.kindModifiers != "")) { bakedItem.kindModifiers = navItem.kindModifiers; } - if (navItem.matchKind != 'none') { + if (navItem.matchKind !== "none") { bakedItem.matchKind = navItem.matchKind; } if (navItem.containerName && (navItem.containerName.length > 0)) { @@ -873,21 +875,21 @@ namespace ts.server { } private getBraceMatching(line: number, offset: number, fileName: string): protocol.TextSpan[] { - var file = ts.normalizePath(fileName); - - var project = this.projectService.getProjectForFile(file); + const file = ts.normalizePath(fileName); + + const project = this.projectService.getProjectForFile(file); if (!project) { throw Errors.NoProject; } - - var compilerService = project.compilerService; - var position = compilerService.host.lineOffsetToPosition(file, line, offset); - - var spans = compilerService.languageService.getBraceMatchingAtPosition(file, position); + + const compilerService = project.compilerService; + const position = compilerService.host.lineOffsetToPosition(file, line, offset); + + const spans = compilerService.languageService.getBraceMatchingAtPosition(file, position); if (!spans) { return undefined; } - + return spans.map(span => ({ start: compilerService.host.positionToLineOffset(file, span.start), end: compilerService.host.positionToLineOffset(file, span.start + span.length) @@ -943,59 +945,59 @@ namespace ts.server { exit() { } - private handlers : Map<(request: protocol.Request) => {response?: any, responseRequired?: boolean}> = { + private handlers: Map<(request: protocol.Request) => {response?: any, responseRequired?: boolean}> = { [CommandNames.Exit]: () => { this.exit(); return { responseRequired: false}; }, [CommandNames.Definition]: (request: protocol.Request) => { - var defArgs = request.arguments; + const defArgs = request.arguments; return {response: this.getDefinition(defArgs.line, defArgs.offset, defArgs.file), responseRequired: true}; }, [CommandNames.TypeDefinition]: (request: protocol.Request) => { - var defArgs = request.arguments; + const defArgs = request.arguments; return {response: this.getTypeDefinition(defArgs.line, defArgs.offset, defArgs.file), responseRequired: true}; }, [CommandNames.References]: (request: protocol.Request) => { - var defArgs = request.arguments; + const defArgs = request.arguments; return {response: this.getReferences(defArgs.line, defArgs.offset, defArgs.file), responseRequired: true}; }, [CommandNames.Rename]: (request: protocol.Request) => { - var renameArgs = request.arguments; - return {response: this.getRenameLocations(renameArgs.line, renameArgs.offset, renameArgs.file, renameArgs.findInComments, renameArgs.findInStrings), responseRequired: true} + const renameArgs = request.arguments; + return {response: this.getRenameLocations(renameArgs.line, renameArgs.offset, renameArgs.file, renameArgs.findInComments, renameArgs.findInStrings), responseRequired: true}; }, [CommandNames.Open]: (request: protocol.Request) => { - var openArgs = request.arguments; + const openArgs = request.arguments; this.openClientFile(openArgs.file); - return {responseRequired: false} + return {responseRequired: false}; }, [CommandNames.Quickinfo]: (request: protocol.Request) => { - var quickinfoArgs = request.arguments; + const quickinfoArgs = request.arguments; return {response: this.getQuickInfo(quickinfoArgs.line, quickinfoArgs.offset, quickinfoArgs.file), responseRequired: true}; }, [CommandNames.Format]: (request: protocol.Request) => { - var formatArgs = request.arguments; + const formatArgs = request.arguments; return {response: this.getFormattingEditsForRange(formatArgs.line, formatArgs.offset, formatArgs.endLine, formatArgs.endOffset, formatArgs.file), responseRequired: true}; }, [CommandNames.Formatonkey]: (request: protocol.Request) => { - var formatOnKeyArgs = request.arguments; + const formatOnKeyArgs = request.arguments; return {response: this.getFormattingEditsAfterKeystroke(formatOnKeyArgs.line, formatOnKeyArgs.offset, formatOnKeyArgs.key, formatOnKeyArgs.file), responseRequired: true}; }, [CommandNames.Completions]: (request: protocol.Request) => { - var completionsArgs = request.arguments; - return {response: this.getCompletions(completionsArgs.line, completionsArgs.offset, completionsArgs.prefix, completionsArgs.file), responseRequired: true} + const completionsArgs = request.arguments; + return {response: this.getCompletions(completionsArgs.line, completionsArgs.offset, completionsArgs.prefix, completionsArgs.file), responseRequired: true}; }, [CommandNames.CompletionDetails]: (request: protocol.Request) => { - var completionDetailsArgs = request.arguments; - return {response: this.getCompletionEntryDetails(completionDetailsArgs.line,completionDetailsArgs.offset, - completionDetailsArgs.entryNames,completionDetailsArgs.file), responseRequired: true} + const completionDetailsArgs = request.arguments; + return {response: this.getCompletionEntryDetails(completionDetailsArgs.line, completionDetailsArgs.offset, + completionDetailsArgs.entryNames, completionDetailsArgs.file), responseRequired: true}; }, [CommandNames.SignatureHelp]: (request: protocol.Request) => { - var signatureHelpArgs = request.arguments; - return {response: this.getSignatureHelpItems(signatureHelpArgs.line, signatureHelpArgs.offset, signatureHelpArgs.file), responseRequired: true} + const signatureHelpArgs = request.arguments; + return {response: this.getSignatureHelpItems(signatureHelpArgs.line, signatureHelpArgs.offset, signatureHelpArgs.file), responseRequired: true}; }, [CommandNames.Geterr]: (request: protocol.Request) => { - var geterrArgs = request.arguments; + const geterrArgs = request.arguments; return {response: this.getDiagnostics(geterrArgs.delay, geterrArgs.files), responseRequired: false}; }, [CommandNames.GeterrForProject]: (request: protocol.Request) => { @@ -1003,54 +1005,54 @@ namespace ts.server { return {response: this.getDiagnosticsForProject(delay, file), responseRequired: false}; }, [CommandNames.Change]: (request: protocol.Request) => { - var changeArgs = request.arguments; + const changeArgs = request.arguments; this.change(changeArgs.line, changeArgs.offset, changeArgs.endLine, changeArgs.endOffset, changeArgs.insertString, changeArgs.file); - return {responseRequired: false} + return {responseRequired: false}; }, [CommandNames.Configure]: (request: protocol.Request) => { - var configureArgs = request.arguments; + const configureArgs = request.arguments; this.projectService.setHostConfiguration(configureArgs); this.output(undefined, CommandNames.Configure, request.seq); - return {responseRequired: false} + return {responseRequired: false}; }, [CommandNames.Reload]: (request: protocol.Request) => { - var reloadArgs = request.arguments; + const reloadArgs = request.arguments; this.reload(reloadArgs.file, reloadArgs.tmpfile, request.seq); - return {responseRequired: false} + return {responseRequired: false}; }, [CommandNames.Saveto]: (request: protocol.Request) => { - var savetoArgs = request.arguments; + const savetoArgs = request.arguments; this.saveToTmp(savetoArgs.file, savetoArgs.tmpfile); - return {responseRequired: false} + return {responseRequired: false}; }, [CommandNames.Close]: (request: protocol.Request) => { - var closeArgs = request.arguments; + const closeArgs = request.arguments; this.closeClientFile(closeArgs.file); return {responseRequired: false}; }, [CommandNames.Navto]: (request: protocol.Request) => { - var navtoArgs = request.arguments; + const navtoArgs = request.arguments; return {response: this.getNavigateToItems(navtoArgs.searchValue, navtoArgs.file, navtoArgs.maxResultCount), responseRequired: true}; }, [CommandNames.Brace]: (request: protocol.Request) => { - var braceArguments = request.arguments; + const braceArguments = request.arguments; return {response: this.getBraceMatching(braceArguments.line, braceArguments.offset, braceArguments.file), responseRequired: true}; }, [CommandNames.NavBar]: (request: protocol.Request) => { - var navBarArgs = request.arguments; + const navBarArgs = request.arguments; return {response: this.getNavigationBarItems(navBarArgs.file), responseRequired: true}; }, [CommandNames.Occurrences]: (request: protocol.Request) => { - var { line, offset, file: fileName } = request.arguments; + const { line, offset, file: fileName } = request.arguments; return {response: this.getOccurrences(line, offset, fileName), responseRequired: true}; }, [CommandNames.DocumentHighlights]: (request: protocol.Request) => { - var { line, offset, file: fileName, filesToSearch } = request.arguments; + const { line, offset, file: fileName, filesToSearch } = request.arguments; return {response: this.getDocumentHighlights(line, offset, fileName, filesToSearch), responseRequired: true}; }, [CommandNames.ProjectInfo]: (request: protocol.Request) => { - var { file, needFileNameList } = request.arguments; + const { file, needFileNameList } = request.arguments; return {response: this.getProjectInfo(file, needFileNameList), responseRequired: true}; }, [CommandNames.ReloadProjects]: (request: protocol.ReloadProjectsRequest) => { @@ -1065,11 +1067,12 @@ namespace ts.server { this.handlers[command] = handler; } - public executeCommand(request: protocol.Request) : {response?: any, responseRequired?: boolean} { - var handler = this.handlers[request.command]; + public executeCommand(request: protocol.Request): {response?: any, responseRequired?: boolean} { + const handler = this.handlers[request.command]; if (handler) { return handler(request); - } else { + } + else { this.projectService.log("Unrecognized JSON command: " + JSON.stringify(request)); this.output(undefined, CommandNames.Unknown, request.seq, "Unrecognized JSON command: " + request.command); return {responseRequired: false}; @@ -1077,20 +1080,22 @@ namespace ts.server { } public onMessage(message: string) { + let start: number[]; if (this.logger.isVerbose()) { this.logger.info("request: " + message); - var start = this.hrtime(); + start = this.hrtime(); } + let request: protocol.Request; try { - var request = JSON.parse(message); - var {response, responseRequired} = this.executeCommand(request); + request = JSON.parse(message); + const {response, responseRequired} = this.executeCommand(request); 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)"; + const elapsed = this.hrtime(start); + const seconds = elapsed[0]; + const nanoseconds = elapsed[1]; + const elapsedMs = ((1e9 * seconds) + nanoseconds) / 1000000.0; + let leader = "Elapsed time (in milliseconds)"; if (!responseRequired) { leader = "Async elapsed time (in milliseconds)"; } @@ -1102,7 +1107,8 @@ namespace ts.server { else if (responseRequired) { this.output(undefined, request.command, request.seq, "No content available."); } - } catch (err) { + } + catch (err) { if (err instanceof OperationCanceledException) { // Handle cancellation exceptions } From 9c0982051d02453789a490afb02498c495e56add Mon Sep 17 00:00:00 2001 From: Vladimir Matveev Date: Wed, 28 Oct 2015 16:02:16 -0700 Subject: [PATCH 106/227] lint node.d.ts --- Jakefile.js | 6 +++--- src/server/node.d.ts | 32 ++++++++++++++++---------------- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/Jakefile.js b/Jakefile.js index fd682d075ae..122aab01208 100644 --- a/Jakefile.js +++ b/Jakefile.js @@ -96,7 +96,7 @@ var servicesSources = [ return path.join(servicesDirectory, f); })); -var serverOnlySources = [ +var serverCoreSources = [ "node.d.ts", "editorServices.ts", "protocol.d.ts", @@ -106,7 +106,7 @@ var serverOnlySources = [ return path.join(serverDirectory, f); }); -var serverSources = serverOnlySources.concat(servicesSources); +var serverSources = serverCoreSources.concat(servicesSources); var languageServiceLibrarySources = [ "editorServices.ts", @@ -902,7 +902,7 @@ function lintFileAsync(options, path, cb) { var lintTargets = compilerSources .concat(harnessCoreSources) - .concat(serverOnlySources.filter(function(p) { return path.basename(p) !== "node.d.ts"; })); + .concat(serverCoreSources); desc("Runs tslint on the compiler sources"); task("lint", ["build-rules"], function() { diff --git a/src/server/node.d.ts b/src/server/node.d.ts index 438b152a1f4..0bde0bb6602 100644 --- a/src/server/node.d.ts +++ b/src/server/node.d.ts @@ -62,14 +62,14 @@ declare var SlowBuffer: { // Buffer class interface Buffer extends NodeBuffer { } interface BufferConstructor { - new (str: string, encoding ?: string): Buffer; + new (str: string, encoding?: string): Buffer; new (size: number): Buffer; new (size: Uint8Array): Buffer; new (array: any[]): Buffer; prototype: Buffer; isBuffer(obj: any): boolean; - byteLength(string: string, encoding ?: string): number; - concat(list: Buffer[], totalLength ?: number): Buffer; + byteLength(string: string, encoding?: string): number; + concat(list: Buffer[], totalLength?: number): Buffer; } declare var Buffer: BufferConstructor; @@ -78,7 +78,7 @@ declare var Buffer: BufferConstructor; * GLOBAL INTERFACES * * * ************************************************/ -declare module NodeJS { +declare namespace NodeJS { export interface ErrnoException extends Error { errno?: any; code?: string; @@ -245,7 +245,7 @@ interface NodeBuffer { fill(value: any, offset?: number, end?: number): void; } -declare module NodeJS { +declare namespace NodeJS { export interface Path { normalize(p: string): string; join(...paths: any[]): string; @@ -258,7 +258,7 @@ declare module NodeJS { } } -declare module NodeJS { +declare namespace NodeJS { export interface ReadLineInstance extends EventEmitter { setPrompt(prompt: string, length: number): void; prompt(preserveCursor?: boolean): void; @@ -280,8 +280,8 @@ declare module NodeJS { } } -declare module NodeJS { - module events { +declare namespace NodeJS { + namespace events { export class EventEmitter implements NodeJS.EventEmitter { static listenerCount(emitter: EventEmitter, event: string): number; @@ -297,8 +297,8 @@ declare module NodeJS { } } -declare module NodeJS { - module stream { +declare namespace NodeJS { + namespace stream { export interface Stream extends events.EventEmitter { pipe(destination: T, options?: { end?: boolean; }): T; @@ -397,8 +397,8 @@ declare module NodeJS { } } -declare module NodeJS { - module fs { +declare namespace NodeJS { + namespace fs { interface Stats { isFile(): boolean; isDirectory(): boolean; @@ -547,8 +547,8 @@ declare module NodeJS { } } -declare module NodeJS { - module path { +declare namespace NodeJS { + namespace path { export function normalize(p: string): string; export function join(...paths: any[]): string; export function resolve(...pathSegments: any[]): string; @@ -560,8 +560,8 @@ declare module NodeJS { } } -declare module NodeJS { - module _debugger { +declare namespace NodeJS { + namespace _debugger { export interface Packet { raw: string; headers: string[]; From febda00f1b430761df7e0e90bbb99cf8c99e4653 Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Wed, 28 Oct 2015 16:06:40 -0700 Subject: [PATCH 107/227] Improve type narrowing algorithm with typeof --- src/compiler/checker.ts | 35 +++---- tests/baselines/reference/symbolType18.types | 2 +- tests/baselines/reference/typeGuardNesting.js | 11 +++ .../reference/typeGuardNesting.symbols | 14 +++ .../reference/typeGuardNesting.types | 30 ++++++ .../typeGuardOfFormTypeOfOther.types | 12 +-- .../reference/typeGuardRedundancy.js | 17 ++++ .../reference/typeGuardRedundancy.symbols | 48 ++++++++++ .../reference/typeGuardRedundancy.types | 84 ++++++++++++++++ .../reference/typeGuardsWithAny.errors.txt | 49 ---------- .../reference/typeGuardsWithAny.symbols | 61 ++++++++++++ .../reference/typeGuardsWithAny.types | 96 +++++++++++++++++++ 12 files changed, 382 insertions(+), 77 deletions(-) create mode 100644 tests/baselines/reference/typeGuardNesting.js create mode 100644 tests/baselines/reference/typeGuardNesting.symbols create mode 100644 tests/baselines/reference/typeGuardNesting.types create mode 100644 tests/baselines/reference/typeGuardRedundancy.js create mode 100644 tests/baselines/reference/typeGuardRedundancy.symbols create mode 100644 tests/baselines/reference/typeGuardRedundancy.types delete mode 100644 tests/baselines/reference/typeGuardsWithAny.errors.txt create mode 100644 tests/baselines/reference/typeGuardsWithAny.symbols create mode 100644 tests/baselines/reference/typeGuardsWithAny.types diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 033614d2b41..ad6e72d68bd 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -6338,6 +6338,10 @@ namespace ts { // Stop at the first containing function or module declaration break loop; } + // Preserve old top-level behavior - if the branch is really an empty set, revert to prior type + if (narrowedType === getUnionType(emptyArray)) { + narrowedType = type; + } // Use narrowed type if construct contains no assignments to variable if (narrowedType !== type) { if (isVariableAssignedWithin(symbol, node)) { @@ -6352,6 +6356,9 @@ namespace ts { return type; function narrowTypeByEquality(type: Type, expr: BinaryExpression, assumeTrue: boolean): Type { + if (!(type.flags & TypeFlags.Union)) { + return type; + } // Check that we have 'typeof ' on the left and string literal on the right if (expr.left.kind !== SyntaxKind.TypeOfExpression || expr.right.kind !== SyntaxKind.StringLiteral) { return type; @@ -6361,31 +6368,17 @@ namespace ts { if (left.expression.kind !== SyntaxKind.Identifier || getResolvedSymbol(left.expression) !== symbol) { return type; } - let typeInfo = primitiveTypeInfo[right.text]; if (expr.operatorToken.kind === SyntaxKind.ExclamationEqualsEqualsToken) { assumeTrue = !assumeTrue; } + let typeInfo = primitiveTypeInfo[right.text]; + let flags = typeInfo ? typeInfo.flags : (assumeTrue = !assumeTrue, TypeFlags.NumberLike | TypeFlags.StringLike | TypeFlags.ESSymbol | TypeFlags.Boolean); + let union = type as UnionType; if (assumeTrue) { - // Assumed result is true. If check was not for a primitive type, remove all primitive types - if (!typeInfo) { - return removeTypesFromUnionType(type, /*typeKind*/ TypeFlags.StringLike | TypeFlags.NumberLike | TypeFlags.Boolean | TypeFlags.ESSymbol, - /*isOfTypeKind*/ true, /*allowEmptyUnionResult*/ true); - } - // Check was for a primitive type, return that primitive type if it is a subtype - if (isTypeSubtypeOf(typeInfo.type, type)) { - return typeInfo.type; - } - // Otherwise, remove all types that aren't of the primitive type kind. This can happen when the type is - // union of enum types and other types. - return removeTypesFromUnionType(type, /*typeKind*/ typeInfo.flags, /*isOfTypeKind*/ false, /*allowEmptyUnionResult*/ true); + return getUnionType(filter(union.types, t => !!(t.flags & flags))); } else { - // Assumed result is false. If check was for a primitive type, remove that primitive type - if (typeInfo) { - return removeTypesFromUnionType(type, /*typeKind*/ typeInfo.flags, /*isOfTypeKind*/ true, /*allowEmptyUnionResult*/ true); - } - // Otherwise we don't have enough information to do anything. - return type; + return getUnionType(filter(union.types, t => !(t.flags & flags))); } } @@ -6399,7 +6392,7 @@ namespace ts { // and the second operand was false. We narrow with those assumptions and union the two resulting types. return getUnionType([ narrowType(type, expr.left, /*assumeTrue*/ false), - narrowType(narrowType(type, expr.left, /*assumeTrue*/ true), expr.right, /*assumeTrue*/ false) + narrowType(type, expr.right, /*assumeTrue*/ false) ]); } } @@ -6410,7 +6403,7 @@ namespace ts { // and the second operand was true. We narrow with those assumptions and union the two resulting types. return getUnionType([ narrowType(type, expr.left, /*assumeTrue*/ true), - narrowType(narrowType(type, expr.left, /*assumeTrue*/ false), expr.right, /*assumeTrue*/ true) + narrowType(type, expr.right, /*assumeTrue*/ true) ]); } else { diff --git a/tests/baselines/reference/symbolType18.types b/tests/baselines/reference/symbolType18.types index db4fb30378f..68c43215136 100644 --- a/tests/baselines/reference/symbolType18.types +++ b/tests/baselines/reference/symbolType18.types @@ -21,5 +21,5 @@ if (typeof x === "object") { } else { x; ->x : symbol | Foo +>x : symbol } diff --git a/tests/baselines/reference/typeGuardNesting.js b/tests/baselines/reference/typeGuardNesting.js new file mode 100644 index 00000000000..4c9a64c2851 --- /dev/null +++ b/tests/baselines/reference/typeGuardNesting.js @@ -0,0 +1,11 @@ +//// [typeGuardNesting.ts] +let strOrBool: string|boolean; +if ((typeof strOrBool === 'boolean' && !strOrBool) || typeof strOrBool === 'string') { + var label: string = (typeof strOrBool === 'string') ? strOrBool : "other string"; +} + +//// [typeGuardNesting.js] +var strOrBool; +if ((typeof strOrBool === 'boolean' && !strOrBool) || typeof strOrBool === 'string') { + var label = (typeof strOrBool === 'string') ? strOrBool : "other string"; +} diff --git a/tests/baselines/reference/typeGuardNesting.symbols b/tests/baselines/reference/typeGuardNesting.symbols new file mode 100644 index 00000000000..f0cfb1f1eed --- /dev/null +++ b/tests/baselines/reference/typeGuardNesting.symbols @@ -0,0 +1,14 @@ +=== tests/cases/conformance/expressions/typeGuards/typeGuardNesting.ts === +let strOrBool: string|boolean; +>strOrBool : Symbol(strOrBool, Decl(typeGuardNesting.ts, 0, 3)) + +if ((typeof strOrBool === 'boolean' && !strOrBool) || typeof strOrBool === 'string') { +>strOrBool : Symbol(strOrBool, Decl(typeGuardNesting.ts, 0, 3)) +>strOrBool : Symbol(strOrBool, Decl(typeGuardNesting.ts, 0, 3)) +>strOrBool : Symbol(strOrBool, Decl(typeGuardNesting.ts, 0, 3)) + + var label: string = (typeof strOrBool === 'string') ? strOrBool : "other string"; +>label : Symbol(label, Decl(typeGuardNesting.ts, 2, 4)) +>strOrBool : Symbol(strOrBool, Decl(typeGuardNesting.ts, 0, 3)) +>strOrBool : Symbol(strOrBool, Decl(typeGuardNesting.ts, 0, 3)) +} diff --git a/tests/baselines/reference/typeGuardNesting.types b/tests/baselines/reference/typeGuardNesting.types new file mode 100644 index 00000000000..9f79974635d --- /dev/null +++ b/tests/baselines/reference/typeGuardNesting.types @@ -0,0 +1,30 @@ +=== tests/cases/conformance/expressions/typeGuards/typeGuardNesting.ts === +let strOrBool: string|boolean; +>strOrBool : string | boolean + +if ((typeof strOrBool === 'boolean' && !strOrBool) || typeof strOrBool === 'string') { +>(typeof strOrBool === 'boolean' && !strOrBool) || typeof strOrBool === 'string' : boolean +>(typeof strOrBool === 'boolean' && !strOrBool) : boolean +>typeof strOrBool === 'boolean' && !strOrBool : boolean +>typeof strOrBool === 'boolean' : boolean +>typeof strOrBool : string +>strOrBool : string | boolean +>'boolean' : string +>!strOrBool : boolean +>strOrBool : boolean +>typeof strOrBool === 'string' : boolean +>typeof strOrBool : string +>strOrBool : string | boolean +>'string' : string + + var label: string = (typeof strOrBool === 'string') ? strOrBool : "other string"; +>label : string +>(typeof strOrBool === 'string') ? strOrBool : "other string" : string +>(typeof strOrBool === 'string') : boolean +>typeof strOrBool === 'string' : boolean +>typeof strOrBool : string +>strOrBool : boolean | string +>'string' : string +>strOrBool : string +>"other string" : string +} diff --git a/tests/baselines/reference/typeGuardOfFormTypeOfOther.types b/tests/baselines/reference/typeGuardOfFormTypeOfOther.types index e0fd443ef63..8150c3ec25d 100644 --- a/tests/baselines/reference/typeGuardOfFormTypeOfOther.types +++ b/tests/baselines/reference/typeGuardOfFormTypeOfOther.types @@ -63,7 +63,7 @@ else { var r2: string | C = strOrC; // string | C >r2 : string | C >C : C ->strOrC : string | C +>strOrC : string } if (typeof numOrC === "Object") { >typeof numOrC === "Object" : boolean @@ -80,7 +80,7 @@ else { var r3: number | C = numOrC; // number | C >r3 : number | C >C : C ->numOrC : number | C +>numOrC : number } if (typeof boolOrC === "Object") { >typeof boolOrC === "Object" : boolean @@ -97,7 +97,7 @@ else { var r4: boolean | C = boolOrC; // boolean | C >r4 : boolean | C >C : C ->boolOrC : boolean | C +>boolOrC : boolean } // Narrowing occurs only if target type is a subtype of variable type @@ -129,7 +129,7 @@ if (typeof strOrC !== "Object") { var r2: string | C = strOrC; // string | C >r2 : string | C >C : C ->strOrC : string | C +>strOrC : string } else { c = strOrC; // C @@ -146,7 +146,7 @@ if (typeof numOrC !== "Object") { var r3: number | C = numOrC; // number | C >r3 : number | C >C : C ->numOrC : number | C +>numOrC : number } else { c = numOrC; // C @@ -163,7 +163,7 @@ if (typeof boolOrC !== "Object") { var r4: boolean | C = boolOrC; // boolean | C >r4 : boolean | C >C : C ->boolOrC : boolean | C +>boolOrC : boolean } else { c = boolOrC; // C diff --git a/tests/baselines/reference/typeGuardRedundancy.js b/tests/baselines/reference/typeGuardRedundancy.js new file mode 100644 index 00000000000..1dfa964cbc9 --- /dev/null +++ b/tests/baselines/reference/typeGuardRedundancy.js @@ -0,0 +1,17 @@ +//// [typeGuardRedundancy.ts] +var x: string|number; + +var r1 = typeof x === "string" && typeof x === "string" ? x.substr : x.toFixed; + +var r2 = !(typeof x === "string" && typeof x === "string") ? x.toFixed : x.substr; + +var r3 = typeof x === "string" || typeof x === "string" ? x.substr : x.toFixed; + +var r4 = !(typeof x === "string" || typeof x === "string") ? x.toFixed : x.substr; + +//// [typeGuardRedundancy.js] +var x; +var r1 = typeof x === "string" && typeof x === "string" ? x.substr : x.toFixed; +var r2 = !(typeof x === "string" && typeof x === "string") ? x.toFixed : x.substr; +var r3 = typeof x === "string" || typeof x === "string" ? x.substr : x.toFixed; +var r4 = !(typeof x === "string" || typeof x === "string") ? x.toFixed : x.substr; diff --git a/tests/baselines/reference/typeGuardRedundancy.symbols b/tests/baselines/reference/typeGuardRedundancy.symbols new file mode 100644 index 00000000000..356061407ad --- /dev/null +++ b/tests/baselines/reference/typeGuardRedundancy.symbols @@ -0,0 +1,48 @@ +=== tests/cases/conformance/expressions/typeGuards/typeGuardRedundancy.ts === +var x: string|number; +>x : Symbol(x, Decl(typeGuardRedundancy.ts, 0, 3)) + +var r1 = typeof x === "string" && typeof x === "string" ? x.substr : x.toFixed; +>r1 : Symbol(r1, Decl(typeGuardRedundancy.ts, 2, 3)) +>x : Symbol(x, Decl(typeGuardRedundancy.ts, 0, 3)) +>x : Symbol(x, Decl(typeGuardRedundancy.ts, 0, 3)) +>x.substr : Symbol(String.substr, Decl(lib.d.ts, --, --)) +>x : Symbol(x, Decl(typeGuardRedundancy.ts, 0, 3)) +>substr : Symbol(String.substr, Decl(lib.d.ts, --, --)) +>x.toFixed : Symbol(Number.toFixed, Decl(lib.d.ts, --, --)) +>x : Symbol(x, Decl(typeGuardRedundancy.ts, 0, 3)) +>toFixed : Symbol(Number.toFixed, Decl(lib.d.ts, --, --)) + +var r2 = !(typeof x === "string" && typeof x === "string") ? x.toFixed : x.substr; +>r2 : Symbol(r2, Decl(typeGuardRedundancy.ts, 4, 3)) +>x : Symbol(x, Decl(typeGuardRedundancy.ts, 0, 3)) +>x : Symbol(x, Decl(typeGuardRedundancy.ts, 0, 3)) +>x.toFixed : Symbol(Number.toFixed, Decl(lib.d.ts, --, --)) +>x : Symbol(x, Decl(typeGuardRedundancy.ts, 0, 3)) +>toFixed : Symbol(Number.toFixed, Decl(lib.d.ts, --, --)) +>x.substr : Symbol(String.substr, Decl(lib.d.ts, --, --)) +>x : Symbol(x, Decl(typeGuardRedundancy.ts, 0, 3)) +>substr : Symbol(String.substr, Decl(lib.d.ts, --, --)) + +var r3 = typeof x === "string" || typeof x === "string" ? x.substr : x.toFixed; +>r3 : Symbol(r3, Decl(typeGuardRedundancy.ts, 6, 3)) +>x : Symbol(x, Decl(typeGuardRedundancy.ts, 0, 3)) +>x : Symbol(x, Decl(typeGuardRedundancy.ts, 0, 3)) +>x.substr : Symbol(String.substr, Decl(lib.d.ts, --, --)) +>x : Symbol(x, Decl(typeGuardRedundancy.ts, 0, 3)) +>substr : Symbol(String.substr, Decl(lib.d.ts, --, --)) +>x.toFixed : Symbol(Number.toFixed, Decl(lib.d.ts, --, --)) +>x : Symbol(x, Decl(typeGuardRedundancy.ts, 0, 3)) +>toFixed : Symbol(Number.toFixed, Decl(lib.d.ts, --, --)) + +var r4 = !(typeof x === "string" || typeof x === "string") ? x.toFixed : x.substr; +>r4 : Symbol(r4, Decl(typeGuardRedundancy.ts, 8, 3)) +>x : Symbol(x, Decl(typeGuardRedundancy.ts, 0, 3)) +>x : Symbol(x, Decl(typeGuardRedundancy.ts, 0, 3)) +>x.toFixed : Symbol(Number.toFixed, Decl(lib.d.ts, --, --)) +>x : Symbol(x, Decl(typeGuardRedundancy.ts, 0, 3)) +>toFixed : Symbol(Number.toFixed, Decl(lib.d.ts, --, --)) +>x.substr : Symbol(String.substr, Decl(lib.d.ts, --, --)) +>x : Symbol(x, Decl(typeGuardRedundancy.ts, 0, 3)) +>substr : Symbol(String.substr, Decl(lib.d.ts, --, --)) + diff --git a/tests/baselines/reference/typeGuardRedundancy.types b/tests/baselines/reference/typeGuardRedundancy.types new file mode 100644 index 00000000000..1507ceb850e --- /dev/null +++ b/tests/baselines/reference/typeGuardRedundancy.types @@ -0,0 +1,84 @@ +=== tests/cases/conformance/expressions/typeGuards/typeGuardRedundancy.ts === +var x: string|number; +>x : string | number + +var r1 = typeof x === "string" && typeof x === "string" ? x.substr : x.toFixed; +>r1 : (from: number, length?: number) => string +>typeof x === "string" && typeof x === "string" ? x.substr : x.toFixed : (from: number, length?: number) => string +>typeof x === "string" && typeof x === "string" : boolean +>typeof x === "string" : boolean +>typeof x : string +>x : string | number +>"string" : string +>typeof x === "string" : boolean +>typeof x : string +>x : string +>"string" : string +>x.substr : (from: number, length?: number) => string +>x : string +>substr : (from: number, length?: number) => string +>x.toFixed : (fractionDigits?: number) => string +>x : number +>toFixed : (fractionDigits?: number) => string + +var r2 = !(typeof x === "string" && typeof x === "string") ? x.toFixed : x.substr; +>r2 : (fractionDigits?: number) => string +>!(typeof x === "string" && typeof x === "string") ? x.toFixed : x.substr : (fractionDigits?: number) => string +>!(typeof x === "string" && typeof x === "string") : boolean +>(typeof x === "string" && typeof x === "string") : boolean +>typeof x === "string" && typeof x === "string" : boolean +>typeof x === "string" : boolean +>typeof x : string +>x : string | number +>"string" : string +>typeof x === "string" : boolean +>typeof x : string +>x : string +>"string" : string +>x.toFixed : (fractionDigits?: number) => string +>x : number +>toFixed : (fractionDigits?: number) => string +>x.substr : (from: number, length?: number) => string +>x : string +>substr : (from: number, length?: number) => string + +var r3 = typeof x === "string" || typeof x === "string" ? x.substr : x.toFixed; +>r3 : (from: number, length?: number) => string +>typeof x === "string" || typeof x === "string" ? x.substr : x.toFixed : (from: number, length?: number) => string +>typeof x === "string" || typeof x === "string" : boolean +>typeof x === "string" : boolean +>typeof x : string +>x : string | number +>"string" : string +>typeof x === "string" : boolean +>typeof x : string +>x : number +>"string" : string +>x.substr : (from: number, length?: number) => string +>x : string +>substr : (from: number, length?: number) => string +>x.toFixed : (fractionDigits?: number) => string +>x : number +>toFixed : (fractionDigits?: number) => string + +var r4 = !(typeof x === "string" || typeof x === "string") ? x.toFixed : x.substr; +>r4 : (fractionDigits?: number) => string +>!(typeof x === "string" || typeof x === "string") ? x.toFixed : x.substr : (fractionDigits?: number) => string +>!(typeof x === "string" || typeof x === "string") : boolean +>(typeof x === "string" || typeof x === "string") : boolean +>typeof x === "string" || typeof x === "string" : boolean +>typeof x === "string" : boolean +>typeof x : string +>x : string | number +>"string" : string +>typeof x === "string" : boolean +>typeof x : string +>x : number +>"string" : string +>x.toFixed : (fractionDigits?: number) => string +>x : number +>toFixed : (fractionDigits?: number) => string +>x.substr : (from: number, length?: number) => string +>x : string +>substr : (from: number, length?: number) => string + diff --git a/tests/baselines/reference/typeGuardsWithAny.errors.txt b/tests/baselines/reference/typeGuardsWithAny.errors.txt deleted file mode 100644 index 653c89c7554..00000000000 --- a/tests/baselines/reference/typeGuardsWithAny.errors.txt +++ /dev/null @@ -1,49 +0,0 @@ -tests/cases/conformance/expressions/typeGuards/typeGuardsWithAny.ts(11,7): error TS2339: Property 'p' does not exist on type 'string'. -tests/cases/conformance/expressions/typeGuards/typeGuardsWithAny.ts(18,7): error TS2339: Property 'p' does not exist on type 'number'. -tests/cases/conformance/expressions/typeGuards/typeGuardsWithAny.ts(25,7): error TS2339: Property 'p' does not exist on type 'boolean'. - - -==== tests/cases/conformance/expressions/typeGuards/typeGuardsWithAny.ts (3 errors) ==== - var x: any = { p: 0 }; - - if (x instanceof Object) { - x.p; // No error, type any unaffected by instanceof type guard - } - else { - x.p; // No error, type any unaffected by instanceof type guard - } - - if (typeof x === "string") { - x.p; // Error, type any narrowed by primitive type check - ~ -!!! error TS2339: Property 'p' does not exist on type 'string'. - } - else { - x.p; // No error, type unaffected in this branch - } - - if (typeof x === "number") { - x.p; // Error, type any narrowed by primitive type check - ~ -!!! error TS2339: Property 'p' does not exist on type 'number'. - } - else { - x.p; // No error, type unaffected in this branch - } - - if (typeof x === "boolean") { - x.p; // Error, type any narrowed by primitive type check - ~ -!!! error TS2339: Property 'p' does not exist on type 'boolean'. - } - else { - x.p; // No error, type unaffected in this branch - } - - if (typeof x === "object") { - x.p; // No error, type any only affected by primitive type check - } - else { - x.p; // No error, type unaffected in this branch - } - \ No newline at end of file diff --git a/tests/baselines/reference/typeGuardsWithAny.symbols b/tests/baselines/reference/typeGuardsWithAny.symbols new file mode 100644 index 00000000000..90405d762a1 --- /dev/null +++ b/tests/baselines/reference/typeGuardsWithAny.symbols @@ -0,0 +1,61 @@ +=== tests/cases/conformance/expressions/typeGuards/typeGuardsWithAny.ts === +var x: any = { p: 0 }; +>x : Symbol(x, Decl(typeGuardsWithAny.ts, 0, 3)) +>p : Symbol(p, Decl(typeGuardsWithAny.ts, 0, 14)) + +if (x instanceof Object) { +>x : Symbol(x, Decl(typeGuardsWithAny.ts, 0, 3)) +>Object : Symbol(Object, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) + + x.p; // No error, type any unaffected by instanceof type guard +>x : Symbol(x, Decl(typeGuardsWithAny.ts, 0, 3)) +} +else { + x.p; // No error, type any unaffected by instanceof type guard +>x : Symbol(x, Decl(typeGuardsWithAny.ts, 0, 3)) +} + +if (typeof x === "string") { +>x : Symbol(x, Decl(typeGuardsWithAny.ts, 0, 3)) + + x.p; // Error, type any narrowed by primitive type check +>x : Symbol(x, Decl(typeGuardsWithAny.ts, 0, 3)) +} +else { + x.p; // No error, type unaffected in this branch +>x : Symbol(x, Decl(typeGuardsWithAny.ts, 0, 3)) +} + +if (typeof x === "number") { +>x : Symbol(x, Decl(typeGuardsWithAny.ts, 0, 3)) + + x.p; // Error, type any narrowed by primitive type check +>x : Symbol(x, Decl(typeGuardsWithAny.ts, 0, 3)) +} +else { + x.p; // No error, type unaffected in this branch +>x : Symbol(x, Decl(typeGuardsWithAny.ts, 0, 3)) +} + +if (typeof x === "boolean") { +>x : Symbol(x, Decl(typeGuardsWithAny.ts, 0, 3)) + + x.p; // Error, type any narrowed by primitive type check +>x : Symbol(x, Decl(typeGuardsWithAny.ts, 0, 3)) +} +else { + x.p; // No error, type unaffected in this branch +>x : Symbol(x, Decl(typeGuardsWithAny.ts, 0, 3)) +} + +if (typeof x === "object") { +>x : Symbol(x, Decl(typeGuardsWithAny.ts, 0, 3)) + + x.p; // No error, type any only affected by primitive type check +>x : Symbol(x, Decl(typeGuardsWithAny.ts, 0, 3)) +} +else { + x.p; // No error, type unaffected in this branch +>x : Symbol(x, Decl(typeGuardsWithAny.ts, 0, 3)) +} + diff --git a/tests/baselines/reference/typeGuardsWithAny.types b/tests/baselines/reference/typeGuardsWithAny.types new file mode 100644 index 00000000000..12a4326e99d --- /dev/null +++ b/tests/baselines/reference/typeGuardsWithAny.types @@ -0,0 +1,96 @@ +=== tests/cases/conformance/expressions/typeGuards/typeGuardsWithAny.ts === +var x: any = { p: 0 }; +>x : any +>{ p: 0 } : { p: number; } +>p : number +>0 : number + +if (x instanceof Object) { +>x instanceof Object : boolean +>x : any +>Object : ObjectConstructor + + x.p; // No error, type any unaffected by instanceof type guard +>x.p : any +>x : any +>p : any +} +else { + x.p; // No error, type any unaffected by instanceof type guard +>x.p : any +>x : any +>p : any +} + +if (typeof x === "string") { +>typeof x === "string" : boolean +>typeof x : string +>x : any +>"string" : string + + x.p; // Error, type any narrowed by primitive type check +>x.p : any +>x : any +>p : any +} +else { + x.p; // No error, type unaffected in this branch +>x.p : any +>x : any +>p : any +} + +if (typeof x === "number") { +>typeof x === "number" : boolean +>typeof x : string +>x : any +>"number" : string + + x.p; // Error, type any narrowed by primitive type check +>x.p : any +>x : any +>p : any +} +else { + x.p; // No error, type unaffected in this branch +>x.p : any +>x : any +>p : any +} + +if (typeof x === "boolean") { +>typeof x === "boolean" : boolean +>typeof x : string +>x : any +>"boolean" : string + + x.p; // Error, type any narrowed by primitive type check +>x.p : any +>x : any +>p : any +} +else { + x.p; // No error, type unaffected in this branch +>x.p : any +>x : any +>p : any +} + +if (typeof x === "object") { +>typeof x === "object" : boolean +>typeof x : string +>x : any +>"object" : string + + x.p; // No error, type any only affected by primitive type check +>x.p : any +>x : any +>p : any +} +else { + x.p; // No error, type unaffected in this branch +>x.p : any +>x : any +>p : any +} + From 168c664639a6c7d01439f39b1d3bd3edd58bada3 Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Wed, 28 Oct 2015 16:29:36 -0700 Subject: [PATCH 108/227] restore any narrowing --- src/compiler/checker.ts | 11 ++- .../reference/typeGuardsWithAny.errors.txt | 49 ++++++++++ .../reference/typeGuardsWithAny.symbols | 61 ------------ .../reference/typeGuardsWithAny.types | 96 ------------------- 4 files changed, 57 insertions(+), 160 deletions(-) create mode 100644 tests/baselines/reference/typeGuardsWithAny.errors.txt delete mode 100644 tests/baselines/reference/typeGuardsWithAny.symbols delete mode 100644 tests/baselines/reference/typeGuardsWithAny.types diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index ad6e72d68bd..93b644b07a4 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -6356,9 +6356,6 @@ namespace ts { return type; function narrowTypeByEquality(type: Type, expr: BinaryExpression, assumeTrue: boolean): Type { - if (!(type.flags & TypeFlags.Union)) { - return type; - } // Check that we have 'typeof ' on the left and string literal on the right if (expr.left.kind !== SyntaxKind.TypeOfExpression || expr.right.kind !== SyntaxKind.StringLiteral) { return type; @@ -6372,6 +6369,14 @@ namespace ts { assumeTrue = !assumeTrue; } let typeInfo = primitiveTypeInfo[right.text]; + // If the type to be narrowed is any and we're affirmatively checking against a primitive, return the primitive + if (!!(type.flags & TypeFlags.Any) && typeInfo && assumeTrue) { + return typeInfo.type; + } + // At this point we can bail if it's not a union + if (!(type.flags & TypeFlags.Union)) { + return type; + } let flags = typeInfo ? typeInfo.flags : (assumeTrue = !assumeTrue, TypeFlags.NumberLike | TypeFlags.StringLike | TypeFlags.ESSymbol | TypeFlags.Boolean); let union = type as UnionType; if (assumeTrue) { diff --git a/tests/baselines/reference/typeGuardsWithAny.errors.txt b/tests/baselines/reference/typeGuardsWithAny.errors.txt new file mode 100644 index 00000000000..653c89c7554 --- /dev/null +++ b/tests/baselines/reference/typeGuardsWithAny.errors.txt @@ -0,0 +1,49 @@ +tests/cases/conformance/expressions/typeGuards/typeGuardsWithAny.ts(11,7): error TS2339: Property 'p' does not exist on type 'string'. +tests/cases/conformance/expressions/typeGuards/typeGuardsWithAny.ts(18,7): error TS2339: Property 'p' does not exist on type 'number'. +tests/cases/conformance/expressions/typeGuards/typeGuardsWithAny.ts(25,7): error TS2339: Property 'p' does not exist on type 'boolean'. + + +==== tests/cases/conformance/expressions/typeGuards/typeGuardsWithAny.ts (3 errors) ==== + var x: any = { p: 0 }; + + if (x instanceof Object) { + x.p; // No error, type any unaffected by instanceof type guard + } + else { + x.p; // No error, type any unaffected by instanceof type guard + } + + if (typeof x === "string") { + x.p; // Error, type any narrowed by primitive type check + ~ +!!! error TS2339: Property 'p' does not exist on type 'string'. + } + else { + x.p; // No error, type unaffected in this branch + } + + if (typeof x === "number") { + x.p; // Error, type any narrowed by primitive type check + ~ +!!! error TS2339: Property 'p' does not exist on type 'number'. + } + else { + x.p; // No error, type unaffected in this branch + } + + if (typeof x === "boolean") { + x.p; // Error, type any narrowed by primitive type check + ~ +!!! error TS2339: Property 'p' does not exist on type 'boolean'. + } + else { + x.p; // No error, type unaffected in this branch + } + + if (typeof x === "object") { + x.p; // No error, type any only affected by primitive type check + } + else { + x.p; // No error, type unaffected in this branch + } + \ No newline at end of file diff --git a/tests/baselines/reference/typeGuardsWithAny.symbols b/tests/baselines/reference/typeGuardsWithAny.symbols deleted file mode 100644 index 90405d762a1..00000000000 --- a/tests/baselines/reference/typeGuardsWithAny.symbols +++ /dev/null @@ -1,61 +0,0 @@ -=== tests/cases/conformance/expressions/typeGuards/typeGuardsWithAny.ts === -var x: any = { p: 0 }; ->x : Symbol(x, Decl(typeGuardsWithAny.ts, 0, 3)) ->p : Symbol(p, Decl(typeGuardsWithAny.ts, 0, 14)) - -if (x instanceof Object) { ->x : Symbol(x, Decl(typeGuardsWithAny.ts, 0, 3)) ->Object : Symbol(Object, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) - - x.p; // No error, type any unaffected by instanceof type guard ->x : Symbol(x, Decl(typeGuardsWithAny.ts, 0, 3)) -} -else { - x.p; // No error, type any unaffected by instanceof type guard ->x : Symbol(x, Decl(typeGuardsWithAny.ts, 0, 3)) -} - -if (typeof x === "string") { ->x : Symbol(x, Decl(typeGuardsWithAny.ts, 0, 3)) - - x.p; // Error, type any narrowed by primitive type check ->x : Symbol(x, Decl(typeGuardsWithAny.ts, 0, 3)) -} -else { - x.p; // No error, type unaffected in this branch ->x : Symbol(x, Decl(typeGuardsWithAny.ts, 0, 3)) -} - -if (typeof x === "number") { ->x : Symbol(x, Decl(typeGuardsWithAny.ts, 0, 3)) - - x.p; // Error, type any narrowed by primitive type check ->x : Symbol(x, Decl(typeGuardsWithAny.ts, 0, 3)) -} -else { - x.p; // No error, type unaffected in this branch ->x : Symbol(x, Decl(typeGuardsWithAny.ts, 0, 3)) -} - -if (typeof x === "boolean") { ->x : Symbol(x, Decl(typeGuardsWithAny.ts, 0, 3)) - - x.p; // Error, type any narrowed by primitive type check ->x : Symbol(x, Decl(typeGuardsWithAny.ts, 0, 3)) -} -else { - x.p; // No error, type unaffected in this branch ->x : Symbol(x, Decl(typeGuardsWithAny.ts, 0, 3)) -} - -if (typeof x === "object") { ->x : Symbol(x, Decl(typeGuardsWithAny.ts, 0, 3)) - - x.p; // No error, type any only affected by primitive type check ->x : Symbol(x, Decl(typeGuardsWithAny.ts, 0, 3)) -} -else { - x.p; // No error, type unaffected in this branch ->x : Symbol(x, Decl(typeGuardsWithAny.ts, 0, 3)) -} - diff --git a/tests/baselines/reference/typeGuardsWithAny.types b/tests/baselines/reference/typeGuardsWithAny.types deleted file mode 100644 index 12a4326e99d..00000000000 --- a/tests/baselines/reference/typeGuardsWithAny.types +++ /dev/null @@ -1,96 +0,0 @@ -=== tests/cases/conformance/expressions/typeGuards/typeGuardsWithAny.ts === -var x: any = { p: 0 }; ->x : any ->{ p: 0 } : { p: number; } ->p : number ->0 : number - -if (x instanceof Object) { ->x instanceof Object : boolean ->x : any ->Object : ObjectConstructor - - x.p; // No error, type any unaffected by instanceof type guard ->x.p : any ->x : any ->p : any -} -else { - x.p; // No error, type any unaffected by instanceof type guard ->x.p : any ->x : any ->p : any -} - -if (typeof x === "string") { ->typeof x === "string" : boolean ->typeof x : string ->x : any ->"string" : string - - x.p; // Error, type any narrowed by primitive type check ->x.p : any ->x : any ->p : any -} -else { - x.p; // No error, type unaffected in this branch ->x.p : any ->x : any ->p : any -} - -if (typeof x === "number") { ->typeof x === "number" : boolean ->typeof x : string ->x : any ->"number" : string - - x.p; // Error, type any narrowed by primitive type check ->x.p : any ->x : any ->p : any -} -else { - x.p; // No error, type unaffected in this branch ->x.p : any ->x : any ->p : any -} - -if (typeof x === "boolean") { ->typeof x === "boolean" : boolean ->typeof x : string ->x : any ->"boolean" : string - - x.p; // Error, type any narrowed by primitive type check ->x.p : any ->x : any ->p : any -} -else { - x.p; // No error, type unaffected in this branch ->x.p : any ->x : any ->p : any -} - -if (typeof x === "object") { ->typeof x === "object" : boolean ->typeof x : string ->x : any ->"object" : string - - x.p; // No error, type any only affected by primitive type check ->x.p : any ->x : any ->p : any -} -else { - x.p; // No error, type unaffected in this branch ->x.p : any ->x : any ->p : any -} - From b60d88fa80bdd09029610584603734419ef89ae9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Arod?= Date: Thu, 29 Oct 2015 12:56:13 +0100 Subject: [PATCH 109/227] Allow comments in tsconfig.json issue #4987 --- Jakefile.js | 3 +- src/compiler/commandLineParser.ts | 94 +++++++++++++++++++++++- tests/cases/unittests/tsconfigParsing.ts | 84 +++++++++++++++++++++ 3 files changed, 179 insertions(+), 2 deletions(-) create mode 100644 tests/cases/unittests/tsconfigParsing.ts diff --git a/Jakefile.js b/Jakefile.js index a602a2c459f..db6b5f55671 100644 --- a/Jakefile.js +++ b/Jakefile.js @@ -145,7 +145,8 @@ var harnessSources = harnessCoreSources.concat([ "transpile.ts", "reuseProgramStructure.ts", "cachingInServerLSHost.ts", - "moduleResolution.ts" + "moduleResolution.ts", + "tsconfigParsing.ts" ].map(function (f) { return path.join(unittestsDirectory, f); })).concat([ diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index 84496fdbeb3..e5950db05b6 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -405,13 +405,105 @@ namespace ts { */ export function parseConfigFileTextToJson(fileName: string, jsonText: string): { config?: any; error?: Diagnostic } { try { - return { config: /\S/.test(jsonText) ? JSON.parse(jsonText) : {} }; + let jsonTextWithoutComments = removeComments(jsonText); + return { config: /\S/.test(jsonTextWithoutComments) ? JSON.parse(jsonTextWithoutComments) : {} }; } catch (e) { return { error: createCompilerDiagnostic(Diagnostics.Failed_to_parse_file_0_Colon_1, fileName, e.message) }; } } + + /** + * Remove the comments from a json like text. + * Comments can be single line comments (starting with # or //) or multiline comments using / * * / + * + * This method replace comment content by whitespace rather than completely remove them to keep positions in json parsing error reporting accurate. + */ + function removeComments(jsonText: string): string { + let result = ""; + let processingString = false; + let processingSingleLineComment = false; + let processingMultiLineComment = false; + for (let i = 0; i < jsonText.length; i++) { + let currentChar = jsonText.charAt(i); + let nextChar = (i + 1 < jsonText.length) ? jsonText.charAt(i + 1) : undefined; + if (processingString) { + if (currentChar === "\\" + && nextChar === "\"") { + // Escaped quote consume the 2 characters + result += currentChar; + result += nextChar; + i += 1; + } + else if (currentChar === "\"") { + // End of string + result += currentChar; + processingString = false; + } + else { + // String content + result += currentChar; + } + } + else if (processingSingleLineComment) { + if (currentChar === "\n") { + // End of single line comment + processingSingleLineComment = false; + // Keep the line breaks to keep line numbers aligned + result += currentChar; + } + else { + // replace comment content by whitespaces + result += " "; + } + } + else if (processingMultiLineComment) { + if (currentChar === "*" && nextChar === "/") { + // End of comment + result += " "; + i += 1; + processingMultiLineComment = false; + } + else if (currentChar === "\n") { + // Keep the line breaks to Keep line aligned + result += currentChar; + } + else { + // replace comment content by whitespaces + result += " "; + } + } + else if (currentChar === "\"") { + // String start + result += currentChar; + processingString = true; + } + else if (currentChar === "#") { + // Start of # comment + result += " "; + processingSingleLineComment = true; + } + else if (currentChar === "/" && nextChar === "/") { + // Start of // comment + result += " "; + i += 1; + processingSingleLineComment = true; + } + else if (currentChar === "/" && nextChar === "*") { + // Start of /**/ comment + result += " "; + i += 1; + processingMultiLineComment = true; + } + else { + // Keep other characters + result += currentChar; + } + } + return result; + } + /** * Parse the contents of a config file (tsconfig.json). * @param json The contents of the config file to parse diff --git a/tests/cases/unittests/tsconfigParsing.ts b/tests/cases/unittests/tsconfigParsing.ts new file mode 100644 index 00000000000..3da1acb83c3 --- /dev/null +++ b/tests/cases/unittests/tsconfigParsing.ts @@ -0,0 +1,84 @@ +/// +/// + +module ts { + describe('parseConfigFileTextToJson', () => { + function assertParseResult(jsonText: string, expectedConfigObject: { config?: any; error?: Diagnostic }) { + let parsed = ts.parseConfigFileTextToJson("/apath/tsconfig.json", jsonText); + assert.equal(JSON.stringify(parsed), JSON.stringify(expectedConfigObject)); + } + + function assertParseError(jsonText: string) { + let parsed = ts.parseConfigFileTextToJson("/apath/tsconfig.json", jsonText); + assert.isTrue(undefined === parsed.config); + assert.isTrue(undefined !== parsed.error); + } + + it("returns empty config for file with only whitespaces", () => { + assertParseResult("", { config : {} }); + assertParseResult(" ", { config : {} }); + }); + + it("returns empty config for file with comments only", () => { + assertParseResult("// Comment", { config: {} }); + assertParseResult("# Comment", { config: {} }); + assertParseResult("/* Comment*/", { config: {} }); + }); + + it("returns empty config when config is empty object", () => { + assertParseResult("{}", { config: {} }); + }); + + it("returns config object without comments", () => { + assertParseResult( + `{ // Excluded files + "exclude": [ + // Exclude d.ts + "file.d.ts" + ] + }`, { config: { exclude: ["file.d.ts"] } }); + assertParseResult( + `{ + # Excluded files + "exclude": [ + # Exclude d.ts + "file.d.ts" + ] + }`, { config: { exclude: ["file.d.ts"] } }); + assertParseResult( + `{ + /* Excluded + Files + */ + "exclude": [ + /* multiline comments can be in the middle of a line */"file.d.ts" + ] + }`, { config: { exclude: ["file.d.ts"] } }); + }); + + it("keeps string content untouched", () => { + assertParseResult( + `{ + "exclude": [ + "xx//file.d.ts" + ] + }`, { config: { exclude: ["xx//file.d.ts"] } }); + assertParseResult( + `{ + "exclude": [ + "xx#file.d.ts" + ] + }`, { config: { exclude: ["xx#file.d.ts"] } }); + assertParseResult( + `{ + "exclude": [ + "xx/*file.d.ts*/" + ] + }`, { config: { exclude: ["xx/*file.d.ts*/"] } }); + }); + + it("returns object with error when json is invalid", () => { + assertParseError("invalid"); + }); + }); +} From f5e73ab8bf2d460c4f302f4d3aa286f9e0177f04 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Arod?= Date: Thu, 29 Oct 2015 14:55:23 +0100 Subject: [PATCH 110/227] Fix handling of escaped characters in string --- src/compiler/commandLineParser.ts | 5 +++-- tests/cases/unittests/tsconfigParsing.ts | 16 ++++++++++++++++ 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index e5950db05b6..d69b91bd5b4 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -430,8 +430,9 @@ namespace ts { let nextChar = (i + 1 < jsonText.length) ? jsonText.charAt(i + 1) : undefined; if (processingString) { if (currentChar === "\\" - && nextChar === "\"") { - // Escaped quote consume the 2 characters + && nextChar !== undefined) { + // Found an escaped character + // consume the \ and the escaped char result += currentChar; result += nextChar; i += 1; diff --git a/tests/cases/unittests/tsconfigParsing.ts b/tests/cases/unittests/tsconfigParsing.ts index 3da1acb83c3..f48593b3169 100644 --- a/tests/cases/unittests/tsconfigParsing.ts +++ b/tests/cases/unittests/tsconfigParsing.ts @@ -77,6 +77,22 @@ module ts { }`, { config: { exclude: ["xx/*file.d.ts*/"] } }); }); + it("handles escaped characters in strings correctly", () => { + assertParseResult( + `{ + "exclude": [ + "xx\\"//files" + ] + }`, { config: { exclude: ["xx\"//files"] } }); + + assertParseResult( + `{ + "exclude": [ + "xx\\\\" // end of line comment + ] + }`, { config: { exclude: ["xx\\"] } }); + }); + it("returns object with error when json is invalid", () => { assertParseError("invalid"); }); From 67026f3461443155e1b8975c0f37510a972675bf Mon Sep 17 00:00:00 2001 From: Vladimir Matveev Date: Thu, 29 Oct 2015 13:09:46 -0700 Subject: [PATCH 111/227] use resolvedFileName as is when calling methods on host --- src/compiler/program.ts | 5 +---- src/compiler/tsc.ts | 34 +++++++++++++++++++--------------- src/compiler/utilities.ts | 6 ++++++ src/harness/projectsRunner.ts | 17 ++++++++++++----- 4 files changed, 38 insertions(+), 24 deletions(-) diff --git a/src/compiler/program.ts b/src/compiler/program.ts index b73afe67edc..e9f659792f9 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -869,10 +869,7 @@ namespace ts { ? resolution.resolvedFileName : getNormalizedAbsolutePath(resolution.resolvedFileName, currentDirectory); - // convert an absolute import path to path that is relative to current directory - // this was host still can locate it but files names in user output will be shorter (and thus look nicer). - const relativePath = getRelativePathToDirectoryOrUrl(currentDirectory, absoluteImportPath, currentDirectory, getCanonicalFileName, false); - const importedFile = findSourceFile(relativePath, absoluteImportPath, /* isDefaultLib */ false, file, skipTrivia(file.text, file.imports[i].pos), file.imports[i].end); + const importedFile = findSourceFile(resolution.resolvedFileName, absoluteImportPath, /* isDefaultLib */ false, file, skipTrivia(file.text, file.imports[i].pos), file.imports[i].end); if (importedFile && resolution.isExternalLibraryImport) { if (!isExternalModule(importedFile)) { diff --git a/src/compiler/tsc.ts b/src/compiler/tsc.ts index c493cf8f87f..fc6d65b45e9 100644 --- a/src/compiler/tsc.ts +++ b/src/compiler/tsc.ts @@ -81,12 +81,16 @@ namespace ts { return diagnostic.messageText; } - function reportDiagnostic(diagnostic: Diagnostic) { + function reportDiagnostic(diagnostic: Diagnostic, host: CompilerHost) { let output = ""; if (diagnostic.file) { let loc = getLineAndCharacterOfPosition(diagnostic.file, diagnostic.start); - output += `${ diagnostic.file.fileName }(${ loc.line + 1 },${ loc.character + 1 }): `; + const relativeFileName = host + ? toRelativePath(diagnostic.file.fileName, host.getCurrentDirectory(), fileName => host.getCanonicalFileName(fileName)) + : diagnostic.file.fileName; + + output += `${ relativeFileName }(${ loc.line + 1 },${ loc.character + 1 }): `; } let category = DiagnosticCategory[diagnostic.category].toLowerCase(); @@ -95,9 +99,9 @@ namespace ts { sys.write(output); } - function reportDiagnostics(diagnostics: Diagnostic[]) { + function reportDiagnostics(diagnostics: Diagnostic[], host: CompilerHost) { for (let i = 0; i < diagnostics.length; i++) { - reportDiagnostic(diagnostics[i]); + reportDiagnostic(diagnostics[i], host); } } @@ -166,7 +170,7 @@ namespace ts { if (commandLine.options.locale) { if (!isJSONSupported()) { - reportDiagnostic(createCompilerDiagnostic(Diagnostics.The_current_host_does_not_support_the_0_option, "--locale")); + reportDiagnostic(createCompilerDiagnostic(Diagnostics.The_current_host_does_not_support_the_0_option, "--locale"), /* compilerHost */ undefined); return sys.exit(ExitStatus.DiagnosticsPresent_OutputsSkipped); } validateLocaleAndSetLanguage(commandLine.options.locale, commandLine.errors); @@ -175,7 +179,7 @@ namespace ts { // If there are any errors due to command line parsing and/or // setting up localization, report them and quit. if (commandLine.errors.length > 0) { - reportDiagnostics(commandLine.errors); + reportDiagnostics(commandLine.errors, compilerHost); return sys.exit(ExitStatus.DiagnosticsPresent_OutputsSkipped); } @@ -185,7 +189,7 @@ namespace ts { } if (commandLine.options.version) { - reportDiagnostic(createCompilerDiagnostic(Diagnostics.Version_0, ts.version)); + reportDiagnostic(createCompilerDiagnostic(Diagnostics.Version_0, ts.version), /* compilerHost */ undefined); return sys.exit(ExitStatus.Success); } @@ -197,12 +201,12 @@ namespace ts { if (commandLine.options.project) { if (!isJSONSupported()) { - reportDiagnostic(createCompilerDiagnostic(Diagnostics.The_current_host_does_not_support_the_0_option, "--project")); + reportDiagnostic(createCompilerDiagnostic(Diagnostics.The_current_host_does_not_support_the_0_option, "--project"), /* compilerHost */ undefined); return sys.exit(ExitStatus.DiagnosticsPresent_OutputsSkipped); } configFileName = normalizePath(combinePaths(commandLine.options.project, "tsconfig.json")); if (commandLine.fileNames.length !== 0) { - reportDiagnostic(createCompilerDiagnostic(Diagnostics.Option_project_cannot_be_mixed_with_source_files_on_a_command_line)); + reportDiagnostic(createCompilerDiagnostic(Diagnostics.Option_project_cannot_be_mixed_with_source_files_on_a_command_line), /* compilerHost */ undefined); return sys.exit(ExitStatus.DiagnosticsPresent_OutputsSkipped); } } @@ -220,7 +224,7 @@ namespace ts { // Firefox has Object.prototype.watch if (commandLine.options.watch && commandLine.options.hasOwnProperty("watch")) { if (!sys.watchFile) { - reportDiagnostic(createCompilerDiagnostic(Diagnostics.The_current_host_does_not_support_the_0_option, "--watch")); + reportDiagnostic(createCompilerDiagnostic(Diagnostics.The_current_host_does_not_support_the_0_option, "--watch"), /* compilerHost */ undefined); return sys.exit(ExitStatus.DiagnosticsPresent_OutputsSkipped); } if (configFileName) { @@ -256,7 +260,7 @@ namespace ts { let configObject = result.config; let configParseResult = parseJsonConfigFileContent(configObject, sys, getDirectoryPath(configFileName)); if (configParseResult.errors.length > 0) { - reportDiagnostics(configParseResult.errors); + reportDiagnostics(configParseResult.errors, /* compilerHost */ undefined); sys.exit(ExitStatus.DiagnosticsPresent_OutputsSkipped); return; } @@ -463,7 +467,7 @@ namespace ts { } } - reportDiagnostics(diagnostics); + reportDiagnostics(diagnostics, compilerHost); // If the user doesn't want us to emit, then we're done at this point. if (compilerOptions.noEmit) { @@ -474,7 +478,7 @@ namespace ts { // Otherwise, emit and report any errors we ran into. let emitOutput = program.emit(); - reportDiagnostics(emitOutput.diagnostics); + reportDiagnostics(emitOutput.diagnostics, compilerHost); // If the emitter didn't emit anything, then pass that value along. if (emitOutput.emitSkipped) { @@ -587,7 +591,7 @@ namespace ts { let currentDirectory = sys.getCurrentDirectory(); let file = normalizePath(combinePaths(currentDirectory, "tsconfig.json")); if (sys.fileExists(file)) { - reportDiagnostic(createCompilerDiagnostic(Diagnostics.A_tsconfig_json_file_is_already_defined_at_Colon_0, file)); + reportDiagnostic(createCompilerDiagnostic(Diagnostics.A_tsconfig_json_file_is_already_defined_at_Colon_0, file), /* compilerHost */ undefined); } else { let compilerOptions = extend(options, defaultInitCompilerOptions); @@ -602,7 +606,7 @@ namespace ts { } sys.writeFile(file, JSON.stringify(configurations, undefined, 4)); - reportDiagnostic(createCompilerDiagnostic(Diagnostics.Successfully_created_a_tsconfig_json_file)); + reportDiagnostic(createCompilerDiagnostic(Diagnostics.Successfully_created_a_tsconfig_json_file), /* compilerHost */ undefined); } return; diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index d8de6e0c303..c019bffc812 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -2183,6 +2183,12 @@ namespace ts { return result; } + export function toRelativePath(absoluteOrRelativePath: string, basePath: string, getCanonicalFileName: (path: string) => string): string { + return !isRootedDiskPath(absoluteOrRelativePath) + ? absoluteOrRelativePath + : getRelativePathToDirectoryOrUrl(basePath, absoluteOrRelativePath, basePath, getCanonicalFileName, /* isAbsolutePathAnUrl */ false); + } + const carriageReturnLineFeed = "\r\n"; const lineFeed = "\n"; export function getNewLineCharacter(options: CompilerOptions): string { diff --git a/src/harness/projectsRunner.ts b/src/harness/projectsRunner.ts index 74539b70848..52d4b85f6b8 100644 --- a/src/harness/projectsRunner.ts +++ b/src/harness/projectsRunner.ts @@ -234,12 +234,15 @@ class ProjectRunner extends RunnerBase { } function writeFile(fileName: string, data: string, writeByteOrderMark: boolean) { + // convert file name to rooted name + // if filename is not rooted - concat it with project root and then expand project root relative to current directory let diskFileName = ts.isRootedDiskPath(fileName) ? fileName - : ts.normalizeSlashes(testCase.projectRoot) + "/" + ts.normalizeSlashes(fileName); + : Harness.IO.resolvePath(ts.normalizeSlashes(testCase.projectRoot) + "/" + ts.normalizeSlashes(fileName)); - let diskRelativeName = ts.getRelativePathToDirectoryOrUrl(testCase.projectRoot, diskFileName, - getCurrentDirectory(), Harness.Compiler.getCanonicalFileName, /*isAbsolutePathAnUrl*/ false); + let currentDirectory = getCurrentDirectory(); + // compute file name relative to current directory (expanded project root) + let diskRelativeName = ts.getRelativePathToDirectoryOrUrl(currentDirectory, diskFileName, currentDirectory, Harness.Compiler.getCanonicalFileName, /*isAbsolutePathAnUrl*/ false); if (ts.isRootedDiskPath(diskRelativeName) || diskRelativeName.substr(0, 3) === "../") { // If the generated output file resides in the parent folder or is rooted path, // we need to instead create files that can live in the project reference folder @@ -373,8 +376,12 @@ class ProjectRunner extends RunnerBase { runTest: testCase.runTest, bug: testCase.bug, rootDir: testCase.rootDir, - resolvedInputFiles: ts.map(compilerResult.program.getSourceFiles(), inputFile => inputFile.fileName), - emittedFiles: ts.map(compilerResult.outputFiles, outputFile => outputFile.emittedFileName) + resolvedInputFiles: ts.map(compilerResult.program.getSourceFiles(), inputFile => { + return ts.toRelativePath(inputFile.fileName, getCurrentDirectory(), path => Harness.Compiler.getCanonicalFileName(path)); + }), + emittedFiles: ts.map(compilerResult.outputFiles, outputFile => { + return ts.toRelativePath(outputFile.emittedFileName, getCurrentDirectory(), path => Harness.Compiler.getCanonicalFileName(path)); + }) }; return resolutionInfo; From 93e942a6de8d55f0d7eb7c9c6a5ad8a71eb191e4 Mon Sep 17 00:00:00 2001 From: Vladimir Matveev Date: Thu, 29 Oct 2015 13:52:38 -0700 Subject: [PATCH 112/227] FileMap now internally stores absolute normalized file names --- src/compiler/core.ts | 4 ++-- src/compiler/program.ts | 4 ++-- src/server/editorServices.ts | 4 ++-- src/services/services.ts | 10 ++++++---- 4 files changed, 12 insertions(+), 10 deletions(-) diff --git a/src/compiler/core.ts b/src/compiler/core.ts index 68c9bd06825..9ad692f3b6c 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -17,7 +17,7 @@ namespace ts { True = -1 } - export function createFileMap(getCanonicalFileName: (fileName: string) => string): FileMap { + export function createFileMap(getCanonicalFileName: (fileName: string) => string, currentDirectory: string): FileMap { let files: Map = {}; return { get, @@ -50,7 +50,7 @@ namespace ts { } function normalizeKey(key: string) { - return getCanonicalFileName(normalizeSlashes(key)); + return getCanonicalFileName(getNormalizedAbsolutePath(key, currentDirectory)); } function clear() { diff --git a/src/compiler/program.ts b/src/compiler/program.ts index e9f659792f9..5a27aa108dc 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -346,10 +346,10 @@ namespace ts { ? ((moduleNames: string[], containingFile: string) => host.resolveModuleNames(moduleNames, containingFile)) : ((moduleNames: string[], containingFile: string) => map(moduleNames, moduleName => resolveModuleName(moduleName, containingFile, options, host).resolvedModule)); - let filesByName = createFileMap(getCanonicalFileName); + let filesByName = createFileMap(getCanonicalFileName, currentDirectory); // stores 'filename -> file association' ignoring case // used to track cases when two file names differ only in casing - let filesByNameIgnoreCase = host.useCaseSensitiveFileNames() ? createFileMap(fileName => fileName.toLowerCase()) : undefined; + let filesByNameIgnoreCase = host.useCaseSensitiveFileNames() ? createFileMap(fileName => fileName.toLowerCase(), currentDirectory) : undefined; if (oldProgram) { // check properties that can affect structure of the program or module resolution strategy diff --git a/src/server/editorServices.ts b/src/server/editorServices.ts index d2e16487d07..9384244c831 100644 --- a/src/server/editorServices.ts +++ b/src/server/editorServices.ts @@ -93,8 +93,8 @@ namespace ts.server { constructor(public host: ServerHost, public project: Project) { const getCanonicalFileName = createGetCanonicalFileName(host.useCaseSensitiveFileNames); - this.resolvedModuleNames = createFileMap>(getCanonicalFileName); - this.filenameToScript = createFileMap(getCanonicalFileName); + this.resolvedModuleNames = createFileMap>(getCanonicalFileName, host.getCurrentDirectory()); + this.filenameToScript = createFileMap(getCanonicalFileName, host.getCurrentDirectory()); this.moduleResolutionHost = { fileExists: fileName => this.fileExists(fileName), readFile: fileName => this.host.readFile(fileName) diff --git a/src/services/services.ts b/src/services/services.ts index 5815e2ab1d1..dbb208be5f5 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -1698,7 +1698,7 @@ namespace ts { constructor(private host: LanguageServiceHost, getCanonicalFileName: (fileName: string) => string) { // script id => script index - this.fileNameToEntry = createFileMap(getCanonicalFileName); + this.fileNameToEntry = createFileMap(getCanonicalFileName, host.getCurrentDirectory()); // Initialize the list with the root file names let rootFileNames = host.getScriptFileNames(); @@ -1993,7 +1993,7 @@ namespace ts { } - export function createDocumentRegistry(useCaseSensitiveFileNames?: boolean): DocumentRegistry { + export function createDocumentRegistry(useCaseSensitiveFileNames?: boolean, currentDirectory = ""): DocumentRegistry { // Maps from compiler setting target (ES3, ES5, etc.) to all the cached documents we have // for those settings. let buckets: Map> = {}; @@ -2007,7 +2007,7 @@ namespace ts { let key = getKeyFromCompilationSettings(settings); let bucket = lookUp(buckets, key); if (!bucket && createIfMissing) { - buckets[key] = bucket = createFileMap(getCanonicalFileName); + buckets[key] = bucket = createFileMap(getCanonicalFileName, currentDirectory); } return bucket; } @@ -2556,7 +2556,9 @@ namespace ts { } } - export function createLanguageService(host: LanguageServiceHost, documentRegistry: DocumentRegistry = createDocumentRegistry()): LanguageService { + export function createLanguageService(host: LanguageServiceHost, + documentRegistry: DocumentRegistry = createDocumentRegistry(host.useCaseSensitiveFileNames && host.useCaseSensitiveFileNames(), host.getCurrentDirectory())): LanguageService { + let syntaxTreeCache: SyntaxTreeCache = new SyntaxTreeCache(host); let ruleProvider: formatting.RulesProvider; let program: Program; From c5b47fb5c8ce348a4cec1cd52654995052c20cc2 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Thu, 29 Oct 2015 14:53:14 -0700 Subject: [PATCH 113/227] Correct partial signature matching --- src/compiler/checker.ts | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 99b3d97b7be..1fde2711e12 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -5603,18 +5603,29 @@ namespace ts { return compareTypes(getTypeOfSymbol(sourceProp), getTypeOfSymbol(targetProp)); } + // A source signature matches a target signature if the two signatures have the same number of required, + // optional, and rest parameters. + function isMatchingSignature(source: Signature, target: Signature) { + return source.parameters.length === target.parameters.length && + source.minArgumentCount === target.minArgumentCount && + source.hasRestParameter === target.hasRestParameter; + } + + // A source signature partially matches a target signature if the target signature has no fewer required + // parameters and no more overall parameters than the source signature (where a signature with a rest + // parameter is always considered to have more overall parameters than one without). + function isPartiallyMatchingSignature(source: Signature, target: Signature) { + return source.minArgumentCount <= target.minArgumentCount && ( + source.hasRestParameter && !target.hasRestParameter || + source.hasRestParameter === target.hasRestParameter && source.parameters.length >= target.parameters.length); + } + function compareSignatures(source: Signature, target: Signature, partialMatch: boolean, ignoreReturnTypes: boolean, compareTypes: (s: Type, t: Type) => Ternary): Ternary { if (source === target) { return Ternary.True; } - if (source.parameters.length !== target.parameters.length || - source.minArgumentCount !== target.minArgumentCount || - source.hasRestParameter !== target.hasRestParameter) { - if (!partialMatch || - source.parameters.length < target.parameters.length && !source.hasRestParameter || - source.minArgumentCount > target.minArgumentCount) { - return Ternary.False; - } + if (!(isMatchingSignature(source, target) || partialMatch && isPartiallyMatchingSignature(source, target))) { + return Ternary.False; } let result = Ternary.True; if (source.typeParameters && target.typeParameters) { From a27ed01516873d2ac0c70b32135eddf30461eba7 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Thu, 29 Oct 2015 14:53:28 -0700 Subject: [PATCH 114/227] Adding test --- .../unionTypeCallSignatures4.errors.txt | 41 +++++++++++++++++ .../reference/unionTypeCallSignatures4.js | 45 +++++++++++++++++++ .../types/union/unionTypeCallSignatures4.ts | 25 +++++++++++ 3 files changed, 111 insertions(+) create mode 100644 tests/baselines/reference/unionTypeCallSignatures4.errors.txt create mode 100644 tests/baselines/reference/unionTypeCallSignatures4.js create mode 100644 tests/cases/conformance/types/union/unionTypeCallSignatures4.ts diff --git a/tests/baselines/reference/unionTypeCallSignatures4.errors.txt b/tests/baselines/reference/unionTypeCallSignatures4.errors.txt new file mode 100644 index 00000000000..585906a6b5a --- /dev/null +++ b/tests/baselines/reference/unionTypeCallSignatures4.errors.txt @@ -0,0 +1,41 @@ +tests/cases/conformance/types/union/unionTypeCallSignatures4.ts(10,1): error TS2346: Supplied parameters do not match any signature of call target. +tests/cases/conformance/types/union/unionTypeCallSignatures4.ts(20,1): error TS2346: Supplied parameters do not match any signature of call target. +tests/cases/conformance/types/union/unionTypeCallSignatures4.ts(23,1): error TS2346: Supplied parameters do not match any signature of call target. +tests/cases/conformance/types/union/unionTypeCallSignatures4.ts(25,1): error TS2346: Supplied parameters do not match any signature of call target. + + +==== tests/cases/conformance/types/union/unionTypeCallSignatures4.ts (4 errors) ==== + type F1 = (a: string, b?: string) => void; + type F2 = (a: string, b?: string, c?: string) => void; + type F3 = (a: string, ...rest: string[]) => void; + type F4 = (a: string, b?: string, ...rest: string[]) => void; + type F5 = (a: string, b: string) => void; + + var f12: F1 | F2; + f12("a"); + f12("a", "b"); + f12("a", "b", "c"); // error + ~~~~~~~~~~~~~~~~~~ +!!! error TS2346: Supplied parameters do not match any signature of call target. + + var f34: F3 | F4; + f34("a"); + f34("a", "b"); + f34("a", "b", "c"); + + var f1234: F1 | F2 | F3 | F4; + f1234("a"); + f1234("a", "b"); + f1234("a", "b", "c"); // error + ~~~~~~~~~~~~~~~~~~~~ +!!! error TS2346: Supplied parameters do not match any signature of call target. + + var f12345: F1 | F2 | F3 | F4 | F5; + f12345("a"); // error + ~~~~~~~~~~~ +!!! error TS2346: Supplied parameters do not match any signature of call target. + f12345("a", "b"); + f12345("a", "b", "c"); // error + ~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2346: Supplied parameters do not match any signature of call target. + \ No newline at end of file diff --git a/tests/baselines/reference/unionTypeCallSignatures4.js b/tests/baselines/reference/unionTypeCallSignatures4.js new file mode 100644 index 00000000000..be9a45b33c9 --- /dev/null +++ b/tests/baselines/reference/unionTypeCallSignatures4.js @@ -0,0 +1,45 @@ +//// [unionTypeCallSignatures4.ts] +type F1 = (a: string, b?: string) => void; +type F2 = (a: string, b?: string, c?: string) => void; +type F3 = (a: string, ...rest: string[]) => void; +type F4 = (a: string, b?: string, ...rest: string[]) => void; +type F5 = (a: string, b: string) => void; + +var f12: F1 | F2; +f12("a"); +f12("a", "b"); +f12("a", "b", "c"); // error + +var f34: F3 | F4; +f34("a"); +f34("a", "b"); +f34("a", "b", "c"); + +var f1234: F1 | F2 | F3 | F4; +f1234("a"); +f1234("a", "b"); +f1234("a", "b", "c"); // error + +var f12345: F1 | F2 | F3 | F4 | F5; +f12345("a"); // error +f12345("a", "b"); +f12345("a", "b", "c"); // error + + +//// [unionTypeCallSignatures4.js] +var f12; +f12("a"); +f12("a", "b"); +f12("a", "b", "c"); // error +var f34; +f34("a"); +f34("a", "b"); +f34("a", "b", "c"); +var f1234; +f1234("a"); +f1234("a", "b"); +f1234("a", "b", "c"); // error +var f12345; +f12345("a"); // error +f12345("a", "b"); +f12345("a", "b", "c"); // error diff --git a/tests/cases/conformance/types/union/unionTypeCallSignatures4.ts b/tests/cases/conformance/types/union/unionTypeCallSignatures4.ts new file mode 100644 index 00000000000..1e27acd2083 --- /dev/null +++ b/tests/cases/conformance/types/union/unionTypeCallSignatures4.ts @@ -0,0 +1,25 @@ +type F1 = (a: string, b?: string) => void; +type F2 = (a: string, b?: string, c?: string) => void; +type F3 = (a: string, ...rest: string[]) => void; +type F4 = (a: string, b?: string, ...rest: string[]) => void; +type F5 = (a: string, b: string) => void; + +var f12: F1 | F2; +f12("a"); +f12("a", "b"); +f12("a", "b", "c"); // error + +var f34: F3 | F4; +f34("a"); +f34("a", "b"); +f34("a", "b", "c"); + +var f1234: F1 | F2 | F3 | F4; +f1234("a"); +f1234("a", "b"); +f1234("a", "b", "c"); // error + +var f12345: F1 | F2 | F3 | F4 | F5; +f12345("a"); // error +f12345("a", "b"); +f12345("a", "b", "c"); // error From 5f81ba12aad46c2549d6121d7c8800b43c9f381a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Arod?= Date: Thu, 29 Oct 2015 23:02:32 +0100 Subject: [PATCH 115/227] Use CharactersCodes and isLineBreak in conditions --- src/compiler/commandLineParser.ts | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index d69b91bd5b4..885b3af45f8 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -426,18 +426,19 @@ namespace ts { let processingSingleLineComment = false; let processingMultiLineComment = false; for (let i = 0; i < jsonText.length; i++) { + let currentCharCode = jsonText.charCodeAt(i); let currentChar = jsonText.charAt(i); - let nextChar = (i + 1 < jsonText.length) ? jsonText.charAt(i + 1) : undefined; + let nextCharCode = (i + 1 < jsonText.length) ? jsonText.charCodeAt(i + 1) : undefined; if (processingString) { - if (currentChar === "\\" - && nextChar !== undefined) { + if (currentCharCode === CharacterCodes.backslash + && nextCharCode !== undefined) { // Found an escaped character // consume the \ and the escaped char result += currentChar; - result += nextChar; + result += jsonText.charAt(i + 1); i += 1; } - else if (currentChar === "\"") { + else if (currentCharCode === CharacterCodes.doubleQuote) { // End of string result += currentChar; processingString = false; @@ -448,7 +449,7 @@ namespace ts { } } else if (processingSingleLineComment) { - if (currentChar === "\n") { + if (isLineBreak(currentCharCode)) { // End of single line comment processingSingleLineComment = false; // Keep the line breaks to keep line numbers aligned @@ -460,13 +461,13 @@ namespace ts { } } else if (processingMultiLineComment) { - if (currentChar === "*" && nextChar === "/") { - // End of comment + if (currentCharCode === CharacterCodes.asterisk && nextCharCode === CharacterCodes.slash) { + // End of comment */ result += " "; i += 1; processingMultiLineComment = false; } - else if (currentChar === "\n") { + else if (isLineBreak(currentCharCode)) { // Keep the line breaks to Keep line aligned result += currentChar; } @@ -475,23 +476,23 @@ namespace ts { result += " "; } } - else if (currentChar === "\"") { + else if (currentCharCode === CharacterCodes.doubleQuote) { // String start result += currentChar; processingString = true; } - else if (currentChar === "#") { + else if (currentCharCode === CharacterCodes.hash) { // Start of # comment result += " "; processingSingleLineComment = true; } - else if (currentChar === "/" && nextChar === "/") { + else if (currentCharCode === CharacterCodes.slash && nextCharCode === CharacterCodes.slash) { // Start of // comment result += " "; i += 1; processingSingleLineComment = true; } - else if (currentChar === "/" && nextChar === "*") { + else if (currentCharCode === CharacterCodes.slash && nextCharCode === CharacterCodes.asterisk) { // Start of /**/ comment result += " "; i += 1; From 71cbaef79e7e00dfbe42c87bf228793db36fc1b6 Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Thu, 29 Oct 2015 15:27:45 -0700 Subject: [PATCH 116/227] Update documentation for fixing lib issues --- CONTRIBUTING.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 2e2c28590c2..3891b3826ba 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -32,6 +32,19 @@ Your pull request should: * Follow the code conventions descriped in [Coding guidelines](https://github.com/Microsoft/TypeScript/wiki/Coding-guidelines) * To avoid line ending issues, set `autocrlf = input` and `whitespace = cr-at-eol` in your git configuration +## Contributing `lib.d.ts` fixes + +The library sources are in: [src\lib\](https://github.com/Microsoft/TypeScript/tree/master/src/lib) + +To build the library files, run +```Shell +jake lib +``` + +`src\lib\dom.generated.d.ts` and `webworker.generated.d.ts`: + +These two files represent the DOM typings and are auto-generated. To make any modifications to them, please update the generation script in https://github.com/Microsoft/TSJS-lib-generator + ## Running the Tests To run all tests, invoke the `runtests` target using jake: From e1b4f01e77062de4ca87feabac34959edbc10627 Mon Sep 17 00:00:00 2001 From: Vladimir Matveev Date: Thu, 29 Oct 2015 14:54:56 -0700 Subject: [PATCH 117/227] introduce Path as branded string type, switch FileMap to use Path --- src/compiler/core.ts | 56 ++++++++++++++++------------ src/compiler/program.ts | 44 +++++++++++----------- src/compiler/types.ts | 16 +++++--- src/compiler/utilities.ts | 1 - src/server/editorServices.ts | 42 ++++++++++++--------- src/services/services.ts | 72 +++++++++++++++++++----------------- 6 files changed, 129 insertions(+), 102 deletions(-) diff --git a/src/compiler/core.ts b/src/compiler/core.ts index 9ad692f3b6c..c0e5739263e 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -17,45 +17,55 @@ namespace ts { True = -1 } - export function createFileMap(getCanonicalFileName: (fileName: string) => string, currentDirectory: string): FileMap { + export function createFileMap(keyMapper?: (key: string) => string): FileMap { let files: Map = {}; return { - get, - set, - contains, - remove, - clear, - forEachValue: forEachValueInMap + getPath, + setPath, + containsPath, + removePath, + forEachValue: forEachValueInMap, + clear }; - function set(fileName: string, value: T) { - files[normalizeKey(fileName)] = value; + function forEachValueInMap(f: (key: Path, value: T) => void) { + for (let key in files) { + f(key, files[key]); + } } - function get(fileName: string) { - return files[normalizeKey(fileName)]; + // path should already be well-formed so it does not need to be normalized + function getPath(path: Path): T { + return files[toKey(path)]; } - function contains(fileName: string) { - return hasProperty(files, normalizeKey(fileName)); + function setPath(path: Path, value: T) { + files[toKey(path)] = value; } - function remove (fileName: string) { - let key = normalizeKey(fileName); + function containsPath(path: Path) { + return hasProperty(files, toKey(path)); + } + + function removePath(path: Path) { + const key = toKey(path); delete files[key]; } - function forEachValueInMap(f: (value: T) => void) { - forEachValue(files, f); - } - - function normalizeKey(key: string) { - return getCanonicalFileName(getNormalizedAbsolutePath(key, currentDirectory)); - } - function clear() { files = {}; } + + function toKey(path: Path): string { + return keyMapper ? keyMapper(path) : path; + } + } + + export function toPath(fileName: string, basePath: string, getCanonicalFileName: (path: string) => string): Path { + const nonCanonicalizedPath = isRootedDiskPath(fileName) + ? normalizePath(fileName) + : getNormalizedAbsolutePath(fileName, basePath); + return getCanonicalFileName(nonCanonicalizedPath); } export const enum Comparison { diff --git a/src/compiler/program.ts b/src/compiler/program.ts index 5a27aa108dc..c579f66253b 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -346,10 +346,10 @@ namespace ts { ? ((moduleNames: string[], containingFile: string) => host.resolveModuleNames(moduleNames, containingFile)) : ((moduleNames: string[], containingFile: string) => map(moduleNames, moduleName => resolveModuleName(moduleName, containingFile, options, host).resolvedModule)); - let filesByName = createFileMap(getCanonicalFileName, currentDirectory); + let filesByName = createFileMap(); // stores 'filename -> file association' ignoring case // used to track cases when two file names differ only in casing - let filesByNameIgnoreCase = host.useCaseSensitiveFileNames() ? createFileMap(fileName => fileName.toLowerCase(), currentDirectory) : undefined; + let filesByNameIgnoreCase = host.useCaseSensitiveFileNames() ? createFileMap(fileName => fileName.toLowerCase()) : undefined; if (oldProgram) { // check properties that can affect structure of the program or module resolution strategy @@ -384,7 +384,7 @@ namespace ts { program = { getRootFileNames: () => rootNames, - getSourceFile: getSourceFile, + getSourceFile, getSourceFiles: () => files, getCompilerOptions: () => options, getSyntacticDiagnostics, @@ -435,7 +435,7 @@ namespace ts { // check if program source files has changed in the way that can affect structure of the program let newSourceFiles: SourceFile[] = []; - let normalizedAbsoluteFileNames: string[] = []; + let filePaths: Path[] = []; let modifiedSourceFiles: SourceFile[] = []; for (let oldSourceFile of oldProgram.getSourceFiles()) { @@ -444,8 +444,8 @@ namespace ts { return false; } - const normalizedAbsolutePath = getNormalizedAbsolutePath(newSourceFile.fileName, currentDirectory); - normalizedAbsoluteFileNames.push(normalizedAbsolutePath); + newSourceFile.path = oldSourceFile.path; + filePaths.push(newSourceFile.path); if (oldSourceFile !== newSourceFile) { if (oldSourceFile.hasNoDefaultLib !== newSourceFile.hasNoDefaultLib) { @@ -469,7 +469,7 @@ namespace ts { if (resolveModuleNamesWorker) { let moduleNames = map(newSourceFile.imports, name => name.text); - let resolutions = resolveModuleNamesWorker(moduleNames, normalizedAbsolutePath); + let resolutions = resolveModuleNamesWorker(moduleNames, getNormalizedAbsolutePath(newSourceFile.fileName, currentDirectory)); // ensure that module resolution results are still correct for (let i = 0; i < moduleNames.length; ++i) { let newResolution = resolutions[i]; @@ -500,7 +500,7 @@ namespace ts { // update fileName -> file mapping for (let i = 0, len = newSourceFiles.length; i < len; ++i) { - filesByName.set(normalizedAbsoluteFileNames[i], newSourceFiles[i]); + filesByName.setPath(filePaths[i], newSourceFiles[i]); } files = newSourceFiles; @@ -570,7 +570,7 @@ namespace ts { } function getSourceFile(fileName: string): SourceFile { - return filesByName.get(getNormalizedAbsolutePath(fileName, currentDirectory)); + return filesByName.getPath(toPath(fileName, currentDirectory, getCanonicalFileName)); } function getDiagnosticsHelper( @@ -741,7 +741,7 @@ namespace ts { diagnostic = Diagnostics.File_0_has_unsupported_extension_The_only_supported_extensions_are_1; diagnosticArgument = [fileName, "'" + supportedExtensions.join("', '") + "'"]; } - else if (!findSourceFile(fileName, getNormalizedAbsolutePath(fileName, currentDirectory), isDefaultLib, refFile, refPos, refEnd)) { + else if (!findSourceFile(fileName, toPath(fileName, currentDirectory, getCanonicalFileName), isDefaultLib, refFile, refPos, refEnd)) { diagnostic = Diagnostics.File_0_not_found; diagnosticArgument = [fileName]; } @@ -751,13 +751,13 @@ namespace ts { } } else { - let nonTsFile: SourceFile = options.allowNonTsExtensions && findSourceFile(fileName, getNormalizedAbsolutePath(fileName, currentDirectory), isDefaultLib, refFile, refPos, refEnd); + let 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, getNormalizedAbsolutePath(fileName + extension, currentDirectory), isDefaultLib, 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]; @@ -786,9 +786,9 @@ namespace ts { } // Get source file from normalized fileName - function findSourceFile(fileName: string, normalizedAbsolutePath: string, isDefaultLib: boolean, refFile?: SourceFile, refPos?: number, refEnd?: number): SourceFile { - if (filesByName.contains(normalizedAbsolutePath)) { - const file = filesByName.get(normalizedAbsolutePath); + function findSourceFile(fileName: string, normalizedAbsolutePath: Path, isDefaultLib: boolean, refFile?: SourceFile, refPos?: number, refEnd?: number): SourceFile { + if (filesByName.containsPath(normalizedAbsolutePath)) { + const file = filesByName.getPath(normalizedAbsolutePath); // try to check if we've already seen this file but with a different casing in path // NOTE: this only makes sense for case-insensitive file systems if (file && options.forceConsistentCasingInFileNames && getNormalizedAbsolutePath(file.fileName, currentDirectory) !== normalizedAbsolutePath) { @@ -809,16 +809,18 @@ namespace ts { } }); - filesByName.set(normalizedAbsolutePath, file); + filesByName.setPath(normalizedAbsolutePath, file); if (file) { + file.path = normalizedAbsolutePath; + if (host.useCaseSensitiveFileNames()) { // for case-sensitive file systems check if we've already seen some file with similar filename ignoring case - const existingFile = filesByNameIgnoreCase.get(normalizedAbsolutePath); + const existingFile = filesByNameIgnoreCase.getPath(normalizedAbsolutePath); if (existingFile) { reportFileNamesDifferOnlyInCasingError(fileName, existingFile.fileName, refFile, refPos, refEnd); } else { - filesByNameIgnoreCase.set(normalizedAbsolutePath, file); + filesByNameIgnoreCase.setPath(normalizedAbsolutePath, file); } } @@ -865,11 +867,7 @@ namespace ts { let resolution = resolutions[i]; setResolvedModule(file, moduleNames[i], resolution); if (resolution && !options.noResolve) { - const absoluteImportPath = isRootedDiskPath(resolution.resolvedFileName) - ? resolution.resolvedFileName - : getNormalizedAbsolutePath(resolution.resolvedFileName, currentDirectory); - - const importedFile = findSourceFile(resolution.resolvedFileName, absoluteImportPath, /* isDefaultLib */ false, file, skipTrivia(file.text, file.imports[i].pos), file.imports[i].end); + const importedFile = findSourceFile(resolution.resolvedFileName, toPath(resolution.resolvedFileName, currentDirectory, getCanonicalFileName), /* isDefaultLib */ false, file, skipTrivia(file.text, file.imports[i].pos), file.imports[i].end); if (importedFile && resolution.isExternalLibraryImport) { if (!isExternalModule(importedFile)) { diff --git a/src/compiler/types.ts b/src/compiler/types.ts index ae08ba7ff32..1e0b8129ac4 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -3,12 +3,17 @@ namespace ts { [index: string]: T; } + // branded string type used to store absolute, normalized and canonicalized paths + // arbitrary file name can be converted to Path via toPath function + export type Path = string & { __pathBrand: any }; + export interface FileMap { - get(fileName: string): T; - set(fileName: string, value: T): void; - contains(fileName: string): boolean; - remove(fileName: string): void; - forEachValue(f: (v: T) => void): void; + getPath(fileName: Path): T; + setPath(fileName: Path, value: T): void; + containsPath(fileName: Path): boolean; + removePath(fileName: Path): void; + + forEachValue(f: (key: Path, v: T) => void): void; clear(): void; } @@ -1250,6 +1255,7 @@ namespace ts { endOfFileToken: Node; fileName: string; + /* internal */ path: Path; text: string; amdDependencies: {path: string; name: string}[]; diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index c019bffc812..fb6d2686b15 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -1357,7 +1357,6 @@ namespace ts { export function tryResolveScriptReference(host: ScriptReferenceHost, sourceFile: SourceFile, reference: FileReference) { if (!host.getCompilerOptions().noResolve) { let referenceFileName = isRootedDiskPath(reference.fileName) ? reference.fileName : combinePaths(getDirectoryPath(sourceFile.fileName), reference.fileName); - referenceFileName = getNormalizedAbsolutePath(referenceFileName, host.getCurrentDirectory()); return host.getSourceFile(referenceFileName); } } diff --git a/src/server/editorServices.ts b/src/server/editorServices.ts index 9384244c831..3bc69b9a179 100644 --- a/src/server/editorServices.ts +++ b/src/server/editorServices.ts @@ -33,8 +33,10 @@ namespace ts.server { defaultProject: Project; // project to use by default for file fileWatcher: FileWatcher; formatCodeOptions = ts.clone(CompilerService.defaultFormatCodeOptions); + path: Path; constructor(private host: ServerHost, public fileName: string, public content: string, public isOpen = false) { + this.path = toPath(fileName, host.getCurrentDirectory(), createGetCanonicalFileName(host.useCaseSensitiveFileNames)); this.svc = ScriptVersionCache.fromString(host, content); } @@ -90,11 +92,12 @@ namespace ts.server { roots: ScriptInfo[] = []; private resolvedModuleNames: ts.FileMap>; private moduleResolutionHost: ts.ModuleResolutionHost; + private getCanonicalFileName: (fileName: string) => string; constructor(public host: ServerHost, public project: Project) { - const getCanonicalFileName = createGetCanonicalFileName(host.useCaseSensitiveFileNames); - this.resolvedModuleNames = createFileMap>(getCanonicalFileName, host.getCurrentDirectory()); - this.filenameToScript = createFileMap(getCanonicalFileName, host.getCurrentDirectory()); + this.getCanonicalFileName = createGetCanonicalFileName(host.useCaseSensitiveFileNames); + this.resolvedModuleNames = createFileMap>(); + this.filenameToScript = createFileMap(); this.moduleResolutionHost = { fileExists: fileName => this.fileExists(fileName), readFile: fileName => this.host.readFile(fileName) @@ -102,7 +105,8 @@ namespace ts.server { } resolveModuleNames(moduleNames: string[], containingFile: string): ResolvedModule[] { - let currentResolutionsInFile = this.resolvedModuleNames.get(containingFile); + let path = toPath(containingFile, this.host.getCurrentDirectory(), this.getCanonicalFileName); + let currentResolutionsInFile = this.resolvedModuleNames.getPath(path); let newResolutions: Map = {}; let resolvedModules: ResolvedModule[] = []; @@ -131,7 +135,7 @@ namespace ts.server { } // replace old results with a new one - this.resolvedModuleNames.set(containingFile, newResolutions); + this.resolvedModuleNames.setPath(path, newResolutions); return resolvedModules; function moduleResolutionIsValid(resolution: TimestampedResolvedModule): boolean { @@ -201,34 +205,35 @@ namespace ts.server { removeReferencedFile(info: ScriptInfo) { if (!info.isOpen) { - this.filenameToScript.remove(info.fileName); - this.resolvedModuleNames.remove(info.fileName); + this.filenameToScript.removePath(info.path); + this.resolvedModuleNames.removePath(info.path); } } getScriptInfo(filename: string): ScriptInfo { - let scriptInfo = this.filenameToScript.get(filename); + let path = toPath(filename, this.host.getCurrentDirectory(), this.getCanonicalFileName); + let scriptInfo = this.filenameToScript.getPath(path); if (!scriptInfo) { scriptInfo = this.project.openReferencedFile(filename); if (scriptInfo) { - this.filenameToScript.set(scriptInfo.fileName, scriptInfo); + this.filenameToScript.setPath(path, scriptInfo); } } return scriptInfo; } addRoot(info: ScriptInfo) { - if (!this.filenameToScript.contains(info.fileName)) { - this.filenameToScript.set(info.fileName, info); + if (!this.filenameToScript.containsPath(info.path)) { + this.filenameToScript.setPath(info.path, info); this.roots.push(info); } } removeRoot(info: ScriptInfo) { - if (!this.filenameToScript.contains(info.fileName)) { - this.filenameToScript.remove(info.fileName); + if (!this.filenameToScript.containsPath(info.path)) { + this.filenameToScript.removePath(info.path); this.roots = copyListRemovingItem(info, this.roots); - this.resolvedModuleNames.remove(info.fileName); + this.resolvedModuleNames.removePath(info.path); } } @@ -277,7 +282,8 @@ namespace ts.server { * @param line 1 based index */ lineToTextSpan(filename: string, line: number): ts.TextSpan { - const script: ScriptInfo = this.filenameToScript.get(filename); + let path = toPath(filename, this.host.getCurrentDirectory(), this.getCanonicalFileName); + const script: ScriptInfo = this.filenameToScript.getPath(path); const index = script.snap().index; const lineInfo = index.lineNumberToInfo(line + 1); @@ -297,7 +303,8 @@ namespace ts.server { * @param offset 1 based index */ lineOffsetToPosition(filename: string, line: number, offset: number): number { - const script: ScriptInfo = this.filenameToScript.get(filename); + let path = toPath(filename, this.host.getCurrentDirectory(), this.getCanonicalFileName); + const script: ScriptInfo = this.filenameToScript.getPath(path); const index = script.snap().index; const lineInfo = index.lineNumberToInfo(line); @@ -310,7 +317,8 @@ namespace ts.server { * @param offset 1-based index */ positionToLineOffset(filename: string, position: number): ILineInfo { - const script: ScriptInfo = this.filenameToScript.get(filename); + let path = toPath(filename, this.host.getCurrentDirectory(), this.getCanonicalFileName); + const script: ScriptInfo = this.filenameToScript.getPath(path); const index = script.snap().index; const lineOffset = index.charOffsetToLineNumberAndPos(position); return { line: lineOffset.line, offset: lineOffset.offset + 1 }; diff --git a/src/services/services.ts b/src/services/services.ts index dbb208be5f5..954a0a37dc9 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -773,6 +773,7 @@ namespace ts { class SourceFileObject extends NodeObject implements SourceFile { public _declarationBrand: any; public fileName: string; + public path: Path; public text: string; public scriptSnapshot: IScriptSnapshot; public lineMap: number[]; @@ -1695,15 +1696,17 @@ namespace ts { class HostCache { private fileNameToEntry: FileMap; private _compilationSettings: CompilerOptions; + private currentDirectory: string; - constructor(private host: LanguageServiceHost, getCanonicalFileName: (fileName: string) => string) { + constructor(private host: LanguageServiceHost, private getCanonicalFileName: (fileName: string) => string) { // script id => script index - this.fileNameToEntry = createFileMap(getCanonicalFileName, host.getCurrentDirectory()); + this.currentDirectory = host.getCurrentDirectory(); + this.fileNameToEntry = createFileMap(); // Initialize the list with the root file names let rootFileNames = host.getScriptFileNames(); for (let fileName of rootFileNames) { - this.createEntry(fileName); + this.createEntry(fileName, toPath(fileName, this.currentDirectory, getCanonicalFileName)); } // store the compilation settings @@ -1714,7 +1717,7 @@ namespace ts { return this._compilationSettings; } - private createEntry(fileName: string) { + private createEntry(fileName: string, path: Path) { let entry: HostFileInformation; let scriptSnapshot = this.host.getScriptSnapshot(fileName); if (scriptSnapshot) { @@ -1725,30 +1728,31 @@ namespace ts { }; } - this.fileNameToEntry.set(fileName, entry); + this.fileNameToEntry.setPath(path, entry); return entry; } - private getEntry(fileName: string): HostFileInformation { - return this.fileNameToEntry.get(fileName); + private getEntry(path: Path): HostFileInformation { + return this.fileNameToEntry.getPath(path); } - private contains(fileName: string): boolean { - return this.fileNameToEntry.contains(fileName); + private contains(path: Path): boolean { + return this.fileNameToEntry.containsPath(path); } public getOrCreateEntry(fileName: string): HostFileInformation { - if (this.contains(fileName)) { - return this.getEntry(fileName); + let path = toPath(fileName, this.currentDirectory, this.getCanonicalFileName) + if (this.contains(path)) { + return this.getEntry(path); } - return this.createEntry(fileName); + return this.createEntry(fileName, path); } public getRootFileNames(): string[] { let fileNames: string[] = []; - this.fileNameToEntry.forEachValue(value => { + this.fileNameToEntry.forEachValue((path, value) => { if (value) { fileNames.push(value.hostFileName); } @@ -1757,13 +1761,13 @@ namespace ts { return fileNames; } - public getVersion(fileName: string): string { - let file = this.getEntry(fileName); + public getVersion(path: Path): string { + let file = this.getEntry(path); return file && file.version; } - public getScriptSnapshot(fileName: string): IScriptSnapshot { - let file = this.getEntry(fileName); + public getScriptSnapshot(path: Path): IScriptSnapshot { + let file = this.getEntry(path); return file && file.scriptSnapshot; } } @@ -2007,7 +2011,7 @@ namespace ts { let key = getKeyFromCompilationSettings(settings); let bucket = lookUp(buckets, key); if (!bucket && createIfMissing) { - buckets[key] = bucket = createFileMap(getCanonicalFileName, currentDirectory); + buckets[key] = bucket = createFileMap(); } return bucket; } @@ -2016,14 +2020,13 @@ namespace ts { let bucketInfoArray = Object.keys(buckets).filter(name => name && name.charAt(0) === '_').map(name => { let entries = lookUp(buckets, name); let sourceFiles: { name: string; refCount: number; references: string[]; }[] = []; - for (let i in entries) { - let entry = entries.get(i); + entries.forEachValue((key, entry) => { sourceFiles.push({ - name: i, + name: key, refCount: entry.languageServiceRefCount, references: entry.owners.slice(0) }); - } + }); sourceFiles.sort((x, y) => y.refCount - x.refCount); return { bucket: name, @@ -2049,7 +2052,8 @@ namespace ts { acquiring: boolean): SourceFile { let bucket = getBucketForCompilationSettings(compilationSettings, /*createIfMissing*/ true); - let entry = bucket.get(fileName); + let path = toPath(fileName, currentDirectory, getCanonicalFileName); + let entry = bucket.getPath(path); if (!entry) { Debug.assert(acquiring, "How could we be trying to update a document that the registry doesn't have?"); @@ -2061,7 +2065,7 @@ namespace ts { languageServiceRefCount: 0, owners: [] }; - bucket.set(fileName, entry); + bucket.setPath(path, entry); } else { // We have an entry for this file. However, it may be for a different version of @@ -2089,12 +2093,14 @@ namespace ts { let bucket = getBucketForCompilationSettings(compilationSettings, false); Debug.assert(bucket !== undefined); - let entry = bucket.get(fileName); + let path = toPath(fileName, currentDirectory, getCanonicalFileName); + + let entry = bucket.getPath(path); entry.languageServiceRefCount--; Debug.assert(entry.languageServiceRefCount >= 0); if (entry.languageServiceRefCount === 0) { - bucket.remove(fileName); + bucket.removePath(path); } } @@ -2567,6 +2573,7 @@ namespace ts { let useCaseSensitivefileNames = false; let cancellationToken = new CancellationTokenObject(host.getCancellationToken && host.getCancellationToken()); + let currentDirectory = host.getCurrentDirectory(); // Check if the localized messages json is set, otherwise query the host for it if (!localizedDiagnosticMessages && host.getLocalizedDiagnosticMessages) { localizedDiagnosticMessages = host.getLocalizedDiagnosticMessages(); @@ -2581,8 +2588,7 @@ namespace ts { let getCanonicalFileName = createGetCanonicalFileName(useCaseSensitivefileNames); function getValidSourceFile(fileName: string): SourceFile { - fileName = normalizeSlashes(fileName); - let sourceFile = program.getSourceFile(getCanonicalFileName(fileName)); + let sourceFile = program.getSourceFile(fileName); if (!sourceFile) { throw new Error("Could not find file: '" + fileName + "'."); } @@ -2643,7 +2649,7 @@ namespace ts { getNewLine: () => getNewLineOrDefaultFromHost(host), getDefaultLibFileName: (options) => host.getDefaultLibFileName(options), writeFile: (fileName, data, writeByteOrderMark) => { }, - getCurrentDirectory: () => host.getCurrentDirectory(), + getCurrentDirectory: () => currentDirectory, fileExists: (fileName): boolean => { // stub missing host functionality Debug.assert(!host.resolveModuleNames); @@ -2667,9 +2673,8 @@ namespace ts { if (program) { let oldSourceFiles = program.getSourceFiles(); for (let oldSourceFile of oldSourceFiles) { - let fileName = oldSourceFile.fileName; - if (!newProgram.getSourceFile(fileName) || changesInCompilationSettingsAffectSyntax) { - documentRegistry.releaseDocument(fileName, oldSettings); + if (!newProgram.getSourceFile(oldSourceFile.fileName) || changesInCompilationSettingsAffectSyntax) { + documentRegistry.releaseDocument(oldSourceFile.fileName, oldSettings); } } } @@ -2734,7 +2739,8 @@ namespace ts { } function sourceFileUpToDate(sourceFile: SourceFile): boolean { - return sourceFile && sourceFile.version === hostCache.getVersion(sourceFile.fileName); + let path = sourceFile.path || toPath(sourceFile.fileName, currentDirectory, getCanonicalFileName); + return sourceFile && sourceFile.version === hostCache.getVersion(path); } function programUpToDate(): boolean { From 534bb62c592cb2f53c178515e9b592a710d86197 Mon Sep 17 00:00:00 2001 From: Vladimir Matveev Date: Thu, 29 Oct 2015 16:43:12 -0700 Subject: [PATCH 118/227] remove 'path' suffix from FileMap methods --- src/compiler/core.ts | 16 ++++++++-------- src/compiler/program.ts | 14 +++++++------- src/compiler/types.ts | 8 ++++---- src/server/editorServices.ts | 28 ++++++++++++++-------------- src/services/services.ts | 14 +++++++------- 5 files changed, 40 insertions(+), 40 deletions(-) diff --git a/src/compiler/core.ts b/src/compiler/core.ts index c0e5739263e..068ab1865bb 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -20,10 +20,10 @@ namespace ts { export function createFileMap(keyMapper?: (key: string) => string): FileMap { let files: Map = {}; return { - getPath, - setPath, - containsPath, - removePath, + get, + set, + contains, + remove, forEachValue: forEachValueInMap, clear }; @@ -35,19 +35,19 @@ namespace ts { } // path should already be well-formed so it does not need to be normalized - function getPath(path: Path): T { + function get(path: Path): T { return files[toKey(path)]; } - function setPath(path: Path, value: T) { + function set(path: Path, value: T) { files[toKey(path)] = value; } - function containsPath(path: Path) { + function contains(path: Path) { return hasProperty(files, toKey(path)); } - function removePath(path: Path) { + function remove(path: Path) { const key = toKey(path); delete files[key]; } diff --git a/src/compiler/program.ts b/src/compiler/program.ts index c579f66253b..4822a86b527 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -500,7 +500,7 @@ namespace ts { // update fileName -> file mapping for (let i = 0, len = newSourceFiles.length; i < len; ++i) { - filesByName.setPath(filePaths[i], newSourceFiles[i]); + filesByName.set(filePaths[i], newSourceFiles[i]); } files = newSourceFiles; @@ -570,7 +570,7 @@ namespace ts { } function getSourceFile(fileName: string): SourceFile { - return filesByName.getPath(toPath(fileName, currentDirectory, getCanonicalFileName)); + return filesByName.get(toPath(fileName, currentDirectory, getCanonicalFileName)); } function getDiagnosticsHelper( @@ -787,8 +787,8 @@ namespace ts { // Get source file from normalized fileName function findSourceFile(fileName: string, normalizedAbsolutePath: Path, isDefaultLib: boolean, refFile?: SourceFile, refPos?: number, refEnd?: number): SourceFile { - if (filesByName.containsPath(normalizedAbsolutePath)) { - const file = filesByName.getPath(normalizedAbsolutePath); + if (filesByName.contains(normalizedAbsolutePath)) { + const file = filesByName.get(normalizedAbsolutePath); // try to check if we've already seen this file but with a different casing in path // NOTE: this only makes sense for case-insensitive file systems if (file && options.forceConsistentCasingInFileNames && getNormalizedAbsolutePath(file.fileName, currentDirectory) !== normalizedAbsolutePath) { @@ -809,18 +809,18 @@ namespace ts { } }); - filesByName.setPath(normalizedAbsolutePath, file); + filesByName.set(normalizedAbsolutePath, file); if (file) { file.path = normalizedAbsolutePath; if (host.useCaseSensitiveFileNames()) { // for case-sensitive file systems check if we've already seen some file with similar filename ignoring case - const existingFile = filesByNameIgnoreCase.getPath(normalizedAbsolutePath); + const existingFile = filesByNameIgnoreCase.get(normalizedAbsolutePath); if (existingFile) { reportFileNamesDifferOnlyInCasingError(fileName, existingFile.fileName, refFile, refPos, refEnd); } else { - filesByNameIgnoreCase.setPath(normalizedAbsolutePath, file); + filesByNameIgnoreCase.set(normalizedAbsolutePath, file); } } diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 1e0b8129ac4..b58e6307202 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -8,10 +8,10 @@ namespace ts { export type Path = string & { __pathBrand: any }; export interface FileMap { - getPath(fileName: Path): T; - setPath(fileName: Path, value: T): void; - containsPath(fileName: Path): boolean; - removePath(fileName: Path): void; + get(fileName: Path): T; + set(fileName: Path, value: T): void; + contains(fileName: Path): boolean; + remove(fileName: Path): void; forEachValue(f: (key: Path, v: T) => void): void; clear(): void; diff --git a/src/server/editorServices.ts b/src/server/editorServices.ts index 3bc69b9a179..df3b63903c5 100644 --- a/src/server/editorServices.ts +++ b/src/server/editorServices.ts @@ -106,7 +106,7 @@ namespace ts.server { resolveModuleNames(moduleNames: string[], containingFile: string): ResolvedModule[] { let path = toPath(containingFile, this.host.getCurrentDirectory(), this.getCanonicalFileName); - let currentResolutionsInFile = this.resolvedModuleNames.getPath(path); + let currentResolutionsInFile = this.resolvedModuleNames.get(path); let newResolutions: Map = {}; let resolvedModules: ResolvedModule[] = []; @@ -135,7 +135,7 @@ namespace ts.server { } // replace old results with a new one - this.resolvedModuleNames.setPath(path, newResolutions); + this.resolvedModuleNames.set(path, newResolutions); return resolvedModules; function moduleResolutionIsValid(resolution: TimestampedResolvedModule): boolean { @@ -205,35 +205,35 @@ namespace ts.server { removeReferencedFile(info: ScriptInfo) { if (!info.isOpen) { - this.filenameToScript.removePath(info.path); - this.resolvedModuleNames.removePath(info.path); + this.filenameToScript.remove(info.path); + this.resolvedModuleNames.remove(info.path); } } getScriptInfo(filename: string): ScriptInfo { let path = toPath(filename, this.host.getCurrentDirectory(), this.getCanonicalFileName); - let scriptInfo = this.filenameToScript.getPath(path); + let scriptInfo = this.filenameToScript.get(path); if (!scriptInfo) { scriptInfo = this.project.openReferencedFile(filename); if (scriptInfo) { - this.filenameToScript.setPath(path, scriptInfo); + this.filenameToScript.set(path, scriptInfo); } } return scriptInfo; } addRoot(info: ScriptInfo) { - if (!this.filenameToScript.containsPath(info.path)) { - this.filenameToScript.setPath(info.path, info); + if (!this.filenameToScript.contains(info.path)) { + this.filenameToScript.set(info.path, info); this.roots.push(info); } } removeRoot(info: ScriptInfo) { - if (!this.filenameToScript.containsPath(info.path)) { - this.filenameToScript.removePath(info.path); + if (!this.filenameToScript.contains(info.path)) { + this.filenameToScript.remove(info.path); this.roots = copyListRemovingItem(info, this.roots); - this.resolvedModuleNames.removePath(info.path); + this.resolvedModuleNames.remove(info.path); } } @@ -283,7 +283,7 @@ namespace ts.server { */ lineToTextSpan(filename: string, line: number): ts.TextSpan { let path = toPath(filename, this.host.getCurrentDirectory(), this.getCanonicalFileName); - const script: ScriptInfo = this.filenameToScript.getPath(path); + const script: ScriptInfo = this.filenameToScript.get(path); const index = script.snap().index; const lineInfo = index.lineNumberToInfo(line + 1); @@ -304,7 +304,7 @@ namespace ts.server { */ lineOffsetToPosition(filename: string, line: number, offset: number): number { let path = toPath(filename, this.host.getCurrentDirectory(), this.getCanonicalFileName); - const script: ScriptInfo = this.filenameToScript.getPath(path); + const script: ScriptInfo = this.filenameToScript.get(path); const index = script.snap().index; const lineInfo = index.lineNumberToInfo(line); @@ -318,7 +318,7 @@ namespace ts.server { */ positionToLineOffset(filename: string, position: number): ILineInfo { let path = toPath(filename, this.host.getCurrentDirectory(), this.getCanonicalFileName); - const script: ScriptInfo = this.filenameToScript.getPath(path); + const script: ScriptInfo = this.filenameToScript.get(path); const index = script.snap().index; const lineOffset = index.charOffsetToLineNumberAndPos(position); return { line: lineOffset.line, offset: lineOffset.offset + 1 }; diff --git a/src/services/services.ts b/src/services/services.ts index 954a0a37dc9..6b7aa0ecbff 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -1728,16 +1728,16 @@ namespace ts { }; } - this.fileNameToEntry.setPath(path, entry); + this.fileNameToEntry.set(path, entry); return entry; } private getEntry(path: Path): HostFileInformation { - return this.fileNameToEntry.getPath(path); + return this.fileNameToEntry.get(path); } private contains(path: Path): boolean { - return this.fileNameToEntry.containsPath(path); + return this.fileNameToEntry.contains(path); } public getOrCreateEntry(fileName: string): HostFileInformation { @@ -2053,7 +2053,7 @@ namespace ts { let bucket = getBucketForCompilationSettings(compilationSettings, /*createIfMissing*/ true); let path = toPath(fileName, currentDirectory, getCanonicalFileName); - let entry = bucket.getPath(path); + let entry = bucket.get(path); if (!entry) { Debug.assert(acquiring, "How could we be trying to update a document that the registry doesn't have?"); @@ -2065,7 +2065,7 @@ namespace ts { languageServiceRefCount: 0, owners: [] }; - bucket.setPath(path, entry); + bucket.set(path, entry); } else { // We have an entry for this file. However, it may be for a different version of @@ -2095,12 +2095,12 @@ namespace ts { let path = toPath(fileName, currentDirectory, getCanonicalFileName); - let entry = bucket.getPath(path); + let entry = bucket.get(path); entry.languageServiceRefCount--; Debug.assert(entry.languageServiceRefCount >= 0); if (entry.languageServiceRefCount === 0) { - bucket.removePath(path); + bucket.remove(path); } } From 0c3d52e8b138fcfc464d3955f31cf41780ae0823 Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Thu, 29 Oct 2015 17:33:09 -0700 Subject: [PATCH 119/227] Update CONTRIBUTING.md respond to review comments --- CONTRIBUTING.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 3891b3826ba..ebbe2af322a 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -41,9 +41,9 @@ To build the library files, run jake lib ``` -`src\lib\dom.generated.d.ts` and `webworker.generated.d.ts`: +`src\lib\dom.generated.d.ts` and `src\lib\webworker.generated.d.ts`: -These two files represent the DOM typings and are auto-generated. To make any modifications to them, please update the generation script in https://github.com/Microsoft/TSJS-lib-generator +These two files represent the DOM typings and are auto-generated. To make any modifications to them, please submit a PR to https://github.com/Microsoft/TSJS-lib-generator ## Running the Tests From 9f12bc8a1b0d100e87d336d8303fe5cf9fe09045 Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Thu, 29 Oct 2015 17:51:36 -0700 Subject: [PATCH 120/227] feedback from pr, new tests --- src/compiler/checker.ts | 61 +++++------ tests/baselines/reference/typeGuardEnums.js | 41 +++++++ .../reference/typeGuardEnums.symbols | 34 ++++++ .../baselines/reference/typeGuardEnums.types | 40 +++++++ tests/baselines/reference/typeGuardNesting.js | 26 ++++- .../reference/typeGuardNesting.symbols | 44 +++++++- .../reference/typeGuardNesting.types | 100 +++++++++++++++++- .../reference/typeGuardOfFormTypeOfOther.js | 24 ++--- .../typeGuardOfFormTypeOfOther.symbols | 18 ++-- .../typeGuardOfFormTypeOfOther.types | 30 +++--- .../typeGuardTautologicalConsistiency.js | 24 +++++ .../typeGuardTautologicalConsistiency.symbols | 23 ++++ .../typeGuardTautologicalConsistiency.types | 36 +++++++ .../expressions/typeGuards/typeGuardEnums.ts | 18 ++++ .../typeGuards/typeGuardNesting.ts | 14 ++- .../typeGuards/typeGuardOfFormTypeOfOther.ts | 12 +-- .../typeGuardTautologicalConsistiency.ts | 11 ++ 17 files changed, 463 insertions(+), 93 deletions(-) create mode 100644 tests/baselines/reference/typeGuardEnums.js create mode 100644 tests/baselines/reference/typeGuardEnums.symbols create mode 100644 tests/baselines/reference/typeGuardEnums.types create mode 100644 tests/baselines/reference/typeGuardTautologicalConsistiency.js create mode 100644 tests/baselines/reference/typeGuardTautologicalConsistiency.symbols create mode 100644 tests/baselines/reference/typeGuardTautologicalConsistiency.types create mode 100644 tests/cases/conformance/expressions/typeGuards/typeGuardEnums.ts create mode 100644 tests/cases/conformance/expressions/typeGuards/typeGuardTautologicalConsistiency.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 93b644b07a4..4e8cb7cc340 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -6177,27 +6177,6 @@ namespace ts { Debug.fail("should not get here"); } - // For a union type, remove all constituent types that are of the given type kind (when isOfTypeKind is true) - // or not of the given type kind (when isOfTypeKind is false) - function removeTypesFromUnionType(type: Type, typeKind: TypeFlags, isOfTypeKind: boolean, allowEmptyUnionResult: boolean): Type { - if (type.flags & TypeFlags.Union) { - let types = (type).types; - if (forEach(types, t => !!(t.flags & typeKind) === isOfTypeKind)) { - // Above we checked if we have anything to remove, now use the opposite test to do the removal - let narrowedType = getUnionType(filter(types, t => !(t.flags & typeKind) === isOfTypeKind)); - if (allowEmptyUnionResult || narrowedType !== emptyObjectType) { - return narrowedType; - } - } - } - else if (allowEmptyUnionResult && !!(type.flags & typeKind) === isOfTypeKind) { - // Use getUnionType(emptyArray) instead of emptyObjectType in case the way empty union types - // are represented ever changes. - return getUnionType(emptyArray); - } - return type; - } - function hasInitializer(node: VariableLikeDeclaration): boolean { return !!(node.initializer || isBindingPattern(node.parent) && hasInitializer(node.parent.parent)); } @@ -6296,6 +6275,7 @@ namespace ts { // Get the narrowed type of a given symbol at a given location function getNarrowedTypeOfSymbol(symbol: Symbol, node: Node) { let type = getTypeOfSymbol(symbol); + let originalType = type; // Only narrow when symbol is variable of type any or an object, union, or type parameter type if (node && symbol.flags & SymbolFlags.Variable) { if (isTypeAny(type) || type.flags & (TypeFlags.ObjectType | TypeFlags.Union | TypeFlags.TypeParameter)) { @@ -6338,10 +6318,6 @@ namespace ts { // Stop at the first containing function or module declaration break loop; } - // Preserve old top-level behavior - if the branch is really an empty set, revert to prior type - if (narrowedType === getUnionType(emptyArray)) { - narrowedType = type; - } // Use narrowed type if construct contains no assignments to variable if (narrowedType !== type) { if (isVariableAssignedWithin(symbol, node)) { @@ -6350,6 +6326,11 @@ namespace ts { type = narrowedType; } } + + // Preserve old top-level behavior - if the branch is really an empty set, revert to prior type + if (type === getUnionType(emptyArray)) { + type = originalType; + } } } @@ -6369,22 +6350,24 @@ namespace ts { assumeTrue = !assumeTrue; } let typeInfo = primitiveTypeInfo[right.text]; - // If the type to be narrowed is any and we're affirmatively checking against a primitive, return the primitive + // If the type to be narrowed is any and we're checking a primitive with assumeTrue=true, return the primitive if (!!(type.flags & TypeFlags.Any) && typeInfo && assumeTrue) { return typeInfo.type; } - // At this point we can bail if it's not a union - if (!(type.flags & TypeFlags.Union)) { - return type; - } - let flags = typeInfo ? typeInfo.flags : (assumeTrue = !assumeTrue, TypeFlags.NumberLike | TypeFlags.StringLike | TypeFlags.ESSymbol | TypeFlags.Boolean); - let union = type as UnionType; - if (assumeTrue) { - return getUnionType(filter(union.types, t => !!(t.flags & flags))); + let flags: TypeFlags; + if (typeInfo) { + flags = typeInfo.flags; } else { - return getUnionType(filter(union.types, t => !(t.flags & flags))); + assumeTrue = !assumeTrue; + flags = TypeFlags.NumberLike | TypeFlags.StringLike | TypeFlags.ESSymbol | TypeFlags.Boolean; } + // At this point we can bail if it's not a union + if (!(type.flags & TypeFlags.Union)) { + // If the active non-union type would be removed from a union by this type guard, return an empty union + return (assumeTrue === !!(type.flags & flags)) ? type : getUnionType(emptyArray); + } + return getUnionType(filter((type as UnionType).types, t => assumeTrue === !!(t.flags & flags)), /*noSubtypeReduction*/ true); } function narrowTypeByAnd(type: Type, expr: BinaryExpression, assumeTrue: boolean): Type { @@ -12554,7 +12537,13 @@ namespace ts { // 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. - let arrayType = removeTypesFromUnionType(arrayOrStringType, TypeFlags.StringLike, /*isTypeOfKind*/ true, /*allowEmptyUnionResult*/ true); + let arrayType = arrayOrStringType; + if (arrayOrStringType.flags & TypeFlags.Union) { + arrayType = getUnionType(filter((arrayOrStringType as UnionType).types, t => !(t.flags & TypeFlags.StringLike))); + } + else if (arrayOrStringType.flags & TypeFlags.StringLike) { + arrayType = getUnionType(emptyArray); + } let hasStringConstituent = arrayOrStringType !== arrayType; let reportedError = false; diff --git a/tests/baselines/reference/typeGuardEnums.js b/tests/baselines/reference/typeGuardEnums.js new file mode 100644 index 00000000000..1eb4b7552c4 --- /dev/null +++ b/tests/baselines/reference/typeGuardEnums.js @@ -0,0 +1,41 @@ +//// [typeGuardEnums.ts] +enum E {} +enum V {} + +let x: number|string|E|V; + +if (typeof x === "number") { + x; // number|E|V +} +else { + x; // string +} + +if (typeof x !== "number") { + x; // string +} +else { + x; // number|E|V +} + + +//// [typeGuardEnums.js] +var E; +(function (E) { +})(E || (E = {})); +var V; +(function (V) { +})(V || (V = {})); +var x; +if (typeof x === "number") { + x; // number|E|V +} +else { + x; // string +} +if (typeof x !== "number") { + x; // string +} +else { + x; // number|E|V +} diff --git a/tests/baselines/reference/typeGuardEnums.symbols b/tests/baselines/reference/typeGuardEnums.symbols new file mode 100644 index 00000000000..8f1a396c481 --- /dev/null +++ b/tests/baselines/reference/typeGuardEnums.symbols @@ -0,0 +1,34 @@ +=== tests/cases/conformance/expressions/typeGuards/typeGuardEnums.ts === +enum E {} +>E : Symbol(E, Decl(typeGuardEnums.ts, 0, 0)) + +enum V {} +>V : Symbol(V, Decl(typeGuardEnums.ts, 0, 9)) + +let x: number|string|E|V; +>x : Symbol(x, Decl(typeGuardEnums.ts, 3, 3)) +>E : Symbol(E, Decl(typeGuardEnums.ts, 0, 0)) +>V : Symbol(V, Decl(typeGuardEnums.ts, 0, 9)) + +if (typeof x === "number") { +>x : Symbol(x, Decl(typeGuardEnums.ts, 3, 3)) + + x; // number|E|V +>x : Symbol(x, Decl(typeGuardEnums.ts, 3, 3)) +} +else { + x; // string +>x : Symbol(x, Decl(typeGuardEnums.ts, 3, 3)) +} + +if (typeof x !== "number") { +>x : Symbol(x, Decl(typeGuardEnums.ts, 3, 3)) + + x; // string +>x : Symbol(x, Decl(typeGuardEnums.ts, 3, 3)) +} +else { + x; // number|E|V +>x : Symbol(x, Decl(typeGuardEnums.ts, 3, 3)) +} + diff --git a/tests/baselines/reference/typeGuardEnums.types b/tests/baselines/reference/typeGuardEnums.types new file mode 100644 index 00000000000..1d39a81d78a --- /dev/null +++ b/tests/baselines/reference/typeGuardEnums.types @@ -0,0 +1,40 @@ +=== tests/cases/conformance/expressions/typeGuards/typeGuardEnums.ts === +enum E {} +>E : E + +enum V {} +>V : V + +let x: number|string|E|V; +>x : number | string | E | V +>E : E +>V : V + +if (typeof x === "number") { +>typeof x === "number" : boolean +>typeof x : string +>x : number | string | E | V +>"number" : string + + x; // number|E|V +>x : number | E | V +} +else { + x; // string +>x : string +} + +if (typeof x !== "number") { +>typeof x !== "number" : boolean +>typeof x : string +>x : number | string | E | V +>"number" : string + + x; // string +>x : string +} +else { + x; // number|E|V +>x : number | E | V +} + diff --git a/tests/baselines/reference/typeGuardNesting.js b/tests/baselines/reference/typeGuardNesting.js index 4c9a64c2851..364653d0273 100644 --- a/tests/baselines/reference/typeGuardNesting.js +++ b/tests/baselines/reference/typeGuardNesting.js @@ -1,11 +1,31 @@ //// [typeGuardNesting.ts] let strOrBool: string|boolean; if ((typeof strOrBool === 'boolean' && !strOrBool) || typeof strOrBool === 'string') { - var label: string = (typeof strOrBool === 'string') ? strOrBool : "other string"; -} + let label: string = (typeof strOrBool === 'string') ? strOrBool : "string"; + let bool: boolean = (typeof strOrBool === 'boolean') ? strOrBool : false; + let label2: string = (typeof strOrBool !== 'boolean') ? strOrBool : "string"; + let bool2: boolean = (typeof strOrBool !== 'string') ? strOrBool : false; +} + +if ((typeof strOrBool !== 'string' && !strOrBool) || typeof strOrBool !== 'boolean') { + let label: string = (typeof strOrBool === 'string') ? strOrBool : "string"; + let bool: boolean = (typeof strOrBool === 'boolean') ? strOrBool : false; + let label2: string = (typeof strOrBool !== 'boolean') ? strOrBool : "string"; + let bool2: boolean = (typeof strOrBool !== 'string') ? strOrBool : false; +} + //// [typeGuardNesting.js] var strOrBool; if ((typeof strOrBool === 'boolean' && !strOrBool) || typeof strOrBool === 'string') { - var label = (typeof strOrBool === 'string') ? strOrBool : "other string"; + var label = (typeof strOrBool === 'string') ? strOrBool : "string"; + var bool = (typeof strOrBool === 'boolean') ? strOrBool : false; + var label2 = (typeof strOrBool !== 'boolean') ? strOrBool : "string"; + var bool2 = (typeof strOrBool !== 'string') ? strOrBool : false; +} +if ((typeof strOrBool !== 'string' && !strOrBool) || typeof strOrBool !== 'boolean') { + var label = (typeof strOrBool === 'string') ? strOrBool : "string"; + var bool = (typeof strOrBool === 'boolean') ? strOrBool : false; + var label2 = (typeof strOrBool !== 'boolean') ? strOrBool : "string"; + var bool2 = (typeof strOrBool !== 'string') ? strOrBool : false; } diff --git a/tests/baselines/reference/typeGuardNesting.symbols b/tests/baselines/reference/typeGuardNesting.symbols index f0cfb1f1eed..427db81f3ed 100644 --- a/tests/baselines/reference/typeGuardNesting.symbols +++ b/tests/baselines/reference/typeGuardNesting.symbols @@ -7,8 +7,50 @@ if ((typeof strOrBool === 'boolean' && !strOrBool) || typeof strOrBool === 'stri >strOrBool : Symbol(strOrBool, Decl(typeGuardNesting.ts, 0, 3)) >strOrBool : Symbol(strOrBool, Decl(typeGuardNesting.ts, 0, 3)) - var label: string = (typeof strOrBool === 'string') ? strOrBool : "other string"; + let label: string = (typeof strOrBool === 'string') ? strOrBool : "string"; >label : Symbol(label, Decl(typeGuardNesting.ts, 2, 4)) >strOrBool : Symbol(strOrBool, Decl(typeGuardNesting.ts, 0, 3)) +>strOrBool : Symbol(strOrBool, Decl(typeGuardNesting.ts, 0, 3)) + + let bool: boolean = (typeof strOrBool === 'boolean') ? strOrBool : false; +>bool : Symbol(bool, Decl(typeGuardNesting.ts, 3, 4)) +>strOrBool : Symbol(strOrBool, Decl(typeGuardNesting.ts, 0, 3)) +>strOrBool : Symbol(strOrBool, Decl(typeGuardNesting.ts, 0, 3)) + + let label2: string = (typeof strOrBool !== 'boolean') ? strOrBool : "string"; +>label2 : Symbol(label2, Decl(typeGuardNesting.ts, 4, 4)) +>strOrBool : Symbol(strOrBool, Decl(typeGuardNesting.ts, 0, 3)) +>strOrBool : Symbol(strOrBool, Decl(typeGuardNesting.ts, 0, 3)) + + let bool2: boolean = (typeof strOrBool !== 'string') ? strOrBool : false; +>bool2 : Symbol(bool2, Decl(typeGuardNesting.ts, 5, 4)) +>strOrBool : Symbol(strOrBool, Decl(typeGuardNesting.ts, 0, 3)) >strOrBool : Symbol(strOrBool, Decl(typeGuardNesting.ts, 0, 3)) } + +if ((typeof strOrBool !== 'string' && !strOrBool) || typeof strOrBool !== 'boolean') { +>strOrBool : Symbol(strOrBool, Decl(typeGuardNesting.ts, 0, 3)) +>strOrBool : Symbol(strOrBool, Decl(typeGuardNesting.ts, 0, 3)) +>strOrBool : Symbol(strOrBool, Decl(typeGuardNesting.ts, 0, 3)) + + let label: string = (typeof strOrBool === 'string') ? strOrBool : "string"; +>label : Symbol(label, Decl(typeGuardNesting.ts, 9, 4)) +>strOrBool : Symbol(strOrBool, Decl(typeGuardNesting.ts, 0, 3)) +>strOrBool : Symbol(strOrBool, Decl(typeGuardNesting.ts, 0, 3)) + + let bool: boolean = (typeof strOrBool === 'boolean') ? strOrBool : false; +>bool : Symbol(bool, Decl(typeGuardNesting.ts, 10, 4)) +>strOrBool : Symbol(strOrBool, Decl(typeGuardNesting.ts, 0, 3)) +>strOrBool : Symbol(strOrBool, Decl(typeGuardNesting.ts, 0, 3)) + + let label2: string = (typeof strOrBool !== 'boolean') ? strOrBool : "string"; +>label2 : Symbol(label2, Decl(typeGuardNesting.ts, 11, 4)) +>strOrBool : Symbol(strOrBool, Decl(typeGuardNesting.ts, 0, 3)) +>strOrBool : Symbol(strOrBool, Decl(typeGuardNesting.ts, 0, 3)) + + let bool2: boolean = (typeof strOrBool !== 'string') ? strOrBool : false; +>bool2 : Symbol(bool2, Decl(typeGuardNesting.ts, 12, 4)) +>strOrBool : Symbol(strOrBool, Decl(typeGuardNesting.ts, 0, 3)) +>strOrBool : Symbol(strOrBool, Decl(typeGuardNesting.ts, 0, 3)) +} + diff --git a/tests/baselines/reference/typeGuardNesting.types b/tests/baselines/reference/typeGuardNesting.types index 9f79974635d..255e96da89e 100644 --- a/tests/baselines/reference/typeGuardNesting.types +++ b/tests/baselines/reference/typeGuardNesting.types @@ -17,14 +17,108 @@ if ((typeof strOrBool === 'boolean' && !strOrBool) || typeof strOrBool === 'stri >strOrBool : string | boolean >'string' : string - var label: string = (typeof strOrBool === 'string') ? strOrBool : "other string"; + let label: string = (typeof strOrBool === 'string') ? strOrBool : "string"; >label : string ->(typeof strOrBool === 'string') ? strOrBool : "other string" : string +>(typeof strOrBool === 'string') ? strOrBool : "string" : string >(typeof strOrBool === 'string') : boolean >typeof strOrBool === 'string' : boolean >typeof strOrBool : string >strOrBool : boolean | string >'string' : string >strOrBool : string ->"other string" : string +>"string" : string + + let bool: boolean = (typeof strOrBool === 'boolean') ? strOrBool : false; +>bool : boolean +>(typeof strOrBool === 'boolean') ? strOrBool : false : boolean +>(typeof strOrBool === 'boolean') : boolean +>typeof strOrBool === 'boolean' : boolean +>typeof strOrBool : string +>strOrBool : boolean | string +>'boolean' : string +>strOrBool : boolean +>false : boolean + + let label2: string = (typeof strOrBool !== 'boolean') ? strOrBool : "string"; +>label2 : string +>(typeof strOrBool !== 'boolean') ? strOrBool : "string" : string +>(typeof strOrBool !== 'boolean') : boolean +>typeof strOrBool !== 'boolean' : boolean +>typeof strOrBool : string +>strOrBool : boolean | string +>'boolean' : string +>strOrBool : string +>"string" : string + + let bool2: boolean = (typeof strOrBool !== 'string') ? strOrBool : false; +>bool2 : boolean +>(typeof strOrBool !== 'string') ? strOrBool : false : boolean +>(typeof strOrBool !== 'string') : boolean +>typeof strOrBool !== 'string' : boolean +>typeof strOrBool : string +>strOrBool : boolean | string +>'string' : string +>strOrBool : boolean +>false : boolean } + +if ((typeof strOrBool !== 'string' && !strOrBool) || typeof strOrBool !== 'boolean') { +>(typeof strOrBool !== 'string' && !strOrBool) || typeof strOrBool !== 'boolean' : boolean +>(typeof strOrBool !== 'string' && !strOrBool) : boolean +>typeof strOrBool !== 'string' && !strOrBool : boolean +>typeof strOrBool !== 'string' : boolean +>typeof strOrBool : string +>strOrBool : string | boolean +>'string' : string +>!strOrBool : boolean +>strOrBool : boolean +>typeof strOrBool !== 'boolean' : boolean +>typeof strOrBool : string +>strOrBool : string | boolean +>'boolean' : string + + let label: string = (typeof strOrBool === 'string') ? strOrBool : "string"; +>label : string +>(typeof strOrBool === 'string') ? strOrBool : "string" : string +>(typeof strOrBool === 'string') : boolean +>typeof strOrBool === 'string' : boolean +>typeof strOrBool : string +>strOrBool : boolean | string +>'string' : string +>strOrBool : string +>"string" : string + + let bool: boolean = (typeof strOrBool === 'boolean') ? strOrBool : false; +>bool : boolean +>(typeof strOrBool === 'boolean') ? strOrBool : false : boolean +>(typeof strOrBool === 'boolean') : boolean +>typeof strOrBool === 'boolean' : boolean +>typeof strOrBool : string +>strOrBool : boolean | string +>'boolean' : string +>strOrBool : boolean +>false : boolean + + let label2: string = (typeof strOrBool !== 'boolean') ? strOrBool : "string"; +>label2 : string +>(typeof strOrBool !== 'boolean') ? strOrBool : "string" : string +>(typeof strOrBool !== 'boolean') : boolean +>typeof strOrBool !== 'boolean' : boolean +>typeof strOrBool : string +>strOrBool : boolean | string +>'boolean' : string +>strOrBool : string +>"string" : string + + let bool2: boolean = (typeof strOrBool !== 'string') ? strOrBool : false; +>bool2 : boolean +>(typeof strOrBool !== 'string') ? strOrBool : false : boolean +>(typeof strOrBool !== 'string') : boolean +>typeof strOrBool !== 'string' : boolean +>typeof strOrBool : string +>strOrBool : boolean | string +>'string' : string +>strOrBool : boolean +>false : boolean +} + diff --git a/tests/baselines/reference/typeGuardOfFormTypeOfOther.js b/tests/baselines/reference/typeGuardOfFormTypeOfOther.js index 3bb1a2091f6..d1cb4994196 100644 --- a/tests/baselines/reference/typeGuardOfFormTypeOfOther.js +++ b/tests/baselines/reference/typeGuardOfFormTypeOfOther.js @@ -23,19 +23,19 @@ if (typeof strOrC === "Object") { c = strOrC; // C } else { - var r2: string | C = strOrC; // string | C + var r2: string = strOrC; // string } if (typeof numOrC === "Object") { c = numOrC; // C } else { - var r3: number | C = numOrC; // number | C + var r3: number = numOrC; // number } if (typeof boolOrC === "Object") { c = boolOrC; // C } else { - var r4: boolean | C = boolOrC; // boolean | C + var r4: boolean = boolOrC; // boolean } // Narrowing occurs only if target type is a subtype of variable type @@ -50,19 +50,19 @@ else { // - when true, narrows the type of x by typeof x === s when false, or // - when false, narrows the type of x by typeof x === s when true. if (typeof strOrC !== "Object") { - var r2: string | C = strOrC; // string | C + var r2: string = strOrC; // string } else { c = strOrC; // C } if (typeof numOrC !== "Object") { - var r3: number | C = numOrC; // number | C + var r3: number = numOrC; // number } else { c = numOrC; // C } if (typeof boolOrC !== "Object") { - var r4: boolean | C = boolOrC; // boolean | C + var r4: boolean = boolOrC; // boolean } else { c = boolOrC; // C @@ -104,19 +104,19 @@ if (typeof strOrC === "Object") { c = strOrC; // C } else { - var r2 = strOrC; // string | C + var r2 = strOrC; // string } if (typeof numOrC === "Object") { c = numOrC; // C } else { - var r3 = numOrC; // number | C + var r3 = numOrC; // number } if (typeof boolOrC === "Object") { c = boolOrC; // C } else { - var r4 = boolOrC; // boolean | C + var r4 = boolOrC; // boolean } // Narrowing occurs only if target type is a subtype of variable type if (typeof strOrNumOrBool === "Object") { @@ -129,19 +129,19 @@ else { // - when true, narrows the type of x by typeof x === s when false, or // - when false, narrows the type of x by typeof x === s when true. if (typeof strOrC !== "Object") { - var r2 = strOrC; // string | C + var r2 = strOrC; // string } else { c = strOrC; // C } if (typeof numOrC !== "Object") { - var r3 = numOrC; // number | C + var r3 = numOrC; // number } else { c = numOrC; // C } if (typeof boolOrC !== "Object") { - var r4 = boolOrC; // boolean | C + var r4 = boolOrC; // boolean } else { c = boolOrC; // C diff --git a/tests/baselines/reference/typeGuardOfFormTypeOfOther.symbols b/tests/baselines/reference/typeGuardOfFormTypeOfOther.symbols index e3ecffdc2e9..eb120d468dc 100644 --- a/tests/baselines/reference/typeGuardOfFormTypeOfOther.symbols +++ b/tests/baselines/reference/typeGuardOfFormTypeOfOther.symbols @@ -56,9 +56,8 @@ if (typeof strOrC === "Object") { >strOrC : Symbol(strOrC, Decl(typeGuardOfFormTypeOfOther.ts, 9, 3)) } else { - var r2: string | C = strOrC; // string | C + var r2: string = strOrC; // string >r2 : Symbol(r2, Decl(typeGuardOfFormTypeOfOther.ts, 24, 7), Decl(typeGuardOfFormTypeOfOther.ts, 51, 7)) ->C : Symbol(C, Decl(typeGuardOfFormTypeOfOther.ts, 0, 0)) >strOrC : Symbol(strOrC, Decl(typeGuardOfFormTypeOfOther.ts, 9, 3)) } if (typeof numOrC === "Object") { @@ -69,9 +68,8 @@ if (typeof numOrC === "Object") { >numOrC : Symbol(numOrC, Decl(typeGuardOfFormTypeOfOther.ts, 10, 3)) } else { - var r3: number | C = numOrC; // number | C + var r3: number = numOrC; // number >r3 : Symbol(r3, Decl(typeGuardOfFormTypeOfOther.ts, 30, 7), Decl(typeGuardOfFormTypeOfOther.ts, 57, 7)) ->C : Symbol(C, Decl(typeGuardOfFormTypeOfOther.ts, 0, 0)) >numOrC : Symbol(numOrC, Decl(typeGuardOfFormTypeOfOther.ts, 10, 3)) } if (typeof boolOrC === "Object") { @@ -82,9 +80,8 @@ if (typeof boolOrC === "Object") { >boolOrC : Symbol(boolOrC, Decl(typeGuardOfFormTypeOfOther.ts, 11, 3)) } else { - var r4: boolean | C = boolOrC; // boolean | C + var r4: boolean = boolOrC; // boolean >r4 : Symbol(r4, Decl(typeGuardOfFormTypeOfOther.ts, 36, 7), Decl(typeGuardOfFormTypeOfOther.ts, 63, 7)) ->C : Symbol(C, Decl(typeGuardOfFormTypeOfOther.ts, 0, 0)) >boolOrC : Symbol(boolOrC, Decl(typeGuardOfFormTypeOfOther.ts, 11, 3)) } @@ -108,9 +105,8 @@ else { if (typeof strOrC !== "Object") { >strOrC : Symbol(strOrC, Decl(typeGuardOfFormTypeOfOther.ts, 9, 3)) - var r2: string | C = strOrC; // string | C + var r2: string = strOrC; // string >r2 : Symbol(r2, Decl(typeGuardOfFormTypeOfOther.ts, 24, 7), Decl(typeGuardOfFormTypeOfOther.ts, 51, 7)) ->C : Symbol(C, Decl(typeGuardOfFormTypeOfOther.ts, 0, 0)) >strOrC : Symbol(strOrC, Decl(typeGuardOfFormTypeOfOther.ts, 9, 3)) } else { @@ -121,9 +117,8 @@ else { if (typeof numOrC !== "Object") { >numOrC : Symbol(numOrC, Decl(typeGuardOfFormTypeOfOther.ts, 10, 3)) - var r3: number | C = numOrC; // number | C + var r3: number = numOrC; // number >r3 : Symbol(r3, Decl(typeGuardOfFormTypeOfOther.ts, 30, 7), Decl(typeGuardOfFormTypeOfOther.ts, 57, 7)) ->C : Symbol(C, Decl(typeGuardOfFormTypeOfOther.ts, 0, 0)) >numOrC : Symbol(numOrC, Decl(typeGuardOfFormTypeOfOther.ts, 10, 3)) } else { @@ -134,9 +129,8 @@ else { if (typeof boolOrC !== "Object") { >boolOrC : Symbol(boolOrC, Decl(typeGuardOfFormTypeOfOther.ts, 11, 3)) - var r4: boolean | C = boolOrC; // boolean | C + var r4: boolean = boolOrC; // boolean >r4 : Symbol(r4, Decl(typeGuardOfFormTypeOfOther.ts, 36, 7), Decl(typeGuardOfFormTypeOfOther.ts, 63, 7)) ->C : Symbol(C, Decl(typeGuardOfFormTypeOfOther.ts, 0, 0)) >boolOrC : Symbol(boolOrC, Decl(typeGuardOfFormTypeOfOther.ts, 11, 3)) } else { diff --git a/tests/baselines/reference/typeGuardOfFormTypeOfOther.types b/tests/baselines/reference/typeGuardOfFormTypeOfOther.types index 8150c3ec25d..5cec3567194 100644 --- a/tests/baselines/reference/typeGuardOfFormTypeOfOther.types +++ b/tests/baselines/reference/typeGuardOfFormTypeOfOther.types @@ -60,9 +60,8 @@ if (typeof strOrC === "Object") { >strOrC : C } else { - var r2: string | C = strOrC; // string | C ->r2 : string | C ->C : C + var r2: string = strOrC; // string +>r2 : string >strOrC : string } if (typeof numOrC === "Object") { @@ -77,9 +76,8 @@ if (typeof numOrC === "Object") { >numOrC : C } else { - var r3: number | C = numOrC; // number | C ->r3 : number | C ->C : C + var r3: number = numOrC; // number +>r3 : number >numOrC : number } if (typeof boolOrC === "Object") { @@ -94,9 +92,8 @@ if (typeof boolOrC === "Object") { >boolOrC : C } else { - var r4: boolean | C = boolOrC; // boolean | C ->r4 : boolean | C ->C : C + var r4: boolean = boolOrC; // boolean +>r4 : boolean >boolOrC : boolean } @@ -126,9 +123,8 @@ if (typeof strOrC !== "Object") { >strOrC : string | C >"Object" : string - var r2: string | C = strOrC; // string | C ->r2 : string | C ->C : C + var r2: string = strOrC; // string +>r2 : string >strOrC : string } else { @@ -143,9 +139,8 @@ if (typeof numOrC !== "Object") { >numOrC : number | C >"Object" : string - var r3: number | C = numOrC; // number | C ->r3 : number | C ->C : C + var r3: number = numOrC; // number +>r3 : number >numOrC : number } else { @@ -160,9 +155,8 @@ if (typeof boolOrC !== "Object") { >boolOrC : boolean | C >"Object" : string - var r4: boolean | C = boolOrC; // boolean | C ->r4 : boolean | C ->C : C + var r4: boolean = boolOrC; // boolean +>r4 : boolean >boolOrC : boolean } else { diff --git a/tests/baselines/reference/typeGuardTautologicalConsistiency.js b/tests/baselines/reference/typeGuardTautologicalConsistiency.js new file mode 100644 index 00000000000..1b7fa2021c5 --- /dev/null +++ b/tests/baselines/reference/typeGuardTautologicalConsistiency.js @@ -0,0 +1,24 @@ +//// [typeGuardTautologicalConsistiency.ts] +let stringOrNumber: string | number; + +if (typeof stringOrNumber === "number") { + if (typeof stringOrNumber !== "number") { + stringOrNumber; + } +} + +if (typeof stringOrNumber === "number" && typeof stringOrNumber !== "number") { + stringOrNumber; +} + + +//// [typeGuardTautologicalConsistiency.js] +var stringOrNumber; +if (typeof stringOrNumber === "number") { + if (typeof stringOrNumber !== "number") { + stringOrNumber; + } +} +if (typeof stringOrNumber === "number" && typeof stringOrNumber !== "number") { + stringOrNumber; +} diff --git a/tests/baselines/reference/typeGuardTautologicalConsistiency.symbols b/tests/baselines/reference/typeGuardTautologicalConsistiency.symbols new file mode 100644 index 00000000000..9ee82a5413f --- /dev/null +++ b/tests/baselines/reference/typeGuardTautologicalConsistiency.symbols @@ -0,0 +1,23 @@ +=== tests/cases/conformance/expressions/typeGuards/typeGuardTautologicalConsistiency.ts === +let stringOrNumber: string | number; +>stringOrNumber : Symbol(stringOrNumber, Decl(typeGuardTautologicalConsistiency.ts, 0, 3)) + +if (typeof stringOrNumber === "number") { +>stringOrNumber : Symbol(stringOrNumber, Decl(typeGuardTautologicalConsistiency.ts, 0, 3)) + + if (typeof stringOrNumber !== "number") { +>stringOrNumber : Symbol(stringOrNumber, Decl(typeGuardTautologicalConsistiency.ts, 0, 3)) + + stringOrNumber; +>stringOrNumber : Symbol(stringOrNumber, Decl(typeGuardTautologicalConsistiency.ts, 0, 3)) + } +} + +if (typeof stringOrNumber === "number" && typeof stringOrNumber !== "number") { +>stringOrNumber : Symbol(stringOrNumber, Decl(typeGuardTautologicalConsistiency.ts, 0, 3)) +>stringOrNumber : Symbol(stringOrNumber, Decl(typeGuardTautologicalConsistiency.ts, 0, 3)) + + stringOrNumber; +>stringOrNumber : Symbol(stringOrNumber, Decl(typeGuardTautologicalConsistiency.ts, 0, 3)) +} + diff --git a/tests/baselines/reference/typeGuardTautologicalConsistiency.types b/tests/baselines/reference/typeGuardTautologicalConsistiency.types new file mode 100644 index 00000000000..9acb1464761 --- /dev/null +++ b/tests/baselines/reference/typeGuardTautologicalConsistiency.types @@ -0,0 +1,36 @@ +=== tests/cases/conformance/expressions/typeGuards/typeGuardTautologicalConsistiency.ts === +let stringOrNumber: string | number; +>stringOrNumber : string | number + +if (typeof stringOrNumber === "number") { +>typeof stringOrNumber === "number" : boolean +>typeof stringOrNumber : string +>stringOrNumber : string | number +>"number" : string + + if (typeof stringOrNumber !== "number") { +>typeof stringOrNumber !== "number" : boolean +>typeof stringOrNumber : string +>stringOrNumber : number +>"number" : string + + stringOrNumber; +>stringOrNumber : string + } +} + +if (typeof stringOrNumber === "number" && typeof stringOrNumber !== "number") { +>typeof stringOrNumber === "number" && typeof stringOrNumber !== "number" : boolean +>typeof stringOrNumber === "number" : boolean +>typeof stringOrNumber : string +>stringOrNumber : string | number +>"number" : string +>typeof stringOrNumber !== "number" : boolean +>typeof stringOrNumber : string +>stringOrNumber : number +>"number" : string + + stringOrNumber; +>stringOrNumber : number +} + diff --git a/tests/cases/conformance/expressions/typeGuards/typeGuardEnums.ts b/tests/cases/conformance/expressions/typeGuards/typeGuardEnums.ts new file mode 100644 index 00000000000..54e9a1bd8fe --- /dev/null +++ b/tests/cases/conformance/expressions/typeGuards/typeGuardEnums.ts @@ -0,0 +1,18 @@ +enum E {} +enum V {} + +let x: number|string|E|V; + +if (typeof x === "number") { + x; // number|E|V +} +else { + x; // string +} + +if (typeof x !== "number") { + x; // string +} +else { + x; // number|E|V +} diff --git a/tests/cases/conformance/expressions/typeGuards/typeGuardNesting.ts b/tests/cases/conformance/expressions/typeGuards/typeGuardNesting.ts index b06b5880800..6423af18a5a 100644 --- a/tests/cases/conformance/expressions/typeGuards/typeGuardNesting.ts +++ b/tests/cases/conformance/expressions/typeGuards/typeGuardNesting.ts @@ -1,4 +1,14 @@ let strOrBool: string|boolean; if ((typeof strOrBool === 'boolean' && !strOrBool) || typeof strOrBool === 'string') { - var label: string = (typeof strOrBool === 'string') ? strOrBool : "other string"; -} \ No newline at end of file + let label: string = (typeof strOrBool === 'string') ? strOrBool : "string"; + let bool: boolean = (typeof strOrBool === 'boolean') ? strOrBool : false; + let label2: string = (typeof strOrBool !== 'boolean') ? strOrBool : "string"; + let bool2: boolean = (typeof strOrBool !== 'string') ? strOrBool : false; +} + +if ((typeof strOrBool !== 'string' && !strOrBool) || typeof strOrBool !== 'boolean') { + let label: string = (typeof strOrBool === 'string') ? strOrBool : "string"; + let bool: boolean = (typeof strOrBool === 'boolean') ? strOrBool : false; + let label2: string = (typeof strOrBool !== 'boolean') ? strOrBool : "string"; + let bool2: boolean = (typeof strOrBool !== 'string') ? strOrBool : false; +} diff --git a/tests/cases/conformance/expressions/typeGuards/typeGuardOfFormTypeOfOther.ts b/tests/cases/conformance/expressions/typeGuards/typeGuardOfFormTypeOfOther.ts index 9d7d555fc18..ac3403d8151 100644 --- a/tests/cases/conformance/expressions/typeGuards/typeGuardOfFormTypeOfOther.ts +++ b/tests/cases/conformance/expressions/typeGuards/typeGuardOfFormTypeOfOther.ts @@ -22,19 +22,19 @@ if (typeof strOrC === "Object") { c = strOrC; // C } else { - var r2: string | C = strOrC; // string | C + var r2: string = strOrC; // string } if (typeof numOrC === "Object") { c = numOrC; // C } else { - var r3: number | C = numOrC; // number | C + var r3: number = numOrC; // number } if (typeof boolOrC === "Object") { c = boolOrC; // C } else { - var r4: boolean | C = boolOrC; // boolean | C + var r4: boolean = boolOrC; // boolean } // Narrowing occurs only if target type is a subtype of variable type @@ -49,19 +49,19 @@ else { // - when true, narrows the type of x by typeof x === s when false, or // - when false, narrows the type of x by typeof x === s when true. if (typeof strOrC !== "Object") { - var r2: string | C = strOrC; // string | C + var r2: string = strOrC; // string } else { c = strOrC; // C } if (typeof numOrC !== "Object") { - var r3: number | C = numOrC; // number | C + var r3: number = numOrC; // number } else { c = numOrC; // C } if (typeof boolOrC !== "Object") { - var r4: boolean | C = boolOrC; // boolean | C + var r4: boolean = boolOrC; // boolean } else { c = boolOrC; // C diff --git a/tests/cases/conformance/expressions/typeGuards/typeGuardTautologicalConsistiency.ts b/tests/cases/conformance/expressions/typeGuards/typeGuardTautologicalConsistiency.ts new file mode 100644 index 00000000000..9a44603d2d4 --- /dev/null +++ b/tests/cases/conformance/expressions/typeGuards/typeGuardTautologicalConsistiency.ts @@ -0,0 +1,11 @@ +let stringOrNumber: string | number; + +if (typeof stringOrNumber === "number") { + if (typeof stringOrNumber !== "number") { + stringOrNumber; + } +} + +if (typeof stringOrNumber === "number" && typeof stringOrNumber !== "number") { + stringOrNumber; +} From 19e796dcbd61d77601f27c9cb4bd4fea396d633d Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Thu, 29 Oct 2015 18:46:06 -0700 Subject: [PATCH 121/227] More correctness --- src/compiler/checker.ts | 72 +++++++++++-------- .../typeGuardTautologicalConsistiency.types | 4 +- 2 files changed, 46 insertions(+), 30 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 4e8cb7cc340..30edecf3b40 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -6275,37 +6275,19 @@ namespace ts { // Get the narrowed type of a given symbol at a given location function getNarrowedTypeOfSymbol(symbol: Symbol, node: Node) { let type = getTypeOfSymbol(symbol); - let originalType = type; // Only narrow when symbol is variable of type any or an object, union, or type parameter type if (node && symbol.flags & SymbolFlags.Variable) { if (isTypeAny(type) || type.flags & (TypeFlags.ObjectType | TypeFlags.Union | TypeFlags.TypeParameter)) { + let originalType = type; + let nodeStack: {node: Node, child: Node}[] = []; loop: while (node.parent) { let child = node; node = node.parent; - let narrowedType = type; switch (node.kind) { case SyntaxKind.IfStatement: - // In a branch of an if statement, narrow based on controlling expression - if (child !== (node).expression) { - narrowedType = narrowType(type, (node).expression, /*assumeTrue*/ child === (node).thenStatement); - } - break; case SyntaxKind.ConditionalExpression: - // In a branch of a conditional expression, narrow based on controlling condition - if (child !== (node).condition) { - narrowedType = narrowType(type, (node).condition, /*assumeTrue*/ child === (node).whenTrue); - } - break; case SyntaxKind.BinaryExpression: - // In the right operand of an && or ||, narrow based on left operand - if (child === (node).right) { - if ((node).operatorToken.kind === SyntaxKind.AmpersandAmpersandToken) { - narrowedType = narrowType(type, (node).left, /*assumeTrue*/ true); - } - else if ((node).operatorToken.kind === SyntaxKind.BarBarToken) { - narrowedType = narrowType(type, (node).left, /*assumeTrue*/ false); - } - } + nodeStack.push({node, child}); break; case SyntaxKind.SourceFile: case SyntaxKind.ModuleDeclaration: @@ -6318,12 +6300,42 @@ namespace ts { // Stop at the first containing function or module declaration break loop; } - // Use narrowed type if construct contains no assignments to variable - if (narrowedType !== type) { - if (isVariableAssignedWithin(symbol, node)) { + } + + let nodes: {node: Node, child: Node}; + while (nodes = nodeStack.pop()) { + let {node, child} = nodes; + switch (node.kind) { + case SyntaxKind.IfStatement: + // In a branch of an if statement, narrow based on controlling expression + if (child !== (node).expression) { + type = narrowType(type, (node).expression, /*assumeTrue*/ child === (node).thenStatement); + } break; - } - type = narrowedType; + case SyntaxKind.ConditionalExpression: + // In a branch of a conditional expression, narrow based on controlling condition + if (child !== (node).condition) { + type = narrowType(type, (node).condition, /*assumeTrue*/ child === (node).whenTrue); + } + break; + case SyntaxKind.BinaryExpression: + // In the right operand of an && or ||, narrow based on left operand + if (child === (node).right) { + if ((node).operatorToken.kind === SyntaxKind.AmpersandAmpersandToken) { + type = narrowType(type, (node).left, /*assumeTrue*/ true); + } + else if ((node).operatorToken.kind === SyntaxKind.BarBarToken) { + type = narrowType(type, (node).left, /*assumeTrue*/ false); + } + } + break; + default: + Debug.fail("Unreachable!"); + } + + // Use original type if construct contains assignments to variable + if (!nodeStack.length && isVariableAssignedWithin(symbol, node)) { + type = originalType; } } @@ -6365,9 +6377,13 @@ namespace ts { // At this point we can bail if it's not a union if (!(type.flags & TypeFlags.Union)) { // If the active non-union type would be removed from a union by this type guard, return an empty union - return (assumeTrue === !!(type.flags & flags)) ? type : getUnionType(emptyArray); + return filterUnion(type) ? type : getUnionType(emptyArray); + } + return getUnionType(filter((type as UnionType).types, filterUnion), /*noSubtypeReduction*/ true); + + function filterUnion(t: Type) { + return assumeTrue === !!(t.flags & flags); } - return getUnionType(filter((type as UnionType).types, t => assumeTrue === !!(t.flags & flags)), /*noSubtypeReduction*/ true); } function narrowTypeByAnd(type: Type, expr: BinaryExpression, assumeTrue: boolean): Type { diff --git a/tests/baselines/reference/typeGuardTautologicalConsistiency.types b/tests/baselines/reference/typeGuardTautologicalConsistiency.types index 9acb1464761..d758dcde22b 100644 --- a/tests/baselines/reference/typeGuardTautologicalConsistiency.types +++ b/tests/baselines/reference/typeGuardTautologicalConsistiency.types @@ -15,7 +15,7 @@ if (typeof stringOrNumber === "number") { >"number" : string stringOrNumber; ->stringOrNumber : string +>stringOrNumber : string | number } } @@ -31,6 +31,6 @@ if (typeof stringOrNumber === "number" && typeof stringOrNumber !== "number") { >"number" : string stringOrNumber; ->stringOrNumber : number +>stringOrNumber : string | number } From 0d0c05d1d3c4ef94fc15d17b5f2602729539ec8e Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Thu, 29 Oct 2015 18:50:11 -0700 Subject: [PATCH 122/227] that feling when you ctrl-z 1 too many times --- 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 30edecf3b40..8ae8ab3d54c 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -6334,7 +6334,7 @@ namespace ts { } // Use original type if construct contains assignments to variable - if (!nodeStack.length && isVariableAssignedWithin(symbol, node)) { + if (type != originalType && isVariableAssignedWithin(symbol, node)) { type = originalType; } } From 79f09dab4f6ea788c595692b7fa724ea8778abde Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Fri, 30 Oct 2015 09:14:39 -0700 Subject: [PATCH 123/227] Add more detailed error message When an object literal, for example, is returned that does not match the type of the consturctor, add detail about a field that is required but missing. Do this by passing `node.expression` instead of `undefined` -- the rest of the error reporting infrastructure is already in place. --- 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 99b3d97b7be..d1dbc966952 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -12647,7 +12647,7 @@ namespace ts { error(node.expression, Diagnostics.Setters_cannot_return_a_value); } else if (func.kind === SyntaxKind.Constructor) { - if (!isTypeAssignableTo(exprType, returnType)) { + if (!checkTypeAssignableTo(exprType, returnType, node.expression)) { error(node.expression, Diagnostics.Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class); } } From 1b0bc8a496c9677a0bff772a572cb21255b3f3cf Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Fri, 30 Oct 2015 09:21:23 -0700 Subject: [PATCH 124/227] Accept baselines --- .../constructorReturnsInvalidType.errors.txt | 7 ++++- ...rWithAssignableReturnExpression.errors.txt | 14 +++++++++- .../reference/returnInConstructor1.errors.txt | 26 ++++++++++++++++++- .../typeGuardFunctionErrors.errors.txt | 7 ++++- 4 files changed, 50 insertions(+), 4 deletions(-) diff --git a/tests/baselines/reference/constructorReturnsInvalidType.errors.txt b/tests/baselines/reference/constructorReturnsInvalidType.errors.txt index 2ebd59b3d93..a8fe1de4700 100644 --- a/tests/baselines/reference/constructorReturnsInvalidType.errors.txt +++ b/tests/baselines/reference/constructorReturnsInvalidType.errors.txt @@ -1,11 +1,16 @@ +tests/cases/compiler/constructorReturnsInvalidType.ts(3,16): error TS2322: Type 'number' is not assignable to type 'X'. + Property 'foo' is missing in type 'Number'. tests/cases/compiler/constructorReturnsInvalidType.ts(3,16): error TS2409: Return type of constructor signature must be assignable to the instance type of the class -==== tests/cases/compiler/constructorReturnsInvalidType.ts (1 errors) ==== +==== tests/cases/compiler/constructorReturnsInvalidType.ts (2 errors) ==== class X { constructor() { return 1; ~ +!!! error TS2322: Type 'number' is not assignable to type 'X'. +!!! error TS2322: Property 'foo' is missing in type 'Number'. + ~ !!! error TS2409: Return type of constructor signature must be assignable to the instance type of the class } foo() { } diff --git a/tests/baselines/reference/constructorWithAssignableReturnExpression.errors.txt b/tests/baselines/reference/constructorWithAssignableReturnExpression.errors.txt index f5ef669d31b..1f7d7133bd7 100644 --- a/tests/baselines/reference/constructorWithAssignableReturnExpression.errors.txt +++ b/tests/baselines/reference/constructorWithAssignableReturnExpression.errors.txt @@ -1,8 +1,13 @@ +tests/cases/conformance/classes/constructorDeclarations/constructorWithAssignableReturnExpression.ts(12,16): error TS2322: Type 'number' is not assignable to type 'D'. + Property 'x' is missing in type 'Number'. tests/cases/conformance/classes/constructorDeclarations/constructorWithAssignableReturnExpression.ts(12,16): error TS2409: Return type of constructor signature must be assignable to the instance type of the class +tests/cases/conformance/classes/constructorDeclarations/constructorWithAssignableReturnExpression.ts(26,16): error TS2322: Type '{ x: number; }' is not assignable to type 'F'. + Types of property 'x' are incompatible. + Type 'number' is not assignable to type 'T'. tests/cases/conformance/classes/constructorDeclarations/constructorWithAssignableReturnExpression.ts(26,16): error TS2409: Return type of constructor signature must be assignable to the instance type of the class -==== tests/cases/conformance/classes/constructorDeclarations/constructorWithAssignableReturnExpression.ts (2 errors) ==== +==== tests/cases/conformance/classes/constructorDeclarations/constructorWithAssignableReturnExpression.ts (4 errors) ==== // a class constructor may return an expression, it must be assignable to the class instance type to be valid class C { @@ -16,6 +21,9 @@ tests/cases/conformance/classes/constructorDeclarations/constructorWithAssignabl constructor() { return 1; // error ~ +!!! error TS2322: Type 'number' is not assignable to type 'D'. +!!! error TS2322: Property 'x' is missing in type 'Number'. + ~ !!! error TS2409: Return type of constructor signature must be assignable to the instance type of the class } } @@ -32,6 +40,10 @@ tests/cases/conformance/classes/constructorDeclarations/constructorWithAssignabl constructor() { return { x: 1 }; // error ~~~~~~~~ +!!! error TS2322: Type '{ x: number; }' is not assignable to type 'F'. +!!! error TS2322: Types of property 'x' are incompatible. +!!! error TS2322: Type 'number' is not assignable to type 'T'. + ~~~~~~~~ !!! error TS2409: Return type of constructor signature must be assignable to the instance type of the class } } diff --git a/tests/baselines/reference/returnInConstructor1.errors.txt b/tests/baselines/reference/returnInConstructor1.errors.txt index eca0037b4a3..dbe3b9e5ee8 100644 --- a/tests/baselines/reference/returnInConstructor1.errors.txt +++ b/tests/baselines/reference/returnInConstructor1.errors.txt @@ -1,10 +1,20 @@ +tests/cases/compiler/returnInConstructor1.ts(11,16): error TS2322: Type 'number' is not assignable to type 'B'. + Property 'foo' is missing in type 'Number'. tests/cases/compiler/returnInConstructor1.ts(11,16): error TS2409: Return type of constructor signature must be assignable to the instance type of the class +tests/cases/compiler/returnInConstructor1.ts(25,16): error TS2322: Type 'string' is not assignable to type 'D'. + Property 'foo' is missing in type 'String'. tests/cases/compiler/returnInConstructor1.ts(25,16): error TS2409: Return type of constructor signature must be assignable to the instance type of the class +tests/cases/compiler/returnInConstructor1.ts(39,16): error TS2322: Type '{ foo: number; }' is not assignable to type 'F'. + Types of property 'foo' are incompatible. + Type 'number' is not assignable to type 'string'. tests/cases/compiler/returnInConstructor1.ts(39,16): error TS2409: Return type of constructor signature must be assignable to the instance type of the class +tests/cases/compiler/returnInConstructor1.ts(55,16): error TS2322: Type 'G' is not assignable to type 'H'. + Types of property 'foo' are incompatible. + Type '() => void' is not assignable to type 'string'. tests/cases/compiler/returnInConstructor1.ts(55,16): error TS2409: Return type of constructor signature must be assignable to the instance type of the class -==== tests/cases/compiler/returnInConstructor1.ts (4 errors) ==== +==== tests/cases/compiler/returnInConstructor1.ts (8 errors) ==== class A { foo() { } constructor() { @@ -17,6 +27,9 @@ tests/cases/compiler/returnInConstructor1.ts(55,16): error TS2409: Return type o constructor() { return 1; // error ~ +!!! error TS2322: Type 'number' is not assignable to type 'B'. +!!! error TS2322: Property 'foo' is missing in type 'Number'. + ~ !!! error TS2409: Return type of constructor signature must be assignable to the instance type of the class } } @@ -33,6 +46,9 @@ tests/cases/compiler/returnInConstructor1.ts(55,16): error TS2409: Return type o constructor() { return "test"; // error ~~~~~~ +!!! error TS2322: Type 'string' is not assignable to type 'D'. +!!! error TS2322: Property 'foo' is missing in type 'String'. + ~~~~~~ !!! error TS2409: Return type of constructor signature must be assignable to the instance type of the class } } @@ -49,6 +65,10 @@ tests/cases/compiler/returnInConstructor1.ts(55,16): error TS2409: Return type o constructor() { return { foo: 1 }; //error ~~~~~~~~~~ +!!! error TS2322: Type '{ foo: number; }' is not assignable to type 'F'. +!!! error TS2322: Types of property 'foo' are incompatible. +!!! error TS2322: Type 'number' is not assignable to type 'string'. + ~~~~~~~~~~ !!! error TS2409: Return type of constructor signature must be assignable to the instance type of the class } } @@ -67,6 +87,10 @@ tests/cases/compiler/returnInConstructor1.ts(55,16): error TS2409: Return type o super(); return new G(); //error ~~~~~~~ +!!! error TS2322: Type 'G' is not assignable to type 'H'. +!!! error TS2322: Types of property 'foo' are incompatible. +!!! error TS2322: Type '() => void' is not assignable to type 'string'. + ~~~~~~~ !!! error TS2409: Return type of constructor signature must be assignable to the instance type of the class } } diff --git a/tests/baselines/reference/typeGuardFunctionErrors.errors.txt b/tests/baselines/reference/typeGuardFunctionErrors.errors.txt index b178b02c6b4..a1427dc2526 100644 --- a/tests/baselines/reference/typeGuardFunctionErrors.errors.txt +++ b/tests/baselines/reference/typeGuardFunctionErrors.errors.txt @@ -25,6 +25,8 @@ tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(96,9): tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(97,16): error TS1228: A type predicate is only allowed in return type position for functions and methods. tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(98,20): error TS1228: A type predicate is only allowed in return type position for functions and methods. tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(104,25): error TS1228: A type predicate is only allowed in return type position for functions and methods. +tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(105,16): error TS2322: Type 'boolean' is not assignable to type 'D'. + Property 'm1' is missing in type 'Boolean'. tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(105,16): error TS2409: Return type of constructor signature must be assignable to the instance type of the class tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(107,20): error TS1228: A type predicate is only allowed in return type position for functions and methods. tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(110,20): error TS1228: A type predicate is only allowed in return type position for functions and methods. @@ -37,7 +39,7 @@ tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(133,34 tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(137,39): error TS1230: A type predicate cannot reference element 'p1' in a binding pattern. -==== tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts (31 errors) ==== +==== tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts (32 errors) ==== class A { propA: number; @@ -192,6 +194,9 @@ tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(137,39 !!! error TS1228: A type predicate is only allowed in return type position for functions and methods. return true; ~~~~ +!!! error TS2322: Type 'boolean' is not assignable to type 'D'. +!!! error TS2322: Property 'm1' is missing in type 'Boolean'. + ~~~~ !!! error TS2409: Return type of constructor signature must be assignable to the instance type of the class } get m1(p1: A): p1 is C { From 83919f0a3ec1ffad0d101e98833d7db0baa1efec Mon Sep 17 00:00:00 2001 From: Vladimir Matveev Date: Fri, 30 Oct 2015 09:52:14 -0700 Subject: [PATCH 125/227] addressed PR feedback: renamed 'toRelativePath' to 'convertToRelativePath' --- src/compiler/tsc.ts | 2 +- src/compiler/utilities.ts | 2 +- src/harness/projectsRunner.ts | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/compiler/tsc.ts b/src/compiler/tsc.ts index fc6d65b45e9..232360116f3 100644 --- a/src/compiler/tsc.ts +++ b/src/compiler/tsc.ts @@ -87,7 +87,7 @@ namespace ts { if (diagnostic.file) { let loc = getLineAndCharacterOfPosition(diagnostic.file, diagnostic.start); const relativeFileName = host - ? toRelativePath(diagnostic.file.fileName, host.getCurrentDirectory(), fileName => host.getCanonicalFileName(fileName)) + ? convertToRelativePath(diagnostic.file.fileName, host.getCurrentDirectory(), fileName => host.getCanonicalFileName(fileName)) : diagnostic.file.fileName; output += `${ relativeFileName }(${ loc.line + 1 },${ loc.character + 1 }): `; diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index fb6d2686b15..fd991039d3e 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -2182,7 +2182,7 @@ namespace ts { return result; } - export function toRelativePath(absoluteOrRelativePath: string, basePath: string, getCanonicalFileName: (path: string) => string): string { + export function convertToRelativePath(absoluteOrRelativePath: string, basePath: string, getCanonicalFileName: (path: string) => string): string { return !isRootedDiskPath(absoluteOrRelativePath) ? absoluteOrRelativePath : getRelativePathToDirectoryOrUrl(basePath, absoluteOrRelativePath, basePath, getCanonicalFileName, /* isAbsolutePathAnUrl */ false); diff --git a/src/harness/projectsRunner.ts b/src/harness/projectsRunner.ts index 52d4b85f6b8..e587aad3ddb 100644 --- a/src/harness/projectsRunner.ts +++ b/src/harness/projectsRunner.ts @@ -377,10 +377,10 @@ class ProjectRunner extends RunnerBase { bug: testCase.bug, rootDir: testCase.rootDir, resolvedInputFiles: ts.map(compilerResult.program.getSourceFiles(), inputFile => { - return ts.toRelativePath(inputFile.fileName, getCurrentDirectory(), path => Harness.Compiler.getCanonicalFileName(path)); + return ts.convertToRelativePath(inputFile.fileName, getCurrentDirectory(), path => Harness.Compiler.getCanonicalFileName(path)); }), emittedFiles: ts.map(compilerResult.outputFiles, outputFile => { - return ts.toRelativePath(outputFile.emittedFileName, getCurrentDirectory(), path => Harness.Compiler.getCanonicalFileName(path)); + return ts.convertToRelativePath(outputFile.emittedFileName, getCurrentDirectory(), path => Harness.Compiler.getCanonicalFileName(path)); }) }; From c82d4a61e39d3ba5fc42618dda92c2375a706b85 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Fri, 30 Oct 2015 14:01:06 -0700 Subject: [PATCH 126/227] Forbid 'this' as constructor parameter type --- src/compiler/checker.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index d1dbc966952..a1207d023c7 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -4420,12 +4420,19 @@ namespace ts { let container = getThisContainer(node, /*includeArrowFunctions*/ false); let parent = container && container.parent; if (parent && (isClassLike(parent) || parent.kind === SyntaxKind.InterfaceDeclaration)) { - if (!(container.flags & NodeFlags.Static)) { + if (!(container.flags & NodeFlags.Static) && !isConstructorParameter(node, container)) { return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(parent)).thisType; } } error(node, Diagnostics.A_this_type_is_available_only_in_a_non_static_member_of_a_class_or_interface); return unknownType; + + function isConstructorParameter(node: TypeNode, container: Node) { + if (container.kind === SyntaxKind.Constructor) { + let ctor = (container); + return !ctor.body.statements.some(st => st === node.parent); + } + } } function getTypeFromThisTypeNode(node: TypeNode): Type { From e609047b786f051aa8dd90e8823b516a41894c36 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Fri, 30 Oct 2015 14:02:07 -0700 Subject: [PATCH 127/227] Add tests based on #5449 --- .../reference/thisTypeErrors2.errors.txt | 22 +++++++++++++ tests/baselines/reference/thisTypeErrors2.js | 33 +++++++++++++++++++ .../types/thisType/thisTypeErrors2.ts | 12 +++++++ 3 files changed, 67 insertions(+) create mode 100644 tests/baselines/reference/thisTypeErrors2.errors.txt create mode 100644 tests/baselines/reference/thisTypeErrors2.js create mode 100644 tests/cases/conformance/types/thisType/thisTypeErrors2.ts diff --git a/tests/baselines/reference/thisTypeErrors2.errors.txt b/tests/baselines/reference/thisTypeErrors2.errors.txt new file mode 100644 index 00000000000..cdb49b877df --- /dev/null +++ b/tests/baselines/reference/thisTypeErrors2.errors.txt @@ -0,0 +1,22 @@ +tests/cases/conformance/types/thisType/thisTypeErrors2.ts(2,20): error TS2526: A 'this' type is available only in a non-static member of a class or interface. +tests/cases/conformance/types/thisType/thisTypeErrors2.ts(9,38): error TS2526: A 'this' type is available only in a non-static member of a class or interface. + + +==== tests/cases/conformance/types/thisType/thisTypeErrors2.ts (2 errors) ==== + class Base { + constructor(a: this) { + ~~~~ +!!! error TS2526: A 'this' type is available only in a non-static member of a class or interface. + } + } + class Generic { + } + class Derived { + n: number; + constructor(public host: Generic) { + ~~~~ +!!! error TS2526: A 'this' type is available only in a non-static member of a class or interface. + this.n = 12; + } + } + \ No newline at end of file diff --git a/tests/baselines/reference/thisTypeErrors2.js b/tests/baselines/reference/thisTypeErrors2.js new file mode 100644 index 00000000000..476e2039996 --- /dev/null +++ b/tests/baselines/reference/thisTypeErrors2.js @@ -0,0 +1,33 @@ +//// [thisTypeErrors2.ts] +class Base { + constructor(a: this) { + } +} +class Generic { +} +class Derived { + n: number; + constructor(public host: Generic) { + this.n = 12; + } +} + + +//// [thisTypeErrors2.js] +var Base = (function () { + function Base(a) { + } + return Base; +})(); +var Generic = (function () { + function Generic() { + } + return Generic; +})(); +var Derived = (function () { + function Derived(host) { + this.host = host; + this.n = 12; + } + return Derived; +})(); diff --git a/tests/cases/conformance/types/thisType/thisTypeErrors2.ts b/tests/cases/conformance/types/thisType/thisTypeErrors2.ts new file mode 100644 index 00000000000..b30a554bd88 --- /dev/null +++ b/tests/cases/conformance/types/thisType/thisTypeErrors2.ts @@ -0,0 +1,12 @@ +class Base { + constructor(a: this) { + } +} +class Generic { +} +class Derived { + n: number; + constructor(public host: Generic) { + this.n = 12; + } +} From 84b894769e33aad84d2bbff209c73db6aa39ab3d Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Fri, 30 Oct 2015 14:19:11 -0700 Subject: [PATCH 128/227] Accept baselines --- .../reference/declarationFiles.errors.txt | 5 +- .../reference/thisTypeInClasses.errors.txt | 57 +++++++++++++++++++ 2 files changed, 61 insertions(+), 1 deletion(-) create mode 100644 tests/baselines/reference/thisTypeInClasses.errors.txt diff --git a/tests/baselines/reference/declarationFiles.errors.txt b/tests/baselines/reference/declarationFiles.errors.txt index c55cac9000b..bbd65b6d658 100644 --- a/tests/baselines/reference/declarationFiles.errors.txt +++ b/tests/baselines/reference/declarationFiles.errors.txt @@ -1,15 +1,18 @@ +tests/cases/conformance/types/thisType/declarationFiles.ts(5,20): error TS2526: A 'this' type is available only in a non-static member of a class or interface. tests/cases/conformance/types/thisType/declarationFiles.ts(31,5): error TS2527: The inferred type of 'x1' references an inaccessible 'this' type. A type annotation is necessary. tests/cases/conformance/types/thisType/declarationFiles.ts(33,5): error TS2527: The inferred type of 'x3' references an inaccessible 'this' type. A type annotation is necessary. tests/cases/conformance/types/thisType/declarationFiles.ts(35,5): error TS2527: The inferred type of 'f1' references an inaccessible 'this' type. A type annotation is necessary. tests/cases/conformance/types/thisType/declarationFiles.ts(41,5): error TS2527: The inferred type of 'f3' references an inaccessible 'this' type. A type annotation is necessary. -==== tests/cases/conformance/types/thisType/declarationFiles.ts (4 errors) ==== +==== tests/cases/conformance/types/thisType/declarationFiles.ts (5 errors) ==== class C1 { x: this; f(x: this): this { return undefined; } constructor(x: this) { } + ~~~~ +!!! error TS2526: A 'this' type is available only in a non-static member of a class or interface. } class C2 { diff --git a/tests/baselines/reference/thisTypeInClasses.errors.txt b/tests/baselines/reference/thisTypeInClasses.errors.txt new file mode 100644 index 00000000000..db2ae1b5793 --- /dev/null +++ b/tests/baselines/reference/thisTypeInClasses.errors.txt @@ -0,0 +1,57 @@ +tests/cases/conformance/types/thisType/thisTypeInClasses.ts(4,20): error TS2526: A 'this' type is available only in a non-static member of a class or interface. + + +==== tests/cases/conformance/types/thisType/thisTypeInClasses.ts (1 errors) ==== + class C1 { + x: this; + f(x: this): this { return undefined; } + constructor(x: this) { } + ~~~~ +!!! error TS2526: A 'this' type is available only in a non-static member of a class or interface. + } + + class C2 { + [x: string]: this; + } + + interface Foo { + x: T; + y: this; + } + + class C3 { + a: this[]; + b: [this, this]; + c: this | Date; + d: this & Date; + e: (((this))); + f: (x: this) => this; + g: new (x: this) => this; + h: Foo; + i: Foo this)>; + j: (x: any) => x is this; + } + + declare class C4 { + x: this; + f(x: this): this; + } + + class C5 { + foo() { + let f1 = (x: this): this => this; + let f2 = (x: this) => this; + let f3 = (x: this) => (y: this) => this; + let f4 = (x: this) => { + let g = (y: this) => { + return () => this; + } + return g(this); + } + } + bar() { + let x1 = undefined; + let x2 = undefined as this; + } + } + \ No newline at end of file From 95a3fc71435518645163344955fdef69bbf70f07 Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Fri, 30 Oct 2015 14:52:45 -0700 Subject: [PATCH 129/227] feedback form pr, new baselines --- src/compiler/emitter.ts | 52 +- src/compiler/program.ts | 2 +- src/harness/harness.ts | 2 +- src/harness/projectsRunner.ts | 5 +- .../baselines/reference/isolatedModulesOut.js | 2 - .../baselines/reference/outModuleConcatAmd.js | 34 +- .../reference/outModuleConcatAmd.js.map | 4 +- .../outModuleConcatAmd.sourcemap.txt | 169 ----- .../reference/outModuleConcatCommonjs.js | 32 +- .../reference/outModuleConcatCommonjs.js.map | 4 +- .../outModuleConcatCommonjs.sourcemap.txt | 194 ------ .../baselines/reference/outModuleConcatES6.js | 17 +- .../reference/outModuleConcatES6.js.map | 4 +- .../outModuleConcatES6.sourcemap.txt | 97 --- .../reference/outModuleConcatSystem.js | 50 +- .../reference/outModuleConcatSystem.js.map | 4 +- .../outModuleConcatSystem.sourcemap.txt | 179 ----- .../baselines/reference/outModuleConcatUmd.js | 50 +- .../reference/outModuleConcatUmd.js.map | 4 +- .../outModuleConcatUmd.sourcemap.txt | 211 ------ .../reference/outModuleTripleSlashRefs.js | 37 +- .../reference/outModuleTripleSlashRefs.js.map | 4 +- .../outModuleTripleSlashRefs.sourcemap.txt | 184 ------ ...tePathMixedSubfolderSpecifyOutputFile.json | 3 - ...edSubfolderSpecifyOutputFile.sourcemap.txt | 172 ----- .../amd/ref/m2.d.ts | 6 - .../amd/ref/m2.js | 15 - .../amd/ref/m2.js.map | 1 - ...tePathMixedSubfolderSpecifyOutputFile.json | 3 - ...edSubfolderSpecifyOutputFile.sourcemap.txt | 171 ----- .../node/ref/m2.d.ts | 6 - .../node/ref/m2.js | 13 - .../node/ref/m2.js.map | 1 - ...erSpecifyOutputFileAndOutputDirectory.json | 3 - ...OutputFileAndOutputDirectory.sourcemap.txt | 172 ----- .../amd/outdir/outAndOutDirFolder/ref/m2.d.ts | 6 - .../amd/outdir/outAndOutDirFolder/ref/m2.js | 15 - .../outdir/outAndOutDirFolder/ref/m2.js.map | 1 - ...erSpecifyOutputFileAndOutputDirectory.json | 3 - ...OutputFileAndOutputDirectory.sourcemap.txt | 171 ----- .../outdir/outAndOutDirFolder/ref/m2.d.ts | 6 - .../node/outdir/outAndOutDirFolder/ref/m2.js | 13 - .../outdir/outAndOutDirFolder/ref/m2.js.map | 1 - .../amd/diskFile0.js.map | 1 - .../amd/diskFile1.js | 15 - .../amd/diskFile2.d.ts | 6 - ...athModuleMultifolderSpecifyOutputFile.json | 9 - ...MultifolderSpecifyOutputFile.sourcemap.txt | 569 ---------------- .../amd/ref/m1.d.ts | 6 - .../amd/ref/m1.js | 15 - .../amd/ref/m1.js.map | 1 - .../amd/test.d.ts | 10 - .../amd/test.js | 17 - .../amd/test.js.map | 1 - .../node/diskFile0.js.map | 1 - .../node/diskFile1.js | 13 - .../node/diskFile2.d.ts | 6 - ...athModuleMultifolderSpecifyOutputFile.json | 9 - ...MultifolderSpecifyOutputFile.sourcemap.txt | 613 ------------------ .../node/ref/m1.d.ts | 6 - .../node/ref/m1.js | 13 - .../node/ref/m1.js.map | 1 - .../node/test.d.ts | 10 - .../node/test.js | 17 - .../node/test.js.map | 1 - .../amd/m1.d.ts | 6 - .../amd/m1.js | 15 - .../amd/m1.js.map | 1 - ...lutePathModuleSimpleSpecifyOutputFile.json | 6 - ...oduleSimpleSpecifyOutputFile.sourcemap.txt | 371 ----------- .../amd/test.d.ts | 8 - .../amd/test.js | 16 - .../amd/test.js.map | 1 - .../node/m1.d.ts | 6 - .../node/m1.js | 13 - .../node/m1.js.map | 1 - ...lutePathModuleSimpleSpecifyOutputFile.json | 6 - ...oduleSimpleSpecifyOutputFile.sourcemap.txt | 392 ----------- .../node/test.d.ts | 8 - .../node/test.js | 15 - .../node/test.js.map | 1 - ...ePathModuleSubfolderSpecifyOutputFile.json | 6 - ...leSubfolderSpecifyOutputFile.sourcemap.txt | 371 ----------- .../amd/ref/m1.d.ts | 6 - .../amd/ref/m1.js | 15 - .../amd/ref/m1.js.map | 1 - .../amd/test.d.ts | 8 - .../amd/test.js | 16 - .../amd/test.js.map | 1 - ...ePathModuleSubfolderSpecifyOutputFile.json | 6 - ...leSubfolderSpecifyOutputFile.sourcemap.txt | 392 ----------- .../node/ref/m1.d.ts | 6 - .../node/ref/m1.js | 13 - .../node/ref/m1.js.map | 1 - .../node/test.d.ts | 8 - .../node/test.js | 15 - .../node/test.js.map | 1 - ...vePathMixedSubfolderSpecifyOutputFile.json | 3 - ...edSubfolderSpecifyOutputFile.sourcemap.txt | 172 ----- .../amd/ref/m2.d.ts | 6 - .../amd/ref/m2.js | 15 - .../amd/ref/m2.js.map | 1 - ...vePathMixedSubfolderSpecifyOutputFile.json | 3 - ...edSubfolderSpecifyOutputFile.sourcemap.txt | 171 ----- .../node/ref/m2.d.ts | 6 - .../node/ref/m2.js | 13 - .../node/ref/m2.js.map | 1 - ...erSpecifyOutputFileAndOutputDirectory.json | 3 - ...OutputFileAndOutputDirectory.sourcemap.txt | 172 ----- .../amd/outdir/outAndOutDirFolder/ref/m2.d.ts | 6 - .../amd/outdir/outAndOutDirFolder/ref/m2.js | 15 - .../outdir/outAndOutDirFolder/ref/m2.js.map | 1 - ...erSpecifyOutputFileAndOutputDirectory.json | 3 - ...OutputFileAndOutputDirectory.sourcemap.txt | 171 ----- .../outdir/outAndOutDirFolder/ref/m2.d.ts | 6 - .../node/outdir/outAndOutDirFolder/ref/m2.js | 13 - .../outdir/outAndOutDirFolder/ref/m2.js.map | 1 - .../amd/diskFile0.js.map | 1 - .../amd/diskFile1.js | 15 - .../amd/diskFile2.d.ts | 6 - ...athModuleMultifolderSpecifyOutputFile.json | 9 - ...MultifolderSpecifyOutputFile.sourcemap.txt | 569 ---------------- .../amd/ref/m1.d.ts | 6 - .../amd/ref/m1.js | 15 - .../amd/ref/m1.js.map | 1 - .../amd/test.d.ts | 10 - .../amd/test.js | 17 - .../amd/test.js.map | 1 - .../node/diskFile0.js.map | 1 - .../node/diskFile1.js | 13 - .../node/diskFile2.d.ts | 6 - ...athModuleMultifolderSpecifyOutputFile.json | 9 - ...MultifolderSpecifyOutputFile.sourcemap.txt | 613 ------------------ .../node/ref/m1.d.ts | 6 - .../node/ref/m1.js | 13 - .../node/ref/m1.js.map | 1 - .../node/test.d.ts | 10 - .../node/test.js | 17 - .../node/test.js.map | 1 - .../amd/m1.d.ts | 6 - .../amd/m1.js | 15 - .../amd/m1.js.map | 1 - ...tivePathModuleSimpleSpecifyOutputFile.json | 6 - ...oduleSimpleSpecifyOutputFile.sourcemap.txt | 371 ----------- .../amd/test.d.ts | 8 - .../amd/test.js | 16 - .../amd/test.js.map | 1 - .../node/m1.d.ts | 6 - .../node/m1.js | 13 - .../node/m1.js.map | 1 - ...tivePathModuleSimpleSpecifyOutputFile.json | 6 - ...oduleSimpleSpecifyOutputFile.sourcemap.txt | 392 ----------- .../node/test.d.ts | 8 - .../node/test.js | 15 - .../node/test.js.map | 1 - ...ePathModuleSubfolderSpecifyOutputFile.json | 6 - ...leSubfolderSpecifyOutputFile.sourcemap.txt | 371 ----------- .../amd/ref/m1.d.ts | 6 - .../amd/ref/m1.js | 15 - .../amd/ref/m1.js.map | 1 - .../amd/test.d.ts | 8 - .../amd/test.js | 16 - .../amd/test.js.map | 1 - ...ePathModuleSubfolderSpecifyOutputFile.json | 6 - ...leSubfolderSpecifyOutputFile.sourcemap.txt | 392 ----------- .../node/ref/m1.d.ts | 6 - .../node/ref/m1.js | 13 - .../node/ref/m1.js.map | 1 - .../node/test.d.ts | 8 - .../node/test.js | 15 - .../node/test.js.map | 1 - ...ootUrlMixedSubfolderSpecifyOutputFile.json | 3 - ...edSubfolderSpecifyOutputFile.sourcemap.txt | 172 ----- .../amd/ref/m2.d.ts | 6 - .../amd/ref/m2.js | 15 - .../amd/ref/m2.js.map | 1 - ...ootUrlMixedSubfolderSpecifyOutputFile.json | 3 - ...edSubfolderSpecifyOutputFile.sourcemap.txt | 171 ----- .../node/ref/m2.d.ts | 6 - .../node/ref/m2.js | 13 - .../node/ref/m2.js.map | 1 - ...erSpecifyOutputFileAndOutputDirectory.json | 3 - ...OutputFileAndOutputDirectory.sourcemap.txt | 172 ----- .../amd/outdir/outAndOutDirFolder/ref/m2.d.ts | 6 - .../amd/outdir/outAndOutDirFolder/ref/m2.js | 15 - .../outdir/outAndOutDirFolder/ref/m2.js.map | 1 - ...erSpecifyOutputFileAndOutputDirectory.json | 3 - ...OutputFileAndOutputDirectory.sourcemap.txt | 171 ----- .../outdir/outAndOutDirFolder/ref/m2.d.ts | 6 - .../node/outdir/outAndOutDirFolder/ref/m2.js | 13 - .../outdir/outAndOutDirFolder/ref/m2.js.map | 1 - .../amd/diskFile0.js.map | 1 - .../amd/diskFile1.js | 15 - .../amd/diskFile2.d.ts | 6 - ...UrlModuleMultifolderSpecifyOutputFile.json | 9 - ...MultifolderSpecifyOutputFile.sourcemap.txt | 569 ---------------- .../amd/ref/m1.d.ts | 6 - .../amd/ref/m1.js | 15 - .../amd/ref/m1.js.map | 1 - .../amd/test.d.ts | 10 - .../amd/test.js | 17 - .../amd/test.js.map | 1 - .../node/diskFile0.js.map | 1 - .../node/diskFile1.js | 13 - .../node/diskFile2.d.ts | 6 - ...UrlModuleMultifolderSpecifyOutputFile.json | 9 - ...MultifolderSpecifyOutputFile.sourcemap.txt | 613 ------------------ .../node/ref/m1.d.ts | 6 - .../node/ref/m1.js | 13 - .../node/ref/m1.js.map | 1 - .../node/test.d.ts | 10 - .../node/test.js | 17 - .../node/test.js.map | 1 - .../amd/m1.d.ts | 6 - .../amd/m1.js | 15 - .../amd/m1.js.map | 1 - ...prootUrlModuleSimpleSpecifyOutputFile.json | 6 - ...oduleSimpleSpecifyOutputFile.sourcemap.txt | 371 ----------- .../amd/test.d.ts | 8 - .../amd/test.js | 16 - .../amd/test.js.map | 1 - .../node/m1.d.ts | 6 - .../node/m1.js | 13 - .../node/m1.js.map | 1 - ...prootUrlModuleSimpleSpecifyOutputFile.json | 6 - ...oduleSimpleSpecifyOutputFile.sourcemap.txt | 392 ----------- .../node/test.d.ts | 8 - .../node/test.js | 15 - .../node/test.js.map | 1 - ...otUrlModuleSubfolderSpecifyOutputFile.json | 6 - ...leSubfolderSpecifyOutputFile.sourcemap.txt | 371 ----------- .../amd/ref/m1.d.ts | 6 - .../amd/ref/m1.js | 15 - .../amd/ref/m1.js.map | 1 - .../amd/test.d.ts | 8 - .../amd/test.js | 16 - .../amd/test.js.map | 1 - ...otUrlModuleSubfolderSpecifyOutputFile.json | 6 - ...leSubfolderSpecifyOutputFile.sourcemap.txt | 392 ----------- .../node/ref/m1.d.ts | 6 - .../node/ref/m1.js | 13 - .../node/ref/m1.js.map | 1 - .../node/test.d.ts | 8 - .../node/test.js | 15 - .../node/test.js.map | 1 - ...ootUrlMixedSubfolderSpecifyOutputFile.json | 3 - ...edSubfolderSpecifyOutputFile.sourcemap.txt | 172 ----- .../amd/ref/m2.d.ts | 6 - .../amd/ref/m2.js | 15 - .../amd/ref/m2.js.map | 1 - ...ootUrlMixedSubfolderSpecifyOutputFile.json | 3 - ...edSubfolderSpecifyOutputFile.sourcemap.txt | 171 ----- .../node/ref/m2.d.ts | 6 - .../node/ref/m2.js | 13 - .../node/ref/m2.js.map | 1 - ...erSpecifyOutputFileAndOutputDirectory.json | 3 - ...OutputFileAndOutputDirectory.sourcemap.txt | 172 ----- .../amd/outdir/outAndOutDirFolder/ref/m2.d.ts | 6 - .../amd/outdir/outAndOutDirFolder/ref/m2.js | 15 - .../outdir/outAndOutDirFolder/ref/m2.js.map | 1 - ...erSpecifyOutputFileAndOutputDirectory.json | 3 - ...OutputFileAndOutputDirectory.sourcemap.txt | 171 ----- .../outdir/outAndOutDirFolder/ref/m2.d.ts | 6 - .../node/outdir/outAndOutDirFolder/ref/m2.js | 13 - .../outdir/outAndOutDirFolder/ref/m2.js.map | 1 - .../amd/diskFile0.js.map | 1 - .../amd/diskFile1.js | 15 - .../amd/diskFile2.d.ts | 6 - ...UrlModuleMultifolderSpecifyOutputFile.json | 9 - ...MultifolderSpecifyOutputFile.sourcemap.txt | 569 ---------------- .../amd/ref/m1.d.ts | 6 - .../amd/ref/m1.js | 15 - .../amd/ref/m1.js.map | 1 - .../amd/test.d.ts | 10 - .../amd/test.js | 17 - .../amd/test.js.map | 1 - .../node/diskFile0.js.map | 1 - .../node/diskFile1.js | 13 - .../node/diskFile2.d.ts | 6 - ...UrlModuleMultifolderSpecifyOutputFile.json | 9 - ...MultifolderSpecifyOutputFile.sourcemap.txt | 613 ------------------ .../node/ref/m1.d.ts | 6 - .../node/ref/m1.js | 13 - .../node/ref/m1.js.map | 1 - .../node/test.d.ts | 10 - .../node/test.js | 17 - .../node/test.js.map | 1 - .../amd/m1.d.ts | 6 - .../amd/m1.js | 15 - .../amd/m1.js.map | 1 - ...erootUrlModuleSimpleSpecifyOutputFile.json | 6 - ...oduleSimpleSpecifyOutputFile.sourcemap.txt | 371 ----------- .../amd/test.d.ts | 8 - .../amd/test.js | 16 - .../amd/test.js.map | 1 - .../node/m1.d.ts | 6 - .../node/m1.js | 13 - .../node/m1.js.map | 1 - ...erootUrlModuleSimpleSpecifyOutputFile.json | 6 - ...oduleSimpleSpecifyOutputFile.sourcemap.txt | 392 ----------- .../node/test.d.ts | 8 - .../node/test.js | 15 - .../node/test.js.map | 1 - ...otUrlModuleSubfolderSpecifyOutputFile.json | 6 - ...leSubfolderSpecifyOutputFile.sourcemap.txt | 371 ----------- .../amd/ref/m1.d.ts | 6 - .../amd/ref/m1.js | 15 - .../amd/ref/m1.js.map | 1 - .../amd/test.d.ts | 8 - .../amd/test.js | 16 - .../amd/test.js.map | 1 - ...otUrlModuleSubfolderSpecifyOutputFile.json | 6 - ...leSubfolderSpecifyOutputFile.sourcemap.txt | 392 ----------- .../node/ref/m1.d.ts | 6 - .../node/ref/m1.js | 13 - .../node/ref/m1.js.map | 1 - .../node/test.d.ts | 8 - .../node/test.js | 15 - .../node/test.js.map | 1 - .../outMixedSubfolderSpecifyOutputFile.json | 2 - .../amd/ref/m2.d.ts | 6 - .../amd/ref/m2.js | 14 - .../outMixedSubfolderSpecifyOutputFile.json | 2 - .../node/ref/m2.d.ts | 6 - .../node/ref/m2.js | 12 - ...erSpecifyOutputFileAndOutputDirectory.json | 2 - .../amd/outdir/outAndOutDirFolder/ref/m2.d.ts | 6 - .../amd/outdir/outAndOutDirFolder/ref/m2.js | 14 - ...erSpecifyOutputFileAndOutputDirectory.json | 2 - .../outdir/outAndOutDirFolder/ref/m2.d.ts | 6 - .../node/outdir/outAndOutDirFolder/ref/m2.js | 12 - .../amd/diskFile0.js | 14 - .../amd/diskFile1.d.ts | 6 - ...outModuleMultifolderSpecifyOutputFile.json | 6 - .../amd/ref/m1.d.ts | 6 - .../amd/ref/m1.js | 14 - .../amd/test.d.ts | 10 - .../amd/test.js | 16 - .../node/diskFile0.js | 12 - .../node/diskFile1.d.ts | 6 - ...outModuleMultifolderSpecifyOutputFile.json | 6 - .../node/ref/m1.d.ts | 6 - .../node/ref/m1.js | 12 - .../node/test.d.ts | 10 - .../node/test.js | 16 - .../amd/m1.d.ts | 6 - .../amd/m1.js | 14 - .../amd/outModuleSimpleSpecifyOutputFile.json | 4 - .../amd/test.d.ts | 8 - .../amd/test.js | 15 - .../node/m1.d.ts | 6 - .../node/m1.js | 12 - .../outModuleSimpleSpecifyOutputFile.json | 4 - .../node/test.d.ts | 8 - .../node/test.js | 14 - .../outModuleSubfolderSpecifyOutputFile.json | 4 - .../amd/ref/m1.d.ts | 6 - .../amd/ref/m1.js | 14 - .../amd/test.d.ts | 8 - .../amd/test.js | 15 - .../outModuleSubfolderSpecifyOutputFile.json | 4 - .../node/ref/m1.d.ts | 6 - .../node/ref/m1.js | 12 - .../node/test.d.ts | 8 - .../node/test.js | 14 - .../amd/ref/m2.d.ts | 6 - .../amd/ref/m2.js | 15 - .../amd/ref/m2.js.map | 1 - ...tePathMixedSubfolderSpecifyOutputFile.json | 3 - ...edSubfolderSpecifyOutputFile.sourcemap.txt | 172 ----- .../node/ref/m2.d.ts | 6 - .../node/ref/m2.js | 13 - .../node/ref/m2.js.map | 1 - ...tePathMixedSubfolderSpecifyOutputFile.json | 3 - ...edSubfolderSpecifyOutputFile.sourcemap.txt | 171 ----- .../amd/outdir/outAndOutDirFolder/ref/m2.d.ts | 6 - .../amd/outdir/outAndOutDirFolder/ref/m2.js | 15 - .../outdir/outAndOutDirFolder/ref/m2.js.map | 1 - ...erSpecifyOutputFileAndOutputDirectory.json | 3 - ...OutputFileAndOutputDirectory.sourcemap.txt | 172 ----- .../outdir/outAndOutDirFolder/ref/m2.d.ts | 6 - .../node/outdir/outAndOutDirFolder/ref/m2.js | 13 - .../outdir/outAndOutDirFolder/ref/m2.js.map | 1 - ...erSpecifyOutputFileAndOutputDirectory.json | 3 - ...OutputFileAndOutputDirectory.sourcemap.txt | 171 ----- .../amd/diskFile0.js.map | 1 - .../amd/diskFile1.js | 15 - .../amd/diskFile2.d.ts | 6 - .../amd/ref/m1.d.ts | 6 - .../amd/ref/m1.js | 15 - .../amd/ref/m1.js.map | 1 - ...athModuleMultifolderSpecifyOutputFile.json | 9 - ...MultifolderSpecifyOutputFile.sourcemap.txt | 569 ---------------- .../amd/test.d.ts | 10 - .../amd/test.js | 17 - .../amd/test.js.map | 1 - .../node/diskFile0.js.map | 1 - .../node/diskFile1.js | 13 - .../node/diskFile2.d.ts | 6 - .../node/ref/m1.d.ts | 6 - .../node/ref/m1.js | 13 - .../node/ref/m1.js.map | 1 - ...athModuleMultifolderSpecifyOutputFile.json | 9 - ...MultifolderSpecifyOutputFile.sourcemap.txt | 613 ------------------ .../node/test.d.ts | 10 - .../node/test.js | 17 - .../node/test.js.map | 1 - .../amd/m1.d.ts | 6 - .../amd/m1.js | 15 - .../amd/m1.js.map | 1 - ...lutePathModuleSimpleSpecifyOutputFile.json | 6 - ...oduleSimpleSpecifyOutputFile.sourcemap.txt | 371 ----------- .../amd/test.d.ts | 8 - .../amd/test.js | 16 - .../amd/test.js.map | 1 - .../node/m1.d.ts | 6 - .../node/m1.js | 13 - .../node/m1.js.map | 1 - ...lutePathModuleSimpleSpecifyOutputFile.json | 6 - ...oduleSimpleSpecifyOutputFile.sourcemap.txt | 392 ----------- .../node/test.d.ts | 8 - .../node/test.js | 15 - .../node/test.js.map | 1 - .../amd/ref/m1.d.ts | 6 - .../amd/ref/m1.js | 15 - .../amd/ref/m1.js.map | 1 - ...ePathModuleSubfolderSpecifyOutputFile.json | 6 - ...leSubfolderSpecifyOutputFile.sourcemap.txt | 371 ----------- .../amd/test.d.ts | 8 - .../amd/test.js | 16 - .../amd/test.js.map | 1 - .../node/ref/m1.d.ts | 6 - .../node/ref/m1.js | 13 - .../node/ref/m1.js.map | 1 - ...ePathModuleSubfolderSpecifyOutputFile.json | 6 - ...leSubfolderSpecifyOutputFile.sourcemap.txt | 392 ----------- .../node/test.d.ts | 8 - .../node/test.js | 15 - .../node/test.js.map | 1 - .../amd/ref/m2.d.ts | 6 - .../amd/ref/m2.js | 15 - .../amd/ref/m2.js.map | 1 - ...vePathMixedSubfolderSpecifyOutputFile.json | 3 - ...edSubfolderSpecifyOutputFile.sourcemap.txt | 172 ----- .../node/ref/m2.d.ts | 6 - .../node/ref/m2.js | 13 - .../node/ref/m2.js.map | 1 - ...vePathMixedSubfolderSpecifyOutputFile.json | 3 - ...edSubfolderSpecifyOutputFile.sourcemap.txt | 171 ----- .../amd/outdir/outAndOutDirFolder/ref/m2.d.ts | 6 - .../amd/outdir/outAndOutDirFolder/ref/m2.js | 15 - .../outdir/outAndOutDirFolder/ref/m2.js.map | 1 - ...erSpecifyOutputFileAndOutputDirectory.json | 3 - ...OutputFileAndOutputDirectory.sourcemap.txt | 172 ----- .../outdir/outAndOutDirFolder/ref/m2.d.ts | 6 - .../node/outdir/outAndOutDirFolder/ref/m2.js | 13 - .../outdir/outAndOutDirFolder/ref/m2.js.map | 1 - ...erSpecifyOutputFileAndOutputDirectory.json | 3 - ...OutputFileAndOutputDirectory.sourcemap.txt | 171 ----- .../amd/diskFile0.js.map | 1 - .../amd/diskFile1.js | 15 - .../amd/diskFile2.d.ts | 6 - .../amd/ref/m1.d.ts | 6 - .../amd/ref/m1.js | 15 - .../amd/ref/m1.js.map | 1 - ...athModuleMultifolderSpecifyOutputFile.json | 9 - ...MultifolderSpecifyOutputFile.sourcemap.txt | 569 ---------------- .../amd/test.d.ts | 10 - .../amd/test.js | 17 - .../amd/test.js.map | 1 - .../node/diskFile0.js.map | 1 - .../node/diskFile1.js | 13 - .../node/diskFile2.d.ts | 6 - .../node/ref/m1.d.ts | 6 - .../node/ref/m1.js | 13 - .../node/ref/m1.js.map | 1 - ...athModuleMultifolderSpecifyOutputFile.json | 9 - ...MultifolderSpecifyOutputFile.sourcemap.txt | 613 ------------------ .../node/test.d.ts | 10 - .../node/test.js | 17 - .../node/test.js.map | 1 - .../amd/m1.d.ts | 6 - .../amd/m1.js | 15 - .../amd/m1.js.map | 1 - ...tivePathModuleSimpleSpecifyOutputFile.json | 6 - ...oduleSimpleSpecifyOutputFile.sourcemap.txt | 371 ----------- .../amd/test.d.ts | 8 - .../amd/test.js | 16 - .../amd/test.js.map | 1 - .../node/m1.d.ts | 6 - .../node/m1.js | 13 - .../node/m1.js.map | 1 - ...tivePathModuleSimpleSpecifyOutputFile.json | 6 - ...oduleSimpleSpecifyOutputFile.sourcemap.txt | 392 ----------- .../node/test.d.ts | 8 - .../node/test.js | 15 - .../node/test.js.map | 1 - .../amd/ref/m1.d.ts | 6 - .../amd/ref/m1.js | 15 - .../amd/ref/m1.js.map | 1 - ...ePathModuleSubfolderSpecifyOutputFile.json | 6 - ...leSubfolderSpecifyOutputFile.sourcemap.txt | 371 ----------- .../amd/test.d.ts | 8 - .../amd/test.js | 16 - .../amd/test.js.map | 1 - .../node/ref/m1.d.ts | 6 - .../node/ref/m1.js | 13 - .../node/ref/m1.js.map | 1 - ...ePathModuleSubfolderSpecifyOutputFile.json | 6 - ...leSubfolderSpecifyOutputFile.sourcemap.txt | 392 ----------- .../node/test.d.ts | 8 - .../node/test.js | 15 - .../node/test.js.map | 1 - .../amd/ref/m2.d.ts | 6 - .../amd/ref/m2.js | 15 - .../amd/ref/m2.js.map | 1 - ...rcemapMixedSubfolderSpecifyOutputFile.json | 3 - ...edSubfolderSpecifyOutputFile.sourcemap.txt | 172 ----- .../node/ref/m2.d.ts | 6 - .../node/ref/m2.js | 13 - .../node/ref/m2.js.map | 1 - ...rcemapMixedSubfolderSpecifyOutputFile.json | 3 - ...edSubfolderSpecifyOutputFile.sourcemap.txt | 171 ----- .../amd/outdir/outAndOutDirFolder/ref/m2.d.ts | 6 - .../amd/outdir/outAndOutDirFolder/ref/m2.js | 15 - .../outdir/outAndOutDirFolder/ref/m2.js.map | 1 - ...erSpecifyOutputFileAndOutputDirectory.json | 3 - ...OutputFileAndOutputDirectory.sourcemap.txt | 172 ----- .../outdir/outAndOutDirFolder/ref/m2.d.ts | 6 - .../node/outdir/outAndOutDirFolder/ref/m2.js | 13 - .../outdir/outAndOutDirFolder/ref/m2.js.map | 1 - ...erSpecifyOutputFileAndOutputDirectory.json | 3 - ...OutputFileAndOutputDirectory.sourcemap.txt | 171 ----- .../amd/diskFile0.js.map | 1 - .../amd/diskFile1.js | 15 - .../amd/diskFile2.d.ts | 6 - .../amd/ref/m1.d.ts | 6 - .../amd/ref/m1.js | 15 - .../amd/ref/m1.js.map | 1 - ...mapModuleMultifolderSpecifyOutputFile.json | 9 - ...MultifolderSpecifyOutputFile.sourcemap.txt | 569 ---------------- .../amd/test.d.ts | 10 - .../amd/test.js | 17 - .../amd/test.js.map | 1 - .../node/diskFile0.js.map | 1 - .../node/diskFile1.js | 13 - .../node/diskFile2.d.ts | 6 - .../node/ref/m1.d.ts | 6 - .../node/ref/m1.js | 13 - .../node/ref/m1.js.map | 1 - ...mapModuleMultifolderSpecifyOutputFile.json | 9 - ...MultifolderSpecifyOutputFile.sourcemap.txt | 613 ------------------ .../node/test.d.ts | 10 - .../node/test.js | 17 - .../node/test.js.map | 1 - .../amd/m1.d.ts | 6 - .../amd/m1.js | 15 - .../amd/m1.js.map | 1 - ...ourcemapModuleSimpleSpecifyOutputFile.json | 6 - ...oduleSimpleSpecifyOutputFile.sourcemap.txt | 371 ----------- .../amd/test.d.ts | 8 - .../amd/test.js | 16 - .../amd/test.js.map | 1 - .../node/m1.d.ts | 6 - .../node/m1.js | 13 - .../node/m1.js.map | 1 - ...ourcemapModuleSimpleSpecifyOutputFile.json | 6 - ...oduleSimpleSpecifyOutputFile.sourcemap.txt | 392 ----------- .../node/test.d.ts | 8 - .../node/test.js | 15 - .../node/test.js.map | 1 - .../amd/ref/m1.d.ts | 6 - .../amd/ref/m1.js | 15 - .../amd/ref/m1.js.map | 1 - ...cemapModuleSubfolderSpecifyOutputFile.json | 6 - ...leSubfolderSpecifyOutputFile.sourcemap.txt | 371 ----------- .../amd/test.d.ts | 8 - .../amd/test.js | 16 - .../amd/test.js.map | 1 - .../node/ref/m1.d.ts | 6 - .../node/ref/m1.js | 13 - .../node/ref/m1.js.map | 1 - ...cemapModuleSubfolderSpecifyOutputFile.json | 6 - ...leSubfolderSpecifyOutputFile.sourcemap.txt | 392 ----------- .../node/test.d.ts | 8 - .../node/test.js | 15 - .../node/test.js.map | 1 - .../amd/ref/m2.d.ts | 6 - .../amd/ref/m2.js | 15 - .../amd/ref/m2.js.map | 1 - ...ootUrlMixedSubfolderSpecifyOutputFile.json | 3 - ...edSubfolderSpecifyOutputFile.sourcemap.txt | 172 ----- .../node/ref/m2.d.ts | 6 - .../node/ref/m2.js | 13 - .../node/ref/m2.js.map | 1 - ...ootUrlMixedSubfolderSpecifyOutputFile.json | 3 - ...edSubfolderSpecifyOutputFile.sourcemap.txt | 171 ----- .../amd/outdir/outAndOutDirFolder/ref/m2.d.ts | 6 - .../amd/outdir/outAndOutDirFolder/ref/m2.js | 15 - .../outdir/outAndOutDirFolder/ref/m2.js.map | 1 - ...erSpecifyOutputFileAndOutputDirectory.json | 3 - ...OutputFileAndOutputDirectory.sourcemap.txt | 172 ----- .../outdir/outAndOutDirFolder/ref/m2.d.ts | 6 - .../node/outdir/outAndOutDirFolder/ref/m2.js | 13 - .../outdir/outAndOutDirFolder/ref/m2.js.map | 1 - ...erSpecifyOutputFileAndOutputDirectory.json | 3 - ...OutputFileAndOutputDirectory.sourcemap.txt | 171 ----- .../amd/diskFile0.js.map | 1 - .../amd/diskFile1.js | 15 - .../amd/diskFile2.d.ts | 6 - .../amd/ref/m1.d.ts | 6 - .../amd/ref/m1.js | 15 - .../amd/ref/m1.js.map | 1 - ...UrlModuleMultifolderSpecifyOutputFile.json | 9 - ...MultifolderSpecifyOutputFile.sourcemap.txt | 569 ---------------- .../amd/test.d.ts | 10 - .../amd/test.js | 17 - .../amd/test.js.map | 1 - .../node/diskFile0.js.map | 1 - .../node/diskFile1.js | 13 - .../node/diskFile2.d.ts | 6 - .../node/ref/m1.d.ts | 6 - .../node/ref/m1.js | 13 - .../node/ref/m1.js.map | 1 - ...UrlModuleMultifolderSpecifyOutputFile.json | 9 - ...MultifolderSpecifyOutputFile.sourcemap.txt | 613 ------------------ .../node/test.d.ts | 10 - .../node/test.js | 17 - .../node/test.js.map | 1 - .../amd/m1.d.ts | 6 - .../amd/m1.js | 15 - .../amd/m1.js.map | 1 - ...erootUrlModuleSimpleSpecifyOutputFile.json | 6 - ...oduleSimpleSpecifyOutputFile.sourcemap.txt | 371 ----------- .../amd/test.d.ts | 8 - .../amd/test.js | 16 - .../amd/test.js.map | 1 - .../node/m1.d.ts | 6 - .../node/m1.js | 13 - .../node/m1.js.map | 1 - ...erootUrlModuleSimpleSpecifyOutputFile.json | 6 - ...oduleSimpleSpecifyOutputFile.sourcemap.txt | 392 ----------- .../node/test.d.ts | 8 - .../node/test.js | 15 - .../node/test.js.map | 1 - .../amd/ref/m1.d.ts | 6 - .../amd/ref/m1.js | 15 - .../amd/ref/m1.js.map | 1 - ...otUrlModuleSubfolderSpecifyOutputFile.json | 6 - ...leSubfolderSpecifyOutputFile.sourcemap.txt | 371 ----------- .../amd/test.d.ts | 8 - .../amd/test.js | 16 - .../amd/test.js.map | 1 - .../node/ref/m1.d.ts | 6 - .../node/ref/m1.js | 13 - .../node/ref/m1.js.map | 1 - ...otUrlModuleSubfolderSpecifyOutputFile.json | 6 - ...leSubfolderSpecifyOutputFile.sourcemap.txt | 392 ----------- .../node/test.d.ts | 8 - .../node/test.js | 15 - .../node/test.js.map | 1 - 661 files changed, 45 insertions(+), 32534 deletions(-) delete mode 100644 tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFile/amd/ref/m2.d.ts delete mode 100644 tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFile/amd/ref/m2.js delete mode 100644 tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFile/amd/ref/m2.js.map delete mode 100644 tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFile/node/ref/m2.d.ts delete mode 100644 tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFile/node/ref/m2.js delete mode 100644 tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFile/node/ref/m2.js.map delete mode 100644 tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/outdir/outAndOutDirFolder/ref/m2.d.ts delete mode 100644 tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/outdir/outAndOutDirFolder/ref/m2.js delete mode 100644 tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/outdir/outAndOutDirFolder/ref/m2.js.map delete mode 100644 tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/outdir/outAndOutDirFolder/ref/m2.d.ts delete mode 100644 tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/outdir/outAndOutDirFolder/ref/m2.js delete mode 100644 tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/outdir/outAndOutDirFolder/ref/m2.js.map delete mode 100644 tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderSpecifyOutputFile/amd/diskFile0.js.map delete mode 100644 tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderSpecifyOutputFile/amd/diskFile1.js delete mode 100644 tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderSpecifyOutputFile/amd/diskFile2.d.ts delete mode 100644 tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderSpecifyOutputFile/amd/ref/m1.d.ts delete mode 100644 tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderSpecifyOutputFile/amd/ref/m1.js delete mode 100644 tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderSpecifyOutputFile/amd/ref/m1.js.map delete mode 100644 tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderSpecifyOutputFile/amd/test.d.ts delete mode 100644 tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderSpecifyOutputFile/amd/test.js delete mode 100644 tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderSpecifyOutputFile/amd/test.js.map delete mode 100644 tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderSpecifyOutputFile/node/diskFile0.js.map delete mode 100644 tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderSpecifyOutputFile/node/diskFile1.js delete mode 100644 tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderSpecifyOutputFile/node/diskFile2.d.ts delete mode 100644 tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderSpecifyOutputFile/node/ref/m1.d.ts delete mode 100644 tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderSpecifyOutputFile/node/ref/m1.js delete mode 100644 tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderSpecifyOutputFile/node/ref/m1.js.map delete mode 100644 tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderSpecifyOutputFile/node/test.d.ts delete mode 100644 tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderSpecifyOutputFile/node/test.js delete mode 100644 tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderSpecifyOutputFile/node/test.js.map delete mode 100644 tests/baselines/reference/project/mapRootAbsolutePathModuleSimpleSpecifyOutputFile/amd/m1.d.ts delete mode 100644 tests/baselines/reference/project/mapRootAbsolutePathModuleSimpleSpecifyOutputFile/amd/m1.js delete mode 100644 tests/baselines/reference/project/mapRootAbsolutePathModuleSimpleSpecifyOutputFile/amd/m1.js.map delete mode 100644 tests/baselines/reference/project/mapRootAbsolutePathModuleSimpleSpecifyOutputFile/amd/test.d.ts delete mode 100644 tests/baselines/reference/project/mapRootAbsolutePathModuleSimpleSpecifyOutputFile/amd/test.js delete mode 100644 tests/baselines/reference/project/mapRootAbsolutePathModuleSimpleSpecifyOutputFile/amd/test.js.map delete mode 100644 tests/baselines/reference/project/mapRootAbsolutePathModuleSimpleSpecifyOutputFile/node/m1.d.ts delete mode 100644 tests/baselines/reference/project/mapRootAbsolutePathModuleSimpleSpecifyOutputFile/node/m1.js delete mode 100644 tests/baselines/reference/project/mapRootAbsolutePathModuleSimpleSpecifyOutputFile/node/m1.js.map delete mode 100644 tests/baselines/reference/project/mapRootAbsolutePathModuleSimpleSpecifyOutputFile/node/test.d.ts delete mode 100644 tests/baselines/reference/project/mapRootAbsolutePathModuleSimpleSpecifyOutputFile/node/test.js delete mode 100644 tests/baselines/reference/project/mapRootAbsolutePathModuleSimpleSpecifyOutputFile/node/test.js.map delete mode 100644 tests/baselines/reference/project/mapRootAbsolutePathModuleSubfolderSpecifyOutputFile/amd/ref/m1.d.ts delete mode 100644 tests/baselines/reference/project/mapRootAbsolutePathModuleSubfolderSpecifyOutputFile/amd/ref/m1.js delete mode 100644 tests/baselines/reference/project/mapRootAbsolutePathModuleSubfolderSpecifyOutputFile/amd/ref/m1.js.map delete mode 100644 tests/baselines/reference/project/mapRootAbsolutePathModuleSubfolderSpecifyOutputFile/amd/test.d.ts delete mode 100644 tests/baselines/reference/project/mapRootAbsolutePathModuleSubfolderSpecifyOutputFile/amd/test.js delete mode 100644 tests/baselines/reference/project/mapRootAbsolutePathModuleSubfolderSpecifyOutputFile/amd/test.js.map delete mode 100644 tests/baselines/reference/project/mapRootAbsolutePathModuleSubfolderSpecifyOutputFile/node/ref/m1.d.ts delete mode 100644 tests/baselines/reference/project/mapRootAbsolutePathModuleSubfolderSpecifyOutputFile/node/ref/m1.js delete mode 100644 tests/baselines/reference/project/mapRootAbsolutePathModuleSubfolderSpecifyOutputFile/node/ref/m1.js.map delete mode 100644 tests/baselines/reference/project/mapRootAbsolutePathModuleSubfolderSpecifyOutputFile/node/test.d.ts delete mode 100644 tests/baselines/reference/project/mapRootAbsolutePathModuleSubfolderSpecifyOutputFile/node/test.js delete mode 100644 tests/baselines/reference/project/mapRootAbsolutePathModuleSubfolderSpecifyOutputFile/node/test.js.map delete mode 100644 tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFile/amd/ref/m2.d.ts delete mode 100644 tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFile/amd/ref/m2.js delete mode 100644 tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFile/amd/ref/m2.js.map delete mode 100644 tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFile/node/ref/m2.d.ts delete mode 100644 tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFile/node/ref/m2.js delete mode 100644 tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFile/node/ref/m2.js.map delete mode 100644 tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/outdir/outAndOutDirFolder/ref/m2.d.ts delete mode 100644 tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/outdir/outAndOutDirFolder/ref/m2.js delete mode 100644 tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/outdir/outAndOutDirFolder/ref/m2.js.map delete mode 100644 tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/outdir/outAndOutDirFolder/ref/m2.d.ts delete mode 100644 tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/outdir/outAndOutDirFolder/ref/m2.js delete mode 100644 tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/outdir/outAndOutDirFolder/ref/m2.js.map delete mode 100644 tests/baselines/reference/project/mapRootRelativePathModuleMultifolderSpecifyOutputFile/amd/diskFile0.js.map delete mode 100644 tests/baselines/reference/project/mapRootRelativePathModuleMultifolderSpecifyOutputFile/amd/diskFile1.js delete mode 100644 tests/baselines/reference/project/mapRootRelativePathModuleMultifolderSpecifyOutputFile/amd/diskFile2.d.ts delete mode 100644 tests/baselines/reference/project/mapRootRelativePathModuleMultifolderSpecifyOutputFile/amd/ref/m1.d.ts delete mode 100644 tests/baselines/reference/project/mapRootRelativePathModuleMultifolderSpecifyOutputFile/amd/ref/m1.js delete mode 100644 tests/baselines/reference/project/mapRootRelativePathModuleMultifolderSpecifyOutputFile/amd/ref/m1.js.map delete mode 100644 tests/baselines/reference/project/mapRootRelativePathModuleMultifolderSpecifyOutputFile/amd/test.d.ts delete mode 100644 tests/baselines/reference/project/mapRootRelativePathModuleMultifolderSpecifyOutputFile/amd/test.js delete mode 100644 tests/baselines/reference/project/mapRootRelativePathModuleMultifolderSpecifyOutputFile/amd/test.js.map delete mode 100644 tests/baselines/reference/project/mapRootRelativePathModuleMultifolderSpecifyOutputFile/node/diskFile0.js.map delete mode 100644 tests/baselines/reference/project/mapRootRelativePathModuleMultifolderSpecifyOutputFile/node/diskFile1.js delete mode 100644 tests/baselines/reference/project/mapRootRelativePathModuleMultifolderSpecifyOutputFile/node/diskFile2.d.ts delete mode 100644 tests/baselines/reference/project/mapRootRelativePathModuleMultifolderSpecifyOutputFile/node/ref/m1.d.ts delete mode 100644 tests/baselines/reference/project/mapRootRelativePathModuleMultifolderSpecifyOutputFile/node/ref/m1.js delete mode 100644 tests/baselines/reference/project/mapRootRelativePathModuleMultifolderSpecifyOutputFile/node/ref/m1.js.map delete mode 100644 tests/baselines/reference/project/mapRootRelativePathModuleMultifolderSpecifyOutputFile/node/test.d.ts delete mode 100644 tests/baselines/reference/project/mapRootRelativePathModuleMultifolderSpecifyOutputFile/node/test.js delete mode 100644 tests/baselines/reference/project/mapRootRelativePathModuleMultifolderSpecifyOutputFile/node/test.js.map delete mode 100644 tests/baselines/reference/project/mapRootRelativePathModuleSimpleSpecifyOutputFile/amd/m1.d.ts delete mode 100644 tests/baselines/reference/project/mapRootRelativePathModuleSimpleSpecifyOutputFile/amd/m1.js delete mode 100644 tests/baselines/reference/project/mapRootRelativePathModuleSimpleSpecifyOutputFile/amd/m1.js.map delete mode 100644 tests/baselines/reference/project/mapRootRelativePathModuleSimpleSpecifyOutputFile/amd/test.d.ts delete mode 100644 tests/baselines/reference/project/mapRootRelativePathModuleSimpleSpecifyOutputFile/amd/test.js delete mode 100644 tests/baselines/reference/project/mapRootRelativePathModuleSimpleSpecifyOutputFile/amd/test.js.map delete mode 100644 tests/baselines/reference/project/mapRootRelativePathModuleSimpleSpecifyOutputFile/node/m1.d.ts delete mode 100644 tests/baselines/reference/project/mapRootRelativePathModuleSimpleSpecifyOutputFile/node/m1.js delete mode 100644 tests/baselines/reference/project/mapRootRelativePathModuleSimpleSpecifyOutputFile/node/m1.js.map delete mode 100644 tests/baselines/reference/project/mapRootRelativePathModuleSimpleSpecifyOutputFile/node/test.d.ts delete mode 100644 tests/baselines/reference/project/mapRootRelativePathModuleSimpleSpecifyOutputFile/node/test.js delete mode 100644 tests/baselines/reference/project/mapRootRelativePathModuleSimpleSpecifyOutputFile/node/test.js.map delete mode 100644 tests/baselines/reference/project/mapRootRelativePathModuleSubfolderSpecifyOutputFile/amd/ref/m1.d.ts delete mode 100644 tests/baselines/reference/project/mapRootRelativePathModuleSubfolderSpecifyOutputFile/amd/ref/m1.js delete mode 100644 tests/baselines/reference/project/mapRootRelativePathModuleSubfolderSpecifyOutputFile/amd/ref/m1.js.map delete mode 100644 tests/baselines/reference/project/mapRootRelativePathModuleSubfolderSpecifyOutputFile/amd/test.d.ts delete mode 100644 tests/baselines/reference/project/mapRootRelativePathModuleSubfolderSpecifyOutputFile/amd/test.js delete mode 100644 tests/baselines/reference/project/mapRootRelativePathModuleSubfolderSpecifyOutputFile/amd/test.js.map delete mode 100644 tests/baselines/reference/project/mapRootRelativePathModuleSubfolderSpecifyOutputFile/node/ref/m1.d.ts delete mode 100644 tests/baselines/reference/project/mapRootRelativePathModuleSubfolderSpecifyOutputFile/node/ref/m1.js delete mode 100644 tests/baselines/reference/project/mapRootRelativePathModuleSubfolderSpecifyOutputFile/node/ref/m1.js.map delete mode 100644 tests/baselines/reference/project/mapRootRelativePathModuleSubfolderSpecifyOutputFile/node/test.d.ts delete mode 100644 tests/baselines/reference/project/mapRootRelativePathModuleSubfolderSpecifyOutputFile/node/test.js delete mode 100644 tests/baselines/reference/project/mapRootRelativePathModuleSubfolderSpecifyOutputFile/node/test.js.map delete mode 100644 tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFile/amd/ref/m2.d.ts delete mode 100644 tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFile/amd/ref/m2.js delete mode 100644 tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFile/amd/ref/m2.js.map delete mode 100644 tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFile/node/ref/m2.d.ts delete mode 100644 tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFile/node/ref/m2.js delete mode 100644 tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFile/node/ref/m2.js.map delete mode 100644 tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/outdir/outAndOutDirFolder/ref/m2.d.ts delete mode 100644 tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/outdir/outAndOutDirFolder/ref/m2.js delete mode 100644 tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/outdir/outAndOutDirFolder/ref/m2.js.map delete mode 100644 tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/outdir/outAndOutDirFolder/ref/m2.d.ts delete mode 100644 tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/outdir/outAndOutDirFolder/ref/m2.js delete mode 100644 tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/outdir/outAndOutDirFolder/ref/m2.js.map delete mode 100644 tests/baselines/reference/project/maprootUrlModuleMultifolderSpecifyOutputFile/amd/diskFile0.js.map delete mode 100644 tests/baselines/reference/project/maprootUrlModuleMultifolderSpecifyOutputFile/amd/diskFile1.js delete mode 100644 tests/baselines/reference/project/maprootUrlModuleMultifolderSpecifyOutputFile/amd/diskFile2.d.ts delete mode 100644 tests/baselines/reference/project/maprootUrlModuleMultifolderSpecifyOutputFile/amd/ref/m1.d.ts delete mode 100644 tests/baselines/reference/project/maprootUrlModuleMultifolderSpecifyOutputFile/amd/ref/m1.js delete mode 100644 tests/baselines/reference/project/maprootUrlModuleMultifolderSpecifyOutputFile/amd/ref/m1.js.map delete mode 100644 tests/baselines/reference/project/maprootUrlModuleMultifolderSpecifyOutputFile/amd/test.d.ts delete mode 100644 tests/baselines/reference/project/maprootUrlModuleMultifolderSpecifyOutputFile/amd/test.js delete mode 100644 tests/baselines/reference/project/maprootUrlModuleMultifolderSpecifyOutputFile/amd/test.js.map delete mode 100644 tests/baselines/reference/project/maprootUrlModuleMultifolderSpecifyOutputFile/node/diskFile0.js.map delete mode 100644 tests/baselines/reference/project/maprootUrlModuleMultifolderSpecifyOutputFile/node/diskFile1.js delete mode 100644 tests/baselines/reference/project/maprootUrlModuleMultifolderSpecifyOutputFile/node/diskFile2.d.ts delete mode 100644 tests/baselines/reference/project/maprootUrlModuleMultifolderSpecifyOutputFile/node/ref/m1.d.ts delete mode 100644 tests/baselines/reference/project/maprootUrlModuleMultifolderSpecifyOutputFile/node/ref/m1.js delete mode 100644 tests/baselines/reference/project/maprootUrlModuleMultifolderSpecifyOutputFile/node/ref/m1.js.map delete mode 100644 tests/baselines/reference/project/maprootUrlModuleMultifolderSpecifyOutputFile/node/test.d.ts delete mode 100644 tests/baselines/reference/project/maprootUrlModuleMultifolderSpecifyOutputFile/node/test.js delete mode 100644 tests/baselines/reference/project/maprootUrlModuleMultifolderSpecifyOutputFile/node/test.js.map delete mode 100644 tests/baselines/reference/project/maprootUrlModuleSimpleSpecifyOutputFile/amd/m1.d.ts delete mode 100644 tests/baselines/reference/project/maprootUrlModuleSimpleSpecifyOutputFile/amd/m1.js delete mode 100644 tests/baselines/reference/project/maprootUrlModuleSimpleSpecifyOutputFile/amd/m1.js.map delete mode 100644 tests/baselines/reference/project/maprootUrlModuleSimpleSpecifyOutputFile/amd/test.d.ts delete mode 100644 tests/baselines/reference/project/maprootUrlModuleSimpleSpecifyOutputFile/amd/test.js delete mode 100644 tests/baselines/reference/project/maprootUrlModuleSimpleSpecifyOutputFile/amd/test.js.map delete mode 100644 tests/baselines/reference/project/maprootUrlModuleSimpleSpecifyOutputFile/node/m1.d.ts delete mode 100644 tests/baselines/reference/project/maprootUrlModuleSimpleSpecifyOutputFile/node/m1.js delete mode 100644 tests/baselines/reference/project/maprootUrlModuleSimpleSpecifyOutputFile/node/m1.js.map delete mode 100644 tests/baselines/reference/project/maprootUrlModuleSimpleSpecifyOutputFile/node/test.d.ts delete mode 100644 tests/baselines/reference/project/maprootUrlModuleSimpleSpecifyOutputFile/node/test.js delete mode 100644 tests/baselines/reference/project/maprootUrlModuleSimpleSpecifyOutputFile/node/test.js.map delete mode 100644 tests/baselines/reference/project/maprootUrlModuleSubfolderSpecifyOutputFile/amd/ref/m1.d.ts delete mode 100644 tests/baselines/reference/project/maprootUrlModuleSubfolderSpecifyOutputFile/amd/ref/m1.js delete mode 100644 tests/baselines/reference/project/maprootUrlModuleSubfolderSpecifyOutputFile/amd/ref/m1.js.map delete mode 100644 tests/baselines/reference/project/maprootUrlModuleSubfolderSpecifyOutputFile/amd/test.d.ts delete mode 100644 tests/baselines/reference/project/maprootUrlModuleSubfolderSpecifyOutputFile/amd/test.js delete mode 100644 tests/baselines/reference/project/maprootUrlModuleSubfolderSpecifyOutputFile/amd/test.js.map delete mode 100644 tests/baselines/reference/project/maprootUrlModuleSubfolderSpecifyOutputFile/node/ref/m1.d.ts delete mode 100644 tests/baselines/reference/project/maprootUrlModuleSubfolderSpecifyOutputFile/node/ref/m1.js delete mode 100644 tests/baselines/reference/project/maprootUrlModuleSubfolderSpecifyOutputFile/node/ref/m1.js.map delete mode 100644 tests/baselines/reference/project/maprootUrlModuleSubfolderSpecifyOutputFile/node/test.d.ts delete mode 100644 tests/baselines/reference/project/maprootUrlModuleSubfolderSpecifyOutputFile/node/test.js delete mode 100644 tests/baselines/reference/project/maprootUrlModuleSubfolderSpecifyOutputFile/node/test.js.map delete mode 100644 tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFile/amd/ref/m2.d.ts delete mode 100644 tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFile/amd/ref/m2.js delete mode 100644 tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFile/amd/ref/m2.js.map delete mode 100644 tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFile/node/ref/m2.d.ts delete mode 100644 tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFile/node/ref/m2.js delete mode 100644 tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFile/node/ref/m2.js.map delete mode 100644 tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/outdir/outAndOutDirFolder/ref/m2.d.ts delete mode 100644 tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/outdir/outAndOutDirFolder/ref/m2.js delete mode 100644 tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/outdir/outAndOutDirFolder/ref/m2.js.map delete mode 100644 tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/outdir/outAndOutDirFolder/ref/m2.d.ts delete mode 100644 tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/outdir/outAndOutDirFolder/ref/m2.js delete mode 100644 tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/outdir/outAndOutDirFolder/ref/m2.js.map delete mode 100644 tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputFile/amd/diskFile0.js.map delete mode 100644 tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputFile/amd/diskFile1.js delete mode 100644 tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputFile/amd/diskFile2.d.ts delete mode 100644 tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputFile/amd/ref/m1.d.ts delete mode 100644 tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputFile/amd/ref/m1.js delete mode 100644 tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputFile/amd/ref/m1.js.map delete mode 100644 tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputFile/amd/test.d.ts delete mode 100644 tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputFile/amd/test.js delete mode 100644 tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputFile/amd/test.js.map delete mode 100644 tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputFile/node/diskFile0.js.map delete mode 100644 tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputFile/node/diskFile1.js delete mode 100644 tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputFile/node/diskFile2.d.ts delete mode 100644 tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputFile/node/ref/m1.d.ts delete mode 100644 tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputFile/node/ref/m1.js delete mode 100644 tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputFile/node/ref/m1.js.map delete mode 100644 tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputFile/node/test.d.ts delete mode 100644 tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputFile/node/test.js delete mode 100644 tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputFile/node/test.js.map delete mode 100644 tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSimpleSpecifyOutputFile/amd/m1.d.ts delete mode 100644 tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSimpleSpecifyOutputFile/amd/m1.js delete mode 100644 tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSimpleSpecifyOutputFile/amd/m1.js.map delete mode 100644 tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSimpleSpecifyOutputFile/amd/test.d.ts delete mode 100644 tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSimpleSpecifyOutputFile/amd/test.js delete mode 100644 tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSimpleSpecifyOutputFile/amd/test.js.map delete mode 100644 tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSimpleSpecifyOutputFile/node/m1.d.ts delete mode 100644 tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSimpleSpecifyOutputFile/node/m1.js delete mode 100644 tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSimpleSpecifyOutputFile/node/m1.js.map delete mode 100644 tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSimpleSpecifyOutputFile/node/test.d.ts delete mode 100644 tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSimpleSpecifyOutputFile/node/test.js delete mode 100644 tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSimpleSpecifyOutputFile/node/test.js.map delete mode 100644 tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSubfolderSpecifyOutputFile/amd/ref/m1.d.ts delete mode 100644 tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSubfolderSpecifyOutputFile/amd/ref/m1.js delete mode 100644 tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSubfolderSpecifyOutputFile/amd/ref/m1.js.map delete mode 100644 tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSubfolderSpecifyOutputFile/amd/test.d.ts delete mode 100644 tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSubfolderSpecifyOutputFile/amd/test.js delete mode 100644 tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSubfolderSpecifyOutputFile/amd/test.js.map delete mode 100644 tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSubfolderSpecifyOutputFile/node/ref/m1.d.ts delete mode 100644 tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSubfolderSpecifyOutputFile/node/ref/m1.js delete mode 100644 tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSubfolderSpecifyOutputFile/node/ref/m1.js.map delete mode 100644 tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSubfolderSpecifyOutputFile/node/test.d.ts delete mode 100644 tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSubfolderSpecifyOutputFile/node/test.js delete mode 100644 tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSubfolderSpecifyOutputFile/node/test.js.map delete mode 100644 tests/baselines/reference/project/outMixedSubfolderSpecifyOutputFile/amd/ref/m2.d.ts delete mode 100644 tests/baselines/reference/project/outMixedSubfolderSpecifyOutputFile/amd/ref/m2.js delete mode 100644 tests/baselines/reference/project/outMixedSubfolderSpecifyOutputFile/node/ref/m2.d.ts delete mode 100644 tests/baselines/reference/project/outMixedSubfolderSpecifyOutputFile/node/ref/m2.js delete mode 100644 tests/baselines/reference/project/outMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/outdir/outAndOutDirFolder/ref/m2.d.ts delete mode 100644 tests/baselines/reference/project/outMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/outdir/outAndOutDirFolder/ref/m2.js delete mode 100644 tests/baselines/reference/project/outMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/outdir/outAndOutDirFolder/ref/m2.d.ts delete mode 100644 tests/baselines/reference/project/outMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/outdir/outAndOutDirFolder/ref/m2.js delete mode 100644 tests/baselines/reference/project/outModuleMultifolderSpecifyOutputFile/amd/diskFile0.js delete mode 100644 tests/baselines/reference/project/outModuleMultifolderSpecifyOutputFile/amd/diskFile1.d.ts delete mode 100644 tests/baselines/reference/project/outModuleMultifolderSpecifyOutputFile/amd/ref/m1.d.ts delete mode 100644 tests/baselines/reference/project/outModuleMultifolderSpecifyOutputFile/amd/ref/m1.js delete mode 100644 tests/baselines/reference/project/outModuleMultifolderSpecifyOutputFile/amd/test.d.ts delete mode 100644 tests/baselines/reference/project/outModuleMultifolderSpecifyOutputFile/amd/test.js delete mode 100644 tests/baselines/reference/project/outModuleMultifolderSpecifyOutputFile/node/diskFile0.js delete mode 100644 tests/baselines/reference/project/outModuleMultifolderSpecifyOutputFile/node/diskFile1.d.ts delete mode 100644 tests/baselines/reference/project/outModuleMultifolderSpecifyOutputFile/node/ref/m1.d.ts delete mode 100644 tests/baselines/reference/project/outModuleMultifolderSpecifyOutputFile/node/ref/m1.js delete mode 100644 tests/baselines/reference/project/outModuleMultifolderSpecifyOutputFile/node/test.d.ts delete mode 100644 tests/baselines/reference/project/outModuleMultifolderSpecifyOutputFile/node/test.js delete mode 100644 tests/baselines/reference/project/outModuleSimpleSpecifyOutputFile/amd/m1.d.ts delete mode 100644 tests/baselines/reference/project/outModuleSimpleSpecifyOutputFile/amd/m1.js delete mode 100644 tests/baselines/reference/project/outModuleSimpleSpecifyOutputFile/amd/test.d.ts delete mode 100644 tests/baselines/reference/project/outModuleSimpleSpecifyOutputFile/amd/test.js delete mode 100644 tests/baselines/reference/project/outModuleSimpleSpecifyOutputFile/node/m1.d.ts delete mode 100644 tests/baselines/reference/project/outModuleSimpleSpecifyOutputFile/node/m1.js delete mode 100644 tests/baselines/reference/project/outModuleSimpleSpecifyOutputFile/node/test.d.ts delete mode 100644 tests/baselines/reference/project/outModuleSimpleSpecifyOutputFile/node/test.js delete mode 100644 tests/baselines/reference/project/outModuleSubfolderSpecifyOutputFile/amd/ref/m1.d.ts delete mode 100644 tests/baselines/reference/project/outModuleSubfolderSpecifyOutputFile/amd/ref/m1.js delete mode 100644 tests/baselines/reference/project/outModuleSubfolderSpecifyOutputFile/amd/test.d.ts delete mode 100644 tests/baselines/reference/project/outModuleSubfolderSpecifyOutputFile/amd/test.js delete mode 100644 tests/baselines/reference/project/outModuleSubfolderSpecifyOutputFile/node/ref/m1.d.ts delete mode 100644 tests/baselines/reference/project/outModuleSubfolderSpecifyOutputFile/node/ref/m1.js delete mode 100644 tests/baselines/reference/project/outModuleSubfolderSpecifyOutputFile/node/test.d.ts delete mode 100644 tests/baselines/reference/project/outModuleSubfolderSpecifyOutputFile/node/test.js delete mode 100644 tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFile/amd/ref/m2.d.ts delete mode 100644 tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFile/amd/ref/m2.js delete mode 100644 tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFile/amd/ref/m2.js.map delete mode 100644 tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFile/node/ref/m2.d.ts delete mode 100644 tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFile/node/ref/m2.js delete mode 100644 tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFile/node/ref/m2.js.map delete mode 100644 tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/outdir/outAndOutDirFolder/ref/m2.d.ts delete mode 100644 tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/outdir/outAndOutDirFolder/ref/m2.js delete mode 100644 tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/outdir/outAndOutDirFolder/ref/m2.js.map delete mode 100644 tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/outdir/outAndOutDirFolder/ref/m2.d.ts delete mode 100644 tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/outdir/outAndOutDirFolder/ref/m2.js delete mode 100644 tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/outdir/outAndOutDirFolder/ref/m2.js.map delete mode 100644 tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderSpecifyOutputFile/amd/diskFile0.js.map delete mode 100644 tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderSpecifyOutputFile/amd/diskFile1.js delete mode 100644 tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderSpecifyOutputFile/amd/diskFile2.d.ts delete mode 100644 tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderSpecifyOutputFile/amd/ref/m1.d.ts delete mode 100644 tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderSpecifyOutputFile/amd/ref/m1.js delete mode 100644 tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderSpecifyOutputFile/amd/ref/m1.js.map delete mode 100644 tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderSpecifyOutputFile/amd/test.d.ts delete mode 100644 tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderSpecifyOutputFile/amd/test.js delete mode 100644 tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderSpecifyOutputFile/amd/test.js.map delete mode 100644 tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderSpecifyOutputFile/node/diskFile0.js.map delete mode 100644 tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderSpecifyOutputFile/node/diskFile1.js delete mode 100644 tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderSpecifyOutputFile/node/diskFile2.d.ts delete mode 100644 tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderSpecifyOutputFile/node/ref/m1.d.ts delete mode 100644 tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderSpecifyOutputFile/node/ref/m1.js delete mode 100644 tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderSpecifyOutputFile/node/ref/m1.js.map delete mode 100644 tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderSpecifyOutputFile/node/test.d.ts delete mode 100644 tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderSpecifyOutputFile/node/test.js delete mode 100644 tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderSpecifyOutputFile/node/test.js.map delete mode 100644 tests/baselines/reference/project/sourceRootAbsolutePathModuleSimpleSpecifyOutputFile/amd/m1.d.ts delete mode 100644 tests/baselines/reference/project/sourceRootAbsolutePathModuleSimpleSpecifyOutputFile/amd/m1.js delete mode 100644 tests/baselines/reference/project/sourceRootAbsolutePathModuleSimpleSpecifyOutputFile/amd/m1.js.map delete mode 100644 tests/baselines/reference/project/sourceRootAbsolutePathModuleSimpleSpecifyOutputFile/amd/test.d.ts delete mode 100644 tests/baselines/reference/project/sourceRootAbsolutePathModuleSimpleSpecifyOutputFile/amd/test.js delete mode 100644 tests/baselines/reference/project/sourceRootAbsolutePathModuleSimpleSpecifyOutputFile/amd/test.js.map delete mode 100644 tests/baselines/reference/project/sourceRootAbsolutePathModuleSimpleSpecifyOutputFile/node/m1.d.ts delete mode 100644 tests/baselines/reference/project/sourceRootAbsolutePathModuleSimpleSpecifyOutputFile/node/m1.js delete mode 100644 tests/baselines/reference/project/sourceRootAbsolutePathModuleSimpleSpecifyOutputFile/node/m1.js.map delete mode 100644 tests/baselines/reference/project/sourceRootAbsolutePathModuleSimpleSpecifyOutputFile/node/test.d.ts delete mode 100644 tests/baselines/reference/project/sourceRootAbsolutePathModuleSimpleSpecifyOutputFile/node/test.js delete mode 100644 tests/baselines/reference/project/sourceRootAbsolutePathModuleSimpleSpecifyOutputFile/node/test.js.map delete mode 100644 tests/baselines/reference/project/sourceRootAbsolutePathModuleSubfolderSpecifyOutputFile/amd/ref/m1.d.ts delete mode 100644 tests/baselines/reference/project/sourceRootAbsolutePathModuleSubfolderSpecifyOutputFile/amd/ref/m1.js delete mode 100644 tests/baselines/reference/project/sourceRootAbsolutePathModuleSubfolderSpecifyOutputFile/amd/ref/m1.js.map delete mode 100644 tests/baselines/reference/project/sourceRootAbsolutePathModuleSubfolderSpecifyOutputFile/amd/test.d.ts delete mode 100644 tests/baselines/reference/project/sourceRootAbsolutePathModuleSubfolderSpecifyOutputFile/amd/test.js delete mode 100644 tests/baselines/reference/project/sourceRootAbsolutePathModuleSubfolderSpecifyOutputFile/amd/test.js.map delete mode 100644 tests/baselines/reference/project/sourceRootAbsolutePathModuleSubfolderSpecifyOutputFile/node/ref/m1.d.ts delete mode 100644 tests/baselines/reference/project/sourceRootAbsolutePathModuleSubfolderSpecifyOutputFile/node/ref/m1.js delete mode 100644 tests/baselines/reference/project/sourceRootAbsolutePathModuleSubfolderSpecifyOutputFile/node/ref/m1.js.map delete mode 100644 tests/baselines/reference/project/sourceRootAbsolutePathModuleSubfolderSpecifyOutputFile/node/test.d.ts delete mode 100644 tests/baselines/reference/project/sourceRootAbsolutePathModuleSubfolderSpecifyOutputFile/node/test.js delete mode 100644 tests/baselines/reference/project/sourceRootAbsolutePathModuleSubfolderSpecifyOutputFile/node/test.js.map delete mode 100644 tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFile/amd/ref/m2.d.ts delete mode 100644 tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFile/amd/ref/m2.js delete mode 100644 tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFile/amd/ref/m2.js.map delete mode 100644 tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFile/node/ref/m2.d.ts delete mode 100644 tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFile/node/ref/m2.js delete mode 100644 tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFile/node/ref/m2.js.map delete mode 100644 tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/outdir/outAndOutDirFolder/ref/m2.d.ts delete mode 100644 tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/outdir/outAndOutDirFolder/ref/m2.js delete mode 100644 tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/outdir/outAndOutDirFolder/ref/m2.js.map delete mode 100644 tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/outdir/outAndOutDirFolder/ref/m2.d.ts delete mode 100644 tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/outdir/outAndOutDirFolder/ref/m2.js delete mode 100644 tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/outdir/outAndOutDirFolder/ref/m2.js.map delete mode 100644 tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderSpecifyOutputFile/amd/diskFile0.js.map delete mode 100644 tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderSpecifyOutputFile/amd/diskFile1.js delete mode 100644 tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderSpecifyOutputFile/amd/diskFile2.d.ts delete mode 100644 tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderSpecifyOutputFile/amd/ref/m1.d.ts delete mode 100644 tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderSpecifyOutputFile/amd/ref/m1.js delete mode 100644 tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderSpecifyOutputFile/amd/ref/m1.js.map delete mode 100644 tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderSpecifyOutputFile/amd/test.d.ts delete mode 100644 tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderSpecifyOutputFile/amd/test.js delete mode 100644 tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderSpecifyOutputFile/amd/test.js.map delete mode 100644 tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderSpecifyOutputFile/node/diskFile0.js.map delete mode 100644 tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderSpecifyOutputFile/node/diskFile1.js delete mode 100644 tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderSpecifyOutputFile/node/diskFile2.d.ts delete mode 100644 tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderSpecifyOutputFile/node/ref/m1.d.ts delete mode 100644 tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderSpecifyOutputFile/node/ref/m1.js delete mode 100644 tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderSpecifyOutputFile/node/ref/m1.js.map delete mode 100644 tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderSpecifyOutputFile/node/test.d.ts delete mode 100644 tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderSpecifyOutputFile/node/test.js delete mode 100644 tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderSpecifyOutputFile/node/test.js.map delete mode 100644 tests/baselines/reference/project/sourceRootRelativePathModuleSimpleSpecifyOutputFile/amd/m1.d.ts delete mode 100644 tests/baselines/reference/project/sourceRootRelativePathModuleSimpleSpecifyOutputFile/amd/m1.js delete mode 100644 tests/baselines/reference/project/sourceRootRelativePathModuleSimpleSpecifyOutputFile/amd/m1.js.map delete mode 100644 tests/baselines/reference/project/sourceRootRelativePathModuleSimpleSpecifyOutputFile/amd/test.d.ts delete mode 100644 tests/baselines/reference/project/sourceRootRelativePathModuleSimpleSpecifyOutputFile/amd/test.js delete mode 100644 tests/baselines/reference/project/sourceRootRelativePathModuleSimpleSpecifyOutputFile/amd/test.js.map delete mode 100644 tests/baselines/reference/project/sourceRootRelativePathModuleSimpleSpecifyOutputFile/node/m1.d.ts delete mode 100644 tests/baselines/reference/project/sourceRootRelativePathModuleSimpleSpecifyOutputFile/node/m1.js delete mode 100644 tests/baselines/reference/project/sourceRootRelativePathModuleSimpleSpecifyOutputFile/node/m1.js.map delete mode 100644 tests/baselines/reference/project/sourceRootRelativePathModuleSimpleSpecifyOutputFile/node/test.d.ts delete mode 100644 tests/baselines/reference/project/sourceRootRelativePathModuleSimpleSpecifyOutputFile/node/test.js delete mode 100644 tests/baselines/reference/project/sourceRootRelativePathModuleSimpleSpecifyOutputFile/node/test.js.map delete mode 100644 tests/baselines/reference/project/sourceRootRelativePathModuleSubfolderSpecifyOutputFile/amd/ref/m1.d.ts delete mode 100644 tests/baselines/reference/project/sourceRootRelativePathModuleSubfolderSpecifyOutputFile/amd/ref/m1.js delete mode 100644 tests/baselines/reference/project/sourceRootRelativePathModuleSubfolderSpecifyOutputFile/amd/ref/m1.js.map delete mode 100644 tests/baselines/reference/project/sourceRootRelativePathModuleSubfolderSpecifyOutputFile/amd/test.d.ts delete mode 100644 tests/baselines/reference/project/sourceRootRelativePathModuleSubfolderSpecifyOutputFile/amd/test.js delete mode 100644 tests/baselines/reference/project/sourceRootRelativePathModuleSubfolderSpecifyOutputFile/amd/test.js.map delete mode 100644 tests/baselines/reference/project/sourceRootRelativePathModuleSubfolderSpecifyOutputFile/node/ref/m1.d.ts delete mode 100644 tests/baselines/reference/project/sourceRootRelativePathModuleSubfolderSpecifyOutputFile/node/ref/m1.js delete mode 100644 tests/baselines/reference/project/sourceRootRelativePathModuleSubfolderSpecifyOutputFile/node/ref/m1.js.map delete mode 100644 tests/baselines/reference/project/sourceRootRelativePathModuleSubfolderSpecifyOutputFile/node/test.d.ts delete mode 100644 tests/baselines/reference/project/sourceRootRelativePathModuleSubfolderSpecifyOutputFile/node/test.js delete mode 100644 tests/baselines/reference/project/sourceRootRelativePathModuleSubfolderSpecifyOutputFile/node/test.js.map delete mode 100644 tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFile/amd/ref/m2.d.ts delete mode 100644 tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFile/amd/ref/m2.js delete mode 100644 tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFile/amd/ref/m2.js.map delete mode 100644 tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFile/node/ref/m2.d.ts delete mode 100644 tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFile/node/ref/m2.js delete mode 100644 tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFile/node/ref/m2.js.map delete mode 100644 tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/outdir/outAndOutDirFolder/ref/m2.d.ts delete mode 100644 tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/outdir/outAndOutDirFolder/ref/m2.js delete mode 100644 tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/outdir/outAndOutDirFolder/ref/m2.js.map delete mode 100644 tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/outdir/outAndOutDirFolder/ref/m2.d.ts delete mode 100644 tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/outdir/outAndOutDirFolder/ref/m2.js delete mode 100644 tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/outdir/outAndOutDirFolder/ref/m2.js.map delete mode 100644 tests/baselines/reference/project/sourcemapModuleMultifolderSpecifyOutputFile/amd/diskFile0.js.map delete mode 100644 tests/baselines/reference/project/sourcemapModuleMultifolderSpecifyOutputFile/amd/diskFile1.js delete mode 100644 tests/baselines/reference/project/sourcemapModuleMultifolderSpecifyOutputFile/amd/diskFile2.d.ts delete mode 100644 tests/baselines/reference/project/sourcemapModuleMultifolderSpecifyOutputFile/amd/ref/m1.d.ts delete mode 100644 tests/baselines/reference/project/sourcemapModuleMultifolderSpecifyOutputFile/amd/ref/m1.js delete mode 100644 tests/baselines/reference/project/sourcemapModuleMultifolderSpecifyOutputFile/amd/ref/m1.js.map delete mode 100644 tests/baselines/reference/project/sourcemapModuleMultifolderSpecifyOutputFile/amd/test.d.ts delete mode 100644 tests/baselines/reference/project/sourcemapModuleMultifolderSpecifyOutputFile/amd/test.js delete mode 100644 tests/baselines/reference/project/sourcemapModuleMultifolderSpecifyOutputFile/amd/test.js.map delete mode 100644 tests/baselines/reference/project/sourcemapModuleMultifolderSpecifyOutputFile/node/diskFile0.js.map delete mode 100644 tests/baselines/reference/project/sourcemapModuleMultifolderSpecifyOutputFile/node/diskFile1.js delete mode 100644 tests/baselines/reference/project/sourcemapModuleMultifolderSpecifyOutputFile/node/diskFile2.d.ts delete mode 100644 tests/baselines/reference/project/sourcemapModuleMultifolderSpecifyOutputFile/node/ref/m1.d.ts delete mode 100644 tests/baselines/reference/project/sourcemapModuleMultifolderSpecifyOutputFile/node/ref/m1.js delete mode 100644 tests/baselines/reference/project/sourcemapModuleMultifolderSpecifyOutputFile/node/ref/m1.js.map delete mode 100644 tests/baselines/reference/project/sourcemapModuleMultifolderSpecifyOutputFile/node/test.d.ts delete mode 100644 tests/baselines/reference/project/sourcemapModuleMultifolderSpecifyOutputFile/node/test.js delete mode 100644 tests/baselines/reference/project/sourcemapModuleMultifolderSpecifyOutputFile/node/test.js.map delete mode 100644 tests/baselines/reference/project/sourcemapModuleSimpleSpecifyOutputFile/amd/m1.d.ts delete mode 100644 tests/baselines/reference/project/sourcemapModuleSimpleSpecifyOutputFile/amd/m1.js delete mode 100644 tests/baselines/reference/project/sourcemapModuleSimpleSpecifyOutputFile/amd/m1.js.map delete mode 100644 tests/baselines/reference/project/sourcemapModuleSimpleSpecifyOutputFile/amd/test.d.ts delete mode 100644 tests/baselines/reference/project/sourcemapModuleSimpleSpecifyOutputFile/amd/test.js delete mode 100644 tests/baselines/reference/project/sourcemapModuleSimpleSpecifyOutputFile/amd/test.js.map delete mode 100644 tests/baselines/reference/project/sourcemapModuleSimpleSpecifyOutputFile/node/m1.d.ts delete mode 100644 tests/baselines/reference/project/sourcemapModuleSimpleSpecifyOutputFile/node/m1.js delete mode 100644 tests/baselines/reference/project/sourcemapModuleSimpleSpecifyOutputFile/node/m1.js.map delete mode 100644 tests/baselines/reference/project/sourcemapModuleSimpleSpecifyOutputFile/node/test.d.ts delete mode 100644 tests/baselines/reference/project/sourcemapModuleSimpleSpecifyOutputFile/node/test.js delete mode 100644 tests/baselines/reference/project/sourcemapModuleSimpleSpecifyOutputFile/node/test.js.map delete mode 100644 tests/baselines/reference/project/sourcemapModuleSubfolderSpecifyOutputFile/amd/ref/m1.d.ts delete mode 100644 tests/baselines/reference/project/sourcemapModuleSubfolderSpecifyOutputFile/amd/ref/m1.js delete mode 100644 tests/baselines/reference/project/sourcemapModuleSubfolderSpecifyOutputFile/amd/ref/m1.js.map delete mode 100644 tests/baselines/reference/project/sourcemapModuleSubfolderSpecifyOutputFile/amd/test.d.ts delete mode 100644 tests/baselines/reference/project/sourcemapModuleSubfolderSpecifyOutputFile/amd/test.js delete mode 100644 tests/baselines/reference/project/sourcemapModuleSubfolderSpecifyOutputFile/amd/test.js.map delete mode 100644 tests/baselines/reference/project/sourcemapModuleSubfolderSpecifyOutputFile/node/ref/m1.d.ts delete mode 100644 tests/baselines/reference/project/sourcemapModuleSubfolderSpecifyOutputFile/node/ref/m1.js delete mode 100644 tests/baselines/reference/project/sourcemapModuleSubfolderSpecifyOutputFile/node/ref/m1.js.map delete mode 100644 tests/baselines/reference/project/sourcemapModuleSubfolderSpecifyOutputFile/node/test.d.ts delete mode 100644 tests/baselines/reference/project/sourcemapModuleSubfolderSpecifyOutputFile/node/test.js delete mode 100644 tests/baselines/reference/project/sourcemapModuleSubfolderSpecifyOutputFile/node/test.js.map delete mode 100644 tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFile/amd/ref/m2.d.ts delete mode 100644 tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFile/amd/ref/m2.js delete mode 100644 tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFile/amd/ref/m2.js.map delete mode 100644 tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFile/node/ref/m2.d.ts delete mode 100644 tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFile/node/ref/m2.js delete mode 100644 tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFile/node/ref/m2.js.map delete mode 100644 tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/outdir/outAndOutDirFolder/ref/m2.d.ts delete mode 100644 tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/outdir/outAndOutDirFolder/ref/m2.js delete mode 100644 tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/outdir/outAndOutDirFolder/ref/m2.js.map delete mode 100644 tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/outdir/outAndOutDirFolder/ref/m2.d.ts delete mode 100644 tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/outdir/outAndOutDirFolder/ref/m2.js delete mode 100644 tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/outdir/outAndOutDirFolder/ref/m2.js.map delete mode 100644 tests/baselines/reference/project/sourcerootUrlModuleMultifolderSpecifyOutputFile/amd/diskFile0.js.map delete mode 100644 tests/baselines/reference/project/sourcerootUrlModuleMultifolderSpecifyOutputFile/amd/diskFile1.js delete mode 100644 tests/baselines/reference/project/sourcerootUrlModuleMultifolderSpecifyOutputFile/amd/diskFile2.d.ts delete mode 100644 tests/baselines/reference/project/sourcerootUrlModuleMultifolderSpecifyOutputFile/amd/ref/m1.d.ts delete mode 100644 tests/baselines/reference/project/sourcerootUrlModuleMultifolderSpecifyOutputFile/amd/ref/m1.js delete mode 100644 tests/baselines/reference/project/sourcerootUrlModuleMultifolderSpecifyOutputFile/amd/ref/m1.js.map delete mode 100644 tests/baselines/reference/project/sourcerootUrlModuleMultifolderSpecifyOutputFile/amd/test.d.ts delete mode 100644 tests/baselines/reference/project/sourcerootUrlModuleMultifolderSpecifyOutputFile/amd/test.js delete mode 100644 tests/baselines/reference/project/sourcerootUrlModuleMultifolderSpecifyOutputFile/amd/test.js.map delete mode 100644 tests/baselines/reference/project/sourcerootUrlModuleMultifolderSpecifyOutputFile/node/diskFile0.js.map delete mode 100644 tests/baselines/reference/project/sourcerootUrlModuleMultifolderSpecifyOutputFile/node/diskFile1.js delete mode 100644 tests/baselines/reference/project/sourcerootUrlModuleMultifolderSpecifyOutputFile/node/diskFile2.d.ts delete mode 100644 tests/baselines/reference/project/sourcerootUrlModuleMultifolderSpecifyOutputFile/node/ref/m1.d.ts delete mode 100644 tests/baselines/reference/project/sourcerootUrlModuleMultifolderSpecifyOutputFile/node/ref/m1.js delete mode 100644 tests/baselines/reference/project/sourcerootUrlModuleMultifolderSpecifyOutputFile/node/ref/m1.js.map delete mode 100644 tests/baselines/reference/project/sourcerootUrlModuleMultifolderSpecifyOutputFile/node/test.d.ts delete mode 100644 tests/baselines/reference/project/sourcerootUrlModuleMultifolderSpecifyOutputFile/node/test.js delete mode 100644 tests/baselines/reference/project/sourcerootUrlModuleMultifolderSpecifyOutputFile/node/test.js.map delete mode 100644 tests/baselines/reference/project/sourcerootUrlModuleSimpleSpecifyOutputFile/amd/m1.d.ts delete mode 100644 tests/baselines/reference/project/sourcerootUrlModuleSimpleSpecifyOutputFile/amd/m1.js delete mode 100644 tests/baselines/reference/project/sourcerootUrlModuleSimpleSpecifyOutputFile/amd/m1.js.map delete mode 100644 tests/baselines/reference/project/sourcerootUrlModuleSimpleSpecifyOutputFile/amd/test.d.ts delete mode 100644 tests/baselines/reference/project/sourcerootUrlModuleSimpleSpecifyOutputFile/amd/test.js delete mode 100644 tests/baselines/reference/project/sourcerootUrlModuleSimpleSpecifyOutputFile/amd/test.js.map delete mode 100644 tests/baselines/reference/project/sourcerootUrlModuleSimpleSpecifyOutputFile/node/m1.d.ts delete mode 100644 tests/baselines/reference/project/sourcerootUrlModuleSimpleSpecifyOutputFile/node/m1.js delete mode 100644 tests/baselines/reference/project/sourcerootUrlModuleSimpleSpecifyOutputFile/node/m1.js.map delete mode 100644 tests/baselines/reference/project/sourcerootUrlModuleSimpleSpecifyOutputFile/node/test.d.ts delete mode 100644 tests/baselines/reference/project/sourcerootUrlModuleSimpleSpecifyOutputFile/node/test.js delete mode 100644 tests/baselines/reference/project/sourcerootUrlModuleSimpleSpecifyOutputFile/node/test.js.map delete mode 100644 tests/baselines/reference/project/sourcerootUrlModuleSubfolderSpecifyOutputFile/amd/ref/m1.d.ts delete mode 100644 tests/baselines/reference/project/sourcerootUrlModuleSubfolderSpecifyOutputFile/amd/ref/m1.js delete mode 100644 tests/baselines/reference/project/sourcerootUrlModuleSubfolderSpecifyOutputFile/amd/ref/m1.js.map delete mode 100644 tests/baselines/reference/project/sourcerootUrlModuleSubfolderSpecifyOutputFile/amd/test.d.ts delete mode 100644 tests/baselines/reference/project/sourcerootUrlModuleSubfolderSpecifyOutputFile/amd/test.js delete mode 100644 tests/baselines/reference/project/sourcerootUrlModuleSubfolderSpecifyOutputFile/amd/test.js.map delete mode 100644 tests/baselines/reference/project/sourcerootUrlModuleSubfolderSpecifyOutputFile/node/ref/m1.d.ts delete mode 100644 tests/baselines/reference/project/sourcerootUrlModuleSubfolderSpecifyOutputFile/node/ref/m1.js delete mode 100644 tests/baselines/reference/project/sourcerootUrlModuleSubfolderSpecifyOutputFile/node/ref/m1.js.map delete mode 100644 tests/baselines/reference/project/sourcerootUrlModuleSubfolderSpecifyOutputFile/node/test.d.ts delete mode 100644 tests/baselines/reference/project/sourcerootUrlModuleSubfolderSpecifyOutputFile/node/test.js delete mode 100644 tests/baselines/reference/project/sourcerootUrlModuleSubfolderSpecifyOutputFile/node/test.js.map diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index e9ea99dc2d5..1343a5c85d9 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -326,17 +326,19 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi let newLine = host.getNewLine(); let jsxDesugaring = host.getCompilerOptions().jsx !== JsxEmit.Preserve; let shouldEmitJsx = (s: SourceFile) => (s.languageVariant === LanguageVariant.JSX && !jsxDesugaring); + let outFile = compilerOptions.outFile || compilerOptions.out; if (targetSourceFile === undefined) { - forEach(host.getSourceFiles(), sourceFile => { - if (shouldEmitToOwnFile(sourceFile, compilerOptions)) { - let jsFilePath = getOwnEmitOutputFilePath(sourceFile, host, shouldEmitJsx(sourceFile) ? ".jsx" : ".js"); - emitFile(jsFilePath, sourceFile); - } - }); - - if (compilerOptions.outFile || compilerOptions.out) { - emitFile(compilerOptions.outFile || compilerOptions.out); + if (outFile) { + emitFile(outFile); + } + else { + forEach(host.getSourceFiles(), sourceFile => { + if (shouldEmitToOwnFile(sourceFile, compilerOptions)) { + let jsFilePath = getOwnEmitOutputFilePath(sourceFile, host, shouldEmitJsx(sourceFile) ? ".jsx" : ".js"); + emitFile(jsFilePath, sourceFile); + } + }); } } else { @@ -345,8 +347,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi let jsFilePath = getOwnEmitOutputFilePath(targetSourceFile, host, shouldEmitJsx(targetSourceFile) ? ".jsx" : ".js"); emitFile(jsFilePath, targetSourceFile); } - else if (!isDeclarationFile(targetSourceFile) && (compilerOptions.outFile || compilerOptions.out)) { - emitFile(compilerOptions.outFile || compilerOptions.out); + else if (!isDeclarationFile(targetSourceFile) && outFile) { + emitFile(outFile); } } @@ -547,7 +549,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi /** If removeComments is true, no leading-comments needed to be emitted **/ let emitLeadingCommentsOfPosition = compilerOptions.removeComments ? function (pos: number) { } : emitLeadingCommentsOfPositionWorker; - let moduleEmitDelegates: Map<(node: SourceFile, resolvePath?: boolean) => void> = { + let moduleEmitDelegates: Map<(node: SourceFile, resolveModuleNames?: boolean) => void> = { [ModuleKind.ES6]: emitES6Module, [ModuleKind.AMD]: emitAMDModule, [ModuleKind.System]: emitSystemModule, @@ -555,7 +557,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi [ModuleKind.CommonJS]: emitCommonJSModule, }; - let bundleEmitDelegates: Map<(node: SourceFile, resolvePath?: boolean) => void> = { + let bundleEmitDelegates: Map<(node: SourceFile, resolveModuleNames?: boolean) => void> = { [ModuleKind.ES6]() {}, [ModuleKind.AMD]: emitAMDModule, [ModuleKind.System]: emitSystemModule, @@ -7280,7 +7282,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi write("}"); // execute } - function emitSystemModule(node: SourceFile, resolvePath?: boolean): void { + function emitSystemModule(node: SourceFile, resolveModuleNames?: boolean): void { collectExternalModuleInfo(node); // System modules has the following shape // System.register(['dep-1', ... 'dep-n'], function(exports) {/* module body function */}) @@ -7320,7 +7322,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi write(", "); } - if (resolvePath) { + if (resolveModuleNames) { let name = lookupSpecifierName(externalImports[i]); if (name) { text = `"${name}"`; @@ -7346,15 +7348,15 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi specifier = (declaration as ImportEqualsDeclaration).moduleReference; } else { - specifier = (declaration as ImportDeclaration|ExportDeclaration).moduleSpecifier; + specifier = (declaration as ImportDeclaration | ExportDeclaration).moduleSpecifier; } let moduleSymbol = resolver.getSymbolAtLocation(specifier); if (!moduleSymbol) { - return; + return undefined; } let moduleDeclaration = getDeclarationOfKind(moduleSymbol, SyntaxKind.SourceFile) as SourceFile; if (!moduleDeclaration || isDeclarationFile(moduleDeclaration)) { - return; + return undefined; } return getExternalModuleNameFromPath(host, moduleDeclaration.fileName); } @@ -7365,7 +7367,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi importAliasNames: string[]; } - function getAMDDependencyNames(node: SourceFile, includeNonAmdDependencies: boolean, resolvePath?: boolean): AMDDependencyNames { + function getAMDDependencyNames(node: SourceFile, includeNonAmdDependencies: boolean, resolveModuleNames?: boolean): AMDDependencyNames { // names of modules with corresponding parameter in the factory function let aliasedModuleNames: string[] = []; // names of modules with no corresponding parameters in factory function @@ -7389,7 +7391,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi // Find the name of the external module let externalModuleName = getExternalModuleNameText(importNode); - if (resolvePath) { + if (resolveModuleNames) { let name = lookupSpecifierName(importNode); if (name) { externalModuleName = `"${name}"`; @@ -7410,7 +7412,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi return { aliasedModuleNames, unaliasedModuleNames, importAliasNames }; } - function emitAMDDependencies(node: SourceFile, includeNonAmdDependencies: boolean, resolvePath?: boolean) { + function emitAMDDependencies(node: SourceFile, includeNonAmdDependencies: boolean, resolveModuleNames?: boolean) { // An AMD define function has the following shape: // define(id?, dependencies?, factory); // @@ -7423,7 +7425,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi // `import "module"` or `` // we need to add modules without alias names to the end of the dependencies list - let dependencyNames = getAMDDependencyNames(node, includeNonAmdDependencies, resolvePath); + let dependencyNames = getAMDDependencyNames(node, includeNonAmdDependencies, resolveModuleNames); emitAMDDependencyList(dependencyNames); write(", "); emitAMDFactoryHeader(dependencyNames); @@ -7451,7 +7453,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi write(") {"); } - function emitAMDModule(node: SourceFile, resolvePath?: boolean) { + function emitAMDModule(node: SourceFile, resolveModuleNames?: boolean) { emitEmitHelpers(node); collectExternalModuleInfo(node); @@ -7460,7 +7462,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi if (node.moduleName) { write("\"" + node.moduleName + "\", "); } - emitAMDDependencies(node, /*includeNonAmdDependencies*/ true, resolvePath); + emitAMDDependencies(node, /*includeNonAmdDependencies*/ true, resolveModuleNames); increaseIndent(); let startIndex = emitDirectivePrologues(node.statements, /*startWithNewLine*/ true); emitExportStarHelper(); @@ -7714,7 +7716,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi emitModule(node); } else { - bundleEmitDelegates[modulekind](node, /*resolvePath*/true); + bundleEmitDelegates[modulekind](node, /*resolveModuleNames*/true); } } else { diff --git a/src/compiler/program.ts b/src/compiler/program.ts index 5b28dac9c09..6a6e8d5bca6 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -1036,7 +1036,7 @@ namespace ts { } // Cannot specify module gen that isn't amd or system with --out - if (outFile && options.module && options.module !== ModuleKind.AMD && options.module !== ModuleKind.System) { + if (outFile && options.module && !(options.module === ModuleKind.AMD || options.module === ModuleKind.System)) { programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Only_amd_and_system_modules_are_supported_alongside_0, options.out ? "out" : "outFile")); } diff --git a/src/harness/harness.ts b/src/harness/harness.ts index 41356e47e1c..91f7e46f845 100644 --- a/src/harness/harness.ts +++ b/src/harness/harness.ts @@ -1169,7 +1169,7 @@ namespace Harness { } else if (isTS(file.unitName)) { let declFile = findResultCodeFile(file.unitName); - if (!findUnit(declFile.fileName, declInputFiles) && !findUnit(declFile.fileName, declOtherFiles)) { + if (declFile && !findUnit(declFile.fileName, declInputFiles) && !findUnit(declFile.fileName, declOtherFiles)) { dtsFiles.push({ unitName: declFile.fileName, content: declFile.code }); } } diff --git a/src/harness/projectsRunner.ts b/src/harness/projectsRunner.ts index ace19acc1e0..036e3e0b054 100644 --- a/src/harness/projectsRunner.ts +++ b/src/harness/projectsRunner.ts @@ -303,7 +303,10 @@ class ProjectRunner extends RunnerBase { } let outputDtsFileName = emitOutputFilePathWithoutExtension + ".d.ts"; - allInputFiles.unshift(findOutpuDtsFile(outputDtsFileName)); + let file = findOutpuDtsFile(outputDtsFileName); + if (file) { + allInputFiles.unshift(file); + } } else { let outputDtsFileName = ts.removeFileExtension(compilerOptions.outFile || compilerOptions.out) + ".d.ts"; diff --git a/tests/baselines/reference/isolatedModulesOut.js b/tests/baselines/reference/isolatedModulesOut.js index ca5eb2b7579..44f319e1031 100644 --- a/tests/baselines/reference/isolatedModulesOut.js +++ b/tests/baselines/reference/isolatedModulesOut.js @@ -6,7 +6,5 @@ export var x; //// [file2.ts] var y; -//// [file1.js] -export var x; //// [all.js] var y; diff --git a/tests/baselines/reference/outModuleConcatAmd.js b/tests/baselines/reference/outModuleConcatAmd.js index 5d825757b71..a1c874abb7c 100644 --- a/tests/baselines/reference/outModuleConcatAmd.js +++ b/tests/baselines/reference/outModuleConcatAmd.js @@ -8,32 +8,7 @@ export class A { } import {A} from "./ref/a"; export class B extends A { } -//// [a.js] -define(["require", "exports"], function (require, exports) { - var A = (function () { - function A() { - } - return A; - })(); - exports.A = A; -}); -//# sourceMappingURL=a.js.map//// [b.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 __()); -}; -define(["require", "exports", "./ref/a"], function (require, exports, a_1) { - var B = (function (_super) { - __extends(B, _super); - function B() { - _super.apply(this, arguments); - } - return B; - })(a_1.A); - exports.B = B; -}); -//# sourceMappingURL=b.js.map//// [all.js] +//// [all.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; } @@ -59,13 +34,6 @@ define("tests/cases/compiler/b", ["require", "exports", "tests/cases/compiler/re }); //# sourceMappingURL=all.js.map -//// [a.d.ts] -export declare class A { -} -//// [b.d.ts] -import { A } from "./ref/a"; -export declare class B extends A { -} //// [all.d.ts] declare module "tests/cases/compiler/ref/a" { export class A { diff --git a/tests/baselines/reference/outModuleConcatAmd.js.map b/tests/baselines/reference/outModuleConcatAmd.js.map index 88e6fa81885..44cd5ce9955 100644 --- a/tests/baselines/reference/outModuleConcatAmd.js.map +++ b/tests/baselines/reference/outModuleConcatAmd.js.map @@ -1,4 +1,2 @@ -//// [a.js.map] -{"version":3,"file":"a.js","sourceRoot":"","sources":["a.ts"],"names":["A","A.constructor"],"mappings":";IACA;QAAAA;QAAiBC,CAACA;QAADD,QAACA;IAADA,CAACA,AAAlB,IAAkB;IAAL,SAAC,IAAI,CAAA"}//// [b.js.map] -{"version":3,"file":"b.js","sourceRoot":"","sources":["b.ts"],"names":["B","B.constructor"],"mappings":";;;;;;IACA;QAAuBA,qBAACA;QAAxBA;YAAuBC,8BAACA;QAAGA,CAACA;QAADD,QAACA;IAADA,CAACA,AAA5B,EAAuB,KAAC,EAAI;IAAf,SAAC,IAAc,CAAA"}//// [all.js.map] +//// [all.js.map] {"version":3,"file":"all.js","sourceRoot":"","sources":["tests/cases/compiler/ref/a.ts","tests/cases/compiler/b.ts"],"names":["A","A.constructor","B","B.constructor"],"mappings":";;;;;;IACA;QAAAA;QAAiBC,CAACA;QAADD,QAACA;IAADA,CAACA,AAAlB,IAAkB;IAAL,SAAC,IAAI,CAAA;;;ICAlB;QAAuBE,qBAACA;QAAxBA;YAAuBC,8BAACA;QAAGA,CAACA;QAADD,QAACA;IAADA,CAACA,AAA5B,EAAuB,KAAC,EAAI;IAAf,SAAC,IAAc,CAAA"} \ No newline at end of file diff --git a/tests/baselines/reference/outModuleConcatAmd.sourcemap.txt b/tests/baselines/reference/outModuleConcatAmd.sourcemap.txt index 4ec8e34e8e1..eec3a6014aa 100644 --- a/tests/baselines/reference/outModuleConcatAmd.sourcemap.txt +++ b/tests/baselines/reference/outModuleConcatAmd.sourcemap.txt @@ -1,173 +1,4 @@ =================================================================== -JsFile: a.js -mapUrl: a.js.map -sourceRoot: -sources: a.ts -=================================================================== -------------------------------------------------------------------- -emittedFile:tests/cases/compiler/ref/a.js -sourceFile:a.ts -------------------------------------------------------------------- ->>>define(["require", "exports"], function (require, exports) { ->>> var A = (function () { -1 >^^^^ -2 > ^^^^^^^^^^^^^^^^^^^-> -1 > - > -1 >Emitted(2, 5) Source(2, 1) + SourceIndex(0) ---- ->>> function A() { -1->^^^^^^^^ -2 > ^^-> -1-> -1->Emitted(3, 9) Source(2, 1) + SourceIndex(0) name (A) ---- ->>> } -1->^^^^^^^^ -2 > ^ -3 > ^^^^^^^^^-> -1->export class A { -2 > } -1->Emitted(4, 9) Source(2, 18) + SourceIndex(0) name (A.constructor) -2 >Emitted(4, 10) Source(2, 19) + SourceIndex(0) name (A.constructor) ---- ->>> return A; -1->^^^^^^^^ -2 > ^^^^^^^^ -1-> -2 > } -1->Emitted(5, 9) Source(2, 18) + SourceIndex(0) name (A) -2 >Emitted(5, 17) Source(2, 19) + SourceIndex(0) name (A) ---- ->>> })(); -1 >^^^^ -2 > ^ -3 > -4 > ^^^^ -5 > ^^^^^^^^^^-> -1 > -2 > } -3 > -4 > export class A { } -1 >Emitted(6, 5) Source(2, 18) + SourceIndex(0) name (A) -2 >Emitted(6, 6) Source(2, 19) + SourceIndex(0) name (A) -3 >Emitted(6, 6) Source(2, 1) + SourceIndex(0) -4 >Emitted(6, 10) Source(2, 19) + SourceIndex(0) ---- ->>> exports.A = A; -1->^^^^ -2 > ^^^^^^^^^ -3 > ^^^^ -4 > ^ -1-> -2 > A -3 > { } -4 > -1->Emitted(7, 5) Source(2, 14) + SourceIndex(0) -2 >Emitted(7, 14) Source(2, 15) + SourceIndex(0) -3 >Emitted(7, 18) Source(2, 19) + SourceIndex(0) -4 >Emitted(7, 19) Source(2, 19) + SourceIndex(0) ---- ->>>}); ->>>//# sourceMappingURL=a.js.map=================================================================== -JsFile: b.js -mapUrl: b.js.map -sourceRoot: -sources: b.ts -=================================================================== -------------------------------------------------------------------- -emittedFile:tests/cases/compiler/b.js -sourceFile:b.ts -------------------------------------------------------------------- ->>>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 __()); ->>>}; ->>>define(["require", "exports", "./ref/a"], function (require, exports, a_1) { ->>> var B = (function (_super) { -1 >^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 >import {A} from "./ref/a"; - > -1 >Emitted(7, 5) Source(2, 1) + SourceIndex(0) ---- ->>> __extends(B, _super); -1->^^^^^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^^ -1->export class B extends -2 > A -1->Emitted(8, 9) Source(2, 24) + SourceIndex(0) name (B) -2 >Emitted(8, 30) Source(2, 25) + SourceIndex(0) name (B) ---- ->>> function B() { -1 >^^^^^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 > -1 >Emitted(9, 9) Source(2, 1) + SourceIndex(0) name (B) ---- ->>> _super.apply(this, arguments); -1->^^^^^^^^^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -1->export class B extends -2 > A -1->Emitted(10, 13) Source(2, 24) + SourceIndex(0) name (B.constructor) -2 >Emitted(10, 43) Source(2, 25) + SourceIndex(0) name (B.constructor) ---- ->>> } -1 >^^^^^^^^ -2 > ^ -3 > ^^^^^^^^^-> -1 > { -2 > } -1 >Emitted(11, 9) Source(2, 28) + SourceIndex(0) name (B.constructor) -2 >Emitted(11, 10) Source(2, 29) + SourceIndex(0) name (B.constructor) ---- ->>> return B; -1->^^^^^^^^ -2 > ^^^^^^^^ -1-> -2 > } -1->Emitted(12, 9) Source(2, 28) + SourceIndex(0) name (B) -2 >Emitted(12, 17) Source(2, 29) + SourceIndex(0) name (B) ---- ->>> })(a_1.A); -1 >^^^^ -2 > ^ -3 > -4 > ^^ -5 > ^^^^^ -6 > ^^ -7 > ^^^^^-> -1 > -2 > } -3 > -4 > export class B extends -5 > A -6 > { } -1 >Emitted(13, 5) Source(2, 28) + SourceIndex(0) name (B) -2 >Emitted(13, 6) Source(2, 29) + SourceIndex(0) name (B) -3 >Emitted(13, 6) Source(2, 1) + SourceIndex(0) -4 >Emitted(13, 8) Source(2, 24) + SourceIndex(0) -5 >Emitted(13, 13) Source(2, 25) + SourceIndex(0) -6 >Emitted(13, 15) Source(2, 29) + SourceIndex(0) ---- ->>> exports.B = B; -1->^^^^ -2 > ^^^^^^^^^ -3 > ^^^^ -4 > ^ -1-> -2 > B -3 > extends A { } -4 > -1->Emitted(14, 5) Source(2, 14) + SourceIndex(0) -2 >Emitted(14, 14) Source(2, 15) + SourceIndex(0) -3 >Emitted(14, 18) Source(2, 29) + SourceIndex(0) -4 >Emitted(14, 19) Source(2, 29) + SourceIndex(0) ---- ->>>}); ->>>//# sourceMappingURL=b.js.map=================================================================== JsFile: all.js mapUrl: all.js.map sourceRoot: diff --git a/tests/baselines/reference/outModuleConcatCommonjs.js b/tests/baselines/reference/outModuleConcatCommonjs.js index 0f83b4fbe99..c859d6c63ef 100644 --- a/tests/baselines/reference/outModuleConcatCommonjs.js +++ b/tests/baselines/reference/outModuleConcatCommonjs.js @@ -10,30 +10,7 @@ export class A { } import {A} from "./ref/a"; export class B extends A { } -//// [a.js] -// This should be an error -var A = (function () { - function A() { - } - return A; -})(); -exports.A = A; -//# sourceMappingURL=a.js.map//// [b.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 a_1 = require("./ref/a"); -var B = (function (_super) { - __extends(B, _super); - function B() { - _super.apply(this, arguments); - } - return B; -})(a_1.A); -exports.B = B; -//# sourceMappingURL=b.js.map//// [all.js] +//// [all.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; } @@ -42,13 +19,6 @@ var __extends = (this && this.__extends) || function (d, b) { // This should be an error //# sourceMappingURL=all.js.map -//// [a.d.ts] -export declare class A { -} -//// [b.d.ts] -import { A } from "./ref/a"; -export declare class B extends A { -} //// [all.d.ts] declare module "tests/cases/compiler/ref/a" { export class A { diff --git a/tests/baselines/reference/outModuleConcatCommonjs.js.map b/tests/baselines/reference/outModuleConcatCommonjs.js.map index babde662bc1..09646467406 100644 --- a/tests/baselines/reference/outModuleConcatCommonjs.js.map +++ b/tests/baselines/reference/outModuleConcatCommonjs.js.map @@ -1,4 +1,2 @@ -//// [a.js.map] -{"version":3,"file":"a.js","sourceRoot":"","sources":["a.ts"],"names":["A","A.constructor"],"mappings":"AACA,0BAA0B;AAE1B;IAAAA;IAAiBC,CAACA;IAADD,QAACA;AAADA,CAACA,AAAlB,IAAkB;AAAL,SAAC,IAAI,CAAA"}//// [b.js.map] -{"version":3,"file":"b.js","sourceRoot":"","sources":["b.ts"],"names":["B","B.constructor"],"mappings":";;;;;AAAA,kBAAgB,SAAS,CAAC,CAAA;AAC1B;IAAuBA,qBAACA;IAAxBA;QAAuBC,8BAACA;IAAGA,CAACA;IAADD,QAACA;AAADA,CAACA,AAA5B,EAAuB,KAAC,EAAI;AAAf,SAAC,IAAc,CAAA"}//// [all.js.map] +//// [all.js.map] {"version":3,"file":"all.js","sourceRoot":"","sources":["tests/cases/compiler/ref/a.ts","tests/cases/compiler/b.ts"],"names":[],"mappings":";;;;;AACA,0BAA0B"} \ No newline at end of file diff --git a/tests/baselines/reference/outModuleConcatCommonjs.sourcemap.txt b/tests/baselines/reference/outModuleConcatCommonjs.sourcemap.txt index 22dda7ae4bf..698328649e2 100644 --- a/tests/baselines/reference/outModuleConcatCommonjs.sourcemap.txt +++ b/tests/baselines/reference/outModuleConcatCommonjs.sourcemap.txt @@ -1,198 +1,4 @@ =================================================================== -JsFile: a.js -mapUrl: a.js.map -sourceRoot: -sources: a.ts -=================================================================== -------------------------------------------------------------------- -emittedFile:tests/cases/compiler/ref/a.js -sourceFile:a.ts -------------------------------------------------------------------- ->>>// This should be an error -1 > -2 >^^^^^^^^^^^^^^^^^^^^^^^^^^ -1 > - > -2 >// This should be an error -1 >Emitted(1, 1) Source(2, 1) + SourceIndex(0) -2 >Emitted(1, 27) Source(2, 27) + SourceIndex(0) ---- ->>>var A = (function () { -1 > -2 >^^^^^^^^^^^^^^^^^^^-> -1 > - > - > -1 >Emitted(2, 1) Source(4, 1) + SourceIndex(0) ---- ->>> function A() { -1->^^^^ -2 > ^^-> -1-> -1->Emitted(3, 5) Source(4, 1) + SourceIndex(0) name (A) ---- ->>> } -1->^^^^ -2 > ^ -3 > ^^^^^^^^^-> -1->export class A { -2 > } -1->Emitted(4, 5) Source(4, 18) + SourceIndex(0) name (A.constructor) -2 >Emitted(4, 6) Source(4, 19) + SourceIndex(0) name (A.constructor) ---- ->>> return A; -1->^^^^ -2 > ^^^^^^^^ -1-> -2 > } -1->Emitted(5, 5) Source(4, 18) + SourceIndex(0) name (A) -2 >Emitted(5, 13) Source(4, 19) + SourceIndex(0) name (A) ---- ->>>})(); -1 > -2 >^ -3 > -4 > ^^^^ -5 > ^^^^^^^^^^-> -1 > -2 >} -3 > -4 > export class A { } -1 >Emitted(6, 1) Source(4, 18) + SourceIndex(0) name (A) -2 >Emitted(6, 2) Source(4, 19) + SourceIndex(0) name (A) -3 >Emitted(6, 2) Source(4, 1) + SourceIndex(0) -4 >Emitted(6, 6) Source(4, 19) + SourceIndex(0) ---- ->>>exports.A = A; -1-> -2 >^^^^^^^^^ -3 > ^^^^ -4 > ^ -5 > ^^^^^^^^^^^^^^-> -1-> -2 >A -3 > { } -4 > -1->Emitted(7, 1) Source(4, 14) + SourceIndex(0) -2 >Emitted(7, 10) Source(4, 15) + SourceIndex(0) -3 >Emitted(7, 14) Source(4, 19) + SourceIndex(0) -4 >Emitted(7, 15) Source(4, 19) + SourceIndex(0) ---- ->>>//# sourceMappingURL=a.js.map=================================================================== -JsFile: b.js -mapUrl: b.js.map -sourceRoot: -sources: b.ts -=================================================================== -------------------------------------------------------------------- -emittedFile:tests/cases/compiler/b.js -sourceFile:b.ts -------------------------------------------------------------------- ->>>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 a_1 = require("./ref/a"); -1 > -2 >^^^^^^^^^^^^^^^^^^ -3 > ^^^^^^^^^ -4 > ^ -5 > ^ -1 > -2 >import {A} from -3 > "./ref/a" -4 > ; -5 > -1 >Emitted(6, 1) Source(1, 1) + SourceIndex(0) -2 >Emitted(6, 19) Source(1, 17) + SourceIndex(0) -3 >Emitted(6, 28) Source(1, 26) + SourceIndex(0) -4 >Emitted(6, 29) Source(1, 27) + SourceIndex(0) -5 >Emitted(6, 30) Source(1, 27) + SourceIndex(0) ---- ->>>var B = (function (_super) { -1 > -2 >^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -1 >Emitted(7, 1) Source(2, 1) + SourceIndex(0) ---- ->>> __extends(B, _super); -1->^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^^ -1->export class B extends -2 > A -1->Emitted(8, 5) Source(2, 24) + SourceIndex(0) name (B) -2 >Emitted(8, 26) Source(2, 25) + SourceIndex(0) name (B) ---- ->>> function B() { -1 >^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 > -1 >Emitted(9, 5) Source(2, 1) + SourceIndex(0) name (B) ---- ->>> _super.apply(this, arguments); -1->^^^^^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -1->export class B extends -2 > A -1->Emitted(10, 9) Source(2, 24) + SourceIndex(0) name (B.constructor) -2 >Emitted(10, 39) Source(2, 25) + SourceIndex(0) name (B.constructor) ---- ->>> } -1 >^^^^ -2 > ^ -3 > ^^^^^^^^^-> -1 > { -2 > } -1 >Emitted(11, 5) Source(2, 28) + SourceIndex(0) name (B.constructor) -2 >Emitted(11, 6) Source(2, 29) + SourceIndex(0) name (B.constructor) ---- ->>> return B; -1->^^^^ -2 > ^^^^^^^^ -1-> -2 > } -1->Emitted(12, 5) Source(2, 28) + SourceIndex(0) name (B) -2 >Emitted(12, 13) Source(2, 29) + SourceIndex(0) name (B) ---- ->>>})(a_1.A); -1 > -2 >^ -3 > -4 > ^^ -5 > ^^^^^ -6 > ^^ -7 > ^^^^^-> -1 > -2 >} -3 > -4 > export class B extends -5 > A -6 > { } -1 >Emitted(13, 1) Source(2, 28) + SourceIndex(0) name (B) -2 >Emitted(13, 2) Source(2, 29) + SourceIndex(0) name (B) -3 >Emitted(13, 2) Source(2, 1) + SourceIndex(0) -4 >Emitted(13, 4) Source(2, 24) + SourceIndex(0) -5 >Emitted(13, 9) Source(2, 25) + SourceIndex(0) -6 >Emitted(13, 11) Source(2, 29) + SourceIndex(0) ---- ->>>exports.B = B; -1-> -2 >^^^^^^^^^ -3 > ^^^^ -4 > ^ -5 > ^^^^^^^^^^^^^^-> -1-> -2 >B -3 > extends A { } -4 > -1->Emitted(14, 1) Source(2, 14) + SourceIndex(0) -2 >Emitted(14, 10) Source(2, 15) + SourceIndex(0) -3 >Emitted(14, 14) Source(2, 29) + SourceIndex(0) -4 >Emitted(14, 15) Source(2, 29) + SourceIndex(0) ---- ->>>//# sourceMappingURL=b.js.map=================================================================== JsFile: all.js mapUrl: all.js.map sourceRoot: diff --git a/tests/baselines/reference/outModuleConcatES6.js b/tests/baselines/reference/outModuleConcatES6.js index c8db9e083b6..037d52eb410 100644 --- a/tests/baselines/reference/outModuleConcatES6.js +++ b/tests/baselines/reference/outModuleConcatES6.js @@ -10,25 +10,10 @@ export class A { } import {A} from "./ref/a"; export class B extends A { } -//// [a.js] -// This should be an error -export class A { -} -//# sourceMappingURL=a.js.map//// [b.js] -import { A } from "./ref/a"; -export class B extends A { -} -//# sourceMappingURL=b.js.map//// [all.js] +//// [all.js] // This should be an error //# sourceMappingURL=all.js.map -//// [a.d.ts] -export declare class A { -} -//// [b.d.ts] -import { A } from "./ref/a"; -export declare class B extends A { -} //// [all.d.ts] declare module "tests/cases/compiler/ref/a" { export class A { diff --git a/tests/baselines/reference/outModuleConcatES6.js.map b/tests/baselines/reference/outModuleConcatES6.js.map index 347b15b38f3..bd3e6f58731 100644 --- a/tests/baselines/reference/outModuleConcatES6.js.map +++ b/tests/baselines/reference/outModuleConcatES6.js.map @@ -1,4 +1,2 @@ -//// [a.js.map] -{"version":3,"file":"a.js","sourceRoot":"","sources":["a.ts"],"names":["A"],"mappings":"AACA,0BAA0B;AAE1B;AAAiBA,CAACA;AAAA"}//// [b.js.map] -{"version":3,"file":"b.js","sourceRoot":"","sources":["b.ts"],"names":["B"],"mappings":"OAAO,EAAC,CAAC,EAAC,MAAM,SAAS;AACzB,uBAAuB,CAAC;AAAGA,CAACA;AAAA"}//// [all.js.map] +//// [all.js.map] {"version":3,"file":"all.js","sourceRoot":"","sources":["tests/cases/compiler/ref/a.ts","tests/cases/compiler/b.ts"],"names":[],"mappings":"AACA,0BAA0B"} \ No newline at end of file diff --git a/tests/baselines/reference/outModuleConcatES6.sourcemap.txt b/tests/baselines/reference/outModuleConcatES6.sourcemap.txt index 239dff14456..78b6e98ac15 100644 --- a/tests/baselines/reference/outModuleConcatES6.sourcemap.txt +++ b/tests/baselines/reference/outModuleConcatES6.sourcemap.txt @@ -1,101 +1,4 @@ =================================================================== -JsFile: a.js -mapUrl: a.js.map -sourceRoot: -sources: a.ts -=================================================================== -------------------------------------------------------------------- -emittedFile:tests/cases/compiler/ref/a.js -sourceFile:a.ts -------------------------------------------------------------------- ->>>// This should be an error -1 > -2 >^^^^^^^^^^^^^^^^^^^^^^^^^^ -1 > - > -2 >// This should be an error -1 >Emitted(1, 1) Source(2, 1) + SourceIndex(0) -2 >Emitted(1, 27) Source(2, 27) + SourceIndex(0) ---- ->>>export class A { -1 > -2 >^^-> -1 > - > - > -1 >Emitted(2, 1) Source(4, 1) + SourceIndex(0) ---- ->>>} -1-> -2 >^ -3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1->export class A { -2 >} -1->Emitted(3, 1) Source(4, 18) + SourceIndex(0) name (A) -2 >Emitted(3, 2) Source(4, 19) + SourceIndex(0) name (A) ---- ->>>//# sourceMappingURL=a.js.map1-> -2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1-> -1->Emitted(4, 1) Source(4, 19) + SourceIndex(0) ---- -=================================================================== -JsFile: b.js -mapUrl: b.js.map -sourceRoot: -sources: b.ts -=================================================================== -------------------------------------------------------------------- -emittedFile:tests/cases/compiler/b.js -sourceFile:b.ts -------------------------------------------------------------------- ->>>import { A } from "./ref/a"; -1 >^^^^^^^ -2 > ^^ -3 > ^ -4 > ^^ -5 > ^^^^^^ -6 > ^^^^^^^^^ -1 >import -2 > { -3 > A -4 > } -5 > from -6 > "./ref/a" -1 >Emitted(1, 8) Source(1, 8) + SourceIndex(0) -2 >Emitted(1, 10) Source(1, 9) + SourceIndex(0) -3 >Emitted(1, 11) Source(1, 10) + SourceIndex(0) -4 >Emitted(1, 13) Source(1, 11) + SourceIndex(0) -5 >Emitted(1, 19) Source(1, 17) + SourceIndex(0) -6 >Emitted(1, 28) Source(1, 26) + SourceIndex(0) ---- ->>>export class B extends A { -1 > -2 >^^^^^^^^^^^^^^^^^^^^^^^ -3 > ^ -1 >; - > -2 >export class B extends -3 > A -1 >Emitted(2, 1) Source(2, 1) + SourceIndex(0) -2 >Emitted(2, 24) Source(2, 24) + SourceIndex(0) -3 >Emitted(2, 25) Source(2, 25) + SourceIndex(0) ---- ->>>} -1 > -2 >^ -3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 > { -2 >} -1 >Emitted(3, 1) Source(2, 28) + SourceIndex(0) name (B) -2 >Emitted(3, 2) Source(2, 29) + SourceIndex(0) name (B) ---- ->>>//# sourceMappingURL=b.js.map1-> -2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1-> -1->Emitted(4, 1) Source(2, 29) + SourceIndex(0) ---- -=================================================================== JsFile: all.js mapUrl: all.js.map sourceRoot: diff --git a/tests/baselines/reference/outModuleConcatSystem.js b/tests/baselines/reference/outModuleConcatSystem.js index 970ea4b3d6d..1f8bdbd8070 100644 --- a/tests/baselines/reference/outModuleConcatSystem.js +++ b/tests/baselines/reference/outModuleConcatSystem.js @@ -8,48 +8,7 @@ export class A { } import {A} from "./ref/a"; export class B extends A { } -//// [a.js] -System.register([], function(exports_1) { - var A; - return { - setters:[], - execute: function() { - A = (function () { - function A() { - } - return A; - })(); - exports_1("A", A); - } - } -}); -//# sourceMappingURL=a.js.map//// [b.js] -System.register(["./ref/a"], function(exports_1) { - 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 a_1; - var B; - return { - setters:[ - function (a_1_1) { - a_1 = a_1_1; - }], - execute: function() { - B = (function (_super) { - __extends(B, _super); - function B() { - _super.apply(this, arguments); - } - return B; - })(a_1.A); - exports_1("B", B); - } - } -}); -//# sourceMappingURL=b.js.map//// [all.js] +//// [all.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; } @@ -91,13 +50,6 @@ System.register("tests/cases/compiler/b", ["tests/cases/compiler/ref/a"], functi }); //# sourceMappingURL=all.js.map -//// [a.d.ts] -export declare class A { -} -//// [b.d.ts] -import { A } from "./ref/a"; -export declare class B extends A { -} //// [all.d.ts] declare module "tests/cases/compiler/ref/a" { export class A { diff --git a/tests/baselines/reference/outModuleConcatSystem.js.map b/tests/baselines/reference/outModuleConcatSystem.js.map index a74b131da99..77ff05f84fb 100644 --- a/tests/baselines/reference/outModuleConcatSystem.js.map +++ b/tests/baselines/reference/outModuleConcatSystem.js.map @@ -1,4 +1,2 @@ -//// [a.js.map] -{"version":3,"file":"a.js","sourceRoot":"","sources":["a.ts"],"names":["A","A.constructor"],"mappings":";;;;;YACA;gBAAAA;gBAAiBC,CAACA;gBAADD,QAACA;YAADA,CAACA,AAAlB,IAAkB;YAAlB,iBAAkB,CAAA"}//// [b.js.map] -{"version":3,"file":"b.js","sourceRoot":"","sources":["b.ts"],"names":["B","B.constructor"],"mappings":";;;;;;;;;;;;;;YACA;gBAAuBA,qBAACA;gBAAxBA;oBAAuBC,8BAACA;gBAAGA,CAACA;gBAADD,QAACA;YAADA,CAACA,AAA5B,EAAuB,KAAC,EAAI;YAA5B,iBAA4B,CAAA"}//// [all.js.map] +//// [all.js.map] {"version":3,"file":"all.js","sourceRoot":"","sources":["tests/cases/compiler/ref/a.ts","tests/cases/compiler/b.ts"],"names":["A","A.constructor","B","B.constructor"],"mappings":";;;;;;;;;;YACA;gBAAAA;gBAAiBC,CAACA;gBAADD,QAACA;YAADA,CAACA,AAAlB,IAAkB;YAAlB,iBAAkB,CAAA;;;;;;;;;;;;;YCAlB;gBAAuBE,qBAACA;gBAAxBA;oBAAuBC,8BAACA;gBAAGA,CAACA;gBAADD,QAACA;YAADA,CAACA,AAA5B,EAAuB,KAAC,EAAI;YAA5B,iBAA4B,CAAA"} \ No newline at end of file diff --git a/tests/baselines/reference/outModuleConcatSystem.sourcemap.txt b/tests/baselines/reference/outModuleConcatSystem.sourcemap.txt index e717c3f677b..489487772db 100644 --- a/tests/baselines/reference/outModuleConcatSystem.sourcemap.txt +++ b/tests/baselines/reference/outModuleConcatSystem.sourcemap.txt @@ -1,183 +1,4 @@ =================================================================== -JsFile: a.js -mapUrl: a.js.map -sourceRoot: -sources: a.ts -=================================================================== -------------------------------------------------------------------- -emittedFile:tests/cases/compiler/ref/a.js -sourceFile:a.ts -------------------------------------------------------------------- ->>>System.register([], function(exports_1) { ->>> var A; ->>> return { ->>> setters:[], ->>> execute: function() { ->>> A = (function () { -1 >^^^^^^^^^^^^ -2 > ^^^^^^^^^^^^^^^^^^^-> -1 > - > -1 >Emitted(6, 13) Source(2, 1) + SourceIndex(0) ---- ->>> function A() { -1->^^^^^^^^^^^^^^^^ -2 > ^^-> -1-> -1->Emitted(7, 17) Source(2, 1) + SourceIndex(0) name (A) ---- ->>> } -1->^^^^^^^^^^^^^^^^ -2 > ^ -3 > ^^^^^^^^^-> -1->export class A { -2 > } -1->Emitted(8, 17) Source(2, 18) + SourceIndex(0) name (A.constructor) -2 >Emitted(8, 18) Source(2, 19) + SourceIndex(0) name (A.constructor) ---- ->>> return A; -1->^^^^^^^^^^^^^^^^ -2 > ^^^^^^^^ -1-> -2 > } -1->Emitted(9, 17) Source(2, 18) + SourceIndex(0) name (A) -2 >Emitted(9, 25) Source(2, 19) + SourceIndex(0) name (A) ---- ->>> })(); -1 >^^^^^^^^^^^^ -2 > ^ -3 > -4 > ^^^^ -5 > ^^^^^^^^^^^^^^-> -1 > -2 > } -3 > -4 > export class A { } -1 >Emitted(10, 13) Source(2, 18) + SourceIndex(0) name (A) -2 >Emitted(10, 14) Source(2, 19) + SourceIndex(0) name (A) -3 >Emitted(10, 14) Source(2, 1) + SourceIndex(0) -4 >Emitted(10, 18) Source(2, 19) + SourceIndex(0) ---- ->>> exports_1("A", A); -1->^^^^^^^^^^^^ -2 > ^^^^^^^^^^^^^^^^^ -3 > ^ -1-> -2 > export class A { } -3 > -1->Emitted(11, 13) Source(2, 1) + SourceIndex(0) -2 >Emitted(11, 30) Source(2, 19) + SourceIndex(0) -3 >Emitted(11, 31) Source(2, 19) + SourceIndex(0) ---- ->>> } ->>> } ->>>}); ->>>//# sourceMappingURL=a.js.map=================================================================== -JsFile: b.js -mapUrl: b.js.map -sourceRoot: -sources: b.ts -=================================================================== -------------------------------------------------------------------- -emittedFile:tests/cases/compiler/b.js -sourceFile:b.ts -------------------------------------------------------------------- ->>>System.register(["./ref/a"], function(exports_1) { ->>> 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 a_1; ->>> var B; ->>> return { ->>> setters:[ ->>> function (a_1_1) { ->>> a_1 = a_1_1; ->>> }], ->>> execute: function() { ->>> B = (function (_super) { -1 >^^^^^^^^^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 >import {A} from "./ref/a"; - > -1 >Emitted(15, 13) Source(2, 1) + SourceIndex(0) ---- ->>> __extends(B, _super); -1->^^^^^^^^^^^^^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^^ -1->export class B extends -2 > A -1->Emitted(16, 17) Source(2, 24) + SourceIndex(0) name (B) -2 >Emitted(16, 38) Source(2, 25) + SourceIndex(0) name (B) ---- ->>> function B() { -1 >^^^^^^^^^^^^^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 > -1 >Emitted(17, 17) Source(2, 1) + SourceIndex(0) name (B) ---- ->>> _super.apply(this, arguments); -1->^^^^^^^^^^^^^^^^^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -1->export class B extends -2 > A -1->Emitted(18, 21) Source(2, 24) + SourceIndex(0) name (B.constructor) -2 >Emitted(18, 51) Source(2, 25) + SourceIndex(0) name (B.constructor) ---- ->>> } -1 >^^^^^^^^^^^^^^^^ -2 > ^ -3 > ^^^^^^^^^-> -1 > { -2 > } -1 >Emitted(19, 17) Source(2, 28) + SourceIndex(0) name (B.constructor) -2 >Emitted(19, 18) Source(2, 29) + SourceIndex(0) name (B.constructor) ---- ->>> return B; -1->^^^^^^^^^^^^^^^^ -2 > ^^^^^^^^ -1-> -2 > } -1->Emitted(20, 17) Source(2, 28) + SourceIndex(0) name (B) -2 >Emitted(20, 25) Source(2, 29) + SourceIndex(0) name (B) ---- ->>> })(a_1.A); -1 >^^^^^^^^^^^^ -2 > ^ -3 > -4 > ^^ -5 > ^^^^^ -6 > ^^ -7 > ^^^^^^^^^-> -1 > -2 > } -3 > -4 > export class B extends -5 > A -6 > { } -1 >Emitted(21, 13) Source(2, 28) + SourceIndex(0) name (B) -2 >Emitted(21, 14) Source(2, 29) + SourceIndex(0) name (B) -3 >Emitted(21, 14) Source(2, 1) + SourceIndex(0) -4 >Emitted(21, 16) Source(2, 24) + SourceIndex(0) -5 >Emitted(21, 21) Source(2, 25) + SourceIndex(0) -6 >Emitted(21, 23) Source(2, 29) + SourceIndex(0) ---- ->>> exports_1("B", B); -1->^^^^^^^^^^^^ -2 > ^^^^^^^^^^^^^^^^^ -3 > ^ -1-> -2 > export class B extends A { } -3 > -1->Emitted(22, 13) Source(2, 1) + SourceIndex(0) -2 >Emitted(22, 30) Source(2, 29) + SourceIndex(0) -3 >Emitted(22, 31) Source(2, 29) + SourceIndex(0) ---- ->>> } ->>> } ->>>}); ->>>//# sourceMappingURL=b.js.map=================================================================== JsFile: all.js mapUrl: all.js.map sourceRoot: diff --git a/tests/baselines/reference/outModuleConcatUmd.js b/tests/baselines/reference/outModuleConcatUmd.js index b94617a19d8..c4aad41c6ed 100644 --- a/tests/baselines/reference/outModuleConcatUmd.js +++ b/tests/baselines/reference/outModuleConcatUmd.js @@ -10,48 +10,7 @@ export class A { } import {A} from "./ref/a"; export class B extends A { } -//// [a.js] -// This should error -(function (factory) { - if (typeof module === 'object' && typeof module.exports === 'object') { - var v = factory(require, exports); if (v !== undefined) module.exports = v; - } - else if (typeof define === 'function' && define.amd) { - define(["require", "exports"], factory); - } -})(function (require, exports) { - var A = (function () { - function A() { - } - return A; - })(); - exports.A = A; -}); -//# sourceMappingURL=a.js.map//// [b.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 __()); -}; -(function (factory) { - if (typeof module === 'object' && typeof module.exports === 'object') { - var v = factory(require, exports); if (v !== undefined) module.exports = v; - } - else if (typeof define === 'function' && define.amd) { - define(["require", "exports", "./ref/a"], factory); - } -})(function (require, exports) { - var a_1 = require("./ref/a"); - var B = (function (_super) { - __extends(B, _super); - function B() { - _super.apply(this, arguments); - } - return B; - })(a_1.A); - exports.B = B; -}); -//# sourceMappingURL=b.js.map//// [all.js] +//// [all.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; } @@ -60,13 +19,6 @@ var __extends = (this && this.__extends) || function (d, b) { // This should error //# sourceMappingURL=all.js.map -//// [a.d.ts] -export declare class A { -} -//// [b.d.ts] -import { A } from "./ref/a"; -export declare class B extends A { -} //// [all.d.ts] declare module "tests/cases/compiler/ref/a" { export class A { diff --git a/tests/baselines/reference/outModuleConcatUmd.js.map b/tests/baselines/reference/outModuleConcatUmd.js.map index b00a2c1c187..7a9fcd77bdf 100644 --- a/tests/baselines/reference/outModuleConcatUmd.js.map +++ b/tests/baselines/reference/outModuleConcatUmd.js.map @@ -1,4 +1,2 @@ -//// [a.js.map] -{"version":3,"file":"a.js","sourceRoot":"","sources":["a.ts"],"names":["A","A.constructor"],"mappings":"AACA,oBAAoB;;;;;;;;;IAEpB;QAAAA;QAAiBC,CAACA;QAADD,QAACA;IAADA,CAACA,AAAlB,IAAkB;IAAL,SAAC,IAAI,CAAA"}//// [b.js.map] -{"version":3,"file":"b.js","sourceRoot":"","sources":["b.ts"],"names":["B","B.constructor"],"mappings":";;;;;;;;;;;;;IAAA,kBAAgB,SAAS,CAAC,CAAA;IAC1B;QAAuBA,qBAACA;QAAxBA;YAAuBC,8BAACA;QAAGA,CAACA;QAADD,QAACA;IAADA,CAACA,AAA5B,EAAuB,KAAC,EAAI;IAAf,SAAC,IAAc,CAAA"}//// [all.js.map] +//// [all.js.map] {"version":3,"file":"all.js","sourceRoot":"","sources":["tests/cases/compiler/ref/a.ts","tests/cases/compiler/b.ts"],"names":[],"mappings":";;;;;AACA,oBAAoB"} \ No newline at end of file diff --git a/tests/baselines/reference/outModuleConcatUmd.sourcemap.txt b/tests/baselines/reference/outModuleConcatUmd.sourcemap.txt index 9749e38cc40..d2fbe17fe65 100644 --- a/tests/baselines/reference/outModuleConcatUmd.sourcemap.txt +++ b/tests/baselines/reference/outModuleConcatUmd.sourcemap.txt @@ -1,215 +1,4 @@ =================================================================== -JsFile: a.js -mapUrl: a.js.map -sourceRoot: -sources: a.ts -=================================================================== -------------------------------------------------------------------- -emittedFile:tests/cases/compiler/ref/a.js -sourceFile:a.ts -------------------------------------------------------------------- ->>>// This should error -1 > -2 >^^^^^^^^^^^^^^^^^^^^ -3 > ^^-> -1 > - > -2 >// This should error -1 >Emitted(1, 1) Source(2, 1) + SourceIndex(0) -2 >Emitted(1, 21) Source(2, 21) + SourceIndex(0) ---- ->>>(function (factory) { ->>> if (typeof module === 'object' && typeof module.exports === 'object') { ->>> var v = factory(require, exports); if (v !== undefined) module.exports = v; ->>> } ->>> else if (typeof define === 'function' && define.amd) { ->>> define(["require", "exports"], factory); ->>> } ->>>})(function (require, exports) { ->>> var A = (function () { -1->^^^^ -2 > ^^^^^^^^^^^^^^^^^^^-> -1-> - > - > -1->Emitted(10, 5) Source(4, 1) + SourceIndex(0) ---- ->>> function A() { -1->^^^^^^^^ -2 > ^^-> -1-> -1->Emitted(11, 9) Source(4, 1) + SourceIndex(0) name (A) ---- ->>> } -1->^^^^^^^^ -2 > ^ -3 > ^^^^^^^^^-> -1->export class A { -2 > } -1->Emitted(12, 9) Source(4, 18) + SourceIndex(0) name (A.constructor) -2 >Emitted(12, 10) Source(4, 19) + SourceIndex(0) name (A.constructor) ---- ->>> return A; -1->^^^^^^^^ -2 > ^^^^^^^^ -1-> -2 > } -1->Emitted(13, 9) Source(4, 18) + SourceIndex(0) name (A) -2 >Emitted(13, 17) Source(4, 19) + SourceIndex(0) name (A) ---- ->>> })(); -1 >^^^^ -2 > ^ -3 > -4 > ^^^^ -5 > ^^^^^^^^^^-> -1 > -2 > } -3 > -4 > export class A { } -1 >Emitted(14, 5) Source(4, 18) + SourceIndex(0) name (A) -2 >Emitted(14, 6) Source(4, 19) + SourceIndex(0) name (A) -3 >Emitted(14, 6) Source(4, 1) + SourceIndex(0) -4 >Emitted(14, 10) Source(4, 19) + SourceIndex(0) ---- ->>> exports.A = A; -1->^^^^ -2 > ^^^^^^^^^ -3 > ^^^^ -4 > ^ -1-> -2 > A -3 > { } -4 > -1->Emitted(15, 5) Source(4, 14) + SourceIndex(0) -2 >Emitted(15, 14) Source(4, 15) + SourceIndex(0) -3 >Emitted(15, 18) Source(4, 19) + SourceIndex(0) -4 >Emitted(15, 19) Source(4, 19) + SourceIndex(0) ---- ->>>}); ->>>//# sourceMappingURL=a.js.map=================================================================== -JsFile: b.js -mapUrl: b.js.map -sourceRoot: -sources: b.ts -=================================================================== -------------------------------------------------------------------- -emittedFile:tests/cases/compiler/b.js -sourceFile:b.ts -------------------------------------------------------------------- ->>>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 __()); ->>>}; ->>>(function (factory) { ->>> if (typeof module === 'object' && typeof module.exports === 'object') { ->>> var v = factory(require, exports); if (v !== undefined) module.exports = v; ->>> } ->>> else if (typeof define === 'function' && define.amd) { ->>> define(["require", "exports", "./ref/a"], factory); ->>> } ->>>})(function (require, exports) { ->>> var a_1 = require("./ref/a"); -1 >^^^^ -2 > ^^^^^^^^^^^^^^^^^^ -3 > ^^^^^^^^^ -4 > ^ -5 > ^ -1 > -2 > import {A} from -3 > "./ref/a" -4 > ; -5 > -1 >Emitted(14, 5) Source(1, 1) + SourceIndex(0) -2 >Emitted(14, 23) Source(1, 17) + SourceIndex(0) -3 >Emitted(14, 32) Source(1, 26) + SourceIndex(0) -4 >Emitted(14, 33) Source(1, 27) + SourceIndex(0) -5 >Emitted(14, 34) Source(1, 27) + SourceIndex(0) ---- ->>> var B = (function (_super) { -1 >^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -1 >Emitted(15, 5) Source(2, 1) + SourceIndex(0) ---- ->>> __extends(B, _super); -1->^^^^^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^^ -1->export class B extends -2 > A -1->Emitted(16, 9) Source(2, 24) + SourceIndex(0) name (B) -2 >Emitted(16, 30) Source(2, 25) + SourceIndex(0) name (B) ---- ->>> function B() { -1 >^^^^^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 > -1 >Emitted(17, 9) Source(2, 1) + SourceIndex(0) name (B) ---- ->>> _super.apply(this, arguments); -1->^^^^^^^^^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -1->export class B extends -2 > A -1->Emitted(18, 13) Source(2, 24) + SourceIndex(0) name (B.constructor) -2 >Emitted(18, 43) Source(2, 25) + SourceIndex(0) name (B.constructor) ---- ->>> } -1 >^^^^^^^^ -2 > ^ -3 > ^^^^^^^^^-> -1 > { -2 > } -1 >Emitted(19, 9) Source(2, 28) + SourceIndex(0) name (B.constructor) -2 >Emitted(19, 10) Source(2, 29) + SourceIndex(0) name (B.constructor) ---- ->>> return B; -1->^^^^^^^^ -2 > ^^^^^^^^ -1-> -2 > } -1->Emitted(20, 9) Source(2, 28) + SourceIndex(0) name (B) -2 >Emitted(20, 17) Source(2, 29) + SourceIndex(0) name (B) ---- ->>> })(a_1.A); -1 >^^^^ -2 > ^ -3 > -4 > ^^ -5 > ^^^^^ -6 > ^^ -7 > ^^^^^-> -1 > -2 > } -3 > -4 > export class B extends -5 > A -6 > { } -1 >Emitted(21, 5) Source(2, 28) + SourceIndex(0) name (B) -2 >Emitted(21, 6) Source(2, 29) + SourceIndex(0) name (B) -3 >Emitted(21, 6) Source(2, 1) + SourceIndex(0) -4 >Emitted(21, 8) Source(2, 24) + SourceIndex(0) -5 >Emitted(21, 13) Source(2, 25) + SourceIndex(0) -6 >Emitted(21, 15) Source(2, 29) + SourceIndex(0) ---- ->>> exports.B = B; -1->^^^^ -2 > ^^^^^^^^^ -3 > ^^^^ -4 > ^ -1-> -2 > B -3 > extends A { } -4 > -1->Emitted(22, 5) Source(2, 14) + SourceIndex(0) -2 >Emitted(22, 14) Source(2, 15) + SourceIndex(0) -3 >Emitted(22, 18) Source(2, 29) + SourceIndex(0) -4 >Emitted(22, 19) Source(2, 29) + SourceIndex(0) ---- ->>>}); ->>>//# sourceMappingURL=b.js.map=================================================================== JsFile: all.js mapUrl: all.js.map sourceRoot: diff --git a/tests/baselines/reference/outModuleTripleSlashRefs.js b/tests/baselines/reference/outModuleTripleSlashRefs.js index dc0cdb22ddd..ae4ac43b5c9 100644 --- a/tests/baselines/reference/outModuleTripleSlashRefs.js +++ b/tests/baselines/reference/outModuleTripleSlashRefs.js @@ -30,33 +30,7 @@ import {A} from "./ref/a"; export class B extends A { } -//// [a.js] -define(["require", "exports"], function (require, exports) { - /// - var A = (function () { - function A() { - } - return A; - })(); - exports.A = A; -}); -//# sourceMappingURL=a.js.map//// [b.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 __()); -}; -define(["require", "exports", "./ref/a"], function (require, exports, a_1) { - var B = (function (_super) { - __extends(B, _super); - function B() { - _super.apply(this, arguments); - } - return B; - })(a_1.A); - exports.B = B; -}); -//# sourceMappingURL=b.js.map//// [all.js] +//// [all.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; } @@ -89,15 +63,6 @@ define("tests/cases/compiler/b", ["require", "exports", "tests/cases/compiler/re }); //# sourceMappingURL=all.js.map -//// [a.d.ts] -/// -export declare class A { - member: typeof GlobalFoo; -} -//// [b.d.ts] -import { A } from "./ref/a"; -export declare class B extends A { -} //// [all.d.ts] /// declare class Foo { diff --git a/tests/baselines/reference/outModuleTripleSlashRefs.js.map b/tests/baselines/reference/outModuleTripleSlashRefs.js.map index 0eeee4a82d5..711163a76e8 100644 --- a/tests/baselines/reference/outModuleTripleSlashRefs.js.map +++ b/tests/baselines/reference/outModuleTripleSlashRefs.js.map @@ -1,4 +1,2 @@ -//// [a.js.map] -{"version":3,"file":"a.js","sourceRoot":"","sources":["a.ts"],"names":["A","A.constructor"],"mappings":";IACA,+BAA+B;IAC/B;QAAAA;QAEAC,CAACA;QAADD,QAACA;IAADA,CAACA,AAFD,IAEC;IAFY,SAAC,IAEb,CAAA"}//// [b.js.map] -{"version":3,"file":"b.js","sourceRoot":"","sources":["b.ts"],"names":["B","B.constructor"],"mappings":";;;;;;IACA;QAAuBA,qBAACA;QAAxBA;YAAuBC,8BAACA;QAAGA,CAACA;QAADD,QAACA;IAADA,CAACA,AAA5B,EAAuB,KAAC,EAAI;IAAf,SAAC,IAAc,CAAA"}//// [all.js.map] +//// [all.js.map] {"version":3,"file":"all.js","sourceRoot":"","sources":["tests/cases/compiler/ref/b.ts","tests/cases/compiler/ref/a.ts","tests/cases/compiler/b.ts"],"names":["Foo","Foo.constructor","A","A.constructor","B","B.constructor"],"mappings":";;;;;AAAA,iCAAiC;AACjC;IAAAA;IAEAC,CAACA;IAADD,UAACA;AAADA,CAACA,AAFD,IAEC;;ICFD,+BAA+B;IAC/B;QAAAE;QAEAC,CAACA;QAADD,QAACA;IAADA,CAACA,AAFD,IAEC;IAFY,SAAC,IAEb,CAAA;;;ICHD;QAAuBE,qBAACA;QAAxBA;YAAuBC,8BAACA;QAAGA,CAACA;QAADD,QAACA;IAADA,CAACA,AAA5B,EAAuB,KAAC,EAAI;IAAf,SAAC,IAAc,CAAA"} \ No newline at end of file diff --git a/tests/baselines/reference/outModuleTripleSlashRefs.sourcemap.txt b/tests/baselines/reference/outModuleTripleSlashRefs.sourcemap.txt index 6e9070cbe04..c95eb22cb10 100644 --- a/tests/baselines/reference/outModuleTripleSlashRefs.sourcemap.txt +++ b/tests/baselines/reference/outModuleTripleSlashRefs.sourcemap.txt @@ -1,188 +1,4 @@ =================================================================== -JsFile: a.js -mapUrl: a.js.map -sourceRoot: -sources: a.ts -=================================================================== -------------------------------------------------------------------- -emittedFile:tests/cases/compiler/ref/a.js -sourceFile:a.ts -------------------------------------------------------------------- ->>>define(["require", "exports"], function (require, exports) { ->>> /// -1 >^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -1 > - > -2 > /// -1 >Emitted(2, 5) Source(2, 1) + SourceIndex(0) -2 >Emitted(2, 36) Source(2, 32) + SourceIndex(0) ---- ->>> var A = (function () { -1 >^^^^ -2 > ^^^^^^^^^^^^^^^^^^^-> -1 > - > -1 >Emitted(3, 5) Source(3, 1) + SourceIndex(0) ---- ->>> function A() { -1->^^^^^^^^ -2 > ^^-> -1-> -1->Emitted(4, 9) Source(3, 1) + SourceIndex(0) name (A) ---- ->>> } -1->^^^^^^^^ -2 > ^ -3 > ^^^^^^^^^-> -1->export class A { - > member: typeof GlobalFoo; - > -2 > } -1->Emitted(5, 9) Source(5, 1) + SourceIndex(0) name (A.constructor) -2 >Emitted(5, 10) Source(5, 2) + SourceIndex(0) name (A.constructor) ---- ->>> return A; -1->^^^^^^^^ -2 > ^^^^^^^^ -1-> -2 > } -1->Emitted(6, 9) Source(5, 1) + SourceIndex(0) name (A) -2 >Emitted(6, 17) Source(5, 2) + SourceIndex(0) name (A) ---- ->>> })(); -1 >^^^^ -2 > ^ -3 > -4 > ^^^^ -5 > ^^^^^^^^^^-> -1 > -2 > } -3 > -4 > export class A { - > member: typeof GlobalFoo; - > } -1 >Emitted(7, 5) Source(5, 1) + SourceIndex(0) name (A) -2 >Emitted(7, 6) Source(5, 2) + SourceIndex(0) name (A) -3 >Emitted(7, 6) Source(3, 1) + SourceIndex(0) -4 >Emitted(7, 10) Source(5, 2) + SourceIndex(0) ---- ->>> exports.A = A; -1->^^^^ -2 > ^^^^^^^^^ -3 > ^^^^ -4 > ^ -1-> -2 > A -3 > { - > member: typeof GlobalFoo; - > } -4 > -1->Emitted(8, 5) Source(3, 14) + SourceIndex(0) -2 >Emitted(8, 14) Source(3, 15) + SourceIndex(0) -3 >Emitted(8, 18) Source(5, 2) + SourceIndex(0) -4 >Emitted(8, 19) Source(5, 2) + SourceIndex(0) ---- ->>>}); ->>>//# sourceMappingURL=a.js.map=================================================================== -JsFile: b.js -mapUrl: b.js.map -sourceRoot: -sources: b.ts -=================================================================== -------------------------------------------------------------------- -emittedFile:tests/cases/compiler/b.js -sourceFile:b.ts -------------------------------------------------------------------- ->>>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 __()); ->>>}; ->>>define(["require", "exports", "./ref/a"], function (require, exports, a_1) { ->>> var B = (function (_super) { -1 >^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 >import {A} from "./ref/a"; - > -1 >Emitted(7, 5) Source(2, 1) + SourceIndex(0) ---- ->>> __extends(B, _super); -1->^^^^^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^^ -1->export class B extends -2 > A -1->Emitted(8, 9) Source(2, 24) + SourceIndex(0) name (B) -2 >Emitted(8, 30) Source(2, 25) + SourceIndex(0) name (B) ---- ->>> function B() { -1 >^^^^^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 > -1 >Emitted(9, 9) Source(2, 1) + SourceIndex(0) name (B) ---- ->>> _super.apply(this, arguments); -1->^^^^^^^^^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -1->export class B extends -2 > A -1->Emitted(10, 13) Source(2, 24) + SourceIndex(0) name (B.constructor) -2 >Emitted(10, 43) Source(2, 25) + SourceIndex(0) name (B.constructor) ---- ->>> } -1 >^^^^^^^^ -2 > ^ -3 > ^^^^^^^^^-> -1 > { -2 > } -1 >Emitted(11, 9) Source(2, 28) + SourceIndex(0) name (B.constructor) -2 >Emitted(11, 10) Source(2, 29) + SourceIndex(0) name (B.constructor) ---- ->>> return B; -1->^^^^^^^^ -2 > ^^^^^^^^ -1-> -2 > } -1->Emitted(12, 9) Source(2, 28) + SourceIndex(0) name (B) -2 >Emitted(12, 17) Source(2, 29) + SourceIndex(0) name (B) ---- ->>> })(a_1.A); -1 >^^^^ -2 > ^ -3 > -4 > ^^ -5 > ^^^^^ -6 > ^^ -7 > ^^^^^-> -1 > -2 > } -3 > -4 > export class B extends -5 > A -6 > { } -1 >Emitted(13, 5) Source(2, 28) + SourceIndex(0) name (B) -2 >Emitted(13, 6) Source(2, 29) + SourceIndex(0) name (B) -3 >Emitted(13, 6) Source(2, 1) + SourceIndex(0) -4 >Emitted(13, 8) Source(2, 24) + SourceIndex(0) -5 >Emitted(13, 13) Source(2, 25) + SourceIndex(0) -6 >Emitted(13, 15) Source(2, 29) + SourceIndex(0) ---- ->>> exports.B = B; -1->^^^^ -2 > ^^^^^^^^^ -3 > ^^^^ -4 > ^ -1-> -2 > B -3 > extends A { } -4 > -1->Emitted(14, 5) Source(2, 14) + SourceIndex(0) -2 >Emitted(14, 14) Source(2, 15) + SourceIndex(0) -3 >Emitted(14, 18) Source(2, 29) + SourceIndex(0) -4 >Emitted(14, 19) Source(2, 29) + SourceIndex(0) ---- ->>>}); ->>>//# sourceMappingURL=b.js.map=================================================================== JsFile: all.js mapUrl: all.js.map sourceRoot: diff --git a/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFile/amd/mapRootAbsolutePathMixedSubfolderSpecifyOutputFile.json b/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFile/amd/mapRootAbsolutePathMixedSubfolderSpecifyOutputFile.json index ee020b0ff80..2f0cd8e1230 100644 --- a/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFile/amd/mapRootAbsolutePathMixedSubfolderSpecifyOutputFile.json +++ b/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFile/amd/mapRootAbsolutePathMixedSubfolderSpecifyOutputFile.json @@ -17,9 +17,6 @@ "test.ts" ], "emittedFiles": [ - "ref/m2.js.map", - "ref/m2.js", - "ref/m2.d.ts", "bin/test.js.map", "bin/test.js", "bin/test.d.ts" diff --git a/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFile/amd/mapRootAbsolutePathMixedSubfolderSpecifyOutputFile.sourcemap.txt b/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFile/amd/mapRootAbsolutePathMixedSubfolderSpecifyOutputFile.sourcemap.txt index ef882554ddb..94348f987ce 100644 --- a/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFile/amd/mapRootAbsolutePathMixedSubfolderSpecifyOutputFile.sourcemap.txt +++ b/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFile/amd/mapRootAbsolutePathMixedSubfolderSpecifyOutputFile.sourcemap.txt @@ -1,176 +1,4 @@ =================================================================== -JsFile: m2.js -mapUrl: /tests/cases/projects/outputdir_mixed_subfolder/mapFiles/ref/m2.js.map -sourceRoot: -sources: ../../ref/m2.ts -=================================================================== -------------------------------------------------------------------- -emittedFile:ref/m2.js -sourceFile:../../ref/m2.ts -------------------------------------------------------------------- ->>>define(["require", "exports"], function (require, exports) { ->>> exports.m2_a1 = 10; -1 >^^^^ -2 > ^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^-> -1 >export var -2 > m2_a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(2, 5) Source(1, 12) + SourceIndex(0) -2 >Emitted(2, 18) Source(1, 17) + SourceIndex(0) -3 >Emitted(2, 21) Source(1, 20) + SourceIndex(0) -4 >Emitted(2, 23) Source(1, 22) + SourceIndex(0) -5 >Emitted(2, 24) Source(1, 23) + SourceIndex(0) ---- ->>> var m2_c1 = (function () { -1->^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^^^^-> -1-> - > -1->Emitted(3, 5) Source(2, 1) + SourceIndex(0) ---- ->>> function m2_c1() { -1->^^^^^^^^ -2 > ^^-> -1-> -1->Emitted(4, 9) Source(2, 1) + SourceIndex(0) name (m2_c1) ---- ->>> } -1->^^^^^^^^ -2 > ^ -3 > ^^^^^^^^^^^^^-> -1->export class m2_c1 { - > public m2_c1_p1: number; - > -2 > } -1->Emitted(5, 9) Source(4, 1) + SourceIndex(0) name (m2_c1.constructor) -2 >Emitted(5, 10) Source(4, 2) + SourceIndex(0) name (m2_c1.constructor) ---- ->>> return m2_c1; -1->^^^^^^^^ -2 > ^^^^^^^^^^^^ -1-> -2 > } -1->Emitted(6, 9) Source(4, 1) + SourceIndex(0) name (m2_c1) -2 >Emitted(6, 21) Source(4, 2) + SourceIndex(0) name (m2_c1) ---- ->>> })(); -1 >^^^^ -2 > ^ -3 > -4 > ^^^^ -5 > ^^^^^^^^^^^^^^^^^^-> -1 > -2 > } -3 > -4 > export class m2_c1 { - > public m2_c1_p1: number; - > } -1 >Emitted(7, 5) Source(4, 1) + SourceIndex(0) name (m2_c1) -2 >Emitted(7, 6) Source(4, 2) + SourceIndex(0) name (m2_c1) -3 >Emitted(7, 6) Source(2, 1) + SourceIndex(0) -4 >Emitted(7, 10) Source(4, 2) + SourceIndex(0) ---- ->>> exports.m2_c1 = m2_c1; -1->^^^^ -2 > ^^^^^^^^^^^^^ -3 > ^^^^^^^^ -4 > ^ -5 > ^^^^^^^^^^^^^^-> -1-> -2 > m2_c1 -3 > { - > public m2_c1_p1: number; - > } -4 > -1->Emitted(8, 5) Source(2, 14) + SourceIndex(0) -2 >Emitted(8, 18) Source(2, 19) + SourceIndex(0) -3 >Emitted(8, 26) Source(4, 2) + SourceIndex(0) -4 >Emitted(8, 27) Source(4, 2) + SourceIndex(0) ---- ->>> exports.m2_instance1 = new m2_c1(); -1->^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^^^ -5 > ^^^^^ -6 > ^^ -7 > ^ -1-> - > - >export var -2 > m2_instance1 -3 > = -4 > new -5 > m2_c1 -6 > () -7 > ; -1->Emitted(9, 5) Source(6, 12) + SourceIndex(0) -2 >Emitted(9, 25) Source(6, 24) + SourceIndex(0) -3 >Emitted(9, 28) Source(6, 27) + SourceIndex(0) -4 >Emitted(9, 32) Source(6, 31) + SourceIndex(0) -5 >Emitted(9, 37) Source(6, 36) + SourceIndex(0) -6 >Emitted(9, 39) Source(6, 38) + SourceIndex(0) -7 >Emitted(9, 40) Source(6, 39) + SourceIndex(0) ---- ->>> function m2_f1() { -1 >^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -1 >Emitted(10, 5) Source(7, 1) + SourceIndex(0) ---- ->>> return exports.m2_instance1; -1->^^^^^^^^ -2 > ^^^^^^ -3 > ^ -4 > ^^^^^^^^^^^^^^^^^^^^ -5 > ^ -1->export function m2_f1() { - > -2 > return -3 > -4 > m2_instance1 -5 > ; -1->Emitted(11, 9) Source(8, 5) + SourceIndex(0) name (m2_f1) -2 >Emitted(11, 15) Source(8, 11) + SourceIndex(0) name (m2_f1) -3 >Emitted(11, 16) Source(8, 12) + SourceIndex(0) name (m2_f1) -4 >Emitted(11, 36) Source(8, 24) + SourceIndex(0) name (m2_f1) -5 >Emitted(11, 37) Source(8, 25) + SourceIndex(0) name (m2_f1) ---- ->>> } -1 >^^^^ -2 > ^ -3 > ^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -2 > } -1 >Emitted(12, 5) Source(9, 1) + SourceIndex(0) name (m2_f1) -2 >Emitted(12, 6) Source(9, 2) + SourceIndex(0) name (m2_f1) ---- ->>> exports.m2_f1 = m2_f1; -1->^^^^ -2 > ^^^^^^^^^^^^^ -3 > ^^^^^^^^ -4 > ^ -1-> -2 > m2_f1 -3 > () { - > return m2_instance1; - > } -4 > -1->Emitted(13, 5) Source(7, 17) + SourceIndex(0) -2 >Emitted(13, 18) Source(7, 22) + SourceIndex(0) -3 >Emitted(13, 26) Source(9, 2) + SourceIndex(0) -4 >Emitted(13, 27) Source(9, 2) + SourceIndex(0) ---- ->>>}); ->>>//# sourceMappingURL=/tests/cases/projects/outputdir_mixed_subfolder/mapFiles/ref/m2.js.map=================================================================== JsFile: test.js mapUrl: /tests/cases/projects/outputdir_mixed_subfolder/mapFiles/test.js.map sourceRoot: diff --git a/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFile/amd/ref/m2.d.ts b/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFile/amd/ref/m2.d.ts deleted file mode 100644 index c09a3c0c32a..00000000000 --- a/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFile/amd/ref/m2.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -export declare var m2_a1: number; -export declare class m2_c1 { - m2_c1_p1: number; -} -export declare var m2_instance1: m2_c1; -export declare function m2_f1(): m2_c1; diff --git a/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFile/amd/ref/m2.js b/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFile/amd/ref/m2.js deleted file mode 100644 index 9dad0db002a..00000000000 --- a/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFile/amd/ref/m2.js +++ /dev/null @@ -1,15 +0,0 @@ -define(["require", "exports"], function (require, exports) { - exports.m2_a1 = 10; - var m2_c1 = (function () { - function m2_c1() { - } - return m2_c1; - })(); - exports.m2_c1 = m2_c1; - exports.m2_instance1 = new m2_c1(); - function m2_f1() { - return exports.m2_instance1; - } - exports.m2_f1 = m2_f1; -}); -//# sourceMappingURL=/tests/cases/projects/outputdir_mixed_subfolder/mapFiles/ref/m2.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFile/amd/ref/m2.js.map b/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFile/amd/ref/m2.js.map deleted file mode 100644 index 0e907c1a2ca..00000000000 --- a/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFile/amd/ref/m2.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"m2.js","sourceRoot":"","sources":["../../ref/m2.ts"],"names":["m2_c1","m2_c1.constructor","m2_f1"],"mappings":";IAAW,aAAK,GAAG,EAAE,CAAC;IACtB;QAAAA;QAEAC,CAACA;QAADD,YAACA;IAADA,CAACA,AAFD,IAEC;IAFY,aAAK,QAEjB,CAAA;IAEU,oBAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACIE,MAAMA,CAACA,oBAAYA,CAACA;IACxBA,CAACA;IAFe,aAAK,QAEpB,CAAA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFile/node/mapRootAbsolutePathMixedSubfolderSpecifyOutputFile.json b/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFile/node/mapRootAbsolutePathMixedSubfolderSpecifyOutputFile.json index ee020b0ff80..2f0cd8e1230 100644 --- a/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFile/node/mapRootAbsolutePathMixedSubfolderSpecifyOutputFile.json +++ b/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFile/node/mapRootAbsolutePathMixedSubfolderSpecifyOutputFile.json @@ -17,9 +17,6 @@ "test.ts" ], "emittedFiles": [ - "ref/m2.js.map", - "ref/m2.js", - "ref/m2.d.ts", "bin/test.js.map", "bin/test.js", "bin/test.d.ts" diff --git a/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFile/node/mapRootAbsolutePathMixedSubfolderSpecifyOutputFile.sourcemap.txt b/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFile/node/mapRootAbsolutePathMixedSubfolderSpecifyOutputFile.sourcemap.txt index c6aeabde516..3f16355ad76 100644 --- a/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFile/node/mapRootAbsolutePathMixedSubfolderSpecifyOutputFile.sourcemap.txt +++ b/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFile/node/mapRootAbsolutePathMixedSubfolderSpecifyOutputFile.sourcemap.txt @@ -1,175 +1,4 @@ =================================================================== -JsFile: m2.js -mapUrl: /tests/cases/projects/outputdir_mixed_subfolder/mapFiles/ref/m2.js.map -sourceRoot: -sources: ../../ref/m2.ts -=================================================================== -------------------------------------------------------------------- -emittedFile:ref/m2.js -sourceFile:../../ref/m2.ts -------------------------------------------------------------------- ->>>exports.m2_a1 = 10; -1 > -2 >^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^-> -1 >export var -2 >m2_a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(1, 1) Source(1, 12) + SourceIndex(0) -2 >Emitted(1, 14) Source(1, 17) + SourceIndex(0) -3 >Emitted(1, 17) Source(1, 20) + SourceIndex(0) -4 >Emitted(1, 19) Source(1, 22) + SourceIndex(0) -5 >Emitted(1, 20) Source(1, 23) + SourceIndex(0) ---- ->>>var m2_c1 = (function () { -1-> -2 >^^^^^^^^^^^^^^^^^^^^^^^-> -1-> - > -1->Emitted(2, 1) Source(2, 1) + SourceIndex(0) ---- ->>> function m2_c1() { -1->^^^^ -2 > ^^-> -1-> -1->Emitted(3, 5) Source(2, 1) + SourceIndex(0) name (m2_c1) ---- ->>> } -1->^^^^ -2 > ^ -3 > ^^^^^^^^^^^^^-> -1->export class m2_c1 { - > public m2_c1_p1: number; - > -2 > } -1->Emitted(4, 5) Source(4, 1) + SourceIndex(0) name (m2_c1.constructor) -2 >Emitted(4, 6) Source(4, 2) + SourceIndex(0) name (m2_c1.constructor) ---- ->>> return m2_c1; -1->^^^^ -2 > ^^^^^^^^^^^^ -1-> -2 > } -1->Emitted(5, 5) Source(4, 1) + SourceIndex(0) name (m2_c1) -2 >Emitted(5, 17) Source(4, 2) + SourceIndex(0) name (m2_c1) ---- ->>>})(); -1 > -2 >^ -3 > -4 > ^^^^ -5 > ^^^^^^^^^^^^^^^^^^-> -1 > -2 >} -3 > -4 > export class m2_c1 { - > public m2_c1_p1: number; - > } -1 >Emitted(6, 1) Source(4, 1) + SourceIndex(0) name (m2_c1) -2 >Emitted(6, 2) Source(4, 2) + SourceIndex(0) name (m2_c1) -3 >Emitted(6, 2) Source(2, 1) + SourceIndex(0) -4 >Emitted(6, 6) Source(4, 2) + SourceIndex(0) ---- ->>>exports.m2_c1 = m2_c1; -1-> -2 >^^^^^^^^^^^^^ -3 > ^^^^^^^^ -4 > ^ -5 > ^^^^^^^^^^^^^^-> -1-> -2 >m2_c1 -3 > { - > public m2_c1_p1: number; - > } -4 > -1->Emitted(7, 1) Source(2, 14) + SourceIndex(0) -2 >Emitted(7, 14) Source(2, 19) + SourceIndex(0) -3 >Emitted(7, 22) Source(4, 2) + SourceIndex(0) -4 >Emitted(7, 23) Source(4, 2) + SourceIndex(0) ---- ->>>exports.m2_instance1 = new m2_c1(); -1-> -2 >^^^^^^^^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^^^ -5 > ^^^^^ -6 > ^^ -7 > ^ -1-> - > - >export var -2 >m2_instance1 -3 > = -4 > new -5 > m2_c1 -6 > () -7 > ; -1->Emitted(8, 1) Source(6, 12) + SourceIndex(0) -2 >Emitted(8, 21) Source(6, 24) + SourceIndex(0) -3 >Emitted(8, 24) Source(6, 27) + SourceIndex(0) -4 >Emitted(8, 28) Source(6, 31) + SourceIndex(0) -5 >Emitted(8, 33) Source(6, 36) + SourceIndex(0) -6 >Emitted(8, 35) Source(6, 38) + SourceIndex(0) -7 >Emitted(8, 36) Source(6, 39) + SourceIndex(0) ---- ->>>function m2_f1() { -1 > -2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -1 >Emitted(9, 1) Source(7, 1) + SourceIndex(0) ---- ->>> return exports.m2_instance1; -1->^^^^ -2 > ^^^^^^ -3 > ^ -4 > ^^^^^^^^^^^^^^^^^^^^ -5 > ^ -1->export function m2_f1() { - > -2 > return -3 > -4 > m2_instance1 -5 > ; -1->Emitted(10, 5) Source(8, 5) + SourceIndex(0) name (m2_f1) -2 >Emitted(10, 11) Source(8, 11) + SourceIndex(0) name (m2_f1) -3 >Emitted(10, 12) Source(8, 12) + SourceIndex(0) name (m2_f1) -4 >Emitted(10, 32) Source(8, 24) + SourceIndex(0) name (m2_f1) -5 >Emitted(10, 33) Source(8, 25) + SourceIndex(0) name (m2_f1) ---- ->>>} -1 > -2 >^ -3 > ^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -2 >} -1 >Emitted(11, 1) Source(9, 1) + SourceIndex(0) name (m2_f1) -2 >Emitted(11, 2) Source(9, 2) + SourceIndex(0) name (m2_f1) ---- ->>>exports.m2_f1 = m2_f1; -1-> -2 >^^^^^^^^^^^^^ -3 > ^^^^^^^^ -4 > ^ -5 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1-> -2 >m2_f1 -3 > () { - > return m2_instance1; - > } -4 > -1->Emitted(12, 1) Source(7, 17) + SourceIndex(0) -2 >Emitted(12, 14) Source(7, 22) + SourceIndex(0) -3 >Emitted(12, 22) Source(9, 2) + SourceIndex(0) -4 >Emitted(12, 23) Source(9, 2) + SourceIndex(0) ---- ->>>//# sourceMappingURL=/tests/cases/projects/outputdir_mixed_subfolder/mapFiles/ref/m2.js.map=================================================================== JsFile: test.js mapUrl: /tests/cases/projects/outputdir_mixed_subfolder/mapFiles/test.js.map sourceRoot: diff --git a/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFile/node/ref/m2.d.ts b/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFile/node/ref/m2.d.ts deleted file mode 100644 index c09a3c0c32a..00000000000 --- a/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFile/node/ref/m2.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -export declare var m2_a1: number; -export declare class m2_c1 { - m2_c1_p1: number; -} -export declare var m2_instance1: m2_c1; -export declare function m2_f1(): m2_c1; diff --git a/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFile/node/ref/m2.js b/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFile/node/ref/m2.js deleted file mode 100644 index 3eaebd5c136..00000000000 --- a/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFile/node/ref/m2.js +++ /dev/null @@ -1,13 +0,0 @@ -exports.m2_a1 = 10; -var m2_c1 = (function () { - function m2_c1() { - } - return m2_c1; -})(); -exports.m2_c1 = m2_c1; -exports.m2_instance1 = new m2_c1(); -function m2_f1() { - return exports.m2_instance1; -} -exports.m2_f1 = m2_f1; -//# sourceMappingURL=/tests/cases/projects/outputdir_mixed_subfolder/mapFiles/ref/m2.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFile/node/ref/m2.js.map b/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFile/node/ref/m2.js.map deleted file mode 100644 index cbb2dc36492..00000000000 --- a/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFile/node/ref/m2.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"m2.js","sourceRoot":"","sources":["../../ref/m2.ts"],"names":["m2_c1","m2_c1.constructor","m2_f1"],"mappings":"AAAW,aAAK,GAAG,EAAE,CAAC;AACtB;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAFY,aAAK,QAEjB,CAAA;AAEU,oBAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACIE,MAAMA,CAACA,oBAAYA,CAACA;AACxBA,CAACA;AAFe,aAAK,QAEpB,CAAA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/mapRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory.json b/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/mapRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory.json index ed7bcd289e7..24fb56c1fd2 100644 --- a/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/mapRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory.json +++ b/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/mapRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory.json @@ -18,9 +18,6 @@ "test.ts" ], "emittedFiles": [ - "outdir/outAndOutDirFolder/ref/m2.js.map", - "outdir/outAndOutDirFolder/ref/m2.js", - "outdir/outAndOutDirFolder/ref/m2.d.ts", "bin/outAndOutDirFile.js.map", "bin/outAndOutDirFile.js", "bin/outAndOutDirFile.d.ts" diff --git a/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/mapRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory.sourcemap.txt b/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/mapRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory.sourcemap.txt index 68630d9e431..c0dbdb42cdf 100644 --- a/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/mapRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory.sourcemap.txt +++ b/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/mapRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory.sourcemap.txt @@ -1,176 +1,4 @@ =================================================================== -JsFile: m2.js -mapUrl: /tests/cases/projects/outputdir_mixed_subfolder/mapFiles/ref/m2.js.map -sourceRoot: -sources: ../../ref/m2.ts -=================================================================== -------------------------------------------------------------------- -emittedFile:outdir/outAndOutDirFolder/ref/m2.js -sourceFile:../../ref/m2.ts -------------------------------------------------------------------- ->>>define(["require", "exports"], function (require, exports) { ->>> exports.m2_a1 = 10; -1 >^^^^ -2 > ^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^-> -1 >export var -2 > m2_a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(2, 5) Source(1, 12) + SourceIndex(0) -2 >Emitted(2, 18) Source(1, 17) + SourceIndex(0) -3 >Emitted(2, 21) Source(1, 20) + SourceIndex(0) -4 >Emitted(2, 23) Source(1, 22) + SourceIndex(0) -5 >Emitted(2, 24) Source(1, 23) + SourceIndex(0) ---- ->>> var m2_c1 = (function () { -1->^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^^^^-> -1-> - > -1->Emitted(3, 5) Source(2, 1) + SourceIndex(0) ---- ->>> function m2_c1() { -1->^^^^^^^^ -2 > ^^-> -1-> -1->Emitted(4, 9) Source(2, 1) + SourceIndex(0) name (m2_c1) ---- ->>> } -1->^^^^^^^^ -2 > ^ -3 > ^^^^^^^^^^^^^-> -1->export class m2_c1 { - > public m2_c1_p1: number; - > -2 > } -1->Emitted(5, 9) Source(4, 1) + SourceIndex(0) name (m2_c1.constructor) -2 >Emitted(5, 10) Source(4, 2) + SourceIndex(0) name (m2_c1.constructor) ---- ->>> return m2_c1; -1->^^^^^^^^ -2 > ^^^^^^^^^^^^ -1-> -2 > } -1->Emitted(6, 9) Source(4, 1) + SourceIndex(0) name (m2_c1) -2 >Emitted(6, 21) Source(4, 2) + SourceIndex(0) name (m2_c1) ---- ->>> })(); -1 >^^^^ -2 > ^ -3 > -4 > ^^^^ -5 > ^^^^^^^^^^^^^^^^^^-> -1 > -2 > } -3 > -4 > export class m2_c1 { - > public m2_c1_p1: number; - > } -1 >Emitted(7, 5) Source(4, 1) + SourceIndex(0) name (m2_c1) -2 >Emitted(7, 6) Source(4, 2) + SourceIndex(0) name (m2_c1) -3 >Emitted(7, 6) Source(2, 1) + SourceIndex(0) -4 >Emitted(7, 10) Source(4, 2) + SourceIndex(0) ---- ->>> exports.m2_c1 = m2_c1; -1->^^^^ -2 > ^^^^^^^^^^^^^ -3 > ^^^^^^^^ -4 > ^ -5 > ^^^^^^^^^^^^^^-> -1-> -2 > m2_c1 -3 > { - > public m2_c1_p1: number; - > } -4 > -1->Emitted(8, 5) Source(2, 14) + SourceIndex(0) -2 >Emitted(8, 18) Source(2, 19) + SourceIndex(0) -3 >Emitted(8, 26) Source(4, 2) + SourceIndex(0) -4 >Emitted(8, 27) Source(4, 2) + SourceIndex(0) ---- ->>> exports.m2_instance1 = new m2_c1(); -1->^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^^^ -5 > ^^^^^ -6 > ^^ -7 > ^ -1-> - > - >export var -2 > m2_instance1 -3 > = -4 > new -5 > m2_c1 -6 > () -7 > ; -1->Emitted(9, 5) Source(6, 12) + SourceIndex(0) -2 >Emitted(9, 25) Source(6, 24) + SourceIndex(0) -3 >Emitted(9, 28) Source(6, 27) + SourceIndex(0) -4 >Emitted(9, 32) Source(6, 31) + SourceIndex(0) -5 >Emitted(9, 37) Source(6, 36) + SourceIndex(0) -6 >Emitted(9, 39) Source(6, 38) + SourceIndex(0) -7 >Emitted(9, 40) Source(6, 39) + SourceIndex(0) ---- ->>> function m2_f1() { -1 >^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -1 >Emitted(10, 5) Source(7, 1) + SourceIndex(0) ---- ->>> return exports.m2_instance1; -1->^^^^^^^^ -2 > ^^^^^^ -3 > ^ -4 > ^^^^^^^^^^^^^^^^^^^^ -5 > ^ -1->export function m2_f1() { - > -2 > return -3 > -4 > m2_instance1 -5 > ; -1->Emitted(11, 9) Source(8, 5) + SourceIndex(0) name (m2_f1) -2 >Emitted(11, 15) Source(8, 11) + SourceIndex(0) name (m2_f1) -3 >Emitted(11, 16) Source(8, 12) + SourceIndex(0) name (m2_f1) -4 >Emitted(11, 36) Source(8, 24) + SourceIndex(0) name (m2_f1) -5 >Emitted(11, 37) Source(8, 25) + SourceIndex(0) name (m2_f1) ---- ->>> } -1 >^^^^ -2 > ^ -3 > ^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -2 > } -1 >Emitted(12, 5) Source(9, 1) + SourceIndex(0) name (m2_f1) -2 >Emitted(12, 6) Source(9, 2) + SourceIndex(0) name (m2_f1) ---- ->>> exports.m2_f1 = m2_f1; -1->^^^^ -2 > ^^^^^^^^^^^^^ -3 > ^^^^^^^^ -4 > ^ -1-> -2 > m2_f1 -3 > () { - > return m2_instance1; - > } -4 > -1->Emitted(13, 5) Source(7, 17) + SourceIndex(0) -2 >Emitted(13, 18) Source(7, 22) + SourceIndex(0) -3 >Emitted(13, 26) Source(9, 2) + SourceIndex(0) -4 >Emitted(13, 27) Source(9, 2) + SourceIndex(0) ---- ->>>}); ->>>//# sourceMappingURL=/tests/cases/projects/outputdir_mixed_subfolder/mapFiles/ref/m2.js.map=================================================================== JsFile: outAndOutDirFile.js mapUrl: /tests/cases/projects/outputdir_mixed_subfolder/mapFiles/outAndOutDirFile.js.map sourceRoot: diff --git a/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/outdir/outAndOutDirFolder/ref/m2.d.ts b/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/outdir/outAndOutDirFolder/ref/m2.d.ts deleted file mode 100644 index c09a3c0c32a..00000000000 --- a/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/outdir/outAndOutDirFolder/ref/m2.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -export declare var m2_a1: number; -export declare class m2_c1 { - m2_c1_p1: number; -} -export declare var m2_instance1: m2_c1; -export declare function m2_f1(): m2_c1; diff --git a/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/outdir/outAndOutDirFolder/ref/m2.js b/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/outdir/outAndOutDirFolder/ref/m2.js deleted file mode 100644 index 9dad0db002a..00000000000 --- a/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/outdir/outAndOutDirFolder/ref/m2.js +++ /dev/null @@ -1,15 +0,0 @@ -define(["require", "exports"], function (require, exports) { - exports.m2_a1 = 10; - var m2_c1 = (function () { - function m2_c1() { - } - return m2_c1; - })(); - exports.m2_c1 = m2_c1; - exports.m2_instance1 = new m2_c1(); - function m2_f1() { - return exports.m2_instance1; - } - exports.m2_f1 = m2_f1; -}); -//# sourceMappingURL=/tests/cases/projects/outputdir_mixed_subfolder/mapFiles/ref/m2.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/outdir/outAndOutDirFolder/ref/m2.js.map b/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/outdir/outAndOutDirFolder/ref/m2.js.map deleted file mode 100644 index 0e907c1a2ca..00000000000 --- a/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/outdir/outAndOutDirFolder/ref/m2.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"m2.js","sourceRoot":"","sources":["../../ref/m2.ts"],"names":["m2_c1","m2_c1.constructor","m2_f1"],"mappings":";IAAW,aAAK,GAAG,EAAE,CAAC;IACtB;QAAAA;QAEAC,CAACA;QAADD,YAACA;IAADA,CAACA,AAFD,IAEC;IAFY,aAAK,QAEjB,CAAA;IAEU,oBAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACIE,MAAMA,CAACA,oBAAYA,CAACA;IACxBA,CAACA;IAFe,aAAK,QAEpB,CAAA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/mapRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory.json b/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/mapRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory.json index ed7bcd289e7..24fb56c1fd2 100644 --- a/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/mapRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory.json +++ b/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/mapRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory.json @@ -18,9 +18,6 @@ "test.ts" ], "emittedFiles": [ - "outdir/outAndOutDirFolder/ref/m2.js.map", - "outdir/outAndOutDirFolder/ref/m2.js", - "outdir/outAndOutDirFolder/ref/m2.d.ts", "bin/outAndOutDirFile.js.map", "bin/outAndOutDirFile.js", "bin/outAndOutDirFile.d.ts" diff --git a/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/mapRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory.sourcemap.txt b/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/mapRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory.sourcemap.txt index 8f645dc8a2d..963b3f3bb22 100644 --- a/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/mapRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory.sourcemap.txt +++ b/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/mapRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory.sourcemap.txt @@ -1,175 +1,4 @@ =================================================================== -JsFile: m2.js -mapUrl: /tests/cases/projects/outputdir_mixed_subfolder/mapFiles/ref/m2.js.map -sourceRoot: -sources: ../../ref/m2.ts -=================================================================== -------------------------------------------------------------------- -emittedFile:outdir/outAndOutDirFolder/ref/m2.js -sourceFile:../../ref/m2.ts -------------------------------------------------------------------- ->>>exports.m2_a1 = 10; -1 > -2 >^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^-> -1 >export var -2 >m2_a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(1, 1) Source(1, 12) + SourceIndex(0) -2 >Emitted(1, 14) Source(1, 17) + SourceIndex(0) -3 >Emitted(1, 17) Source(1, 20) + SourceIndex(0) -4 >Emitted(1, 19) Source(1, 22) + SourceIndex(0) -5 >Emitted(1, 20) Source(1, 23) + SourceIndex(0) ---- ->>>var m2_c1 = (function () { -1-> -2 >^^^^^^^^^^^^^^^^^^^^^^^-> -1-> - > -1->Emitted(2, 1) Source(2, 1) + SourceIndex(0) ---- ->>> function m2_c1() { -1->^^^^ -2 > ^^-> -1-> -1->Emitted(3, 5) Source(2, 1) + SourceIndex(0) name (m2_c1) ---- ->>> } -1->^^^^ -2 > ^ -3 > ^^^^^^^^^^^^^-> -1->export class m2_c1 { - > public m2_c1_p1: number; - > -2 > } -1->Emitted(4, 5) Source(4, 1) + SourceIndex(0) name (m2_c1.constructor) -2 >Emitted(4, 6) Source(4, 2) + SourceIndex(0) name (m2_c1.constructor) ---- ->>> return m2_c1; -1->^^^^ -2 > ^^^^^^^^^^^^ -1-> -2 > } -1->Emitted(5, 5) Source(4, 1) + SourceIndex(0) name (m2_c1) -2 >Emitted(5, 17) Source(4, 2) + SourceIndex(0) name (m2_c1) ---- ->>>})(); -1 > -2 >^ -3 > -4 > ^^^^ -5 > ^^^^^^^^^^^^^^^^^^-> -1 > -2 >} -3 > -4 > export class m2_c1 { - > public m2_c1_p1: number; - > } -1 >Emitted(6, 1) Source(4, 1) + SourceIndex(0) name (m2_c1) -2 >Emitted(6, 2) Source(4, 2) + SourceIndex(0) name (m2_c1) -3 >Emitted(6, 2) Source(2, 1) + SourceIndex(0) -4 >Emitted(6, 6) Source(4, 2) + SourceIndex(0) ---- ->>>exports.m2_c1 = m2_c1; -1-> -2 >^^^^^^^^^^^^^ -3 > ^^^^^^^^ -4 > ^ -5 > ^^^^^^^^^^^^^^-> -1-> -2 >m2_c1 -3 > { - > public m2_c1_p1: number; - > } -4 > -1->Emitted(7, 1) Source(2, 14) + SourceIndex(0) -2 >Emitted(7, 14) Source(2, 19) + SourceIndex(0) -3 >Emitted(7, 22) Source(4, 2) + SourceIndex(0) -4 >Emitted(7, 23) Source(4, 2) + SourceIndex(0) ---- ->>>exports.m2_instance1 = new m2_c1(); -1-> -2 >^^^^^^^^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^^^ -5 > ^^^^^ -6 > ^^ -7 > ^ -1-> - > - >export var -2 >m2_instance1 -3 > = -4 > new -5 > m2_c1 -6 > () -7 > ; -1->Emitted(8, 1) Source(6, 12) + SourceIndex(0) -2 >Emitted(8, 21) Source(6, 24) + SourceIndex(0) -3 >Emitted(8, 24) Source(6, 27) + SourceIndex(0) -4 >Emitted(8, 28) Source(6, 31) + SourceIndex(0) -5 >Emitted(8, 33) Source(6, 36) + SourceIndex(0) -6 >Emitted(8, 35) Source(6, 38) + SourceIndex(0) -7 >Emitted(8, 36) Source(6, 39) + SourceIndex(0) ---- ->>>function m2_f1() { -1 > -2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -1 >Emitted(9, 1) Source(7, 1) + SourceIndex(0) ---- ->>> return exports.m2_instance1; -1->^^^^ -2 > ^^^^^^ -3 > ^ -4 > ^^^^^^^^^^^^^^^^^^^^ -5 > ^ -1->export function m2_f1() { - > -2 > return -3 > -4 > m2_instance1 -5 > ; -1->Emitted(10, 5) Source(8, 5) + SourceIndex(0) name (m2_f1) -2 >Emitted(10, 11) Source(8, 11) + SourceIndex(0) name (m2_f1) -3 >Emitted(10, 12) Source(8, 12) + SourceIndex(0) name (m2_f1) -4 >Emitted(10, 32) Source(8, 24) + SourceIndex(0) name (m2_f1) -5 >Emitted(10, 33) Source(8, 25) + SourceIndex(0) name (m2_f1) ---- ->>>} -1 > -2 >^ -3 > ^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -2 >} -1 >Emitted(11, 1) Source(9, 1) + SourceIndex(0) name (m2_f1) -2 >Emitted(11, 2) Source(9, 2) + SourceIndex(0) name (m2_f1) ---- ->>>exports.m2_f1 = m2_f1; -1-> -2 >^^^^^^^^^^^^^ -3 > ^^^^^^^^ -4 > ^ -5 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1-> -2 >m2_f1 -3 > () { - > return m2_instance1; - > } -4 > -1->Emitted(12, 1) Source(7, 17) + SourceIndex(0) -2 >Emitted(12, 14) Source(7, 22) + SourceIndex(0) -3 >Emitted(12, 22) Source(9, 2) + SourceIndex(0) -4 >Emitted(12, 23) Source(9, 2) + SourceIndex(0) ---- ->>>//# sourceMappingURL=/tests/cases/projects/outputdir_mixed_subfolder/mapFiles/ref/m2.js.map=================================================================== JsFile: outAndOutDirFile.js mapUrl: /tests/cases/projects/outputdir_mixed_subfolder/mapFiles/outAndOutDirFile.js.map sourceRoot: diff --git a/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/outdir/outAndOutDirFolder/ref/m2.d.ts b/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/outdir/outAndOutDirFolder/ref/m2.d.ts deleted file mode 100644 index c09a3c0c32a..00000000000 --- a/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/outdir/outAndOutDirFolder/ref/m2.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -export declare var m2_a1: number; -export declare class m2_c1 { - m2_c1_p1: number; -} -export declare var m2_instance1: m2_c1; -export declare function m2_f1(): m2_c1; diff --git a/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/outdir/outAndOutDirFolder/ref/m2.js b/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/outdir/outAndOutDirFolder/ref/m2.js deleted file mode 100644 index 3eaebd5c136..00000000000 --- a/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/outdir/outAndOutDirFolder/ref/m2.js +++ /dev/null @@ -1,13 +0,0 @@ -exports.m2_a1 = 10; -var m2_c1 = (function () { - function m2_c1() { - } - return m2_c1; -})(); -exports.m2_c1 = m2_c1; -exports.m2_instance1 = new m2_c1(); -function m2_f1() { - return exports.m2_instance1; -} -exports.m2_f1 = m2_f1; -//# sourceMappingURL=/tests/cases/projects/outputdir_mixed_subfolder/mapFiles/ref/m2.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/outdir/outAndOutDirFolder/ref/m2.js.map b/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/outdir/outAndOutDirFolder/ref/m2.js.map deleted file mode 100644 index cbb2dc36492..00000000000 --- a/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/outdir/outAndOutDirFolder/ref/m2.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"m2.js","sourceRoot":"","sources":["../../ref/m2.ts"],"names":["m2_c1","m2_c1.constructor","m2_f1"],"mappings":"AAAW,aAAK,GAAG,EAAE,CAAC;AACtB;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAFY,aAAK,QAEjB,CAAA;AAEU,oBAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACIE,MAAMA,CAACA,oBAAYA,CAACA;AACxBA,CAACA;AAFe,aAAK,QAEpB,CAAA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderSpecifyOutputFile/amd/diskFile0.js.map b/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderSpecifyOutputFile/amd/diskFile0.js.map deleted file mode 100644 index b02c7fdd8c2..00000000000 --- a/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderSpecifyOutputFile/amd/diskFile0.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"m2.js","sourceRoot":"","sources":["../../../outputdir_module_multifolder_ref/m2.ts"],"names":["m2_c1","m2_c1.constructor","m2_f1"],"mappings":";IAAW,aAAK,GAAG,EAAE,CAAC;IACtB;QAAAA;QAEAC,CAACA;QAADD,YAACA;IAADA,CAACA,AAFD,IAEC;IAFY,aAAK,QAEjB,CAAA;IAEU,oBAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACIE,MAAMA,CAACA,oBAAYA,CAACA;IACxBA,CAACA;IAFe,aAAK,QAEpB,CAAA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderSpecifyOutputFile/amd/diskFile1.js b/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderSpecifyOutputFile/amd/diskFile1.js deleted file mode 100644 index 8fe95a1506f..00000000000 --- a/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderSpecifyOutputFile/amd/diskFile1.js +++ /dev/null @@ -1,15 +0,0 @@ -define(["require", "exports"], function (require, exports) { - exports.m2_a1 = 10; - var m2_c1 = (function () { - function m2_c1() { - } - return m2_c1; - })(); - exports.m2_c1 = m2_c1; - exports.m2_instance1 = new m2_c1(); - function m2_f1() { - return exports.m2_instance1; - } - exports.m2_f1 = m2_f1; -}); -//# sourceMappingURL=/tests/cases/projects/outputdir_module_multifolder/mapFiles/outputdir_module_multifolder_ref/m2.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderSpecifyOutputFile/amd/diskFile2.d.ts b/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderSpecifyOutputFile/amd/diskFile2.d.ts deleted file mode 100644 index c09a3c0c32a..00000000000 --- a/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderSpecifyOutputFile/amd/diskFile2.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -export declare var m2_a1: number; -export declare class m2_c1 { - m2_c1_p1: number; -} -export declare var m2_instance1: m2_c1; -export declare function m2_f1(): m2_c1; diff --git a/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderSpecifyOutputFile/amd/mapRootAbsolutePathModuleMultifolderSpecifyOutputFile.json b/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderSpecifyOutputFile/amd/mapRootAbsolutePathModuleMultifolderSpecifyOutputFile.json index 6432d5ae91e..4869993ca92 100644 --- a/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderSpecifyOutputFile/amd/mapRootAbsolutePathModuleMultifolderSpecifyOutputFile.json +++ b/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderSpecifyOutputFile/amd/mapRootAbsolutePathModuleMultifolderSpecifyOutputFile.json @@ -17,15 +17,6 @@ "test.ts" ], "emittedFiles": [ - "ref/m1.js.map", - "ref/m1.js", - "ref/m1.d.ts", - "../outputdir_module_multifolder_ref/m2.js.map", - "../outputdir_module_multifolder_ref/m2.js", - "../outputdir_module_multifolder_ref/m2.d.ts", - "test.js.map", - "test.js", - "test.d.ts", "bin/test.js.map", "bin/test.js", "bin/test.d.ts" diff --git a/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderSpecifyOutputFile/amd/mapRootAbsolutePathModuleMultifolderSpecifyOutputFile.sourcemap.txt b/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderSpecifyOutputFile/amd/mapRootAbsolutePathModuleMultifolderSpecifyOutputFile.sourcemap.txt index 9384228ece5..4462b142d98 100644 --- a/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderSpecifyOutputFile/amd/mapRootAbsolutePathModuleMultifolderSpecifyOutputFile.sourcemap.txt +++ b/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderSpecifyOutputFile/amd/mapRootAbsolutePathModuleMultifolderSpecifyOutputFile.sourcemap.txt @@ -1,573 +1,4 @@ =================================================================== -JsFile: m1.js -mapUrl: /tests/cases/projects/outputdir_module_multifolder/mapFiles/outputdir_module_multifolder/ref/m1.js.map -sourceRoot: -sources: ../../../ref/m1.ts -=================================================================== -------------------------------------------------------------------- -emittedFile:ref/m1.js -sourceFile:../../../ref/m1.ts -------------------------------------------------------------------- ->>>define(["require", "exports"], function (require, exports) { ->>> exports.m1_a1 = 10; -1 >^^^^ -2 > ^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^-> -1 >export var -2 > m1_a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(2, 5) Source(1, 12) + SourceIndex(0) -2 >Emitted(2, 18) Source(1, 17) + SourceIndex(0) -3 >Emitted(2, 21) Source(1, 20) + SourceIndex(0) -4 >Emitted(2, 23) Source(1, 22) + SourceIndex(0) -5 >Emitted(2, 24) Source(1, 23) + SourceIndex(0) ---- ->>> var m1_c1 = (function () { -1->^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^^^^-> -1-> - > -1->Emitted(3, 5) Source(2, 1) + SourceIndex(0) ---- ->>> function m1_c1() { -1->^^^^^^^^ -2 > ^^-> -1-> -1->Emitted(4, 9) Source(2, 1) + SourceIndex(0) name (m1_c1) ---- ->>> } -1->^^^^^^^^ -2 > ^ -3 > ^^^^^^^^^^^^^-> -1->export class m1_c1 { - > public m1_c1_p1: number; - > -2 > } -1->Emitted(5, 9) Source(4, 1) + SourceIndex(0) name (m1_c1.constructor) -2 >Emitted(5, 10) Source(4, 2) + SourceIndex(0) name (m1_c1.constructor) ---- ->>> return m1_c1; -1->^^^^^^^^ -2 > ^^^^^^^^^^^^ -1-> -2 > } -1->Emitted(6, 9) Source(4, 1) + SourceIndex(0) name (m1_c1) -2 >Emitted(6, 21) Source(4, 2) + SourceIndex(0) name (m1_c1) ---- ->>> })(); -1 >^^^^ -2 > ^ -3 > -4 > ^^^^ -5 > ^^^^^^^^^^^^^^^^^^-> -1 > -2 > } -3 > -4 > export class m1_c1 { - > public m1_c1_p1: number; - > } -1 >Emitted(7, 5) Source(4, 1) + SourceIndex(0) name (m1_c1) -2 >Emitted(7, 6) Source(4, 2) + SourceIndex(0) name (m1_c1) -3 >Emitted(7, 6) Source(2, 1) + SourceIndex(0) -4 >Emitted(7, 10) Source(4, 2) + SourceIndex(0) ---- ->>> exports.m1_c1 = m1_c1; -1->^^^^ -2 > ^^^^^^^^^^^^^ -3 > ^^^^^^^^ -4 > ^ -5 > ^^^^^^^^^^^^^^-> -1-> -2 > m1_c1 -3 > { - > public m1_c1_p1: number; - > } -4 > -1->Emitted(8, 5) Source(2, 14) + SourceIndex(0) -2 >Emitted(8, 18) Source(2, 19) + SourceIndex(0) -3 >Emitted(8, 26) Source(4, 2) + SourceIndex(0) -4 >Emitted(8, 27) Source(4, 2) + SourceIndex(0) ---- ->>> exports.m1_instance1 = new m1_c1(); -1->^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^^^ -5 > ^^^^^ -6 > ^^ -7 > ^ -1-> - > - >export var -2 > m1_instance1 -3 > = -4 > new -5 > m1_c1 -6 > () -7 > ; -1->Emitted(9, 5) Source(6, 12) + SourceIndex(0) -2 >Emitted(9, 25) Source(6, 24) + SourceIndex(0) -3 >Emitted(9, 28) Source(6, 27) + SourceIndex(0) -4 >Emitted(9, 32) Source(6, 31) + SourceIndex(0) -5 >Emitted(9, 37) Source(6, 36) + SourceIndex(0) -6 >Emitted(9, 39) Source(6, 38) + SourceIndex(0) -7 >Emitted(9, 40) Source(6, 39) + SourceIndex(0) ---- ->>> function m1_f1() { -1 >^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -1 >Emitted(10, 5) Source(7, 1) + SourceIndex(0) ---- ->>> return exports.m1_instance1; -1->^^^^^^^^ -2 > ^^^^^^ -3 > ^ -4 > ^^^^^^^^^^^^^^^^^^^^ -5 > ^ -1->export function m1_f1() { - > -2 > return -3 > -4 > m1_instance1 -5 > ; -1->Emitted(11, 9) Source(8, 5) + SourceIndex(0) name (m1_f1) -2 >Emitted(11, 15) Source(8, 11) + SourceIndex(0) name (m1_f1) -3 >Emitted(11, 16) Source(8, 12) + SourceIndex(0) name (m1_f1) -4 >Emitted(11, 36) Source(8, 24) + SourceIndex(0) name (m1_f1) -5 >Emitted(11, 37) Source(8, 25) + SourceIndex(0) name (m1_f1) ---- ->>> } -1 >^^^^ -2 > ^ -3 > ^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -2 > } -1 >Emitted(12, 5) Source(9, 1) + SourceIndex(0) name (m1_f1) -2 >Emitted(12, 6) Source(9, 2) + SourceIndex(0) name (m1_f1) ---- ->>> exports.m1_f1 = m1_f1; -1->^^^^ -2 > ^^^^^^^^^^^^^ -3 > ^^^^^^^^ -4 > ^ -1-> -2 > m1_f1 -3 > () { - > return m1_instance1; - > } -4 > -1->Emitted(13, 5) Source(7, 17) + SourceIndex(0) -2 >Emitted(13, 18) Source(7, 22) + SourceIndex(0) -3 >Emitted(13, 26) Source(9, 2) + SourceIndex(0) -4 >Emitted(13, 27) Source(9, 2) + SourceIndex(0) ---- ->>>}); ->>>//# sourceMappingURL=/tests/cases/projects/outputdir_module_multifolder/mapFiles/outputdir_module_multifolder/ref/m1.js.map=================================================================== -JsFile: m2.js -mapUrl: /tests/cases/projects/outputdir_module_multifolder/mapFiles/outputdir_module_multifolder_ref/m2.js.map -sourceRoot: -sources: ../../../outputdir_module_multifolder_ref/m2.ts -=================================================================== -------------------------------------------------------------------- -emittedFile:diskFile1.js -sourceFile:../../../outputdir_module_multifolder_ref/m2.ts -------------------------------------------------------------------- ->>>define(["require", "exports"], function (require, exports) { ->>> exports.m2_a1 = 10; -1 >^^^^ -2 > ^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^-> -1 >export var -2 > m2_a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(2, 5) Source(1, 12) + SourceIndex(0) -2 >Emitted(2, 18) Source(1, 17) + SourceIndex(0) -3 >Emitted(2, 21) Source(1, 20) + SourceIndex(0) -4 >Emitted(2, 23) Source(1, 22) + SourceIndex(0) -5 >Emitted(2, 24) Source(1, 23) + SourceIndex(0) ---- ->>> var m2_c1 = (function () { -1->^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^^^^-> -1-> - > -1->Emitted(3, 5) Source(2, 1) + SourceIndex(0) ---- ->>> function m2_c1() { -1->^^^^^^^^ -2 > ^^-> -1-> -1->Emitted(4, 9) Source(2, 1) + SourceIndex(0) name (m2_c1) ---- ->>> } -1->^^^^^^^^ -2 > ^ -3 > ^^^^^^^^^^^^^-> -1->export class m2_c1 { - > public m2_c1_p1: number; - > -2 > } -1->Emitted(5, 9) Source(4, 1) + SourceIndex(0) name (m2_c1.constructor) -2 >Emitted(5, 10) Source(4, 2) + SourceIndex(0) name (m2_c1.constructor) ---- ->>> return m2_c1; -1->^^^^^^^^ -2 > ^^^^^^^^^^^^ -1-> -2 > } -1->Emitted(6, 9) Source(4, 1) + SourceIndex(0) name (m2_c1) -2 >Emitted(6, 21) Source(4, 2) + SourceIndex(0) name (m2_c1) ---- ->>> })(); -1 >^^^^ -2 > ^ -3 > -4 > ^^^^ -5 > ^^^^^^^^^^^^^^^^^^-> -1 > -2 > } -3 > -4 > export class m2_c1 { - > public m2_c1_p1: number; - > } -1 >Emitted(7, 5) Source(4, 1) + SourceIndex(0) name (m2_c1) -2 >Emitted(7, 6) Source(4, 2) + SourceIndex(0) name (m2_c1) -3 >Emitted(7, 6) Source(2, 1) + SourceIndex(0) -4 >Emitted(7, 10) Source(4, 2) + SourceIndex(0) ---- ->>> exports.m2_c1 = m2_c1; -1->^^^^ -2 > ^^^^^^^^^^^^^ -3 > ^^^^^^^^ -4 > ^ -5 > ^^^^^^^^^^^^^^-> -1-> -2 > m2_c1 -3 > { - > public m2_c1_p1: number; - > } -4 > -1->Emitted(8, 5) Source(2, 14) + SourceIndex(0) -2 >Emitted(8, 18) Source(2, 19) + SourceIndex(0) -3 >Emitted(8, 26) Source(4, 2) + SourceIndex(0) -4 >Emitted(8, 27) Source(4, 2) + SourceIndex(0) ---- ->>> exports.m2_instance1 = new m2_c1(); -1->^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^^^ -5 > ^^^^^ -6 > ^^ -7 > ^ -1-> - > - >export var -2 > m2_instance1 -3 > = -4 > new -5 > m2_c1 -6 > () -7 > ; -1->Emitted(9, 5) Source(6, 12) + SourceIndex(0) -2 >Emitted(9, 25) Source(6, 24) + SourceIndex(0) -3 >Emitted(9, 28) Source(6, 27) + SourceIndex(0) -4 >Emitted(9, 32) Source(6, 31) + SourceIndex(0) -5 >Emitted(9, 37) Source(6, 36) + SourceIndex(0) -6 >Emitted(9, 39) Source(6, 38) + SourceIndex(0) -7 >Emitted(9, 40) Source(6, 39) + SourceIndex(0) ---- ->>> function m2_f1() { -1 >^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -1 >Emitted(10, 5) Source(7, 1) + SourceIndex(0) ---- ->>> return exports.m2_instance1; -1->^^^^^^^^ -2 > ^^^^^^ -3 > ^ -4 > ^^^^^^^^^^^^^^^^^^^^ -5 > ^ -1->export function m2_f1() { - > -2 > return -3 > -4 > m2_instance1 -5 > ; -1->Emitted(11, 9) Source(8, 5) + SourceIndex(0) name (m2_f1) -2 >Emitted(11, 15) Source(8, 11) + SourceIndex(0) name (m2_f1) -3 >Emitted(11, 16) Source(8, 12) + SourceIndex(0) name (m2_f1) -4 >Emitted(11, 36) Source(8, 24) + SourceIndex(0) name (m2_f1) -5 >Emitted(11, 37) Source(8, 25) + SourceIndex(0) name (m2_f1) ---- ->>> } -1 >^^^^ -2 > ^ -3 > ^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -2 > } -1 >Emitted(12, 5) Source(9, 1) + SourceIndex(0) name (m2_f1) -2 >Emitted(12, 6) Source(9, 2) + SourceIndex(0) name (m2_f1) ---- ->>> exports.m2_f1 = m2_f1; -1->^^^^ -2 > ^^^^^^^^^^^^^ -3 > ^^^^^^^^ -4 > ^ -1-> -2 > m2_f1 -3 > () { - > return m2_instance1; - > } -4 > -1->Emitted(13, 5) Source(7, 17) + SourceIndex(0) -2 >Emitted(13, 18) Source(7, 22) + SourceIndex(0) -3 >Emitted(13, 26) Source(9, 2) + SourceIndex(0) -4 >Emitted(13, 27) Source(9, 2) + SourceIndex(0) ---- ->>>}); ->>>//# sourceMappingURL=/tests/cases/projects/outputdir_module_multifolder/mapFiles/outputdir_module_multifolder_ref/m2.js.map=================================================================== -JsFile: test.js -mapUrl: /tests/cases/projects/outputdir_module_multifolder/mapFiles/outputdir_module_multifolder/test.js.map -sourceRoot: -sources: ../../test.ts -=================================================================== -------------------------------------------------------------------- -emittedFile:test.js -sourceFile:../../test.ts -------------------------------------------------------------------- ->>>define(["require", "exports", "ref/m1", "../outputdir_module_multifolder_ref/m2"], function (require, exports, m1, m2) { ->>> exports.a1 = 10; -1 >^^^^ -2 > ^^^^^^^^^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^-> -1 >import m1 = require("ref/m1"); - >import m2 = require("../outputdir_module_multifolder_ref/m2"); - >export var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(2, 5) Source(3, 12) + SourceIndex(0) -2 >Emitted(2, 15) Source(3, 14) + SourceIndex(0) -3 >Emitted(2, 18) Source(3, 17) + SourceIndex(0) -4 >Emitted(2, 20) Source(3, 19) + SourceIndex(0) -5 >Emitted(2, 21) Source(3, 20) + SourceIndex(0) ---- ->>> var c1 = (function () { -1->^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^-> -1-> - > -1->Emitted(3, 5) Source(4, 1) + SourceIndex(0) ---- ->>> function c1() { -1->^^^^^^^^ -2 > ^^-> -1-> -1->Emitted(4, 9) Source(4, 1) + SourceIndex(0) name (c1) ---- ->>> } -1->^^^^^^^^ -2 > ^ -3 > ^^^^^^^^^^-> -1->export class c1 { - > public p1: number; - > -2 > } -1->Emitted(5, 9) Source(6, 1) + SourceIndex(0) name (c1.constructor) -2 >Emitted(5, 10) Source(6, 2) + SourceIndex(0) name (c1.constructor) ---- ->>> return c1; -1->^^^^^^^^ -2 > ^^^^^^^^^ -1-> -2 > } -1->Emitted(6, 9) Source(6, 1) + SourceIndex(0) name (c1) -2 >Emitted(6, 18) Source(6, 2) + SourceIndex(0) name (c1) ---- ->>> })(); -1 >^^^^ -2 > ^ -3 > -4 > ^^^^ -5 > ^^^^^^^^^^^^-> -1 > -2 > } -3 > -4 > export class c1 { - > public p1: number; - > } -1 >Emitted(7, 5) Source(6, 1) + SourceIndex(0) name (c1) -2 >Emitted(7, 6) Source(6, 2) + SourceIndex(0) name (c1) -3 >Emitted(7, 6) Source(4, 1) + SourceIndex(0) -4 >Emitted(7, 10) Source(6, 2) + SourceIndex(0) ---- ->>> exports.c1 = c1; -1->^^^^ -2 > ^^^^^^^^^^ -3 > ^^^^^ -4 > ^ -5 > ^^^^^^^^^^^^^^-> -1-> -2 > c1 -3 > { - > public p1: number; - > } -4 > -1->Emitted(8, 5) Source(4, 14) + SourceIndex(0) -2 >Emitted(8, 15) Source(4, 16) + SourceIndex(0) -3 >Emitted(8, 20) Source(6, 2) + SourceIndex(0) -4 >Emitted(8, 21) Source(6, 2) + SourceIndex(0) ---- ->>> exports.instance1 = new c1(); -1->^^^^ -2 > ^^^^^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^^^ -5 > ^^ -6 > ^^ -7 > ^ -1-> - > - >export var -2 > instance1 -3 > = -4 > new -5 > c1 -6 > () -7 > ; -1->Emitted(9, 5) Source(8, 12) + SourceIndex(0) -2 >Emitted(9, 22) Source(8, 21) + SourceIndex(0) -3 >Emitted(9, 25) Source(8, 24) + SourceIndex(0) -4 >Emitted(9, 29) Source(8, 28) + SourceIndex(0) -5 >Emitted(9, 31) Source(8, 30) + SourceIndex(0) -6 >Emitted(9, 33) Source(8, 32) + SourceIndex(0) -7 >Emitted(9, 34) Source(8, 33) + SourceIndex(0) ---- ->>> function f1() { -1 >^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -1 >Emitted(10, 5) Source(9, 1) + SourceIndex(0) ---- ->>> return exports.instance1; -1->^^^^^^^^ -2 > ^^^^^^ -3 > ^ -4 > ^^^^^^^^^^^^^^^^^ -5 > ^ -1->export function f1() { - > -2 > return -3 > -4 > instance1 -5 > ; -1->Emitted(11, 9) Source(10, 5) + SourceIndex(0) name (f1) -2 >Emitted(11, 15) Source(10, 11) + SourceIndex(0) name (f1) -3 >Emitted(11, 16) Source(10, 12) + SourceIndex(0) name (f1) -4 >Emitted(11, 33) Source(10, 21) + SourceIndex(0) name (f1) -5 >Emitted(11, 34) Source(10, 22) + SourceIndex(0) name (f1) ---- ->>> } -1 >^^^^ -2 > ^ -3 > ^^^^^^^^^^^^^^^^-> -1 > - > -2 > } -1 >Emitted(12, 5) Source(11, 1) + SourceIndex(0) name (f1) -2 >Emitted(12, 6) Source(11, 2) + SourceIndex(0) name (f1) ---- ->>> exports.f1 = f1; -1->^^^^ -2 > ^^^^^^^^^^ -3 > ^^^^^ -4 > ^ -5 > ^^^^^^^-> -1-> -2 > f1 -3 > () { - > return instance1; - > } -4 > -1->Emitted(13, 5) Source(9, 17) + SourceIndex(0) -2 >Emitted(13, 15) Source(9, 19) + SourceIndex(0) -3 >Emitted(13, 20) Source(11, 2) + SourceIndex(0) -4 >Emitted(13, 21) Source(11, 2) + SourceIndex(0) ---- ->>> exports.a2 = m1.m1_c1; -1->^^^^ -2 > ^^^^^^^^^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^ -7 > ^ -8 > ^-> -1-> - > - >export var -2 > a2 -3 > = -4 > m1 -5 > . -6 > m1_c1 -7 > ; -1->Emitted(14, 5) Source(13, 12) + SourceIndex(0) -2 >Emitted(14, 15) Source(13, 14) + SourceIndex(0) -3 >Emitted(14, 18) Source(13, 17) + SourceIndex(0) -4 >Emitted(14, 20) Source(13, 19) + SourceIndex(0) -5 >Emitted(14, 21) Source(13, 20) + SourceIndex(0) -6 >Emitted(14, 26) Source(13, 25) + SourceIndex(0) -7 >Emitted(14, 27) Source(13, 26) + SourceIndex(0) ---- ->>> exports.a3 = m2.m2_c1; -1->^^^^ -2 > ^^^^^^^^^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^ -7 > ^ -1-> - >export var -2 > a3 -3 > = -4 > m2 -5 > . -6 > m2_c1 -7 > ; -1->Emitted(15, 5) Source(14, 12) + SourceIndex(0) -2 >Emitted(15, 15) Source(14, 14) + SourceIndex(0) -3 >Emitted(15, 18) Source(14, 17) + SourceIndex(0) -4 >Emitted(15, 20) Source(14, 19) + SourceIndex(0) -5 >Emitted(15, 21) Source(14, 20) + SourceIndex(0) -6 >Emitted(15, 26) Source(14, 25) + SourceIndex(0) -7 >Emitted(15, 27) Source(14, 26) + SourceIndex(0) ---- ->>>}); ->>>//# sourceMappingURL=/tests/cases/projects/outputdir_module_multifolder/mapFiles/outputdir_module_multifolder/test.js.map=================================================================== JsFile: test.js mapUrl: /tests/cases/projects/outputdir_module_multifolder/mapFiles/test.js.map sourceRoot: diff --git a/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderSpecifyOutputFile/amd/ref/m1.d.ts b/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderSpecifyOutputFile/amd/ref/m1.d.ts deleted file mode 100644 index 4a53b24b156..00000000000 --- a/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderSpecifyOutputFile/amd/ref/m1.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -export declare var m1_a1: number; -export declare class m1_c1 { - m1_c1_p1: number; -} -export declare var m1_instance1: m1_c1; -export declare function m1_f1(): m1_c1; diff --git a/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderSpecifyOutputFile/amd/ref/m1.js b/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderSpecifyOutputFile/amd/ref/m1.js deleted file mode 100644 index 52b5e682660..00000000000 --- a/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderSpecifyOutputFile/amd/ref/m1.js +++ /dev/null @@ -1,15 +0,0 @@ -define(["require", "exports"], function (require, exports) { - exports.m1_a1 = 10; - var m1_c1 = (function () { - function m1_c1() { - } - return m1_c1; - })(); - exports.m1_c1 = m1_c1; - exports.m1_instance1 = new m1_c1(); - function m1_f1() { - return exports.m1_instance1; - } - exports.m1_f1 = m1_f1; -}); -//# sourceMappingURL=/tests/cases/projects/outputdir_module_multifolder/mapFiles/outputdir_module_multifolder/ref/m1.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderSpecifyOutputFile/amd/ref/m1.js.map b/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderSpecifyOutputFile/amd/ref/m1.js.map deleted file mode 100644 index 652d934d602..00000000000 --- a/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderSpecifyOutputFile/amd/ref/m1.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"m1.js","sourceRoot":"","sources":["../../../ref/m1.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1"],"mappings":";IAAW,aAAK,GAAG,EAAE,CAAC;IACtB;QAAAA;QAEAC,CAACA;QAADD,YAACA;IAADA,CAACA,AAFD,IAEC;IAFY,aAAK,QAEjB,CAAA;IAEU,oBAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACIE,MAAMA,CAACA,oBAAYA,CAACA;IACxBA,CAACA;IAFe,aAAK,QAEpB,CAAA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderSpecifyOutputFile/amd/test.d.ts b/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderSpecifyOutputFile/amd/test.d.ts deleted file mode 100644 index 4afd4e69f2d..00000000000 --- a/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderSpecifyOutputFile/amd/test.d.ts +++ /dev/null @@ -1,10 +0,0 @@ -import m1 = require("ref/m1"); -import m2 = require("../outputdir_module_multifolder_ref/m2"); -export declare var a1: number; -export declare class c1 { - p1: number; -} -export declare var instance1: c1; -export declare function f1(): c1; -export declare var a2: typeof m1.m1_c1; -export declare var a3: typeof m2.m2_c1; diff --git a/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderSpecifyOutputFile/amd/test.js b/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderSpecifyOutputFile/amd/test.js deleted file mode 100644 index a2a29b4dcfc..00000000000 --- a/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderSpecifyOutputFile/amd/test.js +++ /dev/null @@ -1,17 +0,0 @@ -define(["require", "exports", "ref/m1", "../outputdir_module_multifolder_ref/m2"], function (require, exports, m1, m2) { - exports.a1 = 10; - var c1 = (function () { - function c1() { - } - return c1; - })(); - exports.c1 = c1; - exports.instance1 = new c1(); - function f1() { - return exports.instance1; - } - exports.f1 = f1; - exports.a2 = m1.m1_c1; - exports.a3 = m2.m2_c1; -}); -//# sourceMappingURL=/tests/cases/projects/outputdir_module_multifolder/mapFiles/outputdir_module_multifolder/test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderSpecifyOutputFile/amd/test.js.map b/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderSpecifyOutputFile/amd/test.js.map deleted file mode 100644 index be0b3a580f5..00000000000 --- a/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderSpecifyOutputFile/amd/test.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"test.js","sourceRoot":"","sources":["../../test.ts"],"names":["c1","c1.constructor","f1"],"mappings":";IAEW,UAAE,GAAG,EAAE,CAAC;IACnB;QAAAA;QAEAC,CAACA;QAADD,SAACA;IAADA,CAACA,AAFD,IAEC;IAFY,UAAE,KAEd,CAAA;IAEU,iBAAS,GAAG,IAAI,EAAE,EAAE,CAAC;IAChC;QACIE,MAAMA,CAACA,iBAASA,CAACA;IACrBA,CAACA;IAFe,UAAE,KAEjB,CAAA;IAEU,UAAE,GAAG,EAAE,CAAC,KAAK,CAAC;IACd,UAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderSpecifyOutputFile/node/diskFile0.js.map b/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderSpecifyOutputFile/node/diskFile0.js.map deleted file mode 100644 index f9d0dd89e9c..00000000000 --- a/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderSpecifyOutputFile/node/diskFile0.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"m2.js","sourceRoot":"","sources":["../../../outputdir_module_multifolder_ref/m2.ts"],"names":["m2_c1","m2_c1.constructor","m2_f1"],"mappings":"AAAW,aAAK,GAAG,EAAE,CAAC;AACtB;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAFY,aAAK,QAEjB,CAAA;AAEU,oBAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACIE,MAAMA,CAACA,oBAAYA,CAACA;AACxBA,CAACA;AAFe,aAAK,QAEpB,CAAA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderSpecifyOutputFile/node/diskFile1.js b/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderSpecifyOutputFile/node/diskFile1.js deleted file mode 100644 index 589c5838a2c..00000000000 --- a/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderSpecifyOutputFile/node/diskFile1.js +++ /dev/null @@ -1,13 +0,0 @@ -exports.m2_a1 = 10; -var m2_c1 = (function () { - function m2_c1() { - } - return m2_c1; -})(); -exports.m2_c1 = m2_c1; -exports.m2_instance1 = new m2_c1(); -function m2_f1() { - return exports.m2_instance1; -} -exports.m2_f1 = m2_f1; -//# sourceMappingURL=/tests/cases/projects/outputdir_module_multifolder/mapFiles/outputdir_module_multifolder_ref/m2.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderSpecifyOutputFile/node/diskFile2.d.ts b/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderSpecifyOutputFile/node/diskFile2.d.ts deleted file mode 100644 index c09a3c0c32a..00000000000 --- a/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderSpecifyOutputFile/node/diskFile2.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -export declare var m2_a1: number; -export declare class m2_c1 { - m2_c1_p1: number; -} -export declare var m2_instance1: m2_c1; -export declare function m2_f1(): m2_c1; diff --git a/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderSpecifyOutputFile/node/mapRootAbsolutePathModuleMultifolderSpecifyOutputFile.json b/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderSpecifyOutputFile/node/mapRootAbsolutePathModuleMultifolderSpecifyOutputFile.json index 6432d5ae91e..4869993ca92 100644 --- a/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderSpecifyOutputFile/node/mapRootAbsolutePathModuleMultifolderSpecifyOutputFile.json +++ b/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderSpecifyOutputFile/node/mapRootAbsolutePathModuleMultifolderSpecifyOutputFile.json @@ -17,15 +17,6 @@ "test.ts" ], "emittedFiles": [ - "ref/m1.js.map", - "ref/m1.js", - "ref/m1.d.ts", - "../outputdir_module_multifolder_ref/m2.js.map", - "../outputdir_module_multifolder_ref/m2.js", - "../outputdir_module_multifolder_ref/m2.d.ts", - "test.js.map", - "test.js", - "test.d.ts", "bin/test.js.map", "bin/test.js", "bin/test.d.ts" diff --git a/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderSpecifyOutputFile/node/mapRootAbsolutePathModuleMultifolderSpecifyOutputFile.sourcemap.txt b/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderSpecifyOutputFile/node/mapRootAbsolutePathModuleMultifolderSpecifyOutputFile.sourcemap.txt index 47e6fcc66ef..5b0497285e2 100644 --- a/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderSpecifyOutputFile/node/mapRootAbsolutePathModuleMultifolderSpecifyOutputFile.sourcemap.txt +++ b/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderSpecifyOutputFile/node/mapRootAbsolutePathModuleMultifolderSpecifyOutputFile.sourcemap.txt @@ -1,617 +1,4 @@ =================================================================== -JsFile: m1.js -mapUrl: /tests/cases/projects/outputdir_module_multifolder/mapFiles/outputdir_module_multifolder/ref/m1.js.map -sourceRoot: -sources: ../../../ref/m1.ts -=================================================================== -------------------------------------------------------------------- -emittedFile:ref/m1.js -sourceFile:../../../ref/m1.ts -------------------------------------------------------------------- ->>>exports.m1_a1 = 10; -1 > -2 >^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^-> -1 >export var -2 >m1_a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(1, 1) Source(1, 12) + SourceIndex(0) -2 >Emitted(1, 14) Source(1, 17) + SourceIndex(0) -3 >Emitted(1, 17) Source(1, 20) + SourceIndex(0) -4 >Emitted(1, 19) Source(1, 22) + SourceIndex(0) -5 >Emitted(1, 20) Source(1, 23) + SourceIndex(0) ---- ->>>var m1_c1 = (function () { -1-> -2 >^^^^^^^^^^^^^^^^^^^^^^^-> -1-> - > -1->Emitted(2, 1) Source(2, 1) + SourceIndex(0) ---- ->>> function m1_c1() { -1->^^^^ -2 > ^^-> -1-> -1->Emitted(3, 5) Source(2, 1) + SourceIndex(0) name (m1_c1) ---- ->>> } -1->^^^^ -2 > ^ -3 > ^^^^^^^^^^^^^-> -1->export class m1_c1 { - > public m1_c1_p1: number; - > -2 > } -1->Emitted(4, 5) Source(4, 1) + SourceIndex(0) name (m1_c1.constructor) -2 >Emitted(4, 6) Source(4, 2) + SourceIndex(0) name (m1_c1.constructor) ---- ->>> return m1_c1; -1->^^^^ -2 > ^^^^^^^^^^^^ -1-> -2 > } -1->Emitted(5, 5) Source(4, 1) + SourceIndex(0) name (m1_c1) -2 >Emitted(5, 17) Source(4, 2) + SourceIndex(0) name (m1_c1) ---- ->>>})(); -1 > -2 >^ -3 > -4 > ^^^^ -5 > ^^^^^^^^^^^^^^^^^^-> -1 > -2 >} -3 > -4 > export class m1_c1 { - > public m1_c1_p1: number; - > } -1 >Emitted(6, 1) Source(4, 1) + SourceIndex(0) name (m1_c1) -2 >Emitted(6, 2) Source(4, 2) + SourceIndex(0) name (m1_c1) -3 >Emitted(6, 2) Source(2, 1) + SourceIndex(0) -4 >Emitted(6, 6) Source(4, 2) + SourceIndex(0) ---- ->>>exports.m1_c1 = m1_c1; -1-> -2 >^^^^^^^^^^^^^ -3 > ^^^^^^^^ -4 > ^ -5 > ^^^^^^^^^^^^^^-> -1-> -2 >m1_c1 -3 > { - > public m1_c1_p1: number; - > } -4 > -1->Emitted(7, 1) Source(2, 14) + SourceIndex(0) -2 >Emitted(7, 14) Source(2, 19) + SourceIndex(0) -3 >Emitted(7, 22) Source(4, 2) + SourceIndex(0) -4 >Emitted(7, 23) Source(4, 2) + SourceIndex(0) ---- ->>>exports.m1_instance1 = new m1_c1(); -1-> -2 >^^^^^^^^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^^^ -5 > ^^^^^ -6 > ^^ -7 > ^ -1-> - > - >export var -2 >m1_instance1 -3 > = -4 > new -5 > m1_c1 -6 > () -7 > ; -1->Emitted(8, 1) Source(6, 12) + SourceIndex(0) -2 >Emitted(8, 21) Source(6, 24) + SourceIndex(0) -3 >Emitted(8, 24) Source(6, 27) + SourceIndex(0) -4 >Emitted(8, 28) Source(6, 31) + SourceIndex(0) -5 >Emitted(8, 33) Source(6, 36) + SourceIndex(0) -6 >Emitted(8, 35) Source(6, 38) + SourceIndex(0) -7 >Emitted(8, 36) Source(6, 39) + SourceIndex(0) ---- ->>>function m1_f1() { -1 > -2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -1 >Emitted(9, 1) Source(7, 1) + SourceIndex(0) ---- ->>> return exports.m1_instance1; -1->^^^^ -2 > ^^^^^^ -3 > ^ -4 > ^^^^^^^^^^^^^^^^^^^^ -5 > ^ -1->export function m1_f1() { - > -2 > return -3 > -4 > m1_instance1 -5 > ; -1->Emitted(10, 5) Source(8, 5) + SourceIndex(0) name (m1_f1) -2 >Emitted(10, 11) Source(8, 11) + SourceIndex(0) name (m1_f1) -3 >Emitted(10, 12) Source(8, 12) + SourceIndex(0) name (m1_f1) -4 >Emitted(10, 32) Source(8, 24) + SourceIndex(0) name (m1_f1) -5 >Emitted(10, 33) Source(8, 25) + SourceIndex(0) name (m1_f1) ---- ->>>} -1 > -2 >^ -3 > ^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -2 >} -1 >Emitted(11, 1) Source(9, 1) + SourceIndex(0) name (m1_f1) -2 >Emitted(11, 2) Source(9, 2) + SourceIndex(0) name (m1_f1) ---- ->>>exports.m1_f1 = m1_f1; -1-> -2 >^^^^^^^^^^^^^ -3 > ^^^^^^^^ -4 > ^ -5 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1-> -2 >m1_f1 -3 > () { - > return m1_instance1; - > } -4 > -1->Emitted(12, 1) Source(7, 17) + SourceIndex(0) -2 >Emitted(12, 14) Source(7, 22) + SourceIndex(0) -3 >Emitted(12, 22) Source(9, 2) + SourceIndex(0) -4 >Emitted(12, 23) Source(9, 2) + SourceIndex(0) ---- ->>>//# sourceMappingURL=/tests/cases/projects/outputdir_module_multifolder/mapFiles/outputdir_module_multifolder/ref/m1.js.map=================================================================== -JsFile: m2.js -mapUrl: /tests/cases/projects/outputdir_module_multifolder/mapFiles/outputdir_module_multifolder_ref/m2.js.map -sourceRoot: -sources: ../../../outputdir_module_multifolder_ref/m2.ts -=================================================================== -------------------------------------------------------------------- -emittedFile:diskFile1.js -sourceFile:../../../outputdir_module_multifolder_ref/m2.ts -------------------------------------------------------------------- ->>>exports.m2_a1 = 10; -1 > -2 >^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^-> -1 >export var -2 >m2_a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(1, 1) Source(1, 12) + SourceIndex(0) -2 >Emitted(1, 14) Source(1, 17) + SourceIndex(0) -3 >Emitted(1, 17) Source(1, 20) + SourceIndex(0) -4 >Emitted(1, 19) Source(1, 22) + SourceIndex(0) -5 >Emitted(1, 20) Source(1, 23) + SourceIndex(0) ---- ->>>var m2_c1 = (function () { -1-> -2 >^^^^^^^^^^^^^^^^^^^^^^^-> -1-> - > -1->Emitted(2, 1) Source(2, 1) + SourceIndex(0) ---- ->>> function m2_c1() { -1->^^^^ -2 > ^^-> -1-> -1->Emitted(3, 5) Source(2, 1) + SourceIndex(0) name (m2_c1) ---- ->>> } -1->^^^^ -2 > ^ -3 > ^^^^^^^^^^^^^-> -1->export class m2_c1 { - > public m2_c1_p1: number; - > -2 > } -1->Emitted(4, 5) Source(4, 1) + SourceIndex(0) name (m2_c1.constructor) -2 >Emitted(4, 6) Source(4, 2) + SourceIndex(0) name (m2_c1.constructor) ---- ->>> return m2_c1; -1->^^^^ -2 > ^^^^^^^^^^^^ -1-> -2 > } -1->Emitted(5, 5) Source(4, 1) + SourceIndex(0) name (m2_c1) -2 >Emitted(5, 17) Source(4, 2) + SourceIndex(0) name (m2_c1) ---- ->>>})(); -1 > -2 >^ -3 > -4 > ^^^^ -5 > ^^^^^^^^^^^^^^^^^^-> -1 > -2 >} -3 > -4 > export class m2_c1 { - > public m2_c1_p1: number; - > } -1 >Emitted(6, 1) Source(4, 1) + SourceIndex(0) name (m2_c1) -2 >Emitted(6, 2) Source(4, 2) + SourceIndex(0) name (m2_c1) -3 >Emitted(6, 2) Source(2, 1) + SourceIndex(0) -4 >Emitted(6, 6) Source(4, 2) + SourceIndex(0) ---- ->>>exports.m2_c1 = m2_c1; -1-> -2 >^^^^^^^^^^^^^ -3 > ^^^^^^^^ -4 > ^ -5 > ^^^^^^^^^^^^^^-> -1-> -2 >m2_c1 -3 > { - > public m2_c1_p1: number; - > } -4 > -1->Emitted(7, 1) Source(2, 14) + SourceIndex(0) -2 >Emitted(7, 14) Source(2, 19) + SourceIndex(0) -3 >Emitted(7, 22) Source(4, 2) + SourceIndex(0) -4 >Emitted(7, 23) Source(4, 2) + SourceIndex(0) ---- ->>>exports.m2_instance1 = new m2_c1(); -1-> -2 >^^^^^^^^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^^^ -5 > ^^^^^ -6 > ^^ -7 > ^ -1-> - > - >export var -2 >m2_instance1 -3 > = -4 > new -5 > m2_c1 -6 > () -7 > ; -1->Emitted(8, 1) Source(6, 12) + SourceIndex(0) -2 >Emitted(8, 21) Source(6, 24) + SourceIndex(0) -3 >Emitted(8, 24) Source(6, 27) + SourceIndex(0) -4 >Emitted(8, 28) Source(6, 31) + SourceIndex(0) -5 >Emitted(8, 33) Source(6, 36) + SourceIndex(0) -6 >Emitted(8, 35) Source(6, 38) + SourceIndex(0) -7 >Emitted(8, 36) Source(6, 39) + SourceIndex(0) ---- ->>>function m2_f1() { -1 > -2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -1 >Emitted(9, 1) Source(7, 1) + SourceIndex(0) ---- ->>> return exports.m2_instance1; -1->^^^^ -2 > ^^^^^^ -3 > ^ -4 > ^^^^^^^^^^^^^^^^^^^^ -5 > ^ -1->export function m2_f1() { - > -2 > return -3 > -4 > m2_instance1 -5 > ; -1->Emitted(10, 5) Source(8, 5) + SourceIndex(0) name (m2_f1) -2 >Emitted(10, 11) Source(8, 11) + SourceIndex(0) name (m2_f1) -3 >Emitted(10, 12) Source(8, 12) + SourceIndex(0) name (m2_f1) -4 >Emitted(10, 32) Source(8, 24) + SourceIndex(0) name (m2_f1) -5 >Emitted(10, 33) Source(8, 25) + SourceIndex(0) name (m2_f1) ---- ->>>} -1 > -2 >^ -3 > ^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -2 >} -1 >Emitted(11, 1) Source(9, 1) + SourceIndex(0) name (m2_f1) -2 >Emitted(11, 2) Source(9, 2) + SourceIndex(0) name (m2_f1) ---- ->>>exports.m2_f1 = m2_f1; -1-> -2 >^^^^^^^^^^^^^ -3 > ^^^^^^^^ -4 > ^ -5 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1-> -2 >m2_f1 -3 > () { - > return m2_instance1; - > } -4 > -1->Emitted(12, 1) Source(7, 17) + SourceIndex(0) -2 >Emitted(12, 14) Source(7, 22) + SourceIndex(0) -3 >Emitted(12, 22) Source(9, 2) + SourceIndex(0) -4 >Emitted(12, 23) Source(9, 2) + SourceIndex(0) ---- ->>>//# sourceMappingURL=/tests/cases/projects/outputdir_module_multifolder/mapFiles/outputdir_module_multifolder_ref/m2.js.map=================================================================== -JsFile: test.js -mapUrl: /tests/cases/projects/outputdir_module_multifolder/mapFiles/outputdir_module_multifolder/test.js.map -sourceRoot: -sources: ../../test.ts -=================================================================== -------------------------------------------------------------------- -emittedFile:test.js -sourceFile:../../test.ts -------------------------------------------------------------------- ->>>var m1 = require("ref/m1"); -1 > -2 >^^^^ -3 > ^^ -4 > ^^^^^^^^^^^ -5 > ^^^^^^^^ -6 > ^ -7 > ^ -8 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 > -2 >import -3 > m1 -4 > = require( -5 > "ref/m1" -6 > ) -7 > ; -1 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) -2 >Emitted(1, 5) Source(1, 8) + SourceIndex(0) -3 >Emitted(1, 7) Source(1, 10) + SourceIndex(0) -4 >Emitted(1, 18) Source(1, 21) + SourceIndex(0) -5 >Emitted(1, 26) Source(1, 29) + SourceIndex(0) -6 >Emitted(1, 27) Source(1, 30) + SourceIndex(0) -7 >Emitted(1, 28) Source(1, 31) + SourceIndex(0) ---- ->>>var m2 = require("../outputdir_module_multifolder_ref/m2"); -1-> -2 >^^^^ -3 > ^^ -4 > ^^^^^^^^^^^ -5 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -6 > ^ -7 > ^ -1-> - > -2 >import -3 > m2 -4 > = require( -5 > "../outputdir_module_multifolder_ref/m2" -6 > ) -7 > ; -1->Emitted(2, 1) Source(2, 1) + SourceIndex(0) -2 >Emitted(2, 5) Source(2, 8) + SourceIndex(0) -3 >Emitted(2, 7) Source(2, 10) + SourceIndex(0) -4 >Emitted(2, 18) Source(2, 21) + SourceIndex(0) -5 >Emitted(2, 58) Source(2, 61) + SourceIndex(0) -6 >Emitted(2, 59) Source(2, 62) + SourceIndex(0) -7 >Emitted(2, 60) Source(2, 63) + SourceIndex(0) ---- ->>>exports.a1 = 10; -1 > -2 >^^^^^^^^^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^-> -1 > - >export var -2 >a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(3, 1) Source(3, 12) + SourceIndex(0) -2 >Emitted(3, 11) Source(3, 14) + SourceIndex(0) -3 >Emitted(3, 14) Source(3, 17) + SourceIndex(0) -4 >Emitted(3, 16) Source(3, 19) + SourceIndex(0) -5 >Emitted(3, 17) Source(3, 20) + SourceIndex(0) ---- ->>>var c1 = (function () { -1-> -2 >^^^^^^^^^^^^^^^^^^^^-> -1-> - > -1->Emitted(4, 1) Source(4, 1) + SourceIndex(0) ---- ->>> function c1() { -1->^^^^ -2 > ^^-> -1-> -1->Emitted(5, 5) Source(4, 1) + SourceIndex(0) name (c1) ---- ->>> } -1->^^^^ -2 > ^ -3 > ^^^^^^^^^^-> -1->export class c1 { - > public p1: number; - > -2 > } -1->Emitted(6, 5) Source(6, 1) + SourceIndex(0) name (c1.constructor) -2 >Emitted(6, 6) Source(6, 2) + SourceIndex(0) name (c1.constructor) ---- ->>> return c1; -1->^^^^ -2 > ^^^^^^^^^ -1-> -2 > } -1->Emitted(7, 5) Source(6, 1) + SourceIndex(0) name (c1) -2 >Emitted(7, 14) Source(6, 2) + SourceIndex(0) name (c1) ---- ->>>})(); -1 > -2 >^ -3 > -4 > ^^^^ -5 > ^^^^^^^^^^^^-> -1 > -2 >} -3 > -4 > export class c1 { - > public p1: number; - > } -1 >Emitted(8, 1) Source(6, 1) + SourceIndex(0) name (c1) -2 >Emitted(8, 2) Source(6, 2) + SourceIndex(0) name (c1) -3 >Emitted(8, 2) Source(4, 1) + SourceIndex(0) -4 >Emitted(8, 6) Source(6, 2) + SourceIndex(0) ---- ->>>exports.c1 = c1; -1-> -2 >^^^^^^^^^^ -3 > ^^^^^ -4 > ^ -5 > ^^^^^^^^^^^^^^-> -1-> -2 >c1 -3 > { - > public p1: number; - > } -4 > -1->Emitted(9, 1) Source(4, 14) + SourceIndex(0) -2 >Emitted(9, 11) Source(4, 16) + SourceIndex(0) -3 >Emitted(9, 16) Source(6, 2) + SourceIndex(0) -4 >Emitted(9, 17) Source(6, 2) + SourceIndex(0) ---- ->>>exports.instance1 = new c1(); -1-> -2 >^^^^^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^^^ -5 > ^^ -6 > ^^ -7 > ^ -1-> - > - >export var -2 >instance1 -3 > = -4 > new -5 > c1 -6 > () -7 > ; -1->Emitted(10, 1) Source(8, 12) + SourceIndex(0) -2 >Emitted(10, 18) Source(8, 21) + SourceIndex(0) -3 >Emitted(10, 21) Source(8, 24) + SourceIndex(0) -4 >Emitted(10, 25) Source(8, 28) + SourceIndex(0) -5 >Emitted(10, 27) Source(8, 30) + SourceIndex(0) -6 >Emitted(10, 29) Source(8, 32) + SourceIndex(0) -7 >Emitted(10, 30) Source(8, 33) + SourceIndex(0) ---- ->>>function f1() { -1 > -2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -1 >Emitted(11, 1) Source(9, 1) + SourceIndex(0) ---- ->>> return exports.instance1; -1->^^^^ -2 > ^^^^^^ -3 > ^ -4 > ^^^^^^^^^^^^^^^^^ -5 > ^ -1->export function f1() { - > -2 > return -3 > -4 > instance1 -5 > ; -1->Emitted(12, 5) Source(10, 5) + SourceIndex(0) name (f1) -2 >Emitted(12, 11) Source(10, 11) + SourceIndex(0) name (f1) -3 >Emitted(12, 12) Source(10, 12) + SourceIndex(0) name (f1) -4 >Emitted(12, 29) Source(10, 21) + SourceIndex(0) name (f1) -5 >Emitted(12, 30) Source(10, 22) + SourceIndex(0) name (f1) ---- ->>>} -1 > -2 >^ -3 > ^^^^^^^^^^^^^^^^-> -1 > - > -2 >} -1 >Emitted(13, 1) Source(11, 1) + SourceIndex(0) name (f1) -2 >Emitted(13, 2) Source(11, 2) + SourceIndex(0) name (f1) ---- ->>>exports.f1 = f1; -1-> -2 >^^^^^^^^^^ -3 > ^^^^^ -4 > ^ -5 > ^^^^^^^-> -1-> -2 >f1 -3 > () { - > return instance1; - > } -4 > -1->Emitted(14, 1) Source(9, 17) + SourceIndex(0) -2 >Emitted(14, 11) Source(9, 19) + SourceIndex(0) -3 >Emitted(14, 16) Source(11, 2) + SourceIndex(0) -4 >Emitted(14, 17) Source(11, 2) + SourceIndex(0) ---- ->>>exports.a2 = m1.m1_c1; -1-> -2 >^^^^^^^^^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^ -7 > ^ -8 > ^-> -1-> - > - >export var -2 >a2 -3 > = -4 > m1 -5 > . -6 > m1_c1 -7 > ; -1->Emitted(15, 1) Source(13, 12) + SourceIndex(0) -2 >Emitted(15, 11) Source(13, 14) + SourceIndex(0) -3 >Emitted(15, 14) Source(13, 17) + SourceIndex(0) -4 >Emitted(15, 16) Source(13, 19) + SourceIndex(0) -5 >Emitted(15, 17) Source(13, 20) + SourceIndex(0) -6 >Emitted(15, 22) Source(13, 25) + SourceIndex(0) -7 >Emitted(15, 23) Source(13, 26) + SourceIndex(0) ---- ->>>exports.a3 = m2.m2_c1; -1-> -2 >^^^^^^^^^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^ -7 > ^ -8 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1-> - >export var -2 >a3 -3 > = -4 > m2 -5 > . -6 > m2_c1 -7 > ; -1->Emitted(16, 1) Source(14, 12) + SourceIndex(0) -2 >Emitted(16, 11) Source(14, 14) + SourceIndex(0) -3 >Emitted(16, 14) Source(14, 17) + SourceIndex(0) -4 >Emitted(16, 16) Source(14, 19) + SourceIndex(0) -5 >Emitted(16, 17) Source(14, 20) + SourceIndex(0) -6 >Emitted(16, 22) Source(14, 25) + SourceIndex(0) -7 >Emitted(16, 23) Source(14, 26) + SourceIndex(0) ---- ->>>//# sourceMappingURL=/tests/cases/projects/outputdir_module_multifolder/mapFiles/outputdir_module_multifolder/test.js.map=================================================================== JsFile: test.js mapUrl: /tests/cases/projects/outputdir_module_multifolder/mapFiles/test.js.map sourceRoot: diff --git a/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderSpecifyOutputFile/node/ref/m1.d.ts b/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderSpecifyOutputFile/node/ref/m1.d.ts deleted file mode 100644 index 4a53b24b156..00000000000 --- a/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderSpecifyOutputFile/node/ref/m1.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -export declare var m1_a1: number; -export declare class m1_c1 { - m1_c1_p1: number; -} -export declare var m1_instance1: m1_c1; -export declare function m1_f1(): m1_c1; diff --git a/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderSpecifyOutputFile/node/ref/m1.js b/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderSpecifyOutputFile/node/ref/m1.js deleted file mode 100644 index b0e6a265bc9..00000000000 --- a/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderSpecifyOutputFile/node/ref/m1.js +++ /dev/null @@ -1,13 +0,0 @@ -exports.m1_a1 = 10; -var m1_c1 = (function () { - function m1_c1() { - } - return m1_c1; -})(); -exports.m1_c1 = m1_c1; -exports.m1_instance1 = new m1_c1(); -function m1_f1() { - return exports.m1_instance1; -} -exports.m1_f1 = m1_f1; -//# sourceMappingURL=/tests/cases/projects/outputdir_module_multifolder/mapFiles/outputdir_module_multifolder/ref/m1.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderSpecifyOutputFile/node/ref/m1.js.map b/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderSpecifyOutputFile/node/ref/m1.js.map deleted file mode 100644 index 15bddd32fe5..00000000000 --- a/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderSpecifyOutputFile/node/ref/m1.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"m1.js","sourceRoot":"","sources":["../../../ref/m1.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1"],"mappings":"AAAW,aAAK,GAAG,EAAE,CAAC;AACtB;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAFY,aAAK,QAEjB,CAAA;AAEU,oBAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACIE,MAAMA,CAACA,oBAAYA,CAACA;AACxBA,CAACA;AAFe,aAAK,QAEpB,CAAA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderSpecifyOutputFile/node/test.d.ts b/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderSpecifyOutputFile/node/test.d.ts deleted file mode 100644 index 4afd4e69f2d..00000000000 --- a/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderSpecifyOutputFile/node/test.d.ts +++ /dev/null @@ -1,10 +0,0 @@ -import m1 = require("ref/m1"); -import m2 = require("../outputdir_module_multifolder_ref/m2"); -export declare var a1: number; -export declare class c1 { - p1: number; -} -export declare var instance1: c1; -export declare function f1(): c1; -export declare var a2: typeof m1.m1_c1; -export declare var a3: typeof m2.m2_c1; diff --git a/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderSpecifyOutputFile/node/test.js b/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderSpecifyOutputFile/node/test.js deleted file mode 100644 index 16422a234c5..00000000000 --- a/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderSpecifyOutputFile/node/test.js +++ /dev/null @@ -1,17 +0,0 @@ -var m1 = require("ref/m1"); -var m2 = require("../outputdir_module_multifolder_ref/m2"); -exports.a1 = 10; -var c1 = (function () { - function c1() { - } - return c1; -})(); -exports.c1 = c1; -exports.instance1 = new c1(); -function f1() { - return exports.instance1; -} -exports.f1 = f1; -exports.a2 = m1.m1_c1; -exports.a3 = m2.m2_c1; -//# sourceMappingURL=/tests/cases/projects/outputdir_module_multifolder/mapFiles/outputdir_module_multifolder/test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderSpecifyOutputFile/node/test.js.map b/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderSpecifyOutputFile/node/test.js.map deleted file mode 100644 index eae921435ac..00000000000 --- a/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderSpecifyOutputFile/node/test.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"test.js","sourceRoot":"","sources":["../../test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AAAA,IAAO,EAAE,WAAW,QAAQ,CAAC,CAAC;AAC9B,IAAO,EAAE,WAAW,wCAAwC,CAAC,CAAC;AACnD,UAAE,GAAG,EAAE,CAAC;AACnB;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAFY,UAAE,KAEd,CAAA;AAEU,iBAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AAChC;IACIE,MAAMA,CAACA,iBAASA,CAACA;AACrBA,CAACA;AAFe,UAAE,KAEjB,CAAA;AAEU,UAAE,GAAG,EAAE,CAAC,KAAK,CAAC;AACd,UAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootAbsolutePathModuleSimpleSpecifyOutputFile/amd/m1.d.ts b/tests/baselines/reference/project/mapRootAbsolutePathModuleSimpleSpecifyOutputFile/amd/m1.d.ts deleted file mode 100644 index 4a53b24b156..00000000000 --- a/tests/baselines/reference/project/mapRootAbsolutePathModuleSimpleSpecifyOutputFile/amd/m1.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -export declare var m1_a1: number; -export declare class m1_c1 { - m1_c1_p1: number; -} -export declare var m1_instance1: m1_c1; -export declare function m1_f1(): m1_c1; diff --git a/tests/baselines/reference/project/mapRootAbsolutePathModuleSimpleSpecifyOutputFile/amd/m1.js b/tests/baselines/reference/project/mapRootAbsolutePathModuleSimpleSpecifyOutputFile/amd/m1.js deleted file mode 100644 index 86c0ba41238..00000000000 --- a/tests/baselines/reference/project/mapRootAbsolutePathModuleSimpleSpecifyOutputFile/amd/m1.js +++ /dev/null @@ -1,15 +0,0 @@ -define(["require", "exports"], function (require, exports) { - exports.m1_a1 = 10; - var m1_c1 = (function () { - function m1_c1() { - } - return m1_c1; - })(); - exports.m1_c1 = m1_c1; - exports.m1_instance1 = new m1_c1(); - function m1_f1() { - return exports.m1_instance1; - } - exports.m1_f1 = m1_f1; -}); -//# sourceMappingURL=/tests/cases/projects/outputdir_module_simple/mapFiles/m1.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootAbsolutePathModuleSimpleSpecifyOutputFile/amd/m1.js.map b/tests/baselines/reference/project/mapRootAbsolutePathModuleSimpleSpecifyOutputFile/amd/m1.js.map deleted file mode 100644 index 7f5576a8a9c..00000000000 --- a/tests/baselines/reference/project/mapRootAbsolutePathModuleSimpleSpecifyOutputFile/amd/m1.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"m1.js","sourceRoot":"","sources":["../m1.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1"],"mappings":";IAAW,aAAK,GAAG,EAAE,CAAC;IACtB;QAAAA;QAEAC,CAACA;QAADD,YAACA;IAADA,CAACA,AAFD,IAEC;IAFY,aAAK,QAEjB,CAAA;IAEU,oBAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACIE,MAAMA,CAACA,oBAAYA,CAACA;IACxBA,CAACA;IAFe,aAAK,QAEpB,CAAA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootAbsolutePathModuleSimpleSpecifyOutputFile/amd/mapRootAbsolutePathModuleSimpleSpecifyOutputFile.json b/tests/baselines/reference/project/mapRootAbsolutePathModuleSimpleSpecifyOutputFile/amd/mapRootAbsolutePathModuleSimpleSpecifyOutputFile.json index f703a63b71f..742acdc7a25 100644 --- a/tests/baselines/reference/project/mapRootAbsolutePathModuleSimpleSpecifyOutputFile/amd/mapRootAbsolutePathModuleSimpleSpecifyOutputFile.json +++ b/tests/baselines/reference/project/mapRootAbsolutePathModuleSimpleSpecifyOutputFile/amd/mapRootAbsolutePathModuleSimpleSpecifyOutputFile.json @@ -16,12 +16,6 @@ "test.ts" ], "emittedFiles": [ - "m1.js.map", - "m1.js", - "m1.d.ts", - "test.js.map", - "test.js", - "test.d.ts", "bin/test.js.map", "bin/test.js", "bin/test.d.ts" diff --git a/tests/baselines/reference/project/mapRootAbsolutePathModuleSimpleSpecifyOutputFile/amd/mapRootAbsolutePathModuleSimpleSpecifyOutputFile.sourcemap.txt b/tests/baselines/reference/project/mapRootAbsolutePathModuleSimpleSpecifyOutputFile/amd/mapRootAbsolutePathModuleSimpleSpecifyOutputFile.sourcemap.txt index ef240e21383..d8ab3db1266 100644 --- a/tests/baselines/reference/project/mapRootAbsolutePathModuleSimpleSpecifyOutputFile/amd/mapRootAbsolutePathModuleSimpleSpecifyOutputFile.sourcemap.txt +++ b/tests/baselines/reference/project/mapRootAbsolutePathModuleSimpleSpecifyOutputFile/amd/mapRootAbsolutePathModuleSimpleSpecifyOutputFile.sourcemap.txt @@ -1,375 +1,4 @@ =================================================================== -JsFile: m1.js -mapUrl: /tests/cases/projects/outputdir_module_simple/mapFiles/m1.js.map -sourceRoot: -sources: ../m1.ts -=================================================================== -------------------------------------------------------------------- -emittedFile:m1.js -sourceFile:../m1.ts -------------------------------------------------------------------- ->>>define(["require", "exports"], function (require, exports) { ->>> exports.m1_a1 = 10; -1 >^^^^ -2 > ^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^-> -1 >export var -2 > m1_a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(2, 5) Source(1, 12) + SourceIndex(0) -2 >Emitted(2, 18) Source(1, 17) + SourceIndex(0) -3 >Emitted(2, 21) Source(1, 20) + SourceIndex(0) -4 >Emitted(2, 23) Source(1, 22) + SourceIndex(0) -5 >Emitted(2, 24) Source(1, 23) + SourceIndex(0) ---- ->>> var m1_c1 = (function () { -1->^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^^^^-> -1-> - > -1->Emitted(3, 5) Source(2, 1) + SourceIndex(0) ---- ->>> function m1_c1() { -1->^^^^^^^^ -2 > ^^-> -1-> -1->Emitted(4, 9) Source(2, 1) + SourceIndex(0) name (m1_c1) ---- ->>> } -1->^^^^^^^^ -2 > ^ -3 > ^^^^^^^^^^^^^-> -1->export class m1_c1 { - > public m1_c1_p1: number; - > -2 > } -1->Emitted(5, 9) Source(4, 1) + SourceIndex(0) name (m1_c1.constructor) -2 >Emitted(5, 10) Source(4, 2) + SourceIndex(0) name (m1_c1.constructor) ---- ->>> return m1_c1; -1->^^^^^^^^ -2 > ^^^^^^^^^^^^ -1-> -2 > } -1->Emitted(6, 9) Source(4, 1) + SourceIndex(0) name (m1_c1) -2 >Emitted(6, 21) Source(4, 2) + SourceIndex(0) name (m1_c1) ---- ->>> })(); -1 >^^^^ -2 > ^ -3 > -4 > ^^^^ -5 > ^^^^^^^^^^^^^^^^^^-> -1 > -2 > } -3 > -4 > export class m1_c1 { - > public m1_c1_p1: number; - > } -1 >Emitted(7, 5) Source(4, 1) + SourceIndex(0) name (m1_c1) -2 >Emitted(7, 6) Source(4, 2) + SourceIndex(0) name (m1_c1) -3 >Emitted(7, 6) Source(2, 1) + SourceIndex(0) -4 >Emitted(7, 10) Source(4, 2) + SourceIndex(0) ---- ->>> exports.m1_c1 = m1_c1; -1->^^^^ -2 > ^^^^^^^^^^^^^ -3 > ^^^^^^^^ -4 > ^ -5 > ^^^^^^^^^^^^^^-> -1-> -2 > m1_c1 -3 > { - > public m1_c1_p1: number; - > } -4 > -1->Emitted(8, 5) Source(2, 14) + SourceIndex(0) -2 >Emitted(8, 18) Source(2, 19) + SourceIndex(0) -3 >Emitted(8, 26) Source(4, 2) + SourceIndex(0) -4 >Emitted(8, 27) Source(4, 2) + SourceIndex(0) ---- ->>> exports.m1_instance1 = new m1_c1(); -1->^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^^^ -5 > ^^^^^ -6 > ^^ -7 > ^ -1-> - > - >export var -2 > m1_instance1 -3 > = -4 > new -5 > m1_c1 -6 > () -7 > ; -1->Emitted(9, 5) Source(6, 12) + SourceIndex(0) -2 >Emitted(9, 25) Source(6, 24) + SourceIndex(0) -3 >Emitted(9, 28) Source(6, 27) + SourceIndex(0) -4 >Emitted(9, 32) Source(6, 31) + SourceIndex(0) -5 >Emitted(9, 37) Source(6, 36) + SourceIndex(0) -6 >Emitted(9, 39) Source(6, 38) + SourceIndex(0) -7 >Emitted(9, 40) Source(6, 39) + SourceIndex(0) ---- ->>> function m1_f1() { -1 >^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -1 >Emitted(10, 5) Source(7, 1) + SourceIndex(0) ---- ->>> return exports.m1_instance1; -1->^^^^^^^^ -2 > ^^^^^^ -3 > ^ -4 > ^^^^^^^^^^^^^^^^^^^^ -5 > ^ -1->export function m1_f1() { - > -2 > return -3 > -4 > m1_instance1 -5 > ; -1->Emitted(11, 9) Source(8, 5) + SourceIndex(0) name (m1_f1) -2 >Emitted(11, 15) Source(8, 11) + SourceIndex(0) name (m1_f1) -3 >Emitted(11, 16) Source(8, 12) + SourceIndex(0) name (m1_f1) -4 >Emitted(11, 36) Source(8, 24) + SourceIndex(0) name (m1_f1) -5 >Emitted(11, 37) Source(8, 25) + SourceIndex(0) name (m1_f1) ---- ->>> } -1 >^^^^ -2 > ^ -3 > ^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -2 > } -1 >Emitted(12, 5) Source(9, 1) + SourceIndex(0) name (m1_f1) -2 >Emitted(12, 6) Source(9, 2) + SourceIndex(0) name (m1_f1) ---- ->>> exports.m1_f1 = m1_f1; -1->^^^^ -2 > ^^^^^^^^^^^^^ -3 > ^^^^^^^^ -4 > ^ -1-> -2 > m1_f1 -3 > () { - > return m1_instance1; - > } -4 > -1->Emitted(13, 5) Source(7, 17) + SourceIndex(0) -2 >Emitted(13, 18) Source(7, 22) + SourceIndex(0) -3 >Emitted(13, 26) Source(9, 2) + SourceIndex(0) -4 >Emitted(13, 27) Source(9, 2) + SourceIndex(0) ---- ->>>}); ->>>//# sourceMappingURL=/tests/cases/projects/outputdir_module_simple/mapFiles/m1.js.map=================================================================== -JsFile: test.js -mapUrl: /tests/cases/projects/outputdir_module_simple/mapFiles/test.js.map -sourceRoot: -sources: ../test.ts -=================================================================== -------------------------------------------------------------------- -emittedFile:test.js -sourceFile:../test.ts -------------------------------------------------------------------- ->>>define(["require", "exports", "m1"], function (require, exports, m1) { ->>> exports.a1 = 10; -1 >^^^^ -2 > ^^^^^^^^^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^-> -1 >import m1 = require("m1"); - >export var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(2, 5) Source(2, 12) + SourceIndex(0) -2 >Emitted(2, 15) Source(2, 14) + SourceIndex(0) -3 >Emitted(2, 18) Source(2, 17) + SourceIndex(0) -4 >Emitted(2, 20) Source(2, 19) + SourceIndex(0) -5 >Emitted(2, 21) Source(2, 20) + SourceIndex(0) ---- ->>> var c1 = (function () { -1->^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^-> -1-> - > -1->Emitted(3, 5) Source(3, 1) + SourceIndex(0) ---- ->>> function c1() { -1->^^^^^^^^ -2 > ^^-> -1-> -1->Emitted(4, 9) Source(3, 1) + SourceIndex(0) name (c1) ---- ->>> } -1->^^^^^^^^ -2 > ^ -3 > ^^^^^^^^^^-> -1->export class c1 { - > public p1: number; - > -2 > } -1->Emitted(5, 9) Source(5, 1) + SourceIndex(0) name (c1.constructor) -2 >Emitted(5, 10) Source(5, 2) + SourceIndex(0) name (c1.constructor) ---- ->>> return c1; -1->^^^^^^^^ -2 > ^^^^^^^^^ -1-> -2 > } -1->Emitted(6, 9) Source(5, 1) + SourceIndex(0) name (c1) -2 >Emitted(6, 18) Source(5, 2) + SourceIndex(0) name (c1) ---- ->>> })(); -1 >^^^^ -2 > ^ -3 > -4 > ^^^^ -5 > ^^^^^^^^^^^^-> -1 > -2 > } -3 > -4 > export class c1 { - > public p1: number; - > } -1 >Emitted(7, 5) Source(5, 1) + SourceIndex(0) name (c1) -2 >Emitted(7, 6) Source(5, 2) + SourceIndex(0) name (c1) -3 >Emitted(7, 6) Source(3, 1) + SourceIndex(0) -4 >Emitted(7, 10) Source(5, 2) + SourceIndex(0) ---- ->>> exports.c1 = c1; -1->^^^^ -2 > ^^^^^^^^^^ -3 > ^^^^^ -4 > ^ -5 > ^^^^^^^^^^^^^^-> -1-> -2 > c1 -3 > { - > public p1: number; - > } -4 > -1->Emitted(8, 5) Source(3, 14) + SourceIndex(0) -2 >Emitted(8, 15) Source(3, 16) + SourceIndex(0) -3 >Emitted(8, 20) Source(5, 2) + SourceIndex(0) -4 >Emitted(8, 21) Source(5, 2) + SourceIndex(0) ---- ->>> exports.instance1 = new c1(); -1->^^^^ -2 > ^^^^^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^^^ -5 > ^^ -6 > ^^ -7 > ^ -1-> - > - >export var -2 > instance1 -3 > = -4 > new -5 > c1 -6 > () -7 > ; -1->Emitted(9, 5) Source(7, 12) + SourceIndex(0) -2 >Emitted(9, 22) Source(7, 21) + SourceIndex(0) -3 >Emitted(9, 25) Source(7, 24) + SourceIndex(0) -4 >Emitted(9, 29) Source(7, 28) + SourceIndex(0) -5 >Emitted(9, 31) Source(7, 30) + SourceIndex(0) -6 >Emitted(9, 33) Source(7, 32) + SourceIndex(0) -7 >Emitted(9, 34) Source(7, 33) + SourceIndex(0) ---- ->>> function f1() { -1 >^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -1 >Emitted(10, 5) Source(8, 1) + SourceIndex(0) ---- ->>> return exports.instance1; -1->^^^^^^^^ -2 > ^^^^^^ -3 > ^ -4 > ^^^^^^^^^^^^^^^^^ -5 > ^ -1->export function f1() { - > -2 > return -3 > -4 > instance1 -5 > ; -1->Emitted(11, 9) Source(9, 5) + SourceIndex(0) name (f1) -2 >Emitted(11, 15) Source(9, 11) + SourceIndex(0) name (f1) -3 >Emitted(11, 16) Source(9, 12) + SourceIndex(0) name (f1) -4 >Emitted(11, 33) Source(9, 21) + SourceIndex(0) name (f1) -5 >Emitted(11, 34) Source(9, 22) + SourceIndex(0) name (f1) ---- ->>> } -1 >^^^^ -2 > ^ -3 > ^^^^^^^^^^^^^^^^-> -1 > - > -2 > } -1 >Emitted(12, 5) Source(10, 1) + SourceIndex(0) name (f1) -2 >Emitted(12, 6) Source(10, 2) + SourceIndex(0) name (f1) ---- ->>> exports.f1 = f1; -1->^^^^ -2 > ^^^^^^^^^^ -3 > ^^^^^ -4 > ^ -5 > ^^^^^^^-> -1-> -2 > f1 -3 > () { - > return instance1; - > } -4 > -1->Emitted(13, 5) Source(8, 17) + SourceIndex(0) -2 >Emitted(13, 15) Source(8, 19) + SourceIndex(0) -3 >Emitted(13, 20) Source(10, 2) + SourceIndex(0) -4 >Emitted(13, 21) Source(10, 2) + SourceIndex(0) ---- ->>> exports.a2 = m1.m1_c1; -1->^^^^ -2 > ^^^^^^^^^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^ -7 > ^ -1-> - > - >export var -2 > a2 -3 > = -4 > m1 -5 > . -6 > m1_c1 -7 > ; -1->Emitted(14, 5) Source(12, 12) + SourceIndex(0) -2 >Emitted(14, 15) Source(12, 14) + SourceIndex(0) -3 >Emitted(14, 18) Source(12, 17) + SourceIndex(0) -4 >Emitted(14, 20) Source(12, 19) + SourceIndex(0) -5 >Emitted(14, 21) Source(12, 20) + SourceIndex(0) -6 >Emitted(14, 26) Source(12, 25) + SourceIndex(0) -7 >Emitted(14, 27) Source(12, 26) + SourceIndex(0) ---- ->>>}); ->>>//# sourceMappingURL=/tests/cases/projects/outputdir_module_simple/mapFiles/test.js.map=================================================================== JsFile: test.js mapUrl: /tests/cases/projects/outputdir_module_simple/mapFiles/test.js.map sourceRoot: diff --git a/tests/baselines/reference/project/mapRootAbsolutePathModuleSimpleSpecifyOutputFile/amd/test.d.ts b/tests/baselines/reference/project/mapRootAbsolutePathModuleSimpleSpecifyOutputFile/amd/test.d.ts deleted file mode 100644 index 250d2615a79..00000000000 --- a/tests/baselines/reference/project/mapRootAbsolutePathModuleSimpleSpecifyOutputFile/amd/test.d.ts +++ /dev/null @@ -1,8 +0,0 @@ -import m1 = require("m1"); -export declare var a1: number; -export declare class c1 { - p1: number; -} -export declare var instance1: c1; -export declare function f1(): c1; -export declare var a2: typeof m1.m1_c1; diff --git a/tests/baselines/reference/project/mapRootAbsolutePathModuleSimpleSpecifyOutputFile/amd/test.js b/tests/baselines/reference/project/mapRootAbsolutePathModuleSimpleSpecifyOutputFile/amd/test.js deleted file mode 100644 index 6e24571a3f2..00000000000 --- a/tests/baselines/reference/project/mapRootAbsolutePathModuleSimpleSpecifyOutputFile/amd/test.js +++ /dev/null @@ -1,16 +0,0 @@ -define(["require", "exports", "m1"], function (require, exports, m1) { - exports.a1 = 10; - var c1 = (function () { - function c1() { - } - return c1; - })(); - exports.c1 = c1; - exports.instance1 = new c1(); - function f1() { - return exports.instance1; - } - exports.f1 = f1; - exports.a2 = m1.m1_c1; -}); -//# sourceMappingURL=/tests/cases/projects/outputdir_module_simple/mapFiles/test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootAbsolutePathModuleSimpleSpecifyOutputFile/amd/test.js.map b/tests/baselines/reference/project/mapRootAbsolutePathModuleSimpleSpecifyOutputFile/amd/test.js.map deleted file mode 100644 index 80d6bbf450b..00000000000 --- a/tests/baselines/reference/project/mapRootAbsolutePathModuleSimpleSpecifyOutputFile/amd/test.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"test.js","sourceRoot":"","sources":["../test.ts"],"names":["c1","c1.constructor","f1"],"mappings":";IACW,UAAE,GAAG,EAAE,CAAC;IACnB;QAAAA;QAEAC,CAACA;QAADD,SAACA;IAADA,CAACA,AAFD,IAEC;IAFY,UAAE,KAEd,CAAA;IAEU,iBAAS,GAAG,IAAI,EAAE,EAAE,CAAC;IAChC;QACIE,MAAMA,CAACA,iBAASA,CAACA;IACrBA,CAACA;IAFe,UAAE,KAEjB,CAAA;IAEU,UAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootAbsolutePathModuleSimpleSpecifyOutputFile/node/m1.d.ts b/tests/baselines/reference/project/mapRootAbsolutePathModuleSimpleSpecifyOutputFile/node/m1.d.ts deleted file mode 100644 index 4a53b24b156..00000000000 --- a/tests/baselines/reference/project/mapRootAbsolutePathModuleSimpleSpecifyOutputFile/node/m1.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -export declare var m1_a1: number; -export declare class m1_c1 { - m1_c1_p1: number; -} -export declare var m1_instance1: m1_c1; -export declare function m1_f1(): m1_c1; diff --git a/tests/baselines/reference/project/mapRootAbsolutePathModuleSimpleSpecifyOutputFile/node/m1.js b/tests/baselines/reference/project/mapRootAbsolutePathModuleSimpleSpecifyOutputFile/node/m1.js deleted file mode 100644 index c8a4f5c91a4..00000000000 --- a/tests/baselines/reference/project/mapRootAbsolutePathModuleSimpleSpecifyOutputFile/node/m1.js +++ /dev/null @@ -1,13 +0,0 @@ -exports.m1_a1 = 10; -var m1_c1 = (function () { - function m1_c1() { - } - return m1_c1; -})(); -exports.m1_c1 = m1_c1; -exports.m1_instance1 = new m1_c1(); -function m1_f1() { - return exports.m1_instance1; -} -exports.m1_f1 = m1_f1; -//# sourceMappingURL=/tests/cases/projects/outputdir_module_simple/mapFiles/m1.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootAbsolutePathModuleSimpleSpecifyOutputFile/node/m1.js.map b/tests/baselines/reference/project/mapRootAbsolutePathModuleSimpleSpecifyOutputFile/node/m1.js.map deleted file mode 100644 index ce271e4a3cd..00000000000 --- a/tests/baselines/reference/project/mapRootAbsolutePathModuleSimpleSpecifyOutputFile/node/m1.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"m1.js","sourceRoot":"","sources":["../m1.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1"],"mappings":"AAAW,aAAK,GAAG,EAAE,CAAC;AACtB;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAFY,aAAK,QAEjB,CAAA;AAEU,oBAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACIE,MAAMA,CAACA,oBAAYA,CAACA;AACxBA,CAACA;AAFe,aAAK,QAEpB,CAAA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootAbsolutePathModuleSimpleSpecifyOutputFile/node/mapRootAbsolutePathModuleSimpleSpecifyOutputFile.json b/tests/baselines/reference/project/mapRootAbsolutePathModuleSimpleSpecifyOutputFile/node/mapRootAbsolutePathModuleSimpleSpecifyOutputFile.json index f703a63b71f..742acdc7a25 100644 --- a/tests/baselines/reference/project/mapRootAbsolutePathModuleSimpleSpecifyOutputFile/node/mapRootAbsolutePathModuleSimpleSpecifyOutputFile.json +++ b/tests/baselines/reference/project/mapRootAbsolutePathModuleSimpleSpecifyOutputFile/node/mapRootAbsolutePathModuleSimpleSpecifyOutputFile.json @@ -16,12 +16,6 @@ "test.ts" ], "emittedFiles": [ - "m1.js.map", - "m1.js", - "m1.d.ts", - "test.js.map", - "test.js", - "test.d.ts", "bin/test.js.map", "bin/test.js", "bin/test.d.ts" diff --git a/tests/baselines/reference/project/mapRootAbsolutePathModuleSimpleSpecifyOutputFile/node/mapRootAbsolutePathModuleSimpleSpecifyOutputFile.sourcemap.txt b/tests/baselines/reference/project/mapRootAbsolutePathModuleSimpleSpecifyOutputFile/node/mapRootAbsolutePathModuleSimpleSpecifyOutputFile.sourcemap.txt index aa64e62c809..1eef0eba6f2 100644 --- a/tests/baselines/reference/project/mapRootAbsolutePathModuleSimpleSpecifyOutputFile/node/mapRootAbsolutePathModuleSimpleSpecifyOutputFile.sourcemap.txt +++ b/tests/baselines/reference/project/mapRootAbsolutePathModuleSimpleSpecifyOutputFile/node/mapRootAbsolutePathModuleSimpleSpecifyOutputFile.sourcemap.txt @@ -1,396 +1,4 @@ =================================================================== -JsFile: m1.js -mapUrl: /tests/cases/projects/outputdir_module_simple/mapFiles/m1.js.map -sourceRoot: -sources: ../m1.ts -=================================================================== -------------------------------------------------------------------- -emittedFile:m1.js -sourceFile:../m1.ts -------------------------------------------------------------------- ->>>exports.m1_a1 = 10; -1 > -2 >^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^-> -1 >export var -2 >m1_a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(1, 1) Source(1, 12) + SourceIndex(0) -2 >Emitted(1, 14) Source(1, 17) + SourceIndex(0) -3 >Emitted(1, 17) Source(1, 20) + SourceIndex(0) -4 >Emitted(1, 19) Source(1, 22) + SourceIndex(0) -5 >Emitted(1, 20) Source(1, 23) + SourceIndex(0) ---- ->>>var m1_c1 = (function () { -1-> -2 >^^^^^^^^^^^^^^^^^^^^^^^-> -1-> - > -1->Emitted(2, 1) Source(2, 1) + SourceIndex(0) ---- ->>> function m1_c1() { -1->^^^^ -2 > ^^-> -1-> -1->Emitted(3, 5) Source(2, 1) + SourceIndex(0) name (m1_c1) ---- ->>> } -1->^^^^ -2 > ^ -3 > ^^^^^^^^^^^^^-> -1->export class m1_c1 { - > public m1_c1_p1: number; - > -2 > } -1->Emitted(4, 5) Source(4, 1) + SourceIndex(0) name (m1_c1.constructor) -2 >Emitted(4, 6) Source(4, 2) + SourceIndex(0) name (m1_c1.constructor) ---- ->>> return m1_c1; -1->^^^^ -2 > ^^^^^^^^^^^^ -1-> -2 > } -1->Emitted(5, 5) Source(4, 1) + SourceIndex(0) name (m1_c1) -2 >Emitted(5, 17) Source(4, 2) + SourceIndex(0) name (m1_c1) ---- ->>>})(); -1 > -2 >^ -3 > -4 > ^^^^ -5 > ^^^^^^^^^^^^^^^^^^-> -1 > -2 >} -3 > -4 > export class m1_c1 { - > public m1_c1_p1: number; - > } -1 >Emitted(6, 1) Source(4, 1) + SourceIndex(0) name (m1_c1) -2 >Emitted(6, 2) Source(4, 2) + SourceIndex(0) name (m1_c1) -3 >Emitted(6, 2) Source(2, 1) + SourceIndex(0) -4 >Emitted(6, 6) Source(4, 2) + SourceIndex(0) ---- ->>>exports.m1_c1 = m1_c1; -1-> -2 >^^^^^^^^^^^^^ -3 > ^^^^^^^^ -4 > ^ -5 > ^^^^^^^^^^^^^^-> -1-> -2 >m1_c1 -3 > { - > public m1_c1_p1: number; - > } -4 > -1->Emitted(7, 1) Source(2, 14) + SourceIndex(0) -2 >Emitted(7, 14) Source(2, 19) + SourceIndex(0) -3 >Emitted(7, 22) Source(4, 2) + SourceIndex(0) -4 >Emitted(7, 23) Source(4, 2) + SourceIndex(0) ---- ->>>exports.m1_instance1 = new m1_c1(); -1-> -2 >^^^^^^^^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^^^ -5 > ^^^^^ -6 > ^^ -7 > ^ -1-> - > - >export var -2 >m1_instance1 -3 > = -4 > new -5 > m1_c1 -6 > () -7 > ; -1->Emitted(8, 1) Source(6, 12) + SourceIndex(0) -2 >Emitted(8, 21) Source(6, 24) + SourceIndex(0) -3 >Emitted(8, 24) Source(6, 27) + SourceIndex(0) -4 >Emitted(8, 28) Source(6, 31) + SourceIndex(0) -5 >Emitted(8, 33) Source(6, 36) + SourceIndex(0) -6 >Emitted(8, 35) Source(6, 38) + SourceIndex(0) -7 >Emitted(8, 36) Source(6, 39) + SourceIndex(0) ---- ->>>function m1_f1() { -1 > -2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -1 >Emitted(9, 1) Source(7, 1) + SourceIndex(0) ---- ->>> return exports.m1_instance1; -1->^^^^ -2 > ^^^^^^ -3 > ^ -4 > ^^^^^^^^^^^^^^^^^^^^ -5 > ^ -1->export function m1_f1() { - > -2 > return -3 > -4 > m1_instance1 -5 > ; -1->Emitted(10, 5) Source(8, 5) + SourceIndex(0) name (m1_f1) -2 >Emitted(10, 11) Source(8, 11) + SourceIndex(0) name (m1_f1) -3 >Emitted(10, 12) Source(8, 12) + SourceIndex(0) name (m1_f1) -4 >Emitted(10, 32) Source(8, 24) + SourceIndex(0) name (m1_f1) -5 >Emitted(10, 33) Source(8, 25) + SourceIndex(0) name (m1_f1) ---- ->>>} -1 > -2 >^ -3 > ^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -2 >} -1 >Emitted(11, 1) Source(9, 1) + SourceIndex(0) name (m1_f1) -2 >Emitted(11, 2) Source(9, 2) + SourceIndex(0) name (m1_f1) ---- ->>>exports.m1_f1 = m1_f1; -1-> -2 >^^^^^^^^^^^^^ -3 > ^^^^^^^^ -4 > ^ -5 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1-> -2 >m1_f1 -3 > () { - > return m1_instance1; - > } -4 > -1->Emitted(12, 1) Source(7, 17) + SourceIndex(0) -2 >Emitted(12, 14) Source(7, 22) + SourceIndex(0) -3 >Emitted(12, 22) Source(9, 2) + SourceIndex(0) -4 >Emitted(12, 23) Source(9, 2) + SourceIndex(0) ---- ->>>//# sourceMappingURL=/tests/cases/projects/outputdir_module_simple/mapFiles/m1.js.map=================================================================== -JsFile: test.js -mapUrl: /tests/cases/projects/outputdir_module_simple/mapFiles/test.js.map -sourceRoot: -sources: ../test.ts -=================================================================== -------------------------------------------------------------------- -emittedFile:test.js -sourceFile:../test.ts -------------------------------------------------------------------- ->>>var m1 = require("m1"); -1 > -2 >^^^^ -3 > ^^ -4 > ^^^^^^^^^^^ -5 > ^^^^ -6 > ^ -7 > ^ -1 > -2 >import -3 > m1 -4 > = require( -5 > "m1" -6 > ) -7 > ; -1 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) -2 >Emitted(1, 5) Source(1, 8) + SourceIndex(0) -3 >Emitted(1, 7) Source(1, 10) + SourceIndex(0) -4 >Emitted(1, 18) Source(1, 21) + SourceIndex(0) -5 >Emitted(1, 22) Source(1, 25) + SourceIndex(0) -6 >Emitted(1, 23) Source(1, 26) + SourceIndex(0) -7 >Emitted(1, 24) Source(1, 27) + SourceIndex(0) ---- ->>>exports.a1 = 10; -1 > -2 >^^^^^^^^^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^-> -1 > - >export var -2 >a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(2, 1) Source(2, 12) + SourceIndex(0) -2 >Emitted(2, 11) Source(2, 14) + SourceIndex(0) -3 >Emitted(2, 14) Source(2, 17) + SourceIndex(0) -4 >Emitted(2, 16) Source(2, 19) + SourceIndex(0) -5 >Emitted(2, 17) Source(2, 20) + SourceIndex(0) ---- ->>>var c1 = (function () { -1-> -2 >^^^^^^^^^^^^^^^^^^^^-> -1-> - > -1->Emitted(3, 1) Source(3, 1) + SourceIndex(0) ---- ->>> function c1() { -1->^^^^ -2 > ^^-> -1-> -1->Emitted(4, 5) Source(3, 1) + SourceIndex(0) name (c1) ---- ->>> } -1->^^^^ -2 > ^ -3 > ^^^^^^^^^^-> -1->export class c1 { - > public p1: number; - > -2 > } -1->Emitted(5, 5) Source(5, 1) + SourceIndex(0) name (c1.constructor) -2 >Emitted(5, 6) Source(5, 2) + SourceIndex(0) name (c1.constructor) ---- ->>> return c1; -1->^^^^ -2 > ^^^^^^^^^ -1-> -2 > } -1->Emitted(6, 5) Source(5, 1) + SourceIndex(0) name (c1) -2 >Emitted(6, 14) Source(5, 2) + SourceIndex(0) name (c1) ---- ->>>})(); -1 > -2 >^ -3 > -4 > ^^^^ -5 > ^^^^^^^^^^^^-> -1 > -2 >} -3 > -4 > export class c1 { - > public p1: number; - > } -1 >Emitted(7, 1) Source(5, 1) + SourceIndex(0) name (c1) -2 >Emitted(7, 2) Source(5, 2) + SourceIndex(0) name (c1) -3 >Emitted(7, 2) Source(3, 1) + SourceIndex(0) -4 >Emitted(7, 6) Source(5, 2) + SourceIndex(0) ---- ->>>exports.c1 = c1; -1-> -2 >^^^^^^^^^^ -3 > ^^^^^ -4 > ^ -5 > ^^^^^^^^^^^^^^-> -1-> -2 >c1 -3 > { - > public p1: number; - > } -4 > -1->Emitted(8, 1) Source(3, 14) + SourceIndex(0) -2 >Emitted(8, 11) Source(3, 16) + SourceIndex(0) -3 >Emitted(8, 16) Source(5, 2) + SourceIndex(0) -4 >Emitted(8, 17) Source(5, 2) + SourceIndex(0) ---- ->>>exports.instance1 = new c1(); -1-> -2 >^^^^^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^^^ -5 > ^^ -6 > ^^ -7 > ^ -1-> - > - >export var -2 >instance1 -3 > = -4 > new -5 > c1 -6 > () -7 > ; -1->Emitted(9, 1) Source(7, 12) + SourceIndex(0) -2 >Emitted(9, 18) Source(7, 21) + SourceIndex(0) -3 >Emitted(9, 21) Source(7, 24) + SourceIndex(0) -4 >Emitted(9, 25) Source(7, 28) + SourceIndex(0) -5 >Emitted(9, 27) Source(7, 30) + SourceIndex(0) -6 >Emitted(9, 29) Source(7, 32) + SourceIndex(0) -7 >Emitted(9, 30) Source(7, 33) + SourceIndex(0) ---- ->>>function f1() { -1 > -2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -1 >Emitted(10, 1) Source(8, 1) + SourceIndex(0) ---- ->>> return exports.instance1; -1->^^^^ -2 > ^^^^^^ -3 > ^ -4 > ^^^^^^^^^^^^^^^^^ -5 > ^ -1->export function f1() { - > -2 > return -3 > -4 > instance1 -5 > ; -1->Emitted(11, 5) Source(9, 5) + SourceIndex(0) name (f1) -2 >Emitted(11, 11) Source(9, 11) + SourceIndex(0) name (f1) -3 >Emitted(11, 12) Source(9, 12) + SourceIndex(0) name (f1) -4 >Emitted(11, 29) Source(9, 21) + SourceIndex(0) name (f1) -5 >Emitted(11, 30) Source(9, 22) + SourceIndex(0) name (f1) ---- ->>>} -1 > -2 >^ -3 > ^^^^^^^^^^^^^^^^-> -1 > - > -2 >} -1 >Emitted(12, 1) Source(10, 1) + SourceIndex(0) name (f1) -2 >Emitted(12, 2) Source(10, 2) + SourceIndex(0) name (f1) ---- ->>>exports.f1 = f1; -1-> -2 >^^^^^^^^^^ -3 > ^^^^^ -4 > ^ -5 > ^^^^^^^-> -1-> -2 >f1 -3 > () { - > return instance1; - > } -4 > -1->Emitted(13, 1) Source(8, 17) + SourceIndex(0) -2 >Emitted(13, 11) Source(8, 19) + SourceIndex(0) -3 >Emitted(13, 16) Source(10, 2) + SourceIndex(0) -4 >Emitted(13, 17) Source(10, 2) + SourceIndex(0) ---- ->>>exports.a2 = m1.m1_c1; -1-> -2 >^^^^^^^^^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^ -7 > ^ -8 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1-> - > - >export var -2 >a2 -3 > = -4 > m1 -5 > . -6 > m1_c1 -7 > ; -1->Emitted(14, 1) Source(12, 12) + SourceIndex(0) -2 >Emitted(14, 11) Source(12, 14) + SourceIndex(0) -3 >Emitted(14, 14) Source(12, 17) + SourceIndex(0) -4 >Emitted(14, 16) Source(12, 19) + SourceIndex(0) -5 >Emitted(14, 17) Source(12, 20) + SourceIndex(0) -6 >Emitted(14, 22) Source(12, 25) + SourceIndex(0) -7 >Emitted(14, 23) Source(12, 26) + SourceIndex(0) ---- ->>>//# sourceMappingURL=/tests/cases/projects/outputdir_module_simple/mapFiles/test.js.map=================================================================== JsFile: test.js mapUrl: /tests/cases/projects/outputdir_module_simple/mapFiles/test.js.map sourceRoot: diff --git a/tests/baselines/reference/project/mapRootAbsolutePathModuleSimpleSpecifyOutputFile/node/test.d.ts b/tests/baselines/reference/project/mapRootAbsolutePathModuleSimpleSpecifyOutputFile/node/test.d.ts deleted file mode 100644 index 250d2615a79..00000000000 --- a/tests/baselines/reference/project/mapRootAbsolutePathModuleSimpleSpecifyOutputFile/node/test.d.ts +++ /dev/null @@ -1,8 +0,0 @@ -import m1 = require("m1"); -export declare var a1: number; -export declare class c1 { - p1: number; -} -export declare var instance1: c1; -export declare function f1(): c1; -export declare var a2: typeof m1.m1_c1; diff --git a/tests/baselines/reference/project/mapRootAbsolutePathModuleSimpleSpecifyOutputFile/node/test.js b/tests/baselines/reference/project/mapRootAbsolutePathModuleSimpleSpecifyOutputFile/node/test.js deleted file mode 100644 index 080dcf6e818..00000000000 --- a/tests/baselines/reference/project/mapRootAbsolutePathModuleSimpleSpecifyOutputFile/node/test.js +++ /dev/null @@ -1,15 +0,0 @@ -var m1 = require("m1"); -exports.a1 = 10; -var c1 = (function () { - function c1() { - } - return c1; -})(); -exports.c1 = c1; -exports.instance1 = new c1(); -function f1() { - return exports.instance1; -} -exports.f1 = f1; -exports.a2 = m1.m1_c1; -//# sourceMappingURL=/tests/cases/projects/outputdir_module_simple/mapFiles/test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootAbsolutePathModuleSimpleSpecifyOutputFile/node/test.js.map b/tests/baselines/reference/project/mapRootAbsolutePathModuleSimpleSpecifyOutputFile/node/test.js.map deleted file mode 100644 index de9ec1f9859..00000000000 --- a/tests/baselines/reference/project/mapRootAbsolutePathModuleSimpleSpecifyOutputFile/node/test.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"test.js","sourceRoot":"","sources":["../test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AAAA,IAAO,EAAE,WAAW,IAAI,CAAC,CAAC;AACf,UAAE,GAAG,EAAE,CAAC;AACnB;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAFY,UAAE,KAEd,CAAA;AAEU,iBAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AAChC;IACIE,MAAMA,CAACA,iBAASA,CAACA;AACrBA,CAACA;AAFe,UAAE,KAEjB,CAAA;AAEU,UAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootAbsolutePathModuleSubfolderSpecifyOutputFile/amd/mapRootAbsolutePathModuleSubfolderSpecifyOutputFile.json b/tests/baselines/reference/project/mapRootAbsolutePathModuleSubfolderSpecifyOutputFile/amd/mapRootAbsolutePathModuleSubfolderSpecifyOutputFile.json index d8f4cc74008..21d6e50f28a 100644 --- a/tests/baselines/reference/project/mapRootAbsolutePathModuleSubfolderSpecifyOutputFile/amd/mapRootAbsolutePathModuleSubfolderSpecifyOutputFile.json +++ b/tests/baselines/reference/project/mapRootAbsolutePathModuleSubfolderSpecifyOutputFile/amd/mapRootAbsolutePathModuleSubfolderSpecifyOutputFile.json @@ -16,12 +16,6 @@ "test.ts" ], "emittedFiles": [ - "ref/m1.js.map", - "ref/m1.js", - "ref/m1.d.ts", - "test.js.map", - "test.js", - "test.d.ts", "bin/test.js.map", "bin/test.js", "bin/test.d.ts" diff --git a/tests/baselines/reference/project/mapRootAbsolutePathModuleSubfolderSpecifyOutputFile/amd/mapRootAbsolutePathModuleSubfolderSpecifyOutputFile.sourcemap.txt b/tests/baselines/reference/project/mapRootAbsolutePathModuleSubfolderSpecifyOutputFile/amd/mapRootAbsolutePathModuleSubfolderSpecifyOutputFile.sourcemap.txt index d6a44398f8e..d63cf86d236 100644 --- a/tests/baselines/reference/project/mapRootAbsolutePathModuleSubfolderSpecifyOutputFile/amd/mapRootAbsolutePathModuleSubfolderSpecifyOutputFile.sourcemap.txt +++ b/tests/baselines/reference/project/mapRootAbsolutePathModuleSubfolderSpecifyOutputFile/amd/mapRootAbsolutePathModuleSubfolderSpecifyOutputFile.sourcemap.txt @@ -1,375 +1,4 @@ =================================================================== -JsFile: m1.js -mapUrl: /tests/cases/projects/outputdir_module_subfolder/mapFiles/ref/m1.js.map -sourceRoot: -sources: ../../ref/m1.ts -=================================================================== -------------------------------------------------------------------- -emittedFile:ref/m1.js -sourceFile:../../ref/m1.ts -------------------------------------------------------------------- ->>>define(["require", "exports"], function (require, exports) { ->>> exports.m1_a1 = 10; -1 >^^^^ -2 > ^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^-> -1 >export var -2 > m1_a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(2, 5) Source(1, 12) + SourceIndex(0) -2 >Emitted(2, 18) Source(1, 17) + SourceIndex(0) -3 >Emitted(2, 21) Source(1, 20) + SourceIndex(0) -4 >Emitted(2, 23) Source(1, 22) + SourceIndex(0) -5 >Emitted(2, 24) Source(1, 23) + SourceIndex(0) ---- ->>> var m1_c1 = (function () { -1->^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^^^^-> -1-> - > -1->Emitted(3, 5) Source(2, 1) + SourceIndex(0) ---- ->>> function m1_c1() { -1->^^^^^^^^ -2 > ^^-> -1-> -1->Emitted(4, 9) Source(2, 1) + SourceIndex(0) name (m1_c1) ---- ->>> } -1->^^^^^^^^ -2 > ^ -3 > ^^^^^^^^^^^^^-> -1->export class m1_c1 { - > public m1_c1_p1: number; - > -2 > } -1->Emitted(5, 9) Source(4, 1) + SourceIndex(0) name (m1_c1.constructor) -2 >Emitted(5, 10) Source(4, 2) + SourceIndex(0) name (m1_c1.constructor) ---- ->>> return m1_c1; -1->^^^^^^^^ -2 > ^^^^^^^^^^^^ -1-> -2 > } -1->Emitted(6, 9) Source(4, 1) + SourceIndex(0) name (m1_c1) -2 >Emitted(6, 21) Source(4, 2) + SourceIndex(0) name (m1_c1) ---- ->>> })(); -1 >^^^^ -2 > ^ -3 > -4 > ^^^^ -5 > ^^^^^^^^^^^^^^^^^^-> -1 > -2 > } -3 > -4 > export class m1_c1 { - > public m1_c1_p1: number; - > } -1 >Emitted(7, 5) Source(4, 1) + SourceIndex(0) name (m1_c1) -2 >Emitted(7, 6) Source(4, 2) + SourceIndex(0) name (m1_c1) -3 >Emitted(7, 6) Source(2, 1) + SourceIndex(0) -4 >Emitted(7, 10) Source(4, 2) + SourceIndex(0) ---- ->>> exports.m1_c1 = m1_c1; -1->^^^^ -2 > ^^^^^^^^^^^^^ -3 > ^^^^^^^^ -4 > ^ -5 > ^^^^^^^^^^^^^^-> -1-> -2 > m1_c1 -3 > { - > public m1_c1_p1: number; - > } -4 > -1->Emitted(8, 5) Source(2, 14) + SourceIndex(0) -2 >Emitted(8, 18) Source(2, 19) + SourceIndex(0) -3 >Emitted(8, 26) Source(4, 2) + SourceIndex(0) -4 >Emitted(8, 27) Source(4, 2) + SourceIndex(0) ---- ->>> exports.m1_instance1 = new m1_c1(); -1->^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^^^ -5 > ^^^^^ -6 > ^^ -7 > ^ -1-> - > - >export var -2 > m1_instance1 -3 > = -4 > new -5 > m1_c1 -6 > () -7 > ; -1->Emitted(9, 5) Source(6, 12) + SourceIndex(0) -2 >Emitted(9, 25) Source(6, 24) + SourceIndex(0) -3 >Emitted(9, 28) Source(6, 27) + SourceIndex(0) -4 >Emitted(9, 32) Source(6, 31) + SourceIndex(0) -5 >Emitted(9, 37) Source(6, 36) + SourceIndex(0) -6 >Emitted(9, 39) Source(6, 38) + SourceIndex(0) -7 >Emitted(9, 40) Source(6, 39) + SourceIndex(0) ---- ->>> function m1_f1() { -1 >^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -1 >Emitted(10, 5) Source(7, 1) + SourceIndex(0) ---- ->>> return exports.m1_instance1; -1->^^^^^^^^ -2 > ^^^^^^ -3 > ^ -4 > ^^^^^^^^^^^^^^^^^^^^ -5 > ^ -1->export function m1_f1() { - > -2 > return -3 > -4 > m1_instance1 -5 > ; -1->Emitted(11, 9) Source(8, 5) + SourceIndex(0) name (m1_f1) -2 >Emitted(11, 15) Source(8, 11) + SourceIndex(0) name (m1_f1) -3 >Emitted(11, 16) Source(8, 12) + SourceIndex(0) name (m1_f1) -4 >Emitted(11, 36) Source(8, 24) + SourceIndex(0) name (m1_f1) -5 >Emitted(11, 37) Source(8, 25) + SourceIndex(0) name (m1_f1) ---- ->>> } -1 >^^^^ -2 > ^ -3 > ^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -2 > } -1 >Emitted(12, 5) Source(9, 1) + SourceIndex(0) name (m1_f1) -2 >Emitted(12, 6) Source(9, 2) + SourceIndex(0) name (m1_f1) ---- ->>> exports.m1_f1 = m1_f1; -1->^^^^ -2 > ^^^^^^^^^^^^^ -3 > ^^^^^^^^ -4 > ^ -1-> -2 > m1_f1 -3 > () { - > return m1_instance1; - > } -4 > -1->Emitted(13, 5) Source(7, 17) + SourceIndex(0) -2 >Emitted(13, 18) Source(7, 22) + SourceIndex(0) -3 >Emitted(13, 26) Source(9, 2) + SourceIndex(0) -4 >Emitted(13, 27) Source(9, 2) + SourceIndex(0) ---- ->>>}); ->>>//# sourceMappingURL=/tests/cases/projects/outputdir_module_subfolder/mapFiles/ref/m1.js.map=================================================================== -JsFile: test.js -mapUrl: /tests/cases/projects/outputdir_module_subfolder/mapFiles/test.js.map -sourceRoot: -sources: ../test.ts -=================================================================== -------------------------------------------------------------------- -emittedFile:test.js -sourceFile:../test.ts -------------------------------------------------------------------- ->>>define(["require", "exports", "ref/m1"], function (require, exports, m1) { ->>> exports.a1 = 10; -1 >^^^^ -2 > ^^^^^^^^^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^-> -1 >import m1 = require("ref/m1"); - >export var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(2, 5) Source(2, 12) + SourceIndex(0) -2 >Emitted(2, 15) Source(2, 14) + SourceIndex(0) -3 >Emitted(2, 18) Source(2, 17) + SourceIndex(0) -4 >Emitted(2, 20) Source(2, 19) + SourceIndex(0) -5 >Emitted(2, 21) Source(2, 20) + SourceIndex(0) ---- ->>> var c1 = (function () { -1->^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^-> -1-> - > -1->Emitted(3, 5) Source(3, 1) + SourceIndex(0) ---- ->>> function c1() { -1->^^^^^^^^ -2 > ^^-> -1-> -1->Emitted(4, 9) Source(3, 1) + SourceIndex(0) name (c1) ---- ->>> } -1->^^^^^^^^ -2 > ^ -3 > ^^^^^^^^^^-> -1->export class c1 { - > public p1: number; - > -2 > } -1->Emitted(5, 9) Source(5, 1) + SourceIndex(0) name (c1.constructor) -2 >Emitted(5, 10) Source(5, 2) + SourceIndex(0) name (c1.constructor) ---- ->>> return c1; -1->^^^^^^^^ -2 > ^^^^^^^^^ -1-> -2 > } -1->Emitted(6, 9) Source(5, 1) + SourceIndex(0) name (c1) -2 >Emitted(6, 18) Source(5, 2) + SourceIndex(0) name (c1) ---- ->>> })(); -1 >^^^^ -2 > ^ -3 > -4 > ^^^^ -5 > ^^^^^^^^^^^^-> -1 > -2 > } -3 > -4 > export class c1 { - > public p1: number; - > } -1 >Emitted(7, 5) Source(5, 1) + SourceIndex(0) name (c1) -2 >Emitted(7, 6) Source(5, 2) + SourceIndex(0) name (c1) -3 >Emitted(7, 6) Source(3, 1) + SourceIndex(0) -4 >Emitted(7, 10) Source(5, 2) + SourceIndex(0) ---- ->>> exports.c1 = c1; -1->^^^^ -2 > ^^^^^^^^^^ -3 > ^^^^^ -4 > ^ -5 > ^^^^^^^^^^^^^^-> -1-> -2 > c1 -3 > { - > public p1: number; - > } -4 > -1->Emitted(8, 5) Source(3, 14) + SourceIndex(0) -2 >Emitted(8, 15) Source(3, 16) + SourceIndex(0) -3 >Emitted(8, 20) Source(5, 2) + SourceIndex(0) -4 >Emitted(8, 21) Source(5, 2) + SourceIndex(0) ---- ->>> exports.instance1 = new c1(); -1->^^^^ -2 > ^^^^^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^^^ -5 > ^^ -6 > ^^ -7 > ^ -1-> - > - >export var -2 > instance1 -3 > = -4 > new -5 > c1 -6 > () -7 > ; -1->Emitted(9, 5) Source(7, 12) + SourceIndex(0) -2 >Emitted(9, 22) Source(7, 21) + SourceIndex(0) -3 >Emitted(9, 25) Source(7, 24) + SourceIndex(0) -4 >Emitted(9, 29) Source(7, 28) + SourceIndex(0) -5 >Emitted(9, 31) Source(7, 30) + SourceIndex(0) -6 >Emitted(9, 33) Source(7, 32) + SourceIndex(0) -7 >Emitted(9, 34) Source(7, 33) + SourceIndex(0) ---- ->>> function f1() { -1 >^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -1 >Emitted(10, 5) Source(8, 1) + SourceIndex(0) ---- ->>> return exports.instance1; -1->^^^^^^^^ -2 > ^^^^^^ -3 > ^ -4 > ^^^^^^^^^^^^^^^^^ -5 > ^ -1->export function f1() { - > -2 > return -3 > -4 > instance1 -5 > ; -1->Emitted(11, 9) Source(9, 5) + SourceIndex(0) name (f1) -2 >Emitted(11, 15) Source(9, 11) + SourceIndex(0) name (f1) -3 >Emitted(11, 16) Source(9, 12) + SourceIndex(0) name (f1) -4 >Emitted(11, 33) Source(9, 21) + SourceIndex(0) name (f1) -5 >Emitted(11, 34) Source(9, 22) + SourceIndex(0) name (f1) ---- ->>> } -1 >^^^^ -2 > ^ -3 > ^^^^^^^^^^^^^^^^-> -1 > - > -2 > } -1 >Emitted(12, 5) Source(10, 1) + SourceIndex(0) name (f1) -2 >Emitted(12, 6) Source(10, 2) + SourceIndex(0) name (f1) ---- ->>> exports.f1 = f1; -1->^^^^ -2 > ^^^^^^^^^^ -3 > ^^^^^ -4 > ^ -5 > ^^^^^^^-> -1-> -2 > f1 -3 > () { - > return instance1; - > } -4 > -1->Emitted(13, 5) Source(8, 17) + SourceIndex(0) -2 >Emitted(13, 15) Source(8, 19) + SourceIndex(0) -3 >Emitted(13, 20) Source(10, 2) + SourceIndex(0) -4 >Emitted(13, 21) Source(10, 2) + SourceIndex(0) ---- ->>> exports.a2 = m1.m1_c1; -1->^^^^ -2 > ^^^^^^^^^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^ -7 > ^ -1-> - > - >export var -2 > a2 -3 > = -4 > m1 -5 > . -6 > m1_c1 -7 > ; -1->Emitted(14, 5) Source(12, 12) + SourceIndex(0) -2 >Emitted(14, 15) Source(12, 14) + SourceIndex(0) -3 >Emitted(14, 18) Source(12, 17) + SourceIndex(0) -4 >Emitted(14, 20) Source(12, 19) + SourceIndex(0) -5 >Emitted(14, 21) Source(12, 20) + SourceIndex(0) -6 >Emitted(14, 26) Source(12, 25) + SourceIndex(0) -7 >Emitted(14, 27) Source(12, 26) + SourceIndex(0) ---- ->>>}); ->>>//# sourceMappingURL=/tests/cases/projects/outputdir_module_subfolder/mapFiles/test.js.map=================================================================== JsFile: test.js mapUrl: /tests/cases/projects/outputdir_module_subfolder/mapFiles/test.js.map sourceRoot: diff --git a/tests/baselines/reference/project/mapRootAbsolutePathModuleSubfolderSpecifyOutputFile/amd/ref/m1.d.ts b/tests/baselines/reference/project/mapRootAbsolutePathModuleSubfolderSpecifyOutputFile/amd/ref/m1.d.ts deleted file mode 100644 index 4a53b24b156..00000000000 --- a/tests/baselines/reference/project/mapRootAbsolutePathModuleSubfolderSpecifyOutputFile/amd/ref/m1.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -export declare var m1_a1: number; -export declare class m1_c1 { - m1_c1_p1: number; -} -export declare var m1_instance1: m1_c1; -export declare function m1_f1(): m1_c1; diff --git a/tests/baselines/reference/project/mapRootAbsolutePathModuleSubfolderSpecifyOutputFile/amd/ref/m1.js b/tests/baselines/reference/project/mapRootAbsolutePathModuleSubfolderSpecifyOutputFile/amd/ref/m1.js deleted file mode 100644 index e819d557c40..00000000000 --- a/tests/baselines/reference/project/mapRootAbsolutePathModuleSubfolderSpecifyOutputFile/amd/ref/m1.js +++ /dev/null @@ -1,15 +0,0 @@ -define(["require", "exports"], function (require, exports) { - exports.m1_a1 = 10; - var m1_c1 = (function () { - function m1_c1() { - } - return m1_c1; - })(); - exports.m1_c1 = m1_c1; - exports.m1_instance1 = new m1_c1(); - function m1_f1() { - return exports.m1_instance1; - } - exports.m1_f1 = m1_f1; -}); -//# sourceMappingURL=/tests/cases/projects/outputdir_module_subfolder/mapFiles/ref/m1.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootAbsolutePathModuleSubfolderSpecifyOutputFile/amd/ref/m1.js.map b/tests/baselines/reference/project/mapRootAbsolutePathModuleSubfolderSpecifyOutputFile/amd/ref/m1.js.map deleted file mode 100644 index 88e67e19b36..00000000000 --- a/tests/baselines/reference/project/mapRootAbsolutePathModuleSubfolderSpecifyOutputFile/amd/ref/m1.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"m1.js","sourceRoot":"","sources":["../../ref/m1.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1"],"mappings":";IAAW,aAAK,GAAG,EAAE,CAAC;IACtB;QAAAA;QAEAC,CAACA;QAADD,YAACA;IAADA,CAACA,AAFD,IAEC;IAFY,aAAK,QAEjB,CAAA;IAEU,oBAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACIE,MAAMA,CAACA,oBAAYA,CAACA;IACxBA,CAACA;IAFe,aAAK,QAEpB,CAAA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootAbsolutePathModuleSubfolderSpecifyOutputFile/amd/test.d.ts b/tests/baselines/reference/project/mapRootAbsolutePathModuleSubfolderSpecifyOutputFile/amd/test.d.ts deleted file mode 100644 index a61d8541048..00000000000 --- a/tests/baselines/reference/project/mapRootAbsolutePathModuleSubfolderSpecifyOutputFile/amd/test.d.ts +++ /dev/null @@ -1,8 +0,0 @@ -import m1 = require("ref/m1"); -export declare var a1: number; -export declare class c1 { - p1: number; -} -export declare var instance1: c1; -export declare function f1(): c1; -export declare var a2: typeof m1.m1_c1; diff --git a/tests/baselines/reference/project/mapRootAbsolutePathModuleSubfolderSpecifyOutputFile/amd/test.js b/tests/baselines/reference/project/mapRootAbsolutePathModuleSubfolderSpecifyOutputFile/amd/test.js deleted file mode 100644 index 3b2cd1a24c4..00000000000 --- a/tests/baselines/reference/project/mapRootAbsolutePathModuleSubfolderSpecifyOutputFile/amd/test.js +++ /dev/null @@ -1,16 +0,0 @@ -define(["require", "exports", "ref/m1"], function (require, exports, m1) { - exports.a1 = 10; - var c1 = (function () { - function c1() { - } - return c1; - })(); - exports.c1 = c1; - exports.instance1 = new c1(); - function f1() { - return exports.instance1; - } - exports.f1 = f1; - exports.a2 = m1.m1_c1; -}); -//# sourceMappingURL=/tests/cases/projects/outputdir_module_subfolder/mapFiles/test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootAbsolutePathModuleSubfolderSpecifyOutputFile/amd/test.js.map b/tests/baselines/reference/project/mapRootAbsolutePathModuleSubfolderSpecifyOutputFile/amd/test.js.map deleted file mode 100644 index 80d6bbf450b..00000000000 --- a/tests/baselines/reference/project/mapRootAbsolutePathModuleSubfolderSpecifyOutputFile/amd/test.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"test.js","sourceRoot":"","sources":["../test.ts"],"names":["c1","c1.constructor","f1"],"mappings":";IACW,UAAE,GAAG,EAAE,CAAC;IACnB;QAAAA;QAEAC,CAACA;QAADD,SAACA;IAADA,CAACA,AAFD,IAEC;IAFY,UAAE,KAEd,CAAA;IAEU,iBAAS,GAAG,IAAI,EAAE,EAAE,CAAC;IAChC;QACIE,MAAMA,CAACA,iBAASA,CAACA;IACrBA,CAACA;IAFe,UAAE,KAEjB,CAAA;IAEU,UAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootAbsolutePathModuleSubfolderSpecifyOutputFile/node/mapRootAbsolutePathModuleSubfolderSpecifyOutputFile.json b/tests/baselines/reference/project/mapRootAbsolutePathModuleSubfolderSpecifyOutputFile/node/mapRootAbsolutePathModuleSubfolderSpecifyOutputFile.json index d8f4cc74008..21d6e50f28a 100644 --- a/tests/baselines/reference/project/mapRootAbsolutePathModuleSubfolderSpecifyOutputFile/node/mapRootAbsolutePathModuleSubfolderSpecifyOutputFile.json +++ b/tests/baselines/reference/project/mapRootAbsolutePathModuleSubfolderSpecifyOutputFile/node/mapRootAbsolutePathModuleSubfolderSpecifyOutputFile.json @@ -16,12 +16,6 @@ "test.ts" ], "emittedFiles": [ - "ref/m1.js.map", - "ref/m1.js", - "ref/m1.d.ts", - "test.js.map", - "test.js", - "test.d.ts", "bin/test.js.map", "bin/test.js", "bin/test.d.ts" diff --git a/tests/baselines/reference/project/mapRootAbsolutePathModuleSubfolderSpecifyOutputFile/node/mapRootAbsolutePathModuleSubfolderSpecifyOutputFile.sourcemap.txt b/tests/baselines/reference/project/mapRootAbsolutePathModuleSubfolderSpecifyOutputFile/node/mapRootAbsolutePathModuleSubfolderSpecifyOutputFile.sourcemap.txt index 55f448a9c2f..20f2ab47188 100644 --- a/tests/baselines/reference/project/mapRootAbsolutePathModuleSubfolderSpecifyOutputFile/node/mapRootAbsolutePathModuleSubfolderSpecifyOutputFile.sourcemap.txt +++ b/tests/baselines/reference/project/mapRootAbsolutePathModuleSubfolderSpecifyOutputFile/node/mapRootAbsolutePathModuleSubfolderSpecifyOutputFile.sourcemap.txt @@ -1,396 +1,4 @@ =================================================================== -JsFile: m1.js -mapUrl: /tests/cases/projects/outputdir_module_subfolder/mapFiles/ref/m1.js.map -sourceRoot: -sources: ../../ref/m1.ts -=================================================================== -------------------------------------------------------------------- -emittedFile:ref/m1.js -sourceFile:../../ref/m1.ts -------------------------------------------------------------------- ->>>exports.m1_a1 = 10; -1 > -2 >^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^-> -1 >export var -2 >m1_a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(1, 1) Source(1, 12) + SourceIndex(0) -2 >Emitted(1, 14) Source(1, 17) + SourceIndex(0) -3 >Emitted(1, 17) Source(1, 20) + SourceIndex(0) -4 >Emitted(1, 19) Source(1, 22) + SourceIndex(0) -5 >Emitted(1, 20) Source(1, 23) + SourceIndex(0) ---- ->>>var m1_c1 = (function () { -1-> -2 >^^^^^^^^^^^^^^^^^^^^^^^-> -1-> - > -1->Emitted(2, 1) Source(2, 1) + SourceIndex(0) ---- ->>> function m1_c1() { -1->^^^^ -2 > ^^-> -1-> -1->Emitted(3, 5) Source(2, 1) + SourceIndex(0) name (m1_c1) ---- ->>> } -1->^^^^ -2 > ^ -3 > ^^^^^^^^^^^^^-> -1->export class m1_c1 { - > public m1_c1_p1: number; - > -2 > } -1->Emitted(4, 5) Source(4, 1) + SourceIndex(0) name (m1_c1.constructor) -2 >Emitted(4, 6) Source(4, 2) + SourceIndex(0) name (m1_c1.constructor) ---- ->>> return m1_c1; -1->^^^^ -2 > ^^^^^^^^^^^^ -1-> -2 > } -1->Emitted(5, 5) Source(4, 1) + SourceIndex(0) name (m1_c1) -2 >Emitted(5, 17) Source(4, 2) + SourceIndex(0) name (m1_c1) ---- ->>>})(); -1 > -2 >^ -3 > -4 > ^^^^ -5 > ^^^^^^^^^^^^^^^^^^-> -1 > -2 >} -3 > -4 > export class m1_c1 { - > public m1_c1_p1: number; - > } -1 >Emitted(6, 1) Source(4, 1) + SourceIndex(0) name (m1_c1) -2 >Emitted(6, 2) Source(4, 2) + SourceIndex(0) name (m1_c1) -3 >Emitted(6, 2) Source(2, 1) + SourceIndex(0) -4 >Emitted(6, 6) Source(4, 2) + SourceIndex(0) ---- ->>>exports.m1_c1 = m1_c1; -1-> -2 >^^^^^^^^^^^^^ -3 > ^^^^^^^^ -4 > ^ -5 > ^^^^^^^^^^^^^^-> -1-> -2 >m1_c1 -3 > { - > public m1_c1_p1: number; - > } -4 > -1->Emitted(7, 1) Source(2, 14) + SourceIndex(0) -2 >Emitted(7, 14) Source(2, 19) + SourceIndex(0) -3 >Emitted(7, 22) Source(4, 2) + SourceIndex(0) -4 >Emitted(7, 23) Source(4, 2) + SourceIndex(0) ---- ->>>exports.m1_instance1 = new m1_c1(); -1-> -2 >^^^^^^^^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^^^ -5 > ^^^^^ -6 > ^^ -7 > ^ -1-> - > - >export var -2 >m1_instance1 -3 > = -4 > new -5 > m1_c1 -6 > () -7 > ; -1->Emitted(8, 1) Source(6, 12) + SourceIndex(0) -2 >Emitted(8, 21) Source(6, 24) + SourceIndex(0) -3 >Emitted(8, 24) Source(6, 27) + SourceIndex(0) -4 >Emitted(8, 28) Source(6, 31) + SourceIndex(0) -5 >Emitted(8, 33) Source(6, 36) + SourceIndex(0) -6 >Emitted(8, 35) Source(6, 38) + SourceIndex(0) -7 >Emitted(8, 36) Source(6, 39) + SourceIndex(0) ---- ->>>function m1_f1() { -1 > -2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -1 >Emitted(9, 1) Source(7, 1) + SourceIndex(0) ---- ->>> return exports.m1_instance1; -1->^^^^ -2 > ^^^^^^ -3 > ^ -4 > ^^^^^^^^^^^^^^^^^^^^ -5 > ^ -1->export function m1_f1() { - > -2 > return -3 > -4 > m1_instance1 -5 > ; -1->Emitted(10, 5) Source(8, 5) + SourceIndex(0) name (m1_f1) -2 >Emitted(10, 11) Source(8, 11) + SourceIndex(0) name (m1_f1) -3 >Emitted(10, 12) Source(8, 12) + SourceIndex(0) name (m1_f1) -4 >Emitted(10, 32) Source(8, 24) + SourceIndex(0) name (m1_f1) -5 >Emitted(10, 33) Source(8, 25) + SourceIndex(0) name (m1_f1) ---- ->>>} -1 > -2 >^ -3 > ^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -2 >} -1 >Emitted(11, 1) Source(9, 1) + SourceIndex(0) name (m1_f1) -2 >Emitted(11, 2) Source(9, 2) + SourceIndex(0) name (m1_f1) ---- ->>>exports.m1_f1 = m1_f1; -1-> -2 >^^^^^^^^^^^^^ -3 > ^^^^^^^^ -4 > ^ -5 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1-> -2 >m1_f1 -3 > () { - > return m1_instance1; - > } -4 > -1->Emitted(12, 1) Source(7, 17) + SourceIndex(0) -2 >Emitted(12, 14) Source(7, 22) + SourceIndex(0) -3 >Emitted(12, 22) Source(9, 2) + SourceIndex(0) -4 >Emitted(12, 23) Source(9, 2) + SourceIndex(0) ---- ->>>//# sourceMappingURL=/tests/cases/projects/outputdir_module_subfolder/mapFiles/ref/m1.js.map=================================================================== -JsFile: test.js -mapUrl: /tests/cases/projects/outputdir_module_subfolder/mapFiles/test.js.map -sourceRoot: -sources: ../test.ts -=================================================================== -------------------------------------------------------------------- -emittedFile:test.js -sourceFile:../test.ts -------------------------------------------------------------------- ->>>var m1 = require("ref/m1"); -1 > -2 >^^^^ -3 > ^^ -4 > ^^^^^^^^^^^ -5 > ^^^^^^^^ -6 > ^ -7 > ^ -1 > -2 >import -3 > m1 -4 > = require( -5 > "ref/m1" -6 > ) -7 > ; -1 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) -2 >Emitted(1, 5) Source(1, 8) + SourceIndex(0) -3 >Emitted(1, 7) Source(1, 10) + SourceIndex(0) -4 >Emitted(1, 18) Source(1, 21) + SourceIndex(0) -5 >Emitted(1, 26) Source(1, 29) + SourceIndex(0) -6 >Emitted(1, 27) Source(1, 30) + SourceIndex(0) -7 >Emitted(1, 28) Source(1, 31) + SourceIndex(0) ---- ->>>exports.a1 = 10; -1 > -2 >^^^^^^^^^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^-> -1 > - >export var -2 >a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(2, 1) Source(2, 12) + SourceIndex(0) -2 >Emitted(2, 11) Source(2, 14) + SourceIndex(0) -3 >Emitted(2, 14) Source(2, 17) + SourceIndex(0) -4 >Emitted(2, 16) Source(2, 19) + SourceIndex(0) -5 >Emitted(2, 17) Source(2, 20) + SourceIndex(0) ---- ->>>var c1 = (function () { -1-> -2 >^^^^^^^^^^^^^^^^^^^^-> -1-> - > -1->Emitted(3, 1) Source(3, 1) + SourceIndex(0) ---- ->>> function c1() { -1->^^^^ -2 > ^^-> -1-> -1->Emitted(4, 5) Source(3, 1) + SourceIndex(0) name (c1) ---- ->>> } -1->^^^^ -2 > ^ -3 > ^^^^^^^^^^-> -1->export class c1 { - > public p1: number; - > -2 > } -1->Emitted(5, 5) Source(5, 1) + SourceIndex(0) name (c1.constructor) -2 >Emitted(5, 6) Source(5, 2) + SourceIndex(0) name (c1.constructor) ---- ->>> return c1; -1->^^^^ -2 > ^^^^^^^^^ -1-> -2 > } -1->Emitted(6, 5) Source(5, 1) + SourceIndex(0) name (c1) -2 >Emitted(6, 14) Source(5, 2) + SourceIndex(0) name (c1) ---- ->>>})(); -1 > -2 >^ -3 > -4 > ^^^^ -5 > ^^^^^^^^^^^^-> -1 > -2 >} -3 > -4 > export class c1 { - > public p1: number; - > } -1 >Emitted(7, 1) Source(5, 1) + SourceIndex(0) name (c1) -2 >Emitted(7, 2) Source(5, 2) + SourceIndex(0) name (c1) -3 >Emitted(7, 2) Source(3, 1) + SourceIndex(0) -4 >Emitted(7, 6) Source(5, 2) + SourceIndex(0) ---- ->>>exports.c1 = c1; -1-> -2 >^^^^^^^^^^ -3 > ^^^^^ -4 > ^ -5 > ^^^^^^^^^^^^^^-> -1-> -2 >c1 -3 > { - > public p1: number; - > } -4 > -1->Emitted(8, 1) Source(3, 14) + SourceIndex(0) -2 >Emitted(8, 11) Source(3, 16) + SourceIndex(0) -3 >Emitted(8, 16) Source(5, 2) + SourceIndex(0) -4 >Emitted(8, 17) Source(5, 2) + SourceIndex(0) ---- ->>>exports.instance1 = new c1(); -1-> -2 >^^^^^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^^^ -5 > ^^ -6 > ^^ -7 > ^ -1-> - > - >export var -2 >instance1 -3 > = -4 > new -5 > c1 -6 > () -7 > ; -1->Emitted(9, 1) Source(7, 12) + SourceIndex(0) -2 >Emitted(9, 18) Source(7, 21) + SourceIndex(0) -3 >Emitted(9, 21) Source(7, 24) + SourceIndex(0) -4 >Emitted(9, 25) Source(7, 28) + SourceIndex(0) -5 >Emitted(9, 27) Source(7, 30) + SourceIndex(0) -6 >Emitted(9, 29) Source(7, 32) + SourceIndex(0) -7 >Emitted(9, 30) Source(7, 33) + SourceIndex(0) ---- ->>>function f1() { -1 > -2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -1 >Emitted(10, 1) Source(8, 1) + SourceIndex(0) ---- ->>> return exports.instance1; -1->^^^^ -2 > ^^^^^^ -3 > ^ -4 > ^^^^^^^^^^^^^^^^^ -5 > ^ -1->export function f1() { - > -2 > return -3 > -4 > instance1 -5 > ; -1->Emitted(11, 5) Source(9, 5) + SourceIndex(0) name (f1) -2 >Emitted(11, 11) Source(9, 11) + SourceIndex(0) name (f1) -3 >Emitted(11, 12) Source(9, 12) + SourceIndex(0) name (f1) -4 >Emitted(11, 29) Source(9, 21) + SourceIndex(0) name (f1) -5 >Emitted(11, 30) Source(9, 22) + SourceIndex(0) name (f1) ---- ->>>} -1 > -2 >^ -3 > ^^^^^^^^^^^^^^^^-> -1 > - > -2 >} -1 >Emitted(12, 1) Source(10, 1) + SourceIndex(0) name (f1) -2 >Emitted(12, 2) Source(10, 2) + SourceIndex(0) name (f1) ---- ->>>exports.f1 = f1; -1-> -2 >^^^^^^^^^^ -3 > ^^^^^ -4 > ^ -5 > ^^^^^^^-> -1-> -2 >f1 -3 > () { - > return instance1; - > } -4 > -1->Emitted(13, 1) Source(8, 17) + SourceIndex(0) -2 >Emitted(13, 11) Source(8, 19) + SourceIndex(0) -3 >Emitted(13, 16) Source(10, 2) + SourceIndex(0) -4 >Emitted(13, 17) Source(10, 2) + SourceIndex(0) ---- ->>>exports.a2 = m1.m1_c1; -1-> -2 >^^^^^^^^^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^ -7 > ^ -8 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1-> - > - >export var -2 >a2 -3 > = -4 > m1 -5 > . -6 > m1_c1 -7 > ; -1->Emitted(14, 1) Source(12, 12) + SourceIndex(0) -2 >Emitted(14, 11) Source(12, 14) + SourceIndex(0) -3 >Emitted(14, 14) Source(12, 17) + SourceIndex(0) -4 >Emitted(14, 16) Source(12, 19) + SourceIndex(0) -5 >Emitted(14, 17) Source(12, 20) + SourceIndex(0) -6 >Emitted(14, 22) Source(12, 25) + SourceIndex(0) -7 >Emitted(14, 23) Source(12, 26) + SourceIndex(0) ---- ->>>//# sourceMappingURL=/tests/cases/projects/outputdir_module_subfolder/mapFiles/test.js.map=================================================================== JsFile: test.js mapUrl: /tests/cases/projects/outputdir_module_subfolder/mapFiles/test.js.map sourceRoot: diff --git a/tests/baselines/reference/project/mapRootAbsolutePathModuleSubfolderSpecifyOutputFile/node/ref/m1.d.ts b/tests/baselines/reference/project/mapRootAbsolutePathModuleSubfolderSpecifyOutputFile/node/ref/m1.d.ts deleted file mode 100644 index 4a53b24b156..00000000000 --- a/tests/baselines/reference/project/mapRootAbsolutePathModuleSubfolderSpecifyOutputFile/node/ref/m1.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -export declare var m1_a1: number; -export declare class m1_c1 { - m1_c1_p1: number; -} -export declare var m1_instance1: m1_c1; -export declare function m1_f1(): m1_c1; diff --git a/tests/baselines/reference/project/mapRootAbsolutePathModuleSubfolderSpecifyOutputFile/node/ref/m1.js b/tests/baselines/reference/project/mapRootAbsolutePathModuleSubfolderSpecifyOutputFile/node/ref/m1.js deleted file mode 100644 index a420241c901..00000000000 --- a/tests/baselines/reference/project/mapRootAbsolutePathModuleSubfolderSpecifyOutputFile/node/ref/m1.js +++ /dev/null @@ -1,13 +0,0 @@ -exports.m1_a1 = 10; -var m1_c1 = (function () { - function m1_c1() { - } - return m1_c1; -})(); -exports.m1_c1 = m1_c1; -exports.m1_instance1 = new m1_c1(); -function m1_f1() { - return exports.m1_instance1; -} -exports.m1_f1 = m1_f1; -//# sourceMappingURL=/tests/cases/projects/outputdir_module_subfolder/mapFiles/ref/m1.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootAbsolutePathModuleSubfolderSpecifyOutputFile/node/ref/m1.js.map b/tests/baselines/reference/project/mapRootAbsolutePathModuleSubfolderSpecifyOutputFile/node/ref/m1.js.map deleted file mode 100644 index 420650feeac..00000000000 --- a/tests/baselines/reference/project/mapRootAbsolutePathModuleSubfolderSpecifyOutputFile/node/ref/m1.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"m1.js","sourceRoot":"","sources":["../../ref/m1.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1"],"mappings":"AAAW,aAAK,GAAG,EAAE,CAAC;AACtB;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAFY,aAAK,QAEjB,CAAA;AAEU,oBAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACIE,MAAMA,CAACA,oBAAYA,CAACA;AACxBA,CAACA;AAFe,aAAK,QAEpB,CAAA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootAbsolutePathModuleSubfolderSpecifyOutputFile/node/test.d.ts b/tests/baselines/reference/project/mapRootAbsolutePathModuleSubfolderSpecifyOutputFile/node/test.d.ts deleted file mode 100644 index a61d8541048..00000000000 --- a/tests/baselines/reference/project/mapRootAbsolutePathModuleSubfolderSpecifyOutputFile/node/test.d.ts +++ /dev/null @@ -1,8 +0,0 @@ -import m1 = require("ref/m1"); -export declare var a1: number; -export declare class c1 { - p1: number; -} -export declare var instance1: c1; -export declare function f1(): c1; -export declare var a2: typeof m1.m1_c1; diff --git a/tests/baselines/reference/project/mapRootAbsolutePathModuleSubfolderSpecifyOutputFile/node/test.js b/tests/baselines/reference/project/mapRootAbsolutePathModuleSubfolderSpecifyOutputFile/node/test.js deleted file mode 100644 index f6319258d8f..00000000000 --- a/tests/baselines/reference/project/mapRootAbsolutePathModuleSubfolderSpecifyOutputFile/node/test.js +++ /dev/null @@ -1,15 +0,0 @@ -var m1 = require("ref/m1"); -exports.a1 = 10; -var c1 = (function () { - function c1() { - } - return c1; -})(); -exports.c1 = c1; -exports.instance1 = new c1(); -function f1() { - return exports.instance1; -} -exports.f1 = f1; -exports.a2 = m1.m1_c1; -//# sourceMappingURL=/tests/cases/projects/outputdir_module_subfolder/mapFiles/test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootAbsolutePathModuleSubfolderSpecifyOutputFile/node/test.js.map b/tests/baselines/reference/project/mapRootAbsolutePathModuleSubfolderSpecifyOutputFile/node/test.js.map deleted file mode 100644 index 15d4e3e1c9b..00000000000 --- a/tests/baselines/reference/project/mapRootAbsolutePathModuleSubfolderSpecifyOutputFile/node/test.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"test.js","sourceRoot":"","sources":["../test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AAAA,IAAO,EAAE,WAAW,QAAQ,CAAC,CAAC;AACnB,UAAE,GAAG,EAAE,CAAC;AACnB;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAFY,UAAE,KAEd,CAAA;AAEU,iBAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AAChC;IACIE,MAAMA,CAACA,iBAASA,CAACA;AACrBA,CAACA;AAFe,UAAE,KAEjB,CAAA;AAEU,UAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFile/amd/mapRootRelativePathMixedSubfolderSpecifyOutputFile.json b/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFile/amd/mapRootRelativePathMixedSubfolderSpecifyOutputFile.json index 8e87f61b8df..f3b0bdd119e 100644 --- a/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFile/amd/mapRootRelativePathMixedSubfolderSpecifyOutputFile.json +++ b/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFile/amd/mapRootRelativePathMixedSubfolderSpecifyOutputFile.json @@ -16,9 +16,6 @@ "test.ts" ], "emittedFiles": [ - "ref/m2.js.map", - "ref/m2.js", - "ref/m2.d.ts", "bin/test.js.map", "bin/test.js", "bin/test.d.ts" diff --git a/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFile/amd/mapRootRelativePathMixedSubfolderSpecifyOutputFile.sourcemap.txt b/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFile/amd/mapRootRelativePathMixedSubfolderSpecifyOutputFile.sourcemap.txt index 33ebe5aaafb..cfd0952c941 100644 --- a/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFile/amd/mapRootRelativePathMixedSubfolderSpecifyOutputFile.sourcemap.txt +++ b/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFile/amd/mapRootRelativePathMixedSubfolderSpecifyOutputFile.sourcemap.txt @@ -1,176 +1,4 @@ =================================================================== -JsFile: m2.js -mapUrl: ../../mapFiles/ref/m2.js.map -sourceRoot: -sources: ../../outputdir_mixed_subfolder/ref/m2.ts -=================================================================== -------------------------------------------------------------------- -emittedFile:ref/m2.js -sourceFile:../../outputdir_mixed_subfolder/ref/m2.ts -------------------------------------------------------------------- ->>>define(["require", "exports"], function (require, exports) { ->>> exports.m2_a1 = 10; -1 >^^^^ -2 > ^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^-> -1 >export var -2 > m2_a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(2, 5) Source(1, 12) + SourceIndex(0) -2 >Emitted(2, 18) Source(1, 17) + SourceIndex(0) -3 >Emitted(2, 21) Source(1, 20) + SourceIndex(0) -4 >Emitted(2, 23) Source(1, 22) + SourceIndex(0) -5 >Emitted(2, 24) Source(1, 23) + SourceIndex(0) ---- ->>> var m2_c1 = (function () { -1->^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^^^^-> -1-> - > -1->Emitted(3, 5) Source(2, 1) + SourceIndex(0) ---- ->>> function m2_c1() { -1->^^^^^^^^ -2 > ^^-> -1-> -1->Emitted(4, 9) Source(2, 1) + SourceIndex(0) name (m2_c1) ---- ->>> } -1->^^^^^^^^ -2 > ^ -3 > ^^^^^^^^^^^^^-> -1->export class m2_c1 { - > public m2_c1_p1: number; - > -2 > } -1->Emitted(5, 9) Source(4, 1) + SourceIndex(0) name (m2_c1.constructor) -2 >Emitted(5, 10) Source(4, 2) + SourceIndex(0) name (m2_c1.constructor) ---- ->>> return m2_c1; -1->^^^^^^^^ -2 > ^^^^^^^^^^^^ -1-> -2 > } -1->Emitted(6, 9) Source(4, 1) + SourceIndex(0) name (m2_c1) -2 >Emitted(6, 21) Source(4, 2) + SourceIndex(0) name (m2_c1) ---- ->>> })(); -1 >^^^^ -2 > ^ -3 > -4 > ^^^^ -5 > ^^^^^^^^^^^^^^^^^^-> -1 > -2 > } -3 > -4 > export class m2_c1 { - > public m2_c1_p1: number; - > } -1 >Emitted(7, 5) Source(4, 1) + SourceIndex(0) name (m2_c1) -2 >Emitted(7, 6) Source(4, 2) + SourceIndex(0) name (m2_c1) -3 >Emitted(7, 6) Source(2, 1) + SourceIndex(0) -4 >Emitted(7, 10) Source(4, 2) + SourceIndex(0) ---- ->>> exports.m2_c1 = m2_c1; -1->^^^^ -2 > ^^^^^^^^^^^^^ -3 > ^^^^^^^^ -4 > ^ -5 > ^^^^^^^^^^^^^^-> -1-> -2 > m2_c1 -3 > { - > public m2_c1_p1: number; - > } -4 > -1->Emitted(8, 5) Source(2, 14) + SourceIndex(0) -2 >Emitted(8, 18) Source(2, 19) + SourceIndex(0) -3 >Emitted(8, 26) Source(4, 2) + SourceIndex(0) -4 >Emitted(8, 27) Source(4, 2) + SourceIndex(0) ---- ->>> exports.m2_instance1 = new m2_c1(); -1->^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^^^ -5 > ^^^^^ -6 > ^^ -7 > ^ -1-> - > - >export var -2 > m2_instance1 -3 > = -4 > new -5 > m2_c1 -6 > () -7 > ; -1->Emitted(9, 5) Source(6, 12) + SourceIndex(0) -2 >Emitted(9, 25) Source(6, 24) + SourceIndex(0) -3 >Emitted(9, 28) Source(6, 27) + SourceIndex(0) -4 >Emitted(9, 32) Source(6, 31) + SourceIndex(0) -5 >Emitted(9, 37) Source(6, 36) + SourceIndex(0) -6 >Emitted(9, 39) Source(6, 38) + SourceIndex(0) -7 >Emitted(9, 40) Source(6, 39) + SourceIndex(0) ---- ->>> function m2_f1() { -1 >^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -1 >Emitted(10, 5) Source(7, 1) + SourceIndex(0) ---- ->>> return exports.m2_instance1; -1->^^^^^^^^ -2 > ^^^^^^ -3 > ^ -4 > ^^^^^^^^^^^^^^^^^^^^ -5 > ^ -1->export function m2_f1() { - > -2 > return -3 > -4 > m2_instance1 -5 > ; -1->Emitted(11, 9) Source(8, 5) + SourceIndex(0) name (m2_f1) -2 >Emitted(11, 15) Source(8, 11) + SourceIndex(0) name (m2_f1) -3 >Emitted(11, 16) Source(8, 12) + SourceIndex(0) name (m2_f1) -4 >Emitted(11, 36) Source(8, 24) + SourceIndex(0) name (m2_f1) -5 >Emitted(11, 37) Source(8, 25) + SourceIndex(0) name (m2_f1) ---- ->>> } -1 >^^^^ -2 > ^ -3 > ^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -2 > } -1 >Emitted(12, 5) Source(9, 1) + SourceIndex(0) name (m2_f1) -2 >Emitted(12, 6) Source(9, 2) + SourceIndex(0) name (m2_f1) ---- ->>> exports.m2_f1 = m2_f1; -1->^^^^ -2 > ^^^^^^^^^^^^^ -3 > ^^^^^^^^ -4 > ^ -1-> -2 > m2_f1 -3 > () { - > return m2_instance1; - > } -4 > -1->Emitted(13, 5) Source(7, 17) + SourceIndex(0) -2 >Emitted(13, 18) Source(7, 22) + SourceIndex(0) -3 >Emitted(13, 26) Source(9, 2) + SourceIndex(0) -4 >Emitted(13, 27) Source(9, 2) + SourceIndex(0) ---- ->>>}); ->>>//# sourceMappingURL=../../mapFiles/ref/m2.js.map=================================================================== JsFile: test.js mapUrl: ../../mapFiles/test.js.map sourceRoot: diff --git a/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFile/amd/ref/m2.d.ts b/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFile/amd/ref/m2.d.ts deleted file mode 100644 index c09a3c0c32a..00000000000 --- a/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFile/amd/ref/m2.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -export declare var m2_a1: number; -export declare class m2_c1 { - m2_c1_p1: number; -} -export declare var m2_instance1: m2_c1; -export declare function m2_f1(): m2_c1; diff --git a/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFile/amd/ref/m2.js b/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFile/amd/ref/m2.js deleted file mode 100644 index 4f0b35f21c7..00000000000 --- a/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFile/amd/ref/m2.js +++ /dev/null @@ -1,15 +0,0 @@ -define(["require", "exports"], function (require, exports) { - exports.m2_a1 = 10; - var m2_c1 = (function () { - function m2_c1() { - } - return m2_c1; - })(); - exports.m2_c1 = m2_c1; - exports.m2_instance1 = new m2_c1(); - function m2_f1() { - return exports.m2_instance1; - } - exports.m2_f1 = m2_f1; -}); -//# sourceMappingURL=../../mapFiles/ref/m2.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFile/amd/ref/m2.js.map b/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFile/amd/ref/m2.js.map deleted file mode 100644 index 81bb9202e5a..00000000000 --- a/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFile/amd/ref/m2.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"m2.js","sourceRoot":"","sources":["../../outputdir_mixed_subfolder/ref/m2.ts"],"names":["m2_c1","m2_c1.constructor","m2_f1"],"mappings":";IAAW,aAAK,GAAG,EAAE,CAAC;IACtB;QAAAA;QAEAC,CAACA;QAADD,YAACA;IAADA,CAACA,AAFD,IAEC;IAFY,aAAK,QAEjB,CAAA;IAEU,oBAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACIE,MAAMA,CAACA,oBAAYA,CAACA;IACxBA,CAACA;IAFe,aAAK,QAEpB,CAAA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFile/node/mapRootRelativePathMixedSubfolderSpecifyOutputFile.json b/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFile/node/mapRootRelativePathMixedSubfolderSpecifyOutputFile.json index 8e87f61b8df..f3b0bdd119e 100644 --- a/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFile/node/mapRootRelativePathMixedSubfolderSpecifyOutputFile.json +++ b/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFile/node/mapRootRelativePathMixedSubfolderSpecifyOutputFile.json @@ -16,9 +16,6 @@ "test.ts" ], "emittedFiles": [ - "ref/m2.js.map", - "ref/m2.js", - "ref/m2.d.ts", "bin/test.js.map", "bin/test.js", "bin/test.d.ts" diff --git a/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFile/node/mapRootRelativePathMixedSubfolderSpecifyOutputFile.sourcemap.txt b/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFile/node/mapRootRelativePathMixedSubfolderSpecifyOutputFile.sourcemap.txt index d55115b85f2..931a09b3ae6 100644 --- a/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFile/node/mapRootRelativePathMixedSubfolderSpecifyOutputFile.sourcemap.txt +++ b/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFile/node/mapRootRelativePathMixedSubfolderSpecifyOutputFile.sourcemap.txt @@ -1,175 +1,4 @@ =================================================================== -JsFile: m2.js -mapUrl: ../../mapFiles/ref/m2.js.map -sourceRoot: -sources: ../../outputdir_mixed_subfolder/ref/m2.ts -=================================================================== -------------------------------------------------------------------- -emittedFile:ref/m2.js -sourceFile:../../outputdir_mixed_subfolder/ref/m2.ts -------------------------------------------------------------------- ->>>exports.m2_a1 = 10; -1 > -2 >^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^-> -1 >export var -2 >m2_a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(1, 1) Source(1, 12) + SourceIndex(0) -2 >Emitted(1, 14) Source(1, 17) + SourceIndex(0) -3 >Emitted(1, 17) Source(1, 20) + SourceIndex(0) -4 >Emitted(1, 19) Source(1, 22) + SourceIndex(0) -5 >Emitted(1, 20) Source(1, 23) + SourceIndex(0) ---- ->>>var m2_c1 = (function () { -1-> -2 >^^^^^^^^^^^^^^^^^^^^^^^-> -1-> - > -1->Emitted(2, 1) Source(2, 1) + SourceIndex(0) ---- ->>> function m2_c1() { -1->^^^^ -2 > ^^-> -1-> -1->Emitted(3, 5) Source(2, 1) + SourceIndex(0) name (m2_c1) ---- ->>> } -1->^^^^ -2 > ^ -3 > ^^^^^^^^^^^^^-> -1->export class m2_c1 { - > public m2_c1_p1: number; - > -2 > } -1->Emitted(4, 5) Source(4, 1) + SourceIndex(0) name (m2_c1.constructor) -2 >Emitted(4, 6) Source(4, 2) + SourceIndex(0) name (m2_c1.constructor) ---- ->>> return m2_c1; -1->^^^^ -2 > ^^^^^^^^^^^^ -1-> -2 > } -1->Emitted(5, 5) Source(4, 1) + SourceIndex(0) name (m2_c1) -2 >Emitted(5, 17) Source(4, 2) + SourceIndex(0) name (m2_c1) ---- ->>>})(); -1 > -2 >^ -3 > -4 > ^^^^ -5 > ^^^^^^^^^^^^^^^^^^-> -1 > -2 >} -3 > -4 > export class m2_c1 { - > public m2_c1_p1: number; - > } -1 >Emitted(6, 1) Source(4, 1) + SourceIndex(0) name (m2_c1) -2 >Emitted(6, 2) Source(4, 2) + SourceIndex(0) name (m2_c1) -3 >Emitted(6, 2) Source(2, 1) + SourceIndex(0) -4 >Emitted(6, 6) Source(4, 2) + SourceIndex(0) ---- ->>>exports.m2_c1 = m2_c1; -1-> -2 >^^^^^^^^^^^^^ -3 > ^^^^^^^^ -4 > ^ -5 > ^^^^^^^^^^^^^^-> -1-> -2 >m2_c1 -3 > { - > public m2_c1_p1: number; - > } -4 > -1->Emitted(7, 1) Source(2, 14) + SourceIndex(0) -2 >Emitted(7, 14) Source(2, 19) + SourceIndex(0) -3 >Emitted(7, 22) Source(4, 2) + SourceIndex(0) -4 >Emitted(7, 23) Source(4, 2) + SourceIndex(0) ---- ->>>exports.m2_instance1 = new m2_c1(); -1-> -2 >^^^^^^^^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^^^ -5 > ^^^^^ -6 > ^^ -7 > ^ -1-> - > - >export var -2 >m2_instance1 -3 > = -4 > new -5 > m2_c1 -6 > () -7 > ; -1->Emitted(8, 1) Source(6, 12) + SourceIndex(0) -2 >Emitted(8, 21) Source(6, 24) + SourceIndex(0) -3 >Emitted(8, 24) Source(6, 27) + SourceIndex(0) -4 >Emitted(8, 28) Source(6, 31) + SourceIndex(0) -5 >Emitted(8, 33) Source(6, 36) + SourceIndex(0) -6 >Emitted(8, 35) Source(6, 38) + SourceIndex(0) -7 >Emitted(8, 36) Source(6, 39) + SourceIndex(0) ---- ->>>function m2_f1() { -1 > -2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -1 >Emitted(9, 1) Source(7, 1) + SourceIndex(0) ---- ->>> return exports.m2_instance1; -1->^^^^ -2 > ^^^^^^ -3 > ^ -4 > ^^^^^^^^^^^^^^^^^^^^ -5 > ^ -1->export function m2_f1() { - > -2 > return -3 > -4 > m2_instance1 -5 > ; -1->Emitted(10, 5) Source(8, 5) + SourceIndex(0) name (m2_f1) -2 >Emitted(10, 11) Source(8, 11) + SourceIndex(0) name (m2_f1) -3 >Emitted(10, 12) Source(8, 12) + SourceIndex(0) name (m2_f1) -4 >Emitted(10, 32) Source(8, 24) + SourceIndex(0) name (m2_f1) -5 >Emitted(10, 33) Source(8, 25) + SourceIndex(0) name (m2_f1) ---- ->>>} -1 > -2 >^ -3 > ^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -2 >} -1 >Emitted(11, 1) Source(9, 1) + SourceIndex(0) name (m2_f1) -2 >Emitted(11, 2) Source(9, 2) + SourceIndex(0) name (m2_f1) ---- ->>>exports.m2_f1 = m2_f1; -1-> -2 >^^^^^^^^^^^^^ -3 > ^^^^^^^^ -4 > ^ -5 > ^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1-> -2 >m2_f1 -3 > () { - > return m2_instance1; - > } -4 > -1->Emitted(12, 1) Source(7, 17) + SourceIndex(0) -2 >Emitted(12, 14) Source(7, 22) + SourceIndex(0) -3 >Emitted(12, 22) Source(9, 2) + SourceIndex(0) -4 >Emitted(12, 23) Source(9, 2) + SourceIndex(0) ---- ->>>//# sourceMappingURL=../../mapFiles/ref/m2.js.map=================================================================== JsFile: test.js mapUrl: ../../mapFiles/test.js.map sourceRoot: diff --git a/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFile/node/ref/m2.d.ts b/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFile/node/ref/m2.d.ts deleted file mode 100644 index c09a3c0c32a..00000000000 --- a/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFile/node/ref/m2.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -export declare var m2_a1: number; -export declare class m2_c1 { - m2_c1_p1: number; -} -export declare var m2_instance1: m2_c1; -export declare function m2_f1(): m2_c1; diff --git a/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFile/node/ref/m2.js b/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFile/node/ref/m2.js deleted file mode 100644 index f13773b3384..00000000000 --- a/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFile/node/ref/m2.js +++ /dev/null @@ -1,13 +0,0 @@ -exports.m2_a1 = 10; -var m2_c1 = (function () { - function m2_c1() { - } - return m2_c1; -})(); -exports.m2_c1 = m2_c1; -exports.m2_instance1 = new m2_c1(); -function m2_f1() { - return exports.m2_instance1; -} -exports.m2_f1 = m2_f1; -//# sourceMappingURL=../../mapFiles/ref/m2.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFile/node/ref/m2.js.map b/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFile/node/ref/m2.js.map deleted file mode 100644 index 98da596cfa4..00000000000 --- a/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFile/node/ref/m2.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"m2.js","sourceRoot":"","sources":["../../outputdir_mixed_subfolder/ref/m2.ts"],"names":["m2_c1","m2_c1.constructor","m2_f1"],"mappings":"AAAW,aAAK,GAAG,EAAE,CAAC;AACtB;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAFY,aAAK,QAEjB,CAAA;AAEU,oBAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACIE,MAAMA,CAACA,oBAAYA,CAACA;AACxBA,CAACA;AAFe,aAAK,QAEpB,CAAA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/mapRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory.json b/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/mapRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory.json index 4ed441e2552..0d6c009961b 100644 --- a/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/mapRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory.json +++ b/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/mapRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory.json @@ -17,9 +17,6 @@ "test.ts" ], "emittedFiles": [ - "outdir/outAndOutDirFolder/ref/m2.js.map", - "outdir/outAndOutDirFolder/ref/m2.js", - "outdir/outAndOutDirFolder/ref/m2.d.ts", "bin/outAndOutDirFile.js.map", "bin/outAndOutDirFile.js", "bin/outAndOutDirFile.d.ts" diff --git a/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/mapRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory.sourcemap.txt b/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/mapRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory.sourcemap.txt index 9932fdda3e9..cb14a553f05 100644 --- a/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/mapRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory.sourcemap.txt +++ b/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/mapRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory.sourcemap.txt @@ -1,176 +1,4 @@ =================================================================== -JsFile: m2.js -mapUrl: ../../../../mapFiles/ref/m2.js.map -sourceRoot: -sources: ../../outputdir_mixed_subfolder/ref/m2.ts -=================================================================== -------------------------------------------------------------------- -emittedFile:outdir/outAndOutDirFolder/ref/m2.js -sourceFile:../../outputdir_mixed_subfolder/ref/m2.ts -------------------------------------------------------------------- ->>>define(["require", "exports"], function (require, exports) { ->>> exports.m2_a1 = 10; -1 >^^^^ -2 > ^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^-> -1 >export var -2 > m2_a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(2, 5) Source(1, 12) + SourceIndex(0) -2 >Emitted(2, 18) Source(1, 17) + SourceIndex(0) -3 >Emitted(2, 21) Source(1, 20) + SourceIndex(0) -4 >Emitted(2, 23) Source(1, 22) + SourceIndex(0) -5 >Emitted(2, 24) Source(1, 23) + SourceIndex(0) ---- ->>> var m2_c1 = (function () { -1->^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^^^^-> -1-> - > -1->Emitted(3, 5) Source(2, 1) + SourceIndex(0) ---- ->>> function m2_c1() { -1->^^^^^^^^ -2 > ^^-> -1-> -1->Emitted(4, 9) Source(2, 1) + SourceIndex(0) name (m2_c1) ---- ->>> } -1->^^^^^^^^ -2 > ^ -3 > ^^^^^^^^^^^^^-> -1->export class m2_c1 { - > public m2_c1_p1: number; - > -2 > } -1->Emitted(5, 9) Source(4, 1) + SourceIndex(0) name (m2_c1.constructor) -2 >Emitted(5, 10) Source(4, 2) + SourceIndex(0) name (m2_c1.constructor) ---- ->>> return m2_c1; -1->^^^^^^^^ -2 > ^^^^^^^^^^^^ -1-> -2 > } -1->Emitted(6, 9) Source(4, 1) + SourceIndex(0) name (m2_c1) -2 >Emitted(6, 21) Source(4, 2) + SourceIndex(0) name (m2_c1) ---- ->>> })(); -1 >^^^^ -2 > ^ -3 > -4 > ^^^^ -5 > ^^^^^^^^^^^^^^^^^^-> -1 > -2 > } -3 > -4 > export class m2_c1 { - > public m2_c1_p1: number; - > } -1 >Emitted(7, 5) Source(4, 1) + SourceIndex(0) name (m2_c1) -2 >Emitted(7, 6) Source(4, 2) + SourceIndex(0) name (m2_c1) -3 >Emitted(7, 6) Source(2, 1) + SourceIndex(0) -4 >Emitted(7, 10) Source(4, 2) + SourceIndex(0) ---- ->>> exports.m2_c1 = m2_c1; -1->^^^^ -2 > ^^^^^^^^^^^^^ -3 > ^^^^^^^^ -4 > ^ -5 > ^^^^^^^^^^^^^^-> -1-> -2 > m2_c1 -3 > { - > public m2_c1_p1: number; - > } -4 > -1->Emitted(8, 5) Source(2, 14) + SourceIndex(0) -2 >Emitted(8, 18) Source(2, 19) + SourceIndex(0) -3 >Emitted(8, 26) Source(4, 2) + SourceIndex(0) -4 >Emitted(8, 27) Source(4, 2) + SourceIndex(0) ---- ->>> exports.m2_instance1 = new m2_c1(); -1->^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^^^ -5 > ^^^^^ -6 > ^^ -7 > ^ -1-> - > - >export var -2 > m2_instance1 -3 > = -4 > new -5 > m2_c1 -6 > () -7 > ; -1->Emitted(9, 5) Source(6, 12) + SourceIndex(0) -2 >Emitted(9, 25) Source(6, 24) + SourceIndex(0) -3 >Emitted(9, 28) Source(6, 27) + SourceIndex(0) -4 >Emitted(9, 32) Source(6, 31) + SourceIndex(0) -5 >Emitted(9, 37) Source(6, 36) + SourceIndex(0) -6 >Emitted(9, 39) Source(6, 38) + SourceIndex(0) -7 >Emitted(9, 40) Source(6, 39) + SourceIndex(0) ---- ->>> function m2_f1() { -1 >^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -1 >Emitted(10, 5) Source(7, 1) + SourceIndex(0) ---- ->>> return exports.m2_instance1; -1->^^^^^^^^ -2 > ^^^^^^ -3 > ^ -4 > ^^^^^^^^^^^^^^^^^^^^ -5 > ^ -1->export function m2_f1() { - > -2 > return -3 > -4 > m2_instance1 -5 > ; -1->Emitted(11, 9) Source(8, 5) + SourceIndex(0) name (m2_f1) -2 >Emitted(11, 15) Source(8, 11) + SourceIndex(0) name (m2_f1) -3 >Emitted(11, 16) Source(8, 12) + SourceIndex(0) name (m2_f1) -4 >Emitted(11, 36) Source(8, 24) + SourceIndex(0) name (m2_f1) -5 >Emitted(11, 37) Source(8, 25) + SourceIndex(0) name (m2_f1) ---- ->>> } -1 >^^^^ -2 > ^ -3 > ^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -2 > } -1 >Emitted(12, 5) Source(9, 1) + SourceIndex(0) name (m2_f1) -2 >Emitted(12, 6) Source(9, 2) + SourceIndex(0) name (m2_f1) ---- ->>> exports.m2_f1 = m2_f1; -1->^^^^ -2 > ^^^^^^^^^^^^^ -3 > ^^^^^^^^ -4 > ^ -1-> -2 > m2_f1 -3 > () { - > return m2_instance1; - > } -4 > -1->Emitted(13, 5) Source(7, 17) + SourceIndex(0) -2 >Emitted(13, 18) Source(7, 22) + SourceIndex(0) -3 >Emitted(13, 26) Source(9, 2) + SourceIndex(0) -4 >Emitted(13, 27) Source(9, 2) + SourceIndex(0) ---- ->>>}); ->>>//# sourceMappingURL=../../../../mapFiles/ref/m2.js.map=================================================================== JsFile: outAndOutDirFile.js mapUrl: ../../mapFiles/outAndOutDirFile.js.map sourceRoot: diff --git a/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/outdir/outAndOutDirFolder/ref/m2.d.ts b/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/outdir/outAndOutDirFolder/ref/m2.d.ts deleted file mode 100644 index c09a3c0c32a..00000000000 --- a/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/outdir/outAndOutDirFolder/ref/m2.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -export declare var m2_a1: number; -export declare class m2_c1 { - m2_c1_p1: number; -} -export declare var m2_instance1: m2_c1; -export declare function m2_f1(): m2_c1; diff --git a/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/outdir/outAndOutDirFolder/ref/m2.js b/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/outdir/outAndOutDirFolder/ref/m2.js deleted file mode 100644 index e4c8f7b3610..00000000000 --- a/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/outdir/outAndOutDirFolder/ref/m2.js +++ /dev/null @@ -1,15 +0,0 @@ -define(["require", "exports"], function (require, exports) { - exports.m2_a1 = 10; - var m2_c1 = (function () { - function m2_c1() { - } - return m2_c1; - })(); - exports.m2_c1 = m2_c1; - exports.m2_instance1 = new m2_c1(); - function m2_f1() { - return exports.m2_instance1; - } - exports.m2_f1 = m2_f1; -}); -//# sourceMappingURL=../../../../mapFiles/ref/m2.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/outdir/outAndOutDirFolder/ref/m2.js.map b/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/outdir/outAndOutDirFolder/ref/m2.js.map deleted file mode 100644 index 81bb9202e5a..00000000000 --- a/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/outdir/outAndOutDirFolder/ref/m2.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"m2.js","sourceRoot":"","sources":["../../outputdir_mixed_subfolder/ref/m2.ts"],"names":["m2_c1","m2_c1.constructor","m2_f1"],"mappings":";IAAW,aAAK,GAAG,EAAE,CAAC;IACtB;QAAAA;QAEAC,CAACA;QAADD,YAACA;IAADA,CAACA,AAFD,IAEC;IAFY,aAAK,QAEjB,CAAA;IAEU,oBAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACIE,MAAMA,CAACA,oBAAYA,CAACA;IACxBA,CAACA;IAFe,aAAK,QAEpB,CAAA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/mapRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory.json b/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/mapRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory.json index 4ed441e2552..0d6c009961b 100644 --- a/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/mapRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory.json +++ b/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/mapRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory.json @@ -17,9 +17,6 @@ "test.ts" ], "emittedFiles": [ - "outdir/outAndOutDirFolder/ref/m2.js.map", - "outdir/outAndOutDirFolder/ref/m2.js", - "outdir/outAndOutDirFolder/ref/m2.d.ts", "bin/outAndOutDirFile.js.map", "bin/outAndOutDirFile.js", "bin/outAndOutDirFile.d.ts" diff --git a/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/mapRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory.sourcemap.txt b/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/mapRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory.sourcemap.txt index 89fba663c60..eddbc79711c 100644 --- a/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/mapRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory.sourcemap.txt +++ b/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/mapRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory.sourcemap.txt @@ -1,175 +1,4 @@ =================================================================== -JsFile: m2.js -mapUrl: ../../../../mapFiles/ref/m2.js.map -sourceRoot: -sources: ../../outputdir_mixed_subfolder/ref/m2.ts -=================================================================== -------------------------------------------------------------------- -emittedFile:outdir/outAndOutDirFolder/ref/m2.js -sourceFile:../../outputdir_mixed_subfolder/ref/m2.ts -------------------------------------------------------------------- ->>>exports.m2_a1 = 10; -1 > -2 >^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^-> -1 >export var -2 >m2_a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(1, 1) Source(1, 12) + SourceIndex(0) -2 >Emitted(1, 14) Source(1, 17) + SourceIndex(0) -3 >Emitted(1, 17) Source(1, 20) + SourceIndex(0) -4 >Emitted(1, 19) Source(1, 22) + SourceIndex(0) -5 >Emitted(1, 20) Source(1, 23) + SourceIndex(0) ---- ->>>var m2_c1 = (function () { -1-> -2 >^^^^^^^^^^^^^^^^^^^^^^^-> -1-> - > -1->Emitted(2, 1) Source(2, 1) + SourceIndex(0) ---- ->>> function m2_c1() { -1->^^^^ -2 > ^^-> -1-> -1->Emitted(3, 5) Source(2, 1) + SourceIndex(0) name (m2_c1) ---- ->>> } -1->^^^^ -2 > ^ -3 > ^^^^^^^^^^^^^-> -1->export class m2_c1 { - > public m2_c1_p1: number; - > -2 > } -1->Emitted(4, 5) Source(4, 1) + SourceIndex(0) name (m2_c1.constructor) -2 >Emitted(4, 6) Source(4, 2) + SourceIndex(0) name (m2_c1.constructor) ---- ->>> return m2_c1; -1->^^^^ -2 > ^^^^^^^^^^^^ -1-> -2 > } -1->Emitted(5, 5) Source(4, 1) + SourceIndex(0) name (m2_c1) -2 >Emitted(5, 17) Source(4, 2) + SourceIndex(0) name (m2_c1) ---- ->>>})(); -1 > -2 >^ -3 > -4 > ^^^^ -5 > ^^^^^^^^^^^^^^^^^^-> -1 > -2 >} -3 > -4 > export class m2_c1 { - > public m2_c1_p1: number; - > } -1 >Emitted(6, 1) Source(4, 1) + SourceIndex(0) name (m2_c1) -2 >Emitted(6, 2) Source(4, 2) + SourceIndex(0) name (m2_c1) -3 >Emitted(6, 2) Source(2, 1) + SourceIndex(0) -4 >Emitted(6, 6) Source(4, 2) + SourceIndex(0) ---- ->>>exports.m2_c1 = m2_c1; -1-> -2 >^^^^^^^^^^^^^ -3 > ^^^^^^^^ -4 > ^ -5 > ^^^^^^^^^^^^^^-> -1-> -2 >m2_c1 -3 > { - > public m2_c1_p1: number; - > } -4 > -1->Emitted(7, 1) Source(2, 14) + SourceIndex(0) -2 >Emitted(7, 14) Source(2, 19) + SourceIndex(0) -3 >Emitted(7, 22) Source(4, 2) + SourceIndex(0) -4 >Emitted(7, 23) Source(4, 2) + SourceIndex(0) ---- ->>>exports.m2_instance1 = new m2_c1(); -1-> -2 >^^^^^^^^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^^^ -5 > ^^^^^ -6 > ^^ -7 > ^ -1-> - > - >export var -2 >m2_instance1 -3 > = -4 > new -5 > m2_c1 -6 > () -7 > ; -1->Emitted(8, 1) Source(6, 12) + SourceIndex(0) -2 >Emitted(8, 21) Source(6, 24) + SourceIndex(0) -3 >Emitted(8, 24) Source(6, 27) + SourceIndex(0) -4 >Emitted(8, 28) Source(6, 31) + SourceIndex(0) -5 >Emitted(8, 33) Source(6, 36) + SourceIndex(0) -6 >Emitted(8, 35) Source(6, 38) + SourceIndex(0) -7 >Emitted(8, 36) Source(6, 39) + SourceIndex(0) ---- ->>>function m2_f1() { -1 > -2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -1 >Emitted(9, 1) Source(7, 1) + SourceIndex(0) ---- ->>> return exports.m2_instance1; -1->^^^^ -2 > ^^^^^^ -3 > ^ -4 > ^^^^^^^^^^^^^^^^^^^^ -5 > ^ -1->export function m2_f1() { - > -2 > return -3 > -4 > m2_instance1 -5 > ; -1->Emitted(10, 5) Source(8, 5) + SourceIndex(0) name (m2_f1) -2 >Emitted(10, 11) Source(8, 11) + SourceIndex(0) name (m2_f1) -3 >Emitted(10, 12) Source(8, 12) + SourceIndex(0) name (m2_f1) -4 >Emitted(10, 32) Source(8, 24) + SourceIndex(0) name (m2_f1) -5 >Emitted(10, 33) Source(8, 25) + SourceIndex(0) name (m2_f1) ---- ->>>} -1 > -2 >^ -3 > ^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -2 >} -1 >Emitted(11, 1) Source(9, 1) + SourceIndex(0) name (m2_f1) -2 >Emitted(11, 2) Source(9, 2) + SourceIndex(0) name (m2_f1) ---- ->>>exports.m2_f1 = m2_f1; -1-> -2 >^^^^^^^^^^^^^ -3 > ^^^^^^^^ -4 > ^ -5 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1-> -2 >m2_f1 -3 > () { - > return m2_instance1; - > } -4 > -1->Emitted(12, 1) Source(7, 17) + SourceIndex(0) -2 >Emitted(12, 14) Source(7, 22) + SourceIndex(0) -3 >Emitted(12, 22) Source(9, 2) + SourceIndex(0) -4 >Emitted(12, 23) Source(9, 2) + SourceIndex(0) ---- ->>>//# sourceMappingURL=../../../../mapFiles/ref/m2.js.map=================================================================== JsFile: outAndOutDirFile.js mapUrl: ../../mapFiles/outAndOutDirFile.js.map sourceRoot: diff --git a/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/outdir/outAndOutDirFolder/ref/m2.d.ts b/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/outdir/outAndOutDirFolder/ref/m2.d.ts deleted file mode 100644 index c09a3c0c32a..00000000000 --- a/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/outdir/outAndOutDirFolder/ref/m2.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -export declare var m2_a1: number; -export declare class m2_c1 { - m2_c1_p1: number; -} -export declare var m2_instance1: m2_c1; -export declare function m2_f1(): m2_c1; diff --git a/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/outdir/outAndOutDirFolder/ref/m2.js b/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/outdir/outAndOutDirFolder/ref/m2.js deleted file mode 100644 index d78261fe225..00000000000 --- a/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/outdir/outAndOutDirFolder/ref/m2.js +++ /dev/null @@ -1,13 +0,0 @@ -exports.m2_a1 = 10; -var m2_c1 = (function () { - function m2_c1() { - } - return m2_c1; -})(); -exports.m2_c1 = m2_c1; -exports.m2_instance1 = new m2_c1(); -function m2_f1() { - return exports.m2_instance1; -} -exports.m2_f1 = m2_f1; -//# sourceMappingURL=../../../../mapFiles/ref/m2.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/outdir/outAndOutDirFolder/ref/m2.js.map b/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/outdir/outAndOutDirFolder/ref/m2.js.map deleted file mode 100644 index 98da596cfa4..00000000000 --- a/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/outdir/outAndOutDirFolder/ref/m2.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"m2.js","sourceRoot":"","sources":["../../outputdir_mixed_subfolder/ref/m2.ts"],"names":["m2_c1","m2_c1.constructor","m2_f1"],"mappings":"AAAW,aAAK,GAAG,EAAE,CAAC;AACtB;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAFY,aAAK,QAEjB,CAAA;AAEU,oBAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACIE,MAAMA,CAACA,oBAAYA,CAACA;AACxBA,CAACA;AAFe,aAAK,QAEpB,CAAA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderSpecifyOutputFile/amd/diskFile0.js.map b/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderSpecifyOutputFile/amd/diskFile0.js.map deleted file mode 100644 index 9745ad1a4ab..00000000000 --- a/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderSpecifyOutputFile/amd/diskFile0.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"m2.js","sourceRoot":"","sources":["../../projects/outputdir_module_multifolder_ref/m2.ts"],"names":["m2_c1","m2_c1.constructor","m2_f1"],"mappings":";IAAW,aAAK,GAAG,EAAE,CAAC;IACtB;QAAAA;QAEAC,CAACA;QAADD,YAACA;IAADA,CAACA,AAFD,IAEC;IAFY,aAAK,QAEjB,CAAA;IAEU,oBAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACIE,MAAMA,CAACA,oBAAYA,CAACA;IACxBA,CAACA;IAFe,aAAK,QAEpB,CAAA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderSpecifyOutputFile/amd/diskFile1.js b/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderSpecifyOutputFile/amd/diskFile1.js deleted file mode 100644 index ad9b3f68611..00000000000 --- a/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderSpecifyOutputFile/amd/diskFile1.js +++ /dev/null @@ -1,15 +0,0 @@ -define(["require", "exports"], function (require, exports) { - exports.m2_a1 = 10; - var m2_c1 = (function () { - function m2_c1() { - } - return m2_c1; - })(); - exports.m2_c1 = m2_c1; - exports.m2_instance1 = new m2_c1(); - function m2_f1() { - return exports.m2_instance1; - } - exports.m2_f1 = m2_f1; -}); -//# sourceMappingURL=../../mapFiles/outputdir_module_multifolder_ref/m2.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderSpecifyOutputFile/amd/diskFile2.d.ts b/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderSpecifyOutputFile/amd/diskFile2.d.ts deleted file mode 100644 index c09a3c0c32a..00000000000 --- a/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderSpecifyOutputFile/amd/diskFile2.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -export declare var m2_a1: number; -export declare class m2_c1 { - m2_c1_p1: number; -} -export declare var m2_instance1: m2_c1; -export declare function m2_f1(): m2_c1; diff --git a/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderSpecifyOutputFile/amd/mapRootRelativePathModuleMultifolderSpecifyOutputFile.json b/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderSpecifyOutputFile/amd/mapRootRelativePathModuleMultifolderSpecifyOutputFile.json index f3c86f22eb7..283c0703f90 100644 --- a/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderSpecifyOutputFile/amd/mapRootRelativePathModuleMultifolderSpecifyOutputFile.json +++ b/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderSpecifyOutputFile/amd/mapRootRelativePathModuleMultifolderSpecifyOutputFile.json @@ -16,15 +16,6 @@ "test.ts" ], "emittedFiles": [ - "ref/m1.js.map", - "ref/m1.js", - "ref/m1.d.ts", - "../outputdir_module_multifolder_ref/m2.js.map", - "../outputdir_module_multifolder_ref/m2.js", - "../outputdir_module_multifolder_ref/m2.d.ts", - "test.js.map", - "test.js", - "test.d.ts", "bin/test.js.map", "bin/test.js", "bin/test.d.ts" diff --git a/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderSpecifyOutputFile/amd/mapRootRelativePathModuleMultifolderSpecifyOutputFile.sourcemap.txt b/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderSpecifyOutputFile/amd/mapRootRelativePathModuleMultifolderSpecifyOutputFile.sourcemap.txt index 2cbcfa7b2ce..47e1835365a 100644 --- a/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderSpecifyOutputFile/amd/mapRootRelativePathModuleMultifolderSpecifyOutputFile.sourcemap.txt +++ b/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderSpecifyOutputFile/amd/mapRootRelativePathModuleMultifolderSpecifyOutputFile.sourcemap.txt @@ -1,573 +1,4 @@ =================================================================== -JsFile: m1.js -mapUrl: ../../../mapFiles/outputdir_module_multifolder/ref/m1.js.map -sourceRoot: -sources: ../../../projects/outputdir_module_multifolder/ref/m1.ts -=================================================================== -------------------------------------------------------------------- -emittedFile:ref/m1.js -sourceFile:../../../projects/outputdir_module_multifolder/ref/m1.ts -------------------------------------------------------------------- ->>>define(["require", "exports"], function (require, exports) { ->>> exports.m1_a1 = 10; -1 >^^^^ -2 > ^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^-> -1 >export var -2 > m1_a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(2, 5) Source(1, 12) + SourceIndex(0) -2 >Emitted(2, 18) Source(1, 17) + SourceIndex(0) -3 >Emitted(2, 21) Source(1, 20) + SourceIndex(0) -4 >Emitted(2, 23) Source(1, 22) + SourceIndex(0) -5 >Emitted(2, 24) Source(1, 23) + SourceIndex(0) ---- ->>> var m1_c1 = (function () { -1->^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^^^^-> -1-> - > -1->Emitted(3, 5) Source(2, 1) + SourceIndex(0) ---- ->>> function m1_c1() { -1->^^^^^^^^ -2 > ^^-> -1-> -1->Emitted(4, 9) Source(2, 1) + SourceIndex(0) name (m1_c1) ---- ->>> } -1->^^^^^^^^ -2 > ^ -3 > ^^^^^^^^^^^^^-> -1->export class m1_c1 { - > public m1_c1_p1: number; - > -2 > } -1->Emitted(5, 9) Source(4, 1) + SourceIndex(0) name (m1_c1.constructor) -2 >Emitted(5, 10) Source(4, 2) + SourceIndex(0) name (m1_c1.constructor) ---- ->>> return m1_c1; -1->^^^^^^^^ -2 > ^^^^^^^^^^^^ -1-> -2 > } -1->Emitted(6, 9) Source(4, 1) + SourceIndex(0) name (m1_c1) -2 >Emitted(6, 21) Source(4, 2) + SourceIndex(0) name (m1_c1) ---- ->>> })(); -1 >^^^^ -2 > ^ -3 > -4 > ^^^^ -5 > ^^^^^^^^^^^^^^^^^^-> -1 > -2 > } -3 > -4 > export class m1_c1 { - > public m1_c1_p1: number; - > } -1 >Emitted(7, 5) Source(4, 1) + SourceIndex(0) name (m1_c1) -2 >Emitted(7, 6) Source(4, 2) + SourceIndex(0) name (m1_c1) -3 >Emitted(7, 6) Source(2, 1) + SourceIndex(0) -4 >Emitted(7, 10) Source(4, 2) + SourceIndex(0) ---- ->>> exports.m1_c1 = m1_c1; -1->^^^^ -2 > ^^^^^^^^^^^^^ -3 > ^^^^^^^^ -4 > ^ -5 > ^^^^^^^^^^^^^^-> -1-> -2 > m1_c1 -3 > { - > public m1_c1_p1: number; - > } -4 > -1->Emitted(8, 5) Source(2, 14) + SourceIndex(0) -2 >Emitted(8, 18) Source(2, 19) + SourceIndex(0) -3 >Emitted(8, 26) Source(4, 2) + SourceIndex(0) -4 >Emitted(8, 27) Source(4, 2) + SourceIndex(0) ---- ->>> exports.m1_instance1 = new m1_c1(); -1->^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^^^ -5 > ^^^^^ -6 > ^^ -7 > ^ -1-> - > - >export var -2 > m1_instance1 -3 > = -4 > new -5 > m1_c1 -6 > () -7 > ; -1->Emitted(9, 5) Source(6, 12) + SourceIndex(0) -2 >Emitted(9, 25) Source(6, 24) + SourceIndex(0) -3 >Emitted(9, 28) Source(6, 27) + SourceIndex(0) -4 >Emitted(9, 32) Source(6, 31) + SourceIndex(0) -5 >Emitted(9, 37) Source(6, 36) + SourceIndex(0) -6 >Emitted(9, 39) Source(6, 38) + SourceIndex(0) -7 >Emitted(9, 40) Source(6, 39) + SourceIndex(0) ---- ->>> function m1_f1() { -1 >^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -1 >Emitted(10, 5) Source(7, 1) + SourceIndex(0) ---- ->>> return exports.m1_instance1; -1->^^^^^^^^ -2 > ^^^^^^ -3 > ^ -4 > ^^^^^^^^^^^^^^^^^^^^ -5 > ^ -1->export function m1_f1() { - > -2 > return -3 > -4 > m1_instance1 -5 > ; -1->Emitted(11, 9) Source(8, 5) + SourceIndex(0) name (m1_f1) -2 >Emitted(11, 15) Source(8, 11) + SourceIndex(0) name (m1_f1) -3 >Emitted(11, 16) Source(8, 12) + SourceIndex(0) name (m1_f1) -4 >Emitted(11, 36) Source(8, 24) + SourceIndex(0) name (m1_f1) -5 >Emitted(11, 37) Source(8, 25) + SourceIndex(0) name (m1_f1) ---- ->>> } -1 >^^^^ -2 > ^ -3 > ^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -2 > } -1 >Emitted(12, 5) Source(9, 1) + SourceIndex(0) name (m1_f1) -2 >Emitted(12, 6) Source(9, 2) + SourceIndex(0) name (m1_f1) ---- ->>> exports.m1_f1 = m1_f1; -1->^^^^ -2 > ^^^^^^^^^^^^^ -3 > ^^^^^^^^ -4 > ^ -1-> -2 > m1_f1 -3 > () { - > return m1_instance1; - > } -4 > -1->Emitted(13, 5) Source(7, 17) + SourceIndex(0) -2 >Emitted(13, 18) Source(7, 22) + SourceIndex(0) -3 >Emitted(13, 26) Source(9, 2) + SourceIndex(0) -4 >Emitted(13, 27) Source(9, 2) + SourceIndex(0) ---- ->>>}); ->>>//# sourceMappingURL=../../../mapFiles/outputdir_module_multifolder/ref/m1.js.map=================================================================== -JsFile: m2.js -mapUrl: ../../mapFiles/outputdir_module_multifolder_ref/m2.js.map -sourceRoot: -sources: ../../projects/outputdir_module_multifolder_ref/m2.ts -=================================================================== -------------------------------------------------------------------- -emittedFile:diskFile1.js -sourceFile:../../projects/outputdir_module_multifolder_ref/m2.ts -------------------------------------------------------------------- ->>>define(["require", "exports"], function (require, exports) { ->>> exports.m2_a1 = 10; -1 >^^^^ -2 > ^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^-> -1 >export var -2 > m2_a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(2, 5) Source(1, 12) + SourceIndex(0) -2 >Emitted(2, 18) Source(1, 17) + SourceIndex(0) -3 >Emitted(2, 21) Source(1, 20) + SourceIndex(0) -4 >Emitted(2, 23) Source(1, 22) + SourceIndex(0) -5 >Emitted(2, 24) Source(1, 23) + SourceIndex(0) ---- ->>> var m2_c1 = (function () { -1->^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^^^^-> -1-> - > -1->Emitted(3, 5) Source(2, 1) + SourceIndex(0) ---- ->>> function m2_c1() { -1->^^^^^^^^ -2 > ^^-> -1-> -1->Emitted(4, 9) Source(2, 1) + SourceIndex(0) name (m2_c1) ---- ->>> } -1->^^^^^^^^ -2 > ^ -3 > ^^^^^^^^^^^^^-> -1->export class m2_c1 { - > public m2_c1_p1: number; - > -2 > } -1->Emitted(5, 9) Source(4, 1) + SourceIndex(0) name (m2_c1.constructor) -2 >Emitted(5, 10) Source(4, 2) + SourceIndex(0) name (m2_c1.constructor) ---- ->>> return m2_c1; -1->^^^^^^^^ -2 > ^^^^^^^^^^^^ -1-> -2 > } -1->Emitted(6, 9) Source(4, 1) + SourceIndex(0) name (m2_c1) -2 >Emitted(6, 21) Source(4, 2) + SourceIndex(0) name (m2_c1) ---- ->>> })(); -1 >^^^^ -2 > ^ -3 > -4 > ^^^^ -5 > ^^^^^^^^^^^^^^^^^^-> -1 > -2 > } -3 > -4 > export class m2_c1 { - > public m2_c1_p1: number; - > } -1 >Emitted(7, 5) Source(4, 1) + SourceIndex(0) name (m2_c1) -2 >Emitted(7, 6) Source(4, 2) + SourceIndex(0) name (m2_c1) -3 >Emitted(7, 6) Source(2, 1) + SourceIndex(0) -4 >Emitted(7, 10) Source(4, 2) + SourceIndex(0) ---- ->>> exports.m2_c1 = m2_c1; -1->^^^^ -2 > ^^^^^^^^^^^^^ -3 > ^^^^^^^^ -4 > ^ -5 > ^^^^^^^^^^^^^^-> -1-> -2 > m2_c1 -3 > { - > public m2_c1_p1: number; - > } -4 > -1->Emitted(8, 5) Source(2, 14) + SourceIndex(0) -2 >Emitted(8, 18) Source(2, 19) + SourceIndex(0) -3 >Emitted(8, 26) Source(4, 2) + SourceIndex(0) -4 >Emitted(8, 27) Source(4, 2) + SourceIndex(0) ---- ->>> exports.m2_instance1 = new m2_c1(); -1->^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^^^ -5 > ^^^^^ -6 > ^^ -7 > ^ -1-> - > - >export var -2 > m2_instance1 -3 > = -4 > new -5 > m2_c1 -6 > () -7 > ; -1->Emitted(9, 5) Source(6, 12) + SourceIndex(0) -2 >Emitted(9, 25) Source(6, 24) + SourceIndex(0) -3 >Emitted(9, 28) Source(6, 27) + SourceIndex(0) -4 >Emitted(9, 32) Source(6, 31) + SourceIndex(0) -5 >Emitted(9, 37) Source(6, 36) + SourceIndex(0) -6 >Emitted(9, 39) Source(6, 38) + SourceIndex(0) -7 >Emitted(9, 40) Source(6, 39) + SourceIndex(0) ---- ->>> function m2_f1() { -1 >^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -1 >Emitted(10, 5) Source(7, 1) + SourceIndex(0) ---- ->>> return exports.m2_instance1; -1->^^^^^^^^ -2 > ^^^^^^ -3 > ^ -4 > ^^^^^^^^^^^^^^^^^^^^ -5 > ^ -1->export function m2_f1() { - > -2 > return -3 > -4 > m2_instance1 -5 > ; -1->Emitted(11, 9) Source(8, 5) + SourceIndex(0) name (m2_f1) -2 >Emitted(11, 15) Source(8, 11) + SourceIndex(0) name (m2_f1) -3 >Emitted(11, 16) Source(8, 12) + SourceIndex(0) name (m2_f1) -4 >Emitted(11, 36) Source(8, 24) + SourceIndex(0) name (m2_f1) -5 >Emitted(11, 37) Source(8, 25) + SourceIndex(0) name (m2_f1) ---- ->>> } -1 >^^^^ -2 > ^ -3 > ^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -2 > } -1 >Emitted(12, 5) Source(9, 1) + SourceIndex(0) name (m2_f1) -2 >Emitted(12, 6) Source(9, 2) + SourceIndex(0) name (m2_f1) ---- ->>> exports.m2_f1 = m2_f1; -1->^^^^ -2 > ^^^^^^^^^^^^^ -3 > ^^^^^^^^ -4 > ^ -1-> -2 > m2_f1 -3 > () { - > return m2_instance1; - > } -4 > -1->Emitted(13, 5) Source(7, 17) + SourceIndex(0) -2 >Emitted(13, 18) Source(7, 22) + SourceIndex(0) -3 >Emitted(13, 26) Source(9, 2) + SourceIndex(0) -4 >Emitted(13, 27) Source(9, 2) + SourceIndex(0) ---- ->>>}); ->>>//# sourceMappingURL=../../mapFiles/outputdir_module_multifolder_ref/m2.js.map=================================================================== -JsFile: test.js -mapUrl: ../../mapFiles/outputdir_module_multifolder/test.js.map -sourceRoot: -sources: ../../projects/outputdir_module_multifolder/test.ts -=================================================================== -------------------------------------------------------------------- -emittedFile:test.js -sourceFile:../../projects/outputdir_module_multifolder/test.ts -------------------------------------------------------------------- ->>>define(["require", "exports", "ref/m1", "../outputdir_module_multifolder_ref/m2"], function (require, exports, m1, m2) { ->>> exports.a1 = 10; -1 >^^^^ -2 > ^^^^^^^^^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^-> -1 >import m1 = require("ref/m1"); - >import m2 = require("../outputdir_module_multifolder_ref/m2"); - >export var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(2, 5) Source(3, 12) + SourceIndex(0) -2 >Emitted(2, 15) Source(3, 14) + SourceIndex(0) -3 >Emitted(2, 18) Source(3, 17) + SourceIndex(0) -4 >Emitted(2, 20) Source(3, 19) + SourceIndex(0) -5 >Emitted(2, 21) Source(3, 20) + SourceIndex(0) ---- ->>> var c1 = (function () { -1->^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^-> -1-> - > -1->Emitted(3, 5) Source(4, 1) + SourceIndex(0) ---- ->>> function c1() { -1->^^^^^^^^ -2 > ^^-> -1-> -1->Emitted(4, 9) Source(4, 1) + SourceIndex(0) name (c1) ---- ->>> } -1->^^^^^^^^ -2 > ^ -3 > ^^^^^^^^^^-> -1->export class c1 { - > public p1: number; - > -2 > } -1->Emitted(5, 9) Source(6, 1) + SourceIndex(0) name (c1.constructor) -2 >Emitted(5, 10) Source(6, 2) + SourceIndex(0) name (c1.constructor) ---- ->>> return c1; -1->^^^^^^^^ -2 > ^^^^^^^^^ -1-> -2 > } -1->Emitted(6, 9) Source(6, 1) + SourceIndex(0) name (c1) -2 >Emitted(6, 18) Source(6, 2) + SourceIndex(0) name (c1) ---- ->>> })(); -1 >^^^^ -2 > ^ -3 > -4 > ^^^^ -5 > ^^^^^^^^^^^^-> -1 > -2 > } -3 > -4 > export class c1 { - > public p1: number; - > } -1 >Emitted(7, 5) Source(6, 1) + SourceIndex(0) name (c1) -2 >Emitted(7, 6) Source(6, 2) + SourceIndex(0) name (c1) -3 >Emitted(7, 6) Source(4, 1) + SourceIndex(0) -4 >Emitted(7, 10) Source(6, 2) + SourceIndex(0) ---- ->>> exports.c1 = c1; -1->^^^^ -2 > ^^^^^^^^^^ -3 > ^^^^^ -4 > ^ -5 > ^^^^^^^^^^^^^^-> -1-> -2 > c1 -3 > { - > public p1: number; - > } -4 > -1->Emitted(8, 5) Source(4, 14) + SourceIndex(0) -2 >Emitted(8, 15) Source(4, 16) + SourceIndex(0) -3 >Emitted(8, 20) Source(6, 2) + SourceIndex(0) -4 >Emitted(8, 21) Source(6, 2) + SourceIndex(0) ---- ->>> exports.instance1 = new c1(); -1->^^^^ -2 > ^^^^^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^^^ -5 > ^^ -6 > ^^ -7 > ^ -1-> - > - >export var -2 > instance1 -3 > = -4 > new -5 > c1 -6 > () -7 > ; -1->Emitted(9, 5) Source(8, 12) + SourceIndex(0) -2 >Emitted(9, 22) Source(8, 21) + SourceIndex(0) -3 >Emitted(9, 25) Source(8, 24) + SourceIndex(0) -4 >Emitted(9, 29) Source(8, 28) + SourceIndex(0) -5 >Emitted(9, 31) Source(8, 30) + SourceIndex(0) -6 >Emitted(9, 33) Source(8, 32) + SourceIndex(0) -7 >Emitted(9, 34) Source(8, 33) + SourceIndex(0) ---- ->>> function f1() { -1 >^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -1 >Emitted(10, 5) Source(9, 1) + SourceIndex(0) ---- ->>> return exports.instance1; -1->^^^^^^^^ -2 > ^^^^^^ -3 > ^ -4 > ^^^^^^^^^^^^^^^^^ -5 > ^ -1->export function f1() { - > -2 > return -3 > -4 > instance1 -5 > ; -1->Emitted(11, 9) Source(10, 5) + SourceIndex(0) name (f1) -2 >Emitted(11, 15) Source(10, 11) + SourceIndex(0) name (f1) -3 >Emitted(11, 16) Source(10, 12) + SourceIndex(0) name (f1) -4 >Emitted(11, 33) Source(10, 21) + SourceIndex(0) name (f1) -5 >Emitted(11, 34) Source(10, 22) + SourceIndex(0) name (f1) ---- ->>> } -1 >^^^^ -2 > ^ -3 > ^^^^^^^^^^^^^^^^-> -1 > - > -2 > } -1 >Emitted(12, 5) Source(11, 1) + SourceIndex(0) name (f1) -2 >Emitted(12, 6) Source(11, 2) + SourceIndex(0) name (f1) ---- ->>> exports.f1 = f1; -1->^^^^ -2 > ^^^^^^^^^^ -3 > ^^^^^ -4 > ^ -5 > ^^^^^^^-> -1-> -2 > f1 -3 > () { - > return instance1; - > } -4 > -1->Emitted(13, 5) Source(9, 17) + SourceIndex(0) -2 >Emitted(13, 15) Source(9, 19) + SourceIndex(0) -3 >Emitted(13, 20) Source(11, 2) + SourceIndex(0) -4 >Emitted(13, 21) Source(11, 2) + SourceIndex(0) ---- ->>> exports.a2 = m1.m1_c1; -1->^^^^ -2 > ^^^^^^^^^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^ -7 > ^ -8 > ^-> -1-> - > - >export var -2 > a2 -3 > = -4 > m1 -5 > . -6 > m1_c1 -7 > ; -1->Emitted(14, 5) Source(13, 12) + SourceIndex(0) -2 >Emitted(14, 15) Source(13, 14) + SourceIndex(0) -3 >Emitted(14, 18) Source(13, 17) + SourceIndex(0) -4 >Emitted(14, 20) Source(13, 19) + SourceIndex(0) -5 >Emitted(14, 21) Source(13, 20) + SourceIndex(0) -6 >Emitted(14, 26) Source(13, 25) + SourceIndex(0) -7 >Emitted(14, 27) Source(13, 26) + SourceIndex(0) ---- ->>> exports.a3 = m2.m2_c1; -1->^^^^ -2 > ^^^^^^^^^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^ -7 > ^ -1-> - >export var -2 > a3 -3 > = -4 > m2 -5 > . -6 > m2_c1 -7 > ; -1->Emitted(15, 5) Source(14, 12) + SourceIndex(0) -2 >Emitted(15, 15) Source(14, 14) + SourceIndex(0) -3 >Emitted(15, 18) Source(14, 17) + SourceIndex(0) -4 >Emitted(15, 20) Source(14, 19) + SourceIndex(0) -5 >Emitted(15, 21) Source(14, 20) + SourceIndex(0) -6 >Emitted(15, 26) Source(14, 25) + SourceIndex(0) -7 >Emitted(15, 27) Source(14, 26) + SourceIndex(0) ---- ->>>}); ->>>//# sourceMappingURL=../../mapFiles/outputdir_module_multifolder/test.js.map=================================================================== JsFile: test.js mapUrl: ../../../mapFiles/test.js.map sourceRoot: diff --git a/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderSpecifyOutputFile/amd/ref/m1.d.ts b/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderSpecifyOutputFile/amd/ref/m1.d.ts deleted file mode 100644 index 4a53b24b156..00000000000 --- a/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderSpecifyOutputFile/amd/ref/m1.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -export declare var m1_a1: number; -export declare class m1_c1 { - m1_c1_p1: number; -} -export declare var m1_instance1: m1_c1; -export declare function m1_f1(): m1_c1; diff --git a/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderSpecifyOutputFile/amd/ref/m1.js b/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderSpecifyOutputFile/amd/ref/m1.js deleted file mode 100644 index 09fbf68994d..00000000000 --- a/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderSpecifyOutputFile/amd/ref/m1.js +++ /dev/null @@ -1,15 +0,0 @@ -define(["require", "exports"], function (require, exports) { - exports.m1_a1 = 10; - var m1_c1 = (function () { - function m1_c1() { - } - return m1_c1; - })(); - exports.m1_c1 = m1_c1; - exports.m1_instance1 = new m1_c1(); - function m1_f1() { - return exports.m1_instance1; - } - exports.m1_f1 = m1_f1; -}); -//# sourceMappingURL=../../../mapFiles/outputdir_module_multifolder/ref/m1.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderSpecifyOutputFile/amd/ref/m1.js.map b/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderSpecifyOutputFile/amd/ref/m1.js.map deleted file mode 100644 index e7200adafdb..00000000000 --- a/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderSpecifyOutputFile/amd/ref/m1.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"m1.js","sourceRoot":"","sources":["../../../projects/outputdir_module_multifolder/ref/m1.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1"],"mappings":";IAAW,aAAK,GAAG,EAAE,CAAC;IACtB;QAAAA;QAEAC,CAACA;QAADD,YAACA;IAADA,CAACA,AAFD,IAEC;IAFY,aAAK,QAEjB,CAAA;IAEU,oBAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACIE,MAAMA,CAACA,oBAAYA,CAACA;IACxBA,CAACA;IAFe,aAAK,QAEpB,CAAA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderSpecifyOutputFile/amd/test.d.ts b/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderSpecifyOutputFile/amd/test.d.ts deleted file mode 100644 index 4afd4e69f2d..00000000000 --- a/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderSpecifyOutputFile/amd/test.d.ts +++ /dev/null @@ -1,10 +0,0 @@ -import m1 = require("ref/m1"); -import m2 = require("../outputdir_module_multifolder_ref/m2"); -export declare var a1: number; -export declare class c1 { - p1: number; -} -export declare var instance1: c1; -export declare function f1(): c1; -export declare var a2: typeof m1.m1_c1; -export declare var a3: typeof m2.m2_c1; diff --git a/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderSpecifyOutputFile/amd/test.js b/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderSpecifyOutputFile/amd/test.js deleted file mode 100644 index 90dee0800c7..00000000000 --- a/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderSpecifyOutputFile/amd/test.js +++ /dev/null @@ -1,17 +0,0 @@ -define(["require", "exports", "ref/m1", "../outputdir_module_multifolder_ref/m2"], function (require, exports, m1, m2) { - exports.a1 = 10; - var c1 = (function () { - function c1() { - } - return c1; - })(); - exports.c1 = c1; - exports.instance1 = new c1(); - function f1() { - return exports.instance1; - } - exports.f1 = f1; - exports.a2 = m1.m1_c1; - exports.a3 = m2.m2_c1; -}); -//# sourceMappingURL=../../mapFiles/outputdir_module_multifolder/test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderSpecifyOutputFile/amd/test.js.map b/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderSpecifyOutputFile/amd/test.js.map deleted file mode 100644 index f2b1ea70110..00000000000 --- a/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderSpecifyOutputFile/amd/test.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"test.js","sourceRoot":"","sources":["../../projects/outputdir_module_multifolder/test.ts"],"names":["c1","c1.constructor","f1"],"mappings":";IAEW,UAAE,GAAG,EAAE,CAAC;IACnB;QAAAA;QAEAC,CAACA;QAADD,SAACA;IAADA,CAACA,AAFD,IAEC;IAFY,UAAE,KAEd,CAAA;IAEU,iBAAS,GAAG,IAAI,EAAE,EAAE,CAAC;IAChC;QACIE,MAAMA,CAACA,iBAASA,CAACA;IACrBA,CAACA;IAFe,UAAE,KAEjB,CAAA;IAEU,UAAE,GAAG,EAAE,CAAC,KAAK,CAAC;IACd,UAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderSpecifyOutputFile/node/diskFile0.js.map b/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderSpecifyOutputFile/node/diskFile0.js.map deleted file mode 100644 index c2ac2bc2710..00000000000 --- a/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderSpecifyOutputFile/node/diskFile0.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"m2.js","sourceRoot":"","sources":["../../projects/outputdir_module_multifolder_ref/m2.ts"],"names":["m2_c1","m2_c1.constructor","m2_f1"],"mappings":"AAAW,aAAK,GAAG,EAAE,CAAC;AACtB;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAFY,aAAK,QAEjB,CAAA;AAEU,oBAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACIE,MAAMA,CAACA,oBAAYA,CAACA;AACxBA,CAACA;AAFe,aAAK,QAEpB,CAAA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderSpecifyOutputFile/node/diskFile1.js b/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderSpecifyOutputFile/node/diskFile1.js deleted file mode 100644 index 573ce2ac6c5..00000000000 --- a/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderSpecifyOutputFile/node/diskFile1.js +++ /dev/null @@ -1,13 +0,0 @@ -exports.m2_a1 = 10; -var m2_c1 = (function () { - function m2_c1() { - } - return m2_c1; -})(); -exports.m2_c1 = m2_c1; -exports.m2_instance1 = new m2_c1(); -function m2_f1() { - return exports.m2_instance1; -} -exports.m2_f1 = m2_f1; -//# sourceMappingURL=../../mapFiles/outputdir_module_multifolder_ref/m2.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderSpecifyOutputFile/node/diskFile2.d.ts b/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderSpecifyOutputFile/node/diskFile2.d.ts deleted file mode 100644 index c09a3c0c32a..00000000000 --- a/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderSpecifyOutputFile/node/diskFile2.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -export declare var m2_a1: number; -export declare class m2_c1 { - m2_c1_p1: number; -} -export declare var m2_instance1: m2_c1; -export declare function m2_f1(): m2_c1; diff --git a/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderSpecifyOutputFile/node/mapRootRelativePathModuleMultifolderSpecifyOutputFile.json b/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderSpecifyOutputFile/node/mapRootRelativePathModuleMultifolderSpecifyOutputFile.json index f3c86f22eb7..283c0703f90 100644 --- a/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderSpecifyOutputFile/node/mapRootRelativePathModuleMultifolderSpecifyOutputFile.json +++ b/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderSpecifyOutputFile/node/mapRootRelativePathModuleMultifolderSpecifyOutputFile.json @@ -16,15 +16,6 @@ "test.ts" ], "emittedFiles": [ - "ref/m1.js.map", - "ref/m1.js", - "ref/m1.d.ts", - "../outputdir_module_multifolder_ref/m2.js.map", - "../outputdir_module_multifolder_ref/m2.js", - "../outputdir_module_multifolder_ref/m2.d.ts", - "test.js.map", - "test.js", - "test.d.ts", "bin/test.js.map", "bin/test.js", "bin/test.d.ts" diff --git a/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderSpecifyOutputFile/node/mapRootRelativePathModuleMultifolderSpecifyOutputFile.sourcemap.txt b/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderSpecifyOutputFile/node/mapRootRelativePathModuleMultifolderSpecifyOutputFile.sourcemap.txt index e020f2716f7..ce08ef2c878 100644 --- a/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderSpecifyOutputFile/node/mapRootRelativePathModuleMultifolderSpecifyOutputFile.sourcemap.txt +++ b/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderSpecifyOutputFile/node/mapRootRelativePathModuleMultifolderSpecifyOutputFile.sourcemap.txt @@ -1,617 +1,4 @@ =================================================================== -JsFile: m1.js -mapUrl: ../../../mapFiles/outputdir_module_multifolder/ref/m1.js.map -sourceRoot: -sources: ../../../projects/outputdir_module_multifolder/ref/m1.ts -=================================================================== -------------------------------------------------------------------- -emittedFile:ref/m1.js -sourceFile:../../../projects/outputdir_module_multifolder/ref/m1.ts -------------------------------------------------------------------- ->>>exports.m1_a1 = 10; -1 > -2 >^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^-> -1 >export var -2 >m1_a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(1, 1) Source(1, 12) + SourceIndex(0) -2 >Emitted(1, 14) Source(1, 17) + SourceIndex(0) -3 >Emitted(1, 17) Source(1, 20) + SourceIndex(0) -4 >Emitted(1, 19) Source(1, 22) + SourceIndex(0) -5 >Emitted(1, 20) Source(1, 23) + SourceIndex(0) ---- ->>>var m1_c1 = (function () { -1-> -2 >^^^^^^^^^^^^^^^^^^^^^^^-> -1-> - > -1->Emitted(2, 1) Source(2, 1) + SourceIndex(0) ---- ->>> function m1_c1() { -1->^^^^ -2 > ^^-> -1-> -1->Emitted(3, 5) Source(2, 1) + SourceIndex(0) name (m1_c1) ---- ->>> } -1->^^^^ -2 > ^ -3 > ^^^^^^^^^^^^^-> -1->export class m1_c1 { - > public m1_c1_p1: number; - > -2 > } -1->Emitted(4, 5) Source(4, 1) + SourceIndex(0) name (m1_c1.constructor) -2 >Emitted(4, 6) Source(4, 2) + SourceIndex(0) name (m1_c1.constructor) ---- ->>> return m1_c1; -1->^^^^ -2 > ^^^^^^^^^^^^ -1-> -2 > } -1->Emitted(5, 5) Source(4, 1) + SourceIndex(0) name (m1_c1) -2 >Emitted(5, 17) Source(4, 2) + SourceIndex(0) name (m1_c1) ---- ->>>})(); -1 > -2 >^ -3 > -4 > ^^^^ -5 > ^^^^^^^^^^^^^^^^^^-> -1 > -2 >} -3 > -4 > export class m1_c1 { - > public m1_c1_p1: number; - > } -1 >Emitted(6, 1) Source(4, 1) + SourceIndex(0) name (m1_c1) -2 >Emitted(6, 2) Source(4, 2) + SourceIndex(0) name (m1_c1) -3 >Emitted(6, 2) Source(2, 1) + SourceIndex(0) -4 >Emitted(6, 6) Source(4, 2) + SourceIndex(0) ---- ->>>exports.m1_c1 = m1_c1; -1-> -2 >^^^^^^^^^^^^^ -3 > ^^^^^^^^ -4 > ^ -5 > ^^^^^^^^^^^^^^-> -1-> -2 >m1_c1 -3 > { - > public m1_c1_p1: number; - > } -4 > -1->Emitted(7, 1) Source(2, 14) + SourceIndex(0) -2 >Emitted(7, 14) Source(2, 19) + SourceIndex(0) -3 >Emitted(7, 22) Source(4, 2) + SourceIndex(0) -4 >Emitted(7, 23) Source(4, 2) + SourceIndex(0) ---- ->>>exports.m1_instance1 = new m1_c1(); -1-> -2 >^^^^^^^^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^^^ -5 > ^^^^^ -6 > ^^ -7 > ^ -1-> - > - >export var -2 >m1_instance1 -3 > = -4 > new -5 > m1_c1 -6 > () -7 > ; -1->Emitted(8, 1) Source(6, 12) + SourceIndex(0) -2 >Emitted(8, 21) Source(6, 24) + SourceIndex(0) -3 >Emitted(8, 24) Source(6, 27) + SourceIndex(0) -4 >Emitted(8, 28) Source(6, 31) + SourceIndex(0) -5 >Emitted(8, 33) Source(6, 36) + SourceIndex(0) -6 >Emitted(8, 35) Source(6, 38) + SourceIndex(0) -7 >Emitted(8, 36) Source(6, 39) + SourceIndex(0) ---- ->>>function m1_f1() { -1 > -2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -1 >Emitted(9, 1) Source(7, 1) + SourceIndex(0) ---- ->>> return exports.m1_instance1; -1->^^^^ -2 > ^^^^^^ -3 > ^ -4 > ^^^^^^^^^^^^^^^^^^^^ -5 > ^ -1->export function m1_f1() { - > -2 > return -3 > -4 > m1_instance1 -5 > ; -1->Emitted(10, 5) Source(8, 5) + SourceIndex(0) name (m1_f1) -2 >Emitted(10, 11) Source(8, 11) + SourceIndex(0) name (m1_f1) -3 >Emitted(10, 12) Source(8, 12) + SourceIndex(0) name (m1_f1) -4 >Emitted(10, 32) Source(8, 24) + SourceIndex(0) name (m1_f1) -5 >Emitted(10, 33) Source(8, 25) + SourceIndex(0) name (m1_f1) ---- ->>>} -1 > -2 >^ -3 > ^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -2 >} -1 >Emitted(11, 1) Source(9, 1) + SourceIndex(0) name (m1_f1) -2 >Emitted(11, 2) Source(9, 2) + SourceIndex(0) name (m1_f1) ---- ->>>exports.m1_f1 = m1_f1; -1-> -2 >^^^^^^^^^^^^^ -3 > ^^^^^^^^ -4 > ^ -5 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1-> -2 >m1_f1 -3 > () { - > return m1_instance1; - > } -4 > -1->Emitted(12, 1) Source(7, 17) + SourceIndex(0) -2 >Emitted(12, 14) Source(7, 22) + SourceIndex(0) -3 >Emitted(12, 22) Source(9, 2) + SourceIndex(0) -4 >Emitted(12, 23) Source(9, 2) + SourceIndex(0) ---- ->>>//# sourceMappingURL=../../../mapFiles/outputdir_module_multifolder/ref/m1.js.map=================================================================== -JsFile: m2.js -mapUrl: ../../mapFiles/outputdir_module_multifolder_ref/m2.js.map -sourceRoot: -sources: ../../projects/outputdir_module_multifolder_ref/m2.ts -=================================================================== -------------------------------------------------------------------- -emittedFile:diskFile1.js -sourceFile:../../projects/outputdir_module_multifolder_ref/m2.ts -------------------------------------------------------------------- ->>>exports.m2_a1 = 10; -1 > -2 >^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^-> -1 >export var -2 >m2_a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(1, 1) Source(1, 12) + SourceIndex(0) -2 >Emitted(1, 14) Source(1, 17) + SourceIndex(0) -3 >Emitted(1, 17) Source(1, 20) + SourceIndex(0) -4 >Emitted(1, 19) Source(1, 22) + SourceIndex(0) -5 >Emitted(1, 20) Source(1, 23) + SourceIndex(0) ---- ->>>var m2_c1 = (function () { -1-> -2 >^^^^^^^^^^^^^^^^^^^^^^^-> -1-> - > -1->Emitted(2, 1) Source(2, 1) + SourceIndex(0) ---- ->>> function m2_c1() { -1->^^^^ -2 > ^^-> -1-> -1->Emitted(3, 5) Source(2, 1) + SourceIndex(0) name (m2_c1) ---- ->>> } -1->^^^^ -2 > ^ -3 > ^^^^^^^^^^^^^-> -1->export class m2_c1 { - > public m2_c1_p1: number; - > -2 > } -1->Emitted(4, 5) Source(4, 1) + SourceIndex(0) name (m2_c1.constructor) -2 >Emitted(4, 6) Source(4, 2) + SourceIndex(0) name (m2_c1.constructor) ---- ->>> return m2_c1; -1->^^^^ -2 > ^^^^^^^^^^^^ -1-> -2 > } -1->Emitted(5, 5) Source(4, 1) + SourceIndex(0) name (m2_c1) -2 >Emitted(5, 17) Source(4, 2) + SourceIndex(0) name (m2_c1) ---- ->>>})(); -1 > -2 >^ -3 > -4 > ^^^^ -5 > ^^^^^^^^^^^^^^^^^^-> -1 > -2 >} -3 > -4 > export class m2_c1 { - > public m2_c1_p1: number; - > } -1 >Emitted(6, 1) Source(4, 1) + SourceIndex(0) name (m2_c1) -2 >Emitted(6, 2) Source(4, 2) + SourceIndex(0) name (m2_c1) -3 >Emitted(6, 2) Source(2, 1) + SourceIndex(0) -4 >Emitted(6, 6) Source(4, 2) + SourceIndex(0) ---- ->>>exports.m2_c1 = m2_c1; -1-> -2 >^^^^^^^^^^^^^ -3 > ^^^^^^^^ -4 > ^ -5 > ^^^^^^^^^^^^^^-> -1-> -2 >m2_c1 -3 > { - > public m2_c1_p1: number; - > } -4 > -1->Emitted(7, 1) Source(2, 14) + SourceIndex(0) -2 >Emitted(7, 14) Source(2, 19) + SourceIndex(0) -3 >Emitted(7, 22) Source(4, 2) + SourceIndex(0) -4 >Emitted(7, 23) Source(4, 2) + SourceIndex(0) ---- ->>>exports.m2_instance1 = new m2_c1(); -1-> -2 >^^^^^^^^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^^^ -5 > ^^^^^ -6 > ^^ -7 > ^ -1-> - > - >export var -2 >m2_instance1 -3 > = -4 > new -5 > m2_c1 -6 > () -7 > ; -1->Emitted(8, 1) Source(6, 12) + SourceIndex(0) -2 >Emitted(8, 21) Source(6, 24) + SourceIndex(0) -3 >Emitted(8, 24) Source(6, 27) + SourceIndex(0) -4 >Emitted(8, 28) Source(6, 31) + SourceIndex(0) -5 >Emitted(8, 33) Source(6, 36) + SourceIndex(0) -6 >Emitted(8, 35) Source(6, 38) + SourceIndex(0) -7 >Emitted(8, 36) Source(6, 39) + SourceIndex(0) ---- ->>>function m2_f1() { -1 > -2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -1 >Emitted(9, 1) Source(7, 1) + SourceIndex(0) ---- ->>> return exports.m2_instance1; -1->^^^^ -2 > ^^^^^^ -3 > ^ -4 > ^^^^^^^^^^^^^^^^^^^^ -5 > ^ -1->export function m2_f1() { - > -2 > return -3 > -4 > m2_instance1 -5 > ; -1->Emitted(10, 5) Source(8, 5) + SourceIndex(0) name (m2_f1) -2 >Emitted(10, 11) Source(8, 11) + SourceIndex(0) name (m2_f1) -3 >Emitted(10, 12) Source(8, 12) + SourceIndex(0) name (m2_f1) -4 >Emitted(10, 32) Source(8, 24) + SourceIndex(0) name (m2_f1) -5 >Emitted(10, 33) Source(8, 25) + SourceIndex(0) name (m2_f1) ---- ->>>} -1 > -2 >^ -3 > ^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -2 >} -1 >Emitted(11, 1) Source(9, 1) + SourceIndex(0) name (m2_f1) -2 >Emitted(11, 2) Source(9, 2) + SourceIndex(0) name (m2_f1) ---- ->>>exports.m2_f1 = m2_f1; -1-> -2 >^^^^^^^^^^^^^ -3 > ^^^^^^^^ -4 > ^ -5 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1-> -2 >m2_f1 -3 > () { - > return m2_instance1; - > } -4 > -1->Emitted(12, 1) Source(7, 17) + SourceIndex(0) -2 >Emitted(12, 14) Source(7, 22) + SourceIndex(0) -3 >Emitted(12, 22) Source(9, 2) + SourceIndex(0) -4 >Emitted(12, 23) Source(9, 2) + SourceIndex(0) ---- ->>>//# sourceMappingURL=../../mapFiles/outputdir_module_multifolder_ref/m2.js.map=================================================================== -JsFile: test.js -mapUrl: ../../mapFiles/outputdir_module_multifolder/test.js.map -sourceRoot: -sources: ../../projects/outputdir_module_multifolder/test.ts -=================================================================== -------------------------------------------------------------------- -emittedFile:test.js -sourceFile:../../projects/outputdir_module_multifolder/test.ts -------------------------------------------------------------------- ->>>var m1 = require("ref/m1"); -1 > -2 >^^^^ -3 > ^^ -4 > ^^^^^^^^^^^ -5 > ^^^^^^^^ -6 > ^ -7 > ^ -8 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 > -2 >import -3 > m1 -4 > = require( -5 > "ref/m1" -6 > ) -7 > ; -1 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) -2 >Emitted(1, 5) Source(1, 8) + SourceIndex(0) -3 >Emitted(1, 7) Source(1, 10) + SourceIndex(0) -4 >Emitted(1, 18) Source(1, 21) + SourceIndex(0) -5 >Emitted(1, 26) Source(1, 29) + SourceIndex(0) -6 >Emitted(1, 27) Source(1, 30) + SourceIndex(0) -7 >Emitted(1, 28) Source(1, 31) + SourceIndex(0) ---- ->>>var m2 = require("../outputdir_module_multifolder_ref/m2"); -1-> -2 >^^^^ -3 > ^^ -4 > ^^^^^^^^^^^ -5 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -6 > ^ -7 > ^ -1-> - > -2 >import -3 > m2 -4 > = require( -5 > "../outputdir_module_multifolder_ref/m2" -6 > ) -7 > ; -1->Emitted(2, 1) Source(2, 1) + SourceIndex(0) -2 >Emitted(2, 5) Source(2, 8) + SourceIndex(0) -3 >Emitted(2, 7) Source(2, 10) + SourceIndex(0) -4 >Emitted(2, 18) Source(2, 21) + SourceIndex(0) -5 >Emitted(2, 58) Source(2, 61) + SourceIndex(0) -6 >Emitted(2, 59) Source(2, 62) + SourceIndex(0) -7 >Emitted(2, 60) Source(2, 63) + SourceIndex(0) ---- ->>>exports.a1 = 10; -1 > -2 >^^^^^^^^^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^-> -1 > - >export var -2 >a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(3, 1) Source(3, 12) + SourceIndex(0) -2 >Emitted(3, 11) Source(3, 14) + SourceIndex(0) -3 >Emitted(3, 14) Source(3, 17) + SourceIndex(0) -4 >Emitted(3, 16) Source(3, 19) + SourceIndex(0) -5 >Emitted(3, 17) Source(3, 20) + SourceIndex(0) ---- ->>>var c1 = (function () { -1-> -2 >^^^^^^^^^^^^^^^^^^^^-> -1-> - > -1->Emitted(4, 1) Source(4, 1) + SourceIndex(0) ---- ->>> function c1() { -1->^^^^ -2 > ^^-> -1-> -1->Emitted(5, 5) Source(4, 1) + SourceIndex(0) name (c1) ---- ->>> } -1->^^^^ -2 > ^ -3 > ^^^^^^^^^^-> -1->export class c1 { - > public p1: number; - > -2 > } -1->Emitted(6, 5) Source(6, 1) + SourceIndex(0) name (c1.constructor) -2 >Emitted(6, 6) Source(6, 2) + SourceIndex(0) name (c1.constructor) ---- ->>> return c1; -1->^^^^ -2 > ^^^^^^^^^ -1-> -2 > } -1->Emitted(7, 5) Source(6, 1) + SourceIndex(0) name (c1) -2 >Emitted(7, 14) Source(6, 2) + SourceIndex(0) name (c1) ---- ->>>})(); -1 > -2 >^ -3 > -4 > ^^^^ -5 > ^^^^^^^^^^^^-> -1 > -2 >} -3 > -4 > export class c1 { - > public p1: number; - > } -1 >Emitted(8, 1) Source(6, 1) + SourceIndex(0) name (c1) -2 >Emitted(8, 2) Source(6, 2) + SourceIndex(0) name (c1) -3 >Emitted(8, 2) Source(4, 1) + SourceIndex(0) -4 >Emitted(8, 6) Source(6, 2) + SourceIndex(0) ---- ->>>exports.c1 = c1; -1-> -2 >^^^^^^^^^^ -3 > ^^^^^ -4 > ^ -5 > ^^^^^^^^^^^^^^-> -1-> -2 >c1 -3 > { - > public p1: number; - > } -4 > -1->Emitted(9, 1) Source(4, 14) + SourceIndex(0) -2 >Emitted(9, 11) Source(4, 16) + SourceIndex(0) -3 >Emitted(9, 16) Source(6, 2) + SourceIndex(0) -4 >Emitted(9, 17) Source(6, 2) + SourceIndex(0) ---- ->>>exports.instance1 = new c1(); -1-> -2 >^^^^^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^^^ -5 > ^^ -6 > ^^ -7 > ^ -1-> - > - >export var -2 >instance1 -3 > = -4 > new -5 > c1 -6 > () -7 > ; -1->Emitted(10, 1) Source(8, 12) + SourceIndex(0) -2 >Emitted(10, 18) Source(8, 21) + SourceIndex(0) -3 >Emitted(10, 21) Source(8, 24) + SourceIndex(0) -4 >Emitted(10, 25) Source(8, 28) + SourceIndex(0) -5 >Emitted(10, 27) Source(8, 30) + SourceIndex(0) -6 >Emitted(10, 29) Source(8, 32) + SourceIndex(0) -7 >Emitted(10, 30) Source(8, 33) + SourceIndex(0) ---- ->>>function f1() { -1 > -2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -1 >Emitted(11, 1) Source(9, 1) + SourceIndex(0) ---- ->>> return exports.instance1; -1->^^^^ -2 > ^^^^^^ -3 > ^ -4 > ^^^^^^^^^^^^^^^^^ -5 > ^ -1->export function f1() { - > -2 > return -3 > -4 > instance1 -5 > ; -1->Emitted(12, 5) Source(10, 5) + SourceIndex(0) name (f1) -2 >Emitted(12, 11) Source(10, 11) + SourceIndex(0) name (f1) -3 >Emitted(12, 12) Source(10, 12) + SourceIndex(0) name (f1) -4 >Emitted(12, 29) Source(10, 21) + SourceIndex(0) name (f1) -5 >Emitted(12, 30) Source(10, 22) + SourceIndex(0) name (f1) ---- ->>>} -1 > -2 >^ -3 > ^^^^^^^^^^^^^^^^-> -1 > - > -2 >} -1 >Emitted(13, 1) Source(11, 1) + SourceIndex(0) name (f1) -2 >Emitted(13, 2) Source(11, 2) + SourceIndex(0) name (f1) ---- ->>>exports.f1 = f1; -1-> -2 >^^^^^^^^^^ -3 > ^^^^^ -4 > ^ -5 > ^^^^^^^-> -1-> -2 >f1 -3 > () { - > return instance1; - > } -4 > -1->Emitted(14, 1) Source(9, 17) + SourceIndex(0) -2 >Emitted(14, 11) Source(9, 19) + SourceIndex(0) -3 >Emitted(14, 16) Source(11, 2) + SourceIndex(0) -4 >Emitted(14, 17) Source(11, 2) + SourceIndex(0) ---- ->>>exports.a2 = m1.m1_c1; -1-> -2 >^^^^^^^^^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^ -7 > ^ -8 > ^-> -1-> - > - >export var -2 >a2 -3 > = -4 > m1 -5 > . -6 > m1_c1 -7 > ; -1->Emitted(15, 1) Source(13, 12) + SourceIndex(0) -2 >Emitted(15, 11) Source(13, 14) + SourceIndex(0) -3 >Emitted(15, 14) Source(13, 17) + SourceIndex(0) -4 >Emitted(15, 16) Source(13, 19) + SourceIndex(0) -5 >Emitted(15, 17) Source(13, 20) + SourceIndex(0) -6 >Emitted(15, 22) Source(13, 25) + SourceIndex(0) -7 >Emitted(15, 23) Source(13, 26) + SourceIndex(0) ---- ->>>exports.a3 = m2.m2_c1; -1-> -2 >^^^^^^^^^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^ -7 > ^ -8 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1-> - >export var -2 >a3 -3 > = -4 > m2 -5 > . -6 > m2_c1 -7 > ; -1->Emitted(16, 1) Source(14, 12) + SourceIndex(0) -2 >Emitted(16, 11) Source(14, 14) + SourceIndex(0) -3 >Emitted(16, 14) Source(14, 17) + SourceIndex(0) -4 >Emitted(16, 16) Source(14, 19) + SourceIndex(0) -5 >Emitted(16, 17) Source(14, 20) + SourceIndex(0) -6 >Emitted(16, 22) Source(14, 25) + SourceIndex(0) -7 >Emitted(16, 23) Source(14, 26) + SourceIndex(0) ---- ->>>//# sourceMappingURL=../../mapFiles/outputdir_module_multifolder/test.js.map=================================================================== JsFile: test.js mapUrl: ../../../mapFiles/test.js.map sourceRoot: diff --git a/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderSpecifyOutputFile/node/ref/m1.d.ts b/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderSpecifyOutputFile/node/ref/m1.d.ts deleted file mode 100644 index 4a53b24b156..00000000000 --- a/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderSpecifyOutputFile/node/ref/m1.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -export declare var m1_a1: number; -export declare class m1_c1 { - m1_c1_p1: number; -} -export declare var m1_instance1: m1_c1; -export declare function m1_f1(): m1_c1; diff --git a/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderSpecifyOutputFile/node/ref/m1.js b/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderSpecifyOutputFile/node/ref/m1.js deleted file mode 100644 index 87f1f3a51b7..00000000000 --- a/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderSpecifyOutputFile/node/ref/m1.js +++ /dev/null @@ -1,13 +0,0 @@ -exports.m1_a1 = 10; -var m1_c1 = (function () { - function m1_c1() { - } - return m1_c1; -})(); -exports.m1_c1 = m1_c1; -exports.m1_instance1 = new m1_c1(); -function m1_f1() { - return exports.m1_instance1; -} -exports.m1_f1 = m1_f1; -//# sourceMappingURL=../../../mapFiles/outputdir_module_multifolder/ref/m1.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderSpecifyOutputFile/node/ref/m1.js.map b/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderSpecifyOutputFile/node/ref/m1.js.map deleted file mode 100644 index 074ab743af3..00000000000 --- a/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderSpecifyOutputFile/node/ref/m1.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"m1.js","sourceRoot":"","sources":["../../../projects/outputdir_module_multifolder/ref/m1.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1"],"mappings":"AAAW,aAAK,GAAG,EAAE,CAAC;AACtB;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAFY,aAAK,QAEjB,CAAA;AAEU,oBAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACIE,MAAMA,CAACA,oBAAYA,CAACA;AACxBA,CAACA;AAFe,aAAK,QAEpB,CAAA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderSpecifyOutputFile/node/test.d.ts b/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderSpecifyOutputFile/node/test.d.ts deleted file mode 100644 index 4afd4e69f2d..00000000000 --- a/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderSpecifyOutputFile/node/test.d.ts +++ /dev/null @@ -1,10 +0,0 @@ -import m1 = require("ref/m1"); -import m2 = require("../outputdir_module_multifolder_ref/m2"); -export declare var a1: number; -export declare class c1 { - p1: number; -} -export declare var instance1: c1; -export declare function f1(): c1; -export declare var a2: typeof m1.m1_c1; -export declare var a3: typeof m2.m2_c1; diff --git a/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderSpecifyOutputFile/node/test.js b/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderSpecifyOutputFile/node/test.js deleted file mode 100644 index 6e2fb8d7851..00000000000 --- a/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderSpecifyOutputFile/node/test.js +++ /dev/null @@ -1,17 +0,0 @@ -var m1 = require("ref/m1"); -var m2 = require("../outputdir_module_multifolder_ref/m2"); -exports.a1 = 10; -var c1 = (function () { - function c1() { - } - return c1; -})(); -exports.c1 = c1; -exports.instance1 = new c1(); -function f1() { - return exports.instance1; -} -exports.f1 = f1; -exports.a2 = m1.m1_c1; -exports.a3 = m2.m2_c1; -//# sourceMappingURL=../../mapFiles/outputdir_module_multifolder/test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderSpecifyOutputFile/node/test.js.map b/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderSpecifyOutputFile/node/test.js.map deleted file mode 100644 index 85da8e39421..00000000000 --- a/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderSpecifyOutputFile/node/test.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"test.js","sourceRoot":"","sources":["../../projects/outputdir_module_multifolder/test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AAAA,IAAO,EAAE,WAAW,QAAQ,CAAC,CAAC;AAC9B,IAAO,EAAE,WAAW,wCAAwC,CAAC,CAAC;AACnD,UAAE,GAAG,EAAE,CAAC;AACnB;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAFY,UAAE,KAEd,CAAA;AAEU,iBAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AAChC;IACIE,MAAMA,CAACA,iBAASA,CAACA;AACrBA,CAACA;AAFe,UAAE,KAEjB,CAAA;AAEU,UAAE,GAAG,EAAE,CAAC,KAAK,CAAC;AACd,UAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootRelativePathModuleSimpleSpecifyOutputFile/amd/m1.d.ts b/tests/baselines/reference/project/mapRootRelativePathModuleSimpleSpecifyOutputFile/amd/m1.d.ts deleted file mode 100644 index 4a53b24b156..00000000000 --- a/tests/baselines/reference/project/mapRootRelativePathModuleSimpleSpecifyOutputFile/amd/m1.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -export declare var m1_a1: number; -export declare class m1_c1 { - m1_c1_p1: number; -} -export declare var m1_instance1: m1_c1; -export declare function m1_f1(): m1_c1; diff --git a/tests/baselines/reference/project/mapRootRelativePathModuleSimpleSpecifyOutputFile/amd/m1.js b/tests/baselines/reference/project/mapRootRelativePathModuleSimpleSpecifyOutputFile/amd/m1.js deleted file mode 100644 index 1fe3446e4bc..00000000000 --- a/tests/baselines/reference/project/mapRootRelativePathModuleSimpleSpecifyOutputFile/amd/m1.js +++ /dev/null @@ -1,15 +0,0 @@ -define(["require", "exports"], function (require, exports) { - exports.m1_a1 = 10; - var m1_c1 = (function () { - function m1_c1() { - } - return m1_c1; - })(); - exports.m1_c1 = m1_c1; - exports.m1_instance1 = new m1_c1(); - function m1_f1() { - return exports.m1_instance1; - } - exports.m1_f1 = m1_f1; -}); -//# sourceMappingURL=../mapFiles/m1.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootRelativePathModuleSimpleSpecifyOutputFile/amd/m1.js.map b/tests/baselines/reference/project/mapRootRelativePathModuleSimpleSpecifyOutputFile/amd/m1.js.map deleted file mode 100644 index e2625035edb..00000000000 --- a/tests/baselines/reference/project/mapRootRelativePathModuleSimpleSpecifyOutputFile/amd/m1.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"m1.js","sourceRoot":"","sources":["../outputdir_module_simple/m1.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1"],"mappings":";IAAW,aAAK,GAAG,EAAE,CAAC;IACtB;QAAAA;QAEAC,CAACA;QAADD,YAACA;IAADA,CAACA,AAFD,IAEC;IAFY,aAAK,QAEjB,CAAA;IAEU,oBAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACIE,MAAMA,CAACA,oBAAYA,CAACA;IACxBA,CAACA;IAFe,aAAK,QAEpB,CAAA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootRelativePathModuleSimpleSpecifyOutputFile/amd/mapRootRelativePathModuleSimpleSpecifyOutputFile.json b/tests/baselines/reference/project/mapRootRelativePathModuleSimpleSpecifyOutputFile/amd/mapRootRelativePathModuleSimpleSpecifyOutputFile.json index fe0b8045a5c..b4efe9ebb39 100644 --- a/tests/baselines/reference/project/mapRootRelativePathModuleSimpleSpecifyOutputFile/amd/mapRootRelativePathModuleSimpleSpecifyOutputFile.json +++ b/tests/baselines/reference/project/mapRootRelativePathModuleSimpleSpecifyOutputFile/amd/mapRootRelativePathModuleSimpleSpecifyOutputFile.json @@ -15,12 +15,6 @@ "test.ts" ], "emittedFiles": [ - "m1.js.map", - "m1.js", - "m1.d.ts", - "test.js.map", - "test.js", - "test.d.ts", "bin/test.js.map", "bin/test.js", "bin/test.d.ts" diff --git a/tests/baselines/reference/project/mapRootRelativePathModuleSimpleSpecifyOutputFile/amd/mapRootRelativePathModuleSimpleSpecifyOutputFile.sourcemap.txt b/tests/baselines/reference/project/mapRootRelativePathModuleSimpleSpecifyOutputFile/amd/mapRootRelativePathModuleSimpleSpecifyOutputFile.sourcemap.txt index 8a95e1100a5..8099c2f176a 100644 --- a/tests/baselines/reference/project/mapRootRelativePathModuleSimpleSpecifyOutputFile/amd/mapRootRelativePathModuleSimpleSpecifyOutputFile.sourcemap.txt +++ b/tests/baselines/reference/project/mapRootRelativePathModuleSimpleSpecifyOutputFile/amd/mapRootRelativePathModuleSimpleSpecifyOutputFile.sourcemap.txt @@ -1,375 +1,4 @@ =================================================================== -JsFile: m1.js -mapUrl: ../mapFiles/m1.js.map -sourceRoot: -sources: ../outputdir_module_simple/m1.ts -=================================================================== -------------------------------------------------------------------- -emittedFile:m1.js -sourceFile:../outputdir_module_simple/m1.ts -------------------------------------------------------------------- ->>>define(["require", "exports"], function (require, exports) { ->>> exports.m1_a1 = 10; -1 >^^^^ -2 > ^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^-> -1 >export var -2 > m1_a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(2, 5) Source(1, 12) + SourceIndex(0) -2 >Emitted(2, 18) Source(1, 17) + SourceIndex(0) -3 >Emitted(2, 21) Source(1, 20) + SourceIndex(0) -4 >Emitted(2, 23) Source(1, 22) + SourceIndex(0) -5 >Emitted(2, 24) Source(1, 23) + SourceIndex(0) ---- ->>> var m1_c1 = (function () { -1->^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^^^^-> -1-> - > -1->Emitted(3, 5) Source(2, 1) + SourceIndex(0) ---- ->>> function m1_c1() { -1->^^^^^^^^ -2 > ^^-> -1-> -1->Emitted(4, 9) Source(2, 1) + SourceIndex(0) name (m1_c1) ---- ->>> } -1->^^^^^^^^ -2 > ^ -3 > ^^^^^^^^^^^^^-> -1->export class m1_c1 { - > public m1_c1_p1: number; - > -2 > } -1->Emitted(5, 9) Source(4, 1) + SourceIndex(0) name (m1_c1.constructor) -2 >Emitted(5, 10) Source(4, 2) + SourceIndex(0) name (m1_c1.constructor) ---- ->>> return m1_c1; -1->^^^^^^^^ -2 > ^^^^^^^^^^^^ -1-> -2 > } -1->Emitted(6, 9) Source(4, 1) + SourceIndex(0) name (m1_c1) -2 >Emitted(6, 21) Source(4, 2) + SourceIndex(0) name (m1_c1) ---- ->>> })(); -1 >^^^^ -2 > ^ -3 > -4 > ^^^^ -5 > ^^^^^^^^^^^^^^^^^^-> -1 > -2 > } -3 > -4 > export class m1_c1 { - > public m1_c1_p1: number; - > } -1 >Emitted(7, 5) Source(4, 1) + SourceIndex(0) name (m1_c1) -2 >Emitted(7, 6) Source(4, 2) + SourceIndex(0) name (m1_c1) -3 >Emitted(7, 6) Source(2, 1) + SourceIndex(0) -4 >Emitted(7, 10) Source(4, 2) + SourceIndex(0) ---- ->>> exports.m1_c1 = m1_c1; -1->^^^^ -2 > ^^^^^^^^^^^^^ -3 > ^^^^^^^^ -4 > ^ -5 > ^^^^^^^^^^^^^^-> -1-> -2 > m1_c1 -3 > { - > public m1_c1_p1: number; - > } -4 > -1->Emitted(8, 5) Source(2, 14) + SourceIndex(0) -2 >Emitted(8, 18) Source(2, 19) + SourceIndex(0) -3 >Emitted(8, 26) Source(4, 2) + SourceIndex(0) -4 >Emitted(8, 27) Source(4, 2) + SourceIndex(0) ---- ->>> exports.m1_instance1 = new m1_c1(); -1->^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^^^ -5 > ^^^^^ -6 > ^^ -7 > ^ -1-> - > - >export var -2 > m1_instance1 -3 > = -4 > new -5 > m1_c1 -6 > () -7 > ; -1->Emitted(9, 5) Source(6, 12) + SourceIndex(0) -2 >Emitted(9, 25) Source(6, 24) + SourceIndex(0) -3 >Emitted(9, 28) Source(6, 27) + SourceIndex(0) -4 >Emitted(9, 32) Source(6, 31) + SourceIndex(0) -5 >Emitted(9, 37) Source(6, 36) + SourceIndex(0) -6 >Emitted(9, 39) Source(6, 38) + SourceIndex(0) -7 >Emitted(9, 40) Source(6, 39) + SourceIndex(0) ---- ->>> function m1_f1() { -1 >^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -1 >Emitted(10, 5) Source(7, 1) + SourceIndex(0) ---- ->>> return exports.m1_instance1; -1->^^^^^^^^ -2 > ^^^^^^ -3 > ^ -4 > ^^^^^^^^^^^^^^^^^^^^ -5 > ^ -1->export function m1_f1() { - > -2 > return -3 > -4 > m1_instance1 -5 > ; -1->Emitted(11, 9) Source(8, 5) + SourceIndex(0) name (m1_f1) -2 >Emitted(11, 15) Source(8, 11) + SourceIndex(0) name (m1_f1) -3 >Emitted(11, 16) Source(8, 12) + SourceIndex(0) name (m1_f1) -4 >Emitted(11, 36) Source(8, 24) + SourceIndex(0) name (m1_f1) -5 >Emitted(11, 37) Source(8, 25) + SourceIndex(0) name (m1_f1) ---- ->>> } -1 >^^^^ -2 > ^ -3 > ^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -2 > } -1 >Emitted(12, 5) Source(9, 1) + SourceIndex(0) name (m1_f1) -2 >Emitted(12, 6) Source(9, 2) + SourceIndex(0) name (m1_f1) ---- ->>> exports.m1_f1 = m1_f1; -1->^^^^ -2 > ^^^^^^^^^^^^^ -3 > ^^^^^^^^ -4 > ^ -1-> -2 > m1_f1 -3 > () { - > return m1_instance1; - > } -4 > -1->Emitted(13, 5) Source(7, 17) + SourceIndex(0) -2 >Emitted(13, 18) Source(7, 22) + SourceIndex(0) -3 >Emitted(13, 26) Source(9, 2) + SourceIndex(0) -4 >Emitted(13, 27) Source(9, 2) + SourceIndex(0) ---- ->>>}); ->>>//# sourceMappingURL=../mapFiles/m1.js.map=================================================================== -JsFile: test.js -mapUrl: ../mapFiles/test.js.map -sourceRoot: -sources: ../outputdir_module_simple/test.ts -=================================================================== -------------------------------------------------------------------- -emittedFile:test.js -sourceFile:../outputdir_module_simple/test.ts -------------------------------------------------------------------- ->>>define(["require", "exports", "m1"], function (require, exports, m1) { ->>> exports.a1 = 10; -1 >^^^^ -2 > ^^^^^^^^^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^-> -1 >import m1 = require("m1"); - >export var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(2, 5) Source(2, 12) + SourceIndex(0) -2 >Emitted(2, 15) Source(2, 14) + SourceIndex(0) -3 >Emitted(2, 18) Source(2, 17) + SourceIndex(0) -4 >Emitted(2, 20) Source(2, 19) + SourceIndex(0) -5 >Emitted(2, 21) Source(2, 20) + SourceIndex(0) ---- ->>> var c1 = (function () { -1->^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^-> -1-> - > -1->Emitted(3, 5) Source(3, 1) + SourceIndex(0) ---- ->>> function c1() { -1->^^^^^^^^ -2 > ^^-> -1-> -1->Emitted(4, 9) Source(3, 1) + SourceIndex(0) name (c1) ---- ->>> } -1->^^^^^^^^ -2 > ^ -3 > ^^^^^^^^^^-> -1->export class c1 { - > public p1: number; - > -2 > } -1->Emitted(5, 9) Source(5, 1) + SourceIndex(0) name (c1.constructor) -2 >Emitted(5, 10) Source(5, 2) + SourceIndex(0) name (c1.constructor) ---- ->>> return c1; -1->^^^^^^^^ -2 > ^^^^^^^^^ -1-> -2 > } -1->Emitted(6, 9) Source(5, 1) + SourceIndex(0) name (c1) -2 >Emitted(6, 18) Source(5, 2) + SourceIndex(0) name (c1) ---- ->>> })(); -1 >^^^^ -2 > ^ -3 > -4 > ^^^^ -5 > ^^^^^^^^^^^^-> -1 > -2 > } -3 > -4 > export class c1 { - > public p1: number; - > } -1 >Emitted(7, 5) Source(5, 1) + SourceIndex(0) name (c1) -2 >Emitted(7, 6) Source(5, 2) + SourceIndex(0) name (c1) -3 >Emitted(7, 6) Source(3, 1) + SourceIndex(0) -4 >Emitted(7, 10) Source(5, 2) + SourceIndex(0) ---- ->>> exports.c1 = c1; -1->^^^^ -2 > ^^^^^^^^^^ -3 > ^^^^^ -4 > ^ -5 > ^^^^^^^^^^^^^^-> -1-> -2 > c1 -3 > { - > public p1: number; - > } -4 > -1->Emitted(8, 5) Source(3, 14) + SourceIndex(0) -2 >Emitted(8, 15) Source(3, 16) + SourceIndex(0) -3 >Emitted(8, 20) Source(5, 2) + SourceIndex(0) -4 >Emitted(8, 21) Source(5, 2) + SourceIndex(0) ---- ->>> exports.instance1 = new c1(); -1->^^^^ -2 > ^^^^^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^^^ -5 > ^^ -6 > ^^ -7 > ^ -1-> - > - >export var -2 > instance1 -3 > = -4 > new -5 > c1 -6 > () -7 > ; -1->Emitted(9, 5) Source(7, 12) + SourceIndex(0) -2 >Emitted(9, 22) Source(7, 21) + SourceIndex(0) -3 >Emitted(9, 25) Source(7, 24) + SourceIndex(0) -4 >Emitted(9, 29) Source(7, 28) + SourceIndex(0) -5 >Emitted(9, 31) Source(7, 30) + SourceIndex(0) -6 >Emitted(9, 33) Source(7, 32) + SourceIndex(0) -7 >Emitted(9, 34) Source(7, 33) + SourceIndex(0) ---- ->>> function f1() { -1 >^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -1 >Emitted(10, 5) Source(8, 1) + SourceIndex(0) ---- ->>> return exports.instance1; -1->^^^^^^^^ -2 > ^^^^^^ -3 > ^ -4 > ^^^^^^^^^^^^^^^^^ -5 > ^ -1->export function f1() { - > -2 > return -3 > -4 > instance1 -5 > ; -1->Emitted(11, 9) Source(9, 5) + SourceIndex(0) name (f1) -2 >Emitted(11, 15) Source(9, 11) + SourceIndex(0) name (f1) -3 >Emitted(11, 16) Source(9, 12) + SourceIndex(0) name (f1) -4 >Emitted(11, 33) Source(9, 21) + SourceIndex(0) name (f1) -5 >Emitted(11, 34) Source(9, 22) + SourceIndex(0) name (f1) ---- ->>> } -1 >^^^^ -2 > ^ -3 > ^^^^^^^^^^^^^^^^-> -1 > - > -2 > } -1 >Emitted(12, 5) Source(10, 1) + SourceIndex(0) name (f1) -2 >Emitted(12, 6) Source(10, 2) + SourceIndex(0) name (f1) ---- ->>> exports.f1 = f1; -1->^^^^ -2 > ^^^^^^^^^^ -3 > ^^^^^ -4 > ^ -5 > ^^^^^^^-> -1-> -2 > f1 -3 > () { - > return instance1; - > } -4 > -1->Emitted(13, 5) Source(8, 17) + SourceIndex(0) -2 >Emitted(13, 15) Source(8, 19) + SourceIndex(0) -3 >Emitted(13, 20) Source(10, 2) + SourceIndex(0) -4 >Emitted(13, 21) Source(10, 2) + SourceIndex(0) ---- ->>> exports.a2 = m1.m1_c1; -1->^^^^ -2 > ^^^^^^^^^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^ -7 > ^ -1-> - > - >export var -2 > a2 -3 > = -4 > m1 -5 > . -6 > m1_c1 -7 > ; -1->Emitted(14, 5) Source(12, 12) + SourceIndex(0) -2 >Emitted(14, 15) Source(12, 14) + SourceIndex(0) -3 >Emitted(14, 18) Source(12, 17) + SourceIndex(0) -4 >Emitted(14, 20) Source(12, 19) + SourceIndex(0) -5 >Emitted(14, 21) Source(12, 20) + SourceIndex(0) -6 >Emitted(14, 26) Source(12, 25) + SourceIndex(0) -7 >Emitted(14, 27) Source(12, 26) + SourceIndex(0) ---- ->>>}); ->>>//# sourceMappingURL=../mapFiles/test.js.map=================================================================== JsFile: test.js mapUrl: ../../mapFiles/test.js.map sourceRoot: diff --git a/tests/baselines/reference/project/mapRootRelativePathModuleSimpleSpecifyOutputFile/amd/test.d.ts b/tests/baselines/reference/project/mapRootRelativePathModuleSimpleSpecifyOutputFile/amd/test.d.ts deleted file mode 100644 index 250d2615a79..00000000000 --- a/tests/baselines/reference/project/mapRootRelativePathModuleSimpleSpecifyOutputFile/amd/test.d.ts +++ /dev/null @@ -1,8 +0,0 @@ -import m1 = require("m1"); -export declare var a1: number; -export declare class c1 { - p1: number; -} -export declare var instance1: c1; -export declare function f1(): c1; -export declare var a2: typeof m1.m1_c1; diff --git a/tests/baselines/reference/project/mapRootRelativePathModuleSimpleSpecifyOutputFile/amd/test.js b/tests/baselines/reference/project/mapRootRelativePathModuleSimpleSpecifyOutputFile/amd/test.js deleted file mode 100644 index 14471b6e983..00000000000 --- a/tests/baselines/reference/project/mapRootRelativePathModuleSimpleSpecifyOutputFile/amd/test.js +++ /dev/null @@ -1,16 +0,0 @@ -define(["require", "exports", "m1"], function (require, exports, m1) { - exports.a1 = 10; - var c1 = (function () { - function c1() { - } - return c1; - })(); - exports.c1 = c1; - exports.instance1 = new c1(); - function f1() { - return exports.instance1; - } - exports.f1 = f1; - exports.a2 = m1.m1_c1; -}); -//# sourceMappingURL=../mapFiles/test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootRelativePathModuleSimpleSpecifyOutputFile/amd/test.js.map b/tests/baselines/reference/project/mapRootRelativePathModuleSimpleSpecifyOutputFile/amd/test.js.map deleted file mode 100644 index 5ce16293424..00000000000 --- a/tests/baselines/reference/project/mapRootRelativePathModuleSimpleSpecifyOutputFile/amd/test.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"test.js","sourceRoot":"","sources":["../outputdir_module_simple/test.ts"],"names":["c1","c1.constructor","f1"],"mappings":";IACW,UAAE,GAAG,EAAE,CAAC;IACnB;QAAAA;QAEAC,CAACA;QAADD,SAACA;IAADA,CAACA,AAFD,IAEC;IAFY,UAAE,KAEd,CAAA;IAEU,iBAAS,GAAG,IAAI,EAAE,EAAE,CAAC;IAChC;QACIE,MAAMA,CAACA,iBAASA,CAACA;IACrBA,CAACA;IAFe,UAAE,KAEjB,CAAA;IAEU,UAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootRelativePathModuleSimpleSpecifyOutputFile/node/m1.d.ts b/tests/baselines/reference/project/mapRootRelativePathModuleSimpleSpecifyOutputFile/node/m1.d.ts deleted file mode 100644 index 4a53b24b156..00000000000 --- a/tests/baselines/reference/project/mapRootRelativePathModuleSimpleSpecifyOutputFile/node/m1.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -export declare var m1_a1: number; -export declare class m1_c1 { - m1_c1_p1: number; -} -export declare var m1_instance1: m1_c1; -export declare function m1_f1(): m1_c1; diff --git a/tests/baselines/reference/project/mapRootRelativePathModuleSimpleSpecifyOutputFile/node/m1.js b/tests/baselines/reference/project/mapRootRelativePathModuleSimpleSpecifyOutputFile/node/m1.js deleted file mode 100644 index 73a399fe253..00000000000 --- a/tests/baselines/reference/project/mapRootRelativePathModuleSimpleSpecifyOutputFile/node/m1.js +++ /dev/null @@ -1,13 +0,0 @@ -exports.m1_a1 = 10; -var m1_c1 = (function () { - function m1_c1() { - } - return m1_c1; -})(); -exports.m1_c1 = m1_c1; -exports.m1_instance1 = new m1_c1(); -function m1_f1() { - return exports.m1_instance1; -} -exports.m1_f1 = m1_f1; -//# sourceMappingURL=../mapFiles/m1.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootRelativePathModuleSimpleSpecifyOutputFile/node/m1.js.map b/tests/baselines/reference/project/mapRootRelativePathModuleSimpleSpecifyOutputFile/node/m1.js.map deleted file mode 100644 index 0950101384d..00000000000 --- a/tests/baselines/reference/project/mapRootRelativePathModuleSimpleSpecifyOutputFile/node/m1.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"m1.js","sourceRoot":"","sources":["../outputdir_module_simple/m1.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1"],"mappings":"AAAW,aAAK,GAAG,EAAE,CAAC;AACtB;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAFY,aAAK,QAEjB,CAAA;AAEU,oBAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACIE,MAAMA,CAACA,oBAAYA,CAACA;AACxBA,CAACA;AAFe,aAAK,QAEpB,CAAA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootRelativePathModuleSimpleSpecifyOutputFile/node/mapRootRelativePathModuleSimpleSpecifyOutputFile.json b/tests/baselines/reference/project/mapRootRelativePathModuleSimpleSpecifyOutputFile/node/mapRootRelativePathModuleSimpleSpecifyOutputFile.json index fe0b8045a5c..b4efe9ebb39 100644 --- a/tests/baselines/reference/project/mapRootRelativePathModuleSimpleSpecifyOutputFile/node/mapRootRelativePathModuleSimpleSpecifyOutputFile.json +++ b/tests/baselines/reference/project/mapRootRelativePathModuleSimpleSpecifyOutputFile/node/mapRootRelativePathModuleSimpleSpecifyOutputFile.json @@ -15,12 +15,6 @@ "test.ts" ], "emittedFiles": [ - "m1.js.map", - "m1.js", - "m1.d.ts", - "test.js.map", - "test.js", - "test.d.ts", "bin/test.js.map", "bin/test.js", "bin/test.d.ts" diff --git a/tests/baselines/reference/project/mapRootRelativePathModuleSimpleSpecifyOutputFile/node/mapRootRelativePathModuleSimpleSpecifyOutputFile.sourcemap.txt b/tests/baselines/reference/project/mapRootRelativePathModuleSimpleSpecifyOutputFile/node/mapRootRelativePathModuleSimpleSpecifyOutputFile.sourcemap.txt index ffc11c547d2..4c009331988 100644 --- a/tests/baselines/reference/project/mapRootRelativePathModuleSimpleSpecifyOutputFile/node/mapRootRelativePathModuleSimpleSpecifyOutputFile.sourcemap.txt +++ b/tests/baselines/reference/project/mapRootRelativePathModuleSimpleSpecifyOutputFile/node/mapRootRelativePathModuleSimpleSpecifyOutputFile.sourcemap.txt @@ -1,396 +1,4 @@ =================================================================== -JsFile: m1.js -mapUrl: ../mapFiles/m1.js.map -sourceRoot: -sources: ../outputdir_module_simple/m1.ts -=================================================================== -------------------------------------------------------------------- -emittedFile:m1.js -sourceFile:../outputdir_module_simple/m1.ts -------------------------------------------------------------------- ->>>exports.m1_a1 = 10; -1 > -2 >^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^-> -1 >export var -2 >m1_a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(1, 1) Source(1, 12) + SourceIndex(0) -2 >Emitted(1, 14) Source(1, 17) + SourceIndex(0) -3 >Emitted(1, 17) Source(1, 20) + SourceIndex(0) -4 >Emitted(1, 19) Source(1, 22) + SourceIndex(0) -5 >Emitted(1, 20) Source(1, 23) + SourceIndex(0) ---- ->>>var m1_c1 = (function () { -1-> -2 >^^^^^^^^^^^^^^^^^^^^^^^-> -1-> - > -1->Emitted(2, 1) Source(2, 1) + SourceIndex(0) ---- ->>> function m1_c1() { -1->^^^^ -2 > ^^-> -1-> -1->Emitted(3, 5) Source(2, 1) + SourceIndex(0) name (m1_c1) ---- ->>> } -1->^^^^ -2 > ^ -3 > ^^^^^^^^^^^^^-> -1->export class m1_c1 { - > public m1_c1_p1: number; - > -2 > } -1->Emitted(4, 5) Source(4, 1) + SourceIndex(0) name (m1_c1.constructor) -2 >Emitted(4, 6) Source(4, 2) + SourceIndex(0) name (m1_c1.constructor) ---- ->>> return m1_c1; -1->^^^^ -2 > ^^^^^^^^^^^^ -1-> -2 > } -1->Emitted(5, 5) Source(4, 1) + SourceIndex(0) name (m1_c1) -2 >Emitted(5, 17) Source(4, 2) + SourceIndex(0) name (m1_c1) ---- ->>>})(); -1 > -2 >^ -3 > -4 > ^^^^ -5 > ^^^^^^^^^^^^^^^^^^-> -1 > -2 >} -3 > -4 > export class m1_c1 { - > public m1_c1_p1: number; - > } -1 >Emitted(6, 1) Source(4, 1) + SourceIndex(0) name (m1_c1) -2 >Emitted(6, 2) Source(4, 2) + SourceIndex(0) name (m1_c1) -3 >Emitted(6, 2) Source(2, 1) + SourceIndex(0) -4 >Emitted(6, 6) Source(4, 2) + SourceIndex(0) ---- ->>>exports.m1_c1 = m1_c1; -1-> -2 >^^^^^^^^^^^^^ -3 > ^^^^^^^^ -4 > ^ -5 > ^^^^^^^^^^^^^^-> -1-> -2 >m1_c1 -3 > { - > public m1_c1_p1: number; - > } -4 > -1->Emitted(7, 1) Source(2, 14) + SourceIndex(0) -2 >Emitted(7, 14) Source(2, 19) + SourceIndex(0) -3 >Emitted(7, 22) Source(4, 2) + SourceIndex(0) -4 >Emitted(7, 23) Source(4, 2) + SourceIndex(0) ---- ->>>exports.m1_instance1 = new m1_c1(); -1-> -2 >^^^^^^^^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^^^ -5 > ^^^^^ -6 > ^^ -7 > ^ -1-> - > - >export var -2 >m1_instance1 -3 > = -4 > new -5 > m1_c1 -6 > () -7 > ; -1->Emitted(8, 1) Source(6, 12) + SourceIndex(0) -2 >Emitted(8, 21) Source(6, 24) + SourceIndex(0) -3 >Emitted(8, 24) Source(6, 27) + SourceIndex(0) -4 >Emitted(8, 28) Source(6, 31) + SourceIndex(0) -5 >Emitted(8, 33) Source(6, 36) + SourceIndex(0) -6 >Emitted(8, 35) Source(6, 38) + SourceIndex(0) -7 >Emitted(8, 36) Source(6, 39) + SourceIndex(0) ---- ->>>function m1_f1() { -1 > -2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -1 >Emitted(9, 1) Source(7, 1) + SourceIndex(0) ---- ->>> return exports.m1_instance1; -1->^^^^ -2 > ^^^^^^ -3 > ^ -4 > ^^^^^^^^^^^^^^^^^^^^ -5 > ^ -1->export function m1_f1() { - > -2 > return -3 > -4 > m1_instance1 -5 > ; -1->Emitted(10, 5) Source(8, 5) + SourceIndex(0) name (m1_f1) -2 >Emitted(10, 11) Source(8, 11) + SourceIndex(0) name (m1_f1) -3 >Emitted(10, 12) Source(8, 12) + SourceIndex(0) name (m1_f1) -4 >Emitted(10, 32) Source(8, 24) + SourceIndex(0) name (m1_f1) -5 >Emitted(10, 33) Source(8, 25) + SourceIndex(0) name (m1_f1) ---- ->>>} -1 > -2 >^ -3 > ^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -2 >} -1 >Emitted(11, 1) Source(9, 1) + SourceIndex(0) name (m1_f1) -2 >Emitted(11, 2) Source(9, 2) + SourceIndex(0) name (m1_f1) ---- ->>>exports.m1_f1 = m1_f1; -1-> -2 >^^^^^^^^^^^^^ -3 > ^^^^^^^^ -4 > ^ -5 > ^^^^^^^^^^^^^^^^^^^-> -1-> -2 >m1_f1 -3 > () { - > return m1_instance1; - > } -4 > -1->Emitted(12, 1) Source(7, 17) + SourceIndex(0) -2 >Emitted(12, 14) Source(7, 22) + SourceIndex(0) -3 >Emitted(12, 22) Source(9, 2) + SourceIndex(0) -4 >Emitted(12, 23) Source(9, 2) + SourceIndex(0) ---- ->>>//# sourceMappingURL=../mapFiles/m1.js.map=================================================================== -JsFile: test.js -mapUrl: ../mapFiles/test.js.map -sourceRoot: -sources: ../outputdir_module_simple/test.ts -=================================================================== -------------------------------------------------------------------- -emittedFile:test.js -sourceFile:../outputdir_module_simple/test.ts -------------------------------------------------------------------- ->>>var m1 = require("m1"); -1 > -2 >^^^^ -3 > ^^ -4 > ^^^^^^^^^^^ -5 > ^^^^ -6 > ^ -7 > ^ -1 > -2 >import -3 > m1 -4 > = require( -5 > "m1" -6 > ) -7 > ; -1 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) -2 >Emitted(1, 5) Source(1, 8) + SourceIndex(0) -3 >Emitted(1, 7) Source(1, 10) + SourceIndex(0) -4 >Emitted(1, 18) Source(1, 21) + SourceIndex(0) -5 >Emitted(1, 22) Source(1, 25) + SourceIndex(0) -6 >Emitted(1, 23) Source(1, 26) + SourceIndex(0) -7 >Emitted(1, 24) Source(1, 27) + SourceIndex(0) ---- ->>>exports.a1 = 10; -1 > -2 >^^^^^^^^^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^-> -1 > - >export var -2 >a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(2, 1) Source(2, 12) + SourceIndex(0) -2 >Emitted(2, 11) Source(2, 14) + SourceIndex(0) -3 >Emitted(2, 14) Source(2, 17) + SourceIndex(0) -4 >Emitted(2, 16) Source(2, 19) + SourceIndex(0) -5 >Emitted(2, 17) Source(2, 20) + SourceIndex(0) ---- ->>>var c1 = (function () { -1-> -2 >^^^^^^^^^^^^^^^^^^^^-> -1-> - > -1->Emitted(3, 1) Source(3, 1) + SourceIndex(0) ---- ->>> function c1() { -1->^^^^ -2 > ^^-> -1-> -1->Emitted(4, 5) Source(3, 1) + SourceIndex(0) name (c1) ---- ->>> } -1->^^^^ -2 > ^ -3 > ^^^^^^^^^^-> -1->export class c1 { - > public p1: number; - > -2 > } -1->Emitted(5, 5) Source(5, 1) + SourceIndex(0) name (c1.constructor) -2 >Emitted(5, 6) Source(5, 2) + SourceIndex(0) name (c1.constructor) ---- ->>> return c1; -1->^^^^ -2 > ^^^^^^^^^ -1-> -2 > } -1->Emitted(6, 5) Source(5, 1) + SourceIndex(0) name (c1) -2 >Emitted(6, 14) Source(5, 2) + SourceIndex(0) name (c1) ---- ->>>})(); -1 > -2 >^ -3 > -4 > ^^^^ -5 > ^^^^^^^^^^^^-> -1 > -2 >} -3 > -4 > export class c1 { - > public p1: number; - > } -1 >Emitted(7, 1) Source(5, 1) + SourceIndex(0) name (c1) -2 >Emitted(7, 2) Source(5, 2) + SourceIndex(0) name (c1) -3 >Emitted(7, 2) Source(3, 1) + SourceIndex(0) -4 >Emitted(7, 6) Source(5, 2) + SourceIndex(0) ---- ->>>exports.c1 = c1; -1-> -2 >^^^^^^^^^^ -3 > ^^^^^ -4 > ^ -5 > ^^^^^^^^^^^^^^-> -1-> -2 >c1 -3 > { - > public p1: number; - > } -4 > -1->Emitted(8, 1) Source(3, 14) + SourceIndex(0) -2 >Emitted(8, 11) Source(3, 16) + SourceIndex(0) -3 >Emitted(8, 16) Source(5, 2) + SourceIndex(0) -4 >Emitted(8, 17) Source(5, 2) + SourceIndex(0) ---- ->>>exports.instance1 = new c1(); -1-> -2 >^^^^^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^^^ -5 > ^^ -6 > ^^ -7 > ^ -1-> - > - >export var -2 >instance1 -3 > = -4 > new -5 > c1 -6 > () -7 > ; -1->Emitted(9, 1) Source(7, 12) + SourceIndex(0) -2 >Emitted(9, 18) Source(7, 21) + SourceIndex(0) -3 >Emitted(9, 21) Source(7, 24) + SourceIndex(0) -4 >Emitted(9, 25) Source(7, 28) + SourceIndex(0) -5 >Emitted(9, 27) Source(7, 30) + SourceIndex(0) -6 >Emitted(9, 29) Source(7, 32) + SourceIndex(0) -7 >Emitted(9, 30) Source(7, 33) + SourceIndex(0) ---- ->>>function f1() { -1 > -2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -1 >Emitted(10, 1) Source(8, 1) + SourceIndex(0) ---- ->>> return exports.instance1; -1->^^^^ -2 > ^^^^^^ -3 > ^ -4 > ^^^^^^^^^^^^^^^^^ -5 > ^ -1->export function f1() { - > -2 > return -3 > -4 > instance1 -5 > ; -1->Emitted(11, 5) Source(9, 5) + SourceIndex(0) name (f1) -2 >Emitted(11, 11) Source(9, 11) + SourceIndex(0) name (f1) -3 >Emitted(11, 12) Source(9, 12) + SourceIndex(0) name (f1) -4 >Emitted(11, 29) Source(9, 21) + SourceIndex(0) name (f1) -5 >Emitted(11, 30) Source(9, 22) + SourceIndex(0) name (f1) ---- ->>>} -1 > -2 >^ -3 > ^^^^^^^^^^^^^^^^-> -1 > - > -2 >} -1 >Emitted(12, 1) Source(10, 1) + SourceIndex(0) name (f1) -2 >Emitted(12, 2) Source(10, 2) + SourceIndex(0) name (f1) ---- ->>>exports.f1 = f1; -1-> -2 >^^^^^^^^^^ -3 > ^^^^^ -4 > ^ -5 > ^^^^^^^-> -1-> -2 >f1 -3 > () { - > return instance1; - > } -4 > -1->Emitted(13, 1) Source(8, 17) + SourceIndex(0) -2 >Emitted(13, 11) Source(8, 19) + SourceIndex(0) -3 >Emitted(13, 16) Source(10, 2) + SourceIndex(0) -4 >Emitted(13, 17) Source(10, 2) + SourceIndex(0) ---- ->>>exports.a2 = m1.m1_c1; -1-> -2 >^^^^^^^^^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^ -7 > ^ -8 > ^^^^^^^^^^^^^^^^^^^^^-> -1-> - > - >export var -2 >a2 -3 > = -4 > m1 -5 > . -6 > m1_c1 -7 > ; -1->Emitted(14, 1) Source(12, 12) + SourceIndex(0) -2 >Emitted(14, 11) Source(12, 14) + SourceIndex(0) -3 >Emitted(14, 14) Source(12, 17) + SourceIndex(0) -4 >Emitted(14, 16) Source(12, 19) + SourceIndex(0) -5 >Emitted(14, 17) Source(12, 20) + SourceIndex(0) -6 >Emitted(14, 22) Source(12, 25) + SourceIndex(0) -7 >Emitted(14, 23) Source(12, 26) + SourceIndex(0) ---- ->>>//# sourceMappingURL=../mapFiles/test.js.map=================================================================== JsFile: test.js mapUrl: ../../mapFiles/test.js.map sourceRoot: diff --git a/tests/baselines/reference/project/mapRootRelativePathModuleSimpleSpecifyOutputFile/node/test.d.ts b/tests/baselines/reference/project/mapRootRelativePathModuleSimpleSpecifyOutputFile/node/test.d.ts deleted file mode 100644 index 250d2615a79..00000000000 --- a/tests/baselines/reference/project/mapRootRelativePathModuleSimpleSpecifyOutputFile/node/test.d.ts +++ /dev/null @@ -1,8 +0,0 @@ -import m1 = require("m1"); -export declare var a1: number; -export declare class c1 { - p1: number; -} -export declare var instance1: c1; -export declare function f1(): c1; -export declare var a2: typeof m1.m1_c1; diff --git a/tests/baselines/reference/project/mapRootRelativePathModuleSimpleSpecifyOutputFile/node/test.js b/tests/baselines/reference/project/mapRootRelativePathModuleSimpleSpecifyOutputFile/node/test.js deleted file mode 100644 index 1a2a4fc5e6a..00000000000 --- a/tests/baselines/reference/project/mapRootRelativePathModuleSimpleSpecifyOutputFile/node/test.js +++ /dev/null @@ -1,15 +0,0 @@ -var m1 = require("m1"); -exports.a1 = 10; -var c1 = (function () { - function c1() { - } - return c1; -})(); -exports.c1 = c1; -exports.instance1 = new c1(); -function f1() { - return exports.instance1; -} -exports.f1 = f1; -exports.a2 = m1.m1_c1; -//# sourceMappingURL=../mapFiles/test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootRelativePathModuleSimpleSpecifyOutputFile/node/test.js.map b/tests/baselines/reference/project/mapRootRelativePathModuleSimpleSpecifyOutputFile/node/test.js.map deleted file mode 100644 index c0654a8e141..00000000000 --- a/tests/baselines/reference/project/mapRootRelativePathModuleSimpleSpecifyOutputFile/node/test.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"test.js","sourceRoot":"","sources":["../outputdir_module_simple/test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AAAA,IAAO,EAAE,WAAW,IAAI,CAAC,CAAC;AACf,UAAE,GAAG,EAAE,CAAC;AACnB;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAFY,UAAE,KAEd,CAAA;AAEU,iBAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AAChC;IACIE,MAAMA,CAACA,iBAASA,CAACA;AACrBA,CAACA;AAFe,UAAE,KAEjB,CAAA;AAEU,UAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootRelativePathModuleSubfolderSpecifyOutputFile/amd/mapRootRelativePathModuleSubfolderSpecifyOutputFile.json b/tests/baselines/reference/project/mapRootRelativePathModuleSubfolderSpecifyOutputFile/amd/mapRootRelativePathModuleSubfolderSpecifyOutputFile.json index a87c7d36d8e..51ad7ddf1b2 100644 --- a/tests/baselines/reference/project/mapRootRelativePathModuleSubfolderSpecifyOutputFile/amd/mapRootRelativePathModuleSubfolderSpecifyOutputFile.json +++ b/tests/baselines/reference/project/mapRootRelativePathModuleSubfolderSpecifyOutputFile/amd/mapRootRelativePathModuleSubfolderSpecifyOutputFile.json @@ -15,12 +15,6 @@ "test.ts" ], "emittedFiles": [ - "ref/m1.js.map", - "ref/m1.js", - "ref/m1.d.ts", - "test.js.map", - "test.js", - "test.d.ts", "bin/test.js.map", "bin/test.js", "bin/test.d.ts" diff --git a/tests/baselines/reference/project/mapRootRelativePathModuleSubfolderSpecifyOutputFile/amd/mapRootRelativePathModuleSubfolderSpecifyOutputFile.sourcemap.txt b/tests/baselines/reference/project/mapRootRelativePathModuleSubfolderSpecifyOutputFile/amd/mapRootRelativePathModuleSubfolderSpecifyOutputFile.sourcemap.txt index 25e76457d53..e666ef224a3 100644 --- a/tests/baselines/reference/project/mapRootRelativePathModuleSubfolderSpecifyOutputFile/amd/mapRootRelativePathModuleSubfolderSpecifyOutputFile.sourcemap.txt +++ b/tests/baselines/reference/project/mapRootRelativePathModuleSubfolderSpecifyOutputFile/amd/mapRootRelativePathModuleSubfolderSpecifyOutputFile.sourcemap.txt @@ -1,375 +1,4 @@ =================================================================== -JsFile: m1.js -mapUrl: ../../mapFiles/ref/m1.js.map -sourceRoot: -sources: ../../outputdir_module_subfolder/ref/m1.ts -=================================================================== -------------------------------------------------------------------- -emittedFile:ref/m1.js -sourceFile:../../outputdir_module_subfolder/ref/m1.ts -------------------------------------------------------------------- ->>>define(["require", "exports"], function (require, exports) { ->>> exports.m1_a1 = 10; -1 >^^^^ -2 > ^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^-> -1 >export var -2 > m1_a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(2, 5) Source(1, 12) + SourceIndex(0) -2 >Emitted(2, 18) Source(1, 17) + SourceIndex(0) -3 >Emitted(2, 21) Source(1, 20) + SourceIndex(0) -4 >Emitted(2, 23) Source(1, 22) + SourceIndex(0) -5 >Emitted(2, 24) Source(1, 23) + SourceIndex(0) ---- ->>> var m1_c1 = (function () { -1->^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^^^^-> -1-> - > -1->Emitted(3, 5) Source(2, 1) + SourceIndex(0) ---- ->>> function m1_c1() { -1->^^^^^^^^ -2 > ^^-> -1-> -1->Emitted(4, 9) Source(2, 1) + SourceIndex(0) name (m1_c1) ---- ->>> } -1->^^^^^^^^ -2 > ^ -3 > ^^^^^^^^^^^^^-> -1->export class m1_c1 { - > public m1_c1_p1: number; - > -2 > } -1->Emitted(5, 9) Source(4, 1) + SourceIndex(0) name (m1_c1.constructor) -2 >Emitted(5, 10) Source(4, 2) + SourceIndex(0) name (m1_c1.constructor) ---- ->>> return m1_c1; -1->^^^^^^^^ -2 > ^^^^^^^^^^^^ -1-> -2 > } -1->Emitted(6, 9) Source(4, 1) + SourceIndex(0) name (m1_c1) -2 >Emitted(6, 21) Source(4, 2) + SourceIndex(0) name (m1_c1) ---- ->>> })(); -1 >^^^^ -2 > ^ -3 > -4 > ^^^^ -5 > ^^^^^^^^^^^^^^^^^^-> -1 > -2 > } -3 > -4 > export class m1_c1 { - > public m1_c1_p1: number; - > } -1 >Emitted(7, 5) Source(4, 1) + SourceIndex(0) name (m1_c1) -2 >Emitted(7, 6) Source(4, 2) + SourceIndex(0) name (m1_c1) -3 >Emitted(7, 6) Source(2, 1) + SourceIndex(0) -4 >Emitted(7, 10) Source(4, 2) + SourceIndex(0) ---- ->>> exports.m1_c1 = m1_c1; -1->^^^^ -2 > ^^^^^^^^^^^^^ -3 > ^^^^^^^^ -4 > ^ -5 > ^^^^^^^^^^^^^^-> -1-> -2 > m1_c1 -3 > { - > public m1_c1_p1: number; - > } -4 > -1->Emitted(8, 5) Source(2, 14) + SourceIndex(0) -2 >Emitted(8, 18) Source(2, 19) + SourceIndex(0) -3 >Emitted(8, 26) Source(4, 2) + SourceIndex(0) -4 >Emitted(8, 27) Source(4, 2) + SourceIndex(0) ---- ->>> exports.m1_instance1 = new m1_c1(); -1->^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^^^ -5 > ^^^^^ -6 > ^^ -7 > ^ -1-> - > - >export var -2 > m1_instance1 -3 > = -4 > new -5 > m1_c1 -6 > () -7 > ; -1->Emitted(9, 5) Source(6, 12) + SourceIndex(0) -2 >Emitted(9, 25) Source(6, 24) + SourceIndex(0) -3 >Emitted(9, 28) Source(6, 27) + SourceIndex(0) -4 >Emitted(9, 32) Source(6, 31) + SourceIndex(0) -5 >Emitted(9, 37) Source(6, 36) + SourceIndex(0) -6 >Emitted(9, 39) Source(6, 38) + SourceIndex(0) -7 >Emitted(9, 40) Source(6, 39) + SourceIndex(0) ---- ->>> function m1_f1() { -1 >^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -1 >Emitted(10, 5) Source(7, 1) + SourceIndex(0) ---- ->>> return exports.m1_instance1; -1->^^^^^^^^ -2 > ^^^^^^ -3 > ^ -4 > ^^^^^^^^^^^^^^^^^^^^ -5 > ^ -1->export function m1_f1() { - > -2 > return -3 > -4 > m1_instance1 -5 > ; -1->Emitted(11, 9) Source(8, 5) + SourceIndex(0) name (m1_f1) -2 >Emitted(11, 15) Source(8, 11) + SourceIndex(0) name (m1_f1) -3 >Emitted(11, 16) Source(8, 12) + SourceIndex(0) name (m1_f1) -4 >Emitted(11, 36) Source(8, 24) + SourceIndex(0) name (m1_f1) -5 >Emitted(11, 37) Source(8, 25) + SourceIndex(0) name (m1_f1) ---- ->>> } -1 >^^^^ -2 > ^ -3 > ^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -2 > } -1 >Emitted(12, 5) Source(9, 1) + SourceIndex(0) name (m1_f1) -2 >Emitted(12, 6) Source(9, 2) + SourceIndex(0) name (m1_f1) ---- ->>> exports.m1_f1 = m1_f1; -1->^^^^ -2 > ^^^^^^^^^^^^^ -3 > ^^^^^^^^ -4 > ^ -1-> -2 > m1_f1 -3 > () { - > return m1_instance1; - > } -4 > -1->Emitted(13, 5) Source(7, 17) + SourceIndex(0) -2 >Emitted(13, 18) Source(7, 22) + SourceIndex(0) -3 >Emitted(13, 26) Source(9, 2) + SourceIndex(0) -4 >Emitted(13, 27) Source(9, 2) + SourceIndex(0) ---- ->>>}); ->>>//# sourceMappingURL=../../mapFiles/ref/m1.js.map=================================================================== -JsFile: test.js -mapUrl: ../mapFiles/test.js.map -sourceRoot: -sources: ../outputdir_module_subfolder/test.ts -=================================================================== -------------------------------------------------------------------- -emittedFile:test.js -sourceFile:../outputdir_module_subfolder/test.ts -------------------------------------------------------------------- ->>>define(["require", "exports", "ref/m1"], function (require, exports, m1) { ->>> exports.a1 = 10; -1 >^^^^ -2 > ^^^^^^^^^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^-> -1 >import m1 = require("ref/m1"); - >export var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(2, 5) Source(2, 12) + SourceIndex(0) -2 >Emitted(2, 15) Source(2, 14) + SourceIndex(0) -3 >Emitted(2, 18) Source(2, 17) + SourceIndex(0) -4 >Emitted(2, 20) Source(2, 19) + SourceIndex(0) -5 >Emitted(2, 21) Source(2, 20) + SourceIndex(0) ---- ->>> var c1 = (function () { -1->^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^-> -1-> - > -1->Emitted(3, 5) Source(3, 1) + SourceIndex(0) ---- ->>> function c1() { -1->^^^^^^^^ -2 > ^^-> -1-> -1->Emitted(4, 9) Source(3, 1) + SourceIndex(0) name (c1) ---- ->>> } -1->^^^^^^^^ -2 > ^ -3 > ^^^^^^^^^^-> -1->export class c1 { - > public p1: number; - > -2 > } -1->Emitted(5, 9) Source(5, 1) + SourceIndex(0) name (c1.constructor) -2 >Emitted(5, 10) Source(5, 2) + SourceIndex(0) name (c1.constructor) ---- ->>> return c1; -1->^^^^^^^^ -2 > ^^^^^^^^^ -1-> -2 > } -1->Emitted(6, 9) Source(5, 1) + SourceIndex(0) name (c1) -2 >Emitted(6, 18) Source(5, 2) + SourceIndex(0) name (c1) ---- ->>> })(); -1 >^^^^ -2 > ^ -3 > -4 > ^^^^ -5 > ^^^^^^^^^^^^-> -1 > -2 > } -3 > -4 > export class c1 { - > public p1: number; - > } -1 >Emitted(7, 5) Source(5, 1) + SourceIndex(0) name (c1) -2 >Emitted(7, 6) Source(5, 2) + SourceIndex(0) name (c1) -3 >Emitted(7, 6) Source(3, 1) + SourceIndex(0) -4 >Emitted(7, 10) Source(5, 2) + SourceIndex(0) ---- ->>> exports.c1 = c1; -1->^^^^ -2 > ^^^^^^^^^^ -3 > ^^^^^ -4 > ^ -5 > ^^^^^^^^^^^^^^-> -1-> -2 > c1 -3 > { - > public p1: number; - > } -4 > -1->Emitted(8, 5) Source(3, 14) + SourceIndex(0) -2 >Emitted(8, 15) Source(3, 16) + SourceIndex(0) -3 >Emitted(8, 20) Source(5, 2) + SourceIndex(0) -4 >Emitted(8, 21) Source(5, 2) + SourceIndex(0) ---- ->>> exports.instance1 = new c1(); -1->^^^^ -2 > ^^^^^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^^^ -5 > ^^ -6 > ^^ -7 > ^ -1-> - > - >export var -2 > instance1 -3 > = -4 > new -5 > c1 -6 > () -7 > ; -1->Emitted(9, 5) Source(7, 12) + SourceIndex(0) -2 >Emitted(9, 22) Source(7, 21) + SourceIndex(0) -3 >Emitted(9, 25) Source(7, 24) + SourceIndex(0) -4 >Emitted(9, 29) Source(7, 28) + SourceIndex(0) -5 >Emitted(9, 31) Source(7, 30) + SourceIndex(0) -6 >Emitted(9, 33) Source(7, 32) + SourceIndex(0) -7 >Emitted(9, 34) Source(7, 33) + SourceIndex(0) ---- ->>> function f1() { -1 >^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -1 >Emitted(10, 5) Source(8, 1) + SourceIndex(0) ---- ->>> return exports.instance1; -1->^^^^^^^^ -2 > ^^^^^^ -3 > ^ -4 > ^^^^^^^^^^^^^^^^^ -5 > ^ -1->export function f1() { - > -2 > return -3 > -4 > instance1 -5 > ; -1->Emitted(11, 9) Source(9, 5) + SourceIndex(0) name (f1) -2 >Emitted(11, 15) Source(9, 11) + SourceIndex(0) name (f1) -3 >Emitted(11, 16) Source(9, 12) + SourceIndex(0) name (f1) -4 >Emitted(11, 33) Source(9, 21) + SourceIndex(0) name (f1) -5 >Emitted(11, 34) Source(9, 22) + SourceIndex(0) name (f1) ---- ->>> } -1 >^^^^ -2 > ^ -3 > ^^^^^^^^^^^^^^^^-> -1 > - > -2 > } -1 >Emitted(12, 5) Source(10, 1) + SourceIndex(0) name (f1) -2 >Emitted(12, 6) Source(10, 2) + SourceIndex(0) name (f1) ---- ->>> exports.f1 = f1; -1->^^^^ -2 > ^^^^^^^^^^ -3 > ^^^^^ -4 > ^ -5 > ^^^^^^^-> -1-> -2 > f1 -3 > () { - > return instance1; - > } -4 > -1->Emitted(13, 5) Source(8, 17) + SourceIndex(0) -2 >Emitted(13, 15) Source(8, 19) + SourceIndex(0) -3 >Emitted(13, 20) Source(10, 2) + SourceIndex(0) -4 >Emitted(13, 21) Source(10, 2) + SourceIndex(0) ---- ->>> exports.a2 = m1.m1_c1; -1->^^^^ -2 > ^^^^^^^^^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^ -7 > ^ -1-> - > - >export var -2 > a2 -3 > = -4 > m1 -5 > . -6 > m1_c1 -7 > ; -1->Emitted(14, 5) Source(12, 12) + SourceIndex(0) -2 >Emitted(14, 15) Source(12, 14) + SourceIndex(0) -3 >Emitted(14, 18) Source(12, 17) + SourceIndex(0) -4 >Emitted(14, 20) Source(12, 19) + SourceIndex(0) -5 >Emitted(14, 21) Source(12, 20) + SourceIndex(0) -6 >Emitted(14, 26) Source(12, 25) + SourceIndex(0) -7 >Emitted(14, 27) Source(12, 26) + SourceIndex(0) ---- ->>>}); ->>>//# sourceMappingURL=../mapFiles/test.js.map=================================================================== JsFile: test.js mapUrl: ../../mapFiles/test.js.map sourceRoot: diff --git a/tests/baselines/reference/project/mapRootRelativePathModuleSubfolderSpecifyOutputFile/amd/ref/m1.d.ts b/tests/baselines/reference/project/mapRootRelativePathModuleSubfolderSpecifyOutputFile/amd/ref/m1.d.ts deleted file mode 100644 index 4a53b24b156..00000000000 --- a/tests/baselines/reference/project/mapRootRelativePathModuleSubfolderSpecifyOutputFile/amd/ref/m1.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -export declare var m1_a1: number; -export declare class m1_c1 { - m1_c1_p1: number; -} -export declare var m1_instance1: m1_c1; -export declare function m1_f1(): m1_c1; diff --git a/tests/baselines/reference/project/mapRootRelativePathModuleSubfolderSpecifyOutputFile/amd/ref/m1.js b/tests/baselines/reference/project/mapRootRelativePathModuleSubfolderSpecifyOutputFile/amd/ref/m1.js deleted file mode 100644 index 3e8406858e2..00000000000 --- a/tests/baselines/reference/project/mapRootRelativePathModuleSubfolderSpecifyOutputFile/amd/ref/m1.js +++ /dev/null @@ -1,15 +0,0 @@ -define(["require", "exports"], function (require, exports) { - exports.m1_a1 = 10; - var m1_c1 = (function () { - function m1_c1() { - } - return m1_c1; - })(); - exports.m1_c1 = m1_c1; - exports.m1_instance1 = new m1_c1(); - function m1_f1() { - return exports.m1_instance1; - } - exports.m1_f1 = m1_f1; -}); -//# sourceMappingURL=../../mapFiles/ref/m1.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootRelativePathModuleSubfolderSpecifyOutputFile/amd/ref/m1.js.map b/tests/baselines/reference/project/mapRootRelativePathModuleSubfolderSpecifyOutputFile/amd/ref/m1.js.map deleted file mode 100644 index 66acf4aace7..00000000000 --- a/tests/baselines/reference/project/mapRootRelativePathModuleSubfolderSpecifyOutputFile/amd/ref/m1.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"m1.js","sourceRoot":"","sources":["../../outputdir_module_subfolder/ref/m1.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1"],"mappings":";IAAW,aAAK,GAAG,EAAE,CAAC;IACtB;QAAAA;QAEAC,CAACA;QAADD,YAACA;IAADA,CAACA,AAFD,IAEC;IAFY,aAAK,QAEjB,CAAA;IAEU,oBAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACIE,MAAMA,CAACA,oBAAYA,CAACA;IACxBA,CAACA;IAFe,aAAK,QAEpB,CAAA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootRelativePathModuleSubfolderSpecifyOutputFile/amd/test.d.ts b/tests/baselines/reference/project/mapRootRelativePathModuleSubfolderSpecifyOutputFile/amd/test.d.ts deleted file mode 100644 index a61d8541048..00000000000 --- a/tests/baselines/reference/project/mapRootRelativePathModuleSubfolderSpecifyOutputFile/amd/test.d.ts +++ /dev/null @@ -1,8 +0,0 @@ -import m1 = require("ref/m1"); -export declare var a1: number; -export declare class c1 { - p1: number; -} -export declare var instance1: c1; -export declare function f1(): c1; -export declare var a2: typeof m1.m1_c1; diff --git a/tests/baselines/reference/project/mapRootRelativePathModuleSubfolderSpecifyOutputFile/amd/test.js b/tests/baselines/reference/project/mapRootRelativePathModuleSubfolderSpecifyOutputFile/amd/test.js deleted file mode 100644 index 84b62ed0fc7..00000000000 --- a/tests/baselines/reference/project/mapRootRelativePathModuleSubfolderSpecifyOutputFile/amd/test.js +++ /dev/null @@ -1,16 +0,0 @@ -define(["require", "exports", "ref/m1"], function (require, exports, m1) { - exports.a1 = 10; - var c1 = (function () { - function c1() { - } - return c1; - })(); - exports.c1 = c1; - exports.instance1 = new c1(); - function f1() { - return exports.instance1; - } - exports.f1 = f1; - exports.a2 = m1.m1_c1; -}); -//# sourceMappingURL=../mapFiles/test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootRelativePathModuleSubfolderSpecifyOutputFile/amd/test.js.map b/tests/baselines/reference/project/mapRootRelativePathModuleSubfolderSpecifyOutputFile/amd/test.js.map deleted file mode 100644 index 6139e8293b0..00000000000 --- a/tests/baselines/reference/project/mapRootRelativePathModuleSubfolderSpecifyOutputFile/amd/test.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"test.js","sourceRoot":"","sources":["../outputdir_module_subfolder/test.ts"],"names":["c1","c1.constructor","f1"],"mappings":";IACW,UAAE,GAAG,EAAE,CAAC;IACnB;QAAAA;QAEAC,CAACA;QAADD,SAACA;IAADA,CAACA,AAFD,IAEC;IAFY,UAAE,KAEd,CAAA;IAEU,iBAAS,GAAG,IAAI,EAAE,EAAE,CAAC;IAChC;QACIE,MAAMA,CAACA,iBAASA,CAACA;IACrBA,CAACA;IAFe,UAAE,KAEjB,CAAA;IAEU,UAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootRelativePathModuleSubfolderSpecifyOutputFile/node/mapRootRelativePathModuleSubfolderSpecifyOutputFile.json b/tests/baselines/reference/project/mapRootRelativePathModuleSubfolderSpecifyOutputFile/node/mapRootRelativePathModuleSubfolderSpecifyOutputFile.json index a87c7d36d8e..51ad7ddf1b2 100644 --- a/tests/baselines/reference/project/mapRootRelativePathModuleSubfolderSpecifyOutputFile/node/mapRootRelativePathModuleSubfolderSpecifyOutputFile.json +++ b/tests/baselines/reference/project/mapRootRelativePathModuleSubfolderSpecifyOutputFile/node/mapRootRelativePathModuleSubfolderSpecifyOutputFile.json @@ -15,12 +15,6 @@ "test.ts" ], "emittedFiles": [ - "ref/m1.js.map", - "ref/m1.js", - "ref/m1.d.ts", - "test.js.map", - "test.js", - "test.d.ts", "bin/test.js.map", "bin/test.js", "bin/test.d.ts" diff --git a/tests/baselines/reference/project/mapRootRelativePathModuleSubfolderSpecifyOutputFile/node/mapRootRelativePathModuleSubfolderSpecifyOutputFile.sourcemap.txt b/tests/baselines/reference/project/mapRootRelativePathModuleSubfolderSpecifyOutputFile/node/mapRootRelativePathModuleSubfolderSpecifyOutputFile.sourcemap.txt index 4a7d5c7d49f..a57632c4e07 100644 --- a/tests/baselines/reference/project/mapRootRelativePathModuleSubfolderSpecifyOutputFile/node/mapRootRelativePathModuleSubfolderSpecifyOutputFile.sourcemap.txt +++ b/tests/baselines/reference/project/mapRootRelativePathModuleSubfolderSpecifyOutputFile/node/mapRootRelativePathModuleSubfolderSpecifyOutputFile.sourcemap.txt @@ -1,396 +1,4 @@ =================================================================== -JsFile: m1.js -mapUrl: ../../mapFiles/ref/m1.js.map -sourceRoot: -sources: ../../outputdir_module_subfolder/ref/m1.ts -=================================================================== -------------------------------------------------------------------- -emittedFile:ref/m1.js -sourceFile:../../outputdir_module_subfolder/ref/m1.ts -------------------------------------------------------------------- ->>>exports.m1_a1 = 10; -1 > -2 >^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^-> -1 >export var -2 >m1_a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(1, 1) Source(1, 12) + SourceIndex(0) -2 >Emitted(1, 14) Source(1, 17) + SourceIndex(0) -3 >Emitted(1, 17) Source(1, 20) + SourceIndex(0) -4 >Emitted(1, 19) Source(1, 22) + SourceIndex(0) -5 >Emitted(1, 20) Source(1, 23) + SourceIndex(0) ---- ->>>var m1_c1 = (function () { -1-> -2 >^^^^^^^^^^^^^^^^^^^^^^^-> -1-> - > -1->Emitted(2, 1) Source(2, 1) + SourceIndex(0) ---- ->>> function m1_c1() { -1->^^^^ -2 > ^^-> -1-> -1->Emitted(3, 5) Source(2, 1) + SourceIndex(0) name (m1_c1) ---- ->>> } -1->^^^^ -2 > ^ -3 > ^^^^^^^^^^^^^-> -1->export class m1_c1 { - > public m1_c1_p1: number; - > -2 > } -1->Emitted(4, 5) Source(4, 1) + SourceIndex(0) name (m1_c1.constructor) -2 >Emitted(4, 6) Source(4, 2) + SourceIndex(0) name (m1_c1.constructor) ---- ->>> return m1_c1; -1->^^^^ -2 > ^^^^^^^^^^^^ -1-> -2 > } -1->Emitted(5, 5) Source(4, 1) + SourceIndex(0) name (m1_c1) -2 >Emitted(5, 17) Source(4, 2) + SourceIndex(0) name (m1_c1) ---- ->>>})(); -1 > -2 >^ -3 > -4 > ^^^^ -5 > ^^^^^^^^^^^^^^^^^^-> -1 > -2 >} -3 > -4 > export class m1_c1 { - > public m1_c1_p1: number; - > } -1 >Emitted(6, 1) Source(4, 1) + SourceIndex(0) name (m1_c1) -2 >Emitted(6, 2) Source(4, 2) + SourceIndex(0) name (m1_c1) -3 >Emitted(6, 2) Source(2, 1) + SourceIndex(0) -4 >Emitted(6, 6) Source(4, 2) + SourceIndex(0) ---- ->>>exports.m1_c1 = m1_c1; -1-> -2 >^^^^^^^^^^^^^ -3 > ^^^^^^^^ -4 > ^ -5 > ^^^^^^^^^^^^^^-> -1-> -2 >m1_c1 -3 > { - > public m1_c1_p1: number; - > } -4 > -1->Emitted(7, 1) Source(2, 14) + SourceIndex(0) -2 >Emitted(7, 14) Source(2, 19) + SourceIndex(0) -3 >Emitted(7, 22) Source(4, 2) + SourceIndex(0) -4 >Emitted(7, 23) Source(4, 2) + SourceIndex(0) ---- ->>>exports.m1_instance1 = new m1_c1(); -1-> -2 >^^^^^^^^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^^^ -5 > ^^^^^ -6 > ^^ -7 > ^ -1-> - > - >export var -2 >m1_instance1 -3 > = -4 > new -5 > m1_c1 -6 > () -7 > ; -1->Emitted(8, 1) Source(6, 12) + SourceIndex(0) -2 >Emitted(8, 21) Source(6, 24) + SourceIndex(0) -3 >Emitted(8, 24) Source(6, 27) + SourceIndex(0) -4 >Emitted(8, 28) Source(6, 31) + SourceIndex(0) -5 >Emitted(8, 33) Source(6, 36) + SourceIndex(0) -6 >Emitted(8, 35) Source(6, 38) + SourceIndex(0) -7 >Emitted(8, 36) Source(6, 39) + SourceIndex(0) ---- ->>>function m1_f1() { -1 > -2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -1 >Emitted(9, 1) Source(7, 1) + SourceIndex(0) ---- ->>> return exports.m1_instance1; -1->^^^^ -2 > ^^^^^^ -3 > ^ -4 > ^^^^^^^^^^^^^^^^^^^^ -5 > ^ -1->export function m1_f1() { - > -2 > return -3 > -4 > m1_instance1 -5 > ; -1->Emitted(10, 5) Source(8, 5) + SourceIndex(0) name (m1_f1) -2 >Emitted(10, 11) Source(8, 11) + SourceIndex(0) name (m1_f1) -3 >Emitted(10, 12) Source(8, 12) + SourceIndex(0) name (m1_f1) -4 >Emitted(10, 32) Source(8, 24) + SourceIndex(0) name (m1_f1) -5 >Emitted(10, 33) Source(8, 25) + SourceIndex(0) name (m1_f1) ---- ->>>} -1 > -2 >^ -3 > ^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -2 >} -1 >Emitted(11, 1) Source(9, 1) + SourceIndex(0) name (m1_f1) -2 >Emitted(11, 2) Source(9, 2) + SourceIndex(0) name (m1_f1) ---- ->>>exports.m1_f1 = m1_f1; -1-> -2 >^^^^^^^^^^^^^ -3 > ^^^^^^^^ -4 > ^ -5 > ^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1-> -2 >m1_f1 -3 > () { - > return m1_instance1; - > } -4 > -1->Emitted(12, 1) Source(7, 17) + SourceIndex(0) -2 >Emitted(12, 14) Source(7, 22) + SourceIndex(0) -3 >Emitted(12, 22) Source(9, 2) + SourceIndex(0) -4 >Emitted(12, 23) Source(9, 2) + SourceIndex(0) ---- ->>>//# sourceMappingURL=../../mapFiles/ref/m1.js.map=================================================================== -JsFile: test.js -mapUrl: ../mapFiles/test.js.map -sourceRoot: -sources: ../outputdir_module_subfolder/test.ts -=================================================================== -------------------------------------------------------------------- -emittedFile:test.js -sourceFile:../outputdir_module_subfolder/test.ts -------------------------------------------------------------------- ->>>var m1 = require("ref/m1"); -1 > -2 >^^^^ -3 > ^^ -4 > ^^^^^^^^^^^ -5 > ^^^^^^^^ -6 > ^ -7 > ^ -1 > -2 >import -3 > m1 -4 > = require( -5 > "ref/m1" -6 > ) -7 > ; -1 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) -2 >Emitted(1, 5) Source(1, 8) + SourceIndex(0) -3 >Emitted(1, 7) Source(1, 10) + SourceIndex(0) -4 >Emitted(1, 18) Source(1, 21) + SourceIndex(0) -5 >Emitted(1, 26) Source(1, 29) + SourceIndex(0) -6 >Emitted(1, 27) Source(1, 30) + SourceIndex(0) -7 >Emitted(1, 28) Source(1, 31) + SourceIndex(0) ---- ->>>exports.a1 = 10; -1 > -2 >^^^^^^^^^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^-> -1 > - >export var -2 >a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(2, 1) Source(2, 12) + SourceIndex(0) -2 >Emitted(2, 11) Source(2, 14) + SourceIndex(0) -3 >Emitted(2, 14) Source(2, 17) + SourceIndex(0) -4 >Emitted(2, 16) Source(2, 19) + SourceIndex(0) -5 >Emitted(2, 17) Source(2, 20) + SourceIndex(0) ---- ->>>var c1 = (function () { -1-> -2 >^^^^^^^^^^^^^^^^^^^^-> -1-> - > -1->Emitted(3, 1) Source(3, 1) + SourceIndex(0) ---- ->>> function c1() { -1->^^^^ -2 > ^^-> -1-> -1->Emitted(4, 5) Source(3, 1) + SourceIndex(0) name (c1) ---- ->>> } -1->^^^^ -2 > ^ -3 > ^^^^^^^^^^-> -1->export class c1 { - > public p1: number; - > -2 > } -1->Emitted(5, 5) Source(5, 1) + SourceIndex(0) name (c1.constructor) -2 >Emitted(5, 6) Source(5, 2) + SourceIndex(0) name (c1.constructor) ---- ->>> return c1; -1->^^^^ -2 > ^^^^^^^^^ -1-> -2 > } -1->Emitted(6, 5) Source(5, 1) + SourceIndex(0) name (c1) -2 >Emitted(6, 14) Source(5, 2) + SourceIndex(0) name (c1) ---- ->>>})(); -1 > -2 >^ -3 > -4 > ^^^^ -5 > ^^^^^^^^^^^^-> -1 > -2 >} -3 > -4 > export class c1 { - > public p1: number; - > } -1 >Emitted(7, 1) Source(5, 1) + SourceIndex(0) name (c1) -2 >Emitted(7, 2) Source(5, 2) + SourceIndex(0) name (c1) -3 >Emitted(7, 2) Source(3, 1) + SourceIndex(0) -4 >Emitted(7, 6) Source(5, 2) + SourceIndex(0) ---- ->>>exports.c1 = c1; -1-> -2 >^^^^^^^^^^ -3 > ^^^^^ -4 > ^ -5 > ^^^^^^^^^^^^^^-> -1-> -2 >c1 -3 > { - > public p1: number; - > } -4 > -1->Emitted(8, 1) Source(3, 14) + SourceIndex(0) -2 >Emitted(8, 11) Source(3, 16) + SourceIndex(0) -3 >Emitted(8, 16) Source(5, 2) + SourceIndex(0) -4 >Emitted(8, 17) Source(5, 2) + SourceIndex(0) ---- ->>>exports.instance1 = new c1(); -1-> -2 >^^^^^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^^^ -5 > ^^ -6 > ^^ -7 > ^ -1-> - > - >export var -2 >instance1 -3 > = -4 > new -5 > c1 -6 > () -7 > ; -1->Emitted(9, 1) Source(7, 12) + SourceIndex(0) -2 >Emitted(9, 18) Source(7, 21) + SourceIndex(0) -3 >Emitted(9, 21) Source(7, 24) + SourceIndex(0) -4 >Emitted(9, 25) Source(7, 28) + SourceIndex(0) -5 >Emitted(9, 27) Source(7, 30) + SourceIndex(0) -6 >Emitted(9, 29) Source(7, 32) + SourceIndex(0) -7 >Emitted(9, 30) Source(7, 33) + SourceIndex(0) ---- ->>>function f1() { -1 > -2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -1 >Emitted(10, 1) Source(8, 1) + SourceIndex(0) ---- ->>> return exports.instance1; -1->^^^^ -2 > ^^^^^^ -3 > ^ -4 > ^^^^^^^^^^^^^^^^^ -5 > ^ -1->export function f1() { - > -2 > return -3 > -4 > instance1 -5 > ; -1->Emitted(11, 5) Source(9, 5) + SourceIndex(0) name (f1) -2 >Emitted(11, 11) Source(9, 11) + SourceIndex(0) name (f1) -3 >Emitted(11, 12) Source(9, 12) + SourceIndex(0) name (f1) -4 >Emitted(11, 29) Source(9, 21) + SourceIndex(0) name (f1) -5 >Emitted(11, 30) Source(9, 22) + SourceIndex(0) name (f1) ---- ->>>} -1 > -2 >^ -3 > ^^^^^^^^^^^^^^^^-> -1 > - > -2 >} -1 >Emitted(12, 1) Source(10, 1) + SourceIndex(0) name (f1) -2 >Emitted(12, 2) Source(10, 2) + SourceIndex(0) name (f1) ---- ->>>exports.f1 = f1; -1-> -2 >^^^^^^^^^^ -3 > ^^^^^ -4 > ^ -5 > ^^^^^^^-> -1-> -2 >f1 -3 > () { - > return instance1; - > } -4 > -1->Emitted(13, 1) Source(8, 17) + SourceIndex(0) -2 >Emitted(13, 11) Source(8, 19) + SourceIndex(0) -3 >Emitted(13, 16) Source(10, 2) + SourceIndex(0) -4 >Emitted(13, 17) Source(10, 2) + SourceIndex(0) ---- ->>>exports.a2 = m1.m1_c1; -1-> -2 >^^^^^^^^^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^ -7 > ^ -8 > ^^^^^^^^^^^^^^^^^^^^^-> -1-> - > - >export var -2 >a2 -3 > = -4 > m1 -5 > . -6 > m1_c1 -7 > ; -1->Emitted(14, 1) Source(12, 12) + SourceIndex(0) -2 >Emitted(14, 11) Source(12, 14) + SourceIndex(0) -3 >Emitted(14, 14) Source(12, 17) + SourceIndex(0) -4 >Emitted(14, 16) Source(12, 19) + SourceIndex(0) -5 >Emitted(14, 17) Source(12, 20) + SourceIndex(0) -6 >Emitted(14, 22) Source(12, 25) + SourceIndex(0) -7 >Emitted(14, 23) Source(12, 26) + SourceIndex(0) ---- ->>>//# sourceMappingURL=../mapFiles/test.js.map=================================================================== JsFile: test.js mapUrl: ../../mapFiles/test.js.map sourceRoot: diff --git a/tests/baselines/reference/project/mapRootRelativePathModuleSubfolderSpecifyOutputFile/node/ref/m1.d.ts b/tests/baselines/reference/project/mapRootRelativePathModuleSubfolderSpecifyOutputFile/node/ref/m1.d.ts deleted file mode 100644 index 4a53b24b156..00000000000 --- a/tests/baselines/reference/project/mapRootRelativePathModuleSubfolderSpecifyOutputFile/node/ref/m1.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -export declare var m1_a1: number; -export declare class m1_c1 { - m1_c1_p1: number; -} -export declare var m1_instance1: m1_c1; -export declare function m1_f1(): m1_c1; diff --git a/tests/baselines/reference/project/mapRootRelativePathModuleSubfolderSpecifyOutputFile/node/ref/m1.js b/tests/baselines/reference/project/mapRootRelativePathModuleSubfolderSpecifyOutputFile/node/ref/m1.js deleted file mode 100644 index 2dbac1edb8e..00000000000 --- a/tests/baselines/reference/project/mapRootRelativePathModuleSubfolderSpecifyOutputFile/node/ref/m1.js +++ /dev/null @@ -1,13 +0,0 @@ -exports.m1_a1 = 10; -var m1_c1 = (function () { - function m1_c1() { - } - return m1_c1; -})(); -exports.m1_c1 = m1_c1; -exports.m1_instance1 = new m1_c1(); -function m1_f1() { - return exports.m1_instance1; -} -exports.m1_f1 = m1_f1; -//# sourceMappingURL=../../mapFiles/ref/m1.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootRelativePathModuleSubfolderSpecifyOutputFile/node/ref/m1.js.map b/tests/baselines/reference/project/mapRootRelativePathModuleSubfolderSpecifyOutputFile/node/ref/m1.js.map deleted file mode 100644 index 7e9c3643b99..00000000000 --- a/tests/baselines/reference/project/mapRootRelativePathModuleSubfolderSpecifyOutputFile/node/ref/m1.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"m1.js","sourceRoot":"","sources":["../../outputdir_module_subfolder/ref/m1.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1"],"mappings":"AAAW,aAAK,GAAG,EAAE,CAAC;AACtB;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAFY,aAAK,QAEjB,CAAA;AAEU,oBAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACIE,MAAMA,CAACA,oBAAYA,CAACA;AACxBA,CAACA;AAFe,aAAK,QAEpB,CAAA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootRelativePathModuleSubfolderSpecifyOutputFile/node/test.d.ts b/tests/baselines/reference/project/mapRootRelativePathModuleSubfolderSpecifyOutputFile/node/test.d.ts deleted file mode 100644 index a61d8541048..00000000000 --- a/tests/baselines/reference/project/mapRootRelativePathModuleSubfolderSpecifyOutputFile/node/test.d.ts +++ /dev/null @@ -1,8 +0,0 @@ -import m1 = require("ref/m1"); -export declare var a1: number; -export declare class c1 { - p1: number; -} -export declare var instance1: c1; -export declare function f1(): c1; -export declare var a2: typeof m1.m1_c1; diff --git a/tests/baselines/reference/project/mapRootRelativePathModuleSubfolderSpecifyOutputFile/node/test.js b/tests/baselines/reference/project/mapRootRelativePathModuleSubfolderSpecifyOutputFile/node/test.js deleted file mode 100644 index c6dd0639fb7..00000000000 --- a/tests/baselines/reference/project/mapRootRelativePathModuleSubfolderSpecifyOutputFile/node/test.js +++ /dev/null @@ -1,15 +0,0 @@ -var m1 = require("ref/m1"); -exports.a1 = 10; -var c1 = (function () { - function c1() { - } - return c1; -})(); -exports.c1 = c1; -exports.instance1 = new c1(); -function f1() { - return exports.instance1; -} -exports.f1 = f1; -exports.a2 = m1.m1_c1; -//# sourceMappingURL=../mapFiles/test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootRelativePathModuleSubfolderSpecifyOutputFile/node/test.js.map b/tests/baselines/reference/project/mapRootRelativePathModuleSubfolderSpecifyOutputFile/node/test.js.map deleted file mode 100644 index 64b21aa3115..00000000000 --- a/tests/baselines/reference/project/mapRootRelativePathModuleSubfolderSpecifyOutputFile/node/test.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"test.js","sourceRoot":"","sources":["../outputdir_module_subfolder/test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AAAA,IAAO,EAAE,WAAW,QAAQ,CAAC,CAAC;AACnB,UAAE,GAAG,EAAE,CAAC;AACnB;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAFY,UAAE,KAEd,CAAA;AAEU,iBAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AAChC;IACIE,MAAMA,CAACA,iBAASA,CAACA;AACrBA,CAACA;AAFe,UAAE,KAEjB,CAAA;AAEU,UAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFile/amd/maprootUrlMixedSubfolderSpecifyOutputFile.json b/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFile/amd/maprootUrlMixedSubfolderSpecifyOutputFile.json index f987aa49ffe..b65b2477c8e 100644 --- a/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFile/amd/maprootUrlMixedSubfolderSpecifyOutputFile.json +++ b/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFile/amd/maprootUrlMixedSubfolderSpecifyOutputFile.json @@ -16,9 +16,6 @@ "test.ts" ], "emittedFiles": [ - "ref/m2.js.map", - "ref/m2.js", - "ref/m2.d.ts", "bin/test.js.map", "bin/test.js", "bin/test.d.ts" diff --git a/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFile/amd/maprootUrlMixedSubfolderSpecifyOutputFile.sourcemap.txt b/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFile/amd/maprootUrlMixedSubfolderSpecifyOutputFile.sourcemap.txt index bd84417baa2..0fa723ff01b 100644 --- a/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFile/amd/maprootUrlMixedSubfolderSpecifyOutputFile.sourcemap.txt +++ b/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFile/amd/maprootUrlMixedSubfolderSpecifyOutputFile.sourcemap.txt @@ -1,176 +1,4 @@ =================================================================== -JsFile: m2.js -mapUrl: http://www.typescriptlang.org/ref/m2.js.map -sourceRoot: -sources: file:///tests/cases/projects/outputdir_mixed_subfolder/ref/m2.ts -=================================================================== -------------------------------------------------------------------- -emittedFile:ref/m2.js -sourceFile:file:///tests/cases/projects/outputdir_mixed_subfolder/ref/m2.ts -------------------------------------------------------------------- ->>>define(["require", "exports"], function (require, exports) { ->>> exports.m2_a1 = 10; -1 >^^^^ -2 > ^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^-> -1 >export var -2 > m2_a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(2, 5) Source(1, 12) + SourceIndex(0) -2 >Emitted(2, 18) Source(1, 17) + SourceIndex(0) -3 >Emitted(2, 21) Source(1, 20) + SourceIndex(0) -4 >Emitted(2, 23) Source(1, 22) + SourceIndex(0) -5 >Emitted(2, 24) Source(1, 23) + SourceIndex(0) ---- ->>> var m2_c1 = (function () { -1->^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^^^^-> -1-> - > -1->Emitted(3, 5) Source(2, 1) + SourceIndex(0) ---- ->>> function m2_c1() { -1->^^^^^^^^ -2 > ^^-> -1-> -1->Emitted(4, 9) Source(2, 1) + SourceIndex(0) name (m2_c1) ---- ->>> } -1->^^^^^^^^ -2 > ^ -3 > ^^^^^^^^^^^^^-> -1->export class m2_c1 { - > public m2_c1_p1: number; - > -2 > } -1->Emitted(5, 9) Source(4, 1) + SourceIndex(0) name (m2_c1.constructor) -2 >Emitted(5, 10) Source(4, 2) + SourceIndex(0) name (m2_c1.constructor) ---- ->>> return m2_c1; -1->^^^^^^^^ -2 > ^^^^^^^^^^^^ -1-> -2 > } -1->Emitted(6, 9) Source(4, 1) + SourceIndex(0) name (m2_c1) -2 >Emitted(6, 21) Source(4, 2) + SourceIndex(0) name (m2_c1) ---- ->>> })(); -1 >^^^^ -2 > ^ -3 > -4 > ^^^^ -5 > ^^^^^^^^^^^^^^^^^^-> -1 > -2 > } -3 > -4 > export class m2_c1 { - > public m2_c1_p1: number; - > } -1 >Emitted(7, 5) Source(4, 1) + SourceIndex(0) name (m2_c1) -2 >Emitted(7, 6) Source(4, 2) + SourceIndex(0) name (m2_c1) -3 >Emitted(7, 6) Source(2, 1) + SourceIndex(0) -4 >Emitted(7, 10) Source(4, 2) + SourceIndex(0) ---- ->>> exports.m2_c1 = m2_c1; -1->^^^^ -2 > ^^^^^^^^^^^^^ -3 > ^^^^^^^^ -4 > ^ -5 > ^^^^^^^^^^^^^^-> -1-> -2 > m2_c1 -3 > { - > public m2_c1_p1: number; - > } -4 > -1->Emitted(8, 5) Source(2, 14) + SourceIndex(0) -2 >Emitted(8, 18) Source(2, 19) + SourceIndex(0) -3 >Emitted(8, 26) Source(4, 2) + SourceIndex(0) -4 >Emitted(8, 27) Source(4, 2) + SourceIndex(0) ---- ->>> exports.m2_instance1 = new m2_c1(); -1->^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^^^ -5 > ^^^^^ -6 > ^^ -7 > ^ -1-> - > - >export var -2 > m2_instance1 -3 > = -4 > new -5 > m2_c1 -6 > () -7 > ; -1->Emitted(9, 5) Source(6, 12) + SourceIndex(0) -2 >Emitted(9, 25) Source(6, 24) + SourceIndex(0) -3 >Emitted(9, 28) Source(6, 27) + SourceIndex(0) -4 >Emitted(9, 32) Source(6, 31) + SourceIndex(0) -5 >Emitted(9, 37) Source(6, 36) + SourceIndex(0) -6 >Emitted(9, 39) Source(6, 38) + SourceIndex(0) -7 >Emitted(9, 40) Source(6, 39) + SourceIndex(0) ---- ->>> function m2_f1() { -1 >^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -1 >Emitted(10, 5) Source(7, 1) + SourceIndex(0) ---- ->>> return exports.m2_instance1; -1->^^^^^^^^ -2 > ^^^^^^ -3 > ^ -4 > ^^^^^^^^^^^^^^^^^^^^ -5 > ^ -1->export function m2_f1() { - > -2 > return -3 > -4 > m2_instance1 -5 > ; -1->Emitted(11, 9) Source(8, 5) + SourceIndex(0) name (m2_f1) -2 >Emitted(11, 15) Source(8, 11) + SourceIndex(0) name (m2_f1) -3 >Emitted(11, 16) Source(8, 12) + SourceIndex(0) name (m2_f1) -4 >Emitted(11, 36) Source(8, 24) + SourceIndex(0) name (m2_f1) -5 >Emitted(11, 37) Source(8, 25) + SourceIndex(0) name (m2_f1) ---- ->>> } -1 >^^^^ -2 > ^ -3 > ^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -2 > } -1 >Emitted(12, 5) Source(9, 1) + SourceIndex(0) name (m2_f1) -2 >Emitted(12, 6) Source(9, 2) + SourceIndex(0) name (m2_f1) ---- ->>> exports.m2_f1 = m2_f1; -1->^^^^ -2 > ^^^^^^^^^^^^^ -3 > ^^^^^^^^ -4 > ^ -1-> -2 > m2_f1 -3 > () { - > return m2_instance1; - > } -4 > -1->Emitted(13, 5) Source(7, 17) + SourceIndex(0) -2 >Emitted(13, 18) Source(7, 22) + SourceIndex(0) -3 >Emitted(13, 26) Source(9, 2) + SourceIndex(0) -4 >Emitted(13, 27) Source(9, 2) + SourceIndex(0) ---- ->>>}); ->>>//# sourceMappingURL=http://www.typescriptlang.org/ref/m2.js.map=================================================================== JsFile: test.js mapUrl: http://www.typescriptlang.org/test.js.map sourceRoot: diff --git a/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFile/amd/ref/m2.d.ts b/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFile/amd/ref/m2.d.ts deleted file mode 100644 index c09a3c0c32a..00000000000 --- a/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFile/amd/ref/m2.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -export declare var m2_a1: number; -export declare class m2_c1 { - m2_c1_p1: number; -} -export declare var m2_instance1: m2_c1; -export declare function m2_f1(): m2_c1; diff --git a/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFile/amd/ref/m2.js b/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFile/amd/ref/m2.js deleted file mode 100644 index aa404804b45..00000000000 --- a/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFile/amd/ref/m2.js +++ /dev/null @@ -1,15 +0,0 @@ -define(["require", "exports"], function (require, exports) { - exports.m2_a1 = 10; - var m2_c1 = (function () { - function m2_c1() { - } - return m2_c1; - })(); - exports.m2_c1 = m2_c1; - exports.m2_instance1 = new m2_c1(); - function m2_f1() { - return exports.m2_instance1; - } - exports.m2_f1 = m2_f1; -}); -//# sourceMappingURL=http://www.typescriptlang.org/ref/m2.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFile/amd/ref/m2.js.map b/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFile/amd/ref/m2.js.map deleted file mode 100644 index c2157bc3b1b..00000000000 --- a/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFile/amd/ref/m2.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"m2.js","sourceRoot":"","sources":["file:///tests/cases/projects/outputdir_mixed_subfolder/ref/m2.ts"],"names":["m2_c1","m2_c1.constructor","m2_f1"],"mappings":";IAAW,aAAK,GAAG,EAAE,CAAC;IACtB;QAAAA;QAEAC,CAACA;QAADD,YAACA;IAADA,CAACA,AAFD,IAEC;IAFY,aAAK,QAEjB,CAAA;IAEU,oBAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACIE,MAAMA,CAACA,oBAAYA,CAACA;IACxBA,CAACA;IAFe,aAAK,QAEpB,CAAA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFile/node/maprootUrlMixedSubfolderSpecifyOutputFile.json b/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFile/node/maprootUrlMixedSubfolderSpecifyOutputFile.json index f987aa49ffe..b65b2477c8e 100644 --- a/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFile/node/maprootUrlMixedSubfolderSpecifyOutputFile.json +++ b/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFile/node/maprootUrlMixedSubfolderSpecifyOutputFile.json @@ -16,9 +16,6 @@ "test.ts" ], "emittedFiles": [ - "ref/m2.js.map", - "ref/m2.js", - "ref/m2.d.ts", "bin/test.js.map", "bin/test.js", "bin/test.d.ts" diff --git a/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFile/node/maprootUrlMixedSubfolderSpecifyOutputFile.sourcemap.txt b/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFile/node/maprootUrlMixedSubfolderSpecifyOutputFile.sourcemap.txt index 7a04c10d333..bfe9f5dff6a 100644 --- a/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFile/node/maprootUrlMixedSubfolderSpecifyOutputFile.sourcemap.txt +++ b/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFile/node/maprootUrlMixedSubfolderSpecifyOutputFile.sourcemap.txt @@ -1,175 +1,4 @@ =================================================================== -JsFile: m2.js -mapUrl: http://www.typescriptlang.org/ref/m2.js.map -sourceRoot: -sources: file:///tests/cases/projects/outputdir_mixed_subfolder/ref/m2.ts -=================================================================== -------------------------------------------------------------------- -emittedFile:ref/m2.js -sourceFile:file:///tests/cases/projects/outputdir_mixed_subfolder/ref/m2.ts -------------------------------------------------------------------- ->>>exports.m2_a1 = 10; -1 > -2 >^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^-> -1 >export var -2 >m2_a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(1, 1) Source(1, 12) + SourceIndex(0) -2 >Emitted(1, 14) Source(1, 17) + SourceIndex(0) -3 >Emitted(1, 17) Source(1, 20) + SourceIndex(0) -4 >Emitted(1, 19) Source(1, 22) + SourceIndex(0) -5 >Emitted(1, 20) Source(1, 23) + SourceIndex(0) ---- ->>>var m2_c1 = (function () { -1-> -2 >^^^^^^^^^^^^^^^^^^^^^^^-> -1-> - > -1->Emitted(2, 1) Source(2, 1) + SourceIndex(0) ---- ->>> function m2_c1() { -1->^^^^ -2 > ^^-> -1-> -1->Emitted(3, 5) Source(2, 1) + SourceIndex(0) name (m2_c1) ---- ->>> } -1->^^^^ -2 > ^ -3 > ^^^^^^^^^^^^^-> -1->export class m2_c1 { - > public m2_c1_p1: number; - > -2 > } -1->Emitted(4, 5) Source(4, 1) + SourceIndex(0) name (m2_c1.constructor) -2 >Emitted(4, 6) Source(4, 2) + SourceIndex(0) name (m2_c1.constructor) ---- ->>> return m2_c1; -1->^^^^ -2 > ^^^^^^^^^^^^ -1-> -2 > } -1->Emitted(5, 5) Source(4, 1) + SourceIndex(0) name (m2_c1) -2 >Emitted(5, 17) Source(4, 2) + SourceIndex(0) name (m2_c1) ---- ->>>})(); -1 > -2 >^ -3 > -4 > ^^^^ -5 > ^^^^^^^^^^^^^^^^^^-> -1 > -2 >} -3 > -4 > export class m2_c1 { - > public m2_c1_p1: number; - > } -1 >Emitted(6, 1) Source(4, 1) + SourceIndex(0) name (m2_c1) -2 >Emitted(6, 2) Source(4, 2) + SourceIndex(0) name (m2_c1) -3 >Emitted(6, 2) Source(2, 1) + SourceIndex(0) -4 >Emitted(6, 6) Source(4, 2) + SourceIndex(0) ---- ->>>exports.m2_c1 = m2_c1; -1-> -2 >^^^^^^^^^^^^^ -3 > ^^^^^^^^ -4 > ^ -5 > ^^^^^^^^^^^^^^-> -1-> -2 >m2_c1 -3 > { - > public m2_c1_p1: number; - > } -4 > -1->Emitted(7, 1) Source(2, 14) + SourceIndex(0) -2 >Emitted(7, 14) Source(2, 19) + SourceIndex(0) -3 >Emitted(7, 22) Source(4, 2) + SourceIndex(0) -4 >Emitted(7, 23) Source(4, 2) + SourceIndex(0) ---- ->>>exports.m2_instance1 = new m2_c1(); -1-> -2 >^^^^^^^^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^^^ -5 > ^^^^^ -6 > ^^ -7 > ^ -1-> - > - >export var -2 >m2_instance1 -3 > = -4 > new -5 > m2_c1 -6 > () -7 > ; -1->Emitted(8, 1) Source(6, 12) + SourceIndex(0) -2 >Emitted(8, 21) Source(6, 24) + SourceIndex(0) -3 >Emitted(8, 24) Source(6, 27) + SourceIndex(0) -4 >Emitted(8, 28) Source(6, 31) + SourceIndex(0) -5 >Emitted(8, 33) Source(6, 36) + SourceIndex(0) -6 >Emitted(8, 35) Source(6, 38) + SourceIndex(0) -7 >Emitted(8, 36) Source(6, 39) + SourceIndex(0) ---- ->>>function m2_f1() { -1 > -2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -1 >Emitted(9, 1) Source(7, 1) + SourceIndex(0) ---- ->>> return exports.m2_instance1; -1->^^^^ -2 > ^^^^^^ -3 > ^ -4 > ^^^^^^^^^^^^^^^^^^^^ -5 > ^ -1->export function m2_f1() { - > -2 > return -3 > -4 > m2_instance1 -5 > ; -1->Emitted(10, 5) Source(8, 5) + SourceIndex(0) name (m2_f1) -2 >Emitted(10, 11) Source(8, 11) + SourceIndex(0) name (m2_f1) -3 >Emitted(10, 12) Source(8, 12) + SourceIndex(0) name (m2_f1) -4 >Emitted(10, 32) Source(8, 24) + SourceIndex(0) name (m2_f1) -5 >Emitted(10, 33) Source(8, 25) + SourceIndex(0) name (m2_f1) ---- ->>>} -1 > -2 >^ -3 > ^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -2 >} -1 >Emitted(11, 1) Source(9, 1) + SourceIndex(0) name (m2_f1) -2 >Emitted(11, 2) Source(9, 2) + SourceIndex(0) name (m2_f1) ---- ->>>exports.m2_f1 = m2_f1; -1-> -2 >^^^^^^^^^^^^^ -3 > ^^^^^^^^ -4 > ^ -5 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1-> -2 >m2_f1 -3 > () { - > return m2_instance1; - > } -4 > -1->Emitted(12, 1) Source(7, 17) + SourceIndex(0) -2 >Emitted(12, 14) Source(7, 22) + SourceIndex(0) -3 >Emitted(12, 22) Source(9, 2) + SourceIndex(0) -4 >Emitted(12, 23) Source(9, 2) + SourceIndex(0) ---- ->>>//# sourceMappingURL=http://www.typescriptlang.org/ref/m2.js.map=================================================================== JsFile: test.js mapUrl: http://www.typescriptlang.org/test.js.map sourceRoot: diff --git a/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFile/node/ref/m2.d.ts b/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFile/node/ref/m2.d.ts deleted file mode 100644 index c09a3c0c32a..00000000000 --- a/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFile/node/ref/m2.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -export declare var m2_a1: number; -export declare class m2_c1 { - m2_c1_p1: number; -} -export declare var m2_instance1: m2_c1; -export declare function m2_f1(): m2_c1; diff --git a/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFile/node/ref/m2.js b/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFile/node/ref/m2.js deleted file mode 100644 index a39f0f50e5f..00000000000 --- a/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFile/node/ref/m2.js +++ /dev/null @@ -1,13 +0,0 @@ -exports.m2_a1 = 10; -var m2_c1 = (function () { - function m2_c1() { - } - return m2_c1; -})(); -exports.m2_c1 = m2_c1; -exports.m2_instance1 = new m2_c1(); -function m2_f1() { - return exports.m2_instance1; -} -exports.m2_f1 = m2_f1; -//# sourceMappingURL=http://www.typescriptlang.org/ref/m2.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFile/node/ref/m2.js.map b/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFile/node/ref/m2.js.map deleted file mode 100644 index 0230aad40a5..00000000000 --- a/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFile/node/ref/m2.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"m2.js","sourceRoot":"","sources":["file:///tests/cases/projects/outputdir_mixed_subfolder/ref/m2.ts"],"names":["m2_c1","m2_c1.constructor","m2_f1"],"mappings":"AAAW,aAAK,GAAG,EAAE,CAAC;AACtB;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAFY,aAAK,QAEjB,CAAA;AAEU,oBAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACIE,MAAMA,CAACA,oBAAYA,CAACA;AACxBA,CAACA;AAFe,aAAK,QAEpB,CAAA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/maprootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory.json b/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/maprootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory.json index 2bb23cdc610..9b7785a024b 100644 --- a/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/maprootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory.json +++ b/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/maprootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory.json @@ -17,9 +17,6 @@ "test.ts" ], "emittedFiles": [ - "outdir/outAndOutDirFolder/ref/m2.js.map", - "outdir/outAndOutDirFolder/ref/m2.js", - "outdir/outAndOutDirFolder/ref/m2.d.ts", "bin/outAndOutDirFile.js.map", "bin/outAndOutDirFile.js", "bin/outAndOutDirFile.d.ts" diff --git a/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/maprootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory.sourcemap.txt b/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/maprootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory.sourcemap.txt index bdeabb5ae19..6746d0609b6 100644 --- a/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/maprootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory.sourcemap.txt +++ b/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/maprootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory.sourcemap.txt @@ -1,176 +1,4 @@ =================================================================== -JsFile: m2.js -mapUrl: http://www.typescriptlang.org/ref/m2.js.map -sourceRoot: -sources: file:///tests/cases/projects/outputdir_mixed_subfolder/ref/m2.ts -=================================================================== -------------------------------------------------------------------- -emittedFile:outdir/outAndOutDirFolder/ref/m2.js -sourceFile:file:///tests/cases/projects/outputdir_mixed_subfolder/ref/m2.ts -------------------------------------------------------------------- ->>>define(["require", "exports"], function (require, exports) { ->>> exports.m2_a1 = 10; -1 >^^^^ -2 > ^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^-> -1 >export var -2 > m2_a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(2, 5) Source(1, 12) + SourceIndex(0) -2 >Emitted(2, 18) Source(1, 17) + SourceIndex(0) -3 >Emitted(2, 21) Source(1, 20) + SourceIndex(0) -4 >Emitted(2, 23) Source(1, 22) + SourceIndex(0) -5 >Emitted(2, 24) Source(1, 23) + SourceIndex(0) ---- ->>> var m2_c1 = (function () { -1->^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^^^^-> -1-> - > -1->Emitted(3, 5) Source(2, 1) + SourceIndex(0) ---- ->>> function m2_c1() { -1->^^^^^^^^ -2 > ^^-> -1-> -1->Emitted(4, 9) Source(2, 1) + SourceIndex(0) name (m2_c1) ---- ->>> } -1->^^^^^^^^ -2 > ^ -3 > ^^^^^^^^^^^^^-> -1->export class m2_c1 { - > public m2_c1_p1: number; - > -2 > } -1->Emitted(5, 9) Source(4, 1) + SourceIndex(0) name (m2_c1.constructor) -2 >Emitted(5, 10) Source(4, 2) + SourceIndex(0) name (m2_c1.constructor) ---- ->>> return m2_c1; -1->^^^^^^^^ -2 > ^^^^^^^^^^^^ -1-> -2 > } -1->Emitted(6, 9) Source(4, 1) + SourceIndex(0) name (m2_c1) -2 >Emitted(6, 21) Source(4, 2) + SourceIndex(0) name (m2_c1) ---- ->>> })(); -1 >^^^^ -2 > ^ -3 > -4 > ^^^^ -5 > ^^^^^^^^^^^^^^^^^^-> -1 > -2 > } -3 > -4 > export class m2_c1 { - > public m2_c1_p1: number; - > } -1 >Emitted(7, 5) Source(4, 1) + SourceIndex(0) name (m2_c1) -2 >Emitted(7, 6) Source(4, 2) + SourceIndex(0) name (m2_c1) -3 >Emitted(7, 6) Source(2, 1) + SourceIndex(0) -4 >Emitted(7, 10) Source(4, 2) + SourceIndex(0) ---- ->>> exports.m2_c1 = m2_c1; -1->^^^^ -2 > ^^^^^^^^^^^^^ -3 > ^^^^^^^^ -4 > ^ -5 > ^^^^^^^^^^^^^^-> -1-> -2 > m2_c1 -3 > { - > public m2_c1_p1: number; - > } -4 > -1->Emitted(8, 5) Source(2, 14) + SourceIndex(0) -2 >Emitted(8, 18) Source(2, 19) + SourceIndex(0) -3 >Emitted(8, 26) Source(4, 2) + SourceIndex(0) -4 >Emitted(8, 27) Source(4, 2) + SourceIndex(0) ---- ->>> exports.m2_instance1 = new m2_c1(); -1->^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^^^ -5 > ^^^^^ -6 > ^^ -7 > ^ -1-> - > - >export var -2 > m2_instance1 -3 > = -4 > new -5 > m2_c1 -6 > () -7 > ; -1->Emitted(9, 5) Source(6, 12) + SourceIndex(0) -2 >Emitted(9, 25) Source(6, 24) + SourceIndex(0) -3 >Emitted(9, 28) Source(6, 27) + SourceIndex(0) -4 >Emitted(9, 32) Source(6, 31) + SourceIndex(0) -5 >Emitted(9, 37) Source(6, 36) + SourceIndex(0) -6 >Emitted(9, 39) Source(6, 38) + SourceIndex(0) -7 >Emitted(9, 40) Source(6, 39) + SourceIndex(0) ---- ->>> function m2_f1() { -1 >^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -1 >Emitted(10, 5) Source(7, 1) + SourceIndex(0) ---- ->>> return exports.m2_instance1; -1->^^^^^^^^ -2 > ^^^^^^ -3 > ^ -4 > ^^^^^^^^^^^^^^^^^^^^ -5 > ^ -1->export function m2_f1() { - > -2 > return -3 > -4 > m2_instance1 -5 > ; -1->Emitted(11, 9) Source(8, 5) + SourceIndex(0) name (m2_f1) -2 >Emitted(11, 15) Source(8, 11) + SourceIndex(0) name (m2_f1) -3 >Emitted(11, 16) Source(8, 12) + SourceIndex(0) name (m2_f1) -4 >Emitted(11, 36) Source(8, 24) + SourceIndex(0) name (m2_f1) -5 >Emitted(11, 37) Source(8, 25) + SourceIndex(0) name (m2_f1) ---- ->>> } -1 >^^^^ -2 > ^ -3 > ^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -2 > } -1 >Emitted(12, 5) Source(9, 1) + SourceIndex(0) name (m2_f1) -2 >Emitted(12, 6) Source(9, 2) + SourceIndex(0) name (m2_f1) ---- ->>> exports.m2_f1 = m2_f1; -1->^^^^ -2 > ^^^^^^^^^^^^^ -3 > ^^^^^^^^ -4 > ^ -1-> -2 > m2_f1 -3 > () { - > return m2_instance1; - > } -4 > -1->Emitted(13, 5) Source(7, 17) + SourceIndex(0) -2 >Emitted(13, 18) Source(7, 22) + SourceIndex(0) -3 >Emitted(13, 26) Source(9, 2) + SourceIndex(0) -4 >Emitted(13, 27) Source(9, 2) + SourceIndex(0) ---- ->>>}); ->>>//# sourceMappingURL=http://www.typescriptlang.org/ref/m2.js.map=================================================================== JsFile: outAndOutDirFile.js mapUrl: http://www.typescriptlang.org/outAndOutDirFile.js.map sourceRoot: diff --git a/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/outdir/outAndOutDirFolder/ref/m2.d.ts b/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/outdir/outAndOutDirFolder/ref/m2.d.ts deleted file mode 100644 index c09a3c0c32a..00000000000 --- a/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/outdir/outAndOutDirFolder/ref/m2.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -export declare var m2_a1: number; -export declare class m2_c1 { - m2_c1_p1: number; -} -export declare var m2_instance1: m2_c1; -export declare function m2_f1(): m2_c1; diff --git a/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/outdir/outAndOutDirFolder/ref/m2.js b/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/outdir/outAndOutDirFolder/ref/m2.js deleted file mode 100644 index aa404804b45..00000000000 --- a/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/outdir/outAndOutDirFolder/ref/m2.js +++ /dev/null @@ -1,15 +0,0 @@ -define(["require", "exports"], function (require, exports) { - exports.m2_a1 = 10; - var m2_c1 = (function () { - function m2_c1() { - } - return m2_c1; - })(); - exports.m2_c1 = m2_c1; - exports.m2_instance1 = new m2_c1(); - function m2_f1() { - return exports.m2_instance1; - } - exports.m2_f1 = m2_f1; -}); -//# sourceMappingURL=http://www.typescriptlang.org/ref/m2.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/outdir/outAndOutDirFolder/ref/m2.js.map b/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/outdir/outAndOutDirFolder/ref/m2.js.map deleted file mode 100644 index c2157bc3b1b..00000000000 --- a/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/outdir/outAndOutDirFolder/ref/m2.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"m2.js","sourceRoot":"","sources":["file:///tests/cases/projects/outputdir_mixed_subfolder/ref/m2.ts"],"names":["m2_c1","m2_c1.constructor","m2_f1"],"mappings":";IAAW,aAAK,GAAG,EAAE,CAAC;IACtB;QAAAA;QAEAC,CAACA;QAADD,YAACA;IAADA,CAACA,AAFD,IAEC;IAFY,aAAK,QAEjB,CAAA;IAEU,oBAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACIE,MAAMA,CAACA,oBAAYA,CAACA;IACxBA,CAACA;IAFe,aAAK,QAEpB,CAAA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/maprootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory.json b/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/maprootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory.json index 2bb23cdc610..9b7785a024b 100644 --- a/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/maprootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory.json +++ b/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/maprootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory.json @@ -17,9 +17,6 @@ "test.ts" ], "emittedFiles": [ - "outdir/outAndOutDirFolder/ref/m2.js.map", - "outdir/outAndOutDirFolder/ref/m2.js", - "outdir/outAndOutDirFolder/ref/m2.d.ts", "bin/outAndOutDirFile.js.map", "bin/outAndOutDirFile.js", "bin/outAndOutDirFile.d.ts" diff --git a/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/maprootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory.sourcemap.txt b/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/maprootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory.sourcemap.txt index 33ade6d5e9d..14ca884e9f7 100644 --- a/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/maprootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory.sourcemap.txt +++ b/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/maprootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory.sourcemap.txt @@ -1,175 +1,4 @@ =================================================================== -JsFile: m2.js -mapUrl: http://www.typescriptlang.org/ref/m2.js.map -sourceRoot: -sources: file:///tests/cases/projects/outputdir_mixed_subfolder/ref/m2.ts -=================================================================== -------------------------------------------------------------------- -emittedFile:outdir/outAndOutDirFolder/ref/m2.js -sourceFile:file:///tests/cases/projects/outputdir_mixed_subfolder/ref/m2.ts -------------------------------------------------------------------- ->>>exports.m2_a1 = 10; -1 > -2 >^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^-> -1 >export var -2 >m2_a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(1, 1) Source(1, 12) + SourceIndex(0) -2 >Emitted(1, 14) Source(1, 17) + SourceIndex(0) -3 >Emitted(1, 17) Source(1, 20) + SourceIndex(0) -4 >Emitted(1, 19) Source(1, 22) + SourceIndex(0) -5 >Emitted(1, 20) Source(1, 23) + SourceIndex(0) ---- ->>>var m2_c1 = (function () { -1-> -2 >^^^^^^^^^^^^^^^^^^^^^^^-> -1-> - > -1->Emitted(2, 1) Source(2, 1) + SourceIndex(0) ---- ->>> function m2_c1() { -1->^^^^ -2 > ^^-> -1-> -1->Emitted(3, 5) Source(2, 1) + SourceIndex(0) name (m2_c1) ---- ->>> } -1->^^^^ -2 > ^ -3 > ^^^^^^^^^^^^^-> -1->export class m2_c1 { - > public m2_c1_p1: number; - > -2 > } -1->Emitted(4, 5) Source(4, 1) + SourceIndex(0) name (m2_c1.constructor) -2 >Emitted(4, 6) Source(4, 2) + SourceIndex(0) name (m2_c1.constructor) ---- ->>> return m2_c1; -1->^^^^ -2 > ^^^^^^^^^^^^ -1-> -2 > } -1->Emitted(5, 5) Source(4, 1) + SourceIndex(0) name (m2_c1) -2 >Emitted(5, 17) Source(4, 2) + SourceIndex(0) name (m2_c1) ---- ->>>})(); -1 > -2 >^ -3 > -4 > ^^^^ -5 > ^^^^^^^^^^^^^^^^^^-> -1 > -2 >} -3 > -4 > export class m2_c1 { - > public m2_c1_p1: number; - > } -1 >Emitted(6, 1) Source(4, 1) + SourceIndex(0) name (m2_c1) -2 >Emitted(6, 2) Source(4, 2) + SourceIndex(0) name (m2_c1) -3 >Emitted(6, 2) Source(2, 1) + SourceIndex(0) -4 >Emitted(6, 6) Source(4, 2) + SourceIndex(0) ---- ->>>exports.m2_c1 = m2_c1; -1-> -2 >^^^^^^^^^^^^^ -3 > ^^^^^^^^ -4 > ^ -5 > ^^^^^^^^^^^^^^-> -1-> -2 >m2_c1 -3 > { - > public m2_c1_p1: number; - > } -4 > -1->Emitted(7, 1) Source(2, 14) + SourceIndex(0) -2 >Emitted(7, 14) Source(2, 19) + SourceIndex(0) -3 >Emitted(7, 22) Source(4, 2) + SourceIndex(0) -4 >Emitted(7, 23) Source(4, 2) + SourceIndex(0) ---- ->>>exports.m2_instance1 = new m2_c1(); -1-> -2 >^^^^^^^^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^^^ -5 > ^^^^^ -6 > ^^ -7 > ^ -1-> - > - >export var -2 >m2_instance1 -3 > = -4 > new -5 > m2_c1 -6 > () -7 > ; -1->Emitted(8, 1) Source(6, 12) + SourceIndex(0) -2 >Emitted(8, 21) Source(6, 24) + SourceIndex(0) -3 >Emitted(8, 24) Source(6, 27) + SourceIndex(0) -4 >Emitted(8, 28) Source(6, 31) + SourceIndex(0) -5 >Emitted(8, 33) Source(6, 36) + SourceIndex(0) -6 >Emitted(8, 35) Source(6, 38) + SourceIndex(0) -7 >Emitted(8, 36) Source(6, 39) + SourceIndex(0) ---- ->>>function m2_f1() { -1 > -2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -1 >Emitted(9, 1) Source(7, 1) + SourceIndex(0) ---- ->>> return exports.m2_instance1; -1->^^^^ -2 > ^^^^^^ -3 > ^ -4 > ^^^^^^^^^^^^^^^^^^^^ -5 > ^ -1->export function m2_f1() { - > -2 > return -3 > -4 > m2_instance1 -5 > ; -1->Emitted(10, 5) Source(8, 5) + SourceIndex(0) name (m2_f1) -2 >Emitted(10, 11) Source(8, 11) + SourceIndex(0) name (m2_f1) -3 >Emitted(10, 12) Source(8, 12) + SourceIndex(0) name (m2_f1) -4 >Emitted(10, 32) Source(8, 24) + SourceIndex(0) name (m2_f1) -5 >Emitted(10, 33) Source(8, 25) + SourceIndex(0) name (m2_f1) ---- ->>>} -1 > -2 >^ -3 > ^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -2 >} -1 >Emitted(11, 1) Source(9, 1) + SourceIndex(0) name (m2_f1) -2 >Emitted(11, 2) Source(9, 2) + SourceIndex(0) name (m2_f1) ---- ->>>exports.m2_f1 = m2_f1; -1-> -2 >^^^^^^^^^^^^^ -3 > ^^^^^^^^ -4 > ^ -5 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1-> -2 >m2_f1 -3 > () { - > return m2_instance1; - > } -4 > -1->Emitted(12, 1) Source(7, 17) + SourceIndex(0) -2 >Emitted(12, 14) Source(7, 22) + SourceIndex(0) -3 >Emitted(12, 22) Source(9, 2) + SourceIndex(0) -4 >Emitted(12, 23) Source(9, 2) + SourceIndex(0) ---- ->>>//# sourceMappingURL=http://www.typescriptlang.org/ref/m2.js.map=================================================================== JsFile: outAndOutDirFile.js mapUrl: http://www.typescriptlang.org/outAndOutDirFile.js.map sourceRoot: diff --git a/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/outdir/outAndOutDirFolder/ref/m2.d.ts b/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/outdir/outAndOutDirFolder/ref/m2.d.ts deleted file mode 100644 index c09a3c0c32a..00000000000 --- a/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/outdir/outAndOutDirFolder/ref/m2.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -export declare var m2_a1: number; -export declare class m2_c1 { - m2_c1_p1: number; -} -export declare var m2_instance1: m2_c1; -export declare function m2_f1(): m2_c1; diff --git a/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/outdir/outAndOutDirFolder/ref/m2.js b/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/outdir/outAndOutDirFolder/ref/m2.js deleted file mode 100644 index a39f0f50e5f..00000000000 --- a/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/outdir/outAndOutDirFolder/ref/m2.js +++ /dev/null @@ -1,13 +0,0 @@ -exports.m2_a1 = 10; -var m2_c1 = (function () { - function m2_c1() { - } - return m2_c1; -})(); -exports.m2_c1 = m2_c1; -exports.m2_instance1 = new m2_c1(); -function m2_f1() { - return exports.m2_instance1; -} -exports.m2_f1 = m2_f1; -//# sourceMappingURL=http://www.typescriptlang.org/ref/m2.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/outdir/outAndOutDirFolder/ref/m2.js.map b/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/outdir/outAndOutDirFolder/ref/m2.js.map deleted file mode 100644 index 0230aad40a5..00000000000 --- a/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/outdir/outAndOutDirFolder/ref/m2.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"m2.js","sourceRoot":"","sources":["file:///tests/cases/projects/outputdir_mixed_subfolder/ref/m2.ts"],"names":["m2_c1","m2_c1.constructor","m2_f1"],"mappings":"AAAW,aAAK,GAAG,EAAE,CAAC;AACtB;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAFY,aAAK,QAEjB,CAAA;AAEU,oBAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACIE,MAAMA,CAACA,oBAAYA,CAACA;AACxBA,CAACA;AAFe,aAAK,QAEpB,CAAA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlModuleMultifolderSpecifyOutputFile/amd/diskFile0.js.map b/tests/baselines/reference/project/maprootUrlModuleMultifolderSpecifyOutputFile/amd/diskFile0.js.map deleted file mode 100644 index 66c8fa96a0b..00000000000 --- a/tests/baselines/reference/project/maprootUrlModuleMultifolderSpecifyOutputFile/amd/diskFile0.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"m2.js","sourceRoot":"","sources":["file:///tests/cases/projects/outputdir_module_multifolder_ref/m2.ts"],"names":["m2_c1","m2_c1.constructor","m2_f1"],"mappings":";IAAW,aAAK,GAAG,EAAE,CAAC;IACtB;QAAAA;QAEAC,CAACA;QAADD,YAACA;IAADA,CAACA,AAFD,IAEC;IAFY,aAAK,QAEjB,CAAA;IAEU,oBAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACIE,MAAMA,CAACA,oBAAYA,CAACA;IACxBA,CAACA;IAFe,aAAK,QAEpB,CAAA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlModuleMultifolderSpecifyOutputFile/amd/diskFile1.js b/tests/baselines/reference/project/maprootUrlModuleMultifolderSpecifyOutputFile/amd/diskFile1.js deleted file mode 100644 index e926e95f3c3..00000000000 --- a/tests/baselines/reference/project/maprootUrlModuleMultifolderSpecifyOutputFile/amd/diskFile1.js +++ /dev/null @@ -1,15 +0,0 @@ -define(["require", "exports"], function (require, exports) { - exports.m2_a1 = 10; - var m2_c1 = (function () { - function m2_c1() { - } - return m2_c1; - })(); - exports.m2_c1 = m2_c1; - exports.m2_instance1 = new m2_c1(); - function m2_f1() { - return exports.m2_instance1; - } - exports.m2_f1 = m2_f1; -}); -//# sourceMappingURL=http://www.typescriptlang.org/outputdir_module_multifolder_ref/m2.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlModuleMultifolderSpecifyOutputFile/amd/diskFile2.d.ts b/tests/baselines/reference/project/maprootUrlModuleMultifolderSpecifyOutputFile/amd/diskFile2.d.ts deleted file mode 100644 index c09a3c0c32a..00000000000 --- a/tests/baselines/reference/project/maprootUrlModuleMultifolderSpecifyOutputFile/amd/diskFile2.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -export declare var m2_a1: number; -export declare class m2_c1 { - m2_c1_p1: number; -} -export declare var m2_instance1: m2_c1; -export declare function m2_f1(): m2_c1; diff --git a/tests/baselines/reference/project/maprootUrlModuleMultifolderSpecifyOutputFile/amd/maprootUrlModuleMultifolderSpecifyOutputFile.json b/tests/baselines/reference/project/maprootUrlModuleMultifolderSpecifyOutputFile/amd/maprootUrlModuleMultifolderSpecifyOutputFile.json index e061982b32f..2ff88c9696f 100644 --- a/tests/baselines/reference/project/maprootUrlModuleMultifolderSpecifyOutputFile/amd/maprootUrlModuleMultifolderSpecifyOutputFile.json +++ b/tests/baselines/reference/project/maprootUrlModuleMultifolderSpecifyOutputFile/amd/maprootUrlModuleMultifolderSpecifyOutputFile.json @@ -16,15 +16,6 @@ "test.ts" ], "emittedFiles": [ - "ref/m1.js.map", - "ref/m1.js", - "ref/m1.d.ts", - "../outputdir_module_multifolder_ref/m2.js.map", - "../outputdir_module_multifolder_ref/m2.js", - "../outputdir_module_multifolder_ref/m2.d.ts", - "test.js.map", - "test.js", - "test.d.ts", "bin/test.js.map", "bin/test.js", "bin/test.d.ts" diff --git a/tests/baselines/reference/project/maprootUrlModuleMultifolderSpecifyOutputFile/amd/maprootUrlModuleMultifolderSpecifyOutputFile.sourcemap.txt b/tests/baselines/reference/project/maprootUrlModuleMultifolderSpecifyOutputFile/amd/maprootUrlModuleMultifolderSpecifyOutputFile.sourcemap.txt index b45d5fdd6ef..5805c876be8 100644 --- a/tests/baselines/reference/project/maprootUrlModuleMultifolderSpecifyOutputFile/amd/maprootUrlModuleMultifolderSpecifyOutputFile.sourcemap.txt +++ b/tests/baselines/reference/project/maprootUrlModuleMultifolderSpecifyOutputFile/amd/maprootUrlModuleMultifolderSpecifyOutputFile.sourcemap.txt @@ -1,573 +1,4 @@ =================================================================== -JsFile: m1.js -mapUrl: http://www.typescriptlang.org/outputdir_module_multifolder/ref/m1.js.map -sourceRoot: -sources: file:///tests/cases/projects/outputdir_module_multifolder/ref/m1.ts -=================================================================== -------------------------------------------------------------------- -emittedFile:ref/m1.js -sourceFile:file:///tests/cases/projects/outputdir_module_multifolder/ref/m1.ts -------------------------------------------------------------------- ->>>define(["require", "exports"], function (require, exports) { ->>> exports.m1_a1 = 10; -1 >^^^^ -2 > ^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^-> -1 >export var -2 > m1_a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(2, 5) Source(1, 12) + SourceIndex(0) -2 >Emitted(2, 18) Source(1, 17) + SourceIndex(0) -3 >Emitted(2, 21) Source(1, 20) + SourceIndex(0) -4 >Emitted(2, 23) Source(1, 22) + SourceIndex(0) -5 >Emitted(2, 24) Source(1, 23) + SourceIndex(0) ---- ->>> var m1_c1 = (function () { -1->^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^^^^-> -1-> - > -1->Emitted(3, 5) Source(2, 1) + SourceIndex(0) ---- ->>> function m1_c1() { -1->^^^^^^^^ -2 > ^^-> -1-> -1->Emitted(4, 9) Source(2, 1) + SourceIndex(0) name (m1_c1) ---- ->>> } -1->^^^^^^^^ -2 > ^ -3 > ^^^^^^^^^^^^^-> -1->export class m1_c1 { - > public m1_c1_p1: number; - > -2 > } -1->Emitted(5, 9) Source(4, 1) + SourceIndex(0) name (m1_c1.constructor) -2 >Emitted(5, 10) Source(4, 2) + SourceIndex(0) name (m1_c1.constructor) ---- ->>> return m1_c1; -1->^^^^^^^^ -2 > ^^^^^^^^^^^^ -1-> -2 > } -1->Emitted(6, 9) Source(4, 1) + SourceIndex(0) name (m1_c1) -2 >Emitted(6, 21) Source(4, 2) + SourceIndex(0) name (m1_c1) ---- ->>> })(); -1 >^^^^ -2 > ^ -3 > -4 > ^^^^ -5 > ^^^^^^^^^^^^^^^^^^-> -1 > -2 > } -3 > -4 > export class m1_c1 { - > public m1_c1_p1: number; - > } -1 >Emitted(7, 5) Source(4, 1) + SourceIndex(0) name (m1_c1) -2 >Emitted(7, 6) Source(4, 2) + SourceIndex(0) name (m1_c1) -3 >Emitted(7, 6) Source(2, 1) + SourceIndex(0) -4 >Emitted(7, 10) Source(4, 2) + SourceIndex(0) ---- ->>> exports.m1_c1 = m1_c1; -1->^^^^ -2 > ^^^^^^^^^^^^^ -3 > ^^^^^^^^ -4 > ^ -5 > ^^^^^^^^^^^^^^-> -1-> -2 > m1_c1 -3 > { - > public m1_c1_p1: number; - > } -4 > -1->Emitted(8, 5) Source(2, 14) + SourceIndex(0) -2 >Emitted(8, 18) Source(2, 19) + SourceIndex(0) -3 >Emitted(8, 26) Source(4, 2) + SourceIndex(0) -4 >Emitted(8, 27) Source(4, 2) + SourceIndex(0) ---- ->>> exports.m1_instance1 = new m1_c1(); -1->^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^^^ -5 > ^^^^^ -6 > ^^ -7 > ^ -1-> - > - >export var -2 > m1_instance1 -3 > = -4 > new -5 > m1_c1 -6 > () -7 > ; -1->Emitted(9, 5) Source(6, 12) + SourceIndex(0) -2 >Emitted(9, 25) Source(6, 24) + SourceIndex(0) -3 >Emitted(9, 28) Source(6, 27) + SourceIndex(0) -4 >Emitted(9, 32) Source(6, 31) + SourceIndex(0) -5 >Emitted(9, 37) Source(6, 36) + SourceIndex(0) -6 >Emitted(9, 39) Source(6, 38) + SourceIndex(0) -7 >Emitted(9, 40) Source(6, 39) + SourceIndex(0) ---- ->>> function m1_f1() { -1 >^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -1 >Emitted(10, 5) Source(7, 1) + SourceIndex(0) ---- ->>> return exports.m1_instance1; -1->^^^^^^^^ -2 > ^^^^^^ -3 > ^ -4 > ^^^^^^^^^^^^^^^^^^^^ -5 > ^ -1->export function m1_f1() { - > -2 > return -3 > -4 > m1_instance1 -5 > ; -1->Emitted(11, 9) Source(8, 5) + SourceIndex(0) name (m1_f1) -2 >Emitted(11, 15) Source(8, 11) + SourceIndex(0) name (m1_f1) -3 >Emitted(11, 16) Source(8, 12) + SourceIndex(0) name (m1_f1) -4 >Emitted(11, 36) Source(8, 24) + SourceIndex(0) name (m1_f1) -5 >Emitted(11, 37) Source(8, 25) + SourceIndex(0) name (m1_f1) ---- ->>> } -1 >^^^^ -2 > ^ -3 > ^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -2 > } -1 >Emitted(12, 5) Source(9, 1) + SourceIndex(0) name (m1_f1) -2 >Emitted(12, 6) Source(9, 2) + SourceIndex(0) name (m1_f1) ---- ->>> exports.m1_f1 = m1_f1; -1->^^^^ -2 > ^^^^^^^^^^^^^ -3 > ^^^^^^^^ -4 > ^ -1-> -2 > m1_f1 -3 > () { - > return m1_instance1; - > } -4 > -1->Emitted(13, 5) Source(7, 17) + SourceIndex(0) -2 >Emitted(13, 18) Source(7, 22) + SourceIndex(0) -3 >Emitted(13, 26) Source(9, 2) + SourceIndex(0) -4 >Emitted(13, 27) Source(9, 2) + SourceIndex(0) ---- ->>>}); ->>>//# sourceMappingURL=http://www.typescriptlang.org/outputdir_module_multifolder/ref/m1.js.map=================================================================== -JsFile: m2.js -mapUrl: http://www.typescriptlang.org/outputdir_module_multifolder_ref/m2.js.map -sourceRoot: -sources: file:///tests/cases/projects/outputdir_module_multifolder_ref/m2.ts -=================================================================== -------------------------------------------------------------------- -emittedFile:diskFile1.js -sourceFile:file:///tests/cases/projects/outputdir_module_multifolder_ref/m2.ts -------------------------------------------------------------------- ->>>define(["require", "exports"], function (require, exports) { ->>> exports.m2_a1 = 10; -1 >^^^^ -2 > ^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^-> -1 >export var -2 > m2_a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(2, 5) Source(1, 12) + SourceIndex(0) -2 >Emitted(2, 18) Source(1, 17) + SourceIndex(0) -3 >Emitted(2, 21) Source(1, 20) + SourceIndex(0) -4 >Emitted(2, 23) Source(1, 22) + SourceIndex(0) -5 >Emitted(2, 24) Source(1, 23) + SourceIndex(0) ---- ->>> var m2_c1 = (function () { -1->^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^^^^-> -1-> - > -1->Emitted(3, 5) Source(2, 1) + SourceIndex(0) ---- ->>> function m2_c1() { -1->^^^^^^^^ -2 > ^^-> -1-> -1->Emitted(4, 9) Source(2, 1) + SourceIndex(0) name (m2_c1) ---- ->>> } -1->^^^^^^^^ -2 > ^ -3 > ^^^^^^^^^^^^^-> -1->export class m2_c1 { - > public m2_c1_p1: number; - > -2 > } -1->Emitted(5, 9) Source(4, 1) + SourceIndex(0) name (m2_c1.constructor) -2 >Emitted(5, 10) Source(4, 2) + SourceIndex(0) name (m2_c1.constructor) ---- ->>> return m2_c1; -1->^^^^^^^^ -2 > ^^^^^^^^^^^^ -1-> -2 > } -1->Emitted(6, 9) Source(4, 1) + SourceIndex(0) name (m2_c1) -2 >Emitted(6, 21) Source(4, 2) + SourceIndex(0) name (m2_c1) ---- ->>> })(); -1 >^^^^ -2 > ^ -3 > -4 > ^^^^ -5 > ^^^^^^^^^^^^^^^^^^-> -1 > -2 > } -3 > -4 > export class m2_c1 { - > public m2_c1_p1: number; - > } -1 >Emitted(7, 5) Source(4, 1) + SourceIndex(0) name (m2_c1) -2 >Emitted(7, 6) Source(4, 2) + SourceIndex(0) name (m2_c1) -3 >Emitted(7, 6) Source(2, 1) + SourceIndex(0) -4 >Emitted(7, 10) Source(4, 2) + SourceIndex(0) ---- ->>> exports.m2_c1 = m2_c1; -1->^^^^ -2 > ^^^^^^^^^^^^^ -3 > ^^^^^^^^ -4 > ^ -5 > ^^^^^^^^^^^^^^-> -1-> -2 > m2_c1 -3 > { - > public m2_c1_p1: number; - > } -4 > -1->Emitted(8, 5) Source(2, 14) + SourceIndex(0) -2 >Emitted(8, 18) Source(2, 19) + SourceIndex(0) -3 >Emitted(8, 26) Source(4, 2) + SourceIndex(0) -4 >Emitted(8, 27) Source(4, 2) + SourceIndex(0) ---- ->>> exports.m2_instance1 = new m2_c1(); -1->^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^^^ -5 > ^^^^^ -6 > ^^ -7 > ^ -1-> - > - >export var -2 > m2_instance1 -3 > = -4 > new -5 > m2_c1 -6 > () -7 > ; -1->Emitted(9, 5) Source(6, 12) + SourceIndex(0) -2 >Emitted(9, 25) Source(6, 24) + SourceIndex(0) -3 >Emitted(9, 28) Source(6, 27) + SourceIndex(0) -4 >Emitted(9, 32) Source(6, 31) + SourceIndex(0) -5 >Emitted(9, 37) Source(6, 36) + SourceIndex(0) -6 >Emitted(9, 39) Source(6, 38) + SourceIndex(0) -7 >Emitted(9, 40) Source(6, 39) + SourceIndex(0) ---- ->>> function m2_f1() { -1 >^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -1 >Emitted(10, 5) Source(7, 1) + SourceIndex(0) ---- ->>> return exports.m2_instance1; -1->^^^^^^^^ -2 > ^^^^^^ -3 > ^ -4 > ^^^^^^^^^^^^^^^^^^^^ -5 > ^ -1->export function m2_f1() { - > -2 > return -3 > -4 > m2_instance1 -5 > ; -1->Emitted(11, 9) Source(8, 5) + SourceIndex(0) name (m2_f1) -2 >Emitted(11, 15) Source(8, 11) + SourceIndex(0) name (m2_f1) -3 >Emitted(11, 16) Source(8, 12) + SourceIndex(0) name (m2_f1) -4 >Emitted(11, 36) Source(8, 24) + SourceIndex(0) name (m2_f1) -5 >Emitted(11, 37) Source(8, 25) + SourceIndex(0) name (m2_f1) ---- ->>> } -1 >^^^^ -2 > ^ -3 > ^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -2 > } -1 >Emitted(12, 5) Source(9, 1) + SourceIndex(0) name (m2_f1) -2 >Emitted(12, 6) Source(9, 2) + SourceIndex(0) name (m2_f1) ---- ->>> exports.m2_f1 = m2_f1; -1->^^^^ -2 > ^^^^^^^^^^^^^ -3 > ^^^^^^^^ -4 > ^ -1-> -2 > m2_f1 -3 > () { - > return m2_instance1; - > } -4 > -1->Emitted(13, 5) Source(7, 17) + SourceIndex(0) -2 >Emitted(13, 18) Source(7, 22) + SourceIndex(0) -3 >Emitted(13, 26) Source(9, 2) + SourceIndex(0) -4 >Emitted(13, 27) Source(9, 2) + SourceIndex(0) ---- ->>>}); ->>>//# sourceMappingURL=http://www.typescriptlang.org/outputdir_module_multifolder_ref/m2.js.map=================================================================== -JsFile: test.js -mapUrl: http://www.typescriptlang.org/outputdir_module_multifolder/test.js.map -sourceRoot: -sources: file:///tests/cases/projects/outputdir_module_multifolder/test.ts -=================================================================== -------------------------------------------------------------------- -emittedFile:test.js -sourceFile:file:///tests/cases/projects/outputdir_module_multifolder/test.ts -------------------------------------------------------------------- ->>>define(["require", "exports", "ref/m1", "../outputdir_module_multifolder_ref/m2"], function (require, exports, m1, m2) { ->>> exports.a1 = 10; -1 >^^^^ -2 > ^^^^^^^^^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^-> -1 >import m1 = require("ref/m1"); - >import m2 = require("../outputdir_module_multifolder_ref/m2"); - >export var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(2, 5) Source(3, 12) + SourceIndex(0) -2 >Emitted(2, 15) Source(3, 14) + SourceIndex(0) -3 >Emitted(2, 18) Source(3, 17) + SourceIndex(0) -4 >Emitted(2, 20) Source(3, 19) + SourceIndex(0) -5 >Emitted(2, 21) Source(3, 20) + SourceIndex(0) ---- ->>> var c1 = (function () { -1->^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^-> -1-> - > -1->Emitted(3, 5) Source(4, 1) + SourceIndex(0) ---- ->>> function c1() { -1->^^^^^^^^ -2 > ^^-> -1-> -1->Emitted(4, 9) Source(4, 1) + SourceIndex(0) name (c1) ---- ->>> } -1->^^^^^^^^ -2 > ^ -3 > ^^^^^^^^^^-> -1->export class c1 { - > public p1: number; - > -2 > } -1->Emitted(5, 9) Source(6, 1) + SourceIndex(0) name (c1.constructor) -2 >Emitted(5, 10) Source(6, 2) + SourceIndex(0) name (c1.constructor) ---- ->>> return c1; -1->^^^^^^^^ -2 > ^^^^^^^^^ -1-> -2 > } -1->Emitted(6, 9) Source(6, 1) + SourceIndex(0) name (c1) -2 >Emitted(6, 18) Source(6, 2) + SourceIndex(0) name (c1) ---- ->>> })(); -1 >^^^^ -2 > ^ -3 > -4 > ^^^^ -5 > ^^^^^^^^^^^^-> -1 > -2 > } -3 > -4 > export class c1 { - > public p1: number; - > } -1 >Emitted(7, 5) Source(6, 1) + SourceIndex(0) name (c1) -2 >Emitted(7, 6) Source(6, 2) + SourceIndex(0) name (c1) -3 >Emitted(7, 6) Source(4, 1) + SourceIndex(0) -4 >Emitted(7, 10) Source(6, 2) + SourceIndex(0) ---- ->>> exports.c1 = c1; -1->^^^^ -2 > ^^^^^^^^^^ -3 > ^^^^^ -4 > ^ -5 > ^^^^^^^^^^^^^^-> -1-> -2 > c1 -3 > { - > public p1: number; - > } -4 > -1->Emitted(8, 5) Source(4, 14) + SourceIndex(0) -2 >Emitted(8, 15) Source(4, 16) + SourceIndex(0) -3 >Emitted(8, 20) Source(6, 2) + SourceIndex(0) -4 >Emitted(8, 21) Source(6, 2) + SourceIndex(0) ---- ->>> exports.instance1 = new c1(); -1->^^^^ -2 > ^^^^^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^^^ -5 > ^^ -6 > ^^ -7 > ^ -1-> - > - >export var -2 > instance1 -3 > = -4 > new -5 > c1 -6 > () -7 > ; -1->Emitted(9, 5) Source(8, 12) + SourceIndex(0) -2 >Emitted(9, 22) Source(8, 21) + SourceIndex(0) -3 >Emitted(9, 25) Source(8, 24) + SourceIndex(0) -4 >Emitted(9, 29) Source(8, 28) + SourceIndex(0) -5 >Emitted(9, 31) Source(8, 30) + SourceIndex(0) -6 >Emitted(9, 33) Source(8, 32) + SourceIndex(0) -7 >Emitted(9, 34) Source(8, 33) + SourceIndex(0) ---- ->>> function f1() { -1 >^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -1 >Emitted(10, 5) Source(9, 1) + SourceIndex(0) ---- ->>> return exports.instance1; -1->^^^^^^^^ -2 > ^^^^^^ -3 > ^ -4 > ^^^^^^^^^^^^^^^^^ -5 > ^ -1->export function f1() { - > -2 > return -3 > -4 > instance1 -5 > ; -1->Emitted(11, 9) Source(10, 5) + SourceIndex(0) name (f1) -2 >Emitted(11, 15) Source(10, 11) + SourceIndex(0) name (f1) -3 >Emitted(11, 16) Source(10, 12) + SourceIndex(0) name (f1) -4 >Emitted(11, 33) Source(10, 21) + SourceIndex(0) name (f1) -5 >Emitted(11, 34) Source(10, 22) + SourceIndex(0) name (f1) ---- ->>> } -1 >^^^^ -2 > ^ -3 > ^^^^^^^^^^^^^^^^-> -1 > - > -2 > } -1 >Emitted(12, 5) Source(11, 1) + SourceIndex(0) name (f1) -2 >Emitted(12, 6) Source(11, 2) + SourceIndex(0) name (f1) ---- ->>> exports.f1 = f1; -1->^^^^ -2 > ^^^^^^^^^^ -3 > ^^^^^ -4 > ^ -5 > ^^^^^^^-> -1-> -2 > f1 -3 > () { - > return instance1; - > } -4 > -1->Emitted(13, 5) Source(9, 17) + SourceIndex(0) -2 >Emitted(13, 15) Source(9, 19) + SourceIndex(0) -3 >Emitted(13, 20) Source(11, 2) + SourceIndex(0) -4 >Emitted(13, 21) Source(11, 2) + SourceIndex(0) ---- ->>> exports.a2 = m1.m1_c1; -1->^^^^ -2 > ^^^^^^^^^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^ -7 > ^ -8 > ^-> -1-> - > - >export var -2 > a2 -3 > = -4 > m1 -5 > . -6 > m1_c1 -7 > ; -1->Emitted(14, 5) Source(13, 12) + SourceIndex(0) -2 >Emitted(14, 15) Source(13, 14) + SourceIndex(0) -3 >Emitted(14, 18) Source(13, 17) + SourceIndex(0) -4 >Emitted(14, 20) Source(13, 19) + SourceIndex(0) -5 >Emitted(14, 21) Source(13, 20) + SourceIndex(0) -6 >Emitted(14, 26) Source(13, 25) + SourceIndex(0) -7 >Emitted(14, 27) Source(13, 26) + SourceIndex(0) ---- ->>> exports.a3 = m2.m2_c1; -1->^^^^ -2 > ^^^^^^^^^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^ -7 > ^ -1-> - >export var -2 > a3 -3 > = -4 > m2 -5 > . -6 > m2_c1 -7 > ; -1->Emitted(15, 5) Source(14, 12) + SourceIndex(0) -2 >Emitted(15, 15) Source(14, 14) + SourceIndex(0) -3 >Emitted(15, 18) Source(14, 17) + SourceIndex(0) -4 >Emitted(15, 20) Source(14, 19) + SourceIndex(0) -5 >Emitted(15, 21) Source(14, 20) + SourceIndex(0) -6 >Emitted(15, 26) Source(14, 25) + SourceIndex(0) -7 >Emitted(15, 27) Source(14, 26) + SourceIndex(0) ---- ->>>}); ->>>//# sourceMappingURL=http://www.typescriptlang.org/outputdir_module_multifolder/test.js.map=================================================================== JsFile: test.js mapUrl: http://www.typescriptlang.org/test.js.map sourceRoot: diff --git a/tests/baselines/reference/project/maprootUrlModuleMultifolderSpecifyOutputFile/amd/ref/m1.d.ts b/tests/baselines/reference/project/maprootUrlModuleMultifolderSpecifyOutputFile/amd/ref/m1.d.ts deleted file mode 100644 index 4a53b24b156..00000000000 --- a/tests/baselines/reference/project/maprootUrlModuleMultifolderSpecifyOutputFile/amd/ref/m1.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -export declare var m1_a1: number; -export declare class m1_c1 { - m1_c1_p1: number; -} -export declare var m1_instance1: m1_c1; -export declare function m1_f1(): m1_c1; diff --git a/tests/baselines/reference/project/maprootUrlModuleMultifolderSpecifyOutputFile/amd/ref/m1.js b/tests/baselines/reference/project/maprootUrlModuleMultifolderSpecifyOutputFile/amd/ref/m1.js deleted file mode 100644 index e8004c87aad..00000000000 --- a/tests/baselines/reference/project/maprootUrlModuleMultifolderSpecifyOutputFile/amd/ref/m1.js +++ /dev/null @@ -1,15 +0,0 @@ -define(["require", "exports"], function (require, exports) { - exports.m1_a1 = 10; - var m1_c1 = (function () { - function m1_c1() { - } - return m1_c1; - })(); - exports.m1_c1 = m1_c1; - exports.m1_instance1 = new m1_c1(); - function m1_f1() { - return exports.m1_instance1; - } - exports.m1_f1 = m1_f1; -}); -//# sourceMappingURL=http://www.typescriptlang.org/outputdir_module_multifolder/ref/m1.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlModuleMultifolderSpecifyOutputFile/amd/ref/m1.js.map b/tests/baselines/reference/project/maprootUrlModuleMultifolderSpecifyOutputFile/amd/ref/m1.js.map deleted file mode 100644 index 37bc8039271..00000000000 --- a/tests/baselines/reference/project/maprootUrlModuleMultifolderSpecifyOutputFile/amd/ref/m1.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"m1.js","sourceRoot":"","sources":["file:///tests/cases/projects/outputdir_module_multifolder/ref/m1.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1"],"mappings":";IAAW,aAAK,GAAG,EAAE,CAAC;IACtB;QAAAA;QAEAC,CAACA;QAADD,YAACA;IAADA,CAACA,AAFD,IAEC;IAFY,aAAK,QAEjB,CAAA;IAEU,oBAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACIE,MAAMA,CAACA,oBAAYA,CAACA;IACxBA,CAACA;IAFe,aAAK,QAEpB,CAAA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlModuleMultifolderSpecifyOutputFile/amd/test.d.ts b/tests/baselines/reference/project/maprootUrlModuleMultifolderSpecifyOutputFile/amd/test.d.ts deleted file mode 100644 index 4afd4e69f2d..00000000000 --- a/tests/baselines/reference/project/maprootUrlModuleMultifolderSpecifyOutputFile/amd/test.d.ts +++ /dev/null @@ -1,10 +0,0 @@ -import m1 = require("ref/m1"); -import m2 = require("../outputdir_module_multifolder_ref/m2"); -export declare var a1: number; -export declare class c1 { - p1: number; -} -export declare var instance1: c1; -export declare function f1(): c1; -export declare var a2: typeof m1.m1_c1; -export declare var a3: typeof m2.m2_c1; diff --git a/tests/baselines/reference/project/maprootUrlModuleMultifolderSpecifyOutputFile/amd/test.js b/tests/baselines/reference/project/maprootUrlModuleMultifolderSpecifyOutputFile/amd/test.js deleted file mode 100644 index 01ad8f96e78..00000000000 --- a/tests/baselines/reference/project/maprootUrlModuleMultifolderSpecifyOutputFile/amd/test.js +++ /dev/null @@ -1,17 +0,0 @@ -define(["require", "exports", "ref/m1", "../outputdir_module_multifolder_ref/m2"], function (require, exports, m1, m2) { - exports.a1 = 10; - var c1 = (function () { - function c1() { - } - return c1; - })(); - exports.c1 = c1; - exports.instance1 = new c1(); - function f1() { - return exports.instance1; - } - exports.f1 = f1; - exports.a2 = m1.m1_c1; - exports.a3 = m2.m2_c1; -}); -//# sourceMappingURL=http://www.typescriptlang.org/outputdir_module_multifolder/test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlModuleMultifolderSpecifyOutputFile/amd/test.js.map b/tests/baselines/reference/project/maprootUrlModuleMultifolderSpecifyOutputFile/amd/test.js.map deleted file mode 100644 index 4e7e9721b83..00000000000 --- a/tests/baselines/reference/project/maprootUrlModuleMultifolderSpecifyOutputFile/amd/test.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"test.js","sourceRoot":"","sources":["file:///tests/cases/projects/outputdir_module_multifolder/test.ts"],"names":["c1","c1.constructor","f1"],"mappings":";IAEW,UAAE,GAAG,EAAE,CAAC;IACnB;QAAAA;QAEAC,CAACA;QAADD,SAACA;IAADA,CAACA,AAFD,IAEC;IAFY,UAAE,KAEd,CAAA;IAEU,iBAAS,GAAG,IAAI,EAAE,EAAE,CAAC;IAChC;QACIE,MAAMA,CAACA,iBAASA,CAACA;IACrBA,CAACA;IAFe,UAAE,KAEjB,CAAA;IAEU,UAAE,GAAG,EAAE,CAAC,KAAK,CAAC;IACd,UAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlModuleMultifolderSpecifyOutputFile/node/diskFile0.js.map b/tests/baselines/reference/project/maprootUrlModuleMultifolderSpecifyOutputFile/node/diskFile0.js.map deleted file mode 100644 index ec29dfcad18..00000000000 --- a/tests/baselines/reference/project/maprootUrlModuleMultifolderSpecifyOutputFile/node/diskFile0.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"m2.js","sourceRoot":"","sources":["file:///tests/cases/projects/outputdir_module_multifolder_ref/m2.ts"],"names":["m2_c1","m2_c1.constructor","m2_f1"],"mappings":"AAAW,aAAK,GAAG,EAAE,CAAC;AACtB;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAFY,aAAK,QAEjB,CAAA;AAEU,oBAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACIE,MAAMA,CAACA,oBAAYA,CAACA;AACxBA,CAACA;AAFe,aAAK,QAEpB,CAAA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlModuleMultifolderSpecifyOutputFile/node/diskFile1.js b/tests/baselines/reference/project/maprootUrlModuleMultifolderSpecifyOutputFile/node/diskFile1.js deleted file mode 100644 index 721fdf3827f..00000000000 --- a/tests/baselines/reference/project/maprootUrlModuleMultifolderSpecifyOutputFile/node/diskFile1.js +++ /dev/null @@ -1,13 +0,0 @@ -exports.m2_a1 = 10; -var m2_c1 = (function () { - function m2_c1() { - } - return m2_c1; -})(); -exports.m2_c1 = m2_c1; -exports.m2_instance1 = new m2_c1(); -function m2_f1() { - return exports.m2_instance1; -} -exports.m2_f1 = m2_f1; -//# sourceMappingURL=http://www.typescriptlang.org/outputdir_module_multifolder_ref/m2.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlModuleMultifolderSpecifyOutputFile/node/diskFile2.d.ts b/tests/baselines/reference/project/maprootUrlModuleMultifolderSpecifyOutputFile/node/diskFile2.d.ts deleted file mode 100644 index c09a3c0c32a..00000000000 --- a/tests/baselines/reference/project/maprootUrlModuleMultifolderSpecifyOutputFile/node/diskFile2.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -export declare var m2_a1: number; -export declare class m2_c1 { - m2_c1_p1: number; -} -export declare var m2_instance1: m2_c1; -export declare function m2_f1(): m2_c1; diff --git a/tests/baselines/reference/project/maprootUrlModuleMultifolderSpecifyOutputFile/node/maprootUrlModuleMultifolderSpecifyOutputFile.json b/tests/baselines/reference/project/maprootUrlModuleMultifolderSpecifyOutputFile/node/maprootUrlModuleMultifolderSpecifyOutputFile.json index e061982b32f..2ff88c9696f 100644 --- a/tests/baselines/reference/project/maprootUrlModuleMultifolderSpecifyOutputFile/node/maprootUrlModuleMultifolderSpecifyOutputFile.json +++ b/tests/baselines/reference/project/maprootUrlModuleMultifolderSpecifyOutputFile/node/maprootUrlModuleMultifolderSpecifyOutputFile.json @@ -16,15 +16,6 @@ "test.ts" ], "emittedFiles": [ - "ref/m1.js.map", - "ref/m1.js", - "ref/m1.d.ts", - "../outputdir_module_multifolder_ref/m2.js.map", - "../outputdir_module_multifolder_ref/m2.js", - "../outputdir_module_multifolder_ref/m2.d.ts", - "test.js.map", - "test.js", - "test.d.ts", "bin/test.js.map", "bin/test.js", "bin/test.d.ts" diff --git a/tests/baselines/reference/project/maprootUrlModuleMultifolderSpecifyOutputFile/node/maprootUrlModuleMultifolderSpecifyOutputFile.sourcemap.txt b/tests/baselines/reference/project/maprootUrlModuleMultifolderSpecifyOutputFile/node/maprootUrlModuleMultifolderSpecifyOutputFile.sourcemap.txt index 4dfb2e5d394..e66e92ff5cf 100644 --- a/tests/baselines/reference/project/maprootUrlModuleMultifolderSpecifyOutputFile/node/maprootUrlModuleMultifolderSpecifyOutputFile.sourcemap.txt +++ b/tests/baselines/reference/project/maprootUrlModuleMultifolderSpecifyOutputFile/node/maprootUrlModuleMultifolderSpecifyOutputFile.sourcemap.txt @@ -1,617 +1,4 @@ =================================================================== -JsFile: m1.js -mapUrl: http://www.typescriptlang.org/outputdir_module_multifolder/ref/m1.js.map -sourceRoot: -sources: file:///tests/cases/projects/outputdir_module_multifolder/ref/m1.ts -=================================================================== -------------------------------------------------------------------- -emittedFile:ref/m1.js -sourceFile:file:///tests/cases/projects/outputdir_module_multifolder/ref/m1.ts -------------------------------------------------------------------- ->>>exports.m1_a1 = 10; -1 > -2 >^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^-> -1 >export var -2 >m1_a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(1, 1) Source(1, 12) + SourceIndex(0) -2 >Emitted(1, 14) Source(1, 17) + SourceIndex(0) -3 >Emitted(1, 17) Source(1, 20) + SourceIndex(0) -4 >Emitted(1, 19) Source(1, 22) + SourceIndex(0) -5 >Emitted(1, 20) Source(1, 23) + SourceIndex(0) ---- ->>>var m1_c1 = (function () { -1-> -2 >^^^^^^^^^^^^^^^^^^^^^^^-> -1-> - > -1->Emitted(2, 1) Source(2, 1) + SourceIndex(0) ---- ->>> function m1_c1() { -1->^^^^ -2 > ^^-> -1-> -1->Emitted(3, 5) Source(2, 1) + SourceIndex(0) name (m1_c1) ---- ->>> } -1->^^^^ -2 > ^ -3 > ^^^^^^^^^^^^^-> -1->export class m1_c1 { - > public m1_c1_p1: number; - > -2 > } -1->Emitted(4, 5) Source(4, 1) + SourceIndex(0) name (m1_c1.constructor) -2 >Emitted(4, 6) Source(4, 2) + SourceIndex(0) name (m1_c1.constructor) ---- ->>> return m1_c1; -1->^^^^ -2 > ^^^^^^^^^^^^ -1-> -2 > } -1->Emitted(5, 5) Source(4, 1) + SourceIndex(0) name (m1_c1) -2 >Emitted(5, 17) Source(4, 2) + SourceIndex(0) name (m1_c1) ---- ->>>})(); -1 > -2 >^ -3 > -4 > ^^^^ -5 > ^^^^^^^^^^^^^^^^^^-> -1 > -2 >} -3 > -4 > export class m1_c1 { - > public m1_c1_p1: number; - > } -1 >Emitted(6, 1) Source(4, 1) + SourceIndex(0) name (m1_c1) -2 >Emitted(6, 2) Source(4, 2) + SourceIndex(0) name (m1_c1) -3 >Emitted(6, 2) Source(2, 1) + SourceIndex(0) -4 >Emitted(6, 6) Source(4, 2) + SourceIndex(0) ---- ->>>exports.m1_c1 = m1_c1; -1-> -2 >^^^^^^^^^^^^^ -3 > ^^^^^^^^ -4 > ^ -5 > ^^^^^^^^^^^^^^-> -1-> -2 >m1_c1 -3 > { - > public m1_c1_p1: number; - > } -4 > -1->Emitted(7, 1) Source(2, 14) + SourceIndex(0) -2 >Emitted(7, 14) Source(2, 19) + SourceIndex(0) -3 >Emitted(7, 22) Source(4, 2) + SourceIndex(0) -4 >Emitted(7, 23) Source(4, 2) + SourceIndex(0) ---- ->>>exports.m1_instance1 = new m1_c1(); -1-> -2 >^^^^^^^^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^^^ -5 > ^^^^^ -6 > ^^ -7 > ^ -1-> - > - >export var -2 >m1_instance1 -3 > = -4 > new -5 > m1_c1 -6 > () -7 > ; -1->Emitted(8, 1) Source(6, 12) + SourceIndex(0) -2 >Emitted(8, 21) Source(6, 24) + SourceIndex(0) -3 >Emitted(8, 24) Source(6, 27) + SourceIndex(0) -4 >Emitted(8, 28) Source(6, 31) + SourceIndex(0) -5 >Emitted(8, 33) Source(6, 36) + SourceIndex(0) -6 >Emitted(8, 35) Source(6, 38) + SourceIndex(0) -7 >Emitted(8, 36) Source(6, 39) + SourceIndex(0) ---- ->>>function m1_f1() { -1 > -2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -1 >Emitted(9, 1) Source(7, 1) + SourceIndex(0) ---- ->>> return exports.m1_instance1; -1->^^^^ -2 > ^^^^^^ -3 > ^ -4 > ^^^^^^^^^^^^^^^^^^^^ -5 > ^ -1->export function m1_f1() { - > -2 > return -3 > -4 > m1_instance1 -5 > ; -1->Emitted(10, 5) Source(8, 5) + SourceIndex(0) name (m1_f1) -2 >Emitted(10, 11) Source(8, 11) + SourceIndex(0) name (m1_f1) -3 >Emitted(10, 12) Source(8, 12) + SourceIndex(0) name (m1_f1) -4 >Emitted(10, 32) Source(8, 24) + SourceIndex(0) name (m1_f1) -5 >Emitted(10, 33) Source(8, 25) + SourceIndex(0) name (m1_f1) ---- ->>>} -1 > -2 >^ -3 > ^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -2 >} -1 >Emitted(11, 1) Source(9, 1) + SourceIndex(0) name (m1_f1) -2 >Emitted(11, 2) Source(9, 2) + SourceIndex(0) name (m1_f1) ---- ->>>exports.m1_f1 = m1_f1; -1-> -2 >^^^^^^^^^^^^^ -3 > ^^^^^^^^ -4 > ^ -5 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1-> -2 >m1_f1 -3 > () { - > return m1_instance1; - > } -4 > -1->Emitted(12, 1) Source(7, 17) + SourceIndex(0) -2 >Emitted(12, 14) Source(7, 22) + SourceIndex(0) -3 >Emitted(12, 22) Source(9, 2) + SourceIndex(0) -4 >Emitted(12, 23) Source(9, 2) + SourceIndex(0) ---- ->>>//# sourceMappingURL=http://www.typescriptlang.org/outputdir_module_multifolder/ref/m1.js.map=================================================================== -JsFile: m2.js -mapUrl: http://www.typescriptlang.org/outputdir_module_multifolder_ref/m2.js.map -sourceRoot: -sources: file:///tests/cases/projects/outputdir_module_multifolder_ref/m2.ts -=================================================================== -------------------------------------------------------------------- -emittedFile:diskFile1.js -sourceFile:file:///tests/cases/projects/outputdir_module_multifolder_ref/m2.ts -------------------------------------------------------------------- ->>>exports.m2_a1 = 10; -1 > -2 >^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^-> -1 >export var -2 >m2_a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(1, 1) Source(1, 12) + SourceIndex(0) -2 >Emitted(1, 14) Source(1, 17) + SourceIndex(0) -3 >Emitted(1, 17) Source(1, 20) + SourceIndex(0) -4 >Emitted(1, 19) Source(1, 22) + SourceIndex(0) -5 >Emitted(1, 20) Source(1, 23) + SourceIndex(0) ---- ->>>var m2_c1 = (function () { -1-> -2 >^^^^^^^^^^^^^^^^^^^^^^^-> -1-> - > -1->Emitted(2, 1) Source(2, 1) + SourceIndex(0) ---- ->>> function m2_c1() { -1->^^^^ -2 > ^^-> -1-> -1->Emitted(3, 5) Source(2, 1) + SourceIndex(0) name (m2_c1) ---- ->>> } -1->^^^^ -2 > ^ -3 > ^^^^^^^^^^^^^-> -1->export class m2_c1 { - > public m2_c1_p1: number; - > -2 > } -1->Emitted(4, 5) Source(4, 1) + SourceIndex(0) name (m2_c1.constructor) -2 >Emitted(4, 6) Source(4, 2) + SourceIndex(0) name (m2_c1.constructor) ---- ->>> return m2_c1; -1->^^^^ -2 > ^^^^^^^^^^^^ -1-> -2 > } -1->Emitted(5, 5) Source(4, 1) + SourceIndex(0) name (m2_c1) -2 >Emitted(5, 17) Source(4, 2) + SourceIndex(0) name (m2_c1) ---- ->>>})(); -1 > -2 >^ -3 > -4 > ^^^^ -5 > ^^^^^^^^^^^^^^^^^^-> -1 > -2 >} -3 > -4 > export class m2_c1 { - > public m2_c1_p1: number; - > } -1 >Emitted(6, 1) Source(4, 1) + SourceIndex(0) name (m2_c1) -2 >Emitted(6, 2) Source(4, 2) + SourceIndex(0) name (m2_c1) -3 >Emitted(6, 2) Source(2, 1) + SourceIndex(0) -4 >Emitted(6, 6) Source(4, 2) + SourceIndex(0) ---- ->>>exports.m2_c1 = m2_c1; -1-> -2 >^^^^^^^^^^^^^ -3 > ^^^^^^^^ -4 > ^ -5 > ^^^^^^^^^^^^^^-> -1-> -2 >m2_c1 -3 > { - > public m2_c1_p1: number; - > } -4 > -1->Emitted(7, 1) Source(2, 14) + SourceIndex(0) -2 >Emitted(7, 14) Source(2, 19) + SourceIndex(0) -3 >Emitted(7, 22) Source(4, 2) + SourceIndex(0) -4 >Emitted(7, 23) Source(4, 2) + SourceIndex(0) ---- ->>>exports.m2_instance1 = new m2_c1(); -1-> -2 >^^^^^^^^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^^^ -5 > ^^^^^ -6 > ^^ -7 > ^ -1-> - > - >export var -2 >m2_instance1 -3 > = -4 > new -5 > m2_c1 -6 > () -7 > ; -1->Emitted(8, 1) Source(6, 12) + SourceIndex(0) -2 >Emitted(8, 21) Source(6, 24) + SourceIndex(0) -3 >Emitted(8, 24) Source(6, 27) + SourceIndex(0) -4 >Emitted(8, 28) Source(6, 31) + SourceIndex(0) -5 >Emitted(8, 33) Source(6, 36) + SourceIndex(0) -6 >Emitted(8, 35) Source(6, 38) + SourceIndex(0) -7 >Emitted(8, 36) Source(6, 39) + SourceIndex(0) ---- ->>>function m2_f1() { -1 > -2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -1 >Emitted(9, 1) Source(7, 1) + SourceIndex(0) ---- ->>> return exports.m2_instance1; -1->^^^^ -2 > ^^^^^^ -3 > ^ -4 > ^^^^^^^^^^^^^^^^^^^^ -5 > ^ -1->export function m2_f1() { - > -2 > return -3 > -4 > m2_instance1 -5 > ; -1->Emitted(10, 5) Source(8, 5) + SourceIndex(0) name (m2_f1) -2 >Emitted(10, 11) Source(8, 11) + SourceIndex(0) name (m2_f1) -3 >Emitted(10, 12) Source(8, 12) + SourceIndex(0) name (m2_f1) -4 >Emitted(10, 32) Source(8, 24) + SourceIndex(0) name (m2_f1) -5 >Emitted(10, 33) Source(8, 25) + SourceIndex(0) name (m2_f1) ---- ->>>} -1 > -2 >^ -3 > ^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -2 >} -1 >Emitted(11, 1) Source(9, 1) + SourceIndex(0) name (m2_f1) -2 >Emitted(11, 2) Source(9, 2) + SourceIndex(0) name (m2_f1) ---- ->>>exports.m2_f1 = m2_f1; -1-> -2 >^^^^^^^^^^^^^ -3 > ^^^^^^^^ -4 > ^ -5 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1-> -2 >m2_f1 -3 > () { - > return m2_instance1; - > } -4 > -1->Emitted(12, 1) Source(7, 17) + SourceIndex(0) -2 >Emitted(12, 14) Source(7, 22) + SourceIndex(0) -3 >Emitted(12, 22) Source(9, 2) + SourceIndex(0) -4 >Emitted(12, 23) Source(9, 2) + SourceIndex(0) ---- ->>>//# sourceMappingURL=http://www.typescriptlang.org/outputdir_module_multifolder_ref/m2.js.map=================================================================== -JsFile: test.js -mapUrl: http://www.typescriptlang.org/outputdir_module_multifolder/test.js.map -sourceRoot: -sources: file:///tests/cases/projects/outputdir_module_multifolder/test.ts -=================================================================== -------------------------------------------------------------------- -emittedFile:test.js -sourceFile:file:///tests/cases/projects/outputdir_module_multifolder/test.ts -------------------------------------------------------------------- ->>>var m1 = require("ref/m1"); -1 > -2 >^^^^ -3 > ^^ -4 > ^^^^^^^^^^^ -5 > ^^^^^^^^ -6 > ^ -7 > ^ -8 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 > -2 >import -3 > m1 -4 > = require( -5 > "ref/m1" -6 > ) -7 > ; -1 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) -2 >Emitted(1, 5) Source(1, 8) + SourceIndex(0) -3 >Emitted(1, 7) Source(1, 10) + SourceIndex(0) -4 >Emitted(1, 18) Source(1, 21) + SourceIndex(0) -5 >Emitted(1, 26) Source(1, 29) + SourceIndex(0) -6 >Emitted(1, 27) Source(1, 30) + SourceIndex(0) -7 >Emitted(1, 28) Source(1, 31) + SourceIndex(0) ---- ->>>var m2 = require("../outputdir_module_multifolder_ref/m2"); -1-> -2 >^^^^ -3 > ^^ -4 > ^^^^^^^^^^^ -5 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -6 > ^ -7 > ^ -1-> - > -2 >import -3 > m2 -4 > = require( -5 > "../outputdir_module_multifolder_ref/m2" -6 > ) -7 > ; -1->Emitted(2, 1) Source(2, 1) + SourceIndex(0) -2 >Emitted(2, 5) Source(2, 8) + SourceIndex(0) -3 >Emitted(2, 7) Source(2, 10) + SourceIndex(0) -4 >Emitted(2, 18) Source(2, 21) + SourceIndex(0) -5 >Emitted(2, 58) Source(2, 61) + SourceIndex(0) -6 >Emitted(2, 59) Source(2, 62) + SourceIndex(0) -7 >Emitted(2, 60) Source(2, 63) + SourceIndex(0) ---- ->>>exports.a1 = 10; -1 > -2 >^^^^^^^^^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^-> -1 > - >export var -2 >a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(3, 1) Source(3, 12) + SourceIndex(0) -2 >Emitted(3, 11) Source(3, 14) + SourceIndex(0) -3 >Emitted(3, 14) Source(3, 17) + SourceIndex(0) -4 >Emitted(3, 16) Source(3, 19) + SourceIndex(0) -5 >Emitted(3, 17) Source(3, 20) + SourceIndex(0) ---- ->>>var c1 = (function () { -1-> -2 >^^^^^^^^^^^^^^^^^^^^-> -1-> - > -1->Emitted(4, 1) Source(4, 1) + SourceIndex(0) ---- ->>> function c1() { -1->^^^^ -2 > ^^-> -1-> -1->Emitted(5, 5) Source(4, 1) + SourceIndex(0) name (c1) ---- ->>> } -1->^^^^ -2 > ^ -3 > ^^^^^^^^^^-> -1->export class c1 { - > public p1: number; - > -2 > } -1->Emitted(6, 5) Source(6, 1) + SourceIndex(0) name (c1.constructor) -2 >Emitted(6, 6) Source(6, 2) + SourceIndex(0) name (c1.constructor) ---- ->>> return c1; -1->^^^^ -2 > ^^^^^^^^^ -1-> -2 > } -1->Emitted(7, 5) Source(6, 1) + SourceIndex(0) name (c1) -2 >Emitted(7, 14) Source(6, 2) + SourceIndex(0) name (c1) ---- ->>>})(); -1 > -2 >^ -3 > -4 > ^^^^ -5 > ^^^^^^^^^^^^-> -1 > -2 >} -3 > -4 > export class c1 { - > public p1: number; - > } -1 >Emitted(8, 1) Source(6, 1) + SourceIndex(0) name (c1) -2 >Emitted(8, 2) Source(6, 2) + SourceIndex(0) name (c1) -3 >Emitted(8, 2) Source(4, 1) + SourceIndex(0) -4 >Emitted(8, 6) Source(6, 2) + SourceIndex(0) ---- ->>>exports.c1 = c1; -1-> -2 >^^^^^^^^^^ -3 > ^^^^^ -4 > ^ -5 > ^^^^^^^^^^^^^^-> -1-> -2 >c1 -3 > { - > public p1: number; - > } -4 > -1->Emitted(9, 1) Source(4, 14) + SourceIndex(0) -2 >Emitted(9, 11) Source(4, 16) + SourceIndex(0) -3 >Emitted(9, 16) Source(6, 2) + SourceIndex(0) -4 >Emitted(9, 17) Source(6, 2) + SourceIndex(0) ---- ->>>exports.instance1 = new c1(); -1-> -2 >^^^^^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^^^ -5 > ^^ -6 > ^^ -7 > ^ -1-> - > - >export var -2 >instance1 -3 > = -4 > new -5 > c1 -6 > () -7 > ; -1->Emitted(10, 1) Source(8, 12) + SourceIndex(0) -2 >Emitted(10, 18) Source(8, 21) + SourceIndex(0) -3 >Emitted(10, 21) Source(8, 24) + SourceIndex(0) -4 >Emitted(10, 25) Source(8, 28) + SourceIndex(0) -5 >Emitted(10, 27) Source(8, 30) + SourceIndex(0) -6 >Emitted(10, 29) Source(8, 32) + SourceIndex(0) -7 >Emitted(10, 30) Source(8, 33) + SourceIndex(0) ---- ->>>function f1() { -1 > -2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -1 >Emitted(11, 1) Source(9, 1) + SourceIndex(0) ---- ->>> return exports.instance1; -1->^^^^ -2 > ^^^^^^ -3 > ^ -4 > ^^^^^^^^^^^^^^^^^ -5 > ^ -1->export function f1() { - > -2 > return -3 > -4 > instance1 -5 > ; -1->Emitted(12, 5) Source(10, 5) + SourceIndex(0) name (f1) -2 >Emitted(12, 11) Source(10, 11) + SourceIndex(0) name (f1) -3 >Emitted(12, 12) Source(10, 12) + SourceIndex(0) name (f1) -4 >Emitted(12, 29) Source(10, 21) + SourceIndex(0) name (f1) -5 >Emitted(12, 30) Source(10, 22) + SourceIndex(0) name (f1) ---- ->>>} -1 > -2 >^ -3 > ^^^^^^^^^^^^^^^^-> -1 > - > -2 >} -1 >Emitted(13, 1) Source(11, 1) + SourceIndex(0) name (f1) -2 >Emitted(13, 2) Source(11, 2) + SourceIndex(0) name (f1) ---- ->>>exports.f1 = f1; -1-> -2 >^^^^^^^^^^ -3 > ^^^^^ -4 > ^ -5 > ^^^^^^^-> -1-> -2 >f1 -3 > () { - > return instance1; - > } -4 > -1->Emitted(14, 1) Source(9, 17) + SourceIndex(0) -2 >Emitted(14, 11) Source(9, 19) + SourceIndex(0) -3 >Emitted(14, 16) Source(11, 2) + SourceIndex(0) -4 >Emitted(14, 17) Source(11, 2) + SourceIndex(0) ---- ->>>exports.a2 = m1.m1_c1; -1-> -2 >^^^^^^^^^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^ -7 > ^ -8 > ^-> -1-> - > - >export var -2 >a2 -3 > = -4 > m1 -5 > . -6 > m1_c1 -7 > ; -1->Emitted(15, 1) Source(13, 12) + SourceIndex(0) -2 >Emitted(15, 11) Source(13, 14) + SourceIndex(0) -3 >Emitted(15, 14) Source(13, 17) + SourceIndex(0) -4 >Emitted(15, 16) Source(13, 19) + SourceIndex(0) -5 >Emitted(15, 17) Source(13, 20) + SourceIndex(0) -6 >Emitted(15, 22) Source(13, 25) + SourceIndex(0) -7 >Emitted(15, 23) Source(13, 26) + SourceIndex(0) ---- ->>>exports.a3 = m2.m2_c1; -1-> -2 >^^^^^^^^^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^ -7 > ^ -8 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1-> - >export var -2 >a3 -3 > = -4 > m2 -5 > . -6 > m2_c1 -7 > ; -1->Emitted(16, 1) Source(14, 12) + SourceIndex(0) -2 >Emitted(16, 11) Source(14, 14) + SourceIndex(0) -3 >Emitted(16, 14) Source(14, 17) + SourceIndex(0) -4 >Emitted(16, 16) Source(14, 19) + SourceIndex(0) -5 >Emitted(16, 17) Source(14, 20) + SourceIndex(0) -6 >Emitted(16, 22) Source(14, 25) + SourceIndex(0) -7 >Emitted(16, 23) Source(14, 26) + SourceIndex(0) ---- ->>>//# sourceMappingURL=http://www.typescriptlang.org/outputdir_module_multifolder/test.js.map=================================================================== JsFile: test.js mapUrl: http://www.typescriptlang.org/test.js.map sourceRoot: diff --git a/tests/baselines/reference/project/maprootUrlModuleMultifolderSpecifyOutputFile/node/ref/m1.d.ts b/tests/baselines/reference/project/maprootUrlModuleMultifolderSpecifyOutputFile/node/ref/m1.d.ts deleted file mode 100644 index 4a53b24b156..00000000000 --- a/tests/baselines/reference/project/maprootUrlModuleMultifolderSpecifyOutputFile/node/ref/m1.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -export declare var m1_a1: number; -export declare class m1_c1 { - m1_c1_p1: number; -} -export declare var m1_instance1: m1_c1; -export declare function m1_f1(): m1_c1; diff --git a/tests/baselines/reference/project/maprootUrlModuleMultifolderSpecifyOutputFile/node/ref/m1.js b/tests/baselines/reference/project/maprootUrlModuleMultifolderSpecifyOutputFile/node/ref/m1.js deleted file mode 100644 index 7b14808a067..00000000000 --- a/tests/baselines/reference/project/maprootUrlModuleMultifolderSpecifyOutputFile/node/ref/m1.js +++ /dev/null @@ -1,13 +0,0 @@ -exports.m1_a1 = 10; -var m1_c1 = (function () { - function m1_c1() { - } - return m1_c1; -})(); -exports.m1_c1 = m1_c1; -exports.m1_instance1 = new m1_c1(); -function m1_f1() { - return exports.m1_instance1; -} -exports.m1_f1 = m1_f1; -//# sourceMappingURL=http://www.typescriptlang.org/outputdir_module_multifolder/ref/m1.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlModuleMultifolderSpecifyOutputFile/node/ref/m1.js.map b/tests/baselines/reference/project/maprootUrlModuleMultifolderSpecifyOutputFile/node/ref/m1.js.map deleted file mode 100644 index c88465aaec4..00000000000 --- a/tests/baselines/reference/project/maprootUrlModuleMultifolderSpecifyOutputFile/node/ref/m1.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"m1.js","sourceRoot":"","sources":["file:///tests/cases/projects/outputdir_module_multifolder/ref/m1.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1"],"mappings":"AAAW,aAAK,GAAG,EAAE,CAAC;AACtB;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAFY,aAAK,QAEjB,CAAA;AAEU,oBAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACIE,MAAMA,CAACA,oBAAYA,CAACA;AACxBA,CAACA;AAFe,aAAK,QAEpB,CAAA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlModuleMultifolderSpecifyOutputFile/node/test.d.ts b/tests/baselines/reference/project/maprootUrlModuleMultifolderSpecifyOutputFile/node/test.d.ts deleted file mode 100644 index 4afd4e69f2d..00000000000 --- a/tests/baselines/reference/project/maprootUrlModuleMultifolderSpecifyOutputFile/node/test.d.ts +++ /dev/null @@ -1,10 +0,0 @@ -import m1 = require("ref/m1"); -import m2 = require("../outputdir_module_multifolder_ref/m2"); -export declare var a1: number; -export declare class c1 { - p1: number; -} -export declare var instance1: c1; -export declare function f1(): c1; -export declare var a2: typeof m1.m1_c1; -export declare var a3: typeof m2.m2_c1; diff --git a/tests/baselines/reference/project/maprootUrlModuleMultifolderSpecifyOutputFile/node/test.js b/tests/baselines/reference/project/maprootUrlModuleMultifolderSpecifyOutputFile/node/test.js deleted file mode 100644 index b9191db7d5f..00000000000 --- a/tests/baselines/reference/project/maprootUrlModuleMultifolderSpecifyOutputFile/node/test.js +++ /dev/null @@ -1,17 +0,0 @@ -var m1 = require("ref/m1"); -var m2 = require("../outputdir_module_multifolder_ref/m2"); -exports.a1 = 10; -var c1 = (function () { - function c1() { - } - return c1; -})(); -exports.c1 = c1; -exports.instance1 = new c1(); -function f1() { - return exports.instance1; -} -exports.f1 = f1; -exports.a2 = m1.m1_c1; -exports.a3 = m2.m2_c1; -//# sourceMappingURL=http://www.typescriptlang.org/outputdir_module_multifolder/test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlModuleMultifolderSpecifyOutputFile/node/test.js.map b/tests/baselines/reference/project/maprootUrlModuleMultifolderSpecifyOutputFile/node/test.js.map deleted file mode 100644 index 6a18d277c10..00000000000 --- a/tests/baselines/reference/project/maprootUrlModuleMultifolderSpecifyOutputFile/node/test.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"test.js","sourceRoot":"","sources":["file:///tests/cases/projects/outputdir_module_multifolder/test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AAAA,IAAO,EAAE,WAAW,QAAQ,CAAC,CAAC;AAC9B,IAAO,EAAE,WAAW,wCAAwC,CAAC,CAAC;AACnD,UAAE,GAAG,EAAE,CAAC;AACnB;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAFY,UAAE,KAEd,CAAA;AAEU,iBAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AAChC;IACIE,MAAMA,CAACA,iBAASA,CAACA;AACrBA,CAACA;AAFe,UAAE,KAEjB,CAAA;AAEU,UAAE,GAAG,EAAE,CAAC,KAAK,CAAC;AACd,UAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlModuleSimpleSpecifyOutputFile/amd/m1.d.ts b/tests/baselines/reference/project/maprootUrlModuleSimpleSpecifyOutputFile/amd/m1.d.ts deleted file mode 100644 index 4a53b24b156..00000000000 --- a/tests/baselines/reference/project/maprootUrlModuleSimpleSpecifyOutputFile/amd/m1.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -export declare var m1_a1: number; -export declare class m1_c1 { - m1_c1_p1: number; -} -export declare var m1_instance1: m1_c1; -export declare function m1_f1(): m1_c1; diff --git a/tests/baselines/reference/project/maprootUrlModuleSimpleSpecifyOutputFile/amd/m1.js b/tests/baselines/reference/project/maprootUrlModuleSimpleSpecifyOutputFile/amd/m1.js deleted file mode 100644 index 1a4d200cdcb..00000000000 --- a/tests/baselines/reference/project/maprootUrlModuleSimpleSpecifyOutputFile/amd/m1.js +++ /dev/null @@ -1,15 +0,0 @@ -define(["require", "exports"], function (require, exports) { - exports.m1_a1 = 10; - var m1_c1 = (function () { - function m1_c1() { - } - return m1_c1; - })(); - exports.m1_c1 = m1_c1; - exports.m1_instance1 = new m1_c1(); - function m1_f1() { - return exports.m1_instance1; - } - exports.m1_f1 = m1_f1; -}); -//# sourceMappingURL=http://www.typescriptlang.org/m1.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlModuleSimpleSpecifyOutputFile/amd/m1.js.map b/tests/baselines/reference/project/maprootUrlModuleSimpleSpecifyOutputFile/amd/m1.js.map deleted file mode 100644 index d2270dfd2ce..00000000000 --- a/tests/baselines/reference/project/maprootUrlModuleSimpleSpecifyOutputFile/amd/m1.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"m1.js","sourceRoot":"","sources":["file:///tests/cases/projects/outputdir_module_simple/m1.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1"],"mappings":";IAAW,aAAK,GAAG,EAAE,CAAC;IACtB;QAAAA;QAEAC,CAACA;QAADD,YAACA;IAADA,CAACA,AAFD,IAEC;IAFY,aAAK,QAEjB,CAAA;IAEU,oBAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACIE,MAAMA,CAACA,oBAAYA,CAACA;IACxBA,CAACA;IAFe,aAAK,QAEpB,CAAA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlModuleSimpleSpecifyOutputFile/amd/maprootUrlModuleSimpleSpecifyOutputFile.json b/tests/baselines/reference/project/maprootUrlModuleSimpleSpecifyOutputFile/amd/maprootUrlModuleSimpleSpecifyOutputFile.json index e636ce61f7e..1dbc9780b95 100644 --- a/tests/baselines/reference/project/maprootUrlModuleSimpleSpecifyOutputFile/amd/maprootUrlModuleSimpleSpecifyOutputFile.json +++ b/tests/baselines/reference/project/maprootUrlModuleSimpleSpecifyOutputFile/amd/maprootUrlModuleSimpleSpecifyOutputFile.json @@ -15,12 +15,6 @@ "test.ts" ], "emittedFiles": [ - "m1.js.map", - "m1.js", - "m1.d.ts", - "test.js.map", - "test.js", - "test.d.ts", "bin/test.js.map", "bin/test.js", "bin/test.d.ts" diff --git a/tests/baselines/reference/project/maprootUrlModuleSimpleSpecifyOutputFile/amd/maprootUrlModuleSimpleSpecifyOutputFile.sourcemap.txt b/tests/baselines/reference/project/maprootUrlModuleSimpleSpecifyOutputFile/amd/maprootUrlModuleSimpleSpecifyOutputFile.sourcemap.txt index 2268138862a..36bfe394d39 100644 --- a/tests/baselines/reference/project/maprootUrlModuleSimpleSpecifyOutputFile/amd/maprootUrlModuleSimpleSpecifyOutputFile.sourcemap.txt +++ b/tests/baselines/reference/project/maprootUrlModuleSimpleSpecifyOutputFile/amd/maprootUrlModuleSimpleSpecifyOutputFile.sourcemap.txt @@ -1,375 +1,4 @@ =================================================================== -JsFile: m1.js -mapUrl: http://www.typescriptlang.org/m1.js.map -sourceRoot: -sources: file:///tests/cases/projects/outputdir_module_simple/m1.ts -=================================================================== -------------------------------------------------------------------- -emittedFile:m1.js -sourceFile:file:///tests/cases/projects/outputdir_module_simple/m1.ts -------------------------------------------------------------------- ->>>define(["require", "exports"], function (require, exports) { ->>> exports.m1_a1 = 10; -1 >^^^^ -2 > ^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^-> -1 >export var -2 > m1_a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(2, 5) Source(1, 12) + SourceIndex(0) -2 >Emitted(2, 18) Source(1, 17) + SourceIndex(0) -3 >Emitted(2, 21) Source(1, 20) + SourceIndex(0) -4 >Emitted(2, 23) Source(1, 22) + SourceIndex(0) -5 >Emitted(2, 24) Source(1, 23) + SourceIndex(0) ---- ->>> var m1_c1 = (function () { -1->^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^^^^-> -1-> - > -1->Emitted(3, 5) Source(2, 1) + SourceIndex(0) ---- ->>> function m1_c1() { -1->^^^^^^^^ -2 > ^^-> -1-> -1->Emitted(4, 9) Source(2, 1) + SourceIndex(0) name (m1_c1) ---- ->>> } -1->^^^^^^^^ -2 > ^ -3 > ^^^^^^^^^^^^^-> -1->export class m1_c1 { - > public m1_c1_p1: number; - > -2 > } -1->Emitted(5, 9) Source(4, 1) + SourceIndex(0) name (m1_c1.constructor) -2 >Emitted(5, 10) Source(4, 2) + SourceIndex(0) name (m1_c1.constructor) ---- ->>> return m1_c1; -1->^^^^^^^^ -2 > ^^^^^^^^^^^^ -1-> -2 > } -1->Emitted(6, 9) Source(4, 1) + SourceIndex(0) name (m1_c1) -2 >Emitted(6, 21) Source(4, 2) + SourceIndex(0) name (m1_c1) ---- ->>> })(); -1 >^^^^ -2 > ^ -3 > -4 > ^^^^ -5 > ^^^^^^^^^^^^^^^^^^-> -1 > -2 > } -3 > -4 > export class m1_c1 { - > public m1_c1_p1: number; - > } -1 >Emitted(7, 5) Source(4, 1) + SourceIndex(0) name (m1_c1) -2 >Emitted(7, 6) Source(4, 2) + SourceIndex(0) name (m1_c1) -3 >Emitted(7, 6) Source(2, 1) + SourceIndex(0) -4 >Emitted(7, 10) Source(4, 2) + SourceIndex(0) ---- ->>> exports.m1_c1 = m1_c1; -1->^^^^ -2 > ^^^^^^^^^^^^^ -3 > ^^^^^^^^ -4 > ^ -5 > ^^^^^^^^^^^^^^-> -1-> -2 > m1_c1 -3 > { - > public m1_c1_p1: number; - > } -4 > -1->Emitted(8, 5) Source(2, 14) + SourceIndex(0) -2 >Emitted(8, 18) Source(2, 19) + SourceIndex(0) -3 >Emitted(8, 26) Source(4, 2) + SourceIndex(0) -4 >Emitted(8, 27) Source(4, 2) + SourceIndex(0) ---- ->>> exports.m1_instance1 = new m1_c1(); -1->^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^^^ -5 > ^^^^^ -6 > ^^ -7 > ^ -1-> - > - >export var -2 > m1_instance1 -3 > = -4 > new -5 > m1_c1 -6 > () -7 > ; -1->Emitted(9, 5) Source(6, 12) + SourceIndex(0) -2 >Emitted(9, 25) Source(6, 24) + SourceIndex(0) -3 >Emitted(9, 28) Source(6, 27) + SourceIndex(0) -4 >Emitted(9, 32) Source(6, 31) + SourceIndex(0) -5 >Emitted(9, 37) Source(6, 36) + SourceIndex(0) -6 >Emitted(9, 39) Source(6, 38) + SourceIndex(0) -7 >Emitted(9, 40) Source(6, 39) + SourceIndex(0) ---- ->>> function m1_f1() { -1 >^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -1 >Emitted(10, 5) Source(7, 1) + SourceIndex(0) ---- ->>> return exports.m1_instance1; -1->^^^^^^^^ -2 > ^^^^^^ -3 > ^ -4 > ^^^^^^^^^^^^^^^^^^^^ -5 > ^ -1->export function m1_f1() { - > -2 > return -3 > -4 > m1_instance1 -5 > ; -1->Emitted(11, 9) Source(8, 5) + SourceIndex(0) name (m1_f1) -2 >Emitted(11, 15) Source(8, 11) + SourceIndex(0) name (m1_f1) -3 >Emitted(11, 16) Source(8, 12) + SourceIndex(0) name (m1_f1) -4 >Emitted(11, 36) Source(8, 24) + SourceIndex(0) name (m1_f1) -5 >Emitted(11, 37) Source(8, 25) + SourceIndex(0) name (m1_f1) ---- ->>> } -1 >^^^^ -2 > ^ -3 > ^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -2 > } -1 >Emitted(12, 5) Source(9, 1) + SourceIndex(0) name (m1_f1) -2 >Emitted(12, 6) Source(9, 2) + SourceIndex(0) name (m1_f1) ---- ->>> exports.m1_f1 = m1_f1; -1->^^^^ -2 > ^^^^^^^^^^^^^ -3 > ^^^^^^^^ -4 > ^ -1-> -2 > m1_f1 -3 > () { - > return m1_instance1; - > } -4 > -1->Emitted(13, 5) Source(7, 17) + SourceIndex(0) -2 >Emitted(13, 18) Source(7, 22) + SourceIndex(0) -3 >Emitted(13, 26) Source(9, 2) + SourceIndex(0) -4 >Emitted(13, 27) Source(9, 2) + SourceIndex(0) ---- ->>>}); ->>>//# sourceMappingURL=http://www.typescriptlang.org/m1.js.map=================================================================== -JsFile: test.js -mapUrl: http://www.typescriptlang.org/test.js.map -sourceRoot: -sources: file:///tests/cases/projects/outputdir_module_simple/test.ts -=================================================================== -------------------------------------------------------------------- -emittedFile:test.js -sourceFile:file:///tests/cases/projects/outputdir_module_simple/test.ts -------------------------------------------------------------------- ->>>define(["require", "exports", "m1"], function (require, exports, m1) { ->>> exports.a1 = 10; -1 >^^^^ -2 > ^^^^^^^^^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^-> -1 >import m1 = require("m1"); - >export var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(2, 5) Source(2, 12) + SourceIndex(0) -2 >Emitted(2, 15) Source(2, 14) + SourceIndex(0) -3 >Emitted(2, 18) Source(2, 17) + SourceIndex(0) -4 >Emitted(2, 20) Source(2, 19) + SourceIndex(0) -5 >Emitted(2, 21) Source(2, 20) + SourceIndex(0) ---- ->>> var c1 = (function () { -1->^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^-> -1-> - > -1->Emitted(3, 5) Source(3, 1) + SourceIndex(0) ---- ->>> function c1() { -1->^^^^^^^^ -2 > ^^-> -1-> -1->Emitted(4, 9) Source(3, 1) + SourceIndex(0) name (c1) ---- ->>> } -1->^^^^^^^^ -2 > ^ -3 > ^^^^^^^^^^-> -1->export class c1 { - > public p1: number; - > -2 > } -1->Emitted(5, 9) Source(5, 1) + SourceIndex(0) name (c1.constructor) -2 >Emitted(5, 10) Source(5, 2) + SourceIndex(0) name (c1.constructor) ---- ->>> return c1; -1->^^^^^^^^ -2 > ^^^^^^^^^ -1-> -2 > } -1->Emitted(6, 9) Source(5, 1) + SourceIndex(0) name (c1) -2 >Emitted(6, 18) Source(5, 2) + SourceIndex(0) name (c1) ---- ->>> })(); -1 >^^^^ -2 > ^ -3 > -4 > ^^^^ -5 > ^^^^^^^^^^^^-> -1 > -2 > } -3 > -4 > export class c1 { - > public p1: number; - > } -1 >Emitted(7, 5) Source(5, 1) + SourceIndex(0) name (c1) -2 >Emitted(7, 6) Source(5, 2) + SourceIndex(0) name (c1) -3 >Emitted(7, 6) Source(3, 1) + SourceIndex(0) -4 >Emitted(7, 10) Source(5, 2) + SourceIndex(0) ---- ->>> exports.c1 = c1; -1->^^^^ -2 > ^^^^^^^^^^ -3 > ^^^^^ -4 > ^ -5 > ^^^^^^^^^^^^^^-> -1-> -2 > c1 -3 > { - > public p1: number; - > } -4 > -1->Emitted(8, 5) Source(3, 14) + SourceIndex(0) -2 >Emitted(8, 15) Source(3, 16) + SourceIndex(0) -3 >Emitted(8, 20) Source(5, 2) + SourceIndex(0) -4 >Emitted(8, 21) Source(5, 2) + SourceIndex(0) ---- ->>> exports.instance1 = new c1(); -1->^^^^ -2 > ^^^^^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^^^ -5 > ^^ -6 > ^^ -7 > ^ -1-> - > - >export var -2 > instance1 -3 > = -4 > new -5 > c1 -6 > () -7 > ; -1->Emitted(9, 5) Source(7, 12) + SourceIndex(0) -2 >Emitted(9, 22) Source(7, 21) + SourceIndex(0) -3 >Emitted(9, 25) Source(7, 24) + SourceIndex(0) -4 >Emitted(9, 29) Source(7, 28) + SourceIndex(0) -5 >Emitted(9, 31) Source(7, 30) + SourceIndex(0) -6 >Emitted(9, 33) Source(7, 32) + SourceIndex(0) -7 >Emitted(9, 34) Source(7, 33) + SourceIndex(0) ---- ->>> function f1() { -1 >^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -1 >Emitted(10, 5) Source(8, 1) + SourceIndex(0) ---- ->>> return exports.instance1; -1->^^^^^^^^ -2 > ^^^^^^ -3 > ^ -4 > ^^^^^^^^^^^^^^^^^ -5 > ^ -1->export function f1() { - > -2 > return -3 > -4 > instance1 -5 > ; -1->Emitted(11, 9) Source(9, 5) + SourceIndex(0) name (f1) -2 >Emitted(11, 15) Source(9, 11) + SourceIndex(0) name (f1) -3 >Emitted(11, 16) Source(9, 12) + SourceIndex(0) name (f1) -4 >Emitted(11, 33) Source(9, 21) + SourceIndex(0) name (f1) -5 >Emitted(11, 34) Source(9, 22) + SourceIndex(0) name (f1) ---- ->>> } -1 >^^^^ -2 > ^ -3 > ^^^^^^^^^^^^^^^^-> -1 > - > -2 > } -1 >Emitted(12, 5) Source(10, 1) + SourceIndex(0) name (f1) -2 >Emitted(12, 6) Source(10, 2) + SourceIndex(0) name (f1) ---- ->>> exports.f1 = f1; -1->^^^^ -2 > ^^^^^^^^^^ -3 > ^^^^^ -4 > ^ -5 > ^^^^^^^-> -1-> -2 > f1 -3 > () { - > return instance1; - > } -4 > -1->Emitted(13, 5) Source(8, 17) + SourceIndex(0) -2 >Emitted(13, 15) Source(8, 19) + SourceIndex(0) -3 >Emitted(13, 20) Source(10, 2) + SourceIndex(0) -4 >Emitted(13, 21) Source(10, 2) + SourceIndex(0) ---- ->>> exports.a2 = m1.m1_c1; -1->^^^^ -2 > ^^^^^^^^^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^ -7 > ^ -1-> - > - >export var -2 > a2 -3 > = -4 > m1 -5 > . -6 > m1_c1 -7 > ; -1->Emitted(14, 5) Source(12, 12) + SourceIndex(0) -2 >Emitted(14, 15) Source(12, 14) + SourceIndex(0) -3 >Emitted(14, 18) Source(12, 17) + SourceIndex(0) -4 >Emitted(14, 20) Source(12, 19) + SourceIndex(0) -5 >Emitted(14, 21) Source(12, 20) + SourceIndex(0) -6 >Emitted(14, 26) Source(12, 25) + SourceIndex(0) -7 >Emitted(14, 27) Source(12, 26) + SourceIndex(0) ---- ->>>}); ->>>//# sourceMappingURL=http://www.typescriptlang.org/test.js.map=================================================================== JsFile: test.js mapUrl: http://www.typescriptlang.org/test.js.map sourceRoot: diff --git a/tests/baselines/reference/project/maprootUrlModuleSimpleSpecifyOutputFile/amd/test.d.ts b/tests/baselines/reference/project/maprootUrlModuleSimpleSpecifyOutputFile/amd/test.d.ts deleted file mode 100644 index 250d2615a79..00000000000 --- a/tests/baselines/reference/project/maprootUrlModuleSimpleSpecifyOutputFile/amd/test.d.ts +++ /dev/null @@ -1,8 +0,0 @@ -import m1 = require("m1"); -export declare var a1: number; -export declare class c1 { - p1: number; -} -export declare var instance1: c1; -export declare function f1(): c1; -export declare var a2: typeof m1.m1_c1; diff --git a/tests/baselines/reference/project/maprootUrlModuleSimpleSpecifyOutputFile/amd/test.js b/tests/baselines/reference/project/maprootUrlModuleSimpleSpecifyOutputFile/amd/test.js deleted file mode 100644 index d752d7f8395..00000000000 --- a/tests/baselines/reference/project/maprootUrlModuleSimpleSpecifyOutputFile/amd/test.js +++ /dev/null @@ -1,16 +0,0 @@ -define(["require", "exports", "m1"], function (require, exports, m1) { - exports.a1 = 10; - var c1 = (function () { - function c1() { - } - return c1; - })(); - exports.c1 = c1; - exports.instance1 = new c1(); - function f1() { - return exports.instance1; - } - exports.f1 = f1; - exports.a2 = m1.m1_c1; -}); -//# sourceMappingURL=http://www.typescriptlang.org/test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlModuleSimpleSpecifyOutputFile/amd/test.js.map b/tests/baselines/reference/project/maprootUrlModuleSimpleSpecifyOutputFile/amd/test.js.map deleted file mode 100644 index de9d99184d2..00000000000 --- a/tests/baselines/reference/project/maprootUrlModuleSimpleSpecifyOutputFile/amd/test.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"test.js","sourceRoot":"","sources":["file:///tests/cases/projects/outputdir_module_simple/test.ts"],"names":["c1","c1.constructor","f1"],"mappings":";IACW,UAAE,GAAG,EAAE,CAAC;IACnB;QAAAA;QAEAC,CAACA;QAADD,SAACA;IAADA,CAACA,AAFD,IAEC;IAFY,UAAE,KAEd,CAAA;IAEU,iBAAS,GAAG,IAAI,EAAE,EAAE,CAAC;IAChC;QACIE,MAAMA,CAACA,iBAASA,CAACA;IACrBA,CAACA;IAFe,UAAE,KAEjB,CAAA;IAEU,UAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlModuleSimpleSpecifyOutputFile/node/m1.d.ts b/tests/baselines/reference/project/maprootUrlModuleSimpleSpecifyOutputFile/node/m1.d.ts deleted file mode 100644 index 4a53b24b156..00000000000 --- a/tests/baselines/reference/project/maprootUrlModuleSimpleSpecifyOutputFile/node/m1.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -export declare var m1_a1: number; -export declare class m1_c1 { - m1_c1_p1: number; -} -export declare var m1_instance1: m1_c1; -export declare function m1_f1(): m1_c1; diff --git a/tests/baselines/reference/project/maprootUrlModuleSimpleSpecifyOutputFile/node/m1.js b/tests/baselines/reference/project/maprootUrlModuleSimpleSpecifyOutputFile/node/m1.js deleted file mode 100644 index 02ca4ab81c7..00000000000 --- a/tests/baselines/reference/project/maprootUrlModuleSimpleSpecifyOutputFile/node/m1.js +++ /dev/null @@ -1,13 +0,0 @@ -exports.m1_a1 = 10; -var m1_c1 = (function () { - function m1_c1() { - } - return m1_c1; -})(); -exports.m1_c1 = m1_c1; -exports.m1_instance1 = new m1_c1(); -function m1_f1() { - return exports.m1_instance1; -} -exports.m1_f1 = m1_f1; -//# sourceMappingURL=http://www.typescriptlang.org/m1.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlModuleSimpleSpecifyOutputFile/node/m1.js.map b/tests/baselines/reference/project/maprootUrlModuleSimpleSpecifyOutputFile/node/m1.js.map deleted file mode 100644 index bc2e2667bcd..00000000000 --- a/tests/baselines/reference/project/maprootUrlModuleSimpleSpecifyOutputFile/node/m1.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"m1.js","sourceRoot":"","sources":["file:///tests/cases/projects/outputdir_module_simple/m1.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1"],"mappings":"AAAW,aAAK,GAAG,EAAE,CAAC;AACtB;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAFY,aAAK,QAEjB,CAAA;AAEU,oBAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACIE,MAAMA,CAACA,oBAAYA,CAACA;AACxBA,CAACA;AAFe,aAAK,QAEpB,CAAA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlModuleSimpleSpecifyOutputFile/node/maprootUrlModuleSimpleSpecifyOutputFile.json b/tests/baselines/reference/project/maprootUrlModuleSimpleSpecifyOutputFile/node/maprootUrlModuleSimpleSpecifyOutputFile.json index e636ce61f7e..1dbc9780b95 100644 --- a/tests/baselines/reference/project/maprootUrlModuleSimpleSpecifyOutputFile/node/maprootUrlModuleSimpleSpecifyOutputFile.json +++ b/tests/baselines/reference/project/maprootUrlModuleSimpleSpecifyOutputFile/node/maprootUrlModuleSimpleSpecifyOutputFile.json @@ -15,12 +15,6 @@ "test.ts" ], "emittedFiles": [ - "m1.js.map", - "m1.js", - "m1.d.ts", - "test.js.map", - "test.js", - "test.d.ts", "bin/test.js.map", "bin/test.js", "bin/test.d.ts" diff --git a/tests/baselines/reference/project/maprootUrlModuleSimpleSpecifyOutputFile/node/maprootUrlModuleSimpleSpecifyOutputFile.sourcemap.txt b/tests/baselines/reference/project/maprootUrlModuleSimpleSpecifyOutputFile/node/maprootUrlModuleSimpleSpecifyOutputFile.sourcemap.txt index 889ac03323b..ef808a08b3f 100644 --- a/tests/baselines/reference/project/maprootUrlModuleSimpleSpecifyOutputFile/node/maprootUrlModuleSimpleSpecifyOutputFile.sourcemap.txt +++ b/tests/baselines/reference/project/maprootUrlModuleSimpleSpecifyOutputFile/node/maprootUrlModuleSimpleSpecifyOutputFile.sourcemap.txt @@ -1,396 +1,4 @@ =================================================================== -JsFile: m1.js -mapUrl: http://www.typescriptlang.org/m1.js.map -sourceRoot: -sources: file:///tests/cases/projects/outputdir_module_simple/m1.ts -=================================================================== -------------------------------------------------------------------- -emittedFile:m1.js -sourceFile:file:///tests/cases/projects/outputdir_module_simple/m1.ts -------------------------------------------------------------------- ->>>exports.m1_a1 = 10; -1 > -2 >^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^-> -1 >export var -2 >m1_a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(1, 1) Source(1, 12) + SourceIndex(0) -2 >Emitted(1, 14) Source(1, 17) + SourceIndex(0) -3 >Emitted(1, 17) Source(1, 20) + SourceIndex(0) -4 >Emitted(1, 19) Source(1, 22) + SourceIndex(0) -5 >Emitted(1, 20) Source(1, 23) + SourceIndex(0) ---- ->>>var m1_c1 = (function () { -1-> -2 >^^^^^^^^^^^^^^^^^^^^^^^-> -1-> - > -1->Emitted(2, 1) Source(2, 1) + SourceIndex(0) ---- ->>> function m1_c1() { -1->^^^^ -2 > ^^-> -1-> -1->Emitted(3, 5) Source(2, 1) + SourceIndex(0) name (m1_c1) ---- ->>> } -1->^^^^ -2 > ^ -3 > ^^^^^^^^^^^^^-> -1->export class m1_c1 { - > public m1_c1_p1: number; - > -2 > } -1->Emitted(4, 5) Source(4, 1) + SourceIndex(0) name (m1_c1.constructor) -2 >Emitted(4, 6) Source(4, 2) + SourceIndex(0) name (m1_c1.constructor) ---- ->>> return m1_c1; -1->^^^^ -2 > ^^^^^^^^^^^^ -1-> -2 > } -1->Emitted(5, 5) Source(4, 1) + SourceIndex(0) name (m1_c1) -2 >Emitted(5, 17) Source(4, 2) + SourceIndex(0) name (m1_c1) ---- ->>>})(); -1 > -2 >^ -3 > -4 > ^^^^ -5 > ^^^^^^^^^^^^^^^^^^-> -1 > -2 >} -3 > -4 > export class m1_c1 { - > public m1_c1_p1: number; - > } -1 >Emitted(6, 1) Source(4, 1) + SourceIndex(0) name (m1_c1) -2 >Emitted(6, 2) Source(4, 2) + SourceIndex(0) name (m1_c1) -3 >Emitted(6, 2) Source(2, 1) + SourceIndex(0) -4 >Emitted(6, 6) Source(4, 2) + SourceIndex(0) ---- ->>>exports.m1_c1 = m1_c1; -1-> -2 >^^^^^^^^^^^^^ -3 > ^^^^^^^^ -4 > ^ -5 > ^^^^^^^^^^^^^^-> -1-> -2 >m1_c1 -3 > { - > public m1_c1_p1: number; - > } -4 > -1->Emitted(7, 1) Source(2, 14) + SourceIndex(0) -2 >Emitted(7, 14) Source(2, 19) + SourceIndex(0) -3 >Emitted(7, 22) Source(4, 2) + SourceIndex(0) -4 >Emitted(7, 23) Source(4, 2) + SourceIndex(0) ---- ->>>exports.m1_instance1 = new m1_c1(); -1-> -2 >^^^^^^^^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^^^ -5 > ^^^^^ -6 > ^^ -7 > ^ -1-> - > - >export var -2 >m1_instance1 -3 > = -4 > new -5 > m1_c1 -6 > () -7 > ; -1->Emitted(8, 1) Source(6, 12) + SourceIndex(0) -2 >Emitted(8, 21) Source(6, 24) + SourceIndex(0) -3 >Emitted(8, 24) Source(6, 27) + SourceIndex(0) -4 >Emitted(8, 28) Source(6, 31) + SourceIndex(0) -5 >Emitted(8, 33) Source(6, 36) + SourceIndex(0) -6 >Emitted(8, 35) Source(6, 38) + SourceIndex(0) -7 >Emitted(8, 36) Source(6, 39) + SourceIndex(0) ---- ->>>function m1_f1() { -1 > -2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -1 >Emitted(9, 1) Source(7, 1) + SourceIndex(0) ---- ->>> return exports.m1_instance1; -1->^^^^ -2 > ^^^^^^ -3 > ^ -4 > ^^^^^^^^^^^^^^^^^^^^ -5 > ^ -1->export function m1_f1() { - > -2 > return -3 > -4 > m1_instance1 -5 > ; -1->Emitted(10, 5) Source(8, 5) + SourceIndex(0) name (m1_f1) -2 >Emitted(10, 11) Source(8, 11) + SourceIndex(0) name (m1_f1) -3 >Emitted(10, 12) Source(8, 12) + SourceIndex(0) name (m1_f1) -4 >Emitted(10, 32) Source(8, 24) + SourceIndex(0) name (m1_f1) -5 >Emitted(10, 33) Source(8, 25) + SourceIndex(0) name (m1_f1) ---- ->>>} -1 > -2 >^ -3 > ^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -2 >} -1 >Emitted(11, 1) Source(9, 1) + SourceIndex(0) name (m1_f1) -2 >Emitted(11, 2) Source(9, 2) + SourceIndex(0) name (m1_f1) ---- ->>>exports.m1_f1 = m1_f1; -1-> -2 >^^^^^^^^^^^^^ -3 > ^^^^^^^^ -4 > ^ -5 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1-> -2 >m1_f1 -3 > () { - > return m1_instance1; - > } -4 > -1->Emitted(12, 1) Source(7, 17) + SourceIndex(0) -2 >Emitted(12, 14) Source(7, 22) + SourceIndex(0) -3 >Emitted(12, 22) Source(9, 2) + SourceIndex(0) -4 >Emitted(12, 23) Source(9, 2) + SourceIndex(0) ---- ->>>//# sourceMappingURL=http://www.typescriptlang.org/m1.js.map=================================================================== -JsFile: test.js -mapUrl: http://www.typescriptlang.org/test.js.map -sourceRoot: -sources: file:///tests/cases/projects/outputdir_module_simple/test.ts -=================================================================== -------------------------------------------------------------------- -emittedFile:test.js -sourceFile:file:///tests/cases/projects/outputdir_module_simple/test.ts -------------------------------------------------------------------- ->>>var m1 = require("m1"); -1 > -2 >^^^^ -3 > ^^ -4 > ^^^^^^^^^^^ -5 > ^^^^ -6 > ^ -7 > ^ -1 > -2 >import -3 > m1 -4 > = require( -5 > "m1" -6 > ) -7 > ; -1 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) -2 >Emitted(1, 5) Source(1, 8) + SourceIndex(0) -3 >Emitted(1, 7) Source(1, 10) + SourceIndex(0) -4 >Emitted(1, 18) Source(1, 21) + SourceIndex(0) -5 >Emitted(1, 22) Source(1, 25) + SourceIndex(0) -6 >Emitted(1, 23) Source(1, 26) + SourceIndex(0) -7 >Emitted(1, 24) Source(1, 27) + SourceIndex(0) ---- ->>>exports.a1 = 10; -1 > -2 >^^^^^^^^^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^-> -1 > - >export var -2 >a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(2, 1) Source(2, 12) + SourceIndex(0) -2 >Emitted(2, 11) Source(2, 14) + SourceIndex(0) -3 >Emitted(2, 14) Source(2, 17) + SourceIndex(0) -4 >Emitted(2, 16) Source(2, 19) + SourceIndex(0) -5 >Emitted(2, 17) Source(2, 20) + SourceIndex(0) ---- ->>>var c1 = (function () { -1-> -2 >^^^^^^^^^^^^^^^^^^^^-> -1-> - > -1->Emitted(3, 1) Source(3, 1) + SourceIndex(0) ---- ->>> function c1() { -1->^^^^ -2 > ^^-> -1-> -1->Emitted(4, 5) Source(3, 1) + SourceIndex(0) name (c1) ---- ->>> } -1->^^^^ -2 > ^ -3 > ^^^^^^^^^^-> -1->export class c1 { - > public p1: number; - > -2 > } -1->Emitted(5, 5) Source(5, 1) + SourceIndex(0) name (c1.constructor) -2 >Emitted(5, 6) Source(5, 2) + SourceIndex(0) name (c1.constructor) ---- ->>> return c1; -1->^^^^ -2 > ^^^^^^^^^ -1-> -2 > } -1->Emitted(6, 5) Source(5, 1) + SourceIndex(0) name (c1) -2 >Emitted(6, 14) Source(5, 2) + SourceIndex(0) name (c1) ---- ->>>})(); -1 > -2 >^ -3 > -4 > ^^^^ -5 > ^^^^^^^^^^^^-> -1 > -2 >} -3 > -4 > export class c1 { - > public p1: number; - > } -1 >Emitted(7, 1) Source(5, 1) + SourceIndex(0) name (c1) -2 >Emitted(7, 2) Source(5, 2) + SourceIndex(0) name (c1) -3 >Emitted(7, 2) Source(3, 1) + SourceIndex(0) -4 >Emitted(7, 6) Source(5, 2) + SourceIndex(0) ---- ->>>exports.c1 = c1; -1-> -2 >^^^^^^^^^^ -3 > ^^^^^ -4 > ^ -5 > ^^^^^^^^^^^^^^-> -1-> -2 >c1 -3 > { - > public p1: number; - > } -4 > -1->Emitted(8, 1) Source(3, 14) + SourceIndex(0) -2 >Emitted(8, 11) Source(3, 16) + SourceIndex(0) -3 >Emitted(8, 16) Source(5, 2) + SourceIndex(0) -4 >Emitted(8, 17) Source(5, 2) + SourceIndex(0) ---- ->>>exports.instance1 = new c1(); -1-> -2 >^^^^^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^^^ -5 > ^^ -6 > ^^ -7 > ^ -1-> - > - >export var -2 >instance1 -3 > = -4 > new -5 > c1 -6 > () -7 > ; -1->Emitted(9, 1) Source(7, 12) + SourceIndex(0) -2 >Emitted(9, 18) Source(7, 21) + SourceIndex(0) -3 >Emitted(9, 21) Source(7, 24) + SourceIndex(0) -4 >Emitted(9, 25) Source(7, 28) + SourceIndex(0) -5 >Emitted(9, 27) Source(7, 30) + SourceIndex(0) -6 >Emitted(9, 29) Source(7, 32) + SourceIndex(0) -7 >Emitted(9, 30) Source(7, 33) + SourceIndex(0) ---- ->>>function f1() { -1 > -2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -1 >Emitted(10, 1) Source(8, 1) + SourceIndex(0) ---- ->>> return exports.instance1; -1->^^^^ -2 > ^^^^^^ -3 > ^ -4 > ^^^^^^^^^^^^^^^^^ -5 > ^ -1->export function f1() { - > -2 > return -3 > -4 > instance1 -5 > ; -1->Emitted(11, 5) Source(9, 5) + SourceIndex(0) name (f1) -2 >Emitted(11, 11) Source(9, 11) + SourceIndex(0) name (f1) -3 >Emitted(11, 12) Source(9, 12) + SourceIndex(0) name (f1) -4 >Emitted(11, 29) Source(9, 21) + SourceIndex(0) name (f1) -5 >Emitted(11, 30) Source(9, 22) + SourceIndex(0) name (f1) ---- ->>>} -1 > -2 >^ -3 > ^^^^^^^^^^^^^^^^-> -1 > - > -2 >} -1 >Emitted(12, 1) Source(10, 1) + SourceIndex(0) name (f1) -2 >Emitted(12, 2) Source(10, 2) + SourceIndex(0) name (f1) ---- ->>>exports.f1 = f1; -1-> -2 >^^^^^^^^^^ -3 > ^^^^^ -4 > ^ -5 > ^^^^^^^-> -1-> -2 >f1 -3 > () { - > return instance1; - > } -4 > -1->Emitted(13, 1) Source(8, 17) + SourceIndex(0) -2 >Emitted(13, 11) Source(8, 19) + SourceIndex(0) -3 >Emitted(13, 16) Source(10, 2) + SourceIndex(0) -4 >Emitted(13, 17) Source(10, 2) + SourceIndex(0) ---- ->>>exports.a2 = m1.m1_c1; -1-> -2 >^^^^^^^^^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^ -7 > ^ -8 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1-> - > - >export var -2 >a2 -3 > = -4 > m1 -5 > . -6 > m1_c1 -7 > ; -1->Emitted(14, 1) Source(12, 12) + SourceIndex(0) -2 >Emitted(14, 11) Source(12, 14) + SourceIndex(0) -3 >Emitted(14, 14) Source(12, 17) + SourceIndex(0) -4 >Emitted(14, 16) Source(12, 19) + SourceIndex(0) -5 >Emitted(14, 17) Source(12, 20) + SourceIndex(0) -6 >Emitted(14, 22) Source(12, 25) + SourceIndex(0) -7 >Emitted(14, 23) Source(12, 26) + SourceIndex(0) ---- ->>>//# sourceMappingURL=http://www.typescriptlang.org/test.js.map=================================================================== JsFile: test.js mapUrl: http://www.typescriptlang.org/test.js.map sourceRoot: diff --git a/tests/baselines/reference/project/maprootUrlModuleSimpleSpecifyOutputFile/node/test.d.ts b/tests/baselines/reference/project/maprootUrlModuleSimpleSpecifyOutputFile/node/test.d.ts deleted file mode 100644 index 250d2615a79..00000000000 --- a/tests/baselines/reference/project/maprootUrlModuleSimpleSpecifyOutputFile/node/test.d.ts +++ /dev/null @@ -1,8 +0,0 @@ -import m1 = require("m1"); -export declare var a1: number; -export declare class c1 { - p1: number; -} -export declare var instance1: c1; -export declare function f1(): c1; -export declare var a2: typeof m1.m1_c1; diff --git a/tests/baselines/reference/project/maprootUrlModuleSimpleSpecifyOutputFile/node/test.js b/tests/baselines/reference/project/maprootUrlModuleSimpleSpecifyOutputFile/node/test.js deleted file mode 100644 index 1d5a32f0ad5..00000000000 --- a/tests/baselines/reference/project/maprootUrlModuleSimpleSpecifyOutputFile/node/test.js +++ /dev/null @@ -1,15 +0,0 @@ -var m1 = require("m1"); -exports.a1 = 10; -var c1 = (function () { - function c1() { - } - return c1; -})(); -exports.c1 = c1; -exports.instance1 = new c1(); -function f1() { - return exports.instance1; -} -exports.f1 = f1; -exports.a2 = m1.m1_c1; -//# sourceMappingURL=http://www.typescriptlang.org/test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlModuleSimpleSpecifyOutputFile/node/test.js.map b/tests/baselines/reference/project/maprootUrlModuleSimpleSpecifyOutputFile/node/test.js.map deleted file mode 100644 index b9c164bb732..00000000000 --- a/tests/baselines/reference/project/maprootUrlModuleSimpleSpecifyOutputFile/node/test.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"test.js","sourceRoot":"","sources":["file:///tests/cases/projects/outputdir_module_simple/test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AAAA,IAAO,EAAE,WAAW,IAAI,CAAC,CAAC;AACf,UAAE,GAAG,EAAE,CAAC;AACnB;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAFY,UAAE,KAEd,CAAA;AAEU,iBAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AAChC;IACIE,MAAMA,CAACA,iBAASA,CAACA;AACrBA,CAACA;AAFe,UAAE,KAEjB,CAAA;AAEU,UAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlModuleSubfolderSpecifyOutputFile/amd/maprootUrlModuleSubfolderSpecifyOutputFile.json b/tests/baselines/reference/project/maprootUrlModuleSubfolderSpecifyOutputFile/amd/maprootUrlModuleSubfolderSpecifyOutputFile.json index 05da8c15292..b33bd42f045 100644 --- a/tests/baselines/reference/project/maprootUrlModuleSubfolderSpecifyOutputFile/amd/maprootUrlModuleSubfolderSpecifyOutputFile.json +++ b/tests/baselines/reference/project/maprootUrlModuleSubfolderSpecifyOutputFile/amd/maprootUrlModuleSubfolderSpecifyOutputFile.json @@ -15,12 +15,6 @@ "test.ts" ], "emittedFiles": [ - "ref/m1.js.map", - "ref/m1.js", - "ref/m1.d.ts", - "test.js.map", - "test.js", - "test.d.ts", "bin/test.js.map", "bin/test.js", "bin/test.d.ts" diff --git a/tests/baselines/reference/project/maprootUrlModuleSubfolderSpecifyOutputFile/amd/maprootUrlModuleSubfolderSpecifyOutputFile.sourcemap.txt b/tests/baselines/reference/project/maprootUrlModuleSubfolderSpecifyOutputFile/amd/maprootUrlModuleSubfolderSpecifyOutputFile.sourcemap.txt index b547512c50d..617b90f7c81 100644 --- a/tests/baselines/reference/project/maprootUrlModuleSubfolderSpecifyOutputFile/amd/maprootUrlModuleSubfolderSpecifyOutputFile.sourcemap.txt +++ b/tests/baselines/reference/project/maprootUrlModuleSubfolderSpecifyOutputFile/amd/maprootUrlModuleSubfolderSpecifyOutputFile.sourcemap.txt @@ -1,375 +1,4 @@ =================================================================== -JsFile: m1.js -mapUrl: http://www.typescriptlang.org/ref/m1.js.map -sourceRoot: -sources: file:///tests/cases/projects/outputdir_module_subfolder/ref/m1.ts -=================================================================== -------------------------------------------------------------------- -emittedFile:ref/m1.js -sourceFile:file:///tests/cases/projects/outputdir_module_subfolder/ref/m1.ts -------------------------------------------------------------------- ->>>define(["require", "exports"], function (require, exports) { ->>> exports.m1_a1 = 10; -1 >^^^^ -2 > ^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^-> -1 >export var -2 > m1_a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(2, 5) Source(1, 12) + SourceIndex(0) -2 >Emitted(2, 18) Source(1, 17) + SourceIndex(0) -3 >Emitted(2, 21) Source(1, 20) + SourceIndex(0) -4 >Emitted(2, 23) Source(1, 22) + SourceIndex(0) -5 >Emitted(2, 24) Source(1, 23) + SourceIndex(0) ---- ->>> var m1_c1 = (function () { -1->^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^^^^-> -1-> - > -1->Emitted(3, 5) Source(2, 1) + SourceIndex(0) ---- ->>> function m1_c1() { -1->^^^^^^^^ -2 > ^^-> -1-> -1->Emitted(4, 9) Source(2, 1) + SourceIndex(0) name (m1_c1) ---- ->>> } -1->^^^^^^^^ -2 > ^ -3 > ^^^^^^^^^^^^^-> -1->export class m1_c1 { - > public m1_c1_p1: number; - > -2 > } -1->Emitted(5, 9) Source(4, 1) + SourceIndex(0) name (m1_c1.constructor) -2 >Emitted(5, 10) Source(4, 2) + SourceIndex(0) name (m1_c1.constructor) ---- ->>> return m1_c1; -1->^^^^^^^^ -2 > ^^^^^^^^^^^^ -1-> -2 > } -1->Emitted(6, 9) Source(4, 1) + SourceIndex(0) name (m1_c1) -2 >Emitted(6, 21) Source(4, 2) + SourceIndex(0) name (m1_c1) ---- ->>> })(); -1 >^^^^ -2 > ^ -3 > -4 > ^^^^ -5 > ^^^^^^^^^^^^^^^^^^-> -1 > -2 > } -3 > -4 > export class m1_c1 { - > public m1_c1_p1: number; - > } -1 >Emitted(7, 5) Source(4, 1) + SourceIndex(0) name (m1_c1) -2 >Emitted(7, 6) Source(4, 2) + SourceIndex(0) name (m1_c1) -3 >Emitted(7, 6) Source(2, 1) + SourceIndex(0) -4 >Emitted(7, 10) Source(4, 2) + SourceIndex(0) ---- ->>> exports.m1_c1 = m1_c1; -1->^^^^ -2 > ^^^^^^^^^^^^^ -3 > ^^^^^^^^ -4 > ^ -5 > ^^^^^^^^^^^^^^-> -1-> -2 > m1_c1 -3 > { - > public m1_c1_p1: number; - > } -4 > -1->Emitted(8, 5) Source(2, 14) + SourceIndex(0) -2 >Emitted(8, 18) Source(2, 19) + SourceIndex(0) -3 >Emitted(8, 26) Source(4, 2) + SourceIndex(0) -4 >Emitted(8, 27) Source(4, 2) + SourceIndex(0) ---- ->>> exports.m1_instance1 = new m1_c1(); -1->^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^^^ -5 > ^^^^^ -6 > ^^ -7 > ^ -1-> - > - >export var -2 > m1_instance1 -3 > = -4 > new -5 > m1_c1 -6 > () -7 > ; -1->Emitted(9, 5) Source(6, 12) + SourceIndex(0) -2 >Emitted(9, 25) Source(6, 24) + SourceIndex(0) -3 >Emitted(9, 28) Source(6, 27) + SourceIndex(0) -4 >Emitted(9, 32) Source(6, 31) + SourceIndex(0) -5 >Emitted(9, 37) Source(6, 36) + SourceIndex(0) -6 >Emitted(9, 39) Source(6, 38) + SourceIndex(0) -7 >Emitted(9, 40) Source(6, 39) + SourceIndex(0) ---- ->>> function m1_f1() { -1 >^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -1 >Emitted(10, 5) Source(7, 1) + SourceIndex(0) ---- ->>> return exports.m1_instance1; -1->^^^^^^^^ -2 > ^^^^^^ -3 > ^ -4 > ^^^^^^^^^^^^^^^^^^^^ -5 > ^ -1->export function m1_f1() { - > -2 > return -3 > -4 > m1_instance1 -5 > ; -1->Emitted(11, 9) Source(8, 5) + SourceIndex(0) name (m1_f1) -2 >Emitted(11, 15) Source(8, 11) + SourceIndex(0) name (m1_f1) -3 >Emitted(11, 16) Source(8, 12) + SourceIndex(0) name (m1_f1) -4 >Emitted(11, 36) Source(8, 24) + SourceIndex(0) name (m1_f1) -5 >Emitted(11, 37) Source(8, 25) + SourceIndex(0) name (m1_f1) ---- ->>> } -1 >^^^^ -2 > ^ -3 > ^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -2 > } -1 >Emitted(12, 5) Source(9, 1) + SourceIndex(0) name (m1_f1) -2 >Emitted(12, 6) Source(9, 2) + SourceIndex(0) name (m1_f1) ---- ->>> exports.m1_f1 = m1_f1; -1->^^^^ -2 > ^^^^^^^^^^^^^ -3 > ^^^^^^^^ -4 > ^ -1-> -2 > m1_f1 -3 > () { - > return m1_instance1; - > } -4 > -1->Emitted(13, 5) Source(7, 17) + SourceIndex(0) -2 >Emitted(13, 18) Source(7, 22) + SourceIndex(0) -3 >Emitted(13, 26) Source(9, 2) + SourceIndex(0) -4 >Emitted(13, 27) Source(9, 2) + SourceIndex(0) ---- ->>>}); ->>>//# sourceMappingURL=http://www.typescriptlang.org/ref/m1.js.map=================================================================== -JsFile: test.js -mapUrl: http://www.typescriptlang.org/test.js.map -sourceRoot: -sources: file:///tests/cases/projects/outputdir_module_subfolder/test.ts -=================================================================== -------------------------------------------------------------------- -emittedFile:test.js -sourceFile:file:///tests/cases/projects/outputdir_module_subfolder/test.ts -------------------------------------------------------------------- ->>>define(["require", "exports", "ref/m1"], function (require, exports, m1) { ->>> exports.a1 = 10; -1 >^^^^ -2 > ^^^^^^^^^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^-> -1 >import m1 = require("ref/m1"); - >export var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(2, 5) Source(2, 12) + SourceIndex(0) -2 >Emitted(2, 15) Source(2, 14) + SourceIndex(0) -3 >Emitted(2, 18) Source(2, 17) + SourceIndex(0) -4 >Emitted(2, 20) Source(2, 19) + SourceIndex(0) -5 >Emitted(2, 21) Source(2, 20) + SourceIndex(0) ---- ->>> var c1 = (function () { -1->^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^-> -1-> - > -1->Emitted(3, 5) Source(3, 1) + SourceIndex(0) ---- ->>> function c1() { -1->^^^^^^^^ -2 > ^^-> -1-> -1->Emitted(4, 9) Source(3, 1) + SourceIndex(0) name (c1) ---- ->>> } -1->^^^^^^^^ -2 > ^ -3 > ^^^^^^^^^^-> -1->export class c1 { - > public p1: number; - > -2 > } -1->Emitted(5, 9) Source(5, 1) + SourceIndex(0) name (c1.constructor) -2 >Emitted(5, 10) Source(5, 2) + SourceIndex(0) name (c1.constructor) ---- ->>> return c1; -1->^^^^^^^^ -2 > ^^^^^^^^^ -1-> -2 > } -1->Emitted(6, 9) Source(5, 1) + SourceIndex(0) name (c1) -2 >Emitted(6, 18) Source(5, 2) + SourceIndex(0) name (c1) ---- ->>> })(); -1 >^^^^ -2 > ^ -3 > -4 > ^^^^ -5 > ^^^^^^^^^^^^-> -1 > -2 > } -3 > -4 > export class c1 { - > public p1: number; - > } -1 >Emitted(7, 5) Source(5, 1) + SourceIndex(0) name (c1) -2 >Emitted(7, 6) Source(5, 2) + SourceIndex(0) name (c1) -3 >Emitted(7, 6) Source(3, 1) + SourceIndex(0) -4 >Emitted(7, 10) Source(5, 2) + SourceIndex(0) ---- ->>> exports.c1 = c1; -1->^^^^ -2 > ^^^^^^^^^^ -3 > ^^^^^ -4 > ^ -5 > ^^^^^^^^^^^^^^-> -1-> -2 > c1 -3 > { - > public p1: number; - > } -4 > -1->Emitted(8, 5) Source(3, 14) + SourceIndex(0) -2 >Emitted(8, 15) Source(3, 16) + SourceIndex(0) -3 >Emitted(8, 20) Source(5, 2) + SourceIndex(0) -4 >Emitted(8, 21) Source(5, 2) + SourceIndex(0) ---- ->>> exports.instance1 = new c1(); -1->^^^^ -2 > ^^^^^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^^^ -5 > ^^ -6 > ^^ -7 > ^ -1-> - > - >export var -2 > instance1 -3 > = -4 > new -5 > c1 -6 > () -7 > ; -1->Emitted(9, 5) Source(7, 12) + SourceIndex(0) -2 >Emitted(9, 22) Source(7, 21) + SourceIndex(0) -3 >Emitted(9, 25) Source(7, 24) + SourceIndex(0) -4 >Emitted(9, 29) Source(7, 28) + SourceIndex(0) -5 >Emitted(9, 31) Source(7, 30) + SourceIndex(0) -6 >Emitted(9, 33) Source(7, 32) + SourceIndex(0) -7 >Emitted(9, 34) Source(7, 33) + SourceIndex(0) ---- ->>> function f1() { -1 >^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -1 >Emitted(10, 5) Source(8, 1) + SourceIndex(0) ---- ->>> return exports.instance1; -1->^^^^^^^^ -2 > ^^^^^^ -3 > ^ -4 > ^^^^^^^^^^^^^^^^^ -5 > ^ -1->export function f1() { - > -2 > return -3 > -4 > instance1 -5 > ; -1->Emitted(11, 9) Source(9, 5) + SourceIndex(0) name (f1) -2 >Emitted(11, 15) Source(9, 11) + SourceIndex(0) name (f1) -3 >Emitted(11, 16) Source(9, 12) + SourceIndex(0) name (f1) -4 >Emitted(11, 33) Source(9, 21) + SourceIndex(0) name (f1) -5 >Emitted(11, 34) Source(9, 22) + SourceIndex(0) name (f1) ---- ->>> } -1 >^^^^ -2 > ^ -3 > ^^^^^^^^^^^^^^^^-> -1 > - > -2 > } -1 >Emitted(12, 5) Source(10, 1) + SourceIndex(0) name (f1) -2 >Emitted(12, 6) Source(10, 2) + SourceIndex(0) name (f1) ---- ->>> exports.f1 = f1; -1->^^^^ -2 > ^^^^^^^^^^ -3 > ^^^^^ -4 > ^ -5 > ^^^^^^^-> -1-> -2 > f1 -3 > () { - > return instance1; - > } -4 > -1->Emitted(13, 5) Source(8, 17) + SourceIndex(0) -2 >Emitted(13, 15) Source(8, 19) + SourceIndex(0) -3 >Emitted(13, 20) Source(10, 2) + SourceIndex(0) -4 >Emitted(13, 21) Source(10, 2) + SourceIndex(0) ---- ->>> exports.a2 = m1.m1_c1; -1->^^^^ -2 > ^^^^^^^^^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^ -7 > ^ -1-> - > - >export var -2 > a2 -3 > = -4 > m1 -5 > . -6 > m1_c1 -7 > ; -1->Emitted(14, 5) Source(12, 12) + SourceIndex(0) -2 >Emitted(14, 15) Source(12, 14) + SourceIndex(0) -3 >Emitted(14, 18) Source(12, 17) + SourceIndex(0) -4 >Emitted(14, 20) Source(12, 19) + SourceIndex(0) -5 >Emitted(14, 21) Source(12, 20) + SourceIndex(0) -6 >Emitted(14, 26) Source(12, 25) + SourceIndex(0) -7 >Emitted(14, 27) Source(12, 26) + SourceIndex(0) ---- ->>>}); ->>>//# sourceMappingURL=http://www.typescriptlang.org/test.js.map=================================================================== JsFile: test.js mapUrl: http://www.typescriptlang.org/test.js.map sourceRoot: diff --git a/tests/baselines/reference/project/maprootUrlModuleSubfolderSpecifyOutputFile/amd/ref/m1.d.ts b/tests/baselines/reference/project/maprootUrlModuleSubfolderSpecifyOutputFile/amd/ref/m1.d.ts deleted file mode 100644 index 4a53b24b156..00000000000 --- a/tests/baselines/reference/project/maprootUrlModuleSubfolderSpecifyOutputFile/amd/ref/m1.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -export declare var m1_a1: number; -export declare class m1_c1 { - m1_c1_p1: number; -} -export declare var m1_instance1: m1_c1; -export declare function m1_f1(): m1_c1; diff --git a/tests/baselines/reference/project/maprootUrlModuleSubfolderSpecifyOutputFile/amd/ref/m1.js b/tests/baselines/reference/project/maprootUrlModuleSubfolderSpecifyOutputFile/amd/ref/m1.js deleted file mode 100644 index 73309eabe30..00000000000 --- a/tests/baselines/reference/project/maprootUrlModuleSubfolderSpecifyOutputFile/amd/ref/m1.js +++ /dev/null @@ -1,15 +0,0 @@ -define(["require", "exports"], function (require, exports) { - exports.m1_a1 = 10; - var m1_c1 = (function () { - function m1_c1() { - } - return m1_c1; - })(); - exports.m1_c1 = m1_c1; - exports.m1_instance1 = new m1_c1(); - function m1_f1() { - return exports.m1_instance1; - } - exports.m1_f1 = m1_f1; -}); -//# sourceMappingURL=http://www.typescriptlang.org/ref/m1.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlModuleSubfolderSpecifyOutputFile/amd/ref/m1.js.map b/tests/baselines/reference/project/maprootUrlModuleSubfolderSpecifyOutputFile/amd/ref/m1.js.map deleted file mode 100644 index ec8a7690d47..00000000000 --- a/tests/baselines/reference/project/maprootUrlModuleSubfolderSpecifyOutputFile/amd/ref/m1.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"m1.js","sourceRoot":"","sources":["file:///tests/cases/projects/outputdir_module_subfolder/ref/m1.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1"],"mappings":";IAAW,aAAK,GAAG,EAAE,CAAC;IACtB;QAAAA;QAEAC,CAACA;QAADD,YAACA;IAADA,CAACA,AAFD,IAEC;IAFY,aAAK,QAEjB,CAAA;IAEU,oBAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACIE,MAAMA,CAACA,oBAAYA,CAACA;IACxBA,CAACA;IAFe,aAAK,QAEpB,CAAA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlModuleSubfolderSpecifyOutputFile/amd/test.d.ts b/tests/baselines/reference/project/maprootUrlModuleSubfolderSpecifyOutputFile/amd/test.d.ts deleted file mode 100644 index a61d8541048..00000000000 --- a/tests/baselines/reference/project/maprootUrlModuleSubfolderSpecifyOutputFile/amd/test.d.ts +++ /dev/null @@ -1,8 +0,0 @@ -import m1 = require("ref/m1"); -export declare var a1: number; -export declare class c1 { - p1: number; -} -export declare var instance1: c1; -export declare function f1(): c1; -export declare var a2: typeof m1.m1_c1; diff --git a/tests/baselines/reference/project/maprootUrlModuleSubfolderSpecifyOutputFile/amd/test.js b/tests/baselines/reference/project/maprootUrlModuleSubfolderSpecifyOutputFile/amd/test.js deleted file mode 100644 index 270604ea7cb..00000000000 --- a/tests/baselines/reference/project/maprootUrlModuleSubfolderSpecifyOutputFile/amd/test.js +++ /dev/null @@ -1,16 +0,0 @@ -define(["require", "exports", "ref/m1"], function (require, exports, m1) { - exports.a1 = 10; - var c1 = (function () { - function c1() { - } - return c1; - })(); - exports.c1 = c1; - exports.instance1 = new c1(); - function f1() { - return exports.instance1; - } - exports.f1 = f1; - exports.a2 = m1.m1_c1; -}); -//# sourceMappingURL=http://www.typescriptlang.org/test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlModuleSubfolderSpecifyOutputFile/amd/test.js.map b/tests/baselines/reference/project/maprootUrlModuleSubfolderSpecifyOutputFile/amd/test.js.map deleted file mode 100644 index 35691a873b8..00000000000 --- a/tests/baselines/reference/project/maprootUrlModuleSubfolderSpecifyOutputFile/amd/test.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"test.js","sourceRoot":"","sources":["file:///tests/cases/projects/outputdir_module_subfolder/test.ts"],"names":["c1","c1.constructor","f1"],"mappings":";IACW,UAAE,GAAG,EAAE,CAAC;IACnB;QAAAA;QAEAC,CAACA;QAADD,SAACA;IAADA,CAACA,AAFD,IAEC;IAFY,UAAE,KAEd,CAAA;IAEU,iBAAS,GAAG,IAAI,EAAE,EAAE,CAAC;IAChC;QACIE,MAAMA,CAACA,iBAASA,CAACA;IACrBA,CAACA;IAFe,UAAE,KAEjB,CAAA;IAEU,UAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlModuleSubfolderSpecifyOutputFile/node/maprootUrlModuleSubfolderSpecifyOutputFile.json b/tests/baselines/reference/project/maprootUrlModuleSubfolderSpecifyOutputFile/node/maprootUrlModuleSubfolderSpecifyOutputFile.json index 05da8c15292..b33bd42f045 100644 --- a/tests/baselines/reference/project/maprootUrlModuleSubfolderSpecifyOutputFile/node/maprootUrlModuleSubfolderSpecifyOutputFile.json +++ b/tests/baselines/reference/project/maprootUrlModuleSubfolderSpecifyOutputFile/node/maprootUrlModuleSubfolderSpecifyOutputFile.json @@ -15,12 +15,6 @@ "test.ts" ], "emittedFiles": [ - "ref/m1.js.map", - "ref/m1.js", - "ref/m1.d.ts", - "test.js.map", - "test.js", - "test.d.ts", "bin/test.js.map", "bin/test.js", "bin/test.d.ts" diff --git a/tests/baselines/reference/project/maprootUrlModuleSubfolderSpecifyOutputFile/node/maprootUrlModuleSubfolderSpecifyOutputFile.sourcemap.txt b/tests/baselines/reference/project/maprootUrlModuleSubfolderSpecifyOutputFile/node/maprootUrlModuleSubfolderSpecifyOutputFile.sourcemap.txt index 3bb1f02d820..16bcb98e00c 100644 --- a/tests/baselines/reference/project/maprootUrlModuleSubfolderSpecifyOutputFile/node/maprootUrlModuleSubfolderSpecifyOutputFile.sourcemap.txt +++ b/tests/baselines/reference/project/maprootUrlModuleSubfolderSpecifyOutputFile/node/maprootUrlModuleSubfolderSpecifyOutputFile.sourcemap.txt @@ -1,396 +1,4 @@ =================================================================== -JsFile: m1.js -mapUrl: http://www.typescriptlang.org/ref/m1.js.map -sourceRoot: -sources: file:///tests/cases/projects/outputdir_module_subfolder/ref/m1.ts -=================================================================== -------------------------------------------------------------------- -emittedFile:ref/m1.js -sourceFile:file:///tests/cases/projects/outputdir_module_subfolder/ref/m1.ts -------------------------------------------------------------------- ->>>exports.m1_a1 = 10; -1 > -2 >^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^-> -1 >export var -2 >m1_a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(1, 1) Source(1, 12) + SourceIndex(0) -2 >Emitted(1, 14) Source(1, 17) + SourceIndex(0) -3 >Emitted(1, 17) Source(1, 20) + SourceIndex(0) -4 >Emitted(1, 19) Source(1, 22) + SourceIndex(0) -5 >Emitted(1, 20) Source(1, 23) + SourceIndex(0) ---- ->>>var m1_c1 = (function () { -1-> -2 >^^^^^^^^^^^^^^^^^^^^^^^-> -1-> - > -1->Emitted(2, 1) Source(2, 1) + SourceIndex(0) ---- ->>> function m1_c1() { -1->^^^^ -2 > ^^-> -1-> -1->Emitted(3, 5) Source(2, 1) + SourceIndex(0) name (m1_c1) ---- ->>> } -1->^^^^ -2 > ^ -3 > ^^^^^^^^^^^^^-> -1->export class m1_c1 { - > public m1_c1_p1: number; - > -2 > } -1->Emitted(4, 5) Source(4, 1) + SourceIndex(0) name (m1_c1.constructor) -2 >Emitted(4, 6) Source(4, 2) + SourceIndex(0) name (m1_c1.constructor) ---- ->>> return m1_c1; -1->^^^^ -2 > ^^^^^^^^^^^^ -1-> -2 > } -1->Emitted(5, 5) Source(4, 1) + SourceIndex(0) name (m1_c1) -2 >Emitted(5, 17) Source(4, 2) + SourceIndex(0) name (m1_c1) ---- ->>>})(); -1 > -2 >^ -3 > -4 > ^^^^ -5 > ^^^^^^^^^^^^^^^^^^-> -1 > -2 >} -3 > -4 > export class m1_c1 { - > public m1_c1_p1: number; - > } -1 >Emitted(6, 1) Source(4, 1) + SourceIndex(0) name (m1_c1) -2 >Emitted(6, 2) Source(4, 2) + SourceIndex(0) name (m1_c1) -3 >Emitted(6, 2) Source(2, 1) + SourceIndex(0) -4 >Emitted(6, 6) Source(4, 2) + SourceIndex(0) ---- ->>>exports.m1_c1 = m1_c1; -1-> -2 >^^^^^^^^^^^^^ -3 > ^^^^^^^^ -4 > ^ -5 > ^^^^^^^^^^^^^^-> -1-> -2 >m1_c1 -3 > { - > public m1_c1_p1: number; - > } -4 > -1->Emitted(7, 1) Source(2, 14) + SourceIndex(0) -2 >Emitted(7, 14) Source(2, 19) + SourceIndex(0) -3 >Emitted(7, 22) Source(4, 2) + SourceIndex(0) -4 >Emitted(7, 23) Source(4, 2) + SourceIndex(0) ---- ->>>exports.m1_instance1 = new m1_c1(); -1-> -2 >^^^^^^^^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^^^ -5 > ^^^^^ -6 > ^^ -7 > ^ -1-> - > - >export var -2 >m1_instance1 -3 > = -4 > new -5 > m1_c1 -6 > () -7 > ; -1->Emitted(8, 1) Source(6, 12) + SourceIndex(0) -2 >Emitted(8, 21) Source(6, 24) + SourceIndex(0) -3 >Emitted(8, 24) Source(6, 27) + SourceIndex(0) -4 >Emitted(8, 28) Source(6, 31) + SourceIndex(0) -5 >Emitted(8, 33) Source(6, 36) + SourceIndex(0) -6 >Emitted(8, 35) Source(6, 38) + SourceIndex(0) -7 >Emitted(8, 36) Source(6, 39) + SourceIndex(0) ---- ->>>function m1_f1() { -1 > -2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -1 >Emitted(9, 1) Source(7, 1) + SourceIndex(0) ---- ->>> return exports.m1_instance1; -1->^^^^ -2 > ^^^^^^ -3 > ^ -4 > ^^^^^^^^^^^^^^^^^^^^ -5 > ^ -1->export function m1_f1() { - > -2 > return -3 > -4 > m1_instance1 -5 > ; -1->Emitted(10, 5) Source(8, 5) + SourceIndex(0) name (m1_f1) -2 >Emitted(10, 11) Source(8, 11) + SourceIndex(0) name (m1_f1) -3 >Emitted(10, 12) Source(8, 12) + SourceIndex(0) name (m1_f1) -4 >Emitted(10, 32) Source(8, 24) + SourceIndex(0) name (m1_f1) -5 >Emitted(10, 33) Source(8, 25) + SourceIndex(0) name (m1_f1) ---- ->>>} -1 > -2 >^ -3 > ^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -2 >} -1 >Emitted(11, 1) Source(9, 1) + SourceIndex(0) name (m1_f1) -2 >Emitted(11, 2) Source(9, 2) + SourceIndex(0) name (m1_f1) ---- ->>>exports.m1_f1 = m1_f1; -1-> -2 >^^^^^^^^^^^^^ -3 > ^^^^^^^^ -4 > ^ -5 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1-> -2 >m1_f1 -3 > () { - > return m1_instance1; - > } -4 > -1->Emitted(12, 1) Source(7, 17) + SourceIndex(0) -2 >Emitted(12, 14) Source(7, 22) + SourceIndex(0) -3 >Emitted(12, 22) Source(9, 2) + SourceIndex(0) -4 >Emitted(12, 23) Source(9, 2) + SourceIndex(0) ---- ->>>//# sourceMappingURL=http://www.typescriptlang.org/ref/m1.js.map=================================================================== -JsFile: test.js -mapUrl: http://www.typescriptlang.org/test.js.map -sourceRoot: -sources: file:///tests/cases/projects/outputdir_module_subfolder/test.ts -=================================================================== -------------------------------------------------------------------- -emittedFile:test.js -sourceFile:file:///tests/cases/projects/outputdir_module_subfolder/test.ts -------------------------------------------------------------------- ->>>var m1 = require("ref/m1"); -1 > -2 >^^^^ -3 > ^^ -4 > ^^^^^^^^^^^ -5 > ^^^^^^^^ -6 > ^ -7 > ^ -1 > -2 >import -3 > m1 -4 > = require( -5 > "ref/m1" -6 > ) -7 > ; -1 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) -2 >Emitted(1, 5) Source(1, 8) + SourceIndex(0) -3 >Emitted(1, 7) Source(1, 10) + SourceIndex(0) -4 >Emitted(1, 18) Source(1, 21) + SourceIndex(0) -5 >Emitted(1, 26) Source(1, 29) + SourceIndex(0) -6 >Emitted(1, 27) Source(1, 30) + SourceIndex(0) -7 >Emitted(1, 28) Source(1, 31) + SourceIndex(0) ---- ->>>exports.a1 = 10; -1 > -2 >^^^^^^^^^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^-> -1 > - >export var -2 >a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(2, 1) Source(2, 12) + SourceIndex(0) -2 >Emitted(2, 11) Source(2, 14) + SourceIndex(0) -3 >Emitted(2, 14) Source(2, 17) + SourceIndex(0) -4 >Emitted(2, 16) Source(2, 19) + SourceIndex(0) -5 >Emitted(2, 17) Source(2, 20) + SourceIndex(0) ---- ->>>var c1 = (function () { -1-> -2 >^^^^^^^^^^^^^^^^^^^^-> -1-> - > -1->Emitted(3, 1) Source(3, 1) + SourceIndex(0) ---- ->>> function c1() { -1->^^^^ -2 > ^^-> -1-> -1->Emitted(4, 5) Source(3, 1) + SourceIndex(0) name (c1) ---- ->>> } -1->^^^^ -2 > ^ -3 > ^^^^^^^^^^-> -1->export class c1 { - > public p1: number; - > -2 > } -1->Emitted(5, 5) Source(5, 1) + SourceIndex(0) name (c1.constructor) -2 >Emitted(5, 6) Source(5, 2) + SourceIndex(0) name (c1.constructor) ---- ->>> return c1; -1->^^^^ -2 > ^^^^^^^^^ -1-> -2 > } -1->Emitted(6, 5) Source(5, 1) + SourceIndex(0) name (c1) -2 >Emitted(6, 14) Source(5, 2) + SourceIndex(0) name (c1) ---- ->>>})(); -1 > -2 >^ -3 > -4 > ^^^^ -5 > ^^^^^^^^^^^^-> -1 > -2 >} -3 > -4 > export class c1 { - > public p1: number; - > } -1 >Emitted(7, 1) Source(5, 1) + SourceIndex(0) name (c1) -2 >Emitted(7, 2) Source(5, 2) + SourceIndex(0) name (c1) -3 >Emitted(7, 2) Source(3, 1) + SourceIndex(0) -4 >Emitted(7, 6) Source(5, 2) + SourceIndex(0) ---- ->>>exports.c1 = c1; -1-> -2 >^^^^^^^^^^ -3 > ^^^^^ -4 > ^ -5 > ^^^^^^^^^^^^^^-> -1-> -2 >c1 -3 > { - > public p1: number; - > } -4 > -1->Emitted(8, 1) Source(3, 14) + SourceIndex(0) -2 >Emitted(8, 11) Source(3, 16) + SourceIndex(0) -3 >Emitted(8, 16) Source(5, 2) + SourceIndex(0) -4 >Emitted(8, 17) Source(5, 2) + SourceIndex(0) ---- ->>>exports.instance1 = new c1(); -1-> -2 >^^^^^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^^^ -5 > ^^ -6 > ^^ -7 > ^ -1-> - > - >export var -2 >instance1 -3 > = -4 > new -5 > c1 -6 > () -7 > ; -1->Emitted(9, 1) Source(7, 12) + SourceIndex(0) -2 >Emitted(9, 18) Source(7, 21) + SourceIndex(0) -3 >Emitted(9, 21) Source(7, 24) + SourceIndex(0) -4 >Emitted(9, 25) Source(7, 28) + SourceIndex(0) -5 >Emitted(9, 27) Source(7, 30) + SourceIndex(0) -6 >Emitted(9, 29) Source(7, 32) + SourceIndex(0) -7 >Emitted(9, 30) Source(7, 33) + SourceIndex(0) ---- ->>>function f1() { -1 > -2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -1 >Emitted(10, 1) Source(8, 1) + SourceIndex(0) ---- ->>> return exports.instance1; -1->^^^^ -2 > ^^^^^^ -3 > ^ -4 > ^^^^^^^^^^^^^^^^^ -5 > ^ -1->export function f1() { - > -2 > return -3 > -4 > instance1 -5 > ; -1->Emitted(11, 5) Source(9, 5) + SourceIndex(0) name (f1) -2 >Emitted(11, 11) Source(9, 11) + SourceIndex(0) name (f1) -3 >Emitted(11, 12) Source(9, 12) + SourceIndex(0) name (f1) -4 >Emitted(11, 29) Source(9, 21) + SourceIndex(0) name (f1) -5 >Emitted(11, 30) Source(9, 22) + SourceIndex(0) name (f1) ---- ->>>} -1 > -2 >^ -3 > ^^^^^^^^^^^^^^^^-> -1 > - > -2 >} -1 >Emitted(12, 1) Source(10, 1) + SourceIndex(0) name (f1) -2 >Emitted(12, 2) Source(10, 2) + SourceIndex(0) name (f1) ---- ->>>exports.f1 = f1; -1-> -2 >^^^^^^^^^^ -3 > ^^^^^ -4 > ^ -5 > ^^^^^^^-> -1-> -2 >f1 -3 > () { - > return instance1; - > } -4 > -1->Emitted(13, 1) Source(8, 17) + SourceIndex(0) -2 >Emitted(13, 11) Source(8, 19) + SourceIndex(0) -3 >Emitted(13, 16) Source(10, 2) + SourceIndex(0) -4 >Emitted(13, 17) Source(10, 2) + SourceIndex(0) ---- ->>>exports.a2 = m1.m1_c1; -1-> -2 >^^^^^^^^^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^ -7 > ^ -8 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1-> - > - >export var -2 >a2 -3 > = -4 > m1 -5 > . -6 > m1_c1 -7 > ; -1->Emitted(14, 1) Source(12, 12) + SourceIndex(0) -2 >Emitted(14, 11) Source(12, 14) + SourceIndex(0) -3 >Emitted(14, 14) Source(12, 17) + SourceIndex(0) -4 >Emitted(14, 16) Source(12, 19) + SourceIndex(0) -5 >Emitted(14, 17) Source(12, 20) + SourceIndex(0) -6 >Emitted(14, 22) Source(12, 25) + SourceIndex(0) -7 >Emitted(14, 23) Source(12, 26) + SourceIndex(0) ---- ->>>//# sourceMappingURL=http://www.typescriptlang.org/test.js.map=================================================================== JsFile: test.js mapUrl: http://www.typescriptlang.org/test.js.map sourceRoot: diff --git a/tests/baselines/reference/project/maprootUrlModuleSubfolderSpecifyOutputFile/node/ref/m1.d.ts b/tests/baselines/reference/project/maprootUrlModuleSubfolderSpecifyOutputFile/node/ref/m1.d.ts deleted file mode 100644 index 4a53b24b156..00000000000 --- a/tests/baselines/reference/project/maprootUrlModuleSubfolderSpecifyOutputFile/node/ref/m1.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -export declare var m1_a1: number; -export declare class m1_c1 { - m1_c1_p1: number; -} -export declare var m1_instance1: m1_c1; -export declare function m1_f1(): m1_c1; diff --git a/tests/baselines/reference/project/maprootUrlModuleSubfolderSpecifyOutputFile/node/ref/m1.js b/tests/baselines/reference/project/maprootUrlModuleSubfolderSpecifyOutputFile/node/ref/m1.js deleted file mode 100644 index 8f31dc2aaa2..00000000000 --- a/tests/baselines/reference/project/maprootUrlModuleSubfolderSpecifyOutputFile/node/ref/m1.js +++ /dev/null @@ -1,13 +0,0 @@ -exports.m1_a1 = 10; -var m1_c1 = (function () { - function m1_c1() { - } - return m1_c1; -})(); -exports.m1_c1 = m1_c1; -exports.m1_instance1 = new m1_c1(); -function m1_f1() { - return exports.m1_instance1; -} -exports.m1_f1 = m1_f1; -//# sourceMappingURL=http://www.typescriptlang.org/ref/m1.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlModuleSubfolderSpecifyOutputFile/node/ref/m1.js.map b/tests/baselines/reference/project/maprootUrlModuleSubfolderSpecifyOutputFile/node/ref/m1.js.map deleted file mode 100644 index 95de442e92d..00000000000 --- a/tests/baselines/reference/project/maprootUrlModuleSubfolderSpecifyOutputFile/node/ref/m1.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"m1.js","sourceRoot":"","sources":["file:///tests/cases/projects/outputdir_module_subfolder/ref/m1.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1"],"mappings":"AAAW,aAAK,GAAG,EAAE,CAAC;AACtB;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAFY,aAAK,QAEjB,CAAA;AAEU,oBAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACIE,MAAMA,CAACA,oBAAYA,CAACA;AACxBA,CAACA;AAFe,aAAK,QAEpB,CAAA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlModuleSubfolderSpecifyOutputFile/node/test.d.ts b/tests/baselines/reference/project/maprootUrlModuleSubfolderSpecifyOutputFile/node/test.d.ts deleted file mode 100644 index a61d8541048..00000000000 --- a/tests/baselines/reference/project/maprootUrlModuleSubfolderSpecifyOutputFile/node/test.d.ts +++ /dev/null @@ -1,8 +0,0 @@ -import m1 = require("ref/m1"); -export declare var a1: number; -export declare class c1 { - p1: number; -} -export declare var instance1: c1; -export declare function f1(): c1; -export declare var a2: typeof m1.m1_c1; diff --git a/tests/baselines/reference/project/maprootUrlModuleSubfolderSpecifyOutputFile/node/test.js b/tests/baselines/reference/project/maprootUrlModuleSubfolderSpecifyOutputFile/node/test.js deleted file mode 100644 index 9bb4ed0180a..00000000000 --- a/tests/baselines/reference/project/maprootUrlModuleSubfolderSpecifyOutputFile/node/test.js +++ /dev/null @@ -1,15 +0,0 @@ -var m1 = require("ref/m1"); -exports.a1 = 10; -var c1 = (function () { - function c1() { - } - return c1; -})(); -exports.c1 = c1; -exports.instance1 = new c1(); -function f1() { - return exports.instance1; -} -exports.f1 = f1; -exports.a2 = m1.m1_c1; -//# sourceMappingURL=http://www.typescriptlang.org/test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlModuleSubfolderSpecifyOutputFile/node/test.js.map b/tests/baselines/reference/project/maprootUrlModuleSubfolderSpecifyOutputFile/node/test.js.map deleted file mode 100644 index fee2f4cb129..00000000000 --- a/tests/baselines/reference/project/maprootUrlModuleSubfolderSpecifyOutputFile/node/test.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"test.js","sourceRoot":"","sources":["file:///tests/cases/projects/outputdir_module_subfolder/test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AAAA,IAAO,EAAE,WAAW,QAAQ,CAAC,CAAC;AACnB,UAAE,GAAG,EAAE,CAAC;AACnB;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAFY,UAAE,KAEd,CAAA;AAEU,iBAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AAChC;IACIE,MAAMA,CAACA,iBAASA,CAACA;AACrBA,CAACA;AAFe,UAAE,KAEjB,CAAA;AAEU,UAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFile/amd/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFile.json b/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFile/amd/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFile.json index c36f3ade5e0..2de7a33388a 100644 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFile/amd/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFile.json +++ b/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFile/amd/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFile.json @@ -17,9 +17,6 @@ "test.ts" ], "emittedFiles": [ - "ref/m2.js.map", - "ref/m2.js", - "ref/m2.d.ts", "bin/test.js.map", "bin/test.js", "bin/test.d.ts" diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFile/amd/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFile.sourcemap.txt b/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFile/amd/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFile.sourcemap.txt index 65ffacd46fc..1a75ab0b601 100644 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFile/amd/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFile.sourcemap.txt +++ b/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFile/amd/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFile.sourcemap.txt @@ -1,176 +1,4 @@ =================================================================== -JsFile: m2.js -mapUrl: http://www.typescriptlang.org/ref/m2.js.map -sourceRoot: http://typescript.codeplex.com/ -sources: ref/m2.ts -=================================================================== -------------------------------------------------------------------- -emittedFile:ref/m2.js -sourceFile:ref/m2.ts -------------------------------------------------------------------- ->>>define(["require", "exports"], function (require, exports) { ->>> exports.m2_a1 = 10; -1 >^^^^ -2 > ^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^-> -1 >export var -2 > m2_a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(2, 5) Source(1, 12) + SourceIndex(0) -2 >Emitted(2, 18) Source(1, 17) + SourceIndex(0) -3 >Emitted(2, 21) Source(1, 20) + SourceIndex(0) -4 >Emitted(2, 23) Source(1, 22) + SourceIndex(0) -5 >Emitted(2, 24) Source(1, 23) + SourceIndex(0) ---- ->>> var m2_c1 = (function () { -1->^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^^^^-> -1-> - > -1->Emitted(3, 5) Source(2, 1) + SourceIndex(0) ---- ->>> function m2_c1() { -1->^^^^^^^^ -2 > ^^-> -1-> -1->Emitted(4, 9) Source(2, 1) + SourceIndex(0) name (m2_c1) ---- ->>> } -1->^^^^^^^^ -2 > ^ -3 > ^^^^^^^^^^^^^-> -1->export class m2_c1 { - > public m2_c1_p1: number; - > -2 > } -1->Emitted(5, 9) Source(4, 1) + SourceIndex(0) name (m2_c1.constructor) -2 >Emitted(5, 10) Source(4, 2) + SourceIndex(0) name (m2_c1.constructor) ---- ->>> return m2_c1; -1->^^^^^^^^ -2 > ^^^^^^^^^^^^ -1-> -2 > } -1->Emitted(6, 9) Source(4, 1) + SourceIndex(0) name (m2_c1) -2 >Emitted(6, 21) Source(4, 2) + SourceIndex(0) name (m2_c1) ---- ->>> })(); -1 >^^^^ -2 > ^ -3 > -4 > ^^^^ -5 > ^^^^^^^^^^^^^^^^^^-> -1 > -2 > } -3 > -4 > export class m2_c1 { - > public m2_c1_p1: number; - > } -1 >Emitted(7, 5) Source(4, 1) + SourceIndex(0) name (m2_c1) -2 >Emitted(7, 6) Source(4, 2) + SourceIndex(0) name (m2_c1) -3 >Emitted(7, 6) Source(2, 1) + SourceIndex(0) -4 >Emitted(7, 10) Source(4, 2) + SourceIndex(0) ---- ->>> exports.m2_c1 = m2_c1; -1->^^^^ -2 > ^^^^^^^^^^^^^ -3 > ^^^^^^^^ -4 > ^ -5 > ^^^^^^^^^^^^^^-> -1-> -2 > m2_c1 -3 > { - > public m2_c1_p1: number; - > } -4 > -1->Emitted(8, 5) Source(2, 14) + SourceIndex(0) -2 >Emitted(8, 18) Source(2, 19) + SourceIndex(0) -3 >Emitted(8, 26) Source(4, 2) + SourceIndex(0) -4 >Emitted(8, 27) Source(4, 2) + SourceIndex(0) ---- ->>> exports.m2_instance1 = new m2_c1(); -1->^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^^^ -5 > ^^^^^ -6 > ^^ -7 > ^ -1-> - > - >export var -2 > m2_instance1 -3 > = -4 > new -5 > m2_c1 -6 > () -7 > ; -1->Emitted(9, 5) Source(6, 12) + SourceIndex(0) -2 >Emitted(9, 25) Source(6, 24) + SourceIndex(0) -3 >Emitted(9, 28) Source(6, 27) + SourceIndex(0) -4 >Emitted(9, 32) Source(6, 31) + SourceIndex(0) -5 >Emitted(9, 37) Source(6, 36) + SourceIndex(0) -6 >Emitted(9, 39) Source(6, 38) + SourceIndex(0) -7 >Emitted(9, 40) Source(6, 39) + SourceIndex(0) ---- ->>> function m2_f1() { -1 >^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -1 >Emitted(10, 5) Source(7, 1) + SourceIndex(0) ---- ->>> return exports.m2_instance1; -1->^^^^^^^^ -2 > ^^^^^^ -3 > ^ -4 > ^^^^^^^^^^^^^^^^^^^^ -5 > ^ -1->export function m2_f1() { - > -2 > return -3 > -4 > m2_instance1 -5 > ; -1->Emitted(11, 9) Source(8, 5) + SourceIndex(0) name (m2_f1) -2 >Emitted(11, 15) Source(8, 11) + SourceIndex(0) name (m2_f1) -3 >Emitted(11, 16) Source(8, 12) + SourceIndex(0) name (m2_f1) -4 >Emitted(11, 36) Source(8, 24) + SourceIndex(0) name (m2_f1) -5 >Emitted(11, 37) Source(8, 25) + SourceIndex(0) name (m2_f1) ---- ->>> } -1 >^^^^ -2 > ^ -3 > ^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -2 > } -1 >Emitted(12, 5) Source(9, 1) + SourceIndex(0) name (m2_f1) -2 >Emitted(12, 6) Source(9, 2) + SourceIndex(0) name (m2_f1) ---- ->>> exports.m2_f1 = m2_f1; -1->^^^^ -2 > ^^^^^^^^^^^^^ -3 > ^^^^^^^^ -4 > ^ -1-> -2 > m2_f1 -3 > () { - > return m2_instance1; - > } -4 > -1->Emitted(13, 5) Source(7, 17) + SourceIndex(0) -2 >Emitted(13, 18) Source(7, 22) + SourceIndex(0) -3 >Emitted(13, 26) Source(9, 2) + SourceIndex(0) -4 >Emitted(13, 27) Source(9, 2) + SourceIndex(0) ---- ->>>}); ->>>//# sourceMappingURL=http://www.typescriptlang.org/ref/m2.js.map=================================================================== JsFile: test.js mapUrl: http://www.typescriptlang.org/test.js.map sourceRoot: http://typescript.codeplex.com/ diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFile/amd/ref/m2.d.ts b/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFile/amd/ref/m2.d.ts deleted file mode 100644 index c09a3c0c32a..00000000000 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFile/amd/ref/m2.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -export declare var m2_a1: number; -export declare class m2_c1 { - m2_c1_p1: number; -} -export declare var m2_instance1: m2_c1; -export declare function m2_f1(): m2_c1; diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFile/amd/ref/m2.js b/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFile/amd/ref/m2.js deleted file mode 100644 index aa404804b45..00000000000 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFile/amd/ref/m2.js +++ /dev/null @@ -1,15 +0,0 @@ -define(["require", "exports"], function (require, exports) { - exports.m2_a1 = 10; - var m2_c1 = (function () { - function m2_c1() { - } - return m2_c1; - })(); - exports.m2_c1 = m2_c1; - exports.m2_instance1 = new m2_c1(); - function m2_f1() { - return exports.m2_instance1; - } - exports.m2_f1 = m2_f1; -}); -//# sourceMappingURL=http://www.typescriptlang.org/ref/m2.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFile/amd/ref/m2.js.map b/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFile/amd/ref/m2.js.map deleted file mode 100644 index 04f168a6289..00000000000 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFile/amd/ref/m2.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"m2.js","sourceRoot":"http://typescript.codeplex.com/","sources":["ref/m2.ts"],"names":["m2_c1","m2_c1.constructor","m2_f1"],"mappings":";IAAW,aAAK,GAAG,EAAE,CAAC;IACtB;QAAAA;QAEAC,CAACA;QAADD,YAACA;IAADA,CAACA,AAFD,IAEC;IAFY,aAAK,QAEjB,CAAA;IAEU,oBAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACIE,MAAMA,CAACA,oBAAYA,CAACA;IACxBA,CAACA;IAFe,aAAK,QAEpB,CAAA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFile/node/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFile.json b/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFile/node/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFile.json index c36f3ade5e0..2de7a33388a 100644 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFile/node/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFile.json +++ b/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFile/node/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFile.json @@ -17,9 +17,6 @@ "test.ts" ], "emittedFiles": [ - "ref/m2.js.map", - "ref/m2.js", - "ref/m2.d.ts", "bin/test.js.map", "bin/test.js", "bin/test.d.ts" diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFile/node/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFile.sourcemap.txt b/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFile/node/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFile.sourcemap.txt index 714864e506f..d1ab16ddf2b 100644 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFile/node/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFile.sourcemap.txt +++ b/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFile/node/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFile.sourcemap.txt @@ -1,175 +1,4 @@ =================================================================== -JsFile: m2.js -mapUrl: http://www.typescriptlang.org/ref/m2.js.map -sourceRoot: http://typescript.codeplex.com/ -sources: ref/m2.ts -=================================================================== -------------------------------------------------------------------- -emittedFile:ref/m2.js -sourceFile:ref/m2.ts -------------------------------------------------------------------- ->>>exports.m2_a1 = 10; -1 > -2 >^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^-> -1 >export var -2 >m2_a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(1, 1) Source(1, 12) + SourceIndex(0) -2 >Emitted(1, 14) Source(1, 17) + SourceIndex(0) -3 >Emitted(1, 17) Source(1, 20) + SourceIndex(0) -4 >Emitted(1, 19) Source(1, 22) + SourceIndex(0) -5 >Emitted(1, 20) Source(1, 23) + SourceIndex(0) ---- ->>>var m2_c1 = (function () { -1-> -2 >^^^^^^^^^^^^^^^^^^^^^^^-> -1-> - > -1->Emitted(2, 1) Source(2, 1) + SourceIndex(0) ---- ->>> function m2_c1() { -1->^^^^ -2 > ^^-> -1-> -1->Emitted(3, 5) Source(2, 1) + SourceIndex(0) name (m2_c1) ---- ->>> } -1->^^^^ -2 > ^ -3 > ^^^^^^^^^^^^^-> -1->export class m2_c1 { - > public m2_c1_p1: number; - > -2 > } -1->Emitted(4, 5) Source(4, 1) + SourceIndex(0) name (m2_c1.constructor) -2 >Emitted(4, 6) Source(4, 2) + SourceIndex(0) name (m2_c1.constructor) ---- ->>> return m2_c1; -1->^^^^ -2 > ^^^^^^^^^^^^ -1-> -2 > } -1->Emitted(5, 5) Source(4, 1) + SourceIndex(0) name (m2_c1) -2 >Emitted(5, 17) Source(4, 2) + SourceIndex(0) name (m2_c1) ---- ->>>})(); -1 > -2 >^ -3 > -4 > ^^^^ -5 > ^^^^^^^^^^^^^^^^^^-> -1 > -2 >} -3 > -4 > export class m2_c1 { - > public m2_c1_p1: number; - > } -1 >Emitted(6, 1) Source(4, 1) + SourceIndex(0) name (m2_c1) -2 >Emitted(6, 2) Source(4, 2) + SourceIndex(0) name (m2_c1) -3 >Emitted(6, 2) Source(2, 1) + SourceIndex(0) -4 >Emitted(6, 6) Source(4, 2) + SourceIndex(0) ---- ->>>exports.m2_c1 = m2_c1; -1-> -2 >^^^^^^^^^^^^^ -3 > ^^^^^^^^ -4 > ^ -5 > ^^^^^^^^^^^^^^-> -1-> -2 >m2_c1 -3 > { - > public m2_c1_p1: number; - > } -4 > -1->Emitted(7, 1) Source(2, 14) + SourceIndex(0) -2 >Emitted(7, 14) Source(2, 19) + SourceIndex(0) -3 >Emitted(7, 22) Source(4, 2) + SourceIndex(0) -4 >Emitted(7, 23) Source(4, 2) + SourceIndex(0) ---- ->>>exports.m2_instance1 = new m2_c1(); -1-> -2 >^^^^^^^^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^^^ -5 > ^^^^^ -6 > ^^ -7 > ^ -1-> - > - >export var -2 >m2_instance1 -3 > = -4 > new -5 > m2_c1 -6 > () -7 > ; -1->Emitted(8, 1) Source(6, 12) + SourceIndex(0) -2 >Emitted(8, 21) Source(6, 24) + SourceIndex(0) -3 >Emitted(8, 24) Source(6, 27) + SourceIndex(0) -4 >Emitted(8, 28) Source(6, 31) + SourceIndex(0) -5 >Emitted(8, 33) Source(6, 36) + SourceIndex(0) -6 >Emitted(8, 35) Source(6, 38) + SourceIndex(0) -7 >Emitted(8, 36) Source(6, 39) + SourceIndex(0) ---- ->>>function m2_f1() { -1 > -2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -1 >Emitted(9, 1) Source(7, 1) + SourceIndex(0) ---- ->>> return exports.m2_instance1; -1->^^^^ -2 > ^^^^^^ -3 > ^ -4 > ^^^^^^^^^^^^^^^^^^^^ -5 > ^ -1->export function m2_f1() { - > -2 > return -3 > -4 > m2_instance1 -5 > ; -1->Emitted(10, 5) Source(8, 5) + SourceIndex(0) name (m2_f1) -2 >Emitted(10, 11) Source(8, 11) + SourceIndex(0) name (m2_f1) -3 >Emitted(10, 12) Source(8, 12) + SourceIndex(0) name (m2_f1) -4 >Emitted(10, 32) Source(8, 24) + SourceIndex(0) name (m2_f1) -5 >Emitted(10, 33) Source(8, 25) + SourceIndex(0) name (m2_f1) ---- ->>>} -1 > -2 >^ -3 > ^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -2 >} -1 >Emitted(11, 1) Source(9, 1) + SourceIndex(0) name (m2_f1) -2 >Emitted(11, 2) Source(9, 2) + SourceIndex(0) name (m2_f1) ---- ->>>exports.m2_f1 = m2_f1; -1-> -2 >^^^^^^^^^^^^^ -3 > ^^^^^^^^ -4 > ^ -5 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1-> -2 >m2_f1 -3 > () { - > return m2_instance1; - > } -4 > -1->Emitted(12, 1) Source(7, 17) + SourceIndex(0) -2 >Emitted(12, 14) Source(7, 22) + SourceIndex(0) -3 >Emitted(12, 22) Source(9, 2) + SourceIndex(0) -4 >Emitted(12, 23) Source(9, 2) + SourceIndex(0) ---- ->>>//# sourceMappingURL=http://www.typescriptlang.org/ref/m2.js.map=================================================================== JsFile: test.js mapUrl: http://www.typescriptlang.org/test.js.map sourceRoot: http://typescript.codeplex.com/ diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFile/node/ref/m2.d.ts b/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFile/node/ref/m2.d.ts deleted file mode 100644 index c09a3c0c32a..00000000000 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFile/node/ref/m2.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -export declare var m2_a1: number; -export declare class m2_c1 { - m2_c1_p1: number; -} -export declare var m2_instance1: m2_c1; -export declare function m2_f1(): m2_c1; diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFile/node/ref/m2.js b/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFile/node/ref/m2.js deleted file mode 100644 index a39f0f50e5f..00000000000 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFile/node/ref/m2.js +++ /dev/null @@ -1,13 +0,0 @@ -exports.m2_a1 = 10; -var m2_c1 = (function () { - function m2_c1() { - } - return m2_c1; -})(); -exports.m2_c1 = m2_c1; -exports.m2_instance1 = new m2_c1(); -function m2_f1() { - return exports.m2_instance1; -} -exports.m2_f1 = m2_f1; -//# sourceMappingURL=http://www.typescriptlang.org/ref/m2.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFile/node/ref/m2.js.map b/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFile/node/ref/m2.js.map deleted file mode 100644 index 0ce68e169af..00000000000 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFile/node/ref/m2.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"m2.js","sourceRoot":"http://typescript.codeplex.com/","sources":["ref/m2.ts"],"names":["m2_c1","m2_c1.constructor","m2_f1"],"mappings":"AAAW,aAAK,GAAG,EAAE,CAAC;AACtB;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAFY,aAAK,QAEjB,CAAA;AAEU,oBAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACIE,MAAMA,CAACA,oBAAYA,CAACA;AACxBA,CAACA;AAFe,aAAK,QAEpB,CAAA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory.json b/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory.json index 4741b9cf9e1..8d29a569320 100644 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory.json +++ b/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory.json @@ -18,9 +18,6 @@ "test.ts" ], "emittedFiles": [ - "outdir/outAndOutDirFolder/ref/m2.js.map", - "outdir/outAndOutDirFolder/ref/m2.js", - "outdir/outAndOutDirFolder/ref/m2.d.ts", "bin/outAndOutDirFile.js.map", "bin/outAndOutDirFile.js", "bin/outAndOutDirFile.d.ts" diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory.sourcemap.txt b/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory.sourcemap.txt index 72dd27c642f..2a4bc95cbc2 100644 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory.sourcemap.txt +++ b/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory.sourcemap.txt @@ -1,176 +1,4 @@ =================================================================== -JsFile: m2.js -mapUrl: http://www.typescriptlang.org/ref/m2.js.map -sourceRoot: http://typescript.codeplex.com/ -sources: ref/m2.ts -=================================================================== -------------------------------------------------------------------- -emittedFile:outdir/outAndOutDirFolder/ref/m2.js -sourceFile:ref/m2.ts -------------------------------------------------------------------- ->>>define(["require", "exports"], function (require, exports) { ->>> exports.m2_a1 = 10; -1 >^^^^ -2 > ^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^-> -1 >export var -2 > m2_a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(2, 5) Source(1, 12) + SourceIndex(0) -2 >Emitted(2, 18) Source(1, 17) + SourceIndex(0) -3 >Emitted(2, 21) Source(1, 20) + SourceIndex(0) -4 >Emitted(2, 23) Source(1, 22) + SourceIndex(0) -5 >Emitted(2, 24) Source(1, 23) + SourceIndex(0) ---- ->>> var m2_c1 = (function () { -1->^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^^^^-> -1-> - > -1->Emitted(3, 5) Source(2, 1) + SourceIndex(0) ---- ->>> function m2_c1() { -1->^^^^^^^^ -2 > ^^-> -1-> -1->Emitted(4, 9) Source(2, 1) + SourceIndex(0) name (m2_c1) ---- ->>> } -1->^^^^^^^^ -2 > ^ -3 > ^^^^^^^^^^^^^-> -1->export class m2_c1 { - > public m2_c1_p1: number; - > -2 > } -1->Emitted(5, 9) Source(4, 1) + SourceIndex(0) name (m2_c1.constructor) -2 >Emitted(5, 10) Source(4, 2) + SourceIndex(0) name (m2_c1.constructor) ---- ->>> return m2_c1; -1->^^^^^^^^ -2 > ^^^^^^^^^^^^ -1-> -2 > } -1->Emitted(6, 9) Source(4, 1) + SourceIndex(0) name (m2_c1) -2 >Emitted(6, 21) Source(4, 2) + SourceIndex(0) name (m2_c1) ---- ->>> })(); -1 >^^^^ -2 > ^ -3 > -4 > ^^^^ -5 > ^^^^^^^^^^^^^^^^^^-> -1 > -2 > } -3 > -4 > export class m2_c1 { - > public m2_c1_p1: number; - > } -1 >Emitted(7, 5) Source(4, 1) + SourceIndex(0) name (m2_c1) -2 >Emitted(7, 6) Source(4, 2) + SourceIndex(0) name (m2_c1) -3 >Emitted(7, 6) Source(2, 1) + SourceIndex(0) -4 >Emitted(7, 10) Source(4, 2) + SourceIndex(0) ---- ->>> exports.m2_c1 = m2_c1; -1->^^^^ -2 > ^^^^^^^^^^^^^ -3 > ^^^^^^^^ -4 > ^ -5 > ^^^^^^^^^^^^^^-> -1-> -2 > m2_c1 -3 > { - > public m2_c1_p1: number; - > } -4 > -1->Emitted(8, 5) Source(2, 14) + SourceIndex(0) -2 >Emitted(8, 18) Source(2, 19) + SourceIndex(0) -3 >Emitted(8, 26) Source(4, 2) + SourceIndex(0) -4 >Emitted(8, 27) Source(4, 2) + SourceIndex(0) ---- ->>> exports.m2_instance1 = new m2_c1(); -1->^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^^^ -5 > ^^^^^ -6 > ^^ -7 > ^ -1-> - > - >export var -2 > m2_instance1 -3 > = -4 > new -5 > m2_c1 -6 > () -7 > ; -1->Emitted(9, 5) Source(6, 12) + SourceIndex(0) -2 >Emitted(9, 25) Source(6, 24) + SourceIndex(0) -3 >Emitted(9, 28) Source(6, 27) + SourceIndex(0) -4 >Emitted(9, 32) Source(6, 31) + SourceIndex(0) -5 >Emitted(9, 37) Source(6, 36) + SourceIndex(0) -6 >Emitted(9, 39) Source(6, 38) + SourceIndex(0) -7 >Emitted(9, 40) Source(6, 39) + SourceIndex(0) ---- ->>> function m2_f1() { -1 >^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -1 >Emitted(10, 5) Source(7, 1) + SourceIndex(0) ---- ->>> return exports.m2_instance1; -1->^^^^^^^^ -2 > ^^^^^^ -3 > ^ -4 > ^^^^^^^^^^^^^^^^^^^^ -5 > ^ -1->export function m2_f1() { - > -2 > return -3 > -4 > m2_instance1 -5 > ; -1->Emitted(11, 9) Source(8, 5) + SourceIndex(0) name (m2_f1) -2 >Emitted(11, 15) Source(8, 11) + SourceIndex(0) name (m2_f1) -3 >Emitted(11, 16) Source(8, 12) + SourceIndex(0) name (m2_f1) -4 >Emitted(11, 36) Source(8, 24) + SourceIndex(0) name (m2_f1) -5 >Emitted(11, 37) Source(8, 25) + SourceIndex(0) name (m2_f1) ---- ->>> } -1 >^^^^ -2 > ^ -3 > ^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -2 > } -1 >Emitted(12, 5) Source(9, 1) + SourceIndex(0) name (m2_f1) -2 >Emitted(12, 6) Source(9, 2) + SourceIndex(0) name (m2_f1) ---- ->>> exports.m2_f1 = m2_f1; -1->^^^^ -2 > ^^^^^^^^^^^^^ -3 > ^^^^^^^^ -4 > ^ -1-> -2 > m2_f1 -3 > () { - > return m2_instance1; - > } -4 > -1->Emitted(13, 5) Source(7, 17) + SourceIndex(0) -2 >Emitted(13, 18) Source(7, 22) + SourceIndex(0) -3 >Emitted(13, 26) Source(9, 2) + SourceIndex(0) -4 >Emitted(13, 27) Source(9, 2) + SourceIndex(0) ---- ->>>}); ->>>//# sourceMappingURL=http://www.typescriptlang.org/ref/m2.js.map=================================================================== JsFile: outAndOutDirFile.js mapUrl: http://www.typescriptlang.org/outAndOutDirFile.js.map sourceRoot: http://typescript.codeplex.com/ diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/outdir/outAndOutDirFolder/ref/m2.d.ts b/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/outdir/outAndOutDirFolder/ref/m2.d.ts deleted file mode 100644 index c09a3c0c32a..00000000000 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/outdir/outAndOutDirFolder/ref/m2.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -export declare var m2_a1: number; -export declare class m2_c1 { - m2_c1_p1: number; -} -export declare var m2_instance1: m2_c1; -export declare function m2_f1(): m2_c1; diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/outdir/outAndOutDirFolder/ref/m2.js b/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/outdir/outAndOutDirFolder/ref/m2.js deleted file mode 100644 index aa404804b45..00000000000 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/outdir/outAndOutDirFolder/ref/m2.js +++ /dev/null @@ -1,15 +0,0 @@ -define(["require", "exports"], function (require, exports) { - exports.m2_a1 = 10; - var m2_c1 = (function () { - function m2_c1() { - } - return m2_c1; - })(); - exports.m2_c1 = m2_c1; - exports.m2_instance1 = new m2_c1(); - function m2_f1() { - return exports.m2_instance1; - } - exports.m2_f1 = m2_f1; -}); -//# sourceMappingURL=http://www.typescriptlang.org/ref/m2.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/outdir/outAndOutDirFolder/ref/m2.js.map b/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/outdir/outAndOutDirFolder/ref/m2.js.map deleted file mode 100644 index 04f168a6289..00000000000 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/outdir/outAndOutDirFolder/ref/m2.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"m2.js","sourceRoot":"http://typescript.codeplex.com/","sources":["ref/m2.ts"],"names":["m2_c1","m2_c1.constructor","m2_f1"],"mappings":";IAAW,aAAK,GAAG,EAAE,CAAC;IACtB;QAAAA;QAEAC,CAACA;QAADD,YAACA;IAADA,CAACA,AAFD,IAEC;IAFY,aAAK,QAEjB,CAAA;IAEU,oBAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACIE,MAAMA,CAACA,oBAAYA,CAACA;IACxBA,CAACA;IAFe,aAAK,QAEpB,CAAA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory.json b/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory.json index 4741b9cf9e1..8d29a569320 100644 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory.json +++ b/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory.json @@ -18,9 +18,6 @@ "test.ts" ], "emittedFiles": [ - "outdir/outAndOutDirFolder/ref/m2.js.map", - "outdir/outAndOutDirFolder/ref/m2.js", - "outdir/outAndOutDirFolder/ref/m2.d.ts", "bin/outAndOutDirFile.js.map", "bin/outAndOutDirFile.js", "bin/outAndOutDirFile.d.ts" diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory.sourcemap.txt b/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory.sourcemap.txt index 8284d795792..da3d501acb7 100644 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory.sourcemap.txt +++ b/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory.sourcemap.txt @@ -1,175 +1,4 @@ =================================================================== -JsFile: m2.js -mapUrl: http://www.typescriptlang.org/ref/m2.js.map -sourceRoot: http://typescript.codeplex.com/ -sources: ref/m2.ts -=================================================================== -------------------------------------------------------------------- -emittedFile:outdir/outAndOutDirFolder/ref/m2.js -sourceFile:ref/m2.ts -------------------------------------------------------------------- ->>>exports.m2_a1 = 10; -1 > -2 >^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^-> -1 >export var -2 >m2_a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(1, 1) Source(1, 12) + SourceIndex(0) -2 >Emitted(1, 14) Source(1, 17) + SourceIndex(0) -3 >Emitted(1, 17) Source(1, 20) + SourceIndex(0) -4 >Emitted(1, 19) Source(1, 22) + SourceIndex(0) -5 >Emitted(1, 20) Source(1, 23) + SourceIndex(0) ---- ->>>var m2_c1 = (function () { -1-> -2 >^^^^^^^^^^^^^^^^^^^^^^^-> -1-> - > -1->Emitted(2, 1) Source(2, 1) + SourceIndex(0) ---- ->>> function m2_c1() { -1->^^^^ -2 > ^^-> -1-> -1->Emitted(3, 5) Source(2, 1) + SourceIndex(0) name (m2_c1) ---- ->>> } -1->^^^^ -2 > ^ -3 > ^^^^^^^^^^^^^-> -1->export class m2_c1 { - > public m2_c1_p1: number; - > -2 > } -1->Emitted(4, 5) Source(4, 1) + SourceIndex(0) name (m2_c1.constructor) -2 >Emitted(4, 6) Source(4, 2) + SourceIndex(0) name (m2_c1.constructor) ---- ->>> return m2_c1; -1->^^^^ -2 > ^^^^^^^^^^^^ -1-> -2 > } -1->Emitted(5, 5) Source(4, 1) + SourceIndex(0) name (m2_c1) -2 >Emitted(5, 17) Source(4, 2) + SourceIndex(0) name (m2_c1) ---- ->>>})(); -1 > -2 >^ -3 > -4 > ^^^^ -5 > ^^^^^^^^^^^^^^^^^^-> -1 > -2 >} -3 > -4 > export class m2_c1 { - > public m2_c1_p1: number; - > } -1 >Emitted(6, 1) Source(4, 1) + SourceIndex(0) name (m2_c1) -2 >Emitted(6, 2) Source(4, 2) + SourceIndex(0) name (m2_c1) -3 >Emitted(6, 2) Source(2, 1) + SourceIndex(0) -4 >Emitted(6, 6) Source(4, 2) + SourceIndex(0) ---- ->>>exports.m2_c1 = m2_c1; -1-> -2 >^^^^^^^^^^^^^ -3 > ^^^^^^^^ -4 > ^ -5 > ^^^^^^^^^^^^^^-> -1-> -2 >m2_c1 -3 > { - > public m2_c1_p1: number; - > } -4 > -1->Emitted(7, 1) Source(2, 14) + SourceIndex(0) -2 >Emitted(7, 14) Source(2, 19) + SourceIndex(0) -3 >Emitted(7, 22) Source(4, 2) + SourceIndex(0) -4 >Emitted(7, 23) Source(4, 2) + SourceIndex(0) ---- ->>>exports.m2_instance1 = new m2_c1(); -1-> -2 >^^^^^^^^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^^^ -5 > ^^^^^ -6 > ^^ -7 > ^ -1-> - > - >export var -2 >m2_instance1 -3 > = -4 > new -5 > m2_c1 -6 > () -7 > ; -1->Emitted(8, 1) Source(6, 12) + SourceIndex(0) -2 >Emitted(8, 21) Source(6, 24) + SourceIndex(0) -3 >Emitted(8, 24) Source(6, 27) + SourceIndex(0) -4 >Emitted(8, 28) Source(6, 31) + SourceIndex(0) -5 >Emitted(8, 33) Source(6, 36) + SourceIndex(0) -6 >Emitted(8, 35) Source(6, 38) + SourceIndex(0) -7 >Emitted(8, 36) Source(6, 39) + SourceIndex(0) ---- ->>>function m2_f1() { -1 > -2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -1 >Emitted(9, 1) Source(7, 1) + SourceIndex(0) ---- ->>> return exports.m2_instance1; -1->^^^^ -2 > ^^^^^^ -3 > ^ -4 > ^^^^^^^^^^^^^^^^^^^^ -5 > ^ -1->export function m2_f1() { - > -2 > return -3 > -4 > m2_instance1 -5 > ; -1->Emitted(10, 5) Source(8, 5) + SourceIndex(0) name (m2_f1) -2 >Emitted(10, 11) Source(8, 11) + SourceIndex(0) name (m2_f1) -3 >Emitted(10, 12) Source(8, 12) + SourceIndex(0) name (m2_f1) -4 >Emitted(10, 32) Source(8, 24) + SourceIndex(0) name (m2_f1) -5 >Emitted(10, 33) Source(8, 25) + SourceIndex(0) name (m2_f1) ---- ->>>} -1 > -2 >^ -3 > ^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -2 >} -1 >Emitted(11, 1) Source(9, 1) + SourceIndex(0) name (m2_f1) -2 >Emitted(11, 2) Source(9, 2) + SourceIndex(0) name (m2_f1) ---- ->>>exports.m2_f1 = m2_f1; -1-> -2 >^^^^^^^^^^^^^ -3 > ^^^^^^^^ -4 > ^ -5 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1-> -2 >m2_f1 -3 > () { - > return m2_instance1; - > } -4 > -1->Emitted(12, 1) Source(7, 17) + SourceIndex(0) -2 >Emitted(12, 14) Source(7, 22) + SourceIndex(0) -3 >Emitted(12, 22) Source(9, 2) + SourceIndex(0) -4 >Emitted(12, 23) Source(9, 2) + SourceIndex(0) ---- ->>>//# sourceMappingURL=http://www.typescriptlang.org/ref/m2.js.map=================================================================== JsFile: outAndOutDirFile.js mapUrl: http://www.typescriptlang.org/outAndOutDirFile.js.map sourceRoot: http://typescript.codeplex.com/ diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/outdir/outAndOutDirFolder/ref/m2.d.ts b/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/outdir/outAndOutDirFolder/ref/m2.d.ts deleted file mode 100644 index c09a3c0c32a..00000000000 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/outdir/outAndOutDirFolder/ref/m2.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -export declare var m2_a1: number; -export declare class m2_c1 { - m2_c1_p1: number; -} -export declare var m2_instance1: m2_c1; -export declare function m2_f1(): m2_c1; diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/outdir/outAndOutDirFolder/ref/m2.js b/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/outdir/outAndOutDirFolder/ref/m2.js deleted file mode 100644 index a39f0f50e5f..00000000000 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/outdir/outAndOutDirFolder/ref/m2.js +++ /dev/null @@ -1,13 +0,0 @@ -exports.m2_a1 = 10; -var m2_c1 = (function () { - function m2_c1() { - } - return m2_c1; -})(); -exports.m2_c1 = m2_c1; -exports.m2_instance1 = new m2_c1(); -function m2_f1() { - return exports.m2_instance1; -} -exports.m2_f1 = m2_f1; -//# sourceMappingURL=http://www.typescriptlang.org/ref/m2.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/outdir/outAndOutDirFolder/ref/m2.js.map b/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/outdir/outAndOutDirFolder/ref/m2.js.map deleted file mode 100644 index 0ce68e169af..00000000000 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/outdir/outAndOutDirFolder/ref/m2.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"m2.js","sourceRoot":"http://typescript.codeplex.com/","sources":["ref/m2.ts"],"names":["m2_c1","m2_c1.constructor","m2_f1"],"mappings":"AAAW,aAAK,GAAG,EAAE,CAAC;AACtB;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAFY,aAAK,QAEjB,CAAA;AAEU,oBAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACIE,MAAMA,CAACA,oBAAYA,CAACA;AACxBA,CAACA;AAFe,aAAK,QAEpB,CAAA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputFile/amd/diskFile0.js.map b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputFile/amd/diskFile0.js.map deleted file mode 100644 index 3b00d82ab66..00000000000 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputFile/amd/diskFile0.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"m2.js","sourceRoot":"http://typescript.codeplex.com/","sources":["outputdir_module_multifolder_ref/m2.ts"],"names":["m2_c1","m2_c1.constructor","m2_f1"],"mappings":";IAAW,aAAK,GAAG,EAAE,CAAC;IACtB;QAAAA;QAEAC,CAACA;QAADD,YAACA;IAADA,CAACA,AAFD,IAEC;IAFY,aAAK,QAEjB,CAAA;IAEU,oBAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACIE,MAAMA,CAACA,oBAAYA,CAACA;IACxBA,CAACA;IAFe,aAAK,QAEpB,CAAA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputFile/amd/diskFile1.js b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputFile/amd/diskFile1.js deleted file mode 100644 index e926e95f3c3..00000000000 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputFile/amd/diskFile1.js +++ /dev/null @@ -1,15 +0,0 @@ -define(["require", "exports"], function (require, exports) { - exports.m2_a1 = 10; - var m2_c1 = (function () { - function m2_c1() { - } - return m2_c1; - })(); - exports.m2_c1 = m2_c1; - exports.m2_instance1 = new m2_c1(); - function m2_f1() { - return exports.m2_instance1; - } - exports.m2_f1 = m2_f1; -}); -//# sourceMappingURL=http://www.typescriptlang.org/outputdir_module_multifolder_ref/m2.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputFile/amd/diskFile2.d.ts b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputFile/amd/diskFile2.d.ts deleted file mode 100644 index c09a3c0c32a..00000000000 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputFile/amd/diskFile2.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -export declare var m2_a1: number; -export declare class m2_c1 { - m2_c1_p1: number; -} -export declare var m2_instance1: m2_c1; -export declare function m2_f1(): m2_c1; diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputFile/amd/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputFile.json b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputFile/amd/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputFile.json index 3ecf4bc4cc4..ae51d051ff0 100644 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputFile/amd/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputFile.json +++ b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputFile/amd/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputFile.json @@ -17,15 +17,6 @@ "test.ts" ], "emittedFiles": [ - "ref/m1.js.map", - "ref/m1.js", - "ref/m1.d.ts", - "../outputdir_module_multifolder_ref/m2.js.map", - "../outputdir_module_multifolder_ref/m2.js", - "../outputdir_module_multifolder_ref/m2.d.ts", - "test.js.map", - "test.js", - "test.d.ts", "bin/test.js.map", "bin/test.js", "bin/test.d.ts" diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputFile/amd/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputFile.sourcemap.txt b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputFile/amd/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputFile.sourcemap.txt index 4eb71f2bf29..20a97890399 100644 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputFile/amd/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputFile.sourcemap.txt +++ b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputFile/amd/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputFile.sourcemap.txt @@ -1,573 +1,4 @@ =================================================================== -JsFile: m1.js -mapUrl: http://www.typescriptlang.org/outputdir_module_multifolder/ref/m1.js.map -sourceRoot: http://typescript.codeplex.com/ -sources: outputdir_module_multifolder/ref/m1.ts -=================================================================== -------------------------------------------------------------------- -emittedFile:ref/m1.js -sourceFile:outputdir_module_multifolder/ref/m1.ts -------------------------------------------------------------------- ->>>define(["require", "exports"], function (require, exports) { ->>> exports.m1_a1 = 10; -1 >^^^^ -2 > ^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^-> -1 >export var -2 > m1_a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(2, 5) Source(1, 12) + SourceIndex(0) -2 >Emitted(2, 18) Source(1, 17) + SourceIndex(0) -3 >Emitted(2, 21) Source(1, 20) + SourceIndex(0) -4 >Emitted(2, 23) Source(1, 22) + SourceIndex(0) -5 >Emitted(2, 24) Source(1, 23) + SourceIndex(0) ---- ->>> var m1_c1 = (function () { -1->^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^^^^-> -1-> - > -1->Emitted(3, 5) Source(2, 1) + SourceIndex(0) ---- ->>> function m1_c1() { -1->^^^^^^^^ -2 > ^^-> -1-> -1->Emitted(4, 9) Source(2, 1) + SourceIndex(0) name (m1_c1) ---- ->>> } -1->^^^^^^^^ -2 > ^ -3 > ^^^^^^^^^^^^^-> -1->export class m1_c1 { - > public m1_c1_p1: number; - > -2 > } -1->Emitted(5, 9) Source(4, 1) + SourceIndex(0) name (m1_c1.constructor) -2 >Emitted(5, 10) Source(4, 2) + SourceIndex(0) name (m1_c1.constructor) ---- ->>> return m1_c1; -1->^^^^^^^^ -2 > ^^^^^^^^^^^^ -1-> -2 > } -1->Emitted(6, 9) Source(4, 1) + SourceIndex(0) name (m1_c1) -2 >Emitted(6, 21) Source(4, 2) + SourceIndex(0) name (m1_c1) ---- ->>> })(); -1 >^^^^ -2 > ^ -3 > -4 > ^^^^ -5 > ^^^^^^^^^^^^^^^^^^-> -1 > -2 > } -3 > -4 > export class m1_c1 { - > public m1_c1_p1: number; - > } -1 >Emitted(7, 5) Source(4, 1) + SourceIndex(0) name (m1_c1) -2 >Emitted(7, 6) Source(4, 2) + SourceIndex(0) name (m1_c1) -3 >Emitted(7, 6) Source(2, 1) + SourceIndex(0) -4 >Emitted(7, 10) Source(4, 2) + SourceIndex(0) ---- ->>> exports.m1_c1 = m1_c1; -1->^^^^ -2 > ^^^^^^^^^^^^^ -3 > ^^^^^^^^ -4 > ^ -5 > ^^^^^^^^^^^^^^-> -1-> -2 > m1_c1 -3 > { - > public m1_c1_p1: number; - > } -4 > -1->Emitted(8, 5) Source(2, 14) + SourceIndex(0) -2 >Emitted(8, 18) Source(2, 19) + SourceIndex(0) -3 >Emitted(8, 26) Source(4, 2) + SourceIndex(0) -4 >Emitted(8, 27) Source(4, 2) + SourceIndex(0) ---- ->>> exports.m1_instance1 = new m1_c1(); -1->^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^^^ -5 > ^^^^^ -6 > ^^ -7 > ^ -1-> - > - >export var -2 > m1_instance1 -3 > = -4 > new -5 > m1_c1 -6 > () -7 > ; -1->Emitted(9, 5) Source(6, 12) + SourceIndex(0) -2 >Emitted(9, 25) Source(6, 24) + SourceIndex(0) -3 >Emitted(9, 28) Source(6, 27) + SourceIndex(0) -4 >Emitted(9, 32) Source(6, 31) + SourceIndex(0) -5 >Emitted(9, 37) Source(6, 36) + SourceIndex(0) -6 >Emitted(9, 39) Source(6, 38) + SourceIndex(0) -7 >Emitted(9, 40) Source(6, 39) + SourceIndex(0) ---- ->>> function m1_f1() { -1 >^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -1 >Emitted(10, 5) Source(7, 1) + SourceIndex(0) ---- ->>> return exports.m1_instance1; -1->^^^^^^^^ -2 > ^^^^^^ -3 > ^ -4 > ^^^^^^^^^^^^^^^^^^^^ -5 > ^ -1->export function m1_f1() { - > -2 > return -3 > -4 > m1_instance1 -5 > ; -1->Emitted(11, 9) Source(8, 5) + SourceIndex(0) name (m1_f1) -2 >Emitted(11, 15) Source(8, 11) + SourceIndex(0) name (m1_f1) -3 >Emitted(11, 16) Source(8, 12) + SourceIndex(0) name (m1_f1) -4 >Emitted(11, 36) Source(8, 24) + SourceIndex(0) name (m1_f1) -5 >Emitted(11, 37) Source(8, 25) + SourceIndex(0) name (m1_f1) ---- ->>> } -1 >^^^^ -2 > ^ -3 > ^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -2 > } -1 >Emitted(12, 5) Source(9, 1) + SourceIndex(0) name (m1_f1) -2 >Emitted(12, 6) Source(9, 2) + SourceIndex(0) name (m1_f1) ---- ->>> exports.m1_f1 = m1_f1; -1->^^^^ -2 > ^^^^^^^^^^^^^ -3 > ^^^^^^^^ -4 > ^ -1-> -2 > m1_f1 -3 > () { - > return m1_instance1; - > } -4 > -1->Emitted(13, 5) Source(7, 17) + SourceIndex(0) -2 >Emitted(13, 18) Source(7, 22) + SourceIndex(0) -3 >Emitted(13, 26) Source(9, 2) + SourceIndex(0) -4 >Emitted(13, 27) Source(9, 2) + SourceIndex(0) ---- ->>>}); ->>>//# sourceMappingURL=http://www.typescriptlang.org/outputdir_module_multifolder/ref/m1.js.map=================================================================== -JsFile: m2.js -mapUrl: http://www.typescriptlang.org/outputdir_module_multifolder_ref/m2.js.map -sourceRoot: http://typescript.codeplex.com/ -sources: outputdir_module_multifolder_ref/m2.ts -=================================================================== -------------------------------------------------------------------- -emittedFile:diskFile1.js -sourceFile:outputdir_module_multifolder_ref/m2.ts -------------------------------------------------------------------- ->>>define(["require", "exports"], function (require, exports) { ->>> exports.m2_a1 = 10; -1 >^^^^ -2 > ^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^-> -1 >export var -2 > m2_a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(2, 5) Source(1, 12) + SourceIndex(0) -2 >Emitted(2, 18) Source(1, 17) + SourceIndex(0) -3 >Emitted(2, 21) Source(1, 20) + SourceIndex(0) -4 >Emitted(2, 23) Source(1, 22) + SourceIndex(0) -5 >Emitted(2, 24) Source(1, 23) + SourceIndex(0) ---- ->>> var m2_c1 = (function () { -1->^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^^^^-> -1-> - > -1->Emitted(3, 5) Source(2, 1) + SourceIndex(0) ---- ->>> function m2_c1() { -1->^^^^^^^^ -2 > ^^-> -1-> -1->Emitted(4, 9) Source(2, 1) + SourceIndex(0) name (m2_c1) ---- ->>> } -1->^^^^^^^^ -2 > ^ -3 > ^^^^^^^^^^^^^-> -1->export class m2_c1 { - > public m2_c1_p1: number; - > -2 > } -1->Emitted(5, 9) Source(4, 1) + SourceIndex(0) name (m2_c1.constructor) -2 >Emitted(5, 10) Source(4, 2) + SourceIndex(0) name (m2_c1.constructor) ---- ->>> return m2_c1; -1->^^^^^^^^ -2 > ^^^^^^^^^^^^ -1-> -2 > } -1->Emitted(6, 9) Source(4, 1) + SourceIndex(0) name (m2_c1) -2 >Emitted(6, 21) Source(4, 2) + SourceIndex(0) name (m2_c1) ---- ->>> })(); -1 >^^^^ -2 > ^ -3 > -4 > ^^^^ -5 > ^^^^^^^^^^^^^^^^^^-> -1 > -2 > } -3 > -4 > export class m2_c1 { - > public m2_c1_p1: number; - > } -1 >Emitted(7, 5) Source(4, 1) + SourceIndex(0) name (m2_c1) -2 >Emitted(7, 6) Source(4, 2) + SourceIndex(0) name (m2_c1) -3 >Emitted(7, 6) Source(2, 1) + SourceIndex(0) -4 >Emitted(7, 10) Source(4, 2) + SourceIndex(0) ---- ->>> exports.m2_c1 = m2_c1; -1->^^^^ -2 > ^^^^^^^^^^^^^ -3 > ^^^^^^^^ -4 > ^ -5 > ^^^^^^^^^^^^^^-> -1-> -2 > m2_c1 -3 > { - > public m2_c1_p1: number; - > } -4 > -1->Emitted(8, 5) Source(2, 14) + SourceIndex(0) -2 >Emitted(8, 18) Source(2, 19) + SourceIndex(0) -3 >Emitted(8, 26) Source(4, 2) + SourceIndex(0) -4 >Emitted(8, 27) Source(4, 2) + SourceIndex(0) ---- ->>> exports.m2_instance1 = new m2_c1(); -1->^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^^^ -5 > ^^^^^ -6 > ^^ -7 > ^ -1-> - > - >export var -2 > m2_instance1 -3 > = -4 > new -5 > m2_c1 -6 > () -7 > ; -1->Emitted(9, 5) Source(6, 12) + SourceIndex(0) -2 >Emitted(9, 25) Source(6, 24) + SourceIndex(0) -3 >Emitted(9, 28) Source(6, 27) + SourceIndex(0) -4 >Emitted(9, 32) Source(6, 31) + SourceIndex(0) -5 >Emitted(9, 37) Source(6, 36) + SourceIndex(0) -6 >Emitted(9, 39) Source(6, 38) + SourceIndex(0) -7 >Emitted(9, 40) Source(6, 39) + SourceIndex(0) ---- ->>> function m2_f1() { -1 >^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -1 >Emitted(10, 5) Source(7, 1) + SourceIndex(0) ---- ->>> return exports.m2_instance1; -1->^^^^^^^^ -2 > ^^^^^^ -3 > ^ -4 > ^^^^^^^^^^^^^^^^^^^^ -5 > ^ -1->export function m2_f1() { - > -2 > return -3 > -4 > m2_instance1 -5 > ; -1->Emitted(11, 9) Source(8, 5) + SourceIndex(0) name (m2_f1) -2 >Emitted(11, 15) Source(8, 11) + SourceIndex(0) name (m2_f1) -3 >Emitted(11, 16) Source(8, 12) + SourceIndex(0) name (m2_f1) -4 >Emitted(11, 36) Source(8, 24) + SourceIndex(0) name (m2_f1) -5 >Emitted(11, 37) Source(8, 25) + SourceIndex(0) name (m2_f1) ---- ->>> } -1 >^^^^ -2 > ^ -3 > ^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -2 > } -1 >Emitted(12, 5) Source(9, 1) + SourceIndex(0) name (m2_f1) -2 >Emitted(12, 6) Source(9, 2) + SourceIndex(0) name (m2_f1) ---- ->>> exports.m2_f1 = m2_f1; -1->^^^^ -2 > ^^^^^^^^^^^^^ -3 > ^^^^^^^^ -4 > ^ -1-> -2 > m2_f1 -3 > () { - > return m2_instance1; - > } -4 > -1->Emitted(13, 5) Source(7, 17) + SourceIndex(0) -2 >Emitted(13, 18) Source(7, 22) + SourceIndex(0) -3 >Emitted(13, 26) Source(9, 2) + SourceIndex(0) -4 >Emitted(13, 27) Source(9, 2) + SourceIndex(0) ---- ->>>}); ->>>//# sourceMappingURL=http://www.typescriptlang.org/outputdir_module_multifolder_ref/m2.js.map=================================================================== -JsFile: test.js -mapUrl: http://www.typescriptlang.org/outputdir_module_multifolder/test.js.map -sourceRoot: http://typescript.codeplex.com/ -sources: outputdir_module_multifolder/test.ts -=================================================================== -------------------------------------------------------------------- -emittedFile:test.js -sourceFile:outputdir_module_multifolder/test.ts -------------------------------------------------------------------- ->>>define(["require", "exports", "ref/m1", "../outputdir_module_multifolder_ref/m2"], function (require, exports, m1, m2) { ->>> exports.a1 = 10; -1 >^^^^ -2 > ^^^^^^^^^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^-> -1 >import m1 = require("ref/m1"); - >import m2 = require("../outputdir_module_multifolder_ref/m2"); - >export var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(2, 5) Source(3, 12) + SourceIndex(0) -2 >Emitted(2, 15) Source(3, 14) + SourceIndex(0) -3 >Emitted(2, 18) Source(3, 17) + SourceIndex(0) -4 >Emitted(2, 20) Source(3, 19) + SourceIndex(0) -5 >Emitted(2, 21) Source(3, 20) + SourceIndex(0) ---- ->>> var c1 = (function () { -1->^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^-> -1-> - > -1->Emitted(3, 5) Source(4, 1) + SourceIndex(0) ---- ->>> function c1() { -1->^^^^^^^^ -2 > ^^-> -1-> -1->Emitted(4, 9) Source(4, 1) + SourceIndex(0) name (c1) ---- ->>> } -1->^^^^^^^^ -2 > ^ -3 > ^^^^^^^^^^-> -1->export class c1 { - > public p1: number; - > -2 > } -1->Emitted(5, 9) Source(6, 1) + SourceIndex(0) name (c1.constructor) -2 >Emitted(5, 10) Source(6, 2) + SourceIndex(0) name (c1.constructor) ---- ->>> return c1; -1->^^^^^^^^ -2 > ^^^^^^^^^ -1-> -2 > } -1->Emitted(6, 9) Source(6, 1) + SourceIndex(0) name (c1) -2 >Emitted(6, 18) Source(6, 2) + SourceIndex(0) name (c1) ---- ->>> })(); -1 >^^^^ -2 > ^ -3 > -4 > ^^^^ -5 > ^^^^^^^^^^^^-> -1 > -2 > } -3 > -4 > export class c1 { - > public p1: number; - > } -1 >Emitted(7, 5) Source(6, 1) + SourceIndex(0) name (c1) -2 >Emitted(7, 6) Source(6, 2) + SourceIndex(0) name (c1) -3 >Emitted(7, 6) Source(4, 1) + SourceIndex(0) -4 >Emitted(7, 10) Source(6, 2) + SourceIndex(0) ---- ->>> exports.c1 = c1; -1->^^^^ -2 > ^^^^^^^^^^ -3 > ^^^^^ -4 > ^ -5 > ^^^^^^^^^^^^^^-> -1-> -2 > c1 -3 > { - > public p1: number; - > } -4 > -1->Emitted(8, 5) Source(4, 14) + SourceIndex(0) -2 >Emitted(8, 15) Source(4, 16) + SourceIndex(0) -3 >Emitted(8, 20) Source(6, 2) + SourceIndex(0) -4 >Emitted(8, 21) Source(6, 2) + SourceIndex(0) ---- ->>> exports.instance1 = new c1(); -1->^^^^ -2 > ^^^^^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^^^ -5 > ^^ -6 > ^^ -7 > ^ -1-> - > - >export var -2 > instance1 -3 > = -4 > new -5 > c1 -6 > () -7 > ; -1->Emitted(9, 5) Source(8, 12) + SourceIndex(0) -2 >Emitted(9, 22) Source(8, 21) + SourceIndex(0) -3 >Emitted(9, 25) Source(8, 24) + SourceIndex(0) -4 >Emitted(9, 29) Source(8, 28) + SourceIndex(0) -5 >Emitted(9, 31) Source(8, 30) + SourceIndex(0) -6 >Emitted(9, 33) Source(8, 32) + SourceIndex(0) -7 >Emitted(9, 34) Source(8, 33) + SourceIndex(0) ---- ->>> function f1() { -1 >^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -1 >Emitted(10, 5) Source(9, 1) + SourceIndex(0) ---- ->>> return exports.instance1; -1->^^^^^^^^ -2 > ^^^^^^ -3 > ^ -4 > ^^^^^^^^^^^^^^^^^ -5 > ^ -1->export function f1() { - > -2 > return -3 > -4 > instance1 -5 > ; -1->Emitted(11, 9) Source(10, 5) + SourceIndex(0) name (f1) -2 >Emitted(11, 15) Source(10, 11) + SourceIndex(0) name (f1) -3 >Emitted(11, 16) Source(10, 12) + SourceIndex(0) name (f1) -4 >Emitted(11, 33) Source(10, 21) + SourceIndex(0) name (f1) -5 >Emitted(11, 34) Source(10, 22) + SourceIndex(0) name (f1) ---- ->>> } -1 >^^^^ -2 > ^ -3 > ^^^^^^^^^^^^^^^^-> -1 > - > -2 > } -1 >Emitted(12, 5) Source(11, 1) + SourceIndex(0) name (f1) -2 >Emitted(12, 6) Source(11, 2) + SourceIndex(0) name (f1) ---- ->>> exports.f1 = f1; -1->^^^^ -2 > ^^^^^^^^^^ -3 > ^^^^^ -4 > ^ -5 > ^^^^^^^-> -1-> -2 > f1 -3 > () { - > return instance1; - > } -4 > -1->Emitted(13, 5) Source(9, 17) + SourceIndex(0) -2 >Emitted(13, 15) Source(9, 19) + SourceIndex(0) -3 >Emitted(13, 20) Source(11, 2) + SourceIndex(0) -4 >Emitted(13, 21) Source(11, 2) + SourceIndex(0) ---- ->>> exports.a2 = m1.m1_c1; -1->^^^^ -2 > ^^^^^^^^^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^ -7 > ^ -8 > ^-> -1-> - > - >export var -2 > a2 -3 > = -4 > m1 -5 > . -6 > m1_c1 -7 > ; -1->Emitted(14, 5) Source(13, 12) + SourceIndex(0) -2 >Emitted(14, 15) Source(13, 14) + SourceIndex(0) -3 >Emitted(14, 18) Source(13, 17) + SourceIndex(0) -4 >Emitted(14, 20) Source(13, 19) + SourceIndex(0) -5 >Emitted(14, 21) Source(13, 20) + SourceIndex(0) -6 >Emitted(14, 26) Source(13, 25) + SourceIndex(0) -7 >Emitted(14, 27) Source(13, 26) + SourceIndex(0) ---- ->>> exports.a3 = m2.m2_c1; -1->^^^^ -2 > ^^^^^^^^^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^ -7 > ^ -1-> - >export var -2 > a3 -3 > = -4 > m2 -5 > . -6 > m2_c1 -7 > ; -1->Emitted(15, 5) Source(14, 12) + SourceIndex(0) -2 >Emitted(15, 15) Source(14, 14) + SourceIndex(0) -3 >Emitted(15, 18) Source(14, 17) + SourceIndex(0) -4 >Emitted(15, 20) Source(14, 19) + SourceIndex(0) -5 >Emitted(15, 21) Source(14, 20) + SourceIndex(0) -6 >Emitted(15, 26) Source(14, 25) + SourceIndex(0) -7 >Emitted(15, 27) Source(14, 26) + SourceIndex(0) ---- ->>>}); ->>>//# sourceMappingURL=http://www.typescriptlang.org/outputdir_module_multifolder/test.js.map=================================================================== JsFile: test.js mapUrl: http://www.typescriptlang.org/test.js.map sourceRoot: http://typescript.codeplex.com/ diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputFile/amd/ref/m1.d.ts b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputFile/amd/ref/m1.d.ts deleted file mode 100644 index 4a53b24b156..00000000000 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputFile/amd/ref/m1.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -export declare var m1_a1: number; -export declare class m1_c1 { - m1_c1_p1: number; -} -export declare var m1_instance1: m1_c1; -export declare function m1_f1(): m1_c1; diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputFile/amd/ref/m1.js b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputFile/amd/ref/m1.js deleted file mode 100644 index e8004c87aad..00000000000 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputFile/amd/ref/m1.js +++ /dev/null @@ -1,15 +0,0 @@ -define(["require", "exports"], function (require, exports) { - exports.m1_a1 = 10; - var m1_c1 = (function () { - function m1_c1() { - } - return m1_c1; - })(); - exports.m1_c1 = m1_c1; - exports.m1_instance1 = new m1_c1(); - function m1_f1() { - return exports.m1_instance1; - } - exports.m1_f1 = m1_f1; -}); -//# sourceMappingURL=http://www.typescriptlang.org/outputdir_module_multifolder/ref/m1.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputFile/amd/ref/m1.js.map b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputFile/amd/ref/m1.js.map deleted file mode 100644 index 8c257bd1111..00000000000 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputFile/amd/ref/m1.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"m1.js","sourceRoot":"http://typescript.codeplex.com/","sources":["outputdir_module_multifolder/ref/m1.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1"],"mappings":";IAAW,aAAK,GAAG,EAAE,CAAC;IACtB;QAAAA;QAEAC,CAACA;QAADD,YAACA;IAADA,CAACA,AAFD,IAEC;IAFY,aAAK,QAEjB,CAAA;IAEU,oBAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACIE,MAAMA,CAACA,oBAAYA,CAACA;IACxBA,CAACA;IAFe,aAAK,QAEpB,CAAA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputFile/amd/test.d.ts b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputFile/amd/test.d.ts deleted file mode 100644 index 4afd4e69f2d..00000000000 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputFile/amd/test.d.ts +++ /dev/null @@ -1,10 +0,0 @@ -import m1 = require("ref/m1"); -import m2 = require("../outputdir_module_multifolder_ref/m2"); -export declare var a1: number; -export declare class c1 { - p1: number; -} -export declare var instance1: c1; -export declare function f1(): c1; -export declare var a2: typeof m1.m1_c1; -export declare var a3: typeof m2.m2_c1; diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputFile/amd/test.js b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputFile/amd/test.js deleted file mode 100644 index 01ad8f96e78..00000000000 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputFile/amd/test.js +++ /dev/null @@ -1,17 +0,0 @@ -define(["require", "exports", "ref/m1", "../outputdir_module_multifolder_ref/m2"], function (require, exports, m1, m2) { - exports.a1 = 10; - var c1 = (function () { - function c1() { - } - return c1; - })(); - exports.c1 = c1; - exports.instance1 = new c1(); - function f1() { - return exports.instance1; - } - exports.f1 = f1; - exports.a2 = m1.m1_c1; - exports.a3 = m2.m2_c1; -}); -//# sourceMappingURL=http://www.typescriptlang.org/outputdir_module_multifolder/test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputFile/amd/test.js.map b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputFile/amd/test.js.map deleted file mode 100644 index 8612cd0d108..00000000000 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputFile/amd/test.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"test.js","sourceRoot":"http://typescript.codeplex.com/","sources":["outputdir_module_multifolder/test.ts"],"names":["c1","c1.constructor","f1"],"mappings":";IAEW,UAAE,GAAG,EAAE,CAAC;IACnB;QAAAA;QAEAC,CAACA;QAADD,SAACA;IAADA,CAACA,AAFD,IAEC;IAFY,UAAE,KAEd,CAAA;IAEU,iBAAS,GAAG,IAAI,EAAE,EAAE,CAAC;IAChC;QACIE,MAAMA,CAACA,iBAASA,CAACA;IACrBA,CAACA;IAFe,UAAE,KAEjB,CAAA;IAEU,UAAE,GAAG,EAAE,CAAC,KAAK,CAAC;IACd,UAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputFile/node/diskFile0.js.map b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputFile/node/diskFile0.js.map deleted file mode 100644 index 058e405b606..00000000000 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputFile/node/diskFile0.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"m2.js","sourceRoot":"http://typescript.codeplex.com/","sources":["outputdir_module_multifolder_ref/m2.ts"],"names":["m2_c1","m2_c1.constructor","m2_f1"],"mappings":"AAAW,aAAK,GAAG,EAAE,CAAC;AACtB;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAFY,aAAK,QAEjB,CAAA;AAEU,oBAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACIE,MAAMA,CAACA,oBAAYA,CAACA;AACxBA,CAACA;AAFe,aAAK,QAEpB,CAAA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputFile/node/diskFile1.js b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputFile/node/diskFile1.js deleted file mode 100644 index 721fdf3827f..00000000000 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputFile/node/diskFile1.js +++ /dev/null @@ -1,13 +0,0 @@ -exports.m2_a1 = 10; -var m2_c1 = (function () { - function m2_c1() { - } - return m2_c1; -})(); -exports.m2_c1 = m2_c1; -exports.m2_instance1 = new m2_c1(); -function m2_f1() { - return exports.m2_instance1; -} -exports.m2_f1 = m2_f1; -//# sourceMappingURL=http://www.typescriptlang.org/outputdir_module_multifolder_ref/m2.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputFile/node/diskFile2.d.ts b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputFile/node/diskFile2.d.ts deleted file mode 100644 index c09a3c0c32a..00000000000 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputFile/node/diskFile2.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -export declare var m2_a1: number; -export declare class m2_c1 { - m2_c1_p1: number; -} -export declare var m2_instance1: m2_c1; -export declare function m2_f1(): m2_c1; diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputFile/node/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputFile.json b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputFile/node/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputFile.json index 3ecf4bc4cc4..ae51d051ff0 100644 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputFile/node/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputFile.json +++ b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputFile/node/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputFile.json @@ -17,15 +17,6 @@ "test.ts" ], "emittedFiles": [ - "ref/m1.js.map", - "ref/m1.js", - "ref/m1.d.ts", - "../outputdir_module_multifolder_ref/m2.js.map", - "../outputdir_module_multifolder_ref/m2.js", - "../outputdir_module_multifolder_ref/m2.d.ts", - "test.js.map", - "test.js", - "test.d.ts", "bin/test.js.map", "bin/test.js", "bin/test.d.ts" diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputFile/node/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputFile.sourcemap.txt b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputFile/node/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputFile.sourcemap.txt index 77c5e460779..909ae1c3750 100644 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputFile/node/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputFile.sourcemap.txt +++ b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputFile/node/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputFile.sourcemap.txt @@ -1,617 +1,4 @@ =================================================================== -JsFile: m1.js -mapUrl: http://www.typescriptlang.org/outputdir_module_multifolder/ref/m1.js.map -sourceRoot: http://typescript.codeplex.com/ -sources: outputdir_module_multifolder/ref/m1.ts -=================================================================== -------------------------------------------------------------------- -emittedFile:ref/m1.js -sourceFile:outputdir_module_multifolder/ref/m1.ts -------------------------------------------------------------------- ->>>exports.m1_a1 = 10; -1 > -2 >^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^-> -1 >export var -2 >m1_a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(1, 1) Source(1, 12) + SourceIndex(0) -2 >Emitted(1, 14) Source(1, 17) + SourceIndex(0) -3 >Emitted(1, 17) Source(1, 20) + SourceIndex(0) -4 >Emitted(1, 19) Source(1, 22) + SourceIndex(0) -5 >Emitted(1, 20) Source(1, 23) + SourceIndex(0) ---- ->>>var m1_c1 = (function () { -1-> -2 >^^^^^^^^^^^^^^^^^^^^^^^-> -1-> - > -1->Emitted(2, 1) Source(2, 1) + SourceIndex(0) ---- ->>> function m1_c1() { -1->^^^^ -2 > ^^-> -1-> -1->Emitted(3, 5) Source(2, 1) + SourceIndex(0) name (m1_c1) ---- ->>> } -1->^^^^ -2 > ^ -3 > ^^^^^^^^^^^^^-> -1->export class m1_c1 { - > public m1_c1_p1: number; - > -2 > } -1->Emitted(4, 5) Source(4, 1) + SourceIndex(0) name (m1_c1.constructor) -2 >Emitted(4, 6) Source(4, 2) + SourceIndex(0) name (m1_c1.constructor) ---- ->>> return m1_c1; -1->^^^^ -2 > ^^^^^^^^^^^^ -1-> -2 > } -1->Emitted(5, 5) Source(4, 1) + SourceIndex(0) name (m1_c1) -2 >Emitted(5, 17) Source(4, 2) + SourceIndex(0) name (m1_c1) ---- ->>>})(); -1 > -2 >^ -3 > -4 > ^^^^ -5 > ^^^^^^^^^^^^^^^^^^-> -1 > -2 >} -3 > -4 > export class m1_c1 { - > public m1_c1_p1: number; - > } -1 >Emitted(6, 1) Source(4, 1) + SourceIndex(0) name (m1_c1) -2 >Emitted(6, 2) Source(4, 2) + SourceIndex(0) name (m1_c1) -3 >Emitted(6, 2) Source(2, 1) + SourceIndex(0) -4 >Emitted(6, 6) Source(4, 2) + SourceIndex(0) ---- ->>>exports.m1_c1 = m1_c1; -1-> -2 >^^^^^^^^^^^^^ -3 > ^^^^^^^^ -4 > ^ -5 > ^^^^^^^^^^^^^^-> -1-> -2 >m1_c1 -3 > { - > public m1_c1_p1: number; - > } -4 > -1->Emitted(7, 1) Source(2, 14) + SourceIndex(0) -2 >Emitted(7, 14) Source(2, 19) + SourceIndex(0) -3 >Emitted(7, 22) Source(4, 2) + SourceIndex(0) -4 >Emitted(7, 23) Source(4, 2) + SourceIndex(0) ---- ->>>exports.m1_instance1 = new m1_c1(); -1-> -2 >^^^^^^^^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^^^ -5 > ^^^^^ -6 > ^^ -7 > ^ -1-> - > - >export var -2 >m1_instance1 -3 > = -4 > new -5 > m1_c1 -6 > () -7 > ; -1->Emitted(8, 1) Source(6, 12) + SourceIndex(0) -2 >Emitted(8, 21) Source(6, 24) + SourceIndex(0) -3 >Emitted(8, 24) Source(6, 27) + SourceIndex(0) -4 >Emitted(8, 28) Source(6, 31) + SourceIndex(0) -5 >Emitted(8, 33) Source(6, 36) + SourceIndex(0) -6 >Emitted(8, 35) Source(6, 38) + SourceIndex(0) -7 >Emitted(8, 36) Source(6, 39) + SourceIndex(0) ---- ->>>function m1_f1() { -1 > -2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -1 >Emitted(9, 1) Source(7, 1) + SourceIndex(0) ---- ->>> return exports.m1_instance1; -1->^^^^ -2 > ^^^^^^ -3 > ^ -4 > ^^^^^^^^^^^^^^^^^^^^ -5 > ^ -1->export function m1_f1() { - > -2 > return -3 > -4 > m1_instance1 -5 > ; -1->Emitted(10, 5) Source(8, 5) + SourceIndex(0) name (m1_f1) -2 >Emitted(10, 11) Source(8, 11) + SourceIndex(0) name (m1_f1) -3 >Emitted(10, 12) Source(8, 12) + SourceIndex(0) name (m1_f1) -4 >Emitted(10, 32) Source(8, 24) + SourceIndex(0) name (m1_f1) -5 >Emitted(10, 33) Source(8, 25) + SourceIndex(0) name (m1_f1) ---- ->>>} -1 > -2 >^ -3 > ^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -2 >} -1 >Emitted(11, 1) Source(9, 1) + SourceIndex(0) name (m1_f1) -2 >Emitted(11, 2) Source(9, 2) + SourceIndex(0) name (m1_f1) ---- ->>>exports.m1_f1 = m1_f1; -1-> -2 >^^^^^^^^^^^^^ -3 > ^^^^^^^^ -4 > ^ -5 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1-> -2 >m1_f1 -3 > () { - > return m1_instance1; - > } -4 > -1->Emitted(12, 1) Source(7, 17) + SourceIndex(0) -2 >Emitted(12, 14) Source(7, 22) + SourceIndex(0) -3 >Emitted(12, 22) Source(9, 2) + SourceIndex(0) -4 >Emitted(12, 23) Source(9, 2) + SourceIndex(0) ---- ->>>//# sourceMappingURL=http://www.typescriptlang.org/outputdir_module_multifolder/ref/m1.js.map=================================================================== -JsFile: m2.js -mapUrl: http://www.typescriptlang.org/outputdir_module_multifolder_ref/m2.js.map -sourceRoot: http://typescript.codeplex.com/ -sources: outputdir_module_multifolder_ref/m2.ts -=================================================================== -------------------------------------------------------------------- -emittedFile:diskFile1.js -sourceFile:outputdir_module_multifolder_ref/m2.ts -------------------------------------------------------------------- ->>>exports.m2_a1 = 10; -1 > -2 >^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^-> -1 >export var -2 >m2_a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(1, 1) Source(1, 12) + SourceIndex(0) -2 >Emitted(1, 14) Source(1, 17) + SourceIndex(0) -3 >Emitted(1, 17) Source(1, 20) + SourceIndex(0) -4 >Emitted(1, 19) Source(1, 22) + SourceIndex(0) -5 >Emitted(1, 20) Source(1, 23) + SourceIndex(0) ---- ->>>var m2_c1 = (function () { -1-> -2 >^^^^^^^^^^^^^^^^^^^^^^^-> -1-> - > -1->Emitted(2, 1) Source(2, 1) + SourceIndex(0) ---- ->>> function m2_c1() { -1->^^^^ -2 > ^^-> -1-> -1->Emitted(3, 5) Source(2, 1) + SourceIndex(0) name (m2_c1) ---- ->>> } -1->^^^^ -2 > ^ -3 > ^^^^^^^^^^^^^-> -1->export class m2_c1 { - > public m2_c1_p1: number; - > -2 > } -1->Emitted(4, 5) Source(4, 1) + SourceIndex(0) name (m2_c1.constructor) -2 >Emitted(4, 6) Source(4, 2) + SourceIndex(0) name (m2_c1.constructor) ---- ->>> return m2_c1; -1->^^^^ -2 > ^^^^^^^^^^^^ -1-> -2 > } -1->Emitted(5, 5) Source(4, 1) + SourceIndex(0) name (m2_c1) -2 >Emitted(5, 17) Source(4, 2) + SourceIndex(0) name (m2_c1) ---- ->>>})(); -1 > -2 >^ -3 > -4 > ^^^^ -5 > ^^^^^^^^^^^^^^^^^^-> -1 > -2 >} -3 > -4 > export class m2_c1 { - > public m2_c1_p1: number; - > } -1 >Emitted(6, 1) Source(4, 1) + SourceIndex(0) name (m2_c1) -2 >Emitted(6, 2) Source(4, 2) + SourceIndex(0) name (m2_c1) -3 >Emitted(6, 2) Source(2, 1) + SourceIndex(0) -4 >Emitted(6, 6) Source(4, 2) + SourceIndex(0) ---- ->>>exports.m2_c1 = m2_c1; -1-> -2 >^^^^^^^^^^^^^ -3 > ^^^^^^^^ -4 > ^ -5 > ^^^^^^^^^^^^^^-> -1-> -2 >m2_c1 -3 > { - > public m2_c1_p1: number; - > } -4 > -1->Emitted(7, 1) Source(2, 14) + SourceIndex(0) -2 >Emitted(7, 14) Source(2, 19) + SourceIndex(0) -3 >Emitted(7, 22) Source(4, 2) + SourceIndex(0) -4 >Emitted(7, 23) Source(4, 2) + SourceIndex(0) ---- ->>>exports.m2_instance1 = new m2_c1(); -1-> -2 >^^^^^^^^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^^^ -5 > ^^^^^ -6 > ^^ -7 > ^ -1-> - > - >export var -2 >m2_instance1 -3 > = -4 > new -5 > m2_c1 -6 > () -7 > ; -1->Emitted(8, 1) Source(6, 12) + SourceIndex(0) -2 >Emitted(8, 21) Source(6, 24) + SourceIndex(0) -3 >Emitted(8, 24) Source(6, 27) + SourceIndex(0) -4 >Emitted(8, 28) Source(6, 31) + SourceIndex(0) -5 >Emitted(8, 33) Source(6, 36) + SourceIndex(0) -6 >Emitted(8, 35) Source(6, 38) + SourceIndex(0) -7 >Emitted(8, 36) Source(6, 39) + SourceIndex(0) ---- ->>>function m2_f1() { -1 > -2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -1 >Emitted(9, 1) Source(7, 1) + SourceIndex(0) ---- ->>> return exports.m2_instance1; -1->^^^^ -2 > ^^^^^^ -3 > ^ -4 > ^^^^^^^^^^^^^^^^^^^^ -5 > ^ -1->export function m2_f1() { - > -2 > return -3 > -4 > m2_instance1 -5 > ; -1->Emitted(10, 5) Source(8, 5) + SourceIndex(0) name (m2_f1) -2 >Emitted(10, 11) Source(8, 11) + SourceIndex(0) name (m2_f1) -3 >Emitted(10, 12) Source(8, 12) + SourceIndex(0) name (m2_f1) -4 >Emitted(10, 32) Source(8, 24) + SourceIndex(0) name (m2_f1) -5 >Emitted(10, 33) Source(8, 25) + SourceIndex(0) name (m2_f1) ---- ->>>} -1 > -2 >^ -3 > ^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -2 >} -1 >Emitted(11, 1) Source(9, 1) + SourceIndex(0) name (m2_f1) -2 >Emitted(11, 2) Source(9, 2) + SourceIndex(0) name (m2_f1) ---- ->>>exports.m2_f1 = m2_f1; -1-> -2 >^^^^^^^^^^^^^ -3 > ^^^^^^^^ -4 > ^ -5 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1-> -2 >m2_f1 -3 > () { - > return m2_instance1; - > } -4 > -1->Emitted(12, 1) Source(7, 17) + SourceIndex(0) -2 >Emitted(12, 14) Source(7, 22) + SourceIndex(0) -3 >Emitted(12, 22) Source(9, 2) + SourceIndex(0) -4 >Emitted(12, 23) Source(9, 2) + SourceIndex(0) ---- ->>>//# sourceMappingURL=http://www.typescriptlang.org/outputdir_module_multifolder_ref/m2.js.map=================================================================== -JsFile: test.js -mapUrl: http://www.typescriptlang.org/outputdir_module_multifolder/test.js.map -sourceRoot: http://typescript.codeplex.com/ -sources: outputdir_module_multifolder/test.ts -=================================================================== -------------------------------------------------------------------- -emittedFile:test.js -sourceFile:outputdir_module_multifolder/test.ts -------------------------------------------------------------------- ->>>var m1 = require("ref/m1"); -1 > -2 >^^^^ -3 > ^^ -4 > ^^^^^^^^^^^ -5 > ^^^^^^^^ -6 > ^ -7 > ^ -8 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 > -2 >import -3 > m1 -4 > = require( -5 > "ref/m1" -6 > ) -7 > ; -1 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) -2 >Emitted(1, 5) Source(1, 8) + SourceIndex(0) -3 >Emitted(1, 7) Source(1, 10) + SourceIndex(0) -4 >Emitted(1, 18) Source(1, 21) + SourceIndex(0) -5 >Emitted(1, 26) Source(1, 29) + SourceIndex(0) -6 >Emitted(1, 27) Source(1, 30) + SourceIndex(0) -7 >Emitted(1, 28) Source(1, 31) + SourceIndex(0) ---- ->>>var m2 = require("../outputdir_module_multifolder_ref/m2"); -1-> -2 >^^^^ -3 > ^^ -4 > ^^^^^^^^^^^ -5 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -6 > ^ -7 > ^ -1-> - > -2 >import -3 > m2 -4 > = require( -5 > "../outputdir_module_multifolder_ref/m2" -6 > ) -7 > ; -1->Emitted(2, 1) Source(2, 1) + SourceIndex(0) -2 >Emitted(2, 5) Source(2, 8) + SourceIndex(0) -3 >Emitted(2, 7) Source(2, 10) + SourceIndex(0) -4 >Emitted(2, 18) Source(2, 21) + SourceIndex(0) -5 >Emitted(2, 58) Source(2, 61) + SourceIndex(0) -6 >Emitted(2, 59) Source(2, 62) + SourceIndex(0) -7 >Emitted(2, 60) Source(2, 63) + SourceIndex(0) ---- ->>>exports.a1 = 10; -1 > -2 >^^^^^^^^^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^-> -1 > - >export var -2 >a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(3, 1) Source(3, 12) + SourceIndex(0) -2 >Emitted(3, 11) Source(3, 14) + SourceIndex(0) -3 >Emitted(3, 14) Source(3, 17) + SourceIndex(0) -4 >Emitted(3, 16) Source(3, 19) + SourceIndex(0) -5 >Emitted(3, 17) Source(3, 20) + SourceIndex(0) ---- ->>>var c1 = (function () { -1-> -2 >^^^^^^^^^^^^^^^^^^^^-> -1-> - > -1->Emitted(4, 1) Source(4, 1) + SourceIndex(0) ---- ->>> function c1() { -1->^^^^ -2 > ^^-> -1-> -1->Emitted(5, 5) Source(4, 1) + SourceIndex(0) name (c1) ---- ->>> } -1->^^^^ -2 > ^ -3 > ^^^^^^^^^^-> -1->export class c1 { - > public p1: number; - > -2 > } -1->Emitted(6, 5) Source(6, 1) + SourceIndex(0) name (c1.constructor) -2 >Emitted(6, 6) Source(6, 2) + SourceIndex(0) name (c1.constructor) ---- ->>> return c1; -1->^^^^ -2 > ^^^^^^^^^ -1-> -2 > } -1->Emitted(7, 5) Source(6, 1) + SourceIndex(0) name (c1) -2 >Emitted(7, 14) Source(6, 2) + SourceIndex(0) name (c1) ---- ->>>})(); -1 > -2 >^ -3 > -4 > ^^^^ -5 > ^^^^^^^^^^^^-> -1 > -2 >} -3 > -4 > export class c1 { - > public p1: number; - > } -1 >Emitted(8, 1) Source(6, 1) + SourceIndex(0) name (c1) -2 >Emitted(8, 2) Source(6, 2) + SourceIndex(0) name (c1) -3 >Emitted(8, 2) Source(4, 1) + SourceIndex(0) -4 >Emitted(8, 6) Source(6, 2) + SourceIndex(0) ---- ->>>exports.c1 = c1; -1-> -2 >^^^^^^^^^^ -3 > ^^^^^ -4 > ^ -5 > ^^^^^^^^^^^^^^-> -1-> -2 >c1 -3 > { - > public p1: number; - > } -4 > -1->Emitted(9, 1) Source(4, 14) + SourceIndex(0) -2 >Emitted(9, 11) Source(4, 16) + SourceIndex(0) -3 >Emitted(9, 16) Source(6, 2) + SourceIndex(0) -4 >Emitted(9, 17) Source(6, 2) + SourceIndex(0) ---- ->>>exports.instance1 = new c1(); -1-> -2 >^^^^^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^^^ -5 > ^^ -6 > ^^ -7 > ^ -1-> - > - >export var -2 >instance1 -3 > = -4 > new -5 > c1 -6 > () -7 > ; -1->Emitted(10, 1) Source(8, 12) + SourceIndex(0) -2 >Emitted(10, 18) Source(8, 21) + SourceIndex(0) -3 >Emitted(10, 21) Source(8, 24) + SourceIndex(0) -4 >Emitted(10, 25) Source(8, 28) + SourceIndex(0) -5 >Emitted(10, 27) Source(8, 30) + SourceIndex(0) -6 >Emitted(10, 29) Source(8, 32) + SourceIndex(0) -7 >Emitted(10, 30) Source(8, 33) + SourceIndex(0) ---- ->>>function f1() { -1 > -2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -1 >Emitted(11, 1) Source(9, 1) + SourceIndex(0) ---- ->>> return exports.instance1; -1->^^^^ -2 > ^^^^^^ -3 > ^ -4 > ^^^^^^^^^^^^^^^^^ -5 > ^ -1->export function f1() { - > -2 > return -3 > -4 > instance1 -5 > ; -1->Emitted(12, 5) Source(10, 5) + SourceIndex(0) name (f1) -2 >Emitted(12, 11) Source(10, 11) + SourceIndex(0) name (f1) -3 >Emitted(12, 12) Source(10, 12) + SourceIndex(0) name (f1) -4 >Emitted(12, 29) Source(10, 21) + SourceIndex(0) name (f1) -5 >Emitted(12, 30) Source(10, 22) + SourceIndex(0) name (f1) ---- ->>>} -1 > -2 >^ -3 > ^^^^^^^^^^^^^^^^-> -1 > - > -2 >} -1 >Emitted(13, 1) Source(11, 1) + SourceIndex(0) name (f1) -2 >Emitted(13, 2) Source(11, 2) + SourceIndex(0) name (f1) ---- ->>>exports.f1 = f1; -1-> -2 >^^^^^^^^^^ -3 > ^^^^^ -4 > ^ -5 > ^^^^^^^-> -1-> -2 >f1 -3 > () { - > return instance1; - > } -4 > -1->Emitted(14, 1) Source(9, 17) + SourceIndex(0) -2 >Emitted(14, 11) Source(9, 19) + SourceIndex(0) -3 >Emitted(14, 16) Source(11, 2) + SourceIndex(0) -4 >Emitted(14, 17) Source(11, 2) + SourceIndex(0) ---- ->>>exports.a2 = m1.m1_c1; -1-> -2 >^^^^^^^^^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^ -7 > ^ -8 > ^-> -1-> - > - >export var -2 >a2 -3 > = -4 > m1 -5 > . -6 > m1_c1 -7 > ; -1->Emitted(15, 1) Source(13, 12) + SourceIndex(0) -2 >Emitted(15, 11) Source(13, 14) + SourceIndex(0) -3 >Emitted(15, 14) Source(13, 17) + SourceIndex(0) -4 >Emitted(15, 16) Source(13, 19) + SourceIndex(0) -5 >Emitted(15, 17) Source(13, 20) + SourceIndex(0) -6 >Emitted(15, 22) Source(13, 25) + SourceIndex(0) -7 >Emitted(15, 23) Source(13, 26) + SourceIndex(0) ---- ->>>exports.a3 = m2.m2_c1; -1-> -2 >^^^^^^^^^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^ -7 > ^ -8 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1-> - >export var -2 >a3 -3 > = -4 > m2 -5 > . -6 > m2_c1 -7 > ; -1->Emitted(16, 1) Source(14, 12) + SourceIndex(0) -2 >Emitted(16, 11) Source(14, 14) + SourceIndex(0) -3 >Emitted(16, 14) Source(14, 17) + SourceIndex(0) -4 >Emitted(16, 16) Source(14, 19) + SourceIndex(0) -5 >Emitted(16, 17) Source(14, 20) + SourceIndex(0) -6 >Emitted(16, 22) Source(14, 25) + SourceIndex(0) -7 >Emitted(16, 23) Source(14, 26) + SourceIndex(0) ---- ->>>//# sourceMappingURL=http://www.typescriptlang.org/outputdir_module_multifolder/test.js.map=================================================================== JsFile: test.js mapUrl: http://www.typescriptlang.org/test.js.map sourceRoot: http://typescript.codeplex.com/ diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputFile/node/ref/m1.d.ts b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputFile/node/ref/m1.d.ts deleted file mode 100644 index 4a53b24b156..00000000000 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputFile/node/ref/m1.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -export declare var m1_a1: number; -export declare class m1_c1 { - m1_c1_p1: number; -} -export declare var m1_instance1: m1_c1; -export declare function m1_f1(): m1_c1; diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputFile/node/ref/m1.js b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputFile/node/ref/m1.js deleted file mode 100644 index 7b14808a067..00000000000 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputFile/node/ref/m1.js +++ /dev/null @@ -1,13 +0,0 @@ -exports.m1_a1 = 10; -var m1_c1 = (function () { - function m1_c1() { - } - return m1_c1; -})(); -exports.m1_c1 = m1_c1; -exports.m1_instance1 = new m1_c1(); -function m1_f1() { - return exports.m1_instance1; -} -exports.m1_f1 = m1_f1; -//# sourceMappingURL=http://www.typescriptlang.org/outputdir_module_multifolder/ref/m1.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputFile/node/ref/m1.js.map b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputFile/node/ref/m1.js.map deleted file mode 100644 index e7f54a4a2e1..00000000000 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputFile/node/ref/m1.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"m1.js","sourceRoot":"http://typescript.codeplex.com/","sources":["outputdir_module_multifolder/ref/m1.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1"],"mappings":"AAAW,aAAK,GAAG,EAAE,CAAC;AACtB;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAFY,aAAK,QAEjB,CAAA;AAEU,oBAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACIE,MAAMA,CAACA,oBAAYA,CAACA;AACxBA,CAACA;AAFe,aAAK,QAEpB,CAAA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputFile/node/test.d.ts b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputFile/node/test.d.ts deleted file mode 100644 index 4afd4e69f2d..00000000000 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputFile/node/test.d.ts +++ /dev/null @@ -1,10 +0,0 @@ -import m1 = require("ref/m1"); -import m2 = require("../outputdir_module_multifolder_ref/m2"); -export declare var a1: number; -export declare class c1 { - p1: number; -} -export declare var instance1: c1; -export declare function f1(): c1; -export declare var a2: typeof m1.m1_c1; -export declare var a3: typeof m2.m2_c1; diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputFile/node/test.js b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputFile/node/test.js deleted file mode 100644 index b9191db7d5f..00000000000 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputFile/node/test.js +++ /dev/null @@ -1,17 +0,0 @@ -var m1 = require("ref/m1"); -var m2 = require("../outputdir_module_multifolder_ref/m2"); -exports.a1 = 10; -var c1 = (function () { - function c1() { - } - return c1; -})(); -exports.c1 = c1; -exports.instance1 = new c1(); -function f1() { - return exports.instance1; -} -exports.f1 = f1; -exports.a2 = m1.m1_c1; -exports.a3 = m2.m2_c1; -//# sourceMappingURL=http://www.typescriptlang.org/outputdir_module_multifolder/test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputFile/node/test.js.map b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputFile/node/test.js.map deleted file mode 100644 index 4ac74c2fcdb..00000000000 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputFile/node/test.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"test.js","sourceRoot":"http://typescript.codeplex.com/","sources":["outputdir_module_multifolder/test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AAAA,IAAO,EAAE,WAAW,QAAQ,CAAC,CAAC;AAC9B,IAAO,EAAE,WAAW,wCAAwC,CAAC,CAAC;AACnD,UAAE,GAAG,EAAE,CAAC;AACnB;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAFY,UAAE,KAEd,CAAA;AAEU,iBAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AAChC;IACIE,MAAMA,CAACA,iBAASA,CAACA;AACrBA,CAACA;AAFe,UAAE,KAEjB,CAAA;AAEU,UAAE,GAAG,EAAE,CAAC,KAAK,CAAC;AACd,UAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSimpleSpecifyOutputFile/amd/m1.d.ts b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSimpleSpecifyOutputFile/amd/m1.d.ts deleted file mode 100644 index 4a53b24b156..00000000000 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSimpleSpecifyOutputFile/amd/m1.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -export declare var m1_a1: number; -export declare class m1_c1 { - m1_c1_p1: number; -} -export declare var m1_instance1: m1_c1; -export declare function m1_f1(): m1_c1; diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSimpleSpecifyOutputFile/amd/m1.js b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSimpleSpecifyOutputFile/amd/m1.js deleted file mode 100644 index 1a4d200cdcb..00000000000 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSimpleSpecifyOutputFile/amd/m1.js +++ /dev/null @@ -1,15 +0,0 @@ -define(["require", "exports"], function (require, exports) { - exports.m1_a1 = 10; - var m1_c1 = (function () { - function m1_c1() { - } - return m1_c1; - })(); - exports.m1_c1 = m1_c1; - exports.m1_instance1 = new m1_c1(); - function m1_f1() { - return exports.m1_instance1; - } - exports.m1_f1 = m1_f1; -}); -//# sourceMappingURL=http://www.typescriptlang.org/m1.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSimpleSpecifyOutputFile/amd/m1.js.map b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSimpleSpecifyOutputFile/amd/m1.js.map deleted file mode 100644 index 6751f2f82cd..00000000000 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSimpleSpecifyOutputFile/amd/m1.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"m1.js","sourceRoot":"http://typescript.codeplex.com/","sources":["m1.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1"],"mappings":";IAAW,aAAK,GAAG,EAAE,CAAC;IACtB;QAAAA;QAEAC,CAACA;QAADD,YAACA;IAADA,CAACA,AAFD,IAEC;IAFY,aAAK,QAEjB,CAAA;IAEU,oBAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACIE,MAAMA,CAACA,oBAAYA,CAACA;IACxBA,CAACA;IAFe,aAAK,QAEpB,CAAA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSimpleSpecifyOutputFile/amd/maprootUrlsourcerootUrlModuleSimpleSpecifyOutputFile.json b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSimpleSpecifyOutputFile/amd/maprootUrlsourcerootUrlModuleSimpleSpecifyOutputFile.json index 2cfc9aebda2..d8ff0027520 100644 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSimpleSpecifyOutputFile/amd/maprootUrlsourcerootUrlModuleSimpleSpecifyOutputFile.json +++ b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSimpleSpecifyOutputFile/amd/maprootUrlsourcerootUrlModuleSimpleSpecifyOutputFile.json @@ -16,12 +16,6 @@ "test.ts" ], "emittedFiles": [ - "m1.js.map", - "m1.js", - "m1.d.ts", - "test.js.map", - "test.js", - "test.d.ts", "bin/test.js.map", "bin/test.js", "bin/test.d.ts" diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSimpleSpecifyOutputFile/amd/maprootUrlsourcerootUrlModuleSimpleSpecifyOutputFile.sourcemap.txt b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSimpleSpecifyOutputFile/amd/maprootUrlsourcerootUrlModuleSimpleSpecifyOutputFile.sourcemap.txt index 6e3a046bb27..bd33dbb5ec7 100644 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSimpleSpecifyOutputFile/amd/maprootUrlsourcerootUrlModuleSimpleSpecifyOutputFile.sourcemap.txt +++ b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSimpleSpecifyOutputFile/amd/maprootUrlsourcerootUrlModuleSimpleSpecifyOutputFile.sourcemap.txt @@ -1,375 +1,4 @@ =================================================================== -JsFile: m1.js -mapUrl: http://www.typescriptlang.org/m1.js.map -sourceRoot: http://typescript.codeplex.com/ -sources: m1.ts -=================================================================== -------------------------------------------------------------------- -emittedFile:m1.js -sourceFile:m1.ts -------------------------------------------------------------------- ->>>define(["require", "exports"], function (require, exports) { ->>> exports.m1_a1 = 10; -1 >^^^^ -2 > ^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^-> -1 >export var -2 > m1_a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(2, 5) Source(1, 12) + SourceIndex(0) -2 >Emitted(2, 18) Source(1, 17) + SourceIndex(0) -3 >Emitted(2, 21) Source(1, 20) + SourceIndex(0) -4 >Emitted(2, 23) Source(1, 22) + SourceIndex(0) -5 >Emitted(2, 24) Source(1, 23) + SourceIndex(0) ---- ->>> var m1_c1 = (function () { -1->^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^^^^-> -1-> - > -1->Emitted(3, 5) Source(2, 1) + SourceIndex(0) ---- ->>> function m1_c1() { -1->^^^^^^^^ -2 > ^^-> -1-> -1->Emitted(4, 9) Source(2, 1) + SourceIndex(0) name (m1_c1) ---- ->>> } -1->^^^^^^^^ -2 > ^ -3 > ^^^^^^^^^^^^^-> -1->export class m1_c1 { - > public m1_c1_p1: number; - > -2 > } -1->Emitted(5, 9) Source(4, 1) + SourceIndex(0) name (m1_c1.constructor) -2 >Emitted(5, 10) Source(4, 2) + SourceIndex(0) name (m1_c1.constructor) ---- ->>> return m1_c1; -1->^^^^^^^^ -2 > ^^^^^^^^^^^^ -1-> -2 > } -1->Emitted(6, 9) Source(4, 1) + SourceIndex(0) name (m1_c1) -2 >Emitted(6, 21) Source(4, 2) + SourceIndex(0) name (m1_c1) ---- ->>> })(); -1 >^^^^ -2 > ^ -3 > -4 > ^^^^ -5 > ^^^^^^^^^^^^^^^^^^-> -1 > -2 > } -3 > -4 > export class m1_c1 { - > public m1_c1_p1: number; - > } -1 >Emitted(7, 5) Source(4, 1) + SourceIndex(0) name (m1_c1) -2 >Emitted(7, 6) Source(4, 2) + SourceIndex(0) name (m1_c1) -3 >Emitted(7, 6) Source(2, 1) + SourceIndex(0) -4 >Emitted(7, 10) Source(4, 2) + SourceIndex(0) ---- ->>> exports.m1_c1 = m1_c1; -1->^^^^ -2 > ^^^^^^^^^^^^^ -3 > ^^^^^^^^ -4 > ^ -5 > ^^^^^^^^^^^^^^-> -1-> -2 > m1_c1 -3 > { - > public m1_c1_p1: number; - > } -4 > -1->Emitted(8, 5) Source(2, 14) + SourceIndex(0) -2 >Emitted(8, 18) Source(2, 19) + SourceIndex(0) -3 >Emitted(8, 26) Source(4, 2) + SourceIndex(0) -4 >Emitted(8, 27) Source(4, 2) + SourceIndex(0) ---- ->>> exports.m1_instance1 = new m1_c1(); -1->^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^^^ -5 > ^^^^^ -6 > ^^ -7 > ^ -1-> - > - >export var -2 > m1_instance1 -3 > = -4 > new -5 > m1_c1 -6 > () -7 > ; -1->Emitted(9, 5) Source(6, 12) + SourceIndex(0) -2 >Emitted(9, 25) Source(6, 24) + SourceIndex(0) -3 >Emitted(9, 28) Source(6, 27) + SourceIndex(0) -4 >Emitted(9, 32) Source(6, 31) + SourceIndex(0) -5 >Emitted(9, 37) Source(6, 36) + SourceIndex(0) -6 >Emitted(9, 39) Source(6, 38) + SourceIndex(0) -7 >Emitted(9, 40) Source(6, 39) + SourceIndex(0) ---- ->>> function m1_f1() { -1 >^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -1 >Emitted(10, 5) Source(7, 1) + SourceIndex(0) ---- ->>> return exports.m1_instance1; -1->^^^^^^^^ -2 > ^^^^^^ -3 > ^ -4 > ^^^^^^^^^^^^^^^^^^^^ -5 > ^ -1->export function m1_f1() { - > -2 > return -3 > -4 > m1_instance1 -5 > ; -1->Emitted(11, 9) Source(8, 5) + SourceIndex(0) name (m1_f1) -2 >Emitted(11, 15) Source(8, 11) + SourceIndex(0) name (m1_f1) -3 >Emitted(11, 16) Source(8, 12) + SourceIndex(0) name (m1_f1) -4 >Emitted(11, 36) Source(8, 24) + SourceIndex(0) name (m1_f1) -5 >Emitted(11, 37) Source(8, 25) + SourceIndex(0) name (m1_f1) ---- ->>> } -1 >^^^^ -2 > ^ -3 > ^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -2 > } -1 >Emitted(12, 5) Source(9, 1) + SourceIndex(0) name (m1_f1) -2 >Emitted(12, 6) Source(9, 2) + SourceIndex(0) name (m1_f1) ---- ->>> exports.m1_f1 = m1_f1; -1->^^^^ -2 > ^^^^^^^^^^^^^ -3 > ^^^^^^^^ -4 > ^ -1-> -2 > m1_f1 -3 > () { - > return m1_instance1; - > } -4 > -1->Emitted(13, 5) Source(7, 17) + SourceIndex(0) -2 >Emitted(13, 18) Source(7, 22) + SourceIndex(0) -3 >Emitted(13, 26) Source(9, 2) + SourceIndex(0) -4 >Emitted(13, 27) Source(9, 2) + SourceIndex(0) ---- ->>>}); ->>>//# sourceMappingURL=http://www.typescriptlang.org/m1.js.map=================================================================== -JsFile: test.js -mapUrl: http://www.typescriptlang.org/test.js.map -sourceRoot: http://typescript.codeplex.com/ -sources: test.ts -=================================================================== -------------------------------------------------------------------- -emittedFile:test.js -sourceFile:test.ts -------------------------------------------------------------------- ->>>define(["require", "exports", "m1"], function (require, exports, m1) { ->>> exports.a1 = 10; -1 >^^^^ -2 > ^^^^^^^^^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^-> -1 >import m1 = require("m1"); - >export var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(2, 5) Source(2, 12) + SourceIndex(0) -2 >Emitted(2, 15) Source(2, 14) + SourceIndex(0) -3 >Emitted(2, 18) Source(2, 17) + SourceIndex(0) -4 >Emitted(2, 20) Source(2, 19) + SourceIndex(0) -5 >Emitted(2, 21) Source(2, 20) + SourceIndex(0) ---- ->>> var c1 = (function () { -1->^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^-> -1-> - > -1->Emitted(3, 5) Source(3, 1) + SourceIndex(0) ---- ->>> function c1() { -1->^^^^^^^^ -2 > ^^-> -1-> -1->Emitted(4, 9) Source(3, 1) + SourceIndex(0) name (c1) ---- ->>> } -1->^^^^^^^^ -2 > ^ -3 > ^^^^^^^^^^-> -1->export class c1 { - > public p1: number; - > -2 > } -1->Emitted(5, 9) Source(5, 1) + SourceIndex(0) name (c1.constructor) -2 >Emitted(5, 10) Source(5, 2) + SourceIndex(0) name (c1.constructor) ---- ->>> return c1; -1->^^^^^^^^ -2 > ^^^^^^^^^ -1-> -2 > } -1->Emitted(6, 9) Source(5, 1) + SourceIndex(0) name (c1) -2 >Emitted(6, 18) Source(5, 2) + SourceIndex(0) name (c1) ---- ->>> })(); -1 >^^^^ -2 > ^ -3 > -4 > ^^^^ -5 > ^^^^^^^^^^^^-> -1 > -2 > } -3 > -4 > export class c1 { - > public p1: number; - > } -1 >Emitted(7, 5) Source(5, 1) + SourceIndex(0) name (c1) -2 >Emitted(7, 6) Source(5, 2) + SourceIndex(0) name (c1) -3 >Emitted(7, 6) Source(3, 1) + SourceIndex(0) -4 >Emitted(7, 10) Source(5, 2) + SourceIndex(0) ---- ->>> exports.c1 = c1; -1->^^^^ -2 > ^^^^^^^^^^ -3 > ^^^^^ -4 > ^ -5 > ^^^^^^^^^^^^^^-> -1-> -2 > c1 -3 > { - > public p1: number; - > } -4 > -1->Emitted(8, 5) Source(3, 14) + SourceIndex(0) -2 >Emitted(8, 15) Source(3, 16) + SourceIndex(0) -3 >Emitted(8, 20) Source(5, 2) + SourceIndex(0) -4 >Emitted(8, 21) Source(5, 2) + SourceIndex(0) ---- ->>> exports.instance1 = new c1(); -1->^^^^ -2 > ^^^^^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^^^ -5 > ^^ -6 > ^^ -7 > ^ -1-> - > - >export var -2 > instance1 -3 > = -4 > new -5 > c1 -6 > () -7 > ; -1->Emitted(9, 5) Source(7, 12) + SourceIndex(0) -2 >Emitted(9, 22) Source(7, 21) + SourceIndex(0) -3 >Emitted(9, 25) Source(7, 24) + SourceIndex(0) -4 >Emitted(9, 29) Source(7, 28) + SourceIndex(0) -5 >Emitted(9, 31) Source(7, 30) + SourceIndex(0) -6 >Emitted(9, 33) Source(7, 32) + SourceIndex(0) -7 >Emitted(9, 34) Source(7, 33) + SourceIndex(0) ---- ->>> function f1() { -1 >^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -1 >Emitted(10, 5) Source(8, 1) + SourceIndex(0) ---- ->>> return exports.instance1; -1->^^^^^^^^ -2 > ^^^^^^ -3 > ^ -4 > ^^^^^^^^^^^^^^^^^ -5 > ^ -1->export function f1() { - > -2 > return -3 > -4 > instance1 -5 > ; -1->Emitted(11, 9) Source(9, 5) + SourceIndex(0) name (f1) -2 >Emitted(11, 15) Source(9, 11) + SourceIndex(0) name (f1) -3 >Emitted(11, 16) Source(9, 12) + SourceIndex(0) name (f1) -4 >Emitted(11, 33) Source(9, 21) + SourceIndex(0) name (f1) -5 >Emitted(11, 34) Source(9, 22) + SourceIndex(0) name (f1) ---- ->>> } -1 >^^^^ -2 > ^ -3 > ^^^^^^^^^^^^^^^^-> -1 > - > -2 > } -1 >Emitted(12, 5) Source(10, 1) + SourceIndex(0) name (f1) -2 >Emitted(12, 6) Source(10, 2) + SourceIndex(0) name (f1) ---- ->>> exports.f1 = f1; -1->^^^^ -2 > ^^^^^^^^^^ -3 > ^^^^^ -4 > ^ -5 > ^^^^^^^-> -1-> -2 > f1 -3 > () { - > return instance1; - > } -4 > -1->Emitted(13, 5) Source(8, 17) + SourceIndex(0) -2 >Emitted(13, 15) Source(8, 19) + SourceIndex(0) -3 >Emitted(13, 20) Source(10, 2) + SourceIndex(0) -4 >Emitted(13, 21) Source(10, 2) + SourceIndex(0) ---- ->>> exports.a2 = m1.m1_c1; -1->^^^^ -2 > ^^^^^^^^^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^ -7 > ^ -1-> - > - >export var -2 > a2 -3 > = -4 > m1 -5 > . -6 > m1_c1 -7 > ; -1->Emitted(14, 5) Source(12, 12) + SourceIndex(0) -2 >Emitted(14, 15) Source(12, 14) + SourceIndex(0) -3 >Emitted(14, 18) Source(12, 17) + SourceIndex(0) -4 >Emitted(14, 20) Source(12, 19) + SourceIndex(0) -5 >Emitted(14, 21) Source(12, 20) + SourceIndex(0) -6 >Emitted(14, 26) Source(12, 25) + SourceIndex(0) -7 >Emitted(14, 27) Source(12, 26) + SourceIndex(0) ---- ->>>}); ->>>//# sourceMappingURL=http://www.typescriptlang.org/test.js.map=================================================================== JsFile: test.js mapUrl: http://www.typescriptlang.org/test.js.map sourceRoot: http://typescript.codeplex.com/ diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSimpleSpecifyOutputFile/amd/test.d.ts b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSimpleSpecifyOutputFile/amd/test.d.ts deleted file mode 100644 index 250d2615a79..00000000000 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSimpleSpecifyOutputFile/amd/test.d.ts +++ /dev/null @@ -1,8 +0,0 @@ -import m1 = require("m1"); -export declare var a1: number; -export declare class c1 { - p1: number; -} -export declare var instance1: c1; -export declare function f1(): c1; -export declare var a2: typeof m1.m1_c1; diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSimpleSpecifyOutputFile/amd/test.js b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSimpleSpecifyOutputFile/amd/test.js deleted file mode 100644 index d752d7f8395..00000000000 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSimpleSpecifyOutputFile/amd/test.js +++ /dev/null @@ -1,16 +0,0 @@ -define(["require", "exports", "m1"], function (require, exports, m1) { - exports.a1 = 10; - var c1 = (function () { - function c1() { - } - return c1; - })(); - exports.c1 = c1; - exports.instance1 = new c1(); - function f1() { - return exports.instance1; - } - exports.f1 = f1; - exports.a2 = m1.m1_c1; -}); -//# sourceMappingURL=http://www.typescriptlang.org/test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSimpleSpecifyOutputFile/amd/test.js.map b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSimpleSpecifyOutputFile/amd/test.js.map deleted file mode 100644 index a57b57d2b17..00000000000 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSimpleSpecifyOutputFile/amd/test.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"test.js","sourceRoot":"http://typescript.codeplex.com/","sources":["test.ts"],"names":["c1","c1.constructor","f1"],"mappings":";IACW,UAAE,GAAG,EAAE,CAAC;IACnB;QAAAA;QAEAC,CAACA;QAADD,SAACA;IAADA,CAACA,AAFD,IAEC;IAFY,UAAE,KAEd,CAAA;IAEU,iBAAS,GAAG,IAAI,EAAE,EAAE,CAAC;IAChC;QACIE,MAAMA,CAACA,iBAASA,CAACA;IACrBA,CAACA;IAFe,UAAE,KAEjB,CAAA;IAEU,UAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSimpleSpecifyOutputFile/node/m1.d.ts b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSimpleSpecifyOutputFile/node/m1.d.ts deleted file mode 100644 index 4a53b24b156..00000000000 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSimpleSpecifyOutputFile/node/m1.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -export declare var m1_a1: number; -export declare class m1_c1 { - m1_c1_p1: number; -} -export declare var m1_instance1: m1_c1; -export declare function m1_f1(): m1_c1; diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSimpleSpecifyOutputFile/node/m1.js b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSimpleSpecifyOutputFile/node/m1.js deleted file mode 100644 index 02ca4ab81c7..00000000000 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSimpleSpecifyOutputFile/node/m1.js +++ /dev/null @@ -1,13 +0,0 @@ -exports.m1_a1 = 10; -var m1_c1 = (function () { - function m1_c1() { - } - return m1_c1; -})(); -exports.m1_c1 = m1_c1; -exports.m1_instance1 = new m1_c1(); -function m1_f1() { - return exports.m1_instance1; -} -exports.m1_f1 = m1_f1; -//# sourceMappingURL=http://www.typescriptlang.org/m1.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSimpleSpecifyOutputFile/node/m1.js.map b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSimpleSpecifyOutputFile/node/m1.js.map deleted file mode 100644 index ca45773f423..00000000000 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSimpleSpecifyOutputFile/node/m1.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"m1.js","sourceRoot":"http://typescript.codeplex.com/","sources":["m1.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1"],"mappings":"AAAW,aAAK,GAAG,EAAE,CAAC;AACtB;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAFY,aAAK,QAEjB,CAAA;AAEU,oBAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACIE,MAAMA,CAACA,oBAAYA,CAACA;AACxBA,CAACA;AAFe,aAAK,QAEpB,CAAA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSimpleSpecifyOutputFile/node/maprootUrlsourcerootUrlModuleSimpleSpecifyOutputFile.json b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSimpleSpecifyOutputFile/node/maprootUrlsourcerootUrlModuleSimpleSpecifyOutputFile.json index 2cfc9aebda2..d8ff0027520 100644 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSimpleSpecifyOutputFile/node/maprootUrlsourcerootUrlModuleSimpleSpecifyOutputFile.json +++ b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSimpleSpecifyOutputFile/node/maprootUrlsourcerootUrlModuleSimpleSpecifyOutputFile.json @@ -16,12 +16,6 @@ "test.ts" ], "emittedFiles": [ - "m1.js.map", - "m1.js", - "m1.d.ts", - "test.js.map", - "test.js", - "test.d.ts", "bin/test.js.map", "bin/test.js", "bin/test.d.ts" diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSimpleSpecifyOutputFile/node/maprootUrlsourcerootUrlModuleSimpleSpecifyOutputFile.sourcemap.txt b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSimpleSpecifyOutputFile/node/maprootUrlsourcerootUrlModuleSimpleSpecifyOutputFile.sourcemap.txt index d52a70d4dac..d9df59725a9 100644 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSimpleSpecifyOutputFile/node/maprootUrlsourcerootUrlModuleSimpleSpecifyOutputFile.sourcemap.txt +++ b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSimpleSpecifyOutputFile/node/maprootUrlsourcerootUrlModuleSimpleSpecifyOutputFile.sourcemap.txt @@ -1,396 +1,4 @@ =================================================================== -JsFile: m1.js -mapUrl: http://www.typescriptlang.org/m1.js.map -sourceRoot: http://typescript.codeplex.com/ -sources: m1.ts -=================================================================== -------------------------------------------------------------------- -emittedFile:m1.js -sourceFile:m1.ts -------------------------------------------------------------------- ->>>exports.m1_a1 = 10; -1 > -2 >^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^-> -1 >export var -2 >m1_a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(1, 1) Source(1, 12) + SourceIndex(0) -2 >Emitted(1, 14) Source(1, 17) + SourceIndex(0) -3 >Emitted(1, 17) Source(1, 20) + SourceIndex(0) -4 >Emitted(1, 19) Source(1, 22) + SourceIndex(0) -5 >Emitted(1, 20) Source(1, 23) + SourceIndex(0) ---- ->>>var m1_c1 = (function () { -1-> -2 >^^^^^^^^^^^^^^^^^^^^^^^-> -1-> - > -1->Emitted(2, 1) Source(2, 1) + SourceIndex(0) ---- ->>> function m1_c1() { -1->^^^^ -2 > ^^-> -1-> -1->Emitted(3, 5) Source(2, 1) + SourceIndex(0) name (m1_c1) ---- ->>> } -1->^^^^ -2 > ^ -3 > ^^^^^^^^^^^^^-> -1->export class m1_c1 { - > public m1_c1_p1: number; - > -2 > } -1->Emitted(4, 5) Source(4, 1) + SourceIndex(0) name (m1_c1.constructor) -2 >Emitted(4, 6) Source(4, 2) + SourceIndex(0) name (m1_c1.constructor) ---- ->>> return m1_c1; -1->^^^^ -2 > ^^^^^^^^^^^^ -1-> -2 > } -1->Emitted(5, 5) Source(4, 1) + SourceIndex(0) name (m1_c1) -2 >Emitted(5, 17) Source(4, 2) + SourceIndex(0) name (m1_c1) ---- ->>>})(); -1 > -2 >^ -3 > -4 > ^^^^ -5 > ^^^^^^^^^^^^^^^^^^-> -1 > -2 >} -3 > -4 > export class m1_c1 { - > public m1_c1_p1: number; - > } -1 >Emitted(6, 1) Source(4, 1) + SourceIndex(0) name (m1_c1) -2 >Emitted(6, 2) Source(4, 2) + SourceIndex(0) name (m1_c1) -3 >Emitted(6, 2) Source(2, 1) + SourceIndex(0) -4 >Emitted(6, 6) Source(4, 2) + SourceIndex(0) ---- ->>>exports.m1_c1 = m1_c1; -1-> -2 >^^^^^^^^^^^^^ -3 > ^^^^^^^^ -4 > ^ -5 > ^^^^^^^^^^^^^^-> -1-> -2 >m1_c1 -3 > { - > public m1_c1_p1: number; - > } -4 > -1->Emitted(7, 1) Source(2, 14) + SourceIndex(0) -2 >Emitted(7, 14) Source(2, 19) + SourceIndex(0) -3 >Emitted(7, 22) Source(4, 2) + SourceIndex(0) -4 >Emitted(7, 23) Source(4, 2) + SourceIndex(0) ---- ->>>exports.m1_instance1 = new m1_c1(); -1-> -2 >^^^^^^^^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^^^ -5 > ^^^^^ -6 > ^^ -7 > ^ -1-> - > - >export var -2 >m1_instance1 -3 > = -4 > new -5 > m1_c1 -6 > () -7 > ; -1->Emitted(8, 1) Source(6, 12) + SourceIndex(0) -2 >Emitted(8, 21) Source(6, 24) + SourceIndex(0) -3 >Emitted(8, 24) Source(6, 27) + SourceIndex(0) -4 >Emitted(8, 28) Source(6, 31) + SourceIndex(0) -5 >Emitted(8, 33) Source(6, 36) + SourceIndex(0) -6 >Emitted(8, 35) Source(6, 38) + SourceIndex(0) -7 >Emitted(8, 36) Source(6, 39) + SourceIndex(0) ---- ->>>function m1_f1() { -1 > -2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -1 >Emitted(9, 1) Source(7, 1) + SourceIndex(0) ---- ->>> return exports.m1_instance1; -1->^^^^ -2 > ^^^^^^ -3 > ^ -4 > ^^^^^^^^^^^^^^^^^^^^ -5 > ^ -1->export function m1_f1() { - > -2 > return -3 > -4 > m1_instance1 -5 > ; -1->Emitted(10, 5) Source(8, 5) + SourceIndex(0) name (m1_f1) -2 >Emitted(10, 11) Source(8, 11) + SourceIndex(0) name (m1_f1) -3 >Emitted(10, 12) Source(8, 12) + SourceIndex(0) name (m1_f1) -4 >Emitted(10, 32) Source(8, 24) + SourceIndex(0) name (m1_f1) -5 >Emitted(10, 33) Source(8, 25) + SourceIndex(0) name (m1_f1) ---- ->>>} -1 > -2 >^ -3 > ^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -2 >} -1 >Emitted(11, 1) Source(9, 1) + SourceIndex(0) name (m1_f1) -2 >Emitted(11, 2) Source(9, 2) + SourceIndex(0) name (m1_f1) ---- ->>>exports.m1_f1 = m1_f1; -1-> -2 >^^^^^^^^^^^^^ -3 > ^^^^^^^^ -4 > ^ -5 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1-> -2 >m1_f1 -3 > () { - > return m1_instance1; - > } -4 > -1->Emitted(12, 1) Source(7, 17) + SourceIndex(0) -2 >Emitted(12, 14) Source(7, 22) + SourceIndex(0) -3 >Emitted(12, 22) Source(9, 2) + SourceIndex(0) -4 >Emitted(12, 23) Source(9, 2) + SourceIndex(0) ---- ->>>//# sourceMappingURL=http://www.typescriptlang.org/m1.js.map=================================================================== -JsFile: test.js -mapUrl: http://www.typescriptlang.org/test.js.map -sourceRoot: http://typescript.codeplex.com/ -sources: test.ts -=================================================================== -------------------------------------------------------------------- -emittedFile:test.js -sourceFile:test.ts -------------------------------------------------------------------- ->>>var m1 = require("m1"); -1 > -2 >^^^^ -3 > ^^ -4 > ^^^^^^^^^^^ -5 > ^^^^ -6 > ^ -7 > ^ -1 > -2 >import -3 > m1 -4 > = require( -5 > "m1" -6 > ) -7 > ; -1 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) -2 >Emitted(1, 5) Source(1, 8) + SourceIndex(0) -3 >Emitted(1, 7) Source(1, 10) + SourceIndex(0) -4 >Emitted(1, 18) Source(1, 21) + SourceIndex(0) -5 >Emitted(1, 22) Source(1, 25) + SourceIndex(0) -6 >Emitted(1, 23) Source(1, 26) + SourceIndex(0) -7 >Emitted(1, 24) Source(1, 27) + SourceIndex(0) ---- ->>>exports.a1 = 10; -1 > -2 >^^^^^^^^^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^-> -1 > - >export var -2 >a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(2, 1) Source(2, 12) + SourceIndex(0) -2 >Emitted(2, 11) Source(2, 14) + SourceIndex(0) -3 >Emitted(2, 14) Source(2, 17) + SourceIndex(0) -4 >Emitted(2, 16) Source(2, 19) + SourceIndex(0) -5 >Emitted(2, 17) Source(2, 20) + SourceIndex(0) ---- ->>>var c1 = (function () { -1-> -2 >^^^^^^^^^^^^^^^^^^^^-> -1-> - > -1->Emitted(3, 1) Source(3, 1) + SourceIndex(0) ---- ->>> function c1() { -1->^^^^ -2 > ^^-> -1-> -1->Emitted(4, 5) Source(3, 1) + SourceIndex(0) name (c1) ---- ->>> } -1->^^^^ -2 > ^ -3 > ^^^^^^^^^^-> -1->export class c1 { - > public p1: number; - > -2 > } -1->Emitted(5, 5) Source(5, 1) + SourceIndex(0) name (c1.constructor) -2 >Emitted(5, 6) Source(5, 2) + SourceIndex(0) name (c1.constructor) ---- ->>> return c1; -1->^^^^ -2 > ^^^^^^^^^ -1-> -2 > } -1->Emitted(6, 5) Source(5, 1) + SourceIndex(0) name (c1) -2 >Emitted(6, 14) Source(5, 2) + SourceIndex(0) name (c1) ---- ->>>})(); -1 > -2 >^ -3 > -4 > ^^^^ -5 > ^^^^^^^^^^^^-> -1 > -2 >} -3 > -4 > export class c1 { - > public p1: number; - > } -1 >Emitted(7, 1) Source(5, 1) + SourceIndex(0) name (c1) -2 >Emitted(7, 2) Source(5, 2) + SourceIndex(0) name (c1) -3 >Emitted(7, 2) Source(3, 1) + SourceIndex(0) -4 >Emitted(7, 6) Source(5, 2) + SourceIndex(0) ---- ->>>exports.c1 = c1; -1-> -2 >^^^^^^^^^^ -3 > ^^^^^ -4 > ^ -5 > ^^^^^^^^^^^^^^-> -1-> -2 >c1 -3 > { - > public p1: number; - > } -4 > -1->Emitted(8, 1) Source(3, 14) + SourceIndex(0) -2 >Emitted(8, 11) Source(3, 16) + SourceIndex(0) -3 >Emitted(8, 16) Source(5, 2) + SourceIndex(0) -4 >Emitted(8, 17) Source(5, 2) + SourceIndex(0) ---- ->>>exports.instance1 = new c1(); -1-> -2 >^^^^^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^^^ -5 > ^^ -6 > ^^ -7 > ^ -1-> - > - >export var -2 >instance1 -3 > = -4 > new -5 > c1 -6 > () -7 > ; -1->Emitted(9, 1) Source(7, 12) + SourceIndex(0) -2 >Emitted(9, 18) Source(7, 21) + SourceIndex(0) -3 >Emitted(9, 21) Source(7, 24) + SourceIndex(0) -4 >Emitted(9, 25) Source(7, 28) + SourceIndex(0) -5 >Emitted(9, 27) Source(7, 30) + SourceIndex(0) -6 >Emitted(9, 29) Source(7, 32) + SourceIndex(0) -7 >Emitted(9, 30) Source(7, 33) + SourceIndex(0) ---- ->>>function f1() { -1 > -2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -1 >Emitted(10, 1) Source(8, 1) + SourceIndex(0) ---- ->>> return exports.instance1; -1->^^^^ -2 > ^^^^^^ -3 > ^ -4 > ^^^^^^^^^^^^^^^^^ -5 > ^ -1->export function f1() { - > -2 > return -3 > -4 > instance1 -5 > ; -1->Emitted(11, 5) Source(9, 5) + SourceIndex(0) name (f1) -2 >Emitted(11, 11) Source(9, 11) + SourceIndex(0) name (f1) -3 >Emitted(11, 12) Source(9, 12) + SourceIndex(0) name (f1) -4 >Emitted(11, 29) Source(9, 21) + SourceIndex(0) name (f1) -5 >Emitted(11, 30) Source(9, 22) + SourceIndex(0) name (f1) ---- ->>>} -1 > -2 >^ -3 > ^^^^^^^^^^^^^^^^-> -1 > - > -2 >} -1 >Emitted(12, 1) Source(10, 1) + SourceIndex(0) name (f1) -2 >Emitted(12, 2) Source(10, 2) + SourceIndex(0) name (f1) ---- ->>>exports.f1 = f1; -1-> -2 >^^^^^^^^^^ -3 > ^^^^^ -4 > ^ -5 > ^^^^^^^-> -1-> -2 >f1 -3 > () { - > return instance1; - > } -4 > -1->Emitted(13, 1) Source(8, 17) + SourceIndex(0) -2 >Emitted(13, 11) Source(8, 19) + SourceIndex(0) -3 >Emitted(13, 16) Source(10, 2) + SourceIndex(0) -4 >Emitted(13, 17) Source(10, 2) + SourceIndex(0) ---- ->>>exports.a2 = m1.m1_c1; -1-> -2 >^^^^^^^^^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^ -7 > ^ -8 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1-> - > - >export var -2 >a2 -3 > = -4 > m1 -5 > . -6 > m1_c1 -7 > ; -1->Emitted(14, 1) Source(12, 12) + SourceIndex(0) -2 >Emitted(14, 11) Source(12, 14) + SourceIndex(0) -3 >Emitted(14, 14) Source(12, 17) + SourceIndex(0) -4 >Emitted(14, 16) Source(12, 19) + SourceIndex(0) -5 >Emitted(14, 17) Source(12, 20) + SourceIndex(0) -6 >Emitted(14, 22) Source(12, 25) + SourceIndex(0) -7 >Emitted(14, 23) Source(12, 26) + SourceIndex(0) ---- ->>>//# sourceMappingURL=http://www.typescriptlang.org/test.js.map=================================================================== JsFile: test.js mapUrl: http://www.typescriptlang.org/test.js.map sourceRoot: http://typescript.codeplex.com/ diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSimpleSpecifyOutputFile/node/test.d.ts b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSimpleSpecifyOutputFile/node/test.d.ts deleted file mode 100644 index 250d2615a79..00000000000 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSimpleSpecifyOutputFile/node/test.d.ts +++ /dev/null @@ -1,8 +0,0 @@ -import m1 = require("m1"); -export declare var a1: number; -export declare class c1 { - p1: number; -} -export declare var instance1: c1; -export declare function f1(): c1; -export declare var a2: typeof m1.m1_c1; diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSimpleSpecifyOutputFile/node/test.js b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSimpleSpecifyOutputFile/node/test.js deleted file mode 100644 index 1d5a32f0ad5..00000000000 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSimpleSpecifyOutputFile/node/test.js +++ /dev/null @@ -1,15 +0,0 @@ -var m1 = require("m1"); -exports.a1 = 10; -var c1 = (function () { - function c1() { - } - return c1; -})(); -exports.c1 = c1; -exports.instance1 = new c1(); -function f1() { - return exports.instance1; -} -exports.f1 = f1; -exports.a2 = m1.m1_c1; -//# sourceMappingURL=http://www.typescriptlang.org/test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSimpleSpecifyOutputFile/node/test.js.map b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSimpleSpecifyOutputFile/node/test.js.map deleted file mode 100644 index 41d3e11e995..00000000000 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSimpleSpecifyOutputFile/node/test.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"test.js","sourceRoot":"http://typescript.codeplex.com/","sources":["test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AAAA,IAAO,EAAE,WAAW,IAAI,CAAC,CAAC;AACf,UAAE,GAAG,EAAE,CAAC;AACnB;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAFY,UAAE,KAEd,CAAA;AAEU,iBAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AAChC;IACIE,MAAMA,CAACA,iBAASA,CAACA;AACrBA,CAACA;AAFe,UAAE,KAEjB,CAAA;AAEU,UAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSubfolderSpecifyOutputFile/amd/maprootUrlsourcerootUrlModuleSubfolderSpecifyOutputFile.json b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSubfolderSpecifyOutputFile/amd/maprootUrlsourcerootUrlModuleSubfolderSpecifyOutputFile.json index cfa0ec5cb81..cd7c4867bc3 100644 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSubfolderSpecifyOutputFile/amd/maprootUrlsourcerootUrlModuleSubfolderSpecifyOutputFile.json +++ b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSubfolderSpecifyOutputFile/amd/maprootUrlsourcerootUrlModuleSubfolderSpecifyOutputFile.json @@ -16,12 +16,6 @@ "test.ts" ], "emittedFiles": [ - "ref/m1.js.map", - "ref/m1.js", - "ref/m1.d.ts", - "test.js.map", - "test.js", - "test.d.ts", "bin/test.js.map", "bin/test.js", "bin/test.d.ts" diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSubfolderSpecifyOutputFile/amd/maprootUrlsourcerootUrlModuleSubfolderSpecifyOutputFile.sourcemap.txt b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSubfolderSpecifyOutputFile/amd/maprootUrlsourcerootUrlModuleSubfolderSpecifyOutputFile.sourcemap.txt index 93d4a677676..557f15f4e2a 100644 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSubfolderSpecifyOutputFile/amd/maprootUrlsourcerootUrlModuleSubfolderSpecifyOutputFile.sourcemap.txt +++ b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSubfolderSpecifyOutputFile/amd/maprootUrlsourcerootUrlModuleSubfolderSpecifyOutputFile.sourcemap.txt @@ -1,375 +1,4 @@ =================================================================== -JsFile: m1.js -mapUrl: http://www.typescriptlang.org/ref/m1.js.map -sourceRoot: http://typescript.codeplex.com/ -sources: ref/m1.ts -=================================================================== -------------------------------------------------------------------- -emittedFile:ref/m1.js -sourceFile:ref/m1.ts -------------------------------------------------------------------- ->>>define(["require", "exports"], function (require, exports) { ->>> exports.m1_a1 = 10; -1 >^^^^ -2 > ^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^-> -1 >export var -2 > m1_a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(2, 5) Source(1, 12) + SourceIndex(0) -2 >Emitted(2, 18) Source(1, 17) + SourceIndex(0) -3 >Emitted(2, 21) Source(1, 20) + SourceIndex(0) -4 >Emitted(2, 23) Source(1, 22) + SourceIndex(0) -5 >Emitted(2, 24) Source(1, 23) + SourceIndex(0) ---- ->>> var m1_c1 = (function () { -1->^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^^^^-> -1-> - > -1->Emitted(3, 5) Source(2, 1) + SourceIndex(0) ---- ->>> function m1_c1() { -1->^^^^^^^^ -2 > ^^-> -1-> -1->Emitted(4, 9) Source(2, 1) + SourceIndex(0) name (m1_c1) ---- ->>> } -1->^^^^^^^^ -2 > ^ -3 > ^^^^^^^^^^^^^-> -1->export class m1_c1 { - > public m1_c1_p1: number; - > -2 > } -1->Emitted(5, 9) Source(4, 1) + SourceIndex(0) name (m1_c1.constructor) -2 >Emitted(5, 10) Source(4, 2) + SourceIndex(0) name (m1_c1.constructor) ---- ->>> return m1_c1; -1->^^^^^^^^ -2 > ^^^^^^^^^^^^ -1-> -2 > } -1->Emitted(6, 9) Source(4, 1) + SourceIndex(0) name (m1_c1) -2 >Emitted(6, 21) Source(4, 2) + SourceIndex(0) name (m1_c1) ---- ->>> })(); -1 >^^^^ -2 > ^ -3 > -4 > ^^^^ -5 > ^^^^^^^^^^^^^^^^^^-> -1 > -2 > } -3 > -4 > export class m1_c1 { - > public m1_c1_p1: number; - > } -1 >Emitted(7, 5) Source(4, 1) + SourceIndex(0) name (m1_c1) -2 >Emitted(7, 6) Source(4, 2) + SourceIndex(0) name (m1_c1) -3 >Emitted(7, 6) Source(2, 1) + SourceIndex(0) -4 >Emitted(7, 10) Source(4, 2) + SourceIndex(0) ---- ->>> exports.m1_c1 = m1_c1; -1->^^^^ -2 > ^^^^^^^^^^^^^ -3 > ^^^^^^^^ -4 > ^ -5 > ^^^^^^^^^^^^^^-> -1-> -2 > m1_c1 -3 > { - > public m1_c1_p1: number; - > } -4 > -1->Emitted(8, 5) Source(2, 14) + SourceIndex(0) -2 >Emitted(8, 18) Source(2, 19) + SourceIndex(0) -3 >Emitted(8, 26) Source(4, 2) + SourceIndex(0) -4 >Emitted(8, 27) Source(4, 2) + SourceIndex(0) ---- ->>> exports.m1_instance1 = new m1_c1(); -1->^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^^^ -5 > ^^^^^ -6 > ^^ -7 > ^ -1-> - > - >export var -2 > m1_instance1 -3 > = -4 > new -5 > m1_c1 -6 > () -7 > ; -1->Emitted(9, 5) Source(6, 12) + SourceIndex(0) -2 >Emitted(9, 25) Source(6, 24) + SourceIndex(0) -3 >Emitted(9, 28) Source(6, 27) + SourceIndex(0) -4 >Emitted(9, 32) Source(6, 31) + SourceIndex(0) -5 >Emitted(9, 37) Source(6, 36) + SourceIndex(0) -6 >Emitted(9, 39) Source(6, 38) + SourceIndex(0) -7 >Emitted(9, 40) Source(6, 39) + SourceIndex(0) ---- ->>> function m1_f1() { -1 >^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -1 >Emitted(10, 5) Source(7, 1) + SourceIndex(0) ---- ->>> return exports.m1_instance1; -1->^^^^^^^^ -2 > ^^^^^^ -3 > ^ -4 > ^^^^^^^^^^^^^^^^^^^^ -5 > ^ -1->export function m1_f1() { - > -2 > return -3 > -4 > m1_instance1 -5 > ; -1->Emitted(11, 9) Source(8, 5) + SourceIndex(0) name (m1_f1) -2 >Emitted(11, 15) Source(8, 11) + SourceIndex(0) name (m1_f1) -3 >Emitted(11, 16) Source(8, 12) + SourceIndex(0) name (m1_f1) -4 >Emitted(11, 36) Source(8, 24) + SourceIndex(0) name (m1_f1) -5 >Emitted(11, 37) Source(8, 25) + SourceIndex(0) name (m1_f1) ---- ->>> } -1 >^^^^ -2 > ^ -3 > ^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -2 > } -1 >Emitted(12, 5) Source(9, 1) + SourceIndex(0) name (m1_f1) -2 >Emitted(12, 6) Source(9, 2) + SourceIndex(0) name (m1_f1) ---- ->>> exports.m1_f1 = m1_f1; -1->^^^^ -2 > ^^^^^^^^^^^^^ -3 > ^^^^^^^^ -4 > ^ -1-> -2 > m1_f1 -3 > () { - > return m1_instance1; - > } -4 > -1->Emitted(13, 5) Source(7, 17) + SourceIndex(0) -2 >Emitted(13, 18) Source(7, 22) + SourceIndex(0) -3 >Emitted(13, 26) Source(9, 2) + SourceIndex(0) -4 >Emitted(13, 27) Source(9, 2) + SourceIndex(0) ---- ->>>}); ->>>//# sourceMappingURL=http://www.typescriptlang.org/ref/m1.js.map=================================================================== -JsFile: test.js -mapUrl: http://www.typescriptlang.org/test.js.map -sourceRoot: http://typescript.codeplex.com/ -sources: test.ts -=================================================================== -------------------------------------------------------------------- -emittedFile:test.js -sourceFile:test.ts -------------------------------------------------------------------- ->>>define(["require", "exports", "ref/m1"], function (require, exports, m1) { ->>> exports.a1 = 10; -1 >^^^^ -2 > ^^^^^^^^^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^-> -1 >import m1 = require("ref/m1"); - >export var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(2, 5) Source(2, 12) + SourceIndex(0) -2 >Emitted(2, 15) Source(2, 14) + SourceIndex(0) -3 >Emitted(2, 18) Source(2, 17) + SourceIndex(0) -4 >Emitted(2, 20) Source(2, 19) + SourceIndex(0) -5 >Emitted(2, 21) Source(2, 20) + SourceIndex(0) ---- ->>> var c1 = (function () { -1->^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^-> -1-> - > -1->Emitted(3, 5) Source(3, 1) + SourceIndex(0) ---- ->>> function c1() { -1->^^^^^^^^ -2 > ^^-> -1-> -1->Emitted(4, 9) Source(3, 1) + SourceIndex(0) name (c1) ---- ->>> } -1->^^^^^^^^ -2 > ^ -3 > ^^^^^^^^^^-> -1->export class c1 { - > public p1: number; - > -2 > } -1->Emitted(5, 9) Source(5, 1) + SourceIndex(0) name (c1.constructor) -2 >Emitted(5, 10) Source(5, 2) + SourceIndex(0) name (c1.constructor) ---- ->>> return c1; -1->^^^^^^^^ -2 > ^^^^^^^^^ -1-> -2 > } -1->Emitted(6, 9) Source(5, 1) + SourceIndex(0) name (c1) -2 >Emitted(6, 18) Source(5, 2) + SourceIndex(0) name (c1) ---- ->>> })(); -1 >^^^^ -2 > ^ -3 > -4 > ^^^^ -5 > ^^^^^^^^^^^^-> -1 > -2 > } -3 > -4 > export class c1 { - > public p1: number; - > } -1 >Emitted(7, 5) Source(5, 1) + SourceIndex(0) name (c1) -2 >Emitted(7, 6) Source(5, 2) + SourceIndex(0) name (c1) -3 >Emitted(7, 6) Source(3, 1) + SourceIndex(0) -4 >Emitted(7, 10) Source(5, 2) + SourceIndex(0) ---- ->>> exports.c1 = c1; -1->^^^^ -2 > ^^^^^^^^^^ -3 > ^^^^^ -4 > ^ -5 > ^^^^^^^^^^^^^^-> -1-> -2 > c1 -3 > { - > public p1: number; - > } -4 > -1->Emitted(8, 5) Source(3, 14) + SourceIndex(0) -2 >Emitted(8, 15) Source(3, 16) + SourceIndex(0) -3 >Emitted(8, 20) Source(5, 2) + SourceIndex(0) -4 >Emitted(8, 21) Source(5, 2) + SourceIndex(0) ---- ->>> exports.instance1 = new c1(); -1->^^^^ -2 > ^^^^^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^^^ -5 > ^^ -6 > ^^ -7 > ^ -1-> - > - >export var -2 > instance1 -3 > = -4 > new -5 > c1 -6 > () -7 > ; -1->Emitted(9, 5) Source(7, 12) + SourceIndex(0) -2 >Emitted(9, 22) Source(7, 21) + SourceIndex(0) -3 >Emitted(9, 25) Source(7, 24) + SourceIndex(0) -4 >Emitted(9, 29) Source(7, 28) + SourceIndex(0) -5 >Emitted(9, 31) Source(7, 30) + SourceIndex(0) -6 >Emitted(9, 33) Source(7, 32) + SourceIndex(0) -7 >Emitted(9, 34) Source(7, 33) + SourceIndex(0) ---- ->>> function f1() { -1 >^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -1 >Emitted(10, 5) Source(8, 1) + SourceIndex(0) ---- ->>> return exports.instance1; -1->^^^^^^^^ -2 > ^^^^^^ -3 > ^ -4 > ^^^^^^^^^^^^^^^^^ -5 > ^ -1->export function f1() { - > -2 > return -3 > -4 > instance1 -5 > ; -1->Emitted(11, 9) Source(9, 5) + SourceIndex(0) name (f1) -2 >Emitted(11, 15) Source(9, 11) + SourceIndex(0) name (f1) -3 >Emitted(11, 16) Source(9, 12) + SourceIndex(0) name (f1) -4 >Emitted(11, 33) Source(9, 21) + SourceIndex(0) name (f1) -5 >Emitted(11, 34) Source(9, 22) + SourceIndex(0) name (f1) ---- ->>> } -1 >^^^^ -2 > ^ -3 > ^^^^^^^^^^^^^^^^-> -1 > - > -2 > } -1 >Emitted(12, 5) Source(10, 1) + SourceIndex(0) name (f1) -2 >Emitted(12, 6) Source(10, 2) + SourceIndex(0) name (f1) ---- ->>> exports.f1 = f1; -1->^^^^ -2 > ^^^^^^^^^^ -3 > ^^^^^ -4 > ^ -5 > ^^^^^^^-> -1-> -2 > f1 -3 > () { - > return instance1; - > } -4 > -1->Emitted(13, 5) Source(8, 17) + SourceIndex(0) -2 >Emitted(13, 15) Source(8, 19) + SourceIndex(0) -3 >Emitted(13, 20) Source(10, 2) + SourceIndex(0) -4 >Emitted(13, 21) Source(10, 2) + SourceIndex(0) ---- ->>> exports.a2 = m1.m1_c1; -1->^^^^ -2 > ^^^^^^^^^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^ -7 > ^ -1-> - > - >export var -2 > a2 -3 > = -4 > m1 -5 > . -6 > m1_c1 -7 > ; -1->Emitted(14, 5) Source(12, 12) + SourceIndex(0) -2 >Emitted(14, 15) Source(12, 14) + SourceIndex(0) -3 >Emitted(14, 18) Source(12, 17) + SourceIndex(0) -4 >Emitted(14, 20) Source(12, 19) + SourceIndex(0) -5 >Emitted(14, 21) Source(12, 20) + SourceIndex(0) -6 >Emitted(14, 26) Source(12, 25) + SourceIndex(0) -7 >Emitted(14, 27) Source(12, 26) + SourceIndex(0) ---- ->>>}); ->>>//# sourceMappingURL=http://www.typescriptlang.org/test.js.map=================================================================== JsFile: test.js mapUrl: http://www.typescriptlang.org/test.js.map sourceRoot: http://typescript.codeplex.com/ diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSubfolderSpecifyOutputFile/amd/ref/m1.d.ts b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSubfolderSpecifyOutputFile/amd/ref/m1.d.ts deleted file mode 100644 index 4a53b24b156..00000000000 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSubfolderSpecifyOutputFile/amd/ref/m1.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -export declare var m1_a1: number; -export declare class m1_c1 { - m1_c1_p1: number; -} -export declare var m1_instance1: m1_c1; -export declare function m1_f1(): m1_c1; diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSubfolderSpecifyOutputFile/amd/ref/m1.js b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSubfolderSpecifyOutputFile/amd/ref/m1.js deleted file mode 100644 index 73309eabe30..00000000000 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSubfolderSpecifyOutputFile/amd/ref/m1.js +++ /dev/null @@ -1,15 +0,0 @@ -define(["require", "exports"], function (require, exports) { - exports.m1_a1 = 10; - var m1_c1 = (function () { - function m1_c1() { - } - return m1_c1; - })(); - exports.m1_c1 = m1_c1; - exports.m1_instance1 = new m1_c1(); - function m1_f1() { - return exports.m1_instance1; - } - exports.m1_f1 = m1_f1; -}); -//# sourceMappingURL=http://www.typescriptlang.org/ref/m1.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSubfolderSpecifyOutputFile/amd/ref/m1.js.map b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSubfolderSpecifyOutputFile/amd/ref/m1.js.map deleted file mode 100644 index 6c5413f630e..00000000000 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSubfolderSpecifyOutputFile/amd/ref/m1.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"m1.js","sourceRoot":"http://typescript.codeplex.com/","sources":["ref/m1.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1"],"mappings":";IAAW,aAAK,GAAG,EAAE,CAAC;IACtB;QAAAA;QAEAC,CAACA;QAADD,YAACA;IAADA,CAACA,AAFD,IAEC;IAFY,aAAK,QAEjB,CAAA;IAEU,oBAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACIE,MAAMA,CAACA,oBAAYA,CAACA;IACxBA,CAACA;IAFe,aAAK,QAEpB,CAAA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSubfolderSpecifyOutputFile/amd/test.d.ts b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSubfolderSpecifyOutputFile/amd/test.d.ts deleted file mode 100644 index a61d8541048..00000000000 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSubfolderSpecifyOutputFile/amd/test.d.ts +++ /dev/null @@ -1,8 +0,0 @@ -import m1 = require("ref/m1"); -export declare var a1: number; -export declare class c1 { - p1: number; -} -export declare var instance1: c1; -export declare function f1(): c1; -export declare var a2: typeof m1.m1_c1; diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSubfolderSpecifyOutputFile/amd/test.js b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSubfolderSpecifyOutputFile/amd/test.js deleted file mode 100644 index 270604ea7cb..00000000000 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSubfolderSpecifyOutputFile/amd/test.js +++ /dev/null @@ -1,16 +0,0 @@ -define(["require", "exports", "ref/m1"], function (require, exports, m1) { - exports.a1 = 10; - var c1 = (function () { - function c1() { - } - return c1; - })(); - exports.c1 = c1; - exports.instance1 = new c1(); - function f1() { - return exports.instance1; - } - exports.f1 = f1; - exports.a2 = m1.m1_c1; -}); -//# sourceMappingURL=http://www.typescriptlang.org/test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSubfolderSpecifyOutputFile/amd/test.js.map b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSubfolderSpecifyOutputFile/amd/test.js.map deleted file mode 100644 index a57b57d2b17..00000000000 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSubfolderSpecifyOutputFile/amd/test.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"test.js","sourceRoot":"http://typescript.codeplex.com/","sources":["test.ts"],"names":["c1","c1.constructor","f1"],"mappings":";IACW,UAAE,GAAG,EAAE,CAAC;IACnB;QAAAA;QAEAC,CAACA;QAADD,SAACA;IAADA,CAACA,AAFD,IAEC;IAFY,UAAE,KAEd,CAAA;IAEU,iBAAS,GAAG,IAAI,EAAE,EAAE,CAAC;IAChC;QACIE,MAAMA,CAACA,iBAASA,CAACA;IACrBA,CAACA;IAFe,UAAE,KAEjB,CAAA;IAEU,UAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSubfolderSpecifyOutputFile/node/maprootUrlsourcerootUrlModuleSubfolderSpecifyOutputFile.json b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSubfolderSpecifyOutputFile/node/maprootUrlsourcerootUrlModuleSubfolderSpecifyOutputFile.json index cfa0ec5cb81..cd7c4867bc3 100644 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSubfolderSpecifyOutputFile/node/maprootUrlsourcerootUrlModuleSubfolderSpecifyOutputFile.json +++ b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSubfolderSpecifyOutputFile/node/maprootUrlsourcerootUrlModuleSubfolderSpecifyOutputFile.json @@ -16,12 +16,6 @@ "test.ts" ], "emittedFiles": [ - "ref/m1.js.map", - "ref/m1.js", - "ref/m1.d.ts", - "test.js.map", - "test.js", - "test.d.ts", "bin/test.js.map", "bin/test.js", "bin/test.d.ts" diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSubfolderSpecifyOutputFile/node/maprootUrlsourcerootUrlModuleSubfolderSpecifyOutputFile.sourcemap.txt b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSubfolderSpecifyOutputFile/node/maprootUrlsourcerootUrlModuleSubfolderSpecifyOutputFile.sourcemap.txt index abdc3af24ca..3a403373a8f 100644 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSubfolderSpecifyOutputFile/node/maprootUrlsourcerootUrlModuleSubfolderSpecifyOutputFile.sourcemap.txt +++ b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSubfolderSpecifyOutputFile/node/maprootUrlsourcerootUrlModuleSubfolderSpecifyOutputFile.sourcemap.txt @@ -1,396 +1,4 @@ =================================================================== -JsFile: m1.js -mapUrl: http://www.typescriptlang.org/ref/m1.js.map -sourceRoot: http://typescript.codeplex.com/ -sources: ref/m1.ts -=================================================================== -------------------------------------------------------------------- -emittedFile:ref/m1.js -sourceFile:ref/m1.ts -------------------------------------------------------------------- ->>>exports.m1_a1 = 10; -1 > -2 >^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^-> -1 >export var -2 >m1_a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(1, 1) Source(1, 12) + SourceIndex(0) -2 >Emitted(1, 14) Source(1, 17) + SourceIndex(0) -3 >Emitted(1, 17) Source(1, 20) + SourceIndex(0) -4 >Emitted(1, 19) Source(1, 22) + SourceIndex(0) -5 >Emitted(1, 20) Source(1, 23) + SourceIndex(0) ---- ->>>var m1_c1 = (function () { -1-> -2 >^^^^^^^^^^^^^^^^^^^^^^^-> -1-> - > -1->Emitted(2, 1) Source(2, 1) + SourceIndex(0) ---- ->>> function m1_c1() { -1->^^^^ -2 > ^^-> -1-> -1->Emitted(3, 5) Source(2, 1) + SourceIndex(0) name (m1_c1) ---- ->>> } -1->^^^^ -2 > ^ -3 > ^^^^^^^^^^^^^-> -1->export class m1_c1 { - > public m1_c1_p1: number; - > -2 > } -1->Emitted(4, 5) Source(4, 1) + SourceIndex(0) name (m1_c1.constructor) -2 >Emitted(4, 6) Source(4, 2) + SourceIndex(0) name (m1_c1.constructor) ---- ->>> return m1_c1; -1->^^^^ -2 > ^^^^^^^^^^^^ -1-> -2 > } -1->Emitted(5, 5) Source(4, 1) + SourceIndex(0) name (m1_c1) -2 >Emitted(5, 17) Source(4, 2) + SourceIndex(0) name (m1_c1) ---- ->>>})(); -1 > -2 >^ -3 > -4 > ^^^^ -5 > ^^^^^^^^^^^^^^^^^^-> -1 > -2 >} -3 > -4 > export class m1_c1 { - > public m1_c1_p1: number; - > } -1 >Emitted(6, 1) Source(4, 1) + SourceIndex(0) name (m1_c1) -2 >Emitted(6, 2) Source(4, 2) + SourceIndex(0) name (m1_c1) -3 >Emitted(6, 2) Source(2, 1) + SourceIndex(0) -4 >Emitted(6, 6) Source(4, 2) + SourceIndex(0) ---- ->>>exports.m1_c1 = m1_c1; -1-> -2 >^^^^^^^^^^^^^ -3 > ^^^^^^^^ -4 > ^ -5 > ^^^^^^^^^^^^^^-> -1-> -2 >m1_c1 -3 > { - > public m1_c1_p1: number; - > } -4 > -1->Emitted(7, 1) Source(2, 14) + SourceIndex(0) -2 >Emitted(7, 14) Source(2, 19) + SourceIndex(0) -3 >Emitted(7, 22) Source(4, 2) + SourceIndex(0) -4 >Emitted(7, 23) Source(4, 2) + SourceIndex(0) ---- ->>>exports.m1_instance1 = new m1_c1(); -1-> -2 >^^^^^^^^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^^^ -5 > ^^^^^ -6 > ^^ -7 > ^ -1-> - > - >export var -2 >m1_instance1 -3 > = -4 > new -5 > m1_c1 -6 > () -7 > ; -1->Emitted(8, 1) Source(6, 12) + SourceIndex(0) -2 >Emitted(8, 21) Source(6, 24) + SourceIndex(0) -3 >Emitted(8, 24) Source(6, 27) + SourceIndex(0) -4 >Emitted(8, 28) Source(6, 31) + SourceIndex(0) -5 >Emitted(8, 33) Source(6, 36) + SourceIndex(0) -6 >Emitted(8, 35) Source(6, 38) + SourceIndex(0) -7 >Emitted(8, 36) Source(6, 39) + SourceIndex(0) ---- ->>>function m1_f1() { -1 > -2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -1 >Emitted(9, 1) Source(7, 1) + SourceIndex(0) ---- ->>> return exports.m1_instance1; -1->^^^^ -2 > ^^^^^^ -3 > ^ -4 > ^^^^^^^^^^^^^^^^^^^^ -5 > ^ -1->export function m1_f1() { - > -2 > return -3 > -4 > m1_instance1 -5 > ; -1->Emitted(10, 5) Source(8, 5) + SourceIndex(0) name (m1_f1) -2 >Emitted(10, 11) Source(8, 11) + SourceIndex(0) name (m1_f1) -3 >Emitted(10, 12) Source(8, 12) + SourceIndex(0) name (m1_f1) -4 >Emitted(10, 32) Source(8, 24) + SourceIndex(0) name (m1_f1) -5 >Emitted(10, 33) Source(8, 25) + SourceIndex(0) name (m1_f1) ---- ->>>} -1 > -2 >^ -3 > ^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -2 >} -1 >Emitted(11, 1) Source(9, 1) + SourceIndex(0) name (m1_f1) -2 >Emitted(11, 2) Source(9, 2) + SourceIndex(0) name (m1_f1) ---- ->>>exports.m1_f1 = m1_f1; -1-> -2 >^^^^^^^^^^^^^ -3 > ^^^^^^^^ -4 > ^ -5 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1-> -2 >m1_f1 -3 > () { - > return m1_instance1; - > } -4 > -1->Emitted(12, 1) Source(7, 17) + SourceIndex(0) -2 >Emitted(12, 14) Source(7, 22) + SourceIndex(0) -3 >Emitted(12, 22) Source(9, 2) + SourceIndex(0) -4 >Emitted(12, 23) Source(9, 2) + SourceIndex(0) ---- ->>>//# sourceMappingURL=http://www.typescriptlang.org/ref/m1.js.map=================================================================== -JsFile: test.js -mapUrl: http://www.typescriptlang.org/test.js.map -sourceRoot: http://typescript.codeplex.com/ -sources: test.ts -=================================================================== -------------------------------------------------------------------- -emittedFile:test.js -sourceFile:test.ts -------------------------------------------------------------------- ->>>var m1 = require("ref/m1"); -1 > -2 >^^^^ -3 > ^^ -4 > ^^^^^^^^^^^ -5 > ^^^^^^^^ -6 > ^ -7 > ^ -1 > -2 >import -3 > m1 -4 > = require( -5 > "ref/m1" -6 > ) -7 > ; -1 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) -2 >Emitted(1, 5) Source(1, 8) + SourceIndex(0) -3 >Emitted(1, 7) Source(1, 10) + SourceIndex(0) -4 >Emitted(1, 18) Source(1, 21) + SourceIndex(0) -5 >Emitted(1, 26) Source(1, 29) + SourceIndex(0) -6 >Emitted(1, 27) Source(1, 30) + SourceIndex(0) -7 >Emitted(1, 28) Source(1, 31) + SourceIndex(0) ---- ->>>exports.a1 = 10; -1 > -2 >^^^^^^^^^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^-> -1 > - >export var -2 >a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(2, 1) Source(2, 12) + SourceIndex(0) -2 >Emitted(2, 11) Source(2, 14) + SourceIndex(0) -3 >Emitted(2, 14) Source(2, 17) + SourceIndex(0) -4 >Emitted(2, 16) Source(2, 19) + SourceIndex(0) -5 >Emitted(2, 17) Source(2, 20) + SourceIndex(0) ---- ->>>var c1 = (function () { -1-> -2 >^^^^^^^^^^^^^^^^^^^^-> -1-> - > -1->Emitted(3, 1) Source(3, 1) + SourceIndex(0) ---- ->>> function c1() { -1->^^^^ -2 > ^^-> -1-> -1->Emitted(4, 5) Source(3, 1) + SourceIndex(0) name (c1) ---- ->>> } -1->^^^^ -2 > ^ -3 > ^^^^^^^^^^-> -1->export class c1 { - > public p1: number; - > -2 > } -1->Emitted(5, 5) Source(5, 1) + SourceIndex(0) name (c1.constructor) -2 >Emitted(5, 6) Source(5, 2) + SourceIndex(0) name (c1.constructor) ---- ->>> return c1; -1->^^^^ -2 > ^^^^^^^^^ -1-> -2 > } -1->Emitted(6, 5) Source(5, 1) + SourceIndex(0) name (c1) -2 >Emitted(6, 14) Source(5, 2) + SourceIndex(0) name (c1) ---- ->>>})(); -1 > -2 >^ -3 > -4 > ^^^^ -5 > ^^^^^^^^^^^^-> -1 > -2 >} -3 > -4 > export class c1 { - > public p1: number; - > } -1 >Emitted(7, 1) Source(5, 1) + SourceIndex(0) name (c1) -2 >Emitted(7, 2) Source(5, 2) + SourceIndex(0) name (c1) -3 >Emitted(7, 2) Source(3, 1) + SourceIndex(0) -4 >Emitted(7, 6) Source(5, 2) + SourceIndex(0) ---- ->>>exports.c1 = c1; -1-> -2 >^^^^^^^^^^ -3 > ^^^^^ -4 > ^ -5 > ^^^^^^^^^^^^^^-> -1-> -2 >c1 -3 > { - > public p1: number; - > } -4 > -1->Emitted(8, 1) Source(3, 14) + SourceIndex(0) -2 >Emitted(8, 11) Source(3, 16) + SourceIndex(0) -3 >Emitted(8, 16) Source(5, 2) + SourceIndex(0) -4 >Emitted(8, 17) Source(5, 2) + SourceIndex(0) ---- ->>>exports.instance1 = new c1(); -1-> -2 >^^^^^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^^^ -5 > ^^ -6 > ^^ -7 > ^ -1-> - > - >export var -2 >instance1 -3 > = -4 > new -5 > c1 -6 > () -7 > ; -1->Emitted(9, 1) Source(7, 12) + SourceIndex(0) -2 >Emitted(9, 18) Source(7, 21) + SourceIndex(0) -3 >Emitted(9, 21) Source(7, 24) + SourceIndex(0) -4 >Emitted(9, 25) Source(7, 28) + SourceIndex(0) -5 >Emitted(9, 27) Source(7, 30) + SourceIndex(0) -6 >Emitted(9, 29) Source(7, 32) + SourceIndex(0) -7 >Emitted(9, 30) Source(7, 33) + SourceIndex(0) ---- ->>>function f1() { -1 > -2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -1 >Emitted(10, 1) Source(8, 1) + SourceIndex(0) ---- ->>> return exports.instance1; -1->^^^^ -2 > ^^^^^^ -3 > ^ -4 > ^^^^^^^^^^^^^^^^^ -5 > ^ -1->export function f1() { - > -2 > return -3 > -4 > instance1 -5 > ; -1->Emitted(11, 5) Source(9, 5) + SourceIndex(0) name (f1) -2 >Emitted(11, 11) Source(9, 11) + SourceIndex(0) name (f1) -3 >Emitted(11, 12) Source(9, 12) + SourceIndex(0) name (f1) -4 >Emitted(11, 29) Source(9, 21) + SourceIndex(0) name (f1) -5 >Emitted(11, 30) Source(9, 22) + SourceIndex(0) name (f1) ---- ->>>} -1 > -2 >^ -3 > ^^^^^^^^^^^^^^^^-> -1 > - > -2 >} -1 >Emitted(12, 1) Source(10, 1) + SourceIndex(0) name (f1) -2 >Emitted(12, 2) Source(10, 2) + SourceIndex(0) name (f1) ---- ->>>exports.f1 = f1; -1-> -2 >^^^^^^^^^^ -3 > ^^^^^ -4 > ^ -5 > ^^^^^^^-> -1-> -2 >f1 -3 > () { - > return instance1; - > } -4 > -1->Emitted(13, 1) Source(8, 17) + SourceIndex(0) -2 >Emitted(13, 11) Source(8, 19) + SourceIndex(0) -3 >Emitted(13, 16) Source(10, 2) + SourceIndex(0) -4 >Emitted(13, 17) Source(10, 2) + SourceIndex(0) ---- ->>>exports.a2 = m1.m1_c1; -1-> -2 >^^^^^^^^^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^ -7 > ^ -8 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1-> - > - >export var -2 >a2 -3 > = -4 > m1 -5 > . -6 > m1_c1 -7 > ; -1->Emitted(14, 1) Source(12, 12) + SourceIndex(0) -2 >Emitted(14, 11) Source(12, 14) + SourceIndex(0) -3 >Emitted(14, 14) Source(12, 17) + SourceIndex(0) -4 >Emitted(14, 16) Source(12, 19) + SourceIndex(0) -5 >Emitted(14, 17) Source(12, 20) + SourceIndex(0) -6 >Emitted(14, 22) Source(12, 25) + SourceIndex(0) -7 >Emitted(14, 23) Source(12, 26) + SourceIndex(0) ---- ->>>//# sourceMappingURL=http://www.typescriptlang.org/test.js.map=================================================================== JsFile: test.js mapUrl: http://www.typescriptlang.org/test.js.map sourceRoot: http://typescript.codeplex.com/ diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSubfolderSpecifyOutputFile/node/ref/m1.d.ts b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSubfolderSpecifyOutputFile/node/ref/m1.d.ts deleted file mode 100644 index 4a53b24b156..00000000000 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSubfolderSpecifyOutputFile/node/ref/m1.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -export declare var m1_a1: number; -export declare class m1_c1 { - m1_c1_p1: number; -} -export declare var m1_instance1: m1_c1; -export declare function m1_f1(): m1_c1; diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSubfolderSpecifyOutputFile/node/ref/m1.js b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSubfolderSpecifyOutputFile/node/ref/m1.js deleted file mode 100644 index 8f31dc2aaa2..00000000000 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSubfolderSpecifyOutputFile/node/ref/m1.js +++ /dev/null @@ -1,13 +0,0 @@ -exports.m1_a1 = 10; -var m1_c1 = (function () { - function m1_c1() { - } - return m1_c1; -})(); -exports.m1_c1 = m1_c1; -exports.m1_instance1 = new m1_c1(); -function m1_f1() { - return exports.m1_instance1; -} -exports.m1_f1 = m1_f1; -//# sourceMappingURL=http://www.typescriptlang.org/ref/m1.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSubfolderSpecifyOutputFile/node/ref/m1.js.map b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSubfolderSpecifyOutputFile/node/ref/m1.js.map deleted file mode 100644 index 35e7e9a48dd..00000000000 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSubfolderSpecifyOutputFile/node/ref/m1.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"m1.js","sourceRoot":"http://typescript.codeplex.com/","sources":["ref/m1.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1"],"mappings":"AAAW,aAAK,GAAG,EAAE,CAAC;AACtB;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAFY,aAAK,QAEjB,CAAA;AAEU,oBAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACIE,MAAMA,CAACA,oBAAYA,CAACA;AACxBA,CAACA;AAFe,aAAK,QAEpB,CAAA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSubfolderSpecifyOutputFile/node/test.d.ts b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSubfolderSpecifyOutputFile/node/test.d.ts deleted file mode 100644 index a61d8541048..00000000000 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSubfolderSpecifyOutputFile/node/test.d.ts +++ /dev/null @@ -1,8 +0,0 @@ -import m1 = require("ref/m1"); -export declare var a1: number; -export declare class c1 { - p1: number; -} -export declare var instance1: c1; -export declare function f1(): c1; -export declare var a2: typeof m1.m1_c1; diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSubfolderSpecifyOutputFile/node/test.js b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSubfolderSpecifyOutputFile/node/test.js deleted file mode 100644 index 9bb4ed0180a..00000000000 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSubfolderSpecifyOutputFile/node/test.js +++ /dev/null @@ -1,15 +0,0 @@ -var m1 = require("ref/m1"); -exports.a1 = 10; -var c1 = (function () { - function c1() { - } - return c1; -})(); -exports.c1 = c1; -exports.instance1 = new c1(); -function f1() { - return exports.instance1; -} -exports.f1 = f1; -exports.a2 = m1.m1_c1; -//# sourceMappingURL=http://www.typescriptlang.org/test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSubfolderSpecifyOutputFile/node/test.js.map b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSubfolderSpecifyOutputFile/node/test.js.map deleted file mode 100644 index d0638b6c34c..00000000000 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSubfolderSpecifyOutputFile/node/test.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"test.js","sourceRoot":"http://typescript.codeplex.com/","sources":["test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AAAA,IAAO,EAAE,WAAW,QAAQ,CAAC,CAAC;AACnB,UAAE,GAAG,EAAE,CAAC;AACnB;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAFY,UAAE,KAEd,CAAA;AAEU,iBAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AAChC;IACIE,MAAMA,CAACA,iBAASA,CAACA;AACrBA,CAACA;AAFe,UAAE,KAEjB,CAAA;AAEU,UAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/outMixedSubfolderSpecifyOutputFile/amd/outMixedSubfolderSpecifyOutputFile.json b/tests/baselines/reference/project/outMixedSubfolderSpecifyOutputFile/amd/outMixedSubfolderSpecifyOutputFile.json index 975fcf59ca9..1b96d09cd3a 100644 --- a/tests/baselines/reference/project/outMixedSubfolderSpecifyOutputFile/amd/outMixedSubfolderSpecifyOutputFile.json +++ b/tests/baselines/reference/project/outMixedSubfolderSpecifyOutputFile/amd/outMixedSubfolderSpecifyOutputFile.json @@ -14,8 +14,6 @@ "test.ts" ], "emittedFiles": [ - "ref/m2.js", - "ref/m2.d.ts", "bin/test.js", "bin/test.d.ts" ] diff --git a/tests/baselines/reference/project/outMixedSubfolderSpecifyOutputFile/amd/ref/m2.d.ts b/tests/baselines/reference/project/outMixedSubfolderSpecifyOutputFile/amd/ref/m2.d.ts deleted file mode 100644 index c09a3c0c32a..00000000000 --- a/tests/baselines/reference/project/outMixedSubfolderSpecifyOutputFile/amd/ref/m2.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -export declare var m2_a1: number; -export declare class m2_c1 { - m2_c1_p1: number; -} -export declare var m2_instance1: m2_c1; -export declare function m2_f1(): m2_c1; diff --git a/tests/baselines/reference/project/outMixedSubfolderSpecifyOutputFile/amd/ref/m2.js b/tests/baselines/reference/project/outMixedSubfolderSpecifyOutputFile/amd/ref/m2.js deleted file mode 100644 index 2c61fd1d935..00000000000 --- a/tests/baselines/reference/project/outMixedSubfolderSpecifyOutputFile/amd/ref/m2.js +++ /dev/null @@ -1,14 +0,0 @@ -define(["require", "exports"], function (require, exports) { - exports.m2_a1 = 10; - var m2_c1 = (function () { - function m2_c1() { - } - return m2_c1; - })(); - exports.m2_c1 = m2_c1; - exports.m2_instance1 = new m2_c1(); - function m2_f1() { - return exports.m2_instance1; - } - exports.m2_f1 = m2_f1; -}); diff --git a/tests/baselines/reference/project/outMixedSubfolderSpecifyOutputFile/node/outMixedSubfolderSpecifyOutputFile.json b/tests/baselines/reference/project/outMixedSubfolderSpecifyOutputFile/node/outMixedSubfolderSpecifyOutputFile.json index 975fcf59ca9..1b96d09cd3a 100644 --- a/tests/baselines/reference/project/outMixedSubfolderSpecifyOutputFile/node/outMixedSubfolderSpecifyOutputFile.json +++ b/tests/baselines/reference/project/outMixedSubfolderSpecifyOutputFile/node/outMixedSubfolderSpecifyOutputFile.json @@ -14,8 +14,6 @@ "test.ts" ], "emittedFiles": [ - "ref/m2.js", - "ref/m2.d.ts", "bin/test.js", "bin/test.d.ts" ] diff --git a/tests/baselines/reference/project/outMixedSubfolderSpecifyOutputFile/node/ref/m2.d.ts b/tests/baselines/reference/project/outMixedSubfolderSpecifyOutputFile/node/ref/m2.d.ts deleted file mode 100644 index c09a3c0c32a..00000000000 --- a/tests/baselines/reference/project/outMixedSubfolderSpecifyOutputFile/node/ref/m2.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -export declare var m2_a1: number; -export declare class m2_c1 { - m2_c1_p1: number; -} -export declare var m2_instance1: m2_c1; -export declare function m2_f1(): m2_c1; diff --git a/tests/baselines/reference/project/outMixedSubfolderSpecifyOutputFile/node/ref/m2.js b/tests/baselines/reference/project/outMixedSubfolderSpecifyOutputFile/node/ref/m2.js deleted file mode 100644 index b7c7f5d8139..00000000000 --- a/tests/baselines/reference/project/outMixedSubfolderSpecifyOutputFile/node/ref/m2.js +++ /dev/null @@ -1,12 +0,0 @@ -exports.m2_a1 = 10; -var m2_c1 = (function () { - function m2_c1() { - } - return m2_c1; -})(); -exports.m2_c1 = m2_c1; -exports.m2_instance1 = new m2_c1(); -function m2_f1() { - return exports.m2_instance1; -} -exports.m2_f1 = m2_f1; diff --git a/tests/baselines/reference/project/outMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/outMixedSubfolderSpecifyOutputFileAndOutputDirectory.json b/tests/baselines/reference/project/outMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/outMixedSubfolderSpecifyOutputFileAndOutputDirectory.json index 2b0a20e739a..f2ea5b95015 100644 --- a/tests/baselines/reference/project/outMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/outMixedSubfolderSpecifyOutputFileAndOutputDirectory.json +++ b/tests/baselines/reference/project/outMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/outMixedSubfolderSpecifyOutputFileAndOutputDirectory.json @@ -15,8 +15,6 @@ "test.ts" ], "emittedFiles": [ - "outdir/outAndOutDirFolder/ref/m2.js", - "outdir/outAndOutDirFolder/ref/m2.d.ts", "bin/outAndOutDirFile.js", "bin/outAndOutDirFile.d.ts" ] diff --git a/tests/baselines/reference/project/outMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/outdir/outAndOutDirFolder/ref/m2.d.ts b/tests/baselines/reference/project/outMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/outdir/outAndOutDirFolder/ref/m2.d.ts deleted file mode 100644 index c09a3c0c32a..00000000000 --- a/tests/baselines/reference/project/outMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/outdir/outAndOutDirFolder/ref/m2.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -export declare var m2_a1: number; -export declare class m2_c1 { - m2_c1_p1: number; -} -export declare var m2_instance1: m2_c1; -export declare function m2_f1(): m2_c1; diff --git a/tests/baselines/reference/project/outMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/outdir/outAndOutDirFolder/ref/m2.js b/tests/baselines/reference/project/outMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/outdir/outAndOutDirFolder/ref/m2.js deleted file mode 100644 index 2c61fd1d935..00000000000 --- a/tests/baselines/reference/project/outMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/outdir/outAndOutDirFolder/ref/m2.js +++ /dev/null @@ -1,14 +0,0 @@ -define(["require", "exports"], function (require, exports) { - exports.m2_a1 = 10; - var m2_c1 = (function () { - function m2_c1() { - } - return m2_c1; - })(); - exports.m2_c1 = m2_c1; - exports.m2_instance1 = new m2_c1(); - function m2_f1() { - return exports.m2_instance1; - } - exports.m2_f1 = m2_f1; -}); diff --git a/tests/baselines/reference/project/outMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/outMixedSubfolderSpecifyOutputFileAndOutputDirectory.json b/tests/baselines/reference/project/outMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/outMixedSubfolderSpecifyOutputFileAndOutputDirectory.json index 2b0a20e739a..f2ea5b95015 100644 --- a/tests/baselines/reference/project/outMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/outMixedSubfolderSpecifyOutputFileAndOutputDirectory.json +++ b/tests/baselines/reference/project/outMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/outMixedSubfolderSpecifyOutputFileAndOutputDirectory.json @@ -15,8 +15,6 @@ "test.ts" ], "emittedFiles": [ - "outdir/outAndOutDirFolder/ref/m2.js", - "outdir/outAndOutDirFolder/ref/m2.d.ts", "bin/outAndOutDirFile.js", "bin/outAndOutDirFile.d.ts" ] diff --git a/tests/baselines/reference/project/outMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/outdir/outAndOutDirFolder/ref/m2.d.ts b/tests/baselines/reference/project/outMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/outdir/outAndOutDirFolder/ref/m2.d.ts deleted file mode 100644 index c09a3c0c32a..00000000000 --- a/tests/baselines/reference/project/outMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/outdir/outAndOutDirFolder/ref/m2.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -export declare var m2_a1: number; -export declare class m2_c1 { - m2_c1_p1: number; -} -export declare var m2_instance1: m2_c1; -export declare function m2_f1(): m2_c1; diff --git a/tests/baselines/reference/project/outMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/outdir/outAndOutDirFolder/ref/m2.js b/tests/baselines/reference/project/outMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/outdir/outAndOutDirFolder/ref/m2.js deleted file mode 100644 index b7c7f5d8139..00000000000 --- a/tests/baselines/reference/project/outMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/outdir/outAndOutDirFolder/ref/m2.js +++ /dev/null @@ -1,12 +0,0 @@ -exports.m2_a1 = 10; -var m2_c1 = (function () { - function m2_c1() { - } - return m2_c1; -})(); -exports.m2_c1 = m2_c1; -exports.m2_instance1 = new m2_c1(); -function m2_f1() { - return exports.m2_instance1; -} -exports.m2_f1 = m2_f1; diff --git a/tests/baselines/reference/project/outModuleMultifolderSpecifyOutputFile/amd/diskFile0.js b/tests/baselines/reference/project/outModuleMultifolderSpecifyOutputFile/amd/diskFile0.js deleted file mode 100644 index 2c61fd1d935..00000000000 --- a/tests/baselines/reference/project/outModuleMultifolderSpecifyOutputFile/amd/diskFile0.js +++ /dev/null @@ -1,14 +0,0 @@ -define(["require", "exports"], function (require, exports) { - exports.m2_a1 = 10; - var m2_c1 = (function () { - function m2_c1() { - } - return m2_c1; - })(); - exports.m2_c1 = m2_c1; - exports.m2_instance1 = new m2_c1(); - function m2_f1() { - return exports.m2_instance1; - } - exports.m2_f1 = m2_f1; -}); diff --git a/tests/baselines/reference/project/outModuleMultifolderSpecifyOutputFile/amd/diskFile1.d.ts b/tests/baselines/reference/project/outModuleMultifolderSpecifyOutputFile/amd/diskFile1.d.ts deleted file mode 100644 index c09a3c0c32a..00000000000 --- a/tests/baselines/reference/project/outModuleMultifolderSpecifyOutputFile/amd/diskFile1.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -export declare var m2_a1: number; -export declare class m2_c1 { - m2_c1_p1: number; -} -export declare var m2_instance1: m2_c1; -export declare function m2_f1(): m2_c1; diff --git a/tests/baselines/reference/project/outModuleMultifolderSpecifyOutputFile/amd/outModuleMultifolderSpecifyOutputFile.json b/tests/baselines/reference/project/outModuleMultifolderSpecifyOutputFile/amd/outModuleMultifolderSpecifyOutputFile.json index 66eced5cc01..ef27e5d6f40 100644 --- a/tests/baselines/reference/project/outModuleMultifolderSpecifyOutputFile/amd/outModuleMultifolderSpecifyOutputFile.json +++ b/tests/baselines/reference/project/outModuleMultifolderSpecifyOutputFile/amd/outModuleMultifolderSpecifyOutputFile.json @@ -14,12 +14,6 @@ "test.ts" ], "emittedFiles": [ - "ref/m1.js", - "ref/m1.d.ts", - "../outputdir_module_multifolder_ref/m2.js", - "../outputdir_module_multifolder_ref/m2.d.ts", - "test.js", - "test.d.ts", "bin/test.js", "bin/test.d.ts" ] diff --git a/tests/baselines/reference/project/outModuleMultifolderSpecifyOutputFile/amd/ref/m1.d.ts b/tests/baselines/reference/project/outModuleMultifolderSpecifyOutputFile/amd/ref/m1.d.ts deleted file mode 100644 index 4a53b24b156..00000000000 --- a/tests/baselines/reference/project/outModuleMultifolderSpecifyOutputFile/amd/ref/m1.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -export declare var m1_a1: number; -export declare class m1_c1 { - m1_c1_p1: number; -} -export declare var m1_instance1: m1_c1; -export declare function m1_f1(): m1_c1; diff --git a/tests/baselines/reference/project/outModuleMultifolderSpecifyOutputFile/amd/ref/m1.js b/tests/baselines/reference/project/outModuleMultifolderSpecifyOutputFile/amd/ref/m1.js deleted file mode 100644 index c2a6326846e..00000000000 --- a/tests/baselines/reference/project/outModuleMultifolderSpecifyOutputFile/amd/ref/m1.js +++ /dev/null @@ -1,14 +0,0 @@ -define(["require", "exports"], function (require, exports) { - exports.m1_a1 = 10; - var m1_c1 = (function () { - function m1_c1() { - } - return m1_c1; - })(); - exports.m1_c1 = m1_c1; - exports.m1_instance1 = new m1_c1(); - function m1_f1() { - return exports.m1_instance1; - } - exports.m1_f1 = m1_f1; -}); diff --git a/tests/baselines/reference/project/outModuleMultifolderSpecifyOutputFile/amd/test.d.ts b/tests/baselines/reference/project/outModuleMultifolderSpecifyOutputFile/amd/test.d.ts deleted file mode 100644 index 4afd4e69f2d..00000000000 --- a/tests/baselines/reference/project/outModuleMultifolderSpecifyOutputFile/amd/test.d.ts +++ /dev/null @@ -1,10 +0,0 @@ -import m1 = require("ref/m1"); -import m2 = require("../outputdir_module_multifolder_ref/m2"); -export declare var a1: number; -export declare class c1 { - p1: number; -} -export declare var instance1: c1; -export declare function f1(): c1; -export declare var a2: typeof m1.m1_c1; -export declare var a3: typeof m2.m2_c1; diff --git a/tests/baselines/reference/project/outModuleMultifolderSpecifyOutputFile/amd/test.js b/tests/baselines/reference/project/outModuleMultifolderSpecifyOutputFile/amd/test.js deleted file mode 100644 index f83ccabfd35..00000000000 --- a/tests/baselines/reference/project/outModuleMultifolderSpecifyOutputFile/amd/test.js +++ /dev/null @@ -1,16 +0,0 @@ -define(["require", "exports", "ref/m1", "../outputdir_module_multifolder_ref/m2"], function (require, exports, m1, m2) { - exports.a1 = 10; - var c1 = (function () { - function c1() { - } - return c1; - })(); - exports.c1 = c1; - exports.instance1 = new c1(); - function f1() { - return exports.instance1; - } - exports.f1 = f1; - exports.a2 = m1.m1_c1; - exports.a3 = m2.m2_c1; -}); diff --git a/tests/baselines/reference/project/outModuleMultifolderSpecifyOutputFile/node/diskFile0.js b/tests/baselines/reference/project/outModuleMultifolderSpecifyOutputFile/node/diskFile0.js deleted file mode 100644 index b7c7f5d8139..00000000000 --- a/tests/baselines/reference/project/outModuleMultifolderSpecifyOutputFile/node/diskFile0.js +++ /dev/null @@ -1,12 +0,0 @@ -exports.m2_a1 = 10; -var m2_c1 = (function () { - function m2_c1() { - } - return m2_c1; -})(); -exports.m2_c1 = m2_c1; -exports.m2_instance1 = new m2_c1(); -function m2_f1() { - return exports.m2_instance1; -} -exports.m2_f1 = m2_f1; diff --git a/tests/baselines/reference/project/outModuleMultifolderSpecifyOutputFile/node/diskFile1.d.ts b/tests/baselines/reference/project/outModuleMultifolderSpecifyOutputFile/node/diskFile1.d.ts deleted file mode 100644 index c09a3c0c32a..00000000000 --- a/tests/baselines/reference/project/outModuleMultifolderSpecifyOutputFile/node/diskFile1.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -export declare var m2_a1: number; -export declare class m2_c1 { - m2_c1_p1: number; -} -export declare var m2_instance1: m2_c1; -export declare function m2_f1(): m2_c1; diff --git a/tests/baselines/reference/project/outModuleMultifolderSpecifyOutputFile/node/outModuleMultifolderSpecifyOutputFile.json b/tests/baselines/reference/project/outModuleMultifolderSpecifyOutputFile/node/outModuleMultifolderSpecifyOutputFile.json index 66eced5cc01..ef27e5d6f40 100644 --- a/tests/baselines/reference/project/outModuleMultifolderSpecifyOutputFile/node/outModuleMultifolderSpecifyOutputFile.json +++ b/tests/baselines/reference/project/outModuleMultifolderSpecifyOutputFile/node/outModuleMultifolderSpecifyOutputFile.json @@ -14,12 +14,6 @@ "test.ts" ], "emittedFiles": [ - "ref/m1.js", - "ref/m1.d.ts", - "../outputdir_module_multifolder_ref/m2.js", - "../outputdir_module_multifolder_ref/m2.d.ts", - "test.js", - "test.d.ts", "bin/test.js", "bin/test.d.ts" ] diff --git a/tests/baselines/reference/project/outModuleMultifolderSpecifyOutputFile/node/ref/m1.d.ts b/tests/baselines/reference/project/outModuleMultifolderSpecifyOutputFile/node/ref/m1.d.ts deleted file mode 100644 index 4a53b24b156..00000000000 --- a/tests/baselines/reference/project/outModuleMultifolderSpecifyOutputFile/node/ref/m1.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -export declare var m1_a1: number; -export declare class m1_c1 { - m1_c1_p1: number; -} -export declare var m1_instance1: m1_c1; -export declare function m1_f1(): m1_c1; diff --git a/tests/baselines/reference/project/outModuleMultifolderSpecifyOutputFile/node/ref/m1.js b/tests/baselines/reference/project/outModuleMultifolderSpecifyOutputFile/node/ref/m1.js deleted file mode 100644 index 37f4ec486b2..00000000000 --- a/tests/baselines/reference/project/outModuleMultifolderSpecifyOutputFile/node/ref/m1.js +++ /dev/null @@ -1,12 +0,0 @@ -exports.m1_a1 = 10; -var m1_c1 = (function () { - function m1_c1() { - } - return m1_c1; -})(); -exports.m1_c1 = m1_c1; -exports.m1_instance1 = new m1_c1(); -function m1_f1() { - return exports.m1_instance1; -} -exports.m1_f1 = m1_f1; diff --git a/tests/baselines/reference/project/outModuleMultifolderSpecifyOutputFile/node/test.d.ts b/tests/baselines/reference/project/outModuleMultifolderSpecifyOutputFile/node/test.d.ts deleted file mode 100644 index 4afd4e69f2d..00000000000 --- a/tests/baselines/reference/project/outModuleMultifolderSpecifyOutputFile/node/test.d.ts +++ /dev/null @@ -1,10 +0,0 @@ -import m1 = require("ref/m1"); -import m2 = require("../outputdir_module_multifolder_ref/m2"); -export declare var a1: number; -export declare class c1 { - p1: number; -} -export declare var instance1: c1; -export declare function f1(): c1; -export declare var a2: typeof m1.m1_c1; -export declare var a3: typeof m2.m2_c1; diff --git a/tests/baselines/reference/project/outModuleMultifolderSpecifyOutputFile/node/test.js b/tests/baselines/reference/project/outModuleMultifolderSpecifyOutputFile/node/test.js deleted file mode 100644 index d1c1b22a85b..00000000000 --- a/tests/baselines/reference/project/outModuleMultifolderSpecifyOutputFile/node/test.js +++ /dev/null @@ -1,16 +0,0 @@ -var m1 = require("ref/m1"); -var m2 = require("../outputdir_module_multifolder_ref/m2"); -exports.a1 = 10; -var c1 = (function () { - function c1() { - } - return c1; -})(); -exports.c1 = c1; -exports.instance1 = new c1(); -function f1() { - return exports.instance1; -} -exports.f1 = f1; -exports.a2 = m1.m1_c1; -exports.a3 = m2.m2_c1; diff --git a/tests/baselines/reference/project/outModuleSimpleSpecifyOutputFile/amd/m1.d.ts b/tests/baselines/reference/project/outModuleSimpleSpecifyOutputFile/amd/m1.d.ts deleted file mode 100644 index 4a53b24b156..00000000000 --- a/tests/baselines/reference/project/outModuleSimpleSpecifyOutputFile/amd/m1.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -export declare var m1_a1: number; -export declare class m1_c1 { - m1_c1_p1: number; -} -export declare var m1_instance1: m1_c1; -export declare function m1_f1(): m1_c1; diff --git a/tests/baselines/reference/project/outModuleSimpleSpecifyOutputFile/amd/m1.js b/tests/baselines/reference/project/outModuleSimpleSpecifyOutputFile/amd/m1.js deleted file mode 100644 index c2a6326846e..00000000000 --- a/tests/baselines/reference/project/outModuleSimpleSpecifyOutputFile/amd/m1.js +++ /dev/null @@ -1,14 +0,0 @@ -define(["require", "exports"], function (require, exports) { - exports.m1_a1 = 10; - var m1_c1 = (function () { - function m1_c1() { - } - return m1_c1; - })(); - exports.m1_c1 = m1_c1; - exports.m1_instance1 = new m1_c1(); - function m1_f1() { - return exports.m1_instance1; - } - exports.m1_f1 = m1_f1; -}); diff --git a/tests/baselines/reference/project/outModuleSimpleSpecifyOutputFile/amd/outModuleSimpleSpecifyOutputFile.json b/tests/baselines/reference/project/outModuleSimpleSpecifyOutputFile/amd/outModuleSimpleSpecifyOutputFile.json index 166aaa982e7..11bd042a34c 100644 --- a/tests/baselines/reference/project/outModuleSimpleSpecifyOutputFile/amd/outModuleSimpleSpecifyOutputFile.json +++ b/tests/baselines/reference/project/outModuleSimpleSpecifyOutputFile/amd/outModuleSimpleSpecifyOutputFile.json @@ -13,10 +13,6 @@ "test.ts" ], "emittedFiles": [ - "m1.js", - "m1.d.ts", - "test.js", - "test.d.ts", "bin/test.js", "bin/test.d.ts" ] diff --git a/tests/baselines/reference/project/outModuleSimpleSpecifyOutputFile/amd/test.d.ts b/tests/baselines/reference/project/outModuleSimpleSpecifyOutputFile/amd/test.d.ts deleted file mode 100644 index 250d2615a79..00000000000 --- a/tests/baselines/reference/project/outModuleSimpleSpecifyOutputFile/amd/test.d.ts +++ /dev/null @@ -1,8 +0,0 @@ -import m1 = require("m1"); -export declare var a1: number; -export declare class c1 { - p1: number; -} -export declare var instance1: c1; -export declare function f1(): c1; -export declare var a2: typeof m1.m1_c1; diff --git a/tests/baselines/reference/project/outModuleSimpleSpecifyOutputFile/amd/test.js b/tests/baselines/reference/project/outModuleSimpleSpecifyOutputFile/amd/test.js deleted file mode 100644 index b6c62f75f3c..00000000000 --- a/tests/baselines/reference/project/outModuleSimpleSpecifyOutputFile/amd/test.js +++ /dev/null @@ -1,15 +0,0 @@ -define(["require", "exports", "m1"], function (require, exports, m1) { - exports.a1 = 10; - var c1 = (function () { - function c1() { - } - return c1; - })(); - exports.c1 = c1; - exports.instance1 = new c1(); - function f1() { - return exports.instance1; - } - exports.f1 = f1; - exports.a2 = m1.m1_c1; -}); diff --git a/tests/baselines/reference/project/outModuleSimpleSpecifyOutputFile/node/m1.d.ts b/tests/baselines/reference/project/outModuleSimpleSpecifyOutputFile/node/m1.d.ts deleted file mode 100644 index 4a53b24b156..00000000000 --- a/tests/baselines/reference/project/outModuleSimpleSpecifyOutputFile/node/m1.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -export declare var m1_a1: number; -export declare class m1_c1 { - m1_c1_p1: number; -} -export declare var m1_instance1: m1_c1; -export declare function m1_f1(): m1_c1; diff --git a/tests/baselines/reference/project/outModuleSimpleSpecifyOutputFile/node/m1.js b/tests/baselines/reference/project/outModuleSimpleSpecifyOutputFile/node/m1.js deleted file mode 100644 index 37f4ec486b2..00000000000 --- a/tests/baselines/reference/project/outModuleSimpleSpecifyOutputFile/node/m1.js +++ /dev/null @@ -1,12 +0,0 @@ -exports.m1_a1 = 10; -var m1_c1 = (function () { - function m1_c1() { - } - return m1_c1; -})(); -exports.m1_c1 = m1_c1; -exports.m1_instance1 = new m1_c1(); -function m1_f1() { - return exports.m1_instance1; -} -exports.m1_f1 = m1_f1; diff --git a/tests/baselines/reference/project/outModuleSimpleSpecifyOutputFile/node/outModuleSimpleSpecifyOutputFile.json b/tests/baselines/reference/project/outModuleSimpleSpecifyOutputFile/node/outModuleSimpleSpecifyOutputFile.json index 166aaa982e7..11bd042a34c 100644 --- a/tests/baselines/reference/project/outModuleSimpleSpecifyOutputFile/node/outModuleSimpleSpecifyOutputFile.json +++ b/tests/baselines/reference/project/outModuleSimpleSpecifyOutputFile/node/outModuleSimpleSpecifyOutputFile.json @@ -13,10 +13,6 @@ "test.ts" ], "emittedFiles": [ - "m1.js", - "m1.d.ts", - "test.js", - "test.d.ts", "bin/test.js", "bin/test.d.ts" ] diff --git a/tests/baselines/reference/project/outModuleSimpleSpecifyOutputFile/node/test.d.ts b/tests/baselines/reference/project/outModuleSimpleSpecifyOutputFile/node/test.d.ts deleted file mode 100644 index 250d2615a79..00000000000 --- a/tests/baselines/reference/project/outModuleSimpleSpecifyOutputFile/node/test.d.ts +++ /dev/null @@ -1,8 +0,0 @@ -import m1 = require("m1"); -export declare var a1: number; -export declare class c1 { - p1: number; -} -export declare var instance1: c1; -export declare function f1(): c1; -export declare var a2: typeof m1.m1_c1; diff --git a/tests/baselines/reference/project/outModuleSimpleSpecifyOutputFile/node/test.js b/tests/baselines/reference/project/outModuleSimpleSpecifyOutputFile/node/test.js deleted file mode 100644 index d016c5ff00a..00000000000 --- a/tests/baselines/reference/project/outModuleSimpleSpecifyOutputFile/node/test.js +++ /dev/null @@ -1,14 +0,0 @@ -var m1 = require("m1"); -exports.a1 = 10; -var c1 = (function () { - function c1() { - } - return c1; -})(); -exports.c1 = c1; -exports.instance1 = new c1(); -function f1() { - return exports.instance1; -} -exports.f1 = f1; -exports.a2 = m1.m1_c1; diff --git a/tests/baselines/reference/project/outModuleSubfolderSpecifyOutputFile/amd/outModuleSubfolderSpecifyOutputFile.json b/tests/baselines/reference/project/outModuleSubfolderSpecifyOutputFile/amd/outModuleSubfolderSpecifyOutputFile.json index f11b95edde9..d37850e3f0b 100644 --- a/tests/baselines/reference/project/outModuleSubfolderSpecifyOutputFile/amd/outModuleSubfolderSpecifyOutputFile.json +++ b/tests/baselines/reference/project/outModuleSubfolderSpecifyOutputFile/amd/outModuleSubfolderSpecifyOutputFile.json @@ -13,10 +13,6 @@ "test.ts" ], "emittedFiles": [ - "ref/m1.js", - "ref/m1.d.ts", - "test.js", - "test.d.ts", "bin/test.js", "bin/test.d.ts" ] diff --git a/tests/baselines/reference/project/outModuleSubfolderSpecifyOutputFile/amd/ref/m1.d.ts b/tests/baselines/reference/project/outModuleSubfolderSpecifyOutputFile/amd/ref/m1.d.ts deleted file mode 100644 index 4a53b24b156..00000000000 --- a/tests/baselines/reference/project/outModuleSubfolderSpecifyOutputFile/amd/ref/m1.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -export declare var m1_a1: number; -export declare class m1_c1 { - m1_c1_p1: number; -} -export declare var m1_instance1: m1_c1; -export declare function m1_f1(): m1_c1; diff --git a/tests/baselines/reference/project/outModuleSubfolderSpecifyOutputFile/amd/ref/m1.js b/tests/baselines/reference/project/outModuleSubfolderSpecifyOutputFile/amd/ref/m1.js deleted file mode 100644 index c2a6326846e..00000000000 --- a/tests/baselines/reference/project/outModuleSubfolderSpecifyOutputFile/amd/ref/m1.js +++ /dev/null @@ -1,14 +0,0 @@ -define(["require", "exports"], function (require, exports) { - exports.m1_a1 = 10; - var m1_c1 = (function () { - function m1_c1() { - } - return m1_c1; - })(); - exports.m1_c1 = m1_c1; - exports.m1_instance1 = new m1_c1(); - function m1_f1() { - return exports.m1_instance1; - } - exports.m1_f1 = m1_f1; -}); diff --git a/tests/baselines/reference/project/outModuleSubfolderSpecifyOutputFile/amd/test.d.ts b/tests/baselines/reference/project/outModuleSubfolderSpecifyOutputFile/amd/test.d.ts deleted file mode 100644 index a61d8541048..00000000000 --- a/tests/baselines/reference/project/outModuleSubfolderSpecifyOutputFile/amd/test.d.ts +++ /dev/null @@ -1,8 +0,0 @@ -import m1 = require("ref/m1"); -export declare var a1: number; -export declare class c1 { - p1: number; -} -export declare var instance1: c1; -export declare function f1(): c1; -export declare var a2: typeof m1.m1_c1; diff --git a/tests/baselines/reference/project/outModuleSubfolderSpecifyOutputFile/amd/test.js b/tests/baselines/reference/project/outModuleSubfolderSpecifyOutputFile/amd/test.js deleted file mode 100644 index ef183a5773c..00000000000 --- a/tests/baselines/reference/project/outModuleSubfolderSpecifyOutputFile/amd/test.js +++ /dev/null @@ -1,15 +0,0 @@ -define(["require", "exports", "ref/m1"], function (require, exports, m1) { - exports.a1 = 10; - var c1 = (function () { - function c1() { - } - return c1; - })(); - exports.c1 = c1; - exports.instance1 = new c1(); - function f1() { - return exports.instance1; - } - exports.f1 = f1; - exports.a2 = m1.m1_c1; -}); diff --git a/tests/baselines/reference/project/outModuleSubfolderSpecifyOutputFile/node/outModuleSubfolderSpecifyOutputFile.json b/tests/baselines/reference/project/outModuleSubfolderSpecifyOutputFile/node/outModuleSubfolderSpecifyOutputFile.json index f11b95edde9..d37850e3f0b 100644 --- a/tests/baselines/reference/project/outModuleSubfolderSpecifyOutputFile/node/outModuleSubfolderSpecifyOutputFile.json +++ b/tests/baselines/reference/project/outModuleSubfolderSpecifyOutputFile/node/outModuleSubfolderSpecifyOutputFile.json @@ -13,10 +13,6 @@ "test.ts" ], "emittedFiles": [ - "ref/m1.js", - "ref/m1.d.ts", - "test.js", - "test.d.ts", "bin/test.js", "bin/test.d.ts" ] diff --git a/tests/baselines/reference/project/outModuleSubfolderSpecifyOutputFile/node/ref/m1.d.ts b/tests/baselines/reference/project/outModuleSubfolderSpecifyOutputFile/node/ref/m1.d.ts deleted file mode 100644 index 4a53b24b156..00000000000 --- a/tests/baselines/reference/project/outModuleSubfolderSpecifyOutputFile/node/ref/m1.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -export declare var m1_a1: number; -export declare class m1_c1 { - m1_c1_p1: number; -} -export declare var m1_instance1: m1_c1; -export declare function m1_f1(): m1_c1; diff --git a/tests/baselines/reference/project/outModuleSubfolderSpecifyOutputFile/node/ref/m1.js b/tests/baselines/reference/project/outModuleSubfolderSpecifyOutputFile/node/ref/m1.js deleted file mode 100644 index 37f4ec486b2..00000000000 --- a/tests/baselines/reference/project/outModuleSubfolderSpecifyOutputFile/node/ref/m1.js +++ /dev/null @@ -1,12 +0,0 @@ -exports.m1_a1 = 10; -var m1_c1 = (function () { - function m1_c1() { - } - return m1_c1; -})(); -exports.m1_c1 = m1_c1; -exports.m1_instance1 = new m1_c1(); -function m1_f1() { - return exports.m1_instance1; -} -exports.m1_f1 = m1_f1; diff --git a/tests/baselines/reference/project/outModuleSubfolderSpecifyOutputFile/node/test.d.ts b/tests/baselines/reference/project/outModuleSubfolderSpecifyOutputFile/node/test.d.ts deleted file mode 100644 index a61d8541048..00000000000 --- a/tests/baselines/reference/project/outModuleSubfolderSpecifyOutputFile/node/test.d.ts +++ /dev/null @@ -1,8 +0,0 @@ -import m1 = require("ref/m1"); -export declare var a1: number; -export declare class c1 { - p1: number; -} -export declare var instance1: c1; -export declare function f1(): c1; -export declare var a2: typeof m1.m1_c1; diff --git a/tests/baselines/reference/project/outModuleSubfolderSpecifyOutputFile/node/test.js b/tests/baselines/reference/project/outModuleSubfolderSpecifyOutputFile/node/test.js deleted file mode 100644 index 548a35e714c..00000000000 --- a/tests/baselines/reference/project/outModuleSubfolderSpecifyOutputFile/node/test.js +++ /dev/null @@ -1,14 +0,0 @@ -var m1 = require("ref/m1"); -exports.a1 = 10; -var c1 = (function () { - function c1() { - } - return c1; -})(); -exports.c1 = c1; -exports.instance1 = new c1(); -function f1() { - return exports.instance1; -} -exports.f1 = f1; -exports.a2 = m1.m1_c1; diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFile/amd/ref/m2.d.ts b/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFile/amd/ref/m2.d.ts deleted file mode 100644 index c09a3c0c32a..00000000000 --- a/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFile/amd/ref/m2.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -export declare var m2_a1: number; -export declare class m2_c1 { - m2_c1_p1: number; -} -export declare var m2_instance1: m2_c1; -export declare function m2_f1(): m2_c1; diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFile/amd/ref/m2.js b/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFile/amd/ref/m2.js deleted file mode 100644 index 144ad24e2de..00000000000 --- a/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFile/amd/ref/m2.js +++ /dev/null @@ -1,15 +0,0 @@ -define(["require", "exports"], function (require, exports) { - exports.m2_a1 = 10; - var m2_c1 = (function () { - function m2_c1() { - } - return m2_c1; - })(); - exports.m2_c1 = m2_c1; - exports.m2_instance1 = new m2_c1(); - function m2_f1() { - return exports.m2_instance1; - } - exports.m2_f1 = m2_f1; -}); -//# sourceMappingURL=m2.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFile/amd/ref/m2.js.map b/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFile/amd/ref/m2.js.map deleted file mode 100644 index 381b239c573..00000000000 --- a/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFile/amd/ref/m2.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"m2.js","sourceRoot":"/tests/cases/projects/outputdir_mixed_subfolder/src/","sources":["ref/m2.ts"],"names":["m2_c1","m2_c1.constructor","m2_f1"],"mappings":";IAAW,aAAK,GAAG,EAAE,CAAC;IACtB;QAAAA;QAEAC,CAACA;QAADD,YAACA;IAADA,CAACA,AAFD,IAEC;IAFY,aAAK,QAEjB,CAAA;IAEU,oBAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACIE,MAAMA,CAACA,oBAAYA,CAACA;IACxBA,CAACA;IAFe,aAAK,QAEpB,CAAA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFile/amd/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFile.json b/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFile/amd/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFile.json index 09c6092f164..1772111176c 100644 --- a/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFile/amd/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFile.json +++ b/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFile/amd/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFile.json @@ -17,9 +17,6 @@ "test.ts" ], "emittedFiles": [ - "ref/m2.js.map", - "ref/m2.js", - "ref/m2.d.ts", "bin/test.js.map", "bin/test.js", "bin/test.d.ts" diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFile/amd/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFile.sourcemap.txt b/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFile/amd/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFile.sourcemap.txt index 06d778caf3a..7ede7f02c36 100644 --- a/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFile/amd/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFile.sourcemap.txt +++ b/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFile/amd/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFile.sourcemap.txt @@ -1,176 +1,4 @@ =================================================================== -JsFile: m2.js -mapUrl: m2.js.map -sourceRoot: /tests/cases/projects/outputdir_mixed_subfolder/src/ -sources: ref/m2.ts -=================================================================== -------------------------------------------------------------------- -emittedFile:ref/m2.js -sourceFile:ref/m2.ts -------------------------------------------------------------------- ->>>define(["require", "exports"], function (require, exports) { ->>> exports.m2_a1 = 10; -1 >^^^^ -2 > ^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^-> -1 >export var -2 > m2_a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(2, 5) Source(1, 12) + SourceIndex(0) -2 >Emitted(2, 18) Source(1, 17) + SourceIndex(0) -3 >Emitted(2, 21) Source(1, 20) + SourceIndex(0) -4 >Emitted(2, 23) Source(1, 22) + SourceIndex(0) -5 >Emitted(2, 24) Source(1, 23) + SourceIndex(0) ---- ->>> var m2_c1 = (function () { -1->^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^^^^-> -1-> - > -1->Emitted(3, 5) Source(2, 1) + SourceIndex(0) ---- ->>> function m2_c1() { -1->^^^^^^^^ -2 > ^^-> -1-> -1->Emitted(4, 9) Source(2, 1) + SourceIndex(0) name (m2_c1) ---- ->>> } -1->^^^^^^^^ -2 > ^ -3 > ^^^^^^^^^^^^^-> -1->export class m2_c1 { - > public m2_c1_p1: number; - > -2 > } -1->Emitted(5, 9) Source(4, 1) + SourceIndex(0) name (m2_c1.constructor) -2 >Emitted(5, 10) Source(4, 2) + SourceIndex(0) name (m2_c1.constructor) ---- ->>> return m2_c1; -1->^^^^^^^^ -2 > ^^^^^^^^^^^^ -1-> -2 > } -1->Emitted(6, 9) Source(4, 1) + SourceIndex(0) name (m2_c1) -2 >Emitted(6, 21) Source(4, 2) + SourceIndex(0) name (m2_c1) ---- ->>> })(); -1 >^^^^ -2 > ^ -3 > -4 > ^^^^ -5 > ^^^^^^^^^^^^^^^^^^-> -1 > -2 > } -3 > -4 > export class m2_c1 { - > public m2_c1_p1: number; - > } -1 >Emitted(7, 5) Source(4, 1) + SourceIndex(0) name (m2_c1) -2 >Emitted(7, 6) Source(4, 2) + SourceIndex(0) name (m2_c1) -3 >Emitted(7, 6) Source(2, 1) + SourceIndex(0) -4 >Emitted(7, 10) Source(4, 2) + SourceIndex(0) ---- ->>> exports.m2_c1 = m2_c1; -1->^^^^ -2 > ^^^^^^^^^^^^^ -3 > ^^^^^^^^ -4 > ^ -5 > ^^^^^^^^^^^^^^-> -1-> -2 > m2_c1 -3 > { - > public m2_c1_p1: number; - > } -4 > -1->Emitted(8, 5) Source(2, 14) + SourceIndex(0) -2 >Emitted(8, 18) Source(2, 19) + SourceIndex(0) -3 >Emitted(8, 26) Source(4, 2) + SourceIndex(0) -4 >Emitted(8, 27) Source(4, 2) + SourceIndex(0) ---- ->>> exports.m2_instance1 = new m2_c1(); -1->^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^^^ -5 > ^^^^^ -6 > ^^ -7 > ^ -1-> - > - >export var -2 > m2_instance1 -3 > = -4 > new -5 > m2_c1 -6 > () -7 > ; -1->Emitted(9, 5) Source(6, 12) + SourceIndex(0) -2 >Emitted(9, 25) Source(6, 24) + SourceIndex(0) -3 >Emitted(9, 28) Source(6, 27) + SourceIndex(0) -4 >Emitted(9, 32) Source(6, 31) + SourceIndex(0) -5 >Emitted(9, 37) Source(6, 36) + SourceIndex(0) -6 >Emitted(9, 39) Source(6, 38) + SourceIndex(0) -7 >Emitted(9, 40) Source(6, 39) + SourceIndex(0) ---- ->>> function m2_f1() { -1 >^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -1 >Emitted(10, 5) Source(7, 1) + SourceIndex(0) ---- ->>> return exports.m2_instance1; -1->^^^^^^^^ -2 > ^^^^^^ -3 > ^ -4 > ^^^^^^^^^^^^^^^^^^^^ -5 > ^ -1->export function m2_f1() { - > -2 > return -3 > -4 > m2_instance1 -5 > ; -1->Emitted(11, 9) Source(8, 5) + SourceIndex(0) name (m2_f1) -2 >Emitted(11, 15) Source(8, 11) + SourceIndex(0) name (m2_f1) -3 >Emitted(11, 16) Source(8, 12) + SourceIndex(0) name (m2_f1) -4 >Emitted(11, 36) Source(8, 24) + SourceIndex(0) name (m2_f1) -5 >Emitted(11, 37) Source(8, 25) + SourceIndex(0) name (m2_f1) ---- ->>> } -1 >^^^^ -2 > ^ -3 > ^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -2 > } -1 >Emitted(12, 5) Source(9, 1) + SourceIndex(0) name (m2_f1) -2 >Emitted(12, 6) Source(9, 2) + SourceIndex(0) name (m2_f1) ---- ->>> exports.m2_f1 = m2_f1; -1->^^^^ -2 > ^^^^^^^^^^^^^ -3 > ^^^^^^^^ -4 > ^ -1-> -2 > m2_f1 -3 > () { - > return m2_instance1; - > } -4 > -1->Emitted(13, 5) Source(7, 17) + SourceIndex(0) -2 >Emitted(13, 18) Source(7, 22) + SourceIndex(0) -3 >Emitted(13, 26) Source(9, 2) + SourceIndex(0) -4 >Emitted(13, 27) Source(9, 2) + SourceIndex(0) ---- ->>>}); ->>>//# sourceMappingURL=m2.js.map=================================================================== JsFile: test.js mapUrl: test.js.map sourceRoot: /tests/cases/projects/outputdir_mixed_subfolder/src/ diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFile/node/ref/m2.d.ts b/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFile/node/ref/m2.d.ts deleted file mode 100644 index c09a3c0c32a..00000000000 --- a/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFile/node/ref/m2.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -export declare var m2_a1: number; -export declare class m2_c1 { - m2_c1_p1: number; -} -export declare var m2_instance1: m2_c1; -export declare function m2_f1(): m2_c1; diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFile/node/ref/m2.js b/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFile/node/ref/m2.js deleted file mode 100644 index ec0a73b5af8..00000000000 --- a/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFile/node/ref/m2.js +++ /dev/null @@ -1,13 +0,0 @@ -exports.m2_a1 = 10; -var m2_c1 = (function () { - function m2_c1() { - } - return m2_c1; -})(); -exports.m2_c1 = m2_c1; -exports.m2_instance1 = new m2_c1(); -function m2_f1() { - return exports.m2_instance1; -} -exports.m2_f1 = m2_f1; -//# sourceMappingURL=m2.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFile/node/ref/m2.js.map b/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFile/node/ref/m2.js.map deleted file mode 100644 index 2963737a5a0..00000000000 --- a/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFile/node/ref/m2.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"m2.js","sourceRoot":"/tests/cases/projects/outputdir_mixed_subfolder/src/","sources":["ref/m2.ts"],"names":["m2_c1","m2_c1.constructor","m2_f1"],"mappings":"AAAW,aAAK,GAAG,EAAE,CAAC;AACtB;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAFY,aAAK,QAEjB,CAAA;AAEU,oBAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACIE,MAAMA,CAACA,oBAAYA,CAACA;AACxBA,CAACA;AAFe,aAAK,QAEpB,CAAA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFile/node/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFile.json b/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFile/node/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFile.json index 09c6092f164..1772111176c 100644 --- a/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFile/node/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFile.json +++ b/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFile/node/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFile.json @@ -17,9 +17,6 @@ "test.ts" ], "emittedFiles": [ - "ref/m2.js.map", - "ref/m2.js", - "ref/m2.d.ts", "bin/test.js.map", "bin/test.js", "bin/test.d.ts" diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFile/node/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFile.sourcemap.txt b/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFile/node/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFile.sourcemap.txt index 631ec5abf3d..7330eac1399 100644 --- a/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFile/node/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFile.sourcemap.txt +++ b/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFile/node/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFile.sourcemap.txt @@ -1,175 +1,4 @@ =================================================================== -JsFile: m2.js -mapUrl: m2.js.map -sourceRoot: /tests/cases/projects/outputdir_mixed_subfolder/src/ -sources: ref/m2.ts -=================================================================== -------------------------------------------------------------------- -emittedFile:ref/m2.js -sourceFile:ref/m2.ts -------------------------------------------------------------------- ->>>exports.m2_a1 = 10; -1 > -2 >^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^-> -1 >export var -2 >m2_a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(1, 1) Source(1, 12) + SourceIndex(0) -2 >Emitted(1, 14) Source(1, 17) + SourceIndex(0) -3 >Emitted(1, 17) Source(1, 20) + SourceIndex(0) -4 >Emitted(1, 19) Source(1, 22) + SourceIndex(0) -5 >Emitted(1, 20) Source(1, 23) + SourceIndex(0) ---- ->>>var m2_c1 = (function () { -1-> -2 >^^^^^^^^^^^^^^^^^^^^^^^-> -1-> - > -1->Emitted(2, 1) Source(2, 1) + SourceIndex(0) ---- ->>> function m2_c1() { -1->^^^^ -2 > ^^-> -1-> -1->Emitted(3, 5) Source(2, 1) + SourceIndex(0) name (m2_c1) ---- ->>> } -1->^^^^ -2 > ^ -3 > ^^^^^^^^^^^^^-> -1->export class m2_c1 { - > public m2_c1_p1: number; - > -2 > } -1->Emitted(4, 5) Source(4, 1) + SourceIndex(0) name (m2_c1.constructor) -2 >Emitted(4, 6) Source(4, 2) + SourceIndex(0) name (m2_c1.constructor) ---- ->>> return m2_c1; -1->^^^^ -2 > ^^^^^^^^^^^^ -1-> -2 > } -1->Emitted(5, 5) Source(4, 1) + SourceIndex(0) name (m2_c1) -2 >Emitted(5, 17) Source(4, 2) + SourceIndex(0) name (m2_c1) ---- ->>>})(); -1 > -2 >^ -3 > -4 > ^^^^ -5 > ^^^^^^^^^^^^^^^^^^-> -1 > -2 >} -3 > -4 > export class m2_c1 { - > public m2_c1_p1: number; - > } -1 >Emitted(6, 1) Source(4, 1) + SourceIndex(0) name (m2_c1) -2 >Emitted(6, 2) Source(4, 2) + SourceIndex(0) name (m2_c1) -3 >Emitted(6, 2) Source(2, 1) + SourceIndex(0) -4 >Emitted(6, 6) Source(4, 2) + SourceIndex(0) ---- ->>>exports.m2_c1 = m2_c1; -1-> -2 >^^^^^^^^^^^^^ -3 > ^^^^^^^^ -4 > ^ -5 > ^^^^^^^^^^^^^^-> -1-> -2 >m2_c1 -3 > { - > public m2_c1_p1: number; - > } -4 > -1->Emitted(7, 1) Source(2, 14) + SourceIndex(0) -2 >Emitted(7, 14) Source(2, 19) + SourceIndex(0) -3 >Emitted(7, 22) Source(4, 2) + SourceIndex(0) -4 >Emitted(7, 23) Source(4, 2) + SourceIndex(0) ---- ->>>exports.m2_instance1 = new m2_c1(); -1-> -2 >^^^^^^^^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^^^ -5 > ^^^^^ -6 > ^^ -7 > ^ -1-> - > - >export var -2 >m2_instance1 -3 > = -4 > new -5 > m2_c1 -6 > () -7 > ; -1->Emitted(8, 1) Source(6, 12) + SourceIndex(0) -2 >Emitted(8, 21) Source(6, 24) + SourceIndex(0) -3 >Emitted(8, 24) Source(6, 27) + SourceIndex(0) -4 >Emitted(8, 28) Source(6, 31) + SourceIndex(0) -5 >Emitted(8, 33) Source(6, 36) + SourceIndex(0) -6 >Emitted(8, 35) Source(6, 38) + SourceIndex(0) -7 >Emitted(8, 36) Source(6, 39) + SourceIndex(0) ---- ->>>function m2_f1() { -1 > -2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -1 >Emitted(9, 1) Source(7, 1) + SourceIndex(0) ---- ->>> return exports.m2_instance1; -1->^^^^ -2 > ^^^^^^ -3 > ^ -4 > ^^^^^^^^^^^^^^^^^^^^ -5 > ^ -1->export function m2_f1() { - > -2 > return -3 > -4 > m2_instance1 -5 > ; -1->Emitted(10, 5) Source(8, 5) + SourceIndex(0) name (m2_f1) -2 >Emitted(10, 11) Source(8, 11) + SourceIndex(0) name (m2_f1) -3 >Emitted(10, 12) Source(8, 12) + SourceIndex(0) name (m2_f1) -4 >Emitted(10, 32) Source(8, 24) + SourceIndex(0) name (m2_f1) -5 >Emitted(10, 33) Source(8, 25) + SourceIndex(0) name (m2_f1) ---- ->>>} -1 > -2 >^ -3 > ^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -2 >} -1 >Emitted(11, 1) Source(9, 1) + SourceIndex(0) name (m2_f1) -2 >Emitted(11, 2) Source(9, 2) + SourceIndex(0) name (m2_f1) ---- ->>>exports.m2_f1 = m2_f1; -1-> -2 >^^^^^^^^^^^^^ -3 > ^^^^^^^^ -4 > ^ -5 > ^^^^^^^-> -1-> -2 >m2_f1 -3 > () { - > return m2_instance1; - > } -4 > -1->Emitted(12, 1) Source(7, 17) + SourceIndex(0) -2 >Emitted(12, 14) Source(7, 22) + SourceIndex(0) -3 >Emitted(12, 22) Source(9, 2) + SourceIndex(0) -4 >Emitted(12, 23) Source(9, 2) + SourceIndex(0) ---- ->>>//# sourceMappingURL=m2.js.map=================================================================== JsFile: test.js mapUrl: test.js.map sourceRoot: /tests/cases/projects/outputdir_mixed_subfolder/src/ diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/outdir/outAndOutDirFolder/ref/m2.d.ts b/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/outdir/outAndOutDirFolder/ref/m2.d.ts deleted file mode 100644 index c09a3c0c32a..00000000000 --- a/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/outdir/outAndOutDirFolder/ref/m2.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -export declare var m2_a1: number; -export declare class m2_c1 { - m2_c1_p1: number; -} -export declare var m2_instance1: m2_c1; -export declare function m2_f1(): m2_c1; diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/outdir/outAndOutDirFolder/ref/m2.js b/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/outdir/outAndOutDirFolder/ref/m2.js deleted file mode 100644 index 144ad24e2de..00000000000 --- a/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/outdir/outAndOutDirFolder/ref/m2.js +++ /dev/null @@ -1,15 +0,0 @@ -define(["require", "exports"], function (require, exports) { - exports.m2_a1 = 10; - var m2_c1 = (function () { - function m2_c1() { - } - return m2_c1; - })(); - exports.m2_c1 = m2_c1; - exports.m2_instance1 = new m2_c1(); - function m2_f1() { - return exports.m2_instance1; - } - exports.m2_f1 = m2_f1; -}); -//# sourceMappingURL=m2.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/outdir/outAndOutDirFolder/ref/m2.js.map b/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/outdir/outAndOutDirFolder/ref/m2.js.map deleted file mode 100644 index 381b239c573..00000000000 --- a/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/outdir/outAndOutDirFolder/ref/m2.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"m2.js","sourceRoot":"/tests/cases/projects/outputdir_mixed_subfolder/src/","sources":["ref/m2.ts"],"names":["m2_c1","m2_c1.constructor","m2_f1"],"mappings":";IAAW,aAAK,GAAG,EAAE,CAAC;IACtB;QAAAA;QAEAC,CAACA;QAADD,YAACA;IAADA,CAACA,AAFD,IAEC;IAFY,aAAK,QAEjB,CAAA;IAEU,oBAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACIE,MAAMA,CAACA,oBAAYA,CAACA;IACxBA,CAACA;IAFe,aAAK,QAEpB,CAAA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory.json b/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory.json index 6fb17fa06b8..8d7c349b481 100644 --- a/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory.json +++ b/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory.json @@ -18,9 +18,6 @@ "test.ts" ], "emittedFiles": [ - "outdir/outAndOutDirFolder/ref/m2.js.map", - "outdir/outAndOutDirFolder/ref/m2.js", - "outdir/outAndOutDirFolder/ref/m2.d.ts", "bin/outAndOutDirFile.js.map", "bin/outAndOutDirFile.js", "bin/outAndOutDirFile.d.ts" diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory.sourcemap.txt b/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory.sourcemap.txt index bda16ffe4e1..b686585c977 100644 --- a/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory.sourcemap.txt +++ b/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory.sourcemap.txt @@ -1,176 +1,4 @@ =================================================================== -JsFile: m2.js -mapUrl: m2.js.map -sourceRoot: /tests/cases/projects/outputdir_mixed_subfolder/src/ -sources: ref/m2.ts -=================================================================== -------------------------------------------------------------------- -emittedFile:outdir/outAndOutDirFolder/ref/m2.js -sourceFile:ref/m2.ts -------------------------------------------------------------------- ->>>define(["require", "exports"], function (require, exports) { ->>> exports.m2_a1 = 10; -1 >^^^^ -2 > ^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^-> -1 >export var -2 > m2_a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(2, 5) Source(1, 12) + SourceIndex(0) -2 >Emitted(2, 18) Source(1, 17) + SourceIndex(0) -3 >Emitted(2, 21) Source(1, 20) + SourceIndex(0) -4 >Emitted(2, 23) Source(1, 22) + SourceIndex(0) -5 >Emitted(2, 24) Source(1, 23) + SourceIndex(0) ---- ->>> var m2_c1 = (function () { -1->^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^^^^-> -1-> - > -1->Emitted(3, 5) Source(2, 1) + SourceIndex(0) ---- ->>> function m2_c1() { -1->^^^^^^^^ -2 > ^^-> -1-> -1->Emitted(4, 9) Source(2, 1) + SourceIndex(0) name (m2_c1) ---- ->>> } -1->^^^^^^^^ -2 > ^ -3 > ^^^^^^^^^^^^^-> -1->export class m2_c1 { - > public m2_c1_p1: number; - > -2 > } -1->Emitted(5, 9) Source(4, 1) + SourceIndex(0) name (m2_c1.constructor) -2 >Emitted(5, 10) Source(4, 2) + SourceIndex(0) name (m2_c1.constructor) ---- ->>> return m2_c1; -1->^^^^^^^^ -2 > ^^^^^^^^^^^^ -1-> -2 > } -1->Emitted(6, 9) Source(4, 1) + SourceIndex(0) name (m2_c1) -2 >Emitted(6, 21) Source(4, 2) + SourceIndex(0) name (m2_c1) ---- ->>> })(); -1 >^^^^ -2 > ^ -3 > -4 > ^^^^ -5 > ^^^^^^^^^^^^^^^^^^-> -1 > -2 > } -3 > -4 > export class m2_c1 { - > public m2_c1_p1: number; - > } -1 >Emitted(7, 5) Source(4, 1) + SourceIndex(0) name (m2_c1) -2 >Emitted(7, 6) Source(4, 2) + SourceIndex(0) name (m2_c1) -3 >Emitted(7, 6) Source(2, 1) + SourceIndex(0) -4 >Emitted(7, 10) Source(4, 2) + SourceIndex(0) ---- ->>> exports.m2_c1 = m2_c1; -1->^^^^ -2 > ^^^^^^^^^^^^^ -3 > ^^^^^^^^ -4 > ^ -5 > ^^^^^^^^^^^^^^-> -1-> -2 > m2_c1 -3 > { - > public m2_c1_p1: number; - > } -4 > -1->Emitted(8, 5) Source(2, 14) + SourceIndex(0) -2 >Emitted(8, 18) Source(2, 19) + SourceIndex(0) -3 >Emitted(8, 26) Source(4, 2) + SourceIndex(0) -4 >Emitted(8, 27) Source(4, 2) + SourceIndex(0) ---- ->>> exports.m2_instance1 = new m2_c1(); -1->^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^^^ -5 > ^^^^^ -6 > ^^ -7 > ^ -1-> - > - >export var -2 > m2_instance1 -3 > = -4 > new -5 > m2_c1 -6 > () -7 > ; -1->Emitted(9, 5) Source(6, 12) + SourceIndex(0) -2 >Emitted(9, 25) Source(6, 24) + SourceIndex(0) -3 >Emitted(9, 28) Source(6, 27) + SourceIndex(0) -4 >Emitted(9, 32) Source(6, 31) + SourceIndex(0) -5 >Emitted(9, 37) Source(6, 36) + SourceIndex(0) -6 >Emitted(9, 39) Source(6, 38) + SourceIndex(0) -7 >Emitted(9, 40) Source(6, 39) + SourceIndex(0) ---- ->>> function m2_f1() { -1 >^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -1 >Emitted(10, 5) Source(7, 1) + SourceIndex(0) ---- ->>> return exports.m2_instance1; -1->^^^^^^^^ -2 > ^^^^^^ -3 > ^ -4 > ^^^^^^^^^^^^^^^^^^^^ -5 > ^ -1->export function m2_f1() { - > -2 > return -3 > -4 > m2_instance1 -5 > ; -1->Emitted(11, 9) Source(8, 5) + SourceIndex(0) name (m2_f1) -2 >Emitted(11, 15) Source(8, 11) + SourceIndex(0) name (m2_f1) -3 >Emitted(11, 16) Source(8, 12) + SourceIndex(0) name (m2_f1) -4 >Emitted(11, 36) Source(8, 24) + SourceIndex(0) name (m2_f1) -5 >Emitted(11, 37) Source(8, 25) + SourceIndex(0) name (m2_f1) ---- ->>> } -1 >^^^^ -2 > ^ -3 > ^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -2 > } -1 >Emitted(12, 5) Source(9, 1) + SourceIndex(0) name (m2_f1) -2 >Emitted(12, 6) Source(9, 2) + SourceIndex(0) name (m2_f1) ---- ->>> exports.m2_f1 = m2_f1; -1->^^^^ -2 > ^^^^^^^^^^^^^ -3 > ^^^^^^^^ -4 > ^ -1-> -2 > m2_f1 -3 > () { - > return m2_instance1; - > } -4 > -1->Emitted(13, 5) Source(7, 17) + SourceIndex(0) -2 >Emitted(13, 18) Source(7, 22) + SourceIndex(0) -3 >Emitted(13, 26) Source(9, 2) + SourceIndex(0) -4 >Emitted(13, 27) Source(9, 2) + SourceIndex(0) ---- ->>>}); ->>>//# sourceMappingURL=m2.js.map=================================================================== JsFile: outAndOutDirFile.js mapUrl: outAndOutDirFile.js.map sourceRoot: /tests/cases/projects/outputdir_mixed_subfolder/src/ diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/outdir/outAndOutDirFolder/ref/m2.d.ts b/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/outdir/outAndOutDirFolder/ref/m2.d.ts deleted file mode 100644 index c09a3c0c32a..00000000000 --- a/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/outdir/outAndOutDirFolder/ref/m2.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -export declare var m2_a1: number; -export declare class m2_c1 { - m2_c1_p1: number; -} -export declare var m2_instance1: m2_c1; -export declare function m2_f1(): m2_c1; diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/outdir/outAndOutDirFolder/ref/m2.js b/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/outdir/outAndOutDirFolder/ref/m2.js deleted file mode 100644 index ec0a73b5af8..00000000000 --- a/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/outdir/outAndOutDirFolder/ref/m2.js +++ /dev/null @@ -1,13 +0,0 @@ -exports.m2_a1 = 10; -var m2_c1 = (function () { - function m2_c1() { - } - return m2_c1; -})(); -exports.m2_c1 = m2_c1; -exports.m2_instance1 = new m2_c1(); -function m2_f1() { - return exports.m2_instance1; -} -exports.m2_f1 = m2_f1; -//# sourceMappingURL=m2.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/outdir/outAndOutDirFolder/ref/m2.js.map b/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/outdir/outAndOutDirFolder/ref/m2.js.map deleted file mode 100644 index 2963737a5a0..00000000000 --- a/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/outdir/outAndOutDirFolder/ref/m2.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"m2.js","sourceRoot":"/tests/cases/projects/outputdir_mixed_subfolder/src/","sources":["ref/m2.ts"],"names":["m2_c1","m2_c1.constructor","m2_f1"],"mappings":"AAAW,aAAK,GAAG,EAAE,CAAC;AACtB;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAFY,aAAK,QAEjB,CAAA;AAEU,oBAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACIE,MAAMA,CAACA,oBAAYA,CAACA;AACxBA,CAACA;AAFe,aAAK,QAEpB,CAAA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory.json b/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory.json index 6fb17fa06b8..8d7c349b481 100644 --- a/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory.json +++ b/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory.json @@ -18,9 +18,6 @@ "test.ts" ], "emittedFiles": [ - "outdir/outAndOutDirFolder/ref/m2.js.map", - "outdir/outAndOutDirFolder/ref/m2.js", - "outdir/outAndOutDirFolder/ref/m2.d.ts", "bin/outAndOutDirFile.js.map", "bin/outAndOutDirFile.js", "bin/outAndOutDirFile.d.ts" diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory.sourcemap.txt b/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory.sourcemap.txt index d46f8d557ed..71a33c01806 100644 --- a/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory.sourcemap.txt +++ b/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory.sourcemap.txt @@ -1,175 +1,4 @@ =================================================================== -JsFile: m2.js -mapUrl: m2.js.map -sourceRoot: /tests/cases/projects/outputdir_mixed_subfolder/src/ -sources: ref/m2.ts -=================================================================== -------------------------------------------------------------------- -emittedFile:outdir/outAndOutDirFolder/ref/m2.js -sourceFile:ref/m2.ts -------------------------------------------------------------------- ->>>exports.m2_a1 = 10; -1 > -2 >^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^-> -1 >export var -2 >m2_a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(1, 1) Source(1, 12) + SourceIndex(0) -2 >Emitted(1, 14) Source(1, 17) + SourceIndex(0) -3 >Emitted(1, 17) Source(1, 20) + SourceIndex(0) -4 >Emitted(1, 19) Source(1, 22) + SourceIndex(0) -5 >Emitted(1, 20) Source(1, 23) + SourceIndex(0) ---- ->>>var m2_c1 = (function () { -1-> -2 >^^^^^^^^^^^^^^^^^^^^^^^-> -1-> - > -1->Emitted(2, 1) Source(2, 1) + SourceIndex(0) ---- ->>> function m2_c1() { -1->^^^^ -2 > ^^-> -1-> -1->Emitted(3, 5) Source(2, 1) + SourceIndex(0) name (m2_c1) ---- ->>> } -1->^^^^ -2 > ^ -3 > ^^^^^^^^^^^^^-> -1->export class m2_c1 { - > public m2_c1_p1: number; - > -2 > } -1->Emitted(4, 5) Source(4, 1) + SourceIndex(0) name (m2_c1.constructor) -2 >Emitted(4, 6) Source(4, 2) + SourceIndex(0) name (m2_c1.constructor) ---- ->>> return m2_c1; -1->^^^^ -2 > ^^^^^^^^^^^^ -1-> -2 > } -1->Emitted(5, 5) Source(4, 1) + SourceIndex(0) name (m2_c1) -2 >Emitted(5, 17) Source(4, 2) + SourceIndex(0) name (m2_c1) ---- ->>>})(); -1 > -2 >^ -3 > -4 > ^^^^ -5 > ^^^^^^^^^^^^^^^^^^-> -1 > -2 >} -3 > -4 > export class m2_c1 { - > public m2_c1_p1: number; - > } -1 >Emitted(6, 1) Source(4, 1) + SourceIndex(0) name (m2_c1) -2 >Emitted(6, 2) Source(4, 2) + SourceIndex(0) name (m2_c1) -3 >Emitted(6, 2) Source(2, 1) + SourceIndex(0) -4 >Emitted(6, 6) Source(4, 2) + SourceIndex(0) ---- ->>>exports.m2_c1 = m2_c1; -1-> -2 >^^^^^^^^^^^^^ -3 > ^^^^^^^^ -4 > ^ -5 > ^^^^^^^^^^^^^^-> -1-> -2 >m2_c1 -3 > { - > public m2_c1_p1: number; - > } -4 > -1->Emitted(7, 1) Source(2, 14) + SourceIndex(0) -2 >Emitted(7, 14) Source(2, 19) + SourceIndex(0) -3 >Emitted(7, 22) Source(4, 2) + SourceIndex(0) -4 >Emitted(7, 23) Source(4, 2) + SourceIndex(0) ---- ->>>exports.m2_instance1 = new m2_c1(); -1-> -2 >^^^^^^^^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^^^ -5 > ^^^^^ -6 > ^^ -7 > ^ -1-> - > - >export var -2 >m2_instance1 -3 > = -4 > new -5 > m2_c1 -6 > () -7 > ; -1->Emitted(8, 1) Source(6, 12) + SourceIndex(0) -2 >Emitted(8, 21) Source(6, 24) + SourceIndex(0) -3 >Emitted(8, 24) Source(6, 27) + SourceIndex(0) -4 >Emitted(8, 28) Source(6, 31) + SourceIndex(0) -5 >Emitted(8, 33) Source(6, 36) + SourceIndex(0) -6 >Emitted(8, 35) Source(6, 38) + SourceIndex(0) -7 >Emitted(8, 36) Source(6, 39) + SourceIndex(0) ---- ->>>function m2_f1() { -1 > -2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -1 >Emitted(9, 1) Source(7, 1) + SourceIndex(0) ---- ->>> return exports.m2_instance1; -1->^^^^ -2 > ^^^^^^ -3 > ^ -4 > ^^^^^^^^^^^^^^^^^^^^ -5 > ^ -1->export function m2_f1() { - > -2 > return -3 > -4 > m2_instance1 -5 > ; -1->Emitted(10, 5) Source(8, 5) + SourceIndex(0) name (m2_f1) -2 >Emitted(10, 11) Source(8, 11) + SourceIndex(0) name (m2_f1) -3 >Emitted(10, 12) Source(8, 12) + SourceIndex(0) name (m2_f1) -4 >Emitted(10, 32) Source(8, 24) + SourceIndex(0) name (m2_f1) -5 >Emitted(10, 33) Source(8, 25) + SourceIndex(0) name (m2_f1) ---- ->>>} -1 > -2 >^ -3 > ^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -2 >} -1 >Emitted(11, 1) Source(9, 1) + SourceIndex(0) name (m2_f1) -2 >Emitted(11, 2) Source(9, 2) + SourceIndex(0) name (m2_f1) ---- ->>>exports.m2_f1 = m2_f1; -1-> -2 >^^^^^^^^^^^^^ -3 > ^^^^^^^^ -4 > ^ -5 > ^^^^^^^-> -1-> -2 >m2_f1 -3 > () { - > return m2_instance1; - > } -4 > -1->Emitted(12, 1) Source(7, 17) + SourceIndex(0) -2 >Emitted(12, 14) Source(7, 22) + SourceIndex(0) -3 >Emitted(12, 22) Source(9, 2) + SourceIndex(0) -4 >Emitted(12, 23) Source(9, 2) + SourceIndex(0) ---- ->>>//# sourceMappingURL=m2.js.map=================================================================== JsFile: outAndOutDirFile.js mapUrl: outAndOutDirFile.js.map sourceRoot: /tests/cases/projects/outputdir_mixed_subfolder/src/ diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderSpecifyOutputFile/amd/diskFile0.js.map b/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderSpecifyOutputFile/amd/diskFile0.js.map deleted file mode 100644 index c4c57a82e12..00000000000 --- a/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderSpecifyOutputFile/amd/diskFile0.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"m2.js","sourceRoot":"/tests/cases/projects/outputdir_module_multifolder/src/","sources":["outputdir_module_multifolder_ref/m2.ts"],"names":["m2_c1","m2_c1.constructor","m2_f1"],"mappings":";IAAW,aAAK,GAAG,EAAE,CAAC;IACtB;QAAAA;QAEAC,CAACA;QAADD,YAACA;IAADA,CAACA,AAFD,IAEC;IAFY,aAAK,QAEjB,CAAA;IAEU,oBAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACIE,MAAMA,CAACA,oBAAYA,CAACA;IACxBA,CAACA;IAFe,aAAK,QAEpB,CAAA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderSpecifyOutputFile/amd/diskFile1.js b/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderSpecifyOutputFile/amd/diskFile1.js deleted file mode 100644 index 144ad24e2de..00000000000 --- a/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderSpecifyOutputFile/amd/diskFile1.js +++ /dev/null @@ -1,15 +0,0 @@ -define(["require", "exports"], function (require, exports) { - exports.m2_a1 = 10; - var m2_c1 = (function () { - function m2_c1() { - } - return m2_c1; - })(); - exports.m2_c1 = m2_c1; - exports.m2_instance1 = new m2_c1(); - function m2_f1() { - return exports.m2_instance1; - } - exports.m2_f1 = m2_f1; -}); -//# sourceMappingURL=m2.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderSpecifyOutputFile/amd/diskFile2.d.ts b/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderSpecifyOutputFile/amd/diskFile2.d.ts deleted file mode 100644 index c09a3c0c32a..00000000000 --- a/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderSpecifyOutputFile/amd/diskFile2.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -export declare var m2_a1: number; -export declare class m2_c1 { - m2_c1_p1: number; -} -export declare var m2_instance1: m2_c1; -export declare function m2_f1(): m2_c1; diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderSpecifyOutputFile/amd/ref/m1.d.ts b/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderSpecifyOutputFile/amd/ref/m1.d.ts deleted file mode 100644 index 4a53b24b156..00000000000 --- a/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderSpecifyOutputFile/amd/ref/m1.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -export declare var m1_a1: number; -export declare class m1_c1 { - m1_c1_p1: number; -} -export declare var m1_instance1: m1_c1; -export declare function m1_f1(): m1_c1; diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderSpecifyOutputFile/amd/ref/m1.js b/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderSpecifyOutputFile/amd/ref/m1.js deleted file mode 100644 index bbaba444ba2..00000000000 --- a/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderSpecifyOutputFile/amd/ref/m1.js +++ /dev/null @@ -1,15 +0,0 @@ -define(["require", "exports"], function (require, exports) { - exports.m1_a1 = 10; - var m1_c1 = (function () { - function m1_c1() { - } - return m1_c1; - })(); - exports.m1_c1 = m1_c1; - exports.m1_instance1 = new m1_c1(); - function m1_f1() { - return exports.m1_instance1; - } - exports.m1_f1 = m1_f1; -}); -//# sourceMappingURL=m1.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderSpecifyOutputFile/amd/ref/m1.js.map b/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderSpecifyOutputFile/amd/ref/m1.js.map deleted file mode 100644 index 71e1da5d3cc..00000000000 --- a/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderSpecifyOutputFile/amd/ref/m1.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"m1.js","sourceRoot":"/tests/cases/projects/outputdir_module_multifolder/src/","sources":["outputdir_module_multifolder/ref/m1.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1"],"mappings":";IAAW,aAAK,GAAG,EAAE,CAAC;IACtB;QAAAA;QAEAC,CAACA;QAADD,YAACA;IAADA,CAACA,AAFD,IAEC;IAFY,aAAK,QAEjB,CAAA;IAEU,oBAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACIE,MAAMA,CAACA,oBAAYA,CAACA;IACxBA,CAACA;IAFe,aAAK,QAEpB,CAAA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderSpecifyOutputFile/amd/sourceRootAbsolutePathModuleMultifolderSpecifyOutputFile.json b/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderSpecifyOutputFile/amd/sourceRootAbsolutePathModuleMultifolderSpecifyOutputFile.json index b3e80123c04..722a6fbd4da 100644 --- a/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderSpecifyOutputFile/amd/sourceRootAbsolutePathModuleMultifolderSpecifyOutputFile.json +++ b/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderSpecifyOutputFile/amd/sourceRootAbsolutePathModuleMultifolderSpecifyOutputFile.json @@ -17,15 +17,6 @@ "test.ts" ], "emittedFiles": [ - "ref/m1.js.map", - "ref/m1.js", - "ref/m1.d.ts", - "../outputdir_module_multifolder_ref/m2.js.map", - "../outputdir_module_multifolder_ref/m2.js", - "../outputdir_module_multifolder_ref/m2.d.ts", - "test.js.map", - "test.js", - "test.d.ts", "bin/test.js.map", "bin/test.js", "bin/test.d.ts" diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderSpecifyOutputFile/amd/sourceRootAbsolutePathModuleMultifolderSpecifyOutputFile.sourcemap.txt b/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderSpecifyOutputFile/amd/sourceRootAbsolutePathModuleMultifolderSpecifyOutputFile.sourcemap.txt index 3937e0acb04..8c710d9c4da 100644 --- a/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderSpecifyOutputFile/amd/sourceRootAbsolutePathModuleMultifolderSpecifyOutputFile.sourcemap.txt +++ b/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderSpecifyOutputFile/amd/sourceRootAbsolutePathModuleMultifolderSpecifyOutputFile.sourcemap.txt @@ -1,573 +1,4 @@ =================================================================== -JsFile: m1.js -mapUrl: m1.js.map -sourceRoot: /tests/cases/projects/outputdir_module_multifolder/src/ -sources: outputdir_module_multifolder/ref/m1.ts -=================================================================== -------------------------------------------------------------------- -emittedFile:ref/m1.js -sourceFile:outputdir_module_multifolder/ref/m1.ts -------------------------------------------------------------------- ->>>define(["require", "exports"], function (require, exports) { ->>> exports.m1_a1 = 10; -1 >^^^^ -2 > ^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^-> -1 >export var -2 > m1_a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(2, 5) Source(1, 12) + SourceIndex(0) -2 >Emitted(2, 18) Source(1, 17) + SourceIndex(0) -3 >Emitted(2, 21) Source(1, 20) + SourceIndex(0) -4 >Emitted(2, 23) Source(1, 22) + SourceIndex(0) -5 >Emitted(2, 24) Source(1, 23) + SourceIndex(0) ---- ->>> var m1_c1 = (function () { -1->^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^^^^-> -1-> - > -1->Emitted(3, 5) Source(2, 1) + SourceIndex(0) ---- ->>> function m1_c1() { -1->^^^^^^^^ -2 > ^^-> -1-> -1->Emitted(4, 9) Source(2, 1) + SourceIndex(0) name (m1_c1) ---- ->>> } -1->^^^^^^^^ -2 > ^ -3 > ^^^^^^^^^^^^^-> -1->export class m1_c1 { - > public m1_c1_p1: number; - > -2 > } -1->Emitted(5, 9) Source(4, 1) + SourceIndex(0) name (m1_c1.constructor) -2 >Emitted(5, 10) Source(4, 2) + SourceIndex(0) name (m1_c1.constructor) ---- ->>> return m1_c1; -1->^^^^^^^^ -2 > ^^^^^^^^^^^^ -1-> -2 > } -1->Emitted(6, 9) Source(4, 1) + SourceIndex(0) name (m1_c1) -2 >Emitted(6, 21) Source(4, 2) + SourceIndex(0) name (m1_c1) ---- ->>> })(); -1 >^^^^ -2 > ^ -3 > -4 > ^^^^ -5 > ^^^^^^^^^^^^^^^^^^-> -1 > -2 > } -3 > -4 > export class m1_c1 { - > public m1_c1_p1: number; - > } -1 >Emitted(7, 5) Source(4, 1) + SourceIndex(0) name (m1_c1) -2 >Emitted(7, 6) Source(4, 2) + SourceIndex(0) name (m1_c1) -3 >Emitted(7, 6) Source(2, 1) + SourceIndex(0) -4 >Emitted(7, 10) Source(4, 2) + SourceIndex(0) ---- ->>> exports.m1_c1 = m1_c1; -1->^^^^ -2 > ^^^^^^^^^^^^^ -3 > ^^^^^^^^ -4 > ^ -5 > ^^^^^^^^^^^^^^-> -1-> -2 > m1_c1 -3 > { - > public m1_c1_p1: number; - > } -4 > -1->Emitted(8, 5) Source(2, 14) + SourceIndex(0) -2 >Emitted(8, 18) Source(2, 19) + SourceIndex(0) -3 >Emitted(8, 26) Source(4, 2) + SourceIndex(0) -4 >Emitted(8, 27) Source(4, 2) + SourceIndex(0) ---- ->>> exports.m1_instance1 = new m1_c1(); -1->^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^^^ -5 > ^^^^^ -6 > ^^ -7 > ^ -1-> - > - >export var -2 > m1_instance1 -3 > = -4 > new -5 > m1_c1 -6 > () -7 > ; -1->Emitted(9, 5) Source(6, 12) + SourceIndex(0) -2 >Emitted(9, 25) Source(6, 24) + SourceIndex(0) -3 >Emitted(9, 28) Source(6, 27) + SourceIndex(0) -4 >Emitted(9, 32) Source(6, 31) + SourceIndex(0) -5 >Emitted(9, 37) Source(6, 36) + SourceIndex(0) -6 >Emitted(9, 39) Source(6, 38) + SourceIndex(0) -7 >Emitted(9, 40) Source(6, 39) + SourceIndex(0) ---- ->>> function m1_f1() { -1 >^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -1 >Emitted(10, 5) Source(7, 1) + SourceIndex(0) ---- ->>> return exports.m1_instance1; -1->^^^^^^^^ -2 > ^^^^^^ -3 > ^ -4 > ^^^^^^^^^^^^^^^^^^^^ -5 > ^ -1->export function m1_f1() { - > -2 > return -3 > -4 > m1_instance1 -5 > ; -1->Emitted(11, 9) Source(8, 5) + SourceIndex(0) name (m1_f1) -2 >Emitted(11, 15) Source(8, 11) + SourceIndex(0) name (m1_f1) -3 >Emitted(11, 16) Source(8, 12) + SourceIndex(0) name (m1_f1) -4 >Emitted(11, 36) Source(8, 24) + SourceIndex(0) name (m1_f1) -5 >Emitted(11, 37) Source(8, 25) + SourceIndex(0) name (m1_f1) ---- ->>> } -1 >^^^^ -2 > ^ -3 > ^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -2 > } -1 >Emitted(12, 5) Source(9, 1) + SourceIndex(0) name (m1_f1) -2 >Emitted(12, 6) Source(9, 2) + SourceIndex(0) name (m1_f1) ---- ->>> exports.m1_f1 = m1_f1; -1->^^^^ -2 > ^^^^^^^^^^^^^ -3 > ^^^^^^^^ -4 > ^ -1-> -2 > m1_f1 -3 > () { - > return m1_instance1; - > } -4 > -1->Emitted(13, 5) Source(7, 17) + SourceIndex(0) -2 >Emitted(13, 18) Source(7, 22) + SourceIndex(0) -3 >Emitted(13, 26) Source(9, 2) + SourceIndex(0) -4 >Emitted(13, 27) Source(9, 2) + SourceIndex(0) ---- ->>>}); ->>>//# sourceMappingURL=m1.js.map=================================================================== -JsFile: m2.js -mapUrl: m2.js.map -sourceRoot: /tests/cases/projects/outputdir_module_multifolder/src/ -sources: outputdir_module_multifolder_ref/m2.ts -=================================================================== -------------------------------------------------------------------- -emittedFile:diskFile1.js -sourceFile:outputdir_module_multifolder_ref/m2.ts -------------------------------------------------------------------- ->>>define(["require", "exports"], function (require, exports) { ->>> exports.m2_a1 = 10; -1 >^^^^ -2 > ^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^-> -1 >export var -2 > m2_a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(2, 5) Source(1, 12) + SourceIndex(0) -2 >Emitted(2, 18) Source(1, 17) + SourceIndex(0) -3 >Emitted(2, 21) Source(1, 20) + SourceIndex(0) -4 >Emitted(2, 23) Source(1, 22) + SourceIndex(0) -5 >Emitted(2, 24) Source(1, 23) + SourceIndex(0) ---- ->>> var m2_c1 = (function () { -1->^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^^^^-> -1-> - > -1->Emitted(3, 5) Source(2, 1) + SourceIndex(0) ---- ->>> function m2_c1() { -1->^^^^^^^^ -2 > ^^-> -1-> -1->Emitted(4, 9) Source(2, 1) + SourceIndex(0) name (m2_c1) ---- ->>> } -1->^^^^^^^^ -2 > ^ -3 > ^^^^^^^^^^^^^-> -1->export class m2_c1 { - > public m2_c1_p1: number; - > -2 > } -1->Emitted(5, 9) Source(4, 1) + SourceIndex(0) name (m2_c1.constructor) -2 >Emitted(5, 10) Source(4, 2) + SourceIndex(0) name (m2_c1.constructor) ---- ->>> return m2_c1; -1->^^^^^^^^ -2 > ^^^^^^^^^^^^ -1-> -2 > } -1->Emitted(6, 9) Source(4, 1) + SourceIndex(0) name (m2_c1) -2 >Emitted(6, 21) Source(4, 2) + SourceIndex(0) name (m2_c1) ---- ->>> })(); -1 >^^^^ -2 > ^ -3 > -4 > ^^^^ -5 > ^^^^^^^^^^^^^^^^^^-> -1 > -2 > } -3 > -4 > export class m2_c1 { - > public m2_c1_p1: number; - > } -1 >Emitted(7, 5) Source(4, 1) + SourceIndex(0) name (m2_c1) -2 >Emitted(7, 6) Source(4, 2) + SourceIndex(0) name (m2_c1) -3 >Emitted(7, 6) Source(2, 1) + SourceIndex(0) -4 >Emitted(7, 10) Source(4, 2) + SourceIndex(0) ---- ->>> exports.m2_c1 = m2_c1; -1->^^^^ -2 > ^^^^^^^^^^^^^ -3 > ^^^^^^^^ -4 > ^ -5 > ^^^^^^^^^^^^^^-> -1-> -2 > m2_c1 -3 > { - > public m2_c1_p1: number; - > } -4 > -1->Emitted(8, 5) Source(2, 14) + SourceIndex(0) -2 >Emitted(8, 18) Source(2, 19) + SourceIndex(0) -3 >Emitted(8, 26) Source(4, 2) + SourceIndex(0) -4 >Emitted(8, 27) Source(4, 2) + SourceIndex(0) ---- ->>> exports.m2_instance1 = new m2_c1(); -1->^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^^^ -5 > ^^^^^ -6 > ^^ -7 > ^ -1-> - > - >export var -2 > m2_instance1 -3 > = -4 > new -5 > m2_c1 -6 > () -7 > ; -1->Emitted(9, 5) Source(6, 12) + SourceIndex(0) -2 >Emitted(9, 25) Source(6, 24) + SourceIndex(0) -3 >Emitted(9, 28) Source(6, 27) + SourceIndex(0) -4 >Emitted(9, 32) Source(6, 31) + SourceIndex(0) -5 >Emitted(9, 37) Source(6, 36) + SourceIndex(0) -6 >Emitted(9, 39) Source(6, 38) + SourceIndex(0) -7 >Emitted(9, 40) Source(6, 39) + SourceIndex(0) ---- ->>> function m2_f1() { -1 >^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -1 >Emitted(10, 5) Source(7, 1) + SourceIndex(0) ---- ->>> return exports.m2_instance1; -1->^^^^^^^^ -2 > ^^^^^^ -3 > ^ -4 > ^^^^^^^^^^^^^^^^^^^^ -5 > ^ -1->export function m2_f1() { - > -2 > return -3 > -4 > m2_instance1 -5 > ; -1->Emitted(11, 9) Source(8, 5) + SourceIndex(0) name (m2_f1) -2 >Emitted(11, 15) Source(8, 11) + SourceIndex(0) name (m2_f1) -3 >Emitted(11, 16) Source(8, 12) + SourceIndex(0) name (m2_f1) -4 >Emitted(11, 36) Source(8, 24) + SourceIndex(0) name (m2_f1) -5 >Emitted(11, 37) Source(8, 25) + SourceIndex(0) name (m2_f1) ---- ->>> } -1 >^^^^ -2 > ^ -3 > ^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -2 > } -1 >Emitted(12, 5) Source(9, 1) + SourceIndex(0) name (m2_f1) -2 >Emitted(12, 6) Source(9, 2) + SourceIndex(0) name (m2_f1) ---- ->>> exports.m2_f1 = m2_f1; -1->^^^^ -2 > ^^^^^^^^^^^^^ -3 > ^^^^^^^^ -4 > ^ -1-> -2 > m2_f1 -3 > () { - > return m2_instance1; - > } -4 > -1->Emitted(13, 5) Source(7, 17) + SourceIndex(0) -2 >Emitted(13, 18) Source(7, 22) + SourceIndex(0) -3 >Emitted(13, 26) Source(9, 2) + SourceIndex(0) -4 >Emitted(13, 27) Source(9, 2) + SourceIndex(0) ---- ->>>}); ->>>//# sourceMappingURL=m2.js.map=================================================================== -JsFile: test.js -mapUrl: test.js.map -sourceRoot: /tests/cases/projects/outputdir_module_multifolder/src/ -sources: outputdir_module_multifolder/test.ts -=================================================================== -------------------------------------------------------------------- -emittedFile:test.js -sourceFile:outputdir_module_multifolder/test.ts -------------------------------------------------------------------- ->>>define(["require", "exports", "ref/m1", "../outputdir_module_multifolder_ref/m2"], function (require, exports, m1, m2) { ->>> exports.a1 = 10; -1 >^^^^ -2 > ^^^^^^^^^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^-> -1 >import m1 = require("ref/m1"); - >import m2 = require("../outputdir_module_multifolder_ref/m2"); - >export var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(2, 5) Source(3, 12) + SourceIndex(0) -2 >Emitted(2, 15) Source(3, 14) + SourceIndex(0) -3 >Emitted(2, 18) Source(3, 17) + SourceIndex(0) -4 >Emitted(2, 20) Source(3, 19) + SourceIndex(0) -5 >Emitted(2, 21) Source(3, 20) + SourceIndex(0) ---- ->>> var c1 = (function () { -1->^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^-> -1-> - > -1->Emitted(3, 5) Source(4, 1) + SourceIndex(0) ---- ->>> function c1() { -1->^^^^^^^^ -2 > ^^-> -1-> -1->Emitted(4, 9) Source(4, 1) + SourceIndex(0) name (c1) ---- ->>> } -1->^^^^^^^^ -2 > ^ -3 > ^^^^^^^^^^-> -1->export class c1 { - > public p1: number; - > -2 > } -1->Emitted(5, 9) Source(6, 1) + SourceIndex(0) name (c1.constructor) -2 >Emitted(5, 10) Source(6, 2) + SourceIndex(0) name (c1.constructor) ---- ->>> return c1; -1->^^^^^^^^ -2 > ^^^^^^^^^ -1-> -2 > } -1->Emitted(6, 9) Source(6, 1) + SourceIndex(0) name (c1) -2 >Emitted(6, 18) Source(6, 2) + SourceIndex(0) name (c1) ---- ->>> })(); -1 >^^^^ -2 > ^ -3 > -4 > ^^^^ -5 > ^^^^^^^^^^^^-> -1 > -2 > } -3 > -4 > export class c1 { - > public p1: number; - > } -1 >Emitted(7, 5) Source(6, 1) + SourceIndex(0) name (c1) -2 >Emitted(7, 6) Source(6, 2) + SourceIndex(0) name (c1) -3 >Emitted(7, 6) Source(4, 1) + SourceIndex(0) -4 >Emitted(7, 10) Source(6, 2) + SourceIndex(0) ---- ->>> exports.c1 = c1; -1->^^^^ -2 > ^^^^^^^^^^ -3 > ^^^^^ -4 > ^ -5 > ^^^^^^^^^^^^^^-> -1-> -2 > c1 -3 > { - > public p1: number; - > } -4 > -1->Emitted(8, 5) Source(4, 14) + SourceIndex(0) -2 >Emitted(8, 15) Source(4, 16) + SourceIndex(0) -3 >Emitted(8, 20) Source(6, 2) + SourceIndex(0) -4 >Emitted(8, 21) Source(6, 2) + SourceIndex(0) ---- ->>> exports.instance1 = new c1(); -1->^^^^ -2 > ^^^^^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^^^ -5 > ^^ -6 > ^^ -7 > ^ -1-> - > - >export var -2 > instance1 -3 > = -4 > new -5 > c1 -6 > () -7 > ; -1->Emitted(9, 5) Source(8, 12) + SourceIndex(0) -2 >Emitted(9, 22) Source(8, 21) + SourceIndex(0) -3 >Emitted(9, 25) Source(8, 24) + SourceIndex(0) -4 >Emitted(9, 29) Source(8, 28) + SourceIndex(0) -5 >Emitted(9, 31) Source(8, 30) + SourceIndex(0) -6 >Emitted(9, 33) Source(8, 32) + SourceIndex(0) -7 >Emitted(9, 34) Source(8, 33) + SourceIndex(0) ---- ->>> function f1() { -1 >^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -1 >Emitted(10, 5) Source(9, 1) + SourceIndex(0) ---- ->>> return exports.instance1; -1->^^^^^^^^ -2 > ^^^^^^ -3 > ^ -4 > ^^^^^^^^^^^^^^^^^ -5 > ^ -1->export function f1() { - > -2 > return -3 > -4 > instance1 -5 > ; -1->Emitted(11, 9) Source(10, 5) + SourceIndex(0) name (f1) -2 >Emitted(11, 15) Source(10, 11) + SourceIndex(0) name (f1) -3 >Emitted(11, 16) Source(10, 12) + SourceIndex(0) name (f1) -4 >Emitted(11, 33) Source(10, 21) + SourceIndex(0) name (f1) -5 >Emitted(11, 34) Source(10, 22) + SourceIndex(0) name (f1) ---- ->>> } -1 >^^^^ -2 > ^ -3 > ^^^^^^^^^^^^^^^^-> -1 > - > -2 > } -1 >Emitted(12, 5) Source(11, 1) + SourceIndex(0) name (f1) -2 >Emitted(12, 6) Source(11, 2) + SourceIndex(0) name (f1) ---- ->>> exports.f1 = f1; -1->^^^^ -2 > ^^^^^^^^^^ -3 > ^^^^^ -4 > ^ -5 > ^^^^^^^-> -1-> -2 > f1 -3 > () { - > return instance1; - > } -4 > -1->Emitted(13, 5) Source(9, 17) + SourceIndex(0) -2 >Emitted(13, 15) Source(9, 19) + SourceIndex(0) -3 >Emitted(13, 20) Source(11, 2) + SourceIndex(0) -4 >Emitted(13, 21) Source(11, 2) + SourceIndex(0) ---- ->>> exports.a2 = m1.m1_c1; -1->^^^^ -2 > ^^^^^^^^^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^ -7 > ^ -8 > ^-> -1-> - > - >export var -2 > a2 -3 > = -4 > m1 -5 > . -6 > m1_c1 -7 > ; -1->Emitted(14, 5) Source(13, 12) + SourceIndex(0) -2 >Emitted(14, 15) Source(13, 14) + SourceIndex(0) -3 >Emitted(14, 18) Source(13, 17) + SourceIndex(0) -4 >Emitted(14, 20) Source(13, 19) + SourceIndex(0) -5 >Emitted(14, 21) Source(13, 20) + SourceIndex(0) -6 >Emitted(14, 26) Source(13, 25) + SourceIndex(0) -7 >Emitted(14, 27) Source(13, 26) + SourceIndex(0) ---- ->>> exports.a3 = m2.m2_c1; -1->^^^^ -2 > ^^^^^^^^^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^ -7 > ^ -1-> - >export var -2 > a3 -3 > = -4 > m2 -5 > . -6 > m2_c1 -7 > ; -1->Emitted(15, 5) Source(14, 12) + SourceIndex(0) -2 >Emitted(15, 15) Source(14, 14) + SourceIndex(0) -3 >Emitted(15, 18) Source(14, 17) + SourceIndex(0) -4 >Emitted(15, 20) Source(14, 19) + SourceIndex(0) -5 >Emitted(15, 21) Source(14, 20) + SourceIndex(0) -6 >Emitted(15, 26) Source(14, 25) + SourceIndex(0) -7 >Emitted(15, 27) Source(14, 26) + SourceIndex(0) ---- ->>>}); ->>>//# sourceMappingURL=test.js.map=================================================================== JsFile: test.js mapUrl: test.js.map sourceRoot: /tests/cases/projects/outputdir_module_multifolder/src/ diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderSpecifyOutputFile/amd/test.d.ts b/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderSpecifyOutputFile/amd/test.d.ts deleted file mode 100644 index 4afd4e69f2d..00000000000 --- a/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderSpecifyOutputFile/amd/test.d.ts +++ /dev/null @@ -1,10 +0,0 @@ -import m1 = require("ref/m1"); -import m2 = require("../outputdir_module_multifolder_ref/m2"); -export declare var a1: number; -export declare class c1 { - p1: number; -} -export declare var instance1: c1; -export declare function f1(): c1; -export declare var a2: typeof m1.m1_c1; -export declare var a3: typeof m2.m2_c1; diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderSpecifyOutputFile/amd/test.js b/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderSpecifyOutputFile/amd/test.js deleted file mode 100644 index 5cca04a0f25..00000000000 --- a/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderSpecifyOutputFile/amd/test.js +++ /dev/null @@ -1,17 +0,0 @@ -define(["require", "exports", "ref/m1", "../outputdir_module_multifolder_ref/m2"], function (require, exports, m1, m2) { - exports.a1 = 10; - var c1 = (function () { - function c1() { - } - return c1; - })(); - exports.c1 = c1; - exports.instance1 = new c1(); - function f1() { - return exports.instance1; - } - exports.f1 = f1; - exports.a2 = m1.m1_c1; - exports.a3 = m2.m2_c1; -}); -//# sourceMappingURL=test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderSpecifyOutputFile/amd/test.js.map b/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderSpecifyOutputFile/amd/test.js.map deleted file mode 100644 index aeb0a1c3c5d..00000000000 --- a/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderSpecifyOutputFile/amd/test.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"test.js","sourceRoot":"/tests/cases/projects/outputdir_module_multifolder/src/","sources":["outputdir_module_multifolder/test.ts"],"names":["c1","c1.constructor","f1"],"mappings":";IAEW,UAAE,GAAG,EAAE,CAAC;IACnB;QAAAA;QAEAC,CAACA;QAADD,SAACA;IAADA,CAACA,AAFD,IAEC;IAFY,UAAE,KAEd,CAAA;IAEU,iBAAS,GAAG,IAAI,EAAE,EAAE,CAAC;IAChC;QACIE,MAAMA,CAACA,iBAASA,CAACA;IACrBA,CAACA;IAFe,UAAE,KAEjB,CAAA;IAEU,UAAE,GAAG,EAAE,CAAC,KAAK,CAAC;IACd,UAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderSpecifyOutputFile/node/diskFile0.js.map b/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderSpecifyOutputFile/node/diskFile0.js.map deleted file mode 100644 index 7e08245de72..00000000000 --- a/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderSpecifyOutputFile/node/diskFile0.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"m2.js","sourceRoot":"/tests/cases/projects/outputdir_module_multifolder/src/","sources":["outputdir_module_multifolder_ref/m2.ts"],"names":["m2_c1","m2_c1.constructor","m2_f1"],"mappings":"AAAW,aAAK,GAAG,EAAE,CAAC;AACtB;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAFY,aAAK,QAEjB,CAAA;AAEU,oBAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACIE,MAAMA,CAACA,oBAAYA,CAACA;AACxBA,CAACA;AAFe,aAAK,QAEpB,CAAA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderSpecifyOutputFile/node/diskFile1.js b/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderSpecifyOutputFile/node/diskFile1.js deleted file mode 100644 index ec0a73b5af8..00000000000 --- a/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderSpecifyOutputFile/node/diskFile1.js +++ /dev/null @@ -1,13 +0,0 @@ -exports.m2_a1 = 10; -var m2_c1 = (function () { - function m2_c1() { - } - return m2_c1; -})(); -exports.m2_c1 = m2_c1; -exports.m2_instance1 = new m2_c1(); -function m2_f1() { - return exports.m2_instance1; -} -exports.m2_f1 = m2_f1; -//# sourceMappingURL=m2.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderSpecifyOutputFile/node/diskFile2.d.ts b/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderSpecifyOutputFile/node/diskFile2.d.ts deleted file mode 100644 index c09a3c0c32a..00000000000 --- a/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderSpecifyOutputFile/node/diskFile2.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -export declare var m2_a1: number; -export declare class m2_c1 { - m2_c1_p1: number; -} -export declare var m2_instance1: m2_c1; -export declare function m2_f1(): m2_c1; diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderSpecifyOutputFile/node/ref/m1.d.ts b/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderSpecifyOutputFile/node/ref/m1.d.ts deleted file mode 100644 index 4a53b24b156..00000000000 --- a/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderSpecifyOutputFile/node/ref/m1.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -export declare var m1_a1: number; -export declare class m1_c1 { - m1_c1_p1: number; -} -export declare var m1_instance1: m1_c1; -export declare function m1_f1(): m1_c1; diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderSpecifyOutputFile/node/ref/m1.js b/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderSpecifyOutputFile/node/ref/m1.js deleted file mode 100644 index 1b4470e2b37..00000000000 --- a/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderSpecifyOutputFile/node/ref/m1.js +++ /dev/null @@ -1,13 +0,0 @@ -exports.m1_a1 = 10; -var m1_c1 = (function () { - function m1_c1() { - } - return m1_c1; -})(); -exports.m1_c1 = m1_c1; -exports.m1_instance1 = new m1_c1(); -function m1_f1() { - return exports.m1_instance1; -} -exports.m1_f1 = m1_f1; -//# sourceMappingURL=m1.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderSpecifyOutputFile/node/ref/m1.js.map b/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderSpecifyOutputFile/node/ref/m1.js.map deleted file mode 100644 index de341c87ec1..00000000000 --- a/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderSpecifyOutputFile/node/ref/m1.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"m1.js","sourceRoot":"/tests/cases/projects/outputdir_module_multifolder/src/","sources":["outputdir_module_multifolder/ref/m1.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1"],"mappings":"AAAW,aAAK,GAAG,EAAE,CAAC;AACtB;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAFY,aAAK,QAEjB,CAAA;AAEU,oBAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACIE,MAAMA,CAACA,oBAAYA,CAACA;AACxBA,CAACA;AAFe,aAAK,QAEpB,CAAA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderSpecifyOutputFile/node/sourceRootAbsolutePathModuleMultifolderSpecifyOutputFile.json b/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderSpecifyOutputFile/node/sourceRootAbsolutePathModuleMultifolderSpecifyOutputFile.json index b3e80123c04..722a6fbd4da 100644 --- a/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderSpecifyOutputFile/node/sourceRootAbsolutePathModuleMultifolderSpecifyOutputFile.json +++ b/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderSpecifyOutputFile/node/sourceRootAbsolutePathModuleMultifolderSpecifyOutputFile.json @@ -17,15 +17,6 @@ "test.ts" ], "emittedFiles": [ - "ref/m1.js.map", - "ref/m1.js", - "ref/m1.d.ts", - "../outputdir_module_multifolder_ref/m2.js.map", - "../outputdir_module_multifolder_ref/m2.js", - "../outputdir_module_multifolder_ref/m2.d.ts", - "test.js.map", - "test.js", - "test.d.ts", "bin/test.js.map", "bin/test.js", "bin/test.d.ts" diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderSpecifyOutputFile/node/sourceRootAbsolutePathModuleMultifolderSpecifyOutputFile.sourcemap.txt b/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderSpecifyOutputFile/node/sourceRootAbsolutePathModuleMultifolderSpecifyOutputFile.sourcemap.txt index 1c069ce2390..e129af6a045 100644 --- a/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderSpecifyOutputFile/node/sourceRootAbsolutePathModuleMultifolderSpecifyOutputFile.sourcemap.txt +++ b/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderSpecifyOutputFile/node/sourceRootAbsolutePathModuleMultifolderSpecifyOutputFile.sourcemap.txt @@ -1,617 +1,4 @@ =================================================================== -JsFile: m1.js -mapUrl: m1.js.map -sourceRoot: /tests/cases/projects/outputdir_module_multifolder/src/ -sources: outputdir_module_multifolder/ref/m1.ts -=================================================================== -------------------------------------------------------------------- -emittedFile:ref/m1.js -sourceFile:outputdir_module_multifolder/ref/m1.ts -------------------------------------------------------------------- ->>>exports.m1_a1 = 10; -1 > -2 >^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^-> -1 >export var -2 >m1_a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(1, 1) Source(1, 12) + SourceIndex(0) -2 >Emitted(1, 14) Source(1, 17) + SourceIndex(0) -3 >Emitted(1, 17) Source(1, 20) + SourceIndex(0) -4 >Emitted(1, 19) Source(1, 22) + SourceIndex(0) -5 >Emitted(1, 20) Source(1, 23) + SourceIndex(0) ---- ->>>var m1_c1 = (function () { -1-> -2 >^^^^^^^^^^^^^^^^^^^^^^^-> -1-> - > -1->Emitted(2, 1) Source(2, 1) + SourceIndex(0) ---- ->>> function m1_c1() { -1->^^^^ -2 > ^^-> -1-> -1->Emitted(3, 5) Source(2, 1) + SourceIndex(0) name (m1_c1) ---- ->>> } -1->^^^^ -2 > ^ -3 > ^^^^^^^^^^^^^-> -1->export class m1_c1 { - > public m1_c1_p1: number; - > -2 > } -1->Emitted(4, 5) Source(4, 1) + SourceIndex(0) name (m1_c1.constructor) -2 >Emitted(4, 6) Source(4, 2) + SourceIndex(0) name (m1_c1.constructor) ---- ->>> return m1_c1; -1->^^^^ -2 > ^^^^^^^^^^^^ -1-> -2 > } -1->Emitted(5, 5) Source(4, 1) + SourceIndex(0) name (m1_c1) -2 >Emitted(5, 17) Source(4, 2) + SourceIndex(0) name (m1_c1) ---- ->>>})(); -1 > -2 >^ -3 > -4 > ^^^^ -5 > ^^^^^^^^^^^^^^^^^^-> -1 > -2 >} -3 > -4 > export class m1_c1 { - > public m1_c1_p1: number; - > } -1 >Emitted(6, 1) Source(4, 1) + SourceIndex(0) name (m1_c1) -2 >Emitted(6, 2) Source(4, 2) + SourceIndex(0) name (m1_c1) -3 >Emitted(6, 2) Source(2, 1) + SourceIndex(0) -4 >Emitted(6, 6) Source(4, 2) + SourceIndex(0) ---- ->>>exports.m1_c1 = m1_c1; -1-> -2 >^^^^^^^^^^^^^ -3 > ^^^^^^^^ -4 > ^ -5 > ^^^^^^^^^^^^^^-> -1-> -2 >m1_c1 -3 > { - > public m1_c1_p1: number; - > } -4 > -1->Emitted(7, 1) Source(2, 14) + SourceIndex(0) -2 >Emitted(7, 14) Source(2, 19) + SourceIndex(0) -3 >Emitted(7, 22) Source(4, 2) + SourceIndex(0) -4 >Emitted(7, 23) Source(4, 2) + SourceIndex(0) ---- ->>>exports.m1_instance1 = new m1_c1(); -1-> -2 >^^^^^^^^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^^^ -5 > ^^^^^ -6 > ^^ -7 > ^ -1-> - > - >export var -2 >m1_instance1 -3 > = -4 > new -5 > m1_c1 -6 > () -7 > ; -1->Emitted(8, 1) Source(6, 12) + SourceIndex(0) -2 >Emitted(8, 21) Source(6, 24) + SourceIndex(0) -3 >Emitted(8, 24) Source(6, 27) + SourceIndex(0) -4 >Emitted(8, 28) Source(6, 31) + SourceIndex(0) -5 >Emitted(8, 33) Source(6, 36) + SourceIndex(0) -6 >Emitted(8, 35) Source(6, 38) + SourceIndex(0) -7 >Emitted(8, 36) Source(6, 39) + SourceIndex(0) ---- ->>>function m1_f1() { -1 > -2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -1 >Emitted(9, 1) Source(7, 1) + SourceIndex(0) ---- ->>> return exports.m1_instance1; -1->^^^^ -2 > ^^^^^^ -3 > ^ -4 > ^^^^^^^^^^^^^^^^^^^^ -5 > ^ -1->export function m1_f1() { - > -2 > return -3 > -4 > m1_instance1 -5 > ; -1->Emitted(10, 5) Source(8, 5) + SourceIndex(0) name (m1_f1) -2 >Emitted(10, 11) Source(8, 11) + SourceIndex(0) name (m1_f1) -3 >Emitted(10, 12) Source(8, 12) + SourceIndex(0) name (m1_f1) -4 >Emitted(10, 32) Source(8, 24) + SourceIndex(0) name (m1_f1) -5 >Emitted(10, 33) Source(8, 25) + SourceIndex(0) name (m1_f1) ---- ->>>} -1 > -2 >^ -3 > ^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -2 >} -1 >Emitted(11, 1) Source(9, 1) + SourceIndex(0) name (m1_f1) -2 >Emitted(11, 2) Source(9, 2) + SourceIndex(0) name (m1_f1) ---- ->>>exports.m1_f1 = m1_f1; -1-> -2 >^^^^^^^^^^^^^ -3 > ^^^^^^^^ -4 > ^ -5 > ^^^^^^^-> -1-> -2 >m1_f1 -3 > () { - > return m1_instance1; - > } -4 > -1->Emitted(12, 1) Source(7, 17) + SourceIndex(0) -2 >Emitted(12, 14) Source(7, 22) + SourceIndex(0) -3 >Emitted(12, 22) Source(9, 2) + SourceIndex(0) -4 >Emitted(12, 23) Source(9, 2) + SourceIndex(0) ---- ->>>//# sourceMappingURL=m1.js.map=================================================================== -JsFile: m2.js -mapUrl: m2.js.map -sourceRoot: /tests/cases/projects/outputdir_module_multifolder/src/ -sources: outputdir_module_multifolder_ref/m2.ts -=================================================================== -------------------------------------------------------------------- -emittedFile:diskFile1.js -sourceFile:outputdir_module_multifolder_ref/m2.ts -------------------------------------------------------------------- ->>>exports.m2_a1 = 10; -1 > -2 >^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^-> -1 >export var -2 >m2_a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(1, 1) Source(1, 12) + SourceIndex(0) -2 >Emitted(1, 14) Source(1, 17) + SourceIndex(0) -3 >Emitted(1, 17) Source(1, 20) + SourceIndex(0) -4 >Emitted(1, 19) Source(1, 22) + SourceIndex(0) -5 >Emitted(1, 20) Source(1, 23) + SourceIndex(0) ---- ->>>var m2_c1 = (function () { -1-> -2 >^^^^^^^^^^^^^^^^^^^^^^^-> -1-> - > -1->Emitted(2, 1) Source(2, 1) + SourceIndex(0) ---- ->>> function m2_c1() { -1->^^^^ -2 > ^^-> -1-> -1->Emitted(3, 5) Source(2, 1) + SourceIndex(0) name (m2_c1) ---- ->>> } -1->^^^^ -2 > ^ -3 > ^^^^^^^^^^^^^-> -1->export class m2_c1 { - > public m2_c1_p1: number; - > -2 > } -1->Emitted(4, 5) Source(4, 1) + SourceIndex(0) name (m2_c1.constructor) -2 >Emitted(4, 6) Source(4, 2) + SourceIndex(0) name (m2_c1.constructor) ---- ->>> return m2_c1; -1->^^^^ -2 > ^^^^^^^^^^^^ -1-> -2 > } -1->Emitted(5, 5) Source(4, 1) + SourceIndex(0) name (m2_c1) -2 >Emitted(5, 17) Source(4, 2) + SourceIndex(0) name (m2_c1) ---- ->>>})(); -1 > -2 >^ -3 > -4 > ^^^^ -5 > ^^^^^^^^^^^^^^^^^^-> -1 > -2 >} -3 > -4 > export class m2_c1 { - > public m2_c1_p1: number; - > } -1 >Emitted(6, 1) Source(4, 1) + SourceIndex(0) name (m2_c1) -2 >Emitted(6, 2) Source(4, 2) + SourceIndex(0) name (m2_c1) -3 >Emitted(6, 2) Source(2, 1) + SourceIndex(0) -4 >Emitted(6, 6) Source(4, 2) + SourceIndex(0) ---- ->>>exports.m2_c1 = m2_c1; -1-> -2 >^^^^^^^^^^^^^ -3 > ^^^^^^^^ -4 > ^ -5 > ^^^^^^^^^^^^^^-> -1-> -2 >m2_c1 -3 > { - > public m2_c1_p1: number; - > } -4 > -1->Emitted(7, 1) Source(2, 14) + SourceIndex(0) -2 >Emitted(7, 14) Source(2, 19) + SourceIndex(0) -3 >Emitted(7, 22) Source(4, 2) + SourceIndex(0) -4 >Emitted(7, 23) Source(4, 2) + SourceIndex(0) ---- ->>>exports.m2_instance1 = new m2_c1(); -1-> -2 >^^^^^^^^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^^^ -5 > ^^^^^ -6 > ^^ -7 > ^ -1-> - > - >export var -2 >m2_instance1 -3 > = -4 > new -5 > m2_c1 -6 > () -7 > ; -1->Emitted(8, 1) Source(6, 12) + SourceIndex(0) -2 >Emitted(8, 21) Source(6, 24) + SourceIndex(0) -3 >Emitted(8, 24) Source(6, 27) + SourceIndex(0) -4 >Emitted(8, 28) Source(6, 31) + SourceIndex(0) -5 >Emitted(8, 33) Source(6, 36) + SourceIndex(0) -6 >Emitted(8, 35) Source(6, 38) + SourceIndex(0) -7 >Emitted(8, 36) Source(6, 39) + SourceIndex(0) ---- ->>>function m2_f1() { -1 > -2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -1 >Emitted(9, 1) Source(7, 1) + SourceIndex(0) ---- ->>> return exports.m2_instance1; -1->^^^^ -2 > ^^^^^^ -3 > ^ -4 > ^^^^^^^^^^^^^^^^^^^^ -5 > ^ -1->export function m2_f1() { - > -2 > return -3 > -4 > m2_instance1 -5 > ; -1->Emitted(10, 5) Source(8, 5) + SourceIndex(0) name (m2_f1) -2 >Emitted(10, 11) Source(8, 11) + SourceIndex(0) name (m2_f1) -3 >Emitted(10, 12) Source(8, 12) + SourceIndex(0) name (m2_f1) -4 >Emitted(10, 32) Source(8, 24) + SourceIndex(0) name (m2_f1) -5 >Emitted(10, 33) Source(8, 25) + SourceIndex(0) name (m2_f1) ---- ->>>} -1 > -2 >^ -3 > ^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -2 >} -1 >Emitted(11, 1) Source(9, 1) + SourceIndex(0) name (m2_f1) -2 >Emitted(11, 2) Source(9, 2) + SourceIndex(0) name (m2_f1) ---- ->>>exports.m2_f1 = m2_f1; -1-> -2 >^^^^^^^^^^^^^ -3 > ^^^^^^^^ -4 > ^ -5 > ^^^^^^^-> -1-> -2 >m2_f1 -3 > () { - > return m2_instance1; - > } -4 > -1->Emitted(12, 1) Source(7, 17) + SourceIndex(0) -2 >Emitted(12, 14) Source(7, 22) + SourceIndex(0) -3 >Emitted(12, 22) Source(9, 2) + SourceIndex(0) -4 >Emitted(12, 23) Source(9, 2) + SourceIndex(0) ---- ->>>//# sourceMappingURL=m2.js.map=================================================================== -JsFile: test.js -mapUrl: test.js.map -sourceRoot: /tests/cases/projects/outputdir_module_multifolder/src/ -sources: outputdir_module_multifolder/test.ts -=================================================================== -------------------------------------------------------------------- -emittedFile:test.js -sourceFile:outputdir_module_multifolder/test.ts -------------------------------------------------------------------- ->>>var m1 = require("ref/m1"); -1 > -2 >^^^^ -3 > ^^ -4 > ^^^^^^^^^^^ -5 > ^^^^^^^^ -6 > ^ -7 > ^ -8 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 > -2 >import -3 > m1 -4 > = require( -5 > "ref/m1" -6 > ) -7 > ; -1 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) -2 >Emitted(1, 5) Source(1, 8) + SourceIndex(0) -3 >Emitted(1, 7) Source(1, 10) + SourceIndex(0) -4 >Emitted(1, 18) Source(1, 21) + SourceIndex(0) -5 >Emitted(1, 26) Source(1, 29) + SourceIndex(0) -6 >Emitted(1, 27) Source(1, 30) + SourceIndex(0) -7 >Emitted(1, 28) Source(1, 31) + SourceIndex(0) ---- ->>>var m2 = require("../outputdir_module_multifolder_ref/m2"); -1-> -2 >^^^^ -3 > ^^ -4 > ^^^^^^^^^^^ -5 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -6 > ^ -7 > ^ -1-> - > -2 >import -3 > m2 -4 > = require( -5 > "../outputdir_module_multifolder_ref/m2" -6 > ) -7 > ; -1->Emitted(2, 1) Source(2, 1) + SourceIndex(0) -2 >Emitted(2, 5) Source(2, 8) + SourceIndex(0) -3 >Emitted(2, 7) Source(2, 10) + SourceIndex(0) -4 >Emitted(2, 18) Source(2, 21) + SourceIndex(0) -5 >Emitted(2, 58) Source(2, 61) + SourceIndex(0) -6 >Emitted(2, 59) Source(2, 62) + SourceIndex(0) -7 >Emitted(2, 60) Source(2, 63) + SourceIndex(0) ---- ->>>exports.a1 = 10; -1 > -2 >^^^^^^^^^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^-> -1 > - >export var -2 >a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(3, 1) Source(3, 12) + SourceIndex(0) -2 >Emitted(3, 11) Source(3, 14) + SourceIndex(0) -3 >Emitted(3, 14) Source(3, 17) + SourceIndex(0) -4 >Emitted(3, 16) Source(3, 19) + SourceIndex(0) -5 >Emitted(3, 17) Source(3, 20) + SourceIndex(0) ---- ->>>var c1 = (function () { -1-> -2 >^^^^^^^^^^^^^^^^^^^^-> -1-> - > -1->Emitted(4, 1) Source(4, 1) + SourceIndex(0) ---- ->>> function c1() { -1->^^^^ -2 > ^^-> -1-> -1->Emitted(5, 5) Source(4, 1) + SourceIndex(0) name (c1) ---- ->>> } -1->^^^^ -2 > ^ -3 > ^^^^^^^^^^-> -1->export class c1 { - > public p1: number; - > -2 > } -1->Emitted(6, 5) Source(6, 1) + SourceIndex(0) name (c1.constructor) -2 >Emitted(6, 6) Source(6, 2) + SourceIndex(0) name (c1.constructor) ---- ->>> return c1; -1->^^^^ -2 > ^^^^^^^^^ -1-> -2 > } -1->Emitted(7, 5) Source(6, 1) + SourceIndex(0) name (c1) -2 >Emitted(7, 14) Source(6, 2) + SourceIndex(0) name (c1) ---- ->>>})(); -1 > -2 >^ -3 > -4 > ^^^^ -5 > ^^^^^^^^^^^^-> -1 > -2 >} -3 > -4 > export class c1 { - > public p1: number; - > } -1 >Emitted(8, 1) Source(6, 1) + SourceIndex(0) name (c1) -2 >Emitted(8, 2) Source(6, 2) + SourceIndex(0) name (c1) -3 >Emitted(8, 2) Source(4, 1) + SourceIndex(0) -4 >Emitted(8, 6) Source(6, 2) + SourceIndex(0) ---- ->>>exports.c1 = c1; -1-> -2 >^^^^^^^^^^ -3 > ^^^^^ -4 > ^ -5 > ^^^^^^^^^^^^^^-> -1-> -2 >c1 -3 > { - > public p1: number; - > } -4 > -1->Emitted(9, 1) Source(4, 14) + SourceIndex(0) -2 >Emitted(9, 11) Source(4, 16) + SourceIndex(0) -3 >Emitted(9, 16) Source(6, 2) + SourceIndex(0) -4 >Emitted(9, 17) Source(6, 2) + SourceIndex(0) ---- ->>>exports.instance1 = new c1(); -1-> -2 >^^^^^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^^^ -5 > ^^ -6 > ^^ -7 > ^ -1-> - > - >export var -2 >instance1 -3 > = -4 > new -5 > c1 -6 > () -7 > ; -1->Emitted(10, 1) Source(8, 12) + SourceIndex(0) -2 >Emitted(10, 18) Source(8, 21) + SourceIndex(0) -3 >Emitted(10, 21) Source(8, 24) + SourceIndex(0) -4 >Emitted(10, 25) Source(8, 28) + SourceIndex(0) -5 >Emitted(10, 27) Source(8, 30) + SourceIndex(0) -6 >Emitted(10, 29) Source(8, 32) + SourceIndex(0) -7 >Emitted(10, 30) Source(8, 33) + SourceIndex(0) ---- ->>>function f1() { -1 > -2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -1 >Emitted(11, 1) Source(9, 1) + SourceIndex(0) ---- ->>> return exports.instance1; -1->^^^^ -2 > ^^^^^^ -3 > ^ -4 > ^^^^^^^^^^^^^^^^^ -5 > ^ -1->export function f1() { - > -2 > return -3 > -4 > instance1 -5 > ; -1->Emitted(12, 5) Source(10, 5) + SourceIndex(0) name (f1) -2 >Emitted(12, 11) Source(10, 11) + SourceIndex(0) name (f1) -3 >Emitted(12, 12) Source(10, 12) + SourceIndex(0) name (f1) -4 >Emitted(12, 29) Source(10, 21) + SourceIndex(0) name (f1) -5 >Emitted(12, 30) Source(10, 22) + SourceIndex(0) name (f1) ---- ->>>} -1 > -2 >^ -3 > ^^^^^^^^^^^^^^^^-> -1 > - > -2 >} -1 >Emitted(13, 1) Source(11, 1) + SourceIndex(0) name (f1) -2 >Emitted(13, 2) Source(11, 2) + SourceIndex(0) name (f1) ---- ->>>exports.f1 = f1; -1-> -2 >^^^^^^^^^^ -3 > ^^^^^ -4 > ^ -5 > ^^^^^^^-> -1-> -2 >f1 -3 > () { - > return instance1; - > } -4 > -1->Emitted(14, 1) Source(9, 17) + SourceIndex(0) -2 >Emitted(14, 11) Source(9, 19) + SourceIndex(0) -3 >Emitted(14, 16) Source(11, 2) + SourceIndex(0) -4 >Emitted(14, 17) Source(11, 2) + SourceIndex(0) ---- ->>>exports.a2 = m1.m1_c1; -1-> -2 >^^^^^^^^^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^ -7 > ^ -8 > ^-> -1-> - > - >export var -2 >a2 -3 > = -4 > m1 -5 > . -6 > m1_c1 -7 > ; -1->Emitted(15, 1) Source(13, 12) + SourceIndex(0) -2 >Emitted(15, 11) Source(13, 14) + SourceIndex(0) -3 >Emitted(15, 14) Source(13, 17) + SourceIndex(0) -4 >Emitted(15, 16) Source(13, 19) + SourceIndex(0) -5 >Emitted(15, 17) Source(13, 20) + SourceIndex(0) -6 >Emitted(15, 22) Source(13, 25) + SourceIndex(0) -7 >Emitted(15, 23) Source(13, 26) + SourceIndex(0) ---- ->>>exports.a3 = m2.m2_c1; -1-> -2 >^^^^^^^^^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^ -7 > ^ -8 > ^^^^^^^^^-> -1-> - >export var -2 >a3 -3 > = -4 > m2 -5 > . -6 > m2_c1 -7 > ; -1->Emitted(16, 1) Source(14, 12) + SourceIndex(0) -2 >Emitted(16, 11) Source(14, 14) + SourceIndex(0) -3 >Emitted(16, 14) Source(14, 17) + SourceIndex(0) -4 >Emitted(16, 16) Source(14, 19) + SourceIndex(0) -5 >Emitted(16, 17) Source(14, 20) + SourceIndex(0) -6 >Emitted(16, 22) Source(14, 25) + SourceIndex(0) -7 >Emitted(16, 23) Source(14, 26) + SourceIndex(0) ---- ->>>//# sourceMappingURL=test.js.map=================================================================== JsFile: test.js mapUrl: test.js.map sourceRoot: /tests/cases/projects/outputdir_module_multifolder/src/ diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderSpecifyOutputFile/node/test.d.ts b/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderSpecifyOutputFile/node/test.d.ts deleted file mode 100644 index 4afd4e69f2d..00000000000 --- a/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderSpecifyOutputFile/node/test.d.ts +++ /dev/null @@ -1,10 +0,0 @@ -import m1 = require("ref/m1"); -import m2 = require("../outputdir_module_multifolder_ref/m2"); -export declare var a1: number; -export declare class c1 { - p1: number; -} -export declare var instance1: c1; -export declare function f1(): c1; -export declare var a2: typeof m1.m1_c1; -export declare var a3: typeof m2.m2_c1; diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderSpecifyOutputFile/node/test.js b/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderSpecifyOutputFile/node/test.js deleted file mode 100644 index 14c09e444a5..00000000000 --- a/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderSpecifyOutputFile/node/test.js +++ /dev/null @@ -1,17 +0,0 @@ -var m1 = require("ref/m1"); -var m2 = require("../outputdir_module_multifolder_ref/m2"); -exports.a1 = 10; -var c1 = (function () { - function c1() { - } - return c1; -})(); -exports.c1 = c1; -exports.instance1 = new c1(); -function f1() { - return exports.instance1; -} -exports.f1 = f1; -exports.a2 = m1.m1_c1; -exports.a3 = m2.m2_c1; -//# sourceMappingURL=test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderSpecifyOutputFile/node/test.js.map b/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderSpecifyOutputFile/node/test.js.map deleted file mode 100644 index 0b67e7ee481..00000000000 --- a/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderSpecifyOutputFile/node/test.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"test.js","sourceRoot":"/tests/cases/projects/outputdir_module_multifolder/src/","sources":["outputdir_module_multifolder/test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AAAA,IAAO,EAAE,WAAW,QAAQ,CAAC,CAAC;AAC9B,IAAO,EAAE,WAAW,wCAAwC,CAAC,CAAC;AACnD,UAAE,GAAG,EAAE,CAAC;AACnB;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAFY,UAAE,KAEd,CAAA;AAEU,iBAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AAChC;IACIE,MAAMA,CAACA,iBAASA,CAACA;AACrBA,CAACA;AAFe,UAAE,KAEjB,CAAA;AAEU,UAAE,GAAG,EAAE,CAAC,KAAK,CAAC;AACd,UAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathModuleSimpleSpecifyOutputFile/amd/m1.d.ts b/tests/baselines/reference/project/sourceRootAbsolutePathModuleSimpleSpecifyOutputFile/amd/m1.d.ts deleted file mode 100644 index 4a53b24b156..00000000000 --- a/tests/baselines/reference/project/sourceRootAbsolutePathModuleSimpleSpecifyOutputFile/amd/m1.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -export declare var m1_a1: number; -export declare class m1_c1 { - m1_c1_p1: number; -} -export declare var m1_instance1: m1_c1; -export declare function m1_f1(): m1_c1; diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathModuleSimpleSpecifyOutputFile/amd/m1.js b/tests/baselines/reference/project/sourceRootAbsolutePathModuleSimpleSpecifyOutputFile/amd/m1.js deleted file mode 100644 index bbaba444ba2..00000000000 --- a/tests/baselines/reference/project/sourceRootAbsolutePathModuleSimpleSpecifyOutputFile/amd/m1.js +++ /dev/null @@ -1,15 +0,0 @@ -define(["require", "exports"], function (require, exports) { - exports.m1_a1 = 10; - var m1_c1 = (function () { - function m1_c1() { - } - return m1_c1; - })(); - exports.m1_c1 = m1_c1; - exports.m1_instance1 = new m1_c1(); - function m1_f1() { - return exports.m1_instance1; - } - exports.m1_f1 = m1_f1; -}); -//# sourceMappingURL=m1.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathModuleSimpleSpecifyOutputFile/amd/m1.js.map b/tests/baselines/reference/project/sourceRootAbsolutePathModuleSimpleSpecifyOutputFile/amd/m1.js.map deleted file mode 100644 index 89373fc1cfa..00000000000 --- a/tests/baselines/reference/project/sourceRootAbsolutePathModuleSimpleSpecifyOutputFile/amd/m1.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"m1.js","sourceRoot":"/tests/cases/projects/outputdir_module_simple/src/","sources":["m1.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1"],"mappings":";IAAW,aAAK,GAAG,EAAE,CAAC;IACtB;QAAAA;QAEAC,CAACA;QAADD,YAACA;IAADA,CAACA,AAFD,IAEC;IAFY,aAAK,QAEjB,CAAA;IAEU,oBAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACIE,MAAMA,CAACA,oBAAYA,CAACA;IACxBA,CAACA;IAFe,aAAK,QAEpB,CAAA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathModuleSimpleSpecifyOutputFile/amd/sourceRootAbsolutePathModuleSimpleSpecifyOutputFile.json b/tests/baselines/reference/project/sourceRootAbsolutePathModuleSimpleSpecifyOutputFile/amd/sourceRootAbsolutePathModuleSimpleSpecifyOutputFile.json index e2621b2fa52..f9e2736f65a 100644 --- a/tests/baselines/reference/project/sourceRootAbsolutePathModuleSimpleSpecifyOutputFile/amd/sourceRootAbsolutePathModuleSimpleSpecifyOutputFile.json +++ b/tests/baselines/reference/project/sourceRootAbsolutePathModuleSimpleSpecifyOutputFile/amd/sourceRootAbsolutePathModuleSimpleSpecifyOutputFile.json @@ -16,12 +16,6 @@ "test.ts" ], "emittedFiles": [ - "m1.js.map", - "m1.js", - "m1.d.ts", - "test.js.map", - "test.js", - "test.d.ts", "bin/test.js.map", "bin/test.js", "bin/test.d.ts" diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathModuleSimpleSpecifyOutputFile/amd/sourceRootAbsolutePathModuleSimpleSpecifyOutputFile.sourcemap.txt b/tests/baselines/reference/project/sourceRootAbsolutePathModuleSimpleSpecifyOutputFile/amd/sourceRootAbsolutePathModuleSimpleSpecifyOutputFile.sourcemap.txt index fab0c65ae8e..827aa235ef2 100644 --- a/tests/baselines/reference/project/sourceRootAbsolutePathModuleSimpleSpecifyOutputFile/amd/sourceRootAbsolutePathModuleSimpleSpecifyOutputFile.sourcemap.txt +++ b/tests/baselines/reference/project/sourceRootAbsolutePathModuleSimpleSpecifyOutputFile/amd/sourceRootAbsolutePathModuleSimpleSpecifyOutputFile.sourcemap.txt @@ -1,375 +1,4 @@ =================================================================== -JsFile: m1.js -mapUrl: m1.js.map -sourceRoot: /tests/cases/projects/outputdir_module_simple/src/ -sources: m1.ts -=================================================================== -------------------------------------------------------------------- -emittedFile:m1.js -sourceFile:m1.ts -------------------------------------------------------------------- ->>>define(["require", "exports"], function (require, exports) { ->>> exports.m1_a1 = 10; -1 >^^^^ -2 > ^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^-> -1 >export var -2 > m1_a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(2, 5) Source(1, 12) + SourceIndex(0) -2 >Emitted(2, 18) Source(1, 17) + SourceIndex(0) -3 >Emitted(2, 21) Source(1, 20) + SourceIndex(0) -4 >Emitted(2, 23) Source(1, 22) + SourceIndex(0) -5 >Emitted(2, 24) Source(1, 23) + SourceIndex(0) ---- ->>> var m1_c1 = (function () { -1->^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^^^^-> -1-> - > -1->Emitted(3, 5) Source(2, 1) + SourceIndex(0) ---- ->>> function m1_c1() { -1->^^^^^^^^ -2 > ^^-> -1-> -1->Emitted(4, 9) Source(2, 1) + SourceIndex(0) name (m1_c1) ---- ->>> } -1->^^^^^^^^ -2 > ^ -3 > ^^^^^^^^^^^^^-> -1->export class m1_c1 { - > public m1_c1_p1: number; - > -2 > } -1->Emitted(5, 9) Source(4, 1) + SourceIndex(0) name (m1_c1.constructor) -2 >Emitted(5, 10) Source(4, 2) + SourceIndex(0) name (m1_c1.constructor) ---- ->>> return m1_c1; -1->^^^^^^^^ -2 > ^^^^^^^^^^^^ -1-> -2 > } -1->Emitted(6, 9) Source(4, 1) + SourceIndex(0) name (m1_c1) -2 >Emitted(6, 21) Source(4, 2) + SourceIndex(0) name (m1_c1) ---- ->>> })(); -1 >^^^^ -2 > ^ -3 > -4 > ^^^^ -5 > ^^^^^^^^^^^^^^^^^^-> -1 > -2 > } -3 > -4 > export class m1_c1 { - > public m1_c1_p1: number; - > } -1 >Emitted(7, 5) Source(4, 1) + SourceIndex(0) name (m1_c1) -2 >Emitted(7, 6) Source(4, 2) + SourceIndex(0) name (m1_c1) -3 >Emitted(7, 6) Source(2, 1) + SourceIndex(0) -4 >Emitted(7, 10) Source(4, 2) + SourceIndex(0) ---- ->>> exports.m1_c1 = m1_c1; -1->^^^^ -2 > ^^^^^^^^^^^^^ -3 > ^^^^^^^^ -4 > ^ -5 > ^^^^^^^^^^^^^^-> -1-> -2 > m1_c1 -3 > { - > public m1_c1_p1: number; - > } -4 > -1->Emitted(8, 5) Source(2, 14) + SourceIndex(0) -2 >Emitted(8, 18) Source(2, 19) + SourceIndex(0) -3 >Emitted(8, 26) Source(4, 2) + SourceIndex(0) -4 >Emitted(8, 27) Source(4, 2) + SourceIndex(0) ---- ->>> exports.m1_instance1 = new m1_c1(); -1->^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^^^ -5 > ^^^^^ -6 > ^^ -7 > ^ -1-> - > - >export var -2 > m1_instance1 -3 > = -4 > new -5 > m1_c1 -6 > () -7 > ; -1->Emitted(9, 5) Source(6, 12) + SourceIndex(0) -2 >Emitted(9, 25) Source(6, 24) + SourceIndex(0) -3 >Emitted(9, 28) Source(6, 27) + SourceIndex(0) -4 >Emitted(9, 32) Source(6, 31) + SourceIndex(0) -5 >Emitted(9, 37) Source(6, 36) + SourceIndex(0) -6 >Emitted(9, 39) Source(6, 38) + SourceIndex(0) -7 >Emitted(9, 40) Source(6, 39) + SourceIndex(0) ---- ->>> function m1_f1() { -1 >^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -1 >Emitted(10, 5) Source(7, 1) + SourceIndex(0) ---- ->>> return exports.m1_instance1; -1->^^^^^^^^ -2 > ^^^^^^ -3 > ^ -4 > ^^^^^^^^^^^^^^^^^^^^ -5 > ^ -1->export function m1_f1() { - > -2 > return -3 > -4 > m1_instance1 -5 > ; -1->Emitted(11, 9) Source(8, 5) + SourceIndex(0) name (m1_f1) -2 >Emitted(11, 15) Source(8, 11) + SourceIndex(0) name (m1_f1) -3 >Emitted(11, 16) Source(8, 12) + SourceIndex(0) name (m1_f1) -4 >Emitted(11, 36) Source(8, 24) + SourceIndex(0) name (m1_f1) -5 >Emitted(11, 37) Source(8, 25) + SourceIndex(0) name (m1_f1) ---- ->>> } -1 >^^^^ -2 > ^ -3 > ^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -2 > } -1 >Emitted(12, 5) Source(9, 1) + SourceIndex(0) name (m1_f1) -2 >Emitted(12, 6) Source(9, 2) + SourceIndex(0) name (m1_f1) ---- ->>> exports.m1_f1 = m1_f1; -1->^^^^ -2 > ^^^^^^^^^^^^^ -3 > ^^^^^^^^ -4 > ^ -1-> -2 > m1_f1 -3 > () { - > return m1_instance1; - > } -4 > -1->Emitted(13, 5) Source(7, 17) + SourceIndex(0) -2 >Emitted(13, 18) Source(7, 22) + SourceIndex(0) -3 >Emitted(13, 26) Source(9, 2) + SourceIndex(0) -4 >Emitted(13, 27) Source(9, 2) + SourceIndex(0) ---- ->>>}); ->>>//# sourceMappingURL=m1.js.map=================================================================== -JsFile: test.js -mapUrl: test.js.map -sourceRoot: /tests/cases/projects/outputdir_module_simple/src/ -sources: test.ts -=================================================================== -------------------------------------------------------------------- -emittedFile:test.js -sourceFile:test.ts -------------------------------------------------------------------- ->>>define(["require", "exports", "m1"], function (require, exports, m1) { ->>> exports.a1 = 10; -1 >^^^^ -2 > ^^^^^^^^^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^-> -1 >import m1 = require("m1"); - >export var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(2, 5) Source(2, 12) + SourceIndex(0) -2 >Emitted(2, 15) Source(2, 14) + SourceIndex(0) -3 >Emitted(2, 18) Source(2, 17) + SourceIndex(0) -4 >Emitted(2, 20) Source(2, 19) + SourceIndex(0) -5 >Emitted(2, 21) Source(2, 20) + SourceIndex(0) ---- ->>> var c1 = (function () { -1->^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^-> -1-> - > -1->Emitted(3, 5) Source(3, 1) + SourceIndex(0) ---- ->>> function c1() { -1->^^^^^^^^ -2 > ^^-> -1-> -1->Emitted(4, 9) Source(3, 1) + SourceIndex(0) name (c1) ---- ->>> } -1->^^^^^^^^ -2 > ^ -3 > ^^^^^^^^^^-> -1->export class c1 { - > public p1: number; - > -2 > } -1->Emitted(5, 9) Source(5, 1) + SourceIndex(0) name (c1.constructor) -2 >Emitted(5, 10) Source(5, 2) + SourceIndex(0) name (c1.constructor) ---- ->>> return c1; -1->^^^^^^^^ -2 > ^^^^^^^^^ -1-> -2 > } -1->Emitted(6, 9) Source(5, 1) + SourceIndex(0) name (c1) -2 >Emitted(6, 18) Source(5, 2) + SourceIndex(0) name (c1) ---- ->>> })(); -1 >^^^^ -2 > ^ -3 > -4 > ^^^^ -5 > ^^^^^^^^^^^^-> -1 > -2 > } -3 > -4 > export class c1 { - > public p1: number; - > } -1 >Emitted(7, 5) Source(5, 1) + SourceIndex(0) name (c1) -2 >Emitted(7, 6) Source(5, 2) + SourceIndex(0) name (c1) -3 >Emitted(7, 6) Source(3, 1) + SourceIndex(0) -4 >Emitted(7, 10) Source(5, 2) + SourceIndex(0) ---- ->>> exports.c1 = c1; -1->^^^^ -2 > ^^^^^^^^^^ -3 > ^^^^^ -4 > ^ -5 > ^^^^^^^^^^^^^^-> -1-> -2 > c1 -3 > { - > public p1: number; - > } -4 > -1->Emitted(8, 5) Source(3, 14) + SourceIndex(0) -2 >Emitted(8, 15) Source(3, 16) + SourceIndex(0) -3 >Emitted(8, 20) Source(5, 2) + SourceIndex(0) -4 >Emitted(8, 21) Source(5, 2) + SourceIndex(0) ---- ->>> exports.instance1 = new c1(); -1->^^^^ -2 > ^^^^^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^^^ -5 > ^^ -6 > ^^ -7 > ^ -1-> - > - >export var -2 > instance1 -3 > = -4 > new -5 > c1 -6 > () -7 > ; -1->Emitted(9, 5) Source(7, 12) + SourceIndex(0) -2 >Emitted(9, 22) Source(7, 21) + SourceIndex(0) -3 >Emitted(9, 25) Source(7, 24) + SourceIndex(0) -4 >Emitted(9, 29) Source(7, 28) + SourceIndex(0) -5 >Emitted(9, 31) Source(7, 30) + SourceIndex(0) -6 >Emitted(9, 33) Source(7, 32) + SourceIndex(0) -7 >Emitted(9, 34) Source(7, 33) + SourceIndex(0) ---- ->>> function f1() { -1 >^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -1 >Emitted(10, 5) Source(8, 1) + SourceIndex(0) ---- ->>> return exports.instance1; -1->^^^^^^^^ -2 > ^^^^^^ -3 > ^ -4 > ^^^^^^^^^^^^^^^^^ -5 > ^ -1->export function f1() { - > -2 > return -3 > -4 > instance1 -5 > ; -1->Emitted(11, 9) Source(9, 5) + SourceIndex(0) name (f1) -2 >Emitted(11, 15) Source(9, 11) + SourceIndex(0) name (f1) -3 >Emitted(11, 16) Source(9, 12) + SourceIndex(0) name (f1) -4 >Emitted(11, 33) Source(9, 21) + SourceIndex(0) name (f1) -5 >Emitted(11, 34) Source(9, 22) + SourceIndex(0) name (f1) ---- ->>> } -1 >^^^^ -2 > ^ -3 > ^^^^^^^^^^^^^^^^-> -1 > - > -2 > } -1 >Emitted(12, 5) Source(10, 1) + SourceIndex(0) name (f1) -2 >Emitted(12, 6) Source(10, 2) + SourceIndex(0) name (f1) ---- ->>> exports.f1 = f1; -1->^^^^ -2 > ^^^^^^^^^^ -3 > ^^^^^ -4 > ^ -5 > ^^^^^^^-> -1-> -2 > f1 -3 > () { - > return instance1; - > } -4 > -1->Emitted(13, 5) Source(8, 17) + SourceIndex(0) -2 >Emitted(13, 15) Source(8, 19) + SourceIndex(0) -3 >Emitted(13, 20) Source(10, 2) + SourceIndex(0) -4 >Emitted(13, 21) Source(10, 2) + SourceIndex(0) ---- ->>> exports.a2 = m1.m1_c1; -1->^^^^ -2 > ^^^^^^^^^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^ -7 > ^ -1-> - > - >export var -2 > a2 -3 > = -4 > m1 -5 > . -6 > m1_c1 -7 > ; -1->Emitted(14, 5) Source(12, 12) + SourceIndex(0) -2 >Emitted(14, 15) Source(12, 14) + SourceIndex(0) -3 >Emitted(14, 18) Source(12, 17) + SourceIndex(0) -4 >Emitted(14, 20) Source(12, 19) + SourceIndex(0) -5 >Emitted(14, 21) Source(12, 20) + SourceIndex(0) -6 >Emitted(14, 26) Source(12, 25) + SourceIndex(0) -7 >Emitted(14, 27) Source(12, 26) + SourceIndex(0) ---- ->>>}); ->>>//# sourceMappingURL=test.js.map=================================================================== JsFile: test.js mapUrl: test.js.map sourceRoot: /tests/cases/projects/outputdir_module_simple/src/ diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathModuleSimpleSpecifyOutputFile/amd/test.d.ts b/tests/baselines/reference/project/sourceRootAbsolutePathModuleSimpleSpecifyOutputFile/amd/test.d.ts deleted file mode 100644 index 250d2615a79..00000000000 --- a/tests/baselines/reference/project/sourceRootAbsolutePathModuleSimpleSpecifyOutputFile/amd/test.d.ts +++ /dev/null @@ -1,8 +0,0 @@ -import m1 = require("m1"); -export declare var a1: number; -export declare class c1 { - p1: number; -} -export declare var instance1: c1; -export declare function f1(): c1; -export declare var a2: typeof m1.m1_c1; diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathModuleSimpleSpecifyOutputFile/amd/test.js b/tests/baselines/reference/project/sourceRootAbsolutePathModuleSimpleSpecifyOutputFile/amd/test.js deleted file mode 100644 index 372f1052b89..00000000000 --- a/tests/baselines/reference/project/sourceRootAbsolutePathModuleSimpleSpecifyOutputFile/amd/test.js +++ /dev/null @@ -1,16 +0,0 @@ -define(["require", "exports", "m1"], function (require, exports, m1) { - exports.a1 = 10; - var c1 = (function () { - function c1() { - } - return c1; - })(); - exports.c1 = c1; - exports.instance1 = new c1(); - function f1() { - return exports.instance1; - } - exports.f1 = f1; - exports.a2 = m1.m1_c1; -}); -//# sourceMappingURL=test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathModuleSimpleSpecifyOutputFile/amd/test.js.map b/tests/baselines/reference/project/sourceRootAbsolutePathModuleSimpleSpecifyOutputFile/amd/test.js.map deleted file mode 100644 index 945ed0583ad..00000000000 --- a/tests/baselines/reference/project/sourceRootAbsolutePathModuleSimpleSpecifyOutputFile/amd/test.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"test.js","sourceRoot":"/tests/cases/projects/outputdir_module_simple/src/","sources":["test.ts"],"names":["c1","c1.constructor","f1"],"mappings":";IACW,UAAE,GAAG,EAAE,CAAC;IACnB;QAAAA;QAEAC,CAACA;QAADD,SAACA;IAADA,CAACA,AAFD,IAEC;IAFY,UAAE,KAEd,CAAA;IAEU,iBAAS,GAAG,IAAI,EAAE,EAAE,CAAC;IAChC;QACIE,MAAMA,CAACA,iBAASA,CAACA;IACrBA,CAACA;IAFe,UAAE,KAEjB,CAAA;IAEU,UAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathModuleSimpleSpecifyOutputFile/node/m1.d.ts b/tests/baselines/reference/project/sourceRootAbsolutePathModuleSimpleSpecifyOutputFile/node/m1.d.ts deleted file mode 100644 index 4a53b24b156..00000000000 --- a/tests/baselines/reference/project/sourceRootAbsolutePathModuleSimpleSpecifyOutputFile/node/m1.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -export declare var m1_a1: number; -export declare class m1_c1 { - m1_c1_p1: number; -} -export declare var m1_instance1: m1_c1; -export declare function m1_f1(): m1_c1; diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathModuleSimpleSpecifyOutputFile/node/m1.js b/tests/baselines/reference/project/sourceRootAbsolutePathModuleSimpleSpecifyOutputFile/node/m1.js deleted file mode 100644 index 1b4470e2b37..00000000000 --- a/tests/baselines/reference/project/sourceRootAbsolutePathModuleSimpleSpecifyOutputFile/node/m1.js +++ /dev/null @@ -1,13 +0,0 @@ -exports.m1_a1 = 10; -var m1_c1 = (function () { - function m1_c1() { - } - return m1_c1; -})(); -exports.m1_c1 = m1_c1; -exports.m1_instance1 = new m1_c1(); -function m1_f1() { - return exports.m1_instance1; -} -exports.m1_f1 = m1_f1; -//# sourceMappingURL=m1.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathModuleSimpleSpecifyOutputFile/node/m1.js.map b/tests/baselines/reference/project/sourceRootAbsolutePathModuleSimpleSpecifyOutputFile/node/m1.js.map deleted file mode 100644 index 9bf6e024b3f..00000000000 --- a/tests/baselines/reference/project/sourceRootAbsolutePathModuleSimpleSpecifyOutputFile/node/m1.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"m1.js","sourceRoot":"/tests/cases/projects/outputdir_module_simple/src/","sources":["m1.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1"],"mappings":"AAAW,aAAK,GAAG,EAAE,CAAC;AACtB;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAFY,aAAK,QAEjB,CAAA;AAEU,oBAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACIE,MAAMA,CAACA,oBAAYA,CAACA;AACxBA,CAACA;AAFe,aAAK,QAEpB,CAAA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathModuleSimpleSpecifyOutputFile/node/sourceRootAbsolutePathModuleSimpleSpecifyOutputFile.json b/tests/baselines/reference/project/sourceRootAbsolutePathModuleSimpleSpecifyOutputFile/node/sourceRootAbsolutePathModuleSimpleSpecifyOutputFile.json index e2621b2fa52..f9e2736f65a 100644 --- a/tests/baselines/reference/project/sourceRootAbsolutePathModuleSimpleSpecifyOutputFile/node/sourceRootAbsolutePathModuleSimpleSpecifyOutputFile.json +++ b/tests/baselines/reference/project/sourceRootAbsolutePathModuleSimpleSpecifyOutputFile/node/sourceRootAbsolutePathModuleSimpleSpecifyOutputFile.json @@ -16,12 +16,6 @@ "test.ts" ], "emittedFiles": [ - "m1.js.map", - "m1.js", - "m1.d.ts", - "test.js.map", - "test.js", - "test.d.ts", "bin/test.js.map", "bin/test.js", "bin/test.d.ts" diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathModuleSimpleSpecifyOutputFile/node/sourceRootAbsolutePathModuleSimpleSpecifyOutputFile.sourcemap.txt b/tests/baselines/reference/project/sourceRootAbsolutePathModuleSimpleSpecifyOutputFile/node/sourceRootAbsolutePathModuleSimpleSpecifyOutputFile.sourcemap.txt index 2da5935b483..0a161bb4886 100644 --- a/tests/baselines/reference/project/sourceRootAbsolutePathModuleSimpleSpecifyOutputFile/node/sourceRootAbsolutePathModuleSimpleSpecifyOutputFile.sourcemap.txt +++ b/tests/baselines/reference/project/sourceRootAbsolutePathModuleSimpleSpecifyOutputFile/node/sourceRootAbsolutePathModuleSimpleSpecifyOutputFile.sourcemap.txt @@ -1,396 +1,4 @@ =================================================================== -JsFile: m1.js -mapUrl: m1.js.map -sourceRoot: /tests/cases/projects/outputdir_module_simple/src/ -sources: m1.ts -=================================================================== -------------------------------------------------------------------- -emittedFile:m1.js -sourceFile:m1.ts -------------------------------------------------------------------- ->>>exports.m1_a1 = 10; -1 > -2 >^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^-> -1 >export var -2 >m1_a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(1, 1) Source(1, 12) + SourceIndex(0) -2 >Emitted(1, 14) Source(1, 17) + SourceIndex(0) -3 >Emitted(1, 17) Source(1, 20) + SourceIndex(0) -4 >Emitted(1, 19) Source(1, 22) + SourceIndex(0) -5 >Emitted(1, 20) Source(1, 23) + SourceIndex(0) ---- ->>>var m1_c1 = (function () { -1-> -2 >^^^^^^^^^^^^^^^^^^^^^^^-> -1-> - > -1->Emitted(2, 1) Source(2, 1) + SourceIndex(0) ---- ->>> function m1_c1() { -1->^^^^ -2 > ^^-> -1-> -1->Emitted(3, 5) Source(2, 1) + SourceIndex(0) name (m1_c1) ---- ->>> } -1->^^^^ -2 > ^ -3 > ^^^^^^^^^^^^^-> -1->export class m1_c1 { - > public m1_c1_p1: number; - > -2 > } -1->Emitted(4, 5) Source(4, 1) + SourceIndex(0) name (m1_c1.constructor) -2 >Emitted(4, 6) Source(4, 2) + SourceIndex(0) name (m1_c1.constructor) ---- ->>> return m1_c1; -1->^^^^ -2 > ^^^^^^^^^^^^ -1-> -2 > } -1->Emitted(5, 5) Source(4, 1) + SourceIndex(0) name (m1_c1) -2 >Emitted(5, 17) Source(4, 2) + SourceIndex(0) name (m1_c1) ---- ->>>})(); -1 > -2 >^ -3 > -4 > ^^^^ -5 > ^^^^^^^^^^^^^^^^^^-> -1 > -2 >} -3 > -4 > export class m1_c1 { - > public m1_c1_p1: number; - > } -1 >Emitted(6, 1) Source(4, 1) + SourceIndex(0) name (m1_c1) -2 >Emitted(6, 2) Source(4, 2) + SourceIndex(0) name (m1_c1) -3 >Emitted(6, 2) Source(2, 1) + SourceIndex(0) -4 >Emitted(6, 6) Source(4, 2) + SourceIndex(0) ---- ->>>exports.m1_c1 = m1_c1; -1-> -2 >^^^^^^^^^^^^^ -3 > ^^^^^^^^ -4 > ^ -5 > ^^^^^^^^^^^^^^-> -1-> -2 >m1_c1 -3 > { - > public m1_c1_p1: number; - > } -4 > -1->Emitted(7, 1) Source(2, 14) + SourceIndex(0) -2 >Emitted(7, 14) Source(2, 19) + SourceIndex(0) -3 >Emitted(7, 22) Source(4, 2) + SourceIndex(0) -4 >Emitted(7, 23) Source(4, 2) + SourceIndex(0) ---- ->>>exports.m1_instance1 = new m1_c1(); -1-> -2 >^^^^^^^^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^^^ -5 > ^^^^^ -6 > ^^ -7 > ^ -1-> - > - >export var -2 >m1_instance1 -3 > = -4 > new -5 > m1_c1 -6 > () -7 > ; -1->Emitted(8, 1) Source(6, 12) + SourceIndex(0) -2 >Emitted(8, 21) Source(6, 24) + SourceIndex(0) -3 >Emitted(8, 24) Source(6, 27) + SourceIndex(0) -4 >Emitted(8, 28) Source(6, 31) + SourceIndex(0) -5 >Emitted(8, 33) Source(6, 36) + SourceIndex(0) -6 >Emitted(8, 35) Source(6, 38) + SourceIndex(0) -7 >Emitted(8, 36) Source(6, 39) + SourceIndex(0) ---- ->>>function m1_f1() { -1 > -2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -1 >Emitted(9, 1) Source(7, 1) + SourceIndex(0) ---- ->>> return exports.m1_instance1; -1->^^^^ -2 > ^^^^^^ -3 > ^ -4 > ^^^^^^^^^^^^^^^^^^^^ -5 > ^ -1->export function m1_f1() { - > -2 > return -3 > -4 > m1_instance1 -5 > ; -1->Emitted(10, 5) Source(8, 5) + SourceIndex(0) name (m1_f1) -2 >Emitted(10, 11) Source(8, 11) + SourceIndex(0) name (m1_f1) -3 >Emitted(10, 12) Source(8, 12) + SourceIndex(0) name (m1_f1) -4 >Emitted(10, 32) Source(8, 24) + SourceIndex(0) name (m1_f1) -5 >Emitted(10, 33) Source(8, 25) + SourceIndex(0) name (m1_f1) ---- ->>>} -1 > -2 >^ -3 > ^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -2 >} -1 >Emitted(11, 1) Source(9, 1) + SourceIndex(0) name (m1_f1) -2 >Emitted(11, 2) Source(9, 2) + SourceIndex(0) name (m1_f1) ---- ->>>exports.m1_f1 = m1_f1; -1-> -2 >^^^^^^^^^^^^^ -3 > ^^^^^^^^ -4 > ^ -5 > ^^^^^^^-> -1-> -2 >m1_f1 -3 > () { - > return m1_instance1; - > } -4 > -1->Emitted(12, 1) Source(7, 17) + SourceIndex(0) -2 >Emitted(12, 14) Source(7, 22) + SourceIndex(0) -3 >Emitted(12, 22) Source(9, 2) + SourceIndex(0) -4 >Emitted(12, 23) Source(9, 2) + SourceIndex(0) ---- ->>>//# sourceMappingURL=m1.js.map=================================================================== -JsFile: test.js -mapUrl: test.js.map -sourceRoot: /tests/cases/projects/outputdir_module_simple/src/ -sources: test.ts -=================================================================== -------------------------------------------------------------------- -emittedFile:test.js -sourceFile:test.ts -------------------------------------------------------------------- ->>>var m1 = require("m1"); -1 > -2 >^^^^ -3 > ^^ -4 > ^^^^^^^^^^^ -5 > ^^^^ -6 > ^ -7 > ^ -1 > -2 >import -3 > m1 -4 > = require( -5 > "m1" -6 > ) -7 > ; -1 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) -2 >Emitted(1, 5) Source(1, 8) + SourceIndex(0) -3 >Emitted(1, 7) Source(1, 10) + SourceIndex(0) -4 >Emitted(1, 18) Source(1, 21) + SourceIndex(0) -5 >Emitted(1, 22) Source(1, 25) + SourceIndex(0) -6 >Emitted(1, 23) Source(1, 26) + SourceIndex(0) -7 >Emitted(1, 24) Source(1, 27) + SourceIndex(0) ---- ->>>exports.a1 = 10; -1 > -2 >^^^^^^^^^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^-> -1 > - >export var -2 >a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(2, 1) Source(2, 12) + SourceIndex(0) -2 >Emitted(2, 11) Source(2, 14) + SourceIndex(0) -3 >Emitted(2, 14) Source(2, 17) + SourceIndex(0) -4 >Emitted(2, 16) Source(2, 19) + SourceIndex(0) -5 >Emitted(2, 17) Source(2, 20) + SourceIndex(0) ---- ->>>var c1 = (function () { -1-> -2 >^^^^^^^^^^^^^^^^^^^^-> -1-> - > -1->Emitted(3, 1) Source(3, 1) + SourceIndex(0) ---- ->>> function c1() { -1->^^^^ -2 > ^^-> -1-> -1->Emitted(4, 5) Source(3, 1) + SourceIndex(0) name (c1) ---- ->>> } -1->^^^^ -2 > ^ -3 > ^^^^^^^^^^-> -1->export class c1 { - > public p1: number; - > -2 > } -1->Emitted(5, 5) Source(5, 1) + SourceIndex(0) name (c1.constructor) -2 >Emitted(5, 6) Source(5, 2) + SourceIndex(0) name (c1.constructor) ---- ->>> return c1; -1->^^^^ -2 > ^^^^^^^^^ -1-> -2 > } -1->Emitted(6, 5) Source(5, 1) + SourceIndex(0) name (c1) -2 >Emitted(6, 14) Source(5, 2) + SourceIndex(0) name (c1) ---- ->>>})(); -1 > -2 >^ -3 > -4 > ^^^^ -5 > ^^^^^^^^^^^^-> -1 > -2 >} -3 > -4 > export class c1 { - > public p1: number; - > } -1 >Emitted(7, 1) Source(5, 1) + SourceIndex(0) name (c1) -2 >Emitted(7, 2) Source(5, 2) + SourceIndex(0) name (c1) -3 >Emitted(7, 2) Source(3, 1) + SourceIndex(0) -4 >Emitted(7, 6) Source(5, 2) + SourceIndex(0) ---- ->>>exports.c1 = c1; -1-> -2 >^^^^^^^^^^ -3 > ^^^^^ -4 > ^ -5 > ^^^^^^^^^^^^^^-> -1-> -2 >c1 -3 > { - > public p1: number; - > } -4 > -1->Emitted(8, 1) Source(3, 14) + SourceIndex(0) -2 >Emitted(8, 11) Source(3, 16) + SourceIndex(0) -3 >Emitted(8, 16) Source(5, 2) + SourceIndex(0) -4 >Emitted(8, 17) Source(5, 2) + SourceIndex(0) ---- ->>>exports.instance1 = new c1(); -1-> -2 >^^^^^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^^^ -5 > ^^ -6 > ^^ -7 > ^ -1-> - > - >export var -2 >instance1 -3 > = -4 > new -5 > c1 -6 > () -7 > ; -1->Emitted(9, 1) Source(7, 12) + SourceIndex(0) -2 >Emitted(9, 18) Source(7, 21) + SourceIndex(0) -3 >Emitted(9, 21) Source(7, 24) + SourceIndex(0) -4 >Emitted(9, 25) Source(7, 28) + SourceIndex(0) -5 >Emitted(9, 27) Source(7, 30) + SourceIndex(0) -6 >Emitted(9, 29) Source(7, 32) + SourceIndex(0) -7 >Emitted(9, 30) Source(7, 33) + SourceIndex(0) ---- ->>>function f1() { -1 > -2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -1 >Emitted(10, 1) Source(8, 1) + SourceIndex(0) ---- ->>> return exports.instance1; -1->^^^^ -2 > ^^^^^^ -3 > ^ -4 > ^^^^^^^^^^^^^^^^^ -5 > ^ -1->export function f1() { - > -2 > return -3 > -4 > instance1 -5 > ; -1->Emitted(11, 5) Source(9, 5) + SourceIndex(0) name (f1) -2 >Emitted(11, 11) Source(9, 11) + SourceIndex(0) name (f1) -3 >Emitted(11, 12) Source(9, 12) + SourceIndex(0) name (f1) -4 >Emitted(11, 29) Source(9, 21) + SourceIndex(0) name (f1) -5 >Emitted(11, 30) Source(9, 22) + SourceIndex(0) name (f1) ---- ->>>} -1 > -2 >^ -3 > ^^^^^^^^^^^^^^^^-> -1 > - > -2 >} -1 >Emitted(12, 1) Source(10, 1) + SourceIndex(0) name (f1) -2 >Emitted(12, 2) Source(10, 2) + SourceIndex(0) name (f1) ---- ->>>exports.f1 = f1; -1-> -2 >^^^^^^^^^^ -3 > ^^^^^ -4 > ^ -5 > ^^^^^^^-> -1-> -2 >f1 -3 > () { - > return instance1; - > } -4 > -1->Emitted(13, 1) Source(8, 17) + SourceIndex(0) -2 >Emitted(13, 11) Source(8, 19) + SourceIndex(0) -3 >Emitted(13, 16) Source(10, 2) + SourceIndex(0) -4 >Emitted(13, 17) Source(10, 2) + SourceIndex(0) ---- ->>>exports.a2 = m1.m1_c1; -1-> -2 >^^^^^^^^^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^ -7 > ^ -8 > ^^^^^^^^^-> -1-> - > - >export var -2 >a2 -3 > = -4 > m1 -5 > . -6 > m1_c1 -7 > ; -1->Emitted(14, 1) Source(12, 12) + SourceIndex(0) -2 >Emitted(14, 11) Source(12, 14) + SourceIndex(0) -3 >Emitted(14, 14) Source(12, 17) + SourceIndex(0) -4 >Emitted(14, 16) Source(12, 19) + SourceIndex(0) -5 >Emitted(14, 17) Source(12, 20) + SourceIndex(0) -6 >Emitted(14, 22) Source(12, 25) + SourceIndex(0) -7 >Emitted(14, 23) Source(12, 26) + SourceIndex(0) ---- ->>>//# sourceMappingURL=test.js.map=================================================================== JsFile: test.js mapUrl: test.js.map sourceRoot: /tests/cases/projects/outputdir_module_simple/src/ diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathModuleSimpleSpecifyOutputFile/node/test.d.ts b/tests/baselines/reference/project/sourceRootAbsolutePathModuleSimpleSpecifyOutputFile/node/test.d.ts deleted file mode 100644 index 250d2615a79..00000000000 --- a/tests/baselines/reference/project/sourceRootAbsolutePathModuleSimpleSpecifyOutputFile/node/test.d.ts +++ /dev/null @@ -1,8 +0,0 @@ -import m1 = require("m1"); -export declare var a1: number; -export declare class c1 { - p1: number; -} -export declare var instance1: c1; -export declare function f1(): c1; -export declare var a2: typeof m1.m1_c1; diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathModuleSimpleSpecifyOutputFile/node/test.js b/tests/baselines/reference/project/sourceRootAbsolutePathModuleSimpleSpecifyOutputFile/node/test.js deleted file mode 100644 index c2e7dfa443b..00000000000 --- a/tests/baselines/reference/project/sourceRootAbsolutePathModuleSimpleSpecifyOutputFile/node/test.js +++ /dev/null @@ -1,15 +0,0 @@ -var m1 = require("m1"); -exports.a1 = 10; -var c1 = (function () { - function c1() { - } - return c1; -})(); -exports.c1 = c1; -exports.instance1 = new c1(); -function f1() { - return exports.instance1; -} -exports.f1 = f1; -exports.a2 = m1.m1_c1; -//# sourceMappingURL=test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathModuleSimpleSpecifyOutputFile/node/test.js.map b/tests/baselines/reference/project/sourceRootAbsolutePathModuleSimpleSpecifyOutputFile/node/test.js.map deleted file mode 100644 index a7792ef5242..00000000000 --- a/tests/baselines/reference/project/sourceRootAbsolutePathModuleSimpleSpecifyOutputFile/node/test.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"test.js","sourceRoot":"/tests/cases/projects/outputdir_module_simple/src/","sources":["test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AAAA,IAAO,EAAE,WAAW,IAAI,CAAC,CAAC;AACf,UAAE,GAAG,EAAE,CAAC;AACnB;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAFY,UAAE,KAEd,CAAA;AAEU,iBAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AAChC;IACIE,MAAMA,CAACA,iBAASA,CAACA;AACrBA,CAACA;AAFe,UAAE,KAEjB,CAAA;AAEU,UAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathModuleSubfolderSpecifyOutputFile/amd/ref/m1.d.ts b/tests/baselines/reference/project/sourceRootAbsolutePathModuleSubfolderSpecifyOutputFile/amd/ref/m1.d.ts deleted file mode 100644 index 4a53b24b156..00000000000 --- a/tests/baselines/reference/project/sourceRootAbsolutePathModuleSubfolderSpecifyOutputFile/amd/ref/m1.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -export declare var m1_a1: number; -export declare class m1_c1 { - m1_c1_p1: number; -} -export declare var m1_instance1: m1_c1; -export declare function m1_f1(): m1_c1; diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathModuleSubfolderSpecifyOutputFile/amd/ref/m1.js b/tests/baselines/reference/project/sourceRootAbsolutePathModuleSubfolderSpecifyOutputFile/amd/ref/m1.js deleted file mode 100644 index bbaba444ba2..00000000000 --- a/tests/baselines/reference/project/sourceRootAbsolutePathModuleSubfolderSpecifyOutputFile/amd/ref/m1.js +++ /dev/null @@ -1,15 +0,0 @@ -define(["require", "exports"], function (require, exports) { - exports.m1_a1 = 10; - var m1_c1 = (function () { - function m1_c1() { - } - return m1_c1; - })(); - exports.m1_c1 = m1_c1; - exports.m1_instance1 = new m1_c1(); - function m1_f1() { - return exports.m1_instance1; - } - exports.m1_f1 = m1_f1; -}); -//# sourceMappingURL=m1.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathModuleSubfolderSpecifyOutputFile/amd/ref/m1.js.map b/tests/baselines/reference/project/sourceRootAbsolutePathModuleSubfolderSpecifyOutputFile/amd/ref/m1.js.map deleted file mode 100644 index 6f750f89857..00000000000 --- a/tests/baselines/reference/project/sourceRootAbsolutePathModuleSubfolderSpecifyOutputFile/amd/ref/m1.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"m1.js","sourceRoot":"/tests/cases/projects/outputdir_module_subfolder/src/","sources":["ref/m1.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1"],"mappings":";IAAW,aAAK,GAAG,EAAE,CAAC;IACtB;QAAAA;QAEAC,CAACA;QAADD,YAACA;IAADA,CAACA,AAFD,IAEC;IAFY,aAAK,QAEjB,CAAA;IAEU,oBAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACIE,MAAMA,CAACA,oBAAYA,CAACA;IACxBA,CAACA;IAFe,aAAK,QAEpB,CAAA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathModuleSubfolderSpecifyOutputFile/amd/sourceRootAbsolutePathModuleSubfolderSpecifyOutputFile.json b/tests/baselines/reference/project/sourceRootAbsolutePathModuleSubfolderSpecifyOutputFile/amd/sourceRootAbsolutePathModuleSubfolderSpecifyOutputFile.json index a43e0f69172..50dc5aaf60f 100644 --- a/tests/baselines/reference/project/sourceRootAbsolutePathModuleSubfolderSpecifyOutputFile/amd/sourceRootAbsolutePathModuleSubfolderSpecifyOutputFile.json +++ b/tests/baselines/reference/project/sourceRootAbsolutePathModuleSubfolderSpecifyOutputFile/amd/sourceRootAbsolutePathModuleSubfolderSpecifyOutputFile.json @@ -16,12 +16,6 @@ "test.ts" ], "emittedFiles": [ - "ref/m1.js.map", - "ref/m1.js", - "ref/m1.d.ts", - "test.js.map", - "test.js", - "test.d.ts", "bin/test.js.map", "bin/test.js", "bin/test.d.ts" diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathModuleSubfolderSpecifyOutputFile/amd/sourceRootAbsolutePathModuleSubfolderSpecifyOutputFile.sourcemap.txt b/tests/baselines/reference/project/sourceRootAbsolutePathModuleSubfolderSpecifyOutputFile/amd/sourceRootAbsolutePathModuleSubfolderSpecifyOutputFile.sourcemap.txt index 15269d7fb80..af6c2b21fdc 100644 --- a/tests/baselines/reference/project/sourceRootAbsolutePathModuleSubfolderSpecifyOutputFile/amd/sourceRootAbsolutePathModuleSubfolderSpecifyOutputFile.sourcemap.txt +++ b/tests/baselines/reference/project/sourceRootAbsolutePathModuleSubfolderSpecifyOutputFile/amd/sourceRootAbsolutePathModuleSubfolderSpecifyOutputFile.sourcemap.txt @@ -1,375 +1,4 @@ =================================================================== -JsFile: m1.js -mapUrl: m1.js.map -sourceRoot: /tests/cases/projects/outputdir_module_subfolder/src/ -sources: ref/m1.ts -=================================================================== -------------------------------------------------------------------- -emittedFile:ref/m1.js -sourceFile:ref/m1.ts -------------------------------------------------------------------- ->>>define(["require", "exports"], function (require, exports) { ->>> exports.m1_a1 = 10; -1 >^^^^ -2 > ^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^-> -1 >export var -2 > m1_a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(2, 5) Source(1, 12) + SourceIndex(0) -2 >Emitted(2, 18) Source(1, 17) + SourceIndex(0) -3 >Emitted(2, 21) Source(1, 20) + SourceIndex(0) -4 >Emitted(2, 23) Source(1, 22) + SourceIndex(0) -5 >Emitted(2, 24) Source(1, 23) + SourceIndex(0) ---- ->>> var m1_c1 = (function () { -1->^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^^^^-> -1-> - > -1->Emitted(3, 5) Source(2, 1) + SourceIndex(0) ---- ->>> function m1_c1() { -1->^^^^^^^^ -2 > ^^-> -1-> -1->Emitted(4, 9) Source(2, 1) + SourceIndex(0) name (m1_c1) ---- ->>> } -1->^^^^^^^^ -2 > ^ -3 > ^^^^^^^^^^^^^-> -1->export class m1_c1 { - > public m1_c1_p1: number; - > -2 > } -1->Emitted(5, 9) Source(4, 1) + SourceIndex(0) name (m1_c1.constructor) -2 >Emitted(5, 10) Source(4, 2) + SourceIndex(0) name (m1_c1.constructor) ---- ->>> return m1_c1; -1->^^^^^^^^ -2 > ^^^^^^^^^^^^ -1-> -2 > } -1->Emitted(6, 9) Source(4, 1) + SourceIndex(0) name (m1_c1) -2 >Emitted(6, 21) Source(4, 2) + SourceIndex(0) name (m1_c1) ---- ->>> })(); -1 >^^^^ -2 > ^ -3 > -4 > ^^^^ -5 > ^^^^^^^^^^^^^^^^^^-> -1 > -2 > } -3 > -4 > export class m1_c1 { - > public m1_c1_p1: number; - > } -1 >Emitted(7, 5) Source(4, 1) + SourceIndex(0) name (m1_c1) -2 >Emitted(7, 6) Source(4, 2) + SourceIndex(0) name (m1_c1) -3 >Emitted(7, 6) Source(2, 1) + SourceIndex(0) -4 >Emitted(7, 10) Source(4, 2) + SourceIndex(0) ---- ->>> exports.m1_c1 = m1_c1; -1->^^^^ -2 > ^^^^^^^^^^^^^ -3 > ^^^^^^^^ -4 > ^ -5 > ^^^^^^^^^^^^^^-> -1-> -2 > m1_c1 -3 > { - > public m1_c1_p1: number; - > } -4 > -1->Emitted(8, 5) Source(2, 14) + SourceIndex(0) -2 >Emitted(8, 18) Source(2, 19) + SourceIndex(0) -3 >Emitted(8, 26) Source(4, 2) + SourceIndex(0) -4 >Emitted(8, 27) Source(4, 2) + SourceIndex(0) ---- ->>> exports.m1_instance1 = new m1_c1(); -1->^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^^^ -5 > ^^^^^ -6 > ^^ -7 > ^ -1-> - > - >export var -2 > m1_instance1 -3 > = -4 > new -5 > m1_c1 -6 > () -7 > ; -1->Emitted(9, 5) Source(6, 12) + SourceIndex(0) -2 >Emitted(9, 25) Source(6, 24) + SourceIndex(0) -3 >Emitted(9, 28) Source(6, 27) + SourceIndex(0) -4 >Emitted(9, 32) Source(6, 31) + SourceIndex(0) -5 >Emitted(9, 37) Source(6, 36) + SourceIndex(0) -6 >Emitted(9, 39) Source(6, 38) + SourceIndex(0) -7 >Emitted(9, 40) Source(6, 39) + SourceIndex(0) ---- ->>> function m1_f1() { -1 >^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -1 >Emitted(10, 5) Source(7, 1) + SourceIndex(0) ---- ->>> return exports.m1_instance1; -1->^^^^^^^^ -2 > ^^^^^^ -3 > ^ -4 > ^^^^^^^^^^^^^^^^^^^^ -5 > ^ -1->export function m1_f1() { - > -2 > return -3 > -4 > m1_instance1 -5 > ; -1->Emitted(11, 9) Source(8, 5) + SourceIndex(0) name (m1_f1) -2 >Emitted(11, 15) Source(8, 11) + SourceIndex(0) name (m1_f1) -3 >Emitted(11, 16) Source(8, 12) + SourceIndex(0) name (m1_f1) -4 >Emitted(11, 36) Source(8, 24) + SourceIndex(0) name (m1_f1) -5 >Emitted(11, 37) Source(8, 25) + SourceIndex(0) name (m1_f1) ---- ->>> } -1 >^^^^ -2 > ^ -3 > ^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -2 > } -1 >Emitted(12, 5) Source(9, 1) + SourceIndex(0) name (m1_f1) -2 >Emitted(12, 6) Source(9, 2) + SourceIndex(0) name (m1_f1) ---- ->>> exports.m1_f1 = m1_f1; -1->^^^^ -2 > ^^^^^^^^^^^^^ -3 > ^^^^^^^^ -4 > ^ -1-> -2 > m1_f1 -3 > () { - > return m1_instance1; - > } -4 > -1->Emitted(13, 5) Source(7, 17) + SourceIndex(0) -2 >Emitted(13, 18) Source(7, 22) + SourceIndex(0) -3 >Emitted(13, 26) Source(9, 2) + SourceIndex(0) -4 >Emitted(13, 27) Source(9, 2) + SourceIndex(0) ---- ->>>}); ->>>//# sourceMappingURL=m1.js.map=================================================================== -JsFile: test.js -mapUrl: test.js.map -sourceRoot: /tests/cases/projects/outputdir_module_subfolder/src/ -sources: test.ts -=================================================================== -------------------------------------------------------------------- -emittedFile:test.js -sourceFile:test.ts -------------------------------------------------------------------- ->>>define(["require", "exports", "ref/m1"], function (require, exports, m1) { ->>> exports.a1 = 10; -1 >^^^^ -2 > ^^^^^^^^^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^-> -1 >import m1 = require("ref/m1"); - >export var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(2, 5) Source(2, 12) + SourceIndex(0) -2 >Emitted(2, 15) Source(2, 14) + SourceIndex(0) -3 >Emitted(2, 18) Source(2, 17) + SourceIndex(0) -4 >Emitted(2, 20) Source(2, 19) + SourceIndex(0) -5 >Emitted(2, 21) Source(2, 20) + SourceIndex(0) ---- ->>> var c1 = (function () { -1->^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^-> -1-> - > -1->Emitted(3, 5) Source(3, 1) + SourceIndex(0) ---- ->>> function c1() { -1->^^^^^^^^ -2 > ^^-> -1-> -1->Emitted(4, 9) Source(3, 1) + SourceIndex(0) name (c1) ---- ->>> } -1->^^^^^^^^ -2 > ^ -3 > ^^^^^^^^^^-> -1->export class c1 { - > public p1: number; - > -2 > } -1->Emitted(5, 9) Source(5, 1) + SourceIndex(0) name (c1.constructor) -2 >Emitted(5, 10) Source(5, 2) + SourceIndex(0) name (c1.constructor) ---- ->>> return c1; -1->^^^^^^^^ -2 > ^^^^^^^^^ -1-> -2 > } -1->Emitted(6, 9) Source(5, 1) + SourceIndex(0) name (c1) -2 >Emitted(6, 18) Source(5, 2) + SourceIndex(0) name (c1) ---- ->>> })(); -1 >^^^^ -2 > ^ -3 > -4 > ^^^^ -5 > ^^^^^^^^^^^^-> -1 > -2 > } -3 > -4 > export class c1 { - > public p1: number; - > } -1 >Emitted(7, 5) Source(5, 1) + SourceIndex(0) name (c1) -2 >Emitted(7, 6) Source(5, 2) + SourceIndex(0) name (c1) -3 >Emitted(7, 6) Source(3, 1) + SourceIndex(0) -4 >Emitted(7, 10) Source(5, 2) + SourceIndex(0) ---- ->>> exports.c1 = c1; -1->^^^^ -2 > ^^^^^^^^^^ -3 > ^^^^^ -4 > ^ -5 > ^^^^^^^^^^^^^^-> -1-> -2 > c1 -3 > { - > public p1: number; - > } -4 > -1->Emitted(8, 5) Source(3, 14) + SourceIndex(0) -2 >Emitted(8, 15) Source(3, 16) + SourceIndex(0) -3 >Emitted(8, 20) Source(5, 2) + SourceIndex(0) -4 >Emitted(8, 21) Source(5, 2) + SourceIndex(0) ---- ->>> exports.instance1 = new c1(); -1->^^^^ -2 > ^^^^^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^^^ -5 > ^^ -6 > ^^ -7 > ^ -1-> - > - >export var -2 > instance1 -3 > = -4 > new -5 > c1 -6 > () -7 > ; -1->Emitted(9, 5) Source(7, 12) + SourceIndex(0) -2 >Emitted(9, 22) Source(7, 21) + SourceIndex(0) -3 >Emitted(9, 25) Source(7, 24) + SourceIndex(0) -4 >Emitted(9, 29) Source(7, 28) + SourceIndex(0) -5 >Emitted(9, 31) Source(7, 30) + SourceIndex(0) -6 >Emitted(9, 33) Source(7, 32) + SourceIndex(0) -7 >Emitted(9, 34) Source(7, 33) + SourceIndex(0) ---- ->>> function f1() { -1 >^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -1 >Emitted(10, 5) Source(8, 1) + SourceIndex(0) ---- ->>> return exports.instance1; -1->^^^^^^^^ -2 > ^^^^^^ -3 > ^ -4 > ^^^^^^^^^^^^^^^^^ -5 > ^ -1->export function f1() { - > -2 > return -3 > -4 > instance1 -5 > ; -1->Emitted(11, 9) Source(9, 5) + SourceIndex(0) name (f1) -2 >Emitted(11, 15) Source(9, 11) + SourceIndex(0) name (f1) -3 >Emitted(11, 16) Source(9, 12) + SourceIndex(0) name (f1) -4 >Emitted(11, 33) Source(9, 21) + SourceIndex(0) name (f1) -5 >Emitted(11, 34) Source(9, 22) + SourceIndex(0) name (f1) ---- ->>> } -1 >^^^^ -2 > ^ -3 > ^^^^^^^^^^^^^^^^-> -1 > - > -2 > } -1 >Emitted(12, 5) Source(10, 1) + SourceIndex(0) name (f1) -2 >Emitted(12, 6) Source(10, 2) + SourceIndex(0) name (f1) ---- ->>> exports.f1 = f1; -1->^^^^ -2 > ^^^^^^^^^^ -3 > ^^^^^ -4 > ^ -5 > ^^^^^^^-> -1-> -2 > f1 -3 > () { - > return instance1; - > } -4 > -1->Emitted(13, 5) Source(8, 17) + SourceIndex(0) -2 >Emitted(13, 15) Source(8, 19) + SourceIndex(0) -3 >Emitted(13, 20) Source(10, 2) + SourceIndex(0) -4 >Emitted(13, 21) Source(10, 2) + SourceIndex(0) ---- ->>> exports.a2 = m1.m1_c1; -1->^^^^ -2 > ^^^^^^^^^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^ -7 > ^ -1-> - > - >export var -2 > a2 -3 > = -4 > m1 -5 > . -6 > m1_c1 -7 > ; -1->Emitted(14, 5) Source(12, 12) + SourceIndex(0) -2 >Emitted(14, 15) Source(12, 14) + SourceIndex(0) -3 >Emitted(14, 18) Source(12, 17) + SourceIndex(0) -4 >Emitted(14, 20) Source(12, 19) + SourceIndex(0) -5 >Emitted(14, 21) Source(12, 20) + SourceIndex(0) -6 >Emitted(14, 26) Source(12, 25) + SourceIndex(0) -7 >Emitted(14, 27) Source(12, 26) + SourceIndex(0) ---- ->>>}); ->>>//# sourceMappingURL=test.js.map=================================================================== JsFile: test.js mapUrl: test.js.map sourceRoot: /tests/cases/projects/outputdir_module_subfolder/src/ diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathModuleSubfolderSpecifyOutputFile/amd/test.d.ts b/tests/baselines/reference/project/sourceRootAbsolutePathModuleSubfolderSpecifyOutputFile/amd/test.d.ts deleted file mode 100644 index a61d8541048..00000000000 --- a/tests/baselines/reference/project/sourceRootAbsolutePathModuleSubfolderSpecifyOutputFile/amd/test.d.ts +++ /dev/null @@ -1,8 +0,0 @@ -import m1 = require("ref/m1"); -export declare var a1: number; -export declare class c1 { - p1: number; -} -export declare var instance1: c1; -export declare function f1(): c1; -export declare var a2: typeof m1.m1_c1; diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathModuleSubfolderSpecifyOutputFile/amd/test.js b/tests/baselines/reference/project/sourceRootAbsolutePathModuleSubfolderSpecifyOutputFile/amd/test.js deleted file mode 100644 index 6c8aeb3190b..00000000000 --- a/tests/baselines/reference/project/sourceRootAbsolutePathModuleSubfolderSpecifyOutputFile/amd/test.js +++ /dev/null @@ -1,16 +0,0 @@ -define(["require", "exports", "ref/m1"], function (require, exports, m1) { - exports.a1 = 10; - var c1 = (function () { - function c1() { - } - return c1; - })(); - exports.c1 = c1; - exports.instance1 = new c1(); - function f1() { - return exports.instance1; - } - exports.f1 = f1; - exports.a2 = m1.m1_c1; -}); -//# sourceMappingURL=test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathModuleSubfolderSpecifyOutputFile/amd/test.js.map b/tests/baselines/reference/project/sourceRootAbsolutePathModuleSubfolderSpecifyOutputFile/amd/test.js.map deleted file mode 100644 index f65cfa554d1..00000000000 --- a/tests/baselines/reference/project/sourceRootAbsolutePathModuleSubfolderSpecifyOutputFile/amd/test.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"test.js","sourceRoot":"/tests/cases/projects/outputdir_module_subfolder/src/","sources":["test.ts"],"names":["c1","c1.constructor","f1"],"mappings":";IACW,UAAE,GAAG,EAAE,CAAC;IACnB;QAAAA;QAEAC,CAACA;QAADD,SAACA;IAADA,CAACA,AAFD,IAEC;IAFY,UAAE,KAEd,CAAA;IAEU,iBAAS,GAAG,IAAI,EAAE,EAAE,CAAC;IAChC;QACIE,MAAMA,CAACA,iBAASA,CAACA;IACrBA,CAACA;IAFe,UAAE,KAEjB,CAAA;IAEU,UAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathModuleSubfolderSpecifyOutputFile/node/ref/m1.d.ts b/tests/baselines/reference/project/sourceRootAbsolutePathModuleSubfolderSpecifyOutputFile/node/ref/m1.d.ts deleted file mode 100644 index 4a53b24b156..00000000000 --- a/tests/baselines/reference/project/sourceRootAbsolutePathModuleSubfolderSpecifyOutputFile/node/ref/m1.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -export declare var m1_a1: number; -export declare class m1_c1 { - m1_c1_p1: number; -} -export declare var m1_instance1: m1_c1; -export declare function m1_f1(): m1_c1; diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathModuleSubfolderSpecifyOutputFile/node/ref/m1.js b/tests/baselines/reference/project/sourceRootAbsolutePathModuleSubfolderSpecifyOutputFile/node/ref/m1.js deleted file mode 100644 index 1b4470e2b37..00000000000 --- a/tests/baselines/reference/project/sourceRootAbsolutePathModuleSubfolderSpecifyOutputFile/node/ref/m1.js +++ /dev/null @@ -1,13 +0,0 @@ -exports.m1_a1 = 10; -var m1_c1 = (function () { - function m1_c1() { - } - return m1_c1; -})(); -exports.m1_c1 = m1_c1; -exports.m1_instance1 = new m1_c1(); -function m1_f1() { - return exports.m1_instance1; -} -exports.m1_f1 = m1_f1; -//# sourceMappingURL=m1.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathModuleSubfolderSpecifyOutputFile/node/ref/m1.js.map b/tests/baselines/reference/project/sourceRootAbsolutePathModuleSubfolderSpecifyOutputFile/node/ref/m1.js.map deleted file mode 100644 index 19b046a427c..00000000000 --- a/tests/baselines/reference/project/sourceRootAbsolutePathModuleSubfolderSpecifyOutputFile/node/ref/m1.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"m1.js","sourceRoot":"/tests/cases/projects/outputdir_module_subfolder/src/","sources":["ref/m1.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1"],"mappings":"AAAW,aAAK,GAAG,EAAE,CAAC;AACtB;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAFY,aAAK,QAEjB,CAAA;AAEU,oBAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACIE,MAAMA,CAACA,oBAAYA,CAACA;AACxBA,CAACA;AAFe,aAAK,QAEpB,CAAA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathModuleSubfolderSpecifyOutputFile/node/sourceRootAbsolutePathModuleSubfolderSpecifyOutputFile.json b/tests/baselines/reference/project/sourceRootAbsolutePathModuleSubfolderSpecifyOutputFile/node/sourceRootAbsolutePathModuleSubfolderSpecifyOutputFile.json index a43e0f69172..50dc5aaf60f 100644 --- a/tests/baselines/reference/project/sourceRootAbsolutePathModuleSubfolderSpecifyOutputFile/node/sourceRootAbsolutePathModuleSubfolderSpecifyOutputFile.json +++ b/tests/baselines/reference/project/sourceRootAbsolutePathModuleSubfolderSpecifyOutputFile/node/sourceRootAbsolutePathModuleSubfolderSpecifyOutputFile.json @@ -16,12 +16,6 @@ "test.ts" ], "emittedFiles": [ - "ref/m1.js.map", - "ref/m1.js", - "ref/m1.d.ts", - "test.js.map", - "test.js", - "test.d.ts", "bin/test.js.map", "bin/test.js", "bin/test.d.ts" diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathModuleSubfolderSpecifyOutputFile/node/sourceRootAbsolutePathModuleSubfolderSpecifyOutputFile.sourcemap.txt b/tests/baselines/reference/project/sourceRootAbsolutePathModuleSubfolderSpecifyOutputFile/node/sourceRootAbsolutePathModuleSubfolderSpecifyOutputFile.sourcemap.txt index 9bcf1436d51..5d837611e49 100644 --- a/tests/baselines/reference/project/sourceRootAbsolutePathModuleSubfolderSpecifyOutputFile/node/sourceRootAbsolutePathModuleSubfolderSpecifyOutputFile.sourcemap.txt +++ b/tests/baselines/reference/project/sourceRootAbsolutePathModuleSubfolderSpecifyOutputFile/node/sourceRootAbsolutePathModuleSubfolderSpecifyOutputFile.sourcemap.txt @@ -1,396 +1,4 @@ =================================================================== -JsFile: m1.js -mapUrl: m1.js.map -sourceRoot: /tests/cases/projects/outputdir_module_subfolder/src/ -sources: ref/m1.ts -=================================================================== -------------------------------------------------------------------- -emittedFile:ref/m1.js -sourceFile:ref/m1.ts -------------------------------------------------------------------- ->>>exports.m1_a1 = 10; -1 > -2 >^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^-> -1 >export var -2 >m1_a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(1, 1) Source(1, 12) + SourceIndex(0) -2 >Emitted(1, 14) Source(1, 17) + SourceIndex(0) -3 >Emitted(1, 17) Source(1, 20) + SourceIndex(0) -4 >Emitted(1, 19) Source(1, 22) + SourceIndex(0) -5 >Emitted(1, 20) Source(1, 23) + SourceIndex(0) ---- ->>>var m1_c1 = (function () { -1-> -2 >^^^^^^^^^^^^^^^^^^^^^^^-> -1-> - > -1->Emitted(2, 1) Source(2, 1) + SourceIndex(0) ---- ->>> function m1_c1() { -1->^^^^ -2 > ^^-> -1-> -1->Emitted(3, 5) Source(2, 1) + SourceIndex(0) name (m1_c1) ---- ->>> } -1->^^^^ -2 > ^ -3 > ^^^^^^^^^^^^^-> -1->export class m1_c1 { - > public m1_c1_p1: number; - > -2 > } -1->Emitted(4, 5) Source(4, 1) + SourceIndex(0) name (m1_c1.constructor) -2 >Emitted(4, 6) Source(4, 2) + SourceIndex(0) name (m1_c1.constructor) ---- ->>> return m1_c1; -1->^^^^ -2 > ^^^^^^^^^^^^ -1-> -2 > } -1->Emitted(5, 5) Source(4, 1) + SourceIndex(0) name (m1_c1) -2 >Emitted(5, 17) Source(4, 2) + SourceIndex(0) name (m1_c1) ---- ->>>})(); -1 > -2 >^ -3 > -4 > ^^^^ -5 > ^^^^^^^^^^^^^^^^^^-> -1 > -2 >} -3 > -4 > export class m1_c1 { - > public m1_c1_p1: number; - > } -1 >Emitted(6, 1) Source(4, 1) + SourceIndex(0) name (m1_c1) -2 >Emitted(6, 2) Source(4, 2) + SourceIndex(0) name (m1_c1) -3 >Emitted(6, 2) Source(2, 1) + SourceIndex(0) -4 >Emitted(6, 6) Source(4, 2) + SourceIndex(0) ---- ->>>exports.m1_c1 = m1_c1; -1-> -2 >^^^^^^^^^^^^^ -3 > ^^^^^^^^ -4 > ^ -5 > ^^^^^^^^^^^^^^-> -1-> -2 >m1_c1 -3 > { - > public m1_c1_p1: number; - > } -4 > -1->Emitted(7, 1) Source(2, 14) + SourceIndex(0) -2 >Emitted(7, 14) Source(2, 19) + SourceIndex(0) -3 >Emitted(7, 22) Source(4, 2) + SourceIndex(0) -4 >Emitted(7, 23) Source(4, 2) + SourceIndex(0) ---- ->>>exports.m1_instance1 = new m1_c1(); -1-> -2 >^^^^^^^^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^^^ -5 > ^^^^^ -6 > ^^ -7 > ^ -1-> - > - >export var -2 >m1_instance1 -3 > = -4 > new -5 > m1_c1 -6 > () -7 > ; -1->Emitted(8, 1) Source(6, 12) + SourceIndex(0) -2 >Emitted(8, 21) Source(6, 24) + SourceIndex(0) -3 >Emitted(8, 24) Source(6, 27) + SourceIndex(0) -4 >Emitted(8, 28) Source(6, 31) + SourceIndex(0) -5 >Emitted(8, 33) Source(6, 36) + SourceIndex(0) -6 >Emitted(8, 35) Source(6, 38) + SourceIndex(0) -7 >Emitted(8, 36) Source(6, 39) + SourceIndex(0) ---- ->>>function m1_f1() { -1 > -2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -1 >Emitted(9, 1) Source(7, 1) + SourceIndex(0) ---- ->>> return exports.m1_instance1; -1->^^^^ -2 > ^^^^^^ -3 > ^ -4 > ^^^^^^^^^^^^^^^^^^^^ -5 > ^ -1->export function m1_f1() { - > -2 > return -3 > -4 > m1_instance1 -5 > ; -1->Emitted(10, 5) Source(8, 5) + SourceIndex(0) name (m1_f1) -2 >Emitted(10, 11) Source(8, 11) + SourceIndex(0) name (m1_f1) -3 >Emitted(10, 12) Source(8, 12) + SourceIndex(0) name (m1_f1) -4 >Emitted(10, 32) Source(8, 24) + SourceIndex(0) name (m1_f1) -5 >Emitted(10, 33) Source(8, 25) + SourceIndex(0) name (m1_f1) ---- ->>>} -1 > -2 >^ -3 > ^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -2 >} -1 >Emitted(11, 1) Source(9, 1) + SourceIndex(0) name (m1_f1) -2 >Emitted(11, 2) Source(9, 2) + SourceIndex(0) name (m1_f1) ---- ->>>exports.m1_f1 = m1_f1; -1-> -2 >^^^^^^^^^^^^^ -3 > ^^^^^^^^ -4 > ^ -5 > ^^^^^^^-> -1-> -2 >m1_f1 -3 > () { - > return m1_instance1; - > } -4 > -1->Emitted(12, 1) Source(7, 17) + SourceIndex(0) -2 >Emitted(12, 14) Source(7, 22) + SourceIndex(0) -3 >Emitted(12, 22) Source(9, 2) + SourceIndex(0) -4 >Emitted(12, 23) Source(9, 2) + SourceIndex(0) ---- ->>>//# sourceMappingURL=m1.js.map=================================================================== -JsFile: test.js -mapUrl: test.js.map -sourceRoot: /tests/cases/projects/outputdir_module_subfolder/src/ -sources: test.ts -=================================================================== -------------------------------------------------------------------- -emittedFile:test.js -sourceFile:test.ts -------------------------------------------------------------------- ->>>var m1 = require("ref/m1"); -1 > -2 >^^^^ -3 > ^^ -4 > ^^^^^^^^^^^ -5 > ^^^^^^^^ -6 > ^ -7 > ^ -1 > -2 >import -3 > m1 -4 > = require( -5 > "ref/m1" -6 > ) -7 > ; -1 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) -2 >Emitted(1, 5) Source(1, 8) + SourceIndex(0) -3 >Emitted(1, 7) Source(1, 10) + SourceIndex(0) -4 >Emitted(1, 18) Source(1, 21) + SourceIndex(0) -5 >Emitted(1, 26) Source(1, 29) + SourceIndex(0) -6 >Emitted(1, 27) Source(1, 30) + SourceIndex(0) -7 >Emitted(1, 28) Source(1, 31) + SourceIndex(0) ---- ->>>exports.a1 = 10; -1 > -2 >^^^^^^^^^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^-> -1 > - >export var -2 >a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(2, 1) Source(2, 12) + SourceIndex(0) -2 >Emitted(2, 11) Source(2, 14) + SourceIndex(0) -3 >Emitted(2, 14) Source(2, 17) + SourceIndex(0) -4 >Emitted(2, 16) Source(2, 19) + SourceIndex(0) -5 >Emitted(2, 17) Source(2, 20) + SourceIndex(0) ---- ->>>var c1 = (function () { -1-> -2 >^^^^^^^^^^^^^^^^^^^^-> -1-> - > -1->Emitted(3, 1) Source(3, 1) + SourceIndex(0) ---- ->>> function c1() { -1->^^^^ -2 > ^^-> -1-> -1->Emitted(4, 5) Source(3, 1) + SourceIndex(0) name (c1) ---- ->>> } -1->^^^^ -2 > ^ -3 > ^^^^^^^^^^-> -1->export class c1 { - > public p1: number; - > -2 > } -1->Emitted(5, 5) Source(5, 1) + SourceIndex(0) name (c1.constructor) -2 >Emitted(5, 6) Source(5, 2) + SourceIndex(0) name (c1.constructor) ---- ->>> return c1; -1->^^^^ -2 > ^^^^^^^^^ -1-> -2 > } -1->Emitted(6, 5) Source(5, 1) + SourceIndex(0) name (c1) -2 >Emitted(6, 14) Source(5, 2) + SourceIndex(0) name (c1) ---- ->>>})(); -1 > -2 >^ -3 > -4 > ^^^^ -5 > ^^^^^^^^^^^^-> -1 > -2 >} -3 > -4 > export class c1 { - > public p1: number; - > } -1 >Emitted(7, 1) Source(5, 1) + SourceIndex(0) name (c1) -2 >Emitted(7, 2) Source(5, 2) + SourceIndex(0) name (c1) -3 >Emitted(7, 2) Source(3, 1) + SourceIndex(0) -4 >Emitted(7, 6) Source(5, 2) + SourceIndex(0) ---- ->>>exports.c1 = c1; -1-> -2 >^^^^^^^^^^ -3 > ^^^^^ -4 > ^ -5 > ^^^^^^^^^^^^^^-> -1-> -2 >c1 -3 > { - > public p1: number; - > } -4 > -1->Emitted(8, 1) Source(3, 14) + SourceIndex(0) -2 >Emitted(8, 11) Source(3, 16) + SourceIndex(0) -3 >Emitted(8, 16) Source(5, 2) + SourceIndex(0) -4 >Emitted(8, 17) Source(5, 2) + SourceIndex(0) ---- ->>>exports.instance1 = new c1(); -1-> -2 >^^^^^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^^^ -5 > ^^ -6 > ^^ -7 > ^ -1-> - > - >export var -2 >instance1 -3 > = -4 > new -5 > c1 -6 > () -7 > ; -1->Emitted(9, 1) Source(7, 12) + SourceIndex(0) -2 >Emitted(9, 18) Source(7, 21) + SourceIndex(0) -3 >Emitted(9, 21) Source(7, 24) + SourceIndex(0) -4 >Emitted(9, 25) Source(7, 28) + SourceIndex(0) -5 >Emitted(9, 27) Source(7, 30) + SourceIndex(0) -6 >Emitted(9, 29) Source(7, 32) + SourceIndex(0) -7 >Emitted(9, 30) Source(7, 33) + SourceIndex(0) ---- ->>>function f1() { -1 > -2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -1 >Emitted(10, 1) Source(8, 1) + SourceIndex(0) ---- ->>> return exports.instance1; -1->^^^^ -2 > ^^^^^^ -3 > ^ -4 > ^^^^^^^^^^^^^^^^^ -5 > ^ -1->export function f1() { - > -2 > return -3 > -4 > instance1 -5 > ; -1->Emitted(11, 5) Source(9, 5) + SourceIndex(0) name (f1) -2 >Emitted(11, 11) Source(9, 11) + SourceIndex(0) name (f1) -3 >Emitted(11, 12) Source(9, 12) + SourceIndex(0) name (f1) -4 >Emitted(11, 29) Source(9, 21) + SourceIndex(0) name (f1) -5 >Emitted(11, 30) Source(9, 22) + SourceIndex(0) name (f1) ---- ->>>} -1 > -2 >^ -3 > ^^^^^^^^^^^^^^^^-> -1 > - > -2 >} -1 >Emitted(12, 1) Source(10, 1) + SourceIndex(0) name (f1) -2 >Emitted(12, 2) Source(10, 2) + SourceIndex(0) name (f1) ---- ->>>exports.f1 = f1; -1-> -2 >^^^^^^^^^^ -3 > ^^^^^ -4 > ^ -5 > ^^^^^^^-> -1-> -2 >f1 -3 > () { - > return instance1; - > } -4 > -1->Emitted(13, 1) Source(8, 17) + SourceIndex(0) -2 >Emitted(13, 11) Source(8, 19) + SourceIndex(0) -3 >Emitted(13, 16) Source(10, 2) + SourceIndex(0) -4 >Emitted(13, 17) Source(10, 2) + SourceIndex(0) ---- ->>>exports.a2 = m1.m1_c1; -1-> -2 >^^^^^^^^^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^ -7 > ^ -8 > ^^^^^^^^^-> -1-> - > - >export var -2 >a2 -3 > = -4 > m1 -5 > . -6 > m1_c1 -7 > ; -1->Emitted(14, 1) Source(12, 12) + SourceIndex(0) -2 >Emitted(14, 11) Source(12, 14) + SourceIndex(0) -3 >Emitted(14, 14) Source(12, 17) + SourceIndex(0) -4 >Emitted(14, 16) Source(12, 19) + SourceIndex(0) -5 >Emitted(14, 17) Source(12, 20) + SourceIndex(0) -6 >Emitted(14, 22) Source(12, 25) + SourceIndex(0) -7 >Emitted(14, 23) Source(12, 26) + SourceIndex(0) ---- ->>>//# sourceMappingURL=test.js.map=================================================================== JsFile: test.js mapUrl: test.js.map sourceRoot: /tests/cases/projects/outputdir_module_subfolder/src/ diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathModuleSubfolderSpecifyOutputFile/node/test.d.ts b/tests/baselines/reference/project/sourceRootAbsolutePathModuleSubfolderSpecifyOutputFile/node/test.d.ts deleted file mode 100644 index a61d8541048..00000000000 --- a/tests/baselines/reference/project/sourceRootAbsolutePathModuleSubfolderSpecifyOutputFile/node/test.d.ts +++ /dev/null @@ -1,8 +0,0 @@ -import m1 = require("ref/m1"); -export declare var a1: number; -export declare class c1 { - p1: number; -} -export declare var instance1: c1; -export declare function f1(): c1; -export declare var a2: typeof m1.m1_c1; diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathModuleSubfolderSpecifyOutputFile/node/test.js b/tests/baselines/reference/project/sourceRootAbsolutePathModuleSubfolderSpecifyOutputFile/node/test.js deleted file mode 100644 index 46c9f29e55a..00000000000 --- a/tests/baselines/reference/project/sourceRootAbsolutePathModuleSubfolderSpecifyOutputFile/node/test.js +++ /dev/null @@ -1,15 +0,0 @@ -var m1 = require("ref/m1"); -exports.a1 = 10; -var c1 = (function () { - function c1() { - } - return c1; -})(); -exports.c1 = c1; -exports.instance1 = new c1(); -function f1() { - return exports.instance1; -} -exports.f1 = f1; -exports.a2 = m1.m1_c1; -//# sourceMappingURL=test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathModuleSubfolderSpecifyOutputFile/node/test.js.map b/tests/baselines/reference/project/sourceRootAbsolutePathModuleSubfolderSpecifyOutputFile/node/test.js.map deleted file mode 100644 index c63a0943976..00000000000 --- a/tests/baselines/reference/project/sourceRootAbsolutePathModuleSubfolderSpecifyOutputFile/node/test.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"test.js","sourceRoot":"/tests/cases/projects/outputdir_module_subfolder/src/","sources":["test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AAAA,IAAO,EAAE,WAAW,QAAQ,CAAC,CAAC;AACnB,UAAE,GAAG,EAAE,CAAC;AACnB;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAFY,UAAE,KAEd,CAAA;AAEU,iBAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AAChC;IACIE,MAAMA,CAACA,iBAASA,CAACA;AACrBA,CAACA;AAFe,UAAE,KAEjB,CAAA;AAEU,UAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFile/amd/ref/m2.d.ts b/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFile/amd/ref/m2.d.ts deleted file mode 100644 index c09a3c0c32a..00000000000 --- a/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFile/amd/ref/m2.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -export declare var m2_a1: number; -export declare class m2_c1 { - m2_c1_p1: number; -} -export declare var m2_instance1: m2_c1; -export declare function m2_f1(): m2_c1; diff --git a/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFile/amd/ref/m2.js b/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFile/amd/ref/m2.js deleted file mode 100644 index 144ad24e2de..00000000000 --- a/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFile/amd/ref/m2.js +++ /dev/null @@ -1,15 +0,0 @@ -define(["require", "exports"], function (require, exports) { - exports.m2_a1 = 10; - var m2_c1 = (function () { - function m2_c1() { - } - return m2_c1; - })(); - exports.m2_c1 = m2_c1; - exports.m2_instance1 = new m2_c1(); - function m2_f1() { - return exports.m2_instance1; - } - exports.m2_f1 = m2_f1; -}); -//# sourceMappingURL=m2.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFile/amd/ref/m2.js.map b/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFile/amd/ref/m2.js.map deleted file mode 100644 index 0927206ec1b..00000000000 --- a/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFile/amd/ref/m2.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"m2.js","sourceRoot":"../src/","sources":["ref/m2.ts"],"names":["m2_c1","m2_c1.constructor","m2_f1"],"mappings":";IAAW,aAAK,GAAG,EAAE,CAAC;IACtB;QAAAA;QAEAC,CAACA;QAADD,YAACA;IAADA,CAACA,AAFD,IAEC;IAFY,aAAK,QAEjB,CAAA;IAEU,oBAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACIE,MAAMA,CAACA,oBAAYA,CAACA;IACxBA,CAACA;IAFe,aAAK,QAEpB,CAAA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFile/amd/sourceRootRelativePathMixedSubfolderSpecifyOutputFile.json b/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFile/amd/sourceRootRelativePathMixedSubfolderSpecifyOutputFile.json index 82ef1c7d882..2dcfc8a5a2c 100644 --- a/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFile/amd/sourceRootRelativePathMixedSubfolderSpecifyOutputFile.json +++ b/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFile/amd/sourceRootRelativePathMixedSubfolderSpecifyOutputFile.json @@ -16,9 +16,6 @@ "test.ts" ], "emittedFiles": [ - "ref/m2.js.map", - "ref/m2.js", - "ref/m2.d.ts", "bin/test.js.map", "bin/test.js", "bin/test.d.ts" diff --git a/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFile/amd/sourceRootRelativePathMixedSubfolderSpecifyOutputFile.sourcemap.txt b/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFile/amd/sourceRootRelativePathMixedSubfolderSpecifyOutputFile.sourcemap.txt index cbab02333cb..d722bc8936a 100644 --- a/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFile/amd/sourceRootRelativePathMixedSubfolderSpecifyOutputFile.sourcemap.txt +++ b/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFile/amd/sourceRootRelativePathMixedSubfolderSpecifyOutputFile.sourcemap.txt @@ -1,176 +1,4 @@ =================================================================== -JsFile: m2.js -mapUrl: m2.js.map -sourceRoot: ../src/ -sources: ref/m2.ts -=================================================================== -------------------------------------------------------------------- -emittedFile:ref/m2.js -sourceFile:ref/m2.ts -------------------------------------------------------------------- ->>>define(["require", "exports"], function (require, exports) { ->>> exports.m2_a1 = 10; -1 >^^^^ -2 > ^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^-> -1 >export var -2 > m2_a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(2, 5) Source(1, 12) + SourceIndex(0) -2 >Emitted(2, 18) Source(1, 17) + SourceIndex(0) -3 >Emitted(2, 21) Source(1, 20) + SourceIndex(0) -4 >Emitted(2, 23) Source(1, 22) + SourceIndex(0) -5 >Emitted(2, 24) Source(1, 23) + SourceIndex(0) ---- ->>> var m2_c1 = (function () { -1->^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^^^^-> -1-> - > -1->Emitted(3, 5) Source(2, 1) + SourceIndex(0) ---- ->>> function m2_c1() { -1->^^^^^^^^ -2 > ^^-> -1-> -1->Emitted(4, 9) Source(2, 1) + SourceIndex(0) name (m2_c1) ---- ->>> } -1->^^^^^^^^ -2 > ^ -3 > ^^^^^^^^^^^^^-> -1->export class m2_c1 { - > public m2_c1_p1: number; - > -2 > } -1->Emitted(5, 9) Source(4, 1) + SourceIndex(0) name (m2_c1.constructor) -2 >Emitted(5, 10) Source(4, 2) + SourceIndex(0) name (m2_c1.constructor) ---- ->>> return m2_c1; -1->^^^^^^^^ -2 > ^^^^^^^^^^^^ -1-> -2 > } -1->Emitted(6, 9) Source(4, 1) + SourceIndex(0) name (m2_c1) -2 >Emitted(6, 21) Source(4, 2) + SourceIndex(0) name (m2_c1) ---- ->>> })(); -1 >^^^^ -2 > ^ -3 > -4 > ^^^^ -5 > ^^^^^^^^^^^^^^^^^^-> -1 > -2 > } -3 > -4 > export class m2_c1 { - > public m2_c1_p1: number; - > } -1 >Emitted(7, 5) Source(4, 1) + SourceIndex(0) name (m2_c1) -2 >Emitted(7, 6) Source(4, 2) + SourceIndex(0) name (m2_c1) -3 >Emitted(7, 6) Source(2, 1) + SourceIndex(0) -4 >Emitted(7, 10) Source(4, 2) + SourceIndex(0) ---- ->>> exports.m2_c1 = m2_c1; -1->^^^^ -2 > ^^^^^^^^^^^^^ -3 > ^^^^^^^^ -4 > ^ -5 > ^^^^^^^^^^^^^^-> -1-> -2 > m2_c1 -3 > { - > public m2_c1_p1: number; - > } -4 > -1->Emitted(8, 5) Source(2, 14) + SourceIndex(0) -2 >Emitted(8, 18) Source(2, 19) + SourceIndex(0) -3 >Emitted(8, 26) Source(4, 2) + SourceIndex(0) -4 >Emitted(8, 27) Source(4, 2) + SourceIndex(0) ---- ->>> exports.m2_instance1 = new m2_c1(); -1->^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^^^ -5 > ^^^^^ -6 > ^^ -7 > ^ -1-> - > - >export var -2 > m2_instance1 -3 > = -4 > new -5 > m2_c1 -6 > () -7 > ; -1->Emitted(9, 5) Source(6, 12) + SourceIndex(0) -2 >Emitted(9, 25) Source(6, 24) + SourceIndex(0) -3 >Emitted(9, 28) Source(6, 27) + SourceIndex(0) -4 >Emitted(9, 32) Source(6, 31) + SourceIndex(0) -5 >Emitted(9, 37) Source(6, 36) + SourceIndex(0) -6 >Emitted(9, 39) Source(6, 38) + SourceIndex(0) -7 >Emitted(9, 40) Source(6, 39) + SourceIndex(0) ---- ->>> function m2_f1() { -1 >^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -1 >Emitted(10, 5) Source(7, 1) + SourceIndex(0) ---- ->>> return exports.m2_instance1; -1->^^^^^^^^ -2 > ^^^^^^ -3 > ^ -4 > ^^^^^^^^^^^^^^^^^^^^ -5 > ^ -1->export function m2_f1() { - > -2 > return -3 > -4 > m2_instance1 -5 > ; -1->Emitted(11, 9) Source(8, 5) + SourceIndex(0) name (m2_f1) -2 >Emitted(11, 15) Source(8, 11) + SourceIndex(0) name (m2_f1) -3 >Emitted(11, 16) Source(8, 12) + SourceIndex(0) name (m2_f1) -4 >Emitted(11, 36) Source(8, 24) + SourceIndex(0) name (m2_f1) -5 >Emitted(11, 37) Source(8, 25) + SourceIndex(0) name (m2_f1) ---- ->>> } -1 >^^^^ -2 > ^ -3 > ^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -2 > } -1 >Emitted(12, 5) Source(9, 1) + SourceIndex(0) name (m2_f1) -2 >Emitted(12, 6) Source(9, 2) + SourceIndex(0) name (m2_f1) ---- ->>> exports.m2_f1 = m2_f1; -1->^^^^ -2 > ^^^^^^^^^^^^^ -3 > ^^^^^^^^ -4 > ^ -1-> -2 > m2_f1 -3 > () { - > return m2_instance1; - > } -4 > -1->Emitted(13, 5) Source(7, 17) + SourceIndex(0) -2 >Emitted(13, 18) Source(7, 22) + SourceIndex(0) -3 >Emitted(13, 26) Source(9, 2) + SourceIndex(0) -4 >Emitted(13, 27) Source(9, 2) + SourceIndex(0) ---- ->>>}); ->>>//# sourceMappingURL=m2.js.map=================================================================== JsFile: test.js mapUrl: test.js.map sourceRoot: ../src/ diff --git a/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFile/node/ref/m2.d.ts b/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFile/node/ref/m2.d.ts deleted file mode 100644 index c09a3c0c32a..00000000000 --- a/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFile/node/ref/m2.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -export declare var m2_a1: number; -export declare class m2_c1 { - m2_c1_p1: number; -} -export declare var m2_instance1: m2_c1; -export declare function m2_f1(): m2_c1; diff --git a/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFile/node/ref/m2.js b/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFile/node/ref/m2.js deleted file mode 100644 index ec0a73b5af8..00000000000 --- a/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFile/node/ref/m2.js +++ /dev/null @@ -1,13 +0,0 @@ -exports.m2_a1 = 10; -var m2_c1 = (function () { - function m2_c1() { - } - return m2_c1; -})(); -exports.m2_c1 = m2_c1; -exports.m2_instance1 = new m2_c1(); -function m2_f1() { - return exports.m2_instance1; -} -exports.m2_f1 = m2_f1; -//# sourceMappingURL=m2.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFile/node/ref/m2.js.map b/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFile/node/ref/m2.js.map deleted file mode 100644 index 84f18c56247..00000000000 --- a/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFile/node/ref/m2.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"m2.js","sourceRoot":"../src/","sources":["ref/m2.ts"],"names":["m2_c1","m2_c1.constructor","m2_f1"],"mappings":"AAAW,aAAK,GAAG,EAAE,CAAC;AACtB;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAFY,aAAK,QAEjB,CAAA;AAEU,oBAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACIE,MAAMA,CAACA,oBAAYA,CAACA;AACxBA,CAACA;AAFe,aAAK,QAEpB,CAAA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFile/node/sourceRootRelativePathMixedSubfolderSpecifyOutputFile.json b/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFile/node/sourceRootRelativePathMixedSubfolderSpecifyOutputFile.json index 82ef1c7d882..2dcfc8a5a2c 100644 --- a/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFile/node/sourceRootRelativePathMixedSubfolderSpecifyOutputFile.json +++ b/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFile/node/sourceRootRelativePathMixedSubfolderSpecifyOutputFile.json @@ -16,9 +16,6 @@ "test.ts" ], "emittedFiles": [ - "ref/m2.js.map", - "ref/m2.js", - "ref/m2.d.ts", "bin/test.js.map", "bin/test.js", "bin/test.d.ts" diff --git a/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFile/node/sourceRootRelativePathMixedSubfolderSpecifyOutputFile.sourcemap.txt b/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFile/node/sourceRootRelativePathMixedSubfolderSpecifyOutputFile.sourcemap.txt index e064f005473..b71c21b5b99 100644 --- a/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFile/node/sourceRootRelativePathMixedSubfolderSpecifyOutputFile.sourcemap.txt +++ b/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFile/node/sourceRootRelativePathMixedSubfolderSpecifyOutputFile.sourcemap.txt @@ -1,175 +1,4 @@ =================================================================== -JsFile: m2.js -mapUrl: m2.js.map -sourceRoot: ../src/ -sources: ref/m2.ts -=================================================================== -------------------------------------------------------------------- -emittedFile:ref/m2.js -sourceFile:ref/m2.ts -------------------------------------------------------------------- ->>>exports.m2_a1 = 10; -1 > -2 >^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^-> -1 >export var -2 >m2_a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(1, 1) Source(1, 12) + SourceIndex(0) -2 >Emitted(1, 14) Source(1, 17) + SourceIndex(0) -3 >Emitted(1, 17) Source(1, 20) + SourceIndex(0) -4 >Emitted(1, 19) Source(1, 22) + SourceIndex(0) -5 >Emitted(1, 20) Source(1, 23) + SourceIndex(0) ---- ->>>var m2_c1 = (function () { -1-> -2 >^^^^^^^^^^^^^^^^^^^^^^^-> -1-> - > -1->Emitted(2, 1) Source(2, 1) + SourceIndex(0) ---- ->>> function m2_c1() { -1->^^^^ -2 > ^^-> -1-> -1->Emitted(3, 5) Source(2, 1) + SourceIndex(0) name (m2_c1) ---- ->>> } -1->^^^^ -2 > ^ -3 > ^^^^^^^^^^^^^-> -1->export class m2_c1 { - > public m2_c1_p1: number; - > -2 > } -1->Emitted(4, 5) Source(4, 1) + SourceIndex(0) name (m2_c1.constructor) -2 >Emitted(4, 6) Source(4, 2) + SourceIndex(0) name (m2_c1.constructor) ---- ->>> return m2_c1; -1->^^^^ -2 > ^^^^^^^^^^^^ -1-> -2 > } -1->Emitted(5, 5) Source(4, 1) + SourceIndex(0) name (m2_c1) -2 >Emitted(5, 17) Source(4, 2) + SourceIndex(0) name (m2_c1) ---- ->>>})(); -1 > -2 >^ -3 > -4 > ^^^^ -5 > ^^^^^^^^^^^^^^^^^^-> -1 > -2 >} -3 > -4 > export class m2_c1 { - > public m2_c1_p1: number; - > } -1 >Emitted(6, 1) Source(4, 1) + SourceIndex(0) name (m2_c1) -2 >Emitted(6, 2) Source(4, 2) + SourceIndex(0) name (m2_c1) -3 >Emitted(6, 2) Source(2, 1) + SourceIndex(0) -4 >Emitted(6, 6) Source(4, 2) + SourceIndex(0) ---- ->>>exports.m2_c1 = m2_c1; -1-> -2 >^^^^^^^^^^^^^ -3 > ^^^^^^^^ -4 > ^ -5 > ^^^^^^^^^^^^^^-> -1-> -2 >m2_c1 -3 > { - > public m2_c1_p1: number; - > } -4 > -1->Emitted(7, 1) Source(2, 14) + SourceIndex(0) -2 >Emitted(7, 14) Source(2, 19) + SourceIndex(0) -3 >Emitted(7, 22) Source(4, 2) + SourceIndex(0) -4 >Emitted(7, 23) Source(4, 2) + SourceIndex(0) ---- ->>>exports.m2_instance1 = new m2_c1(); -1-> -2 >^^^^^^^^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^^^ -5 > ^^^^^ -6 > ^^ -7 > ^ -1-> - > - >export var -2 >m2_instance1 -3 > = -4 > new -5 > m2_c1 -6 > () -7 > ; -1->Emitted(8, 1) Source(6, 12) + SourceIndex(0) -2 >Emitted(8, 21) Source(6, 24) + SourceIndex(0) -3 >Emitted(8, 24) Source(6, 27) + SourceIndex(0) -4 >Emitted(8, 28) Source(6, 31) + SourceIndex(0) -5 >Emitted(8, 33) Source(6, 36) + SourceIndex(0) -6 >Emitted(8, 35) Source(6, 38) + SourceIndex(0) -7 >Emitted(8, 36) Source(6, 39) + SourceIndex(0) ---- ->>>function m2_f1() { -1 > -2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -1 >Emitted(9, 1) Source(7, 1) + SourceIndex(0) ---- ->>> return exports.m2_instance1; -1->^^^^ -2 > ^^^^^^ -3 > ^ -4 > ^^^^^^^^^^^^^^^^^^^^ -5 > ^ -1->export function m2_f1() { - > -2 > return -3 > -4 > m2_instance1 -5 > ; -1->Emitted(10, 5) Source(8, 5) + SourceIndex(0) name (m2_f1) -2 >Emitted(10, 11) Source(8, 11) + SourceIndex(0) name (m2_f1) -3 >Emitted(10, 12) Source(8, 12) + SourceIndex(0) name (m2_f1) -4 >Emitted(10, 32) Source(8, 24) + SourceIndex(0) name (m2_f1) -5 >Emitted(10, 33) Source(8, 25) + SourceIndex(0) name (m2_f1) ---- ->>>} -1 > -2 >^ -3 > ^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -2 >} -1 >Emitted(11, 1) Source(9, 1) + SourceIndex(0) name (m2_f1) -2 >Emitted(11, 2) Source(9, 2) + SourceIndex(0) name (m2_f1) ---- ->>>exports.m2_f1 = m2_f1; -1-> -2 >^^^^^^^^^^^^^ -3 > ^^^^^^^^ -4 > ^ -5 > ^^^^^^^-> -1-> -2 >m2_f1 -3 > () { - > return m2_instance1; - > } -4 > -1->Emitted(12, 1) Source(7, 17) + SourceIndex(0) -2 >Emitted(12, 14) Source(7, 22) + SourceIndex(0) -3 >Emitted(12, 22) Source(9, 2) + SourceIndex(0) -4 >Emitted(12, 23) Source(9, 2) + SourceIndex(0) ---- ->>>//# sourceMappingURL=m2.js.map=================================================================== JsFile: test.js mapUrl: test.js.map sourceRoot: ../src/ diff --git a/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/outdir/outAndOutDirFolder/ref/m2.d.ts b/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/outdir/outAndOutDirFolder/ref/m2.d.ts deleted file mode 100644 index c09a3c0c32a..00000000000 --- a/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/outdir/outAndOutDirFolder/ref/m2.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -export declare var m2_a1: number; -export declare class m2_c1 { - m2_c1_p1: number; -} -export declare var m2_instance1: m2_c1; -export declare function m2_f1(): m2_c1; diff --git a/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/outdir/outAndOutDirFolder/ref/m2.js b/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/outdir/outAndOutDirFolder/ref/m2.js deleted file mode 100644 index 144ad24e2de..00000000000 --- a/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/outdir/outAndOutDirFolder/ref/m2.js +++ /dev/null @@ -1,15 +0,0 @@ -define(["require", "exports"], function (require, exports) { - exports.m2_a1 = 10; - var m2_c1 = (function () { - function m2_c1() { - } - return m2_c1; - })(); - exports.m2_c1 = m2_c1; - exports.m2_instance1 = new m2_c1(); - function m2_f1() { - return exports.m2_instance1; - } - exports.m2_f1 = m2_f1; -}); -//# sourceMappingURL=m2.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/outdir/outAndOutDirFolder/ref/m2.js.map b/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/outdir/outAndOutDirFolder/ref/m2.js.map deleted file mode 100644 index 0927206ec1b..00000000000 --- a/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/outdir/outAndOutDirFolder/ref/m2.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"m2.js","sourceRoot":"../src/","sources":["ref/m2.ts"],"names":["m2_c1","m2_c1.constructor","m2_f1"],"mappings":";IAAW,aAAK,GAAG,EAAE,CAAC;IACtB;QAAAA;QAEAC,CAACA;QAADD,YAACA;IAADA,CAACA,AAFD,IAEC;IAFY,aAAK,QAEjB,CAAA;IAEU,oBAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACIE,MAAMA,CAACA,oBAAYA,CAACA;IACxBA,CAACA;IAFe,aAAK,QAEpB,CAAA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/sourceRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory.json b/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/sourceRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory.json index d5f4fd9c654..4247e9dadc2 100644 --- a/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/sourceRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory.json +++ b/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/sourceRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory.json @@ -17,9 +17,6 @@ "test.ts" ], "emittedFiles": [ - "outdir/outAndOutDirFolder/ref/m2.js.map", - "outdir/outAndOutDirFolder/ref/m2.js", - "outdir/outAndOutDirFolder/ref/m2.d.ts", "bin/outAndOutDirFile.js.map", "bin/outAndOutDirFile.js", "bin/outAndOutDirFile.d.ts" diff --git a/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/sourceRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory.sourcemap.txt b/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/sourceRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory.sourcemap.txt index f2fc29c157e..d1799c07a98 100644 --- a/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/sourceRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory.sourcemap.txt +++ b/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/sourceRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory.sourcemap.txt @@ -1,176 +1,4 @@ =================================================================== -JsFile: m2.js -mapUrl: m2.js.map -sourceRoot: ../src/ -sources: ref/m2.ts -=================================================================== -------------------------------------------------------------------- -emittedFile:outdir/outAndOutDirFolder/ref/m2.js -sourceFile:ref/m2.ts -------------------------------------------------------------------- ->>>define(["require", "exports"], function (require, exports) { ->>> exports.m2_a1 = 10; -1 >^^^^ -2 > ^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^-> -1 >export var -2 > m2_a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(2, 5) Source(1, 12) + SourceIndex(0) -2 >Emitted(2, 18) Source(1, 17) + SourceIndex(0) -3 >Emitted(2, 21) Source(1, 20) + SourceIndex(0) -4 >Emitted(2, 23) Source(1, 22) + SourceIndex(0) -5 >Emitted(2, 24) Source(1, 23) + SourceIndex(0) ---- ->>> var m2_c1 = (function () { -1->^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^^^^-> -1-> - > -1->Emitted(3, 5) Source(2, 1) + SourceIndex(0) ---- ->>> function m2_c1() { -1->^^^^^^^^ -2 > ^^-> -1-> -1->Emitted(4, 9) Source(2, 1) + SourceIndex(0) name (m2_c1) ---- ->>> } -1->^^^^^^^^ -2 > ^ -3 > ^^^^^^^^^^^^^-> -1->export class m2_c1 { - > public m2_c1_p1: number; - > -2 > } -1->Emitted(5, 9) Source(4, 1) + SourceIndex(0) name (m2_c1.constructor) -2 >Emitted(5, 10) Source(4, 2) + SourceIndex(0) name (m2_c1.constructor) ---- ->>> return m2_c1; -1->^^^^^^^^ -2 > ^^^^^^^^^^^^ -1-> -2 > } -1->Emitted(6, 9) Source(4, 1) + SourceIndex(0) name (m2_c1) -2 >Emitted(6, 21) Source(4, 2) + SourceIndex(0) name (m2_c1) ---- ->>> })(); -1 >^^^^ -2 > ^ -3 > -4 > ^^^^ -5 > ^^^^^^^^^^^^^^^^^^-> -1 > -2 > } -3 > -4 > export class m2_c1 { - > public m2_c1_p1: number; - > } -1 >Emitted(7, 5) Source(4, 1) + SourceIndex(0) name (m2_c1) -2 >Emitted(7, 6) Source(4, 2) + SourceIndex(0) name (m2_c1) -3 >Emitted(7, 6) Source(2, 1) + SourceIndex(0) -4 >Emitted(7, 10) Source(4, 2) + SourceIndex(0) ---- ->>> exports.m2_c1 = m2_c1; -1->^^^^ -2 > ^^^^^^^^^^^^^ -3 > ^^^^^^^^ -4 > ^ -5 > ^^^^^^^^^^^^^^-> -1-> -2 > m2_c1 -3 > { - > public m2_c1_p1: number; - > } -4 > -1->Emitted(8, 5) Source(2, 14) + SourceIndex(0) -2 >Emitted(8, 18) Source(2, 19) + SourceIndex(0) -3 >Emitted(8, 26) Source(4, 2) + SourceIndex(0) -4 >Emitted(8, 27) Source(4, 2) + SourceIndex(0) ---- ->>> exports.m2_instance1 = new m2_c1(); -1->^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^^^ -5 > ^^^^^ -6 > ^^ -7 > ^ -1-> - > - >export var -2 > m2_instance1 -3 > = -4 > new -5 > m2_c1 -6 > () -7 > ; -1->Emitted(9, 5) Source(6, 12) + SourceIndex(0) -2 >Emitted(9, 25) Source(6, 24) + SourceIndex(0) -3 >Emitted(9, 28) Source(6, 27) + SourceIndex(0) -4 >Emitted(9, 32) Source(6, 31) + SourceIndex(0) -5 >Emitted(9, 37) Source(6, 36) + SourceIndex(0) -6 >Emitted(9, 39) Source(6, 38) + SourceIndex(0) -7 >Emitted(9, 40) Source(6, 39) + SourceIndex(0) ---- ->>> function m2_f1() { -1 >^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -1 >Emitted(10, 5) Source(7, 1) + SourceIndex(0) ---- ->>> return exports.m2_instance1; -1->^^^^^^^^ -2 > ^^^^^^ -3 > ^ -4 > ^^^^^^^^^^^^^^^^^^^^ -5 > ^ -1->export function m2_f1() { - > -2 > return -3 > -4 > m2_instance1 -5 > ; -1->Emitted(11, 9) Source(8, 5) + SourceIndex(0) name (m2_f1) -2 >Emitted(11, 15) Source(8, 11) + SourceIndex(0) name (m2_f1) -3 >Emitted(11, 16) Source(8, 12) + SourceIndex(0) name (m2_f1) -4 >Emitted(11, 36) Source(8, 24) + SourceIndex(0) name (m2_f1) -5 >Emitted(11, 37) Source(8, 25) + SourceIndex(0) name (m2_f1) ---- ->>> } -1 >^^^^ -2 > ^ -3 > ^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -2 > } -1 >Emitted(12, 5) Source(9, 1) + SourceIndex(0) name (m2_f1) -2 >Emitted(12, 6) Source(9, 2) + SourceIndex(0) name (m2_f1) ---- ->>> exports.m2_f1 = m2_f1; -1->^^^^ -2 > ^^^^^^^^^^^^^ -3 > ^^^^^^^^ -4 > ^ -1-> -2 > m2_f1 -3 > () { - > return m2_instance1; - > } -4 > -1->Emitted(13, 5) Source(7, 17) + SourceIndex(0) -2 >Emitted(13, 18) Source(7, 22) + SourceIndex(0) -3 >Emitted(13, 26) Source(9, 2) + SourceIndex(0) -4 >Emitted(13, 27) Source(9, 2) + SourceIndex(0) ---- ->>>}); ->>>//# sourceMappingURL=m2.js.map=================================================================== JsFile: outAndOutDirFile.js mapUrl: outAndOutDirFile.js.map sourceRoot: ../src/ diff --git a/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/outdir/outAndOutDirFolder/ref/m2.d.ts b/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/outdir/outAndOutDirFolder/ref/m2.d.ts deleted file mode 100644 index c09a3c0c32a..00000000000 --- a/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/outdir/outAndOutDirFolder/ref/m2.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -export declare var m2_a1: number; -export declare class m2_c1 { - m2_c1_p1: number; -} -export declare var m2_instance1: m2_c1; -export declare function m2_f1(): m2_c1; diff --git a/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/outdir/outAndOutDirFolder/ref/m2.js b/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/outdir/outAndOutDirFolder/ref/m2.js deleted file mode 100644 index ec0a73b5af8..00000000000 --- a/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/outdir/outAndOutDirFolder/ref/m2.js +++ /dev/null @@ -1,13 +0,0 @@ -exports.m2_a1 = 10; -var m2_c1 = (function () { - function m2_c1() { - } - return m2_c1; -})(); -exports.m2_c1 = m2_c1; -exports.m2_instance1 = new m2_c1(); -function m2_f1() { - return exports.m2_instance1; -} -exports.m2_f1 = m2_f1; -//# sourceMappingURL=m2.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/outdir/outAndOutDirFolder/ref/m2.js.map b/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/outdir/outAndOutDirFolder/ref/m2.js.map deleted file mode 100644 index 84f18c56247..00000000000 --- a/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/outdir/outAndOutDirFolder/ref/m2.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"m2.js","sourceRoot":"../src/","sources":["ref/m2.ts"],"names":["m2_c1","m2_c1.constructor","m2_f1"],"mappings":"AAAW,aAAK,GAAG,EAAE,CAAC;AACtB;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAFY,aAAK,QAEjB,CAAA;AAEU,oBAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACIE,MAAMA,CAACA,oBAAYA,CAACA;AACxBA,CAACA;AAFe,aAAK,QAEpB,CAAA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/sourceRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory.json b/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/sourceRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory.json index d5f4fd9c654..4247e9dadc2 100644 --- a/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/sourceRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory.json +++ b/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/sourceRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory.json @@ -17,9 +17,6 @@ "test.ts" ], "emittedFiles": [ - "outdir/outAndOutDirFolder/ref/m2.js.map", - "outdir/outAndOutDirFolder/ref/m2.js", - "outdir/outAndOutDirFolder/ref/m2.d.ts", "bin/outAndOutDirFile.js.map", "bin/outAndOutDirFile.js", "bin/outAndOutDirFile.d.ts" diff --git a/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/sourceRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory.sourcemap.txt b/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/sourceRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory.sourcemap.txt index 5690deb27df..2a0cc630cc0 100644 --- a/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/sourceRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory.sourcemap.txt +++ b/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/sourceRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory.sourcemap.txt @@ -1,175 +1,4 @@ =================================================================== -JsFile: m2.js -mapUrl: m2.js.map -sourceRoot: ../src/ -sources: ref/m2.ts -=================================================================== -------------------------------------------------------------------- -emittedFile:outdir/outAndOutDirFolder/ref/m2.js -sourceFile:ref/m2.ts -------------------------------------------------------------------- ->>>exports.m2_a1 = 10; -1 > -2 >^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^-> -1 >export var -2 >m2_a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(1, 1) Source(1, 12) + SourceIndex(0) -2 >Emitted(1, 14) Source(1, 17) + SourceIndex(0) -3 >Emitted(1, 17) Source(1, 20) + SourceIndex(0) -4 >Emitted(1, 19) Source(1, 22) + SourceIndex(0) -5 >Emitted(1, 20) Source(1, 23) + SourceIndex(0) ---- ->>>var m2_c1 = (function () { -1-> -2 >^^^^^^^^^^^^^^^^^^^^^^^-> -1-> - > -1->Emitted(2, 1) Source(2, 1) + SourceIndex(0) ---- ->>> function m2_c1() { -1->^^^^ -2 > ^^-> -1-> -1->Emitted(3, 5) Source(2, 1) + SourceIndex(0) name (m2_c1) ---- ->>> } -1->^^^^ -2 > ^ -3 > ^^^^^^^^^^^^^-> -1->export class m2_c1 { - > public m2_c1_p1: number; - > -2 > } -1->Emitted(4, 5) Source(4, 1) + SourceIndex(0) name (m2_c1.constructor) -2 >Emitted(4, 6) Source(4, 2) + SourceIndex(0) name (m2_c1.constructor) ---- ->>> return m2_c1; -1->^^^^ -2 > ^^^^^^^^^^^^ -1-> -2 > } -1->Emitted(5, 5) Source(4, 1) + SourceIndex(0) name (m2_c1) -2 >Emitted(5, 17) Source(4, 2) + SourceIndex(0) name (m2_c1) ---- ->>>})(); -1 > -2 >^ -3 > -4 > ^^^^ -5 > ^^^^^^^^^^^^^^^^^^-> -1 > -2 >} -3 > -4 > export class m2_c1 { - > public m2_c1_p1: number; - > } -1 >Emitted(6, 1) Source(4, 1) + SourceIndex(0) name (m2_c1) -2 >Emitted(6, 2) Source(4, 2) + SourceIndex(0) name (m2_c1) -3 >Emitted(6, 2) Source(2, 1) + SourceIndex(0) -4 >Emitted(6, 6) Source(4, 2) + SourceIndex(0) ---- ->>>exports.m2_c1 = m2_c1; -1-> -2 >^^^^^^^^^^^^^ -3 > ^^^^^^^^ -4 > ^ -5 > ^^^^^^^^^^^^^^-> -1-> -2 >m2_c1 -3 > { - > public m2_c1_p1: number; - > } -4 > -1->Emitted(7, 1) Source(2, 14) + SourceIndex(0) -2 >Emitted(7, 14) Source(2, 19) + SourceIndex(0) -3 >Emitted(7, 22) Source(4, 2) + SourceIndex(0) -4 >Emitted(7, 23) Source(4, 2) + SourceIndex(0) ---- ->>>exports.m2_instance1 = new m2_c1(); -1-> -2 >^^^^^^^^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^^^ -5 > ^^^^^ -6 > ^^ -7 > ^ -1-> - > - >export var -2 >m2_instance1 -3 > = -4 > new -5 > m2_c1 -6 > () -7 > ; -1->Emitted(8, 1) Source(6, 12) + SourceIndex(0) -2 >Emitted(8, 21) Source(6, 24) + SourceIndex(0) -3 >Emitted(8, 24) Source(6, 27) + SourceIndex(0) -4 >Emitted(8, 28) Source(6, 31) + SourceIndex(0) -5 >Emitted(8, 33) Source(6, 36) + SourceIndex(0) -6 >Emitted(8, 35) Source(6, 38) + SourceIndex(0) -7 >Emitted(8, 36) Source(6, 39) + SourceIndex(0) ---- ->>>function m2_f1() { -1 > -2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -1 >Emitted(9, 1) Source(7, 1) + SourceIndex(0) ---- ->>> return exports.m2_instance1; -1->^^^^ -2 > ^^^^^^ -3 > ^ -4 > ^^^^^^^^^^^^^^^^^^^^ -5 > ^ -1->export function m2_f1() { - > -2 > return -3 > -4 > m2_instance1 -5 > ; -1->Emitted(10, 5) Source(8, 5) + SourceIndex(0) name (m2_f1) -2 >Emitted(10, 11) Source(8, 11) + SourceIndex(0) name (m2_f1) -3 >Emitted(10, 12) Source(8, 12) + SourceIndex(0) name (m2_f1) -4 >Emitted(10, 32) Source(8, 24) + SourceIndex(0) name (m2_f1) -5 >Emitted(10, 33) Source(8, 25) + SourceIndex(0) name (m2_f1) ---- ->>>} -1 > -2 >^ -3 > ^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -2 >} -1 >Emitted(11, 1) Source(9, 1) + SourceIndex(0) name (m2_f1) -2 >Emitted(11, 2) Source(9, 2) + SourceIndex(0) name (m2_f1) ---- ->>>exports.m2_f1 = m2_f1; -1-> -2 >^^^^^^^^^^^^^ -3 > ^^^^^^^^ -4 > ^ -5 > ^^^^^^^-> -1-> -2 >m2_f1 -3 > () { - > return m2_instance1; - > } -4 > -1->Emitted(12, 1) Source(7, 17) + SourceIndex(0) -2 >Emitted(12, 14) Source(7, 22) + SourceIndex(0) -3 >Emitted(12, 22) Source(9, 2) + SourceIndex(0) -4 >Emitted(12, 23) Source(9, 2) + SourceIndex(0) ---- ->>>//# sourceMappingURL=m2.js.map=================================================================== JsFile: outAndOutDirFile.js mapUrl: outAndOutDirFile.js.map sourceRoot: ../src/ diff --git a/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderSpecifyOutputFile/amd/diskFile0.js.map b/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderSpecifyOutputFile/amd/diskFile0.js.map deleted file mode 100644 index 414fa845b2e..00000000000 --- a/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderSpecifyOutputFile/amd/diskFile0.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"m2.js","sourceRoot":"../src/","sources":["outputdir_module_multifolder_ref/m2.ts"],"names":["m2_c1","m2_c1.constructor","m2_f1"],"mappings":";IAAW,aAAK,GAAG,EAAE,CAAC;IACtB;QAAAA;QAEAC,CAACA;QAADD,YAACA;IAADA,CAACA,AAFD,IAEC;IAFY,aAAK,QAEjB,CAAA;IAEU,oBAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACIE,MAAMA,CAACA,oBAAYA,CAACA;IACxBA,CAACA;IAFe,aAAK,QAEpB,CAAA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderSpecifyOutputFile/amd/diskFile1.js b/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderSpecifyOutputFile/amd/diskFile1.js deleted file mode 100644 index 144ad24e2de..00000000000 --- a/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderSpecifyOutputFile/amd/diskFile1.js +++ /dev/null @@ -1,15 +0,0 @@ -define(["require", "exports"], function (require, exports) { - exports.m2_a1 = 10; - var m2_c1 = (function () { - function m2_c1() { - } - return m2_c1; - })(); - exports.m2_c1 = m2_c1; - exports.m2_instance1 = new m2_c1(); - function m2_f1() { - return exports.m2_instance1; - } - exports.m2_f1 = m2_f1; -}); -//# sourceMappingURL=m2.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderSpecifyOutputFile/amd/diskFile2.d.ts b/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderSpecifyOutputFile/amd/diskFile2.d.ts deleted file mode 100644 index c09a3c0c32a..00000000000 --- a/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderSpecifyOutputFile/amd/diskFile2.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -export declare var m2_a1: number; -export declare class m2_c1 { - m2_c1_p1: number; -} -export declare var m2_instance1: m2_c1; -export declare function m2_f1(): m2_c1; diff --git a/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderSpecifyOutputFile/amd/ref/m1.d.ts b/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderSpecifyOutputFile/amd/ref/m1.d.ts deleted file mode 100644 index 4a53b24b156..00000000000 --- a/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderSpecifyOutputFile/amd/ref/m1.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -export declare var m1_a1: number; -export declare class m1_c1 { - m1_c1_p1: number; -} -export declare var m1_instance1: m1_c1; -export declare function m1_f1(): m1_c1; diff --git a/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderSpecifyOutputFile/amd/ref/m1.js b/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderSpecifyOutputFile/amd/ref/m1.js deleted file mode 100644 index bbaba444ba2..00000000000 --- a/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderSpecifyOutputFile/amd/ref/m1.js +++ /dev/null @@ -1,15 +0,0 @@ -define(["require", "exports"], function (require, exports) { - exports.m1_a1 = 10; - var m1_c1 = (function () { - function m1_c1() { - } - return m1_c1; - })(); - exports.m1_c1 = m1_c1; - exports.m1_instance1 = new m1_c1(); - function m1_f1() { - return exports.m1_instance1; - } - exports.m1_f1 = m1_f1; -}); -//# sourceMappingURL=m1.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderSpecifyOutputFile/amd/ref/m1.js.map b/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderSpecifyOutputFile/amd/ref/m1.js.map deleted file mode 100644 index 0cdc44d330d..00000000000 --- a/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderSpecifyOutputFile/amd/ref/m1.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"m1.js","sourceRoot":"../src/","sources":["outputdir_module_multifolder/ref/m1.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1"],"mappings":";IAAW,aAAK,GAAG,EAAE,CAAC;IACtB;QAAAA;QAEAC,CAACA;QAADD,YAACA;IAADA,CAACA,AAFD,IAEC;IAFY,aAAK,QAEjB,CAAA;IAEU,oBAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACIE,MAAMA,CAACA,oBAAYA,CAACA;IACxBA,CAACA;IAFe,aAAK,QAEpB,CAAA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderSpecifyOutputFile/amd/sourceRootRelativePathModuleMultifolderSpecifyOutputFile.json b/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderSpecifyOutputFile/amd/sourceRootRelativePathModuleMultifolderSpecifyOutputFile.json index 69a577baffd..77179246af5 100644 --- a/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderSpecifyOutputFile/amd/sourceRootRelativePathModuleMultifolderSpecifyOutputFile.json +++ b/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderSpecifyOutputFile/amd/sourceRootRelativePathModuleMultifolderSpecifyOutputFile.json @@ -16,15 +16,6 @@ "test.ts" ], "emittedFiles": [ - "ref/m1.js.map", - "ref/m1.js", - "ref/m1.d.ts", - "../outputdir_module_multifolder_ref/m2.js.map", - "../outputdir_module_multifolder_ref/m2.js", - "../outputdir_module_multifolder_ref/m2.d.ts", - "test.js.map", - "test.js", - "test.d.ts", "bin/test.js.map", "bin/test.js", "bin/test.d.ts" diff --git a/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderSpecifyOutputFile/amd/sourceRootRelativePathModuleMultifolderSpecifyOutputFile.sourcemap.txt b/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderSpecifyOutputFile/amd/sourceRootRelativePathModuleMultifolderSpecifyOutputFile.sourcemap.txt index b2923025e73..43c4340ba37 100644 --- a/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderSpecifyOutputFile/amd/sourceRootRelativePathModuleMultifolderSpecifyOutputFile.sourcemap.txt +++ b/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderSpecifyOutputFile/amd/sourceRootRelativePathModuleMultifolderSpecifyOutputFile.sourcemap.txt @@ -1,573 +1,4 @@ =================================================================== -JsFile: m1.js -mapUrl: m1.js.map -sourceRoot: ../src/ -sources: outputdir_module_multifolder/ref/m1.ts -=================================================================== -------------------------------------------------------------------- -emittedFile:ref/m1.js -sourceFile:outputdir_module_multifolder/ref/m1.ts -------------------------------------------------------------------- ->>>define(["require", "exports"], function (require, exports) { ->>> exports.m1_a1 = 10; -1 >^^^^ -2 > ^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^-> -1 >export var -2 > m1_a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(2, 5) Source(1, 12) + SourceIndex(0) -2 >Emitted(2, 18) Source(1, 17) + SourceIndex(0) -3 >Emitted(2, 21) Source(1, 20) + SourceIndex(0) -4 >Emitted(2, 23) Source(1, 22) + SourceIndex(0) -5 >Emitted(2, 24) Source(1, 23) + SourceIndex(0) ---- ->>> var m1_c1 = (function () { -1->^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^^^^-> -1-> - > -1->Emitted(3, 5) Source(2, 1) + SourceIndex(0) ---- ->>> function m1_c1() { -1->^^^^^^^^ -2 > ^^-> -1-> -1->Emitted(4, 9) Source(2, 1) + SourceIndex(0) name (m1_c1) ---- ->>> } -1->^^^^^^^^ -2 > ^ -3 > ^^^^^^^^^^^^^-> -1->export class m1_c1 { - > public m1_c1_p1: number; - > -2 > } -1->Emitted(5, 9) Source(4, 1) + SourceIndex(0) name (m1_c1.constructor) -2 >Emitted(5, 10) Source(4, 2) + SourceIndex(0) name (m1_c1.constructor) ---- ->>> return m1_c1; -1->^^^^^^^^ -2 > ^^^^^^^^^^^^ -1-> -2 > } -1->Emitted(6, 9) Source(4, 1) + SourceIndex(0) name (m1_c1) -2 >Emitted(6, 21) Source(4, 2) + SourceIndex(0) name (m1_c1) ---- ->>> })(); -1 >^^^^ -2 > ^ -3 > -4 > ^^^^ -5 > ^^^^^^^^^^^^^^^^^^-> -1 > -2 > } -3 > -4 > export class m1_c1 { - > public m1_c1_p1: number; - > } -1 >Emitted(7, 5) Source(4, 1) + SourceIndex(0) name (m1_c1) -2 >Emitted(7, 6) Source(4, 2) + SourceIndex(0) name (m1_c1) -3 >Emitted(7, 6) Source(2, 1) + SourceIndex(0) -4 >Emitted(7, 10) Source(4, 2) + SourceIndex(0) ---- ->>> exports.m1_c1 = m1_c1; -1->^^^^ -2 > ^^^^^^^^^^^^^ -3 > ^^^^^^^^ -4 > ^ -5 > ^^^^^^^^^^^^^^-> -1-> -2 > m1_c1 -3 > { - > public m1_c1_p1: number; - > } -4 > -1->Emitted(8, 5) Source(2, 14) + SourceIndex(0) -2 >Emitted(8, 18) Source(2, 19) + SourceIndex(0) -3 >Emitted(8, 26) Source(4, 2) + SourceIndex(0) -4 >Emitted(8, 27) Source(4, 2) + SourceIndex(0) ---- ->>> exports.m1_instance1 = new m1_c1(); -1->^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^^^ -5 > ^^^^^ -6 > ^^ -7 > ^ -1-> - > - >export var -2 > m1_instance1 -3 > = -4 > new -5 > m1_c1 -6 > () -7 > ; -1->Emitted(9, 5) Source(6, 12) + SourceIndex(0) -2 >Emitted(9, 25) Source(6, 24) + SourceIndex(0) -3 >Emitted(9, 28) Source(6, 27) + SourceIndex(0) -4 >Emitted(9, 32) Source(6, 31) + SourceIndex(0) -5 >Emitted(9, 37) Source(6, 36) + SourceIndex(0) -6 >Emitted(9, 39) Source(6, 38) + SourceIndex(0) -7 >Emitted(9, 40) Source(6, 39) + SourceIndex(0) ---- ->>> function m1_f1() { -1 >^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -1 >Emitted(10, 5) Source(7, 1) + SourceIndex(0) ---- ->>> return exports.m1_instance1; -1->^^^^^^^^ -2 > ^^^^^^ -3 > ^ -4 > ^^^^^^^^^^^^^^^^^^^^ -5 > ^ -1->export function m1_f1() { - > -2 > return -3 > -4 > m1_instance1 -5 > ; -1->Emitted(11, 9) Source(8, 5) + SourceIndex(0) name (m1_f1) -2 >Emitted(11, 15) Source(8, 11) + SourceIndex(0) name (m1_f1) -3 >Emitted(11, 16) Source(8, 12) + SourceIndex(0) name (m1_f1) -4 >Emitted(11, 36) Source(8, 24) + SourceIndex(0) name (m1_f1) -5 >Emitted(11, 37) Source(8, 25) + SourceIndex(0) name (m1_f1) ---- ->>> } -1 >^^^^ -2 > ^ -3 > ^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -2 > } -1 >Emitted(12, 5) Source(9, 1) + SourceIndex(0) name (m1_f1) -2 >Emitted(12, 6) Source(9, 2) + SourceIndex(0) name (m1_f1) ---- ->>> exports.m1_f1 = m1_f1; -1->^^^^ -2 > ^^^^^^^^^^^^^ -3 > ^^^^^^^^ -4 > ^ -1-> -2 > m1_f1 -3 > () { - > return m1_instance1; - > } -4 > -1->Emitted(13, 5) Source(7, 17) + SourceIndex(0) -2 >Emitted(13, 18) Source(7, 22) + SourceIndex(0) -3 >Emitted(13, 26) Source(9, 2) + SourceIndex(0) -4 >Emitted(13, 27) Source(9, 2) + SourceIndex(0) ---- ->>>}); ->>>//# sourceMappingURL=m1.js.map=================================================================== -JsFile: m2.js -mapUrl: m2.js.map -sourceRoot: ../src/ -sources: outputdir_module_multifolder_ref/m2.ts -=================================================================== -------------------------------------------------------------------- -emittedFile:diskFile1.js -sourceFile:outputdir_module_multifolder_ref/m2.ts -------------------------------------------------------------------- ->>>define(["require", "exports"], function (require, exports) { ->>> exports.m2_a1 = 10; -1 >^^^^ -2 > ^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^-> -1 >export var -2 > m2_a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(2, 5) Source(1, 12) + SourceIndex(0) -2 >Emitted(2, 18) Source(1, 17) + SourceIndex(0) -3 >Emitted(2, 21) Source(1, 20) + SourceIndex(0) -4 >Emitted(2, 23) Source(1, 22) + SourceIndex(0) -5 >Emitted(2, 24) Source(1, 23) + SourceIndex(0) ---- ->>> var m2_c1 = (function () { -1->^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^^^^-> -1-> - > -1->Emitted(3, 5) Source(2, 1) + SourceIndex(0) ---- ->>> function m2_c1() { -1->^^^^^^^^ -2 > ^^-> -1-> -1->Emitted(4, 9) Source(2, 1) + SourceIndex(0) name (m2_c1) ---- ->>> } -1->^^^^^^^^ -2 > ^ -3 > ^^^^^^^^^^^^^-> -1->export class m2_c1 { - > public m2_c1_p1: number; - > -2 > } -1->Emitted(5, 9) Source(4, 1) + SourceIndex(0) name (m2_c1.constructor) -2 >Emitted(5, 10) Source(4, 2) + SourceIndex(0) name (m2_c1.constructor) ---- ->>> return m2_c1; -1->^^^^^^^^ -2 > ^^^^^^^^^^^^ -1-> -2 > } -1->Emitted(6, 9) Source(4, 1) + SourceIndex(0) name (m2_c1) -2 >Emitted(6, 21) Source(4, 2) + SourceIndex(0) name (m2_c1) ---- ->>> })(); -1 >^^^^ -2 > ^ -3 > -4 > ^^^^ -5 > ^^^^^^^^^^^^^^^^^^-> -1 > -2 > } -3 > -4 > export class m2_c1 { - > public m2_c1_p1: number; - > } -1 >Emitted(7, 5) Source(4, 1) + SourceIndex(0) name (m2_c1) -2 >Emitted(7, 6) Source(4, 2) + SourceIndex(0) name (m2_c1) -3 >Emitted(7, 6) Source(2, 1) + SourceIndex(0) -4 >Emitted(7, 10) Source(4, 2) + SourceIndex(0) ---- ->>> exports.m2_c1 = m2_c1; -1->^^^^ -2 > ^^^^^^^^^^^^^ -3 > ^^^^^^^^ -4 > ^ -5 > ^^^^^^^^^^^^^^-> -1-> -2 > m2_c1 -3 > { - > public m2_c1_p1: number; - > } -4 > -1->Emitted(8, 5) Source(2, 14) + SourceIndex(0) -2 >Emitted(8, 18) Source(2, 19) + SourceIndex(0) -3 >Emitted(8, 26) Source(4, 2) + SourceIndex(0) -4 >Emitted(8, 27) Source(4, 2) + SourceIndex(0) ---- ->>> exports.m2_instance1 = new m2_c1(); -1->^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^^^ -5 > ^^^^^ -6 > ^^ -7 > ^ -1-> - > - >export var -2 > m2_instance1 -3 > = -4 > new -5 > m2_c1 -6 > () -7 > ; -1->Emitted(9, 5) Source(6, 12) + SourceIndex(0) -2 >Emitted(9, 25) Source(6, 24) + SourceIndex(0) -3 >Emitted(9, 28) Source(6, 27) + SourceIndex(0) -4 >Emitted(9, 32) Source(6, 31) + SourceIndex(0) -5 >Emitted(9, 37) Source(6, 36) + SourceIndex(0) -6 >Emitted(9, 39) Source(6, 38) + SourceIndex(0) -7 >Emitted(9, 40) Source(6, 39) + SourceIndex(0) ---- ->>> function m2_f1() { -1 >^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -1 >Emitted(10, 5) Source(7, 1) + SourceIndex(0) ---- ->>> return exports.m2_instance1; -1->^^^^^^^^ -2 > ^^^^^^ -3 > ^ -4 > ^^^^^^^^^^^^^^^^^^^^ -5 > ^ -1->export function m2_f1() { - > -2 > return -3 > -4 > m2_instance1 -5 > ; -1->Emitted(11, 9) Source(8, 5) + SourceIndex(0) name (m2_f1) -2 >Emitted(11, 15) Source(8, 11) + SourceIndex(0) name (m2_f1) -3 >Emitted(11, 16) Source(8, 12) + SourceIndex(0) name (m2_f1) -4 >Emitted(11, 36) Source(8, 24) + SourceIndex(0) name (m2_f1) -5 >Emitted(11, 37) Source(8, 25) + SourceIndex(0) name (m2_f1) ---- ->>> } -1 >^^^^ -2 > ^ -3 > ^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -2 > } -1 >Emitted(12, 5) Source(9, 1) + SourceIndex(0) name (m2_f1) -2 >Emitted(12, 6) Source(9, 2) + SourceIndex(0) name (m2_f1) ---- ->>> exports.m2_f1 = m2_f1; -1->^^^^ -2 > ^^^^^^^^^^^^^ -3 > ^^^^^^^^ -4 > ^ -1-> -2 > m2_f1 -3 > () { - > return m2_instance1; - > } -4 > -1->Emitted(13, 5) Source(7, 17) + SourceIndex(0) -2 >Emitted(13, 18) Source(7, 22) + SourceIndex(0) -3 >Emitted(13, 26) Source(9, 2) + SourceIndex(0) -4 >Emitted(13, 27) Source(9, 2) + SourceIndex(0) ---- ->>>}); ->>>//# sourceMappingURL=m2.js.map=================================================================== -JsFile: test.js -mapUrl: test.js.map -sourceRoot: ../src/ -sources: outputdir_module_multifolder/test.ts -=================================================================== -------------------------------------------------------------------- -emittedFile:test.js -sourceFile:outputdir_module_multifolder/test.ts -------------------------------------------------------------------- ->>>define(["require", "exports", "ref/m1", "../outputdir_module_multifolder_ref/m2"], function (require, exports, m1, m2) { ->>> exports.a1 = 10; -1 >^^^^ -2 > ^^^^^^^^^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^-> -1 >import m1 = require("ref/m1"); - >import m2 = require("../outputdir_module_multifolder_ref/m2"); - >export var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(2, 5) Source(3, 12) + SourceIndex(0) -2 >Emitted(2, 15) Source(3, 14) + SourceIndex(0) -3 >Emitted(2, 18) Source(3, 17) + SourceIndex(0) -4 >Emitted(2, 20) Source(3, 19) + SourceIndex(0) -5 >Emitted(2, 21) Source(3, 20) + SourceIndex(0) ---- ->>> var c1 = (function () { -1->^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^-> -1-> - > -1->Emitted(3, 5) Source(4, 1) + SourceIndex(0) ---- ->>> function c1() { -1->^^^^^^^^ -2 > ^^-> -1-> -1->Emitted(4, 9) Source(4, 1) + SourceIndex(0) name (c1) ---- ->>> } -1->^^^^^^^^ -2 > ^ -3 > ^^^^^^^^^^-> -1->export class c1 { - > public p1: number; - > -2 > } -1->Emitted(5, 9) Source(6, 1) + SourceIndex(0) name (c1.constructor) -2 >Emitted(5, 10) Source(6, 2) + SourceIndex(0) name (c1.constructor) ---- ->>> return c1; -1->^^^^^^^^ -2 > ^^^^^^^^^ -1-> -2 > } -1->Emitted(6, 9) Source(6, 1) + SourceIndex(0) name (c1) -2 >Emitted(6, 18) Source(6, 2) + SourceIndex(0) name (c1) ---- ->>> })(); -1 >^^^^ -2 > ^ -3 > -4 > ^^^^ -5 > ^^^^^^^^^^^^-> -1 > -2 > } -3 > -4 > export class c1 { - > public p1: number; - > } -1 >Emitted(7, 5) Source(6, 1) + SourceIndex(0) name (c1) -2 >Emitted(7, 6) Source(6, 2) + SourceIndex(0) name (c1) -3 >Emitted(7, 6) Source(4, 1) + SourceIndex(0) -4 >Emitted(7, 10) Source(6, 2) + SourceIndex(0) ---- ->>> exports.c1 = c1; -1->^^^^ -2 > ^^^^^^^^^^ -3 > ^^^^^ -4 > ^ -5 > ^^^^^^^^^^^^^^-> -1-> -2 > c1 -3 > { - > public p1: number; - > } -4 > -1->Emitted(8, 5) Source(4, 14) + SourceIndex(0) -2 >Emitted(8, 15) Source(4, 16) + SourceIndex(0) -3 >Emitted(8, 20) Source(6, 2) + SourceIndex(0) -4 >Emitted(8, 21) Source(6, 2) + SourceIndex(0) ---- ->>> exports.instance1 = new c1(); -1->^^^^ -2 > ^^^^^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^^^ -5 > ^^ -6 > ^^ -7 > ^ -1-> - > - >export var -2 > instance1 -3 > = -4 > new -5 > c1 -6 > () -7 > ; -1->Emitted(9, 5) Source(8, 12) + SourceIndex(0) -2 >Emitted(9, 22) Source(8, 21) + SourceIndex(0) -3 >Emitted(9, 25) Source(8, 24) + SourceIndex(0) -4 >Emitted(9, 29) Source(8, 28) + SourceIndex(0) -5 >Emitted(9, 31) Source(8, 30) + SourceIndex(0) -6 >Emitted(9, 33) Source(8, 32) + SourceIndex(0) -7 >Emitted(9, 34) Source(8, 33) + SourceIndex(0) ---- ->>> function f1() { -1 >^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -1 >Emitted(10, 5) Source(9, 1) + SourceIndex(0) ---- ->>> return exports.instance1; -1->^^^^^^^^ -2 > ^^^^^^ -3 > ^ -4 > ^^^^^^^^^^^^^^^^^ -5 > ^ -1->export function f1() { - > -2 > return -3 > -4 > instance1 -5 > ; -1->Emitted(11, 9) Source(10, 5) + SourceIndex(0) name (f1) -2 >Emitted(11, 15) Source(10, 11) + SourceIndex(0) name (f1) -3 >Emitted(11, 16) Source(10, 12) + SourceIndex(0) name (f1) -4 >Emitted(11, 33) Source(10, 21) + SourceIndex(0) name (f1) -5 >Emitted(11, 34) Source(10, 22) + SourceIndex(0) name (f1) ---- ->>> } -1 >^^^^ -2 > ^ -3 > ^^^^^^^^^^^^^^^^-> -1 > - > -2 > } -1 >Emitted(12, 5) Source(11, 1) + SourceIndex(0) name (f1) -2 >Emitted(12, 6) Source(11, 2) + SourceIndex(0) name (f1) ---- ->>> exports.f1 = f1; -1->^^^^ -2 > ^^^^^^^^^^ -3 > ^^^^^ -4 > ^ -5 > ^^^^^^^-> -1-> -2 > f1 -3 > () { - > return instance1; - > } -4 > -1->Emitted(13, 5) Source(9, 17) + SourceIndex(0) -2 >Emitted(13, 15) Source(9, 19) + SourceIndex(0) -3 >Emitted(13, 20) Source(11, 2) + SourceIndex(0) -4 >Emitted(13, 21) Source(11, 2) + SourceIndex(0) ---- ->>> exports.a2 = m1.m1_c1; -1->^^^^ -2 > ^^^^^^^^^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^ -7 > ^ -8 > ^-> -1-> - > - >export var -2 > a2 -3 > = -4 > m1 -5 > . -6 > m1_c1 -7 > ; -1->Emitted(14, 5) Source(13, 12) + SourceIndex(0) -2 >Emitted(14, 15) Source(13, 14) + SourceIndex(0) -3 >Emitted(14, 18) Source(13, 17) + SourceIndex(0) -4 >Emitted(14, 20) Source(13, 19) + SourceIndex(0) -5 >Emitted(14, 21) Source(13, 20) + SourceIndex(0) -6 >Emitted(14, 26) Source(13, 25) + SourceIndex(0) -7 >Emitted(14, 27) Source(13, 26) + SourceIndex(0) ---- ->>> exports.a3 = m2.m2_c1; -1->^^^^ -2 > ^^^^^^^^^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^ -7 > ^ -1-> - >export var -2 > a3 -3 > = -4 > m2 -5 > . -6 > m2_c1 -7 > ; -1->Emitted(15, 5) Source(14, 12) + SourceIndex(0) -2 >Emitted(15, 15) Source(14, 14) + SourceIndex(0) -3 >Emitted(15, 18) Source(14, 17) + SourceIndex(0) -4 >Emitted(15, 20) Source(14, 19) + SourceIndex(0) -5 >Emitted(15, 21) Source(14, 20) + SourceIndex(0) -6 >Emitted(15, 26) Source(14, 25) + SourceIndex(0) -7 >Emitted(15, 27) Source(14, 26) + SourceIndex(0) ---- ->>>}); ->>>//# sourceMappingURL=test.js.map=================================================================== JsFile: test.js mapUrl: test.js.map sourceRoot: ../src/ diff --git a/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderSpecifyOutputFile/amd/test.d.ts b/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderSpecifyOutputFile/amd/test.d.ts deleted file mode 100644 index 4afd4e69f2d..00000000000 --- a/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderSpecifyOutputFile/amd/test.d.ts +++ /dev/null @@ -1,10 +0,0 @@ -import m1 = require("ref/m1"); -import m2 = require("../outputdir_module_multifolder_ref/m2"); -export declare var a1: number; -export declare class c1 { - p1: number; -} -export declare var instance1: c1; -export declare function f1(): c1; -export declare var a2: typeof m1.m1_c1; -export declare var a3: typeof m2.m2_c1; diff --git a/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderSpecifyOutputFile/amd/test.js b/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderSpecifyOutputFile/amd/test.js deleted file mode 100644 index 5cca04a0f25..00000000000 --- a/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderSpecifyOutputFile/amd/test.js +++ /dev/null @@ -1,17 +0,0 @@ -define(["require", "exports", "ref/m1", "../outputdir_module_multifolder_ref/m2"], function (require, exports, m1, m2) { - exports.a1 = 10; - var c1 = (function () { - function c1() { - } - return c1; - })(); - exports.c1 = c1; - exports.instance1 = new c1(); - function f1() { - return exports.instance1; - } - exports.f1 = f1; - exports.a2 = m1.m1_c1; - exports.a3 = m2.m2_c1; -}); -//# sourceMappingURL=test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderSpecifyOutputFile/amd/test.js.map b/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderSpecifyOutputFile/amd/test.js.map deleted file mode 100644 index 20138821cfe..00000000000 --- a/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderSpecifyOutputFile/amd/test.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"test.js","sourceRoot":"../src/","sources":["outputdir_module_multifolder/test.ts"],"names":["c1","c1.constructor","f1"],"mappings":";IAEW,UAAE,GAAG,EAAE,CAAC;IACnB;QAAAA;QAEAC,CAACA;QAADD,SAACA;IAADA,CAACA,AAFD,IAEC;IAFY,UAAE,KAEd,CAAA;IAEU,iBAAS,GAAG,IAAI,EAAE,EAAE,CAAC;IAChC;QACIE,MAAMA,CAACA,iBAASA,CAACA;IACrBA,CAACA;IAFe,UAAE,KAEjB,CAAA;IAEU,UAAE,GAAG,EAAE,CAAC,KAAK,CAAC;IACd,UAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderSpecifyOutputFile/node/diskFile0.js.map b/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderSpecifyOutputFile/node/diskFile0.js.map deleted file mode 100644 index 92fd6e19cfb..00000000000 --- a/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderSpecifyOutputFile/node/diskFile0.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"m2.js","sourceRoot":"../src/","sources":["outputdir_module_multifolder_ref/m2.ts"],"names":["m2_c1","m2_c1.constructor","m2_f1"],"mappings":"AAAW,aAAK,GAAG,EAAE,CAAC;AACtB;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAFY,aAAK,QAEjB,CAAA;AAEU,oBAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACIE,MAAMA,CAACA,oBAAYA,CAACA;AACxBA,CAACA;AAFe,aAAK,QAEpB,CAAA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderSpecifyOutputFile/node/diskFile1.js b/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderSpecifyOutputFile/node/diskFile1.js deleted file mode 100644 index ec0a73b5af8..00000000000 --- a/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderSpecifyOutputFile/node/diskFile1.js +++ /dev/null @@ -1,13 +0,0 @@ -exports.m2_a1 = 10; -var m2_c1 = (function () { - function m2_c1() { - } - return m2_c1; -})(); -exports.m2_c1 = m2_c1; -exports.m2_instance1 = new m2_c1(); -function m2_f1() { - return exports.m2_instance1; -} -exports.m2_f1 = m2_f1; -//# sourceMappingURL=m2.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderSpecifyOutputFile/node/diskFile2.d.ts b/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderSpecifyOutputFile/node/diskFile2.d.ts deleted file mode 100644 index c09a3c0c32a..00000000000 --- a/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderSpecifyOutputFile/node/diskFile2.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -export declare var m2_a1: number; -export declare class m2_c1 { - m2_c1_p1: number; -} -export declare var m2_instance1: m2_c1; -export declare function m2_f1(): m2_c1; diff --git a/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderSpecifyOutputFile/node/ref/m1.d.ts b/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderSpecifyOutputFile/node/ref/m1.d.ts deleted file mode 100644 index 4a53b24b156..00000000000 --- a/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderSpecifyOutputFile/node/ref/m1.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -export declare var m1_a1: number; -export declare class m1_c1 { - m1_c1_p1: number; -} -export declare var m1_instance1: m1_c1; -export declare function m1_f1(): m1_c1; diff --git a/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderSpecifyOutputFile/node/ref/m1.js b/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderSpecifyOutputFile/node/ref/m1.js deleted file mode 100644 index 1b4470e2b37..00000000000 --- a/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderSpecifyOutputFile/node/ref/m1.js +++ /dev/null @@ -1,13 +0,0 @@ -exports.m1_a1 = 10; -var m1_c1 = (function () { - function m1_c1() { - } - return m1_c1; -})(); -exports.m1_c1 = m1_c1; -exports.m1_instance1 = new m1_c1(); -function m1_f1() { - return exports.m1_instance1; -} -exports.m1_f1 = m1_f1; -//# sourceMappingURL=m1.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderSpecifyOutputFile/node/ref/m1.js.map b/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderSpecifyOutputFile/node/ref/m1.js.map deleted file mode 100644 index 292dcb61933..00000000000 --- a/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderSpecifyOutputFile/node/ref/m1.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"m1.js","sourceRoot":"../src/","sources":["outputdir_module_multifolder/ref/m1.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1"],"mappings":"AAAW,aAAK,GAAG,EAAE,CAAC;AACtB;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAFY,aAAK,QAEjB,CAAA;AAEU,oBAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACIE,MAAMA,CAACA,oBAAYA,CAACA;AACxBA,CAACA;AAFe,aAAK,QAEpB,CAAA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderSpecifyOutputFile/node/sourceRootRelativePathModuleMultifolderSpecifyOutputFile.json b/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderSpecifyOutputFile/node/sourceRootRelativePathModuleMultifolderSpecifyOutputFile.json index 69a577baffd..77179246af5 100644 --- a/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderSpecifyOutputFile/node/sourceRootRelativePathModuleMultifolderSpecifyOutputFile.json +++ b/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderSpecifyOutputFile/node/sourceRootRelativePathModuleMultifolderSpecifyOutputFile.json @@ -16,15 +16,6 @@ "test.ts" ], "emittedFiles": [ - "ref/m1.js.map", - "ref/m1.js", - "ref/m1.d.ts", - "../outputdir_module_multifolder_ref/m2.js.map", - "../outputdir_module_multifolder_ref/m2.js", - "../outputdir_module_multifolder_ref/m2.d.ts", - "test.js.map", - "test.js", - "test.d.ts", "bin/test.js.map", "bin/test.js", "bin/test.d.ts" diff --git a/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderSpecifyOutputFile/node/sourceRootRelativePathModuleMultifolderSpecifyOutputFile.sourcemap.txt b/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderSpecifyOutputFile/node/sourceRootRelativePathModuleMultifolderSpecifyOutputFile.sourcemap.txt index c0077fe3214..7ef7adace73 100644 --- a/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderSpecifyOutputFile/node/sourceRootRelativePathModuleMultifolderSpecifyOutputFile.sourcemap.txt +++ b/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderSpecifyOutputFile/node/sourceRootRelativePathModuleMultifolderSpecifyOutputFile.sourcemap.txt @@ -1,617 +1,4 @@ =================================================================== -JsFile: m1.js -mapUrl: m1.js.map -sourceRoot: ../src/ -sources: outputdir_module_multifolder/ref/m1.ts -=================================================================== -------------------------------------------------------------------- -emittedFile:ref/m1.js -sourceFile:outputdir_module_multifolder/ref/m1.ts -------------------------------------------------------------------- ->>>exports.m1_a1 = 10; -1 > -2 >^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^-> -1 >export var -2 >m1_a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(1, 1) Source(1, 12) + SourceIndex(0) -2 >Emitted(1, 14) Source(1, 17) + SourceIndex(0) -3 >Emitted(1, 17) Source(1, 20) + SourceIndex(0) -4 >Emitted(1, 19) Source(1, 22) + SourceIndex(0) -5 >Emitted(1, 20) Source(1, 23) + SourceIndex(0) ---- ->>>var m1_c1 = (function () { -1-> -2 >^^^^^^^^^^^^^^^^^^^^^^^-> -1-> - > -1->Emitted(2, 1) Source(2, 1) + SourceIndex(0) ---- ->>> function m1_c1() { -1->^^^^ -2 > ^^-> -1-> -1->Emitted(3, 5) Source(2, 1) + SourceIndex(0) name (m1_c1) ---- ->>> } -1->^^^^ -2 > ^ -3 > ^^^^^^^^^^^^^-> -1->export class m1_c1 { - > public m1_c1_p1: number; - > -2 > } -1->Emitted(4, 5) Source(4, 1) + SourceIndex(0) name (m1_c1.constructor) -2 >Emitted(4, 6) Source(4, 2) + SourceIndex(0) name (m1_c1.constructor) ---- ->>> return m1_c1; -1->^^^^ -2 > ^^^^^^^^^^^^ -1-> -2 > } -1->Emitted(5, 5) Source(4, 1) + SourceIndex(0) name (m1_c1) -2 >Emitted(5, 17) Source(4, 2) + SourceIndex(0) name (m1_c1) ---- ->>>})(); -1 > -2 >^ -3 > -4 > ^^^^ -5 > ^^^^^^^^^^^^^^^^^^-> -1 > -2 >} -3 > -4 > export class m1_c1 { - > public m1_c1_p1: number; - > } -1 >Emitted(6, 1) Source(4, 1) + SourceIndex(0) name (m1_c1) -2 >Emitted(6, 2) Source(4, 2) + SourceIndex(0) name (m1_c1) -3 >Emitted(6, 2) Source(2, 1) + SourceIndex(0) -4 >Emitted(6, 6) Source(4, 2) + SourceIndex(0) ---- ->>>exports.m1_c1 = m1_c1; -1-> -2 >^^^^^^^^^^^^^ -3 > ^^^^^^^^ -4 > ^ -5 > ^^^^^^^^^^^^^^-> -1-> -2 >m1_c1 -3 > { - > public m1_c1_p1: number; - > } -4 > -1->Emitted(7, 1) Source(2, 14) + SourceIndex(0) -2 >Emitted(7, 14) Source(2, 19) + SourceIndex(0) -3 >Emitted(7, 22) Source(4, 2) + SourceIndex(0) -4 >Emitted(7, 23) Source(4, 2) + SourceIndex(0) ---- ->>>exports.m1_instance1 = new m1_c1(); -1-> -2 >^^^^^^^^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^^^ -5 > ^^^^^ -6 > ^^ -7 > ^ -1-> - > - >export var -2 >m1_instance1 -3 > = -4 > new -5 > m1_c1 -6 > () -7 > ; -1->Emitted(8, 1) Source(6, 12) + SourceIndex(0) -2 >Emitted(8, 21) Source(6, 24) + SourceIndex(0) -3 >Emitted(8, 24) Source(6, 27) + SourceIndex(0) -4 >Emitted(8, 28) Source(6, 31) + SourceIndex(0) -5 >Emitted(8, 33) Source(6, 36) + SourceIndex(0) -6 >Emitted(8, 35) Source(6, 38) + SourceIndex(0) -7 >Emitted(8, 36) Source(6, 39) + SourceIndex(0) ---- ->>>function m1_f1() { -1 > -2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -1 >Emitted(9, 1) Source(7, 1) + SourceIndex(0) ---- ->>> return exports.m1_instance1; -1->^^^^ -2 > ^^^^^^ -3 > ^ -4 > ^^^^^^^^^^^^^^^^^^^^ -5 > ^ -1->export function m1_f1() { - > -2 > return -3 > -4 > m1_instance1 -5 > ; -1->Emitted(10, 5) Source(8, 5) + SourceIndex(0) name (m1_f1) -2 >Emitted(10, 11) Source(8, 11) + SourceIndex(0) name (m1_f1) -3 >Emitted(10, 12) Source(8, 12) + SourceIndex(0) name (m1_f1) -4 >Emitted(10, 32) Source(8, 24) + SourceIndex(0) name (m1_f1) -5 >Emitted(10, 33) Source(8, 25) + SourceIndex(0) name (m1_f1) ---- ->>>} -1 > -2 >^ -3 > ^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -2 >} -1 >Emitted(11, 1) Source(9, 1) + SourceIndex(0) name (m1_f1) -2 >Emitted(11, 2) Source(9, 2) + SourceIndex(0) name (m1_f1) ---- ->>>exports.m1_f1 = m1_f1; -1-> -2 >^^^^^^^^^^^^^ -3 > ^^^^^^^^ -4 > ^ -5 > ^^^^^^^-> -1-> -2 >m1_f1 -3 > () { - > return m1_instance1; - > } -4 > -1->Emitted(12, 1) Source(7, 17) + SourceIndex(0) -2 >Emitted(12, 14) Source(7, 22) + SourceIndex(0) -3 >Emitted(12, 22) Source(9, 2) + SourceIndex(0) -4 >Emitted(12, 23) Source(9, 2) + SourceIndex(0) ---- ->>>//# sourceMappingURL=m1.js.map=================================================================== -JsFile: m2.js -mapUrl: m2.js.map -sourceRoot: ../src/ -sources: outputdir_module_multifolder_ref/m2.ts -=================================================================== -------------------------------------------------------------------- -emittedFile:diskFile1.js -sourceFile:outputdir_module_multifolder_ref/m2.ts -------------------------------------------------------------------- ->>>exports.m2_a1 = 10; -1 > -2 >^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^-> -1 >export var -2 >m2_a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(1, 1) Source(1, 12) + SourceIndex(0) -2 >Emitted(1, 14) Source(1, 17) + SourceIndex(0) -3 >Emitted(1, 17) Source(1, 20) + SourceIndex(0) -4 >Emitted(1, 19) Source(1, 22) + SourceIndex(0) -5 >Emitted(1, 20) Source(1, 23) + SourceIndex(0) ---- ->>>var m2_c1 = (function () { -1-> -2 >^^^^^^^^^^^^^^^^^^^^^^^-> -1-> - > -1->Emitted(2, 1) Source(2, 1) + SourceIndex(0) ---- ->>> function m2_c1() { -1->^^^^ -2 > ^^-> -1-> -1->Emitted(3, 5) Source(2, 1) + SourceIndex(0) name (m2_c1) ---- ->>> } -1->^^^^ -2 > ^ -3 > ^^^^^^^^^^^^^-> -1->export class m2_c1 { - > public m2_c1_p1: number; - > -2 > } -1->Emitted(4, 5) Source(4, 1) + SourceIndex(0) name (m2_c1.constructor) -2 >Emitted(4, 6) Source(4, 2) + SourceIndex(0) name (m2_c1.constructor) ---- ->>> return m2_c1; -1->^^^^ -2 > ^^^^^^^^^^^^ -1-> -2 > } -1->Emitted(5, 5) Source(4, 1) + SourceIndex(0) name (m2_c1) -2 >Emitted(5, 17) Source(4, 2) + SourceIndex(0) name (m2_c1) ---- ->>>})(); -1 > -2 >^ -3 > -4 > ^^^^ -5 > ^^^^^^^^^^^^^^^^^^-> -1 > -2 >} -3 > -4 > export class m2_c1 { - > public m2_c1_p1: number; - > } -1 >Emitted(6, 1) Source(4, 1) + SourceIndex(0) name (m2_c1) -2 >Emitted(6, 2) Source(4, 2) + SourceIndex(0) name (m2_c1) -3 >Emitted(6, 2) Source(2, 1) + SourceIndex(0) -4 >Emitted(6, 6) Source(4, 2) + SourceIndex(0) ---- ->>>exports.m2_c1 = m2_c1; -1-> -2 >^^^^^^^^^^^^^ -3 > ^^^^^^^^ -4 > ^ -5 > ^^^^^^^^^^^^^^-> -1-> -2 >m2_c1 -3 > { - > public m2_c1_p1: number; - > } -4 > -1->Emitted(7, 1) Source(2, 14) + SourceIndex(0) -2 >Emitted(7, 14) Source(2, 19) + SourceIndex(0) -3 >Emitted(7, 22) Source(4, 2) + SourceIndex(0) -4 >Emitted(7, 23) Source(4, 2) + SourceIndex(0) ---- ->>>exports.m2_instance1 = new m2_c1(); -1-> -2 >^^^^^^^^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^^^ -5 > ^^^^^ -6 > ^^ -7 > ^ -1-> - > - >export var -2 >m2_instance1 -3 > = -4 > new -5 > m2_c1 -6 > () -7 > ; -1->Emitted(8, 1) Source(6, 12) + SourceIndex(0) -2 >Emitted(8, 21) Source(6, 24) + SourceIndex(0) -3 >Emitted(8, 24) Source(6, 27) + SourceIndex(0) -4 >Emitted(8, 28) Source(6, 31) + SourceIndex(0) -5 >Emitted(8, 33) Source(6, 36) + SourceIndex(0) -6 >Emitted(8, 35) Source(6, 38) + SourceIndex(0) -7 >Emitted(8, 36) Source(6, 39) + SourceIndex(0) ---- ->>>function m2_f1() { -1 > -2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -1 >Emitted(9, 1) Source(7, 1) + SourceIndex(0) ---- ->>> return exports.m2_instance1; -1->^^^^ -2 > ^^^^^^ -3 > ^ -4 > ^^^^^^^^^^^^^^^^^^^^ -5 > ^ -1->export function m2_f1() { - > -2 > return -3 > -4 > m2_instance1 -5 > ; -1->Emitted(10, 5) Source(8, 5) + SourceIndex(0) name (m2_f1) -2 >Emitted(10, 11) Source(8, 11) + SourceIndex(0) name (m2_f1) -3 >Emitted(10, 12) Source(8, 12) + SourceIndex(0) name (m2_f1) -4 >Emitted(10, 32) Source(8, 24) + SourceIndex(0) name (m2_f1) -5 >Emitted(10, 33) Source(8, 25) + SourceIndex(0) name (m2_f1) ---- ->>>} -1 > -2 >^ -3 > ^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -2 >} -1 >Emitted(11, 1) Source(9, 1) + SourceIndex(0) name (m2_f1) -2 >Emitted(11, 2) Source(9, 2) + SourceIndex(0) name (m2_f1) ---- ->>>exports.m2_f1 = m2_f1; -1-> -2 >^^^^^^^^^^^^^ -3 > ^^^^^^^^ -4 > ^ -5 > ^^^^^^^-> -1-> -2 >m2_f1 -3 > () { - > return m2_instance1; - > } -4 > -1->Emitted(12, 1) Source(7, 17) + SourceIndex(0) -2 >Emitted(12, 14) Source(7, 22) + SourceIndex(0) -3 >Emitted(12, 22) Source(9, 2) + SourceIndex(0) -4 >Emitted(12, 23) Source(9, 2) + SourceIndex(0) ---- ->>>//# sourceMappingURL=m2.js.map=================================================================== -JsFile: test.js -mapUrl: test.js.map -sourceRoot: ../src/ -sources: outputdir_module_multifolder/test.ts -=================================================================== -------------------------------------------------------------------- -emittedFile:test.js -sourceFile:outputdir_module_multifolder/test.ts -------------------------------------------------------------------- ->>>var m1 = require("ref/m1"); -1 > -2 >^^^^ -3 > ^^ -4 > ^^^^^^^^^^^ -5 > ^^^^^^^^ -6 > ^ -7 > ^ -8 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 > -2 >import -3 > m1 -4 > = require( -5 > "ref/m1" -6 > ) -7 > ; -1 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) -2 >Emitted(1, 5) Source(1, 8) + SourceIndex(0) -3 >Emitted(1, 7) Source(1, 10) + SourceIndex(0) -4 >Emitted(1, 18) Source(1, 21) + SourceIndex(0) -5 >Emitted(1, 26) Source(1, 29) + SourceIndex(0) -6 >Emitted(1, 27) Source(1, 30) + SourceIndex(0) -7 >Emitted(1, 28) Source(1, 31) + SourceIndex(0) ---- ->>>var m2 = require("../outputdir_module_multifolder_ref/m2"); -1-> -2 >^^^^ -3 > ^^ -4 > ^^^^^^^^^^^ -5 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -6 > ^ -7 > ^ -1-> - > -2 >import -3 > m2 -4 > = require( -5 > "../outputdir_module_multifolder_ref/m2" -6 > ) -7 > ; -1->Emitted(2, 1) Source(2, 1) + SourceIndex(0) -2 >Emitted(2, 5) Source(2, 8) + SourceIndex(0) -3 >Emitted(2, 7) Source(2, 10) + SourceIndex(0) -4 >Emitted(2, 18) Source(2, 21) + SourceIndex(0) -5 >Emitted(2, 58) Source(2, 61) + SourceIndex(0) -6 >Emitted(2, 59) Source(2, 62) + SourceIndex(0) -7 >Emitted(2, 60) Source(2, 63) + SourceIndex(0) ---- ->>>exports.a1 = 10; -1 > -2 >^^^^^^^^^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^-> -1 > - >export var -2 >a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(3, 1) Source(3, 12) + SourceIndex(0) -2 >Emitted(3, 11) Source(3, 14) + SourceIndex(0) -3 >Emitted(3, 14) Source(3, 17) + SourceIndex(0) -4 >Emitted(3, 16) Source(3, 19) + SourceIndex(0) -5 >Emitted(3, 17) Source(3, 20) + SourceIndex(0) ---- ->>>var c1 = (function () { -1-> -2 >^^^^^^^^^^^^^^^^^^^^-> -1-> - > -1->Emitted(4, 1) Source(4, 1) + SourceIndex(0) ---- ->>> function c1() { -1->^^^^ -2 > ^^-> -1-> -1->Emitted(5, 5) Source(4, 1) + SourceIndex(0) name (c1) ---- ->>> } -1->^^^^ -2 > ^ -3 > ^^^^^^^^^^-> -1->export class c1 { - > public p1: number; - > -2 > } -1->Emitted(6, 5) Source(6, 1) + SourceIndex(0) name (c1.constructor) -2 >Emitted(6, 6) Source(6, 2) + SourceIndex(0) name (c1.constructor) ---- ->>> return c1; -1->^^^^ -2 > ^^^^^^^^^ -1-> -2 > } -1->Emitted(7, 5) Source(6, 1) + SourceIndex(0) name (c1) -2 >Emitted(7, 14) Source(6, 2) + SourceIndex(0) name (c1) ---- ->>>})(); -1 > -2 >^ -3 > -4 > ^^^^ -5 > ^^^^^^^^^^^^-> -1 > -2 >} -3 > -4 > export class c1 { - > public p1: number; - > } -1 >Emitted(8, 1) Source(6, 1) + SourceIndex(0) name (c1) -2 >Emitted(8, 2) Source(6, 2) + SourceIndex(0) name (c1) -3 >Emitted(8, 2) Source(4, 1) + SourceIndex(0) -4 >Emitted(8, 6) Source(6, 2) + SourceIndex(0) ---- ->>>exports.c1 = c1; -1-> -2 >^^^^^^^^^^ -3 > ^^^^^ -4 > ^ -5 > ^^^^^^^^^^^^^^-> -1-> -2 >c1 -3 > { - > public p1: number; - > } -4 > -1->Emitted(9, 1) Source(4, 14) + SourceIndex(0) -2 >Emitted(9, 11) Source(4, 16) + SourceIndex(0) -3 >Emitted(9, 16) Source(6, 2) + SourceIndex(0) -4 >Emitted(9, 17) Source(6, 2) + SourceIndex(0) ---- ->>>exports.instance1 = new c1(); -1-> -2 >^^^^^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^^^ -5 > ^^ -6 > ^^ -7 > ^ -1-> - > - >export var -2 >instance1 -3 > = -4 > new -5 > c1 -6 > () -7 > ; -1->Emitted(10, 1) Source(8, 12) + SourceIndex(0) -2 >Emitted(10, 18) Source(8, 21) + SourceIndex(0) -3 >Emitted(10, 21) Source(8, 24) + SourceIndex(0) -4 >Emitted(10, 25) Source(8, 28) + SourceIndex(0) -5 >Emitted(10, 27) Source(8, 30) + SourceIndex(0) -6 >Emitted(10, 29) Source(8, 32) + SourceIndex(0) -7 >Emitted(10, 30) Source(8, 33) + SourceIndex(0) ---- ->>>function f1() { -1 > -2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -1 >Emitted(11, 1) Source(9, 1) + SourceIndex(0) ---- ->>> return exports.instance1; -1->^^^^ -2 > ^^^^^^ -3 > ^ -4 > ^^^^^^^^^^^^^^^^^ -5 > ^ -1->export function f1() { - > -2 > return -3 > -4 > instance1 -5 > ; -1->Emitted(12, 5) Source(10, 5) + SourceIndex(0) name (f1) -2 >Emitted(12, 11) Source(10, 11) + SourceIndex(0) name (f1) -3 >Emitted(12, 12) Source(10, 12) + SourceIndex(0) name (f1) -4 >Emitted(12, 29) Source(10, 21) + SourceIndex(0) name (f1) -5 >Emitted(12, 30) Source(10, 22) + SourceIndex(0) name (f1) ---- ->>>} -1 > -2 >^ -3 > ^^^^^^^^^^^^^^^^-> -1 > - > -2 >} -1 >Emitted(13, 1) Source(11, 1) + SourceIndex(0) name (f1) -2 >Emitted(13, 2) Source(11, 2) + SourceIndex(0) name (f1) ---- ->>>exports.f1 = f1; -1-> -2 >^^^^^^^^^^ -3 > ^^^^^ -4 > ^ -5 > ^^^^^^^-> -1-> -2 >f1 -3 > () { - > return instance1; - > } -4 > -1->Emitted(14, 1) Source(9, 17) + SourceIndex(0) -2 >Emitted(14, 11) Source(9, 19) + SourceIndex(0) -3 >Emitted(14, 16) Source(11, 2) + SourceIndex(0) -4 >Emitted(14, 17) Source(11, 2) + SourceIndex(0) ---- ->>>exports.a2 = m1.m1_c1; -1-> -2 >^^^^^^^^^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^ -7 > ^ -8 > ^-> -1-> - > - >export var -2 >a2 -3 > = -4 > m1 -5 > . -6 > m1_c1 -7 > ; -1->Emitted(15, 1) Source(13, 12) + SourceIndex(0) -2 >Emitted(15, 11) Source(13, 14) + SourceIndex(0) -3 >Emitted(15, 14) Source(13, 17) + SourceIndex(0) -4 >Emitted(15, 16) Source(13, 19) + SourceIndex(0) -5 >Emitted(15, 17) Source(13, 20) + SourceIndex(0) -6 >Emitted(15, 22) Source(13, 25) + SourceIndex(0) -7 >Emitted(15, 23) Source(13, 26) + SourceIndex(0) ---- ->>>exports.a3 = m2.m2_c1; -1-> -2 >^^^^^^^^^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^ -7 > ^ -8 > ^^^^^^^^^-> -1-> - >export var -2 >a3 -3 > = -4 > m2 -5 > . -6 > m2_c1 -7 > ; -1->Emitted(16, 1) Source(14, 12) + SourceIndex(0) -2 >Emitted(16, 11) Source(14, 14) + SourceIndex(0) -3 >Emitted(16, 14) Source(14, 17) + SourceIndex(0) -4 >Emitted(16, 16) Source(14, 19) + SourceIndex(0) -5 >Emitted(16, 17) Source(14, 20) + SourceIndex(0) -6 >Emitted(16, 22) Source(14, 25) + SourceIndex(0) -7 >Emitted(16, 23) Source(14, 26) + SourceIndex(0) ---- ->>>//# sourceMappingURL=test.js.map=================================================================== JsFile: test.js mapUrl: test.js.map sourceRoot: ../src/ diff --git a/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderSpecifyOutputFile/node/test.d.ts b/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderSpecifyOutputFile/node/test.d.ts deleted file mode 100644 index 4afd4e69f2d..00000000000 --- a/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderSpecifyOutputFile/node/test.d.ts +++ /dev/null @@ -1,10 +0,0 @@ -import m1 = require("ref/m1"); -import m2 = require("../outputdir_module_multifolder_ref/m2"); -export declare var a1: number; -export declare class c1 { - p1: number; -} -export declare var instance1: c1; -export declare function f1(): c1; -export declare var a2: typeof m1.m1_c1; -export declare var a3: typeof m2.m2_c1; diff --git a/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderSpecifyOutputFile/node/test.js b/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderSpecifyOutputFile/node/test.js deleted file mode 100644 index 14c09e444a5..00000000000 --- a/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderSpecifyOutputFile/node/test.js +++ /dev/null @@ -1,17 +0,0 @@ -var m1 = require("ref/m1"); -var m2 = require("../outputdir_module_multifolder_ref/m2"); -exports.a1 = 10; -var c1 = (function () { - function c1() { - } - return c1; -})(); -exports.c1 = c1; -exports.instance1 = new c1(); -function f1() { - return exports.instance1; -} -exports.f1 = f1; -exports.a2 = m1.m1_c1; -exports.a3 = m2.m2_c1; -//# sourceMappingURL=test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderSpecifyOutputFile/node/test.js.map b/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderSpecifyOutputFile/node/test.js.map deleted file mode 100644 index a603394fc15..00000000000 --- a/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderSpecifyOutputFile/node/test.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"test.js","sourceRoot":"../src/","sources":["outputdir_module_multifolder/test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AAAA,IAAO,EAAE,WAAW,QAAQ,CAAC,CAAC;AAC9B,IAAO,EAAE,WAAW,wCAAwC,CAAC,CAAC;AACnD,UAAE,GAAG,EAAE,CAAC;AACnB;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAFY,UAAE,KAEd,CAAA;AAEU,iBAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AAChC;IACIE,MAAMA,CAACA,iBAASA,CAACA;AACrBA,CAACA;AAFe,UAAE,KAEjB,CAAA;AAEU,UAAE,GAAG,EAAE,CAAC,KAAK,CAAC;AACd,UAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootRelativePathModuleSimpleSpecifyOutputFile/amd/m1.d.ts b/tests/baselines/reference/project/sourceRootRelativePathModuleSimpleSpecifyOutputFile/amd/m1.d.ts deleted file mode 100644 index 4a53b24b156..00000000000 --- a/tests/baselines/reference/project/sourceRootRelativePathModuleSimpleSpecifyOutputFile/amd/m1.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -export declare var m1_a1: number; -export declare class m1_c1 { - m1_c1_p1: number; -} -export declare var m1_instance1: m1_c1; -export declare function m1_f1(): m1_c1; diff --git a/tests/baselines/reference/project/sourceRootRelativePathModuleSimpleSpecifyOutputFile/amd/m1.js b/tests/baselines/reference/project/sourceRootRelativePathModuleSimpleSpecifyOutputFile/amd/m1.js deleted file mode 100644 index bbaba444ba2..00000000000 --- a/tests/baselines/reference/project/sourceRootRelativePathModuleSimpleSpecifyOutputFile/amd/m1.js +++ /dev/null @@ -1,15 +0,0 @@ -define(["require", "exports"], function (require, exports) { - exports.m1_a1 = 10; - var m1_c1 = (function () { - function m1_c1() { - } - return m1_c1; - })(); - exports.m1_c1 = m1_c1; - exports.m1_instance1 = new m1_c1(); - function m1_f1() { - return exports.m1_instance1; - } - exports.m1_f1 = m1_f1; -}); -//# sourceMappingURL=m1.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootRelativePathModuleSimpleSpecifyOutputFile/amd/m1.js.map b/tests/baselines/reference/project/sourceRootRelativePathModuleSimpleSpecifyOutputFile/amd/m1.js.map deleted file mode 100644 index e0af3af9b22..00000000000 --- a/tests/baselines/reference/project/sourceRootRelativePathModuleSimpleSpecifyOutputFile/amd/m1.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"m1.js","sourceRoot":"../src/","sources":["m1.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1"],"mappings":";IAAW,aAAK,GAAG,EAAE,CAAC;IACtB;QAAAA;QAEAC,CAACA;QAADD,YAACA;IAADA,CAACA,AAFD,IAEC;IAFY,aAAK,QAEjB,CAAA;IAEU,oBAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACIE,MAAMA,CAACA,oBAAYA,CAACA;IACxBA,CAACA;IAFe,aAAK,QAEpB,CAAA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootRelativePathModuleSimpleSpecifyOutputFile/amd/sourceRootRelativePathModuleSimpleSpecifyOutputFile.json b/tests/baselines/reference/project/sourceRootRelativePathModuleSimpleSpecifyOutputFile/amd/sourceRootRelativePathModuleSimpleSpecifyOutputFile.json index a4a6698d3ca..8213a1478ae 100644 --- a/tests/baselines/reference/project/sourceRootRelativePathModuleSimpleSpecifyOutputFile/amd/sourceRootRelativePathModuleSimpleSpecifyOutputFile.json +++ b/tests/baselines/reference/project/sourceRootRelativePathModuleSimpleSpecifyOutputFile/amd/sourceRootRelativePathModuleSimpleSpecifyOutputFile.json @@ -15,12 +15,6 @@ "test.ts" ], "emittedFiles": [ - "m1.js.map", - "m1.js", - "m1.d.ts", - "test.js.map", - "test.js", - "test.d.ts", "bin/test.js.map", "bin/test.js", "bin/test.d.ts" diff --git a/tests/baselines/reference/project/sourceRootRelativePathModuleSimpleSpecifyOutputFile/amd/sourceRootRelativePathModuleSimpleSpecifyOutputFile.sourcemap.txt b/tests/baselines/reference/project/sourceRootRelativePathModuleSimpleSpecifyOutputFile/amd/sourceRootRelativePathModuleSimpleSpecifyOutputFile.sourcemap.txt index 97323d5d307..fc0f367f343 100644 --- a/tests/baselines/reference/project/sourceRootRelativePathModuleSimpleSpecifyOutputFile/amd/sourceRootRelativePathModuleSimpleSpecifyOutputFile.sourcemap.txt +++ b/tests/baselines/reference/project/sourceRootRelativePathModuleSimpleSpecifyOutputFile/amd/sourceRootRelativePathModuleSimpleSpecifyOutputFile.sourcemap.txt @@ -1,375 +1,4 @@ =================================================================== -JsFile: m1.js -mapUrl: m1.js.map -sourceRoot: ../src/ -sources: m1.ts -=================================================================== -------------------------------------------------------------------- -emittedFile:m1.js -sourceFile:m1.ts -------------------------------------------------------------------- ->>>define(["require", "exports"], function (require, exports) { ->>> exports.m1_a1 = 10; -1 >^^^^ -2 > ^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^-> -1 >export var -2 > m1_a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(2, 5) Source(1, 12) + SourceIndex(0) -2 >Emitted(2, 18) Source(1, 17) + SourceIndex(0) -3 >Emitted(2, 21) Source(1, 20) + SourceIndex(0) -4 >Emitted(2, 23) Source(1, 22) + SourceIndex(0) -5 >Emitted(2, 24) Source(1, 23) + SourceIndex(0) ---- ->>> var m1_c1 = (function () { -1->^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^^^^-> -1-> - > -1->Emitted(3, 5) Source(2, 1) + SourceIndex(0) ---- ->>> function m1_c1() { -1->^^^^^^^^ -2 > ^^-> -1-> -1->Emitted(4, 9) Source(2, 1) + SourceIndex(0) name (m1_c1) ---- ->>> } -1->^^^^^^^^ -2 > ^ -3 > ^^^^^^^^^^^^^-> -1->export class m1_c1 { - > public m1_c1_p1: number; - > -2 > } -1->Emitted(5, 9) Source(4, 1) + SourceIndex(0) name (m1_c1.constructor) -2 >Emitted(5, 10) Source(4, 2) + SourceIndex(0) name (m1_c1.constructor) ---- ->>> return m1_c1; -1->^^^^^^^^ -2 > ^^^^^^^^^^^^ -1-> -2 > } -1->Emitted(6, 9) Source(4, 1) + SourceIndex(0) name (m1_c1) -2 >Emitted(6, 21) Source(4, 2) + SourceIndex(0) name (m1_c1) ---- ->>> })(); -1 >^^^^ -2 > ^ -3 > -4 > ^^^^ -5 > ^^^^^^^^^^^^^^^^^^-> -1 > -2 > } -3 > -4 > export class m1_c1 { - > public m1_c1_p1: number; - > } -1 >Emitted(7, 5) Source(4, 1) + SourceIndex(0) name (m1_c1) -2 >Emitted(7, 6) Source(4, 2) + SourceIndex(0) name (m1_c1) -3 >Emitted(7, 6) Source(2, 1) + SourceIndex(0) -4 >Emitted(7, 10) Source(4, 2) + SourceIndex(0) ---- ->>> exports.m1_c1 = m1_c1; -1->^^^^ -2 > ^^^^^^^^^^^^^ -3 > ^^^^^^^^ -4 > ^ -5 > ^^^^^^^^^^^^^^-> -1-> -2 > m1_c1 -3 > { - > public m1_c1_p1: number; - > } -4 > -1->Emitted(8, 5) Source(2, 14) + SourceIndex(0) -2 >Emitted(8, 18) Source(2, 19) + SourceIndex(0) -3 >Emitted(8, 26) Source(4, 2) + SourceIndex(0) -4 >Emitted(8, 27) Source(4, 2) + SourceIndex(0) ---- ->>> exports.m1_instance1 = new m1_c1(); -1->^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^^^ -5 > ^^^^^ -6 > ^^ -7 > ^ -1-> - > - >export var -2 > m1_instance1 -3 > = -4 > new -5 > m1_c1 -6 > () -7 > ; -1->Emitted(9, 5) Source(6, 12) + SourceIndex(0) -2 >Emitted(9, 25) Source(6, 24) + SourceIndex(0) -3 >Emitted(9, 28) Source(6, 27) + SourceIndex(0) -4 >Emitted(9, 32) Source(6, 31) + SourceIndex(0) -5 >Emitted(9, 37) Source(6, 36) + SourceIndex(0) -6 >Emitted(9, 39) Source(6, 38) + SourceIndex(0) -7 >Emitted(9, 40) Source(6, 39) + SourceIndex(0) ---- ->>> function m1_f1() { -1 >^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -1 >Emitted(10, 5) Source(7, 1) + SourceIndex(0) ---- ->>> return exports.m1_instance1; -1->^^^^^^^^ -2 > ^^^^^^ -3 > ^ -4 > ^^^^^^^^^^^^^^^^^^^^ -5 > ^ -1->export function m1_f1() { - > -2 > return -3 > -4 > m1_instance1 -5 > ; -1->Emitted(11, 9) Source(8, 5) + SourceIndex(0) name (m1_f1) -2 >Emitted(11, 15) Source(8, 11) + SourceIndex(0) name (m1_f1) -3 >Emitted(11, 16) Source(8, 12) + SourceIndex(0) name (m1_f1) -4 >Emitted(11, 36) Source(8, 24) + SourceIndex(0) name (m1_f1) -5 >Emitted(11, 37) Source(8, 25) + SourceIndex(0) name (m1_f1) ---- ->>> } -1 >^^^^ -2 > ^ -3 > ^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -2 > } -1 >Emitted(12, 5) Source(9, 1) + SourceIndex(0) name (m1_f1) -2 >Emitted(12, 6) Source(9, 2) + SourceIndex(0) name (m1_f1) ---- ->>> exports.m1_f1 = m1_f1; -1->^^^^ -2 > ^^^^^^^^^^^^^ -3 > ^^^^^^^^ -4 > ^ -1-> -2 > m1_f1 -3 > () { - > return m1_instance1; - > } -4 > -1->Emitted(13, 5) Source(7, 17) + SourceIndex(0) -2 >Emitted(13, 18) Source(7, 22) + SourceIndex(0) -3 >Emitted(13, 26) Source(9, 2) + SourceIndex(0) -4 >Emitted(13, 27) Source(9, 2) + SourceIndex(0) ---- ->>>}); ->>>//# sourceMappingURL=m1.js.map=================================================================== -JsFile: test.js -mapUrl: test.js.map -sourceRoot: ../src/ -sources: test.ts -=================================================================== -------------------------------------------------------------------- -emittedFile:test.js -sourceFile:test.ts -------------------------------------------------------------------- ->>>define(["require", "exports", "m1"], function (require, exports, m1) { ->>> exports.a1 = 10; -1 >^^^^ -2 > ^^^^^^^^^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^-> -1 >import m1 = require("m1"); - >export var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(2, 5) Source(2, 12) + SourceIndex(0) -2 >Emitted(2, 15) Source(2, 14) + SourceIndex(0) -3 >Emitted(2, 18) Source(2, 17) + SourceIndex(0) -4 >Emitted(2, 20) Source(2, 19) + SourceIndex(0) -5 >Emitted(2, 21) Source(2, 20) + SourceIndex(0) ---- ->>> var c1 = (function () { -1->^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^-> -1-> - > -1->Emitted(3, 5) Source(3, 1) + SourceIndex(0) ---- ->>> function c1() { -1->^^^^^^^^ -2 > ^^-> -1-> -1->Emitted(4, 9) Source(3, 1) + SourceIndex(0) name (c1) ---- ->>> } -1->^^^^^^^^ -2 > ^ -3 > ^^^^^^^^^^-> -1->export class c1 { - > public p1: number; - > -2 > } -1->Emitted(5, 9) Source(5, 1) + SourceIndex(0) name (c1.constructor) -2 >Emitted(5, 10) Source(5, 2) + SourceIndex(0) name (c1.constructor) ---- ->>> return c1; -1->^^^^^^^^ -2 > ^^^^^^^^^ -1-> -2 > } -1->Emitted(6, 9) Source(5, 1) + SourceIndex(0) name (c1) -2 >Emitted(6, 18) Source(5, 2) + SourceIndex(0) name (c1) ---- ->>> })(); -1 >^^^^ -2 > ^ -3 > -4 > ^^^^ -5 > ^^^^^^^^^^^^-> -1 > -2 > } -3 > -4 > export class c1 { - > public p1: number; - > } -1 >Emitted(7, 5) Source(5, 1) + SourceIndex(0) name (c1) -2 >Emitted(7, 6) Source(5, 2) + SourceIndex(0) name (c1) -3 >Emitted(7, 6) Source(3, 1) + SourceIndex(0) -4 >Emitted(7, 10) Source(5, 2) + SourceIndex(0) ---- ->>> exports.c1 = c1; -1->^^^^ -2 > ^^^^^^^^^^ -3 > ^^^^^ -4 > ^ -5 > ^^^^^^^^^^^^^^-> -1-> -2 > c1 -3 > { - > public p1: number; - > } -4 > -1->Emitted(8, 5) Source(3, 14) + SourceIndex(0) -2 >Emitted(8, 15) Source(3, 16) + SourceIndex(0) -3 >Emitted(8, 20) Source(5, 2) + SourceIndex(0) -4 >Emitted(8, 21) Source(5, 2) + SourceIndex(0) ---- ->>> exports.instance1 = new c1(); -1->^^^^ -2 > ^^^^^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^^^ -5 > ^^ -6 > ^^ -7 > ^ -1-> - > - >export var -2 > instance1 -3 > = -4 > new -5 > c1 -6 > () -7 > ; -1->Emitted(9, 5) Source(7, 12) + SourceIndex(0) -2 >Emitted(9, 22) Source(7, 21) + SourceIndex(0) -3 >Emitted(9, 25) Source(7, 24) + SourceIndex(0) -4 >Emitted(9, 29) Source(7, 28) + SourceIndex(0) -5 >Emitted(9, 31) Source(7, 30) + SourceIndex(0) -6 >Emitted(9, 33) Source(7, 32) + SourceIndex(0) -7 >Emitted(9, 34) Source(7, 33) + SourceIndex(0) ---- ->>> function f1() { -1 >^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -1 >Emitted(10, 5) Source(8, 1) + SourceIndex(0) ---- ->>> return exports.instance1; -1->^^^^^^^^ -2 > ^^^^^^ -3 > ^ -4 > ^^^^^^^^^^^^^^^^^ -5 > ^ -1->export function f1() { - > -2 > return -3 > -4 > instance1 -5 > ; -1->Emitted(11, 9) Source(9, 5) + SourceIndex(0) name (f1) -2 >Emitted(11, 15) Source(9, 11) + SourceIndex(0) name (f1) -3 >Emitted(11, 16) Source(9, 12) + SourceIndex(0) name (f1) -4 >Emitted(11, 33) Source(9, 21) + SourceIndex(0) name (f1) -5 >Emitted(11, 34) Source(9, 22) + SourceIndex(0) name (f1) ---- ->>> } -1 >^^^^ -2 > ^ -3 > ^^^^^^^^^^^^^^^^-> -1 > - > -2 > } -1 >Emitted(12, 5) Source(10, 1) + SourceIndex(0) name (f1) -2 >Emitted(12, 6) Source(10, 2) + SourceIndex(0) name (f1) ---- ->>> exports.f1 = f1; -1->^^^^ -2 > ^^^^^^^^^^ -3 > ^^^^^ -4 > ^ -5 > ^^^^^^^-> -1-> -2 > f1 -3 > () { - > return instance1; - > } -4 > -1->Emitted(13, 5) Source(8, 17) + SourceIndex(0) -2 >Emitted(13, 15) Source(8, 19) + SourceIndex(0) -3 >Emitted(13, 20) Source(10, 2) + SourceIndex(0) -4 >Emitted(13, 21) Source(10, 2) + SourceIndex(0) ---- ->>> exports.a2 = m1.m1_c1; -1->^^^^ -2 > ^^^^^^^^^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^ -7 > ^ -1-> - > - >export var -2 > a2 -3 > = -4 > m1 -5 > . -6 > m1_c1 -7 > ; -1->Emitted(14, 5) Source(12, 12) + SourceIndex(0) -2 >Emitted(14, 15) Source(12, 14) + SourceIndex(0) -3 >Emitted(14, 18) Source(12, 17) + SourceIndex(0) -4 >Emitted(14, 20) Source(12, 19) + SourceIndex(0) -5 >Emitted(14, 21) Source(12, 20) + SourceIndex(0) -6 >Emitted(14, 26) Source(12, 25) + SourceIndex(0) -7 >Emitted(14, 27) Source(12, 26) + SourceIndex(0) ---- ->>>}); ->>>//# sourceMappingURL=test.js.map=================================================================== JsFile: test.js mapUrl: test.js.map sourceRoot: ../src/ diff --git a/tests/baselines/reference/project/sourceRootRelativePathModuleSimpleSpecifyOutputFile/amd/test.d.ts b/tests/baselines/reference/project/sourceRootRelativePathModuleSimpleSpecifyOutputFile/amd/test.d.ts deleted file mode 100644 index 250d2615a79..00000000000 --- a/tests/baselines/reference/project/sourceRootRelativePathModuleSimpleSpecifyOutputFile/amd/test.d.ts +++ /dev/null @@ -1,8 +0,0 @@ -import m1 = require("m1"); -export declare var a1: number; -export declare class c1 { - p1: number; -} -export declare var instance1: c1; -export declare function f1(): c1; -export declare var a2: typeof m1.m1_c1; diff --git a/tests/baselines/reference/project/sourceRootRelativePathModuleSimpleSpecifyOutputFile/amd/test.js b/tests/baselines/reference/project/sourceRootRelativePathModuleSimpleSpecifyOutputFile/amd/test.js deleted file mode 100644 index 372f1052b89..00000000000 --- a/tests/baselines/reference/project/sourceRootRelativePathModuleSimpleSpecifyOutputFile/amd/test.js +++ /dev/null @@ -1,16 +0,0 @@ -define(["require", "exports", "m1"], function (require, exports, m1) { - exports.a1 = 10; - var c1 = (function () { - function c1() { - } - return c1; - })(); - exports.c1 = c1; - exports.instance1 = new c1(); - function f1() { - return exports.instance1; - } - exports.f1 = f1; - exports.a2 = m1.m1_c1; -}); -//# sourceMappingURL=test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootRelativePathModuleSimpleSpecifyOutputFile/amd/test.js.map b/tests/baselines/reference/project/sourceRootRelativePathModuleSimpleSpecifyOutputFile/amd/test.js.map deleted file mode 100644 index 22f07c17544..00000000000 --- a/tests/baselines/reference/project/sourceRootRelativePathModuleSimpleSpecifyOutputFile/amd/test.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"test.js","sourceRoot":"../src/","sources":["test.ts"],"names":["c1","c1.constructor","f1"],"mappings":";IACW,UAAE,GAAG,EAAE,CAAC;IACnB;QAAAA;QAEAC,CAACA;QAADD,SAACA;IAADA,CAACA,AAFD,IAEC;IAFY,UAAE,KAEd,CAAA;IAEU,iBAAS,GAAG,IAAI,EAAE,EAAE,CAAC;IAChC;QACIE,MAAMA,CAACA,iBAASA,CAACA;IACrBA,CAACA;IAFe,UAAE,KAEjB,CAAA;IAEU,UAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootRelativePathModuleSimpleSpecifyOutputFile/node/m1.d.ts b/tests/baselines/reference/project/sourceRootRelativePathModuleSimpleSpecifyOutputFile/node/m1.d.ts deleted file mode 100644 index 4a53b24b156..00000000000 --- a/tests/baselines/reference/project/sourceRootRelativePathModuleSimpleSpecifyOutputFile/node/m1.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -export declare var m1_a1: number; -export declare class m1_c1 { - m1_c1_p1: number; -} -export declare var m1_instance1: m1_c1; -export declare function m1_f1(): m1_c1; diff --git a/tests/baselines/reference/project/sourceRootRelativePathModuleSimpleSpecifyOutputFile/node/m1.js b/tests/baselines/reference/project/sourceRootRelativePathModuleSimpleSpecifyOutputFile/node/m1.js deleted file mode 100644 index 1b4470e2b37..00000000000 --- a/tests/baselines/reference/project/sourceRootRelativePathModuleSimpleSpecifyOutputFile/node/m1.js +++ /dev/null @@ -1,13 +0,0 @@ -exports.m1_a1 = 10; -var m1_c1 = (function () { - function m1_c1() { - } - return m1_c1; -})(); -exports.m1_c1 = m1_c1; -exports.m1_instance1 = new m1_c1(); -function m1_f1() { - return exports.m1_instance1; -} -exports.m1_f1 = m1_f1; -//# sourceMappingURL=m1.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootRelativePathModuleSimpleSpecifyOutputFile/node/m1.js.map b/tests/baselines/reference/project/sourceRootRelativePathModuleSimpleSpecifyOutputFile/node/m1.js.map deleted file mode 100644 index 05c53f0182e..00000000000 --- a/tests/baselines/reference/project/sourceRootRelativePathModuleSimpleSpecifyOutputFile/node/m1.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"m1.js","sourceRoot":"../src/","sources":["m1.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1"],"mappings":"AAAW,aAAK,GAAG,EAAE,CAAC;AACtB;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAFY,aAAK,QAEjB,CAAA;AAEU,oBAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACIE,MAAMA,CAACA,oBAAYA,CAACA;AACxBA,CAACA;AAFe,aAAK,QAEpB,CAAA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootRelativePathModuleSimpleSpecifyOutputFile/node/sourceRootRelativePathModuleSimpleSpecifyOutputFile.json b/tests/baselines/reference/project/sourceRootRelativePathModuleSimpleSpecifyOutputFile/node/sourceRootRelativePathModuleSimpleSpecifyOutputFile.json index a4a6698d3ca..8213a1478ae 100644 --- a/tests/baselines/reference/project/sourceRootRelativePathModuleSimpleSpecifyOutputFile/node/sourceRootRelativePathModuleSimpleSpecifyOutputFile.json +++ b/tests/baselines/reference/project/sourceRootRelativePathModuleSimpleSpecifyOutputFile/node/sourceRootRelativePathModuleSimpleSpecifyOutputFile.json @@ -15,12 +15,6 @@ "test.ts" ], "emittedFiles": [ - "m1.js.map", - "m1.js", - "m1.d.ts", - "test.js.map", - "test.js", - "test.d.ts", "bin/test.js.map", "bin/test.js", "bin/test.d.ts" diff --git a/tests/baselines/reference/project/sourceRootRelativePathModuleSimpleSpecifyOutputFile/node/sourceRootRelativePathModuleSimpleSpecifyOutputFile.sourcemap.txt b/tests/baselines/reference/project/sourceRootRelativePathModuleSimpleSpecifyOutputFile/node/sourceRootRelativePathModuleSimpleSpecifyOutputFile.sourcemap.txt index b38468c878d..2910ad61478 100644 --- a/tests/baselines/reference/project/sourceRootRelativePathModuleSimpleSpecifyOutputFile/node/sourceRootRelativePathModuleSimpleSpecifyOutputFile.sourcemap.txt +++ b/tests/baselines/reference/project/sourceRootRelativePathModuleSimpleSpecifyOutputFile/node/sourceRootRelativePathModuleSimpleSpecifyOutputFile.sourcemap.txt @@ -1,396 +1,4 @@ =================================================================== -JsFile: m1.js -mapUrl: m1.js.map -sourceRoot: ../src/ -sources: m1.ts -=================================================================== -------------------------------------------------------------------- -emittedFile:m1.js -sourceFile:m1.ts -------------------------------------------------------------------- ->>>exports.m1_a1 = 10; -1 > -2 >^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^-> -1 >export var -2 >m1_a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(1, 1) Source(1, 12) + SourceIndex(0) -2 >Emitted(1, 14) Source(1, 17) + SourceIndex(0) -3 >Emitted(1, 17) Source(1, 20) + SourceIndex(0) -4 >Emitted(1, 19) Source(1, 22) + SourceIndex(0) -5 >Emitted(1, 20) Source(1, 23) + SourceIndex(0) ---- ->>>var m1_c1 = (function () { -1-> -2 >^^^^^^^^^^^^^^^^^^^^^^^-> -1-> - > -1->Emitted(2, 1) Source(2, 1) + SourceIndex(0) ---- ->>> function m1_c1() { -1->^^^^ -2 > ^^-> -1-> -1->Emitted(3, 5) Source(2, 1) + SourceIndex(0) name (m1_c1) ---- ->>> } -1->^^^^ -2 > ^ -3 > ^^^^^^^^^^^^^-> -1->export class m1_c1 { - > public m1_c1_p1: number; - > -2 > } -1->Emitted(4, 5) Source(4, 1) + SourceIndex(0) name (m1_c1.constructor) -2 >Emitted(4, 6) Source(4, 2) + SourceIndex(0) name (m1_c1.constructor) ---- ->>> return m1_c1; -1->^^^^ -2 > ^^^^^^^^^^^^ -1-> -2 > } -1->Emitted(5, 5) Source(4, 1) + SourceIndex(0) name (m1_c1) -2 >Emitted(5, 17) Source(4, 2) + SourceIndex(0) name (m1_c1) ---- ->>>})(); -1 > -2 >^ -3 > -4 > ^^^^ -5 > ^^^^^^^^^^^^^^^^^^-> -1 > -2 >} -3 > -4 > export class m1_c1 { - > public m1_c1_p1: number; - > } -1 >Emitted(6, 1) Source(4, 1) + SourceIndex(0) name (m1_c1) -2 >Emitted(6, 2) Source(4, 2) + SourceIndex(0) name (m1_c1) -3 >Emitted(6, 2) Source(2, 1) + SourceIndex(0) -4 >Emitted(6, 6) Source(4, 2) + SourceIndex(0) ---- ->>>exports.m1_c1 = m1_c1; -1-> -2 >^^^^^^^^^^^^^ -3 > ^^^^^^^^ -4 > ^ -5 > ^^^^^^^^^^^^^^-> -1-> -2 >m1_c1 -3 > { - > public m1_c1_p1: number; - > } -4 > -1->Emitted(7, 1) Source(2, 14) + SourceIndex(0) -2 >Emitted(7, 14) Source(2, 19) + SourceIndex(0) -3 >Emitted(7, 22) Source(4, 2) + SourceIndex(0) -4 >Emitted(7, 23) Source(4, 2) + SourceIndex(0) ---- ->>>exports.m1_instance1 = new m1_c1(); -1-> -2 >^^^^^^^^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^^^ -5 > ^^^^^ -6 > ^^ -7 > ^ -1-> - > - >export var -2 >m1_instance1 -3 > = -4 > new -5 > m1_c1 -6 > () -7 > ; -1->Emitted(8, 1) Source(6, 12) + SourceIndex(0) -2 >Emitted(8, 21) Source(6, 24) + SourceIndex(0) -3 >Emitted(8, 24) Source(6, 27) + SourceIndex(0) -4 >Emitted(8, 28) Source(6, 31) + SourceIndex(0) -5 >Emitted(8, 33) Source(6, 36) + SourceIndex(0) -6 >Emitted(8, 35) Source(6, 38) + SourceIndex(0) -7 >Emitted(8, 36) Source(6, 39) + SourceIndex(0) ---- ->>>function m1_f1() { -1 > -2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -1 >Emitted(9, 1) Source(7, 1) + SourceIndex(0) ---- ->>> return exports.m1_instance1; -1->^^^^ -2 > ^^^^^^ -3 > ^ -4 > ^^^^^^^^^^^^^^^^^^^^ -5 > ^ -1->export function m1_f1() { - > -2 > return -3 > -4 > m1_instance1 -5 > ; -1->Emitted(10, 5) Source(8, 5) + SourceIndex(0) name (m1_f1) -2 >Emitted(10, 11) Source(8, 11) + SourceIndex(0) name (m1_f1) -3 >Emitted(10, 12) Source(8, 12) + SourceIndex(0) name (m1_f1) -4 >Emitted(10, 32) Source(8, 24) + SourceIndex(0) name (m1_f1) -5 >Emitted(10, 33) Source(8, 25) + SourceIndex(0) name (m1_f1) ---- ->>>} -1 > -2 >^ -3 > ^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -2 >} -1 >Emitted(11, 1) Source(9, 1) + SourceIndex(0) name (m1_f1) -2 >Emitted(11, 2) Source(9, 2) + SourceIndex(0) name (m1_f1) ---- ->>>exports.m1_f1 = m1_f1; -1-> -2 >^^^^^^^^^^^^^ -3 > ^^^^^^^^ -4 > ^ -5 > ^^^^^^^-> -1-> -2 >m1_f1 -3 > () { - > return m1_instance1; - > } -4 > -1->Emitted(12, 1) Source(7, 17) + SourceIndex(0) -2 >Emitted(12, 14) Source(7, 22) + SourceIndex(0) -3 >Emitted(12, 22) Source(9, 2) + SourceIndex(0) -4 >Emitted(12, 23) Source(9, 2) + SourceIndex(0) ---- ->>>//# sourceMappingURL=m1.js.map=================================================================== -JsFile: test.js -mapUrl: test.js.map -sourceRoot: ../src/ -sources: test.ts -=================================================================== -------------------------------------------------------------------- -emittedFile:test.js -sourceFile:test.ts -------------------------------------------------------------------- ->>>var m1 = require("m1"); -1 > -2 >^^^^ -3 > ^^ -4 > ^^^^^^^^^^^ -5 > ^^^^ -6 > ^ -7 > ^ -1 > -2 >import -3 > m1 -4 > = require( -5 > "m1" -6 > ) -7 > ; -1 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) -2 >Emitted(1, 5) Source(1, 8) + SourceIndex(0) -3 >Emitted(1, 7) Source(1, 10) + SourceIndex(0) -4 >Emitted(1, 18) Source(1, 21) + SourceIndex(0) -5 >Emitted(1, 22) Source(1, 25) + SourceIndex(0) -6 >Emitted(1, 23) Source(1, 26) + SourceIndex(0) -7 >Emitted(1, 24) Source(1, 27) + SourceIndex(0) ---- ->>>exports.a1 = 10; -1 > -2 >^^^^^^^^^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^-> -1 > - >export var -2 >a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(2, 1) Source(2, 12) + SourceIndex(0) -2 >Emitted(2, 11) Source(2, 14) + SourceIndex(0) -3 >Emitted(2, 14) Source(2, 17) + SourceIndex(0) -4 >Emitted(2, 16) Source(2, 19) + SourceIndex(0) -5 >Emitted(2, 17) Source(2, 20) + SourceIndex(0) ---- ->>>var c1 = (function () { -1-> -2 >^^^^^^^^^^^^^^^^^^^^-> -1-> - > -1->Emitted(3, 1) Source(3, 1) + SourceIndex(0) ---- ->>> function c1() { -1->^^^^ -2 > ^^-> -1-> -1->Emitted(4, 5) Source(3, 1) + SourceIndex(0) name (c1) ---- ->>> } -1->^^^^ -2 > ^ -3 > ^^^^^^^^^^-> -1->export class c1 { - > public p1: number; - > -2 > } -1->Emitted(5, 5) Source(5, 1) + SourceIndex(0) name (c1.constructor) -2 >Emitted(5, 6) Source(5, 2) + SourceIndex(0) name (c1.constructor) ---- ->>> return c1; -1->^^^^ -2 > ^^^^^^^^^ -1-> -2 > } -1->Emitted(6, 5) Source(5, 1) + SourceIndex(0) name (c1) -2 >Emitted(6, 14) Source(5, 2) + SourceIndex(0) name (c1) ---- ->>>})(); -1 > -2 >^ -3 > -4 > ^^^^ -5 > ^^^^^^^^^^^^-> -1 > -2 >} -3 > -4 > export class c1 { - > public p1: number; - > } -1 >Emitted(7, 1) Source(5, 1) + SourceIndex(0) name (c1) -2 >Emitted(7, 2) Source(5, 2) + SourceIndex(0) name (c1) -3 >Emitted(7, 2) Source(3, 1) + SourceIndex(0) -4 >Emitted(7, 6) Source(5, 2) + SourceIndex(0) ---- ->>>exports.c1 = c1; -1-> -2 >^^^^^^^^^^ -3 > ^^^^^ -4 > ^ -5 > ^^^^^^^^^^^^^^-> -1-> -2 >c1 -3 > { - > public p1: number; - > } -4 > -1->Emitted(8, 1) Source(3, 14) + SourceIndex(0) -2 >Emitted(8, 11) Source(3, 16) + SourceIndex(0) -3 >Emitted(8, 16) Source(5, 2) + SourceIndex(0) -4 >Emitted(8, 17) Source(5, 2) + SourceIndex(0) ---- ->>>exports.instance1 = new c1(); -1-> -2 >^^^^^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^^^ -5 > ^^ -6 > ^^ -7 > ^ -1-> - > - >export var -2 >instance1 -3 > = -4 > new -5 > c1 -6 > () -7 > ; -1->Emitted(9, 1) Source(7, 12) + SourceIndex(0) -2 >Emitted(9, 18) Source(7, 21) + SourceIndex(0) -3 >Emitted(9, 21) Source(7, 24) + SourceIndex(0) -4 >Emitted(9, 25) Source(7, 28) + SourceIndex(0) -5 >Emitted(9, 27) Source(7, 30) + SourceIndex(0) -6 >Emitted(9, 29) Source(7, 32) + SourceIndex(0) -7 >Emitted(9, 30) Source(7, 33) + SourceIndex(0) ---- ->>>function f1() { -1 > -2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -1 >Emitted(10, 1) Source(8, 1) + SourceIndex(0) ---- ->>> return exports.instance1; -1->^^^^ -2 > ^^^^^^ -3 > ^ -4 > ^^^^^^^^^^^^^^^^^ -5 > ^ -1->export function f1() { - > -2 > return -3 > -4 > instance1 -5 > ; -1->Emitted(11, 5) Source(9, 5) + SourceIndex(0) name (f1) -2 >Emitted(11, 11) Source(9, 11) + SourceIndex(0) name (f1) -3 >Emitted(11, 12) Source(9, 12) + SourceIndex(0) name (f1) -4 >Emitted(11, 29) Source(9, 21) + SourceIndex(0) name (f1) -5 >Emitted(11, 30) Source(9, 22) + SourceIndex(0) name (f1) ---- ->>>} -1 > -2 >^ -3 > ^^^^^^^^^^^^^^^^-> -1 > - > -2 >} -1 >Emitted(12, 1) Source(10, 1) + SourceIndex(0) name (f1) -2 >Emitted(12, 2) Source(10, 2) + SourceIndex(0) name (f1) ---- ->>>exports.f1 = f1; -1-> -2 >^^^^^^^^^^ -3 > ^^^^^ -4 > ^ -5 > ^^^^^^^-> -1-> -2 >f1 -3 > () { - > return instance1; - > } -4 > -1->Emitted(13, 1) Source(8, 17) + SourceIndex(0) -2 >Emitted(13, 11) Source(8, 19) + SourceIndex(0) -3 >Emitted(13, 16) Source(10, 2) + SourceIndex(0) -4 >Emitted(13, 17) Source(10, 2) + SourceIndex(0) ---- ->>>exports.a2 = m1.m1_c1; -1-> -2 >^^^^^^^^^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^ -7 > ^ -8 > ^^^^^^^^^-> -1-> - > - >export var -2 >a2 -3 > = -4 > m1 -5 > . -6 > m1_c1 -7 > ; -1->Emitted(14, 1) Source(12, 12) + SourceIndex(0) -2 >Emitted(14, 11) Source(12, 14) + SourceIndex(0) -3 >Emitted(14, 14) Source(12, 17) + SourceIndex(0) -4 >Emitted(14, 16) Source(12, 19) + SourceIndex(0) -5 >Emitted(14, 17) Source(12, 20) + SourceIndex(0) -6 >Emitted(14, 22) Source(12, 25) + SourceIndex(0) -7 >Emitted(14, 23) Source(12, 26) + SourceIndex(0) ---- ->>>//# sourceMappingURL=test.js.map=================================================================== JsFile: test.js mapUrl: test.js.map sourceRoot: ../src/ diff --git a/tests/baselines/reference/project/sourceRootRelativePathModuleSimpleSpecifyOutputFile/node/test.d.ts b/tests/baselines/reference/project/sourceRootRelativePathModuleSimpleSpecifyOutputFile/node/test.d.ts deleted file mode 100644 index 250d2615a79..00000000000 --- a/tests/baselines/reference/project/sourceRootRelativePathModuleSimpleSpecifyOutputFile/node/test.d.ts +++ /dev/null @@ -1,8 +0,0 @@ -import m1 = require("m1"); -export declare var a1: number; -export declare class c1 { - p1: number; -} -export declare var instance1: c1; -export declare function f1(): c1; -export declare var a2: typeof m1.m1_c1; diff --git a/tests/baselines/reference/project/sourceRootRelativePathModuleSimpleSpecifyOutputFile/node/test.js b/tests/baselines/reference/project/sourceRootRelativePathModuleSimpleSpecifyOutputFile/node/test.js deleted file mode 100644 index c2e7dfa443b..00000000000 --- a/tests/baselines/reference/project/sourceRootRelativePathModuleSimpleSpecifyOutputFile/node/test.js +++ /dev/null @@ -1,15 +0,0 @@ -var m1 = require("m1"); -exports.a1 = 10; -var c1 = (function () { - function c1() { - } - return c1; -})(); -exports.c1 = c1; -exports.instance1 = new c1(); -function f1() { - return exports.instance1; -} -exports.f1 = f1; -exports.a2 = m1.m1_c1; -//# sourceMappingURL=test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootRelativePathModuleSimpleSpecifyOutputFile/node/test.js.map b/tests/baselines/reference/project/sourceRootRelativePathModuleSimpleSpecifyOutputFile/node/test.js.map deleted file mode 100644 index 1e72e2a2203..00000000000 --- a/tests/baselines/reference/project/sourceRootRelativePathModuleSimpleSpecifyOutputFile/node/test.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"test.js","sourceRoot":"../src/","sources":["test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AAAA,IAAO,EAAE,WAAW,IAAI,CAAC,CAAC;AACf,UAAE,GAAG,EAAE,CAAC;AACnB;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAFY,UAAE,KAEd,CAAA;AAEU,iBAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AAChC;IACIE,MAAMA,CAACA,iBAASA,CAACA;AACrBA,CAACA;AAFe,UAAE,KAEjB,CAAA;AAEU,UAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootRelativePathModuleSubfolderSpecifyOutputFile/amd/ref/m1.d.ts b/tests/baselines/reference/project/sourceRootRelativePathModuleSubfolderSpecifyOutputFile/amd/ref/m1.d.ts deleted file mode 100644 index 4a53b24b156..00000000000 --- a/tests/baselines/reference/project/sourceRootRelativePathModuleSubfolderSpecifyOutputFile/amd/ref/m1.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -export declare var m1_a1: number; -export declare class m1_c1 { - m1_c1_p1: number; -} -export declare var m1_instance1: m1_c1; -export declare function m1_f1(): m1_c1; diff --git a/tests/baselines/reference/project/sourceRootRelativePathModuleSubfolderSpecifyOutputFile/amd/ref/m1.js b/tests/baselines/reference/project/sourceRootRelativePathModuleSubfolderSpecifyOutputFile/amd/ref/m1.js deleted file mode 100644 index bbaba444ba2..00000000000 --- a/tests/baselines/reference/project/sourceRootRelativePathModuleSubfolderSpecifyOutputFile/amd/ref/m1.js +++ /dev/null @@ -1,15 +0,0 @@ -define(["require", "exports"], function (require, exports) { - exports.m1_a1 = 10; - var m1_c1 = (function () { - function m1_c1() { - } - return m1_c1; - })(); - exports.m1_c1 = m1_c1; - exports.m1_instance1 = new m1_c1(); - function m1_f1() { - return exports.m1_instance1; - } - exports.m1_f1 = m1_f1; -}); -//# sourceMappingURL=m1.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootRelativePathModuleSubfolderSpecifyOutputFile/amd/ref/m1.js.map b/tests/baselines/reference/project/sourceRootRelativePathModuleSubfolderSpecifyOutputFile/amd/ref/m1.js.map deleted file mode 100644 index aaae11bb5b5..00000000000 --- a/tests/baselines/reference/project/sourceRootRelativePathModuleSubfolderSpecifyOutputFile/amd/ref/m1.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"m1.js","sourceRoot":"../src/","sources":["ref/m1.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1"],"mappings":";IAAW,aAAK,GAAG,EAAE,CAAC;IACtB;QAAAA;QAEAC,CAACA;QAADD,YAACA;IAADA,CAACA,AAFD,IAEC;IAFY,aAAK,QAEjB,CAAA;IAEU,oBAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACIE,MAAMA,CAACA,oBAAYA,CAACA;IACxBA,CAACA;IAFe,aAAK,QAEpB,CAAA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootRelativePathModuleSubfolderSpecifyOutputFile/amd/sourceRootRelativePathModuleSubfolderSpecifyOutputFile.json b/tests/baselines/reference/project/sourceRootRelativePathModuleSubfolderSpecifyOutputFile/amd/sourceRootRelativePathModuleSubfolderSpecifyOutputFile.json index 71896f202b2..a5966ef08b8 100644 --- a/tests/baselines/reference/project/sourceRootRelativePathModuleSubfolderSpecifyOutputFile/amd/sourceRootRelativePathModuleSubfolderSpecifyOutputFile.json +++ b/tests/baselines/reference/project/sourceRootRelativePathModuleSubfolderSpecifyOutputFile/amd/sourceRootRelativePathModuleSubfolderSpecifyOutputFile.json @@ -15,12 +15,6 @@ "test.ts" ], "emittedFiles": [ - "ref/m1.js.map", - "ref/m1.js", - "ref/m1.d.ts", - "test.js.map", - "test.js", - "test.d.ts", "bin/test.js.map", "bin/test.js", "bin/test.d.ts" diff --git a/tests/baselines/reference/project/sourceRootRelativePathModuleSubfolderSpecifyOutputFile/amd/sourceRootRelativePathModuleSubfolderSpecifyOutputFile.sourcemap.txt b/tests/baselines/reference/project/sourceRootRelativePathModuleSubfolderSpecifyOutputFile/amd/sourceRootRelativePathModuleSubfolderSpecifyOutputFile.sourcemap.txt index e754942b588..83f9ef1f262 100644 --- a/tests/baselines/reference/project/sourceRootRelativePathModuleSubfolderSpecifyOutputFile/amd/sourceRootRelativePathModuleSubfolderSpecifyOutputFile.sourcemap.txt +++ b/tests/baselines/reference/project/sourceRootRelativePathModuleSubfolderSpecifyOutputFile/amd/sourceRootRelativePathModuleSubfolderSpecifyOutputFile.sourcemap.txt @@ -1,375 +1,4 @@ =================================================================== -JsFile: m1.js -mapUrl: m1.js.map -sourceRoot: ../src/ -sources: ref/m1.ts -=================================================================== -------------------------------------------------------------------- -emittedFile:ref/m1.js -sourceFile:ref/m1.ts -------------------------------------------------------------------- ->>>define(["require", "exports"], function (require, exports) { ->>> exports.m1_a1 = 10; -1 >^^^^ -2 > ^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^-> -1 >export var -2 > m1_a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(2, 5) Source(1, 12) + SourceIndex(0) -2 >Emitted(2, 18) Source(1, 17) + SourceIndex(0) -3 >Emitted(2, 21) Source(1, 20) + SourceIndex(0) -4 >Emitted(2, 23) Source(1, 22) + SourceIndex(0) -5 >Emitted(2, 24) Source(1, 23) + SourceIndex(0) ---- ->>> var m1_c1 = (function () { -1->^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^^^^-> -1-> - > -1->Emitted(3, 5) Source(2, 1) + SourceIndex(0) ---- ->>> function m1_c1() { -1->^^^^^^^^ -2 > ^^-> -1-> -1->Emitted(4, 9) Source(2, 1) + SourceIndex(0) name (m1_c1) ---- ->>> } -1->^^^^^^^^ -2 > ^ -3 > ^^^^^^^^^^^^^-> -1->export class m1_c1 { - > public m1_c1_p1: number; - > -2 > } -1->Emitted(5, 9) Source(4, 1) + SourceIndex(0) name (m1_c1.constructor) -2 >Emitted(5, 10) Source(4, 2) + SourceIndex(0) name (m1_c1.constructor) ---- ->>> return m1_c1; -1->^^^^^^^^ -2 > ^^^^^^^^^^^^ -1-> -2 > } -1->Emitted(6, 9) Source(4, 1) + SourceIndex(0) name (m1_c1) -2 >Emitted(6, 21) Source(4, 2) + SourceIndex(0) name (m1_c1) ---- ->>> })(); -1 >^^^^ -2 > ^ -3 > -4 > ^^^^ -5 > ^^^^^^^^^^^^^^^^^^-> -1 > -2 > } -3 > -4 > export class m1_c1 { - > public m1_c1_p1: number; - > } -1 >Emitted(7, 5) Source(4, 1) + SourceIndex(0) name (m1_c1) -2 >Emitted(7, 6) Source(4, 2) + SourceIndex(0) name (m1_c1) -3 >Emitted(7, 6) Source(2, 1) + SourceIndex(0) -4 >Emitted(7, 10) Source(4, 2) + SourceIndex(0) ---- ->>> exports.m1_c1 = m1_c1; -1->^^^^ -2 > ^^^^^^^^^^^^^ -3 > ^^^^^^^^ -4 > ^ -5 > ^^^^^^^^^^^^^^-> -1-> -2 > m1_c1 -3 > { - > public m1_c1_p1: number; - > } -4 > -1->Emitted(8, 5) Source(2, 14) + SourceIndex(0) -2 >Emitted(8, 18) Source(2, 19) + SourceIndex(0) -3 >Emitted(8, 26) Source(4, 2) + SourceIndex(0) -4 >Emitted(8, 27) Source(4, 2) + SourceIndex(0) ---- ->>> exports.m1_instance1 = new m1_c1(); -1->^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^^^ -5 > ^^^^^ -6 > ^^ -7 > ^ -1-> - > - >export var -2 > m1_instance1 -3 > = -4 > new -5 > m1_c1 -6 > () -7 > ; -1->Emitted(9, 5) Source(6, 12) + SourceIndex(0) -2 >Emitted(9, 25) Source(6, 24) + SourceIndex(0) -3 >Emitted(9, 28) Source(6, 27) + SourceIndex(0) -4 >Emitted(9, 32) Source(6, 31) + SourceIndex(0) -5 >Emitted(9, 37) Source(6, 36) + SourceIndex(0) -6 >Emitted(9, 39) Source(6, 38) + SourceIndex(0) -7 >Emitted(9, 40) Source(6, 39) + SourceIndex(0) ---- ->>> function m1_f1() { -1 >^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -1 >Emitted(10, 5) Source(7, 1) + SourceIndex(0) ---- ->>> return exports.m1_instance1; -1->^^^^^^^^ -2 > ^^^^^^ -3 > ^ -4 > ^^^^^^^^^^^^^^^^^^^^ -5 > ^ -1->export function m1_f1() { - > -2 > return -3 > -4 > m1_instance1 -5 > ; -1->Emitted(11, 9) Source(8, 5) + SourceIndex(0) name (m1_f1) -2 >Emitted(11, 15) Source(8, 11) + SourceIndex(0) name (m1_f1) -3 >Emitted(11, 16) Source(8, 12) + SourceIndex(0) name (m1_f1) -4 >Emitted(11, 36) Source(8, 24) + SourceIndex(0) name (m1_f1) -5 >Emitted(11, 37) Source(8, 25) + SourceIndex(0) name (m1_f1) ---- ->>> } -1 >^^^^ -2 > ^ -3 > ^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -2 > } -1 >Emitted(12, 5) Source(9, 1) + SourceIndex(0) name (m1_f1) -2 >Emitted(12, 6) Source(9, 2) + SourceIndex(0) name (m1_f1) ---- ->>> exports.m1_f1 = m1_f1; -1->^^^^ -2 > ^^^^^^^^^^^^^ -3 > ^^^^^^^^ -4 > ^ -1-> -2 > m1_f1 -3 > () { - > return m1_instance1; - > } -4 > -1->Emitted(13, 5) Source(7, 17) + SourceIndex(0) -2 >Emitted(13, 18) Source(7, 22) + SourceIndex(0) -3 >Emitted(13, 26) Source(9, 2) + SourceIndex(0) -4 >Emitted(13, 27) Source(9, 2) + SourceIndex(0) ---- ->>>}); ->>>//# sourceMappingURL=m1.js.map=================================================================== -JsFile: test.js -mapUrl: test.js.map -sourceRoot: ../src/ -sources: test.ts -=================================================================== -------------------------------------------------------------------- -emittedFile:test.js -sourceFile:test.ts -------------------------------------------------------------------- ->>>define(["require", "exports", "ref/m1"], function (require, exports, m1) { ->>> exports.a1 = 10; -1 >^^^^ -2 > ^^^^^^^^^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^-> -1 >import m1 = require("ref/m1"); - >export var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(2, 5) Source(2, 12) + SourceIndex(0) -2 >Emitted(2, 15) Source(2, 14) + SourceIndex(0) -3 >Emitted(2, 18) Source(2, 17) + SourceIndex(0) -4 >Emitted(2, 20) Source(2, 19) + SourceIndex(0) -5 >Emitted(2, 21) Source(2, 20) + SourceIndex(0) ---- ->>> var c1 = (function () { -1->^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^-> -1-> - > -1->Emitted(3, 5) Source(3, 1) + SourceIndex(0) ---- ->>> function c1() { -1->^^^^^^^^ -2 > ^^-> -1-> -1->Emitted(4, 9) Source(3, 1) + SourceIndex(0) name (c1) ---- ->>> } -1->^^^^^^^^ -2 > ^ -3 > ^^^^^^^^^^-> -1->export class c1 { - > public p1: number; - > -2 > } -1->Emitted(5, 9) Source(5, 1) + SourceIndex(0) name (c1.constructor) -2 >Emitted(5, 10) Source(5, 2) + SourceIndex(0) name (c1.constructor) ---- ->>> return c1; -1->^^^^^^^^ -2 > ^^^^^^^^^ -1-> -2 > } -1->Emitted(6, 9) Source(5, 1) + SourceIndex(0) name (c1) -2 >Emitted(6, 18) Source(5, 2) + SourceIndex(0) name (c1) ---- ->>> })(); -1 >^^^^ -2 > ^ -3 > -4 > ^^^^ -5 > ^^^^^^^^^^^^-> -1 > -2 > } -3 > -4 > export class c1 { - > public p1: number; - > } -1 >Emitted(7, 5) Source(5, 1) + SourceIndex(0) name (c1) -2 >Emitted(7, 6) Source(5, 2) + SourceIndex(0) name (c1) -3 >Emitted(7, 6) Source(3, 1) + SourceIndex(0) -4 >Emitted(7, 10) Source(5, 2) + SourceIndex(0) ---- ->>> exports.c1 = c1; -1->^^^^ -2 > ^^^^^^^^^^ -3 > ^^^^^ -4 > ^ -5 > ^^^^^^^^^^^^^^-> -1-> -2 > c1 -3 > { - > public p1: number; - > } -4 > -1->Emitted(8, 5) Source(3, 14) + SourceIndex(0) -2 >Emitted(8, 15) Source(3, 16) + SourceIndex(0) -3 >Emitted(8, 20) Source(5, 2) + SourceIndex(0) -4 >Emitted(8, 21) Source(5, 2) + SourceIndex(0) ---- ->>> exports.instance1 = new c1(); -1->^^^^ -2 > ^^^^^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^^^ -5 > ^^ -6 > ^^ -7 > ^ -1-> - > - >export var -2 > instance1 -3 > = -4 > new -5 > c1 -6 > () -7 > ; -1->Emitted(9, 5) Source(7, 12) + SourceIndex(0) -2 >Emitted(9, 22) Source(7, 21) + SourceIndex(0) -3 >Emitted(9, 25) Source(7, 24) + SourceIndex(0) -4 >Emitted(9, 29) Source(7, 28) + SourceIndex(0) -5 >Emitted(9, 31) Source(7, 30) + SourceIndex(0) -6 >Emitted(9, 33) Source(7, 32) + SourceIndex(0) -7 >Emitted(9, 34) Source(7, 33) + SourceIndex(0) ---- ->>> function f1() { -1 >^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -1 >Emitted(10, 5) Source(8, 1) + SourceIndex(0) ---- ->>> return exports.instance1; -1->^^^^^^^^ -2 > ^^^^^^ -3 > ^ -4 > ^^^^^^^^^^^^^^^^^ -5 > ^ -1->export function f1() { - > -2 > return -3 > -4 > instance1 -5 > ; -1->Emitted(11, 9) Source(9, 5) + SourceIndex(0) name (f1) -2 >Emitted(11, 15) Source(9, 11) + SourceIndex(0) name (f1) -3 >Emitted(11, 16) Source(9, 12) + SourceIndex(0) name (f1) -4 >Emitted(11, 33) Source(9, 21) + SourceIndex(0) name (f1) -5 >Emitted(11, 34) Source(9, 22) + SourceIndex(0) name (f1) ---- ->>> } -1 >^^^^ -2 > ^ -3 > ^^^^^^^^^^^^^^^^-> -1 > - > -2 > } -1 >Emitted(12, 5) Source(10, 1) + SourceIndex(0) name (f1) -2 >Emitted(12, 6) Source(10, 2) + SourceIndex(0) name (f1) ---- ->>> exports.f1 = f1; -1->^^^^ -2 > ^^^^^^^^^^ -3 > ^^^^^ -4 > ^ -5 > ^^^^^^^-> -1-> -2 > f1 -3 > () { - > return instance1; - > } -4 > -1->Emitted(13, 5) Source(8, 17) + SourceIndex(0) -2 >Emitted(13, 15) Source(8, 19) + SourceIndex(0) -3 >Emitted(13, 20) Source(10, 2) + SourceIndex(0) -4 >Emitted(13, 21) Source(10, 2) + SourceIndex(0) ---- ->>> exports.a2 = m1.m1_c1; -1->^^^^ -2 > ^^^^^^^^^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^ -7 > ^ -1-> - > - >export var -2 > a2 -3 > = -4 > m1 -5 > . -6 > m1_c1 -7 > ; -1->Emitted(14, 5) Source(12, 12) + SourceIndex(0) -2 >Emitted(14, 15) Source(12, 14) + SourceIndex(0) -3 >Emitted(14, 18) Source(12, 17) + SourceIndex(0) -4 >Emitted(14, 20) Source(12, 19) + SourceIndex(0) -5 >Emitted(14, 21) Source(12, 20) + SourceIndex(0) -6 >Emitted(14, 26) Source(12, 25) + SourceIndex(0) -7 >Emitted(14, 27) Source(12, 26) + SourceIndex(0) ---- ->>>}); ->>>//# sourceMappingURL=test.js.map=================================================================== JsFile: test.js mapUrl: test.js.map sourceRoot: ../src/ diff --git a/tests/baselines/reference/project/sourceRootRelativePathModuleSubfolderSpecifyOutputFile/amd/test.d.ts b/tests/baselines/reference/project/sourceRootRelativePathModuleSubfolderSpecifyOutputFile/amd/test.d.ts deleted file mode 100644 index a61d8541048..00000000000 --- a/tests/baselines/reference/project/sourceRootRelativePathModuleSubfolderSpecifyOutputFile/amd/test.d.ts +++ /dev/null @@ -1,8 +0,0 @@ -import m1 = require("ref/m1"); -export declare var a1: number; -export declare class c1 { - p1: number; -} -export declare var instance1: c1; -export declare function f1(): c1; -export declare var a2: typeof m1.m1_c1; diff --git a/tests/baselines/reference/project/sourceRootRelativePathModuleSubfolderSpecifyOutputFile/amd/test.js b/tests/baselines/reference/project/sourceRootRelativePathModuleSubfolderSpecifyOutputFile/amd/test.js deleted file mode 100644 index 6c8aeb3190b..00000000000 --- a/tests/baselines/reference/project/sourceRootRelativePathModuleSubfolderSpecifyOutputFile/amd/test.js +++ /dev/null @@ -1,16 +0,0 @@ -define(["require", "exports", "ref/m1"], function (require, exports, m1) { - exports.a1 = 10; - var c1 = (function () { - function c1() { - } - return c1; - })(); - exports.c1 = c1; - exports.instance1 = new c1(); - function f1() { - return exports.instance1; - } - exports.f1 = f1; - exports.a2 = m1.m1_c1; -}); -//# sourceMappingURL=test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootRelativePathModuleSubfolderSpecifyOutputFile/amd/test.js.map b/tests/baselines/reference/project/sourceRootRelativePathModuleSubfolderSpecifyOutputFile/amd/test.js.map deleted file mode 100644 index 22f07c17544..00000000000 --- a/tests/baselines/reference/project/sourceRootRelativePathModuleSubfolderSpecifyOutputFile/amd/test.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"test.js","sourceRoot":"../src/","sources":["test.ts"],"names":["c1","c1.constructor","f1"],"mappings":";IACW,UAAE,GAAG,EAAE,CAAC;IACnB;QAAAA;QAEAC,CAACA;QAADD,SAACA;IAADA,CAACA,AAFD,IAEC;IAFY,UAAE,KAEd,CAAA;IAEU,iBAAS,GAAG,IAAI,EAAE,EAAE,CAAC;IAChC;QACIE,MAAMA,CAACA,iBAASA,CAACA;IACrBA,CAACA;IAFe,UAAE,KAEjB,CAAA;IAEU,UAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootRelativePathModuleSubfolderSpecifyOutputFile/node/ref/m1.d.ts b/tests/baselines/reference/project/sourceRootRelativePathModuleSubfolderSpecifyOutputFile/node/ref/m1.d.ts deleted file mode 100644 index 4a53b24b156..00000000000 --- a/tests/baselines/reference/project/sourceRootRelativePathModuleSubfolderSpecifyOutputFile/node/ref/m1.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -export declare var m1_a1: number; -export declare class m1_c1 { - m1_c1_p1: number; -} -export declare var m1_instance1: m1_c1; -export declare function m1_f1(): m1_c1; diff --git a/tests/baselines/reference/project/sourceRootRelativePathModuleSubfolderSpecifyOutputFile/node/ref/m1.js b/tests/baselines/reference/project/sourceRootRelativePathModuleSubfolderSpecifyOutputFile/node/ref/m1.js deleted file mode 100644 index 1b4470e2b37..00000000000 --- a/tests/baselines/reference/project/sourceRootRelativePathModuleSubfolderSpecifyOutputFile/node/ref/m1.js +++ /dev/null @@ -1,13 +0,0 @@ -exports.m1_a1 = 10; -var m1_c1 = (function () { - function m1_c1() { - } - return m1_c1; -})(); -exports.m1_c1 = m1_c1; -exports.m1_instance1 = new m1_c1(); -function m1_f1() { - return exports.m1_instance1; -} -exports.m1_f1 = m1_f1; -//# sourceMappingURL=m1.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootRelativePathModuleSubfolderSpecifyOutputFile/node/ref/m1.js.map b/tests/baselines/reference/project/sourceRootRelativePathModuleSubfolderSpecifyOutputFile/node/ref/m1.js.map deleted file mode 100644 index 702b574b614..00000000000 --- a/tests/baselines/reference/project/sourceRootRelativePathModuleSubfolderSpecifyOutputFile/node/ref/m1.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"m1.js","sourceRoot":"../src/","sources":["ref/m1.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1"],"mappings":"AAAW,aAAK,GAAG,EAAE,CAAC;AACtB;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAFY,aAAK,QAEjB,CAAA;AAEU,oBAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACIE,MAAMA,CAACA,oBAAYA,CAACA;AACxBA,CAACA;AAFe,aAAK,QAEpB,CAAA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootRelativePathModuleSubfolderSpecifyOutputFile/node/sourceRootRelativePathModuleSubfolderSpecifyOutputFile.json b/tests/baselines/reference/project/sourceRootRelativePathModuleSubfolderSpecifyOutputFile/node/sourceRootRelativePathModuleSubfolderSpecifyOutputFile.json index 71896f202b2..a5966ef08b8 100644 --- a/tests/baselines/reference/project/sourceRootRelativePathModuleSubfolderSpecifyOutputFile/node/sourceRootRelativePathModuleSubfolderSpecifyOutputFile.json +++ b/tests/baselines/reference/project/sourceRootRelativePathModuleSubfolderSpecifyOutputFile/node/sourceRootRelativePathModuleSubfolderSpecifyOutputFile.json @@ -15,12 +15,6 @@ "test.ts" ], "emittedFiles": [ - "ref/m1.js.map", - "ref/m1.js", - "ref/m1.d.ts", - "test.js.map", - "test.js", - "test.d.ts", "bin/test.js.map", "bin/test.js", "bin/test.d.ts" diff --git a/tests/baselines/reference/project/sourceRootRelativePathModuleSubfolderSpecifyOutputFile/node/sourceRootRelativePathModuleSubfolderSpecifyOutputFile.sourcemap.txt b/tests/baselines/reference/project/sourceRootRelativePathModuleSubfolderSpecifyOutputFile/node/sourceRootRelativePathModuleSubfolderSpecifyOutputFile.sourcemap.txt index 7e4dd146e52..b05ffee34ca 100644 --- a/tests/baselines/reference/project/sourceRootRelativePathModuleSubfolderSpecifyOutputFile/node/sourceRootRelativePathModuleSubfolderSpecifyOutputFile.sourcemap.txt +++ b/tests/baselines/reference/project/sourceRootRelativePathModuleSubfolderSpecifyOutputFile/node/sourceRootRelativePathModuleSubfolderSpecifyOutputFile.sourcemap.txt @@ -1,396 +1,4 @@ =================================================================== -JsFile: m1.js -mapUrl: m1.js.map -sourceRoot: ../src/ -sources: ref/m1.ts -=================================================================== -------------------------------------------------------------------- -emittedFile:ref/m1.js -sourceFile:ref/m1.ts -------------------------------------------------------------------- ->>>exports.m1_a1 = 10; -1 > -2 >^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^-> -1 >export var -2 >m1_a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(1, 1) Source(1, 12) + SourceIndex(0) -2 >Emitted(1, 14) Source(1, 17) + SourceIndex(0) -3 >Emitted(1, 17) Source(1, 20) + SourceIndex(0) -4 >Emitted(1, 19) Source(1, 22) + SourceIndex(0) -5 >Emitted(1, 20) Source(1, 23) + SourceIndex(0) ---- ->>>var m1_c1 = (function () { -1-> -2 >^^^^^^^^^^^^^^^^^^^^^^^-> -1-> - > -1->Emitted(2, 1) Source(2, 1) + SourceIndex(0) ---- ->>> function m1_c1() { -1->^^^^ -2 > ^^-> -1-> -1->Emitted(3, 5) Source(2, 1) + SourceIndex(0) name (m1_c1) ---- ->>> } -1->^^^^ -2 > ^ -3 > ^^^^^^^^^^^^^-> -1->export class m1_c1 { - > public m1_c1_p1: number; - > -2 > } -1->Emitted(4, 5) Source(4, 1) + SourceIndex(0) name (m1_c1.constructor) -2 >Emitted(4, 6) Source(4, 2) + SourceIndex(0) name (m1_c1.constructor) ---- ->>> return m1_c1; -1->^^^^ -2 > ^^^^^^^^^^^^ -1-> -2 > } -1->Emitted(5, 5) Source(4, 1) + SourceIndex(0) name (m1_c1) -2 >Emitted(5, 17) Source(4, 2) + SourceIndex(0) name (m1_c1) ---- ->>>})(); -1 > -2 >^ -3 > -4 > ^^^^ -5 > ^^^^^^^^^^^^^^^^^^-> -1 > -2 >} -3 > -4 > export class m1_c1 { - > public m1_c1_p1: number; - > } -1 >Emitted(6, 1) Source(4, 1) + SourceIndex(0) name (m1_c1) -2 >Emitted(6, 2) Source(4, 2) + SourceIndex(0) name (m1_c1) -3 >Emitted(6, 2) Source(2, 1) + SourceIndex(0) -4 >Emitted(6, 6) Source(4, 2) + SourceIndex(0) ---- ->>>exports.m1_c1 = m1_c1; -1-> -2 >^^^^^^^^^^^^^ -3 > ^^^^^^^^ -4 > ^ -5 > ^^^^^^^^^^^^^^-> -1-> -2 >m1_c1 -3 > { - > public m1_c1_p1: number; - > } -4 > -1->Emitted(7, 1) Source(2, 14) + SourceIndex(0) -2 >Emitted(7, 14) Source(2, 19) + SourceIndex(0) -3 >Emitted(7, 22) Source(4, 2) + SourceIndex(0) -4 >Emitted(7, 23) Source(4, 2) + SourceIndex(0) ---- ->>>exports.m1_instance1 = new m1_c1(); -1-> -2 >^^^^^^^^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^^^ -5 > ^^^^^ -6 > ^^ -7 > ^ -1-> - > - >export var -2 >m1_instance1 -3 > = -4 > new -5 > m1_c1 -6 > () -7 > ; -1->Emitted(8, 1) Source(6, 12) + SourceIndex(0) -2 >Emitted(8, 21) Source(6, 24) + SourceIndex(0) -3 >Emitted(8, 24) Source(6, 27) + SourceIndex(0) -4 >Emitted(8, 28) Source(6, 31) + SourceIndex(0) -5 >Emitted(8, 33) Source(6, 36) + SourceIndex(0) -6 >Emitted(8, 35) Source(6, 38) + SourceIndex(0) -7 >Emitted(8, 36) Source(6, 39) + SourceIndex(0) ---- ->>>function m1_f1() { -1 > -2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -1 >Emitted(9, 1) Source(7, 1) + SourceIndex(0) ---- ->>> return exports.m1_instance1; -1->^^^^ -2 > ^^^^^^ -3 > ^ -4 > ^^^^^^^^^^^^^^^^^^^^ -5 > ^ -1->export function m1_f1() { - > -2 > return -3 > -4 > m1_instance1 -5 > ; -1->Emitted(10, 5) Source(8, 5) + SourceIndex(0) name (m1_f1) -2 >Emitted(10, 11) Source(8, 11) + SourceIndex(0) name (m1_f1) -3 >Emitted(10, 12) Source(8, 12) + SourceIndex(0) name (m1_f1) -4 >Emitted(10, 32) Source(8, 24) + SourceIndex(0) name (m1_f1) -5 >Emitted(10, 33) Source(8, 25) + SourceIndex(0) name (m1_f1) ---- ->>>} -1 > -2 >^ -3 > ^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -2 >} -1 >Emitted(11, 1) Source(9, 1) + SourceIndex(0) name (m1_f1) -2 >Emitted(11, 2) Source(9, 2) + SourceIndex(0) name (m1_f1) ---- ->>>exports.m1_f1 = m1_f1; -1-> -2 >^^^^^^^^^^^^^ -3 > ^^^^^^^^ -4 > ^ -5 > ^^^^^^^-> -1-> -2 >m1_f1 -3 > () { - > return m1_instance1; - > } -4 > -1->Emitted(12, 1) Source(7, 17) + SourceIndex(0) -2 >Emitted(12, 14) Source(7, 22) + SourceIndex(0) -3 >Emitted(12, 22) Source(9, 2) + SourceIndex(0) -4 >Emitted(12, 23) Source(9, 2) + SourceIndex(0) ---- ->>>//# sourceMappingURL=m1.js.map=================================================================== -JsFile: test.js -mapUrl: test.js.map -sourceRoot: ../src/ -sources: test.ts -=================================================================== -------------------------------------------------------------------- -emittedFile:test.js -sourceFile:test.ts -------------------------------------------------------------------- ->>>var m1 = require("ref/m1"); -1 > -2 >^^^^ -3 > ^^ -4 > ^^^^^^^^^^^ -5 > ^^^^^^^^ -6 > ^ -7 > ^ -1 > -2 >import -3 > m1 -4 > = require( -5 > "ref/m1" -6 > ) -7 > ; -1 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) -2 >Emitted(1, 5) Source(1, 8) + SourceIndex(0) -3 >Emitted(1, 7) Source(1, 10) + SourceIndex(0) -4 >Emitted(1, 18) Source(1, 21) + SourceIndex(0) -5 >Emitted(1, 26) Source(1, 29) + SourceIndex(0) -6 >Emitted(1, 27) Source(1, 30) + SourceIndex(0) -7 >Emitted(1, 28) Source(1, 31) + SourceIndex(0) ---- ->>>exports.a1 = 10; -1 > -2 >^^^^^^^^^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^-> -1 > - >export var -2 >a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(2, 1) Source(2, 12) + SourceIndex(0) -2 >Emitted(2, 11) Source(2, 14) + SourceIndex(0) -3 >Emitted(2, 14) Source(2, 17) + SourceIndex(0) -4 >Emitted(2, 16) Source(2, 19) + SourceIndex(0) -5 >Emitted(2, 17) Source(2, 20) + SourceIndex(0) ---- ->>>var c1 = (function () { -1-> -2 >^^^^^^^^^^^^^^^^^^^^-> -1-> - > -1->Emitted(3, 1) Source(3, 1) + SourceIndex(0) ---- ->>> function c1() { -1->^^^^ -2 > ^^-> -1-> -1->Emitted(4, 5) Source(3, 1) + SourceIndex(0) name (c1) ---- ->>> } -1->^^^^ -2 > ^ -3 > ^^^^^^^^^^-> -1->export class c1 { - > public p1: number; - > -2 > } -1->Emitted(5, 5) Source(5, 1) + SourceIndex(0) name (c1.constructor) -2 >Emitted(5, 6) Source(5, 2) + SourceIndex(0) name (c1.constructor) ---- ->>> return c1; -1->^^^^ -2 > ^^^^^^^^^ -1-> -2 > } -1->Emitted(6, 5) Source(5, 1) + SourceIndex(0) name (c1) -2 >Emitted(6, 14) Source(5, 2) + SourceIndex(0) name (c1) ---- ->>>})(); -1 > -2 >^ -3 > -4 > ^^^^ -5 > ^^^^^^^^^^^^-> -1 > -2 >} -3 > -4 > export class c1 { - > public p1: number; - > } -1 >Emitted(7, 1) Source(5, 1) + SourceIndex(0) name (c1) -2 >Emitted(7, 2) Source(5, 2) + SourceIndex(0) name (c1) -3 >Emitted(7, 2) Source(3, 1) + SourceIndex(0) -4 >Emitted(7, 6) Source(5, 2) + SourceIndex(0) ---- ->>>exports.c1 = c1; -1-> -2 >^^^^^^^^^^ -3 > ^^^^^ -4 > ^ -5 > ^^^^^^^^^^^^^^-> -1-> -2 >c1 -3 > { - > public p1: number; - > } -4 > -1->Emitted(8, 1) Source(3, 14) + SourceIndex(0) -2 >Emitted(8, 11) Source(3, 16) + SourceIndex(0) -3 >Emitted(8, 16) Source(5, 2) + SourceIndex(0) -4 >Emitted(8, 17) Source(5, 2) + SourceIndex(0) ---- ->>>exports.instance1 = new c1(); -1-> -2 >^^^^^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^^^ -5 > ^^ -6 > ^^ -7 > ^ -1-> - > - >export var -2 >instance1 -3 > = -4 > new -5 > c1 -6 > () -7 > ; -1->Emitted(9, 1) Source(7, 12) + SourceIndex(0) -2 >Emitted(9, 18) Source(7, 21) + SourceIndex(0) -3 >Emitted(9, 21) Source(7, 24) + SourceIndex(0) -4 >Emitted(9, 25) Source(7, 28) + SourceIndex(0) -5 >Emitted(9, 27) Source(7, 30) + SourceIndex(0) -6 >Emitted(9, 29) Source(7, 32) + SourceIndex(0) -7 >Emitted(9, 30) Source(7, 33) + SourceIndex(0) ---- ->>>function f1() { -1 > -2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -1 >Emitted(10, 1) Source(8, 1) + SourceIndex(0) ---- ->>> return exports.instance1; -1->^^^^ -2 > ^^^^^^ -3 > ^ -4 > ^^^^^^^^^^^^^^^^^ -5 > ^ -1->export function f1() { - > -2 > return -3 > -4 > instance1 -5 > ; -1->Emitted(11, 5) Source(9, 5) + SourceIndex(0) name (f1) -2 >Emitted(11, 11) Source(9, 11) + SourceIndex(0) name (f1) -3 >Emitted(11, 12) Source(9, 12) + SourceIndex(0) name (f1) -4 >Emitted(11, 29) Source(9, 21) + SourceIndex(0) name (f1) -5 >Emitted(11, 30) Source(9, 22) + SourceIndex(0) name (f1) ---- ->>>} -1 > -2 >^ -3 > ^^^^^^^^^^^^^^^^-> -1 > - > -2 >} -1 >Emitted(12, 1) Source(10, 1) + SourceIndex(0) name (f1) -2 >Emitted(12, 2) Source(10, 2) + SourceIndex(0) name (f1) ---- ->>>exports.f1 = f1; -1-> -2 >^^^^^^^^^^ -3 > ^^^^^ -4 > ^ -5 > ^^^^^^^-> -1-> -2 >f1 -3 > () { - > return instance1; - > } -4 > -1->Emitted(13, 1) Source(8, 17) + SourceIndex(0) -2 >Emitted(13, 11) Source(8, 19) + SourceIndex(0) -3 >Emitted(13, 16) Source(10, 2) + SourceIndex(0) -4 >Emitted(13, 17) Source(10, 2) + SourceIndex(0) ---- ->>>exports.a2 = m1.m1_c1; -1-> -2 >^^^^^^^^^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^ -7 > ^ -8 > ^^^^^^^^^-> -1-> - > - >export var -2 >a2 -3 > = -4 > m1 -5 > . -6 > m1_c1 -7 > ; -1->Emitted(14, 1) Source(12, 12) + SourceIndex(0) -2 >Emitted(14, 11) Source(12, 14) + SourceIndex(0) -3 >Emitted(14, 14) Source(12, 17) + SourceIndex(0) -4 >Emitted(14, 16) Source(12, 19) + SourceIndex(0) -5 >Emitted(14, 17) Source(12, 20) + SourceIndex(0) -6 >Emitted(14, 22) Source(12, 25) + SourceIndex(0) -7 >Emitted(14, 23) Source(12, 26) + SourceIndex(0) ---- ->>>//# sourceMappingURL=test.js.map=================================================================== JsFile: test.js mapUrl: test.js.map sourceRoot: ../src/ diff --git a/tests/baselines/reference/project/sourceRootRelativePathModuleSubfolderSpecifyOutputFile/node/test.d.ts b/tests/baselines/reference/project/sourceRootRelativePathModuleSubfolderSpecifyOutputFile/node/test.d.ts deleted file mode 100644 index a61d8541048..00000000000 --- a/tests/baselines/reference/project/sourceRootRelativePathModuleSubfolderSpecifyOutputFile/node/test.d.ts +++ /dev/null @@ -1,8 +0,0 @@ -import m1 = require("ref/m1"); -export declare var a1: number; -export declare class c1 { - p1: number; -} -export declare var instance1: c1; -export declare function f1(): c1; -export declare var a2: typeof m1.m1_c1; diff --git a/tests/baselines/reference/project/sourceRootRelativePathModuleSubfolderSpecifyOutputFile/node/test.js b/tests/baselines/reference/project/sourceRootRelativePathModuleSubfolderSpecifyOutputFile/node/test.js deleted file mode 100644 index 46c9f29e55a..00000000000 --- a/tests/baselines/reference/project/sourceRootRelativePathModuleSubfolderSpecifyOutputFile/node/test.js +++ /dev/null @@ -1,15 +0,0 @@ -var m1 = require("ref/m1"); -exports.a1 = 10; -var c1 = (function () { - function c1() { - } - return c1; -})(); -exports.c1 = c1; -exports.instance1 = new c1(); -function f1() { - return exports.instance1; -} -exports.f1 = f1; -exports.a2 = m1.m1_c1; -//# sourceMappingURL=test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootRelativePathModuleSubfolderSpecifyOutputFile/node/test.js.map b/tests/baselines/reference/project/sourceRootRelativePathModuleSubfolderSpecifyOutputFile/node/test.js.map deleted file mode 100644 index b3972a3cfc1..00000000000 --- a/tests/baselines/reference/project/sourceRootRelativePathModuleSubfolderSpecifyOutputFile/node/test.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"test.js","sourceRoot":"../src/","sources":["test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AAAA,IAAO,EAAE,WAAW,QAAQ,CAAC,CAAC;AACnB,UAAE,GAAG,EAAE,CAAC;AACnB;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAFY,UAAE,KAEd,CAAA;AAEU,iBAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AAChC;IACIE,MAAMA,CAACA,iBAASA,CAACA;AACrBA,CAACA;AAFe,UAAE,KAEjB,CAAA;AAEU,UAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFile/amd/ref/m2.d.ts b/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFile/amd/ref/m2.d.ts deleted file mode 100644 index c09a3c0c32a..00000000000 --- a/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFile/amd/ref/m2.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -export declare var m2_a1: number; -export declare class m2_c1 { - m2_c1_p1: number; -} -export declare var m2_instance1: m2_c1; -export declare function m2_f1(): m2_c1; diff --git a/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFile/amd/ref/m2.js b/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFile/amd/ref/m2.js deleted file mode 100644 index 144ad24e2de..00000000000 --- a/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFile/amd/ref/m2.js +++ /dev/null @@ -1,15 +0,0 @@ -define(["require", "exports"], function (require, exports) { - exports.m2_a1 = 10; - var m2_c1 = (function () { - function m2_c1() { - } - return m2_c1; - })(); - exports.m2_c1 = m2_c1; - exports.m2_instance1 = new m2_c1(); - function m2_f1() { - return exports.m2_instance1; - } - exports.m2_f1 = m2_f1; -}); -//# sourceMappingURL=m2.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFile/amd/ref/m2.js.map b/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFile/amd/ref/m2.js.map deleted file mode 100644 index cbb7eed4953..00000000000 --- a/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFile/amd/ref/m2.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"m2.js","sourceRoot":"","sources":["m2.ts"],"names":["m2_c1","m2_c1.constructor","m2_f1"],"mappings":";IAAW,aAAK,GAAG,EAAE,CAAC;IACtB;QAAAA;QAEAC,CAACA;QAADD,YAACA;IAADA,CAACA,AAFD,IAEC;IAFY,aAAK,QAEjB,CAAA;IAEU,oBAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACIE,MAAMA,CAACA,oBAAYA,CAACA;IACxBA,CAACA;IAFe,aAAK,QAEpB,CAAA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFile/amd/sourcemapMixedSubfolderSpecifyOutputFile.json b/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFile/amd/sourcemapMixedSubfolderSpecifyOutputFile.json index 3270fe610aa..39cb44f229f 100644 --- a/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFile/amd/sourcemapMixedSubfolderSpecifyOutputFile.json +++ b/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFile/amd/sourcemapMixedSubfolderSpecifyOutputFile.json @@ -15,9 +15,6 @@ "test.ts" ], "emittedFiles": [ - "ref/m2.js.map", - "ref/m2.js", - "ref/m2.d.ts", "bin/test.js.map", "bin/test.js", "bin/test.d.ts" diff --git a/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFile/amd/sourcemapMixedSubfolderSpecifyOutputFile.sourcemap.txt b/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFile/amd/sourcemapMixedSubfolderSpecifyOutputFile.sourcemap.txt index 23f10a2cf62..821236c5c85 100644 --- a/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFile/amd/sourcemapMixedSubfolderSpecifyOutputFile.sourcemap.txt +++ b/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFile/amd/sourcemapMixedSubfolderSpecifyOutputFile.sourcemap.txt @@ -1,176 +1,4 @@ =================================================================== -JsFile: m2.js -mapUrl: m2.js.map -sourceRoot: -sources: m2.ts -=================================================================== -------------------------------------------------------------------- -emittedFile:ref/m2.js -sourceFile:m2.ts -------------------------------------------------------------------- ->>>define(["require", "exports"], function (require, exports) { ->>> exports.m2_a1 = 10; -1 >^^^^ -2 > ^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^-> -1 >export var -2 > m2_a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(2, 5) Source(1, 12) + SourceIndex(0) -2 >Emitted(2, 18) Source(1, 17) + SourceIndex(0) -3 >Emitted(2, 21) Source(1, 20) + SourceIndex(0) -4 >Emitted(2, 23) Source(1, 22) + SourceIndex(0) -5 >Emitted(2, 24) Source(1, 23) + SourceIndex(0) ---- ->>> var m2_c1 = (function () { -1->^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^^^^-> -1-> - > -1->Emitted(3, 5) Source(2, 1) + SourceIndex(0) ---- ->>> function m2_c1() { -1->^^^^^^^^ -2 > ^^-> -1-> -1->Emitted(4, 9) Source(2, 1) + SourceIndex(0) name (m2_c1) ---- ->>> } -1->^^^^^^^^ -2 > ^ -3 > ^^^^^^^^^^^^^-> -1->export class m2_c1 { - > public m2_c1_p1: number; - > -2 > } -1->Emitted(5, 9) Source(4, 1) + SourceIndex(0) name (m2_c1.constructor) -2 >Emitted(5, 10) Source(4, 2) + SourceIndex(0) name (m2_c1.constructor) ---- ->>> return m2_c1; -1->^^^^^^^^ -2 > ^^^^^^^^^^^^ -1-> -2 > } -1->Emitted(6, 9) Source(4, 1) + SourceIndex(0) name (m2_c1) -2 >Emitted(6, 21) Source(4, 2) + SourceIndex(0) name (m2_c1) ---- ->>> })(); -1 >^^^^ -2 > ^ -3 > -4 > ^^^^ -5 > ^^^^^^^^^^^^^^^^^^-> -1 > -2 > } -3 > -4 > export class m2_c1 { - > public m2_c1_p1: number; - > } -1 >Emitted(7, 5) Source(4, 1) + SourceIndex(0) name (m2_c1) -2 >Emitted(7, 6) Source(4, 2) + SourceIndex(0) name (m2_c1) -3 >Emitted(7, 6) Source(2, 1) + SourceIndex(0) -4 >Emitted(7, 10) Source(4, 2) + SourceIndex(0) ---- ->>> exports.m2_c1 = m2_c1; -1->^^^^ -2 > ^^^^^^^^^^^^^ -3 > ^^^^^^^^ -4 > ^ -5 > ^^^^^^^^^^^^^^-> -1-> -2 > m2_c1 -3 > { - > public m2_c1_p1: number; - > } -4 > -1->Emitted(8, 5) Source(2, 14) + SourceIndex(0) -2 >Emitted(8, 18) Source(2, 19) + SourceIndex(0) -3 >Emitted(8, 26) Source(4, 2) + SourceIndex(0) -4 >Emitted(8, 27) Source(4, 2) + SourceIndex(0) ---- ->>> exports.m2_instance1 = new m2_c1(); -1->^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^^^ -5 > ^^^^^ -6 > ^^ -7 > ^ -1-> - > - >export var -2 > m2_instance1 -3 > = -4 > new -5 > m2_c1 -6 > () -7 > ; -1->Emitted(9, 5) Source(6, 12) + SourceIndex(0) -2 >Emitted(9, 25) Source(6, 24) + SourceIndex(0) -3 >Emitted(9, 28) Source(6, 27) + SourceIndex(0) -4 >Emitted(9, 32) Source(6, 31) + SourceIndex(0) -5 >Emitted(9, 37) Source(6, 36) + SourceIndex(0) -6 >Emitted(9, 39) Source(6, 38) + SourceIndex(0) -7 >Emitted(9, 40) Source(6, 39) + SourceIndex(0) ---- ->>> function m2_f1() { -1 >^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -1 >Emitted(10, 5) Source(7, 1) + SourceIndex(0) ---- ->>> return exports.m2_instance1; -1->^^^^^^^^ -2 > ^^^^^^ -3 > ^ -4 > ^^^^^^^^^^^^^^^^^^^^ -5 > ^ -1->export function m2_f1() { - > -2 > return -3 > -4 > m2_instance1 -5 > ; -1->Emitted(11, 9) Source(8, 5) + SourceIndex(0) name (m2_f1) -2 >Emitted(11, 15) Source(8, 11) + SourceIndex(0) name (m2_f1) -3 >Emitted(11, 16) Source(8, 12) + SourceIndex(0) name (m2_f1) -4 >Emitted(11, 36) Source(8, 24) + SourceIndex(0) name (m2_f1) -5 >Emitted(11, 37) Source(8, 25) + SourceIndex(0) name (m2_f1) ---- ->>> } -1 >^^^^ -2 > ^ -3 > ^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -2 > } -1 >Emitted(12, 5) Source(9, 1) + SourceIndex(0) name (m2_f1) -2 >Emitted(12, 6) Source(9, 2) + SourceIndex(0) name (m2_f1) ---- ->>> exports.m2_f1 = m2_f1; -1->^^^^ -2 > ^^^^^^^^^^^^^ -3 > ^^^^^^^^ -4 > ^ -1-> -2 > m2_f1 -3 > () { - > return m2_instance1; - > } -4 > -1->Emitted(13, 5) Source(7, 17) + SourceIndex(0) -2 >Emitted(13, 18) Source(7, 22) + SourceIndex(0) -3 >Emitted(13, 26) Source(9, 2) + SourceIndex(0) -4 >Emitted(13, 27) Source(9, 2) + SourceIndex(0) ---- ->>>}); ->>>//# sourceMappingURL=m2.js.map=================================================================== JsFile: test.js mapUrl: test.js.map sourceRoot: diff --git a/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFile/node/ref/m2.d.ts b/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFile/node/ref/m2.d.ts deleted file mode 100644 index c09a3c0c32a..00000000000 --- a/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFile/node/ref/m2.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -export declare var m2_a1: number; -export declare class m2_c1 { - m2_c1_p1: number; -} -export declare var m2_instance1: m2_c1; -export declare function m2_f1(): m2_c1; diff --git a/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFile/node/ref/m2.js b/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFile/node/ref/m2.js deleted file mode 100644 index ec0a73b5af8..00000000000 --- a/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFile/node/ref/m2.js +++ /dev/null @@ -1,13 +0,0 @@ -exports.m2_a1 = 10; -var m2_c1 = (function () { - function m2_c1() { - } - return m2_c1; -})(); -exports.m2_c1 = m2_c1; -exports.m2_instance1 = new m2_c1(); -function m2_f1() { - return exports.m2_instance1; -} -exports.m2_f1 = m2_f1; -//# sourceMappingURL=m2.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFile/node/ref/m2.js.map b/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFile/node/ref/m2.js.map deleted file mode 100644 index 0826e9e95f3..00000000000 --- a/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFile/node/ref/m2.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"m2.js","sourceRoot":"","sources":["m2.ts"],"names":["m2_c1","m2_c1.constructor","m2_f1"],"mappings":"AAAW,aAAK,GAAG,EAAE,CAAC;AACtB;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAFY,aAAK,QAEjB,CAAA;AAEU,oBAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACIE,MAAMA,CAACA,oBAAYA,CAACA;AACxBA,CAACA;AAFe,aAAK,QAEpB,CAAA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFile/node/sourcemapMixedSubfolderSpecifyOutputFile.json b/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFile/node/sourcemapMixedSubfolderSpecifyOutputFile.json index 3270fe610aa..39cb44f229f 100644 --- a/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFile/node/sourcemapMixedSubfolderSpecifyOutputFile.json +++ b/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFile/node/sourcemapMixedSubfolderSpecifyOutputFile.json @@ -15,9 +15,6 @@ "test.ts" ], "emittedFiles": [ - "ref/m2.js.map", - "ref/m2.js", - "ref/m2.d.ts", "bin/test.js.map", "bin/test.js", "bin/test.d.ts" diff --git a/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFile/node/sourcemapMixedSubfolderSpecifyOutputFile.sourcemap.txt b/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFile/node/sourcemapMixedSubfolderSpecifyOutputFile.sourcemap.txt index 4bc6731c326..e37948398a3 100644 --- a/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFile/node/sourcemapMixedSubfolderSpecifyOutputFile.sourcemap.txt +++ b/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFile/node/sourcemapMixedSubfolderSpecifyOutputFile.sourcemap.txt @@ -1,175 +1,4 @@ =================================================================== -JsFile: m2.js -mapUrl: m2.js.map -sourceRoot: -sources: m2.ts -=================================================================== -------------------------------------------------------------------- -emittedFile:ref/m2.js -sourceFile:m2.ts -------------------------------------------------------------------- ->>>exports.m2_a1 = 10; -1 > -2 >^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^-> -1 >export var -2 >m2_a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(1, 1) Source(1, 12) + SourceIndex(0) -2 >Emitted(1, 14) Source(1, 17) + SourceIndex(0) -3 >Emitted(1, 17) Source(1, 20) + SourceIndex(0) -4 >Emitted(1, 19) Source(1, 22) + SourceIndex(0) -5 >Emitted(1, 20) Source(1, 23) + SourceIndex(0) ---- ->>>var m2_c1 = (function () { -1-> -2 >^^^^^^^^^^^^^^^^^^^^^^^-> -1-> - > -1->Emitted(2, 1) Source(2, 1) + SourceIndex(0) ---- ->>> function m2_c1() { -1->^^^^ -2 > ^^-> -1-> -1->Emitted(3, 5) Source(2, 1) + SourceIndex(0) name (m2_c1) ---- ->>> } -1->^^^^ -2 > ^ -3 > ^^^^^^^^^^^^^-> -1->export class m2_c1 { - > public m2_c1_p1: number; - > -2 > } -1->Emitted(4, 5) Source(4, 1) + SourceIndex(0) name (m2_c1.constructor) -2 >Emitted(4, 6) Source(4, 2) + SourceIndex(0) name (m2_c1.constructor) ---- ->>> return m2_c1; -1->^^^^ -2 > ^^^^^^^^^^^^ -1-> -2 > } -1->Emitted(5, 5) Source(4, 1) + SourceIndex(0) name (m2_c1) -2 >Emitted(5, 17) Source(4, 2) + SourceIndex(0) name (m2_c1) ---- ->>>})(); -1 > -2 >^ -3 > -4 > ^^^^ -5 > ^^^^^^^^^^^^^^^^^^-> -1 > -2 >} -3 > -4 > export class m2_c1 { - > public m2_c1_p1: number; - > } -1 >Emitted(6, 1) Source(4, 1) + SourceIndex(0) name (m2_c1) -2 >Emitted(6, 2) Source(4, 2) + SourceIndex(0) name (m2_c1) -3 >Emitted(6, 2) Source(2, 1) + SourceIndex(0) -4 >Emitted(6, 6) Source(4, 2) + SourceIndex(0) ---- ->>>exports.m2_c1 = m2_c1; -1-> -2 >^^^^^^^^^^^^^ -3 > ^^^^^^^^ -4 > ^ -5 > ^^^^^^^^^^^^^^-> -1-> -2 >m2_c1 -3 > { - > public m2_c1_p1: number; - > } -4 > -1->Emitted(7, 1) Source(2, 14) + SourceIndex(0) -2 >Emitted(7, 14) Source(2, 19) + SourceIndex(0) -3 >Emitted(7, 22) Source(4, 2) + SourceIndex(0) -4 >Emitted(7, 23) Source(4, 2) + SourceIndex(0) ---- ->>>exports.m2_instance1 = new m2_c1(); -1-> -2 >^^^^^^^^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^^^ -5 > ^^^^^ -6 > ^^ -7 > ^ -1-> - > - >export var -2 >m2_instance1 -3 > = -4 > new -5 > m2_c1 -6 > () -7 > ; -1->Emitted(8, 1) Source(6, 12) + SourceIndex(0) -2 >Emitted(8, 21) Source(6, 24) + SourceIndex(0) -3 >Emitted(8, 24) Source(6, 27) + SourceIndex(0) -4 >Emitted(8, 28) Source(6, 31) + SourceIndex(0) -5 >Emitted(8, 33) Source(6, 36) + SourceIndex(0) -6 >Emitted(8, 35) Source(6, 38) + SourceIndex(0) -7 >Emitted(8, 36) Source(6, 39) + SourceIndex(0) ---- ->>>function m2_f1() { -1 > -2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -1 >Emitted(9, 1) Source(7, 1) + SourceIndex(0) ---- ->>> return exports.m2_instance1; -1->^^^^ -2 > ^^^^^^ -3 > ^ -4 > ^^^^^^^^^^^^^^^^^^^^ -5 > ^ -1->export function m2_f1() { - > -2 > return -3 > -4 > m2_instance1 -5 > ; -1->Emitted(10, 5) Source(8, 5) + SourceIndex(0) name (m2_f1) -2 >Emitted(10, 11) Source(8, 11) + SourceIndex(0) name (m2_f1) -3 >Emitted(10, 12) Source(8, 12) + SourceIndex(0) name (m2_f1) -4 >Emitted(10, 32) Source(8, 24) + SourceIndex(0) name (m2_f1) -5 >Emitted(10, 33) Source(8, 25) + SourceIndex(0) name (m2_f1) ---- ->>>} -1 > -2 >^ -3 > ^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -2 >} -1 >Emitted(11, 1) Source(9, 1) + SourceIndex(0) name (m2_f1) -2 >Emitted(11, 2) Source(9, 2) + SourceIndex(0) name (m2_f1) ---- ->>>exports.m2_f1 = m2_f1; -1-> -2 >^^^^^^^^^^^^^ -3 > ^^^^^^^^ -4 > ^ -5 > ^^^^^^^-> -1-> -2 >m2_f1 -3 > () { - > return m2_instance1; - > } -4 > -1->Emitted(12, 1) Source(7, 17) + SourceIndex(0) -2 >Emitted(12, 14) Source(7, 22) + SourceIndex(0) -3 >Emitted(12, 22) Source(9, 2) + SourceIndex(0) -4 >Emitted(12, 23) Source(9, 2) + SourceIndex(0) ---- ->>>//# sourceMappingURL=m2.js.map=================================================================== JsFile: test.js mapUrl: test.js.map sourceRoot: diff --git a/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/outdir/outAndOutDirFolder/ref/m2.d.ts b/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/outdir/outAndOutDirFolder/ref/m2.d.ts deleted file mode 100644 index c09a3c0c32a..00000000000 --- a/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/outdir/outAndOutDirFolder/ref/m2.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -export declare var m2_a1: number; -export declare class m2_c1 { - m2_c1_p1: number; -} -export declare var m2_instance1: m2_c1; -export declare function m2_f1(): m2_c1; diff --git a/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/outdir/outAndOutDirFolder/ref/m2.js b/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/outdir/outAndOutDirFolder/ref/m2.js deleted file mode 100644 index 144ad24e2de..00000000000 --- a/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/outdir/outAndOutDirFolder/ref/m2.js +++ /dev/null @@ -1,15 +0,0 @@ -define(["require", "exports"], function (require, exports) { - exports.m2_a1 = 10; - var m2_c1 = (function () { - function m2_c1() { - } - return m2_c1; - })(); - exports.m2_c1 = m2_c1; - exports.m2_instance1 = new m2_c1(); - function m2_f1() { - return exports.m2_instance1; - } - exports.m2_f1 = m2_f1; -}); -//# sourceMappingURL=m2.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/outdir/outAndOutDirFolder/ref/m2.js.map b/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/outdir/outAndOutDirFolder/ref/m2.js.map deleted file mode 100644 index aabf49f904d..00000000000 --- a/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/outdir/outAndOutDirFolder/ref/m2.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"m2.js","sourceRoot":"","sources":["../../../ref/m2.ts"],"names":["m2_c1","m2_c1.constructor","m2_f1"],"mappings":";IAAW,aAAK,GAAG,EAAE,CAAC;IACtB;QAAAA;QAEAC,CAACA;QAADD,YAACA;IAADA,CAACA,AAFD,IAEC;IAFY,aAAK,QAEjB,CAAA;IAEU,oBAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACIE,MAAMA,CAACA,oBAAYA,CAACA;IACxBA,CAACA;IAFe,aAAK,QAEpB,CAAA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/sourcemapMixedSubfolderSpecifyOutputFileAndOutputDirectory.json b/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/sourcemapMixedSubfolderSpecifyOutputFileAndOutputDirectory.json index 3a260af84a0..117a18c7c7a 100644 --- a/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/sourcemapMixedSubfolderSpecifyOutputFileAndOutputDirectory.json +++ b/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/sourcemapMixedSubfolderSpecifyOutputFileAndOutputDirectory.json @@ -16,9 +16,6 @@ "test.ts" ], "emittedFiles": [ - "outdir/outAndOutDirFolder/ref/m2.js.map", - "outdir/outAndOutDirFolder/ref/m2.js", - "outdir/outAndOutDirFolder/ref/m2.d.ts", "bin/outAndOutDirFile.js.map", "bin/outAndOutDirFile.js", "bin/outAndOutDirFile.d.ts" diff --git a/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/sourcemapMixedSubfolderSpecifyOutputFileAndOutputDirectory.sourcemap.txt b/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/sourcemapMixedSubfolderSpecifyOutputFileAndOutputDirectory.sourcemap.txt index 5a223fb7109..4394eb0748e 100644 --- a/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/sourcemapMixedSubfolderSpecifyOutputFileAndOutputDirectory.sourcemap.txt +++ b/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/sourcemapMixedSubfolderSpecifyOutputFileAndOutputDirectory.sourcemap.txt @@ -1,176 +1,4 @@ =================================================================== -JsFile: m2.js -mapUrl: m2.js.map -sourceRoot: -sources: ../../../ref/m2.ts -=================================================================== -------------------------------------------------------------------- -emittedFile:outdir/outAndOutDirFolder/ref/m2.js -sourceFile:../../../ref/m2.ts -------------------------------------------------------------------- ->>>define(["require", "exports"], function (require, exports) { ->>> exports.m2_a1 = 10; -1 >^^^^ -2 > ^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^-> -1 >export var -2 > m2_a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(2, 5) Source(1, 12) + SourceIndex(0) -2 >Emitted(2, 18) Source(1, 17) + SourceIndex(0) -3 >Emitted(2, 21) Source(1, 20) + SourceIndex(0) -4 >Emitted(2, 23) Source(1, 22) + SourceIndex(0) -5 >Emitted(2, 24) Source(1, 23) + SourceIndex(0) ---- ->>> var m2_c1 = (function () { -1->^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^^^^-> -1-> - > -1->Emitted(3, 5) Source(2, 1) + SourceIndex(0) ---- ->>> function m2_c1() { -1->^^^^^^^^ -2 > ^^-> -1-> -1->Emitted(4, 9) Source(2, 1) + SourceIndex(0) name (m2_c1) ---- ->>> } -1->^^^^^^^^ -2 > ^ -3 > ^^^^^^^^^^^^^-> -1->export class m2_c1 { - > public m2_c1_p1: number; - > -2 > } -1->Emitted(5, 9) Source(4, 1) + SourceIndex(0) name (m2_c1.constructor) -2 >Emitted(5, 10) Source(4, 2) + SourceIndex(0) name (m2_c1.constructor) ---- ->>> return m2_c1; -1->^^^^^^^^ -2 > ^^^^^^^^^^^^ -1-> -2 > } -1->Emitted(6, 9) Source(4, 1) + SourceIndex(0) name (m2_c1) -2 >Emitted(6, 21) Source(4, 2) + SourceIndex(0) name (m2_c1) ---- ->>> })(); -1 >^^^^ -2 > ^ -3 > -4 > ^^^^ -5 > ^^^^^^^^^^^^^^^^^^-> -1 > -2 > } -3 > -4 > export class m2_c1 { - > public m2_c1_p1: number; - > } -1 >Emitted(7, 5) Source(4, 1) + SourceIndex(0) name (m2_c1) -2 >Emitted(7, 6) Source(4, 2) + SourceIndex(0) name (m2_c1) -3 >Emitted(7, 6) Source(2, 1) + SourceIndex(0) -4 >Emitted(7, 10) Source(4, 2) + SourceIndex(0) ---- ->>> exports.m2_c1 = m2_c1; -1->^^^^ -2 > ^^^^^^^^^^^^^ -3 > ^^^^^^^^ -4 > ^ -5 > ^^^^^^^^^^^^^^-> -1-> -2 > m2_c1 -3 > { - > public m2_c1_p1: number; - > } -4 > -1->Emitted(8, 5) Source(2, 14) + SourceIndex(0) -2 >Emitted(8, 18) Source(2, 19) + SourceIndex(0) -3 >Emitted(8, 26) Source(4, 2) + SourceIndex(0) -4 >Emitted(8, 27) Source(4, 2) + SourceIndex(0) ---- ->>> exports.m2_instance1 = new m2_c1(); -1->^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^^^ -5 > ^^^^^ -6 > ^^ -7 > ^ -1-> - > - >export var -2 > m2_instance1 -3 > = -4 > new -5 > m2_c1 -6 > () -7 > ; -1->Emitted(9, 5) Source(6, 12) + SourceIndex(0) -2 >Emitted(9, 25) Source(6, 24) + SourceIndex(0) -3 >Emitted(9, 28) Source(6, 27) + SourceIndex(0) -4 >Emitted(9, 32) Source(6, 31) + SourceIndex(0) -5 >Emitted(9, 37) Source(6, 36) + SourceIndex(0) -6 >Emitted(9, 39) Source(6, 38) + SourceIndex(0) -7 >Emitted(9, 40) Source(6, 39) + SourceIndex(0) ---- ->>> function m2_f1() { -1 >^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -1 >Emitted(10, 5) Source(7, 1) + SourceIndex(0) ---- ->>> return exports.m2_instance1; -1->^^^^^^^^ -2 > ^^^^^^ -3 > ^ -4 > ^^^^^^^^^^^^^^^^^^^^ -5 > ^ -1->export function m2_f1() { - > -2 > return -3 > -4 > m2_instance1 -5 > ; -1->Emitted(11, 9) Source(8, 5) + SourceIndex(0) name (m2_f1) -2 >Emitted(11, 15) Source(8, 11) + SourceIndex(0) name (m2_f1) -3 >Emitted(11, 16) Source(8, 12) + SourceIndex(0) name (m2_f1) -4 >Emitted(11, 36) Source(8, 24) + SourceIndex(0) name (m2_f1) -5 >Emitted(11, 37) Source(8, 25) + SourceIndex(0) name (m2_f1) ---- ->>> } -1 >^^^^ -2 > ^ -3 > ^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -2 > } -1 >Emitted(12, 5) Source(9, 1) + SourceIndex(0) name (m2_f1) -2 >Emitted(12, 6) Source(9, 2) + SourceIndex(0) name (m2_f1) ---- ->>> exports.m2_f1 = m2_f1; -1->^^^^ -2 > ^^^^^^^^^^^^^ -3 > ^^^^^^^^ -4 > ^ -1-> -2 > m2_f1 -3 > () { - > return m2_instance1; - > } -4 > -1->Emitted(13, 5) Source(7, 17) + SourceIndex(0) -2 >Emitted(13, 18) Source(7, 22) + SourceIndex(0) -3 >Emitted(13, 26) Source(9, 2) + SourceIndex(0) -4 >Emitted(13, 27) Source(9, 2) + SourceIndex(0) ---- ->>>}); ->>>//# sourceMappingURL=m2.js.map=================================================================== JsFile: outAndOutDirFile.js mapUrl: outAndOutDirFile.js.map sourceRoot: diff --git a/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/outdir/outAndOutDirFolder/ref/m2.d.ts b/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/outdir/outAndOutDirFolder/ref/m2.d.ts deleted file mode 100644 index c09a3c0c32a..00000000000 --- a/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/outdir/outAndOutDirFolder/ref/m2.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -export declare var m2_a1: number; -export declare class m2_c1 { - m2_c1_p1: number; -} -export declare var m2_instance1: m2_c1; -export declare function m2_f1(): m2_c1; diff --git a/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/outdir/outAndOutDirFolder/ref/m2.js b/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/outdir/outAndOutDirFolder/ref/m2.js deleted file mode 100644 index ec0a73b5af8..00000000000 --- a/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/outdir/outAndOutDirFolder/ref/m2.js +++ /dev/null @@ -1,13 +0,0 @@ -exports.m2_a1 = 10; -var m2_c1 = (function () { - function m2_c1() { - } - return m2_c1; -})(); -exports.m2_c1 = m2_c1; -exports.m2_instance1 = new m2_c1(); -function m2_f1() { - return exports.m2_instance1; -} -exports.m2_f1 = m2_f1; -//# sourceMappingURL=m2.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/outdir/outAndOutDirFolder/ref/m2.js.map b/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/outdir/outAndOutDirFolder/ref/m2.js.map deleted file mode 100644 index e31d90a8f0c..00000000000 --- a/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/outdir/outAndOutDirFolder/ref/m2.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"m2.js","sourceRoot":"","sources":["../../../ref/m2.ts"],"names":["m2_c1","m2_c1.constructor","m2_f1"],"mappings":"AAAW,aAAK,GAAG,EAAE,CAAC;AACtB;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAFY,aAAK,QAEjB,CAAA;AAEU,oBAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACIE,MAAMA,CAACA,oBAAYA,CAACA;AACxBA,CAACA;AAFe,aAAK,QAEpB,CAAA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/sourcemapMixedSubfolderSpecifyOutputFileAndOutputDirectory.json b/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/sourcemapMixedSubfolderSpecifyOutputFileAndOutputDirectory.json index 3a260af84a0..117a18c7c7a 100644 --- a/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/sourcemapMixedSubfolderSpecifyOutputFileAndOutputDirectory.json +++ b/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/sourcemapMixedSubfolderSpecifyOutputFileAndOutputDirectory.json @@ -16,9 +16,6 @@ "test.ts" ], "emittedFiles": [ - "outdir/outAndOutDirFolder/ref/m2.js.map", - "outdir/outAndOutDirFolder/ref/m2.js", - "outdir/outAndOutDirFolder/ref/m2.d.ts", "bin/outAndOutDirFile.js.map", "bin/outAndOutDirFile.js", "bin/outAndOutDirFile.d.ts" diff --git a/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/sourcemapMixedSubfolderSpecifyOutputFileAndOutputDirectory.sourcemap.txt b/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/sourcemapMixedSubfolderSpecifyOutputFileAndOutputDirectory.sourcemap.txt index b36bfbd8c56..9486ad5e3a7 100644 --- a/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/sourcemapMixedSubfolderSpecifyOutputFileAndOutputDirectory.sourcemap.txt +++ b/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/sourcemapMixedSubfolderSpecifyOutputFileAndOutputDirectory.sourcemap.txt @@ -1,175 +1,4 @@ =================================================================== -JsFile: m2.js -mapUrl: m2.js.map -sourceRoot: -sources: ../../../ref/m2.ts -=================================================================== -------------------------------------------------------------------- -emittedFile:outdir/outAndOutDirFolder/ref/m2.js -sourceFile:../../../ref/m2.ts -------------------------------------------------------------------- ->>>exports.m2_a1 = 10; -1 > -2 >^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^-> -1 >export var -2 >m2_a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(1, 1) Source(1, 12) + SourceIndex(0) -2 >Emitted(1, 14) Source(1, 17) + SourceIndex(0) -3 >Emitted(1, 17) Source(1, 20) + SourceIndex(0) -4 >Emitted(1, 19) Source(1, 22) + SourceIndex(0) -5 >Emitted(1, 20) Source(1, 23) + SourceIndex(0) ---- ->>>var m2_c1 = (function () { -1-> -2 >^^^^^^^^^^^^^^^^^^^^^^^-> -1-> - > -1->Emitted(2, 1) Source(2, 1) + SourceIndex(0) ---- ->>> function m2_c1() { -1->^^^^ -2 > ^^-> -1-> -1->Emitted(3, 5) Source(2, 1) + SourceIndex(0) name (m2_c1) ---- ->>> } -1->^^^^ -2 > ^ -3 > ^^^^^^^^^^^^^-> -1->export class m2_c1 { - > public m2_c1_p1: number; - > -2 > } -1->Emitted(4, 5) Source(4, 1) + SourceIndex(0) name (m2_c1.constructor) -2 >Emitted(4, 6) Source(4, 2) + SourceIndex(0) name (m2_c1.constructor) ---- ->>> return m2_c1; -1->^^^^ -2 > ^^^^^^^^^^^^ -1-> -2 > } -1->Emitted(5, 5) Source(4, 1) + SourceIndex(0) name (m2_c1) -2 >Emitted(5, 17) Source(4, 2) + SourceIndex(0) name (m2_c1) ---- ->>>})(); -1 > -2 >^ -3 > -4 > ^^^^ -5 > ^^^^^^^^^^^^^^^^^^-> -1 > -2 >} -3 > -4 > export class m2_c1 { - > public m2_c1_p1: number; - > } -1 >Emitted(6, 1) Source(4, 1) + SourceIndex(0) name (m2_c1) -2 >Emitted(6, 2) Source(4, 2) + SourceIndex(0) name (m2_c1) -3 >Emitted(6, 2) Source(2, 1) + SourceIndex(0) -4 >Emitted(6, 6) Source(4, 2) + SourceIndex(0) ---- ->>>exports.m2_c1 = m2_c1; -1-> -2 >^^^^^^^^^^^^^ -3 > ^^^^^^^^ -4 > ^ -5 > ^^^^^^^^^^^^^^-> -1-> -2 >m2_c1 -3 > { - > public m2_c1_p1: number; - > } -4 > -1->Emitted(7, 1) Source(2, 14) + SourceIndex(0) -2 >Emitted(7, 14) Source(2, 19) + SourceIndex(0) -3 >Emitted(7, 22) Source(4, 2) + SourceIndex(0) -4 >Emitted(7, 23) Source(4, 2) + SourceIndex(0) ---- ->>>exports.m2_instance1 = new m2_c1(); -1-> -2 >^^^^^^^^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^^^ -5 > ^^^^^ -6 > ^^ -7 > ^ -1-> - > - >export var -2 >m2_instance1 -3 > = -4 > new -5 > m2_c1 -6 > () -7 > ; -1->Emitted(8, 1) Source(6, 12) + SourceIndex(0) -2 >Emitted(8, 21) Source(6, 24) + SourceIndex(0) -3 >Emitted(8, 24) Source(6, 27) + SourceIndex(0) -4 >Emitted(8, 28) Source(6, 31) + SourceIndex(0) -5 >Emitted(8, 33) Source(6, 36) + SourceIndex(0) -6 >Emitted(8, 35) Source(6, 38) + SourceIndex(0) -7 >Emitted(8, 36) Source(6, 39) + SourceIndex(0) ---- ->>>function m2_f1() { -1 > -2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -1 >Emitted(9, 1) Source(7, 1) + SourceIndex(0) ---- ->>> return exports.m2_instance1; -1->^^^^ -2 > ^^^^^^ -3 > ^ -4 > ^^^^^^^^^^^^^^^^^^^^ -5 > ^ -1->export function m2_f1() { - > -2 > return -3 > -4 > m2_instance1 -5 > ; -1->Emitted(10, 5) Source(8, 5) + SourceIndex(0) name (m2_f1) -2 >Emitted(10, 11) Source(8, 11) + SourceIndex(0) name (m2_f1) -3 >Emitted(10, 12) Source(8, 12) + SourceIndex(0) name (m2_f1) -4 >Emitted(10, 32) Source(8, 24) + SourceIndex(0) name (m2_f1) -5 >Emitted(10, 33) Source(8, 25) + SourceIndex(0) name (m2_f1) ---- ->>>} -1 > -2 >^ -3 > ^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -2 >} -1 >Emitted(11, 1) Source(9, 1) + SourceIndex(0) name (m2_f1) -2 >Emitted(11, 2) Source(9, 2) + SourceIndex(0) name (m2_f1) ---- ->>>exports.m2_f1 = m2_f1; -1-> -2 >^^^^^^^^^^^^^ -3 > ^^^^^^^^ -4 > ^ -5 > ^^^^^^^-> -1-> -2 >m2_f1 -3 > () { - > return m2_instance1; - > } -4 > -1->Emitted(12, 1) Source(7, 17) + SourceIndex(0) -2 >Emitted(12, 14) Source(7, 22) + SourceIndex(0) -3 >Emitted(12, 22) Source(9, 2) + SourceIndex(0) -4 >Emitted(12, 23) Source(9, 2) + SourceIndex(0) ---- ->>>//# sourceMappingURL=m2.js.map=================================================================== JsFile: outAndOutDirFile.js mapUrl: outAndOutDirFile.js.map sourceRoot: diff --git a/tests/baselines/reference/project/sourcemapModuleMultifolderSpecifyOutputFile/amd/diskFile0.js.map b/tests/baselines/reference/project/sourcemapModuleMultifolderSpecifyOutputFile/amd/diskFile0.js.map deleted file mode 100644 index cbb7eed4953..00000000000 --- a/tests/baselines/reference/project/sourcemapModuleMultifolderSpecifyOutputFile/amd/diskFile0.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"m2.js","sourceRoot":"","sources":["m2.ts"],"names":["m2_c1","m2_c1.constructor","m2_f1"],"mappings":";IAAW,aAAK,GAAG,EAAE,CAAC;IACtB;QAAAA;QAEAC,CAACA;QAADD,YAACA;IAADA,CAACA,AAFD,IAEC;IAFY,aAAK,QAEjB,CAAA;IAEU,oBAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACIE,MAAMA,CAACA,oBAAYA,CAACA;IACxBA,CAACA;IAFe,aAAK,QAEpB,CAAA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcemapModuleMultifolderSpecifyOutputFile/amd/diskFile1.js b/tests/baselines/reference/project/sourcemapModuleMultifolderSpecifyOutputFile/amd/diskFile1.js deleted file mode 100644 index 144ad24e2de..00000000000 --- a/tests/baselines/reference/project/sourcemapModuleMultifolderSpecifyOutputFile/amd/diskFile1.js +++ /dev/null @@ -1,15 +0,0 @@ -define(["require", "exports"], function (require, exports) { - exports.m2_a1 = 10; - var m2_c1 = (function () { - function m2_c1() { - } - return m2_c1; - })(); - exports.m2_c1 = m2_c1; - exports.m2_instance1 = new m2_c1(); - function m2_f1() { - return exports.m2_instance1; - } - exports.m2_f1 = m2_f1; -}); -//# sourceMappingURL=m2.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcemapModuleMultifolderSpecifyOutputFile/amd/diskFile2.d.ts b/tests/baselines/reference/project/sourcemapModuleMultifolderSpecifyOutputFile/amd/diskFile2.d.ts deleted file mode 100644 index c09a3c0c32a..00000000000 --- a/tests/baselines/reference/project/sourcemapModuleMultifolderSpecifyOutputFile/amd/diskFile2.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -export declare var m2_a1: number; -export declare class m2_c1 { - m2_c1_p1: number; -} -export declare var m2_instance1: m2_c1; -export declare function m2_f1(): m2_c1; diff --git a/tests/baselines/reference/project/sourcemapModuleMultifolderSpecifyOutputFile/amd/ref/m1.d.ts b/tests/baselines/reference/project/sourcemapModuleMultifolderSpecifyOutputFile/amd/ref/m1.d.ts deleted file mode 100644 index 4a53b24b156..00000000000 --- a/tests/baselines/reference/project/sourcemapModuleMultifolderSpecifyOutputFile/amd/ref/m1.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -export declare var m1_a1: number; -export declare class m1_c1 { - m1_c1_p1: number; -} -export declare var m1_instance1: m1_c1; -export declare function m1_f1(): m1_c1; diff --git a/tests/baselines/reference/project/sourcemapModuleMultifolderSpecifyOutputFile/amd/ref/m1.js b/tests/baselines/reference/project/sourcemapModuleMultifolderSpecifyOutputFile/amd/ref/m1.js deleted file mode 100644 index bbaba444ba2..00000000000 --- a/tests/baselines/reference/project/sourcemapModuleMultifolderSpecifyOutputFile/amd/ref/m1.js +++ /dev/null @@ -1,15 +0,0 @@ -define(["require", "exports"], function (require, exports) { - exports.m1_a1 = 10; - var m1_c1 = (function () { - function m1_c1() { - } - return m1_c1; - })(); - exports.m1_c1 = m1_c1; - exports.m1_instance1 = new m1_c1(); - function m1_f1() { - return exports.m1_instance1; - } - exports.m1_f1 = m1_f1; -}); -//# sourceMappingURL=m1.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcemapModuleMultifolderSpecifyOutputFile/amd/ref/m1.js.map b/tests/baselines/reference/project/sourcemapModuleMultifolderSpecifyOutputFile/amd/ref/m1.js.map deleted file mode 100644 index 51755e4c9a3..00000000000 --- a/tests/baselines/reference/project/sourcemapModuleMultifolderSpecifyOutputFile/amd/ref/m1.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"m1.js","sourceRoot":"","sources":["m1.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1"],"mappings":";IAAW,aAAK,GAAG,EAAE,CAAC;IACtB;QAAAA;QAEAC,CAACA;QAADD,YAACA;IAADA,CAACA,AAFD,IAEC;IAFY,aAAK,QAEjB,CAAA;IAEU,oBAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACIE,MAAMA,CAACA,oBAAYA,CAACA;IACxBA,CAACA;IAFe,aAAK,QAEpB,CAAA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcemapModuleMultifolderSpecifyOutputFile/amd/sourcemapModuleMultifolderSpecifyOutputFile.json b/tests/baselines/reference/project/sourcemapModuleMultifolderSpecifyOutputFile/amd/sourcemapModuleMultifolderSpecifyOutputFile.json index 3d2df95ad66..7ba960c4bef 100644 --- a/tests/baselines/reference/project/sourcemapModuleMultifolderSpecifyOutputFile/amd/sourcemapModuleMultifolderSpecifyOutputFile.json +++ b/tests/baselines/reference/project/sourcemapModuleMultifolderSpecifyOutputFile/amd/sourcemapModuleMultifolderSpecifyOutputFile.json @@ -15,15 +15,6 @@ "test.ts" ], "emittedFiles": [ - "ref/m1.js.map", - "ref/m1.js", - "ref/m1.d.ts", - "../outputdir_module_multifolder_ref/m2.js.map", - "../outputdir_module_multifolder_ref/m2.js", - "../outputdir_module_multifolder_ref/m2.d.ts", - "test.js.map", - "test.js", - "test.d.ts", "bin/test.js.map", "bin/test.js", "bin/test.d.ts" diff --git a/tests/baselines/reference/project/sourcemapModuleMultifolderSpecifyOutputFile/amd/sourcemapModuleMultifolderSpecifyOutputFile.sourcemap.txt b/tests/baselines/reference/project/sourcemapModuleMultifolderSpecifyOutputFile/amd/sourcemapModuleMultifolderSpecifyOutputFile.sourcemap.txt index 3fa1bc7e057..6c8bdf4da74 100644 --- a/tests/baselines/reference/project/sourcemapModuleMultifolderSpecifyOutputFile/amd/sourcemapModuleMultifolderSpecifyOutputFile.sourcemap.txt +++ b/tests/baselines/reference/project/sourcemapModuleMultifolderSpecifyOutputFile/amd/sourcemapModuleMultifolderSpecifyOutputFile.sourcemap.txt @@ -1,573 +1,4 @@ =================================================================== -JsFile: m1.js -mapUrl: m1.js.map -sourceRoot: -sources: m1.ts -=================================================================== -------------------------------------------------------------------- -emittedFile:ref/m1.js -sourceFile:m1.ts -------------------------------------------------------------------- ->>>define(["require", "exports"], function (require, exports) { ->>> exports.m1_a1 = 10; -1 >^^^^ -2 > ^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^-> -1 >export var -2 > m1_a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(2, 5) Source(1, 12) + SourceIndex(0) -2 >Emitted(2, 18) Source(1, 17) + SourceIndex(0) -3 >Emitted(2, 21) Source(1, 20) + SourceIndex(0) -4 >Emitted(2, 23) Source(1, 22) + SourceIndex(0) -5 >Emitted(2, 24) Source(1, 23) + SourceIndex(0) ---- ->>> var m1_c1 = (function () { -1->^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^^^^-> -1-> - > -1->Emitted(3, 5) Source(2, 1) + SourceIndex(0) ---- ->>> function m1_c1() { -1->^^^^^^^^ -2 > ^^-> -1-> -1->Emitted(4, 9) Source(2, 1) + SourceIndex(0) name (m1_c1) ---- ->>> } -1->^^^^^^^^ -2 > ^ -3 > ^^^^^^^^^^^^^-> -1->export class m1_c1 { - > public m1_c1_p1: number; - > -2 > } -1->Emitted(5, 9) Source(4, 1) + SourceIndex(0) name (m1_c1.constructor) -2 >Emitted(5, 10) Source(4, 2) + SourceIndex(0) name (m1_c1.constructor) ---- ->>> return m1_c1; -1->^^^^^^^^ -2 > ^^^^^^^^^^^^ -1-> -2 > } -1->Emitted(6, 9) Source(4, 1) + SourceIndex(0) name (m1_c1) -2 >Emitted(6, 21) Source(4, 2) + SourceIndex(0) name (m1_c1) ---- ->>> })(); -1 >^^^^ -2 > ^ -3 > -4 > ^^^^ -5 > ^^^^^^^^^^^^^^^^^^-> -1 > -2 > } -3 > -4 > export class m1_c1 { - > public m1_c1_p1: number; - > } -1 >Emitted(7, 5) Source(4, 1) + SourceIndex(0) name (m1_c1) -2 >Emitted(7, 6) Source(4, 2) + SourceIndex(0) name (m1_c1) -3 >Emitted(7, 6) Source(2, 1) + SourceIndex(0) -4 >Emitted(7, 10) Source(4, 2) + SourceIndex(0) ---- ->>> exports.m1_c1 = m1_c1; -1->^^^^ -2 > ^^^^^^^^^^^^^ -3 > ^^^^^^^^ -4 > ^ -5 > ^^^^^^^^^^^^^^-> -1-> -2 > m1_c1 -3 > { - > public m1_c1_p1: number; - > } -4 > -1->Emitted(8, 5) Source(2, 14) + SourceIndex(0) -2 >Emitted(8, 18) Source(2, 19) + SourceIndex(0) -3 >Emitted(8, 26) Source(4, 2) + SourceIndex(0) -4 >Emitted(8, 27) Source(4, 2) + SourceIndex(0) ---- ->>> exports.m1_instance1 = new m1_c1(); -1->^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^^^ -5 > ^^^^^ -6 > ^^ -7 > ^ -1-> - > - >export var -2 > m1_instance1 -3 > = -4 > new -5 > m1_c1 -6 > () -7 > ; -1->Emitted(9, 5) Source(6, 12) + SourceIndex(0) -2 >Emitted(9, 25) Source(6, 24) + SourceIndex(0) -3 >Emitted(9, 28) Source(6, 27) + SourceIndex(0) -4 >Emitted(9, 32) Source(6, 31) + SourceIndex(0) -5 >Emitted(9, 37) Source(6, 36) + SourceIndex(0) -6 >Emitted(9, 39) Source(6, 38) + SourceIndex(0) -7 >Emitted(9, 40) Source(6, 39) + SourceIndex(0) ---- ->>> function m1_f1() { -1 >^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -1 >Emitted(10, 5) Source(7, 1) + SourceIndex(0) ---- ->>> return exports.m1_instance1; -1->^^^^^^^^ -2 > ^^^^^^ -3 > ^ -4 > ^^^^^^^^^^^^^^^^^^^^ -5 > ^ -1->export function m1_f1() { - > -2 > return -3 > -4 > m1_instance1 -5 > ; -1->Emitted(11, 9) Source(8, 5) + SourceIndex(0) name (m1_f1) -2 >Emitted(11, 15) Source(8, 11) + SourceIndex(0) name (m1_f1) -3 >Emitted(11, 16) Source(8, 12) + SourceIndex(0) name (m1_f1) -4 >Emitted(11, 36) Source(8, 24) + SourceIndex(0) name (m1_f1) -5 >Emitted(11, 37) Source(8, 25) + SourceIndex(0) name (m1_f1) ---- ->>> } -1 >^^^^ -2 > ^ -3 > ^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -2 > } -1 >Emitted(12, 5) Source(9, 1) + SourceIndex(0) name (m1_f1) -2 >Emitted(12, 6) Source(9, 2) + SourceIndex(0) name (m1_f1) ---- ->>> exports.m1_f1 = m1_f1; -1->^^^^ -2 > ^^^^^^^^^^^^^ -3 > ^^^^^^^^ -4 > ^ -1-> -2 > m1_f1 -3 > () { - > return m1_instance1; - > } -4 > -1->Emitted(13, 5) Source(7, 17) + SourceIndex(0) -2 >Emitted(13, 18) Source(7, 22) + SourceIndex(0) -3 >Emitted(13, 26) Source(9, 2) + SourceIndex(0) -4 >Emitted(13, 27) Source(9, 2) + SourceIndex(0) ---- ->>>}); ->>>//# sourceMappingURL=m1.js.map=================================================================== -JsFile: m2.js -mapUrl: m2.js.map -sourceRoot: -sources: m2.ts -=================================================================== -------------------------------------------------------------------- -emittedFile:diskFile1.js -sourceFile:m2.ts -------------------------------------------------------------------- ->>>define(["require", "exports"], function (require, exports) { ->>> exports.m2_a1 = 10; -1 >^^^^ -2 > ^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^-> -1 >export var -2 > m2_a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(2, 5) Source(1, 12) + SourceIndex(0) -2 >Emitted(2, 18) Source(1, 17) + SourceIndex(0) -3 >Emitted(2, 21) Source(1, 20) + SourceIndex(0) -4 >Emitted(2, 23) Source(1, 22) + SourceIndex(0) -5 >Emitted(2, 24) Source(1, 23) + SourceIndex(0) ---- ->>> var m2_c1 = (function () { -1->^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^^^^-> -1-> - > -1->Emitted(3, 5) Source(2, 1) + SourceIndex(0) ---- ->>> function m2_c1() { -1->^^^^^^^^ -2 > ^^-> -1-> -1->Emitted(4, 9) Source(2, 1) + SourceIndex(0) name (m2_c1) ---- ->>> } -1->^^^^^^^^ -2 > ^ -3 > ^^^^^^^^^^^^^-> -1->export class m2_c1 { - > public m2_c1_p1: number; - > -2 > } -1->Emitted(5, 9) Source(4, 1) + SourceIndex(0) name (m2_c1.constructor) -2 >Emitted(5, 10) Source(4, 2) + SourceIndex(0) name (m2_c1.constructor) ---- ->>> return m2_c1; -1->^^^^^^^^ -2 > ^^^^^^^^^^^^ -1-> -2 > } -1->Emitted(6, 9) Source(4, 1) + SourceIndex(0) name (m2_c1) -2 >Emitted(6, 21) Source(4, 2) + SourceIndex(0) name (m2_c1) ---- ->>> })(); -1 >^^^^ -2 > ^ -3 > -4 > ^^^^ -5 > ^^^^^^^^^^^^^^^^^^-> -1 > -2 > } -3 > -4 > export class m2_c1 { - > public m2_c1_p1: number; - > } -1 >Emitted(7, 5) Source(4, 1) + SourceIndex(0) name (m2_c1) -2 >Emitted(7, 6) Source(4, 2) + SourceIndex(0) name (m2_c1) -3 >Emitted(7, 6) Source(2, 1) + SourceIndex(0) -4 >Emitted(7, 10) Source(4, 2) + SourceIndex(0) ---- ->>> exports.m2_c1 = m2_c1; -1->^^^^ -2 > ^^^^^^^^^^^^^ -3 > ^^^^^^^^ -4 > ^ -5 > ^^^^^^^^^^^^^^-> -1-> -2 > m2_c1 -3 > { - > public m2_c1_p1: number; - > } -4 > -1->Emitted(8, 5) Source(2, 14) + SourceIndex(0) -2 >Emitted(8, 18) Source(2, 19) + SourceIndex(0) -3 >Emitted(8, 26) Source(4, 2) + SourceIndex(0) -4 >Emitted(8, 27) Source(4, 2) + SourceIndex(0) ---- ->>> exports.m2_instance1 = new m2_c1(); -1->^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^^^ -5 > ^^^^^ -6 > ^^ -7 > ^ -1-> - > - >export var -2 > m2_instance1 -3 > = -4 > new -5 > m2_c1 -6 > () -7 > ; -1->Emitted(9, 5) Source(6, 12) + SourceIndex(0) -2 >Emitted(9, 25) Source(6, 24) + SourceIndex(0) -3 >Emitted(9, 28) Source(6, 27) + SourceIndex(0) -4 >Emitted(9, 32) Source(6, 31) + SourceIndex(0) -5 >Emitted(9, 37) Source(6, 36) + SourceIndex(0) -6 >Emitted(9, 39) Source(6, 38) + SourceIndex(0) -7 >Emitted(9, 40) Source(6, 39) + SourceIndex(0) ---- ->>> function m2_f1() { -1 >^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -1 >Emitted(10, 5) Source(7, 1) + SourceIndex(0) ---- ->>> return exports.m2_instance1; -1->^^^^^^^^ -2 > ^^^^^^ -3 > ^ -4 > ^^^^^^^^^^^^^^^^^^^^ -5 > ^ -1->export function m2_f1() { - > -2 > return -3 > -4 > m2_instance1 -5 > ; -1->Emitted(11, 9) Source(8, 5) + SourceIndex(0) name (m2_f1) -2 >Emitted(11, 15) Source(8, 11) + SourceIndex(0) name (m2_f1) -3 >Emitted(11, 16) Source(8, 12) + SourceIndex(0) name (m2_f1) -4 >Emitted(11, 36) Source(8, 24) + SourceIndex(0) name (m2_f1) -5 >Emitted(11, 37) Source(8, 25) + SourceIndex(0) name (m2_f1) ---- ->>> } -1 >^^^^ -2 > ^ -3 > ^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -2 > } -1 >Emitted(12, 5) Source(9, 1) + SourceIndex(0) name (m2_f1) -2 >Emitted(12, 6) Source(9, 2) + SourceIndex(0) name (m2_f1) ---- ->>> exports.m2_f1 = m2_f1; -1->^^^^ -2 > ^^^^^^^^^^^^^ -3 > ^^^^^^^^ -4 > ^ -1-> -2 > m2_f1 -3 > () { - > return m2_instance1; - > } -4 > -1->Emitted(13, 5) Source(7, 17) + SourceIndex(0) -2 >Emitted(13, 18) Source(7, 22) + SourceIndex(0) -3 >Emitted(13, 26) Source(9, 2) + SourceIndex(0) -4 >Emitted(13, 27) Source(9, 2) + SourceIndex(0) ---- ->>>}); ->>>//# sourceMappingURL=m2.js.map=================================================================== -JsFile: test.js -mapUrl: test.js.map -sourceRoot: -sources: test.ts -=================================================================== -------------------------------------------------------------------- -emittedFile:test.js -sourceFile:test.ts -------------------------------------------------------------------- ->>>define(["require", "exports", "ref/m1", "../outputdir_module_multifolder_ref/m2"], function (require, exports, m1, m2) { ->>> exports.a1 = 10; -1 >^^^^ -2 > ^^^^^^^^^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^-> -1 >import m1 = require("ref/m1"); - >import m2 = require("../outputdir_module_multifolder_ref/m2"); - >export var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(2, 5) Source(3, 12) + SourceIndex(0) -2 >Emitted(2, 15) Source(3, 14) + SourceIndex(0) -3 >Emitted(2, 18) Source(3, 17) + SourceIndex(0) -4 >Emitted(2, 20) Source(3, 19) + SourceIndex(0) -5 >Emitted(2, 21) Source(3, 20) + SourceIndex(0) ---- ->>> var c1 = (function () { -1->^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^-> -1-> - > -1->Emitted(3, 5) Source(4, 1) + SourceIndex(0) ---- ->>> function c1() { -1->^^^^^^^^ -2 > ^^-> -1-> -1->Emitted(4, 9) Source(4, 1) + SourceIndex(0) name (c1) ---- ->>> } -1->^^^^^^^^ -2 > ^ -3 > ^^^^^^^^^^-> -1->export class c1 { - > public p1: number; - > -2 > } -1->Emitted(5, 9) Source(6, 1) + SourceIndex(0) name (c1.constructor) -2 >Emitted(5, 10) Source(6, 2) + SourceIndex(0) name (c1.constructor) ---- ->>> return c1; -1->^^^^^^^^ -2 > ^^^^^^^^^ -1-> -2 > } -1->Emitted(6, 9) Source(6, 1) + SourceIndex(0) name (c1) -2 >Emitted(6, 18) Source(6, 2) + SourceIndex(0) name (c1) ---- ->>> })(); -1 >^^^^ -2 > ^ -3 > -4 > ^^^^ -5 > ^^^^^^^^^^^^-> -1 > -2 > } -3 > -4 > export class c1 { - > public p1: number; - > } -1 >Emitted(7, 5) Source(6, 1) + SourceIndex(0) name (c1) -2 >Emitted(7, 6) Source(6, 2) + SourceIndex(0) name (c1) -3 >Emitted(7, 6) Source(4, 1) + SourceIndex(0) -4 >Emitted(7, 10) Source(6, 2) + SourceIndex(0) ---- ->>> exports.c1 = c1; -1->^^^^ -2 > ^^^^^^^^^^ -3 > ^^^^^ -4 > ^ -5 > ^^^^^^^^^^^^^^-> -1-> -2 > c1 -3 > { - > public p1: number; - > } -4 > -1->Emitted(8, 5) Source(4, 14) + SourceIndex(0) -2 >Emitted(8, 15) Source(4, 16) + SourceIndex(0) -3 >Emitted(8, 20) Source(6, 2) + SourceIndex(0) -4 >Emitted(8, 21) Source(6, 2) + SourceIndex(0) ---- ->>> exports.instance1 = new c1(); -1->^^^^ -2 > ^^^^^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^^^ -5 > ^^ -6 > ^^ -7 > ^ -1-> - > - >export var -2 > instance1 -3 > = -4 > new -5 > c1 -6 > () -7 > ; -1->Emitted(9, 5) Source(8, 12) + SourceIndex(0) -2 >Emitted(9, 22) Source(8, 21) + SourceIndex(0) -3 >Emitted(9, 25) Source(8, 24) + SourceIndex(0) -4 >Emitted(9, 29) Source(8, 28) + SourceIndex(0) -5 >Emitted(9, 31) Source(8, 30) + SourceIndex(0) -6 >Emitted(9, 33) Source(8, 32) + SourceIndex(0) -7 >Emitted(9, 34) Source(8, 33) + SourceIndex(0) ---- ->>> function f1() { -1 >^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -1 >Emitted(10, 5) Source(9, 1) + SourceIndex(0) ---- ->>> return exports.instance1; -1->^^^^^^^^ -2 > ^^^^^^ -3 > ^ -4 > ^^^^^^^^^^^^^^^^^ -5 > ^ -1->export function f1() { - > -2 > return -3 > -4 > instance1 -5 > ; -1->Emitted(11, 9) Source(10, 5) + SourceIndex(0) name (f1) -2 >Emitted(11, 15) Source(10, 11) + SourceIndex(0) name (f1) -3 >Emitted(11, 16) Source(10, 12) + SourceIndex(0) name (f1) -4 >Emitted(11, 33) Source(10, 21) + SourceIndex(0) name (f1) -5 >Emitted(11, 34) Source(10, 22) + SourceIndex(0) name (f1) ---- ->>> } -1 >^^^^ -2 > ^ -3 > ^^^^^^^^^^^^^^^^-> -1 > - > -2 > } -1 >Emitted(12, 5) Source(11, 1) + SourceIndex(0) name (f1) -2 >Emitted(12, 6) Source(11, 2) + SourceIndex(0) name (f1) ---- ->>> exports.f1 = f1; -1->^^^^ -2 > ^^^^^^^^^^ -3 > ^^^^^ -4 > ^ -5 > ^^^^^^^-> -1-> -2 > f1 -3 > () { - > return instance1; - > } -4 > -1->Emitted(13, 5) Source(9, 17) + SourceIndex(0) -2 >Emitted(13, 15) Source(9, 19) + SourceIndex(0) -3 >Emitted(13, 20) Source(11, 2) + SourceIndex(0) -4 >Emitted(13, 21) Source(11, 2) + SourceIndex(0) ---- ->>> exports.a2 = m1.m1_c1; -1->^^^^ -2 > ^^^^^^^^^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^ -7 > ^ -8 > ^-> -1-> - > - >export var -2 > a2 -3 > = -4 > m1 -5 > . -6 > m1_c1 -7 > ; -1->Emitted(14, 5) Source(13, 12) + SourceIndex(0) -2 >Emitted(14, 15) Source(13, 14) + SourceIndex(0) -3 >Emitted(14, 18) Source(13, 17) + SourceIndex(0) -4 >Emitted(14, 20) Source(13, 19) + SourceIndex(0) -5 >Emitted(14, 21) Source(13, 20) + SourceIndex(0) -6 >Emitted(14, 26) Source(13, 25) + SourceIndex(0) -7 >Emitted(14, 27) Source(13, 26) + SourceIndex(0) ---- ->>> exports.a3 = m2.m2_c1; -1->^^^^ -2 > ^^^^^^^^^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^ -7 > ^ -1-> - >export var -2 > a3 -3 > = -4 > m2 -5 > . -6 > m2_c1 -7 > ; -1->Emitted(15, 5) Source(14, 12) + SourceIndex(0) -2 >Emitted(15, 15) Source(14, 14) + SourceIndex(0) -3 >Emitted(15, 18) Source(14, 17) + SourceIndex(0) -4 >Emitted(15, 20) Source(14, 19) + SourceIndex(0) -5 >Emitted(15, 21) Source(14, 20) + SourceIndex(0) -6 >Emitted(15, 26) Source(14, 25) + SourceIndex(0) -7 >Emitted(15, 27) Source(14, 26) + SourceIndex(0) ---- ->>>}); ->>>//# sourceMappingURL=test.js.map=================================================================== JsFile: test.js mapUrl: test.js.map sourceRoot: diff --git a/tests/baselines/reference/project/sourcemapModuleMultifolderSpecifyOutputFile/amd/test.d.ts b/tests/baselines/reference/project/sourcemapModuleMultifolderSpecifyOutputFile/amd/test.d.ts deleted file mode 100644 index 4afd4e69f2d..00000000000 --- a/tests/baselines/reference/project/sourcemapModuleMultifolderSpecifyOutputFile/amd/test.d.ts +++ /dev/null @@ -1,10 +0,0 @@ -import m1 = require("ref/m1"); -import m2 = require("../outputdir_module_multifolder_ref/m2"); -export declare var a1: number; -export declare class c1 { - p1: number; -} -export declare var instance1: c1; -export declare function f1(): c1; -export declare var a2: typeof m1.m1_c1; -export declare var a3: typeof m2.m2_c1; diff --git a/tests/baselines/reference/project/sourcemapModuleMultifolderSpecifyOutputFile/amd/test.js b/tests/baselines/reference/project/sourcemapModuleMultifolderSpecifyOutputFile/amd/test.js deleted file mode 100644 index 5cca04a0f25..00000000000 --- a/tests/baselines/reference/project/sourcemapModuleMultifolderSpecifyOutputFile/amd/test.js +++ /dev/null @@ -1,17 +0,0 @@ -define(["require", "exports", "ref/m1", "../outputdir_module_multifolder_ref/m2"], function (require, exports, m1, m2) { - exports.a1 = 10; - var c1 = (function () { - function c1() { - } - return c1; - })(); - exports.c1 = c1; - exports.instance1 = new c1(); - function f1() { - return exports.instance1; - } - exports.f1 = f1; - exports.a2 = m1.m1_c1; - exports.a3 = m2.m2_c1; -}); -//# sourceMappingURL=test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcemapModuleMultifolderSpecifyOutputFile/amd/test.js.map b/tests/baselines/reference/project/sourcemapModuleMultifolderSpecifyOutputFile/amd/test.js.map deleted file mode 100644 index 462fa38ab42..00000000000 --- a/tests/baselines/reference/project/sourcemapModuleMultifolderSpecifyOutputFile/amd/test.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"test.js","sourceRoot":"","sources":["test.ts"],"names":["c1","c1.constructor","f1"],"mappings":";IAEW,UAAE,GAAG,EAAE,CAAC;IACnB;QAAAA;QAEAC,CAACA;QAADD,SAACA;IAADA,CAACA,AAFD,IAEC;IAFY,UAAE,KAEd,CAAA;IAEU,iBAAS,GAAG,IAAI,EAAE,EAAE,CAAC;IAChC;QACIE,MAAMA,CAACA,iBAASA,CAACA;IACrBA,CAACA;IAFe,UAAE,KAEjB,CAAA;IAEU,UAAE,GAAG,EAAE,CAAC,KAAK,CAAC;IACd,UAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcemapModuleMultifolderSpecifyOutputFile/node/diskFile0.js.map b/tests/baselines/reference/project/sourcemapModuleMultifolderSpecifyOutputFile/node/diskFile0.js.map deleted file mode 100644 index 0826e9e95f3..00000000000 --- a/tests/baselines/reference/project/sourcemapModuleMultifolderSpecifyOutputFile/node/diskFile0.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"m2.js","sourceRoot":"","sources":["m2.ts"],"names":["m2_c1","m2_c1.constructor","m2_f1"],"mappings":"AAAW,aAAK,GAAG,EAAE,CAAC;AACtB;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAFY,aAAK,QAEjB,CAAA;AAEU,oBAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACIE,MAAMA,CAACA,oBAAYA,CAACA;AACxBA,CAACA;AAFe,aAAK,QAEpB,CAAA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcemapModuleMultifolderSpecifyOutputFile/node/diskFile1.js b/tests/baselines/reference/project/sourcemapModuleMultifolderSpecifyOutputFile/node/diskFile1.js deleted file mode 100644 index ec0a73b5af8..00000000000 --- a/tests/baselines/reference/project/sourcemapModuleMultifolderSpecifyOutputFile/node/diskFile1.js +++ /dev/null @@ -1,13 +0,0 @@ -exports.m2_a1 = 10; -var m2_c1 = (function () { - function m2_c1() { - } - return m2_c1; -})(); -exports.m2_c1 = m2_c1; -exports.m2_instance1 = new m2_c1(); -function m2_f1() { - return exports.m2_instance1; -} -exports.m2_f1 = m2_f1; -//# sourceMappingURL=m2.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcemapModuleMultifolderSpecifyOutputFile/node/diskFile2.d.ts b/tests/baselines/reference/project/sourcemapModuleMultifolderSpecifyOutputFile/node/diskFile2.d.ts deleted file mode 100644 index c09a3c0c32a..00000000000 --- a/tests/baselines/reference/project/sourcemapModuleMultifolderSpecifyOutputFile/node/diskFile2.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -export declare var m2_a1: number; -export declare class m2_c1 { - m2_c1_p1: number; -} -export declare var m2_instance1: m2_c1; -export declare function m2_f1(): m2_c1; diff --git a/tests/baselines/reference/project/sourcemapModuleMultifolderSpecifyOutputFile/node/ref/m1.d.ts b/tests/baselines/reference/project/sourcemapModuleMultifolderSpecifyOutputFile/node/ref/m1.d.ts deleted file mode 100644 index 4a53b24b156..00000000000 --- a/tests/baselines/reference/project/sourcemapModuleMultifolderSpecifyOutputFile/node/ref/m1.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -export declare var m1_a1: number; -export declare class m1_c1 { - m1_c1_p1: number; -} -export declare var m1_instance1: m1_c1; -export declare function m1_f1(): m1_c1; diff --git a/tests/baselines/reference/project/sourcemapModuleMultifolderSpecifyOutputFile/node/ref/m1.js b/tests/baselines/reference/project/sourcemapModuleMultifolderSpecifyOutputFile/node/ref/m1.js deleted file mode 100644 index 1b4470e2b37..00000000000 --- a/tests/baselines/reference/project/sourcemapModuleMultifolderSpecifyOutputFile/node/ref/m1.js +++ /dev/null @@ -1,13 +0,0 @@ -exports.m1_a1 = 10; -var m1_c1 = (function () { - function m1_c1() { - } - return m1_c1; -})(); -exports.m1_c1 = m1_c1; -exports.m1_instance1 = new m1_c1(); -function m1_f1() { - return exports.m1_instance1; -} -exports.m1_f1 = m1_f1; -//# sourceMappingURL=m1.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcemapModuleMultifolderSpecifyOutputFile/node/ref/m1.js.map b/tests/baselines/reference/project/sourcemapModuleMultifolderSpecifyOutputFile/node/ref/m1.js.map deleted file mode 100644 index 095951a67d0..00000000000 --- a/tests/baselines/reference/project/sourcemapModuleMultifolderSpecifyOutputFile/node/ref/m1.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"m1.js","sourceRoot":"","sources":["m1.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1"],"mappings":"AAAW,aAAK,GAAG,EAAE,CAAC;AACtB;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAFY,aAAK,QAEjB,CAAA;AAEU,oBAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACIE,MAAMA,CAACA,oBAAYA,CAACA;AACxBA,CAACA;AAFe,aAAK,QAEpB,CAAA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcemapModuleMultifolderSpecifyOutputFile/node/sourcemapModuleMultifolderSpecifyOutputFile.json b/tests/baselines/reference/project/sourcemapModuleMultifolderSpecifyOutputFile/node/sourcemapModuleMultifolderSpecifyOutputFile.json index 3d2df95ad66..7ba960c4bef 100644 --- a/tests/baselines/reference/project/sourcemapModuleMultifolderSpecifyOutputFile/node/sourcemapModuleMultifolderSpecifyOutputFile.json +++ b/tests/baselines/reference/project/sourcemapModuleMultifolderSpecifyOutputFile/node/sourcemapModuleMultifolderSpecifyOutputFile.json @@ -15,15 +15,6 @@ "test.ts" ], "emittedFiles": [ - "ref/m1.js.map", - "ref/m1.js", - "ref/m1.d.ts", - "../outputdir_module_multifolder_ref/m2.js.map", - "../outputdir_module_multifolder_ref/m2.js", - "../outputdir_module_multifolder_ref/m2.d.ts", - "test.js.map", - "test.js", - "test.d.ts", "bin/test.js.map", "bin/test.js", "bin/test.d.ts" diff --git a/tests/baselines/reference/project/sourcemapModuleMultifolderSpecifyOutputFile/node/sourcemapModuleMultifolderSpecifyOutputFile.sourcemap.txt b/tests/baselines/reference/project/sourcemapModuleMultifolderSpecifyOutputFile/node/sourcemapModuleMultifolderSpecifyOutputFile.sourcemap.txt index d36064b989c..70054e8f1c6 100644 --- a/tests/baselines/reference/project/sourcemapModuleMultifolderSpecifyOutputFile/node/sourcemapModuleMultifolderSpecifyOutputFile.sourcemap.txt +++ b/tests/baselines/reference/project/sourcemapModuleMultifolderSpecifyOutputFile/node/sourcemapModuleMultifolderSpecifyOutputFile.sourcemap.txt @@ -1,617 +1,4 @@ =================================================================== -JsFile: m1.js -mapUrl: m1.js.map -sourceRoot: -sources: m1.ts -=================================================================== -------------------------------------------------------------------- -emittedFile:ref/m1.js -sourceFile:m1.ts -------------------------------------------------------------------- ->>>exports.m1_a1 = 10; -1 > -2 >^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^-> -1 >export var -2 >m1_a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(1, 1) Source(1, 12) + SourceIndex(0) -2 >Emitted(1, 14) Source(1, 17) + SourceIndex(0) -3 >Emitted(1, 17) Source(1, 20) + SourceIndex(0) -4 >Emitted(1, 19) Source(1, 22) + SourceIndex(0) -5 >Emitted(1, 20) Source(1, 23) + SourceIndex(0) ---- ->>>var m1_c1 = (function () { -1-> -2 >^^^^^^^^^^^^^^^^^^^^^^^-> -1-> - > -1->Emitted(2, 1) Source(2, 1) + SourceIndex(0) ---- ->>> function m1_c1() { -1->^^^^ -2 > ^^-> -1-> -1->Emitted(3, 5) Source(2, 1) + SourceIndex(0) name (m1_c1) ---- ->>> } -1->^^^^ -2 > ^ -3 > ^^^^^^^^^^^^^-> -1->export class m1_c1 { - > public m1_c1_p1: number; - > -2 > } -1->Emitted(4, 5) Source(4, 1) + SourceIndex(0) name (m1_c1.constructor) -2 >Emitted(4, 6) Source(4, 2) + SourceIndex(0) name (m1_c1.constructor) ---- ->>> return m1_c1; -1->^^^^ -2 > ^^^^^^^^^^^^ -1-> -2 > } -1->Emitted(5, 5) Source(4, 1) + SourceIndex(0) name (m1_c1) -2 >Emitted(5, 17) Source(4, 2) + SourceIndex(0) name (m1_c1) ---- ->>>})(); -1 > -2 >^ -3 > -4 > ^^^^ -5 > ^^^^^^^^^^^^^^^^^^-> -1 > -2 >} -3 > -4 > export class m1_c1 { - > public m1_c1_p1: number; - > } -1 >Emitted(6, 1) Source(4, 1) + SourceIndex(0) name (m1_c1) -2 >Emitted(6, 2) Source(4, 2) + SourceIndex(0) name (m1_c1) -3 >Emitted(6, 2) Source(2, 1) + SourceIndex(0) -4 >Emitted(6, 6) Source(4, 2) + SourceIndex(0) ---- ->>>exports.m1_c1 = m1_c1; -1-> -2 >^^^^^^^^^^^^^ -3 > ^^^^^^^^ -4 > ^ -5 > ^^^^^^^^^^^^^^-> -1-> -2 >m1_c1 -3 > { - > public m1_c1_p1: number; - > } -4 > -1->Emitted(7, 1) Source(2, 14) + SourceIndex(0) -2 >Emitted(7, 14) Source(2, 19) + SourceIndex(0) -3 >Emitted(7, 22) Source(4, 2) + SourceIndex(0) -4 >Emitted(7, 23) Source(4, 2) + SourceIndex(0) ---- ->>>exports.m1_instance1 = new m1_c1(); -1-> -2 >^^^^^^^^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^^^ -5 > ^^^^^ -6 > ^^ -7 > ^ -1-> - > - >export var -2 >m1_instance1 -3 > = -4 > new -5 > m1_c1 -6 > () -7 > ; -1->Emitted(8, 1) Source(6, 12) + SourceIndex(0) -2 >Emitted(8, 21) Source(6, 24) + SourceIndex(0) -3 >Emitted(8, 24) Source(6, 27) + SourceIndex(0) -4 >Emitted(8, 28) Source(6, 31) + SourceIndex(0) -5 >Emitted(8, 33) Source(6, 36) + SourceIndex(0) -6 >Emitted(8, 35) Source(6, 38) + SourceIndex(0) -7 >Emitted(8, 36) Source(6, 39) + SourceIndex(0) ---- ->>>function m1_f1() { -1 > -2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -1 >Emitted(9, 1) Source(7, 1) + SourceIndex(0) ---- ->>> return exports.m1_instance1; -1->^^^^ -2 > ^^^^^^ -3 > ^ -4 > ^^^^^^^^^^^^^^^^^^^^ -5 > ^ -1->export function m1_f1() { - > -2 > return -3 > -4 > m1_instance1 -5 > ; -1->Emitted(10, 5) Source(8, 5) + SourceIndex(0) name (m1_f1) -2 >Emitted(10, 11) Source(8, 11) + SourceIndex(0) name (m1_f1) -3 >Emitted(10, 12) Source(8, 12) + SourceIndex(0) name (m1_f1) -4 >Emitted(10, 32) Source(8, 24) + SourceIndex(0) name (m1_f1) -5 >Emitted(10, 33) Source(8, 25) + SourceIndex(0) name (m1_f1) ---- ->>>} -1 > -2 >^ -3 > ^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -2 >} -1 >Emitted(11, 1) Source(9, 1) + SourceIndex(0) name (m1_f1) -2 >Emitted(11, 2) Source(9, 2) + SourceIndex(0) name (m1_f1) ---- ->>>exports.m1_f1 = m1_f1; -1-> -2 >^^^^^^^^^^^^^ -3 > ^^^^^^^^ -4 > ^ -5 > ^^^^^^^-> -1-> -2 >m1_f1 -3 > () { - > return m1_instance1; - > } -4 > -1->Emitted(12, 1) Source(7, 17) + SourceIndex(0) -2 >Emitted(12, 14) Source(7, 22) + SourceIndex(0) -3 >Emitted(12, 22) Source(9, 2) + SourceIndex(0) -4 >Emitted(12, 23) Source(9, 2) + SourceIndex(0) ---- ->>>//# sourceMappingURL=m1.js.map=================================================================== -JsFile: m2.js -mapUrl: m2.js.map -sourceRoot: -sources: m2.ts -=================================================================== -------------------------------------------------------------------- -emittedFile:diskFile1.js -sourceFile:m2.ts -------------------------------------------------------------------- ->>>exports.m2_a1 = 10; -1 > -2 >^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^-> -1 >export var -2 >m2_a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(1, 1) Source(1, 12) + SourceIndex(0) -2 >Emitted(1, 14) Source(1, 17) + SourceIndex(0) -3 >Emitted(1, 17) Source(1, 20) + SourceIndex(0) -4 >Emitted(1, 19) Source(1, 22) + SourceIndex(0) -5 >Emitted(1, 20) Source(1, 23) + SourceIndex(0) ---- ->>>var m2_c1 = (function () { -1-> -2 >^^^^^^^^^^^^^^^^^^^^^^^-> -1-> - > -1->Emitted(2, 1) Source(2, 1) + SourceIndex(0) ---- ->>> function m2_c1() { -1->^^^^ -2 > ^^-> -1-> -1->Emitted(3, 5) Source(2, 1) + SourceIndex(0) name (m2_c1) ---- ->>> } -1->^^^^ -2 > ^ -3 > ^^^^^^^^^^^^^-> -1->export class m2_c1 { - > public m2_c1_p1: number; - > -2 > } -1->Emitted(4, 5) Source(4, 1) + SourceIndex(0) name (m2_c1.constructor) -2 >Emitted(4, 6) Source(4, 2) + SourceIndex(0) name (m2_c1.constructor) ---- ->>> return m2_c1; -1->^^^^ -2 > ^^^^^^^^^^^^ -1-> -2 > } -1->Emitted(5, 5) Source(4, 1) + SourceIndex(0) name (m2_c1) -2 >Emitted(5, 17) Source(4, 2) + SourceIndex(0) name (m2_c1) ---- ->>>})(); -1 > -2 >^ -3 > -4 > ^^^^ -5 > ^^^^^^^^^^^^^^^^^^-> -1 > -2 >} -3 > -4 > export class m2_c1 { - > public m2_c1_p1: number; - > } -1 >Emitted(6, 1) Source(4, 1) + SourceIndex(0) name (m2_c1) -2 >Emitted(6, 2) Source(4, 2) + SourceIndex(0) name (m2_c1) -3 >Emitted(6, 2) Source(2, 1) + SourceIndex(0) -4 >Emitted(6, 6) Source(4, 2) + SourceIndex(0) ---- ->>>exports.m2_c1 = m2_c1; -1-> -2 >^^^^^^^^^^^^^ -3 > ^^^^^^^^ -4 > ^ -5 > ^^^^^^^^^^^^^^-> -1-> -2 >m2_c1 -3 > { - > public m2_c1_p1: number; - > } -4 > -1->Emitted(7, 1) Source(2, 14) + SourceIndex(0) -2 >Emitted(7, 14) Source(2, 19) + SourceIndex(0) -3 >Emitted(7, 22) Source(4, 2) + SourceIndex(0) -4 >Emitted(7, 23) Source(4, 2) + SourceIndex(0) ---- ->>>exports.m2_instance1 = new m2_c1(); -1-> -2 >^^^^^^^^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^^^ -5 > ^^^^^ -6 > ^^ -7 > ^ -1-> - > - >export var -2 >m2_instance1 -3 > = -4 > new -5 > m2_c1 -6 > () -7 > ; -1->Emitted(8, 1) Source(6, 12) + SourceIndex(0) -2 >Emitted(8, 21) Source(6, 24) + SourceIndex(0) -3 >Emitted(8, 24) Source(6, 27) + SourceIndex(0) -4 >Emitted(8, 28) Source(6, 31) + SourceIndex(0) -5 >Emitted(8, 33) Source(6, 36) + SourceIndex(0) -6 >Emitted(8, 35) Source(6, 38) + SourceIndex(0) -7 >Emitted(8, 36) Source(6, 39) + SourceIndex(0) ---- ->>>function m2_f1() { -1 > -2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -1 >Emitted(9, 1) Source(7, 1) + SourceIndex(0) ---- ->>> return exports.m2_instance1; -1->^^^^ -2 > ^^^^^^ -3 > ^ -4 > ^^^^^^^^^^^^^^^^^^^^ -5 > ^ -1->export function m2_f1() { - > -2 > return -3 > -4 > m2_instance1 -5 > ; -1->Emitted(10, 5) Source(8, 5) + SourceIndex(0) name (m2_f1) -2 >Emitted(10, 11) Source(8, 11) + SourceIndex(0) name (m2_f1) -3 >Emitted(10, 12) Source(8, 12) + SourceIndex(0) name (m2_f1) -4 >Emitted(10, 32) Source(8, 24) + SourceIndex(0) name (m2_f1) -5 >Emitted(10, 33) Source(8, 25) + SourceIndex(0) name (m2_f1) ---- ->>>} -1 > -2 >^ -3 > ^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -2 >} -1 >Emitted(11, 1) Source(9, 1) + SourceIndex(0) name (m2_f1) -2 >Emitted(11, 2) Source(9, 2) + SourceIndex(0) name (m2_f1) ---- ->>>exports.m2_f1 = m2_f1; -1-> -2 >^^^^^^^^^^^^^ -3 > ^^^^^^^^ -4 > ^ -5 > ^^^^^^^-> -1-> -2 >m2_f1 -3 > () { - > return m2_instance1; - > } -4 > -1->Emitted(12, 1) Source(7, 17) + SourceIndex(0) -2 >Emitted(12, 14) Source(7, 22) + SourceIndex(0) -3 >Emitted(12, 22) Source(9, 2) + SourceIndex(0) -4 >Emitted(12, 23) Source(9, 2) + SourceIndex(0) ---- ->>>//# sourceMappingURL=m2.js.map=================================================================== -JsFile: test.js -mapUrl: test.js.map -sourceRoot: -sources: test.ts -=================================================================== -------------------------------------------------------------------- -emittedFile:test.js -sourceFile:test.ts -------------------------------------------------------------------- ->>>var m1 = require("ref/m1"); -1 > -2 >^^^^ -3 > ^^ -4 > ^^^^^^^^^^^ -5 > ^^^^^^^^ -6 > ^ -7 > ^ -8 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 > -2 >import -3 > m1 -4 > = require( -5 > "ref/m1" -6 > ) -7 > ; -1 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) -2 >Emitted(1, 5) Source(1, 8) + SourceIndex(0) -3 >Emitted(1, 7) Source(1, 10) + SourceIndex(0) -4 >Emitted(1, 18) Source(1, 21) + SourceIndex(0) -5 >Emitted(1, 26) Source(1, 29) + SourceIndex(0) -6 >Emitted(1, 27) Source(1, 30) + SourceIndex(0) -7 >Emitted(1, 28) Source(1, 31) + SourceIndex(0) ---- ->>>var m2 = require("../outputdir_module_multifolder_ref/m2"); -1-> -2 >^^^^ -3 > ^^ -4 > ^^^^^^^^^^^ -5 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -6 > ^ -7 > ^ -1-> - > -2 >import -3 > m2 -4 > = require( -5 > "../outputdir_module_multifolder_ref/m2" -6 > ) -7 > ; -1->Emitted(2, 1) Source(2, 1) + SourceIndex(0) -2 >Emitted(2, 5) Source(2, 8) + SourceIndex(0) -3 >Emitted(2, 7) Source(2, 10) + SourceIndex(0) -4 >Emitted(2, 18) Source(2, 21) + SourceIndex(0) -5 >Emitted(2, 58) Source(2, 61) + SourceIndex(0) -6 >Emitted(2, 59) Source(2, 62) + SourceIndex(0) -7 >Emitted(2, 60) Source(2, 63) + SourceIndex(0) ---- ->>>exports.a1 = 10; -1 > -2 >^^^^^^^^^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^-> -1 > - >export var -2 >a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(3, 1) Source(3, 12) + SourceIndex(0) -2 >Emitted(3, 11) Source(3, 14) + SourceIndex(0) -3 >Emitted(3, 14) Source(3, 17) + SourceIndex(0) -4 >Emitted(3, 16) Source(3, 19) + SourceIndex(0) -5 >Emitted(3, 17) Source(3, 20) + SourceIndex(0) ---- ->>>var c1 = (function () { -1-> -2 >^^^^^^^^^^^^^^^^^^^^-> -1-> - > -1->Emitted(4, 1) Source(4, 1) + SourceIndex(0) ---- ->>> function c1() { -1->^^^^ -2 > ^^-> -1-> -1->Emitted(5, 5) Source(4, 1) + SourceIndex(0) name (c1) ---- ->>> } -1->^^^^ -2 > ^ -3 > ^^^^^^^^^^-> -1->export class c1 { - > public p1: number; - > -2 > } -1->Emitted(6, 5) Source(6, 1) + SourceIndex(0) name (c1.constructor) -2 >Emitted(6, 6) Source(6, 2) + SourceIndex(0) name (c1.constructor) ---- ->>> return c1; -1->^^^^ -2 > ^^^^^^^^^ -1-> -2 > } -1->Emitted(7, 5) Source(6, 1) + SourceIndex(0) name (c1) -2 >Emitted(7, 14) Source(6, 2) + SourceIndex(0) name (c1) ---- ->>>})(); -1 > -2 >^ -3 > -4 > ^^^^ -5 > ^^^^^^^^^^^^-> -1 > -2 >} -3 > -4 > export class c1 { - > public p1: number; - > } -1 >Emitted(8, 1) Source(6, 1) + SourceIndex(0) name (c1) -2 >Emitted(8, 2) Source(6, 2) + SourceIndex(0) name (c1) -3 >Emitted(8, 2) Source(4, 1) + SourceIndex(0) -4 >Emitted(8, 6) Source(6, 2) + SourceIndex(0) ---- ->>>exports.c1 = c1; -1-> -2 >^^^^^^^^^^ -3 > ^^^^^ -4 > ^ -5 > ^^^^^^^^^^^^^^-> -1-> -2 >c1 -3 > { - > public p1: number; - > } -4 > -1->Emitted(9, 1) Source(4, 14) + SourceIndex(0) -2 >Emitted(9, 11) Source(4, 16) + SourceIndex(0) -3 >Emitted(9, 16) Source(6, 2) + SourceIndex(0) -4 >Emitted(9, 17) Source(6, 2) + SourceIndex(0) ---- ->>>exports.instance1 = new c1(); -1-> -2 >^^^^^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^^^ -5 > ^^ -6 > ^^ -7 > ^ -1-> - > - >export var -2 >instance1 -3 > = -4 > new -5 > c1 -6 > () -7 > ; -1->Emitted(10, 1) Source(8, 12) + SourceIndex(0) -2 >Emitted(10, 18) Source(8, 21) + SourceIndex(0) -3 >Emitted(10, 21) Source(8, 24) + SourceIndex(0) -4 >Emitted(10, 25) Source(8, 28) + SourceIndex(0) -5 >Emitted(10, 27) Source(8, 30) + SourceIndex(0) -6 >Emitted(10, 29) Source(8, 32) + SourceIndex(0) -7 >Emitted(10, 30) Source(8, 33) + SourceIndex(0) ---- ->>>function f1() { -1 > -2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -1 >Emitted(11, 1) Source(9, 1) + SourceIndex(0) ---- ->>> return exports.instance1; -1->^^^^ -2 > ^^^^^^ -3 > ^ -4 > ^^^^^^^^^^^^^^^^^ -5 > ^ -1->export function f1() { - > -2 > return -3 > -4 > instance1 -5 > ; -1->Emitted(12, 5) Source(10, 5) + SourceIndex(0) name (f1) -2 >Emitted(12, 11) Source(10, 11) + SourceIndex(0) name (f1) -3 >Emitted(12, 12) Source(10, 12) + SourceIndex(0) name (f1) -4 >Emitted(12, 29) Source(10, 21) + SourceIndex(0) name (f1) -5 >Emitted(12, 30) Source(10, 22) + SourceIndex(0) name (f1) ---- ->>>} -1 > -2 >^ -3 > ^^^^^^^^^^^^^^^^-> -1 > - > -2 >} -1 >Emitted(13, 1) Source(11, 1) + SourceIndex(0) name (f1) -2 >Emitted(13, 2) Source(11, 2) + SourceIndex(0) name (f1) ---- ->>>exports.f1 = f1; -1-> -2 >^^^^^^^^^^ -3 > ^^^^^ -4 > ^ -5 > ^^^^^^^-> -1-> -2 >f1 -3 > () { - > return instance1; - > } -4 > -1->Emitted(14, 1) Source(9, 17) + SourceIndex(0) -2 >Emitted(14, 11) Source(9, 19) + SourceIndex(0) -3 >Emitted(14, 16) Source(11, 2) + SourceIndex(0) -4 >Emitted(14, 17) Source(11, 2) + SourceIndex(0) ---- ->>>exports.a2 = m1.m1_c1; -1-> -2 >^^^^^^^^^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^ -7 > ^ -8 > ^-> -1-> - > - >export var -2 >a2 -3 > = -4 > m1 -5 > . -6 > m1_c1 -7 > ; -1->Emitted(15, 1) Source(13, 12) + SourceIndex(0) -2 >Emitted(15, 11) Source(13, 14) + SourceIndex(0) -3 >Emitted(15, 14) Source(13, 17) + SourceIndex(0) -4 >Emitted(15, 16) Source(13, 19) + SourceIndex(0) -5 >Emitted(15, 17) Source(13, 20) + SourceIndex(0) -6 >Emitted(15, 22) Source(13, 25) + SourceIndex(0) -7 >Emitted(15, 23) Source(13, 26) + SourceIndex(0) ---- ->>>exports.a3 = m2.m2_c1; -1-> -2 >^^^^^^^^^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^ -7 > ^ -8 > ^^^^^^^^^-> -1-> - >export var -2 >a3 -3 > = -4 > m2 -5 > . -6 > m2_c1 -7 > ; -1->Emitted(16, 1) Source(14, 12) + SourceIndex(0) -2 >Emitted(16, 11) Source(14, 14) + SourceIndex(0) -3 >Emitted(16, 14) Source(14, 17) + SourceIndex(0) -4 >Emitted(16, 16) Source(14, 19) + SourceIndex(0) -5 >Emitted(16, 17) Source(14, 20) + SourceIndex(0) -6 >Emitted(16, 22) Source(14, 25) + SourceIndex(0) -7 >Emitted(16, 23) Source(14, 26) + SourceIndex(0) ---- ->>>//# sourceMappingURL=test.js.map=================================================================== JsFile: test.js mapUrl: test.js.map sourceRoot: diff --git a/tests/baselines/reference/project/sourcemapModuleMultifolderSpecifyOutputFile/node/test.d.ts b/tests/baselines/reference/project/sourcemapModuleMultifolderSpecifyOutputFile/node/test.d.ts deleted file mode 100644 index 4afd4e69f2d..00000000000 --- a/tests/baselines/reference/project/sourcemapModuleMultifolderSpecifyOutputFile/node/test.d.ts +++ /dev/null @@ -1,10 +0,0 @@ -import m1 = require("ref/m1"); -import m2 = require("../outputdir_module_multifolder_ref/m2"); -export declare var a1: number; -export declare class c1 { - p1: number; -} -export declare var instance1: c1; -export declare function f1(): c1; -export declare var a2: typeof m1.m1_c1; -export declare var a3: typeof m2.m2_c1; diff --git a/tests/baselines/reference/project/sourcemapModuleMultifolderSpecifyOutputFile/node/test.js b/tests/baselines/reference/project/sourcemapModuleMultifolderSpecifyOutputFile/node/test.js deleted file mode 100644 index 14c09e444a5..00000000000 --- a/tests/baselines/reference/project/sourcemapModuleMultifolderSpecifyOutputFile/node/test.js +++ /dev/null @@ -1,17 +0,0 @@ -var m1 = require("ref/m1"); -var m2 = require("../outputdir_module_multifolder_ref/m2"); -exports.a1 = 10; -var c1 = (function () { - function c1() { - } - return c1; -})(); -exports.c1 = c1; -exports.instance1 = new c1(); -function f1() { - return exports.instance1; -} -exports.f1 = f1; -exports.a2 = m1.m1_c1; -exports.a3 = m2.m2_c1; -//# sourceMappingURL=test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcemapModuleMultifolderSpecifyOutputFile/node/test.js.map b/tests/baselines/reference/project/sourcemapModuleMultifolderSpecifyOutputFile/node/test.js.map deleted file mode 100644 index 3b3ef6b145c..00000000000 --- a/tests/baselines/reference/project/sourcemapModuleMultifolderSpecifyOutputFile/node/test.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"test.js","sourceRoot":"","sources":["test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AAAA,IAAO,EAAE,WAAW,QAAQ,CAAC,CAAC;AAC9B,IAAO,EAAE,WAAW,wCAAwC,CAAC,CAAC;AACnD,UAAE,GAAG,EAAE,CAAC;AACnB;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAFY,UAAE,KAEd,CAAA;AAEU,iBAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AAChC;IACIE,MAAMA,CAACA,iBAASA,CAACA;AACrBA,CAACA;AAFe,UAAE,KAEjB,CAAA;AAEU,UAAE,GAAG,EAAE,CAAC,KAAK,CAAC;AACd,UAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcemapModuleSimpleSpecifyOutputFile/amd/m1.d.ts b/tests/baselines/reference/project/sourcemapModuleSimpleSpecifyOutputFile/amd/m1.d.ts deleted file mode 100644 index 4a53b24b156..00000000000 --- a/tests/baselines/reference/project/sourcemapModuleSimpleSpecifyOutputFile/amd/m1.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -export declare var m1_a1: number; -export declare class m1_c1 { - m1_c1_p1: number; -} -export declare var m1_instance1: m1_c1; -export declare function m1_f1(): m1_c1; diff --git a/tests/baselines/reference/project/sourcemapModuleSimpleSpecifyOutputFile/amd/m1.js b/tests/baselines/reference/project/sourcemapModuleSimpleSpecifyOutputFile/amd/m1.js deleted file mode 100644 index bbaba444ba2..00000000000 --- a/tests/baselines/reference/project/sourcemapModuleSimpleSpecifyOutputFile/amd/m1.js +++ /dev/null @@ -1,15 +0,0 @@ -define(["require", "exports"], function (require, exports) { - exports.m1_a1 = 10; - var m1_c1 = (function () { - function m1_c1() { - } - return m1_c1; - })(); - exports.m1_c1 = m1_c1; - exports.m1_instance1 = new m1_c1(); - function m1_f1() { - return exports.m1_instance1; - } - exports.m1_f1 = m1_f1; -}); -//# sourceMappingURL=m1.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcemapModuleSimpleSpecifyOutputFile/amd/m1.js.map b/tests/baselines/reference/project/sourcemapModuleSimpleSpecifyOutputFile/amd/m1.js.map deleted file mode 100644 index 51755e4c9a3..00000000000 --- a/tests/baselines/reference/project/sourcemapModuleSimpleSpecifyOutputFile/amd/m1.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"m1.js","sourceRoot":"","sources":["m1.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1"],"mappings":";IAAW,aAAK,GAAG,EAAE,CAAC;IACtB;QAAAA;QAEAC,CAACA;QAADD,YAACA;IAADA,CAACA,AAFD,IAEC;IAFY,aAAK,QAEjB,CAAA;IAEU,oBAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACIE,MAAMA,CAACA,oBAAYA,CAACA;IACxBA,CAACA;IAFe,aAAK,QAEpB,CAAA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcemapModuleSimpleSpecifyOutputFile/amd/sourcemapModuleSimpleSpecifyOutputFile.json b/tests/baselines/reference/project/sourcemapModuleSimpleSpecifyOutputFile/amd/sourcemapModuleSimpleSpecifyOutputFile.json index 9ff29662d40..c9889aff69b 100644 --- a/tests/baselines/reference/project/sourcemapModuleSimpleSpecifyOutputFile/amd/sourcemapModuleSimpleSpecifyOutputFile.json +++ b/tests/baselines/reference/project/sourcemapModuleSimpleSpecifyOutputFile/amd/sourcemapModuleSimpleSpecifyOutputFile.json @@ -14,12 +14,6 @@ "test.ts" ], "emittedFiles": [ - "m1.js.map", - "m1.js", - "m1.d.ts", - "test.js.map", - "test.js", - "test.d.ts", "bin/test.js.map", "bin/test.js", "bin/test.d.ts" diff --git a/tests/baselines/reference/project/sourcemapModuleSimpleSpecifyOutputFile/amd/sourcemapModuleSimpleSpecifyOutputFile.sourcemap.txt b/tests/baselines/reference/project/sourcemapModuleSimpleSpecifyOutputFile/amd/sourcemapModuleSimpleSpecifyOutputFile.sourcemap.txt index 2d6e3052871..71c0a41b2d1 100644 --- a/tests/baselines/reference/project/sourcemapModuleSimpleSpecifyOutputFile/amd/sourcemapModuleSimpleSpecifyOutputFile.sourcemap.txt +++ b/tests/baselines/reference/project/sourcemapModuleSimpleSpecifyOutputFile/amd/sourcemapModuleSimpleSpecifyOutputFile.sourcemap.txt @@ -1,375 +1,4 @@ =================================================================== -JsFile: m1.js -mapUrl: m1.js.map -sourceRoot: -sources: m1.ts -=================================================================== -------------------------------------------------------------------- -emittedFile:m1.js -sourceFile:m1.ts -------------------------------------------------------------------- ->>>define(["require", "exports"], function (require, exports) { ->>> exports.m1_a1 = 10; -1 >^^^^ -2 > ^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^-> -1 >export var -2 > m1_a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(2, 5) Source(1, 12) + SourceIndex(0) -2 >Emitted(2, 18) Source(1, 17) + SourceIndex(0) -3 >Emitted(2, 21) Source(1, 20) + SourceIndex(0) -4 >Emitted(2, 23) Source(1, 22) + SourceIndex(0) -5 >Emitted(2, 24) Source(1, 23) + SourceIndex(0) ---- ->>> var m1_c1 = (function () { -1->^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^^^^-> -1-> - > -1->Emitted(3, 5) Source(2, 1) + SourceIndex(0) ---- ->>> function m1_c1() { -1->^^^^^^^^ -2 > ^^-> -1-> -1->Emitted(4, 9) Source(2, 1) + SourceIndex(0) name (m1_c1) ---- ->>> } -1->^^^^^^^^ -2 > ^ -3 > ^^^^^^^^^^^^^-> -1->export class m1_c1 { - > public m1_c1_p1: number; - > -2 > } -1->Emitted(5, 9) Source(4, 1) + SourceIndex(0) name (m1_c1.constructor) -2 >Emitted(5, 10) Source(4, 2) + SourceIndex(0) name (m1_c1.constructor) ---- ->>> return m1_c1; -1->^^^^^^^^ -2 > ^^^^^^^^^^^^ -1-> -2 > } -1->Emitted(6, 9) Source(4, 1) + SourceIndex(0) name (m1_c1) -2 >Emitted(6, 21) Source(4, 2) + SourceIndex(0) name (m1_c1) ---- ->>> })(); -1 >^^^^ -2 > ^ -3 > -4 > ^^^^ -5 > ^^^^^^^^^^^^^^^^^^-> -1 > -2 > } -3 > -4 > export class m1_c1 { - > public m1_c1_p1: number; - > } -1 >Emitted(7, 5) Source(4, 1) + SourceIndex(0) name (m1_c1) -2 >Emitted(7, 6) Source(4, 2) + SourceIndex(0) name (m1_c1) -3 >Emitted(7, 6) Source(2, 1) + SourceIndex(0) -4 >Emitted(7, 10) Source(4, 2) + SourceIndex(0) ---- ->>> exports.m1_c1 = m1_c1; -1->^^^^ -2 > ^^^^^^^^^^^^^ -3 > ^^^^^^^^ -4 > ^ -5 > ^^^^^^^^^^^^^^-> -1-> -2 > m1_c1 -3 > { - > public m1_c1_p1: number; - > } -4 > -1->Emitted(8, 5) Source(2, 14) + SourceIndex(0) -2 >Emitted(8, 18) Source(2, 19) + SourceIndex(0) -3 >Emitted(8, 26) Source(4, 2) + SourceIndex(0) -4 >Emitted(8, 27) Source(4, 2) + SourceIndex(0) ---- ->>> exports.m1_instance1 = new m1_c1(); -1->^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^^^ -5 > ^^^^^ -6 > ^^ -7 > ^ -1-> - > - >export var -2 > m1_instance1 -3 > = -4 > new -5 > m1_c1 -6 > () -7 > ; -1->Emitted(9, 5) Source(6, 12) + SourceIndex(0) -2 >Emitted(9, 25) Source(6, 24) + SourceIndex(0) -3 >Emitted(9, 28) Source(6, 27) + SourceIndex(0) -4 >Emitted(9, 32) Source(6, 31) + SourceIndex(0) -5 >Emitted(9, 37) Source(6, 36) + SourceIndex(0) -6 >Emitted(9, 39) Source(6, 38) + SourceIndex(0) -7 >Emitted(9, 40) Source(6, 39) + SourceIndex(0) ---- ->>> function m1_f1() { -1 >^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -1 >Emitted(10, 5) Source(7, 1) + SourceIndex(0) ---- ->>> return exports.m1_instance1; -1->^^^^^^^^ -2 > ^^^^^^ -3 > ^ -4 > ^^^^^^^^^^^^^^^^^^^^ -5 > ^ -1->export function m1_f1() { - > -2 > return -3 > -4 > m1_instance1 -5 > ; -1->Emitted(11, 9) Source(8, 5) + SourceIndex(0) name (m1_f1) -2 >Emitted(11, 15) Source(8, 11) + SourceIndex(0) name (m1_f1) -3 >Emitted(11, 16) Source(8, 12) + SourceIndex(0) name (m1_f1) -4 >Emitted(11, 36) Source(8, 24) + SourceIndex(0) name (m1_f1) -5 >Emitted(11, 37) Source(8, 25) + SourceIndex(0) name (m1_f1) ---- ->>> } -1 >^^^^ -2 > ^ -3 > ^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -2 > } -1 >Emitted(12, 5) Source(9, 1) + SourceIndex(0) name (m1_f1) -2 >Emitted(12, 6) Source(9, 2) + SourceIndex(0) name (m1_f1) ---- ->>> exports.m1_f1 = m1_f1; -1->^^^^ -2 > ^^^^^^^^^^^^^ -3 > ^^^^^^^^ -4 > ^ -1-> -2 > m1_f1 -3 > () { - > return m1_instance1; - > } -4 > -1->Emitted(13, 5) Source(7, 17) + SourceIndex(0) -2 >Emitted(13, 18) Source(7, 22) + SourceIndex(0) -3 >Emitted(13, 26) Source(9, 2) + SourceIndex(0) -4 >Emitted(13, 27) Source(9, 2) + SourceIndex(0) ---- ->>>}); ->>>//# sourceMappingURL=m1.js.map=================================================================== -JsFile: test.js -mapUrl: test.js.map -sourceRoot: -sources: test.ts -=================================================================== -------------------------------------------------------------------- -emittedFile:test.js -sourceFile:test.ts -------------------------------------------------------------------- ->>>define(["require", "exports", "m1"], function (require, exports, m1) { ->>> exports.a1 = 10; -1 >^^^^ -2 > ^^^^^^^^^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^-> -1 >import m1 = require("m1"); - >export var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(2, 5) Source(2, 12) + SourceIndex(0) -2 >Emitted(2, 15) Source(2, 14) + SourceIndex(0) -3 >Emitted(2, 18) Source(2, 17) + SourceIndex(0) -4 >Emitted(2, 20) Source(2, 19) + SourceIndex(0) -5 >Emitted(2, 21) Source(2, 20) + SourceIndex(0) ---- ->>> var c1 = (function () { -1->^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^-> -1-> - > -1->Emitted(3, 5) Source(3, 1) + SourceIndex(0) ---- ->>> function c1() { -1->^^^^^^^^ -2 > ^^-> -1-> -1->Emitted(4, 9) Source(3, 1) + SourceIndex(0) name (c1) ---- ->>> } -1->^^^^^^^^ -2 > ^ -3 > ^^^^^^^^^^-> -1->export class c1 { - > public p1: number; - > -2 > } -1->Emitted(5, 9) Source(5, 1) + SourceIndex(0) name (c1.constructor) -2 >Emitted(5, 10) Source(5, 2) + SourceIndex(0) name (c1.constructor) ---- ->>> return c1; -1->^^^^^^^^ -2 > ^^^^^^^^^ -1-> -2 > } -1->Emitted(6, 9) Source(5, 1) + SourceIndex(0) name (c1) -2 >Emitted(6, 18) Source(5, 2) + SourceIndex(0) name (c1) ---- ->>> })(); -1 >^^^^ -2 > ^ -3 > -4 > ^^^^ -5 > ^^^^^^^^^^^^-> -1 > -2 > } -3 > -4 > export class c1 { - > public p1: number; - > } -1 >Emitted(7, 5) Source(5, 1) + SourceIndex(0) name (c1) -2 >Emitted(7, 6) Source(5, 2) + SourceIndex(0) name (c1) -3 >Emitted(7, 6) Source(3, 1) + SourceIndex(0) -4 >Emitted(7, 10) Source(5, 2) + SourceIndex(0) ---- ->>> exports.c1 = c1; -1->^^^^ -2 > ^^^^^^^^^^ -3 > ^^^^^ -4 > ^ -5 > ^^^^^^^^^^^^^^-> -1-> -2 > c1 -3 > { - > public p1: number; - > } -4 > -1->Emitted(8, 5) Source(3, 14) + SourceIndex(0) -2 >Emitted(8, 15) Source(3, 16) + SourceIndex(0) -3 >Emitted(8, 20) Source(5, 2) + SourceIndex(0) -4 >Emitted(8, 21) Source(5, 2) + SourceIndex(0) ---- ->>> exports.instance1 = new c1(); -1->^^^^ -2 > ^^^^^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^^^ -5 > ^^ -6 > ^^ -7 > ^ -1-> - > - >export var -2 > instance1 -3 > = -4 > new -5 > c1 -6 > () -7 > ; -1->Emitted(9, 5) Source(7, 12) + SourceIndex(0) -2 >Emitted(9, 22) Source(7, 21) + SourceIndex(0) -3 >Emitted(9, 25) Source(7, 24) + SourceIndex(0) -4 >Emitted(9, 29) Source(7, 28) + SourceIndex(0) -5 >Emitted(9, 31) Source(7, 30) + SourceIndex(0) -6 >Emitted(9, 33) Source(7, 32) + SourceIndex(0) -7 >Emitted(9, 34) Source(7, 33) + SourceIndex(0) ---- ->>> function f1() { -1 >^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -1 >Emitted(10, 5) Source(8, 1) + SourceIndex(0) ---- ->>> return exports.instance1; -1->^^^^^^^^ -2 > ^^^^^^ -3 > ^ -4 > ^^^^^^^^^^^^^^^^^ -5 > ^ -1->export function f1() { - > -2 > return -3 > -4 > instance1 -5 > ; -1->Emitted(11, 9) Source(9, 5) + SourceIndex(0) name (f1) -2 >Emitted(11, 15) Source(9, 11) + SourceIndex(0) name (f1) -3 >Emitted(11, 16) Source(9, 12) + SourceIndex(0) name (f1) -4 >Emitted(11, 33) Source(9, 21) + SourceIndex(0) name (f1) -5 >Emitted(11, 34) Source(9, 22) + SourceIndex(0) name (f1) ---- ->>> } -1 >^^^^ -2 > ^ -3 > ^^^^^^^^^^^^^^^^-> -1 > - > -2 > } -1 >Emitted(12, 5) Source(10, 1) + SourceIndex(0) name (f1) -2 >Emitted(12, 6) Source(10, 2) + SourceIndex(0) name (f1) ---- ->>> exports.f1 = f1; -1->^^^^ -2 > ^^^^^^^^^^ -3 > ^^^^^ -4 > ^ -5 > ^^^^^^^-> -1-> -2 > f1 -3 > () { - > return instance1; - > } -4 > -1->Emitted(13, 5) Source(8, 17) + SourceIndex(0) -2 >Emitted(13, 15) Source(8, 19) + SourceIndex(0) -3 >Emitted(13, 20) Source(10, 2) + SourceIndex(0) -4 >Emitted(13, 21) Source(10, 2) + SourceIndex(0) ---- ->>> exports.a2 = m1.m1_c1; -1->^^^^ -2 > ^^^^^^^^^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^ -7 > ^ -1-> - > - >export var -2 > a2 -3 > = -4 > m1 -5 > . -6 > m1_c1 -7 > ; -1->Emitted(14, 5) Source(12, 12) + SourceIndex(0) -2 >Emitted(14, 15) Source(12, 14) + SourceIndex(0) -3 >Emitted(14, 18) Source(12, 17) + SourceIndex(0) -4 >Emitted(14, 20) Source(12, 19) + SourceIndex(0) -5 >Emitted(14, 21) Source(12, 20) + SourceIndex(0) -6 >Emitted(14, 26) Source(12, 25) + SourceIndex(0) -7 >Emitted(14, 27) Source(12, 26) + SourceIndex(0) ---- ->>>}); ->>>//# sourceMappingURL=test.js.map=================================================================== JsFile: test.js mapUrl: test.js.map sourceRoot: diff --git a/tests/baselines/reference/project/sourcemapModuleSimpleSpecifyOutputFile/amd/test.d.ts b/tests/baselines/reference/project/sourcemapModuleSimpleSpecifyOutputFile/amd/test.d.ts deleted file mode 100644 index 250d2615a79..00000000000 --- a/tests/baselines/reference/project/sourcemapModuleSimpleSpecifyOutputFile/amd/test.d.ts +++ /dev/null @@ -1,8 +0,0 @@ -import m1 = require("m1"); -export declare var a1: number; -export declare class c1 { - p1: number; -} -export declare var instance1: c1; -export declare function f1(): c1; -export declare var a2: typeof m1.m1_c1; diff --git a/tests/baselines/reference/project/sourcemapModuleSimpleSpecifyOutputFile/amd/test.js b/tests/baselines/reference/project/sourcemapModuleSimpleSpecifyOutputFile/amd/test.js deleted file mode 100644 index 372f1052b89..00000000000 --- a/tests/baselines/reference/project/sourcemapModuleSimpleSpecifyOutputFile/amd/test.js +++ /dev/null @@ -1,16 +0,0 @@ -define(["require", "exports", "m1"], function (require, exports, m1) { - exports.a1 = 10; - var c1 = (function () { - function c1() { - } - return c1; - })(); - exports.c1 = c1; - exports.instance1 = new c1(); - function f1() { - return exports.instance1; - } - exports.f1 = f1; - exports.a2 = m1.m1_c1; -}); -//# sourceMappingURL=test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcemapModuleSimpleSpecifyOutputFile/amd/test.js.map b/tests/baselines/reference/project/sourcemapModuleSimpleSpecifyOutputFile/amd/test.js.map deleted file mode 100644 index 9bcc170386c..00000000000 --- a/tests/baselines/reference/project/sourcemapModuleSimpleSpecifyOutputFile/amd/test.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"test.js","sourceRoot":"","sources":["test.ts"],"names":["c1","c1.constructor","f1"],"mappings":";IACW,UAAE,GAAG,EAAE,CAAC;IACnB;QAAAA;QAEAC,CAACA;QAADD,SAACA;IAADA,CAACA,AAFD,IAEC;IAFY,UAAE,KAEd,CAAA;IAEU,iBAAS,GAAG,IAAI,EAAE,EAAE,CAAC;IAChC;QACIE,MAAMA,CAACA,iBAASA,CAACA;IACrBA,CAACA;IAFe,UAAE,KAEjB,CAAA;IAEU,UAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcemapModuleSimpleSpecifyOutputFile/node/m1.d.ts b/tests/baselines/reference/project/sourcemapModuleSimpleSpecifyOutputFile/node/m1.d.ts deleted file mode 100644 index 4a53b24b156..00000000000 --- a/tests/baselines/reference/project/sourcemapModuleSimpleSpecifyOutputFile/node/m1.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -export declare var m1_a1: number; -export declare class m1_c1 { - m1_c1_p1: number; -} -export declare var m1_instance1: m1_c1; -export declare function m1_f1(): m1_c1; diff --git a/tests/baselines/reference/project/sourcemapModuleSimpleSpecifyOutputFile/node/m1.js b/tests/baselines/reference/project/sourcemapModuleSimpleSpecifyOutputFile/node/m1.js deleted file mode 100644 index 1b4470e2b37..00000000000 --- a/tests/baselines/reference/project/sourcemapModuleSimpleSpecifyOutputFile/node/m1.js +++ /dev/null @@ -1,13 +0,0 @@ -exports.m1_a1 = 10; -var m1_c1 = (function () { - function m1_c1() { - } - return m1_c1; -})(); -exports.m1_c1 = m1_c1; -exports.m1_instance1 = new m1_c1(); -function m1_f1() { - return exports.m1_instance1; -} -exports.m1_f1 = m1_f1; -//# sourceMappingURL=m1.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcemapModuleSimpleSpecifyOutputFile/node/m1.js.map b/tests/baselines/reference/project/sourcemapModuleSimpleSpecifyOutputFile/node/m1.js.map deleted file mode 100644 index 095951a67d0..00000000000 --- a/tests/baselines/reference/project/sourcemapModuleSimpleSpecifyOutputFile/node/m1.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"m1.js","sourceRoot":"","sources":["m1.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1"],"mappings":"AAAW,aAAK,GAAG,EAAE,CAAC;AACtB;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAFY,aAAK,QAEjB,CAAA;AAEU,oBAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACIE,MAAMA,CAACA,oBAAYA,CAACA;AACxBA,CAACA;AAFe,aAAK,QAEpB,CAAA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcemapModuleSimpleSpecifyOutputFile/node/sourcemapModuleSimpleSpecifyOutputFile.json b/tests/baselines/reference/project/sourcemapModuleSimpleSpecifyOutputFile/node/sourcemapModuleSimpleSpecifyOutputFile.json index 9ff29662d40..c9889aff69b 100644 --- a/tests/baselines/reference/project/sourcemapModuleSimpleSpecifyOutputFile/node/sourcemapModuleSimpleSpecifyOutputFile.json +++ b/tests/baselines/reference/project/sourcemapModuleSimpleSpecifyOutputFile/node/sourcemapModuleSimpleSpecifyOutputFile.json @@ -14,12 +14,6 @@ "test.ts" ], "emittedFiles": [ - "m1.js.map", - "m1.js", - "m1.d.ts", - "test.js.map", - "test.js", - "test.d.ts", "bin/test.js.map", "bin/test.js", "bin/test.d.ts" diff --git a/tests/baselines/reference/project/sourcemapModuleSimpleSpecifyOutputFile/node/sourcemapModuleSimpleSpecifyOutputFile.sourcemap.txt b/tests/baselines/reference/project/sourcemapModuleSimpleSpecifyOutputFile/node/sourcemapModuleSimpleSpecifyOutputFile.sourcemap.txt index c1334bd15ae..056b7a1c7f2 100644 --- a/tests/baselines/reference/project/sourcemapModuleSimpleSpecifyOutputFile/node/sourcemapModuleSimpleSpecifyOutputFile.sourcemap.txt +++ b/tests/baselines/reference/project/sourcemapModuleSimpleSpecifyOutputFile/node/sourcemapModuleSimpleSpecifyOutputFile.sourcemap.txt @@ -1,396 +1,4 @@ =================================================================== -JsFile: m1.js -mapUrl: m1.js.map -sourceRoot: -sources: m1.ts -=================================================================== -------------------------------------------------------------------- -emittedFile:m1.js -sourceFile:m1.ts -------------------------------------------------------------------- ->>>exports.m1_a1 = 10; -1 > -2 >^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^-> -1 >export var -2 >m1_a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(1, 1) Source(1, 12) + SourceIndex(0) -2 >Emitted(1, 14) Source(1, 17) + SourceIndex(0) -3 >Emitted(1, 17) Source(1, 20) + SourceIndex(0) -4 >Emitted(1, 19) Source(1, 22) + SourceIndex(0) -5 >Emitted(1, 20) Source(1, 23) + SourceIndex(0) ---- ->>>var m1_c1 = (function () { -1-> -2 >^^^^^^^^^^^^^^^^^^^^^^^-> -1-> - > -1->Emitted(2, 1) Source(2, 1) + SourceIndex(0) ---- ->>> function m1_c1() { -1->^^^^ -2 > ^^-> -1-> -1->Emitted(3, 5) Source(2, 1) + SourceIndex(0) name (m1_c1) ---- ->>> } -1->^^^^ -2 > ^ -3 > ^^^^^^^^^^^^^-> -1->export class m1_c1 { - > public m1_c1_p1: number; - > -2 > } -1->Emitted(4, 5) Source(4, 1) + SourceIndex(0) name (m1_c1.constructor) -2 >Emitted(4, 6) Source(4, 2) + SourceIndex(0) name (m1_c1.constructor) ---- ->>> return m1_c1; -1->^^^^ -2 > ^^^^^^^^^^^^ -1-> -2 > } -1->Emitted(5, 5) Source(4, 1) + SourceIndex(0) name (m1_c1) -2 >Emitted(5, 17) Source(4, 2) + SourceIndex(0) name (m1_c1) ---- ->>>})(); -1 > -2 >^ -3 > -4 > ^^^^ -5 > ^^^^^^^^^^^^^^^^^^-> -1 > -2 >} -3 > -4 > export class m1_c1 { - > public m1_c1_p1: number; - > } -1 >Emitted(6, 1) Source(4, 1) + SourceIndex(0) name (m1_c1) -2 >Emitted(6, 2) Source(4, 2) + SourceIndex(0) name (m1_c1) -3 >Emitted(6, 2) Source(2, 1) + SourceIndex(0) -4 >Emitted(6, 6) Source(4, 2) + SourceIndex(0) ---- ->>>exports.m1_c1 = m1_c1; -1-> -2 >^^^^^^^^^^^^^ -3 > ^^^^^^^^ -4 > ^ -5 > ^^^^^^^^^^^^^^-> -1-> -2 >m1_c1 -3 > { - > public m1_c1_p1: number; - > } -4 > -1->Emitted(7, 1) Source(2, 14) + SourceIndex(0) -2 >Emitted(7, 14) Source(2, 19) + SourceIndex(0) -3 >Emitted(7, 22) Source(4, 2) + SourceIndex(0) -4 >Emitted(7, 23) Source(4, 2) + SourceIndex(0) ---- ->>>exports.m1_instance1 = new m1_c1(); -1-> -2 >^^^^^^^^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^^^ -5 > ^^^^^ -6 > ^^ -7 > ^ -1-> - > - >export var -2 >m1_instance1 -3 > = -4 > new -5 > m1_c1 -6 > () -7 > ; -1->Emitted(8, 1) Source(6, 12) + SourceIndex(0) -2 >Emitted(8, 21) Source(6, 24) + SourceIndex(0) -3 >Emitted(8, 24) Source(6, 27) + SourceIndex(0) -4 >Emitted(8, 28) Source(6, 31) + SourceIndex(0) -5 >Emitted(8, 33) Source(6, 36) + SourceIndex(0) -6 >Emitted(8, 35) Source(6, 38) + SourceIndex(0) -7 >Emitted(8, 36) Source(6, 39) + SourceIndex(0) ---- ->>>function m1_f1() { -1 > -2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -1 >Emitted(9, 1) Source(7, 1) + SourceIndex(0) ---- ->>> return exports.m1_instance1; -1->^^^^ -2 > ^^^^^^ -3 > ^ -4 > ^^^^^^^^^^^^^^^^^^^^ -5 > ^ -1->export function m1_f1() { - > -2 > return -3 > -4 > m1_instance1 -5 > ; -1->Emitted(10, 5) Source(8, 5) + SourceIndex(0) name (m1_f1) -2 >Emitted(10, 11) Source(8, 11) + SourceIndex(0) name (m1_f1) -3 >Emitted(10, 12) Source(8, 12) + SourceIndex(0) name (m1_f1) -4 >Emitted(10, 32) Source(8, 24) + SourceIndex(0) name (m1_f1) -5 >Emitted(10, 33) Source(8, 25) + SourceIndex(0) name (m1_f1) ---- ->>>} -1 > -2 >^ -3 > ^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -2 >} -1 >Emitted(11, 1) Source(9, 1) + SourceIndex(0) name (m1_f1) -2 >Emitted(11, 2) Source(9, 2) + SourceIndex(0) name (m1_f1) ---- ->>>exports.m1_f1 = m1_f1; -1-> -2 >^^^^^^^^^^^^^ -3 > ^^^^^^^^ -4 > ^ -5 > ^^^^^^^-> -1-> -2 >m1_f1 -3 > () { - > return m1_instance1; - > } -4 > -1->Emitted(12, 1) Source(7, 17) + SourceIndex(0) -2 >Emitted(12, 14) Source(7, 22) + SourceIndex(0) -3 >Emitted(12, 22) Source(9, 2) + SourceIndex(0) -4 >Emitted(12, 23) Source(9, 2) + SourceIndex(0) ---- ->>>//# sourceMappingURL=m1.js.map=================================================================== -JsFile: test.js -mapUrl: test.js.map -sourceRoot: -sources: test.ts -=================================================================== -------------------------------------------------------------------- -emittedFile:test.js -sourceFile:test.ts -------------------------------------------------------------------- ->>>var m1 = require("m1"); -1 > -2 >^^^^ -3 > ^^ -4 > ^^^^^^^^^^^ -5 > ^^^^ -6 > ^ -7 > ^ -1 > -2 >import -3 > m1 -4 > = require( -5 > "m1" -6 > ) -7 > ; -1 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) -2 >Emitted(1, 5) Source(1, 8) + SourceIndex(0) -3 >Emitted(1, 7) Source(1, 10) + SourceIndex(0) -4 >Emitted(1, 18) Source(1, 21) + SourceIndex(0) -5 >Emitted(1, 22) Source(1, 25) + SourceIndex(0) -6 >Emitted(1, 23) Source(1, 26) + SourceIndex(0) -7 >Emitted(1, 24) Source(1, 27) + SourceIndex(0) ---- ->>>exports.a1 = 10; -1 > -2 >^^^^^^^^^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^-> -1 > - >export var -2 >a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(2, 1) Source(2, 12) + SourceIndex(0) -2 >Emitted(2, 11) Source(2, 14) + SourceIndex(0) -3 >Emitted(2, 14) Source(2, 17) + SourceIndex(0) -4 >Emitted(2, 16) Source(2, 19) + SourceIndex(0) -5 >Emitted(2, 17) Source(2, 20) + SourceIndex(0) ---- ->>>var c1 = (function () { -1-> -2 >^^^^^^^^^^^^^^^^^^^^-> -1-> - > -1->Emitted(3, 1) Source(3, 1) + SourceIndex(0) ---- ->>> function c1() { -1->^^^^ -2 > ^^-> -1-> -1->Emitted(4, 5) Source(3, 1) + SourceIndex(0) name (c1) ---- ->>> } -1->^^^^ -2 > ^ -3 > ^^^^^^^^^^-> -1->export class c1 { - > public p1: number; - > -2 > } -1->Emitted(5, 5) Source(5, 1) + SourceIndex(0) name (c1.constructor) -2 >Emitted(5, 6) Source(5, 2) + SourceIndex(0) name (c1.constructor) ---- ->>> return c1; -1->^^^^ -2 > ^^^^^^^^^ -1-> -2 > } -1->Emitted(6, 5) Source(5, 1) + SourceIndex(0) name (c1) -2 >Emitted(6, 14) Source(5, 2) + SourceIndex(0) name (c1) ---- ->>>})(); -1 > -2 >^ -3 > -4 > ^^^^ -5 > ^^^^^^^^^^^^-> -1 > -2 >} -3 > -4 > export class c1 { - > public p1: number; - > } -1 >Emitted(7, 1) Source(5, 1) + SourceIndex(0) name (c1) -2 >Emitted(7, 2) Source(5, 2) + SourceIndex(0) name (c1) -3 >Emitted(7, 2) Source(3, 1) + SourceIndex(0) -4 >Emitted(7, 6) Source(5, 2) + SourceIndex(0) ---- ->>>exports.c1 = c1; -1-> -2 >^^^^^^^^^^ -3 > ^^^^^ -4 > ^ -5 > ^^^^^^^^^^^^^^-> -1-> -2 >c1 -3 > { - > public p1: number; - > } -4 > -1->Emitted(8, 1) Source(3, 14) + SourceIndex(0) -2 >Emitted(8, 11) Source(3, 16) + SourceIndex(0) -3 >Emitted(8, 16) Source(5, 2) + SourceIndex(0) -4 >Emitted(8, 17) Source(5, 2) + SourceIndex(0) ---- ->>>exports.instance1 = new c1(); -1-> -2 >^^^^^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^^^ -5 > ^^ -6 > ^^ -7 > ^ -1-> - > - >export var -2 >instance1 -3 > = -4 > new -5 > c1 -6 > () -7 > ; -1->Emitted(9, 1) Source(7, 12) + SourceIndex(0) -2 >Emitted(9, 18) Source(7, 21) + SourceIndex(0) -3 >Emitted(9, 21) Source(7, 24) + SourceIndex(0) -4 >Emitted(9, 25) Source(7, 28) + SourceIndex(0) -5 >Emitted(9, 27) Source(7, 30) + SourceIndex(0) -6 >Emitted(9, 29) Source(7, 32) + SourceIndex(0) -7 >Emitted(9, 30) Source(7, 33) + SourceIndex(0) ---- ->>>function f1() { -1 > -2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -1 >Emitted(10, 1) Source(8, 1) + SourceIndex(0) ---- ->>> return exports.instance1; -1->^^^^ -2 > ^^^^^^ -3 > ^ -4 > ^^^^^^^^^^^^^^^^^ -5 > ^ -1->export function f1() { - > -2 > return -3 > -4 > instance1 -5 > ; -1->Emitted(11, 5) Source(9, 5) + SourceIndex(0) name (f1) -2 >Emitted(11, 11) Source(9, 11) + SourceIndex(0) name (f1) -3 >Emitted(11, 12) Source(9, 12) + SourceIndex(0) name (f1) -4 >Emitted(11, 29) Source(9, 21) + SourceIndex(0) name (f1) -5 >Emitted(11, 30) Source(9, 22) + SourceIndex(0) name (f1) ---- ->>>} -1 > -2 >^ -3 > ^^^^^^^^^^^^^^^^-> -1 > - > -2 >} -1 >Emitted(12, 1) Source(10, 1) + SourceIndex(0) name (f1) -2 >Emitted(12, 2) Source(10, 2) + SourceIndex(0) name (f1) ---- ->>>exports.f1 = f1; -1-> -2 >^^^^^^^^^^ -3 > ^^^^^ -4 > ^ -5 > ^^^^^^^-> -1-> -2 >f1 -3 > () { - > return instance1; - > } -4 > -1->Emitted(13, 1) Source(8, 17) + SourceIndex(0) -2 >Emitted(13, 11) Source(8, 19) + SourceIndex(0) -3 >Emitted(13, 16) Source(10, 2) + SourceIndex(0) -4 >Emitted(13, 17) Source(10, 2) + SourceIndex(0) ---- ->>>exports.a2 = m1.m1_c1; -1-> -2 >^^^^^^^^^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^ -7 > ^ -8 > ^^^^^^^^^-> -1-> - > - >export var -2 >a2 -3 > = -4 > m1 -5 > . -6 > m1_c1 -7 > ; -1->Emitted(14, 1) Source(12, 12) + SourceIndex(0) -2 >Emitted(14, 11) Source(12, 14) + SourceIndex(0) -3 >Emitted(14, 14) Source(12, 17) + SourceIndex(0) -4 >Emitted(14, 16) Source(12, 19) + SourceIndex(0) -5 >Emitted(14, 17) Source(12, 20) + SourceIndex(0) -6 >Emitted(14, 22) Source(12, 25) + SourceIndex(0) -7 >Emitted(14, 23) Source(12, 26) + SourceIndex(0) ---- ->>>//# sourceMappingURL=test.js.map=================================================================== JsFile: test.js mapUrl: test.js.map sourceRoot: diff --git a/tests/baselines/reference/project/sourcemapModuleSimpleSpecifyOutputFile/node/test.d.ts b/tests/baselines/reference/project/sourcemapModuleSimpleSpecifyOutputFile/node/test.d.ts deleted file mode 100644 index 250d2615a79..00000000000 --- a/tests/baselines/reference/project/sourcemapModuleSimpleSpecifyOutputFile/node/test.d.ts +++ /dev/null @@ -1,8 +0,0 @@ -import m1 = require("m1"); -export declare var a1: number; -export declare class c1 { - p1: number; -} -export declare var instance1: c1; -export declare function f1(): c1; -export declare var a2: typeof m1.m1_c1; diff --git a/tests/baselines/reference/project/sourcemapModuleSimpleSpecifyOutputFile/node/test.js b/tests/baselines/reference/project/sourcemapModuleSimpleSpecifyOutputFile/node/test.js deleted file mode 100644 index c2e7dfa443b..00000000000 --- a/tests/baselines/reference/project/sourcemapModuleSimpleSpecifyOutputFile/node/test.js +++ /dev/null @@ -1,15 +0,0 @@ -var m1 = require("m1"); -exports.a1 = 10; -var c1 = (function () { - function c1() { - } - return c1; -})(); -exports.c1 = c1; -exports.instance1 = new c1(); -function f1() { - return exports.instance1; -} -exports.f1 = f1; -exports.a2 = m1.m1_c1; -//# sourceMappingURL=test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcemapModuleSimpleSpecifyOutputFile/node/test.js.map b/tests/baselines/reference/project/sourcemapModuleSimpleSpecifyOutputFile/node/test.js.map deleted file mode 100644 index 7bae4ed7491..00000000000 --- a/tests/baselines/reference/project/sourcemapModuleSimpleSpecifyOutputFile/node/test.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"test.js","sourceRoot":"","sources":["test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AAAA,IAAO,EAAE,WAAW,IAAI,CAAC,CAAC;AACf,UAAE,GAAG,EAAE,CAAC;AACnB;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAFY,UAAE,KAEd,CAAA;AAEU,iBAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AAChC;IACIE,MAAMA,CAACA,iBAASA,CAACA;AACrBA,CAACA;AAFe,UAAE,KAEjB,CAAA;AAEU,UAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcemapModuleSubfolderSpecifyOutputFile/amd/ref/m1.d.ts b/tests/baselines/reference/project/sourcemapModuleSubfolderSpecifyOutputFile/amd/ref/m1.d.ts deleted file mode 100644 index 4a53b24b156..00000000000 --- a/tests/baselines/reference/project/sourcemapModuleSubfolderSpecifyOutputFile/amd/ref/m1.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -export declare var m1_a1: number; -export declare class m1_c1 { - m1_c1_p1: number; -} -export declare var m1_instance1: m1_c1; -export declare function m1_f1(): m1_c1; diff --git a/tests/baselines/reference/project/sourcemapModuleSubfolderSpecifyOutputFile/amd/ref/m1.js b/tests/baselines/reference/project/sourcemapModuleSubfolderSpecifyOutputFile/amd/ref/m1.js deleted file mode 100644 index bbaba444ba2..00000000000 --- a/tests/baselines/reference/project/sourcemapModuleSubfolderSpecifyOutputFile/amd/ref/m1.js +++ /dev/null @@ -1,15 +0,0 @@ -define(["require", "exports"], function (require, exports) { - exports.m1_a1 = 10; - var m1_c1 = (function () { - function m1_c1() { - } - return m1_c1; - })(); - exports.m1_c1 = m1_c1; - exports.m1_instance1 = new m1_c1(); - function m1_f1() { - return exports.m1_instance1; - } - exports.m1_f1 = m1_f1; -}); -//# sourceMappingURL=m1.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcemapModuleSubfolderSpecifyOutputFile/amd/ref/m1.js.map b/tests/baselines/reference/project/sourcemapModuleSubfolderSpecifyOutputFile/amd/ref/m1.js.map deleted file mode 100644 index 51755e4c9a3..00000000000 --- a/tests/baselines/reference/project/sourcemapModuleSubfolderSpecifyOutputFile/amd/ref/m1.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"m1.js","sourceRoot":"","sources":["m1.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1"],"mappings":";IAAW,aAAK,GAAG,EAAE,CAAC;IACtB;QAAAA;QAEAC,CAACA;QAADD,YAACA;IAADA,CAACA,AAFD,IAEC;IAFY,aAAK,QAEjB,CAAA;IAEU,oBAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACIE,MAAMA,CAACA,oBAAYA,CAACA;IACxBA,CAACA;IAFe,aAAK,QAEpB,CAAA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcemapModuleSubfolderSpecifyOutputFile/amd/sourcemapModuleSubfolderSpecifyOutputFile.json b/tests/baselines/reference/project/sourcemapModuleSubfolderSpecifyOutputFile/amd/sourcemapModuleSubfolderSpecifyOutputFile.json index 9d200ef685d..da85c1bf06c 100644 --- a/tests/baselines/reference/project/sourcemapModuleSubfolderSpecifyOutputFile/amd/sourcemapModuleSubfolderSpecifyOutputFile.json +++ b/tests/baselines/reference/project/sourcemapModuleSubfolderSpecifyOutputFile/amd/sourcemapModuleSubfolderSpecifyOutputFile.json @@ -14,12 +14,6 @@ "test.ts" ], "emittedFiles": [ - "ref/m1.js.map", - "ref/m1.js", - "ref/m1.d.ts", - "test.js.map", - "test.js", - "test.d.ts", "bin/test.js.map", "bin/test.js", "bin/test.d.ts" diff --git a/tests/baselines/reference/project/sourcemapModuleSubfolderSpecifyOutputFile/amd/sourcemapModuleSubfolderSpecifyOutputFile.sourcemap.txt b/tests/baselines/reference/project/sourcemapModuleSubfolderSpecifyOutputFile/amd/sourcemapModuleSubfolderSpecifyOutputFile.sourcemap.txt index c72d3084670..9c12e1749ca 100644 --- a/tests/baselines/reference/project/sourcemapModuleSubfolderSpecifyOutputFile/amd/sourcemapModuleSubfolderSpecifyOutputFile.sourcemap.txt +++ b/tests/baselines/reference/project/sourcemapModuleSubfolderSpecifyOutputFile/amd/sourcemapModuleSubfolderSpecifyOutputFile.sourcemap.txt @@ -1,375 +1,4 @@ =================================================================== -JsFile: m1.js -mapUrl: m1.js.map -sourceRoot: -sources: m1.ts -=================================================================== -------------------------------------------------------------------- -emittedFile:ref/m1.js -sourceFile:m1.ts -------------------------------------------------------------------- ->>>define(["require", "exports"], function (require, exports) { ->>> exports.m1_a1 = 10; -1 >^^^^ -2 > ^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^-> -1 >export var -2 > m1_a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(2, 5) Source(1, 12) + SourceIndex(0) -2 >Emitted(2, 18) Source(1, 17) + SourceIndex(0) -3 >Emitted(2, 21) Source(1, 20) + SourceIndex(0) -4 >Emitted(2, 23) Source(1, 22) + SourceIndex(0) -5 >Emitted(2, 24) Source(1, 23) + SourceIndex(0) ---- ->>> var m1_c1 = (function () { -1->^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^^^^-> -1-> - > -1->Emitted(3, 5) Source(2, 1) + SourceIndex(0) ---- ->>> function m1_c1() { -1->^^^^^^^^ -2 > ^^-> -1-> -1->Emitted(4, 9) Source(2, 1) + SourceIndex(0) name (m1_c1) ---- ->>> } -1->^^^^^^^^ -2 > ^ -3 > ^^^^^^^^^^^^^-> -1->export class m1_c1 { - > public m1_c1_p1: number; - > -2 > } -1->Emitted(5, 9) Source(4, 1) + SourceIndex(0) name (m1_c1.constructor) -2 >Emitted(5, 10) Source(4, 2) + SourceIndex(0) name (m1_c1.constructor) ---- ->>> return m1_c1; -1->^^^^^^^^ -2 > ^^^^^^^^^^^^ -1-> -2 > } -1->Emitted(6, 9) Source(4, 1) + SourceIndex(0) name (m1_c1) -2 >Emitted(6, 21) Source(4, 2) + SourceIndex(0) name (m1_c1) ---- ->>> })(); -1 >^^^^ -2 > ^ -3 > -4 > ^^^^ -5 > ^^^^^^^^^^^^^^^^^^-> -1 > -2 > } -3 > -4 > export class m1_c1 { - > public m1_c1_p1: number; - > } -1 >Emitted(7, 5) Source(4, 1) + SourceIndex(0) name (m1_c1) -2 >Emitted(7, 6) Source(4, 2) + SourceIndex(0) name (m1_c1) -3 >Emitted(7, 6) Source(2, 1) + SourceIndex(0) -4 >Emitted(7, 10) Source(4, 2) + SourceIndex(0) ---- ->>> exports.m1_c1 = m1_c1; -1->^^^^ -2 > ^^^^^^^^^^^^^ -3 > ^^^^^^^^ -4 > ^ -5 > ^^^^^^^^^^^^^^-> -1-> -2 > m1_c1 -3 > { - > public m1_c1_p1: number; - > } -4 > -1->Emitted(8, 5) Source(2, 14) + SourceIndex(0) -2 >Emitted(8, 18) Source(2, 19) + SourceIndex(0) -3 >Emitted(8, 26) Source(4, 2) + SourceIndex(0) -4 >Emitted(8, 27) Source(4, 2) + SourceIndex(0) ---- ->>> exports.m1_instance1 = new m1_c1(); -1->^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^^^ -5 > ^^^^^ -6 > ^^ -7 > ^ -1-> - > - >export var -2 > m1_instance1 -3 > = -4 > new -5 > m1_c1 -6 > () -7 > ; -1->Emitted(9, 5) Source(6, 12) + SourceIndex(0) -2 >Emitted(9, 25) Source(6, 24) + SourceIndex(0) -3 >Emitted(9, 28) Source(6, 27) + SourceIndex(0) -4 >Emitted(9, 32) Source(6, 31) + SourceIndex(0) -5 >Emitted(9, 37) Source(6, 36) + SourceIndex(0) -6 >Emitted(9, 39) Source(6, 38) + SourceIndex(0) -7 >Emitted(9, 40) Source(6, 39) + SourceIndex(0) ---- ->>> function m1_f1() { -1 >^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -1 >Emitted(10, 5) Source(7, 1) + SourceIndex(0) ---- ->>> return exports.m1_instance1; -1->^^^^^^^^ -2 > ^^^^^^ -3 > ^ -4 > ^^^^^^^^^^^^^^^^^^^^ -5 > ^ -1->export function m1_f1() { - > -2 > return -3 > -4 > m1_instance1 -5 > ; -1->Emitted(11, 9) Source(8, 5) + SourceIndex(0) name (m1_f1) -2 >Emitted(11, 15) Source(8, 11) + SourceIndex(0) name (m1_f1) -3 >Emitted(11, 16) Source(8, 12) + SourceIndex(0) name (m1_f1) -4 >Emitted(11, 36) Source(8, 24) + SourceIndex(0) name (m1_f1) -5 >Emitted(11, 37) Source(8, 25) + SourceIndex(0) name (m1_f1) ---- ->>> } -1 >^^^^ -2 > ^ -3 > ^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -2 > } -1 >Emitted(12, 5) Source(9, 1) + SourceIndex(0) name (m1_f1) -2 >Emitted(12, 6) Source(9, 2) + SourceIndex(0) name (m1_f1) ---- ->>> exports.m1_f1 = m1_f1; -1->^^^^ -2 > ^^^^^^^^^^^^^ -3 > ^^^^^^^^ -4 > ^ -1-> -2 > m1_f1 -3 > () { - > return m1_instance1; - > } -4 > -1->Emitted(13, 5) Source(7, 17) + SourceIndex(0) -2 >Emitted(13, 18) Source(7, 22) + SourceIndex(0) -3 >Emitted(13, 26) Source(9, 2) + SourceIndex(0) -4 >Emitted(13, 27) Source(9, 2) + SourceIndex(0) ---- ->>>}); ->>>//# sourceMappingURL=m1.js.map=================================================================== -JsFile: test.js -mapUrl: test.js.map -sourceRoot: -sources: test.ts -=================================================================== -------------------------------------------------------------------- -emittedFile:test.js -sourceFile:test.ts -------------------------------------------------------------------- ->>>define(["require", "exports", "ref/m1"], function (require, exports, m1) { ->>> exports.a1 = 10; -1 >^^^^ -2 > ^^^^^^^^^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^-> -1 >import m1 = require("ref/m1"); - >export var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(2, 5) Source(2, 12) + SourceIndex(0) -2 >Emitted(2, 15) Source(2, 14) + SourceIndex(0) -3 >Emitted(2, 18) Source(2, 17) + SourceIndex(0) -4 >Emitted(2, 20) Source(2, 19) + SourceIndex(0) -5 >Emitted(2, 21) Source(2, 20) + SourceIndex(0) ---- ->>> var c1 = (function () { -1->^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^-> -1-> - > -1->Emitted(3, 5) Source(3, 1) + SourceIndex(0) ---- ->>> function c1() { -1->^^^^^^^^ -2 > ^^-> -1-> -1->Emitted(4, 9) Source(3, 1) + SourceIndex(0) name (c1) ---- ->>> } -1->^^^^^^^^ -2 > ^ -3 > ^^^^^^^^^^-> -1->export class c1 { - > public p1: number; - > -2 > } -1->Emitted(5, 9) Source(5, 1) + SourceIndex(0) name (c1.constructor) -2 >Emitted(5, 10) Source(5, 2) + SourceIndex(0) name (c1.constructor) ---- ->>> return c1; -1->^^^^^^^^ -2 > ^^^^^^^^^ -1-> -2 > } -1->Emitted(6, 9) Source(5, 1) + SourceIndex(0) name (c1) -2 >Emitted(6, 18) Source(5, 2) + SourceIndex(0) name (c1) ---- ->>> })(); -1 >^^^^ -2 > ^ -3 > -4 > ^^^^ -5 > ^^^^^^^^^^^^-> -1 > -2 > } -3 > -4 > export class c1 { - > public p1: number; - > } -1 >Emitted(7, 5) Source(5, 1) + SourceIndex(0) name (c1) -2 >Emitted(7, 6) Source(5, 2) + SourceIndex(0) name (c1) -3 >Emitted(7, 6) Source(3, 1) + SourceIndex(0) -4 >Emitted(7, 10) Source(5, 2) + SourceIndex(0) ---- ->>> exports.c1 = c1; -1->^^^^ -2 > ^^^^^^^^^^ -3 > ^^^^^ -4 > ^ -5 > ^^^^^^^^^^^^^^-> -1-> -2 > c1 -3 > { - > public p1: number; - > } -4 > -1->Emitted(8, 5) Source(3, 14) + SourceIndex(0) -2 >Emitted(8, 15) Source(3, 16) + SourceIndex(0) -3 >Emitted(8, 20) Source(5, 2) + SourceIndex(0) -4 >Emitted(8, 21) Source(5, 2) + SourceIndex(0) ---- ->>> exports.instance1 = new c1(); -1->^^^^ -2 > ^^^^^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^^^ -5 > ^^ -6 > ^^ -7 > ^ -1-> - > - >export var -2 > instance1 -3 > = -4 > new -5 > c1 -6 > () -7 > ; -1->Emitted(9, 5) Source(7, 12) + SourceIndex(0) -2 >Emitted(9, 22) Source(7, 21) + SourceIndex(0) -3 >Emitted(9, 25) Source(7, 24) + SourceIndex(0) -4 >Emitted(9, 29) Source(7, 28) + SourceIndex(0) -5 >Emitted(9, 31) Source(7, 30) + SourceIndex(0) -6 >Emitted(9, 33) Source(7, 32) + SourceIndex(0) -7 >Emitted(9, 34) Source(7, 33) + SourceIndex(0) ---- ->>> function f1() { -1 >^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -1 >Emitted(10, 5) Source(8, 1) + SourceIndex(0) ---- ->>> return exports.instance1; -1->^^^^^^^^ -2 > ^^^^^^ -3 > ^ -4 > ^^^^^^^^^^^^^^^^^ -5 > ^ -1->export function f1() { - > -2 > return -3 > -4 > instance1 -5 > ; -1->Emitted(11, 9) Source(9, 5) + SourceIndex(0) name (f1) -2 >Emitted(11, 15) Source(9, 11) + SourceIndex(0) name (f1) -3 >Emitted(11, 16) Source(9, 12) + SourceIndex(0) name (f1) -4 >Emitted(11, 33) Source(9, 21) + SourceIndex(0) name (f1) -5 >Emitted(11, 34) Source(9, 22) + SourceIndex(0) name (f1) ---- ->>> } -1 >^^^^ -2 > ^ -3 > ^^^^^^^^^^^^^^^^-> -1 > - > -2 > } -1 >Emitted(12, 5) Source(10, 1) + SourceIndex(0) name (f1) -2 >Emitted(12, 6) Source(10, 2) + SourceIndex(0) name (f1) ---- ->>> exports.f1 = f1; -1->^^^^ -2 > ^^^^^^^^^^ -3 > ^^^^^ -4 > ^ -5 > ^^^^^^^-> -1-> -2 > f1 -3 > () { - > return instance1; - > } -4 > -1->Emitted(13, 5) Source(8, 17) + SourceIndex(0) -2 >Emitted(13, 15) Source(8, 19) + SourceIndex(0) -3 >Emitted(13, 20) Source(10, 2) + SourceIndex(0) -4 >Emitted(13, 21) Source(10, 2) + SourceIndex(0) ---- ->>> exports.a2 = m1.m1_c1; -1->^^^^ -2 > ^^^^^^^^^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^ -7 > ^ -1-> - > - >export var -2 > a2 -3 > = -4 > m1 -5 > . -6 > m1_c1 -7 > ; -1->Emitted(14, 5) Source(12, 12) + SourceIndex(0) -2 >Emitted(14, 15) Source(12, 14) + SourceIndex(0) -3 >Emitted(14, 18) Source(12, 17) + SourceIndex(0) -4 >Emitted(14, 20) Source(12, 19) + SourceIndex(0) -5 >Emitted(14, 21) Source(12, 20) + SourceIndex(0) -6 >Emitted(14, 26) Source(12, 25) + SourceIndex(0) -7 >Emitted(14, 27) Source(12, 26) + SourceIndex(0) ---- ->>>}); ->>>//# sourceMappingURL=test.js.map=================================================================== JsFile: test.js mapUrl: test.js.map sourceRoot: diff --git a/tests/baselines/reference/project/sourcemapModuleSubfolderSpecifyOutputFile/amd/test.d.ts b/tests/baselines/reference/project/sourcemapModuleSubfolderSpecifyOutputFile/amd/test.d.ts deleted file mode 100644 index a61d8541048..00000000000 --- a/tests/baselines/reference/project/sourcemapModuleSubfolderSpecifyOutputFile/amd/test.d.ts +++ /dev/null @@ -1,8 +0,0 @@ -import m1 = require("ref/m1"); -export declare var a1: number; -export declare class c1 { - p1: number; -} -export declare var instance1: c1; -export declare function f1(): c1; -export declare var a2: typeof m1.m1_c1; diff --git a/tests/baselines/reference/project/sourcemapModuleSubfolderSpecifyOutputFile/amd/test.js b/tests/baselines/reference/project/sourcemapModuleSubfolderSpecifyOutputFile/amd/test.js deleted file mode 100644 index 6c8aeb3190b..00000000000 --- a/tests/baselines/reference/project/sourcemapModuleSubfolderSpecifyOutputFile/amd/test.js +++ /dev/null @@ -1,16 +0,0 @@ -define(["require", "exports", "ref/m1"], function (require, exports, m1) { - exports.a1 = 10; - var c1 = (function () { - function c1() { - } - return c1; - })(); - exports.c1 = c1; - exports.instance1 = new c1(); - function f1() { - return exports.instance1; - } - exports.f1 = f1; - exports.a2 = m1.m1_c1; -}); -//# sourceMappingURL=test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcemapModuleSubfolderSpecifyOutputFile/amd/test.js.map b/tests/baselines/reference/project/sourcemapModuleSubfolderSpecifyOutputFile/amd/test.js.map deleted file mode 100644 index 9bcc170386c..00000000000 --- a/tests/baselines/reference/project/sourcemapModuleSubfolderSpecifyOutputFile/amd/test.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"test.js","sourceRoot":"","sources":["test.ts"],"names":["c1","c1.constructor","f1"],"mappings":";IACW,UAAE,GAAG,EAAE,CAAC;IACnB;QAAAA;QAEAC,CAACA;QAADD,SAACA;IAADA,CAACA,AAFD,IAEC;IAFY,UAAE,KAEd,CAAA;IAEU,iBAAS,GAAG,IAAI,EAAE,EAAE,CAAC;IAChC;QACIE,MAAMA,CAACA,iBAASA,CAACA;IACrBA,CAACA;IAFe,UAAE,KAEjB,CAAA;IAEU,UAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcemapModuleSubfolderSpecifyOutputFile/node/ref/m1.d.ts b/tests/baselines/reference/project/sourcemapModuleSubfolderSpecifyOutputFile/node/ref/m1.d.ts deleted file mode 100644 index 4a53b24b156..00000000000 --- a/tests/baselines/reference/project/sourcemapModuleSubfolderSpecifyOutputFile/node/ref/m1.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -export declare var m1_a1: number; -export declare class m1_c1 { - m1_c1_p1: number; -} -export declare var m1_instance1: m1_c1; -export declare function m1_f1(): m1_c1; diff --git a/tests/baselines/reference/project/sourcemapModuleSubfolderSpecifyOutputFile/node/ref/m1.js b/tests/baselines/reference/project/sourcemapModuleSubfolderSpecifyOutputFile/node/ref/m1.js deleted file mode 100644 index 1b4470e2b37..00000000000 --- a/tests/baselines/reference/project/sourcemapModuleSubfolderSpecifyOutputFile/node/ref/m1.js +++ /dev/null @@ -1,13 +0,0 @@ -exports.m1_a1 = 10; -var m1_c1 = (function () { - function m1_c1() { - } - return m1_c1; -})(); -exports.m1_c1 = m1_c1; -exports.m1_instance1 = new m1_c1(); -function m1_f1() { - return exports.m1_instance1; -} -exports.m1_f1 = m1_f1; -//# sourceMappingURL=m1.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcemapModuleSubfolderSpecifyOutputFile/node/ref/m1.js.map b/tests/baselines/reference/project/sourcemapModuleSubfolderSpecifyOutputFile/node/ref/m1.js.map deleted file mode 100644 index 095951a67d0..00000000000 --- a/tests/baselines/reference/project/sourcemapModuleSubfolderSpecifyOutputFile/node/ref/m1.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"m1.js","sourceRoot":"","sources":["m1.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1"],"mappings":"AAAW,aAAK,GAAG,EAAE,CAAC;AACtB;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAFY,aAAK,QAEjB,CAAA;AAEU,oBAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACIE,MAAMA,CAACA,oBAAYA,CAACA;AACxBA,CAACA;AAFe,aAAK,QAEpB,CAAA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcemapModuleSubfolderSpecifyOutputFile/node/sourcemapModuleSubfolderSpecifyOutputFile.json b/tests/baselines/reference/project/sourcemapModuleSubfolderSpecifyOutputFile/node/sourcemapModuleSubfolderSpecifyOutputFile.json index 9d200ef685d..da85c1bf06c 100644 --- a/tests/baselines/reference/project/sourcemapModuleSubfolderSpecifyOutputFile/node/sourcemapModuleSubfolderSpecifyOutputFile.json +++ b/tests/baselines/reference/project/sourcemapModuleSubfolderSpecifyOutputFile/node/sourcemapModuleSubfolderSpecifyOutputFile.json @@ -14,12 +14,6 @@ "test.ts" ], "emittedFiles": [ - "ref/m1.js.map", - "ref/m1.js", - "ref/m1.d.ts", - "test.js.map", - "test.js", - "test.d.ts", "bin/test.js.map", "bin/test.js", "bin/test.d.ts" diff --git a/tests/baselines/reference/project/sourcemapModuleSubfolderSpecifyOutputFile/node/sourcemapModuleSubfolderSpecifyOutputFile.sourcemap.txt b/tests/baselines/reference/project/sourcemapModuleSubfolderSpecifyOutputFile/node/sourcemapModuleSubfolderSpecifyOutputFile.sourcemap.txt index 9011abbae05..282a64dbc6f 100644 --- a/tests/baselines/reference/project/sourcemapModuleSubfolderSpecifyOutputFile/node/sourcemapModuleSubfolderSpecifyOutputFile.sourcemap.txt +++ b/tests/baselines/reference/project/sourcemapModuleSubfolderSpecifyOutputFile/node/sourcemapModuleSubfolderSpecifyOutputFile.sourcemap.txt @@ -1,396 +1,4 @@ =================================================================== -JsFile: m1.js -mapUrl: m1.js.map -sourceRoot: -sources: m1.ts -=================================================================== -------------------------------------------------------------------- -emittedFile:ref/m1.js -sourceFile:m1.ts -------------------------------------------------------------------- ->>>exports.m1_a1 = 10; -1 > -2 >^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^-> -1 >export var -2 >m1_a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(1, 1) Source(1, 12) + SourceIndex(0) -2 >Emitted(1, 14) Source(1, 17) + SourceIndex(0) -3 >Emitted(1, 17) Source(1, 20) + SourceIndex(0) -4 >Emitted(1, 19) Source(1, 22) + SourceIndex(0) -5 >Emitted(1, 20) Source(1, 23) + SourceIndex(0) ---- ->>>var m1_c1 = (function () { -1-> -2 >^^^^^^^^^^^^^^^^^^^^^^^-> -1-> - > -1->Emitted(2, 1) Source(2, 1) + SourceIndex(0) ---- ->>> function m1_c1() { -1->^^^^ -2 > ^^-> -1-> -1->Emitted(3, 5) Source(2, 1) + SourceIndex(0) name (m1_c1) ---- ->>> } -1->^^^^ -2 > ^ -3 > ^^^^^^^^^^^^^-> -1->export class m1_c1 { - > public m1_c1_p1: number; - > -2 > } -1->Emitted(4, 5) Source(4, 1) + SourceIndex(0) name (m1_c1.constructor) -2 >Emitted(4, 6) Source(4, 2) + SourceIndex(0) name (m1_c1.constructor) ---- ->>> return m1_c1; -1->^^^^ -2 > ^^^^^^^^^^^^ -1-> -2 > } -1->Emitted(5, 5) Source(4, 1) + SourceIndex(0) name (m1_c1) -2 >Emitted(5, 17) Source(4, 2) + SourceIndex(0) name (m1_c1) ---- ->>>})(); -1 > -2 >^ -3 > -4 > ^^^^ -5 > ^^^^^^^^^^^^^^^^^^-> -1 > -2 >} -3 > -4 > export class m1_c1 { - > public m1_c1_p1: number; - > } -1 >Emitted(6, 1) Source(4, 1) + SourceIndex(0) name (m1_c1) -2 >Emitted(6, 2) Source(4, 2) + SourceIndex(0) name (m1_c1) -3 >Emitted(6, 2) Source(2, 1) + SourceIndex(0) -4 >Emitted(6, 6) Source(4, 2) + SourceIndex(0) ---- ->>>exports.m1_c1 = m1_c1; -1-> -2 >^^^^^^^^^^^^^ -3 > ^^^^^^^^ -4 > ^ -5 > ^^^^^^^^^^^^^^-> -1-> -2 >m1_c1 -3 > { - > public m1_c1_p1: number; - > } -4 > -1->Emitted(7, 1) Source(2, 14) + SourceIndex(0) -2 >Emitted(7, 14) Source(2, 19) + SourceIndex(0) -3 >Emitted(7, 22) Source(4, 2) + SourceIndex(0) -4 >Emitted(7, 23) Source(4, 2) + SourceIndex(0) ---- ->>>exports.m1_instance1 = new m1_c1(); -1-> -2 >^^^^^^^^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^^^ -5 > ^^^^^ -6 > ^^ -7 > ^ -1-> - > - >export var -2 >m1_instance1 -3 > = -4 > new -5 > m1_c1 -6 > () -7 > ; -1->Emitted(8, 1) Source(6, 12) + SourceIndex(0) -2 >Emitted(8, 21) Source(6, 24) + SourceIndex(0) -3 >Emitted(8, 24) Source(6, 27) + SourceIndex(0) -4 >Emitted(8, 28) Source(6, 31) + SourceIndex(0) -5 >Emitted(8, 33) Source(6, 36) + SourceIndex(0) -6 >Emitted(8, 35) Source(6, 38) + SourceIndex(0) -7 >Emitted(8, 36) Source(6, 39) + SourceIndex(0) ---- ->>>function m1_f1() { -1 > -2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -1 >Emitted(9, 1) Source(7, 1) + SourceIndex(0) ---- ->>> return exports.m1_instance1; -1->^^^^ -2 > ^^^^^^ -3 > ^ -4 > ^^^^^^^^^^^^^^^^^^^^ -5 > ^ -1->export function m1_f1() { - > -2 > return -3 > -4 > m1_instance1 -5 > ; -1->Emitted(10, 5) Source(8, 5) + SourceIndex(0) name (m1_f1) -2 >Emitted(10, 11) Source(8, 11) + SourceIndex(0) name (m1_f1) -3 >Emitted(10, 12) Source(8, 12) + SourceIndex(0) name (m1_f1) -4 >Emitted(10, 32) Source(8, 24) + SourceIndex(0) name (m1_f1) -5 >Emitted(10, 33) Source(8, 25) + SourceIndex(0) name (m1_f1) ---- ->>>} -1 > -2 >^ -3 > ^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -2 >} -1 >Emitted(11, 1) Source(9, 1) + SourceIndex(0) name (m1_f1) -2 >Emitted(11, 2) Source(9, 2) + SourceIndex(0) name (m1_f1) ---- ->>>exports.m1_f1 = m1_f1; -1-> -2 >^^^^^^^^^^^^^ -3 > ^^^^^^^^ -4 > ^ -5 > ^^^^^^^-> -1-> -2 >m1_f1 -3 > () { - > return m1_instance1; - > } -4 > -1->Emitted(12, 1) Source(7, 17) + SourceIndex(0) -2 >Emitted(12, 14) Source(7, 22) + SourceIndex(0) -3 >Emitted(12, 22) Source(9, 2) + SourceIndex(0) -4 >Emitted(12, 23) Source(9, 2) + SourceIndex(0) ---- ->>>//# sourceMappingURL=m1.js.map=================================================================== -JsFile: test.js -mapUrl: test.js.map -sourceRoot: -sources: test.ts -=================================================================== -------------------------------------------------------------------- -emittedFile:test.js -sourceFile:test.ts -------------------------------------------------------------------- ->>>var m1 = require("ref/m1"); -1 > -2 >^^^^ -3 > ^^ -4 > ^^^^^^^^^^^ -5 > ^^^^^^^^ -6 > ^ -7 > ^ -1 > -2 >import -3 > m1 -4 > = require( -5 > "ref/m1" -6 > ) -7 > ; -1 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) -2 >Emitted(1, 5) Source(1, 8) + SourceIndex(0) -3 >Emitted(1, 7) Source(1, 10) + SourceIndex(0) -4 >Emitted(1, 18) Source(1, 21) + SourceIndex(0) -5 >Emitted(1, 26) Source(1, 29) + SourceIndex(0) -6 >Emitted(1, 27) Source(1, 30) + SourceIndex(0) -7 >Emitted(1, 28) Source(1, 31) + SourceIndex(0) ---- ->>>exports.a1 = 10; -1 > -2 >^^^^^^^^^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^-> -1 > - >export var -2 >a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(2, 1) Source(2, 12) + SourceIndex(0) -2 >Emitted(2, 11) Source(2, 14) + SourceIndex(0) -3 >Emitted(2, 14) Source(2, 17) + SourceIndex(0) -4 >Emitted(2, 16) Source(2, 19) + SourceIndex(0) -5 >Emitted(2, 17) Source(2, 20) + SourceIndex(0) ---- ->>>var c1 = (function () { -1-> -2 >^^^^^^^^^^^^^^^^^^^^-> -1-> - > -1->Emitted(3, 1) Source(3, 1) + SourceIndex(0) ---- ->>> function c1() { -1->^^^^ -2 > ^^-> -1-> -1->Emitted(4, 5) Source(3, 1) + SourceIndex(0) name (c1) ---- ->>> } -1->^^^^ -2 > ^ -3 > ^^^^^^^^^^-> -1->export class c1 { - > public p1: number; - > -2 > } -1->Emitted(5, 5) Source(5, 1) + SourceIndex(0) name (c1.constructor) -2 >Emitted(5, 6) Source(5, 2) + SourceIndex(0) name (c1.constructor) ---- ->>> return c1; -1->^^^^ -2 > ^^^^^^^^^ -1-> -2 > } -1->Emitted(6, 5) Source(5, 1) + SourceIndex(0) name (c1) -2 >Emitted(6, 14) Source(5, 2) + SourceIndex(0) name (c1) ---- ->>>})(); -1 > -2 >^ -3 > -4 > ^^^^ -5 > ^^^^^^^^^^^^-> -1 > -2 >} -3 > -4 > export class c1 { - > public p1: number; - > } -1 >Emitted(7, 1) Source(5, 1) + SourceIndex(0) name (c1) -2 >Emitted(7, 2) Source(5, 2) + SourceIndex(0) name (c1) -3 >Emitted(7, 2) Source(3, 1) + SourceIndex(0) -4 >Emitted(7, 6) Source(5, 2) + SourceIndex(0) ---- ->>>exports.c1 = c1; -1-> -2 >^^^^^^^^^^ -3 > ^^^^^ -4 > ^ -5 > ^^^^^^^^^^^^^^-> -1-> -2 >c1 -3 > { - > public p1: number; - > } -4 > -1->Emitted(8, 1) Source(3, 14) + SourceIndex(0) -2 >Emitted(8, 11) Source(3, 16) + SourceIndex(0) -3 >Emitted(8, 16) Source(5, 2) + SourceIndex(0) -4 >Emitted(8, 17) Source(5, 2) + SourceIndex(0) ---- ->>>exports.instance1 = new c1(); -1-> -2 >^^^^^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^^^ -5 > ^^ -6 > ^^ -7 > ^ -1-> - > - >export var -2 >instance1 -3 > = -4 > new -5 > c1 -6 > () -7 > ; -1->Emitted(9, 1) Source(7, 12) + SourceIndex(0) -2 >Emitted(9, 18) Source(7, 21) + SourceIndex(0) -3 >Emitted(9, 21) Source(7, 24) + SourceIndex(0) -4 >Emitted(9, 25) Source(7, 28) + SourceIndex(0) -5 >Emitted(9, 27) Source(7, 30) + SourceIndex(0) -6 >Emitted(9, 29) Source(7, 32) + SourceIndex(0) -7 >Emitted(9, 30) Source(7, 33) + SourceIndex(0) ---- ->>>function f1() { -1 > -2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -1 >Emitted(10, 1) Source(8, 1) + SourceIndex(0) ---- ->>> return exports.instance1; -1->^^^^ -2 > ^^^^^^ -3 > ^ -4 > ^^^^^^^^^^^^^^^^^ -5 > ^ -1->export function f1() { - > -2 > return -3 > -4 > instance1 -5 > ; -1->Emitted(11, 5) Source(9, 5) + SourceIndex(0) name (f1) -2 >Emitted(11, 11) Source(9, 11) + SourceIndex(0) name (f1) -3 >Emitted(11, 12) Source(9, 12) + SourceIndex(0) name (f1) -4 >Emitted(11, 29) Source(9, 21) + SourceIndex(0) name (f1) -5 >Emitted(11, 30) Source(9, 22) + SourceIndex(0) name (f1) ---- ->>>} -1 > -2 >^ -3 > ^^^^^^^^^^^^^^^^-> -1 > - > -2 >} -1 >Emitted(12, 1) Source(10, 1) + SourceIndex(0) name (f1) -2 >Emitted(12, 2) Source(10, 2) + SourceIndex(0) name (f1) ---- ->>>exports.f1 = f1; -1-> -2 >^^^^^^^^^^ -3 > ^^^^^ -4 > ^ -5 > ^^^^^^^-> -1-> -2 >f1 -3 > () { - > return instance1; - > } -4 > -1->Emitted(13, 1) Source(8, 17) + SourceIndex(0) -2 >Emitted(13, 11) Source(8, 19) + SourceIndex(0) -3 >Emitted(13, 16) Source(10, 2) + SourceIndex(0) -4 >Emitted(13, 17) Source(10, 2) + SourceIndex(0) ---- ->>>exports.a2 = m1.m1_c1; -1-> -2 >^^^^^^^^^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^ -7 > ^ -8 > ^^^^^^^^^-> -1-> - > - >export var -2 >a2 -3 > = -4 > m1 -5 > . -6 > m1_c1 -7 > ; -1->Emitted(14, 1) Source(12, 12) + SourceIndex(0) -2 >Emitted(14, 11) Source(12, 14) + SourceIndex(0) -3 >Emitted(14, 14) Source(12, 17) + SourceIndex(0) -4 >Emitted(14, 16) Source(12, 19) + SourceIndex(0) -5 >Emitted(14, 17) Source(12, 20) + SourceIndex(0) -6 >Emitted(14, 22) Source(12, 25) + SourceIndex(0) -7 >Emitted(14, 23) Source(12, 26) + SourceIndex(0) ---- ->>>//# sourceMappingURL=test.js.map=================================================================== JsFile: test.js mapUrl: test.js.map sourceRoot: diff --git a/tests/baselines/reference/project/sourcemapModuleSubfolderSpecifyOutputFile/node/test.d.ts b/tests/baselines/reference/project/sourcemapModuleSubfolderSpecifyOutputFile/node/test.d.ts deleted file mode 100644 index a61d8541048..00000000000 --- a/tests/baselines/reference/project/sourcemapModuleSubfolderSpecifyOutputFile/node/test.d.ts +++ /dev/null @@ -1,8 +0,0 @@ -import m1 = require("ref/m1"); -export declare var a1: number; -export declare class c1 { - p1: number; -} -export declare var instance1: c1; -export declare function f1(): c1; -export declare var a2: typeof m1.m1_c1; diff --git a/tests/baselines/reference/project/sourcemapModuleSubfolderSpecifyOutputFile/node/test.js b/tests/baselines/reference/project/sourcemapModuleSubfolderSpecifyOutputFile/node/test.js deleted file mode 100644 index 46c9f29e55a..00000000000 --- a/tests/baselines/reference/project/sourcemapModuleSubfolderSpecifyOutputFile/node/test.js +++ /dev/null @@ -1,15 +0,0 @@ -var m1 = require("ref/m1"); -exports.a1 = 10; -var c1 = (function () { - function c1() { - } - return c1; -})(); -exports.c1 = c1; -exports.instance1 = new c1(); -function f1() { - return exports.instance1; -} -exports.f1 = f1; -exports.a2 = m1.m1_c1; -//# sourceMappingURL=test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcemapModuleSubfolderSpecifyOutputFile/node/test.js.map b/tests/baselines/reference/project/sourcemapModuleSubfolderSpecifyOutputFile/node/test.js.map deleted file mode 100644 index 56d42d8bdfd..00000000000 --- a/tests/baselines/reference/project/sourcemapModuleSubfolderSpecifyOutputFile/node/test.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"test.js","sourceRoot":"","sources":["test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AAAA,IAAO,EAAE,WAAW,QAAQ,CAAC,CAAC;AACnB,UAAE,GAAG,EAAE,CAAC;AACnB;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAFY,UAAE,KAEd,CAAA;AAEU,iBAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AAChC;IACIE,MAAMA,CAACA,iBAASA,CAACA;AACrBA,CAACA;AAFe,UAAE,KAEjB,CAAA;AAEU,UAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFile/amd/ref/m2.d.ts b/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFile/amd/ref/m2.d.ts deleted file mode 100644 index c09a3c0c32a..00000000000 --- a/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFile/amd/ref/m2.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -export declare var m2_a1: number; -export declare class m2_c1 { - m2_c1_p1: number; -} -export declare var m2_instance1: m2_c1; -export declare function m2_f1(): m2_c1; diff --git a/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFile/amd/ref/m2.js b/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFile/amd/ref/m2.js deleted file mode 100644 index 144ad24e2de..00000000000 --- a/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFile/amd/ref/m2.js +++ /dev/null @@ -1,15 +0,0 @@ -define(["require", "exports"], function (require, exports) { - exports.m2_a1 = 10; - var m2_c1 = (function () { - function m2_c1() { - } - return m2_c1; - })(); - exports.m2_c1 = m2_c1; - exports.m2_instance1 = new m2_c1(); - function m2_f1() { - return exports.m2_instance1; - } - exports.m2_f1 = m2_f1; -}); -//# sourceMappingURL=m2.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFile/amd/ref/m2.js.map b/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFile/amd/ref/m2.js.map deleted file mode 100644 index 04f168a6289..00000000000 --- a/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFile/amd/ref/m2.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"m2.js","sourceRoot":"http://typescript.codeplex.com/","sources":["ref/m2.ts"],"names":["m2_c1","m2_c1.constructor","m2_f1"],"mappings":";IAAW,aAAK,GAAG,EAAE,CAAC;IACtB;QAAAA;QAEAC,CAACA;QAADD,YAACA;IAADA,CAACA,AAFD,IAEC;IAFY,aAAK,QAEjB,CAAA;IAEU,oBAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACIE,MAAMA,CAACA,oBAAYA,CAACA;IACxBA,CAACA;IAFe,aAAK,QAEpB,CAAA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFile/amd/sourcerootUrlMixedSubfolderSpecifyOutputFile.json b/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFile/amd/sourcerootUrlMixedSubfolderSpecifyOutputFile.json index 50a4518a1b0..7316c8b01c9 100644 --- a/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFile/amd/sourcerootUrlMixedSubfolderSpecifyOutputFile.json +++ b/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFile/amd/sourcerootUrlMixedSubfolderSpecifyOutputFile.json @@ -16,9 +16,6 @@ "test.ts" ], "emittedFiles": [ - "ref/m2.js.map", - "ref/m2.js", - "ref/m2.d.ts", "bin/test.js.map", "bin/test.js", "bin/test.d.ts" diff --git a/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFile/amd/sourcerootUrlMixedSubfolderSpecifyOutputFile.sourcemap.txt b/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFile/amd/sourcerootUrlMixedSubfolderSpecifyOutputFile.sourcemap.txt index d88a0d7585b..51a641cb750 100644 --- a/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFile/amd/sourcerootUrlMixedSubfolderSpecifyOutputFile.sourcemap.txt +++ b/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFile/amd/sourcerootUrlMixedSubfolderSpecifyOutputFile.sourcemap.txt @@ -1,176 +1,4 @@ =================================================================== -JsFile: m2.js -mapUrl: m2.js.map -sourceRoot: http://typescript.codeplex.com/ -sources: ref/m2.ts -=================================================================== -------------------------------------------------------------------- -emittedFile:ref/m2.js -sourceFile:ref/m2.ts -------------------------------------------------------------------- ->>>define(["require", "exports"], function (require, exports) { ->>> exports.m2_a1 = 10; -1 >^^^^ -2 > ^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^-> -1 >export var -2 > m2_a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(2, 5) Source(1, 12) + SourceIndex(0) -2 >Emitted(2, 18) Source(1, 17) + SourceIndex(0) -3 >Emitted(2, 21) Source(1, 20) + SourceIndex(0) -4 >Emitted(2, 23) Source(1, 22) + SourceIndex(0) -5 >Emitted(2, 24) Source(1, 23) + SourceIndex(0) ---- ->>> var m2_c1 = (function () { -1->^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^^^^-> -1-> - > -1->Emitted(3, 5) Source(2, 1) + SourceIndex(0) ---- ->>> function m2_c1() { -1->^^^^^^^^ -2 > ^^-> -1-> -1->Emitted(4, 9) Source(2, 1) + SourceIndex(0) name (m2_c1) ---- ->>> } -1->^^^^^^^^ -2 > ^ -3 > ^^^^^^^^^^^^^-> -1->export class m2_c1 { - > public m2_c1_p1: number; - > -2 > } -1->Emitted(5, 9) Source(4, 1) + SourceIndex(0) name (m2_c1.constructor) -2 >Emitted(5, 10) Source(4, 2) + SourceIndex(0) name (m2_c1.constructor) ---- ->>> return m2_c1; -1->^^^^^^^^ -2 > ^^^^^^^^^^^^ -1-> -2 > } -1->Emitted(6, 9) Source(4, 1) + SourceIndex(0) name (m2_c1) -2 >Emitted(6, 21) Source(4, 2) + SourceIndex(0) name (m2_c1) ---- ->>> })(); -1 >^^^^ -2 > ^ -3 > -4 > ^^^^ -5 > ^^^^^^^^^^^^^^^^^^-> -1 > -2 > } -3 > -4 > export class m2_c1 { - > public m2_c1_p1: number; - > } -1 >Emitted(7, 5) Source(4, 1) + SourceIndex(0) name (m2_c1) -2 >Emitted(7, 6) Source(4, 2) + SourceIndex(0) name (m2_c1) -3 >Emitted(7, 6) Source(2, 1) + SourceIndex(0) -4 >Emitted(7, 10) Source(4, 2) + SourceIndex(0) ---- ->>> exports.m2_c1 = m2_c1; -1->^^^^ -2 > ^^^^^^^^^^^^^ -3 > ^^^^^^^^ -4 > ^ -5 > ^^^^^^^^^^^^^^-> -1-> -2 > m2_c1 -3 > { - > public m2_c1_p1: number; - > } -4 > -1->Emitted(8, 5) Source(2, 14) + SourceIndex(0) -2 >Emitted(8, 18) Source(2, 19) + SourceIndex(0) -3 >Emitted(8, 26) Source(4, 2) + SourceIndex(0) -4 >Emitted(8, 27) Source(4, 2) + SourceIndex(0) ---- ->>> exports.m2_instance1 = new m2_c1(); -1->^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^^^ -5 > ^^^^^ -6 > ^^ -7 > ^ -1-> - > - >export var -2 > m2_instance1 -3 > = -4 > new -5 > m2_c1 -6 > () -7 > ; -1->Emitted(9, 5) Source(6, 12) + SourceIndex(0) -2 >Emitted(9, 25) Source(6, 24) + SourceIndex(0) -3 >Emitted(9, 28) Source(6, 27) + SourceIndex(0) -4 >Emitted(9, 32) Source(6, 31) + SourceIndex(0) -5 >Emitted(9, 37) Source(6, 36) + SourceIndex(0) -6 >Emitted(9, 39) Source(6, 38) + SourceIndex(0) -7 >Emitted(9, 40) Source(6, 39) + SourceIndex(0) ---- ->>> function m2_f1() { -1 >^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -1 >Emitted(10, 5) Source(7, 1) + SourceIndex(0) ---- ->>> return exports.m2_instance1; -1->^^^^^^^^ -2 > ^^^^^^ -3 > ^ -4 > ^^^^^^^^^^^^^^^^^^^^ -5 > ^ -1->export function m2_f1() { - > -2 > return -3 > -4 > m2_instance1 -5 > ; -1->Emitted(11, 9) Source(8, 5) + SourceIndex(0) name (m2_f1) -2 >Emitted(11, 15) Source(8, 11) + SourceIndex(0) name (m2_f1) -3 >Emitted(11, 16) Source(8, 12) + SourceIndex(0) name (m2_f1) -4 >Emitted(11, 36) Source(8, 24) + SourceIndex(0) name (m2_f1) -5 >Emitted(11, 37) Source(8, 25) + SourceIndex(0) name (m2_f1) ---- ->>> } -1 >^^^^ -2 > ^ -3 > ^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -2 > } -1 >Emitted(12, 5) Source(9, 1) + SourceIndex(0) name (m2_f1) -2 >Emitted(12, 6) Source(9, 2) + SourceIndex(0) name (m2_f1) ---- ->>> exports.m2_f1 = m2_f1; -1->^^^^ -2 > ^^^^^^^^^^^^^ -3 > ^^^^^^^^ -4 > ^ -1-> -2 > m2_f1 -3 > () { - > return m2_instance1; - > } -4 > -1->Emitted(13, 5) Source(7, 17) + SourceIndex(0) -2 >Emitted(13, 18) Source(7, 22) + SourceIndex(0) -3 >Emitted(13, 26) Source(9, 2) + SourceIndex(0) -4 >Emitted(13, 27) Source(9, 2) + SourceIndex(0) ---- ->>>}); ->>>//# sourceMappingURL=m2.js.map=================================================================== JsFile: test.js mapUrl: test.js.map sourceRoot: http://typescript.codeplex.com/ diff --git a/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFile/node/ref/m2.d.ts b/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFile/node/ref/m2.d.ts deleted file mode 100644 index c09a3c0c32a..00000000000 --- a/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFile/node/ref/m2.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -export declare var m2_a1: number; -export declare class m2_c1 { - m2_c1_p1: number; -} -export declare var m2_instance1: m2_c1; -export declare function m2_f1(): m2_c1; diff --git a/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFile/node/ref/m2.js b/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFile/node/ref/m2.js deleted file mode 100644 index ec0a73b5af8..00000000000 --- a/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFile/node/ref/m2.js +++ /dev/null @@ -1,13 +0,0 @@ -exports.m2_a1 = 10; -var m2_c1 = (function () { - function m2_c1() { - } - return m2_c1; -})(); -exports.m2_c1 = m2_c1; -exports.m2_instance1 = new m2_c1(); -function m2_f1() { - return exports.m2_instance1; -} -exports.m2_f1 = m2_f1; -//# sourceMappingURL=m2.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFile/node/ref/m2.js.map b/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFile/node/ref/m2.js.map deleted file mode 100644 index 0ce68e169af..00000000000 --- a/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFile/node/ref/m2.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"m2.js","sourceRoot":"http://typescript.codeplex.com/","sources":["ref/m2.ts"],"names":["m2_c1","m2_c1.constructor","m2_f1"],"mappings":"AAAW,aAAK,GAAG,EAAE,CAAC;AACtB;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAFY,aAAK,QAEjB,CAAA;AAEU,oBAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACIE,MAAMA,CAACA,oBAAYA,CAACA;AACxBA,CAACA;AAFe,aAAK,QAEpB,CAAA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFile/node/sourcerootUrlMixedSubfolderSpecifyOutputFile.json b/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFile/node/sourcerootUrlMixedSubfolderSpecifyOutputFile.json index 50a4518a1b0..7316c8b01c9 100644 --- a/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFile/node/sourcerootUrlMixedSubfolderSpecifyOutputFile.json +++ b/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFile/node/sourcerootUrlMixedSubfolderSpecifyOutputFile.json @@ -16,9 +16,6 @@ "test.ts" ], "emittedFiles": [ - "ref/m2.js.map", - "ref/m2.js", - "ref/m2.d.ts", "bin/test.js.map", "bin/test.js", "bin/test.d.ts" diff --git a/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFile/node/sourcerootUrlMixedSubfolderSpecifyOutputFile.sourcemap.txt b/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFile/node/sourcerootUrlMixedSubfolderSpecifyOutputFile.sourcemap.txt index 244cd8fafdf..38aecc15857 100644 --- a/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFile/node/sourcerootUrlMixedSubfolderSpecifyOutputFile.sourcemap.txt +++ b/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFile/node/sourcerootUrlMixedSubfolderSpecifyOutputFile.sourcemap.txt @@ -1,175 +1,4 @@ =================================================================== -JsFile: m2.js -mapUrl: m2.js.map -sourceRoot: http://typescript.codeplex.com/ -sources: ref/m2.ts -=================================================================== -------------------------------------------------------------------- -emittedFile:ref/m2.js -sourceFile:ref/m2.ts -------------------------------------------------------------------- ->>>exports.m2_a1 = 10; -1 > -2 >^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^-> -1 >export var -2 >m2_a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(1, 1) Source(1, 12) + SourceIndex(0) -2 >Emitted(1, 14) Source(1, 17) + SourceIndex(0) -3 >Emitted(1, 17) Source(1, 20) + SourceIndex(0) -4 >Emitted(1, 19) Source(1, 22) + SourceIndex(0) -5 >Emitted(1, 20) Source(1, 23) + SourceIndex(0) ---- ->>>var m2_c1 = (function () { -1-> -2 >^^^^^^^^^^^^^^^^^^^^^^^-> -1-> - > -1->Emitted(2, 1) Source(2, 1) + SourceIndex(0) ---- ->>> function m2_c1() { -1->^^^^ -2 > ^^-> -1-> -1->Emitted(3, 5) Source(2, 1) + SourceIndex(0) name (m2_c1) ---- ->>> } -1->^^^^ -2 > ^ -3 > ^^^^^^^^^^^^^-> -1->export class m2_c1 { - > public m2_c1_p1: number; - > -2 > } -1->Emitted(4, 5) Source(4, 1) + SourceIndex(0) name (m2_c1.constructor) -2 >Emitted(4, 6) Source(4, 2) + SourceIndex(0) name (m2_c1.constructor) ---- ->>> return m2_c1; -1->^^^^ -2 > ^^^^^^^^^^^^ -1-> -2 > } -1->Emitted(5, 5) Source(4, 1) + SourceIndex(0) name (m2_c1) -2 >Emitted(5, 17) Source(4, 2) + SourceIndex(0) name (m2_c1) ---- ->>>})(); -1 > -2 >^ -3 > -4 > ^^^^ -5 > ^^^^^^^^^^^^^^^^^^-> -1 > -2 >} -3 > -4 > export class m2_c1 { - > public m2_c1_p1: number; - > } -1 >Emitted(6, 1) Source(4, 1) + SourceIndex(0) name (m2_c1) -2 >Emitted(6, 2) Source(4, 2) + SourceIndex(0) name (m2_c1) -3 >Emitted(6, 2) Source(2, 1) + SourceIndex(0) -4 >Emitted(6, 6) Source(4, 2) + SourceIndex(0) ---- ->>>exports.m2_c1 = m2_c1; -1-> -2 >^^^^^^^^^^^^^ -3 > ^^^^^^^^ -4 > ^ -5 > ^^^^^^^^^^^^^^-> -1-> -2 >m2_c1 -3 > { - > public m2_c1_p1: number; - > } -4 > -1->Emitted(7, 1) Source(2, 14) + SourceIndex(0) -2 >Emitted(7, 14) Source(2, 19) + SourceIndex(0) -3 >Emitted(7, 22) Source(4, 2) + SourceIndex(0) -4 >Emitted(7, 23) Source(4, 2) + SourceIndex(0) ---- ->>>exports.m2_instance1 = new m2_c1(); -1-> -2 >^^^^^^^^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^^^ -5 > ^^^^^ -6 > ^^ -7 > ^ -1-> - > - >export var -2 >m2_instance1 -3 > = -4 > new -5 > m2_c1 -6 > () -7 > ; -1->Emitted(8, 1) Source(6, 12) + SourceIndex(0) -2 >Emitted(8, 21) Source(6, 24) + SourceIndex(0) -3 >Emitted(8, 24) Source(6, 27) + SourceIndex(0) -4 >Emitted(8, 28) Source(6, 31) + SourceIndex(0) -5 >Emitted(8, 33) Source(6, 36) + SourceIndex(0) -6 >Emitted(8, 35) Source(6, 38) + SourceIndex(0) -7 >Emitted(8, 36) Source(6, 39) + SourceIndex(0) ---- ->>>function m2_f1() { -1 > -2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -1 >Emitted(9, 1) Source(7, 1) + SourceIndex(0) ---- ->>> return exports.m2_instance1; -1->^^^^ -2 > ^^^^^^ -3 > ^ -4 > ^^^^^^^^^^^^^^^^^^^^ -5 > ^ -1->export function m2_f1() { - > -2 > return -3 > -4 > m2_instance1 -5 > ; -1->Emitted(10, 5) Source(8, 5) + SourceIndex(0) name (m2_f1) -2 >Emitted(10, 11) Source(8, 11) + SourceIndex(0) name (m2_f1) -3 >Emitted(10, 12) Source(8, 12) + SourceIndex(0) name (m2_f1) -4 >Emitted(10, 32) Source(8, 24) + SourceIndex(0) name (m2_f1) -5 >Emitted(10, 33) Source(8, 25) + SourceIndex(0) name (m2_f1) ---- ->>>} -1 > -2 >^ -3 > ^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -2 >} -1 >Emitted(11, 1) Source(9, 1) + SourceIndex(0) name (m2_f1) -2 >Emitted(11, 2) Source(9, 2) + SourceIndex(0) name (m2_f1) ---- ->>>exports.m2_f1 = m2_f1; -1-> -2 >^^^^^^^^^^^^^ -3 > ^^^^^^^^ -4 > ^ -5 > ^^^^^^^-> -1-> -2 >m2_f1 -3 > () { - > return m2_instance1; - > } -4 > -1->Emitted(12, 1) Source(7, 17) + SourceIndex(0) -2 >Emitted(12, 14) Source(7, 22) + SourceIndex(0) -3 >Emitted(12, 22) Source(9, 2) + SourceIndex(0) -4 >Emitted(12, 23) Source(9, 2) + SourceIndex(0) ---- ->>>//# sourceMappingURL=m2.js.map=================================================================== JsFile: test.js mapUrl: test.js.map sourceRoot: http://typescript.codeplex.com/ diff --git a/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/outdir/outAndOutDirFolder/ref/m2.d.ts b/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/outdir/outAndOutDirFolder/ref/m2.d.ts deleted file mode 100644 index c09a3c0c32a..00000000000 --- a/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/outdir/outAndOutDirFolder/ref/m2.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -export declare var m2_a1: number; -export declare class m2_c1 { - m2_c1_p1: number; -} -export declare var m2_instance1: m2_c1; -export declare function m2_f1(): m2_c1; diff --git a/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/outdir/outAndOutDirFolder/ref/m2.js b/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/outdir/outAndOutDirFolder/ref/m2.js deleted file mode 100644 index 144ad24e2de..00000000000 --- a/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/outdir/outAndOutDirFolder/ref/m2.js +++ /dev/null @@ -1,15 +0,0 @@ -define(["require", "exports"], function (require, exports) { - exports.m2_a1 = 10; - var m2_c1 = (function () { - function m2_c1() { - } - return m2_c1; - })(); - exports.m2_c1 = m2_c1; - exports.m2_instance1 = new m2_c1(); - function m2_f1() { - return exports.m2_instance1; - } - exports.m2_f1 = m2_f1; -}); -//# sourceMappingURL=m2.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/outdir/outAndOutDirFolder/ref/m2.js.map b/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/outdir/outAndOutDirFolder/ref/m2.js.map deleted file mode 100644 index 04f168a6289..00000000000 --- a/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/outdir/outAndOutDirFolder/ref/m2.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"m2.js","sourceRoot":"http://typescript.codeplex.com/","sources":["ref/m2.ts"],"names":["m2_c1","m2_c1.constructor","m2_f1"],"mappings":";IAAW,aAAK,GAAG,EAAE,CAAC;IACtB;QAAAA;QAEAC,CAACA;QAADD,YAACA;IAADA,CAACA,AAFD,IAEC;IAFY,aAAK,QAEjB,CAAA;IAEU,oBAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACIE,MAAMA,CAACA,oBAAYA,CAACA;IACxBA,CAACA;IAFe,aAAK,QAEpB,CAAA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/sourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory.json b/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/sourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory.json index b6ef6b5bd51..e165908b72c 100644 --- a/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/sourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory.json +++ b/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/sourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory.json @@ -17,9 +17,6 @@ "test.ts" ], "emittedFiles": [ - "outdir/outAndOutDirFolder/ref/m2.js.map", - "outdir/outAndOutDirFolder/ref/m2.js", - "outdir/outAndOutDirFolder/ref/m2.d.ts", "bin/outAndOutDirFile.js.map", "bin/outAndOutDirFile.js", "bin/outAndOutDirFile.d.ts" diff --git a/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/sourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory.sourcemap.txt b/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/sourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory.sourcemap.txt index 5744420ab71..df760dc79b0 100644 --- a/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/sourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory.sourcemap.txt +++ b/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/sourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory.sourcemap.txt @@ -1,176 +1,4 @@ =================================================================== -JsFile: m2.js -mapUrl: m2.js.map -sourceRoot: http://typescript.codeplex.com/ -sources: ref/m2.ts -=================================================================== -------------------------------------------------------------------- -emittedFile:outdir/outAndOutDirFolder/ref/m2.js -sourceFile:ref/m2.ts -------------------------------------------------------------------- ->>>define(["require", "exports"], function (require, exports) { ->>> exports.m2_a1 = 10; -1 >^^^^ -2 > ^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^-> -1 >export var -2 > m2_a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(2, 5) Source(1, 12) + SourceIndex(0) -2 >Emitted(2, 18) Source(1, 17) + SourceIndex(0) -3 >Emitted(2, 21) Source(1, 20) + SourceIndex(0) -4 >Emitted(2, 23) Source(1, 22) + SourceIndex(0) -5 >Emitted(2, 24) Source(1, 23) + SourceIndex(0) ---- ->>> var m2_c1 = (function () { -1->^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^^^^-> -1-> - > -1->Emitted(3, 5) Source(2, 1) + SourceIndex(0) ---- ->>> function m2_c1() { -1->^^^^^^^^ -2 > ^^-> -1-> -1->Emitted(4, 9) Source(2, 1) + SourceIndex(0) name (m2_c1) ---- ->>> } -1->^^^^^^^^ -2 > ^ -3 > ^^^^^^^^^^^^^-> -1->export class m2_c1 { - > public m2_c1_p1: number; - > -2 > } -1->Emitted(5, 9) Source(4, 1) + SourceIndex(0) name (m2_c1.constructor) -2 >Emitted(5, 10) Source(4, 2) + SourceIndex(0) name (m2_c1.constructor) ---- ->>> return m2_c1; -1->^^^^^^^^ -2 > ^^^^^^^^^^^^ -1-> -2 > } -1->Emitted(6, 9) Source(4, 1) + SourceIndex(0) name (m2_c1) -2 >Emitted(6, 21) Source(4, 2) + SourceIndex(0) name (m2_c1) ---- ->>> })(); -1 >^^^^ -2 > ^ -3 > -4 > ^^^^ -5 > ^^^^^^^^^^^^^^^^^^-> -1 > -2 > } -3 > -4 > export class m2_c1 { - > public m2_c1_p1: number; - > } -1 >Emitted(7, 5) Source(4, 1) + SourceIndex(0) name (m2_c1) -2 >Emitted(7, 6) Source(4, 2) + SourceIndex(0) name (m2_c1) -3 >Emitted(7, 6) Source(2, 1) + SourceIndex(0) -4 >Emitted(7, 10) Source(4, 2) + SourceIndex(0) ---- ->>> exports.m2_c1 = m2_c1; -1->^^^^ -2 > ^^^^^^^^^^^^^ -3 > ^^^^^^^^ -4 > ^ -5 > ^^^^^^^^^^^^^^-> -1-> -2 > m2_c1 -3 > { - > public m2_c1_p1: number; - > } -4 > -1->Emitted(8, 5) Source(2, 14) + SourceIndex(0) -2 >Emitted(8, 18) Source(2, 19) + SourceIndex(0) -3 >Emitted(8, 26) Source(4, 2) + SourceIndex(0) -4 >Emitted(8, 27) Source(4, 2) + SourceIndex(0) ---- ->>> exports.m2_instance1 = new m2_c1(); -1->^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^^^ -5 > ^^^^^ -6 > ^^ -7 > ^ -1-> - > - >export var -2 > m2_instance1 -3 > = -4 > new -5 > m2_c1 -6 > () -7 > ; -1->Emitted(9, 5) Source(6, 12) + SourceIndex(0) -2 >Emitted(9, 25) Source(6, 24) + SourceIndex(0) -3 >Emitted(9, 28) Source(6, 27) + SourceIndex(0) -4 >Emitted(9, 32) Source(6, 31) + SourceIndex(0) -5 >Emitted(9, 37) Source(6, 36) + SourceIndex(0) -6 >Emitted(9, 39) Source(6, 38) + SourceIndex(0) -7 >Emitted(9, 40) Source(6, 39) + SourceIndex(0) ---- ->>> function m2_f1() { -1 >^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -1 >Emitted(10, 5) Source(7, 1) + SourceIndex(0) ---- ->>> return exports.m2_instance1; -1->^^^^^^^^ -2 > ^^^^^^ -3 > ^ -4 > ^^^^^^^^^^^^^^^^^^^^ -5 > ^ -1->export function m2_f1() { - > -2 > return -3 > -4 > m2_instance1 -5 > ; -1->Emitted(11, 9) Source(8, 5) + SourceIndex(0) name (m2_f1) -2 >Emitted(11, 15) Source(8, 11) + SourceIndex(0) name (m2_f1) -3 >Emitted(11, 16) Source(8, 12) + SourceIndex(0) name (m2_f1) -4 >Emitted(11, 36) Source(8, 24) + SourceIndex(0) name (m2_f1) -5 >Emitted(11, 37) Source(8, 25) + SourceIndex(0) name (m2_f1) ---- ->>> } -1 >^^^^ -2 > ^ -3 > ^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -2 > } -1 >Emitted(12, 5) Source(9, 1) + SourceIndex(0) name (m2_f1) -2 >Emitted(12, 6) Source(9, 2) + SourceIndex(0) name (m2_f1) ---- ->>> exports.m2_f1 = m2_f1; -1->^^^^ -2 > ^^^^^^^^^^^^^ -3 > ^^^^^^^^ -4 > ^ -1-> -2 > m2_f1 -3 > () { - > return m2_instance1; - > } -4 > -1->Emitted(13, 5) Source(7, 17) + SourceIndex(0) -2 >Emitted(13, 18) Source(7, 22) + SourceIndex(0) -3 >Emitted(13, 26) Source(9, 2) + SourceIndex(0) -4 >Emitted(13, 27) Source(9, 2) + SourceIndex(0) ---- ->>>}); ->>>//# sourceMappingURL=m2.js.map=================================================================== JsFile: outAndOutDirFile.js mapUrl: outAndOutDirFile.js.map sourceRoot: http://typescript.codeplex.com/ diff --git a/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/outdir/outAndOutDirFolder/ref/m2.d.ts b/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/outdir/outAndOutDirFolder/ref/m2.d.ts deleted file mode 100644 index c09a3c0c32a..00000000000 --- a/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/outdir/outAndOutDirFolder/ref/m2.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -export declare var m2_a1: number; -export declare class m2_c1 { - m2_c1_p1: number; -} -export declare var m2_instance1: m2_c1; -export declare function m2_f1(): m2_c1; diff --git a/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/outdir/outAndOutDirFolder/ref/m2.js b/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/outdir/outAndOutDirFolder/ref/m2.js deleted file mode 100644 index ec0a73b5af8..00000000000 --- a/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/outdir/outAndOutDirFolder/ref/m2.js +++ /dev/null @@ -1,13 +0,0 @@ -exports.m2_a1 = 10; -var m2_c1 = (function () { - function m2_c1() { - } - return m2_c1; -})(); -exports.m2_c1 = m2_c1; -exports.m2_instance1 = new m2_c1(); -function m2_f1() { - return exports.m2_instance1; -} -exports.m2_f1 = m2_f1; -//# sourceMappingURL=m2.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/outdir/outAndOutDirFolder/ref/m2.js.map b/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/outdir/outAndOutDirFolder/ref/m2.js.map deleted file mode 100644 index 0ce68e169af..00000000000 --- a/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/outdir/outAndOutDirFolder/ref/m2.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"m2.js","sourceRoot":"http://typescript.codeplex.com/","sources":["ref/m2.ts"],"names":["m2_c1","m2_c1.constructor","m2_f1"],"mappings":"AAAW,aAAK,GAAG,EAAE,CAAC;AACtB;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAFY,aAAK,QAEjB,CAAA;AAEU,oBAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACIE,MAAMA,CAACA,oBAAYA,CAACA;AACxBA,CAACA;AAFe,aAAK,QAEpB,CAAA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/sourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory.json b/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/sourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory.json index b6ef6b5bd51..e165908b72c 100644 --- a/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/sourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory.json +++ b/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/sourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory.json @@ -17,9 +17,6 @@ "test.ts" ], "emittedFiles": [ - "outdir/outAndOutDirFolder/ref/m2.js.map", - "outdir/outAndOutDirFolder/ref/m2.js", - "outdir/outAndOutDirFolder/ref/m2.d.ts", "bin/outAndOutDirFile.js.map", "bin/outAndOutDirFile.js", "bin/outAndOutDirFile.d.ts" diff --git a/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/sourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory.sourcemap.txt b/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/sourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory.sourcemap.txt index 568c310918f..c8507ca7df8 100644 --- a/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/sourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory.sourcemap.txt +++ b/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/sourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory.sourcemap.txt @@ -1,175 +1,4 @@ =================================================================== -JsFile: m2.js -mapUrl: m2.js.map -sourceRoot: http://typescript.codeplex.com/ -sources: ref/m2.ts -=================================================================== -------------------------------------------------------------------- -emittedFile:outdir/outAndOutDirFolder/ref/m2.js -sourceFile:ref/m2.ts -------------------------------------------------------------------- ->>>exports.m2_a1 = 10; -1 > -2 >^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^-> -1 >export var -2 >m2_a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(1, 1) Source(1, 12) + SourceIndex(0) -2 >Emitted(1, 14) Source(1, 17) + SourceIndex(0) -3 >Emitted(1, 17) Source(1, 20) + SourceIndex(0) -4 >Emitted(1, 19) Source(1, 22) + SourceIndex(0) -5 >Emitted(1, 20) Source(1, 23) + SourceIndex(0) ---- ->>>var m2_c1 = (function () { -1-> -2 >^^^^^^^^^^^^^^^^^^^^^^^-> -1-> - > -1->Emitted(2, 1) Source(2, 1) + SourceIndex(0) ---- ->>> function m2_c1() { -1->^^^^ -2 > ^^-> -1-> -1->Emitted(3, 5) Source(2, 1) + SourceIndex(0) name (m2_c1) ---- ->>> } -1->^^^^ -2 > ^ -3 > ^^^^^^^^^^^^^-> -1->export class m2_c1 { - > public m2_c1_p1: number; - > -2 > } -1->Emitted(4, 5) Source(4, 1) + SourceIndex(0) name (m2_c1.constructor) -2 >Emitted(4, 6) Source(4, 2) + SourceIndex(0) name (m2_c1.constructor) ---- ->>> return m2_c1; -1->^^^^ -2 > ^^^^^^^^^^^^ -1-> -2 > } -1->Emitted(5, 5) Source(4, 1) + SourceIndex(0) name (m2_c1) -2 >Emitted(5, 17) Source(4, 2) + SourceIndex(0) name (m2_c1) ---- ->>>})(); -1 > -2 >^ -3 > -4 > ^^^^ -5 > ^^^^^^^^^^^^^^^^^^-> -1 > -2 >} -3 > -4 > export class m2_c1 { - > public m2_c1_p1: number; - > } -1 >Emitted(6, 1) Source(4, 1) + SourceIndex(0) name (m2_c1) -2 >Emitted(6, 2) Source(4, 2) + SourceIndex(0) name (m2_c1) -3 >Emitted(6, 2) Source(2, 1) + SourceIndex(0) -4 >Emitted(6, 6) Source(4, 2) + SourceIndex(0) ---- ->>>exports.m2_c1 = m2_c1; -1-> -2 >^^^^^^^^^^^^^ -3 > ^^^^^^^^ -4 > ^ -5 > ^^^^^^^^^^^^^^-> -1-> -2 >m2_c1 -3 > { - > public m2_c1_p1: number; - > } -4 > -1->Emitted(7, 1) Source(2, 14) + SourceIndex(0) -2 >Emitted(7, 14) Source(2, 19) + SourceIndex(0) -3 >Emitted(7, 22) Source(4, 2) + SourceIndex(0) -4 >Emitted(7, 23) Source(4, 2) + SourceIndex(0) ---- ->>>exports.m2_instance1 = new m2_c1(); -1-> -2 >^^^^^^^^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^^^ -5 > ^^^^^ -6 > ^^ -7 > ^ -1-> - > - >export var -2 >m2_instance1 -3 > = -4 > new -5 > m2_c1 -6 > () -7 > ; -1->Emitted(8, 1) Source(6, 12) + SourceIndex(0) -2 >Emitted(8, 21) Source(6, 24) + SourceIndex(0) -3 >Emitted(8, 24) Source(6, 27) + SourceIndex(0) -4 >Emitted(8, 28) Source(6, 31) + SourceIndex(0) -5 >Emitted(8, 33) Source(6, 36) + SourceIndex(0) -6 >Emitted(8, 35) Source(6, 38) + SourceIndex(0) -7 >Emitted(8, 36) Source(6, 39) + SourceIndex(0) ---- ->>>function m2_f1() { -1 > -2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -1 >Emitted(9, 1) Source(7, 1) + SourceIndex(0) ---- ->>> return exports.m2_instance1; -1->^^^^ -2 > ^^^^^^ -3 > ^ -4 > ^^^^^^^^^^^^^^^^^^^^ -5 > ^ -1->export function m2_f1() { - > -2 > return -3 > -4 > m2_instance1 -5 > ; -1->Emitted(10, 5) Source(8, 5) + SourceIndex(0) name (m2_f1) -2 >Emitted(10, 11) Source(8, 11) + SourceIndex(0) name (m2_f1) -3 >Emitted(10, 12) Source(8, 12) + SourceIndex(0) name (m2_f1) -4 >Emitted(10, 32) Source(8, 24) + SourceIndex(0) name (m2_f1) -5 >Emitted(10, 33) Source(8, 25) + SourceIndex(0) name (m2_f1) ---- ->>>} -1 > -2 >^ -3 > ^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -2 >} -1 >Emitted(11, 1) Source(9, 1) + SourceIndex(0) name (m2_f1) -2 >Emitted(11, 2) Source(9, 2) + SourceIndex(0) name (m2_f1) ---- ->>>exports.m2_f1 = m2_f1; -1-> -2 >^^^^^^^^^^^^^ -3 > ^^^^^^^^ -4 > ^ -5 > ^^^^^^^-> -1-> -2 >m2_f1 -3 > () { - > return m2_instance1; - > } -4 > -1->Emitted(12, 1) Source(7, 17) + SourceIndex(0) -2 >Emitted(12, 14) Source(7, 22) + SourceIndex(0) -3 >Emitted(12, 22) Source(9, 2) + SourceIndex(0) -4 >Emitted(12, 23) Source(9, 2) + SourceIndex(0) ---- ->>>//# sourceMappingURL=m2.js.map=================================================================== JsFile: outAndOutDirFile.js mapUrl: outAndOutDirFile.js.map sourceRoot: http://typescript.codeplex.com/ diff --git a/tests/baselines/reference/project/sourcerootUrlModuleMultifolderSpecifyOutputFile/amd/diskFile0.js.map b/tests/baselines/reference/project/sourcerootUrlModuleMultifolderSpecifyOutputFile/amd/diskFile0.js.map deleted file mode 100644 index 3b00d82ab66..00000000000 --- a/tests/baselines/reference/project/sourcerootUrlModuleMultifolderSpecifyOutputFile/amd/diskFile0.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"m2.js","sourceRoot":"http://typescript.codeplex.com/","sources":["outputdir_module_multifolder_ref/m2.ts"],"names":["m2_c1","m2_c1.constructor","m2_f1"],"mappings":";IAAW,aAAK,GAAG,EAAE,CAAC;IACtB;QAAAA;QAEAC,CAACA;QAADD,YAACA;IAADA,CAACA,AAFD,IAEC;IAFY,aAAK,QAEjB,CAAA;IAEU,oBAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACIE,MAAMA,CAACA,oBAAYA,CAACA;IACxBA,CAACA;IAFe,aAAK,QAEpB,CAAA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcerootUrlModuleMultifolderSpecifyOutputFile/amd/diskFile1.js b/tests/baselines/reference/project/sourcerootUrlModuleMultifolderSpecifyOutputFile/amd/diskFile1.js deleted file mode 100644 index 144ad24e2de..00000000000 --- a/tests/baselines/reference/project/sourcerootUrlModuleMultifolderSpecifyOutputFile/amd/diskFile1.js +++ /dev/null @@ -1,15 +0,0 @@ -define(["require", "exports"], function (require, exports) { - exports.m2_a1 = 10; - var m2_c1 = (function () { - function m2_c1() { - } - return m2_c1; - })(); - exports.m2_c1 = m2_c1; - exports.m2_instance1 = new m2_c1(); - function m2_f1() { - return exports.m2_instance1; - } - exports.m2_f1 = m2_f1; -}); -//# sourceMappingURL=m2.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcerootUrlModuleMultifolderSpecifyOutputFile/amd/diskFile2.d.ts b/tests/baselines/reference/project/sourcerootUrlModuleMultifolderSpecifyOutputFile/amd/diskFile2.d.ts deleted file mode 100644 index c09a3c0c32a..00000000000 --- a/tests/baselines/reference/project/sourcerootUrlModuleMultifolderSpecifyOutputFile/amd/diskFile2.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -export declare var m2_a1: number; -export declare class m2_c1 { - m2_c1_p1: number; -} -export declare var m2_instance1: m2_c1; -export declare function m2_f1(): m2_c1; diff --git a/tests/baselines/reference/project/sourcerootUrlModuleMultifolderSpecifyOutputFile/amd/ref/m1.d.ts b/tests/baselines/reference/project/sourcerootUrlModuleMultifolderSpecifyOutputFile/amd/ref/m1.d.ts deleted file mode 100644 index 4a53b24b156..00000000000 --- a/tests/baselines/reference/project/sourcerootUrlModuleMultifolderSpecifyOutputFile/amd/ref/m1.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -export declare var m1_a1: number; -export declare class m1_c1 { - m1_c1_p1: number; -} -export declare var m1_instance1: m1_c1; -export declare function m1_f1(): m1_c1; diff --git a/tests/baselines/reference/project/sourcerootUrlModuleMultifolderSpecifyOutputFile/amd/ref/m1.js b/tests/baselines/reference/project/sourcerootUrlModuleMultifolderSpecifyOutputFile/amd/ref/m1.js deleted file mode 100644 index bbaba444ba2..00000000000 --- a/tests/baselines/reference/project/sourcerootUrlModuleMultifolderSpecifyOutputFile/amd/ref/m1.js +++ /dev/null @@ -1,15 +0,0 @@ -define(["require", "exports"], function (require, exports) { - exports.m1_a1 = 10; - var m1_c1 = (function () { - function m1_c1() { - } - return m1_c1; - })(); - exports.m1_c1 = m1_c1; - exports.m1_instance1 = new m1_c1(); - function m1_f1() { - return exports.m1_instance1; - } - exports.m1_f1 = m1_f1; -}); -//# sourceMappingURL=m1.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcerootUrlModuleMultifolderSpecifyOutputFile/amd/ref/m1.js.map b/tests/baselines/reference/project/sourcerootUrlModuleMultifolderSpecifyOutputFile/amd/ref/m1.js.map deleted file mode 100644 index 8c257bd1111..00000000000 --- a/tests/baselines/reference/project/sourcerootUrlModuleMultifolderSpecifyOutputFile/amd/ref/m1.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"m1.js","sourceRoot":"http://typescript.codeplex.com/","sources":["outputdir_module_multifolder/ref/m1.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1"],"mappings":";IAAW,aAAK,GAAG,EAAE,CAAC;IACtB;QAAAA;QAEAC,CAACA;QAADD,YAACA;IAADA,CAACA,AAFD,IAEC;IAFY,aAAK,QAEjB,CAAA;IAEU,oBAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACIE,MAAMA,CAACA,oBAAYA,CAACA;IACxBA,CAACA;IAFe,aAAK,QAEpB,CAAA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcerootUrlModuleMultifolderSpecifyOutputFile/amd/sourcerootUrlModuleMultifolderSpecifyOutputFile.json b/tests/baselines/reference/project/sourcerootUrlModuleMultifolderSpecifyOutputFile/amd/sourcerootUrlModuleMultifolderSpecifyOutputFile.json index cc2a6c9b1aa..27485e45ad9 100644 --- a/tests/baselines/reference/project/sourcerootUrlModuleMultifolderSpecifyOutputFile/amd/sourcerootUrlModuleMultifolderSpecifyOutputFile.json +++ b/tests/baselines/reference/project/sourcerootUrlModuleMultifolderSpecifyOutputFile/amd/sourcerootUrlModuleMultifolderSpecifyOutputFile.json @@ -16,15 +16,6 @@ "test.ts" ], "emittedFiles": [ - "ref/m1.js.map", - "ref/m1.js", - "ref/m1.d.ts", - "../outputdir_module_multifolder_ref/m2.js.map", - "../outputdir_module_multifolder_ref/m2.js", - "../outputdir_module_multifolder_ref/m2.d.ts", - "test.js.map", - "test.js", - "test.d.ts", "bin/test.js.map", "bin/test.js", "bin/test.d.ts" diff --git a/tests/baselines/reference/project/sourcerootUrlModuleMultifolderSpecifyOutputFile/amd/sourcerootUrlModuleMultifolderSpecifyOutputFile.sourcemap.txt b/tests/baselines/reference/project/sourcerootUrlModuleMultifolderSpecifyOutputFile/amd/sourcerootUrlModuleMultifolderSpecifyOutputFile.sourcemap.txt index 088f581289a..d2331ef3579 100644 --- a/tests/baselines/reference/project/sourcerootUrlModuleMultifolderSpecifyOutputFile/amd/sourcerootUrlModuleMultifolderSpecifyOutputFile.sourcemap.txt +++ b/tests/baselines/reference/project/sourcerootUrlModuleMultifolderSpecifyOutputFile/amd/sourcerootUrlModuleMultifolderSpecifyOutputFile.sourcemap.txt @@ -1,573 +1,4 @@ =================================================================== -JsFile: m1.js -mapUrl: m1.js.map -sourceRoot: http://typescript.codeplex.com/ -sources: outputdir_module_multifolder/ref/m1.ts -=================================================================== -------------------------------------------------------------------- -emittedFile:ref/m1.js -sourceFile:outputdir_module_multifolder/ref/m1.ts -------------------------------------------------------------------- ->>>define(["require", "exports"], function (require, exports) { ->>> exports.m1_a1 = 10; -1 >^^^^ -2 > ^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^-> -1 >export var -2 > m1_a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(2, 5) Source(1, 12) + SourceIndex(0) -2 >Emitted(2, 18) Source(1, 17) + SourceIndex(0) -3 >Emitted(2, 21) Source(1, 20) + SourceIndex(0) -4 >Emitted(2, 23) Source(1, 22) + SourceIndex(0) -5 >Emitted(2, 24) Source(1, 23) + SourceIndex(0) ---- ->>> var m1_c1 = (function () { -1->^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^^^^-> -1-> - > -1->Emitted(3, 5) Source(2, 1) + SourceIndex(0) ---- ->>> function m1_c1() { -1->^^^^^^^^ -2 > ^^-> -1-> -1->Emitted(4, 9) Source(2, 1) + SourceIndex(0) name (m1_c1) ---- ->>> } -1->^^^^^^^^ -2 > ^ -3 > ^^^^^^^^^^^^^-> -1->export class m1_c1 { - > public m1_c1_p1: number; - > -2 > } -1->Emitted(5, 9) Source(4, 1) + SourceIndex(0) name (m1_c1.constructor) -2 >Emitted(5, 10) Source(4, 2) + SourceIndex(0) name (m1_c1.constructor) ---- ->>> return m1_c1; -1->^^^^^^^^ -2 > ^^^^^^^^^^^^ -1-> -2 > } -1->Emitted(6, 9) Source(4, 1) + SourceIndex(0) name (m1_c1) -2 >Emitted(6, 21) Source(4, 2) + SourceIndex(0) name (m1_c1) ---- ->>> })(); -1 >^^^^ -2 > ^ -3 > -4 > ^^^^ -5 > ^^^^^^^^^^^^^^^^^^-> -1 > -2 > } -3 > -4 > export class m1_c1 { - > public m1_c1_p1: number; - > } -1 >Emitted(7, 5) Source(4, 1) + SourceIndex(0) name (m1_c1) -2 >Emitted(7, 6) Source(4, 2) + SourceIndex(0) name (m1_c1) -3 >Emitted(7, 6) Source(2, 1) + SourceIndex(0) -4 >Emitted(7, 10) Source(4, 2) + SourceIndex(0) ---- ->>> exports.m1_c1 = m1_c1; -1->^^^^ -2 > ^^^^^^^^^^^^^ -3 > ^^^^^^^^ -4 > ^ -5 > ^^^^^^^^^^^^^^-> -1-> -2 > m1_c1 -3 > { - > public m1_c1_p1: number; - > } -4 > -1->Emitted(8, 5) Source(2, 14) + SourceIndex(0) -2 >Emitted(8, 18) Source(2, 19) + SourceIndex(0) -3 >Emitted(8, 26) Source(4, 2) + SourceIndex(0) -4 >Emitted(8, 27) Source(4, 2) + SourceIndex(0) ---- ->>> exports.m1_instance1 = new m1_c1(); -1->^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^^^ -5 > ^^^^^ -6 > ^^ -7 > ^ -1-> - > - >export var -2 > m1_instance1 -3 > = -4 > new -5 > m1_c1 -6 > () -7 > ; -1->Emitted(9, 5) Source(6, 12) + SourceIndex(0) -2 >Emitted(9, 25) Source(6, 24) + SourceIndex(0) -3 >Emitted(9, 28) Source(6, 27) + SourceIndex(0) -4 >Emitted(9, 32) Source(6, 31) + SourceIndex(0) -5 >Emitted(9, 37) Source(6, 36) + SourceIndex(0) -6 >Emitted(9, 39) Source(6, 38) + SourceIndex(0) -7 >Emitted(9, 40) Source(6, 39) + SourceIndex(0) ---- ->>> function m1_f1() { -1 >^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -1 >Emitted(10, 5) Source(7, 1) + SourceIndex(0) ---- ->>> return exports.m1_instance1; -1->^^^^^^^^ -2 > ^^^^^^ -3 > ^ -4 > ^^^^^^^^^^^^^^^^^^^^ -5 > ^ -1->export function m1_f1() { - > -2 > return -3 > -4 > m1_instance1 -5 > ; -1->Emitted(11, 9) Source(8, 5) + SourceIndex(0) name (m1_f1) -2 >Emitted(11, 15) Source(8, 11) + SourceIndex(0) name (m1_f1) -3 >Emitted(11, 16) Source(8, 12) + SourceIndex(0) name (m1_f1) -4 >Emitted(11, 36) Source(8, 24) + SourceIndex(0) name (m1_f1) -5 >Emitted(11, 37) Source(8, 25) + SourceIndex(0) name (m1_f1) ---- ->>> } -1 >^^^^ -2 > ^ -3 > ^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -2 > } -1 >Emitted(12, 5) Source(9, 1) + SourceIndex(0) name (m1_f1) -2 >Emitted(12, 6) Source(9, 2) + SourceIndex(0) name (m1_f1) ---- ->>> exports.m1_f1 = m1_f1; -1->^^^^ -2 > ^^^^^^^^^^^^^ -3 > ^^^^^^^^ -4 > ^ -1-> -2 > m1_f1 -3 > () { - > return m1_instance1; - > } -4 > -1->Emitted(13, 5) Source(7, 17) + SourceIndex(0) -2 >Emitted(13, 18) Source(7, 22) + SourceIndex(0) -3 >Emitted(13, 26) Source(9, 2) + SourceIndex(0) -4 >Emitted(13, 27) Source(9, 2) + SourceIndex(0) ---- ->>>}); ->>>//# sourceMappingURL=m1.js.map=================================================================== -JsFile: m2.js -mapUrl: m2.js.map -sourceRoot: http://typescript.codeplex.com/ -sources: outputdir_module_multifolder_ref/m2.ts -=================================================================== -------------------------------------------------------------------- -emittedFile:diskFile1.js -sourceFile:outputdir_module_multifolder_ref/m2.ts -------------------------------------------------------------------- ->>>define(["require", "exports"], function (require, exports) { ->>> exports.m2_a1 = 10; -1 >^^^^ -2 > ^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^-> -1 >export var -2 > m2_a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(2, 5) Source(1, 12) + SourceIndex(0) -2 >Emitted(2, 18) Source(1, 17) + SourceIndex(0) -3 >Emitted(2, 21) Source(1, 20) + SourceIndex(0) -4 >Emitted(2, 23) Source(1, 22) + SourceIndex(0) -5 >Emitted(2, 24) Source(1, 23) + SourceIndex(0) ---- ->>> var m2_c1 = (function () { -1->^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^^^^-> -1-> - > -1->Emitted(3, 5) Source(2, 1) + SourceIndex(0) ---- ->>> function m2_c1() { -1->^^^^^^^^ -2 > ^^-> -1-> -1->Emitted(4, 9) Source(2, 1) + SourceIndex(0) name (m2_c1) ---- ->>> } -1->^^^^^^^^ -2 > ^ -3 > ^^^^^^^^^^^^^-> -1->export class m2_c1 { - > public m2_c1_p1: number; - > -2 > } -1->Emitted(5, 9) Source(4, 1) + SourceIndex(0) name (m2_c1.constructor) -2 >Emitted(5, 10) Source(4, 2) + SourceIndex(0) name (m2_c1.constructor) ---- ->>> return m2_c1; -1->^^^^^^^^ -2 > ^^^^^^^^^^^^ -1-> -2 > } -1->Emitted(6, 9) Source(4, 1) + SourceIndex(0) name (m2_c1) -2 >Emitted(6, 21) Source(4, 2) + SourceIndex(0) name (m2_c1) ---- ->>> })(); -1 >^^^^ -2 > ^ -3 > -4 > ^^^^ -5 > ^^^^^^^^^^^^^^^^^^-> -1 > -2 > } -3 > -4 > export class m2_c1 { - > public m2_c1_p1: number; - > } -1 >Emitted(7, 5) Source(4, 1) + SourceIndex(0) name (m2_c1) -2 >Emitted(7, 6) Source(4, 2) + SourceIndex(0) name (m2_c1) -3 >Emitted(7, 6) Source(2, 1) + SourceIndex(0) -4 >Emitted(7, 10) Source(4, 2) + SourceIndex(0) ---- ->>> exports.m2_c1 = m2_c1; -1->^^^^ -2 > ^^^^^^^^^^^^^ -3 > ^^^^^^^^ -4 > ^ -5 > ^^^^^^^^^^^^^^-> -1-> -2 > m2_c1 -3 > { - > public m2_c1_p1: number; - > } -4 > -1->Emitted(8, 5) Source(2, 14) + SourceIndex(0) -2 >Emitted(8, 18) Source(2, 19) + SourceIndex(0) -3 >Emitted(8, 26) Source(4, 2) + SourceIndex(0) -4 >Emitted(8, 27) Source(4, 2) + SourceIndex(0) ---- ->>> exports.m2_instance1 = new m2_c1(); -1->^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^^^ -5 > ^^^^^ -6 > ^^ -7 > ^ -1-> - > - >export var -2 > m2_instance1 -3 > = -4 > new -5 > m2_c1 -6 > () -7 > ; -1->Emitted(9, 5) Source(6, 12) + SourceIndex(0) -2 >Emitted(9, 25) Source(6, 24) + SourceIndex(0) -3 >Emitted(9, 28) Source(6, 27) + SourceIndex(0) -4 >Emitted(9, 32) Source(6, 31) + SourceIndex(0) -5 >Emitted(9, 37) Source(6, 36) + SourceIndex(0) -6 >Emitted(9, 39) Source(6, 38) + SourceIndex(0) -7 >Emitted(9, 40) Source(6, 39) + SourceIndex(0) ---- ->>> function m2_f1() { -1 >^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -1 >Emitted(10, 5) Source(7, 1) + SourceIndex(0) ---- ->>> return exports.m2_instance1; -1->^^^^^^^^ -2 > ^^^^^^ -3 > ^ -4 > ^^^^^^^^^^^^^^^^^^^^ -5 > ^ -1->export function m2_f1() { - > -2 > return -3 > -4 > m2_instance1 -5 > ; -1->Emitted(11, 9) Source(8, 5) + SourceIndex(0) name (m2_f1) -2 >Emitted(11, 15) Source(8, 11) + SourceIndex(0) name (m2_f1) -3 >Emitted(11, 16) Source(8, 12) + SourceIndex(0) name (m2_f1) -4 >Emitted(11, 36) Source(8, 24) + SourceIndex(0) name (m2_f1) -5 >Emitted(11, 37) Source(8, 25) + SourceIndex(0) name (m2_f1) ---- ->>> } -1 >^^^^ -2 > ^ -3 > ^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -2 > } -1 >Emitted(12, 5) Source(9, 1) + SourceIndex(0) name (m2_f1) -2 >Emitted(12, 6) Source(9, 2) + SourceIndex(0) name (m2_f1) ---- ->>> exports.m2_f1 = m2_f1; -1->^^^^ -2 > ^^^^^^^^^^^^^ -3 > ^^^^^^^^ -4 > ^ -1-> -2 > m2_f1 -3 > () { - > return m2_instance1; - > } -4 > -1->Emitted(13, 5) Source(7, 17) + SourceIndex(0) -2 >Emitted(13, 18) Source(7, 22) + SourceIndex(0) -3 >Emitted(13, 26) Source(9, 2) + SourceIndex(0) -4 >Emitted(13, 27) Source(9, 2) + SourceIndex(0) ---- ->>>}); ->>>//# sourceMappingURL=m2.js.map=================================================================== -JsFile: test.js -mapUrl: test.js.map -sourceRoot: http://typescript.codeplex.com/ -sources: outputdir_module_multifolder/test.ts -=================================================================== -------------------------------------------------------------------- -emittedFile:test.js -sourceFile:outputdir_module_multifolder/test.ts -------------------------------------------------------------------- ->>>define(["require", "exports", "ref/m1", "../outputdir_module_multifolder_ref/m2"], function (require, exports, m1, m2) { ->>> exports.a1 = 10; -1 >^^^^ -2 > ^^^^^^^^^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^-> -1 >import m1 = require("ref/m1"); - >import m2 = require("../outputdir_module_multifolder_ref/m2"); - >export var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(2, 5) Source(3, 12) + SourceIndex(0) -2 >Emitted(2, 15) Source(3, 14) + SourceIndex(0) -3 >Emitted(2, 18) Source(3, 17) + SourceIndex(0) -4 >Emitted(2, 20) Source(3, 19) + SourceIndex(0) -5 >Emitted(2, 21) Source(3, 20) + SourceIndex(0) ---- ->>> var c1 = (function () { -1->^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^-> -1-> - > -1->Emitted(3, 5) Source(4, 1) + SourceIndex(0) ---- ->>> function c1() { -1->^^^^^^^^ -2 > ^^-> -1-> -1->Emitted(4, 9) Source(4, 1) + SourceIndex(0) name (c1) ---- ->>> } -1->^^^^^^^^ -2 > ^ -3 > ^^^^^^^^^^-> -1->export class c1 { - > public p1: number; - > -2 > } -1->Emitted(5, 9) Source(6, 1) + SourceIndex(0) name (c1.constructor) -2 >Emitted(5, 10) Source(6, 2) + SourceIndex(0) name (c1.constructor) ---- ->>> return c1; -1->^^^^^^^^ -2 > ^^^^^^^^^ -1-> -2 > } -1->Emitted(6, 9) Source(6, 1) + SourceIndex(0) name (c1) -2 >Emitted(6, 18) Source(6, 2) + SourceIndex(0) name (c1) ---- ->>> })(); -1 >^^^^ -2 > ^ -3 > -4 > ^^^^ -5 > ^^^^^^^^^^^^-> -1 > -2 > } -3 > -4 > export class c1 { - > public p1: number; - > } -1 >Emitted(7, 5) Source(6, 1) + SourceIndex(0) name (c1) -2 >Emitted(7, 6) Source(6, 2) + SourceIndex(0) name (c1) -3 >Emitted(7, 6) Source(4, 1) + SourceIndex(0) -4 >Emitted(7, 10) Source(6, 2) + SourceIndex(0) ---- ->>> exports.c1 = c1; -1->^^^^ -2 > ^^^^^^^^^^ -3 > ^^^^^ -4 > ^ -5 > ^^^^^^^^^^^^^^-> -1-> -2 > c1 -3 > { - > public p1: number; - > } -4 > -1->Emitted(8, 5) Source(4, 14) + SourceIndex(0) -2 >Emitted(8, 15) Source(4, 16) + SourceIndex(0) -3 >Emitted(8, 20) Source(6, 2) + SourceIndex(0) -4 >Emitted(8, 21) Source(6, 2) + SourceIndex(0) ---- ->>> exports.instance1 = new c1(); -1->^^^^ -2 > ^^^^^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^^^ -5 > ^^ -6 > ^^ -7 > ^ -1-> - > - >export var -2 > instance1 -3 > = -4 > new -5 > c1 -6 > () -7 > ; -1->Emitted(9, 5) Source(8, 12) + SourceIndex(0) -2 >Emitted(9, 22) Source(8, 21) + SourceIndex(0) -3 >Emitted(9, 25) Source(8, 24) + SourceIndex(0) -4 >Emitted(9, 29) Source(8, 28) + SourceIndex(0) -5 >Emitted(9, 31) Source(8, 30) + SourceIndex(0) -6 >Emitted(9, 33) Source(8, 32) + SourceIndex(0) -7 >Emitted(9, 34) Source(8, 33) + SourceIndex(0) ---- ->>> function f1() { -1 >^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -1 >Emitted(10, 5) Source(9, 1) + SourceIndex(0) ---- ->>> return exports.instance1; -1->^^^^^^^^ -2 > ^^^^^^ -3 > ^ -4 > ^^^^^^^^^^^^^^^^^ -5 > ^ -1->export function f1() { - > -2 > return -3 > -4 > instance1 -5 > ; -1->Emitted(11, 9) Source(10, 5) + SourceIndex(0) name (f1) -2 >Emitted(11, 15) Source(10, 11) + SourceIndex(0) name (f1) -3 >Emitted(11, 16) Source(10, 12) + SourceIndex(0) name (f1) -4 >Emitted(11, 33) Source(10, 21) + SourceIndex(0) name (f1) -5 >Emitted(11, 34) Source(10, 22) + SourceIndex(0) name (f1) ---- ->>> } -1 >^^^^ -2 > ^ -3 > ^^^^^^^^^^^^^^^^-> -1 > - > -2 > } -1 >Emitted(12, 5) Source(11, 1) + SourceIndex(0) name (f1) -2 >Emitted(12, 6) Source(11, 2) + SourceIndex(0) name (f1) ---- ->>> exports.f1 = f1; -1->^^^^ -2 > ^^^^^^^^^^ -3 > ^^^^^ -4 > ^ -5 > ^^^^^^^-> -1-> -2 > f1 -3 > () { - > return instance1; - > } -4 > -1->Emitted(13, 5) Source(9, 17) + SourceIndex(0) -2 >Emitted(13, 15) Source(9, 19) + SourceIndex(0) -3 >Emitted(13, 20) Source(11, 2) + SourceIndex(0) -4 >Emitted(13, 21) Source(11, 2) + SourceIndex(0) ---- ->>> exports.a2 = m1.m1_c1; -1->^^^^ -2 > ^^^^^^^^^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^ -7 > ^ -8 > ^-> -1-> - > - >export var -2 > a2 -3 > = -4 > m1 -5 > . -6 > m1_c1 -7 > ; -1->Emitted(14, 5) Source(13, 12) + SourceIndex(0) -2 >Emitted(14, 15) Source(13, 14) + SourceIndex(0) -3 >Emitted(14, 18) Source(13, 17) + SourceIndex(0) -4 >Emitted(14, 20) Source(13, 19) + SourceIndex(0) -5 >Emitted(14, 21) Source(13, 20) + SourceIndex(0) -6 >Emitted(14, 26) Source(13, 25) + SourceIndex(0) -7 >Emitted(14, 27) Source(13, 26) + SourceIndex(0) ---- ->>> exports.a3 = m2.m2_c1; -1->^^^^ -2 > ^^^^^^^^^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^ -7 > ^ -1-> - >export var -2 > a3 -3 > = -4 > m2 -5 > . -6 > m2_c1 -7 > ; -1->Emitted(15, 5) Source(14, 12) + SourceIndex(0) -2 >Emitted(15, 15) Source(14, 14) + SourceIndex(0) -3 >Emitted(15, 18) Source(14, 17) + SourceIndex(0) -4 >Emitted(15, 20) Source(14, 19) + SourceIndex(0) -5 >Emitted(15, 21) Source(14, 20) + SourceIndex(0) -6 >Emitted(15, 26) Source(14, 25) + SourceIndex(0) -7 >Emitted(15, 27) Source(14, 26) + SourceIndex(0) ---- ->>>}); ->>>//# sourceMappingURL=test.js.map=================================================================== JsFile: test.js mapUrl: test.js.map sourceRoot: http://typescript.codeplex.com/ diff --git a/tests/baselines/reference/project/sourcerootUrlModuleMultifolderSpecifyOutputFile/amd/test.d.ts b/tests/baselines/reference/project/sourcerootUrlModuleMultifolderSpecifyOutputFile/amd/test.d.ts deleted file mode 100644 index 4afd4e69f2d..00000000000 --- a/tests/baselines/reference/project/sourcerootUrlModuleMultifolderSpecifyOutputFile/amd/test.d.ts +++ /dev/null @@ -1,10 +0,0 @@ -import m1 = require("ref/m1"); -import m2 = require("../outputdir_module_multifolder_ref/m2"); -export declare var a1: number; -export declare class c1 { - p1: number; -} -export declare var instance1: c1; -export declare function f1(): c1; -export declare var a2: typeof m1.m1_c1; -export declare var a3: typeof m2.m2_c1; diff --git a/tests/baselines/reference/project/sourcerootUrlModuleMultifolderSpecifyOutputFile/amd/test.js b/tests/baselines/reference/project/sourcerootUrlModuleMultifolderSpecifyOutputFile/amd/test.js deleted file mode 100644 index 5cca04a0f25..00000000000 --- a/tests/baselines/reference/project/sourcerootUrlModuleMultifolderSpecifyOutputFile/amd/test.js +++ /dev/null @@ -1,17 +0,0 @@ -define(["require", "exports", "ref/m1", "../outputdir_module_multifolder_ref/m2"], function (require, exports, m1, m2) { - exports.a1 = 10; - var c1 = (function () { - function c1() { - } - return c1; - })(); - exports.c1 = c1; - exports.instance1 = new c1(); - function f1() { - return exports.instance1; - } - exports.f1 = f1; - exports.a2 = m1.m1_c1; - exports.a3 = m2.m2_c1; -}); -//# sourceMappingURL=test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcerootUrlModuleMultifolderSpecifyOutputFile/amd/test.js.map b/tests/baselines/reference/project/sourcerootUrlModuleMultifolderSpecifyOutputFile/amd/test.js.map deleted file mode 100644 index 8612cd0d108..00000000000 --- a/tests/baselines/reference/project/sourcerootUrlModuleMultifolderSpecifyOutputFile/amd/test.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"test.js","sourceRoot":"http://typescript.codeplex.com/","sources":["outputdir_module_multifolder/test.ts"],"names":["c1","c1.constructor","f1"],"mappings":";IAEW,UAAE,GAAG,EAAE,CAAC;IACnB;QAAAA;QAEAC,CAACA;QAADD,SAACA;IAADA,CAACA,AAFD,IAEC;IAFY,UAAE,KAEd,CAAA;IAEU,iBAAS,GAAG,IAAI,EAAE,EAAE,CAAC;IAChC;QACIE,MAAMA,CAACA,iBAASA,CAACA;IACrBA,CAACA;IAFe,UAAE,KAEjB,CAAA;IAEU,UAAE,GAAG,EAAE,CAAC,KAAK,CAAC;IACd,UAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcerootUrlModuleMultifolderSpecifyOutputFile/node/diskFile0.js.map b/tests/baselines/reference/project/sourcerootUrlModuleMultifolderSpecifyOutputFile/node/diskFile0.js.map deleted file mode 100644 index 058e405b606..00000000000 --- a/tests/baselines/reference/project/sourcerootUrlModuleMultifolderSpecifyOutputFile/node/diskFile0.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"m2.js","sourceRoot":"http://typescript.codeplex.com/","sources":["outputdir_module_multifolder_ref/m2.ts"],"names":["m2_c1","m2_c1.constructor","m2_f1"],"mappings":"AAAW,aAAK,GAAG,EAAE,CAAC;AACtB;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAFY,aAAK,QAEjB,CAAA;AAEU,oBAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACIE,MAAMA,CAACA,oBAAYA,CAACA;AACxBA,CAACA;AAFe,aAAK,QAEpB,CAAA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcerootUrlModuleMultifolderSpecifyOutputFile/node/diskFile1.js b/tests/baselines/reference/project/sourcerootUrlModuleMultifolderSpecifyOutputFile/node/diskFile1.js deleted file mode 100644 index ec0a73b5af8..00000000000 --- a/tests/baselines/reference/project/sourcerootUrlModuleMultifolderSpecifyOutputFile/node/diskFile1.js +++ /dev/null @@ -1,13 +0,0 @@ -exports.m2_a1 = 10; -var m2_c1 = (function () { - function m2_c1() { - } - return m2_c1; -})(); -exports.m2_c1 = m2_c1; -exports.m2_instance1 = new m2_c1(); -function m2_f1() { - return exports.m2_instance1; -} -exports.m2_f1 = m2_f1; -//# sourceMappingURL=m2.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcerootUrlModuleMultifolderSpecifyOutputFile/node/diskFile2.d.ts b/tests/baselines/reference/project/sourcerootUrlModuleMultifolderSpecifyOutputFile/node/diskFile2.d.ts deleted file mode 100644 index c09a3c0c32a..00000000000 --- a/tests/baselines/reference/project/sourcerootUrlModuleMultifolderSpecifyOutputFile/node/diskFile2.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -export declare var m2_a1: number; -export declare class m2_c1 { - m2_c1_p1: number; -} -export declare var m2_instance1: m2_c1; -export declare function m2_f1(): m2_c1; diff --git a/tests/baselines/reference/project/sourcerootUrlModuleMultifolderSpecifyOutputFile/node/ref/m1.d.ts b/tests/baselines/reference/project/sourcerootUrlModuleMultifolderSpecifyOutputFile/node/ref/m1.d.ts deleted file mode 100644 index 4a53b24b156..00000000000 --- a/tests/baselines/reference/project/sourcerootUrlModuleMultifolderSpecifyOutputFile/node/ref/m1.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -export declare var m1_a1: number; -export declare class m1_c1 { - m1_c1_p1: number; -} -export declare var m1_instance1: m1_c1; -export declare function m1_f1(): m1_c1; diff --git a/tests/baselines/reference/project/sourcerootUrlModuleMultifolderSpecifyOutputFile/node/ref/m1.js b/tests/baselines/reference/project/sourcerootUrlModuleMultifolderSpecifyOutputFile/node/ref/m1.js deleted file mode 100644 index 1b4470e2b37..00000000000 --- a/tests/baselines/reference/project/sourcerootUrlModuleMultifolderSpecifyOutputFile/node/ref/m1.js +++ /dev/null @@ -1,13 +0,0 @@ -exports.m1_a1 = 10; -var m1_c1 = (function () { - function m1_c1() { - } - return m1_c1; -})(); -exports.m1_c1 = m1_c1; -exports.m1_instance1 = new m1_c1(); -function m1_f1() { - return exports.m1_instance1; -} -exports.m1_f1 = m1_f1; -//# sourceMappingURL=m1.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcerootUrlModuleMultifolderSpecifyOutputFile/node/ref/m1.js.map b/tests/baselines/reference/project/sourcerootUrlModuleMultifolderSpecifyOutputFile/node/ref/m1.js.map deleted file mode 100644 index e7f54a4a2e1..00000000000 --- a/tests/baselines/reference/project/sourcerootUrlModuleMultifolderSpecifyOutputFile/node/ref/m1.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"m1.js","sourceRoot":"http://typescript.codeplex.com/","sources":["outputdir_module_multifolder/ref/m1.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1"],"mappings":"AAAW,aAAK,GAAG,EAAE,CAAC;AACtB;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAFY,aAAK,QAEjB,CAAA;AAEU,oBAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACIE,MAAMA,CAACA,oBAAYA,CAACA;AACxBA,CAACA;AAFe,aAAK,QAEpB,CAAA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcerootUrlModuleMultifolderSpecifyOutputFile/node/sourcerootUrlModuleMultifolderSpecifyOutputFile.json b/tests/baselines/reference/project/sourcerootUrlModuleMultifolderSpecifyOutputFile/node/sourcerootUrlModuleMultifolderSpecifyOutputFile.json index cc2a6c9b1aa..27485e45ad9 100644 --- a/tests/baselines/reference/project/sourcerootUrlModuleMultifolderSpecifyOutputFile/node/sourcerootUrlModuleMultifolderSpecifyOutputFile.json +++ b/tests/baselines/reference/project/sourcerootUrlModuleMultifolderSpecifyOutputFile/node/sourcerootUrlModuleMultifolderSpecifyOutputFile.json @@ -16,15 +16,6 @@ "test.ts" ], "emittedFiles": [ - "ref/m1.js.map", - "ref/m1.js", - "ref/m1.d.ts", - "../outputdir_module_multifolder_ref/m2.js.map", - "../outputdir_module_multifolder_ref/m2.js", - "../outputdir_module_multifolder_ref/m2.d.ts", - "test.js.map", - "test.js", - "test.d.ts", "bin/test.js.map", "bin/test.js", "bin/test.d.ts" diff --git a/tests/baselines/reference/project/sourcerootUrlModuleMultifolderSpecifyOutputFile/node/sourcerootUrlModuleMultifolderSpecifyOutputFile.sourcemap.txt b/tests/baselines/reference/project/sourcerootUrlModuleMultifolderSpecifyOutputFile/node/sourcerootUrlModuleMultifolderSpecifyOutputFile.sourcemap.txt index a116b6b4d78..95f7d3cee8f 100644 --- a/tests/baselines/reference/project/sourcerootUrlModuleMultifolderSpecifyOutputFile/node/sourcerootUrlModuleMultifolderSpecifyOutputFile.sourcemap.txt +++ b/tests/baselines/reference/project/sourcerootUrlModuleMultifolderSpecifyOutputFile/node/sourcerootUrlModuleMultifolderSpecifyOutputFile.sourcemap.txt @@ -1,617 +1,4 @@ =================================================================== -JsFile: m1.js -mapUrl: m1.js.map -sourceRoot: http://typescript.codeplex.com/ -sources: outputdir_module_multifolder/ref/m1.ts -=================================================================== -------------------------------------------------------------------- -emittedFile:ref/m1.js -sourceFile:outputdir_module_multifolder/ref/m1.ts -------------------------------------------------------------------- ->>>exports.m1_a1 = 10; -1 > -2 >^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^-> -1 >export var -2 >m1_a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(1, 1) Source(1, 12) + SourceIndex(0) -2 >Emitted(1, 14) Source(1, 17) + SourceIndex(0) -3 >Emitted(1, 17) Source(1, 20) + SourceIndex(0) -4 >Emitted(1, 19) Source(1, 22) + SourceIndex(0) -5 >Emitted(1, 20) Source(1, 23) + SourceIndex(0) ---- ->>>var m1_c1 = (function () { -1-> -2 >^^^^^^^^^^^^^^^^^^^^^^^-> -1-> - > -1->Emitted(2, 1) Source(2, 1) + SourceIndex(0) ---- ->>> function m1_c1() { -1->^^^^ -2 > ^^-> -1-> -1->Emitted(3, 5) Source(2, 1) + SourceIndex(0) name (m1_c1) ---- ->>> } -1->^^^^ -2 > ^ -3 > ^^^^^^^^^^^^^-> -1->export class m1_c1 { - > public m1_c1_p1: number; - > -2 > } -1->Emitted(4, 5) Source(4, 1) + SourceIndex(0) name (m1_c1.constructor) -2 >Emitted(4, 6) Source(4, 2) + SourceIndex(0) name (m1_c1.constructor) ---- ->>> return m1_c1; -1->^^^^ -2 > ^^^^^^^^^^^^ -1-> -2 > } -1->Emitted(5, 5) Source(4, 1) + SourceIndex(0) name (m1_c1) -2 >Emitted(5, 17) Source(4, 2) + SourceIndex(0) name (m1_c1) ---- ->>>})(); -1 > -2 >^ -3 > -4 > ^^^^ -5 > ^^^^^^^^^^^^^^^^^^-> -1 > -2 >} -3 > -4 > export class m1_c1 { - > public m1_c1_p1: number; - > } -1 >Emitted(6, 1) Source(4, 1) + SourceIndex(0) name (m1_c1) -2 >Emitted(6, 2) Source(4, 2) + SourceIndex(0) name (m1_c1) -3 >Emitted(6, 2) Source(2, 1) + SourceIndex(0) -4 >Emitted(6, 6) Source(4, 2) + SourceIndex(0) ---- ->>>exports.m1_c1 = m1_c1; -1-> -2 >^^^^^^^^^^^^^ -3 > ^^^^^^^^ -4 > ^ -5 > ^^^^^^^^^^^^^^-> -1-> -2 >m1_c1 -3 > { - > public m1_c1_p1: number; - > } -4 > -1->Emitted(7, 1) Source(2, 14) + SourceIndex(0) -2 >Emitted(7, 14) Source(2, 19) + SourceIndex(0) -3 >Emitted(7, 22) Source(4, 2) + SourceIndex(0) -4 >Emitted(7, 23) Source(4, 2) + SourceIndex(0) ---- ->>>exports.m1_instance1 = new m1_c1(); -1-> -2 >^^^^^^^^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^^^ -5 > ^^^^^ -6 > ^^ -7 > ^ -1-> - > - >export var -2 >m1_instance1 -3 > = -4 > new -5 > m1_c1 -6 > () -7 > ; -1->Emitted(8, 1) Source(6, 12) + SourceIndex(0) -2 >Emitted(8, 21) Source(6, 24) + SourceIndex(0) -3 >Emitted(8, 24) Source(6, 27) + SourceIndex(0) -4 >Emitted(8, 28) Source(6, 31) + SourceIndex(0) -5 >Emitted(8, 33) Source(6, 36) + SourceIndex(0) -6 >Emitted(8, 35) Source(6, 38) + SourceIndex(0) -7 >Emitted(8, 36) Source(6, 39) + SourceIndex(0) ---- ->>>function m1_f1() { -1 > -2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -1 >Emitted(9, 1) Source(7, 1) + SourceIndex(0) ---- ->>> return exports.m1_instance1; -1->^^^^ -2 > ^^^^^^ -3 > ^ -4 > ^^^^^^^^^^^^^^^^^^^^ -5 > ^ -1->export function m1_f1() { - > -2 > return -3 > -4 > m1_instance1 -5 > ; -1->Emitted(10, 5) Source(8, 5) + SourceIndex(0) name (m1_f1) -2 >Emitted(10, 11) Source(8, 11) + SourceIndex(0) name (m1_f1) -3 >Emitted(10, 12) Source(8, 12) + SourceIndex(0) name (m1_f1) -4 >Emitted(10, 32) Source(8, 24) + SourceIndex(0) name (m1_f1) -5 >Emitted(10, 33) Source(8, 25) + SourceIndex(0) name (m1_f1) ---- ->>>} -1 > -2 >^ -3 > ^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -2 >} -1 >Emitted(11, 1) Source(9, 1) + SourceIndex(0) name (m1_f1) -2 >Emitted(11, 2) Source(9, 2) + SourceIndex(0) name (m1_f1) ---- ->>>exports.m1_f1 = m1_f1; -1-> -2 >^^^^^^^^^^^^^ -3 > ^^^^^^^^ -4 > ^ -5 > ^^^^^^^-> -1-> -2 >m1_f1 -3 > () { - > return m1_instance1; - > } -4 > -1->Emitted(12, 1) Source(7, 17) + SourceIndex(0) -2 >Emitted(12, 14) Source(7, 22) + SourceIndex(0) -3 >Emitted(12, 22) Source(9, 2) + SourceIndex(0) -4 >Emitted(12, 23) Source(9, 2) + SourceIndex(0) ---- ->>>//# sourceMappingURL=m1.js.map=================================================================== -JsFile: m2.js -mapUrl: m2.js.map -sourceRoot: http://typescript.codeplex.com/ -sources: outputdir_module_multifolder_ref/m2.ts -=================================================================== -------------------------------------------------------------------- -emittedFile:diskFile1.js -sourceFile:outputdir_module_multifolder_ref/m2.ts -------------------------------------------------------------------- ->>>exports.m2_a1 = 10; -1 > -2 >^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^-> -1 >export var -2 >m2_a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(1, 1) Source(1, 12) + SourceIndex(0) -2 >Emitted(1, 14) Source(1, 17) + SourceIndex(0) -3 >Emitted(1, 17) Source(1, 20) + SourceIndex(0) -4 >Emitted(1, 19) Source(1, 22) + SourceIndex(0) -5 >Emitted(1, 20) Source(1, 23) + SourceIndex(0) ---- ->>>var m2_c1 = (function () { -1-> -2 >^^^^^^^^^^^^^^^^^^^^^^^-> -1-> - > -1->Emitted(2, 1) Source(2, 1) + SourceIndex(0) ---- ->>> function m2_c1() { -1->^^^^ -2 > ^^-> -1-> -1->Emitted(3, 5) Source(2, 1) + SourceIndex(0) name (m2_c1) ---- ->>> } -1->^^^^ -2 > ^ -3 > ^^^^^^^^^^^^^-> -1->export class m2_c1 { - > public m2_c1_p1: number; - > -2 > } -1->Emitted(4, 5) Source(4, 1) + SourceIndex(0) name (m2_c1.constructor) -2 >Emitted(4, 6) Source(4, 2) + SourceIndex(0) name (m2_c1.constructor) ---- ->>> return m2_c1; -1->^^^^ -2 > ^^^^^^^^^^^^ -1-> -2 > } -1->Emitted(5, 5) Source(4, 1) + SourceIndex(0) name (m2_c1) -2 >Emitted(5, 17) Source(4, 2) + SourceIndex(0) name (m2_c1) ---- ->>>})(); -1 > -2 >^ -3 > -4 > ^^^^ -5 > ^^^^^^^^^^^^^^^^^^-> -1 > -2 >} -3 > -4 > export class m2_c1 { - > public m2_c1_p1: number; - > } -1 >Emitted(6, 1) Source(4, 1) + SourceIndex(0) name (m2_c1) -2 >Emitted(6, 2) Source(4, 2) + SourceIndex(0) name (m2_c1) -3 >Emitted(6, 2) Source(2, 1) + SourceIndex(0) -4 >Emitted(6, 6) Source(4, 2) + SourceIndex(0) ---- ->>>exports.m2_c1 = m2_c1; -1-> -2 >^^^^^^^^^^^^^ -3 > ^^^^^^^^ -4 > ^ -5 > ^^^^^^^^^^^^^^-> -1-> -2 >m2_c1 -3 > { - > public m2_c1_p1: number; - > } -4 > -1->Emitted(7, 1) Source(2, 14) + SourceIndex(0) -2 >Emitted(7, 14) Source(2, 19) + SourceIndex(0) -3 >Emitted(7, 22) Source(4, 2) + SourceIndex(0) -4 >Emitted(7, 23) Source(4, 2) + SourceIndex(0) ---- ->>>exports.m2_instance1 = new m2_c1(); -1-> -2 >^^^^^^^^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^^^ -5 > ^^^^^ -6 > ^^ -7 > ^ -1-> - > - >export var -2 >m2_instance1 -3 > = -4 > new -5 > m2_c1 -6 > () -7 > ; -1->Emitted(8, 1) Source(6, 12) + SourceIndex(0) -2 >Emitted(8, 21) Source(6, 24) + SourceIndex(0) -3 >Emitted(8, 24) Source(6, 27) + SourceIndex(0) -4 >Emitted(8, 28) Source(6, 31) + SourceIndex(0) -5 >Emitted(8, 33) Source(6, 36) + SourceIndex(0) -6 >Emitted(8, 35) Source(6, 38) + SourceIndex(0) -7 >Emitted(8, 36) Source(6, 39) + SourceIndex(0) ---- ->>>function m2_f1() { -1 > -2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -1 >Emitted(9, 1) Source(7, 1) + SourceIndex(0) ---- ->>> return exports.m2_instance1; -1->^^^^ -2 > ^^^^^^ -3 > ^ -4 > ^^^^^^^^^^^^^^^^^^^^ -5 > ^ -1->export function m2_f1() { - > -2 > return -3 > -4 > m2_instance1 -5 > ; -1->Emitted(10, 5) Source(8, 5) + SourceIndex(0) name (m2_f1) -2 >Emitted(10, 11) Source(8, 11) + SourceIndex(0) name (m2_f1) -3 >Emitted(10, 12) Source(8, 12) + SourceIndex(0) name (m2_f1) -4 >Emitted(10, 32) Source(8, 24) + SourceIndex(0) name (m2_f1) -5 >Emitted(10, 33) Source(8, 25) + SourceIndex(0) name (m2_f1) ---- ->>>} -1 > -2 >^ -3 > ^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -2 >} -1 >Emitted(11, 1) Source(9, 1) + SourceIndex(0) name (m2_f1) -2 >Emitted(11, 2) Source(9, 2) + SourceIndex(0) name (m2_f1) ---- ->>>exports.m2_f1 = m2_f1; -1-> -2 >^^^^^^^^^^^^^ -3 > ^^^^^^^^ -4 > ^ -5 > ^^^^^^^-> -1-> -2 >m2_f1 -3 > () { - > return m2_instance1; - > } -4 > -1->Emitted(12, 1) Source(7, 17) + SourceIndex(0) -2 >Emitted(12, 14) Source(7, 22) + SourceIndex(0) -3 >Emitted(12, 22) Source(9, 2) + SourceIndex(0) -4 >Emitted(12, 23) Source(9, 2) + SourceIndex(0) ---- ->>>//# sourceMappingURL=m2.js.map=================================================================== -JsFile: test.js -mapUrl: test.js.map -sourceRoot: http://typescript.codeplex.com/ -sources: outputdir_module_multifolder/test.ts -=================================================================== -------------------------------------------------------------------- -emittedFile:test.js -sourceFile:outputdir_module_multifolder/test.ts -------------------------------------------------------------------- ->>>var m1 = require("ref/m1"); -1 > -2 >^^^^ -3 > ^^ -4 > ^^^^^^^^^^^ -5 > ^^^^^^^^ -6 > ^ -7 > ^ -8 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 > -2 >import -3 > m1 -4 > = require( -5 > "ref/m1" -6 > ) -7 > ; -1 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) -2 >Emitted(1, 5) Source(1, 8) + SourceIndex(0) -3 >Emitted(1, 7) Source(1, 10) + SourceIndex(0) -4 >Emitted(1, 18) Source(1, 21) + SourceIndex(0) -5 >Emitted(1, 26) Source(1, 29) + SourceIndex(0) -6 >Emitted(1, 27) Source(1, 30) + SourceIndex(0) -7 >Emitted(1, 28) Source(1, 31) + SourceIndex(0) ---- ->>>var m2 = require("../outputdir_module_multifolder_ref/m2"); -1-> -2 >^^^^ -3 > ^^ -4 > ^^^^^^^^^^^ -5 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -6 > ^ -7 > ^ -1-> - > -2 >import -3 > m2 -4 > = require( -5 > "../outputdir_module_multifolder_ref/m2" -6 > ) -7 > ; -1->Emitted(2, 1) Source(2, 1) + SourceIndex(0) -2 >Emitted(2, 5) Source(2, 8) + SourceIndex(0) -3 >Emitted(2, 7) Source(2, 10) + SourceIndex(0) -4 >Emitted(2, 18) Source(2, 21) + SourceIndex(0) -5 >Emitted(2, 58) Source(2, 61) + SourceIndex(0) -6 >Emitted(2, 59) Source(2, 62) + SourceIndex(0) -7 >Emitted(2, 60) Source(2, 63) + SourceIndex(0) ---- ->>>exports.a1 = 10; -1 > -2 >^^^^^^^^^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^-> -1 > - >export var -2 >a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(3, 1) Source(3, 12) + SourceIndex(0) -2 >Emitted(3, 11) Source(3, 14) + SourceIndex(0) -3 >Emitted(3, 14) Source(3, 17) + SourceIndex(0) -4 >Emitted(3, 16) Source(3, 19) + SourceIndex(0) -5 >Emitted(3, 17) Source(3, 20) + SourceIndex(0) ---- ->>>var c1 = (function () { -1-> -2 >^^^^^^^^^^^^^^^^^^^^-> -1-> - > -1->Emitted(4, 1) Source(4, 1) + SourceIndex(0) ---- ->>> function c1() { -1->^^^^ -2 > ^^-> -1-> -1->Emitted(5, 5) Source(4, 1) + SourceIndex(0) name (c1) ---- ->>> } -1->^^^^ -2 > ^ -3 > ^^^^^^^^^^-> -1->export class c1 { - > public p1: number; - > -2 > } -1->Emitted(6, 5) Source(6, 1) + SourceIndex(0) name (c1.constructor) -2 >Emitted(6, 6) Source(6, 2) + SourceIndex(0) name (c1.constructor) ---- ->>> return c1; -1->^^^^ -2 > ^^^^^^^^^ -1-> -2 > } -1->Emitted(7, 5) Source(6, 1) + SourceIndex(0) name (c1) -2 >Emitted(7, 14) Source(6, 2) + SourceIndex(0) name (c1) ---- ->>>})(); -1 > -2 >^ -3 > -4 > ^^^^ -5 > ^^^^^^^^^^^^-> -1 > -2 >} -3 > -4 > export class c1 { - > public p1: number; - > } -1 >Emitted(8, 1) Source(6, 1) + SourceIndex(0) name (c1) -2 >Emitted(8, 2) Source(6, 2) + SourceIndex(0) name (c1) -3 >Emitted(8, 2) Source(4, 1) + SourceIndex(0) -4 >Emitted(8, 6) Source(6, 2) + SourceIndex(0) ---- ->>>exports.c1 = c1; -1-> -2 >^^^^^^^^^^ -3 > ^^^^^ -4 > ^ -5 > ^^^^^^^^^^^^^^-> -1-> -2 >c1 -3 > { - > public p1: number; - > } -4 > -1->Emitted(9, 1) Source(4, 14) + SourceIndex(0) -2 >Emitted(9, 11) Source(4, 16) + SourceIndex(0) -3 >Emitted(9, 16) Source(6, 2) + SourceIndex(0) -4 >Emitted(9, 17) Source(6, 2) + SourceIndex(0) ---- ->>>exports.instance1 = new c1(); -1-> -2 >^^^^^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^^^ -5 > ^^ -6 > ^^ -7 > ^ -1-> - > - >export var -2 >instance1 -3 > = -4 > new -5 > c1 -6 > () -7 > ; -1->Emitted(10, 1) Source(8, 12) + SourceIndex(0) -2 >Emitted(10, 18) Source(8, 21) + SourceIndex(0) -3 >Emitted(10, 21) Source(8, 24) + SourceIndex(0) -4 >Emitted(10, 25) Source(8, 28) + SourceIndex(0) -5 >Emitted(10, 27) Source(8, 30) + SourceIndex(0) -6 >Emitted(10, 29) Source(8, 32) + SourceIndex(0) -7 >Emitted(10, 30) Source(8, 33) + SourceIndex(0) ---- ->>>function f1() { -1 > -2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -1 >Emitted(11, 1) Source(9, 1) + SourceIndex(0) ---- ->>> return exports.instance1; -1->^^^^ -2 > ^^^^^^ -3 > ^ -4 > ^^^^^^^^^^^^^^^^^ -5 > ^ -1->export function f1() { - > -2 > return -3 > -4 > instance1 -5 > ; -1->Emitted(12, 5) Source(10, 5) + SourceIndex(0) name (f1) -2 >Emitted(12, 11) Source(10, 11) + SourceIndex(0) name (f1) -3 >Emitted(12, 12) Source(10, 12) + SourceIndex(0) name (f1) -4 >Emitted(12, 29) Source(10, 21) + SourceIndex(0) name (f1) -5 >Emitted(12, 30) Source(10, 22) + SourceIndex(0) name (f1) ---- ->>>} -1 > -2 >^ -3 > ^^^^^^^^^^^^^^^^-> -1 > - > -2 >} -1 >Emitted(13, 1) Source(11, 1) + SourceIndex(0) name (f1) -2 >Emitted(13, 2) Source(11, 2) + SourceIndex(0) name (f1) ---- ->>>exports.f1 = f1; -1-> -2 >^^^^^^^^^^ -3 > ^^^^^ -4 > ^ -5 > ^^^^^^^-> -1-> -2 >f1 -3 > () { - > return instance1; - > } -4 > -1->Emitted(14, 1) Source(9, 17) + SourceIndex(0) -2 >Emitted(14, 11) Source(9, 19) + SourceIndex(0) -3 >Emitted(14, 16) Source(11, 2) + SourceIndex(0) -4 >Emitted(14, 17) Source(11, 2) + SourceIndex(0) ---- ->>>exports.a2 = m1.m1_c1; -1-> -2 >^^^^^^^^^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^ -7 > ^ -8 > ^-> -1-> - > - >export var -2 >a2 -3 > = -4 > m1 -5 > . -6 > m1_c1 -7 > ; -1->Emitted(15, 1) Source(13, 12) + SourceIndex(0) -2 >Emitted(15, 11) Source(13, 14) + SourceIndex(0) -3 >Emitted(15, 14) Source(13, 17) + SourceIndex(0) -4 >Emitted(15, 16) Source(13, 19) + SourceIndex(0) -5 >Emitted(15, 17) Source(13, 20) + SourceIndex(0) -6 >Emitted(15, 22) Source(13, 25) + SourceIndex(0) -7 >Emitted(15, 23) Source(13, 26) + SourceIndex(0) ---- ->>>exports.a3 = m2.m2_c1; -1-> -2 >^^^^^^^^^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^ -7 > ^ -8 > ^^^^^^^^^-> -1-> - >export var -2 >a3 -3 > = -4 > m2 -5 > . -6 > m2_c1 -7 > ; -1->Emitted(16, 1) Source(14, 12) + SourceIndex(0) -2 >Emitted(16, 11) Source(14, 14) + SourceIndex(0) -3 >Emitted(16, 14) Source(14, 17) + SourceIndex(0) -4 >Emitted(16, 16) Source(14, 19) + SourceIndex(0) -5 >Emitted(16, 17) Source(14, 20) + SourceIndex(0) -6 >Emitted(16, 22) Source(14, 25) + SourceIndex(0) -7 >Emitted(16, 23) Source(14, 26) + SourceIndex(0) ---- ->>>//# sourceMappingURL=test.js.map=================================================================== JsFile: test.js mapUrl: test.js.map sourceRoot: http://typescript.codeplex.com/ diff --git a/tests/baselines/reference/project/sourcerootUrlModuleMultifolderSpecifyOutputFile/node/test.d.ts b/tests/baselines/reference/project/sourcerootUrlModuleMultifolderSpecifyOutputFile/node/test.d.ts deleted file mode 100644 index 4afd4e69f2d..00000000000 --- a/tests/baselines/reference/project/sourcerootUrlModuleMultifolderSpecifyOutputFile/node/test.d.ts +++ /dev/null @@ -1,10 +0,0 @@ -import m1 = require("ref/m1"); -import m2 = require("../outputdir_module_multifolder_ref/m2"); -export declare var a1: number; -export declare class c1 { - p1: number; -} -export declare var instance1: c1; -export declare function f1(): c1; -export declare var a2: typeof m1.m1_c1; -export declare var a3: typeof m2.m2_c1; diff --git a/tests/baselines/reference/project/sourcerootUrlModuleMultifolderSpecifyOutputFile/node/test.js b/tests/baselines/reference/project/sourcerootUrlModuleMultifolderSpecifyOutputFile/node/test.js deleted file mode 100644 index 14c09e444a5..00000000000 --- a/tests/baselines/reference/project/sourcerootUrlModuleMultifolderSpecifyOutputFile/node/test.js +++ /dev/null @@ -1,17 +0,0 @@ -var m1 = require("ref/m1"); -var m2 = require("../outputdir_module_multifolder_ref/m2"); -exports.a1 = 10; -var c1 = (function () { - function c1() { - } - return c1; -})(); -exports.c1 = c1; -exports.instance1 = new c1(); -function f1() { - return exports.instance1; -} -exports.f1 = f1; -exports.a2 = m1.m1_c1; -exports.a3 = m2.m2_c1; -//# sourceMappingURL=test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcerootUrlModuleMultifolderSpecifyOutputFile/node/test.js.map b/tests/baselines/reference/project/sourcerootUrlModuleMultifolderSpecifyOutputFile/node/test.js.map deleted file mode 100644 index 4ac74c2fcdb..00000000000 --- a/tests/baselines/reference/project/sourcerootUrlModuleMultifolderSpecifyOutputFile/node/test.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"test.js","sourceRoot":"http://typescript.codeplex.com/","sources":["outputdir_module_multifolder/test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AAAA,IAAO,EAAE,WAAW,QAAQ,CAAC,CAAC;AAC9B,IAAO,EAAE,WAAW,wCAAwC,CAAC,CAAC;AACnD,UAAE,GAAG,EAAE,CAAC;AACnB;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAFY,UAAE,KAEd,CAAA;AAEU,iBAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AAChC;IACIE,MAAMA,CAACA,iBAASA,CAACA;AACrBA,CAACA;AAFe,UAAE,KAEjB,CAAA;AAEU,UAAE,GAAG,EAAE,CAAC,KAAK,CAAC;AACd,UAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcerootUrlModuleSimpleSpecifyOutputFile/amd/m1.d.ts b/tests/baselines/reference/project/sourcerootUrlModuleSimpleSpecifyOutputFile/amd/m1.d.ts deleted file mode 100644 index 4a53b24b156..00000000000 --- a/tests/baselines/reference/project/sourcerootUrlModuleSimpleSpecifyOutputFile/amd/m1.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -export declare var m1_a1: number; -export declare class m1_c1 { - m1_c1_p1: number; -} -export declare var m1_instance1: m1_c1; -export declare function m1_f1(): m1_c1; diff --git a/tests/baselines/reference/project/sourcerootUrlModuleSimpleSpecifyOutputFile/amd/m1.js b/tests/baselines/reference/project/sourcerootUrlModuleSimpleSpecifyOutputFile/amd/m1.js deleted file mode 100644 index bbaba444ba2..00000000000 --- a/tests/baselines/reference/project/sourcerootUrlModuleSimpleSpecifyOutputFile/amd/m1.js +++ /dev/null @@ -1,15 +0,0 @@ -define(["require", "exports"], function (require, exports) { - exports.m1_a1 = 10; - var m1_c1 = (function () { - function m1_c1() { - } - return m1_c1; - })(); - exports.m1_c1 = m1_c1; - exports.m1_instance1 = new m1_c1(); - function m1_f1() { - return exports.m1_instance1; - } - exports.m1_f1 = m1_f1; -}); -//# sourceMappingURL=m1.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcerootUrlModuleSimpleSpecifyOutputFile/amd/m1.js.map b/tests/baselines/reference/project/sourcerootUrlModuleSimpleSpecifyOutputFile/amd/m1.js.map deleted file mode 100644 index 6751f2f82cd..00000000000 --- a/tests/baselines/reference/project/sourcerootUrlModuleSimpleSpecifyOutputFile/amd/m1.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"m1.js","sourceRoot":"http://typescript.codeplex.com/","sources":["m1.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1"],"mappings":";IAAW,aAAK,GAAG,EAAE,CAAC;IACtB;QAAAA;QAEAC,CAACA;QAADD,YAACA;IAADA,CAACA,AAFD,IAEC;IAFY,aAAK,QAEjB,CAAA;IAEU,oBAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACIE,MAAMA,CAACA,oBAAYA,CAACA;IACxBA,CAACA;IAFe,aAAK,QAEpB,CAAA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcerootUrlModuleSimpleSpecifyOutputFile/amd/sourcerootUrlModuleSimpleSpecifyOutputFile.json b/tests/baselines/reference/project/sourcerootUrlModuleSimpleSpecifyOutputFile/amd/sourcerootUrlModuleSimpleSpecifyOutputFile.json index 5419c5a8225..4d92e8a8951 100644 --- a/tests/baselines/reference/project/sourcerootUrlModuleSimpleSpecifyOutputFile/amd/sourcerootUrlModuleSimpleSpecifyOutputFile.json +++ b/tests/baselines/reference/project/sourcerootUrlModuleSimpleSpecifyOutputFile/amd/sourcerootUrlModuleSimpleSpecifyOutputFile.json @@ -15,12 +15,6 @@ "test.ts" ], "emittedFiles": [ - "m1.js.map", - "m1.js", - "m1.d.ts", - "test.js.map", - "test.js", - "test.d.ts", "bin/test.js.map", "bin/test.js", "bin/test.d.ts" diff --git a/tests/baselines/reference/project/sourcerootUrlModuleSimpleSpecifyOutputFile/amd/sourcerootUrlModuleSimpleSpecifyOutputFile.sourcemap.txt b/tests/baselines/reference/project/sourcerootUrlModuleSimpleSpecifyOutputFile/amd/sourcerootUrlModuleSimpleSpecifyOutputFile.sourcemap.txt index 906ba3a07ac..e0c060eb889 100644 --- a/tests/baselines/reference/project/sourcerootUrlModuleSimpleSpecifyOutputFile/amd/sourcerootUrlModuleSimpleSpecifyOutputFile.sourcemap.txt +++ b/tests/baselines/reference/project/sourcerootUrlModuleSimpleSpecifyOutputFile/amd/sourcerootUrlModuleSimpleSpecifyOutputFile.sourcemap.txt @@ -1,375 +1,4 @@ =================================================================== -JsFile: m1.js -mapUrl: m1.js.map -sourceRoot: http://typescript.codeplex.com/ -sources: m1.ts -=================================================================== -------------------------------------------------------------------- -emittedFile:m1.js -sourceFile:m1.ts -------------------------------------------------------------------- ->>>define(["require", "exports"], function (require, exports) { ->>> exports.m1_a1 = 10; -1 >^^^^ -2 > ^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^-> -1 >export var -2 > m1_a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(2, 5) Source(1, 12) + SourceIndex(0) -2 >Emitted(2, 18) Source(1, 17) + SourceIndex(0) -3 >Emitted(2, 21) Source(1, 20) + SourceIndex(0) -4 >Emitted(2, 23) Source(1, 22) + SourceIndex(0) -5 >Emitted(2, 24) Source(1, 23) + SourceIndex(0) ---- ->>> var m1_c1 = (function () { -1->^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^^^^-> -1-> - > -1->Emitted(3, 5) Source(2, 1) + SourceIndex(0) ---- ->>> function m1_c1() { -1->^^^^^^^^ -2 > ^^-> -1-> -1->Emitted(4, 9) Source(2, 1) + SourceIndex(0) name (m1_c1) ---- ->>> } -1->^^^^^^^^ -2 > ^ -3 > ^^^^^^^^^^^^^-> -1->export class m1_c1 { - > public m1_c1_p1: number; - > -2 > } -1->Emitted(5, 9) Source(4, 1) + SourceIndex(0) name (m1_c1.constructor) -2 >Emitted(5, 10) Source(4, 2) + SourceIndex(0) name (m1_c1.constructor) ---- ->>> return m1_c1; -1->^^^^^^^^ -2 > ^^^^^^^^^^^^ -1-> -2 > } -1->Emitted(6, 9) Source(4, 1) + SourceIndex(0) name (m1_c1) -2 >Emitted(6, 21) Source(4, 2) + SourceIndex(0) name (m1_c1) ---- ->>> })(); -1 >^^^^ -2 > ^ -3 > -4 > ^^^^ -5 > ^^^^^^^^^^^^^^^^^^-> -1 > -2 > } -3 > -4 > export class m1_c1 { - > public m1_c1_p1: number; - > } -1 >Emitted(7, 5) Source(4, 1) + SourceIndex(0) name (m1_c1) -2 >Emitted(7, 6) Source(4, 2) + SourceIndex(0) name (m1_c1) -3 >Emitted(7, 6) Source(2, 1) + SourceIndex(0) -4 >Emitted(7, 10) Source(4, 2) + SourceIndex(0) ---- ->>> exports.m1_c1 = m1_c1; -1->^^^^ -2 > ^^^^^^^^^^^^^ -3 > ^^^^^^^^ -4 > ^ -5 > ^^^^^^^^^^^^^^-> -1-> -2 > m1_c1 -3 > { - > public m1_c1_p1: number; - > } -4 > -1->Emitted(8, 5) Source(2, 14) + SourceIndex(0) -2 >Emitted(8, 18) Source(2, 19) + SourceIndex(0) -3 >Emitted(8, 26) Source(4, 2) + SourceIndex(0) -4 >Emitted(8, 27) Source(4, 2) + SourceIndex(0) ---- ->>> exports.m1_instance1 = new m1_c1(); -1->^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^^^ -5 > ^^^^^ -6 > ^^ -7 > ^ -1-> - > - >export var -2 > m1_instance1 -3 > = -4 > new -5 > m1_c1 -6 > () -7 > ; -1->Emitted(9, 5) Source(6, 12) + SourceIndex(0) -2 >Emitted(9, 25) Source(6, 24) + SourceIndex(0) -3 >Emitted(9, 28) Source(6, 27) + SourceIndex(0) -4 >Emitted(9, 32) Source(6, 31) + SourceIndex(0) -5 >Emitted(9, 37) Source(6, 36) + SourceIndex(0) -6 >Emitted(9, 39) Source(6, 38) + SourceIndex(0) -7 >Emitted(9, 40) Source(6, 39) + SourceIndex(0) ---- ->>> function m1_f1() { -1 >^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -1 >Emitted(10, 5) Source(7, 1) + SourceIndex(0) ---- ->>> return exports.m1_instance1; -1->^^^^^^^^ -2 > ^^^^^^ -3 > ^ -4 > ^^^^^^^^^^^^^^^^^^^^ -5 > ^ -1->export function m1_f1() { - > -2 > return -3 > -4 > m1_instance1 -5 > ; -1->Emitted(11, 9) Source(8, 5) + SourceIndex(0) name (m1_f1) -2 >Emitted(11, 15) Source(8, 11) + SourceIndex(0) name (m1_f1) -3 >Emitted(11, 16) Source(8, 12) + SourceIndex(0) name (m1_f1) -4 >Emitted(11, 36) Source(8, 24) + SourceIndex(0) name (m1_f1) -5 >Emitted(11, 37) Source(8, 25) + SourceIndex(0) name (m1_f1) ---- ->>> } -1 >^^^^ -2 > ^ -3 > ^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -2 > } -1 >Emitted(12, 5) Source(9, 1) + SourceIndex(0) name (m1_f1) -2 >Emitted(12, 6) Source(9, 2) + SourceIndex(0) name (m1_f1) ---- ->>> exports.m1_f1 = m1_f1; -1->^^^^ -2 > ^^^^^^^^^^^^^ -3 > ^^^^^^^^ -4 > ^ -1-> -2 > m1_f1 -3 > () { - > return m1_instance1; - > } -4 > -1->Emitted(13, 5) Source(7, 17) + SourceIndex(0) -2 >Emitted(13, 18) Source(7, 22) + SourceIndex(0) -3 >Emitted(13, 26) Source(9, 2) + SourceIndex(0) -4 >Emitted(13, 27) Source(9, 2) + SourceIndex(0) ---- ->>>}); ->>>//# sourceMappingURL=m1.js.map=================================================================== -JsFile: test.js -mapUrl: test.js.map -sourceRoot: http://typescript.codeplex.com/ -sources: test.ts -=================================================================== -------------------------------------------------------------------- -emittedFile:test.js -sourceFile:test.ts -------------------------------------------------------------------- ->>>define(["require", "exports", "m1"], function (require, exports, m1) { ->>> exports.a1 = 10; -1 >^^^^ -2 > ^^^^^^^^^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^-> -1 >import m1 = require("m1"); - >export var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(2, 5) Source(2, 12) + SourceIndex(0) -2 >Emitted(2, 15) Source(2, 14) + SourceIndex(0) -3 >Emitted(2, 18) Source(2, 17) + SourceIndex(0) -4 >Emitted(2, 20) Source(2, 19) + SourceIndex(0) -5 >Emitted(2, 21) Source(2, 20) + SourceIndex(0) ---- ->>> var c1 = (function () { -1->^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^-> -1-> - > -1->Emitted(3, 5) Source(3, 1) + SourceIndex(0) ---- ->>> function c1() { -1->^^^^^^^^ -2 > ^^-> -1-> -1->Emitted(4, 9) Source(3, 1) + SourceIndex(0) name (c1) ---- ->>> } -1->^^^^^^^^ -2 > ^ -3 > ^^^^^^^^^^-> -1->export class c1 { - > public p1: number; - > -2 > } -1->Emitted(5, 9) Source(5, 1) + SourceIndex(0) name (c1.constructor) -2 >Emitted(5, 10) Source(5, 2) + SourceIndex(0) name (c1.constructor) ---- ->>> return c1; -1->^^^^^^^^ -2 > ^^^^^^^^^ -1-> -2 > } -1->Emitted(6, 9) Source(5, 1) + SourceIndex(0) name (c1) -2 >Emitted(6, 18) Source(5, 2) + SourceIndex(0) name (c1) ---- ->>> })(); -1 >^^^^ -2 > ^ -3 > -4 > ^^^^ -5 > ^^^^^^^^^^^^-> -1 > -2 > } -3 > -4 > export class c1 { - > public p1: number; - > } -1 >Emitted(7, 5) Source(5, 1) + SourceIndex(0) name (c1) -2 >Emitted(7, 6) Source(5, 2) + SourceIndex(0) name (c1) -3 >Emitted(7, 6) Source(3, 1) + SourceIndex(0) -4 >Emitted(7, 10) Source(5, 2) + SourceIndex(0) ---- ->>> exports.c1 = c1; -1->^^^^ -2 > ^^^^^^^^^^ -3 > ^^^^^ -4 > ^ -5 > ^^^^^^^^^^^^^^-> -1-> -2 > c1 -3 > { - > public p1: number; - > } -4 > -1->Emitted(8, 5) Source(3, 14) + SourceIndex(0) -2 >Emitted(8, 15) Source(3, 16) + SourceIndex(0) -3 >Emitted(8, 20) Source(5, 2) + SourceIndex(0) -4 >Emitted(8, 21) Source(5, 2) + SourceIndex(0) ---- ->>> exports.instance1 = new c1(); -1->^^^^ -2 > ^^^^^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^^^ -5 > ^^ -6 > ^^ -7 > ^ -1-> - > - >export var -2 > instance1 -3 > = -4 > new -5 > c1 -6 > () -7 > ; -1->Emitted(9, 5) Source(7, 12) + SourceIndex(0) -2 >Emitted(9, 22) Source(7, 21) + SourceIndex(0) -3 >Emitted(9, 25) Source(7, 24) + SourceIndex(0) -4 >Emitted(9, 29) Source(7, 28) + SourceIndex(0) -5 >Emitted(9, 31) Source(7, 30) + SourceIndex(0) -6 >Emitted(9, 33) Source(7, 32) + SourceIndex(0) -7 >Emitted(9, 34) Source(7, 33) + SourceIndex(0) ---- ->>> function f1() { -1 >^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -1 >Emitted(10, 5) Source(8, 1) + SourceIndex(0) ---- ->>> return exports.instance1; -1->^^^^^^^^ -2 > ^^^^^^ -3 > ^ -4 > ^^^^^^^^^^^^^^^^^ -5 > ^ -1->export function f1() { - > -2 > return -3 > -4 > instance1 -5 > ; -1->Emitted(11, 9) Source(9, 5) + SourceIndex(0) name (f1) -2 >Emitted(11, 15) Source(9, 11) + SourceIndex(0) name (f1) -3 >Emitted(11, 16) Source(9, 12) + SourceIndex(0) name (f1) -4 >Emitted(11, 33) Source(9, 21) + SourceIndex(0) name (f1) -5 >Emitted(11, 34) Source(9, 22) + SourceIndex(0) name (f1) ---- ->>> } -1 >^^^^ -2 > ^ -3 > ^^^^^^^^^^^^^^^^-> -1 > - > -2 > } -1 >Emitted(12, 5) Source(10, 1) + SourceIndex(0) name (f1) -2 >Emitted(12, 6) Source(10, 2) + SourceIndex(0) name (f1) ---- ->>> exports.f1 = f1; -1->^^^^ -2 > ^^^^^^^^^^ -3 > ^^^^^ -4 > ^ -5 > ^^^^^^^-> -1-> -2 > f1 -3 > () { - > return instance1; - > } -4 > -1->Emitted(13, 5) Source(8, 17) + SourceIndex(0) -2 >Emitted(13, 15) Source(8, 19) + SourceIndex(0) -3 >Emitted(13, 20) Source(10, 2) + SourceIndex(0) -4 >Emitted(13, 21) Source(10, 2) + SourceIndex(0) ---- ->>> exports.a2 = m1.m1_c1; -1->^^^^ -2 > ^^^^^^^^^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^ -7 > ^ -1-> - > - >export var -2 > a2 -3 > = -4 > m1 -5 > . -6 > m1_c1 -7 > ; -1->Emitted(14, 5) Source(12, 12) + SourceIndex(0) -2 >Emitted(14, 15) Source(12, 14) + SourceIndex(0) -3 >Emitted(14, 18) Source(12, 17) + SourceIndex(0) -4 >Emitted(14, 20) Source(12, 19) + SourceIndex(0) -5 >Emitted(14, 21) Source(12, 20) + SourceIndex(0) -6 >Emitted(14, 26) Source(12, 25) + SourceIndex(0) -7 >Emitted(14, 27) Source(12, 26) + SourceIndex(0) ---- ->>>}); ->>>//# sourceMappingURL=test.js.map=================================================================== JsFile: test.js mapUrl: test.js.map sourceRoot: http://typescript.codeplex.com/ diff --git a/tests/baselines/reference/project/sourcerootUrlModuleSimpleSpecifyOutputFile/amd/test.d.ts b/tests/baselines/reference/project/sourcerootUrlModuleSimpleSpecifyOutputFile/amd/test.d.ts deleted file mode 100644 index 250d2615a79..00000000000 --- a/tests/baselines/reference/project/sourcerootUrlModuleSimpleSpecifyOutputFile/amd/test.d.ts +++ /dev/null @@ -1,8 +0,0 @@ -import m1 = require("m1"); -export declare var a1: number; -export declare class c1 { - p1: number; -} -export declare var instance1: c1; -export declare function f1(): c1; -export declare var a2: typeof m1.m1_c1; diff --git a/tests/baselines/reference/project/sourcerootUrlModuleSimpleSpecifyOutputFile/amd/test.js b/tests/baselines/reference/project/sourcerootUrlModuleSimpleSpecifyOutputFile/amd/test.js deleted file mode 100644 index 372f1052b89..00000000000 --- a/tests/baselines/reference/project/sourcerootUrlModuleSimpleSpecifyOutputFile/amd/test.js +++ /dev/null @@ -1,16 +0,0 @@ -define(["require", "exports", "m1"], function (require, exports, m1) { - exports.a1 = 10; - var c1 = (function () { - function c1() { - } - return c1; - })(); - exports.c1 = c1; - exports.instance1 = new c1(); - function f1() { - return exports.instance1; - } - exports.f1 = f1; - exports.a2 = m1.m1_c1; -}); -//# sourceMappingURL=test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcerootUrlModuleSimpleSpecifyOutputFile/amd/test.js.map b/tests/baselines/reference/project/sourcerootUrlModuleSimpleSpecifyOutputFile/amd/test.js.map deleted file mode 100644 index a57b57d2b17..00000000000 --- a/tests/baselines/reference/project/sourcerootUrlModuleSimpleSpecifyOutputFile/amd/test.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"test.js","sourceRoot":"http://typescript.codeplex.com/","sources":["test.ts"],"names":["c1","c1.constructor","f1"],"mappings":";IACW,UAAE,GAAG,EAAE,CAAC;IACnB;QAAAA;QAEAC,CAACA;QAADD,SAACA;IAADA,CAACA,AAFD,IAEC;IAFY,UAAE,KAEd,CAAA;IAEU,iBAAS,GAAG,IAAI,EAAE,EAAE,CAAC;IAChC;QACIE,MAAMA,CAACA,iBAASA,CAACA;IACrBA,CAACA;IAFe,UAAE,KAEjB,CAAA;IAEU,UAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcerootUrlModuleSimpleSpecifyOutputFile/node/m1.d.ts b/tests/baselines/reference/project/sourcerootUrlModuleSimpleSpecifyOutputFile/node/m1.d.ts deleted file mode 100644 index 4a53b24b156..00000000000 --- a/tests/baselines/reference/project/sourcerootUrlModuleSimpleSpecifyOutputFile/node/m1.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -export declare var m1_a1: number; -export declare class m1_c1 { - m1_c1_p1: number; -} -export declare var m1_instance1: m1_c1; -export declare function m1_f1(): m1_c1; diff --git a/tests/baselines/reference/project/sourcerootUrlModuleSimpleSpecifyOutputFile/node/m1.js b/tests/baselines/reference/project/sourcerootUrlModuleSimpleSpecifyOutputFile/node/m1.js deleted file mode 100644 index 1b4470e2b37..00000000000 --- a/tests/baselines/reference/project/sourcerootUrlModuleSimpleSpecifyOutputFile/node/m1.js +++ /dev/null @@ -1,13 +0,0 @@ -exports.m1_a1 = 10; -var m1_c1 = (function () { - function m1_c1() { - } - return m1_c1; -})(); -exports.m1_c1 = m1_c1; -exports.m1_instance1 = new m1_c1(); -function m1_f1() { - return exports.m1_instance1; -} -exports.m1_f1 = m1_f1; -//# sourceMappingURL=m1.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcerootUrlModuleSimpleSpecifyOutputFile/node/m1.js.map b/tests/baselines/reference/project/sourcerootUrlModuleSimpleSpecifyOutputFile/node/m1.js.map deleted file mode 100644 index ca45773f423..00000000000 --- a/tests/baselines/reference/project/sourcerootUrlModuleSimpleSpecifyOutputFile/node/m1.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"m1.js","sourceRoot":"http://typescript.codeplex.com/","sources":["m1.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1"],"mappings":"AAAW,aAAK,GAAG,EAAE,CAAC;AACtB;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAFY,aAAK,QAEjB,CAAA;AAEU,oBAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACIE,MAAMA,CAACA,oBAAYA,CAACA;AACxBA,CAACA;AAFe,aAAK,QAEpB,CAAA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcerootUrlModuleSimpleSpecifyOutputFile/node/sourcerootUrlModuleSimpleSpecifyOutputFile.json b/tests/baselines/reference/project/sourcerootUrlModuleSimpleSpecifyOutputFile/node/sourcerootUrlModuleSimpleSpecifyOutputFile.json index 5419c5a8225..4d92e8a8951 100644 --- a/tests/baselines/reference/project/sourcerootUrlModuleSimpleSpecifyOutputFile/node/sourcerootUrlModuleSimpleSpecifyOutputFile.json +++ b/tests/baselines/reference/project/sourcerootUrlModuleSimpleSpecifyOutputFile/node/sourcerootUrlModuleSimpleSpecifyOutputFile.json @@ -15,12 +15,6 @@ "test.ts" ], "emittedFiles": [ - "m1.js.map", - "m1.js", - "m1.d.ts", - "test.js.map", - "test.js", - "test.d.ts", "bin/test.js.map", "bin/test.js", "bin/test.d.ts" diff --git a/tests/baselines/reference/project/sourcerootUrlModuleSimpleSpecifyOutputFile/node/sourcerootUrlModuleSimpleSpecifyOutputFile.sourcemap.txt b/tests/baselines/reference/project/sourcerootUrlModuleSimpleSpecifyOutputFile/node/sourcerootUrlModuleSimpleSpecifyOutputFile.sourcemap.txt index 432e0b90c49..dfbb5f48fff 100644 --- a/tests/baselines/reference/project/sourcerootUrlModuleSimpleSpecifyOutputFile/node/sourcerootUrlModuleSimpleSpecifyOutputFile.sourcemap.txt +++ b/tests/baselines/reference/project/sourcerootUrlModuleSimpleSpecifyOutputFile/node/sourcerootUrlModuleSimpleSpecifyOutputFile.sourcemap.txt @@ -1,396 +1,4 @@ =================================================================== -JsFile: m1.js -mapUrl: m1.js.map -sourceRoot: http://typescript.codeplex.com/ -sources: m1.ts -=================================================================== -------------------------------------------------------------------- -emittedFile:m1.js -sourceFile:m1.ts -------------------------------------------------------------------- ->>>exports.m1_a1 = 10; -1 > -2 >^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^-> -1 >export var -2 >m1_a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(1, 1) Source(1, 12) + SourceIndex(0) -2 >Emitted(1, 14) Source(1, 17) + SourceIndex(0) -3 >Emitted(1, 17) Source(1, 20) + SourceIndex(0) -4 >Emitted(1, 19) Source(1, 22) + SourceIndex(0) -5 >Emitted(1, 20) Source(1, 23) + SourceIndex(0) ---- ->>>var m1_c1 = (function () { -1-> -2 >^^^^^^^^^^^^^^^^^^^^^^^-> -1-> - > -1->Emitted(2, 1) Source(2, 1) + SourceIndex(0) ---- ->>> function m1_c1() { -1->^^^^ -2 > ^^-> -1-> -1->Emitted(3, 5) Source(2, 1) + SourceIndex(0) name (m1_c1) ---- ->>> } -1->^^^^ -2 > ^ -3 > ^^^^^^^^^^^^^-> -1->export class m1_c1 { - > public m1_c1_p1: number; - > -2 > } -1->Emitted(4, 5) Source(4, 1) + SourceIndex(0) name (m1_c1.constructor) -2 >Emitted(4, 6) Source(4, 2) + SourceIndex(0) name (m1_c1.constructor) ---- ->>> return m1_c1; -1->^^^^ -2 > ^^^^^^^^^^^^ -1-> -2 > } -1->Emitted(5, 5) Source(4, 1) + SourceIndex(0) name (m1_c1) -2 >Emitted(5, 17) Source(4, 2) + SourceIndex(0) name (m1_c1) ---- ->>>})(); -1 > -2 >^ -3 > -4 > ^^^^ -5 > ^^^^^^^^^^^^^^^^^^-> -1 > -2 >} -3 > -4 > export class m1_c1 { - > public m1_c1_p1: number; - > } -1 >Emitted(6, 1) Source(4, 1) + SourceIndex(0) name (m1_c1) -2 >Emitted(6, 2) Source(4, 2) + SourceIndex(0) name (m1_c1) -3 >Emitted(6, 2) Source(2, 1) + SourceIndex(0) -4 >Emitted(6, 6) Source(4, 2) + SourceIndex(0) ---- ->>>exports.m1_c1 = m1_c1; -1-> -2 >^^^^^^^^^^^^^ -3 > ^^^^^^^^ -4 > ^ -5 > ^^^^^^^^^^^^^^-> -1-> -2 >m1_c1 -3 > { - > public m1_c1_p1: number; - > } -4 > -1->Emitted(7, 1) Source(2, 14) + SourceIndex(0) -2 >Emitted(7, 14) Source(2, 19) + SourceIndex(0) -3 >Emitted(7, 22) Source(4, 2) + SourceIndex(0) -4 >Emitted(7, 23) Source(4, 2) + SourceIndex(0) ---- ->>>exports.m1_instance1 = new m1_c1(); -1-> -2 >^^^^^^^^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^^^ -5 > ^^^^^ -6 > ^^ -7 > ^ -1-> - > - >export var -2 >m1_instance1 -3 > = -4 > new -5 > m1_c1 -6 > () -7 > ; -1->Emitted(8, 1) Source(6, 12) + SourceIndex(0) -2 >Emitted(8, 21) Source(6, 24) + SourceIndex(0) -3 >Emitted(8, 24) Source(6, 27) + SourceIndex(0) -4 >Emitted(8, 28) Source(6, 31) + SourceIndex(0) -5 >Emitted(8, 33) Source(6, 36) + SourceIndex(0) -6 >Emitted(8, 35) Source(6, 38) + SourceIndex(0) -7 >Emitted(8, 36) Source(6, 39) + SourceIndex(0) ---- ->>>function m1_f1() { -1 > -2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -1 >Emitted(9, 1) Source(7, 1) + SourceIndex(0) ---- ->>> return exports.m1_instance1; -1->^^^^ -2 > ^^^^^^ -3 > ^ -4 > ^^^^^^^^^^^^^^^^^^^^ -5 > ^ -1->export function m1_f1() { - > -2 > return -3 > -4 > m1_instance1 -5 > ; -1->Emitted(10, 5) Source(8, 5) + SourceIndex(0) name (m1_f1) -2 >Emitted(10, 11) Source(8, 11) + SourceIndex(0) name (m1_f1) -3 >Emitted(10, 12) Source(8, 12) + SourceIndex(0) name (m1_f1) -4 >Emitted(10, 32) Source(8, 24) + SourceIndex(0) name (m1_f1) -5 >Emitted(10, 33) Source(8, 25) + SourceIndex(0) name (m1_f1) ---- ->>>} -1 > -2 >^ -3 > ^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -2 >} -1 >Emitted(11, 1) Source(9, 1) + SourceIndex(0) name (m1_f1) -2 >Emitted(11, 2) Source(9, 2) + SourceIndex(0) name (m1_f1) ---- ->>>exports.m1_f1 = m1_f1; -1-> -2 >^^^^^^^^^^^^^ -3 > ^^^^^^^^ -4 > ^ -5 > ^^^^^^^-> -1-> -2 >m1_f1 -3 > () { - > return m1_instance1; - > } -4 > -1->Emitted(12, 1) Source(7, 17) + SourceIndex(0) -2 >Emitted(12, 14) Source(7, 22) + SourceIndex(0) -3 >Emitted(12, 22) Source(9, 2) + SourceIndex(0) -4 >Emitted(12, 23) Source(9, 2) + SourceIndex(0) ---- ->>>//# sourceMappingURL=m1.js.map=================================================================== -JsFile: test.js -mapUrl: test.js.map -sourceRoot: http://typescript.codeplex.com/ -sources: test.ts -=================================================================== -------------------------------------------------------------------- -emittedFile:test.js -sourceFile:test.ts -------------------------------------------------------------------- ->>>var m1 = require("m1"); -1 > -2 >^^^^ -3 > ^^ -4 > ^^^^^^^^^^^ -5 > ^^^^ -6 > ^ -7 > ^ -1 > -2 >import -3 > m1 -4 > = require( -5 > "m1" -6 > ) -7 > ; -1 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) -2 >Emitted(1, 5) Source(1, 8) + SourceIndex(0) -3 >Emitted(1, 7) Source(1, 10) + SourceIndex(0) -4 >Emitted(1, 18) Source(1, 21) + SourceIndex(0) -5 >Emitted(1, 22) Source(1, 25) + SourceIndex(0) -6 >Emitted(1, 23) Source(1, 26) + SourceIndex(0) -7 >Emitted(1, 24) Source(1, 27) + SourceIndex(0) ---- ->>>exports.a1 = 10; -1 > -2 >^^^^^^^^^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^-> -1 > - >export var -2 >a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(2, 1) Source(2, 12) + SourceIndex(0) -2 >Emitted(2, 11) Source(2, 14) + SourceIndex(0) -3 >Emitted(2, 14) Source(2, 17) + SourceIndex(0) -4 >Emitted(2, 16) Source(2, 19) + SourceIndex(0) -5 >Emitted(2, 17) Source(2, 20) + SourceIndex(0) ---- ->>>var c1 = (function () { -1-> -2 >^^^^^^^^^^^^^^^^^^^^-> -1-> - > -1->Emitted(3, 1) Source(3, 1) + SourceIndex(0) ---- ->>> function c1() { -1->^^^^ -2 > ^^-> -1-> -1->Emitted(4, 5) Source(3, 1) + SourceIndex(0) name (c1) ---- ->>> } -1->^^^^ -2 > ^ -3 > ^^^^^^^^^^-> -1->export class c1 { - > public p1: number; - > -2 > } -1->Emitted(5, 5) Source(5, 1) + SourceIndex(0) name (c1.constructor) -2 >Emitted(5, 6) Source(5, 2) + SourceIndex(0) name (c1.constructor) ---- ->>> return c1; -1->^^^^ -2 > ^^^^^^^^^ -1-> -2 > } -1->Emitted(6, 5) Source(5, 1) + SourceIndex(0) name (c1) -2 >Emitted(6, 14) Source(5, 2) + SourceIndex(0) name (c1) ---- ->>>})(); -1 > -2 >^ -3 > -4 > ^^^^ -5 > ^^^^^^^^^^^^-> -1 > -2 >} -3 > -4 > export class c1 { - > public p1: number; - > } -1 >Emitted(7, 1) Source(5, 1) + SourceIndex(0) name (c1) -2 >Emitted(7, 2) Source(5, 2) + SourceIndex(0) name (c1) -3 >Emitted(7, 2) Source(3, 1) + SourceIndex(0) -4 >Emitted(7, 6) Source(5, 2) + SourceIndex(0) ---- ->>>exports.c1 = c1; -1-> -2 >^^^^^^^^^^ -3 > ^^^^^ -4 > ^ -5 > ^^^^^^^^^^^^^^-> -1-> -2 >c1 -3 > { - > public p1: number; - > } -4 > -1->Emitted(8, 1) Source(3, 14) + SourceIndex(0) -2 >Emitted(8, 11) Source(3, 16) + SourceIndex(0) -3 >Emitted(8, 16) Source(5, 2) + SourceIndex(0) -4 >Emitted(8, 17) Source(5, 2) + SourceIndex(0) ---- ->>>exports.instance1 = new c1(); -1-> -2 >^^^^^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^^^ -5 > ^^ -6 > ^^ -7 > ^ -1-> - > - >export var -2 >instance1 -3 > = -4 > new -5 > c1 -6 > () -7 > ; -1->Emitted(9, 1) Source(7, 12) + SourceIndex(0) -2 >Emitted(9, 18) Source(7, 21) + SourceIndex(0) -3 >Emitted(9, 21) Source(7, 24) + SourceIndex(0) -4 >Emitted(9, 25) Source(7, 28) + SourceIndex(0) -5 >Emitted(9, 27) Source(7, 30) + SourceIndex(0) -6 >Emitted(9, 29) Source(7, 32) + SourceIndex(0) -7 >Emitted(9, 30) Source(7, 33) + SourceIndex(0) ---- ->>>function f1() { -1 > -2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -1 >Emitted(10, 1) Source(8, 1) + SourceIndex(0) ---- ->>> return exports.instance1; -1->^^^^ -2 > ^^^^^^ -3 > ^ -4 > ^^^^^^^^^^^^^^^^^ -5 > ^ -1->export function f1() { - > -2 > return -3 > -4 > instance1 -5 > ; -1->Emitted(11, 5) Source(9, 5) + SourceIndex(0) name (f1) -2 >Emitted(11, 11) Source(9, 11) + SourceIndex(0) name (f1) -3 >Emitted(11, 12) Source(9, 12) + SourceIndex(0) name (f1) -4 >Emitted(11, 29) Source(9, 21) + SourceIndex(0) name (f1) -5 >Emitted(11, 30) Source(9, 22) + SourceIndex(0) name (f1) ---- ->>>} -1 > -2 >^ -3 > ^^^^^^^^^^^^^^^^-> -1 > - > -2 >} -1 >Emitted(12, 1) Source(10, 1) + SourceIndex(0) name (f1) -2 >Emitted(12, 2) Source(10, 2) + SourceIndex(0) name (f1) ---- ->>>exports.f1 = f1; -1-> -2 >^^^^^^^^^^ -3 > ^^^^^ -4 > ^ -5 > ^^^^^^^-> -1-> -2 >f1 -3 > () { - > return instance1; - > } -4 > -1->Emitted(13, 1) Source(8, 17) + SourceIndex(0) -2 >Emitted(13, 11) Source(8, 19) + SourceIndex(0) -3 >Emitted(13, 16) Source(10, 2) + SourceIndex(0) -4 >Emitted(13, 17) Source(10, 2) + SourceIndex(0) ---- ->>>exports.a2 = m1.m1_c1; -1-> -2 >^^^^^^^^^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^ -7 > ^ -8 > ^^^^^^^^^-> -1-> - > - >export var -2 >a2 -3 > = -4 > m1 -5 > . -6 > m1_c1 -7 > ; -1->Emitted(14, 1) Source(12, 12) + SourceIndex(0) -2 >Emitted(14, 11) Source(12, 14) + SourceIndex(0) -3 >Emitted(14, 14) Source(12, 17) + SourceIndex(0) -4 >Emitted(14, 16) Source(12, 19) + SourceIndex(0) -5 >Emitted(14, 17) Source(12, 20) + SourceIndex(0) -6 >Emitted(14, 22) Source(12, 25) + SourceIndex(0) -7 >Emitted(14, 23) Source(12, 26) + SourceIndex(0) ---- ->>>//# sourceMappingURL=test.js.map=================================================================== JsFile: test.js mapUrl: test.js.map sourceRoot: http://typescript.codeplex.com/ diff --git a/tests/baselines/reference/project/sourcerootUrlModuleSimpleSpecifyOutputFile/node/test.d.ts b/tests/baselines/reference/project/sourcerootUrlModuleSimpleSpecifyOutputFile/node/test.d.ts deleted file mode 100644 index 250d2615a79..00000000000 --- a/tests/baselines/reference/project/sourcerootUrlModuleSimpleSpecifyOutputFile/node/test.d.ts +++ /dev/null @@ -1,8 +0,0 @@ -import m1 = require("m1"); -export declare var a1: number; -export declare class c1 { - p1: number; -} -export declare var instance1: c1; -export declare function f1(): c1; -export declare var a2: typeof m1.m1_c1; diff --git a/tests/baselines/reference/project/sourcerootUrlModuleSimpleSpecifyOutputFile/node/test.js b/tests/baselines/reference/project/sourcerootUrlModuleSimpleSpecifyOutputFile/node/test.js deleted file mode 100644 index c2e7dfa443b..00000000000 --- a/tests/baselines/reference/project/sourcerootUrlModuleSimpleSpecifyOutputFile/node/test.js +++ /dev/null @@ -1,15 +0,0 @@ -var m1 = require("m1"); -exports.a1 = 10; -var c1 = (function () { - function c1() { - } - return c1; -})(); -exports.c1 = c1; -exports.instance1 = new c1(); -function f1() { - return exports.instance1; -} -exports.f1 = f1; -exports.a2 = m1.m1_c1; -//# sourceMappingURL=test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcerootUrlModuleSimpleSpecifyOutputFile/node/test.js.map b/tests/baselines/reference/project/sourcerootUrlModuleSimpleSpecifyOutputFile/node/test.js.map deleted file mode 100644 index 41d3e11e995..00000000000 --- a/tests/baselines/reference/project/sourcerootUrlModuleSimpleSpecifyOutputFile/node/test.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"test.js","sourceRoot":"http://typescript.codeplex.com/","sources":["test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AAAA,IAAO,EAAE,WAAW,IAAI,CAAC,CAAC;AACf,UAAE,GAAG,EAAE,CAAC;AACnB;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAFY,UAAE,KAEd,CAAA;AAEU,iBAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AAChC;IACIE,MAAMA,CAACA,iBAASA,CAACA;AACrBA,CAACA;AAFe,UAAE,KAEjB,CAAA;AAEU,UAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcerootUrlModuleSubfolderSpecifyOutputFile/amd/ref/m1.d.ts b/tests/baselines/reference/project/sourcerootUrlModuleSubfolderSpecifyOutputFile/amd/ref/m1.d.ts deleted file mode 100644 index 4a53b24b156..00000000000 --- a/tests/baselines/reference/project/sourcerootUrlModuleSubfolderSpecifyOutputFile/amd/ref/m1.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -export declare var m1_a1: number; -export declare class m1_c1 { - m1_c1_p1: number; -} -export declare var m1_instance1: m1_c1; -export declare function m1_f1(): m1_c1; diff --git a/tests/baselines/reference/project/sourcerootUrlModuleSubfolderSpecifyOutputFile/amd/ref/m1.js b/tests/baselines/reference/project/sourcerootUrlModuleSubfolderSpecifyOutputFile/amd/ref/m1.js deleted file mode 100644 index bbaba444ba2..00000000000 --- a/tests/baselines/reference/project/sourcerootUrlModuleSubfolderSpecifyOutputFile/amd/ref/m1.js +++ /dev/null @@ -1,15 +0,0 @@ -define(["require", "exports"], function (require, exports) { - exports.m1_a1 = 10; - var m1_c1 = (function () { - function m1_c1() { - } - return m1_c1; - })(); - exports.m1_c1 = m1_c1; - exports.m1_instance1 = new m1_c1(); - function m1_f1() { - return exports.m1_instance1; - } - exports.m1_f1 = m1_f1; -}); -//# sourceMappingURL=m1.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcerootUrlModuleSubfolderSpecifyOutputFile/amd/ref/m1.js.map b/tests/baselines/reference/project/sourcerootUrlModuleSubfolderSpecifyOutputFile/amd/ref/m1.js.map deleted file mode 100644 index 6c5413f630e..00000000000 --- a/tests/baselines/reference/project/sourcerootUrlModuleSubfolderSpecifyOutputFile/amd/ref/m1.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"m1.js","sourceRoot":"http://typescript.codeplex.com/","sources":["ref/m1.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1"],"mappings":";IAAW,aAAK,GAAG,EAAE,CAAC;IACtB;QAAAA;QAEAC,CAACA;QAADD,YAACA;IAADA,CAACA,AAFD,IAEC;IAFY,aAAK,QAEjB,CAAA;IAEU,oBAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACIE,MAAMA,CAACA,oBAAYA,CAACA;IACxBA,CAACA;IAFe,aAAK,QAEpB,CAAA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcerootUrlModuleSubfolderSpecifyOutputFile/amd/sourcerootUrlModuleSubfolderSpecifyOutputFile.json b/tests/baselines/reference/project/sourcerootUrlModuleSubfolderSpecifyOutputFile/amd/sourcerootUrlModuleSubfolderSpecifyOutputFile.json index d80dacb3444..e1f6d3c6e36 100644 --- a/tests/baselines/reference/project/sourcerootUrlModuleSubfolderSpecifyOutputFile/amd/sourcerootUrlModuleSubfolderSpecifyOutputFile.json +++ b/tests/baselines/reference/project/sourcerootUrlModuleSubfolderSpecifyOutputFile/amd/sourcerootUrlModuleSubfolderSpecifyOutputFile.json @@ -15,12 +15,6 @@ "test.ts" ], "emittedFiles": [ - "ref/m1.js.map", - "ref/m1.js", - "ref/m1.d.ts", - "test.js.map", - "test.js", - "test.d.ts", "bin/test.js.map", "bin/test.js", "bin/test.d.ts" diff --git a/tests/baselines/reference/project/sourcerootUrlModuleSubfolderSpecifyOutputFile/amd/sourcerootUrlModuleSubfolderSpecifyOutputFile.sourcemap.txt b/tests/baselines/reference/project/sourcerootUrlModuleSubfolderSpecifyOutputFile/amd/sourcerootUrlModuleSubfolderSpecifyOutputFile.sourcemap.txt index a5d445804bf..54624487a57 100644 --- a/tests/baselines/reference/project/sourcerootUrlModuleSubfolderSpecifyOutputFile/amd/sourcerootUrlModuleSubfolderSpecifyOutputFile.sourcemap.txt +++ b/tests/baselines/reference/project/sourcerootUrlModuleSubfolderSpecifyOutputFile/amd/sourcerootUrlModuleSubfolderSpecifyOutputFile.sourcemap.txt @@ -1,375 +1,4 @@ =================================================================== -JsFile: m1.js -mapUrl: m1.js.map -sourceRoot: http://typescript.codeplex.com/ -sources: ref/m1.ts -=================================================================== -------------------------------------------------------------------- -emittedFile:ref/m1.js -sourceFile:ref/m1.ts -------------------------------------------------------------------- ->>>define(["require", "exports"], function (require, exports) { ->>> exports.m1_a1 = 10; -1 >^^^^ -2 > ^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^-> -1 >export var -2 > m1_a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(2, 5) Source(1, 12) + SourceIndex(0) -2 >Emitted(2, 18) Source(1, 17) + SourceIndex(0) -3 >Emitted(2, 21) Source(1, 20) + SourceIndex(0) -4 >Emitted(2, 23) Source(1, 22) + SourceIndex(0) -5 >Emitted(2, 24) Source(1, 23) + SourceIndex(0) ---- ->>> var m1_c1 = (function () { -1->^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^^^^-> -1-> - > -1->Emitted(3, 5) Source(2, 1) + SourceIndex(0) ---- ->>> function m1_c1() { -1->^^^^^^^^ -2 > ^^-> -1-> -1->Emitted(4, 9) Source(2, 1) + SourceIndex(0) name (m1_c1) ---- ->>> } -1->^^^^^^^^ -2 > ^ -3 > ^^^^^^^^^^^^^-> -1->export class m1_c1 { - > public m1_c1_p1: number; - > -2 > } -1->Emitted(5, 9) Source(4, 1) + SourceIndex(0) name (m1_c1.constructor) -2 >Emitted(5, 10) Source(4, 2) + SourceIndex(0) name (m1_c1.constructor) ---- ->>> return m1_c1; -1->^^^^^^^^ -2 > ^^^^^^^^^^^^ -1-> -2 > } -1->Emitted(6, 9) Source(4, 1) + SourceIndex(0) name (m1_c1) -2 >Emitted(6, 21) Source(4, 2) + SourceIndex(0) name (m1_c1) ---- ->>> })(); -1 >^^^^ -2 > ^ -3 > -4 > ^^^^ -5 > ^^^^^^^^^^^^^^^^^^-> -1 > -2 > } -3 > -4 > export class m1_c1 { - > public m1_c1_p1: number; - > } -1 >Emitted(7, 5) Source(4, 1) + SourceIndex(0) name (m1_c1) -2 >Emitted(7, 6) Source(4, 2) + SourceIndex(0) name (m1_c1) -3 >Emitted(7, 6) Source(2, 1) + SourceIndex(0) -4 >Emitted(7, 10) Source(4, 2) + SourceIndex(0) ---- ->>> exports.m1_c1 = m1_c1; -1->^^^^ -2 > ^^^^^^^^^^^^^ -3 > ^^^^^^^^ -4 > ^ -5 > ^^^^^^^^^^^^^^-> -1-> -2 > m1_c1 -3 > { - > public m1_c1_p1: number; - > } -4 > -1->Emitted(8, 5) Source(2, 14) + SourceIndex(0) -2 >Emitted(8, 18) Source(2, 19) + SourceIndex(0) -3 >Emitted(8, 26) Source(4, 2) + SourceIndex(0) -4 >Emitted(8, 27) Source(4, 2) + SourceIndex(0) ---- ->>> exports.m1_instance1 = new m1_c1(); -1->^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^^^ -5 > ^^^^^ -6 > ^^ -7 > ^ -1-> - > - >export var -2 > m1_instance1 -3 > = -4 > new -5 > m1_c1 -6 > () -7 > ; -1->Emitted(9, 5) Source(6, 12) + SourceIndex(0) -2 >Emitted(9, 25) Source(6, 24) + SourceIndex(0) -3 >Emitted(9, 28) Source(6, 27) + SourceIndex(0) -4 >Emitted(9, 32) Source(6, 31) + SourceIndex(0) -5 >Emitted(9, 37) Source(6, 36) + SourceIndex(0) -6 >Emitted(9, 39) Source(6, 38) + SourceIndex(0) -7 >Emitted(9, 40) Source(6, 39) + SourceIndex(0) ---- ->>> function m1_f1() { -1 >^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -1 >Emitted(10, 5) Source(7, 1) + SourceIndex(0) ---- ->>> return exports.m1_instance1; -1->^^^^^^^^ -2 > ^^^^^^ -3 > ^ -4 > ^^^^^^^^^^^^^^^^^^^^ -5 > ^ -1->export function m1_f1() { - > -2 > return -3 > -4 > m1_instance1 -5 > ; -1->Emitted(11, 9) Source(8, 5) + SourceIndex(0) name (m1_f1) -2 >Emitted(11, 15) Source(8, 11) + SourceIndex(0) name (m1_f1) -3 >Emitted(11, 16) Source(8, 12) + SourceIndex(0) name (m1_f1) -4 >Emitted(11, 36) Source(8, 24) + SourceIndex(0) name (m1_f1) -5 >Emitted(11, 37) Source(8, 25) + SourceIndex(0) name (m1_f1) ---- ->>> } -1 >^^^^ -2 > ^ -3 > ^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -2 > } -1 >Emitted(12, 5) Source(9, 1) + SourceIndex(0) name (m1_f1) -2 >Emitted(12, 6) Source(9, 2) + SourceIndex(0) name (m1_f1) ---- ->>> exports.m1_f1 = m1_f1; -1->^^^^ -2 > ^^^^^^^^^^^^^ -3 > ^^^^^^^^ -4 > ^ -1-> -2 > m1_f1 -3 > () { - > return m1_instance1; - > } -4 > -1->Emitted(13, 5) Source(7, 17) + SourceIndex(0) -2 >Emitted(13, 18) Source(7, 22) + SourceIndex(0) -3 >Emitted(13, 26) Source(9, 2) + SourceIndex(0) -4 >Emitted(13, 27) Source(9, 2) + SourceIndex(0) ---- ->>>}); ->>>//# sourceMappingURL=m1.js.map=================================================================== -JsFile: test.js -mapUrl: test.js.map -sourceRoot: http://typescript.codeplex.com/ -sources: test.ts -=================================================================== -------------------------------------------------------------------- -emittedFile:test.js -sourceFile:test.ts -------------------------------------------------------------------- ->>>define(["require", "exports", "ref/m1"], function (require, exports, m1) { ->>> exports.a1 = 10; -1 >^^^^ -2 > ^^^^^^^^^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^-> -1 >import m1 = require("ref/m1"); - >export var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(2, 5) Source(2, 12) + SourceIndex(0) -2 >Emitted(2, 15) Source(2, 14) + SourceIndex(0) -3 >Emitted(2, 18) Source(2, 17) + SourceIndex(0) -4 >Emitted(2, 20) Source(2, 19) + SourceIndex(0) -5 >Emitted(2, 21) Source(2, 20) + SourceIndex(0) ---- ->>> var c1 = (function () { -1->^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^-> -1-> - > -1->Emitted(3, 5) Source(3, 1) + SourceIndex(0) ---- ->>> function c1() { -1->^^^^^^^^ -2 > ^^-> -1-> -1->Emitted(4, 9) Source(3, 1) + SourceIndex(0) name (c1) ---- ->>> } -1->^^^^^^^^ -2 > ^ -3 > ^^^^^^^^^^-> -1->export class c1 { - > public p1: number; - > -2 > } -1->Emitted(5, 9) Source(5, 1) + SourceIndex(0) name (c1.constructor) -2 >Emitted(5, 10) Source(5, 2) + SourceIndex(0) name (c1.constructor) ---- ->>> return c1; -1->^^^^^^^^ -2 > ^^^^^^^^^ -1-> -2 > } -1->Emitted(6, 9) Source(5, 1) + SourceIndex(0) name (c1) -2 >Emitted(6, 18) Source(5, 2) + SourceIndex(0) name (c1) ---- ->>> })(); -1 >^^^^ -2 > ^ -3 > -4 > ^^^^ -5 > ^^^^^^^^^^^^-> -1 > -2 > } -3 > -4 > export class c1 { - > public p1: number; - > } -1 >Emitted(7, 5) Source(5, 1) + SourceIndex(0) name (c1) -2 >Emitted(7, 6) Source(5, 2) + SourceIndex(0) name (c1) -3 >Emitted(7, 6) Source(3, 1) + SourceIndex(0) -4 >Emitted(7, 10) Source(5, 2) + SourceIndex(0) ---- ->>> exports.c1 = c1; -1->^^^^ -2 > ^^^^^^^^^^ -3 > ^^^^^ -4 > ^ -5 > ^^^^^^^^^^^^^^-> -1-> -2 > c1 -3 > { - > public p1: number; - > } -4 > -1->Emitted(8, 5) Source(3, 14) + SourceIndex(0) -2 >Emitted(8, 15) Source(3, 16) + SourceIndex(0) -3 >Emitted(8, 20) Source(5, 2) + SourceIndex(0) -4 >Emitted(8, 21) Source(5, 2) + SourceIndex(0) ---- ->>> exports.instance1 = new c1(); -1->^^^^ -2 > ^^^^^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^^^ -5 > ^^ -6 > ^^ -7 > ^ -1-> - > - >export var -2 > instance1 -3 > = -4 > new -5 > c1 -6 > () -7 > ; -1->Emitted(9, 5) Source(7, 12) + SourceIndex(0) -2 >Emitted(9, 22) Source(7, 21) + SourceIndex(0) -3 >Emitted(9, 25) Source(7, 24) + SourceIndex(0) -4 >Emitted(9, 29) Source(7, 28) + SourceIndex(0) -5 >Emitted(9, 31) Source(7, 30) + SourceIndex(0) -6 >Emitted(9, 33) Source(7, 32) + SourceIndex(0) -7 >Emitted(9, 34) Source(7, 33) + SourceIndex(0) ---- ->>> function f1() { -1 >^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -1 >Emitted(10, 5) Source(8, 1) + SourceIndex(0) ---- ->>> return exports.instance1; -1->^^^^^^^^ -2 > ^^^^^^ -3 > ^ -4 > ^^^^^^^^^^^^^^^^^ -5 > ^ -1->export function f1() { - > -2 > return -3 > -4 > instance1 -5 > ; -1->Emitted(11, 9) Source(9, 5) + SourceIndex(0) name (f1) -2 >Emitted(11, 15) Source(9, 11) + SourceIndex(0) name (f1) -3 >Emitted(11, 16) Source(9, 12) + SourceIndex(0) name (f1) -4 >Emitted(11, 33) Source(9, 21) + SourceIndex(0) name (f1) -5 >Emitted(11, 34) Source(9, 22) + SourceIndex(0) name (f1) ---- ->>> } -1 >^^^^ -2 > ^ -3 > ^^^^^^^^^^^^^^^^-> -1 > - > -2 > } -1 >Emitted(12, 5) Source(10, 1) + SourceIndex(0) name (f1) -2 >Emitted(12, 6) Source(10, 2) + SourceIndex(0) name (f1) ---- ->>> exports.f1 = f1; -1->^^^^ -2 > ^^^^^^^^^^ -3 > ^^^^^ -4 > ^ -5 > ^^^^^^^-> -1-> -2 > f1 -3 > () { - > return instance1; - > } -4 > -1->Emitted(13, 5) Source(8, 17) + SourceIndex(0) -2 >Emitted(13, 15) Source(8, 19) + SourceIndex(0) -3 >Emitted(13, 20) Source(10, 2) + SourceIndex(0) -4 >Emitted(13, 21) Source(10, 2) + SourceIndex(0) ---- ->>> exports.a2 = m1.m1_c1; -1->^^^^ -2 > ^^^^^^^^^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^ -7 > ^ -1-> - > - >export var -2 > a2 -3 > = -4 > m1 -5 > . -6 > m1_c1 -7 > ; -1->Emitted(14, 5) Source(12, 12) + SourceIndex(0) -2 >Emitted(14, 15) Source(12, 14) + SourceIndex(0) -3 >Emitted(14, 18) Source(12, 17) + SourceIndex(0) -4 >Emitted(14, 20) Source(12, 19) + SourceIndex(0) -5 >Emitted(14, 21) Source(12, 20) + SourceIndex(0) -6 >Emitted(14, 26) Source(12, 25) + SourceIndex(0) -7 >Emitted(14, 27) Source(12, 26) + SourceIndex(0) ---- ->>>}); ->>>//# sourceMappingURL=test.js.map=================================================================== JsFile: test.js mapUrl: test.js.map sourceRoot: http://typescript.codeplex.com/ diff --git a/tests/baselines/reference/project/sourcerootUrlModuleSubfolderSpecifyOutputFile/amd/test.d.ts b/tests/baselines/reference/project/sourcerootUrlModuleSubfolderSpecifyOutputFile/amd/test.d.ts deleted file mode 100644 index a61d8541048..00000000000 --- a/tests/baselines/reference/project/sourcerootUrlModuleSubfolderSpecifyOutputFile/amd/test.d.ts +++ /dev/null @@ -1,8 +0,0 @@ -import m1 = require("ref/m1"); -export declare var a1: number; -export declare class c1 { - p1: number; -} -export declare var instance1: c1; -export declare function f1(): c1; -export declare var a2: typeof m1.m1_c1; diff --git a/tests/baselines/reference/project/sourcerootUrlModuleSubfolderSpecifyOutputFile/amd/test.js b/tests/baselines/reference/project/sourcerootUrlModuleSubfolderSpecifyOutputFile/amd/test.js deleted file mode 100644 index 6c8aeb3190b..00000000000 --- a/tests/baselines/reference/project/sourcerootUrlModuleSubfolderSpecifyOutputFile/amd/test.js +++ /dev/null @@ -1,16 +0,0 @@ -define(["require", "exports", "ref/m1"], function (require, exports, m1) { - exports.a1 = 10; - var c1 = (function () { - function c1() { - } - return c1; - })(); - exports.c1 = c1; - exports.instance1 = new c1(); - function f1() { - return exports.instance1; - } - exports.f1 = f1; - exports.a2 = m1.m1_c1; -}); -//# sourceMappingURL=test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcerootUrlModuleSubfolderSpecifyOutputFile/amd/test.js.map b/tests/baselines/reference/project/sourcerootUrlModuleSubfolderSpecifyOutputFile/amd/test.js.map deleted file mode 100644 index a57b57d2b17..00000000000 --- a/tests/baselines/reference/project/sourcerootUrlModuleSubfolderSpecifyOutputFile/amd/test.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"test.js","sourceRoot":"http://typescript.codeplex.com/","sources":["test.ts"],"names":["c1","c1.constructor","f1"],"mappings":";IACW,UAAE,GAAG,EAAE,CAAC;IACnB;QAAAA;QAEAC,CAACA;QAADD,SAACA;IAADA,CAACA,AAFD,IAEC;IAFY,UAAE,KAEd,CAAA;IAEU,iBAAS,GAAG,IAAI,EAAE,EAAE,CAAC;IAChC;QACIE,MAAMA,CAACA,iBAASA,CAACA;IACrBA,CAACA;IAFe,UAAE,KAEjB,CAAA;IAEU,UAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcerootUrlModuleSubfolderSpecifyOutputFile/node/ref/m1.d.ts b/tests/baselines/reference/project/sourcerootUrlModuleSubfolderSpecifyOutputFile/node/ref/m1.d.ts deleted file mode 100644 index 4a53b24b156..00000000000 --- a/tests/baselines/reference/project/sourcerootUrlModuleSubfolderSpecifyOutputFile/node/ref/m1.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -export declare var m1_a1: number; -export declare class m1_c1 { - m1_c1_p1: number; -} -export declare var m1_instance1: m1_c1; -export declare function m1_f1(): m1_c1; diff --git a/tests/baselines/reference/project/sourcerootUrlModuleSubfolderSpecifyOutputFile/node/ref/m1.js b/tests/baselines/reference/project/sourcerootUrlModuleSubfolderSpecifyOutputFile/node/ref/m1.js deleted file mode 100644 index 1b4470e2b37..00000000000 --- a/tests/baselines/reference/project/sourcerootUrlModuleSubfolderSpecifyOutputFile/node/ref/m1.js +++ /dev/null @@ -1,13 +0,0 @@ -exports.m1_a1 = 10; -var m1_c1 = (function () { - function m1_c1() { - } - return m1_c1; -})(); -exports.m1_c1 = m1_c1; -exports.m1_instance1 = new m1_c1(); -function m1_f1() { - return exports.m1_instance1; -} -exports.m1_f1 = m1_f1; -//# sourceMappingURL=m1.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcerootUrlModuleSubfolderSpecifyOutputFile/node/ref/m1.js.map b/tests/baselines/reference/project/sourcerootUrlModuleSubfolderSpecifyOutputFile/node/ref/m1.js.map deleted file mode 100644 index 35e7e9a48dd..00000000000 --- a/tests/baselines/reference/project/sourcerootUrlModuleSubfolderSpecifyOutputFile/node/ref/m1.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"m1.js","sourceRoot":"http://typescript.codeplex.com/","sources":["ref/m1.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1"],"mappings":"AAAW,aAAK,GAAG,EAAE,CAAC;AACtB;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAFY,aAAK,QAEjB,CAAA;AAEU,oBAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACIE,MAAMA,CAACA,oBAAYA,CAACA;AACxBA,CAACA;AAFe,aAAK,QAEpB,CAAA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcerootUrlModuleSubfolderSpecifyOutputFile/node/sourcerootUrlModuleSubfolderSpecifyOutputFile.json b/tests/baselines/reference/project/sourcerootUrlModuleSubfolderSpecifyOutputFile/node/sourcerootUrlModuleSubfolderSpecifyOutputFile.json index d80dacb3444..e1f6d3c6e36 100644 --- a/tests/baselines/reference/project/sourcerootUrlModuleSubfolderSpecifyOutputFile/node/sourcerootUrlModuleSubfolderSpecifyOutputFile.json +++ b/tests/baselines/reference/project/sourcerootUrlModuleSubfolderSpecifyOutputFile/node/sourcerootUrlModuleSubfolderSpecifyOutputFile.json @@ -15,12 +15,6 @@ "test.ts" ], "emittedFiles": [ - "ref/m1.js.map", - "ref/m1.js", - "ref/m1.d.ts", - "test.js.map", - "test.js", - "test.d.ts", "bin/test.js.map", "bin/test.js", "bin/test.d.ts" diff --git a/tests/baselines/reference/project/sourcerootUrlModuleSubfolderSpecifyOutputFile/node/sourcerootUrlModuleSubfolderSpecifyOutputFile.sourcemap.txt b/tests/baselines/reference/project/sourcerootUrlModuleSubfolderSpecifyOutputFile/node/sourcerootUrlModuleSubfolderSpecifyOutputFile.sourcemap.txt index 3f2ad9829b3..2903ad0141c 100644 --- a/tests/baselines/reference/project/sourcerootUrlModuleSubfolderSpecifyOutputFile/node/sourcerootUrlModuleSubfolderSpecifyOutputFile.sourcemap.txt +++ b/tests/baselines/reference/project/sourcerootUrlModuleSubfolderSpecifyOutputFile/node/sourcerootUrlModuleSubfolderSpecifyOutputFile.sourcemap.txt @@ -1,396 +1,4 @@ =================================================================== -JsFile: m1.js -mapUrl: m1.js.map -sourceRoot: http://typescript.codeplex.com/ -sources: ref/m1.ts -=================================================================== -------------------------------------------------------------------- -emittedFile:ref/m1.js -sourceFile:ref/m1.ts -------------------------------------------------------------------- ->>>exports.m1_a1 = 10; -1 > -2 >^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^-> -1 >export var -2 >m1_a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(1, 1) Source(1, 12) + SourceIndex(0) -2 >Emitted(1, 14) Source(1, 17) + SourceIndex(0) -3 >Emitted(1, 17) Source(1, 20) + SourceIndex(0) -4 >Emitted(1, 19) Source(1, 22) + SourceIndex(0) -5 >Emitted(1, 20) Source(1, 23) + SourceIndex(0) ---- ->>>var m1_c1 = (function () { -1-> -2 >^^^^^^^^^^^^^^^^^^^^^^^-> -1-> - > -1->Emitted(2, 1) Source(2, 1) + SourceIndex(0) ---- ->>> function m1_c1() { -1->^^^^ -2 > ^^-> -1-> -1->Emitted(3, 5) Source(2, 1) + SourceIndex(0) name (m1_c1) ---- ->>> } -1->^^^^ -2 > ^ -3 > ^^^^^^^^^^^^^-> -1->export class m1_c1 { - > public m1_c1_p1: number; - > -2 > } -1->Emitted(4, 5) Source(4, 1) + SourceIndex(0) name (m1_c1.constructor) -2 >Emitted(4, 6) Source(4, 2) + SourceIndex(0) name (m1_c1.constructor) ---- ->>> return m1_c1; -1->^^^^ -2 > ^^^^^^^^^^^^ -1-> -2 > } -1->Emitted(5, 5) Source(4, 1) + SourceIndex(0) name (m1_c1) -2 >Emitted(5, 17) Source(4, 2) + SourceIndex(0) name (m1_c1) ---- ->>>})(); -1 > -2 >^ -3 > -4 > ^^^^ -5 > ^^^^^^^^^^^^^^^^^^-> -1 > -2 >} -3 > -4 > export class m1_c1 { - > public m1_c1_p1: number; - > } -1 >Emitted(6, 1) Source(4, 1) + SourceIndex(0) name (m1_c1) -2 >Emitted(6, 2) Source(4, 2) + SourceIndex(0) name (m1_c1) -3 >Emitted(6, 2) Source(2, 1) + SourceIndex(0) -4 >Emitted(6, 6) Source(4, 2) + SourceIndex(0) ---- ->>>exports.m1_c1 = m1_c1; -1-> -2 >^^^^^^^^^^^^^ -3 > ^^^^^^^^ -4 > ^ -5 > ^^^^^^^^^^^^^^-> -1-> -2 >m1_c1 -3 > { - > public m1_c1_p1: number; - > } -4 > -1->Emitted(7, 1) Source(2, 14) + SourceIndex(0) -2 >Emitted(7, 14) Source(2, 19) + SourceIndex(0) -3 >Emitted(7, 22) Source(4, 2) + SourceIndex(0) -4 >Emitted(7, 23) Source(4, 2) + SourceIndex(0) ---- ->>>exports.m1_instance1 = new m1_c1(); -1-> -2 >^^^^^^^^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^^^ -5 > ^^^^^ -6 > ^^ -7 > ^ -1-> - > - >export var -2 >m1_instance1 -3 > = -4 > new -5 > m1_c1 -6 > () -7 > ; -1->Emitted(8, 1) Source(6, 12) + SourceIndex(0) -2 >Emitted(8, 21) Source(6, 24) + SourceIndex(0) -3 >Emitted(8, 24) Source(6, 27) + SourceIndex(0) -4 >Emitted(8, 28) Source(6, 31) + SourceIndex(0) -5 >Emitted(8, 33) Source(6, 36) + SourceIndex(0) -6 >Emitted(8, 35) Source(6, 38) + SourceIndex(0) -7 >Emitted(8, 36) Source(6, 39) + SourceIndex(0) ---- ->>>function m1_f1() { -1 > -2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -1 >Emitted(9, 1) Source(7, 1) + SourceIndex(0) ---- ->>> return exports.m1_instance1; -1->^^^^ -2 > ^^^^^^ -3 > ^ -4 > ^^^^^^^^^^^^^^^^^^^^ -5 > ^ -1->export function m1_f1() { - > -2 > return -3 > -4 > m1_instance1 -5 > ; -1->Emitted(10, 5) Source(8, 5) + SourceIndex(0) name (m1_f1) -2 >Emitted(10, 11) Source(8, 11) + SourceIndex(0) name (m1_f1) -3 >Emitted(10, 12) Source(8, 12) + SourceIndex(0) name (m1_f1) -4 >Emitted(10, 32) Source(8, 24) + SourceIndex(0) name (m1_f1) -5 >Emitted(10, 33) Source(8, 25) + SourceIndex(0) name (m1_f1) ---- ->>>} -1 > -2 >^ -3 > ^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -2 >} -1 >Emitted(11, 1) Source(9, 1) + SourceIndex(0) name (m1_f1) -2 >Emitted(11, 2) Source(9, 2) + SourceIndex(0) name (m1_f1) ---- ->>>exports.m1_f1 = m1_f1; -1-> -2 >^^^^^^^^^^^^^ -3 > ^^^^^^^^ -4 > ^ -5 > ^^^^^^^-> -1-> -2 >m1_f1 -3 > () { - > return m1_instance1; - > } -4 > -1->Emitted(12, 1) Source(7, 17) + SourceIndex(0) -2 >Emitted(12, 14) Source(7, 22) + SourceIndex(0) -3 >Emitted(12, 22) Source(9, 2) + SourceIndex(0) -4 >Emitted(12, 23) Source(9, 2) + SourceIndex(0) ---- ->>>//# sourceMappingURL=m1.js.map=================================================================== -JsFile: test.js -mapUrl: test.js.map -sourceRoot: http://typescript.codeplex.com/ -sources: test.ts -=================================================================== -------------------------------------------------------------------- -emittedFile:test.js -sourceFile:test.ts -------------------------------------------------------------------- ->>>var m1 = require("ref/m1"); -1 > -2 >^^^^ -3 > ^^ -4 > ^^^^^^^^^^^ -5 > ^^^^^^^^ -6 > ^ -7 > ^ -1 > -2 >import -3 > m1 -4 > = require( -5 > "ref/m1" -6 > ) -7 > ; -1 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) -2 >Emitted(1, 5) Source(1, 8) + SourceIndex(0) -3 >Emitted(1, 7) Source(1, 10) + SourceIndex(0) -4 >Emitted(1, 18) Source(1, 21) + SourceIndex(0) -5 >Emitted(1, 26) Source(1, 29) + SourceIndex(0) -6 >Emitted(1, 27) Source(1, 30) + SourceIndex(0) -7 >Emitted(1, 28) Source(1, 31) + SourceIndex(0) ---- ->>>exports.a1 = 10; -1 > -2 >^^^^^^^^^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^-> -1 > - >export var -2 >a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(2, 1) Source(2, 12) + SourceIndex(0) -2 >Emitted(2, 11) Source(2, 14) + SourceIndex(0) -3 >Emitted(2, 14) Source(2, 17) + SourceIndex(0) -4 >Emitted(2, 16) Source(2, 19) + SourceIndex(0) -5 >Emitted(2, 17) Source(2, 20) + SourceIndex(0) ---- ->>>var c1 = (function () { -1-> -2 >^^^^^^^^^^^^^^^^^^^^-> -1-> - > -1->Emitted(3, 1) Source(3, 1) + SourceIndex(0) ---- ->>> function c1() { -1->^^^^ -2 > ^^-> -1-> -1->Emitted(4, 5) Source(3, 1) + SourceIndex(0) name (c1) ---- ->>> } -1->^^^^ -2 > ^ -3 > ^^^^^^^^^^-> -1->export class c1 { - > public p1: number; - > -2 > } -1->Emitted(5, 5) Source(5, 1) + SourceIndex(0) name (c1.constructor) -2 >Emitted(5, 6) Source(5, 2) + SourceIndex(0) name (c1.constructor) ---- ->>> return c1; -1->^^^^ -2 > ^^^^^^^^^ -1-> -2 > } -1->Emitted(6, 5) Source(5, 1) + SourceIndex(0) name (c1) -2 >Emitted(6, 14) Source(5, 2) + SourceIndex(0) name (c1) ---- ->>>})(); -1 > -2 >^ -3 > -4 > ^^^^ -5 > ^^^^^^^^^^^^-> -1 > -2 >} -3 > -4 > export class c1 { - > public p1: number; - > } -1 >Emitted(7, 1) Source(5, 1) + SourceIndex(0) name (c1) -2 >Emitted(7, 2) Source(5, 2) + SourceIndex(0) name (c1) -3 >Emitted(7, 2) Source(3, 1) + SourceIndex(0) -4 >Emitted(7, 6) Source(5, 2) + SourceIndex(0) ---- ->>>exports.c1 = c1; -1-> -2 >^^^^^^^^^^ -3 > ^^^^^ -4 > ^ -5 > ^^^^^^^^^^^^^^-> -1-> -2 >c1 -3 > { - > public p1: number; - > } -4 > -1->Emitted(8, 1) Source(3, 14) + SourceIndex(0) -2 >Emitted(8, 11) Source(3, 16) + SourceIndex(0) -3 >Emitted(8, 16) Source(5, 2) + SourceIndex(0) -4 >Emitted(8, 17) Source(5, 2) + SourceIndex(0) ---- ->>>exports.instance1 = new c1(); -1-> -2 >^^^^^^^^^^^^^^^^^ -3 > ^^^ -4 > ^^^^ -5 > ^^ -6 > ^^ -7 > ^ -1-> - > - >export var -2 >instance1 -3 > = -4 > new -5 > c1 -6 > () -7 > ; -1->Emitted(9, 1) Source(7, 12) + SourceIndex(0) -2 >Emitted(9, 18) Source(7, 21) + SourceIndex(0) -3 >Emitted(9, 21) Source(7, 24) + SourceIndex(0) -4 >Emitted(9, 25) Source(7, 28) + SourceIndex(0) -5 >Emitted(9, 27) Source(7, 30) + SourceIndex(0) -6 >Emitted(9, 29) Source(7, 32) + SourceIndex(0) -7 >Emitted(9, 30) Source(7, 33) + SourceIndex(0) ---- ->>>function f1() { -1 > -2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -1 >Emitted(10, 1) Source(8, 1) + SourceIndex(0) ---- ->>> return exports.instance1; -1->^^^^ -2 > ^^^^^^ -3 > ^ -4 > ^^^^^^^^^^^^^^^^^ -5 > ^ -1->export function f1() { - > -2 > return -3 > -4 > instance1 -5 > ; -1->Emitted(11, 5) Source(9, 5) + SourceIndex(0) name (f1) -2 >Emitted(11, 11) Source(9, 11) + SourceIndex(0) name (f1) -3 >Emitted(11, 12) Source(9, 12) + SourceIndex(0) name (f1) -4 >Emitted(11, 29) Source(9, 21) + SourceIndex(0) name (f1) -5 >Emitted(11, 30) Source(9, 22) + SourceIndex(0) name (f1) ---- ->>>} -1 > -2 >^ -3 > ^^^^^^^^^^^^^^^^-> -1 > - > -2 >} -1 >Emitted(12, 1) Source(10, 1) + SourceIndex(0) name (f1) -2 >Emitted(12, 2) Source(10, 2) + SourceIndex(0) name (f1) ---- ->>>exports.f1 = f1; -1-> -2 >^^^^^^^^^^ -3 > ^^^^^ -4 > ^ -5 > ^^^^^^^-> -1-> -2 >f1 -3 > () { - > return instance1; - > } -4 > -1->Emitted(13, 1) Source(8, 17) + SourceIndex(0) -2 >Emitted(13, 11) Source(8, 19) + SourceIndex(0) -3 >Emitted(13, 16) Source(10, 2) + SourceIndex(0) -4 >Emitted(13, 17) Source(10, 2) + SourceIndex(0) ---- ->>>exports.a2 = m1.m1_c1; -1-> -2 >^^^^^^^^^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^ -7 > ^ -8 > ^^^^^^^^^-> -1-> - > - >export var -2 >a2 -3 > = -4 > m1 -5 > . -6 > m1_c1 -7 > ; -1->Emitted(14, 1) Source(12, 12) + SourceIndex(0) -2 >Emitted(14, 11) Source(12, 14) + SourceIndex(0) -3 >Emitted(14, 14) Source(12, 17) + SourceIndex(0) -4 >Emitted(14, 16) Source(12, 19) + SourceIndex(0) -5 >Emitted(14, 17) Source(12, 20) + SourceIndex(0) -6 >Emitted(14, 22) Source(12, 25) + SourceIndex(0) -7 >Emitted(14, 23) Source(12, 26) + SourceIndex(0) ---- ->>>//# sourceMappingURL=test.js.map=================================================================== JsFile: test.js mapUrl: test.js.map sourceRoot: http://typescript.codeplex.com/ diff --git a/tests/baselines/reference/project/sourcerootUrlModuleSubfolderSpecifyOutputFile/node/test.d.ts b/tests/baselines/reference/project/sourcerootUrlModuleSubfolderSpecifyOutputFile/node/test.d.ts deleted file mode 100644 index a61d8541048..00000000000 --- a/tests/baselines/reference/project/sourcerootUrlModuleSubfolderSpecifyOutputFile/node/test.d.ts +++ /dev/null @@ -1,8 +0,0 @@ -import m1 = require("ref/m1"); -export declare var a1: number; -export declare class c1 { - p1: number; -} -export declare var instance1: c1; -export declare function f1(): c1; -export declare var a2: typeof m1.m1_c1; diff --git a/tests/baselines/reference/project/sourcerootUrlModuleSubfolderSpecifyOutputFile/node/test.js b/tests/baselines/reference/project/sourcerootUrlModuleSubfolderSpecifyOutputFile/node/test.js deleted file mode 100644 index 46c9f29e55a..00000000000 --- a/tests/baselines/reference/project/sourcerootUrlModuleSubfolderSpecifyOutputFile/node/test.js +++ /dev/null @@ -1,15 +0,0 @@ -var m1 = require("ref/m1"); -exports.a1 = 10; -var c1 = (function () { - function c1() { - } - return c1; -})(); -exports.c1 = c1; -exports.instance1 = new c1(); -function f1() { - return exports.instance1; -} -exports.f1 = f1; -exports.a2 = m1.m1_c1; -//# sourceMappingURL=test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcerootUrlModuleSubfolderSpecifyOutputFile/node/test.js.map b/tests/baselines/reference/project/sourcerootUrlModuleSubfolderSpecifyOutputFile/node/test.js.map deleted file mode 100644 index d0638b6c34c..00000000000 --- a/tests/baselines/reference/project/sourcerootUrlModuleSubfolderSpecifyOutputFile/node/test.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"test.js","sourceRoot":"http://typescript.codeplex.com/","sources":["test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AAAA,IAAO,EAAE,WAAW,QAAQ,CAAC,CAAC;AACnB,UAAE,GAAG,EAAE,CAAC;AACnB;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAFY,UAAE,KAEd,CAAA;AAEU,iBAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AAChC;IACIE,MAAMA,CAACA,iBAASA,CAACA;AACrBA,CAACA;AAFe,UAAE,KAEjB,CAAA;AAEU,UAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file From 6aecd43d9a7edca358df3e0ef629e0b2d994c6d0 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Fri, 30 Oct 2015 15:03:44 -0700 Subject: [PATCH 130/227] Fix `isConstructorParameter` --- src/compiler/checker.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index a1207d023c7..6ea8d896326 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -4427,10 +4427,17 @@ namespace ts { error(node, Diagnostics.A_this_type_is_available_only_in_a_non_static_member_of_a_class_or_interface); return unknownType; - function isConstructorParameter(node: TypeNode, container: Node) { + function isConstructorParameter(node: Node, container: Node) { if (container.kind === SyntaxKind.Constructor) { let ctor = (container); - return !ctor.body.statements.some(st => st === node.parent); + while (node && node !== ctor) { + if (node === ctor.body) { + return false; + } + node = node.parent; + } + + return true; } } } From c3c9e513a816305829051e5f6573b9372ac8f767 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Fri, 30 Oct 2015 15:24:34 -0700 Subject: [PATCH 131/227] Added failing test. --- .../conformance/es6/for-ofStatements/for-of58.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 tests/cases/conformance/es6/for-ofStatements/for-of58.ts diff --git a/tests/cases/conformance/es6/for-ofStatements/for-of58.ts b/tests/cases/conformance/es6/for-ofStatements/for-of58.ts new file mode 100644 index 00000000000..9f646e2c851 --- /dev/null +++ b/tests/cases/conformance/es6/for-ofStatements/for-of58.ts @@ -0,0 +1,12 @@ +//@target: ES5 + +var array = [1,2,3]; +var sum = 0; + +for (let num of array) { + if (sum === 0) { + array = [4,5,6] + } + + sum += num; +} \ No newline at end of file From f36b6ab8f94ce66499cb63185da44ca660c0d4e1 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Fri, 30 Oct 2015 15:30:59 -0700 Subject: [PATCH 132/227] Accepted baselines. --- tests/baselines/reference/for-of58.js | 23 ++++++++++++++ tests/baselines/reference/for-of58.symbols | 23 ++++++++++++++ tests/baselines/reference/for-of58.types | 36 ++++++++++++++++++++++ 3 files changed, 82 insertions(+) create mode 100644 tests/baselines/reference/for-of58.js create mode 100644 tests/baselines/reference/for-of58.symbols create mode 100644 tests/baselines/reference/for-of58.types diff --git a/tests/baselines/reference/for-of58.js b/tests/baselines/reference/for-of58.js new file mode 100644 index 00000000000..196d2d4a15d --- /dev/null +++ b/tests/baselines/reference/for-of58.js @@ -0,0 +1,23 @@ +//// [for-of58.ts] + +var array = [1,2,3]; +var sum = 0; + +for (let num of array) { + if (sum === 0) { + array = [4,5,6] + } + + sum += num; +} + +//// [for-of58.js] +var array = [1, 2, 3]; +var sum = 0; +for (var _i = 0; _i < array.length; _i++) { + var num = array[_i]; + if (sum === 0) { + array = [4, 5, 6]; + } + sum += num; +} diff --git a/tests/baselines/reference/for-of58.symbols b/tests/baselines/reference/for-of58.symbols new file mode 100644 index 00000000000..cb7fa87e22d --- /dev/null +++ b/tests/baselines/reference/for-of58.symbols @@ -0,0 +1,23 @@ +=== tests/cases/conformance/es6/for-ofStatements/for-of58.ts === + +var array = [1,2,3]; +>array : Symbol(array, Decl(for-of58.ts, 1, 3)) + +var sum = 0; +>sum : Symbol(sum, Decl(for-of58.ts, 2, 3)) + +for (let num of array) { +>num : Symbol(num, Decl(for-of58.ts, 4, 8)) +>array : Symbol(array, Decl(for-of58.ts, 1, 3)) + + if (sum === 0) { +>sum : Symbol(sum, Decl(for-of58.ts, 2, 3)) + + array = [4,5,6] +>array : Symbol(array, Decl(for-of58.ts, 1, 3)) + } + + sum += num; +>sum : Symbol(sum, Decl(for-of58.ts, 2, 3)) +>num : Symbol(num, Decl(for-of58.ts, 4, 8)) +} diff --git a/tests/baselines/reference/for-of58.types b/tests/baselines/reference/for-of58.types new file mode 100644 index 00000000000..b82fdfd8483 --- /dev/null +++ b/tests/baselines/reference/for-of58.types @@ -0,0 +1,36 @@ +=== tests/cases/conformance/es6/for-ofStatements/for-of58.ts === + +var array = [1,2,3]; +>array : number[] +>[1,2,3] : number[] +>1 : number +>2 : number +>3 : number + +var sum = 0; +>sum : number +>0 : number + +for (let num of array) { +>num : number +>array : number[] + + if (sum === 0) { +>sum === 0 : boolean +>sum : number +>0 : number + + array = [4,5,6] +>array = [4,5,6] : number[] +>array : number[] +>[4,5,6] : number[] +>4 : number +>5 : number +>6 : number + } + + sum += num; +>sum += num : number +>sum : number +>num : number +} From d4d60783ebf1f519c6b8a95105e63831e8daa420 Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Fri, 30 Oct 2015 15:53:44 -0700 Subject: [PATCH 133/227] accept new baselines postmerge --- ...tAbsolutePathModuleMultifolderSpecifyOutputFile.errors.txt | 4 ++-- ...apRootAbsolutePathModuleSimpleSpecifyOutputFile.errors.txt | 2 +- ...ootAbsolutePathModuleSubfolderSpecifyOutputFile.errors.txt | 2 +- ...tRelativePathModuleMultifolderSpecifyOutputFile.errors.txt | 4 ++-- ...apRootRelativePathModuleSimpleSpecifyOutputFile.errors.txt | 2 +- ...ootRelativePathModuleSubfolderSpecifyOutputFile.errors.txt | 2 +- .../maprootUrlModuleMultifolderSpecifyOutputFile.errors.txt | 4 ++-- .../node/maprootUrlModuleSimpleSpecifyOutputFile.errors.txt | 2 +- .../maprootUrlModuleSubfolderSpecifyOutputFile.errors.txt | 2 +- ...sourcerootUrlModuleMultifolderSpecifyOutputFile.errors.txt | 4 ++-- ...otUrlsourcerootUrlModuleSimpleSpecifyOutputFile.errors.txt | 2 +- ...rlsourcerootUrlModuleSubfolderSpecifyOutputFile.errors.txt | 2 +- .../node/outModuleMultifolderSpecifyOutputFile.errors.txt | 4 ++-- .../node/outModuleSimpleSpecifyOutputFile.errors.txt | 2 +- .../node/outModuleSubfolderSpecifyOutputFile.errors.txt | 2 +- ...tAbsolutePathModuleMultifolderSpecifyOutputFile.errors.txt | 4 ++-- ...ceRootAbsolutePathModuleSimpleSpecifyOutputFile.errors.txt | 2 +- ...ootAbsolutePathModuleSubfolderSpecifyOutputFile.errors.txt | 2 +- ...tRelativePathModuleMultifolderSpecifyOutputFile.errors.txt | 4 ++-- ...ceRootRelativePathModuleSimpleSpecifyOutputFile.errors.txt | 2 +- ...ootRelativePathModuleSubfolderSpecifyOutputFile.errors.txt | 2 +- .../sourcemapModuleMultifolderSpecifyOutputFile.errors.txt | 4 ++-- .../node/sourcemapModuleSimpleSpecifyOutputFile.errors.txt | 2 +- .../node/sourcemapModuleSubfolderSpecifyOutputFile.errors.txt | 2 +- ...sourcerootUrlModuleMultifolderSpecifyOutputFile.errors.txt | 4 ++-- .../sourcerootUrlModuleSimpleSpecifyOutputFile.errors.txt | 2 +- .../sourcerootUrlModuleSubfolderSpecifyOutputFile.errors.txt | 2 +- 27 files changed, 36 insertions(+), 36 deletions(-) diff --git a/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderSpecifyOutputFile/node/mapRootAbsolutePathModuleMultifolderSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderSpecifyOutputFile/node/mapRootAbsolutePathModuleMultifolderSpecifyOutputFile.errors.txt index 20fc9c39de5..f705eb8105e 100644 --- a/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderSpecifyOutputFile/node/mapRootAbsolutePathModuleMultifolderSpecifyOutputFile.errors.txt +++ b/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderSpecifyOutputFile/node/mapRootAbsolutePathModuleMultifolderSpecifyOutputFile.errors.txt @@ -2,7 +2,7 @@ error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. !!! error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. -==== ref/m1.ts (0 errors) ==== +==== G:/ts/typescript/tests/cases/projects/outputdir_module_multifolder/ref/m1.ts (0 errors) ==== export var m1_a1 = 10; export class m1_c1 { public m1_c1_p1: number; @@ -12,7 +12,7 @@ error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. export function m1_f1() { return m1_instance1; } -==== ../outputdir_module_multifolder_ref/m2.ts (0 errors) ==== +==== G:/ts/typescript/tests/cases/projects/outputdir_module_multifolder_ref/m2.ts (0 errors) ==== export var m2_a1 = 10; export class m2_c1 { public m2_c1_p1: number; diff --git a/tests/baselines/reference/project/mapRootAbsolutePathModuleSimpleSpecifyOutputFile/node/mapRootAbsolutePathModuleSimpleSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/mapRootAbsolutePathModuleSimpleSpecifyOutputFile/node/mapRootAbsolutePathModuleSimpleSpecifyOutputFile.errors.txt index 12592331fb5..0cf639d7f1c 100644 --- a/tests/baselines/reference/project/mapRootAbsolutePathModuleSimpleSpecifyOutputFile/node/mapRootAbsolutePathModuleSimpleSpecifyOutputFile.errors.txt +++ b/tests/baselines/reference/project/mapRootAbsolutePathModuleSimpleSpecifyOutputFile/node/mapRootAbsolutePathModuleSimpleSpecifyOutputFile.errors.txt @@ -2,7 +2,7 @@ error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. !!! error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. -==== m1.ts (0 errors) ==== +==== G:/ts/typescript/tests/cases/projects/outputdir_module_simple/m1.ts (0 errors) ==== export var m1_a1 = 10; export class m1_c1 { public m1_c1_p1: number; diff --git a/tests/baselines/reference/project/mapRootAbsolutePathModuleSubfolderSpecifyOutputFile/node/mapRootAbsolutePathModuleSubfolderSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/mapRootAbsolutePathModuleSubfolderSpecifyOutputFile/node/mapRootAbsolutePathModuleSubfolderSpecifyOutputFile.errors.txt index bbe6b1772ae..676e800a45e 100644 --- a/tests/baselines/reference/project/mapRootAbsolutePathModuleSubfolderSpecifyOutputFile/node/mapRootAbsolutePathModuleSubfolderSpecifyOutputFile.errors.txt +++ b/tests/baselines/reference/project/mapRootAbsolutePathModuleSubfolderSpecifyOutputFile/node/mapRootAbsolutePathModuleSubfolderSpecifyOutputFile.errors.txt @@ -2,7 +2,7 @@ error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. !!! error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. -==== ref/m1.ts (0 errors) ==== +==== G:/ts/typescript/tests/cases/projects/outputdir_module_subfolder/ref/m1.ts (0 errors) ==== export var m1_a1 = 10; export class m1_c1 { public m1_c1_p1: number; diff --git a/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderSpecifyOutputFile/node/mapRootRelativePathModuleMultifolderSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderSpecifyOutputFile/node/mapRootRelativePathModuleMultifolderSpecifyOutputFile.errors.txt index 20fc9c39de5..f705eb8105e 100644 --- a/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderSpecifyOutputFile/node/mapRootRelativePathModuleMultifolderSpecifyOutputFile.errors.txt +++ b/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderSpecifyOutputFile/node/mapRootRelativePathModuleMultifolderSpecifyOutputFile.errors.txt @@ -2,7 +2,7 @@ error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. !!! error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. -==== ref/m1.ts (0 errors) ==== +==== G:/ts/typescript/tests/cases/projects/outputdir_module_multifolder/ref/m1.ts (0 errors) ==== export var m1_a1 = 10; export class m1_c1 { public m1_c1_p1: number; @@ -12,7 +12,7 @@ error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. export function m1_f1() { return m1_instance1; } -==== ../outputdir_module_multifolder_ref/m2.ts (0 errors) ==== +==== G:/ts/typescript/tests/cases/projects/outputdir_module_multifolder_ref/m2.ts (0 errors) ==== export var m2_a1 = 10; export class m2_c1 { public m2_c1_p1: number; diff --git a/tests/baselines/reference/project/mapRootRelativePathModuleSimpleSpecifyOutputFile/node/mapRootRelativePathModuleSimpleSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/mapRootRelativePathModuleSimpleSpecifyOutputFile/node/mapRootRelativePathModuleSimpleSpecifyOutputFile.errors.txt index 12592331fb5..0cf639d7f1c 100644 --- a/tests/baselines/reference/project/mapRootRelativePathModuleSimpleSpecifyOutputFile/node/mapRootRelativePathModuleSimpleSpecifyOutputFile.errors.txt +++ b/tests/baselines/reference/project/mapRootRelativePathModuleSimpleSpecifyOutputFile/node/mapRootRelativePathModuleSimpleSpecifyOutputFile.errors.txt @@ -2,7 +2,7 @@ error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. !!! error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. -==== m1.ts (0 errors) ==== +==== G:/ts/typescript/tests/cases/projects/outputdir_module_simple/m1.ts (0 errors) ==== export var m1_a1 = 10; export class m1_c1 { public m1_c1_p1: number; diff --git a/tests/baselines/reference/project/mapRootRelativePathModuleSubfolderSpecifyOutputFile/node/mapRootRelativePathModuleSubfolderSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/mapRootRelativePathModuleSubfolderSpecifyOutputFile/node/mapRootRelativePathModuleSubfolderSpecifyOutputFile.errors.txt index bbe6b1772ae..676e800a45e 100644 --- a/tests/baselines/reference/project/mapRootRelativePathModuleSubfolderSpecifyOutputFile/node/mapRootRelativePathModuleSubfolderSpecifyOutputFile.errors.txt +++ b/tests/baselines/reference/project/mapRootRelativePathModuleSubfolderSpecifyOutputFile/node/mapRootRelativePathModuleSubfolderSpecifyOutputFile.errors.txt @@ -2,7 +2,7 @@ error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. !!! error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. -==== ref/m1.ts (0 errors) ==== +==== G:/ts/typescript/tests/cases/projects/outputdir_module_subfolder/ref/m1.ts (0 errors) ==== export var m1_a1 = 10; export class m1_c1 { public m1_c1_p1: number; diff --git a/tests/baselines/reference/project/maprootUrlModuleMultifolderSpecifyOutputFile/node/maprootUrlModuleMultifolderSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/maprootUrlModuleMultifolderSpecifyOutputFile/node/maprootUrlModuleMultifolderSpecifyOutputFile.errors.txt index 20fc9c39de5..f705eb8105e 100644 --- a/tests/baselines/reference/project/maprootUrlModuleMultifolderSpecifyOutputFile/node/maprootUrlModuleMultifolderSpecifyOutputFile.errors.txt +++ b/tests/baselines/reference/project/maprootUrlModuleMultifolderSpecifyOutputFile/node/maprootUrlModuleMultifolderSpecifyOutputFile.errors.txt @@ -2,7 +2,7 @@ error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. !!! error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. -==== ref/m1.ts (0 errors) ==== +==== G:/ts/typescript/tests/cases/projects/outputdir_module_multifolder/ref/m1.ts (0 errors) ==== export var m1_a1 = 10; export class m1_c1 { public m1_c1_p1: number; @@ -12,7 +12,7 @@ error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. export function m1_f1() { return m1_instance1; } -==== ../outputdir_module_multifolder_ref/m2.ts (0 errors) ==== +==== G:/ts/typescript/tests/cases/projects/outputdir_module_multifolder_ref/m2.ts (0 errors) ==== export var m2_a1 = 10; export class m2_c1 { public m2_c1_p1: number; diff --git a/tests/baselines/reference/project/maprootUrlModuleSimpleSpecifyOutputFile/node/maprootUrlModuleSimpleSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/maprootUrlModuleSimpleSpecifyOutputFile/node/maprootUrlModuleSimpleSpecifyOutputFile.errors.txt index 12592331fb5..0cf639d7f1c 100644 --- a/tests/baselines/reference/project/maprootUrlModuleSimpleSpecifyOutputFile/node/maprootUrlModuleSimpleSpecifyOutputFile.errors.txt +++ b/tests/baselines/reference/project/maprootUrlModuleSimpleSpecifyOutputFile/node/maprootUrlModuleSimpleSpecifyOutputFile.errors.txt @@ -2,7 +2,7 @@ error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. !!! error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. -==== m1.ts (0 errors) ==== +==== G:/ts/typescript/tests/cases/projects/outputdir_module_simple/m1.ts (0 errors) ==== export var m1_a1 = 10; export class m1_c1 { public m1_c1_p1: number; diff --git a/tests/baselines/reference/project/maprootUrlModuleSubfolderSpecifyOutputFile/node/maprootUrlModuleSubfolderSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/maprootUrlModuleSubfolderSpecifyOutputFile/node/maprootUrlModuleSubfolderSpecifyOutputFile.errors.txt index bbe6b1772ae..676e800a45e 100644 --- a/tests/baselines/reference/project/maprootUrlModuleSubfolderSpecifyOutputFile/node/maprootUrlModuleSubfolderSpecifyOutputFile.errors.txt +++ b/tests/baselines/reference/project/maprootUrlModuleSubfolderSpecifyOutputFile/node/maprootUrlModuleSubfolderSpecifyOutputFile.errors.txt @@ -2,7 +2,7 @@ error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. !!! error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. -==== ref/m1.ts (0 errors) ==== +==== G:/ts/typescript/tests/cases/projects/outputdir_module_subfolder/ref/m1.ts (0 errors) ==== export var m1_a1 = 10; export class m1_c1 { public m1_c1_p1: number; diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputFile/node/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputFile/node/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputFile.errors.txt index 20fc9c39de5..f705eb8105e 100644 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputFile/node/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputFile.errors.txt +++ b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputFile/node/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputFile.errors.txt @@ -2,7 +2,7 @@ error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. !!! error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. -==== ref/m1.ts (0 errors) ==== +==== G:/ts/typescript/tests/cases/projects/outputdir_module_multifolder/ref/m1.ts (0 errors) ==== export var m1_a1 = 10; export class m1_c1 { public m1_c1_p1: number; @@ -12,7 +12,7 @@ error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. export function m1_f1() { return m1_instance1; } -==== ../outputdir_module_multifolder_ref/m2.ts (0 errors) ==== +==== G:/ts/typescript/tests/cases/projects/outputdir_module_multifolder_ref/m2.ts (0 errors) ==== export var m2_a1 = 10; export class m2_c1 { public m2_c1_p1: number; diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSimpleSpecifyOutputFile/node/maprootUrlsourcerootUrlModuleSimpleSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSimpleSpecifyOutputFile/node/maprootUrlsourcerootUrlModuleSimpleSpecifyOutputFile.errors.txt index 12592331fb5..0cf639d7f1c 100644 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSimpleSpecifyOutputFile/node/maprootUrlsourcerootUrlModuleSimpleSpecifyOutputFile.errors.txt +++ b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSimpleSpecifyOutputFile/node/maprootUrlsourcerootUrlModuleSimpleSpecifyOutputFile.errors.txt @@ -2,7 +2,7 @@ error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. !!! error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. -==== m1.ts (0 errors) ==== +==== G:/ts/typescript/tests/cases/projects/outputdir_module_simple/m1.ts (0 errors) ==== export var m1_a1 = 10; export class m1_c1 { public m1_c1_p1: number; diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSubfolderSpecifyOutputFile/node/maprootUrlsourcerootUrlModuleSubfolderSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSubfolderSpecifyOutputFile/node/maprootUrlsourcerootUrlModuleSubfolderSpecifyOutputFile.errors.txt index bbe6b1772ae..676e800a45e 100644 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSubfolderSpecifyOutputFile/node/maprootUrlsourcerootUrlModuleSubfolderSpecifyOutputFile.errors.txt +++ b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSubfolderSpecifyOutputFile/node/maprootUrlsourcerootUrlModuleSubfolderSpecifyOutputFile.errors.txt @@ -2,7 +2,7 @@ error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. !!! error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. -==== ref/m1.ts (0 errors) ==== +==== G:/ts/typescript/tests/cases/projects/outputdir_module_subfolder/ref/m1.ts (0 errors) ==== export var m1_a1 = 10; export class m1_c1 { public m1_c1_p1: number; diff --git a/tests/baselines/reference/project/outModuleMultifolderSpecifyOutputFile/node/outModuleMultifolderSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/outModuleMultifolderSpecifyOutputFile/node/outModuleMultifolderSpecifyOutputFile.errors.txt index 20fc9c39de5..f705eb8105e 100644 --- a/tests/baselines/reference/project/outModuleMultifolderSpecifyOutputFile/node/outModuleMultifolderSpecifyOutputFile.errors.txt +++ b/tests/baselines/reference/project/outModuleMultifolderSpecifyOutputFile/node/outModuleMultifolderSpecifyOutputFile.errors.txt @@ -2,7 +2,7 @@ error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. !!! error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. -==== ref/m1.ts (0 errors) ==== +==== G:/ts/typescript/tests/cases/projects/outputdir_module_multifolder/ref/m1.ts (0 errors) ==== export var m1_a1 = 10; export class m1_c1 { public m1_c1_p1: number; @@ -12,7 +12,7 @@ error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. export function m1_f1() { return m1_instance1; } -==== ../outputdir_module_multifolder_ref/m2.ts (0 errors) ==== +==== G:/ts/typescript/tests/cases/projects/outputdir_module_multifolder_ref/m2.ts (0 errors) ==== export var m2_a1 = 10; export class m2_c1 { public m2_c1_p1: number; diff --git a/tests/baselines/reference/project/outModuleSimpleSpecifyOutputFile/node/outModuleSimpleSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/outModuleSimpleSpecifyOutputFile/node/outModuleSimpleSpecifyOutputFile.errors.txt index 12592331fb5..0cf639d7f1c 100644 --- a/tests/baselines/reference/project/outModuleSimpleSpecifyOutputFile/node/outModuleSimpleSpecifyOutputFile.errors.txt +++ b/tests/baselines/reference/project/outModuleSimpleSpecifyOutputFile/node/outModuleSimpleSpecifyOutputFile.errors.txt @@ -2,7 +2,7 @@ error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. !!! error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. -==== m1.ts (0 errors) ==== +==== G:/ts/typescript/tests/cases/projects/outputdir_module_simple/m1.ts (0 errors) ==== export var m1_a1 = 10; export class m1_c1 { public m1_c1_p1: number; diff --git a/tests/baselines/reference/project/outModuleSubfolderSpecifyOutputFile/node/outModuleSubfolderSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/outModuleSubfolderSpecifyOutputFile/node/outModuleSubfolderSpecifyOutputFile.errors.txt index bbe6b1772ae..676e800a45e 100644 --- a/tests/baselines/reference/project/outModuleSubfolderSpecifyOutputFile/node/outModuleSubfolderSpecifyOutputFile.errors.txt +++ b/tests/baselines/reference/project/outModuleSubfolderSpecifyOutputFile/node/outModuleSubfolderSpecifyOutputFile.errors.txt @@ -2,7 +2,7 @@ error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. !!! error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. -==== ref/m1.ts (0 errors) ==== +==== G:/ts/typescript/tests/cases/projects/outputdir_module_subfolder/ref/m1.ts (0 errors) ==== export var m1_a1 = 10; export class m1_c1 { public m1_c1_p1: number; diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderSpecifyOutputFile/node/sourceRootAbsolutePathModuleMultifolderSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderSpecifyOutputFile/node/sourceRootAbsolutePathModuleMultifolderSpecifyOutputFile.errors.txt index 20fc9c39de5..f705eb8105e 100644 --- a/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderSpecifyOutputFile/node/sourceRootAbsolutePathModuleMultifolderSpecifyOutputFile.errors.txt +++ b/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderSpecifyOutputFile/node/sourceRootAbsolutePathModuleMultifolderSpecifyOutputFile.errors.txt @@ -2,7 +2,7 @@ error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. !!! error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. -==== ref/m1.ts (0 errors) ==== +==== G:/ts/typescript/tests/cases/projects/outputdir_module_multifolder/ref/m1.ts (0 errors) ==== export var m1_a1 = 10; export class m1_c1 { public m1_c1_p1: number; @@ -12,7 +12,7 @@ error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. export function m1_f1() { return m1_instance1; } -==== ../outputdir_module_multifolder_ref/m2.ts (0 errors) ==== +==== G:/ts/typescript/tests/cases/projects/outputdir_module_multifolder_ref/m2.ts (0 errors) ==== export var m2_a1 = 10; export class m2_c1 { public m2_c1_p1: number; diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathModuleSimpleSpecifyOutputFile/node/sourceRootAbsolutePathModuleSimpleSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/sourceRootAbsolutePathModuleSimpleSpecifyOutputFile/node/sourceRootAbsolutePathModuleSimpleSpecifyOutputFile.errors.txt index 12592331fb5..0cf639d7f1c 100644 --- a/tests/baselines/reference/project/sourceRootAbsolutePathModuleSimpleSpecifyOutputFile/node/sourceRootAbsolutePathModuleSimpleSpecifyOutputFile.errors.txt +++ b/tests/baselines/reference/project/sourceRootAbsolutePathModuleSimpleSpecifyOutputFile/node/sourceRootAbsolutePathModuleSimpleSpecifyOutputFile.errors.txt @@ -2,7 +2,7 @@ error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. !!! error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. -==== m1.ts (0 errors) ==== +==== G:/ts/typescript/tests/cases/projects/outputdir_module_simple/m1.ts (0 errors) ==== export var m1_a1 = 10; export class m1_c1 { public m1_c1_p1: number; diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathModuleSubfolderSpecifyOutputFile/node/sourceRootAbsolutePathModuleSubfolderSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/sourceRootAbsolutePathModuleSubfolderSpecifyOutputFile/node/sourceRootAbsolutePathModuleSubfolderSpecifyOutputFile.errors.txt index bbe6b1772ae..676e800a45e 100644 --- a/tests/baselines/reference/project/sourceRootAbsolutePathModuleSubfolderSpecifyOutputFile/node/sourceRootAbsolutePathModuleSubfolderSpecifyOutputFile.errors.txt +++ b/tests/baselines/reference/project/sourceRootAbsolutePathModuleSubfolderSpecifyOutputFile/node/sourceRootAbsolutePathModuleSubfolderSpecifyOutputFile.errors.txt @@ -2,7 +2,7 @@ error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. !!! error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. -==== ref/m1.ts (0 errors) ==== +==== G:/ts/typescript/tests/cases/projects/outputdir_module_subfolder/ref/m1.ts (0 errors) ==== export var m1_a1 = 10; export class m1_c1 { public m1_c1_p1: number; diff --git a/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderSpecifyOutputFile/node/sourceRootRelativePathModuleMultifolderSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderSpecifyOutputFile/node/sourceRootRelativePathModuleMultifolderSpecifyOutputFile.errors.txt index 20fc9c39de5..f705eb8105e 100644 --- a/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderSpecifyOutputFile/node/sourceRootRelativePathModuleMultifolderSpecifyOutputFile.errors.txt +++ b/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderSpecifyOutputFile/node/sourceRootRelativePathModuleMultifolderSpecifyOutputFile.errors.txt @@ -2,7 +2,7 @@ error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. !!! error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. -==== ref/m1.ts (0 errors) ==== +==== G:/ts/typescript/tests/cases/projects/outputdir_module_multifolder/ref/m1.ts (0 errors) ==== export var m1_a1 = 10; export class m1_c1 { public m1_c1_p1: number; @@ -12,7 +12,7 @@ error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. export function m1_f1() { return m1_instance1; } -==== ../outputdir_module_multifolder_ref/m2.ts (0 errors) ==== +==== G:/ts/typescript/tests/cases/projects/outputdir_module_multifolder_ref/m2.ts (0 errors) ==== export var m2_a1 = 10; export class m2_c1 { public m2_c1_p1: number; diff --git a/tests/baselines/reference/project/sourceRootRelativePathModuleSimpleSpecifyOutputFile/node/sourceRootRelativePathModuleSimpleSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/sourceRootRelativePathModuleSimpleSpecifyOutputFile/node/sourceRootRelativePathModuleSimpleSpecifyOutputFile.errors.txt index 12592331fb5..0cf639d7f1c 100644 --- a/tests/baselines/reference/project/sourceRootRelativePathModuleSimpleSpecifyOutputFile/node/sourceRootRelativePathModuleSimpleSpecifyOutputFile.errors.txt +++ b/tests/baselines/reference/project/sourceRootRelativePathModuleSimpleSpecifyOutputFile/node/sourceRootRelativePathModuleSimpleSpecifyOutputFile.errors.txt @@ -2,7 +2,7 @@ error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. !!! error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. -==== m1.ts (0 errors) ==== +==== G:/ts/typescript/tests/cases/projects/outputdir_module_simple/m1.ts (0 errors) ==== export var m1_a1 = 10; export class m1_c1 { public m1_c1_p1: number; diff --git a/tests/baselines/reference/project/sourceRootRelativePathModuleSubfolderSpecifyOutputFile/node/sourceRootRelativePathModuleSubfolderSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/sourceRootRelativePathModuleSubfolderSpecifyOutputFile/node/sourceRootRelativePathModuleSubfolderSpecifyOutputFile.errors.txt index bbe6b1772ae..676e800a45e 100644 --- a/tests/baselines/reference/project/sourceRootRelativePathModuleSubfolderSpecifyOutputFile/node/sourceRootRelativePathModuleSubfolderSpecifyOutputFile.errors.txt +++ b/tests/baselines/reference/project/sourceRootRelativePathModuleSubfolderSpecifyOutputFile/node/sourceRootRelativePathModuleSubfolderSpecifyOutputFile.errors.txt @@ -2,7 +2,7 @@ error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. !!! error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. -==== ref/m1.ts (0 errors) ==== +==== G:/ts/typescript/tests/cases/projects/outputdir_module_subfolder/ref/m1.ts (0 errors) ==== export var m1_a1 = 10; export class m1_c1 { public m1_c1_p1: number; diff --git a/tests/baselines/reference/project/sourcemapModuleMultifolderSpecifyOutputFile/node/sourcemapModuleMultifolderSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/sourcemapModuleMultifolderSpecifyOutputFile/node/sourcemapModuleMultifolderSpecifyOutputFile.errors.txt index 20fc9c39de5..f705eb8105e 100644 --- a/tests/baselines/reference/project/sourcemapModuleMultifolderSpecifyOutputFile/node/sourcemapModuleMultifolderSpecifyOutputFile.errors.txt +++ b/tests/baselines/reference/project/sourcemapModuleMultifolderSpecifyOutputFile/node/sourcemapModuleMultifolderSpecifyOutputFile.errors.txt @@ -2,7 +2,7 @@ error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. !!! error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. -==== ref/m1.ts (0 errors) ==== +==== G:/ts/typescript/tests/cases/projects/outputdir_module_multifolder/ref/m1.ts (0 errors) ==== export var m1_a1 = 10; export class m1_c1 { public m1_c1_p1: number; @@ -12,7 +12,7 @@ error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. export function m1_f1() { return m1_instance1; } -==== ../outputdir_module_multifolder_ref/m2.ts (0 errors) ==== +==== G:/ts/typescript/tests/cases/projects/outputdir_module_multifolder_ref/m2.ts (0 errors) ==== export var m2_a1 = 10; export class m2_c1 { public m2_c1_p1: number; diff --git a/tests/baselines/reference/project/sourcemapModuleSimpleSpecifyOutputFile/node/sourcemapModuleSimpleSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/sourcemapModuleSimpleSpecifyOutputFile/node/sourcemapModuleSimpleSpecifyOutputFile.errors.txt index 12592331fb5..0cf639d7f1c 100644 --- a/tests/baselines/reference/project/sourcemapModuleSimpleSpecifyOutputFile/node/sourcemapModuleSimpleSpecifyOutputFile.errors.txt +++ b/tests/baselines/reference/project/sourcemapModuleSimpleSpecifyOutputFile/node/sourcemapModuleSimpleSpecifyOutputFile.errors.txt @@ -2,7 +2,7 @@ error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. !!! error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. -==== m1.ts (0 errors) ==== +==== G:/ts/typescript/tests/cases/projects/outputdir_module_simple/m1.ts (0 errors) ==== export var m1_a1 = 10; export class m1_c1 { public m1_c1_p1: number; diff --git a/tests/baselines/reference/project/sourcemapModuleSubfolderSpecifyOutputFile/node/sourcemapModuleSubfolderSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/sourcemapModuleSubfolderSpecifyOutputFile/node/sourcemapModuleSubfolderSpecifyOutputFile.errors.txt index bbe6b1772ae..676e800a45e 100644 --- a/tests/baselines/reference/project/sourcemapModuleSubfolderSpecifyOutputFile/node/sourcemapModuleSubfolderSpecifyOutputFile.errors.txt +++ b/tests/baselines/reference/project/sourcemapModuleSubfolderSpecifyOutputFile/node/sourcemapModuleSubfolderSpecifyOutputFile.errors.txt @@ -2,7 +2,7 @@ error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. !!! error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. -==== ref/m1.ts (0 errors) ==== +==== G:/ts/typescript/tests/cases/projects/outputdir_module_subfolder/ref/m1.ts (0 errors) ==== export var m1_a1 = 10; export class m1_c1 { public m1_c1_p1: number; diff --git a/tests/baselines/reference/project/sourcerootUrlModuleMultifolderSpecifyOutputFile/node/sourcerootUrlModuleMultifolderSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/sourcerootUrlModuleMultifolderSpecifyOutputFile/node/sourcerootUrlModuleMultifolderSpecifyOutputFile.errors.txt index 20fc9c39de5..f705eb8105e 100644 --- a/tests/baselines/reference/project/sourcerootUrlModuleMultifolderSpecifyOutputFile/node/sourcerootUrlModuleMultifolderSpecifyOutputFile.errors.txt +++ b/tests/baselines/reference/project/sourcerootUrlModuleMultifolderSpecifyOutputFile/node/sourcerootUrlModuleMultifolderSpecifyOutputFile.errors.txt @@ -2,7 +2,7 @@ error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. !!! error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. -==== ref/m1.ts (0 errors) ==== +==== G:/ts/typescript/tests/cases/projects/outputdir_module_multifolder/ref/m1.ts (0 errors) ==== export var m1_a1 = 10; export class m1_c1 { public m1_c1_p1: number; @@ -12,7 +12,7 @@ error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. export function m1_f1() { return m1_instance1; } -==== ../outputdir_module_multifolder_ref/m2.ts (0 errors) ==== +==== G:/ts/typescript/tests/cases/projects/outputdir_module_multifolder_ref/m2.ts (0 errors) ==== export var m2_a1 = 10; export class m2_c1 { public m2_c1_p1: number; diff --git a/tests/baselines/reference/project/sourcerootUrlModuleSimpleSpecifyOutputFile/node/sourcerootUrlModuleSimpleSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/sourcerootUrlModuleSimpleSpecifyOutputFile/node/sourcerootUrlModuleSimpleSpecifyOutputFile.errors.txt index 12592331fb5..0cf639d7f1c 100644 --- a/tests/baselines/reference/project/sourcerootUrlModuleSimpleSpecifyOutputFile/node/sourcerootUrlModuleSimpleSpecifyOutputFile.errors.txt +++ b/tests/baselines/reference/project/sourcerootUrlModuleSimpleSpecifyOutputFile/node/sourcerootUrlModuleSimpleSpecifyOutputFile.errors.txt @@ -2,7 +2,7 @@ error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. !!! error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. -==== m1.ts (0 errors) ==== +==== G:/ts/typescript/tests/cases/projects/outputdir_module_simple/m1.ts (0 errors) ==== export var m1_a1 = 10; export class m1_c1 { public m1_c1_p1: number; diff --git a/tests/baselines/reference/project/sourcerootUrlModuleSubfolderSpecifyOutputFile/node/sourcerootUrlModuleSubfolderSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/sourcerootUrlModuleSubfolderSpecifyOutputFile/node/sourcerootUrlModuleSubfolderSpecifyOutputFile.errors.txt index bbe6b1772ae..676e800a45e 100644 --- a/tests/baselines/reference/project/sourcerootUrlModuleSubfolderSpecifyOutputFile/node/sourcerootUrlModuleSubfolderSpecifyOutputFile.errors.txt +++ b/tests/baselines/reference/project/sourcerootUrlModuleSubfolderSpecifyOutputFile/node/sourcerootUrlModuleSubfolderSpecifyOutputFile.errors.txt @@ -2,7 +2,7 @@ error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. !!! error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. -==== ref/m1.ts (0 errors) ==== +==== G:/ts/typescript/tests/cases/projects/outputdir_module_subfolder/ref/m1.ts (0 errors) ==== export var m1_a1 = 10; export class m1_c1 { public m1_c1_p1: number; From 90bac23be41c6ebae3e51d01e9a4a49e756d5b36 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Fri, 30 Oct 2015 15:59:16 -0700 Subject: [PATCH 134/227] Always generate an identifier in a for-of loop. --- src/compiler/emitter.ts | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index b2fa553a737..c3933451a7a 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -3614,10 +3614,12 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi // // for (let v of arr) { } // - // we don't want to emit a temporary variable for the RHS, just use it directly. - let rhsIsIdentifier = node.expression.kind === SyntaxKind.Identifier; + // we can't reuse 'arr' because it might be modified within the body of the loop. let counter = createTempVariable(TempFlags._i); - let rhsReference = rhsIsIdentifier ? node.expression : createTempVariable(TempFlags.Auto); + let rhsReference = createSynthesizedNode(SyntaxKind.Identifier) as Identifier; + rhsReference.text = node.expression.kind === SyntaxKind.Identifier ? + makeUniqueName((node.expression).text) : + makeTempVariableName(TempFlags.Auto); // This is the let keyword for the counter and rhsReference. The let keyword for // the LHS will be emitted inside the body. @@ -3629,15 +3631,13 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi write(" = 0"); emitEnd(node.expression); - if (!rhsIsIdentifier) { - // , _a = expr - write(", "); - emitStart(node.expression); - emitNodeWithoutSourceMap(rhsReference); - write(" = "); - emitNodeWithoutSourceMap(node.expression); - emitEnd(node.expression); - } + // , _a = expr + write(", "); + emitStart(node.expression); + emitNodeWithoutSourceMap(rhsReference); + write(" = "); + emitNodeWithoutSourceMap(node.expression); + emitEnd(node.expression); write("; "); From 6a277d981adee1b7a68b1faba5defc04da31163f Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Fri, 30 Oct 2015 15:59:27 -0700 Subject: [PATCH 135/227] Accepted baselines. --- .../reference/ES3For-ofTypeCheck4.js | 4 +- .../reference/ES3For-ofTypeCheck6.js | 4 +- tests/baselines/reference/ES5For-of24.js | 6 +-- tests/baselines/reference/ES5For-of25.js | 4 +- tests/baselines/reference/ES5For-of25.js.map | 2 +- .../reference/ES5For-of25.sourcemap.txt | 50 +++++++++---------- tests/baselines/reference/ES5For-of30.js | 4 +- .../reference/ES5For-ofTypeCheck11.js | 4 +- .../reference/ES5For-ofTypeCheck3.js | 4 +- .../reference/ES5For-ofTypeCheck4.js | 4 +- .../reference/ES5For-ofTypeCheck5.js | 4 +- .../reference/ES5For-ofTypeCheck6.js | 4 +- .../reference/ES5For-ofTypeCheck7.js | 4 +- .../reference/ES5For-ofTypeCheck8.js | 4 +- .../reference/ES5For-ofTypeCheck9.js | 4 +- .../argumentsObjectIterator01_ES5.js | 4 +- ...ariableDeclarationBindingPatterns01_ES5.js | 24 ++++----- tests/baselines/reference/for-of58.js | 4 +- .../reference/parserES5ForOfStatement10.js | 4 +- .../reference/parserES5ForOfStatement11.js | 4 +- .../reference/parserES5ForOfStatement12.js | 4 +- .../reference/parserES5ForOfStatement13.js | 4 +- .../reference/parserES5ForOfStatement14.js | 4 +- .../reference/parserES5ForOfStatement15.js | 4 +- .../reference/parserES5ForOfStatement16.js | 4 +- .../reference/parserES5ForOfStatement18.js | 4 +- .../reference/parserES5ForOfStatement2.js | 4 +- .../reference/parserES5ForOfStatement21.js | 4 +- .../reference/parserES5ForOfStatement3.js | 4 +- .../reference/parserES5ForOfStatement4.js | 4 +- .../reference/parserES5ForOfStatement5.js | 4 +- .../reference/parserES5ForOfStatement6.js | 4 +- .../reference/parserES5ForOfStatement7.js | 4 +- .../reference/parserES5ForOfStatement8.js | 4 +- .../reference/parserES5ForOfStatement9.js | 4 +- 35 files changed, 103 insertions(+), 103 deletions(-) diff --git a/tests/baselines/reference/ES3For-ofTypeCheck4.js b/tests/baselines/reference/ES3For-ofTypeCheck4.js index 7386a1967eb..a628a81c517 100644 --- a/tests/baselines/reference/ES3For-ofTypeCheck4.js +++ b/tests/baselines/reference/ES3For-ofTypeCheck4.js @@ -4,6 +4,6 @@ for (const v of union) { } //// [ES3For-ofTypeCheck4.js] var union; -for (var _i = 0; _i < union.length; _i++) { - var v = union[_i]; +for (var _i = 0, union_1 = union; _i < union_1.length; _i++) { + var v = union_1[_i]; } diff --git a/tests/baselines/reference/ES3For-ofTypeCheck6.js b/tests/baselines/reference/ES3For-ofTypeCheck6.js index ddc11808b18..8b4a917eb85 100644 --- a/tests/baselines/reference/ES3For-ofTypeCheck6.js +++ b/tests/baselines/reference/ES3For-ofTypeCheck6.js @@ -4,6 +4,6 @@ for (var v of union) { } //// [ES3For-ofTypeCheck6.js] var union; -for (var _i = 0; _i < union.length; _i++) { - var v = union[_i]; +for (var _i = 0, union_1 = union; _i < union_1.length; _i++) { + var v = union_1[_i]; } diff --git a/tests/baselines/reference/ES5For-of24.js b/tests/baselines/reference/ES5For-of24.js index cdc0876692f..ce4376ad648 100644 --- a/tests/baselines/reference/ES5For-of24.js +++ b/tests/baselines/reference/ES5For-of24.js @@ -6,7 +6,7 @@ for (var v of a) { //// [ES5For-of24.js] var a = [1, 2, 3]; -for (var _i = 0; _i < a.length; _i++) { - var v = a[_i]; - var a_1 = 0; +for (var _i = 0, a_1 = a; _i < a_1.length; _i++) { + var v = a_1[_i]; + var a_2 = 0; } diff --git a/tests/baselines/reference/ES5For-of25.js b/tests/baselines/reference/ES5For-of25.js index 756c14fbe81..440c0b55efb 100644 --- a/tests/baselines/reference/ES5For-of25.js +++ b/tests/baselines/reference/ES5For-of25.js @@ -7,8 +7,8 @@ for (var v of a) { //// [ES5For-of25.js] var a = [1, 2, 3]; -for (var _i = 0; _i < a.length; _i++) { - var v = a[_i]; +for (var _i = 0, a_1 = a; _i < a_1.length; _i++) { + var v = a_1[_i]; v; a; } diff --git a/tests/baselines/reference/ES5For-of25.js.map b/tests/baselines/reference/ES5For-of25.js.map index cc31767128b..1c4d8c2101f 100644 --- a/tests/baselines/reference/ES5For-of25.js.map +++ b/tests/baselines/reference/ES5For-of25.js.map @@ -1,2 +1,2 @@ //// [ES5For-of25.js.map] -{"version":3,"file":"ES5For-of25.js","sourceRoot":"","sources":["ES5For-of25.ts"],"names":[],"mappings":"AAAA,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;AAClB,GAAG,CAAC,CAAU,UAAC,EAAV,aAAK,EAAL,IAAU,CAAC;IAAX,IAAI,CAAC,GAAI,CAAC,IAAL;IACN,CAAC,CAAC;IACF,CAAC,CAAC;CACL"} \ No newline at end of file +{"version":3,"file":"ES5For-of25.js","sourceRoot":"","sources":["ES5For-of25.ts"],"names":[],"mappings":"AAAA,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;AAClB,GAAG,CAAC,CAAU,UAAC,EAAD,OAAC,EAAV,eAAK,EAAL,IAAU,CAAC;IAAX,IAAI,CAAC,UAAA;IACN,CAAC,CAAC;IACF,CAAC,CAAC;CACL"} \ No newline at end of file diff --git a/tests/baselines/reference/ES5For-of25.sourcemap.txt b/tests/baselines/reference/ES5For-of25.sourcemap.txt index 623627fde20..453eef4ee46 100644 --- a/tests/baselines/reference/ES5For-of25.sourcemap.txt +++ b/tests/baselines/reference/ES5For-of25.sourcemap.txt @@ -21,7 +21,7 @@ sourceFile:ES5For-of25.ts 10> ^ 11> ^ 12> ^ -13> ^^^^^^^^^^^^^^^^^^^^^^-> +13> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> 1 > 2 >var 3 > a @@ -47,17 +47,19 @@ sourceFile:ES5For-of25.ts 11>Emitted(1, 18) Source(1, 18) + SourceIndex(0) 12>Emitted(1, 19) Source(1, 19) + SourceIndex(0) --- ->>>for (var _i = 0; _i < a.length; _i++) { +>>>for (var _i = 0, a_1 = a; _i < a_1.length; _i++) { 1-> 2 >^^^ 3 > ^ 4 > ^ 5 > ^^^^^^^^^^ 6 > ^^ -7 > ^^^^^^^^^^^^^ -8 > ^^ -9 > ^^^^ -10> ^ +7 > ^^^^^^^ +8 > ^^ +9 > ^^^^^^^^^^^^^^^ +10> ^^ +11> ^^^^ +12> ^ 1-> > 2 >for @@ -65,40 +67,38 @@ sourceFile:ES5For-of25.ts 4 > (var v of 5 > a 6 > -7 > var v -8 > -9 > var v of a -10> ) +7 > a +8 > +9 > var v +10> +11> var v of a +12> ) 1->Emitted(2, 1) Source(2, 1) + SourceIndex(0) 2 >Emitted(2, 4) Source(2, 4) + SourceIndex(0) 3 >Emitted(2, 5) Source(2, 5) + SourceIndex(0) 4 >Emitted(2, 6) Source(2, 15) + SourceIndex(0) 5 >Emitted(2, 16) Source(2, 16) + SourceIndex(0) -6 >Emitted(2, 18) Source(2, 6) + SourceIndex(0) -7 >Emitted(2, 31) Source(2, 11) + SourceIndex(0) -8 >Emitted(2, 33) Source(2, 6) + SourceIndex(0) -9 >Emitted(2, 37) Source(2, 16) + SourceIndex(0) -10>Emitted(2, 38) Source(2, 17) + SourceIndex(0) +6 >Emitted(2, 18) Source(2, 15) + SourceIndex(0) +7 >Emitted(2, 25) Source(2, 16) + SourceIndex(0) +8 >Emitted(2, 27) Source(2, 6) + SourceIndex(0) +9 >Emitted(2, 42) Source(2, 11) + SourceIndex(0) +10>Emitted(2, 44) Source(2, 6) + SourceIndex(0) +11>Emitted(2, 48) Source(2, 16) + SourceIndex(0) +12>Emitted(2, 49) Source(2, 17) + SourceIndex(0) --- ->>> var v = a[_i]; +>>> var v = a_1[_i]; 1 >^^^^ 2 > ^^^^ 3 > ^ -4 > ^^^ -5 > ^ -6 > ^^^^ +4 > ^^^^^^^^^^ 1 > 2 > var 3 > v -4 > of -5 > a -6 > +4 > 1 >Emitted(3, 5) Source(2, 6) + SourceIndex(0) 2 >Emitted(3, 9) Source(2, 10) + SourceIndex(0) 3 >Emitted(3, 10) Source(2, 11) + SourceIndex(0) -4 >Emitted(3, 13) Source(2, 15) + SourceIndex(0) -5 >Emitted(3, 14) Source(2, 16) + SourceIndex(0) -6 >Emitted(3, 18) Source(2, 11) + SourceIndex(0) +4 >Emitted(3, 20) Source(2, 11) + SourceIndex(0) --- >>> v; 1 >^^^^ diff --git a/tests/baselines/reference/ES5For-of30.js b/tests/baselines/reference/ES5For-of30.js index 2a1dc5a3399..fead25e7cf0 100644 --- a/tests/baselines/reference/ES5For-of30.js +++ b/tests/baselines/reference/ES5For-of30.js @@ -9,8 +9,8 @@ for ([a = 1, b = ""] of tuple) { //// [ES5For-of30.js] var a, b; var tuple = [2, "3"]; -for (var _i = 0; _i < tuple.length; _i++) { - _a = tuple[_i], _b = _a[0], a = _b === void 0 ? 1 : _b, _c = _a[1], b = _c === void 0 ? "" : _c; +for (var _i = 0, tuple_1 = tuple; _i < tuple_1.length; _i++) { + _a = tuple_1[_i], _b = _a[0], a = _b === void 0 ? 1 : _b, _c = _a[1], b = _c === void 0 ? "" : _c; a; b; } diff --git a/tests/baselines/reference/ES5For-ofTypeCheck11.js b/tests/baselines/reference/ES5For-ofTypeCheck11.js index c0e46a45452..ce439427755 100644 --- a/tests/baselines/reference/ES5For-ofTypeCheck11.js +++ b/tests/baselines/reference/ES5For-ofTypeCheck11.js @@ -6,6 +6,6 @@ for (v of union) { } //// [ES5For-ofTypeCheck11.js] var union; var v; -for (var _i = 0; _i < union.length; _i++) { - v = union[_i]; +for (var _i = 0, union_1 = union; _i < union_1.length; _i++) { + v = union_1[_i]; } diff --git a/tests/baselines/reference/ES5For-ofTypeCheck3.js b/tests/baselines/reference/ES5For-ofTypeCheck3.js index 76d8237997b..61a60727cba 100644 --- a/tests/baselines/reference/ES5For-ofTypeCheck3.js +++ b/tests/baselines/reference/ES5For-ofTypeCheck3.js @@ -4,6 +4,6 @@ for (var v of tuple) { } //// [ES5For-ofTypeCheck3.js] var tuple = ["", 0]; -for (var _i = 0; _i < tuple.length; _i++) { - var v = tuple[_i]; +for (var _i = 0, tuple_1 = tuple; _i < tuple_1.length; _i++) { + var v = tuple_1[_i]; } diff --git a/tests/baselines/reference/ES5For-ofTypeCheck4.js b/tests/baselines/reference/ES5For-ofTypeCheck4.js index 630bc869c58..6240b6a799a 100644 --- a/tests/baselines/reference/ES5For-ofTypeCheck4.js +++ b/tests/baselines/reference/ES5For-ofTypeCheck4.js @@ -4,6 +4,6 @@ for (const v of union) { } //// [ES5For-ofTypeCheck4.js] var union; -for (var _i = 0; _i < union.length; _i++) { - var v = union[_i]; +for (var _i = 0, union_1 = union; _i < union_1.length; _i++) { + var v = union_1[_i]; } diff --git a/tests/baselines/reference/ES5For-ofTypeCheck5.js b/tests/baselines/reference/ES5For-ofTypeCheck5.js index 2e6b47f779d..0d285d67d8b 100644 --- a/tests/baselines/reference/ES5For-ofTypeCheck5.js +++ b/tests/baselines/reference/ES5For-ofTypeCheck5.js @@ -4,6 +4,6 @@ for (var v of union) { } //// [ES5For-ofTypeCheck5.js] var union; -for (var _i = 0; _i < union.length; _i++) { - var v = union[_i]; +for (var _i = 0, union_1 = union; _i < union_1.length; _i++) { + var v = union_1[_i]; } diff --git a/tests/baselines/reference/ES5For-ofTypeCheck6.js b/tests/baselines/reference/ES5For-ofTypeCheck6.js index 9249020b9d4..c99fd415b23 100644 --- a/tests/baselines/reference/ES5For-ofTypeCheck6.js +++ b/tests/baselines/reference/ES5For-ofTypeCheck6.js @@ -4,6 +4,6 @@ for (var v of union) { } //// [ES5For-ofTypeCheck6.js] var union; -for (var _i = 0; _i < union.length; _i++) { - var v = union[_i]; +for (var _i = 0, union_1 = union; _i < union_1.length; _i++) { + var v = union_1[_i]; } diff --git a/tests/baselines/reference/ES5For-ofTypeCheck7.js b/tests/baselines/reference/ES5For-ofTypeCheck7.js index d5b74a24728..1bd360e5132 100644 --- a/tests/baselines/reference/ES5For-ofTypeCheck7.js +++ b/tests/baselines/reference/ES5For-ofTypeCheck7.js @@ -4,6 +4,6 @@ for (var v of union) { } //// [ES5For-ofTypeCheck7.js] var union; -for (var _i = 0; _i < union.length; _i++) { - var v = union[_i]; +for (var _i = 0, union_1 = union; _i < union_1.length; _i++) { + var v = union_1[_i]; } diff --git a/tests/baselines/reference/ES5For-ofTypeCheck8.js b/tests/baselines/reference/ES5For-ofTypeCheck8.js index d73aea1cb7b..ae4a823a18c 100644 --- a/tests/baselines/reference/ES5For-ofTypeCheck8.js +++ b/tests/baselines/reference/ES5For-ofTypeCheck8.js @@ -6,6 +6,6 @@ for (v of union) { } //// [ES5For-ofTypeCheck8.js] var union; var v; -for (var _i = 0; _i < union.length; _i++) { - v = union[_i]; +for (var _i = 0, union_1 = union; _i < union_1.length; _i++) { + v = union_1[_i]; } diff --git a/tests/baselines/reference/ES5For-ofTypeCheck9.js b/tests/baselines/reference/ES5For-ofTypeCheck9.js index 6c7465d10ec..3e18c2da31f 100644 --- a/tests/baselines/reference/ES5For-ofTypeCheck9.js +++ b/tests/baselines/reference/ES5For-ofTypeCheck9.js @@ -4,6 +4,6 @@ for (let v of union) { } //// [ES5For-ofTypeCheck9.js] var union; -for (var _i = 0; _i < union.length; _i++) { - var v = union[_i]; +for (var _i = 0, union_1 = union; _i < union_1.length; _i++) { + var v = union_1[_i]; } diff --git a/tests/baselines/reference/argumentsObjectIterator01_ES5.js b/tests/baselines/reference/argumentsObjectIterator01_ES5.js index bc51d6f5582..8378528dbf4 100644 --- a/tests/baselines/reference/argumentsObjectIterator01_ES5.js +++ b/tests/baselines/reference/argumentsObjectIterator01_ES5.js @@ -11,8 +11,8 @@ function doubleAndReturnAsArray(x: number, y: number, z: number): [number, numbe //// [argumentsObjectIterator01_ES5.js] function doubleAndReturnAsArray(x, y, z) { var result = []; - for (var _i = 0; _i < arguments.length; _i++) { - var arg = arguments[_i]; + for (var _i = 0, arguments_1 = arguments; _i < arguments_1.length; _i++) { + var arg = arguments_1[_i]; result.push(arg + arg); } return result; diff --git a/tests/baselines/reference/emptyVariableDeclarationBindingPatterns01_ES5.js b/tests/baselines/reference/emptyVariableDeclarationBindingPatterns01_ES5.js index 11c4f4e1807..52207ceda96 100644 --- a/tests/baselines/reference/emptyVariableDeclarationBindingPatterns01_ES5.js +++ b/tests/baselines/reference/emptyVariableDeclarationBindingPatterns01_ES5.js @@ -80,22 +80,22 @@ })(); (function () { var ns = []; - for (var _i = 0; _i < ns.length; _i++) { - var _a = ns[_i]; + for (var _i = 0, ns_1 = ns; _i < ns_1.length; _i++) { + var _a = ns_1[_i]; } - for (var _b = 0; _b < ns.length; _b++) { - var _c = ns[_b]; + for (var _b = 0, ns_2 = ns; _b < ns_2.length; _b++) { + var _c = ns_2[_b]; } - for (var _d = 0; _d < ns.length; _d++) { - var _e = ns[_d]; + for (var _d = 0, ns_3 = ns; _d < ns_3.length; _d++) { + var _e = ns_3[_d]; } - for (var _f = 0; _f < ns.length; _f++) { - var _g = ns[_f]; + for (var _f = 0, ns_4 = ns; _f < ns_4.length; _f++) { + var _g = ns_4[_f]; } - for (var _h = 0; _h < ns.length; _h++) { - var _j = ns[_h]; + for (var _h = 0, ns_5 = ns; _h < ns_5.length; _h++) { + var _j = ns_5[_h]; } - for (var _k = 0; _k < ns.length; _k++) { - var _l = ns[_k]; + for (var _k = 0, ns_6 = ns; _k < ns_6.length; _k++) { + var _l = ns_6[_k]; } })(); diff --git a/tests/baselines/reference/for-of58.js b/tests/baselines/reference/for-of58.js index 196d2d4a15d..6f738a59142 100644 --- a/tests/baselines/reference/for-of58.js +++ b/tests/baselines/reference/for-of58.js @@ -14,8 +14,8 @@ for (let num of array) { //// [for-of58.js] var array = [1, 2, 3]; var sum = 0; -for (var _i = 0; _i < array.length; _i++) { - var num = array[_i]; +for (var _i = 0, array_1 = array; _i < array_1.length; _i++) { + var num = array_1[_i]; if (sum === 0) { array = [4, 5, 6]; } diff --git a/tests/baselines/reference/parserES5ForOfStatement10.js b/tests/baselines/reference/parserES5ForOfStatement10.js index cac70523022..36c505b0a12 100644 --- a/tests/baselines/reference/parserES5ForOfStatement10.js +++ b/tests/baselines/reference/parserES5ForOfStatement10.js @@ -3,6 +3,6 @@ for (const v of X) { } //// [parserES5ForOfStatement10.js] -for (var _i = 0; _i < X.length; _i++) { - var v = X[_i]; +for (var _i = 0, X_1 = X; _i < X_1.length; _i++) { + var v = X_1[_i]; } diff --git a/tests/baselines/reference/parserES5ForOfStatement11.js b/tests/baselines/reference/parserES5ForOfStatement11.js index 40e4ca68d6b..e3bac1584fc 100644 --- a/tests/baselines/reference/parserES5ForOfStatement11.js +++ b/tests/baselines/reference/parserES5ForOfStatement11.js @@ -3,6 +3,6 @@ for (const [a, b] of X) { } //// [parserES5ForOfStatement11.js] -for (var _i = 0; _i < X.length; _i++) { - var _a = X[_i], a = _a[0], b = _a[1]; +for (var _i = 0, X_1 = X; _i < X_1.length; _i++) { + var _a = X_1[_i], a = _a[0], b = _a[1]; } diff --git a/tests/baselines/reference/parserES5ForOfStatement12.js b/tests/baselines/reference/parserES5ForOfStatement12.js index f877ebdb757..2a43ca2dea3 100644 --- a/tests/baselines/reference/parserES5ForOfStatement12.js +++ b/tests/baselines/reference/parserES5ForOfStatement12.js @@ -3,6 +3,6 @@ for (const {a, b} of X) { } //// [parserES5ForOfStatement12.js] -for (var _i = 0; _i < X.length; _i++) { - var _a = X[_i], a = _a.a, b = _a.b; +for (var _i = 0, X_1 = X; _i < X_1.length; _i++) { + var _a = X_1[_i], a = _a.a, b = _a.b; } diff --git a/tests/baselines/reference/parserES5ForOfStatement13.js b/tests/baselines/reference/parserES5ForOfStatement13.js index 45199480518..2f1f280090f 100644 --- a/tests/baselines/reference/parserES5ForOfStatement13.js +++ b/tests/baselines/reference/parserES5ForOfStatement13.js @@ -3,6 +3,6 @@ for (let {a, b} of X) { } //// [parserES5ForOfStatement13.js] -for (var _i = 0; _i < X.length; _i++) { - var _a = X[_i], a = _a.a, b = _a.b; +for (var _i = 0, X_1 = X; _i < X_1.length; _i++) { + var _a = X_1[_i], a = _a.a, b = _a.b; } diff --git a/tests/baselines/reference/parserES5ForOfStatement14.js b/tests/baselines/reference/parserES5ForOfStatement14.js index d05fdb96e57..cb753328937 100644 --- a/tests/baselines/reference/parserES5ForOfStatement14.js +++ b/tests/baselines/reference/parserES5ForOfStatement14.js @@ -3,6 +3,6 @@ for (let [a, b] of X) { } //// [parserES5ForOfStatement14.js] -for (var _i = 0; _i < X.length; _i++) { - var _a = X[_i], a = _a[0], b = _a[1]; +for (var _i = 0, X_1 = X; _i < X_1.length; _i++) { + var _a = X_1[_i], a = _a[0], b = _a[1]; } diff --git a/tests/baselines/reference/parserES5ForOfStatement15.js b/tests/baselines/reference/parserES5ForOfStatement15.js index 0af74961145..c7c4db351a6 100644 --- a/tests/baselines/reference/parserES5ForOfStatement15.js +++ b/tests/baselines/reference/parserES5ForOfStatement15.js @@ -3,6 +3,6 @@ for (var [a, b] of X) { } //// [parserES5ForOfStatement15.js] -for (var _i = 0; _i < X.length; _i++) { - var _a = X[_i], a = _a[0], b = _a[1]; +for (var _i = 0, X_1 = X; _i < X_1.length; _i++) { + var _a = X_1[_i], a = _a[0], b = _a[1]; } diff --git a/tests/baselines/reference/parserES5ForOfStatement16.js b/tests/baselines/reference/parserES5ForOfStatement16.js index 1e7c6e005a8..149b6ce3df7 100644 --- a/tests/baselines/reference/parserES5ForOfStatement16.js +++ b/tests/baselines/reference/parserES5ForOfStatement16.js @@ -3,6 +3,6 @@ for (var {a, b} of X) { } //// [parserES5ForOfStatement16.js] -for (var _i = 0; _i < X.length; _i++) { - var _a = X[_i], a = _a.a, b = _a.b; +for (var _i = 0, X_1 = X; _i < X_1.length; _i++) { + var _a = X_1[_i], a = _a.a, b = _a.b; } diff --git a/tests/baselines/reference/parserES5ForOfStatement18.js b/tests/baselines/reference/parserES5ForOfStatement18.js index 905ba9c1d1e..0427adb52d8 100644 --- a/tests/baselines/reference/parserES5ForOfStatement18.js +++ b/tests/baselines/reference/parserES5ForOfStatement18.js @@ -2,6 +2,6 @@ for (var of of of) { } //// [parserES5ForOfStatement18.js] -for (var _i = 0; _i < of.length; _i++) { - var of = of[_i]; +for (var _i = 0, of_1 = of; _i < of_1.length; _i++) { + var of = of_1[_i]; } diff --git a/tests/baselines/reference/parserES5ForOfStatement2.js b/tests/baselines/reference/parserES5ForOfStatement2.js index 287602dfb9c..43b557d9c8f 100644 --- a/tests/baselines/reference/parserES5ForOfStatement2.js +++ b/tests/baselines/reference/parserES5ForOfStatement2.js @@ -3,6 +3,6 @@ for (var of X) { } //// [parserES5ForOfStatement2.js] -for (var _i = 0; _i < X.length; _i++) { - var _a = X[_i]; +for (var _i = 0, X_1 = X; _i < X_1.length; _i++) { + var _a = X_1[_i]; } diff --git a/tests/baselines/reference/parserES5ForOfStatement21.js b/tests/baselines/reference/parserES5ForOfStatement21.js index dcdffbc3cf0..e5d7ebcac21 100644 --- a/tests/baselines/reference/parserES5ForOfStatement21.js +++ b/tests/baselines/reference/parserES5ForOfStatement21.js @@ -2,6 +2,6 @@ for (var of of) { } //// [parserES5ForOfStatement21.js] -for (var _i = 0; _i < of.length; _i++) { - var _a = of[_i]; +for (var _i = 0, of_1 = of; _i < of_1.length; _i++) { + var _a = of_1[_i]; } diff --git a/tests/baselines/reference/parserES5ForOfStatement3.js b/tests/baselines/reference/parserES5ForOfStatement3.js index a99e96a23b8..953a59fb9b8 100644 --- a/tests/baselines/reference/parserES5ForOfStatement3.js +++ b/tests/baselines/reference/parserES5ForOfStatement3.js @@ -3,6 +3,6 @@ for (var a, b of X) { } //// [parserES5ForOfStatement3.js] -for (var _i = 0; _i < X.length; _i++) { - var a = X[_i]; +for (var _i = 0, X_1 = X; _i < X_1.length; _i++) { + var a = X_1[_i]; } diff --git a/tests/baselines/reference/parserES5ForOfStatement4.js b/tests/baselines/reference/parserES5ForOfStatement4.js index f1558005f20..8ad35187e51 100644 --- a/tests/baselines/reference/parserES5ForOfStatement4.js +++ b/tests/baselines/reference/parserES5ForOfStatement4.js @@ -3,6 +3,6 @@ for (var a = 1 of X) { } //// [parserES5ForOfStatement4.js] -for (var _i = 0; _i < X.length; _i++) { - var a = 1 = X[_i]; +for (var _i = 0, X_1 = X; _i < X_1.length; _i++) { + var a = 1 = X_1[_i]; } diff --git a/tests/baselines/reference/parserES5ForOfStatement5.js b/tests/baselines/reference/parserES5ForOfStatement5.js index 328b2fba0a7..3138b05e499 100644 --- a/tests/baselines/reference/parserES5ForOfStatement5.js +++ b/tests/baselines/reference/parserES5ForOfStatement5.js @@ -3,6 +3,6 @@ for (var a: number of X) { } //// [parserES5ForOfStatement5.js] -for (var _i = 0; _i < X.length; _i++) { - var a = X[_i]; +for (var _i = 0, X_1 = X; _i < X_1.length; _i++) { + var a = X_1[_i]; } diff --git a/tests/baselines/reference/parserES5ForOfStatement6.js b/tests/baselines/reference/parserES5ForOfStatement6.js index 15747b93ba9..75454de208e 100644 --- a/tests/baselines/reference/parserES5ForOfStatement6.js +++ b/tests/baselines/reference/parserES5ForOfStatement6.js @@ -3,6 +3,6 @@ for (var a = 1, b = 2 of X) { } //// [parserES5ForOfStatement6.js] -for (var _i = 0; _i < X.length; _i++) { - var a = 1 = X[_i]; +for (var _i = 0, X_1 = X; _i < X_1.length; _i++) { + var a = 1 = X_1[_i]; } diff --git a/tests/baselines/reference/parserES5ForOfStatement7.js b/tests/baselines/reference/parserES5ForOfStatement7.js index 29e4de8787f..ef3a02e45eb 100644 --- a/tests/baselines/reference/parserES5ForOfStatement7.js +++ b/tests/baselines/reference/parserES5ForOfStatement7.js @@ -3,6 +3,6 @@ for (var a: number = 1, b: string = "" of X) { } //// [parserES5ForOfStatement7.js] -for (var _i = 0; _i < X.length; _i++) { - var a = 1 = X[_i]; +for (var _i = 0, X_1 = X; _i < X_1.length; _i++) { + var a = 1 = X_1[_i]; } diff --git a/tests/baselines/reference/parserES5ForOfStatement8.js b/tests/baselines/reference/parserES5ForOfStatement8.js index 5c449fc6433..7aa61972601 100644 --- a/tests/baselines/reference/parserES5ForOfStatement8.js +++ b/tests/baselines/reference/parserES5ForOfStatement8.js @@ -3,6 +3,6 @@ for (var v of X) { } //// [parserES5ForOfStatement8.js] -for (var _i = 0; _i < X.length; _i++) { - var v = X[_i]; +for (var _i = 0, X_1 = X; _i < X_1.length; _i++) { + var v = X_1[_i]; } diff --git a/tests/baselines/reference/parserES5ForOfStatement9.js b/tests/baselines/reference/parserES5ForOfStatement9.js index 6b63d58a88a..8202d2812c1 100644 --- a/tests/baselines/reference/parserES5ForOfStatement9.js +++ b/tests/baselines/reference/parserES5ForOfStatement9.js @@ -3,6 +3,6 @@ for (let v of X) { } //// [parserES5ForOfStatement9.js] -for (var _i = 0; _i < X.length; _i++) { - var v = X[_i]; +for (var _i = 0, X_1 = X; _i < X_1.length; _i++) { + var v = X_1[_i]; } From f06627f780ea0420897d3dfb9cee54a1f8def643 Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Fri, 30 Oct 2015 16:35:31 -0700 Subject: [PATCH 136/227] prevent absolutre paths from leaking through error baselines --- src/harness/projectsRunner.ts | 2 +- ...RootAbsolutePathMixedSubfolderSpecifyOutputFile.errors.txt | 4 ++-- ...xedSubfolderSpecifyOutputFileAndOutputDirectory.errors.txt | 4 ++-- ...tAbsolutePathModuleMultifolderSpecifyOutputFile.errors.txt | 4 ++-- ...apRootAbsolutePathModuleSimpleSpecifyOutputFile.errors.txt | 2 +- ...ootAbsolutePathModuleSubfolderSpecifyOutputFile.errors.txt | 2 +- ...mapRootAbsolutePathMultifolderSpecifyOutputFile.errors.txt | 4 ++-- .../mapRootAbsolutePathSubfolderSpecifyOutputFile.errors.txt | 2 +- ...RootRelativePathMixedSubfolderSpecifyOutputFile.errors.txt | 4 ++-- ...xedSubfolderSpecifyOutputFileAndOutputDirectory.errors.txt | 4 ++-- ...tRelativePathModuleMultifolderSpecifyOutputFile.errors.txt | 4 ++-- ...apRootRelativePathModuleSimpleSpecifyOutputFile.errors.txt | 2 +- ...ootRelativePathModuleSubfolderSpecifyOutputFile.errors.txt | 2 +- ...mapRootRelativePathMultifolderSpecifyOutputFile.errors.txt | 4 ++-- .../mapRootRelativePathSubfolderSpecifyOutputFile.errors.txt | 2 +- .../node/maprootUrlMixedSubfolderSpecifyOutputFile.errors.txt | 4 ++-- ...xedSubfolderSpecifyOutputFileAndOutputDirectory.errors.txt | 4 ++-- .../maprootUrlModuleMultifolderSpecifyOutputFile.errors.txt | 4 ++-- .../node/maprootUrlModuleSimpleSpecifyOutputFile.errors.txt | 2 +- .../maprootUrlModuleSubfolderSpecifyOutputFile.errors.txt | 2 +- .../node/maprootUrlMultifolderSpecifyOutputFile.errors.txt | 4 ++-- .../node/maprootUrlSubfolderSpecifyOutputFile.errors.txt | 2 +- ...UrlsourcerootUrlMixedSubfolderSpecifyOutputFile.errors.txt | 4 ++-- ...xedSubfolderSpecifyOutputFileAndOutputDirectory.errors.txt | 4 ++-- ...sourcerootUrlModuleMultifolderSpecifyOutputFile.errors.txt | 4 ++-- ...otUrlsourcerootUrlModuleSimpleSpecifyOutputFile.errors.txt | 2 +- ...rlsourcerootUrlModuleSubfolderSpecifyOutputFile.errors.txt | 2 +- ...ootUrlsourcerootUrlMultifolderSpecifyOutputFile.errors.txt | 4 ++-- ...prootUrlsourcerootUrlSubfolderSpecifyOutputFile.errors.txt | 2 +- .../node/outMixedSubfolderSpecifyOutputFile.errors.txt | 4 ++-- ...xedSubfolderSpecifyOutputFileAndOutputDirectory.errors.txt | 4 ++-- .../node/outModuleMultifolderSpecifyOutputFile.errors.txt | 4 ++-- .../node/outModuleSimpleSpecifyOutputFile.errors.txt | 2 +- .../node/outModuleSubfolderSpecifyOutputFile.errors.txt | 2 +- .../node/outMultifolderSpecifyOutputFile.errors.txt | 4 ++-- .../node/outSubfolderSpecifyOutputFile.errors.txt | 2 +- .../rootDirectoryErrors/amd/rootDirectoryErrors.errors.txt | 4 ++-- .../rootDirectoryErrors/node/rootDirectoryErrors.errors.txt | 4 ++-- ...RootAbsolutePathMixedSubfolderSpecifyOutputFile.errors.txt | 4 ++-- ...xedSubfolderSpecifyOutputFileAndOutputDirectory.errors.txt | 4 ++-- ...tAbsolutePathModuleMultifolderSpecifyOutputFile.errors.txt | 4 ++-- ...ceRootAbsolutePathModuleSimpleSpecifyOutputFile.errors.txt | 2 +- ...ootAbsolutePathModuleSubfolderSpecifyOutputFile.errors.txt | 2 +- ...rceRootAbsolutePathMultifolderSpecifyOutputFile.errors.txt | 4 ++-- ...ourceRootAbsolutePathSubfolderSpecifyOutputFile.errors.txt | 2 +- ...RootRelativePathMixedSubfolderSpecifyOutputFile.errors.txt | 4 ++-- ...xedSubfolderSpecifyOutputFileAndOutputDirectory.errors.txt | 4 ++-- ...tRelativePathModuleMultifolderSpecifyOutputFile.errors.txt | 4 ++-- ...ceRootRelativePathModuleSimpleSpecifyOutputFile.errors.txt | 2 +- ...ootRelativePathModuleSubfolderSpecifyOutputFile.errors.txt | 2 +- ...rceRootRelativePathMultifolderSpecifyOutputFile.errors.txt | 4 ++-- ...ourceRootRelativePathSubfolderSpecifyOutputFile.errors.txt | 2 +- .../node/sourcemapMixedSubfolderSpecifyOutputFile.errors.txt | 4 ++-- ...xedSubfolderSpecifyOutputFileAndOutputDirectory.errors.txt | 4 ++-- .../sourcemapModuleMultifolderSpecifyOutputFile.errors.txt | 4 ++-- .../node/sourcemapModuleSimpleSpecifyOutputFile.errors.txt | 2 +- .../node/sourcemapModuleSubfolderSpecifyOutputFile.errors.txt | 2 +- .../node/sourcemapMultifolderSpecifyOutputFile.errors.txt | 4 ++-- .../node/sourcemapSubfolderSpecifyOutputFile.errors.txt | 2 +- .../sourcerootUrlMixedSubfolderSpecifyOutputFile.errors.txt | 4 ++-- ...xedSubfolderSpecifyOutputFileAndOutputDirectory.errors.txt | 4 ++-- ...sourcerootUrlModuleMultifolderSpecifyOutputFile.errors.txt | 4 ++-- .../sourcerootUrlModuleSimpleSpecifyOutputFile.errors.txt | 2 +- .../sourcerootUrlModuleSubfolderSpecifyOutputFile.errors.txt | 2 +- .../node/sourcerootUrlMultifolderSpecifyOutputFile.errors.txt | 4 ++-- .../node/sourcerootUrlSubfolderSpecifyOutputFile.errors.txt | 2 +- 66 files changed, 104 insertions(+), 104 deletions(-) diff --git a/src/harness/projectsRunner.ts b/src/harness/projectsRunner.ts index aca90c92f8e..75affe04d13 100644 --- a/src/harness/projectsRunner.ts +++ b/src/harness/projectsRunner.ts @@ -349,7 +349,7 @@ class ProjectRunner extends RunnerBase { let inputFiles = ts.map(ts.filter(compilerResult.program.getSourceFiles(), sourceFile => sourceFile.fileName !== "lib.d.ts"), sourceFile => { - return { unitName: sourceFile.fileName, content: sourceFile.text }; + return { unitName: RunnerBase.removeFullPaths(sourceFile.fileName), content: sourceFile.text }; }); return Harness.Compiler.getErrorBaseline(inputFiles, compilerResult.errors); diff --git a/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFile/node/mapRootAbsolutePathMixedSubfolderSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFile/node/mapRootAbsolutePathMixedSubfolderSpecifyOutputFile.errors.txt index 51edf2991ad..ea1bbf2ba6b 100644 --- a/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFile/node/mapRootAbsolutePathMixedSubfolderSpecifyOutputFile.errors.txt +++ b/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFile/node/mapRootAbsolutePathMixedSubfolderSpecifyOutputFile.errors.txt @@ -2,7 +2,7 @@ error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. !!! error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. -==== ref/m1.ts (0 errors) ==== +==== m1.ts (0 errors) ==== var m1_a1 = 10; class m1_c1 { public m1_c1_p1: number; @@ -12,7 +12,7 @@ error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. function m1_f1() { return m1_instance1; } -==== ref/m2.ts (0 errors) ==== +==== m2.ts (0 errors) ==== export var m2_a1 = 10; export class m2_c1 { public m2_c1_p1: number; diff --git a/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/mapRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory.errors.txt b/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/mapRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory.errors.txt index 51edf2991ad..ea1bbf2ba6b 100644 --- a/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/mapRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory.errors.txt +++ b/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/mapRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory.errors.txt @@ -2,7 +2,7 @@ error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. !!! error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. -==== ref/m1.ts (0 errors) ==== +==== m1.ts (0 errors) ==== var m1_a1 = 10; class m1_c1 { public m1_c1_p1: number; @@ -12,7 +12,7 @@ error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. function m1_f1() { return m1_instance1; } -==== ref/m2.ts (0 errors) ==== +==== m2.ts (0 errors) ==== export var m2_a1 = 10; export class m2_c1 { public m2_c1_p1: number; diff --git a/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderSpecifyOutputFile/node/mapRootAbsolutePathModuleMultifolderSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderSpecifyOutputFile/node/mapRootAbsolutePathModuleMultifolderSpecifyOutputFile.errors.txt index f705eb8105e..247f9e4f2f2 100644 --- a/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderSpecifyOutputFile/node/mapRootAbsolutePathModuleMultifolderSpecifyOutputFile.errors.txt +++ b/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderSpecifyOutputFile/node/mapRootAbsolutePathModuleMultifolderSpecifyOutputFile.errors.txt @@ -2,7 +2,7 @@ error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. !!! error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. -==== G:/ts/typescript/tests/cases/projects/outputdir_module_multifolder/ref/m1.ts (0 errors) ==== +==== m1.ts (0 errors) ==== export var m1_a1 = 10; export class m1_c1 { public m1_c1_p1: number; @@ -12,7 +12,7 @@ error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. export function m1_f1() { return m1_instance1; } -==== G:/ts/typescript/tests/cases/projects/outputdir_module_multifolder_ref/m2.ts (0 errors) ==== +==== m2.ts (0 errors) ==== export var m2_a1 = 10; export class m2_c1 { public m2_c1_p1: number; diff --git a/tests/baselines/reference/project/mapRootAbsolutePathModuleSimpleSpecifyOutputFile/node/mapRootAbsolutePathModuleSimpleSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/mapRootAbsolutePathModuleSimpleSpecifyOutputFile/node/mapRootAbsolutePathModuleSimpleSpecifyOutputFile.errors.txt index 0cf639d7f1c..12592331fb5 100644 --- a/tests/baselines/reference/project/mapRootAbsolutePathModuleSimpleSpecifyOutputFile/node/mapRootAbsolutePathModuleSimpleSpecifyOutputFile.errors.txt +++ b/tests/baselines/reference/project/mapRootAbsolutePathModuleSimpleSpecifyOutputFile/node/mapRootAbsolutePathModuleSimpleSpecifyOutputFile.errors.txt @@ -2,7 +2,7 @@ error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. !!! error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. -==== G:/ts/typescript/tests/cases/projects/outputdir_module_simple/m1.ts (0 errors) ==== +==== m1.ts (0 errors) ==== export var m1_a1 = 10; export class m1_c1 { public m1_c1_p1: number; diff --git a/tests/baselines/reference/project/mapRootAbsolutePathModuleSubfolderSpecifyOutputFile/node/mapRootAbsolutePathModuleSubfolderSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/mapRootAbsolutePathModuleSubfolderSpecifyOutputFile/node/mapRootAbsolutePathModuleSubfolderSpecifyOutputFile.errors.txt index 676e800a45e..42154149020 100644 --- a/tests/baselines/reference/project/mapRootAbsolutePathModuleSubfolderSpecifyOutputFile/node/mapRootAbsolutePathModuleSubfolderSpecifyOutputFile.errors.txt +++ b/tests/baselines/reference/project/mapRootAbsolutePathModuleSubfolderSpecifyOutputFile/node/mapRootAbsolutePathModuleSubfolderSpecifyOutputFile.errors.txt @@ -2,7 +2,7 @@ error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. !!! error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. -==== G:/ts/typescript/tests/cases/projects/outputdir_module_subfolder/ref/m1.ts (0 errors) ==== +==== m1.ts (0 errors) ==== export var m1_a1 = 10; export class m1_c1 { public m1_c1_p1: number; diff --git a/tests/baselines/reference/project/mapRootAbsolutePathMultifolderSpecifyOutputFile/node/mapRootAbsolutePathMultifolderSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/mapRootAbsolutePathMultifolderSpecifyOutputFile/node/mapRootAbsolutePathMultifolderSpecifyOutputFile.errors.txt index 664beb97bc2..53a35eb2c84 100644 --- a/tests/baselines/reference/project/mapRootAbsolutePathMultifolderSpecifyOutputFile/node/mapRootAbsolutePathMultifolderSpecifyOutputFile.errors.txt +++ b/tests/baselines/reference/project/mapRootAbsolutePathMultifolderSpecifyOutputFile/node/mapRootAbsolutePathMultifolderSpecifyOutputFile.errors.txt @@ -2,7 +2,7 @@ error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. !!! error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. -==== ref/m1.ts (0 errors) ==== +==== m1.ts (0 errors) ==== var m1_a1 = 10; class m1_c1 { public m1_c1_p1: number; @@ -12,7 +12,7 @@ error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. function m1_f1() { return m1_instance1; } -==== ../outputdir_multifolder_ref/m2.ts (0 errors) ==== +==== m2.ts (0 errors) ==== var m2_a1 = 10; class m2_c1 { public m2_c1_p1: number; diff --git a/tests/baselines/reference/project/mapRootAbsolutePathSubfolderSpecifyOutputFile/node/mapRootAbsolutePathSubfolderSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/mapRootAbsolutePathSubfolderSpecifyOutputFile/node/mapRootAbsolutePathSubfolderSpecifyOutputFile.errors.txt index 110e3849820..376cfa761b8 100644 --- a/tests/baselines/reference/project/mapRootAbsolutePathSubfolderSpecifyOutputFile/node/mapRootAbsolutePathSubfolderSpecifyOutputFile.errors.txt +++ b/tests/baselines/reference/project/mapRootAbsolutePathSubfolderSpecifyOutputFile/node/mapRootAbsolutePathSubfolderSpecifyOutputFile.errors.txt @@ -2,7 +2,7 @@ error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. !!! error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. -==== ref/m1.ts (0 errors) ==== +==== m1.ts (0 errors) ==== var m1_a1 = 10; class m1_c1 { public m1_c1_p1: number; diff --git a/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFile/node/mapRootRelativePathMixedSubfolderSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFile/node/mapRootRelativePathMixedSubfolderSpecifyOutputFile.errors.txt index 51edf2991ad..ea1bbf2ba6b 100644 --- a/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFile/node/mapRootRelativePathMixedSubfolderSpecifyOutputFile.errors.txt +++ b/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFile/node/mapRootRelativePathMixedSubfolderSpecifyOutputFile.errors.txt @@ -2,7 +2,7 @@ error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. !!! error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. -==== ref/m1.ts (0 errors) ==== +==== m1.ts (0 errors) ==== var m1_a1 = 10; class m1_c1 { public m1_c1_p1: number; @@ -12,7 +12,7 @@ error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. function m1_f1() { return m1_instance1; } -==== ref/m2.ts (0 errors) ==== +==== m2.ts (0 errors) ==== export var m2_a1 = 10; export class m2_c1 { public m2_c1_p1: number; diff --git a/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/mapRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory.errors.txt b/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/mapRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory.errors.txt index 51edf2991ad..ea1bbf2ba6b 100644 --- a/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/mapRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory.errors.txt +++ b/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/mapRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory.errors.txt @@ -2,7 +2,7 @@ error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. !!! error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. -==== ref/m1.ts (0 errors) ==== +==== m1.ts (0 errors) ==== var m1_a1 = 10; class m1_c1 { public m1_c1_p1: number; @@ -12,7 +12,7 @@ error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. function m1_f1() { return m1_instance1; } -==== ref/m2.ts (0 errors) ==== +==== m2.ts (0 errors) ==== export var m2_a1 = 10; export class m2_c1 { public m2_c1_p1: number; diff --git a/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderSpecifyOutputFile/node/mapRootRelativePathModuleMultifolderSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderSpecifyOutputFile/node/mapRootRelativePathModuleMultifolderSpecifyOutputFile.errors.txt index f705eb8105e..247f9e4f2f2 100644 --- a/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderSpecifyOutputFile/node/mapRootRelativePathModuleMultifolderSpecifyOutputFile.errors.txt +++ b/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderSpecifyOutputFile/node/mapRootRelativePathModuleMultifolderSpecifyOutputFile.errors.txt @@ -2,7 +2,7 @@ error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. !!! error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. -==== G:/ts/typescript/tests/cases/projects/outputdir_module_multifolder/ref/m1.ts (0 errors) ==== +==== m1.ts (0 errors) ==== export var m1_a1 = 10; export class m1_c1 { public m1_c1_p1: number; @@ -12,7 +12,7 @@ error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. export function m1_f1() { return m1_instance1; } -==== G:/ts/typescript/tests/cases/projects/outputdir_module_multifolder_ref/m2.ts (0 errors) ==== +==== m2.ts (0 errors) ==== export var m2_a1 = 10; export class m2_c1 { public m2_c1_p1: number; diff --git a/tests/baselines/reference/project/mapRootRelativePathModuleSimpleSpecifyOutputFile/node/mapRootRelativePathModuleSimpleSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/mapRootRelativePathModuleSimpleSpecifyOutputFile/node/mapRootRelativePathModuleSimpleSpecifyOutputFile.errors.txt index 0cf639d7f1c..12592331fb5 100644 --- a/tests/baselines/reference/project/mapRootRelativePathModuleSimpleSpecifyOutputFile/node/mapRootRelativePathModuleSimpleSpecifyOutputFile.errors.txt +++ b/tests/baselines/reference/project/mapRootRelativePathModuleSimpleSpecifyOutputFile/node/mapRootRelativePathModuleSimpleSpecifyOutputFile.errors.txt @@ -2,7 +2,7 @@ error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. !!! error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. -==== G:/ts/typescript/tests/cases/projects/outputdir_module_simple/m1.ts (0 errors) ==== +==== m1.ts (0 errors) ==== export var m1_a1 = 10; export class m1_c1 { public m1_c1_p1: number; diff --git a/tests/baselines/reference/project/mapRootRelativePathModuleSubfolderSpecifyOutputFile/node/mapRootRelativePathModuleSubfolderSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/mapRootRelativePathModuleSubfolderSpecifyOutputFile/node/mapRootRelativePathModuleSubfolderSpecifyOutputFile.errors.txt index 676e800a45e..42154149020 100644 --- a/tests/baselines/reference/project/mapRootRelativePathModuleSubfolderSpecifyOutputFile/node/mapRootRelativePathModuleSubfolderSpecifyOutputFile.errors.txt +++ b/tests/baselines/reference/project/mapRootRelativePathModuleSubfolderSpecifyOutputFile/node/mapRootRelativePathModuleSubfolderSpecifyOutputFile.errors.txt @@ -2,7 +2,7 @@ error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. !!! error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. -==== G:/ts/typescript/tests/cases/projects/outputdir_module_subfolder/ref/m1.ts (0 errors) ==== +==== m1.ts (0 errors) ==== export var m1_a1 = 10; export class m1_c1 { public m1_c1_p1: number; diff --git a/tests/baselines/reference/project/mapRootRelativePathMultifolderSpecifyOutputFile/node/mapRootRelativePathMultifolderSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/mapRootRelativePathMultifolderSpecifyOutputFile/node/mapRootRelativePathMultifolderSpecifyOutputFile.errors.txt index 664beb97bc2..53a35eb2c84 100644 --- a/tests/baselines/reference/project/mapRootRelativePathMultifolderSpecifyOutputFile/node/mapRootRelativePathMultifolderSpecifyOutputFile.errors.txt +++ b/tests/baselines/reference/project/mapRootRelativePathMultifolderSpecifyOutputFile/node/mapRootRelativePathMultifolderSpecifyOutputFile.errors.txt @@ -2,7 +2,7 @@ error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. !!! error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. -==== ref/m1.ts (0 errors) ==== +==== m1.ts (0 errors) ==== var m1_a1 = 10; class m1_c1 { public m1_c1_p1: number; @@ -12,7 +12,7 @@ error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. function m1_f1() { return m1_instance1; } -==== ../outputdir_multifolder_ref/m2.ts (0 errors) ==== +==== m2.ts (0 errors) ==== var m2_a1 = 10; class m2_c1 { public m2_c1_p1: number; diff --git a/tests/baselines/reference/project/mapRootRelativePathSubfolderSpecifyOutputFile/node/mapRootRelativePathSubfolderSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/mapRootRelativePathSubfolderSpecifyOutputFile/node/mapRootRelativePathSubfolderSpecifyOutputFile.errors.txt index 110e3849820..376cfa761b8 100644 --- a/tests/baselines/reference/project/mapRootRelativePathSubfolderSpecifyOutputFile/node/mapRootRelativePathSubfolderSpecifyOutputFile.errors.txt +++ b/tests/baselines/reference/project/mapRootRelativePathSubfolderSpecifyOutputFile/node/mapRootRelativePathSubfolderSpecifyOutputFile.errors.txt @@ -2,7 +2,7 @@ error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. !!! error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. -==== ref/m1.ts (0 errors) ==== +==== m1.ts (0 errors) ==== var m1_a1 = 10; class m1_c1 { public m1_c1_p1: number; diff --git a/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFile/node/maprootUrlMixedSubfolderSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFile/node/maprootUrlMixedSubfolderSpecifyOutputFile.errors.txt index 51edf2991ad..ea1bbf2ba6b 100644 --- a/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFile/node/maprootUrlMixedSubfolderSpecifyOutputFile.errors.txt +++ b/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFile/node/maprootUrlMixedSubfolderSpecifyOutputFile.errors.txt @@ -2,7 +2,7 @@ error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. !!! error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. -==== ref/m1.ts (0 errors) ==== +==== m1.ts (0 errors) ==== var m1_a1 = 10; class m1_c1 { public m1_c1_p1: number; @@ -12,7 +12,7 @@ error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. function m1_f1() { return m1_instance1; } -==== ref/m2.ts (0 errors) ==== +==== m2.ts (0 errors) ==== export var m2_a1 = 10; export class m2_c1 { public m2_c1_p1: number; diff --git a/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/maprootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory.errors.txt b/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/maprootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory.errors.txt index 51edf2991ad..ea1bbf2ba6b 100644 --- a/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/maprootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory.errors.txt +++ b/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/maprootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory.errors.txt @@ -2,7 +2,7 @@ error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. !!! error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. -==== ref/m1.ts (0 errors) ==== +==== m1.ts (0 errors) ==== var m1_a1 = 10; class m1_c1 { public m1_c1_p1: number; @@ -12,7 +12,7 @@ error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. function m1_f1() { return m1_instance1; } -==== ref/m2.ts (0 errors) ==== +==== m2.ts (0 errors) ==== export var m2_a1 = 10; export class m2_c1 { public m2_c1_p1: number; diff --git a/tests/baselines/reference/project/maprootUrlModuleMultifolderSpecifyOutputFile/node/maprootUrlModuleMultifolderSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/maprootUrlModuleMultifolderSpecifyOutputFile/node/maprootUrlModuleMultifolderSpecifyOutputFile.errors.txt index f705eb8105e..247f9e4f2f2 100644 --- a/tests/baselines/reference/project/maprootUrlModuleMultifolderSpecifyOutputFile/node/maprootUrlModuleMultifolderSpecifyOutputFile.errors.txt +++ b/tests/baselines/reference/project/maprootUrlModuleMultifolderSpecifyOutputFile/node/maprootUrlModuleMultifolderSpecifyOutputFile.errors.txt @@ -2,7 +2,7 @@ error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. !!! error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. -==== G:/ts/typescript/tests/cases/projects/outputdir_module_multifolder/ref/m1.ts (0 errors) ==== +==== m1.ts (0 errors) ==== export var m1_a1 = 10; export class m1_c1 { public m1_c1_p1: number; @@ -12,7 +12,7 @@ error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. export function m1_f1() { return m1_instance1; } -==== G:/ts/typescript/tests/cases/projects/outputdir_module_multifolder_ref/m2.ts (0 errors) ==== +==== m2.ts (0 errors) ==== export var m2_a1 = 10; export class m2_c1 { public m2_c1_p1: number; diff --git a/tests/baselines/reference/project/maprootUrlModuleSimpleSpecifyOutputFile/node/maprootUrlModuleSimpleSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/maprootUrlModuleSimpleSpecifyOutputFile/node/maprootUrlModuleSimpleSpecifyOutputFile.errors.txt index 0cf639d7f1c..12592331fb5 100644 --- a/tests/baselines/reference/project/maprootUrlModuleSimpleSpecifyOutputFile/node/maprootUrlModuleSimpleSpecifyOutputFile.errors.txt +++ b/tests/baselines/reference/project/maprootUrlModuleSimpleSpecifyOutputFile/node/maprootUrlModuleSimpleSpecifyOutputFile.errors.txt @@ -2,7 +2,7 @@ error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. !!! error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. -==== G:/ts/typescript/tests/cases/projects/outputdir_module_simple/m1.ts (0 errors) ==== +==== m1.ts (0 errors) ==== export var m1_a1 = 10; export class m1_c1 { public m1_c1_p1: number; diff --git a/tests/baselines/reference/project/maprootUrlModuleSubfolderSpecifyOutputFile/node/maprootUrlModuleSubfolderSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/maprootUrlModuleSubfolderSpecifyOutputFile/node/maprootUrlModuleSubfolderSpecifyOutputFile.errors.txt index 676e800a45e..42154149020 100644 --- a/tests/baselines/reference/project/maprootUrlModuleSubfolderSpecifyOutputFile/node/maprootUrlModuleSubfolderSpecifyOutputFile.errors.txt +++ b/tests/baselines/reference/project/maprootUrlModuleSubfolderSpecifyOutputFile/node/maprootUrlModuleSubfolderSpecifyOutputFile.errors.txt @@ -2,7 +2,7 @@ error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. !!! error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. -==== G:/ts/typescript/tests/cases/projects/outputdir_module_subfolder/ref/m1.ts (0 errors) ==== +==== m1.ts (0 errors) ==== export var m1_a1 = 10; export class m1_c1 { public m1_c1_p1: number; diff --git a/tests/baselines/reference/project/maprootUrlMultifolderSpecifyOutputFile/node/maprootUrlMultifolderSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/maprootUrlMultifolderSpecifyOutputFile/node/maprootUrlMultifolderSpecifyOutputFile.errors.txt index 664beb97bc2..53a35eb2c84 100644 --- a/tests/baselines/reference/project/maprootUrlMultifolderSpecifyOutputFile/node/maprootUrlMultifolderSpecifyOutputFile.errors.txt +++ b/tests/baselines/reference/project/maprootUrlMultifolderSpecifyOutputFile/node/maprootUrlMultifolderSpecifyOutputFile.errors.txt @@ -2,7 +2,7 @@ error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. !!! error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. -==== ref/m1.ts (0 errors) ==== +==== m1.ts (0 errors) ==== var m1_a1 = 10; class m1_c1 { public m1_c1_p1: number; @@ -12,7 +12,7 @@ error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. function m1_f1() { return m1_instance1; } -==== ../outputdir_multifolder_ref/m2.ts (0 errors) ==== +==== m2.ts (0 errors) ==== var m2_a1 = 10; class m2_c1 { public m2_c1_p1: number; diff --git a/tests/baselines/reference/project/maprootUrlSubfolderSpecifyOutputFile/node/maprootUrlSubfolderSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/maprootUrlSubfolderSpecifyOutputFile/node/maprootUrlSubfolderSpecifyOutputFile.errors.txt index 110e3849820..376cfa761b8 100644 --- a/tests/baselines/reference/project/maprootUrlSubfolderSpecifyOutputFile/node/maprootUrlSubfolderSpecifyOutputFile.errors.txt +++ b/tests/baselines/reference/project/maprootUrlSubfolderSpecifyOutputFile/node/maprootUrlSubfolderSpecifyOutputFile.errors.txt @@ -2,7 +2,7 @@ error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. !!! error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. -==== ref/m1.ts (0 errors) ==== +==== m1.ts (0 errors) ==== var m1_a1 = 10; class m1_c1 { public m1_c1_p1: number; diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFile/node/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFile/node/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFile.errors.txt index 51edf2991ad..ea1bbf2ba6b 100644 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFile/node/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFile.errors.txt +++ b/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFile/node/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFile.errors.txt @@ -2,7 +2,7 @@ error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. !!! error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. -==== ref/m1.ts (0 errors) ==== +==== m1.ts (0 errors) ==== var m1_a1 = 10; class m1_c1 { public m1_c1_p1: number; @@ -12,7 +12,7 @@ error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. function m1_f1() { return m1_instance1; } -==== ref/m2.ts (0 errors) ==== +==== m2.ts (0 errors) ==== export var m2_a1 = 10; export class m2_c1 { public m2_c1_p1: number; diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory.errors.txt b/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory.errors.txt index 51edf2991ad..ea1bbf2ba6b 100644 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory.errors.txt +++ b/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory.errors.txt @@ -2,7 +2,7 @@ error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. !!! error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. -==== ref/m1.ts (0 errors) ==== +==== m1.ts (0 errors) ==== var m1_a1 = 10; class m1_c1 { public m1_c1_p1: number; @@ -12,7 +12,7 @@ error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. function m1_f1() { return m1_instance1; } -==== ref/m2.ts (0 errors) ==== +==== m2.ts (0 errors) ==== export var m2_a1 = 10; export class m2_c1 { public m2_c1_p1: number; diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputFile/node/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputFile/node/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputFile.errors.txt index f705eb8105e..247f9e4f2f2 100644 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputFile/node/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputFile.errors.txt +++ b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputFile/node/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputFile.errors.txt @@ -2,7 +2,7 @@ error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. !!! error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. -==== G:/ts/typescript/tests/cases/projects/outputdir_module_multifolder/ref/m1.ts (0 errors) ==== +==== m1.ts (0 errors) ==== export var m1_a1 = 10; export class m1_c1 { public m1_c1_p1: number; @@ -12,7 +12,7 @@ error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. export function m1_f1() { return m1_instance1; } -==== G:/ts/typescript/tests/cases/projects/outputdir_module_multifolder_ref/m2.ts (0 errors) ==== +==== m2.ts (0 errors) ==== export var m2_a1 = 10; export class m2_c1 { public m2_c1_p1: number; diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSimpleSpecifyOutputFile/node/maprootUrlsourcerootUrlModuleSimpleSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSimpleSpecifyOutputFile/node/maprootUrlsourcerootUrlModuleSimpleSpecifyOutputFile.errors.txt index 0cf639d7f1c..12592331fb5 100644 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSimpleSpecifyOutputFile/node/maprootUrlsourcerootUrlModuleSimpleSpecifyOutputFile.errors.txt +++ b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSimpleSpecifyOutputFile/node/maprootUrlsourcerootUrlModuleSimpleSpecifyOutputFile.errors.txt @@ -2,7 +2,7 @@ error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. !!! error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. -==== G:/ts/typescript/tests/cases/projects/outputdir_module_simple/m1.ts (0 errors) ==== +==== m1.ts (0 errors) ==== export var m1_a1 = 10; export class m1_c1 { public m1_c1_p1: number; diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSubfolderSpecifyOutputFile/node/maprootUrlsourcerootUrlModuleSubfolderSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSubfolderSpecifyOutputFile/node/maprootUrlsourcerootUrlModuleSubfolderSpecifyOutputFile.errors.txt index 676e800a45e..42154149020 100644 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSubfolderSpecifyOutputFile/node/maprootUrlsourcerootUrlModuleSubfolderSpecifyOutputFile.errors.txt +++ b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSubfolderSpecifyOutputFile/node/maprootUrlsourcerootUrlModuleSubfolderSpecifyOutputFile.errors.txt @@ -2,7 +2,7 @@ error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. !!! error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. -==== G:/ts/typescript/tests/cases/projects/outputdir_module_subfolder/ref/m1.ts (0 errors) ==== +==== m1.ts (0 errors) ==== export var m1_a1 = 10; export class m1_c1 { public m1_c1_p1: number; diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlMultifolderSpecifyOutputFile/node/maprootUrlsourcerootUrlMultifolderSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/maprootUrlsourcerootUrlMultifolderSpecifyOutputFile/node/maprootUrlsourcerootUrlMultifolderSpecifyOutputFile.errors.txt index 664beb97bc2..53a35eb2c84 100644 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlMultifolderSpecifyOutputFile/node/maprootUrlsourcerootUrlMultifolderSpecifyOutputFile.errors.txt +++ b/tests/baselines/reference/project/maprootUrlsourcerootUrlMultifolderSpecifyOutputFile/node/maprootUrlsourcerootUrlMultifolderSpecifyOutputFile.errors.txt @@ -2,7 +2,7 @@ error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. !!! error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. -==== ref/m1.ts (0 errors) ==== +==== m1.ts (0 errors) ==== var m1_a1 = 10; class m1_c1 { public m1_c1_p1: number; @@ -12,7 +12,7 @@ error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. function m1_f1() { return m1_instance1; } -==== ../outputdir_multifolder_ref/m2.ts (0 errors) ==== +==== m2.ts (0 errors) ==== var m2_a1 = 10; class m2_c1 { public m2_c1_p1: number; diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlSubfolderSpecifyOutputFile/node/maprootUrlsourcerootUrlSubfolderSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/maprootUrlsourcerootUrlSubfolderSpecifyOutputFile/node/maprootUrlsourcerootUrlSubfolderSpecifyOutputFile.errors.txt index 110e3849820..376cfa761b8 100644 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlSubfolderSpecifyOutputFile/node/maprootUrlsourcerootUrlSubfolderSpecifyOutputFile.errors.txt +++ b/tests/baselines/reference/project/maprootUrlsourcerootUrlSubfolderSpecifyOutputFile/node/maprootUrlsourcerootUrlSubfolderSpecifyOutputFile.errors.txt @@ -2,7 +2,7 @@ error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. !!! error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. -==== ref/m1.ts (0 errors) ==== +==== m1.ts (0 errors) ==== var m1_a1 = 10; class m1_c1 { public m1_c1_p1: number; diff --git a/tests/baselines/reference/project/outMixedSubfolderSpecifyOutputFile/node/outMixedSubfolderSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/outMixedSubfolderSpecifyOutputFile/node/outMixedSubfolderSpecifyOutputFile.errors.txt index 51edf2991ad..ea1bbf2ba6b 100644 --- a/tests/baselines/reference/project/outMixedSubfolderSpecifyOutputFile/node/outMixedSubfolderSpecifyOutputFile.errors.txt +++ b/tests/baselines/reference/project/outMixedSubfolderSpecifyOutputFile/node/outMixedSubfolderSpecifyOutputFile.errors.txt @@ -2,7 +2,7 @@ error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. !!! error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. -==== ref/m1.ts (0 errors) ==== +==== m1.ts (0 errors) ==== var m1_a1 = 10; class m1_c1 { public m1_c1_p1: number; @@ -12,7 +12,7 @@ error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. function m1_f1() { return m1_instance1; } -==== ref/m2.ts (0 errors) ==== +==== m2.ts (0 errors) ==== export var m2_a1 = 10; export class m2_c1 { public m2_c1_p1: number; diff --git a/tests/baselines/reference/project/outMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/outMixedSubfolderSpecifyOutputFileAndOutputDirectory.errors.txt b/tests/baselines/reference/project/outMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/outMixedSubfolderSpecifyOutputFileAndOutputDirectory.errors.txt index 51edf2991ad..ea1bbf2ba6b 100644 --- a/tests/baselines/reference/project/outMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/outMixedSubfolderSpecifyOutputFileAndOutputDirectory.errors.txt +++ b/tests/baselines/reference/project/outMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/outMixedSubfolderSpecifyOutputFileAndOutputDirectory.errors.txt @@ -2,7 +2,7 @@ error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. !!! error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. -==== ref/m1.ts (0 errors) ==== +==== m1.ts (0 errors) ==== var m1_a1 = 10; class m1_c1 { public m1_c1_p1: number; @@ -12,7 +12,7 @@ error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. function m1_f1() { return m1_instance1; } -==== ref/m2.ts (0 errors) ==== +==== m2.ts (0 errors) ==== export var m2_a1 = 10; export class m2_c1 { public m2_c1_p1: number; diff --git a/tests/baselines/reference/project/outModuleMultifolderSpecifyOutputFile/node/outModuleMultifolderSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/outModuleMultifolderSpecifyOutputFile/node/outModuleMultifolderSpecifyOutputFile.errors.txt index f705eb8105e..247f9e4f2f2 100644 --- a/tests/baselines/reference/project/outModuleMultifolderSpecifyOutputFile/node/outModuleMultifolderSpecifyOutputFile.errors.txt +++ b/tests/baselines/reference/project/outModuleMultifolderSpecifyOutputFile/node/outModuleMultifolderSpecifyOutputFile.errors.txt @@ -2,7 +2,7 @@ error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. !!! error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. -==== G:/ts/typescript/tests/cases/projects/outputdir_module_multifolder/ref/m1.ts (0 errors) ==== +==== m1.ts (0 errors) ==== export var m1_a1 = 10; export class m1_c1 { public m1_c1_p1: number; @@ -12,7 +12,7 @@ error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. export function m1_f1() { return m1_instance1; } -==== G:/ts/typescript/tests/cases/projects/outputdir_module_multifolder_ref/m2.ts (0 errors) ==== +==== m2.ts (0 errors) ==== export var m2_a1 = 10; export class m2_c1 { public m2_c1_p1: number; diff --git a/tests/baselines/reference/project/outModuleSimpleSpecifyOutputFile/node/outModuleSimpleSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/outModuleSimpleSpecifyOutputFile/node/outModuleSimpleSpecifyOutputFile.errors.txt index 0cf639d7f1c..12592331fb5 100644 --- a/tests/baselines/reference/project/outModuleSimpleSpecifyOutputFile/node/outModuleSimpleSpecifyOutputFile.errors.txt +++ b/tests/baselines/reference/project/outModuleSimpleSpecifyOutputFile/node/outModuleSimpleSpecifyOutputFile.errors.txt @@ -2,7 +2,7 @@ error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. !!! error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. -==== G:/ts/typescript/tests/cases/projects/outputdir_module_simple/m1.ts (0 errors) ==== +==== m1.ts (0 errors) ==== export var m1_a1 = 10; export class m1_c1 { public m1_c1_p1: number; diff --git a/tests/baselines/reference/project/outModuleSubfolderSpecifyOutputFile/node/outModuleSubfolderSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/outModuleSubfolderSpecifyOutputFile/node/outModuleSubfolderSpecifyOutputFile.errors.txt index 676e800a45e..42154149020 100644 --- a/tests/baselines/reference/project/outModuleSubfolderSpecifyOutputFile/node/outModuleSubfolderSpecifyOutputFile.errors.txt +++ b/tests/baselines/reference/project/outModuleSubfolderSpecifyOutputFile/node/outModuleSubfolderSpecifyOutputFile.errors.txt @@ -2,7 +2,7 @@ error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. !!! error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. -==== G:/ts/typescript/tests/cases/projects/outputdir_module_subfolder/ref/m1.ts (0 errors) ==== +==== m1.ts (0 errors) ==== export var m1_a1 = 10; export class m1_c1 { public m1_c1_p1: number; diff --git a/tests/baselines/reference/project/outMultifolderSpecifyOutputFile/node/outMultifolderSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/outMultifolderSpecifyOutputFile/node/outMultifolderSpecifyOutputFile.errors.txt index 664beb97bc2..53a35eb2c84 100644 --- a/tests/baselines/reference/project/outMultifolderSpecifyOutputFile/node/outMultifolderSpecifyOutputFile.errors.txt +++ b/tests/baselines/reference/project/outMultifolderSpecifyOutputFile/node/outMultifolderSpecifyOutputFile.errors.txt @@ -2,7 +2,7 @@ error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. !!! error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. -==== ref/m1.ts (0 errors) ==== +==== m1.ts (0 errors) ==== var m1_a1 = 10; class m1_c1 { public m1_c1_p1: number; @@ -12,7 +12,7 @@ error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. function m1_f1() { return m1_instance1; } -==== ../outputdir_multifolder_ref/m2.ts (0 errors) ==== +==== m2.ts (0 errors) ==== var m2_a1 = 10; class m2_c1 { public m2_c1_p1: number; diff --git a/tests/baselines/reference/project/outSubfolderSpecifyOutputFile/node/outSubfolderSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/outSubfolderSpecifyOutputFile/node/outSubfolderSpecifyOutputFile.errors.txt index 110e3849820..376cfa761b8 100644 --- a/tests/baselines/reference/project/outSubfolderSpecifyOutputFile/node/outSubfolderSpecifyOutputFile.errors.txt +++ b/tests/baselines/reference/project/outSubfolderSpecifyOutputFile/node/outSubfolderSpecifyOutputFile.errors.txt @@ -2,7 +2,7 @@ error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. !!! error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. -==== ref/m1.ts (0 errors) ==== +==== m1.ts (0 errors) ==== var m1_a1 = 10; class m1_c1 { public m1_c1_p1: number; diff --git a/tests/baselines/reference/project/rootDirectoryErrors/amd/rootDirectoryErrors.errors.txt b/tests/baselines/reference/project/rootDirectoryErrors/amd/rootDirectoryErrors.errors.txt index dfbdd679685..cde83785831 100644 --- a/tests/baselines/reference/project/rootDirectoryErrors/amd/rootDirectoryErrors.errors.txt +++ b/tests/baselines/reference/project/rootDirectoryErrors/amd/rootDirectoryErrors.errors.txt @@ -2,11 +2,11 @@ error TS6059: File 'FolderA/FolderB/fileB.ts' is not under 'rootDir' 'FolderA/Fo !!! error TS6059: File 'fileB.ts' is not under 'rootDir' 'FolderA/FolderB/FolderC'. 'rootDir' is expected to contain all source files. -==== FolderA/FolderB/FolderC/fileC.ts (0 errors) ==== +==== fileC.ts (0 errors) ==== class C { } -==== FolderA/FolderB/fileB.ts (0 errors) ==== +==== fileB.ts (0 errors) ==== /// class B { public c: C; diff --git a/tests/baselines/reference/project/rootDirectoryErrors/node/rootDirectoryErrors.errors.txt b/tests/baselines/reference/project/rootDirectoryErrors/node/rootDirectoryErrors.errors.txt index dfbdd679685..cde83785831 100644 --- a/tests/baselines/reference/project/rootDirectoryErrors/node/rootDirectoryErrors.errors.txt +++ b/tests/baselines/reference/project/rootDirectoryErrors/node/rootDirectoryErrors.errors.txt @@ -2,11 +2,11 @@ error TS6059: File 'FolderA/FolderB/fileB.ts' is not under 'rootDir' 'FolderA/Fo !!! error TS6059: File 'fileB.ts' is not under 'rootDir' 'FolderA/FolderB/FolderC'. 'rootDir' is expected to contain all source files. -==== FolderA/FolderB/FolderC/fileC.ts (0 errors) ==== +==== fileC.ts (0 errors) ==== class C { } -==== FolderA/FolderB/fileB.ts (0 errors) ==== +==== fileB.ts (0 errors) ==== /// class B { public c: C; diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFile/node/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFile/node/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFile.errors.txt index 51edf2991ad..ea1bbf2ba6b 100644 --- a/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFile/node/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFile.errors.txt +++ b/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFile/node/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFile.errors.txt @@ -2,7 +2,7 @@ error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. !!! error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. -==== ref/m1.ts (0 errors) ==== +==== m1.ts (0 errors) ==== var m1_a1 = 10; class m1_c1 { public m1_c1_p1: number; @@ -12,7 +12,7 @@ error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. function m1_f1() { return m1_instance1; } -==== ref/m2.ts (0 errors) ==== +==== m2.ts (0 errors) ==== export var m2_a1 = 10; export class m2_c1 { public m2_c1_p1: number; diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory.errors.txt b/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory.errors.txt index 51edf2991ad..ea1bbf2ba6b 100644 --- a/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory.errors.txt +++ b/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory.errors.txt @@ -2,7 +2,7 @@ error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. !!! error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. -==== ref/m1.ts (0 errors) ==== +==== m1.ts (0 errors) ==== var m1_a1 = 10; class m1_c1 { public m1_c1_p1: number; @@ -12,7 +12,7 @@ error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. function m1_f1() { return m1_instance1; } -==== ref/m2.ts (0 errors) ==== +==== m2.ts (0 errors) ==== export var m2_a1 = 10; export class m2_c1 { public m2_c1_p1: number; diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderSpecifyOutputFile/node/sourceRootAbsolutePathModuleMultifolderSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderSpecifyOutputFile/node/sourceRootAbsolutePathModuleMultifolderSpecifyOutputFile.errors.txt index f705eb8105e..247f9e4f2f2 100644 --- a/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderSpecifyOutputFile/node/sourceRootAbsolutePathModuleMultifolderSpecifyOutputFile.errors.txt +++ b/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderSpecifyOutputFile/node/sourceRootAbsolutePathModuleMultifolderSpecifyOutputFile.errors.txt @@ -2,7 +2,7 @@ error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. !!! error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. -==== G:/ts/typescript/tests/cases/projects/outputdir_module_multifolder/ref/m1.ts (0 errors) ==== +==== m1.ts (0 errors) ==== export var m1_a1 = 10; export class m1_c1 { public m1_c1_p1: number; @@ -12,7 +12,7 @@ error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. export function m1_f1() { return m1_instance1; } -==== G:/ts/typescript/tests/cases/projects/outputdir_module_multifolder_ref/m2.ts (0 errors) ==== +==== m2.ts (0 errors) ==== export var m2_a1 = 10; export class m2_c1 { public m2_c1_p1: number; diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathModuleSimpleSpecifyOutputFile/node/sourceRootAbsolutePathModuleSimpleSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/sourceRootAbsolutePathModuleSimpleSpecifyOutputFile/node/sourceRootAbsolutePathModuleSimpleSpecifyOutputFile.errors.txt index 0cf639d7f1c..12592331fb5 100644 --- a/tests/baselines/reference/project/sourceRootAbsolutePathModuleSimpleSpecifyOutputFile/node/sourceRootAbsolutePathModuleSimpleSpecifyOutputFile.errors.txt +++ b/tests/baselines/reference/project/sourceRootAbsolutePathModuleSimpleSpecifyOutputFile/node/sourceRootAbsolutePathModuleSimpleSpecifyOutputFile.errors.txt @@ -2,7 +2,7 @@ error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. !!! error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. -==== G:/ts/typescript/tests/cases/projects/outputdir_module_simple/m1.ts (0 errors) ==== +==== m1.ts (0 errors) ==== export var m1_a1 = 10; export class m1_c1 { public m1_c1_p1: number; diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathModuleSubfolderSpecifyOutputFile/node/sourceRootAbsolutePathModuleSubfolderSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/sourceRootAbsolutePathModuleSubfolderSpecifyOutputFile/node/sourceRootAbsolutePathModuleSubfolderSpecifyOutputFile.errors.txt index 676e800a45e..42154149020 100644 --- a/tests/baselines/reference/project/sourceRootAbsolutePathModuleSubfolderSpecifyOutputFile/node/sourceRootAbsolutePathModuleSubfolderSpecifyOutputFile.errors.txt +++ b/tests/baselines/reference/project/sourceRootAbsolutePathModuleSubfolderSpecifyOutputFile/node/sourceRootAbsolutePathModuleSubfolderSpecifyOutputFile.errors.txt @@ -2,7 +2,7 @@ error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. !!! error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. -==== G:/ts/typescript/tests/cases/projects/outputdir_module_subfolder/ref/m1.ts (0 errors) ==== +==== m1.ts (0 errors) ==== export var m1_a1 = 10; export class m1_c1 { public m1_c1_p1: number; diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathMultifolderSpecifyOutputFile/node/sourceRootAbsolutePathMultifolderSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/sourceRootAbsolutePathMultifolderSpecifyOutputFile/node/sourceRootAbsolutePathMultifolderSpecifyOutputFile.errors.txt index 664beb97bc2..53a35eb2c84 100644 --- a/tests/baselines/reference/project/sourceRootAbsolutePathMultifolderSpecifyOutputFile/node/sourceRootAbsolutePathMultifolderSpecifyOutputFile.errors.txt +++ b/tests/baselines/reference/project/sourceRootAbsolutePathMultifolderSpecifyOutputFile/node/sourceRootAbsolutePathMultifolderSpecifyOutputFile.errors.txt @@ -2,7 +2,7 @@ error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. !!! error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. -==== ref/m1.ts (0 errors) ==== +==== m1.ts (0 errors) ==== var m1_a1 = 10; class m1_c1 { public m1_c1_p1: number; @@ -12,7 +12,7 @@ error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. function m1_f1() { return m1_instance1; } -==== ../outputdir_multifolder_ref/m2.ts (0 errors) ==== +==== m2.ts (0 errors) ==== var m2_a1 = 10; class m2_c1 { public m2_c1_p1: number; diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathSubfolderSpecifyOutputFile/node/sourceRootAbsolutePathSubfolderSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/sourceRootAbsolutePathSubfolderSpecifyOutputFile/node/sourceRootAbsolutePathSubfolderSpecifyOutputFile.errors.txt index 110e3849820..376cfa761b8 100644 --- a/tests/baselines/reference/project/sourceRootAbsolutePathSubfolderSpecifyOutputFile/node/sourceRootAbsolutePathSubfolderSpecifyOutputFile.errors.txt +++ b/tests/baselines/reference/project/sourceRootAbsolutePathSubfolderSpecifyOutputFile/node/sourceRootAbsolutePathSubfolderSpecifyOutputFile.errors.txt @@ -2,7 +2,7 @@ error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. !!! error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. -==== ref/m1.ts (0 errors) ==== +==== m1.ts (0 errors) ==== var m1_a1 = 10; class m1_c1 { public m1_c1_p1: number; diff --git a/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFile/node/sourceRootRelativePathMixedSubfolderSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFile/node/sourceRootRelativePathMixedSubfolderSpecifyOutputFile.errors.txt index 51edf2991ad..ea1bbf2ba6b 100644 --- a/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFile/node/sourceRootRelativePathMixedSubfolderSpecifyOutputFile.errors.txt +++ b/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFile/node/sourceRootRelativePathMixedSubfolderSpecifyOutputFile.errors.txt @@ -2,7 +2,7 @@ error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. !!! error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. -==== ref/m1.ts (0 errors) ==== +==== m1.ts (0 errors) ==== var m1_a1 = 10; class m1_c1 { public m1_c1_p1: number; @@ -12,7 +12,7 @@ error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. function m1_f1() { return m1_instance1; } -==== ref/m2.ts (0 errors) ==== +==== m2.ts (0 errors) ==== export var m2_a1 = 10; export class m2_c1 { public m2_c1_p1: number; diff --git a/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/sourceRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory.errors.txt b/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/sourceRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory.errors.txt index 51edf2991ad..ea1bbf2ba6b 100644 --- a/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/sourceRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory.errors.txt +++ b/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/sourceRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory.errors.txt @@ -2,7 +2,7 @@ error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. !!! error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. -==== ref/m1.ts (0 errors) ==== +==== m1.ts (0 errors) ==== var m1_a1 = 10; class m1_c1 { public m1_c1_p1: number; @@ -12,7 +12,7 @@ error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. function m1_f1() { return m1_instance1; } -==== ref/m2.ts (0 errors) ==== +==== m2.ts (0 errors) ==== export var m2_a1 = 10; export class m2_c1 { public m2_c1_p1: number; diff --git a/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderSpecifyOutputFile/node/sourceRootRelativePathModuleMultifolderSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderSpecifyOutputFile/node/sourceRootRelativePathModuleMultifolderSpecifyOutputFile.errors.txt index f705eb8105e..247f9e4f2f2 100644 --- a/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderSpecifyOutputFile/node/sourceRootRelativePathModuleMultifolderSpecifyOutputFile.errors.txt +++ b/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderSpecifyOutputFile/node/sourceRootRelativePathModuleMultifolderSpecifyOutputFile.errors.txt @@ -2,7 +2,7 @@ error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. !!! error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. -==== G:/ts/typescript/tests/cases/projects/outputdir_module_multifolder/ref/m1.ts (0 errors) ==== +==== m1.ts (0 errors) ==== export var m1_a1 = 10; export class m1_c1 { public m1_c1_p1: number; @@ -12,7 +12,7 @@ error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. export function m1_f1() { return m1_instance1; } -==== G:/ts/typescript/tests/cases/projects/outputdir_module_multifolder_ref/m2.ts (0 errors) ==== +==== m2.ts (0 errors) ==== export var m2_a1 = 10; export class m2_c1 { public m2_c1_p1: number; diff --git a/tests/baselines/reference/project/sourceRootRelativePathModuleSimpleSpecifyOutputFile/node/sourceRootRelativePathModuleSimpleSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/sourceRootRelativePathModuleSimpleSpecifyOutputFile/node/sourceRootRelativePathModuleSimpleSpecifyOutputFile.errors.txt index 0cf639d7f1c..12592331fb5 100644 --- a/tests/baselines/reference/project/sourceRootRelativePathModuleSimpleSpecifyOutputFile/node/sourceRootRelativePathModuleSimpleSpecifyOutputFile.errors.txt +++ b/tests/baselines/reference/project/sourceRootRelativePathModuleSimpleSpecifyOutputFile/node/sourceRootRelativePathModuleSimpleSpecifyOutputFile.errors.txt @@ -2,7 +2,7 @@ error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. !!! error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. -==== G:/ts/typescript/tests/cases/projects/outputdir_module_simple/m1.ts (0 errors) ==== +==== m1.ts (0 errors) ==== export var m1_a1 = 10; export class m1_c1 { public m1_c1_p1: number; diff --git a/tests/baselines/reference/project/sourceRootRelativePathModuleSubfolderSpecifyOutputFile/node/sourceRootRelativePathModuleSubfolderSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/sourceRootRelativePathModuleSubfolderSpecifyOutputFile/node/sourceRootRelativePathModuleSubfolderSpecifyOutputFile.errors.txt index 676e800a45e..42154149020 100644 --- a/tests/baselines/reference/project/sourceRootRelativePathModuleSubfolderSpecifyOutputFile/node/sourceRootRelativePathModuleSubfolderSpecifyOutputFile.errors.txt +++ b/tests/baselines/reference/project/sourceRootRelativePathModuleSubfolderSpecifyOutputFile/node/sourceRootRelativePathModuleSubfolderSpecifyOutputFile.errors.txt @@ -2,7 +2,7 @@ error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. !!! error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. -==== G:/ts/typescript/tests/cases/projects/outputdir_module_subfolder/ref/m1.ts (0 errors) ==== +==== m1.ts (0 errors) ==== export var m1_a1 = 10; export class m1_c1 { public m1_c1_p1: number; diff --git a/tests/baselines/reference/project/sourceRootRelativePathMultifolderSpecifyOutputFile/node/sourceRootRelativePathMultifolderSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/sourceRootRelativePathMultifolderSpecifyOutputFile/node/sourceRootRelativePathMultifolderSpecifyOutputFile.errors.txt index 664beb97bc2..53a35eb2c84 100644 --- a/tests/baselines/reference/project/sourceRootRelativePathMultifolderSpecifyOutputFile/node/sourceRootRelativePathMultifolderSpecifyOutputFile.errors.txt +++ b/tests/baselines/reference/project/sourceRootRelativePathMultifolderSpecifyOutputFile/node/sourceRootRelativePathMultifolderSpecifyOutputFile.errors.txt @@ -2,7 +2,7 @@ error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. !!! error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. -==== ref/m1.ts (0 errors) ==== +==== m1.ts (0 errors) ==== var m1_a1 = 10; class m1_c1 { public m1_c1_p1: number; @@ -12,7 +12,7 @@ error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. function m1_f1() { return m1_instance1; } -==== ../outputdir_multifolder_ref/m2.ts (0 errors) ==== +==== m2.ts (0 errors) ==== var m2_a1 = 10; class m2_c1 { public m2_c1_p1: number; diff --git a/tests/baselines/reference/project/sourceRootRelativePathSubfolderSpecifyOutputFile/node/sourceRootRelativePathSubfolderSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/sourceRootRelativePathSubfolderSpecifyOutputFile/node/sourceRootRelativePathSubfolderSpecifyOutputFile.errors.txt index 110e3849820..376cfa761b8 100644 --- a/tests/baselines/reference/project/sourceRootRelativePathSubfolderSpecifyOutputFile/node/sourceRootRelativePathSubfolderSpecifyOutputFile.errors.txt +++ b/tests/baselines/reference/project/sourceRootRelativePathSubfolderSpecifyOutputFile/node/sourceRootRelativePathSubfolderSpecifyOutputFile.errors.txt @@ -2,7 +2,7 @@ error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. !!! error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. -==== ref/m1.ts (0 errors) ==== +==== m1.ts (0 errors) ==== var m1_a1 = 10; class m1_c1 { public m1_c1_p1: number; diff --git a/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFile/node/sourcemapMixedSubfolderSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFile/node/sourcemapMixedSubfolderSpecifyOutputFile.errors.txt index 51edf2991ad..ea1bbf2ba6b 100644 --- a/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFile/node/sourcemapMixedSubfolderSpecifyOutputFile.errors.txt +++ b/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFile/node/sourcemapMixedSubfolderSpecifyOutputFile.errors.txt @@ -2,7 +2,7 @@ error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. !!! error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. -==== ref/m1.ts (0 errors) ==== +==== m1.ts (0 errors) ==== var m1_a1 = 10; class m1_c1 { public m1_c1_p1: number; @@ -12,7 +12,7 @@ error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. function m1_f1() { return m1_instance1; } -==== ref/m2.ts (0 errors) ==== +==== m2.ts (0 errors) ==== export var m2_a1 = 10; export class m2_c1 { public m2_c1_p1: number; diff --git a/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/sourcemapMixedSubfolderSpecifyOutputFileAndOutputDirectory.errors.txt b/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/sourcemapMixedSubfolderSpecifyOutputFileAndOutputDirectory.errors.txt index 51edf2991ad..ea1bbf2ba6b 100644 --- a/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/sourcemapMixedSubfolderSpecifyOutputFileAndOutputDirectory.errors.txt +++ b/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/sourcemapMixedSubfolderSpecifyOutputFileAndOutputDirectory.errors.txt @@ -2,7 +2,7 @@ error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. !!! error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. -==== ref/m1.ts (0 errors) ==== +==== m1.ts (0 errors) ==== var m1_a1 = 10; class m1_c1 { public m1_c1_p1: number; @@ -12,7 +12,7 @@ error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. function m1_f1() { return m1_instance1; } -==== ref/m2.ts (0 errors) ==== +==== m2.ts (0 errors) ==== export var m2_a1 = 10; export class m2_c1 { public m2_c1_p1: number; diff --git a/tests/baselines/reference/project/sourcemapModuleMultifolderSpecifyOutputFile/node/sourcemapModuleMultifolderSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/sourcemapModuleMultifolderSpecifyOutputFile/node/sourcemapModuleMultifolderSpecifyOutputFile.errors.txt index f705eb8105e..247f9e4f2f2 100644 --- a/tests/baselines/reference/project/sourcemapModuleMultifolderSpecifyOutputFile/node/sourcemapModuleMultifolderSpecifyOutputFile.errors.txt +++ b/tests/baselines/reference/project/sourcemapModuleMultifolderSpecifyOutputFile/node/sourcemapModuleMultifolderSpecifyOutputFile.errors.txt @@ -2,7 +2,7 @@ error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. !!! error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. -==== G:/ts/typescript/tests/cases/projects/outputdir_module_multifolder/ref/m1.ts (0 errors) ==== +==== m1.ts (0 errors) ==== export var m1_a1 = 10; export class m1_c1 { public m1_c1_p1: number; @@ -12,7 +12,7 @@ error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. export function m1_f1() { return m1_instance1; } -==== G:/ts/typescript/tests/cases/projects/outputdir_module_multifolder_ref/m2.ts (0 errors) ==== +==== m2.ts (0 errors) ==== export var m2_a1 = 10; export class m2_c1 { public m2_c1_p1: number; diff --git a/tests/baselines/reference/project/sourcemapModuleSimpleSpecifyOutputFile/node/sourcemapModuleSimpleSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/sourcemapModuleSimpleSpecifyOutputFile/node/sourcemapModuleSimpleSpecifyOutputFile.errors.txt index 0cf639d7f1c..12592331fb5 100644 --- a/tests/baselines/reference/project/sourcemapModuleSimpleSpecifyOutputFile/node/sourcemapModuleSimpleSpecifyOutputFile.errors.txt +++ b/tests/baselines/reference/project/sourcemapModuleSimpleSpecifyOutputFile/node/sourcemapModuleSimpleSpecifyOutputFile.errors.txt @@ -2,7 +2,7 @@ error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. !!! error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. -==== G:/ts/typescript/tests/cases/projects/outputdir_module_simple/m1.ts (0 errors) ==== +==== m1.ts (0 errors) ==== export var m1_a1 = 10; export class m1_c1 { public m1_c1_p1: number; diff --git a/tests/baselines/reference/project/sourcemapModuleSubfolderSpecifyOutputFile/node/sourcemapModuleSubfolderSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/sourcemapModuleSubfolderSpecifyOutputFile/node/sourcemapModuleSubfolderSpecifyOutputFile.errors.txt index 676e800a45e..42154149020 100644 --- a/tests/baselines/reference/project/sourcemapModuleSubfolderSpecifyOutputFile/node/sourcemapModuleSubfolderSpecifyOutputFile.errors.txt +++ b/tests/baselines/reference/project/sourcemapModuleSubfolderSpecifyOutputFile/node/sourcemapModuleSubfolderSpecifyOutputFile.errors.txt @@ -2,7 +2,7 @@ error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. !!! error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. -==== G:/ts/typescript/tests/cases/projects/outputdir_module_subfolder/ref/m1.ts (0 errors) ==== +==== m1.ts (0 errors) ==== export var m1_a1 = 10; export class m1_c1 { public m1_c1_p1: number; diff --git a/tests/baselines/reference/project/sourcemapMultifolderSpecifyOutputFile/node/sourcemapMultifolderSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/sourcemapMultifolderSpecifyOutputFile/node/sourcemapMultifolderSpecifyOutputFile.errors.txt index 664beb97bc2..53a35eb2c84 100644 --- a/tests/baselines/reference/project/sourcemapMultifolderSpecifyOutputFile/node/sourcemapMultifolderSpecifyOutputFile.errors.txt +++ b/tests/baselines/reference/project/sourcemapMultifolderSpecifyOutputFile/node/sourcemapMultifolderSpecifyOutputFile.errors.txt @@ -2,7 +2,7 @@ error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. !!! error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. -==== ref/m1.ts (0 errors) ==== +==== m1.ts (0 errors) ==== var m1_a1 = 10; class m1_c1 { public m1_c1_p1: number; @@ -12,7 +12,7 @@ error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. function m1_f1() { return m1_instance1; } -==== ../outputdir_multifolder_ref/m2.ts (0 errors) ==== +==== m2.ts (0 errors) ==== var m2_a1 = 10; class m2_c1 { public m2_c1_p1: number; diff --git a/tests/baselines/reference/project/sourcemapSubfolderSpecifyOutputFile/node/sourcemapSubfolderSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/sourcemapSubfolderSpecifyOutputFile/node/sourcemapSubfolderSpecifyOutputFile.errors.txt index 110e3849820..376cfa761b8 100644 --- a/tests/baselines/reference/project/sourcemapSubfolderSpecifyOutputFile/node/sourcemapSubfolderSpecifyOutputFile.errors.txt +++ b/tests/baselines/reference/project/sourcemapSubfolderSpecifyOutputFile/node/sourcemapSubfolderSpecifyOutputFile.errors.txt @@ -2,7 +2,7 @@ error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. !!! error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. -==== ref/m1.ts (0 errors) ==== +==== m1.ts (0 errors) ==== var m1_a1 = 10; class m1_c1 { public m1_c1_p1: number; diff --git a/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFile/node/sourcerootUrlMixedSubfolderSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFile/node/sourcerootUrlMixedSubfolderSpecifyOutputFile.errors.txt index 51edf2991ad..ea1bbf2ba6b 100644 --- a/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFile/node/sourcerootUrlMixedSubfolderSpecifyOutputFile.errors.txt +++ b/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFile/node/sourcerootUrlMixedSubfolderSpecifyOutputFile.errors.txt @@ -2,7 +2,7 @@ error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. !!! error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. -==== ref/m1.ts (0 errors) ==== +==== m1.ts (0 errors) ==== var m1_a1 = 10; class m1_c1 { public m1_c1_p1: number; @@ -12,7 +12,7 @@ error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. function m1_f1() { return m1_instance1; } -==== ref/m2.ts (0 errors) ==== +==== m2.ts (0 errors) ==== export var m2_a1 = 10; export class m2_c1 { public m2_c1_p1: number; diff --git a/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/sourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory.errors.txt b/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/sourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory.errors.txt index 51edf2991ad..ea1bbf2ba6b 100644 --- a/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/sourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory.errors.txt +++ b/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/sourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory.errors.txt @@ -2,7 +2,7 @@ error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. !!! error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. -==== ref/m1.ts (0 errors) ==== +==== m1.ts (0 errors) ==== var m1_a1 = 10; class m1_c1 { public m1_c1_p1: number; @@ -12,7 +12,7 @@ error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. function m1_f1() { return m1_instance1; } -==== ref/m2.ts (0 errors) ==== +==== m2.ts (0 errors) ==== export var m2_a1 = 10; export class m2_c1 { public m2_c1_p1: number; diff --git a/tests/baselines/reference/project/sourcerootUrlModuleMultifolderSpecifyOutputFile/node/sourcerootUrlModuleMultifolderSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/sourcerootUrlModuleMultifolderSpecifyOutputFile/node/sourcerootUrlModuleMultifolderSpecifyOutputFile.errors.txt index f705eb8105e..247f9e4f2f2 100644 --- a/tests/baselines/reference/project/sourcerootUrlModuleMultifolderSpecifyOutputFile/node/sourcerootUrlModuleMultifolderSpecifyOutputFile.errors.txt +++ b/tests/baselines/reference/project/sourcerootUrlModuleMultifolderSpecifyOutputFile/node/sourcerootUrlModuleMultifolderSpecifyOutputFile.errors.txt @@ -2,7 +2,7 @@ error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. !!! error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. -==== G:/ts/typescript/tests/cases/projects/outputdir_module_multifolder/ref/m1.ts (0 errors) ==== +==== m1.ts (0 errors) ==== export var m1_a1 = 10; export class m1_c1 { public m1_c1_p1: number; @@ -12,7 +12,7 @@ error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. export function m1_f1() { return m1_instance1; } -==== G:/ts/typescript/tests/cases/projects/outputdir_module_multifolder_ref/m2.ts (0 errors) ==== +==== m2.ts (0 errors) ==== export var m2_a1 = 10; export class m2_c1 { public m2_c1_p1: number; diff --git a/tests/baselines/reference/project/sourcerootUrlModuleSimpleSpecifyOutputFile/node/sourcerootUrlModuleSimpleSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/sourcerootUrlModuleSimpleSpecifyOutputFile/node/sourcerootUrlModuleSimpleSpecifyOutputFile.errors.txt index 0cf639d7f1c..12592331fb5 100644 --- a/tests/baselines/reference/project/sourcerootUrlModuleSimpleSpecifyOutputFile/node/sourcerootUrlModuleSimpleSpecifyOutputFile.errors.txt +++ b/tests/baselines/reference/project/sourcerootUrlModuleSimpleSpecifyOutputFile/node/sourcerootUrlModuleSimpleSpecifyOutputFile.errors.txt @@ -2,7 +2,7 @@ error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. !!! error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. -==== G:/ts/typescript/tests/cases/projects/outputdir_module_simple/m1.ts (0 errors) ==== +==== m1.ts (0 errors) ==== export var m1_a1 = 10; export class m1_c1 { public m1_c1_p1: number; diff --git a/tests/baselines/reference/project/sourcerootUrlModuleSubfolderSpecifyOutputFile/node/sourcerootUrlModuleSubfolderSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/sourcerootUrlModuleSubfolderSpecifyOutputFile/node/sourcerootUrlModuleSubfolderSpecifyOutputFile.errors.txt index 676e800a45e..42154149020 100644 --- a/tests/baselines/reference/project/sourcerootUrlModuleSubfolderSpecifyOutputFile/node/sourcerootUrlModuleSubfolderSpecifyOutputFile.errors.txt +++ b/tests/baselines/reference/project/sourcerootUrlModuleSubfolderSpecifyOutputFile/node/sourcerootUrlModuleSubfolderSpecifyOutputFile.errors.txt @@ -2,7 +2,7 @@ error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. !!! error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. -==== G:/ts/typescript/tests/cases/projects/outputdir_module_subfolder/ref/m1.ts (0 errors) ==== +==== m1.ts (0 errors) ==== export var m1_a1 = 10; export class m1_c1 { public m1_c1_p1: number; diff --git a/tests/baselines/reference/project/sourcerootUrlMultifolderSpecifyOutputFile/node/sourcerootUrlMultifolderSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/sourcerootUrlMultifolderSpecifyOutputFile/node/sourcerootUrlMultifolderSpecifyOutputFile.errors.txt index 664beb97bc2..53a35eb2c84 100644 --- a/tests/baselines/reference/project/sourcerootUrlMultifolderSpecifyOutputFile/node/sourcerootUrlMultifolderSpecifyOutputFile.errors.txt +++ b/tests/baselines/reference/project/sourcerootUrlMultifolderSpecifyOutputFile/node/sourcerootUrlMultifolderSpecifyOutputFile.errors.txt @@ -2,7 +2,7 @@ error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. !!! error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. -==== ref/m1.ts (0 errors) ==== +==== m1.ts (0 errors) ==== var m1_a1 = 10; class m1_c1 { public m1_c1_p1: number; @@ -12,7 +12,7 @@ error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. function m1_f1() { return m1_instance1; } -==== ../outputdir_multifolder_ref/m2.ts (0 errors) ==== +==== m2.ts (0 errors) ==== var m2_a1 = 10; class m2_c1 { public m2_c1_p1: number; diff --git a/tests/baselines/reference/project/sourcerootUrlSubfolderSpecifyOutputFile/node/sourcerootUrlSubfolderSpecifyOutputFile.errors.txt b/tests/baselines/reference/project/sourcerootUrlSubfolderSpecifyOutputFile/node/sourcerootUrlSubfolderSpecifyOutputFile.errors.txt index 110e3849820..376cfa761b8 100644 --- a/tests/baselines/reference/project/sourcerootUrlSubfolderSpecifyOutputFile/node/sourcerootUrlSubfolderSpecifyOutputFile.errors.txt +++ b/tests/baselines/reference/project/sourcerootUrlSubfolderSpecifyOutputFile/node/sourcerootUrlSubfolderSpecifyOutputFile.errors.txt @@ -2,7 +2,7 @@ error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. !!! error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile. -==== ref/m1.ts (0 errors) ==== +==== m1.ts (0 errors) ==== var m1_a1 = 10; class m1_c1 { public m1_c1_p1: number; From 982926a4c41032bc0abe43109ca9e374b12957be Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Fri, 30 Oct 2015 16:59:31 -0700 Subject: [PATCH 137/227] Moved test. --- .../for-of58.ts => statements/for-ofStatements/ES5for-of32.ts} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename tests/cases/conformance/{es6/for-ofStatements/for-of58.ts => statements/for-ofStatements/ES5for-of32.ts} (100%) diff --git a/tests/cases/conformance/es6/for-ofStatements/for-of58.ts b/tests/cases/conformance/statements/for-ofStatements/ES5for-of32.ts similarity index 100% rename from tests/cases/conformance/es6/for-ofStatements/for-of58.ts rename to tests/cases/conformance/statements/for-ofStatements/ES5for-of32.ts From d5dd69b7b6af655b94f81006143def9c12e8279d Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Fri, 30 Oct 2015 17:10:14 -0700 Subject: [PATCH 138/227] Accepted baselines. --- .../reference/{for-of58.js => ES5for-of32.js} | 4 ++-- tests/baselines/reference/ES5for-of32.symbols | 23 +++++++++++++++++++ .../{for-of58.types => ES5for-of32.types} | 2 +- tests/baselines/reference/for-of58.symbols | 23 ------------------- 4 files changed, 26 insertions(+), 26 deletions(-) rename tests/baselines/reference/{for-of58.js => ES5for-of32.js} (85%) create mode 100644 tests/baselines/reference/ES5for-of32.symbols rename tests/baselines/reference/{for-of58.types => ES5for-of32.types} (80%) delete mode 100644 tests/baselines/reference/for-of58.symbols diff --git a/tests/baselines/reference/for-of58.js b/tests/baselines/reference/ES5for-of32.js similarity index 85% rename from tests/baselines/reference/for-of58.js rename to tests/baselines/reference/ES5for-of32.js index 6f738a59142..7af7cc3874a 100644 --- a/tests/baselines/reference/for-of58.js +++ b/tests/baselines/reference/ES5for-of32.js @@ -1,4 +1,4 @@ -//// [for-of58.ts] +//// [ES5for-of32.ts] var array = [1,2,3]; var sum = 0; @@ -11,7 +11,7 @@ for (let num of array) { sum += num; } -//// [for-of58.js] +//// [ES5for-of32.js] var array = [1, 2, 3]; var sum = 0; for (var _i = 0, array_1 = array; _i < array_1.length; _i++) { diff --git a/tests/baselines/reference/ES5for-of32.symbols b/tests/baselines/reference/ES5for-of32.symbols new file mode 100644 index 00000000000..5672ad01109 --- /dev/null +++ b/tests/baselines/reference/ES5for-of32.symbols @@ -0,0 +1,23 @@ +=== tests/cases/conformance/statements/for-ofStatements/ES5for-of32.ts === + +var array = [1,2,3]; +>array : Symbol(array, Decl(ES5for-of32.ts, 1, 3)) + +var sum = 0; +>sum : Symbol(sum, Decl(ES5for-of32.ts, 2, 3)) + +for (let num of array) { +>num : Symbol(num, Decl(ES5for-of32.ts, 4, 8)) +>array : Symbol(array, Decl(ES5for-of32.ts, 1, 3)) + + if (sum === 0) { +>sum : Symbol(sum, Decl(ES5for-of32.ts, 2, 3)) + + array = [4,5,6] +>array : Symbol(array, Decl(ES5for-of32.ts, 1, 3)) + } + + sum += num; +>sum : Symbol(sum, Decl(ES5for-of32.ts, 2, 3)) +>num : Symbol(num, Decl(ES5for-of32.ts, 4, 8)) +} diff --git a/tests/baselines/reference/for-of58.types b/tests/baselines/reference/ES5for-of32.types similarity index 80% rename from tests/baselines/reference/for-of58.types rename to tests/baselines/reference/ES5for-of32.types index b82fdfd8483..6fe5ba2008b 100644 --- a/tests/baselines/reference/for-of58.types +++ b/tests/baselines/reference/ES5for-of32.types @@ -1,4 +1,4 @@ -=== tests/cases/conformance/es6/for-ofStatements/for-of58.ts === +=== tests/cases/conformance/statements/for-ofStatements/ES5for-of32.ts === var array = [1,2,3]; >array : number[] diff --git a/tests/baselines/reference/for-of58.symbols b/tests/baselines/reference/for-of58.symbols deleted file mode 100644 index cb7fa87e22d..00000000000 --- a/tests/baselines/reference/for-of58.symbols +++ /dev/null @@ -1,23 +0,0 @@ -=== tests/cases/conformance/es6/for-ofStatements/for-of58.ts === - -var array = [1,2,3]; ->array : Symbol(array, Decl(for-of58.ts, 1, 3)) - -var sum = 0; ->sum : Symbol(sum, Decl(for-of58.ts, 2, 3)) - -for (let num of array) { ->num : Symbol(num, Decl(for-of58.ts, 4, 8)) ->array : Symbol(array, Decl(for-of58.ts, 1, 3)) - - if (sum === 0) { ->sum : Symbol(sum, Decl(for-of58.ts, 2, 3)) - - array = [4,5,6] ->array : Symbol(array, Decl(for-of58.ts, 1, 3)) - } - - sum += num; ->sum : Symbol(sum, Decl(for-of58.ts, 2, 3)) ->num : Symbol(num, Decl(for-of58.ts, 4, 8)) -} From 48c2bb1c5005c100e599612fb756b025d70d8fb5 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Fri, 30 Oct 2015 18:10:31 -0700 Subject: [PATCH 139/227] Fixed 'tsconfig.json' ordering. --- src/compiler/tsconfig.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/compiler/tsconfig.json b/src/compiler/tsconfig.json index fd541a8ca80..ca297c087cf 100644 --- a/src/compiler/tsconfig.json +++ b/src/compiler/tsconfig.json @@ -11,6 +11,7 @@ "core.ts", "sys.ts", "types.ts", + "diagnosticInformationMap.generated.ts", "scanner.ts", "parser.ts", "utilities.ts", @@ -19,7 +20,6 @@ "emitter.ts", "program.ts", "commandLineParser.ts", - "tsc.ts", - "diagnosticInformationMap.generated.ts" + "tsc.ts" ] } From 201266b97fa30087f13a84ab90fc647e23e41389 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Sat, 31 Oct 2015 12:42:04 -0700 Subject: [PATCH 140/227] Switch to `isNodeDescendantOf` --- src/compiler/checker.ts | 17 ++--------------- src/compiler/emitter.ts | 8 -------- src/compiler/utilities.ts | 8 ++++++++ 3 files changed, 10 insertions(+), 23 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 6ea8d896326..80bc58217ae 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -4420,26 +4420,13 @@ namespace ts { let container = getThisContainer(node, /*includeArrowFunctions*/ false); let parent = container && container.parent; if (parent && (isClassLike(parent) || parent.kind === SyntaxKind.InterfaceDeclaration)) { - if (!(container.flags & NodeFlags.Static) && !isConstructorParameter(node, container)) { + if (!(container.flags & NodeFlags.Static) && + (container.kind !== SyntaxKind.Constructor || isNodeDescendentOf(node, (container).body))) { return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(parent)).thisType; } } error(node, Diagnostics.A_this_type_is_available_only_in_a_non_static_member_of_a_class_or_interface); return unknownType; - - function isConstructorParameter(node: Node, container: Node) { - if (container.kind === SyntaxKind.Constructor) { - let ctor = (container); - while (node && node !== ctor) { - if (node === ctor.body) { - return false; - } - node = node.parent; - } - - return true; - } - } } function getTypeFromThisTypeNode(node: TypeNode): Type { diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index b2fa553a737..abcea979dd9 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -359,14 +359,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi sourceMaps: sourceMapDataList }; - function isNodeDescendentOf(node: Node, ancestor: Node): boolean { - while (node) { - if (node === ancestor) return true; - node = node.parent; - } - return false; - } - function isUniqueLocalName(name: string, container: Node): boolean { for (let node = container; isNodeDescendentOf(node, container); node = node.nextContainer) { if (node.locals && hasProperty(node.locals, name)) { diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index fd991039d3e..9b8948d6cc4 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -1167,6 +1167,14 @@ namespace ts { return !!node && (node.kind === SyntaxKind.ArrayBindingPattern || node.kind === SyntaxKind.ObjectBindingPattern); } + export function isNodeDescendentOf(node: Node, ancestor: Node): boolean { + while (node) { + if (node === ancestor) return true; + node = node.parent; + } + return false; + } + export function isInAmbientContext(node: Node): boolean { while (node) { if (node.flags & (NodeFlags.Ambient | NodeFlags.DeclarationFile)) { From 00b389d47765f71bbba9ddd9ebd37e06c29d2009 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Arod?= Date: Sat, 31 Oct 2015 23:16:04 +0100 Subject: [PATCH 141/227] New commit using TS scanner. This commit uses TS scanner and replaces comments token text by whitespaces to preserve orginal positions. --- src/compiler/commandLineParser.ts | 120 ++++++++--------------- tests/cases/unittests/tsconfigParsing.ts | 24 +---- 2 files changed, 44 insertions(+), 100 deletions(-) diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index 885b3af45f8..840e2a7e584 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -421,91 +421,49 @@ namespace ts { * This method replace comment content by whitespace rather than completely remove them to keep positions in json parsing error reporting accurate. */ function removeComments(jsonText: string): string { - let result = ""; - let processingString = false; - let processingSingleLineComment = false; - let processingMultiLineComment = false; - for (let i = 0; i < jsonText.length; i++) { - let currentCharCode = jsonText.charCodeAt(i); - let currentChar = jsonText.charAt(i); - let nextCharCode = (i + 1 < jsonText.length) ? jsonText.charCodeAt(i + 1) : undefined; - if (processingString) { - if (currentCharCode === CharacterCodes.backslash - && nextCharCode !== undefined) { - // Found an escaped character - // consume the \ and the escaped char - result += currentChar; - result += jsonText.charAt(i + 1); - i += 1; - } - else if (currentCharCode === CharacterCodes.doubleQuote) { - // End of string - result += currentChar; - processingString = false; - } - else { - // String content - result += currentChar; - } - } - else if (processingSingleLineComment) { - if (isLineBreak(currentCharCode)) { - // End of single line comment - processingSingleLineComment = false; - // Keep the line breaks to keep line numbers aligned - result += currentChar; - } - else { - // replace comment content by whitespaces - result += " "; - } - } - else if (processingMultiLineComment) { - if (currentCharCode === CharacterCodes.asterisk && nextCharCode === CharacterCodes.slash) { - // End of comment */ - result += " "; - i += 1; - processingMultiLineComment = false; - } - else if (isLineBreak(currentCharCode)) { - // Keep the line breaks to Keep line aligned - result += currentChar; - } - else { - // replace comment content by whitespaces - result += " "; - } - } - else if (currentCharCode === CharacterCodes.doubleQuote) { - // String start - result += currentChar; - processingString = true; - } - else if (currentCharCode === CharacterCodes.hash) { - // Start of # comment - result += " "; - processingSingleLineComment = true; - } - else if (currentCharCode === CharacterCodes.slash && nextCharCode === CharacterCodes.slash) { - // Start of // comment - result += " "; - i += 1; - processingSingleLineComment = true; - } - else if (currentCharCode === CharacterCodes.slash && nextCharCode === CharacterCodes.asterisk) { - // Start of /**/ comment - result += " "; - i += 1; - processingMultiLineComment = true; - } - else { - // Keep other characters - result += currentChar; + let output = ""; + let scanner = createScanner(ScriptTarget.ES5, /* skipTrivia */ false, LanguageVariant.Standard, jsonText); + let token: SyntaxKind; + while ((token = scanner.scan()) !== SyntaxKind.EndOfFileToken) { + switch (token) { + case SyntaxKind.SingleLineCommentTrivia: + case SyntaxKind.MultiLineCommentTrivia: + // replace comments with whitespaces to preserve original characters position + output += replaceWithWhitespaces(scanner.getTokenText()); + break; + default: + output += scanner.getTokenText(); + break; } } - return result; + return output; + + function replaceWithWhitespaces(commentTokenText: string): string { + let result = ""; + let pos = 0; + let start = 0; + while (pos < commentTokenText.length) { + if (isLineBreak(commentTokenText.charCodeAt(pos))) { + let nbCharToReplace = pos - start; + result += nSpaces(nbCharToReplace); + result += commentTokenText.charAt(pos); + pos += 1; + start = pos; + } + else { + pos += 1; + } + } + result += nSpaces(pos - start); + return result; + + function nSpaces(n: number): string { + return new Array(n + 1).join(" "); + }; + } } + /** * Parse the contents of a config file (tsconfig.json). * @param json The contents of the config file to parse diff --git a/tests/cases/unittests/tsconfigParsing.ts b/tests/cases/unittests/tsconfigParsing.ts index f48593b3169..7490b525000 100644 --- a/tests/cases/unittests/tsconfigParsing.ts +++ b/tests/cases/unittests/tsconfigParsing.ts @@ -21,7 +21,6 @@ module ts { it("returns empty config for file with comments only", () => { assertParseResult("// Comment", { config: {} }); - assertParseResult("# Comment", { config: {} }); assertParseResult("/* Comment*/", { config: {} }); }); @@ -37,19 +36,12 @@ module ts { "file.d.ts" ] }`, { config: { exclude: ["file.d.ts"] } }); - assertParseResult( - `{ - # Excluded files - "exclude": [ - # Exclude d.ts - "file.d.ts" - ] - }`, { config: { exclude: ["file.d.ts"] } }); + assertParseResult( `{ /* Excluded - Files - */ + Files + */ "exclude": [ /* multiline comments can be in the middle of a line */"file.d.ts" ] @@ -60,16 +52,10 @@ module ts { assertParseResult( `{ "exclude": [ - "xx//file.d.ts" + "xx//file.d.ts" ] }`, { config: { exclude: ["xx//file.d.ts"] } }); - assertParseResult( - `{ - "exclude": [ - "xx#file.d.ts" - ] - }`, { config: { exclude: ["xx#file.d.ts"] } }); - assertParseResult( + assertParseResult( `{ "exclude": [ "xx/*file.d.ts*/" From 638e4b758a7f46b4bebae5da3bd89cd5ca3a67e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Arod?= Date: Sun, 1 Nov 2015 15:31:16 +0100 Subject: [PATCH 142/227] Use regex for repacing comments content. Use space for indents --- src/compiler/commandLineParser.ts | 28 +---- tests/cases/unittests/tsconfigParsing.ts | 154 +++++++++++------------ 2 files changed, 79 insertions(+), 103 deletions(-) diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index 840e2a7e584..aaf3bf624b6 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -428,8 +428,8 @@ namespace ts { switch (token) { case SyntaxKind.SingleLineCommentTrivia: case SyntaxKind.MultiLineCommentTrivia: - // replace comments with whitespaces to preserve original characters position - output += replaceWithWhitespaces(scanner.getTokenText()); + // replace comments with whitespace to preserve original character positions + output += scanner.getTokenText().replace(/\S/g, " "); break; default: output += scanner.getTokenText(); @@ -437,30 +437,6 @@ namespace ts { } } return output; - - function replaceWithWhitespaces(commentTokenText: string): string { - let result = ""; - let pos = 0; - let start = 0; - while (pos < commentTokenText.length) { - if (isLineBreak(commentTokenText.charCodeAt(pos))) { - let nbCharToReplace = pos - start; - result += nSpaces(nbCharToReplace); - result += commentTokenText.charAt(pos); - pos += 1; - start = pos; - } - else { - pos += 1; - } - } - result += nSpaces(pos - start); - return result; - - function nSpaces(n: number): string { - return new Array(n + 1).join(" "); - }; - } } diff --git a/tests/cases/unittests/tsconfigParsing.ts b/tests/cases/unittests/tsconfigParsing.ts index 7490b525000..3603d22f314 100644 --- a/tests/cases/unittests/tsconfigParsing.ts +++ b/tests/cases/unittests/tsconfigParsing.ts @@ -1,86 +1,86 @@ /// /// -module ts { - describe('parseConfigFileTextToJson', () => { - function assertParseResult(jsonText: string, expectedConfigObject: { config?: any; error?: Diagnostic }) { - let parsed = ts.parseConfigFileTextToJson("/apath/tsconfig.json", jsonText); - assert.equal(JSON.stringify(parsed), JSON.stringify(expectedConfigObject)); - } - - function assertParseError(jsonText: string) { - let parsed = ts.parseConfigFileTextToJson("/apath/tsconfig.json", jsonText); - assert.isTrue(undefined === parsed.config); - assert.isTrue(undefined !== parsed.error); - } +namespace ts { + describe('parseConfigFileTextToJson', () => { + function assertParseResult(jsonText: string, expectedConfigObject: { config?: any; error?: Diagnostic }) { + let parsed = ts.parseConfigFileTextToJson("/apath/tsconfig.json", jsonText); + assert.equal(JSON.stringify(parsed), JSON.stringify(expectedConfigObject)); + } - it("returns empty config for file with only whitespaces", () => { - assertParseResult("", { config : {} }); - assertParseResult(" ", { config : {} }); - }); - - it("returns empty config for file with comments only", () => { - assertParseResult("// Comment", { config: {} }); - assertParseResult("/* Comment*/", { config: {} }); - }); + function assertParseError(jsonText: string) { + let parsed = ts.parseConfigFileTextToJson("/apath/tsconfig.json", jsonText); + assert.isTrue(undefined === parsed.config); + assert.isTrue(undefined !== parsed.error); + } - it("returns empty config when config is empty object", () => { - assertParseResult("{}", { config: {} }); - }); + it("returns empty config for file with only whitespaces", () => { + assertParseResult("", { config : {} }); + assertParseResult(" ", { config : {} }); + }); - it("returns config object without comments", () => { - assertParseResult( - `{ // Excluded files - "exclude": [ - // Exclude d.ts - "file.d.ts" - ] - }`, { config: { exclude: ["file.d.ts"] } }); - - assertParseResult( - `{ - /* Excluded - Files - */ - "exclude": [ - /* multiline comments can be in the middle of a line */"file.d.ts" - ] - }`, { config: { exclude: ["file.d.ts"] } }); - }); + it("returns empty config for file with comments only", () => { + assertParseResult("// Comment", { config: {} }); + assertParseResult("/* Comment*/", { config: {} }); + }); - it("keeps string content untouched", () => { - assertParseResult( - `{ - "exclude": [ - "xx//file.d.ts" - ] - }`, { config: { exclude: ["xx//file.d.ts"] } }); - assertParseResult( - `{ - "exclude": [ - "xx/*file.d.ts*/" - ] - }`, { config: { exclude: ["xx/*file.d.ts*/"] } }); + it("returns empty config when config is empty object", () => { + assertParseResult("{}", { config: {} }); + }); + + it("returns config object without comments", () => { + assertParseResult( + `{ // Excluded files + "exclude": [ + // Exclude d.ts + "file.d.ts" + ] + }`, { config: { exclude: ["file.d.ts"] } }); + + assertParseResult( + `{ + /* Excluded + Files + */ + "exclude": [ + /* multiline comments can be in the middle of a line */"file.d.ts" + ] + }`, { config: { exclude: ["file.d.ts"] } }); + }); + + it("keeps string content untouched", () => { + assertParseResult( + `{ + "exclude": [ + "xx//file.d.ts" + ] + }`, { config: { exclude: ["xx//file.d.ts"] } }); + assertParseResult( + `{ + "exclude": [ + "xx/*file.d.ts*/" + ] + }`, { config: { exclude: ["xx/*file.d.ts*/"] } }); + }); + + it("handles escaped characters in strings correctly", () => { + assertParseResult( + `{ + "exclude": [ + "xx\\"//files" + ] + }`, { config: { exclude: ["xx\"//files"] } }); + + assertParseResult( + `{ + "exclude": [ + "xx\\\\" // end of line comment + ] + }`, { config: { exclude: ["xx\\"] } }); + }); + + it("returns object with error when json is invalid", () => { + assertParseError("invalid"); + }); }); - - it("handles escaped characters in strings correctly", () => { - assertParseResult( - `{ - "exclude": [ - "xx\\"//files" - ] - }`, { config: { exclude: ["xx\"//files"] } }); - - assertParseResult( - `{ - "exclude": [ - "xx\\\\" // end of line comment - ] - }`, { config: { exclude: ["xx\\"] } }); - }); - - it("returns object with error when json is invalid", () => { - assertParseError("invalid"); - }); - }); } From 1703972dd2a3980af42c1d4423ad02b8498b92f9 Mon Sep 17 00:00:00 2001 From: Martin Vseticka Date: Fri, 30 Oct 2015 20:43:22 +0100 Subject: [PATCH 143/227] Preserve copyright comments when generating d.ts files --- src/compiler/declarationEmitter.ts | 1 + src/compiler/emitter.ts | 76 +++-------------- src/compiler/utilities.ts | 68 +++++++++++++++ .../declarationEmitDetachedComment1.js | 85 +++++++++++++++++++ .../declarationEmitDetachedComment1.symbols | 34 ++++++++ .../declarationEmitDetachedComment1.types | 34 ++++++++ .../declarationEmitDetachedComment2.js | 65 ++++++++++++++ .../declarationEmitDetachedComment2.symbols | 34 ++++++++ .../declarationEmitDetachedComment2.types | 34 ++++++++ .../declarationEmitDetachedComment1.ts | 34 ++++++++ .../declarationEmitDetachedComment2.ts | 34 ++++++++ 11 files changed, 435 insertions(+), 64 deletions(-) create mode 100644 tests/baselines/reference/declarationEmitDetachedComment1.js create mode 100644 tests/baselines/reference/declarationEmitDetachedComment1.symbols create mode 100644 tests/baselines/reference/declarationEmitDetachedComment1.types create mode 100644 tests/baselines/reference/declarationEmitDetachedComment2.js create mode 100644 tests/baselines/reference/declarationEmitDetachedComment2.symbols create mode 100644 tests/baselines/reference/declarationEmitDetachedComment2.types create mode 100644 tests/cases/compiler/declarationEmitDetachedComment1.ts create mode 100644 tests/cases/compiler/declarationEmitDetachedComment2.ts diff --git a/src/compiler/declarationEmitter.ts b/src/compiler/declarationEmitter.ts index 00085f16086..719085f7f6a 100644 --- a/src/compiler/declarationEmitter.ts +++ b/src/compiler/declarationEmitter.ts @@ -468,6 +468,7 @@ namespace ts { function emitSourceFile(node: SourceFile) { currentSourceFile = node; enclosingDeclaration = node; + emitDetachedComments(currentSourceFile, writer, writeCommentRange, node, newLine, true /* remove comments */); emitLines(node.statements); } diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index c3933451a7a..2e2ae290c37 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -4907,7 +4907,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi increaseIndent(); let outPos = writer.getTextPos(); - emitDetachedComments(node.body); + emitDetachedCommentsAndUpdateCommentsInfo(node.body); emitFunctionBodyPreamble(node); let preambleEmitted = writer.getTextPos() !== outPos; decreaseIndent(); @@ -4952,7 +4952,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi let initialTextPos = writer.getTextPos(); increaseIndent(); - emitDetachedComments(body.statements); + emitDetachedCommentsAndUpdateCommentsInfo(body.statements); // Emit all the directive prologues (like "use strict"). These have to come before // any other preamble code we write (like parameter initializers). @@ -5274,7 +5274,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi // Emit all the directive prologues (like "use strict"). These have to come before // any other preamble code we write (like parameter initializers). startIndex = emitDirectivePrologues(ctor.body.statements, /*startWithNewLine*/ true); - emitDetachedComments(ctor.body.statements); + emitDetachedCommentsAndUpdateCommentsInfo(ctor.body.statements); } emitCaptureThisForNodeIfNecessary(node); let superCall: ExpressionStatement; @@ -7652,7 +7652,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi // Start new file on new line writeLine(); emitShebang(); - emitDetachedComments(node); + emitDetachedCommentsAndUpdateCommentsInfo(node); if (isExternalModule(node) || compilerOptions.isolatedModules) { let emitModule = moduleEmitDelegates[modulekind] || moduleEmitDelegates[ModuleKind.CommonJS]; @@ -7948,11 +7948,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi return leadingComments; } - function isPinnedComments(comment: CommentRange) { - return currentSourceFile.text.charCodeAt(comment.pos + 1) === CharacterCodes.asterisk && - currentSourceFile.text.charCodeAt(comment.pos + 2) === CharacterCodes.exclamation; - } - /** * Determine if the given comment is a triple-slash * @@ -8086,62 +8081,15 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi emitComments(currentSourceFile, writer, leadingComments, /*trailingSeparator*/ true, newLine, writeComment); } - function emitDetachedComments(node: TextRange) { - let leadingComments: CommentRange[]; - if (compilerOptions.removeComments) { - // removeComments is true, only reserve pinned comment at the top of file - // For example: - // /*! Pinned Comment */ - // - // var x = 10; - if (node.pos === 0) { - leadingComments = filter(getLeadingCommentRanges(currentSourceFile.text, node.pos), isPinnedComments); + function emitDetachedCommentsAndUpdateCommentsInfo(node: TextRange) { + let currentDetachedCommentInfo = emitDetachedComments(currentSourceFile, writer, writeComment, node, newLine, compilerOptions.removeComments); + + if (currentDetachedCommentInfo) { + if (detachedCommentsInfo) { + detachedCommentsInfo.push(currentDetachedCommentInfo); } - } - else { - // removeComments is false, just get detached as normal and bypass the process to filter comment - leadingComments = getLeadingCommentRanges(currentSourceFile.text, node.pos); - } - - if (leadingComments) { - let detachedComments: CommentRange[] = []; - let lastComment: CommentRange; - - forEach(leadingComments, comment => { - if (lastComment) { - let lastCommentLine = getLineOfLocalPosition(currentSourceFile, lastComment.end); - let commentLine = getLineOfLocalPosition(currentSourceFile, comment.pos); - - if (commentLine >= lastCommentLine + 2) { - // There was a blank line between the last comment and this comment. This - // comment is not part of the copyright comments. Return what we have so - // far. - return detachedComments; - } - } - - detachedComments.push(comment); - lastComment = comment; - }); - - if (detachedComments.length) { - // All comments look like they could have been part of the copyright header. Make - // sure there is at least one blank line between it and the node. If not, it's not - // a copyright header. - let lastCommentLine = getLineOfLocalPosition(currentSourceFile, lastOrUndefined(detachedComments).end); - let nodeLine = getLineOfLocalPosition(currentSourceFile, skipTrivia(currentSourceFile.text, node.pos)); - if (nodeLine >= lastCommentLine + 2) { - // Valid detachedComments - emitNewLineBeforeLeadingComments(currentSourceFile, writer, node, leadingComments); - emitComments(currentSourceFile, writer, detachedComments, /*trailingSeparator*/ true, newLine, writeComment); - let currentDetachedCommentInfo = { nodePos: node.pos, detachedCommentEndPos: lastOrUndefined(detachedComments).end }; - if (detachedCommentsInfo) { - detachedCommentsInfo.push(currentDetachedCommentInfo); - } - else { - detachedCommentsInfo = [currentDetachedCommentInfo]; - } - } + else { + detachedCommentsInfo = [currentDetachedCommentInfo]; } } } diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index fd991039d3e..4e0b5d125ab 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -1904,6 +1904,74 @@ namespace ts { }); } + /** + * Detached comment is a comment at the top of file or function body that is separated from + * the next statement by space. + */ + export function emitDetachedComments(currentSourceFile: SourceFile, writer: EmitTextWriter, + writeComment: (currentSourceFile: SourceFile, writer: EmitTextWriter, comment: CommentRange, newLine: string) => void, + node: TextRange, newLine: string, removeComments: boolean) { + let leadingComments: CommentRange[]; + let currentDetachedCommentInfo: {nodePos: number, detachedCommentEndPos: number}; + if (removeComments) { + // removeComments is true, only reserve pinned comment at the top of file + // For example: + // /*! Pinned Comment */ + // + // var x = 10; + if (node.pos === 0) { + leadingComments = filter(getLeadingCommentRanges(currentSourceFile.text, node.pos), isPinnedComment); + } + } + else { + // removeComments is false, just get detached as normal and bypass the process to filter comment + leadingComments = getLeadingCommentRanges(currentSourceFile.text, node.pos); + } + + if (leadingComments) { + let detachedComments: CommentRange[] = []; + let lastComment: CommentRange; + + for (let comment of leadingComments) { + if (lastComment) { + let lastCommentLine = getLineOfLocalPosition(currentSourceFile, lastComment.end); + let commentLine = getLineOfLocalPosition(currentSourceFile, comment.pos); + + if (commentLine >= lastCommentLine + 2) { + // There was a blank line between the last comment and this comment. This + // comment is not part of the copyright comments. Return what we have so + // far. + break; + } + } + + detachedComments.push(comment); + lastComment = comment; + } + + if (detachedComments.length) { + // All comments look like they could have been part of the copyright header. Make + // sure there is at least one blank line between it and the node. If not, it's not + // a copyright header. + let lastCommentLine = getLineOfLocalPosition(currentSourceFile, lastOrUndefined(detachedComments).end); + let nodeLine = getLineOfLocalPosition(currentSourceFile, skipTrivia(currentSourceFile.text, node.pos)); + if (nodeLine >= lastCommentLine + 2) { + // Valid detachedComments + emitNewLineBeforeLeadingComments(currentSourceFile, writer, node, leadingComments); + emitComments(currentSourceFile, writer, detachedComments, /*trailingSeparator*/ true, newLine, writeComment); + currentDetachedCommentInfo = { nodePos: node.pos, detachedCommentEndPos: lastOrUndefined(detachedComments).end }; + } + } + } + + return currentDetachedCommentInfo; + + function isPinnedComment(comment: CommentRange) { + return currentSourceFile.text.charCodeAt(comment.pos + 1) === CharacterCodes.asterisk && + currentSourceFile.text.charCodeAt(comment.pos + 2) === CharacterCodes.exclamation; + } + } + export function writeCommentRange(currentSourceFile: SourceFile, writer: EmitTextWriter, comment: CommentRange, newLine: string) { if (currentSourceFile.text.charCodeAt(comment.pos + 1) === CharacterCodes.asterisk) { let firstCommentLineAndCharacter = getLineAndCharacterOfPosition(currentSourceFile, comment.pos); diff --git a/tests/baselines/reference/declarationEmitDetachedComment1.js b/tests/baselines/reference/declarationEmitDetachedComment1.js new file mode 100644 index 00000000000..38c7e60406d --- /dev/null +++ b/tests/baselines/reference/declarationEmitDetachedComment1.js @@ -0,0 +1,85 @@ +//// [tests/cases/compiler/declarationEmitDetachedComment1.ts] //// + +//// [test1.ts] + +/*! Copyright 2015 MyCompany Inc. */ + +/** + * Hello class + */ +class Hello { + +} + +//// [test2.ts] +/* A comment at the top of the file. */ + +/** + * Hi class + */ +class Hi { + +} + +//// [test3.ts] +// A one-line comment at the top of the file. + +/** + * Hola class + */ +class Hola { + +} + + +//// [test1.js] +/*! Copyright 2015 MyCompany Inc. */ +/** + * Hello class + */ +var Hello = (function () { + function Hello() { + } + return Hello; +})(); +//// [test2.js] +/* A comment at the top of the file. */ +/** + * Hi class + */ +var Hi = (function () { + function Hi() { + } + return Hi; +})(); +//// [test3.js] +// A one-line comment at the top of the file. +/** + * Hola class + */ +var Hola = (function () { + function Hola() { + } + return Hola; +})(); + + +//// [test1.d.ts] +/*! Copyright 2015 MyCompany Inc. */ +/** + * Hello class + */ +declare class Hello { +} +//// [test2.d.ts] +/** + * Hi class + */ +declare class Hi { +} +//// [test3.d.ts] +/** + * Hola class + */ +declare class Hola { +} diff --git a/tests/baselines/reference/declarationEmitDetachedComment1.symbols b/tests/baselines/reference/declarationEmitDetachedComment1.symbols new file mode 100644 index 00000000000..c466716ca44 --- /dev/null +++ b/tests/baselines/reference/declarationEmitDetachedComment1.symbols @@ -0,0 +1,34 @@ +=== tests/cases/compiler/test1.ts === + +/*! Copyright 2015 MyCompany Inc. */ + +/** + * Hello class + */ +class Hello { +>Hello : Symbol(Hello, Decl(test1.ts, 0, 0)) + +} + +=== tests/cases/compiler/test2.ts === +/* A comment at the top of the file. */ + +/** + * Hi class + */ +class Hi { +>Hi : Symbol(Hi, Decl(test2.ts, 0, 0)) + +} + +=== tests/cases/compiler/test3.ts === +// A one-line comment at the top of the file. + +/** + * Hola class + */ +class Hola { +>Hola : Symbol(Hola, Decl(test3.ts, 0, 0)) + +} + diff --git a/tests/baselines/reference/declarationEmitDetachedComment1.types b/tests/baselines/reference/declarationEmitDetachedComment1.types new file mode 100644 index 00000000000..6d1a87b5151 --- /dev/null +++ b/tests/baselines/reference/declarationEmitDetachedComment1.types @@ -0,0 +1,34 @@ +=== tests/cases/compiler/test1.ts === + +/*! Copyright 2015 MyCompany Inc. */ + +/** + * Hello class + */ +class Hello { +>Hello : Hello + +} + +=== tests/cases/compiler/test2.ts === +/* A comment at the top of the file. */ + +/** + * Hi class + */ +class Hi { +>Hi : Hi + +} + +=== tests/cases/compiler/test3.ts === +// A one-line comment at the top of the file. + +/** + * Hola class + */ +class Hola { +>Hola : Hola + +} + diff --git a/tests/baselines/reference/declarationEmitDetachedComment2.js b/tests/baselines/reference/declarationEmitDetachedComment2.js new file mode 100644 index 00000000000..d4d176da12c --- /dev/null +++ b/tests/baselines/reference/declarationEmitDetachedComment2.js @@ -0,0 +1,65 @@ +//// [tests/cases/compiler/declarationEmitDetachedComment2.ts] //// + +//// [test1.ts] + +/*! Copyright 2015 MyCompany Inc. */ + +/** + * Hello class + */ +class Hello { + +} + +//// [test2.ts] +/* A comment at the top of the file. */ + +/** + * Hi class + */ +class Hi { + +} + +//// [test3.ts] +// A one-line comment at the top of the file. + +/** + * Hola class + */ +class Hola { + +} + + +//// [test1.js] +/*! Copyright 2015 MyCompany Inc. */ +var Hello = (function () { + function Hello() { + } + return Hello; +})(); +//// [test2.js] +var Hi = (function () { + function Hi() { + } + return Hi; +})(); +//// [test3.js] +var Hola = (function () { + function Hola() { + } + return Hola; +})(); + + +//// [test1.d.ts] +/*! Copyright 2015 MyCompany Inc. */ +declare class Hello { +} +//// [test2.d.ts] +declare class Hi { +} +//// [test3.d.ts] +declare class Hola { +} diff --git a/tests/baselines/reference/declarationEmitDetachedComment2.symbols b/tests/baselines/reference/declarationEmitDetachedComment2.symbols new file mode 100644 index 00000000000..c466716ca44 --- /dev/null +++ b/tests/baselines/reference/declarationEmitDetachedComment2.symbols @@ -0,0 +1,34 @@ +=== tests/cases/compiler/test1.ts === + +/*! Copyright 2015 MyCompany Inc. */ + +/** + * Hello class + */ +class Hello { +>Hello : Symbol(Hello, Decl(test1.ts, 0, 0)) + +} + +=== tests/cases/compiler/test2.ts === +/* A comment at the top of the file. */ + +/** + * Hi class + */ +class Hi { +>Hi : Symbol(Hi, Decl(test2.ts, 0, 0)) + +} + +=== tests/cases/compiler/test3.ts === +// A one-line comment at the top of the file. + +/** + * Hola class + */ +class Hola { +>Hola : Symbol(Hola, Decl(test3.ts, 0, 0)) + +} + diff --git a/tests/baselines/reference/declarationEmitDetachedComment2.types b/tests/baselines/reference/declarationEmitDetachedComment2.types new file mode 100644 index 00000000000..6d1a87b5151 --- /dev/null +++ b/tests/baselines/reference/declarationEmitDetachedComment2.types @@ -0,0 +1,34 @@ +=== tests/cases/compiler/test1.ts === + +/*! Copyright 2015 MyCompany Inc. */ + +/** + * Hello class + */ +class Hello { +>Hello : Hello + +} + +=== tests/cases/compiler/test2.ts === +/* A comment at the top of the file. */ + +/** + * Hi class + */ +class Hi { +>Hi : Hi + +} + +=== tests/cases/compiler/test3.ts === +// A one-line comment at the top of the file. + +/** + * Hola class + */ +class Hola { +>Hola : Hola + +} + diff --git a/tests/cases/compiler/declarationEmitDetachedComment1.ts b/tests/cases/compiler/declarationEmitDetachedComment1.ts new file mode 100644 index 00000000000..8d49482f3cc --- /dev/null +++ b/tests/cases/compiler/declarationEmitDetachedComment1.ts @@ -0,0 +1,34 @@ +// @target: es5 +// @module: commonjs +// @declaration: true +// @removeComments: false + +// @filename: test1.ts +/*! Copyright 2015 MyCompany Inc. */ + +/** + * Hello class + */ +class Hello { + +} + +// @filename: test2.ts +/* A comment at the top of the file. */ + +/** + * Hi class + */ +class Hi { + +} + +// @filename: test3.ts +// A one-line comment at the top of the file. + +/** + * Hola class + */ +class Hola { + +} diff --git a/tests/cases/compiler/declarationEmitDetachedComment2.ts b/tests/cases/compiler/declarationEmitDetachedComment2.ts new file mode 100644 index 00000000000..1eed803c625 --- /dev/null +++ b/tests/cases/compiler/declarationEmitDetachedComment2.ts @@ -0,0 +1,34 @@ +// @target: es5 +// @module: commonjs +// @declaration: true +// @removeComments: true + +// @filename: test1.ts +/*! Copyright 2015 MyCompany Inc. */ + +/** + * Hello class + */ +class Hello { + +} + +// @filename: test2.ts +/* A comment at the top of the file. */ + +/** + * Hi class + */ +class Hi { + +} + +// @filename: test3.ts +// A one-line comment at the top of the file. + +/** + * Hola class + */ +class Hola { + +} From 6d683d2a967165717907a3cf43d78bbccb269309 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Mon, 2 Nov 2015 10:44:25 -0800 Subject: [PATCH 144/227] Add initial test --- .../genericClassExpressionInFunction.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 tests/cases/conformance/classes/classExpressions/genericClassExpressionInFunction.ts diff --git a/tests/cases/conformance/classes/classExpressions/genericClassExpressionInFunction.ts b/tests/cases/conformance/classes/classExpressions/genericClassExpressionInFunction.ts new file mode 100644 index 00000000000..ab2155c0324 --- /dev/null +++ b/tests/cases/conformance/classes/classExpressions/genericClassExpressionInFunction.ts @@ -0,0 +1,13 @@ +class A { + genericVar: T +} +function B() { + // class expression can use T + return class extends A { } +} +// extends can call B +class K extends B() { + name: string; +} +var c = new K(); +c.genericVar = 12; From 67b9647069322eb3a29f8926500d834b89b0b5ee Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Mon, 2 Nov 2015 10:47:56 -0800 Subject: [PATCH 145/227] Add a variable of type `this` in constructor body The test already had a reference to the `this` value, but that doesn't show that the *type* is allowed. --- tests/baselines/reference/thisTypeErrors2.errors.txt | 1 + tests/baselines/reference/thisTypeErrors2.js | 2 ++ tests/cases/conformance/types/thisType/thisTypeErrors2.ts | 1 + 3 files changed, 4 insertions(+) diff --git a/tests/baselines/reference/thisTypeErrors2.errors.txt b/tests/baselines/reference/thisTypeErrors2.errors.txt index cdb49b877df..783325f4ef3 100644 --- a/tests/baselines/reference/thisTypeErrors2.errors.txt +++ b/tests/baselines/reference/thisTypeErrors2.errors.txt @@ -16,6 +16,7 @@ tests/cases/conformance/types/thisType/thisTypeErrors2.ts(9,38): error TS2526: A constructor(public host: Generic) { ~~~~ !!! error TS2526: A 'this' type is available only in a non-static member of a class or interface. + let self: this = this; this.n = 12; } } diff --git a/tests/baselines/reference/thisTypeErrors2.js b/tests/baselines/reference/thisTypeErrors2.js index 476e2039996..f48d0874e53 100644 --- a/tests/baselines/reference/thisTypeErrors2.js +++ b/tests/baselines/reference/thisTypeErrors2.js @@ -8,6 +8,7 @@ class Generic { class Derived { n: number; constructor(public host: Generic) { + let self: this = this; this.n = 12; } } @@ -27,6 +28,7 @@ var Generic = (function () { var Derived = (function () { function Derived(host) { this.host = host; + var self = this; this.n = 12; } return Derived; diff --git a/tests/cases/conformance/types/thisType/thisTypeErrors2.ts b/tests/cases/conformance/types/thisType/thisTypeErrors2.ts index b30a554bd88..d29e714c4d0 100644 --- a/tests/cases/conformance/types/thisType/thisTypeErrors2.ts +++ b/tests/cases/conformance/types/thisType/thisTypeErrors2.ts @@ -7,6 +7,7 @@ class Generic { class Derived { n: number; constructor(public host: Generic) { + let self: this = this; this.n = 12; } } From d48a4f0cf184f5ff045d027693282c3b1b03c003 Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Mon, 2 Nov 2015 10:48:59 -0800 Subject: [PATCH 146/227] fix nits --- src/compiler/checker.ts | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 8ae8ab3d54c..b77faadd011 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -112,6 +112,7 @@ namespace ts { let circularType = createIntrinsicType(TypeFlags.Any, "__circular__"); let emptyObjectType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); + let emptyUnionType = emptyObjectType; let emptyGenericType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); emptyGenericType.instantiations = {}; @@ -4321,7 +4322,7 @@ namespace ts { // a named type that circularly references itself. function getUnionType(types: Type[], noSubtypeReduction?: boolean): Type { if (types.length === 0) { - return emptyObjectType; + return emptyUnionType; } let typeSet: Type[] = []; addTypesToSet(typeSet, types, TypeFlags.Union); @@ -6278,8 +6279,8 @@ namespace ts { // Only narrow when symbol is variable of type any or an object, union, or type parameter type if (node && symbol.flags & SymbolFlags.Variable) { if (isTypeAny(type) || type.flags & (TypeFlags.ObjectType | TypeFlags.Union | TypeFlags.TypeParameter)) { - let originalType = type; - let nodeStack: {node: Node, child: Node}[] = []; + const originalType = type; + const nodeStack: {node: Node, child: Node}[] = []; loop: while (node.parent) { let child = node; node = node.parent; @@ -6304,7 +6305,7 @@ namespace ts { let nodes: {node: Node, child: Node}; while (nodes = nodeStack.pop()) { - let {node, child} = nodes; + const {node, child} = nodes; switch (node.kind) { case SyntaxKind.IfStatement: // In a branch of an if statement, narrow based on controlling expression @@ -6334,13 +6335,13 @@ namespace ts { } // Use original type if construct contains assignments to variable - if (type != originalType && isVariableAssignedWithin(symbol, node)) { + if (type !== originalType && isVariableAssignedWithin(symbol, node)) { type = originalType; } } // Preserve old top-level behavior - if the branch is really an empty set, revert to prior type - if (type === getUnionType(emptyArray)) { + if (type === emptyUnionType) { type = originalType; } } @@ -6368,7 +6369,7 @@ namespace ts { } let flags: TypeFlags; if (typeInfo) { - flags = typeInfo.flags; + flags = typeInfo.flags; } else { assumeTrue = !assumeTrue; @@ -6377,12 +6378,12 @@ namespace ts { // At this point we can bail if it's not a union if (!(type.flags & TypeFlags.Union)) { // If the active non-union type would be removed from a union by this type guard, return an empty union - return filterUnion(type) ? type : getUnionType(emptyArray); + return filterUnion(type) ? type : emptyUnionType; } return getUnionType(filter((type as UnionType).types, filterUnion), /*noSubtypeReduction*/ true); - function filterUnion(t: Type) { - return assumeTrue === !!(t.flags & flags); + function filterUnion(type: Type) { + return assumeTrue === !!(type.flags & flags); } } @@ -12558,7 +12559,7 @@ namespace ts { arrayType = getUnionType(filter((arrayOrStringType as UnionType).types, t => !(t.flags & TypeFlags.StringLike))); } else if (arrayOrStringType.flags & TypeFlags.StringLike) { - arrayType = getUnionType(emptyArray); + arrayType = emptyUnionType; } let hasStringConstituent = arrayOrStringType !== arrayType; From 6de5221dcddf3da57869a370abf6166993ebff2f Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Mon, 2 Nov 2015 12:53:27 -0800 Subject: [PATCH 147/227] dont mutate --- src/compiler/declarationEmitter.ts | 2 +- src/compiler/emitter.ts | 32 +++++++++++++----------------- 2 files changed, 15 insertions(+), 19 deletions(-) diff --git a/src/compiler/declarationEmitter.ts b/src/compiler/declarationEmitter.ts index 426000f6282..cfb7c98968b 100644 --- a/src/compiler/declarationEmitter.ts +++ b/src/compiler/declarationEmitter.ts @@ -130,7 +130,7 @@ namespace ts { } else if (isExternalModule(sourceFile)) { noDeclare = true; - write(`declare module "${sourceFile.moduleName}" {`); + write(`declare module "${getModuleName(host, sourceFile)}" {`); writeLine(); increaseIndent(); emitSourceFile(sourceFile); diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index 1343a5c85d9..2c6e2dc621f 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -7,6 +7,10 @@ namespace ts { return isExternalModule(sourceFile) || isDeclarationFile(sourceFile); } + export function getModuleName(host: EmitHost, file: SourceFile): string { + return file.moduleName || getExternalModuleNameFromPath(host, file.fileName); + } + type DependencyGroup = Array; let entities: Map = { @@ -578,12 +582,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi forEach(host.getSourceFiles(), emitEmitHelpers); } forEach(host.getSourceFiles(), sourceFile => { - if (!isExternalModuleOrDeclarationFile(sourceFile)) { + if ((!isExternalModuleOrDeclarationFile(sourceFile)) || (modulekind && isExternalModule(sourceFile))) { emitSourceFile(sourceFile); } - else if (modulekind && isExternalModule(sourceFile)) { - emitConcatenatedModule(sourceFile); - } }); } @@ -597,14 +598,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi emit(sourceFile); } - function emitConcatenatedModule(sourceFile: SourceFile): void { - currentSourceFile = sourceFile; - exportFunctionForFile = undefined; - let canonicalName = getExternalModuleNameFromPath(host, sourceFile.fileName); - sourceFile.moduleName = sourceFile.moduleName || canonicalName; - emit(sourceFile); - } - function isUniqueName(name: string): boolean { return !resolver.hasGlobalName(name) && !hasProperty(currentSourceFile.identifiers, name) && @@ -7282,6 +7275,13 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi write("}"); // execute } + function writeModuleName(node: SourceFile, resolveModuleNames?: boolean): void { + let moduleName = node.moduleName; + if (moduleName || (resolveModuleNames && (moduleName = getModuleName(host, node)))) { + write(`"${moduleName}", `); + } + } + function emitSystemModule(node: SourceFile, resolveModuleNames?: boolean): void { collectExternalModuleInfo(node); // System modules has the following shape @@ -7297,9 +7297,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi exportFunctionForFile = makeUniqueName("exports"); writeLine(); write("System.register("); - if (node.moduleName) { - write(`"${node.moduleName}", `); - } + writeModuleName(node, resolveModuleNames); write("["); let groupIndices: Map = {}; @@ -7459,9 +7457,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi writeLine(); write("define("); - if (node.moduleName) { - write("\"" + node.moduleName + "\", "); - } + writeModuleName(node, resolveModuleNames); emitAMDDependencies(node, /*includeNonAmdDependencies*/ true, resolveModuleNames); increaseIndent(); let startIndex = emitDirectivePrologues(node.statements, /*startWithNewLine*/ true); From 4219c5ffecbefea92b507cf57652a0f1ec40c306 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Mon, 2 Nov 2015 13:12:19 -0800 Subject: [PATCH 148/227] Added colors to diagnostic types, addressed some CR feedback. --- src/compiler/tsc.ts | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/src/compiler/tsc.ts b/src/compiler/tsc.ts index ab2a83c90d4..cedfacba9e3 100644 --- a/src/compiler/tsc.ts +++ b/src/compiler/tsc.ts @@ -104,11 +104,23 @@ namespace ts { sys.write(output); } - const shouldUseColors = sys.writesToTty && sys.writesToTty(); + const shouldUseColors = !!sys.writesToTty && sys.writesToTty(); const redForegroundEscapeSequence = shouldUseColors ? "\u001b[91m" : ""; + const yellowForegroundEscapeSequence = shouldUseColors ? "\u001b[93m" : ""; + const blueForegroundEscapeSequence = shouldUseColors ? "\u001b[93m" : ""; const gutterStyleSequence = shouldUseColors ? "\u001b[100;30m" : ""; const gutterSeparator = shouldUseColors ? " " : " | "; const resetEscapeSequence = shouldUseColors ? "\u001b[0m" : ""; + const elipsis = "..."; + const categoryFormatMap: Map = { + [DiagnosticCategory.Warning]: yellowForegroundEscapeSequence, + [DiagnosticCategory.Error]: redForegroundEscapeSequence, + [DiagnosticCategory.Message]: blueForegroundEscapeSequence, + } + + function formatAndReset(text: string, formatStyle: string) { + return formatStyle + text + resetEscapeSequence; + } function reportDiagnosticWithColorAndContext(diagnostic: Diagnostic): void { let output = ""; @@ -122,7 +134,7 @@ namespace ts { let hasMoreThanFiveLines = (lastLine - firstLine) >= 4; let gutterWidth = (lastLine + 1 + "").length; if (hasMoreThanFiveLines) { - gutterWidth = Math.max("...".length, gutterWidth); + gutterWidth = Math.max(elipsis.length, gutterWidth); } output += sys.newLine; @@ -130,7 +142,7 @@ namespace ts { // If the error spans over 5 lines, we'll only show the first 2 and last 2 lines, // so we'll skip ahead to the second-to-last line. if (hasMoreThanFiveLines && firstLine + 1 < i && i < lastLine - 1) { - output += gutterStyleSequence + padLeft("...", gutterWidth) + resetEscapeSequence + gutterSeparator + sys.newLine; + output += formatAndReset(padLeft(elipsis, gutterWidth), gutterStyleSequence) + gutterSeparator + sys.newLine; i = lastLine - 1; } @@ -141,16 +153,16 @@ namespace ts { lineContent = lineContent.replace("\t", " "); // convert tabs to single spaces // Output the gutter and the actual contents of the line. - output += gutterStyleSequence + padLeft(i + 1 + "", gutterWidth) + resetEscapeSequence + gutterSeparator; + output += formatAndReset(padLeft(i + 1 + "", gutterWidth), gutterStyleSequence) + gutterSeparator; output += lineContent + sys.newLine; // Output the gutter and the error span for the line using tildes. - output += gutterStyleSequence + padLeft("", gutterWidth) + resetEscapeSequence + gutterSeparator; + output += formatAndReset(padLeft("", gutterWidth), gutterStyleSequence) + gutterSeparator; output += redForegroundEscapeSequence; if (i === firstLine) { // If we're on the last line, then limit it to the last character of the last line. // Otherwise, we'll just squiggle the rest of the line, giving 'slice' no end position. - let lastCharForLine = i === lastLine ? lastLineChar : undefined; + const lastCharForLine = i === lastLine ? lastLineChar : undefined; output += lineContent.slice(0, firstLineChar).replace(/\S/g, " "); output += lineContent.slice(firstLineChar, lastCharForLine).replace(/./g, "~"); @@ -171,8 +183,9 @@ namespace ts { output += `${ file.fileName }(${ firstLine + 1 },${ firstLineChar + 1 }): `; } - let category = DiagnosticCategory[diagnostic.category].toLowerCase(); - output += `${ category } TS${ diagnostic.code }: ${ flattenDiagnosticMessageText(diagnostic.messageText, sys.newLine) }`; + const categoryColor = categoryFormatMap[diagnostic.category]; + const category = DiagnosticCategory[diagnostic.category].toLowerCase(); + output += `${ formatAndReset(category, categoryColor) } TS${ diagnostic.code }: ${ flattenDiagnosticMessageText(diagnostic.messageText, sys.newLine) }`; output += sys.newLine + sys.newLine; sys.write(output); From 654cbd977940b367962500f3d89dd28b21383704 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Mon, 2 Nov 2015 13:20:48 -0800 Subject: [PATCH 149/227] Just name the option 'pretty' for now. --- src/compiler/commandLineParser.ts | 17 ++++++----------- src/compiler/diagnosticMessages.json | 6 +----- src/compiler/tsc.ts | 2 +- src/compiler/types.ts | 2 +- 4 files changed, 9 insertions(+), 18 deletions(-) diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index ee1a36ec45e..141ab85929e 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -21,17 +21,6 @@ namespace ts { name: "diagnostics", type: "boolean", }, - { - name: "diagnosticStyle", - paramType: Diagnostics.KIND, - description: Diagnostics.Specify_diagnostic_printing_style_Colon_simple_default_or_pretty, - type: { - "simple": DiagnosticStyle.Simple, - "pretty": DiagnosticStyle.Pretty, - }, - error: Diagnostics.Argument_for_diagnosticStyle_must_be_simple_or_pretty, - experimental: true, - }, { name: "emitBOM", type: "boolean" @@ -162,6 +151,12 @@ namespace ts { type: "boolean", description: Diagnostics.Do_not_erase_const_enum_declarations_in_generated_code }, + { + name: "pretty", + paramType: Diagnostics.KIND, + description: Diagnostics.Stylize_errors_and_messages_using_colors_if_available_experimental, + type: "boolean" + }, { name: "project", shortName: "p", diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 0abe92299bf..ed17c2a77b0 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -2286,14 +2286,10 @@ "category": "Message", "code": 6072 }, - "Specify diagnostic printing style: 'simple' (default) or 'pretty'.": { + "Stylize errors and messages using colors if available. (experimental)": { "category": "Message", "code": 6073 }, - "Argument for '--diagnosticStyle' must be 'simple' or 'pretty'.": { - "category": "Error", - "code": 6074 - }, "Specify JSX code generation: 'preserve' or 'react'": { "category": "Message", diff --git a/src/compiler/tsc.ts b/src/compiler/tsc.ts index cedfacba9e3..66a6cbb65bd 100644 --- a/src/compiler/tsc.ts +++ b/src/compiler/tsc.ts @@ -374,7 +374,7 @@ namespace ts { compilerHost.fileExists = cachedFileExists; } - if (compilerOptions.diagnosticStyle === DiagnosticStyle.Pretty) { + if (compilerOptions.pretty) { reportDiagnostic = reportDiagnosticWithColorAndContext; } diff --git a/src/compiler/types.ts b/src/compiler/types.ts index ca8a0014924..363c3a4a29f 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -2053,7 +2053,6 @@ namespace ts { charset?: string; declaration?: boolean; diagnostics?: boolean; - /* @internal */diagnosticStyle?: DiagnosticStyle; emitBOM?: boolean; help?: boolean; init?: boolean; @@ -2076,6 +2075,7 @@ namespace ts { outFile?: string; outDir?: string; preserveConstEnums?: boolean; + /* @internal */ pretty?: DiagnosticStyle; project?: string; removeComments?: boolean; rootDir?: string; From 40f10abe01b3765193c62f7eacb7e17e2f911cd7 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Mon, 2 Nov 2015 14:48:28 -0800 Subject: [PATCH 150/227] Forget about tty detection. It won't work in build tools. --- src/compiler/sys.ts | 2 -- src/compiler/tsc.ts | 13 ++++++------- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/src/compiler/sys.ts b/src/compiler/sys.ts index ee9d1a9653c..6263f7237f6 100644 --- a/src/compiler/sys.ts +++ b/src/compiler/sys.ts @@ -6,7 +6,6 @@ namespace ts { newLine: string; useCaseSensitiveFileNames: boolean; write(s: string): void; - writesToTty?(): boolean; readFile(path: string, encoding?: string): string; writeFile(path: string, data: string, writeByteOrderMark?: boolean): void; watchFile?(path: string, callback: (path: string, removed?: boolean) => void): FileWatcher; @@ -379,7 +378,6 @@ namespace ts { write(s: string): void { process.stdout.write(s); }, - writesToTty: () => _tty.isatty(1), readFile, writeFile, watchFile: (fileName, callback) => { diff --git a/src/compiler/tsc.ts b/src/compiler/tsc.ts index 66a6cbb65bd..f996797db6e 100644 --- a/src/compiler/tsc.ts +++ b/src/compiler/tsc.ts @@ -104,13 +104,12 @@ namespace ts { sys.write(output); } - const shouldUseColors = !!sys.writesToTty && sys.writesToTty(); - const redForegroundEscapeSequence = shouldUseColors ? "\u001b[91m" : ""; - const yellowForegroundEscapeSequence = shouldUseColors ? "\u001b[93m" : ""; - const blueForegroundEscapeSequence = shouldUseColors ? "\u001b[93m" : ""; - const gutterStyleSequence = shouldUseColors ? "\u001b[100;30m" : ""; - const gutterSeparator = shouldUseColors ? " " : " | "; - const resetEscapeSequence = shouldUseColors ? "\u001b[0m" : ""; + const redForegroundEscapeSequence = "\u001b[91m"; + const yellowForegroundEscapeSequence = "\u001b[93m"; + const blueForegroundEscapeSequence = "\u001b[93m"; + const gutterStyleSequence = "\u001b[100;30m"; + const gutterSeparator = " "; + const resetEscapeSequence = "\u001b[0m"; const elipsis = "..."; const categoryFormatMap: Map = { [DiagnosticCategory.Warning]: yellowForegroundEscapeSequence, From 8d60ed3d43905a28d35cf7f681ca82ae71a7f5ae Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Mon, 2 Nov 2015 15:24:23 -0800 Subject: [PATCH 151/227] Update baselines --- tests/baselines/reference/typeGuardFunctionErrors.errors.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/baselines/reference/typeGuardFunctionErrors.errors.txt b/tests/baselines/reference/typeGuardFunctionErrors.errors.txt index f05c44b8325..92d9d21f0cc 100644 --- a/tests/baselines/reference/typeGuardFunctionErrors.errors.txt +++ b/tests/baselines/reference/typeGuardFunctionErrors.errors.txt @@ -40,7 +40,7 @@ tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(133,34 tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(137,39): error TS1230: A type predicate cannot reference element 'p1' in a binding pattern. -==== tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts (32 errors) ==== +==== tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts (33 errors) ==== class A { propA: number; From ce24bcb2eecec7c0d5cdc5d760a28b2428d79345 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Mon, 2 Nov 2015 15:45:57 -0800 Subject: [PATCH 152/227] ; --- src/compiler/tsc.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compiler/tsc.ts b/src/compiler/tsc.ts index de43ce10332..083df70be0f 100644 --- a/src/compiler/tsc.ts +++ b/src/compiler/tsc.ts @@ -119,7 +119,7 @@ namespace ts { [DiagnosticCategory.Warning]: yellowForegroundEscapeSequence, [DiagnosticCategory.Error]: redForegroundEscapeSequence, [DiagnosticCategory.Message]: blueForegroundEscapeSequence, - } + }; function formatAndReset(text: string, formatStyle: string) { return formatStyle + text + resetEscapeSequence; From a44a3404494e50cc2be5af0483458d77e9a19d90 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Mon, 2 Nov 2015 16:40:35 -0800 Subject: [PATCH 153/227] Fix description of '--pretty'. --- src/compiler/commandLineParser.ts | 2 +- src/compiler/diagnosticMessages.json | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index b39a802a0b5..f4de5c430ac 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -154,7 +154,7 @@ namespace ts { { name: "pretty", paramType: Diagnostics.KIND, - description: Diagnostics.Stylize_errors_and_messages_using_colors_if_available_experimental, + description: Diagnostics.Stylize_errors_and_messages_using_color_and_context_experimental, type: "boolean" }, { diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 401cbaf8dda..e6008ce3c1e 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -2285,8 +2285,8 @@ "Suppress excess property checks for object literals.": { "category": "Message", "code": 6072 - }, - "Stylize errors and messages using colors if available. (experimental)": { + }, + "Stylize errors and messages using color and context. (experimental)": { "category": "Message", "code": 6073 }, @@ -2318,8 +2318,8 @@ "Argument for '--jsx' must be 'preserve' or 'react'.": { "category": "Message", "code": 6081 - }, - + }, + "Variable '{0}' implicitly has an '{1}' type.": { "category": "Error", "code": 7005 From fc51ca749ce987e0be53fb7c96577a3b82ab617e Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Mon, 2 Nov 2015 16:41:13 -0800 Subject: [PATCH 154/227] Updated LKG. --- lib/tsc.js | 1660 ++++++++++++++++++----------- lib/tsserver.js | 1945 ++++++++++++++++++++-------------- lib/typescript.d.ts | 101 +- lib/typescript.js | 1992 +++++++++++++++++++++-------------- lib/typescriptServices.d.ts | 101 +- lib/typescriptServices.js | 1992 +++++++++++++++++++++-------------- 6 files changed, 4765 insertions(+), 3026 deletions(-) diff --git a/lib/tsc.js b/lib/tsc.js index 511fc67c0aa..bbbcedf0f47 100644 --- a/lib/tsc.js +++ b/lib/tsc.js @@ -49,40 +49,49 @@ var ts; })(ts || (ts = {})); var ts; (function (ts) { - function createFileMap(getCanonicalFileName) { + function createFileMap(keyMapper) { var files = {}; return { get: get, set: set, contains: contains, remove: remove, - clear: clear, - forEachValue: forEachValueInMap + forEachValue: forEachValueInMap, + clear: clear }; - function set(fileName, value) { - files[normalizeKey(fileName)] = value; - } - function get(fileName) { - return files[normalizeKey(fileName)]; - } - function contains(fileName) { - return hasProperty(files, normalizeKey(fileName)); - } - function remove(fileName) { - var key = normalizeKey(fileName); - delete files[key]; - } function forEachValueInMap(f) { - forEachValue(files, f); + for (var key in files) { + f(key, files[key]); + } } - function normalizeKey(key) { - return getCanonicalFileName(normalizeSlashes(key)); + function get(path) { + return files[toKey(path)]; + } + function set(path, value) { + files[toKey(path)] = value; + } + function contains(path) { + return hasProperty(files, toKey(path)); + } + function remove(path) { + var key = toKey(path); + delete files[key]; } function clear() { files = {}; } + function toKey(path) { + return keyMapper ? keyMapper(path) : path; + } } ts.createFileMap = createFileMap; + function toPath(fileName, basePath, getCanonicalFileName) { + var nonCanonicalizedPath = isRootedDiskPath(fileName) + ? normalizePath(fileName) + : getNormalizedAbsolutePath(fileName, basePath); + return getCanonicalFileName(nonCanonicalizedPath); + } + ts.toPath = toPath; function forEach(array, callback) { if (array) { for (var i = 0, len = array.length; i < len; i++) { @@ -97,8 +106,8 @@ var ts; ts.forEach = forEach; function contains(array, value) { if (array) { - for (var _i = 0; _i < array.length; _i++) { - var v = array[_i]; + for (var _i = 0, array_1 = array; _i < array_1.length; _i++) { + var v = array_1[_i]; if (v === value) { return true; } @@ -121,8 +130,8 @@ var ts; function countWhere(array, predicate) { var count = 0; if (array) { - for (var _i = 0; _i < array.length; _i++) { - var v = array[_i]; + for (var _i = 0, array_2 = array; _i < array_2.length; _i++) { + var v = array_2[_i]; if (predicate(v)) { count++; } @@ -135,8 +144,8 @@ var ts; var result; if (array) { result = []; - for (var _i = 0; _i < array.length; _i++) { - var item = array[_i]; + for (var _i = 0, array_3 = array; _i < array_3.length; _i++) { + var item = array_3[_i]; if (f(item)) { result.push(item); } @@ -149,8 +158,8 @@ var ts; var result; if (array) { result = []; - for (var _i = 0; _i < array.length; _i++) { - var v = array[_i]; + for (var _i = 0, array_4 = array; _i < array_4.length; _i++) { + var v = array_4[_i]; result.push(f(v)); } } @@ -169,8 +178,8 @@ var ts; var result; if (array) { result = []; - for (var _i = 0; _i < array.length; _i++) { - var item = array[_i]; + for (var _i = 0, array_5 = array; _i < array_5.length; _i++) { + var item = array_5[_i]; if (!contains(result, item)) { result.push(item); } @@ -181,8 +190,8 @@ var ts; ts.deduplicate = deduplicate; function sum(array, prop) { var result = 0; - for (var _i = 0; _i < array.length; _i++) { - var v = array[_i]; + for (var _i = 0, array_6 = array; _i < array_6.length; _i++) { + var v = array_6[_i]; result += v[prop]; } return result; @@ -190,8 +199,8 @@ var ts; ts.sum = sum; function addRange(to, from) { if (to && from) { - for (var _i = 0; _i < from.length; _i++) { - var v = from[_i]; + for (var _i = 0, from_1 = from; _i < from_1.length; _i++) { + var v = from_1[_i]; to.push(v); } } @@ -512,8 +521,8 @@ var ts; function getNormalizedParts(normalizedSlashedPath, rootLength) { var parts = normalizedSlashedPath.substr(rootLength).split(ts.directorySeparator); var normalized = []; - for (var _i = 0; _i < parts.length; _i++) { - var part = parts[_i]; + for (var _i = 0, parts_1 = parts; _i < parts_1.length; _i++) { + var part = parts_1[_i]; if (part !== ".") { if (part === ".." && normalized.length > 0 && lastOrUndefined(normalized) !== "..") { normalized.pop(); @@ -661,8 +670,8 @@ var ts; if (!fileName) { return false; } - for (var _i = 0; _i < ts.supportedExtensions.length; _i++) { - var extension = ts.supportedExtensions[_i]; + for (var _i = 0, supportedExtensions_1 = ts.supportedExtensions; _i < supportedExtensions_1.length; _i++) { + var extension = supportedExtensions_1[_i]; if (fileExtensionIs(fileName, extension)) { return true; } @@ -672,8 +681,8 @@ var ts; ts.isSupportedSourceFileName = isSupportedSourceFileName; var extensionsToRemove = [".d.ts", ".ts", ".js", ".tsx", ".jsx"]; function removeFileExtension(path) { - for (var _i = 0; _i < extensionsToRemove.length; _i++) { - var ext = extensionsToRemove[_i]; + for (var _i = 0, extensionsToRemove_1 = extensionsToRemove; _i < extensionsToRemove_1.length; _i++) { + var ext = extensionsToRemove_1[_i]; if (fileExtensionIs(path, ext)) { return path.substr(0, path.length - ext.length); } @@ -747,8 +756,8 @@ var ts; })(Debug = ts.Debug || (ts.Debug = {})); function copyListRemovingItem(item, list) { var copiedList = []; - for (var _i = 0; _i < list.length; _i++) { - var e = list[_i]; + for (var _i = 0, list_1 = list; _i < list_1.length; _i++) { + var e = list_1[_i]; if (e !== item) { copiedList.push(e); } @@ -834,16 +843,16 @@ var ts; function visitDirectory(path) { var folder = fso.GetFolder(path || "."); var files = getNames(folder.files); - for (var _i = 0; _i < files.length; _i++) { - var current = files[_i]; + for (var _i = 0, files_1 = files; _i < files_1.length; _i++) { + var current = files_1[_i]; var name_1 = ts.combinePaths(path, current); if ((!extension || ts.fileExtensionIs(name_1, extension)) && !ts.contains(exclude, getCanonicalPath(name_1))) { result.push(name_1); } } var subfolders = getNames(folder.subfolders); - for (var _a = 0; _a < subfolders.length; _a++) { - var current = subfolders[_a]; + for (var _a = 0, subfolders_1 = subfolders; _a < subfolders_1.length; _a++) { + var current = subfolders_1[_a]; var name_2 = ts.combinePaths(path, current); if (!ts.contains(exclude, getCanonicalPath(name_2))) { visitDirectory(name_2); @@ -894,6 +903,7 @@ var ts; var _fs = require("fs"); var _path = require("path"); var _os = require("os"); + var _tty = require("tty"); function createWatchedFileSet(interval, chunkSize) { if (interval === void 0) { interval = 2500; } if (chunkSize === void 0) { chunkSize = 30; } @@ -1006,8 +1016,8 @@ var ts; function visitDirectory(path) { var files = _fs.readdirSync(path || ".").sort(); var directories = []; - for (var _i = 0; _i < files.length; _i++) { - var current = files[_i]; + for (var _i = 0, files_2 = files; _i < files_2.length; _i++) { + var current = files_2[_i]; var name_3 = ts.combinePaths(path, current); if (!ts.contains(exclude, getCanonicalPath(name_3))) { var stat = _fs.statSync(name_3); @@ -1021,8 +1031,8 @@ var ts; } } } - for (var _a = 0; _a < directories.length; _a++) { - var current = directories[_a]; + for (var _a = 0, directories_1 = directories; _a < directories_1.length; _a++) { + var current = directories_1[_a]; visitDirectory(current); } } @@ -1032,14 +1042,7 @@ var ts; newLine: _os.EOL, useCaseSensitiveFileNames: useCaseSensitiveFileNames, write: function (s) { - var buffer = new Buffer(s, "utf8"); - var offset = 0; - var toWrite = buffer.length; - var written = 0; - while ((written = _fs.writeSync(1, buffer, offset, toWrite)) < toWrite) { - offset += written; - toWrite -= written; - } + process.stdout.write(s); }, readFile: readFile, writeFile: writeFile, @@ -1306,6 +1309,7 @@ var ts; await_expression_is_only_allowed_within_an_async_function: { code: 1308, category: ts.DiagnosticCategory.Error, key: "await_expression_is_only_allowed_within_an_async_function_1308", message: "'await' expression is only allowed within an async function." }, Async_functions_are_only_available_when_targeting_ECMAScript_6_and_higher: { code: 1311, category: ts.DiagnosticCategory.Error, key: "Async_functions_are_only_available_when_targeting_ECMAScript_6_and_higher_1311", message: "Async functions are only available when targeting ECMAScript 6 and higher." }, can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment: { code: 1312, category: ts.DiagnosticCategory.Error, key: "can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment_1312", message: "'=' can only be used in an object literal property inside a destructuring assignment." }, + The_body_of_an_if_statement_cannot_be_the_empty_statement: { code: 1313, category: ts.DiagnosticCategory.Error, key: "The_body_of_an_if_statement_cannot_be_the_empty_statement_1313", message: "The body of an 'if' statement cannot be the empty statement." }, Duplicate_identifier_0: { code: 2300, category: ts.DiagnosticCategory.Error, key: "Duplicate_identifier_0_2300", message: "Duplicate identifier '{0}'." }, Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor: { code: 2301, category: ts.DiagnosticCategory.Error, key: "Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor_2301", message: "Initializer of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor." }, Static_members_cannot_reference_class_type_parameters: { code: 2302, category: ts.DiagnosticCategory.Error, key: "Static_members_cannot_reference_class_type_parameters_2302", message: "Static members cannot reference class type parameters." }, @@ -1358,7 +1362,7 @@ var ts; Neither_type_0_nor_type_1_is_assignable_to_the_other: { code: 2352, category: ts.DiagnosticCategory.Error, key: "Neither_type_0_nor_type_1_is_assignable_to_the_other_2352", message: "Neither type '{0}' nor type '{1}' is assignable to the other." }, Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1: { code: 2353, category: ts.DiagnosticCategory.Error, key: "Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1_2353", message: "Object literal may only specify known properties, and '{0}' does not exist in type '{1}'." }, No_best_common_type_exists_among_return_expressions: { code: 2354, category: ts.DiagnosticCategory.Error, key: "No_best_common_type_exists_among_return_expressions_2354", message: "No best common type exists among return expressions." }, - A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value_or_consist_of_a_single_throw_statement: { code: 2355, category: ts.DiagnosticCategory.Error, key: "A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value_or_consist_of_a_single_th_2355", message: "A function whose declared type is neither 'void' nor 'any' must return a value or consist of a single 'throw' statement." }, + A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value: { code: 2355, category: ts.DiagnosticCategory.Error, key: "A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value_2355", message: "A function whose declared type is neither 'void' nor 'any' must return a value." }, An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type: { code: 2356, category: ts.DiagnosticCategory.Error, key: "An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type_2356", message: "An arithmetic operand must be of type 'any', 'number' or an enum type." }, The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_property_or_indexer: { code: 2357, category: ts.DiagnosticCategory.Error, key: "The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_property_or_indexer_2357", message: "The operand of an increment or decrement operator must be a variable, property or indexer." }, The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_parameter: { code: 2358, category: ts.DiagnosticCategory.Error, key: "The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_paramete_2358", message: "The left-hand side of an 'instanceof' expression must be of type 'any', an object type or a type parameter." }, @@ -1379,7 +1383,7 @@ var ts; Duplicate_number_index_signature: { code: 2375, category: ts.DiagnosticCategory.Error, key: "Duplicate_number_index_signature_2375", message: "Duplicate number index signature." }, A_super_call_must_be_the_first_statement_in_the_constructor_when_a_class_contains_initialized_properties_or_has_parameter_properties: { code: 2376, category: ts.DiagnosticCategory.Error, key: "A_super_call_must_be_the_first_statement_in_the_constructor_when_a_class_contains_initialized_proper_2376", message: "A 'super' call must be the first statement in the constructor when a class contains initialized properties or has parameter properties." }, Constructors_for_derived_classes_must_contain_a_super_call: { code: 2377, category: ts.DiagnosticCategory.Error, key: "Constructors_for_derived_classes_must_contain_a_super_call_2377", message: "Constructors for derived classes must contain a 'super' call." }, - A_get_accessor_must_return_a_value_or_consist_of_a_single_throw_statement: { code: 2378, category: ts.DiagnosticCategory.Error, key: "A_get_accessor_must_return_a_value_or_consist_of_a_single_throw_statement_2378", message: "A 'get' accessor must return a value or consist of a single 'throw' statement." }, + A_get_accessor_must_return_a_value: { code: 2378, category: ts.DiagnosticCategory.Error, key: "A_get_accessor_must_return_a_value_2378", message: "A 'get' accessor must return a value." }, Getter_and_setter_accessors_do_not_agree_in_visibility: { code: 2379, category: ts.DiagnosticCategory.Error, key: "Getter_and_setter_accessors_do_not_agree_in_visibility_2379", message: "Getter and setter accessors do not agree in visibility." }, get_and_set_accessor_must_have_the_same_type: { code: 2380, category: ts.DiagnosticCategory.Error, key: "get_and_set_accessor_must_have_the_same_type_2380", message: "'get' and 'set' accessor must have the same type." }, A_signature_with_an_implementation_cannot_use_a_string_literal_type: { code: 2381, category: ts.DiagnosticCategory.Error, key: "A_signature_with_an_implementation_cannot_use_a_string_literal_type_2381", message: "A signature with an implementation cannot use a string literal type." }, @@ -1669,8 +1673,6 @@ var ts; NEWLINE: { code: 6061, category: ts.DiagnosticCategory.Message, key: "NEWLINE_6061", message: "NEWLINE" }, Argument_for_newLine_option_must_be_CRLF_or_LF: { code: 6062, category: ts.DiagnosticCategory.Error, key: "Argument_for_newLine_option_must_be_CRLF_or_LF_6062", message: "Argument for '--newLine' option must be 'CRLF' or 'LF'." }, Argument_for_moduleResolution_option_must_be_node_or_classic: { code: 6063, category: ts.DiagnosticCategory.Error, key: "Argument_for_moduleResolution_option_must_be_node_or_classic_6063", message: "Argument for '--moduleResolution' option must be 'node' or 'classic'." }, - Specify_JSX_code_generation_Colon_preserve_or_react: { code: 6080, category: ts.DiagnosticCategory.Message, key: "Specify_JSX_code_generation_Colon_preserve_or_react_6080", message: "Specify JSX code generation: 'preserve' or 'react'" }, - Argument_for_jsx_must_be_preserve_or_react: { code: 6081, category: ts.DiagnosticCategory.Message, key: "Argument_for_jsx_must_be_preserve_or_react_6081", message: "Argument for '--jsx' must be 'preserve' or 'react'." }, Enables_experimental_support_for_ES7_decorators: { code: 6065, category: ts.DiagnosticCategory.Message, key: "Enables_experimental_support_for_ES7_decorators_6065", message: "Enables experimental support for ES7 decorators." }, Enables_experimental_support_for_emitting_type_metadata_for_decorators: { code: 6066, category: ts.DiagnosticCategory.Message, key: "Enables_experimental_support_for_emitting_type_metadata_for_decorators_6066", message: "Enables experimental support for emitting type metadata for decorators." }, Enables_experimental_support_for_ES7_async_functions: { code: 6068, category: ts.DiagnosticCategory.Message, key: "Enables_experimental_support_for_ES7_async_functions_6068", message: "Enables experimental support for ES7 async functions." }, @@ -1678,7 +1680,14 @@ var ts; Initializes_a_TypeScript_project_and_creates_a_tsconfig_json_file: { code: 6070, category: ts.DiagnosticCategory.Message, key: "Initializes_a_TypeScript_project_and_creates_a_tsconfig_json_file_6070", message: "Initializes a TypeScript project and creates a tsconfig.json file." }, Successfully_created_a_tsconfig_json_file: { code: 6071, category: ts.DiagnosticCategory.Message, key: "Successfully_created_a_tsconfig_json_file_6071", message: "Successfully created a tsconfig.json file." }, Suppress_excess_property_checks_for_object_literals: { code: 6072, category: ts.DiagnosticCategory.Message, key: "Suppress_excess_property_checks_for_object_literals_6072", message: "Suppress excess property checks for object literals." }, - Disallow_inconsistently_cased_references_to_the_same_file: { code: 6073, category: ts.DiagnosticCategory.Message, key: "Disallow_inconsistently_cased_references_to_the_same_file_6073", message: "Disallow inconsistently-cased references to the same file." }, + Stylize_errors_and_messages_using_color_and_context_experimental: { code: 6073, category: ts.DiagnosticCategory.Message, key: "Stylize_errors_and_messages_using_color_and_context_experimental_6073", message: "Stylize errors and messages using color and context. (experimental)" }, + Do_not_report_errors_on_unused_labels: { code: 6074, category: ts.DiagnosticCategory.Message, key: "Do_not_report_errors_on_unused_labels_6074", message: "Do not report errors on unused labels." }, + Report_error_when_not_all_code_paths_in_function_return_a_value: { code: 6075, category: ts.DiagnosticCategory.Message, key: "Report_error_when_not_all_code_paths_in_function_return_a_value_6075", message: "Report error when not all code paths in function return a value." }, + Report_errors_for_fallthrough_cases_in_switch_statement: { code: 6076, category: ts.DiagnosticCategory.Message, key: "Report_errors_for_fallthrough_cases_in_switch_statement_6076", message: "Report errors for fallthrough cases in switch statement." }, + Do_not_report_errors_on_unreachable_code: { code: 6077, category: ts.DiagnosticCategory.Message, key: "Do_not_report_errors_on_unreachable_code_6077", message: "Do not report errors on unreachable code." }, + Disallow_inconsistently_cased_references_to_the_same_file: { code: 6078, category: ts.DiagnosticCategory.Message, key: "Disallow_inconsistently_cased_references_to_the_same_file_6078", message: "Disallow inconsistently-cased references to the same file." }, + Specify_JSX_code_generation_Colon_preserve_or_react: { code: 6080, category: ts.DiagnosticCategory.Message, key: "Specify_JSX_code_generation_Colon_preserve_or_react_6080", message: "Specify JSX code generation: 'preserve' or 'react'" }, + Argument_for_jsx_must_be_preserve_or_react: { code: 6081, category: ts.DiagnosticCategory.Message, key: "Argument_for_jsx_must_be_preserve_or_react_6081", message: "Argument for '--jsx' must be 'preserve' or 'react'." }, 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." }, @@ -1696,6 +1705,10 @@ var ts; Function_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions: { code: 7024, category: ts.DiagnosticCategory.Error, key: "Function_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_ref_7024", message: "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." }, Generator_implicitly_has_type_0_because_it_does_not_yield_any_values_Consider_supplying_a_return_type: { code: 7025, category: ts.DiagnosticCategory.Error, key: "Generator_implicitly_has_type_0_because_it_does_not_yield_any_values_Consider_supplying_a_return_typ_7025", message: "Generator implicitly has type '{0}' because it does not yield any values. Consider supplying a return type." }, JSX_element_implicitly_has_type_any_because_no_interface_JSX_0_exists: { code: 7026, category: ts.DiagnosticCategory.Error, key: "JSX_element_implicitly_has_type_any_because_no_interface_JSX_0_exists_7026", message: "JSX element implicitly has type 'any' because no interface 'JSX.{0}' exists" }, + Unreachable_code_detected: { code: 7027, category: ts.DiagnosticCategory.Error, key: "Unreachable_code_detected_7027", message: "Unreachable code detected." }, + Unused_label: { code: 7028, category: ts.DiagnosticCategory.Error, key: "Unused_label_7028", message: "Unused label." }, + Fallthrough_case_in_switch: { code: 7029, category: ts.DiagnosticCategory.Error, key: "Fallthrough_case_in_switch_7029", message: "Fallthrough case in switch." }, + Not_all_code_paths_return_a_value: { code: 7030, category: ts.DiagnosticCategory.Error, key: "Not_all_code_paths_return_a_value_7030", message: "Not all code paths return a value." }, 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." }, @@ -3082,6 +3095,13 @@ var ts; var ts; (function (ts) { ts.bindTime = 0; + function or(state1, state2) { + return (state1 | state2) & 2 + ? 2 + : (state1 & state2) & 8 + ? 8 + : 4; + } function getModuleInstanceState(node) { if (node.kind === 215 || node.kind === 216) { return 0; @@ -3089,7 +3109,7 @@ var ts; else if (ts.isConstEnumDeclaration(node)) { return 2; } - else if ((node.kind === 222 || node.kind === 221) && !(node.flags & 1)) { + else if ((node.kind === 222 || node.kind === 221) && !(node.flags & 2)) { return 0; } else if (node.kind === 219) { @@ -3116,28 +3136,52 @@ var ts; } } ts.getModuleInstanceState = getModuleInstanceState; - function bindSourceFile(file) { + var binder = createBinder(); + function bindSourceFile(file, options) { var start = new Date().getTime(); - bindSourceFileWorker(file); + binder(file, options); ts.bindTime += new Date().getTime() - start; } ts.bindSourceFile = bindSourceFile; - function bindSourceFileWorker(file) { + function createBinder() { + var file; + var options; var parent; var container; var blockScopeContainer; var lastContainer; var seenThisKeyword; - var inStrictMode = !!file.externalModuleIndicator; + var hasExplicitReturn; + var currentReachabilityState; + var labelStack; + var labelIndexMap; + var implicitLabels; + var inStrictMode; var symbolCount = 0; - var Symbol = ts.objectAllocator.getSymbolConstructor(); - var classifiableNames = {}; - if (!file.locals) { - bind(file); - file.symbolCount = symbolCount; - file.classifiableNames = classifiableNames; + var Symbol; + var classifiableNames; + function bindSourceFile(f, opts) { + file = f; + options = opts; + inStrictMode = !!file.externalModuleIndicator; + classifiableNames = {}; + Symbol = ts.objectAllocator.getSymbolConstructor(); + if (!file.locals) { + bind(file); + file.symbolCount = symbolCount; + file.classifiableNames = classifiableNames; + } + parent = undefined; + container = undefined; + blockScopeContainer = undefined; + lastContainer = undefined; + seenThisKeyword = false; + hasExplicitReturn = false; + labelStack = undefined; + labelIndexMap = undefined; + implicitLabels = undefined; } - return; + return bindSourceFile; function createSymbol(flags, name) { symbolCount++; return new Symbol(flags, name); @@ -3188,7 +3232,7 @@ var ts; return node.isExportEquals ? "export=" : "default"; case 213: case 214: - return node.flags & 1024 ? "default" : undefined; + return node.flags & 512 ? "default" : undefined; } } function getDisplayName(node) { @@ -3196,7 +3240,7 @@ var ts; } function declareSymbol(symbolTable, parent, node, includes, excludes) { ts.Debug.assert(!ts.hasDynamicName(node)); - var isDefaultExport = node.flags & 1024; + var isDefaultExport = node.flags & 512; var name = isDefaultExport && parent ? "default" : getDeclarationName(node); var symbol; if (name !== undefined) { @@ -3214,7 +3258,7 @@ var ts; ? ts.Diagnostics.Cannot_redeclare_block_scoped_variable_0 : ts.Diagnostics.Duplicate_identifier_0; ts.forEach(symbol.declarations, function (declaration) { - if (declaration.flags & 1024) { + if (declaration.flags & 512) { message = ts.Diagnostics.A_module_cannot_have_multiple_default_exports; } }); @@ -3233,7 +3277,7 @@ var ts; return symbol; } function declareModuleMember(node, symbolFlags, symbolExcludes) { - var hasExportModifier = ts.getCombinedNodeFlags(node) & 1; + var hasExportModifier = ts.getCombinedNodeFlags(node) & 2; if (symbolFlags & 8388608) { if (node.kind === 230 || (node.kind === 221 && hasExportModifier)) { return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); @@ -3243,7 +3287,7 @@ var ts; } } else { - if (hasExportModifier || container.flags & 262144) { + if (hasExportModifier || container.flags & 131072) { var exportKind = (symbolFlags & 107455 ? 1048576 : 0) | (symbolFlags & 793056 ? 2097152 : 0) | (symbolFlags & 1536 ? 4194304 : 0); @@ -3274,18 +3318,202 @@ var ts; blockScopeContainer = node; blockScopeContainer.locals = undefined; } - if (node.kind === 215) { + var savedReachabilityState; + var savedLabelStack; + var savedLabels; + var savedImplicitLabels; + var savedHasExplicitReturn; + var kind = node.kind; + var flags = node.flags; + flags &= ~1572864; + if (kind === 215) { seenThisKeyword = false; - ts.forEachChild(node, bind); - node.flags = seenThisKeyword ? node.flags | 524288 : node.flags & ~524288; } - else { - ts.forEachChild(node, bind); + var saveState = kind === 248 || kind === 219 || ts.isFunctionLikeKind(kind); + if (saveState) { + savedReachabilityState = currentReachabilityState; + savedLabelStack = labelStack; + savedLabels = labelIndexMap; + savedImplicitLabels = implicitLabels; + savedHasExplicitReturn = hasExplicitReturn; + currentReachabilityState = 2; + hasExplicitReturn = false; + labelStack = labelIndexMap = implicitLabels = undefined; + } + bindReachableStatement(node); + if (currentReachabilityState === 2 && ts.isFunctionLikeKind(kind) && ts.nodeIsPresent(node.body)) { + flags |= 524288; + if (hasExplicitReturn) { + flags |= 1048576; + } + } + if (kind === 215) { + flags = seenThisKeyword ? flags | 262144 : flags & ~262144; + } + node.flags = flags; + if (saveState) { + hasExplicitReturn = savedHasExplicitReturn; + currentReachabilityState = savedReachabilityState; + labelStack = savedLabelStack; + labelIndexMap = savedLabels; + implicitLabels = savedImplicitLabels; } container = saveContainer; parent = saveParent; blockScopeContainer = savedBlockScopeContainer; } + function bindReachableStatement(node) { + if (checkUnreachable(node)) { + ts.forEachChild(node, bind); + return; + } + switch (node.kind) { + case 198: + bindWhileStatement(node); + break; + case 197: + bindDoStatement(node); + break; + case 199: + bindForStatement(node); + break; + case 200: + case 201: + bindForInOrForOfStatement(node); + break; + case 196: + bindIfStatement(node); + break; + case 204: + case 208: + bindReturnOrThrow(node); + break; + case 203: + case 202: + bindBreakOrContinueStatement(node); + break; + case 209: + bindTryStatement(node); + break; + case 206: + bindSwitchStatement(node); + break; + case 220: + bindCaseBlock(node); + break; + case 207: + bindLabeledStatement(node); + break; + default: + ts.forEachChild(node, bind); + break; + } + } + function bindWhileStatement(n) { + var preWhileState = n.expression.kind === 84 ? 4 : currentReachabilityState; + var postWhileState = n.expression.kind === 99 ? 4 : currentReachabilityState; + bind(n.expression); + currentReachabilityState = preWhileState; + var postWhileLabel = pushImplicitLabel(); + bind(n.statement); + popImplicitLabel(postWhileLabel, postWhileState); + } + function bindDoStatement(n) { + var preDoState = currentReachabilityState; + var postDoLabel = pushImplicitLabel(); + bind(n.statement); + var postDoState = n.expression.kind === 99 ? 4 : preDoState; + popImplicitLabel(postDoLabel, postDoState); + bind(n.expression); + } + function bindForStatement(n) { + var preForState = currentReachabilityState; + var postForLabel = pushImplicitLabel(); + bind(n.initializer); + bind(n.condition); + bind(n.incrementor); + bind(n.statement); + var isInfiniteLoop = (!n.condition || n.condition.kind === 99); + var postForState = isInfiniteLoop ? 4 : preForState; + popImplicitLabel(postForLabel, postForState); + } + function bindForInOrForOfStatement(n) { + var preStatementState = currentReachabilityState; + var postStatementLabel = pushImplicitLabel(); + bind(n.initializer); + bind(n.expression); + bind(n.statement); + popImplicitLabel(postStatementLabel, preStatementState); + } + function bindIfStatement(n) { + var ifTrueState = n.expression.kind === 84 ? 4 : currentReachabilityState; + var ifFalseState = n.expression.kind === 99 ? 4 : currentReachabilityState; + currentReachabilityState = ifTrueState; + bind(n.expression); + bind(n.thenStatement); + if (n.elseStatement) { + var preElseState = currentReachabilityState; + currentReachabilityState = ifFalseState; + bind(n.elseStatement); + currentReachabilityState = or(currentReachabilityState, preElseState); + } + else { + currentReachabilityState = or(currentReachabilityState, ifFalseState); + } + } + function bindReturnOrThrow(n) { + bind(n.expression); + if (n.kind === 204) { + hasExplicitReturn = true; + } + currentReachabilityState = 4; + } + function bindBreakOrContinueStatement(n) { + bind(n.label); + var isValidJump = jumpToLabel(n.label, n.kind === 203 ? currentReachabilityState : 4); + if (isValidJump) { + currentReachabilityState = 4; + } + } + function bindTryStatement(n) { + var preTryState = currentReachabilityState; + bind(n.tryBlock); + var postTryState = currentReachabilityState; + currentReachabilityState = preTryState; + bind(n.catchClause); + var postCatchState = currentReachabilityState; + currentReachabilityState = preTryState; + bind(n.finallyBlock); + currentReachabilityState = or(postTryState, postCatchState); + } + function bindSwitchStatement(n) { + var preSwitchState = currentReachabilityState; + var postSwitchLabel = pushImplicitLabel(); + bind(n.expression); + bind(n.caseBlock); + var hasDefault = ts.forEach(n.caseBlock.clauses, function (c) { return c.kind === 242; }); + var postSwitchState = hasDefault && currentReachabilityState !== 2 ? 4 : preSwitchState; + popImplicitLabel(postSwitchLabel, postSwitchState); + } + function bindCaseBlock(n) { + var startState = currentReachabilityState; + for (var _i = 0, _a = n.clauses; _i < _a.length; _i++) { + var clause = _a[_i]; + currentReachabilityState = startState; + bind(clause); + if (clause.statements.length && currentReachabilityState === 2 && options.noFallthroughCasesInSwitch) { + errorOnFirstToken(clause, ts.Diagnostics.Fallthrough_case_in_switch); + } + } + } + function bindLabeledStatement(n) { + bind(n.label); + var ok = pushNamedLabel(n.label); + bind(n.statement); + if (ok) { + popNamedLabel(n.label, currentReachabilityState); + } + } function getContainerFlags(node) { switch (node.kind) { case 186: @@ -3365,7 +3593,7 @@ var ts; } } function declareClassMember(node, symbolFlags, symbolExcludes) { - return node.flags & 128 + return node.flags & 64 ? declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes) : declareSymbol(container.symbol.members, container.symbol, node, symbolFlags, symbolExcludes); } @@ -3374,15 +3602,6 @@ var ts; ? declareModuleMember(node, symbolFlags, symbolExcludes) : declareSymbol(file.locals, undefined, node, symbolFlags, symbolExcludes); } - function isAmbientContext(node) { - while (node) { - if (node.flags & 2) { - return true; - } - node = node.parent; - } - return false; - } function hasExportDeclarations(node) { var body = node.kind === 248 ? node : node.body; if (body.kind === 248 || body.kind === 219) { @@ -3396,11 +3615,11 @@ var ts; return false; } function setExportContextFlag(node) { - if (isAmbientContext(node) && !hasExportDeclarations(node)) { - node.flags |= 262144; + if (ts.isInAmbientContext(node) && !hasExportDeclarations(node)) { + node.flags |= 131072; } else { - node.flags &= ~262144; + node.flags &= ~131072; } } function bindModuleDeclaration(node) { @@ -3551,7 +3770,7 @@ var ts; } } function checkStrictModeNumericLiteral(node) { - if (inStrictMode && node.flags & 65536) { + if (inStrictMode && node.flags & 32768) { file.bindDiagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.Octal_literals_are_not_allowed_in_strict_mode)); } } @@ -3569,10 +3788,10 @@ var ts; } function checkStrictModeWithStatement(node) { if (inStrictMode) { - grammarErrorOnFirstToken(node, ts.Diagnostics.with_statements_are_not_allowed_in_strict_mode); + errorOnFirstToken(node, ts.Diagnostics.with_statements_are_not_allowed_in_strict_mode); } } - function grammarErrorOnFirstToken(node, message, arg0, arg1, arg2) { + function errorOnFirstToken(node, message, arg0, arg1, arg2) { var span = ts.getSpanOfTokenAtPosition(file, node.pos); file.bindDiagnostics.push(ts.createFileDiagnostic(file, span.start, span.length, message, arg0, arg1, arg2)); } @@ -3580,6 +3799,9 @@ var ts; return "__" + ts.indexOf(node.parent.parameters, node); } function bind(node) { + if (!node) { + return; + } node.parent = parent; var savedInStrictMode = inStrictMode; if (!savedInStrictMode) { @@ -3607,8 +3829,8 @@ var ts; } } function updateStrictModeStatementList(statements) { - for (var _i = 0; _i < statements.length; _i++) { - var statement = statements[_i]; + for (var _i = 0, statements_1 = statements; _i < statements_1.length; _i++) { + var statement = statements_1[_i]; if (!ts.isPrologueDirective(statement)) { return; } @@ -3795,7 +4017,7 @@ var ts; else { declareSymbolAndAddToSymbolTable(node, 1, 107455); } - if (node.flags & 112 && + if (node.flags & 56 && node.parent.kind === 144 && ts.isClassLike(node.parent.parent)) { var classDeclaration = node.parent.parent; @@ -3807,6 +4029,95 @@ var ts; ? bindAnonymousDeclaration(node, symbolFlags, "__computed") : declareSymbolAndAddToSymbolTable(node, symbolFlags, symbolExcludes); } + function pushNamedLabel(name) { + initializeReachabilityStateIfNecessary(); + if (ts.hasProperty(labelIndexMap, name.text)) { + return false; + } + labelIndexMap[name.text] = labelStack.push(1) - 1; + return true; + } + function pushImplicitLabel() { + initializeReachabilityStateIfNecessary(); + var index = labelStack.push(1) - 1; + implicitLabels.push(index); + return index; + } + function popNamedLabel(label, outerState) { + var index = labelIndexMap[label.text]; + ts.Debug.assert(index !== undefined); + ts.Debug.assert(labelStack.length == index + 1); + labelIndexMap[label.text] = undefined; + setCurrentStateAtLabel(labelStack.pop(), outerState, label); + } + function popImplicitLabel(implicitLabelIndex, outerState) { + if (labelStack.length !== implicitLabelIndex + 1) { + ts.Debug.assert(false, "Label stack: " + labelStack.length + ", index:" + implicitLabelIndex); + } + var i = implicitLabels.pop(); + if (implicitLabelIndex !== i) { + ts.Debug.assert(false, "i: " + i + ", index: " + implicitLabelIndex); + } + setCurrentStateAtLabel(labelStack.pop(), outerState, undefined); + } + function setCurrentStateAtLabel(innerMergedState, outerState, label) { + if (innerMergedState === 1) { + if (label && !options.allowUnusedLabels) { + file.bindDiagnostics.push(ts.createDiagnosticForNode(label, ts.Diagnostics.Unused_label)); + } + currentReachabilityState = outerState; + } + else { + currentReachabilityState = or(innerMergedState, outerState); + } + } + function jumpToLabel(label, outerState) { + initializeReachabilityStateIfNecessary(); + var index = label ? labelIndexMap[label.text] : ts.lastOrUndefined(implicitLabels); + if (index === undefined) { + return false; + } + var stateAtLabel = labelStack[index]; + labelStack[index] = stateAtLabel === 1 ? outerState : or(stateAtLabel, outerState); + return true; + } + function checkUnreachable(node) { + switch (currentReachabilityState) { + case 4: + var reportError = ts.isStatement(node) || + node.kind === 214 || + (node.kind === 218 && shouldReportErrorOnModuleDeclaration(node)) || + (node.kind === 217 && (!ts.isConstEnumDeclaration(node) || options.preserveConstEnums)); + if (reportError) { + currentReachabilityState = 8; + var reportUnreachableCode = !options.allowUnreachableCode && + !ts.isInAmbientContext(node) && + (node.kind !== 193 || + ts.getCombinedNodeFlags(node.declarationList) & 24576 || + ts.forEach(node.declarationList.declarations, function (d) { return d.initializer; })); + if (reportUnreachableCode) { + errorOnFirstToken(node, ts.Diagnostics.Unreachable_code_detected); + } + } + case 8: + return true; + default: + return false; + } + function shouldReportErrorOnModuleDeclaration(node) { + var instanceState = getModuleInstanceState(node); + return instanceState === 1 || (instanceState === 2 && options.preserveConstEnums); + } + } + function initializeReachabilityStateIfNecessary() { + if (labelIndexMap) { + return; + } + currentReachabilityState = 2; + labelIndexMap = {}; + labelStack = []; + implicitLabels = []; + } } })(ts || (ts = {})); var ts; @@ -3814,8 +4125,8 @@ var ts; function getDeclarationOfKind(symbol, kind) { var declarations = symbol.declarations; if (declarations) { - for (var _i = 0; _i < declarations.length; _i++) { - var declaration = declarations[_i]; + for (var _i = 0, declarations_1 = declarations; _i < declarations_1.length; _i++) { + var declaration = declarations_1[_i]; if (declaration.kind === kind) { return declaration; } @@ -3985,7 +4296,7 @@ var ts; } ts.makeIdentifierFromModuleName = makeIdentifierFromModuleName; function isBlockOrCatchScoped(declaration) { - return (getCombinedNodeFlags(declaration) & 49152) !== 0 || + return (getCombinedNodeFlags(declaration) & 24576) !== 0 || isCatchClauseVariableDeclaration(declaration); } ts.isBlockOrCatchScoped = isBlockOrCatchScoped; @@ -4086,7 +4397,7 @@ var ts; } ts.isExternalModule = isExternalModule; function isDeclarationFile(file) { - return (file.flags & 8192) !== 0; + return (file.flags & 4096) !== 0; } ts.isDeclarationFile = isDeclarationFile; function isConstEnumDeclaration(node) { @@ -4116,11 +4427,11 @@ var ts; } ts.getCombinedNodeFlags = getCombinedNodeFlags; function isConst(node) { - return !!(getCombinedNodeFlags(node) & 32768); + return !!(getCombinedNodeFlags(node) & 16384); } ts.isConst = isConst; function isLet(node) { - return !!(getCombinedNodeFlags(node) & 16384); + return !!(getCombinedNodeFlags(node) & 8192); } ts.isLet = isLet; function isPrologueDirective(node) { @@ -4299,27 +4610,28 @@ var ts; } ts.isClassLike = isClassLike; function isFunctionLike(node) { - if (node) { - switch (node.kind) { - case 144: - case 173: - case 213: - case 174: - case 143: - case 142: - case 145: - case 146: - case 147: - case 148: - case 149: - case 152: - case 153: - return true; - } - } - return false; + return node && isFunctionLikeKind(node.kind); } ts.isFunctionLike = isFunctionLike; + function isFunctionLikeKind(kind) { + switch (kind) { + case 144: + case 173: + case 213: + case 174: + case 143: + case 142: + case 145: + case 146: + case 147: + case 148: + case 149: + case 152: + case 153: + return true; + } + } + ts.isFunctionLikeKind = isFunctionLikeKind; function introducesArgumentsExoticObject(node) { switch (node.kind) { case 143: @@ -4783,9 +5095,18 @@ var ts; return !!node && (node.kind === 162 || node.kind === 161); } ts.isBindingPattern = isBindingPattern; + function isNodeDescendentOf(node, ancestor) { + while (node) { + if (node === ancestor) + return true; + node = node.parent; + } + return false; + } + ts.isNodeDescendentOf = isNodeDescendentOf; function isInAmbientContext(node) { while (node) { - if (node.flags & (2 | 8192)) { + if (node.flags & (4 | 4096)) { return true; } node = node.parent; @@ -4843,7 +5164,7 @@ var ts; case 207: case 204: case 206: - case 98: + case 208: case 209: case 193: case 198: @@ -4942,8 +5263,8 @@ var ts; ts.getInterfaceBaseTypeNodes = getInterfaceBaseTypeNodes; function getHeritageClause(clauses, kind) { if (clauses) { - for (var _i = 0; _i < clauses.length; _i++) { - var clause = clauses[_i]; + for (var _i = 0, clauses_1 = clauses; _i < clauses_1.length; _i++) { + var clause = clauses_1[_i]; if (clause.token === kind) { return clause; } @@ -4955,7 +5276,6 @@ var ts; function tryResolveScriptReference(host, sourceFile, reference) { if (!host.getCompilerOptions().noResolve) { var referenceFileName = ts.isRootedDiskPath(reference.fileName) ? reference.fileName : ts.combinePaths(ts.getDirectoryPath(sourceFile.fileName), reference.fileName); - referenceFileName = ts.getNormalizedAbsolutePath(referenceFileName, host.getCurrentDirectory()); return host.getSourceFile(referenceFileName); } } @@ -5013,7 +5333,7 @@ var ts; } ts.isTrivia = isTrivia; function isAsyncFunctionLike(node) { - return isFunctionLike(node) && (node.flags & 512) !== 0 && !isAccessor(node); + return isFunctionLike(node) && (node.flags & 256) !== 0 && !isAccessor(node); } ts.isAsyncFunctionLike = isAsyncFunctionLike; function hasDynamicName(declaration) { @@ -5371,7 +5691,7 @@ var ts; else { ts.forEach(declarations, function (member) { if ((member.kind === 145 || member.kind === 146) - && (member.flags & 128) === (accessor.flags & 128)) { + && (member.flags & 64) === (accessor.flags & 64)) { var memberName = getPropertyNameForPropertyNameNode(member.name); var accessorName = getPropertyNameForPropertyNameNode(accessor.name); if (memberName === accessorName) { @@ -5426,6 +5746,49 @@ var ts; }); } ts.emitComments = emitComments; + function emitDetachedComments(currentSourceFile, writer, writeComment, node, newLine, removeComments) { + var leadingComments; + var currentDetachedCommentInfo; + if (removeComments) { + if (node.pos === 0) { + leadingComments = ts.filter(ts.getLeadingCommentRanges(currentSourceFile.text, node.pos), isPinnedComment); + } + } + else { + leadingComments = ts.getLeadingCommentRanges(currentSourceFile.text, node.pos); + } + if (leadingComments) { + var detachedComments = []; + var lastComment; + for (var _i = 0, leadingComments_1 = leadingComments; _i < leadingComments_1.length; _i++) { + var comment = leadingComments_1[_i]; + if (lastComment) { + var lastCommentLine = getLineOfLocalPosition(currentSourceFile, lastComment.end); + var commentLine = getLineOfLocalPosition(currentSourceFile, comment.pos); + if (commentLine >= lastCommentLine + 2) { + break; + } + } + detachedComments.push(comment); + lastComment = comment; + } + if (detachedComments.length) { + var lastCommentLine = getLineOfLocalPosition(currentSourceFile, ts.lastOrUndefined(detachedComments).end); + var nodeLine = getLineOfLocalPosition(currentSourceFile, ts.skipTrivia(currentSourceFile.text, node.pos)); + if (nodeLine >= lastCommentLine + 2) { + emitNewLineBeforeLeadingComments(currentSourceFile, writer, node, leadingComments); + emitComments(currentSourceFile, writer, detachedComments, true, newLine, writeComment); + currentDetachedCommentInfo = { nodePos: node.pos, detachedCommentEndPos: ts.lastOrUndefined(detachedComments).end }; + } + } + } + return currentDetachedCommentInfo; + function isPinnedComment(comment) { + return currentSourceFile.text.charCodeAt(comment.pos + 1) === 42 && + currentSourceFile.text.charCodeAt(comment.pos + 2) === 33; + } + } + ts.emitDetachedComments = emitDetachedComments; function writeCommentRange(currentSourceFile, writer, comment, newLine) { if (currentSourceFile.text.charCodeAt(comment.pos + 1) === 42) { var firstCommentLineAndCharacter = ts.getLineAndCharacterOfPosition(currentSourceFile, comment.pos); @@ -5490,16 +5853,16 @@ var ts; ts.writeCommentRange = writeCommentRange; function modifierToFlag(token) { switch (token) { - case 113: return 128; - case 112: return 16; - case 111: return 64; - case 110: return 32; - case 115: return 256; - case 82: return 1; - case 122: return 2; - case 74: return 32768; - case 77: return 1024; - case 118: return 512; + case 113: return 64; + case 112: return 8; + case 111: return 32; + case 110: return 16; + case 115: return 128; + case 82: return 2; + case 122: return 4; + case 74: return 16384; + case 77: return 512; + case 118: return 256; } return 0; } @@ -5578,7 +5941,7 @@ var ts; } ts.isEmptyObjectLiteralOrArrayLiteral = isEmptyObjectLiteralOrArrayLiteral; function getLocalSymbolForExportDefault(symbol) { - return symbol && symbol.valueDeclaration && (symbol.valueDeclaration.flags & 1024) ? symbol.valueDeclaration.localSymbol : undefined; + return symbol && symbol.valueDeclaration && (symbol.valueDeclaration.flags & 512) ? symbol.valueDeclaration.localSymbol : undefined; } ts.getLocalSymbolForExportDefault = getLocalSymbolForExportDefault; function isJavaScript(fileName) { @@ -5642,6 +6005,12 @@ 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) { @@ -5814,8 +6183,8 @@ var ts; } function visitEachNode(cbNode, nodes) { if (nodes) { - for (var _i = 0; _i < nodes.length; _i++) { - var node = nodes[_i]; + for (var _i = 0, nodes_1 = nodes; _i < nodes_1.length; _i++) { + var node = nodes_1[_i]; var result = cbNode(node); if (result) { return result; @@ -6276,8 +6645,8 @@ var ts; function addJSDocComment(node) { var comments = ts.getLeadingCommentRangesOfNode(node, sourceFile); if (comments) { - for (var _i = 0; _i < comments.length; _i++) { - var comment = comments[_i]; + for (var _i = 0, comments_1 = comments; _i < comments_1.length; _i++) { + var comment = comments_1[_i]; var jsDocComment = JSDocParser.parseJSDocComment(node, comment.pos, comment.end - comment.pos); if (jsDocComment) { node.jsDocComment = jsDocComment; @@ -6308,7 +6677,7 @@ var ts; sourceFile.bindDiagnostics = []; sourceFile.languageVersion = languageVersion; sourceFile.fileName = ts.normalizePath(fileName); - sourceFile.flags = ts.fileExtensionIs(sourceFile.fileName, ".d.ts") ? 8192 : 0; + sourceFile.flags = ts.fileExtensionIs(sourceFile.fileName, ".d.ts") ? 4096 : 0; sourceFile.languageVariant = ts.isTsx(sourceFile.fileName) ? 1 : 0; return sourceFile; } @@ -7144,7 +7513,7 @@ var ts; if (node.kind === 8 && sourceText.charCodeAt(tokenPos) === 48 && ts.isOctalDigit(sourceText.charCodeAt(tokenPos + 1))) { - node.flags |= 65536; + node.flags |= 32768; } return node; } @@ -7713,7 +8082,7 @@ var ts; if (!arrowFunction) { return undefined; } - var isAsync = !!(arrowFunction.flags & 512); + var isAsync = !!(arrowFunction.flags & 256); var lastToken = token; arrowFunction.equalsGreaterThanToken = parseExpectedToken(34, false, ts.Diagnostics._0_expected, "=>"); arrowFunction.body = (lastToken === 34 || lastToken === 15) @@ -7805,7 +8174,7 @@ var ts; function parseParenthesizedArrowFunctionExpressionHead(allowAmbiguity) { var node = createNode(174); setModifiers(node, parseModifiersForArrowFunction()); - var isAsync = !!(node.flags & 512); + var isAsync = !!(node.flags & 256); fillSignature(54, false, isAsync, !allowAmbiguity, node); if (!node.parameters) { return undefined; @@ -8419,7 +8788,7 @@ var ts; var node = createNode(164); parseExpected(19); if (scanner.hasPrecedingLineBreak()) - node.flags |= 2048; + node.flags |= 1024; node.elements = parseDelimitedList(15, parseArgumentOrArrayLiteralElement); parseExpected(20); return finishNode(node); @@ -8474,7 +8843,7 @@ var ts; var node = createNode(165); parseExpected(15); if (scanner.hasPrecedingLineBreak()) { - node.flags |= 2048; + node.flags |= 1024; } node.properties = parseDelimitedList(12, parseObjectLiteralElement, true); parseExpected(16); @@ -8490,7 +8859,7 @@ var ts; parseExpected(87); node.asteriskToken = parseOptionalToken(37); var isGenerator = !!node.asteriskToken; - var isAsync = !!(node.flags & 512); + var isAsync = !!(node.flags & 256); node.name = isGenerator && isAsync ? doInYieldAndAwaitContext(parseOptionalIdentifier) : isGenerator ? doInYieldContext(parseOptionalIdentifier) : @@ -9028,10 +9397,10 @@ var ts; case 102: break; case 108: - node.flags |= 16384; + node.flags |= 8192; break; case 74: - node.flags |= 32768; + node.flags |= 16384; break; default: ts.Debug.fail(); @@ -9065,9 +9434,9 @@ var ts; setModifiers(node, modifiers); parseExpected(87); node.asteriskToken = parseOptionalToken(37); - node.name = node.flags & 1024 ? parseOptionalIdentifier() : parseIdentifier(); + node.name = node.flags & 512 ? parseOptionalIdentifier() : parseIdentifier(); var isGenerator = !!node.asteriskToken; - var isAsync = !!(node.flags & 512); + var isAsync = !!(node.flags & 256); fillSignature(54, isGenerator, isAsync, false, node); node.body = parseFunctionBlockOrSemicolon(isGenerator, isAsync, ts.Diagnostics.or_expected); return finishNode(node); @@ -9089,7 +9458,7 @@ var ts; method.name = name; method.questionToken = questionToken; var isGenerator = !!asteriskToken; - var isAsync = !!(method.flags & 512); + var isAsync = !!(method.flags & 256); fillSignature(54, isGenerator, isAsync, false, method); method.body = parseFunctionBlockOrSemicolon(isGenerator, isAsync, diagnosticMessage); return finishNode(method); @@ -9101,7 +9470,7 @@ var ts; property.name = name; property.questionToken = questionToken; property.type = parseTypeAnnotation(); - property.initializer = modifiers && modifiers.flags & 128 + property.initializer = modifiers && modifiers.flags & 64 ? allowInAnd(parseNonParameterInitializer) : doOutsideOfContext(2 | 1, parseNonParameterInitializer); parseSemicolon(); @@ -9391,13 +9760,13 @@ var ts; } function parseModuleOrNamespaceDeclaration(fullStart, decorators, modifiers, flags) { var node = createNode(218, fullStart); - var namespaceFlag = flags & 131072; + var namespaceFlag = flags & 65536; node.decorators = decorators; setModifiers(node, modifiers); node.flags |= flags; node.name = parseIdentifier(); node.body = parseOptional(21) - ? parseModuleOrNamespaceDeclaration(getNodePos(), undefined, undefined, 1 | namespaceFlag) + ? parseModuleOrNamespaceDeclaration(getNodePos(), undefined, undefined, 2 | namespaceFlag) : parseModuleBlock(); return finishNode(node); } @@ -9412,7 +9781,7 @@ var ts; function parseModuleDeclaration(fullStart, decorators, modifiers) { var flags = modifiers ? modifiers.flags : 0; if (parseOptional(126)) { - flags |= 131072; + flags |= 65536; } else { parseExpected(125); @@ -9626,7 +9995,7 @@ var ts; } function setExternalModuleIndicator(sourceFile) { sourceFile.externalModuleIndicator = ts.forEach(sourceFile.statements, function (node) { - return node.flags & 1 + return node.flags & 2 || node.kind === 221 && node.moduleReference.kind === 232 || node.kind === 222 || node.kind === 227 @@ -10200,8 +10569,8 @@ var ts; array._children = undefined; array.pos += delta; array.end += delta; - for (var _i = 0; _i < array.length; _i++) { - var node = array[_i]; + for (var _i = 0, array_7 = array; _i < array_7.length; _i++) { + var node = array_7[_i]; visitNode(node); } } @@ -10273,8 +10642,8 @@ var ts; array.intersectsChange = true; array._children = undefined; adjustIntersectingElement(array, changeStart, changeRangeOldEnd, changeRangeNewEnd, delta); - for (var _i = 0; _i < array.length; _i++) { - var node = array[_i]; + for (var _i = 0, array_8 = array; _i < array_8.length; _i++) { + var node = array_8[_i]; visitNode(node); } return; @@ -10547,6 +10916,7 @@ var ts; var getInstantiatedGlobalPromiseLikeType; var getGlobalPromiseConstructorLikeType; var getGlobalThenableType; + var jsxElementClassType; var tupleTypes = {}; var unionTypes = {}; var intersectionTypes = {}; @@ -10795,7 +11165,7 @@ var ts; } var initializerOfNonStaticProperty = current.parent && current.parent.kind === 141 && - (current.parent.flags & 128) === 0 && + (current.parent.flags & 64) === 0 && current.parent.initializer === current; if (initializerOfNonStaticProperty) { return true; @@ -10854,7 +11224,7 @@ var ts; break; case 141: case 140: - if (ts.isClassLike(location.parent) && !(location.flags & 128)) { + if (ts.isClassLike(location.parent) && !(location.flags & 64)) { var ctor = findConstructorDeclaration(location.parent); if (ctor && ctor.locals) { if (getSymbol(ctor.locals, name, meaning & 107455)) { @@ -10867,7 +11237,7 @@ var ts; case 186: case 215: if (result = getSymbol(getSymbolOfNode(location).members, name, meaning & 793056)) { - if (lastLocation && lastLocation.flags & 128) { + if (lastLocation && lastLocation.flags & 64) { error(errorLocation, ts.Diagnostics.Static_members_cannot_reference_class_type_parameters); return undefined; } @@ -11301,8 +11671,8 @@ var ts; } function findConstructorDeclaration(node) { var members = node.members; - for (var _i = 0; _i < members.length; _i++) { - var member = members[_i]; + for (var _i = 0, members_1 = members; _i < members_1.length; _i++) { + var member = members_1[_i]; if (member.kind === 144 && ts.nodeIsPresent(member.body)) { return member; } @@ -11508,7 +11878,7 @@ var ts; if (!isDeclarationVisible(declaration)) { var anyImportSyntax = getAnyImportSyntax(declaration); if (anyImportSyntax && - !(anyImportSyntax.flags & 1) && + !(anyImportSyntax.flags & 2) && isDeclarationVisible(anyImportSyntax.parent)) { getNodeLinks(declaration).isVisible = true; if (aliasesToMakeVisible) { @@ -11638,8 +12008,8 @@ var ts; walkSymbol(getParentOfSymbol(accessibleSymbolChain ? accessibleSymbolChain[0] : symbol), getQualifiedLeftMeaning(meaning)); } if (accessibleSymbolChain) { - for (var _i = 0; _i < accessibleSymbolChain.length; _i++) { - var accessibleSymbol = accessibleSymbolChain[_i]; + for (var _i = 0, accessibleSymbolChain_1 = accessibleSymbolChain; _i < accessibleSymbolChain_1.length; _i++) { + var accessibleSymbol = accessibleSymbolChain_1[_i]; appendParentTypeArgumentsAndSymbolName(accessibleSymbol); } } @@ -11805,7 +12175,7 @@ var ts; } function shouldWriteTypeOfFunctionSymbol() { var isStaticMethodSymbol = !!(symbol.flags & 8192 && - ts.forEach(symbol.declarations, function (declaration) { return declaration.flags & 128; })); + ts.forEach(symbol.declarations, function (declaration) { return declaration.flags & 64; })); var isNonLocalFunctionSymbol = !!(symbol.flags & 16) && (symbol.parent || ts.forEach(symbol.declarations, function (declaration) { @@ -11911,8 +12281,8 @@ var ts; var t = getTypeOfSymbol(p); if (p.flags & (16 | 8192) && !getPropertiesOfObjectType(t).length) { var signatures = getSignaturesOfType(t, 0); - for (var _f = 0; _f < signatures.length; _f++) { - var signature = signatures[_f]; + for (var _f = 0, signatures_1 = signatures; _f < signatures_1.length; _f++) { + var signature = signatures_1[_f]; buildSymbolDisplay(p, writer); if (p.flags & 536870912) { writePunctuation(writer, 53); @@ -12115,7 +12485,7 @@ var ts; case 217: case 221: var parent_4 = getDeclarationContainer(node); - if (!(ts.getCombinedNodeFlags(node) & 1) && + if (!(ts.getCombinedNodeFlags(node) & 2) && !(node.kind !== 221 && parent_4.kind !== 248 && ts.isInAmbientContext(parent_4))) { return isGlobalSourceFile(parent_4); } @@ -12126,7 +12496,7 @@ var ts; case 146: case 143: case 142: - if (node.flags & (32 | 64)) { + if (node.flags & (16 | 32)) { return false; } case 144: @@ -12555,8 +12925,8 @@ var ts; } } function appendTypeParameters(typeParameters, declarations) { - for (var _i = 0; _i < declarations.length; _i++) { - var declaration = declarations[_i]; + for (var _i = 0, declarations_2 = declarations; _i < declarations_2.length; _i++) { + var declaration = declarations_2[_i]; var tp = getDeclaredTypeOfTypeParameter(getSymbolOfNode(declaration)); if (!typeParameters) { typeParameters = [tp]; @@ -12737,13 +13107,13 @@ var ts; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; if (declaration.kind === 215) { - if (declaration.flags & 524288) { + if (declaration.flags & 262144) { return false; } var baseTypeNodes = ts.getInterfaceBaseTypeNodes(declaration); if (baseTypeNodes) { - for (var _b = 0; _b < baseTypeNodes.length; _b++) { - var node = baseTypeNodes[_b]; + for (var _b = 0, baseTypeNodes_1 = baseTypeNodes; _b < baseTypeNodes_1.length; _b++) { + var node = baseTypeNodes_1[_b]; if (ts.isSupportedExpressionWithTypeArguments(node)) { var baseSymbol = resolveEntityName(node.expression, 793056, true); if (!baseSymbol || !(baseSymbol.flags & 64) || getDeclaredTypeOfClassOrInterface(baseSymbol).thisType) { @@ -12911,23 +13281,23 @@ var ts; } function createSymbolTable(symbols) { var result = {}; - for (var _i = 0; _i < symbols.length; _i++) { - var symbol = symbols[_i]; + for (var _i = 0, symbols_1 = symbols; _i < symbols_1.length; _i++) { + var symbol = symbols_1[_i]; result[symbol.name] = symbol; } return result; } function createInstantiatedSymbolTable(symbols, mapper, mappingThisOnly) { var result = {}; - for (var _i = 0; _i < symbols.length; _i++) { - var symbol = symbols[_i]; + for (var _i = 0, symbols_2 = symbols; _i < symbols_2.length; _i++) { + var symbol = symbols_2[_i]; result[symbol.name] = mappingThisOnly && isIndependentMember(symbol) ? symbol : instantiateSymbol(symbol, mapper); } return result; } function addInheritedMembers(symbols, baseSymbols) { - for (var _i = 0; _i < baseSymbols.length; _i++) { - var s = baseSymbols[_i]; + for (var _i = 0, baseSymbols_1 = baseSymbols; _i < baseSymbols_1.length; _i++) { + var s = baseSymbols_1[_i]; if (!ts.hasProperty(symbols, s.name)) { symbols[s.name] = s; } @@ -12935,8 +13305,8 @@ var ts; } function addInheritedSignatures(signatures, baseSignatures) { if (baseSignatures) { - for (var _i = 0; _i < baseSignatures.length; _i++) { - var signature = baseSignatures[_i]; + for (var _i = 0, baseSignatures_1 = baseSignatures; _i < baseSignatures_1.length; _i++) { + var signature = baseSignatures_1[_i]; signatures.push(signature); } } @@ -12979,8 +13349,8 @@ var ts; members = createSymbolTable(source.declaredProperties); } var thisArgument = ts.lastOrUndefined(typeArguments); - for (var _i = 0; _i < baseTypes.length; _i++) { - var baseType = baseTypes[_i]; + for (var _i = 0, baseTypes_1 = baseTypes; _i < baseTypes_1.length; _i++) { + var baseType = baseTypes_1[_i]; var instantiatedBaseType = thisArgument ? getTypeWithThisArgument(instantiateType(baseType, mapper), thisArgument) : baseType; addInheritedMembers(members, getPropertiesOfObjectType(instantiatedBaseType)); callSignatures = ts.concatenate(callSignatures, getSignaturesOfType(instantiatedBaseType, 0)); @@ -13026,8 +13396,8 @@ var ts; var typeArguments = ts.map(baseTypeNode.typeArguments, getTypeFromTypeNode); var typeArgCount = typeArguments ? typeArguments.length : 0; var result = []; - for (var _i = 0; _i < baseSignatures.length; _i++) { - var baseSig = baseSignatures[_i]; + for (var _i = 0, baseSignatures_2 = baseSignatures; _i < baseSignatures_2.length; _i++) { + var baseSig = baseSignatures_2[_i]; var typeParamCount = baseSig.typeParameters ? baseSig.typeParameters.length : 0; if (typeParamCount === typeArgCount) { var sig = typeParamCount ? getSignatureInstantiation(baseSig, typeArguments) : cloneSignature(baseSig); @@ -13055,8 +13425,8 @@ var ts; setObjectTypeMembers(type, members, arrayType.callSignatures, arrayType.constructSignatures, arrayType.stringIndexType, arrayType.numberIndexType); } function findMatchingSignature(signatureList, signature, partialMatch, ignoreReturnTypes) { - for (var _i = 0; _i < signatureList.length; _i++) { - var s = signatureList[_i]; + for (var _i = 0, signatureList_1 = signatureList; _i < signatureList_1.length; _i++) { + var s = signatureList_1[_i]; if (compareSignatures(s, signature, partialMatch, ignoreReturnTypes, compareTypes)) { return s; } @@ -13110,8 +13480,8 @@ var ts; } function getUnionIndexType(types, kind) { var indexTypes = []; - for (var _i = 0; _i < types.length; _i++) { - var type = types[_i]; + for (var _i = 0, types_1 = types; _i < types_1.length; _i++) { + var type = types_1[_i]; var indexType = getIndexTypeOfType(type, kind); if (!indexType) { return undefined; @@ -13275,12 +13645,12 @@ var ts; function createUnionOrIntersectionProperty(containingType, name) { var types = containingType.types; var props; - for (var _i = 0; _i < types.length; _i++) { - var current = types[_i]; + for (var _i = 0, types_2 = types; _i < types_2.length; _i++) { + var current = types_2[_i]; var type = getApparentType(current); if (type !== unknownType) { var prop = getPropertyOfType(type, name); - if (prop && !(getDeclarationFlagsFromSymbol(prop) & (32 | 64))) { + if (prop && !(getDeclarationFlagsFromSymbol(prop) & (16 | 32))) { if (!props) { props = [prop]; } @@ -13301,8 +13671,8 @@ var ts; } var propTypes = []; var declarations = []; - for (var _a = 0; _a < props.length; _a++) { - var prop = props[_a]; + for (var _a = 0, props_1 = props; _a < props_1.length; _a++) { + var prop = props_1[_a]; if (prop.declarations) { ts.addRange(declarations, prop.declarations); } @@ -13635,8 +14005,8 @@ var ts; } function getPropagatingFlagsOfTypes(types) { var result = 0; - for (var _i = 0; _i < types.length; _i++) { - var type = types[_i]; + for (var _i = 0, types_3 = types; _i < types_3.length; _i++) { + var type = types_3[_i]; result |= type.flags; } return result & 14680064; @@ -13757,8 +14127,8 @@ var ts; function getTypeOfGlobalSymbol(symbol, arity) { function getTypeDeclaration(symbol) { var declarations = symbol.declarations; - for (var _i = 0; _i < declarations.length; _i++) { - var declaration = declarations[_i]; + for (var _i = 0, declarations_3 = declarations; _i < declarations_3.length; _i++) { + var declaration = declarations_3[_i]; switch (declaration.kind) { case 214: case 215: @@ -13856,8 +14226,8 @@ var ts; } } function addTypesToSet(typeSet, types, typeSetKind) { - for (var _i = 0; _i < types.length; _i++) { - var type = types[_i]; + for (var _i = 0, types_4 = types; _i < types_4.length; _i++) { + var type = types_4[_i]; addTypeToSet(typeSet, type, typeSetKind); } } @@ -13879,8 +14249,8 @@ var ts; } } function containsTypeAny(types) { - for (var _i = 0; _i < types.length; _i++) { - var type = types[_i]; + for (var _i = 0, types_5 = types; _i < types_5.length; _i++) { + var type = types_5[_i]; if (isTypeAny(type)) { return true; } @@ -13983,7 +14353,8 @@ var ts; var container = ts.getThisContainer(node, false); var parent = container && container.parent; if (parent && (ts.isClassLike(parent) || parent.kind === 215)) { - if (!(container.flags & 128)) { + if (!(container.flags & 64) && + (container.kind !== 144 || ts.isNodeDescendentOf(node, container.body))) { return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(parent)).thisType; } } @@ -14048,8 +14419,8 @@ var ts; function instantiateList(items, mapper, instantiator) { if (items && items.length) { var result = []; - for (var _i = 0; _i < items.length; _i++) { - var v = items[_i]; + for (var _i = 0, items_1 = items; _i < items_1.length; _i++) { + var v = items_1[_i]; result.push(instantiator(v, mapper)); } return result; @@ -14088,8 +14459,8 @@ var ts; case 2: return createBinaryTypeEraser(sources[0], sources[1]); } return function (t) { - for (var _i = 0; _i < sources.length; _i++) { - var source = sources[_i]; + for (var _i = 0, sources_1 = sources; _i < sources_1.length; _i++) { + var source = sources_1[_i]; if (t === source) { return anyType; } @@ -14454,8 +14825,8 @@ var ts; function eachTypeRelatedToSomeType(source, target) { var result = -1; var sourceTypes = source.types; - for (var _i = 0; _i < sourceTypes.length; _i++) { - var sourceType = sourceTypes[_i]; + for (var _i = 0, sourceTypes_1 = sourceTypes; _i < sourceTypes_1.length; _i++) { + var sourceType = sourceTypes_1[_i]; var related = typeRelatedToSomeType(sourceType, target, false); if (!related) { return 0; @@ -14477,8 +14848,8 @@ var ts; function typeRelatedToEachType(source, target, reportErrors) { var result = -1; var targetTypes = target.types; - for (var _i = 0; _i < targetTypes.length; _i++) { - var targetType = targetTypes[_i]; + for (var _i = 0, targetTypes_1 = targetTypes; _i < targetTypes_1.length; _i++) { + var targetType = targetTypes_1[_i]; var related = isRelatedTo(source, targetType, reportErrors); if (!related) { return 0; @@ -14500,8 +14871,8 @@ var ts; function eachTypeRelatedToType(source, target, reportErrors) { var result = -1; var sourceTypes = source.types; - for (var _i = 0; _i < sourceTypes.length; _i++) { - var sourceType = sourceTypes[_i]; + for (var _i = 0, sourceTypes_2 = sourceTypes; _i < sourceTypes_2.length; _i++) { + var sourceType = sourceTypes_2[_i]; var related = isRelatedTo(sourceType, target, reportErrors); if (!related) { return 0; @@ -14614,8 +14985,8 @@ var ts; var result = -1; var properties = getPropertiesOfObjectType(target); var requireOptionalProperties = relation === subtypeRelation && !(source.flags & 524288); - for (var _i = 0; _i < properties.length; _i++) { - var targetProp = properties[_i]; + for (var _i = 0, properties_1 = properties; _i < properties_1.length; _i++) { + var targetProp = properties_1[_i]; var sourceProp = getPropertyOfType(source, targetProp.name); if (sourceProp !== targetProp) { if (!sourceProp) { @@ -14629,20 +15000,20 @@ var ts; else if (!(targetProp.flags & 134217728)) { var sourcePropFlags = getDeclarationFlagsFromSymbol(sourceProp); var targetPropFlags = getDeclarationFlagsFromSymbol(targetProp); - if (sourcePropFlags & 32 || targetPropFlags & 32) { + if (sourcePropFlags & 16 || targetPropFlags & 16) { if (sourceProp.valueDeclaration !== targetProp.valueDeclaration) { if (reportErrors) { - if (sourcePropFlags & 32 && targetPropFlags & 32) { + if (sourcePropFlags & 16 && targetPropFlags & 16) { reportError(ts.Diagnostics.Types_have_separate_declarations_of_a_private_property_0, symbolToString(targetProp)); } else { - reportError(ts.Diagnostics.Property_0_is_private_in_type_1_but_not_in_type_2, symbolToString(targetProp), typeToString(sourcePropFlags & 32 ? source : target), typeToString(sourcePropFlags & 32 ? target : source)); + reportError(ts.Diagnostics.Property_0_is_private_in_type_1_but_not_in_type_2, symbolToString(targetProp), typeToString(sourcePropFlags & 16 ? source : target), typeToString(sourcePropFlags & 16 ? target : source)); } } return 0; } } - else if (targetPropFlags & 64) { + else if (targetPropFlags & 32) { var sourceDeclaredInClass = sourceProp.parent && sourceProp.parent.flags & 32; var sourceClass = sourceDeclaredInClass ? getDeclaredTypeOfSymbol(sourceProp.parent) : undefined; var targetClass = getDeclaredTypeOfSymbol(targetProp.parent); @@ -14653,7 +15024,7 @@ var ts; return 0; } } - else if (sourcePropFlags & 64) { + else if (sourcePropFlags & 32) { if (reportErrors) { reportError(ts.Diagnostics.Property_0_is_protected_in_type_1_but_public_in_type_2, symbolToString(targetProp), typeToString(source), typeToString(target)); } @@ -14688,8 +15059,8 @@ var ts; return 0; } var result = -1; - for (var _i = 0; _i < sourceProperties.length; _i++) { - var sourceProp = sourceProperties[_i]; + for (var _i = 0, sourceProperties_1 = sourceProperties; _i < sourceProperties_1.length; _i++) { + var sourceProp = sourceProperties_1[_i]; var targetProp = getPropertyOfObjectType(target, sourceProp.name); if (!targetProp) { return 0; @@ -14721,13 +15092,13 @@ var ts; return result; } } - outer: for (var _i = 0; _i < targetSignatures.length; _i++) { - var t = targetSignatures[_i]; + outer: for (var _i = 0, targetSignatures_1 = targetSignatures; _i < targetSignatures_1.length; _i++) { + var t = targetSignatures_1[_i]; if (!t.hasStringLiterals || target.flags & 262144) { var localErrors = reportErrors; var checkedAbstractAssignability = false; - for (var _a = 0; _a < sourceSignatures.length; _a++) { - var s = sourceSignatures[_a]; + for (var _a = 0, sourceSignatures_1 = sourceSignatures; _a < sourceSignatures_1.length; _a++) { + var s = sourceSignatures_1[_a]; if (!s.hasStringLiterals || source.flags & 262144) { var related = signatureRelatedTo(s, t, localErrors); if (related) { @@ -14755,8 +15126,8 @@ var ts; var targetReturnType = targetErasedSignature && getReturnTypeOfSignature(targetErasedSignature); var sourceReturnDecl = sourceReturnType && sourceReturnType.symbol && getClassLikeDeclarationOfSymbol(sourceReturnType.symbol); var targetReturnDecl = targetReturnType && targetReturnType.symbol && getClassLikeDeclarationOfSymbol(targetReturnType.symbol); - var sourceIsAbstract = sourceReturnDecl && sourceReturnDecl.flags & 256; - var targetIsAbstract = targetReturnDecl && targetReturnDecl.flags & 256; + var sourceIsAbstract = sourceReturnDecl && sourceReturnDecl.flags & 128; + var targetIsAbstract = targetReturnDecl && targetReturnDecl.flags & 128; if (sourceIsAbstract && !(targetIsAbstract && targetDecl)) { if (reportErrors) { reportError(ts.Diagnostics.Cannot_assign_an_abstract_constructor_type_to_a_non_abstract_constructor_type); @@ -14957,8 +15328,8 @@ var ts; if (sourceProp === targetProp) { return -1; } - var sourcePropAccessibility = getDeclarationFlagsFromSymbol(sourceProp) & (32 | 64); - var targetPropAccessibility = getDeclarationFlagsFromSymbol(targetProp) & (32 | 64); + var sourcePropAccessibility = getDeclarationFlagsFromSymbol(sourceProp) & (16 | 32); + var targetPropAccessibility = getDeclarationFlagsFromSymbol(targetProp) & (16 | 32); if (sourcePropAccessibility !== targetPropAccessibility) { return 0; } @@ -15024,8 +15395,8 @@ var ts; return signature.hasRestParameter && parameterIndex >= signature.parameters.length - 1; } function isSupertypeOfEach(candidate, types) { - for (var _i = 0; _i < types.length; _i++) { - var type = types[_i]; + for (var _i = 0, types_6 = types; _i < types_6.length; _i++) { + var type = types_6[_i]; if (candidate !== type && !isTypeSubtypeOf(type, candidate)) return false; } @@ -15238,8 +15609,8 @@ var ts; } function createInferenceContext(typeParameters, inferUnionTypes) { var inferences = []; - for (var _i = 0; _i < typeParameters.length; _i++) { - var unused = typeParameters[_i]; + for (var _i = 0, typeParameters_1 = typeParameters; _i < typeParameters_1.length; _i++) { + var unused = typeParameters_1[_i]; inferences.push({ primary: undefined, secondary: undefined, isFixed: false }); @@ -15305,8 +15676,8 @@ var ts; var targetTypes = target.types; var typeParameterCount = 0; var typeParameter; - for (var _i = 0; _i < targetTypes.length; _i++) { - var t = targetTypes[_i]; + for (var _i = 0, targetTypes_2 = targetTypes; _i < targetTypes_2.length; _i++) { + var t = targetTypes_2[_i]; if (t.flags & 512 && ts.contains(context.typeParameters, t)) { typeParameter = t; typeParameterCount++; @@ -15323,8 +15694,8 @@ var ts; } else if (source.flags & 49152) { var sourceTypes = source.types; - for (var _a = 0; _a < sourceTypes.length; _a++) { - var sourceType = sourceTypes[_a]; + for (var _a = 0, sourceTypes_3 = sourceTypes; _a < sourceTypes_3.length; _a++) { + var sourceType = sourceTypes_3[_a]; inferFromTypes(sourceType, target); } } @@ -15357,8 +15728,8 @@ var ts; } function inferFromProperties(source, target) { var properties = getPropertiesOfObjectType(target); - for (var _i = 0; _i < properties.length; _i++) { - var targetProp = properties[_i]; + for (var _i = 0, properties_2 = properties; _i < properties_2.length; _i++) { + var targetProp = properties_2[_i]; var sourceProp = getPropertyOfObjectType(source, targetProp.name); if (sourceProp) { inferFromTypes(getTypeOfSymbol(sourceProp), getTypeOfSymbol(targetProp)); @@ -15849,7 +16220,7 @@ var ts; break; case 141: case 140: - if (container.flags & 128) { + if (container.flags & 64) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_static_property_initializer); } break; @@ -15862,7 +16233,7 @@ var ts; } if (ts.isClassLike(container.parent)) { var symbol = getSymbolOfNode(container.parent); - return container.flags & 128 ? getTypeOfSymbol(symbol) : getDeclaredTypeOfSymbol(symbol).thisType; + return container.flags & 64 ? getTypeOfSymbol(symbol) : getDeclaredTypeOfSymbol(symbol).thisType; } return anyType; } @@ -15890,7 +16261,7 @@ var ts; var canUseSuperExpression = isLegalUsageOfSuperExpression(container); var nodeCheckFlag = 0; if (canUseSuperExpression) { - if ((container.flags & 128) || isCallExpression) { + if ((container.flags & 64) || isCallExpression) { nodeCheckFlag = 512; } else { @@ -15935,7 +16306,7 @@ var ts; } else { if (container && ts.isClassLike(container.parent)) { - if (container.flags & 128) { + if (container.flags & 64) { return container.kind === 143 || container.kind === 142 || container.kind === 145 || @@ -16074,8 +16445,8 @@ var ts; var types = type.types; var mappedType; var mappedTypes; - for (var _i = 0; _i < types.length; _i++) { - var current = types[_i]; + for (var _i = 0, types_7 = types; _i < types_7.length; _i++) { + var current = types_7[_i]; var t = mapper(current); if (t) { if (!mappedType) { @@ -16239,8 +16610,8 @@ var ts; } var signatureList; var types = type.types; - for (var _i = 0; _i < types.length; _i++) { - var current = types[_i]; + for (var _i = 0, types_8 = types; _i < types_8.length; _i++) { + var current = types_8[_i]; var signature = getNonGenericSignature(current); if (signature) { if (!signatureList) { @@ -16291,8 +16662,8 @@ var ts; var hasSpreadElement = false; var elementTypes = []; var inDestructuringPattern = isAssignmentTarget(node); - for (var _i = 0; _i < elements.length; _i++) { - var e = elements[_i]; + for (var _i = 0, elements_1 = elements; _i < elements_1.length; _i++) { + var e = elements_1[_i]; if (inDestructuringPattern && e.kind === 185) { var restArrayType = checkExpression(e.expression, contextualMapper); var restElementType = getIndexTypeOfType(restArrayType, 1) || @@ -16551,8 +16922,8 @@ var ts; function checkJsxSpreadAttribute(node, elementAttributesType, nameTable) { var type = checkExpression(node.expression); var props = getPropertiesOfType(type); - for (var _i = 0; _i < props.length; _i++) { - var prop = props[_i]; + for (var _i = 0, props_2 = props; _i < props_2.length; _i++) { + var prop = props_2[_i]; if (!nameTable[prop.name]) { var targetPropSym = getPropertyOfType(elementAttributesType, prop.name); if (targetPropSym) { @@ -16721,7 +17092,6 @@ var ts; var prop = getPropertyOfType(attributesType, attrib.name.text); return prop || unknownSymbol; } - var jsxElementClassType = undefined; function getJsxGlobalElementClassType() { if (!jsxElementClassType) { jsxElementClassType = getExportedTypeFromNamespace(JsxNames.JSX, JsxNames.ElementClass); @@ -16788,7 +17158,7 @@ var ts; return s.valueDeclaration ? s.valueDeclaration.kind : 141; } function getDeclarationFlagsFromSymbol(s) { - return s.valueDeclaration ? ts.getCombinedNodeFlags(s.valueDeclaration) : s.flags & 134217728 ? 16 | 128 : 0; + return s.valueDeclaration ? ts.getCombinedNodeFlags(s.valueDeclaration) : s.flags & 134217728 ? 8 | 64 : 0; } function checkClassPropertyAccess(node, left, type, prop) { var flags = getDeclarationFlagsFromSymbol(prop); @@ -16801,17 +17171,17 @@ var ts; error(errorNode, ts.Diagnostics.Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword); return false; } - if (flags & 256) { + if (flags & 128) { error(errorNode, ts.Diagnostics.Abstract_method_0_in_class_1_cannot_be_accessed_via_super_expression, symbolToString(prop), typeToString(declaringClass)); return false; } } - if (!(flags & (32 | 64))) { + if (!(flags & (16 | 32))) { return true; } var enclosingClassDeclaration = ts.getContainingClass(node); var enclosingClass = enclosingClassDeclaration ? getDeclaredTypeOfSymbol(getSymbolOfNode(enclosingClassDeclaration)) : undefined; - if (flags & 32) { + if (flags & 16) { if (declaringClass !== enclosingClass) { error(node, ts.Diagnostics.Property_0_is_private_and_only_accessible_within_class_1, symbolToString(prop), typeToString(declaringClass)); return false; @@ -16825,7 +17195,7 @@ var ts; error(node, ts.Diagnostics.Property_0_is_protected_and_only_accessible_within_class_1_and_its_subclasses, symbolToString(prop), typeToString(declaringClass)); return false; } - if (flags & 128) { + if (flags & 64) { return true; } if (type.flags & 33554432) { @@ -17005,8 +17375,8 @@ var ts; var specializedIndex = -1; var spliceIndex; ts.Debug.assert(!result.length); - for (var _i = 0; _i < signatures.length; _i++) { - var signature = signatures[_i]; + 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_5 = signature.declaration && signature.declaration.parent; if (!lastSymbol || symbol === lastSymbol) { @@ -17417,8 +17787,8 @@ var ts; reportError(ts.Diagnostics.Supplied_parameters_do_not_match_any_signature_of_call_target); } if (!produceDiagnostics) { - for (var _i = 0; _i < candidates.length; _i++) { - var candidate = candidates[_i]; + for (var _i = 0, candidates_1 = candidates; _i < candidates_1.length; _i++) { + var candidate = candidates_1[_i]; if (hasCorrectArity(node, args, candidate)) { if (candidate.typeParameters && typeArguments) { candidate = getSignatureInstantiation(candidate, ts.map(typeArguments, getTypeFromTypeNode)); @@ -17437,8 +17807,8 @@ var ts; diagnostics.add(ts.createDiagnosticForNodeFromMessageChain(node, errorInfo)); } function chooseOverload(candidates, relation) { - for (var _i = 0; _i < candidates.length; _i++) { - var originalCandidate = candidates[_i]; + for (var _i = 0, candidates_2 = candidates; _i < candidates_2.length; _i++) { + var originalCandidate = candidates_2[_i]; if (!hasCorrectArity(node, args, originalCandidate)) { continue; } @@ -17541,7 +17911,7 @@ var ts; return resolveErrorCall(node); } var valueDecl = expressionType.symbol && getClassLikeDeclarationOfSymbol(expressionType.symbol); - if (valueDecl && valueDecl.flags & 256) { + if (valueDecl && valueDecl.flags & 128) { error(node, ts.Diagnostics.Cannot_create_an_instance_of_the_abstract_class_0, ts.declarationNameToString(valueDecl.name)); return resolveErrorCall(node); } @@ -17827,32 +18197,24 @@ var ts; }); return aggregatedTypes; } - function bodyContainsAReturnStatement(funcBody) { - return ts.forEachReturnStatement(funcBody, function (returnStatement) { - return true; - }); - } - function bodyContainsSingleThrowStatement(body) { - return (body.statements.length === 1) && (body.statements[0].kind === 208); - } - function checkIfNonVoidFunctionHasReturnExpressionsOrSingleThrowStatment(func, returnType) { + function checkAllCodePathsInNonVoidFunctionReturnOrThrow(func, returnType) { if (!produceDiagnostics) { return; } if (returnType === voidType || isTypeAny(returnType)) { return; } - if (ts.nodeIsMissing(func.body) || func.body.kind !== 192) { + if (ts.nodeIsMissing(func.body) || func.body.kind !== 192 || !(func.flags & 524288)) { return; } - var bodyBlock = func.body; - if (bodyContainsAReturnStatement(bodyBlock)) { - return; + if (func.flags & 1048576) { + if (compilerOptions.noImplicitReturns) { + error(func.type, ts.Diagnostics.Not_all_code_paths_return_a_value); + } } - if (bodyContainsSingleThrowStatement(bodyBlock)) { - return; + else { + error(func.type, ts.Diagnostics.A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value); } - error(func.type, ts.Diagnostics.A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value_or_consist_of_a_single_throw_statement); } function checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper) { ts.Debug.assert(node.kind !== 143 || ts.isObjectLiteralMethod(node)); @@ -17911,7 +18273,7 @@ var ts; promisedType = checkAsyncFunctionReturnType(node); } if (returnType && !node.asteriskToken) { - checkIfNonVoidFunctionHasReturnExpressionsOrSingleThrowStatment(node, isAsync ? promisedType : returnType); + checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, isAsync ? promisedType : returnType); } if (node.body) { if (!node.type) { @@ -17970,7 +18332,7 @@ var ts; case 69: case 166: { var symbol = findSymbol(n); - return symbol && (symbol.flags & 3) !== 0 && (getDeclarationFlagsFromSymbol(symbol) & 32768) !== 0; + return symbol && (symbol.flags & 3) !== 0 && (getDeclarationFlagsFromSymbol(symbol) & 16384) !== 0; } case 167: { var index = n.argumentExpression; @@ -17978,7 +18340,7 @@ var ts; if (symbol && index && index.kind === 9) { var name_12 = index.text; var prop = getPropertyOfType(getTypeOfSymbol(symbol), name_12); - return prop && (prop.flags & 3) !== 0 && (getDeclarationFlagsFromSymbol(prop) & 32768) !== 0; + return prop && (prop.flags & 3) !== 0 && (getDeclarationFlagsFromSymbol(prop) & 16384) !== 0; } return false; } @@ -18058,8 +18420,8 @@ var ts; } if (type.flags & 49152) { var types = type.types; - for (var _i = 0; _i < types.length; _i++) { - var current = types[_i]; + for (var _i = 0, types_9 = types; _i < types_9.length; _i++) { + var current = types_9[_i]; if (current.flags & kind) { return true; } @@ -18074,8 +18436,8 @@ var ts; } if (type.flags & 49152) { var types = type.types; - for (var _i = 0; _i < types.length; _i++) { - var current = types[_i]; + for (var _i = 0, types_10 = types; _i < types_10.length; _i++) { + var current = types_10[_i]; if (!(current.flags & kind)) { return false; } @@ -18110,8 +18472,8 @@ var ts; } function checkObjectLiteralAssignment(node, sourceType, contextualMapper) { var properties = node.properties; - for (var _i = 0; _i < properties.length; _i++) { - var p = properties[_i]; + for (var _i = 0, properties_3 = properties; _i < properties_3.length; _i++) { + var p = properties_3[_i]; if (p.kind === 245 || p.kind === 246) { var name_13 = p.name; var type = isTypeAny(sourceType) @@ -18573,7 +18935,7 @@ var ts; checkGrammarDecorators(node) || checkGrammarModifiers(node); checkVariableLikeDeclaration(node); var func = ts.getContainingFunction(node); - if (node.flags & 112) { + if (node.flags & 56) { func = ts.getContainingFunction(node); if (!(func.kind === 144 && ts.nodeIsPresent(func.body))) { error(node, ts.Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation); @@ -18754,7 +19116,7 @@ var ts; function checkMethodDeclaration(node) { checkGrammarMethod(node) || checkGrammarComputedPropertyName(node.name); checkFunctionLikeDeclaration(node); - if (node.flags & 256 && node.body) { + if (node.flags & 128 && node.body) { error(node, ts.Diagnostics.Method_0_cannot_have_an_implementation_because_it_is_marked_abstract, ts.declarationNameToString(node.name)); } } @@ -18801,7 +19163,7 @@ var ts; } function isInstancePropertyWithInitializer(n) { return n.kind === 141 && - !(n.flags & 128) && + !(n.flags & 64) && !!n.initializer; } var containingClassDecl = node.parent; @@ -18814,12 +19176,12 @@ var ts; error(node, ts.Diagnostics.A_constructor_cannot_contain_a_super_call_when_its_class_extends_null); } var superCallShouldBeFirst = ts.forEach(node.parent.members, isInstancePropertyWithInitializer) || - ts.forEach(node.parameters, function (p) { return p.flags & (16 | 32 | 64); }); + ts.forEach(node.parameters, function (p) { return p.flags & (8 | 16 | 32); }); if (superCallShouldBeFirst) { var statements = node.body.statements; var superCallStatement; - for (var _i = 0; _i < statements.length; _i++) { - var statement = statements[_i]; + for (var _i = 0, statements_2 = statements; _i < statements_2.length; _i++) { + var statement = statements_2[_i]; if (statement.kind === 195 && isSuperCallExpression(statement.expression)) { superCallStatement = statement; break; @@ -18845,15 +19207,22 @@ var ts; if (produceDiagnostics) { checkGrammarFunctionLikeDeclaration(node) || checkGrammarAccessor(node) || checkGrammarComputedPropertyName(node.name); if (node.kind === 145) { - if (!ts.isInAmbientContext(node) && ts.nodeIsPresent(node.body) && !(bodyContainsAReturnStatement(node.body) || bodyContainsSingleThrowStatement(node.body))) { - error(node.name, ts.Diagnostics.A_get_accessor_must_return_a_value_or_consist_of_a_single_throw_statement); + if (!ts.isInAmbientContext(node) && ts.nodeIsPresent(node.body) && (node.flags & 524288)) { + if (node.flags & 1048576) { + if (compilerOptions.noImplicitReturns) { + error(node.name, ts.Diagnostics.Not_all_code_paths_return_a_value); + } + } + else { + error(node.name, ts.Diagnostics.A_get_accessor_must_return_a_value); + } } } if (!ts.hasDynamicName(node)) { var otherKind = node.kind === 145 ? 146 : 145; var otherAccessor = ts.getDeclarationOfKind(node.symbol, otherKind); if (otherAccessor) { - if (((node.flags & 112) !== (otherAccessor.flags & 112))) { + if (((node.flags & 56) !== (otherAccessor.flags & 56))) { error(node.name, ts.Diagnostics.Getter_and_setter_accessors_do_not_agree_in_visibility); } var currentAccessorType = getAnnotatedAccessorType(node); @@ -18920,7 +19289,7 @@ var ts; ts.forEach(node.types, checkSourceElement); } function isPrivateWithinAmbient(node) { - return (node.flags & 32) && ts.isInAmbientContext(node); + return (node.flags & 16) && ts.isInAmbientContext(node); } function checkSpecializedSignatureDeclaration(signatureDeclarationNode) { if (!produceDiagnostics) { @@ -18945,8 +19314,8 @@ var ts; else { signaturesToCheck = getSignaturesOfSymbol(getSymbolOfNode(signatureDeclarationNode)); } - for (var _i = 0; _i < signaturesToCheck.length; _i++) { - var otherSignature = signaturesToCheck[_i]; + for (var _i = 0, signaturesToCheck_1 = signaturesToCheck; _i < signaturesToCheck_1.length; _i++) { + var otherSignature = signaturesToCheck_1[_i]; if (!otherSignature.hasStringLiterals && isSignatureAssignableTo(signature, otherSignature)) { return; } @@ -18959,10 +19328,10 @@ var ts; n.parent.kind !== 214 && n.parent.kind !== 186 && ts.isInAmbientContext(n)) { - if (!(flags & 2)) { - flags |= 1; + if (!(flags & 4)) { + flags |= 2; } - flags |= 2; + flags |= 4; } return flags & flagsToCheck; } @@ -18980,16 +19349,16 @@ var ts; var canonicalFlags = getEffectiveDeclarationFlags(getCanonicalOverload(overloads, implementation), flagsToCheck); ts.forEach(overloads, function (o) { var deviation = getEffectiveDeclarationFlags(o, flagsToCheck) ^ canonicalFlags; - if (deviation & 1) { + if (deviation & 2) { error(o.name, ts.Diagnostics.Overload_signatures_must_all_be_exported_or_not_exported); } - else if (deviation & 2) { + else if (deviation & 4) { error(o.name, ts.Diagnostics.Overload_signatures_must_all_be_ambient_or_non_ambient); } - else if (deviation & (32 | 64)) { + else if (deviation & (16 | 32)) { error(o.name, ts.Diagnostics.Overload_signatures_must_all_be_public_private_or_protected); } - else if (deviation & 256) { + else if (deviation & 128) { error(o.name, ts.Diagnostics.Overload_signatures_must_all_be_abstract_or_not_abstract); } }); @@ -19006,7 +19375,7 @@ var ts; }); } } - var flagsToCheck = 1 | 2 | 32 | 64 | 256; + var flagsToCheck = 2 | 4 | 16 | 32 | 128; var someNodeFlags = 0; var allNodeFlags = flagsToCheck; var someHaveQuestionToken = false; @@ -19035,8 +19404,8 @@ var ts; var errorNode_1 = subsequentNode.name || subsequentNode; if (node.name && subsequentNode.name && node.name.text === subsequentNode.name.text) { ts.Debug.assert(node.kind === 143 || node.kind === 142); - ts.Debug.assert((node.flags & 128) !== (subsequentNode.flags & 128)); - var diagnostic = node.flags & 128 ? ts.Diagnostics.Function_overload_must_be_static : ts.Diagnostics.Function_overload_must_not_be_static; + ts.Debug.assert((node.flags & 64) !== (subsequentNode.flags & 64)); + var diagnostic = node.flags & 64 ? ts.Diagnostics.Function_overload_must_be_static : ts.Diagnostics.Function_overload_must_not_be_static; error(errorNode_1, diagnostic); return; } @@ -19051,7 +19420,7 @@ var ts; error(errorNode, ts.Diagnostics.Constructor_implementation_is_missing); } else { - if (node.flags & 256) { + if (node.flags & 128) { error(errorNode, ts.Diagnostics.All_declarations_of_an_abstract_method_must_be_consecutive); } else { @@ -19062,8 +19431,8 @@ var ts; var isExportSymbolInsideModule = symbol.parent && symbol.parent.flags & 1536; var duplicateFunctionDeclaration = false; var multipleConstructorImplementation = false; - for (var _i = 0; _i < declarations.length; _i++) { - var current = declarations[_i]; + for (var _i = 0, declarations_4 = declarations; _i < declarations_4.length; _i++) { + var current = declarations_4[_i]; var node = current; var inAmbientContext = ts.isInAmbientContext(node); var inAmbientContextOrInterface = node.parent.kind === 215 || node.parent.kind === 155 || inAmbientContext; @@ -19112,7 +19481,7 @@ var ts; }); } if (!isExportSymbolInsideModule && lastSeenNonAmbientDeclaration && !lastSeenNonAmbientDeclaration.body && - !(lastSeenNonAmbientDeclaration.flags & 256)) { + !(lastSeenNonAmbientDeclaration.flags & 128)) { reportImplementationExpectedError(lastSeenNonAmbientDeclaration); } if (hasOverloads) { @@ -19122,8 +19491,8 @@ var ts; var signatures = getSignaturesOfSymbol(symbol); var bodySignature = getSignatureFromDeclaration(bodyDeclaration); if (!bodySignature.hasStringLiterals) { - for (var _a = 0; _a < signatures.length; _a++) { - var signature = signatures[_a]; + for (var _a = 0, signatures_3 = signatures; _a < signatures_3.length; _a++) { + var signature = signatures_3[_a]; if (!signature.hasStringLiterals && !isSignatureAssignableTo(bodySignature, signature)) { error(signature.declaration, ts.Diagnostics.Overload_signature_is_not_compatible_with_function_implementation); break; @@ -19153,9 +19522,9 @@ var ts; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var d = _a[_i]; var declarationSpaces = getDeclarationSpaces(d); - var effectiveDeclarationFlags = getEffectiveDeclarationFlags(d, 1 | 1024); - if (effectiveDeclarationFlags & 1) { - if (effectiveDeclarationFlags & 1024) { + var effectiveDeclarationFlags = getEffectiveDeclarationFlags(d, 2 | 512); + if (effectiveDeclarationFlags & 2) { + if (effectiveDeclarationFlags & 512) { defaultExportedDeclarationSpaces |= declarationSpaces; } else { @@ -19291,9 +19660,12 @@ var ts; if (promiseType === unknownType && compilerOptions.isolatedModules) { return unknownType; } - var promiseConstructor = getMergedSymbol(promiseType.symbol); + var promiseConstructor = getNodeLinks(node.type).resolvedSymbol; if (!promiseConstructor || !symbolIsValue(promiseConstructor)) { - error(node, ts.Diagnostics.Type_0_is_not_a_valid_async_function_return_type, typeToString(promiseType)); + var typeName = promiseConstructor + ? symbolToString(promiseConstructor) + : typeToString(promiseType); + error(node, ts.Diagnostics.Type_0_is_not_a_valid_async_function_return_type, typeName); return unknownType; } var promiseConstructorType = getTypeOfSymbol(promiseConstructor); @@ -19452,7 +19824,7 @@ var ts; if (isAsync) { promisedType = checkAsyncFunctionReturnType(node); } - checkIfNonVoidFunctionHasReturnExpressionsOrSingleThrowStatment(node, isAsync ? promisedType : returnType); + checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, isAsync ? promisedType : returnType); } if (produceDiagnostics && !node.type) { if (compilerOptions.noImplicitAny && ts.nodeIsMissing(node.body) && !isPrivateWithinAmbient(node)) { @@ -19555,7 +19927,7 @@ var ts; } } function checkVarDeclaredNamesNotShadowed(node) { - if ((ts.getCombinedNodeFlags(node) & 49152) !== 0 || ts.isParameterDeclaration(node)) { + if ((ts.getCombinedNodeFlags(node) & 24576) !== 0 || ts.isParameterDeclaration(node)) { return; } if (node.kind === 211 && !node.initializer) { @@ -19567,7 +19939,7 @@ var ts; if (localDeclarationSymbol && localDeclarationSymbol !== symbol && localDeclarationSymbol.flags & 2) { - if (getDeclarationFlagsFromSymbol(localDeclarationSymbol) & 49152) { + if (getDeclarationFlagsFromSymbol(localDeclarationSymbol) & 24576) { var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 212); var container = varDeclList.parent.kind === 193 && varDeclList.parent.parent ? varDeclList.parent.parent @@ -19694,6 +20066,9 @@ var ts; checkGrammarStatementInAmbientContext(node); checkExpression(node.expression); checkSourceElement(node.thenStatement); + if (node.thenStatement.kind === 194) { + error(node.thenStatement, ts.Diagnostics.The_body_of_an_if_statement_cannot_be_the_empty_statement); + } checkSourceElement(node.elseStatement); } function checkDoStatement(node) { @@ -19943,7 +20318,7 @@ var ts; error(node.expression, ts.Diagnostics.Setters_cannot_return_a_value); } else if (func.kind === 144) { - if (!isTypeAssignableTo(exprType, returnType)) { + if (!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); } } @@ -20073,7 +20448,7 @@ var ts; var classDeclaration = type.symbol.valueDeclaration; for (var _i = 0, _a = classDeclaration.members; _i < _a.length; _i++) { var member = _a[_i]; - if (!(member.flags & 128) && ts.hasDynamicName(member)) { + if (!(member.flags & 64) && ts.hasDynamicName(member)) { var propType = getTypeOfSymbol(member.symbol); checkIndexConstraintForProperty(member.symbol, propType, type, declaredStringIndexer, stringIndexType, 0); checkIndexConstraintForProperty(member.symbol, propType, type, declaredNumberIndexer, numberIndexType, 1); @@ -20149,7 +20524,7 @@ var ts; return getTypeOfSymbol(getSymbolOfNode(node)); } function checkClassDeclaration(node) { - if (!node.name && !(node.flags & 1024)) { + if (!node.name && !(node.flags & 512)) { grammarErrorOnFirstToken(node, ts.Diagnostics.A_class_declaration_without_the_default_modifier_must_have_a_name); } checkClassLikeDeclaration(node); @@ -20199,8 +20574,8 @@ var ts; } var implementedTypeNodes = ts.getClassImplementsHeritageClauseElements(node); if (implementedTypeNodes) { - for (var _b = 0; _b < implementedTypeNodes.length; _b++) { - var typeRefNode = implementedTypeNodes[_b]; + for (var _b = 0, implementedTypeNodes_1 = implementedTypeNodes; _b < implementedTypeNodes_1.length; _b++) { + var typeRefNode = implementedTypeNodes_1[_b]; if (!ts.isSupportedExpressionWithTypeArguments(typeRefNode)) { error(typeRefNode.expression, ts.Diagnostics.A_class_can_only_implement_an_identifier_Slashqualified_name_with_optional_type_arguments); } @@ -20232,8 +20607,8 @@ var ts; } function checkKindsOfPropertyMemberOverrides(type, baseType) { var baseProperties = getPropertiesOfObjectType(baseType); - for (var _i = 0; _i < baseProperties.length; _i++) { - var baseProperty = baseProperties[_i]; + for (var _i = 0, baseProperties_1 = baseProperties; _i < baseProperties_1.length; _i++) { + var baseProperty = baseProperties_1[_i]; var base = getTargetSymbol(baseProperty); if (base.flags & 134217728) { continue; @@ -20244,7 +20619,7 @@ var ts; if (derived) { if (derived === base) { var derivedClassDecl = getClassLikeDeclarationOfSymbol(type.symbol); - if (baseDeclarationFlags & 256 && (!derivedClassDecl || !(derivedClassDecl.flags & 256))) { + if (baseDeclarationFlags & 128 && (!derivedClassDecl || !(derivedClassDecl.flags & 128))) { if (derivedClassDecl.kind === 186) { error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1, symbolToString(baseProperty), typeToString(baseType)); } @@ -20255,10 +20630,10 @@ var ts; } else { var derivedDeclarationFlags = getDeclarationFlagsFromSymbol(derived); - if ((baseDeclarationFlags & 32) || (derivedDeclarationFlags & 32)) { + if ((baseDeclarationFlags & 16) || (derivedDeclarationFlags & 16)) { continue; } - if ((baseDeclarationFlags & 128) !== (derivedDeclarationFlags & 128)) { + if ((baseDeclarationFlags & 64) !== (derivedDeclarationFlags & 64)) { continue; } if ((base.flags & derived.flags & 8192) || ((base.flags & 98308) && (derived.flags & 98308))) { @@ -20324,11 +20699,11 @@ var ts; var seen = {}; ts.forEach(resolveDeclaredMembers(type).declaredProperties, function (p) { seen[p.name] = { prop: p, containingType: type }; }); var ok = true; - for (var _i = 0; _i < baseTypes.length; _i++) { - var base = baseTypes[_i]; + for (var _i = 0, baseTypes_2 = baseTypes; _i < baseTypes_2.length; _i++) { + var base = baseTypes_2[_i]; var properties = getPropertiesOfObjectType(getTypeWithThisArgument(base, type.thisType)); - for (var _a = 0; _a < properties.length; _a++) { - var prop = properties[_a]; + for (var _a = 0, properties_4 = properties; _a < properties_4.length; _a++) { + var prop = properties_4[_a]; if (!ts.hasProperty(seen, prop.name)) { seen[prop.name] = { prop: prop, containingType: base }; } @@ -20597,8 +20972,8 @@ var ts; } function getFirstNonAmbientClassOrFunctionDeclaration(symbol) { var declarations = symbol.declarations; - for (var _i = 0; _i < declarations.length; _i++) { - var declaration = declarations[_i]; + for (var _i = 0, declarations_5 = declarations; _i < declarations_5.length; _i++) { + var declaration = declarations_5[_i]; if ((declaration.kind === 214 || (declaration.kind === 213 && ts.nodeIsPresent(declaration.body))) && !ts.isInAmbientContext(declaration)) { @@ -20726,7 +21101,7 @@ var ts; if (checkGrammarModuleElementContext(node, ts.Diagnostics.An_import_declaration_can_only_be_used_in_a_namespace_or_module)) { return; } - if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && (node.flags & 2035)) { + if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && (node.flags & 1022)) { grammarErrorOnFirstToken(node, ts.Diagnostics.An_import_declaration_cannot_have_modifiers); } if (checkExternalImportOrExportDeclaration(node)) { @@ -20753,7 +21128,7 @@ var ts; checkGrammarDecorators(node) || checkGrammarModifiers(node); if (ts.isInternalModuleImportEqualsDeclaration(node) || checkExternalImportOrExportDeclaration(node)) { checkImportBinding(node); - if (node.flags & 1) { + if (node.flags & 2) { markExportAsReferenced(node); } if (ts.isInternalModuleImportEqualsDeclaration(node)) { @@ -20781,7 +21156,7 @@ var ts; if (checkGrammarModuleElementContext(node, ts.Diagnostics.An_export_declaration_can_only_be_used_in_a_module)) { return; } - if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && (node.flags & 2035)) { + if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && (node.flags & 1022)) { grammarErrorOnFirstToken(node, ts.Diagnostics.An_export_declaration_cannot_have_modifiers); } if (!node.moduleSpecifier || checkExternalImportOrExportDeclaration(node)) { @@ -20820,7 +21195,7 @@ var ts; error(node, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_namespace); return; } - if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && (node.flags & 2035)) { + if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && (node.flags & 1022)) { grammarErrorOnFirstToken(node, ts.Diagnostics.An_export_assignment_cannot_have_modifiers); } if (node.expression.kind === 69) { @@ -21205,7 +21580,7 @@ var ts; } case 214: case 215: - if (!(memberFlags & 128)) { + if (!(memberFlags & 64)) { copySymbols(getSymbolOfNode(location).members, meaning & 793056); } break; @@ -21467,7 +21842,7 @@ var ts; } function getParentTypeOfClassElement(node) { var classSymbol = getSymbolOfNode(node.parent); - return node.flags & 128 + return node.flags & 64 ? getTypeOfSymbol(classSymbol) : getDeclaredTypeOfSymbol(classSymbol); } @@ -21753,7 +22128,7 @@ var ts; } function initializeTypeChecker() { ts.forEach(host.getSourceFiles(), function (file) { - ts.bindSourceFile(file); + ts.bindSourceFile(file, compilerOptions); }); ts.forEach(host.getSourceFiles(), function (file) { if (!ts.isExternalModule(file)) { @@ -21897,19 +22272,19 @@ var ts; text = "private"; lastPrivate = modifier; } - if (flags & 112) { + if (flags & 56) { return grammarErrorOnNode(modifier, ts.Diagnostics.Accessibility_modifier_already_seen); } - else if (flags & 128) { + else if (flags & 64) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "static"); } - else if (flags & 512) { + else if (flags & 256) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "async"); } else if (node.parent.kind === 219 || node.parent.kind === 248) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_element, text); } - else if (flags & 256) { + else if (flags & 128) { if (modifier.kind === 110) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, text, "abstract"); } @@ -21920,10 +22295,10 @@ var ts; flags |= ts.modifierToFlag(modifier.kind); break; case 113: - if (flags & 128) { + if (flags & 64) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "static"); } - else if (flags & 512) { + else if (flags & 256) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "static", "async"); } else if (node.parent.kind === 219 || node.parent.kind === 248) { @@ -21932,23 +22307,23 @@ var ts; else if (node.kind === 138) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "static"); } - else if (flags & 256) { + else if (flags & 128) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "static", "abstract"); } - flags |= 128; + flags |= 64; lastStatic = modifier; break; case 82: - if (flags & 1) { + if (flags & 2) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "export"); } - else if (flags & 2) { + else if (flags & 4) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "declare"); } - else if (flags & 256) { + else if (flags & 128) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "abstract"); } - else if (flags & 512) { + else if (flags & 256) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "async"); } else if (node.parent.kind === 214) { @@ -21957,13 +22332,13 @@ var ts; else if (node.kind === 138) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "export"); } - flags |= 1; + flags |= 2; break; case 122: - if (flags & 2) { + if (flags & 4) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "declare"); } - else if (flags & 512) { + else if (flags & 256) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); } else if (node.parent.kind === 214) { @@ -21975,69 +22350,69 @@ var ts; else if (ts.isInAmbientContext(node.parent) && node.parent.kind === 219) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_declare_modifier_cannot_be_used_in_an_already_ambient_context); } - flags |= 2; + flags |= 4; lastDeclare = modifier; break; case 115: - if (flags & 256) { + if (flags & 128) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "abstract"); } if (node.kind !== 214) { if (node.kind !== 143) { return grammarErrorOnNode(modifier, ts.Diagnostics.abstract_modifier_can_only_appear_on_a_class_or_method_declaration); } - if (!(node.parent.kind === 214 && node.parent.flags & 256)) { + if (!(node.parent.kind === 214 && node.parent.flags & 128)) { return grammarErrorOnNode(modifier, ts.Diagnostics.Abstract_methods_can_only_appear_within_an_abstract_class); } - if (flags & 128) { + if (flags & 64) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "static", "abstract"); } - if (flags & 32) { + if (flags & 16) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "private", "abstract"); } } - flags |= 256; + flags |= 128; break; case 118: - if (flags & 512) { + if (flags & 256) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "async"); } - else if (flags & 2 || ts.isInAmbientContext(node.parent)) { + else if (flags & 4 || ts.isInAmbientContext(node.parent)) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); } else if (node.kind === 138) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "async"); } - flags |= 512; + flags |= 256; lastAsync = modifier; break; } } if (node.kind === 144) { - if (flags & 128) { + if (flags & 64) { return grammarErrorOnNode(lastStatic, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "static"); } - if (flags & 256) { + if (flags & 128) { return grammarErrorOnNode(lastStatic, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "abstract"); } - else if (flags & 64) { + else if (flags & 32) { return grammarErrorOnNode(lastProtected, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "protected"); } - else if (flags & 32) { + else if (flags & 16) { return grammarErrorOnNode(lastPrivate, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "private"); } - else if (flags & 512) { + else if (flags & 256) { return grammarErrorOnNode(lastAsync, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "async"); } return; } - else if ((node.kind === 222 || node.kind === 221) && flags & 2) { + else if ((node.kind === 222 || node.kind === 221) && flags & 4) { return grammarErrorOnNode(lastDeclare, ts.Diagnostics.A_0_modifier_cannot_be_used_with_an_import_declaration, "declare"); } - else if (node.kind === 138 && (flags & 112) && ts.isBindingPattern(node.name)) { + else if (node.kind === 138 && (flags & 56) && ts.isBindingPattern(node.name)) { return grammarErrorOnNode(node, ts.Diagnostics.A_parameter_property_may_not_be_a_binding_pattern); } - if (flags & 512) { + if (flags & 256) { return checkGrammarAsyncModifier(node, lastAsync); } } @@ -22137,7 +22512,7 @@ var ts; if (parameter.dotDotDotToken) { return grammarErrorOnNode(parameter.dotDotDotToken, ts.Diagnostics.An_index_signature_cannot_have_a_rest_parameter); } - if (parameter.flags & 2035) { + if (parameter.flags & 1022) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_cannot_have_an_accessibility_modifier); } if (parameter.questionToken) { @@ -22157,7 +22532,7 @@ var ts; } } function checkGrammarForIndexSignatureModifier(node) { - if (node.flags & 2035) { + if (node.flags & 1022) { grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_not_permitted_on_index_signature_members); } } @@ -22179,8 +22554,8 @@ var ts; function checkGrammarForOmittedArgument(node, args) { if (args) { var sourceFile = ts.getSourceFileOfNode(node); - for (var _i = 0; _i < args.length; _i++) { - var arg = args[_i]; + for (var _i = 0, args_1 = args; _i < args_1.length; _i++) { + var arg = args_1[_i]; if (arg.kind === 187) { return grammarErrorAtPos(sourceFile, arg.pos, 0, ts.Diagnostics.Argument_expression_expected); } @@ -22420,7 +22795,7 @@ var ts; if (parameter.dotDotDotToken) { return grammarErrorOnNode(parameter.dotDotDotToken, ts.Diagnostics.A_set_accessor_cannot_have_rest_parameter); } - else if (parameter.flags & 2035) { + else if (parameter.flags & 1022) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation); } else if (parameter.questionToken) { @@ -22554,8 +22929,8 @@ var ts; } else { var elements = name.elements; - for (var _i = 0; _i < elements.length; _i++) { - var element = elements[_i]; + for (var _i = 0, elements_2 = elements; _i < elements_2.length; _i++) { + var element = elements_2[_i]; if (element.kind !== 187) { checkGrammarNameInLetOrConstDeclarations(element.name); } @@ -22674,8 +23049,8 @@ var ts; node.kind === 221 || node.kind === 228 || node.kind === 227 || - (node.flags & 2) || - (node.flags & (1 | 1024))) { + (node.flags & 4) || + (node.flags & (2 | 512))) { return false; } return grammarErrorOnFirstToken(node, ts.Diagnostics.A_declare_modifier_is_required_for_a_top_level_declaration_in_a_d_ts_file); @@ -22713,7 +23088,7 @@ var ts; } } function checkGrammarNumericLiteral(node) { - if (node.flags & 65536 && languageVersion >= 1) { + if (node.flags & 32768 && languageVersion >= 1) { return grammarErrorOnNode(node, ts.Diagnostics.Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher); } } @@ -22760,7 +23135,7 @@ var ts; var addedGlobalFileReference = false; ts.forEach(root.referencedFiles, function (fileReference) { var referencedFile = ts.tryResolveScriptReference(host, root, fileReference); - if (referencedFile && ((referencedFile.flags & 8192) || + if (referencedFile && ((referencedFile.flags & 4096) || ts.shouldEmitToOwnFile(referencedFile, compilerOptions) || !addedGlobalFileReference)) { writeReferencePath(referencedFile); @@ -22938,15 +23313,15 @@ var ts; } } function emitLines(nodes) { - for (var _i = 0; _i < nodes.length; _i++) { - var node = nodes[_i]; + for (var _i = 0, nodes_2 = nodes; _i < nodes_2.length; _i++) { + var node = nodes_2[_i]; emit(node); } } function emitSeparatedList(nodes, separator, eachNodeEmitFn, canEmitFn) { var currentWriterPos = writer.getTextPos(); - for (var _i = 0; _i < nodes.length; _i++) { - var node = nodes[_i]; + for (var _i = 0, nodes_3 = nodes; _i < nodes_3.length; _i++) { + var node = nodes_3[_i]; if (!canEmitFn || canEmitFn(node)) { if (currentWriterPos !== writer.getTextPos()) { write(separator); @@ -23088,6 +23463,7 @@ var ts; function emitSourceFile(node) { currentSourceFile = node; enclosingDeclaration = node; + ts.emitDetachedComments(currentSourceFile, writer, ts.writeCommentRange, node, newLine, true); emitLines(node.statements); } function getExportDefaultTempVariableName() { @@ -23194,10 +23570,10 @@ var ts; } function emitModuleElementDeclarationFlags(node) { if (node.parent === currentSourceFile) { - if (node.flags & 1) { + if (node.flags & 2) { write("export "); } - if (node.flags & 1024) { + if (node.flags & 512) { write("default "); } else if (node.kind !== 215) { @@ -23206,22 +23582,22 @@ var ts; } } function emitClassMemberDeclarationFlags(node) { - if (node.flags & 32) { + if (node.flags & 16) { write("private "); } - else if (node.flags & 64) { + else if (node.flags & 32) { write("protected "); } - if (node.flags & 128) { + if (node.flags & 64) { write("static "); } - if (node.flags & 256) { + if (node.flags & 128) { write("abstract "); } } function writeImportEqualsDeclaration(node) { emitJsDocComments(node); - if (node.flags & 1) { + if (node.flags & 2) { write("export "); } write("import "); @@ -23256,11 +23632,11 @@ var ts; } } function writeImportDeclaration(node) { - if (!node.importClause && !(node.flags & 1)) { + if (!node.importClause && !(node.flags & 2)) { return; } emitJsDocComments(node); - if (node.flags & 1) { + if (node.flags & 2) { write("export "); } write("import "); @@ -23322,7 +23698,7 @@ var ts; function writeModuleDeclaration(node) { emitJsDocComments(node); emitModuleElementDeclarationFlags(node); - if (node.flags & 131072) { + if (node.flags & 65536) { write("namespace "); } else { @@ -23394,7 +23770,7 @@ var ts; writeLine(); } function isPrivateMethodTypeParameter(node) { - return node.parent.kind === 143 && (node.parent.flags & 32); + return node.parent.kind === 143 && (node.parent.flags & 16); } function emitTypeParameters(typeParameters) { function emitTypeParameter(node) { @@ -23436,7 +23812,7 @@ var ts; break; case 143: case 142: - if (node.parent.flags & 128) { + if (node.parent.flags & 64) { 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 === 214) { @@ -23499,7 +23875,7 @@ var ts; function emitParameterProperties(constructorDeclaration) { if (constructorDeclaration) { ts.forEach(constructorDeclaration.parameters, function (param) { - if (param.flags & 112) { + if (param.flags & 56) { emitPropertyDeclaration(param); } }); @@ -23507,7 +23883,7 @@ var ts; } emitJsDocComments(node); emitModuleElementDeclarationFlags(node); - if (node.flags & 256) { + if (node.flags & 128) { write("abstract "); } write("class "); @@ -23571,7 +23947,7 @@ var ts; if ((node.kind === 141 || node.kind === 140) && node.parent.kind === 155) { emitTypeOfVariableDeclarationFromTypeLiteral(node); } - else if (!(node.flags & 32)) { + else if (!(node.flags & 16)) { writeTypeOfDeclaration(node, node.type, getVariableDeclarationTypeVisibilityError); } } @@ -23585,7 +23961,7 @@ var ts; ts.Diagnostics.Exported_variable_0_has_or_is_using_private_name_1; } else if (node.kind === 141 || node.kind === 140) { - if (node.flags & 128) { + if (node.flags & 64) { return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 ? ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -23680,7 +24056,7 @@ var ts; emitJsDocComments(accessors.setAccessor); emitClassMemberDeclarationFlags(node); writeTextOfNode(currentSourceFile, node.name); - if (!(node.flags & 32)) { + if (!(node.flags & 16)) { accessorWithTypeAnnotation = node; var type = getTypeAnnotationFromAccessor(node); if (!type) { @@ -23707,7 +24083,7 @@ var ts; function getAccessorDeclarationTypeVisibilityError(symbolAccesibilityResult) { var diagnosticMessage; if (accessorWithTypeAnnotation.kind === 146) { - if (accessorWithTypeAnnotation.parent.flags & 128) { + if (accessorWithTypeAnnotation.parent.flags & 64) { diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_public_static_property_setter_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_public_static_property_setter_from_exported_class_has_or_is_using_private_name_1; @@ -23724,7 +24100,7 @@ var ts; }; } else { - if (accessorWithTypeAnnotation.flags & 128) { + if (accessorWithTypeAnnotation.flags & 64) { diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 ? ts.Diagnostics.Return_type_of_public_static_property_getter_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : @@ -23805,7 +24181,7 @@ var ts; emitType(node.type); } } - else if (node.kind !== 144 && !(node.flags & 32)) { + else if (node.kind !== 144 && !(node.flags & 16)) { writeReturnTypeAtSignature(node, getReturnTypeVisibilityError); } enclosingDeclaration = prevEnclosingDeclaration; @@ -23833,7 +24209,7 @@ var ts; break; case 143: case 142: - if (node.flags & 128) { + if (node.flags & 64) { diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 ? ts.Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : @@ -23890,7 +24266,7 @@ var ts; node.parent.parent.kind === 155) { emitTypeOfVariableDeclarationFromTypeLiteral(node); } - else if (!(node.parent.flags & 32)) { + else if (!(node.parent.flags & 16)) { writeTypeOfDeclaration(node, node.type, getParameterDeclarationTypeVisibilityError); } function getParameterDeclarationTypeVisibilityError(symbolAccesibilityResult) { @@ -23919,7 +24295,7 @@ var ts; ts.Diagnostics.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; case 143: case 142: - if (node.parent.flags & 128) { + if (node.parent.flags & 64) { return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 ? ts.Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -24035,7 +24411,7 @@ var ts; } } function writeReferencePath(referencedFile) { - var declFileName = referencedFile.flags & 8192 + var declFileName = referencedFile.flags & 4096 ? referencedFile.fileName : ts.shouldEmitToOwnFile(referencedFile, compilerOptions) ? ts.getOwnEmitOutputFilePath(referencedFile, host, ".d.ts") @@ -24368,16 +24744,8 @@ var ts; diagnostics: diagnostics, sourceMaps: sourceMapDataList }; - function isNodeDescendentOf(node, ancestor) { - while (node) { - if (node === ancestor) - return true; - node = node.parent; - } - return false; - } function isUniqueLocalName(name, container) { - for (var node = container; isNodeDescendentOf(node, container); node = node.nextContainer) { + for (var node = container; ts.isNodeDescendentOf(node, container); node = node.nextContainer) { if (node.locals && ts.hasProperty(node.locals, name)) { if (node.locals[name].flags & (107455 | 1048576 | 8388608)) { return false; @@ -25670,7 +26038,7 @@ var ts; write("]"); } else { - emitListWithSpread(elements, true, (node.flags & 2048) !== 0, elements.hasTrailingComma, true); + emitListWithSpread(elements, true, (node.flags & 1024) !== 0, elements.hasTrailingComma, true); } } function emitObjectLiteralBody(node, numElements) { @@ -25685,7 +26053,7 @@ var ts; emitLinePreservingList(node, properties, languageVersion >= 1, true); } else { - var multiLine = (node.flags & 2048) !== 0; + var multiLine = (node.flags & 1024) !== 0; if (!multiLine) { write(" "); } @@ -25704,7 +26072,7 @@ var ts; write("}"); } function emitDownlevelObjectLiteralWithComputedProperties(node, firstComputedPropertyIndex) { - var multiLine = (node.flags & 2048) !== 0; + var multiLine = (node.flags & 1024) !== 0; var properties = node.properties; write("("); if (multiLine) { @@ -26222,7 +26590,7 @@ var ts; var current = node; while (current) { if (current.kind === 248) { - return !isExported || ((ts.getCombinedNodeFlags(node) & 1) !== 0); + return !isExported || ((ts.getCombinedNodeFlags(node) & 2) !== 0); } else if (ts.isFunctionLike(current) || current.kind === 219) { return false; @@ -26440,7 +26808,7 @@ var ts; if (shouldHoistVariable(decl, true)) { return false; } - if (convertedLoopState && (ts.getCombinedNodeFlags(decl) & 49152) === 0) { + if (convertedLoopState && (ts.getCombinedNodeFlags(decl) & 24576) === 0) { for (var _a = 0, _b = decl.declarations; _a < _b.length; _a++) { var varDecl = _b[_a]; hoistVariableDeclarationFromLoop(convertedLoopState, varDecl); @@ -26522,7 +26890,7 @@ var ts; break; } var loopParameters; - if (loopInitializer && (ts.getCombinedNodeFlags(loopInitializer) & 49152)) { + if (loopInitializer && (ts.getCombinedNodeFlags(loopInitializer) & 24576)) { loopParameters = []; for (var _a = 0, _b = loopInitializer.declarations; _a < _b.length; _a++) { var varDeclaration = _b[_a]; @@ -26779,22 +27147,22 @@ var ts; var endPos = emitToken(86, node.pos); write(" "); endPos = emitToken(17, endPos); - var rhsIsIdentifier = node.expression.kind === 69; var counter = createTempVariable(268435456); - var rhsReference = rhsIsIdentifier ? node.expression : createTempVariable(0); + var rhsReference = ts.createSynthesizedNode(69); + rhsReference.text = node.expression.kind === 69 ? + makeUniqueName(node.expression.text) : + makeTempVariableName(0); emitStart(node.expression); write("var "); emitNodeWithoutSourceMap(counter); write(" = 0"); emitEnd(node.expression); - if (!rhsIsIdentifier) { - write(", "); - emitStart(node.expression); - emitNodeWithoutSourceMap(rhsReference); - write(" = "); - emitNodeWithoutSourceMap(node.expression); - emitEnd(node.expression); - } + write(", "); + emitStart(node.expression); + emitNodeWithoutSourceMap(rhsReference); + write(" = "); + emitNodeWithoutSourceMap(node.expression); + emitEnd(node.expression); write("; "); emitStart(node.initializer); emitNodeWithoutSourceMap(counter); @@ -27029,7 +27397,7 @@ var ts; } function emitModuleMemberName(node) { emitStart(node.name); - if (ts.getCombinedNodeFlags(node) & 1) { + if (ts.getCombinedNodeFlags(node) & 2) { var container = getContainingModule(node); if (container) { write(getGeneratedNameForNode(container)); @@ -27051,7 +27419,7 @@ var ts; } function emitEs6ExportDefaultCompat(node) { if (node.parent.kind === 248) { - ts.Debug.assert(!!(node.flags & 1024) || node.kind === 227); + ts.Debug.assert(!!(node.flags & 512) || node.kind === 227); if (modulekind === 1 || modulekind === 2 || modulekind === 3) { if (!currentSourceFile.symbol.exports["___esModule"]) { if (languageVersion === 1) { @@ -27067,12 +27435,12 @@ var ts; } } function emitExportMemberAssignment(node) { - if (node.flags & 1) { + if (node.flags & 2) { writeLine(); emitStart(node); if (modulekind === 4 && node.parent === currentSourceFile) { write(exportFunctionForFile + "(\""); - if (node.flags & 1024) { + if (node.flags & 512) { write("default"); } else { @@ -27083,7 +27451,7 @@ var ts; write(")"); } else { - if (node.flags & 1024) { + if (node.flags & 512) { emitEs6ExportDefaultCompat(node); if (languageVersion === 0) { write("exports[\"default\"]"); @@ -27171,7 +27539,7 @@ var ts; var emitCount = 0; var canDefineTempVariablesInPlace = false; if (root.kind === 211) { - var isExported = ts.getCombinedNodeFlags(root) & 1; + var isExported = ts.getCombinedNodeFlags(root) & 2; var isSourceLevelForSystemModuleKind = shouldHoistDeclarationInSystemJsModule(root); canDefineTempVariablesInPlace = !isExported && !isSourceLevelForSystemModuleKind; } @@ -27237,8 +27605,8 @@ var ts; if (properties.length !== 1) { value = ensureIdentifier(value, true); } - for (var _a = 0; _a < properties.length; _a++) { - var p = properties[_a]; + for (var _a = 0, properties_5 = properties; _a < properties_5.length; _a++) { + var p = properties_5[_a]; if (p.kind === 245 || p.kind === 246) { var propName = p.name; var target_1 = p.kind === 246 ? p : p.initializer || propName; @@ -27357,7 +27725,7 @@ var ts; var initializer = node.initializer; if (!initializer && languageVersion < 2) { var isLetDefinedInLoop = (resolver.getNodeCheckFlags(node) & 16384) && - (getCombinedFlagsForIdentifier(node.name) & 16384); + (getCombinedFlagsForIdentifier(node.name) & 8192); if (isLetDefinedInLoop && node.parent.parent.kind !== 200 && node.parent.parent.kind !== 201) { @@ -27396,13 +27764,13 @@ var ts; return ts.getCombinedNodeFlags(node.parent); } function isES6ExportedDeclaration(node) { - return !!(node.flags & 1) && + return !!(node.flags & 2) && modulekind === 5 && node.parent.kind === 248; } function emitVariableStatement(node) { var startIsEmitted = false; - if (node.flags & 1) { + if (node.flags & 2) { if (isES6ExportedDeclaration(node)) { write("export "); startIsEmitted = tryEmitStartOfVariableDeclarationList(node.declarationList); @@ -27426,7 +27794,7 @@ var ts; } } function shouldEmitLeadingAndTrailingCommentsForVariableStatement(node) { - if (!(node.flags & 1)) { + if (!(node.flags & 2)) { return true; } if (isES6ExportedDeclaration(node)) { @@ -27583,7 +27951,7 @@ var ts; if (!shouldEmitAsArrowFunction(node)) { if (isES6ExportedDeclaration(node)) { write("export "); - if (node.flags & 1024) { + if (node.flags & 512) { write("default "); } } @@ -27722,7 +28090,7 @@ var ts; emitRestParameter(node); } function emitExpressionFunctionBody(node, body) { - if (languageVersion < 2 || node.flags & 512) { + if (languageVersion < 2 || node.flags & 256) { emitDownLevelExpressionFunctionBody(node, body); return; } @@ -27738,7 +28106,7 @@ var ts; scopeEmitStart(node); increaseIndent(); var outPos = writer.getTextPos(); - emitDetachedComments(node.body); + emitDetachedCommentsAndUpdateCommentsInfo(node.body); emitFunctionBodyPreamble(node); var preambleEmitted = writer.getTextPos() !== outPos; decreaseIndent(); @@ -27774,7 +28142,7 @@ var ts; scopeEmitStart(node); var initialTextPos = writer.getTextPos(); increaseIndent(); - emitDetachedComments(body.statements); + emitDetachedCommentsAndUpdateCommentsInfo(body.statements); var startIndex = emitDirectivePrologues(body.statements, true); emitFunctionBodyPreamble(node); decreaseIndent(); @@ -27816,7 +28184,7 @@ var ts; } function emitParameterPropertyAssignments(node) { ts.forEach(node.parameters, function (param) { - if (param.flags & 112) { + if (param.flags & 56) { writeLine(); emitStart(param); emitStart(param.name); @@ -27848,15 +28216,15 @@ var ts; var properties = []; for (var _a = 0, _b = node.members; _a < _b.length; _a++) { var member = _b[_a]; - if (member.kind === 141 && isStatic === ((member.flags & 128) !== 0) && member.initializer) { + if (member.kind === 141 && isStatic === ((member.flags & 64) !== 0) && member.initializer) { properties.push(member); } } return properties; } function emitPropertyDeclarations(node, properties) { - for (var _a = 0; _a < properties.length; _a++) { - var property = properties[_a]; + for (var _a = 0, properties_6 = properties; _a < properties_6.length; _a++) { + var property = properties_6[_a]; emitPropertyDeclaration(node, property); } } @@ -27869,7 +28237,7 @@ var ts; emit(receiver); } else { - if (property.flags & 128) { + if (property.flags & 64) { emitDeclarationName(node); } else { @@ -27968,7 +28336,7 @@ var ts; writeLine(); emitLeadingComments(member); emitStart(member); - if (member.flags & 128) { + if (member.flags & 64) { write("static "); } if (member.kind === 145) { @@ -28013,7 +28381,7 @@ var ts; if (member.kind === 144 && !member.body) { emitCommentsOnNotEmittedNode(member); } - if (member.kind === 141 && member.initializer && (member.flags & 128) === 0) { + if (member.kind === 141 && member.initializer && (member.flags & 64) === 0) { hasInstancePropertyWithInitializer = true; } }); @@ -28050,7 +28418,7 @@ var ts; increaseIndent(); if (ctor) { startIndex = emitDirectivePrologues(ctor.body.statements, true); - emitDetachedComments(ctor.body.statements); + emitDetachedCommentsAndUpdateCommentsInfo(ctor.body.statements); } emitCaptureThisForNodeIfNecessary(node); var superCall; @@ -28121,7 +28489,7 @@ var ts; var thisNodeIsDecorated = ts.nodeIsDecorated(node); if (node.kind === 214) { if (thisNodeIsDecorated) { - if (isES6ExportedDeclaration(node) && !(node.flags & 1024)) { + if (isES6ExportedDeclaration(node) && !(node.flags & 512)) { write("export "); } write("let "); @@ -28130,7 +28498,7 @@ var ts; } else if (isES6ExportedDeclaration(node)) { write("export "); - if (node.flags & 1024) { + if (node.flags & 512) { write("default "); } } @@ -28146,7 +28514,7 @@ var ts; write(" = "); } write("class"); - if ((node.name || (node.flags & 1024 && staticProperties.length > 0)) && !thisNodeIsDecorated) { + if ((node.name || (node.flags & 512 && staticProperties.length > 0)) && !thisNodeIsDecorated) { write(" "); emitDeclarationName(node); } @@ -28169,8 +28537,8 @@ var ts; write(";"); } if (isClassExpressionWithStaticProperties) { - for (var _a = 0; _a < staticProperties.length; _a++) { - var property = staticProperties[_a]; + for (var _a = 0, staticProperties_1 = staticProperties; _a < staticProperties_1.length; _a++) { + var property = staticProperties_1[_a]; write(","); writeLine(); emitPropertyDeclaration(node, property, tempVariable, true); @@ -28186,7 +28554,7 @@ var ts; emitPropertyDeclarations(node, staticProperties); emitDecoratorsOfClass(node); } - if (!isES6ExportedDeclaration(node) && (node.flags & 1)) { + if (!isES6ExportedDeclaration(node) && (node.flags & 2)) { writeLine(); emitStart(node); emitModuleMemberName(node); @@ -28195,7 +28563,7 @@ var ts; emitEnd(node); write(";"); } - else if (isES6ExportedDeclaration(node) && (node.flags & 1024) && thisNodeIsDecorated) { + else if (isES6ExportedDeclaration(node) && (node.flags & 512) && thisNodeIsDecorated) { writeLine(); write("export default "); emitDeclarationName(node); @@ -28275,13 +28643,13 @@ var ts; } function emitClassMemberPrefix(node, member) { emitDeclarationName(node); - if (!(member.flags & 128)) { + if (!(member.flags & 64)) { write(".prototype"); } } function emitDecoratorsOfClass(node) { emitDecoratorsOfMembers(node, 0); - emitDecoratorsOfMembers(node, 128); + emitDecoratorsOfMembers(node, 64); emitDecoratorsOfConstructor(node); } function emitDecoratorsOfConstructor(node) { @@ -28316,7 +28684,7 @@ var ts; function emitDecoratorsOfMembers(node, staticFlag) { for (var _a = 0, _b = node.members; _a < _b.length; _a++) { var member = _b[_a]; - if ((member.flags & 128) !== staticFlag) { + if ((member.flags & 64) !== staticFlag) { continue; } if (!ts.nodeCanBeDecorated(member)) { @@ -28643,7 +29011,7 @@ var ts; return; } if (!shouldHoistDeclarationInSystemJsModule(node)) { - if (!(node.flags & 1) || isES6ExportedDeclaration(node)) { + if (!(node.flags & 2) || isES6ExportedDeclaration(node)) { emitStart(node); if (isES6ExportedDeclaration(node)) { write("export "); @@ -28674,7 +29042,7 @@ var ts; emitModuleMemberName(node); write(" = {}));"); emitEnd(node); - if (!isES6ExportedDeclaration(node) && node.flags & 1 && !shouldHoistDeclarationInSystemJsModule(node)) { + if (!isES6ExportedDeclaration(node) && node.flags & 2 && !shouldHoistDeclarationInSystemJsModule(node)) { writeLine(); emitStart(node); write("var "); @@ -28685,7 +29053,7 @@ var ts; write(";"); } if (modulekind !== 5 && node.parent === currentSourceFile) { - if (modulekind === 4 && (node.flags & 1)) { + if (modulekind === 4 && (node.flags & 2)) { writeLine(); write(exportFunctionForFile + "(\""); emitDeclarationName(node); @@ -28787,7 +29155,7 @@ var ts; scopeEmitEnd(); } write(")("); - if ((node.flags & 1) && !isES6ExportedDeclaration(node)) { + if ((node.flags & 2) && !isES6ExportedDeclaration(node)) { emit(node.name); write(" = "); } @@ -28797,7 +29165,7 @@ var ts; write(" = {}));"); emitEnd(node); if (!isES6ExportedDeclaration(node) && node.name.kind === 69 && node.parent === currentSourceFile) { - if (modulekind === 4 && (node.flags & 1)) { + if (modulekind === 4 && (node.flags & 2)) { writeLine(); write(exportFunctionForFile + "(\""); emitDeclarationName(node); @@ -28895,7 +29263,7 @@ var ts; } function emitExternalImportDeclaration(node) { if (ts.contains(externalImports, node)) { - var isExportedImport = node.kind === 221 && (node.flags & 1) !== 0; + var isExportedImport = node.kind === 221 && (node.flags & 2) !== 0; var namespaceDeclaration = getNamespaceDeclarationNode(node); if (modulekind !== 2) { emitLeadingComments(node); @@ -28961,7 +29329,7 @@ var ts; write("export "); write("var "); } - else if (!(node.flags & 1)) { + else if (!(node.flags & 2)) { write("var "); } } @@ -29049,8 +29417,8 @@ var ts; function emitExportOrImportSpecifierList(specifiers, shouldEmit) { ts.Debug.assert(modulekind === 5); var needsComma = false; - for (var _a = 0; _a < specifiers.length; _a++) { - var specifier = specifiers[_a]; + for (var _a = 0, specifiers_1 = specifiers; _a < specifiers_1.length; _a++) { + var specifier = specifiers_1[_a]; if (shouldEmit(specifier)) { if (needsComma) { write(", "); @@ -29184,8 +29552,8 @@ var ts; } writeLine(); var started = false; - for (var _a = 0; _a < externalImports.length; _a++) { - var importNode = externalImports[_a]; + for (var _a = 0, externalImports_1 = externalImports; _a < externalImports_1.length; _a++) { + var importNode = externalImports_1[_a]; var skipNode = importNode.kind === 228 || (importNode.kind === 222 && !importNode.importClause); if (skipNode) { @@ -29210,8 +29578,8 @@ var ts; } if (!exportedDeclarations && ts.isEmpty(exportSpecifiers)) { var hasExportDeclarationWithExportClause = false; - for (var _a = 0; _a < externalImports.length; _a++) { - var externalImport = externalImports[_a]; + for (var _a = 0, externalImports_2 = externalImports; _a < externalImports_2.length; _a++) { + var externalImport = externalImports_2[_a]; if (externalImport.kind === 228 && externalImport.exportClause) { hasExportDeclarationWithExportClause = true; break; @@ -29239,8 +29607,8 @@ var ts; } } } - for (var _d = 0; _d < externalImports.length; _d++) { - var externalImport = externalImports[_d]; + for (var _d = 0, externalImports_3 = externalImports; _d < externalImports_3.length; _d++) { + var externalImport = externalImports_3[_d]; if (externalImport.kind !== 228) { continue; } @@ -29284,7 +29652,7 @@ var ts; return exportStarFunction; } function writeExportedName(node) { - if (node.kind !== 69 && node.flags & 1024) { + if (node.kind !== 69 && node.flags & 512) { return; } if (started) { @@ -29337,7 +29705,7 @@ var ts; emit(local); } var flags = ts.getCombinedNodeFlags(local.kind === 69 ? local.parent : local); - if (flags & 1) { + if (flags & 2) { if (!exportedDeclarations) { exportedDeclarations = []; } @@ -29347,11 +29715,11 @@ var ts; write(";"); } if (hoistedFunctionDeclarations) { - for (var _a = 0; _a < hoistedFunctionDeclarations.length; _a++) { - var f = hoistedFunctionDeclarations[_a]; + for (var _a = 0, hoistedFunctionDeclarations_1 = hoistedFunctionDeclarations; _a < hoistedFunctionDeclarations_1.length; _a++) { + var f = hoistedFunctionDeclarations_1[_a]; writeLine(); emit(f); - if (f.flags & 1) { + if (f.flags & 2) { if (!exportedDeclarations) { exportedDeclarations = []; } @@ -29361,7 +29729,7 @@ var ts; } return exportedDeclarations; function visit(node) { - if (node.flags & 2) { + if (node.flags & 4) { return; } if (node.kind === 213) { @@ -29431,7 +29799,7 @@ var ts; if (checkIfSourceFileLevelDecl && !shouldHoistDeclarationInSystemJsModule(node)) { return false; } - return (ts.getCombinedNodeFlags(node) & 49152) === 0 || + return (ts.getCombinedNodeFlags(node) & 24576) === 0 || ts.getEnclosingBlockScopeContainer(node).kind === 248; } function isCurrentFileSystemExternalModule() { @@ -29466,8 +29834,8 @@ var ts; var parameterName = makeUniqueName(ts.forEach(group, getLocalNameForExternalImport) || ""); write("function (" + parameterName + ") {"); increaseIndent(); - for (var _a = 0; _a < group.length; _a++) { - var entry = group[_a]; + for (var _a = 0, group_1 = group; _a < group_1.length; _a++) { + var entry = group_1[_a]; var importVariableName = getLocalNameForExternalImport(entry) || ""; switch (entry.kind) { case 222: @@ -29601,8 +29969,8 @@ var ts; unaliasedModuleNames.push("\"" + amdDependency.path + "\""); } } - for (var _c = 0; _c < externalImports.length; _c++) { - var importNode = externalImports[_c]; + for (var _c = 0, externalImports_4 = externalImports; _c < externalImports_4.length; _c++) { + var importNode = externalImports_4[_c]; var externalModuleName = getExternalModuleNameText(importNode); var importAliasName = getLocalNameForExternalImport(importNode); if (includeNonAmdDependencies && importAliasName) { @@ -29855,7 +30223,7 @@ var ts; function emitSourceFileNode(node) { writeLine(); emitShebang(); - emitDetachedComments(node); + emitDetachedCommentsAndUpdateCommentsInfo(node); if (ts.isExternalModule(node) || compilerOptions.isolatedModules) { var emitModule = moduleEmitDelegates[modulekind] || moduleEmitDelegates[1]; emitModule(node); @@ -29878,7 +30246,7 @@ var ts; } function emitNodeConsideringCommentsOption(node, emitNodeConsideringSourcemap) { if (node) { - if (node.flags & 2) { + if (node.flags & 4) { return emitCommentsOnNotEmittedNode(node); } if (isSpecializedCommentHandling(node)) { @@ -30111,10 +30479,6 @@ var ts; } return leadingComments; } - function isPinnedComments(comment) { - return currentSourceFile.text.charCodeAt(comment.pos + 1) === 42 && - currentSourceFile.text.charCodeAt(comment.pos + 2) === 33; - } function isTripleSlashComment(comment) { if (currentSourceFile.text.charCodeAt(comment.pos + 1) === 47 && comment.pos + 2 < comment.end && @@ -30195,44 +30559,14 @@ var ts; ts.emitNewLineBeforeLeadingComments(currentSourceFile, writer, { pos: pos, end: pos }, leadingComments); ts.emitComments(currentSourceFile, writer, leadingComments, true, newLine, writeComment); } - function emitDetachedComments(node) { - var leadingComments; - if (compilerOptions.removeComments) { - if (node.pos === 0) { - leadingComments = ts.filter(ts.getLeadingCommentRanges(currentSourceFile.text, node.pos), isPinnedComments); + function emitDetachedCommentsAndUpdateCommentsInfo(node) { + var currentDetachedCommentInfo = ts.emitDetachedComments(currentSourceFile, writer, writeComment, node, newLine, compilerOptions.removeComments); + if (currentDetachedCommentInfo) { + if (detachedCommentsInfo) { + detachedCommentsInfo.push(currentDetachedCommentInfo); } - } - else { - leadingComments = ts.getLeadingCommentRanges(currentSourceFile.text, node.pos); - } - if (leadingComments) { - var detachedComments = []; - var lastComment; - ts.forEach(leadingComments, function (comment) { - if (lastComment) { - var lastCommentLine = ts.getLineOfLocalPosition(currentSourceFile, lastComment.end); - var commentLine = ts.getLineOfLocalPosition(currentSourceFile, comment.pos); - if (commentLine >= lastCommentLine + 2) { - return detachedComments; - } - } - detachedComments.push(comment); - lastComment = comment; - }); - if (detachedComments.length) { - var lastCommentLine = ts.getLineOfLocalPosition(currentSourceFile, ts.lastOrUndefined(detachedComments).end); - var nodeLine = ts.getLineOfLocalPosition(currentSourceFile, ts.skipTrivia(currentSourceFile.text, node.pos)); - if (nodeLine >= lastCommentLine + 2) { - ts.emitNewLineBeforeLeadingComments(currentSourceFile, writer, node, leadingComments); - ts.emitComments(currentSourceFile, writer, detachedComments, true, newLine, writeComment); - var currentDetachedCommentInfo = { nodePos: node.pos, detachedCommentEndPos: ts.lastOrUndefined(detachedComments).end }; - if (detachedCommentsInfo) { - detachedCommentsInfo.push(currentDetachedCommentInfo); - } - else { - detachedCommentsInfo = [currentDetachedCommentInfo]; - } - } + else { + detachedCommentsInfo = [currentDetachedCommentInfo]; } } } @@ -30535,7 +30869,7 @@ var ts; var resolveModuleNamesWorker = host.resolveModuleNames ? (function (moduleNames, containingFile) { return host.resolveModuleNames(moduleNames, containingFile); }) : (function (moduleNames, containingFile) { return ts.map(moduleNames, function (moduleName) { return resolveModuleName(moduleName, containingFile, options, host).resolvedModule; }); }); - var filesByName = ts.createFileMap(getCanonicalFileName); + var filesByName = ts.createFileMap(); var filesByNameIgnoreCase = host.useCaseSensitiveFileNames() ? ts.createFileMap(function (fileName) { return fileName.toLowerCase(); }) : undefined; if (oldProgram) { var oldOptions = oldProgram.getCompilerOptions(); @@ -30583,8 +30917,8 @@ var ts; if (!classifiableNames) { getTypeChecker(); classifiableNames = {}; - for (var _i = 0; _i < files.length; _i++) { - var sourceFile = files[_i]; + for (var _i = 0, files_3 = files; _i < files_3.length; _i++) { + var sourceFile = files_3[_i]; ts.copyMap(sourceFile.classifiableNames, classifiableNames); } } @@ -30600,7 +30934,7 @@ var ts; return false; } var newSourceFiles = []; - var normalizedAbsoluteFileNames = []; + var filePaths = []; var modifiedSourceFiles = []; for (var _i = 0, _a = oldProgram.getSourceFiles(); _i < _a.length; _i++) { var oldSourceFile = _a[_i]; @@ -30608,8 +30942,8 @@ var ts; if (!newSourceFile) { return false; } - var normalizedAbsolutePath = ts.getNormalizedAbsolutePath(newSourceFile.fileName, currentDirectory); - normalizedAbsoluteFileNames.push(normalizedAbsolutePath); + newSourceFile.path = oldSourceFile.path; + filePaths.push(newSourceFile.path); if (oldSourceFile !== newSourceFile) { if (oldSourceFile.hasNoDefaultLib !== newSourceFile.hasNoDefaultLib) { return false; @@ -30623,7 +30957,7 @@ var ts; } if (resolveModuleNamesWorker) { var moduleNames = ts.map(newSourceFile.imports, function (name) { return name.text; }); - var resolutions = resolveModuleNamesWorker(moduleNames, normalizedAbsolutePath); + var resolutions = resolveModuleNamesWorker(moduleNames, ts.getNormalizedAbsolutePath(newSourceFile.fileName, currentDirectory)); for (var i = 0; i < moduleNames.length; ++i) { var newResolution = resolutions[i]; var oldResolution = ts.getResolvedModule(oldSourceFile, moduleNames[i]); @@ -30646,12 +30980,12 @@ var ts; newSourceFiles.push(newSourceFile); } for (var i = 0, len = newSourceFiles.length; i < len; ++i) { - filesByName.set(normalizedAbsoluteFileNames[i], newSourceFiles[i]); + filesByName.set(filePaths[i], newSourceFiles[i]); } files = newSourceFiles; fileProcessingDiagnostics = oldProgram.getFileProcessingDiagnostics(); - for (var _b = 0; _b < modifiedSourceFiles.length; _b++) { - var modifiedFile = modifiedSourceFiles[_b]; + for (var _b = 0, modifiedSourceFiles_1 = modifiedSourceFiles; _b < modifiedSourceFiles_1.length; _b++) { + var modifiedFile = modifiedSourceFiles_1[_b]; fileProcessingDiagnostics.reattachFileDiagnostics(modifiedFile); } oldProgram.structureIsReused = true; @@ -30690,7 +31024,7 @@ var ts; return emitResult; } function getSourceFile(fileName) { - return filesByName.get(ts.getNormalizedAbsolutePath(fileName, currentDirectory)); + return filesByName.get(ts.toPath(fileName, currentDirectory, getCanonicalFileName)); } function getDiagnosticsHelper(sourceFile, getDiagnostics, cancellationToken) { if (sourceFile) { @@ -30799,7 +31133,7 @@ var ts; } break; case 218: - if (node.name.kind === 9 && (node.flags & 2 || ts.isDeclarationFile(file))) { + if (node.name.kind === 9 && (node.flags & 4 || ts.isDeclarationFile(file))) { ts.forEachChild(node.body, function (node) { collect(node, false); }); @@ -30816,7 +31150,7 @@ var ts; diagnostic = ts.Diagnostics.File_0_has_unsupported_extension_The_only_supported_extensions_are_1; diagnosticArgument = [fileName, "'" + ts.supportedExtensions.join("', '") + "'"]; } - else if (!findSourceFile(fileName, ts.getNormalizedAbsolutePath(fileName, currentDirectory), isDefaultLib, 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]; } @@ -30826,13 +31160,13 @@ var ts; } } else { - var nonTsFile = options.allowNonTsExtensions && findSourceFile(fileName, ts.getNormalizedAbsolutePath(fileName, currentDirectory), isDefaultLib, 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(ts.supportedExtensions, function (extension) { return findSourceFile(fileName + extension, ts.getNormalizedAbsolutePath(fileName + extension, currentDirectory), isDefaultLib, refFile, refPos, refEnd); })) { + else if (!ts.forEach(ts.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]; @@ -30874,6 +31208,7 @@ var ts; }); filesByName.set(normalizedAbsolutePath, file); if (file) { + file.path = normalizedAbsolutePath; if (host.useCaseSensitiveFileNames()) { var existingFile = filesByNameIgnoreCase.get(normalizedAbsolutePath); if (existingFile) { @@ -30918,11 +31253,7 @@ var ts; var resolution = resolutions[i]; ts.setResolvedModule(file, moduleNames[i], resolution); if (resolution && !options.noResolve) { - var absoluteImportPath = ts.isRootedDiskPath(resolution.resolvedFileName) - ? resolution.resolvedFileName - : ts.getNormalizedAbsolutePath(resolution.resolvedFileName, currentDirectory); - var relativePath = ts.getRelativePathToDirectoryOrUrl(currentDirectory, absoluteImportPath, currentDirectory, getCanonicalFileName, false); - var importedFile = findSourceFile(relativePath, absoluteImportPath, false, file, ts.skipTrivia(file.text, file.imports[i].pos), file.imports[i].end); + var importedFile = findSourceFile(resolution.resolvedFileName, ts.toPath(resolution.resolvedFileName, currentDirectory, getCanonicalFileName), false, file, ts.skipTrivia(file.text, file.imports[i].pos), file.imports[i].end); if (importedFile && resolution.isExternalLibraryImport) { if (!ts.isExternalModule(importedFile)) { var start_2 = ts.getTokenPosOfNode(file.imports[i], file); @@ -30973,8 +31304,8 @@ var ts; var allFilesBelongToPath = true; if (sourceFiles) { var absoluteRootDirectoryPath = host.getCanonicalFileName(ts.getNormalizedAbsolutePath(rootDirectory, currentDirectory)); - for (var _i = 0; _i < sourceFiles.length; _i++) { - var sourceFile = sourceFiles[_i]; + for (var _i = 0, sourceFiles_1 = sourceFiles; _i < sourceFiles_1.length; _i++) { + var sourceFile = sourceFiles_1[_i]; if (!ts.isDeclarationFile(sourceFile)) { var absoluteSourceFilePath = host.getCanonicalFileName(ts.getNormalizedAbsolutePath(sourceFile.fileName, currentDirectory)); if (absoluteSourceFilePath.indexOf(absoluteRootDirectoryPath) !== 0) { @@ -31231,6 +31562,12 @@ var ts; type: "boolean", description: ts.Diagnostics.Do_not_erase_const_enum_declarations_in_generated_code }, + { + name: "pretty", + paramType: ts.Diagnostics.KIND, + description: ts.Diagnostics.Stylize_errors_and_messages_using_color_and_context_experimental, + type: "boolean" + }, { name: "project", shortName: "p", @@ -31329,11 +31666,31 @@ var ts; description: ts.Diagnostics.Specifies_module_resolution_strategy_Colon_node_Node_js_or_classic_TypeScript_pre_1_6, error: ts.Diagnostics.Argument_for_moduleResolution_option_must_be_node_or_classic }, + { + 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 - }, + } ]; var optionNameMapCache; function getOptionNameMap() { @@ -31459,13 +31816,31 @@ var ts; ts.readConfigFile = readConfigFile; function parseConfigFileTextToJson(fileName, jsonText) { try { - return { config: /\S/.test(jsonText) ? JSON.parse(jsonText) : {} }; + var jsonTextWithoutComments = removeComments(jsonText); + return { config: /\S/.test(jsonTextWithoutComments) ? JSON.parse(jsonTextWithoutComments) : {} }; } catch (e) { return { error: ts.createCompilerDiagnostic(ts.Diagnostics.Failed_to_parse_file_0_Colon_1, fileName, e.message) }; } } ts.parseConfigFileTextToJson = parseConfigFileTextToJson; + 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) { var _a = convertCompilerOptionsFromJson(json["compilerOptions"], basePath), options = _a.options, errors = _a.errors; return { @@ -31554,6 +31929,13 @@ var ts; })(ts || (ts = {})); var ts; (function (ts) { + var reportDiagnostic = reportDiagnosticSimply; + function reportDiagnostics(diagnostics, host) { + for (var _i = 0, diagnostics_1 = diagnostics; _i < diagnostics_1.length; _i++) { + var diagnostic = diagnostics_1[_i]; + reportDiagnostic(diagnostic, host); + } + } function validateLocaleAndSetLanguage(locale, errors) { var matchResult = /^([a-z]+)([_\-]([a-z]+))?$/.exec(locale.toLowerCase()); if (!matchResult) { @@ -31612,20 +31994,84 @@ var ts; var diagnostic = ts.createCompilerDiagnostic.apply(undefined, arguments); return diagnostic.messageText; } - function reportDiagnostic(diagnostic) { + function reportDiagnosticSimply(diagnostic, host) { var output = ""; if (diagnostic.file) { - var loc = ts.getLineAndCharacterOfPosition(diagnostic.file, diagnostic.start); - output += diagnostic.file.fileName + "(" + (loc.line + 1) + "," + (loc.character + 1) + "): "; + var _a = ts.getLineAndCharacterOfPosition(diagnostic.file, diagnostic.start), line = _a.line, character = _a.character; + var relativeFileName = host + ? ts.convertToRelativePath(diagnostic.file.fileName, host.getCurrentDirectory(), function (fileName) { return host.getCanonicalFileName(fileName); }) + : diagnostic.file.fileName; + output += diagnostic.file.fileName + "(" + (line + 1) + "," + (character + 1) + "): "; } var category = ts.DiagnosticCategory[diagnostic.category].toLowerCase(); output += category + " TS" + diagnostic.code + ": " + ts.flattenDiagnosticMessageText(diagnostic.messageText, ts.sys.newLine) + ts.sys.newLine; ts.sys.write(output); } - function reportDiagnostics(diagnostics) { - for (var i = 0; i < diagnostics.length; i++) { - reportDiagnostic(diagnostics[i]); + var redForegroundEscapeSequence = "\u001b[91m"; + var yellowForegroundEscapeSequence = "\u001b[93m"; + var blueForegroundEscapeSequence = "\u001b[93m"; + var gutterStyleSequence = "\u001b[100;30m"; + var gutterSeparator = " "; + var resetEscapeSequence = "\u001b[0m"; + var elipsis = "..."; + var categoryFormatMap = (_a = {}, + _a[ts.DiagnosticCategory.Warning] = yellowForegroundEscapeSequence, + _a[ts.DiagnosticCategory.Error] = redForegroundEscapeSequence, + _a[ts.DiagnosticCategory.Message] = blueForegroundEscapeSequence, + _a + ); + function formatAndReset(text, formatStyle) { + return formatStyle + text + resetEscapeSequence; + } + function reportDiagnosticWithColorAndContext(diagnostic, host) { + var output = ""; + if (diagnostic.file) { + var start = diagnostic.start, length_3 = diagnostic.length, file = diagnostic.file; + var _a = ts.getLineAndCharacterOfPosition(file, start), firstLine = _a.line, firstLineChar = _a.character; + var _b = ts.getLineAndCharacterOfPosition(file, start + length_3), lastLine = _b.line, lastLineChar = _b.character; + var lastLineInFile = ts.getLineAndCharacterOfPosition(file, file.text.length).line; + var hasMoreThanFiveLines = (lastLine - firstLine) >= 4; + var gutterWidth = (lastLine + 1 + "").length; + if (hasMoreThanFiveLines) { + gutterWidth = Math.max(elipsis.length, gutterWidth); + } + output += ts.sys.newLine; + for (var i = firstLine; i <= lastLine; i++) { + if (hasMoreThanFiveLines && firstLine + 1 < i && i < lastLine - 1) { + output += formatAndReset(padLeft(elipsis, gutterWidth), gutterStyleSequence) + gutterSeparator + ts.sys.newLine; + i = lastLine - 1; + } + var lineStart = ts.getPositionOfLineAndCharacter(file, i, 0); + var lineEnd = i < lastLineInFile ? ts.getPositionOfLineAndCharacter(file, i + 1, 0) : file.text.length; + var lineContent = file.text.slice(lineStart, lineEnd); + lineContent = lineContent.replace(/\s+$/g, ""); + lineContent = lineContent.replace("\t", " "); + output += formatAndReset(padLeft(i + 1 + "", gutterWidth), gutterStyleSequence) + gutterSeparator; + output += lineContent + ts.sys.newLine; + output += formatAndReset(padLeft("", gutterWidth), gutterStyleSequence) + gutterSeparator; + output += redForegroundEscapeSequence; + if (i === firstLine) { + var lastCharForLine = i === lastLine ? lastLineChar : undefined; + output += lineContent.slice(0, firstLineChar).replace(/\S/g, " "); + output += lineContent.slice(firstLineChar, lastCharForLine).replace(/./g, "~"); + } + else if (i === lastLine) { + output += lineContent.slice(0, lastLineChar).replace(/./g, "~"); + } + else { + output += lineContent.replace(/./g, "~"); + } + output += resetEscapeSequence; + output += ts.sys.newLine; + } + output += ts.sys.newLine; + output += file.fileName + "(" + (firstLine + 1) + "," + (firstLineChar + 1) + "): "; } + var categoryColor = categoryFormatMap[diagnostic.category]; + var category = ts.DiagnosticCategory[diagnostic.category].toLowerCase(); + output += formatAndReset(category, categoryColor) + " TS" + diagnostic.code + ": " + ts.flattenDiagnosticMessageText(diagnostic.messageText, ts.sys.newLine); + output += ts.sys.newLine + ts.sys.newLine; + ts.sys.write(output); } function reportWatchDiagnostic(diagnostic) { var output = new Date().toLocaleTimeString() + " - "; @@ -31677,13 +32123,13 @@ var ts; var hostFileExists; if (commandLine.options.locale) { if (!isJSONSupported()) { - reportDiagnostic(ts.createCompilerDiagnostic(ts.Diagnostics.The_current_host_does_not_support_the_0_option, "--locale")); + reportDiagnostic(ts.createCompilerDiagnostic(ts.Diagnostics.The_current_host_does_not_support_the_0_option, "--locale"), undefined); return ts.sys.exit(ts.ExitStatus.DiagnosticsPresent_OutputsSkipped); } validateLocaleAndSetLanguage(commandLine.options.locale, commandLine.errors); } if (commandLine.errors.length > 0) { - reportDiagnostics(commandLine.errors); + reportDiagnostics(commandLine.errors, compilerHost); return ts.sys.exit(ts.ExitStatus.DiagnosticsPresent_OutputsSkipped); } if (commandLine.options.init) { @@ -31691,7 +32137,7 @@ var ts; return ts.sys.exit(ts.ExitStatus.Success); } if (commandLine.options.version) { - reportDiagnostic(ts.createCompilerDiagnostic(ts.Diagnostics.Version_0, ts.version)); + reportDiagnostic(ts.createCompilerDiagnostic(ts.Diagnostics.Version_0, ts.version), undefined); return ts.sys.exit(ts.ExitStatus.Success); } if (commandLine.options.help) { @@ -31701,12 +32147,12 @@ var ts; } if (commandLine.options.project) { if (!isJSONSupported()) { - reportDiagnostic(ts.createCompilerDiagnostic(ts.Diagnostics.The_current_host_does_not_support_the_0_option, "--project")); + reportDiagnostic(ts.createCompilerDiagnostic(ts.Diagnostics.The_current_host_does_not_support_the_0_option, "--project"), undefined); return ts.sys.exit(ts.ExitStatus.DiagnosticsPresent_OutputsSkipped); } configFileName = ts.normalizePath(ts.combinePaths(commandLine.options.project, "tsconfig.json")); if (commandLine.fileNames.length !== 0) { - reportDiagnostic(ts.createCompilerDiagnostic(ts.Diagnostics.Option_project_cannot_be_mixed_with_source_files_on_a_command_line)); + reportDiagnostic(ts.createCompilerDiagnostic(ts.Diagnostics.Option_project_cannot_be_mixed_with_source_files_on_a_command_line), undefined); return ts.sys.exit(ts.ExitStatus.DiagnosticsPresent_OutputsSkipped); } } @@ -31721,7 +32167,7 @@ var ts; } if (commandLine.options.watch && commandLine.options.hasOwnProperty("watch")) { if (!ts.sys.watchFile) { - reportDiagnostic(ts.createCompilerDiagnostic(ts.Diagnostics.The_current_host_does_not_support_the_0_option, "--watch")); + reportDiagnostic(ts.createCompilerDiagnostic(ts.Diagnostics.The_current_host_does_not_support_the_0_option, "--watch"), undefined); return ts.sys.exit(ts.ExitStatus.DiagnosticsPresent_OutputsSkipped); } if (configFileName) { @@ -31749,7 +32195,7 @@ var ts; var configObject = result.config; var configParseResult = ts.parseJsonConfigFileContent(configObject, ts.sys, ts.getDirectoryPath(configFileName)); if (configParseResult.errors.length > 0) { - reportDiagnostics(configParseResult.errors); + reportDiagnostics(configParseResult.errors, undefined); ts.sys.exit(ts.ExitStatus.DiagnosticsPresent_OutputsSkipped); return; } @@ -31772,6 +32218,9 @@ var ts; hostFileExists = compilerHost.fileExists; compilerHost.fileExists = cachedFileExists; } + if (compilerOptions.pretty) { + reportDiagnostic = reportDiagnosticWithColorAndContext; + } cachedExistingFiles = {}; var compileResult = compile(rootFileNames, compilerOptions, compilerHost); if (!compilerOptions.watch) { @@ -31906,14 +32355,14 @@ var ts; diagnostics = program.getSemanticDiagnostics(); } } - reportDiagnostics(diagnostics); + reportDiagnostics(diagnostics, compilerHost); if (compilerOptions.noEmit) { return diagnostics.length ? ts.ExitStatus.DiagnosticsPresent_OutputsSkipped : ts.ExitStatus.Success; } var emitOutput = program.emit(); - reportDiagnostics(emitOutput.diagnostics); + reportDiagnostics(emitOutput.diagnostics, compilerHost); if (emitOutput.emitSkipped) { return ts.ExitStatus.DiagnosticsPresent_OutputsSkipped; } @@ -31988,7 +32437,7 @@ var ts; var currentDirectory = ts.sys.getCurrentDirectory(); var file = ts.normalizePath(ts.combinePaths(currentDirectory, "tsconfig.json")); if (ts.sys.fileExists(file)) { - reportDiagnostic(ts.createCompilerDiagnostic(ts.Diagnostics.A_tsconfig_json_file_is_already_defined_at_Colon_0, file)); + reportDiagnostic(ts.createCompilerDiagnostic(ts.Diagnostics.A_tsconfig_json_file_is_already_defined_at_Colon_0, file), undefined); } else { var compilerOptions = ts.extend(options, ts.defaultInitCompilerOptions); @@ -32000,7 +32449,7 @@ var ts; configurations.files = fileNames; } ts.sys.writeFile(file, JSON.stringify(configurations, undefined, 4)); - reportDiagnostic(ts.createCompilerDiagnostic(ts.Diagnostics.Successfully_created_a_tsconfig_json_file)); + reportDiagnostic(ts.createCompilerDiagnostic(ts.Diagnostics.Successfully_created_a_tsconfig_json_file), undefined); } return; function serializeCompilerOptions(options) { @@ -32039,5 +32488,6 @@ var ts; return result; } } + var _a; })(ts || (ts = {})); ts.executeCommandLine(ts.sys.args); diff --git a/lib/tsserver.js b/lib/tsserver.js index ed62dd90686..2893dab82ef 100644 --- a/lib/tsserver.js +++ b/lib/tsserver.js @@ -49,40 +49,49 @@ var ts; })(ts || (ts = {})); var ts; (function (ts) { - function createFileMap(getCanonicalFileName) { + function createFileMap(keyMapper) { var files = {}; return { get: get, set: set, contains: contains, remove: remove, - clear: clear, - forEachValue: forEachValueInMap + forEachValue: forEachValueInMap, + clear: clear }; - function set(fileName, value) { - files[normalizeKey(fileName)] = value; - } - function get(fileName) { - return files[normalizeKey(fileName)]; - } - function contains(fileName) { - return hasProperty(files, normalizeKey(fileName)); - } - function remove(fileName) { - var key = normalizeKey(fileName); - delete files[key]; - } function forEachValueInMap(f) { - forEachValue(files, f); + for (var key in files) { + f(key, files[key]); + } } - function normalizeKey(key) { - return getCanonicalFileName(normalizeSlashes(key)); + function get(path) { + return files[toKey(path)]; + } + function set(path, value) { + files[toKey(path)] = value; + } + function contains(path) { + return hasProperty(files, toKey(path)); + } + function remove(path) { + var key = toKey(path); + delete files[key]; } function clear() { files = {}; } + function toKey(path) { + return keyMapper ? keyMapper(path) : path; + } } ts.createFileMap = createFileMap; + function toPath(fileName, basePath, getCanonicalFileName) { + var nonCanonicalizedPath = isRootedDiskPath(fileName) + ? normalizePath(fileName) + : getNormalizedAbsolutePath(fileName, basePath); + return getCanonicalFileName(nonCanonicalizedPath); + } + ts.toPath = toPath; function forEach(array, callback) { if (array) { for (var i = 0, len = array.length; i < len; i++) { @@ -97,8 +106,8 @@ var ts; ts.forEach = forEach; function contains(array, value) { if (array) { - for (var _i = 0; _i < array.length; _i++) { - var v = array[_i]; + for (var _i = 0, array_1 = array; _i < array_1.length; _i++) { + var v = array_1[_i]; if (v === value) { return true; } @@ -121,8 +130,8 @@ var ts; function countWhere(array, predicate) { var count = 0; if (array) { - for (var _i = 0; _i < array.length; _i++) { - var v = array[_i]; + for (var _i = 0, array_2 = array; _i < array_2.length; _i++) { + var v = array_2[_i]; if (predicate(v)) { count++; } @@ -135,8 +144,8 @@ var ts; var result; if (array) { result = []; - for (var _i = 0; _i < array.length; _i++) { - var item = array[_i]; + for (var _i = 0, array_3 = array; _i < array_3.length; _i++) { + var item = array_3[_i]; if (f(item)) { result.push(item); } @@ -149,8 +158,8 @@ var ts; var result; if (array) { result = []; - for (var _i = 0; _i < array.length; _i++) { - var v = array[_i]; + for (var _i = 0, array_4 = array; _i < array_4.length; _i++) { + var v = array_4[_i]; result.push(f(v)); } } @@ -169,8 +178,8 @@ var ts; var result; if (array) { result = []; - for (var _i = 0; _i < array.length; _i++) { - var item = array[_i]; + for (var _i = 0, array_5 = array; _i < array_5.length; _i++) { + var item = array_5[_i]; if (!contains(result, item)) { result.push(item); } @@ -181,8 +190,8 @@ var ts; ts.deduplicate = deduplicate; function sum(array, prop) { var result = 0; - for (var _i = 0; _i < array.length; _i++) { - var v = array[_i]; + for (var _i = 0, array_6 = array; _i < array_6.length; _i++) { + var v = array_6[_i]; result += v[prop]; } return result; @@ -190,8 +199,8 @@ var ts; ts.sum = sum; function addRange(to, from) { if (to && from) { - for (var _i = 0; _i < from.length; _i++) { - var v = from[_i]; + for (var _i = 0, from_1 = from; _i < from_1.length; _i++) { + var v = from_1[_i]; to.push(v); } } @@ -512,8 +521,8 @@ var ts; function getNormalizedParts(normalizedSlashedPath, rootLength) { var parts = normalizedSlashedPath.substr(rootLength).split(ts.directorySeparator); var normalized = []; - for (var _i = 0; _i < parts.length; _i++) { - var part = parts[_i]; + for (var _i = 0, parts_1 = parts; _i < parts_1.length; _i++) { + var part = parts_1[_i]; if (part !== ".") { if (part === ".." && normalized.length > 0 && lastOrUndefined(normalized) !== "..") { normalized.pop(); @@ -661,8 +670,8 @@ var ts; if (!fileName) { return false; } - for (var _i = 0; _i < ts.supportedExtensions.length; _i++) { - var extension = ts.supportedExtensions[_i]; + for (var _i = 0, supportedExtensions_1 = ts.supportedExtensions; _i < supportedExtensions_1.length; _i++) { + var extension = supportedExtensions_1[_i]; if (fileExtensionIs(fileName, extension)) { return true; } @@ -672,8 +681,8 @@ var ts; ts.isSupportedSourceFileName = isSupportedSourceFileName; var extensionsToRemove = [".d.ts", ".ts", ".js", ".tsx", ".jsx"]; function removeFileExtension(path) { - for (var _i = 0; _i < extensionsToRemove.length; _i++) { - var ext = extensionsToRemove[_i]; + for (var _i = 0, extensionsToRemove_1 = extensionsToRemove; _i < extensionsToRemove_1.length; _i++) { + var ext = extensionsToRemove_1[_i]; if (fileExtensionIs(path, ext)) { return path.substr(0, path.length - ext.length); } @@ -747,8 +756,8 @@ var ts; })(Debug = ts.Debug || (ts.Debug = {})); function copyListRemovingItem(item, list) { var copiedList = []; - for (var _i = 0; _i < list.length; _i++) { - var e = list[_i]; + for (var _i = 0, list_1 = list; _i < list_1.length; _i++) { + var e = list_1[_i]; if (e !== item) { copiedList.push(e); } @@ -834,16 +843,16 @@ var ts; function visitDirectory(path) { var folder = fso.GetFolder(path || "."); var files = getNames(folder.files); - for (var _i = 0; _i < files.length; _i++) { - var current = files[_i]; + for (var _i = 0, files_1 = files; _i < files_1.length; _i++) { + var current = files_1[_i]; var name_1 = ts.combinePaths(path, current); if ((!extension || ts.fileExtensionIs(name_1, extension)) && !ts.contains(exclude, getCanonicalPath(name_1))) { result.push(name_1); } } var subfolders = getNames(folder.subfolders); - for (var _a = 0; _a < subfolders.length; _a++) { - var current = subfolders[_a]; + for (var _a = 0, subfolders_1 = subfolders; _a < subfolders_1.length; _a++) { + var current = subfolders_1[_a]; var name_2 = ts.combinePaths(path, current); if (!ts.contains(exclude, getCanonicalPath(name_2))) { visitDirectory(name_2); @@ -894,6 +903,7 @@ var ts; var _fs = require("fs"); var _path = require("path"); var _os = require("os"); + var _tty = require("tty"); function createWatchedFileSet(interval, chunkSize) { if (interval === void 0) { interval = 2500; } if (chunkSize === void 0) { chunkSize = 30; } @@ -1006,8 +1016,8 @@ var ts; function visitDirectory(path) { var files = _fs.readdirSync(path || ".").sort(); var directories = []; - for (var _i = 0; _i < files.length; _i++) { - var current = files[_i]; + for (var _i = 0, files_2 = files; _i < files_2.length; _i++) { + var current = files_2[_i]; var name_3 = ts.combinePaths(path, current); if (!ts.contains(exclude, getCanonicalPath(name_3))) { var stat = _fs.statSync(name_3); @@ -1021,8 +1031,8 @@ var ts; } } } - for (var _a = 0; _a < directories.length; _a++) { - var current = directories[_a]; + for (var _a = 0, directories_1 = directories; _a < directories_1.length; _a++) { + var current = directories_1[_a]; visitDirectory(current); } } @@ -1032,14 +1042,7 @@ var ts; newLine: _os.EOL, useCaseSensitiveFileNames: useCaseSensitiveFileNames, write: function (s) { - var buffer = new Buffer(s, "utf8"); - var offset = 0; - var toWrite = buffer.length; - var written = 0; - while ((written = _fs.writeSync(1, buffer, offset, toWrite)) < toWrite) { - offset += written; - toWrite -= written; - } + process.stdout.write(s); }, readFile: readFile, writeFile: writeFile, @@ -1306,6 +1309,7 @@ var ts; await_expression_is_only_allowed_within_an_async_function: { code: 1308, category: ts.DiagnosticCategory.Error, key: "await_expression_is_only_allowed_within_an_async_function_1308", message: "'await' expression is only allowed within an async function." }, Async_functions_are_only_available_when_targeting_ECMAScript_6_and_higher: { code: 1311, category: ts.DiagnosticCategory.Error, key: "Async_functions_are_only_available_when_targeting_ECMAScript_6_and_higher_1311", message: "Async functions are only available when targeting ECMAScript 6 and higher." }, can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment: { code: 1312, category: ts.DiagnosticCategory.Error, key: "can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment_1312", message: "'=' can only be used in an object literal property inside a destructuring assignment." }, + The_body_of_an_if_statement_cannot_be_the_empty_statement: { code: 1313, category: ts.DiagnosticCategory.Error, key: "The_body_of_an_if_statement_cannot_be_the_empty_statement_1313", message: "The body of an 'if' statement cannot be the empty statement." }, Duplicate_identifier_0: { code: 2300, category: ts.DiagnosticCategory.Error, key: "Duplicate_identifier_0_2300", message: "Duplicate identifier '{0}'." }, Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor: { code: 2301, category: ts.DiagnosticCategory.Error, key: "Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor_2301", message: "Initializer of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor." }, Static_members_cannot_reference_class_type_parameters: { code: 2302, category: ts.DiagnosticCategory.Error, key: "Static_members_cannot_reference_class_type_parameters_2302", message: "Static members cannot reference class type parameters." }, @@ -1358,7 +1362,7 @@ var ts; Neither_type_0_nor_type_1_is_assignable_to_the_other: { code: 2352, category: ts.DiagnosticCategory.Error, key: "Neither_type_0_nor_type_1_is_assignable_to_the_other_2352", message: "Neither type '{0}' nor type '{1}' is assignable to the other." }, Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1: { code: 2353, category: ts.DiagnosticCategory.Error, key: "Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1_2353", message: "Object literal may only specify known properties, and '{0}' does not exist in type '{1}'." }, No_best_common_type_exists_among_return_expressions: { code: 2354, category: ts.DiagnosticCategory.Error, key: "No_best_common_type_exists_among_return_expressions_2354", message: "No best common type exists among return expressions." }, - A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value_or_consist_of_a_single_throw_statement: { code: 2355, category: ts.DiagnosticCategory.Error, key: "A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value_or_consist_of_a_single_th_2355", message: "A function whose declared type is neither 'void' nor 'any' must return a value or consist of a single 'throw' statement." }, + A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value: { code: 2355, category: ts.DiagnosticCategory.Error, key: "A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value_2355", message: "A function whose declared type is neither 'void' nor 'any' must return a value." }, An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type: { code: 2356, category: ts.DiagnosticCategory.Error, key: "An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type_2356", message: "An arithmetic operand must be of type 'any', 'number' or an enum type." }, The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_property_or_indexer: { code: 2357, category: ts.DiagnosticCategory.Error, key: "The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_property_or_indexer_2357", message: "The operand of an increment or decrement operator must be a variable, property or indexer." }, The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_parameter: { code: 2358, category: ts.DiagnosticCategory.Error, key: "The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_paramete_2358", message: "The left-hand side of an 'instanceof' expression must be of type 'any', an object type or a type parameter." }, @@ -1379,7 +1383,7 @@ var ts; Duplicate_number_index_signature: { code: 2375, category: ts.DiagnosticCategory.Error, key: "Duplicate_number_index_signature_2375", message: "Duplicate number index signature." }, A_super_call_must_be_the_first_statement_in_the_constructor_when_a_class_contains_initialized_properties_or_has_parameter_properties: { code: 2376, category: ts.DiagnosticCategory.Error, key: "A_super_call_must_be_the_first_statement_in_the_constructor_when_a_class_contains_initialized_proper_2376", message: "A 'super' call must be the first statement in the constructor when a class contains initialized properties or has parameter properties." }, Constructors_for_derived_classes_must_contain_a_super_call: { code: 2377, category: ts.DiagnosticCategory.Error, key: "Constructors_for_derived_classes_must_contain_a_super_call_2377", message: "Constructors for derived classes must contain a 'super' call." }, - A_get_accessor_must_return_a_value_or_consist_of_a_single_throw_statement: { code: 2378, category: ts.DiagnosticCategory.Error, key: "A_get_accessor_must_return_a_value_or_consist_of_a_single_throw_statement_2378", message: "A 'get' accessor must return a value or consist of a single 'throw' statement." }, + A_get_accessor_must_return_a_value: { code: 2378, category: ts.DiagnosticCategory.Error, key: "A_get_accessor_must_return_a_value_2378", message: "A 'get' accessor must return a value." }, Getter_and_setter_accessors_do_not_agree_in_visibility: { code: 2379, category: ts.DiagnosticCategory.Error, key: "Getter_and_setter_accessors_do_not_agree_in_visibility_2379", message: "Getter and setter accessors do not agree in visibility." }, get_and_set_accessor_must_have_the_same_type: { code: 2380, category: ts.DiagnosticCategory.Error, key: "get_and_set_accessor_must_have_the_same_type_2380", message: "'get' and 'set' accessor must have the same type." }, A_signature_with_an_implementation_cannot_use_a_string_literal_type: { code: 2381, category: ts.DiagnosticCategory.Error, key: "A_signature_with_an_implementation_cannot_use_a_string_literal_type_2381", message: "A signature with an implementation cannot use a string literal type." }, @@ -1669,8 +1673,6 @@ var ts; NEWLINE: { code: 6061, category: ts.DiagnosticCategory.Message, key: "NEWLINE_6061", message: "NEWLINE" }, Argument_for_newLine_option_must_be_CRLF_or_LF: { code: 6062, category: ts.DiagnosticCategory.Error, key: "Argument_for_newLine_option_must_be_CRLF_or_LF_6062", message: "Argument for '--newLine' option must be 'CRLF' or 'LF'." }, Argument_for_moduleResolution_option_must_be_node_or_classic: { code: 6063, category: ts.DiagnosticCategory.Error, key: "Argument_for_moduleResolution_option_must_be_node_or_classic_6063", message: "Argument for '--moduleResolution' option must be 'node' or 'classic'." }, - Specify_JSX_code_generation_Colon_preserve_or_react: { code: 6080, category: ts.DiagnosticCategory.Message, key: "Specify_JSX_code_generation_Colon_preserve_or_react_6080", message: "Specify JSX code generation: 'preserve' or 'react'" }, - Argument_for_jsx_must_be_preserve_or_react: { code: 6081, category: ts.DiagnosticCategory.Message, key: "Argument_for_jsx_must_be_preserve_or_react_6081", message: "Argument for '--jsx' must be 'preserve' or 'react'." }, Enables_experimental_support_for_ES7_decorators: { code: 6065, category: ts.DiagnosticCategory.Message, key: "Enables_experimental_support_for_ES7_decorators_6065", message: "Enables experimental support for ES7 decorators." }, Enables_experimental_support_for_emitting_type_metadata_for_decorators: { code: 6066, category: ts.DiagnosticCategory.Message, key: "Enables_experimental_support_for_emitting_type_metadata_for_decorators_6066", message: "Enables experimental support for emitting type metadata for decorators." }, Enables_experimental_support_for_ES7_async_functions: { code: 6068, category: ts.DiagnosticCategory.Message, key: "Enables_experimental_support_for_ES7_async_functions_6068", message: "Enables experimental support for ES7 async functions." }, @@ -1678,7 +1680,14 @@ var ts; Initializes_a_TypeScript_project_and_creates_a_tsconfig_json_file: { code: 6070, category: ts.DiagnosticCategory.Message, key: "Initializes_a_TypeScript_project_and_creates_a_tsconfig_json_file_6070", message: "Initializes a TypeScript project and creates a tsconfig.json file." }, Successfully_created_a_tsconfig_json_file: { code: 6071, category: ts.DiagnosticCategory.Message, key: "Successfully_created_a_tsconfig_json_file_6071", message: "Successfully created a tsconfig.json file." }, Suppress_excess_property_checks_for_object_literals: { code: 6072, category: ts.DiagnosticCategory.Message, key: "Suppress_excess_property_checks_for_object_literals_6072", message: "Suppress excess property checks for object literals." }, - Disallow_inconsistently_cased_references_to_the_same_file: { code: 6073, category: ts.DiagnosticCategory.Message, key: "Disallow_inconsistently_cased_references_to_the_same_file_6073", message: "Disallow inconsistently-cased references to the same file." }, + Stylize_errors_and_messages_using_color_and_context_experimental: { code: 6073, category: ts.DiagnosticCategory.Message, key: "Stylize_errors_and_messages_using_color_and_context_experimental_6073", message: "Stylize errors and messages using color and context. (experimental)" }, + Do_not_report_errors_on_unused_labels: { code: 6074, category: ts.DiagnosticCategory.Message, key: "Do_not_report_errors_on_unused_labels_6074", message: "Do not report errors on unused labels." }, + Report_error_when_not_all_code_paths_in_function_return_a_value: { code: 6075, category: ts.DiagnosticCategory.Message, key: "Report_error_when_not_all_code_paths_in_function_return_a_value_6075", message: "Report error when not all code paths in function return a value." }, + Report_errors_for_fallthrough_cases_in_switch_statement: { code: 6076, category: ts.DiagnosticCategory.Message, key: "Report_errors_for_fallthrough_cases_in_switch_statement_6076", message: "Report errors for fallthrough cases in switch statement." }, + Do_not_report_errors_on_unreachable_code: { code: 6077, category: ts.DiagnosticCategory.Message, key: "Do_not_report_errors_on_unreachable_code_6077", message: "Do not report errors on unreachable code." }, + Disallow_inconsistently_cased_references_to_the_same_file: { code: 6078, category: ts.DiagnosticCategory.Message, key: "Disallow_inconsistently_cased_references_to_the_same_file_6078", message: "Disallow inconsistently-cased references to the same file." }, + Specify_JSX_code_generation_Colon_preserve_or_react: { code: 6080, category: ts.DiagnosticCategory.Message, key: "Specify_JSX_code_generation_Colon_preserve_or_react_6080", message: "Specify JSX code generation: 'preserve' or 'react'" }, + Argument_for_jsx_must_be_preserve_or_react: { code: 6081, category: ts.DiagnosticCategory.Message, key: "Argument_for_jsx_must_be_preserve_or_react_6081", message: "Argument for '--jsx' must be 'preserve' or 'react'." }, 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." }, @@ -1696,6 +1705,10 @@ var ts; Function_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions: { code: 7024, category: ts.DiagnosticCategory.Error, key: "Function_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_ref_7024", message: "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." }, Generator_implicitly_has_type_0_because_it_does_not_yield_any_values_Consider_supplying_a_return_type: { code: 7025, category: ts.DiagnosticCategory.Error, key: "Generator_implicitly_has_type_0_because_it_does_not_yield_any_values_Consider_supplying_a_return_typ_7025", message: "Generator implicitly has type '{0}' because it does not yield any values. Consider supplying a return type." }, JSX_element_implicitly_has_type_any_because_no_interface_JSX_0_exists: { code: 7026, category: ts.DiagnosticCategory.Error, key: "JSX_element_implicitly_has_type_any_because_no_interface_JSX_0_exists_7026", message: "JSX element implicitly has type 'any' because no interface 'JSX.{0}' exists" }, + Unreachable_code_detected: { code: 7027, category: ts.DiagnosticCategory.Error, key: "Unreachable_code_detected_7027", message: "Unreachable code detected." }, + Unused_label: { code: 7028, category: ts.DiagnosticCategory.Error, key: "Unused_label_7028", message: "Unused label." }, + Fallthrough_case_in_switch: { code: 7029, category: ts.DiagnosticCategory.Error, key: "Fallthrough_case_in_switch_7029", message: "Fallthrough case in switch." }, + Not_all_code_paths_return_a_value: { code: 7030, category: ts.DiagnosticCategory.Error, key: "Not_all_code_paths_return_a_value_7030", message: "Not all code paths return a value." }, 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." }, @@ -3225,6 +3238,12 @@ var ts; type: "boolean", description: ts.Diagnostics.Do_not_erase_const_enum_declarations_in_generated_code }, + { + name: "pretty", + paramType: ts.Diagnostics.KIND, + description: ts.Diagnostics.Stylize_errors_and_messages_using_color_and_context_experimental, + type: "boolean" + }, { name: "project", shortName: "p", @@ -3323,11 +3342,31 @@ var ts; description: ts.Diagnostics.Specifies_module_resolution_strategy_Colon_node_Node_js_or_classic_TypeScript_pre_1_6, error: ts.Diagnostics.Argument_for_moduleResolution_option_must_be_node_or_classic }, + { + 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 - }, + } ]; var optionNameMapCache; function getOptionNameMap() { @@ -3453,13 +3492,31 @@ var ts; ts.readConfigFile = readConfigFile; function parseConfigFileTextToJson(fileName, jsonText) { try { - return { config: /\S/.test(jsonText) ? JSON.parse(jsonText) : {} }; + var jsonTextWithoutComments = removeComments(jsonText); + return { config: /\S/.test(jsonTextWithoutComments) ? JSON.parse(jsonTextWithoutComments) : {} }; } catch (e) { return { error: ts.createCompilerDiagnostic(ts.Diagnostics.Failed_to_parse_file_0_Colon_1, fileName, e.message) }; } } ts.parseConfigFileTextToJson = parseConfigFileTextToJson; + 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) { var _a = convertCompilerOptionsFromJson(json["compilerOptions"], basePath), options = _a.options, errors = _a.errors; return { @@ -3551,8 +3608,8 @@ var ts; function getDeclarationOfKind(symbol, kind) { var declarations = symbol.declarations; if (declarations) { - for (var _i = 0; _i < declarations.length; _i++) { - var declaration = declarations[_i]; + for (var _i = 0, declarations_1 = declarations; _i < declarations_1.length; _i++) { + var declaration = declarations_1[_i]; if (declaration.kind === kind) { return declaration; } @@ -3722,7 +3779,7 @@ var ts; } ts.makeIdentifierFromModuleName = makeIdentifierFromModuleName; function isBlockOrCatchScoped(declaration) { - return (getCombinedNodeFlags(declaration) & 49152) !== 0 || + return (getCombinedNodeFlags(declaration) & 24576) !== 0 || isCatchClauseVariableDeclaration(declaration); } ts.isBlockOrCatchScoped = isBlockOrCatchScoped; @@ -3823,7 +3880,7 @@ var ts; } ts.isExternalModule = isExternalModule; function isDeclarationFile(file) { - return (file.flags & 8192) !== 0; + return (file.flags & 4096) !== 0; } ts.isDeclarationFile = isDeclarationFile; function isConstEnumDeclaration(node) { @@ -3853,11 +3910,11 @@ var ts; } ts.getCombinedNodeFlags = getCombinedNodeFlags; function isConst(node) { - return !!(getCombinedNodeFlags(node) & 32768); + return !!(getCombinedNodeFlags(node) & 16384); } ts.isConst = isConst; function isLet(node) { - return !!(getCombinedNodeFlags(node) & 16384); + return !!(getCombinedNodeFlags(node) & 8192); } ts.isLet = isLet; function isPrologueDirective(node) { @@ -4036,27 +4093,28 @@ var ts; } ts.isClassLike = isClassLike; function isFunctionLike(node) { - if (node) { - switch (node.kind) { - case 144: - case 173: - case 213: - case 174: - case 143: - case 142: - case 145: - case 146: - case 147: - case 148: - case 149: - case 152: - case 153: - return true; - } - } - return false; + return node && isFunctionLikeKind(node.kind); } ts.isFunctionLike = isFunctionLike; + function isFunctionLikeKind(kind) { + switch (kind) { + case 144: + case 173: + case 213: + case 174: + case 143: + case 142: + case 145: + case 146: + case 147: + case 148: + case 149: + case 152: + case 153: + return true; + } + } + ts.isFunctionLikeKind = isFunctionLikeKind; function introducesArgumentsExoticObject(node) { switch (node.kind) { case 143: @@ -4520,9 +4578,18 @@ var ts; return !!node && (node.kind === 162 || node.kind === 161); } ts.isBindingPattern = isBindingPattern; + function isNodeDescendentOf(node, ancestor) { + while (node) { + if (node === ancestor) + return true; + node = node.parent; + } + return false; + } + ts.isNodeDescendentOf = isNodeDescendentOf; function isInAmbientContext(node) { while (node) { - if (node.flags & (2 | 8192)) { + if (node.flags & (4 | 4096)) { return true; } node = node.parent; @@ -4580,7 +4647,7 @@ var ts; case 207: case 204: case 206: - case 98: + case 208: case 209: case 193: case 198: @@ -4679,8 +4746,8 @@ var ts; ts.getInterfaceBaseTypeNodes = getInterfaceBaseTypeNodes; function getHeritageClause(clauses, kind) { if (clauses) { - for (var _i = 0; _i < clauses.length; _i++) { - var clause = clauses[_i]; + for (var _i = 0, clauses_1 = clauses; _i < clauses_1.length; _i++) { + var clause = clauses_1[_i]; if (clause.token === kind) { return clause; } @@ -4692,7 +4759,6 @@ var ts; function tryResolveScriptReference(host, sourceFile, reference) { if (!host.getCompilerOptions().noResolve) { var referenceFileName = ts.isRootedDiskPath(reference.fileName) ? reference.fileName : ts.combinePaths(ts.getDirectoryPath(sourceFile.fileName), reference.fileName); - referenceFileName = ts.getNormalizedAbsolutePath(referenceFileName, host.getCurrentDirectory()); return host.getSourceFile(referenceFileName); } } @@ -4750,7 +4816,7 @@ var ts; } ts.isTrivia = isTrivia; function isAsyncFunctionLike(node) { - return isFunctionLike(node) && (node.flags & 512) !== 0 && !isAccessor(node); + return isFunctionLike(node) && (node.flags & 256) !== 0 && !isAccessor(node); } ts.isAsyncFunctionLike = isAsyncFunctionLike; function hasDynamicName(declaration) { @@ -5108,7 +5174,7 @@ var ts; else { ts.forEach(declarations, function (member) { if ((member.kind === 145 || member.kind === 146) - && (member.flags & 128) === (accessor.flags & 128)) { + && (member.flags & 64) === (accessor.flags & 64)) { var memberName = getPropertyNameForPropertyNameNode(member.name); var accessorName = getPropertyNameForPropertyNameNode(accessor.name); if (memberName === accessorName) { @@ -5163,6 +5229,49 @@ var ts; }); } ts.emitComments = emitComments; + function emitDetachedComments(currentSourceFile, writer, writeComment, node, newLine, removeComments) { + var leadingComments; + var currentDetachedCommentInfo; + if (removeComments) { + if (node.pos === 0) { + leadingComments = ts.filter(ts.getLeadingCommentRanges(currentSourceFile.text, node.pos), isPinnedComment); + } + } + else { + leadingComments = ts.getLeadingCommentRanges(currentSourceFile.text, node.pos); + } + if (leadingComments) { + var detachedComments = []; + var lastComment; + for (var _i = 0, leadingComments_1 = leadingComments; _i < leadingComments_1.length; _i++) { + var comment = leadingComments_1[_i]; + if (lastComment) { + var lastCommentLine = getLineOfLocalPosition(currentSourceFile, lastComment.end); + var commentLine = getLineOfLocalPosition(currentSourceFile, comment.pos); + if (commentLine >= lastCommentLine + 2) { + break; + } + } + detachedComments.push(comment); + lastComment = comment; + } + if (detachedComments.length) { + var lastCommentLine = getLineOfLocalPosition(currentSourceFile, ts.lastOrUndefined(detachedComments).end); + var nodeLine = getLineOfLocalPosition(currentSourceFile, ts.skipTrivia(currentSourceFile.text, node.pos)); + if (nodeLine >= lastCommentLine + 2) { + emitNewLineBeforeLeadingComments(currentSourceFile, writer, node, leadingComments); + emitComments(currentSourceFile, writer, detachedComments, true, newLine, writeComment); + currentDetachedCommentInfo = { nodePos: node.pos, detachedCommentEndPos: ts.lastOrUndefined(detachedComments).end }; + } + } + } + return currentDetachedCommentInfo; + function isPinnedComment(comment) { + return currentSourceFile.text.charCodeAt(comment.pos + 1) === 42 && + currentSourceFile.text.charCodeAt(comment.pos + 2) === 33; + } + } + ts.emitDetachedComments = emitDetachedComments; function writeCommentRange(currentSourceFile, writer, comment, newLine) { if (currentSourceFile.text.charCodeAt(comment.pos + 1) === 42) { var firstCommentLineAndCharacter = ts.getLineAndCharacterOfPosition(currentSourceFile, comment.pos); @@ -5227,16 +5336,16 @@ var ts; ts.writeCommentRange = writeCommentRange; function modifierToFlag(token) { switch (token) { - case 113: return 128; - case 112: return 16; - case 111: return 64; - case 110: return 32; - case 115: return 256; - case 82: return 1; - case 122: return 2; - case 74: return 32768; - case 77: return 1024; - case 118: return 512; + case 113: return 64; + case 112: return 8; + case 111: return 32; + case 110: return 16; + case 115: return 128; + case 82: return 2; + case 122: return 4; + case 74: return 16384; + case 77: return 512; + case 118: return 256; } return 0; } @@ -5315,7 +5424,7 @@ var ts; } ts.isEmptyObjectLiteralOrArrayLiteral = isEmptyObjectLiteralOrArrayLiteral; function getLocalSymbolForExportDefault(symbol) { - return symbol && symbol.valueDeclaration && (symbol.valueDeclaration.flags & 1024) ? symbol.valueDeclaration.localSymbol : undefined; + return symbol && symbol.valueDeclaration && (symbol.valueDeclaration.flags & 512) ? symbol.valueDeclaration.localSymbol : undefined; } ts.getLocalSymbolForExportDefault = getLocalSymbolForExportDefault; function isJavaScript(fileName) { @@ -5379,6 +5488,12 @@ 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) { @@ -5551,8 +5666,8 @@ var ts; } function visitEachNode(cbNode, nodes) { if (nodes) { - for (var _i = 0; _i < nodes.length; _i++) { - var node = nodes[_i]; + for (var _i = 0, nodes_1 = nodes; _i < nodes_1.length; _i++) { + var node = nodes_1[_i]; var result = cbNode(node); if (result) { return result; @@ -6013,8 +6128,8 @@ var ts; function addJSDocComment(node) { var comments = ts.getLeadingCommentRangesOfNode(node, sourceFile); if (comments) { - for (var _i = 0; _i < comments.length; _i++) { - var comment = comments[_i]; + for (var _i = 0, comments_1 = comments; _i < comments_1.length; _i++) { + var comment = comments_1[_i]; var jsDocComment = JSDocParser.parseJSDocComment(node, comment.pos, comment.end - comment.pos); if (jsDocComment) { node.jsDocComment = jsDocComment; @@ -6045,7 +6160,7 @@ var ts; sourceFile.bindDiagnostics = []; sourceFile.languageVersion = languageVersion; sourceFile.fileName = ts.normalizePath(fileName); - sourceFile.flags = ts.fileExtensionIs(sourceFile.fileName, ".d.ts") ? 8192 : 0; + sourceFile.flags = ts.fileExtensionIs(sourceFile.fileName, ".d.ts") ? 4096 : 0; sourceFile.languageVariant = ts.isTsx(sourceFile.fileName) ? 1 : 0; return sourceFile; } @@ -6881,7 +6996,7 @@ var ts; if (node.kind === 8 && sourceText.charCodeAt(tokenPos) === 48 && ts.isOctalDigit(sourceText.charCodeAt(tokenPos + 1))) { - node.flags |= 65536; + node.flags |= 32768; } return node; } @@ -7450,7 +7565,7 @@ var ts; if (!arrowFunction) { return undefined; } - var isAsync = !!(arrowFunction.flags & 512); + var isAsync = !!(arrowFunction.flags & 256); var lastToken = token; arrowFunction.equalsGreaterThanToken = parseExpectedToken(34, false, ts.Diagnostics._0_expected, "=>"); arrowFunction.body = (lastToken === 34 || lastToken === 15) @@ -7542,7 +7657,7 @@ var ts; function parseParenthesizedArrowFunctionExpressionHead(allowAmbiguity) { var node = createNode(174); setModifiers(node, parseModifiersForArrowFunction()); - var isAsync = !!(node.flags & 512); + var isAsync = !!(node.flags & 256); fillSignature(54, false, isAsync, !allowAmbiguity, node); if (!node.parameters) { return undefined; @@ -8156,7 +8271,7 @@ var ts; var node = createNode(164); parseExpected(19); if (scanner.hasPrecedingLineBreak()) - node.flags |= 2048; + node.flags |= 1024; node.elements = parseDelimitedList(15, parseArgumentOrArrayLiteralElement); parseExpected(20); return finishNode(node); @@ -8211,7 +8326,7 @@ var ts; var node = createNode(165); parseExpected(15); if (scanner.hasPrecedingLineBreak()) { - node.flags |= 2048; + node.flags |= 1024; } node.properties = parseDelimitedList(12, parseObjectLiteralElement, true); parseExpected(16); @@ -8227,7 +8342,7 @@ var ts; parseExpected(87); node.asteriskToken = parseOptionalToken(37); var isGenerator = !!node.asteriskToken; - var isAsync = !!(node.flags & 512); + var isAsync = !!(node.flags & 256); node.name = isGenerator && isAsync ? doInYieldAndAwaitContext(parseOptionalIdentifier) : isGenerator ? doInYieldContext(parseOptionalIdentifier) : @@ -8765,10 +8880,10 @@ var ts; case 102: break; case 108: - node.flags |= 16384; + node.flags |= 8192; break; case 74: - node.flags |= 32768; + node.flags |= 16384; break; default: ts.Debug.fail(); @@ -8802,9 +8917,9 @@ var ts; setModifiers(node, modifiers); parseExpected(87); node.asteriskToken = parseOptionalToken(37); - node.name = node.flags & 1024 ? parseOptionalIdentifier() : parseIdentifier(); + node.name = node.flags & 512 ? parseOptionalIdentifier() : parseIdentifier(); var isGenerator = !!node.asteriskToken; - var isAsync = !!(node.flags & 512); + var isAsync = !!(node.flags & 256); fillSignature(54, isGenerator, isAsync, false, node); node.body = parseFunctionBlockOrSemicolon(isGenerator, isAsync, ts.Diagnostics.or_expected); return finishNode(node); @@ -8826,7 +8941,7 @@ var ts; method.name = name; method.questionToken = questionToken; var isGenerator = !!asteriskToken; - var isAsync = !!(method.flags & 512); + var isAsync = !!(method.flags & 256); fillSignature(54, isGenerator, isAsync, false, method); method.body = parseFunctionBlockOrSemicolon(isGenerator, isAsync, diagnosticMessage); return finishNode(method); @@ -8838,7 +8953,7 @@ var ts; property.name = name; property.questionToken = questionToken; property.type = parseTypeAnnotation(); - property.initializer = modifiers && modifiers.flags & 128 + property.initializer = modifiers && modifiers.flags & 64 ? allowInAnd(parseNonParameterInitializer) : doOutsideOfContext(2 | 1, parseNonParameterInitializer); parseSemicolon(); @@ -9128,13 +9243,13 @@ var ts; } function parseModuleOrNamespaceDeclaration(fullStart, decorators, modifiers, flags) { var node = createNode(218, fullStart); - var namespaceFlag = flags & 131072; + var namespaceFlag = flags & 65536; node.decorators = decorators; setModifiers(node, modifiers); node.flags |= flags; node.name = parseIdentifier(); node.body = parseOptional(21) - ? parseModuleOrNamespaceDeclaration(getNodePos(), undefined, undefined, 1 | namespaceFlag) + ? parseModuleOrNamespaceDeclaration(getNodePos(), undefined, undefined, 2 | namespaceFlag) : parseModuleBlock(); return finishNode(node); } @@ -9149,7 +9264,7 @@ var ts; function parseModuleDeclaration(fullStart, decorators, modifiers) { var flags = modifiers ? modifiers.flags : 0; if (parseOptional(126)) { - flags |= 131072; + flags |= 65536; } else { parseExpected(125); @@ -9363,7 +9478,7 @@ var ts; } function setExternalModuleIndicator(sourceFile) { sourceFile.externalModuleIndicator = ts.forEach(sourceFile.statements, function (node) { - return node.flags & 1 + return node.flags & 2 || node.kind === 221 && node.moduleReference.kind === 232 || node.kind === 222 || node.kind === 227 @@ -9937,8 +10052,8 @@ var ts; array._children = undefined; array.pos += delta; array.end += delta; - for (var _i = 0; _i < array.length; _i++) { - var node = array[_i]; + for (var _i = 0, array_7 = array; _i < array_7.length; _i++) { + var node = array_7[_i]; visitNode(node); } } @@ -10010,8 +10125,8 @@ var ts; array.intersectsChange = true; array._children = undefined; adjustIntersectingElement(array, changeStart, changeRangeOldEnd, changeRangeNewEnd, delta); - for (var _i = 0; _i < array.length; _i++) { - var node = array[_i]; + for (var _i = 0, array_8 = array; _i < array_8.length; _i++) { + var node = array_8[_i]; visitNode(node); } return; @@ -10164,6 +10279,13 @@ var ts; var ts; (function (ts) { ts.bindTime = 0; + function or(state1, state2) { + return (state1 | state2) & 2 + ? 2 + : (state1 & state2) & 8 + ? 8 + : 4; + } function getModuleInstanceState(node) { if (node.kind === 215 || node.kind === 216) { return 0; @@ -10171,7 +10293,7 @@ var ts; else if (ts.isConstEnumDeclaration(node)) { return 2; } - else if ((node.kind === 222 || node.kind === 221) && !(node.flags & 1)) { + else if ((node.kind === 222 || node.kind === 221) && !(node.flags & 2)) { return 0; } else if (node.kind === 219) { @@ -10198,28 +10320,52 @@ var ts; } } ts.getModuleInstanceState = getModuleInstanceState; - function bindSourceFile(file) { + var binder = createBinder(); + function bindSourceFile(file, options) { var start = new Date().getTime(); - bindSourceFileWorker(file); + binder(file, options); ts.bindTime += new Date().getTime() - start; } ts.bindSourceFile = bindSourceFile; - function bindSourceFileWorker(file) { + function createBinder() { + var file; + var options; var parent; var container; var blockScopeContainer; var lastContainer; var seenThisKeyword; - var inStrictMode = !!file.externalModuleIndicator; + var hasExplicitReturn; + var currentReachabilityState; + var labelStack; + var labelIndexMap; + var implicitLabels; + var inStrictMode; var symbolCount = 0; - var Symbol = ts.objectAllocator.getSymbolConstructor(); - var classifiableNames = {}; - if (!file.locals) { - bind(file); - file.symbolCount = symbolCount; - file.classifiableNames = classifiableNames; + var Symbol; + var classifiableNames; + function bindSourceFile(f, opts) { + file = f; + options = opts; + inStrictMode = !!file.externalModuleIndicator; + classifiableNames = {}; + Symbol = ts.objectAllocator.getSymbolConstructor(); + if (!file.locals) { + bind(file); + file.symbolCount = symbolCount; + file.classifiableNames = classifiableNames; + } + parent = undefined; + container = undefined; + blockScopeContainer = undefined; + lastContainer = undefined; + seenThisKeyword = false; + hasExplicitReturn = false; + labelStack = undefined; + labelIndexMap = undefined; + implicitLabels = undefined; } - return; + return bindSourceFile; function createSymbol(flags, name) { symbolCount++; return new Symbol(flags, name); @@ -10270,7 +10416,7 @@ var ts; return node.isExportEquals ? "export=" : "default"; case 213: case 214: - return node.flags & 1024 ? "default" : undefined; + return node.flags & 512 ? "default" : undefined; } } function getDisplayName(node) { @@ -10278,7 +10424,7 @@ var ts; } function declareSymbol(symbolTable, parent, node, includes, excludes) { ts.Debug.assert(!ts.hasDynamicName(node)); - var isDefaultExport = node.flags & 1024; + var isDefaultExport = node.flags & 512; var name = isDefaultExport && parent ? "default" : getDeclarationName(node); var symbol; if (name !== undefined) { @@ -10296,7 +10442,7 @@ var ts; ? ts.Diagnostics.Cannot_redeclare_block_scoped_variable_0 : ts.Diagnostics.Duplicate_identifier_0; ts.forEach(symbol.declarations, function (declaration) { - if (declaration.flags & 1024) { + if (declaration.flags & 512) { message = ts.Diagnostics.A_module_cannot_have_multiple_default_exports; } }); @@ -10315,7 +10461,7 @@ var ts; return symbol; } function declareModuleMember(node, symbolFlags, symbolExcludes) { - var hasExportModifier = ts.getCombinedNodeFlags(node) & 1; + var hasExportModifier = ts.getCombinedNodeFlags(node) & 2; if (symbolFlags & 8388608) { if (node.kind === 230 || (node.kind === 221 && hasExportModifier)) { return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); @@ -10325,7 +10471,7 @@ var ts; } } else { - if (hasExportModifier || container.flags & 262144) { + if (hasExportModifier || container.flags & 131072) { var exportKind = (symbolFlags & 107455 ? 1048576 : 0) | (symbolFlags & 793056 ? 2097152 : 0) | (symbolFlags & 1536 ? 4194304 : 0); @@ -10356,18 +10502,202 @@ var ts; blockScopeContainer = node; blockScopeContainer.locals = undefined; } - if (node.kind === 215) { + var savedReachabilityState; + var savedLabelStack; + var savedLabels; + var savedImplicitLabels; + var savedHasExplicitReturn; + var kind = node.kind; + var flags = node.flags; + flags &= ~1572864; + if (kind === 215) { seenThisKeyword = false; - ts.forEachChild(node, bind); - node.flags = seenThisKeyword ? node.flags | 524288 : node.flags & ~524288; } - else { - ts.forEachChild(node, bind); + var saveState = kind === 248 || kind === 219 || ts.isFunctionLikeKind(kind); + if (saveState) { + savedReachabilityState = currentReachabilityState; + savedLabelStack = labelStack; + savedLabels = labelIndexMap; + savedImplicitLabels = implicitLabels; + savedHasExplicitReturn = hasExplicitReturn; + currentReachabilityState = 2; + hasExplicitReturn = false; + labelStack = labelIndexMap = implicitLabels = undefined; + } + bindReachableStatement(node); + if (currentReachabilityState === 2 && ts.isFunctionLikeKind(kind) && ts.nodeIsPresent(node.body)) { + flags |= 524288; + if (hasExplicitReturn) { + flags |= 1048576; + } + } + if (kind === 215) { + flags = seenThisKeyword ? flags | 262144 : flags & ~262144; + } + node.flags = flags; + if (saveState) { + hasExplicitReturn = savedHasExplicitReturn; + currentReachabilityState = savedReachabilityState; + labelStack = savedLabelStack; + labelIndexMap = savedLabels; + implicitLabels = savedImplicitLabels; } container = saveContainer; parent = saveParent; blockScopeContainer = savedBlockScopeContainer; } + function bindReachableStatement(node) { + if (checkUnreachable(node)) { + ts.forEachChild(node, bind); + return; + } + switch (node.kind) { + case 198: + bindWhileStatement(node); + break; + case 197: + bindDoStatement(node); + break; + case 199: + bindForStatement(node); + break; + case 200: + case 201: + bindForInOrForOfStatement(node); + break; + case 196: + bindIfStatement(node); + break; + case 204: + case 208: + bindReturnOrThrow(node); + break; + case 203: + case 202: + bindBreakOrContinueStatement(node); + break; + case 209: + bindTryStatement(node); + break; + case 206: + bindSwitchStatement(node); + break; + case 220: + bindCaseBlock(node); + break; + case 207: + bindLabeledStatement(node); + break; + default: + ts.forEachChild(node, bind); + break; + } + } + function bindWhileStatement(n) { + var preWhileState = n.expression.kind === 84 ? 4 : currentReachabilityState; + var postWhileState = n.expression.kind === 99 ? 4 : currentReachabilityState; + bind(n.expression); + currentReachabilityState = preWhileState; + var postWhileLabel = pushImplicitLabel(); + bind(n.statement); + popImplicitLabel(postWhileLabel, postWhileState); + } + function bindDoStatement(n) { + var preDoState = currentReachabilityState; + var postDoLabel = pushImplicitLabel(); + bind(n.statement); + var postDoState = n.expression.kind === 99 ? 4 : preDoState; + popImplicitLabel(postDoLabel, postDoState); + bind(n.expression); + } + function bindForStatement(n) { + var preForState = currentReachabilityState; + var postForLabel = pushImplicitLabel(); + bind(n.initializer); + bind(n.condition); + bind(n.incrementor); + bind(n.statement); + var isInfiniteLoop = (!n.condition || n.condition.kind === 99); + var postForState = isInfiniteLoop ? 4 : preForState; + popImplicitLabel(postForLabel, postForState); + } + function bindForInOrForOfStatement(n) { + var preStatementState = currentReachabilityState; + var postStatementLabel = pushImplicitLabel(); + bind(n.initializer); + bind(n.expression); + bind(n.statement); + popImplicitLabel(postStatementLabel, preStatementState); + } + function bindIfStatement(n) { + var ifTrueState = n.expression.kind === 84 ? 4 : currentReachabilityState; + var ifFalseState = n.expression.kind === 99 ? 4 : currentReachabilityState; + currentReachabilityState = ifTrueState; + bind(n.expression); + bind(n.thenStatement); + if (n.elseStatement) { + var preElseState = currentReachabilityState; + currentReachabilityState = ifFalseState; + bind(n.elseStatement); + currentReachabilityState = or(currentReachabilityState, preElseState); + } + else { + currentReachabilityState = or(currentReachabilityState, ifFalseState); + } + } + function bindReturnOrThrow(n) { + bind(n.expression); + if (n.kind === 204) { + hasExplicitReturn = true; + } + currentReachabilityState = 4; + } + function bindBreakOrContinueStatement(n) { + bind(n.label); + var isValidJump = jumpToLabel(n.label, n.kind === 203 ? currentReachabilityState : 4); + if (isValidJump) { + currentReachabilityState = 4; + } + } + function bindTryStatement(n) { + var preTryState = currentReachabilityState; + bind(n.tryBlock); + var postTryState = currentReachabilityState; + currentReachabilityState = preTryState; + bind(n.catchClause); + var postCatchState = currentReachabilityState; + currentReachabilityState = preTryState; + bind(n.finallyBlock); + currentReachabilityState = or(postTryState, postCatchState); + } + function bindSwitchStatement(n) { + var preSwitchState = currentReachabilityState; + var postSwitchLabel = pushImplicitLabel(); + bind(n.expression); + bind(n.caseBlock); + var hasDefault = ts.forEach(n.caseBlock.clauses, function (c) { return c.kind === 242; }); + var postSwitchState = hasDefault && currentReachabilityState !== 2 ? 4 : preSwitchState; + popImplicitLabel(postSwitchLabel, postSwitchState); + } + function bindCaseBlock(n) { + var startState = currentReachabilityState; + for (var _i = 0, _a = n.clauses; _i < _a.length; _i++) { + var clause = _a[_i]; + currentReachabilityState = startState; + bind(clause); + if (clause.statements.length && currentReachabilityState === 2 && options.noFallthroughCasesInSwitch) { + errorOnFirstToken(clause, ts.Diagnostics.Fallthrough_case_in_switch); + } + } + } + function bindLabeledStatement(n) { + bind(n.label); + var ok = pushNamedLabel(n.label); + bind(n.statement); + if (ok) { + popNamedLabel(n.label, currentReachabilityState); + } + } function getContainerFlags(node) { switch (node.kind) { case 186: @@ -10447,7 +10777,7 @@ var ts; } } function declareClassMember(node, symbolFlags, symbolExcludes) { - return node.flags & 128 + return node.flags & 64 ? declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes) : declareSymbol(container.symbol.members, container.symbol, node, symbolFlags, symbolExcludes); } @@ -10456,15 +10786,6 @@ var ts; ? declareModuleMember(node, symbolFlags, symbolExcludes) : declareSymbol(file.locals, undefined, node, symbolFlags, symbolExcludes); } - function isAmbientContext(node) { - while (node) { - if (node.flags & 2) { - return true; - } - node = node.parent; - } - return false; - } function hasExportDeclarations(node) { var body = node.kind === 248 ? node : node.body; if (body.kind === 248 || body.kind === 219) { @@ -10478,11 +10799,11 @@ var ts; return false; } function setExportContextFlag(node) { - if (isAmbientContext(node) && !hasExportDeclarations(node)) { - node.flags |= 262144; + if (ts.isInAmbientContext(node) && !hasExportDeclarations(node)) { + node.flags |= 131072; } else { - node.flags &= ~262144; + node.flags &= ~131072; } } function bindModuleDeclaration(node) { @@ -10633,7 +10954,7 @@ var ts; } } function checkStrictModeNumericLiteral(node) { - if (inStrictMode && node.flags & 65536) { + if (inStrictMode && node.flags & 32768) { file.bindDiagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.Octal_literals_are_not_allowed_in_strict_mode)); } } @@ -10651,10 +10972,10 @@ var ts; } function checkStrictModeWithStatement(node) { if (inStrictMode) { - grammarErrorOnFirstToken(node, ts.Diagnostics.with_statements_are_not_allowed_in_strict_mode); + errorOnFirstToken(node, ts.Diagnostics.with_statements_are_not_allowed_in_strict_mode); } } - function grammarErrorOnFirstToken(node, message, arg0, arg1, arg2) { + function errorOnFirstToken(node, message, arg0, arg1, arg2) { var span = ts.getSpanOfTokenAtPosition(file, node.pos); file.bindDiagnostics.push(ts.createFileDiagnostic(file, span.start, span.length, message, arg0, arg1, arg2)); } @@ -10662,6 +10983,9 @@ var ts; return "__" + ts.indexOf(node.parent.parameters, node); } function bind(node) { + if (!node) { + return; + } node.parent = parent; var savedInStrictMode = inStrictMode; if (!savedInStrictMode) { @@ -10689,8 +11013,8 @@ var ts; } } function updateStrictModeStatementList(statements) { - for (var _i = 0; _i < statements.length; _i++) { - var statement = statements[_i]; + for (var _i = 0, statements_1 = statements; _i < statements_1.length; _i++) { + var statement = statements_1[_i]; if (!ts.isPrologueDirective(statement)) { return; } @@ -10877,7 +11201,7 @@ var ts; else { declareSymbolAndAddToSymbolTable(node, 1, 107455); } - if (node.flags & 112 && + if (node.flags & 56 && node.parent.kind === 144 && ts.isClassLike(node.parent.parent)) { var classDeclaration = node.parent.parent; @@ -10889,6 +11213,95 @@ var ts; ? bindAnonymousDeclaration(node, symbolFlags, "__computed") : declareSymbolAndAddToSymbolTable(node, symbolFlags, symbolExcludes); } + function pushNamedLabel(name) { + initializeReachabilityStateIfNecessary(); + if (ts.hasProperty(labelIndexMap, name.text)) { + return false; + } + labelIndexMap[name.text] = labelStack.push(1) - 1; + return true; + } + function pushImplicitLabel() { + initializeReachabilityStateIfNecessary(); + var index = labelStack.push(1) - 1; + implicitLabels.push(index); + return index; + } + function popNamedLabel(label, outerState) { + var index = labelIndexMap[label.text]; + ts.Debug.assert(index !== undefined); + ts.Debug.assert(labelStack.length == index + 1); + labelIndexMap[label.text] = undefined; + setCurrentStateAtLabel(labelStack.pop(), outerState, label); + } + function popImplicitLabel(implicitLabelIndex, outerState) { + if (labelStack.length !== implicitLabelIndex + 1) { + ts.Debug.assert(false, "Label stack: " + labelStack.length + ", index:" + implicitLabelIndex); + } + var i = implicitLabels.pop(); + if (implicitLabelIndex !== i) { + ts.Debug.assert(false, "i: " + i + ", index: " + implicitLabelIndex); + } + setCurrentStateAtLabel(labelStack.pop(), outerState, undefined); + } + function setCurrentStateAtLabel(innerMergedState, outerState, label) { + if (innerMergedState === 1) { + if (label && !options.allowUnusedLabels) { + file.bindDiagnostics.push(ts.createDiagnosticForNode(label, ts.Diagnostics.Unused_label)); + } + currentReachabilityState = outerState; + } + else { + currentReachabilityState = or(innerMergedState, outerState); + } + } + function jumpToLabel(label, outerState) { + initializeReachabilityStateIfNecessary(); + var index = label ? labelIndexMap[label.text] : ts.lastOrUndefined(implicitLabels); + if (index === undefined) { + return false; + } + var stateAtLabel = labelStack[index]; + labelStack[index] = stateAtLabel === 1 ? outerState : or(stateAtLabel, outerState); + return true; + } + function checkUnreachable(node) { + switch (currentReachabilityState) { + case 4: + var reportError = ts.isStatement(node) || + node.kind === 214 || + (node.kind === 218 && shouldReportErrorOnModuleDeclaration(node)) || + (node.kind === 217 && (!ts.isConstEnumDeclaration(node) || options.preserveConstEnums)); + if (reportError) { + currentReachabilityState = 8; + var reportUnreachableCode = !options.allowUnreachableCode && + !ts.isInAmbientContext(node) && + (node.kind !== 193 || + ts.getCombinedNodeFlags(node.declarationList) & 24576 || + ts.forEach(node.declarationList.declarations, function (d) { return d.initializer; })); + if (reportUnreachableCode) { + errorOnFirstToken(node, ts.Diagnostics.Unreachable_code_detected); + } + } + case 8: + return true; + default: + return false; + } + function shouldReportErrorOnModuleDeclaration(node) { + var instanceState = getModuleInstanceState(node); + return instanceState === 1 || (instanceState === 2 && options.preserveConstEnums); + } + } + function initializeReachabilityStateIfNecessary() { + if (labelIndexMap) { + return; + } + currentReachabilityState = 2; + labelIndexMap = {}; + labelStack = []; + implicitLabels = []; + } } })(ts || (ts = {})); var ts; @@ -11014,6 +11427,7 @@ var ts; var getInstantiatedGlobalPromiseLikeType; var getGlobalPromiseConstructorLikeType; var getGlobalThenableType; + var jsxElementClassType; var tupleTypes = {}; var unionTypes = {}; var intersectionTypes = {}; @@ -11262,7 +11676,7 @@ var ts; } var initializerOfNonStaticProperty = current.parent && current.parent.kind === 141 && - (current.parent.flags & 128) === 0 && + (current.parent.flags & 64) === 0 && current.parent.initializer === current; if (initializerOfNonStaticProperty) { return true; @@ -11321,7 +11735,7 @@ var ts; break; case 141: case 140: - if (ts.isClassLike(location.parent) && !(location.flags & 128)) { + if (ts.isClassLike(location.parent) && !(location.flags & 64)) { var ctor = findConstructorDeclaration(location.parent); if (ctor && ctor.locals) { if (getSymbol(ctor.locals, name, meaning & 107455)) { @@ -11334,7 +11748,7 @@ var ts; case 186: case 215: if (result = getSymbol(getSymbolOfNode(location).members, name, meaning & 793056)) { - if (lastLocation && lastLocation.flags & 128) { + if (lastLocation && lastLocation.flags & 64) { error(errorLocation, ts.Diagnostics.Static_members_cannot_reference_class_type_parameters); return undefined; } @@ -11768,8 +12182,8 @@ var ts; } function findConstructorDeclaration(node) { var members = node.members; - for (var _i = 0; _i < members.length; _i++) { - var member = members[_i]; + for (var _i = 0, members_1 = members; _i < members_1.length; _i++) { + var member = members_1[_i]; if (member.kind === 144 && ts.nodeIsPresent(member.body)) { return member; } @@ -11975,7 +12389,7 @@ var ts; if (!isDeclarationVisible(declaration)) { var anyImportSyntax = getAnyImportSyntax(declaration); if (anyImportSyntax && - !(anyImportSyntax.flags & 1) && + !(anyImportSyntax.flags & 2) && isDeclarationVisible(anyImportSyntax.parent)) { getNodeLinks(declaration).isVisible = true; if (aliasesToMakeVisible) { @@ -12105,8 +12519,8 @@ var ts; walkSymbol(getParentOfSymbol(accessibleSymbolChain ? accessibleSymbolChain[0] : symbol), getQualifiedLeftMeaning(meaning)); } if (accessibleSymbolChain) { - for (var _i = 0; _i < accessibleSymbolChain.length; _i++) { - var accessibleSymbol = accessibleSymbolChain[_i]; + for (var _i = 0, accessibleSymbolChain_1 = accessibleSymbolChain; _i < accessibleSymbolChain_1.length; _i++) { + var accessibleSymbol = accessibleSymbolChain_1[_i]; appendParentTypeArgumentsAndSymbolName(accessibleSymbol); } } @@ -12272,7 +12686,7 @@ var ts; } function shouldWriteTypeOfFunctionSymbol() { var isStaticMethodSymbol = !!(symbol.flags & 8192 && - ts.forEach(symbol.declarations, function (declaration) { return declaration.flags & 128; })); + ts.forEach(symbol.declarations, function (declaration) { return declaration.flags & 64; })); var isNonLocalFunctionSymbol = !!(symbol.flags & 16) && (symbol.parent || ts.forEach(symbol.declarations, function (declaration) { @@ -12378,8 +12792,8 @@ var ts; var t = getTypeOfSymbol(p); if (p.flags & (16 | 8192) && !getPropertiesOfObjectType(t).length) { var signatures = getSignaturesOfType(t, 0); - for (var _f = 0; _f < signatures.length; _f++) { - var signature = signatures[_f]; + for (var _f = 0, signatures_1 = signatures; _f < signatures_1.length; _f++) { + var signature = signatures_1[_f]; buildSymbolDisplay(p, writer); if (p.flags & 536870912) { writePunctuation(writer, 53); @@ -12582,7 +12996,7 @@ var ts; case 217: case 221: var parent_4 = getDeclarationContainer(node); - if (!(ts.getCombinedNodeFlags(node) & 1) && + if (!(ts.getCombinedNodeFlags(node) & 2) && !(node.kind !== 221 && parent_4.kind !== 248 && ts.isInAmbientContext(parent_4))) { return isGlobalSourceFile(parent_4); } @@ -12593,7 +13007,7 @@ var ts; case 146: case 143: case 142: - if (node.flags & (32 | 64)) { + if (node.flags & (16 | 32)) { return false; } case 144: @@ -13022,8 +13436,8 @@ var ts; } } function appendTypeParameters(typeParameters, declarations) { - for (var _i = 0; _i < declarations.length; _i++) { - var declaration = declarations[_i]; + for (var _i = 0, declarations_2 = declarations; _i < declarations_2.length; _i++) { + var declaration = declarations_2[_i]; var tp = getDeclaredTypeOfTypeParameter(getSymbolOfNode(declaration)); if (!typeParameters) { typeParameters = [tp]; @@ -13204,13 +13618,13 @@ var ts; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; if (declaration.kind === 215) { - if (declaration.flags & 524288) { + if (declaration.flags & 262144) { return false; } var baseTypeNodes = ts.getInterfaceBaseTypeNodes(declaration); if (baseTypeNodes) { - for (var _b = 0; _b < baseTypeNodes.length; _b++) { - var node = baseTypeNodes[_b]; + for (var _b = 0, baseTypeNodes_1 = baseTypeNodes; _b < baseTypeNodes_1.length; _b++) { + var node = baseTypeNodes_1[_b]; if (ts.isSupportedExpressionWithTypeArguments(node)) { var baseSymbol = resolveEntityName(node.expression, 793056, true); if (!baseSymbol || !(baseSymbol.flags & 64) || getDeclaredTypeOfClassOrInterface(baseSymbol).thisType) { @@ -13378,23 +13792,23 @@ var ts; } function createSymbolTable(symbols) { var result = {}; - for (var _i = 0; _i < symbols.length; _i++) { - var symbol = symbols[_i]; + for (var _i = 0, symbols_1 = symbols; _i < symbols_1.length; _i++) { + var symbol = symbols_1[_i]; result[symbol.name] = symbol; } return result; } function createInstantiatedSymbolTable(symbols, mapper, mappingThisOnly) { var result = {}; - for (var _i = 0; _i < symbols.length; _i++) { - var symbol = symbols[_i]; + for (var _i = 0, symbols_2 = symbols; _i < symbols_2.length; _i++) { + var symbol = symbols_2[_i]; result[symbol.name] = mappingThisOnly && isIndependentMember(symbol) ? symbol : instantiateSymbol(symbol, mapper); } return result; } function addInheritedMembers(symbols, baseSymbols) { - for (var _i = 0; _i < baseSymbols.length; _i++) { - var s = baseSymbols[_i]; + for (var _i = 0, baseSymbols_1 = baseSymbols; _i < baseSymbols_1.length; _i++) { + var s = baseSymbols_1[_i]; if (!ts.hasProperty(symbols, s.name)) { symbols[s.name] = s; } @@ -13402,8 +13816,8 @@ var ts; } function addInheritedSignatures(signatures, baseSignatures) { if (baseSignatures) { - for (var _i = 0; _i < baseSignatures.length; _i++) { - var signature = baseSignatures[_i]; + for (var _i = 0, baseSignatures_1 = baseSignatures; _i < baseSignatures_1.length; _i++) { + var signature = baseSignatures_1[_i]; signatures.push(signature); } } @@ -13446,8 +13860,8 @@ var ts; members = createSymbolTable(source.declaredProperties); } var thisArgument = ts.lastOrUndefined(typeArguments); - for (var _i = 0; _i < baseTypes.length; _i++) { - var baseType = baseTypes[_i]; + for (var _i = 0, baseTypes_1 = baseTypes; _i < baseTypes_1.length; _i++) { + var baseType = baseTypes_1[_i]; var instantiatedBaseType = thisArgument ? getTypeWithThisArgument(instantiateType(baseType, mapper), thisArgument) : baseType; addInheritedMembers(members, getPropertiesOfObjectType(instantiatedBaseType)); callSignatures = ts.concatenate(callSignatures, getSignaturesOfType(instantiatedBaseType, 0)); @@ -13493,8 +13907,8 @@ var ts; var typeArguments = ts.map(baseTypeNode.typeArguments, getTypeFromTypeNode); var typeArgCount = typeArguments ? typeArguments.length : 0; var result = []; - for (var _i = 0; _i < baseSignatures.length; _i++) { - var baseSig = baseSignatures[_i]; + for (var _i = 0, baseSignatures_2 = baseSignatures; _i < baseSignatures_2.length; _i++) { + var baseSig = baseSignatures_2[_i]; var typeParamCount = baseSig.typeParameters ? baseSig.typeParameters.length : 0; if (typeParamCount === typeArgCount) { var sig = typeParamCount ? getSignatureInstantiation(baseSig, typeArguments) : cloneSignature(baseSig); @@ -13522,8 +13936,8 @@ var ts; setObjectTypeMembers(type, members, arrayType.callSignatures, arrayType.constructSignatures, arrayType.stringIndexType, arrayType.numberIndexType); } function findMatchingSignature(signatureList, signature, partialMatch, ignoreReturnTypes) { - for (var _i = 0; _i < signatureList.length; _i++) { - var s = signatureList[_i]; + for (var _i = 0, signatureList_1 = signatureList; _i < signatureList_1.length; _i++) { + var s = signatureList_1[_i]; if (compareSignatures(s, signature, partialMatch, ignoreReturnTypes, compareTypes)) { return s; } @@ -13577,8 +13991,8 @@ var ts; } function getUnionIndexType(types, kind) { var indexTypes = []; - for (var _i = 0; _i < types.length; _i++) { - var type = types[_i]; + for (var _i = 0, types_1 = types; _i < types_1.length; _i++) { + var type = types_1[_i]; var indexType = getIndexTypeOfType(type, kind); if (!indexType) { return undefined; @@ -13742,12 +14156,12 @@ var ts; function createUnionOrIntersectionProperty(containingType, name) { var types = containingType.types; var props; - for (var _i = 0; _i < types.length; _i++) { - var current = types[_i]; + for (var _i = 0, types_2 = types; _i < types_2.length; _i++) { + var current = types_2[_i]; var type = getApparentType(current); if (type !== unknownType) { var prop = getPropertyOfType(type, name); - if (prop && !(getDeclarationFlagsFromSymbol(prop) & (32 | 64))) { + if (prop && !(getDeclarationFlagsFromSymbol(prop) & (16 | 32))) { if (!props) { props = [prop]; } @@ -13768,8 +14182,8 @@ var ts; } var propTypes = []; var declarations = []; - for (var _a = 0; _a < props.length; _a++) { - var prop = props[_a]; + for (var _a = 0, props_1 = props; _a < props_1.length; _a++) { + var prop = props_1[_a]; if (prop.declarations) { ts.addRange(declarations, prop.declarations); } @@ -14102,8 +14516,8 @@ var ts; } function getPropagatingFlagsOfTypes(types) { var result = 0; - for (var _i = 0; _i < types.length; _i++) { - var type = types[_i]; + for (var _i = 0, types_3 = types; _i < types_3.length; _i++) { + var type = types_3[_i]; result |= type.flags; } return result & 14680064; @@ -14224,8 +14638,8 @@ var ts; function getTypeOfGlobalSymbol(symbol, arity) { function getTypeDeclaration(symbol) { var declarations = symbol.declarations; - for (var _i = 0; _i < declarations.length; _i++) { - var declaration = declarations[_i]; + for (var _i = 0, declarations_3 = declarations; _i < declarations_3.length; _i++) { + var declaration = declarations_3[_i]; switch (declaration.kind) { case 214: case 215: @@ -14323,8 +14737,8 @@ var ts; } } function addTypesToSet(typeSet, types, typeSetKind) { - for (var _i = 0; _i < types.length; _i++) { - var type = types[_i]; + for (var _i = 0, types_4 = types; _i < types_4.length; _i++) { + var type = types_4[_i]; addTypeToSet(typeSet, type, typeSetKind); } } @@ -14346,8 +14760,8 @@ var ts; } } function containsTypeAny(types) { - for (var _i = 0; _i < types.length; _i++) { - var type = types[_i]; + for (var _i = 0, types_5 = types; _i < types_5.length; _i++) { + var type = types_5[_i]; if (isTypeAny(type)) { return true; } @@ -14450,7 +14864,8 @@ var ts; var container = ts.getThisContainer(node, false); var parent = container && container.parent; if (parent && (ts.isClassLike(parent) || parent.kind === 215)) { - if (!(container.flags & 128)) { + if (!(container.flags & 64) && + (container.kind !== 144 || ts.isNodeDescendentOf(node, container.body))) { return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(parent)).thisType; } } @@ -14515,8 +14930,8 @@ var ts; function instantiateList(items, mapper, instantiator) { if (items && items.length) { var result = []; - for (var _i = 0; _i < items.length; _i++) { - var v = items[_i]; + for (var _i = 0, items_1 = items; _i < items_1.length; _i++) { + var v = items_1[_i]; result.push(instantiator(v, mapper)); } return result; @@ -14555,8 +14970,8 @@ var ts; case 2: return createBinaryTypeEraser(sources[0], sources[1]); } return function (t) { - for (var _i = 0; _i < sources.length; _i++) { - var source = sources[_i]; + for (var _i = 0, sources_1 = sources; _i < sources_1.length; _i++) { + var source = sources_1[_i]; if (t === source) { return anyType; } @@ -14921,8 +15336,8 @@ var ts; function eachTypeRelatedToSomeType(source, target) { var result = -1; var sourceTypes = source.types; - for (var _i = 0; _i < sourceTypes.length; _i++) { - var sourceType = sourceTypes[_i]; + for (var _i = 0, sourceTypes_1 = sourceTypes; _i < sourceTypes_1.length; _i++) { + var sourceType = sourceTypes_1[_i]; var related = typeRelatedToSomeType(sourceType, target, false); if (!related) { return 0; @@ -14944,8 +15359,8 @@ var ts; function typeRelatedToEachType(source, target, reportErrors) { var result = -1; var targetTypes = target.types; - for (var _i = 0; _i < targetTypes.length; _i++) { - var targetType = targetTypes[_i]; + for (var _i = 0, targetTypes_1 = targetTypes; _i < targetTypes_1.length; _i++) { + var targetType = targetTypes_1[_i]; var related = isRelatedTo(source, targetType, reportErrors); if (!related) { return 0; @@ -14967,8 +15382,8 @@ var ts; function eachTypeRelatedToType(source, target, reportErrors) { var result = -1; var sourceTypes = source.types; - for (var _i = 0; _i < sourceTypes.length; _i++) { - var sourceType = sourceTypes[_i]; + for (var _i = 0, sourceTypes_2 = sourceTypes; _i < sourceTypes_2.length; _i++) { + var sourceType = sourceTypes_2[_i]; var related = isRelatedTo(sourceType, target, reportErrors); if (!related) { return 0; @@ -15081,8 +15496,8 @@ var ts; var result = -1; var properties = getPropertiesOfObjectType(target); var requireOptionalProperties = relation === subtypeRelation && !(source.flags & 524288); - for (var _i = 0; _i < properties.length; _i++) { - var targetProp = properties[_i]; + for (var _i = 0, properties_1 = properties; _i < properties_1.length; _i++) { + var targetProp = properties_1[_i]; var sourceProp = getPropertyOfType(source, targetProp.name); if (sourceProp !== targetProp) { if (!sourceProp) { @@ -15096,20 +15511,20 @@ var ts; else if (!(targetProp.flags & 134217728)) { var sourcePropFlags = getDeclarationFlagsFromSymbol(sourceProp); var targetPropFlags = getDeclarationFlagsFromSymbol(targetProp); - if (sourcePropFlags & 32 || targetPropFlags & 32) { + if (sourcePropFlags & 16 || targetPropFlags & 16) { if (sourceProp.valueDeclaration !== targetProp.valueDeclaration) { if (reportErrors) { - if (sourcePropFlags & 32 && targetPropFlags & 32) { + if (sourcePropFlags & 16 && targetPropFlags & 16) { reportError(ts.Diagnostics.Types_have_separate_declarations_of_a_private_property_0, symbolToString(targetProp)); } else { - reportError(ts.Diagnostics.Property_0_is_private_in_type_1_but_not_in_type_2, symbolToString(targetProp), typeToString(sourcePropFlags & 32 ? source : target), typeToString(sourcePropFlags & 32 ? target : source)); + reportError(ts.Diagnostics.Property_0_is_private_in_type_1_but_not_in_type_2, symbolToString(targetProp), typeToString(sourcePropFlags & 16 ? source : target), typeToString(sourcePropFlags & 16 ? target : source)); } } return 0; } } - else if (targetPropFlags & 64) { + else if (targetPropFlags & 32) { var sourceDeclaredInClass = sourceProp.parent && sourceProp.parent.flags & 32; var sourceClass = sourceDeclaredInClass ? getDeclaredTypeOfSymbol(sourceProp.parent) : undefined; var targetClass = getDeclaredTypeOfSymbol(targetProp.parent); @@ -15120,7 +15535,7 @@ var ts; return 0; } } - else if (sourcePropFlags & 64) { + else if (sourcePropFlags & 32) { if (reportErrors) { reportError(ts.Diagnostics.Property_0_is_protected_in_type_1_but_public_in_type_2, symbolToString(targetProp), typeToString(source), typeToString(target)); } @@ -15155,8 +15570,8 @@ var ts; return 0; } var result = -1; - for (var _i = 0; _i < sourceProperties.length; _i++) { - var sourceProp = sourceProperties[_i]; + for (var _i = 0, sourceProperties_1 = sourceProperties; _i < sourceProperties_1.length; _i++) { + var sourceProp = sourceProperties_1[_i]; var targetProp = getPropertyOfObjectType(target, sourceProp.name); if (!targetProp) { return 0; @@ -15188,13 +15603,13 @@ var ts; return result; } } - outer: for (var _i = 0; _i < targetSignatures.length; _i++) { - var t = targetSignatures[_i]; + outer: for (var _i = 0, targetSignatures_1 = targetSignatures; _i < targetSignatures_1.length; _i++) { + var t = targetSignatures_1[_i]; if (!t.hasStringLiterals || target.flags & 262144) { var localErrors = reportErrors; var checkedAbstractAssignability = false; - for (var _a = 0; _a < sourceSignatures.length; _a++) { - var s = sourceSignatures[_a]; + for (var _a = 0, sourceSignatures_1 = sourceSignatures; _a < sourceSignatures_1.length; _a++) { + var s = sourceSignatures_1[_a]; if (!s.hasStringLiterals || source.flags & 262144) { var related = signatureRelatedTo(s, t, localErrors); if (related) { @@ -15222,8 +15637,8 @@ var ts; var targetReturnType = targetErasedSignature && getReturnTypeOfSignature(targetErasedSignature); var sourceReturnDecl = sourceReturnType && sourceReturnType.symbol && getClassLikeDeclarationOfSymbol(sourceReturnType.symbol); var targetReturnDecl = targetReturnType && targetReturnType.symbol && getClassLikeDeclarationOfSymbol(targetReturnType.symbol); - var sourceIsAbstract = sourceReturnDecl && sourceReturnDecl.flags & 256; - var targetIsAbstract = targetReturnDecl && targetReturnDecl.flags & 256; + var sourceIsAbstract = sourceReturnDecl && sourceReturnDecl.flags & 128; + var targetIsAbstract = targetReturnDecl && targetReturnDecl.flags & 128; if (sourceIsAbstract && !(targetIsAbstract && targetDecl)) { if (reportErrors) { reportError(ts.Diagnostics.Cannot_assign_an_abstract_constructor_type_to_a_non_abstract_constructor_type); @@ -15424,8 +15839,8 @@ var ts; if (sourceProp === targetProp) { return -1; } - var sourcePropAccessibility = getDeclarationFlagsFromSymbol(sourceProp) & (32 | 64); - var targetPropAccessibility = getDeclarationFlagsFromSymbol(targetProp) & (32 | 64); + var sourcePropAccessibility = getDeclarationFlagsFromSymbol(sourceProp) & (16 | 32); + var targetPropAccessibility = getDeclarationFlagsFromSymbol(targetProp) & (16 | 32); if (sourcePropAccessibility !== targetPropAccessibility) { return 0; } @@ -15491,8 +15906,8 @@ var ts; return signature.hasRestParameter && parameterIndex >= signature.parameters.length - 1; } function isSupertypeOfEach(candidate, types) { - for (var _i = 0; _i < types.length; _i++) { - var type = types[_i]; + for (var _i = 0, types_6 = types; _i < types_6.length; _i++) { + var type = types_6[_i]; if (candidate !== type && !isTypeSubtypeOf(type, candidate)) return false; } @@ -15705,8 +16120,8 @@ var ts; } function createInferenceContext(typeParameters, inferUnionTypes) { var inferences = []; - for (var _i = 0; _i < typeParameters.length; _i++) { - var unused = typeParameters[_i]; + for (var _i = 0, typeParameters_1 = typeParameters; _i < typeParameters_1.length; _i++) { + var unused = typeParameters_1[_i]; inferences.push({ primary: undefined, secondary: undefined, isFixed: false }); @@ -15772,8 +16187,8 @@ var ts; var targetTypes = target.types; var typeParameterCount = 0; var typeParameter; - for (var _i = 0; _i < targetTypes.length; _i++) { - var t = targetTypes[_i]; + for (var _i = 0, targetTypes_2 = targetTypes; _i < targetTypes_2.length; _i++) { + var t = targetTypes_2[_i]; if (t.flags & 512 && ts.contains(context.typeParameters, t)) { typeParameter = t; typeParameterCount++; @@ -15790,8 +16205,8 @@ var ts; } else if (source.flags & 49152) { var sourceTypes = source.types; - for (var _a = 0; _a < sourceTypes.length; _a++) { - var sourceType = sourceTypes[_a]; + for (var _a = 0, sourceTypes_3 = sourceTypes; _a < sourceTypes_3.length; _a++) { + var sourceType = sourceTypes_3[_a]; inferFromTypes(sourceType, target); } } @@ -15824,8 +16239,8 @@ var ts; } function inferFromProperties(source, target) { var properties = getPropertiesOfObjectType(target); - for (var _i = 0; _i < properties.length; _i++) { - var targetProp = properties[_i]; + for (var _i = 0, properties_2 = properties; _i < properties_2.length; _i++) { + var targetProp = properties_2[_i]; var sourceProp = getPropertyOfObjectType(source, targetProp.name); if (sourceProp) { inferFromTypes(getTypeOfSymbol(sourceProp), getTypeOfSymbol(targetProp)); @@ -16316,7 +16731,7 @@ var ts; break; case 141: case 140: - if (container.flags & 128) { + if (container.flags & 64) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_static_property_initializer); } break; @@ -16329,7 +16744,7 @@ var ts; } if (ts.isClassLike(container.parent)) { var symbol = getSymbolOfNode(container.parent); - return container.flags & 128 ? getTypeOfSymbol(symbol) : getDeclaredTypeOfSymbol(symbol).thisType; + return container.flags & 64 ? getTypeOfSymbol(symbol) : getDeclaredTypeOfSymbol(symbol).thisType; } return anyType; } @@ -16357,7 +16772,7 @@ var ts; var canUseSuperExpression = isLegalUsageOfSuperExpression(container); var nodeCheckFlag = 0; if (canUseSuperExpression) { - if ((container.flags & 128) || isCallExpression) { + if ((container.flags & 64) || isCallExpression) { nodeCheckFlag = 512; } else { @@ -16402,7 +16817,7 @@ var ts; } else { if (container && ts.isClassLike(container.parent)) { - if (container.flags & 128) { + if (container.flags & 64) { return container.kind === 143 || container.kind === 142 || container.kind === 145 || @@ -16541,8 +16956,8 @@ var ts; var types = type.types; var mappedType; var mappedTypes; - for (var _i = 0; _i < types.length; _i++) { - var current = types[_i]; + for (var _i = 0, types_7 = types; _i < types_7.length; _i++) { + var current = types_7[_i]; var t = mapper(current); if (t) { if (!mappedType) { @@ -16706,8 +17121,8 @@ var ts; } var signatureList; var types = type.types; - for (var _i = 0; _i < types.length; _i++) { - var current = types[_i]; + for (var _i = 0, types_8 = types; _i < types_8.length; _i++) { + var current = types_8[_i]; var signature = getNonGenericSignature(current); if (signature) { if (!signatureList) { @@ -16758,8 +17173,8 @@ var ts; var hasSpreadElement = false; var elementTypes = []; var inDestructuringPattern = isAssignmentTarget(node); - for (var _i = 0; _i < elements.length; _i++) { - var e = elements[_i]; + for (var _i = 0, elements_1 = elements; _i < elements_1.length; _i++) { + var e = elements_1[_i]; if (inDestructuringPattern && e.kind === 185) { var restArrayType = checkExpression(e.expression, contextualMapper); var restElementType = getIndexTypeOfType(restArrayType, 1) || @@ -17018,8 +17433,8 @@ var ts; function checkJsxSpreadAttribute(node, elementAttributesType, nameTable) { var type = checkExpression(node.expression); var props = getPropertiesOfType(type); - for (var _i = 0; _i < props.length; _i++) { - var prop = props[_i]; + for (var _i = 0, props_2 = props; _i < props_2.length; _i++) { + var prop = props_2[_i]; if (!nameTable[prop.name]) { var targetPropSym = getPropertyOfType(elementAttributesType, prop.name); if (targetPropSym) { @@ -17188,7 +17603,6 @@ var ts; var prop = getPropertyOfType(attributesType, attrib.name.text); return prop || unknownSymbol; } - var jsxElementClassType = undefined; function getJsxGlobalElementClassType() { if (!jsxElementClassType) { jsxElementClassType = getExportedTypeFromNamespace(JsxNames.JSX, JsxNames.ElementClass); @@ -17255,7 +17669,7 @@ var ts; return s.valueDeclaration ? s.valueDeclaration.kind : 141; } function getDeclarationFlagsFromSymbol(s) { - return s.valueDeclaration ? ts.getCombinedNodeFlags(s.valueDeclaration) : s.flags & 134217728 ? 16 | 128 : 0; + return s.valueDeclaration ? ts.getCombinedNodeFlags(s.valueDeclaration) : s.flags & 134217728 ? 8 | 64 : 0; } function checkClassPropertyAccess(node, left, type, prop) { var flags = getDeclarationFlagsFromSymbol(prop); @@ -17268,17 +17682,17 @@ var ts; error(errorNode, ts.Diagnostics.Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword); return false; } - if (flags & 256) { + if (flags & 128) { error(errorNode, ts.Diagnostics.Abstract_method_0_in_class_1_cannot_be_accessed_via_super_expression, symbolToString(prop), typeToString(declaringClass)); return false; } } - if (!(flags & (32 | 64))) { + if (!(flags & (16 | 32))) { return true; } var enclosingClassDeclaration = ts.getContainingClass(node); var enclosingClass = enclosingClassDeclaration ? getDeclaredTypeOfSymbol(getSymbolOfNode(enclosingClassDeclaration)) : undefined; - if (flags & 32) { + if (flags & 16) { if (declaringClass !== enclosingClass) { error(node, ts.Diagnostics.Property_0_is_private_and_only_accessible_within_class_1, symbolToString(prop), typeToString(declaringClass)); return false; @@ -17292,7 +17706,7 @@ var ts; error(node, ts.Diagnostics.Property_0_is_protected_and_only_accessible_within_class_1_and_its_subclasses, symbolToString(prop), typeToString(declaringClass)); return false; } - if (flags & 128) { + if (flags & 64) { return true; } if (type.flags & 33554432) { @@ -17472,8 +17886,8 @@ var ts; var specializedIndex = -1; var spliceIndex; ts.Debug.assert(!result.length); - for (var _i = 0; _i < signatures.length; _i++) { - var signature = signatures[_i]; + 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_5 = signature.declaration && signature.declaration.parent; if (!lastSymbol || symbol === lastSymbol) { @@ -17884,8 +18298,8 @@ var ts; reportError(ts.Diagnostics.Supplied_parameters_do_not_match_any_signature_of_call_target); } if (!produceDiagnostics) { - for (var _i = 0; _i < candidates.length; _i++) { - var candidate = candidates[_i]; + for (var _i = 0, candidates_1 = candidates; _i < candidates_1.length; _i++) { + var candidate = candidates_1[_i]; if (hasCorrectArity(node, args, candidate)) { if (candidate.typeParameters && typeArguments) { candidate = getSignatureInstantiation(candidate, ts.map(typeArguments, getTypeFromTypeNode)); @@ -17904,8 +18318,8 @@ var ts; diagnostics.add(ts.createDiagnosticForNodeFromMessageChain(node, errorInfo)); } function chooseOverload(candidates, relation) { - for (var _i = 0; _i < candidates.length; _i++) { - var originalCandidate = candidates[_i]; + for (var _i = 0, candidates_2 = candidates; _i < candidates_2.length; _i++) { + var originalCandidate = candidates_2[_i]; if (!hasCorrectArity(node, args, originalCandidate)) { continue; } @@ -18008,7 +18422,7 @@ var ts; return resolveErrorCall(node); } var valueDecl = expressionType.symbol && getClassLikeDeclarationOfSymbol(expressionType.symbol); - if (valueDecl && valueDecl.flags & 256) { + if (valueDecl && valueDecl.flags & 128) { error(node, ts.Diagnostics.Cannot_create_an_instance_of_the_abstract_class_0, ts.declarationNameToString(valueDecl.name)); return resolveErrorCall(node); } @@ -18294,32 +18708,24 @@ var ts; }); return aggregatedTypes; } - function bodyContainsAReturnStatement(funcBody) { - return ts.forEachReturnStatement(funcBody, function (returnStatement) { - return true; - }); - } - function bodyContainsSingleThrowStatement(body) { - return (body.statements.length === 1) && (body.statements[0].kind === 208); - } - function checkIfNonVoidFunctionHasReturnExpressionsOrSingleThrowStatment(func, returnType) { + function checkAllCodePathsInNonVoidFunctionReturnOrThrow(func, returnType) { if (!produceDiagnostics) { return; } if (returnType === voidType || isTypeAny(returnType)) { return; } - if (ts.nodeIsMissing(func.body) || func.body.kind !== 192) { + if (ts.nodeIsMissing(func.body) || func.body.kind !== 192 || !(func.flags & 524288)) { return; } - var bodyBlock = func.body; - if (bodyContainsAReturnStatement(bodyBlock)) { - return; + if (func.flags & 1048576) { + if (compilerOptions.noImplicitReturns) { + error(func.type, ts.Diagnostics.Not_all_code_paths_return_a_value); + } } - if (bodyContainsSingleThrowStatement(bodyBlock)) { - return; + else { + error(func.type, ts.Diagnostics.A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value); } - error(func.type, ts.Diagnostics.A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value_or_consist_of_a_single_throw_statement); } function checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper) { ts.Debug.assert(node.kind !== 143 || ts.isObjectLiteralMethod(node)); @@ -18378,7 +18784,7 @@ var ts; promisedType = checkAsyncFunctionReturnType(node); } if (returnType && !node.asteriskToken) { - checkIfNonVoidFunctionHasReturnExpressionsOrSingleThrowStatment(node, isAsync ? promisedType : returnType); + checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, isAsync ? promisedType : returnType); } if (node.body) { if (!node.type) { @@ -18437,7 +18843,7 @@ var ts; case 69: case 166: { var symbol = findSymbol(n); - return symbol && (symbol.flags & 3) !== 0 && (getDeclarationFlagsFromSymbol(symbol) & 32768) !== 0; + return symbol && (symbol.flags & 3) !== 0 && (getDeclarationFlagsFromSymbol(symbol) & 16384) !== 0; } case 167: { var index = n.argumentExpression; @@ -18445,7 +18851,7 @@ var ts; if (symbol && index && index.kind === 9) { var name_13 = index.text; var prop = getPropertyOfType(getTypeOfSymbol(symbol), name_13); - return prop && (prop.flags & 3) !== 0 && (getDeclarationFlagsFromSymbol(prop) & 32768) !== 0; + return prop && (prop.flags & 3) !== 0 && (getDeclarationFlagsFromSymbol(prop) & 16384) !== 0; } return false; } @@ -18525,8 +18931,8 @@ var ts; } if (type.flags & 49152) { var types = type.types; - for (var _i = 0; _i < types.length; _i++) { - var current = types[_i]; + for (var _i = 0, types_9 = types; _i < types_9.length; _i++) { + var current = types_9[_i]; if (current.flags & kind) { return true; } @@ -18541,8 +18947,8 @@ var ts; } if (type.flags & 49152) { var types = type.types; - for (var _i = 0; _i < types.length; _i++) { - var current = types[_i]; + for (var _i = 0, types_10 = types; _i < types_10.length; _i++) { + var current = types_10[_i]; if (!(current.flags & kind)) { return false; } @@ -18577,8 +18983,8 @@ var ts; } function checkObjectLiteralAssignment(node, sourceType, contextualMapper) { var properties = node.properties; - for (var _i = 0; _i < properties.length; _i++) { - var p = properties[_i]; + for (var _i = 0, properties_3 = properties; _i < properties_3.length; _i++) { + var p = properties_3[_i]; if (p.kind === 245 || p.kind === 246) { var name_14 = p.name; var type = isTypeAny(sourceType) @@ -19040,7 +19446,7 @@ var ts; checkGrammarDecorators(node) || checkGrammarModifiers(node); checkVariableLikeDeclaration(node); var func = ts.getContainingFunction(node); - if (node.flags & 112) { + if (node.flags & 56) { func = ts.getContainingFunction(node); if (!(func.kind === 144 && ts.nodeIsPresent(func.body))) { error(node, ts.Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation); @@ -19221,7 +19627,7 @@ var ts; function checkMethodDeclaration(node) { checkGrammarMethod(node) || checkGrammarComputedPropertyName(node.name); checkFunctionLikeDeclaration(node); - if (node.flags & 256 && node.body) { + if (node.flags & 128 && node.body) { error(node, ts.Diagnostics.Method_0_cannot_have_an_implementation_because_it_is_marked_abstract, ts.declarationNameToString(node.name)); } } @@ -19268,7 +19674,7 @@ var ts; } function isInstancePropertyWithInitializer(n) { return n.kind === 141 && - !(n.flags & 128) && + !(n.flags & 64) && !!n.initializer; } var containingClassDecl = node.parent; @@ -19281,12 +19687,12 @@ var ts; error(node, ts.Diagnostics.A_constructor_cannot_contain_a_super_call_when_its_class_extends_null); } var superCallShouldBeFirst = ts.forEach(node.parent.members, isInstancePropertyWithInitializer) || - ts.forEach(node.parameters, function (p) { return p.flags & (16 | 32 | 64); }); + ts.forEach(node.parameters, function (p) { return p.flags & (8 | 16 | 32); }); if (superCallShouldBeFirst) { var statements = node.body.statements; var superCallStatement; - for (var _i = 0; _i < statements.length; _i++) { - var statement = statements[_i]; + for (var _i = 0, statements_2 = statements; _i < statements_2.length; _i++) { + var statement = statements_2[_i]; if (statement.kind === 195 && isSuperCallExpression(statement.expression)) { superCallStatement = statement; break; @@ -19312,15 +19718,22 @@ var ts; if (produceDiagnostics) { checkGrammarFunctionLikeDeclaration(node) || checkGrammarAccessor(node) || checkGrammarComputedPropertyName(node.name); if (node.kind === 145) { - if (!ts.isInAmbientContext(node) && ts.nodeIsPresent(node.body) && !(bodyContainsAReturnStatement(node.body) || bodyContainsSingleThrowStatement(node.body))) { - error(node.name, ts.Diagnostics.A_get_accessor_must_return_a_value_or_consist_of_a_single_throw_statement); + if (!ts.isInAmbientContext(node) && ts.nodeIsPresent(node.body) && (node.flags & 524288)) { + if (node.flags & 1048576) { + if (compilerOptions.noImplicitReturns) { + error(node.name, ts.Diagnostics.Not_all_code_paths_return_a_value); + } + } + else { + error(node.name, ts.Diagnostics.A_get_accessor_must_return_a_value); + } } } if (!ts.hasDynamicName(node)) { var otherKind = node.kind === 145 ? 146 : 145; var otherAccessor = ts.getDeclarationOfKind(node.symbol, otherKind); if (otherAccessor) { - if (((node.flags & 112) !== (otherAccessor.flags & 112))) { + if (((node.flags & 56) !== (otherAccessor.flags & 56))) { error(node.name, ts.Diagnostics.Getter_and_setter_accessors_do_not_agree_in_visibility); } var currentAccessorType = getAnnotatedAccessorType(node); @@ -19387,7 +19800,7 @@ var ts; ts.forEach(node.types, checkSourceElement); } function isPrivateWithinAmbient(node) { - return (node.flags & 32) && ts.isInAmbientContext(node); + return (node.flags & 16) && ts.isInAmbientContext(node); } function checkSpecializedSignatureDeclaration(signatureDeclarationNode) { if (!produceDiagnostics) { @@ -19412,8 +19825,8 @@ var ts; else { signaturesToCheck = getSignaturesOfSymbol(getSymbolOfNode(signatureDeclarationNode)); } - for (var _i = 0; _i < signaturesToCheck.length; _i++) { - var otherSignature = signaturesToCheck[_i]; + for (var _i = 0, signaturesToCheck_1 = signaturesToCheck; _i < signaturesToCheck_1.length; _i++) { + var otherSignature = signaturesToCheck_1[_i]; if (!otherSignature.hasStringLiterals && isSignatureAssignableTo(signature, otherSignature)) { return; } @@ -19426,10 +19839,10 @@ var ts; n.parent.kind !== 214 && n.parent.kind !== 186 && ts.isInAmbientContext(n)) { - if (!(flags & 2)) { - flags |= 1; + if (!(flags & 4)) { + flags |= 2; } - flags |= 2; + flags |= 4; } return flags & flagsToCheck; } @@ -19447,16 +19860,16 @@ var ts; var canonicalFlags = getEffectiveDeclarationFlags(getCanonicalOverload(overloads, implementation), flagsToCheck); ts.forEach(overloads, function (o) { var deviation = getEffectiveDeclarationFlags(o, flagsToCheck) ^ canonicalFlags; - if (deviation & 1) { + if (deviation & 2) { error(o.name, ts.Diagnostics.Overload_signatures_must_all_be_exported_or_not_exported); } - else if (deviation & 2) { + else if (deviation & 4) { error(o.name, ts.Diagnostics.Overload_signatures_must_all_be_ambient_or_non_ambient); } - else if (deviation & (32 | 64)) { + else if (deviation & (16 | 32)) { error(o.name, ts.Diagnostics.Overload_signatures_must_all_be_public_private_or_protected); } - else if (deviation & 256) { + else if (deviation & 128) { error(o.name, ts.Diagnostics.Overload_signatures_must_all_be_abstract_or_not_abstract); } }); @@ -19473,7 +19886,7 @@ var ts; }); } } - var flagsToCheck = 1 | 2 | 32 | 64 | 256; + var flagsToCheck = 2 | 4 | 16 | 32 | 128; var someNodeFlags = 0; var allNodeFlags = flagsToCheck; var someHaveQuestionToken = false; @@ -19502,8 +19915,8 @@ var ts; var errorNode_1 = subsequentNode.name || subsequentNode; if (node.name && subsequentNode.name && node.name.text === subsequentNode.name.text) { ts.Debug.assert(node.kind === 143 || node.kind === 142); - ts.Debug.assert((node.flags & 128) !== (subsequentNode.flags & 128)); - var diagnostic = node.flags & 128 ? ts.Diagnostics.Function_overload_must_be_static : ts.Diagnostics.Function_overload_must_not_be_static; + ts.Debug.assert((node.flags & 64) !== (subsequentNode.flags & 64)); + var diagnostic = node.flags & 64 ? ts.Diagnostics.Function_overload_must_be_static : ts.Diagnostics.Function_overload_must_not_be_static; error(errorNode_1, diagnostic); return; } @@ -19518,7 +19931,7 @@ var ts; error(errorNode, ts.Diagnostics.Constructor_implementation_is_missing); } else { - if (node.flags & 256) { + if (node.flags & 128) { error(errorNode, ts.Diagnostics.All_declarations_of_an_abstract_method_must_be_consecutive); } else { @@ -19529,8 +19942,8 @@ var ts; var isExportSymbolInsideModule = symbol.parent && symbol.parent.flags & 1536; var duplicateFunctionDeclaration = false; var multipleConstructorImplementation = false; - for (var _i = 0; _i < declarations.length; _i++) { - var current = declarations[_i]; + for (var _i = 0, declarations_4 = declarations; _i < declarations_4.length; _i++) { + var current = declarations_4[_i]; var node = current; var inAmbientContext = ts.isInAmbientContext(node); var inAmbientContextOrInterface = node.parent.kind === 215 || node.parent.kind === 155 || inAmbientContext; @@ -19579,7 +19992,7 @@ var ts; }); } if (!isExportSymbolInsideModule && lastSeenNonAmbientDeclaration && !lastSeenNonAmbientDeclaration.body && - !(lastSeenNonAmbientDeclaration.flags & 256)) { + !(lastSeenNonAmbientDeclaration.flags & 128)) { reportImplementationExpectedError(lastSeenNonAmbientDeclaration); } if (hasOverloads) { @@ -19589,8 +20002,8 @@ var ts; var signatures = getSignaturesOfSymbol(symbol); var bodySignature = getSignatureFromDeclaration(bodyDeclaration); if (!bodySignature.hasStringLiterals) { - for (var _a = 0; _a < signatures.length; _a++) { - var signature = signatures[_a]; + for (var _a = 0, signatures_3 = signatures; _a < signatures_3.length; _a++) { + var signature = signatures_3[_a]; if (!signature.hasStringLiterals && !isSignatureAssignableTo(bodySignature, signature)) { error(signature.declaration, ts.Diagnostics.Overload_signature_is_not_compatible_with_function_implementation); break; @@ -19620,9 +20033,9 @@ var ts; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var d = _a[_i]; var declarationSpaces = getDeclarationSpaces(d); - var effectiveDeclarationFlags = getEffectiveDeclarationFlags(d, 1 | 1024); - if (effectiveDeclarationFlags & 1) { - if (effectiveDeclarationFlags & 1024) { + var effectiveDeclarationFlags = getEffectiveDeclarationFlags(d, 2 | 512); + if (effectiveDeclarationFlags & 2) { + if (effectiveDeclarationFlags & 512) { defaultExportedDeclarationSpaces |= declarationSpaces; } else { @@ -19758,9 +20171,12 @@ var ts; if (promiseType === unknownType && compilerOptions.isolatedModules) { return unknownType; } - var promiseConstructor = getMergedSymbol(promiseType.symbol); + var promiseConstructor = getNodeLinks(node.type).resolvedSymbol; if (!promiseConstructor || !symbolIsValue(promiseConstructor)) { - error(node, ts.Diagnostics.Type_0_is_not_a_valid_async_function_return_type, typeToString(promiseType)); + var typeName = promiseConstructor + ? symbolToString(promiseConstructor) + : typeToString(promiseType); + error(node, ts.Diagnostics.Type_0_is_not_a_valid_async_function_return_type, typeName); return unknownType; } var promiseConstructorType = getTypeOfSymbol(promiseConstructor); @@ -19919,7 +20335,7 @@ var ts; if (isAsync) { promisedType = checkAsyncFunctionReturnType(node); } - checkIfNonVoidFunctionHasReturnExpressionsOrSingleThrowStatment(node, isAsync ? promisedType : returnType); + checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, isAsync ? promisedType : returnType); } if (produceDiagnostics && !node.type) { if (compilerOptions.noImplicitAny && ts.nodeIsMissing(node.body) && !isPrivateWithinAmbient(node)) { @@ -20022,7 +20438,7 @@ var ts; } } function checkVarDeclaredNamesNotShadowed(node) { - if ((ts.getCombinedNodeFlags(node) & 49152) !== 0 || ts.isParameterDeclaration(node)) { + if ((ts.getCombinedNodeFlags(node) & 24576) !== 0 || ts.isParameterDeclaration(node)) { return; } if (node.kind === 211 && !node.initializer) { @@ -20034,7 +20450,7 @@ var ts; if (localDeclarationSymbol && localDeclarationSymbol !== symbol && localDeclarationSymbol.flags & 2) { - if (getDeclarationFlagsFromSymbol(localDeclarationSymbol) & 49152) { + if (getDeclarationFlagsFromSymbol(localDeclarationSymbol) & 24576) { var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 212); var container = varDeclList.parent.kind === 193 && varDeclList.parent.parent ? varDeclList.parent.parent @@ -20161,6 +20577,9 @@ var ts; checkGrammarStatementInAmbientContext(node); checkExpression(node.expression); checkSourceElement(node.thenStatement); + if (node.thenStatement.kind === 194) { + error(node.thenStatement, ts.Diagnostics.The_body_of_an_if_statement_cannot_be_the_empty_statement); + } checkSourceElement(node.elseStatement); } function checkDoStatement(node) { @@ -20410,7 +20829,7 @@ var ts; error(node.expression, ts.Diagnostics.Setters_cannot_return_a_value); } else if (func.kind === 144) { - if (!isTypeAssignableTo(exprType, returnType)) { + if (!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); } } @@ -20540,7 +20959,7 @@ var ts; var classDeclaration = type.symbol.valueDeclaration; for (var _i = 0, _a = classDeclaration.members; _i < _a.length; _i++) { var member = _a[_i]; - if (!(member.flags & 128) && ts.hasDynamicName(member)) { + if (!(member.flags & 64) && ts.hasDynamicName(member)) { var propType = getTypeOfSymbol(member.symbol); checkIndexConstraintForProperty(member.symbol, propType, type, declaredStringIndexer, stringIndexType, 0); checkIndexConstraintForProperty(member.symbol, propType, type, declaredNumberIndexer, numberIndexType, 1); @@ -20616,7 +21035,7 @@ var ts; return getTypeOfSymbol(getSymbolOfNode(node)); } function checkClassDeclaration(node) { - if (!node.name && !(node.flags & 1024)) { + if (!node.name && !(node.flags & 512)) { grammarErrorOnFirstToken(node, ts.Diagnostics.A_class_declaration_without_the_default_modifier_must_have_a_name); } checkClassLikeDeclaration(node); @@ -20666,8 +21085,8 @@ var ts; } var implementedTypeNodes = ts.getClassImplementsHeritageClauseElements(node); if (implementedTypeNodes) { - for (var _b = 0; _b < implementedTypeNodes.length; _b++) { - var typeRefNode = implementedTypeNodes[_b]; + for (var _b = 0, implementedTypeNodes_1 = implementedTypeNodes; _b < implementedTypeNodes_1.length; _b++) { + var typeRefNode = implementedTypeNodes_1[_b]; if (!ts.isSupportedExpressionWithTypeArguments(typeRefNode)) { error(typeRefNode.expression, ts.Diagnostics.A_class_can_only_implement_an_identifier_Slashqualified_name_with_optional_type_arguments); } @@ -20699,8 +21118,8 @@ var ts; } function checkKindsOfPropertyMemberOverrides(type, baseType) { var baseProperties = getPropertiesOfObjectType(baseType); - for (var _i = 0; _i < baseProperties.length; _i++) { - var baseProperty = baseProperties[_i]; + for (var _i = 0, baseProperties_1 = baseProperties; _i < baseProperties_1.length; _i++) { + var baseProperty = baseProperties_1[_i]; var base = getTargetSymbol(baseProperty); if (base.flags & 134217728) { continue; @@ -20711,7 +21130,7 @@ var ts; if (derived) { if (derived === base) { var derivedClassDecl = getClassLikeDeclarationOfSymbol(type.symbol); - if (baseDeclarationFlags & 256 && (!derivedClassDecl || !(derivedClassDecl.flags & 256))) { + if (baseDeclarationFlags & 128 && (!derivedClassDecl || !(derivedClassDecl.flags & 128))) { if (derivedClassDecl.kind === 186) { error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1, symbolToString(baseProperty), typeToString(baseType)); } @@ -20722,10 +21141,10 @@ var ts; } else { var derivedDeclarationFlags = getDeclarationFlagsFromSymbol(derived); - if ((baseDeclarationFlags & 32) || (derivedDeclarationFlags & 32)) { + if ((baseDeclarationFlags & 16) || (derivedDeclarationFlags & 16)) { continue; } - if ((baseDeclarationFlags & 128) !== (derivedDeclarationFlags & 128)) { + if ((baseDeclarationFlags & 64) !== (derivedDeclarationFlags & 64)) { continue; } if ((base.flags & derived.flags & 8192) || ((base.flags & 98308) && (derived.flags & 98308))) { @@ -20791,11 +21210,11 @@ var ts; var seen = {}; ts.forEach(resolveDeclaredMembers(type).declaredProperties, function (p) { seen[p.name] = { prop: p, containingType: type }; }); var ok = true; - for (var _i = 0; _i < baseTypes.length; _i++) { - var base = baseTypes[_i]; + for (var _i = 0, baseTypes_2 = baseTypes; _i < baseTypes_2.length; _i++) { + var base = baseTypes_2[_i]; var properties = getPropertiesOfObjectType(getTypeWithThisArgument(base, type.thisType)); - for (var _a = 0; _a < properties.length; _a++) { - var prop = properties[_a]; + for (var _a = 0, properties_4 = properties; _a < properties_4.length; _a++) { + var prop = properties_4[_a]; if (!ts.hasProperty(seen, prop.name)) { seen[prop.name] = { prop: prop, containingType: base }; } @@ -21064,8 +21483,8 @@ var ts; } function getFirstNonAmbientClassOrFunctionDeclaration(symbol) { var declarations = symbol.declarations; - for (var _i = 0; _i < declarations.length; _i++) { - var declaration = declarations[_i]; + for (var _i = 0, declarations_5 = declarations; _i < declarations_5.length; _i++) { + var declaration = declarations_5[_i]; if ((declaration.kind === 214 || (declaration.kind === 213 && ts.nodeIsPresent(declaration.body))) && !ts.isInAmbientContext(declaration)) { @@ -21193,7 +21612,7 @@ var ts; if (checkGrammarModuleElementContext(node, ts.Diagnostics.An_import_declaration_can_only_be_used_in_a_namespace_or_module)) { return; } - if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && (node.flags & 2035)) { + if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && (node.flags & 1022)) { grammarErrorOnFirstToken(node, ts.Diagnostics.An_import_declaration_cannot_have_modifiers); } if (checkExternalImportOrExportDeclaration(node)) { @@ -21220,7 +21639,7 @@ var ts; checkGrammarDecorators(node) || checkGrammarModifiers(node); if (ts.isInternalModuleImportEqualsDeclaration(node) || checkExternalImportOrExportDeclaration(node)) { checkImportBinding(node); - if (node.flags & 1) { + if (node.flags & 2) { markExportAsReferenced(node); } if (ts.isInternalModuleImportEqualsDeclaration(node)) { @@ -21248,7 +21667,7 @@ var ts; if (checkGrammarModuleElementContext(node, ts.Diagnostics.An_export_declaration_can_only_be_used_in_a_module)) { return; } - if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && (node.flags & 2035)) { + if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && (node.flags & 1022)) { grammarErrorOnFirstToken(node, ts.Diagnostics.An_export_declaration_cannot_have_modifiers); } if (!node.moduleSpecifier || checkExternalImportOrExportDeclaration(node)) { @@ -21287,7 +21706,7 @@ var ts; error(node, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_namespace); return; } - if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && (node.flags & 2035)) { + if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && (node.flags & 1022)) { grammarErrorOnFirstToken(node, ts.Diagnostics.An_export_assignment_cannot_have_modifiers); } if (node.expression.kind === 69) { @@ -21672,7 +22091,7 @@ var ts; } case 214: case 215: - if (!(memberFlags & 128)) { + if (!(memberFlags & 64)) { copySymbols(getSymbolOfNode(location).members, meaning & 793056); } break; @@ -21934,7 +22353,7 @@ var ts; } function getParentTypeOfClassElement(node) { var classSymbol = getSymbolOfNode(node.parent); - return node.flags & 128 + return node.flags & 64 ? getTypeOfSymbol(classSymbol) : getDeclaredTypeOfSymbol(classSymbol); } @@ -22220,7 +22639,7 @@ var ts; } function initializeTypeChecker() { ts.forEach(host.getSourceFiles(), function (file) { - ts.bindSourceFile(file); + ts.bindSourceFile(file, compilerOptions); }); ts.forEach(host.getSourceFiles(), function (file) { if (!ts.isExternalModule(file)) { @@ -22364,19 +22783,19 @@ var ts; text = "private"; lastPrivate = modifier; } - if (flags & 112) { + if (flags & 56) { return grammarErrorOnNode(modifier, ts.Diagnostics.Accessibility_modifier_already_seen); } - else if (flags & 128) { + else if (flags & 64) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "static"); } - else if (flags & 512) { + else if (flags & 256) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "async"); } else if (node.parent.kind === 219 || node.parent.kind === 248) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_element, text); } - else if (flags & 256) { + else if (flags & 128) { if (modifier.kind === 110) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, text, "abstract"); } @@ -22387,10 +22806,10 @@ var ts; flags |= ts.modifierToFlag(modifier.kind); break; case 113: - if (flags & 128) { + if (flags & 64) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "static"); } - else if (flags & 512) { + else if (flags & 256) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "static", "async"); } else if (node.parent.kind === 219 || node.parent.kind === 248) { @@ -22399,23 +22818,23 @@ var ts; else if (node.kind === 138) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "static"); } - else if (flags & 256) { + else if (flags & 128) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "static", "abstract"); } - flags |= 128; + flags |= 64; lastStatic = modifier; break; case 82: - if (flags & 1) { + if (flags & 2) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "export"); } - else if (flags & 2) { + else if (flags & 4) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "declare"); } - else if (flags & 256) { + else if (flags & 128) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "abstract"); } - else if (flags & 512) { + else if (flags & 256) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "async"); } else if (node.parent.kind === 214) { @@ -22424,13 +22843,13 @@ var ts; else if (node.kind === 138) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "export"); } - flags |= 1; + flags |= 2; break; case 122: - if (flags & 2) { + if (flags & 4) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "declare"); } - else if (flags & 512) { + else if (flags & 256) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); } else if (node.parent.kind === 214) { @@ -22442,69 +22861,69 @@ var ts; else if (ts.isInAmbientContext(node.parent) && node.parent.kind === 219) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_declare_modifier_cannot_be_used_in_an_already_ambient_context); } - flags |= 2; + flags |= 4; lastDeclare = modifier; break; case 115: - if (flags & 256) { + if (flags & 128) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "abstract"); } if (node.kind !== 214) { if (node.kind !== 143) { return grammarErrorOnNode(modifier, ts.Diagnostics.abstract_modifier_can_only_appear_on_a_class_or_method_declaration); } - if (!(node.parent.kind === 214 && node.parent.flags & 256)) { + if (!(node.parent.kind === 214 && node.parent.flags & 128)) { return grammarErrorOnNode(modifier, ts.Diagnostics.Abstract_methods_can_only_appear_within_an_abstract_class); } - if (flags & 128) { + if (flags & 64) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "static", "abstract"); } - if (flags & 32) { + if (flags & 16) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "private", "abstract"); } } - flags |= 256; + flags |= 128; break; case 118: - if (flags & 512) { + if (flags & 256) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "async"); } - else if (flags & 2 || ts.isInAmbientContext(node.parent)) { + else if (flags & 4 || ts.isInAmbientContext(node.parent)) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); } else if (node.kind === 138) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "async"); } - flags |= 512; + flags |= 256; lastAsync = modifier; break; } } if (node.kind === 144) { - if (flags & 128) { + if (flags & 64) { return grammarErrorOnNode(lastStatic, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "static"); } - if (flags & 256) { + if (flags & 128) { return grammarErrorOnNode(lastStatic, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "abstract"); } - else if (flags & 64) { + else if (flags & 32) { return grammarErrorOnNode(lastProtected, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "protected"); } - else if (flags & 32) { + else if (flags & 16) { return grammarErrorOnNode(lastPrivate, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "private"); } - else if (flags & 512) { + else if (flags & 256) { return grammarErrorOnNode(lastAsync, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "async"); } return; } - else if ((node.kind === 222 || node.kind === 221) && flags & 2) { + else if ((node.kind === 222 || node.kind === 221) && flags & 4) { return grammarErrorOnNode(lastDeclare, ts.Diagnostics.A_0_modifier_cannot_be_used_with_an_import_declaration, "declare"); } - else if (node.kind === 138 && (flags & 112) && ts.isBindingPattern(node.name)) { + else if (node.kind === 138 && (flags & 56) && ts.isBindingPattern(node.name)) { return grammarErrorOnNode(node, ts.Diagnostics.A_parameter_property_may_not_be_a_binding_pattern); } - if (flags & 512) { + if (flags & 256) { return checkGrammarAsyncModifier(node, lastAsync); } } @@ -22604,7 +23023,7 @@ var ts; if (parameter.dotDotDotToken) { return grammarErrorOnNode(parameter.dotDotDotToken, ts.Diagnostics.An_index_signature_cannot_have_a_rest_parameter); } - if (parameter.flags & 2035) { + if (parameter.flags & 1022) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_cannot_have_an_accessibility_modifier); } if (parameter.questionToken) { @@ -22624,7 +23043,7 @@ var ts; } } function checkGrammarForIndexSignatureModifier(node) { - if (node.flags & 2035) { + if (node.flags & 1022) { grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_not_permitted_on_index_signature_members); } } @@ -22646,8 +23065,8 @@ var ts; function checkGrammarForOmittedArgument(node, args) { if (args) { var sourceFile = ts.getSourceFileOfNode(node); - for (var _i = 0; _i < args.length; _i++) { - var arg = args[_i]; + for (var _i = 0, args_1 = args; _i < args_1.length; _i++) { + var arg = args_1[_i]; if (arg.kind === 187) { return grammarErrorAtPos(sourceFile, arg.pos, 0, ts.Diagnostics.Argument_expression_expected); } @@ -22887,7 +23306,7 @@ var ts; if (parameter.dotDotDotToken) { return grammarErrorOnNode(parameter.dotDotDotToken, ts.Diagnostics.A_set_accessor_cannot_have_rest_parameter); } - else if (parameter.flags & 2035) { + else if (parameter.flags & 1022) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation); } else if (parameter.questionToken) { @@ -23021,8 +23440,8 @@ var ts; } else { var elements = name.elements; - for (var _i = 0; _i < elements.length; _i++) { - var element = elements[_i]; + for (var _i = 0, elements_2 = elements; _i < elements_2.length; _i++) { + var element = elements_2[_i]; if (element.kind !== 187) { checkGrammarNameInLetOrConstDeclarations(element.name); } @@ -23141,8 +23560,8 @@ var ts; node.kind === 221 || node.kind === 228 || node.kind === 227 || - (node.flags & 2) || - (node.flags & (1 | 1024))) { + (node.flags & 4) || + (node.flags & (2 | 512))) { return false; } return grammarErrorOnFirstToken(node, ts.Diagnostics.A_declare_modifier_is_required_for_a_top_level_declaration_in_a_d_ts_file); @@ -23180,7 +23599,7 @@ var ts; } } function checkGrammarNumericLiteral(node) { - if (node.flags & 65536 && languageVersion >= 1) { + if (node.flags & 32768 && languageVersion >= 1) { return grammarErrorOnNode(node, ts.Diagnostics.Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher); } } @@ -23227,7 +23646,7 @@ var ts; var addedGlobalFileReference = false; ts.forEach(root.referencedFiles, function (fileReference) { var referencedFile = ts.tryResolveScriptReference(host, root, fileReference); - if (referencedFile && ((referencedFile.flags & 8192) || + if (referencedFile && ((referencedFile.flags & 4096) || ts.shouldEmitToOwnFile(referencedFile, compilerOptions) || !addedGlobalFileReference)) { writeReferencePath(referencedFile); @@ -23405,15 +23824,15 @@ var ts; } } function emitLines(nodes) { - for (var _i = 0; _i < nodes.length; _i++) { - var node = nodes[_i]; + for (var _i = 0, nodes_2 = nodes; _i < nodes_2.length; _i++) { + var node = nodes_2[_i]; emit(node); } } function emitSeparatedList(nodes, separator, eachNodeEmitFn, canEmitFn) { var currentWriterPos = writer.getTextPos(); - for (var _i = 0; _i < nodes.length; _i++) { - var node = nodes[_i]; + for (var _i = 0, nodes_3 = nodes; _i < nodes_3.length; _i++) { + var node = nodes_3[_i]; if (!canEmitFn || canEmitFn(node)) { if (currentWriterPos !== writer.getTextPos()) { write(separator); @@ -23555,6 +23974,7 @@ var ts; function emitSourceFile(node) { currentSourceFile = node; enclosingDeclaration = node; + ts.emitDetachedComments(currentSourceFile, writer, ts.writeCommentRange, node, newLine, true); emitLines(node.statements); } function getExportDefaultTempVariableName() { @@ -23661,10 +24081,10 @@ var ts; } function emitModuleElementDeclarationFlags(node) { if (node.parent === currentSourceFile) { - if (node.flags & 1) { + if (node.flags & 2) { write("export "); } - if (node.flags & 1024) { + if (node.flags & 512) { write("default "); } else if (node.kind !== 215) { @@ -23673,22 +24093,22 @@ var ts; } } function emitClassMemberDeclarationFlags(node) { - if (node.flags & 32) { + if (node.flags & 16) { write("private "); } - else if (node.flags & 64) { + else if (node.flags & 32) { write("protected "); } - if (node.flags & 128) { + if (node.flags & 64) { write("static "); } - if (node.flags & 256) { + if (node.flags & 128) { write("abstract "); } } function writeImportEqualsDeclaration(node) { emitJsDocComments(node); - if (node.flags & 1) { + if (node.flags & 2) { write("export "); } write("import "); @@ -23723,11 +24143,11 @@ var ts; } } function writeImportDeclaration(node) { - if (!node.importClause && !(node.flags & 1)) { + if (!node.importClause && !(node.flags & 2)) { return; } emitJsDocComments(node); - if (node.flags & 1) { + if (node.flags & 2) { write("export "); } write("import "); @@ -23789,7 +24209,7 @@ var ts; function writeModuleDeclaration(node) { emitJsDocComments(node); emitModuleElementDeclarationFlags(node); - if (node.flags & 131072) { + if (node.flags & 65536) { write("namespace "); } else { @@ -23861,7 +24281,7 @@ var ts; writeLine(); } function isPrivateMethodTypeParameter(node) { - return node.parent.kind === 143 && (node.parent.flags & 32); + return node.parent.kind === 143 && (node.parent.flags & 16); } function emitTypeParameters(typeParameters) { function emitTypeParameter(node) { @@ -23903,7 +24323,7 @@ var ts; break; case 143: case 142: - if (node.parent.flags & 128) { + if (node.parent.flags & 64) { 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 === 214) { @@ -23966,7 +24386,7 @@ var ts; function emitParameterProperties(constructorDeclaration) { if (constructorDeclaration) { ts.forEach(constructorDeclaration.parameters, function (param) { - if (param.flags & 112) { + if (param.flags & 56) { emitPropertyDeclaration(param); } }); @@ -23974,7 +24394,7 @@ var ts; } emitJsDocComments(node); emitModuleElementDeclarationFlags(node); - if (node.flags & 256) { + if (node.flags & 128) { write("abstract "); } write("class "); @@ -24038,7 +24458,7 @@ var ts; if ((node.kind === 141 || node.kind === 140) && node.parent.kind === 155) { emitTypeOfVariableDeclarationFromTypeLiteral(node); } - else if (!(node.flags & 32)) { + else if (!(node.flags & 16)) { writeTypeOfDeclaration(node, node.type, getVariableDeclarationTypeVisibilityError); } } @@ -24052,7 +24472,7 @@ var ts; ts.Diagnostics.Exported_variable_0_has_or_is_using_private_name_1; } else if (node.kind === 141 || node.kind === 140) { - if (node.flags & 128) { + if (node.flags & 64) { return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 ? ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -24147,7 +24567,7 @@ var ts; emitJsDocComments(accessors.setAccessor); emitClassMemberDeclarationFlags(node); writeTextOfNode(currentSourceFile, node.name); - if (!(node.flags & 32)) { + if (!(node.flags & 16)) { accessorWithTypeAnnotation = node; var type = getTypeAnnotationFromAccessor(node); if (!type) { @@ -24174,7 +24594,7 @@ var ts; function getAccessorDeclarationTypeVisibilityError(symbolAccesibilityResult) { var diagnosticMessage; if (accessorWithTypeAnnotation.kind === 146) { - if (accessorWithTypeAnnotation.parent.flags & 128) { + if (accessorWithTypeAnnotation.parent.flags & 64) { diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_public_static_property_setter_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_public_static_property_setter_from_exported_class_has_or_is_using_private_name_1; @@ -24191,7 +24611,7 @@ var ts; }; } else { - if (accessorWithTypeAnnotation.flags & 128) { + if (accessorWithTypeAnnotation.flags & 64) { diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 ? ts.Diagnostics.Return_type_of_public_static_property_getter_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : @@ -24272,7 +24692,7 @@ var ts; emitType(node.type); } } - else if (node.kind !== 144 && !(node.flags & 32)) { + else if (node.kind !== 144 && !(node.flags & 16)) { writeReturnTypeAtSignature(node, getReturnTypeVisibilityError); } enclosingDeclaration = prevEnclosingDeclaration; @@ -24300,7 +24720,7 @@ var ts; break; case 143: case 142: - if (node.flags & 128) { + if (node.flags & 64) { diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 ? ts.Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : @@ -24357,7 +24777,7 @@ var ts; node.parent.parent.kind === 155) { emitTypeOfVariableDeclarationFromTypeLiteral(node); } - else if (!(node.parent.flags & 32)) { + else if (!(node.parent.flags & 16)) { writeTypeOfDeclaration(node, node.type, getParameterDeclarationTypeVisibilityError); } function getParameterDeclarationTypeVisibilityError(symbolAccesibilityResult) { @@ -24386,7 +24806,7 @@ var ts; ts.Diagnostics.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; case 143: case 142: - if (node.parent.flags & 128) { + if (node.parent.flags & 64) { return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 ? ts.Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -24502,7 +24922,7 @@ var ts; } } function writeReferencePath(referencedFile) { - var declFileName = referencedFile.flags & 8192 + var declFileName = referencedFile.flags & 4096 ? referencedFile.fileName : ts.shouldEmitToOwnFile(referencedFile, compilerOptions) ? ts.getOwnEmitOutputFilePath(referencedFile, host, ".d.ts") @@ -24835,16 +25255,8 @@ var ts; diagnostics: diagnostics, sourceMaps: sourceMapDataList }; - function isNodeDescendentOf(node, ancestor) { - while (node) { - if (node === ancestor) - return true; - node = node.parent; - } - return false; - } function isUniqueLocalName(name, container) { - for (var node = container; isNodeDescendentOf(node, container); node = node.nextContainer) { + for (var node = container; ts.isNodeDescendentOf(node, container); node = node.nextContainer) { if (node.locals && ts.hasProperty(node.locals, name)) { if (node.locals[name].flags & (107455 | 1048576 | 8388608)) { return false; @@ -26137,7 +26549,7 @@ var ts; write("]"); } else { - emitListWithSpread(elements, true, (node.flags & 2048) !== 0, elements.hasTrailingComma, true); + emitListWithSpread(elements, true, (node.flags & 1024) !== 0, elements.hasTrailingComma, true); } } function emitObjectLiteralBody(node, numElements) { @@ -26152,7 +26564,7 @@ var ts; emitLinePreservingList(node, properties, languageVersion >= 1, true); } else { - var multiLine = (node.flags & 2048) !== 0; + var multiLine = (node.flags & 1024) !== 0; if (!multiLine) { write(" "); } @@ -26171,7 +26583,7 @@ var ts; write("}"); } function emitDownlevelObjectLiteralWithComputedProperties(node, firstComputedPropertyIndex) { - var multiLine = (node.flags & 2048) !== 0; + var multiLine = (node.flags & 1024) !== 0; var properties = node.properties; write("("); if (multiLine) { @@ -26689,7 +27101,7 @@ var ts; var current = node; while (current) { if (current.kind === 248) { - return !isExported || ((ts.getCombinedNodeFlags(node) & 1) !== 0); + return !isExported || ((ts.getCombinedNodeFlags(node) & 2) !== 0); } else if (ts.isFunctionLike(current) || current.kind === 219) { return false; @@ -26907,7 +27319,7 @@ var ts; if (shouldHoistVariable(decl, true)) { return false; } - if (convertedLoopState && (ts.getCombinedNodeFlags(decl) & 49152) === 0) { + if (convertedLoopState && (ts.getCombinedNodeFlags(decl) & 24576) === 0) { for (var _a = 0, _b = decl.declarations; _a < _b.length; _a++) { var varDecl = _b[_a]; hoistVariableDeclarationFromLoop(convertedLoopState, varDecl); @@ -26989,7 +27401,7 @@ var ts; break; } var loopParameters; - if (loopInitializer && (ts.getCombinedNodeFlags(loopInitializer) & 49152)) { + if (loopInitializer && (ts.getCombinedNodeFlags(loopInitializer) & 24576)) { loopParameters = []; for (var _a = 0, _b = loopInitializer.declarations; _a < _b.length; _a++) { var varDeclaration = _b[_a]; @@ -27246,22 +27658,22 @@ var ts; var endPos = emitToken(86, node.pos); write(" "); endPos = emitToken(17, endPos); - var rhsIsIdentifier = node.expression.kind === 69; var counter = createTempVariable(268435456); - var rhsReference = rhsIsIdentifier ? node.expression : createTempVariable(0); + var rhsReference = ts.createSynthesizedNode(69); + rhsReference.text = node.expression.kind === 69 ? + makeUniqueName(node.expression.text) : + makeTempVariableName(0); emitStart(node.expression); write("var "); emitNodeWithoutSourceMap(counter); write(" = 0"); emitEnd(node.expression); - if (!rhsIsIdentifier) { - write(", "); - emitStart(node.expression); - emitNodeWithoutSourceMap(rhsReference); - write(" = "); - emitNodeWithoutSourceMap(node.expression); - emitEnd(node.expression); - } + write(", "); + emitStart(node.expression); + emitNodeWithoutSourceMap(rhsReference); + write(" = "); + emitNodeWithoutSourceMap(node.expression); + emitEnd(node.expression); write("; "); emitStart(node.initializer); emitNodeWithoutSourceMap(counter); @@ -27496,7 +27908,7 @@ var ts; } function emitModuleMemberName(node) { emitStart(node.name); - if (ts.getCombinedNodeFlags(node) & 1) { + if (ts.getCombinedNodeFlags(node) & 2) { var container = getContainingModule(node); if (container) { write(getGeneratedNameForNode(container)); @@ -27518,7 +27930,7 @@ var ts; } function emitEs6ExportDefaultCompat(node) { if (node.parent.kind === 248) { - ts.Debug.assert(!!(node.flags & 1024) || node.kind === 227); + ts.Debug.assert(!!(node.flags & 512) || node.kind === 227); if (modulekind === 1 || modulekind === 2 || modulekind === 3) { if (!currentSourceFile.symbol.exports["___esModule"]) { if (languageVersion === 1) { @@ -27534,12 +27946,12 @@ var ts; } } function emitExportMemberAssignment(node) { - if (node.flags & 1) { + if (node.flags & 2) { writeLine(); emitStart(node); if (modulekind === 4 && node.parent === currentSourceFile) { write(exportFunctionForFile + "(\""); - if (node.flags & 1024) { + if (node.flags & 512) { write("default"); } else { @@ -27550,7 +27962,7 @@ var ts; write(")"); } else { - if (node.flags & 1024) { + if (node.flags & 512) { emitEs6ExportDefaultCompat(node); if (languageVersion === 0) { write("exports[\"default\"]"); @@ -27638,7 +28050,7 @@ var ts; var emitCount = 0; var canDefineTempVariablesInPlace = false; if (root.kind === 211) { - var isExported = ts.getCombinedNodeFlags(root) & 1; + var isExported = ts.getCombinedNodeFlags(root) & 2; var isSourceLevelForSystemModuleKind = shouldHoistDeclarationInSystemJsModule(root); canDefineTempVariablesInPlace = !isExported && !isSourceLevelForSystemModuleKind; } @@ -27704,8 +28116,8 @@ var ts; if (properties.length !== 1) { value = ensureIdentifier(value, true); } - for (var _a = 0; _a < properties.length; _a++) { - var p = properties[_a]; + for (var _a = 0, properties_5 = properties; _a < properties_5.length; _a++) { + var p = properties_5[_a]; if (p.kind === 245 || p.kind === 246) { var propName = p.name; var target_1 = p.kind === 246 ? p : p.initializer || propName; @@ -27824,7 +28236,7 @@ var ts; var initializer = node.initializer; if (!initializer && languageVersion < 2) { var isLetDefinedInLoop = (resolver.getNodeCheckFlags(node) & 16384) && - (getCombinedFlagsForIdentifier(node.name) & 16384); + (getCombinedFlagsForIdentifier(node.name) & 8192); if (isLetDefinedInLoop && node.parent.parent.kind !== 200 && node.parent.parent.kind !== 201) { @@ -27863,13 +28275,13 @@ var ts; return ts.getCombinedNodeFlags(node.parent); } function isES6ExportedDeclaration(node) { - return !!(node.flags & 1) && + return !!(node.flags & 2) && modulekind === 5 && node.parent.kind === 248; } function emitVariableStatement(node) { var startIsEmitted = false; - if (node.flags & 1) { + if (node.flags & 2) { if (isES6ExportedDeclaration(node)) { write("export "); startIsEmitted = tryEmitStartOfVariableDeclarationList(node.declarationList); @@ -27893,7 +28305,7 @@ var ts; } } function shouldEmitLeadingAndTrailingCommentsForVariableStatement(node) { - if (!(node.flags & 1)) { + if (!(node.flags & 2)) { return true; } if (isES6ExportedDeclaration(node)) { @@ -28050,7 +28462,7 @@ var ts; if (!shouldEmitAsArrowFunction(node)) { if (isES6ExportedDeclaration(node)) { write("export "); - if (node.flags & 1024) { + if (node.flags & 512) { write("default "); } } @@ -28189,7 +28601,7 @@ var ts; emitRestParameter(node); } function emitExpressionFunctionBody(node, body) { - if (languageVersion < 2 || node.flags & 512) { + if (languageVersion < 2 || node.flags & 256) { emitDownLevelExpressionFunctionBody(node, body); return; } @@ -28205,7 +28617,7 @@ var ts; scopeEmitStart(node); increaseIndent(); var outPos = writer.getTextPos(); - emitDetachedComments(node.body); + emitDetachedCommentsAndUpdateCommentsInfo(node.body); emitFunctionBodyPreamble(node); var preambleEmitted = writer.getTextPos() !== outPos; decreaseIndent(); @@ -28241,7 +28653,7 @@ var ts; scopeEmitStart(node); var initialTextPos = writer.getTextPos(); increaseIndent(); - emitDetachedComments(body.statements); + emitDetachedCommentsAndUpdateCommentsInfo(body.statements); var startIndex = emitDirectivePrologues(body.statements, true); emitFunctionBodyPreamble(node); decreaseIndent(); @@ -28283,7 +28695,7 @@ var ts; } function emitParameterPropertyAssignments(node) { ts.forEach(node.parameters, function (param) { - if (param.flags & 112) { + if (param.flags & 56) { writeLine(); emitStart(param); emitStart(param.name); @@ -28315,15 +28727,15 @@ var ts; var properties = []; for (var _a = 0, _b = node.members; _a < _b.length; _a++) { var member = _b[_a]; - if (member.kind === 141 && isStatic === ((member.flags & 128) !== 0) && member.initializer) { + if (member.kind === 141 && isStatic === ((member.flags & 64) !== 0) && member.initializer) { properties.push(member); } } return properties; } function emitPropertyDeclarations(node, properties) { - for (var _a = 0; _a < properties.length; _a++) { - var property = properties[_a]; + for (var _a = 0, properties_6 = properties; _a < properties_6.length; _a++) { + var property = properties_6[_a]; emitPropertyDeclaration(node, property); } } @@ -28336,7 +28748,7 @@ var ts; emit(receiver); } else { - if (property.flags & 128) { + if (property.flags & 64) { emitDeclarationName(node); } else { @@ -28435,7 +28847,7 @@ var ts; writeLine(); emitLeadingComments(member); emitStart(member); - if (member.flags & 128) { + if (member.flags & 64) { write("static "); } if (member.kind === 145) { @@ -28480,7 +28892,7 @@ var ts; if (member.kind === 144 && !member.body) { emitCommentsOnNotEmittedNode(member); } - if (member.kind === 141 && member.initializer && (member.flags & 128) === 0) { + if (member.kind === 141 && member.initializer && (member.flags & 64) === 0) { hasInstancePropertyWithInitializer = true; } }); @@ -28517,7 +28929,7 @@ var ts; increaseIndent(); if (ctor) { startIndex = emitDirectivePrologues(ctor.body.statements, true); - emitDetachedComments(ctor.body.statements); + emitDetachedCommentsAndUpdateCommentsInfo(ctor.body.statements); } emitCaptureThisForNodeIfNecessary(node); var superCall; @@ -28588,7 +29000,7 @@ var ts; var thisNodeIsDecorated = ts.nodeIsDecorated(node); if (node.kind === 214) { if (thisNodeIsDecorated) { - if (isES6ExportedDeclaration(node) && !(node.flags & 1024)) { + if (isES6ExportedDeclaration(node) && !(node.flags & 512)) { write("export "); } write("let "); @@ -28597,7 +29009,7 @@ var ts; } else if (isES6ExportedDeclaration(node)) { write("export "); - if (node.flags & 1024) { + if (node.flags & 512) { write("default "); } } @@ -28613,7 +29025,7 @@ var ts; write(" = "); } write("class"); - if ((node.name || (node.flags & 1024 && staticProperties.length > 0)) && !thisNodeIsDecorated) { + if ((node.name || (node.flags & 512 && staticProperties.length > 0)) && !thisNodeIsDecorated) { write(" "); emitDeclarationName(node); } @@ -28636,8 +29048,8 @@ var ts; write(";"); } if (isClassExpressionWithStaticProperties) { - for (var _a = 0; _a < staticProperties.length; _a++) { - var property = staticProperties[_a]; + for (var _a = 0, staticProperties_1 = staticProperties; _a < staticProperties_1.length; _a++) { + var property = staticProperties_1[_a]; write(","); writeLine(); emitPropertyDeclaration(node, property, tempVariable, true); @@ -28653,7 +29065,7 @@ var ts; emitPropertyDeclarations(node, staticProperties); emitDecoratorsOfClass(node); } - if (!isES6ExportedDeclaration(node) && (node.flags & 1)) { + if (!isES6ExportedDeclaration(node) && (node.flags & 2)) { writeLine(); emitStart(node); emitModuleMemberName(node); @@ -28662,7 +29074,7 @@ var ts; emitEnd(node); write(";"); } - else if (isES6ExportedDeclaration(node) && (node.flags & 1024) && thisNodeIsDecorated) { + else if (isES6ExportedDeclaration(node) && (node.flags & 512) && thisNodeIsDecorated) { writeLine(); write("export default "); emitDeclarationName(node); @@ -28742,13 +29154,13 @@ var ts; } function emitClassMemberPrefix(node, member) { emitDeclarationName(node); - if (!(member.flags & 128)) { + if (!(member.flags & 64)) { write(".prototype"); } } function emitDecoratorsOfClass(node) { emitDecoratorsOfMembers(node, 0); - emitDecoratorsOfMembers(node, 128); + emitDecoratorsOfMembers(node, 64); emitDecoratorsOfConstructor(node); } function emitDecoratorsOfConstructor(node) { @@ -28783,7 +29195,7 @@ var ts; function emitDecoratorsOfMembers(node, staticFlag) { for (var _a = 0, _b = node.members; _a < _b.length; _a++) { var member = _b[_a]; - if ((member.flags & 128) !== staticFlag) { + if ((member.flags & 64) !== staticFlag) { continue; } if (!ts.nodeCanBeDecorated(member)) { @@ -29110,7 +29522,7 @@ var ts; return; } if (!shouldHoistDeclarationInSystemJsModule(node)) { - if (!(node.flags & 1) || isES6ExportedDeclaration(node)) { + if (!(node.flags & 2) || isES6ExportedDeclaration(node)) { emitStart(node); if (isES6ExportedDeclaration(node)) { write("export "); @@ -29141,7 +29553,7 @@ var ts; emitModuleMemberName(node); write(" = {}));"); emitEnd(node); - if (!isES6ExportedDeclaration(node) && node.flags & 1 && !shouldHoistDeclarationInSystemJsModule(node)) { + if (!isES6ExportedDeclaration(node) && node.flags & 2 && !shouldHoistDeclarationInSystemJsModule(node)) { writeLine(); emitStart(node); write("var "); @@ -29152,7 +29564,7 @@ var ts; write(";"); } if (modulekind !== 5 && node.parent === currentSourceFile) { - if (modulekind === 4 && (node.flags & 1)) { + if (modulekind === 4 && (node.flags & 2)) { writeLine(); write(exportFunctionForFile + "(\""); emitDeclarationName(node); @@ -29254,7 +29666,7 @@ var ts; scopeEmitEnd(); } write(")("); - if ((node.flags & 1) && !isES6ExportedDeclaration(node)) { + if ((node.flags & 2) && !isES6ExportedDeclaration(node)) { emit(node.name); write(" = "); } @@ -29264,7 +29676,7 @@ var ts; write(" = {}));"); emitEnd(node); if (!isES6ExportedDeclaration(node) && node.name.kind === 69 && node.parent === currentSourceFile) { - if (modulekind === 4 && (node.flags & 1)) { + if (modulekind === 4 && (node.flags & 2)) { writeLine(); write(exportFunctionForFile + "(\""); emitDeclarationName(node); @@ -29362,7 +29774,7 @@ var ts; } function emitExternalImportDeclaration(node) { if (ts.contains(externalImports, node)) { - var isExportedImport = node.kind === 221 && (node.flags & 1) !== 0; + var isExportedImport = node.kind === 221 && (node.flags & 2) !== 0; var namespaceDeclaration = getNamespaceDeclarationNode(node); if (modulekind !== 2) { emitLeadingComments(node); @@ -29428,7 +29840,7 @@ var ts; write("export "); write("var "); } - else if (!(node.flags & 1)) { + else if (!(node.flags & 2)) { write("var "); } } @@ -29516,8 +29928,8 @@ var ts; function emitExportOrImportSpecifierList(specifiers, shouldEmit) { ts.Debug.assert(modulekind === 5); var needsComma = false; - for (var _a = 0; _a < specifiers.length; _a++) { - var specifier = specifiers[_a]; + for (var _a = 0, specifiers_1 = specifiers; _a < specifiers_1.length; _a++) { + var specifier = specifiers_1[_a]; if (shouldEmit(specifier)) { if (needsComma) { write(", "); @@ -29651,8 +30063,8 @@ var ts; } writeLine(); var started = false; - for (var _a = 0; _a < externalImports.length; _a++) { - var importNode = externalImports[_a]; + for (var _a = 0, externalImports_1 = externalImports; _a < externalImports_1.length; _a++) { + var importNode = externalImports_1[_a]; var skipNode = importNode.kind === 228 || (importNode.kind === 222 && !importNode.importClause); if (skipNode) { @@ -29677,8 +30089,8 @@ var ts; } if (!exportedDeclarations && ts.isEmpty(exportSpecifiers)) { var hasExportDeclarationWithExportClause = false; - for (var _a = 0; _a < externalImports.length; _a++) { - var externalImport = externalImports[_a]; + for (var _a = 0, externalImports_2 = externalImports; _a < externalImports_2.length; _a++) { + var externalImport = externalImports_2[_a]; if (externalImport.kind === 228 && externalImport.exportClause) { hasExportDeclarationWithExportClause = true; break; @@ -29706,8 +30118,8 @@ var ts; } } } - for (var _d = 0; _d < externalImports.length; _d++) { - var externalImport = externalImports[_d]; + for (var _d = 0, externalImports_3 = externalImports; _d < externalImports_3.length; _d++) { + var externalImport = externalImports_3[_d]; if (externalImport.kind !== 228) { continue; } @@ -29751,7 +30163,7 @@ var ts; return exportStarFunction; } function writeExportedName(node) { - if (node.kind !== 69 && node.flags & 1024) { + if (node.kind !== 69 && node.flags & 512) { return; } if (started) { @@ -29804,7 +30216,7 @@ var ts; emit(local); } var flags = ts.getCombinedNodeFlags(local.kind === 69 ? local.parent : local); - if (flags & 1) { + if (flags & 2) { if (!exportedDeclarations) { exportedDeclarations = []; } @@ -29814,11 +30226,11 @@ var ts; write(";"); } if (hoistedFunctionDeclarations) { - for (var _a = 0; _a < hoistedFunctionDeclarations.length; _a++) { - var f = hoistedFunctionDeclarations[_a]; + for (var _a = 0, hoistedFunctionDeclarations_1 = hoistedFunctionDeclarations; _a < hoistedFunctionDeclarations_1.length; _a++) { + var f = hoistedFunctionDeclarations_1[_a]; writeLine(); emit(f); - if (f.flags & 1) { + if (f.flags & 2) { if (!exportedDeclarations) { exportedDeclarations = []; } @@ -29828,7 +30240,7 @@ var ts; } return exportedDeclarations; function visit(node) { - if (node.flags & 2) { + if (node.flags & 4) { return; } if (node.kind === 213) { @@ -29898,7 +30310,7 @@ var ts; if (checkIfSourceFileLevelDecl && !shouldHoistDeclarationInSystemJsModule(node)) { return false; } - return (ts.getCombinedNodeFlags(node) & 49152) === 0 || + return (ts.getCombinedNodeFlags(node) & 24576) === 0 || ts.getEnclosingBlockScopeContainer(node).kind === 248; } function isCurrentFileSystemExternalModule() { @@ -29933,8 +30345,8 @@ var ts; var parameterName = makeUniqueName(ts.forEach(group, getLocalNameForExternalImport) || ""); write("function (" + parameterName + ") {"); increaseIndent(); - for (var _a = 0; _a < group.length; _a++) { - var entry = group[_a]; + for (var _a = 0, group_1 = group; _a < group_1.length; _a++) { + var entry = group_1[_a]; var importVariableName = getLocalNameForExternalImport(entry) || ""; switch (entry.kind) { case 222: @@ -30068,8 +30480,8 @@ var ts; unaliasedModuleNames.push("\"" + amdDependency.path + "\""); } } - for (var _c = 0; _c < externalImports.length; _c++) { - var importNode = externalImports[_c]; + for (var _c = 0, externalImports_4 = externalImports; _c < externalImports_4.length; _c++) { + var importNode = externalImports_4[_c]; var externalModuleName = getExternalModuleNameText(importNode); var importAliasName = getLocalNameForExternalImport(importNode); if (includeNonAmdDependencies && importAliasName) { @@ -30322,7 +30734,7 @@ var ts; function emitSourceFileNode(node) { writeLine(); emitShebang(); - emitDetachedComments(node); + emitDetachedCommentsAndUpdateCommentsInfo(node); if (ts.isExternalModule(node) || compilerOptions.isolatedModules) { var emitModule = moduleEmitDelegates[modulekind] || moduleEmitDelegates[1]; emitModule(node); @@ -30345,7 +30757,7 @@ var ts; } function emitNodeConsideringCommentsOption(node, emitNodeConsideringSourcemap) { if (node) { - if (node.flags & 2) { + if (node.flags & 4) { return emitCommentsOnNotEmittedNode(node); } if (isSpecializedCommentHandling(node)) { @@ -30578,10 +30990,6 @@ var ts; } return leadingComments; } - function isPinnedComments(comment) { - return currentSourceFile.text.charCodeAt(comment.pos + 1) === 42 && - currentSourceFile.text.charCodeAt(comment.pos + 2) === 33; - } function isTripleSlashComment(comment) { if (currentSourceFile.text.charCodeAt(comment.pos + 1) === 47 && comment.pos + 2 < comment.end && @@ -30662,44 +31070,14 @@ var ts; ts.emitNewLineBeforeLeadingComments(currentSourceFile, writer, { pos: pos, end: pos }, leadingComments); ts.emitComments(currentSourceFile, writer, leadingComments, true, newLine, writeComment); } - function emitDetachedComments(node) { - var leadingComments; - if (compilerOptions.removeComments) { - if (node.pos === 0) { - leadingComments = ts.filter(ts.getLeadingCommentRanges(currentSourceFile.text, node.pos), isPinnedComments); + function emitDetachedCommentsAndUpdateCommentsInfo(node) { + var currentDetachedCommentInfo = ts.emitDetachedComments(currentSourceFile, writer, writeComment, node, newLine, compilerOptions.removeComments); + if (currentDetachedCommentInfo) { + if (detachedCommentsInfo) { + detachedCommentsInfo.push(currentDetachedCommentInfo); } - } - else { - leadingComments = ts.getLeadingCommentRanges(currentSourceFile.text, node.pos); - } - if (leadingComments) { - var detachedComments = []; - var lastComment; - ts.forEach(leadingComments, function (comment) { - if (lastComment) { - var lastCommentLine = ts.getLineOfLocalPosition(currentSourceFile, lastComment.end); - var commentLine = ts.getLineOfLocalPosition(currentSourceFile, comment.pos); - if (commentLine >= lastCommentLine + 2) { - return detachedComments; - } - } - detachedComments.push(comment); - lastComment = comment; - }); - if (detachedComments.length) { - var lastCommentLine = ts.getLineOfLocalPosition(currentSourceFile, ts.lastOrUndefined(detachedComments).end); - var nodeLine = ts.getLineOfLocalPosition(currentSourceFile, ts.skipTrivia(currentSourceFile.text, node.pos)); - if (nodeLine >= lastCommentLine + 2) { - ts.emitNewLineBeforeLeadingComments(currentSourceFile, writer, node, leadingComments); - ts.emitComments(currentSourceFile, writer, detachedComments, true, newLine, writeComment); - var currentDetachedCommentInfo = { nodePos: node.pos, detachedCommentEndPos: ts.lastOrUndefined(detachedComments).end }; - if (detachedCommentsInfo) { - detachedCommentsInfo.push(currentDetachedCommentInfo); - } - else { - detachedCommentsInfo = [currentDetachedCommentInfo]; - } - } + else { + detachedCommentsInfo = [currentDetachedCommentInfo]; } } } @@ -31002,7 +31380,7 @@ var ts; var resolveModuleNamesWorker = host.resolveModuleNames ? (function (moduleNames, containingFile) { return host.resolveModuleNames(moduleNames, containingFile); }) : (function (moduleNames, containingFile) { return ts.map(moduleNames, function (moduleName) { return resolveModuleName(moduleName, containingFile, options, host).resolvedModule; }); }); - var filesByName = ts.createFileMap(getCanonicalFileName); + var filesByName = ts.createFileMap(); var filesByNameIgnoreCase = host.useCaseSensitiveFileNames() ? ts.createFileMap(function (fileName) { return fileName.toLowerCase(); }) : undefined; if (oldProgram) { var oldOptions = oldProgram.getCompilerOptions(); @@ -31050,8 +31428,8 @@ var ts; if (!classifiableNames) { getTypeChecker(); classifiableNames = {}; - for (var _i = 0; _i < files.length; _i++) { - var sourceFile = files[_i]; + for (var _i = 0, files_3 = files; _i < files_3.length; _i++) { + var sourceFile = files_3[_i]; ts.copyMap(sourceFile.classifiableNames, classifiableNames); } } @@ -31067,7 +31445,7 @@ var ts; return false; } var newSourceFiles = []; - var normalizedAbsoluteFileNames = []; + var filePaths = []; var modifiedSourceFiles = []; for (var _i = 0, _a = oldProgram.getSourceFiles(); _i < _a.length; _i++) { var oldSourceFile = _a[_i]; @@ -31075,8 +31453,8 @@ var ts; if (!newSourceFile) { return false; } - var normalizedAbsolutePath = ts.getNormalizedAbsolutePath(newSourceFile.fileName, currentDirectory); - normalizedAbsoluteFileNames.push(normalizedAbsolutePath); + newSourceFile.path = oldSourceFile.path; + filePaths.push(newSourceFile.path); if (oldSourceFile !== newSourceFile) { if (oldSourceFile.hasNoDefaultLib !== newSourceFile.hasNoDefaultLib) { return false; @@ -31090,7 +31468,7 @@ var ts; } if (resolveModuleNamesWorker) { var moduleNames = ts.map(newSourceFile.imports, function (name) { return name.text; }); - var resolutions = resolveModuleNamesWorker(moduleNames, normalizedAbsolutePath); + var resolutions = resolveModuleNamesWorker(moduleNames, ts.getNormalizedAbsolutePath(newSourceFile.fileName, currentDirectory)); for (var i = 0; i < moduleNames.length; ++i) { var newResolution = resolutions[i]; var oldResolution = ts.getResolvedModule(oldSourceFile, moduleNames[i]); @@ -31113,12 +31491,12 @@ var ts; newSourceFiles.push(newSourceFile); } for (var i = 0, len = newSourceFiles.length; i < len; ++i) { - filesByName.set(normalizedAbsoluteFileNames[i], newSourceFiles[i]); + filesByName.set(filePaths[i], newSourceFiles[i]); } files = newSourceFiles; fileProcessingDiagnostics = oldProgram.getFileProcessingDiagnostics(); - for (var _b = 0; _b < modifiedSourceFiles.length; _b++) { - var modifiedFile = modifiedSourceFiles[_b]; + for (var _b = 0, modifiedSourceFiles_1 = modifiedSourceFiles; _b < modifiedSourceFiles_1.length; _b++) { + var modifiedFile = modifiedSourceFiles_1[_b]; fileProcessingDiagnostics.reattachFileDiagnostics(modifiedFile); } oldProgram.structureIsReused = true; @@ -31157,7 +31535,7 @@ var ts; return emitResult; } function getSourceFile(fileName) { - return filesByName.get(ts.getNormalizedAbsolutePath(fileName, currentDirectory)); + return filesByName.get(ts.toPath(fileName, currentDirectory, getCanonicalFileName)); } function getDiagnosticsHelper(sourceFile, getDiagnostics, cancellationToken) { if (sourceFile) { @@ -31266,7 +31644,7 @@ var ts; } break; case 218: - if (node.name.kind === 9 && (node.flags & 2 || ts.isDeclarationFile(file))) { + if (node.name.kind === 9 && (node.flags & 4 || ts.isDeclarationFile(file))) { ts.forEachChild(node.body, function (node) { collect(node, false); }); @@ -31283,7 +31661,7 @@ var ts; diagnostic = ts.Diagnostics.File_0_has_unsupported_extension_The_only_supported_extensions_are_1; diagnosticArgument = [fileName, "'" + ts.supportedExtensions.join("', '") + "'"]; } - else if (!findSourceFile(fileName, ts.getNormalizedAbsolutePath(fileName, currentDirectory), isDefaultLib, 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]; } @@ -31293,13 +31671,13 @@ var ts; } } else { - var nonTsFile = options.allowNonTsExtensions && findSourceFile(fileName, ts.getNormalizedAbsolutePath(fileName, currentDirectory), isDefaultLib, 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(ts.supportedExtensions, function (extension) { return findSourceFile(fileName + extension, ts.getNormalizedAbsolutePath(fileName + extension, currentDirectory), isDefaultLib, refFile, refPos, refEnd); })) { + else if (!ts.forEach(ts.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]; @@ -31341,6 +31719,7 @@ var ts; }); filesByName.set(normalizedAbsolutePath, file); if (file) { + file.path = normalizedAbsolutePath; if (host.useCaseSensitiveFileNames()) { var existingFile = filesByNameIgnoreCase.get(normalizedAbsolutePath); if (existingFile) { @@ -31385,11 +31764,7 @@ var ts; var resolution = resolutions[i]; ts.setResolvedModule(file, moduleNames[i], resolution); if (resolution && !options.noResolve) { - var absoluteImportPath = ts.isRootedDiskPath(resolution.resolvedFileName) - ? resolution.resolvedFileName - : ts.getNormalizedAbsolutePath(resolution.resolvedFileName, currentDirectory); - var relativePath = ts.getRelativePathToDirectoryOrUrl(currentDirectory, absoluteImportPath, currentDirectory, getCanonicalFileName, false); - var importedFile = findSourceFile(relativePath, absoluteImportPath, false, file, ts.skipTrivia(file.text, file.imports[i].pos), file.imports[i].end); + var importedFile = findSourceFile(resolution.resolvedFileName, ts.toPath(resolution.resolvedFileName, currentDirectory, getCanonicalFileName), false, file, ts.skipTrivia(file.text, file.imports[i].pos), file.imports[i].end); if (importedFile && resolution.isExternalLibraryImport) { if (!ts.isExternalModule(importedFile)) { var start_2 = ts.getTokenPosOfNode(file.imports[i], file); @@ -31440,8 +31815,8 @@ var ts; var allFilesBelongToPath = true; if (sourceFiles) { var absoluteRootDirectoryPath = host.getCanonicalFileName(ts.getNormalizedAbsolutePath(rootDirectory, currentDirectory)); - for (var _i = 0; _i < sourceFiles.length; _i++) { - var sourceFile = sourceFiles[_i]; + for (var _i = 0, sourceFiles_1 = sourceFiles; _i < sourceFiles_1.length; _i++) { + var sourceFile = sourceFiles_1[_i]; if (!ts.isDeclarationFile(sourceFile)) { var absoluteSourceFilePath = host.getCanonicalFileName(ts.getNormalizedAbsolutePath(sourceFile.fileName, currentDirectory)); if (absoluteSourceFilePath.indexOf(absoluteRootDirectoryPath) !== 0) { @@ -31557,7 +31932,7 @@ var ts; var BreakpointResolver; (function (BreakpointResolver) { function spanInSourceFileAtLocation(sourceFile, position) { - if (sourceFile.flags & 8192) { + if (sourceFile.flags & 4096) { return undefined; } var tokenAtLocation = ts.getTokenAtPosition(sourceFile, position); @@ -31732,7 +32107,7 @@ var ts; : isDeclarationOfForStatement ? variableDeclaration.parent.parent.initializer.declarations : undefined; - if (variableDeclaration.initializer || (variableDeclaration.flags & 1)) { + if (variableDeclaration.initializer || (variableDeclaration.flags & 2)) { if (declarations && declarations[0] === variableDeclaration) { if (isParentVariableStatement) { return textSpan(variableDeclaration.parent, variableDeclaration); @@ -31753,7 +32128,7 @@ var ts; } function canHaveSpanInParameterDeclaration(parameter) { return !!parameter.initializer || parameter.dotDotDotToken !== undefined || - !!(parameter.flags & 16) || !!(parameter.flags & 32); + !!(parameter.flags & 8) || !!(parameter.flags & 16); } function spanInParameterDeclaration(parameter) { if (canHaveSpanInParameterDeclaration(parameter)) { @@ -31771,7 +32146,7 @@ var ts; } } function canFunctionHaveSpanInWholeDeclaration(functionDeclaration) { - return !!(functionDeclaration.flags & 1) || + return !!(functionDeclaration.flags & 2) || (functionDeclaration.parent.kind === 214 && functionDeclaration.kind !== 144); } function spanInFunctionDeclaration(functionDeclaration) { @@ -31853,7 +32228,6 @@ var ts; } case 244: return spanInNode(ts.lastOrUndefined(node.parent.statements)); - ; case 220: var caseBlock = node.parent; var lastClause = ts.lastOrUndefined(caseBlock.clauses); @@ -31888,7 +32262,6 @@ var ts; default: return spanInNode(node.parent); } - return spanInNode(node.parent); } function spanInColonToken(node) { if (ts.isFunctionLike(node.parent) || node.parent.kind === 245) { @@ -31949,8 +32322,8 @@ var ts; var lastSingleLineCommentEnd = -1; var isFirstSingleLineComment = true; var singleLineCommentCount = 0; - for (var _i = 0; _i < comments.length; _i++) { - var currentComment = comments[_i]; + for (var _i = 0, comments_2 = comments; _i < comments_2.length; _i++) { + var currentComment = comments_2[_i]; if (currentComment.kind === 2) { if (isFirstSingleLineComment) { firstSingleLineCommentStart = currentComment.pos; @@ -32071,6 +32444,7 @@ var ts; function getNavigateToItems(program, cancellationToken, searchValue, maxResultCount) { var patternMatcher = ts.createPatternMatcher(searchValue); var rawItems = []; + var baseSensitivity = { sensitivity: "base" }; ts.forEach(program.getSourceFiles(), function (sourceFile) { cancellationToken.throwIfCancellationRequested(); var nameToDeclarations = sourceFile.getNamedDeclarations(); @@ -32081,8 +32455,8 @@ var ts; if (!matches) { continue; } - for (var _i = 0; _i < declarations.length; _i++) { - var declaration = declarations[_i]; + for (var _i = 0, declarations_6 = declarations; _i < declarations_6.length; _i++) { + var declaration = declarations_6[_i]; if (patternMatcher.patternContainsDots) { var containers = getContainers(declaration); if (!containers) { @@ -32108,8 +32482,8 @@ var ts; return items; function allMatchesAreCaseSensitive(matches) { ts.Debug.assert(matches.length > 0); - for (var _i = 0; _i < matches.length; _i++) { - var match = matches[_i]; + for (var _i = 0, matches_1 = matches; _i < matches_1.length; _i++) { + var match = matches_1[_i]; if (!match.isCaseSensitive) { return false; } @@ -32177,8 +32551,8 @@ var ts; function bestMatchKind(matches) { ts.Debug.assert(matches.length > 0); var bestMatchKind = ts.PatternMatchKind.camelCase; - for (var _i = 0; _i < matches.length; _i++) { - var match = matches[_i]; + for (var _i = 0, matches_2 = matches; _i < matches_2.length; _i++) { + var match = matches_2[_i]; var kind = match.kind; if (kind < bestMatchKind) { bestMatchKind = kind; @@ -32186,7 +32560,6 @@ var ts; } return bestMatchKind; } - var baseSensitivity = { sensitivity: "base" }; function compareNavigateToItems(i1, i2) { return i1.matchKind - i2.matchKind || i1.name.localeCompare(i2.name, undefined, baseSensitivity) || @@ -32314,8 +32687,8 @@ var ts; } function addTopLevelNodes(nodes, topLevelNodes) { nodes = sortNodes(nodes); - for (var _i = 0; _i < nodes.length; _i++) { - var node = nodes[_i]; + for (var _i = 0, nodes_4 = nodes; _i < nodes_4.length; _i++) { + var node = nodes_4[_i]; switch (node.kind) { case 214: case 217: @@ -32353,8 +32726,8 @@ var ts; function getItemsWorker(nodes, createItem) { var items = []; var keyToItem = {}; - for (var _i = 0; _i < nodes.length; _i++) { - var child = nodes[_i]; + for (var _i = 0, nodes_5 = nodes; _i < nodes_5.length; _i++) { + var child = nodes_5[_i]; var item = createItem(child); if (item !== undefined) { if (item.text.length > 0) { @@ -32397,7 +32770,7 @@ var ts; if (ts.isBindingPattern(node.name)) { break; } - if ((node.flags & 2035) === 0) { + if ((node.flags & 1022) === 0) { return undefined; } return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberVariableElement); @@ -32661,8 +33034,8 @@ var ts; if (isLowercase) { if (index > 0) { var wordSpans = getWordSpans(candidate); - for (var _i = 0; _i < wordSpans.length; _i++) { - var span = wordSpans[_i]; + for (var _i = 0, wordSpans_1 = wordSpans; _i < wordSpans_1.length; _i++) { + var span = wordSpans_1[_i]; if (partStartsWith(candidate, span, chunk.text, true)) { return createPatternMatch(PatternMatchKind.substring, punctuationStripped, partStartsWith(candidate, span, chunk.text, false)); } @@ -32714,8 +33087,8 @@ var ts; } var subWordTextChunks = segment.subWordTextChunks; var matches = undefined; - for (var _i = 0; _i < subWordTextChunks.length; _i++) { - var subWordTextChunk = subWordTextChunks[_i]; + for (var _i = 0, subWordTextChunks_1 = subWordTextChunks; _i < subWordTextChunks_1.length; _i++) { + var subWordTextChunk = subWordTextChunks_1[_i]; var result = matchTextChunk(candidate, subWordTextChunk, true); if (!result) { return undefined; @@ -33078,8 +33451,8 @@ var ts; var nameToDeclarations = sourceFile_1.getNamedDeclarations(); var declarations = ts.getProperty(nameToDeclarations, name.text); if (declarations) { - for (var _b = 0; _b < declarations.length; _b++) { - var declaration = declarations[_b]; + for (var _b = 0, declarations_7 = declarations; _b < declarations_7.length; _b++) { + var declaration = declarations_7[_b]; var symbol = declaration.symbol; if (symbol) { var type = typeChecker.getTypeOfSymbolAtLocation(symbol, declaration); @@ -33155,8 +33528,8 @@ var ts; function getArgumentIndex(argumentsList, node) { var argumentIndex = 0; var listChildren = argumentsList.getChildren(); - for (var _i = 0; _i < listChildren.length; _i++) { - var child = listChildren[_i]; + for (var _i = 0, listChildren_1 = listChildren; _i < listChildren_1.length; _i++) { + var child = listChildren_1[_i]; if (child === node) { break; } @@ -33598,8 +33971,8 @@ var ts; return n; } var children = n.getChildren(); - for (var _i = 0; _i < children.length; _i++) { - var child = children[_i]; + for (var _i = 0, children_1 = children; _i < children_1.length; _i++) { + var child = children_1[_i]; var shouldDiveInChildNode = (child.pos <= previousToken.pos && child.end > previousToken.end) || (child.pos === previousToken.end); if (shouldDiveInChildNode && nodeHasTokens(child)) { @@ -33722,17 +34095,17 @@ var ts; function getNodeModifiers(node) { var flags = ts.getCombinedNodeFlags(node); var result = []; - if (flags & 32) - result.push(ts.ScriptElementKindModifier.privateMemberModifier); - if (flags & 64) - result.push(ts.ScriptElementKindModifier.protectedMemberModifier); if (flags & 16) + result.push(ts.ScriptElementKindModifier.privateMemberModifier); + if (flags & 32) + result.push(ts.ScriptElementKindModifier.protectedMemberModifier); + if (flags & 8) result.push(ts.ScriptElementKindModifier.publicMemberModifier); - if (flags & 128) + if (flags & 64) result.push(ts.ScriptElementKindModifier.staticModifier); - if (flags & 256) + if (flags & 128) result.push(ts.ScriptElementKindModifier.abstractModifier); - if (flags & 1) + if (flags & 2) result.push(ts.ScriptElementKindModifier.exportedModifier); if (ts.isInAmbientContext(node)) result.push(ts.ScriptElementKindModifier.ambientModifier); @@ -35533,8 +35906,8 @@ var ts; } } var inheritedIndentation = -1; - for (var _i = 0; _i < nodes.length; _i++) { - var child = nodes[_i]; + for (var _i = 0, nodes_6 = nodes; _i < nodes_6.length; _i++) { + var child = nodes_6[_i]; inheritedIndentation = processChildNode(child, inheritedIndentation, node, listDynamicIndentation, startLine, startLine, true); } if (listEndToken !== 0) { @@ -35616,8 +35989,8 @@ var ts; } } function processTrivia(trivia, parent, contextNode, dynamicIndentation) { - for (var _i = 0; _i < trivia.length; _i++) { - var triviaItem = trivia[_i]; + for (var _i = 0, trivia_1 = trivia; _i < trivia_1.length; _i++) { + var triviaItem = trivia_1[_i]; if (ts.isComment(triviaItem.kind) && ts.rangeContainsRange(originalRange, triviaItem)) { var triviaItemStart = sourceFile.getLineAndCharacterOfPosition(triviaItem.pos); processRange(triviaItem, triviaItemStart, parent, contextNode, dynamicIndentation); @@ -36146,7 +36519,6 @@ var ts; return node; } } - return node; } } function deriveActualIndentationFromList(list, index, sourceFile, options) { @@ -36374,17 +36746,17 @@ var ts; while (pos < end) { var token = scanner.scan(); var textPos = scanner.getTextPos(); - nodes.push(createNode(token, pos, textPos, 4096, this)); + nodes.push(createNode(token, pos, textPos, 2048, this)); pos = textPos; } return pos; }; NodeObject.prototype.createSyntaxList = function (nodes) { - var list = createNode(271, nodes.pos, nodes.end, 4096, this); + var list = createNode(271, nodes.pos, nodes.end, 2048, this); list._children = []; var pos = nodes.pos; - for (var _i = 0; _i < nodes.length; _i++) { - var node = nodes[_i]; + for (var _i = 0, nodes_7 = nodes; _i < nodes_7.length; _i++) { + var node = nodes_7[_i]; if (pos < node.pos) { pos = this.addSyntheticNodes(list._children, pos, node.pos); } @@ -36890,7 +37262,7 @@ var ts; } break; case 138: - if (!(node.flags & 112)) { + if (!(node.flags & 56)) { break; } case 211: @@ -37089,18 +37461,20 @@ var ts; var HostCache = (function () { function HostCache(host, getCanonicalFileName) { this.host = host; - this.fileNameToEntry = ts.createFileMap(getCanonicalFileName); + this.getCanonicalFileName = getCanonicalFileName; + this.currentDirectory = host.getCurrentDirectory(); + this.fileNameToEntry = ts.createFileMap(); var rootFileNames = host.getScriptFileNames(); - for (var _i = 0; _i < rootFileNames.length; _i++) { - var fileName = rootFileNames[_i]; - this.createEntry(fileName); + for (var _i = 0, rootFileNames_1 = rootFileNames; _i < rootFileNames_1.length; _i++) { + var fileName = rootFileNames_1[_i]; + this.createEntry(fileName, ts.toPath(fileName, this.currentDirectory, getCanonicalFileName)); } this._compilationSettings = host.getCompilationSettings() || getDefaultCompilerOptions(); } HostCache.prototype.compilationSettings = function () { return this._compilationSettings; }; - HostCache.prototype.createEntry = function (fileName) { + HostCache.prototype.createEntry = function (fileName, path) { var entry; var scriptSnapshot = this.host.getScriptSnapshot(fileName); if (scriptSnapshot) { @@ -37110,36 +37484,37 @@ var ts; scriptSnapshot: scriptSnapshot }; } - this.fileNameToEntry.set(fileName, entry); + this.fileNameToEntry.set(path, entry); return entry; }; - HostCache.prototype.getEntry = function (fileName) { - return this.fileNameToEntry.get(fileName); + HostCache.prototype.getEntry = function (path) { + return this.fileNameToEntry.get(path); }; - HostCache.prototype.contains = function (fileName) { - return this.fileNameToEntry.contains(fileName); + HostCache.prototype.contains = function (path) { + return this.fileNameToEntry.contains(path); }; HostCache.prototype.getOrCreateEntry = function (fileName) { - if (this.contains(fileName)) { - return this.getEntry(fileName); + var path = ts.toPath(fileName, this.currentDirectory, this.getCanonicalFileName); + if (this.contains(path)) { + return this.getEntry(path); } - return this.createEntry(fileName); + return this.createEntry(fileName, path); }; HostCache.prototype.getRootFileNames = function () { var fileNames = []; - this.fileNameToEntry.forEachValue(function (value) { + this.fileNameToEntry.forEachValue(function (path, value) { if (value) { fileNames.push(value.hostFileName); } }); return fileNames; }; - HostCache.prototype.getVersion = function (fileName) { - var file = this.getEntry(fileName); + HostCache.prototype.getVersion = function (path) { + var file = this.getEntry(path); return file && file.version; }; - HostCache.prototype.getScriptSnapshot = function (fileName) { - var file = this.getEntry(fileName); + HostCache.prototype.getScriptSnapshot = function (path) { + var file = this.getEntry(path); return file && file.scriptSnapshot; }; return HostCache; @@ -37282,7 +37657,8 @@ var ts; : (function (fileName) { return fileName.toLowerCase(); }); } ts.createGetCanonicalFileName = createGetCanonicalFileName; - function createDocumentRegistry(useCaseSensitiveFileNames) { + function createDocumentRegistry(useCaseSensitiveFileNames, currentDirectory) { + if (currentDirectory === void 0) { currentDirectory = ""; } var buckets = {}; var getCanonicalFileName = createGetCanonicalFileName(!!useCaseSensitiveFileNames); function getKeyFromCompilationSettings(settings) { @@ -37292,7 +37668,7 @@ var ts; var key = getKeyFromCompilationSettings(settings); var bucket = ts.lookUp(buckets, key); if (!bucket && createIfMissing) { - buckets[key] = bucket = ts.createFileMap(getCanonicalFileName); + buckets[key] = bucket = ts.createFileMap(); } return bucket; } @@ -37300,14 +37676,13 @@ var ts; var bucketInfoArray = Object.keys(buckets).filter(function (name) { return name && name.charAt(0) === '_'; }).map(function (name) { var entries = ts.lookUp(buckets, name); var sourceFiles = []; - for (var i in entries) { - var entry = entries.get(i); + entries.forEachValue(function (key, entry) { sourceFiles.push({ - name: i, + name: key, refCount: entry.languageServiceRefCount, references: entry.owners.slice(0) }); - } + }); sourceFiles.sort(function (x, y) { return y.refCount - x.refCount; }); return { bucket: name, @@ -37324,7 +37699,8 @@ var ts; } function acquireOrUpdateDocument(fileName, compilationSettings, scriptSnapshot, version, acquiring) { var bucket = getBucketForCompilationSettings(compilationSettings, true); - var entry = bucket.get(fileName); + var path = ts.toPath(fileName, currentDirectory, getCanonicalFileName); + var entry = bucket.get(path); if (!entry) { ts.Debug.assert(acquiring, "How could we be trying to update a document that the registry doesn't have?"); var sourceFile = createLanguageServiceSourceFile(fileName, scriptSnapshot, compilationSettings.target, version, false); @@ -37333,7 +37709,7 @@ var ts; languageServiceRefCount: 0, owners: [] }; - bucket.set(fileName, entry); + bucket.set(path, entry); } else { if (entry.sourceFile.version !== version) { @@ -37348,11 +37724,12 @@ var ts; function releaseDocument(fileName, compilationSettings) { var bucket = getBucketForCompilationSettings(compilationSettings, false); ts.Debug.assert(bucket !== undefined); - var entry = bucket.get(fileName); + var path = ts.toPath(fileName, currentDirectory, getCanonicalFileName); + var entry = bucket.get(path); entry.languageServiceRefCount--; ts.Debug.assert(entry.languageServiceRefCount >= 0); if (entry.languageServiceRefCount === 0) { - bucket.remove(fileName); + bucket.remove(path); } } return { @@ -37705,7 +38082,7 @@ var ts; case 144: return ScriptElementKind.constructorImplementationElement; case 137: return ScriptElementKind.typeParameterElement; case 247: return ScriptElementKind.variableElement; - case 138: return (node.flags & 112) ? ScriptElementKind.memberVariableElement : ScriptElementKind.parameterElement; + case 138: return (node.flags & 56) ? ScriptElementKind.memberVariableElement : ScriptElementKind.parameterElement; case 221: case 226: case 223: @@ -37731,13 +38108,14 @@ var ts; return CancellationTokenObject; })(); function createLanguageService(host, documentRegistry) { - if (documentRegistry === void 0) { documentRegistry = createDocumentRegistry(); } + if (documentRegistry === void 0) { documentRegistry = createDocumentRegistry(host.useCaseSensitiveFileNames && host.useCaseSensitiveFileNames(), host.getCurrentDirectory()); } var syntaxTreeCache = new SyntaxTreeCache(host); var ruleProvider; var program; var lastProjectVersion; var useCaseSensitivefileNames = false; var cancellationToken = new CancellationTokenObject(host.getCancellationToken && host.getCancellationToken()); + var currentDirectory = host.getCurrentDirectory(); if (!ts.localizedDiagnosticMessages && host.getLocalizedDiagnosticMessages) { ts.localizedDiagnosticMessages = host.getLocalizedDiagnosticMessages(); } @@ -37748,8 +38126,7 @@ var ts; } var getCanonicalFileName = createGetCanonicalFileName(useCaseSensitivefileNames); function getValidSourceFile(fileName) { - fileName = ts.normalizeSlashes(fileName); - var sourceFile = program.getSourceFile(getCanonicalFileName(fileName)); + var sourceFile = program.getSourceFile(fileName); if (!sourceFile) { throw new Error("Could not find file: '" + fileName + "'."); } @@ -37791,7 +38168,7 @@ var ts; getNewLine: function () { return ts.getNewLineOrDefaultFromHost(host); }, getDefaultLibFileName: function (options) { return host.getDefaultLibFileName(options); }, writeFile: function (fileName, data, writeByteOrderMark) { }, - getCurrentDirectory: function () { return host.getCurrentDirectory(); }, + getCurrentDirectory: function () { return currentDirectory; }, fileExists: function (fileName) { ts.Debug.assert(!host.resolveModuleNames); return hostCache.getOrCreateEntry(fileName) !== undefined; @@ -37807,11 +38184,10 @@ var ts; var newProgram = ts.createProgram(hostCache.getRootFileNames(), newSettings, compilerHost, program); if (program) { var oldSourceFiles = program.getSourceFiles(); - for (var _i = 0; _i < oldSourceFiles.length; _i++) { - var oldSourceFile = oldSourceFiles[_i]; - var fileName = oldSourceFile.fileName; - if (!newProgram.getSourceFile(fileName) || changesInCompilationSettingsAffectSyntax) { - documentRegistry.releaseDocument(fileName, oldSettings); + for (var _i = 0, oldSourceFiles_1 = oldSourceFiles; _i < oldSourceFiles_1.length; _i++) { + var oldSourceFile = oldSourceFiles_1[_i]; + if (!newProgram.getSourceFile(oldSourceFile.fileName) || changesInCompilationSettingsAffectSyntax) { + documentRegistry.releaseDocument(oldSourceFile.fileName, oldSettings); } } } @@ -37834,7 +38210,8 @@ var ts; return documentRegistry.acquireDocument(fileName, newSettings, hostFileInformation.scriptSnapshot, hostFileInformation.version); } function sourceFileUpToDate(sourceFile) { - return sourceFile && sourceFile.version === hostCache.getVersion(sourceFile.fileName); + var path = sourceFile.path || ts.toPath(sourceFile.fileName, currentDirectory, getCanonicalFileName); + return sourceFile && sourceFile.version === hostCache.getVersion(path); } function programUpToDate() { if (!program) { @@ -37844,8 +38221,8 @@ var ts; if (program.getSourceFiles().length !== rootFileNames.length) { return false; } - for (var _i = 0; _i < rootFileNames.length; _i++) { - var fileName = rootFileNames[_i]; + for (var _i = 0, rootFileNames_2 = rootFileNames; _i < rootFileNames_2.length; _i++) { + var fileName = rootFileNames_2[_i]; if (!sourceFileUpToDate(program.getSourceFile(fileName))) { return false; } @@ -38007,8 +38384,8 @@ var ts; } function checkModifiers(modifiers) { if (modifiers) { - for (var _i = 0; _i < modifiers.length; _i++) { - var modifier = modifiers[_i]; + for (var _i = 0, modifiers_1 = modifiers; _i < modifiers_1.length; _i++) { + var modifier = modifiers_1[_i]; switch (modifier.kind) { case 112: case 110: @@ -38571,8 +38948,8 @@ var ts; } function filterNamedImportOrExportCompletionItems(exportsOfModule, namedImportsOrExports) { var exisingImportsOrExports = {}; - for (var _i = 0; _i < namedImportsOrExports.length; _i++) { - var element = namedImportsOrExports[_i]; + for (var _i = 0, namedImportsOrExports_1 = namedImportsOrExports; _i < namedImportsOrExports_1.length; _i++) { + var element = namedImportsOrExports_1[_i]; if (element.getStart() <= position && position <= element.getEnd()) { continue; } @@ -38589,8 +38966,8 @@ var ts; return contextualMemberSymbols; } var existingMemberNames = {}; - for (var _i = 0; _i < existingMembers.length; _i++) { - var m = existingMembers[_i]; + for (var _i = 0, existingMembers_1 = existingMembers; _i < existingMembers_1.length; _i++) { + var m = existingMembers_1[_i]; if (m.kind !== 245 && m.kind !== 246 && m.kind !== 163) { @@ -38612,8 +38989,8 @@ var ts; } function filterJsxAttributes(symbols, attributes) { var seenNames = {}; - for (var _i = 0; _i < attributes.length; _i++) { - var attr = attributes[_i]; + for (var _i = 0, attributes_1 = attributes; _i < attributes_1.length; _i++) { + var attr = attributes_1[_i]; if (attr.getStart() <= position && position <= attr.getEnd()) { continue; } @@ -38701,8 +39078,8 @@ var ts; var entries = []; if (symbols) { var nameToSymbol = {}; - for (var _i = 0; _i < symbols.length; _i++) { - var symbol = symbols[_i]; + for (var _i = 0, symbols_3 = symbols; _i < symbols_3.length; _i++) { + var symbol = symbols_3[_i]; var entry = createCompletionEntry(symbol, location); if (entry) { var id = ts.escapeIdentifier(entry.name); @@ -39385,8 +39762,8 @@ var ts; } var fileNameToDocumentHighlights = {}; var result = []; - for (var _i = 0; _i < referencedSymbols.length; _i++) { - var referencedSymbol = referencedSymbols[_i]; + for (var _i = 0, referencedSymbols_1 = referencedSymbols; _i < referencedSymbols_1.length; _i++) { + var referencedSymbol = referencedSymbols_1[_i]; for (var _a = 0, _b = referencedSymbol.references; _a < _b.length; _a++) { var referenceEntry = _b[_a]; var fileName_1 = referenceEntry.fileName; @@ -39522,7 +39899,6 @@ var ts; ts.forEachChild(node, aggregate); } } - ; } function getThrowStatementOwner(throwStatement) { var child = throwStatement; @@ -39553,7 +39929,6 @@ var ts; ts.forEachChild(node, aggregate); } } - ; } function ownsBreakOrContinueStatement(owner, statement) { var actualOwner = getBreakOrContinueOwner(statement); @@ -39617,7 +39992,7 @@ var ts; switch (container.kind) { case 219: case 248: - if (modifierFlag & 256) { + if (modifierFlag & 128) { nodes = declaration.members.concat(declaration); } else { @@ -39630,7 +40005,7 @@ var ts; case 214: case 186: nodes = container.members; - if (modifierFlag & 112) { + if (modifierFlag & 56) { var constructor = ts.forEach(container.members, function (member) { return member.kind === 144 && member; }); @@ -39638,7 +40013,7 @@ var ts; nodes = nodes.concat(constructor.parameters); } } - else if (modifierFlag & 256) { + else if (modifierFlag & 128) { nodes = nodes.concat(container); } break; @@ -39654,19 +40029,19 @@ var ts; function getFlagFromModifier(modifier) { switch (modifier) { case 112: - return 16; + return 8; case 110: - return 32; + return 16; case 111: - return 64; + return 32; case 113: - return 128; + return 64; case 82: - return 1; - case 122: return 2; + case 122: + return 4; case 115: - return 256; + return 128; default: ts.Debug.fail(); } @@ -39851,8 +40226,8 @@ var ts; return undefined; } var result = []; - for (var _i = 0; _i < documentHighlights.length; _i++) { - var entry = documentHighlights[_i]; + for (var _i = 0, documentHighlights_1 = documentHighlights; _i < documentHighlights_1.length; _i++) { + var entry = documentHighlights_1[_i]; for (var _a = 0, _b = entry.highlightSpans; _a < _b.length; _a++) { var highlightSpan = _b[_a]; result.push({ @@ -39870,8 +40245,8 @@ var ts; return undefined; } var referenceEntries = []; - for (var _i = 0; _i < referenceSymbols.length; _i++) { - var referenceSymbol = referenceSymbols[_i]; + for (var _i = 0, referenceSymbols_1 = referenceSymbols; _i < referenceSymbols_1.length; _i++) { + var referenceSymbol = referenceSymbols_1[_i]; ts.addRange(referenceEntries, referenceSymbol.references); } return referenceEntries; @@ -39939,8 +40314,8 @@ var ts; } else { var internedName = getInternedName(symbol, node, declarations); - for (var _i = 0; _i < sourceFiles.length; _i++) { - var sourceFile = sourceFiles[_i]; + for (var _i = 0, sourceFiles_2 = sourceFiles; _i < sourceFiles_2.length; _i++) { + var sourceFile = sourceFiles_2[_i]; cancellationToken.throwIfCancellationRequested(); var nameTable = getNameTable(sourceFile); if (ts.lookUp(nameTable, internedName)) { @@ -39985,7 +40360,7 @@ var ts; return valueDeclaration; } if (symbol.flags & (4 | 8192)) { - var privateDeclaration = ts.forEach(symbol.getDeclarations(), function (d) { return (d.flags & 32) ? d : undefined; }); + var privateDeclaration = ts.forEach(symbol.getDeclarations(), function (d) { return (d.flags & 16) ? d : undefined; }); if (privateDeclaration) { return ts.getAncestor(privateDeclaration, 214); } @@ -39999,8 +40374,8 @@ var ts; var scope = undefined; var declarations = symbol.getDeclarations(); if (declarations) { - for (var _i = 0; _i < declarations.length; _i++) { - var declaration = declarations[_i]; + for (var _i = 0, declarations_8 = declarations; _i < declarations_8.length; _i++) { + var declaration = declarations_8[_i]; var container = getContainerNode(declaration); if (!container) { return undefined; @@ -40153,7 +40528,7 @@ var ts; if (!searchSpaceNode) { return undefined; } - var staticFlag = 128; + var staticFlag = 64; switch (searchSpaceNode.kind) { case 141: case 140: @@ -40178,7 +40553,7 @@ var ts; return; } var container = ts.getSuperContainer(node, false); - if (container && (128 & container.flags) === staticFlag && container.parent.symbol === searchSpaceNode.symbol) { + if (container && (64 & container.flags) === staticFlag && container.parent.symbol === searchSpaceNode.symbol) { references.push(getReferenceEntryFromNode(node)); } }); @@ -40187,7 +40562,7 @@ var ts; } function getReferencesForThisKeyword(thisOrSuperKeyword, sourceFiles) { var searchSpaceNode = ts.getThisContainer(thisOrSuperKeyword, false); - var staticFlag = 128; + var staticFlag = 64; switch (searchSpaceNode.kind) { case 143: case 142: @@ -40259,7 +40634,7 @@ var ts; break; case 186: case 214: - if (container.parent && searchSpaceNode.symbol === container.parent.symbol && (container.flags & 128) === staticFlag) { + if (container.parent && searchSpaceNode.symbol === container.parent.symbol && (container.flags & 64) === staticFlag) { result.push(getReferenceEntryFromNode(node)); } break; @@ -40386,8 +40761,8 @@ var ts; var lastIterationMeaning; do { lastIterationMeaning = meaning; - for (var _i = 0; _i < declarations.length; _i++) { - var declaration = declarations[_i]; + for (var _i = 0, declarations_9 = declarations; _i < declarations_9.length; _i++) { + var declaration = declarations_9[_i]; var declarationMeaning = getMeaningFromDeclaration(declaration); if (declarationMeaning & meaning) { meaning |= declarationMeaning; @@ -40500,7 +40875,6 @@ var ts; return 4 | 1; } return 1 | 2 | 4; - ts.Debug.fail("Unknown declaration type"); } function isTypeReference(node) { if (ts.isRightSideOfQualifiedNameOrPropertyAccess(node)) { @@ -41007,8 +41381,8 @@ var ts; if (matchKind) { var parentElement = token.parent; var childNodes = parentElement.getChildren(sourceFile); - for (var _i = 0; _i < childNodes.length; _i++) { - var current = childNodes[_i]; + for (var _i = 0, childNodes_1 = childNodes; _i < childNodes_1.length; _i++) { + var current = childNodes_1[_i]; if (current.kind === matchKind) { var range1 = ts.createTextSpan(token.getStart(sourceFile), token.getWidth(sourceFile)); var range2 = ts.createTextSpan(current.getStart(sourceFile), current.getWidth(sourceFile)); @@ -41224,8 +41598,8 @@ var ts; if (declarations && declarations.length > 0) { var defaultLibFileName = host.getDefaultLibFileName(host.getCompilationSettings()); if (defaultLibFileName) { - for (var _i = 0; _i < declarations.length; _i++) { - var current = declarations[_i]; + for (var _i = 0, declarations_10 = declarations; _i < declarations_10.length; _i++) { + var current = declarations_10[_i]; var sourceFile_2 = current.getSourceFile(); var canonicalName = getCanonicalFileName(ts.normalizePath(sourceFile_2.fileName)); if (sourceFile_2 && getCanonicalFileName(ts.normalizePath(sourceFile_2.fileName)) === getCanonicalFileName(ts.normalizePath(defaultLibFileName))) { @@ -41962,8 +42336,8 @@ var ts; if (this.logger.isVerbose()) { this.logger.info(msg.type + ": " + json); } - this.sendLineToClient('Content-Length: ' + (1 + this.byteLength(json, 'utf8')) + - '\r\n\r\n' + json); + this.sendLineToClient("Content-Length: " + (1 + this.byteLength(json, "utf8")) + + "\r\n\r\n" + json); }; Session.prototype.event = function (info, eventName) { var ev = { @@ -42346,7 +42720,8 @@ var ts; }; var preferredIndent = compilerService.languageService.getIndentationAtPosition(file, position, editorOptions); var hasIndent = 0; - for (var i = 0, len = lineText.length; i < len; i++) { + var i, len; + for (i = 0, len = lineText.length; i < len; i++) { if (lineText.charAt(i) == " ") { hasIndent++; } @@ -42553,7 +42928,7 @@ var ts; if (navItem.kindModifiers && (navItem.kindModifiers != "")) { bakedItem.kindModifiers = navItem.kindModifiers; } - if (navItem.matchKind != 'none') { + if (navItem.matchKind !== "none") { bakedItem.matchKind = navItem.matchKind; } if (navItem.containerName && (navItem.containerName.length > 0)) { @@ -42592,8 +42967,8 @@ var ts; var veryLowPriorityFiles = []; var normalizedFileName = ts.normalizePath(fileName); var project = this.projectService.getProjectForFile(normalizedFileName); - for (var _i = 0; _i < fileNamesInProject.length; _i++) { - var fileNameInProject = fileNamesInProject[_i]; + for (var _i = 0, fileNamesInProject_1 = fileNamesInProject; _i < fileNamesInProject_1.length; _i++) { + var fileNameInProject = fileNamesInProject_1[_i]; if (this.getCanonicalFileName(fileNameInProject) == this.getCanonicalFileName(fileName)) highPriorityFiles.push(fileNameInProject); else { @@ -42641,12 +43016,14 @@ var ts; } }; Session.prototype.onMessage = function (message) { + var start; if (this.logger.isVerbose()) { this.logger.info("request: " + message); - var start = this.hrtime(); + start = this.hrtime(); } + var request; try { - var request = JSON.parse(message); + request = JSON.parse(message); var _a = this.executeCommand(request), response = _a.response, responseRequired = _a.responseRequired; if (this.logger.isVerbose()) { var elapsed = this.hrtime(start); @@ -42701,6 +43078,7 @@ var ts; this.isOpen = isOpen; this.children = []; this.formatCodeOptions = ts.clone(CompilerService.defaultFormatCodeOptions); + this.path = ts.toPath(fileName, host.getCurrentDirectory(), ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames)); this.svc = ScriptVersionCache.fromString(host, content); } ScriptInfo.prototype.setFormatOptions = function (formatOptions) { @@ -42742,23 +43120,23 @@ var ts; var _this = this; this.host = host; this.project = project; - this.ls = null; this.roots = []; - var getCanonicalFileName = ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames); - this.resolvedModuleNames = ts.createFileMap(getCanonicalFileName); - this.filenameToScript = ts.createFileMap(getCanonicalFileName); + this.getCanonicalFileName = ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames); + this.resolvedModuleNames = ts.createFileMap(); + this.filenameToScript = ts.createFileMap(); this.moduleResolutionHost = { fileExists: function (fileName) { return _this.fileExists(fileName); }, readFile: function (fileName) { return _this.host.readFile(fileName); } }; } LSHost.prototype.resolveModuleNames = function (moduleNames, containingFile) { - var currentResolutionsInFile = this.resolvedModuleNames.get(containingFile); + var path = ts.toPath(containingFile, this.host.getCurrentDirectory(), this.getCanonicalFileName); + var currentResolutionsInFile = this.resolvedModuleNames.get(path); var newResolutions = {}; var resolvedModules = []; var compilerOptions = this.getCompilationSettings(); - for (var _i = 0; _i < moduleNames.length; _i++) { - var moduleName = moduleNames[_i]; + for (var _i = 0, moduleNames_1 = moduleNames; _i < moduleNames_1.length; _i++) { + var moduleName = moduleNames_1[_i]; var resolution = ts.lookUp(newResolutions, moduleName); if (!resolution) { var existingResolution = currentResolutionsInFile && ts.lookUp(currentResolutionsInFile, moduleName); @@ -42774,7 +43152,7 @@ var ts; ts.Debug.assert(resolution !== undefined); resolvedModules.push(resolution.resolvedModule); } - this.resolvedModuleNames.set(containingFile, newResolutions); + this.resolvedModuleNames.set(path, newResolutions); return resolvedModules; function moduleResolutionIsValid(resolution) { if (!resolution) { @@ -42825,31 +43203,32 @@ var ts; }; LSHost.prototype.removeReferencedFile = function (info) { if (!info.isOpen) { - this.filenameToScript.remove(info.fileName); - this.resolvedModuleNames.remove(info.fileName); + this.filenameToScript.remove(info.path); + this.resolvedModuleNames.remove(info.path); } }; LSHost.prototype.getScriptInfo = function (filename) { - var scriptInfo = this.filenameToScript.get(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(scriptInfo.fileName, scriptInfo); + this.filenameToScript.set(path, scriptInfo); } } return scriptInfo; }; LSHost.prototype.addRoot = function (info) { - if (!this.filenameToScript.contains(info.fileName)) { - this.filenameToScript.set(info.fileName, 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.fileName)) { - this.filenameToScript.remove(info.fileName); + if (!this.filenameToScript.contains(info.path)) { + this.filenameToScript.remove(info.path); this.roots = copyListRemovingItem(info, this.roots); - this.resolvedModuleNames.remove(info.fileName); + this.resolvedModuleNames.remove(info.path); } }; LSHost.prototype.saveTo = function (filename, tmpfilename) { @@ -42887,7 +43266,8 @@ var ts; return this.host.directoryExists(path); }; LSHost.prototype.lineToTextSpan = function (filename, line) { - var script = this.filenameToScript.get(filename); + 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; @@ -42901,13 +43281,15 @@ var ts; return ts.createTextSpan(lineInfo.offset, len); }; LSHost.prototype.lineOffsetToPosition = function (filename, line, offset) { - var script = this.filenameToScript.get(filename); + 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) { - var script = this.filenameToScript.get(filename); + var path = ts.toPath(filename, this.host.getCurrentDirectory(), this.getCanonicalFileName); + var script = this.filenameToScript.get(path); var index = script.snap().index; var lineOffset = index.charOffsetToLineNumberAndPos(position); return { line: lineOffset.line, offset: lineOffset.offset + 1 }; @@ -42921,22 +43303,22 @@ var ts; return filename; } else { - var splitFilename = filename.split('/'); - var splitDir = directory.split('/'); + var splitFilename = filename.split("/"); + var splitDir = directory.split("/"); var i = 0; var dirTail = 0; var sflen = splitFilename.length; - while ((i < sflen) && (splitFilename[i].charAt(0) == '.')) { + while ((i < sflen) && (splitFilename[i].charAt(0) == ".")) { var dots = splitFilename[i]; - if (dots == '..') { + if (dots == "..") { dirTail++; } - else if (dots != '.') { + else if (dots != ".") { return undefined; } i++; } - return splitDir.slice(0, splitDir.length - dirTail).concat(splitFilename.slice(i)).join('/'); + return splitDir.slice(0, splitDir.length - dirTail).concat(splitFilename.slice(i)).join("/"); } } var Project = (function () { @@ -43111,8 +43493,8 @@ var ts; var _a = this.configFileToProjectOptions(fileName), succeeded = _a.succeeded, projectOptions = _a.projectOptions, error = _a.error; 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; _i < openFileRoots.length; _i++) { - var openFileRoot = openFileRoots[_i]; + 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; @@ -43236,8 +43618,8 @@ var ts; this.inferredProjects = copyListRemovingItem(project, this.inferredProjects); } var fileNames = project.getFileNames(); - for (var _b = 0; _b < fileNames.length; _b++) { - var fileName = fileNames[_b]; + for (var _b = 0, fileNames_1 = fileNames; _b < fileNames_1.length; _b++) { + var fileName = fileNames_1[_b]; var info = this.getScriptInfo(fileName); if (info.defaultProject == project) { info.defaultProject = undefined; @@ -43591,10 +43973,11 @@ var ts; } else { var parsedCommandLine = ts.parseJsonConfigFileContent(rawConfig.config, this.host, dirPath); + ts.Debug.assert(!!parsedCommandLine.fileNames); if (parsedCommandLine.errors && (parsedCommandLine.errors.length > 0)) { return { succeeded: false, error: { errorMsg: "tsconfig option errors" } }; } - else if (parsedCommandLine.fileNames == null) { + else if (parsedCommandLine.fileNames.length === 0) { return { succeeded: false, error: { errorMsg: "no files found" } }; } else { @@ -43646,15 +44029,15 @@ var ts; var newFileNames = projectOptions.files; var fileNamesToRemove = oldFileNames.filter(function (f) { return newFileNames.indexOf(f) < 0; }); var fileNamesToAdd = newFileNames.filter(function (f) { return oldFileNames.indexOf(f) < 0; }); - for (var _i = 0; _i < fileNamesToRemove.length; _i++) { - var fileName = fileNamesToRemove[_i]; + for (var _i = 0, fileNamesToRemove_1 = fileNamesToRemove; _i < fileNamesToRemove_1.length; _i++) { + var fileName = fileNamesToRemove_1[_i]; var info = this.getScriptInfo(fileName); if (info) { project.removeRoot(info); } } - for (var _b = 0; _b < fileNamesToAdd.length; _b++) { - var fileName = fileNamesToAdd[_b]; + for (var _b = 0, fileNamesToAdd_1 = fileNamesToAdd; _b < fileNamesToAdd_1.length; _b++) { + var fileName = fileNamesToAdd_1[_b]; var info = this.getScriptInfo(fileName); if (!info) { info = this.openFile(fileName, false); @@ -43714,7 +44097,7 @@ var ts; CompilerService.defaultFormatCodeOptions = { IndentSize: 4, TabSize: 4, - NewLineCharacter: ts.sys ? ts.sys.newLine : '\n', + NewLineCharacter: ts.sys ? ts.sys.newLine : "\n", ConvertTabsToSpaces: true, IndentStyle: ts.IndentStyle.Smart, InsertSpaceAfterCommaDelimiter: true, @@ -43804,7 +44187,7 @@ var ts; if (len > 1) { var insertedNodes = new Array(len - 1); var startNode = leafNode; - for (var i = 1, len = lines.length; i < len; i++) { + for (var i = 1, len_1 = lines.length; i < len_1; i++) { insertedNodes[i - 1] = new LineLeaf(lines[i]); } var pathIndex = this.startPath.length - 2; @@ -44172,8 +44555,9 @@ var ts; } } else { + var checkText; if (this.checkEdits) { - var checkText = editFlat(this.getText(0, this.root.charCount()), pos, deleteLength, newText); + checkText = editFlat(this.getText(0, this.root.charCount()), pos, deleteLength, newText); } var walker = new EditWalker(); if (pos >= this.root.charCount()) { @@ -44399,7 +44783,9 @@ var ts; LineNode.prototype.childFromLineNumber = function (lineNumber, charOffset) { var child; var relativeLineNumber = lineNumber; - for (var i = 0, len = this.children.length; i < len; i++) { + var i; + var len; + for (i = 0, len = this.children.length; i < len; i++) { child = this.children[i]; var childLineCount = child.lineCount(); if (childLineCount >= relativeLineNumber) { @@ -44419,7 +44805,9 @@ var ts; }; LineNode.prototype.childFromCharOffset = function (lineNumber, charOffset) { var child; - for (var i = 0, len = this.children.length; i < len; i++) { + var i; + var len; + for (i = 0, len = this.children.length; i < len; i++) { child = this.children[i]; if (child.charCount() > charOffset) { break; @@ -44501,7 +44889,7 @@ var ts; splitNode = splitNodes[splitNodeIndex]; } } - for (i = splitNodes.length - 1; i >= 0; i--) { + for (var i = splitNodes.length - 1; i >= 0; i--) { if (splitNodes[i].children.length === 0) { splitNodes.length--; } @@ -44511,7 +44899,7 @@ var ts; splitNodes[splitNodes.length] = shiftNode; } this.updateCounts(); - for (i = 0; i < splitNodeCount; i++) { + for (var i = 0; i < splitNodeCount; i++) { splitNodes[i].updateCounts(); } return splitNodes; @@ -44561,10 +44949,10 @@ var ts; (function (ts) { var server; (function (server) { - var nodeproto = require('_debugger'); - var readline = require('readline'); - var path = require('path'); - var fs = require('fs'); + var nodeproto = require("_debugger"); + var readline = require("readline"); + var path = require("path"); + var fs = require("fs"); var rl = readline.createInterface({ input: process.stdin, output: process.stdout, @@ -44644,11 +45032,11 @@ var ts; }; IOSession.prototype.listen = function () { var _this = this; - rl.on('line', function (input) { + rl.on("line", function (input) { var message = input.trim(); _this.onMessage(message); }); - rl.on('close', function () { + rl.on("close", function () { _this.exit(); }); }; @@ -44656,7 +45044,7 @@ var ts; })(server.Session); function parseLoggingEnvironmentString(logEnvStr) { var logEnv = {}; - var args = logEnvStr.split(' '); + var args = logEnvStr.split(" "); for (var i = 0, len = args.length; i < (len - 1); i += 2) { var option = args[i]; var value = args[i + 1]; @@ -44711,7 +45099,7 @@ var ts; } ts.sys.write = function (s) { return writeMessage(s); }; var ioSession = new IOSession(ts.sys, logger); - process.on('uncaughtException', function (err) { + process.on("uncaughtException", function (err) { ioSession.logError(err, "unknown"); }); ioSession.listen(); @@ -44794,7 +45182,6 @@ var ts; var settingsJson = this.shimHost.getCompilationSettings(); if (settingsJson == null || settingsJson == "") { throw Error("LanguageServiceShimHostAdapter.getCompilationSettings: empty compilationSettings"); - return null; } return JSON.parse(settingsJson); }; diff --git a/lib/typescript.d.ts b/lib/typescript.d.ts index d94e55eb48f..972ebfa472d 100644 --- a/lib/typescript.d.ts +++ b/lib/typescript.d.ts @@ -17,19 +17,22 @@ declare namespace ts { interface Map { [index: string]: T; } + type Path = string & { + __pathBrand: any; + }; interface FileMap { - get(fileName: string): T; - set(fileName: string, value: T): void; - contains(fileName: string): boolean; - remove(fileName: string): void; - forEachValue(f: (v: T) => void): void; + get(fileName: Path): T; + set(fileName: Path, value: T): void; + contains(fileName: Path): boolean; + remove(fileName: Path): void; + forEachValue(f: (key: Path, v: T) => void): void; clear(): void; } interface TextRange { pos: number; end: number; } - const enum SyntaxKind { + enum SyntaxKind { Unknown = 0, EndOfFileToken = 1, SingleLineCommentTrivia = 2, @@ -327,31 +330,34 @@ declare namespace ts { LastBinaryOperator = 68, FirstNode = 135, } - const enum NodeFlags { + enum NodeFlags { None = 0, - Export = 1, - Ambient = 2, - Public = 16, - Private = 32, - Protected = 64, - Static = 128, - Abstract = 256, - Async = 512, - Default = 1024, - MultiLine = 2048, - Synthetic = 4096, - DeclarationFile = 8192, - Let = 16384, - Const = 32768, - OctalLiteral = 65536, - Namespace = 131072, - ExportContext = 262144, - ContainsThis = 524288, - Modifier = 2035, - AccessibilityModifier = 112, - BlockScoped = 49152, + Export = 2, + Ambient = 4, + Public = 8, + Private = 16, + Protected = 32, + Static = 64, + Abstract = 128, + Async = 256, + Default = 512, + MultiLine = 1024, + Synthetic = 2048, + DeclarationFile = 4096, + Let = 8192, + Const = 16384, + OctalLiteral = 32768, + Namespace = 65536, + ExportContext = 131072, + ContainsThis = 262144, + HasImplicitReturn = 524288, + HasExplicitReturn = 1048576, + Modifier = 1022, + AccessibilityModifier = 56, + BlockScoped = 24576, + ReachabilityCheckFlags = 1572864, } - const enum JsxFlags { + enum JsxFlags { None = 0, IntrinsicNamedElement = 1, IntrinsicIndexedElement = 2, @@ -931,6 +937,7 @@ declare namespace ts { statements: NodeArray; endOfFileToken: Node; fileName: string; + path: Path; text: string; amdDependencies: { path: string; @@ -1093,7 +1100,7 @@ declare namespace ts { trackSymbol(symbol: Symbol, enclosingDeclaration?: Node, meaning?: SymbolFlags): void; reportInaccessibleThisError(): void; } - const enum TypeFormatFlags { + enum TypeFormatFlags { None = 0, WriteArrayAsGenericType = 1, UseTypeOfFunction = 2, @@ -1104,7 +1111,7 @@ declare namespace ts { InElementType = 64, UseFullyQualifiedType = 128, } - const enum SymbolFormatFlags { + enum SymbolFormatFlags { None = 0, WriteTypeParametersOrArguments = 1, UseOnlyExternalAliasing = 2, @@ -1114,7 +1121,7 @@ declare namespace ts { parameterIndex: number; type: Type; } - const enum SymbolFlags { + enum SymbolFlags { None = 0, FunctionScopedVariable = 1, BlockScopedVariable = 2, @@ -1191,7 +1198,7 @@ declare namespace ts { interface SymbolTable { [index: string]: Symbol; } - const enum TypeFlags { + enum TypeFlags { Any = 1, String = 2, Number = 4, @@ -1262,7 +1269,7 @@ declare namespace ts { interface TypeParameter extends Type { constraint: Type; } - const enum SignatureKind { + enum SignatureKind { Call = 0, Construct = 1, } @@ -1272,7 +1279,7 @@ declare namespace ts { parameters: Symbol[]; typePredicate?: TypePredicate; } - const enum IndexKind { + enum IndexKind { String = 0, Number = 1, } @@ -1307,7 +1314,7 @@ declare namespace ts { Error = 1, Message = 2, } - const enum ModuleResolutionKind { + enum ModuleResolutionKind { Classic = 1, NodeJs = 2, } @@ -1352,10 +1359,14 @@ declare namespace ts { experimentalDecorators?: boolean; emitDecoratorMetadata?: boolean; moduleResolution?: ModuleResolutionKind; + allowUnusedLabels?: boolean; + allowUnreachableCode?: boolean; + noImplicitReturns?: boolean; + noFallthroughCasesInSwitch?: boolean; forceConsistentCasingInFileNames?: boolean; [option: string]: string | number | boolean; } - const enum ModuleKind { + enum ModuleKind { None = 0, CommonJS = 1, AMD = 2, @@ -1364,12 +1375,12 @@ declare namespace ts { ES6 = 5, ES2015 = 5, } - const enum JsxEmit { + enum JsxEmit { None = 0, Preserve = 1, React = 2, } - const enum NewLineKind { + enum NewLineKind { CarriageReturnLineFeed = 0, LineFeed = 1, } @@ -1377,14 +1388,14 @@ declare namespace ts { line: number; character: number; } - const enum ScriptTarget { + enum ScriptTarget { ES3 = 0, ES5 = 1, ES6 = 2, ES2015 = 2, Latest = 2, } - const enum LanguageVariant { + enum LanguageVariant { Standard = 0, JSX = 1, } @@ -1938,7 +1949,7 @@ declare namespace ts { outputFiles: OutputFile[]; emitSkipped: boolean; } - const enum OutputFileType { + enum OutputFileType { JavaScript = 0, SourceMap = 1, Declaration = 2, @@ -1948,7 +1959,7 @@ declare namespace ts { writeByteOrderMark: boolean; text: string; } - const enum EndOfLineState { + enum EndOfLineState { None = 0, InMultiLineCommentTrivia = 1, InSingleQuoteStringLiteral = 2, @@ -2116,7 +2127,7 @@ declare namespace ts { static parameterName: string; static docCommentTagName: string; } - const enum ClassificationType { + enum ClassificationType { comment = 1, identifier = 2, keyword = 3, @@ -2159,7 +2170,7 @@ declare namespace ts { let disableIncrementalParsing: boolean; function updateLanguageServiceSourceFile(sourceFile: SourceFile, scriptSnapshot: IScriptSnapshot, version: string, textChangeRange: TextChangeRange, aggressiveChecks?: boolean): SourceFile; function createGetCanonicalFileName(useCaseSensitivefileNames: boolean): (fileName: string) => string; - function createDocumentRegistry(useCaseSensitiveFileNames?: boolean): DocumentRegistry; + function createDocumentRegistry(useCaseSensitiveFileNames?: boolean, currentDirectory?: string): DocumentRegistry; function preProcessFile(sourceText: string, readImportFiles?: boolean): PreProcessedFileInfo; function createLanguageService(host: LanguageServiceHost, documentRegistry?: DocumentRegistry): LanguageService; function createClassifier(): Classifier; diff --git a/lib/typescript.js b/lib/typescript.js index 1e0c0edad05..8b0ef04f96e 100644 --- a/lib/typescript.js +++ b/lib/typescript.js @@ -350,27 +350,30 @@ var ts; var SyntaxKind = ts.SyntaxKind; (function (NodeFlags) { NodeFlags[NodeFlags["None"] = 0] = "None"; - NodeFlags[NodeFlags["Export"] = 1] = "Export"; - NodeFlags[NodeFlags["Ambient"] = 2] = "Ambient"; - NodeFlags[NodeFlags["Public"] = 16] = "Public"; - NodeFlags[NodeFlags["Private"] = 32] = "Private"; - NodeFlags[NodeFlags["Protected"] = 64] = "Protected"; - NodeFlags[NodeFlags["Static"] = 128] = "Static"; - NodeFlags[NodeFlags["Abstract"] = 256] = "Abstract"; - NodeFlags[NodeFlags["Async"] = 512] = "Async"; - NodeFlags[NodeFlags["Default"] = 1024] = "Default"; - NodeFlags[NodeFlags["MultiLine"] = 2048] = "MultiLine"; - NodeFlags[NodeFlags["Synthetic"] = 4096] = "Synthetic"; - NodeFlags[NodeFlags["DeclarationFile"] = 8192] = "DeclarationFile"; - NodeFlags[NodeFlags["Let"] = 16384] = "Let"; - NodeFlags[NodeFlags["Const"] = 32768] = "Const"; - NodeFlags[NodeFlags["OctalLiteral"] = 65536] = "OctalLiteral"; - NodeFlags[NodeFlags["Namespace"] = 131072] = "Namespace"; - NodeFlags[NodeFlags["ExportContext"] = 262144] = "ExportContext"; - NodeFlags[NodeFlags["ContainsThis"] = 524288] = "ContainsThis"; - NodeFlags[NodeFlags["Modifier"] = 2035] = "Modifier"; - NodeFlags[NodeFlags["AccessibilityModifier"] = 112] = "AccessibilityModifier"; - NodeFlags[NodeFlags["BlockScoped"] = 49152] = "BlockScoped"; + NodeFlags[NodeFlags["Export"] = 2] = "Export"; + NodeFlags[NodeFlags["Ambient"] = 4] = "Ambient"; + NodeFlags[NodeFlags["Public"] = 8] = "Public"; + NodeFlags[NodeFlags["Private"] = 16] = "Private"; + NodeFlags[NodeFlags["Protected"] = 32] = "Protected"; + NodeFlags[NodeFlags["Static"] = 64] = "Static"; + NodeFlags[NodeFlags["Abstract"] = 128] = "Abstract"; + NodeFlags[NodeFlags["Async"] = 256] = "Async"; + NodeFlags[NodeFlags["Default"] = 512] = "Default"; + NodeFlags[NodeFlags["MultiLine"] = 1024] = "MultiLine"; + NodeFlags[NodeFlags["Synthetic"] = 2048] = "Synthetic"; + NodeFlags[NodeFlags["DeclarationFile"] = 4096] = "DeclarationFile"; + NodeFlags[NodeFlags["Let"] = 8192] = "Let"; + NodeFlags[NodeFlags["Const"] = 16384] = "Const"; + NodeFlags[NodeFlags["OctalLiteral"] = 32768] = "OctalLiteral"; + NodeFlags[NodeFlags["Namespace"] = 65536] = "Namespace"; + NodeFlags[NodeFlags["ExportContext"] = 131072] = "ExportContext"; + NodeFlags[NodeFlags["ContainsThis"] = 262144] = "ContainsThis"; + NodeFlags[NodeFlags["HasImplicitReturn"] = 524288] = "HasImplicitReturn"; + NodeFlags[NodeFlags["HasExplicitReturn"] = 1048576] = "HasExplicitReturn"; + NodeFlags[NodeFlags["Modifier"] = 1022] = "Modifier"; + NodeFlags[NodeFlags["AccessibilityModifier"] = 56] = "AccessibilityModifier"; + NodeFlags[NodeFlags["BlockScoped"] = 24576] = "BlockScoped"; + NodeFlags[NodeFlags["ReachabilityCheckFlags"] = 1572864] = "ReachabilityCheckFlags"; })(ts.NodeFlags || (ts.NodeFlags = {})); var NodeFlags = ts.NodeFlags; /* @internal */ @@ -690,6 +693,12 @@ var ts; })(ts.LanguageVariant || (ts.LanguageVariant = {})); var LanguageVariant = ts.LanguageVariant; /* @internal */ + (function (DiagnosticStyle) { + DiagnosticStyle[DiagnosticStyle["Simple"] = 0] = "Simple"; + DiagnosticStyle[DiagnosticStyle["Pretty"] = 1] = "Pretty"; + })(ts.DiagnosticStyle || (ts.DiagnosticStyle = {})); + var DiagnosticStyle = ts.DiagnosticStyle; + /* @internal */ (function (CharacterCodes) { CharacterCodes[CharacterCodes["nullCharacter"] = 0] = "nullCharacter"; CharacterCodes[CharacterCodes["maxAsciiCharacter"] = 127] = "maxAsciiCharacter"; @@ -838,40 +847,50 @@ var ts; Ternary[Ternary["True"] = -1] = "True"; })(ts.Ternary || (ts.Ternary = {})); var Ternary = ts.Ternary; - function createFileMap(getCanonicalFileName) { + function createFileMap(keyMapper) { var files = {}; return { get: get, set: set, contains: contains, remove: remove, - clear: clear, - forEachValue: forEachValueInMap + forEachValue: forEachValueInMap, + clear: clear }; - function set(fileName, value) { - files[normalizeKey(fileName)] = value; - } - function get(fileName) { - return files[normalizeKey(fileName)]; - } - function contains(fileName) { - return hasProperty(files, normalizeKey(fileName)); - } - function remove(fileName) { - var key = normalizeKey(fileName); - delete files[key]; - } function forEachValueInMap(f) { - forEachValue(files, f); + for (var key in files) { + f(key, files[key]); + } } - function normalizeKey(key) { - return getCanonicalFileName(normalizeSlashes(key)); + // path should already be well-formed so it does not need to be normalized + function get(path) { + return files[toKey(path)]; + } + function set(path, value) { + files[toKey(path)] = value; + } + function contains(path) { + return hasProperty(files, toKey(path)); + } + function remove(path) { + var key = toKey(path); + delete files[key]; } function clear() { files = {}; } + function toKey(path) { + return keyMapper ? keyMapper(path) : path; + } } ts.createFileMap = createFileMap; + function toPath(fileName, basePath, getCanonicalFileName) { + var nonCanonicalizedPath = isRootedDiskPath(fileName) + ? normalizePath(fileName) + : getNormalizedAbsolutePath(fileName, basePath); + return getCanonicalFileName(nonCanonicalizedPath); + } + ts.toPath = toPath; (function (Comparison) { Comparison[Comparison["LessThan"] = -1] = "LessThan"; Comparison[Comparison["EqualTo"] = 0] = "EqualTo"; @@ -897,8 +916,8 @@ var ts; ts.forEach = forEach; function contains(array, value) { if (array) { - for (var _i = 0; _i < array.length; _i++) { - var v = array[_i]; + for (var _i = 0, array_1 = array; _i < array_1.length; _i++) { + var v = array_1[_i]; if (v === value) { return true; } @@ -921,8 +940,8 @@ var ts; function countWhere(array, predicate) { var count = 0; if (array) { - for (var _i = 0; _i < array.length; _i++) { - var v = array[_i]; + for (var _i = 0, array_2 = array; _i < array_2.length; _i++) { + var v = array_2[_i]; if (predicate(v)) { count++; } @@ -935,8 +954,8 @@ var ts; var result; if (array) { result = []; - for (var _i = 0; _i < array.length; _i++) { - var item = array[_i]; + for (var _i = 0, array_3 = array; _i < array_3.length; _i++) { + var item = array_3[_i]; if (f(item)) { result.push(item); } @@ -949,8 +968,8 @@ var ts; var result; if (array) { result = []; - for (var _i = 0; _i < array.length; _i++) { - var v = array[_i]; + for (var _i = 0, array_4 = array; _i < array_4.length; _i++) { + var v = array_4[_i]; result.push(f(v)); } } @@ -969,8 +988,8 @@ var ts; var result; if (array) { result = []; - for (var _i = 0; _i < array.length; _i++) { - var item = array[_i]; + for (var _i = 0, array_5 = array; _i < array_5.length; _i++) { + var item = array_5[_i]; if (!contains(result, item)) { result.push(item); } @@ -981,8 +1000,8 @@ var ts; ts.deduplicate = deduplicate; function sum(array, prop) { var result = 0; - for (var _i = 0; _i < array.length; _i++) { - var v = array[_i]; + for (var _i = 0, array_6 = array; _i < array_6.length; _i++) { + var v = array_6[_i]; result += v[prop]; } return result; @@ -990,8 +1009,8 @@ var ts; ts.sum = sum; function addRange(to, from) { if (to && from) { - for (var _i = 0; _i < from.length; _i++) { - var v = from[_i]; + for (var _i = 0, from_1 = from; _i < from_1.length; _i++) { + var v = from_1[_i]; to.push(v); } } @@ -1341,8 +1360,8 @@ var ts; function getNormalizedParts(normalizedSlashedPath, rootLength) { var parts = normalizedSlashedPath.substr(rootLength).split(ts.directorySeparator); var normalized = []; - for (var _i = 0; _i < parts.length; _i++) { - var part = parts[_i]; + for (var _i = 0, parts_1 = parts; _i < parts_1.length; _i++) { + var part = parts_1[_i]; if (part !== ".") { if (part === ".." && normalized.length > 0 && lastOrUndefined(normalized) !== "..") { normalized.pop(); @@ -1521,8 +1540,8 @@ var ts; if (!fileName) { return false; } - for (var _i = 0; _i < ts.supportedExtensions.length; _i++) { - var extension = ts.supportedExtensions[_i]; + for (var _i = 0, supportedExtensions_1 = ts.supportedExtensions; _i < supportedExtensions_1.length; _i++) { + var extension = supportedExtensions_1[_i]; if (fileExtensionIs(fileName, extension)) { return true; } @@ -1532,8 +1551,8 @@ var ts; ts.isSupportedSourceFileName = isSupportedSourceFileName; var extensionsToRemove = [".d.ts", ".ts", ".js", ".tsx", ".jsx"]; function removeFileExtension(path) { - for (var _i = 0; _i < extensionsToRemove.length; _i++) { - var ext = extensionsToRemove[_i]; + for (var _i = 0, extensionsToRemove_1 = extensionsToRemove; _i < extensionsToRemove_1.length; _i++) { + var ext = extensionsToRemove_1[_i]; if (fileExtensionIs(path, ext)) { return path.substr(0, path.length - ext.length); } @@ -1614,8 +1633,8 @@ var ts; })(Debug = ts.Debug || (ts.Debug = {})); function copyListRemovingItem(item, list) { var copiedList = []; - for (var _i = 0; _i < list.length; _i++) { - var e = list[_i]; + for (var _i = 0, list_1 = list; _i < list_1.length; _i++) { + var e = list_1[_i]; if (e !== item) { copiedList.push(e); } @@ -1709,16 +1728,16 @@ var ts; function visitDirectory(path) { var folder = fso.GetFolder(path || "."); var files = getNames(folder.files); - for (var _i = 0; _i < files.length; _i++) { - var current = files[_i]; + for (var _i = 0, files_1 = files; _i < files_1.length; _i++) { + var current = files_1[_i]; var name_1 = ts.combinePaths(path, current); if ((!extension || ts.fileExtensionIs(name_1, extension)) && !ts.contains(exclude, getCanonicalPath(name_1))) { result.push(name_1); } } var subfolders = getNames(folder.subfolders); - for (var _a = 0; _a < subfolders.length; _a++) { - var current = subfolders[_a]; + for (var _a = 0, subfolders_1 = subfolders; _a < subfolders_1.length; _a++) { + var current = subfolders_1[_a]; var name_2 = ts.combinePaths(path, current); if (!ts.contains(exclude, getCanonicalPath(name_2))) { visitDirectory(name_2); @@ -1769,6 +1788,7 @@ var ts; var _fs = require("fs"); var _path = require("path"); var _os = require("os"); + var _tty = require("tty"); // average async stat takes about 30 microseconds // set chunk size to do 30 files in < 1 millisecond function createWatchedFileSet(interval, chunkSize) { @@ -1906,8 +1926,8 @@ var ts; function visitDirectory(path) { var files = _fs.readdirSync(path || ".").sort(); var directories = []; - for (var _i = 0; _i < files.length; _i++) { - var current = files[_i]; + for (var _i = 0, files_2 = files; _i < files_2.length; _i++) { + var current = files_2[_i]; var name_3 = ts.combinePaths(path, current); if (!ts.contains(exclude, getCanonicalPath(name_3))) { var stat = _fs.statSync(name_3); @@ -1921,8 +1941,8 @@ var ts; } } } - for (var _a = 0; _a < directories.length; _a++) { - var current = directories[_a]; + for (var _a = 0, directories_1 = directories; _a < directories_1.length; _a++) { + var current = directories_1[_a]; visitDirectory(current); } } @@ -1932,15 +1952,7 @@ var ts; newLine: _os.EOL, useCaseSensitiveFileNames: useCaseSensitiveFileNames, write: function (s) { - var buffer = new Buffer(s, "utf8"); - var offset = 0; - var toWrite = buffer.length; - var written = 0; - // 1 is a standard descriptor for stdout - while ((written = _fs.writeSync(1, buffer, offset, toWrite)) < toWrite) { - offset += written; - toWrite -= written; - } + process.stdout.write(s); }, readFile: readFile, writeFile: writeFile, @@ -2223,6 +2235,7 @@ var ts; await_expression_is_only_allowed_within_an_async_function: { code: 1308, category: ts.DiagnosticCategory.Error, key: "await_expression_is_only_allowed_within_an_async_function_1308", message: "'await' expression is only allowed within an async function." }, Async_functions_are_only_available_when_targeting_ECMAScript_6_and_higher: { code: 1311, category: ts.DiagnosticCategory.Error, key: "Async_functions_are_only_available_when_targeting_ECMAScript_6_and_higher_1311", message: "Async functions are only available when targeting ECMAScript 6 and higher." }, can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment: { code: 1312, category: ts.DiagnosticCategory.Error, key: "can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment_1312", message: "'=' can only be used in an object literal property inside a destructuring assignment." }, + The_body_of_an_if_statement_cannot_be_the_empty_statement: { code: 1313, category: ts.DiagnosticCategory.Error, key: "The_body_of_an_if_statement_cannot_be_the_empty_statement_1313", message: "The body of an 'if' statement cannot be the empty statement." }, Duplicate_identifier_0: { code: 2300, category: ts.DiagnosticCategory.Error, key: "Duplicate_identifier_0_2300", message: "Duplicate identifier '{0}'." }, Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor: { code: 2301, category: ts.DiagnosticCategory.Error, key: "Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor_2301", message: "Initializer of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor." }, Static_members_cannot_reference_class_type_parameters: { code: 2302, category: ts.DiagnosticCategory.Error, key: "Static_members_cannot_reference_class_type_parameters_2302", message: "Static members cannot reference class type parameters." }, @@ -2275,7 +2288,7 @@ var ts; Neither_type_0_nor_type_1_is_assignable_to_the_other: { code: 2352, category: ts.DiagnosticCategory.Error, key: "Neither_type_0_nor_type_1_is_assignable_to_the_other_2352", message: "Neither type '{0}' nor type '{1}' is assignable to the other." }, Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1: { code: 2353, category: ts.DiagnosticCategory.Error, key: "Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1_2353", message: "Object literal may only specify known properties, and '{0}' does not exist in type '{1}'." }, No_best_common_type_exists_among_return_expressions: { code: 2354, category: ts.DiagnosticCategory.Error, key: "No_best_common_type_exists_among_return_expressions_2354", message: "No best common type exists among return expressions." }, - A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value_or_consist_of_a_single_throw_statement: { code: 2355, category: ts.DiagnosticCategory.Error, key: "A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value_or_consist_of_a_single_th_2355", message: "A function whose declared type is neither 'void' nor 'any' must return a value or consist of a single 'throw' statement." }, + A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value: { code: 2355, category: ts.DiagnosticCategory.Error, key: "A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value_2355", message: "A function whose declared type is neither 'void' nor 'any' must return a value." }, An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type: { code: 2356, category: ts.DiagnosticCategory.Error, key: "An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type_2356", message: "An arithmetic operand must be of type 'any', 'number' or an enum type." }, The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_property_or_indexer: { code: 2357, category: ts.DiagnosticCategory.Error, key: "The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_property_or_indexer_2357", message: "The operand of an increment or decrement operator must be a variable, property or indexer." }, The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_parameter: { code: 2358, category: ts.DiagnosticCategory.Error, key: "The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_paramete_2358", message: "The left-hand side of an 'instanceof' expression must be of type 'any', an object type or a type parameter." }, @@ -2296,7 +2309,7 @@ var ts; Duplicate_number_index_signature: { code: 2375, category: ts.DiagnosticCategory.Error, key: "Duplicate_number_index_signature_2375", message: "Duplicate number index signature." }, A_super_call_must_be_the_first_statement_in_the_constructor_when_a_class_contains_initialized_properties_or_has_parameter_properties: { code: 2376, category: ts.DiagnosticCategory.Error, key: "A_super_call_must_be_the_first_statement_in_the_constructor_when_a_class_contains_initialized_proper_2376", message: "A 'super' call must be the first statement in the constructor when a class contains initialized properties or has parameter properties." }, Constructors_for_derived_classes_must_contain_a_super_call: { code: 2377, category: ts.DiagnosticCategory.Error, key: "Constructors_for_derived_classes_must_contain_a_super_call_2377", message: "Constructors for derived classes must contain a 'super' call." }, - A_get_accessor_must_return_a_value_or_consist_of_a_single_throw_statement: { code: 2378, category: ts.DiagnosticCategory.Error, key: "A_get_accessor_must_return_a_value_or_consist_of_a_single_throw_statement_2378", message: "A 'get' accessor must return a value or consist of a single 'throw' statement." }, + A_get_accessor_must_return_a_value: { code: 2378, category: ts.DiagnosticCategory.Error, key: "A_get_accessor_must_return_a_value_2378", message: "A 'get' accessor must return a value." }, Getter_and_setter_accessors_do_not_agree_in_visibility: { code: 2379, category: ts.DiagnosticCategory.Error, key: "Getter_and_setter_accessors_do_not_agree_in_visibility_2379", message: "Getter and setter accessors do not agree in visibility." }, get_and_set_accessor_must_have_the_same_type: { code: 2380, category: ts.DiagnosticCategory.Error, key: "get_and_set_accessor_must_have_the_same_type_2380", message: "'get' and 'set' accessor must have the same type." }, A_signature_with_an_implementation_cannot_use_a_string_literal_type: { code: 2381, category: ts.DiagnosticCategory.Error, key: "A_signature_with_an_implementation_cannot_use_a_string_literal_type_2381", message: "A signature with an implementation cannot use a string literal type." }, @@ -2586,8 +2599,6 @@ var ts; NEWLINE: { code: 6061, category: ts.DiagnosticCategory.Message, key: "NEWLINE_6061", message: "NEWLINE" }, Argument_for_newLine_option_must_be_CRLF_or_LF: { code: 6062, category: ts.DiagnosticCategory.Error, key: "Argument_for_newLine_option_must_be_CRLF_or_LF_6062", message: "Argument for '--newLine' option must be 'CRLF' or 'LF'." }, Argument_for_moduleResolution_option_must_be_node_or_classic: { code: 6063, category: ts.DiagnosticCategory.Error, key: "Argument_for_moduleResolution_option_must_be_node_or_classic_6063", message: "Argument for '--moduleResolution' option must be 'node' or 'classic'." }, - Specify_JSX_code_generation_Colon_preserve_or_react: { code: 6080, category: ts.DiagnosticCategory.Message, key: "Specify_JSX_code_generation_Colon_preserve_or_react_6080", message: "Specify JSX code generation: 'preserve' or 'react'" }, - Argument_for_jsx_must_be_preserve_or_react: { code: 6081, category: ts.DiagnosticCategory.Message, key: "Argument_for_jsx_must_be_preserve_or_react_6081", message: "Argument for '--jsx' must be 'preserve' or 'react'." }, Enables_experimental_support_for_ES7_decorators: { code: 6065, category: ts.DiagnosticCategory.Message, key: "Enables_experimental_support_for_ES7_decorators_6065", message: "Enables experimental support for ES7 decorators." }, Enables_experimental_support_for_emitting_type_metadata_for_decorators: { code: 6066, category: ts.DiagnosticCategory.Message, key: "Enables_experimental_support_for_emitting_type_metadata_for_decorators_6066", message: "Enables experimental support for emitting type metadata for decorators." }, Enables_experimental_support_for_ES7_async_functions: { code: 6068, category: ts.DiagnosticCategory.Message, key: "Enables_experimental_support_for_ES7_async_functions_6068", message: "Enables experimental support for ES7 async functions." }, @@ -2595,7 +2606,14 @@ var ts; Initializes_a_TypeScript_project_and_creates_a_tsconfig_json_file: { code: 6070, category: ts.DiagnosticCategory.Message, key: "Initializes_a_TypeScript_project_and_creates_a_tsconfig_json_file_6070", message: "Initializes a TypeScript project and creates a tsconfig.json file." }, Successfully_created_a_tsconfig_json_file: { code: 6071, category: ts.DiagnosticCategory.Message, key: "Successfully_created_a_tsconfig_json_file_6071", message: "Successfully created a tsconfig.json file." }, Suppress_excess_property_checks_for_object_literals: { code: 6072, category: ts.DiagnosticCategory.Message, key: "Suppress_excess_property_checks_for_object_literals_6072", message: "Suppress excess property checks for object literals." }, - Disallow_inconsistently_cased_references_to_the_same_file: { code: 6073, category: ts.DiagnosticCategory.Message, key: "Disallow_inconsistently_cased_references_to_the_same_file_6073", message: "Disallow inconsistently-cased references to the same file." }, + Stylize_errors_and_messages_using_color_and_context_experimental: { code: 6073, category: ts.DiagnosticCategory.Message, key: "Stylize_errors_and_messages_using_color_and_context_experimental_6073", message: "Stylize errors and messages using color and context. (experimental)" }, + Do_not_report_errors_on_unused_labels: { code: 6074, category: ts.DiagnosticCategory.Message, key: "Do_not_report_errors_on_unused_labels_6074", message: "Do not report errors on unused labels." }, + Report_error_when_not_all_code_paths_in_function_return_a_value: { code: 6075, category: ts.DiagnosticCategory.Message, key: "Report_error_when_not_all_code_paths_in_function_return_a_value_6075", message: "Report error when not all code paths in function return a value." }, + Report_errors_for_fallthrough_cases_in_switch_statement: { code: 6076, category: ts.DiagnosticCategory.Message, key: "Report_errors_for_fallthrough_cases_in_switch_statement_6076", message: "Report errors for fallthrough cases in switch statement." }, + Do_not_report_errors_on_unreachable_code: { code: 6077, category: ts.DiagnosticCategory.Message, key: "Do_not_report_errors_on_unreachable_code_6077", message: "Do not report errors on unreachable code." }, + Disallow_inconsistently_cased_references_to_the_same_file: { code: 6078, category: ts.DiagnosticCategory.Message, key: "Disallow_inconsistently_cased_references_to_the_same_file_6078", message: "Disallow inconsistently-cased references to the same file." }, + Specify_JSX_code_generation_Colon_preserve_or_react: { code: 6080, category: ts.DiagnosticCategory.Message, key: "Specify_JSX_code_generation_Colon_preserve_or_react_6080", message: "Specify JSX code generation: 'preserve' or 'react'" }, + Argument_for_jsx_must_be_preserve_or_react: { code: 6081, category: ts.DiagnosticCategory.Message, key: "Argument_for_jsx_must_be_preserve_or_react_6081", message: "Argument for '--jsx' must be 'preserve' or 'react'." }, 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." }, @@ -2613,6 +2631,10 @@ var ts; Function_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions: { code: 7024, category: ts.DiagnosticCategory.Error, key: "Function_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_ref_7024", message: "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." }, Generator_implicitly_has_type_0_because_it_does_not_yield_any_values_Consider_supplying_a_return_type: { code: 7025, category: ts.DiagnosticCategory.Error, key: "Generator_implicitly_has_type_0_because_it_does_not_yield_any_values_Consider_supplying_a_return_typ_7025", message: "Generator implicitly has type '{0}' because it does not yield any values. Consider supplying a return type." }, JSX_element_implicitly_has_type_any_because_no_interface_JSX_0_exists: { code: 7026, category: ts.DiagnosticCategory.Error, key: "JSX_element_implicitly_has_type_any_because_no_interface_JSX_0_exists_7026", message: "JSX element implicitly has type 'any' because no interface 'JSX.{0}' exists" }, + Unreachable_code_detected: { code: 7027, category: ts.DiagnosticCategory.Error, key: "Unreachable_code_detected_7027", message: "Unreachable code detected." }, + Unused_label: { code: 7028, category: ts.DiagnosticCategory.Error, key: "Unused_label_7028", message: "Unused label." }, + Fallthrough_case_in_switch: { code: 7029, category: ts.DiagnosticCategory.Error, key: "Fallthrough_case_in_switch_7029", message: "Fallthrough case in switch." }, + Not_all_code_paths_return_a_value: { code: 7030, category: ts.DiagnosticCategory.Error, key: "Not_all_code_paths_return_a_value_7030", message: "Not all code paths return a value." }, 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." }, @@ -4166,6 +4188,20 @@ var ts; ModuleInstanceState[ModuleInstanceState["ConstEnumOnly"] = 2] = "ConstEnumOnly"; })(ts.ModuleInstanceState || (ts.ModuleInstanceState = {})); var ModuleInstanceState = ts.ModuleInstanceState; + var Reachability; + (function (Reachability) { + Reachability[Reachability["Unintialized"] = 1] = "Unintialized"; + Reachability[Reachability["Reachable"] = 2] = "Reachable"; + Reachability[Reachability["Unreachable"] = 4] = "Unreachable"; + Reachability[Reachability["ReportedUnreachable"] = 8] = "ReportedUnreachable"; + })(Reachability || (Reachability = {})); + function or(state1, state2) { + return (state1 | state2) & 2 /* Reachable */ + ? 2 /* Reachable */ + : (state1 & state2) & 8 /* ReportedUnreachable */ + ? 8 /* ReportedUnreachable */ + : 4 /* Unreachable */; + } function getModuleInstanceState(node) { // A module is uninstantiated if it contains only // 1. interface declarations, type alias declarations @@ -4175,7 +4211,7 @@ var ts; else if (ts.isConstEnumDeclaration(node)) { return 2 /* ConstEnumOnly */; } - else if ((node.kind === 222 /* ImportDeclaration */ || node.kind === 221 /* ImportEqualsDeclaration */) && !(node.flags & 1 /* Export */)) { + else if ((node.kind === 222 /* ImportDeclaration */ || node.kind === 221 /* ImportEqualsDeclaration */) && !(node.flags & 2 /* Export */)) { return 0 /* NonInstantiated */; } else if (node.kind === 219 /* ModuleBlock */) { @@ -4226,31 +4262,56 @@ var ts; // Functions, Methods, Modules, Source-files. ContainerFlags[ContainerFlags["IsContainerWithLocals"] = 5] = "IsContainerWithLocals"; })(ContainerFlags || (ContainerFlags = {})); - function bindSourceFile(file) { + var binder = createBinder(); + function bindSourceFile(file, options) { var start = new Date().getTime(); - bindSourceFileWorker(file); + binder(file, options); ts.bindTime += new Date().getTime() - start; } ts.bindSourceFile = bindSourceFile; - function bindSourceFileWorker(file) { + function createBinder() { + var file; + var options; var parent; var container; var blockScopeContainer; var lastContainer; var seenThisKeyword; + // state used by reachability checks + var hasExplicitReturn; + var currentReachabilityState; + var labelStack; + var labelIndexMap; + var implicitLabels; // 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). - var inStrictMode = !!file.externalModuleIndicator; + var inStrictMode; var symbolCount = 0; - var Symbol = ts.objectAllocator.getSymbolConstructor(); - var classifiableNames = {}; - if (!file.locals) { - bind(file); - file.symbolCount = symbolCount; - file.classifiableNames = classifiableNames; + var Symbol; + var classifiableNames; + function bindSourceFile(f, opts) { + file = f; + options = opts; + inStrictMode = !!file.externalModuleIndicator; + classifiableNames = {}; + Symbol = ts.objectAllocator.getSymbolConstructor(); + if (!file.locals) { + bind(file); + file.symbolCount = symbolCount; + file.classifiableNames = classifiableNames; + } + parent = undefined; + container = undefined; + blockScopeContainer = undefined; + lastContainer = undefined; + seenThisKeyword = false; + hasExplicitReturn = false; + labelStack = undefined; + labelIndexMap = undefined; + implicitLabels = undefined; } - return; + return bindSourceFile; function createSymbol(flags, name) { symbolCount++; return new Symbol(flags, name); @@ -4303,7 +4364,7 @@ var ts; return node.isExportEquals ? "export=" : "default"; case 213 /* FunctionDeclaration */: case 214 /* ClassDeclaration */: - return node.flags & 1024 /* Default */ ? "default" : undefined; + return node.flags & 512 /* Default */ ? "default" : undefined; } } function getDisplayName(node) { @@ -4319,7 +4380,7 @@ var ts; */ function declareSymbol(symbolTable, parent, node, includes, excludes) { ts.Debug.assert(!ts.hasDynamicName(node)); - var isDefaultExport = node.flags & 1024 /* Default */; + var isDefaultExport = node.flags & 512 /* Default */; // The exported symbol for an export default function/class node is always named "default" var name = isDefaultExport && parent ? "default" : getDeclarationName(node); var symbol; @@ -4358,7 +4419,7 @@ var ts; ? ts.Diagnostics.Cannot_redeclare_block_scoped_variable_0 : ts.Diagnostics.Duplicate_identifier_0; ts.forEach(symbol.declarations, function (declaration) { - if (declaration.flags & 1024 /* Default */) { + if (declaration.flags & 512 /* Default */) { message = ts.Diagnostics.A_module_cannot_have_multiple_default_exports; } }); @@ -4377,7 +4438,7 @@ var ts; return symbol; } function declareModuleMember(node, symbolFlags, symbolExcludes) { - var hasExportModifier = ts.getCombinedNodeFlags(node) & 1 /* Export */; + var hasExportModifier = ts.getCombinedNodeFlags(node) & 2 /* Export */; if (symbolFlags & 8388608 /* Alias */) { if (node.kind === 230 /* ExportSpecifier */ || (node.kind === 221 /* ImportEqualsDeclaration */ && hasExportModifier)) { return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); @@ -4398,7 +4459,7 @@ var ts; // 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. - if (hasExportModifier || container.flags & 262144 /* ExportContext */) { + if (hasExportModifier || container.flags & 131072 /* ExportContext */) { var exportKind = (symbolFlags & 107455 /* Value */ ? 1048576 /* ExportValue */ : 0) | (symbolFlags & 793056 /* Type */ ? 2097152 /* ExportType */ : 0) | (symbolFlags & 1536 /* Namespace */ ? 4194304 /* ExportNamespace */ : 0); @@ -4453,18 +4514,229 @@ var ts; blockScopeContainer = node; blockScopeContainer.locals = undefined; } - if (node.kind === 215 /* InterfaceDeclaration */) { + var savedReachabilityState; + var savedLabelStack; + var savedLabels; + var savedImplicitLabels; + var savedHasExplicitReturn; + var kind = node.kind; + var flags = node.flags; + // reset all reachability check related flags on node (for incremental scenarios) + flags &= ~1572864 /* ReachabilityCheckFlags */; + if (kind === 215 /* InterfaceDeclaration */) { seenThisKeyword = false; - ts.forEachChild(node, bind); - node.flags = seenThisKeyword ? node.flags | 524288 /* ContainsThis */ : node.flags & ~524288 /* ContainsThis */; } - else { - ts.forEachChild(node, bind); + var saveState = kind === 248 /* SourceFile */ || kind === 219 /* ModuleBlock */ || ts.isFunctionLikeKind(kind); + if (saveState) { + savedReachabilityState = currentReachabilityState; + savedLabelStack = labelStack; + savedLabels = labelIndexMap; + savedImplicitLabels = implicitLabels; + savedHasExplicitReturn = hasExplicitReturn; + currentReachabilityState = 2 /* Reachable */; + hasExplicitReturn = false; + labelStack = labelIndexMap = implicitLabels = undefined; + } + bindReachableStatement(node); + if (currentReachabilityState === 2 /* Reachable */ && ts.isFunctionLikeKind(kind) && ts.nodeIsPresent(node.body)) { + flags |= 524288 /* HasImplicitReturn */; + if (hasExplicitReturn) { + flags |= 1048576 /* HasExplicitReturn */; + } + } + if (kind === 215 /* InterfaceDeclaration */) { + flags = seenThisKeyword ? flags | 262144 /* ContainsThis */ : flags & ~262144 /* ContainsThis */; + } + node.flags = flags; + if (saveState) { + hasExplicitReturn = savedHasExplicitReturn; + currentReachabilityState = savedReachabilityState; + labelStack = savedLabelStack; + labelIndexMap = savedLabels; + implicitLabels = savedImplicitLabels; } container = saveContainer; parent = saveParent; blockScopeContainer = savedBlockScopeContainer; } + /** + * Returns true if node and its subnodes were successfully traversed. + * Returning false means that node was not examined and caller needs to dive into the node himself. + */ + function bindReachableStatement(node) { + if (checkUnreachable(node)) { + ts.forEachChild(node, bind); + return; + } + switch (node.kind) { + case 198 /* WhileStatement */: + bindWhileStatement(node); + break; + case 197 /* DoStatement */: + bindDoStatement(node); + break; + case 199 /* ForStatement */: + bindForStatement(node); + break; + case 200 /* ForInStatement */: + case 201 /* ForOfStatement */: + bindForInOrForOfStatement(node); + break; + case 196 /* IfStatement */: + bindIfStatement(node); + break; + case 204 /* ReturnStatement */: + case 208 /* ThrowStatement */: + bindReturnOrThrow(node); + break; + case 203 /* BreakStatement */: + case 202 /* ContinueStatement */: + bindBreakOrContinueStatement(node); + break; + case 209 /* TryStatement */: + bindTryStatement(node); + break; + case 206 /* SwitchStatement */: + bindSwitchStatement(node); + break; + case 220 /* CaseBlock */: + bindCaseBlock(node); + break; + case 207 /* LabeledStatement */: + bindLabeledStatement(node); + break; + default: + ts.forEachChild(node, bind); + break; + } + } + function bindWhileStatement(n) { + var preWhileState = n.expression.kind === 84 /* FalseKeyword */ ? 4 /* Unreachable */ : currentReachabilityState; + var postWhileState = n.expression.kind === 99 /* TrueKeyword */ ? 4 /* Unreachable */ : currentReachabilityState; + // bind expressions (don't affect reachability) + bind(n.expression); + currentReachabilityState = preWhileState; + var postWhileLabel = pushImplicitLabel(); + bind(n.statement); + popImplicitLabel(postWhileLabel, postWhileState); + } + function bindDoStatement(n) { + var preDoState = currentReachabilityState; + var postDoLabel = pushImplicitLabel(); + bind(n.statement); + var postDoState = n.expression.kind === 99 /* TrueKeyword */ ? 4 /* Unreachable */ : preDoState; + popImplicitLabel(postDoLabel, postDoState); + // bind expressions (don't affect reachability) + bind(n.expression); + } + function bindForStatement(n) { + var preForState = currentReachabilityState; + var postForLabel = pushImplicitLabel(); + // bind expressions (don't affect reachability) + bind(n.initializer); + bind(n.condition); + bind(n.incrementor); + bind(n.statement); + // for statement is considered infinite when it condition is either omitted or is true keyword + // - for(..;;..) + // - for(..;true;..) + var isInfiniteLoop = (!n.condition || n.condition.kind === 99 /* TrueKeyword */); + var postForState = isInfiniteLoop ? 4 /* Unreachable */ : preForState; + popImplicitLabel(postForLabel, postForState); + } + function bindForInOrForOfStatement(n) { + var preStatementState = currentReachabilityState; + var postStatementLabel = pushImplicitLabel(); + // bind expressions (don't affect reachability) + bind(n.initializer); + bind(n.expression); + bind(n.statement); + popImplicitLabel(postStatementLabel, preStatementState); + } + function bindIfStatement(n) { + // denotes reachability state when entering 'thenStatement' part of the if statement: + // i.e. if condition is false then thenStatement is unreachable + var ifTrueState = n.expression.kind === 84 /* FalseKeyword */ ? 4 /* Unreachable */ : currentReachabilityState; + // denotes reachability state when entering 'elseStatement': + // i.e. if condition is true then elseStatement is unreachable + var ifFalseState = n.expression.kind === 99 /* TrueKeyword */ ? 4 /* Unreachable */ : currentReachabilityState; + currentReachabilityState = ifTrueState; + // bind expression (don't affect reachability) + bind(n.expression); + bind(n.thenStatement); + if (n.elseStatement) { + var preElseState = currentReachabilityState; + currentReachabilityState = ifFalseState; + bind(n.elseStatement); + currentReachabilityState = or(currentReachabilityState, preElseState); + } + else { + currentReachabilityState = or(currentReachabilityState, ifFalseState); + } + } + function bindReturnOrThrow(n) { + // bind expression (don't affect reachability) + bind(n.expression); + if (n.kind === 204 /* ReturnStatement */) { + hasExplicitReturn = true; + } + currentReachabilityState = 4 /* Unreachable */; + } + function bindBreakOrContinueStatement(n) { + // call bind on label (don't affect reachability) + bind(n.label); + // for continue case touch label so it will be marked a used + var isValidJump = jumpToLabel(n.label, n.kind === 203 /* BreakStatement */ ? currentReachabilityState : 4 /* Unreachable */); + if (isValidJump) { + currentReachabilityState = 4 /* Unreachable */; + } + } + function bindTryStatement(n) { + // catch\finally blocks has the same reachability as try block + var preTryState = currentReachabilityState; + bind(n.tryBlock); + var postTryState = currentReachabilityState; + currentReachabilityState = preTryState; + bind(n.catchClause); + var postCatchState = currentReachabilityState; + currentReachabilityState = preTryState; + bind(n.finallyBlock); + // post catch/finally state is reachable if + // - post try state is reachable - control flow can fall out of try block + // - post catch state is reachable - control flow can fall out of catch block + currentReachabilityState = or(postTryState, postCatchState); + } + function bindSwitchStatement(n) { + var preSwitchState = currentReachabilityState; + var postSwitchLabel = pushImplicitLabel(); + // bind expression (don't affect reachability) + bind(n.expression); + bind(n.caseBlock); + var hasDefault = ts.forEach(n.caseBlock.clauses, function (c) { return c.kind === 242 /* DefaultClause */; }); + // post switch state is unreachable if switch is exaustive (has a default case ) and does not have fallthrough from the last case + var postSwitchState = hasDefault && currentReachabilityState !== 2 /* Reachable */ ? 4 /* Unreachable */ : preSwitchState; + popImplicitLabel(postSwitchLabel, postSwitchState); + } + function bindCaseBlock(n) { + var startState = currentReachabilityState; + for (var _i = 0, _a = n.clauses; _i < _a.length; _i++) { + var clause = _a[_i]; + currentReachabilityState = startState; + bind(clause); + if (clause.statements.length && currentReachabilityState === 2 /* Reachable */ && options.noFallthroughCasesInSwitch) { + errorOnFirstToken(clause, ts.Diagnostics.Fallthrough_case_in_switch); + } + } + } + function bindLabeledStatement(n) { + // call bind on label (don't affect reachability) + bind(n.label); + var ok = pushNamedLabel(n.label); + bind(n.statement); + if (ok) { + popNamedLabel(n.label, currentReachabilityState); + } + } function getContainerFlags(node) { switch (node.kind) { case 186 /* ClassExpression */: @@ -4576,7 +4848,7 @@ var ts; } } function declareClassMember(node, symbolFlags, symbolExcludes) { - return node.flags & 128 /* Static */ + return node.flags & 64 /* Static */ ? declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes) : declareSymbol(container.symbol.members, container.symbol, node, symbolFlags, symbolExcludes); } @@ -4585,15 +4857,6 @@ var ts; ? declareModuleMember(node, symbolFlags, symbolExcludes) : declareSymbol(file.locals, undefined, node, symbolFlags, symbolExcludes); } - function isAmbientContext(node) { - while (node) { - if (node.flags & 2 /* Ambient */) { - return true; - } - node = node.parent; - } - return false; - } function hasExportDeclarations(node) { var body = node.kind === 248 /* SourceFile */ ? node : node.body; if (body.kind === 248 /* SourceFile */ || body.kind === 219 /* ModuleBlock */) { @@ -4609,11 +4872,11 @@ var ts; function setExportContextFlag(node) { // 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 (isAmbientContext(node) && !hasExportDeclarations(node)) { - node.flags |= 262144 /* ExportContext */; + if (ts.isInAmbientContext(node) && !hasExportDeclarations(node)) { + node.flags |= 131072 /* ExportContext */; } else { - node.flags &= ~262144 /* ExportContext */; + node.flags &= ~131072 /* ExportContext */; } } function bindModuleDeclaration(node) { @@ -4805,7 +5068,7 @@ var ts; } } function checkStrictModeNumericLiteral(node) { - if (inStrictMode && node.flags & 65536 /* OctalLiteral */) { + if (inStrictMode && node.flags & 32768 /* OctalLiteral */) { file.bindDiagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.Octal_literals_are_not_allowed_in_strict_mode)); } } @@ -4829,10 +5092,10 @@ var ts; function checkStrictModeWithStatement(node) { // Grammar checking for withStatement if (inStrictMode) { - grammarErrorOnFirstToken(node, ts.Diagnostics.with_statements_are_not_allowed_in_strict_mode); + errorOnFirstToken(node, ts.Diagnostics.with_statements_are_not_allowed_in_strict_mode); } } - function grammarErrorOnFirstToken(node, message, arg0, arg1, arg2) { + function errorOnFirstToken(node, message, arg0, arg1, arg2) { var span = ts.getSpanOfTokenAtPosition(file, node.pos); file.bindDiagnostics.push(ts.createFileDiagnostic(file, span.start, span.length, message, arg0, arg1, arg2)); } @@ -4840,6 +5103,9 @@ var ts; return "__" + ts.indexOf(node.parent.parameters, node); } function bind(node) { + if (!node) { + return; + } node.parent = parent; var savedInStrictMode = inStrictMode; if (!savedInStrictMode) { @@ -4882,8 +5148,8 @@ var ts; } } function updateStrictModeStatementList(statements) { - for (var _i = 0; _i < statements.length; _i++) { - var statement = statements[_i]; + for (var _i = 0, statements_1 = statements; _i < statements_1.length; _i++) { + var statement = statements_1[_i]; if (!ts.isPrologueDirective(statement)) { return; } @@ -5105,7 +5371,7 @@ var ts; } // If this is a property-parameter, then also declare the property symbol into the // containing class. - if (node.flags & 112 /* AccessibilityModifier */ && + if (node.flags & 56 /* AccessibilityModifier */ && node.parent.kind === 144 /* Constructor */ && ts.isClassLike(node.parent.parent)) { var classDeclaration = node.parent.parent; @@ -5117,6 +5383,112 @@ var ts; ? bindAnonymousDeclaration(node, symbolFlags, "__computed") : declareSymbolAndAddToSymbolTable(node, symbolFlags, symbolExcludes); } + // reachability checks + function pushNamedLabel(name) { + initializeReachabilityStateIfNecessary(); + if (ts.hasProperty(labelIndexMap, name.text)) { + return false; + } + labelIndexMap[name.text] = labelStack.push(1 /* Unintialized */) - 1; + return true; + } + function pushImplicitLabel() { + initializeReachabilityStateIfNecessary(); + var index = labelStack.push(1 /* Unintialized */) - 1; + implicitLabels.push(index); + return index; + } + function popNamedLabel(label, outerState) { + var index = labelIndexMap[label.text]; + ts.Debug.assert(index !== undefined); + ts.Debug.assert(labelStack.length == index + 1); + labelIndexMap[label.text] = undefined; + setCurrentStateAtLabel(labelStack.pop(), outerState, label); + } + function popImplicitLabel(implicitLabelIndex, outerState) { + if (labelStack.length !== implicitLabelIndex + 1) { + ts.Debug.assert(false, "Label stack: " + labelStack.length + ", index:" + implicitLabelIndex); + } + var i = implicitLabels.pop(); + if (implicitLabelIndex !== i) { + ts.Debug.assert(false, "i: " + i + ", index: " + implicitLabelIndex); + } + setCurrentStateAtLabel(labelStack.pop(), outerState, /*name*/ undefined); + } + function setCurrentStateAtLabel(innerMergedState, outerState, label) { + if (innerMergedState === 1 /* Unintialized */) { + if (label && !options.allowUnusedLabels) { + file.bindDiagnostics.push(ts.createDiagnosticForNode(label, ts.Diagnostics.Unused_label)); + } + currentReachabilityState = outerState; + } + else { + currentReachabilityState = or(innerMergedState, outerState); + } + } + function jumpToLabel(label, outerState) { + initializeReachabilityStateIfNecessary(); + var index = label ? labelIndexMap[label.text] : ts.lastOrUndefined(implicitLabels); + if (index === undefined) { + // reference to unknown label or + // break/continue used outside of loops + return false; + } + var stateAtLabel = labelStack[index]; + labelStack[index] = stateAtLabel === 1 /* Unintialized */ ? outerState : or(stateAtLabel, outerState); + return true; + } + function checkUnreachable(node) { + switch (currentReachabilityState) { + case 4 /* Unreachable */: + var reportError = + // report error on all statements + ts.isStatement(node) || + // report error on class declarations + node.kind === 214 /* ClassDeclaration */ || + // report error on instantiated modules or const-enums only modules if preserveConstEnums is set + (node.kind === 218 /* ModuleDeclaration */ && shouldReportErrorOnModuleDeclaration(node)) || + // report error on regular enums and const enums if preserveConstEnums is set + (node.kind === 217 /* EnumDeclaration */ && (!ts.isConstEnumDeclaration(node) || options.preserveConstEnums)); + if (reportError) { + currentReachabilityState = 8 /* ReportedUnreachable */; + // 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 + var reportUnreachableCode = !options.allowUnreachableCode && + !ts.isInAmbientContext(node) && + (node.kind !== 193 /* VariableStatement */ || + ts.getCombinedNodeFlags(node.declarationList) & 24576 /* BlockScoped */ || + ts.forEach(node.declarationList.declarations, function (d) { return d.initializer; })); + if (reportUnreachableCode) { + errorOnFirstToken(node, ts.Diagnostics.Unreachable_code_detected); + } + } + case 8 /* ReportedUnreachable */: + return true; + default: + return false; + } + function shouldReportErrorOnModuleDeclaration(node) { + var instanceState = getModuleInstanceState(node); + return instanceState === 1 /* Instantiated */ || (instanceState === 2 /* ConstEnumOnly */ && options.preserveConstEnums); + } + } + function initializeReachabilityStateIfNecessary() { + if (labelIndexMap) { + return; + } + currentReachabilityState = 2 /* Reachable */; + labelIndexMap = {}; + labelStack = []; + implicitLabels = []; + } } })(ts || (ts = {})); /// @@ -5127,8 +5499,8 @@ var ts; function getDeclarationOfKind(symbol, kind) { var declarations = symbol.declarations; if (declarations) { - for (var _i = 0; _i < declarations.length; _i++) { - var declaration = declarations[_i]; + for (var _i = 0, declarations_1 = declarations; _i < declarations_1.length; _i++) { + var declaration = declarations_1[_i]; if (declaration.kind === kind) { return declaration; } @@ -5328,7 +5700,7 @@ var ts; } ts.makeIdentifierFromModuleName = makeIdentifierFromModuleName; function isBlockOrCatchScoped(declaration) { - return (getCombinedNodeFlags(declaration) & 49152 /* BlockScoped */) !== 0 || + return (getCombinedNodeFlags(declaration) & 24576 /* BlockScoped */) !== 0 || isCatchClauseVariableDeclaration(declaration); } ts.isBlockOrCatchScoped = isBlockOrCatchScoped; @@ -5441,7 +5813,7 @@ var ts; } ts.isExternalModule = isExternalModule; function isDeclarationFile(file) { - return (file.flags & 8192 /* DeclarationFile */) !== 0; + return (file.flags & 4096 /* DeclarationFile */) !== 0; } ts.isDeclarationFile = isDeclarationFile; function isConstEnumDeclaration(node) { @@ -5478,11 +5850,11 @@ var ts; } ts.getCombinedNodeFlags = getCombinedNodeFlags; function isConst(node) { - return !!(getCombinedNodeFlags(node) & 32768 /* Const */); + return !!(getCombinedNodeFlags(node) & 16384 /* Const */); } ts.isConst = isConst; function isLet(node) { - return !!(getCombinedNodeFlags(node) & 16384 /* Let */); + return !!(getCombinedNodeFlags(node) & 8192 /* Let */); } ts.isLet = isLet; function isPrologueDirective(node) { @@ -5683,27 +6055,28 @@ var ts; } ts.isClassLike = isClassLike; function isFunctionLike(node) { - if (node) { - switch (node.kind) { - case 144 /* Constructor */: - case 173 /* FunctionExpression */: - case 213 /* FunctionDeclaration */: - case 174 /* ArrowFunction */: - case 143 /* MethodDeclaration */: - case 142 /* MethodSignature */: - case 145 /* GetAccessor */: - case 146 /* SetAccessor */: - case 147 /* CallSignature */: - case 148 /* ConstructSignature */: - case 149 /* IndexSignature */: - case 152 /* FunctionType */: - case 153 /* ConstructorType */: - return true; - } - } - return false; + return node && isFunctionLikeKind(node.kind); } ts.isFunctionLike = isFunctionLike; + function isFunctionLikeKind(kind) { + switch (kind) { + case 144 /* Constructor */: + case 173 /* FunctionExpression */: + case 213 /* FunctionDeclaration */: + case 174 /* ArrowFunction */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: + case 147 /* CallSignature */: + case 148 /* ConstructSignature */: + case 149 /* IndexSignature */: + case 152 /* FunctionType */: + case 153 /* ConstructorType */: + return true; + } + } + ts.isFunctionLikeKind = isFunctionLikeKind; function introducesArgumentsExoticObject(node) { switch (node.kind) { case 143 /* MethodDeclaration */: @@ -6206,9 +6579,18 @@ var ts; return !!node && (node.kind === 162 /* ArrayBindingPattern */ || node.kind === 161 /* ObjectBindingPattern */); } ts.isBindingPattern = isBindingPattern; + function isNodeDescendentOf(node, ancestor) { + while (node) { + if (node === ancestor) + return true; + node = node.parent; + } + return false; + } + ts.isNodeDescendentOf = isNodeDescendentOf; function isInAmbientContext(node) { while (node) { - if (node.flags & (2 /* Ambient */ | 8192 /* DeclarationFile */)) { + if (node.flags & (4 /* Ambient */ | 4096 /* DeclarationFile */)) { return true; } node = node.parent; @@ -6266,7 +6648,7 @@ var ts; case 207 /* LabeledStatement */: case 204 /* ReturnStatement */: case 206 /* SwitchStatement */: - case 98 /* ThrowKeyword */: + case 208 /* ThrowStatement */: case 209 /* TryStatement */: case 193 /* VariableStatement */: case 198 /* WhileStatement */: @@ -6379,8 +6761,8 @@ var ts; ts.getInterfaceBaseTypeNodes = getInterfaceBaseTypeNodes; function getHeritageClause(clauses, kind) { if (clauses) { - for (var _i = 0; _i < clauses.length; _i++) { - var clause = clauses[_i]; + for (var _i = 0, clauses_1 = clauses; _i < clauses_1.length; _i++) { + var clause = clauses_1[_i]; if (clause.token === kind) { return clause; } @@ -6392,7 +6774,6 @@ var ts; function tryResolveScriptReference(host, sourceFile, reference) { if (!host.getCompilerOptions().noResolve) { var referenceFileName = ts.isRootedDiskPath(reference.fileName) ? reference.fileName : ts.combinePaths(ts.getDirectoryPath(sourceFile.fileName), reference.fileName); - referenceFileName = ts.getNormalizedAbsolutePath(referenceFileName, host.getCurrentDirectory()); return host.getSourceFile(referenceFileName); } } @@ -6450,7 +6831,7 @@ var ts; } ts.isTrivia = isTrivia; function isAsyncFunctionLike(node) { - return isFunctionLike(node) && (node.flags & 512 /* Async */) !== 0 && !isAccessor(node); + return isFunctionLike(node) && (node.flags & 256 /* Async */) !== 0 && !isAccessor(node); } ts.isAsyncFunctionLike = isAsyncFunctionLike; /** @@ -6837,7 +7218,7 @@ var ts; else { ts.forEach(declarations, function (member) { if ((member.kind === 145 /* GetAccessor */ || member.kind === 146 /* SetAccessor */) - && (member.flags & 128 /* Static */) === (accessor.flags & 128 /* Static */)) { + && (member.flags & 64 /* Static */) === (accessor.flags & 64 /* Static */)) { var memberName = getPropertyNameForPropertyNameNode(member.name); var accessorName = getPropertyNameForPropertyNameNode(accessor.name); if (memberName === accessorName) { @@ -6894,6 +7275,66 @@ var ts; }); } ts.emitComments = emitComments; + /** + * Detached comment is a comment at the top of file or function body that is separated from + * the next statement by space. + */ + function emitDetachedComments(currentSourceFile, writer, writeComment, node, newLine, removeComments) { + var leadingComments; + var currentDetachedCommentInfo; + if (removeComments) { + // removeComments is true, only reserve pinned comment at the top of file + // For example: + // /*! Pinned Comment */ + // + // var x = 10; + if (node.pos === 0) { + leadingComments = ts.filter(ts.getLeadingCommentRanges(currentSourceFile.text, node.pos), isPinnedComment); + } + } + else { + // removeComments is false, just get detached as normal and bypass the process to filter comment + leadingComments = ts.getLeadingCommentRanges(currentSourceFile.text, node.pos); + } + if (leadingComments) { + var detachedComments = []; + var lastComment; + for (var _i = 0, leadingComments_1 = leadingComments; _i < leadingComments_1.length; _i++) { + var comment = leadingComments_1[_i]; + if (lastComment) { + var lastCommentLine = getLineOfLocalPosition(currentSourceFile, lastComment.end); + var commentLine = getLineOfLocalPosition(currentSourceFile, comment.pos); + if (commentLine >= lastCommentLine + 2) { + // There was a blank line between the last comment and this comment. This + // comment is not part of the copyright comments. Return what we have so + // far. + break; + } + } + detachedComments.push(comment); + lastComment = comment; + } + if (detachedComments.length) { + // All comments look like they could have been part of the copyright header. Make + // sure there is at least one blank line between it and the node. If not, it's not + // a copyright header. + var lastCommentLine = getLineOfLocalPosition(currentSourceFile, ts.lastOrUndefined(detachedComments).end); + var nodeLine = getLineOfLocalPosition(currentSourceFile, ts.skipTrivia(currentSourceFile.text, node.pos)); + if (nodeLine >= lastCommentLine + 2) { + // Valid detachedComments + emitNewLineBeforeLeadingComments(currentSourceFile, writer, node, leadingComments); + emitComments(currentSourceFile, writer, detachedComments, /*trailingSeparator*/ true, newLine, writeComment); + currentDetachedCommentInfo = { nodePos: node.pos, detachedCommentEndPos: ts.lastOrUndefined(detachedComments).end }; + } + } + } + return currentDetachedCommentInfo; + function isPinnedComment(comment) { + return currentSourceFile.text.charCodeAt(comment.pos + 1) === 42 /* asterisk */ && + currentSourceFile.text.charCodeAt(comment.pos + 2) === 33 /* exclamation */; + } + } + ts.emitDetachedComments = emitDetachedComments; function writeCommentRange(currentSourceFile, writer, comment, newLine) { if (currentSourceFile.text.charCodeAt(comment.pos + 1) === 42 /* asterisk */) { var firstCommentLineAndCharacter = ts.getLineAndCharacterOfPosition(currentSourceFile, comment.pos); @@ -6983,16 +7424,16 @@ var ts; ts.writeCommentRange = writeCommentRange; function modifierToFlag(token) { switch (token) { - case 113 /* StaticKeyword */: return 128 /* Static */; - case 112 /* PublicKeyword */: return 16 /* Public */; - case 111 /* ProtectedKeyword */: return 64 /* Protected */; - case 110 /* PrivateKeyword */: return 32 /* Private */; - case 115 /* AbstractKeyword */: return 256 /* Abstract */; - case 82 /* ExportKeyword */: return 1 /* Export */; - case 122 /* DeclareKeyword */: return 2 /* Ambient */; - case 74 /* ConstKeyword */: return 32768 /* Const */; - case 77 /* DefaultKeyword */: return 1024 /* Default */; - case 118 /* AsyncKeyword */: return 512 /* Async */; + case 113 /* StaticKeyword */: return 64 /* Static */; + case 112 /* PublicKeyword */: return 8 /* Public */; + case 111 /* ProtectedKeyword */: return 32 /* Protected */; + case 110 /* PrivateKeyword */: return 16 /* Private */; + case 115 /* AbstractKeyword */: return 128 /* Abstract */; + case 82 /* ExportKeyword */: return 2 /* Export */; + case 122 /* DeclareKeyword */: return 4 /* Ambient */; + case 74 /* ConstKeyword */: return 16384 /* Const */; + case 77 /* DefaultKeyword */: return 512 /* Default */; + case 118 /* AsyncKeyword */: return 256 /* Async */; } return 0; } @@ -7073,7 +7514,7 @@ var ts; } ts.isEmptyObjectLiteralOrArrayLiteral = isEmptyObjectLiteralOrArrayLiteral; function getLocalSymbolForExportDefault(symbol) { - return symbol && symbol.valueDeclaration && (symbol.valueDeclaration.flags & 1024 /* Default */) ? symbol.valueDeclaration.localSymbol : undefined; + return symbol && symbol.valueDeclaration && (symbol.valueDeclaration.flags & 512 /* Default */) ? symbol.valueDeclaration.localSymbol : undefined; } ts.getLocalSymbolForExportDefault = getLocalSymbolForExportDefault; function isJavaScript(fileName) { @@ -7150,6 +7591,12 @@ 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) { @@ -7414,8 +7861,8 @@ var ts; } function visitEachNode(cbNode, nodes) { if (nodes) { - for (var _i = 0; _i < nodes.length; _i++) { - var node = nodes[_i]; + for (var _i = 0, nodes_1 = nodes; _i < nodes_1.length; _i++) { + var node = nodes_1[_i]; var result = cbNode(node); if (result) { return result; @@ -7982,8 +8429,8 @@ var ts; function addJSDocComment(node) { var comments = ts.getLeadingCommentRangesOfNode(node, sourceFile); if (comments) { - for (var _i = 0; _i < comments.length; _i++) { - var comment = comments[_i]; + for (var _i = 0, comments_1 = comments; _i < comments_1.length; _i++) { + var comment = comments_1[_i]; var jsDocComment = JSDocParser.parseJSDocComment(node, comment.pos, comment.end - comment.pos); if (jsDocComment) { node.jsDocComment = jsDocComment; @@ -8021,7 +8468,7 @@ var ts; sourceFile.bindDiagnostics = []; sourceFile.languageVersion = languageVersion; sourceFile.fileName = ts.normalizePath(fileName); - sourceFile.flags = ts.fileExtensionIs(sourceFile.fileName, ".d.ts") ? 8192 /* DeclarationFile */ : 0; + sourceFile.flags = ts.fileExtensionIs(sourceFile.fileName, ".d.ts") ? 4096 /* DeclarationFile */ : 0; sourceFile.languageVariant = ts.isTsx(sourceFile.fileName) ? 1 /* JSX */ : 0 /* Standard */; return sourceFile; } @@ -9079,7 +9526,7 @@ var ts; if (node.kind === 8 /* NumericLiteral */ && sourceText.charCodeAt(tokenPos) === 48 /* _0 */ && ts.isOctalDigit(sourceText.charCodeAt(tokenPos + 1))) { - node.flags |= 65536 /* OctalLiteral */; + node.flags |= 32768 /* OctalLiteral */; } return node; } @@ -9832,7 +10279,7 @@ var ts; // Didn't appear to actually be a parenthesized arrow function. Just bail out. return undefined; } - var isAsync = !!(arrowFunction.flags & 512 /* Async */); + var isAsync = !!(arrowFunction.flags & 256 /* Async */); // 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; @@ -9959,7 +10406,7 @@ var ts; function parseParenthesizedArrowFunctionExpressionHead(allowAmbiguity) { var node = createNode(174 /* ArrowFunction */); setModifiers(node, parseModifiersForArrowFunction()); - var isAsync = !!(node.flags & 512 /* Async */); + var isAsync = !!(node.flags & 256 /* Async */); // Arrow functions are never generators. // // If we're speculatively parsing a signature for a parenthesized arrow function, then @@ -10802,7 +11249,7 @@ var ts; var node = createNode(164 /* ArrayLiteralExpression */); parseExpected(19 /* OpenBracketToken */); if (scanner.hasPrecedingLineBreak()) - node.flags |= 2048 /* MultiLine */; + node.flags |= 1024 /* MultiLine */; node.elements = parseDelimitedList(15 /* ArrayLiteralMembers */, parseArgumentOrArrayLiteralElement); parseExpected(20 /* CloseBracketToken */); return finishNode(node); @@ -10863,7 +11310,7 @@ var ts; var node = createNode(165 /* ObjectLiteralExpression */); parseExpected(15 /* OpenBraceToken */); if (scanner.hasPrecedingLineBreak()) { - node.flags |= 2048 /* MultiLine */; + node.flags |= 1024 /* MultiLine */; } node.properties = parseDelimitedList(12 /* ObjectLiteralMembers */, parseObjectLiteralElement, /*considerSemicolonAsDelimeter*/ true); parseExpected(16 /* CloseBraceToken */); @@ -10884,7 +11331,7 @@ var ts; parseExpected(87 /* FunctionKeyword */); node.asteriskToken = parseOptionalToken(37 /* AsteriskToken */); var isGenerator = !!node.asteriskToken; - var isAsync = !!(node.flags & 512 /* Async */); + var isAsync = !!(node.flags & 256 /* Async */); node.name = isGenerator && isAsync ? doInYieldAndAwaitContext(parseOptionalIdentifier) : isGenerator ? doInYieldContext(parseOptionalIdentifier) : @@ -11476,10 +11923,10 @@ var ts; case 102 /* VarKeyword */: break; case 108 /* LetKeyword */: - node.flags |= 16384 /* Let */; + node.flags |= 8192 /* Let */; break; case 74 /* ConstKeyword */: - node.flags |= 32768 /* Const */; + node.flags |= 16384 /* Const */; break; default: ts.Debug.fail(); @@ -11522,9 +11969,9 @@ var ts; setModifiers(node, modifiers); parseExpected(87 /* FunctionKeyword */); node.asteriskToken = parseOptionalToken(37 /* AsteriskToken */); - node.name = node.flags & 1024 /* Default */ ? parseOptionalIdentifier() : parseIdentifier(); + node.name = node.flags & 512 /* Default */ ? parseOptionalIdentifier() : parseIdentifier(); var isGenerator = !!node.asteriskToken; - var isAsync = !!(node.flags & 512 /* Async */); + var isAsync = !!(node.flags & 256 /* Async */); fillSignature(54 /* ColonToken */, /*yieldContext*/ isGenerator, /*awaitContext*/ isAsync, /*requireCompleteParameterList*/ false, node); node.body = parseFunctionBlockOrSemicolon(isGenerator, isAsync, ts.Diagnostics.or_expected); return finishNode(node); @@ -11546,7 +11993,7 @@ var ts; method.name = name; method.questionToken = questionToken; var isGenerator = !!asteriskToken; - var isAsync = !!(method.flags & 512 /* Async */); + var isAsync = !!(method.flags & 256 /* Async */); fillSignature(54 /* ColonToken */, /*yieldContext*/ isGenerator, /*awaitContext*/ isAsync, /*requireCompleteParameterList*/ false, method); method.body = parseFunctionBlockOrSemicolon(isGenerator, isAsync, diagnosticMessage); return finishNode(method); @@ -11567,7 +12014,7 @@ var ts; // AccessibilityModifier_opt static_opt PropertyName TypeAnnotation_opt Initialiser_opt[In, ?Yield]; // // The checker may still error in the static case to explicitly disallow the yield expression. - property.initializer = modifiers && modifiers.flags & 128 /* Static */ + property.initializer = modifiers && modifiers.flags & 64 /* Static */ ? allowInAnd(parseNonParameterInitializer) : doOutsideOfContext(2 /* Yield */ | 1 /* DisallowIn */, parseNonParameterInitializer); parseSemicolon(); @@ -11900,13 +12347,13 @@ var ts; var node = createNode(218 /* ModuleDeclaration */, fullStart); // If we are parsing a dotted namespace name, we want to // propagate the 'Namespace' flag across the names if set. - var namespaceFlag = flags & 131072 /* Namespace */; + var namespaceFlag = flags & 65536 /* Namespace */; node.decorators = decorators; setModifiers(node, modifiers); node.flags |= flags; node.name = parseIdentifier(); node.body = parseOptional(21 /* DotToken */) - ? parseModuleOrNamespaceDeclaration(getNodePos(), /*decorators*/ undefined, /*modifiers*/ undefined, 1 /* Export */ | namespaceFlag) + ? parseModuleOrNamespaceDeclaration(getNodePos(), /*decorators*/ undefined, /*modifiers*/ undefined, 2 /* Export */ | namespaceFlag) : parseModuleBlock(); return finishNode(node); } @@ -11921,7 +12368,7 @@ var ts; function parseModuleDeclaration(fullStart, decorators, modifiers) { var flags = modifiers ? modifiers.flags : 0; if (parseOptional(126 /* NamespaceKeyword */)) { - flags |= 131072 /* Namespace */; + flags |= 65536 /* Namespace */; } else { parseExpected(125 /* ModuleKeyword */); @@ -12179,7 +12626,7 @@ var ts; } function setExternalModuleIndicator(sourceFile) { sourceFile.externalModuleIndicator = ts.forEach(sourceFile.statements, function (node) { - return node.flags & 1 /* Export */ + return node.flags & 2 /* Export */ || node.kind === 221 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 232 /* ExternalModuleReference */ || node.kind === 222 /* ImportDeclaration */ || node.kind === 227 /* ExportAssignment */ @@ -12868,8 +13315,8 @@ var ts; array._children = undefined; array.pos += delta; array.end += delta; - for (var _i = 0; _i < array.length; _i++) { - var node = array[_i]; + for (var _i = 0, array_7 = array; _i < array_7.length; _i++) { + var node = array_7[_i]; visitNode(node); } } @@ -13006,8 +13453,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; _i < array.length; _i++) { - var node = array[_i]; + for (var _i = 0, array_8 = array; _i < array_8.length; _i++) { + var node = array_8[_i]; visitNode(node); } return; @@ -13374,6 +13821,7 @@ var ts; var getInstantiatedGlobalPromiseLikeType; var getGlobalPromiseConstructorLikeType; var getGlobalThenableType; + var jsxElementClassType; var tupleTypes = {}; var unionTypes = {}; var intersectionTypes = {}; @@ -13643,7 +14091,7 @@ var ts; } var initializerOfNonStaticProperty = current.parent && current.parent.kind === 141 /* PropertyDeclaration */ && - (current.parent.flags & 128 /* Static */) === 0 && + (current.parent.flags & 64 /* Static */) === 0 && current.parent.initializer === current; if (initializerOfNonStaticProperty) { return true; @@ -13725,7 +14173,7 @@ var ts; // local variables of the constructor. This effectively means that entities from outer scopes // by the same name as a constructor parameter or local variable are inaccessible // in initializer expressions for instance member variables. - if (ts.isClassLike(location.parent) && !(location.flags & 128 /* Static */)) { + if (ts.isClassLike(location.parent) && !(location.flags & 64 /* Static */)) { var ctor = findConstructorDeclaration(location.parent); if (ctor && ctor.locals) { if (getSymbol(ctor.locals, name, meaning & 107455 /* Value */)) { @@ -13739,7 +14187,7 @@ var ts; case 186 /* ClassExpression */: case 215 /* InterfaceDeclaration */: if (result = getSymbol(getSymbolOfNode(location).members, name, meaning & 793056 /* Type */)) { - if (lastLocation && lastLocation.flags & 128 /* Static */) { + if (lastLocation && lastLocation.flags & 64 /* Static */) { // TypeScript 1.0 spec (April 2014): 3.4.1 // The scope of a type parameter extends over the entire declaration with which the type // parameter list is associated, with the exception of static member declarations in classes. @@ -14267,8 +14715,8 @@ var ts; } function findConstructorDeclaration(node) { var members = node.members; - for (var _i = 0; _i < members.length; _i++) { - var member = members[_i]; + for (var _i = 0, members_1 = members; _i < members_1.length; _i++) { + var member = members_1[_i]; if (member.kind === 144 /* Constructor */ && ts.nodeIsPresent(member.body)) { return member; } @@ -14515,7 +14963,7 @@ var ts; // because these kind of aliases can be used to name types in declaration file var anyImportSyntax = getAnyImportSyntax(declaration); if (anyImportSyntax && - !(anyImportSyntax.flags & 1 /* Export */) && + !(anyImportSyntax.flags & 2 /* Export */) && isDeclarationVisible(anyImportSyntax.parent)) { getNodeLinks(declaration).isVisible = true; if (aliasesToMakeVisible) { @@ -14669,8 +15117,8 @@ var ts; walkSymbol(getParentOfSymbol(accessibleSymbolChain ? accessibleSymbolChain[0] : symbol), getQualifiedLeftMeaning(meaning)); } if (accessibleSymbolChain) { - for (var _i = 0; _i < accessibleSymbolChain.length; _i++) { - var accessibleSymbol = accessibleSymbolChain[_i]; + for (var _i = 0, accessibleSymbolChain_1 = accessibleSymbolChain; _i < accessibleSymbolChain_1.length; _i++) { + var accessibleSymbol = accessibleSymbolChain_1[_i]; appendParentTypeArgumentsAndSymbolName(accessibleSymbol); } } @@ -14860,7 +15308,7 @@ var ts; } function shouldWriteTypeOfFunctionSymbol() { var isStaticMethodSymbol = !!(symbol.flags & 8192 /* Method */ && - ts.forEach(symbol.declarations, function (declaration) { return declaration.flags & 128 /* Static */; })); + ts.forEach(symbol.declarations, function (declaration) { return declaration.flags & 64 /* Static */; })); var isNonLocalFunctionSymbol = !!(symbol.flags & 16 /* Function */) && (symbol.parent || ts.forEach(symbol.declarations, function (declaration) { @@ -14971,8 +15419,8 @@ var ts; var t = getTypeOfSymbol(p); if (p.flags & (16 /* Function */ | 8192 /* Method */) && !getPropertiesOfObjectType(t).length) { var signatures = getSignaturesOfType(t, 0 /* Call */); - for (var _f = 0; _f < signatures.length; _f++) { - var signature = signatures[_f]; + for (var _f = 0, signatures_1 = signatures; _f < signatures_1.length; _f++) { + var signature = signatures_1[_f]; buildSymbolDisplay(p, writer); if (p.flags & 536870912 /* Optional */) { writePunctuation(writer, 53 /* QuestionToken */); @@ -15186,7 +15634,7 @@ var ts; case 221 /* ImportEqualsDeclaration */: var parent_4 = getDeclarationContainer(node); // If the node is not exported or it is not ambient module element (except import declaration) - if (!(ts.getCombinedNodeFlags(node) & 1 /* Export */) && + if (!(ts.getCombinedNodeFlags(node) & 2 /* Export */) && !(node.kind !== 221 /* ImportEqualsDeclaration */ && parent_4.kind !== 248 /* SourceFile */ && ts.isInAmbientContext(parent_4))) { return isGlobalSourceFile(parent_4); } @@ -15198,7 +15646,7 @@ var ts; case 146 /* SetAccessor */: case 143 /* MethodDeclaration */: case 142 /* MethodSignature */: - if (node.flags & (32 /* Private */ | 64 /* Protected */)) { + if (node.flags & (16 /* Private */ | 32 /* Protected */)) { // Private/protected properties/methods are not visible return false; } @@ -15728,8 +16176,8 @@ var ts; // The function allocates a new array if the input type parameter set is undefined, but otherwise it modifies the set // in-place and returns the same array. function appendTypeParameters(typeParameters, declarations) { - for (var _i = 0; _i < declarations.length; _i++) { - var declaration = declarations[_i]; + for (var _i = 0, declarations_2 = declarations; _i < declarations_2.length; _i++) { + var declaration = declarations_2[_i]; var tp = getDeclaredTypeOfTypeParameter(getSymbolOfNode(declaration)); if (!typeParameters) { typeParameters = [tp]; @@ -15934,13 +16382,13 @@ var ts; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; if (declaration.kind === 215 /* InterfaceDeclaration */) { - if (declaration.flags & 524288 /* ContainsThis */) { + if (declaration.flags & 262144 /* ContainsThis */) { return false; } var baseTypeNodes = ts.getInterfaceBaseTypeNodes(declaration); if (baseTypeNodes) { - for (var _b = 0; _b < baseTypeNodes.length; _b++) { - var node = baseTypeNodes[_b]; + for (var _b = 0, baseTypeNodes_1 = baseTypeNodes; _b < baseTypeNodes_1.length; _b++) { + var node = baseTypeNodes_1[_b]; if (ts.isSupportedExpressionWithTypeArguments(node)) { var baseSymbol = resolveEntityName(node.expression, 793056 /* Type */, /*ignoreErrors*/ true); if (!baseSymbol || !(baseSymbol.flags & 64 /* Interface */) || getDeclaredTypeOfClassOrInterface(baseSymbol).thisType) { @@ -16130,8 +16578,8 @@ var ts; } function createSymbolTable(symbols) { var result = {}; - for (var _i = 0; _i < symbols.length; _i++) { - var symbol = symbols[_i]; + for (var _i = 0, symbols_1 = symbols; _i < symbols_1.length; _i++) { + var symbol = symbols_1[_i]; result[symbol.name] = symbol; } return result; @@ -16140,15 +16588,15 @@ var ts; // we check symbols to see if we can quickly conclude they are free of "this" references, thus needing no instantiation. function createInstantiatedSymbolTable(symbols, mapper, mappingThisOnly) { var result = {}; - for (var _i = 0; _i < symbols.length; _i++) { - var symbol = symbols[_i]; + for (var _i = 0, symbols_2 = symbols; _i < symbols_2.length; _i++) { + var symbol = symbols_2[_i]; result[symbol.name] = mappingThisOnly && isIndependentMember(symbol) ? symbol : instantiateSymbol(symbol, mapper); } return result; } function addInheritedMembers(symbols, baseSymbols) { - for (var _i = 0; _i < baseSymbols.length; _i++) { - var s = baseSymbols[_i]; + for (var _i = 0, baseSymbols_1 = baseSymbols; _i < baseSymbols_1.length; _i++) { + var s = baseSymbols_1[_i]; if (!ts.hasProperty(symbols, s.name)) { symbols[s.name] = s; } @@ -16156,8 +16604,8 @@ var ts; } function addInheritedSignatures(signatures, baseSignatures) { if (baseSignatures) { - for (var _i = 0; _i < baseSignatures.length; _i++) { - var signature = baseSignatures[_i]; + for (var _i = 0, baseSignatures_1 = baseSignatures; _i < baseSignatures_1.length; _i++) { + var signature = baseSignatures_1[_i]; signatures.push(signature); } } @@ -16200,8 +16648,8 @@ var ts; members = createSymbolTable(source.declaredProperties); } var thisArgument = ts.lastOrUndefined(typeArguments); - for (var _i = 0; _i < baseTypes.length; _i++) { - var baseType = baseTypes[_i]; + for (var _i = 0, baseTypes_1 = baseTypes; _i < baseTypes_1.length; _i++) { + var baseType = baseTypes_1[_i]; var instantiatedBaseType = thisArgument ? getTypeWithThisArgument(instantiateType(baseType, mapper), thisArgument) : baseType; addInheritedMembers(members, getPropertiesOfObjectType(instantiatedBaseType)); callSignatures = ts.concatenate(callSignatures, getSignaturesOfType(instantiatedBaseType, 0 /* Call */)); @@ -16247,8 +16695,8 @@ var ts; var typeArguments = ts.map(baseTypeNode.typeArguments, getTypeFromTypeNode); var typeArgCount = typeArguments ? typeArguments.length : 0; var result = []; - for (var _i = 0; _i < baseSignatures.length; _i++) { - var baseSig = baseSignatures[_i]; + for (var _i = 0, baseSignatures_2 = baseSignatures; _i < baseSignatures_2.length; _i++) { + var baseSig = baseSignatures_2[_i]; var typeParamCount = baseSig.typeParameters ? baseSig.typeParameters.length : 0; if (typeParamCount === typeArgCount) { var sig = typeParamCount ? getSignatureInstantiation(baseSig, typeArguments) : cloneSignature(baseSig); @@ -16277,8 +16725,8 @@ var ts; setObjectTypeMembers(type, members, arrayType.callSignatures, arrayType.constructSignatures, arrayType.stringIndexType, arrayType.numberIndexType); } function findMatchingSignature(signatureList, signature, partialMatch, ignoreReturnTypes) { - for (var _i = 0; _i < signatureList.length; _i++) { - var s = signatureList[_i]; + for (var _i = 0, signatureList_1 = signatureList; _i < signatureList_1.length; _i++) { + var s = signatureList_1[_i]; if (compareSignatures(s, signature, partialMatch, ignoreReturnTypes, compareTypes)) { return s; } @@ -16342,8 +16790,8 @@ var ts; } function getUnionIndexType(types, kind) { var indexTypes = []; - for (var _i = 0; _i < types.length; _i++) { - var type = types[_i]; + for (var _i = 0, types_1 = types; _i < types_1.length; _i++) { + var type = types_1[_i]; var indexType = getIndexTypeOfType(type, kind); if (!indexType) { return undefined; @@ -16522,12 +16970,12 @@ var ts; function createUnionOrIntersectionProperty(containingType, name) { var types = containingType.types; var props; - for (var _i = 0; _i < types.length; _i++) { - var current = types[_i]; + for (var _i = 0, types_2 = types; _i < types_2.length; _i++) { + var current = types_2[_i]; var type = getApparentType(current); if (type !== unknownType) { var prop = getPropertyOfType(type, name); - if (prop && !(getDeclarationFlagsFromSymbol(prop) & (32 /* Private */ | 64 /* Protected */))) { + if (prop && !(getDeclarationFlagsFromSymbol(prop) & (16 /* Private */ | 32 /* Protected */))) { if (!props) { props = [prop]; } @@ -16549,8 +16997,8 @@ var ts; } var propTypes = []; var declarations = []; - for (var _a = 0; _a < props.length; _a++) { - var prop = props[_a]; + for (var _a = 0, props_1 = props; _a < props_1.length; _a++) { + var prop = props_1[_a]; if (prop.declarations) { ts.addRange(declarations, prop.declarations); } @@ -16908,8 +17356,8 @@ var ts; // that care about the presence of such types at arbitrary depth in a containing type. function getPropagatingFlagsOfTypes(types) { var result = 0; - for (var _i = 0; _i < types.length; _i++) { - var type = types[_i]; + for (var _i = 0, types_3 = types; _i < types_3.length; _i++) { + var type = types_3[_i]; result |= type.flags; } return result & 14680064 /* PropagatingFlags */; @@ -17059,8 +17507,8 @@ var ts; function getTypeOfGlobalSymbol(symbol, arity) { function getTypeDeclaration(symbol) { var declarations = symbol.declarations; - for (var _i = 0; _i < declarations.length; _i++) { - var declaration = declarations[_i]; + for (var _i = 0, declarations_3 = declarations; _i < declarations_3.length; _i++) { + var declaration = declarations_3[_i]; switch (declaration.kind) { case 214 /* ClassDeclaration */: case 215 /* InterfaceDeclaration */: @@ -17170,8 +17618,8 @@ var ts; // Add the given types to the given type set. Order is preserved, duplicates are removed, // and nested types of the given kind are flattened into the set. function addTypesToSet(typeSet, types, typeSetKind) { - for (var _i = 0; _i < types.length; _i++) { - var type = types[_i]; + for (var _i = 0, types_4 = types; _i < types_4.length; _i++) { + var type = types_4[_i]; addTypeToSet(typeSet, type, typeSetKind); } } @@ -17193,8 +17641,8 @@ var ts; } } function containsTypeAny(types) { - for (var _i = 0; _i < types.length; _i++) { - var type = types[_i]; + for (var _i = 0, types_5 = types; _i < types_5.length; _i++) { + var type = types_5[_i]; if (isTypeAny(type)) { return true; } @@ -17310,7 +17758,8 @@ var ts; var container = ts.getThisContainer(node, /*includeArrowFunctions*/ false); var parent = container && container.parent; if (parent && (ts.isClassLike(parent) || parent.kind === 215 /* InterfaceDeclaration */)) { - if (!(container.flags & 128 /* Static */)) { + if (!(container.flags & 64 /* Static */) && + (container.kind !== 144 /* Constructor */ || ts.isNodeDescendentOf(node, container.body))) { return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(parent)).thisType; } } @@ -17377,8 +17826,8 @@ var ts; function instantiateList(items, mapper, instantiator) { if (items && items.length) { var result = []; - for (var _i = 0; _i < items.length; _i++) { - var v = items[_i]; + for (var _i = 0, items_1 = items; _i < items_1.length; _i++) { + var v = items_1[_i]; result.push(instantiator(v, mapper)); } return result; @@ -17417,8 +17866,8 @@ var ts; case 2: return createBinaryTypeEraser(sources[0], sources[1]); } return function (t) { - for (var _i = 0; _i < sources.length; _i++) { - var source = sources[_i]; + for (var _i = 0, sources_1 = sources; _i < sources_1.length; _i++) { + var source = sources_1[_i]; if (t === source) { return anyType; } @@ -17836,8 +18285,8 @@ var ts; function eachTypeRelatedToSomeType(source, target) { var result = -1 /* True */; var sourceTypes = source.types; - for (var _i = 0; _i < sourceTypes.length; _i++) { - var sourceType = sourceTypes[_i]; + for (var _i = 0, sourceTypes_1 = sourceTypes; _i < sourceTypes_1.length; _i++) { + var sourceType = sourceTypes_1[_i]; var related = typeRelatedToSomeType(sourceType, target, false); if (!related) { return 0 /* False */; @@ -17859,8 +18308,8 @@ var ts; function typeRelatedToEachType(source, target, reportErrors) { var result = -1 /* True */; var targetTypes = target.types; - for (var _i = 0; _i < targetTypes.length; _i++) { - var targetType = targetTypes[_i]; + for (var _i = 0, targetTypes_1 = targetTypes; _i < targetTypes_1.length; _i++) { + var targetType = targetTypes_1[_i]; var related = isRelatedTo(source, targetType, reportErrors); if (!related) { return 0 /* False */; @@ -17882,8 +18331,8 @@ var ts; function eachTypeRelatedToType(source, target, reportErrors) { var result = -1 /* True */; var sourceTypes = source.types; - for (var _i = 0; _i < sourceTypes.length; _i++) { - var sourceType = sourceTypes[_i]; + for (var _i = 0, sourceTypes_2 = sourceTypes; _i < sourceTypes_2.length; _i++) { + var sourceType = sourceTypes_2[_i]; var related = isRelatedTo(sourceType, target, reportErrors); if (!related) { return 0 /* False */; @@ -18008,8 +18457,8 @@ var ts; var result = -1 /* True */; var properties = getPropertiesOfObjectType(target); var requireOptionalProperties = relation === subtypeRelation && !(source.flags & 524288 /* ObjectLiteral */); - for (var _i = 0; _i < properties.length; _i++) { - var targetProp = properties[_i]; + for (var _i = 0, properties_1 = properties; _i < properties_1.length; _i++) { + var targetProp = properties_1[_i]; var sourceProp = getPropertyOfType(source, targetProp.name); if (sourceProp !== targetProp) { if (!sourceProp) { @@ -18023,20 +18472,20 @@ var ts; else if (!(targetProp.flags & 134217728 /* Prototype */)) { var sourcePropFlags = getDeclarationFlagsFromSymbol(sourceProp); var targetPropFlags = getDeclarationFlagsFromSymbol(targetProp); - if (sourcePropFlags & 32 /* Private */ || targetPropFlags & 32 /* Private */) { + if (sourcePropFlags & 16 /* Private */ || targetPropFlags & 16 /* Private */) { if (sourceProp.valueDeclaration !== targetProp.valueDeclaration) { if (reportErrors) { - if (sourcePropFlags & 32 /* Private */ && targetPropFlags & 32 /* Private */) { + if (sourcePropFlags & 16 /* Private */ && targetPropFlags & 16 /* Private */) { reportError(ts.Diagnostics.Types_have_separate_declarations_of_a_private_property_0, symbolToString(targetProp)); } else { - reportError(ts.Diagnostics.Property_0_is_private_in_type_1_but_not_in_type_2, symbolToString(targetProp), typeToString(sourcePropFlags & 32 /* Private */ ? source : target), typeToString(sourcePropFlags & 32 /* Private */ ? target : source)); + reportError(ts.Diagnostics.Property_0_is_private_in_type_1_but_not_in_type_2, symbolToString(targetProp), typeToString(sourcePropFlags & 16 /* Private */ ? source : target), typeToString(sourcePropFlags & 16 /* Private */ ? target : source)); } } return 0 /* False */; } } - else if (targetPropFlags & 64 /* Protected */) { + else if (targetPropFlags & 32 /* Protected */) { var sourceDeclaredInClass = sourceProp.parent && sourceProp.parent.flags & 32 /* Class */; var sourceClass = sourceDeclaredInClass ? getDeclaredTypeOfSymbol(sourceProp.parent) : undefined; var targetClass = getDeclaredTypeOfSymbol(targetProp.parent); @@ -18047,7 +18496,7 @@ var ts; return 0 /* False */; } } - else if (sourcePropFlags & 64 /* Protected */) { + else if (sourcePropFlags & 32 /* Protected */) { if (reportErrors) { reportError(ts.Diagnostics.Property_0_is_protected_in_type_1_but_public_in_type_2, symbolToString(targetProp), typeToString(source), typeToString(target)); } @@ -18089,8 +18538,8 @@ var ts; return 0 /* False */; } var result = -1 /* True */; - for (var _i = 0; _i < sourceProperties.length; _i++) { - var sourceProp = sourceProperties[_i]; + for (var _i = 0, sourceProperties_1 = sourceProperties; _i < sourceProperties_1.length; _i++) { + var sourceProp = sourceProperties_1[_i]; var targetProp = getPropertyOfObjectType(target, sourceProp.name); if (!targetProp) { return 0 /* False */; @@ -18130,13 +18579,13 @@ var ts; return result; } } - outer: for (var _i = 0; _i < targetSignatures.length; _i++) { - var t = targetSignatures[_i]; + outer: for (var _i = 0, targetSignatures_1 = targetSignatures; _i < targetSignatures_1.length; _i++) { + var t = targetSignatures_1[_i]; if (!t.hasStringLiterals || target.flags & 262144 /* FromSignature */) { var localErrors = reportErrors; var checkedAbstractAssignability = false; - for (var _a = 0; _a < sourceSignatures.length; _a++) { - var s = sourceSignatures[_a]; + for (var _a = 0, sourceSignatures_1 = sourceSignatures; _a < sourceSignatures_1.length; _a++) { + var s = sourceSignatures_1[_a]; if (!s.hasStringLiterals || source.flags & 262144 /* FromSignature */) { var related = signatureRelatedTo(s, t, localErrors); if (related) { @@ -18167,8 +18616,8 @@ var ts; var targetReturnType = targetErasedSignature && getReturnTypeOfSignature(targetErasedSignature); var sourceReturnDecl = sourceReturnType && sourceReturnType.symbol && getClassLikeDeclarationOfSymbol(sourceReturnType.symbol); var targetReturnDecl = targetReturnType && targetReturnType.symbol && getClassLikeDeclarationOfSymbol(targetReturnType.symbol); - var sourceIsAbstract = sourceReturnDecl && sourceReturnDecl.flags & 256 /* Abstract */; - var targetIsAbstract = targetReturnDecl && targetReturnDecl.flags & 256 /* Abstract */; + var sourceIsAbstract = sourceReturnDecl && sourceReturnDecl.flags & 128 /* Abstract */; + var targetIsAbstract = targetReturnDecl && targetReturnDecl.flags & 128 /* Abstract */; if (sourceIsAbstract && !(targetIsAbstract && targetDecl)) { // if target isn't a class-declaration type, then it can be new'd, so we forbid the assignment. if (reportErrors) { @@ -18284,7 +18733,7 @@ var ts; var targetType = getIndexTypeOfType(target, 0 /* String */); if (targetType) { if ((targetType.flags & 1 /* Any */) && !(originalSource.flags & 16777726 /* Primitive */)) { - // non-primitive assignment to any is always allowed, eg + // non-primitive assignment to any is always allowed, eg // `var x: { [index: string]: any } = { property: 12 };` return -1 /* True */; } @@ -18313,7 +18762,7 @@ var ts; var targetType = getIndexTypeOfType(target, 1 /* Number */); if (targetType) { if ((targetType.flags & 1 /* Any */) && !(originalSource.flags & 16777726 /* Primitive */)) { - // non-primitive assignment to any is always allowed, eg + // non-primitive assignment to any is always allowed, eg // `var x: { [index: number]: any } = { property: 12 };` return -1 /* True */; } @@ -18386,8 +18835,8 @@ var ts; if (sourceProp === targetProp) { return -1 /* True */; } - var sourcePropAccessibility = getDeclarationFlagsFromSymbol(sourceProp) & (32 /* Private */ | 64 /* Protected */); - var targetPropAccessibility = getDeclarationFlagsFromSymbol(targetProp) & (32 /* Private */ | 64 /* Protected */); + var sourcePropAccessibility = getDeclarationFlagsFromSymbol(sourceProp) & (16 /* Private */ | 32 /* Protected */); + var targetPropAccessibility = getDeclarationFlagsFromSymbol(targetProp) & (16 /* Private */ | 32 /* Protected */); if (sourcePropAccessibility !== targetPropAccessibility) { return 0 /* False */; } @@ -18455,8 +18904,8 @@ var ts; return signature.hasRestParameter && parameterIndex >= signature.parameters.length - 1; } function isSupertypeOfEach(candidate, types) { - for (var _i = 0; _i < types.length; _i++) { - var type = types[_i]; + for (var _i = 0, types_6 = types; _i < types_6.length; _i++) { + var type = types_6[_i]; if (candidate !== type && !isTypeSubtypeOf(type, candidate)) return false; } @@ -18692,8 +19141,8 @@ var ts; } function createInferenceContext(typeParameters, inferUnionTypes) { var inferences = []; - for (var _i = 0; _i < typeParameters.length; _i++) { - var unused = typeParameters[_i]; + for (var _i = 0, typeParameters_1 = typeParameters; _i < typeParameters_1.length; _i++) { + var unused = typeParameters_1[_i]; inferences.push({ primary: undefined, secondary: undefined, isFixed: false }); @@ -18774,8 +19223,8 @@ var ts; var typeParameterCount = 0; var typeParameter; // First infer to each type in union or intersection that isn't a type parameter - for (var _i = 0; _i < targetTypes.length; _i++) { - var t = targetTypes[_i]; + for (var _i = 0, targetTypes_2 = targetTypes; _i < targetTypes_2.length; _i++) { + var t = targetTypes_2[_i]; if (t.flags & 512 /* TypeParameter */ && ts.contains(context.typeParameters, t)) { typeParameter = t; typeParameterCount++; @@ -18797,8 +19246,8 @@ var ts; else if (source.flags & 49152 /* UnionOrIntersection */) { // Source is a union or intersection type, infer from each consituent type var sourceTypes = source.types; - for (var _a = 0; _a < sourceTypes.length; _a++) { - var sourceType = sourceTypes[_a]; + for (var _a = 0, sourceTypes_3 = sourceTypes; _a < sourceTypes_3.length; _a++) { + var sourceType = sourceTypes_3[_a]; inferFromTypes(sourceType, target); } } @@ -18832,8 +19281,8 @@ var ts; } function inferFromProperties(source, target) { var properties = getPropertiesOfObjectType(target); - for (var _i = 0; _i < properties.length; _i++) { - var targetProp = properties[_i]; + for (var _i = 0, properties_2 = properties; _i < properties_2.length; _i++) { + var targetProp = properties_2[_i]; var sourceProp = getPropertyOfObjectType(source, targetProp.name); if (sourceProp) { inferFromTypes(getTypeOfSymbol(sourceProp), getTypeOfSymbol(targetProp)); @@ -19324,9 +19773,9 @@ var ts; symbol.valueDeclaration.parent.kind === 244 /* CatchClause */) { return; } - // 1. walk from the use site up to the declaration and check + // 1. walk from the use site up to the declaration and check // if there is anything function like between declaration and use-site (is binding/class is captured in function). - // 2. walk from the declaration up to the boundary of lexical environment and check + // 2. walk from the declaration up to the boundary of lexical environment and check // if there is an iteration statement in between declaration and boundary (is binding/class declared inside iteration statement) var container; if (symbol.flags & 32 /* Class */) { @@ -19398,7 +19847,7 @@ var ts; break; case 141 /* PropertyDeclaration */: case 140 /* PropertySignature */: - if (container.flags & 128 /* Static */) { + if (container.flags & 64 /* Static */) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_static_property_initializer); } break; @@ -19411,7 +19860,7 @@ var ts; } if (ts.isClassLike(container.parent)) { var symbol = getSymbolOfNode(container.parent); - return container.flags & 128 /* Static */ ? getTypeOfSymbol(symbol) : getDeclaredTypeOfSymbol(symbol).thisType; + return container.flags & 64 /* Static */ ? getTypeOfSymbol(symbol) : getDeclaredTypeOfSymbol(symbol).thisType; } return anyType; } @@ -19441,7 +19890,7 @@ var ts; var nodeCheckFlag = 0; // always set NodeCheckFlags for 'super' expression node if (canUseSuperExpression) { - if ((container.flags & 128 /* Static */) || isCallExpression) { + if ((container.flags & 64 /* Static */) || isCallExpression) { nodeCheckFlag = 512 /* SuperStatic */; } else { @@ -19497,7 +19946,7 @@ var ts; // - In a static member function or static member accessor // topmost container must be something that is directly nested in the class declaration if (container && ts.isClassLike(container.parent)) { - if (container.flags & 128 /* Static */) { + if (container.flags & 64 /* Static */) { return container.kind === 143 /* MethodDeclaration */ || container.kind === 142 /* MethodSignature */ || container.kind === 145 /* GetAccessor */ || @@ -19654,8 +20103,8 @@ var ts; var types = type.types; var mappedType; var mappedTypes; - for (var _i = 0; _i < types.length; _i++) { - var current = types[_i]; + for (var _i = 0, types_7 = types; _i < types_7.length; _i++) { + var current = types_7[_i]; var t = mapper(current); if (t) { if (!mappedType) { @@ -19845,8 +20294,8 @@ var ts; } var signatureList; var types = type.types; - for (var _i = 0; _i < types.length; _i++) { - var current = types[_i]; + for (var _i = 0, types_8 = types; _i < types_8.length; _i++) { + var current = types_8[_i]; var signature = getNonGenericSignature(current); if (signature) { if (!signatureList) { @@ -19926,8 +20375,8 @@ var ts; var hasSpreadElement = false; var elementTypes = []; var inDestructuringPattern = isAssignmentTarget(node); - for (var _i = 0; _i < elements.length; _i++) { - var e = elements[_i]; + for (var _i = 0, elements_1 = elements; _i < elements_1.length; _i++) { + var e = elements_1[_i]; if (inDestructuringPattern && e.kind === 185 /* SpreadElementExpression */) { // Given the following situation: // var c: {}; @@ -20259,8 +20708,8 @@ var ts; function checkJsxSpreadAttribute(node, elementAttributesType, nameTable) { var type = checkExpression(node.expression); var props = getPropertiesOfType(type); - for (var _i = 0; _i < props.length; _i++) { - var prop = props[_i]; + for (var _i = 0, props_2 = props; _i < props_2.length; _i++) { + var prop = props_2[_i]; // Is there a corresponding property in the element attributes type? Skip checking of properties // that have already been assigned to, as these are not actually pushed into the resulting type if (!nameTable[prop.name]) { @@ -20479,7 +20928,6 @@ var ts; var prop = getPropertyOfType(attributesType, attrib.name.text); return prop || unknownSymbol; } - var jsxElementClassType = undefined; function getJsxGlobalElementClassType() { if (!jsxElementClassType) { jsxElementClassType = getExportedTypeFromNamespace(JsxNames.JSX, JsxNames.ElementClass); @@ -20558,7 +21006,7 @@ var ts; return s.valueDeclaration ? s.valueDeclaration.kind : 141 /* PropertyDeclaration */; } function getDeclarationFlagsFromSymbol(s) { - return s.valueDeclaration ? ts.getCombinedNodeFlags(s.valueDeclaration) : s.flags & 134217728 /* Prototype */ ? 16 /* Public */ | 128 /* Static */ : 0; + return s.valueDeclaration ? ts.getCombinedNodeFlags(s.valueDeclaration) : s.flags & 134217728 /* Prototype */ ? 8 /* Public */ | 64 /* Static */ : 0; } /** * Check whether the requested property access is valid. @@ -20588,7 +21036,7 @@ var ts; error(errorNode, ts.Diagnostics.Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword); return false; } - if (flags & 256 /* Abstract */) { + if (flags & 128 /* Abstract */) { // A method cannot be accessed in a super property access if the method is abstract. // This error could mask a private property access error. But, a member // cannot simultaneously be private and abstract, so this will trigger an @@ -20598,7 +21046,7 @@ var ts; } } // Public properties are otherwise accessible. - if (!(flags & (32 /* Private */ | 64 /* Protected */))) { + if (!(flags & (16 /* Private */ | 32 /* Protected */))) { return true; } // Property is known to be private or protected at this point @@ -20606,7 +21054,7 @@ var ts; var enclosingClassDeclaration = ts.getContainingClass(node); var enclosingClass = enclosingClassDeclaration ? getDeclaredTypeOfSymbol(getSymbolOfNode(enclosingClassDeclaration)) : undefined; // Private property is accessible if declaring and enclosing class are the same - if (flags & 32 /* Private */) { + if (flags & 16 /* Private */) { if (declaringClass !== enclosingClass) { error(node, ts.Diagnostics.Property_0_is_private_and_only_accessible_within_class_1, symbolToString(prop), typeToString(declaringClass)); return false; @@ -20624,7 +21072,7 @@ var ts; return false; } // No further restrictions for static properties - if (flags & 128 /* Static */) { + if (flags & 64 /* Static */) { return true; } // An instance property must be accessed through an instance of the enclosing class @@ -20851,8 +21299,8 @@ var ts; var specializedIndex = -1; var spliceIndex; ts.Debug.assert(!result.length); - for (var _i = 0; _i < signatures.length; _i++) { - var signature = signatures[_i]; + 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_5 = signature.declaration && signature.declaration.parent; if (!lastSymbol || symbol === lastSymbol) { @@ -21494,8 +21942,8 @@ var ts; // declare function f(a: { xa: number; xb: number; }); // f({ | if (!produceDiagnostics) { - for (var _i = 0; _i < candidates.length; _i++) { - var candidate = candidates[_i]; + for (var _i = 0, candidates_1 = candidates; _i < candidates_1.length; _i++) { + var candidate = candidates_1[_i]; if (hasCorrectArity(node, args, candidate)) { if (candidate.typeParameters && typeArguments) { candidate = getSignatureInstantiation(candidate, ts.map(typeArguments, getTypeFromTypeNode)); @@ -21514,8 +21962,8 @@ var ts; diagnostics.add(ts.createDiagnosticForNodeFromMessageChain(node, errorInfo)); } function chooseOverload(candidates, relation) { - for (var _i = 0; _i < candidates.length; _i++) { - var originalCandidate = candidates[_i]; + for (var _i = 0, candidates_2 = candidates; _i < candidates_2.length; _i++) { + var originalCandidate = candidates_2[_i]; if (!hasCorrectArity(node, args, originalCandidate)) { continue; } @@ -21652,7 +22100,7 @@ var ts; // In the case of a merged class-module or class-interface declaration, // only the class declaration node will have the Abstract flag set. var valueDecl = expressionType.symbol && getClassLikeDeclarationOfSymbol(expressionType.symbol); - if (valueDecl && valueDecl.flags & 256 /* Abstract */) { + if (valueDecl && valueDecl.flags & 128 /* Abstract */) { error(node, ts.Diagnostics.Cannot_create_an_instance_of_the_abstract_class_0, ts.declarationNameToString(valueDecl.name)); return resolveErrorCall(node); } @@ -22017,19 +22465,11 @@ var ts; }); return aggregatedTypes; } - function bodyContainsAReturnStatement(funcBody) { - return ts.forEachReturnStatement(funcBody, function (returnStatement) { - return true; - }); - } - function bodyContainsSingleThrowStatement(body) { - return (body.statements.length === 1) && (body.statements[0].kind === 208 /* ThrowStatement */); - } // TypeScript Specification 1.0 (6.3) - July 2014 // An explicitly typed function whose return type isn't the Void or the Any type // must have at least one return statement somewhere in its body. // An exception to this rule is if the function implementation consists of a single 'throw' statement. - function checkIfNonVoidFunctionHasReturnExpressionsOrSingleThrowStatment(func, returnType) { + function checkAllCodePathsInNonVoidFunctionReturnOrThrow(func, returnType) { if (!produceDiagnostics) { return; } @@ -22038,22 +22478,19 @@ var ts; return; } // If all we have is a function signature, or an arrow function with an expression body, then there is nothing to check. - if (ts.nodeIsMissing(func.body) || func.body.kind !== 192 /* Block */) { + // also if HasImplicitReturnValue flags is not set this means that all codepaths in function body end with return of throw + if (ts.nodeIsMissing(func.body) || func.body.kind !== 192 /* Block */ || !(func.flags & 524288 /* HasImplicitReturn */)) { return; } - var bodyBlock = func.body; - // Ensure the body has at least one return expression. - if (bodyContainsAReturnStatement(bodyBlock)) { - return; + if (func.flags & 1048576 /* HasExplicitReturn */) { + if (compilerOptions.noImplicitReturns) { + error(func.type, ts.Diagnostics.Not_all_code_paths_return_a_value); + } } - // If there are no return expressions, then we need to check if - // the function body consists solely of a throw statement; - // this is to make an exception for unimplemented functions. - if (bodyContainsSingleThrowStatement(bodyBlock)) { - return; + else { + // This function does not conform to the specification. + error(func.type, ts.Diagnostics.A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value); } - // This function does not conform to the specification. - error(func.type, ts.Diagnostics.A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value_or_consist_of_a_single_throw_statement); } function checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper) { ts.Debug.assert(node.kind !== 143 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); @@ -22120,7 +22557,7 @@ var ts; promisedType = checkAsyncFunctionReturnType(node); } if (returnType && !node.asteriskToken) { - checkIfNonVoidFunctionHasReturnExpressionsOrSingleThrowStatment(node, isAsync ? promisedType : returnType); + checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, isAsync ? promisedType : returnType); } if (node.body) { if (!node.type) { @@ -22205,7 +22642,7 @@ var ts; case 69 /* Identifier */: case 166 /* PropertyAccessExpression */: { var symbol = findSymbol(n); - return symbol && (symbol.flags & 3 /* Variable */) !== 0 && (getDeclarationFlagsFromSymbol(symbol) & 32768 /* Const */) !== 0; + return symbol && (symbol.flags & 3 /* Variable */) !== 0 && (getDeclarationFlagsFromSymbol(symbol) & 16384 /* Const */) !== 0; } case 167 /* ElementAccessExpression */: { var index = n.argumentExpression; @@ -22213,7 +22650,7 @@ var ts; if (symbol && index && index.kind === 9 /* StringLiteral */) { var name_12 = index.text; var prop = getPropertyOfType(getTypeOfSymbol(symbol), name_12); - return prop && (prop.flags & 3 /* Variable */) !== 0 && (getDeclarationFlagsFromSymbol(prop) & 32768 /* Const */) !== 0; + return prop && (prop.flags & 3 /* Variable */) !== 0 && (getDeclarationFlagsFromSymbol(prop) & 16384 /* Const */) !== 0; } return false; } @@ -22298,8 +22735,8 @@ var ts; } if (type.flags & 49152 /* UnionOrIntersection */) { var types = type.types; - for (var _i = 0; _i < types.length; _i++) { - var current = types[_i]; + for (var _i = 0, types_9 = types; _i < types_9.length; _i++) { + var current = types_9[_i]; if (current.flags & kind) { return true; } @@ -22315,8 +22752,8 @@ var ts; } if (type.flags & 49152 /* UnionOrIntersection */) { var types = type.types; - for (var _i = 0; _i < types.length; _i++) { - var current = types[_i]; + for (var _i = 0, types_10 = types; _i < types_10.length; _i++) { + var current = types_10[_i]; if (!(current.flags & kind)) { return false; } @@ -22361,8 +22798,8 @@ var ts; } function checkObjectLiteralAssignment(node, sourceType, contextualMapper) { var properties = node.properties; - for (var _i = 0; _i < properties.length; _i++) { - var p = properties[_i]; + for (var _i = 0, properties_3 = properties; _i < properties_3.length; _i++) { + var p = properties_3[_i]; if (p.kind === 245 /* PropertyAssignment */ || p.kind === 246 /* ShorthandPropertyAssignment */) { // TODO(andersh): Computed property support var name_13 = p.name; @@ -22896,7 +23333,7 @@ var ts; checkGrammarDecorators(node) || checkGrammarModifiers(node); checkVariableLikeDeclaration(node); var func = ts.getContainingFunction(node); - if (node.flags & 112 /* AccessibilityModifier */) { + if (node.flags & 56 /* AccessibilityModifier */) { func = ts.getContainingFunction(node); if (!(func.kind === 144 /* Constructor */ && ts.nodeIsPresent(func.body))) { error(node, ts.Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation); @@ -23096,7 +23533,7 @@ var ts; checkFunctionLikeDeclaration(node); // Abstract methods cannot have an implementation. // Extra checks are to avoid reporting multiple errors relating to the "abstractness" of the node. - if (node.flags & 256 /* Abstract */ && node.body) { + if (node.flags & 128 /* Abstract */ && node.body) { error(node, ts.Diagnostics.Method_0_cannot_have_an_implementation_because_it_is_marked_abstract, ts.declarationNameToString(node.name)); } } @@ -23147,7 +23584,7 @@ var ts; } function isInstancePropertyWithInitializer(n) { return n.kind === 141 /* PropertyDeclaration */ && - !(n.flags & 128 /* Static */) && + !(n.flags & 64 /* Static */) && !!n.initializer; } // TS 1.0 spec (April 2014): 8.3.2 @@ -23168,14 +23605,14 @@ var ts; // - The constructor declares parameter properties // or the containing class declares instance member variables with initializers. var superCallShouldBeFirst = ts.forEach(node.parent.members, isInstancePropertyWithInitializer) || - ts.forEach(node.parameters, function (p) { return p.flags & (16 /* Public */ | 32 /* Private */ | 64 /* Protected */); }); + ts.forEach(node.parameters, function (p) { return p.flags & (8 /* Public */ | 16 /* Private */ | 32 /* Protected */); }); // Skip past any prologue directives to find the first statement // to ensure that it was a super call. if (superCallShouldBeFirst) { var statements = node.body.statements; var superCallStatement; - for (var _i = 0; _i < statements.length; _i++) { - var statement = statements[_i]; + for (var _i = 0, statements_2 = statements; _i < statements_2.length; _i++) { + var statement = statements_2[_i]; if (statement.kind === 195 /* ExpressionStatement */ && isSuperCallExpression(statement.expression)) { superCallStatement = statement; break; @@ -23203,8 +23640,15 @@ var ts; // Grammar checking accessors checkGrammarFunctionLikeDeclaration(node) || checkGrammarAccessor(node) || checkGrammarComputedPropertyName(node.name); if (node.kind === 145 /* GetAccessor */) { - if (!ts.isInAmbientContext(node) && ts.nodeIsPresent(node.body) && !(bodyContainsAReturnStatement(node.body) || bodyContainsSingleThrowStatement(node.body))) { - error(node.name, ts.Diagnostics.A_get_accessor_must_return_a_value_or_consist_of_a_single_throw_statement); + if (!ts.isInAmbientContext(node) && ts.nodeIsPresent(node.body) && (node.flags & 524288 /* HasImplicitReturn */)) { + if (node.flags & 1048576 /* HasExplicitReturn */) { + if (compilerOptions.noImplicitReturns) { + error(node.name, ts.Diagnostics.Not_all_code_paths_return_a_value); + } + } + else { + error(node.name, ts.Diagnostics.A_get_accessor_must_return_a_value); + } } } if (!ts.hasDynamicName(node)) { @@ -23213,7 +23657,7 @@ var ts; var otherKind = node.kind === 145 /* GetAccessor */ ? 146 /* SetAccessor */ : 145 /* GetAccessor */; var otherAccessor = ts.getDeclarationOfKind(node.symbol, otherKind); if (otherAccessor) { - if (((node.flags & 112 /* AccessibilityModifier */) !== (otherAccessor.flags & 112 /* AccessibilityModifier */))) { + if (((node.flags & 56 /* AccessibilityModifier */) !== (otherAccessor.flags & 56 /* AccessibilityModifier */))) { error(node.name, ts.Diagnostics.Getter_and_setter_accessors_do_not_agree_in_visibility); } var currentAccessorType = getAnnotatedAccessorType(node); @@ -23284,7 +23728,7 @@ var ts; ts.forEach(node.types, checkSourceElement); } function isPrivateWithinAmbient(node) { - return (node.flags & 32 /* Private */) && ts.isInAmbientContext(node); + return (node.flags & 16 /* Private */) && ts.isInAmbientContext(node); } function checkSpecializedSignatureDeclaration(signatureDeclarationNode) { if (!produceDiagnostics) { @@ -23316,8 +23760,8 @@ var ts; else { signaturesToCheck = getSignaturesOfSymbol(getSymbolOfNode(signatureDeclarationNode)); } - for (var _i = 0; _i < signaturesToCheck.length; _i++) { - var otherSignature = signaturesToCheck[_i]; + for (var _i = 0, signaturesToCheck_1 = signaturesToCheck; _i < signaturesToCheck_1.length; _i++) { + var otherSignature = signaturesToCheck_1[_i]; if (!otherSignature.hasStringLiterals && isSignatureAssignableTo(signature, otherSignature)) { return; } @@ -23332,11 +23776,11 @@ var ts; n.parent.kind !== 214 /* ClassDeclaration */ && n.parent.kind !== 186 /* ClassExpression */ && ts.isInAmbientContext(n)) { - if (!(flags & 2 /* Ambient */)) { + if (!(flags & 4 /* Ambient */)) { // It is nested in an ambient context, which means it is automatically exported - flags |= 1 /* Export */; + flags |= 2 /* Export */; } - flags |= 2 /* Ambient */; + flags |= 4 /* Ambient */; } return flags & flagsToCheck; } @@ -23361,16 +23805,16 @@ var ts; var canonicalFlags = getEffectiveDeclarationFlags(getCanonicalOverload(overloads, implementation), flagsToCheck); ts.forEach(overloads, function (o) { var deviation = getEffectiveDeclarationFlags(o, flagsToCheck) ^ canonicalFlags; - if (deviation & 1 /* Export */) { + if (deviation & 2 /* Export */) { error(o.name, ts.Diagnostics.Overload_signatures_must_all_be_exported_or_not_exported); } - else if (deviation & 2 /* Ambient */) { + else if (deviation & 4 /* Ambient */) { error(o.name, ts.Diagnostics.Overload_signatures_must_all_be_ambient_or_non_ambient); } - else if (deviation & (32 /* Private */ | 64 /* Protected */)) { + else if (deviation & (16 /* Private */ | 32 /* Protected */)) { error(o.name, ts.Diagnostics.Overload_signatures_must_all_be_public_private_or_protected); } - else if (deviation & 256 /* Abstract */) { + else if (deviation & 128 /* Abstract */) { error(o.name, ts.Diagnostics.Overload_signatures_must_all_be_abstract_or_not_abstract); } }); @@ -23387,7 +23831,7 @@ var ts; }); } } - var flagsToCheck = 1 /* Export */ | 2 /* Ambient */ | 32 /* Private */ | 64 /* Protected */ | 256 /* Abstract */; + var flagsToCheck = 2 /* Export */ | 4 /* Ambient */ | 16 /* Private */ | 32 /* Protected */ | 128 /* Abstract */; var someNodeFlags = 0; var allNodeFlags = flagsToCheck; var someHaveQuestionToken = false; @@ -23418,8 +23862,8 @@ var ts; if (node.name && subsequentNode.name && node.name.text === subsequentNode.name.text) { // the only situation when this is possible (same kind\same name but different symbol) - mixed static and instance class members ts.Debug.assert(node.kind === 143 /* MethodDeclaration */ || node.kind === 142 /* MethodSignature */); - ts.Debug.assert((node.flags & 128 /* Static */) !== (subsequentNode.flags & 128 /* Static */)); - var diagnostic = node.flags & 128 /* Static */ ? ts.Diagnostics.Function_overload_must_be_static : ts.Diagnostics.Function_overload_must_not_be_static; + ts.Debug.assert((node.flags & 64 /* Static */) !== (subsequentNode.flags & 64 /* Static */)); + var diagnostic = node.flags & 64 /* Static */ ? ts.Diagnostics.Function_overload_must_be_static : ts.Diagnostics.Function_overload_must_not_be_static; error(errorNode_1, diagnostic); return; } @@ -23436,7 +23880,7 @@ var ts; else { // Report different errors regarding non-consecutive blocks of declarations depending on whether // the node in question is abstract. - if (node.flags & 256 /* Abstract */) { + if (node.flags & 128 /* Abstract */) { error(errorNode, ts.Diagnostics.All_declarations_of_an_abstract_method_must_be_consecutive); } else { @@ -23449,8 +23893,8 @@ var ts; var isExportSymbolInsideModule = symbol.parent && symbol.parent.flags & 1536 /* Module */; var duplicateFunctionDeclaration = false; var multipleConstructorImplementation = false; - for (var _i = 0; _i < declarations.length; _i++) { - var current = declarations[_i]; + for (var _i = 0, declarations_4 = declarations; _i < declarations_4.length; _i++) { + var current = declarations_4[_i]; var node = current; var inAmbientContext = ts.isInAmbientContext(node); var inAmbientContextOrInterface = node.parent.kind === 215 /* InterfaceDeclaration */ || node.parent.kind === 155 /* TypeLiteral */ || inAmbientContext; @@ -23507,7 +23951,7 @@ var ts; } // Abstract methods can't have an implementation -- in particular, they don't need one. if (!isExportSymbolInsideModule && lastSeenNonAmbientDeclaration && !lastSeenNonAmbientDeclaration.body && - !(lastSeenNonAmbientDeclaration.flags & 256 /* Abstract */)) { + !(lastSeenNonAmbientDeclaration.flags & 128 /* Abstract */)) { reportImplementationExpectedError(lastSeenNonAmbientDeclaration); } if (hasOverloads) { @@ -23533,8 +23977,8 @@ var ts; // function g(x: string, y: string) { } // // The implementation is completely unrelated to the specialized signature, yet we do not check this. - for (var _a = 0; _a < signatures.length; _a++) { - var signature = signatures[_a]; + for (var _a = 0, signatures_3 = signatures; _a < signatures_3.length; _a++) { + var signature = signatures_3[_a]; if (!signature.hasStringLiterals && !isSignatureAssignableTo(bodySignature, signature)) { error(signature.declaration, ts.Diagnostics.Overload_signature_is_not_compatible_with_function_implementation); break; @@ -23571,9 +24015,9 @@ var ts; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var d = _a[_i]; var declarationSpaces = getDeclarationSpaces(d); - var effectiveDeclarationFlags = getEffectiveDeclarationFlags(d, 1 /* Export */ | 1024 /* Default */); - if (effectiveDeclarationFlags & 1 /* Export */) { - if (effectiveDeclarationFlags & 1024 /* Default */) { + var effectiveDeclarationFlags = getEffectiveDeclarationFlags(d, 2 /* Export */ | 512 /* Default */); + if (effectiveDeclarationFlags & 2 /* Export */) { + if (effectiveDeclarationFlags & 512 /* Default */) { defaultExportedDeclarationSpaces |= declarationSpaces; } else { @@ -23826,9 +24270,12 @@ var ts; // type as a value. As such, we will just return unknownType; return unknownType; } - var promiseConstructor = getMergedSymbol(promiseType.symbol); + var promiseConstructor = getNodeLinks(node.type).resolvedSymbol; if (!promiseConstructor || !symbolIsValue(promiseConstructor)) { - error(node, ts.Diagnostics.Type_0_is_not_a_valid_async_function_return_type, typeToString(promiseType)); + var typeName = promiseConstructor + ? symbolToString(promiseConstructor) + : typeToString(promiseType); + error(node, ts.Diagnostics.Type_0_is_not_a_valid_async_function_return_type, typeName); return unknownType; } // Validate the promise constructor type. @@ -24020,7 +24467,7 @@ var ts; if (isAsync) { promisedType = checkAsyncFunctionReturnType(node); } - checkIfNonVoidFunctionHasReturnExpressionsOrSingleThrowStatment(node, isAsync ? promisedType : returnType); + checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, isAsync ? promisedType : returnType); } if (produceDiagnostics && !node.type) { // Report an implicit any error if there is no body, no explicit return type, and node is not a private method @@ -24162,7 +24609,7 @@ var ts; // let x = 0; // symbol for this declaration will be 'symbol' // } // skip block-scoped variables and parameters - if ((ts.getCombinedNodeFlags(node) & 49152 /* BlockScoped */) !== 0 || ts.isParameterDeclaration(node)) { + if ((ts.getCombinedNodeFlags(node) & 24576 /* BlockScoped */) !== 0 || ts.isParameterDeclaration(node)) { return; } // skip variable declarations that don't have initializers @@ -24177,7 +24624,7 @@ var ts; if (localDeclarationSymbol && localDeclarationSymbol !== symbol && localDeclarationSymbol.flags & 2 /* BlockScopedVariable */) { - if (getDeclarationFlagsFromSymbol(localDeclarationSymbol) & 49152 /* BlockScoped */) { + if (getDeclarationFlagsFromSymbol(localDeclarationSymbol) & 24576 /* BlockScoped */) { var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 212 /* VariableDeclarationList */); var container = varDeclList.parent.kind === 193 /* VariableStatement */ && varDeclList.parent.parent ? varDeclList.parent.parent @@ -24330,6 +24777,9 @@ var ts; checkGrammarStatementInAmbientContext(node); checkExpression(node.expression); checkSourceElement(node.thenStatement); + if (node.thenStatement.kind === 194 /* EmptyStatement */) { + error(node.thenStatement, ts.Diagnostics.The_body_of_an_if_statement_cannot_be_the_empty_statement); + } checkSourceElement(node.elseStatement); } function checkDoStatement(node) { @@ -24688,7 +25138,7 @@ var ts; error(node.expression, ts.Diagnostics.Setters_cannot_return_a_value); } else if (func.kind === 144 /* Constructor */) { - if (!isTypeAssignableTo(exprType, returnType)) { + if (!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); } } @@ -24835,7 +25285,7 @@ var ts; // Only process instance properties with computed names here. // Static properties cannot be in conflict with indexers, // and properties with literal names were already checked. - if (!(member.flags & 128 /* Static */) && ts.hasDynamicName(member)) { + if (!(member.flags & 64 /* Static */) && ts.hasDynamicName(member)) { var propType = getTypeOfSymbol(member.symbol); checkIndexConstraintForProperty(member.symbol, propType, type, declaredStringIndexer, stringIndexType, 0 /* String */); checkIndexConstraintForProperty(member.symbol, propType, type, declaredNumberIndexer, numberIndexType, 1 /* Number */); @@ -24921,7 +25371,7 @@ var ts; return getTypeOfSymbol(getSymbolOfNode(node)); } function checkClassDeclaration(node) { - if (!node.name && !(node.flags & 1024 /* Default */)) { + if (!node.name && !(node.flags & 512 /* Default */)) { grammarErrorOnFirstToken(node, ts.Diagnostics.A_class_declaration_without_the_default_modifier_must_have_a_name); } checkClassLikeDeclaration(node); @@ -24975,8 +25425,8 @@ var ts; } var implementedTypeNodes = ts.getClassImplementsHeritageClauseElements(node); if (implementedTypeNodes) { - for (var _b = 0; _b < implementedTypeNodes.length; _b++) { - var typeRefNode = implementedTypeNodes[_b]; + for (var _b = 0, implementedTypeNodes_1 = implementedTypeNodes; _b < implementedTypeNodes_1.length; _b++) { + var typeRefNode = implementedTypeNodes_1[_b]; if (!ts.isSupportedExpressionWithTypeArguments(typeRefNode)) { error(typeRefNode.expression, ts.Diagnostics.A_class_can_only_implement_an_identifier_Slashqualified_name_with_optional_type_arguments); } @@ -25024,8 +25474,8 @@ var ts; // derived class instance member variables and accessors, but not by other kinds of members. // NOTE: assignability is checked in checkClassDeclaration var baseProperties = getPropertiesOfObjectType(baseType); - for (var _i = 0; _i < baseProperties.length; _i++) { - var baseProperty = baseProperties[_i]; + for (var _i = 0, baseProperties_1 = baseProperties; _i < baseProperties_1.length; _i++) { + var baseProperty = baseProperties_1[_i]; var base = getTargetSymbol(baseProperty); if (base.flags & 134217728 /* Prototype */) { continue; @@ -25043,7 +25493,7 @@ var ts; // It is an error to inherit an abstract member without implementing it or being declared abstract. // If there is no declaration for the derived class (as in the case of class expressions), // then the class cannot be declared abstract. - if (baseDeclarationFlags & 256 /* Abstract */ && (!derivedClassDecl || !(derivedClassDecl.flags & 256 /* Abstract */))) { + if (baseDeclarationFlags & 128 /* Abstract */ && (!derivedClassDecl || !(derivedClassDecl.flags & 128 /* Abstract */))) { if (derivedClassDecl.kind === 186 /* ClassExpression */) { error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1, symbolToString(baseProperty), typeToString(baseType)); } @@ -25055,11 +25505,11 @@ var ts; else { // derived overrides base. var derivedDeclarationFlags = getDeclarationFlagsFromSymbol(derived); - if ((baseDeclarationFlags & 32 /* Private */) || (derivedDeclarationFlags & 32 /* Private */)) { + if ((baseDeclarationFlags & 16 /* Private */) || (derivedDeclarationFlags & 16 /* Private */)) { // either base or derived property is private - not override, skip it continue; } - if ((baseDeclarationFlags & 128 /* Static */) !== (derivedDeclarationFlags & 128 /* Static */)) { + if ((baseDeclarationFlags & 64 /* Static */) !== (derivedDeclarationFlags & 64 /* Static */)) { // value of 'static' is not the same for properties - not override, skip it continue; } @@ -25130,11 +25580,11 @@ var ts; var seen = {}; ts.forEach(resolveDeclaredMembers(type).declaredProperties, function (p) { seen[p.name] = { prop: p, containingType: type }; }); var ok = true; - for (var _i = 0; _i < baseTypes.length; _i++) { - var base = baseTypes[_i]; + for (var _i = 0, baseTypes_2 = baseTypes; _i < baseTypes_2.length; _i++) { + var base = baseTypes_2[_i]; var properties = getPropertiesOfObjectType(getTypeWithThisArgument(base, type.thisType)); - for (var _a = 0; _a < properties.length; _a++) { - var prop = properties[_a]; + for (var _a = 0, properties_4 = properties; _a < properties_4.length; _a++) { + var prop = properties_4[_a]; if (!ts.hasProperty(seen, prop.name)) { seen[prop.name] = { prop: prop, containingType: base }; } @@ -25431,8 +25881,8 @@ var ts; } function getFirstNonAmbientClassOrFunctionDeclaration(symbol) { var declarations = symbol.declarations; - for (var _i = 0; _i < declarations.length; _i++) { - var declaration = declarations[_i]; + for (var _i = 0, declarations_5 = declarations; _i < declarations_5.length; _i++) { + var declaration = declarations_5[_i]; if ((declaration.kind === 214 /* ClassDeclaration */ || (declaration.kind === 213 /* FunctionDeclaration */ && ts.nodeIsPresent(declaration.body))) && !ts.isInAmbientContext(declaration)) { @@ -25571,7 +26021,7 @@ var ts; // If we hit an import declaration in an illegal context, just bail out to avoid cascading errors. return; } - if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && (node.flags & 2035 /* Modifier */)) { + if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && (node.flags & 1022 /* Modifier */)) { grammarErrorOnFirstToken(node, ts.Diagnostics.An_import_declaration_cannot_have_modifiers); } if (checkExternalImportOrExportDeclaration(node)) { @@ -25599,7 +26049,7 @@ var ts; checkGrammarDecorators(node) || checkGrammarModifiers(node); if (ts.isInternalModuleImportEqualsDeclaration(node) || checkExternalImportOrExportDeclaration(node)) { checkImportBinding(node); - if (node.flags & 1 /* Export */) { + if (node.flags & 2 /* Export */) { markExportAsReferenced(node); } if (ts.isInternalModuleImportEqualsDeclaration(node)) { @@ -25630,7 +26080,7 @@ var ts; // If we hit an export in an illegal context, just bail out to avoid cascading errors. return; } - if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && (node.flags & 2035 /* Modifier */)) { + if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && (node.flags & 1022 /* Modifier */)) { grammarErrorOnFirstToken(node, ts.Diagnostics.An_export_declaration_cannot_have_modifiers); } if (!node.moduleSpecifier || checkExternalImportOrExportDeclaration(node)) { @@ -25674,7 +26124,7 @@ var ts; return; } // Grammar checking - if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && (node.flags & 2035 /* Modifier */)) { + if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && (node.flags & 1022 /* Modifier */)) { grammarErrorOnFirstToken(node, ts.Diagnostics.An_export_assignment_cannot_have_modifiers); } if (node.expression.kind === 69 /* Identifier */) { @@ -26087,7 +26537,7 @@ var ts; // add the type parameters into the symbol table // (type parameters of classDeclaration/classExpression and interface are in member property of the symbol. // Note: that the memberFlags come from previous iteration. - if (!(memberFlags & 128 /* Static */)) { + if (!(memberFlags & 64 /* Static */)) { copySymbols(getSymbolOfNode(location).members, meaning & 793056 /* Type */); } break; @@ -26388,7 +26838,7 @@ var ts; */ function getParentTypeOfClassElement(node) { var classSymbol = getSymbolOfNode(node.parent); - return node.flags & 128 /* Static */ + return node.flags & 64 /* Static */ ? getTypeOfSymbol(classSymbol) : getDeclaredTypeOfSymbol(classSymbol); } @@ -26709,7 +27159,7 @@ var ts; function initializeTypeChecker() { // Bind all source files and propagate errors ts.forEach(host.getSourceFiles(), function (file) { - ts.bindSourceFile(file); + ts.bindSourceFile(file, compilerOptions); }); // Initialize global symbol table ts.forEach(host.getSourceFiles(), function (file) { @@ -26863,19 +27313,19 @@ var ts; text = "private"; lastPrivate = modifier; } - if (flags & 112 /* AccessibilityModifier */) { + if (flags & 56 /* AccessibilityModifier */) { return grammarErrorOnNode(modifier, ts.Diagnostics.Accessibility_modifier_already_seen); } - else if (flags & 128 /* Static */) { + else if (flags & 64 /* Static */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "static"); } - else if (flags & 512 /* Async */) { + else if (flags & 256 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "async"); } else if (node.parent.kind === 219 /* ModuleBlock */ || node.parent.kind === 248 /* SourceFile */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_element, text); } - else if (flags & 256 /* Abstract */) { + else if (flags & 128 /* Abstract */) { if (modifier.kind === 110 /* PrivateKeyword */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, text, "abstract"); } @@ -26886,10 +27336,10 @@ var ts; flags |= ts.modifierToFlag(modifier.kind); break; case 113 /* StaticKeyword */: - if (flags & 128 /* Static */) { + if (flags & 64 /* Static */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "static"); } - else if (flags & 512 /* Async */) { + else if (flags & 256 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "static", "async"); } else if (node.parent.kind === 219 /* ModuleBlock */ || node.parent.kind === 248 /* SourceFile */) { @@ -26898,23 +27348,23 @@ var ts; else if (node.kind === 138 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "static"); } - else if (flags & 256 /* Abstract */) { + else if (flags & 128 /* Abstract */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "static", "abstract"); } - flags |= 128 /* Static */; + flags |= 64 /* Static */; lastStatic = modifier; break; case 82 /* ExportKeyword */: - if (flags & 1 /* Export */) { + if (flags & 2 /* Export */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "export"); } - else if (flags & 2 /* Ambient */) { + else if (flags & 4 /* Ambient */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "declare"); } - else if (flags & 256 /* Abstract */) { + else if (flags & 128 /* Abstract */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "abstract"); } - else if (flags & 512 /* Async */) { + else if (flags & 256 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "async"); } else if (node.parent.kind === 214 /* ClassDeclaration */) { @@ -26923,13 +27373,13 @@ var ts; else if (node.kind === 138 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "export"); } - flags |= 1 /* Export */; + flags |= 2 /* Export */; break; case 122 /* DeclareKeyword */: - if (flags & 2 /* Ambient */) { + if (flags & 4 /* Ambient */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "declare"); } - else if (flags & 512 /* Async */) { + 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 === 214 /* ClassDeclaration */) { @@ -26941,69 +27391,69 @@ var ts; else if (ts.isInAmbientContext(node.parent) && node.parent.kind === 219 /* ModuleBlock */) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_declare_modifier_cannot_be_used_in_an_already_ambient_context); } - flags |= 2 /* Ambient */; + flags |= 4 /* Ambient */; lastDeclare = modifier; break; case 115 /* AbstractKeyword */: - if (flags & 256 /* Abstract */) { + if (flags & 128 /* Abstract */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "abstract"); } if (node.kind !== 214 /* ClassDeclaration */) { if (node.kind !== 143 /* MethodDeclaration */) { return grammarErrorOnNode(modifier, ts.Diagnostics.abstract_modifier_can_only_appear_on_a_class_or_method_declaration); } - if (!(node.parent.kind === 214 /* ClassDeclaration */ && node.parent.flags & 256 /* Abstract */)) { + if (!(node.parent.kind === 214 /* ClassDeclaration */ && node.parent.flags & 128 /* Abstract */)) { return grammarErrorOnNode(modifier, ts.Diagnostics.Abstract_methods_can_only_appear_within_an_abstract_class); } - if (flags & 128 /* Static */) { + if (flags & 64 /* Static */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "static", "abstract"); } - if (flags & 32 /* Private */) { + if (flags & 16 /* Private */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "private", "abstract"); } } - flags |= 256 /* Abstract */; + flags |= 128 /* Abstract */; break; case 118 /* AsyncKeyword */: - if (flags & 512 /* Async */) { + if (flags & 256 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "async"); } - else if (flags & 2 /* Ambient */ || ts.isInAmbientContext(node.parent)) { + else if (flags & 4 /* Ambient */ || ts.isInAmbientContext(node.parent)) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); } else if (node.kind === 138 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "async"); } - flags |= 512 /* Async */; + flags |= 256 /* Async */; lastAsync = modifier; break; } } if (node.kind === 144 /* Constructor */) { - if (flags & 128 /* Static */) { + if (flags & 64 /* Static */) { return grammarErrorOnNode(lastStatic, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "static"); } - if (flags & 256 /* Abstract */) { + if (flags & 128 /* Abstract */) { return grammarErrorOnNode(lastStatic, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "abstract"); } - else if (flags & 64 /* Protected */) { + else if (flags & 32 /* Protected */) { return grammarErrorOnNode(lastProtected, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "protected"); } - else if (flags & 32 /* Private */) { + else if (flags & 16 /* Private */) { return grammarErrorOnNode(lastPrivate, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "private"); } - else if (flags & 512 /* Async */) { + else if (flags & 256 /* Async */) { return grammarErrorOnNode(lastAsync, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "async"); } return; } - else if ((node.kind === 222 /* ImportDeclaration */ || node.kind === 221 /* ImportEqualsDeclaration */) && flags & 2 /* Ambient */) { + else if ((node.kind === 222 /* ImportDeclaration */ || node.kind === 221 /* ImportEqualsDeclaration */) && flags & 4 /* Ambient */) { return grammarErrorOnNode(lastDeclare, ts.Diagnostics.A_0_modifier_cannot_be_used_with_an_import_declaration, "declare"); } - else if (node.kind === 138 /* Parameter */ && (flags & 112 /* AccessibilityModifier */) && ts.isBindingPattern(node.name)) { + else if (node.kind === 138 /* Parameter */ && (flags & 56 /* AccessibilityModifier */) && ts.isBindingPattern(node.name)) { return grammarErrorOnNode(node, ts.Diagnostics.A_parameter_property_may_not_be_a_binding_pattern); } - if (flags & 512 /* Async */) { + if (flags & 256 /* Async */) { return checkGrammarAsyncModifier(node, lastAsync); } } @@ -27104,7 +27554,7 @@ var ts; if (parameter.dotDotDotToken) { return grammarErrorOnNode(parameter.dotDotDotToken, ts.Diagnostics.An_index_signature_cannot_have_a_rest_parameter); } - if (parameter.flags & 2035 /* Modifier */) { + if (parameter.flags & 1022 /* Modifier */) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_cannot_have_an_accessibility_modifier); } if (parameter.questionToken) { @@ -27124,7 +27574,7 @@ var ts; } } function checkGrammarForIndexSignatureModifier(node) { - if (node.flags & 2035 /* Modifier */) { + if (node.flags & 1022 /* Modifier */) { grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_not_permitted_on_index_signature_members); } } @@ -27147,8 +27597,8 @@ var ts; function checkGrammarForOmittedArgument(node, args) { if (args) { var sourceFile = ts.getSourceFileOfNode(node); - for (var _i = 0; _i < args.length; _i++) { - var arg = args[_i]; + for (var _i = 0, args_1 = args; _i < args_1.length; _i++) { + var arg = args_1[_i]; if (arg.kind === 187 /* OmittedExpression */) { return grammarErrorAtPos(sourceFile, arg.pos, 0, ts.Diagnostics.Argument_expression_expected); } @@ -27403,7 +27853,7 @@ var ts; if (parameter.dotDotDotToken) { return grammarErrorOnNode(parameter.dotDotDotToken, ts.Diagnostics.A_set_accessor_cannot_have_rest_parameter); } - else if (parameter.flags & 2035 /* Modifier */) { + else if (parameter.flags & 1022 /* Modifier */) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation); } else if (parameter.questionToken) { @@ -27554,8 +28004,8 @@ var ts; } else { var elements = name.elements; - for (var _i = 0; _i < elements.length; _i++) { - var element = elements[_i]; + for (var _i = 0, elements_2 = elements; _i < elements_2.length; _i++) { + var element = elements_2[_i]; if (element.kind !== 187 /* OmittedExpression */) { checkGrammarNameInLetOrConstDeclarations(element.name); } @@ -27691,8 +28141,8 @@ var ts; node.kind === 221 /* ImportEqualsDeclaration */ || node.kind === 228 /* ExportDeclaration */ || node.kind === 227 /* ExportAssignment */ || - (node.flags & 2 /* Ambient */) || - (node.flags & (1 /* Export */ | 1024 /* Default */))) { + (node.flags & 4 /* Ambient */) || + (node.flags & (2 /* Export */ | 512 /* Default */))) { return false; } return grammarErrorOnFirstToken(node, ts.Diagnostics.A_declare_modifier_is_required_for_a_top_level_declaration_in_a_d_ts_file); @@ -27739,7 +28189,7 @@ var ts; } function checkGrammarNumericLiteral(node) { // Grammar checking - if (node.flags & 65536 /* OctalLiteral */ && languageVersion >= 1 /* ES5 */) { + if (node.flags & 32768 /* OctalLiteral */ && languageVersion >= 1 /* ES5 */) { return grammarErrorOnNode(node, ts.Diagnostics.Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher); } } @@ -27793,7 +28243,7 @@ var ts; ts.forEach(root.referencedFiles, function (fileReference) { var referencedFile = ts.tryResolveScriptReference(host, root, fileReference); // All the references that are not going to be part of same file - if (referencedFile && ((referencedFile.flags & 8192 /* DeclarationFile */) || + if (referencedFile && ((referencedFile.flags & 4096 /* DeclarationFile */) || ts.shouldEmitToOwnFile(referencedFile, compilerOptions) || !addedGlobalFileReference)) { writeReferencePath(referencedFile); @@ -27988,15 +28438,15 @@ var ts; } } function emitLines(nodes) { - for (var _i = 0; _i < nodes.length; _i++) { - var node = nodes[_i]; + for (var _i = 0, nodes_2 = nodes; _i < nodes_2.length; _i++) { + var node = nodes_2[_i]; emit(node); } } function emitSeparatedList(nodes, separator, eachNodeEmitFn, canEmitFn) { var currentWriterPos = writer.getTextPos(); - for (var _i = 0; _i < nodes.length; _i++) { - var node = nodes[_i]; + for (var _i = 0, nodes_3 = nodes; _i < nodes_3.length; _i++) { + var node = nodes_3[_i]; if (!canEmitFn || canEmitFn(node)) { if (currentWriterPos !== writer.getTextPos()) { write(separator); @@ -28142,6 +28592,7 @@ var ts; function emitSourceFile(node) { currentSourceFile = node; enclosingDeclaration = node; + ts.emitDetachedComments(currentSourceFile, writer, ts.writeCommentRange, node, newLine, true /* remove comments */); emitLines(node.statements); } // Return a temp variable name to be used in `export default` statements. @@ -28258,10 +28709,10 @@ var ts; // If the node is parented in the current source file we need to emit export declare or just export if (node.parent === currentSourceFile) { // If the node is exported - if (node.flags & 1 /* Export */) { + if (node.flags & 2 /* Export */) { write("export "); } - if (node.flags & 1024 /* Default */) { + if (node.flags & 512 /* Default */) { write("default "); } else if (node.kind !== 215 /* InterfaceDeclaration */) { @@ -28270,16 +28721,16 @@ var ts; } } function emitClassMemberDeclarationFlags(node) { - if (node.flags & 32 /* Private */) { + if (node.flags & 16 /* Private */) { write("private "); } - else if (node.flags & 64 /* Protected */) { + else if (node.flags & 32 /* Protected */) { write("protected "); } - if (node.flags & 128 /* Static */) { + if (node.flags & 64 /* Static */) { write("static "); } - if (node.flags & 256 /* Abstract */) { + if (node.flags & 128 /* Abstract */) { write("abstract "); } } @@ -28287,7 +28738,7 @@ var ts; // note usage of writer. methods instead of aliases created, just to make sure we are using // correct writer especially to handle asynchronous alias writing emitJsDocComments(node); - if (node.flags & 1 /* Export */) { + if (node.flags & 2 /* Export */) { write("export "); } write("import "); @@ -28322,12 +28773,12 @@ var ts; } } function writeImportDeclaration(node) { - if (!node.importClause && !(node.flags & 1 /* Export */)) { + if (!node.importClause && !(node.flags & 2 /* Export */)) { // do not write non-exported import declarations that don't have import clauses return; } emitJsDocComments(node); - if (node.flags & 1 /* Export */) { + if (node.flags & 2 /* Export */) { write("export "); } write("import "); @@ -28392,7 +28843,7 @@ var ts; function writeModuleDeclaration(node) { emitJsDocComments(node); emitModuleElementDeclarationFlags(node); - if (node.flags & 131072 /* Namespace */) { + if (node.flags & 65536 /* Namespace */) { write("namespace "); } else { @@ -28464,7 +28915,7 @@ var ts; writeLine(); } function isPrivateMethodTypeParameter(node) { - return node.parent.kind === 143 /* MethodDeclaration */ && (node.parent.flags & 32 /* Private */); + return node.parent.kind === 143 /* MethodDeclaration */ && (node.parent.flags & 16 /* Private */); } function emitTypeParameters(typeParameters) { function emitTypeParameter(node) { @@ -28508,7 +28959,7 @@ var ts; break; case 143 /* MethodDeclaration */: case 142 /* MethodSignature */: - if (node.parent.flags & 128 /* Static */) { + if (node.parent.flags & 64 /* 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 === 214 /* ClassDeclaration */) { @@ -28574,7 +29025,7 @@ var ts; function emitParameterProperties(constructorDeclaration) { if (constructorDeclaration) { ts.forEach(constructorDeclaration.parameters, function (param) { - if (param.flags & 112 /* AccessibilityModifier */) { + if (param.flags & 56 /* AccessibilityModifier */) { emitPropertyDeclaration(param); } }); @@ -28582,7 +29033,7 @@ var ts; } emitJsDocComments(node); emitModuleElementDeclarationFlags(node); - if (node.flags & 256 /* Abstract */) { + if (node.flags & 128 /* Abstract */) { write("abstract "); } write("class "); @@ -28652,7 +29103,7 @@ var ts; if ((node.kind === 141 /* PropertyDeclaration */ || node.kind === 140 /* PropertySignature */) && node.parent.kind === 155 /* TypeLiteral */) { emitTypeOfVariableDeclarationFromTypeLiteral(node); } - else if (!(node.flags & 32 /* Private */)) { + else if (!(node.flags & 16 /* Private */)) { writeTypeOfDeclaration(node, node.type, getVariableDeclarationTypeVisibilityError); } } @@ -28667,7 +29118,7 @@ var ts; } else if (node.kind === 141 /* PropertyDeclaration */ || node.kind === 140 /* PropertySignature */) { // TODO(jfreeman): Deal with computed properties in error reporting. - if (node.flags & 128 /* Static */) { + if (node.flags & 64 /* Static */) { return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -28771,7 +29222,7 @@ var ts; emitJsDocComments(accessors.setAccessor); emitClassMemberDeclarationFlags(node); writeTextOfNode(currentSourceFile, node.name); - if (!(node.flags & 32 /* Private */)) { + if (!(node.flags & 16 /* Private */)) { accessorWithTypeAnnotation = node; var type = getTypeAnnotationFromAccessor(node); if (!type) { @@ -28800,7 +29251,7 @@ var ts; var diagnosticMessage; if (accessorWithTypeAnnotation.kind === 146 /* SetAccessor */) { // Setters have to have type named and cannot infer it so, the type should always be named - if (accessorWithTypeAnnotation.parent.flags & 128 /* Static */) { + if (accessorWithTypeAnnotation.parent.flags & 64 /* Static */) { diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_public_static_property_setter_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_public_static_property_setter_from_exported_class_has_or_is_using_private_name_1; @@ -28818,7 +29269,7 @@ var ts; }; } else { - if (accessorWithTypeAnnotation.flags & 128 /* Static */) { + if (accessorWithTypeAnnotation.flags & 64 /* Static */) { diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Return_type_of_public_static_property_getter_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : @@ -28905,7 +29356,7 @@ var ts; emitType(node.type); } } - else if (node.kind !== 144 /* Constructor */ && !(node.flags & 32 /* Private */)) { + else if (node.kind !== 144 /* Constructor */ && !(node.flags & 16 /* Private */)) { writeReturnTypeAtSignature(node, getReturnTypeVisibilityError); } enclosingDeclaration = prevEnclosingDeclaration; @@ -28936,7 +29387,7 @@ var ts; break; case 143 /* MethodDeclaration */: case 142 /* MethodSignature */: - if (node.flags & 128 /* Static */) { + if (node.flags & 64 /* Static */) { diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : @@ -28997,7 +29448,7 @@ var ts; node.parent.parent.kind === 155 /* TypeLiteral */) { emitTypeOfVariableDeclarationFromTypeLiteral(node); } - else if (!(node.parent.flags & 32 /* Private */)) { + else if (!(node.parent.flags & 16 /* Private */)) { writeTypeOfDeclaration(node, node.type, getParameterDeclarationTypeVisibilityError); } function getParameterDeclarationTypeVisibilityError(symbolAccesibilityResult) { @@ -29028,7 +29479,7 @@ var ts; ts.Diagnostics.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; case 143 /* MethodDeclaration */: case 142 /* MethodSignature */: - if (node.parent.flags & 128 /* Static */) { + if (node.parent.flags & 64 /* Static */) { return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -29170,7 +29621,7 @@ var ts; } } function writeReferencePath(referencedFile) { - var declFileName = referencedFile.flags & 8192 /* DeclarationFile */ + var declFileName = referencedFile.flags & 4096 /* DeclarationFile */ ? referencedFile.fileName // Declaration file, use declaration file name : ts.shouldEmitToOwnFile(referencedFile, compilerOptions) ? ts.getOwnEmitOutputFilePath(referencedFile, host, ".d.ts") // Own output file so get the .d.ts file @@ -29216,6 +29667,12 @@ var ts; return ts.isExternalModule(sourceFile) || ts.isDeclarationFile(sourceFile); } ts.isExternalModuleOrDeclarationFile = isExternalModuleOrDeclarationFile; + var Jump; + (function (Jump) { + Jump[Jump["Break"] = 2] = "Break"; + Jump[Jump["Continue"] = 4] = "Continue"; + Jump[Jump["Return"] = 8] = "Return"; + })(Jump || (Jump = {})); var entities = { "quot": 0x0022, "amp": 0x0026, @@ -29525,16 +29982,8 @@ var ts; diagnostics: diagnostics, sourceMaps: sourceMapDataList }; - function isNodeDescendentOf(node, ancestor) { - while (node) { - if (node === ancestor) - return true; - node = node.parent; - } - return false; - } function isUniqueLocalName(name, container) { - for (var node = container; isNodeDescendentOf(node, container); node = node.nextContainer) { + for (var node = container; ts.isNodeDescendentOf(node, container); node = node.nextContainer) { if (node.locals && ts.hasProperty(node.locals, name)) { // We conservatively include alias symbols to cover cases where they're emitted as locals if (node.locals[name].flags & (107455 /* Value */ | 1048576 /* ExportValue */ | 8388608 /* Alias */)) { @@ -29544,12 +29993,6 @@ var ts; } return true; } - var Jump; - (function (Jump) { - Jump[Jump["Break"] = 2] = "Break"; - Jump[Jump["Continue"] = 4] = "Continue"; - Jump[Jump["Return"] = 8] = "Return"; - })(Jump || (Jump = {})); function setLabeledJump(state, isBreak, labelText, labelMarker) { if (isBreak) { if (!state.labeledNonLocalBreaks) { @@ -31026,7 +31469,7 @@ var ts; write("]"); } else { - emitListWithSpread(elements, /*needsUniqueCopy*/ true, /*multiLine*/ (node.flags & 2048 /* MultiLine */) !== 0, + emitListWithSpread(elements, /*needsUniqueCopy*/ true, /*multiLine*/ (node.flags & 1024 /* MultiLine */) !== 0, /*trailingComma*/ elements.hasTrailingComma, /*useConcat*/ true); } } @@ -31045,7 +31488,7 @@ var ts; emitLinePreservingList(node, properties, /* allowTrailingComma */ languageVersion >= 1 /* ES5 */, /* spacesBetweenBraces */ true); } else { - var multiLine = (node.flags & 2048 /* MultiLine */) !== 0; + var multiLine = (node.flags & 1024 /* MultiLine */) !== 0; if (!multiLine) { write(" "); } @@ -31064,7 +31507,7 @@ var ts; write("}"); } function emitDownlevelObjectLiteralWithComputedProperties(node, firstComputedPropertyIndex) { - var multiLine = (node.flags & 2048 /* MultiLine */) !== 0; + var multiLine = (node.flags & 1024 /* MultiLine */) !== 0; var properties = node.properties; write("("); if (multiLine) { @@ -31693,7 +32136,7 @@ var ts; var current = node; while (current) { if (current.kind === 248 /* SourceFile */) { - return !isExported || ((ts.getCombinedNodeFlags(node) & 1 /* Export */) !== 0); + return !isExported || ((ts.getCombinedNodeFlags(node) & 2 /* Export */) !== 0); } else if (ts.isFunctionLike(current) || current.kind === 219 /* ModuleBlock */) { return false; @@ -31934,7 +32377,7 @@ var ts; // variables in variable declaration list were already hoisted return false; } - if (convertedLoopState && (ts.getCombinedNodeFlags(decl) & 49152 /* BlockScoped */) === 0) { + if (convertedLoopState && (ts.getCombinedNodeFlags(decl) & 24576 /* BlockScoped */) === 0) { // we are inside a converted loop - this can only happen in downlevel scenarios // record names for all variable declarations for (var _a = 0, _b = decl.declarations; _a < _b.length; _a++) { @@ -32019,7 +32462,7 @@ var ts; break; } var loopParameters; - if (loopInitializer && (ts.getCombinedNodeFlags(loopInitializer) & 49152 /* BlockScoped */)) { + if (loopInitializer && (ts.getCombinedNodeFlags(loopInitializer) & 24576 /* BlockScoped */)) { // if loop initializer contains block scoped variables - they should be passed to converted loop body as parameters loopParameters = []; for (var _a = 0, _b = loopInitializer.declarations; _a < _b.length; _a++) { @@ -32334,10 +32777,12 @@ var ts; // // for (let v of arr) { } // - // we don't want to emit a temporary variable for the RHS, just use it directly. - var rhsIsIdentifier = node.expression.kind === 69 /* Identifier */; + // we can't reuse 'arr' because it might be modified within the body of the loop. var counter = createTempVariable(268435456 /* _i */); - var rhsReference = rhsIsIdentifier ? node.expression : createTempVariable(0 /* Auto */); + var rhsReference = ts.createSynthesizedNode(69 /* Identifier */); + rhsReference.text = node.expression.kind === 69 /* Identifier */ ? + makeUniqueName(node.expression.text) : + makeTempVariableName(0 /* Auto */); // This is the let keyword for the counter and rhsReference. The let keyword for // the LHS will be emitted inside the body. emitStart(node.expression); @@ -32346,15 +32791,13 @@ var ts; emitNodeWithoutSourceMap(counter); write(" = 0"); emitEnd(node.expression); - if (!rhsIsIdentifier) { - // , _a = expr - write(", "); - emitStart(node.expression); - emitNodeWithoutSourceMap(rhsReference); - write(" = "); - emitNodeWithoutSourceMap(node.expression); - emitEnd(node.expression); - } + // , _a = expr + write(", "); + emitStart(node.expression); + emitNodeWithoutSourceMap(rhsReference); + write(" = "); + emitNodeWithoutSourceMap(node.expression); + emitEnd(node.expression); write("; "); // _i < _a.length; emitStart(node.initializer); @@ -32609,7 +33052,7 @@ var ts; } function emitModuleMemberName(node) { emitStart(node.name); - if (ts.getCombinedNodeFlags(node) & 1 /* Export */) { + if (ts.getCombinedNodeFlags(node) & 2 /* Export */) { var container = getContainingModule(node); if (container) { write(getGeneratedNameForNode(container)); @@ -32631,7 +33074,7 @@ var ts; } function emitEs6ExportDefaultCompat(node) { if (node.parent.kind === 248 /* SourceFile */) { - ts.Debug.assert(!!(node.flags & 1024 /* Default */) || node.kind === 227 /* ExportAssignment */); + ts.Debug.assert(!!(node.flags & 512 /* Default */) || node.kind === 227 /* ExportAssignment */); // only allow export default at a source file level if (modulekind === 1 /* CommonJS */ || modulekind === 2 /* AMD */ || modulekind === 3 /* UMD */) { if (!currentSourceFile.symbol.exports["___esModule"]) { @@ -32649,7 +33092,7 @@ var ts; } } function emitExportMemberAssignment(node) { - if (node.flags & 1 /* Export */) { + if (node.flags & 2 /* Export */) { writeLine(); emitStart(node); // emit call to exporter only for top level nodes @@ -32657,7 +33100,7 @@ var ts; // emit export default as // export("default", ) write(exportFunctionForFile + "(\""); - if (node.flags & 1024 /* Default */) { + if (node.flags & 512 /* Default */) { write("default"); } else { @@ -32668,7 +33111,7 @@ var ts; write(")"); } else { - if (node.flags & 1024 /* Default */) { + if (node.flags & 512 /* Default */) { emitEs6ExportDefaultCompat(node); if (languageVersion === 0 /* ES3 */) { write("exports[\"default\"]"); @@ -32772,7 +33215,7 @@ var ts; // because actual variable declarations are hoisted var canDefineTempVariablesInPlace = false; if (root.kind === 211 /* VariableDeclaration */) { - var isExported = ts.getCombinedNodeFlags(root) & 1 /* Export */; + var isExported = ts.getCombinedNodeFlags(root) & 2 /* Export */; var isSourceLevelForSystemModuleKind = shouldHoistDeclarationInSystemJsModule(root); canDefineTempVariablesInPlace = !isExported && !isSourceLevelForSystemModuleKind; } @@ -32854,8 +33297,8 @@ var ts; // to ensure value is evaluated exactly once. value = ensureIdentifier(value, /*reuseIdentifierExpressions*/ true); } - for (var _a = 0; _a < properties.length; _a++) { - var p = properties[_a]; + for (var _a = 0, properties_5 = properties; _a < properties_5.length; _a++) { + var p = properties_5[_a]; if (p.kind === 245 /* PropertyAssignment */ || p.kind === 246 /* ShorthandPropertyAssignment */) { var propName = p.name; var target_1 = p.kind === 246 /* ShorthandPropertyAssignment */ ? p : p.initializer || propName; @@ -32990,7 +33433,7 @@ var ts; // this is necessary to preserve ES6 semantic in scenarios like // for (...) { let x; console.log(x); x = 1 } // assignment on one iteration should not affect other iterations var isLetDefinedInLoop = (resolver.getNodeCheckFlags(node) & 16384 /* BlockScopedBindingInLoop */) && - (getCombinedFlagsForIdentifier(node.name) & 16384 /* Let */); + (getCombinedFlagsForIdentifier(node.name) & 8192 /* Let */); // NOTE: default initialization should not be added to let bindings in for-in\for-of statements if (isLetDefinedInLoop && node.parent.parent.kind !== 200 /* ForInStatement */ && @@ -33030,13 +33473,13 @@ var ts; return ts.getCombinedNodeFlags(node.parent); } function isES6ExportedDeclaration(node) { - return !!(node.flags & 1 /* Export */) && + return !!(node.flags & 2 /* Export */) && modulekind === 5 /* ES6 */ && node.parent.kind === 248 /* SourceFile */; } function emitVariableStatement(node) { var startIsEmitted = false; - if (node.flags & 1 /* Export */) { + if (node.flags & 2 /* Export */) { if (isES6ExportedDeclaration(node)) { // Exported ES6 module member write("export "); @@ -33063,7 +33506,7 @@ var ts; function shouldEmitLeadingAndTrailingCommentsForVariableStatement(node) { // If we're not exporting the variables, there's nothing special here. // Always emit comments for these nodes. - if (!(node.flags & 1 /* Export */)) { + if (!(node.flags & 2 /* Export */)) { return true; } // If we are exporting, but it's a top-level ES6 module exports, @@ -33246,7 +33689,7 @@ var ts; if (!shouldEmitAsArrowFunction(node)) { if (isES6ExportedDeclaration(node)) { write("export "); - if (node.flags & 1024 /* Default */) { + if (node.flags & 512 /* Default */) { write("default "); } } @@ -33466,7 +33909,7 @@ var ts; emitRestParameter(node); } function emitExpressionFunctionBody(node, body) { - if (languageVersion < 2 /* ES6 */ || node.flags & 512 /* Async */) { + if (languageVersion < 2 /* ES6 */ || node.flags & 256 /* Async */) { emitDownLevelExpressionFunctionBody(node, body); return; } @@ -33487,7 +33930,7 @@ var ts; scopeEmitStart(node); increaseIndent(); var outPos = writer.getTextPos(); - emitDetachedComments(node.body); + emitDetachedCommentsAndUpdateCommentsInfo(node.body); emitFunctionBodyPreamble(node); var preambleEmitted = writer.getTextPos() !== outPos; decreaseIndent(); @@ -33525,7 +33968,7 @@ var ts; scopeEmitStart(node); var initialTextPos = writer.getTextPos(); increaseIndent(); - emitDetachedComments(body.statements); + emitDetachedCommentsAndUpdateCommentsInfo(body.statements); // Emit all the directive prologues (like "use strict"). These have to come before // any other preamble code we write (like parameter initializers). var startIndex = emitDirectivePrologues(body.statements, /*startWithNewLine*/ true); @@ -33569,7 +34012,7 @@ var ts; } function emitParameterPropertyAssignments(node) { ts.forEach(node.parameters, function (param) { - if (param.flags & 112 /* AccessibilityModifier */) { + if (param.flags & 56 /* AccessibilityModifier */) { writeLine(); emitStart(param); emitStart(param.name); @@ -33604,15 +34047,15 @@ var ts; var properties = []; for (var _a = 0, _b = node.members; _a < _b.length; _a++) { var member = _b[_a]; - if (member.kind === 141 /* PropertyDeclaration */ && isStatic === ((member.flags & 128 /* Static */) !== 0) && member.initializer) { + if (member.kind === 141 /* PropertyDeclaration */ && isStatic === ((member.flags & 64 /* Static */) !== 0) && member.initializer) { properties.push(member); } } return properties; } function emitPropertyDeclarations(node, properties) { - for (var _a = 0; _a < properties.length; _a++) { - var property = properties[_a]; + for (var _a = 0, properties_6 = properties; _a < properties_6.length; _a++) { + var property = properties_6[_a]; emitPropertyDeclaration(node, property); } } @@ -33625,7 +34068,7 @@ var ts; emit(receiver); } else { - if (property.flags & 128 /* Static */) { + if (property.flags & 64 /* Static */) { emitDeclarationName(node); } else { @@ -33724,7 +34167,7 @@ var ts; writeLine(); emitLeadingComments(member); emitStart(member); - if (member.flags & 128 /* Static */) { + if (member.flags & 64 /* Static */) { write("static "); } if (member.kind === 145 /* GetAccessor */) { @@ -33774,7 +34217,7 @@ var ts; emitCommentsOnNotEmittedNode(member); } // Check if there is any non-static property assignment - if (member.kind === 141 /* PropertyDeclaration */ && member.initializer && (member.flags & 128 /* Static */) === 0) { + if (member.kind === 141 /* PropertyDeclaration */ && member.initializer && (member.flags & 64 /* Static */) === 0) { hasInstancePropertyWithInitializer = true; } }); @@ -33821,7 +34264,7 @@ var ts; // Emit all the directive prologues (like "use strict"). These have to come before // any other preamble code we write (like parameter initializers). startIndex = emitDirectivePrologues(ctor.body.statements, /*startWithNewLine*/ true); - emitDetachedComments(ctor.body.statements); + emitDetachedCommentsAndUpdateCommentsInfo(ctor.body.statements); } emitCaptureThisForNodeIfNecessary(node); var superCall; @@ -33941,7 +34384,7 @@ var ts; // _default = __decorate([dec], _default); // export default _default; // - if (isES6ExportedDeclaration(node) && !(node.flags & 1024 /* Default */)) { + if (isES6ExportedDeclaration(node) && !(node.flags & 512 /* Default */)) { write("export "); } write("let "); @@ -33950,7 +34393,7 @@ var ts; } else if (isES6ExportedDeclaration(node)) { write("export "); - if (node.flags & 1024 /* Default */) { + if (node.flags & 512 /* Default */) { write("default "); } } @@ -33980,7 +34423,7 @@ var ts; // emit name if // - node has a name // - this is default export with static initializers - if ((node.name || (node.flags & 1024 /* Default */ && staticProperties.length > 0)) && !thisNodeIsDecorated) { + if ((node.name || (node.flags & 512 /* Default */ && staticProperties.length > 0)) && !thisNodeIsDecorated) { write(" "); emitDeclarationName(node); } @@ -34016,8 +34459,8 @@ 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 (isClassExpressionWithStaticProperties) { - for (var _a = 0; _a < staticProperties.length; _a++) { - var property = staticProperties[_a]; + for (var _a = 0, staticProperties_1 = staticProperties; _a < staticProperties_1.length; _a++) { + var property = staticProperties_1[_a]; write(","); writeLine(); emitPropertyDeclaration(node, property, /*receiver:*/ tempVariable, /*isExpression:*/ true); @@ -34035,7 +34478,7 @@ var ts; } // If this is an exported class, but not on the top level (i.e. on an internal // module), export it - if (!isES6ExportedDeclaration(node) && (node.flags & 1 /* Export */)) { + if (!isES6ExportedDeclaration(node) && (node.flags & 2 /* Export */)) { writeLine(); emitStart(node); emitModuleMemberName(node); @@ -34044,7 +34487,7 @@ var ts; emitEnd(node); write(";"); } - else if (isES6ExportedDeclaration(node) && (node.flags & 1024 /* Default */) && thisNodeIsDecorated) { + else if (isES6ExportedDeclaration(node) && (node.flags & 512 /* Default */) && thisNodeIsDecorated) { // if this is a top level default export of decorated class, write the export after the declaration. writeLine(); write("export default "); @@ -34126,13 +34569,13 @@ var ts; } function emitClassMemberPrefix(node, member) { emitDeclarationName(node); - if (!(member.flags & 128 /* Static */)) { + if (!(member.flags & 64 /* Static */)) { write(".prototype"); } } function emitDecoratorsOfClass(node) { emitDecoratorsOfMembers(node, /*staticFlag*/ 0); - emitDecoratorsOfMembers(node, 128 /* Static */); + emitDecoratorsOfMembers(node, 64 /* Static */); emitDecoratorsOfConstructor(node); } function emitDecoratorsOfConstructor(node) { @@ -34179,7 +34622,7 @@ var ts; for (var _a = 0, _b = node.members; _a < _b.length; _a++) { var member = _b[_a]; // only emit members in the correct group - if ((member.flags & 128 /* Static */) !== staticFlag) { + if ((member.flags & 64 /* Static */) !== staticFlag) { continue; } // skip members that cannot be decorated (such as the constructor) @@ -34580,7 +35023,7 @@ var ts; } if (!shouldHoistDeclarationInSystemJsModule(node)) { // do not emit var if variable was already hoisted - if (!(node.flags & 1 /* Export */) || isES6ExportedDeclaration(node)) { + if (!(node.flags & 2 /* Export */) || isES6ExportedDeclaration(node)) { emitStart(node); if (isES6ExportedDeclaration(node)) { write("export "); @@ -34611,7 +35054,7 @@ var ts; emitModuleMemberName(node); write(" = {}));"); emitEnd(node); - if (!isES6ExportedDeclaration(node) && node.flags & 1 /* Export */ && !shouldHoistDeclarationInSystemJsModule(node)) { + if (!isES6ExportedDeclaration(node) && node.flags & 2 /* Export */ && !shouldHoistDeclarationInSystemJsModule(node)) { // do not emit var if variable was already hoisted writeLine(); emitStart(node); @@ -34623,7 +35066,7 @@ var ts; write(";"); } if (modulekind !== 5 /* ES6 */ && node.parent === currentSourceFile) { - if (modulekind === 4 /* System */ && (node.flags & 1 /* Export */)) { + if (modulekind === 4 /* System */ && (node.flags & 2 /* Export */)) { // write the call to exporter for enum writeLine(); write(exportFunctionForFile + "(\""); @@ -34728,7 +35171,7 @@ var ts; } write(")("); // write moduleDecl = containingModule.m only if it is not exported es6 module member - if ((node.flags & 1 /* Export */) && !isES6ExportedDeclaration(node)) { + if ((node.flags & 2 /* Export */) && !isES6ExportedDeclaration(node)) { emit(node.name); write(" = "); } @@ -34738,7 +35181,7 @@ var ts; write(" = {}));"); emitEnd(node); if (!isES6ExportedDeclaration(node) && node.name.kind === 69 /* Identifier */ && node.parent === currentSourceFile) { - if (modulekind === 4 /* System */ && (node.flags & 1 /* Export */)) { + if (modulekind === 4 /* System */ && (node.flags & 2 /* Export */)) { writeLine(); write(exportFunctionForFile + "(\""); emitDeclarationName(node); @@ -34841,7 +35284,7 @@ var ts; } function emitExternalImportDeclaration(node) { if (ts.contains(externalImports, node)) { - var isExportedImport = node.kind === 221 /* ImportEqualsDeclaration */ && (node.flags & 1 /* Export */) !== 0; + var isExportedImport = node.kind === 221 /* ImportEqualsDeclaration */ && (node.flags & 2 /* Export */) !== 0; var namespaceDeclaration = getNamespaceDeclarationNode(node); if (modulekind !== 2 /* AMD */) { emitLeadingComments(node); @@ -34923,7 +35366,7 @@ var ts; write("export "); write("var "); } - else if (!(node.flags & 1 /* Export */)) { + else if (!(node.flags & 2 /* Export */)) { write("var "); } } @@ -35014,8 +35457,8 @@ var ts; function emitExportOrImportSpecifierList(specifiers, shouldEmit) { ts.Debug.assert(modulekind === 5 /* ES6 */); var needsComma = false; - for (var _a = 0; _a < specifiers.length; _a++) { - var specifier = specifiers[_a]; + for (var _a = 0, specifiers_1 = specifiers; _a < specifiers_1.length; _a++) { + var specifier = specifiers_1[_a]; if (shouldEmit(specifier)) { if (needsComma) { write(", "); @@ -35158,8 +35601,8 @@ var ts; } writeLine(); var started = false; - for (var _a = 0; _a < externalImports.length; _a++) { - var importNode = externalImports[_a]; + for (var _a = 0, externalImports_1 = externalImports; _a < externalImports_1.length; _a++) { + var importNode = externalImports_1[_a]; // do not create variable declaration for exports and imports that lack import clause var skipNode = importNode.kind === 228 /* ExportDeclaration */ || (importNode.kind === 222 /* ImportDeclaration */ && !importNode.importClause); @@ -35193,8 +35636,8 @@ var ts; // no exported declarations (export var ...) or export specifiers (export {x}) // check if we have any non star export declarations. var hasExportDeclarationWithExportClause = false; - for (var _a = 0; _a < externalImports.length; _a++) { - var externalImport = externalImports[_a]; + for (var _a = 0, externalImports_2 = externalImports; _a < externalImports_2.length; _a++) { + var externalImport = externalImports_2[_a]; if (externalImport.kind === 228 /* ExportDeclaration */ && externalImport.exportClause) { hasExportDeclarationWithExportClause = true; break; @@ -35225,8 +35668,8 @@ var ts; } } } - for (var _d = 0; _d < externalImports.length; _d++) { - var externalImport = externalImports[_d]; + for (var _d = 0, externalImports_3 = externalImports; _d < externalImports_3.length; _d++) { + var externalImport = externalImports_3[_d]; if (externalImport.kind !== 228 /* ExportDeclaration */) { continue; } @@ -35275,7 +35718,7 @@ var ts; function writeExportedName(node) { // do not record default exports // they are local to module and never overwritten (explicitly skipped) by star export - if (node.kind !== 69 /* Identifier */ && node.flags & 1024 /* Default */) { + if (node.kind !== 69 /* Identifier */ && node.flags & 512 /* Default */) { return; } if (started) { @@ -35338,7 +35781,7 @@ var ts; emit(local); } var flags = ts.getCombinedNodeFlags(local.kind === 69 /* Identifier */ ? local.parent : local); - if (flags & 1 /* Export */) { + if (flags & 2 /* Export */) { if (!exportedDeclarations) { exportedDeclarations = []; } @@ -35348,11 +35791,11 @@ var ts; write(";"); } if (hoistedFunctionDeclarations) { - for (var _a = 0; _a < hoistedFunctionDeclarations.length; _a++) { - var f = hoistedFunctionDeclarations[_a]; + for (var _a = 0, hoistedFunctionDeclarations_1 = hoistedFunctionDeclarations; _a < hoistedFunctionDeclarations_1.length; _a++) { + var f = hoistedFunctionDeclarations_1[_a]; writeLine(); emit(f); - if (f.flags & 1 /* Export */) { + if (f.flags & 2 /* Export */) { if (!exportedDeclarations) { exportedDeclarations = []; } @@ -35362,7 +35805,7 @@ var ts; } return exportedDeclarations; function visit(node) { - if (node.flags & 2 /* Ambient */) { + if (node.flags & 4 /* Ambient */) { return; } if (node.kind === 213 /* FunctionDeclaration */) { @@ -35437,7 +35880,7 @@ var ts; // - it is top level block scoped // if block scoped variables are nested in some another block then // no other functions can use them except ones that are defined at least in the same block - return (ts.getCombinedNodeFlags(node) & 49152 /* BlockScoped */) === 0 || + return (ts.getCombinedNodeFlags(node) & 24576 /* BlockScoped */) === 0 || ts.getEnclosingBlockScopeContainer(node).kind === 248 /* SourceFile */; } function isCurrentFileSystemExternalModule() { @@ -35509,8 +35952,8 @@ var ts; var parameterName = makeUniqueName(ts.forEach(group, getLocalNameForExternalImport) || ""); write("function (" + parameterName + ") {"); increaseIndent(); - for (var _a = 0; _a < group.length; _a++) { - var entry = group[_a]; + for (var _a = 0, group_1 = group; _a < group_1.length; _a++) { + var entry = group_1[_a]; var importVariableName = getLocalNameForExternalImport(entry) || ""; switch (entry.kind) { case 222 /* ImportDeclaration */: @@ -35679,8 +36122,8 @@ var ts; unaliasedModuleNames.push("\"" + amdDependency.path + "\""); } } - for (var _c = 0; _c < externalImports.length; _c++) { - var importNode = externalImports[_c]; + for (var _c = 0, externalImports_4 = externalImports; _c < externalImports_4.length; _c++) { + var importNode = externalImports_4[_c]; // Find the name of the external module var externalModuleName = getExternalModuleNameText(importNode); // Find the name of the module alias, if there is one @@ -35959,7 +36402,7 @@ var ts; // Start new file on new line writeLine(); emitShebang(); - emitDetachedComments(node); + emitDetachedCommentsAndUpdateCommentsInfo(node); if (ts.isExternalModule(node) || compilerOptions.isolatedModules) { var emitModule = moduleEmitDelegates[modulekind] || moduleEmitDelegates[1 /* CommonJS */]; emitModule(node); @@ -35983,7 +36426,7 @@ var ts; } function emitNodeConsideringCommentsOption(node, emitNodeConsideringSourcemap) { if (node) { - if (node.flags & 2 /* Ambient */) { + if (node.flags & 4 /* Ambient */) { return emitCommentsOnNotEmittedNode(node); } if (isSpecializedCommentHandling(node)) { @@ -36232,10 +36675,6 @@ var ts; } return leadingComments; } - function isPinnedComments(comment) { - return currentSourceFile.text.charCodeAt(comment.pos + 1) === 42 /* asterisk */ && - currentSourceFile.text.charCodeAt(comment.pos + 2) === 33 /* exclamation */; - } /** * Determine if the given comment is a triple-slash * @@ -36350,57 +36789,14 @@ var ts; // Leading comments are emitted at /*leading comment1 */space/*leading comment*/space ts.emitComments(currentSourceFile, writer, leadingComments, /*trailingSeparator*/ true, newLine, writeComment); } - function emitDetachedComments(node) { - var leadingComments; - if (compilerOptions.removeComments) { - // removeComments is true, only reserve pinned comment at the top of file - // For example: - // /*! Pinned Comment */ - // - // var x = 10; - if (node.pos === 0) { - leadingComments = ts.filter(ts.getLeadingCommentRanges(currentSourceFile.text, node.pos), isPinnedComments); + function emitDetachedCommentsAndUpdateCommentsInfo(node) { + var currentDetachedCommentInfo = ts.emitDetachedComments(currentSourceFile, writer, writeComment, node, newLine, compilerOptions.removeComments); + if (currentDetachedCommentInfo) { + if (detachedCommentsInfo) { + detachedCommentsInfo.push(currentDetachedCommentInfo); } - } - else { - // removeComments is false, just get detached as normal and bypass the process to filter comment - leadingComments = ts.getLeadingCommentRanges(currentSourceFile.text, node.pos); - } - if (leadingComments) { - var detachedComments = []; - var lastComment; - ts.forEach(leadingComments, function (comment) { - if (lastComment) { - var lastCommentLine = ts.getLineOfLocalPosition(currentSourceFile, lastComment.end); - var commentLine = ts.getLineOfLocalPosition(currentSourceFile, comment.pos); - if (commentLine >= lastCommentLine + 2) { - // There was a blank line between the last comment and this comment. This - // comment is not part of the copyright comments. Return what we have so - // far. - return detachedComments; - } - } - detachedComments.push(comment); - lastComment = comment; - }); - if (detachedComments.length) { - // All comments look like they could have been part of the copyright header. Make - // sure there is at least one blank line between it and the node. If not, it's not - // a copyright header. - var lastCommentLine = ts.getLineOfLocalPosition(currentSourceFile, ts.lastOrUndefined(detachedComments).end); - var nodeLine = ts.getLineOfLocalPosition(currentSourceFile, ts.skipTrivia(currentSourceFile.text, node.pos)); - if (nodeLine >= lastCommentLine + 2) { - // Valid detachedComments - ts.emitNewLineBeforeLeadingComments(currentSourceFile, writer, node, leadingComments); - ts.emitComments(currentSourceFile, writer, detachedComments, /*trailingSeparator*/ true, newLine, writeComment); - var currentDetachedCommentInfo = { nodePos: node.pos, detachedCommentEndPos: ts.lastOrUndefined(detachedComments).end }; - if (detachedCommentsInfo) { - detachedCommentsInfo.push(currentDetachedCommentInfo); - } - else { - detachedCommentsInfo = [currentDetachedCommentInfo]; - } - } + else { + detachedCommentsInfo = [currentDetachedCommentInfo]; } } } @@ -36716,7 +37112,7 @@ var ts; var resolveModuleNamesWorker = host.resolveModuleNames ? (function (moduleNames, containingFile) { return host.resolveModuleNames(moduleNames, containingFile); }) : (function (moduleNames, containingFile) { return ts.map(moduleNames, function (moduleName) { return resolveModuleName(moduleName, containingFile, options, host).resolvedModule; }); }); - var filesByName = ts.createFileMap(getCanonicalFileName); + var filesByName = ts.createFileMap(); // stores 'filename -> file association' ignoring case // used to track cases when two file names differ only in casing var filesByNameIgnoreCase = host.useCaseSensitiveFileNames() ? ts.createFileMap(function (fileName) { return fileName.toLowerCase(); }) : undefined; @@ -36774,8 +37170,8 @@ var ts; // Initialize a checker so that all our files are bound. getTypeChecker(); classifiableNames = {}; - for (var _i = 0; _i < files.length; _i++) { - var sourceFile = files[_i]; + for (var _i = 0, files_3 = files; _i < files_3.length; _i++) { + var sourceFile = files_3[_i]; ts.copyMap(sourceFile.classifiableNames, classifiableNames); } } @@ -36793,7 +37189,7 @@ var ts; } // check if program source files has changed in the way that can affect structure of the program var newSourceFiles = []; - var normalizedAbsoluteFileNames = []; + var filePaths = []; var modifiedSourceFiles = []; for (var _i = 0, _a = oldProgram.getSourceFiles(); _i < _a.length; _i++) { var oldSourceFile = _a[_i]; @@ -36801,8 +37197,8 @@ var ts; if (!newSourceFile) { return false; } - var normalizedAbsolutePath = ts.getNormalizedAbsolutePath(newSourceFile.fileName, currentDirectory); - normalizedAbsoluteFileNames.push(normalizedAbsolutePath); + newSourceFile.path = oldSourceFile.path; + filePaths.push(newSourceFile.path); if (oldSourceFile !== newSourceFile) { if (oldSourceFile.hasNoDefaultLib !== newSourceFile.hasNoDefaultLib) { // value of no-default-lib has changed @@ -36822,7 +37218,7 @@ var ts; } if (resolveModuleNamesWorker) { var moduleNames = ts.map(newSourceFile.imports, function (name) { return name.text; }); - var resolutions = resolveModuleNamesWorker(moduleNames, normalizedAbsolutePath); + var resolutions = resolveModuleNamesWorker(moduleNames, ts.getNormalizedAbsolutePath(newSourceFile.fileName, currentDirectory)); // ensure that module resolution results are still correct for (var i = 0; i < moduleNames.length; ++i) { var newResolution = resolutions[i]; @@ -36850,12 +37246,12 @@ var ts; } // update fileName -> file mapping for (var i = 0, len = newSourceFiles.length; i < len; ++i) { - filesByName.set(normalizedAbsoluteFileNames[i], newSourceFiles[i]); + filesByName.set(filePaths[i], newSourceFiles[i]); } files = newSourceFiles; fileProcessingDiagnostics = oldProgram.getFileProcessingDiagnostics(); - for (var _b = 0; _b < modifiedSourceFiles.length; _b++) { - var modifiedFile = modifiedSourceFiles[_b]; + for (var _b = 0, modifiedSourceFiles_1 = modifiedSourceFiles; _b < modifiedSourceFiles_1.length; _b++) { + var modifiedFile = modifiedSourceFiles_1[_b]; fileProcessingDiagnostics.reattachFileDiagnostics(modifiedFile); } oldProgram.structureIsReused = true; @@ -36905,7 +37301,7 @@ var ts; return emitResult; } function getSourceFile(fileName) { - return filesByName.get(ts.getNormalizedAbsolutePath(fileName, currentDirectory)); + return filesByName.get(ts.toPath(fileName, currentDirectory, getCanonicalFileName)); } function getDiagnosticsHelper(sourceFile, getDiagnostics, cancellationToken) { if (sourceFile) { @@ -37024,7 +37420,7 @@ var ts; } break; case 218 /* ModuleDeclaration */: - if (node.name.kind === 9 /* StringLiteral */ && (node.flags & 2 /* Ambient */ || ts.isDeclarationFile(file))) { + if (node.name.kind === 9 /* StringLiteral */ && (node.flags & 4 /* Ambient */ || ts.isDeclarationFile(file))) { // TypeScript 1.0 spec (April 2014): 12.1.6 // An AmbientExternalModuleDeclaration declares an external module. // This type of declaration is permitted only in the global module. @@ -37049,7 +37445,7 @@ var ts; diagnostic = ts.Diagnostics.File_0_has_unsupported_extension_The_only_supported_extensions_are_1; diagnosticArgument = [fileName, "'" + ts.supportedExtensions.join("', '") + "'"]; } - else if (!findSourceFile(fileName, ts.getNormalizedAbsolutePath(fileName, currentDirectory), isDefaultLib, 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]; } @@ -37059,13 +37455,13 @@ var ts; } } else { - var nonTsFile = options.allowNonTsExtensions && findSourceFile(fileName, ts.getNormalizedAbsolutePath(fileName, currentDirectory), isDefaultLib, 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(ts.supportedExtensions, function (extension) { return findSourceFile(fileName + extension, ts.getNormalizedAbsolutePath(fileName + extension, currentDirectory), isDefaultLib, refFile, refPos, refEnd); })) { + else if (!ts.forEach(ts.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]; @@ -37111,6 +37507,7 @@ var ts; }); filesByName.set(normalizedAbsolutePath, file); if (file) { + file.path = normalizedAbsolutePath; if (host.useCaseSensitiveFileNames()) { // for case-sensitive file systems check if we've already seen some file with similar filename ignoring case var existingFile = filesByNameIgnoreCase.get(normalizedAbsolutePath); @@ -37157,13 +37554,7 @@ var ts; var resolution = resolutions[i]; ts.setResolvedModule(file, moduleNames[i], resolution); if (resolution && !options.noResolve) { - var absoluteImportPath = ts.isRootedDiskPath(resolution.resolvedFileName) - ? resolution.resolvedFileName - : ts.getNormalizedAbsolutePath(resolution.resolvedFileName, currentDirectory); - // convert an absolute import path to path that is relative to current directory - // this was host still can locate it but files names in user output will be shorter (and thus look nicer). - var relativePath = ts.getRelativePathToDirectoryOrUrl(currentDirectory, absoluteImportPath, currentDirectory, getCanonicalFileName, false); - var importedFile = findSourceFile(relativePath, absoluteImportPath, /* isDefaultLib */ false, file, ts.skipTrivia(file.text, file.imports[i].pos), file.imports[i].end); + var importedFile = findSourceFile(resolution.resolvedFileName, ts.toPath(resolution.resolvedFileName, currentDirectory, getCanonicalFileName), /* isDefaultLib */ false, file, ts.skipTrivia(file.text, file.imports[i].pos), file.imports[i].end); if (importedFile && resolution.isExternalLibraryImport) { if (!ts.isExternalModule(importedFile)) { var start_2 = ts.getTokenPosOfNode(file.imports[i], file); @@ -37219,8 +37610,8 @@ var ts; var allFilesBelongToPath = true; if (sourceFiles) { var absoluteRootDirectoryPath = host.getCanonicalFileName(ts.getNormalizedAbsolutePath(rootDirectory, currentDirectory)); - for (var _i = 0; _i < sourceFiles.length; _i++) { - var sourceFile = sourceFiles[_i]; + for (var _i = 0, sourceFiles_1 = sourceFiles; _i < sourceFiles_1.length; _i++) { + var sourceFile = sourceFiles_1[_i]; if (!ts.isDeclarationFile(sourceFile)) { var absoluteSourceFilePath = host.getCanonicalFileName(ts.getNormalizedAbsolutePath(sourceFile.fileName, currentDirectory)); if (absoluteSourceFilePath.indexOf(absoluteRootDirectoryPath) !== 0) { @@ -37344,6 +37735,7 @@ var ts; /// /// /// +/// /// var ts; (function (ts) { @@ -37493,6 +37885,12 @@ var ts; type: "boolean", description: ts.Diagnostics.Do_not_erase_const_enum_declarations_in_generated_code }, + { + name: "pretty", + paramType: ts.Diagnostics.KIND, + description: ts.Diagnostics.Stylize_errors_and_messages_using_color_and_context_experimental, + type: "boolean" + }, { name: "project", shortName: "p", @@ -37591,11 +37989,31 @@ var ts; description: ts.Diagnostics.Specifies_module_resolution_strategy_Colon_node_Node_js_or_classic_TypeScript_pre_1_6, error: ts.Diagnostics.Argument_for_moduleResolution_option_must_be_node_or_classic }, + { + 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 - }, + } ]; var optionNameMapCache; /* @internal */ @@ -37734,13 +38152,38 @@ var ts; */ function parseConfigFileTextToJson(fileName, jsonText) { try { - return { config: /\S/.test(jsonText) ? JSON.parse(jsonText) : {} }; + var jsonTextWithoutComments = removeComments(jsonText); + return { config: /\S/.test(jsonTextWithoutComments) ? JSON.parse(jsonTextWithoutComments) : {} }; } catch (e) { return { error: ts.createCompilerDiagnostic(ts.Diagnostics.Failed_to_parse_file_0_Colon_1, fileName, e.message) }; } } ts.parseConfigFileTextToJson = parseConfigFileTextToJson; + /** + * Remove the comments from a json like text. + * Comments can be single line comments (starting with # or //) or multiline comments using / * * / + * + * This method replace comment content by whitespace rather than completely remove them to keep positions in json parsing error reporting accurate. + */ + function removeComments(jsonText) { + var output = ""; + var scanner = ts.createScanner(1 /* ES5 */, /* skipTrivia */ false, 0 /* Standard */, jsonText); + var token; + while ((token = scanner.scan()) !== 1 /* EndOfFileToken */) { + switch (token) { + case 2 /* SingleLineCommentTrivia */: + case 3 /* MultiLineCommentTrivia */: + // replace comments with whitespace to preserve original character positions + output += scanner.getTokenText().replace(/\S/g, " "); + break; + default: + output += scanner.getTokenText(); + break; + } + } + return output; + } /** * Parse the contents of a config file (tsconfig.json). * @param json The contents of the config file to parse @@ -37871,8 +38314,8 @@ var ts; var lastSingleLineCommentEnd = -1; var isFirstSingleLineComment = true; var singleLineCommentCount = 0; - for (var _i = 0; _i < comments.length; _i++) { - var currentComment = comments[_i]; + for (var _i = 0, comments_2 = comments; _i < comments_2.length; _i++) { + var currentComment = comments_2[_i]; // For single line comments, combine consecutive ones (2 or more) into // a single span from the start of the first till the end of the last if (currentComment.kind === 2 /* SingleLineCommentTrivia */) { @@ -38004,6 +38447,8 @@ var ts; function getNavigateToItems(program, cancellationToken, searchValue, maxResultCount) { 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(program.getSourceFiles(), function (sourceFile) { cancellationToken.throwIfCancellationRequested(); @@ -38017,8 +38462,8 @@ var ts; if (!matches) { continue; } - for (var _i = 0; _i < declarations.length; _i++) { - var declaration = declarations[_i]; + for (var _i = 0, declarations_6 = declarations; _i < declarations_6.length; _i++) { + var declaration = declarations_6[_i]; // It was a match! If the pattern has dots in it, then also see if the // declaration container matches as well. if (patternMatcher.patternContainsDots) { @@ -38047,8 +38492,8 @@ var ts; function allMatchesAreCaseSensitive(matches) { ts.Debug.assert(matches.length > 0); // This is a case sensitive match, only if all the submatches were case sensitive. - for (var _i = 0; _i < matches.length; _i++) { - var match = matches[_i]; + for (var _i = 0, matches_1 = matches; _i < matches_1.length; _i++) { + var match = matches_1[_i]; if (!match.isCaseSensitive) { return false; } @@ -38123,8 +38568,8 @@ var ts; function bestMatchKind(matches) { ts.Debug.assert(matches.length > 0); var bestMatchKind = ts.PatternMatchKind.camelCase; - for (var _i = 0; _i < matches.length; _i++) { - var match = matches[_i]; + for (var _i = 0, matches_2 = matches; _i < matches_2.length; _i++) { + var match = matches_2[_i]; var kind = match.kind; if (kind < bestMatchKind) { bestMatchKind = kind; @@ -38132,8 +38577,6 @@ var ts; } return bestMatchKind; } - // This means "compare in a case insensitive manner." - var baseSensitivity = { sensitivity: "base" }; function compareNavigateToItems(i1, i2) { // TODO(cyrusn): get the gamut of comparisons that VS already uses here. // Right now we just sort by kind first, and then by name of the item. @@ -38296,8 +38739,8 @@ var ts; } function addTopLevelNodes(nodes, topLevelNodes) { nodes = sortNodes(nodes); - for (var _i = 0; _i < nodes.length; _i++) { - var node = nodes[_i]; + for (var _i = 0, nodes_4 = nodes; _i < nodes_4.length; _i++) { + var node = nodes_4[_i]; switch (node.kind) { case 214 /* ClassDeclaration */: case 217 /* EnumDeclaration */: @@ -38340,8 +38783,8 @@ var ts; function getItemsWorker(nodes, createItem) { var items = []; var keyToItem = {}; - for (var _i = 0; _i < nodes.length; _i++) { - var child = nodes[_i]; + for (var _i = 0, nodes_5 = nodes; _i < nodes_5.length; _i++) { + var child = nodes_5[_i]; var item = createItem(child); if (item !== undefined) { if (item.text.length > 0) { @@ -38389,7 +38832,7 @@ var ts; if (ts.isBindingPattern(node.name)) { break; } - if ((node.flags & 2035 /* Modifier */) === 0) { + if ((node.flags & 1022 /* Modifier */) === 0) { return undefined; } return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberVariableElement); @@ -38693,8 +39136,8 @@ var ts; // word part. That way we don't match something like 'Class' when the user types 'a'. // But we would match 'FooAttribute' (since 'Attribute' starts with 'a'). var wordSpans = getWordSpans(candidate); - for (var _i = 0; _i < wordSpans.length; _i++) { - var span = wordSpans[_i]; + for (var _i = 0, wordSpans_1 = wordSpans; _i < wordSpans_1.length; _i++) { + var span = wordSpans_1[_i]; if (partStartsWith(candidate, span, chunk.text, /*ignoreCase:*/ true)) { return createPatternMatch(PatternMatchKind.substring, punctuationStripped, /*isCaseSensitive:*/ partStartsWith(candidate, span, chunk.text, /*ignoreCase:*/ false)); @@ -38800,8 +39243,8 @@ var ts; // Only if all words have some sort of match is the pattern considered matched. var subWordTextChunks = segment.subWordTextChunks; var matches = undefined; - for (var _i = 0; _i < subWordTextChunks.length; _i++) { - var subWordTextChunk = subWordTextChunks[_i]; + for (var _i = 0, subWordTextChunks_1 = subWordTextChunks; _i < subWordTextChunks_1.length; _i++) { + var subWordTextChunk = subWordTextChunks_1[_i]; // Try to match the candidate with this word var result = matchTextChunk(candidate, subWordTextChunk, /*punctuationStripped:*/ true); if (!result) { @@ -39386,8 +39829,8 @@ var ts; var nameToDeclarations = sourceFile_1.getNamedDeclarations(); var declarations = ts.getProperty(nameToDeclarations, name.text); if (declarations) { - for (var _b = 0; _b < declarations.length; _b++) { - var declaration = declarations[_b]; + for (var _b = 0, declarations_7 = declarations; _b < declarations_7.length; _b++) { + var declaration = declarations_7[_b]; var symbol = declaration.symbol; if (symbol) { var type = typeChecker.getTypeOfSymbolAtLocation(symbol, declaration); @@ -39503,8 +39946,8 @@ var ts; // arg index. var argumentIndex = 0; var listChildren = argumentsList.getChildren(); - for (var _i = 0; _i < listChildren.length; _i++) { - var child = listChildren[_i]; + for (var _i = 0, listChildren_1 = listChildren; _i < listChildren_1.length; _i++) { + var child = listChildren_1[_i]; if (child === node) { break; } @@ -40049,8 +40492,8 @@ var ts; return n; } var children = n.getChildren(); - for (var _i = 0; _i < children.length; _i++) { - var child = children[_i]; + for (var _i = 0, children_1 = children; _i < children_1.length; _i++) { + var child = children_1[_i]; var shouldDiveInChildNode = // previous token is enclosed somewhere in the child (child.pos <= previousToken.pos && child.end > previousToken.end) || @@ -40212,17 +40655,17 @@ var ts; function getNodeModifiers(node) { var flags = ts.getCombinedNodeFlags(node); var result = []; - if (flags & 32 /* Private */) + if (flags & 16 /* Private */) result.push(ts.ScriptElementKindModifier.privateMemberModifier); - if (flags & 64 /* Protected */) + if (flags & 32 /* Protected */) result.push(ts.ScriptElementKindModifier.protectedMemberModifier); - if (flags & 16 /* Public */) + if (flags & 8 /* Public */) result.push(ts.ScriptElementKindModifier.publicMemberModifier); - if (flags & 128 /* Static */) + if (flags & 64 /* Static */) result.push(ts.ScriptElementKindModifier.staticModifier); - if (flags & 256 /* Abstract */) + if (flags & 128 /* Abstract */) result.push(ts.ScriptElementKindModifier.abstractModifier); - if (flags & 1 /* Export */) + if (flags & 2 /* Export */) result.push(ts.ScriptElementKindModifier.exportedModifier); if (ts.isInAmbientContext(node)) result.push(ts.ScriptElementKindModifier.ambientModifier); @@ -42366,8 +42809,8 @@ var ts; } } var inheritedIndentation = -1 /* Unknown */; - for (var _i = 0; _i < nodes.length; _i++) { - var child = nodes[_i]; + for (var _i = 0, nodes_6 = nodes; _i < nodes_6.length; _i++) { + var child = nodes_6[_i]; inheritedIndentation = processChildNode(child, inheritedIndentation, node, listDynamicIndentation, startLine, startLine, /*isListElement*/ true); } if (listEndToken !== 0 /* Unknown */) { @@ -42458,8 +42901,8 @@ var ts; } } function processTrivia(trivia, parent, contextNode, dynamicIndentation) { - for (var _i = 0; _i < trivia.length; _i++) { - var triviaItem = trivia[_i]; + for (var _i = 0, trivia_1 = trivia; _i < trivia_1.length; _i++) { + var triviaItem = trivia_1[_i]; if (ts.isComment(triviaItem.kind) && ts.rangeContainsRange(originalRange, triviaItem)) { var triviaItemStart = sourceFile.getLineAndCharacterOfPosition(triviaItem.pos); processRange(triviaItem, triviaItemStart, parent, contextNode, dynamicIndentation); @@ -43056,7 +43499,6 @@ var ts; return node; } } - return node; } } function deriveActualIndentationFromList(list, index, sourceFile, options) { @@ -43307,17 +43749,17 @@ var ts; while (pos < end) { var token = scanner.scan(); var textPos = scanner.getTextPos(); - nodes.push(createNode(token, pos, textPos, 4096 /* Synthetic */, this)); + nodes.push(createNode(token, pos, textPos, 2048 /* Synthetic */, this)); pos = textPos; } return pos; }; NodeObject.prototype.createSyntaxList = function (nodes) { - var list = createNode(271 /* SyntaxList */, nodes.pos, nodes.end, 4096 /* Synthetic */, this); + var list = createNode(271 /* SyntaxList */, nodes.pos, nodes.end, 2048 /* Synthetic */, this); list._children = []; var pos = nodes.pos; - for (var _i = 0; _i < nodes.length; _i++) { - var node = nodes[_i]; + for (var _i = 0, nodes_7 = nodes; _i < nodes_7.length; _i++) { + var node = nodes_7[_i]; if (pos < node.pos) { pos = this.addSyntheticNodes(list._children, pos, node.pos); } @@ -43872,7 +44314,7 @@ var ts; break; case 138 /* Parameter */: // Only consider properties defined as constructor parameters - if (!(node.flags & 112 /* AccessibilityModifier */)) { + if (!(node.flags & 56 /* AccessibilityModifier */)) { break; } // fall through @@ -44148,13 +44590,15 @@ var ts; var HostCache = (function () { function HostCache(host, getCanonicalFileName) { this.host = host; + this.getCanonicalFileName = getCanonicalFileName; // script id => script index - this.fileNameToEntry = ts.createFileMap(getCanonicalFileName); + this.currentDirectory = host.getCurrentDirectory(); + this.fileNameToEntry = ts.createFileMap(); // Initialize the list with the root file names var rootFileNames = host.getScriptFileNames(); - for (var _i = 0; _i < rootFileNames.length; _i++) { - var fileName = rootFileNames[_i]; - this.createEntry(fileName); + for (var _i = 0, rootFileNames_1 = rootFileNames; _i < rootFileNames_1.length; _i++) { + var fileName = rootFileNames_1[_i]; + this.createEntry(fileName, ts.toPath(fileName, this.currentDirectory, getCanonicalFileName)); } // store the compilation settings this._compilationSettings = host.getCompilationSettings() || getDefaultCompilerOptions(); @@ -44162,7 +44606,7 @@ var ts; HostCache.prototype.compilationSettings = function () { return this._compilationSettings; }; - HostCache.prototype.createEntry = function (fileName) { + HostCache.prototype.createEntry = function (fileName, path) { var entry; var scriptSnapshot = this.host.getScriptSnapshot(fileName); if (scriptSnapshot) { @@ -44172,36 +44616,37 @@ var ts; scriptSnapshot: scriptSnapshot }; } - this.fileNameToEntry.set(fileName, entry); + this.fileNameToEntry.set(path, entry); return entry; }; - HostCache.prototype.getEntry = function (fileName) { - return this.fileNameToEntry.get(fileName); + HostCache.prototype.getEntry = function (path) { + return this.fileNameToEntry.get(path); }; - HostCache.prototype.contains = function (fileName) { - return this.fileNameToEntry.contains(fileName); + HostCache.prototype.contains = function (path) { + return this.fileNameToEntry.contains(path); }; HostCache.prototype.getOrCreateEntry = function (fileName) { - if (this.contains(fileName)) { - return this.getEntry(fileName); + var path = ts.toPath(fileName, this.currentDirectory, this.getCanonicalFileName); + if (this.contains(path)) { + return this.getEntry(path); } - return this.createEntry(fileName); + return this.createEntry(fileName, path); }; HostCache.prototype.getRootFileNames = function () { var fileNames = []; - this.fileNameToEntry.forEachValue(function (value) { + this.fileNameToEntry.forEachValue(function (path, value) { if (value) { fileNames.push(value.hostFileName); } }); return fileNames; }; - HostCache.prototype.getVersion = function (fileName) { - var file = this.getEntry(fileName); + HostCache.prototype.getVersion = function (path) { + var file = this.getEntry(path); return file && file.version; }; - HostCache.prototype.getScriptSnapshot = function (fileName) { - var file = this.getEntry(fileName); + HostCache.prototype.getScriptSnapshot = function (path) { + var file = this.getEntry(path); return file && file.scriptSnapshot; }; return HostCache; @@ -44383,7 +44828,8 @@ var ts; : (function (fileName) { return fileName.toLowerCase(); }); } ts.createGetCanonicalFileName = createGetCanonicalFileName; - function createDocumentRegistry(useCaseSensitiveFileNames) { + function createDocumentRegistry(useCaseSensitiveFileNames, currentDirectory) { + if (currentDirectory === void 0) { currentDirectory = ""; } // Maps from compiler setting target (ES3, ES5, etc.) to all the cached documents we have // for those settings. var buckets = {}; @@ -44395,7 +44841,7 @@ var ts; var key = getKeyFromCompilationSettings(settings); var bucket = ts.lookUp(buckets, key); if (!bucket && createIfMissing) { - buckets[key] = bucket = ts.createFileMap(getCanonicalFileName); + buckets[key] = bucket = ts.createFileMap(); } return bucket; } @@ -44403,14 +44849,13 @@ var ts; var bucketInfoArray = Object.keys(buckets).filter(function (name) { return name && name.charAt(0) === '_'; }).map(function (name) { var entries = ts.lookUp(buckets, name); var sourceFiles = []; - for (var i in entries) { - var entry = entries.get(i); + entries.forEachValue(function (key, entry) { sourceFiles.push({ - name: i, + name: key, refCount: entry.languageServiceRefCount, references: entry.owners.slice(0) }); - } + }); sourceFiles.sort(function (x, y) { return y.refCount - x.refCount; }); return { bucket: name, @@ -44427,7 +44872,8 @@ var ts; } function acquireOrUpdateDocument(fileName, compilationSettings, scriptSnapshot, version, acquiring) { var bucket = getBucketForCompilationSettings(compilationSettings, /*createIfMissing*/ true); - var entry = bucket.get(fileName); + var path = ts.toPath(fileName, currentDirectory, getCanonicalFileName); + var entry = bucket.get(path); if (!entry) { ts.Debug.assert(acquiring, "How could we be trying to update a document that the registry doesn't have?"); // Have never seen this file with these settings. Create a new source file for it. @@ -44437,7 +44883,7 @@ var ts; languageServiceRefCount: 0, owners: [] }; - bucket.set(fileName, entry); + bucket.set(path, entry); } else { // We have an entry for this file. However, it may be for a different version of @@ -44460,11 +44906,12 @@ var ts; function releaseDocument(fileName, compilationSettings) { var bucket = getBucketForCompilationSettings(compilationSettings, false); ts.Debug.assert(bucket !== undefined); - var entry = bucket.get(fileName); + var path = ts.toPath(fileName, currentDirectory, getCanonicalFileName); + var entry = bucket.get(path); entry.languageServiceRefCount--; ts.Debug.assert(entry.languageServiceRefCount >= 0); if (entry.languageServiceRefCount === 0) { - bucket.remove(fileName); + bucket.remove(path); } } return { @@ -44871,7 +45318,7 @@ var ts; case 144 /* Constructor */: return ScriptElementKind.constructorImplementationElement; case 137 /* TypeParameter */: return ScriptElementKind.typeParameterElement; case 247 /* EnumMember */: return ScriptElementKind.variableElement; - case 138 /* Parameter */: return (node.flags & 112 /* AccessibilityModifier */) ? ScriptElementKind.memberVariableElement : ScriptElementKind.parameterElement; + case 138 /* Parameter */: return (node.flags & 56 /* AccessibilityModifier */) ? ScriptElementKind.memberVariableElement : ScriptElementKind.parameterElement; case 221 /* ImportEqualsDeclaration */: case 226 /* ImportSpecifier */: case 223 /* ImportClause */: @@ -44897,13 +45344,14 @@ var ts; return CancellationTokenObject; })(); function createLanguageService(host, documentRegistry) { - if (documentRegistry === void 0) { documentRegistry = createDocumentRegistry(); } + if (documentRegistry === void 0) { documentRegistry = createDocumentRegistry(host.useCaseSensitiveFileNames && host.useCaseSensitiveFileNames(), host.getCurrentDirectory()); } var syntaxTreeCache = new SyntaxTreeCache(host); var ruleProvider; var program; var lastProjectVersion; var useCaseSensitivefileNames = false; 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 if (!ts.localizedDiagnosticMessages && host.getLocalizedDiagnosticMessages) { ts.localizedDiagnosticMessages = host.getLocalizedDiagnosticMessages(); @@ -44915,8 +45363,7 @@ var ts; } var getCanonicalFileName = createGetCanonicalFileName(useCaseSensitivefileNames); function getValidSourceFile(fileName) { - fileName = ts.normalizeSlashes(fileName); - var sourceFile = program.getSourceFile(getCanonicalFileName(fileName)); + var sourceFile = program.getSourceFile(fileName); if (!sourceFile) { throw new Error("Could not find file: '" + fileName + "'."); } @@ -44968,7 +45415,7 @@ var ts; getNewLine: function () { return ts.getNewLineOrDefaultFromHost(host); }, getDefaultLibFileName: function (options) { return host.getDefaultLibFileName(options); }, writeFile: function (fileName, data, writeByteOrderMark) { }, - getCurrentDirectory: function () { return host.getCurrentDirectory(); }, + getCurrentDirectory: function () { return currentDirectory; }, fileExists: function (fileName) { // stub missing host functionality ts.Debug.assert(!host.resolveModuleNames); @@ -44988,11 +45435,10 @@ var ts; // not part of the new program. if (program) { var oldSourceFiles = program.getSourceFiles(); - for (var _i = 0; _i < oldSourceFiles.length; _i++) { - var oldSourceFile = oldSourceFiles[_i]; - var fileName = oldSourceFile.fileName; - if (!newProgram.getSourceFile(fileName) || changesInCompilationSettingsAffectSyntax) { - documentRegistry.releaseDocument(fileName, oldSettings); + for (var _i = 0, oldSourceFiles_1 = oldSourceFiles; _i < oldSourceFiles_1.length; _i++) { + var oldSourceFile = oldSourceFiles_1[_i]; + if (!newProgram.getSourceFile(oldSourceFile.fileName) || changesInCompilationSettingsAffectSyntax) { + documentRegistry.releaseDocument(oldSourceFile.fileName, oldSettings); } } } @@ -45048,7 +45494,8 @@ var ts; return documentRegistry.acquireDocument(fileName, newSettings, hostFileInformation.scriptSnapshot, hostFileInformation.version); } function sourceFileUpToDate(sourceFile) { - return sourceFile && sourceFile.version === hostCache.getVersion(sourceFile.fileName); + var path = sourceFile.path || ts.toPath(sourceFile.fileName, currentDirectory, getCanonicalFileName); + return sourceFile && sourceFile.version === hostCache.getVersion(path); } function programUpToDate() { // If we haven't create a program yet, then it is not up-to-date @@ -45061,8 +45508,8 @@ var ts; return false; } // If any file is not up-to-date, then the whole program is not up-to-date - for (var _i = 0; _i < rootFileNames.length; _i++) { - var fileName = rootFileNames[_i]; + for (var _i = 0, rootFileNames_2 = rootFileNames; _i < rootFileNames_2.length; _i++) { + var fileName = rootFileNames_2[_i]; if (!sourceFileUpToDate(program.getSourceFile(fileName))) { return false; } @@ -45237,8 +45684,8 @@ var ts; } function checkModifiers(modifiers) { if (modifiers) { - for (var _i = 0; _i < modifiers.length; _i++) { - var modifier = modifiers[_i]; + 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 */: @@ -45940,8 +46387,8 @@ var ts; */ function filterNamedImportOrExportCompletionItems(exportsOfModule, namedImportsOrExports) { var exisingImportsOrExports = {}; - for (var _i = 0; _i < namedImportsOrExports.length; _i++) { - var element = namedImportsOrExports[_i]; + for (var _i = 0, namedImportsOrExports_1 = namedImportsOrExports; _i < namedImportsOrExports_1.length; _i++) { + var element = namedImportsOrExports_1[_i]; // If this is the current item we are editing right now, do not filter it out if (element.getStart() <= position && position <= element.getEnd()) { continue; @@ -45965,8 +46412,8 @@ var ts; return contextualMemberSymbols; } var existingMemberNames = {}; - for (var _i = 0; _i < existingMembers.length; _i++) { - var m = existingMembers[_i]; + for (var _i = 0, existingMembers_1 = existingMembers; _i < existingMembers_1.length; _i++) { + var m = existingMembers_1[_i]; // Ignore omitted expressions for missing members if (m.kind !== 245 /* PropertyAssignment */ && m.kind !== 246 /* ShorthandPropertyAssignment */ && @@ -45999,8 +46446,8 @@ var ts; */ function filterJsxAttributes(symbols, attributes) { var seenNames = {}; - for (var _i = 0; _i < attributes.length; _i++) { - var attr = attributes[_i]; + for (var _i = 0, attributes_1 = attributes; _i < attributes_1.length; _i++) { + var attr = attributes_1[_i]; // If this is the current item we are editing right now, do not filter it out if (attr.getStart() <= position && position <= attr.getEnd()) { continue; @@ -46101,8 +46548,8 @@ var ts; var entries = []; if (symbols) { var nameToSymbol = {}; - for (var _i = 0; _i < symbols.length; _i++) { - var symbol = symbols[_i]; + for (var _i = 0, symbols_3 = symbols; _i < symbols_3.length; _i++) { + var symbol = symbols_3[_i]; var entry = createCompletionEntry(symbol, location); if (entry) { var id = ts.escapeIdentifier(entry.name); @@ -46844,8 +47291,8 @@ var ts; } var fileNameToDocumentHighlights = {}; var result = []; - for (var _i = 0; _i < referencedSymbols.length; _i++) { - var referencedSymbol = referencedSymbols[_i]; + for (var _i = 0, referencedSymbols_1 = referencedSymbols; _i < referencedSymbols_1.length; _i++) { + var referencedSymbol = referencedSymbols_1[_i]; for (var _a = 0, _b = referencedSymbol.references; _a < _b.length; _a++) { var referenceEntry = _b[_a]; var fileName_1 = referenceEntry.fileName; @@ -46989,7 +47436,6 @@ var ts; ts.forEachChild(node, aggregate); } } - ; } /** * For lack of a better name, this function takes a throw statement and returns the @@ -47027,7 +47473,6 @@ var ts; ts.forEachChild(node, aggregate); } } - ; } function ownsBreakOrContinueStatement(owner, statement) { var actualOwner = getBreakOrContinueOwner(statement); @@ -47096,7 +47541,7 @@ var ts; case 219 /* ModuleBlock */: case 248 /* SourceFile */: // Container is either a class declaration or the declaration is a classDeclaration - if (modifierFlag & 256 /* Abstract */) { + if (modifierFlag & 128 /* Abstract */) { nodes = declaration.members.concat(declaration); } else { @@ -47111,7 +47556,7 @@ var ts; nodes = container.members; // If we're an accessibility modifier, we're in an instance member and should search // the constructor's parameter list for instance members as well. - if (modifierFlag & 112 /* AccessibilityModifier */) { + if (modifierFlag & 56 /* AccessibilityModifier */) { var constructor = ts.forEach(container.members, function (member) { return member.kind === 144 /* Constructor */ && member; }); @@ -47119,7 +47564,7 @@ var ts; nodes = nodes.concat(constructor.parameters); } } - else if (modifierFlag & 256 /* Abstract */) { + else if (modifierFlag & 128 /* Abstract */) { nodes = nodes.concat(container); } break; @@ -47135,19 +47580,19 @@ var ts; function getFlagFromModifier(modifier) { switch (modifier) { case 112 /* PublicKeyword */: - return 16 /* Public */; + return 8 /* Public */; case 110 /* PrivateKeyword */: - return 32 /* Private */; + return 16 /* Private */; case 111 /* ProtectedKeyword */: - return 64 /* Protected */; + return 32 /* Protected */; case 113 /* StaticKeyword */: - return 128 /* Static */; + return 64 /* Static */; case 82 /* ExportKeyword */: - return 1 /* Export */; + return 2 /* Export */; case 122 /* DeclareKeyword */: - return 2 /* Ambient */; + return 4 /* Ambient */; case 115 /* AbstractKeyword */: - return 256 /* Abstract */; + return 128 /* Abstract */; default: ts.Debug.fail(); } @@ -47346,8 +47791,8 @@ var ts; return undefined; } var result = []; - for (var _i = 0; _i < documentHighlights.length; _i++) { - var entry = documentHighlights[_i]; + for (var _i = 0, documentHighlights_1 = documentHighlights; _i < documentHighlights_1.length; _i++) { + var entry = documentHighlights_1[_i]; for (var _a = 0, _b = entry.highlightSpans; _a < _b.length; _a++) { var highlightSpan = _b[_a]; result.push({ @@ -47365,8 +47810,8 @@ var ts; return undefined; } var referenceEntries = []; - for (var _i = 0; _i < referenceSymbols.length; _i++) { - var referenceSymbol = referenceSymbols[_i]; + for (var _i = 0, referenceSymbols_1 = referenceSymbols; _i < referenceSymbols_1.length; _i++) { + var referenceSymbol = referenceSymbols_1[_i]; ts.addRange(referenceEntries, referenceSymbol.references); } return referenceEntries; @@ -47451,8 +47896,8 @@ var ts; } else { var internedName = getInternedName(symbol, node, declarations); - for (var _i = 0; _i < sourceFiles.length; _i++) { - var sourceFile = sourceFiles[_i]; + for (var _i = 0, sourceFiles_2 = sourceFiles; _i < sourceFiles_2.length; _i++) { + var sourceFile = sourceFiles_2[_i]; cancellationToken.throwIfCancellationRequested(); var nameTable = getNameTable(sourceFile); if (ts.lookUp(nameTable, internedName)) { @@ -47512,7 +47957,7 @@ var ts; } // If this is private property or method, the scope is the containing class if (symbol.flags & (4 /* Property */ | 8192 /* Method */)) { - var privateDeclaration = ts.forEach(symbol.getDeclarations(), function (d) { return (d.flags & 32 /* Private */) ? d : undefined; }); + var privateDeclaration = ts.forEach(symbol.getDeclarations(), function (d) { return (d.flags & 16 /* Private */) ? d : undefined; }); if (privateDeclaration) { return ts.getAncestor(privateDeclaration, 214 /* ClassDeclaration */); } @@ -47530,8 +47975,8 @@ var ts; var scope = undefined; var declarations = symbol.getDeclarations(); if (declarations) { - for (var _i = 0; _i < declarations.length; _i++) { - var declaration = declarations[_i]; + for (var _i = 0, declarations_8 = declarations; _i < declarations_8.length; _i++) { + var declaration = declarations_8[_i]; var container = getContainerNode(declaration); if (!container) { return undefined; @@ -47711,7 +48156,7 @@ var ts; return undefined; } // Whether 'super' occurs in a static context within a class. - var staticFlag = 128 /* Static */; + var staticFlag = 64 /* Static */; switch (searchSpaceNode.kind) { case 141 /* PropertyDeclaration */: case 140 /* PropertySignature */: @@ -47739,7 +48184,7 @@ var ts; // If we have a 'super' container, we must have an enclosing class. // Now make sure the owning class is the same as the search-space // and has the same static qualifier as the original 'super's owner. - if (container && (128 /* Static */ & container.flags) === staticFlag && container.parent.symbol === searchSpaceNode.symbol) { + if (container && (64 /* Static */ & container.flags) === staticFlag && container.parent.symbol === searchSpaceNode.symbol) { references.push(getReferenceEntryFromNode(node)); } }); @@ -47749,7 +48194,7 @@ var ts; function getReferencesForThisKeyword(thisOrSuperKeyword, sourceFiles) { var searchSpaceNode = ts.getThisContainer(thisOrSuperKeyword, /* includeArrowFunctions */ false); // Whether 'this' occurs in a static context within a class. - var staticFlag = 128 /* Static */; + var staticFlag = 64 /* Static */; switch (searchSpaceNode.kind) { case 143 /* MethodDeclaration */: case 142 /* MethodSignature */: @@ -47827,7 +48272,7 @@ var ts; case 214 /* ClassDeclaration */: // Make sure the container belongs to the same class // and has the appropriate static modifier from the original container. - if (container.parent && searchSpaceNode.symbol === container.parent.symbol && (container.flags & 128 /* Static */) === staticFlag) { + if (container.parent && searchSpaceNode.symbol === container.parent.symbol && (container.flags & 64 /* Static */) === staticFlag) { result.push(getReferenceEntryFromNode(node)); } break; @@ -47998,8 +48443,8 @@ var ts; // To achieve that we will keep iterating until the result stabilizes. // Remember the last meaning lastIterationMeaning = meaning; - for (var _i = 0; _i < declarations.length; _i++) { - var declaration = declarations[_i]; + for (var _i = 0, declarations_9 = declarations; _i < declarations_9.length; _i++) { + var declaration = declarations_9[_i]; var declarationMeaning = getMeaningFromDeclaration(declaration); if (declarationMeaning & meaning) { meaning |= declarationMeaning; @@ -48115,7 +48560,6 @@ var ts; return 4 /* Namespace */ | 1 /* Value */; } return 1 /* Value */ | 2 /* Type */ | 4 /* Namespace */; - ts.Debug.fail("Unknown declaration type"); } function isTypeReference(node) { if (ts.isRightSideOfQualifiedNameOrPropertyAccess(node)) { @@ -48694,8 +49138,8 @@ var ts; if (matchKind) { var parentElement = token.parent; var childNodes = parentElement.getChildren(sourceFile); - for (var _i = 0; _i < childNodes.length; _i++) { - var current = childNodes[_i]; + for (var _i = 0, childNodes_1 = childNodes; _i < childNodes_1.length; _i++) { + var current = childNodes_1[_i]; if (current.kind === matchKind) { var range1 = ts.createTextSpan(token.getStart(sourceFile), token.getWidth(sourceFile)); var range2 = ts.createTextSpan(current.getStart(sourceFile), current.getWidth(sourceFile)); @@ -49025,8 +49469,8 @@ var ts; // Disallow rename for elements that are defined in the standard TypeScript library. var defaultLibFileName = host.getDefaultLibFileName(host.getCompilationSettings()); if (defaultLibFileName) { - for (var _i = 0; _i < declarations.length; _i++) { - var current = declarations[_i]; + for (var _i = 0, declarations_10 = declarations; _i < declarations_10.length; _i++) { + var current = declarations_10[_i]; var sourceFile_2 = current.getSourceFile(); var canonicalName = getCanonicalFileName(ts.normalizePath(sourceFile_2.fileName)); if (sourceFile_2 && getCanonicalFileName(ts.normalizePath(sourceFile_2.fileName)) === getCanonicalFileName(ts.normalizePath(defaultLibFileName))) { @@ -49609,7 +50053,7 @@ var ts; */ function spanInSourceFileAtLocation(sourceFile, position) { // Cannot set breakpoint in dts file - if (sourceFile.flags & 8192 /* DeclarationFile */) { + if (sourceFile.flags & 4096 /* DeclarationFile */) { return undefined; } var tokenAtLocation = ts.getTokenAtPosition(sourceFile, position); @@ -49827,7 +50271,7 @@ var ts; ? variableDeclaration.parent.parent.initializer.declarations : undefined; // Breakpoint is possible in variableDeclaration only if there is initialization - if (variableDeclaration.initializer || (variableDeclaration.flags & 1 /* Export */)) { + if (variableDeclaration.initializer || (variableDeclaration.flags & 2 /* Export */)) { if (declarations && declarations[0] === variableDeclaration) { if (isParentVariableStatement) { // First declaration - include let keyword @@ -49853,7 +50297,7 @@ var ts; function canHaveSpanInParameterDeclaration(parameter) { // Breakpoint is possible on parameter only if it has initializer, is a rest parameter, or has public or private modifier return !!parameter.initializer || parameter.dotDotDotToken !== undefined || - !!(parameter.flags & 16 /* Public */) || !!(parameter.flags & 32 /* Private */); + !!(parameter.flags & 8 /* Public */) || !!(parameter.flags & 16 /* Private */); } function spanInParameterDeclaration(parameter) { if (canHaveSpanInParameterDeclaration(parameter)) { @@ -49873,7 +50317,7 @@ var ts; } } function canFunctionHaveSpanInWholeDeclaration(functionDeclaration) { - return !!(functionDeclaration.flags & 1 /* Export */) || + return !!(functionDeclaration.flags & 2 /* Export */) || (functionDeclaration.parent.kind === 214 /* ClassDeclaration */ && functionDeclaration.kind !== 144 /* Constructor */); } function spanInFunctionDeclaration(functionDeclaration) { @@ -49967,7 +50411,6 @@ var ts; // fall through. case 244 /* CatchClause */: return spanInNode(ts.lastOrUndefined(node.parent.statements)); - ; case 220 /* CaseBlock */: // breakpoint in last statement of the last clause var caseBlock = node.parent; @@ -50008,8 +50451,6 @@ var ts; default: return spanInNode(node.parent); } - // Default to parent node - return spanInNode(node.parent); } function spanInColonToken(node) { // Is this : specifying return annotation of the function declaration @@ -50138,7 +50579,6 @@ var ts; // TODO: should this be '==='? if (settingsJson == null || settingsJson == "") { throw Error("LanguageServiceShimHostAdapter.getCompilationSettings: empty compilationSettings"); - return null; } return JSON.parse(settingsJson); }; diff --git a/lib/typescriptServices.d.ts b/lib/typescriptServices.d.ts index badaff1c3e2..d2758e6d5e9 100644 --- a/lib/typescriptServices.d.ts +++ b/lib/typescriptServices.d.ts @@ -17,19 +17,22 @@ declare namespace ts { interface Map { [index: string]: T; } + type Path = string & { + __pathBrand: any; + }; interface FileMap { - get(fileName: string): T; - set(fileName: string, value: T): void; - contains(fileName: string): boolean; - remove(fileName: string): void; - forEachValue(f: (v: T) => void): void; + get(fileName: Path): T; + set(fileName: Path, value: T): void; + contains(fileName: Path): boolean; + remove(fileName: Path): void; + forEachValue(f: (key: Path, v: T) => void): void; clear(): void; } interface TextRange { pos: number; end: number; } - const enum SyntaxKind { + enum SyntaxKind { Unknown = 0, EndOfFileToken = 1, SingleLineCommentTrivia = 2, @@ -327,31 +330,34 @@ declare namespace ts { LastBinaryOperator = 68, FirstNode = 135, } - const enum NodeFlags { + enum NodeFlags { None = 0, - Export = 1, - Ambient = 2, - Public = 16, - Private = 32, - Protected = 64, - Static = 128, - Abstract = 256, - Async = 512, - Default = 1024, - MultiLine = 2048, - Synthetic = 4096, - DeclarationFile = 8192, - Let = 16384, - Const = 32768, - OctalLiteral = 65536, - Namespace = 131072, - ExportContext = 262144, - ContainsThis = 524288, - Modifier = 2035, - AccessibilityModifier = 112, - BlockScoped = 49152, + Export = 2, + Ambient = 4, + Public = 8, + Private = 16, + Protected = 32, + Static = 64, + Abstract = 128, + Async = 256, + Default = 512, + MultiLine = 1024, + Synthetic = 2048, + DeclarationFile = 4096, + Let = 8192, + Const = 16384, + OctalLiteral = 32768, + Namespace = 65536, + ExportContext = 131072, + ContainsThis = 262144, + HasImplicitReturn = 524288, + HasExplicitReturn = 1048576, + Modifier = 1022, + AccessibilityModifier = 56, + BlockScoped = 24576, + ReachabilityCheckFlags = 1572864, } - const enum JsxFlags { + enum JsxFlags { None = 0, IntrinsicNamedElement = 1, IntrinsicIndexedElement = 2, @@ -931,6 +937,7 @@ declare namespace ts { statements: NodeArray; endOfFileToken: Node; fileName: string; + path: Path; text: string; amdDependencies: { path: string; @@ -1093,7 +1100,7 @@ declare namespace ts { trackSymbol(symbol: Symbol, enclosingDeclaration?: Node, meaning?: SymbolFlags): void; reportInaccessibleThisError(): void; } - const enum TypeFormatFlags { + enum TypeFormatFlags { None = 0, WriteArrayAsGenericType = 1, UseTypeOfFunction = 2, @@ -1104,7 +1111,7 @@ declare namespace ts { InElementType = 64, UseFullyQualifiedType = 128, } - const enum SymbolFormatFlags { + enum SymbolFormatFlags { None = 0, WriteTypeParametersOrArguments = 1, UseOnlyExternalAliasing = 2, @@ -1114,7 +1121,7 @@ declare namespace ts { parameterIndex: number; type: Type; } - const enum SymbolFlags { + enum SymbolFlags { None = 0, FunctionScopedVariable = 1, BlockScopedVariable = 2, @@ -1191,7 +1198,7 @@ declare namespace ts { interface SymbolTable { [index: string]: Symbol; } - const enum TypeFlags { + enum TypeFlags { Any = 1, String = 2, Number = 4, @@ -1262,7 +1269,7 @@ declare namespace ts { interface TypeParameter extends Type { constraint: Type; } - const enum SignatureKind { + enum SignatureKind { Call = 0, Construct = 1, } @@ -1272,7 +1279,7 @@ declare namespace ts { parameters: Symbol[]; typePredicate?: TypePredicate; } - const enum IndexKind { + enum IndexKind { String = 0, Number = 1, } @@ -1307,7 +1314,7 @@ declare namespace ts { Error = 1, Message = 2, } - const enum ModuleResolutionKind { + enum ModuleResolutionKind { Classic = 1, NodeJs = 2, } @@ -1352,10 +1359,14 @@ declare namespace ts { experimentalDecorators?: boolean; emitDecoratorMetadata?: boolean; moduleResolution?: ModuleResolutionKind; + allowUnusedLabels?: boolean; + allowUnreachableCode?: boolean; + noImplicitReturns?: boolean; + noFallthroughCasesInSwitch?: boolean; forceConsistentCasingInFileNames?: boolean; [option: string]: string | number | boolean; } - const enum ModuleKind { + enum ModuleKind { None = 0, CommonJS = 1, AMD = 2, @@ -1364,12 +1375,12 @@ declare namespace ts { ES6 = 5, ES2015 = 5, } - const enum JsxEmit { + enum JsxEmit { None = 0, Preserve = 1, React = 2, } - const enum NewLineKind { + enum NewLineKind { CarriageReturnLineFeed = 0, LineFeed = 1, } @@ -1377,14 +1388,14 @@ declare namespace ts { line: number; character: number; } - const enum ScriptTarget { + enum ScriptTarget { ES3 = 0, ES5 = 1, ES6 = 2, ES2015 = 2, Latest = 2, } - const enum LanguageVariant { + enum LanguageVariant { Standard = 0, JSX = 1, } @@ -1938,7 +1949,7 @@ declare namespace ts { outputFiles: OutputFile[]; emitSkipped: boolean; } - const enum OutputFileType { + enum OutputFileType { JavaScript = 0, SourceMap = 1, Declaration = 2, @@ -1948,7 +1959,7 @@ declare namespace ts { writeByteOrderMark: boolean; text: string; } - const enum EndOfLineState { + enum EndOfLineState { None = 0, InMultiLineCommentTrivia = 1, InSingleQuoteStringLiteral = 2, @@ -2116,7 +2127,7 @@ declare namespace ts { static parameterName: string; static docCommentTagName: string; } - const enum ClassificationType { + enum ClassificationType { comment = 1, identifier = 2, keyword = 3, @@ -2159,7 +2170,7 @@ declare namespace ts { let disableIncrementalParsing: boolean; function updateLanguageServiceSourceFile(sourceFile: SourceFile, scriptSnapshot: IScriptSnapshot, version: string, textChangeRange: TextChangeRange, aggressiveChecks?: boolean): SourceFile; function createGetCanonicalFileName(useCaseSensitivefileNames: boolean): (fileName: string) => string; - function createDocumentRegistry(useCaseSensitiveFileNames?: boolean): DocumentRegistry; + function createDocumentRegistry(useCaseSensitiveFileNames?: boolean, currentDirectory?: string): DocumentRegistry; function preProcessFile(sourceText: string, readImportFiles?: boolean): PreProcessedFileInfo; function createLanguageService(host: LanguageServiceHost, documentRegistry?: DocumentRegistry): LanguageService; function createClassifier(): Classifier; diff --git a/lib/typescriptServices.js b/lib/typescriptServices.js index 1e0c0edad05..8b0ef04f96e 100644 --- a/lib/typescriptServices.js +++ b/lib/typescriptServices.js @@ -350,27 +350,30 @@ var ts; var SyntaxKind = ts.SyntaxKind; (function (NodeFlags) { NodeFlags[NodeFlags["None"] = 0] = "None"; - NodeFlags[NodeFlags["Export"] = 1] = "Export"; - NodeFlags[NodeFlags["Ambient"] = 2] = "Ambient"; - NodeFlags[NodeFlags["Public"] = 16] = "Public"; - NodeFlags[NodeFlags["Private"] = 32] = "Private"; - NodeFlags[NodeFlags["Protected"] = 64] = "Protected"; - NodeFlags[NodeFlags["Static"] = 128] = "Static"; - NodeFlags[NodeFlags["Abstract"] = 256] = "Abstract"; - NodeFlags[NodeFlags["Async"] = 512] = "Async"; - NodeFlags[NodeFlags["Default"] = 1024] = "Default"; - NodeFlags[NodeFlags["MultiLine"] = 2048] = "MultiLine"; - NodeFlags[NodeFlags["Synthetic"] = 4096] = "Synthetic"; - NodeFlags[NodeFlags["DeclarationFile"] = 8192] = "DeclarationFile"; - NodeFlags[NodeFlags["Let"] = 16384] = "Let"; - NodeFlags[NodeFlags["Const"] = 32768] = "Const"; - NodeFlags[NodeFlags["OctalLiteral"] = 65536] = "OctalLiteral"; - NodeFlags[NodeFlags["Namespace"] = 131072] = "Namespace"; - NodeFlags[NodeFlags["ExportContext"] = 262144] = "ExportContext"; - NodeFlags[NodeFlags["ContainsThis"] = 524288] = "ContainsThis"; - NodeFlags[NodeFlags["Modifier"] = 2035] = "Modifier"; - NodeFlags[NodeFlags["AccessibilityModifier"] = 112] = "AccessibilityModifier"; - NodeFlags[NodeFlags["BlockScoped"] = 49152] = "BlockScoped"; + NodeFlags[NodeFlags["Export"] = 2] = "Export"; + NodeFlags[NodeFlags["Ambient"] = 4] = "Ambient"; + NodeFlags[NodeFlags["Public"] = 8] = "Public"; + NodeFlags[NodeFlags["Private"] = 16] = "Private"; + NodeFlags[NodeFlags["Protected"] = 32] = "Protected"; + NodeFlags[NodeFlags["Static"] = 64] = "Static"; + NodeFlags[NodeFlags["Abstract"] = 128] = "Abstract"; + NodeFlags[NodeFlags["Async"] = 256] = "Async"; + NodeFlags[NodeFlags["Default"] = 512] = "Default"; + NodeFlags[NodeFlags["MultiLine"] = 1024] = "MultiLine"; + NodeFlags[NodeFlags["Synthetic"] = 2048] = "Synthetic"; + NodeFlags[NodeFlags["DeclarationFile"] = 4096] = "DeclarationFile"; + NodeFlags[NodeFlags["Let"] = 8192] = "Let"; + NodeFlags[NodeFlags["Const"] = 16384] = "Const"; + NodeFlags[NodeFlags["OctalLiteral"] = 32768] = "OctalLiteral"; + NodeFlags[NodeFlags["Namespace"] = 65536] = "Namespace"; + NodeFlags[NodeFlags["ExportContext"] = 131072] = "ExportContext"; + NodeFlags[NodeFlags["ContainsThis"] = 262144] = "ContainsThis"; + NodeFlags[NodeFlags["HasImplicitReturn"] = 524288] = "HasImplicitReturn"; + NodeFlags[NodeFlags["HasExplicitReturn"] = 1048576] = "HasExplicitReturn"; + NodeFlags[NodeFlags["Modifier"] = 1022] = "Modifier"; + NodeFlags[NodeFlags["AccessibilityModifier"] = 56] = "AccessibilityModifier"; + NodeFlags[NodeFlags["BlockScoped"] = 24576] = "BlockScoped"; + NodeFlags[NodeFlags["ReachabilityCheckFlags"] = 1572864] = "ReachabilityCheckFlags"; })(ts.NodeFlags || (ts.NodeFlags = {})); var NodeFlags = ts.NodeFlags; /* @internal */ @@ -690,6 +693,12 @@ var ts; })(ts.LanguageVariant || (ts.LanguageVariant = {})); var LanguageVariant = ts.LanguageVariant; /* @internal */ + (function (DiagnosticStyle) { + DiagnosticStyle[DiagnosticStyle["Simple"] = 0] = "Simple"; + DiagnosticStyle[DiagnosticStyle["Pretty"] = 1] = "Pretty"; + })(ts.DiagnosticStyle || (ts.DiagnosticStyle = {})); + var DiagnosticStyle = ts.DiagnosticStyle; + /* @internal */ (function (CharacterCodes) { CharacterCodes[CharacterCodes["nullCharacter"] = 0] = "nullCharacter"; CharacterCodes[CharacterCodes["maxAsciiCharacter"] = 127] = "maxAsciiCharacter"; @@ -838,40 +847,50 @@ var ts; Ternary[Ternary["True"] = -1] = "True"; })(ts.Ternary || (ts.Ternary = {})); var Ternary = ts.Ternary; - function createFileMap(getCanonicalFileName) { + function createFileMap(keyMapper) { var files = {}; return { get: get, set: set, contains: contains, remove: remove, - clear: clear, - forEachValue: forEachValueInMap + forEachValue: forEachValueInMap, + clear: clear }; - function set(fileName, value) { - files[normalizeKey(fileName)] = value; - } - function get(fileName) { - return files[normalizeKey(fileName)]; - } - function contains(fileName) { - return hasProperty(files, normalizeKey(fileName)); - } - function remove(fileName) { - var key = normalizeKey(fileName); - delete files[key]; - } function forEachValueInMap(f) { - forEachValue(files, f); + for (var key in files) { + f(key, files[key]); + } } - function normalizeKey(key) { - return getCanonicalFileName(normalizeSlashes(key)); + // path should already be well-formed so it does not need to be normalized + function get(path) { + return files[toKey(path)]; + } + function set(path, value) { + files[toKey(path)] = value; + } + function contains(path) { + return hasProperty(files, toKey(path)); + } + function remove(path) { + var key = toKey(path); + delete files[key]; } function clear() { files = {}; } + function toKey(path) { + return keyMapper ? keyMapper(path) : path; + } } ts.createFileMap = createFileMap; + function toPath(fileName, basePath, getCanonicalFileName) { + var nonCanonicalizedPath = isRootedDiskPath(fileName) + ? normalizePath(fileName) + : getNormalizedAbsolutePath(fileName, basePath); + return getCanonicalFileName(nonCanonicalizedPath); + } + ts.toPath = toPath; (function (Comparison) { Comparison[Comparison["LessThan"] = -1] = "LessThan"; Comparison[Comparison["EqualTo"] = 0] = "EqualTo"; @@ -897,8 +916,8 @@ var ts; ts.forEach = forEach; function contains(array, value) { if (array) { - for (var _i = 0; _i < array.length; _i++) { - var v = array[_i]; + for (var _i = 0, array_1 = array; _i < array_1.length; _i++) { + var v = array_1[_i]; if (v === value) { return true; } @@ -921,8 +940,8 @@ var ts; function countWhere(array, predicate) { var count = 0; if (array) { - for (var _i = 0; _i < array.length; _i++) { - var v = array[_i]; + for (var _i = 0, array_2 = array; _i < array_2.length; _i++) { + var v = array_2[_i]; if (predicate(v)) { count++; } @@ -935,8 +954,8 @@ var ts; var result; if (array) { result = []; - for (var _i = 0; _i < array.length; _i++) { - var item = array[_i]; + for (var _i = 0, array_3 = array; _i < array_3.length; _i++) { + var item = array_3[_i]; if (f(item)) { result.push(item); } @@ -949,8 +968,8 @@ var ts; var result; if (array) { result = []; - for (var _i = 0; _i < array.length; _i++) { - var v = array[_i]; + for (var _i = 0, array_4 = array; _i < array_4.length; _i++) { + var v = array_4[_i]; result.push(f(v)); } } @@ -969,8 +988,8 @@ var ts; var result; if (array) { result = []; - for (var _i = 0; _i < array.length; _i++) { - var item = array[_i]; + for (var _i = 0, array_5 = array; _i < array_5.length; _i++) { + var item = array_5[_i]; if (!contains(result, item)) { result.push(item); } @@ -981,8 +1000,8 @@ var ts; ts.deduplicate = deduplicate; function sum(array, prop) { var result = 0; - for (var _i = 0; _i < array.length; _i++) { - var v = array[_i]; + for (var _i = 0, array_6 = array; _i < array_6.length; _i++) { + var v = array_6[_i]; result += v[prop]; } return result; @@ -990,8 +1009,8 @@ var ts; ts.sum = sum; function addRange(to, from) { if (to && from) { - for (var _i = 0; _i < from.length; _i++) { - var v = from[_i]; + for (var _i = 0, from_1 = from; _i < from_1.length; _i++) { + var v = from_1[_i]; to.push(v); } } @@ -1341,8 +1360,8 @@ var ts; function getNormalizedParts(normalizedSlashedPath, rootLength) { var parts = normalizedSlashedPath.substr(rootLength).split(ts.directorySeparator); var normalized = []; - for (var _i = 0; _i < parts.length; _i++) { - var part = parts[_i]; + for (var _i = 0, parts_1 = parts; _i < parts_1.length; _i++) { + var part = parts_1[_i]; if (part !== ".") { if (part === ".." && normalized.length > 0 && lastOrUndefined(normalized) !== "..") { normalized.pop(); @@ -1521,8 +1540,8 @@ var ts; if (!fileName) { return false; } - for (var _i = 0; _i < ts.supportedExtensions.length; _i++) { - var extension = ts.supportedExtensions[_i]; + for (var _i = 0, supportedExtensions_1 = ts.supportedExtensions; _i < supportedExtensions_1.length; _i++) { + var extension = supportedExtensions_1[_i]; if (fileExtensionIs(fileName, extension)) { return true; } @@ -1532,8 +1551,8 @@ var ts; ts.isSupportedSourceFileName = isSupportedSourceFileName; var extensionsToRemove = [".d.ts", ".ts", ".js", ".tsx", ".jsx"]; function removeFileExtension(path) { - for (var _i = 0; _i < extensionsToRemove.length; _i++) { - var ext = extensionsToRemove[_i]; + for (var _i = 0, extensionsToRemove_1 = extensionsToRemove; _i < extensionsToRemove_1.length; _i++) { + var ext = extensionsToRemove_1[_i]; if (fileExtensionIs(path, ext)) { return path.substr(0, path.length - ext.length); } @@ -1614,8 +1633,8 @@ var ts; })(Debug = ts.Debug || (ts.Debug = {})); function copyListRemovingItem(item, list) { var copiedList = []; - for (var _i = 0; _i < list.length; _i++) { - var e = list[_i]; + for (var _i = 0, list_1 = list; _i < list_1.length; _i++) { + var e = list_1[_i]; if (e !== item) { copiedList.push(e); } @@ -1709,16 +1728,16 @@ var ts; function visitDirectory(path) { var folder = fso.GetFolder(path || "."); var files = getNames(folder.files); - for (var _i = 0; _i < files.length; _i++) { - var current = files[_i]; + for (var _i = 0, files_1 = files; _i < files_1.length; _i++) { + var current = files_1[_i]; var name_1 = ts.combinePaths(path, current); if ((!extension || ts.fileExtensionIs(name_1, extension)) && !ts.contains(exclude, getCanonicalPath(name_1))) { result.push(name_1); } } var subfolders = getNames(folder.subfolders); - for (var _a = 0; _a < subfolders.length; _a++) { - var current = subfolders[_a]; + for (var _a = 0, subfolders_1 = subfolders; _a < subfolders_1.length; _a++) { + var current = subfolders_1[_a]; var name_2 = ts.combinePaths(path, current); if (!ts.contains(exclude, getCanonicalPath(name_2))) { visitDirectory(name_2); @@ -1769,6 +1788,7 @@ var ts; var _fs = require("fs"); var _path = require("path"); var _os = require("os"); + var _tty = require("tty"); // average async stat takes about 30 microseconds // set chunk size to do 30 files in < 1 millisecond function createWatchedFileSet(interval, chunkSize) { @@ -1906,8 +1926,8 @@ var ts; function visitDirectory(path) { var files = _fs.readdirSync(path || ".").sort(); var directories = []; - for (var _i = 0; _i < files.length; _i++) { - var current = files[_i]; + for (var _i = 0, files_2 = files; _i < files_2.length; _i++) { + var current = files_2[_i]; var name_3 = ts.combinePaths(path, current); if (!ts.contains(exclude, getCanonicalPath(name_3))) { var stat = _fs.statSync(name_3); @@ -1921,8 +1941,8 @@ var ts; } } } - for (var _a = 0; _a < directories.length; _a++) { - var current = directories[_a]; + for (var _a = 0, directories_1 = directories; _a < directories_1.length; _a++) { + var current = directories_1[_a]; visitDirectory(current); } } @@ -1932,15 +1952,7 @@ var ts; newLine: _os.EOL, useCaseSensitiveFileNames: useCaseSensitiveFileNames, write: function (s) { - var buffer = new Buffer(s, "utf8"); - var offset = 0; - var toWrite = buffer.length; - var written = 0; - // 1 is a standard descriptor for stdout - while ((written = _fs.writeSync(1, buffer, offset, toWrite)) < toWrite) { - offset += written; - toWrite -= written; - } + process.stdout.write(s); }, readFile: readFile, writeFile: writeFile, @@ -2223,6 +2235,7 @@ var ts; await_expression_is_only_allowed_within_an_async_function: { code: 1308, category: ts.DiagnosticCategory.Error, key: "await_expression_is_only_allowed_within_an_async_function_1308", message: "'await' expression is only allowed within an async function." }, Async_functions_are_only_available_when_targeting_ECMAScript_6_and_higher: { code: 1311, category: ts.DiagnosticCategory.Error, key: "Async_functions_are_only_available_when_targeting_ECMAScript_6_and_higher_1311", message: "Async functions are only available when targeting ECMAScript 6 and higher." }, can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment: { code: 1312, category: ts.DiagnosticCategory.Error, key: "can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment_1312", message: "'=' can only be used in an object literal property inside a destructuring assignment." }, + The_body_of_an_if_statement_cannot_be_the_empty_statement: { code: 1313, category: ts.DiagnosticCategory.Error, key: "The_body_of_an_if_statement_cannot_be_the_empty_statement_1313", message: "The body of an 'if' statement cannot be the empty statement." }, Duplicate_identifier_0: { code: 2300, category: ts.DiagnosticCategory.Error, key: "Duplicate_identifier_0_2300", message: "Duplicate identifier '{0}'." }, Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor: { code: 2301, category: ts.DiagnosticCategory.Error, key: "Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor_2301", message: "Initializer of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor." }, Static_members_cannot_reference_class_type_parameters: { code: 2302, category: ts.DiagnosticCategory.Error, key: "Static_members_cannot_reference_class_type_parameters_2302", message: "Static members cannot reference class type parameters." }, @@ -2275,7 +2288,7 @@ var ts; Neither_type_0_nor_type_1_is_assignable_to_the_other: { code: 2352, category: ts.DiagnosticCategory.Error, key: "Neither_type_0_nor_type_1_is_assignable_to_the_other_2352", message: "Neither type '{0}' nor type '{1}' is assignable to the other." }, Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1: { code: 2353, category: ts.DiagnosticCategory.Error, key: "Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1_2353", message: "Object literal may only specify known properties, and '{0}' does not exist in type '{1}'." }, No_best_common_type_exists_among_return_expressions: { code: 2354, category: ts.DiagnosticCategory.Error, key: "No_best_common_type_exists_among_return_expressions_2354", message: "No best common type exists among return expressions." }, - A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value_or_consist_of_a_single_throw_statement: { code: 2355, category: ts.DiagnosticCategory.Error, key: "A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value_or_consist_of_a_single_th_2355", message: "A function whose declared type is neither 'void' nor 'any' must return a value or consist of a single 'throw' statement." }, + A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value: { code: 2355, category: ts.DiagnosticCategory.Error, key: "A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value_2355", message: "A function whose declared type is neither 'void' nor 'any' must return a value." }, An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type: { code: 2356, category: ts.DiagnosticCategory.Error, key: "An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type_2356", message: "An arithmetic operand must be of type 'any', 'number' or an enum type." }, The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_property_or_indexer: { code: 2357, category: ts.DiagnosticCategory.Error, key: "The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_property_or_indexer_2357", message: "The operand of an increment or decrement operator must be a variable, property or indexer." }, The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_parameter: { code: 2358, category: ts.DiagnosticCategory.Error, key: "The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_paramete_2358", message: "The left-hand side of an 'instanceof' expression must be of type 'any', an object type or a type parameter." }, @@ -2296,7 +2309,7 @@ var ts; Duplicate_number_index_signature: { code: 2375, category: ts.DiagnosticCategory.Error, key: "Duplicate_number_index_signature_2375", message: "Duplicate number index signature." }, A_super_call_must_be_the_first_statement_in_the_constructor_when_a_class_contains_initialized_properties_or_has_parameter_properties: { code: 2376, category: ts.DiagnosticCategory.Error, key: "A_super_call_must_be_the_first_statement_in_the_constructor_when_a_class_contains_initialized_proper_2376", message: "A 'super' call must be the first statement in the constructor when a class contains initialized properties or has parameter properties." }, Constructors_for_derived_classes_must_contain_a_super_call: { code: 2377, category: ts.DiagnosticCategory.Error, key: "Constructors_for_derived_classes_must_contain_a_super_call_2377", message: "Constructors for derived classes must contain a 'super' call." }, - A_get_accessor_must_return_a_value_or_consist_of_a_single_throw_statement: { code: 2378, category: ts.DiagnosticCategory.Error, key: "A_get_accessor_must_return_a_value_or_consist_of_a_single_throw_statement_2378", message: "A 'get' accessor must return a value or consist of a single 'throw' statement." }, + A_get_accessor_must_return_a_value: { code: 2378, category: ts.DiagnosticCategory.Error, key: "A_get_accessor_must_return_a_value_2378", message: "A 'get' accessor must return a value." }, Getter_and_setter_accessors_do_not_agree_in_visibility: { code: 2379, category: ts.DiagnosticCategory.Error, key: "Getter_and_setter_accessors_do_not_agree_in_visibility_2379", message: "Getter and setter accessors do not agree in visibility." }, get_and_set_accessor_must_have_the_same_type: { code: 2380, category: ts.DiagnosticCategory.Error, key: "get_and_set_accessor_must_have_the_same_type_2380", message: "'get' and 'set' accessor must have the same type." }, A_signature_with_an_implementation_cannot_use_a_string_literal_type: { code: 2381, category: ts.DiagnosticCategory.Error, key: "A_signature_with_an_implementation_cannot_use_a_string_literal_type_2381", message: "A signature with an implementation cannot use a string literal type." }, @@ -2586,8 +2599,6 @@ var ts; NEWLINE: { code: 6061, category: ts.DiagnosticCategory.Message, key: "NEWLINE_6061", message: "NEWLINE" }, Argument_for_newLine_option_must_be_CRLF_or_LF: { code: 6062, category: ts.DiagnosticCategory.Error, key: "Argument_for_newLine_option_must_be_CRLF_or_LF_6062", message: "Argument for '--newLine' option must be 'CRLF' or 'LF'." }, Argument_for_moduleResolution_option_must_be_node_or_classic: { code: 6063, category: ts.DiagnosticCategory.Error, key: "Argument_for_moduleResolution_option_must_be_node_or_classic_6063", message: "Argument for '--moduleResolution' option must be 'node' or 'classic'." }, - Specify_JSX_code_generation_Colon_preserve_or_react: { code: 6080, category: ts.DiagnosticCategory.Message, key: "Specify_JSX_code_generation_Colon_preserve_or_react_6080", message: "Specify JSX code generation: 'preserve' or 'react'" }, - Argument_for_jsx_must_be_preserve_or_react: { code: 6081, category: ts.DiagnosticCategory.Message, key: "Argument_for_jsx_must_be_preserve_or_react_6081", message: "Argument for '--jsx' must be 'preserve' or 'react'." }, Enables_experimental_support_for_ES7_decorators: { code: 6065, category: ts.DiagnosticCategory.Message, key: "Enables_experimental_support_for_ES7_decorators_6065", message: "Enables experimental support for ES7 decorators." }, Enables_experimental_support_for_emitting_type_metadata_for_decorators: { code: 6066, category: ts.DiagnosticCategory.Message, key: "Enables_experimental_support_for_emitting_type_metadata_for_decorators_6066", message: "Enables experimental support for emitting type metadata for decorators." }, Enables_experimental_support_for_ES7_async_functions: { code: 6068, category: ts.DiagnosticCategory.Message, key: "Enables_experimental_support_for_ES7_async_functions_6068", message: "Enables experimental support for ES7 async functions." }, @@ -2595,7 +2606,14 @@ var ts; Initializes_a_TypeScript_project_and_creates_a_tsconfig_json_file: { code: 6070, category: ts.DiagnosticCategory.Message, key: "Initializes_a_TypeScript_project_and_creates_a_tsconfig_json_file_6070", message: "Initializes a TypeScript project and creates a tsconfig.json file." }, Successfully_created_a_tsconfig_json_file: { code: 6071, category: ts.DiagnosticCategory.Message, key: "Successfully_created_a_tsconfig_json_file_6071", message: "Successfully created a tsconfig.json file." }, Suppress_excess_property_checks_for_object_literals: { code: 6072, category: ts.DiagnosticCategory.Message, key: "Suppress_excess_property_checks_for_object_literals_6072", message: "Suppress excess property checks for object literals." }, - Disallow_inconsistently_cased_references_to_the_same_file: { code: 6073, category: ts.DiagnosticCategory.Message, key: "Disallow_inconsistently_cased_references_to_the_same_file_6073", message: "Disallow inconsistently-cased references to the same file." }, + Stylize_errors_and_messages_using_color_and_context_experimental: { code: 6073, category: ts.DiagnosticCategory.Message, key: "Stylize_errors_and_messages_using_color_and_context_experimental_6073", message: "Stylize errors and messages using color and context. (experimental)" }, + Do_not_report_errors_on_unused_labels: { code: 6074, category: ts.DiagnosticCategory.Message, key: "Do_not_report_errors_on_unused_labels_6074", message: "Do not report errors on unused labels." }, + Report_error_when_not_all_code_paths_in_function_return_a_value: { code: 6075, category: ts.DiagnosticCategory.Message, key: "Report_error_when_not_all_code_paths_in_function_return_a_value_6075", message: "Report error when not all code paths in function return a value." }, + Report_errors_for_fallthrough_cases_in_switch_statement: { code: 6076, category: ts.DiagnosticCategory.Message, key: "Report_errors_for_fallthrough_cases_in_switch_statement_6076", message: "Report errors for fallthrough cases in switch statement." }, + Do_not_report_errors_on_unreachable_code: { code: 6077, category: ts.DiagnosticCategory.Message, key: "Do_not_report_errors_on_unreachable_code_6077", message: "Do not report errors on unreachable code." }, + Disallow_inconsistently_cased_references_to_the_same_file: { code: 6078, category: ts.DiagnosticCategory.Message, key: "Disallow_inconsistently_cased_references_to_the_same_file_6078", message: "Disallow inconsistently-cased references to the same file." }, + Specify_JSX_code_generation_Colon_preserve_or_react: { code: 6080, category: ts.DiagnosticCategory.Message, key: "Specify_JSX_code_generation_Colon_preserve_or_react_6080", message: "Specify JSX code generation: 'preserve' or 'react'" }, + Argument_for_jsx_must_be_preserve_or_react: { code: 6081, category: ts.DiagnosticCategory.Message, key: "Argument_for_jsx_must_be_preserve_or_react_6081", message: "Argument for '--jsx' must be 'preserve' or 'react'." }, 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." }, @@ -2613,6 +2631,10 @@ var ts; Function_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions: { code: 7024, category: ts.DiagnosticCategory.Error, key: "Function_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_ref_7024", message: "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." }, Generator_implicitly_has_type_0_because_it_does_not_yield_any_values_Consider_supplying_a_return_type: { code: 7025, category: ts.DiagnosticCategory.Error, key: "Generator_implicitly_has_type_0_because_it_does_not_yield_any_values_Consider_supplying_a_return_typ_7025", message: "Generator implicitly has type '{0}' because it does not yield any values. Consider supplying a return type." }, JSX_element_implicitly_has_type_any_because_no_interface_JSX_0_exists: { code: 7026, category: ts.DiagnosticCategory.Error, key: "JSX_element_implicitly_has_type_any_because_no_interface_JSX_0_exists_7026", message: "JSX element implicitly has type 'any' because no interface 'JSX.{0}' exists" }, + Unreachable_code_detected: { code: 7027, category: ts.DiagnosticCategory.Error, key: "Unreachable_code_detected_7027", message: "Unreachable code detected." }, + Unused_label: { code: 7028, category: ts.DiagnosticCategory.Error, key: "Unused_label_7028", message: "Unused label." }, + Fallthrough_case_in_switch: { code: 7029, category: ts.DiagnosticCategory.Error, key: "Fallthrough_case_in_switch_7029", message: "Fallthrough case in switch." }, + Not_all_code_paths_return_a_value: { code: 7030, category: ts.DiagnosticCategory.Error, key: "Not_all_code_paths_return_a_value_7030", message: "Not all code paths return a value." }, 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." }, @@ -4166,6 +4188,20 @@ var ts; ModuleInstanceState[ModuleInstanceState["ConstEnumOnly"] = 2] = "ConstEnumOnly"; })(ts.ModuleInstanceState || (ts.ModuleInstanceState = {})); var ModuleInstanceState = ts.ModuleInstanceState; + var Reachability; + (function (Reachability) { + Reachability[Reachability["Unintialized"] = 1] = "Unintialized"; + Reachability[Reachability["Reachable"] = 2] = "Reachable"; + Reachability[Reachability["Unreachable"] = 4] = "Unreachable"; + Reachability[Reachability["ReportedUnreachable"] = 8] = "ReportedUnreachable"; + })(Reachability || (Reachability = {})); + function or(state1, state2) { + return (state1 | state2) & 2 /* Reachable */ + ? 2 /* Reachable */ + : (state1 & state2) & 8 /* ReportedUnreachable */ + ? 8 /* ReportedUnreachable */ + : 4 /* Unreachable */; + } function getModuleInstanceState(node) { // A module is uninstantiated if it contains only // 1. interface declarations, type alias declarations @@ -4175,7 +4211,7 @@ var ts; else if (ts.isConstEnumDeclaration(node)) { return 2 /* ConstEnumOnly */; } - else if ((node.kind === 222 /* ImportDeclaration */ || node.kind === 221 /* ImportEqualsDeclaration */) && !(node.flags & 1 /* Export */)) { + else if ((node.kind === 222 /* ImportDeclaration */ || node.kind === 221 /* ImportEqualsDeclaration */) && !(node.flags & 2 /* Export */)) { return 0 /* NonInstantiated */; } else if (node.kind === 219 /* ModuleBlock */) { @@ -4226,31 +4262,56 @@ var ts; // Functions, Methods, Modules, Source-files. ContainerFlags[ContainerFlags["IsContainerWithLocals"] = 5] = "IsContainerWithLocals"; })(ContainerFlags || (ContainerFlags = {})); - function bindSourceFile(file) { + var binder = createBinder(); + function bindSourceFile(file, options) { var start = new Date().getTime(); - bindSourceFileWorker(file); + binder(file, options); ts.bindTime += new Date().getTime() - start; } ts.bindSourceFile = bindSourceFile; - function bindSourceFileWorker(file) { + function createBinder() { + var file; + var options; var parent; var container; var blockScopeContainer; var lastContainer; var seenThisKeyword; + // state used by reachability checks + var hasExplicitReturn; + var currentReachabilityState; + var labelStack; + var labelIndexMap; + var implicitLabels; // 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). - var inStrictMode = !!file.externalModuleIndicator; + var inStrictMode; var symbolCount = 0; - var Symbol = ts.objectAllocator.getSymbolConstructor(); - var classifiableNames = {}; - if (!file.locals) { - bind(file); - file.symbolCount = symbolCount; - file.classifiableNames = classifiableNames; + var Symbol; + var classifiableNames; + function bindSourceFile(f, opts) { + file = f; + options = opts; + inStrictMode = !!file.externalModuleIndicator; + classifiableNames = {}; + Symbol = ts.objectAllocator.getSymbolConstructor(); + if (!file.locals) { + bind(file); + file.symbolCount = symbolCount; + file.classifiableNames = classifiableNames; + } + parent = undefined; + container = undefined; + blockScopeContainer = undefined; + lastContainer = undefined; + seenThisKeyword = false; + hasExplicitReturn = false; + labelStack = undefined; + labelIndexMap = undefined; + implicitLabels = undefined; } - return; + return bindSourceFile; function createSymbol(flags, name) { symbolCount++; return new Symbol(flags, name); @@ -4303,7 +4364,7 @@ var ts; return node.isExportEquals ? "export=" : "default"; case 213 /* FunctionDeclaration */: case 214 /* ClassDeclaration */: - return node.flags & 1024 /* Default */ ? "default" : undefined; + return node.flags & 512 /* Default */ ? "default" : undefined; } } function getDisplayName(node) { @@ -4319,7 +4380,7 @@ var ts; */ function declareSymbol(symbolTable, parent, node, includes, excludes) { ts.Debug.assert(!ts.hasDynamicName(node)); - var isDefaultExport = node.flags & 1024 /* Default */; + var isDefaultExport = node.flags & 512 /* Default */; // The exported symbol for an export default function/class node is always named "default" var name = isDefaultExport && parent ? "default" : getDeclarationName(node); var symbol; @@ -4358,7 +4419,7 @@ var ts; ? ts.Diagnostics.Cannot_redeclare_block_scoped_variable_0 : ts.Diagnostics.Duplicate_identifier_0; ts.forEach(symbol.declarations, function (declaration) { - if (declaration.flags & 1024 /* Default */) { + if (declaration.flags & 512 /* Default */) { message = ts.Diagnostics.A_module_cannot_have_multiple_default_exports; } }); @@ -4377,7 +4438,7 @@ var ts; return symbol; } function declareModuleMember(node, symbolFlags, symbolExcludes) { - var hasExportModifier = ts.getCombinedNodeFlags(node) & 1 /* Export */; + var hasExportModifier = ts.getCombinedNodeFlags(node) & 2 /* Export */; if (symbolFlags & 8388608 /* Alias */) { if (node.kind === 230 /* ExportSpecifier */ || (node.kind === 221 /* ImportEqualsDeclaration */ && hasExportModifier)) { return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); @@ -4398,7 +4459,7 @@ var ts; // 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. - if (hasExportModifier || container.flags & 262144 /* ExportContext */) { + if (hasExportModifier || container.flags & 131072 /* ExportContext */) { var exportKind = (symbolFlags & 107455 /* Value */ ? 1048576 /* ExportValue */ : 0) | (symbolFlags & 793056 /* Type */ ? 2097152 /* ExportType */ : 0) | (symbolFlags & 1536 /* Namespace */ ? 4194304 /* ExportNamespace */ : 0); @@ -4453,18 +4514,229 @@ var ts; blockScopeContainer = node; blockScopeContainer.locals = undefined; } - if (node.kind === 215 /* InterfaceDeclaration */) { + var savedReachabilityState; + var savedLabelStack; + var savedLabels; + var savedImplicitLabels; + var savedHasExplicitReturn; + var kind = node.kind; + var flags = node.flags; + // reset all reachability check related flags on node (for incremental scenarios) + flags &= ~1572864 /* ReachabilityCheckFlags */; + if (kind === 215 /* InterfaceDeclaration */) { seenThisKeyword = false; - ts.forEachChild(node, bind); - node.flags = seenThisKeyword ? node.flags | 524288 /* ContainsThis */ : node.flags & ~524288 /* ContainsThis */; } - else { - ts.forEachChild(node, bind); + var saveState = kind === 248 /* SourceFile */ || kind === 219 /* ModuleBlock */ || ts.isFunctionLikeKind(kind); + if (saveState) { + savedReachabilityState = currentReachabilityState; + savedLabelStack = labelStack; + savedLabels = labelIndexMap; + savedImplicitLabels = implicitLabels; + savedHasExplicitReturn = hasExplicitReturn; + currentReachabilityState = 2 /* Reachable */; + hasExplicitReturn = false; + labelStack = labelIndexMap = implicitLabels = undefined; + } + bindReachableStatement(node); + if (currentReachabilityState === 2 /* Reachable */ && ts.isFunctionLikeKind(kind) && ts.nodeIsPresent(node.body)) { + flags |= 524288 /* HasImplicitReturn */; + if (hasExplicitReturn) { + flags |= 1048576 /* HasExplicitReturn */; + } + } + if (kind === 215 /* InterfaceDeclaration */) { + flags = seenThisKeyword ? flags | 262144 /* ContainsThis */ : flags & ~262144 /* ContainsThis */; + } + node.flags = flags; + if (saveState) { + hasExplicitReturn = savedHasExplicitReturn; + currentReachabilityState = savedReachabilityState; + labelStack = savedLabelStack; + labelIndexMap = savedLabels; + implicitLabels = savedImplicitLabels; } container = saveContainer; parent = saveParent; blockScopeContainer = savedBlockScopeContainer; } + /** + * Returns true if node and its subnodes were successfully traversed. + * Returning false means that node was not examined and caller needs to dive into the node himself. + */ + function bindReachableStatement(node) { + if (checkUnreachable(node)) { + ts.forEachChild(node, bind); + return; + } + switch (node.kind) { + case 198 /* WhileStatement */: + bindWhileStatement(node); + break; + case 197 /* DoStatement */: + bindDoStatement(node); + break; + case 199 /* ForStatement */: + bindForStatement(node); + break; + case 200 /* ForInStatement */: + case 201 /* ForOfStatement */: + bindForInOrForOfStatement(node); + break; + case 196 /* IfStatement */: + bindIfStatement(node); + break; + case 204 /* ReturnStatement */: + case 208 /* ThrowStatement */: + bindReturnOrThrow(node); + break; + case 203 /* BreakStatement */: + case 202 /* ContinueStatement */: + bindBreakOrContinueStatement(node); + break; + case 209 /* TryStatement */: + bindTryStatement(node); + break; + case 206 /* SwitchStatement */: + bindSwitchStatement(node); + break; + case 220 /* CaseBlock */: + bindCaseBlock(node); + break; + case 207 /* LabeledStatement */: + bindLabeledStatement(node); + break; + default: + ts.forEachChild(node, bind); + break; + } + } + function bindWhileStatement(n) { + var preWhileState = n.expression.kind === 84 /* FalseKeyword */ ? 4 /* Unreachable */ : currentReachabilityState; + var postWhileState = n.expression.kind === 99 /* TrueKeyword */ ? 4 /* Unreachable */ : currentReachabilityState; + // bind expressions (don't affect reachability) + bind(n.expression); + currentReachabilityState = preWhileState; + var postWhileLabel = pushImplicitLabel(); + bind(n.statement); + popImplicitLabel(postWhileLabel, postWhileState); + } + function bindDoStatement(n) { + var preDoState = currentReachabilityState; + var postDoLabel = pushImplicitLabel(); + bind(n.statement); + var postDoState = n.expression.kind === 99 /* TrueKeyword */ ? 4 /* Unreachable */ : preDoState; + popImplicitLabel(postDoLabel, postDoState); + // bind expressions (don't affect reachability) + bind(n.expression); + } + function bindForStatement(n) { + var preForState = currentReachabilityState; + var postForLabel = pushImplicitLabel(); + // bind expressions (don't affect reachability) + bind(n.initializer); + bind(n.condition); + bind(n.incrementor); + bind(n.statement); + // for statement is considered infinite when it condition is either omitted or is true keyword + // - for(..;;..) + // - for(..;true;..) + var isInfiniteLoop = (!n.condition || n.condition.kind === 99 /* TrueKeyword */); + var postForState = isInfiniteLoop ? 4 /* Unreachable */ : preForState; + popImplicitLabel(postForLabel, postForState); + } + function bindForInOrForOfStatement(n) { + var preStatementState = currentReachabilityState; + var postStatementLabel = pushImplicitLabel(); + // bind expressions (don't affect reachability) + bind(n.initializer); + bind(n.expression); + bind(n.statement); + popImplicitLabel(postStatementLabel, preStatementState); + } + function bindIfStatement(n) { + // denotes reachability state when entering 'thenStatement' part of the if statement: + // i.e. if condition is false then thenStatement is unreachable + var ifTrueState = n.expression.kind === 84 /* FalseKeyword */ ? 4 /* Unreachable */ : currentReachabilityState; + // denotes reachability state when entering 'elseStatement': + // i.e. if condition is true then elseStatement is unreachable + var ifFalseState = n.expression.kind === 99 /* TrueKeyword */ ? 4 /* Unreachable */ : currentReachabilityState; + currentReachabilityState = ifTrueState; + // bind expression (don't affect reachability) + bind(n.expression); + bind(n.thenStatement); + if (n.elseStatement) { + var preElseState = currentReachabilityState; + currentReachabilityState = ifFalseState; + bind(n.elseStatement); + currentReachabilityState = or(currentReachabilityState, preElseState); + } + else { + currentReachabilityState = or(currentReachabilityState, ifFalseState); + } + } + function bindReturnOrThrow(n) { + // bind expression (don't affect reachability) + bind(n.expression); + if (n.kind === 204 /* ReturnStatement */) { + hasExplicitReturn = true; + } + currentReachabilityState = 4 /* Unreachable */; + } + function bindBreakOrContinueStatement(n) { + // call bind on label (don't affect reachability) + bind(n.label); + // for continue case touch label so it will be marked a used + var isValidJump = jumpToLabel(n.label, n.kind === 203 /* BreakStatement */ ? currentReachabilityState : 4 /* Unreachable */); + if (isValidJump) { + currentReachabilityState = 4 /* Unreachable */; + } + } + function bindTryStatement(n) { + // catch\finally blocks has the same reachability as try block + var preTryState = currentReachabilityState; + bind(n.tryBlock); + var postTryState = currentReachabilityState; + currentReachabilityState = preTryState; + bind(n.catchClause); + var postCatchState = currentReachabilityState; + currentReachabilityState = preTryState; + bind(n.finallyBlock); + // post catch/finally state is reachable if + // - post try state is reachable - control flow can fall out of try block + // - post catch state is reachable - control flow can fall out of catch block + currentReachabilityState = or(postTryState, postCatchState); + } + function bindSwitchStatement(n) { + var preSwitchState = currentReachabilityState; + var postSwitchLabel = pushImplicitLabel(); + // bind expression (don't affect reachability) + bind(n.expression); + bind(n.caseBlock); + var hasDefault = ts.forEach(n.caseBlock.clauses, function (c) { return c.kind === 242 /* DefaultClause */; }); + // post switch state is unreachable if switch is exaustive (has a default case ) and does not have fallthrough from the last case + var postSwitchState = hasDefault && currentReachabilityState !== 2 /* Reachable */ ? 4 /* Unreachable */ : preSwitchState; + popImplicitLabel(postSwitchLabel, postSwitchState); + } + function bindCaseBlock(n) { + var startState = currentReachabilityState; + for (var _i = 0, _a = n.clauses; _i < _a.length; _i++) { + var clause = _a[_i]; + currentReachabilityState = startState; + bind(clause); + if (clause.statements.length && currentReachabilityState === 2 /* Reachable */ && options.noFallthroughCasesInSwitch) { + errorOnFirstToken(clause, ts.Diagnostics.Fallthrough_case_in_switch); + } + } + } + function bindLabeledStatement(n) { + // call bind on label (don't affect reachability) + bind(n.label); + var ok = pushNamedLabel(n.label); + bind(n.statement); + if (ok) { + popNamedLabel(n.label, currentReachabilityState); + } + } function getContainerFlags(node) { switch (node.kind) { case 186 /* ClassExpression */: @@ -4576,7 +4848,7 @@ var ts; } } function declareClassMember(node, symbolFlags, symbolExcludes) { - return node.flags & 128 /* Static */ + return node.flags & 64 /* Static */ ? declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes) : declareSymbol(container.symbol.members, container.symbol, node, symbolFlags, symbolExcludes); } @@ -4585,15 +4857,6 @@ var ts; ? declareModuleMember(node, symbolFlags, symbolExcludes) : declareSymbol(file.locals, undefined, node, symbolFlags, symbolExcludes); } - function isAmbientContext(node) { - while (node) { - if (node.flags & 2 /* Ambient */) { - return true; - } - node = node.parent; - } - return false; - } function hasExportDeclarations(node) { var body = node.kind === 248 /* SourceFile */ ? node : node.body; if (body.kind === 248 /* SourceFile */ || body.kind === 219 /* ModuleBlock */) { @@ -4609,11 +4872,11 @@ var ts; function setExportContextFlag(node) { // 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 (isAmbientContext(node) && !hasExportDeclarations(node)) { - node.flags |= 262144 /* ExportContext */; + if (ts.isInAmbientContext(node) && !hasExportDeclarations(node)) { + node.flags |= 131072 /* ExportContext */; } else { - node.flags &= ~262144 /* ExportContext */; + node.flags &= ~131072 /* ExportContext */; } } function bindModuleDeclaration(node) { @@ -4805,7 +5068,7 @@ var ts; } } function checkStrictModeNumericLiteral(node) { - if (inStrictMode && node.flags & 65536 /* OctalLiteral */) { + if (inStrictMode && node.flags & 32768 /* OctalLiteral */) { file.bindDiagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.Octal_literals_are_not_allowed_in_strict_mode)); } } @@ -4829,10 +5092,10 @@ var ts; function checkStrictModeWithStatement(node) { // Grammar checking for withStatement if (inStrictMode) { - grammarErrorOnFirstToken(node, ts.Diagnostics.with_statements_are_not_allowed_in_strict_mode); + errorOnFirstToken(node, ts.Diagnostics.with_statements_are_not_allowed_in_strict_mode); } } - function grammarErrorOnFirstToken(node, message, arg0, arg1, arg2) { + function errorOnFirstToken(node, message, arg0, arg1, arg2) { var span = ts.getSpanOfTokenAtPosition(file, node.pos); file.bindDiagnostics.push(ts.createFileDiagnostic(file, span.start, span.length, message, arg0, arg1, arg2)); } @@ -4840,6 +5103,9 @@ var ts; return "__" + ts.indexOf(node.parent.parameters, node); } function bind(node) { + if (!node) { + return; + } node.parent = parent; var savedInStrictMode = inStrictMode; if (!savedInStrictMode) { @@ -4882,8 +5148,8 @@ var ts; } } function updateStrictModeStatementList(statements) { - for (var _i = 0; _i < statements.length; _i++) { - var statement = statements[_i]; + for (var _i = 0, statements_1 = statements; _i < statements_1.length; _i++) { + var statement = statements_1[_i]; if (!ts.isPrologueDirective(statement)) { return; } @@ -5105,7 +5371,7 @@ var ts; } // If this is a property-parameter, then also declare the property symbol into the // containing class. - if (node.flags & 112 /* AccessibilityModifier */ && + if (node.flags & 56 /* AccessibilityModifier */ && node.parent.kind === 144 /* Constructor */ && ts.isClassLike(node.parent.parent)) { var classDeclaration = node.parent.parent; @@ -5117,6 +5383,112 @@ var ts; ? bindAnonymousDeclaration(node, symbolFlags, "__computed") : declareSymbolAndAddToSymbolTable(node, symbolFlags, symbolExcludes); } + // reachability checks + function pushNamedLabel(name) { + initializeReachabilityStateIfNecessary(); + if (ts.hasProperty(labelIndexMap, name.text)) { + return false; + } + labelIndexMap[name.text] = labelStack.push(1 /* Unintialized */) - 1; + return true; + } + function pushImplicitLabel() { + initializeReachabilityStateIfNecessary(); + var index = labelStack.push(1 /* Unintialized */) - 1; + implicitLabels.push(index); + return index; + } + function popNamedLabel(label, outerState) { + var index = labelIndexMap[label.text]; + ts.Debug.assert(index !== undefined); + ts.Debug.assert(labelStack.length == index + 1); + labelIndexMap[label.text] = undefined; + setCurrentStateAtLabel(labelStack.pop(), outerState, label); + } + function popImplicitLabel(implicitLabelIndex, outerState) { + if (labelStack.length !== implicitLabelIndex + 1) { + ts.Debug.assert(false, "Label stack: " + labelStack.length + ", index:" + implicitLabelIndex); + } + var i = implicitLabels.pop(); + if (implicitLabelIndex !== i) { + ts.Debug.assert(false, "i: " + i + ", index: " + implicitLabelIndex); + } + setCurrentStateAtLabel(labelStack.pop(), outerState, /*name*/ undefined); + } + function setCurrentStateAtLabel(innerMergedState, outerState, label) { + if (innerMergedState === 1 /* Unintialized */) { + if (label && !options.allowUnusedLabels) { + file.bindDiagnostics.push(ts.createDiagnosticForNode(label, ts.Diagnostics.Unused_label)); + } + currentReachabilityState = outerState; + } + else { + currentReachabilityState = or(innerMergedState, outerState); + } + } + function jumpToLabel(label, outerState) { + initializeReachabilityStateIfNecessary(); + var index = label ? labelIndexMap[label.text] : ts.lastOrUndefined(implicitLabels); + if (index === undefined) { + // reference to unknown label or + // break/continue used outside of loops + return false; + } + var stateAtLabel = labelStack[index]; + labelStack[index] = stateAtLabel === 1 /* Unintialized */ ? outerState : or(stateAtLabel, outerState); + return true; + } + function checkUnreachable(node) { + switch (currentReachabilityState) { + case 4 /* Unreachable */: + var reportError = + // report error on all statements + ts.isStatement(node) || + // report error on class declarations + node.kind === 214 /* ClassDeclaration */ || + // report error on instantiated modules or const-enums only modules if preserveConstEnums is set + (node.kind === 218 /* ModuleDeclaration */ && shouldReportErrorOnModuleDeclaration(node)) || + // report error on regular enums and const enums if preserveConstEnums is set + (node.kind === 217 /* EnumDeclaration */ && (!ts.isConstEnumDeclaration(node) || options.preserveConstEnums)); + if (reportError) { + currentReachabilityState = 8 /* ReportedUnreachable */; + // 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 + var reportUnreachableCode = !options.allowUnreachableCode && + !ts.isInAmbientContext(node) && + (node.kind !== 193 /* VariableStatement */ || + ts.getCombinedNodeFlags(node.declarationList) & 24576 /* BlockScoped */ || + ts.forEach(node.declarationList.declarations, function (d) { return d.initializer; })); + if (reportUnreachableCode) { + errorOnFirstToken(node, ts.Diagnostics.Unreachable_code_detected); + } + } + case 8 /* ReportedUnreachable */: + return true; + default: + return false; + } + function shouldReportErrorOnModuleDeclaration(node) { + var instanceState = getModuleInstanceState(node); + return instanceState === 1 /* Instantiated */ || (instanceState === 2 /* ConstEnumOnly */ && options.preserveConstEnums); + } + } + function initializeReachabilityStateIfNecessary() { + if (labelIndexMap) { + return; + } + currentReachabilityState = 2 /* Reachable */; + labelIndexMap = {}; + labelStack = []; + implicitLabels = []; + } } })(ts || (ts = {})); /// @@ -5127,8 +5499,8 @@ var ts; function getDeclarationOfKind(symbol, kind) { var declarations = symbol.declarations; if (declarations) { - for (var _i = 0; _i < declarations.length; _i++) { - var declaration = declarations[_i]; + for (var _i = 0, declarations_1 = declarations; _i < declarations_1.length; _i++) { + var declaration = declarations_1[_i]; if (declaration.kind === kind) { return declaration; } @@ -5328,7 +5700,7 @@ var ts; } ts.makeIdentifierFromModuleName = makeIdentifierFromModuleName; function isBlockOrCatchScoped(declaration) { - return (getCombinedNodeFlags(declaration) & 49152 /* BlockScoped */) !== 0 || + return (getCombinedNodeFlags(declaration) & 24576 /* BlockScoped */) !== 0 || isCatchClauseVariableDeclaration(declaration); } ts.isBlockOrCatchScoped = isBlockOrCatchScoped; @@ -5441,7 +5813,7 @@ var ts; } ts.isExternalModule = isExternalModule; function isDeclarationFile(file) { - return (file.flags & 8192 /* DeclarationFile */) !== 0; + return (file.flags & 4096 /* DeclarationFile */) !== 0; } ts.isDeclarationFile = isDeclarationFile; function isConstEnumDeclaration(node) { @@ -5478,11 +5850,11 @@ var ts; } ts.getCombinedNodeFlags = getCombinedNodeFlags; function isConst(node) { - return !!(getCombinedNodeFlags(node) & 32768 /* Const */); + return !!(getCombinedNodeFlags(node) & 16384 /* Const */); } ts.isConst = isConst; function isLet(node) { - return !!(getCombinedNodeFlags(node) & 16384 /* Let */); + return !!(getCombinedNodeFlags(node) & 8192 /* Let */); } ts.isLet = isLet; function isPrologueDirective(node) { @@ -5683,27 +6055,28 @@ var ts; } ts.isClassLike = isClassLike; function isFunctionLike(node) { - if (node) { - switch (node.kind) { - case 144 /* Constructor */: - case 173 /* FunctionExpression */: - case 213 /* FunctionDeclaration */: - case 174 /* ArrowFunction */: - case 143 /* MethodDeclaration */: - case 142 /* MethodSignature */: - case 145 /* GetAccessor */: - case 146 /* SetAccessor */: - case 147 /* CallSignature */: - case 148 /* ConstructSignature */: - case 149 /* IndexSignature */: - case 152 /* FunctionType */: - case 153 /* ConstructorType */: - return true; - } - } - return false; + return node && isFunctionLikeKind(node.kind); } ts.isFunctionLike = isFunctionLike; + function isFunctionLikeKind(kind) { + switch (kind) { + case 144 /* Constructor */: + case 173 /* FunctionExpression */: + case 213 /* FunctionDeclaration */: + case 174 /* ArrowFunction */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: + case 147 /* CallSignature */: + case 148 /* ConstructSignature */: + case 149 /* IndexSignature */: + case 152 /* FunctionType */: + case 153 /* ConstructorType */: + return true; + } + } + ts.isFunctionLikeKind = isFunctionLikeKind; function introducesArgumentsExoticObject(node) { switch (node.kind) { case 143 /* MethodDeclaration */: @@ -6206,9 +6579,18 @@ var ts; return !!node && (node.kind === 162 /* ArrayBindingPattern */ || node.kind === 161 /* ObjectBindingPattern */); } ts.isBindingPattern = isBindingPattern; + function isNodeDescendentOf(node, ancestor) { + while (node) { + if (node === ancestor) + return true; + node = node.parent; + } + return false; + } + ts.isNodeDescendentOf = isNodeDescendentOf; function isInAmbientContext(node) { while (node) { - if (node.flags & (2 /* Ambient */ | 8192 /* DeclarationFile */)) { + if (node.flags & (4 /* Ambient */ | 4096 /* DeclarationFile */)) { return true; } node = node.parent; @@ -6266,7 +6648,7 @@ var ts; case 207 /* LabeledStatement */: case 204 /* ReturnStatement */: case 206 /* SwitchStatement */: - case 98 /* ThrowKeyword */: + case 208 /* ThrowStatement */: case 209 /* TryStatement */: case 193 /* VariableStatement */: case 198 /* WhileStatement */: @@ -6379,8 +6761,8 @@ var ts; ts.getInterfaceBaseTypeNodes = getInterfaceBaseTypeNodes; function getHeritageClause(clauses, kind) { if (clauses) { - for (var _i = 0; _i < clauses.length; _i++) { - var clause = clauses[_i]; + for (var _i = 0, clauses_1 = clauses; _i < clauses_1.length; _i++) { + var clause = clauses_1[_i]; if (clause.token === kind) { return clause; } @@ -6392,7 +6774,6 @@ var ts; function tryResolveScriptReference(host, sourceFile, reference) { if (!host.getCompilerOptions().noResolve) { var referenceFileName = ts.isRootedDiskPath(reference.fileName) ? reference.fileName : ts.combinePaths(ts.getDirectoryPath(sourceFile.fileName), reference.fileName); - referenceFileName = ts.getNormalizedAbsolutePath(referenceFileName, host.getCurrentDirectory()); return host.getSourceFile(referenceFileName); } } @@ -6450,7 +6831,7 @@ var ts; } ts.isTrivia = isTrivia; function isAsyncFunctionLike(node) { - return isFunctionLike(node) && (node.flags & 512 /* Async */) !== 0 && !isAccessor(node); + return isFunctionLike(node) && (node.flags & 256 /* Async */) !== 0 && !isAccessor(node); } ts.isAsyncFunctionLike = isAsyncFunctionLike; /** @@ -6837,7 +7218,7 @@ var ts; else { ts.forEach(declarations, function (member) { if ((member.kind === 145 /* GetAccessor */ || member.kind === 146 /* SetAccessor */) - && (member.flags & 128 /* Static */) === (accessor.flags & 128 /* Static */)) { + && (member.flags & 64 /* Static */) === (accessor.flags & 64 /* Static */)) { var memberName = getPropertyNameForPropertyNameNode(member.name); var accessorName = getPropertyNameForPropertyNameNode(accessor.name); if (memberName === accessorName) { @@ -6894,6 +7275,66 @@ var ts; }); } ts.emitComments = emitComments; + /** + * Detached comment is a comment at the top of file or function body that is separated from + * the next statement by space. + */ + function emitDetachedComments(currentSourceFile, writer, writeComment, node, newLine, removeComments) { + var leadingComments; + var currentDetachedCommentInfo; + if (removeComments) { + // removeComments is true, only reserve pinned comment at the top of file + // For example: + // /*! Pinned Comment */ + // + // var x = 10; + if (node.pos === 0) { + leadingComments = ts.filter(ts.getLeadingCommentRanges(currentSourceFile.text, node.pos), isPinnedComment); + } + } + else { + // removeComments is false, just get detached as normal and bypass the process to filter comment + leadingComments = ts.getLeadingCommentRanges(currentSourceFile.text, node.pos); + } + if (leadingComments) { + var detachedComments = []; + var lastComment; + for (var _i = 0, leadingComments_1 = leadingComments; _i < leadingComments_1.length; _i++) { + var comment = leadingComments_1[_i]; + if (lastComment) { + var lastCommentLine = getLineOfLocalPosition(currentSourceFile, lastComment.end); + var commentLine = getLineOfLocalPosition(currentSourceFile, comment.pos); + if (commentLine >= lastCommentLine + 2) { + // There was a blank line between the last comment and this comment. This + // comment is not part of the copyright comments. Return what we have so + // far. + break; + } + } + detachedComments.push(comment); + lastComment = comment; + } + if (detachedComments.length) { + // All comments look like they could have been part of the copyright header. Make + // sure there is at least one blank line between it and the node. If not, it's not + // a copyright header. + var lastCommentLine = getLineOfLocalPosition(currentSourceFile, ts.lastOrUndefined(detachedComments).end); + var nodeLine = getLineOfLocalPosition(currentSourceFile, ts.skipTrivia(currentSourceFile.text, node.pos)); + if (nodeLine >= lastCommentLine + 2) { + // Valid detachedComments + emitNewLineBeforeLeadingComments(currentSourceFile, writer, node, leadingComments); + emitComments(currentSourceFile, writer, detachedComments, /*trailingSeparator*/ true, newLine, writeComment); + currentDetachedCommentInfo = { nodePos: node.pos, detachedCommentEndPos: ts.lastOrUndefined(detachedComments).end }; + } + } + } + return currentDetachedCommentInfo; + function isPinnedComment(comment) { + return currentSourceFile.text.charCodeAt(comment.pos + 1) === 42 /* asterisk */ && + currentSourceFile.text.charCodeAt(comment.pos + 2) === 33 /* exclamation */; + } + } + ts.emitDetachedComments = emitDetachedComments; function writeCommentRange(currentSourceFile, writer, comment, newLine) { if (currentSourceFile.text.charCodeAt(comment.pos + 1) === 42 /* asterisk */) { var firstCommentLineAndCharacter = ts.getLineAndCharacterOfPosition(currentSourceFile, comment.pos); @@ -6983,16 +7424,16 @@ var ts; ts.writeCommentRange = writeCommentRange; function modifierToFlag(token) { switch (token) { - case 113 /* StaticKeyword */: return 128 /* Static */; - case 112 /* PublicKeyword */: return 16 /* Public */; - case 111 /* ProtectedKeyword */: return 64 /* Protected */; - case 110 /* PrivateKeyword */: return 32 /* Private */; - case 115 /* AbstractKeyword */: return 256 /* Abstract */; - case 82 /* ExportKeyword */: return 1 /* Export */; - case 122 /* DeclareKeyword */: return 2 /* Ambient */; - case 74 /* ConstKeyword */: return 32768 /* Const */; - case 77 /* DefaultKeyword */: return 1024 /* Default */; - case 118 /* AsyncKeyword */: return 512 /* Async */; + case 113 /* StaticKeyword */: return 64 /* Static */; + case 112 /* PublicKeyword */: return 8 /* Public */; + case 111 /* ProtectedKeyword */: return 32 /* Protected */; + case 110 /* PrivateKeyword */: return 16 /* Private */; + case 115 /* AbstractKeyword */: return 128 /* Abstract */; + case 82 /* ExportKeyword */: return 2 /* Export */; + case 122 /* DeclareKeyword */: return 4 /* Ambient */; + case 74 /* ConstKeyword */: return 16384 /* Const */; + case 77 /* DefaultKeyword */: return 512 /* Default */; + case 118 /* AsyncKeyword */: return 256 /* Async */; } return 0; } @@ -7073,7 +7514,7 @@ var ts; } ts.isEmptyObjectLiteralOrArrayLiteral = isEmptyObjectLiteralOrArrayLiteral; function getLocalSymbolForExportDefault(symbol) { - return symbol && symbol.valueDeclaration && (symbol.valueDeclaration.flags & 1024 /* Default */) ? symbol.valueDeclaration.localSymbol : undefined; + return symbol && symbol.valueDeclaration && (symbol.valueDeclaration.flags & 512 /* Default */) ? symbol.valueDeclaration.localSymbol : undefined; } ts.getLocalSymbolForExportDefault = getLocalSymbolForExportDefault; function isJavaScript(fileName) { @@ -7150,6 +7591,12 @@ 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) { @@ -7414,8 +7861,8 @@ var ts; } function visitEachNode(cbNode, nodes) { if (nodes) { - for (var _i = 0; _i < nodes.length; _i++) { - var node = nodes[_i]; + for (var _i = 0, nodes_1 = nodes; _i < nodes_1.length; _i++) { + var node = nodes_1[_i]; var result = cbNode(node); if (result) { return result; @@ -7982,8 +8429,8 @@ var ts; function addJSDocComment(node) { var comments = ts.getLeadingCommentRangesOfNode(node, sourceFile); if (comments) { - for (var _i = 0; _i < comments.length; _i++) { - var comment = comments[_i]; + for (var _i = 0, comments_1 = comments; _i < comments_1.length; _i++) { + var comment = comments_1[_i]; var jsDocComment = JSDocParser.parseJSDocComment(node, comment.pos, comment.end - comment.pos); if (jsDocComment) { node.jsDocComment = jsDocComment; @@ -8021,7 +8468,7 @@ var ts; sourceFile.bindDiagnostics = []; sourceFile.languageVersion = languageVersion; sourceFile.fileName = ts.normalizePath(fileName); - sourceFile.flags = ts.fileExtensionIs(sourceFile.fileName, ".d.ts") ? 8192 /* DeclarationFile */ : 0; + sourceFile.flags = ts.fileExtensionIs(sourceFile.fileName, ".d.ts") ? 4096 /* DeclarationFile */ : 0; sourceFile.languageVariant = ts.isTsx(sourceFile.fileName) ? 1 /* JSX */ : 0 /* Standard */; return sourceFile; } @@ -9079,7 +9526,7 @@ var ts; if (node.kind === 8 /* NumericLiteral */ && sourceText.charCodeAt(tokenPos) === 48 /* _0 */ && ts.isOctalDigit(sourceText.charCodeAt(tokenPos + 1))) { - node.flags |= 65536 /* OctalLiteral */; + node.flags |= 32768 /* OctalLiteral */; } return node; } @@ -9832,7 +10279,7 @@ var ts; // Didn't appear to actually be a parenthesized arrow function. Just bail out. return undefined; } - var isAsync = !!(arrowFunction.flags & 512 /* Async */); + var isAsync = !!(arrowFunction.flags & 256 /* Async */); // 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; @@ -9959,7 +10406,7 @@ var ts; function parseParenthesizedArrowFunctionExpressionHead(allowAmbiguity) { var node = createNode(174 /* ArrowFunction */); setModifiers(node, parseModifiersForArrowFunction()); - var isAsync = !!(node.flags & 512 /* Async */); + var isAsync = !!(node.flags & 256 /* Async */); // Arrow functions are never generators. // // If we're speculatively parsing a signature for a parenthesized arrow function, then @@ -10802,7 +11249,7 @@ var ts; var node = createNode(164 /* ArrayLiteralExpression */); parseExpected(19 /* OpenBracketToken */); if (scanner.hasPrecedingLineBreak()) - node.flags |= 2048 /* MultiLine */; + node.flags |= 1024 /* MultiLine */; node.elements = parseDelimitedList(15 /* ArrayLiteralMembers */, parseArgumentOrArrayLiteralElement); parseExpected(20 /* CloseBracketToken */); return finishNode(node); @@ -10863,7 +11310,7 @@ var ts; var node = createNode(165 /* ObjectLiteralExpression */); parseExpected(15 /* OpenBraceToken */); if (scanner.hasPrecedingLineBreak()) { - node.flags |= 2048 /* MultiLine */; + node.flags |= 1024 /* MultiLine */; } node.properties = parseDelimitedList(12 /* ObjectLiteralMembers */, parseObjectLiteralElement, /*considerSemicolonAsDelimeter*/ true); parseExpected(16 /* CloseBraceToken */); @@ -10884,7 +11331,7 @@ var ts; parseExpected(87 /* FunctionKeyword */); node.asteriskToken = parseOptionalToken(37 /* AsteriskToken */); var isGenerator = !!node.asteriskToken; - var isAsync = !!(node.flags & 512 /* Async */); + var isAsync = !!(node.flags & 256 /* Async */); node.name = isGenerator && isAsync ? doInYieldAndAwaitContext(parseOptionalIdentifier) : isGenerator ? doInYieldContext(parseOptionalIdentifier) : @@ -11476,10 +11923,10 @@ var ts; case 102 /* VarKeyword */: break; case 108 /* LetKeyword */: - node.flags |= 16384 /* Let */; + node.flags |= 8192 /* Let */; break; case 74 /* ConstKeyword */: - node.flags |= 32768 /* Const */; + node.flags |= 16384 /* Const */; break; default: ts.Debug.fail(); @@ -11522,9 +11969,9 @@ var ts; setModifiers(node, modifiers); parseExpected(87 /* FunctionKeyword */); node.asteriskToken = parseOptionalToken(37 /* AsteriskToken */); - node.name = node.flags & 1024 /* Default */ ? parseOptionalIdentifier() : parseIdentifier(); + node.name = node.flags & 512 /* Default */ ? parseOptionalIdentifier() : parseIdentifier(); var isGenerator = !!node.asteriskToken; - var isAsync = !!(node.flags & 512 /* Async */); + var isAsync = !!(node.flags & 256 /* Async */); fillSignature(54 /* ColonToken */, /*yieldContext*/ isGenerator, /*awaitContext*/ isAsync, /*requireCompleteParameterList*/ false, node); node.body = parseFunctionBlockOrSemicolon(isGenerator, isAsync, ts.Diagnostics.or_expected); return finishNode(node); @@ -11546,7 +11993,7 @@ var ts; method.name = name; method.questionToken = questionToken; var isGenerator = !!asteriskToken; - var isAsync = !!(method.flags & 512 /* Async */); + var isAsync = !!(method.flags & 256 /* Async */); fillSignature(54 /* ColonToken */, /*yieldContext*/ isGenerator, /*awaitContext*/ isAsync, /*requireCompleteParameterList*/ false, method); method.body = parseFunctionBlockOrSemicolon(isGenerator, isAsync, diagnosticMessage); return finishNode(method); @@ -11567,7 +12014,7 @@ var ts; // AccessibilityModifier_opt static_opt PropertyName TypeAnnotation_opt Initialiser_opt[In, ?Yield]; // // The checker may still error in the static case to explicitly disallow the yield expression. - property.initializer = modifiers && modifiers.flags & 128 /* Static */ + property.initializer = modifiers && modifiers.flags & 64 /* Static */ ? allowInAnd(parseNonParameterInitializer) : doOutsideOfContext(2 /* Yield */ | 1 /* DisallowIn */, parseNonParameterInitializer); parseSemicolon(); @@ -11900,13 +12347,13 @@ var ts; var node = createNode(218 /* ModuleDeclaration */, fullStart); // If we are parsing a dotted namespace name, we want to // propagate the 'Namespace' flag across the names if set. - var namespaceFlag = flags & 131072 /* Namespace */; + var namespaceFlag = flags & 65536 /* Namespace */; node.decorators = decorators; setModifiers(node, modifiers); node.flags |= flags; node.name = parseIdentifier(); node.body = parseOptional(21 /* DotToken */) - ? parseModuleOrNamespaceDeclaration(getNodePos(), /*decorators*/ undefined, /*modifiers*/ undefined, 1 /* Export */ | namespaceFlag) + ? parseModuleOrNamespaceDeclaration(getNodePos(), /*decorators*/ undefined, /*modifiers*/ undefined, 2 /* Export */ | namespaceFlag) : parseModuleBlock(); return finishNode(node); } @@ -11921,7 +12368,7 @@ var ts; function parseModuleDeclaration(fullStart, decorators, modifiers) { var flags = modifiers ? modifiers.flags : 0; if (parseOptional(126 /* NamespaceKeyword */)) { - flags |= 131072 /* Namespace */; + flags |= 65536 /* Namespace */; } else { parseExpected(125 /* ModuleKeyword */); @@ -12179,7 +12626,7 @@ var ts; } function setExternalModuleIndicator(sourceFile) { sourceFile.externalModuleIndicator = ts.forEach(sourceFile.statements, function (node) { - return node.flags & 1 /* Export */ + return node.flags & 2 /* Export */ || node.kind === 221 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 232 /* ExternalModuleReference */ || node.kind === 222 /* ImportDeclaration */ || node.kind === 227 /* ExportAssignment */ @@ -12868,8 +13315,8 @@ var ts; array._children = undefined; array.pos += delta; array.end += delta; - for (var _i = 0; _i < array.length; _i++) { - var node = array[_i]; + for (var _i = 0, array_7 = array; _i < array_7.length; _i++) { + var node = array_7[_i]; visitNode(node); } } @@ -13006,8 +13453,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; _i < array.length; _i++) { - var node = array[_i]; + for (var _i = 0, array_8 = array; _i < array_8.length; _i++) { + var node = array_8[_i]; visitNode(node); } return; @@ -13374,6 +13821,7 @@ var ts; var getInstantiatedGlobalPromiseLikeType; var getGlobalPromiseConstructorLikeType; var getGlobalThenableType; + var jsxElementClassType; var tupleTypes = {}; var unionTypes = {}; var intersectionTypes = {}; @@ -13643,7 +14091,7 @@ var ts; } var initializerOfNonStaticProperty = current.parent && current.parent.kind === 141 /* PropertyDeclaration */ && - (current.parent.flags & 128 /* Static */) === 0 && + (current.parent.flags & 64 /* Static */) === 0 && current.parent.initializer === current; if (initializerOfNonStaticProperty) { return true; @@ -13725,7 +14173,7 @@ var ts; // local variables of the constructor. This effectively means that entities from outer scopes // by the same name as a constructor parameter or local variable are inaccessible // in initializer expressions for instance member variables. - if (ts.isClassLike(location.parent) && !(location.flags & 128 /* Static */)) { + if (ts.isClassLike(location.parent) && !(location.flags & 64 /* Static */)) { var ctor = findConstructorDeclaration(location.parent); if (ctor && ctor.locals) { if (getSymbol(ctor.locals, name, meaning & 107455 /* Value */)) { @@ -13739,7 +14187,7 @@ var ts; case 186 /* ClassExpression */: case 215 /* InterfaceDeclaration */: if (result = getSymbol(getSymbolOfNode(location).members, name, meaning & 793056 /* Type */)) { - if (lastLocation && lastLocation.flags & 128 /* Static */) { + if (lastLocation && lastLocation.flags & 64 /* Static */) { // TypeScript 1.0 spec (April 2014): 3.4.1 // The scope of a type parameter extends over the entire declaration with which the type // parameter list is associated, with the exception of static member declarations in classes. @@ -14267,8 +14715,8 @@ var ts; } function findConstructorDeclaration(node) { var members = node.members; - for (var _i = 0; _i < members.length; _i++) { - var member = members[_i]; + for (var _i = 0, members_1 = members; _i < members_1.length; _i++) { + var member = members_1[_i]; if (member.kind === 144 /* Constructor */ && ts.nodeIsPresent(member.body)) { return member; } @@ -14515,7 +14963,7 @@ var ts; // because these kind of aliases can be used to name types in declaration file var anyImportSyntax = getAnyImportSyntax(declaration); if (anyImportSyntax && - !(anyImportSyntax.flags & 1 /* Export */) && + !(anyImportSyntax.flags & 2 /* Export */) && isDeclarationVisible(anyImportSyntax.parent)) { getNodeLinks(declaration).isVisible = true; if (aliasesToMakeVisible) { @@ -14669,8 +15117,8 @@ var ts; walkSymbol(getParentOfSymbol(accessibleSymbolChain ? accessibleSymbolChain[0] : symbol), getQualifiedLeftMeaning(meaning)); } if (accessibleSymbolChain) { - for (var _i = 0; _i < accessibleSymbolChain.length; _i++) { - var accessibleSymbol = accessibleSymbolChain[_i]; + for (var _i = 0, accessibleSymbolChain_1 = accessibleSymbolChain; _i < accessibleSymbolChain_1.length; _i++) { + var accessibleSymbol = accessibleSymbolChain_1[_i]; appendParentTypeArgumentsAndSymbolName(accessibleSymbol); } } @@ -14860,7 +15308,7 @@ var ts; } function shouldWriteTypeOfFunctionSymbol() { var isStaticMethodSymbol = !!(symbol.flags & 8192 /* Method */ && - ts.forEach(symbol.declarations, function (declaration) { return declaration.flags & 128 /* Static */; })); + ts.forEach(symbol.declarations, function (declaration) { return declaration.flags & 64 /* Static */; })); var isNonLocalFunctionSymbol = !!(symbol.flags & 16 /* Function */) && (symbol.parent || ts.forEach(symbol.declarations, function (declaration) { @@ -14971,8 +15419,8 @@ var ts; var t = getTypeOfSymbol(p); if (p.flags & (16 /* Function */ | 8192 /* Method */) && !getPropertiesOfObjectType(t).length) { var signatures = getSignaturesOfType(t, 0 /* Call */); - for (var _f = 0; _f < signatures.length; _f++) { - var signature = signatures[_f]; + for (var _f = 0, signatures_1 = signatures; _f < signatures_1.length; _f++) { + var signature = signatures_1[_f]; buildSymbolDisplay(p, writer); if (p.flags & 536870912 /* Optional */) { writePunctuation(writer, 53 /* QuestionToken */); @@ -15186,7 +15634,7 @@ var ts; case 221 /* ImportEqualsDeclaration */: var parent_4 = getDeclarationContainer(node); // If the node is not exported or it is not ambient module element (except import declaration) - if (!(ts.getCombinedNodeFlags(node) & 1 /* Export */) && + if (!(ts.getCombinedNodeFlags(node) & 2 /* Export */) && !(node.kind !== 221 /* ImportEqualsDeclaration */ && parent_4.kind !== 248 /* SourceFile */ && ts.isInAmbientContext(parent_4))) { return isGlobalSourceFile(parent_4); } @@ -15198,7 +15646,7 @@ var ts; case 146 /* SetAccessor */: case 143 /* MethodDeclaration */: case 142 /* MethodSignature */: - if (node.flags & (32 /* Private */ | 64 /* Protected */)) { + if (node.flags & (16 /* Private */ | 32 /* Protected */)) { // Private/protected properties/methods are not visible return false; } @@ -15728,8 +16176,8 @@ var ts; // The function allocates a new array if the input type parameter set is undefined, but otherwise it modifies the set // in-place and returns the same array. function appendTypeParameters(typeParameters, declarations) { - for (var _i = 0; _i < declarations.length; _i++) { - var declaration = declarations[_i]; + for (var _i = 0, declarations_2 = declarations; _i < declarations_2.length; _i++) { + var declaration = declarations_2[_i]; var tp = getDeclaredTypeOfTypeParameter(getSymbolOfNode(declaration)); if (!typeParameters) { typeParameters = [tp]; @@ -15934,13 +16382,13 @@ var ts; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; if (declaration.kind === 215 /* InterfaceDeclaration */) { - if (declaration.flags & 524288 /* ContainsThis */) { + if (declaration.flags & 262144 /* ContainsThis */) { return false; } var baseTypeNodes = ts.getInterfaceBaseTypeNodes(declaration); if (baseTypeNodes) { - for (var _b = 0; _b < baseTypeNodes.length; _b++) { - var node = baseTypeNodes[_b]; + for (var _b = 0, baseTypeNodes_1 = baseTypeNodes; _b < baseTypeNodes_1.length; _b++) { + var node = baseTypeNodes_1[_b]; if (ts.isSupportedExpressionWithTypeArguments(node)) { var baseSymbol = resolveEntityName(node.expression, 793056 /* Type */, /*ignoreErrors*/ true); if (!baseSymbol || !(baseSymbol.flags & 64 /* Interface */) || getDeclaredTypeOfClassOrInterface(baseSymbol).thisType) { @@ -16130,8 +16578,8 @@ var ts; } function createSymbolTable(symbols) { var result = {}; - for (var _i = 0; _i < symbols.length; _i++) { - var symbol = symbols[_i]; + for (var _i = 0, symbols_1 = symbols; _i < symbols_1.length; _i++) { + var symbol = symbols_1[_i]; result[symbol.name] = symbol; } return result; @@ -16140,15 +16588,15 @@ var ts; // we check symbols to see if we can quickly conclude they are free of "this" references, thus needing no instantiation. function createInstantiatedSymbolTable(symbols, mapper, mappingThisOnly) { var result = {}; - for (var _i = 0; _i < symbols.length; _i++) { - var symbol = symbols[_i]; + for (var _i = 0, symbols_2 = symbols; _i < symbols_2.length; _i++) { + var symbol = symbols_2[_i]; result[symbol.name] = mappingThisOnly && isIndependentMember(symbol) ? symbol : instantiateSymbol(symbol, mapper); } return result; } function addInheritedMembers(symbols, baseSymbols) { - for (var _i = 0; _i < baseSymbols.length; _i++) { - var s = baseSymbols[_i]; + for (var _i = 0, baseSymbols_1 = baseSymbols; _i < baseSymbols_1.length; _i++) { + var s = baseSymbols_1[_i]; if (!ts.hasProperty(symbols, s.name)) { symbols[s.name] = s; } @@ -16156,8 +16604,8 @@ var ts; } function addInheritedSignatures(signatures, baseSignatures) { if (baseSignatures) { - for (var _i = 0; _i < baseSignatures.length; _i++) { - var signature = baseSignatures[_i]; + for (var _i = 0, baseSignatures_1 = baseSignatures; _i < baseSignatures_1.length; _i++) { + var signature = baseSignatures_1[_i]; signatures.push(signature); } } @@ -16200,8 +16648,8 @@ var ts; members = createSymbolTable(source.declaredProperties); } var thisArgument = ts.lastOrUndefined(typeArguments); - for (var _i = 0; _i < baseTypes.length; _i++) { - var baseType = baseTypes[_i]; + for (var _i = 0, baseTypes_1 = baseTypes; _i < baseTypes_1.length; _i++) { + var baseType = baseTypes_1[_i]; var instantiatedBaseType = thisArgument ? getTypeWithThisArgument(instantiateType(baseType, mapper), thisArgument) : baseType; addInheritedMembers(members, getPropertiesOfObjectType(instantiatedBaseType)); callSignatures = ts.concatenate(callSignatures, getSignaturesOfType(instantiatedBaseType, 0 /* Call */)); @@ -16247,8 +16695,8 @@ var ts; var typeArguments = ts.map(baseTypeNode.typeArguments, getTypeFromTypeNode); var typeArgCount = typeArguments ? typeArguments.length : 0; var result = []; - for (var _i = 0; _i < baseSignatures.length; _i++) { - var baseSig = baseSignatures[_i]; + for (var _i = 0, baseSignatures_2 = baseSignatures; _i < baseSignatures_2.length; _i++) { + var baseSig = baseSignatures_2[_i]; var typeParamCount = baseSig.typeParameters ? baseSig.typeParameters.length : 0; if (typeParamCount === typeArgCount) { var sig = typeParamCount ? getSignatureInstantiation(baseSig, typeArguments) : cloneSignature(baseSig); @@ -16277,8 +16725,8 @@ var ts; setObjectTypeMembers(type, members, arrayType.callSignatures, arrayType.constructSignatures, arrayType.stringIndexType, arrayType.numberIndexType); } function findMatchingSignature(signatureList, signature, partialMatch, ignoreReturnTypes) { - for (var _i = 0; _i < signatureList.length; _i++) { - var s = signatureList[_i]; + for (var _i = 0, signatureList_1 = signatureList; _i < signatureList_1.length; _i++) { + var s = signatureList_1[_i]; if (compareSignatures(s, signature, partialMatch, ignoreReturnTypes, compareTypes)) { return s; } @@ -16342,8 +16790,8 @@ var ts; } function getUnionIndexType(types, kind) { var indexTypes = []; - for (var _i = 0; _i < types.length; _i++) { - var type = types[_i]; + for (var _i = 0, types_1 = types; _i < types_1.length; _i++) { + var type = types_1[_i]; var indexType = getIndexTypeOfType(type, kind); if (!indexType) { return undefined; @@ -16522,12 +16970,12 @@ var ts; function createUnionOrIntersectionProperty(containingType, name) { var types = containingType.types; var props; - for (var _i = 0; _i < types.length; _i++) { - var current = types[_i]; + for (var _i = 0, types_2 = types; _i < types_2.length; _i++) { + var current = types_2[_i]; var type = getApparentType(current); if (type !== unknownType) { var prop = getPropertyOfType(type, name); - if (prop && !(getDeclarationFlagsFromSymbol(prop) & (32 /* Private */ | 64 /* Protected */))) { + if (prop && !(getDeclarationFlagsFromSymbol(prop) & (16 /* Private */ | 32 /* Protected */))) { if (!props) { props = [prop]; } @@ -16549,8 +16997,8 @@ var ts; } var propTypes = []; var declarations = []; - for (var _a = 0; _a < props.length; _a++) { - var prop = props[_a]; + for (var _a = 0, props_1 = props; _a < props_1.length; _a++) { + var prop = props_1[_a]; if (prop.declarations) { ts.addRange(declarations, prop.declarations); } @@ -16908,8 +17356,8 @@ var ts; // that care about the presence of such types at arbitrary depth in a containing type. function getPropagatingFlagsOfTypes(types) { var result = 0; - for (var _i = 0; _i < types.length; _i++) { - var type = types[_i]; + for (var _i = 0, types_3 = types; _i < types_3.length; _i++) { + var type = types_3[_i]; result |= type.flags; } return result & 14680064 /* PropagatingFlags */; @@ -17059,8 +17507,8 @@ var ts; function getTypeOfGlobalSymbol(symbol, arity) { function getTypeDeclaration(symbol) { var declarations = symbol.declarations; - for (var _i = 0; _i < declarations.length; _i++) { - var declaration = declarations[_i]; + for (var _i = 0, declarations_3 = declarations; _i < declarations_3.length; _i++) { + var declaration = declarations_3[_i]; switch (declaration.kind) { case 214 /* ClassDeclaration */: case 215 /* InterfaceDeclaration */: @@ -17170,8 +17618,8 @@ var ts; // Add the given types to the given type set. Order is preserved, duplicates are removed, // and nested types of the given kind are flattened into the set. function addTypesToSet(typeSet, types, typeSetKind) { - for (var _i = 0; _i < types.length; _i++) { - var type = types[_i]; + for (var _i = 0, types_4 = types; _i < types_4.length; _i++) { + var type = types_4[_i]; addTypeToSet(typeSet, type, typeSetKind); } } @@ -17193,8 +17641,8 @@ var ts; } } function containsTypeAny(types) { - for (var _i = 0; _i < types.length; _i++) { - var type = types[_i]; + for (var _i = 0, types_5 = types; _i < types_5.length; _i++) { + var type = types_5[_i]; if (isTypeAny(type)) { return true; } @@ -17310,7 +17758,8 @@ var ts; var container = ts.getThisContainer(node, /*includeArrowFunctions*/ false); var parent = container && container.parent; if (parent && (ts.isClassLike(parent) || parent.kind === 215 /* InterfaceDeclaration */)) { - if (!(container.flags & 128 /* Static */)) { + if (!(container.flags & 64 /* Static */) && + (container.kind !== 144 /* Constructor */ || ts.isNodeDescendentOf(node, container.body))) { return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(parent)).thisType; } } @@ -17377,8 +17826,8 @@ var ts; function instantiateList(items, mapper, instantiator) { if (items && items.length) { var result = []; - for (var _i = 0; _i < items.length; _i++) { - var v = items[_i]; + for (var _i = 0, items_1 = items; _i < items_1.length; _i++) { + var v = items_1[_i]; result.push(instantiator(v, mapper)); } return result; @@ -17417,8 +17866,8 @@ var ts; case 2: return createBinaryTypeEraser(sources[0], sources[1]); } return function (t) { - for (var _i = 0; _i < sources.length; _i++) { - var source = sources[_i]; + for (var _i = 0, sources_1 = sources; _i < sources_1.length; _i++) { + var source = sources_1[_i]; if (t === source) { return anyType; } @@ -17836,8 +18285,8 @@ var ts; function eachTypeRelatedToSomeType(source, target) { var result = -1 /* True */; var sourceTypes = source.types; - for (var _i = 0; _i < sourceTypes.length; _i++) { - var sourceType = sourceTypes[_i]; + for (var _i = 0, sourceTypes_1 = sourceTypes; _i < sourceTypes_1.length; _i++) { + var sourceType = sourceTypes_1[_i]; var related = typeRelatedToSomeType(sourceType, target, false); if (!related) { return 0 /* False */; @@ -17859,8 +18308,8 @@ var ts; function typeRelatedToEachType(source, target, reportErrors) { var result = -1 /* True */; var targetTypes = target.types; - for (var _i = 0; _i < targetTypes.length; _i++) { - var targetType = targetTypes[_i]; + for (var _i = 0, targetTypes_1 = targetTypes; _i < targetTypes_1.length; _i++) { + var targetType = targetTypes_1[_i]; var related = isRelatedTo(source, targetType, reportErrors); if (!related) { return 0 /* False */; @@ -17882,8 +18331,8 @@ var ts; function eachTypeRelatedToType(source, target, reportErrors) { var result = -1 /* True */; var sourceTypes = source.types; - for (var _i = 0; _i < sourceTypes.length; _i++) { - var sourceType = sourceTypes[_i]; + for (var _i = 0, sourceTypes_2 = sourceTypes; _i < sourceTypes_2.length; _i++) { + var sourceType = sourceTypes_2[_i]; var related = isRelatedTo(sourceType, target, reportErrors); if (!related) { return 0 /* False */; @@ -18008,8 +18457,8 @@ var ts; var result = -1 /* True */; var properties = getPropertiesOfObjectType(target); var requireOptionalProperties = relation === subtypeRelation && !(source.flags & 524288 /* ObjectLiteral */); - for (var _i = 0; _i < properties.length; _i++) { - var targetProp = properties[_i]; + for (var _i = 0, properties_1 = properties; _i < properties_1.length; _i++) { + var targetProp = properties_1[_i]; var sourceProp = getPropertyOfType(source, targetProp.name); if (sourceProp !== targetProp) { if (!sourceProp) { @@ -18023,20 +18472,20 @@ var ts; else if (!(targetProp.flags & 134217728 /* Prototype */)) { var sourcePropFlags = getDeclarationFlagsFromSymbol(sourceProp); var targetPropFlags = getDeclarationFlagsFromSymbol(targetProp); - if (sourcePropFlags & 32 /* Private */ || targetPropFlags & 32 /* Private */) { + if (sourcePropFlags & 16 /* Private */ || targetPropFlags & 16 /* Private */) { if (sourceProp.valueDeclaration !== targetProp.valueDeclaration) { if (reportErrors) { - if (sourcePropFlags & 32 /* Private */ && targetPropFlags & 32 /* Private */) { + if (sourcePropFlags & 16 /* Private */ && targetPropFlags & 16 /* Private */) { reportError(ts.Diagnostics.Types_have_separate_declarations_of_a_private_property_0, symbolToString(targetProp)); } else { - reportError(ts.Diagnostics.Property_0_is_private_in_type_1_but_not_in_type_2, symbolToString(targetProp), typeToString(sourcePropFlags & 32 /* Private */ ? source : target), typeToString(sourcePropFlags & 32 /* Private */ ? target : source)); + reportError(ts.Diagnostics.Property_0_is_private_in_type_1_but_not_in_type_2, symbolToString(targetProp), typeToString(sourcePropFlags & 16 /* Private */ ? source : target), typeToString(sourcePropFlags & 16 /* Private */ ? target : source)); } } return 0 /* False */; } } - else if (targetPropFlags & 64 /* Protected */) { + else if (targetPropFlags & 32 /* Protected */) { var sourceDeclaredInClass = sourceProp.parent && sourceProp.parent.flags & 32 /* Class */; var sourceClass = sourceDeclaredInClass ? getDeclaredTypeOfSymbol(sourceProp.parent) : undefined; var targetClass = getDeclaredTypeOfSymbol(targetProp.parent); @@ -18047,7 +18496,7 @@ var ts; return 0 /* False */; } } - else if (sourcePropFlags & 64 /* Protected */) { + else if (sourcePropFlags & 32 /* Protected */) { if (reportErrors) { reportError(ts.Diagnostics.Property_0_is_protected_in_type_1_but_public_in_type_2, symbolToString(targetProp), typeToString(source), typeToString(target)); } @@ -18089,8 +18538,8 @@ var ts; return 0 /* False */; } var result = -1 /* True */; - for (var _i = 0; _i < sourceProperties.length; _i++) { - var sourceProp = sourceProperties[_i]; + for (var _i = 0, sourceProperties_1 = sourceProperties; _i < sourceProperties_1.length; _i++) { + var sourceProp = sourceProperties_1[_i]; var targetProp = getPropertyOfObjectType(target, sourceProp.name); if (!targetProp) { return 0 /* False */; @@ -18130,13 +18579,13 @@ var ts; return result; } } - outer: for (var _i = 0; _i < targetSignatures.length; _i++) { - var t = targetSignatures[_i]; + outer: for (var _i = 0, targetSignatures_1 = targetSignatures; _i < targetSignatures_1.length; _i++) { + var t = targetSignatures_1[_i]; if (!t.hasStringLiterals || target.flags & 262144 /* FromSignature */) { var localErrors = reportErrors; var checkedAbstractAssignability = false; - for (var _a = 0; _a < sourceSignatures.length; _a++) { - var s = sourceSignatures[_a]; + for (var _a = 0, sourceSignatures_1 = sourceSignatures; _a < sourceSignatures_1.length; _a++) { + var s = sourceSignatures_1[_a]; if (!s.hasStringLiterals || source.flags & 262144 /* FromSignature */) { var related = signatureRelatedTo(s, t, localErrors); if (related) { @@ -18167,8 +18616,8 @@ var ts; var targetReturnType = targetErasedSignature && getReturnTypeOfSignature(targetErasedSignature); var sourceReturnDecl = sourceReturnType && sourceReturnType.symbol && getClassLikeDeclarationOfSymbol(sourceReturnType.symbol); var targetReturnDecl = targetReturnType && targetReturnType.symbol && getClassLikeDeclarationOfSymbol(targetReturnType.symbol); - var sourceIsAbstract = sourceReturnDecl && sourceReturnDecl.flags & 256 /* Abstract */; - var targetIsAbstract = targetReturnDecl && targetReturnDecl.flags & 256 /* Abstract */; + var sourceIsAbstract = sourceReturnDecl && sourceReturnDecl.flags & 128 /* Abstract */; + var targetIsAbstract = targetReturnDecl && targetReturnDecl.flags & 128 /* Abstract */; if (sourceIsAbstract && !(targetIsAbstract && targetDecl)) { // if target isn't a class-declaration type, then it can be new'd, so we forbid the assignment. if (reportErrors) { @@ -18284,7 +18733,7 @@ var ts; var targetType = getIndexTypeOfType(target, 0 /* String */); if (targetType) { if ((targetType.flags & 1 /* Any */) && !(originalSource.flags & 16777726 /* Primitive */)) { - // non-primitive assignment to any is always allowed, eg + // non-primitive assignment to any is always allowed, eg // `var x: { [index: string]: any } = { property: 12 };` return -1 /* True */; } @@ -18313,7 +18762,7 @@ var ts; var targetType = getIndexTypeOfType(target, 1 /* Number */); if (targetType) { if ((targetType.flags & 1 /* Any */) && !(originalSource.flags & 16777726 /* Primitive */)) { - // non-primitive assignment to any is always allowed, eg + // non-primitive assignment to any is always allowed, eg // `var x: { [index: number]: any } = { property: 12 };` return -1 /* True */; } @@ -18386,8 +18835,8 @@ var ts; if (sourceProp === targetProp) { return -1 /* True */; } - var sourcePropAccessibility = getDeclarationFlagsFromSymbol(sourceProp) & (32 /* Private */ | 64 /* Protected */); - var targetPropAccessibility = getDeclarationFlagsFromSymbol(targetProp) & (32 /* Private */ | 64 /* Protected */); + var sourcePropAccessibility = getDeclarationFlagsFromSymbol(sourceProp) & (16 /* Private */ | 32 /* Protected */); + var targetPropAccessibility = getDeclarationFlagsFromSymbol(targetProp) & (16 /* Private */ | 32 /* Protected */); if (sourcePropAccessibility !== targetPropAccessibility) { return 0 /* False */; } @@ -18455,8 +18904,8 @@ var ts; return signature.hasRestParameter && parameterIndex >= signature.parameters.length - 1; } function isSupertypeOfEach(candidate, types) { - for (var _i = 0; _i < types.length; _i++) { - var type = types[_i]; + for (var _i = 0, types_6 = types; _i < types_6.length; _i++) { + var type = types_6[_i]; if (candidate !== type && !isTypeSubtypeOf(type, candidate)) return false; } @@ -18692,8 +19141,8 @@ var ts; } function createInferenceContext(typeParameters, inferUnionTypes) { var inferences = []; - for (var _i = 0; _i < typeParameters.length; _i++) { - var unused = typeParameters[_i]; + for (var _i = 0, typeParameters_1 = typeParameters; _i < typeParameters_1.length; _i++) { + var unused = typeParameters_1[_i]; inferences.push({ primary: undefined, secondary: undefined, isFixed: false }); @@ -18774,8 +19223,8 @@ var ts; var typeParameterCount = 0; var typeParameter; // First infer to each type in union or intersection that isn't a type parameter - for (var _i = 0; _i < targetTypes.length; _i++) { - var t = targetTypes[_i]; + for (var _i = 0, targetTypes_2 = targetTypes; _i < targetTypes_2.length; _i++) { + var t = targetTypes_2[_i]; if (t.flags & 512 /* TypeParameter */ && ts.contains(context.typeParameters, t)) { typeParameter = t; typeParameterCount++; @@ -18797,8 +19246,8 @@ var ts; else if (source.flags & 49152 /* UnionOrIntersection */) { // Source is a union or intersection type, infer from each consituent type var sourceTypes = source.types; - for (var _a = 0; _a < sourceTypes.length; _a++) { - var sourceType = sourceTypes[_a]; + for (var _a = 0, sourceTypes_3 = sourceTypes; _a < sourceTypes_3.length; _a++) { + var sourceType = sourceTypes_3[_a]; inferFromTypes(sourceType, target); } } @@ -18832,8 +19281,8 @@ var ts; } function inferFromProperties(source, target) { var properties = getPropertiesOfObjectType(target); - for (var _i = 0; _i < properties.length; _i++) { - var targetProp = properties[_i]; + for (var _i = 0, properties_2 = properties; _i < properties_2.length; _i++) { + var targetProp = properties_2[_i]; var sourceProp = getPropertyOfObjectType(source, targetProp.name); if (sourceProp) { inferFromTypes(getTypeOfSymbol(sourceProp), getTypeOfSymbol(targetProp)); @@ -19324,9 +19773,9 @@ var ts; symbol.valueDeclaration.parent.kind === 244 /* CatchClause */) { return; } - // 1. walk from the use site up to the declaration and check + // 1. walk from the use site up to the declaration and check // if there is anything function like between declaration and use-site (is binding/class is captured in function). - // 2. walk from the declaration up to the boundary of lexical environment and check + // 2. walk from the declaration up to the boundary of lexical environment and check // if there is an iteration statement in between declaration and boundary (is binding/class declared inside iteration statement) var container; if (symbol.flags & 32 /* Class */) { @@ -19398,7 +19847,7 @@ var ts; break; case 141 /* PropertyDeclaration */: case 140 /* PropertySignature */: - if (container.flags & 128 /* Static */) { + if (container.flags & 64 /* Static */) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_static_property_initializer); } break; @@ -19411,7 +19860,7 @@ var ts; } if (ts.isClassLike(container.parent)) { var symbol = getSymbolOfNode(container.parent); - return container.flags & 128 /* Static */ ? getTypeOfSymbol(symbol) : getDeclaredTypeOfSymbol(symbol).thisType; + return container.flags & 64 /* Static */ ? getTypeOfSymbol(symbol) : getDeclaredTypeOfSymbol(symbol).thisType; } return anyType; } @@ -19441,7 +19890,7 @@ var ts; var nodeCheckFlag = 0; // always set NodeCheckFlags for 'super' expression node if (canUseSuperExpression) { - if ((container.flags & 128 /* Static */) || isCallExpression) { + if ((container.flags & 64 /* Static */) || isCallExpression) { nodeCheckFlag = 512 /* SuperStatic */; } else { @@ -19497,7 +19946,7 @@ var ts; // - In a static member function or static member accessor // topmost container must be something that is directly nested in the class declaration if (container && ts.isClassLike(container.parent)) { - if (container.flags & 128 /* Static */) { + if (container.flags & 64 /* Static */) { return container.kind === 143 /* MethodDeclaration */ || container.kind === 142 /* MethodSignature */ || container.kind === 145 /* GetAccessor */ || @@ -19654,8 +20103,8 @@ var ts; var types = type.types; var mappedType; var mappedTypes; - for (var _i = 0; _i < types.length; _i++) { - var current = types[_i]; + for (var _i = 0, types_7 = types; _i < types_7.length; _i++) { + var current = types_7[_i]; var t = mapper(current); if (t) { if (!mappedType) { @@ -19845,8 +20294,8 @@ var ts; } var signatureList; var types = type.types; - for (var _i = 0; _i < types.length; _i++) { - var current = types[_i]; + for (var _i = 0, types_8 = types; _i < types_8.length; _i++) { + var current = types_8[_i]; var signature = getNonGenericSignature(current); if (signature) { if (!signatureList) { @@ -19926,8 +20375,8 @@ var ts; var hasSpreadElement = false; var elementTypes = []; var inDestructuringPattern = isAssignmentTarget(node); - for (var _i = 0; _i < elements.length; _i++) { - var e = elements[_i]; + for (var _i = 0, elements_1 = elements; _i < elements_1.length; _i++) { + var e = elements_1[_i]; if (inDestructuringPattern && e.kind === 185 /* SpreadElementExpression */) { // Given the following situation: // var c: {}; @@ -20259,8 +20708,8 @@ var ts; function checkJsxSpreadAttribute(node, elementAttributesType, nameTable) { var type = checkExpression(node.expression); var props = getPropertiesOfType(type); - for (var _i = 0; _i < props.length; _i++) { - var prop = props[_i]; + for (var _i = 0, props_2 = props; _i < props_2.length; _i++) { + var prop = props_2[_i]; // Is there a corresponding property in the element attributes type? Skip checking of properties // that have already been assigned to, as these are not actually pushed into the resulting type if (!nameTable[prop.name]) { @@ -20479,7 +20928,6 @@ var ts; var prop = getPropertyOfType(attributesType, attrib.name.text); return prop || unknownSymbol; } - var jsxElementClassType = undefined; function getJsxGlobalElementClassType() { if (!jsxElementClassType) { jsxElementClassType = getExportedTypeFromNamespace(JsxNames.JSX, JsxNames.ElementClass); @@ -20558,7 +21006,7 @@ var ts; return s.valueDeclaration ? s.valueDeclaration.kind : 141 /* PropertyDeclaration */; } function getDeclarationFlagsFromSymbol(s) { - return s.valueDeclaration ? ts.getCombinedNodeFlags(s.valueDeclaration) : s.flags & 134217728 /* Prototype */ ? 16 /* Public */ | 128 /* Static */ : 0; + return s.valueDeclaration ? ts.getCombinedNodeFlags(s.valueDeclaration) : s.flags & 134217728 /* Prototype */ ? 8 /* Public */ | 64 /* Static */ : 0; } /** * Check whether the requested property access is valid. @@ -20588,7 +21036,7 @@ var ts; error(errorNode, ts.Diagnostics.Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword); return false; } - if (flags & 256 /* Abstract */) { + if (flags & 128 /* Abstract */) { // A method cannot be accessed in a super property access if the method is abstract. // This error could mask a private property access error. But, a member // cannot simultaneously be private and abstract, so this will trigger an @@ -20598,7 +21046,7 @@ var ts; } } // Public properties are otherwise accessible. - if (!(flags & (32 /* Private */ | 64 /* Protected */))) { + if (!(flags & (16 /* Private */ | 32 /* Protected */))) { return true; } // Property is known to be private or protected at this point @@ -20606,7 +21054,7 @@ var ts; var enclosingClassDeclaration = ts.getContainingClass(node); var enclosingClass = enclosingClassDeclaration ? getDeclaredTypeOfSymbol(getSymbolOfNode(enclosingClassDeclaration)) : undefined; // Private property is accessible if declaring and enclosing class are the same - if (flags & 32 /* Private */) { + if (flags & 16 /* Private */) { if (declaringClass !== enclosingClass) { error(node, ts.Diagnostics.Property_0_is_private_and_only_accessible_within_class_1, symbolToString(prop), typeToString(declaringClass)); return false; @@ -20624,7 +21072,7 @@ var ts; return false; } // No further restrictions for static properties - if (flags & 128 /* Static */) { + if (flags & 64 /* Static */) { return true; } // An instance property must be accessed through an instance of the enclosing class @@ -20851,8 +21299,8 @@ var ts; var specializedIndex = -1; var spliceIndex; ts.Debug.assert(!result.length); - for (var _i = 0; _i < signatures.length; _i++) { - var signature = signatures[_i]; + 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_5 = signature.declaration && signature.declaration.parent; if (!lastSymbol || symbol === lastSymbol) { @@ -21494,8 +21942,8 @@ var ts; // declare function f(a: { xa: number; xb: number; }); // f({ | if (!produceDiagnostics) { - for (var _i = 0; _i < candidates.length; _i++) { - var candidate = candidates[_i]; + for (var _i = 0, candidates_1 = candidates; _i < candidates_1.length; _i++) { + var candidate = candidates_1[_i]; if (hasCorrectArity(node, args, candidate)) { if (candidate.typeParameters && typeArguments) { candidate = getSignatureInstantiation(candidate, ts.map(typeArguments, getTypeFromTypeNode)); @@ -21514,8 +21962,8 @@ var ts; diagnostics.add(ts.createDiagnosticForNodeFromMessageChain(node, errorInfo)); } function chooseOverload(candidates, relation) { - for (var _i = 0; _i < candidates.length; _i++) { - var originalCandidate = candidates[_i]; + for (var _i = 0, candidates_2 = candidates; _i < candidates_2.length; _i++) { + var originalCandidate = candidates_2[_i]; if (!hasCorrectArity(node, args, originalCandidate)) { continue; } @@ -21652,7 +22100,7 @@ var ts; // In the case of a merged class-module or class-interface declaration, // only the class declaration node will have the Abstract flag set. var valueDecl = expressionType.symbol && getClassLikeDeclarationOfSymbol(expressionType.symbol); - if (valueDecl && valueDecl.flags & 256 /* Abstract */) { + if (valueDecl && valueDecl.flags & 128 /* Abstract */) { error(node, ts.Diagnostics.Cannot_create_an_instance_of_the_abstract_class_0, ts.declarationNameToString(valueDecl.name)); return resolveErrorCall(node); } @@ -22017,19 +22465,11 @@ var ts; }); return aggregatedTypes; } - function bodyContainsAReturnStatement(funcBody) { - return ts.forEachReturnStatement(funcBody, function (returnStatement) { - return true; - }); - } - function bodyContainsSingleThrowStatement(body) { - return (body.statements.length === 1) && (body.statements[0].kind === 208 /* ThrowStatement */); - } // TypeScript Specification 1.0 (6.3) - July 2014 // An explicitly typed function whose return type isn't the Void or the Any type // must have at least one return statement somewhere in its body. // An exception to this rule is if the function implementation consists of a single 'throw' statement. - function checkIfNonVoidFunctionHasReturnExpressionsOrSingleThrowStatment(func, returnType) { + function checkAllCodePathsInNonVoidFunctionReturnOrThrow(func, returnType) { if (!produceDiagnostics) { return; } @@ -22038,22 +22478,19 @@ var ts; return; } // If all we have is a function signature, or an arrow function with an expression body, then there is nothing to check. - if (ts.nodeIsMissing(func.body) || func.body.kind !== 192 /* Block */) { + // also if HasImplicitReturnValue flags is not set this means that all codepaths in function body end with return of throw + if (ts.nodeIsMissing(func.body) || func.body.kind !== 192 /* Block */ || !(func.flags & 524288 /* HasImplicitReturn */)) { return; } - var bodyBlock = func.body; - // Ensure the body has at least one return expression. - if (bodyContainsAReturnStatement(bodyBlock)) { - return; + if (func.flags & 1048576 /* HasExplicitReturn */) { + if (compilerOptions.noImplicitReturns) { + error(func.type, ts.Diagnostics.Not_all_code_paths_return_a_value); + } } - // If there are no return expressions, then we need to check if - // the function body consists solely of a throw statement; - // this is to make an exception for unimplemented functions. - if (bodyContainsSingleThrowStatement(bodyBlock)) { - return; + else { + // This function does not conform to the specification. + error(func.type, ts.Diagnostics.A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value); } - // This function does not conform to the specification. - error(func.type, ts.Diagnostics.A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value_or_consist_of_a_single_throw_statement); } function checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper) { ts.Debug.assert(node.kind !== 143 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); @@ -22120,7 +22557,7 @@ var ts; promisedType = checkAsyncFunctionReturnType(node); } if (returnType && !node.asteriskToken) { - checkIfNonVoidFunctionHasReturnExpressionsOrSingleThrowStatment(node, isAsync ? promisedType : returnType); + checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, isAsync ? promisedType : returnType); } if (node.body) { if (!node.type) { @@ -22205,7 +22642,7 @@ var ts; case 69 /* Identifier */: case 166 /* PropertyAccessExpression */: { var symbol = findSymbol(n); - return symbol && (symbol.flags & 3 /* Variable */) !== 0 && (getDeclarationFlagsFromSymbol(symbol) & 32768 /* Const */) !== 0; + return symbol && (symbol.flags & 3 /* Variable */) !== 0 && (getDeclarationFlagsFromSymbol(symbol) & 16384 /* Const */) !== 0; } case 167 /* ElementAccessExpression */: { var index = n.argumentExpression; @@ -22213,7 +22650,7 @@ var ts; if (symbol && index && index.kind === 9 /* StringLiteral */) { var name_12 = index.text; var prop = getPropertyOfType(getTypeOfSymbol(symbol), name_12); - return prop && (prop.flags & 3 /* Variable */) !== 0 && (getDeclarationFlagsFromSymbol(prop) & 32768 /* Const */) !== 0; + return prop && (prop.flags & 3 /* Variable */) !== 0 && (getDeclarationFlagsFromSymbol(prop) & 16384 /* Const */) !== 0; } return false; } @@ -22298,8 +22735,8 @@ var ts; } if (type.flags & 49152 /* UnionOrIntersection */) { var types = type.types; - for (var _i = 0; _i < types.length; _i++) { - var current = types[_i]; + for (var _i = 0, types_9 = types; _i < types_9.length; _i++) { + var current = types_9[_i]; if (current.flags & kind) { return true; } @@ -22315,8 +22752,8 @@ var ts; } if (type.flags & 49152 /* UnionOrIntersection */) { var types = type.types; - for (var _i = 0; _i < types.length; _i++) { - var current = types[_i]; + for (var _i = 0, types_10 = types; _i < types_10.length; _i++) { + var current = types_10[_i]; if (!(current.flags & kind)) { return false; } @@ -22361,8 +22798,8 @@ var ts; } function checkObjectLiteralAssignment(node, sourceType, contextualMapper) { var properties = node.properties; - for (var _i = 0; _i < properties.length; _i++) { - var p = properties[_i]; + for (var _i = 0, properties_3 = properties; _i < properties_3.length; _i++) { + var p = properties_3[_i]; if (p.kind === 245 /* PropertyAssignment */ || p.kind === 246 /* ShorthandPropertyAssignment */) { // TODO(andersh): Computed property support var name_13 = p.name; @@ -22896,7 +23333,7 @@ var ts; checkGrammarDecorators(node) || checkGrammarModifiers(node); checkVariableLikeDeclaration(node); var func = ts.getContainingFunction(node); - if (node.flags & 112 /* AccessibilityModifier */) { + if (node.flags & 56 /* AccessibilityModifier */) { func = ts.getContainingFunction(node); if (!(func.kind === 144 /* Constructor */ && ts.nodeIsPresent(func.body))) { error(node, ts.Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation); @@ -23096,7 +23533,7 @@ var ts; checkFunctionLikeDeclaration(node); // Abstract methods cannot have an implementation. // Extra checks are to avoid reporting multiple errors relating to the "abstractness" of the node. - if (node.flags & 256 /* Abstract */ && node.body) { + if (node.flags & 128 /* Abstract */ && node.body) { error(node, ts.Diagnostics.Method_0_cannot_have_an_implementation_because_it_is_marked_abstract, ts.declarationNameToString(node.name)); } } @@ -23147,7 +23584,7 @@ var ts; } function isInstancePropertyWithInitializer(n) { return n.kind === 141 /* PropertyDeclaration */ && - !(n.flags & 128 /* Static */) && + !(n.flags & 64 /* Static */) && !!n.initializer; } // TS 1.0 spec (April 2014): 8.3.2 @@ -23168,14 +23605,14 @@ var ts; // - The constructor declares parameter properties // or the containing class declares instance member variables with initializers. var superCallShouldBeFirst = ts.forEach(node.parent.members, isInstancePropertyWithInitializer) || - ts.forEach(node.parameters, function (p) { return p.flags & (16 /* Public */ | 32 /* Private */ | 64 /* Protected */); }); + ts.forEach(node.parameters, function (p) { return p.flags & (8 /* Public */ | 16 /* Private */ | 32 /* Protected */); }); // Skip past any prologue directives to find the first statement // to ensure that it was a super call. if (superCallShouldBeFirst) { var statements = node.body.statements; var superCallStatement; - for (var _i = 0; _i < statements.length; _i++) { - var statement = statements[_i]; + for (var _i = 0, statements_2 = statements; _i < statements_2.length; _i++) { + var statement = statements_2[_i]; if (statement.kind === 195 /* ExpressionStatement */ && isSuperCallExpression(statement.expression)) { superCallStatement = statement; break; @@ -23203,8 +23640,15 @@ var ts; // Grammar checking accessors checkGrammarFunctionLikeDeclaration(node) || checkGrammarAccessor(node) || checkGrammarComputedPropertyName(node.name); if (node.kind === 145 /* GetAccessor */) { - if (!ts.isInAmbientContext(node) && ts.nodeIsPresent(node.body) && !(bodyContainsAReturnStatement(node.body) || bodyContainsSingleThrowStatement(node.body))) { - error(node.name, ts.Diagnostics.A_get_accessor_must_return_a_value_or_consist_of_a_single_throw_statement); + if (!ts.isInAmbientContext(node) && ts.nodeIsPresent(node.body) && (node.flags & 524288 /* HasImplicitReturn */)) { + if (node.flags & 1048576 /* HasExplicitReturn */) { + if (compilerOptions.noImplicitReturns) { + error(node.name, ts.Diagnostics.Not_all_code_paths_return_a_value); + } + } + else { + error(node.name, ts.Diagnostics.A_get_accessor_must_return_a_value); + } } } if (!ts.hasDynamicName(node)) { @@ -23213,7 +23657,7 @@ var ts; var otherKind = node.kind === 145 /* GetAccessor */ ? 146 /* SetAccessor */ : 145 /* GetAccessor */; var otherAccessor = ts.getDeclarationOfKind(node.symbol, otherKind); if (otherAccessor) { - if (((node.flags & 112 /* AccessibilityModifier */) !== (otherAccessor.flags & 112 /* AccessibilityModifier */))) { + if (((node.flags & 56 /* AccessibilityModifier */) !== (otherAccessor.flags & 56 /* AccessibilityModifier */))) { error(node.name, ts.Diagnostics.Getter_and_setter_accessors_do_not_agree_in_visibility); } var currentAccessorType = getAnnotatedAccessorType(node); @@ -23284,7 +23728,7 @@ var ts; ts.forEach(node.types, checkSourceElement); } function isPrivateWithinAmbient(node) { - return (node.flags & 32 /* Private */) && ts.isInAmbientContext(node); + return (node.flags & 16 /* Private */) && ts.isInAmbientContext(node); } function checkSpecializedSignatureDeclaration(signatureDeclarationNode) { if (!produceDiagnostics) { @@ -23316,8 +23760,8 @@ var ts; else { signaturesToCheck = getSignaturesOfSymbol(getSymbolOfNode(signatureDeclarationNode)); } - for (var _i = 0; _i < signaturesToCheck.length; _i++) { - var otherSignature = signaturesToCheck[_i]; + for (var _i = 0, signaturesToCheck_1 = signaturesToCheck; _i < signaturesToCheck_1.length; _i++) { + var otherSignature = signaturesToCheck_1[_i]; if (!otherSignature.hasStringLiterals && isSignatureAssignableTo(signature, otherSignature)) { return; } @@ -23332,11 +23776,11 @@ var ts; n.parent.kind !== 214 /* ClassDeclaration */ && n.parent.kind !== 186 /* ClassExpression */ && ts.isInAmbientContext(n)) { - if (!(flags & 2 /* Ambient */)) { + if (!(flags & 4 /* Ambient */)) { // It is nested in an ambient context, which means it is automatically exported - flags |= 1 /* Export */; + flags |= 2 /* Export */; } - flags |= 2 /* Ambient */; + flags |= 4 /* Ambient */; } return flags & flagsToCheck; } @@ -23361,16 +23805,16 @@ var ts; var canonicalFlags = getEffectiveDeclarationFlags(getCanonicalOverload(overloads, implementation), flagsToCheck); ts.forEach(overloads, function (o) { var deviation = getEffectiveDeclarationFlags(o, flagsToCheck) ^ canonicalFlags; - if (deviation & 1 /* Export */) { + if (deviation & 2 /* Export */) { error(o.name, ts.Diagnostics.Overload_signatures_must_all_be_exported_or_not_exported); } - else if (deviation & 2 /* Ambient */) { + else if (deviation & 4 /* Ambient */) { error(o.name, ts.Diagnostics.Overload_signatures_must_all_be_ambient_or_non_ambient); } - else if (deviation & (32 /* Private */ | 64 /* Protected */)) { + else if (deviation & (16 /* Private */ | 32 /* Protected */)) { error(o.name, ts.Diagnostics.Overload_signatures_must_all_be_public_private_or_protected); } - else if (deviation & 256 /* Abstract */) { + else if (deviation & 128 /* Abstract */) { error(o.name, ts.Diagnostics.Overload_signatures_must_all_be_abstract_or_not_abstract); } }); @@ -23387,7 +23831,7 @@ var ts; }); } } - var flagsToCheck = 1 /* Export */ | 2 /* Ambient */ | 32 /* Private */ | 64 /* Protected */ | 256 /* Abstract */; + var flagsToCheck = 2 /* Export */ | 4 /* Ambient */ | 16 /* Private */ | 32 /* Protected */ | 128 /* Abstract */; var someNodeFlags = 0; var allNodeFlags = flagsToCheck; var someHaveQuestionToken = false; @@ -23418,8 +23862,8 @@ var ts; if (node.name && subsequentNode.name && node.name.text === subsequentNode.name.text) { // the only situation when this is possible (same kind\same name but different symbol) - mixed static and instance class members ts.Debug.assert(node.kind === 143 /* MethodDeclaration */ || node.kind === 142 /* MethodSignature */); - ts.Debug.assert((node.flags & 128 /* Static */) !== (subsequentNode.flags & 128 /* Static */)); - var diagnostic = node.flags & 128 /* Static */ ? ts.Diagnostics.Function_overload_must_be_static : ts.Diagnostics.Function_overload_must_not_be_static; + ts.Debug.assert((node.flags & 64 /* Static */) !== (subsequentNode.flags & 64 /* Static */)); + var diagnostic = node.flags & 64 /* Static */ ? ts.Diagnostics.Function_overload_must_be_static : ts.Diagnostics.Function_overload_must_not_be_static; error(errorNode_1, diagnostic); return; } @@ -23436,7 +23880,7 @@ var ts; else { // Report different errors regarding non-consecutive blocks of declarations depending on whether // the node in question is abstract. - if (node.flags & 256 /* Abstract */) { + if (node.flags & 128 /* Abstract */) { error(errorNode, ts.Diagnostics.All_declarations_of_an_abstract_method_must_be_consecutive); } else { @@ -23449,8 +23893,8 @@ var ts; var isExportSymbolInsideModule = symbol.parent && symbol.parent.flags & 1536 /* Module */; var duplicateFunctionDeclaration = false; var multipleConstructorImplementation = false; - for (var _i = 0; _i < declarations.length; _i++) { - var current = declarations[_i]; + for (var _i = 0, declarations_4 = declarations; _i < declarations_4.length; _i++) { + var current = declarations_4[_i]; var node = current; var inAmbientContext = ts.isInAmbientContext(node); var inAmbientContextOrInterface = node.parent.kind === 215 /* InterfaceDeclaration */ || node.parent.kind === 155 /* TypeLiteral */ || inAmbientContext; @@ -23507,7 +23951,7 @@ var ts; } // Abstract methods can't have an implementation -- in particular, they don't need one. if (!isExportSymbolInsideModule && lastSeenNonAmbientDeclaration && !lastSeenNonAmbientDeclaration.body && - !(lastSeenNonAmbientDeclaration.flags & 256 /* Abstract */)) { + !(lastSeenNonAmbientDeclaration.flags & 128 /* Abstract */)) { reportImplementationExpectedError(lastSeenNonAmbientDeclaration); } if (hasOverloads) { @@ -23533,8 +23977,8 @@ var ts; // function g(x: string, y: string) { } // // The implementation is completely unrelated to the specialized signature, yet we do not check this. - for (var _a = 0; _a < signatures.length; _a++) { - var signature = signatures[_a]; + for (var _a = 0, signatures_3 = signatures; _a < signatures_3.length; _a++) { + var signature = signatures_3[_a]; if (!signature.hasStringLiterals && !isSignatureAssignableTo(bodySignature, signature)) { error(signature.declaration, ts.Diagnostics.Overload_signature_is_not_compatible_with_function_implementation); break; @@ -23571,9 +24015,9 @@ var ts; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var d = _a[_i]; var declarationSpaces = getDeclarationSpaces(d); - var effectiveDeclarationFlags = getEffectiveDeclarationFlags(d, 1 /* Export */ | 1024 /* Default */); - if (effectiveDeclarationFlags & 1 /* Export */) { - if (effectiveDeclarationFlags & 1024 /* Default */) { + var effectiveDeclarationFlags = getEffectiveDeclarationFlags(d, 2 /* Export */ | 512 /* Default */); + if (effectiveDeclarationFlags & 2 /* Export */) { + if (effectiveDeclarationFlags & 512 /* Default */) { defaultExportedDeclarationSpaces |= declarationSpaces; } else { @@ -23826,9 +24270,12 @@ var ts; // type as a value. As such, we will just return unknownType; return unknownType; } - var promiseConstructor = getMergedSymbol(promiseType.symbol); + var promiseConstructor = getNodeLinks(node.type).resolvedSymbol; if (!promiseConstructor || !symbolIsValue(promiseConstructor)) { - error(node, ts.Diagnostics.Type_0_is_not_a_valid_async_function_return_type, typeToString(promiseType)); + var typeName = promiseConstructor + ? symbolToString(promiseConstructor) + : typeToString(promiseType); + error(node, ts.Diagnostics.Type_0_is_not_a_valid_async_function_return_type, typeName); return unknownType; } // Validate the promise constructor type. @@ -24020,7 +24467,7 @@ var ts; if (isAsync) { promisedType = checkAsyncFunctionReturnType(node); } - checkIfNonVoidFunctionHasReturnExpressionsOrSingleThrowStatment(node, isAsync ? promisedType : returnType); + checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, isAsync ? promisedType : returnType); } if (produceDiagnostics && !node.type) { // Report an implicit any error if there is no body, no explicit return type, and node is not a private method @@ -24162,7 +24609,7 @@ var ts; // let x = 0; // symbol for this declaration will be 'symbol' // } // skip block-scoped variables and parameters - if ((ts.getCombinedNodeFlags(node) & 49152 /* BlockScoped */) !== 0 || ts.isParameterDeclaration(node)) { + if ((ts.getCombinedNodeFlags(node) & 24576 /* BlockScoped */) !== 0 || ts.isParameterDeclaration(node)) { return; } // skip variable declarations that don't have initializers @@ -24177,7 +24624,7 @@ var ts; if (localDeclarationSymbol && localDeclarationSymbol !== symbol && localDeclarationSymbol.flags & 2 /* BlockScopedVariable */) { - if (getDeclarationFlagsFromSymbol(localDeclarationSymbol) & 49152 /* BlockScoped */) { + if (getDeclarationFlagsFromSymbol(localDeclarationSymbol) & 24576 /* BlockScoped */) { var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 212 /* VariableDeclarationList */); var container = varDeclList.parent.kind === 193 /* VariableStatement */ && varDeclList.parent.parent ? varDeclList.parent.parent @@ -24330,6 +24777,9 @@ var ts; checkGrammarStatementInAmbientContext(node); checkExpression(node.expression); checkSourceElement(node.thenStatement); + if (node.thenStatement.kind === 194 /* EmptyStatement */) { + error(node.thenStatement, ts.Diagnostics.The_body_of_an_if_statement_cannot_be_the_empty_statement); + } checkSourceElement(node.elseStatement); } function checkDoStatement(node) { @@ -24688,7 +25138,7 @@ var ts; error(node.expression, ts.Diagnostics.Setters_cannot_return_a_value); } else if (func.kind === 144 /* Constructor */) { - if (!isTypeAssignableTo(exprType, returnType)) { + if (!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); } } @@ -24835,7 +25285,7 @@ var ts; // Only process instance properties with computed names here. // Static properties cannot be in conflict with indexers, // and properties with literal names were already checked. - if (!(member.flags & 128 /* Static */) && ts.hasDynamicName(member)) { + if (!(member.flags & 64 /* Static */) && ts.hasDynamicName(member)) { var propType = getTypeOfSymbol(member.symbol); checkIndexConstraintForProperty(member.symbol, propType, type, declaredStringIndexer, stringIndexType, 0 /* String */); checkIndexConstraintForProperty(member.symbol, propType, type, declaredNumberIndexer, numberIndexType, 1 /* Number */); @@ -24921,7 +25371,7 @@ var ts; return getTypeOfSymbol(getSymbolOfNode(node)); } function checkClassDeclaration(node) { - if (!node.name && !(node.flags & 1024 /* Default */)) { + if (!node.name && !(node.flags & 512 /* Default */)) { grammarErrorOnFirstToken(node, ts.Diagnostics.A_class_declaration_without_the_default_modifier_must_have_a_name); } checkClassLikeDeclaration(node); @@ -24975,8 +25425,8 @@ var ts; } var implementedTypeNodes = ts.getClassImplementsHeritageClauseElements(node); if (implementedTypeNodes) { - for (var _b = 0; _b < implementedTypeNodes.length; _b++) { - var typeRefNode = implementedTypeNodes[_b]; + for (var _b = 0, implementedTypeNodes_1 = implementedTypeNodes; _b < implementedTypeNodes_1.length; _b++) { + var typeRefNode = implementedTypeNodes_1[_b]; if (!ts.isSupportedExpressionWithTypeArguments(typeRefNode)) { error(typeRefNode.expression, ts.Diagnostics.A_class_can_only_implement_an_identifier_Slashqualified_name_with_optional_type_arguments); } @@ -25024,8 +25474,8 @@ var ts; // derived class instance member variables and accessors, but not by other kinds of members. // NOTE: assignability is checked in checkClassDeclaration var baseProperties = getPropertiesOfObjectType(baseType); - for (var _i = 0; _i < baseProperties.length; _i++) { - var baseProperty = baseProperties[_i]; + for (var _i = 0, baseProperties_1 = baseProperties; _i < baseProperties_1.length; _i++) { + var baseProperty = baseProperties_1[_i]; var base = getTargetSymbol(baseProperty); if (base.flags & 134217728 /* Prototype */) { continue; @@ -25043,7 +25493,7 @@ var ts; // It is an error to inherit an abstract member without implementing it or being declared abstract. // If there is no declaration for the derived class (as in the case of class expressions), // then the class cannot be declared abstract. - if (baseDeclarationFlags & 256 /* Abstract */ && (!derivedClassDecl || !(derivedClassDecl.flags & 256 /* Abstract */))) { + if (baseDeclarationFlags & 128 /* Abstract */ && (!derivedClassDecl || !(derivedClassDecl.flags & 128 /* Abstract */))) { if (derivedClassDecl.kind === 186 /* ClassExpression */) { error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1, symbolToString(baseProperty), typeToString(baseType)); } @@ -25055,11 +25505,11 @@ var ts; else { // derived overrides base. var derivedDeclarationFlags = getDeclarationFlagsFromSymbol(derived); - if ((baseDeclarationFlags & 32 /* Private */) || (derivedDeclarationFlags & 32 /* Private */)) { + if ((baseDeclarationFlags & 16 /* Private */) || (derivedDeclarationFlags & 16 /* Private */)) { // either base or derived property is private - not override, skip it continue; } - if ((baseDeclarationFlags & 128 /* Static */) !== (derivedDeclarationFlags & 128 /* Static */)) { + if ((baseDeclarationFlags & 64 /* Static */) !== (derivedDeclarationFlags & 64 /* Static */)) { // value of 'static' is not the same for properties - not override, skip it continue; } @@ -25130,11 +25580,11 @@ var ts; var seen = {}; ts.forEach(resolveDeclaredMembers(type).declaredProperties, function (p) { seen[p.name] = { prop: p, containingType: type }; }); var ok = true; - for (var _i = 0; _i < baseTypes.length; _i++) { - var base = baseTypes[_i]; + for (var _i = 0, baseTypes_2 = baseTypes; _i < baseTypes_2.length; _i++) { + var base = baseTypes_2[_i]; var properties = getPropertiesOfObjectType(getTypeWithThisArgument(base, type.thisType)); - for (var _a = 0; _a < properties.length; _a++) { - var prop = properties[_a]; + for (var _a = 0, properties_4 = properties; _a < properties_4.length; _a++) { + var prop = properties_4[_a]; if (!ts.hasProperty(seen, prop.name)) { seen[prop.name] = { prop: prop, containingType: base }; } @@ -25431,8 +25881,8 @@ var ts; } function getFirstNonAmbientClassOrFunctionDeclaration(symbol) { var declarations = symbol.declarations; - for (var _i = 0; _i < declarations.length; _i++) { - var declaration = declarations[_i]; + for (var _i = 0, declarations_5 = declarations; _i < declarations_5.length; _i++) { + var declaration = declarations_5[_i]; if ((declaration.kind === 214 /* ClassDeclaration */ || (declaration.kind === 213 /* FunctionDeclaration */ && ts.nodeIsPresent(declaration.body))) && !ts.isInAmbientContext(declaration)) { @@ -25571,7 +26021,7 @@ var ts; // If we hit an import declaration in an illegal context, just bail out to avoid cascading errors. return; } - if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && (node.flags & 2035 /* Modifier */)) { + if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && (node.flags & 1022 /* Modifier */)) { grammarErrorOnFirstToken(node, ts.Diagnostics.An_import_declaration_cannot_have_modifiers); } if (checkExternalImportOrExportDeclaration(node)) { @@ -25599,7 +26049,7 @@ var ts; checkGrammarDecorators(node) || checkGrammarModifiers(node); if (ts.isInternalModuleImportEqualsDeclaration(node) || checkExternalImportOrExportDeclaration(node)) { checkImportBinding(node); - if (node.flags & 1 /* Export */) { + if (node.flags & 2 /* Export */) { markExportAsReferenced(node); } if (ts.isInternalModuleImportEqualsDeclaration(node)) { @@ -25630,7 +26080,7 @@ var ts; // If we hit an export in an illegal context, just bail out to avoid cascading errors. return; } - if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && (node.flags & 2035 /* Modifier */)) { + if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && (node.flags & 1022 /* Modifier */)) { grammarErrorOnFirstToken(node, ts.Diagnostics.An_export_declaration_cannot_have_modifiers); } if (!node.moduleSpecifier || checkExternalImportOrExportDeclaration(node)) { @@ -25674,7 +26124,7 @@ var ts; return; } // Grammar checking - if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && (node.flags & 2035 /* Modifier */)) { + if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && (node.flags & 1022 /* Modifier */)) { grammarErrorOnFirstToken(node, ts.Diagnostics.An_export_assignment_cannot_have_modifiers); } if (node.expression.kind === 69 /* Identifier */) { @@ -26087,7 +26537,7 @@ var ts; // add the type parameters into the symbol table // (type parameters of classDeclaration/classExpression and interface are in member property of the symbol. // Note: that the memberFlags come from previous iteration. - if (!(memberFlags & 128 /* Static */)) { + if (!(memberFlags & 64 /* Static */)) { copySymbols(getSymbolOfNode(location).members, meaning & 793056 /* Type */); } break; @@ -26388,7 +26838,7 @@ var ts; */ function getParentTypeOfClassElement(node) { var classSymbol = getSymbolOfNode(node.parent); - return node.flags & 128 /* Static */ + return node.flags & 64 /* Static */ ? getTypeOfSymbol(classSymbol) : getDeclaredTypeOfSymbol(classSymbol); } @@ -26709,7 +27159,7 @@ var ts; function initializeTypeChecker() { // Bind all source files and propagate errors ts.forEach(host.getSourceFiles(), function (file) { - ts.bindSourceFile(file); + ts.bindSourceFile(file, compilerOptions); }); // Initialize global symbol table ts.forEach(host.getSourceFiles(), function (file) { @@ -26863,19 +27313,19 @@ var ts; text = "private"; lastPrivate = modifier; } - if (flags & 112 /* AccessibilityModifier */) { + if (flags & 56 /* AccessibilityModifier */) { return grammarErrorOnNode(modifier, ts.Diagnostics.Accessibility_modifier_already_seen); } - else if (flags & 128 /* Static */) { + else if (flags & 64 /* Static */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "static"); } - else if (flags & 512 /* Async */) { + else if (flags & 256 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "async"); } else if (node.parent.kind === 219 /* ModuleBlock */ || node.parent.kind === 248 /* SourceFile */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_element, text); } - else if (flags & 256 /* Abstract */) { + else if (flags & 128 /* Abstract */) { if (modifier.kind === 110 /* PrivateKeyword */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, text, "abstract"); } @@ -26886,10 +27336,10 @@ var ts; flags |= ts.modifierToFlag(modifier.kind); break; case 113 /* StaticKeyword */: - if (flags & 128 /* Static */) { + if (flags & 64 /* Static */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "static"); } - else if (flags & 512 /* Async */) { + else if (flags & 256 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "static", "async"); } else if (node.parent.kind === 219 /* ModuleBlock */ || node.parent.kind === 248 /* SourceFile */) { @@ -26898,23 +27348,23 @@ var ts; else if (node.kind === 138 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "static"); } - else if (flags & 256 /* Abstract */) { + else if (flags & 128 /* Abstract */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "static", "abstract"); } - flags |= 128 /* Static */; + flags |= 64 /* Static */; lastStatic = modifier; break; case 82 /* ExportKeyword */: - if (flags & 1 /* Export */) { + if (flags & 2 /* Export */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "export"); } - else if (flags & 2 /* Ambient */) { + else if (flags & 4 /* Ambient */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "declare"); } - else if (flags & 256 /* Abstract */) { + else if (flags & 128 /* Abstract */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "abstract"); } - else if (flags & 512 /* Async */) { + else if (flags & 256 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "async"); } else if (node.parent.kind === 214 /* ClassDeclaration */) { @@ -26923,13 +27373,13 @@ var ts; else if (node.kind === 138 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "export"); } - flags |= 1 /* Export */; + flags |= 2 /* Export */; break; case 122 /* DeclareKeyword */: - if (flags & 2 /* Ambient */) { + if (flags & 4 /* Ambient */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "declare"); } - else if (flags & 512 /* Async */) { + 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 === 214 /* ClassDeclaration */) { @@ -26941,69 +27391,69 @@ var ts; else if (ts.isInAmbientContext(node.parent) && node.parent.kind === 219 /* ModuleBlock */) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_declare_modifier_cannot_be_used_in_an_already_ambient_context); } - flags |= 2 /* Ambient */; + flags |= 4 /* Ambient */; lastDeclare = modifier; break; case 115 /* AbstractKeyword */: - if (flags & 256 /* Abstract */) { + if (flags & 128 /* Abstract */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "abstract"); } if (node.kind !== 214 /* ClassDeclaration */) { if (node.kind !== 143 /* MethodDeclaration */) { return grammarErrorOnNode(modifier, ts.Diagnostics.abstract_modifier_can_only_appear_on_a_class_or_method_declaration); } - if (!(node.parent.kind === 214 /* ClassDeclaration */ && node.parent.flags & 256 /* Abstract */)) { + if (!(node.parent.kind === 214 /* ClassDeclaration */ && node.parent.flags & 128 /* Abstract */)) { return grammarErrorOnNode(modifier, ts.Diagnostics.Abstract_methods_can_only_appear_within_an_abstract_class); } - if (flags & 128 /* Static */) { + if (flags & 64 /* Static */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "static", "abstract"); } - if (flags & 32 /* Private */) { + if (flags & 16 /* Private */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "private", "abstract"); } } - flags |= 256 /* Abstract */; + flags |= 128 /* Abstract */; break; case 118 /* AsyncKeyword */: - if (flags & 512 /* Async */) { + if (flags & 256 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "async"); } - else if (flags & 2 /* Ambient */ || ts.isInAmbientContext(node.parent)) { + else if (flags & 4 /* Ambient */ || ts.isInAmbientContext(node.parent)) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); } else if (node.kind === 138 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "async"); } - flags |= 512 /* Async */; + flags |= 256 /* Async */; lastAsync = modifier; break; } } if (node.kind === 144 /* Constructor */) { - if (flags & 128 /* Static */) { + if (flags & 64 /* Static */) { return grammarErrorOnNode(lastStatic, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "static"); } - if (flags & 256 /* Abstract */) { + if (flags & 128 /* Abstract */) { return grammarErrorOnNode(lastStatic, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "abstract"); } - else if (flags & 64 /* Protected */) { + else if (flags & 32 /* Protected */) { return grammarErrorOnNode(lastProtected, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "protected"); } - else if (flags & 32 /* Private */) { + else if (flags & 16 /* Private */) { return grammarErrorOnNode(lastPrivate, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "private"); } - else if (flags & 512 /* Async */) { + else if (flags & 256 /* Async */) { return grammarErrorOnNode(lastAsync, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "async"); } return; } - else if ((node.kind === 222 /* ImportDeclaration */ || node.kind === 221 /* ImportEqualsDeclaration */) && flags & 2 /* Ambient */) { + else if ((node.kind === 222 /* ImportDeclaration */ || node.kind === 221 /* ImportEqualsDeclaration */) && flags & 4 /* Ambient */) { return grammarErrorOnNode(lastDeclare, ts.Diagnostics.A_0_modifier_cannot_be_used_with_an_import_declaration, "declare"); } - else if (node.kind === 138 /* Parameter */ && (flags & 112 /* AccessibilityModifier */) && ts.isBindingPattern(node.name)) { + else if (node.kind === 138 /* Parameter */ && (flags & 56 /* AccessibilityModifier */) && ts.isBindingPattern(node.name)) { return grammarErrorOnNode(node, ts.Diagnostics.A_parameter_property_may_not_be_a_binding_pattern); } - if (flags & 512 /* Async */) { + if (flags & 256 /* Async */) { return checkGrammarAsyncModifier(node, lastAsync); } } @@ -27104,7 +27554,7 @@ var ts; if (parameter.dotDotDotToken) { return grammarErrorOnNode(parameter.dotDotDotToken, ts.Diagnostics.An_index_signature_cannot_have_a_rest_parameter); } - if (parameter.flags & 2035 /* Modifier */) { + if (parameter.flags & 1022 /* Modifier */) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_cannot_have_an_accessibility_modifier); } if (parameter.questionToken) { @@ -27124,7 +27574,7 @@ var ts; } } function checkGrammarForIndexSignatureModifier(node) { - if (node.flags & 2035 /* Modifier */) { + if (node.flags & 1022 /* Modifier */) { grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_not_permitted_on_index_signature_members); } } @@ -27147,8 +27597,8 @@ var ts; function checkGrammarForOmittedArgument(node, args) { if (args) { var sourceFile = ts.getSourceFileOfNode(node); - for (var _i = 0; _i < args.length; _i++) { - var arg = args[_i]; + for (var _i = 0, args_1 = args; _i < args_1.length; _i++) { + var arg = args_1[_i]; if (arg.kind === 187 /* OmittedExpression */) { return grammarErrorAtPos(sourceFile, arg.pos, 0, ts.Diagnostics.Argument_expression_expected); } @@ -27403,7 +27853,7 @@ var ts; if (parameter.dotDotDotToken) { return grammarErrorOnNode(parameter.dotDotDotToken, ts.Diagnostics.A_set_accessor_cannot_have_rest_parameter); } - else if (parameter.flags & 2035 /* Modifier */) { + else if (parameter.flags & 1022 /* Modifier */) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation); } else if (parameter.questionToken) { @@ -27554,8 +28004,8 @@ var ts; } else { var elements = name.elements; - for (var _i = 0; _i < elements.length; _i++) { - var element = elements[_i]; + for (var _i = 0, elements_2 = elements; _i < elements_2.length; _i++) { + var element = elements_2[_i]; if (element.kind !== 187 /* OmittedExpression */) { checkGrammarNameInLetOrConstDeclarations(element.name); } @@ -27691,8 +28141,8 @@ var ts; node.kind === 221 /* ImportEqualsDeclaration */ || node.kind === 228 /* ExportDeclaration */ || node.kind === 227 /* ExportAssignment */ || - (node.flags & 2 /* Ambient */) || - (node.flags & (1 /* Export */ | 1024 /* Default */))) { + (node.flags & 4 /* Ambient */) || + (node.flags & (2 /* Export */ | 512 /* Default */))) { return false; } return grammarErrorOnFirstToken(node, ts.Diagnostics.A_declare_modifier_is_required_for_a_top_level_declaration_in_a_d_ts_file); @@ -27739,7 +28189,7 @@ var ts; } function checkGrammarNumericLiteral(node) { // Grammar checking - if (node.flags & 65536 /* OctalLiteral */ && languageVersion >= 1 /* ES5 */) { + if (node.flags & 32768 /* OctalLiteral */ && languageVersion >= 1 /* ES5 */) { return grammarErrorOnNode(node, ts.Diagnostics.Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher); } } @@ -27793,7 +28243,7 @@ var ts; ts.forEach(root.referencedFiles, function (fileReference) { var referencedFile = ts.tryResolveScriptReference(host, root, fileReference); // All the references that are not going to be part of same file - if (referencedFile && ((referencedFile.flags & 8192 /* DeclarationFile */) || + if (referencedFile && ((referencedFile.flags & 4096 /* DeclarationFile */) || ts.shouldEmitToOwnFile(referencedFile, compilerOptions) || !addedGlobalFileReference)) { writeReferencePath(referencedFile); @@ -27988,15 +28438,15 @@ var ts; } } function emitLines(nodes) { - for (var _i = 0; _i < nodes.length; _i++) { - var node = nodes[_i]; + for (var _i = 0, nodes_2 = nodes; _i < nodes_2.length; _i++) { + var node = nodes_2[_i]; emit(node); } } function emitSeparatedList(nodes, separator, eachNodeEmitFn, canEmitFn) { var currentWriterPos = writer.getTextPos(); - for (var _i = 0; _i < nodes.length; _i++) { - var node = nodes[_i]; + for (var _i = 0, nodes_3 = nodes; _i < nodes_3.length; _i++) { + var node = nodes_3[_i]; if (!canEmitFn || canEmitFn(node)) { if (currentWriterPos !== writer.getTextPos()) { write(separator); @@ -28142,6 +28592,7 @@ var ts; function emitSourceFile(node) { currentSourceFile = node; enclosingDeclaration = node; + ts.emitDetachedComments(currentSourceFile, writer, ts.writeCommentRange, node, newLine, true /* remove comments */); emitLines(node.statements); } // Return a temp variable name to be used in `export default` statements. @@ -28258,10 +28709,10 @@ var ts; // If the node is parented in the current source file we need to emit export declare or just export if (node.parent === currentSourceFile) { // If the node is exported - if (node.flags & 1 /* Export */) { + if (node.flags & 2 /* Export */) { write("export "); } - if (node.flags & 1024 /* Default */) { + if (node.flags & 512 /* Default */) { write("default "); } else if (node.kind !== 215 /* InterfaceDeclaration */) { @@ -28270,16 +28721,16 @@ var ts; } } function emitClassMemberDeclarationFlags(node) { - if (node.flags & 32 /* Private */) { + if (node.flags & 16 /* Private */) { write("private "); } - else if (node.flags & 64 /* Protected */) { + else if (node.flags & 32 /* Protected */) { write("protected "); } - if (node.flags & 128 /* Static */) { + if (node.flags & 64 /* Static */) { write("static "); } - if (node.flags & 256 /* Abstract */) { + if (node.flags & 128 /* Abstract */) { write("abstract "); } } @@ -28287,7 +28738,7 @@ var ts; // note usage of writer. methods instead of aliases created, just to make sure we are using // correct writer especially to handle asynchronous alias writing emitJsDocComments(node); - if (node.flags & 1 /* Export */) { + if (node.flags & 2 /* Export */) { write("export "); } write("import "); @@ -28322,12 +28773,12 @@ var ts; } } function writeImportDeclaration(node) { - if (!node.importClause && !(node.flags & 1 /* Export */)) { + if (!node.importClause && !(node.flags & 2 /* Export */)) { // do not write non-exported import declarations that don't have import clauses return; } emitJsDocComments(node); - if (node.flags & 1 /* Export */) { + if (node.flags & 2 /* Export */) { write("export "); } write("import "); @@ -28392,7 +28843,7 @@ var ts; function writeModuleDeclaration(node) { emitJsDocComments(node); emitModuleElementDeclarationFlags(node); - if (node.flags & 131072 /* Namespace */) { + if (node.flags & 65536 /* Namespace */) { write("namespace "); } else { @@ -28464,7 +28915,7 @@ var ts; writeLine(); } function isPrivateMethodTypeParameter(node) { - return node.parent.kind === 143 /* MethodDeclaration */ && (node.parent.flags & 32 /* Private */); + return node.parent.kind === 143 /* MethodDeclaration */ && (node.parent.flags & 16 /* Private */); } function emitTypeParameters(typeParameters) { function emitTypeParameter(node) { @@ -28508,7 +28959,7 @@ var ts; break; case 143 /* MethodDeclaration */: case 142 /* MethodSignature */: - if (node.parent.flags & 128 /* Static */) { + if (node.parent.flags & 64 /* 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 === 214 /* ClassDeclaration */) { @@ -28574,7 +29025,7 @@ var ts; function emitParameterProperties(constructorDeclaration) { if (constructorDeclaration) { ts.forEach(constructorDeclaration.parameters, function (param) { - if (param.flags & 112 /* AccessibilityModifier */) { + if (param.flags & 56 /* AccessibilityModifier */) { emitPropertyDeclaration(param); } }); @@ -28582,7 +29033,7 @@ var ts; } emitJsDocComments(node); emitModuleElementDeclarationFlags(node); - if (node.flags & 256 /* Abstract */) { + if (node.flags & 128 /* Abstract */) { write("abstract "); } write("class "); @@ -28652,7 +29103,7 @@ var ts; if ((node.kind === 141 /* PropertyDeclaration */ || node.kind === 140 /* PropertySignature */) && node.parent.kind === 155 /* TypeLiteral */) { emitTypeOfVariableDeclarationFromTypeLiteral(node); } - else if (!(node.flags & 32 /* Private */)) { + else if (!(node.flags & 16 /* Private */)) { writeTypeOfDeclaration(node, node.type, getVariableDeclarationTypeVisibilityError); } } @@ -28667,7 +29118,7 @@ var ts; } else if (node.kind === 141 /* PropertyDeclaration */ || node.kind === 140 /* PropertySignature */) { // TODO(jfreeman): Deal with computed properties in error reporting. - if (node.flags & 128 /* Static */) { + if (node.flags & 64 /* Static */) { return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -28771,7 +29222,7 @@ var ts; emitJsDocComments(accessors.setAccessor); emitClassMemberDeclarationFlags(node); writeTextOfNode(currentSourceFile, node.name); - if (!(node.flags & 32 /* Private */)) { + if (!(node.flags & 16 /* Private */)) { accessorWithTypeAnnotation = node; var type = getTypeAnnotationFromAccessor(node); if (!type) { @@ -28800,7 +29251,7 @@ var ts; var diagnosticMessage; if (accessorWithTypeAnnotation.kind === 146 /* SetAccessor */) { // Setters have to have type named and cannot infer it so, the type should always be named - if (accessorWithTypeAnnotation.parent.flags & 128 /* Static */) { + if (accessorWithTypeAnnotation.parent.flags & 64 /* Static */) { diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_public_static_property_setter_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_public_static_property_setter_from_exported_class_has_or_is_using_private_name_1; @@ -28818,7 +29269,7 @@ var ts; }; } else { - if (accessorWithTypeAnnotation.flags & 128 /* Static */) { + if (accessorWithTypeAnnotation.flags & 64 /* Static */) { diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Return_type_of_public_static_property_getter_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : @@ -28905,7 +29356,7 @@ var ts; emitType(node.type); } } - else if (node.kind !== 144 /* Constructor */ && !(node.flags & 32 /* Private */)) { + else if (node.kind !== 144 /* Constructor */ && !(node.flags & 16 /* Private */)) { writeReturnTypeAtSignature(node, getReturnTypeVisibilityError); } enclosingDeclaration = prevEnclosingDeclaration; @@ -28936,7 +29387,7 @@ var ts; break; case 143 /* MethodDeclaration */: case 142 /* MethodSignature */: - if (node.flags & 128 /* Static */) { + if (node.flags & 64 /* Static */) { diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : @@ -28997,7 +29448,7 @@ var ts; node.parent.parent.kind === 155 /* TypeLiteral */) { emitTypeOfVariableDeclarationFromTypeLiteral(node); } - else if (!(node.parent.flags & 32 /* Private */)) { + else if (!(node.parent.flags & 16 /* Private */)) { writeTypeOfDeclaration(node, node.type, getParameterDeclarationTypeVisibilityError); } function getParameterDeclarationTypeVisibilityError(symbolAccesibilityResult) { @@ -29028,7 +29479,7 @@ var ts; ts.Diagnostics.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; case 143 /* MethodDeclaration */: case 142 /* MethodSignature */: - if (node.parent.flags & 128 /* Static */) { + if (node.parent.flags & 64 /* Static */) { return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -29170,7 +29621,7 @@ var ts; } } function writeReferencePath(referencedFile) { - var declFileName = referencedFile.flags & 8192 /* DeclarationFile */ + var declFileName = referencedFile.flags & 4096 /* DeclarationFile */ ? referencedFile.fileName // Declaration file, use declaration file name : ts.shouldEmitToOwnFile(referencedFile, compilerOptions) ? ts.getOwnEmitOutputFilePath(referencedFile, host, ".d.ts") // Own output file so get the .d.ts file @@ -29216,6 +29667,12 @@ var ts; return ts.isExternalModule(sourceFile) || ts.isDeclarationFile(sourceFile); } ts.isExternalModuleOrDeclarationFile = isExternalModuleOrDeclarationFile; + var Jump; + (function (Jump) { + Jump[Jump["Break"] = 2] = "Break"; + Jump[Jump["Continue"] = 4] = "Continue"; + Jump[Jump["Return"] = 8] = "Return"; + })(Jump || (Jump = {})); var entities = { "quot": 0x0022, "amp": 0x0026, @@ -29525,16 +29982,8 @@ var ts; diagnostics: diagnostics, sourceMaps: sourceMapDataList }; - function isNodeDescendentOf(node, ancestor) { - while (node) { - if (node === ancestor) - return true; - node = node.parent; - } - return false; - } function isUniqueLocalName(name, container) { - for (var node = container; isNodeDescendentOf(node, container); node = node.nextContainer) { + for (var node = container; ts.isNodeDescendentOf(node, container); node = node.nextContainer) { if (node.locals && ts.hasProperty(node.locals, name)) { // We conservatively include alias symbols to cover cases where they're emitted as locals if (node.locals[name].flags & (107455 /* Value */ | 1048576 /* ExportValue */ | 8388608 /* Alias */)) { @@ -29544,12 +29993,6 @@ var ts; } return true; } - var Jump; - (function (Jump) { - Jump[Jump["Break"] = 2] = "Break"; - Jump[Jump["Continue"] = 4] = "Continue"; - Jump[Jump["Return"] = 8] = "Return"; - })(Jump || (Jump = {})); function setLabeledJump(state, isBreak, labelText, labelMarker) { if (isBreak) { if (!state.labeledNonLocalBreaks) { @@ -31026,7 +31469,7 @@ var ts; write("]"); } else { - emitListWithSpread(elements, /*needsUniqueCopy*/ true, /*multiLine*/ (node.flags & 2048 /* MultiLine */) !== 0, + emitListWithSpread(elements, /*needsUniqueCopy*/ true, /*multiLine*/ (node.flags & 1024 /* MultiLine */) !== 0, /*trailingComma*/ elements.hasTrailingComma, /*useConcat*/ true); } } @@ -31045,7 +31488,7 @@ var ts; emitLinePreservingList(node, properties, /* allowTrailingComma */ languageVersion >= 1 /* ES5 */, /* spacesBetweenBraces */ true); } else { - var multiLine = (node.flags & 2048 /* MultiLine */) !== 0; + var multiLine = (node.flags & 1024 /* MultiLine */) !== 0; if (!multiLine) { write(" "); } @@ -31064,7 +31507,7 @@ var ts; write("}"); } function emitDownlevelObjectLiteralWithComputedProperties(node, firstComputedPropertyIndex) { - var multiLine = (node.flags & 2048 /* MultiLine */) !== 0; + var multiLine = (node.flags & 1024 /* MultiLine */) !== 0; var properties = node.properties; write("("); if (multiLine) { @@ -31693,7 +32136,7 @@ var ts; var current = node; while (current) { if (current.kind === 248 /* SourceFile */) { - return !isExported || ((ts.getCombinedNodeFlags(node) & 1 /* Export */) !== 0); + return !isExported || ((ts.getCombinedNodeFlags(node) & 2 /* Export */) !== 0); } else if (ts.isFunctionLike(current) || current.kind === 219 /* ModuleBlock */) { return false; @@ -31934,7 +32377,7 @@ var ts; // variables in variable declaration list were already hoisted return false; } - if (convertedLoopState && (ts.getCombinedNodeFlags(decl) & 49152 /* BlockScoped */) === 0) { + if (convertedLoopState && (ts.getCombinedNodeFlags(decl) & 24576 /* BlockScoped */) === 0) { // we are inside a converted loop - this can only happen in downlevel scenarios // record names for all variable declarations for (var _a = 0, _b = decl.declarations; _a < _b.length; _a++) { @@ -32019,7 +32462,7 @@ var ts; break; } var loopParameters; - if (loopInitializer && (ts.getCombinedNodeFlags(loopInitializer) & 49152 /* BlockScoped */)) { + if (loopInitializer && (ts.getCombinedNodeFlags(loopInitializer) & 24576 /* BlockScoped */)) { // if loop initializer contains block scoped variables - they should be passed to converted loop body as parameters loopParameters = []; for (var _a = 0, _b = loopInitializer.declarations; _a < _b.length; _a++) { @@ -32334,10 +32777,12 @@ var ts; // // for (let v of arr) { } // - // we don't want to emit a temporary variable for the RHS, just use it directly. - var rhsIsIdentifier = node.expression.kind === 69 /* Identifier */; + // we can't reuse 'arr' because it might be modified within the body of the loop. var counter = createTempVariable(268435456 /* _i */); - var rhsReference = rhsIsIdentifier ? node.expression : createTempVariable(0 /* Auto */); + var rhsReference = ts.createSynthesizedNode(69 /* Identifier */); + rhsReference.text = node.expression.kind === 69 /* Identifier */ ? + makeUniqueName(node.expression.text) : + makeTempVariableName(0 /* Auto */); // This is the let keyword for the counter and rhsReference. The let keyword for // the LHS will be emitted inside the body. emitStart(node.expression); @@ -32346,15 +32791,13 @@ var ts; emitNodeWithoutSourceMap(counter); write(" = 0"); emitEnd(node.expression); - if (!rhsIsIdentifier) { - // , _a = expr - write(", "); - emitStart(node.expression); - emitNodeWithoutSourceMap(rhsReference); - write(" = "); - emitNodeWithoutSourceMap(node.expression); - emitEnd(node.expression); - } + // , _a = expr + write(", "); + emitStart(node.expression); + emitNodeWithoutSourceMap(rhsReference); + write(" = "); + emitNodeWithoutSourceMap(node.expression); + emitEnd(node.expression); write("; "); // _i < _a.length; emitStart(node.initializer); @@ -32609,7 +33052,7 @@ var ts; } function emitModuleMemberName(node) { emitStart(node.name); - if (ts.getCombinedNodeFlags(node) & 1 /* Export */) { + if (ts.getCombinedNodeFlags(node) & 2 /* Export */) { var container = getContainingModule(node); if (container) { write(getGeneratedNameForNode(container)); @@ -32631,7 +33074,7 @@ var ts; } function emitEs6ExportDefaultCompat(node) { if (node.parent.kind === 248 /* SourceFile */) { - ts.Debug.assert(!!(node.flags & 1024 /* Default */) || node.kind === 227 /* ExportAssignment */); + ts.Debug.assert(!!(node.flags & 512 /* Default */) || node.kind === 227 /* ExportAssignment */); // only allow export default at a source file level if (modulekind === 1 /* CommonJS */ || modulekind === 2 /* AMD */ || modulekind === 3 /* UMD */) { if (!currentSourceFile.symbol.exports["___esModule"]) { @@ -32649,7 +33092,7 @@ var ts; } } function emitExportMemberAssignment(node) { - if (node.flags & 1 /* Export */) { + if (node.flags & 2 /* Export */) { writeLine(); emitStart(node); // emit call to exporter only for top level nodes @@ -32657,7 +33100,7 @@ var ts; // emit export default as // export("default", ) write(exportFunctionForFile + "(\""); - if (node.flags & 1024 /* Default */) { + if (node.flags & 512 /* Default */) { write("default"); } else { @@ -32668,7 +33111,7 @@ var ts; write(")"); } else { - if (node.flags & 1024 /* Default */) { + if (node.flags & 512 /* Default */) { emitEs6ExportDefaultCompat(node); if (languageVersion === 0 /* ES3 */) { write("exports[\"default\"]"); @@ -32772,7 +33215,7 @@ var ts; // because actual variable declarations are hoisted var canDefineTempVariablesInPlace = false; if (root.kind === 211 /* VariableDeclaration */) { - var isExported = ts.getCombinedNodeFlags(root) & 1 /* Export */; + var isExported = ts.getCombinedNodeFlags(root) & 2 /* Export */; var isSourceLevelForSystemModuleKind = shouldHoistDeclarationInSystemJsModule(root); canDefineTempVariablesInPlace = !isExported && !isSourceLevelForSystemModuleKind; } @@ -32854,8 +33297,8 @@ var ts; // to ensure value is evaluated exactly once. value = ensureIdentifier(value, /*reuseIdentifierExpressions*/ true); } - for (var _a = 0; _a < properties.length; _a++) { - var p = properties[_a]; + for (var _a = 0, properties_5 = properties; _a < properties_5.length; _a++) { + var p = properties_5[_a]; if (p.kind === 245 /* PropertyAssignment */ || p.kind === 246 /* ShorthandPropertyAssignment */) { var propName = p.name; var target_1 = p.kind === 246 /* ShorthandPropertyAssignment */ ? p : p.initializer || propName; @@ -32990,7 +33433,7 @@ var ts; // this is necessary to preserve ES6 semantic in scenarios like // for (...) { let x; console.log(x); x = 1 } // assignment on one iteration should not affect other iterations var isLetDefinedInLoop = (resolver.getNodeCheckFlags(node) & 16384 /* BlockScopedBindingInLoop */) && - (getCombinedFlagsForIdentifier(node.name) & 16384 /* Let */); + (getCombinedFlagsForIdentifier(node.name) & 8192 /* Let */); // NOTE: default initialization should not be added to let bindings in for-in\for-of statements if (isLetDefinedInLoop && node.parent.parent.kind !== 200 /* ForInStatement */ && @@ -33030,13 +33473,13 @@ var ts; return ts.getCombinedNodeFlags(node.parent); } function isES6ExportedDeclaration(node) { - return !!(node.flags & 1 /* Export */) && + return !!(node.flags & 2 /* Export */) && modulekind === 5 /* ES6 */ && node.parent.kind === 248 /* SourceFile */; } function emitVariableStatement(node) { var startIsEmitted = false; - if (node.flags & 1 /* Export */) { + if (node.flags & 2 /* Export */) { if (isES6ExportedDeclaration(node)) { // Exported ES6 module member write("export "); @@ -33063,7 +33506,7 @@ var ts; function shouldEmitLeadingAndTrailingCommentsForVariableStatement(node) { // If we're not exporting the variables, there's nothing special here. // Always emit comments for these nodes. - if (!(node.flags & 1 /* Export */)) { + if (!(node.flags & 2 /* Export */)) { return true; } // If we are exporting, but it's a top-level ES6 module exports, @@ -33246,7 +33689,7 @@ var ts; if (!shouldEmitAsArrowFunction(node)) { if (isES6ExportedDeclaration(node)) { write("export "); - if (node.flags & 1024 /* Default */) { + if (node.flags & 512 /* Default */) { write("default "); } } @@ -33466,7 +33909,7 @@ var ts; emitRestParameter(node); } function emitExpressionFunctionBody(node, body) { - if (languageVersion < 2 /* ES6 */ || node.flags & 512 /* Async */) { + if (languageVersion < 2 /* ES6 */ || node.flags & 256 /* Async */) { emitDownLevelExpressionFunctionBody(node, body); return; } @@ -33487,7 +33930,7 @@ var ts; scopeEmitStart(node); increaseIndent(); var outPos = writer.getTextPos(); - emitDetachedComments(node.body); + emitDetachedCommentsAndUpdateCommentsInfo(node.body); emitFunctionBodyPreamble(node); var preambleEmitted = writer.getTextPos() !== outPos; decreaseIndent(); @@ -33525,7 +33968,7 @@ var ts; scopeEmitStart(node); var initialTextPos = writer.getTextPos(); increaseIndent(); - emitDetachedComments(body.statements); + emitDetachedCommentsAndUpdateCommentsInfo(body.statements); // Emit all the directive prologues (like "use strict"). These have to come before // any other preamble code we write (like parameter initializers). var startIndex = emitDirectivePrologues(body.statements, /*startWithNewLine*/ true); @@ -33569,7 +34012,7 @@ var ts; } function emitParameterPropertyAssignments(node) { ts.forEach(node.parameters, function (param) { - if (param.flags & 112 /* AccessibilityModifier */) { + if (param.flags & 56 /* AccessibilityModifier */) { writeLine(); emitStart(param); emitStart(param.name); @@ -33604,15 +34047,15 @@ var ts; var properties = []; for (var _a = 0, _b = node.members; _a < _b.length; _a++) { var member = _b[_a]; - if (member.kind === 141 /* PropertyDeclaration */ && isStatic === ((member.flags & 128 /* Static */) !== 0) && member.initializer) { + if (member.kind === 141 /* PropertyDeclaration */ && isStatic === ((member.flags & 64 /* Static */) !== 0) && member.initializer) { properties.push(member); } } return properties; } function emitPropertyDeclarations(node, properties) { - for (var _a = 0; _a < properties.length; _a++) { - var property = properties[_a]; + for (var _a = 0, properties_6 = properties; _a < properties_6.length; _a++) { + var property = properties_6[_a]; emitPropertyDeclaration(node, property); } } @@ -33625,7 +34068,7 @@ var ts; emit(receiver); } else { - if (property.flags & 128 /* Static */) { + if (property.flags & 64 /* Static */) { emitDeclarationName(node); } else { @@ -33724,7 +34167,7 @@ var ts; writeLine(); emitLeadingComments(member); emitStart(member); - if (member.flags & 128 /* Static */) { + if (member.flags & 64 /* Static */) { write("static "); } if (member.kind === 145 /* GetAccessor */) { @@ -33774,7 +34217,7 @@ var ts; emitCommentsOnNotEmittedNode(member); } // Check if there is any non-static property assignment - if (member.kind === 141 /* PropertyDeclaration */ && member.initializer && (member.flags & 128 /* Static */) === 0) { + if (member.kind === 141 /* PropertyDeclaration */ && member.initializer && (member.flags & 64 /* Static */) === 0) { hasInstancePropertyWithInitializer = true; } }); @@ -33821,7 +34264,7 @@ var ts; // Emit all the directive prologues (like "use strict"). These have to come before // any other preamble code we write (like parameter initializers). startIndex = emitDirectivePrologues(ctor.body.statements, /*startWithNewLine*/ true); - emitDetachedComments(ctor.body.statements); + emitDetachedCommentsAndUpdateCommentsInfo(ctor.body.statements); } emitCaptureThisForNodeIfNecessary(node); var superCall; @@ -33941,7 +34384,7 @@ var ts; // _default = __decorate([dec], _default); // export default _default; // - if (isES6ExportedDeclaration(node) && !(node.flags & 1024 /* Default */)) { + if (isES6ExportedDeclaration(node) && !(node.flags & 512 /* Default */)) { write("export "); } write("let "); @@ -33950,7 +34393,7 @@ var ts; } else if (isES6ExportedDeclaration(node)) { write("export "); - if (node.flags & 1024 /* Default */) { + if (node.flags & 512 /* Default */) { write("default "); } } @@ -33980,7 +34423,7 @@ var ts; // emit name if // - node has a name // - this is default export with static initializers - if ((node.name || (node.flags & 1024 /* Default */ && staticProperties.length > 0)) && !thisNodeIsDecorated) { + if ((node.name || (node.flags & 512 /* Default */ && staticProperties.length > 0)) && !thisNodeIsDecorated) { write(" "); emitDeclarationName(node); } @@ -34016,8 +34459,8 @@ 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 (isClassExpressionWithStaticProperties) { - for (var _a = 0; _a < staticProperties.length; _a++) { - var property = staticProperties[_a]; + for (var _a = 0, staticProperties_1 = staticProperties; _a < staticProperties_1.length; _a++) { + var property = staticProperties_1[_a]; write(","); writeLine(); emitPropertyDeclaration(node, property, /*receiver:*/ tempVariable, /*isExpression:*/ true); @@ -34035,7 +34478,7 @@ var ts; } // If this is an exported class, but not on the top level (i.e. on an internal // module), export it - if (!isES6ExportedDeclaration(node) && (node.flags & 1 /* Export */)) { + if (!isES6ExportedDeclaration(node) && (node.flags & 2 /* Export */)) { writeLine(); emitStart(node); emitModuleMemberName(node); @@ -34044,7 +34487,7 @@ var ts; emitEnd(node); write(";"); } - else if (isES6ExportedDeclaration(node) && (node.flags & 1024 /* Default */) && thisNodeIsDecorated) { + else if (isES6ExportedDeclaration(node) && (node.flags & 512 /* Default */) && thisNodeIsDecorated) { // if this is a top level default export of decorated class, write the export after the declaration. writeLine(); write("export default "); @@ -34126,13 +34569,13 @@ var ts; } function emitClassMemberPrefix(node, member) { emitDeclarationName(node); - if (!(member.flags & 128 /* Static */)) { + if (!(member.flags & 64 /* Static */)) { write(".prototype"); } } function emitDecoratorsOfClass(node) { emitDecoratorsOfMembers(node, /*staticFlag*/ 0); - emitDecoratorsOfMembers(node, 128 /* Static */); + emitDecoratorsOfMembers(node, 64 /* Static */); emitDecoratorsOfConstructor(node); } function emitDecoratorsOfConstructor(node) { @@ -34179,7 +34622,7 @@ var ts; for (var _a = 0, _b = node.members; _a < _b.length; _a++) { var member = _b[_a]; // only emit members in the correct group - if ((member.flags & 128 /* Static */) !== staticFlag) { + if ((member.flags & 64 /* Static */) !== staticFlag) { continue; } // skip members that cannot be decorated (such as the constructor) @@ -34580,7 +35023,7 @@ var ts; } if (!shouldHoistDeclarationInSystemJsModule(node)) { // do not emit var if variable was already hoisted - if (!(node.flags & 1 /* Export */) || isES6ExportedDeclaration(node)) { + if (!(node.flags & 2 /* Export */) || isES6ExportedDeclaration(node)) { emitStart(node); if (isES6ExportedDeclaration(node)) { write("export "); @@ -34611,7 +35054,7 @@ var ts; emitModuleMemberName(node); write(" = {}));"); emitEnd(node); - if (!isES6ExportedDeclaration(node) && node.flags & 1 /* Export */ && !shouldHoistDeclarationInSystemJsModule(node)) { + if (!isES6ExportedDeclaration(node) && node.flags & 2 /* Export */ && !shouldHoistDeclarationInSystemJsModule(node)) { // do not emit var if variable was already hoisted writeLine(); emitStart(node); @@ -34623,7 +35066,7 @@ var ts; write(";"); } if (modulekind !== 5 /* ES6 */ && node.parent === currentSourceFile) { - if (modulekind === 4 /* System */ && (node.flags & 1 /* Export */)) { + if (modulekind === 4 /* System */ && (node.flags & 2 /* Export */)) { // write the call to exporter for enum writeLine(); write(exportFunctionForFile + "(\""); @@ -34728,7 +35171,7 @@ var ts; } write(")("); // write moduleDecl = containingModule.m only if it is not exported es6 module member - if ((node.flags & 1 /* Export */) && !isES6ExportedDeclaration(node)) { + if ((node.flags & 2 /* Export */) && !isES6ExportedDeclaration(node)) { emit(node.name); write(" = "); } @@ -34738,7 +35181,7 @@ var ts; write(" = {}));"); emitEnd(node); if (!isES6ExportedDeclaration(node) && node.name.kind === 69 /* Identifier */ && node.parent === currentSourceFile) { - if (modulekind === 4 /* System */ && (node.flags & 1 /* Export */)) { + if (modulekind === 4 /* System */ && (node.flags & 2 /* Export */)) { writeLine(); write(exportFunctionForFile + "(\""); emitDeclarationName(node); @@ -34841,7 +35284,7 @@ var ts; } function emitExternalImportDeclaration(node) { if (ts.contains(externalImports, node)) { - var isExportedImport = node.kind === 221 /* ImportEqualsDeclaration */ && (node.flags & 1 /* Export */) !== 0; + var isExportedImport = node.kind === 221 /* ImportEqualsDeclaration */ && (node.flags & 2 /* Export */) !== 0; var namespaceDeclaration = getNamespaceDeclarationNode(node); if (modulekind !== 2 /* AMD */) { emitLeadingComments(node); @@ -34923,7 +35366,7 @@ var ts; write("export "); write("var "); } - else if (!(node.flags & 1 /* Export */)) { + else if (!(node.flags & 2 /* Export */)) { write("var "); } } @@ -35014,8 +35457,8 @@ var ts; function emitExportOrImportSpecifierList(specifiers, shouldEmit) { ts.Debug.assert(modulekind === 5 /* ES6 */); var needsComma = false; - for (var _a = 0; _a < specifiers.length; _a++) { - var specifier = specifiers[_a]; + for (var _a = 0, specifiers_1 = specifiers; _a < specifiers_1.length; _a++) { + var specifier = specifiers_1[_a]; if (shouldEmit(specifier)) { if (needsComma) { write(", "); @@ -35158,8 +35601,8 @@ var ts; } writeLine(); var started = false; - for (var _a = 0; _a < externalImports.length; _a++) { - var importNode = externalImports[_a]; + for (var _a = 0, externalImports_1 = externalImports; _a < externalImports_1.length; _a++) { + var importNode = externalImports_1[_a]; // do not create variable declaration for exports and imports that lack import clause var skipNode = importNode.kind === 228 /* ExportDeclaration */ || (importNode.kind === 222 /* ImportDeclaration */ && !importNode.importClause); @@ -35193,8 +35636,8 @@ var ts; // no exported declarations (export var ...) or export specifiers (export {x}) // check if we have any non star export declarations. var hasExportDeclarationWithExportClause = false; - for (var _a = 0; _a < externalImports.length; _a++) { - var externalImport = externalImports[_a]; + for (var _a = 0, externalImports_2 = externalImports; _a < externalImports_2.length; _a++) { + var externalImport = externalImports_2[_a]; if (externalImport.kind === 228 /* ExportDeclaration */ && externalImport.exportClause) { hasExportDeclarationWithExportClause = true; break; @@ -35225,8 +35668,8 @@ var ts; } } } - for (var _d = 0; _d < externalImports.length; _d++) { - var externalImport = externalImports[_d]; + for (var _d = 0, externalImports_3 = externalImports; _d < externalImports_3.length; _d++) { + var externalImport = externalImports_3[_d]; if (externalImport.kind !== 228 /* ExportDeclaration */) { continue; } @@ -35275,7 +35718,7 @@ var ts; function writeExportedName(node) { // do not record default exports // they are local to module and never overwritten (explicitly skipped) by star export - if (node.kind !== 69 /* Identifier */ && node.flags & 1024 /* Default */) { + if (node.kind !== 69 /* Identifier */ && node.flags & 512 /* Default */) { return; } if (started) { @@ -35338,7 +35781,7 @@ var ts; emit(local); } var flags = ts.getCombinedNodeFlags(local.kind === 69 /* Identifier */ ? local.parent : local); - if (flags & 1 /* Export */) { + if (flags & 2 /* Export */) { if (!exportedDeclarations) { exportedDeclarations = []; } @@ -35348,11 +35791,11 @@ var ts; write(";"); } if (hoistedFunctionDeclarations) { - for (var _a = 0; _a < hoistedFunctionDeclarations.length; _a++) { - var f = hoistedFunctionDeclarations[_a]; + for (var _a = 0, hoistedFunctionDeclarations_1 = hoistedFunctionDeclarations; _a < hoistedFunctionDeclarations_1.length; _a++) { + var f = hoistedFunctionDeclarations_1[_a]; writeLine(); emit(f); - if (f.flags & 1 /* Export */) { + if (f.flags & 2 /* Export */) { if (!exportedDeclarations) { exportedDeclarations = []; } @@ -35362,7 +35805,7 @@ var ts; } return exportedDeclarations; function visit(node) { - if (node.flags & 2 /* Ambient */) { + if (node.flags & 4 /* Ambient */) { return; } if (node.kind === 213 /* FunctionDeclaration */) { @@ -35437,7 +35880,7 @@ var ts; // - it is top level block scoped // if block scoped variables are nested in some another block then // no other functions can use them except ones that are defined at least in the same block - return (ts.getCombinedNodeFlags(node) & 49152 /* BlockScoped */) === 0 || + return (ts.getCombinedNodeFlags(node) & 24576 /* BlockScoped */) === 0 || ts.getEnclosingBlockScopeContainer(node).kind === 248 /* SourceFile */; } function isCurrentFileSystemExternalModule() { @@ -35509,8 +35952,8 @@ var ts; var parameterName = makeUniqueName(ts.forEach(group, getLocalNameForExternalImport) || ""); write("function (" + parameterName + ") {"); increaseIndent(); - for (var _a = 0; _a < group.length; _a++) { - var entry = group[_a]; + for (var _a = 0, group_1 = group; _a < group_1.length; _a++) { + var entry = group_1[_a]; var importVariableName = getLocalNameForExternalImport(entry) || ""; switch (entry.kind) { case 222 /* ImportDeclaration */: @@ -35679,8 +36122,8 @@ var ts; unaliasedModuleNames.push("\"" + amdDependency.path + "\""); } } - for (var _c = 0; _c < externalImports.length; _c++) { - var importNode = externalImports[_c]; + for (var _c = 0, externalImports_4 = externalImports; _c < externalImports_4.length; _c++) { + var importNode = externalImports_4[_c]; // Find the name of the external module var externalModuleName = getExternalModuleNameText(importNode); // Find the name of the module alias, if there is one @@ -35959,7 +36402,7 @@ var ts; // Start new file on new line writeLine(); emitShebang(); - emitDetachedComments(node); + emitDetachedCommentsAndUpdateCommentsInfo(node); if (ts.isExternalModule(node) || compilerOptions.isolatedModules) { var emitModule = moduleEmitDelegates[modulekind] || moduleEmitDelegates[1 /* CommonJS */]; emitModule(node); @@ -35983,7 +36426,7 @@ var ts; } function emitNodeConsideringCommentsOption(node, emitNodeConsideringSourcemap) { if (node) { - if (node.flags & 2 /* Ambient */) { + if (node.flags & 4 /* Ambient */) { return emitCommentsOnNotEmittedNode(node); } if (isSpecializedCommentHandling(node)) { @@ -36232,10 +36675,6 @@ var ts; } return leadingComments; } - function isPinnedComments(comment) { - return currentSourceFile.text.charCodeAt(comment.pos + 1) === 42 /* asterisk */ && - currentSourceFile.text.charCodeAt(comment.pos + 2) === 33 /* exclamation */; - } /** * Determine if the given comment is a triple-slash * @@ -36350,57 +36789,14 @@ var ts; // Leading comments are emitted at /*leading comment1 */space/*leading comment*/space ts.emitComments(currentSourceFile, writer, leadingComments, /*trailingSeparator*/ true, newLine, writeComment); } - function emitDetachedComments(node) { - var leadingComments; - if (compilerOptions.removeComments) { - // removeComments is true, only reserve pinned comment at the top of file - // For example: - // /*! Pinned Comment */ - // - // var x = 10; - if (node.pos === 0) { - leadingComments = ts.filter(ts.getLeadingCommentRanges(currentSourceFile.text, node.pos), isPinnedComments); + function emitDetachedCommentsAndUpdateCommentsInfo(node) { + var currentDetachedCommentInfo = ts.emitDetachedComments(currentSourceFile, writer, writeComment, node, newLine, compilerOptions.removeComments); + if (currentDetachedCommentInfo) { + if (detachedCommentsInfo) { + detachedCommentsInfo.push(currentDetachedCommentInfo); } - } - else { - // removeComments is false, just get detached as normal and bypass the process to filter comment - leadingComments = ts.getLeadingCommentRanges(currentSourceFile.text, node.pos); - } - if (leadingComments) { - var detachedComments = []; - var lastComment; - ts.forEach(leadingComments, function (comment) { - if (lastComment) { - var lastCommentLine = ts.getLineOfLocalPosition(currentSourceFile, lastComment.end); - var commentLine = ts.getLineOfLocalPosition(currentSourceFile, comment.pos); - if (commentLine >= lastCommentLine + 2) { - // There was a blank line between the last comment and this comment. This - // comment is not part of the copyright comments. Return what we have so - // far. - return detachedComments; - } - } - detachedComments.push(comment); - lastComment = comment; - }); - if (detachedComments.length) { - // All comments look like they could have been part of the copyright header. Make - // sure there is at least one blank line between it and the node. If not, it's not - // a copyright header. - var lastCommentLine = ts.getLineOfLocalPosition(currentSourceFile, ts.lastOrUndefined(detachedComments).end); - var nodeLine = ts.getLineOfLocalPosition(currentSourceFile, ts.skipTrivia(currentSourceFile.text, node.pos)); - if (nodeLine >= lastCommentLine + 2) { - // Valid detachedComments - ts.emitNewLineBeforeLeadingComments(currentSourceFile, writer, node, leadingComments); - ts.emitComments(currentSourceFile, writer, detachedComments, /*trailingSeparator*/ true, newLine, writeComment); - var currentDetachedCommentInfo = { nodePos: node.pos, detachedCommentEndPos: ts.lastOrUndefined(detachedComments).end }; - if (detachedCommentsInfo) { - detachedCommentsInfo.push(currentDetachedCommentInfo); - } - else { - detachedCommentsInfo = [currentDetachedCommentInfo]; - } - } + else { + detachedCommentsInfo = [currentDetachedCommentInfo]; } } } @@ -36716,7 +37112,7 @@ var ts; var resolveModuleNamesWorker = host.resolveModuleNames ? (function (moduleNames, containingFile) { return host.resolveModuleNames(moduleNames, containingFile); }) : (function (moduleNames, containingFile) { return ts.map(moduleNames, function (moduleName) { return resolveModuleName(moduleName, containingFile, options, host).resolvedModule; }); }); - var filesByName = ts.createFileMap(getCanonicalFileName); + var filesByName = ts.createFileMap(); // stores 'filename -> file association' ignoring case // used to track cases when two file names differ only in casing var filesByNameIgnoreCase = host.useCaseSensitiveFileNames() ? ts.createFileMap(function (fileName) { return fileName.toLowerCase(); }) : undefined; @@ -36774,8 +37170,8 @@ var ts; // Initialize a checker so that all our files are bound. getTypeChecker(); classifiableNames = {}; - for (var _i = 0; _i < files.length; _i++) { - var sourceFile = files[_i]; + for (var _i = 0, files_3 = files; _i < files_3.length; _i++) { + var sourceFile = files_3[_i]; ts.copyMap(sourceFile.classifiableNames, classifiableNames); } } @@ -36793,7 +37189,7 @@ var ts; } // check if program source files has changed in the way that can affect structure of the program var newSourceFiles = []; - var normalizedAbsoluteFileNames = []; + var filePaths = []; var modifiedSourceFiles = []; for (var _i = 0, _a = oldProgram.getSourceFiles(); _i < _a.length; _i++) { var oldSourceFile = _a[_i]; @@ -36801,8 +37197,8 @@ var ts; if (!newSourceFile) { return false; } - var normalizedAbsolutePath = ts.getNormalizedAbsolutePath(newSourceFile.fileName, currentDirectory); - normalizedAbsoluteFileNames.push(normalizedAbsolutePath); + newSourceFile.path = oldSourceFile.path; + filePaths.push(newSourceFile.path); if (oldSourceFile !== newSourceFile) { if (oldSourceFile.hasNoDefaultLib !== newSourceFile.hasNoDefaultLib) { // value of no-default-lib has changed @@ -36822,7 +37218,7 @@ var ts; } if (resolveModuleNamesWorker) { var moduleNames = ts.map(newSourceFile.imports, function (name) { return name.text; }); - var resolutions = resolveModuleNamesWorker(moduleNames, normalizedAbsolutePath); + var resolutions = resolveModuleNamesWorker(moduleNames, ts.getNormalizedAbsolutePath(newSourceFile.fileName, currentDirectory)); // ensure that module resolution results are still correct for (var i = 0; i < moduleNames.length; ++i) { var newResolution = resolutions[i]; @@ -36850,12 +37246,12 @@ var ts; } // update fileName -> file mapping for (var i = 0, len = newSourceFiles.length; i < len; ++i) { - filesByName.set(normalizedAbsoluteFileNames[i], newSourceFiles[i]); + filesByName.set(filePaths[i], newSourceFiles[i]); } files = newSourceFiles; fileProcessingDiagnostics = oldProgram.getFileProcessingDiagnostics(); - for (var _b = 0; _b < modifiedSourceFiles.length; _b++) { - var modifiedFile = modifiedSourceFiles[_b]; + for (var _b = 0, modifiedSourceFiles_1 = modifiedSourceFiles; _b < modifiedSourceFiles_1.length; _b++) { + var modifiedFile = modifiedSourceFiles_1[_b]; fileProcessingDiagnostics.reattachFileDiagnostics(modifiedFile); } oldProgram.structureIsReused = true; @@ -36905,7 +37301,7 @@ var ts; return emitResult; } function getSourceFile(fileName) { - return filesByName.get(ts.getNormalizedAbsolutePath(fileName, currentDirectory)); + return filesByName.get(ts.toPath(fileName, currentDirectory, getCanonicalFileName)); } function getDiagnosticsHelper(sourceFile, getDiagnostics, cancellationToken) { if (sourceFile) { @@ -37024,7 +37420,7 @@ var ts; } break; case 218 /* ModuleDeclaration */: - if (node.name.kind === 9 /* StringLiteral */ && (node.flags & 2 /* Ambient */ || ts.isDeclarationFile(file))) { + if (node.name.kind === 9 /* StringLiteral */ && (node.flags & 4 /* Ambient */ || ts.isDeclarationFile(file))) { // TypeScript 1.0 spec (April 2014): 12.1.6 // An AmbientExternalModuleDeclaration declares an external module. // This type of declaration is permitted only in the global module. @@ -37049,7 +37445,7 @@ var ts; diagnostic = ts.Diagnostics.File_0_has_unsupported_extension_The_only_supported_extensions_are_1; diagnosticArgument = [fileName, "'" + ts.supportedExtensions.join("', '") + "'"]; } - else if (!findSourceFile(fileName, ts.getNormalizedAbsolutePath(fileName, currentDirectory), isDefaultLib, 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]; } @@ -37059,13 +37455,13 @@ var ts; } } else { - var nonTsFile = options.allowNonTsExtensions && findSourceFile(fileName, ts.getNormalizedAbsolutePath(fileName, currentDirectory), isDefaultLib, 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(ts.supportedExtensions, function (extension) { return findSourceFile(fileName + extension, ts.getNormalizedAbsolutePath(fileName + extension, currentDirectory), isDefaultLib, refFile, refPos, refEnd); })) { + else if (!ts.forEach(ts.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]; @@ -37111,6 +37507,7 @@ var ts; }); filesByName.set(normalizedAbsolutePath, file); if (file) { + file.path = normalizedAbsolutePath; if (host.useCaseSensitiveFileNames()) { // for case-sensitive file systems check if we've already seen some file with similar filename ignoring case var existingFile = filesByNameIgnoreCase.get(normalizedAbsolutePath); @@ -37157,13 +37554,7 @@ var ts; var resolution = resolutions[i]; ts.setResolvedModule(file, moduleNames[i], resolution); if (resolution && !options.noResolve) { - var absoluteImportPath = ts.isRootedDiskPath(resolution.resolvedFileName) - ? resolution.resolvedFileName - : ts.getNormalizedAbsolutePath(resolution.resolvedFileName, currentDirectory); - // convert an absolute import path to path that is relative to current directory - // this was host still can locate it but files names in user output will be shorter (and thus look nicer). - var relativePath = ts.getRelativePathToDirectoryOrUrl(currentDirectory, absoluteImportPath, currentDirectory, getCanonicalFileName, false); - var importedFile = findSourceFile(relativePath, absoluteImportPath, /* isDefaultLib */ false, file, ts.skipTrivia(file.text, file.imports[i].pos), file.imports[i].end); + var importedFile = findSourceFile(resolution.resolvedFileName, ts.toPath(resolution.resolvedFileName, currentDirectory, getCanonicalFileName), /* isDefaultLib */ false, file, ts.skipTrivia(file.text, file.imports[i].pos), file.imports[i].end); if (importedFile && resolution.isExternalLibraryImport) { if (!ts.isExternalModule(importedFile)) { var start_2 = ts.getTokenPosOfNode(file.imports[i], file); @@ -37219,8 +37610,8 @@ var ts; var allFilesBelongToPath = true; if (sourceFiles) { var absoluteRootDirectoryPath = host.getCanonicalFileName(ts.getNormalizedAbsolutePath(rootDirectory, currentDirectory)); - for (var _i = 0; _i < sourceFiles.length; _i++) { - var sourceFile = sourceFiles[_i]; + for (var _i = 0, sourceFiles_1 = sourceFiles; _i < sourceFiles_1.length; _i++) { + var sourceFile = sourceFiles_1[_i]; if (!ts.isDeclarationFile(sourceFile)) { var absoluteSourceFilePath = host.getCanonicalFileName(ts.getNormalizedAbsolutePath(sourceFile.fileName, currentDirectory)); if (absoluteSourceFilePath.indexOf(absoluteRootDirectoryPath) !== 0) { @@ -37344,6 +37735,7 @@ var ts; /// /// /// +/// /// var ts; (function (ts) { @@ -37493,6 +37885,12 @@ var ts; type: "boolean", description: ts.Diagnostics.Do_not_erase_const_enum_declarations_in_generated_code }, + { + name: "pretty", + paramType: ts.Diagnostics.KIND, + description: ts.Diagnostics.Stylize_errors_and_messages_using_color_and_context_experimental, + type: "boolean" + }, { name: "project", shortName: "p", @@ -37591,11 +37989,31 @@ var ts; description: ts.Diagnostics.Specifies_module_resolution_strategy_Colon_node_Node_js_or_classic_TypeScript_pre_1_6, error: ts.Diagnostics.Argument_for_moduleResolution_option_must_be_node_or_classic }, + { + 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 - }, + } ]; var optionNameMapCache; /* @internal */ @@ -37734,13 +38152,38 @@ var ts; */ function parseConfigFileTextToJson(fileName, jsonText) { try { - return { config: /\S/.test(jsonText) ? JSON.parse(jsonText) : {} }; + var jsonTextWithoutComments = removeComments(jsonText); + return { config: /\S/.test(jsonTextWithoutComments) ? JSON.parse(jsonTextWithoutComments) : {} }; } catch (e) { return { error: ts.createCompilerDiagnostic(ts.Diagnostics.Failed_to_parse_file_0_Colon_1, fileName, e.message) }; } } ts.parseConfigFileTextToJson = parseConfigFileTextToJson; + /** + * Remove the comments from a json like text. + * Comments can be single line comments (starting with # or //) or multiline comments using / * * / + * + * This method replace comment content by whitespace rather than completely remove them to keep positions in json parsing error reporting accurate. + */ + function removeComments(jsonText) { + var output = ""; + var scanner = ts.createScanner(1 /* ES5 */, /* skipTrivia */ false, 0 /* Standard */, jsonText); + var token; + while ((token = scanner.scan()) !== 1 /* EndOfFileToken */) { + switch (token) { + case 2 /* SingleLineCommentTrivia */: + case 3 /* MultiLineCommentTrivia */: + // replace comments with whitespace to preserve original character positions + output += scanner.getTokenText().replace(/\S/g, " "); + break; + default: + output += scanner.getTokenText(); + break; + } + } + return output; + } /** * Parse the contents of a config file (tsconfig.json). * @param json The contents of the config file to parse @@ -37871,8 +38314,8 @@ var ts; var lastSingleLineCommentEnd = -1; var isFirstSingleLineComment = true; var singleLineCommentCount = 0; - for (var _i = 0; _i < comments.length; _i++) { - var currentComment = comments[_i]; + for (var _i = 0, comments_2 = comments; _i < comments_2.length; _i++) { + var currentComment = comments_2[_i]; // For single line comments, combine consecutive ones (2 or more) into // a single span from the start of the first till the end of the last if (currentComment.kind === 2 /* SingleLineCommentTrivia */) { @@ -38004,6 +38447,8 @@ var ts; function getNavigateToItems(program, cancellationToken, searchValue, maxResultCount) { 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(program.getSourceFiles(), function (sourceFile) { cancellationToken.throwIfCancellationRequested(); @@ -38017,8 +38462,8 @@ var ts; if (!matches) { continue; } - for (var _i = 0; _i < declarations.length; _i++) { - var declaration = declarations[_i]; + for (var _i = 0, declarations_6 = declarations; _i < declarations_6.length; _i++) { + var declaration = declarations_6[_i]; // It was a match! If the pattern has dots in it, then also see if the // declaration container matches as well. if (patternMatcher.patternContainsDots) { @@ -38047,8 +38492,8 @@ var ts; function allMatchesAreCaseSensitive(matches) { ts.Debug.assert(matches.length > 0); // This is a case sensitive match, only if all the submatches were case sensitive. - for (var _i = 0; _i < matches.length; _i++) { - var match = matches[_i]; + for (var _i = 0, matches_1 = matches; _i < matches_1.length; _i++) { + var match = matches_1[_i]; if (!match.isCaseSensitive) { return false; } @@ -38123,8 +38568,8 @@ var ts; function bestMatchKind(matches) { ts.Debug.assert(matches.length > 0); var bestMatchKind = ts.PatternMatchKind.camelCase; - for (var _i = 0; _i < matches.length; _i++) { - var match = matches[_i]; + for (var _i = 0, matches_2 = matches; _i < matches_2.length; _i++) { + var match = matches_2[_i]; var kind = match.kind; if (kind < bestMatchKind) { bestMatchKind = kind; @@ -38132,8 +38577,6 @@ var ts; } return bestMatchKind; } - // This means "compare in a case insensitive manner." - var baseSensitivity = { sensitivity: "base" }; function compareNavigateToItems(i1, i2) { // TODO(cyrusn): get the gamut of comparisons that VS already uses here. // Right now we just sort by kind first, and then by name of the item. @@ -38296,8 +38739,8 @@ var ts; } function addTopLevelNodes(nodes, topLevelNodes) { nodes = sortNodes(nodes); - for (var _i = 0; _i < nodes.length; _i++) { - var node = nodes[_i]; + for (var _i = 0, nodes_4 = nodes; _i < nodes_4.length; _i++) { + var node = nodes_4[_i]; switch (node.kind) { case 214 /* ClassDeclaration */: case 217 /* EnumDeclaration */: @@ -38340,8 +38783,8 @@ var ts; function getItemsWorker(nodes, createItem) { var items = []; var keyToItem = {}; - for (var _i = 0; _i < nodes.length; _i++) { - var child = nodes[_i]; + for (var _i = 0, nodes_5 = nodes; _i < nodes_5.length; _i++) { + var child = nodes_5[_i]; var item = createItem(child); if (item !== undefined) { if (item.text.length > 0) { @@ -38389,7 +38832,7 @@ var ts; if (ts.isBindingPattern(node.name)) { break; } - if ((node.flags & 2035 /* Modifier */) === 0) { + if ((node.flags & 1022 /* Modifier */) === 0) { return undefined; } return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberVariableElement); @@ -38693,8 +39136,8 @@ var ts; // word part. That way we don't match something like 'Class' when the user types 'a'. // But we would match 'FooAttribute' (since 'Attribute' starts with 'a'). var wordSpans = getWordSpans(candidate); - for (var _i = 0; _i < wordSpans.length; _i++) { - var span = wordSpans[_i]; + for (var _i = 0, wordSpans_1 = wordSpans; _i < wordSpans_1.length; _i++) { + var span = wordSpans_1[_i]; if (partStartsWith(candidate, span, chunk.text, /*ignoreCase:*/ true)) { return createPatternMatch(PatternMatchKind.substring, punctuationStripped, /*isCaseSensitive:*/ partStartsWith(candidate, span, chunk.text, /*ignoreCase:*/ false)); @@ -38800,8 +39243,8 @@ var ts; // Only if all words have some sort of match is the pattern considered matched. var subWordTextChunks = segment.subWordTextChunks; var matches = undefined; - for (var _i = 0; _i < subWordTextChunks.length; _i++) { - var subWordTextChunk = subWordTextChunks[_i]; + for (var _i = 0, subWordTextChunks_1 = subWordTextChunks; _i < subWordTextChunks_1.length; _i++) { + var subWordTextChunk = subWordTextChunks_1[_i]; // Try to match the candidate with this word var result = matchTextChunk(candidate, subWordTextChunk, /*punctuationStripped:*/ true); if (!result) { @@ -39386,8 +39829,8 @@ var ts; var nameToDeclarations = sourceFile_1.getNamedDeclarations(); var declarations = ts.getProperty(nameToDeclarations, name.text); if (declarations) { - for (var _b = 0; _b < declarations.length; _b++) { - var declaration = declarations[_b]; + for (var _b = 0, declarations_7 = declarations; _b < declarations_7.length; _b++) { + var declaration = declarations_7[_b]; var symbol = declaration.symbol; if (symbol) { var type = typeChecker.getTypeOfSymbolAtLocation(symbol, declaration); @@ -39503,8 +39946,8 @@ var ts; // arg index. var argumentIndex = 0; var listChildren = argumentsList.getChildren(); - for (var _i = 0; _i < listChildren.length; _i++) { - var child = listChildren[_i]; + for (var _i = 0, listChildren_1 = listChildren; _i < listChildren_1.length; _i++) { + var child = listChildren_1[_i]; if (child === node) { break; } @@ -40049,8 +40492,8 @@ var ts; return n; } var children = n.getChildren(); - for (var _i = 0; _i < children.length; _i++) { - var child = children[_i]; + for (var _i = 0, children_1 = children; _i < children_1.length; _i++) { + var child = children_1[_i]; var shouldDiveInChildNode = // previous token is enclosed somewhere in the child (child.pos <= previousToken.pos && child.end > previousToken.end) || @@ -40212,17 +40655,17 @@ var ts; function getNodeModifiers(node) { var flags = ts.getCombinedNodeFlags(node); var result = []; - if (flags & 32 /* Private */) + if (flags & 16 /* Private */) result.push(ts.ScriptElementKindModifier.privateMemberModifier); - if (flags & 64 /* Protected */) + if (flags & 32 /* Protected */) result.push(ts.ScriptElementKindModifier.protectedMemberModifier); - if (flags & 16 /* Public */) + if (flags & 8 /* Public */) result.push(ts.ScriptElementKindModifier.publicMemberModifier); - if (flags & 128 /* Static */) + if (flags & 64 /* Static */) result.push(ts.ScriptElementKindModifier.staticModifier); - if (flags & 256 /* Abstract */) + if (flags & 128 /* Abstract */) result.push(ts.ScriptElementKindModifier.abstractModifier); - if (flags & 1 /* Export */) + if (flags & 2 /* Export */) result.push(ts.ScriptElementKindModifier.exportedModifier); if (ts.isInAmbientContext(node)) result.push(ts.ScriptElementKindModifier.ambientModifier); @@ -42366,8 +42809,8 @@ var ts; } } var inheritedIndentation = -1 /* Unknown */; - for (var _i = 0; _i < nodes.length; _i++) { - var child = nodes[_i]; + for (var _i = 0, nodes_6 = nodes; _i < nodes_6.length; _i++) { + var child = nodes_6[_i]; inheritedIndentation = processChildNode(child, inheritedIndentation, node, listDynamicIndentation, startLine, startLine, /*isListElement*/ true); } if (listEndToken !== 0 /* Unknown */) { @@ -42458,8 +42901,8 @@ var ts; } } function processTrivia(trivia, parent, contextNode, dynamicIndentation) { - for (var _i = 0; _i < trivia.length; _i++) { - var triviaItem = trivia[_i]; + for (var _i = 0, trivia_1 = trivia; _i < trivia_1.length; _i++) { + var triviaItem = trivia_1[_i]; if (ts.isComment(triviaItem.kind) && ts.rangeContainsRange(originalRange, triviaItem)) { var triviaItemStart = sourceFile.getLineAndCharacterOfPosition(triviaItem.pos); processRange(triviaItem, triviaItemStart, parent, contextNode, dynamicIndentation); @@ -43056,7 +43499,6 @@ var ts; return node; } } - return node; } } function deriveActualIndentationFromList(list, index, sourceFile, options) { @@ -43307,17 +43749,17 @@ var ts; while (pos < end) { var token = scanner.scan(); var textPos = scanner.getTextPos(); - nodes.push(createNode(token, pos, textPos, 4096 /* Synthetic */, this)); + nodes.push(createNode(token, pos, textPos, 2048 /* Synthetic */, this)); pos = textPos; } return pos; }; NodeObject.prototype.createSyntaxList = function (nodes) { - var list = createNode(271 /* SyntaxList */, nodes.pos, nodes.end, 4096 /* Synthetic */, this); + var list = createNode(271 /* SyntaxList */, nodes.pos, nodes.end, 2048 /* Synthetic */, this); list._children = []; var pos = nodes.pos; - for (var _i = 0; _i < nodes.length; _i++) { - var node = nodes[_i]; + for (var _i = 0, nodes_7 = nodes; _i < nodes_7.length; _i++) { + var node = nodes_7[_i]; if (pos < node.pos) { pos = this.addSyntheticNodes(list._children, pos, node.pos); } @@ -43872,7 +44314,7 @@ var ts; break; case 138 /* Parameter */: // Only consider properties defined as constructor parameters - if (!(node.flags & 112 /* AccessibilityModifier */)) { + if (!(node.flags & 56 /* AccessibilityModifier */)) { break; } // fall through @@ -44148,13 +44590,15 @@ var ts; var HostCache = (function () { function HostCache(host, getCanonicalFileName) { this.host = host; + this.getCanonicalFileName = getCanonicalFileName; // script id => script index - this.fileNameToEntry = ts.createFileMap(getCanonicalFileName); + this.currentDirectory = host.getCurrentDirectory(); + this.fileNameToEntry = ts.createFileMap(); // Initialize the list with the root file names var rootFileNames = host.getScriptFileNames(); - for (var _i = 0; _i < rootFileNames.length; _i++) { - var fileName = rootFileNames[_i]; - this.createEntry(fileName); + for (var _i = 0, rootFileNames_1 = rootFileNames; _i < rootFileNames_1.length; _i++) { + var fileName = rootFileNames_1[_i]; + this.createEntry(fileName, ts.toPath(fileName, this.currentDirectory, getCanonicalFileName)); } // store the compilation settings this._compilationSettings = host.getCompilationSettings() || getDefaultCompilerOptions(); @@ -44162,7 +44606,7 @@ var ts; HostCache.prototype.compilationSettings = function () { return this._compilationSettings; }; - HostCache.prototype.createEntry = function (fileName) { + HostCache.prototype.createEntry = function (fileName, path) { var entry; var scriptSnapshot = this.host.getScriptSnapshot(fileName); if (scriptSnapshot) { @@ -44172,36 +44616,37 @@ var ts; scriptSnapshot: scriptSnapshot }; } - this.fileNameToEntry.set(fileName, entry); + this.fileNameToEntry.set(path, entry); return entry; }; - HostCache.prototype.getEntry = function (fileName) { - return this.fileNameToEntry.get(fileName); + HostCache.prototype.getEntry = function (path) { + return this.fileNameToEntry.get(path); }; - HostCache.prototype.contains = function (fileName) { - return this.fileNameToEntry.contains(fileName); + HostCache.prototype.contains = function (path) { + return this.fileNameToEntry.contains(path); }; HostCache.prototype.getOrCreateEntry = function (fileName) { - if (this.contains(fileName)) { - return this.getEntry(fileName); + var path = ts.toPath(fileName, this.currentDirectory, this.getCanonicalFileName); + if (this.contains(path)) { + return this.getEntry(path); } - return this.createEntry(fileName); + return this.createEntry(fileName, path); }; HostCache.prototype.getRootFileNames = function () { var fileNames = []; - this.fileNameToEntry.forEachValue(function (value) { + this.fileNameToEntry.forEachValue(function (path, value) { if (value) { fileNames.push(value.hostFileName); } }); return fileNames; }; - HostCache.prototype.getVersion = function (fileName) { - var file = this.getEntry(fileName); + HostCache.prototype.getVersion = function (path) { + var file = this.getEntry(path); return file && file.version; }; - HostCache.prototype.getScriptSnapshot = function (fileName) { - var file = this.getEntry(fileName); + HostCache.prototype.getScriptSnapshot = function (path) { + var file = this.getEntry(path); return file && file.scriptSnapshot; }; return HostCache; @@ -44383,7 +44828,8 @@ var ts; : (function (fileName) { return fileName.toLowerCase(); }); } ts.createGetCanonicalFileName = createGetCanonicalFileName; - function createDocumentRegistry(useCaseSensitiveFileNames) { + function createDocumentRegistry(useCaseSensitiveFileNames, currentDirectory) { + if (currentDirectory === void 0) { currentDirectory = ""; } // Maps from compiler setting target (ES3, ES5, etc.) to all the cached documents we have // for those settings. var buckets = {}; @@ -44395,7 +44841,7 @@ var ts; var key = getKeyFromCompilationSettings(settings); var bucket = ts.lookUp(buckets, key); if (!bucket && createIfMissing) { - buckets[key] = bucket = ts.createFileMap(getCanonicalFileName); + buckets[key] = bucket = ts.createFileMap(); } return bucket; } @@ -44403,14 +44849,13 @@ var ts; var bucketInfoArray = Object.keys(buckets).filter(function (name) { return name && name.charAt(0) === '_'; }).map(function (name) { var entries = ts.lookUp(buckets, name); var sourceFiles = []; - for (var i in entries) { - var entry = entries.get(i); + entries.forEachValue(function (key, entry) { sourceFiles.push({ - name: i, + name: key, refCount: entry.languageServiceRefCount, references: entry.owners.slice(0) }); - } + }); sourceFiles.sort(function (x, y) { return y.refCount - x.refCount; }); return { bucket: name, @@ -44427,7 +44872,8 @@ var ts; } function acquireOrUpdateDocument(fileName, compilationSettings, scriptSnapshot, version, acquiring) { var bucket = getBucketForCompilationSettings(compilationSettings, /*createIfMissing*/ true); - var entry = bucket.get(fileName); + var path = ts.toPath(fileName, currentDirectory, getCanonicalFileName); + var entry = bucket.get(path); if (!entry) { ts.Debug.assert(acquiring, "How could we be trying to update a document that the registry doesn't have?"); // Have never seen this file with these settings. Create a new source file for it. @@ -44437,7 +44883,7 @@ var ts; languageServiceRefCount: 0, owners: [] }; - bucket.set(fileName, entry); + bucket.set(path, entry); } else { // We have an entry for this file. However, it may be for a different version of @@ -44460,11 +44906,12 @@ var ts; function releaseDocument(fileName, compilationSettings) { var bucket = getBucketForCompilationSettings(compilationSettings, false); ts.Debug.assert(bucket !== undefined); - var entry = bucket.get(fileName); + var path = ts.toPath(fileName, currentDirectory, getCanonicalFileName); + var entry = bucket.get(path); entry.languageServiceRefCount--; ts.Debug.assert(entry.languageServiceRefCount >= 0); if (entry.languageServiceRefCount === 0) { - bucket.remove(fileName); + bucket.remove(path); } } return { @@ -44871,7 +45318,7 @@ var ts; case 144 /* Constructor */: return ScriptElementKind.constructorImplementationElement; case 137 /* TypeParameter */: return ScriptElementKind.typeParameterElement; case 247 /* EnumMember */: return ScriptElementKind.variableElement; - case 138 /* Parameter */: return (node.flags & 112 /* AccessibilityModifier */) ? ScriptElementKind.memberVariableElement : ScriptElementKind.parameterElement; + case 138 /* Parameter */: return (node.flags & 56 /* AccessibilityModifier */) ? ScriptElementKind.memberVariableElement : ScriptElementKind.parameterElement; case 221 /* ImportEqualsDeclaration */: case 226 /* ImportSpecifier */: case 223 /* ImportClause */: @@ -44897,13 +45344,14 @@ var ts; return CancellationTokenObject; })(); function createLanguageService(host, documentRegistry) { - if (documentRegistry === void 0) { documentRegistry = createDocumentRegistry(); } + if (documentRegistry === void 0) { documentRegistry = createDocumentRegistry(host.useCaseSensitiveFileNames && host.useCaseSensitiveFileNames(), host.getCurrentDirectory()); } var syntaxTreeCache = new SyntaxTreeCache(host); var ruleProvider; var program; var lastProjectVersion; var useCaseSensitivefileNames = false; 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 if (!ts.localizedDiagnosticMessages && host.getLocalizedDiagnosticMessages) { ts.localizedDiagnosticMessages = host.getLocalizedDiagnosticMessages(); @@ -44915,8 +45363,7 @@ var ts; } var getCanonicalFileName = createGetCanonicalFileName(useCaseSensitivefileNames); function getValidSourceFile(fileName) { - fileName = ts.normalizeSlashes(fileName); - var sourceFile = program.getSourceFile(getCanonicalFileName(fileName)); + var sourceFile = program.getSourceFile(fileName); if (!sourceFile) { throw new Error("Could not find file: '" + fileName + "'."); } @@ -44968,7 +45415,7 @@ var ts; getNewLine: function () { return ts.getNewLineOrDefaultFromHost(host); }, getDefaultLibFileName: function (options) { return host.getDefaultLibFileName(options); }, writeFile: function (fileName, data, writeByteOrderMark) { }, - getCurrentDirectory: function () { return host.getCurrentDirectory(); }, + getCurrentDirectory: function () { return currentDirectory; }, fileExists: function (fileName) { // stub missing host functionality ts.Debug.assert(!host.resolveModuleNames); @@ -44988,11 +45435,10 @@ var ts; // not part of the new program. if (program) { var oldSourceFiles = program.getSourceFiles(); - for (var _i = 0; _i < oldSourceFiles.length; _i++) { - var oldSourceFile = oldSourceFiles[_i]; - var fileName = oldSourceFile.fileName; - if (!newProgram.getSourceFile(fileName) || changesInCompilationSettingsAffectSyntax) { - documentRegistry.releaseDocument(fileName, oldSettings); + for (var _i = 0, oldSourceFiles_1 = oldSourceFiles; _i < oldSourceFiles_1.length; _i++) { + var oldSourceFile = oldSourceFiles_1[_i]; + if (!newProgram.getSourceFile(oldSourceFile.fileName) || changesInCompilationSettingsAffectSyntax) { + documentRegistry.releaseDocument(oldSourceFile.fileName, oldSettings); } } } @@ -45048,7 +45494,8 @@ var ts; return documentRegistry.acquireDocument(fileName, newSettings, hostFileInformation.scriptSnapshot, hostFileInformation.version); } function sourceFileUpToDate(sourceFile) { - return sourceFile && sourceFile.version === hostCache.getVersion(sourceFile.fileName); + var path = sourceFile.path || ts.toPath(sourceFile.fileName, currentDirectory, getCanonicalFileName); + return sourceFile && sourceFile.version === hostCache.getVersion(path); } function programUpToDate() { // If we haven't create a program yet, then it is not up-to-date @@ -45061,8 +45508,8 @@ var ts; return false; } // If any file is not up-to-date, then the whole program is not up-to-date - for (var _i = 0; _i < rootFileNames.length; _i++) { - var fileName = rootFileNames[_i]; + for (var _i = 0, rootFileNames_2 = rootFileNames; _i < rootFileNames_2.length; _i++) { + var fileName = rootFileNames_2[_i]; if (!sourceFileUpToDate(program.getSourceFile(fileName))) { return false; } @@ -45237,8 +45684,8 @@ var ts; } function checkModifiers(modifiers) { if (modifiers) { - for (var _i = 0; _i < modifiers.length; _i++) { - var modifier = modifiers[_i]; + 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 */: @@ -45940,8 +46387,8 @@ var ts; */ function filterNamedImportOrExportCompletionItems(exportsOfModule, namedImportsOrExports) { var exisingImportsOrExports = {}; - for (var _i = 0; _i < namedImportsOrExports.length; _i++) { - var element = namedImportsOrExports[_i]; + for (var _i = 0, namedImportsOrExports_1 = namedImportsOrExports; _i < namedImportsOrExports_1.length; _i++) { + var element = namedImportsOrExports_1[_i]; // If this is the current item we are editing right now, do not filter it out if (element.getStart() <= position && position <= element.getEnd()) { continue; @@ -45965,8 +46412,8 @@ var ts; return contextualMemberSymbols; } var existingMemberNames = {}; - for (var _i = 0; _i < existingMembers.length; _i++) { - var m = existingMembers[_i]; + for (var _i = 0, existingMembers_1 = existingMembers; _i < existingMembers_1.length; _i++) { + var m = existingMembers_1[_i]; // Ignore omitted expressions for missing members if (m.kind !== 245 /* PropertyAssignment */ && m.kind !== 246 /* ShorthandPropertyAssignment */ && @@ -45999,8 +46446,8 @@ var ts; */ function filterJsxAttributes(symbols, attributes) { var seenNames = {}; - for (var _i = 0; _i < attributes.length; _i++) { - var attr = attributes[_i]; + for (var _i = 0, attributes_1 = attributes; _i < attributes_1.length; _i++) { + var attr = attributes_1[_i]; // If this is the current item we are editing right now, do not filter it out if (attr.getStart() <= position && position <= attr.getEnd()) { continue; @@ -46101,8 +46548,8 @@ var ts; var entries = []; if (symbols) { var nameToSymbol = {}; - for (var _i = 0; _i < symbols.length; _i++) { - var symbol = symbols[_i]; + for (var _i = 0, symbols_3 = symbols; _i < symbols_3.length; _i++) { + var symbol = symbols_3[_i]; var entry = createCompletionEntry(symbol, location); if (entry) { var id = ts.escapeIdentifier(entry.name); @@ -46844,8 +47291,8 @@ var ts; } var fileNameToDocumentHighlights = {}; var result = []; - for (var _i = 0; _i < referencedSymbols.length; _i++) { - var referencedSymbol = referencedSymbols[_i]; + for (var _i = 0, referencedSymbols_1 = referencedSymbols; _i < referencedSymbols_1.length; _i++) { + var referencedSymbol = referencedSymbols_1[_i]; for (var _a = 0, _b = referencedSymbol.references; _a < _b.length; _a++) { var referenceEntry = _b[_a]; var fileName_1 = referenceEntry.fileName; @@ -46989,7 +47436,6 @@ var ts; ts.forEachChild(node, aggregate); } } - ; } /** * For lack of a better name, this function takes a throw statement and returns the @@ -47027,7 +47473,6 @@ var ts; ts.forEachChild(node, aggregate); } } - ; } function ownsBreakOrContinueStatement(owner, statement) { var actualOwner = getBreakOrContinueOwner(statement); @@ -47096,7 +47541,7 @@ var ts; case 219 /* ModuleBlock */: case 248 /* SourceFile */: // Container is either a class declaration or the declaration is a classDeclaration - if (modifierFlag & 256 /* Abstract */) { + if (modifierFlag & 128 /* Abstract */) { nodes = declaration.members.concat(declaration); } else { @@ -47111,7 +47556,7 @@ var ts; nodes = container.members; // If we're an accessibility modifier, we're in an instance member and should search // the constructor's parameter list for instance members as well. - if (modifierFlag & 112 /* AccessibilityModifier */) { + if (modifierFlag & 56 /* AccessibilityModifier */) { var constructor = ts.forEach(container.members, function (member) { return member.kind === 144 /* Constructor */ && member; }); @@ -47119,7 +47564,7 @@ var ts; nodes = nodes.concat(constructor.parameters); } } - else if (modifierFlag & 256 /* Abstract */) { + else if (modifierFlag & 128 /* Abstract */) { nodes = nodes.concat(container); } break; @@ -47135,19 +47580,19 @@ var ts; function getFlagFromModifier(modifier) { switch (modifier) { case 112 /* PublicKeyword */: - return 16 /* Public */; + return 8 /* Public */; case 110 /* PrivateKeyword */: - return 32 /* Private */; + return 16 /* Private */; case 111 /* ProtectedKeyword */: - return 64 /* Protected */; + return 32 /* Protected */; case 113 /* StaticKeyword */: - return 128 /* Static */; + return 64 /* Static */; case 82 /* ExportKeyword */: - return 1 /* Export */; + return 2 /* Export */; case 122 /* DeclareKeyword */: - return 2 /* Ambient */; + return 4 /* Ambient */; case 115 /* AbstractKeyword */: - return 256 /* Abstract */; + return 128 /* Abstract */; default: ts.Debug.fail(); } @@ -47346,8 +47791,8 @@ var ts; return undefined; } var result = []; - for (var _i = 0; _i < documentHighlights.length; _i++) { - var entry = documentHighlights[_i]; + for (var _i = 0, documentHighlights_1 = documentHighlights; _i < documentHighlights_1.length; _i++) { + var entry = documentHighlights_1[_i]; for (var _a = 0, _b = entry.highlightSpans; _a < _b.length; _a++) { var highlightSpan = _b[_a]; result.push({ @@ -47365,8 +47810,8 @@ var ts; return undefined; } var referenceEntries = []; - for (var _i = 0; _i < referenceSymbols.length; _i++) { - var referenceSymbol = referenceSymbols[_i]; + for (var _i = 0, referenceSymbols_1 = referenceSymbols; _i < referenceSymbols_1.length; _i++) { + var referenceSymbol = referenceSymbols_1[_i]; ts.addRange(referenceEntries, referenceSymbol.references); } return referenceEntries; @@ -47451,8 +47896,8 @@ var ts; } else { var internedName = getInternedName(symbol, node, declarations); - for (var _i = 0; _i < sourceFiles.length; _i++) { - var sourceFile = sourceFiles[_i]; + for (var _i = 0, sourceFiles_2 = sourceFiles; _i < sourceFiles_2.length; _i++) { + var sourceFile = sourceFiles_2[_i]; cancellationToken.throwIfCancellationRequested(); var nameTable = getNameTable(sourceFile); if (ts.lookUp(nameTable, internedName)) { @@ -47512,7 +47957,7 @@ var ts; } // If this is private property or method, the scope is the containing class if (symbol.flags & (4 /* Property */ | 8192 /* Method */)) { - var privateDeclaration = ts.forEach(symbol.getDeclarations(), function (d) { return (d.flags & 32 /* Private */) ? d : undefined; }); + var privateDeclaration = ts.forEach(symbol.getDeclarations(), function (d) { return (d.flags & 16 /* Private */) ? d : undefined; }); if (privateDeclaration) { return ts.getAncestor(privateDeclaration, 214 /* ClassDeclaration */); } @@ -47530,8 +47975,8 @@ var ts; var scope = undefined; var declarations = symbol.getDeclarations(); if (declarations) { - for (var _i = 0; _i < declarations.length; _i++) { - var declaration = declarations[_i]; + for (var _i = 0, declarations_8 = declarations; _i < declarations_8.length; _i++) { + var declaration = declarations_8[_i]; var container = getContainerNode(declaration); if (!container) { return undefined; @@ -47711,7 +48156,7 @@ var ts; return undefined; } // Whether 'super' occurs in a static context within a class. - var staticFlag = 128 /* Static */; + var staticFlag = 64 /* Static */; switch (searchSpaceNode.kind) { case 141 /* PropertyDeclaration */: case 140 /* PropertySignature */: @@ -47739,7 +48184,7 @@ var ts; // If we have a 'super' container, we must have an enclosing class. // Now make sure the owning class is the same as the search-space // and has the same static qualifier as the original 'super's owner. - if (container && (128 /* Static */ & container.flags) === staticFlag && container.parent.symbol === searchSpaceNode.symbol) { + if (container && (64 /* Static */ & container.flags) === staticFlag && container.parent.symbol === searchSpaceNode.symbol) { references.push(getReferenceEntryFromNode(node)); } }); @@ -47749,7 +48194,7 @@ var ts; function getReferencesForThisKeyword(thisOrSuperKeyword, sourceFiles) { var searchSpaceNode = ts.getThisContainer(thisOrSuperKeyword, /* includeArrowFunctions */ false); // Whether 'this' occurs in a static context within a class. - var staticFlag = 128 /* Static */; + var staticFlag = 64 /* Static */; switch (searchSpaceNode.kind) { case 143 /* MethodDeclaration */: case 142 /* MethodSignature */: @@ -47827,7 +48272,7 @@ var ts; case 214 /* ClassDeclaration */: // Make sure the container belongs to the same class // and has the appropriate static modifier from the original container. - if (container.parent && searchSpaceNode.symbol === container.parent.symbol && (container.flags & 128 /* Static */) === staticFlag) { + if (container.parent && searchSpaceNode.symbol === container.parent.symbol && (container.flags & 64 /* Static */) === staticFlag) { result.push(getReferenceEntryFromNode(node)); } break; @@ -47998,8 +48443,8 @@ var ts; // To achieve that we will keep iterating until the result stabilizes. // Remember the last meaning lastIterationMeaning = meaning; - for (var _i = 0; _i < declarations.length; _i++) { - var declaration = declarations[_i]; + for (var _i = 0, declarations_9 = declarations; _i < declarations_9.length; _i++) { + var declaration = declarations_9[_i]; var declarationMeaning = getMeaningFromDeclaration(declaration); if (declarationMeaning & meaning) { meaning |= declarationMeaning; @@ -48115,7 +48560,6 @@ var ts; return 4 /* Namespace */ | 1 /* Value */; } return 1 /* Value */ | 2 /* Type */ | 4 /* Namespace */; - ts.Debug.fail("Unknown declaration type"); } function isTypeReference(node) { if (ts.isRightSideOfQualifiedNameOrPropertyAccess(node)) { @@ -48694,8 +49138,8 @@ var ts; if (matchKind) { var parentElement = token.parent; var childNodes = parentElement.getChildren(sourceFile); - for (var _i = 0; _i < childNodes.length; _i++) { - var current = childNodes[_i]; + for (var _i = 0, childNodes_1 = childNodes; _i < childNodes_1.length; _i++) { + var current = childNodes_1[_i]; if (current.kind === matchKind) { var range1 = ts.createTextSpan(token.getStart(sourceFile), token.getWidth(sourceFile)); var range2 = ts.createTextSpan(current.getStart(sourceFile), current.getWidth(sourceFile)); @@ -49025,8 +49469,8 @@ var ts; // Disallow rename for elements that are defined in the standard TypeScript library. var defaultLibFileName = host.getDefaultLibFileName(host.getCompilationSettings()); if (defaultLibFileName) { - for (var _i = 0; _i < declarations.length; _i++) { - var current = declarations[_i]; + for (var _i = 0, declarations_10 = declarations; _i < declarations_10.length; _i++) { + var current = declarations_10[_i]; var sourceFile_2 = current.getSourceFile(); var canonicalName = getCanonicalFileName(ts.normalizePath(sourceFile_2.fileName)); if (sourceFile_2 && getCanonicalFileName(ts.normalizePath(sourceFile_2.fileName)) === getCanonicalFileName(ts.normalizePath(defaultLibFileName))) { @@ -49609,7 +50053,7 @@ var ts; */ function spanInSourceFileAtLocation(sourceFile, position) { // Cannot set breakpoint in dts file - if (sourceFile.flags & 8192 /* DeclarationFile */) { + if (sourceFile.flags & 4096 /* DeclarationFile */) { return undefined; } var tokenAtLocation = ts.getTokenAtPosition(sourceFile, position); @@ -49827,7 +50271,7 @@ var ts; ? variableDeclaration.parent.parent.initializer.declarations : undefined; // Breakpoint is possible in variableDeclaration only if there is initialization - if (variableDeclaration.initializer || (variableDeclaration.flags & 1 /* Export */)) { + if (variableDeclaration.initializer || (variableDeclaration.flags & 2 /* Export */)) { if (declarations && declarations[0] === variableDeclaration) { if (isParentVariableStatement) { // First declaration - include let keyword @@ -49853,7 +50297,7 @@ var ts; function canHaveSpanInParameterDeclaration(parameter) { // Breakpoint is possible on parameter only if it has initializer, is a rest parameter, or has public or private modifier return !!parameter.initializer || parameter.dotDotDotToken !== undefined || - !!(parameter.flags & 16 /* Public */) || !!(parameter.flags & 32 /* Private */); + !!(parameter.flags & 8 /* Public */) || !!(parameter.flags & 16 /* Private */); } function spanInParameterDeclaration(parameter) { if (canHaveSpanInParameterDeclaration(parameter)) { @@ -49873,7 +50317,7 @@ var ts; } } function canFunctionHaveSpanInWholeDeclaration(functionDeclaration) { - return !!(functionDeclaration.flags & 1 /* Export */) || + return !!(functionDeclaration.flags & 2 /* Export */) || (functionDeclaration.parent.kind === 214 /* ClassDeclaration */ && functionDeclaration.kind !== 144 /* Constructor */); } function spanInFunctionDeclaration(functionDeclaration) { @@ -49967,7 +50411,6 @@ var ts; // fall through. case 244 /* CatchClause */: return spanInNode(ts.lastOrUndefined(node.parent.statements)); - ; case 220 /* CaseBlock */: // breakpoint in last statement of the last clause var caseBlock = node.parent; @@ -50008,8 +50451,6 @@ var ts; default: return spanInNode(node.parent); } - // Default to parent node - return spanInNode(node.parent); } function spanInColonToken(node) { // Is this : specifying return annotation of the function declaration @@ -50138,7 +50579,6 @@ var ts; // TODO: should this be '==='? if (settingsJson == null || settingsJson == "") { throw Error("LanguageServiceShimHostAdapter.getCompilationSettings: empty compilationSettings"); - return null; } return JSON.parse(settingsJson); }; From 3f0c6b1aaf337567e77229c9b0c7fa105df32f6a Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Mon, 2 Nov 2015 16:41:28 -0800 Subject: [PATCH 155/227] Use '--pretty' in builds. --- Jakefile.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jakefile.js b/Jakefile.js index 9bad451eec9..2640f8a1225 100644 --- a/Jakefile.js +++ b/Jakefile.js @@ -228,7 +228,7 @@ var builtLocalCompiler = path.join(builtLocalDirectory, compilerFilename); function compileFile(outFile, sources, prereqs, prefixes, useBuiltCompiler, noOutFile, generateDeclarations, outDir, preserveConstEnums, keepComments, noResolve, stripInternal, callback) { file(outFile, prereqs, function() { var compilerPath = useBuiltCompiler ? builtLocalCompiler : LKGCompiler; - var options = "--module commonjs --noImplicitAny --noEmitOnError"; + var options = "--module commonjs --noImplicitAny --noEmitOnError --pretty"; // Keep comments when specifically requested // or when in debug mode. From 265fb518a8c3c715cf7ba43debbc635cf8b61fc4 Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Mon, 2 Nov 2015 16:54:12 -0800 Subject: [PATCH 156/227] feedback from CR --- src/compiler/checker.ts | 15 ++++++- src/compiler/declarationEmitter.ts | 18 ++++----- src/compiler/emitter.ts | 63 ++++++++++++------------------ src/compiler/types.ts | 2 +- 4 files changed, 48 insertions(+), 50 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 821c7ca7e7b..f5d35e6ae78 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -14908,10 +14908,23 @@ namespace ts { getTypeReferenceSerializationKind, isOptionalParameter, isArgumentsLocalBinding, - getSymbolAtLocation + getExternalModuleFileFromDeclaration }; } + function getExternalModuleFileFromDeclaration(declaration: ImportEqualsDeclaration | ImportDeclaration | ExportDeclaration): SourceFile { + const specifier = getExternalModuleName(declaration); + const moduleSymbol = getSymbolAtLocation(specifier); + if (!moduleSymbol) { + return undefined; + } + const moduleDeclaration = getDeclarationOfKind(moduleSymbol, SyntaxKind.SourceFile) as SourceFile; + if (!moduleDeclaration) { + return undefined; + } + return moduleDeclaration; + } + function initializeTypeChecker() { // Bind all source files and propagate errors forEach(host.getSourceFiles(), file => { diff --git a/src/compiler/declarationEmitter.ts b/src/compiler/declarationEmitter.ts index cfb7c98968b..9d34da29897 100644 --- a/src/compiler/declarationEmitter.ts +++ b/src/compiler/declarationEmitter.ts @@ -130,7 +130,7 @@ namespace ts { } else if (isExternalModule(sourceFile)) { noDeclare = true; - write(`declare module "${getModuleName(host, sourceFile)}" {`); + write(`declare module "${getResolvedExternalModuleName(host, sourceFile)}" {`); writeLine(); increaseIndent(); emitSourceFile(sourceFile); @@ -738,16 +738,12 @@ namespace ts { function emitExternalModuleSpecifier(moduleSpecifier: Expression) { if (moduleSpecifier.kind === SyntaxKind.StringLiteral && (!root) && (compilerOptions.out || compilerOptions.outFile)) { - let moduleSymbol = resolver.getSymbolAtLocation(moduleSpecifier); - if (moduleSymbol) { - let moduleDeclaration = getDeclarationOfKind(moduleSymbol, SyntaxKind.SourceFile) as SourceFile; - if (moduleDeclaration && !isDeclarationFile(moduleDeclaration)) { - let nonRelativeModuleName = getExternalModuleNameFromPath(host, moduleDeclaration.fileName); - write("\""); - write(nonRelativeModuleName); - write("\""); - return; - } + let moduleName = getExternalModuleNameFromDeclaration(host, resolver, moduleSpecifier.parent as (ImportEqualsDeclaration | ImportDeclaration | ExportDeclaration)); + if (moduleName) { + write("\""); + write(moduleName); + write("\""); + return; } } diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index 2c6e2dc621f..4baf62668ad 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -7,10 +7,18 @@ namespace ts { return isExternalModule(sourceFile) || isDeclarationFile(sourceFile); } - export function getModuleName(host: EmitHost, file: SourceFile): string { + export function getResolvedExternalModuleName(host: EmitHost, file: SourceFile): string { return file.moduleName || getExternalModuleNameFromPath(host, file.fileName); } + export function getExternalModuleNameFromDeclaration(host: EmitHost, resolver: EmitResolver, declaration: ImportEqualsDeclaration | ImportDeclaration | ExportDeclaration): string { + let file = resolver.getExternalModuleFileFromDeclaration(declaration); + if (!file || isDeclarationFile(file)) { + return undefined; + } + return getResolvedExternalModuleName(host, file); + } + type DependencyGroup = Array; let entities: Map = { @@ -553,7 +561,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi /** If removeComments is true, no leading-comments needed to be emitted **/ let emitLeadingCommentsOfPosition = compilerOptions.removeComments ? function (pos: number) { } : emitLeadingCommentsOfPositionWorker; - let moduleEmitDelegates: Map<(node: SourceFile, resolveModuleNames?: boolean) => void> = { + let moduleEmitDelegates: Map<(node: SourceFile, emitRelativePathAsModuleName?: boolean) => void> = { [ModuleKind.ES6]: emitES6Module, [ModuleKind.AMD]: emitAMDModule, [ModuleKind.System]: emitSystemModule, @@ -561,7 +569,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi [ModuleKind.CommonJS]: emitCommonJSModule, }; - let bundleEmitDelegates: Map<(node: SourceFile, resolveModuleNames?: boolean) => void> = { + let bundleEmitDelegates: Map<(node: SourceFile, emitRelativePathAsModuleName?: boolean) => void> = { [ModuleKind.ES6]() {}, [ModuleKind.AMD]: emitAMDModule, [ModuleKind.System]: emitSystemModule, @@ -7275,14 +7283,14 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi write("}"); // execute } - function writeModuleName(node: SourceFile, resolveModuleNames?: boolean): void { + function writeModuleName(node: SourceFile, emitRelativePathAsModuleName?: boolean): void { let moduleName = node.moduleName; - if (moduleName || (resolveModuleNames && (moduleName = getModuleName(host, node)))) { + if (moduleName || (emitRelativePathAsModuleName && (moduleName = getResolvedExternalModuleName(host, node)))) { write(`"${moduleName}", `); } } - function emitSystemModule(node: SourceFile, resolveModuleNames?: boolean): void { + function emitSystemModule(node: SourceFile, emitRelativePathAsModuleName?: boolean): void { collectExternalModuleInfo(node); // System modules has the following shape // System.register(['dep-1', ... 'dep-n'], function(exports) {/* module body function */}) @@ -7297,7 +7305,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi exportFunctionForFile = makeUniqueName("exports"); writeLine(); write("System.register("); - writeModuleName(node, resolveModuleNames); + writeModuleName(node, emitRelativePathAsModuleName); write("["); let groupIndices: Map = {}; @@ -7320,8 +7328,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi write(", "); } - if (resolveModuleNames) { - let name = lookupSpecifierName(externalImports[i]); + if (emitRelativePathAsModuleName) { + let name = getExternalModuleNameFromDeclaration(host, resolver, externalImports[i]); if (name) { text = `"${name}"`; } @@ -7340,32 +7348,13 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi write("});"); } - function lookupSpecifierName(declaration: ImportEqualsDeclaration | ImportDeclaration | ExportDeclaration): string { - let specifier: Node; - if (declaration.kind === SyntaxKind.ImportEqualsDeclaration) { - specifier = (declaration as ImportEqualsDeclaration).moduleReference; - } - else { - specifier = (declaration as ImportDeclaration | ExportDeclaration).moduleSpecifier; - } - let moduleSymbol = resolver.getSymbolAtLocation(specifier); - if (!moduleSymbol) { - return undefined; - } - let moduleDeclaration = getDeclarationOfKind(moduleSymbol, SyntaxKind.SourceFile) as SourceFile; - if (!moduleDeclaration || isDeclarationFile(moduleDeclaration)) { - return undefined; - } - return getExternalModuleNameFromPath(host, moduleDeclaration.fileName); - } - interface AMDDependencyNames { aliasedModuleNames: string[]; unaliasedModuleNames: string[]; importAliasNames: string[]; } - function getAMDDependencyNames(node: SourceFile, includeNonAmdDependencies: boolean, resolveModuleNames?: boolean): AMDDependencyNames { + function getAMDDependencyNames(node: SourceFile, includeNonAmdDependencies: boolean, emitRelativePathAsModuleName?: boolean): AMDDependencyNames { // names of modules with corresponding parameter in the factory function let aliasedModuleNames: string[] = []; // names of modules with no corresponding parameters in factory function @@ -7389,8 +7378,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi // Find the name of the external module let externalModuleName = getExternalModuleNameText(importNode); - if (resolveModuleNames) { - let name = lookupSpecifierName(importNode); + if (emitRelativePathAsModuleName) { + let name = getExternalModuleNameFromDeclaration(host, resolver, importNode); if (name) { externalModuleName = `"${name}"`; } @@ -7410,7 +7399,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi return { aliasedModuleNames, unaliasedModuleNames, importAliasNames }; } - function emitAMDDependencies(node: SourceFile, includeNonAmdDependencies: boolean, resolveModuleNames?: boolean) { + function emitAMDDependencies(node: SourceFile, includeNonAmdDependencies: boolean, emitRelativePathAsModuleName?: boolean) { // An AMD define function has the following shape: // define(id?, dependencies?, factory); // @@ -7423,7 +7412,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi // `import "module"` or `` // we need to add modules without alias names to the end of the dependencies list - let dependencyNames = getAMDDependencyNames(node, includeNonAmdDependencies, resolveModuleNames); + let dependencyNames = getAMDDependencyNames(node, includeNonAmdDependencies, emitRelativePathAsModuleName); emitAMDDependencyList(dependencyNames); write(", "); emitAMDFactoryHeader(dependencyNames); @@ -7451,14 +7440,14 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi write(") {"); } - function emitAMDModule(node: SourceFile, resolveModuleNames?: boolean) { + function emitAMDModule(node: SourceFile, emitRelativePathAsModuleName?: boolean) { emitEmitHelpers(node); collectExternalModuleInfo(node); writeLine(); write("define("); - writeModuleName(node, resolveModuleNames); - emitAMDDependencies(node, /*includeNonAmdDependencies*/ true, resolveModuleNames); + writeModuleName(node, emitRelativePathAsModuleName); + emitAMDDependencies(node, /*includeNonAmdDependencies*/ true, emitRelativePathAsModuleName); increaseIndent(); let startIndex = emitDirectivePrologues(node.statements, /*startWithNewLine*/ true); emitExportStarHelper(); @@ -7712,7 +7701,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi emitModule(node); } else { - bundleEmitDelegates[modulekind](node, /*resolveModuleNames*/true); + bundleEmitDelegates[modulekind](node, /*emitRelativePathAsModuleName*/true); } } else { diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 50d34286fa1..bc88356193d 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -1619,7 +1619,7 @@ namespace ts { getTypeReferenceSerializationKind(typeName: EntityName): TypeReferenceSerializationKind; isOptionalParameter(node: ParameterDeclaration): boolean; isArgumentsLocalBinding(node: Identifier): boolean; - getSymbolAtLocation(node: Node): Symbol; + getExternalModuleFileFromDeclaration(declaration: ImportEqualsDeclaration | ImportDeclaration | ExportDeclaration): SourceFile; } export const enum SymbolFlags { From 83c33551ae2096842f053cad5e7d763f458f8ae2 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Mon, 2 Nov 2015 16:57:57 -0800 Subject: [PATCH 157/227] Added 'README.md' files to 'lib' and 'src/lib'. --- lib/README.md | 4 ++++ src/lib/README.md | 8 ++++++++ 2 files changed, 12 insertions(+) create mode 100644 lib/README.md create mode 100644 src/lib/README.md diff --git a/lib/README.md b/lib/README.md new file mode 100644 index 00000000000..b2837989505 --- /dev/null +++ b/lib/README.md @@ -0,0 +1,4 @@ +# Read this! + +These files are not meant to be edited by hand. +If you need to make modifications, the respective files should be changed within the repository's top-level `src` directory. \ No newline at end of file diff --git a/src/lib/README.md b/src/lib/README.md new file mode 100644 index 00000000000..cbf80e4d0da --- /dev/null +++ b/src/lib/README.md @@ -0,0 +1,8 @@ +# Read this! + +The files within this directory are used to generate `lib.d.ts` and `lib.es6.d.ts`. + +## Generated files + +Any files ending in `.generated.d.ts` aren't mean to be edited by hand. +If you need to make changes to such files, make a change to the input files for our [library generator](https://github.com/Microsoft/TSJS-lib-generator). From 1baea882467d1254deac181b9f1fe66a36caab1d Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Mon, 2 Nov 2015 17:04:59 -0800 Subject: [PATCH 158/227] shorten function --- src/compiler/checker.ts | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 0bb87337466..f8da1edaeed 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -14911,11 +14911,7 @@ namespace ts { if (!moduleSymbol) { return undefined; } - const moduleDeclaration = getDeclarationOfKind(moduleSymbol, SyntaxKind.SourceFile) as SourceFile; - if (!moduleDeclaration) { - return undefined; - } - return moduleDeclaration; + return getDeclarationOfKind(moduleSymbol, SyntaxKind.SourceFile) as SourceFile; } function initializeTypeChecker() { From 4a7804337ca1394adc144dfc79aae3a9cbc79aab Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Mon, 2 Nov 2015 17:07:14 -0800 Subject: [PATCH 159/227] Update CONTRIBUTING.md --- CONTRIBUTING.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index ebbe2af322a..7c1f068920c 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -34,14 +34,14 @@ Your pull request should: ## Contributing `lib.d.ts` fixes -The library sources are in: [src\lib\](https://github.com/Microsoft/TypeScript/tree/master/src/lib) +The library sources are in: [src/lib](https://github.com/Microsoft/TypeScript/tree/master/src/lib) To build the library files, run ```Shell jake lib ``` -`src\lib\dom.generated.d.ts` and `src\lib\webworker.generated.d.ts`: +### `src/lib/dom.generated.d.ts` and `src/lib/webworker.generated.d.ts` These two files represent the DOM typings and are auto-generated. To make any modifications to them, please submit a PR to https://github.com/Microsoft/TSJS-lib-generator From 244b26d762c36e312b8f891dcac4a69703b506bb Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Mon, 2 Nov 2015 17:08:14 -0800 Subject: [PATCH 160/227] Update CONTRIBUTING.md --- CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 7c1f068920c..68d88854849 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -41,7 +41,7 @@ To build the library files, run jake lib ``` -### `src/lib/dom.generated.d.ts` and `src/lib/webworker.generated.d.ts` +#### `src/lib/dom.generated.d.ts` and `src/lib/webworker.generated.d.ts` These two files represent the DOM typings and are auto-generated. To make any modifications to them, please submit a PR to https://github.com/Microsoft/TSJS-lib-generator From da169de53dc140913ee031351fe2cf0f5bc8da76 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Mon, 2 Nov 2015 17:09:48 -0800 Subject: [PATCH 161/227] Added 'lib/README.md' to .npmignore. --- .npmignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.npmignore b/.npmignore index 3af34bded4a..d295e9bbd77 100644 --- a/.npmignore +++ b/.npmignore @@ -1,5 +1,6 @@ built doc +lib/README.md scripts src tests From 30499e7ee5fbdbc8de23b7db8b7a6a6df6b4c136 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20V=C5=A1eti=C4=8Dka?= Date: Thu, 29 Oct 2015 19:13:54 +0100 Subject: [PATCH 162/227] Support '/dev/stdout' as a valid '--out' parameter --- src/compiler/sys.ts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/compiler/sys.ts b/src/compiler/sys.ts index 6263f7237f6..7810d9f710a 100644 --- a/src/compiler/sys.ts +++ b/src/compiler/sys.ts @@ -336,7 +336,17 @@ namespace ts { data = "\uFEFF" + data; } - _fs.writeFileSync(fileName, data, "utf8"); + let fd: number; + + try { + fd = _fs.openSync(fileName, "w"); + _fs.writeSync(fd, data, undefined, "utf8"); + } + finally { + if (fd !== undefined) { + _fs.closeSync(fd); + } + } } function getCanonicalPath(path: string): string { From 2be7f4f27b0e60ea19a83a291f353a4a9238390f Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Tue, 3 Nov 2015 12:53:31 -0800 Subject: [PATCH 163/227] Skip files with no-default-lib when '--skipDefaultLibCheck' and '--noLib' are used. --- src/compiler/checker.ts | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 65f507c13c0..3fd42865c32 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -14058,8 +14058,16 @@ namespace ts { if (!(links.flags & NodeCheckFlags.TypeChecked)) { // Check whether the file has declared it is the default lib, // and whether the user has specifically chosen to avoid checking it. - if (node.isDefaultLib && compilerOptions.skipDefaultLibCheck) { - return; + if (compilerOptions.skipDefaultLibCheck) { + if (node.isDefaultLib) { + return; + } + + // If the user specified '--noLib' and a file has a `/// , + // then we should treat that file as a default lib. + if (compilerOptions.noLib && node.hasNoDefaultLib) { + return; + } } // Grammar checking From b9368a955cd43d33e4f1e86c13011f76b8afbce1 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Tue, 3 Nov 2015 12:55:18 -0800 Subject: [PATCH 164/227] Fixed comment. --- 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 3fd42865c32..9b0c5d3468c 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -14063,7 +14063,7 @@ namespace ts { return; } - // If the user specified '--noLib' and a file has a `/// , + // If the user specified '--noLib' and a file has a '/// ', // then we should treat that file as a default lib. if (compilerOptions.noLib && node.hasNoDefaultLib) { return; From 884dff03ba3a5a2ee23bdf47accffcf767d1d503 Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Tue, 3 Nov 2015 14:27:26 -0800 Subject: [PATCH 165/227] Use relative file name when reporting errors --- src/compiler/tsc.ts | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/compiler/tsc.ts b/src/compiler/tsc.ts index 083df70be0f..962805d34a0 100644 --- a/src/compiler/tsc.ts +++ b/src/compiler/tsc.ts @@ -89,16 +89,17 @@ namespace ts { return diagnostic.messageText; } + function getRelativeFileName(fileName: string, host: CompilerHost): string { + return host ? convertToRelativePath(fileName, host.getCurrentDirectory(), fileName => host.getCanonicalFileName(fileName)) : fileName; + } + function reportDiagnosticSimply(diagnostic: Diagnostic, host: CompilerHost): void { let output = ""; if (diagnostic.file) { const { line, character } = getLineAndCharacterOfPosition(diagnostic.file, diagnostic.start); - const relativeFileName = host - ? convertToRelativePath(diagnostic.file.fileName, host.getCurrentDirectory(), fileName => host.getCanonicalFileName(fileName)) - : diagnostic.file.fileName; - - output += `${ diagnostic.file.fileName }(${ line + 1 },${ character + 1 }): `; + const relativeFileName = getRelativeFileName(diagnostic.file.fileName, host); + output += `${ relativeFileName }(${ line + 1 },${ character + 1 }): `; } let category = DiagnosticCategory[diagnostic.category].toLowerCase(); @@ -107,7 +108,7 @@ namespace ts { sys.write(output); } - + const redForegroundEscapeSequence = "\u001b[91m"; const yellowForegroundEscapeSequence = "\u001b[93m"; const blueForegroundEscapeSequence = "\u001b[93m"; @@ -133,6 +134,7 @@ namespace ts { let { line: firstLine, character: firstLineChar } = getLineAndCharacterOfPosition(file, start); let { line: lastLine, character: lastLineChar } = getLineAndCharacterOfPosition(file, start + length); const lastLineInFile = getLineAndCharacterOfPosition(file, file.text.length).line; + const relativeFileName = getRelativeFileName(file.fileName, host); let hasMoreThanFiveLines = (lastLine - firstLine) >= 4; let gutterWidth = (lastLine + 1 + "").length; @@ -183,7 +185,7 @@ namespace ts { } output += sys.newLine; - output += `${ file.fileName }(${ firstLine + 1 },${ firstLineChar + 1 }): `; + output += `${ relativeFileName }(${ firstLine + 1 },${ firstLineChar + 1 }): `; } const categoryColor = categoryFormatMap[diagnostic.category]; From 77c69daf2e7d67f8ec54947983ce331e672c454c Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Tue, 3 Nov 2015 14:35:11 -0800 Subject: [PATCH 166/227] const all the things --- src/compiler/checker.ts | 97 ++++++++++++++++++++--------------------- 1 file changed, 48 insertions(+), 49 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index b77faadd011..4bdbebaa50b 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -33,26 +33,26 @@ namespace ts { // they no longer need the information (for example, if the user started editing again). let cancellationToken: CancellationToken; - let Symbol = objectAllocator.getSymbolConstructor(); - let Type = objectAllocator.getTypeConstructor(); - let Signature = objectAllocator.getSignatureConstructor(); + const Symbol = objectAllocator.getSymbolConstructor(); + const Type = objectAllocator.getTypeConstructor(); + const Signature = objectAllocator.getSignatureConstructor(); let typeCount = 0; let symbolCount = 0; - let emptyArray: any[] = []; - let emptySymbols: SymbolTable = {}; + const emptyArray: any[] = []; + const emptySymbols: SymbolTable = {}; - let compilerOptions = host.getCompilerOptions(); - let languageVersion = compilerOptions.target || ScriptTarget.ES3; - let modulekind = compilerOptions.module ? compilerOptions.module : languageVersion === ScriptTarget.ES6 ? ModuleKind.ES6 : ModuleKind.None; + const compilerOptions = host.getCompilerOptions(); + const languageVersion = compilerOptions.target || ScriptTarget.ES3; + const modulekind = compilerOptions.module ? compilerOptions.module : languageVersion === ScriptTarget.ES6 ? ModuleKind.ES6 : ModuleKind.None; - let emitResolver = createResolver(); + const emitResolver = createResolver(); - let undefinedSymbol = createSymbol(SymbolFlags.Property | SymbolFlags.Transient, "undefined"); - let argumentsSymbol = createSymbol(SymbolFlags.Property | SymbolFlags.Transient, "arguments"); + const undefinedSymbol = createSymbol(SymbolFlags.Property | SymbolFlags.Transient, "undefined"); + const argumentsSymbol = createSymbol(SymbolFlags.Property | SymbolFlags.Transient, "arguments"); - let checker: TypeChecker = { + const checker: TypeChecker = { getNodeCount: () => sum(host.getSourceFiles(), "nodeCount"), getIdentifierCount: () => sum(host.getSourceFiles(), "identifierCount"), getSymbolCount: () => sum(host.getSourceFiles(), "symbolCount") + symbolCount, @@ -97,36 +97,35 @@ namespace ts { isOptionalParameter }; - let unknownSymbol = createSymbol(SymbolFlags.Property | SymbolFlags.Transient, "unknown"); - let resolvingSymbol = createSymbol(SymbolFlags.Transient, "__resolving__"); + const unknownSymbol = createSymbol(SymbolFlags.Property | SymbolFlags.Transient, "unknown"); + const resolvingSymbol = createSymbol(SymbolFlags.Transient, "__resolving__"); - let anyType = createIntrinsicType(TypeFlags.Any, "any"); - let stringType = createIntrinsicType(TypeFlags.String, "string"); - let numberType = createIntrinsicType(TypeFlags.Number, "number"); - let booleanType = createIntrinsicType(TypeFlags.Boolean, "boolean"); - let esSymbolType = createIntrinsicType(TypeFlags.ESSymbol, "symbol"); - let voidType = createIntrinsicType(TypeFlags.Void, "void"); - let undefinedType = createIntrinsicType(TypeFlags.Undefined | TypeFlags.ContainsUndefinedOrNull, "undefined"); - let nullType = createIntrinsicType(TypeFlags.Null | TypeFlags.ContainsUndefinedOrNull, "null"); - let unknownType = createIntrinsicType(TypeFlags.Any, "unknown"); - let circularType = createIntrinsicType(TypeFlags.Any, "__circular__"); + const anyType = createIntrinsicType(TypeFlags.Any, "any"); + const stringType = createIntrinsicType(TypeFlags.String, "string"); + const numberType = createIntrinsicType(TypeFlags.Number, "number"); + const booleanType = createIntrinsicType(TypeFlags.Boolean, "boolean"); + const esSymbolType = createIntrinsicType(TypeFlags.ESSymbol, "symbol"); + const voidType = createIntrinsicType(TypeFlags.Void, "void"); + const undefinedType = createIntrinsicType(TypeFlags.Undefined | TypeFlags.ContainsUndefinedOrNull, "undefined"); + const nullType = createIntrinsicType(TypeFlags.Null | TypeFlags.ContainsUndefinedOrNull, "null"); + const unknownType = createIntrinsicType(TypeFlags.Any, "unknown"); - let emptyObjectType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); - let emptyUnionType = emptyObjectType; - let emptyGenericType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); + const emptyObjectType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); + const emptyUnionType = emptyObjectType; + const emptyGenericType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); emptyGenericType.instantiations = {}; - let anyFunctionType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); + const anyFunctionType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); // The anyFunctionType contains the anyFunctionType by definition. The flag is further propagated // in getPropagatingFlagsOfTypes, and it is checked in inferFromTypes. anyFunctionType.flags |= TypeFlags.ContainsAnyFunctionType; - let noConstraintType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); + const noConstraintType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); - let anySignature = createSignature(undefined, undefined, emptyArray, anyType, undefined, 0, false, false); - let unknownSignature = createSignature(undefined, undefined, emptyArray, unknownType, undefined, 0, false, false); + const anySignature = createSignature(undefined, undefined, emptyArray, anyType, undefined, 0, false, false); + const unknownSignature = createSignature(undefined, undefined, emptyArray, unknownType, undefined, 0, false, false); - let globals: SymbolTable = {}; + const globals: SymbolTable = {}; let globalESSymbolConstructorSymbol: Symbol; @@ -161,29 +160,29 @@ namespace ts { let getGlobalPromiseConstructorLikeType: () => ObjectType; let getGlobalThenableType: () => ObjectType; - let tupleTypes: Map = {}; - let unionTypes: Map = {}; - let intersectionTypes: Map = {}; - let stringLiteralTypes: Map = {}; + const tupleTypes: Map = {}; + const unionTypes: Map = {}; + const intersectionTypes: Map = {}; + const stringLiteralTypes: Map = {}; let emitExtends = false; let emitDecorate = false; let emitParam = false; let emitAwaiter = false; let emitGenerator = false; - let resolutionTargets: TypeSystemEntity[] = []; - let resolutionResults: boolean[] = []; - let resolutionPropertyNames: TypeSystemPropertyName[] = []; + const resolutionTargets: TypeSystemEntity[] = []; + const resolutionResults: boolean[] = []; + const resolutionPropertyNames: TypeSystemPropertyName[] = []; - let mergedSymbols: Symbol[] = []; - let symbolLinks: SymbolLinks[] = []; - let nodeLinks: NodeLinks[] = []; - let potentialThisCollisions: Node[] = []; - let awaitedTypeStack: number[] = []; + const mergedSymbols: Symbol[] = []; + const symbolLinks: SymbolLinks[] = []; + const nodeLinks: NodeLinks[] = []; + const potentialThisCollisions: Node[] = []; + const awaitedTypeStack: number[] = []; - let diagnostics = createDiagnosticCollection(); + const diagnostics = createDiagnosticCollection(); - let primitiveTypeInfo: Map<{ type: Type; flags: TypeFlags }> = { + const primitiveTypeInfo: Map<{ type: Type; flags: TypeFlags }> = { "string": { type: stringType, flags: TypeFlags.StringLike @@ -210,9 +209,9 @@ namespace ts { Element: "Element" }; - let subtypeRelation: Map = {}; - let assignableRelation: Map = {}; - let identityRelation: Map = {}; + const subtypeRelation: Map = {}; + const assignableRelation: Map = {}; + const identityRelation: Map = {}; // This is for caching the result of getSymbolDisplayBuilder. Do not access directly. let _displayBuilder: SymbolDisplayBuilder; From 9223b02136f0ede6ebeacf0404a7c8c9a2851486 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Tue, 3 Nov 2015 14:42:03 -0800 Subject: [PATCH 167/227] Improve test case and add working comparison --- .../genericClassExpressionInFunction.ts | 20 +++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/tests/cases/conformance/classes/classExpressions/genericClassExpressionInFunction.ts b/tests/cases/conformance/classes/classExpressions/genericClassExpressionInFunction.ts index ab2155c0324..70f63e8a929 100644 --- a/tests/cases/conformance/classes/classExpressions/genericClassExpressionInFunction.ts +++ b/tests/cases/conformance/classes/classExpressions/genericClassExpressionInFunction.ts @@ -1,13 +1,25 @@ class A { genericVar: T } -function B() { +class B3 extends A { +} +function B1() { // class expression can use T - return class extends A { } + return class extends A { } +} +class B2 { + anon = class extends A { } } // extends can call B -class K extends B() { +class K extends B1() { + namae: string; +} +class C extends (new B2().anon) { name: string; } -var c = new K(); +var c = new C(); +var k = new K(); +var b3 = new B3(); c.genericVar = 12; +k.genericVar = 12; +b3.genericVar = 12 From 652a3a4a5500af1d6b8592fae3259ccd21014e28 Mon Sep 17 00:00:00 2001 From: Vladimir Matveev Date: Tue, 3 Nov 2015 22:30:27 -0800 Subject: [PATCH 168/227] do not report 'unreachable code' on empty statements --- src/compiler/binder.ts | 4 +- .../noReachabilityErrorsOnEmptyStatement.js | 10 +++++ ...ReachabilityErrorsOnEmptyStatement.symbols | 6 +++ ...noReachabilityErrorsOnEmptyStatement.types | 7 ++++ ...ionCannotNameReturnTypeDeclFile.errors.txt | 38 +------------------ .../noReachabilityErrorsOnEmptyStatement.ts | 3 ++ 6 files changed, 29 insertions(+), 39 deletions(-) create mode 100644 tests/baselines/reference/noReachabilityErrorsOnEmptyStatement.js create mode 100644 tests/baselines/reference/noReachabilityErrorsOnEmptyStatement.symbols create mode 100644 tests/baselines/reference/noReachabilityErrorsOnEmptyStatement.types create mode 100644 tests/cases/compiler/noReachabilityErrorsOnEmptyStatement.ts diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index 3d7d980706b..1169e331f1f 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -1453,8 +1453,8 @@ namespace ts { switch (currentReachabilityState) { case Reachability.Unreachable: const reportError = - // report error on all statements - isStatement(node) || + // report error on all statements except empty ones + (isStatement(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 diff --git a/tests/baselines/reference/noReachabilityErrorsOnEmptyStatement.js b/tests/baselines/reference/noReachabilityErrorsOnEmptyStatement.js new file mode 100644 index 00000000000..b2f08b599be --- /dev/null +++ b/tests/baselines/reference/noReachabilityErrorsOnEmptyStatement.js @@ -0,0 +1,10 @@ +//// [noReachabilityErrorsOnEmptyStatement.ts] +function foo() { + return 1;; +} + +//// [noReachabilityErrorsOnEmptyStatement.js] +function foo() { + return 1; + ; +} diff --git a/tests/baselines/reference/noReachabilityErrorsOnEmptyStatement.symbols b/tests/baselines/reference/noReachabilityErrorsOnEmptyStatement.symbols new file mode 100644 index 00000000000..0179e5150bb --- /dev/null +++ b/tests/baselines/reference/noReachabilityErrorsOnEmptyStatement.symbols @@ -0,0 +1,6 @@ +=== tests/cases/compiler/noReachabilityErrorsOnEmptyStatement.ts === +function foo() { +>foo : Symbol(foo, Decl(noReachabilityErrorsOnEmptyStatement.ts, 0, 0)) + + return 1;; +} diff --git a/tests/baselines/reference/noReachabilityErrorsOnEmptyStatement.types b/tests/baselines/reference/noReachabilityErrorsOnEmptyStatement.types new file mode 100644 index 00000000000..e90fa04699b --- /dev/null +++ b/tests/baselines/reference/noReachabilityErrorsOnEmptyStatement.types @@ -0,0 +1,7 @@ +=== tests/cases/compiler/noReachabilityErrorsOnEmptyStatement.ts === +function foo() { +>foo : () => number + + return 1;; +>1 : number +} diff --git a/tests/baselines/reference/privacyFunctionCannotNameReturnTypeDeclFile.errors.txt b/tests/baselines/reference/privacyFunctionCannotNameReturnTypeDeclFile.errors.txt index 0f148b6a20e..bc6229815f5 100644 --- a/tests/baselines/reference/privacyFunctionCannotNameReturnTypeDeclFile.errors.txt +++ b/tests/baselines/reference/privacyFunctionCannotNameReturnTypeDeclFile.errors.txt @@ -1,19 +1,7 @@ tests/cases/compiler/privacyFunctionReturnTypeDeclFile_consumer.ts(3,12): error TS4050: Return type of public static method from exported class has or is using name 'Widget1' from external module "tests/cases/compiler/privacyFunctionReturnTypeDeclFile_Widgets" but cannot be named. -tests/cases/compiler/privacyFunctionReturnTypeDeclFile_consumer.ts(7,49): error TS7027: Unreachable code detected. tests/cases/compiler/privacyFunctionReturnTypeDeclFile_consumer.ts(9,5): error TS4053: Return type of public method from exported class has or is using name 'Widget1' from external module "tests/cases/compiler/privacyFunctionReturnTypeDeclFile_Widgets" but cannot be named. -tests/cases/compiler/privacyFunctionReturnTypeDeclFile_consumer.ts(10,49): error TS7027: Unreachable code detected. -tests/cases/compiler/privacyFunctionReturnTypeDeclFile_consumer.ts(13,49): error TS7027: Unreachable code detected. tests/cases/compiler/privacyFunctionReturnTypeDeclFile_consumer.ts(15,12): error TS4050: Return type of public static method from exported class has or is using name 'Widget3' from external module "GlobalWidgets" but cannot be named. -tests/cases/compiler/privacyFunctionReturnTypeDeclFile_consumer.ts(19,49): error TS7027: Unreachable code detected. tests/cases/compiler/privacyFunctionReturnTypeDeclFile_consumer.ts(21,5): error TS4053: Return type of public method from exported class has or is using name 'Widget3' from external module "GlobalWidgets" but cannot be named. -tests/cases/compiler/privacyFunctionReturnTypeDeclFile_consumer.ts(22,49): error TS7027: Unreachable code detected. -tests/cases/compiler/privacyFunctionReturnTypeDeclFile_consumer.ts(25,49): error TS7027: Unreachable code detected. -tests/cases/compiler/privacyFunctionReturnTypeDeclFile_consumer.ts(34,49): error TS7027: Unreachable code detected. -tests/cases/compiler/privacyFunctionReturnTypeDeclFile_consumer.ts(37,49): error TS7027: Unreachable code detected. -tests/cases/compiler/privacyFunctionReturnTypeDeclFile_consumer.ts(40,49): error TS7027: Unreachable code detected. -tests/cases/compiler/privacyFunctionReturnTypeDeclFile_consumer.ts(46,49): error TS7027: Unreachable code detected. -tests/cases/compiler/privacyFunctionReturnTypeDeclFile_consumer.ts(49,49): error TS7027: Unreachable code detected. -tests/cases/compiler/privacyFunctionReturnTypeDeclFile_consumer.ts(52,49): error TS7027: Unreachable code detected. tests/cases/compiler/privacyFunctionReturnTypeDeclFile_consumer.ts(56,17): error TS4058: Return type of exported function has or is using name 'Widget1' from external module "tests/cases/compiler/privacyFunctionReturnTypeDeclFile_Widgets" but cannot be named. tests/cases/compiler/privacyFunctionReturnTypeDeclFile_consumer.ts(62,17): error TS4058: Return type of exported function has or is using name 'Widget3' from external module "GlobalWidgets" but cannot be named. tests/cases/compiler/privacyFunctionReturnTypeDeclFile_consumer.ts(70,12): error TS4050: Return type of public static method from exported class has or is using name 'SpecializedWidget.Widget2' from external module "tests/cases/compiler/privacyFunctionReturnTypeDeclFile_Widgets" but cannot be named. @@ -24,7 +12,7 @@ tests/cases/compiler/privacyFunctionReturnTypeDeclFile_consumer.ts(83,17): error tests/cases/compiler/privacyFunctionReturnTypeDeclFile_consumer.ts(86,17): error TS4058: Return type of exported function has or is using name 'SpecializedGlobalWidget.Widget4' from external module "GlobalWidgets" but cannot be named. -==== tests/cases/compiler/privacyFunctionReturnTypeDeclFile_consumer.ts (24 errors) ==== +==== tests/cases/compiler/privacyFunctionReturnTypeDeclFile_consumer.ts (12 errors) ==== import exporter = require("./privacyFunctionReturnTypeDeclFile_exporter"); export class publicClassWithWithPrivateParmeterTypes { static myPublicStaticMethod() { // Error @@ -34,20 +22,14 @@ tests/cases/compiler/privacyFunctionReturnTypeDeclFile_consumer.ts(86,17): error } private static myPrivateStaticMethod() { return exporter.createExportedWidget1();; - ~ -!!! error TS7027: Unreachable code detected. } myPublicMethod() { // Error ~~~~~~~~~~~~~~ !!! error TS4053: Return type of public method from exported class has or is using name 'Widget1' from external module "tests/cases/compiler/privacyFunctionReturnTypeDeclFile_Widgets" but cannot be named. return exporter.createExportedWidget1();; - ~ -!!! error TS7027: Unreachable code detected. } private myPrivateMethod() { return exporter.createExportedWidget1();; - ~ -!!! error TS7027: Unreachable code detected. } static myPublicStaticMethod1() { // Error ~~~~~~~~~~~~~~~~~~~~~ @@ -56,20 +38,14 @@ tests/cases/compiler/privacyFunctionReturnTypeDeclFile_consumer.ts(86,17): error } private static myPrivateStaticMethod1() { return exporter.createExportedWidget3();; - ~ -!!! error TS7027: Unreachable code detected. } myPublicMethod1() { // Error ~~~~~~~~~~~~~~~ !!! error TS4053: Return type of public method from exported class has or is using name 'Widget3' from external module "GlobalWidgets" but cannot be named. return exporter.createExportedWidget3();; - ~ -!!! error TS7027: Unreachable code detected. } private myPrivateMethod1() { return exporter.createExportedWidget3();; - ~ -!!! error TS7027: Unreachable code detected. } } @@ -79,36 +55,24 @@ tests/cases/compiler/privacyFunctionReturnTypeDeclFile_consumer.ts(86,17): error } private static myPrivateStaticMethod() { return exporter.createExportedWidget1();; - ~ -!!! error TS7027: Unreachable code detected. } myPublicMethod() { return exporter.createExportedWidget1();; - ~ -!!! error TS7027: Unreachable code detected. } private myPrivateMethod() { return exporter.createExportedWidget1();; - ~ -!!! error TS7027: Unreachable code detected. } static myPublicStaticMethod1() { return exporter.createExportedWidget3(); } private static myPrivateStaticMethod1() { return exporter.createExportedWidget3();; - ~ -!!! error TS7027: Unreachable code detected. } myPublicMethod1() { return exporter.createExportedWidget3();; - ~ -!!! error TS7027: Unreachable code detected. } private myPrivateMethod1() { return exporter.createExportedWidget3();; - ~ -!!! error TS7027: Unreachable code detected. } } diff --git a/tests/cases/compiler/noReachabilityErrorsOnEmptyStatement.ts b/tests/cases/compiler/noReachabilityErrorsOnEmptyStatement.ts new file mode 100644 index 00000000000..81152c82b43 --- /dev/null +++ b/tests/cases/compiler/noReachabilityErrorsOnEmptyStatement.ts @@ -0,0 +1,3 @@ +function foo() { + return 1;; +} \ No newline at end of file From ec716549a5c6fc765b56eb572c8b16f07a016aaa Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Wed, 4 Nov 2015 09:08:33 -0800 Subject: [PATCH 169/227] Update default configurations --- src/compiler/program.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/compiler/program.ts b/src/compiler/program.ts index 4822a86b527..a22db74c669 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -199,10 +199,8 @@ namespace ts { /* @internal */ export const defaultInitCompilerOptions: CompilerOptions = { module: ModuleKind.CommonJS, - target: ScriptTarget.ES3, + target: ScriptTarget.ES5, noImplicitAny: false, - outDir: "built", - rootDir: ".", sourceMap: false, }; From 51fc4f2c230cd04a9c0420e32e02cc7d1f644cd9 Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Wed, 4 Nov 2015 11:02:43 -0800 Subject: [PATCH 170/227] Add prefer const rule --- Jakefile.js | 1 + scripts/tslint/preferConstRule.ts | 235 ++++++++++++++++++++++++++++++ tslint.json | 3 +- 3 files changed, 238 insertions(+), 1 deletion(-) create mode 100644 scripts/tslint/preferConstRule.ts diff --git a/Jakefile.js b/Jakefile.js index 2640f8a1225..14bf047cf21 100644 --- a/Jakefile.js +++ b/Jakefile.js @@ -859,6 +859,7 @@ var tslintRuleDir = "scripts/tslint"; var tslintRules = ([ "nextLineRule", "noNullRule", + "preferConstRule", "booleanTriviaRule", "typeOperatorSpacingRule" ]); diff --git a/scripts/tslint/preferConstRule.ts b/scripts/tslint/preferConstRule.ts new file mode 100644 index 00000000000..c2592c90c9f --- /dev/null +++ b/scripts/tslint/preferConstRule.ts @@ -0,0 +1,235 @@ +/// +/// + + +export class Rule extends Lint.Rules.AbstractRule { + public static FAILURE_STRING_FACTORY = (identifier: string) => `Identifier '${identifier}' never appears on the LHS of an assignment - use const instead of let for its declaration.`; + + public apply(sourceFile: ts.SourceFile): Lint.RuleFailure[] { + return this.applyWithWalker(new PreferConstWalker(sourceFile, this.getOptions())); + } +} + +function isBindingPattern(node: ts.Node): node is ts.BindingPattern { + return !!node && (node.kind === ts.SyntaxKind.ArrayBindingPattern || node.kind === ts.SyntaxKind.ObjectBindingPattern); +} + +function walkUpBindingElementsAndPatterns(node: ts.Node): ts.Node { + while (node && (node.kind === ts.SyntaxKind.BindingElement || isBindingPattern(node))) { + node = node.parent; + } + + return node; +} + +function getCombinedNodeFlags(node: ts.Node): ts.NodeFlags { + node = walkUpBindingElementsAndPatterns(node); + + let flags = node.flags; + if (node.kind === ts.SyntaxKind.VariableDeclaration) { + node = node.parent; + } + + if (node && node.kind === ts.SyntaxKind.VariableDeclarationList) { + flags |= node.flags; + node = node.parent; + } + + if (node && node.kind === ts.SyntaxKind.VariableStatement) { + flags |= node.flags; + } + + return flags; +} + +function isLet(node: ts.Node) { + return !!(getCombinedNodeFlags(node) & ts.NodeFlags.Let); +} + +function isExported(node: ts.Node) { + return !!(getCombinedNodeFlags(node) & ts.NodeFlags.Export); +} + +function isAssignmentOperator(token: ts.SyntaxKind): boolean { + return token >= ts.SyntaxKind.FirstAssignment && token <= ts.SyntaxKind.LastAssignment; +} + +function isBindingLiteralExpression(node: ts.Node): node is (ts.ArrayLiteralExpression | ts.ObjectLiteralExpression) { + return (!!node) && (node.kind === ts.SyntaxKind.ObjectLiteralExpression || node.kind === ts.SyntaxKind.ArrayLiteralExpression); +} + +interface DeclarationUsages { + declaration: ts.VariableDeclaration; + usages: number; +} + +class PreferConstWalker extends Lint.RuleWalker { + private inScopeLetDeclarations: ts.Map[] = []; + private errors: Lint.RuleFailure[] = []; + private markAssignment(identifier: ts.Identifier) { + const name = identifier.text; + for (var i = this.inScopeLetDeclarations.length - 1; i >= 0; i--) { + var declarations = this.inScopeLetDeclarations[i]; + if (declarations[name]) { + declarations[name].usages++; + break; + } + } + } + + visitSourceFile(node: ts.SourceFile) { + super.visitSourceFile(node); + // Sort errors by position because tslint doesn't + this.errors.sort((a, b) => a.getStartPosition().getPosition() - b.getStartPosition().getPosition()).forEach(e => this.addFailure(e)); + } + + visitBinaryExpression(node: ts.BinaryExpression) { + if (isAssignmentOperator(node.operatorToken.kind)) { + this.visitLHSExpressions(node.left); + } + super.visitBinaryExpression(node); + } + + private visitLHSExpressions(node: ts.Expression) { + while (node.kind === ts.SyntaxKind.ParenthesizedExpression) { + node = (node as ts.ParenthesizedExpression).expression; + } + if (node.kind === ts.SyntaxKind.Identifier) { + this.markAssignment(node as ts.Identifier); + } + else if (isBindingLiteralExpression(node)) { + this.visitBindingLiteralExpression(node as (ts.ArrayLiteralExpression | ts.ObjectLiteralExpression)); + } + } + + private visitBindingLiteralExpression(node: ts.ArrayLiteralExpression | ts.ObjectLiteralExpression) { + if (node.kind === ts.SyntaxKind.ObjectLiteralExpression) { + const pattern = node as ts.ObjectLiteralExpression; + for (let i = 0; i < pattern.properties.length; i++) { + const element = pattern.properties[i]; + if (element.name.kind === ts.SyntaxKind.Identifier) { + this.markAssignment(element.name as ts.Identifier) + } + else if (isBindingPattern(element.name)) { + this.visitBindingPatternIdentifiers(element.name as ts.BindingPattern); + } + } + } + else if (node.kind === ts.SyntaxKind.ArrayLiteralExpression) { + const pattern = node as ts.ArrayLiteralExpression; + for (let i = 0; i < pattern.elements.length; i++) { + const element = pattern.elements[i]; + this.visitLHSExpressions(element); + } + } + } + + private visitBindingPatternIdentifiers(pattern: ts.BindingPattern) { + for (let i = 0; i < pattern.elements.length; i++) { + const element = pattern.elements[i]; + if (element.name.kind === ts.SyntaxKind.Identifier) { + this.markAssignment(element.name as ts.Identifier); + } + else { + this.visitBindingPatternIdentifiers(element.name as ts.BindingPattern); + } + } + } + + visitPrefixUnaryExpression(node: ts.PrefixUnaryExpression) { + this.visitAnyUnaryExpression(node); + super.visitPrefixUnaryExpression(node); + } + + visitPostfixUnaryExpression(node: ts.PostfixUnaryExpression) { + this.visitAnyUnaryExpression(node); + super.visitPostfixUnaryExpression(node); + } + + private visitAnyUnaryExpression(node: ts.PrefixUnaryExpression | ts.PostfixUnaryExpression) { + if (node.operator === ts.SyntaxKind.PlusPlusToken || node.operator === ts.SyntaxKind.MinusMinusToken) { + this.visitLHSExpressions(node.operand); + } + } + + visitModuleDeclaration(node: ts.ModuleDeclaration) { + if (node.body.kind === ts.SyntaxKind.ModuleBlock) { + // For some reason module blocks are left out of the visit block traversal + this.visitBlock(node.body as ts.ModuleBlock); + } + super.visitModuleDeclaration(node); + } + + visitForOfStatement(node: ts.ForOfStatement) { + this.visitAnyForStatement(node); + super.visitForOfStatement(node); + this.popDeclarations(); + } + + visitForInStatement(node: ts.ForInStatement) { + this.visitAnyForStatement(node); + super.visitForInStatement(node); + this.popDeclarations(); + } + + private visitAnyForStatement(node: ts.ForOfStatement | ts.ForInStatement) { + let names: ts.Map = {}; + if (isLet(node.initializer)) { + if (node.initializer.kind === ts.SyntaxKind.VariableDeclarationList) { + this.collectLetIdentifiers(node.initializer as ts.VariableDeclarationList, names); + } + } + this.inScopeLetDeclarations.push(names); + } + + private popDeclarations() { + const completed = this.inScopeLetDeclarations.pop(); + for (const name in completed) { + if (Object.hasOwnProperty.call(completed, name)) { + const element = completed[name]; + if (element.usages === 0) { + this.errors.push(this.createFailure(element.declaration.getStart(this.getSourceFile()), element.declaration.getWidth(this.getSourceFile()), Rule.FAILURE_STRING_FACTORY(name))); + } + } + } + } + + visitBlock(node: ts.Block) { + let names: ts.Map = {}; + for (let i = 0; i < node.statements.length; i++) { + const statement = node.statements[i]; + if (statement.kind === ts.SyntaxKind.VariableStatement) { + this.collectLetIdentifiers((statement as ts.VariableStatement).declarationList, names); + } + } + this.inScopeLetDeclarations.push(names); + super.visitBlock(node); + this.popDeclarations(); + } + + private collectLetIdentifiers(list: ts.VariableDeclarationList, ret: ts.Map) { + const children = list.declarations; + for (let i = 0; i < children.length; i++) { + const node = children[i]; + if (isLet(node) && !isExported(node)) { + this.collectNameIdentifiers(node, node.name, ret); + } + } + } + + private collectNameIdentifiers(value: ts.VariableDeclaration, node: ts.Identifier | ts.BindingPattern, table: ts.Map) { + if (node.kind === ts.SyntaxKind.Identifier) { + table[(node as ts.Identifier).text] = {declaration: value, usages: 0}; + } + else { + this.collectBindingPatternIdentifiers(value, node as ts.BindingPattern, table); + } + } + + private collectBindingPatternIdentifiers(value: ts.VariableDeclaration, pattern: ts.BindingPattern, table: ts.Map) { + for (let i = 0; i < pattern.elements.length; i++) { + const element = pattern.elements[i]; + this.collectNameIdentifiers(value, element.name, table); + } + } +} diff --git a/tslint.json b/tslint.json index db10daa3fcc..3cafdbfd39c 100644 --- a/tslint.json +++ b/tslint.json @@ -39,6 +39,7 @@ "no-inferrable-types": true, "no-null": true, "boolean-trivia": true, - "type-operator-spacing": true + "type-operator-spacing": true, + "prefer-const": true } } From 8a93b489454fdcbdf544edef05f73a913449be1d Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Wed, 4 Nov 2015 14:02:33 -0800 Subject: [PATCH 171/227] fix lint: prefer const --- src/compiler/binder.ts | 82 +- src/compiler/checker.ts | 2448 ++++++++++++------------- src/compiler/commandLineParser.ts | 50 +- src/compiler/core.ts | 108 +- src/compiler/declarationEmitter.ts | 98 +- src/compiler/emitter.ts | 577 +++--- src/compiler/parser.ts | 709 ++++--- src/compiler/program.ts | 152 +- src/compiler/scanner.ts | 102 +- src/compiler/sys.ts | 54 +- src/compiler/tsc.ts | 110 +- src/compiler/utilities.ts | 194 +- src/harness/compilerRunner.ts | 48 +- src/harness/fourslash.ts | 556 +++--- src/harness/fourslashRunner.ts | 12 +- src/harness/harness.ts | 204 +-- src/harness/harnessLanguageService.ts | 74 +- src/harness/loggedIO.ts | 28 +- src/harness/projectsRunner.ts | 44 +- src/harness/runner.ts | 4 +- src/harness/runnerbase.ts | 6 +- src/harness/rwcRunner.ts | 30 +- src/harness/sourceMapRecorder.ts | 28 +- src/harness/test262Runner.ts | 18 +- src/harness/typeWriter.ts | 24 +- src/server/editorServices.ts | 89 +- src/server/server.ts | 2 +- src/server/session.ts | 64 +- 28 files changed, 2956 insertions(+), 2959 deletions(-) diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index 1169e331f1f..6edba58cb11 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -95,7 +95,7 @@ namespace ts { const binder = createBinder(); export function bindSourceFile(file: SourceFile, options: CompilerOptions) { - let start = new Date().getTime(); + const start = new Date().getTime(); binder(file, options); bindTime += new Date().getTime() - start; } @@ -187,7 +187,7 @@ namespace ts { return `"${(node.name).text}"`; } if (node.name.kind === SyntaxKind.ComputedPropertyName) { - let nameExpression = (node.name).expression; + const nameExpression = (node.name).expression; Debug.assert(isWellKnownSymbolSyntactically(nameExpression)); return getPropertyNameForKnownSymbolName((nameExpression).name.text); } @@ -229,9 +229,9 @@ namespace ts { function declareSymbol(symbolTable: SymbolTable, parent: Symbol, node: Declaration, includes: SymbolFlags, excludes: SymbolFlags): Symbol { Debug.assert(!hasDynamicName(node)); - let isDefaultExport = node.flags & NodeFlags.Default; + const isDefaultExport = node.flags & NodeFlags.Default; // The exported symbol for an export default function/class node is always named "default" - let name = isDefaultExport && parent ? "default" : getDeclarationName(node); + const name = isDefaultExport && parent ? "default" : getDeclarationName(node); let symbol: Symbol; if (name !== undefined) { @@ -298,7 +298,7 @@ namespace ts { } function declareModuleMember(node: Declaration, symbolFlags: SymbolFlags, symbolExcludes: SymbolFlags): Symbol { - let hasExportModifier = getCombinedNodeFlags(node) & NodeFlags.Export; + const hasExportModifier = getCombinedNodeFlags(node) & NodeFlags.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); @@ -320,11 +320,11 @@ namespace ts { // 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. if (hasExportModifier || container.flags & NodeFlags.ExportContext) { - let exportKind = + const exportKind = (symbolFlags & SymbolFlags.Value ? SymbolFlags.ExportValue : 0) | (symbolFlags & SymbolFlags.Type ? SymbolFlags.ExportType : 0) | (symbolFlags & SymbolFlags.Namespace ? SymbolFlags.ExportNamespace : 0); - let local = declareSymbol(container.locals, undefined, node, exportKind, symbolExcludes); + 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; @@ -342,9 +342,9 @@ namespace ts { // Before we recurse into a node's chilren, we first save the existing parent, container // and block-container. Then after we pop out of processing the children, we restore // these saved values. - let saveParent = parent; - let saveContainer = container; - let savedBlockScopeContainer = blockScopeContainer; + const saveParent = parent; + const saveContainer = container; + const savedBlockScopeContainer = blockScopeContainer; // This node will now be set as the parent of all of its children as we recurse into them. parent = node; @@ -366,7 +366,7 @@ namespace ts { // reusing a node from a previous compilation, that node may have had 'locals' created // for it. We must clear this so we don't accidently move any stale data forward from // a previous compilation. - let containerFlags = getContainerFlags(node); + const containerFlags = getContainerFlags(node); if (containerFlags & ContainerFlags.IsContainer) { container = blockScopeContainer = node; @@ -398,7 +398,7 @@ namespace ts { seenThisKeyword = false; } - let saveState = kind === SyntaxKind.SourceFile || kind === SyntaxKind.ModuleBlock || isFunctionLikeKind(kind); + const saveState = kind === SyntaxKind.SourceFile || kind === SyntaxKind.ModuleBlock || isFunctionLikeKind(kind); if (saveState) { savedReachabilityState = currentReachabilityState; savedLabelStack = labelStack; @@ -633,7 +633,7 @@ namespace ts { function bindCaseBlock(n: CaseBlock): void { const startState = currentReachabilityState; - for (let clause of n.clauses) { + for (const clause of n.clauses) { currentReachabilityState = startState; bind(clause); if (clause.statements.length && currentReachabilityState === Reachability.Reachable && options.noFallthroughCasesInSwitch) { @@ -790,9 +790,9 @@ namespace ts { } function hasExportDeclarations(node: ModuleDeclaration | SourceFile): boolean { - let body = node.kind === SyntaxKind.SourceFile ? node : (node).body; + const body = node.kind === SyntaxKind.SourceFile ? node : (node).body; if (body.kind === SyntaxKind.SourceFile || body.kind === SyntaxKind.ModuleBlock) { - for (let stat of (body).statements) { + for (const stat of (body).statements) { if (stat.kind === SyntaxKind.ExportDeclaration || stat.kind === SyntaxKind.ExportAssignment) { return true; } @@ -818,7 +818,7 @@ namespace ts { declareSymbolAndAddToSymbolTable(node, SymbolFlags.ValueModule, SymbolFlags.ValueModuleExcludes); } else { - let state = getModuleInstanceState(node); + const state = getModuleInstanceState(node); if (state === ModuleInstanceState.NonInstantiated) { declareSymbolAndAddToSymbolTable(node, SymbolFlags.NamespaceModule, SymbolFlags.NamespaceModuleExcludes); } @@ -830,7 +830,7 @@ namespace ts { node.symbol.constEnumOnlyModule = false; } else { - let currentModuleIsConstEnumOnly = state === ModuleInstanceState.ConstEnumOnly; + const currentModuleIsConstEnumOnly = state === ModuleInstanceState.ConstEnumOnly; if (node.symbol.constEnumOnlyModule === undefined) { // non-merged case - use the current state node.symbol.constEnumOnlyModule = currentModuleIsConstEnumOnly; @@ -851,10 +851,10 @@ namespace ts { // 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. - let symbol = createSymbol(SymbolFlags.Signature, getDeclarationName(node)); + const symbol = createSymbol(SymbolFlags.Signature, getDeclarationName(node)); addDeclarationToSymbol(symbol, node, SymbolFlags.Signature); - let typeLiteralSymbol = createSymbol(SymbolFlags.TypeLiteral, "__type"); + const typeLiteralSymbol = createSymbol(SymbolFlags.TypeLiteral, "__type"); addDeclarationToSymbol(typeLiteralSymbol, node, SymbolFlags.TypeLiteral); typeLiteralSymbol.members = { [symbol.name]: symbol }; } @@ -866,14 +866,14 @@ namespace ts { } if (inStrictMode) { - let seen: Map = {}; + const seen: Map = {}; - for (let prop of node.properties) { + for (const prop of node.properties) { if (prop.name.kind !== SyntaxKind.Identifier) { continue; } - let identifier = prop.name; + const identifier = prop.name; // ECMA-262 11.1.5 Object Initialiser // If previous is not undefined then throw a SyntaxError exception if any of the following conditions are true @@ -883,18 +883,18 @@ namespace 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 - let currentKind = prop.kind === SyntaxKind.PropertyAssignment || prop.kind === SyntaxKind.ShorthandPropertyAssignment || prop.kind === SyntaxKind.MethodDeclaration + const currentKind = prop.kind === SyntaxKind.PropertyAssignment || prop.kind === SyntaxKind.ShorthandPropertyAssignment || prop.kind === SyntaxKind.MethodDeclaration ? ElementKind.Property : ElementKind.Accessor; - let existingKind = seen[identifier.text]; + const existingKind = seen[identifier.text]; if (!existingKind) { seen[identifier.text] = currentKind; continue; } if (currentKind === ElementKind.Property && existingKind === ElementKind.Property) { - let span = getErrorSpanForNode(file, identifier); + 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)); } @@ -905,7 +905,7 @@ namespace ts { } function bindAnonymousDeclaration(node: Declaration, symbolFlags: SymbolFlags, name: string) { - let symbol = createSymbol(symbolFlags, name); + const symbol = createSymbol(symbolFlags, name); addDeclarationToSymbol(symbol, node, symbolFlags); } @@ -984,7 +984,7 @@ namespace ts { 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 - let span = getErrorSpanForNode(file, node.expression); + 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)); } } @@ -996,11 +996,11 @@ namespace ts { function checkStrictModeEvalOrArguments(contextNode: Node, name: Node) { if (name && name.kind === SyntaxKind.Identifier) { - let identifier = name; + 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. - let span = getErrorSpanForNode(file, name); + const span = getErrorSpanForNode(file, name); file.bindDiagnostics.push(createFileDiagnostic(file, span.start, span.length, getStrictModeEvalOrArgumentsMessage(contextNode), identifier.text)); } @@ -1061,7 +1061,7 @@ namespace ts { } function errorOnFirstToken(node: Node, message: DiagnosticMessage, arg0?: any, arg1?: any, arg2?: any) { - let span = getSpanOfTokenAtPosition(file, node.pos); + const span = getSpanOfTokenAtPosition(file, node.pos); file.bindDiagnostics.push(createFileDiagnostic(file, span.start, span.length, message, arg0, arg1, arg2)); } @@ -1076,7 +1076,7 @@ namespace ts { node.parent = parent; - let savedInStrictMode = inStrictMode; + const savedInStrictMode = inStrictMode; if (!savedInStrictMode) { updateStrictMode(node); } @@ -1122,7 +1122,7 @@ namespace ts { } function updateStrictModeStatementList(statements: NodeArray) { - for (let statement of statements) { + for (const statement of statements) { if (!isPrologueDirective(statement)) { return; } @@ -1136,7 +1136,7 @@ namespace ts { /// Should be called only on prologue directives (isPrologueDirective(node) should be true) function isUseStrictPrologueDirective(node: ExpressionStatement): boolean { - let nodeText = getTextOfNodeFromSourceText(file.text, node.expression); + 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). @@ -1211,7 +1211,7 @@ namespace ts { case SyntaxKind.FunctionExpression: case SyntaxKind.ArrowFunction: checkStrictModeFunctionName(node); - let bindingName = (node).name ? (node).name.text : "__function"; + const bindingName = (node).name ? (node).name.text : "__function"; return bindAnonymousDeclaration(node, SymbolFlags.Function, bindingName); case SyntaxKind.ClassExpression: case SyntaxKind.ClassDeclaration: @@ -1284,7 +1284,7 @@ namespace ts { bindBlockScopedDeclaration(node, SymbolFlags.Class, SymbolFlags.ClassExcludes); } else { - let bindingName = node.name ? node.name.text : "__class"; + 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) { @@ -1292,7 +1292,7 @@ namespace ts { } } - let symbol = node.symbol; + const symbol = node.symbol; // TypeScript 1.0 spec (April 2014): 8.4 // Every class automatically contains a static property member named 'prototype', the @@ -1303,7 +1303,7 @@ namespace ts { // 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. - let prototypeSymbol = createSymbol(SymbolFlags.Property | SymbolFlags.Prototype, "prototype"); + const prototypeSymbol = createSymbol(SymbolFlags.Property | SymbolFlags.Prototype, "prototype"); if (hasProperty(symbol.exports, prototypeSymbol.name)) { if (node.name) { node.name.parent = node; @@ -1368,7 +1368,7 @@ namespace ts { node.parent.kind === SyntaxKind.Constructor && isClassLike(node.parent.parent)) { - let classDeclaration = node.parent.parent; + const classDeclaration = node.parent.parent; declareSymbol(classDeclaration.symbol.members, classDeclaration.symbol, node, SymbolFlags.Property, SymbolFlags.PropertyExcludes); } } @@ -1394,13 +1394,13 @@ namespace ts { function pushImplicitLabel(): number { initializeReachabilityStateIfNecessary(); - let index = labelStack.push(Reachability.Unintialized) - 1; + const index = labelStack.push(Reachability.Unintialized) - 1; implicitLabels.push(index); return index; } function popNamedLabel(label: Identifier, outerState: Reachability): void { - let index = labelIndexMap[label.text]; + const index = labelIndexMap[label.text]; Debug.assert(index !== undefined); Debug.assert(labelStack.length == index + 1); @@ -1414,7 +1414,7 @@ namespace ts { Debug.assert(false, `Label stack: ${labelStack.length}, index:${implicitLabelIndex}`); } - let i = implicitLabels.pop(); + const i = implicitLabels.pop(); if (implicitLabelIndex !== i) { Debug.assert(false, `i: ${i}, index: ${implicitLabelIndex}`); diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 65f507c13c0..993742a71e1 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -33,26 +33,26 @@ namespace ts { // they no longer need the information (for example, if the user started editing again). let cancellationToken: CancellationToken; - let Symbol = objectAllocator.getSymbolConstructor(); - let Type = objectAllocator.getTypeConstructor(); - let Signature = objectAllocator.getSignatureConstructor(); + const Symbol = objectAllocator.getSymbolConstructor(); + const Type = objectAllocator.getTypeConstructor(); + const Signature = objectAllocator.getSignatureConstructor(); let typeCount = 0; let symbolCount = 0; - let emptyArray: any[] = []; - let emptySymbols: SymbolTable = {}; + const emptyArray: any[] = []; + const emptySymbols: SymbolTable = {}; - let compilerOptions = host.getCompilerOptions(); - let languageVersion = compilerOptions.target || ScriptTarget.ES3; - let modulekind = compilerOptions.module ? compilerOptions.module : languageVersion === ScriptTarget.ES6 ? ModuleKind.ES6 : ModuleKind.None; + const compilerOptions = host.getCompilerOptions(); + const languageVersion = compilerOptions.target || ScriptTarget.ES3; + const modulekind = compilerOptions.module ? compilerOptions.module : languageVersion === ScriptTarget.ES6 ? ModuleKind.ES6 : ModuleKind.None; - let emitResolver = createResolver(); + const emitResolver = createResolver(); - let undefinedSymbol = createSymbol(SymbolFlags.Property | SymbolFlags.Transient, "undefined"); - let argumentsSymbol = createSymbol(SymbolFlags.Property | SymbolFlags.Transient, "arguments"); + const undefinedSymbol = createSymbol(SymbolFlags.Property | SymbolFlags.Transient, "undefined"); + const argumentsSymbol = createSymbol(SymbolFlags.Property | SymbolFlags.Transient, "arguments"); - let checker: TypeChecker = { + const checker: TypeChecker = { getNodeCount: () => sum(host.getSourceFiles(), "nodeCount"), getIdentifierCount: () => sum(host.getSourceFiles(), "identifierCount"), getSymbolCount: () => sum(host.getSourceFiles(), "symbolCount") + symbolCount, @@ -97,35 +97,35 @@ namespace ts { isOptionalParameter }; - let unknownSymbol = createSymbol(SymbolFlags.Property | SymbolFlags.Transient, "unknown"); - let resolvingSymbol = createSymbol(SymbolFlags.Transient, "__resolving__"); + const unknownSymbol = createSymbol(SymbolFlags.Property | SymbolFlags.Transient, "unknown"); + const resolvingSymbol = createSymbol(SymbolFlags.Transient, "__resolving__"); - let anyType = createIntrinsicType(TypeFlags.Any, "any"); - let stringType = createIntrinsicType(TypeFlags.String, "string"); - let numberType = createIntrinsicType(TypeFlags.Number, "number"); - let booleanType = createIntrinsicType(TypeFlags.Boolean, "boolean"); - let esSymbolType = createIntrinsicType(TypeFlags.ESSymbol, "symbol"); - let voidType = createIntrinsicType(TypeFlags.Void, "void"); - let undefinedType = createIntrinsicType(TypeFlags.Undefined | TypeFlags.ContainsUndefinedOrNull, "undefined"); - let nullType = createIntrinsicType(TypeFlags.Null | TypeFlags.ContainsUndefinedOrNull, "null"); - let unknownType = createIntrinsicType(TypeFlags.Any, "unknown"); - let circularType = createIntrinsicType(TypeFlags.Any, "__circular__"); + const anyType = createIntrinsicType(TypeFlags.Any, "any"); + const stringType = createIntrinsicType(TypeFlags.String, "string"); + const numberType = createIntrinsicType(TypeFlags.Number, "number"); + const booleanType = createIntrinsicType(TypeFlags.Boolean, "boolean"); + const esSymbolType = createIntrinsicType(TypeFlags.ESSymbol, "symbol"); + const voidType = createIntrinsicType(TypeFlags.Void, "void"); + const undefinedType = createIntrinsicType(TypeFlags.Undefined | TypeFlags.ContainsUndefinedOrNull, "undefined"); + const nullType = createIntrinsicType(TypeFlags.Null | TypeFlags.ContainsUndefinedOrNull, "null"); + const unknownType = createIntrinsicType(TypeFlags.Any, "unknown"); + const circularType = createIntrinsicType(TypeFlags.Any, "__circular__"); - let emptyObjectType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); - let emptyGenericType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); + const emptyObjectType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); + const emptyGenericType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); emptyGenericType.instantiations = {}; - let anyFunctionType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); + const anyFunctionType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); // The anyFunctionType contains the anyFunctionType by definition. The flag is further propagated // in getPropagatingFlagsOfTypes, and it is checked in inferFromTypes. anyFunctionType.flags |= TypeFlags.ContainsAnyFunctionType; - let noConstraintType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); + const noConstraintType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); - let anySignature = createSignature(undefined, undefined, emptyArray, anyType, undefined, 0, false, false); - let unknownSignature = createSignature(undefined, undefined, emptyArray, unknownType, undefined, 0, false, false); + const anySignature = createSignature(undefined, undefined, emptyArray, anyType, undefined, 0, false, false); + const unknownSignature = createSignature(undefined, undefined, emptyArray, unknownType, undefined, 0, false, false); - let globals: SymbolTable = {}; + const globals: SymbolTable = {}; let globalESSymbolConstructorSymbol: Symbol; @@ -162,29 +162,29 @@ namespace ts { let jsxElementClassType: Type; - let tupleTypes: Map = {}; - let unionTypes: Map = {}; - let intersectionTypes: Map = {}; - let stringLiteralTypes: Map = {}; + const tupleTypes: Map = {}; + const unionTypes: Map = {}; + const intersectionTypes: Map = {}; + const stringLiteralTypes: Map = {}; let emitExtends = false; let emitDecorate = false; let emitParam = false; let emitAwaiter = false; - let emitGenerator = false; + const emitGenerator = false; - let resolutionTargets: TypeSystemEntity[] = []; - let resolutionResults: boolean[] = []; - let resolutionPropertyNames: TypeSystemPropertyName[] = []; + const resolutionTargets: TypeSystemEntity[] = []; + const resolutionResults: boolean[] = []; + const resolutionPropertyNames: TypeSystemPropertyName[] = []; - let mergedSymbols: Symbol[] = []; - let symbolLinks: SymbolLinks[] = []; - let nodeLinks: NodeLinks[] = []; - let potentialThisCollisions: Node[] = []; - let awaitedTypeStack: number[] = []; + const mergedSymbols: Symbol[] = []; + const symbolLinks: SymbolLinks[] = []; + const nodeLinks: NodeLinks[] = []; + const potentialThisCollisions: Node[] = []; + const awaitedTypeStack: number[] = []; - let diagnostics = createDiagnosticCollection(); + const diagnostics = createDiagnosticCollection(); - let primitiveTypeInfo: Map<{ type: Type; flags: TypeFlags }> = { + const primitiveTypeInfo: Map<{ type: Type; flags: TypeFlags }> = { "string": { type: stringType, flags: TypeFlags.StringLike @@ -211,9 +211,9 @@ namespace ts { Element: "Element" }; - let subtypeRelation: Map = {}; - let assignableRelation: Map = {}; - let identityRelation: Map = {}; + const subtypeRelation: Map = {}; + const assignableRelation: Map = {}; + const identityRelation: Map = {}; // This is for caching the result of getSymbolDisplayBuilder. Do not access directly. let _displayBuilder: SymbolDisplayBuilder; @@ -239,7 +239,7 @@ namespace ts { } function error(location: Node, message: DiagnosticMessage, arg0?: any, arg1?: any, arg2?: any): void { - let diagnostic = location + const diagnostic = location ? createDiagnosticForNode(location, message, arg0, arg1, arg2) : createCompilerDiagnostic(message, arg0, arg1, arg2); diagnostics.add(diagnostic); @@ -277,7 +277,7 @@ namespace ts { } function cloneSymbol(symbol: Symbol): Symbol { - let result = createSymbol(symbol.flags | SymbolFlags.Merged, symbol.name); + const result = createSymbol(symbol.flags | SymbolFlags.Merged, symbol.name); result.declarations = symbol.declarations.slice(0); result.parent = symbol.parent; if (symbol.valueDeclaration) result.valueDeclaration = symbol.valueDeclaration; @@ -310,7 +310,7 @@ namespace ts { recordMergedSymbol(target, source); } else { - let message = target.flags & SymbolFlags.BlockScopedVariable || source.flags & SymbolFlags.BlockScopedVariable + const message = target.flags & SymbolFlags.BlockScopedVariable || source.flags & SymbolFlags.BlockScopedVariable ? Diagnostics.Cannot_redeclare_block_scoped_variable_0 : Diagnostics.Duplicate_identifier_0; forEach(source.declarations, node => { error(node.name ? node.name : node, message, symbolToString(source)); @@ -322,8 +322,8 @@ namespace ts { } function cloneSymbolTable(symbolTable: SymbolTable): SymbolTable { - let result: SymbolTable = {}; - for (let id in symbolTable) { + const result: SymbolTable = {}; + for (const id in symbolTable) { if (hasProperty(symbolTable, id)) { result[id] = symbolTable[id]; } @@ -332,7 +332,7 @@ namespace ts { } function mergeSymbolTable(target: SymbolTable, source: SymbolTable) { - for (let id in source) { + for (const id in source) { if (hasProperty(source, id)) { if (!hasProperty(target, id)) { target[id] = source[id]; @@ -350,12 +350,12 @@ namespace ts { function getSymbolLinks(symbol: Symbol): SymbolLinks { if (symbol.flags & SymbolFlags.Transient) return symbol; - let id = getSymbolId(symbol); + const id = getSymbolId(symbol); return symbolLinks[id] || (symbolLinks[id] = {}); } function getNodeLinks(node: Node): NodeLinks { - let nodeId = getNodeId(node); + const nodeId = getNodeId(node); return nodeLinks[nodeId] || (nodeLinks[nodeId] = {}); } @@ -369,13 +369,13 @@ namespace ts { function getSymbol(symbols: SymbolTable, name: string, meaning: SymbolFlags): Symbol { if (meaning && hasProperty(symbols, name)) { - let symbol = symbols[name]; + const symbol = symbols[name]; Debug.assert((symbol.flags & SymbolFlags.Instantiated) === 0, "Should never get an instantiated symbol here."); if (symbol.flags & meaning) { return symbol; } if (symbol.flags & SymbolFlags.Alias) { - let target = resolveAlias(symbol); + const target = resolveAlias(symbol); // Unknown symbol means an error occurred in alias resolution, treat it as positive answer to avoid cascading errors if (target === unknownSymbol || target.flags & meaning) { return symbol; @@ -421,7 +421,7 @@ namespace ts { else if (declaration.parent.parent.kind === SyntaxKind.ForOfStatement || declaration.parent.parent.kind === SyntaxKind.ForInStatement) { // ForIn/ForOf case - use site should not be used in expression part - let expression = (declaration.parent.parent).expression; + const expression = (declaration.parent.parent).expression; return isSameScopeDescendentOf(usage, expression, container); } } @@ -460,7 +460,7 @@ namespace ts { let result: Symbol; let lastLocation: Node; let propertyWithInvalidInitializer: Node; - let errorLocation = location; + const errorLocation = location; let grandparent: Node; loop: while (location) { @@ -482,7 +482,7 @@ namespace ts { case SyntaxKind.SourceFile: if (!isExternalModule(location)) break; case SyntaxKind.ModuleDeclaration: - let moduleExports = getSymbolOfNode(location).exports; + const moduleExports = getSymbolOfNode(location).exports; if (location.kind === SyntaxKind.SourceFile || (location.kind === SyntaxKind.ModuleDeclaration && (location).name.kind === SyntaxKind.StringLiteral)) { @@ -504,7 +504,7 @@ namespace ts { } result = moduleExports["default"]; - let localSymbol = getLocalSymbolForExportDefault(result); + const localSymbol = getLocalSymbolForExportDefault(result); if (result && localSymbol && (result.flags & meaning) && localSymbol.name === name) { break loop; } @@ -529,7 +529,7 @@ namespace ts { // by the same name as a constructor parameter or local variable are inaccessible // in initializer expressions for instance member variables. if (isClassLike(location.parent) && !(location.flags & NodeFlags.Static)) { - let ctor = findConstructorDeclaration(location.parent); + const ctor = findConstructorDeclaration(location.parent); if (ctor && ctor.locals) { if (getSymbol(ctor.locals, name, meaning & SymbolFlags.Value)) { // Remember the property node, it will be used later to report appropriate error @@ -552,7 +552,7 @@ namespace ts { break loop; } if (location.kind === SyntaxKind.ClassExpression && meaning & SymbolFlags.Class) { - let className = (location).name; + const className = (location).name; if (className && name === className.text) { result = location.symbol; break loop; @@ -597,7 +597,7 @@ namespace ts { } if (meaning & SymbolFlags.Function) { - let functionName = (location).name; + const functionName = (location).name; if (functionName && name === functionName.text) { result = location.symbol; break loop; @@ -647,7 +647,7 @@ namespace ts { if (propertyWithInvalidInitializer) { // We have a match, but the reference occurred within a property initializer and the identifier also binds // to a local variable in the constructor where the code will be emitted. - let propertyName = (propertyWithInvalidInitializer).name; + const propertyName = (propertyWithInvalidInitializer).name; error(errorLocation, Diagnostics.Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor, declarationNameToString(propertyName), typeof nameArg === "string" ? nameArg : declarationNameToString(nameArg)); return undefined; @@ -659,7 +659,7 @@ namespace ts { // declare module foo { // interface bar {} // } - // let foo/*1*/: foo/*2*/.bar; + // const foo/*1*/: foo/*2*/.bar; // The foo at /*1*/ and /*2*/ will share same symbol with two meaning // block - scope variable and namespace module. However, only when we // try to resolve name in /*1*/ which is used in variable position, @@ -677,7 +677,7 @@ namespace ts { function checkResolvedBlockScopedVariable(result: Symbol, errorLocation: Node): void { Debug.assert((result.flags & SymbolFlags.BlockScopedVariable) !== 0); // Block-scoped variables cannot be used before their definition - let declaration = forEach(result.declarations, d => isBlockOrCatchScoped(d) ? d : undefined); + const declaration = forEach(result.declarations, d => isBlockOrCatchScoped(d) ? d : undefined); Debug.assert(declaration !== undefined, "Block-scoped variable declaration is undefined"); @@ -727,9 +727,9 @@ namespace ts { } function getTargetOfImportClause(node: ImportClause): Symbol { - let moduleSymbol = resolveExternalModuleName(node, (node.parent).moduleSpecifier); + const moduleSymbol = resolveExternalModuleName(node, (node.parent).moduleSpecifier); if (moduleSymbol) { - let exportDefaultSymbol = resolveSymbol(moduleSymbol.exports["default"]); + const exportDefaultSymbol = resolveSymbol(moduleSymbol.exports["default"]); if (!exportDefaultSymbol) { error(node.name, Diagnostics.Module_0_has_no_default_export, symbolToString(moduleSymbol)); } @@ -738,13 +738,13 @@ namespace ts { } function getTargetOfNamespaceImport(node: NamespaceImport): Symbol { - let moduleSpecifier = (node.parent.parent).moduleSpecifier; + const moduleSpecifier = (node.parent.parent).moduleSpecifier; return resolveESModuleSymbol(resolveExternalModuleName(node, moduleSpecifier), moduleSpecifier); } function getMemberOfModuleVariable(moduleSymbol: Symbol, name: string): Symbol { if (moduleSymbol.flags & SymbolFlags.Variable) { - let typeAnnotation = (moduleSymbol.valueDeclaration).type; + const typeAnnotation = (moduleSymbol.valueDeclaration).type; if (typeAnnotation) { return getPropertyOfType(getTypeFromTypeNode(typeAnnotation), name); } @@ -773,7 +773,7 @@ namespace ts { if (valueSymbol.flags & (SymbolFlags.Type | SymbolFlags.Namespace)) { return valueSymbol; } - let result = createSymbol(valueSymbol.flags | typeSymbol.flags, valueSymbol.name); + const result = createSymbol(valueSymbol.flags | typeSymbol.flags, valueSymbol.name); result.declarations = concatenate(valueSymbol.declarations, typeSymbol.declarations); result.parent = valueSymbol.parent || typeSymbol.parent; if (valueSymbol.valueDeclaration) result.valueDeclaration = valueSymbol.valueDeclaration; @@ -784,7 +784,7 @@ namespace ts { function getExportOfModule(symbol: Symbol, name: string): Symbol { if (symbol.flags & SymbolFlags.Module) { - let exports = getExportsOfSymbol(symbol); + const exports = getExportsOfSymbol(symbol); if (hasProperty(exports, name)) { return resolveSymbol(exports[name]); } @@ -793,7 +793,7 @@ namespace ts { function getPropertyOfVariable(symbol: Symbol, name: string): Symbol { if (symbol.flags & SymbolFlags.Variable) { - let typeAnnotation = (symbol.valueDeclaration).type; + const typeAnnotation = (symbol.valueDeclaration).type; if (typeAnnotation) { return resolveSymbol(getPropertyOfType(getTypeFromTypeNode(typeAnnotation), name)); } @@ -801,14 +801,14 @@ namespace ts { } function getExternalModuleMember(node: ImportDeclaration | ExportDeclaration, specifier: ImportOrExportSpecifier): Symbol { - let moduleSymbol = resolveExternalModuleName(node, node.moduleSpecifier); - let targetSymbol = resolveESModuleSymbol(moduleSymbol, node.moduleSpecifier); + const moduleSymbol = resolveExternalModuleName(node, node.moduleSpecifier); + const targetSymbol = resolveESModuleSymbol(moduleSymbol, node.moduleSpecifier); if (targetSymbol) { - let name = specifier.propertyName || specifier.name; + const name = specifier.propertyName || specifier.name; if (name.text) { - let symbolFromModule = getExportOfModule(targetSymbol, name.text); - let symbolFromVariable = getPropertyOfVariable(targetSymbol, name.text); - let symbol = symbolFromModule && symbolFromVariable ? + const symbolFromModule = getExportOfModule(targetSymbol, name.text); + const symbolFromVariable = getPropertyOfVariable(targetSymbol, name.text); + const symbol = symbolFromModule && symbolFromVariable ? combineValueAndTypeSymbols(symbolFromVariable, symbolFromModule) : symbolFromModule || symbolFromVariable; if (!symbol) { @@ -856,11 +856,11 @@ namespace ts { function resolveAlias(symbol: Symbol): Symbol { Debug.assert((symbol.flags & SymbolFlags.Alias) !== 0, "Should only get Alias here."); - let links = getSymbolLinks(symbol); + const links = getSymbolLinks(symbol); if (!links.target) { links.target = resolvingSymbol; - let node = getDeclarationOfAliasSymbol(symbol); - let target = getTargetOfAliasDeclaration(node); + const node = getDeclarationOfAliasSymbol(symbol); + const target = getTargetOfAliasDeclaration(node); if (links.target === resolvingSymbol) { links.target = target || unknownSymbol; } @@ -875,10 +875,10 @@ namespace ts { } function markExportAsReferenced(node: ImportEqualsDeclaration | ExportAssignment | ExportSpecifier) { - let symbol = getSymbolOfNode(node); - let target = resolveAlias(symbol); + const symbol = getSymbolOfNode(node); + const target = resolveAlias(symbol); if (target) { - let markAlias = + const markAlias = (target === unknownSymbol && compilerOptions.isolatedModules) || (target !== unknownSymbol && (target.flags & SymbolFlags.Value) && !isConstEnumOrConstEnumOnlyModule(target)); @@ -892,10 +892,10 @@ namespace ts { // we reach a non-alias or an exported entity (which is always considered referenced). We do this by checking the target of // the alias as an expression (which recursively takes us back here if the target references another alias). function markAliasSymbolAsReferenced(symbol: Symbol) { - let links = getSymbolLinks(symbol); + const links = getSymbolLinks(symbol); if (!links.referenced) { links.referenced = true; - let node = getDeclarationOfAliasSymbol(symbol); + const node = getDeclarationOfAliasSymbol(symbol); if (node.kind === SyntaxKind.ExportAssignment) { // export default checkExpressionCached((node).expression); @@ -950,7 +950,7 @@ namespace ts { let symbol: Symbol; if (name.kind === SyntaxKind.Identifier) { - let message = meaning === SymbolFlags.Namespace ? Diagnostics.Cannot_find_namespace_0 : Diagnostics.Cannot_find_name_0; + const message = meaning === SymbolFlags.Namespace ? Diagnostics.Cannot_find_namespace_0 : Diagnostics.Cannot_find_name_0; symbol = resolveName(name, (name).text, meaning, ignoreErrors ? undefined : message, name); if (!symbol) { @@ -958,10 +958,10 @@ namespace ts { } } else if (name.kind === SyntaxKind.QualifiedName || name.kind === SyntaxKind.PropertyAccessExpression) { - let left = name.kind === SyntaxKind.QualifiedName ? (name).left : (name).expression; - let right = name.kind === SyntaxKind.QualifiedName ? (name).right : (name).name; + const left = name.kind === SyntaxKind.QualifiedName ? (name).left : (name).expression; + const right = name.kind === SyntaxKind.QualifiedName ? (name).right : (name).name; - let namespace = resolveEntityName(left, SymbolFlags.Namespace, ignoreErrors); + const namespace = resolveEntityName(left, SymbolFlags.Namespace, ignoreErrors); if (!namespace || namespace === unknownSymbol || nodeIsMissing(right)) { return undefined; } @@ -985,26 +985,26 @@ namespace ts { return; } - let moduleReferenceLiteral = moduleReferenceExpression; - let searchPath = getDirectoryPath(getSourceFile(location).fileName); + const moduleReferenceLiteral = moduleReferenceExpression; + const searchPath = getDirectoryPath(getSourceFile(location).fileName); // Module names are escaped in our symbol table. However, string literal values aren't. // Escape the name in the "require(...)" clause to ensure we find the right symbol. - let moduleName = escapeIdentifier(moduleReferenceLiteral.text); + const moduleName = escapeIdentifier(moduleReferenceLiteral.text); if (moduleName === undefined) { return; } - let isRelative = isExternalModuleNameRelative(moduleName); + const isRelative = isExternalModuleNameRelative(moduleName); if (!isRelative) { - let symbol = getSymbol(globals, "\"" + moduleName + "\"", SymbolFlags.ValueModule); + const symbol = getSymbol(globals, "\"" + moduleName + "\"", SymbolFlags.ValueModule); if (symbol) { return symbol; } } - let resolvedModule = getResolvedModule(getSourceFile(location), moduleReferenceLiteral.text); - let sourceFile = resolvedModule && host.getSourceFile(resolvedModule.resolvedFileName); + const resolvedModule = getResolvedModule(getSourceFile(location), moduleReferenceLiteral.text); + const sourceFile = resolvedModule && host.getSourceFile(resolvedModule.resolvedFileName); if (sourceFile) { if (sourceFile.symbol) { return sourceFile.symbol; @@ -1046,12 +1046,12 @@ namespace ts { } function getExportsOfModule(moduleSymbol: Symbol): SymbolTable { - let links = getSymbolLinks(moduleSymbol); + const links = getSymbolLinks(moduleSymbol); return links.resolvedExports || (links.resolvedExports = getExportsForModule(moduleSymbol)); } function extendExportSymbols(target: SymbolTable, source: SymbolTable) { - for (let id in source) { + for (const id in source) { if (id !== "default" && !hasProperty(target, id)) { target[id] = source[id]; } @@ -1060,7 +1060,7 @@ namespace ts { function getExportsForModule(moduleSymbol: Symbol): SymbolTable { let result: SymbolTable; - let visitedSymbols: Symbol[] = []; + const visitedSymbols: Symbol[] = []; visit(moduleSymbol); return result || moduleSymbol.exports; @@ -1076,9 +1076,9 @@ namespace ts { extendExportSymbols(result, symbol.exports); } // All export * declarations are collected in an __export symbol by the binder - let exportStars = symbol.exports["__export"]; + const exportStars = symbol.exports["__export"]; if (exportStars) { - for (let node of exportStars.declarations) { + for (const node of exportStars.declarations) { visit(resolveExternalModuleName(node, (node).moduleSpecifier)); } } @@ -1126,8 +1126,8 @@ namespace ts { } function findConstructorDeclaration(node: ClassLikeDeclaration): ConstructorDeclaration { - let members = node.members; - for (let member of members) { + const members = node.members; + for (const member of members) { if (member.kind === SyntaxKind.Constructor && nodeIsPresent((member).body)) { return member; } @@ -1135,19 +1135,19 @@ namespace ts { } function createType(flags: TypeFlags): Type { - let result = new Type(checker, flags); + const result = new Type(checker, flags); result.id = typeCount++; return result; } function createIntrinsicType(kind: TypeFlags, intrinsicName: string): IntrinsicType { - let type = createType(kind); + const type = createType(kind); type.intrinsicName = intrinsicName; return type; } function createObjectType(kind: TypeFlags, symbol?: Symbol): ObjectType { - let type = createType(kind); + const type = createType(kind); type.symbol = symbol; return type; } @@ -1165,11 +1165,11 @@ namespace ts { function getNamedMembers(members: SymbolTable): Symbol[] { let result: Symbol[]; - for (let id in members) { + for (const id in members) { if (hasProperty(members, id)) { if (!isReservedMemberName(id)) { if (!result) result = []; - let symbol = members[id]; + const symbol = members[id]; if (symbolIsValue(symbol)) { result.push(symbol); } @@ -1239,7 +1239,7 @@ namespace ts { } // If symbol needs qualification, make sure that parent is accessible, if it is then this symbol is accessible too - let accessibleParent = getAccessibleSymbolChain(symbolFromSymbolTable.parent, enclosingDeclaration, getQualifiedLeftMeaning(meaning), useOnlyExternalAliasing); + const accessibleParent = getAccessibleSymbolChain(symbolFromSymbolTable.parent, enclosingDeclaration, getQualifiedLeftMeaning(meaning), useOnlyExternalAliasing); return !!accessibleParent; } @@ -1267,14 +1267,14 @@ namespace ts { // Is this external alias, then use it to name ts.forEach(symbolFromSymbolTable.declarations, isExternalModuleImportEqualsDeclaration)) { - let resolvedImportedSymbol = resolveAlias(symbolFromSymbolTable); + const resolvedImportedSymbol = resolveAlias(symbolFromSymbolTable); if (isAccessible(symbolFromSymbolTable, resolveAlias(symbolFromSymbolTable))) { return [symbolFromSymbolTable]; } // Look in the exported members, if we can find accessibleSymbolChain, symbol is accessible using this chain // but only if the symbolFromSymbolTable can be qualified - let accessibleSymbolsFromExports = resolvedImportedSymbol.exports ? getAccessibleSymbolChainFromSymbolTable(resolvedImportedSymbol.exports) : undefined; + const accessibleSymbolsFromExports = resolvedImportedSymbol.exports ? getAccessibleSymbolChainFromSymbolTable(resolvedImportedSymbol.exports) : undefined; if (accessibleSymbolsFromExports && canQualifySymbol(symbolFromSymbolTable, getQualifiedLeftMeaning(meaning))) { return [symbolFromSymbolTable].concat(accessibleSymbolsFromExports); } @@ -1319,13 +1319,13 @@ namespace ts { function isSymbolAccessible(symbol: Symbol, enclosingDeclaration: Node, meaning: SymbolFlags): SymbolAccessiblityResult { if (symbol && enclosingDeclaration && !(symbol.flags & SymbolFlags.TypeParameter)) { - let initialSymbol = symbol; + const initialSymbol = symbol; let meaningToLook = meaning; while (symbol) { // Symbol is accessible if it by itself is accessible - let accessibleSymbolChain = getAccessibleSymbolChain(symbol, enclosingDeclaration, meaningToLook, /*useOnlyExternalAliasing*/ false); + const accessibleSymbolChain = getAccessibleSymbolChain(symbol, enclosingDeclaration, meaningToLook, /*useOnlyExternalAliasing*/ false); if (accessibleSymbolChain) { - let hasAccessibleDeclarations = hasVisibleDeclarations(accessibleSymbolChain[0]); + const hasAccessibleDeclarations = hasVisibleDeclarations(accessibleSymbolChain[0]); if (!hasAccessibleDeclarations) { return { accessibility: SymbolAccessibility.NotAccessible, @@ -1343,7 +1343,7 @@ namespace ts { // export class c { // } // } - // let x: typeof m.c + // const x: typeof m.c // In the above example when we start with checking if typeof m.c symbol is accessible, // we are going to see if c can be accessed in scope directly. // But it can't, hence the accessible is going to be undefined, but that doesn't mean m.c is inaccessible @@ -1354,9 +1354,9 @@ namespace ts { // This could be a symbol that is not exported in the external module // or it could be a symbol from different external module that is not aliased and hence cannot be named - let symbolExternalModule = forEach(initialSymbol.declarations, getExternalModuleContainer); + const symbolExternalModule = forEach(initialSymbol.declarations, getExternalModuleContainer); if (symbolExternalModule) { - let enclosingExternalModule = getExternalModuleContainer(enclosingDeclaration); + const enclosingExternalModule = getExternalModuleContainer(enclosingDeclaration); if (symbolExternalModule !== enclosingExternalModule) { // name from different external module that is not visible return { @@ -1402,7 +1402,7 @@ namespace ts { // Mark the unexported alias as visible if its parent is visible // because these kind of aliases can be used to name types in declaration file - let anyImportSyntax = getAnyImportSyntax(declaration); + const anyImportSyntax = getAnyImportSyntax(declaration); if (anyImportSyntax && !(anyImportSyntax.flags & NodeFlags.Export) && // import clause without export isDeclarationVisible(anyImportSyntax.parent)) { @@ -1444,8 +1444,8 @@ namespace ts { meaning = SymbolFlags.Type; } - let firstIdentifier = getFirstIdentifier(entityName); - let symbol = resolveName(enclosingDeclaration, (firstIdentifier).text, meaning, /*nodeNotFoundErrorMessage*/ undefined, /*nameArg*/ undefined); + const firstIdentifier = getFirstIdentifier(entityName); + const symbol = resolveName(enclosingDeclaration, (firstIdentifier).text, meaning, /*nodeNotFoundErrorMessage*/ undefined, /*nameArg*/ undefined); // Verify if the symbol is accessible return (symbol && hasVisibleDeclarations(symbol)) || { @@ -1468,30 +1468,30 @@ namespace ts { } function symbolToString(symbol: Symbol, enclosingDeclaration?: Node, meaning?: SymbolFlags): string { - let writer = getSingleLineStringWriter(); + const writer = getSingleLineStringWriter(); getSymbolDisplayBuilder().buildSymbolDisplay(symbol, writer, enclosingDeclaration, meaning); - let result = writer.string(); + const result = writer.string(); releaseStringWriter(writer); return result; } function signatureToString(signature: Signature, enclosingDeclaration?: Node, flags?: TypeFormatFlags): string { - let writer = getSingleLineStringWriter(); + const writer = getSingleLineStringWriter(); getSymbolDisplayBuilder().buildSignatureDisplay(signature, writer, enclosingDeclaration, flags); - let result = writer.string(); + const result = writer.string(); releaseStringWriter(writer); return result; } function typeToString(type: Type, enclosingDeclaration?: Node, flags?: TypeFormatFlags): string { - let writer = getSingleLineStringWriter(); + const writer = getSingleLineStringWriter(); getSymbolDisplayBuilder().buildTypeDisplay(type, writer, enclosingDeclaration, flags); let result = writer.string(); releaseStringWriter(writer); - let maxLength = compilerOptions.noErrorTruncation || flags & TypeFormatFlags.NoTruncation ? undefined : 100; + const maxLength = compilerOptions.noErrorTruncation || flags & TypeFormatFlags.NoTruncation ? undefined : 100; if (maxLength && result.length >= maxLength) { result = result.substr(0, maxLength - "...".length) + "..."; } @@ -1515,7 +1515,7 @@ namespace ts { function getNameOfSymbol(symbol: Symbol): string { if (symbol.declarations && symbol.declarations.length) { - let declaration = symbol.declarations[0]; + const declaration = symbol.declarations[0]; if (declaration.name) { return declarationNameToString(declaration.name); } @@ -1562,7 +1562,7 @@ namespace ts { appendSymbolNameOnly(symbol, writer); } - // Let the writer know we just wrote out a symbol. The declaration emitter writer uses + // const the writer know we just wrote out a symbol. The declaration emitter writer uses // this to determine if an import it has previously seen (and not written out) needs // to be written to the file once the walk of the tree is complete. // @@ -1572,7 +1572,7 @@ namespace ts { writer.trackSymbol(symbol, enclosingDeclaration, meaning); function walkSymbol(symbol: Symbol, meaning: SymbolFlags): void { if (symbol) { - let accessibleSymbolChain = getAccessibleSymbolChain(symbol, enclosingDeclaration, meaning, !!(flags & SymbolFormatFlags.UseOnlyExternalAliasing)); + const accessibleSymbolChain = getAccessibleSymbolChain(symbol, enclosingDeclaration, meaning, !!(flags & SymbolFormatFlags.UseOnlyExternalAliasing)); if (!accessibleSymbolChain || needsQualification(accessibleSymbolChain[0], enclosingDeclaration, accessibleSymbolChain.length === 1 ? meaning : getQualifiedLeftMeaning(meaning))) { @@ -1584,7 +1584,7 @@ namespace ts { } if (accessibleSymbolChain) { - for (let accessibleSymbol of accessibleSymbolChain) { + for (const accessibleSymbol of accessibleSymbolChain) { appendParentTypeArgumentsAndSymbolName(accessibleSymbol); } } @@ -1607,8 +1607,8 @@ namespace ts { // Get qualified name if the symbol is not a type parameter // and there is an enclosing declaration or we specifically // asked for it - let isTypeParameter = symbol.flags & SymbolFlags.TypeParameter; - let typeFormatFlag = TypeFormatFlags.UseFullyQualifiedType & typeFlags; + const isTypeParameter = symbol.flags & SymbolFlags.TypeParameter; + const typeFormatFlag = TypeFormatFlags.UseFullyQualifiedType & typeFlags; if (!isTypeParameter && (enclosingDeclaration || typeFormatFlag)) { walkSymbol(symbol, meaning); return; @@ -1618,7 +1618,7 @@ namespace ts { } function buildTypeDisplay(type: Type, writer: SymbolWriter, enclosingDeclaration?: Node, globalFlags?: TypeFormatFlags, symbolStack?: Symbol[]) { - let globalFlagsToPass = globalFlags & TypeFormatFlags.WriteOwnNameForAnyLike; + const globalFlagsToPass = globalFlags & TypeFormatFlags.WriteOwnNameForAnyLike; let inObjectTypeLiteral = false; return writeType(type, globalFlags); @@ -1697,7 +1697,7 @@ namespace ts { } function writeTypeReference(type: TypeReference, flags: TypeFormatFlags) { - let typeArguments = type.typeArguments || emptyArray; + const typeArguments = type.typeArguments || emptyArray; if (type.target === globalArrayType && !(flags & TypeFormatFlags.WriteArrayAsGenericType)) { writeType(typeArguments[0], TypeFormatFlags.InElementType); writePunctuation(writer, SyntaxKind.OpenBracketToken); @@ -1707,14 +1707,14 @@ namespace ts { // Write the type reference in the format f.g.C where A and B are type arguments // for outer type parameters, and f and g are the respective declaring containers of those // type parameters. - let outerTypeParameters = type.target.outerTypeParameters; + const outerTypeParameters = type.target.outerTypeParameters; let i = 0; if (outerTypeParameters) { - let length = outerTypeParameters.length; + const length = outerTypeParameters.length; while (i < length) { // Find group of type arguments for type parameters with the same declaring container. - let start = i; - let parent = getParentSymbolOfTypeParameter(outerTypeParameters[i]); + const start = i; + const parent = getParentSymbolOfTypeParameter(outerTypeParameters[i]); do { i++; } while (i < length && getParentSymbolOfTypeParameter(outerTypeParameters[i]) === parent); @@ -1726,7 +1726,7 @@ namespace ts { } } } - let typeParameterCount = (type.target.typeParameters || emptyArray).length; + const typeParameterCount = (type.target.typeParameters || emptyArray).length; writeSymbolTypeReference(type.symbol, typeArguments, i, typeParameterCount, flags); } } @@ -1748,7 +1748,7 @@ namespace ts { } function writeAnonymousType(type: ObjectType, flags: TypeFormatFlags) { - let symbol = type.symbol; + const symbol = type.symbol; if (symbol) { // Always use 'typeof T' for type of class, enum, and module objects if (symbol.flags & (SymbolFlags.Class | SymbolFlags.Enum | SymbolFlags.ValueModule)) { @@ -1759,7 +1759,7 @@ namespace ts { } else if (contains(symbolStack, symbol)) { // If type is an anonymous type literal in a type alias declaration, use type alias name - let typeAlias = getTypeAliasForTypeLiteral(type); + const typeAlias = getTypeAliasForTypeLiteral(type); if (typeAlias) { // The specified symbol flags need to be reinterpreted as type flags buildSymbolDisplay(typeAlias, writer, enclosingDeclaration, SymbolFlags.Type, SymbolFormatFlags.None, flags); @@ -1786,9 +1786,9 @@ namespace ts { } function shouldWriteTypeOfFunctionSymbol() { - let isStaticMethodSymbol = !!(symbol.flags & SymbolFlags.Method && // typeof static method + const isStaticMethodSymbol = !!(symbol.flags & SymbolFlags.Method && // typeof static method forEach(symbol.declarations, declaration => declaration.flags & NodeFlags.Static)); - let isNonLocalFunctionSymbol = !!(symbol.flags & SymbolFlags.Function) && + const isNonLocalFunctionSymbol = !!(symbol.flags & SymbolFlags.Function) && (symbol.parent || // is exported function symbol forEach(symbol.declarations, declaration => declaration.parent.kind === SyntaxKind.SourceFile || declaration.parent.kind === SyntaxKind.ModuleBlock)); @@ -1807,7 +1807,7 @@ namespace ts { } function getIndexerParameterName(type: ObjectType, indexKind: IndexKind, fallbackName: string): string { - let declaration = getIndexDeclarationOfSymbol(type.symbol, indexKind); + const declaration = getIndexDeclarationOfSymbol(type.symbol, indexKind); if (!declaration) { // declaration might not be found if indexer was added from the contextual type. // in this case use fallback name @@ -1818,7 +1818,7 @@ namespace ts { } function writeLiteralType(type: ObjectType, flags: TypeFormatFlags) { - let resolved = resolveStructuredTypeMembers(type); + const resolved = resolveStructuredTypeMembers(type); if (!resolved.properties.length && !resolved.stringIndexType && !resolved.numberIndexType) { if (!resolved.callSignatures.length && !resolved.constructSignatures.length) { writePunctuation(writer, SyntaxKind.OpenBraceToken); @@ -1850,17 +1850,17 @@ namespace ts { } } - let saveInObjectTypeLiteral = inObjectTypeLiteral; + const saveInObjectTypeLiteral = inObjectTypeLiteral; inObjectTypeLiteral = true; writePunctuation(writer, SyntaxKind.OpenBraceToken); writer.writeLine(); writer.increaseIndent(); - for (let signature of resolved.callSignatures) { + for (const signature of resolved.callSignatures) { buildSignatureDisplay(signature, writer, enclosingDeclaration, globalFlagsToPass, symbolStack); writePunctuation(writer, SyntaxKind.SemicolonToken); writer.writeLine(); } - for (let signature of resolved.constructSignatures) { + for (const signature of resolved.constructSignatures) { writeKeyword(writer, SyntaxKind.NewKeyword); writeSpace(writer); @@ -1896,11 +1896,11 @@ namespace ts { writePunctuation(writer, SyntaxKind.SemicolonToken); writer.writeLine(); } - for (let p of resolved.properties) { - let t = getTypeOfSymbol(p); + for (const p of resolved.properties) { + const t = getTypeOfSymbol(p); if (p.flags & (SymbolFlags.Function | SymbolFlags.Method) && !getPropertiesOfObjectType(t).length) { - let signatures = getSignaturesOfType(t, SignatureKind.Call); - for (let signature of signatures) { + const signatures = getSignaturesOfType(t, SignatureKind.Call); + for (const signature of signatures) { buildSymbolDisplay(p, writer); if (p.flags & SymbolFlags.Optional) { writePunctuation(writer, SyntaxKind.QuestionToken); @@ -1929,7 +1929,7 @@ namespace ts { } function buildTypeParameterDisplayFromSymbol(symbol: Symbol, writer: SymbolWriter, enclosingDeclaraiton?: Node, flags?: TypeFormatFlags) { - let targetSymbol = getTargetSymbol(symbol); + const targetSymbol = getTargetSymbol(symbol); if (targetSymbol.flags & SymbolFlags.Class || targetSymbol.flags & SymbolFlags.Interface || targetSymbol.flags & SymbolFlags.TypeAlias) { buildDisplayForTypeParametersAndDelimiters(getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol), writer, enclosingDeclaraiton, flags); } @@ -1937,7 +1937,7 @@ namespace ts { function buildTypeParameterDisplay(tp: TypeParameter, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags, symbolStack?: Symbol[]) { appendSymbolNameOnly(tp.symbol, writer); - let constraint = getConstraintOfTypeParameter(tp); + const constraint = getConstraintOfTypeParameter(tp); if (constraint) { writeSpace(writer); writeKeyword(writer, SyntaxKind.ExtendsKeyword); @@ -1947,7 +1947,7 @@ namespace ts { } function buildParameterDisplay(p: Symbol, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags, symbolStack?: Symbol[]) { - let parameterNode = p.valueDeclaration; + const parameterNode = p.valueDeclaration; if (isRestParameter(parameterNode)) { writePunctuation(writer, SyntaxKind.DotDotDotToken); } @@ -2069,14 +2069,14 @@ namespace ts { function isUsedInExportAssignment(node: Node) { // Get source File and see if it is external module and has export assigned symbol - let externalModule = getContainingExternalModule(node); + const externalModule = getContainingExternalModule(node); let exportAssignmentSymbol: Symbol; let resolvedExportSymbol: Symbol; if (externalModule) { // This is export assigned symbol node - let externalModuleSymbol = getSymbolOfNode(externalModule); + const externalModuleSymbol = getSymbolOfNode(externalModule); exportAssignmentSymbol = getExportAssignmentSymbol(externalModuleSymbol); - let symbolOfNode = getSymbolOfNode(node); + const symbolOfNode = getSymbolOfNode(node); if (isSymbolUsedInExportAssignment(symbolOfNode)) { return true; } @@ -2131,7 +2131,7 @@ namespace ts { case SyntaxKind.FunctionDeclaration: case SyntaxKind.EnumDeclaration: case SyntaxKind.ImportEqualsDeclaration: - let parent = getDeclarationContainer(node); + const parent = getDeclarationContainer(node); // If the node is not exported or it is not ambient module element (except import declaration) if (!(getCombinedNodeFlags(node) & NodeFlags.Export) && !(node.kind !== SyntaxKind.ImportEqualsDeclaration && parent.kind !== SyntaxKind.SourceFile && isInAmbientContext(parent))) { @@ -2150,7 +2150,7 @@ namespace ts { // Private/protected properties/methods are not visible return false; } - // Public properties/methods are visible if its parents are visible, so let it fall into next case statement + // Public properties/methods are visible if its parents are visible, so const it fall into next case statement case SyntaxKind.Constructor: case SyntaxKind.ConstructSignature: @@ -2192,7 +2192,7 @@ namespace ts { } if (node) { - let links = getNodeLinks(node); + const links = getNodeLinks(node); if (links.isVisible === undefined) { links.isVisible = !!determineIfDeclarationIsVisible(); } @@ -2206,12 +2206,12 @@ namespace ts { exportSymbol = resolveName(node.parent, node.text, SymbolFlags.Value | SymbolFlags.Type | SymbolFlags.Namespace | SymbolFlags.Alias, Diagnostics.Cannot_find_name_0, node); } else if (node.parent.kind === SyntaxKind.ExportSpecifier) { - let exportSpecifier = node.parent; + const exportSpecifier = node.parent; exportSymbol = (exportSpecifier.parent.parent).moduleSpecifier ? getExternalModuleMember(exportSpecifier.parent.parent, exportSpecifier) : resolveEntityName(exportSpecifier.propertyName || exportSpecifier.name, SymbolFlags.Value | SymbolFlags.Type | SymbolFlags.Namespace | SymbolFlags.Alias); } - let result: Node[] = []; + const result: Node[] = []; if (exportSymbol) { buildVisibleNodeList(exportSymbol.declarations); } @@ -2220,16 +2220,16 @@ namespace ts { function buildVisibleNodeList(declarations: Declaration[]) { forEach(declarations, declaration => { getNodeLinks(declaration).isVisible = true; - let resultNode = getAnyImportSyntax(declaration) || declaration; + const resultNode = getAnyImportSyntax(declaration) || declaration; if (!contains(result, resultNode)) { result.push(resultNode); } if (isInternalModuleImportEqualsDeclaration(declaration)) { // Add the referenced top container visible - let internalModuleReference = (declaration).moduleReference; - let firstIdentifier = getFirstIdentifier(internalModuleReference); - let importSymbol = resolveName(declaration, firstIdentifier.text, SymbolFlags.Value | SymbolFlags.Type | SymbolFlags.Namespace, + const internalModuleReference = (declaration).moduleReference; + const firstIdentifier = getFirstIdentifier(internalModuleReference); + const importSymbol = resolveName(declaration, firstIdentifier.text, SymbolFlags.Value | SymbolFlags.Type | SymbolFlags.Namespace, Diagnostics.Cannot_find_name_0, firstIdentifier); buildVisibleNodeList(importSymbol.declarations); } @@ -2249,10 +2249,10 @@ namespace ts { * @param propertyName The property name that should be used to query the target for its type */ function pushTypeResolution(target: TypeSystemEntity, propertyName: TypeSystemPropertyName): boolean { - let resolutionCycleStartIndex = findResolutionCycleStartIndex(target, propertyName); + const resolutionCycleStartIndex = findResolutionCycleStartIndex(target, propertyName); if (resolutionCycleStartIndex >= 0) { // A cycle was found - let { length } = resolutionTargets; + const { length } = resolutionTargets; for (let i = resolutionCycleStartIndex; i < length; i++) { resolutionResults[i] = false; } @@ -2316,13 +2316,13 @@ namespace ts { // 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'. - let classType = getDeclaredTypeOfSymbol(prototype.parent); + const classType = getDeclaredTypeOfSymbol(prototype.parent); return classType.typeParameters ? createTypeReference(classType, map(classType.typeParameters, _ => anyType)) : classType; } // Return the type of the given property in the given type, or undefined if no such property exists function getTypeOfPropertyOfType(type: Type, name: string): Type { - let prop = getPropertyOfType(type, name); + const prop = getPropertyOfType(type, name); return prop ? getTypeOfSymbol(prop) : undefined; } @@ -2333,14 +2333,14 @@ namespace ts { // Return the type of a binding element parent. We check SymbolLinks first to see if a type has been // assigned by contextual typing. function getTypeForBindingElementParent(node: VariableLikeDeclaration) { - let symbol = getSymbolOfNode(node); + const symbol = getSymbolOfNode(node); return symbol && getSymbolLinks(symbol).type || getTypeForVariableLikeDeclaration(node); } // Return the inferred type for a binding element function getTypeForBindingElement(declaration: BindingElement): Type { - let pattern = declaration.parent; - let parentType = getTypeForBindingElementParent(pattern.parent); + const pattern = declaration.parent; + const parentType = getTypeForBindingElementParent(pattern.parent); // If parent has the unknown (error) type, then so does this binding element if (parentType === unknownType) { return unknownType; @@ -2358,7 +2358,7 @@ namespace ts { let type: Type; if (pattern.kind === SyntaxKind.ObjectBindingPattern) { // Use explicitly specified property name ({ p: xxx } form), or otherwise the implied name ({ p } form) - let name = declaration.propertyName || declaration.name; + const name = declaration.propertyName || declaration.name; // Use type of the specified property, or otherwise, for a numeric name, the type of the numeric index signature, // or otherwise the type of the string index signature. type = getTypeOfPropertyOfType(parentType, name.text) || @@ -2373,10 +2373,10 @@ namespace ts { // This elementType will be used if the specific property corresponding to this index is not // present (aka the tuple element property). This call also checks that the parentType is in // fact an iterable or array (depending on target language). - let elementType = checkIteratedTypeOrElementType(parentType, pattern, /*allowStringInput*/ false); + const elementType = checkIteratedTypeOrElementType(parentType, pattern, /*allowStringInput*/ false); if (!declaration.dotDotDotToken) { // Use specific property type when parent is a tuple or numeric index type when parent is an array - let propName = "" + indexOf(pattern.elements, declaration); + const propName = "" + indexOf(pattern.elements, declaration); type = isTupleLikeType(parentType) ? getTypeOfPropertyOfType(parentType, propName) : elementType; @@ -2423,16 +2423,16 @@ namespace ts { } if (declaration.kind === SyntaxKind.Parameter) { - let func = declaration.parent; + const func = declaration.parent; // For a parameter of a set accessor, use the type of the get accessor if one is present if (func.kind === SyntaxKind.SetAccessor && !hasDynamicName(func)) { - let getter = getDeclarationOfKind(declaration.parent.symbol, SyntaxKind.GetAccessor); + const getter = getDeclarationOfKind(declaration.parent.symbol, SyntaxKind.GetAccessor); if (getter) { return getReturnTypeOfSignature(getSignatureFromDeclaration(getter)); } } // Use contextual parameter type if one is available - let type = getContextuallyTypedParameterType(declaration); + const type = getContextuallyTypedParameterType(declaration); if (type) { return type; } @@ -2472,16 +2472,16 @@ namespace ts { // Return the type implied by an object binding pattern function getTypeFromObjectBindingPattern(pattern: BindingPattern, includePatternInType: boolean): Type { - let members: SymbolTable = {}; + const members: SymbolTable = {}; forEach(pattern.elements, e => { - let flags = SymbolFlags.Property | SymbolFlags.Transient | (e.initializer ? SymbolFlags.Optional : 0); - let name = e.propertyName || e.name; - let symbol = createSymbol(flags, name.text); + const flags = SymbolFlags.Property | SymbolFlags.Transient | (e.initializer ? SymbolFlags.Optional : 0); + const name = e.propertyName || e.name; + const symbol = createSymbol(flags, name.text); symbol.type = getTypeFromBindingElement(e, includePatternInType); symbol.bindingElement = e; members[symbol.name] = symbol; }); - let result = createAnonymousType(undefined, members, emptyArray, emptyArray, undefined, undefined); + const result = createAnonymousType(undefined, members, emptyArray, emptyArray, undefined, undefined); if (includePatternInType) { result.pattern = pattern; } @@ -2490,14 +2490,14 @@ namespace ts { // Return the type implied by an array binding pattern function getTypeFromArrayBindingPattern(pattern: BindingPattern, includePatternInType: boolean): Type { - let elements = pattern.elements; + const elements = pattern.elements; if (elements.length === 0 || elements[elements.length - 1].dotDotDotToken) { return languageVersion >= ScriptTarget.ES6 ? createIterableType(anyType) : anyArrayType; } // If the pattern has at least one element, and no rest element, then it should imply a tuple type. - let elementTypes = map(elements, e => e.kind === SyntaxKind.OmittedExpression ? anyType : getTypeFromBindingElement(e, includePatternInType)); + const elementTypes = map(elements, e => e.kind === SyntaxKind.OmittedExpression ? anyType : getTypeFromBindingElement(e, includePatternInType)); if (includePatternInType) { - let result = createNewTupleType(elementTypes); + const result = createNewTupleType(elementTypes); result.pattern = pattern; return result; } @@ -2543,7 +2543,7 @@ namespace ts { // Report implicit any errors unless this is a private property within an ambient declaration if (reportErrors && compilerOptions.noImplicitAny) { - let root = getRootDeclaration(declaration); + const root = getRootDeclaration(declaration); if (!isPrivateWithinAmbient(root) && !(root.kind === SyntaxKind.Parameter && isPrivateWithinAmbient(root.parent))) { reportImplicitAnyError(declaration, type); } @@ -2552,14 +2552,14 @@ namespace ts { } function getTypeOfVariableOrParameterOrProperty(symbol: Symbol): Type { - let links = getSymbolLinks(symbol); + const links = getSymbolLinks(symbol); if (!links.type) { // Handle prototype property if (symbol.flags & SymbolFlags.Prototype) { return links.type = getTypeOfPrototypeProperty(symbol); } // Handle catch clause variables - let declaration = symbol.valueDeclaration; + const declaration = symbol.valueDeclaration; if (declaration.parent.kind === SyntaxKind.CatchClause) { return links.type = anyType; } @@ -2599,7 +2599,7 @@ namespace ts { return accessor.type && getTypeFromTypeNode(accessor.type); } else { - let setterTypeAnnotation = getSetAccessorTypeAnnotationNode(accessor); + const setterTypeAnnotation = getSetAccessorTypeAnnotationNode(accessor); return setterTypeAnnotation && getTypeFromTypeNode(setterTypeAnnotation); } } @@ -2607,22 +2607,22 @@ namespace ts { } function getTypeOfAccessors(symbol: Symbol): Type { - let links = getSymbolLinks(symbol); + const links = getSymbolLinks(symbol); if (!links.type) { if (!pushTypeResolution(symbol, TypeSystemPropertyName.Type)) { return unknownType; } - let getter = getDeclarationOfKind(symbol, SyntaxKind.GetAccessor); - let setter = getDeclarationOfKind(symbol, SyntaxKind.SetAccessor); + const getter = getDeclarationOfKind(symbol, SyntaxKind.GetAccessor); + const setter = getDeclarationOfKind(symbol, SyntaxKind.SetAccessor); let type: Type; // First try to see if the user specified a return type on the get-accessor. - let getterReturnType = getAnnotatedAccessorType(getter); + const getterReturnType = getAnnotatedAccessorType(getter); if (getterReturnType) { type = getterReturnType; } else { // If the user didn't specify a return type, try to use the set-accessor's parameter type. - let setterParameterType = getAnnotatedAccessorType(setter); + const setterParameterType = getAnnotatedAccessorType(setter); if (setterParameterType) { type = setterParameterType; } @@ -2643,7 +2643,7 @@ namespace ts { if (!popTypeResolution()) { type = anyType; if (compilerOptions.noImplicitAny) { - let getter = getDeclarationOfKind(symbol, SyntaxKind.GetAccessor); + const getter = getDeclarationOfKind(symbol, SyntaxKind.GetAccessor); error(getter, 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)); } } @@ -2653,7 +2653,7 @@ namespace ts { } function getTypeOfFuncClassEnumModule(symbol: Symbol): Type { - let links = getSymbolLinks(symbol); + const links = getSymbolLinks(symbol); if (!links.type) { links.type = createObjectType(TypeFlags.Anonymous, symbol); } @@ -2661,7 +2661,7 @@ namespace ts { } function getTypeOfEnumMember(symbol: Symbol): Type { - let links = getSymbolLinks(symbol); + const links = getSymbolLinks(symbol); if (!links.type) { links.type = getDeclaredTypeOfEnum(getParentOfSymbol(symbol)); } @@ -2669,9 +2669,9 @@ namespace ts { } function getTypeOfAlias(symbol: Symbol): Type { - let links = getSymbolLinks(symbol); + const links = getSymbolLinks(symbol); if (!links.type) { - let targetSymbol = resolveAlias(symbol); + const targetSymbol = resolveAlias(symbol); // It only makes sense to get the type of a value symbol. If the result of resolving // the alias is not a value, then it has no type. To get the type associated with a @@ -2686,7 +2686,7 @@ namespace ts { } function getTypeOfInstantiatedSymbol(symbol: Symbol): Type { - let links = getSymbolLinks(symbol); + const links = getSymbolLinks(symbol); if (!links.type) { links.type = instantiateType(getTypeOfSymbol(links.target), links.mapper); } @@ -2722,7 +2722,7 @@ namespace ts { function hasBaseType(type: InterfaceType, checkBase: InterfaceType) { return check(type); function check(type: InterfaceType): boolean { - let target = getTargetType(type); + const target = getTargetType(type); return target === checkBase || forEach(getBaseTypes(target), check); } } @@ -2731,8 +2731,8 @@ namespace ts { // The function allocates a new array if the input type parameter set is undefined, but otherwise it modifies the set // in-place and returns the same array. function appendTypeParameters(typeParameters: TypeParameter[], declarations: TypeParameterDeclaration[]): TypeParameter[] { - for (let declaration of declarations) { - let tp = getDeclaredTypeOfTypeParameter(getSymbolOfNode(declaration)); + for (const declaration of declarations) { + const tp = getDeclaredTypeOfTypeParameter(getSymbolOfNode(declaration)); if (!typeParameters) { typeParameters = [tp]; } @@ -2755,7 +2755,7 @@ namespace ts { if (node.kind === SyntaxKind.ClassDeclaration || node.kind === SyntaxKind.ClassExpression || node.kind === SyntaxKind.FunctionDeclaration || node.kind === SyntaxKind.FunctionExpression || node.kind === SyntaxKind.MethodDeclaration || node.kind === SyntaxKind.ArrowFunction) { - let declarations = (node).typeParameters; + const declarations = (node).typeParameters; if (declarations) { return appendTypeParameters(appendOuterTypeParameters(typeParameters, node), declarations); } @@ -2765,7 +2765,7 @@ namespace ts { // The outer type parameters are those defined by enclosing generic classes, methods, or functions. function getOuterTypeParametersOfClassOrInterface(symbol: Symbol): TypeParameter[] { - let declaration = symbol.flags & SymbolFlags.Class ? symbol.valueDeclaration : getDeclarationOfKind(symbol, SyntaxKind.InterfaceDeclaration); + const declaration = symbol.flags & SymbolFlags.Class ? symbol.valueDeclaration : getDeclarationOfKind(symbol, SyntaxKind.InterfaceDeclaration); return appendOuterTypeParameters(undefined, declaration); } @@ -2773,10 +2773,10 @@ namespace ts { // interface, or type alias. function getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol: Symbol): TypeParameter[] { let result: TypeParameter[]; - for (let node of symbol.declarations) { + for (const node of symbol.declarations) { if (node.kind === SyntaxKind.InterfaceDeclaration || node.kind === SyntaxKind.ClassDeclaration || node.kind === SyntaxKind.ClassExpression || node.kind === SyntaxKind.TypeAliasDeclaration) { - let declaration = node; + const declaration = node; if (declaration.typeParameters) { result = appendTypeParameters(result, declaration.typeParameters); } @@ -2800,7 +2800,7 @@ namespace ts { } function getConstructorsForTypeArguments(type: ObjectType, typeArgumentNodes: TypeNode[]): Signature[] { - let typeArgCount = typeArgumentNodes ? typeArgumentNodes.length : 0; + const typeArgCount = typeArgumentNodes ? typeArgumentNodes.length : 0; return filter(getSignaturesOfType(type, SignatureKind.Construct), sig => (sig.typeParameters ? sig.typeParameters.length : 0) === typeArgCount); } @@ -2808,7 +2808,7 @@ namespace ts { function getInstantiatedConstructorsForTypeArguments(type: ObjectType, typeArgumentNodes: TypeNode[]): Signature[] { let signatures = getConstructorsForTypeArguments(type, typeArgumentNodes); if (typeArgumentNodes) { - let typeArguments = map(typeArgumentNodes, getTypeFromTypeNode); + const typeArguments = map(typeArgumentNodes, getTypeFromTypeNode); signatures = map(signatures, sig => getSignatureInstantiation(sig, typeArguments)); } return signatures; @@ -2821,14 +2821,14 @@ namespace ts { // an object type with at least one construct signature. function getBaseConstructorTypeOfClass(type: InterfaceType): ObjectType { if (!type.resolvedBaseConstructorType) { - let baseTypeNode = getBaseTypeNodeOfClass(type); + const baseTypeNode = getBaseTypeNodeOfClass(type); if (!baseTypeNode) { return type.resolvedBaseConstructorType = undefinedType; } if (!pushTypeResolution(type, TypeSystemPropertyName.ResolvedBaseConstructorType)) { return unknownType; } - let baseConstructorType = checkExpression(baseTypeNode.expression); + const baseConstructorType = checkExpression(baseTypeNode.expression); 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. @@ -2852,8 +2852,8 @@ namespace ts { } function getBaseTypes(type: InterfaceType): ObjectType[] { - let isClass = type.symbol.flags & SymbolFlags.Class; - let isInterface = type.symbol.flags & SymbolFlags.Interface; + const isClass = type.symbol.flags & SymbolFlags.Class; + const isInterface = type.symbol.flags & SymbolFlags.Interface; if (!type.resolvedBaseTypes) { if (!isClass && !isInterface) { Debug.fail("type must be class or interface"); @@ -2870,11 +2870,11 @@ namespace ts { function resolveBaseTypesOfClass(type: InterfaceType): void { type.resolvedBaseTypes = type.resolvedBaseTypes || emptyArray; - let baseContructorType = getBaseConstructorTypeOfClass(type); + const baseContructorType = getBaseConstructorTypeOfClass(type); if (!(baseContructorType.flags & TypeFlags.ObjectType)) { return; } - let baseTypeNode = getBaseTypeNodeOfClass(type); + const baseTypeNode = getBaseTypeNodeOfClass(type); let baseType: Type; if (baseContructorType.symbol && baseContructorType.symbol.flags & SymbolFlags.Class) { // When base constructor type is a class we know that the constructors all have the same type parameters as the @@ -2886,7 +2886,7 @@ namespace ts { // The class derives from a "class-like" constructor function, check that we have at least one construct signature // with a matching number of type parameters and use the return type of the first instantiated signature. Elsewhere // we check that all instantiated signatures return the same type. - let constructors = getInstantiatedConstructorsForTypeArguments(baseContructorType, baseTypeNode.typeArguments); + const constructors = getInstantiatedConstructorsForTypeArguments(baseContructorType, baseTypeNode.typeArguments); if (!constructors.length) { error(baseTypeNode.expression, Diagnostics.No_base_constructor_has_the_specified_number_of_type_arguments); return; @@ -2915,10 +2915,10 @@ namespace ts { function resolveBaseTypesOfInterface(type: InterfaceType): void { type.resolvedBaseTypes = type.resolvedBaseTypes || emptyArray; - for (let declaration of type.symbol.declarations) { + for (const declaration of type.symbol.declarations) { if (declaration.kind === SyntaxKind.InterfaceDeclaration && getInterfaceBaseTypeNodes(declaration)) { - for (let node of getInterfaceBaseTypeNodes(declaration)) { - let baseType = getTypeFromTypeNode(node); + for (const node of getInterfaceBaseTypeNodes(declaration)) { + const baseType = getTypeFromTypeNode(node); if (baseType !== unknownType) { if (getTargetType(baseType).flags & (TypeFlags.Class | TypeFlags.Interface)) { if (type !== baseType && !hasBaseType(baseType, type)) { @@ -2946,16 +2946,16 @@ namespace ts { // true if the interface itself contains no references to "this" in its body, if all base types are interfaces, // and if none of the base interfaces have a "this" type. function isIndependentInterface(symbol: Symbol): boolean { - for (let declaration of symbol.declarations) { + for (const declaration of symbol.declarations) { if (declaration.kind === SyntaxKind.InterfaceDeclaration) { if (declaration.flags & NodeFlags.ContainsThis) { return false; } - let baseTypeNodes = getInterfaceBaseTypeNodes(declaration); + const baseTypeNodes = getInterfaceBaseTypeNodes(declaration); if (baseTypeNodes) { - for (let node of baseTypeNodes) { + for (const node of baseTypeNodes) { if (isSupportedExpressionWithTypeArguments(node)) { - let baseSymbol = resolveEntityName(node.expression, SymbolFlags.Type, /*ignoreErrors*/ true); + const baseSymbol = resolveEntityName(node.expression, SymbolFlags.Type, /*ignoreErrors*/ true); if (!baseSymbol || !(baseSymbol.flags & SymbolFlags.Interface) || getDeclaredTypeOfClassOrInterface(baseSymbol).thisType) { return false; } @@ -2968,12 +2968,12 @@ namespace ts { } function getDeclaredTypeOfClassOrInterface(symbol: Symbol): InterfaceType { - let links = getSymbolLinks(symbol); + const links = getSymbolLinks(symbol); if (!links.declaredType) { - let kind = symbol.flags & SymbolFlags.Class ? TypeFlags.Class : TypeFlags.Interface; - let type = links.declaredType = createObjectType(kind, symbol); - let outerTypeParameters = getOuterTypeParametersOfClassOrInterface(symbol); - let localTypeParameters = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol); + const kind = symbol.flags & SymbolFlags.Class ? TypeFlags.Class : TypeFlags.Interface; + const type = links.declaredType = createObjectType(kind, symbol); + const outerTypeParameters = getOuterTypeParametersOfClassOrInterface(symbol); + const localTypeParameters = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol); // A class or interface is generic if it has type parameters or a "this" type. We always give classes a "this" type // because it is not feasible to analyze all members to determine if the "this" type escapes the class (in particular, // property types inferred from initializers and method return types inferred from return statements are very hard @@ -2997,14 +2997,14 @@ namespace ts { } function getDeclaredTypeOfTypeAlias(symbol: Symbol): Type { - let links = getSymbolLinks(symbol); + const links = getSymbolLinks(symbol); if (!links.declaredType) { // Note that we use the links object as the target here because the symbol object is used as the unique // identity for resolution of the 'type' property in SymbolLinks. if (!pushTypeResolution(symbol, TypeSystemPropertyName.DeclaredType)) { return unknownType; } - let declaration = getDeclarationOfKind(symbol, SyntaxKind.TypeAliasDeclaration); + const declaration = getDeclarationOfKind(symbol, SyntaxKind.TypeAliasDeclaration); let type = getTypeFromTypeNode(declaration.type); if (popTypeResolution()) { links.typeParameters = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol); @@ -3025,9 +3025,9 @@ namespace ts { } function getDeclaredTypeOfEnum(symbol: Symbol): Type { - let links = getSymbolLinks(symbol); + const links = getSymbolLinks(symbol); if (!links.declaredType) { - let type = createType(TypeFlags.Enum); + const type = createType(TypeFlags.Enum); type.symbol = symbol; links.declaredType = type; } @@ -3035,9 +3035,9 @@ namespace ts { } function getDeclaredTypeOfTypeParameter(symbol: Symbol): TypeParameter { - let links = getSymbolLinks(symbol); + const links = getSymbolLinks(symbol); if (!links.declaredType) { - let type = createType(TypeFlags.TypeParameter); + const type = createType(TypeFlags.TypeParameter); type.symbol = symbol; if (!(getDeclarationOfKind(symbol, SyntaxKind.TypeParameter)).constraint) { type.constraint = noConstraintType; @@ -3048,7 +3048,7 @@ namespace ts { } function getDeclaredTypeOfAlias(symbol: Symbol): Type { - let links = getSymbolLinks(symbol); + const links = getSymbolLinks(symbol); if (!links.declaredType) { links.declaredType = getDeclaredTypeOfSymbol(resolveAlias(symbol)); } @@ -3078,7 +3078,7 @@ namespace ts { // A type reference is considered independent if each type argument is considered independent. function isIndependentTypeReference(node: TypeReferenceNode): boolean { if (node.typeArguments) { - for (let typeNode of node.typeArguments) { + for (const typeNode of node.typeArguments) { if (!isIndependentType(typeNode)) { return false; } @@ -3120,7 +3120,7 @@ namespace ts { if (node.kind !== SyntaxKind.Constructor && (!node.type || !isIndependentType(node.type))) { return false; } - for (let parameter of node.parameters) { + for (const parameter of node.parameters) { if (!isIndependentVariableLikeDeclaration(parameter)) { return false; } @@ -3135,7 +3135,7 @@ namespace ts { // assumed not to be free of "this" references. function isIndependentMember(symbol: Symbol): boolean { if (symbol.declarations && symbol.declarations.length === 1) { - let declaration = symbol.declarations[0]; + const declaration = symbol.declarations[0]; if (declaration) { switch (declaration.kind) { case SyntaxKind.PropertyDeclaration: @@ -3152,8 +3152,8 @@ namespace ts { } function createSymbolTable(symbols: Symbol[]): SymbolTable { - let result: SymbolTable = {}; - for (let symbol of symbols) { + const result: SymbolTable = {}; + for (const symbol of symbols) { result[symbol.name] = symbol; } return result; @@ -3162,15 +3162,15 @@ namespace ts { // The mappingThisOnly flag indicates that the only type parameter being mapped is "this". When the flag is true, // we check symbols to see if we can quickly conclude they are free of "this" references, thus needing no instantiation. function createInstantiatedSymbolTable(symbols: Symbol[], mapper: TypeMapper, mappingThisOnly: boolean): SymbolTable { - let result: SymbolTable = {}; - for (let symbol of symbols) { + const result: SymbolTable = {}; + for (const symbol of symbols) { result[symbol.name] = mappingThisOnly && isIndependentMember(symbol) ? symbol : instantiateSymbol(symbol, mapper); } return result; } function addInheritedMembers(symbols: SymbolTable, baseSymbols: Symbol[]) { - for (let s of baseSymbols) { + for (const s of baseSymbols) { if (!hasProperty(symbols, s.name)) { symbols[s.name] = s; } @@ -3179,7 +3179,7 @@ namespace ts { function addInheritedSignatures(signatures: Signature[], baseSignatures: Signature[]) { if (baseSignatures) { - for (let signature of baseSignatures) { + for (const signature of baseSignatures) { signatures.push(signature); } } @@ -3187,7 +3187,7 @@ namespace ts { function resolveDeclaredMembers(type: InterfaceType): InterfaceTypeWithDeclaredMembers { if (!(type).declaredProperties) { - let symbol = type.symbol; + const symbol = type.symbol; (type).declaredProperties = getNamedMembers(symbol.members); (type).declaredCallSignatures = getSignaturesOfSymbol(symbol.members["__call"]); (type).declaredConstructSignatures = getSignaturesOfSymbol(symbol.members["__new"]); @@ -3220,14 +3220,14 @@ namespace ts { stringIndexType = instantiateType(source.declaredStringIndexType, mapper); numberIndexType = instantiateType(source.declaredNumberIndexType, mapper); } - let baseTypes = getBaseTypes(source); + const baseTypes = getBaseTypes(source); if (baseTypes.length) { if (members === source.symbol.members) { members = createSymbolTable(source.declaredProperties); } - let thisArgument = lastOrUndefined(typeArguments); - for (let baseType of baseTypes) { - let instantiatedBaseType = thisArgument ? getTypeWithThisArgument(instantiateType(baseType, mapper), thisArgument) : baseType; + const thisArgument = lastOrUndefined(typeArguments); + for (const baseType of baseTypes) { + 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)); @@ -3243,16 +3243,16 @@ namespace ts { } function resolveTypeReferenceMembers(type: TypeReference): void { - let source = resolveDeclaredMembers(type.target); - let typeParameters = concatenate(source.typeParameters, [source.thisType]); - let typeArguments = type.typeArguments && type.typeArguments.length === typeParameters.length ? + const source = resolveDeclaredMembers(type.target); + const typeParameters = concatenate(source.typeParameters, [source.thisType]); + const typeArguments = type.typeArguments && type.typeArguments.length === typeParameters.length ? type.typeArguments : concatenate(type.typeArguments, [type]); resolveObjectTypeMembers(type, source, typeParameters, typeArguments); } function createSignature(declaration: SignatureDeclaration, typeParameters: TypeParameter[], parameters: Symbol[], resolvedReturnType: Type, typePredicate: TypePredicate, minArgumentCount: number, hasRestParameter: boolean, hasStringLiterals: boolean): Signature { - let sig = new Signature(checker); + const sig = new Signature(checker); sig.declaration = declaration; sig.typeParameters = typeParameters; sig.parameters = parameters; @@ -3273,16 +3273,16 @@ namespace ts { if (!hasClassBaseType(classType)) { return [createSignature(undefined, classType.localTypeParameters, emptyArray, classType, undefined, 0, false, false)]; } - let baseConstructorType = getBaseConstructorTypeOfClass(classType); - let baseSignatures = getSignaturesOfType(baseConstructorType, SignatureKind.Construct); - let baseTypeNode = getBaseTypeNodeOfClass(classType); - let typeArguments = map(baseTypeNode.typeArguments, getTypeFromTypeNode); - let typeArgCount = typeArguments ? typeArguments.length : 0; - let result: Signature[] = []; - for (let baseSig of baseSignatures) { - let typeParamCount = baseSig.typeParameters ? baseSig.typeParameters.length : 0; + const baseConstructorType = getBaseConstructorTypeOfClass(classType); + const baseSignatures = getSignaturesOfType(baseConstructorType, SignatureKind.Construct); + const baseTypeNode = getBaseTypeNodeOfClass(classType); + const typeArguments = map(baseTypeNode.typeArguments, getTypeFromTypeNode); + const typeArgCount = typeArguments ? typeArguments.length : 0; + const result: Signature[] = []; + for (const baseSig of baseSignatures) { + const typeParamCount = baseSig.typeParameters ? baseSig.typeParameters.length : 0; if (typeParamCount === typeArgCount) { - let sig = typeParamCount ? getSignatureInstantiation(baseSig, typeArguments) : cloneSignature(baseSig); + const sig = typeParamCount ? getSignatureInstantiation(baseSig, typeArguments) : cloneSignature(baseSig); sig.typeParameters = classType.localTypeParameters; sig.resolvedReturnType = classType; result.push(sig); @@ -3292,9 +3292,9 @@ namespace ts { } function createTupleTypeMemberSymbols(memberTypes: Type[]): SymbolTable { - let members: SymbolTable = {}; + const members: SymbolTable = {}; for (let i = 0; i < memberTypes.length; i++) { - let symbol = createSymbol(SymbolFlags.Property | SymbolFlags.Transient, "" + i); + const symbol = createSymbol(SymbolFlags.Property | SymbolFlags.Transient, "" + i); symbol.type = memberTypes[i]; members[i] = symbol; } @@ -3302,16 +3302,16 @@ namespace ts { } function resolveTupleTypeMembers(type: TupleType) { - let arrayElementType = getUnionType(type.elementTypes, /*noSubtypeReduction*/ true); + const arrayElementType = getUnionType(type.elementTypes, /*noSubtypeReduction*/ true); // Make the tuple type itself the 'this' type by including an extra type argument - let arrayType = resolveStructuredTypeMembers(createTypeFromGenericGlobalType(globalArrayType, [arrayElementType, type])); - let members = createTupleTypeMemberSymbols(type.elementTypes); + const arrayType = resolveStructuredTypeMembers(createTypeFromGenericGlobalType(globalArrayType, [arrayElementType, type])); + const members = createTupleTypeMemberSymbols(type.elementTypes); addInheritedMembers(members, arrayType.properties); setObjectTypeMembers(type, members, arrayType.callSignatures, arrayType.constructSignatures, arrayType.stringIndexType, arrayType.numberIndexType); } function findMatchingSignature(signatureList: Signature[], signature: Signature, partialMatch: boolean, ignoreReturnTypes: boolean): Signature { - for (let s of signatureList) { + for (const s of signatureList) { if (compareSignatures(s, signature, partialMatch, ignoreReturnTypes, compareTypes)) { return s; } @@ -3335,7 +3335,7 @@ namespace ts { let result: Signature[] = undefined; for (let i = 0; i < signatureLists.length; i++) { // Allow matching non-generic signatures to have excess parameters and different return types - let match = i === listIndex ? signature : findMatchingSignature(signatureLists[i], signature, /*partialMatch*/ true, /*ignoreReturnTypes*/ true); + const match = i === listIndex ? signature : findMatchingSignature(signatureLists[i], signature, /*partialMatch*/ true, /*ignoreReturnTypes*/ true); if (!match) { return undefined; } @@ -3351,13 +3351,13 @@ namespace ts { // parameters and may differ in return types. When signatures differ in return types, the resulting return // type is the union of the constituent return types. function getUnionSignatures(types: Type[], kind: SignatureKind): Signature[] { - let signatureLists = map(types, t => getSignaturesOfType(t, kind)); + const signatureLists = map(types, t => getSignaturesOfType(t, kind)); let result: Signature[] = undefined; for (let i = 0; i < signatureLists.length; i++) { - for (let signature of signatureLists[i]) { + for (const signature of signatureLists[i]) { // Only process signatures with parameter lists that aren't already in the result list if (!result || !findMatchingSignature(result, signature, /*partialMatch*/ false, /*ignoreReturnTypes*/ true)) { - let unionSignatures = findMatchingSignatures(signatureLists, signature, i); + const unionSignatures = findMatchingSignatures(signatureLists, signature, i); if (unionSignatures) { let s = signature; // Union the result types when more than one signature matches @@ -3376,9 +3376,9 @@ namespace ts { } function getUnionIndexType(types: Type[], kind: IndexKind): Type { - let indexTypes: Type[] = []; - for (let type of types) { - let indexType = getIndexTypeOfType(type, kind); + const indexTypes: Type[] = []; + for (const type of types) { + const indexType = getIndexTypeOfType(type, kind); if (!indexType) { return undefined; } @@ -3390,10 +3390,10 @@ namespace ts { function resolveUnionTypeMembers(type: UnionType) { // The members and properties collections are empty for union types. To get all properties of a union // type use getPropertiesOfType (only the language service uses this). - let callSignatures = getUnionSignatures(type.types, SignatureKind.Call); - let constructSignatures = getUnionSignatures(type.types, SignatureKind.Construct); - let stringIndexType = getUnionIndexType(type.types, IndexKind.String); - let numberIndexType = getUnionIndexType(type.types, IndexKind.Number); + const callSignatures = getUnionSignatures(type.types, SignatureKind.Call); + const constructSignatures = getUnionSignatures(type.types, SignatureKind.Construct); + const stringIndexType = getUnionIndexType(type.types, IndexKind.String); + const numberIndexType = getUnionIndexType(type.types, IndexKind.Number); setObjectTypeMembers(type, emptySymbols, callSignatures, constructSignatures, stringIndexType, numberIndexType); } @@ -3408,7 +3408,7 @@ namespace ts { let constructSignatures: Signature[] = emptyArray; let stringIndexType: Type = undefined; let numberIndexType: Type = undefined; - for (let t of type.types) { + for (const t of type.types) { callSignatures = concatenate(callSignatures, getSignaturesOfType(t, SignatureKind.Call)); constructSignatures = concatenate(constructSignatures, getSignaturesOfType(t, SignatureKind.Construct)); stringIndexType = intersectTypes(stringIndexType, getIndexTypeOfType(t, IndexKind.String)); @@ -3418,7 +3418,7 @@ namespace ts { } function resolveAnonymousTypeMembers(type: AnonymousType) { - let symbol = type.symbol; + const symbol = type.symbol; let members: SymbolTable; let callSignatures: Signature[]; let constructSignatures: Signature[]; @@ -3451,12 +3451,12 @@ namespace ts { callSignatures = getSignaturesOfSymbol(symbol); } if (symbol.flags & SymbolFlags.Class) { - let classType = getDeclaredTypeOfClassOrInterface(symbol); + const classType = getDeclaredTypeOfClassOrInterface(symbol); constructSignatures = getSignaturesOfSymbol(symbol.members["__constructor"]); if (!constructSignatures.length) { constructSignatures = getDefaultConstructSignatures(classType); } - let baseConstructorType = getBaseConstructorTypeOfClass(classType); + const baseConstructorType = getBaseConstructorTypeOfClass(classType); if (baseConstructorType.flags & TypeFlags.ObjectType) { members = createSymbolTable(getNamedMembers(members)); addInheritedMembers(members, getPropertiesOfObjectType(baseConstructorType)); @@ -3504,9 +3504,9 @@ namespace ts { // return the symbol for that property.Otherwise return undefined. function getPropertyOfObjectType(type: Type, name: string): Symbol { if (type.flags & TypeFlags.ObjectType) { - let resolved = resolveStructuredTypeMembers(type); + const resolved = resolveStructuredTypeMembers(type); if (hasProperty(resolved.members, name)) { - let symbol = resolved.members[name]; + const symbol = resolved.members[name]; if (symbolIsValue(symbol)) { return symbol; } @@ -3515,8 +3515,8 @@ namespace ts { } function getPropertiesOfUnionOrIntersectionType(type: UnionOrIntersectionType): Symbol[] { - for (let current of type.types) { - for (let prop of getPropertiesOfType(current)) { + for (const current of type.types) { + for (const prop of getPropertiesOfType(current)) { getPropertyOfUnionOrIntersectionType(type, prop.name); } // The properties of a union type are those that are present in all constituent types, so @@ -3563,12 +3563,12 @@ namespace ts { } function createUnionOrIntersectionProperty(containingType: UnionOrIntersectionType, name: string): Symbol { - let types = containingType.types; + const types = containingType.types; let props: Symbol[]; - for (let current of types) { - let type = getApparentType(current); + for (const current of types) { + const type = getApparentType(current); if (type !== unknownType) { - let prop = getPropertyOfType(type, name); + const prop = getPropertyOfType(type, name); if (prop && !(getDeclarationFlagsFromSymbol(prop) & (NodeFlags.Private | NodeFlags.Protected))) { if (!props) { props = [prop]; @@ -3589,15 +3589,15 @@ namespace ts { if (props.length === 1) { return props[0]; } - let propTypes: Type[] = []; - let declarations: Declaration[] = []; - for (let prop of props) { + const propTypes: Type[] = []; + const declarations: Declaration[] = []; + for (const prop of props) { if (prop.declarations) { addRange(declarations, prop.declarations); } propTypes.push(getTypeOfSymbol(prop)); } - let result = createSymbol(SymbolFlags.Property | SymbolFlags.Transient | SymbolFlags.SyntheticProperty, name); + const result = createSymbol(SymbolFlags.Property | SymbolFlags.Transient | SymbolFlags.SyntheticProperty, name); result.containingType = containingType; result.declarations = declarations; result.type = containingType.flags & TypeFlags.Union ? getUnionType(propTypes) : getIntersectionType(propTypes); @@ -3605,11 +3605,11 @@ namespace ts { } function getPropertyOfUnionOrIntersectionType(type: UnionOrIntersectionType, name: string): Symbol { - let properties = type.resolvedProperties || (type.resolvedProperties = {}); + const properties = type.resolvedProperties || (type.resolvedProperties = {}); if (hasProperty(properties, name)) { return properties[name]; } - let property = createUnionOrIntersectionProperty(type, name); + const property = createUnionOrIntersectionProperty(type, name); if (property) { properties[name] = property; } @@ -3622,15 +3622,15 @@ namespace ts { function getPropertyOfType(type: Type, name: string): Symbol { type = getApparentType(type); if (type.flags & TypeFlags.ObjectType) { - let resolved = resolveStructuredTypeMembers(type); + const resolved = resolveStructuredTypeMembers(type); if (hasProperty(resolved.members, name)) { - let symbol = resolved.members[name]; + const symbol = resolved.members[name]; if (symbolIsValue(symbol)) { return symbol; } } if (resolved === anyFunctionType || resolved.callSignatures.length || resolved.constructSignatures.length) { - let symbol = getPropertyOfObjectType(globalFunctionType, name); + const symbol = getPropertyOfObjectType(globalFunctionType, name); if (symbol) { return symbol; } @@ -3645,7 +3645,7 @@ namespace ts { function getSignaturesOfStructuredType(type: Type, kind: SignatureKind): Signature[] { if (type.flags & TypeFlags.StructuredType) { - let resolved = resolveStructuredTypeMembers(type); + const resolved = resolveStructuredTypeMembers(type); return kind === SignatureKind.Call ? resolved.callSignatures : resolved.constructSignatures; } return emptyArray; @@ -3660,18 +3660,18 @@ namespace ts { } function typeHasConstructSignatures(type: Type): boolean { - let apparentType = getApparentType(type); + const apparentType = getApparentType(type); if (apparentType.flags & (TypeFlags.ObjectType | TypeFlags.Union)) { - let resolved = resolveStructuredTypeMembers(type); + const resolved = resolveStructuredTypeMembers(type); return resolved.constructSignatures.length > 0; } return false; } function typeHasCallOrConstructSignatures(type: Type): boolean { - let apparentType = getApparentType(type); + const apparentType = getApparentType(type); if (apparentType.flags & TypeFlags.StructuredType) { - let resolved = resolveStructuredTypeMembers(type); + const resolved = resolveStructuredTypeMembers(type); return resolved.callSignatures.length > 0 || resolved.constructSignatures.length > 0; } return false; @@ -3679,7 +3679,7 @@ namespace ts { function getIndexTypeOfStructuredType(type: Type, kind: IndexKind): Type { if (type.flags & TypeFlags.StructuredType) { - let resolved = resolveStructuredTypeMembers(type); + const resolved = resolveStructuredTypeMembers(type); return kind === IndexKind.String ? resolved.stringIndexType : resolved.numberIndexType; } } @@ -3693,9 +3693,9 @@ namespace ts { // Return list of type parameters with duplicates removed (duplicate identifier errors are generated in the actual // type checking functions). function getTypeParametersFromDeclaration(typeParameterDeclarations: TypeParameterDeclaration[]): TypeParameter[] { - let result: TypeParameter[] = []; + const result: TypeParameter[] = []; forEach(typeParameterDeclarations, node => { - let tp = getDeclaredTypeOfTypeParameter(node.symbol); + const tp = getDeclaredTypeOfTypeParameter(node.symbol); if (!contains(result, tp)) { result.push(tp); } @@ -3704,8 +3704,8 @@ namespace ts { } function symbolsToArray(symbols: SymbolTable): Symbol[] { - let result: Symbol[] = []; - for (let id in symbols) { + const result: Symbol[] = []; + for (const id in symbols) { if (!isReservedMemberName(id)) { result.push(symbols[id]); } @@ -3719,9 +3719,9 @@ namespace ts { } if (node.initializer) { - let signatureDeclaration = node.parent; - let signature = getSignatureFromDeclaration(signatureDeclaration); - let parameterIndex = signatureDeclaration.parameters.indexOf(node); + const signatureDeclaration = node.parent; + const signature = getSignatureFromDeclaration(signatureDeclaration); + const parameterIndex = signatureDeclaration.parameters.indexOf(node); Debug.assert(parameterIndex >= 0); return parameterIndex >= signature.minArgumentCount; } @@ -3730,18 +3730,18 @@ namespace ts { } function getSignatureFromDeclaration(declaration: SignatureDeclaration): Signature { - let links = getNodeLinks(declaration); + const links = getNodeLinks(declaration); if (!links.resolvedSignature) { - let classType = declaration.kind === SyntaxKind.Constructor ? + const classType = declaration.kind === SyntaxKind.Constructor ? getDeclaredTypeOfClassOrInterface(getMergedSymbol((declaration.parent).symbol)) : undefined; - let typeParameters = classType ? classType.localTypeParameters : + const typeParameters = classType ? classType.localTypeParameters : declaration.typeParameters ? getTypeParametersFromDeclaration(declaration.typeParameters) : undefined; - let parameters: Symbol[] = []; + const parameters: Symbol[] = []; let hasStringLiterals = false; let minArgumentCount = -1; for (let i = 0, n = declaration.parameters.length; i < n; i++) { - let param = declaration.parameters[i]; + const param = declaration.parameters[i]; parameters.push(param.symbol); if (param.type && param.type.kind === SyntaxKind.StringLiteral) { hasStringLiterals = true; @@ -3770,7 +3770,7 @@ namespace ts { else if (declaration.type) { returnType = getTypeFromTypeNode(declaration.type); if (declaration.type.kind === SyntaxKind.TypePredicate) { - let typePredicateNode = declaration.type; + const typePredicateNode = declaration.type; typePredicate = { parameterName: typePredicateNode.parameterName ? typePredicateNode.parameterName.text : undefined, parameterIndex: typePredicateNode.parameterName ? getTypePredicateParameterIndex(declaration.parameters, typePredicateNode.parameterName) : undefined, @@ -3782,7 +3782,7 @@ namespace 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 === SyntaxKind.GetAccessor && !hasDynamicName(declaration)) { - let setter = getDeclarationOfKind(declaration.symbol, SyntaxKind.SetAccessor); + const setter = getDeclarationOfKind(declaration.symbol, SyntaxKind.SetAccessor); returnType = getAnnotatedAccessorType(setter); } @@ -3799,9 +3799,9 @@ namespace ts { function getSignaturesOfSymbol(symbol: Symbol): Signature[] { if (!symbol) return emptyArray; - let result: Signature[] = []; + const result: Signature[] = []; for (let i = 0, len = symbol.declarations.length; i < len; i++) { - let node = symbol.declarations[i]; + const node = symbol.declarations[i]; switch (node.kind) { case SyntaxKind.FunctionType: case SyntaxKind.ConstructorType: @@ -3820,7 +3820,7 @@ namespace ts { // an implementation node if it has a body and the previous node is of the same kind and immediately // precedes the implementation node (i.e. has the same parent and ends where the implementation starts). if (i > 0 && (node).body) { - let previous = symbol.declarations[i - 1]; + const previous = symbol.declarations[i - 1]; if (node.parent === previous.parent && node.kind === previous.kind && node.pos === previous.end) { break; } @@ -3849,7 +3849,7 @@ namespace ts { if (!popTypeResolution()) { type = anyType; if (compilerOptions.noImplicitAny) { - let declaration = signature.declaration; + const declaration = signature.declaration; if (declaration.name) { error(declaration.name, 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, declarationNameToString(declaration.name)); } @@ -3865,7 +3865,7 @@ namespace ts { function getRestTypeOfSignature(signature: Signature): Type { if (signature.hasRestParameter) { - let type = getTypeOfSymbol(lastOrUndefined(signature.parameters)); + const type = getTypeOfSymbol(lastOrUndefined(signature.parameters)); if (type.flags & TypeFlags.Reference && (type).target === globalArrayType) { return (type).typeArguments[0]; } @@ -3896,8 +3896,8 @@ namespace 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) { - let isConstructor = signature.declaration.kind === SyntaxKind.Constructor || signature.declaration.kind === SyntaxKind.ConstructSignature; - let type = createObjectType(TypeFlags.Anonymous | TypeFlags.FromSignature); + const isConstructor = signature.declaration.kind === SyntaxKind.Constructor || signature.declaration.kind === SyntaxKind.ConstructSignature; + const type = createObjectType(TypeFlags.Anonymous | TypeFlags.FromSignature); type.members = emptySymbols; type.properties = emptyArray; type.callSignatures = !isConstructor ? [signature] : emptyArray; @@ -3913,13 +3913,13 @@ namespace ts { } function getIndexDeclarationOfSymbol(symbol: Symbol, kind: IndexKind): SignatureDeclaration { - let syntaxKind = kind === IndexKind.Number ? SyntaxKind.NumberKeyword : SyntaxKind.StringKeyword; - let indexSymbol = getIndexSymbol(symbol); + const syntaxKind = kind === IndexKind.Number ? SyntaxKind.NumberKeyword : SyntaxKind.StringKeyword; + const indexSymbol = getIndexSymbol(symbol); if (indexSymbol) { - for (let decl of indexSymbol.declarations) { - let node = decl; + for (const decl of indexSymbol.declarations) { + const node = decl; if (node.parameters.length === 1) { - let parameter = node.parameters[0]; + const parameter = node.parameters[0]; if (parameter && parameter.type && parameter.type.kind === syntaxKind) { return node; } @@ -3931,7 +3931,7 @@ namespace ts { } function getIndexTypeOfSymbol(symbol: Symbol, kind: IndexKind): Type { - let declaration = getIndexDeclarationOfSymbol(symbol, kind); + const declaration = getIndexDeclarationOfSymbol(symbol, kind); return declaration ? declaration.type ? getTypeFromTypeNode(declaration.type) : anyType : undefined; @@ -3940,7 +3940,7 @@ namespace ts { function getConstraintOfTypeParameter(type: TypeParameter): Type { if (!type.constraint) { if (type.target) { - let targetConstraint = getConstraintOfTypeParameter(type.target); + const targetConstraint = getConstraintOfTypeParameter(type.target); type.constraint = targetConstraint ? instantiateType(targetConstraint, type.mapper) : noConstraintType; } else { @@ -3981,17 +3981,17 @@ namespace ts { // that care about the presence of such types at arbitrary depth in a containing type. function getPropagatingFlagsOfTypes(types: Type[]): TypeFlags { let result: TypeFlags = 0; - for (let type of types) { + for (const type of types) { result |= type.flags; } return result & TypeFlags.PropagatingFlags; } function createTypeReference(target: GenericType, typeArguments: Type[]): TypeReference { - let id = getTypeListId(typeArguments); + const id = getTypeListId(typeArguments); let type = target.instantiations[id]; if (!type) { - let flags = TypeFlags.Reference | (typeArguments ? getPropagatingFlagsOfTypes(typeArguments) : 0); + const flags = TypeFlags.Reference | (typeArguments ? getPropagatingFlagsOfTypes(typeArguments) : 0); type = target.instantiations[id] = createObjectType(flags, target.symbol); type.target = target; type.typeArguments = typeArguments; @@ -4000,7 +4000,7 @@ namespace ts { } function isTypeParameterReferenceIllegalInConstraint(typeReferenceNode: TypeReferenceNode | ExpressionWithTypeArguments, typeParameterSymbol: Symbol): boolean { - let links = getNodeLinks(typeReferenceNode); + const links = getNodeLinks(typeReferenceNode); if (links.isIllegalTypeReferenceInConstraint !== undefined) { return links.isIllegalTypeReferenceInConstraint; } @@ -4020,9 +4020,9 @@ namespace ts { let typeParameterSymbol: Symbol; function check(n: Node): void { if (n.kind === SyntaxKind.TypeReference && (n).typeName.kind === SyntaxKind.Identifier) { - let links = getNodeLinks(n); + const links = getNodeLinks(n); if (links.isIllegalTypeReferenceInConstraint === undefined) { - let symbol = resolveName(typeParameter, ((n).typeName).text, SymbolFlags.Type, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined); + const symbol = resolveName(typeParameter, ((n).typeName).text, SymbolFlags.Type, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined); if (symbol && (symbol.flags & SymbolFlags.TypeParameter)) { // TypeScript 1.0 spec (April 2014): 3.4.1 // Type parameters declared in a particular type parameter list @@ -4050,8 +4050,8 @@ namespace ts { // Get type from reference to class or interface function getTypeFromClassOrInterfaceReference(node: TypeReferenceNode | ExpressionWithTypeArguments, symbol: Symbol): Type { - let type = getDeclaredTypeOfSymbol(symbol); - let typeParameters = type.localTypeParameters; + const type = getDeclaredTypeOfSymbol(symbol); + 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); @@ -4073,16 +4073,16 @@ namespace ts { // references to the type parameters of the alias. We replace those with the actual type arguments by instantiating the // declared type. Instantiations are cached using the type identities of the type arguments as the key. function getTypeFromTypeAliasReference(node: TypeReferenceNode | ExpressionWithTypeArguments, symbol: Symbol): Type { - let type = getDeclaredTypeOfSymbol(symbol); - let links = getSymbolLinks(symbol); - let typeParameters = links.typeParameters; + const type = getDeclaredTypeOfSymbol(symbol); + const links = getSymbolLinks(symbol); + 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); return unknownType; } - let typeArguments = map(node.typeArguments, getTypeFromTypeNode); - let id = getTypeListId(typeArguments); + const typeArguments = map(node.typeArguments, getTypeFromTypeNode); + const id = getTypeListId(typeArguments); return links.instantiations[id] || (links.instantiations[id] = instantiateType(type, createTypeMapper(typeParameters, typeArguments))); } if (node.typeArguments) { @@ -4109,14 +4109,14 @@ namespace ts { } function getTypeFromTypeReference(node: TypeReferenceNode | ExpressionWithTypeArguments): Type { - let links = getNodeLinks(node); + const links = getNodeLinks(node); if (!links.resolvedType) { // We only support expressions that are simple qualified names. For other expressions this produces undefined. - let typeNameOrExpression = node.kind === SyntaxKind.TypeReference ? (node).typeName : + const typeNameOrExpression = node.kind === SyntaxKind.TypeReference ? (node).typeName : isSupportedExpressionWithTypeArguments(node) ? (node).expression : undefined; - let symbol = typeNameOrExpression && resolveEntityName(typeNameOrExpression, SymbolFlags.Type) || unknownSymbol; - let type = symbol === unknownSymbol ? unknownType : + const symbol = typeNameOrExpression && resolveEntityName(typeNameOrExpression, SymbolFlags.Type) || unknownSymbol; + const type = symbol === unknownSymbol ? unknownType : symbol.flags & (SymbolFlags.Class | SymbolFlags.Interface) ? getTypeFromClassOrInterfaceReference(node, symbol) : symbol.flags & SymbolFlags.TypeAlias ? getTypeFromTypeAliasReference(node, symbol) : getTypeFromNonGenericTypeReference(node, symbol); @@ -4129,7 +4129,7 @@ namespace ts { } function getTypeFromTypeQueryNode(node: TypeQueryNode): Type { - let links = getNodeLinks(node); + const links = getNodeLinks(node); if (!links.resolvedType) { // TypeScript 1.0 spec (April 2014): 3.6.3 // The expression is processed as an identifier expression (section 4.3) @@ -4143,8 +4143,8 @@ namespace ts { function getTypeOfGlobalSymbol(symbol: Symbol, arity: number): ObjectType { function getTypeDeclaration(symbol: Symbol): Declaration { - let declarations = symbol.declarations; - for (let declaration of declarations) { + const declarations = symbol.declarations; + for (const declaration of declarations) { switch (declaration.kind) { case SyntaxKind.ClassDeclaration: case SyntaxKind.InterfaceDeclaration: @@ -4157,7 +4157,7 @@ namespace ts { if (!symbol) { return arity ? emptyGenericType : emptyObjectType; } - let type = getDeclaredTypeOfSymbol(symbol); + const type = getDeclaredTypeOfSymbol(symbol); if (!(type.flags & TypeFlags.ObjectType)) { error(getTypeDeclaration(symbol), Diagnostics.Global_type_0_must_be_a_class_or_interface_type, symbol.name); return arity ? emptyGenericType : emptyObjectType; @@ -4194,8 +4194,8 @@ namespace ts { * getExportedTypeFromNamespace('JSX', 'Element') returns the JSX.Element type */ function getExportedTypeFromNamespace(namespace: string, name: string): Type { - let namespaceSymbol = getGlobalSymbol(namespace, SymbolFlags.Namespace, /*diagnosticMessage*/ undefined); - let typeSymbol = namespaceSymbol && getSymbol(namespaceSymbol.exports, name, SymbolFlags.Type); + const namespaceSymbol = getGlobalSymbol(namespace, SymbolFlags.Namespace, /*diagnosticMessage*/ undefined); + const typeSymbol = namespaceSymbol && getSymbol(namespaceSymbol.exports, name, SymbolFlags.Type); return typeSymbol && getDeclaredTypeOfSymbol(typeSymbol); } @@ -4207,7 +4207,7 @@ namespace ts { * Creates a TypeReference for a generic `TypedPropertyDescriptor`. */ function createTypedPropertyDescriptorType(propertyType: Type): Type { - let globalTypedPropertyDescriptorType = getGlobalTypedPropertyDescriptorType(); + const globalTypedPropertyDescriptorType = getGlobalTypedPropertyDescriptorType(); return globalTypedPropertyDescriptorType !== emptyGenericType ? createTypeReference(globalTypedPropertyDescriptorType, [propertyType]) : emptyObjectType; @@ -4233,7 +4233,7 @@ namespace ts { } function getTypeFromArrayTypeNode(node: ArrayTypeNode): Type { - let links = getNodeLinks(node); + const links = getNodeLinks(node); if (!links.resolvedType) { links.resolvedType = createArrayType(getTypeFromTypeNode(node.elementType)); } @@ -4241,18 +4241,18 @@ namespace ts { } function createTupleType(elementTypes: Type[]) { - let id = getTypeListId(elementTypes); + const id = getTypeListId(elementTypes); return tupleTypes[id] || (tupleTypes[id] = createNewTupleType(elementTypes)); } function createNewTupleType(elementTypes: Type[]) { - let type = createObjectType(TypeFlags.Tuple | getPropagatingFlagsOfTypes(elementTypes)); + const type = createObjectType(TypeFlags.Tuple | getPropagatingFlagsOfTypes(elementTypes)); type.elementTypes = elementTypes; return type; } function getTypeFromTupleTypeNode(node: TupleTypeNode): Type { - let links = getNodeLinks(node); + const links = getNodeLinks(node); if (!links.resolvedType) { links.resolvedType = createTupleType(map(node.elementTypes, getTypeFromTypeNode)); } @@ -4271,7 +4271,7 @@ namespace ts { // Add the given types to the given type set. Order is preserved, duplicates are removed, // and nested types of the given kind are flattened into the set. function addTypesToSet(typeSet: Type[], types: Type[], typeSetKind: TypeFlags) { - for (let type of types) { + for (const type of types) { addTypeToSet(typeSet, type, typeSetKind); } } @@ -4296,7 +4296,7 @@ namespace ts { } function containsTypeAny(types: Type[]): boolean { - for (let type of types) { + for (const type of types) { if (isTypeAny(type)) { return true; } @@ -4325,7 +4325,7 @@ namespace ts { if (types.length === 0) { return emptyObjectType; } - let typeSet: Type[] = []; + const typeSet: Type[] = []; addTypesToSet(typeSet, types, TypeFlags.Union); if (containsTypeAny(typeSet)) { return anyType; @@ -4340,7 +4340,7 @@ namespace ts { if (typeSet.length === 1) { return typeSet[0]; } - let id = getTypeListId(typeSet); + const id = getTypeListId(typeSet); let type = unionTypes[id]; if (!type) { type = unionTypes[id] = createObjectType(TypeFlags.Union | getPropagatingFlagsOfTypes(typeSet)); @@ -4350,7 +4350,7 @@ namespace ts { } function getTypeFromUnionTypeNode(node: UnionTypeNode): Type { - let links = getNodeLinks(node); + const links = getNodeLinks(node); if (!links.resolvedType) { links.resolvedType = getUnionType(map(node.types, getTypeFromTypeNode), /*noSubtypeReduction*/ true); } @@ -4366,7 +4366,7 @@ namespace ts { if (types.length === 0) { return emptyObjectType; } - let typeSet: Type[] = []; + const typeSet: Type[] = []; addTypesToSet(typeSet, types, TypeFlags.Intersection); if (containsTypeAny(typeSet)) { return anyType; @@ -4374,7 +4374,7 @@ namespace ts { if (typeSet.length === 1) { return typeSet[0]; } - let id = getTypeListId(typeSet); + const id = getTypeListId(typeSet); let type = intersectionTypes[id]; if (!type) { type = intersectionTypes[id] = createObjectType(TypeFlags.Intersection | getPropagatingFlagsOfTypes(typeSet)); @@ -4384,7 +4384,7 @@ namespace ts { } function getTypeFromIntersectionTypeNode(node: IntersectionTypeNode): Type { - let links = getNodeLinks(node); + const links = getNodeLinks(node); if (!links.resolvedType) { links.resolvedType = getIntersectionType(map(node.types, getTypeFromTypeNode)); } @@ -4392,7 +4392,7 @@ namespace ts { } function getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node: Node): Type { - let links = getNodeLinks(node); + const links = getNodeLinks(node); if (!links.resolvedType) { // Deferred resolution of members is handled by resolveObjectTypeMembers links.resolvedType = createObjectType(TypeFlags.Anonymous, node.symbol); @@ -4405,13 +4405,13 @@ namespace ts { return stringLiteralTypes[node.text]; } - let type = stringLiteralTypes[node.text] = createType(TypeFlags.StringLiteral); + const type = stringLiteralTypes[node.text] = createType(TypeFlags.StringLiteral); type.text = getTextOfNode(node); return type; } function getTypeFromStringLiteral(node: StringLiteral): Type { - let links = getNodeLinks(node); + const links = getNodeLinks(node); if (!links.resolvedType) { links.resolvedType = getStringLiteralType(node); } @@ -4419,8 +4419,8 @@ namespace ts { } function getThisType(node: TypeNode): Type { - let container = getThisContainer(node, /*includeArrowFunctions*/ false); - let parent = container && container.parent; + const container = getThisContainer(node, /*includeArrowFunctions*/ false); + const parent = container && container.parent; if (parent && (isClassLike(parent) || parent.kind === SyntaxKind.InterfaceDeclaration)) { if (!(container.flags & NodeFlags.Static) && (container.kind !== SyntaxKind.Constructor || isNodeDescendentOf(node, (container).body))) { @@ -4432,7 +4432,7 @@ namespace ts { } function getTypeFromThisTypeNode(node: TypeNode): Type { - let links = getNodeLinks(node); + const links = getNodeLinks(node); if (!links.resolvedType) { links.resolvedType = getThisType(node); } @@ -4483,7 +4483,7 @@ namespace ts { // Callers should first ensure this by calling isTypeNode case SyntaxKind.Identifier: case SyntaxKind.QualifiedName: - let symbol = getSymbolAtLocation(node); + const symbol = getSymbolAtLocation(node); return symbol && getDeclaredTypeOfSymbol(symbol); default: return unknownType; @@ -4492,8 +4492,8 @@ namespace ts { function instantiateList(items: T[], mapper: TypeMapper, instantiator: (item: T, mapper: TypeMapper) => T): T[] { if (items && items.length) { - let result: T[] = []; - for (let v of items) { + const result: T[] = []; + for (const v of items) { result.push(instantiator(v, mapper)); } return result; @@ -4538,7 +4538,7 @@ namespace ts { case 2: return createBinaryTypeEraser(sources[0], sources[1]); } return t => { - for (let source of sources) { + for (const source of sources) { if (t === source) { return anyType; } @@ -4548,7 +4548,7 @@ namespace ts { } function createInferenceMapper(context: InferenceContext): TypeMapper { - let mapper: TypeMapper = t => { + const mapper: TypeMapper = t => { for (let i = 0; i < context.typeParameters.length; i++) { if (t === context.typeParameters[i]) { context.inferences[i].isFixed = true; @@ -4571,7 +4571,7 @@ namespace ts { } function instantiateTypeParameter(typeParameter: TypeParameter, mapper: TypeMapper): TypeParameter { - let result = createType(TypeFlags.TypeParameter); + const result = createType(TypeFlags.TypeParameter); result.symbol = typeParameter.symbol; if (typeParameter.constraint) { result.constraint = instantiateType(typeParameter.constraint, mapper); @@ -4597,7 +4597,7 @@ namespace ts { type: instantiateType(signature.typePredicate.type, mapper) }; } - let result = createSignature(signature.declaration, freshTypeParameters, + const result = createSignature(signature.declaration, freshTypeParameters, instantiateList(signature.parameters, mapper, instantiateSymbol), instantiateType(signature.resolvedReturnType, mapper), freshTypePredicate, @@ -4609,7 +4609,7 @@ namespace ts { function instantiateSymbol(symbol: Symbol, mapper: TypeMapper): Symbol { if (symbol.flags & SymbolFlags.Instantiated) { - let links = getSymbolLinks(symbol); + const links = getSymbolLinks(symbol); // If symbol being instantiated is itself a instantiation, fetch the original target and combine the // type mappers. This ensures that original type identities are properly preserved and that aliases // always reference a non-aliases. @@ -4619,7 +4619,7 @@ namespace ts { // Keep the flags from the symbol we're instantiating. Mark that is instantiated, and // also transient so that we can just store data on it directly. - let result = createSymbol(SymbolFlags.Instantiated | SymbolFlags.Transient | symbol.flags, symbol.name); + const result = createSymbol(SymbolFlags.Instantiated | SymbolFlags.Transient | symbol.flags, symbol.name); result.declarations = symbol.declarations; result.parent = symbol.parent; result.target = symbol; @@ -4633,7 +4633,7 @@ namespace ts { function instantiateAnonymousType(type: AnonymousType, mapper: TypeMapper): ObjectType { if (mapper.instantiations) { - let cachedType = mapper.instantiations[type.id]; + const cachedType = mapper.instantiations[type.id]; if (cachedType) { return cachedType; } @@ -4642,7 +4642,7 @@ namespace ts { mapper.instantiations = []; } // Mark the anonymous type as instantiated such that our infinite instantiation detection logic can recognize it - let result = createObjectType(TypeFlags.Anonymous | TypeFlags.Instantiated, type.symbol); + const result = createObjectType(TypeFlags.Anonymous | TypeFlags.Instantiated, type.symbol); result.target = type; result.mapper = mapper; mapper.instantiations[type.id] = result; @@ -4710,9 +4710,9 @@ namespace ts { function getTypeWithoutSignatures(type: Type): Type { if (type.flags & TypeFlags.ObjectType) { - let resolved = resolveStructuredTypeMembers(type); + const resolved = resolveStructuredTypeMembers(type); if (resolved.constructSignatures.length) { - let result = createObjectType(TypeFlags.Anonymous, type.symbol); + const result = createObjectType(TypeFlags.Anonymous, type.symbol); result.members = resolved.members; result.properties = resolved.properties; result.callSignatures = emptyArray; @@ -4750,8 +4750,8 @@ namespace ts { } function isSignatureAssignableTo(source: Signature, target: Signature): boolean { - let sourceType = getOrCreateTypeFromSignature(source); - let targetType = getOrCreateTypeFromSignature(target); + const sourceType = getOrCreateTypeFromSignature(source); + const targetType = getOrCreateTypeFromSignature(target); return checkTypeRelatedTo(sourceType, targetType, assignableRelation, /*errorNode*/ undefined); } @@ -4784,7 +4784,7 @@ namespace ts { Debug.assert(relation !== identityRelation || !errorNode, "no error reporting in identity checking"); - let result = isRelatedTo(source, target, errorNode !== undefined, headMessage); + const result = isRelatedTo(source, target, errorNode !== undefined, headMessage); if (overflow) { error(errorNode, Diagnostics.Excessive_stack_depth_comparing_types_0_and_1, typeToString(source), typeToString(target)); } @@ -4858,7 +4858,7 @@ namespace ts { } } - let saveErrorInfo = errorInfo; + const saveErrorInfo = errorInfo; // Note that the "each" checks must precede the "some" checks to produce the correct results if (source.flags & TypeFlags.Union) { @@ -4894,7 +4894,7 @@ namespace ts { constraint = emptyObjectType; } // Report constraint errors only if the constraint is not the empty object type - let reportConstraintErrors = reportErrors && constraint !== emptyObjectType; + const reportConstraintErrors = reportErrors && constraint !== emptyObjectType; if (result = isRelatedTo(constraint, target, reportConstraintErrors)) { errorInfo = saveErrorInfo; return result; @@ -4909,13 +4909,13 @@ namespace ts { } // Even if relationship doesn't hold for unions, intersections, or generic type references, // it may hold in a structural comparison. - let apparentType = getApparentType(source); + const apparentType = getApparentType(source); // 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 (apparentType.flags & (TypeFlags.ObjectType | TypeFlags.Intersection) && target.flags & TypeFlags.ObjectType) { // Report structural errors only if we haven't reported any errors yet - let reportStructuralErrors = reportErrors && errorInfo === saveErrorInfo; + const reportStructuralErrors = reportErrors && errorInfo === saveErrorInfo; if (result = objectTypeRelatedTo(apparentType, source, target, reportStructuralErrors)) { errorInfo = saveErrorInfo; return result; @@ -4967,7 +4967,7 @@ namespace ts { } } else if (type.flags & TypeFlags.UnionOrIntersection) { - for (let t of (type).types) { + for (const t of (type).types) { if (isKnownProperty(t, name)) { return true; } @@ -4978,7 +4978,7 @@ namespace ts { function hasExcessProperties(source: FreshObjectLiteralType, target: Type, reportErrors: boolean): boolean { if (someConstituentTypeHasKind(target, TypeFlags.ObjectType)) { - for (let prop of getPropertiesOfObjectType(source)) { + for (const prop of getPropertiesOfObjectType(source)) { if (!isKnownProperty(target, prop.name)) { if (reportErrors) { // We know *exactly* where things went wrong when comparing the types. @@ -4997,9 +4997,9 @@ namespace ts { function eachTypeRelatedToSomeType(source: UnionOrIntersectionType, target: UnionOrIntersectionType): Ternary { let result = Ternary.True; - let sourceTypes = source.types; - for (let sourceType of sourceTypes) { - let related = typeRelatedToSomeType(sourceType, target, false); + const sourceTypes = source.types; + for (const sourceType of sourceTypes) { + const related = typeRelatedToSomeType(sourceType, target, false); if (!related) { return Ternary.False; } @@ -5009,9 +5009,9 @@ namespace ts { } function typeRelatedToSomeType(source: Type, target: UnionOrIntersectionType, reportErrors: boolean): Ternary { - let targetTypes = target.types; + const targetTypes = target.types; for (let i = 0, len = targetTypes.length; i < len; i++) { - let related = isRelatedTo(source, targetTypes[i], reportErrors && i === len - 1); + const related = isRelatedTo(source, targetTypes[i], reportErrors && i === len - 1); if (related) { return related; } @@ -5021,9 +5021,9 @@ namespace ts { function typeRelatedToEachType(source: Type, target: UnionOrIntersectionType, reportErrors: boolean): Ternary { let result = Ternary.True; - let targetTypes = target.types; - for (let targetType of targetTypes) { - let related = isRelatedTo(source, targetType, reportErrors); + const targetTypes = target.types; + for (const targetType of targetTypes) { + const related = isRelatedTo(source, targetType, reportErrors); if (!related) { return Ternary.False; } @@ -5033,9 +5033,9 @@ namespace ts { } function someTypeRelatedToType(source: UnionOrIntersectionType, target: Type, reportErrors: boolean): Ternary { - let sourceTypes = source.types; + const sourceTypes = source.types; for (let i = 0, len = sourceTypes.length; i < len; i++) { - let related = isRelatedTo(sourceTypes[i], target, reportErrors && i === len - 1); + const related = isRelatedTo(sourceTypes[i], target, reportErrors && i === len - 1); if (related) { return related; } @@ -5045,9 +5045,9 @@ namespace ts { function eachTypeRelatedToType(source: UnionOrIntersectionType, target: Type, reportErrors: boolean): Ternary { let result = Ternary.True; - let sourceTypes = source.types; - for (let sourceType of sourceTypes) { - let related = isRelatedTo(sourceType, target, reportErrors); + const sourceTypes = source.types; + for (const sourceType of sourceTypes) { + const related = isRelatedTo(sourceType, target, reportErrors); if (!related) { return Ternary.False; } @@ -5057,14 +5057,14 @@ namespace ts { } function typeArgumentsRelatedTo(source: TypeReference, target: TypeReference, reportErrors: boolean): Ternary { - let sources = source.typeArguments || emptyArray; - let targets = target.typeArguments || emptyArray; + const sources = source.typeArguments || emptyArray; + const targets = target.typeArguments || emptyArray; if (sources.length !== targets.length && relation === identityRelation) { return Ternary.False; } let result = Ternary.True; for (let i = 0; i < targets.length; i++) { - let related = isRelatedTo(sources[i], targets[i], reportErrors); + const related = isRelatedTo(sources[i], targets[i], reportErrors); if (!related) { return Ternary.False; } @@ -5096,8 +5096,8 @@ namespace ts { if (overflow) { return Ternary.False; } - let id = relation !== identityRelation || apparentSource.id < target.id ? apparentSource.id + "," + target.id : target.id + "," + apparentSource.id; - let related = relation[id]; + const id = relation !== identityRelation || apparentSource.id < target.id ? apparentSource.id + "," + target.id : target.id + "," + apparentSource.id; + const related = relation[id]; if (related !== undefined) { // If we computed this relation already and it was failed and reported, or if we're not being asked to elaborate // errors, we can use the cached value. Otherwise, recompute the relation @@ -5128,7 +5128,7 @@ namespace ts { maybeStack[depth] = {}; maybeStack[depth][id] = RelationComparisonResult.Succeeded; depth++; - let saveExpandingFlags = expandingFlags; + const saveExpandingFlags = expandingFlags; if (!(expandingFlags & 1) && isDeeplyNestedGeneric(apparentSource, sourceStack, depth)) expandingFlags |= 1; if (!(expandingFlags & 2) && isDeeplyNestedGeneric(target, targetStack, depth)) expandingFlags |= 2; let result: Ternary; @@ -5153,9 +5153,9 @@ namespace ts { expandingFlags = saveExpandingFlags; depth--; if (result) { - let maybeCache = maybeStack[depth]; + const maybeCache = maybeStack[depth]; // If result is definitely true, copy assumptions to global cache, else copy to next level up - let destinationCache = (result === Ternary.True || depth === 0) ? relation : maybeStack[depth - 1]; + const destinationCache = (result === Ternary.True || depth === 0) ? relation : maybeStack[depth - 1]; copyMap(maybeCache, destinationCache); } else { @@ -5171,10 +5171,10 @@ namespace ts { return propertiesIdenticalTo(source, target); } let result = Ternary.True; - let properties = getPropertiesOfObjectType(target); - let requireOptionalProperties = relation === subtypeRelation && !(source.flags & TypeFlags.ObjectLiteral); - for (let targetProp of properties) { - let sourceProp = getPropertyOfType(source, targetProp.name); + const properties = getPropertiesOfObjectType(target); + const requireOptionalProperties = relation === subtypeRelation && !(source.flags & TypeFlags.ObjectLiteral); + for (const targetProp of properties) { + const sourceProp = getPropertyOfType(source, targetProp.name); if (sourceProp !== targetProp) { if (!sourceProp) { @@ -5186,8 +5186,8 @@ namespace ts { } } else if (!(targetProp.flags & SymbolFlags.Prototype)) { - let sourcePropFlags = getDeclarationFlagsFromSymbol(sourceProp); - let targetPropFlags = getDeclarationFlagsFromSymbol(targetProp); + const sourcePropFlags = getDeclarationFlagsFromSymbol(sourceProp); + const targetPropFlags = getDeclarationFlagsFromSymbol(targetProp); if (sourcePropFlags & NodeFlags.Private || targetPropFlags & NodeFlags.Private) { if (sourceProp.valueDeclaration !== targetProp.valueDeclaration) { if (reportErrors) { @@ -5204,9 +5204,9 @@ namespace ts { } } else if (targetPropFlags & NodeFlags.Protected) { - let sourceDeclaredInClass = sourceProp.parent && sourceProp.parent.flags & SymbolFlags.Class; - let sourceClass = sourceDeclaredInClass ? getDeclaredTypeOfSymbol(sourceProp.parent) : undefined; - let targetClass = getDeclaredTypeOfSymbol(targetProp.parent); + const sourceDeclaredInClass = sourceProp.parent && sourceProp.parent.flags & SymbolFlags.Class; + const sourceClass = sourceDeclaredInClass ? getDeclaredTypeOfSymbol(sourceProp.parent) : undefined; + const targetClass = getDeclaredTypeOfSymbol(targetProp.parent); if (!sourceClass || !hasBaseType(sourceClass, targetClass)) { if (reportErrors) { reportError(Diagnostics.Property_0_is_protected_but_type_1_is_not_a_class_derived_from_2, @@ -5222,7 +5222,7 @@ namespace ts { } return Ternary.False; } - let related = isRelatedTo(getTypeOfSymbol(sourceProp), getTypeOfSymbol(targetProp), reportErrors); + const related = isRelatedTo(getTypeOfSymbol(sourceProp), getTypeOfSymbol(targetProp), reportErrors); if (!related) { if (reportErrors) { reportError(Diagnostics.Types_of_property_0_are_incompatible, symbolToString(targetProp)); @@ -5254,18 +5254,18 @@ namespace ts { if (!(source.flags & TypeFlags.ObjectType && target.flags & TypeFlags.ObjectType)) { return Ternary.False; } - let sourceProperties = getPropertiesOfObjectType(source); - let targetProperties = getPropertiesOfObjectType(target); + const sourceProperties = getPropertiesOfObjectType(source); + const targetProperties = getPropertiesOfObjectType(target); if (sourceProperties.length !== targetProperties.length) { return Ternary.False; } let result = Ternary.True; - for (let sourceProp of sourceProperties) { - let targetProp = getPropertyOfObjectType(target, sourceProp.name); + for (const sourceProp of sourceProperties) { + const targetProp = getPropertyOfObjectType(target, sourceProp.name); if (!targetProp) { return Ternary.False; } - let related = compareProperties(sourceProp, targetProp, isRelatedTo); + const related = compareProperties(sourceProp, targetProp, isRelatedTo); if (!related) { return Ternary.False; } @@ -5281,10 +5281,10 @@ namespace ts { if (target === anyFunctionType || source === anyFunctionType) { return Ternary.True; } - let sourceSignatures = getSignaturesOfType(source, kind); - let targetSignatures = getSignaturesOfType(target, kind); + const sourceSignatures = getSignaturesOfType(source, kind); + const targetSignatures = getSignaturesOfType(target, kind); let result = Ternary.True; - let saveErrorInfo = errorInfo; + const saveErrorInfo = errorInfo; @@ -5298,8 +5298,8 @@ namespace ts { // sourceSig and targetSig are (possibly) undefined. // // Note that in an extends-clause, targetSignatures is stripped, so the check never proceeds. - let sourceSig = sourceSignatures[0]; - let targetSig = targetSignatures[0]; + const sourceSig = sourceSignatures[0]; + const targetSig = targetSignatures[0]; result &= abstractSignatureRelatedTo(source, sourceSig, target, targetSig); if (result !== Ternary.True) { @@ -5307,13 +5307,13 @@ namespace ts { } } - outer: for (let t of targetSignatures) { + outer: for (const t of targetSignatures) { if (!t.hasStringLiterals || target.flags & TypeFlags.FromSignature) { let localErrors = reportErrors; - let checkedAbstractAssignability = false; - for (let s of sourceSignatures) { + const checkedAbstractAssignability = false; + for (const s of sourceSignatures) { if (!s.hasStringLiterals || source.flags & TypeFlags.FromSignature) { - let related = signatureRelatedTo(s, t, localErrors); + const related = signatureRelatedTo(s, t, localErrors); if (related) { result &= related; errorInfo = saveErrorInfo; @@ -5331,8 +5331,8 @@ namespace ts { function abstractSignatureRelatedTo(source: Type, sourceSig: Signature, target: Type, targetSig: Signature) { if (sourceSig && targetSig) { - let sourceDecl = source.symbol && getClassLikeDeclarationOfSymbol(source.symbol); - let targetDecl = target.symbol && getClassLikeDeclarationOfSymbol(target.symbol); + const sourceDecl = source.symbol && getClassLikeDeclarationOfSymbol(source.symbol); + const targetDecl = target.symbol && getClassLikeDeclarationOfSymbol(target.symbol); if (!sourceDecl) { // If the source object isn't itself a class declaration, it can be freely assigned, regardless @@ -5340,16 +5340,16 @@ namespace ts { return Ternary.True; } - let sourceErasedSignature = getErasedSignature(sourceSig); - let targetErasedSignature = getErasedSignature(targetSig); + const sourceErasedSignature = getErasedSignature(sourceSig); + const targetErasedSignature = getErasedSignature(targetSig); - let sourceReturnType = sourceErasedSignature && getReturnTypeOfSignature(sourceErasedSignature); - let targetReturnType = targetErasedSignature && getReturnTypeOfSignature(targetErasedSignature); + const sourceReturnType = sourceErasedSignature && getReturnTypeOfSignature(sourceErasedSignature); + const targetReturnType = targetErasedSignature && getReturnTypeOfSignature(targetErasedSignature); - let sourceReturnDecl = sourceReturnType && sourceReturnType.symbol && getClassLikeDeclarationOfSymbol(sourceReturnType.symbol); - let targetReturnDecl = targetReturnType && targetReturnType.symbol && getClassLikeDeclarationOfSymbol(targetReturnType.symbol); - let sourceIsAbstract = sourceReturnDecl && sourceReturnDecl.flags & NodeFlags.Abstract; - let targetIsAbstract = targetReturnDecl && targetReturnDecl.flags & NodeFlags.Abstract; + const sourceReturnDecl = sourceReturnType && sourceReturnType.symbol && getClassLikeDeclarationOfSymbol(sourceReturnType.symbol); + const targetReturnDecl = targetReturnType && targetReturnType.symbol && getClassLikeDeclarationOfSymbol(targetReturnType.symbol); + const sourceIsAbstract = sourceReturnDecl && sourceReturnDecl.flags & NodeFlags.Abstract; + const targetIsAbstract = targetReturnDecl && targetReturnDecl.flags & NodeFlags.Abstract; if (sourceIsAbstract && !(targetIsAbstract && targetDecl)) { // if target isn't a class-declaration type, then it can be new'd, so we forbid the assignment. @@ -5395,9 +5395,9 @@ namespace ts { target = getErasedSignature(target); let result = Ternary.True; for (let i = 0; i < checkCount; i++) { - let s = i < sourceMax ? getTypeOfSymbol(source.parameters[i]) : getRestTypeOfSignature(source); - let t = i < targetMax ? getTypeOfSymbol(target.parameters[i]) : getRestTypeOfSignature(target); - let saveErrorInfo = errorInfo; + const s = i < sourceMax ? getTypeOfSymbol(source.parameters[i]) : getRestTypeOfSignature(source); + const t = i < targetMax ? getTypeOfSymbol(target.parameters[i]) : getRestTypeOfSignature(target); + const saveErrorInfo = errorInfo; let related = isRelatedTo(s, t, reportErrors); if (!related) { related = isRelatedTo(t, s, false); @@ -5415,16 +5415,16 @@ namespace ts { } if (source.typePredicate && target.typePredicate) { - let hasDifferentParameterIndex = source.typePredicate.parameterIndex !== target.typePredicate.parameterIndex; + const hasDifferentParameterIndex = source.typePredicate.parameterIndex !== target.typePredicate.parameterIndex; let hasDifferentTypes: boolean; if (hasDifferentParameterIndex || (hasDifferentTypes = !isTypeIdenticalTo(source.typePredicate.type, target.typePredicate.type))) { if (reportErrors) { - let sourceParamText = source.typePredicate.parameterName; - let targetParamText = target.typePredicate.parameterName; - let sourceTypeText = typeToString(source.typePredicate.type); - let targetTypeText = typeToString(target.typePredicate.type); + const sourceParamText = source.typePredicate.parameterName; + const targetParamText = target.typePredicate.parameterName; + const sourceTypeText = typeToString(source.typePredicate.type); + const targetTypeText = typeToString(target.typePredicate.type); if (hasDifferentParameterIndex) { reportError(Diagnostics.Parameter_0_is_not_in_the_same_position_as_parameter_1, @@ -5451,22 +5451,22 @@ namespace ts { return Ternary.False; } - let targetReturnType = getReturnTypeOfSignature(target); + const targetReturnType = getReturnTypeOfSignature(target); if (targetReturnType === voidType) return result; - let sourceReturnType = getReturnTypeOfSignature(source); + const sourceReturnType = getReturnTypeOfSignature(source); return result & isRelatedTo(sourceReturnType, targetReturnType, reportErrors); } function signaturesIdenticalTo(source: Type, target: Type, kind: SignatureKind): Ternary { - let sourceSignatures = getSignaturesOfType(source, kind); - let targetSignatures = getSignaturesOfType(target, kind); + const sourceSignatures = getSignaturesOfType(source, kind); + const targetSignatures = getSignaturesOfType(target, kind); if (sourceSignatures.length !== targetSignatures.length) { return Ternary.False; } let result = Ternary.True; for (let i = 0, len = sourceSignatures.length; i < len; ++i) { - let related = compareSignatures(sourceSignatures[i], targetSignatures[i], /*partialMatch*/ false, /*ignoreReturnTypes*/ false, isRelatedTo); + const related = compareSignatures(sourceSignatures[i], targetSignatures[i], /*partialMatch*/ false, /*ignoreReturnTypes*/ false, isRelatedTo); if (!related) { return Ternary.False; } @@ -5479,21 +5479,21 @@ namespace ts { if (relation === identityRelation) { return indexTypesIdenticalTo(IndexKind.String, source, target); } - let targetType = getIndexTypeOfType(target, IndexKind.String); + const targetType = getIndexTypeOfType(target, IndexKind.String); if (targetType) { if ((targetType.flags & TypeFlags.Any) && !(originalSource.flags & TypeFlags.Primitive)) { // non-primitive assignment to any is always allowed, eg // `var x: { [index: string]: any } = { property: 12 };` return Ternary.True; } - let sourceType = getIndexTypeOfType(source, IndexKind.String); + const sourceType = getIndexTypeOfType(source, IndexKind.String); if (!sourceType) { if (reportErrors) { reportError(Diagnostics.Index_signature_is_missing_in_type_0, typeToString(source)); } return Ternary.False; } - let related = isRelatedTo(sourceType, targetType, reportErrors); + const related = isRelatedTo(sourceType, targetType, reportErrors); if (!related) { if (reportErrors) { reportError(Diagnostics.Index_signatures_are_incompatible); @@ -5509,15 +5509,15 @@ namespace ts { if (relation === identityRelation) { return indexTypesIdenticalTo(IndexKind.Number, source, target); } - let targetType = getIndexTypeOfType(target, IndexKind.Number); + const targetType = getIndexTypeOfType(target, IndexKind.Number); if (targetType) { if ((targetType.flags & TypeFlags.Any) && !(originalSource.flags & TypeFlags.Primitive)) { // non-primitive assignment to any is always allowed, eg // `var x: { [index: number]: any } = { property: 12 };` return Ternary.True; } - let sourceStringType = getIndexTypeOfType(source, IndexKind.String); - let sourceNumberType = getIndexTypeOfType(source, IndexKind.Number); + const sourceStringType = getIndexTypeOfType(source, IndexKind.String); + const sourceNumberType = getIndexTypeOfType(source, IndexKind.Number); if (!(sourceStringType || sourceNumberType)) { if (reportErrors) { reportError(Diagnostics.Index_signature_is_missing_in_type_0, typeToString(source)); @@ -5544,8 +5544,8 @@ namespace ts { } function indexTypesIdenticalTo(indexKind: IndexKind, source: Type, target: Type): Ternary { - let targetType = getIndexTypeOfType(target, indexKind); - let sourceType = getIndexTypeOfType(source, indexKind); + const targetType = getIndexTypeOfType(target, indexKind); + const sourceType = getIndexTypeOfType(source, indexKind); if (!sourceType && !targetType) { return Ternary.True; } @@ -5564,10 +5564,10 @@ namespace ts { 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) { - let symbol = type.symbol; + const symbol = type.symbol; let count = 0; for (let i = 0; i < depth; i++) { - let t = stack[i]; + const t = stack[i]; if (t.flags & (TypeFlags.Reference | TypeFlags.Instantiated) && t.symbol === symbol) { count++; if (count >= 5) return true; @@ -5588,8 +5588,8 @@ namespace ts { if (sourceProp === targetProp) { return Ternary.True; } - let sourcePropAccessibility = getDeclarationFlagsFromSymbol(sourceProp) & (NodeFlags.Private | NodeFlags.Protected); - let targetPropAccessibility = getDeclarationFlagsFromSymbol(targetProp) & (NodeFlags.Private | NodeFlags.Protected); + const sourcePropAccessibility = getDeclarationFlagsFromSymbol(sourceProp) & (NodeFlags.Private | NodeFlags.Protected); + const targetPropAccessibility = getDeclarationFlagsFromSymbol(targetProp) & (NodeFlags.Private | NodeFlags.Protected); if (sourcePropAccessibility !== targetPropAccessibility) { return Ternary.False; } @@ -5625,7 +5625,7 @@ namespace ts { return Ternary.False; } for (let i = 0, len = source.typeParameters.length; i < len; ++i) { - let related = compareTypes(source.typeParameters[i], target.typeParameters[i]); + const related = compareTypes(source.typeParameters[i], target.typeParameters[i]); if (!related) { return Ternary.False; } @@ -5639,11 +5639,11 @@ namespace ts { // M and N (the signatures) are instantiated using type Any as the type argument for all type parameters declared by M and N source = getErasedSignature(source); target = getErasedSignature(target); - let targetLen = target.parameters.length; + const targetLen = target.parameters.length; for (let i = 0; i < targetLen; i++) { - let s = isRestParameterIndex(source, i) ? getRestTypeOfSignature(source) : getTypeOfSymbol(source.parameters[i]); - let t = isRestParameterIndex(target, i) ? getRestTypeOfSignature(target) : getTypeOfSymbol(target.parameters[i]); - let related = compareTypes(s, t); + const s = isRestParameterIndex(source, i) ? getRestTypeOfSignature(source) : getTypeOfSymbol(source.parameters[i]); + const t = isRestParameterIndex(target, i) ? getRestTypeOfSignature(target) : getTypeOfSymbol(target.parameters[i]); + const related = compareTypes(s, t); if (!related) { return Ternary.False; } @@ -5660,7 +5660,7 @@ namespace ts { } function isSupertypeOfEach(candidate: Type, types: Type[]): boolean { - for (let type of types) { + for (const type of types) { if (candidate !== type && !isTypeSubtypeOf(type, candidate)) return false; } return true; @@ -5752,13 +5752,13 @@ namespace ts { } function getWidenedTypeOfObjectLiteral(type: Type): Type { - let properties = getPropertiesOfObjectType(type); - let members: SymbolTable = {}; + const properties = getPropertiesOfObjectType(type); + const members: SymbolTable = {}; forEach(properties, p => { - let propType = getTypeOfSymbol(p); - let widenedType = getWidenedType(propType); + const propType = getTypeOfSymbol(p); + const widenedType = getWidenedType(propType); if (propType !== widenedType) { - let symbol = createSymbol(p.flags | SymbolFlags.Transient, p.name); + const symbol = createSymbol(p.flags | SymbolFlags.Transient, p.name); symbol.declarations = p.declarations; symbol.parent = p.parent; symbol.type = widenedType; @@ -5810,7 +5810,7 @@ namespace ts { function reportWideningErrorsInType(type: Type): boolean { let errorReported = false; if (type.flags & TypeFlags.Union) { - for (let t of (type).types) { + for (const t of (type).types) { if (reportWideningErrorsInType(t)) { errorReported = true; } @@ -5820,15 +5820,15 @@ namespace ts { return reportWideningErrorsInType((type).typeArguments[0]); } if (isTupleType(type)) { - for (let t of type.elementTypes) { + for (const t of type.elementTypes) { if (reportWideningErrorsInType(t)) { errorReported = true; } } } if (type.flags & TypeFlags.ObjectLiteral) { - for (let p of getPropertiesOfObjectType(type)) { - let t = getTypeOfSymbol(p); + for (const p of getPropertiesOfObjectType(type)) { + const t = getTypeOfSymbol(p); if (t.flags & TypeFlags.ContainsUndefinedOrNull) { if (!reportWideningErrorsInType(t)) { error(p.valueDeclaration, Diagnostics.Object_literal_s_property_0_implicitly_has_an_1_type, p.name, typeToString(getWidenedType(t))); @@ -5841,7 +5841,7 @@ namespace ts { } function reportImplicitAnyError(declaration: Declaration, type: Type) { - let typeAsString = typeToString(getWidenedType(type)); + const typeAsString = typeToString(getWidenedType(type)); let diagnostic: DiagnosticMessage; switch (declaration.kind) { case SyntaxKind.PropertyDeclaration: @@ -5902,15 +5902,15 @@ namespace ts { count = sourceMax < targetMax ? sourceMax : targetMax; } for (let i = 0; i < count; i++) { - let s = i < sourceMax ? getTypeOfSymbol(source.parameters[i]) : getRestTypeOfSignature(source); - let t = i < targetMax ? getTypeOfSymbol(target.parameters[i]) : getRestTypeOfSignature(target); + const s = i < sourceMax ? getTypeOfSymbol(source.parameters[i]) : getRestTypeOfSignature(source); + const t = i < targetMax ? getTypeOfSymbol(target.parameters[i]) : getRestTypeOfSignature(target); callback(s, t); } } function createInferenceContext(typeParameters: TypeParameter[], inferUnionTypes: boolean): InferenceContext { - let inferences: TypeInferences[] = []; - for (let unused of typeParameters) { + const inferences: TypeInferences[] = []; + for (const unused of typeParameters) { inferences.push({ primary: undefined, secondary: undefined, isFixed: false }); @@ -5951,10 +5951,10 @@ namespace ts { return; } - let typeParameters = context.typeParameters; + const typeParameters = context.typeParameters; for (let i = 0; i < typeParameters.length; i++) { if (target === typeParameters[i]) { - let inferences = context.inferences[i]; + const inferences = context.inferences[i]; if (!inferences.isFixed) { // Any inferences that are made to a type parameter in a union type are inferior // to inferences made to a flat (non-union) type. This is because if we infer to @@ -5962,7 +5962,7 @@ namespace ts { // the correct constituent on the target side could be string[]). Therefore, we put // such inferior inferences into a secondary bucket, and only use them if the primary // bucket is empty. - let candidates = inferiority ? + const candidates = inferiority ? inferences.secondary || (inferences.secondary = []) : inferences.primary || (inferences.primary = []); if (!contains(candidates, source)) { @@ -5975,27 +5975,27 @@ namespace ts { } else if (source.flags & TypeFlags.Reference && target.flags & TypeFlags.Reference && (source).target === (target).target) { // If source and target are references to the same generic type, infer from type arguments - let sourceTypes = (source).typeArguments || emptyArray; - let targetTypes = (target).typeArguments || emptyArray; - let count = sourceTypes.length < targetTypes.length ? sourceTypes.length : targetTypes.length; + const sourceTypes = (source).typeArguments || emptyArray; + const targetTypes = (target).typeArguments || emptyArray; + const count = sourceTypes.length < targetTypes.length ? sourceTypes.length : targetTypes.length; for (let i = 0; i < count; i++) { inferFromTypes(sourceTypes[i], targetTypes[i]); } } else if (source.flags & TypeFlags.Tuple && target.flags & TypeFlags.Tuple && (source).elementTypes.length === (target).elementTypes.length) { // If source and target are tuples of the same size, infer from element types - let sourceTypes = (source).elementTypes; - let targetTypes = (target).elementTypes; + const sourceTypes = (source).elementTypes; + const targetTypes = (target).elementTypes; for (let i = 0; i < sourceTypes.length; i++) { inferFromTypes(sourceTypes[i], targetTypes[i]); } } else if (target.flags & TypeFlags.UnionOrIntersection) { - let targetTypes = (target).types; + const targetTypes = (target).types; let typeParameterCount = 0; let typeParameter: TypeParameter; // First infer to each type in union or intersection that isn't a type parameter - for (let t of targetTypes) { + for (const t of targetTypes) { if (t.flags & TypeFlags.TypeParameter && contains(context.typeParameters, t)) { typeParameter = t; typeParameterCount++; @@ -6016,8 +6016,8 @@ namespace ts { } else if (source.flags & TypeFlags.UnionOrIntersection) { // Source is a union or intersection type, infer from each consituent type - let sourceTypes = (source).types; - for (let sourceType of sourceTypes) { + const sourceTypes = (source).types; + for (const sourceType of sourceTypes) { inferFromTypes(sourceType, target); } } @@ -6052,9 +6052,9 @@ namespace ts { } function inferFromProperties(source: Type, target: Type) { - let properties = getPropertiesOfObjectType(target); - for (let targetProp of properties) { - let sourceProp = getPropertyOfObjectType(source, targetProp.name); + const properties = getPropertiesOfObjectType(target); + for (const targetProp of properties) { + const sourceProp = getPropertyOfObjectType(source, targetProp.name); if (sourceProp) { inferFromTypes(getTypeOfSymbol(sourceProp), getTypeOfSymbol(targetProp)); } @@ -6062,11 +6062,11 @@ namespace ts { } function inferFromSignatures(source: Type, target: Type, kind: SignatureKind) { - let sourceSignatures = getSignaturesOfType(source, kind); - let targetSignatures = getSignaturesOfType(target, kind); - let sourceLen = sourceSignatures.length; - let targetLen = targetSignatures.length; - let len = sourceLen < targetLen ? sourceLen : targetLen; + const sourceSignatures = getSignaturesOfType(source, kind); + const targetSignatures = getSignaturesOfType(target, kind); + const sourceLen = sourceSignatures.length; + const targetLen = targetSignatures.length; + const len = sourceLen < targetLen ? sourceLen : targetLen; for (let i = 0; i < len; i++) { inferFromSignature(getErasedSignature(sourceSignatures[sourceLen - len + i]), getErasedSignature(targetSignatures[targetLen - len + i])); } @@ -6088,9 +6088,9 @@ namespace ts { } function inferFromIndexTypes(source: Type, target: Type, sourceKind: IndexKind, targetKind: IndexKind) { - let targetIndexType = getIndexTypeOfType(target, targetKind); + const targetIndexType = getIndexTypeOfType(target, targetKind); if (targetIndexType) { - let sourceIndexType = getIndexTypeOfType(source, sourceKind); + const sourceIndexType = getIndexTypeOfType(source, sourceKind); if (sourceIndexType) { inferFromTypes(sourceIndexType, targetIndexType); } @@ -6099,7 +6099,7 @@ namespace ts { } function getInferenceCandidates(context: InferenceContext, index: number): Type[] { - let inferences = context.inferences[index]; + const inferences = context.inferences[index]; return inferences.primary || inferences.secondary || emptyArray; } @@ -6107,10 +6107,10 @@ namespace ts { let inferredType = context.inferredTypes[index]; let inferenceSucceeded: boolean; if (!inferredType) { - let inferences = getInferenceCandidates(context, index); + const inferences = getInferenceCandidates(context, index); if (inferences.length) { // Infer widened union or supertype, or the unknown type for no common supertype - let unionOrSuperType = context.inferUnionTypes ? getUnionType(inferences) : getCommonSupertype(inferences); + const unionOrSuperType = context.inferUnionTypes ? getUnionType(inferences) : getCommonSupertype(inferences); inferredType = unionOrSuperType ? getWidenedType(unionOrSuperType) : unknownType; inferenceSucceeded = !!unionOrSuperType; } @@ -6125,7 +6125,7 @@ namespace ts { // Only do the constraint check if inference succeeded (to prevent cascading errors) if (inferenceSucceeded) { - let constraint = getConstraintOfTypeParameter(context.typeParameters[index]); + const constraint = getConstraintOfTypeParameter(context.typeParameters[index]); inferredType = constraint && !isTypeAssignableTo(inferredType, constraint) ? constraint : inferredType; } else if (context.failedTypeParameterIndex === undefined || context.failedTypeParameterIndex > index) { @@ -6154,7 +6154,7 @@ namespace ts { // EXPRESSION TYPE CHECKING function getResolvedSymbol(node: Identifier): Symbol { - let links = getNodeLinks(node); + const links = getNodeLinks(node); if (!links.resolvedSymbol) { links.resolvedSymbol = (!nodeIsMissing(node) && resolveName(node, node.text, SymbolFlags.Value | SymbolFlags.ExportValue, Diagnostics.Cannot_find_name_0, node)) || unknownSymbol; } @@ -6184,10 +6184,10 @@ namespace ts { // or not of the given type kind (when isOfTypeKind is false) function removeTypesFromUnionType(type: Type, typeKind: TypeFlags, isOfTypeKind: boolean, allowEmptyUnionResult: boolean): Type { if (type.flags & TypeFlags.Union) { - let types = (type).types; + const types = (type).types; if (forEach(types, t => !!(t.flags & typeKind) === isOfTypeKind)) { // Above we checked if we have anything to remove, now use the opposite test to do the removal - let narrowedType = getUnionType(filter(types, t => !(t.flags & typeKind) === isOfTypeKind)); + const narrowedType = getUnionType(filter(types, t => !(t.flags & typeKind) === isOfTypeKind)); if (allowEmptyUnionResult || narrowedType !== emptyObjectType) { return narrowedType; } @@ -6207,9 +6207,9 @@ namespace ts { // Check if a given variable is assigned within a given syntax node function isVariableAssignedWithin(symbol: Symbol, node: Node): boolean { - let links = getNodeLinks(node); + const links = getNodeLinks(node); if (links.assignmentChecks) { - let cachedResult = links.assignmentChecks[symbol.id]; + const cachedResult = links.assignmentChecks[symbol.id]; if (cachedResult !== undefined) { return cachedResult; } @@ -6303,7 +6303,7 @@ namespace ts { if (node && symbol.flags & SymbolFlags.Variable) { if (isTypeAny(type) || type.flags & (TypeFlags.ObjectType | TypeFlags.Union | TypeFlags.TypeParameter)) { loop: while (node.parent) { - let child = node; + const child = node; node = node.parent; let narrowedType = type; switch (node.kind) { @@ -6359,12 +6359,12 @@ namespace ts { if (expr.left.kind !== SyntaxKind.TypeOfExpression || expr.right.kind !== SyntaxKind.StringLiteral) { return type; } - let left = expr.left; - let right = expr.right; + const left = expr.left; + const right = expr.right; if (left.expression.kind !== SyntaxKind.Identifier || getResolvedSymbol(left.expression) !== symbol) { return type; } - let typeInfo = primitiveTypeInfo[right.text]; + const typeInfo = primitiveTypeInfo[right.text]; if (expr.operatorToken.kind === SyntaxKind.ExclamationEqualsEqualsToken) { assumeTrue = !assumeTrue; } @@ -6428,16 +6428,16 @@ namespace ts { return type; } // Check that right operand is a function type with a prototype property - let rightType = checkExpression(expr.right); + const rightType = checkExpression(expr.right); if (!isTypeSubtypeOf(rightType, globalFunctionType)) { return type; } let targetType: Type; - let prototypeProperty = getPropertyOfType(rightType, "prototype"); + const prototypeProperty = getPropertyOfType(rightType, "prototype"); if (prototypeProperty) { // Target type is type of the prototype property - let prototypePropertyType = getTypeOfSymbol(prototypeProperty); + const prototypePropertyType = getTypeOfSymbol(prototypeProperty); if (!isTypeAny(prototypePropertyType)) { targetType = prototypePropertyType; } @@ -6468,7 +6468,7 @@ namespace ts { // If the current type is a union type, remove all constituents that aren't assignable to target. If that produces // 0 candidates, fall back to the assignability check if (originalType.flags & TypeFlags.Union) { - let assignableConstituents = filter((originalType).types, t => isTypeAssignableTo(t, narrowedTypeCandidate)); + const assignableConstituents = filter((originalType).types, t => isTypeAssignableTo(t, narrowedTypeCandidate)); if (assignableConstituents.length) { return getUnionType(assignableConstituents); } @@ -6486,7 +6486,7 @@ namespace ts { if (type.flags & TypeFlags.Any) { return type; } - let signature = getResolvedSignature(expr); + const signature = getResolvedSignature(expr); if (signature.typePredicate && expr.arguments[signature.typePredicate.parameterIndex] && @@ -6512,7 +6512,7 @@ namespace ts { case SyntaxKind.ParenthesizedExpression: return narrowType(type, (expr).expression, assumeTrue); case SyntaxKind.BinaryExpression: - let operator = (expr).operatorToken.kind; + const operator = (expr).operatorToken.kind; if (operator === SyntaxKind.EqualsEqualsEqualsToken || operator === SyntaxKind.ExclamationEqualsEqualsToken) { return narrowTypeByEquality(type, expr, assumeTrue); } @@ -6537,7 +6537,7 @@ namespace ts { } function checkIdentifier(node: Identifier): Type { - let symbol = getResolvedSymbol(node); + const symbol = getResolvedSymbol(node); // As noted in ECMAScript 6 language spec, arrow functions never have an arguments objects. // Although in down-level emit of arrow function, we emit it using function expression which means that @@ -6546,7 +6546,7 @@ namespace ts { // To avoid that we will give an error to users if they use arguments objects in arrow function so that they // can explicitly bound arguments objects if (symbol === argumentsSymbol) { - let container = getContainingFunction(node); + const container = getContainingFunction(node); if (container.kind === SyntaxKind.ArrowFunction) { if (languageVersion < ScriptTarget.ES6) { error(node, Diagnostics.The_arguments_object_cannot_be_referenced_in_an_arrow_function_in_ES3_and_ES5_Consider_using_a_standard_function_expression); @@ -6614,7 +6614,7 @@ namespace ts { } } - let inFunction = isInsideFunction(node.parent, container); + const inFunction = isInsideFunction(node.parent, container); let current = container; while (current && !nodeStartsNewLexicalEnvironment(current)) { @@ -6633,7 +6633,7 @@ namespace ts { function captureLexicalThis(node: Node, container: Node): void { getNodeLinks(node).flags |= NodeCheckFlags.LexicalThis; if (container.kind === SyntaxKind.PropertyDeclaration || container.kind === SyntaxKind.Constructor) { - let classNode = container.parent; + const classNode = container.parent; getNodeLinks(classNode).flags |= NodeCheckFlags.CaptureThis; } else { @@ -6687,7 +6687,7 @@ namespace ts { } if (isClassLike(container.parent)) { - let symbol = getSymbolOfNode(container.parent); + const symbol = getSymbolOfNode(container.parent); return container.flags & NodeFlags.Static ? getTypeOfSymbol(symbol) : (getDeclaredTypeOfSymbol(symbol)).thisType; } return anyType; @@ -6703,10 +6703,10 @@ namespace ts { } function checkSuperExpression(node: Node): Type { - let isCallExpression = node.parent.kind === SyntaxKind.CallExpression && (node.parent).expression === node; - let classDeclaration = getContainingClass(node); - let classType = classDeclaration && getDeclaredTypeOfSymbol(getSymbolOfNode(classDeclaration)); - let baseClassType = classType && getBaseTypes(classType)[0]; + const isCallExpression = node.parent.kind === SyntaxKind.CallExpression && (node.parent).expression === node; + const classDeclaration = getContainingClass(node); + const classType = classDeclaration && getDeclaredTypeOfSymbol(getSymbolOfNode(classDeclaration)); + const baseClassType = classType && getBaseTypes(classType)[0]; let container = getSuperContainer(node, /*includeFunctions*/ true); let needToCaptureLexicalThis = false; @@ -6719,7 +6719,7 @@ namespace ts { } } - let canUseSuperExpression = isLegalUsageOfSuperExpression(container); + const canUseSuperExpression = isLegalUsageOfSuperExpression(container); let nodeCheckFlag: NodeCheckFlags = 0; // always set NodeCheckFlags for 'super' expression node @@ -6814,15 +6814,15 @@ namespace ts { // Return contextual type of parameter or undefined if no contextual type is available function getContextuallyTypedParameterType(parameter: ParameterDeclaration): Type { - let func = parameter.parent; + const func = parameter.parent; if (isFunctionExpressionOrArrowFunction(func) || isObjectLiteralMethod(func)) { if (isContextSensitive(func)) { - let contextualSignature = getContextualSignature(func); + const contextualSignature = getContextualSignature(func); if (contextualSignature) { - let funcHasRestParameters = hasRestParameter(func); - let len = func.parameters.length - (funcHasRestParameters ? 1 : 0); - let indexOfParameter = indexOf(func.parameters, parameter); + const funcHasRestParameters = hasRestParameter(func); + const len = func.parameters.length - (funcHasRestParameters ? 1 : 0); + const indexOfParameter = indexOf(func.parameters, parameter); if (indexOfParameter < len) { return getTypeAtPosition(contextualSignature, indexOfParameter); } @@ -6845,13 +6845,13 @@ namespace ts { // of the parameter. Otherwise, in a variable or parameter declaration with a binding pattern name, the contextual // type of an initializer expression is the type implied by the binding pattern. function getContextualTypeForInitializerExpression(node: Expression): Type { - let declaration = node.parent; + const declaration = node.parent; if (node === declaration.initializer) { if (declaration.type) { return getTypeFromTypeNode(declaration.type); } if (declaration.kind === SyntaxKind.Parameter) { - let type = getContextuallyTypedParameterType(declaration); + const type = getContextuallyTypedParameterType(declaration); if (type) { return type; } @@ -6864,7 +6864,7 @@ namespace ts { } function getContextualTypeForReturnExpression(node: Expression): Type { - let func = getContainingFunction(node); + const func = getContainingFunction(node); if (func && !func.asteriskToken) { return getContextualReturnType(func); } @@ -6873,9 +6873,9 @@ namespace ts { } function getContextualTypeForYieldOperand(node: YieldExpression): Type { - let func = getContainingFunction(node); + const func = getContainingFunction(node); if (func) { - let contextualReturnType = getContextualReturnType(func); + const contextualReturnType = getContextualReturnType(func); if (contextualReturnType) { return node.asteriskToken ? contextualReturnType @@ -6909,7 +6909,7 @@ namespace ts { // Otherwise, if the containing function is contextually typed by a function type with exactly one call signature // and that call signature is non-generic, return statements are contextually typed by the return type of the signature - let signature = getContextualSignatureForFunctionLikeDeclaration(functionDecl); + const signature = getContextualSignatureForFunctionLikeDeclaration(functionDecl); if (signature) { return getReturnTypeOfSignature(signature); } @@ -6919,10 +6919,10 @@ namespace ts { // In a typed function call, an argument or substitution expression is contextually typed by the type of the corresponding parameter. function getContextualTypeForArgument(callTarget: CallLikeExpression, arg: Expression): Type { - let args = getEffectiveCallArguments(callTarget); - let argIndex = indexOf(args, arg); + const args = getEffectiveCallArguments(callTarget); + const argIndex = indexOf(args, arg); if (argIndex >= 0) { - let signature = getResolvedSignature(callTarget); + const signature = getResolvedSignature(callTarget); return getTypeAtPosition(signature, argIndex); } return undefined; @@ -6937,8 +6937,8 @@ namespace ts { } function getContextualTypeForBinaryOperand(node: Expression): Type { - let binaryExpression = node.parent; - let operator = binaryExpression.operatorToken.kind; + const binaryExpression = node.parent; + const operator = binaryExpression.operatorToken.kind; if (operator >= SyntaxKind.FirstAssignment && operator <= SyntaxKind.LastAssignment) { // In an assignment expression, the right operand is contextually typed by the type of the left operand. if (node === binaryExpression.right) { @@ -6964,11 +6964,11 @@ namespace ts { if (!(type.flags & TypeFlags.Union)) { return mapper(type); } - let types = (type).types; + const types = (type).types; let mappedType: Type; let mappedTypes: Type[]; - for (let current of types) { - let t = mapper(current); + for (const current of types) { + const t = mapper(current); if (t) { if (!mappedType) { mappedType = t; @@ -6986,7 +6986,7 @@ namespace ts { function getTypeOfPropertyOfContextualType(type: Type, name: string) { return applyToContextualType(type, t => { - let prop = t.flags & TypeFlags.StructuredType ? getPropertyOfType(t, name) : undefined; + const prop = t.flags & TypeFlags.StructuredType ? getPropertyOfType(t, name) : undefined; return prop ? getTypeOfSymbol(prop) : undefined; }); } @@ -7019,15 +7019,15 @@ namespace ts { } function getContextualTypeForObjectLiteralElement(element: ObjectLiteralElement) { - let objectLiteral = element.parent; - let type = getContextualType(objectLiteral); + const objectLiteral = element.parent; + const type = getContextualType(objectLiteral); if (type) { if (!hasDynamicName(element)) { // For a (non-symbol) computed property, there is no reason to look up the name // in the type. It will just be "__computed", which does not appear in any // SymbolTable. - let symbolName = getSymbolOfNode(element).name; - let propertyType = getTypeOfPropertyOfContextualType(type, symbolName); + const symbolName = getSymbolOfNode(element).name; + const propertyType = getTypeOfPropertyOfContextualType(type, symbolName); if (propertyType) { return propertyType; } @@ -7045,10 +7045,10 @@ namespace ts { // it is the type of the numeric index signature in T. Otherwise, in ES6 and higher, the contextual type is the iterated // type of T. function getContextualTypeForElementExpression(node: Expression): Type { - let arrayLiteral = node.parent; - let type = getContextualType(arrayLiteral); + const arrayLiteral = node.parent; + const type = getContextualType(arrayLiteral); if (type) { - let index = indexOf(arrayLiteral.elements, node); + const index = indexOf(arrayLiteral.elements, node); return getTypeOfPropertyOfContextualType(type, "" + index) || getIndexTypeOfContextualType(type, IndexKind.Number) || (languageVersion >= ScriptTarget.ES6 ? getElementTypeOfIterable(type, /*errorNode*/ undefined) : undefined); @@ -7058,15 +7058,15 @@ namespace ts { // In a contextually typed conditional expression, the true/false expressions are contextually typed by the same type. function getContextualTypeForConditionalOperand(node: Expression): Type { - let conditional = node.parent; + const conditional = node.parent; return node === conditional.whenTrue || node === conditional.whenFalse ? getContextualType(conditional) : undefined; } function getContextualTypeForJsxExpression(expr: JsxExpression | JsxSpreadAttribute): Type { // Contextual type only applies to JSX expressions that are in attribute assignments (not in 'Children' positions) if (expr.parent.kind === SyntaxKind.JsxAttribute) { - let attrib = expr.parent; - let attrsType = getJsxElementAttributesType(attrib.parent); + const attrib = expr.parent; + const attrsType = getJsxElementAttributesType(attrib.parent); if (!attrsType || isTypeAny(attrsType)) { return undefined; } @@ -7085,7 +7085,7 @@ namespace ts { // Return the contextual type for a given expression node. During overload resolution, a contextual type may temporarily // be "pushed" onto a node using the contextualType property. function getContextualType(node: Expression): Type { - let type = getContextualTypeWorker(node); + const type = getContextualTypeWorker(node); return type && getApparentType(type); } @@ -7097,7 +7097,7 @@ namespace ts { if (node.contextualType) { return node.contextualType; } - let parent = node.parent; + const parent = node.parent; switch (parent.kind) { case SyntaxKind.VariableDeclaration: case SyntaxKind.Parameter: @@ -7139,9 +7139,9 @@ namespace ts { // If the given type is an object or union type, if that type has a single signature, and if // that signature is non-generic, return the signature. Otherwise return undefined. function getNonGenericSignature(type: Type): Signature { - let signatures = getSignaturesOfStructuredType(type, SignatureKind.Call); + const signatures = getSignaturesOfStructuredType(type, SignatureKind.Call); if (signatures.length === 1) { - let signature = signatures[0]; + const signature = signatures[0]; if (!signature.typeParameters) { return signature; } @@ -7166,7 +7166,7 @@ namespace ts { // union type of return types from these signatures function getContextualSignature(node: FunctionExpression | MethodDeclaration): Signature { Debug.assert(node.kind !== SyntaxKind.MethodDeclaration || isObjectLiteralMethod(node)); - let type = isObjectLiteralMethod(node) + const type = isObjectLiteralMethod(node) ? getContextualTypeForObjectLiteralMethod(node) : getContextualType(node); if (!type) { @@ -7176,9 +7176,9 @@ namespace ts { return getNonGenericSignature(type); } let signatureList: Signature[]; - let types = (type).types; - for (let current of types) { - let signature = getNonGenericSignature(current); + const types = (type).types; + for (const current of types) { + const signature = getNonGenericSignature(current); if (signature) { if (!signatureList) { // This signature will contribute to contextual union signature @@ -7229,7 +7229,7 @@ namespace 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: Node): boolean { - let parent = node.parent; + const parent = node.parent; if (parent.kind === SyntaxKind.BinaryExpression && (parent).operatorToken.kind === SyntaxKind.EqualsToken && (parent).left === node) { return true; } @@ -7249,7 +7249,7 @@ namespace ts { // with this type. It is neither affected by it, nor does it propagate it to its operand. // So the fact that contextualMapper is passed is not important, because the operand of a spread // element is not contextually typed. - let arrayOrIterableType = checkExpressionCached(node.expression, contextualMapper); + const arrayOrIterableType = checkExpressionCached(node.expression, contextualMapper); return checkIteratedTypeOrElementType(arrayOrIterableType, node.expression, /*allowStringInput*/ false); } @@ -7259,11 +7259,11 @@ namespace ts { } function checkArrayLiteral(node: ArrayLiteralExpression, contextualMapper?: TypeMapper): Type { - let elements = node.elements; + const elements = node.elements; let hasSpreadElement = false; - let elementTypes: Type[] = []; - let inDestructuringPattern = isAssignmentTarget(node); - for (let e of elements) { + const elementTypes: Type[] = []; + const inDestructuringPattern = isAssignmentTarget(node); + for (const e of elements) { if (inDestructuringPattern && e.kind === SyntaxKind.SpreadElementExpression) { // Given the following situation: // var c: {}; @@ -7277,15 +7277,15 @@ namespace ts { // get the contextual element type from it. So we do something similar to // getContextualTypeForElementExpression, which will crucially not error // if there is no index type / iterated type. - let restArrayType = checkExpression((e).expression, contextualMapper); - let restElementType = getIndexTypeOfType(restArrayType, IndexKind.Number) || + const restArrayType = checkExpression((e).expression, contextualMapper); + const restElementType = getIndexTypeOfType(restArrayType, IndexKind.Number) || (languageVersion >= ScriptTarget.ES6 ? getElementTypeOfIterable(restArrayType, /*errorNode*/ undefined) : undefined); if (restElementType) { elementTypes.push(restElementType); } } else { - let type = checkExpression(e, contextualMapper); + const type = checkExpression(e, contextualMapper); elementTypes.push(type); } hasSpreadElement = hasSpreadElement || e.kind === SyntaxKind.SpreadElementExpression; @@ -7294,19 +7294,19 @@ namespace ts { // If array literal is actually a destructuring pattern, mark it as an implied type. We do this such // that we get the same behavior for "var [x, y] = []" and "[x, y] = []". if (inDestructuringPattern && elementTypes.length) { - let type = createNewTupleType(elementTypes); + const type = createNewTupleType(elementTypes); type.pattern = node; return type; } - let contextualType = getContextualType(node); + const contextualType = getContextualType(node); if (contextualType && contextualTypeIsTupleLikeType(contextualType)) { - let pattern = contextualType.pattern; + const 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 === SyntaxKind.ArrayBindingPattern || pattern.kind === SyntaxKind.ArrayLiteralExpression)) { - let patternElements = (pattern).elements; + const patternElements = (pattern).elements; for (let i = elementTypes.length; i < patternElements.length; i++) { - let patternElement = patternElements[i]; + const patternElement = patternElements[i]; if (hasDefaultValue(patternElement)) { elementTypes.push((contextualType).elementTypes[i]); } @@ -7366,7 +7366,7 @@ namespace ts { } function checkComputedPropertyName(node: ComputedPropertyName): Type { - let links = getNodeLinks(node.expression); + const links = getNodeLinks(node.expression); if (!links.resolvedType) { links.resolvedType = checkExpression(node.expression); @@ -7384,18 +7384,18 @@ namespace ts { } function checkObjectLiteral(node: ObjectLiteralExpression, contextualMapper?: TypeMapper): Type { - let inDestructuringPattern = isAssignmentTarget(node); + const inDestructuringPattern = isAssignmentTarget(node); // Grammar checking checkGrammarObjectLiteralExpression(node, inDestructuringPattern); - let propertiesTable: SymbolTable = {}; - let propertiesArray: Symbol[] = []; - let contextualType = getContextualType(node); - let contextualTypeHasPattern = contextualType && contextualType.pattern && + const propertiesTable: SymbolTable = {}; + const propertiesArray: Symbol[] = []; + const contextualType = getContextualType(node); + const contextualTypeHasPattern = contextualType && contextualType.pattern && (contextualType.pattern.kind === SyntaxKind.ObjectBindingPattern || contextualType.pattern.kind === SyntaxKind.ObjectLiteralExpression); let typeFlags: TypeFlags = 0; - for (let memberDecl of node.properties) { + for (const memberDecl of node.properties) { let member = memberDecl.symbol; if (memberDecl.kind === SyntaxKind.PropertyAssignment || memberDecl.kind === SyntaxKind.ShorthandPropertyAssignment || @@ -7412,7 +7412,7 @@ namespace ts { type = checkExpression((memberDecl).name, contextualMapper); } typeFlags |= type.flags; - let prop = createSymbol(SymbolFlags.Property | SymbolFlags.Transient | member.flags, member.name); + const prop = createSymbol(SymbolFlags.Property | SymbolFlags.Transient | member.flags, member.name); if (inDestructuringPattern) { // If object literal is an assignment pattern and if the assignment pattern specifies a default value // for the property, make the property optional. @@ -7426,7 +7426,7 @@ namespace ts { else if (contextualTypeHasPattern) { // 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. - let impliedProp = getPropertyOfType(contextualType, member.name); + const impliedProp = getPropertyOfType(contextualType, member.name); if (impliedProp) { prop.flags |= impliedProp.flags & SymbolFlags.Optional; } @@ -7464,7 +7464,7 @@ namespace ts { // If object literal is contextually typed by the implied type of a binding pattern, augment the result // type with those properties for which the binding pattern specifies a default value. if (contextualTypeHasPattern) { - for (let prop of getPropertiesOfType(contextualType)) { + for (const prop of getPropertiesOfType(contextualType)) { if (!hasProperty(propertiesTable, prop.name)) { if (!(prop.flags & SymbolFlags.Optional)) { error(prop.valueDeclaration || (prop).bindingElement, @@ -7476,10 +7476,10 @@ namespace ts { } } - let stringIndexType = getIndexType(IndexKind.String); - let numberIndexType = getIndexType(IndexKind.Number); - let result = createAnonymousType(node.symbol, propertiesTable, emptyArray, emptyArray, stringIndexType, numberIndexType); - let freshObjectLiteralFlag = compilerOptions.suppressExcessPropertyErrors ? 0 : TypeFlags.FreshObjectLiteral; + const stringIndexType = getIndexType(IndexKind.String); + const numberIndexType = getIndexType(IndexKind.Number); + const result = createAnonymousType(node.symbol, propertiesTable, emptyArray, emptyArray, stringIndexType, numberIndexType); + const freshObjectLiteralFlag = compilerOptions.suppressExcessPropertyErrors ? 0 : TypeFlags.FreshObjectLiteral; result.flags |= TypeFlags.ObjectLiteral | TypeFlags.ContainsObjectLiteral | freshObjectLiteralFlag | (typeFlags & TypeFlags.PropagatingFlags); if (inDestructuringPattern) { result.pattern = node; @@ -7488,21 +7488,21 @@ namespace ts { function getIndexType(kind: IndexKind) { if (contextualType && contextualTypeHasIndexSignature(contextualType, kind)) { - let propTypes: Type[] = []; + const propTypes: Type[] = []; for (let i = 0; i < propertiesArray.length; i++) { - let propertyDecl = node.properties[i]; + const propertyDecl = node.properties[i]; if (kind === IndexKind.String || isNumericName(propertyDecl.name)) { // Do not call getSymbolOfNode(propertyDecl), as that will get the // original symbol for the node. We actually want to get the symbol // created by checkObjectLiteral, since that will be appropriately // contextually typed and resolved. - let type = getTypeOfSymbol(propertiesArray[i]); + const type = getTypeOfSymbol(propertiesArray[i]); if (!contains(propTypes, type)) { propTypes.push(type); } } } - let result = propTypes.length ? getUnionType(propTypes) : undefinedType; + const result = propTypes.length ? getUnionType(propTypes) : undefinedType; typeFlags |= result.flags; return result; } @@ -7542,7 +7542,7 @@ namespace ts { } // Check children - for (let child of node.children) { + for (const child of node.children) { switch (child.kind) { case SyntaxKind.JsxExpression: checkJsxExpression(child); @@ -7588,11 +7588,11 @@ namespace ts { error(node.parent, Diagnostics.JSX_element_class_does_not_support_attributes_because_it_does_not_have_a_0_property, getJsxElementPropertiesName()); } else if (elementAttributesType && !isTypeAny(elementAttributesType)) { - let correspondingPropSymbol = getPropertyOfType(elementAttributesType, node.name.text); + const correspondingPropSymbol = getPropertyOfType(elementAttributesType, node.name.text); correspondingPropType = correspondingPropSymbol && getTypeOfSymbol(correspondingPropSymbol); if (isUnhyphenatedJsxName(node.name.text)) { // Maybe there's a string indexer? - let indexerType = getIndexTypeOfType(elementAttributesType, IndexKind.String); + const indexerType = getIndexTypeOfType(elementAttributesType, IndexKind.String); if (indexerType) { correspondingPropType = indexerType; } @@ -7624,15 +7624,15 @@ namespace ts { } function checkJsxSpreadAttribute(node: JsxSpreadAttribute, elementAttributesType: Type, nameTable: Map) { - let type = checkExpression(node.expression); - let props = getPropertiesOfType(type); - for (let prop of props) { + const type = checkExpression(node.expression); + const props = getPropertiesOfType(type); + for (const prop of props) { // Is there a corresponding property in the element attributes type? Skip checking of properties // that have already been assigned to, as these are not actually pushed into the resulting type if (!nameTable[prop.name]) { - let targetPropSym = getPropertyOfType(elementAttributesType, prop.name); + const targetPropSym = getPropertyOfType(elementAttributesType, prop.name); if (targetPropSym) { - let msg = chainDiagnosticMessages(undefined, Diagnostics.Property_0_of_JSX_spread_attribute_is_not_assignable_to_target_property, prop.name); + const msg = chainDiagnosticMessages(undefined, Diagnostics.Property_0_of_JSX_spread_attribute_is_not_assignable_to_target_property, prop.name); checkTypeAssignableTo(getTypeOfSymbol(prop), getTypeOfSymbol(targetPropSym), node, undefined, msg); } @@ -7657,8 +7657,8 @@ namespace ts { /// type or factory function. /// Otherwise, returns unknownSymbol. function getJsxElementTagSymbol(node: JsxOpeningLikeElement | JsxClosingElement): Symbol { - let flags: JsxFlags = JsxFlags.UnknownElement; - let links = getNodeLinks(node); + const flags: JsxFlags = JsxFlags.UnknownElement; + const links = getNodeLinks(node); if (!links.resolvedSymbol) { if (isJsxIntrinsicIdentifier(node.tagName)) { links.resolvedSymbol = lookupIntrinsicTag(node); @@ -7670,17 +7670,17 @@ namespace ts { return links.resolvedSymbol; function lookupIntrinsicTag(node: JsxOpeningLikeElement | JsxClosingElement): Symbol { - let intrinsicElementsType = getJsxIntrinsicElementsType(); + const intrinsicElementsType = getJsxIntrinsicElementsType(); if (intrinsicElementsType !== unknownType) { // Property case - let intrinsicProp = getPropertyOfType(intrinsicElementsType, (node.tagName).text); + const intrinsicProp = getPropertyOfType(intrinsicElementsType, (node.tagName).text); if (intrinsicProp) { links.jsxFlags |= JsxFlags.IntrinsicNamedElement; return intrinsicProp; } // Intrinsic string indexer case - let indexSignatureType = getIndexTypeOfType(intrinsicElementsType, IndexKind.String); + const indexSignatureType = getIndexTypeOfType(intrinsicElementsType, IndexKind.String); if (indexSignatureType) { links.jsxFlags |= JsxFlags.IntrinsicIndexedElement; return intrinsicElementsType.symbol; @@ -7698,7 +7698,7 @@ namespace ts { } function lookupClassTag(node: JsxOpeningLikeElement | JsxClosingElement): Symbol { - let valueSymbol: Symbol = resolveJsxTagName(node); + const valueSymbol: Symbol = resolveJsxTagName(node); // Look up the value in the current scope if (valueSymbol && valueSymbol !== unknownSymbol) { @@ -7713,8 +7713,8 @@ namespace ts { function resolveJsxTagName(node: JsxOpeningLikeElement | JsxClosingElement): Symbol { if (node.tagName.kind === SyntaxKind.Identifier) { - let tag = node.tagName; - let sym = getResolvedSymbol(tag); + const tag = node.tagName; + const sym = getResolvedSymbol(tag); return sym.exportSymbol || sym; } else { @@ -7733,13 +7733,13 @@ namespace ts { // line shouldn't be hit. Debug.assert(!!(getNodeLinks(node).jsxFlags & JsxFlags.ClassElement), "Should not call getJsxElementInstanceType on non-class Element"); - let classSymbol = getJsxElementTagSymbol(node); + const classSymbol = getJsxElementTagSymbol(node); if (classSymbol === unknownSymbol) { // Couldn't find the class instance type. Error has already been issued return anyType; } - let valueType = getTypeOfSymbol(classSymbol); + const valueType = getTypeOfSymbol(classSymbol); if (isTypeAny(valueType)) { // Short-circuit if the class tag is using an element type 'any' return anyType; @@ -7758,10 +7758,10 @@ namespace ts { } } - let returnType = getUnionType(signatures.map(getReturnTypeOfSignature)); + const returnType = getUnionType(signatures.map(getReturnTypeOfSignature)); // Issue an error if this return type isn't assignable to JSX.ElementClass - let elemClassType = getJsxGlobalElementClassType(); + const elemClassType = getJsxGlobalElementClassType(); if (elemClassType) { checkTypeRelatedTo(returnType, elemClassType, assignableRelation, node, Diagnostics.JSX_element_type_0_is_not_a_constructor_function_for_JSX_elements); } @@ -7776,13 +7776,13 @@ namespace ts { /// non-instrinsic elements' attributes type is the element instance type) function getJsxElementPropertiesName() { // JSX - let jsxNamespace = getGlobalSymbol(JsxNames.JSX, SymbolFlags.Namespace, /*diagnosticMessage*/undefined); + const jsxNamespace = getGlobalSymbol(JsxNames.JSX, SymbolFlags.Namespace, /*diagnosticMessage*/undefined); // JSX.ElementAttributesProperty [symbol] - let attribsPropTypeSym = jsxNamespace && getSymbol(jsxNamespace.exports, JsxNames.ElementAttributesPropertyNameContainer, SymbolFlags.Type); + const attribsPropTypeSym = jsxNamespace && getSymbol(jsxNamespace.exports, JsxNames.ElementAttributesPropertyNameContainer, SymbolFlags.Type); // JSX.ElementAttributesProperty [type] - let attribPropType = attribsPropTypeSym && getDeclaredTypeOfSymbol(attribsPropTypeSym); + const attribPropType = attribsPropTypeSym && getDeclaredTypeOfSymbol(attribsPropTypeSym); // The properites of JSX.ElementAttributesProperty - let attribProperties = attribPropType && getPropertiesOfType(attribPropType); + const attribProperties = attribPropType && getPropertiesOfType(attribPropType); if (attribProperties) { // Element Attributes has zero properties, so the element attributes type will be the class instance type @@ -7811,18 +7811,18 @@ namespace ts { * us which attributes are valid on a given element. */ function getJsxElementAttributesType(node: JsxOpeningLikeElement): Type { - let links = getNodeLinks(node); + const links = getNodeLinks(node); if (!links.resolvedJsxType) { - let sym = getJsxElementTagSymbol(node); + const sym = getJsxElementTagSymbol(node); if (links.jsxFlags & JsxFlags.ClassElement) { - let elemInstanceType = getJsxElementInstanceType(node); + const elemInstanceType = getJsxElementInstanceType(node); if (isTypeAny(elemInstanceType)) { return links.resolvedJsxType = elemInstanceType; } - let propsName = getJsxElementPropertiesName(); + const propsName = getJsxElementPropertiesName(); if (propsName === undefined) { // There is no type ElementAttributesProperty, return 'any' return links.resolvedJsxType = anyType; @@ -7832,7 +7832,7 @@ namespace ts { return links.resolvedJsxType = elemInstanceType; } else { - let attributesType = getTypeOfPropertyOfType(elemInstanceType, propsName); + const attributesType = getTypeOfPropertyOfType(elemInstanceType, propsName); if (!attributesType) { // There is no property named 'props' on this instance type @@ -7871,8 +7871,8 @@ namespace ts { * that have no matching element attributes type property. */ function getJsxAttributePropertySymbol(attrib: JsxAttribute): Symbol { - let attributesType = getJsxElementAttributesType(attrib.parent); - let prop = getPropertyOfType(attributesType, attrib.name.text); + const attributesType = getJsxElementAttributesType(attrib.parent); + const prop = getPropertyOfType(attributesType, attrib.name.text); return prop || unknownSymbol; } @@ -7885,7 +7885,7 @@ namespace ts { /// Returns all the properties of the Jsx.IntrinsicElements interface function getJsxIntrinsicTagNames(): Symbol[] { - let intrinsics = getJsxIntrinsicElementsType(); + const intrinsics = getJsxIntrinsicElementsType(); return intrinsics ? getPropertiesOfType(intrinsics) : emptyArray; } @@ -7910,15 +7910,15 @@ namespace ts { // be marked as 'used' so we don't incorrectly elide its import. And if there // is no 'React' symbol in scope, we should issue an error. if (compilerOptions.jsx === JsxEmit.React) { - let reactSym = resolveName(node.tagName, "React", SymbolFlags.Value, Diagnostics.Cannot_find_name_0, "React"); + const reactSym = resolveName(node.tagName, "React", SymbolFlags.Value, Diagnostics.Cannot_find_name_0, "React"); if (reactSym) { getSymbolLinks(reactSym).referenced = true; } } - let targetAttributesType = getJsxElementAttributesType(node); + const targetAttributesType = getJsxElementAttributesType(node); - let nameTable: Map = {}; + const nameTable: Map = {}; // Process this array in right-to-left order so we know which // attributes (mostly from spreads) are being overwritten and // thus should have their types ignored @@ -7929,7 +7929,7 @@ namespace ts { } else { Debug.assert(node.attributes[i].kind === SyntaxKind.JsxSpreadAttribute); - let spreadType = checkJsxSpreadAttribute((node.attributes[i]), targetAttributesType, nameTable); + const spreadType = checkJsxSpreadAttribute((node.attributes[i]), targetAttributesType, nameTable); if (isTypeAny(spreadType)) { sawSpreadedAny = true; } @@ -7939,7 +7939,7 @@ namespace ts { // Check that all required properties have been provided. If an 'any' // was spreaded in, though, assume that it provided all required properties if (targetAttributesType && !sawSpreadedAny) { - let targetProperties = getPropertiesOfType(targetAttributesType); + const targetProperties = getPropertiesOfType(targetAttributesType); for (let i = 0; i < targetProperties.length; i++) { if (!(targetProperties[i].flags & SymbolFlags.Optional) && nameTable[targetProperties[i].name] === undefined) { @@ -7978,11 +7978,11 @@ namespace ts { * @param prop The symbol for the right hand side of the property access. */ function checkClassPropertyAccess(node: PropertyAccessExpression | QualifiedName, left: Expression | QualifiedName, type: Type, prop: Symbol): boolean { - let flags = getDeclarationFlagsFromSymbol(prop); - let declaringClass = getDeclaredTypeOfSymbol(prop.parent); + const flags = getDeclarationFlagsFromSymbol(prop); + const declaringClass = getDeclaredTypeOfSymbol(prop.parent); if (left.kind === SyntaxKind.SuperKeyword) { - let errorNode = node.kind === SyntaxKind.PropertyAccessExpression ? + const errorNode = node.kind === SyntaxKind.PropertyAccessExpression ? (node).name : (node).right; @@ -8019,9 +8019,9 @@ namespace ts { // Property is known to be private or protected at this point // Get the declaring and enclosing class instance types - let enclosingClassDeclaration = getContainingClass(node); + const enclosingClassDeclaration = getContainingClass(node); - let enclosingClass = enclosingClassDeclaration ? getDeclaredTypeOfSymbol(getSymbolOfNode(enclosingClassDeclaration)) : undefined; + const enclosingClass = enclosingClassDeclaration ? getDeclaredTypeOfSymbol(getSymbolOfNode(enclosingClassDeclaration)) : undefined; // Private property is accessible if declaring and enclosing class are the same if (flags & NodeFlags.Private) { @@ -8070,17 +8070,17 @@ namespace ts { } function checkPropertyAccessExpressionOrQualifiedName(node: PropertyAccessExpression | QualifiedName, left: Expression | QualifiedName, right: Identifier) { - let type = checkExpression(left); + const type = checkExpression(left); if (isTypeAny(type)) { return type; } - let apparentType = getApparentType(getWidenedType(type)); + const apparentType = getApparentType(getWidenedType(type)); if (apparentType === unknownType) { // handle cases when type is Type parameter with invalid constraint return unknownType; } - let prop = getPropertyOfType(apparentType, right.text); + const prop = getPropertyOfType(apparentType, right.text); if (!prop) { if (right.text) { error(right, Diagnostics.Property_0_does_not_exist_on_type_1, declarationNameToString(right), typeToString(type.flags & TypeFlags.ThisType ? apparentType : type)); @@ -8097,13 +8097,13 @@ namespace ts { } function isValidPropertyAccess(node: PropertyAccessExpression | QualifiedName, propertyName: string): boolean { - let left = node.kind === SyntaxKind.PropertyAccessExpression + const left = node.kind === SyntaxKind.PropertyAccessExpression ? (node).expression : (node).left; - let type = checkExpression(left); + const type = checkExpression(left); if (type !== unknownType && !isTypeAny(type)) { - let prop = getPropertyOfType(getWidenedType(type), propertyName); + const prop = getPropertyOfType(getWidenedType(type), propertyName); if (prop && prop.parent && prop.parent.flags & SymbolFlags.Class) { return checkClassPropertyAccess(node, left, type, prop); } @@ -8114,28 +8114,28 @@ namespace ts { function checkIndexedAccess(node: ElementAccessExpression): Type { // Grammar checking if (!node.argumentExpression) { - let sourceFile = getSourceFile(node); + const sourceFile = getSourceFile(node); if (node.parent.kind === SyntaxKind.NewExpression && (node.parent).expression === node) { - let start = skipTrivia(sourceFile.text, node.expression.end); - let end = node.end; + const start = skipTrivia(sourceFile.text, node.expression.end); + const end = node.end; grammarErrorAtPos(sourceFile, start, end - start, Diagnostics.new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead); } else { - let start = node.end - "]".length; - let end = node.end; + const start = node.end - "]".length; + const end = node.end; grammarErrorAtPos(sourceFile, start, end - start, Diagnostics.Expression_expected); } } // Obtain base constraint such that we can bail out if the constraint is an unknown type - let objectType = getApparentType(checkExpression(node.expression)); - let indexType = node.argumentExpression ? checkExpression(node.argumentExpression) : unknownType; + const objectType = getApparentType(checkExpression(node.expression)); + const indexType = node.argumentExpression ? checkExpression(node.argumentExpression) : unknownType; if (objectType === unknownType) { return unknownType; } - let isConstEnum = isConstEnumObjectType(objectType); + const isConstEnum = isConstEnumObjectType(objectType); if (isConstEnum && (!node.argumentExpression || node.argumentExpression.kind !== SyntaxKind.StringLiteral)) { error(node.argumentExpression, Diagnostics.A_const_enum_member_can_only_be_accessed_using_a_string_literal); @@ -8153,9 +8153,9 @@ namespace ts { // See if we can index as a property. if (node.argumentExpression) { - let name = getPropertyNameForIndexedAccess(node.argumentExpression, indexType); + const name = getPropertyNameForIndexedAccess(node.argumentExpression, indexType); if (name !== undefined) { - let prop = getPropertyOfType(objectType, name); + const prop = getPropertyOfType(objectType, name); if (prop) { getNodeLinks(node).resolvedSymbol = prop; return getTypeOfSymbol(prop); @@ -8172,14 +8172,14 @@ namespace ts { // Try to use a number indexer. if (isTypeAnyOrAllConstituentTypesHaveKind(indexType, TypeFlags.NumberLike)) { - let numberIndexType = getIndexTypeOfType(objectType, IndexKind.Number); + const numberIndexType = getIndexTypeOfType(objectType, IndexKind.Number); if (numberIndexType) { return numberIndexType; } } // Try to use string indexing. - let stringIndexType = getIndexTypeOfType(objectType, IndexKind.String); + const stringIndexType = getIndexTypeOfType(objectType, IndexKind.String); if (stringIndexType) { return stringIndexType; } @@ -8210,13 +8210,13 @@ namespace ts { return (indexArgumentExpression).text; } if (indexArgumentExpression.kind === SyntaxKind.ElementAccessExpression || indexArgumentExpression.kind === SyntaxKind.PropertyAccessExpression) { - let value = getConstantValue(indexArgumentExpression); + const value = getConstantValue(indexArgumentExpression); if (value !== undefined) { return value.toString(); } } if (checkThatExpressionIsProperSymbolReference(indexArgumentExpression, indexArgumentType, /*reportError*/ false)) { - let rightHandSideName = ((indexArgumentExpression).name).text; + const rightHandSideName = ((indexArgumentExpression).name).text; return getPropertyNameForKnownSymbolName(rightHandSideName); } @@ -8250,13 +8250,13 @@ namespace ts { // The name is Symbol., so make sure Symbol actually resolves to the // global Symbol object - let leftHandSide = (expression).expression; - let leftHandSideSymbol = getResolvedSymbol(leftHandSide); + const leftHandSide = (expression).expression; + const leftHandSideSymbol = getResolvedSymbol(leftHandSide); if (!leftHandSideSymbol) { return false; } - let globalESSymbol = getGlobalESSymbolConstructorSymbol(); + const globalESSymbol = getGlobalESSymbolConstructorSymbol(); if (!globalESSymbol) { // Already errored when we tried to look up the symbol return false; @@ -8295,7 +8295,7 @@ namespace ts { // so order how inherited signatures are processed is still preserved. // interface A { (x: string): void } // interface B extends A { (x: 'foo'): string } - // let b: B; + // const b: B; // b('foo') // <- here overloads should be processed as [(x:'foo'): string, (x: string): void] function reorderCandidates(signatures: Signature[], result: Signature[]): void { let lastParent: Node; @@ -8305,9 +8305,9 @@ namespace ts { let specializedIndex = -1; let spliceIndex: number; Debug.assert(!result.length); - for (let signature of signatures) { - let symbol = signature.declaration && getSymbolOfNode(signature.declaration); - let parent = signature.declaration && signature.declaration.parent; + for (const signature of signatures) { + const symbol = signature.declaration && getSymbolOfNode(signature.declaration); + const parent = signature.declaration && signature.declaration.parent; if (!lastSymbol || symbol === lastSymbol) { if (lastParent && parent === lastParent) { index++; @@ -8345,7 +8345,7 @@ namespace ts { function getSpreadArgumentIndex(args: Expression[]): number { for (let i = 0; i < args.length; i++) { - let arg = args[i]; + const arg = args[i]; if (arg && arg.kind === SyntaxKind.SpreadElementExpression) { return i; } @@ -8361,7 +8361,7 @@ namespace ts { let spreadArgIndex = -1; if (node.kind === SyntaxKind.TaggedTemplateExpression) { - let tagExpression = node; + const 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 @@ -8371,8 +8371,8 @@ namespace ts { if (tagExpression.template.kind === SyntaxKind.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. - let templateExpression = tagExpression.template; - let lastSpan = lastOrUndefined(templateExpression.templateSpans); + const templateExpression = tagExpression.template; + const lastSpan = lastOrUndefined(templateExpression.templateSpans); Debug.assert(lastSpan !== undefined); // we should always have at least one span. callIsIncomplete = nodeIsMissing(lastSpan.literal) || !!lastSpan.literal.isUnterminated; } @@ -8380,7 +8380,7 @@ namespace ts { // If the template didn't end in a backtick, or its beginning occurred right prior to EOF, // then this might actually turn out to be a TemplateHead in the future; // so we consider the call to be incomplete. - let templateLiteral = tagExpression.template; + const templateLiteral = tagExpression.template; Debug.assert(templateLiteral.kind === SyntaxKind.NoSubstitutionTemplateLiteral); callIsIncomplete = !!templateLiteral.isUnterminated; } @@ -8391,7 +8391,7 @@ namespace ts { adjustedArgCount = getEffectiveArgumentCount(node, /*args*/ undefined, signature); } else { - let callExpression = node; + const callExpression = node; if (!callExpression.arguments) { // This only happens when we have something of the form: 'new C' Debug.assert(callExpression.kind === SyntaxKind.NewExpression); @@ -8411,7 +8411,7 @@ namespace ts { // If the user supplied type arguments, but the number of type arguments does not match // the declared number of type parameters, the call has an incorrect arity. - let hasRightNumberOfTypeArgs = !typeArguments || + const hasRightNumberOfTypeArgs = !typeArguments || (signature.typeParameters && typeArguments.length === signature.typeParameters.length); if (!hasRightNumberOfTypeArgs) { return false; @@ -8429,14 +8429,14 @@ namespace ts { } // If the call is incomplete, we should skip the lower bound check. - let hasEnoughArguments = adjustedArgCount >= signature.minArgumentCount; + const hasEnoughArguments = adjustedArgCount >= signature.minArgumentCount; return callIsIncomplete || hasEnoughArguments; } // 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) { - let resolved = resolveStructuredTypeMembers(type); + const resolved = resolveStructuredTypeMembers(type); if (resolved.callSignatures.length === 1 && resolved.constructSignatures.length === 0 && resolved.properties.length === 0 && !resolved.stringIndexType && !resolved.numberIndexType) { return resolved.callSignatures[0]; @@ -8447,7 +8447,7 @@ namespace ts { // Instantiate a generic signature in the context of a non-generic signature (section 3.8.5 in TypeScript spec) function instantiateSignatureInContextOf(signature: Signature, contextualSignature: Signature, contextualMapper: TypeMapper): Signature { - let context = createInferenceContext(signature.typeParameters, /*inferUnionTypes*/ true); + const context = createInferenceContext(signature.typeParameters, /*inferUnionTypes*/ true); forEachMatchingParameterType(contextualSignature, signature, (source, target) => { // Type parameters from outer context referenced by source type are fixed by instantiation of the source type inferTypes(context, instantiateType(source, contextualMapper), target); @@ -8456,8 +8456,8 @@ namespace ts { } function inferTypeArguments(node: CallLikeExpression, signature: Signature, args: Expression[], excludeArgument: boolean[], context: InferenceContext): void { - let typeParameters = signature.typeParameters; - let inferenceMapper = createInferenceMapper(context); + const typeParameters = signature.typeParameters; + const inferenceMapper = createInferenceMapper(context); // Clear out all the inference results from the last time inferTypeArguments was called on this context for (let i = 0; i < typeParameters.length; i++) { @@ -8483,12 +8483,12 @@ namespace ts { // We perform two passes over the arguments. In the first pass we infer from all arguments, but use // wildcards for all context sensitive function expressions. - let argCount = getEffectiveArgumentCount(node, args, signature); + const argCount = getEffectiveArgumentCount(node, args, signature); for (let i = 0; i < argCount; i++) { - let arg = getEffectiveArgument(node, args, i); + const 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 !== SyntaxKind.OmittedExpression) { - let paramType = getTypeAtPosition(signature, i); + const paramType = getTypeAtPosition(signature, i); let argType = getEffectiveArgumentType(node, i, arg); // If the effective argument type is 'undefined', there is no synthetic type @@ -8496,7 +8496,7 @@ namespace ts { if (argType === undefined) { // For context sensitive arguments we pass the identityMapper, which is a signal to treat all // context sensitive function expressions as wildcards - let mapper = excludeArgument && excludeArgument[i] !== undefined ? identityMapper : inferenceMapper; + const mapper = excludeArgument && excludeArgument[i] !== undefined ? identityMapper : inferenceMapper; argType = checkExpressionWithContextualType(arg, paramType, mapper); } @@ -8513,8 +8513,8 @@ namespace ts { for (let i = 0; i < argCount; i++) { // No need to check for omitted args and template expressions, their exlusion value is always undefined if (excludeArgument[i] === false) { - let arg = args[i]; - let paramType = getTypeAtPosition(signature, i); + const arg = args[i]; + const paramType = getTypeAtPosition(signature, i); inferTypes(context, checkExpressionWithContextualType(arg, paramType, inferenceMapper), paramType); } } @@ -8524,15 +8524,15 @@ namespace ts { } function checkTypeArguments(signature: Signature, typeArguments: TypeNode[], typeArgumentResultTypes: Type[], reportErrors: boolean, headMessage?: DiagnosticMessage): boolean { - let typeParameters = signature.typeParameters; + const typeParameters = signature.typeParameters; let typeArgumentsAreAssignable = true; for (let i = 0; i < typeParameters.length; i++) { - let typeArgNode = typeArguments[i]; - let typeArgument = getTypeFromTypeNode(typeArgNode); + const typeArgNode = typeArguments[i]; + const typeArgument = getTypeFromTypeNode(typeArgNode); // Do not push on this array! It has a preallocated length typeArgumentResultTypes[i] = typeArgument; if (typeArgumentsAreAssignable /* so far */) { - let constraint = getConstraintOfTypeParameter(typeParameters[i]); + const constraint = getConstraintOfTypeParameter(typeParameters[i]); if (constraint) { let errorInfo: DiagnosticMessageChain; let typeArgumentHeadMessage = Diagnostics.Type_0_does_not_satisfy_the_constraint_1; @@ -8555,13 +8555,13 @@ namespace ts { } function checkApplicableSignature(node: CallLikeExpression, args: Expression[], signature: Signature, relation: Map, excludeArgument: boolean[], reportErrors: boolean) { - let argCount = getEffectiveArgumentCount(node, args, signature); + const argCount = getEffectiveArgumentCount(node, args, signature); for (let i = 0; i < argCount; i++) { - let arg = getEffectiveArgument(node, args, i); + const 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 !== SyntaxKind.OmittedExpression) { // Check spread elements against rest type (from arity check we know spread argument corresponds to a rest parameter) - let paramType = getTypeAtPosition(signature, i); + const paramType = getTypeAtPosition(signature, i); let argType = getEffectiveArgumentType(node, i, arg); // If the effective argument type is 'undefined', there is no synthetic type @@ -8573,8 +8573,8 @@ namespace ts { } // Use argument expression as error location when reporting errors - let errorNode = reportErrors ? getEffectiveArgumentErrorNode(node, i, arg) : undefined; - let headMessage = Diagnostics.Argument_of_type_0_is_not_assignable_to_parameter_of_type_1; + const errorNode = reportErrors ? getEffectiveArgumentErrorNode(node, i, arg) : undefined; + const headMessage = Diagnostics.Argument_of_type_0_is_not_assignable_to_parameter_of_type_1; if (!checkTypeRelatedTo(argType, paramType, relation, errorNode, headMessage)) { return false; } @@ -8596,7 +8596,7 @@ namespace ts { function getEffectiveCallArguments(node: CallLikeExpression): Expression[] { let args: Expression[]; if (node.kind === SyntaxKind.TaggedTemplateExpression) { - let template = (node).template; + const template = (node).template; args = [undefined]; if (template.kind === SyntaxKind.TemplateExpression) { forEach((template).templateSpans, span => { @@ -8688,7 +8688,7 @@ namespace ts { if (node.kind === SyntaxKind.ClassDeclaration) { // For a class decorator, the `target` is the type of the class (e.g. the // "static" or "constructor" side of the class) - let classSymbol = getSymbolOfNode(node); + const classSymbol = getSymbolOfNode(node); return getTypeOfSymbol(classSymbol); } @@ -8697,7 +8697,7 @@ namespace ts { // parameter's containing method. node = node.parent; if (node.kind === SyntaxKind.Constructor) { - let classSymbol = getSymbolOfNode(node); + const classSymbol = getSymbolOfNode(node); return getTypeOfSymbol(classSymbol); } } @@ -8758,7 +8758,7 @@ namespace ts { // 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. - let element = node; + const element = node; switch (element.name.kind) { case SyntaxKind.Identifier: case SyntaxKind.NumericLiteral: @@ -8766,7 +8766,7 @@ namespace ts { return getStringLiteralType(element.name); case SyntaxKind.ComputedPropertyName: - let nameType = checkComputedPropertyName(element.name); + const nameType = checkComputedPropertyName(element.name); if (allConstituentTypesHaveKind(nameType, TypeFlags.ESSymbol)) { return nameType; } @@ -8814,7 +8814,7 @@ namespace ts { node.kind === SyntaxKind.SetAccessor) { // The `descriptor` for a method decorator will be a `TypedPropertyDescriptor` // for the type of the member. - let propertyType = getTypeOfNode(node); + const propertyType = getTypeOfNode(node); return createTypedPropertyDescriptorType(propertyType); } @@ -8890,8 +8890,8 @@ namespace ts { } function resolveCall(node: CallLikeExpression, signatures: Signature[], candidatesOutArray: Signature[], headMessage?: DiagnosticMessage): Signature { - let isTaggedTemplate = node.kind === SyntaxKind.TaggedTemplateExpression; - let isDecorator = node.kind === SyntaxKind.Decorator; + const isTaggedTemplate = node.kind === SyntaxKind.TaggedTemplateExpression; + const isDecorator = node.kind === SyntaxKind.Decorator; let typeArguments: TypeNode[]; @@ -8904,7 +8904,7 @@ namespace ts { } } - let candidates = candidatesOutArray || []; + const candidates = candidatesOutArray || []; // reorderCandidates fills up the candidates array directly reorderCandidates(signatures, candidates); if (!candidates.length) { @@ -8912,7 +8912,7 @@ namespace ts { return resolveErrorCall(node); } - let args = getEffectiveCallArguments(node); + const args = getEffectiveCallArguments(node); // The following applies to any value of 'excludeArgument[i]': // - true: the argument at 'i' is susceptible to a one-time permanent contextual typing. @@ -9010,8 +9010,8 @@ namespace ts { } else { Debug.assert(resultOfFailedInference.failedTypeParameterIndex >= 0); - let failedTypeParameter = candidateForTypeArgumentError.typeParameters[resultOfFailedInference.failedTypeParameterIndex]; - let inferenceCandidates = getInferenceCandidates(resultOfFailedInference, resultOfFailedInference.failedTypeParameterIndex); + const failedTypeParameter = candidateForTypeArgumentError.typeParameters[resultOfFailedInference.failedTypeParameterIndex]; + const inferenceCandidates = getInferenceCandidates(resultOfFailedInference, resultOfFailedInference.failedTypeParameterIndex); let diagnosticChainHead = chainDiagnosticMessages(/*details*/ undefined, // details will be provided by call to reportNoCommonSupertypeError Diagnostics.The_type_argument_for_type_parameter_0_cannot_be_inferred_from_the_usage_Consider_specifying_the_type_arguments_explicitly, @@ -9057,14 +9057,14 @@ namespace ts { } function chooseOverload(candidates: Signature[], relation: Map) { - for (let originalCandidate of candidates) { + for (const originalCandidate of candidates) { if (!hasCorrectArity(node, args, originalCandidate)) { continue; } let candidate: Signature; let typeArgumentsAreValid: boolean; - let inferenceContext = originalCandidate.typeParameters + const inferenceContext = originalCandidate.typeParameters ? createInferenceContext(originalCandidate.typeParameters, /*inferUnionTypes*/ false) : undefined; @@ -9089,7 +9089,7 @@ namespace ts { if (!checkApplicableSignature(node, args, candidate, relation, excludeArgument, /*reportErrors*/ false)) { break; } - let index = excludeArgument ? indexOf(excludeArgument, true) : -1; + const index = excludeArgument ? indexOf(excludeArgument, true) : -1; if (index < 0) { return candidate; } @@ -9102,7 +9102,7 @@ namespace ts { // report an error based on the arguments. If there was an issue with type // arguments, then we can only report an error based on the type arguments. if (originalCandidate.typeParameters) { - let instantiatedCandidate = candidate; + const instantiatedCandidate = candidate; if (typeArgumentsAreValid) { candidateForArgumentError = instantiatedCandidate; } @@ -9126,19 +9126,19 @@ namespace ts { function resolveCallExpression(node: CallExpression, candidatesOutArray: Signature[]): Signature { if (node.expression.kind === SyntaxKind.SuperKeyword) { - let superType = checkSuperExpression(node.expression); + const superType = checkSuperExpression(node.expression); if (superType !== unknownType) { // In super call, the candidate signatures are the matching arity signatures of the base constructor function instantiated // with the type arguments specified in the extends clause. - let baseTypeNode = getClassExtendsHeritageClauseElement(getContainingClass(node)); - let baseConstructors = getInstantiatedConstructorsForTypeArguments(superType, baseTypeNode.typeArguments); + const baseTypeNode = getClassExtendsHeritageClauseElement(getContainingClass(node)); + const baseConstructors = getInstantiatedConstructorsForTypeArguments(superType, baseTypeNode.typeArguments); return resolveCall(node, baseConstructors, candidatesOutArray); } return resolveUntypedCall(node); } - let funcType = checkExpression(node.expression); - let apparentType = getApparentType(funcType); + const funcType = checkExpression(node.expression); + const apparentType = getApparentType(funcType); if (apparentType === unknownType) { // Another error has already been reported @@ -9149,9 +9149,9 @@ namespace ts { // but we are not including call signatures that may have been added to the Object or // Function interface, since they have none by default. This is a bit of a leap of faith // that the user will not add any. - let callSignatures = getSignaturesOfType(apparentType, SignatureKind.Call); + const callSignatures = getSignaturesOfType(apparentType, SignatureKind.Call); - let constructSignatures = getSignaturesOfType(apparentType, SignatureKind.Construct); + const constructSignatures = getSignaturesOfType(apparentType, SignatureKind.Construct); // TS 1.0 spec: 4.12 // If FuncExpr is of type Any, or of an object type that has no call or construct signatures // but is a subtype of the Function interface, the call is an untyped function call. In an @@ -9184,7 +9184,7 @@ namespace ts { function resolveNewExpression(node: NewExpression, candidatesOutArray: Signature[]): Signature { if (node.arguments && languageVersion < ScriptTarget.ES5) { - let spreadIndex = getSpreadArgumentIndex(node.arguments); + const spreadIndex = getSpreadArgumentIndex(node.arguments); if (spreadIndex >= 0) { error(node.arguments[spreadIndex], Diagnostics.Spread_operator_in_new_expressions_is_only_available_when_targeting_ECMAScript_5_and_higher); } @@ -9207,7 +9207,7 @@ namespace ts { // Note, only class declarations can be declared abstract. // In the case of a merged class-module or class-interface declaration, // only the class declaration node will have the Abstract flag set. - let valueDecl = expressionType.symbol && getClassLikeDeclarationOfSymbol(expressionType.symbol); + const valueDecl = expressionType.symbol && getClassLikeDeclarationOfSymbol(expressionType.symbol); if (valueDecl && valueDecl.flags & NodeFlags.Abstract) { error(node, Diagnostics.Cannot_create_an_instance_of_the_abstract_class_0, declarationNameToString(valueDecl.name)); return resolveErrorCall(node); @@ -9227,7 +9227,7 @@ namespace ts { // but we are not including construct signatures that may have been added to the Object or // Function interface, since they have none by default. This is a bit of a leap of faith // that the user will not add any. - let constructSignatures = getSignaturesOfType(expressionType, SignatureKind.Construct); + const constructSignatures = getSignaturesOfType(expressionType, SignatureKind.Construct); if (constructSignatures.length) { return resolveCall(node, constructSignatures, candidatesOutArray); } @@ -9236,9 +9236,9 @@ namespace ts { // one or more call signatures, the expression is processed as a function call. A compile-time // error occurs if the result of the function call is not Void. The type of the result of the // operation is Any. - let callSignatures = getSignaturesOfType(expressionType, SignatureKind.Call); + const callSignatures = getSignaturesOfType(expressionType, SignatureKind.Call); if (callSignatures.length) { - let signature = resolveCall(node, callSignatures, candidatesOutArray); + const signature = resolveCall(node, callSignatures, candidatesOutArray); if (getReturnTypeOfSignature(signature) !== voidType) { error(node, Diagnostics.Only_a_void_function_can_be_called_with_the_new_keyword); } @@ -9250,15 +9250,15 @@ namespace ts { } function resolveTaggedTemplateExpression(node: TaggedTemplateExpression, candidatesOutArray: Signature[]): Signature { - let tagType = checkExpression(node.tag); - let apparentType = getApparentType(tagType); + const tagType = checkExpression(node.tag); + const apparentType = getApparentType(tagType); if (apparentType === unknownType) { // Another error has already been reported return resolveErrorCall(node); } - let callSignatures = getSignaturesOfType(apparentType, SignatureKind.Call); + const callSignatures = getSignaturesOfType(apparentType, SignatureKind.Call); if (isTypeAny(tagType) || (!callSignatures.length && !(tagType.flags & TypeFlags.Union) && isTypeAssignableTo(tagType, globalFunctionType))) { return resolveUntypedCall(node); @@ -9298,18 +9298,18 @@ namespace ts { * Resolves a decorator as if it were a call expression. */ function resolveDecorator(node: Decorator, candidatesOutArray: Signature[]): Signature { - let funcType = checkExpression(node.expression); - let apparentType = getApparentType(funcType); + const funcType = checkExpression(node.expression); + const apparentType = getApparentType(funcType); if (apparentType === unknownType) { return resolveErrorCall(node); } - let callSignatures = getSignaturesOfType(apparentType, SignatureKind.Call); + const callSignatures = getSignaturesOfType(apparentType, SignatureKind.Call); if (funcType === anyType || (!callSignatures.length && !(funcType.flags & TypeFlags.Union) && isTypeAssignableTo(funcType, globalFunctionType))) { return resolveUntypedCall(node); } - let headMessage = getDiagnosticHeadMessageForDecoratorResolution(node); + const headMessage = getDiagnosticHeadMessageForDecoratorResolution(node); if (!callSignatures.length) { let errorInfo: DiagnosticMessageChain; errorInfo = chainDiagnosticMessages(errorInfo, Diagnostics.Cannot_invoke_an_expression_whose_type_lacks_a_call_signature); @@ -9324,7 +9324,7 @@ namespace ts { // candidatesOutArray is passed by signature help in the language service, and collectCandidates // must fill it up with the appropriate candidate signatures function getResolvedSignature(node: CallLikeExpression, candidatesOutArray?: Signature[]): Signature { - let links = getNodeLinks(node); + const links = getNodeLinks(node); // If getResolvedSignature has already been called, we will have cached the resolvedSignature. // However, it is possible that either candidatesOutArray was not passed in the first time, // or that a different candidatesOutArray was passed in. Therefore, we need to redo the work @@ -9360,12 +9360,12 @@ namespace ts { // Grammar checking; stop grammar-checking if checkGrammarTypeArguments return true checkGrammarTypeArguments(node, node.typeArguments) || checkGrammarArguments(node, node.arguments); - let signature = getResolvedSignature(node); + const signature = getResolvedSignature(node); if (node.expression.kind === SyntaxKind.SuperKeyword) { return voidType; } if (node.kind === SyntaxKind.NewExpression) { - let declaration = signature.declaration; + const declaration = signature.declaration; if (declaration && declaration.kind !== SyntaxKind.Constructor && @@ -9387,10 +9387,10 @@ namespace ts { } function checkAssertion(node: AssertionExpression) { - let exprType = getRegularTypeOfObjectLiteral(checkExpression(node.expression)); - let targetType = getTypeFromTypeNode(node.type); + const exprType = getRegularTypeOfObjectLiteral(checkExpression(node.expression)); + const targetType = getTypeFromTypeNode(node.type); if (produceDiagnostics && targetType !== unknownType) { - let widenedType = getWidenedType(exprType); + const widenedType = getWidenedType(exprType); if (!(isTypeAssignableTo(targetType, widenedType))) { checkTypeAssignableTo(exprType, targetType, node, Diagnostics.Neither_type_0_nor_type_1_is_assignable_to_the_other); } @@ -9405,15 +9405,15 @@ namespace ts { } function assignContextualParameterTypes(signature: Signature, context: Signature, mapper: TypeMapper) { - let len = signature.parameters.length - (signature.hasRestParameter ? 1 : 0); + const len = signature.parameters.length - (signature.hasRestParameter ? 1 : 0); for (let i = 0; i < len; i++) { - let parameter = signature.parameters[i]; - let contextualParameterType = getTypeAtPosition(context, i); + const parameter = signature.parameters[i]; + const contextualParameterType = getTypeAtPosition(context, i); assignTypeToParameterAndFixTypeParameters(parameter, contextualParameterType, mapper); } if (signature.hasRestParameter && isRestParameterIndex(context, signature.parameters.length - 1)) { - let parameter = lastOrUndefined(signature.parameters); - let contextualParameterType = getTypeOfSymbol(lastOrUndefined(context.parameters)); + const parameter = lastOrUndefined(signature.parameters); + const contextualParameterType = getTypeOfSymbol(lastOrUndefined(context.parameters)); assignTypeToParameterAndFixTypeParameters(parameter, contextualParameterType, mapper); } } @@ -9422,7 +9422,7 @@ namespace ts { // the destructured type into the contained binding elements. function assignBindingElementTypes(node: VariableLikeDeclaration) { if (isBindingPattern(node.name)) { - for (let element of (node.name).elements) { + for (const element of (node.name).elements) { if (element.kind !== SyntaxKind.OmittedExpression) { if (element.name.kind === SyntaxKind.Identifier) { getSymbolLinks(getSymbolOfNode(element)).type = getTypeForBindingElement(element); @@ -9434,7 +9434,7 @@ namespace ts { } function assignTypeToParameterAndFixTypeParameters(parameter: Symbol, contextualType: Type, mapper: TypeMapper) { - let links = getSymbolLinks(parameter); + const links = getSymbolLinks(parameter); if (!links.type) { links.type = instantiateType(contextualType, mapper); assignBindingElementTypes(parameter.valueDeclaration); @@ -9475,7 +9475,7 @@ namespace ts { function createPromiseType(promisedType: Type): Type { // creates a `Promise` type where `T` is the promisedType argument - let globalPromiseType = getGlobalPromiseType(); + const globalPromiseType = getGlobalPromiseType(); if (globalPromiseType !== emptyGenericType) { // if the promised type is itself a promise, get the underlying type; otherwise, fallback to the promised type promisedType = getAwaitedType(promisedType); @@ -9486,12 +9486,12 @@ namespace ts { } function getReturnTypeFromBody(func: FunctionLikeDeclaration, contextualMapper?: TypeMapper): Type { - let contextualSignature = getContextualSignatureForFunctionLikeDeclaration(func); + const contextualSignature = getContextualSignatureForFunctionLikeDeclaration(func); if (!func.body) { return unknownType; } - let isAsync = isAsyncFunctionLike(func); + const isAsync = isAsyncFunctionLike(func); let type: Type; if (func.body.kind !== SyntaxKind.Block) { type = checkExpressionCached(func.body, contextualMapper); @@ -9505,11 +9505,11 @@ namespace ts { } else { let types: Type[]; - let funcIsGenerator = !!func.asteriskToken; + const funcIsGenerator = !!func.asteriskToken; if (funcIsGenerator) { types = checkAndAggregateYieldOperandTypes(func.body, contextualMapper); if (types.length === 0) { - let iterableIteratorAny = createIterableIteratorType(anyType); + const iterableIteratorAny = createIterableIteratorType(anyType); if (compilerOptions.noImplicitAny) { error(func.asteriskToken, Diagnostics.Generator_implicitly_has_type_0_because_it_does_not_yield_any_values_Consider_supplying_a_return_type, typeToString(iterableIteratorAny)); @@ -9522,7 +9522,7 @@ namespace ts { if (types.length === 0) { if (isAsync) { // For an async function, the return type will not be void, but rather a Promise for void. - let promiseType = createPromiseType(voidType); + const promiseType = createPromiseType(voidType); if (promiseType === emptyObjectType) { error(func, Diagnostics.An_async_function_or_method_must_have_a_valid_awaitable_return_type); return unknownType; @@ -9557,12 +9557,12 @@ namespace ts { reportErrorsFromWidening(func, type); } - let widenedType = getWidenedType(type); + const widenedType = getWidenedType(type); if (isAsync) { // From within an async function you can return either a non-promise value or a promise. Any // Promise/A+ compatible implementation will always assimilate any foreign promise, so the // return type of the body is awaited type of the body, wrapped in a native Promise type. - let promiseType = createPromiseType(widenedType); + const promiseType = createPromiseType(widenedType); if (promiseType === emptyObjectType) { error(func, Diagnostics.An_async_function_or_method_must_have_a_valid_awaitable_return_type); return unknownType; @@ -9576,10 +9576,10 @@ namespace ts { } function checkAndAggregateYieldOperandTypes(body: Block, contextualMapper?: TypeMapper): Type[] { - let aggregatedTypes: Type[] = []; + const aggregatedTypes: Type[] = []; forEachYieldExpression(body, yieldExpression => { - let expr = yieldExpression.expression; + const expr = yieldExpression.expression; if (expr) { let type = checkExpressionCached(expr, contextualMapper); @@ -9598,10 +9598,10 @@ namespace ts { } function checkAndAggregateReturnExpressionTypes(body: Block, contextualMapper?: TypeMapper, isAsync?: boolean): Type[] { - let aggregatedTypes: Type[] = []; + const aggregatedTypes: Type[] = []; forEachReturnStatement(body, returnStatement => { - let expr = returnStatement.expression; + const expr = returnStatement.expression; if (expr) { let type = checkExpressionCached(expr, contextualMapper); if (isAsync) { @@ -9656,7 +9656,7 @@ namespace ts { Debug.assert(node.kind !== SyntaxKind.MethodDeclaration || isObjectLiteralMethod(node)); // Grammar checking - let hasGrammarError = checkGrammarFunctionLikeDeclaration(node); + const hasGrammarError = checkGrammarFunctionLikeDeclaration(node); if (!hasGrammarError && node.kind === SyntaxKind.FunctionExpression) { checkGrammarForGenerator(node); } @@ -9666,34 +9666,34 @@ namespace ts { return anyFunctionType; } - let isAsync = isAsyncFunctionLike(node); + const isAsync = isAsyncFunctionLike(node); if (isAsync) { emitAwaiter = true; } - let links = getNodeLinks(node); - let type = getTypeOfSymbol(node.symbol); - let contextSensitive = isContextSensitive(node); - let mightFixTypeParameters = contextSensitive && isInferentialContext(contextualMapper); + const links = getNodeLinks(node); + const type = getTypeOfSymbol(node.symbol); + const contextSensitive = isContextSensitive(node); + const mightFixTypeParameters = contextSensitive && isInferentialContext(contextualMapper); // Check if function expression is contextually typed and assign parameter types if so. // See the comment in assignTypeToParameterAndFixTypeParameters to understand why we need to // check mightFixTypeParameters. if (mightFixTypeParameters || !(links.flags & NodeCheckFlags.ContextChecked)) { - let contextualSignature = getContextualSignature(node); + const contextualSignature = getContextualSignature(node); // If a type check is started at a function expression that is an argument of a function call, obtaining the // contextual type may recursively get back to here during overload resolution of the call. If so, we will have // already assigned contextual types. - let contextChecked = !!(links.flags & NodeCheckFlags.ContextChecked); + const contextChecked = !!(links.flags & NodeCheckFlags.ContextChecked); if (mightFixTypeParameters || !contextChecked) { links.flags |= NodeCheckFlags.ContextChecked; if (contextualSignature) { - let signature = getSignaturesOfType(type, SignatureKind.Call)[0]; + const signature = getSignaturesOfType(type, SignatureKind.Call)[0]; if (contextSensitive) { assignContextualParameterTypes(signature, contextualSignature, contextualMapper || identityMapper); } if (mightFixTypeParameters || !node.type && !signature.resolvedReturnType) { - let returnType = getReturnTypeFromBody(node, contextualMapper); + const returnType = getReturnTypeFromBody(node, contextualMapper); if (!signature.resolvedReturnType) { signature.resolvedReturnType = returnType; } @@ -9717,12 +9717,12 @@ namespace ts { function checkFunctionExpressionOrObjectLiteralMethodBody(node: FunctionExpression | MethodDeclaration) { Debug.assert(node.kind !== SyntaxKind.MethodDeclaration || isObjectLiteralMethod(node)); - let isAsync = isAsyncFunctionLike(node); + const isAsync = isAsyncFunctionLike(node); if (isAsync) { emitAwaiter = true; } - let returnType = node.type && getTypeFromTypeNode(node.type); + const returnType = node.type && getTypeFromTypeNode(node.type); let promisedType: Type; if (returnType && isAsync) { promisedType = checkAsyncFunctionReturnType(node); @@ -9751,10 +9751,10 @@ namespace ts { // should not be checking assignability of a promise to the return type. Instead, we need to // check assignability of the awaited type of the expression body against the promised type of // its return type annotation. - let exprType = checkExpression(node.body); + const exprType = checkExpression(node.body); if (returnType) { if (isAsync) { - let awaitedType = checkAwaitedType(exprType, node.body, Diagnostics.Expression_body_for_async_arrow_function_does_not_have_a_valid_callable_then_member); + const awaitedType = checkAwaitedType(exprType, node.body, Diagnostics.Expression_body_for_async_arrow_function_does_not_have_a_valid_callable_then_member); checkTypeAssignableTo(awaitedType, promisedType, node.body); } else { @@ -9777,7 +9777,7 @@ namespace ts { function checkReferenceExpression(n: Node, invalidReferenceMessage: DiagnosticMessage, constantVariableMessage: DiagnosticMessage): boolean { function findSymbol(n: Node): Symbol { - let symbol = getNodeLinks(n).resolvedSymbol; + const symbol = getNodeLinks(n).resolvedSymbol; // Because we got the symbol from the resolvedSymbol property, it might be of kind // SymbolFlags.ExportValue. In this case it is necessary to get the actual export // symbol, which will have the correct flags set on it. @@ -9793,14 +9793,14 @@ namespace ts { // All other expression constructs described in this chapter are classified as values. switch (n.kind) { case SyntaxKind.Identifier: { - let symbol = findSymbol(n); + const symbol = findSymbol(n); // TypeScript 1.0 spec (April 2014): 4.3 // An identifier expression that references a variable or parameter is classified as a reference. // An identifier expression that references any other kind of entity is classified as a value(and therefore cannot be the target of an assignment). return !symbol || symbol === unknownSymbol || symbol === argumentsSymbol || (symbol.flags & SymbolFlags.Variable) !== 0; } case SyntaxKind.PropertyAccessExpression: { - let symbol = findSymbol(n); + const symbol = findSymbol(n); // TypeScript 1.0 spec (April 2014): 4.10 // A property access expression is always classified as a reference. // NOTE (not in spec): assignment to enum members should not be allowed @@ -9820,15 +9820,15 @@ namespace ts { switch (n.kind) { case SyntaxKind.Identifier: case SyntaxKind.PropertyAccessExpression: { - let symbol = findSymbol(n); + const symbol = findSymbol(n); return symbol && (symbol.flags & SymbolFlags.Variable) !== 0 && (getDeclarationFlagsFromSymbol(symbol) & NodeFlags.Const) !== 0; } case SyntaxKind.ElementAccessExpression: { - let index = (n).argumentExpression; - let symbol = findSymbol((n).expression); + const index = (n).argumentExpression; + const symbol = findSymbol((n).expression); if (symbol && index && index.kind === SyntaxKind.StringLiteral) { - let name = (index).text; - let prop = getPropertyOfType(getTypeOfSymbol(symbol), name); + const name = (index).text; + const prop = getPropertyOfType(getTypeOfSymbol(symbol), name); return prop && (prop.flags & SymbolFlags.Variable) !== 0 && (getDeclarationFlagsFromSymbol(prop) & NodeFlags.Const) !== 0; } return false; @@ -9880,12 +9880,12 @@ namespace ts { } } - let operandType = checkExpression(node.expression); + const operandType = checkExpression(node.expression); return checkAwaitedType(operandType, node); } function checkPrefixUnaryExpression(node: PrefixUnaryExpression): Type { - let operandType = checkExpression(node.operand); + const operandType = checkExpression(node.operand); switch (node.operator) { case SyntaxKind.PlusToken: case SyntaxKind.MinusToken: @@ -9898,7 +9898,7 @@ namespace ts { return booleanType; case SyntaxKind.PlusPlusToken: case SyntaxKind.MinusMinusToken: - let ok = checkArithmeticOperandType(node.operand, operandType, Diagnostics.An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type); + const ok = checkArithmeticOperandType(node.operand, operandType, 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 checkReferenceExpression(node.operand, @@ -9911,8 +9911,8 @@ namespace ts { } function checkPostfixUnaryExpression(node: PostfixUnaryExpression): Type { - let operandType = checkExpression(node.operand); - let ok = checkArithmeticOperandType(node.operand, operandType, Diagnostics.An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type); + const operandType = checkExpression(node.operand); + const ok = checkArithmeticOperandType(node.operand, operandType, 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 checkReferenceExpression(node.operand, @@ -9929,8 +9929,8 @@ namespace ts { return true; } if (type.flags & TypeFlags.UnionOrIntersection) { - let types = (type).types; - for (let current of types) { + const types = (type).types; + for (const current of types) { if (current.flags & kind) { return true; } @@ -9946,8 +9946,8 @@ namespace ts { return true; } if (type.flags & TypeFlags.UnionOrIntersection) { - let types = (type).types; - for (let current of types) { + const types = (type).types; + for (const current of types) { if (!(current.flags & kind)) { return false; } @@ -9996,12 +9996,12 @@ namespace ts { } function checkObjectLiteralAssignment(node: ObjectLiteralExpression, sourceType: Type, contextualMapper?: TypeMapper): Type { - let properties = node.properties; - for (let p of properties) { + const properties = node.properties; + for (const p of properties) { if (p.kind === SyntaxKind.PropertyAssignment || p.kind === SyntaxKind.ShorthandPropertyAssignment) { // TODO(andersh): Computed property support - let name = (p).name; - let type = isTypeAny(sourceType) + const name = (p).name; + const type = isTypeAny(sourceType) ? sourceType : getTypeOfPropertyOfType(sourceType, name.text) || isNumericLiteralName(name.text) && getIndexTypeOfType(sourceType, IndexKind.Number) || @@ -10029,14 +10029,14 @@ namespace ts { // This elementType will be used if the specific property corresponding to this index is not // present (aka the tuple element property). This call also checks that the parentType is in // fact an iterable or array (depending on target language). - let elementType = checkIteratedTypeOrElementType(sourceType, node, /*allowStringInput*/ false) || unknownType; - let elements = node.elements; + const elementType = checkIteratedTypeOrElementType(sourceType, node, /*allowStringInput*/ false) || unknownType; + const elements = node.elements; for (let i = 0; i < elements.length; i++) { - let e = elements[i]; + const e = elements[i]; if (e.kind !== SyntaxKind.OmittedExpression) { if (e.kind !== SyntaxKind.SpreadElementExpression) { - let propName = "" + i; - let type = isTypeAny(sourceType) + const propName = "" + i; + const type = isTypeAny(sourceType) ? sourceType : isTupleLikeType(sourceType) ? getTypeOfPropertyOfType(sourceType, propName) @@ -10058,7 +10058,7 @@ namespace ts { error(e, Diagnostics.A_rest_element_must_be_last_in_an_array_destructuring_pattern); } else { - let restExpression = (e).expression; + const restExpression = (e).expression; if (restExpression.kind === SyntaxKind.BinaryExpression && (restExpression).operatorToken.kind === SyntaxKind.EqualsToken) { error((restExpression).operatorToken, Diagnostics.A_rest_element_cannot_have_an_initializer); } @@ -10099,7 +10099,7 @@ namespace ts { } function checkReferenceAssignment(target: Expression, sourceType: Type, contextualMapper?: TypeMapper): Type { - let targetType = checkExpression(target, contextualMapper); + const targetType = checkExpression(target, contextualMapper); if (checkReferenceExpression(target, Diagnostics.Invalid_left_hand_side_of_assignment_expression, Diagnostics.Left_hand_side_of_assignment_expression_cannot_be_a_constant)) { checkTypeAssignableTo(sourceType, targetType, target, /*headMessage*/ undefined); } @@ -10111,7 +10111,7 @@ namespace ts { } function checkBinaryLikeExpression(left: Expression, operatorToken: Node, right: Expression, contextualMapper?: TypeMapper, errorNode?: Node) { - let operator = operatorToken.kind; + const operator = operatorToken.kind; if (operator === SyntaxKind.EqualsToken && (left.kind === SyntaxKind.ObjectLiteralExpression || left.kind === SyntaxKind.ArrayLiteralExpression)) { return checkDestructuringAssignment(left, checkExpression(right, contextualMapper), contextualMapper); } @@ -10159,8 +10159,8 @@ namespace ts { } else { // otherwise just check each operand separately and report errors as normal - let leftOk = checkArithmeticOperandType(left, leftType, Diagnostics.The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type); - let rightOk = checkArithmeticOperandType(right, rightType, Diagnostics.The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type); + const leftOk = checkArithmeticOperandType(left, leftType, Diagnostics.The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type); + const rightOk = checkArithmeticOperandType(right, rightType, Diagnostics.The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type); if (leftOk && rightOk) { checkAssignmentOperator(numberType); } @@ -10242,7 +10242,7 @@ namespace ts { // Return true if there was no error, false if there was an error. function checkForDisallowedESSymbolOperand(operator: SyntaxKind): boolean { - let offendingSymbolOperand = + const offendingSymbolOperand = someConstituentTypeHasKind(leftType, TypeFlags.ESSymbol) ? left : someConstituentTypeHasKind(rightType, TypeFlags.ESSymbol) ? right : undefined; @@ -10278,7 +10278,7 @@ namespace ts { // requires VarExpr to be classified as a reference // A compound assignment furthermore requires VarExpr to be classified as a reference (section 4.1) // and the type of the non - compound operation to be assignable to the type of VarExpr. - let ok = checkReferenceExpression(left, Diagnostics.Invalid_left_hand_side_of_assignment_expression, Diagnostics.Left_hand_side_of_assignment_expression_cannot_be_a_constant); + const ok = checkReferenceExpression(left, Diagnostics.Invalid_left_hand_side_of_assignment_expression, Diagnostics.Left_hand_side_of_assignment_expression_cannot_be_a_constant); // Use default messages if (ok) { // to avoid cascading errors check assignability only if 'isReference' check succeeded and no errors were reported @@ -10323,13 +10323,13 @@ namespace ts { } if (node.expression) { - let func = getContainingFunction(node); + const func = getContainingFunction(node); // If the user's code is syntactically correct, the func should always have a star. After all, // we are in a yield context. if (func && func.asteriskToken) { - let expressionType = checkExpressionCached(node.expression, /*contextualMapper*/ undefined); + const expressionType = checkExpressionCached(node.expression, /*contextualMapper*/ undefined); let expressionElementType: Type; - let nodeIsYieldStar = !!node.asteriskToken; + const nodeIsYieldStar = !!node.asteriskToken; if (nodeIsYieldStar) { expressionElementType = checkElementTypeOfIterable(expressionType, node.expression); } @@ -10337,7 +10337,7 @@ namespace ts { // has no explicit return type because the return type is directly computed // from the yield expressions. if (func.type) { - let signatureElementType = getElementTypeOfIterableIterator(getTypeFromTypeNode(func.type)) || anyType; + const signatureElementType = getElementTypeOfIterableIterator(getTypeFromTypeNode(func.type)) || anyType; if (nodeIsYieldStar) { checkTypeAssignableTo(expressionElementType, signatureElementType, node.expression, /*headMessage*/ undefined); } @@ -10354,8 +10354,8 @@ namespace ts { function checkConditionalExpression(node: ConditionalExpression, contextualMapper?: TypeMapper): Type { checkExpression(node.condition); - let type1 = checkExpression(node.whenTrue, contextualMapper); - let type2 = checkExpression(node.whenFalse, contextualMapper); + const type1 = checkExpression(node.whenTrue, contextualMapper); + const type2 = checkExpression(node.whenFalse, contextualMapper); return getUnionType([type1, type2]); } @@ -10373,15 +10373,15 @@ namespace ts { } function checkExpressionWithContextualType(node: Expression, contextualType: Type, contextualMapper?: TypeMapper): Type { - let saveContextualType = node.contextualType; + const saveContextualType = node.contextualType; node.contextualType = contextualType; - let result = checkExpression(node, contextualMapper); + const result = checkExpression(node, contextualMapper); node.contextualType = saveContextualType; return result; } function checkExpressionCached(node: Expression, contextualMapper?: TypeMapper): Type { - let links = getNodeLinks(node); + const links = getNodeLinks(node); if (!links.resolvedType) { links.resolvedType = checkExpression(node, contextualMapper); } @@ -10410,17 +10410,17 @@ namespace ts { checkComputedPropertyName(node.name); } - let uninstantiatedType = checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); + const uninstantiatedType = checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); return instantiateTypeWithSingleGenericCallSignature(node, uninstantiatedType, contextualMapper); } function instantiateTypeWithSingleGenericCallSignature(node: Expression | MethodDeclaration, type: Type, contextualMapper?: TypeMapper) { if (isInferentialContext(contextualMapper)) { - let signature = getSingleCallSignature(type); + const signature = getSingleCallSignature(type); if (signature && signature.typeParameters) { - let contextualType = getContextualType(node); + const contextualType = getContextualType(node); if (contextualType) { - let contextualSignature = getSingleCallSignature(contextualType); + const contextualSignature = getSingleCallSignature(contextualType); if (contextualSignature && !contextualSignature.typeParameters) { return getOrCreateTypeFromSignature(instantiateSignatureInContextOf(signature, contextualSignature, contextualMapper)); } @@ -10444,7 +10444,7 @@ namespace ts { type = checkQualifiedName(node); } else { - let uninstantiatedType = checkExpressionWorker(node, contextualMapper); + const uninstantiatedType = checkExpressionWorker(node, contextualMapper); type = instantiateTypeWithSingleGenericCallSignature(node, uninstantiatedType, contextualMapper); } @@ -10453,7 +10453,7 @@ namespace ts { // - 'left' in property access // - 'object' in indexed access // - target in rhs of import statement - let ok = + const ok = (node.parent.kind === SyntaxKind.PropertyAccessExpression && (node.parent).expression === node) || (node.parent.kind === SyntaxKind.ElementAccessExpression && (node.parent).expression === node) || ((node.kind === SyntaxKind.Identifier || node.kind === SyntaxKind.QualifiedName) && isInRightSideOfImportOrExportAssignment(node)); @@ -10607,7 +10607,7 @@ namespace ts { function getTypePredicateParameterIndex(parameterList: NodeArray, parameter: Identifier): number { if (parameterList) { for (let i = 0; i < parameterList.length; i++) { - let param = parameterList[i]; + const param = parameterList[i]; if (param.name.kind === SyntaxKind.Identifier && (param.name).text === parameter.text) { @@ -10650,8 +10650,8 @@ namespace ts { if (node.type) { if (node.type.kind === SyntaxKind.TypePredicate) { - let typePredicate = getSignatureFromDeclaration(node).typePredicate; - let typePredicateNode = node.type; + const typePredicate = getSignatureFromDeclaration(node).typePredicate; + const typePredicateNode = node.type; if (isInLegalTypePredicatePosition(typePredicateNode)) { if (typePredicate.parameterIndex >= 0) { if (node.parameters[typePredicate.parameterIndex].dotDotDotToken) { @@ -10674,7 +10674,7 @@ namespace ts { param.name.kind === SyntaxKind.ArrayBindingPattern) { (function checkBindingPattern(pattern: BindingPattern) { - for (let element of pattern.elements) { + for (const element of pattern.elements) { if (element.name.kind === SyntaxKind.Identifier && (element.name).text === typePredicate.parameterName) { @@ -10725,13 +10725,13 @@ namespace ts { if (node.type) { if (languageVersion >= ScriptTarget.ES6 && isSyntacticallyValidGenerator(node)) { - let returnType = getTypeFromTypeNode(node.type); + const returnType = getTypeFromTypeNode(node.type); if (returnType === voidType) { error(node.type, Diagnostics.A_generator_cannot_have_a_void_type_annotation); } else { - let generatorElementType = getElementTypeOfIterableIterator(returnType) || anyType; - let iterableIteratorInstantiation = createIterableIteratorType(generatorElementType); + const generatorElementType = getElementTypeOfIterableIterator(returnType) || anyType; + const iterableIteratorInstantiation = createIterableIteratorType(generatorElementType); // Naively, one could check that IterableIterator is assignable to the return type annotation. // However, that would not catch the error in the following case. @@ -10750,7 +10750,7 @@ namespace ts { function checkTypeForDuplicateIndexSignatures(node: Node) { if (node.kind === SyntaxKind.InterfaceDeclaration) { - let nodeSymbol = getSymbolOfNode(node); + const 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 if (nodeSymbol.declarations.length > 0 && nodeSymbol.declarations[0] !== node) { @@ -10761,12 +10761,12 @@ namespace ts { // TypeScript 1.0 spec (April 2014) // 3.7.4: An object type can contain at most one string index signature and one numeric index signature. // 8.5: A class declaration can have at most one string index member declaration and one numeric index member declaration - let indexSymbol = getIndexSymbol(getSymbolOfNode(node)); + const indexSymbol = getIndexSymbol(getSymbolOfNode(node)); if (indexSymbol) { let seenNumericIndexer = false; let seenStringIndexer = false; - for (let decl of indexSymbol.declarations) { - let declaration = decl; + for (const decl of indexSymbol.declarations) { + const declaration = decl; if (declaration.parameters.length === 1 && declaration.parameters[0].type) { switch (declaration.parameters[0].type.kind) { case SyntaxKind.StringKeyword: @@ -10820,8 +10820,8 @@ namespace ts { checkSourceElement(node.body); - let symbol = getSymbolOfNode(node); - let firstDeclaration = getDeclarationOfKind(symbol, node.kind); + const symbol = getSymbolOfNode(node); + const firstDeclaration = getDeclarationOfKind(symbol, node.kind); // Only type check the symbol once if (node === firstDeclaration) { checkFunctionOrConstructorSymbol(symbol); @@ -10875,11 +10875,11 @@ namespace ts { // TS 1.0 spec (April 2014): 8.3.2 // Constructors of classes with no extends clause may not contain super calls, whereas // constructors of derived classes must contain at least one super call somewhere in their function body. - let containingClassDecl = node.parent; + const containingClassDecl = node.parent; if (getClassExtendsHeritageClauseElement(containingClassDecl)) { - let containingClassSymbol = getSymbolOfNode(containingClassDecl); - let containingClassInstanceType = getDeclaredTypeOfSymbol(containingClassSymbol); - let baseConstructorType = getBaseConstructorTypeOfClass(containingClassInstanceType); + const containingClassSymbol = getSymbolOfNode(containingClassDecl); + const containingClassInstanceType = getDeclaredTypeOfSymbol(containingClassSymbol); + const baseConstructorType = getBaseConstructorTypeOfClass(containingClassInstanceType); if (containsSuperCall(node.body)) { if (baseConstructorType === nullType) { @@ -10891,16 +10891,16 @@ namespace ts { // - The containing class is a derived class. // - The constructor declares parameter properties // or the containing class declares instance member variables with initializers. - let superCallShouldBeFirst = + const superCallShouldBeFirst = forEach((node.parent).members, isInstancePropertyWithInitializer) || forEach(node.parameters, p => p.flags & (NodeFlags.Public | NodeFlags.Private | NodeFlags.Protected)); // Skip past any prologue directives to find the first statement // to ensure that it was a super call. if (superCallShouldBeFirst) { - let statements = (node.body).statements; + const statements = (node.body).statements; let superCallStatement: ExpressionStatement; - for (let statement of statements) { + for (const statement of statements) { if (statement.kind === SyntaxKind.ExpressionStatement && isSuperCallExpression((statement).expression)) { superCallStatement = statement; break; @@ -10945,15 +10945,15 @@ namespace ts { if (!hasDynamicName(node)) { // TypeScript 1.0 spec (April 2014): 8.4.3 // Accessors for the same member name must specify the same accessibility. - let otherKind = node.kind === SyntaxKind.GetAccessor ? SyntaxKind.SetAccessor : SyntaxKind.GetAccessor; - let otherAccessor = getDeclarationOfKind(node.symbol, otherKind); + const otherKind = node.kind === SyntaxKind.GetAccessor ? SyntaxKind.SetAccessor : SyntaxKind.GetAccessor; + const otherAccessor = getDeclarationOfKind(node.symbol, otherKind); if (otherAccessor) { if (((node.flags & NodeFlags.AccessibilityModifier) !== (otherAccessor.flags & NodeFlags.AccessibilityModifier))) { error(node.name, Diagnostics.Getter_and_setter_accessors_do_not_agree_in_visibility); } - let currentAccessorType = getAnnotatedAccessorType(node); - let otherAccessorType = getAnnotatedAccessorType(otherAccessor); + const currentAccessorType = getAnnotatedAccessorType(node); + const otherAccessorType = getAnnotatedAccessorType(otherAccessor); // TypeScript 1.0 spec (April 2014): 4.5 // If both accessors include type annotations, the specified types must be identical. if (currentAccessorType && otherAccessorType) { @@ -10976,9 +10976,9 @@ namespace ts { function checkTypeArgumentConstraints(typeParameters: TypeParameter[], typeArguments: TypeNode[]): boolean { let result = true; for (let i = 0; i < typeParameters.length; i++) { - let constraint = getConstraintOfTypeParameter(typeParameters[i]); + const constraint = getConstraintOfTypeParameter(typeParameters[i]); if (constraint) { - let typeArgument = typeArguments[i]; + const typeArgument = typeArguments[i]; result = result && checkTypeAssignableTo(getTypeFromTypeNode(typeArgument), constraint, typeArgument, Diagnostics.Type_0_does_not_satisfy_the_constraint_1); } } @@ -10987,13 +10987,13 @@ namespace ts { function checkTypeReferenceNode(node: TypeReferenceNode | ExpressionWithTypeArguments) { checkGrammarTypeArguments(node, node.typeArguments); - let type = getTypeFromTypeReference(node); + const type = getTypeFromTypeReference(node); if (type !== unknownType && node.typeArguments) { // Do type argument local checks only if referenced type is successfully resolved forEach(node.typeArguments, checkSourceElement); if (produceDiagnostics) { - let symbol = getNodeLinks(node).resolvedSymbol; - let typeParameters = symbol.flags & SymbolFlags.TypeAlias ? getSymbolLinks(symbol).typeParameters : (type).target.localTypeParameters; + const symbol = getNodeLinks(node).resolvedSymbol; + const typeParameters = symbol.flags & SymbolFlags.TypeAlias ? getSymbolLinks(symbol).typeParameters : (type).target.localTypeParameters; checkTypeArgumentConstraints(typeParameters, node.typeArguments); } } @@ -11006,7 +11006,7 @@ namespace ts { function checkTypeLiteral(node: TypeLiteralNode) { forEach(node.members, checkSourceElement); if (produceDiagnostics) { - let type = getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node); + const type = getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node); checkIndexConstraints(type); checkTypeForDuplicateIndexSignatures(node); } @@ -11018,7 +11018,7 @@ namespace ts { function checkTupleType(node: TupleTypeNode) { // Grammar checking - let hasErrorFromDisallowedTrailingComma = checkGrammarForDisallowedTrailingComma(node.elementTypes); + const hasErrorFromDisallowedTrailingComma = checkGrammarForDisallowedTrailingComma(node.elementTypes); if (!hasErrorFromDisallowedTrailingComma && node.elementTypes.length === 0) { grammarErrorOnNode(node, Diagnostics.A_tuple_type_element_list_cannot_be_empty); } @@ -11038,7 +11038,7 @@ namespace ts { if (!produceDiagnostics) { return; } - let signature = getSignatureFromDeclaration(signatureDeclarationNode); + const signature = getSignatureFromDeclaration(signatureDeclarationNode); if (!signature.hasStringLiterals) { return; } @@ -11058,16 +11058,16 @@ namespace ts { // Use declaring type to obtain full list of signatures. if (!signatureDeclarationNode.name && signatureDeclarationNode.parent && signatureDeclarationNode.parent.kind === SyntaxKind.InterfaceDeclaration) { Debug.assert(signatureDeclarationNode.kind === SyntaxKind.CallSignature || signatureDeclarationNode.kind === SyntaxKind.ConstructSignature); - let signatureKind = signatureDeclarationNode.kind === SyntaxKind.CallSignature ? SignatureKind.Call : SignatureKind.Construct; - let containingSymbol = getSymbolOfNode(signatureDeclarationNode.parent); - let containingType = getDeclaredTypeOfSymbol(containingSymbol); + const signatureKind = signatureDeclarationNode.kind === SyntaxKind.CallSignature ? SignatureKind.Call : SignatureKind.Construct; + const containingSymbol = getSymbolOfNode(signatureDeclarationNode.parent); + const containingType = getDeclaredTypeOfSymbol(containingSymbol); signaturesToCheck = getSignaturesOfType(containingType, signatureKind); } else { signaturesToCheck = getSignaturesOfSymbol(getSymbolOfNode(signatureDeclarationNode)); } - for (let otherSignature of signaturesToCheck) { + for (const otherSignature of signaturesToCheck) { if (!otherSignature.hasStringLiterals && isSignatureAssignableTo(signature, otherSignature)) { return; } @@ -11106,19 +11106,19 @@ namespace ts { // The caveat is that if some overloads are defined in lib.d.ts, we don't want to // report the errors on those. To achieve this, we will say that the implementation is // the canonical signature only if it is in the same container as the first overload - let implementationSharesContainerWithFirstOverload = implementation !== undefined && implementation.parent === overloads[0].parent; + const implementationSharesContainerWithFirstOverload = implementation !== undefined && implementation.parent === overloads[0].parent; return implementationSharesContainerWithFirstOverload ? implementation : overloads[0]; } function checkFlagAgreementBetweenOverloads(overloads: Declaration[], implementation: FunctionLikeDeclaration, flagsToCheck: NodeFlags, someOverloadFlags: NodeFlags, allOverloadFlags: NodeFlags): void { // Error if some overloads have a flag that is not shared by all overloads. To find the // deviations, we XOR someOverloadFlags with allOverloadFlags - let someButNotAllOverloadFlags = someOverloadFlags ^ allOverloadFlags; + const someButNotAllOverloadFlags = someOverloadFlags ^ allOverloadFlags; if (someButNotAllOverloadFlags !== 0) { - let canonicalFlags = getEffectiveDeclarationFlags(getCanonicalOverload(overloads, implementation), flagsToCheck); + const canonicalFlags = getEffectiveDeclarationFlags(getCanonicalOverload(overloads, implementation), flagsToCheck); forEach(overloads, o => { - let deviation = getEffectiveDeclarationFlags(o, flagsToCheck) ^ canonicalFlags; + const deviation = getEffectiveDeclarationFlags(o, flagsToCheck) ^ canonicalFlags; if (deviation & NodeFlags.Export) { error(o.name, Diagnostics.Overload_signatures_must_all_be_exported_or_not_exported); } @@ -11137,9 +11137,9 @@ namespace ts { function checkQuestionTokenAgreementBetweenOverloads(overloads: Declaration[], implementation: FunctionLikeDeclaration, someHaveQuestionToken: boolean, allHaveQuestionToken: boolean): void { if (someHaveQuestionToken !== allHaveQuestionToken) { - let canonicalHasQuestionToken = hasQuestionToken(getCanonicalOverload(overloads, implementation)); + const canonicalHasQuestionToken = hasQuestionToken(getCanonicalOverload(overloads, implementation)); forEach(overloads, o => { - let deviation = hasQuestionToken(o) !== canonicalHasQuestionToken; + const deviation = hasQuestionToken(o) !== canonicalHasQuestionToken; if (deviation) { error(o.name, Diagnostics.Overload_signatures_must_all_be_optional_or_required); } @@ -11147,7 +11147,7 @@ namespace ts { } } - let flagsToCheck: NodeFlags = NodeFlags.Export | NodeFlags.Ambient | NodeFlags.Private | NodeFlags.Protected | NodeFlags.Abstract; + const flagsToCheck: NodeFlags = NodeFlags.Export | NodeFlags.Ambient | NodeFlags.Private | NodeFlags.Protected | NodeFlags.Abstract; let someNodeFlags: NodeFlags = 0; let allNodeFlags = flagsToCheck; let someHaveQuestionToken = false; @@ -11157,8 +11157,8 @@ namespace ts { let lastSeenNonAmbientDeclaration: FunctionLikeDeclaration; let previousDeclaration: FunctionLikeDeclaration; - let declarations = symbol.declarations; - let isConstructor = (symbol.flags & SymbolFlags.Constructor) !== 0; + const declarations = symbol.declarations; + const isConstructor = (symbol.flags & SymbolFlags.Constructor) !== 0; function reportImplementationExpectedError(node: FunctionLikeDeclaration): void { if (node.name && nodeIsMissing(node.name)) { @@ -11166,7 +11166,7 @@ namespace ts { } let seen = false; - let subsequentNode = forEachChild(node.parent, c => { + const subsequentNode = forEachChild(node.parent, c => { if (seen) { return c; } @@ -11176,13 +11176,13 @@ namespace ts { }); if (subsequentNode) { if (subsequentNode.kind === node.kind) { - let errorNode: Node = (subsequentNode).name || subsequentNode; + const errorNode: Node = (subsequentNode).name || subsequentNode; // TODO(jfreeman): These are methods, so handle computed name case if (node.name && (subsequentNode).name && (node.name).text === ((subsequentNode).name).text) { // the only situation when this is possible (same kind\same name but different symbol) - mixed static and instance class members Debug.assert(node.kind === SyntaxKind.MethodDeclaration || node.kind === SyntaxKind.MethodSignature); Debug.assert((node.flags & NodeFlags.Static) !== (subsequentNode.flags & NodeFlags.Static)); - let diagnostic = node.flags & NodeFlags.Static ? Diagnostics.Function_overload_must_be_static : Diagnostics.Function_overload_must_not_be_static; + const diagnostic = node.flags & NodeFlags.Static ? Diagnostics.Function_overload_must_be_static : Diagnostics.Function_overload_must_not_be_static; error(errorNode, diagnostic); return; } @@ -11192,7 +11192,7 @@ namespace ts { } } } - let errorNode: Node = node.name || node; + const errorNode: Node = node.name || node; if (isConstructor) { error(errorNode, Diagnostics.Constructor_implementation_is_missing); } @@ -11210,13 +11210,13 @@ namespace ts { // when checking exported function declarations across modules check only duplicate implementations // names and consistency of modifiers are verified when we check local symbol - let isExportSymbolInsideModule = symbol.parent && symbol.parent.flags & SymbolFlags.Module; + const isExportSymbolInsideModule = symbol.parent && symbol.parent.flags & SymbolFlags.Module; let duplicateFunctionDeclaration = false; let multipleConstructorImplementation = false; - for (let current of declarations) { - let node = current; - let inAmbientContext = isInAmbientContext(node); - let inAmbientContextOrInterface = node.parent.kind === SyntaxKind.InterfaceDeclaration || node.parent.kind === SyntaxKind.TypeLiteral || inAmbientContext; + for (const current of declarations) { + const node = current; + const inAmbientContext = isInAmbientContext(node); + const inAmbientContextOrInterface = node.parent.kind === SyntaxKind.InterfaceDeclaration || node.parent.kind === SyntaxKind.TypeLiteral || inAmbientContext; if (inAmbientContextOrInterface) { // check if declarations are consecutive only if they are non-ambient // 1. ambient declarations can be interleaved @@ -11229,7 +11229,7 @@ namespace ts { } if (node.kind === SyntaxKind.FunctionDeclaration || node.kind === SyntaxKind.MethodDeclaration || node.kind === SyntaxKind.MethodSignature || node.kind === SyntaxKind.Constructor) { - let currentNodeFlags = getEffectiveDeclarationFlags(node, flagsToCheck); + const currentNodeFlags = getEffectiveDeclarationFlags(node, flagsToCheck); someNodeFlags |= currentNodeFlags; allNodeFlags &= currentNodeFlags; someHaveQuestionToken = someHaveQuestionToken || hasQuestionToken(node); @@ -11287,8 +11287,8 @@ namespace ts { checkQuestionTokenAgreementBetweenOverloads(declarations, bodyDeclaration, someHaveQuestionToken, allHaveQuestionToken); if (bodyDeclaration) { - let signatures = getSignaturesOfSymbol(symbol); - let bodySignature = getSignatureFromDeclaration(bodyDeclaration); + const signatures = getSignaturesOfSymbol(symbol); + const bodySignature = getSignatureFromDeclaration(bodyDeclaration); // If the implementation signature has string literals, we will have reported an error in // checkSpecializedSignatureDeclaration if (!bodySignature.hasStringLiterals) { @@ -11306,7 +11306,7 @@ namespace ts { // function g(x: string, y: string) { } // // The implementation is completely unrelated to the specialized signature, yet we do not check this. - for (let signature of signatures) { + for (const signature of signatures) { if (!signature.hasStringLiterals && !isSignatureAssignableTo(bodySignature, signature)) { error(signature.declaration, Diagnostics.Overload_signature_is_not_compatible_with_function_implementation); break; @@ -11344,9 +11344,9 @@ namespace ts { let exportedDeclarationSpaces = SymbolFlags.None; let nonExportedDeclarationSpaces = SymbolFlags.None; let defaultExportedDeclarationSpaces = SymbolFlags.None; - for (let d of symbol.declarations) { - let declarationSpaces = getDeclarationSpaces(d); - let effectiveDeclarationFlags = getEffectiveDeclarationFlags(d, NodeFlags.Export | NodeFlags.Default); + for (const d of symbol.declarations) { + const declarationSpaces = getDeclarationSpaces(d); + const effectiveDeclarationFlags = getEffectiveDeclarationFlags(d, NodeFlags.Export | NodeFlags.Default); if (effectiveDeclarationFlags & NodeFlags.Export) { if (effectiveDeclarationFlags & NodeFlags.Default) { @@ -11362,15 +11362,15 @@ namespace ts { } // Spaces for anyting not declared a 'default export'. - let nonDefaultExportedDeclarationSpaces = exportedDeclarationSpaces | nonExportedDeclarationSpaces; + const nonDefaultExportedDeclarationSpaces = exportedDeclarationSpaces | nonExportedDeclarationSpaces; - let commonDeclarationSpacesForExportsAndLocals = exportedDeclarationSpaces & nonExportedDeclarationSpaces; - let commonDeclarationSpacesForDefaultAndNonDefault = defaultExportedDeclarationSpaces & nonDefaultExportedDeclarationSpaces; + const commonDeclarationSpacesForExportsAndLocals = exportedDeclarationSpaces & nonExportedDeclarationSpaces; + const commonDeclarationSpacesForDefaultAndNonDefault = defaultExportedDeclarationSpaces & nonDefaultExportedDeclarationSpaces; if (commonDeclarationSpacesForExportsAndLocals || commonDeclarationSpacesForDefaultAndNonDefault) { // declaration spaces for exported and non-exported declarations intersect - for (let d of symbol.declarations) { - let declarationSpaces = getDeclarationSpaces(d); + for (const d of symbol.declarations) { + const declarationSpaces = getDeclarationSpaces(d); // Only error on the declarations that conributed to the intersecting spaces. if (declarationSpaces & commonDeclarationSpacesForDefaultAndNonDefault) { @@ -11395,7 +11395,7 @@ namespace ts { return SymbolFlags.ExportType | SymbolFlags.ExportValue; case SyntaxKind.ImportEqualsDeclaration: let result: SymbolFlags = 0; - let target = resolveAlias(getSymbolOfNode(d)); + const target = resolveAlias(getSymbolOfNode(d)); forEach(target.declarations, d => { result |= getDeclarationSpaces(d); }); return result; default: @@ -11445,32 +11445,32 @@ namespace ts { return (promise).typeArguments[0]; } - let globalPromiseLikeType = getInstantiatedGlobalPromiseLikeType(); + const globalPromiseLikeType = getInstantiatedGlobalPromiseLikeType(); if (globalPromiseLikeType === emptyObjectType || !isTypeAssignableTo(promise, globalPromiseLikeType)) { return undefined; } - let thenFunction = getTypeOfPropertyOfType(promise, "then"); + const thenFunction = getTypeOfPropertyOfType(promise, "then"); if (thenFunction && (thenFunction.flags & TypeFlags.Any)) { return undefined; } - let thenSignatures = thenFunction ? getSignaturesOfType(thenFunction, SignatureKind.Call) : emptyArray; + const thenSignatures = thenFunction ? getSignaturesOfType(thenFunction, SignatureKind.Call) : emptyArray; if (thenSignatures.length === 0) { return undefined; } - let onfulfilledParameterType = getUnionType(map(thenSignatures, getTypeOfFirstParameterOfSignature)); + const onfulfilledParameterType = getUnionType(map(thenSignatures, getTypeOfFirstParameterOfSignature)); if (onfulfilledParameterType.flags & TypeFlags.Any) { return undefined; } - let onfulfilledParameterSignatures = getSignaturesOfType(onfulfilledParameterType, SignatureKind.Call); + const onfulfilledParameterSignatures = getSignaturesOfType(onfulfilledParameterType, SignatureKind.Call); if (onfulfilledParameterSignatures.length === 0) { return undefined; } - let valueParameterType = getUnionType(map(onfulfilledParameterSignatures, getTypeOfFirstParameterOfSignature)); + const valueParameterType = getUnionType(map(onfulfilledParameterSignatures, getTypeOfFirstParameterOfSignature)); return valueParameterType; } @@ -11494,15 +11494,15 @@ namespace ts { function checkAwaitedTypeWorker(type: Type): Type { if (type.flags & TypeFlags.Union) { - let types: Type[] = []; - for (let constituentType of (type).types) { + const types: Type[] = []; + for (const constituentType of (type).types) { types.push(checkAwaitedTypeWorker(constituentType)); } return getUnionType(types); } else { - let promisedType = getPromisedType(type); + const promisedType = getPromisedType(type); if (promisedType === undefined) { // The type was not a PromiseLike, so it could not be unwrapped any further. // As long as the type does not have a callable "then" property, it is @@ -11569,7 +11569,7 @@ namespace ts { // Keep track of the type we're about to unwrap to avoid bad recursive promise types. // See the comments above for more information. awaitedTypeStack.push(type.id); - let awaitedType = checkAwaitedTypeWorker(promisedType); + const awaitedType = checkAwaitedTypeWorker(promisedType); awaitedTypeStack.pop(); return awaitedType; } @@ -11591,7 +11591,7 @@ namespace ts { * callable `then` signature. */ function checkAsyncFunctionReturnType(node: FunctionLikeDeclaration): Type { - let globalPromiseConstructorLikeType = getGlobalPromiseConstructorLikeType(); + const globalPromiseConstructorLikeType = getGlobalPromiseConstructorLikeType(); if (globalPromiseConstructorLikeType === emptyObjectType) { // If we couldn't resolve the global PromiseConstructorLike type we cannot verify // compatibility with __awaiter. @@ -11625,16 +11625,16 @@ namespace ts { // When we get the type of the `Promise` symbol here, we get the type of the static // side of the `Promise` class, which would be `{ new (...): Promise }`. - let promiseType = getTypeFromTypeNode(node.type); + const promiseType = getTypeFromTypeNode(node.type); if (promiseType === unknownType && compilerOptions.isolatedModules) { // If we are compiling with isolatedModules, we may not be able to resolve the // type as a value. As such, we will just return unknownType; return unknownType; } - let promiseConstructor = getNodeLinks(node.type).resolvedSymbol; + const promiseConstructor = getNodeLinks(node.type).resolvedSymbol; if (!promiseConstructor || !symbolIsValue(promiseConstructor)) { - let typeName = promiseConstructor + const typeName = promiseConstructor ? symbolToString(promiseConstructor) : typeToString(promiseType); error(node, Diagnostics.Type_0_is_not_a_valid_async_function_return_type, typeName); @@ -11642,15 +11642,15 @@ namespace ts { } // Validate the promise constructor type. - let promiseConstructorType = getTypeOfSymbol(promiseConstructor); + const promiseConstructorType = getTypeOfSymbol(promiseConstructor); if (!checkTypeAssignableTo(promiseConstructorType, globalPromiseConstructorLikeType, node, Diagnostics.Type_0_is_not_a_valid_async_function_return_type)) { return unknownType; } // Verify there is no local declaration that could collide with the promise constructor. - let promiseName = getEntityNameFromTypeNode(node.type); - let root = getFirstIdentifier(promiseName); - let rootSymbol = getSymbol(node.locals, root.text, SymbolFlags.Value); + const promiseName = getEntityNameFromTypeNode(node.type); + const root = getFirstIdentifier(promiseName); + const rootSymbol = getSymbol(node.locals, root.text, SymbolFlags.Value); if (rootSymbol) { error(rootSymbol.valueDeclaration, Diagnostics.Duplicate_identifier_0_Compiler_uses_declaration_1_to_support_async_functions, root.text, @@ -11664,19 +11664,19 @@ namespace ts { /** Check a decorator */ function checkDecorator(node: Decorator): void { - let signature = getResolvedSignature(node); - let returnType = getReturnTypeOfSignature(signature); + const signature = getResolvedSignature(node); + const returnType = getReturnTypeOfSignature(signature); if (returnType.flags & TypeFlags.Any) { return; } let expectedReturnType: Type; - let headMessage = getDiagnosticHeadMessageForDecoratorResolution(node); + const headMessage = getDiagnosticHeadMessageForDecoratorResolution(node); let errorInfo: DiagnosticMessageChain; switch (node.parent.kind) { case SyntaxKind.ClassDeclaration: - let classSymbol = getSymbolOfNode(node.parent); - let classConstructorType = getTypeOfSymbol(classSymbol); + const classSymbol = getSymbolOfNode(node.parent); + const classConstructorType = getTypeOfSymbol(classSymbol); expectedReturnType = getUnionType([classConstructorType, voidType]); break; @@ -11698,8 +11698,8 @@ namespace ts { case SyntaxKind.MethodDeclaration: case SyntaxKind.GetAccessor: case SyntaxKind.SetAccessor: - let methodType = getTypeOfNode(node.parent); - let descriptorType = createTypedPropertyDescriptorType(methodType); + const methodType = getTypeOfNode(node.parent); + const descriptorType = createTypedPropertyDescriptorType(methodType); expectedReturnType = getUnionType([descriptorType, voidType]); break; } @@ -11718,13 +11718,13 @@ namespace ts { // 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 === SyntaxKind.TypeReference) { - let root = getFirstIdentifier((node).typeName); - let meaning = root.parent.kind === SyntaxKind.TypeReference ? SymbolFlags.Type : SymbolFlags.Namespace; + const root = getFirstIdentifier((node).typeName); + const meaning = root.parent.kind === SyntaxKind.TypeReference ? SymbolFlags.Type : SymbolFlags.Namespace; // Resolve type so we know which symbol is referenced - let rootSymbol = resolveName(root, root.text, meaning | SymbolFlags.Alias, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined); + const rootSymbol = resolveName(root, root.text, meaning | SymbolFlags.Alias, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined); // Resolved symbol is alias if (rootSymbol && rootSymbol.flags & SymbolFlags.Alias) { - let aliasTarget = resolveAlias(rootSymbol); + const aliasTarget = resolveAlias(rootSymbol); // If alias has value symbol - mark alias as referenced if (aliasTarget.flags & SymbolFlags.Value && !isConstEnumOrConstEnumOnlyModule(resolveAlias(rootSymbol))) { markAliasSymbolAsReferenced(rootSymbol); @@ -11760,7 +11760,7 @@ namespace ts { /** Checks the type annotation of the parameters of a function/method or the constructor of a class as expressions */ function checkParameterTypeAnnotationsAsExpressions(node: FunctionLikeDeclaration) { // ensure all type annotations with a value declaration are checked as an expression - for (let parameter of node.parameters) { + for (const parameter of node.parameters) { checkTypeAnnotationAsExpression(parameter); } } @@ -11785,7 +11785,7 @@ namespace ts { // we only need to perform these checks if we are emitting serialized type metadata for the target of a decorator. switch (node.kind) { case SyntaxKind.ClassDeclaration: - let constructor = getFirstConstructorWithBody(node); + const constructor = getFirstConstructorWithBody(node); if (constructor) { checkParameterTypeAnnotationsAsExpressions(constructor); } @@ -11825,7 +11825,7 @@ namespace ts { function checkFunctionLikeDeclaration(node: FunctionLikeDeclaration): void { checkDecorators(node); checkSignatureDeclaration(node); - let isAsync = isAsyncFunctionLike(node); + const isAsync = isAsyncFunctionLike(node); if (isAsync) { emitAwaiter = true; } @@ -11843,10 +11843,10 @@ namespace ts { // first we want to check the local symbol that contain this declaration // - if node.localSymbol !== undefined - this is current declaration is exported and localSymbol points to the local symbol // - if node.localSymbol === undefined - this node is non-exported so we can just pick the result of getSymbolOfNode - let symbol = getSymbolOfNode(node); - let localSymbol = node.localSymbol || symbol; + const symbol = getSymbolOfNode(node); + const localSymbol = node.localSymbol || symbol; - let firstDeclaration = getDeclarationOfKind(localSymbol, node.kind); + const firstDeclaration = getDeclarationOfKind(localSymbol, node.kind); // Only type check the symbol once if (node === firstDeclaration) { checkFunctionOrConstructorSymbol(localSymbol); @@ -11863,7 +11863,7 @@ namespace ts { checkSourceElement(node.body); if (node.type && !isAccessor(node.kind) && !node.asteriskToken) { - let returnType = getTypeFromTypeNode(node.type); + const returnType = getTypeFromTypeNode(node.type); let promisedType: Type; if (isAsync) { promisedType = checkAsyncFunctionReturnType(node); @@ -11933,7 +11933,7 @@ namespace ts { return false; } - let root = getRootDeclaration(node); + const root = getRootDeclaration(node); if (root.kind === SyntaxKind.Parameter && nodeIsMissing((root.parent).body)) { // just an overload - no codegen impact return false; @@ -11953,7 +11953,7 @@ namespace ts { let current = node; while (current) { if (getNodeCheckFlags(current) & NodeCheckFlags.CaptureThis) { - let isDeclaration = node.kind !== SyntaxKind.Identifier; + const isDeclaration = node.kind !== SyntaxKind.Identifier; if (isDeclaration) { error((node).name, Diagnostics.Duplicate_identifier_this_Compiler_uses_variable_declaration_this_to_capture_this_reference); } @@ -11972,14 +11972,14 @@ namespace ts { } // bubble up and find containing type - let enclosingClass = getContainingClass(node); + const enclosingClass = getContainingClass(node); // if containing type was not found or it is ambient - exit (no codegen) if (!enclosingClass || isInAmbientContext(enclosingClass)) { return; } if (getClassExtendsHeritageClauseElement(enclosingClass)) { - let isDeclaration = node.kind !== SyntaxKind.Identifier; + const isDeclaration = node.kind !== SyntaxKind.Identifier; if (isDeclaration) { error(node, Diagnostics.Duplicate_identifier_super_Compiler_uses_super_to_capture_base_class_reference); } @@ -12000,7 +12000,7 @@ namespace ts { } // In case of variable declaration, node.parent is variable statement so look at the variable statement's parent - let parent = getDeclarationContainer(node); + const parent = getDeclarationContainer(node); if (parent.kind === SyntaxKind.SourceFile && isExternalModule(parent)) { // If the declaration happens to be in external module, report error that require and exports are reserved keywords error(name, Diagnostics.Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module, @@ -12023,15 +12023,15 @@ namespace ts { // A non-initialized declaration is a no-op as the block declaration will resolve before the var // declaration. the problem is if the declaration has an initializer. this will act as a write to the // block declared value. this is fine for let, but not const. - // Only consider declarations with initializers, uninitialized let declarations will not + // Only consider declarations with initializers, uninitialized const declarations will not // step on a let/const variable. - // Do not consider let and const declarations, as duplicate block-scoped declarations + // Do not consider const and const declarations, as duplicate block-scoped declarations // are handled by the binder. - // We are only looking for let declarations that step on let\const declarations from a + // We are only looking for const declarations that step on let\const declarations from a // different scope. e.g.: // { // const x = 0; // localDeclarationSymbol obtained after name resolution will correspond to this declaration - // let x = 0; // symbol for this declaration will be 'symbol' + // const x = 0; // symbol for this declaration will be 'symbol' // } // skip block-scoped variables and parameters @@ -12046,22 +12046,22 @@ namespace ts { return; } - let symbol = getSymbolOfNode(node); + const symbol = getSymbolOfNode(node); if (symbol.flags & SymbolFlags.FunctionScopedVariable) { - let localDeclarationSymbol = resolveName(node, (node.name).text, SymbolFlags.Variable, /*nodeNotFoundErrorMessage*/ undefined, /*nameArg*/ undefined); + const localDeclarationSymbol = resolveName(node, (node.name).text, SymbolFlags.Variable, /*nodeNotFoundErrorMessage*/ undefined, /*nameArg*/ undefined); if (localDeclarationSymbol && localDeclarationSymbol !== symbol && localDeclarationSymbol.flags & SymbolFlags.BlockScopedVariable) { if (getDeclarationFlagsFromSymbol(localDeclarationSymbol) & NodeFlags.BlockScoped) { - let varDeclList = getAncestor(localDeclarationSymbol.valueDeclaration, SyntaxKind.VariableDeclarationList); - let container = + const varDeclList = getAncestor(localDeclarationSymbol.valueDeclaration, SyntaxKind.VariableDeclarationList); + const container = varDeclList.parent.kind === SyntaxKind.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) - let namesShareScope = + const namesShareScope = container && (container.kind === SyntaxKind.Block && isFunctionLike(container.parent) || container.kind === SyntaxKind.ModuleBlock || @@ -12073,7 +12073,7 @@ namespace ts { // otherwise if variable has an initializer - show error that initialization will fail // since LHS will be block scoped name instead of function scoped if (!namesShareScope) { - let name = symbolToString(localDeclarationSymbol); + const name = symbolToString(localDeclarationSymbol); error(node, Diagnostics.Cannot_initialize_outer_scoped_variable_0_in_the_same_scope_as_block_scoped_declaration_1, name, name); } } @@ -12087,12 +12087,12 @@ namespace ts { return; } - let func = getContainingFunction(node); + const func = getContainingFunction(node); visit(node.initializer); function visit(n: Node) { if (n.kind === SyntaxKind.Identifier) { - let referencedSymbol = getNodeLinks(n).resolvedSymbol; + const referencedSymbol = getNodeLinks(n).resolvedSymbol; // check FunctionLikeDeclaration.locals (stores parameters\function local variable) // if it contains entry with a specified name and if this entry matches the resolved symbol if (referencedSymbol && referencedSymbol !== unknownSymbol && getSymbol(func.locals, referencedSymbol.name, SymbolFlags.Value) === referencedSymbol) { @@ -12147,8 +12147,8 @@ namespace ts { } return; } - let symbol = getSymbolOfNode(node); - let type = getTypeOfVariableOrParameterOrProperty(symbol); + const symbol = getSymbolOfNode(node); + const type = getTypeOfVariableOrParameterOrProperty(symbol); if (node === symbol.valueDeclaration) { // Node is the primary declaration of the symbol, just validate the initializer if (node.initializer) { @@ -12159,7 +12159,7 @@ namespace 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 - let declarationType = getWidenedTypeForVariableLikeDeclaration(node); + const declarationType = getWidenedTypeForVariableLikeDeclaration(node); if (type !== unknownType && declarationType !== unknownType && !isTypeIdenticalTo(type, declarationType)) { error(node.name, Diagnostics.Subsequent_variable_declarations_must_have_the_same_type_Variable_0_must_be_of_type_1_but_here_has_type_2, declarationNameToString(node.name), typeToString(type), typeToString(declarationType)); } @@ -12281,8 +12281,8 @@ namespace ts { checkForInOrForOfVariableDeclaration(node); } else { - let varExpr = node.initializer; - let iteratedType = checkRightHandSideOfForOf(node.expression); + const varExpr = node.initializer; + const iteratedType = checkRightHandSideOfForOf(node.expression); // There may be a destructuring assignment on the left side if (varExpr.kind === SyntaxKind.ArrayLiteralExpression || varExpr.kind === SyntaxKind.ObjectLiteralExpression) { @@ -12292,7 +12292,7 @@ namespace ts { checkDestructuringAssignment(varExpr, iteratedType || unknownType); } else { - let leftType = checkExpression(varExpr); + const leftType = checkExpression(varExpr); checkReferenceExpression(varExpr, /*invalidReferenceMessage*/ Diagnostics.Invalid_left_hand_side_in_for_of_statement, /*constantVariableMessage*/ Diagnostics.The_left_hand_side_of_a_for_of_statement_cannot_be_a_previously_defined_constant); @@ -12319,7 +12319,7 @@ namespace ts { // 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 === SyntaxKind.VariableDeclarationList) { - let variable = (node.initializer).declarations[0]; + const variable = (node.initializer).declarations[0]; if (variable && isBindingPattern(variable.name)) { error(variable.name, Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern); } @@ -12331,8 +12331,8 @@ namespace ts { // for (Var in Expr) Statement // Var must be an expression classified as a reference of type Any or the String primitive type, // and Expr must be an expression of type Any, an object type, or a type parameter type. - let varExpr = node.initializer; - let leftType = checkExpression(varExpr); + const varExpr = node.initializer; + const leftType = checkExpression(varExpr); if (varExpr.kind === SyntaxKind.ArrayLiteralExpression || varExpr.kind === SyntaxKind.ObjectLiteralExpression) { error(varExpr, Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern); } @@ -12345,7 +12345,7 @@ namespace ts { } } - let rightType = checkExpression(node.expression); + const rightType = checkExpression(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)) { @@ -12356,16 +12356,16 @@ namespace ts { } function checkForInOrForOfVariableDeclaration(iterationStatement: ForInStatement | ForOfStatement): void { - let variableDeclarationList = iterationStatement.initializer; + const variableDeclarationList = iterationStatement.initializer; // checkGrammarForInOrForOfStatement will check that there is exactly one declaration. if (variableDeclarationList.declarations.length >= 1) { - let decl = variableDeclarationList.declarations[0]; + const decl = variableDeclarationList.declarations[0]; checkVariableDeclaration(decl); } } function checkRightHandSideOfForOf(rhsExpression: Expression): Type { - let expressionType = getTypeOfExpression(rhsExpression); + const expressionType = getTypeOfExpression(rhsExpression); return checkIteratedTypeOrElementType(expressionType, rhsExpression, /*allowStringInput*/ true); } @@ -12383,7 +12383,7 @@ namespace ts { } if (isArrayLikeType(inputType)) { - let indexType = getIndexTypeOfType(inputType, IndexKind.Number); + const indexType = getIndexTypeOfType(inputType, IndexKind.Number); if (indexType) { return indexType; } @@ -12397,7 +12397,7 @@ namespace ts { * When errorNode is undefined, it means we should not report any errors. */ function checkElementTypeOfIterable(iterable: Type, errorNode: Node): Type { - let elementType = getElementTypeOfIterable(iterable, errorNode); + const elementType = getElementTypeOfIterable(iterable, errorNode); // Now even though we have extracted the iteratedType, we will have to validate that the type // passed in is actually an Iterable. if (errorNode && elementType) { @@ -12433,7 +12433,7 @@ namespace ts { return undefined; } - let typeAsIterable = type; + const typeAsIterable = type; if (!typeAsIterable.iterableElementType) { // As an optimization, if the type is instantiated directly using the globalIterableType (Iterable), // then just grab its type argument. @@ -12441,12 +12441,12 @@ namespace ts { typeAsIterable.iterableElementType = (type).typeArguments[0]; } else { - let iteratorFunction = getTypeOfPropertyOfType(type, getPropertyNameForKnownSymbolName("iterator")); + const iteratorFunction = getTypeOfPropertyOfType(type, getPropertyNameForKnownSymbolName("iterator")); if (isTypeAny(iteratorFunction)) { return undefined; } - let iteratorFunctionSignatures = iteratorFunction ? getSignaturesOfType(iteratorFunction, SignatureKind.Call) : emptyArray; + const iteratorFunctionSignatures = iteratorFunction ? getSignaturesOfType(iteratorFunction, SignatureKind.Call) : emptyArray; if (iteratorFunctionSignatures.length === 0) { if (errorNode) { error(errorNode, Diagnostics.Type_must_have_a_Symbol_iterator_method_that_returns_an_iterator); @@ -12479,7 +12479,7 @@ namespace ts { return undefined; } - let typeAsIterator = type; + const typeAsIterator = type; if (!typeAsIterator.iteratorElementType) { // As an optimization, if the type is instantiated directly using the globalIteratorType (Iterator), // then just grab its type argument. @@ -12487,12 +12487,12 @@ namespace ts { typeAsIterator.iteratorElementType = (type).typeArguments[0]; } else { - let iteratorNextFunction = getTypeOfPropertyOfType(type, "next"); + const iteratorNextFunction = getTypeOfPropertyOfType(type, "next"); if (isTypeAny(iteratorNextFunction)) { return undefined; } - let iteratorNextFunctionSignatures = iteratorNextFunction ? getSignaturesOfType(iteratorNextFunction, SignatureKind.Call) : emptyArray; + const iteratorNextFunctionSignatures = iteratorNextFunction ? getSignaturesOfType(iteratorNextFunction, SignatureKind.Call) : emptyArray; if (iteratorNextFunctionSignatures.length === 0) { if (errorNode) { error(errorNode, Diagnostics.An_iterator_must_have_a_next_method); @@ -12500,12 +12500,12 @@ namespace ts { return undefined; } - let iteratorNextResult = getUnionType(map(iteratorNextFunctionSignatures, getReturnTypeOfSignature)); + const iteratorNextResult = getUnionType(map(iteratorNextFunctionSignatures, getReturnTypeOfSignature)); if (isTypeAny(iteratorNextResult)) { return undefined; } - let iteratorNextValue = getTypeOfPropertyOfType(iteratorNextResult, "value"); + const iteratorNextValue = getTypeOfPropertyOfType(iteratorNextResult, "value"); if (!iteratorNextValue) { if (errorNode) { error(errorNode, Diagnostics.The_type_returned_by_the_next_method_of_an_iterator_must_have_a_value_property); @@ -12557,8 +12557,8 @@ namespace ts { // 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. - let arrayType = removeTypesFromUnionType(arrayOrStringType, TypeFlags.StringLike, /*isTypeOfKind*/ true, /*allowEmptyUnionResult*/ true); - let hasStringConstituent = arrayOrStringType !== arrayType; + const arrayType = removeTypesFromUnionType(arrayOrStringType, TypeFlags.StringLike, /*isTypeOfKind*/ true, /*allowEmptyUnionResult*/ true); + const hasStringConstituent = arrayOrStringType !== arrayType; let reportedError = false; if (hasStringConstituent) { @@ -12580,7 +12580,7 @@ namespace ts { // if the input type is number | string, we want to say that number is not an array type. // But if the input was just number, we want to say that number is not an array type // or a string type. - let diagnostic = hasStringConstituent + const diagnostic = hasStringConstituent ? Diagnostics.Type_0_is_not_an_array_type : Diagnostics.Type_0_is_not_an_array_type_or_a_string_type; error(errorNode, diagnostic, typeToString(arrayType)); @@ -12588,7 +12588,7 @@ namespace ts { return hasStringConstituent ? stringType : unknownType; } - let arrayElementType = getIndexTypeOfType(arrayType, IndexKind.Number) || unknownType; + const arrayElementType = getIndexTypeOfType(arrayType, IndexKind.Number) || unknownType; if (hasStringConstituent) { // This is just an optimization for the case where arrayOrStringType is string | string[] if (arrayElementType.flags & TypeFlags.StringLike) { @@ -12615,18 +12615,18 @@ namespace ts { function checkReturnStatement(node: ReturnStatement) { // Grammar checking if (!checkGrammarStatementInAmbientContext(node)) { - let functionBlock = getContainingFunction(node); + const functionBlock = getContainingFunction(node); if (!functionBlock) { grammarErrorOnFirstToken(node, Diagnostics.A_return_statement_can_only_be_used_within_a_function_body); } } if (node.expression) { - let func = getContainingFunction(node); + const func = getContainingFunction(node); if (func) { - let signature = getSignatureFromDeclaration(func); - let returnType = getReturnTypeOfSignature(signature); - let exprType = checkExpressionCached(node.expression); + const signature = getSignatureFromDeclaration(func); + const returnType = getReturnTypeOfSignature(signature); + const exprType = checkExpressionCached(node.expression); if (func.asteriskToken) { // A generator does not need its return expressions checked against its return type. @@ -12646,8 +12646,8 @@ namespace ts { } else if (func.type || isGetAccessorWithAnnotatatedSetAccessor(func) || signature.typePredicate) { if (isAsyncFunctionLike(func)) { - let promisedType = getPromisedType(returnType); - let awaitedType = checkAwaitedType(exprType, node.expression, Diagnostics.Return_expression_in_async_function_does_not_have_a_valid_callable_then_member); + const promisedType = getPromisedType(returnType); + const awaitedType = checkAwaitedType(exprType, node.expression, Diagnostics.Return_expression_in_async_function_does_not_have_a_valid_callable_then_member); if (promisedType) { // If the function has a return type, but promisedType is // undefined, an error will be reported in checkAsyncFunctionReturnType @@ -12682,7 +12682,7 @@ namespace ts { let firstDefaultClause: CaseOrDefaultClause; let hasDuplicateDefaultClause = false; - let expressionType = checkExpression(node.expression); + const expressionType = checkExpression(node.expression); forEach(node.caseBlock.clauses, clause => { // Grammar check for duplicate default clauses, skip if we already report duplicate default clause if (clause.kind === SyntaxKind.DefaultClause && !hasDuplicateDefaultClause) { @@ -12690,19 +12690,19 @@ namespace ts { firstDefaultClause = clause; } else { - let sourceFile = getSourceFileOfNode(node); - let start = skipTrivia(sourceFile.text, clause.pos); - let end = clause.statements.length > 0 ? clause.statements[0].pos : clause.end; + const sourceFile = getSourceFileOfNode(node); + const start = skipTrivia(sourceFile.text, clause.pos); + const end = clause.statements.length > 0 ? clause.statements[0].pos : clause.end; grammarErrorAtPos(sourceFile, start, end - start, Diagnostics.A_default_clause_cannot_appear_more_than_once_in_a_switch_statement); hasDuplicateDefaultClause = true; } } if (produceDiagnostics && clause.kind === SyntaxKind.CaseClause) { - let caseClause = clause; + const caseClause = clause; // TypeScript 1.0 spec (April 2014):5.9 // In a 'switch' statement, each 'case' expression must be of a type that is assignable to or from the type of the 'switch' expression. - let caseType = checkExpression(caseClause.expression); + const caseType = checkExpression(caseClause.expression); if (!isTypeAssignableTo(expressionType, caseType)) { // check 'expressionType isAssignableTo caseType' failed, try the reversed check and report errors if it fails checkTypeAssignableTo(caseType, expressionType, caseClause.expression, /*headMessage*/ undefined); @@ -12721,7 +12721,7 @@ namespace ts { break; } if (current.kind === SyntaxKind.LabeledStatement && (current).label.text === node.label.text) { - let sourceFile = getSourceFileOfNode(node); + const sourceFile = getSourceFileOfNode(node); grammarErrorOnNode(node.label, Diagnostics.Duplicate_label_0, getTextOfNodeFromSourceText(sourceFile.text, node.label)); break; } @@ -12751,7 +12751,7 @@ namespace ts { checkGrammarStatementInAmbientContext(node); checkBlock(node.tryBlock); - let catchClause = node.catchClause; + const catchClause = node.catchClause; if (catchClause) { // Grammar checking if (catchClause.variableDeclaration) { @@ -12765,10 +12765,10 @@ namespace ts { grammarErrorOnFirstToken(catchClause.variableDeclaration.initializer, Diagnostics.Catch_clause_variable_cannot_have_an_initializer); } else { - let identifierName = (catchClause.variableDeclaration.name).text; - let locals = catchClause.block.locals; + const identifierName = (catchClause.variableDeclaration.name).text; + const locals = catchClause.block.locals; if (locals && hasProperty(locals, identifierName)) { - let localSymbol = locals[identifierName]; + const localSymbol = locals[identifierName]; if (localSymbol && (localSymbol.flags & SymbolFlags.BlockScopedVariable) !== 0) { grammarErrorOnNode(localSymbol.valueDeclaration, Diagnostics.Cannot_redeclare_identifier_0_in_catch_clause, identifierName); } @@ -12785,27 +12785,27 @@ namespace ts { } function checkIndexConstraints(type: Type) { - let declaredNumberIndexer = getIndexDeclarationOfSymbol(type.symbol, IndexKind.Number); - let declaredStringIndexer = getIndexDeclarationOfSymbol(type.symbol, IndexKind.String); + const declaredNumberIndexer = getIndexDeclarationOfSymbol(type.symbol, IndexKind.Number); + const declaredStringIndexer = getIndexDeclarationOfSymbol(type.symbol, IndexKind.String); - let stringIndexType = getIndexTypeOfType(type, IndexKind.String); - let numberIndexType = getIndexTypeOfType(type, IndexKind.Number); + const stringIndexType = getIndexTypeOfType(type, IndexKind.String); + const numberIndexType = getIndexTypeOfType(type, IndexKind.Number); if (stringIndexType || numberIndexType) { forEach(getPropertiesOfObjectType(type), prop => { - let propType = getTypeOfSymbol(prop); + const propType = getTypeOfSymbol(prop); checkIndexConstraintForProperty(prop, propType, type, declaredStringIndexer, stringIndexType, IndexKind.String); checkIndexConstraintForProperty(prop, propType, type, declaredNumberIndexer, numberIndexType, IndexKind.Number); }); if (type.flags & TypeFlags.Class && isClassLike(type.symbol.valueDeclaration)) { - let classDeclaration = type.symbol.valueDeclaration; - for (let member of classDeclaration.members) { + const classDeclaration = type.symbol.valueDeclaration; + for (const member of classDeclaration.members) { // Only process instance properties with computed names here. // Static properties cannot be in conflict with indexers, // and properties with literal names were already checked. if (!(member.flags & NodeFlags.Static) && hasDynamicName(member)) { - let propType = getTypeOfSymbol(member.symbol); + const propType = getTypeOfSymbol(member.symbol); checkIndexConstraintForProperty(member.symbol, propType, type, declaredStringIndexer, stringIndexType, IndexKind.String); checkIndexConstraintForProperty(member.symbol, propType, type, declaredNumberIndexer, numberIndexType, IndexKind.Number); } @@ -12818,7 +12818,7 @@ namespace ts { errorNode = declaredNumberIndexer || declaredStringIndexer; // condition 'errorNode === undefined' may appear if types does not declare nor string neither number indexer if (!errorNode && (type.flags & TypeFlags.Interface)) { - let someBaseTypeHasBothIndexers = forEach(getBaseTypes(type), base => getIndexTypeOfType(base, IndexKind.String) && getIndexTypeOfType(base, IndexKind.Number)); + const someBaseTypeHasBothIndexers = forEach(getBaseTypes(type), base => getIndexTypeOfType(base, IndexKind.String) && getIndexTypeOfType(base, IndexKind.Number)); errorNode = someBaseTypeHasBothIndexers ? undefined : type.symbol.declarations[0]; } } @@ -12858,12 +12858,12 @@ namespace ts { // 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 - let someBaseClassHasBothPropertyAndIndexer = forEach(getBaseTypes(containingType), base => getPropertyOfObjectType(base, prop.name) && getIndexTypeOfType(base, indexKind)); + const someBaseClassHasBothPropertyAndIndexer = forEach(getBaseTypes(containingType), base => getPropertyOfObjectType(base, prop.name) && getIndexTypeOfType(base, indexKind)); errorNode = someBaseClassHasBothPropertyAndIndexer ? undefined : containingType.symbol.declarations[0]; } if (errorNode && !isTypeAssignableTo(propertyType, indexType)) { - let errorMessage = + const errorMessage = indexKind === IndexKind.String ? Diagnostics.Property_0_of_type_1_is_not_assignable_to_string_index_type_2 : Diagnostics.Property_0_of_type_1_is_not_assignable_to_numeric_index_type_2; @@ -12890,7 +12890,7 @@ namespace ts { function checkTypeParameters(typeParameterDeclarations: TypeParameterDeclaration[]) { if (typeParameterDeclarations) { for (let i = 0, n = typeParameterDeclarations.length; i < n; i++) { - let node = typeParameterDeclarations[i]; + const node = typeParameterDeclarations[i]; checkTypeParameter(node); if (produceDiagnostics) { @@ -12928,22 +12928,22 @@ namespace ts { } checkTypeParameters(node.typeParameters); checkExportsOnMergedDeclarations(node); - let symbol = getSymbolOfNode(node); - let type = getDeclaredTypeOfSymbol(symbol); - let typeWithThis = getTypeWithThisArgument(type); - let staticType = getTypeOfSymbol(symbol); + const symbol = getSymbolOfNode(node); + const type = getDeclaredTypeOfSymbol(symbol); + const typeWithThis = getTypeWithThisArgument(type); + const staticType = getTypeOfSymbol(symbol); - let baseTypeNode = getClassExtendsHeritageClauseElement(node); + const baseTypeNode = getClassExtendsHeritageClauseElement(node); if (baseTypeNode) { emitExtends = emitExtends || !isInAmbientContext(node); - let baseTypes = getBaseTypes(type); + const baseTypes = getBaseTypes(type); if (baseTypes.length && produceDiagnostics) { - let baseType = baseTypes[0]; - let staticBaseType = getBaseConstructorTypeOfClass(type); + const baseType = baseTypes[0]; + const staticBaseType = getBaseConstructorTypeOfClass(type); checkSourceElement(baseTypeNode.expression); if (baseTypeNode.typeArguments) { forEach(baseTypeNode.typeArguments, checkSourceElement); - for (let constructor of getConstructorsForTypeArguments(staticBaseType, baseTypeNode.typeArguments)) { + for (const constructor of getConstructorsForTypeArguments(staticBaseType, baseTypeNode.typeArguments)) { if (!checkTypeArgumentConstraints(constructor.typeParameters, baseTypeNode.typeArguments)) { break; } @@ -12958,7 +12958,7 @@ namespace ts { // that all instantiated base constructor signatures return the same type. We can simply compare the type // references (as opposed to checking the structure of the types) because elsewhere we have already checked // that the base type is a class or interface type (and not, for example, an anonymous object type). - let constructors = getInstantiatedConstructorsForTypeArguments(staticBaseType, baseTypeNode.typeArguments); + const constructors = getInstantiatedConstructorsForTypeArguments(staticBaseType, baseTypeNode.typeArguments); if (forEach(constructors, sig => getReturnTypeOfSignature(sig) !== baseType)) { error(baseTypeNode.expression, Diagnostics.Base_constructors_must_all_have_the_same_return_type); } @@ -12967,17 +12967,17 @@ namespace ts { } } - let implementedTypeNodes = getClassImplementsHeritageClauseElements(node); + const implementedTypeNodes = getClassImplementsHeritageClauseElements(node); if (implementedTypeNodes) { - for (let typeRefNode of implementedTypeNodes) { + for (const typeRefNode of implementedTypeNodes) { if (!isSupportedExpressionWithTypeArguments(typeRefNode)) { error(typeRefNode.expression, Diagnostics.A_class_can_only_implement_an_identifier_Slashqualified_name_with_optional_type_arguments); } checkTypeReferenceNode(typeRefNode); if (produceDiagnostics) { - let t = getTypeFromTypeNode(typeRefNode); + const t = getTypeFromTypeNode(typeRefNode); if (t !== unknownType) { - let declaredType = (t.flags & TypeFlags.Reference) ? (t).target : t; + const declaredType = (t.flags & TypeFlags.Reference) ? (t).target : t; if (declaredType.flags & (TypeFlags.Class | TypeFlags.Interface)) { checkTypeAssignableTo(typeWithThis, getTypeWithThisArgument(t, type.thisType), node.name || node, Diagnostics.Class_0_incorrectly_implements_interface_1); } @@ -13022,16 +13022,16 @@ namespace ts { // derived class instance member variables and accessors, but not by other kinds of members. // NOTE: assignability is checked in checkClassDeclaration - let baseProperties = getPropertiesOfObjectType(baseType); - for (let baseProperty of baseProperties) { - let base = getTargetSymbol(baseProperty); + const baseProperties = getPropertiesOfObjectType(baseType); + for (const baseProperty of baseProperties) { + const base = getTargetSymbol(baseProperty); if (base.flags & SymbolFlags.Prototype) { continue; } - let derived = getTargetSymbol(getPropertyOfObjectType(type, base.name)); - let baseDeclarationFlags = getDeclarationFlagsFromSymbol(base); + const derived = getTargetSymbol(getPropertyOfObjectType(type, base.name)); + const baseDeclarationFlags = getDeclarationFlagsFromSymbol(base); Debug.assert(!!derived, "derived should point to something, even if it is the base class' declaration."); @@ -13042,7 +13042,7 @@ namespace ts { if (derived === base) { // derived class inherits base without override/redeclaration - let derivedClassDecl = getClassLikeDeclarationOfSymbol(type.symbol); + const derivedClassDecl = getClassLikeDeclarationOfSymbol(type.symbol); // It is an error to inherit an abstract member without implementing it or being declared abstract. // If there is no declaration for the derived class (as in the case of class expressions), @@ -13060,7 +13060,7 @@ namespace ts { } else { // derived overrides base. - let derivedDeclarationFlags = getDeclarationFlagsFromSymbol(derived); + const derivedDeclarationFlags = getDeclarationFlagsFromSymbol(derived); if ((baseDeclarationFlags & NodeFlags.Private) || (derivedDeclarationFlags & NodeFlags.Private)) { // either base or derived property is private - not override, skip it continue; @@ -13117,8 +13117,8 @@ namespace ts { // When a generic interface has multiple declarations, all declarations must have identical type parameter // lists, i.e. identical type parameter names with identical constraints in identical order. for (let i = 0, len = list1.length; i < len; i++) { - let tp1 = list1[i]; - let tp2 = list2[i]; + const tp1 = list1[i]; + const tp2 = list2[i]; if (tp1.name.text !== tp2.name.text) { return false; } @@ -13136,29 +13136,29 @@ namespace ts { } function checkInheritedPropertiesAreIdentical(type: InterfaceType, typeNode: Node): boolean { - let baseTypes = getBaseTypes(type); + const baseTypes = getBaseTypes(type); if (baseTypes.length < 2) { return true; } - let seen: Map<{ prop: Symbol; containingType: Type }> = {}; + const seen: Map<{ prop: Symbol; containingType: Type }> = {}; forEach(resolveDeclaredMembers(type).declaredProperties, p => { seen[p.name] = { prop: p, containingType: type }; }); let ok = true; - for (let base of baseTypes) { - let properties = getPropertiesOfObjectType(getTypeWithThisArgument(base, type.thisType)); - for (let prop of properties) { + for (const base of baseTypes) { + const properties = getPropertiesOfObjectType(getTypeWithThisArgument(base, type.thisType)); + for (const prop of properties) { if (!hasProperty(seen, prop.name)) { seen[prop.name] = { prop: prop, containingType: base }; } else { - let existing = seen[prop.name]; - let isInheritedProperty = existing.containingType !== type; + const existing = seen[prop.name]; + const isInheritedProperty = existing.containingType !== type; if (isInheritedProperty && !isPropertyIdenticalTo(existing.prop, prop)) { ok = false; - let typeName1 = typeToString(existing.containingType); - let typeName2 = typeToString(base); + const typeName1 = typeToString(existing.containingType); + const typeName2 = typeToString(base); let errorInfo = chainDiagnosticMessages(undefined, Diagnostics.Named_property_0_of_types_1_and_2_are_not_identical, symbolToString(prop), typeName1, typeName2); errorInfo = chainDiagnosticMessages(errorInfo, Diagnostics.Interface_0_cannot_simultaneously_extend_types_1_and_2, typeToString(type), typeName1, typeName2); @@ -13180,8 +13180,8 @@ namespace ts { checkTypeNameIsReserved(node.name, Diagnostics.Interface_name_cannot_be_0); checkExportsOnMergedDeclarations(node); - let symbol = getSymbolOfNode(node); - let firstInterfaceDecl = getDeclarationOfKind(symbol, SyntaxKind.InterfaceDeclaration); + const symbol = getSymbolOfNode(node); + const firstInterfaceDecl = getDeclarationOfKind(symbol, SyntaxKind.InterfaceDeclaration); if (symbol.declarations.length > 1) { if (node !== firstInterfaceDecl && !areTypeParametersIdentical(firstInterfaceDecl.typeParameters, node.typeParameters)) { error(node.name, Diagnostics.All_declarations_of_an_interface_must_have_identical_type_parameters); @@ -13190,11 +13190,11 @@ namespace ts { // Only check this symbol once if (node === firstInterfaceDecl) { - let type = getDeclaredTypeOfSymbol(symbol); - let typeWithThis = getTypeWithThisArgument(type); + const type = getDeclaredTypeOfSymbol(symbol); + const typeWithThis = getTypeWithThisArgument(type); // run subsequent checks only if first set succeeded if (checkInheritedPropertiesAreIdentical(type, node.name)) { - for (let baseType of getBaseTypes(type)) { + for (const baseType of getBaseTypes(type)) { checkTypeAssignableTo(typeWithThis, getTypeWithThisArgument(baseType, type.thisType), node.name, Diagnostics.Interface_0_incorrectly_extends_interface_1); } checkIndexConstraints(type); @@ -13224,14 +13224,14 @@ namespace ts { } function computeEnumMemberValues(node: EnumDeclaration) { - let nodeLinks = getNodeLinks(node); + const nodeLinks = getNodeLinks(node); if (!(nodeLinks.flags & NodeCheckFlags.EnumValuesComputed)) { - let enumSymbol = getSymbolOfNode(node); - let enumType = getDeclaredTypeOfSymbol(enumSymbol); + const enumSymbol = getSymbolOfNode(node); + const enumType = getDeclaredTypeOfSymbol(enumSymbol); let autoValue = 0; // set to undefined when enum member is non-constant - let ambient = isInAmbientContext(node); - let enumIsConst = isConst(node); + const ambient = isInAmbientContext(node); + const enumIsConst = isConst(node); for (const member of node.members) { if (member.name.kind === SyntaxKind.ComputedPropertyName) { @@ -13243,7 +13243,7 @@ namespace ts { const previousEnumMemberIsNonConstant = autoValue === undefined; - let initializer = member.initializer; + const initializer = member.initializer; if (initializer) { autoValue = computeConstantValueForEnumMemberInitializer(initializer, enumType, enumIsConst, ambient); } @@ -13272,7 +13272,7 @@ namespace ts { // Controls if error should be reported after evaluation of constant value is completed // Can be false if another more precise error was already reported during evaluation. let reportError = true; - let value = evalConstant(initializer); + const value = evalConstant(initializer); if (reportError) { if (value === undefined) { @@ -13302,7 +13302,7 @@ namespace ts { function evalConstant(e: Node): number { switch (e.kind) { case SyntaxKind.PrefixUnaryExpression: - let value = evalConstant((e).operand); + const value = evalConstant((e).operand); if (value === undefined) { return undefined; } @@ -13313,11 +13313,11 @@ namespace ts { } return undefined; case SyntaxKind.BinaryExpression: - let left = evalConstant((e).left); + const left = evalConstant((e).left); if (left === undefined) { return undefined; } - let right = evalConstant((e).right); + const right = evalConstant((e).right); if (right === undefined) { return undefined; } @@ -13342,8 +13342,8 @@ namespace ts { case SyntaxKind.Identifier: case SyntaxKind.ElementAccessExpression: case SyntaxKind.PropertyAccessExpression: - let member = initializer.parent; - let currentType = getTypeOfSymbol(getSymbolOfNode(member.parent)); + const member = initializer.parent; + const currentType = getTypeOfSymbol(getSymbolOfNode(member.parent)); let enumType: Type; let propertyName: string; @@ -13393,12 +13393,12 @@ namespace ts { return undefined; } - let property = getPropertyOfObjectType(enumType, propertyName); + const property = getPropertyOfObjectType(enumType, propertyName); if (!property || !(property.flags & SymbolFlags.EnumMember)) { return undefined; } - let propertyDecl = property.valueDeclaration; + const propertyDecl = property.valueDeclaration; // self references are illegal if (member === propertyDecl) { return undefined; @@ -13432,7 +13432,7 @@ namespace ts { computeEnumMemberValues(node); - let enumIsConst = isConst(node); + const enumIsConst = isConst(node); if (compilerOptions.isolatedModules && enumIsConst && isInAmbientContext(node)) { error(node.name, Diagnostics.Ambient_const_enums_are_not_allowed_when_the_isolatedModules_flag_is_provided); } @@ -13443,8 +13443,8 @@ namespace ts { // for the first member. // // Only perform this check once per symbol - let enumSymbol = getSymbolOfNode(node); - let firstDeclaration = getDeclarationOfKind(enumSymbol, node.kind); + const enumSymbol = getSymbolOfNode(node); + const firstDeclaration = getDeclarationOfKind(enumSymbol, node.kind); if (node === firstDeclaration) { if (enumSymbol.declarations.length > 1) { // check that const is placed\omitted on all enum declarations @@ -13462,12 +13462,12 @@ namespace ts { return false; } - let enumDeclaration = declaration; + const enumDeclaration = declaration; if (!enumDeclaration.members.length) { return false; } - let firstEnumMember = enumDeclaration.members[0]; + const firstEnumMember = enumDeclaration.members[0]; if (!firstEnumMember.initializer) { if (seenEnumMissingInitialInitializer) { error(firstEnumMember.name, Diagnostics.In_an_enum_with_multiple_declarations_only_one_declaration_can_omit_an_initializer_for_its_first_enum_element); @@ -13481,8 +13481,8 @@ namespace ts { } function getFirstNonAmbientClassOrFunctionDeclaration(symbol: Symbol): Declaration { - let declarations = symbol.declarations; - for (let declaration of declarations) { + const declarations = symbol.declarations; + for (const declaration of declarations) { if ((declaration.kind === SyntaxKind.ClassDeclaration || (declaration.kind === SyntaxKind.FunctionDeclaration && nodeIsPresent((declaration).body))) && !isInAmbientContext(declaration)) { @@ -13493,8 +13493,8 @@ namespace ts { } function inSameLexicalScope(node1: Node, node2: Node) { - let container1 = getEnclosingBlockScopeContainer(node1); - let container2 = getEnclosingBlockScopeContainer(node2); + const container1 = getEnclosingBlockScopeContainer(node1); + const container2 = getEnclosingBlockScopeContainer(node2); if (isGlobalSourceFile(container1)) { return isGlobalSourceFile(container2); } @@ -13509,8 +13509,8 @@ namespace ts { function checkModuleDeclaration(node: ModuleDeclaration) { if (produceDiagnostics) { // Grammar checking - let isAmbientExternalModule = node.name.kind === SyntaxKind.StringLiteral; - let contextErrorMessage = isAmbientExternalModule + const isAmbientExternalModule = node.name.kind === SyntaxKind.StringLiteral; + const contextErrorMessage = isAmbientExternalModule ? Diagnostics.An_ambient_module_declaration_is_only_allowed_at_the_top_level_in_a_file : Diagnostics.A_namespace_declaration_is_only_allowed_in_a_namespace_or_module; if (checkGrammarModuleElementContext(node, contextErrorMessage)) { @@ -13527,14 +13527,14 @@ namespace ts { checkCollisionWithCapturedThisVariable(node, node.name); checkCollisionWithRequireExportsInGeneratedCode(node, node.name); checkExportsOnMergedDeclarations(node); - let symbol = getSymbolOfNode(node); + const symbol = getSymbolOfNode(node); // The following checks only apply on a non-ambient instantiated module declaration. if (symbol.flags & SymbolFlags.ValueModule && symbol.declarations.length > 1 && !isInAmbientContext(node) && isInstantiatedModule(node, compilerOptions.preserveConstEnums || compilerOptions.isolatedModules)) { - let firstNonAmbientClassOrFunc = getFirstNonAmbientClassOrFunctionDeclaration(symbol); + const firstNonAmbientClassOrFunc = getFirstNonAmbientClassOrFunctionDeclaration(symbol); if (firstNonAmbientClassOrFunc) { if (getSourceFileOfNode(node) !== getSourceFileOfNode(firstNonAmbientClassOrFunc)) { error(node.name, Diagnostics.A_namespace_declaration_cannot_be_in_a_different_file_from_a_class_or_function_with_which_it_is_merged); @@ -13546,7 +13546,7 @@ namespace ts { // if the module merges with a class declaration in the same lexical scope, // we need to track this to ensure the correct emit. - let mergedClass = getDeclarationOfKind(symbol, SyntaxKind.ClassDeclaration); + const mergedClass = getDeclarationOfKind(symbol, SyntaxKind.ClassDeclaration); if (mergedClass && inSameLexicalScope(node, mergedClass)) { getNodeLinks(node).flags |= NodeCheckFlags.LexicalModuleMergesWithClass; @@ -13583,12 +13583,12 @@ namespace ts { } function checkExternalImportOrExportDeclaration(node: ImportDeclaration | ImportEqualsDeclaration | ExportDeclaration): boolean { - let moduleName = getExternalModuleName(node); + const moduleName = getExternalModuleName(node); if (!nodeIsMissing(moduleName) && moduleName.kind !== SyntaxKind.StringLiteral) { error(moduleName, Diagnostics.String_literal_expected); return false; } - let inAmbientExternalModule = node.parent.kind === SyntaxKind.ModuleBlock && (node.parent.parent).name.kind === SyntaxKind.StringLiteral; + const inAmbientExternalModule = node.parent.kind === SyntaxKind.ModuleBlock && (node.parent.parent).name.kind === SyntaxKind.StringLiteral; if (node.parent.kind !== SyntaxKind.SourceFile && !inAmbientExternalModule) { error(moduleName, node.kind === SyntaxKind.ExportDeclaration ? Diagnostics.Export_declarations_are_not_permitted_in_a_namespace : @@ -13607,15 +13607,15 @@ namespace ts { } function checkAliasSymbol(node: ImportEqualsDeclaration | ImportClause | NamespaceImport | ImportSpecifier | ExportSpecifier) { - let symbol = getSymbolOfNode(node); - let target = resolveAlias(symbol); + const symbol = getSymbolOfNode(node); + const target = resolveAlias(symbol); if (target !== unknownSymbol) { - let excludedMeanings = + const excludedMeanings = (symbol.flags & SymbolFlags.Value ? SymbolFlags.Value : 0) | (symbol.flags & SymbolFlags.Type ? SymbolFlags.Type : 0) | (symbol.flags & SymbolFlags.Namespace ? SymbolFlags.Namespace : 0); if (target.flags & excludedMeanings) { - let message = node.kind === SyntaxKind.ExportSpecifier ? + const message = node.kind === SyntaxKind.ExportSpecifier ? Diagnostics.Export_declaration_conflicts_with_exported_declaration_of_0 : Diagnostics.Import_declaration_conflicts_with_local_declaration_of_0; error(node, message, symbolToString(symbol)); @@ -13638,7 +13638,7 @@ namespace ts { grammarErrorOnFirstToken(node, Diagnostics.An_import_declaration_cannot_have_modifiers); } if (checkExternalImportOrExportDeclaration(node)) { - let importClause = node.importClause; + const importClause = node.importClause; if (importClause) { if (importClause.name) { checkImportBinding(importClause); @@ -13668,11 +13668,11 @@ namespace ts { markExportAsReferenced(node); } if (isInternalModuleImportEqualsDeclaration(node)) { - let target = resolveAlias(getSymbolOfNode(node)); + const target = resolveAlias(getSymbolOfNode(node)); if (target !== unknownSymbol) { if (target.flags & SymbolFlags.Value) { // Target is a value symbol, check that it is not hidden by a local declaration with the same name - let moduleName = getFirstIdentifier(node.moduleReference); + const moduleName = getFirstIdentifier(node.moduleReference); if (!(resolveEntityName(moduleName, SymbolFlags.Value | SymbolFlags.Namespace).flags & SymbolFlags.Namespace)) { error(moduleName, Diagnostics.Module_0_is_hidden_by_a_local_declaration_with_the_same_name, declarationNameToString(moduleName)); } @@ -13707,14 +13707,14 @@ namespace ts { // export { x, y } from "foo" forEach(node.exportClause.elements, checkExportSpecifier); - let inAmbientExternalModule = node.parent.kind === SyntaxKind.ModuleBlock && (node.parent.parent).name.kind === SyntaxKind.StringLiteral; + const inAmbientExternalModule = node.parent.kind === SyntaxKind.ModuleBlock && (node.parent.parent).name.kind === SyntaxKind.StringLiteral; if (node.parent.kind !== SyntaxKind.SourceFile && !inAmbientExternalModule) { error(node, Diagnostics.Export_declarations_are_not_permitted_in_a_namespace); } } else { // export * from "foo" - let moduleSymbol = resolveExternalModuleName(node, node.moduleSpecifier); + const moduleSymbol = resolveExternalModuleName(node, node.moduleSpecifier); if (moduleSymbol && moduleSymbol.exports["export="]) { error(node.moduleSpecifier, Diagnostics.Module_0_uses_export_and_cannot_be_used_with_export_Asterisk, symbolToString(moduleSymbol)); } @@ -13741,7 +13741,7 @@ namespace ts { return; } - let container = node.parent.kind === SyntaxKind.SourceFile ? node.parent : node.parent.parent; + const container = node.parent.kind === SyntaxKind.SourceFile ? node.parent : node.parent.parent; if (container.kind === SyntaxKind.ModuleDeclaration && (container).name.kind === SyntaxKind.Identifier) { error(node, Diagnostics.An_export_assignment_cannot_be_used_in_a_namespace); return; @@ -13791,12 +13791,12 @@ namespace ts { } function checkExternalModuleExports(node: SourceFile | ModuleDeclaration) { - let moduleSymbol = getSymbolOfNode(node); - let links = getSymbolLinks(moduleSymbol); + const moduleSymbol = getSymbolOfNode(node); + const links = getSymbolLinks(moduleSymbol); if (!links.exportsChecked) { - let exportEqualsSymbol = moduleSymbol.exports["export="]; + const exportEqualsSymbol = moduleSymbol.exports["export="]; if (exportEqualsSymbol && hasExportedMembers(moduleSymbol)) { - let declaration = getDeclarationOfAliasSymbol(exportEqualsSymbol) || exportEqualsSymbol.valueDeclaration; + const declaration = getDeclarationOfAliasSymbol(exportEqualsSymbol) || exportEqualsSymbol.valueDeclaration; error(declaration, Diagnostics.An_export_assignment_cannot_be_used_in_a_module_with_other_exported_elements); } links.exportsChecked = true; @@ -13814,7 +13814,7 @@ namespace ts { return; } - let kind = node.kind; + const kind = node.kind; if (cancellationToken) { // Only bother checking on a few construct kinds. We don't want to be excessivly // hitting the cancellation token on every node we check. @@ -13938,8 +13938,8 @@ namespace ts { // Function and class expression bodies are checked after all statements in the enclosing body. This is // to ensure constructs like the following are permitted: - // let foo = function () { - // let s = foo(); + // const foo = function () { + // const s = foo(); // return "hello"; // } // Here, performing a full type check of the body of the function expression whilst in the process of @@ -14045,7 +14045,7 @@ namespace ts { } function checkSourceFile(node: SourceFile) { - let start = new Date().getTime(); + const start = new Date().getTime(); checkSourceFileWorker(node); @@ -14054,7 +14054,7 @@ namespace ts { // Fully type check a source file and collect the relevant diagnostics. function checkSourceFileWorker(node: SourceFile) { - let links = getNodeLinks(node); + const links = getNodeLinks(node); if (!(links.flags & NodeCheckFlags.TypeChecked)) { // Check whether the file has declared it is the default lib, // and whether the user has specifically chosen to avoid checking it. @@ -14156,7 +14156,7 @@ namespace ts { } function getSymbolsInScope(location: Node, meaning: SymbolFlags): Symbol[] { - let symbols: SymbolTable = {}; + const symbols: SymbolTable = {}; let memberFlags: NodeFlags = 0; if (isInsideWithStatementBody(location)) { @@ -14186,7 +14186,7 @@ namespace ts { copySymbols(getSymbolOfNode(location).exports, meaning & SymbolFlags.EnumMember); break; case SyntaxKind.ClassExpression: - let className = (location).name; + const className = (location).name; if (className) { copySymbol(location.symbol, meaning); } @@ -14203,7 +14203,7 @@ namespace ts { } break; case SyntaxKind.FunctionExpression: - let funcName = (location).name; + const funcName = (location).name; if (funcName) { copySymbol(location.symbol, meaning); } @@ -14230,7 +14230,7 @@ namespace ts { */ function copySymbol(symbol: Symbol, meaning: SymbolFlags): void { if (symbol.flags & meaning) { - let id = symbol.name; + const id = symbol.name; // We will copy all symbol regardless of its reserved name because // symbolsToArray will check whether the key is a reserved name and // it will not copy symbol with reserved name to the array @@ -14242,8 +14242,8 @@ namespace ts { function copySymbols(source: SymbolTable, meaning: SymbolFlags): void { if (meaning) { - for (let id in source) { - let symbol = source[id]; + for (const id in source) { + const symbol = source[id]; copySymbol(symbol, meaning); } } @@ -14360,18 +14360,18 @@ namespace ts { if (entityName.kind === SyntaxKind.Identifier) { // Include aliases in the meaning, this ensures that we do not follow aliases to where they point and instead // return the alias symbol. - let meaning: SymbolFlags = SymbolFlags.Value | SymbolFlags.Alias; + const meaning: SymbolFlags = SymbolFlags.Value | SymbolFlags.Alias; return resolveEntityName(entityName, meaning); } else if (entityName.kind === SyntaxKind.PropertyAccessExpression) { - let symbol = getNodeLinks(entityName).resolvedSymbol; + const symbol = getNodeLinks(entityName).resolvedSymbol; if (!symbol) { checkPropertyAccessExpression(entityName); } return getNodeLinks(entityName).resolvedSymbol; } else if (entityName.kind === SyntaxKind.QualifiedName) { - let symbol = getNodeLinks(entityName).resolvedSymbol; + const symbol = getNodeLinks(entityName).resolvedSymbol; if (!symbol) { checkQualifiedName(entityName); } @@ -14417,8 +14417,8 @@ namespace ts { else if (node.parent.kind === SyntaxKind.BindingElement && node.parent.parent.kind === SyntaxKind.ObjectBindingPattern && node === (node.parent).propertyName) { - let typeOfPattern = getTypeOfNode(node.parent.parent); - let propertyDeclaration = typeOfPattern && getPropertyOfType(typeOfPattern, (node).text); + const typeOfPattern = getTypeOfNode(node.parent.parent); + const propertyDeclaration = typeOfPattern && getPropertyOfType(typeOfPattern, (node).text); if (propertyDeclaration) { return propertyDeclaration; @@ -14434,12 +14434,12 @@ namespace ts { case SyntaxKind.ThisKeyword: case SyntaxKind.SuperKeyword: - let type = isExpression(node) ? checkExpression(node) : getTypeFromTypeNode(node); + const type = isExpression(node) ? checkExpression(node) : getTypeFromTypeNode(node); return type.symbol; case SyntaxKind.ConstructorKeyword: // constructor keyword for an overload, should take us to the definition if it exist - let constructorDeclaration = node.parent; + const constructorDeclaration = node.parent; if (constructorDeclaration && constructorDeclaration.kind === SyntaxKind.Constructor) { return (constructorDeclaration.parent).symbol; } @@ -14458,9 +14458,9 @@ namespace ts { case SyntaxKind.NumericLiteral: // index access if (node.parent.kind === SyntaxKind.ElementAccessExpression && (node.parent).argumentExpression === node) { - let objectType = checkExpression((node.parent).expression); + const objectType = checkExpression((node.parent).expression); if (objectType === unknownType) return undefined; - let apparentType = getApparentType(objectType); + const apparentType = getApparentType(objectType); if (apparentType === unknownType) return undefined; return getPropertyOfType(apparentType, (node).text); } @@ -14501,23 +14501,23 @@ namespace ts { if (isTypeDeclaration(node)) { // In this case, we call getSymbolOfNode instead of getSymbolAtLocation because it is a declaration - let symbol = getSymbolOfNode(node); + const symbol = getSymbolOfNode(node); return getDeclaredTypeOfSymbol(symbol); } if (isTypeDeclarationName(node)) { - let symbol = getSymbolAtLocation(node); + const symbol = getSymbolAtLocation(node); return symbol && getDeclaredTypeOfSymbol(symbol); } if (isDeclaration(node)) { // In this case, we call getSymbolOfNode instead of getSymbolAtLocation because it is a declaration - let symbol = getSymbolOfNode(node); + const symbol = getSymbolOfNode(node); return getTypeOfSymbol(symbol); } if (isDeclarationName(node)) { - let symbol = getSymbolAtLocation(node); + const symbol = getSymbolAtLocation(node); return symbol && getTypeOfSymbol(symbol); } @@ -14526,8 +14526,8 @@ namespace ts { } if (isInRightSideOfImportOrExportAssignment(node)) { - let symbol = getSymbolAtLocation(node); - let declaredType = symbol && getDeclaredTypeOfSymbol(symbol); + const symbol = getSymbolAtLocation(node); + const declaredType = symbol && getDeclaredTypeOfSymbol(symbol); return declaredType !== unknownType ? declaredType : getTypeOfSymbol(symbol); } @@ -14547,7 +14547,7 @@ namespace ts { * whether the element is declared as "static". */ function getParentTypeOfClassElement(node: ClassElement) { - let classSymbol = getSymbolOfNode(node.parent); + const classSymbol = getSymbolOfNode(node.parent); return node.flags & NodeFlags.Static ? getTypeOfSymbol(classSymbol) : getDeclaredTypeOfSymbol(classSymbol); @@ -14557,7 +14557,7 @@ namespace ts { // if the type has call or construct signatures function getAugmentedPropertiesOfType(type: Type): Symbol[] { type = getApparentType(type); - let propsByName = createSymbolTable(getPropertiesOfType(type)); + const propsByName = createSymbolTable(getPropertiesOfType(type)); if (getSignaturesOfType(type, SignatureKind.Call).length || getSignaturesOfType(type, SignatureKind.Construct).length) { forEach(getPropertiesOfType(globalFunctionType), p => { if (!hasProperty(propsByName, p.name)) { @@ -14570,10 +14570,10 @@ namespace ts { function getRootSymbols(symbol: Symbol): Symbol[] { if (symbol.flags & SymbolFlags.SyntheticProperty) { - let symbols: Symbol[] = []; - let name = symbol.name; + const symbols: Symbol[] = []; + const name = symbol.name; forEach(getSymbolLinks(symbol).containingType.types, t => { - let symbol = getPropertyOfType(t, name); + const symbol = getPropertyOfType(t, name); if (symbol) { symbols.push(symbol); } @@ -14581,7 +14581,7 @@ namespace ts { return symbols; } else if (symbol.flags & SymbolFlags.Transient) { - let target = getSymbolLinks(symbol).target; + const target = getSymbolLinks(symbol).target; if (target) { return [target]; } @@ -14604,13 +14604,13 @@ namespace ts { // If we reference an exported entity within the same module declaration, then whether // we prefix depends on the kind of entity. SymbolFlags.ExportHasLocal encompasses all the // kinds that we do NOT prefix. - let exportSymbol = getMergedSymbol(symbol.exportSymbol); + const exportSymbol = getMergedSymbol(symbol.exportSymbol); if (exportSymbol.flags & SymbolFlags.ExportHasLocal) { return undefined; } symbol = exportSymbol; } - let parentSymbol = getParentOfSymbol(symbol); + const parentSymbol = getParentOfSymbol(symbol); if (parentSymbol) { if (parentSymbol.flags & SymbolFlags.ValueModule && parentSymbol.valueDeclaration.kind === SyntaxKind.SourceFile) { return parentSymbol.valueDeclaration; @@ -14627,7 +14627,7 @@ namespace ts { // When resolved as an expression identifier, if the given node references an import, return the declaration of // that import. Otherwise, return undefined. function getReferencedImportDeclaration(node: Identifier): Declaration { - let symbol = getReferencedValueSymbol(node); + const symbol = getReferencedValueSymbol(node); return symbol && symbol.flags & SymbolFlags.Alias ? getDeclarationOfAliasSymbol(symbol) : undefined; } @@ -14645,9 +14645,9 @@ namespace ts { function isNestedRedeclarationSymbol(symbol: Symbol): boolean { if (symbol.flags & SymbolFlags.BlockScoped) { - let links = getSymbolLinks(symbol); + const links = getSymbolLinks(symbol); if (links.isNestedRedeclaration === undefined) { - let container = getEnclosingBlockScopeContainer(symbol.valueDeclaration); + const container = getEnclosingBlockScopeContainer(symbol.valueDeclaration); links.isNestedRedeclaration = isStatementWithLocals(container) && !!resolveName(container.parent, symbol.name, SymbolFlags.Value, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined); } @@ -14659,7 +14659,7 @@ namespace ts { // When resolved as an expression identifier, if the given node references a nested block scoped entity with // a name that hides an existing name, return the declaration of that entity. Otherwise, return undefined. function getReferencedNestedRedeclaration(node: Identifier): Declaration { - let symbol = getReferencedValueSymbol(node); + const symbol = getReferencedValueSymbol(node); return symbol && isNestedRedeclarationSymbol(symbol) ? symbol.valueDeclaration : undefined; } @@ -14678,7 +14678,7 @@ namespace ts { case SyntaxKind.ExportSpecifier: return isAliasResolvedToValue(getSymbolOfNode(node)); case SyntaxKind.ExportDeclaration: - let exportClause = (node).exportClause; + const exportClause = (node).exportClause; return exportClause && forEach(exportClause.elements, isValueAliasDeclaration); case SyntaxKind.ExportAssignment: return (node).expression && (node).expression.kind === SyntaxKind.Identifier ? isAliasResolvedToValue(getSymbolOfNode(node)) : true; @@ -14692,12 +14692,12 @@ namespace ts { return false; } - let isValue = isAliasResolvedToValue(getSymbolOfNode(node)); + const isValue = isAliasResolvedToValue(getSymbolOfNode(node)); return isValue && node.moduleReference && !nodeIsMissing(node.moduleReference); } function isAliasResolvedToValue(symbol: Symbol): boolean { - let target = resolveAlias(symbol); + const target = resolveAlias(symbol); if (target === unknownSymbol && compilerOptions.isolatedModules) { return true; } @@ -14715,7 +14715,7 @@ namespace ts { function isReferencedAliasDeclaration(node: Node, checkChildren?: boolean): boolean { if (isAliasSymbolDeclaration(node)) { - let symbol = getSymbolOfNode(node); + const symbol = getSymbolOfNode(node); if (getSymbolLinks(symbol).referenced) { return true; } @@ -14729,8 +14729,8 @@ namespace ts { function isImplementationOfOverload(node: FunctionLikeDeclaration) { if (nodeIsPresent(node.body)) { - let symbol = getSymbolOfNode(node); - let signaturesOfSymbol = getSignaturesOfSymbol(symbol); + const symbol = getSymbolOfNode(node); + const signaturesOfSymbol = getSignaturesOfSymbol(symbol); // If this function body corresponds to function with multiple signature, it is implementation of overload // e.g.: function foo(a: string): string; // function foo(a: number): number; @@ -14762,7 +14762,7 @@ namespace ts { return getEnumMemberValue(node); } - let symbol = getNodeLinks(node).resolvedSymbol; + const symbol = getNodeLinks(node).resolvedSymbol; if (symbol && (symbol.flags & SymbolFlags.EnumMember)) { // inline property\index accesses only for const enums if (isConstEnumDeclaration(symbol.valueDeclaration.parent)) { @@ -14779,19 +14779,19 @@ namespace ts { function getTypeReferenceSerializationKind(typeName: EntityName): TypeReferenceSerializationKind { // Resolve the symbol as a value to ensure the type can be reached at runtime during emit. - let valueSymbol = resolveEntityName(typeName, SymbolFlags.Value, /*ignoreErrors*/ true); - let constructorType = valueSymbol ? getTypeOfSymbol(valueSymbol) : undefined; + const valueSymbol = resolveEntityName(typeName, SymbolFlags.Value, /*ignoreErrors*/ true); + const constructorType = valueSymbol ? getTypeOfSymbol(valueSymbol) : undefined; if (constructorType && isConstructorType(constructorType)) { return TypeReferenceSerializationKind.TypeWithConstructSignatureAndValue; } // Resolve the symbol as a type so that we can provide a more useful hint for the type serializer. - let typeSymbol = resolveEntityName(typeName, SymbolFlags.Type, /*ignoreErrors*/ true); + const typeSymbol = resolveEntityName(typeName, SymbolFlags.Type, /*ignoreErrors*/ true); // We might not be able to resolve type symbol so use unknown type in that case (eg error case) if (!typeSymbol) { return TypeReferenceSerializationKind.ObjectType; } - let type = getDeclaredTypeOfSymbol(typeSymbol); + const type = getDeclaredTypeOfSymbol(typeSymbol); if (type === unknownType) { return TypeReferenceSerializationKind.Unknown; } @@ -14829,8 +14829,8 @@ namespace ts { function writeTypeOfDeclaration(declaration: AccessorDeclaration | VariableLikeDeclaration, enclosingDeclaration: Node, flags: TypeFormatFlags, writer: SymbolWriter) { // Get type of the symbol if this is the valid symbol otherwise get type at location - let symbol = getSymbolOfNode(declaration); - let type = symbol && !(symbol.flags & (SymbolFlags.TypeLiteral | SymbolFlags.Signature)) + const symbol = getSymbolOfNode(declaration); + const type = symbol && !(symbol.flags & (SymbolFlags.TypeLiteral | SymbolFlags.Signature)) ? getTypeOfSymbol(symbol) : unknownType; @@ -14838,12 +14838,12 @@ namespace ts { } function writeReturnTypeOfSignatureDeclaration(signatureDeclaration: SignatureDeclaration, enclosingDeclaration: Node, flags: TypeFormatFlags, writer: SymbolWriter) { - let signature = getSignatureFromDeclaration(signatureDeclaration); + const signature = getSignatureFromDeclaration(signatureDeclaration); getSymbolDisplayBuilder().buildTypeDisplay(getReturnTypeOfSignature(signature), writer, enclosingDeclaration, flags); } function writeTypeOfExpression(expr: Expression, enclosingDeclaration: Node, flags: TypeFormatFlags, writer: SymbolWriter) { - let type = getTypeOfExpression(expr); + const type = getTypeOfExpression(expr); getSymbolDisplayBuilder().buildTypeDisplay(type, writer, enclosingDeclaration, flags); } @@ -14859,7 +14859,7 @@ namespace ts { function getReferencedValueDeclaration(reference: Identifier): Declaration { Debug.assert(!nodeIsSynthesized(reference)); - let symbol = getReferencedValueSymbol(reference); + const symbol = getReferencedValueSymbol(reference); return symbol && getExportSymbolOfValueSymbolIfExported(symbol).valueDeclaration; } @@ -14868,12 +14868,12 @@ namespace ts { return unknownType; } - let signature = getSingleCallSignature(functionType); + const signature = getSingleCallSignature(functionType); if (!signature) { return unknownType; } - let instantiatedSignature = getSignatureInstantiation(signature, typeArguments); + const instantiatedSignature = getSignatureInstantiation(signature, typeArguments); return getOrCreateTypeFromSignature(instantiatedSignature); } @@ -14971,7 +14971,7 @@ namespace ts { } function createInstantiatedPromiseLikeType(): ObjectType { - let promiseLikeType = getGlobalPromiseLikeType(); + const promiseLikeType = getGlobalPromiseLikeType(); if (promiseLikeType !== emptyGenericType) { return createTypeReference(promiseLikeType, [anyType]); } @@ -14981,10 +14981,10 @@ namespace ts { function createThenableType() { // build the thenable type that is used to verify against a non-promise "thenable" operand to `await`. - let thenPropertySymbol = createSymbol(SymbolFlags.Transient | SymbolFlags.Property, "then"); + const thenPropertySymbol = createSymbol(SymbolFlags.Transient | SymbolFlags.Property, "then"); getSymbolLinks(thenPropertySymbol).type = globalFunctionType; - let thenableType = createObjectType(TypeFlags.Anonymous); + const thenableType = createObjectType(TypeFlags.Anonymous); thenableType.properties = [thenPropertySymbol]; thenableType.members = createSymbolTable(thenableType.properties); thenableType.callSignatures = []; @@ -15001,7 +15001,7 @@ namespace ts { return grammarErrorOnFirstToken(node, Diagnostics.Decorators_are_not_valid_here); } else if (node.kind === SyntaxKind.GetAccessor || node.kind === SyntaxKind.SetAccessor) { - let accessors = getAllAccessorDeclarations((node.parent).members, node); + const accessors = getAllAccessorDeclarations((node.parent).members, node); if (accessors.firstAccessor.decorators && node === accessors.secondAccessor) { return grammarErrorOnFirstToken(node, Diagnostics.Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name); } @@ -15056,7 +15056,7 @@ namespace ts { let lastStatic: Node, lastPrivate: Node, lastProtected: Node, lastDeclare: Node, lastAsync: Node; let flags = 0; - for (let modifier of node.modifiers) { + for (const modifier of node.modifiers) { switch (modifier.kind) { case SyntaxKind.PublicKeyword: case SyntaxKind.ProtectedKeyword: @@ -15247,9 +15247,9 @@ namespace ts { function checkGrammarForDisallowedTrailingComma(list: NodeArray): boolean { if (list && list.hasTrailingComma) { - let start = list.end - ",".length; - let end = list.end; - let sourceFile = getSourceFileOfNode(list[0]); + const start = list.end - ",".length; + const end = list.end; + const sourceFile = getSourceFileOfNode(list[0]); return grammarErrorAtPos(sourceFile, start, end - start, Diagnostics.Trailing_comma_not_allowed); } } @@ -15260,8 +15260,8 @@ namespace ts { } if (typeParameters && typeParameters.length === 0) { - let start = typeParameters.pos - "<".length; - let end = skipTrivia(file.text, typeParameters.end) + ">".length; + const start = typeParameters.pos - "<".length; + const end = skipTrivia(file.text, typeParameters.end) + ">".length; return grammarErrorAtPos(file, start, end - start, Diagnostics.Type_parameter_list_cannot_be_empty); } } @@ -15272,10 +15272,10 @@ namespace ts { } let seenOptionalParameter = false; - let parameterCount = parameters.length; + const parameterCount = parameters.length; for (let i = 0; i < parameterCount; i++) { - let parameter = parameters[i]; + const parameter = parameters[i]; if (parameter.dotDotDotToken) { if (i !== (parameterCount - 1)) { return grammarErrorOnNode(parameter.dotDotDotToken, Diagnostics.A_rest_parameter_must_be_last_in_a_parameter_list); @@ -15308,16 +15308,16 @@ namespace ts { function checkGrammarFunctionLikeDeclaration(node: FunctionLikeDeclaration): boolean { // Prevent cascading error by short-circuit - let file = getSourceFileOfNode(node); + const file = getSourceFileOfNode(node); return checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarTypeParameterList(node, node.typeParameters, file) || checkGrammarParameterList(node.parameters) || checkGrammarArrowFunction(node, file); } function checkGrammarArrowFunction(node: FunctionLikeDeclaration, file: SourceFile): boolean { if (node.kind === SyntaxKind.ArrowFunction) { - let arrowFunction = node; - let startLine = getLineAndCharacterOfPosition(file, arrowFunction.equalsGreaterThanToken.pos).line; - let endLine = getLineAndCharacterOfPosition(file, arrowFunction.equalsGreaterThanToken.end).line; + const arrowFunction = node; + const startLine = getLineAndCharacterOfPosition(file, arrowFunction.equalsGreaterThanToken.pos).line; + const endLine = getLineAndCharacterOfPosition(file, arrowFunction.equalsGreaterThanToken.end).line; if (startLine !== endLine) { return grammarErrorOnNode(arrowFunction.equalsGreaterThanToken, Diagnostics.Line_terminator_not_permitted_before_arrow); } @@ -15326,7 +15326,7 @@ namespace ts { } function checkGrammarIndexSignatureParameters(node: SignatureDeclaration): boolean { - let parameter = node.parameters[0]; + const parameter = node.parameters[0]; if (node.parameters.length !== 1) { if (parameter) { return grammarErrorOnNode(parameter.name, Diagnostics.An_index_signature_must_have_exactly_one_parameter); @@ -15371,9 +15371,9 @@ namespace ts { function checkGrammarForAtLeastOneTypeArgument(node: Node, typeArguments: NodeArray): boolean { if (typeArguments && typeArguments.length === 0) { - let sourceFile = getSourceFileOfNode(node); - let start = typeArguments.pos - "<".length; - let end = skipTrivia(sourceFile.text, typeArguments.end) + ">".length; + const sourceFile = getSourceFileOfNode(node); + const start = typeArguments.pos - "<".length; + const end = skipTrivia(sourceFile.text, typeArguments.end) + ">".length; return grammarErrorAtPos(sourceFile, start, end - start, Diagnostics.Type_argument_list_cannot_be_empty); } } @@ -15385,8 +15385,8 @@ namespace ts { function checkGrammarForOmittedArgument(node: CallExpression, args: NodeArray): boolean { if (args) { - let sourceFile = getSourceFileOfNode(node); - for (let arg of args) { + const sourceFile = getSourceFileOfNode(node); + for (const arg of args) { if (arg.kind === SyntaxKind.OmittedExpression) { return grammarErrorAtPos(sourceFile, arg.pos, 0, Diagnostics.Argument_expression_expected); } @@ -15400,13 +15400,13 @@ namespace ts { } function checkGrammarHeritageClause(node: HeritageClause): boolean { - let types = node.types; + const types = node.types; if (checkGrammarForDisallowedTrailingComma(types)) { return true; } if (types && types.length === 0) { - let listType = tokenToString(node.token); - let sourceFile = getSourceFileOfNode(node); + const listType = tokenToString(node.token); + const sourceFile = getSourceFileOfNode(node); return grammarErrorAtPos(sourceFile, types.pos, 0, Diagnostics._0_list_cannot_be_empty, listType); } } @@ -15416,7 +15416,7 @@ namespace ts { let seenImplementsClause = false; if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && node.heritageClauses) { - for (let heritageClause of node.heritageClauses) { + for (const heritageClause of node.heritageClauses) { if (heritageClause.token === SyntaxKind.ExtendsKeyword) { if (seenExtendsClause) { return grammarErrorOnFirstToken(heritageClause, Diagnostics.extends_clause_already_seen); @@ -15451,7 +15451,7 @@ namespace ts { let seenExtendsClause = false; if (node.heritageClauses) { - for (let heritageClause of node.heritageClauses) { + for (const heritageClause of node.heritageClauses) { if (heritageClause.token === SyntaxKind.ExtendsKeyword) { if (seenExtendsClause) { return grammarErrorOnFirstToken(heritageClause, Diagnostics.extends_clause_already_seen); @@ -15478,7 +15478,7 @@ namespace ts { return false; } - let computedPropertyName = node; + const computedPropertyName = node; if (computedPropertyName.expression.kind === SyntaxKind.BinaryExpression && (computedPropertyName.expression).operatorToken.kind === SyntaxKind.CommaToken) { return grammarErrorOnNode(computedPropertyName.expression, Diagnostics.A_comma_expression_is_not_allowed_in_a_computed_property_name); } @@ -15509,14 +15509,14 @@ namespace ts { } function checkGrammarObjectLiteralExpression(node: ObjectLiteralExpression, inDestructuring: boolean) { - let seen: Map = {}; - let Property = 1; - let GetAccessor = 2; - let SetAccesor = 4; - let GetOrSetAccessor = GetAccessor | SetAccesor; + const seen: Map = {}; + const Property = 1; + const GetAccessor = 2; + const SetAccesor = 4; + const GetOrSetAccessor = GetAccessor | SetAccesor; - for (let prop of node.properties) { - let name = prop.name; + for (const prop of node.properties) { + const name = prop.name; if (prop.kind === SyntaxKind.OmittedExpression || name.kind === SyntaxKind.ComputedPropertyName) { // If the name is not a ComputedPropertyName, the grammar checking will skip it @@ -15564,7 +15564,7 @@ namespace ts { seen[(name).text] = currentKind; } else { - let existingKind = seen[(name).text]; + const existingKind = seen[(name).text]; if (currentKind === Property && existingKind === Property) { continue; } @@ -15585,13 +15585,13 @@ namespace ts { function checkGrammarJsxElement(node: JsxOpeningLikeElement) { const seen: Map = {}; - for (let attr of node.attributes) { + for (const attr of node.attributes) { if (attr.kind === SyntaxKind.JsxSpreadAttribute) { continue; } - let jsxAttr = (attr); - let name = jsxAttr.name; + const jsxAttr = (attr); + const name = jsxAttr.name; if (!hasProperty(seen, name.text)) { seen[name.text] = true; } @@ -15599,7 +15599,7 @@ namespace ts { return grammarErrorOnNode(name, Diagnostics.JSX_elements_cannot_have_multiple_attributes_with_the_same_name); } - let initializer = jsxAttr.initializer; + const initializer = jsxAttr.initializer; if (initializer && initializer.kind === SyntaxKind.JsxExpression && !(initializer).expression) { return grammarErrorOnNode(jsxAttr.initializer, Diagnostics.JSX_attributes_must_only_be_assigned_a_non_empty_expression); } @@ -15612,23 +15612,23 @@ namespace ts { } if (forInOrOfStatement.initializer.kind === SyntaxKind.VariableDeclarationList) { - let variableList = forInOrOfStatement.initializer; + const variableList = forInOrOfStatement.initializer; if (!checkGrammarVariableDeclarationList(variableList)) { if (variableList.declarations.length > 1) { - let diagnostic = forInOrOfStatement.kind === SyntaxKind.ForInStatement + const diagnostic = forInOrOfStatement.kind === SyntaxKind.ForInStatement ? Diagnostics.Only_a_single_variable_declaration_is_allowed_in_a_for_in_statement : Diagnostics.Only_a_single_variable_declaration_is_allowed_in_a_for_of_statement; return grammarErrorOnFirstToken(variableList.declarations[1], diagnostic); } - let firstDeclaration = variableList.declarations[0]; + const firstDeclaration = variableList.declarations[0]; if (firstDeclaration.initializer) { - let diagnostic = forInOrOfStatement.kind === SyntaxKind.ForInStatement + const diagnostic = forInOrOfStatement.kind === SyntaxKind.ForInStatement ? Diagnostics.The_variable_declaration_of_a_for_in_statement_cannot_have_an_initializer : Diagnostics.The_variable_declaration_of_a_for_of_statement_cannot_have_an_initializer; return grammarErrorOnNode(firstDeclaration.name, diagnostic); } if (firstDeclaration.type) { - let diagnostic = forInOrOfStatement.kind === SyntaxKind.ForInStatement + const diagnostic = forInOrOfStatement.kind === SyntaxKind.ForInStatement ? Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_use_a_type_annotation : Diagnostics.The_left_hand_side_of_a_for_of_statement_cannot_use_a_type_annotation; return grammarErrorOnNode(firstDeclaration, diagnostic); @@ -15640,7 +15640,7 @@ namespace ts { } function checkGrammarAccessor(accessor: MethodDeclaration): boolean { - let kind = accessor.kind; + const kind = accessor.kind; if (languageVersion < ScriptTarget.ES5) { return grammarErrorOnNode(accessor.name, Diagnostics.Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher); } @@ -15664,7 +15664,7 @@ namespace ts { return grammarErrorOnNode(accessor.name, Diagnostics.A_set_accessor_must_have_exactly_one_parameter); } else { - let parameter = accessor.parameters[0]; + const parameter = accessor.parameters[0]; if (parameter.dotDotDotToken) { return grammarErrorOnNode(parameter.dotDotDotToken, Diagnostics.A_set_accessor_cannot_have_rest_parameter); } @@ -15739,7 +15739,7 @@ namespace ts { 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 - let isMisplacedContinueLabel = node.kind === SyntaxKind.ContinueStatement + const isMisplacedContinueLabel = node.kind === SyntaxKind.ContinueStatement && !isIterationStatement((current).statement, /*lookInLabeledStatement*/ true); if (isMisplacedContinueLabel) { @@ -15767,14 +15767,14 @@ namespace ts { } if (node.label) { - let message = node.kind === SyntaxKind.BreakStatement + const message = node.kind === SyntaxKind.BreakStatement ? Diagnostics.A_break_statement_can_only_jump_to_a_label_of_an_enclosing_statement : Diagnostics.A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement; return grammarErrorOnNode(node, message); } else { - let message = node.kind === SyntaxKind.BreakStatement + const message = node.kind === SyntaxKind.BreakStatement ? Diagnostics.A_break_statement_can_only_be_used_within_an_enclosing_iteration_or_switch_statement : Diagnostics.A_continue_statement_can_only_be_used_within_an_enclosing_iteration_statement; return grammarErrorOnNode(node, message); @@ -15783,7 +15783,7 @@ namespace ts { function checkGrammarBindingElement(node: BindingElement) { if (node.dotDotDotToken) { - let elements = (node.parent).elements; + const elements = (node.parent).elements; if (node !== lastOrUndefined(elements)) { return grammarErrorOnNode(node, Diagnostics.A_rest_element_must_be_last_in_an_array_destructuring_pattern); } @@ -15804,7 +15804,7 @@ namespace ts { if (isInAmbientContext(node)) { if (node.initializer) { // Error on equals token which immediate precedes the initializer - let equalsTokenLength = "=".length; + const equalsTokenLength = "=".length; return grammarErrorAtPos(getSourceFileOfNode(node), node.initializer.pos - equalsTokenLength, equalsTokenLength, Diagnostics.Initializers_are_not_allowed_in_ambient_contexts); } @@ -15819,7 +15819,7 @@ namespace ts { } } - let checkLetConstNames = languageVersion >= ScriptTarget.ES6 && (isLet(node) || isConst(node)); + const checkLetConstNames = languageVersion >= ScriptTarget.ES6 && (isLet(node) || isConst(node)); // 1. LexicalDeclaration : LetOrConst BindingList ; // It is a Syntax Error if the BoundNames of BindingList contains "let". @@ -15838,8 +15838,8 @@ namespace ts { } } else { - let elements = (name).elements; - for (let element of elements) { + const elements = (name).elements; + for (const element of elements) { if (element.kind !== SyntaxKind.OmittedExpression) { checkGrammarNameInLetOrConstDeclarations(element.name); } @@ -15848,7 +15848,7 @@ namespace ts { } function checkGrammarVariableDeclarationList(declarationList: VariableDeclarationList): boolean { - let declarations = declarationList.declarations; + const declarations = declarationList.declarations; if (checkGrammarForDisallowedTrailingComma(declarationList.declarations)) { return true; } @@ -15888,7 +15888,7 @@ namespace ts { function isIntegerLiteral(expression: Expression): boolean { if (expression.kind === SyntaxKind.PrefixUnaryExpression) { - let unaryExpression = expression; + const unaryExpression = expression; if (unaryExpression.operator === SyntaxKind.PlusToken || unaryExpression.operator === SyntaxKind.MinusToken) { expression = unaryExpression.operand; } @@ -15910,9 +15910,9 @@ namespace ts { } function grammarErrorOnFirstToken(node: Node, message: DiagnosticMessage, arg0?: any, arg1?: any, arg2?: any): boolean { - let sourceFile = getSourceFileOfNode(node); + const sourceFile = getSourceFileOfNode(node); if (!hasParseDiagnostics(sourceFile)) { - let span = getSpanOfTokenAtPosition(sourceFile, node.pos); + const span = getSpanOfTokenAtPosition(sourceFile, node.pos); diagnostics.add(createFileDiagnostic(sourceFile, span.start, span.length, message, arg0, arg1, arg2)); return true; } @@ -15926,7 +15926,7 @@ namespace ts { } function grammarErrorOnNode(node: Node, message: DiagnosticMessage, arg0?: any, arg1?: any, arg2?: any): boolean { - let sourceFile = getSourceFileOfNode(node); + const sourceFile = getSourceFileOfNode(node); if (!hasParseDiagnostics(sourceFile)) { diagnostics.add(createDiagnosticForNode(node, message, arg0, arg1, arg2)); return true; @@ -16002,7 +16002,7 @@ namespace ts { } function checkGrammarTopLevelElementsForRequiredDeclareModifier(file: SourceFile): boolean { - for (let decl of file.statements) { + for (const decl of file.statements) { if (isDeclaration(decl) || decl.kind === SyntaxKind.VariableStatement) { if (checkGrammarTopLevelElementForRequiredDeclareModifier(decl)) { return true; @@ -16023,7 +16023,7 @@ namespace ts { } // Find containing block which is either Block, ModuleBlock, SourceFile - let links = getNodeLinks(node); + const links = getNodeLinks(node); if (!links.hasReportedStatementInAmbientContext && isFunctionLike(node.parent)) { return getNodeLinks(node).hasReportedStatementInAmbientContext = grammarErrorOnFirstToken(node, Diagnostics.An_implementation_cannot_be_declared_in_ambient_contexts); } @@ -16034,7 +16034,7 @@ namespace ts { // this has already been reported, and don't report if it has. // if (node.parent.kind === SyntaxKind.Block || node.parent.kind === SyntaxKind.ModuleBlock || node.parent.kind === SyntaxKind.SourceFile) { - let links = getNodeLinks(node.parent); + const links = getNodeLinks(node.parent); // Check if the containing block ever report this error if (!links.hasReportedStatementInAmbientContext) { return links.hasReportedStatementInAmbientContext = grammarErrorOnFirstToken(node, Diagnostics.Statements_are_not_allowed_in_ambient_contexts); @@ -16056,9 +16056,9 @@ namespace ts { } function grammarErrorAfterFirstToken(node: Node, message: DiagnosticMessage, arg0?: any, arg1?: any, arg2?: any): boolean { - let sourceFile = getSourceFileOfNode(node); + const sourceFile = getSourceFileOfNode(node); if (!hasParseDiagnostics(sourceFile)) { - let span = getSpanOfTokenAtPosition(sourceFile, node.pos); + const span = getSpanOfTokenAtPosition(sourceFile, node.pos); diagnostics.add(createFileDiagnostic(sourceFile, textSpanEnd(span), /*length*/ 0, message, arg0, arg1, arg2)); return true; } diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index f4de5c430ac..3fca97c0450 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -295,8 +295,8 @@ namespace ts { return optionNameMapCache; } - let optionNameMap: Map = {}; - let shortOptionNames: Map = {}; + const optionNameMap: Map = {}; + const shortOptionNames: Map = {}; forEach(optionDeclarations, option => { optionNameMap[option.name.toLowerCase()] = option; if (option.shortName) { @@ -309,10 +309,10 @@ namespace ts { } export function parseCommandLine(commandLine: string[], readFile?: (path: string) => string): ParsedCommandLine { - let options: CompilerOptions = {}; - let fileNames: string[] = []; - let errors: Diagnostic[] = []; - let { optionNameMap, shortOptionNames } = getOptionNameMap(); + const options: CompilerOptions = {}; + const fileNames: string[] = []; + const errors: Diagnostic[] = []; + const { optionNameMap, shortOptionNames } = getOptionNameMap(); parseStrings(commandLine); return { @@ -337,7 +337,7 @@ namespace ts { } if (hasProperty(optionNameMap, s)) { - let opt = optionNameMap[s]; + const opt = optionNameMap[s]; // Check to see if no argument was provided (e.g. "--locale" is the last command-line argument). if (!args[i] && opt.type !== "boolean") { @@ -377,19 +377,19 @@ namespace ts { } function parseResponseFile(fileName: string) { - let text = readFile ? readFile(fileName) : sys.readFile(fileName); + const text = readFile ? readFile(fileName) : sys.readFile(fileName); if (!text) { errors.push(createCompilerDiagnostic(Diagnostics.File_0_not_found, fileName)); return; } - let args: string[] = []; + const args: string[] = []; let pos = 0; while (true) { while (pos < text.length && text.charCodeAt(pos) <= CharacterCodes.space) pos++; if (pos >= text.length) break; - let start = pos; + const start = pos; if (text.charCodeAt(start) === CharacterCodes.doubleQuote) { pos++; while (pos < text.length && text.charCodeAt(pos) !== CharacterCodes.doubleQuote) pos++; @@ -432,7 +432,7 @@ namespace ts { */ export function parseConfigFileTextToJson(fileName: string, jsonText: string): { config?: any; error?: Diagnostic } { try { - let jsonTextWithoutComments = removeComments(jsonText); + const jsonTextWithoutComments = removeComments(jsonText); return { config: /\S/.test(jsonTextWithoutComments) ? JSON.parse(jsonTextWithoutComments) : {} }; } catch (e) { @@ -449,7 +449,7 @@ namespace ts { */ function removeComments(jsonText: string): string { let output = ""; - let scanner = createScanner(ScriptTarget.ES5, /* skipTrivia */ false, LanguageVariant.Standard, jsonText); + const scanner = createScanner(ScriptTarget.ES5, /* skipTrivia */ false, LanguageVariant.Standard, jsonText); let token: SyntaxKind; while ((token = scanner.scan()) !== SyntaxKind.EndOfFileToken) { switch (token) { @@ -475,7 +475,7 @@ namespace ts { * file to. e.g. outDir */ export function parseJsonConfigFileContent(json: any, host: ParseConfigHost, basePath: string): ParsedCommandLine { - let { options, errors } = convertCompilerOptionsFromJson(json["compilerOptions"], basePath); + const { options, errors } = convertCompilerOptionsFromJson(json["compilerOptions"], basePath); return { options, @@ -494,12 +494,12 @@ namespace ts { } } else { - let exclude = json["exclude"] instanceof Array ? map(json["exclude"], normalizeSlashes) : undefined; - let sysFiles = host.readDirectory(basePath, ".ts", exclude).concat(host.readDirectory(basePath, ".tsx", exclude)); + const exclude = json["exclude"] instanceof Array ? map(json["exclude"], normalizeSlashes) : undefined; + const sysFiles = host.readDirectory(basePath, ".ts", exclude).concat(host.readDirectory(basePath, ".tsx", exclude)); for (let i = 0; i < sysFiles.length; i++) { - let name = sysFiles[i]; + const name = sysFiles[i]; if (fileExtensionIs(name, ".d.ts")) { - let baseName = name.substr(0, name.length - ".d.ts".length); + const baseName = name.substr(0, name.length - ".d.ts".length); if (!contains(sysFiles, baseName + ".tsx") && !contains(sysFiles, baseName + ".ts")) { fileNames.push(name); } @@ -519,24 +519,24 @@ namespace ts { } export function convertCompilerOptionsFromJson(jsonOptions: any, basePath: string): { options: CompilerOptions, errors: Diagnostic[] } { - let options: CompilerOptions = {}; - let errors: Diagnostic[] = []; + const options: CompilerOptions = {}; + const errors: Diagnostic[] = []; if (!jsonOptions) { return { options, errors }; } - let optionNameMap = arrayToMap(optionDeclarations, opt => opt.name); + const optionNameMap = arrayToMap(optionDeclarations, opt => opt.name); - for (let id in jsonOptions) { + for (const id in jsonOptions) { if (hasProperty(optionNameMap, id)) { - let opt = optionNameMap[id]; - let optType = opt.type; + const opt = optionNameMap[id]; + const optType = opt.type; let value = jsonOptions[id]; - let expectedType = typeof optType === "string" ? optType : "string"; + const expectedType = typeof optType === "string" ? optType : "string"; if (typeof value === expectedType) { if (typeof optType !== "string") { - let key = value.toLowerCase(); + const key = value.toLowerCase(); if (hasProperty(optType, key)) { value = optType[key]; } diff --git a/src/compiler/core.ts b/src/compiler/core.ts index 068ab1865bb..5c882fb5304 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -29,7 +29,7 @@ namespace ts { }; function forEachValueInMap(f: (key: Path, value: T) => void) { - for (let key in files) { + for (const key in files) { f(key, files[key]); } } @@ -84,7 +84,7 @@ namespace ts { export function forEach(array: T[], callback: (element: T, index: number) => U): U { if (array) { for (let i = 0, len = array.length; i < len; i++) { - let result = callback(array[i], i); + const result = callback(array[i], i); if (result) { return result; } @@ -95,7 +95,7 @@ namespace ts { export function contains(array: T[], value: T): boolean { if (array) { - for (let v of array) { + for (const v of array) { if (v === value) { return true; } @@ -118,7 +118,7 @@ namespace ts { export function countWhere(array: T[], predicate: (x: T) => boolean): number { let count = 0; if (array) { - for (let v of array) { + for (const v of array) { if (predicate(v)) { count++; } @@ -131,7 +131,7 @@ namespace ts { let result: T[]; if (array) { result = []; - for (let item of array) { + for (const item of array) { if (f(item)) { result.push(item); } @@ -144,7 +144,7 @@ namespace ts { let result: U[]; if (array) { result = []; - for (let v of array) { + for (const v of array) { result.push(f(v)); } } @@ -162,7 +162,7 @@ namespace ts { let result: T[]; if (array) { result = []; - for (let item of array) { + for (const item of array) { if (!contains(result, item)) { result.push(item); } @@ -173,7 +173,7 @@ namespace ts { export function sum(array: any[], prop: string): number { let result = 0; - for (let v of array) { + for (const v of array) { result += v[prop]; } return result; @@ -181,7 +181,7 @@ namespace ts { export function addRange(to: T[], from: T[]): void { if (to && from) { - for (let v of from) { + for (const v of from) { to.push(v); } } @@ -220,8 +220,8 @@ namespace ts { let high = array.length - 1; while (low <= high) { - let middle = low + ((high - low) >> 1); - let midValue = array[middle]; + const middle = low + ((high - low) >> 1); + const midValue = array[middle]; if (midValue === value) { return middle; @@ -270,7 +270,7 @@ namespace ts { return initial; } - let hasOwnProperty = Object.prototype.hasOwnProperty; + const hasOwnProperty = Object.prototype.hasOwnProperty; export function hasProperty(map: Map, key: string): boolean { return hasOwnProperty.call(map, key); @@ -281,7 +281,7 @@ namespace ts { } export function isEmpty(map: Map) { - for (let id in map) { + for (const id in map) { if (hasProperty(map, id)) { return false; } @@ -290,19 +290,19 @@ namespace ts { } export function clone(object: T): T { - let result: any = {}; - for (let id in object) { + const result: any = {}; + for (const id in object) { result[id] = (object)[id]; } return result; } export function extend(first: Map, second: Map): Map { - let result: Map = {}; - for (let id in first) { + const result: Map = {}; + for (const id in first) { (result as any)[id] = first[id]; } - for (let id in second) { + for (const id in second) { if (!hasProperty(result, id)) { (result as any)[id] = second[id]; } @@ -312,7 +312,7 @@ namespace ts { export function forEachValue(map: Map, callback: (value: T) => U): U { let result: U; - for (let id in map) { + for (const id in map) { if (result = callback(map[id])) break; } return result; @@ -320,7 +320,7 @@ namespace ts { export function forEachKey(map: Map, callback: (key: string) => U): U { let result: U; - for (let id in map) { + for (const id in map) { if (result = callback(id)) break; } return result; @@ -331,7 +331,7 @@ namespace ts { } export function copyMap(source: Map, target: Map): void { - for (let p in source) { + for (const p in source) { target[p] = source[p]; } } @@ -347,7 +347,7 @@ namespace ts { * index in the array will be the one associated with the produced key. */ export function arrayToMap(array: T[], makeKey: (value: T) => string): Map { - let result: Map = {}; + const result: Map = {}; forEach(array, value => { result[makeKey(value)] = value; @@ -383,7 +383,7 @@ namespace ts { 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): Diagnostic { - let end = start + length; + const end = start + length; Debug.assert(start >= 0, "start must be non-negative, is " + start); Debug.assert(length >= 0, "length must be non-negative, is " + length); @@ -479,10 +479,10 @@ namespace ts { function compareMessageText(text1: string | DiagnosticMessageChain, text2: string | DiagnosticMessageChain): Comparison { while (text1 && text2) { // We still have both chains. - let string1 = typeof text1 === "string" ? text1 : text1.messageText; - let string2 = typeof text2 === "string" ? text2 : text2.messageText; + const string1 = typeof text1 === "string" ? text1 : text1.messageText; + const string2 = typeof text2 === "string" ? text2 : text2.messageText; - let res = compareValues(string1, string2); + const res = compareValues(string1, string2); if (res) { return res; } @@ -509,11 +509,11 @@ namespace ts { return diagnostics; } - let newDiagnostics = [diagnostics[0]]; + const newDiagnostics = [diagnostics[0]]; let previousDiagnostic = diagnostics[0]; for (let i = 1; i < diagnostics.length; i++) { - let currentDiagnostic = diagnostics[i]; - let isDupe = compareDiagnostics(currentDiagnostic, previousDiagnostic) === Comparison.EqualTo; + const currentDiagnostic = diagnostics[i]; + const isDupe = compareDiagnostics(currentDiagnostic, previousDiagnostic) === Comparison.EqualTo; if (!isDupe) { newDiagnostics.push(currentDiagnostic); previousDiagnostic = currentDiagnostic; @@ -531,9 +531,9 @@ namespace ts { export function getRootLength(path: string): number { if (path.charCodeAt(0) === CharacterCodes.slash) { if (path.charCodeAt(1) !== CharacterCodes.slash) return 1; - let p1 = path.indexOf("/", 2); + const p1 = path.indexOf("/", 2); if (p1 < 0) return 2; - let p2 = path.indexOf("/", p1 + 1); + const p2 = path.indexOf("/", p1 + 1); if (p2 < 0) return p1 + 1; return p2 + 1; } @@ -549,7 +549,7 @@ namespace ts { if (path.lastIndexOf("file:///", 0) === 0) { return "file:///".length; } - let idx = path.indexOf("://"); + const idx = path.indexOf("://"); if (idx !== -1) { return idx + "://".length; } @@ -558,9 +558,9 @@ namespace ts { export let directorySeparator = "/"; function getNormalizedParts(normalizedSlashedPath: string, rootLength: number) { - let parts = normalizedSlashedPath.substr(rootLength).split(directorySeparator); - let normalized: string[] = []; - for (let part of parts) { + const parts = normalizedSlashedPath.substr(rootLength).split(directorySeparator); + const normalized: string[] = []; + for (const part of parts) { if (part !== ".") { if (part === ".." && normalized.length > 0 && lastOrUndefined(normalized) !== "..") { normalized.pop(); @@ -580,8 +580,8 @@ namespace ts { export function normalizePath(path: string): string { path = normalizeSlashes(path); - let rootLength = getRootLength(path); - let normalized = getNormalizedParts(path, rootLength); + const rootLength = getRootLength(path); + const normalized = getNormalizedParts(path, rootLength); return path.substr(0, rootLength) + normalized.join(directorySeparator); } @@ -598,7 +598,7 @@ namespace ts { } function normalizedPathComponents(path: string, rootLength: number) { - let normalizedParts = getNormalizedParts(path, rootLength); + const normalizedParts = getNormalizedParts(path, rootLength); return [path.substr(0, rootLength)].concat(normalizedParts); } @@ -629,7 +629,7 @@ namespace ts { // In this example the root is: http://www.website.com/ // normalized path components should be ["http://www.website.com/", "folder1", "folder2"] - let urlLength = url.length; + const urlLength = url.length; // Initial root length is http:// part let rootLength = url.indexOf("://") + "://".length; while (rootLength < urlLength) { @@ -650,7 +650,7 @@ namespace ts { } // Find the index of "/" after website.com so the root can be http://www.website.com/ (from existing http://) - let indexOfNextSlash = url.indexOf(directorySeparator, rootLength); + const indexOfNextSlash = url.indexOf(directorySeparator, rootLength); if (indexOfNextSlash !== -1) { // Found the "/" after the website.com so the root is length of http://www.website.com/ // and get components afetr the root normally like any other folder components @@ -676,8 +676,8 @@ namespace ts { } export function getRelativePathToDirectoryOrUrl(directoryPathOrUrl: string, relativeOrAbsolutePath: string, currentDirectory: string, getCanonicalFileName: (fileName: string) => string, isAbsolutePathAnUrl: boolean) { - let pathComponents = getNormalizedPathOrUrlComponents(relativeOrAbsolutePath, currentDirectory); - let directoryComponents = getNormalizedPathOrUrlComponents(directoryPathOrUrl, currentDirectory); + const pathComponents = getNormalizedPathOrUrlComponents(relativeOrAbsolutePath, currentDirectory); + const directoryComponents = getNormalizedPathOrUrlComponents(directoryPathOrUrl, currentDirectory); if (directoryComponents.length > 1 && lastOrUndefined(directoryComponents) === "") { // If the directory path given was of type test/cases/ then we really need components of directory to be only till its name // that is ["test", "cases", ""] needs to be actually ["test", "cases"] @@ -694,7 +694,7 @@ namespace ts { // Get the relative path if (joinStartIndex) { let relativePath = ""; - let relativePathComponents = pathComponents.slice(joinStartIndex, pathComponents.length); + const relativePathComponents = pathComponents.slice(joinStartIndex, pathComponents.length); for (; joinStartIndex < directoryComponents.length; joinStartIndex++) { if (directoryComponents[joinStartIndex] !== "") { relativePath = relativePath + ".." + directorySeparator; @@ -717,7 +717,7 @@ namespace ts { if (!path) { return undefined; } - let i = path.lastIndexOf(directorySeparator); + const i = path.lastIndexOf(directorySeparator); return i < 0 ? path : path.substring(i + 1); } @@ -730,8 +730,8 @@ namespace ts { } export function fileExtensionIs(path: string, extension: string): boolean { - let pathLen = path.length; - let extLen = extension.length; + const pathLen = path.length; + const extLen = extension.length; return pathLen > extLen && path.substr(pathLen - extLen, extLen) === extension; } @@ -749,7 +749,7 @@ namespace ts { export function isSupportedSourceFileName(fileName: string) { if (!fileName) { return false; } - for (let extension of supportedExtensions) { + for (const extension of supportedExtensions) { if (fileExtensionIs(fileName, extension)) { return true; } @@ -759,7 +759,7 @@ namespace ts { const extensionsToRemove = [".d.ts", ".ts", ".js", ".tsx", ".jsx"]; export function removeFileExtension(path: string): string { - for (let ext of extensionsToRemove) { + for (const ext of extensionsToRemove) { if (fileExtensionIs(path, ext)) { return path.substr(0, path.length - ext.length); } @@ -767,9 +767,9 @@ namespace ts { return path; } - let backslashOrDoubleQuote = /[\"\\]/g; - let escapedCharsRegExp = /[\u0000-\u001f\t\v\f\b\r\n\u2028\u2029\u0085]/g; - let escapedCharsMap: Map = { + const backslashOrDoubleQuote = /[\"\\]/g; + const escapedCharsRegExp = /[\u0000-\u001f\t\v\f\b\r\n\u2028\u2029\u0085]/g; + const escapedCharsMap: Map = { "\0": "\\0", "\t": "\\t", "\v": "\\v", @@ -828,7 +828,7 @@ namespace ts { } export namespace Debug { - let currentAssertionLevel = AssertionLevel.None; + const currentAssertionLevel = AssertionLevel.None; export function shouldAssert(level: AssertionLevel): boolean { return currentAssertionLevel >= level; @@ -851,8 +851,8 @@ namespace ts { } export function copyListRemovingItem(item: T, list: T[]) { - let copiedList: T[] = []; - for (let e of list) { + const copiedList: T[] = []; + for (const e of list) { if (e !== item) { copiedList.push(e); } diff --git a/src/compiler/declarationEmitter.ts b/src/compiler/declarationEmitter.ts index 719085f7f6a..ac91a39a78b 100644 --- a/src/compiler/declarationEmitter.ts +++ b/src/compiler/declarationEmitter.ts @@ -31,15 +31,15 @@ namespace ts { } export function getDeclarationDiagnostics(host: EmitHost, resolver: EmitResolver, targetSourceFile: SourceFile): Diagnostic[] { - let diagnostics: Diagnostic[] = []; - let jsFilePath = getOwnEmitOutputFilePath(targetSourceFile, host, ".js"); + const diagnostics: Diagnostic[] = []; + const jsFilePath = getOwnEmitOutputFilePath(targetSourceFile, host, ".js"); emitDeclarations(host, resolver, diagnostics, jsFilePath, targetSourceFile); return diagnostics; } function emitDeclarations(host: EmitHost, resolver: EmitResolver, diagnostics: Diagnostic[], jsFilePath: string, root?: SourceFile): DeclarationEmit { - let newLine = host.getNewLine(); - let compilerOptions = host.getCompilerOptions(); + const newLine = host.getNewLine(); + const compilerOptions = host.getCompilerOptions(); let write: (s: string) => void; let writeLine: () => void; @@ -53,10 +53,10 @@ namespace ts { let currentSourceFile: SourceFile; let reportedDeclarationError = false; let errorNameNode: DeclarationName; - let emitJsDocComments = compilerOptions.removeComments ? function (declaration: Node) { } : writeJsDocComments; - let emit = compilerOptions.stripInternal ? stripInternal : emitNode; + const emitJsDocComments = compilerOptions.removeComments ? function (declaration: Node) { } : writeJsDocComments; + const emit = compilerOptions.stripInternal ? stripInternal : emitNode; - let moduleElementDeclarationEmitInfo: ModuleElementDeclarationEmitInfo[] = []; + const moduleElementDeclarationEmitInfo: ModuleElementDeclarationEmitInfo[] = []; let asynchronousSubModuleDeclarationEmitInfo: ModuleElementDeclarationEmitInfo[]; // Contains the reference paths that needs to go in the declaration file. @@ -69,7 +69,7 @@ namespace ts { if (!compilerOptions.noResolve) { let addedGlobalFileReference = false; forEach(root.referencedFiles, fileReference => { - let referencedFile = tryResolveScriptReference(host, root, fileReference); + const referencedFile = tryResolveScriptReference(host, root, fileReference); // All the references that are not going to be part of same file if (referencedFile && ((referencedFile.flags & NodeFlags.DeclarationFile) || // This is a declare file reference @@ -88,7 +88,7 @@ namespace ts { // create asynchronous output for the importDeclarations if (moduleElementDeclarationEmitInfo.length) { - let oldWriter = writer; + const oldWriter = writer; forEach(moduleElementDeclarationEmitInfo, aliasEmitInfo => { if (aliasEmitInfo.isVisible) { Debug.assert(aliasEmitInfo.node.kind === SyntaxKind.ImportDeclaration); @@ -103,13 +103,13 @@ namespace ts { } else { // Emit references corresponding to this file - let emittedReferencedFiles: SourceFile[] = []; + const emittedReferencedFiles: SourceFile[] = []; forEach(host.getSourceFiles(), sourceFile => { if (!isExternalModuleOrDeclarationFile(sourceFile)) { // Check what references need to be added if (!compilerOptions.noResolve) { forEach(sourceFile.referencedFiles, fileReference => { - let referencedFile = tryResolveScriptReference(host, sourceFile, fileReference); + const referencedFile = tryResolveScriptReference(host, sourceFile, fileReference); // If the reference file is a declaration file or an external module, emit that reference if (referencedFile && (isExternalModuleOrDeclarationFile(referencedFile) && @@ -134,14 +134,14 @@ namespace ts { }; function hasInternalAnnotation(range: CommentRange) { - let text = currentSourceFile.text; - let comment = text.substring(range.pos, range.end); + const text = currentSourceFile.text; + const comment = text.substring(range.pos, range.end); return comment.indexOf("@internal") >= 0; } function stripInternal(node: Node) { if (node) { - let leadingCommentRanges = getLeadingCommentRanges(currentSourceFile.text, node.pos); + const leadingCommentRanges = getLeadingCommentRanges(currentSourceFile.text, node.pos); if (forEach(leadingCommentRanges, hasInternalAnnotation)) { return; } @@ -151,7 +151,7 @@ namespace ts { } function createAndSetNewTextWriterWithSymbolWriter(): EmitTextWriterWithSymbolWriter { - let writer = createTextWriter(newLine); + const writer = createTextWriter(newLine); writer.trackSymbol = trackSymbol; writer.reportInaccessibleThisError = reportInaccessibleThisError; writer.writeKeyword = writer.write; @@ -175,7 +175,7 @@ namespace ts { } function writeAsynchronousModuleElements(nodes: Node[]) { - let oldWriter = writer; + const oldWriter = writer; forEach(nodes, declaration => { let nodeToCheck: Node; if (declaration.kind === SyntaxKind.VariableDeclaration) { @@ -238,7 +238,7 @@ namespace ts { else { // Report error reportedDeclarationError = true; - let errorInfo = writer.getSymbolAccessibilityDiagnostic(symbolAccesibilityResult); + const errorInfo = writer.getSymbolAccessibilityDiagnostic(symbolAccesibilityResult); if (errorInfo) { if (errorInfo.typeName) { diagnostics.push(createDiagnosticForNode(symbolAccesibilityResult.errorNode || errorInfo.errorNode, @@ -297,14 +297,14 @@ namespace ts { } function emitLines(nodes: Node[]) { - for (let node of nodes) { + for (const node of nodes) { emit(node); } } function emitSeparatedList(nodes: Node[], separator: string, eachNodeEmitFn: (node: Node) => void, canEmitFn?: (node: Node) => boolean) { let currentWriterPos = writer.getTextPos(); - for (let node of nodes) { + for (const node of nodes) { if (!canEmitFn || canEmitFn(node)) { if (currentWriterPos !== writer.getTextPos()) { write(separator); @@ -321,7 +321,7 @@ namespace ts { function writeJsDocComments(declaration: Node) { if (declaration) { - let jsDocComments = getJsDocComments(declaration, currentSourceFile); + const jsDocComments = getJsDocComments(declaration, currentSourceFile); emitNewLineBeforeLeadingComments(currentSourceFile, writer, declaration, jsDocComments); // jsDoc comments are emitted at /*leading comment1 */space/*leading comment*/space emitComments(currentSourceFile, writer, jsDocComments, /*trailingSeparator*/ true, newLine, writeCommentRange); @@ -378,8 +378,8 @@ namespace ts { writeTextOfNode(currentSourceFile, entityName); } else { - let left = entityName.kind === SyntaxKind.QualifiedName ? (entityName).left : (entityName).expression; - let right = entityName.kind === SyntaxKind.QualifiedName ? (entityName).right : (entityName).name; + const left = entityName.kind === SyntaxKind.QualifiedName ? (entityName).left : (entityName).expression; + const right = entityName.kind === SyntaxKind.QualifiedName ? (entityName).right : (entityName).name; writeEntityName(left); write("."); writeTextOfNode(currentSourceFile, right); @@ -387,7 +387,7 @@ namespace ts { } function emitEntityName(entityName: EntityName | PropertyAccessExpression) { - let visibilityResult = resolver.isEntityNameVisible(entityName, + const visibilityResult = resolver.isEntityNameVisible(entityName, // Aliases can be written asynchronously so use correct enclosing declaration entityName.parent.kind === SyntaxKind.ImportEqualsDeclaration ? entityName.parent : enclosingDeclaration); @@ -477,13 +477,13 @@ namespace ts { // Note that export default is only allowed at most once in a module, so we // do not need to keep track of created temp names. function getExportDefaultTempVariableName(): string { - let baseName = "_default"; + const baseName = "_default"; if (!hasProperty(currentSourceFile.identifiers, baseName)) { return baseName; } let count = 0; while (true) { - let name = baseName + "_" + (++count); + const name = baseName + "_" + (++count); if (!hasProperty(currentSourceFile.identifiers, name)) { return name; } @@ -497,7 +497,7 @@ namespace ts { } else { // Expression - let tempVarName = getExportDefaultTempVariableName(); + const tempVarName = getExportDefaultTempVariableName(); write("declare var "); write(tempVarName); write(": "); @@ -513,7 +513,7 @@ namespace ts { // Make all the declarations visible for the export name if (node.expression.kind === SyntaxKind.Identifier) { - let nodes = resolver.collectLinkedAliases(node.expression); + const nodes = resolver.collectLinkedAliases(node.expression); // write each of these declarations asynchronously writeAsynchronousModuleElements(nodes); @@ -550,7 +550,7 @@ namespace ts { } else { if (node.kind === SyntaxKind.ImportDeclaration) { - let importDeclaration = node; + const importDeclaration = node; if (importDeclaration.importClause) { isVisible = (importDeclaration.importClause.name && resolver.isDeclarationVisible(importDeclaration.importClause)) || isVisibleNamedBinding(importDeclaration.importClause.namedBindings); @@ -676,7 +676,7 @@ namespace ts { } write("import "); if (node.importClause) { - let currentWriterPos = writer.getTextPos(); + const currentWriterPos = writer.getTextPos(); if (node.importClause.name && resolver.isDeclarationVisible(node.importClause)) { writeTextOfNode(currentSourceFile, node.importClause.name); } @@ -714,7 +714,7 @@ namespace ts { emitImportOrExportSpecifier(node); // Make all the declarations visible for the export name - let nodes = resolver.collectLinkedAliases(node.propertyName || node.name); + const nodes = resolver.collectLinkedAliases(node.propertyName || node.name); // write each of these declarations asynchronously writeAsynchronousModuleElements(nodes); @@ -754,7 +754,7 @@ namespace ts { write("."); writeTextOfNode(currentSourceFile, node.name); } - let prevEnclosingDeclaration = enclosingDeclaration; + const prevEnclosingDeclaration = enclosingDeclaration; enclosingDeclaration = node; write(" {"); writeLine(); @@ -767,7 +767,7 @@ namespace ts { } function writeTypeAliasDeclaration(node: TypeAliasDeclaration) { - let prevEnclosingDeclaration = enclosingDeclaration; + const prevEnclosingDeclaration = enclosingDeclaration; enclosingDeclaration = node; emitJsDocComments(node); emitModuleElementDeclarationFlags(node); @@ -809,7 +809,7 @@ namespace ts { function emitEnumMemberDeclaration(node: EnumMember) { emitJsDocComments(node); writeTextOfNode(currentSourceFile, node.name); - let enumMemberValue = resolver.getConstantValue(node); + const enumMemberValue = resolver.getConstantValue(node); if (enumMemberValue !== undefined) { write(" = "); write(enumMemberValue.toString()); @@ -959,10 +959,10 @@ namespace ts { write("class "); writeTextOfNode(currentSourceFile, node.name); - let prevEnclosingDeclaration = enclosingDeclaration; + const prevEnclosingDeclaration = enclosingDeclaration; enclosingDeclaration = node; emitTypeParameters(node.typeParameters); - let baseTypeNode = getClassExtendsHeritageClauseElement(node); + const baseTypeNode = getClassExtendsHeritageClauseElement(node); if (baseTypeNode) { emitHeritageClause([baseTypeNode], /*isImplementsList*/ false); } @@ -983,7 +983,7 @@ namespace ts { emitModuleElementDeclarationFlags(node); write("interface "); writeTextOfNode(currentSourceFile, node.name); - let prevEnclosingDeclaration = enclosingDeclaration; + const prevEnclosingDeclaration = enclosingDeclaration; enclosingDeclaration = node; emitTypeParameters(node.typeParameters); emitHeritageClause(getInterfaceBaseTypeNodes(node), /*isImplementsList*/ false); @@ -1069,7 +1069,7 @@ namespace ts { } function getVariableDeclarationTypeVisibilityError(symbolAccesibilityResult: SymbolAccessiblityResult): SymbolAccessibilityDiagnostic { - let diagnosticMessage = getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccesibilityResult); + const diagnosticMessage = getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccesibilityResult); return diagnosticMessage !== undefined ? { diagnosticMessage, errorNode: node, @@ -1083,8 +1083,8 @@ namespace ts { // For example: // original: var [, c,,] = [ 2,3,4] // emitted: declare var c: number; // instead of declare var c:number, ; - let elements: Node[] = []; - for (let element of bindingPattern.elements) { + const elements: Node[] = []; + for (const element of bindingPattern.elements) { if (element.kind !== SyntaxKind.OmittedExpression) { elements.push(element); } @@ -1094,7 +1094,7 @@ namespace ts { function emitBindingElement(bindingElement: BindingElement) { function getBindingElementTypeVisibilityError(symbolAccesibilityResult: SymbolAccessiblityResult): SymbolAccessibilityDiagnostic { - let diagnosticMessage = getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccesibilityResult); + const diagnosticMessage = getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccesibilityResult); return diagnosticMessage !== undefined ? { diagnosticMessage, errorNode: bindingElement, @@ -1150,7 +1150,7 @@ namespace ts { return; } - let accessors = getAllAccessorDeclarations((node.parent).members, node); + const accessors = getAllAccessorDeclarations((node.parent).members, node); let accessorWithTypeAnnotation: AccessorDeclaration; if (node === accessors.firstAccessor) { @@ -1163,7 +1163,7 @@ namespace ts { let type = getTypeAnnotationFromAccessor(node); if (!type) { // couldn't get type for the first accessor, try the another one - let anotherAccessor = node.kind === SyntaxKind.GetAccessor ? accessors.setAccessor : accessors.getAccessor; + const anotherAccessor = node.kind === SyntaxKind.GetAccessor ? accessors.setAccessor : accessors.getAccessor; type = getTypeAnnotationFromAccessor(anotherAccessor); if (type) { accessorWithTypeAnnotation = anotherAccessor; @@ -1280,7 +1280,7 @@ namespace ts { write("("); } - let prevEnclosingDeclaration = enclosingDeclaration; + const prevEnclosingDeclaration = enclosingDeclaration; enclosingDeclaration = node; // Parameters @@ -1294,7 +1294,7 @@ namespace ts { } // If this is not a constructor and is not private, emit the return type - let isFunctionTypeOrConstructorType = node.kind === SyntaxKind.FunctionType || node.kind === SyntaxKind.ConstructorType; + const isFunctionTypeOrConstructorType = node.kind === SyntaxKind.FunctionType || node.kind === SyntaxKind.ConstructorType; if (isFunctionTypeOrConstructorType || node.parent.kind === SyntaxKind.TypeLiteral) { // Emit type literal signature return type only if specified if (node.type) { @@ -1410,7 +1410,7 @@ namespace ts { } function getParameterDeclarationTypeVisibilityError(symbolAccesibilityResult: SymbolAccessiblityResult): SymbolAccessibilityDiagnostic { - let diagnosticMessage: DiagnosticMessage = getParameterDeclarationTypeVisibilityDiagnosticMessage(symbolAccesibilityResult); + const diagnosticMessage: DiagnosticMessage = getParameterDeclarationTypeVisibilityDiagnosticMessage(symbolAccesibilityResult); return diagnosticMessage !== undefined ? { diagnosticMessage, errorNode: node, @@ -1483,7 +1483,7 @@ namespace ts { } else if (bindingPattern.kind === SyntaxKind.ArrayBindingPattern) { write("["); - let elements = bindingPattern.elements; + const elements = bindingPattern.elements; emitCommaList(elements, emitBindingElement); if (elements && elements.hasTrailingComma) { write(", "); @@ -1494,7 +1494,7 @@ namespace ts { function emitBindingElement(bindingElement: BindingElement) { function getBindingElementTypeVisibilityError(symbolAccesibilityResult: SymbolAccessiblityResult): SymbolAccessibilityDiagnostic { - let diagnosticMessage = getParameterDeclarationTypeVisibilityDiagnosticMessage(symbolAccesibilityResult); + const diagnosticMessage = getParameterDeclarationTypeVisibilityDiagnosticMessage(symbolAccesibilityResult); return diagnosticMessage !== undefined ? { diagnosticMessage, errorNode: bindingElement, @@ -1609,11 +1609,11 @@ namespace ts { /* @internal */ export function writeDeclarationFile(jsFilePath: string, sourceFile: SourceFile, host: EmitHost, resolver: EmitResolver, diagnostics: Diagnostic[]) { - let emitDeclarationResult = emitDeclarations(host, resolver, diagnostics, jsFilePath, sourceFile); + const emitDeclarationResult = emitDeclarations(host, resolver, diagnostics, jsFilePath, sourceFile); // TODO(shkamat): Should we not write any declaration file if any of them can produce error, // or should we just not write this file like we are doing now if (!emitDeclarationResult.reportedDeclarationError) { - let declarationOutput = emitDeclarationResult.referencePathsOutput + const declarationOutput = emitDeclarationResult.referencePathsOutput + getDeclarationOutput(emitDeclarationResult.synchronousDeclarationOutput, emitDeclarationResult.moduleElementDeclarationEmitInfo); writeFile(host, diagnostics, removeFileExtension(jsFilePath) + ".d.ts", declarationOutput, host.getCompilerOptions().emitBOM); } diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index f0ec75c005c..464bd51a91d 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -15,7 +15,7 @@ namespace ts { Return = 1 << 3 } - let entities: Map = { + const entities: Map = { "quot": 0x0022, "amp": 0x0026, "apos": 0x0027, @@ -324,19 +324,19 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi }); };`; - let compilerOptions = host.getCompilerOptions(); - let languageVersion = compilerOptions.target || ScriptTarget.ES3; - let modulekind = compilerOptions.module ? compilerOptions.module : languageVersion === ScriptTarget.ES6 ? ModuleKind.ES6 : ModuleKind.None; - let sourceMapDataList: SourceMapData[] = compilerOptions.sourceMap || compilerOptions.inlineSourceMap ? [] : undefined; + const compilerOptions = host.getCompilerOptions(); + const languageVersion = compilerOptions.target || ScriptTarget.ES3; + const modulekind = compilerOptions.module ? compilerOptions.module : languageVersion === ScriptTarget.ES6 ? ModuleKind.ES6 : ModuleKind.None; + const sourceMapDataList: SourceMapData[] = compilerOptions.sourceMap || compilerOptions.inlineSourceMap ? [] : undefined; let diagnostics: Diagnostic[] = []; - let newLine = host.getNewLine(); - let jsxDesugaring = host.getCompilerOptions().jsx !== JsxEmit.Preserve; - let shouldEmitJsx = (s: SourceFile) => (s.languageVariant === LanguageVariant.JSX && !jsxDesugaring); + const newLine = host.getNewLine(); + const jsxDesugaring = host.getCompilerOptions().jsx !== JsxEmit.Preserve; + const shouldEmitJsx = (s: SourceFile) => (s.languageVariant === LanguageVariant.JSX && !jsxDesugaring); if (targetSourceFile === undefined) { forEach(host.getSourceFiles(), sourceFile => { if (shouldEmitToOwnFile(sourceFile, compilerOptions)) { - let jsFilePath = getOwnEmitOutputFilePath(sourceFile, host, shouldEmitJsx(sourceFile) ? ".jsx" : ".js"); + const jsFilePath = getOwnEmitOutputFilePath(sourceFile, host, shouldEmitJsx(sourceFile) ? ".jsx" : ".js"); emitFile(jsFilePath, sourceFile); } }); @@ -348,7 +348,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi else { // targetSourceFile is specified (e.g calling emitter from language service or calling getSemanticDiagnostic from language service) if (shouldEmitToOwnFile(targetSourceFile, compilerOptions)) { - let jsFilePath = getOwnEmitOutputFilePath(targetSourceFile, host, shouldEmitJsx(targetSourceFile) ? ".jsx" : ".js"); + const jsFilePath = getOwnEmitOutputFilePath(targetSourceFile, host, shouldEmitJsx(targetSourceFile) ? ".jsx" : ".js"); emitFile(jsFilePath, targetSourceFile); } else if (!isDeclarationFile(targetSourceFile) && (compilerOptions.outFile || compilerOptions.out)) { @@ -471,8 +471,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi } function emitJavaScript(jsFilePath: string, root?: SourceFile) { - let writer = createTextWriter(newLine); - let { write, writeTextOfNode, writeLine, increaseIndent, decreaseIndent } = writer; + const writer = createTextWriter(newLine); + const { write, writeTextOfNode, writeLine, increaseIndent, decreaseIndent } = writer; let currentSourceFile: SourceFile; // name of an exporter function if file is a System external module @@ -483,8 +483,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi // var x;... exporter("x", x = 1) let exportFunctionForFile: string; - let generatedNameSet: Map = {}; - let nodeToGeneratedName: string[] = []; + const generatedNameSet: Map = {}; + const nodeToGeneratedName: string[] = []; let computedPropertyNamesToGeneratedNames: string[]; let convertedLoopState: ConvertedLoopState; @@ -537,9 +537,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi let sourceMapData: SourceMapData; /** If removeComments is true, no leading-comments needed to be emitted **/ - let emitLeadingCommentsOfPosition = compilerOptions.removeComments ? function (pos: number) { } : emitLeadingCommentsOfPositionWorker; + const emitLeadingCommentsOfPosition = compilerOptions.removeComments ? function (pos: number) { } : emitLeadingCommentsOfPositionWorker; - let moduleEmitDelegates: Map<(node: SourceFile) => void> = { + const moduleEmitDelegates: Map<(node: SourceFile) => void> = { [ModuleKind.ES6]: emitES6Module, [ModuleKind.AMD]: emitAMDModule, [ModuleKind.System]: emitSystemModule, @@ -584,18 +584,18 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi // Note that names generated by makeTempVariableName and makeUniqueName will never conflict. function makeTempVariableName(flags: TempFlags): string { if (flags && !(tempFlags & flags)) { - let name = flags === TempFlags._i ? "_i" : "_n"; + const name = flags === TempFlags._i ? "_i" : "_n"; if (isUniqueName(name)) { tempFlags |= flags; return name; } } while (true) { - let count = tempFlags & TempFlags.CountMask; + const count = tempFlags & TempFlags.CountMask; tempFlags++; // Skip over 'i' and 'n' if (count !== 8 && count !== 13) { - let name = count < 26 ? "_" + String.fromCharCode(CharacterCodes.a + count) : "_" + (count - 26); + const name = count < 26 ? "_" + String.fromCharCode(CharacterCodes.a + count) : "_" + (count - 26); if (isUniqueName(name)) { return name; } @@ -614,7 +614,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi } let i = 1; while (true) { - let generatedName = baseName + i; + const generatedName = baseName + i; if (isUniqueName(generatedName)) { return generatedNameSet[generatedName] = generatedName; } @@ -623,14 +623,14 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi } function generateNameForModuleOrEnum(node: ModuleDeclaration | EnumDeclaration) { - let name = node.name.text; + const name = node.name.text; // Use module/enum name itself if it is unique, otherwise make a unique variation return isUniqueLocalName(name, node) ? name : makeUniqueName(name); } function generateNameForImportOrExportDeclaration(node: ImportDeclaration | ExportDeclaration) { - let expr = getExternalModuleName(node); - let baseName = expr.kind === SyntaxKind.StringLiteral ? + const expr = getExternalModuleName(node); + const baseName = expr.kind === SyntaxKind.StringLiteral ? escapeIdentifier(makeIdentifierFromModuleName((expr).text)) : "module"; return makeUniqueName(baseName); } @@ -663,7 +663,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi } function getGeneratedNameForNode(node: Node) { - let id = getNodeId(node); + const id = getNodeId(node); return nodeToGeneratedName[id] || (nodeToGeneratedName[id] = unescapeIdentifier(generateNameForNode(node))); } @@ -674,8 +674,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi let sourceMapSourceIndex = -1; // Names and its index map - let sourceMapNameIndexMap: Map = {}; - let sourceMapNameIndices: number[] = []; + const sourceMapNameIndexMap: Map = {}; + const sourceMapNameIndices: number[] = []; function getSourceMapNameIndex() { return sourceMapNameIndices.length ? lastOrUndefined(sourceMapNameIndices) : -1; } @@ -771,14 +771,14 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi } function recordSourceMapSpan(pos: number) { - let sourceLinePos = getLineAndCharacterOfPosition(currentSourceFile, pos); + const sourceLinePos = getLineAndCharacterOfPosition(currentSourceFile, pos); // Convert the location to be one-based. sourceLinePos.line++; sourceLinePos.character++; - let emittedLine = writer.getLine(); - let emittedColumn = writer.getColumn(); + const emittedLine = writer.getLine(); + const emittedColumn = writer.getColumn(); // If this location wasn't recorded or the location in source is going backwards, record the span if (!lastRecordedSourceMapSpan || @@ -818,9 +818,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi } function writeTextWithSpanRecord(tokenKind: SyntaxKind, startPos: number, emitFn?: () => void) { - let tokenStartPos = ts.skipTrivia(currentSourceFile.text, startPos); + const tokenStartPos = ts.skipTrivia(currentSourceFile.text, startPos); recordSourceMapSpan(tokenStartPos); - let tokenEndPos = emitTokenText(tokenKind, tokenStartPos, emitFn); + const tokenEndPos = emitTokenText(tokenKind, tokenStartPos, emitFn); recordSourceMapSpan(tokenEndPos); return tokenEndPos; } @@ -829,7 +829,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi // Add the file to tsFilePaths // If sourceroot option: Use the relative path corresponding to the common directory path // otherwise source locations relative to map file location - let sourcesDirectoryPath = compilerOptions.sourceRoot ? host.getCommonSourceDirectory() : sourceMapDir; + const sourcesDirectoryPath = compilerOptions.sourceRoot ? host.getCommonSourceDirectory() : sourceMapDir; sourceMapData.sourceMapSources.push(getRelativePathToDirectoryOrUrl(sourcesDirectoryPath, node.fileName, @@ -857,12 +857,12 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi function recordScopeNameStart(scopeName: string) { let scopeNameIndex = -1; if (scopeName) { - let parentIndex = getSourceMapNameIndex(); + const parentIndex = getSourceMapNameIndex(); if (parentIndex !== -1) { // Child scopes are always shown with a dot (even if they have no name), // unless it is a computed property. Then it is shown with brackets, // but the brackets are included in the name. - let name = (node).name; + const name = (node).name; if (!name || name.kind !== SyntaxKind.ComputedPropertyName) { scopeName = "." + scopeName; } @@ -894,7 +894,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi node.kind === SyntaxKind.EnumDeclaration) { // Declaration and has associated name use it if ((node).name) { - let name = (node).name; + const name = (node).name; // For computed property names, the text will include the brackets scopeName = name.kind === SyntaxKind.ComputedPropertyName ? getTextOfNode(name) @@ -920,7 +920,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi function serializeSourceMapContents(version: number, file: string, sourceRoot: string, sources: string[], names: string[], mappings: string, sourcesContent?: string[]) { if (typeof JSON !== "undefined") { - let map: any = { + const map: any = { version, file, sourceRoot, @@ -953,7 +953,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi function writeJavaScriptAndSourceMapFile(emitOutput: string, writeByteOrderMark: boolean) { encodeLastRecordedSourceMapSpan(); - let sourceMapText = serializeSourceMapContents( + const sourceMapText = serializeSourceMapContents( 3, sourceMapData.sourceMapFile, sourceMapData.sourceMapSourceRoot, @@ -967,7 +967,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi let sourceMapUrl: string; if (compilerOptions.inlineSourceMap) { // Encode the sourceMap into the sourceMap url - let base64SourceMapText = convertToBase64(sourceMapText); + const base64SourceMapText = convertToBase64(sourceMapText); sourceMapUrl = `//# sourceMappingURL=data:application/json;base64,${base64SourceMapText}`; } else { @@ -981,7 +981,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi } // Initialize source map data - let sourceMapJsFile = getBaseFileName(normalizeSlashes(jsFilePath)); + const sourceMapJsFile = getBaseFileName(normalizeSlashes(jsFilePath)); sourceMapData = { sourceMapFilePath: jsFilePath + ".map", jsSourceMappingURL: sourceMapJsFile + ".map", @@ -1065,7 +1065,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi // Create a temporary variable with a unique unused name. function createTempVariable(flags: TempFlags): Identifier { - let result = createSynthesizedNode(SyntaxKind.Identifier); + const result = createSynthesizedNode(SyntaxKind.Identifier); result.text = makeTempVariableName(flags); return result; } @@ -1078,7 +1078,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi } function createAndRecordTempVariable(flags: TempFlags): Identifier { - let temp = createTempVariable(flags); + const temp = createTempVariable(flags); recordTempDeclaration(temp); return temp; @@ -1099,7 +1099,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi } function emitTokenText(tokenKind: SyntaxKind, startPos: number, emitFn?: () => void) { - let tokenString = tokenToString(tokenKind); + const tokenString = tokenToString(tokenKind); if (emitFn) { emitFn(); } @@ -1193,7 +1193,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi write(", "); } } - let node = nodes[start + i]; + const node = nodes[start + i]; // This emitting is to make sure we emit following comment properly // ...(x, /*comment1*/ y)... // ^ => node.pos @@ -1245,7 +1245,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi } function emitLiteral(node: LiteralExpression) { - let text = getLiteralText(node); + const text = getLiteralText(node); if ((compilerOptions.sourceMap || compilerOptions.inlineSourceMap) && (node.kind === SyntaxKind.StringLiteral || isTemplateLiteralKind(node.kind))) { writer.writeLiteral(text); @@ -1306,7 +1306,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi // thus we need to remove those characters. // First template piece starts with "`", others with "}" // Last template piece ends with "`", others with "${" - let isLast = node.kind === SyntaxKind.NoSubstitutionTemplateLiteral || node.kind === SyntaxKind.TemplateTail; + const isLast = node.kind === SyntaxKind.NoSubstitutionTemplateLiteral || node.kind === SyntaxKind.TemplateTail; text = text.substring(1, text.length - (isLast ? 1 : 2)); // Newline normalization: @@ -1334,7 +1334,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi } function emitDownlevelTaggedTemplate(node: TaggedTemplateExpression) { - let tempVariable = createAndRecordTempVariable(TempFlags.Auto); + const tempVariable = createAndRecordTempVariable(TempFlags.Auto); write("("); emit(tempVariable); write(" = "); @@ -1354,7 +1354,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi if (node.template.kind === SyntaxKind.TemplateExpression) { forEach((node.template).templateSpans, templateSpan => { write(", "); - let needsParens = templateSpan.expression.kind === SyntaxKind.BinaryExpression + const needsParens = templateSpan.expression.kind === SyntaxKind.BinaryExpression && (templateSpan.expression).operatorToken.kind === SyntaxKind.CommaToken; emitParenthesizedIf(templateSpan.expression, needsParens); }); @@ -1370,7 +1370,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi return; } - let emitOuterParens = isExpression(node.parent) + const emitOuterParens = isExpression(node.parent) && templateNeedsParens(node, node.parent); if (emitOuterParens) { @@ -1384,7 +1384,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi } for (let i = 0, n = node.templateSpans.length; i < n; i++) { - let templateSpan = node.templateSpans[i]; + const templateSpan = node.templateSpans[i]; // Check if the expression has operands and binds its operands less closely than binary '+'. // If it does, we need to wrap the expression in parentheses. Otherwise, something like @@ -1395,7 +1395,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi // ("abc" + 1) << (2 + "") // rather than // "abc" + (1 << 2) + "" - let needsParens = templateSpan.expression.kind !== SyntaxKind.ParenthesizedExpression + const needsParens = templateSpan.expression.kind !== SyntaxKind.ParenthesizedExpression && comparePrecedenceToBinaryPlus(templateSpan.expression) !== Comparison.GreaterThan; if (i > 0 || headEmitted) { @@ -1538,7 +1538,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi } function emitJsxElement(openingNode: JsxOpeningLikeElement, children?: JsxChild[]) { - let syntheticReactRef = createSynthesizedNode(SyntaxKind.Identifier); + const syntheticReactRef = createSynthesizedNode(SyntaxKind.Identifier); syntheticReactRef.text = "React"; syntheticReactRef.parent = openingNode; @@ -1557,7 +1557,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi else { // Either emit one big object literal (no spread attribs), or // a call to React.__spread - let attrs = openingNode.attributes; + const attrs = openingNode.attributes; if (forEach(attrs, attr => attr.kind === SyntaxKind.JsxSpreadAttribute)) { emitExpressionIdentifier(syntheticReactRef); write(".__spread("); @@ -1621,7 +1621,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi // Don't emit empty strings if (children[i].kind === SyntaxKind.JsxText) { - let text = getTextToEmit(children[i]); + const text = getTextToEmit(children[i]); if (text !== undefined) { write(", \""); write(text); @@ -1780,7 +1780,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi } function isExpressionIdentifier(node: Node): boolean { - let parent = node.parent; + const parent = node.parent; switch (parent.kind) { case SyntaxKind.ArrayLiteralExpression: case SyntaxKind.AsExpression: @@ -1848,7 +1848,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi return; } - let container = resolver.getReferencedExportContainer(node); + const container = resolver.getReferencedExportContainer(node); if (container) { if (container.kind === SyntaxKind.SourceFile) { // Identifier references module export @@ -1864,7 +1864,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi } else { if (modulekind !== ModuleKind.ES6) { - let declaration = resolver.getReferencedImportDeclaration(node); + const declaration = resolver.getReferencedImportDeclaration(node); if (declaration) { if (declaration.kind === SyntaxKind.ImportClause) { // Identifier references default import @@ -1875,8 +1875,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi else if (declaration.kind === SyntaxKind.ImportSpecifier) { // Identifier references named import write(getGeneratedNameForNode(declaration.parent.parent.parent)); - let name = (declaration).propertyName || (declaration).name; - let identifier = getSourceTextOfNodeFromSourceFile(currentSourceFile, name); + const name = (declaration).propertyName || (declaration).name; + const identifier = getSourceTextOfNodeFromSourceFile(currentSourceFile, name); if (languageVersion === ScriptTarget.ES3 && identifier === "default") { write(`["default"]`); } @@ -1890,7 +1890,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi } if (languageVersion !== ScriptTarget.ES6) { - let declaration = resolver.getReferencedNestedRedeclaration(node); + const declaration = resolver.getReferencedNestedRedeclaration(node); if (declaration) { write(getGeneratedNameForNode(declaration.name)); return; @@ -1908,7 +1908,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi function isNameOfNestedRedeclaration(node: Identifier) { if (languageVersion < ScriptTarget.ES6) { - let parent = node.parent; + const parent = node.parent; switch (parent.kind) { case SyntaxKind.BindingElement: case SyntaxKind.ClassDeclaration: @@ -1924,7 +1924,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi if (convertedLoopState) { if (node.text == "arguments" && resolver.isArgumentsLocalBinding(node)) { // in converted loop body arguments cannot be used directly. - let name = convertedLoopState.argumentsName || (convertedLoopState.argumentsName = makeUniqueName("arguments")); + const name = convertedLoopState.argumentsName || (convertedLoopState.argumentsName = makeUniqueName("arguments")); write(name); return; } @@ -1961,7 +1961,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi write("super"); } else { - let flags = resolver.getNodeCheckFlags(node); + const flags = resolver.getNodeCheckFlags(node); if (flags & NodeCheckFlags.SuperInstance) { write("_super.prototype"); } @@ -1973,14 +1973,14 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi function emitObjectBindingPattern(node: BindingPattern) { write("{ "); - let elements = node.elements; + const elements = node.elements; emitList(elements, 0, elements.length, /*multiLine*/ false, /*trailingComma*/ elements.hasTrailingComma); write(" }"); } function emitArrayBindingPattern(node: BindingPattern) { write("["); - let elements = node.elements; + const elements = node.elements; emitList(elements, 0, elements.length, /*multiLine*/ false, /*trailingComma*/ elements.hasTrailingComma); write("]"); } @@ -2019,7 +2019,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi } function emitAwaitExpression(node: AwaitExpression) { - let needsParenthesis = needsParenthesisForAwaitExpressionAsYield(node); + const needsParenthesis = needsParenthesisForAwaitExpressionAsYield(node); if (needsParenthesis) { write("("); } @@ -2060,7 +2060,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi function emitListWithSpread(elements: Expression[], needsUniqueCopy: boolean, multiLine: boolean, trailingComma: boolean, useConcat: boolean) { let pos = 0; let group = 0; - let length = elements.length; + const length = elements.length; while (pos < length) { // Emit using the pattern .concat(, , ...) if (group === 1 && useConcat) { @@ -2108,7 +2108,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi } function emitArrayLiteral(node: ArrayLiteralExpression) { - let elements = node.elements; + const elements = node.elements; if (elements.length === 0) { write("[]"); } @@ -2132,7 +2132,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi write("{"); if (numElements > 0) { - let properties = node.properties; + const properties = node.properties; // If we are not doing a downlevel transformation for object literals, // then try to preserve the original shape of the object literal. @@ -2141,7 +2141,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi emitLinePreservingList(node, properties, /* allowTrailingComma */ languageVersion >= ScriptTarget.ES5, /* spacesBetweenBraces */ true); } else { - let multiLine = (node.flags & NodeFlags.MultiLine) !== 0; + const multiLine = (node.flags & NodeFlags.MultiLine) !== 0; if (!multiLine) { write(" "); } @@ -2164,8 +2164,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi } function emitDownlevelObjectLiteralWithComputedProperties(node: ObjectLiteralExpression, firstComputedPropertyIndex: number) { - let multiLine = (node.flags & NodeFlags.MultiLine) !== 0; - let properties = node.properties; + const multiLine = (node.flags & NodeFlags.MultiLine) !== 0; + const properties = node.properties; write("("); @@ -2175,7 +2175,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi // For computed properties, we need to create a unique handle to the object // literal so we can modify it without risking internal assignments tainting the object. - let tempVar = createAndRecordTempVariable(TempFlags.Auto); + const tempVar = createAndRecordTempVariable(TempFlags.Auto); // Write out the first non-computed properties // (or all properties if none of them are computed), @@ -2187,12 +2187,12 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi for (let i = firstComputedPropertyIndex, n = properties.length; i < n; i++) { writeComma(); - let property = properties[i]; + const property = properties[i]; emitStart(property); if (property.kind === SyntaxKind.GetAccessor || property.kind === SyntaxKind.SetAccessor) { // TODO (drosen): Reconcile with 'emitMemberFunctions'. - let accessors = getAllAccessorDeclarations(node.properties, property); + const accessors = getAllAccessorDeclarations(node.properties, property); if (property !== accessors.firstAccessor) { continue; } @@ -2283,10 +2283,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi } function emitObjectLiteral(node: ObjectLiteralExpression): void { - let properties = node.properties; + const properties = node.properties; if (languageVersion < ScriptTarget.ES6) { - let numProperties = properties.length; + const numProperties = properties.length; // Find the first computed property. // Everything until that point can be emitted as part of the initial object literal. @@ -2298,7 +2298,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi } } - let hasComputedProperty = numInitialNonComputedProperties !== properties.length; + const hasComputedProperty = numInitialNonComputedProperties !== properties.length; if (hasComputedProperty) { emitDownlevelObjectLiteralWithComputedProperties(node, numInitialNonComputedProperties); return; @@ -2311,7 +2311,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi } function createBinaryExpression(left: Expression, operator: SyntaxKind, right: Expression, startsOnNewLine?: boolean): BinaryExpression { - let result = createSynthesizedNode(SyntaxKind.BinaryExpression, startsOnNewLine); + const result = createSynthesizedNode(SyntaxKind.BinaryExpression, startsOnNewLine); result.operatorToken = createSynthesizedNode(operator); result.left = left; result.right = right; @@ -2320,7 +2320,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi } function createPropertyAccessExpression(expression: Expression, name: Identifier): PropertyAccessExpression { - let result = createSynthesizedNode(SyntaxKind.PropertyAccessExpression); + const result = createSynthesizedNode(SyntaxKind.PropertyAccessExpression); result.expression = parenthesizeForAccess(expression); result.dotToken = createSynthesizedNode(SyntaxKind.DotToken); result.name = name; @@ -2329,7 +2329,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi } function createElementAccessExpression(expression: Expression, argumentExpression: Expression): ElementAccessExpression { - let result = createSynthesizedNode(SyntaxKind.ElementAccessExpression); + const result = createSynthesizedNode(SyntaxKind.ElementAccessExpression); result.expression = parenthesizeForAccess(expression); result.argumentExpression = argumentExpression; @@ -2357,7 +2357,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi return expr; } - let node = createSynthesizedNode(SyntaxKind.ParenthesizedExpression); + const node = createSynthesizedNode(SyntaxKind.ParenthesizedExpression); node.expression = expr; return node; } @@ -2396,7 +2396,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi // Return true if identifier resolves to an exported member of a namespace function isNamespaceExportReference(node: Identifier) { - let container = resolver.getReferencedExportContainer(node); + const container = resolver.getReferencedExportContainer(node); return container && container.kind !== SyntaxKind.SourceFile; } @@ -2426,11 +2426,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi } function tryEmitConstantValue(node: PropertyAccessExpression | ElementAccessExpression): boolean { - let constantValue = tryGetConstEnumValue(node); + const constantValue = tryGetConstEnumValue(node); if (constantValue !== undefined) { write(constantValue.toString()); if (!compilerOptions.removeComments) { - let propertyName: string = node.kind === SyntaxKind.PropertyAccessExpression ? declarationNameToString((node).name) : getTextOfNode((node).argumentExpression); + const propertyName: string = node.kind === SyntaxKind.PropertyAccessExpression ? declarationNameToString((node).name) : getTextOfNode((node).argumentExpression); write(" /* " + propertyName + " */"); } return true; @@ -2452,10 +2452,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi // If the code is not indented, an optional valueToWriteWhenNotIndenting will be // emitted instead. function indentIfOnDifferentLines(parent: Node, node1: Node, node2: Node, valueToWriteWhenNotIndenting?: string): boolean { - let realNodesAreOnDifferentLines = !nodeIsSynthesized(parent) && !nodeEndIsOnSameLineAsNodeStart(node1, node2); + const realNodesAreOnDifferentLines = !nodeIsSynthesized(parent) && !nodeEndIsOnSameLineAsNodeStart(node1, node2); // Always use a newline for synthesized code if the synthesizer desires it. - let synthesizedNodeIsOnDifferentLine = synthesizedNodeStartsOnNewLine(node2); + const synthesizedNodeIsOnDifferentLine = synthesizedNodeStartsOnNewLine(node2); if (realNodesAreOnDifferentLines || synthesizedNodeIsOnDifferentLine) { increaseIndent(); @@ -2476,7 +2476,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi } emit(node.expression); - let indentedBeforeDot = indentIfOnDifferentLines(node, node.expression, node.dotToken); + const indentedBeforeDot = indentIfOnDifferentLines(node, node.expression, node.dotToken); // 1 .toString is a valid property access, emit a space after the literal // Also emit a space if expression is a integer const enum value - it will appear in generated code as numeric literal @@ -2484,12 +2484,12 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi if (!indentedBeforeDot) { if (node.expression.kind === SyntaxKind.NumericLiteral) { // check if numeric literal was originally written with a dot - let text = getSourceTextOfNodeFromSourceFile(currentSourceFile, node.expression); + const text = getSourceTextOfNodeFromSourceFile(currentSourceFile, node.expression); shouldEmitSpace = text.indexOf(tokenToString(SyntaxKind.DotToken)) < 0; } else { // check if constant enum value is integer - let constantValue = tryGetConstEnumValue(node.expression); + const constantValue = tryGetConstEnumValue(node.expression); // isFinite handles cases when constantValue is undefined shouldEmitSpace = isFinite(constantValue) && Math.floor(constantValue) === constantValue; } @@ -2502,7 +2502,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi write("."); } - let indentedAfterDot = indentIfOnDifferentLines(node, node.dotToken, node.name); + const indentedAfterDot = indentIfOnDifferentLines(node, node.dotToken, node.name); emit(node.name); decreaseIndentIf(indentedBeforeDot, indentedAfterDot); } @@ -2518,7 +2518,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi emitEntityNameAsExpression(node.left, useFallback); } else if (useFallback) { - let temp = createAndRecordTempVariable(TempFlags.Auto); + const temp = createAndRecordTempVariable(TempFlags.Auto); write("("); emitNodeWithoutSourceMap(temp); write(" = "); @@ -2578,7 +2578,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi emit(node); return node; } - let temp = createAndRecordTempVariable(TempFlags.Auto); + const temp = createAndRecordTempVariable(TempFlags.Auto); write("("); emit(temp); @@ -2590,7 +2590,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi function emitCallWithSpread(node: CallExpression) { let target: Expression; - let expr = skipParentheses(node.expression); + const expr = skipParentheses(node.expression); if (expr.kind === SyntaxKind.PropertyAccessExpression) { // Target will be emitted as "this" argument target = emitCallTarget((expr).expression); @@ -2684,7 +2684,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi hasSpreadElement(node.arguments)) { write("("); - let target = emitCallTarget(node.expression); + const target = emitCallTarget(node.expression); write(".bind.apply("); emit(target); write(", [void 0].concat("); @@ -2816,7 +2816,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi // expression a prefix increment whose operand is a plus expression - (++(+x)) // The same is true of minus of course. if (node.operand.kind === SyntaxKind.PrefixUnaryExpression) { - let operand = node.operand; + const operand = node.operand; if (node.operator === SyntaxKind.PlusToken && (operand.operator === SyntaxKind.PlusToken || operand.operator === SyntaxKind.PlusPlusToken)) { write(" "); } @@ -2895,7 +2895,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi * @param node a binary expression node containing exponentiationOperator (**, **=) */ function emitExponentiationOperator(node: BinaryExpression) { - let leftHandSideExpression = node.left; + const leftHandSideExpression = node.left; if (node.operatorToken.kind === SyntaxKind.AsteriskAsteriskEqualsToken) { let synthesizedLHS: ElementAccessExpression | PropertyAccessExpression; let shouldEmitParentheses = false; @@ -2905,12 +2905,12 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi synthesizedLHS = createSynthesizedNode(SyntaxKind.ElementAccessExpression, /*startsOnNewLine*/ false); - let identifier = emitTempVariableAssignment(leftHandSideExpression.expression, /*canDefinedTempVariablesInPlaces*/ false, /*shouldEmitCommaBeforeAssignment*/ false); + const identifier = emitTempVariableAssignment(leftHandSideExpression.expression, /*canDefinedTempVariablesInPlaces*/ false, /*shouldEmitCommaBeforeAssignment*/ false); synthesizedLHS.expression = identifier; if (leftHandSideExpression.argumentExpression.kind !== SyntaxKind.NumericLiteral && leftHandSideExpression.argumentExpression.kind !== SyntaxKind.StringLiteral) { - let tempArgumentExpression = createAndRecordTempVariable(TempFlags._i); + const tempArgumentExpression = createAndRecordTempVariable(TempFlags._i); (synthesizedLHS).argumentExpression = tempArgumentExpression; emitAssignment(tempArgumentExpression, leftHandSideExpression.argumentExpression, /*shouldEmitCommaBeforeAssignment*/ true); } @@ -2924,7 +2924,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi write("("); synthesizedLHS = createSynthesizedNode(SyntaxKind.PropertyAccessExpression, /*startsOnNewLine*/ false); - let identifier = emitTempVariableAssignment(leftHandSideExpression.expression, /*canDefinedTempVariablesInPlaces*/ false, /*shouldemitCommaBeforeAssignment*/ false); + const identifier = emitTempVariableAssignment(leftHandSideExpression.expression, /*canDefinedTempVariablesInPlaces*/ false, /*shouldemitCommaBeforeAssignment*/ false); synthesizedLHS.expression = identifier; (synthesizedLHS).dotToken = leftHandSideExpression.dotToken; @@ -2983,9 +2983,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi // emitted as // 3 // + 2; - let indentedBeforeOperator = indentIfOnDifferentLines(node, node.left, node.operatorToken, node.operatorToken.kind !== SyntaxKind.CommaToken ? " " : undefined); + const indentedBeforeOperator = indentIfOnDifferentLines(node, node.left, node.operatorToken, node.operatorToken.kind !== SyntaxKind.CommaToken ? " " : undefined); write(tokenToString(node.operatorToken.kind)); - let indentedAfterOperator = indentIfOnDifferentLines(node, node.operatorToken, node.right, " "); + const indentedAfterOperator = indentIfOnDifferentLines(node, node.operatorToken, node.right, " "); emit(node.right); decreaseIndentIf(indentedBeforeOperator, indentedAfterOperator); } @@ -3002,14 +3002,14 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi function emitConditionalExpression(node: ConditionalExpression) { emit(node.condition); - let indentedBeforeQuestion = indentIfOnDifferentLines(node, node.condition, node.questionToken, " "); + const indentedBeforeQuestion = indentIfOnDifferentLines(node, node.condition, node.questionToken, " "); write("?"); - let indentedAfterQuestion = indentIfOnDifferentLines(node, node.questionToken, node.whenTrue, " "); + const indentedAfterQuestion = indentIfOnDifferentLines(node, node.questionToken, node.whenTrue, " "); emit(node.whenTrue); decreaseIndentIf(indentedBeforeQuestion, indentedAfterQuestion); - let indentedBeforeColon = indentIfOnDifferentLines(node, node.whenTrue, node.colonToken, " "); + const indentedBeforeColon = indentIfOnDifferentLines(node, node.whenTrue, node.colonToken, " "); write(":"); - let indentedAfterColon = indentIfOnDifferentLines(node, node.colonToken, node.whenFalse, " "); + const indentedAfterColon = indentIfOnDifferentLines(node, node.colonToken, node.whenFalse, " "); emit(node.whenFalse); decreaseIndentIf(indentedBeforeColon, indentedAfterColon); } @@ -3029,7 +3029,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi function isSingleLineEmptyBlock(node: Node) { if (node && node.kind === SyntaxKind.Block) { - let block = node; + const block = node; return block.statements.length === 0 && nodeEndIsOnSameLineAsNodeStart(block, block); } } @@ -3190,7 +3190,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi function emitVariableDeclarationListSkippingUninitializedEntries(list: VariableDeclarationList): boolean { let started = false; - for (let decl of list.declarations) { + for (const decl of list.declarations) { if (!decl.initializer) { continue; } @@ -3468,8 +3468,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi return; } - for (let labelText in table) { - let labelMarker = table[labelText]; + for (const labelText in table) { + const labelMarker = table[labelText]; writeLine(); write(`case "${labelMarker}": `); // if there are no outer converted loop or outer label in question is located inside outer converted loop @@ -3501,8 +3501,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi write(" "); endPos = emitToken(SyntaxKind.OpenParenToken, endPos); if (node.initializer && node.initializer.kind === SyntaxKind.VariableDeclarationList) { - let variableDeclarationList = node.initializer; - let startIsEmitted = tryEmitStartOfVariableDeclarationList(variableDeclarationList, endPos); + const variableDeclarationList = node.initializer; + const startIsEmitted = tryEmitStartOfVariableDeclarationList(variableDeclarationList, endPos); if (startIsEmitted) { emitCommaList(variableDeclarationList.declarations); } @@ -3541,7 +3541,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi write(" "); endPos = emitToken(SyntaxKind.OpenParenToken, endPos); if (node.initializer.kind === SyntaxKind.VariableDeclarationList) { - let variableDeclarationList = node.initializer; + const variableDeclarationList = node.initializer; if (variableDeclarationList.declarations.length >= 1) { tryEmitStartOfVariableDeclarationList(variableDeclarationList, endPos); emit(variableDeclarationList.declarations[0]); @@ -3607,8 +3607,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi // for (let v of arr) { } // // we can't reuse 'arr' because it might be modified within the body of the loop. - let counter = createTempVariable(TempFlags._i); - let rhsReference = createSynthesizedNode(SyntaxKind.Identifier) as Identifier; + const counter = createTempVariable(TempFlags._i); + const rhsReference = createSynthesizedNode(SyntaxKind.Identifier) as Identifier; rhsReference.text = node.expression.kind === SyntaxKind.Identifier ? makeUniqueName((node.expression).text) : makeTempVariableName(TempFlags.Auto); @@ -3658,13 +3658,13 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi // Initialize LHS // let v = _a[_i]; - let rhsIterationValue = createElementAccessExpression(rhsReference, counter); + const rhsIterationValue = createElementAccessExpression(rhsReference, counter); emitStart(node.initializer); if (node.initializer.kind === SyntaxKind.VariableDeclarationList) { write("var "); - let variableDeclarationList = node.initializer; + const variableDeclarationList = node.initializer; if (variableDeclarationList.declarations.length > 0) { - let declaration = variableDeclarationList.declarations[0]; + const declaration = variableDeclarationList.declarations[0]; if (isBindingPattern(declaration.name)) { // This works whether the declaration is a var, let, or const. // It will use rhsIterationValue _a[_i] as the initializer. @@ -3689,7 +3689,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi else { // Initializer is an expression. Emit the expression in the body, so that it's // evaluated on every iteration. - let assignmentExpression = createBinaryExpression(node.initializer, SyntaxKind.EqualsToken, rhsIterationValue, /*startsOnNewLine*/ false); + const assignmentExpression = createBinaryExpression(node.initializer, SyntaxKind.EqualsToken, rhsIterationValue, /*startsOnNewLine*/ false); if (node.initializer.kind === SyntaxKind.ArrayLiteralExpression || node.initializer.kind === SyntaxKind.ObjectLiteralExpression) { // This is a destructuring pattern, so call emitDestructuring instead of emit. Calling emit will not work, because it will cause // the BinaryExpression to be passed in instead of the expression statement, which will cause emitDestructuring to crash. @@ -3869,7 +3869,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi function emitCatchClause(node: CatchClause) { writeLine(); - let endPos = emitToken(SyntaxKind.CatchKeyword, node.pos); + const endPos = emitToken(SyntaxKind.CatchKeyword, node.pos); write(" "); emitToken(SyntaxKind.OpenParenToken, endPos); emit(node.variableDeclaration); @@ -3915,14 +3915,14 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi } function emitContainingModuleName(node: Node) { - let container = getContainingModule(node); + const container = getContainingModule(node); write(container ? getGeneratedNameForNode(container) : "exports"); } function emitModuleMemberName(node: Declaration) { emitStart(node.name); if (getCombinedNodeFlags(node) & NodeFlags.Export) { - let container = getContainingModule(node); + const container = getContainingModule(node); if (container) { write(getGeneratedNameForNode(container)); write("."); @@ -3936,9 +3936,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi } function createVoidZero(): Expression { - let zero = createSynthesizedNode(SyntaxKind.NumericLiteral); + const zero = createSynthesizedNode(SyntaxKind.NumericLiteral); zero.text = "0"; - let result = createSynthesizedNode(SyntaxKind.VoidExpression); + const result = createSynthesizedNode(SyntaxKind.VoidExpression); result.expression = zero; return result; } @@ -4010,7 +4010,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi } if (!exportEquals && exportSpecifiers && hasProperty(exportSpecifiers, name.text)) { - for (let specifier of exportSpecifiers[name.text]) { + for (const specifier of exportSpecifiers[name.text]) { writeLine(); emitStart(specifier.name); emitContainingModuleName(specifier); @@ -4053,7 +4053,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi write(", "); } - let exportChanged = isNameOfExportedSourceLevelDeclarationInSystemExternalModule(name); + const exportChanged = isNameOfExportedSourceLevelDeclarationInSystemExternalModule(name); if (exportChanged) { write(`${exportFunctionForFile}("`); @@ -4086,7 +4086,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi * @param shouldEmitCommaBeforeAssignment a boolean indicating whether an assignment should prefix with comma */ function emitTempVariableAssignment(expression: Expression, canDefineTempVariablesInPlace: boolean, shouldEmitCommaBeforeAssignment: boolean): Identifier { - let identifier = createTempVariable(TempFlags.Auto); + const identifier = createTempVariable(TempFlags.Auto); if (!canDefineTempVariablesInPlace) { recordTempDeclaration(identifier); } @@ -4103,8 +4103,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi // because actual variable declarations are hoisted let canDefineTempVariablesInPlace = false; if (root.kind === SyntaxKind.VariableDeclaration) { - let isExported = getCombinedNodeFlags(root) & NodeFlags.Export; - let isSourceLevelForSystemModuleKind = shouldHoistDeclarationInSystemJsModule(root); + const isExported = getCombinedNodeFlags(root) & NodeFlags.Export; + const isSourceLevelForSystemModuleKind = shouldHoistDeclarationInSystemJsModule(root); canDefineTempVariablesInPlace = !isExported && !isSourceLevelForSystemModuleKind; } else if (root.kind === SyntaxKind.Parameter) { @@ -4134,7 +4134,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi return expr; } - let identifier = emitTempVariableAssignment(expr, canDefineTempVariablesInPlace, emitCount > 0); + const identifier = emitTempVariableAssignment(expr, canDefineTempVariablesInPlace, emitCount > 0); emitCount++; return identifier; } @@ -4144,7 +4144,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi // we need to generate a temporary variable value = ensureIdentifier(value, /*reuseIdentifierExpressions*/ true); // Return the expression 'value === void 0 ? defaultValue : value' - let equals = createSynthesizedNode(SyntaxKind.BinaryExpression); + const equals = createSynthesizedNode(SyntaxKind.BinaryExpression); equals.left = value; equals.operatorToken = createSynthesizedNode(SyntaxKind.EqualsEqualsEqualsToken); equals.right = createVoidZero(); @@ -4152,7 +4152,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi } function createConditionalExpression(condition: Expression, whenTrue: Expression, whenFalse: Expression) { - let cond = createSynthesizedNode(SyntaxKind.ConditionalExpression); + const cond = createSynthesizedNode(SyntaxKind.ConditionalExpression); cond.condition = condition; cond.questionToken = createSynthesizedNode(SyntaxKind.QuestionToken); cond.whenTrue = whenTrue; @@ -4162,7 +4162,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi } function createNumericLiteral(value: number) { - let node = createSynthesizedNode(SyntaxKind.NumericLiteral); + const node = createSynthesizedNode(SyntaxKind.NumericLiteral); node.text = "" + value; return node; } @@ -4170,7 +4170,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi function createPropertyAccessForDestructuringProperty(object: Expression, propName: Identifier | LiteralExpression): Expression { // We create a synthetic copy of the identifier in order to avoid the rewriting that might // otherwise occur when the identifier is emitted. - let syntheticName = createSynthesizedNode(propName.kind); + const syntheticName = createSynthesizedNode(propName.kind); syntheticName.text = propName.text; if (syntheticName.kind !== SyntaxKind.Identifier) { return createElementAccessExpression(object, syntheticName); @@ -4179,8 +4179,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi } function createSliceCall(value: Expression, sliceIndex: number): CallExpression { - let call = createSynthesizedNode(SyntaxKind.CallExpression); - let sliceIdentifier = createSynthesizedNode(SyntaxKind.Identifier); + const call = createSynthesizedNode(SyntaxKind.CallExpression); + const sliceIdentifier = createSynthesizedNode(SyntaxKind.Identifier); sliceIdentifier.text = "slice"; call.expression = createPropertyAccessExpression(value, sliceIdentifier); call.arguments = >createSynthesizedNodeArray(); @@ -4189,30 +4189,30 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi } function emitObjectLiteralAssignment(target: ObjectLiteralExpression, value: Expression) { - let properties = target.properties; + const properties = target.properties; if (properties.length !== 1) { // For anything but a single element destructuring we need to generate a temporary // to ensure value is evaluated exactly once. value = ensureIdentifier(value, /*reuseIdentifierExpressions*/ true); } - for (let p of properties) { + for (const p of properties) { if (p.kind === SyntaxKind.PropertyAssignment || p.kind === SyntaxKind.ShorthandPropertyAssignment) { - let propName = (p).name; - let target = p.kind === SyntaxKind.ShorthandPropertyAssignment ? p : (p).initializer || propName; + const propName = (p).name; + const target = p.kind === SyntaxKind.ShorthandPropertyAssignment ? p : (p).initializer || propName; emitDestructuringAssignment(target, createPropertyAccessForDestructuringProperty(value, propName)); } } } function emitArrayLiteralAssignment(target: ArrayLiteralExpression, value: Expression) { - let elements = target.elements; + const elements = target.elements; if (elements.length !== 1) { // For anything but a single element destructuring we need to generate a temporary // to ensure value is evaluated exactly once. value = ensureIdentifier(value, /*reuseIdentifierExpressions*/ true); } for (let i = 0; i < elements.length; i++) { - let e = elements[i]; + const e = elements[i]; if (e.kind !== SyntaxKind.OmittedExpression) { if (e.kind !== SyntaxKind.SpreadElementExpression) { emitDestructuringAssignment(e, createElementAccessExpression(value, createNumericLiteral(i))); @@ -4248,7 +4248,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi } function emitAssignmentExpression(root: BinaryExpression) { - let target = root.left; + const target = root.left; let value = root.right; if (isEmptyObjectLiteralOrArrayLiteral(target)) { @@ -4294,10 +4294,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi } for (let i = 0; i < numElements; i++) { - let element = elements[i]; + const element = elements[i]; if (pattern.kind === SyntaxKind.ObjectBindingPattern) { // Rewrite element to a declaration with an initializer that fetches property - let propName = element.propertyName || element.name; + const propName = element.propertyName || element.name; emitBindingElement(element, createPropertyAccessForDestructuringProperty(value, propName)); } else if (element.kind !== SyntaxKind.OmittedExpression) { @@ -4338,7 +4338,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi // for (...) { var = void 0; } // this is necessary to preserve ES6 semantic in scenarios like // for (...) { let x; console.log(x); x = 1 } // assignment on one iteration should not affect other iterations - let isLetDefinedInLoop = + const isLetDefinedInLoop = (resolver.getNodeCheckFlags(node) & NodeCheckFlags.BlockScopedBindingInLoop) && (getCombinedFlagsForIdentifier(node.name) & NodeFlags.Let); @@ -4350,7 +4350,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi } } - let exportChanged = isNameOfExportedSourceLevelDeclarationInSystemExternalModule(node.name); + const exportChanged = isNameOfExportedSourceLevelDeclarationInSystemExternalModule(node.name); if (exportChanged) { write(`${exportFunctionForFile}("`); @@ -4371,7 +4371,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi if (node.kind === SyntaxKind.OmittedExpression) { return; } - let name = node.name; + const name = node.name; if (name.kind === SyntaxKind.Identifier) { emitExportMemberAssignments(name); } @@ -4413,7 +4413,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi write(";"); } else { - let atLeastOneItem = emitVariableDeclarationListSkippingUninitializedEntries(node.declarationList); + const atLeastOneItem = emitVariableDeclarationListSkippingUninitializedEntries(node.declarationList); if (atLeastOneItem) { write(";"); } @@ -4437,7 +4437,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi } // Otherwise, only emit if we have at least one initializer present. - for (let declaration of node.declarationList.declarations) { + for (const declaration of node.declarationList.declarations) { if (declaration.initializer) { return true; } @@ -4448,7 +4448,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi function emitParameter(node: ParameterDeclaration) { if (languageVersion < ScriptTarget.ES6) { if (isBindingPattern(node.name)) { - let name = createTempVariable(TempFlags.Auto); + const name = createTempVariable(TempFlags.Auto); if (!tempParameters) { tempParameters = []; } @@ -4478,12 +4478,12 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi return; } - let { name: paramName, initializer } = parameter; + const { name: paramName, initializer } = parameter; if (isBindingPattern(paramName)) { // 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. - let hasBindingElements = paramName.elements.length > 0; + const hasBindingElements = paramName.elements.length > 0; if (hasBindingElements || initializer) { writeLine(); write("var "); @@ -4522,15 +4522,15 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi function emitRestParameter(node: FunctionLikeDeclaration) { if (languageVersion < ScriptTarget.ES6 && hasRestParameter(node)) { - let restIndex = node.parameters.length - 1; - let restParam = node.parameters[restIndex]; + const restIndex = node.parameters.length - 1; + const restParam = node.parameters[restIndex]; // A rest parameter cannot have a binding pattern, so let's just ignore it if it does. if (isBindingPattern(restParam.name)) { return; } - let tempName = createTempVariable(TempFlags._i).text; + const tempName = createTempVariable(TempFlags._i).text; writeLine(); emitLeadingComments(restParam); emitStart(restParam); @@ -4667,8 +4667,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi increaseIndent(); write("("); if (node) { - let parameters = node.parameters; - let omitCount = languageVersion < ScriptTarget.ES6 && hasRestParameter(node) ? 1 : 0; + const parameters = node.parameters; + const omitCount = languageVersion < ScriptTarget.ES6 && hasRestParameter(node) ? 1 : 0; emitList(parameters, 0, parameters.length - omitCount, /*multiLine*/ false, /*trailingComma*/ false); } write(")"); @@ -4686,10 +4686,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi } function emitAsyncFunctionBodyForES6(node: FunctionLikeDeclaration) { - let promiseConstructor = getEntityNameFromTypeNode(node.type); - let isArrowFunction = node.kind === SyntaxKind.ArrowFunction; - let hasLexicalArguments = (resolver.getNodeCheckFlags(node) & NodeCheckFlags.CaptureArguments) !== 0; - let args: string; + const promiseConstructor = getEntityNameFromTypeNode(node.type); + 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 @@ -4827,9 +4826,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi function emitSignatureAndBody(node: FunctionLikeDeclaration) { const saveConvertedLoopState = convertedLoopState; - let saveTempFlags = tempFlags; - let saveTempVariables = tempVariables; - let saveTempParameters = tempParameters; + const saveTempFlags = tempFlags; + const saveTempVariables = tempVariables; + const saveTempParameters = tempParameters; convertedLoopState = undefined; tempFlags = 0; @@ -4845,7 +4844,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi emitSignatureParameters(node); } - let isAsync = isAsyncFunctionLike(node); + const isAsync = isAsyncFunctionLike(node); if (isAsync && languageVersion === ScriptTarget.ES6) { emitAsyncFunctionBodyForES6(node); } @@ -4898,10 +4897,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi scopeEmitStart(node); increaseIndent(); - let outPos = writer.getTextPos(); + const outPos = writer.getTextPos(); emitDetachedCommentsAndUpdateCommentsInfo(node.body); emitFunctionBodyPreamble(node); - let preambleEmitted = writer.getTextPos() !== outPos; + const preambleEmitted = writer.getTextPos() !== outPos; decreaseIndent(); // If we didn't have to emit any preamble code, then attempt to keep the arrow @@ -4941,21 +4940,21 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi write(" {"); scopeEmitStart(node); - let initialTextPos = writer.getTextPos(); + const initialTextPos = writer.getTextPos(); increaseIndent(); emitDetachedCommentsAndUpdateCommentsInfo(body.statements); // Emit all the directive prologues (like "use strict"). These have to come before // any other preamble code we write (like parameter initializers). - let startIndex = emitDirectivePrologues(body.statements, /*startWithNewLine*/ true); + const startIndex = emitDirectivePrologues(body.statements, /*startWithNewLine*/ true); emitFunctionBodyPreamble(node); decreaseIndent(); - let preambleEmitted = writer.getTextPos() !== initialTextPos; + const preambleEmitted = writer.getTextPos() !== initialTextPos; if (!preambleEmitted && nodeEndIsOnSameLineAsNodeStart(body, body)) { - for (let statement of body.statements) { + for (const statement of body.statements) { write(" "); emit(statement); } @@ -4979,11 +4978,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi function findInitialSuperCall(ctor: ConstructorDeclaration): ExpressionStatement { if (ctor.body) { - let statement = (ctor.body).statements[0]; + const statement = (ctor.body).statements[0]; if (statement && statement.kind === SyntaxKind.ExpressionStatement) { - let expr = (statement).expression; + const expr = (statement).expression; if (expr && expr.kind === SyntaxKind.CallExpression) { - let func = (expr).expression; + const func = (expr).expression; if (func && func.kind === SyntaxKind.SuperKeyword) { return statement; } @@ -5028,8 +5027,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi } function getInitializedProperties(node: ClassLikeDeclaration, isStatic: boolean) { - let properties: PropertyDeclaration[] = []; - for (let member of node.members) { + const properties: PropertyDeclaration[] = []; + for (const member of node.members) { if (member.kind === SyntaxKind.PropertyDeclaration && isStatic === ((member.flags & NodeFlags.Static) !== 0) && (member).initializer) { properties.push(member); } @@ -5039,7 +5038,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi } function emitPropertyDeclarations(node: ClassLikeDeclaration, properties: PropertyDeclaration[]) { - for (let property of properties) { + for (const property of properties) { emitPropertyDeclaration(node, property); } } @@ -5097,7 +5096,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi emitTrailingComments(member); } else if (member.kind === SyntaxKind.GetAccessor || member.kind === SyntaxKind.SetAccessor) { - let accessors = getAllAccessorDeclarations(node.members, member); + const accessors = getAllAccessorDeclarations(node.members, member); if (member === accessors.firstAccessor) { writeLine(); emitStart(member); @@ -5145,7 +5144,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi } function emitMemberFunctionsForES6AndHigher(node: ClassLikeDeclaration) { - for (let member of node.members) { + for (const member of node.members) { if ((member.kind === SyntaxKind.MethodDeclaration || node.kind === SyntaxKind.MethodSignature) && !(member).body) { emitCommentsOnNotEmittedNode(member); } @@ -5182,9 +5181,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi function emitConstructor(node: ClassLikeDeclaration, baseTypeElement: ExpressionWithTypeArguments) { const saveConvertedLoopState = convertedLoopState; - let saveTempFlags = tempFlags; - let saveTempVariables = tempVariables; - let saveTempParameters = tempParameters; + const saveTempFlags = tempFlags; + const saveTempVariables = tempVariables; + const saveTempParameters = tempParameters; convertedLoopState = undefined; tempFlags = 0; @@ -5218,7 +5217,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi } }); - let ctor = getFirstConstructorWithBody(node); + const ctor = getFirstConstructorWithBody(node); // For target ES6 and above, if there is no user-defined constructor and there is no property assignment // do not emit constructor in class declaration. @@ -5338,7 +5337,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi } function emitClassLikeDeclarationForES6AndHigher(node: ClassLikeDeclaration) { - let thisNodeIsDecorated = nodeIsDecorated(node); + const thisNodeIsDecorated = nodeIsDecorated(node); if (node.kind === SyntaxKind.ClassDeclaration) { if (thisNodeIsDecorated) { // To preserve the correct runtime semantics when decorators are applied to the class, @@ -5417,8 +5416,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi // // This keeps the expression as an expression, while ensuring that the static parts // of it have been initialized by the time it is used. - let staticProperties = getInitializedProperties(node, /*static:*/ true); - let isClassExpressionWithStaticProperties = staticProperties.length > 0 && node.kind === SyntaxKind.ClassExpression; + const staticProperties = getInitializedProperties(node, /*static:*/ true); + const isClassExpressionWithStaticProperties = staticProperties.length > 0 && node.kind === SyntaxKind.ClassExpression; let tempVariable: Identifier; if (isClassExpressionWithStaticProperties) { @@ -5439,7 +5438,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi emitDeclarationName(node); } - let baseTypeNode = getClassExtendsHeritageClauseElement(node); + const baseTypeNode = getClassExtendsHeritageClauseElement(node); if (baseTypeNode) { write(" extends "); emit(baseTypeNode.expression); @@ -5524,16 +5523,16 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi } write("(function ("); - let baseTypeNode = getClassExtendsHeritageClauseElement(node); + const baseTypeNode = getClassExtendsHeritageClauseElement(node); if (baseTypeNode) { write("_super"); } write(") {"); - let saveTempFlags = tempFlags; - let saveTempVariables = tempVariables; - let saveTempParameters = tempParameters; - let saveComputedPropertyNamesToGeneratedNames = computedPropertyNamesToGeneratedNames; - let saveConvertedLoopState = convertedLoopState; + const saveTempFlags = tempFlags; + const saveTempVariables = tempVariables; + const saveTempParameters = tempParameters; + const saveComputedPropertyNamesToGeneratedNames = computedPropertyNamesToGeneratedNames; + const saveConvertedLoopState = convertedLoopState; convertedLoopState = undefined; tempFlags = 0; @@ -5605,9 +5604,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi } function emitDecoratorsOfConstructor(node: ClassLikeDeclaration) { - let decorators = node.decorators; - let constructor = getFirstConstructorWithBody(node); - let hasDecoratedParameters = constructor && forEach(constructor.parameters, nodeIsDecorated); + const decorators = node.decorators; + const constructor = getFirstConstructorWithBody(node); + const hasDecoratedParameters = constructor && forEach(constructor.parameters, nodeIsDecorated); // skip decoration of the constructor if neither it nor its parameters are decorated if (!decorators && !hasDecoratedParameters) { @@ -5632,7 +5631,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi increaseIndent(); writeLine(); - let decoratorCount = decorators ? decorators.length : 0; + const decoratorCount = decorators ? decorators.length : 0; let argumentsWritten = emitList(decorators, 0, decoratorCount, /*multiLine*/ true, /*trailingComma*/ false, /*leadingComma*/ false, /*noTrailingNewLine*/ true, decorator => { emitStart(decorator); emit(decorator.expression); @@ -5652,7 +5651,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi } function emitDecoratorsOfMembers(node: ClassLikeDeclaration, staticFlag: NodeFlags) { - for (let member of node.members) { + for (const member of node.members) { // only emit members in the correct group if ((member.flags & NodeFlags.Static) !== staticFlag) { continue; @@ -5672,7 +5671,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi let decorators: NodeArray; let functionLikeMember: FunctionLikeDeclaration; if (isAccessor(member)) { - let accessors = getAllAccessorDeclarations(node.members, member); + const accessors = getAllAccessorDeclarations(node.members, member); if (member !== accessors.firstAccessor) { continue; } @@ -5732,7 +5731,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi increaseIndent(); writeLine(); - let decoratorCount = decorators ? decorators.length : 0; + const decoratorCount = decorators ? decorators.length : 0; let argumentsWritten = emitList(decorators, 0, decoratorCount, /*multiLine*/ true, /*trailingComma*/ false, /*leadingComma*/ false, /*noTrailingNewLine*/ true, decorator => { emitStart(decorator); emit(decorator.expression); @@ -5774,9 +5773,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi let argumentsWritten = 0; if (node) { let parameterIndex = 0; - for (let parameter of node.parameters) { + for (const parameter of node.parameters) { if (nodeIsDecorated(parameter)) { - let decorators = parameter.decorators; + const decorators = parameter.decorators; argumentsWritten += emitList(decorators, 0, decorators.length, /*multiLine*/ true, /*trailingComma*/ false, /*leadingComma*/ leadingComma, /*noTrailingNewLine*/ true, decorator => { emitStart(decorator); write(`__param(${parameterIndex}, `); @@ -5941,10 +5940,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi } // Clone the type name and parent it to a location outside of the current declaration. - let typeName = cloneEntityName(node.typeName); + const typeName = cloneEntityName(node.typeName); typeName.parent = location; - let result = resolver.getTypeReferenceSerializationKind(typeName); + const result = resolver.getTypeReferenceSerializationKind(typeName); switch (result) { case TypeReferenceSerializationKind.Unknown: let temp = createAndRecordTempVariable(TempFlags.Auto); @@ -6106,7 +6105,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi } function shouldEmitEnumDeclaration(node: EnumDeclaration) { - let isConstEnum = isConst(node); + const isConstEnum = isConst(node); return !isConstEnum || compilerOptions.preserveConstEnums || compilerOptions.isolatedModules; } @@ -6175,7 +6174,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi } function emitEnumMember(node: EnumMember) { - let enumParent = node.parent; + const enumParent = node.parent; emitStart(node); write(getGeneratedNameForNode(enumParent)); write("["); @@ -6191,7 +6190,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi } function writeEnumMemberDeclarationValue(member: EnumMember) { - let value = resolver.getConstantValue(member); + const value = resolver.getConstantValue(member); if (value !== undefined) { write(value.toString()); return; @@ -6206,7 +6205,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi function getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration: ModuleDeclaration): ModuleDeclaration { if (moduleDeclaration.body.kind === SyntaxKind.ModuleDeclaration) { - let recursiveInnerModule = getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration.body); + const recursiveInnerModule = getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration.body); return recursiveInnerModule || moduleDeclaration.body; } } @@ -6221,13 +6220,13 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi function emitModuleDeclaration(node: ModuleDeclaration) { // Emit only if this module is non-ambient. - let shouldEmit = shouldEmitModuleDeclaration(node); + const shouldEmit = shouldEmitModuleDeclaration(node); if (!shouldEmit) { return emitCommentsOnNotEmittedNode(node); } - let hoistedInDeclarationScope = shouldHoistDeclarationInSystemJsModule(node); - let emitVarForModule = !hoistedInDeclarationScope && !isModuleMergedWithES6Class(node); + const hoistedInDeclarationScope = shouldHoistDeclarationInSystemJsModule(node); + const emitVarForModule = !hoistedInDeclarationScope && !isModuleMergedWithES6Class(node); if (emitVarForModule) { emitStart(node); @@ -6249,8 +6248,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi write(") "); if (node.body.kind === SyntaxKind.ModuleBlock) { const saveConvertedLoopState = convertedLoopState; - let saveTempFlags = tempFlags; - let saveTempVariables = tempVariables; + const saveTempFlags = tempFlags; + const saveTempVariables = tempVariables; convertedLoopState = undefined; tempFlags = 0; tempVariables = undefined; @@ -6272,7 +6271,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi emit(node.body); decreaseIndent(); writeLine(); - let moduleBlock = getInnerMostModuleDeclarationFromDottedModule(node).body; + const moduleBlock = getInnerMostModuleDeclarationFromDottedModule(node).body; emitToken(SyntaxKind.CloseBraceToken, moduleBlock.statements.end); scopeEmitEnd(); } @@ -6314,7 +6313,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi function emitRequire(moduleName: Expression) { if (moduleName.kind === SyntaxKind.StringLiteral) { write("require("); - let text = tryRenameExternalModule(moduleName); + const text = tryRenameExternalModule(moduleName); if (text) { write(text); } @@ -6334,7 +6333,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi if (node.kind === SyntaxKind.ImportEqualsDeclaration) { return node; } - let importClause = (node).importClause; + const importClause = (node).importClause; if (importClause && importClause.namedBindings && importClause.namedBindings.kind === SyntaxKind.NamespaceImport) { return importClause.namedBindings; } @@ -6358,8 +6357,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi // ES6 import if (node.importClause) { - let shouldEmitDefaultBindings = resolver.isReferencedAliasDeclaration(node.importClause); - let shouldEmitNamedBindings = node.importClause.namedBindings && resolver.isReferencedAliasDeclaration(node.importClause.namedBindings, /* checkChildren */ true); + const shouldEmitDefaultBindings = resolver.isReferencedAliasDeclaration(node.importClause); + const shouldEmitNamedBindings = node.importClause.namedBindings && resolver.isReferencedAliasDeclaration(node.importClause.namedBindings, /* checkChildren */ true); if (shouldEmitDefaultBindings || shouldEmitNamedBindings) { write("import "); emitStart(node.importClause); @@ -6400,8 +6399,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi function emitExternalImportDeclaration(node: ImportDeclaration | ImportEqualsDeclaration) { if (contains(externalImports, node)) { - let isExportedImport = node.kind === SyntaxKind.ImportEqualsDeclaration && (node.flags & NodeFlags.Export) !== 0; - let namespaceDeclaration = getNamespaceDeclarationNode(node); + const isExportedImport = node.kind === SyntaxKind.ImportEqualsDeclaration && (node.flags & NodeFlags.Export) !== 0; + const namespaceDeclaration = getNamespaceDeclarationNode(node); if (modulekind !== ModuleKind.AMD) { emitLeadingComments(node); @@ -6419,7 +6418,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi // import { x, y } from "foo" // import d, * as x from "foo" // import d, { x, y } from "foo" - let isNakedImport = SyntaxKind.ImportDeclaration && !(node).importClause; + const isNakedImport = SyntaxKind.ImportDeclaration && !(node).importClause; if (!isNakedImport) { write("var "); write(getGeneratedNameForNode(node)); @@ -6474,11 +6473,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi // variable declaration for import-equals declaration can be hoisted in system modules // in this case 'var' should be omitted and emit should contain only initialization - let variableDeclarationIsHoisted = shouldHoistVariable(node, /*checkIfSourceFileLevelDecl*/ true); + const variableDeclarationIsHoisted = shouldHoistVariable(node, /*checkIfSourceFileLevelDecl*/ true); // is it top level export import v = a.b.c in system module? // if yes - it needs to be rewritten as exporter('v', v = a.b.c) - let isExported = isSourceFileLevelDeclarationInSystemJsModule(node, /*isExported*/ true); + const isExported = isSourceFileLevelDeclarationInSystemJsModule(node, /*isExported*/ true); if (!variableDeclarationIsHoisted) { Debug.assert(!isExported); @@ -6520,7 +6519,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi if (modulekind !== ModuleKind.ES6) { if (node.moduleSpecifier && (!node.exportClause || resolver.isValueAliasDeclaration(node))) { emitStart(node); - let generatedName = getGeneratedNameForNode(node); + const generatedName = getGeneratedNameForNode(node); if (node.exportClause) { // export { x, y, ... } from "foo" if (modulekind !== ModuleKind.AMD) { @@ -6530,7 +6529,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi emitRequire(getExternalModuleName(node)); write(";"); } - for (let specifier of node.exportClause.elements) { + for (const specifier of node.exportClause.elements) { if (resolver.isValueAliasDeclaration(specifier)) { writeLine(); emitStart(specifier); @@ -6586,7 +6585,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi Debug.assert(modulekind === ModuleKind.ES6); let needsComma = false; - for (let specifier of specifiers) { + for (const specifier of specifiers) { if (shouldEmit(specifier)) { if (needsComma) { write(", "); @@ -6607,7 +6606,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi writeLine(); emitStart(node); write("export default "); - let expression = node.expression; + const expression = node.expression; emit(expression); if (expression.kind !== SyntaxKind.FunctionDeclaration && expression.kind !== SyntaxKind.ClassDeclaration) { @@ -6645,7 +6644,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi exportSpecifiers = {}; exportEquals = undefined; hasExportStars = false; - for (let node of sourceFile.statements) { + for (const node of sourceFile.statements) { switch (node.kind) { case SyntaxKind.ImportDeclaration: if (!(node).importClause || @@ -6677,8 +6676,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi } else { // export { x, y } - for (let specifier of (node).exportClause.elements) { - let name = (specifier.propertyName || specifier.name).text; + for (const specifier of (node).exportClause.elements) { + const name = (specifier.propertyName || specifier.name).text; (exportSpecifiers[name] || (exportSpecifiers[name] = [])).push(specifier); } } @@ -6707,7 +6706,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi } function getLocalNameForExternalImport(node: ImportDeclaration | ExportDeclaration | ImportEqualsDeclaration): string { - let namespaceDeclaration = getNamespaceDeclarationNode(node); + const namespaceDeclaration = getNamespaceDeclarationNode(node); if (namespaceDeclaration && !isDefaultImport(node)) { return getSourceTextOfNodeFromSourceFile(currentSourceFile, namespaceDeclaration.name); } @@ -6720,7 +6719,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi } function getExternalModuleNameText(importNode: ImportDeclaration | ExportDeclaration | ImportEqualsDeclaration): string { - let moduleName = getExternalModuleName(importNode); + const moduleName = getExternalModuleName(importNode); if (moduleName.kind === SyntaxKind.StringLiteral) { return tryRenameExternalModule(moduleName) || getLiteralText(moduleName); } @@ -6735,9 +6734,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi writeLine(); let started = false; - for (let importNode of externalImports) { + for (const importNode of externalImports) { // do not create variable declaration for exports and imports that lack import clause - let skipNode = + const skipNode = importNode.kind === SyntaxKind.ExportDeclaration || (importNode.kind === SyntaxKind.ImportDeclaration && !(importNode).importClause); @@ -6776,7 +6775,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi // no exported declarations (export var ...) or export specifiers (export {x}) // check if we have any non star export declarations. let hasExportDeclarationWithExportClause = false; - for (let externalImport of externalImports) { + for (const externalImport of externalImports) { if (externalImport.kind === SyntaxKind.ExportDeclaration && (externalImport).exportClause) { hasExportDeclarationWithExportClause = true; break; @@ -6804,26 +6803,26 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi } if (exportSpecifiers) { - for (let n in exportSpecifiers) { - for (let specifier of exportSpecifiers[n]) { + for (const n in exportSpecifiers) { + for (const specifier of exportSpecifiers[n]) { // write name of export specified, i.e. 'export {x}' writeExportedName(specifier.name); } } } - for (let externalImport of externalImports) { + for (const externalImport of externalImports) { if (externalImport.kind !== SyntaxKind.ExportDeclaration) { continue; } - let exportDecl = externalImport; + const exportDecl = externalImport; if (!exportDecl.exportClause) { // export * from ... continue; } - for (let element of exportDecl.exportClause.elements) { + for (const element of exportDecl.exportClause.elements) { // write name of indirectly exported entry, i.e. 'export {x} from ...' writeExportedName(element.name || element.propertyName); } @@ -6912,16 +6911,16 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi if (hoistedVars) { writeLine(); write("var "); - let seen: Map = {}; + const seen: Map = {}; for (let i = 0; i < hoistedVars.length; ++i) { - let local = hoistedVars[i]; - let name = local.kind === SyntaxKind.Identifier + const local = hoistedVars[i]; + const name = local.kind === SyntaxKind.Identifier ? local : (local).name; if (name) { // do not emit duplicate entries (in case of declaration merging) in the list of hoisted variables - let text = unescapeIdentifier(name.text); + const text = unescapeIdentifier(name.text); if (hasProperty(seen, text)) { continue; } @@ -6941,7 +6940,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi emit(local); } - let flags = getCombinedNodeFlags(local.kind === SyntaxKind.Identifier ? local.parent : local); + const flags = getCombinedNodeFlags(local.kind === SyntaxKind.Identifier ? local.parent : local); if (flags & NodeFlags.Export) { if (!exportedDeclarations) { exportedDeclarations = []; @@ -6953,7 +6952,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi } if (hoistedFunctionDeclarations) { - for (let f of hoistedFunctionDeclarations) { + for (const f of hoistedFunctionDeclarations) { writeLine(); emit(f); @@ -7016,7 +7015,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi if (node.kind === SyntaxKind.VariableDeclaration || node.kind === SyntaxKind.BindingElement) { if (shouldHoistVariable(node, /*checkIfSourceFileLevelDecl*/ false)) { - let name = (node).name; + const name = (node).name; if (name.kind === SyntaxKind.Identifier) { if (!hoistedVars) { hoistedVars = []; @@ -7107,8 +7106,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi // } emitVariableDeclarationsForImports(); writeLine(); - let exportedDeclarations = processTopLevelVariableAndFunctionDeclarations(node); - let exportStarFunction = emitLocalStorageForExportedNamesIfNecessary(exportedDeclarations); + const exportedDeclarations = processTopLevelVariableAndFunctionDeclarations(node); + const exportStarFunction = emitLocalStorageForExportedNamesIfNecessary(exportedDeclarations); writeLine(); write("return {"); increaseIndent(); @@ -7133,15 +7132,15 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi writeLine(); increaseIndent(); - let group = dependencyGroups[i]; + const group = dependencyGroups[i]; // derive a unique name for parameter from the first named entry in the group - let parameterName = makeUniqueName(forEach(group, getLocalNameForExternalImport) || ""); + const parameterName = makeUniqueName(forEach(group, getLocalNameForExternalImport) || ""); write(`function (${parameterName}) {`); increaseIndent(); - for (let entry of group) { - let importVariableName = getLocalNameForExternalImport(entry) || ""; + for (const entry of group) { + const importVariableName = getLocalNameForExternalImport(entry) || ""; switch (entry.kind) { case SyntaxKind.ImportDeclaration: @@ -7179,7 +7178,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi writeLine(); } - let e = (entry).exportClause.elements[i]; + const e = (entry).exportClause.elements[i]; write(`"`); emitNodeWithCommentsAndWithoutSourcemap(e.name); write(`": ${parameterName}["`); @@ -7217,7 +7216,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi increaseIndent(); writeLine(); for (let i = startIndex; i < node.statements.length; ++i) { - let statement = node.statements[i]; + const statement = node.statements[i]; switch (statement.kind) { // - function declarations are not emitted because they were already hoisted // - import declarations are not emitted since they are already handled in setters @@ -7228,7 +7227,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi continue; case SyntaxKind.ExportDeclaration: if (!(statement).moduleSpecifier) { - for (let element of (statement).exportClause.elements) { + for (const element of (statement).exportClause.elements) { // write call to exporter function for every export specifier in exports list emitExportSpecifierInSystemModule(element); } @@ -7270,14 +7269,14 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi } write("["); - let groupIndices: Map = {}; - let dependencyGroups: DependencyGroup[] = []; + const groupIndices: Map = {}; + const dependencyGroups: DependencyGroup[] = []; for (let i = 0; i < externalImports.length; ++i) { - let text = getExternalModuleNameText(externalImports[i]); + const text = getExternalModuleNameText(externalImports[i]); if (hasProperty(groupIndices, text)) { // deduplicate/group entries in dependency list by the dependency name - let groupIndex = groupIndices[text]; + const groupIndex = groupIndices[text]; dependencyGroups[groupIndex].push(externalImports[i]); continue; } @@ -7295,7 +7294,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi write(`], function(${exportFunctionForFile}) {`); writeLine(); increaseIndent(); - let startIndex = emitDirectivePrologues(node.statements, /*startWithNewLine*/ true); + const startIndex = emitDirectivePrologues(node.statements, /*startWithNewLine*/ true); emitEmitHelpers(node); emitCaptureThisForNodeIfNecessary(node); emitSystemModuleBody(node, dependencyGroups, startIndex); @@ -7312,15 +7311,15 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi function getAMDDependencyNames(node: SourceFile, includeNonAmdDependencies: boolean): AMDDependencyNames { // names of modules with corresponding parameter in the factory function - let aliasedModuleNames: string[] = []; + const aliasedModuleNames: string[] = []; // names of modules with no corresponding parameters in factory function - let unaliasedModuleNames: string[] = []; - let importAliasNames: string[] = []; // names of the parameters in the factory function; these + const unaliasedModuleNames: string[] = []; + const importAliasNames: string[] = []; // names of the parameters in the factory function; these // parameters need to match the indexes of the corresponding // module names in aliasedModuleNames. // Fill in amd-dependency tags - for (let amdDependency of node.amdDependencies) { + for (const amdDependency of node.amdDependencies) { if (amdDependency.name) { aliasedModuleNames.push("\"" + amdDependency.path + "\""); importAliasNames.push(amdDependency.name); @@ -7330,12 +7329,12 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi } } - for (let importNode of externalImports) { + for (const importNode of externalImports) { // Find the name of the external module - let externalModuleName = getExternalModuleNameText(importNode); + const externalModuleName = getExternalModuleNameText(importNode); // Find the name of the module alias, if there is one - let importAliasName = getLocalNameForExternalImport(importNode); + const importAliasName = getLocalNameForExternalImport(importNode); if (includeNonAmdDependencies && importAliasName) { aliasedModuleNames.push(externalModuleName); importAliasNames.push(importAliasName); @@ -7361,7 +7360,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi // `import "module"` or `` // we need to add modules without alias names to the end of the dependencies list - let dependencyNames = getAMDDependencyNames(node, includeNonAmdDependencies); + const dependencyNames = getAMDDependencyNames(node, includeNonAmdDependencies); emitAMDDependencyList(dependencyNames); write(", "); emitAMDFactoryHeader(dependencyNames); @@ -7400,7 +7399,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi } emitAMDDependencies(node, /*includeNonAmdDependencies*/ true); increaseIndent(); - let startIndex = emitDirectivePrologues(node.statements, /*startWithNewLine*/ true); + const startIndex = emitDirectivePrologues(node.statements, /*startWithNewLine*/ true); emitExportStarHelper(); emitCaptureThisForNodeIfNecessary(node); emitLinesStartingAt(node.statements, startIndex); @@ -7412,7 +7411,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi } function emitCommonJSModule(node: SourceFile) { - let startIndex = emitDirectivePrologues(node.statements, /*startWithNewLine*/ false); + const startIndex = emitDirectivePrologues(node.statements, /*startWithNewLine*/ false); emitEmitHelpers(node); collectExternalModuleInfo(node); emitExportStarHelper(); @@ -7426,7 +7425,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi emitEmitHelpers(node); collectExternalModuleInfo(node); - let dependencyNames = getAMDDependencyNames(node, /*includeNonAmdDependencies*/ false); + const dependencyNames = getAMDDependencyNames(node, /*includeNonAmdDependencies*/ false); // Module is detected first to support Browserify users that load into a browser with an AMD loader writeLines(`(function (factory) { @@ -7441,7 +7440,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi })(`); emitAMDFactoryHeader(dependencyNames); increaseIndent(); - let startIndex = emitDirectivePrologues(node.statements, /*startWithNewLine*/ true); + const startIndex = emitDirectivePrologues(node.statements, /*startWithNewLine*/ true); emitExportStarHelper(); emitCaptureThisForNodeIfNecessary(node); emitLinesStartingAt(node.statements, startIndex); @@ -7457,7 +7456,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi exportSpecifiers = undefined; exportEquals = undefined; hasExportStars = false; - let startIndex = emitDirectivePrologues(node.statements, /*startWithNewLine*/ false); + const startIndex = emitDirectivePrologues(node.statements, /*startWithNewLine*/ false); emitEmitHelpers(node); emitCaptureThisForNodeIfNecessary(node); emitLinesStartingAt(node.statements, startIndex); @@ -7492,7 +7491,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi function trimReactWhitespaceAndApplyEntities(node: JsxText): string { let result: string = undefined; - let text = getTextOfNode(node, /*includeTrivia*/ true); + const text = getTextOfNode(node, /*includeTrivia*/ true); let firstNonWhitespace = 0; let lastNonWhitespace = -1; @@ -7500,10 +7499,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi // start/end of a tag is considered a start/end of a line only if that line is // on the same line as the closing tag. See examples in tests/cases/conformance/jsx/tsxReactEmitWhitespace.tsx for (let i = 0; i < text.length; i++) { - let c = text.charCodeAt(i); + const c = text.charCodeAt(i); if (isLineBreak(c)) { if (firstNonWhitespace !== -1 && (lastNonWhitespace - firstNonWhitespace + 1 > 0)) { - let part = text.substr(firstNonWhitespace, lastNonWhitespace - firstNonWhitespace + 1); + const part = text.substr(firstNonWhitespace, lastNonWhitespace - firstNonWhitespace + 1); result = (result ? result + "\" + ' ' + \"" : "") + escapeString(part); } firstNonWhitespace = -1; @@ -7517,7 +7516,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi } if (firstNonWhitespace !== -1) { - let part = text.substr(firstNonWhitespace); + const part = text.substr(firstNonWhitespace); result = (result ? result + "\" + ' ' + \"" : "") + escapeString(part); } @@ -7600,9 +7599,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi } function writeLines(text: string): void { - let lines = text.split(/\r\n|\r|\n/g); + const lines = text.split(/\r\n|\r|\n/g); for (let i = 0; i < lines.length; ++i) { - let line = lines[i]; + const line = lines[i]; if (line.length) { writeLine(); write(line); @@ -7647,12 +7646,12 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi emitDetachedCommentsAndUpdateCommentsInfo(node); if (isExternalModule(node) || compilerOptions.isolatedModules) { - let emitModule = moduleEmitDelegates[modulekind] || moduleEmitDelegates[ModuleKind.CommonJS]; + const emitModule = moduleEmitDelegates[modulekind] || moduleEmitDelegates[ModuleKind.CommonJS]; emitModule(node); } else { // emit prologue directives prior to __extends - let startIndex = emitDirectivePrologues(node.statements, /*startWithNewLine*/ false); + const startIndex = emitDirectivePrologues(node.statements, /*startWithNewLine*/ false); externalImports = undefined; exportSpecifiers = undefined; exportEquals = undefined; @@ -7681,7 +7680,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi return emitNodeWithoutSourceMap(node); } - let emitComments = shouldEmitLeadingAndTrailingComments(node); + const emitComments = shouldEmitLeadingAndTrailingComments(node); if (emitComments) { emitLeadingComments(node); } @@ -7928,7 +7927,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi function getLeadingCommentsWithoutDetachedComments() { // get the leading comments from detachedPos - let leadingComments = getLeadingCommentRanges(currentSourceFile.text, + const leadingComments = getLeadingCommentRanges(currentSourceFile.text, lastOrUndefined(detachedCommentsInfo).detachedCommentEndPos); if (detachedCommentsInfo.length - 1) { detachedCommentsInfo.pop(); @@ -7951,7 +7950,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi if (currentSourceFile.text.charCodeAt(comment.pos + 1) === CharacterCodes.slash && comment.pos + 2 < comment.end && currentSourceFile.text.charCodeAt(comment.pos + 2) === CharacterCodes.slash) { - let textSubStr = currentSourceFile.text.substring(comment.pos, comment.end); + const textSubStr = currentSourceFile.text.substring(comment.pos, comment.end); return textSubStr.match(fullTripleSlashReferencePathRegEx) || textSubStr.match(fullTripleSlashAMDReferencePathRegEx) ? true : false; @@ -8030,7 +8029,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi } // Emit the trailing comments only if the parent's end doesn't match - let trailingComments = getTrailingCommentsToEmit(node); + const trailingComments = getTrailingCommentsToEmit(node); // trailing comments are emitted at space/*trailing comment1 */space/*trailing comment*/ emitComments(currentSourceFile, writer, trailingComments, /*trailingSeparator*/ false, newLine, writeComment); @@ -8046,7 +8045,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi return; } - let trailingComments = getTrailingCommentRanges(currentSourceFile.text, pos); + const trailingComments = getTrailingCommentRanges(currentSourceFile.text, pos); // trailing comments are emitted at space/*trailing comment1 */space/*trailing comment*/ emitComments(currentSourceFile, writer, trailingComments, /*trailingSeparator*/ true, newLine, writeComment); @@ -8074,7 +8073,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi } function emitDetachedCommentsAndUpdateCommentsInfo(node: TextRange) { - let currentDetachedCommentInfo = emitDetachedComments(currentSourceFile, writer, writeComment, node, newLine, compilerOptions.removeComments); + const currentDetachedCommentInfo = emitDetachedComments(currentSourceFile, writer, writeComment, node, newLine, compilerOptions.removeComments); if (currentDetachedCommentInfo) { if (detachedCommentsInfo) { @@ -8087,7 +8086,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi } function emitShebang() { - let shebang = getShebang(currentSourceFile.text); + const shebang = getShebang(currentSourceFile.text); if (shebang) { write(shebang); } diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 3e93e31340d..ab06b12318b 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -2,7 +2,7 @@ /// namespace ts { - let nodeConstructors = new Array Node>(SyntaxKind.Count); + const nodeConstructors = new Array Node>(SyntaxKind.Count); /* @internal */ export let parseTime = 0; export function getNodeConstructor(kind: SyntaxKind): new (pos?: number, end?: number) => Node { @@ -27,8 +27,8 @@ namespace ts { function visitEachNode(cbNode: (node: Node) => T, nodes: Node[]) { if (nodes) { - for (let node of nodes) { - let result = cbNode(node); + for (const node of nodes) { + const result = cbNode(node); if (result) { return result; } @@ -47,8 +47,8 @@ namespace ts { // The visitXXX functions could be written as local functions that close over the cbNode and cbNodeArray // callback parameters, but that causes a closure allocation for each invocation with noticeable effects // on performance. - let visitNodes: (cb: (node: Node | Node[]) => T, nodes: Node[]) => T = cbNodeArray ? visitNodeArray : visitEachNode; - let cbNodes = cbNodeArray || cbNode; + const visitNodes: (cb: (node: Node | Node[]) => T, nodes: Node[]) => T = cbNodeArray ? visitNodeArray : visitEachNode; + const cbNodes = cbNodeArray || cbNode; switch (node.kind) { case SyntaxKind.QualifiedName: return visitNode(cbNode, (node).left) || @@ -397,8 +397,8 @@ namespace ts { } export function createSourceFile(fileName: string, sourceText: string, languageVersion: ScriptTarget, setParentNodes = false): SourceFile { - let start = new Date().getTime(); - let result = Parser.parseSourceFile(fileName, sourceText, languageVersion, /*syntaxCursor*/ undefined, setParentNodes); + const start = new Date().getTime(); + const result = Parser.parseSourceFile(fileName, sourceText, languageVersion, /*syntaxCursor*/ undefined, setParentNodes); parseTime += new Date().getTime() - start; return result; @@ -529,7 +529,7 @@ namespace ts { export function parseSourceFile(fileName: string, _sourceText: string, languageVersion: ScriptTarget, _syntaxCursor: IncrementalParser.SyntaxCursor, setParentNodes?: boolean): SourceFile { initializeState(fileName, _sourceText, languageVersion, _syntaxCursor); - let result = parseSourceFileWorker(fileName, languageVersion, setParentNodes); + const result = parseSourceFileWorker(fileName, languageVersion, setParentNodes); clearState(); @@ -620,10 +620,10 @@ namespace ts { } function addJSDocComment(node: Node) { - let comments = getLeadingCommentRangesOfNode(node, sourceFile); + const comments = getLeadingCommentRangesOfNode(node, sourceFile); if (comments) { - for (let comment of comments) { - let jsDocComment = JSDocParser.parseJSDocComment(node, comment.pos, comment.end - comment.pos); + for (const comment of comments) { + const jsDocComment = JSDocParser.parseJSDocComment(node, comment.pos, comment.end - comment.pos); if (jsDocComment) { node.jsDocComment = jsDocComment; } @@ -648,7 +648,7 @@ namespace ts { if (n.parent !== parent) { n.parent = parent; - let saveParent = parent; + const saveParent = parent; parent = n; forEachChild(n, visitNode); parent = saveParent; @@ -657,7 +657,7 @@ namespace ts { } function createSourceFile(fileName: string, languageVersion: ScriptTarget): SourceFile { - let sourceFile = createNode(SyntaxKind.SourceFile, /*pos*/ 0); + const sourceFile = createNode(SyntaxKind.SourceFile, /*pos*/ 0); sourceFile.pos = 0; sourceFile.end = sourceText.length; @@ -703,11 +703,11 @@ namespace ts { // that we do not mutate cached flags for the incremental // parser (ThisNodeHasError, ThisNodeOrAnySubNodesHasError, and // HasAggregatedChildData). - let contextFlagsToClear = context & contextFlags; + const contextFlagsToClear = context & contextFlags; if (contextFlagsToClear) { // clear the requested context flags setContextFlag(false, contextFlagsToClear); - let result = func(); + const result = func(); // restore the context flags we just cleared setContextFlag(true, contextFlagsToClear); return result; @@ -724,11 +724,11 @@ namespace ts { // that we do not mutate cached flags for the incremental // parser (ThisNodeHasError, ThisNodeOrAnySubNodesHasError, and // HasAggregatedChildData). - let contextFlagsToSet = context & ~contextFlags; + const contextFlagsToSet = context & ~contextFlags; if (contextFlagsToSet) { // set the requested context flags setContextFlag(true, contextFlagsToSet); - let result = func(); + const result = func(); // reset the context flags we just set setContextFlag(false, contextFlagsToSet); return result; @@ -795,15 +795,15 @@ namespace ts { } function parseErrorAtCurrentToken(message: DiagnosticMessage, arg0?: any): void { - let start = scanner.getTokenPos(); - let length = scanner.getTextPos() - start; + const start = scanner.getTokenPos(); + const length = scanner.getTextPos() - start; parseErrorAtPosition(start, length, message, arg0); } function parseErrorAtPosition(start: number, length: number, message: DiagnosticMessage, arg0?: any): void { // Don't report another error if it would just be at the same position as the last error. - let lastError = lastOrUndefined(parseDiagnostics); + const lastError = lastOrUndefined(parseDiagnostics); if (!lastError || start !== lastError.start) { parseDiagnostics.push(createFileDiagnostic(sourceFile, start, length, message, arg0)); } @@ -814,7 +814,7 @@ namespace ts { } function scanError(message: DiagnosticMessage, length?: number) { - let pos = scanner.getTextPos(); + const pos = scanner.getTextPos(); parseErrorAtPosition(pos, length || 0, message); } @@ -857,20 +857,20 @@ namespace ts { function speculationHelper(callback: () => T, isLookAhead: boolean): T { // Keep track of the state we'll need to rollback to if lookahead fails (or if the // caller asked us to always reset our state). - let saveToken = token; - let saveParseDiagnosticsLength = parseDiagnostics.length; - let saveParseErrorBeforeNextFinishedNode = parseErrorBeforeNextFinishedNode; + const saveToken = token; + const saveParseDiagnosticsLength = parseDiagnostics.length; + const saveParseErrorBeforeNextFinishedNode = parseErrorBeforeNextFinishedNode; // Note: it is not actually necessary to save/restore the context flags here. That's // because the saving/restoring of these flags happens naturally through the recursive // descent nature of our parser. However, we still store this here just so we can // assert that that invariant holds. - let saveContextFlags = contextFlags; + const saveContextFlags = contextFlags; // If we're only looking ahead, then tell the scanner to only lookahead as well. // Otherwise, if we're actually speculatively parsing, then tell the scanner to do the // same. - let result = isLookAhead + const result = isLookAhead ? scanner.lookAhead(callback) : scanner.tryScan(callback); @@ -962,7 +962,7 @@ namespace ts { } function parseTokenNode(): T { - let node = createNode(token); + const node = createNode(token); nextToken(); return finishNode(node); } @@ -1025,7 +1025,7 @@ namespace ts { parseErrorAtCurrentToken(diagnosticMessage, arg0); } - let result = createNode(kind, scanner.getStartPos()); + const result = createNode(kind, scanner.getStartPos()); (result).text = ""; return finishNode(result); } @@ -1041,7 +1041,7 @@ namespace ts { function createIdentifier(isIdentifier: boolean, diagnosticMessage?: DiagnosticMessage): Identifier { identifierCount++; if (isIdentifier) { - let node = createNode(SyntaxKind.Identifier); + const node = createNode(SyntaxKind.Identifier); // Store original token kind if it is not just an Identifier so we can report appropriate error later in type checker if (token !== SyntaxKind.Identifier) { @@ -1095,7 +1095,7 @@ namespace ts { // PropertyName [Yield]: // LiteralPropertyName // ComputedPropertyName[?Yield] - let node = createNode(SyntaxKind.ComputedPropertyName); + const node = createNode(SyntaxKind.ComputedPropertyName); parseExpected(SyntaxKind.OpenBracketToken); // We parse any expression (including a comma expression). But the grammar @@ -1156,7 +1156,7 @@ namespace ts { // True if positioned at the start of a list element function isListElement(parsingContext: ParsingContext, inErrorRecovery: boolean): boolean { - let node = currentNode(parsingContext); + const node = currentNode(parsingContext); if (node) { return true; } @@ -1250,7 +1250,7 @@ namespace ts { // extends {} extends // extends {} implements - let next = nextToken(); + const next = nextToken(); return next === SyntaxKind.CommaToken || next === SyntaxKind.OpenBraceToken || next === SyntaxKind.ExtendsKeyword || next === SyntaxKind.ImplementsKeyword; } @@ -1378,14 +1378,14 @@ namespace ts { // Parses a list of elements function parseList(kind: ParsingContext, parseElement: () => T): NodeArray { - let saveParsingContext = parsingContext; + const saveParsingContext = parsingContext; parsingContext |= 1 << kind; - let result = >[]; + const result = >[]; result.pos = getNodePos(); while (!isListTerminator(kind)) { if (isListElement(kind, /* inErrorRecovery */ false)) { - let element = parseListElement(kind, parseElement); + const element = parseListElement(kind, parseElement); result.push(element); continue; @@ -1402,7 +1402,7 @@ namespace ts { } function parseListElement(parsingContext: ParsingContext, parseElement: () => T): T { - let node = currentNode(parsingContext); + const node = currentNode(parsingContext); if (node) { return consumeNode(node); } @@ -1427,7 +1427,7 @@ namespace ts { return undefined; } - let node = syntaxCursor.currentNode(scanner.getStartPos()); + const node = syntaxCursor.currentNode(scanner.getStartPos()); // Can't reuse a missing node. if (nodeIsMissing(node)) { @@ -1456,7 +1456,7 @@ namespace ts { // differently depending on what mode it is in. // // This also applies to all our other context flags as well. - let nodeContextFlags = node.parserContextFlags & ParserContextFlags.ParserGeneratedFlags; + const nodeContextFlags = node.parserContextFlags & ParserContextFlags.ParserGeneratedFlags; if (nodeContextFlags !== contextFlags) { return undefined; } @@ -1668,7 +1668,7 @@ namespace ts { // // In order to prevent this, we do not allow a variable declarator to be reused if it // has an initializer. - let variableDeclarator = node; + const variableDeclarator = node; return variableDeclarator.initializer === undefined; } @@ -1678,7 +1678,7 @@ namespace ts { } // See the comment in isReusableVariableDeclaration for why we do this. - let parameter = node; + const parameter = node; return parameter.initializer === undefined; } @@ -1726,9 +1726,9 @@ namespace ts { // Parses a comma-delimited list of elements function parseDelimitedList(kind: ParsingContext, parseElement: () => T, considerSemicolonAsDelimeter?: boolean): NodeArray { - let saveParsingContext = parsingContext; + const saveParsingContext = parsingContext; parsingContext |= 1 << kind; - let result = >[]; + const result = >[]; result.pos = getNodePos(); let commaStart = -1; // Meaning the previous token was not a comma @@ -1785,8 +1785,8 @@ namespace ts { } function createMissingList(): NodeArray { - let pos = getNodePos(); - let result = >[]; + const pos = getNodePos(); + const result = >[]; result.pos = pos; result.end = pos; return result; @@ -1794,7 +1794,7 @@ namespace ts { function parseBracketedList(kind: ParsingContext, parseElement: () => T, open: SyntaxKind, close: SyntaxKind): NodeArray { if (parseExpected(open)) { - let result = parseDelimitedList(kind, parseElement); + const result = parseDelimitedList(kind, parseElement); parseExpected(close); return result; } @@ -1806,7 +1806,7 @@ namespace ts { function parseEntityName(allowReservedWords: boolean, diagnosticMessage?: DiagnosticMessage): EntityName { let entity: EntityName = parseIdentifier(diagnosticMessage); while (parseOptional(SyntaxKind.DotToken)) { - let node = createNode(SyntaxKind.QualifiedName, entity.pos); + const node = createNode(SyntaxKind.QualifiedName, entity.pos); node.left = entity; node.right = parseRightSideOfDot(allowReservedWords); entity = finishNode(node); @@ -1835,7 +1835,7 @@ namespace ts { // In the first case though, ASI will not take effect because there is not a // line terminator after the identifier or keyword. if (scanner.hasPrecedingLineBreak() && tokenIsIdentifierOrKeyword(token)) { - let matchesPattern = lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine); + const matchesPattern = lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine); if (matchesPattern) { // Report that we need an identifier. However, report it right after the dot, @@ -1849,12 +1849,12 @@ namespace ts { } function parseTemplateExpression(): TemplateExpression { - let template = createNode(SyntaxKind.TemplateExpression); + const template = createNode(SyntaxKind.TemplateExpression); template.head = parseLiteralNode(); Debug.assert(template.head.kind === SyntaxKind.TemplateHead, "Template head has wrong token kind"); - let templateSpans = >[]; + const templateSpans = >[]; templateSpans.pos = getNodePos(); do { @@ -1869,7 +1869,7 @@ namespace ts { } function parseTemplateSpan(): TemplateSpan { - let span = createNode(SyntaxKind.TemplateSpan); + const span = createNode(SyntaxKind.TemplateSpan); span.expression = allowInAnd(parseExpression); let literal: LiteralExpression; @@ -1887,8 +1887,8 @@ namespace ts { } function parseLiteralNode(internName?: boolean): LiteralExpression { - let node = createNode(token); - let text = scanner.getTokenValue(); + const node = createNode(token); + const text = scanner.getTokenValue(); node.text = internName ? internIdentifier(text) : text; if (scanner.hasExtendedUnicodeEscape()) { @@ -1899,7 +1899,7 @@ namespace ts { node.isUnterminated = true; } - let tokenPos = scanner.getTokenPos(); + const tokenPos = scanner.getTokenPos(); nextToken(); finishNode(node); @@ -1922,15 +1922,15 @@ namespace ts { // TYPES function parseTypeReferenceOrTypePredicate(): TypeReferenceNode | TypePredicateNode { - let typeName = parseEntityName(/*allowReservedWords*/ false, Diagnostics.Type_expected); + const typeName = parseEntityName(/*allowReservedWords*/ false, Diagnostics.Type_expected); if (typeName.kind === SyntaxKind.Identifier && token === SyntaxKind.IsKeyword && !scanner.hasPrecedingLineBreak()) { nextToken(); - let node = createNode(SyntaxKind.TypePredicate, typeName.pos); + const node = createNode(SyntaxKind.TypePredicate, typeName.pos); node.parameterName = typeName; node.type = parseType(); return finishNode(node); } - let node = createNode(SyntaxKind.TypeReference, typeName.pos); + const node = createNode(SyntaxKind.TypeReference, typeName.pos); node.typeName = typeName; if (!scanner.hasPrecedingLineBreak() && token === SyntaxKind.LessThanToken) { node.typeArguments = parseBracketedList(ParsingContext.TypeArguments, parseType, SyntaxKind.LessThanToken, SyntaxKind.GreaterThanToken); @@ -1939,14 +1939,14 @@ namespace ts { } function parseTypeQuery(): TypeQueryNode { - let node = createNode(SyntaxKind.TypeQuery); + const node = createNode(SyntaxKind.TypeQuery); parseExpected(SyntaxKind.TypeOfKeyword); node.exprName = parseEntityName(/*allowReservedWords*/ true); return finishNode(node); } function parseTypeParameter(): TypeParameterDeclaration { - let node = createNode(SyntaxKind.TypeParameter); + const node = createNode(SyntaxKind.TypeParameter); node.name = parseIdentifier(); if (parseOptional(SyntaxKind.ExtendsKeyword)) { // It's not uncommon for people to write improper constraints to a generic. If the @@ -1999,7 +1999,7 @@ namespace ts { } function parseParameter(): ParameterDeclaration { - let node = createNode(SyntaxKind.Parameter); + const node = createNode(SyntaxKind.Parameter); node.decorators = parseDecorators(); setModifiers(node, parseModifiers()); node.dotDotDotToken = parseOptionalToken(SyntaxKind.DotDotDotToken); @@ -2051,7 +2051,7 @@ namespace ts { requireCompleteParameterList: boolean, signature: SignatureDeclaration): void { - let returnTokenRequired = returnToken === SyntaxKind.EqualsGreaterThanToken; + const returnTokenRequired = returnToken === SyntaxKind.EqualsGreaterThanToken; signature.typeParameters = parseTypeParameters(); signature.parameters = parseParameterList(yieldContext, awaitContext, requireCompleteParameterList); @@ -2079,13 +2079,13 @@ namespace ts { // SingleNameBinding [Yield,Await]: // BindingIdentifier[?Yield,?Await]Initializer [In, ?Yield,?Await] opt if (parseExpected(SyntaxKind.OpenParenToken)) { - let savedYieldContext = inYieldContext(); - let savedAwaitContext = inAwaitContext(); + const savedYieldContext = inYieldContext(); + const savedAwaitContext = inAwaitContext(); setYieldContext(yieldContext); setAwaitContext(awaitContext); - let result = parseDelimitedList(ParsingContext.Parameters, parseParameter); + const result = parseDelimitedList(ParsingContext.Parameters, parseParameter); setYieldContext(savedYieldContext); setAwaitContext(savedAwaitContext); @@ -2117,7 +2117,7 @@ namespace ts { } function parseSignatureMember(kind: SyntaxKind): SignatureDeclaration { - let node = createNode(kind); + const node = createNode(kind); if (kind === SyntaxKind.ConstructSignature) { parseExpected(SyntaxKind.NewKeyword); } @@ -2190,7 +2190,7 @@ namespace ts { } function parseIndexSignatureDeclaration(fullStart: number, decorators: NodeArray, modifiers: ModifiersArray): IndexSignatureDeclaration { - let node = createNode(SyntaxKind.IndexSignature, fullStart); + const node = createNode(SyntaxKind.IndexSignature, fullStart); node.decorators = decorators; setModifiers(node, modifiers); node.parameters = parseBracketedList(ParsingContext.Parameters, parseParameter, SyntaxKind.OpenBracketToken, SyntaxKind.CloseBracketToken); @@ -2200,12 +2200,12 @@ namespace ts { } function parsePropertyOrMethodSignature(): Declaration { - let fullStart = scanner.getStartPos(); - let name = parsePropertyName(); - let questionToken = parseOptionalToken(SyntaxKind.QuestionToken); + const fullStart = scanner.getStartPos(); + const name = parsePropertyName(); + const questionToken = parseOptionalToken(SyntaxKind.QuestionToken); if (token === SyntaxKind.OpenParenToken || token === SyntaxKind.LessThanToken) { - let method = createNode(SyntaxKind.MethodSignature, fullStart); + const method = createNode(SyntaxKind.MethodSignature, fullStart); method.name = name; method.questionToken = questionToken; @@ -2216,7 +2216,7 @@ namespace ts { return finishNode(method); } else { - let property = createNode(SyntaxKind.PropertySignature, fullStart); + const property = createNode(SyntaxKind.PropertySignature, fullStart); property.name = name; property.questionToken = questionToken; property.type = parseTypeAnnotation(); @@ -2233,7 +2233,7 @@ namespace ts { return true; default: if (isModifier(token)) { - let result = lookAhead(isStartOfIndexSignatureDeclaration); + const result = lookAhead(isStartOfIndexSignatureDeclaration); if (result) { return result; } @@ -2286,7 +2286,7 @@ namespace ts { // if it has the same text regardless of whether it is inside a class or an // object type. if (isModifier(token)) { - let result = tryParse(parseIndexSignatureWithModifiers); + const result = tryParse(parseIndexSignatureWithModifiers); if (result) { return result; } @@ -2299,9 +2299,9 @@ namespace ts { } function parseIndexSignatureWithModifiers() { - let fullStart = scanner.getStartPos(); - let decorators = parseDecorators(); - let modifiers = parseModifiers(); + const fullStart = scanner.getStartPos(); + const decorators = parseDecorators(); + const modifiers = parseModifiers(); return isIndexSignature() ? parseIndexSignatureDeclaration(fullStart, decorators, modifiers) : undefined; @@ -2313,7 +2313,7 @@ namespace ts { } function parseTypeLiteral(): TypeLiteralNode { - let node = createNode(SyntaxKind.TypeLiteral); + const node = createNode(SyntaxKind.TypeLiteral); node.members = parseObjectTypeMembers(); return finishNode(node); } @@ -2332,13 +2332,13 @@ namespace ts { } function parseTupleType(): TupleTypeNode { - let node = createNode(SyntaxKind.TupleType); + const node = createNode(SyntaxKind.TupleType); node.elementTypes = parseBracketedList(ParsingContext.TupleElementTypes, parseType, SyntaxKind.OpenBracketToken, SyntaxKind.CloseBracketToken); return finishNode(node); } function parseParenthesizedType(): ParenthesizedTypeNode { - let node = createNode(SyntaxKind.ParenthesizedType); + const node = createNode(SyntaxKind.ParenthesizedType); parseExpected(SyntaxKind.OpenParenToken); node.type = parseType(); parseExpected(SyntaxKind.CloseParenToken); @@ -2346,7 +2346,7 @@ namespace ts { } function parseFunctionOrConstructorType(kind: SyntaxKind): FunctionOrConstructorTypeNode { - let node = createNode(kind); + const node = createNode(kind); if (kind === SyntaxKind.ConstructorType) { parseExpected(SyntaxKind.NewKeyword); } @@ -2355,7 +2355,7 @@ namespace ts { } function parseKeywordAndNoDot(): TypeNode { - let node = parseTokenNode(); + const node = parseTokenNode(); return token === SyntaxKind.DotToken ? undefined : node; } @@ -2367,7 +2367,7 @@ namespace ts { case SyntaxKind.BooleanKeyword: case SyntaxKind.SymbolKeyword: // If these are followed by a dot, then parse these out as a dotted type reference instead. - let node = tryParse(parseKeywordAndNoDot); + const node = tryParse(parseKeywordAndNoDot); return node || parseTypeReferenceOrTypePredicate(); case SyntaxKind.VoidKeyword: case SyntaxKind.ThisKeyword: @@ -2418,7 +2418,7 @@ namespace ts { let type = parseNonArrayType(); while (!scanner.hasPrecedingLineBreak() && parseOptional(SyntaxKind.OpenBracketToken)) { parseExpected(SyntaxKind.CloseBracketToken); - let node = createNode(SyntaxKind.ArrayType, type.pos); + const node = createNode(SyntaxKind.ArrayType, type.pos); node.elementType = type; type = finishNode(node); } @@ -2428,13 +2428,13 @@ namespace ts { function parseUnionOrIntersectionType(kind: SyntaxKind, parseConstituentType: () => TypeNode, operator: SyntaxKind): TypeNode { let type = parseConstituentType(); if (token === operator) { - let types = >[type]; + const types = >[type]; types.pos = type.pos; while (parseOptional(operator)) { types.push(parseConstituentType()); } types.end = getNodeEnd(); - let node = createNode(kind, type.pos); + const node = createNode(kind, type.pos); node.types = types; type = finishNode(node); } @@ -2588,7 +2588,7 @@ namespace ts { // Expression[in] , AssignmentExpression[in] // clear the decorator context when parsing Expression, as it should be unambiguous when parsing a decorator - let saveDecoratorContext = inDecoratorContext(); + const saveDecoratorContext = inDecoratorContext(); if (saveDecoratorContext) { setDecoratorContext(false); } @@ -2649,7 +2649,7 @@ namespace ts { // parameter list. If we do, we must *not* recurse for productions 1, 2 or 3. An ArrowFunction is // not a LeftHandSideExpression, nor does it start a ConditionalExpression. So we are done // with AssignmentExpression if we see one. - let arrowExpression = tryParseParenthesizedArrowFunctionExpression(); + const arrowExpression = tryParseParenthesizedArrowFunctionExpression(); if (arrowExpression) { return arrowExpression; } @@ -2663,7 +2663,7 @@ namespace ts { // Otherwise, we try to parse out the conditional expression bit. We want to allow any // binary expression here, so we pass in the 'lowest' precedence here so that it matches // and consumes anything. - let expr = parseBinaryExpressionOrHigher(/*precedence*/ 0); + const expr = parseBinaryExpressionOrHigher(/*precedence*/ 0); // 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 @@ -2720,7 +2720,7 @@ namespace ts { } function parseYieldExpression(): YieldExpression { - let node = createNode(SyntaxKind.YieldExpression); + const node = createNode(SyntaxKind.YieldExpression); // YieldExpression[In] : // yield @@ -2744,9 +2744,9 @@ namespace ts { function parseSimpleArrowFunctionExpression(identifier: Identifier): Expression { Debug.assert(token === SyntaxKind.EqualsGreaterThanToken, "parseSimpleArrowFunctionExpression should only have been called if we had a =>"); - let node = createNode(SyntaxKind.ArrowFunction, identifier.pos); + const node = createNode(SyntaxKind.ArrowFunction, identifier.pos); - let parameter = createNode(SyntaxKind.Parameter, identifier.pos); + const parameter = createNode(SyntaxKind.Parameter, identifier.pos); parameter.name = identifier; finishNode(parameter); @@ -2761,7 +2761,7 @@ namespace ts { } function tryParseParenthesizedArrowFunctionExpression(): Expression { - let triState = isParenthesizedArrowFunctionExpression(); + const triState = isParenthesizedArrowFunctionExpression(); if (triState === Tristate.False) { // It's definitely not a parenthesized arrow function expression. return undefined; @@ -2771,7 +2771,7 @@ namespace ts { // following => or { token. Otherwise, we *might* have an arrow function. Try to parse // it out, but don't allow any ambiguity, and return 'undefined' if this could be an // expression instead. - let arrowFunction = triState === Tristate.True + const arrowFunction = triState === Tristate.True ? parseParenthesizedArrowFunctionExpressionHead(/*allowAmbiguity*/ true) : tryParse(parsePossibleParenthesizedArrowFunctionExpressionHead); @@ -2780,11 +2780,11 @@ namespace ts { return undefined; } - let isAsync = !!(arrowFunction.flags & NodeFlags.Async); + const isAsync = !!(arrowFunction.flags & NodeFlags.Async); // 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. - let lastToken = token; + const lastToken = token; arrowFunction.equalsGreaterThanToken = parseExpectedToken(SyntaxKind.EqualsGreaterThanToken, /*reportAtCurrentPosition*/false, Diagnostics._0_expected, "=>"); arrowFunction.body = (lastToken === SyntaxKind.EqualsGreaterThanToken || lastToken === SyntaxKind.OpenBraceToken) ? parseArrowFunctionExpressionBody(isAsync) @@ -2823,8 +2823,8 @@ namespace ts { } } - let first = token; - let second = nextToken(); + const first = token; + const second = nextToken(); if (first === SyntaxKind.OpenParenToken) { if (second === SyntaxKind.CloseParenToken) { @@ -2832,7 +2832,7 @@ namespace ts { // 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. - let third = nextToken(); + const third = nextToken(); switch (third) { case SyntaxKind.EqualsGreaterThanToken: case SyntaxKind.ColonToken: @@ -2875,7 +2875,7 @@ namespace ts { } // This *could* be a parenthesized arrow function. - // Return Unknown to let the caller know. + // Return Unknown to const the caller know. return Tristate.Unknown; } else { @@ -2889,10 +2889,10 @@ namespace ts { // JSX overrides if (sourceFile.languageVariant === LanguageVariant.JSX) { - let isArrowFunctionInJsx = lookAhead(() => { - let third = nextToken(); + const isArrowFunctionInJsx = lookAhead(() => { + const third = nextToken(); if (third === SyntaxKind.ExtendsKeyword) { - let fourth = nextToken(); + const fourth = nextToken(); switch (fourth) { case SyntaxKind.EqualsToken: case SyntaxKind.GreaterThanToken: @@ -2924,9 +2924,9 @@ namespace ts { } function parseParenthesizedArrowFunctionExpressionHead(allowAmbiguity: boolean): ArrowFunction { - let node = createNode(SyntaxKind.ArrowFunction); + const node = createNode(SyntaxKind.ArrowFunction); setModifiers(node, parseModifiersForArrowFunction()); - let isAsync = !!(node.flags & NodeFlags.Async); + const isAsync = !!(node.flags & NodeFlags.Async); // Arrow functions are never generators. // @@ -2974,7 +2974,7 @@ namespace ts { // user meant to supply a block. For example, if the user wrote: // // a => - // let v = 0; + // const v = 0; // } // // they may be missing an open brace. Check to see if that's the case so we can @@ -2992,14 +2992,14 @@ namespace ts { function parseConditionalExpressionRest(leftOperand: Expression): Expression { // Note: we are passed in an expression which was produced from parseBinaryExpressionOrHigher. - let questionToken = parseOptionalToken(SyntaxKind.QuestionToken); + const questionToken = parseOptionalToken(SyntaxKind.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. - let node = createNode(SyntaxKind.ConditionalExpression, leftOperand.pos); + const node = createNode(SyntaxKind.ConditionalExpression, leftOperand.pos); node.condition = leftOperand; node.questionToken = questionToken; node.whenTrue = doOutsideOfContext(disallowInAndDecoratorContext, parseAssignmentExpressionOrHigher); @@ -3010,7 +3010,7 @@ namespace ts { } function parseBinaryExpressionOrHigher(precedence: number): Expression { - let leftOperand = parseUnaryExpressionOrHigher(); + const leftOperand = parseUnaryExpressionOrHigher(); return parseBinaryExpressionRest(precedence, leftOperand); } @@ -3024,7 +3024,7 @@ namespace ts { // reScanGreaterToken so that we merge token sequences like > and = into >= reScanGreaterToken(); - let newPrecedence = getBinaryOperatorPrecedence(); + const newPrecedence = getBinaryOperatorPrecedence(); // Check the precedence to see if we should "take" this operator // - For left associative operator (all operator but **), consume the operator, @@ -3135,7 +3135,7 @@ namespace ts { } function makeBinaryExpression(left: Expression, operatorToken: Node, right: Expression): BinaryExpression { - let node = createNode(SyntaxKind.BinaryExpression, left.pos); + const node = createNode(SyntaxKind.BinaryExpression, left.pos); node.left = left; node.operatorToken = operatorToken; node.right = right; @@ -3143,14 +3143,14 @@ namespace ts { } function makeAsExpression(left: Expression, right: TypeNode): AsExpression { - let node = createNode(SyntaxKind.AsExpression, left.pos); + const node = createNode(SyntaxKind.AsExpression, left.pos); node.expression = left; node.type = right; return finishNode(node); } function parsePrefixUnaryExpression() { - let node = createNode(SyntaxKind.PrefixUnaryExpression); + const node = createNode(SyntaxKind.PrefixUnaryExpression); node.operator = token; nextToken(); node.operand = parseSimpleUnaryExpression(); @@ -3159,21 +3159,21 @@ namespace ts { } function parseDeleteExpression() { - let node = createNode(SyntaxKind.DeleteExpression); + const node = createNode(SyntaxKind.DeleteExpression); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function parseTypeOfExpression() { - let node = createNode(SyntaxKind.TypeOfExpression); + const node = createNode(SyntaxKind.TypeOfExpression); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function parseVoidExpression() { - let node = createNode(SyntaxKind.VoidExpression); + const node = createNode(SyntaxKind.VoidExpression); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); @@ -3212,17 +3212,16 @@ namespace ts { } if (isIncrementExpression()) { - let incrementExpression = parseIncrementExpression(); + const incrementExpression = parseIncrementExpression(); return token === SyntaxKind.AsteriskAsteriskToken ? parseBinaryExpressionRest(getBinaryOperatorPrecedence(), incrementExpression) : incrementExpression; } - let unaryOperator = token; - let simpleUnaryExpression = parseSimpleUnaryExpression(); + const unaryOperator = token; + const simpleUnaryExpression = parseSimpleUnaryExpression(); if (token === SyntaxKind.AsteriskAsteriskToken) { - let diagnostic: Diagnostic; - let start = skipTrivia(sourceText, simpleUnaryExpression.pos); + const start = skipTrivia(sourceText, simpleUnaryExpression.pos); if (simpleUnaryExpression.kind === SyntaxKind.TypeAssertionExpression) { parseErrorAtPosition(start, simpleUnaryExpression.end - start, Diagnostics.A_type_assertion_expression_is_not_allowed_in_the_left_hand_side_of_an_exponentiation_expression_Consider_enclosing_the_expression_in_parentheses); } @@ -3316,7 +3315,7 @@ namespace ts { */ function parseIncrementExpression(): IncrementExpression { if (token === SyntaxKind.PlusPlusToken || token === SyntaxKind.MinusMinusToken) { - let node = createNode(SyntaxKind.PrefixUnaryExpression); + const node = createNode(SyntaxKind.PrefixUnaryExpression); node.operator = token; nextToken(); node.operand = parseLeftHandSideExpressionOrHigher(); @@ -3327,11 +3326,11 @@ namespace ts { return parseJsxElementOrSelfClosingElement(/*inExpressionContext*/ true); } - let expression = parseLeftHandSideExpressionOrHigher(); + const expression = parseLeftHandSideExpressionOrHigher(); Debug.assert(isLeftHandSideExpression(expression)); if ((token === SyntaxKind.PlusPlusToken || token === SyntaxKind.MinusMinusToken) && !scanner.hasPrecedingLineBreak()) { - let node = createNode(SyntaxKind.PostfixUnaryExpression, expression.pos); + const node = createNode(SyntaxKind.PostfixUnaryExpression, expression.pos); node.operand = expression; node.operator = token; nextToken(); @@ -3372,7 +3371,7 @@ namespace 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. - let expression = token === SyntaxKind.SuperKeyword + const expression = token === SyntaxKind.SuperKeyword ? parseSuperExpression() : parseMemberExpressionOrHigher(); @@ -3429,19 +3428,19 @@ namespace ts { // // Because CallExpression and MemberExpression are left recursive, we need to bottom out // of the recursion immediately. So we parse out a primary expression to start with. - let expression = parsePrimaryExpression(); + const expression = parsePrimaryExpression(); return parseMemberExpressionRest(expression); } function parseSuperExpression(): MemberExpression { - let expression = parseTokenNode(); + const expression = parseTokenNode(); if (token === SyntaxKind.OpenParenToken || token === SyntaxKind.DotToken || token === SyntaxKind.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. - let node = createNode(SyntaxKind.PropertyAccessExpression, expression.pos); + const node = createNode(SyntaxKind.PropertyAccessExpression, expression.pos); node.expression = expression; node.dotToken = parseExpectedToken(SyntaxKind.DotToken, /*reportAtCurrentPosition*/ false, Diagnostics.super_must_be_followed_by_an_argument_list_or_member_access); node.name = parseRightSideOfDot(/*allowIdentifierNames*/ true); @@ -3449,10 +3448,10 @@ namespace ts { } function parseJsxElementOrSelfClosingElement(inExpressionContext: boolean): JsxElement | JsxSelfClosingElement { - let opening = parseJsxOpeningOrSelfClosingElement(inExpressionContext); + const opening = parseJsxOpeningOrSelfClosingElement(inExpressionContext); let result: JsxElement | JsxSelfClosingElement; if (opening.kind === SyntaxKind.JsxOpeningElement) { - let node = createNode(SyntaxKind.JsxElement, opening.pos); + const node = createNode(SyntaxKind.JsxElement, opening.pos); node.openingElement = opening; node.children = parseJsxChildren(node.openingElement.tagName); @@ -3473,10 +3472,10 @@ namespace ts { // Since JSX elements are invalid < operands anyway, this lookahead parse will only occur in error scenarios // of one sort or another. if (inExpressionContext && token === SyntaxKind.LessThanToken) { - let invalidElement = tryParse(() => parseJsxElementOrSelfClosingElement(/*inExpressionContext*/true)); + const invalidElement = tryParse(() => parseJsxElementOrSelfClosingElement(/*inExpressionContext*/true)); if (invalidElement) { parseErrorAtCurrentToken(Diagnostics.JSX_expressions_must_have_one_parent_element); - let badNode = createNode(SyntaxKind.BinaryExpression, result.pos); + const badNode = createNode(SyntaxKind.BinaryExpression, result.pos); badNode.end = invalidElement.end; badNode.left = result; badNode.right = invalidElement; @@ -3490,7 +3489,7 @@ namespace ts { } function parseJsxText(): JsxText { - let node = createNode(SyntaxKind.JsxText, scanner.getStartPos()); + const node = createNode(SyntaxKind.JsxText, scanner.getStartPos()); token = scanner.scanJsxToken(); return finishNode(node); } @@ -3508,9 +3507,9 @@ namespace ts { } function parseJsxChildren(openingTagName: EntityName): NodeArray { - let result = >[]; + const result = >[]; result.pos = scanner.getStartPos(); - let saveParsingContext = parsingContext; + const saveParsingContext = parsingContext; parsingContext |= 1 << ParsingContext.JsxChildren; while (true) { @@ -3533,13 +3532,13 @@ namespace ts { } function parseJsxOpeningOrSelfClosingElement(inExpressionContext: boolean): JsxOpeningElement | JsxSelfClosingElement { - let fullStart = scanner.getStartPos(); + const fullStart = scanner.getStartPos(); parseExpected(SyntaxKind.LessThanToken); - let tagName = parseJsxElementName(); + const tagName = parseJsxElementName(); - let attributes = parseList(ParsingContext.JsxAttributes, parseJsxAttribute); + const attributes = parseList(ParsingContext.JsxAttributes, parseJsxAttribute); let node: JsxOpeningLikeElement; if (token === SyntaxKind.GreaterThanToken) { @@ -3572,7 +3571,7 @@ namespace ts { let elementName: EntityName = parseIdentifierName(); while (parseOptional(SyntaxKind.DotToken)) { scanJsxIdentifier(); - let node = createNode(SyntaxKind.QualifiedName, elementName.pos); + const node = createNode(SyntaxKind.QualifiedName, elementName.pos); node.left = elementName; node.right = parseIdentifierName(); elementName = finishNode(node); @@ -3581,7 +3580,7 @@ namespace ts { } function parseJsxExpression(inExpressionContext: boolean): JsxExpression { - let node = createNode(SyntaxKind.JsxExpression); + const node = createNode(SyntaxKind.JsxExpression); parseExpected(SyntaxKind.OpenBraceToken); if (token !== SyntaxKind.CloseBraceToken) { @@ -3604,7 +3603,7 @@ namespace ts { } scanJsxIdentifier(); - let node = createNode(SyntaxKind.JsxAttribute); + const node = createNode(SyntaxKind.JsxAttribute); node.name = parseIdentifierName(); if (parseOptional(SyntaxKind.EqualsToken)) { switch (token) { @@ -3620,7 +3619,7 @@ namespace ts { } function parseJsxSpreadAttribute(): JsxSpreadAttribute { - let node = createNode(SyntaxKind.JsxSpreadAttribute); + const node = createNode(SyntaxKind.JsxSpreadAttribute); parseExpected(SyntaxKind.OpenBraceToken); parseExpected(SyntaxKind.DotDotDotToken); node.expression = parseExpression(); @@ -3629,7 +3628,7 @@ namespace ts { } function parseJsxClosingElement(inExpressionContext: boolean): JsxClosingElement { - let node = createNode(SyntaxKind.JsxClosingElement); + const node = createNode(SyntaxKind.JsxClosingElement); parseExpected(SyntaxKind.LessThanSlashToken); node.tagName = parseJsxElementName(); if (inExpressionContext) { @@ -3643,7 +3642,7 @@ namespace ts { } function parseTypeAssertion(): TypeAssertion { - let node = createNode(SyntaxKind.TypeAssertionExpression); + const node = createNode(SyntaxKind.TypeAssertionExpression); parseExpected(SyntaxKind.LessThanToken); node.type = parseType(); parseExpected(SyntaxKind.GreaterThanToken); @@ -3653,9 +3652,9 @@ namespace ts { function parseMemberExpressionRest(expression: LeftHandSideExpression): MemberExpression { while (true) { - let dotToken = parseOptionalToken(SyntaxKind.DotToken); + const dotToken = parseOptionalToken(SyntaxKind.DotToken); if (dotToken) { - let propertyAccess = createNode(SyntaxKind.PropertyAccessExpression, expression.pos); + const propertyAccess = createNode(SyntaxKind.PropertyAccessExpression, expression.pos); propertyAccess.expression = expression; propertyAccess.dotToken = dotToken; propertyAccess.name = parseRightSideOfDot(/*allowIdentifierNames*/ true); @@ -3665,7 +3664,7 @@ namespace ts { // when in the [Decorator] context, we do not parse ElementAccess as it could be part of a ComputedPropertyName if (!inDecoratorContext() && parseOptional(SyntaxKind.OpenBracketToken)) { - let indexedAccess = createNode(SyntaxKind.ElementAccessExpression, expression.pos); + const indexedAccess = createNode(SyntaxKind.ElementAccessExpression, expression.pos); indexedAccess.expression = expression; // It's not uncommon for a user to write: "new Type[]". @@ -3673,7 +3672,7 @@ namespace ts { if (token !== SyntaxKind.CloseBracketToken) { indexedAccess.argumentExpression = allowInAnd(parseExpression); if (indexedAccess.argumentExpression.kind === SyntaxKind.StringLiteral || indexedAccess.argumentExpression.kind === SyntaxKind.NumericLiteral) { - let literal = indexedAccess.argumentExpression; + const literal = indexedAccess.argumentExpression; literal.text = internIdentifier(literal.text); } } @@ -3684,7 +3683,7 @@ namespace ts { } if (token === SyntaxKind.NoSubstitutionTemplateLiteral || token === SyntaxKind.TemplateHead) { - let tagExpression = createNode(SyntaxKind.TaggedTemplateExpression, expression.pos); + const tagExpression = createNode(SyntaxKind.TaggedTemplateExpression, expression.pos); tagExpression.tag = expression; tagExpression.template = token === SyntaxKind.NoSubstitutionTemplateLiteral ? parseLiteralNode() @@ -3705,12 +3704,12 @@ namespace ts { // 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 // stack. - let typeArguments = tryParse(parseTypeArgumentsInExpression); + const typeArguments = tryParse(parseTypeArgumentsInExpression); if (!typeArguments) { return expression; } - let callExpr = createNode(SyntaxKind.CallExpression, expression.pos); + const callExpr = createNode(SyntaxKind.CallExpression, expression.pos); callExpr.expression = expression; callExpr.typeArguments = typeArguments; callExpr.arguments = parseArgumentList(); @@ -3718,7 +3717,7 @@ namespace ts { continue; } else if (token === SyntaxKind.OpenParenToken) { - let callExpr = createNode(SyntaxKind.CallExpression, expression.pos); + const callExpr = createNode(SyntaxKind.CallExpression, expression.pos); callExpr.expression = expression; callExpr.arguments = parseArgumentList(); expression = finishNode(callExpr); @@ -3731,7 +3730,7 @@ namespace ts { function parseArgumentList() { parseExpected(SyntaxKind.OpenParenToken); - let result = parseDelimitedList(ParsingContext.ArgumentExpressions, parseArgumentExpression); + const result = parseDelimitedList(ParsingContext.ArgumentExpressions, parseArgumentExpression); parseExpected(SyntaxKind.CloseParenToken); return result; } @@ -3741,7 +3740,7 @@ namespace ts { return undefined; } - let typeArguments = parseDelimitedList(ParsingContext.TypeArguments, parseType); + const typeArguments = parseDelimitedList(ParsingContext.TypeArguments, parseType); if (!parseExpected(SyntaxKind.GreaterThanToken)) { // If it doesn't have the closing > then it's definitely not an type argument list. return undefined; @@ -3841,7 +3840,7 @@ namespace ts { } function parseParenthesizedExpression(): ParenthesizedExpression { - let node = createNode(SyntaxKind.ParenthesizedExpression); + const node = createNode(SyntaxKind.ParenthesizedExpression); parseExpected(SyntaxKind.OpenParenToken); node.expression = allowInAnd(parseExpression); parseExpected(SyntaxKind.CloseParenToken); @@ -3849,7 +3848,7 @@ namespace ts { } function parseSpreadElement(): Expression { - let node = createNode(SyntaxKind.SpreadElementExpression); + const node = createNode(SyntaxKind.SpreadElementExpression); parseExpected(SyntaxKind.DotDotDotToken); node.expression = parseAssignmentExpressionOrHigher(); return finishNode(node); @@ -3866,7 +3865,7 @@ namespace ts { } function parseArrayLiteralExpression(): ArrayLiteralExpression { - let node = createNode(SyntaxKind.ArrayLiteralExpression); + const node = createNode(SyntaxKind.ArrayLiteralExpression); parseExpected(SyntaxKind.OpenBracketToken); if (scanner.hasPrecedingLineBreak()) node.flags |= NodeFlags.MultiLine; node.elements = parseDelimitedList(ParsingContext.ArrayLiteralMembers, parseArgumentOrArrayLiteralElement); @@ -3886,22 +3885,22 @@ namespace ts { } function parseObjectLiteralElement(): ObjectLiteralElement { - let fullStart = scanner.getStartPos(); - let decorators = parseDecorators(); - let modifiers = parseModifiers(); + const fullStart = scanner.getStartPos(); + const decorators = parseDecorators(); + const modifiers = parseModifiers(); - let accessor = tryParseAccessorDeclaration(fullStart, decorators, modifiers); + const accessor = tryParseAccessorDeclaration(fullStart, decorators, modifiers); if (accessor) { return accessor; } - let asteriskToken = parseOptionalToken(SyntaxKind.AsteriskToken); - let tokenIsIdentifier = isIdentifier(); - let nameToken = token; - let propertyName = parsePropertyName(); + const asteriskToken = parseOptionalToken(SyntaxKind.AsteriskToken); + const tokenIsIdentifier = isIdentifier(); + const nameToken = token; + const propertyName = parsePropertyName(); // Disallowing of optional property assignments happens in the grammar checker. - let questionToken = parseOptionalToken(SyntaxKind.QuestionToken); + const questionToken = parseOptionalToken(SyntaxKind.QuestionToken); if (asteriskToken || token === SyntaxKind.OpenParenToken || token === SyntaxKind.LessThanToken) { return parseMethodDeclaration(fullStart, decorators, modifiers, asteriskToken, propertyName, questionToken); } @@ -3915,7 +3914,7 @@ namespace ts { tokenIsIdentifier && (token === SyntaxKind.CommaToken || token === SyntaxKind.CloseBraceToken || token === SyntaxKind.EqualsToken); if (isShorthandPropertyAssignment) { - let shorthandDeclaration = createNode(SyntaxKind.ShorthandPropertyAssignment, fullStart); + const shorthandDeclaration = createNode(SyntaxKind.ShorthandPropertyAssignment, fullStart); shorthandDeclaration.name = propertyName; shorthandDeclaration.questionToken = questionToken; const equalsToken = parseOptionalToken(SyntaxKind.EqualsToken); @@ -3926,7 +3925,7 @@ namespace ts { return finishNode(shorthandDeclaration); } else { - let propertyAssignment = createNode(SyntaxKind.PropertyAssignment, fullStart); + const propertyAssignment = createNode(SyntaxKind.PropertyAssignment, fullStart); propertyAssignment.name = propertyName; propertyAssignment.questionToken = questionToken; parseExpected(SyntaxKind.ColonToken); @@ -3936,7 +3935,7 @@ namespace ts { } function parseObjectLiteralExpression(): ObjectLiteralExpression { - let node = createNode(SyntaxKind.ObjectLiteralExpression); + const node = createNode(SyntaxKind.ObjectLiteralExpression); parseExpected(SyntaxKind.OpenBraceToken); if (scanner.hasPrecedingLineBreak()) { node.flags |= NodeFlags.MultiLine; @@ -3953,18 +3952,18 @@ namespace ts { // // FunctionExpression: // function BindingIdentifier[opt](FormalParameters){ FunctionBody } - let saveDecoratorContext = inDecoratorContext(); + const saveDecoratorContext = inDecoratorContext(); if (saveDecoratorContext) { setDecoratorContext(false); } - let node = createNode(SyntaxKind.FunctionExpression); + const node = createNode(SyntaxKind.FunctionExpression); setModifiers(node, parseModifiers()); parseExpected(SyntaxKind.FunctionKeyword); node.asteriskToken = parseOptionalToken(SyntaxKind.AsteriskToken); - let isGenerator = !!node.asteriskToken; - let isAsync = !!(node.flags & NodeFlags.Async); + const isGenerator = !!node.asteriskToken; + const isAsync = !!(node.flags & NodeFlags.Async); node.name = isGenerator && isAsync ? doInYieldAndAwaitContext(parseOptionalIdentifier) : isGenerator ? doInYieldContext(parseOptionalIdentifier) : @@ -3986,7 +3985,7 @@ namespace ts { } function parseNewExpression(): NewExpression { - let node = createNode(SyntaxKind.NewExpression); + const node = createNode(SyntaxKind.NewExpression); parseExpected(SyntaxKind.NewKeyword); node.expression = parseMemberExpressionOrHigher(); node.typeArguments = tryParse(parseTypeArgumentsInExpression); @@ -3999,7 +3998,7 @@ namespace ts { // STATEMENTS function parseBlock(ignoreMissingOpenBrace: boolean, diagnosticMessage?: DiagnosticMessage): Block { - let node = createNode(SyntaxKind.Block); + const node = createNode(SyntaxKind.Block); if (parseExpected(SyntaxKind.OpenBraceToken, diagnosticMessage) || ignoreMissingOpenBrace) { node.statements = parseList(ParsingContext.BlockStatements, parseStatement); parseExpected(SyntaxKind.CloseBraceToken); @@ -4011,20 +4010,20 @@ namespace ts { } function parseFunctionBlock(allowYield: boolean, allowAwait: boolean, ignoreMissingOpenBrace: boolean, diagnosticMessage?: DiagnosticMessage): Block { - let savedYieldContext = inYieldContext(); + const savedYieldContext = inYieldContext(); setYieldContext(allowYield); - let savedAwaitContext = inAwaitContext(); + const savedAwaitContext = inAwaitContext(); setAwaitContext(allowAwait); // We may be in a [Decorator] context when parsing a function expression or // arrow function. The body of the function is not in [Decorator] context. - let saveDecoratorContext = inDecoratorContext(); + const saveDecoratorContext = inDecoratorContext(); if (saveDecoratorContext) { setDecoratorContext(false); } - let block = parseBlock(ignoreMissingOpenBrace, diagnosticMessage); + const block = parseBlock(ignoreMissingOpenBrace, diagnosticMessage); if (saveDecoratorContext) { setDecoratorContext(true); @@ -4037,13 +4036,13 @@ namespace ts { } function parseEmptyStatement(): Statement { - let node = createNode(SyntaxKind.EmptyStatement); + const node = createNode(SyntaxKind.EmptyStatement); parseExpected(SyntaxKind.SemicolonToken); return finishNode(node); } function parseIfStatement(): IfStatement { - let node = createNode(SyntaxKind.IfStatement); + const node = createNode(SyntaxKind.IfStatement); parseExpected(SyntaxKind.IfKeyword); parseExpected(SyntaxKind.OpenParenToken); node.expression = allowInAnd(parseExpression); @@ -4054,7 +4053,7 @@ namespace ts { } function parseDoStatement(): DoStatement { - let node = createNode(SyntaxKind.DoStatement); + const node = createNode(SyntaxKind.DoStatement); parseExpected(SyntaxKind.DoKeyword); node.statement = parseStatement(); parseExpected(SyntaxKind.WhileKeyword); @@ -4071,7 +4070,7 @@ namespace ts { } function parseWhileStatement(): WhileStatement { - let node = createNode(SyntaxKind.WhileStatement); + const node = createNode(SyntaxKind.WhileStatement); parseExpected(SyntaxKind.WhileKeyword); parseExpected(SyntaxKind.OpenParenToken); node.expression = allowInAnd(parseExpression); @@ -4081,7 +4080,7 @@ namespace ts { } function parseForOrForInOrForOfStatement(): Statement { - let pos = getNodePos(); + const pos = getNodePos(); parseExpected(SyntaxKind.ForKeyword); parseExpected(SyntaxKind.OpenParenToken); @@ -4096,21 +4095,21 @@ namespace ts { } let forOrForInOrForOfStatement: IterationStatement; if (parseOptional(SyntaxKind.InKeyword)) { - let forInStatement = createNode(SyntaxKind.ForInStatement, pos); + const forInStatement = createNode(SyntaxKind.ForInStatement, pos); forInStatement.initializer = initializer; forInStatement.expression = allowInAnd(parseExpression); parseExpected(SyntaxKind.CloseParenToken); forOrForInOrForOfStatement = forInStatement; } else if (parseOptional(SyntaxKind.OfKeyword)) { - let forOfStatement = createNode(SyntaxKind.ForOfStatement, pos); + const forOfStatement = createNode(SyntaxKind.ForOfStatement, pos); forOfStatement.initializer = initializer; forOfStatement.expression = allowInAnd(parseAssignmentExpressionOrHigher); parseExpected(SyntaxKind.CloseParenToken); forOrForInOrForOfStatement = forOfStatement; } else { - let forStatement = createNode(SyntaxKind.ForStatement, pos); + const forStatement = createNode(SyntaxKind.ForStatement, pos); forStatement.initializer = initializer; parseExpected(SyntaxKind.SemicolonToken); if (token !== SyntaxKind.SemicolonToken && token !== SyntaxKind.CloseParenToken) { @@ -4130,7 +4129,7 @@ namespace ts { } function parseBreakOrContinueStatement(kind: SyntaxKind): BreakOrContinueStatement { - let node = createNode(kind); + const node = createNode(kind); parseExpected(kind === SyntaxKind.BreakStatement ? SyntaxKind.BreakKeyword : SyntaxKind.ContinueKeyword); if (!canParseSemicolon()) { @@ -4142,7 +4141,7 @@ namespace ts { } function parseReturnStatement(): ReturnStatement { - let node = createNode(SyntaxKind.ReturnStatement); + const node = createNode(SyntaxKind.ReturnStatement); parseExpected(SyntaxKind.ReturnKeyword); if (!canParseSemicolon()) { @@ -4154,7 +4153,7 @@ namespace ts { } function parseWithStatement(): WithStatement { - let node = createNode(SyntaxKind.WithStatement); + const node = createNode(SyntaxKind.WithStatement); parseExpected(SyntaxKind.WithKeyword); parseExpected(SyntaxKind.OpenParenToken); node.expression = allowInAnd(parseExpression); @@ -4164,7 +4163,7 @@ namespace ts { } function parseCaseClause(): CaseClause { - let node = createNode(SyntaxKind.CaseClause); + const node = createNode(SyntaxKind.CaseClause); parseExpected(SyntaxKind.CaseKeyword); node.expression = allowInAnd(parseExpression); parseExpected(SyntaxKind.ColonToken); @@ -4173,7 +4172,7 @@ namespace ts { } function parseDefaultClause(): DefaultClause { - let node = createNode(SyntaxKind.DefaultClause); + const node = createNode(SyntaxKind.DefaultClause); parseExpected(SyntaxKind.DefaultKeyword); parseExpected(SyntaxKind.ColonToken); node.statements = parseList(ParsingContext.SwitchClauseStatements, parseStatement); @@ -4185,12 +4184,12 @@ namespace ts { } function parseSwitchStatement(): SwitchStatement { - let node = createNode(SyntaxKind.SwitchStatement); + const node = createNode(SyntaxKind.SwitchStatement); parseExpected(SyntaxKind.SwitchKeyword); parseExpected(SyntaxKind.OpenParenToken); node.expression = allowInAnd(parseExpression); parseExpected(SyntaxKind.CloseParenToken); - let caseBlock = createNode(SyntaxKind.CaseBlock, scanner.getStartPos()); + const caseBlock = createNode(SyntaxKind.CaseBlock, scanner.getStartPos()); parseExpected(SyntaxKind.OpenBraceToken); caseBlock.clauses = parseList(ParsingContext.SwitchClauses, parseCaseOrDefaultClause); parseExpected(SyntaxKind.CloseBraceToken); @@ -4207,7 +4206,7 @@ namespace 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. - let node = createNode(SyntaxKind.ThrowStatement); + const node = createNode(SyntaxKind.ThrowStatement); parseExpected(SyntaxKind.ThrowKeyword); node.expression = scanner.hasPrecedingLineBreak() ? undefined : allowInAnd(parseExpression); parseSemicolon(); @@ -4216,7 +4215,7 @@ namespace ts { // TODO: Review for error recovery function parseTryStatement(): TryStatement { - let node = createNode(SyntaxKind.TryStatement); + const node = createNode(SyntaxKind.TryStatement); parseExpected(SyntaxKind.TryKeyword); node.tryBlock = parseBlock(/*ignoreMissingOpenBrace*/ false); @@ -4233,7 +4232,7 @@ namespace ts { } function parseCatchClause(): CatchClause { - let result = createNode(SyntaxKind.CatchClause); + const result = createNode(SyntaxKind.CatchClause); parseExpected(SyntaxKind.CatchKeyword); if (parseExpected(SyntaxKind.OpenParenToken)) { result.variableDeclaration = parseVariableDeclaration(); @@ -4245,7 +4244,7 @@ namespace ts { } function parseDebuggerStatement(): Statement { - let node = createNode(SyntaxKind.DebuggerStatement); + const node = createNode(SyntaxKind.DebuggerStatement); parseExpected(SyntaxKind.DebuggerKeyword); parseSemicolon(); return finishNode(node); @@ -4255,17 +4254,17 @@ namespace ts { // Avoiding having to do the lookahead for a labeled statement by just trying to parse // out an expression, seeing if it is identifier and then seeing if it is followed by // a colon. - let fullStart = scanner.getStartPos(); - let expression = allowInAnd(parseExpression); + const fullStart = scanner.getStartPos(); + const expression = allowInAnd(parseExpression); if (expression.kind === SyntaxKind.Identifier && parseOptional(SyntaxKind.ColonToken)) { - let labeledStatement = createNode(SyntaxKind.LabeledStatement, fullStart); + const labeledStatement = createNode(SyntaxKind.LabeledStatement, fullStart); labeledStatement.label = expression; labeledStatement.statement = parseStatement(); return finishNode(labeledStatement); } else { - let expressionStatement = createNode(SyntaxKind.ExpressionStatement, fullStart); + const expressionStatement = createNode(SyntaxKind.ExpressionStatement, fullStart); expressionStatement.expression = expression; parseSemicolon(); return finishNode(expressionStatement); @@ -4499,9 +4498,9 @@ namespace ts { } function parseDeclaration(): Statement { - let fullStart = getNodePos(); - let decorators = parseDecorators(); - let modifiers = parseModifiers(); + const fullStart = getNodePos(); + const decorators = parseDecorators(); + const modifiers = parseModifiers(); switch (token) { case SyntaxKind.VarKeyword: case SyntaxKind.LetKeyword: @@ -4531,7 +4530,7 @@ namespace 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. - let node = createMissingNode(SyntaxKind.MissingDeclaration, /*reportAtCurrentPosition*/ true, Diagnostics.Declaration_expected); + const node = createMissingNode(SyntaxKind.MissingDeclaration, /*reportAtCurrentPosition*/ true, Diagnostics.Declaration_expected); node.pos = fullStart; node.decorators = decorators; setModifiers(node, modifiers); @@ -4560,7 +4559,7 @@ namespace ts { if (token === SyntaxKind.CommaToken) { return createNode(SyntaxKind.OmittedExpression); } - let node = createNode(SyntaxKind.BindingElement); + const node = createNode(SyntaxKind.BindingElement); node.dotDotDotToken = parseOptionalToken(SyntaxKind.DotDotDotToken); node.name = parseIdentifierOrPattern(); node.initializer = parseBindingElementInitializer(/*inParameter*/ false); @@ -4568,10 +4567,10 @@ namespace ts { } function parseObjectBindingElement(): BindingElement { - let node = createNode(SyntaxKind.BindingElement); + const node = createNode(SyntaxKind.BindingElement); // TODO(andersh): Handle computed properties - let tokenIsIdentifier = isIdentifier(); - let propertyName = parsePropertyName(); + const tokenIsIdentifier = isIdentifier(); + const propertyName = parsePropertyName(); if (tokenIsIdentifier && token !== SyntaxKind.ColonToken) { node.name = propertyName; } @@ -4585,7 +4584,7 @@ namespace ts { } function parseObjectBindingPattern(): BindingPattern { - let node = createNode(SyntaxKind.ObjectBindingPattern); + const node = createNode(SyntaxKind.ObjectBindingPattern); parseExpected(SyntaxKind.OpenBraceToken); node.elements = parseDelimitedList(ParsingContext.ObjectBindingElements, parseObjectBindingElement); parseExpected(SyntaxKind.CloseBraceToken); @@ -4593,7 +4592,7 @@ namespace ts { } function parseArrayBindingPattern(): BindingPattern { - let node = createNode(SyntaxKind.ArrayBindingPattern); + const node = createNode(SyntaxKind.ArrayBindingPattern); parseExpected(SyntaxKind.OpenBracketToken); node.elements = parseDelimitedList(ParsingContext.ArrayBindingElements, parseArrayBindingElement); parseExpected(SyntaxKind.CloseBracketToken); @@ -4615,7 +4614,7 @@ namespace ts { } function parseVariableDeclaration(): VariableDeclaration { - let node = createNode(SyntaxKind.VariableDeclaration); + const node = createNode(SyntaxKind.VariableDeclaration); node.name = parseIdentifierOrPattern(); node.type = parseTypeAnnotation(); if (!isInOrOfKeyword(token)) { @@ -4625,7 +4624,7 @@ namespace ts { } function parseVariableDeclarationList(inForStatementInitializer: boolean): VariableDeclarationList { - let node = createNode(SyntaxKind.VariableDeclarationList); + const node = createNode(SyntaxKind.VariableDeclarationList); switch (token) { case SyntaxKind.VarKeyword: @@ -4655,7 +4654,7 @@ namespace ts { node.declarations = createMissingList(); } else { - let savedDisallowIn = inDisallowInContext(); + const savedDisallowIn = inDisallowInContext(); setDisallowInContext(inForStatementInitializer); node.declarations = parseDelimitedList(ParsingContext.VariableDeclarations, parseVariableDeclaration); @@ -4671,7 +4670,7 @@ namespace ts { } function parseVariableStatement(fullStart: number, decorators: NodeArray, modifiers: ModifiersArray): VariableStatement { - let node = createNode(SyntaxKind.VariableStatement, fullStart); + const node = createNode(SyntaxKind.VariableStatement, fullStart); node.decorators = decorators; setModifiers(node, modifiers); node.declarationList = parseVariableDeclarationList(/*inForStatementInitializer*/ false); @@ -4680,21 +4679,21 @@ namespace ts { } function parseFunctionDeclaration(fullStart: number, decorators: NodeArray, modifiers: ModifiersArray): FunctionDeclaration { - let node = createNode(SyntaxKind.FunctionDeclaration, fullStart); + const node = createNode(SyntaxKind.FunctionDeclaration, fullStart); node.decorators = decorators; setModifiers(node, modifiers); parseExpected(SyntaxKind.FunctionKeyword); node.asteriskToken = parseOptionalToken(SyntaxKind.AsteriskToken); node.name = node.flags & NodeFlags.Default ? parseOptionalIdentifier() : parseIdentifier(); - let isGenerator = !!node.asteriskToken; - let isAsync = !!(node.flags & NodeFlags.Async); + const isGenerator = !!node.asteriskToken; + const isAsync = !!(node.flags & NodeFlags.Async); fillSignature(SyntaxKind.ColonToken, /*yieldContext*/ isGenerator, /*awaitContext*/ isAsync, /*requireCompleteParameterList*/ false, node); node.body = parseFunctionBlockOrSemicolon(isGenerator, isAsync, Diagnostics.or_expected); return finishNode(node); } function parseConstructorDeclaration(pos: number, decorators: NodeArray, modifiers: ModifiersArray): ConstructorDeclaration { - let node = createNode(SyntaxKind.Constructor, pos); + const node = createNode(SyntaxKind.Constructor, pos); node.decorators = decorators; setModifiers(node, modifiers); parseExpected(SyntaxKind.ConstructorKeyword); @@ -4704,21 +4703,21 @@ namespace ts { } function parseMethodDeclaration(fullStart: number, decorators: NodeArray, modifiers: ModifiersArray, asteriskToken: Node, name: DeclarationName, questionToken: Node, diagnosticMessage?: DiagnosticMessage): MethodDeclaration { - let method = createNode(SyntaxKind.MethodDeclaration, fullStart); + const method = createNode(SyntaxKind.MethodDeclaration, fullStart); method.decorators = decorators; setModifiers(method, modifiers); method.asteriskToken = asteriskToken; method.name = name; method.questionToken = questionToken; - let isGenerator = !!asteriskToken; - let isAsync = !!(method.flags & NodeFlags.Async); + const isGenerator = !!asteriskToken; + const isAsync = !!(method.flags & NodeFlags.Async); fillSignature(SyntaxKind.ColonToken, /*yieldContext*/ isGenerator, /*awaitContext*/ isAsync, /*requireCompleteParameterList*/ false, method); method.body = parseFunctionBlockOrSemicolon(isGenerator, isAsync, diagnosticMessage); return finishNode(method); } function parsePropertyDeclaration(fullStart: number, decorators: NodeArray, modifiers: ModifiersArray, name: DeclarationName, questionToken: Node): ClassElement { - let property = createNode(SyntaxKind.PropertyDeclaration, fullStart); + const property = createNode(SyntaxKind.PropertyDeclaration, fullStart); property.decorators = decorators; setModifiers(property, modifiers); property.name = name; @@ -4743,12 +4742,12 @@ namespace ts { } function parsePropertyOrMethodDeclaration(fullStart: number, decorators: NodeArray, modifiers: ModifiersArray): ClassElement { - let asteriskToken = parseOptionalToken(SyntaxKind.AsteriskToken); - let name = parsePropertyName(); + const asteriskToken = parseOptionalToken(SyntaxKind.AsteriskToken); + const 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. - let questionToken = parseOptionalToken(SyntaxKind.QuestionToken); + const questionToken = parseOptionalToken(SyntaxKind.QuestionToken); if (asteriskToken || token === SyntaxKind.OpenParenToken || token === SyntaxKind.LessThanToken) { return parseMethodDeclaration(fullStart, decorators, modifiers, asteriskToken, name, questionToken, Diagnostics.or_expected); } @@ -4762,7 +4761,7 @@ namespace ts { } function parseAccessorDeclaration(kind: SyntaxKind, fullStart: number, decorators: NodeArray, modifiers: ModifiersArray): AccessorDeclaration { - let node = createNode(kind, fullStart); + const node = createNode(kind, fullStart); node.decorators = decorators; setModifiers(node, modifiers); node.name = parsePropertyName(); @@ -4854,7 +4853,7 @@ namespace ts { function parseDecorators(): NodeArray { let decorators: NodeArray; while (true) { - let decoratorStart = getNodePos(); + const decoratorStart = getNodePos(); if (!parseOptional(SyntaxKind.AtToken)) { break; } @@ -4864,7 +4863,7 @@ namespace ts { decorators.pos = scanner.getStartPos(); } - let decorator = createNode(SyntaxKind.Decorator, decoratorStart); + const decorator = createNode(SyntaxKind.Decorator, decoratorStart); decorator.expression = doInDecoratorContext(parseLeftHandSideExpressionOrHigher); decorators.push(finishNode(decorator)); } @@ -4878,8 +4877,8 @@ namespace ts { let flags = 0; let modifiers: ModifiersArray; while (true) { - let modifierStart = scanner.getStartPos(); - let modifierKind = token; + const modifierStart = scanner.getStartPos(); + const modifierKind = token; if (!parseAnyContextualModifier()) { break; @@ -4904,8 +4903,8 @@ namespace ts { let flags = 0; let modifiers: ModifiersArray; if (token === SyntaxKind.AsyncKeyword) { - let modifierStart = scanner.getStartPos(); - let modifierKind = token; + const modifierStart = scanner.getStartPos(); + const modifierKind = token; nextToken(); modifiers = []; modifiers.pos = modifierStart; @@ -4920,16 +4919,16 @@ namespace ts { function parseClassElement(): ClassElement { if (token === SyntaxKind.SemicolonToken) { - let result = createNode(SyntaxKind.SemicolonClassElement); + const result = createNode(SyntaxKind.SemicolonClassElement); nextToken(); return finishNode(result); } - let fullStart = getNodePos(); - let decorators = parseDecorators(); - let modifiers = parseModifiers(); + const fullStart = getNodePos(); + const decorators = parseDecorators(); + const modifiers = parseModifiers(); - let accessor = tryParseAccessorDeclaration(fullStart, decorators, modifiers); + const accessor = tryParseAccessorDeclaration(fullStart, decorators, modifiers); if (accessor) { return accessor; } @@ -4955,7 +4954,7 @@ namespace ts { if (decorators || modifiers) { // treat this as a property declaration with a missing name. - let name = createMissingNode(SyntaxKind.Identifier, /*reportAtCurrentPosition*/ true, Diagnostics.Declaration_expected); + const name = createMissingNode(SyntaxKind.Identifier, /*reportAtCurrentPosition*/ true, Diagnostics.Declaration_expected); return parsePropertyDeclaration(fullStart, decorators, modifiers, name, /*questionToken*/ undefined); } @@ -4976,7 +4975,7 @@ namespace ts { } function parseClassDeclarationOrExpression(fullStart: number, decorators: NodeArray, modifiers: ModifiersArray, kind: SyntaxKind): ClassLikeDeclaration { - let node = createNode(kind, fullStart); + const node = createNode(kind, fullStart); node.decorators = decorators; setModifiers(node, modifiers); parseExpected(SyntaxKind.ClassKeyword); @@ -5029,7 +5028,7 @@ namespace ts { function parseHeritageClause() { if (token === SyntaxKind.ExtendsKeyword || token === SyntaxKind.ImplementsKeyword) { - let node = createNode(SyntaxKind.HeritageClause); + const node = createNode(SyntaxKind.HeritageClause); node.token = token; nextToken(); node.types = parseDelimitedList(ParsingContext.HeritageClauseElement, parseExpressionWithTypeArguments); @@ -5040,7 +5039,7 @@ namespace ts { } function parseExpressionWithTypeArguments(): ExpressionWithTypeArguments { - let node = createNode(SyntaxKind.ExpressionWithTypeArguments); + const node = createNode(SyntaxKind.ExpressionWithTypeArguments); node.expression = parseLeftHandSideExpressionOrHigher(); if (token === SyntaxKind.LessThanToken) { node.typeArguments = parseBracketedList(ParsingContext.TypeArguments, parseType, SyntaxKind.LessThanToken, SyntaxKind.GreaterThanToken); @@ -5058,7 +5057,7 @@ namespace ts { } function parseInterfaceDeclaration(fullStart: number, decorators: NodeArray, modifiers: ModifiersArray): InterfaceDeclaration { - let node = createNode(SyntaxKind.InterfaceDeclaration, fullStart); + const node = createNode(SyntaxKind.InterfaceDeclaration, fullStart); node.decorators = decorators; setModifiers(node, modifiers); parseExpected(SyntaxKind.InterfaceKeyword); @@ -5070,7 +5069,7 @@ namespace ts { } function parseTypeAliasDeclaration(fullStart: number, decorators: NodeArray, modifiers: ModifiersArray): TypeAliasDeclaration { - let node = createNode(SyntaxKind.TypeAliasDeclaration, fullStart); + const node = createNode(SyntaxKind.TypeAliasDeclaration, fullStart); node.decorators = decorators; setModifiers(node, modifiers); parseExpected(SyntaxKind.TypeKeyword); @@ -5087,14 +5086,14 @@ namespace ts { // ConstantEnumMemberSection, which starts at the beginning of an enum declaration // or any time an integer literal initializer is encountered. function parseEnumMember(): EnumMember { - let node = createNode(SyntaxKind.EnumMember, scanner.getStartPos()); + const node = createNode(SyntaxKind.EnumMember, scanner.getStartPos()); node.name = parsePropertyName(); node.initializer = allowInAnd(parseNonParameterInitializer); return finishNode(node); } function parseEnumDeclaration(fullStart: number, decorators: NodeArray, modifiers: ModifiersArray): EnumDeclaration { - let node = createNode(SyntaxKind.EnumDeclaration, fullStart); + const node = createNode(SyntaxKind.EnumDeclaration, fullStart); node.decorators = decorators; setModifiers(node, modifiers); parseExpected(SyntaxKind.EnumKeyword); @@ -5110,7 +5109,7 @@ namespace ts { } function parseModuleBlock(): ModuleBlock { - let node = createNode(SyntaxKind.ModuleBlock, scanner.getStartPos()); + const node = createNode(SyntaxKind.ModuleBlock, scanner.getStartPos()); if (parseExpected(SyntaxKind.OpenBraceToken)) { node.statements = parseList(ParsingContext.BlockStatements, parseStatement); parseExpected(SyntaxKind.CloseBraceToken); @@ -5122,10 +5121,10 @@ namespace ts { } function parseModuleOrNamespaceDeclaration(fullStart: number, decorators: NodeArray, modifiers: ModifiersArray, flags: NodeFlags): ModuleDeclaration { - let node = createNode(SyntaxKind.ModuleDeclaration, fullStart); + const node = createNode(SyntaxKind.ModuleDeclaration, fullStart); // If we are parsing a dotted namespace name, we want to // propagate the 'Namespace' flag across the names if set. - let namespaceFlag = flags & NodeFlags.Namespace; + const namespaceFlag = flags & NodeFlags.Namespace; node.decorators = decorators; setModifiers(node, modifiers); node.flags |= flags; @@ -5137,7 +5136,7 @@ namespace ts { } function parseAmbientExternalModuleDeclaration(fullStart: number, decorators: NodeArray, modifiers: ModifiersArray): ModuleDeclaration { - let node = createNode(SyntaxKind.ModuleDeclaration, fullStart); + const node = createNode(SyntaxKind.ModuleDeclaration, fullStart); node.decorators = decorators; setModifiers(node, modifiers); node.name = parseLiteralNode(/*internName*/ true); @@ -5180,7 +5179,7 @@ namespace ts { function parseImportDeclarationOrImportEqualsDeclaration(fullStart: number, decorators: NodeArray, modifiers: ModifiersArray): ImportEqualsDeclaration | ImportDeclaration { parseExpected(SyntaxKind.ImportKeyword); - let afterImportPos = scanner.getStartPos(); + const afterImportPos = scanner.getStartPos(); let identifier: Identifier; if (isIdentifier()) { @@ -5189,7 +5188,7 @@ namespace ts { // ImportEquals declaration of type: // import x = require("mod"); or // import x = M.x; - let importEqualsDeclaration = createNode(SyntaxKind.ImportEqualsDeclaration, fullStart); + const importEqualsDeclaration = createNode(SyntaxKind.ImportEqualsDeclaration, fullStart); importEqualsDeclaration.decorators = decorators; setModifiers(importEqualsDeclaration, modifiers); importEqualsDeclaration.name = identifier; @@ -5201,7 +5200,7 @@ namespace ts { } // Import statement - let importDeclaration = createNode(SyntaxKind.ImportDeclaration, fullStart); + const importDeclaration = createNode(SyntaxKind.ImportDeclaration, fullStart); importDeclaration.decorators = decorators; setModifiers(importDeclaration, modifiers); @@ -5228,7 +5227,7 @@ namespace ts { // ImportedDefaultBinding, NameSpaceImport // ImportedDefaultBinding, NamedImports - let importClause = createNode(SyntaxKind.ImportClause, fullStart); + const importClause = createNode(SyntaxKind.ImportClause, fullStart); if (identifier) { // ImportedDefaultBinding: // ImportedBinding @@ -5252,7 +5251,7 @@ namespace ts { } function parseExternalModuleReference() { - let node = createNode(SyntaxKind.ExternalModuleReference); + const node = createNode(SyntaxKind.ExternalModuleReference); parseExpected(SyntaxKind.RequireKeyword); parseExpected(SyntaxKind.OpenParenToken); node.expression = parseModuleSpecifier(); @@ -5264,7 +5263,7 @@ namespace ts { // We allow arbitrary expressions here, even though the grammar only allows string // literals. We check to ensure that it is only a string literal later in the grammar // walker. - let result = parseExpression(); + const result = parseExpression(); // Ensure the string being required is in our 'identifier' table. This will ensure // that features like 'find refs' will look inside this file when search for its name. if (result.kind === SyntaxKind.StringLiteral) { @@ -5276,7 +5275,7 @@ namespace ts { function parseNamespaceImport(): NamespaceImport { // NameSpaceImport: // * as ImportedBinding - let namespaceImport = createNode(SyntaxKind.NamespaceImport); + const namespaceImport = createNode(SyntaxKind.NamespaceImport); parseExpected(SyntaxKind.AsteriskToken); parseExpected(SyntaxKind.AsKeyword); namespaceImport.name = parseIdentifier(); @@ -5284,7 +5283,7 @@ namespace ts { } function parseNamedImportsOrExports(kind: SyntaxKind): NamedImportsOrExports { - let node = createNode(kind); + const node = createNode(kind); // NamedImports: // { } @@ -5309,7 +5308,7 @@ namespace ts { } function parseImportOrExportSpecifier(kind: SyntaxKind): ImportOrExportSpecifier { - let node = createNode(kind); + const node = createNode(kind); // ImportSpecifier: // BindingIdentifier // IdentifierName as BindingIdentifier @@ -5319,7 +5318,7 @@ namespace ts { let checkIdentifierIsKeyword = isKeyword(token) && !isIdentifier(); let checkIdentifierStart = scanner.getTokenPos(); let checkIdentifierEnd = scanner.getTextPos(); - let identifierName = parseIdentifierName(); + const identifierName = parseIdentifierName(); if (token === SyntaxKind.AsKeyword) { node.propertyName = identifierName; parseExpected(SyntaxKind.AsKeyword); @@ -5339,7 +5338,7 @@ namespace ts { } function parseExportDeclaration(fullStart: number, decorators: NodeArray, modifiers: ModifiersArray): ExportDeclaration { - let node = createNode(SyntaxKind.ExportDeclaration, fullStart); + const node = createNode(SyntaxKind.ExportDeclaration, fullStart); node.decorators = decorators; setModifiers(node, modifiers); if (parseOptional(SyntaxKind.AsteriskToken)) { @@ -5362,7 +5361,7 @@ namespace ts { } function parseExportAssignment(fullStart: number, decorators: NodeArray, modifiers: ModifiersArray): ExportAssignment { - let node = createNode(SyntaxKind.ExportAssignment, fullStart); + const node = createNode(SyntaxKind.ExportAssignment, fullStart); node.decorators = decorators; setModifiers(node, modifiers); if (parseOptional(SyntaxKind.EqualsToken)) { @@ -5377,16 +5376,16 @@ namespace ts { } function processReferenceComments(sourceFile: SourceFile): void { - let triviaScanner = createScanner(sourceFile.languageVersion, /*skipTrivia*/false, LanguageVariant.Standard, sourceText); - let referencedFiles: FileReference[] = []; - let amdDependencies: { path: string; name: string }[] = []; + const triviaScanner = createScanner(sourceFile.languageVersion, /*skipTrivia*/false, LanguageVariant.Standard, sourceText); + const referencedFiles: FileReference[] = []; + const amdDependencies: { path: string; name: string }[] = []; let amdModuleName: string; // Keep scanning all the leading trivia in the file until we get to something that // isn't trivia. Any single line comment will be analyzed to see if it is a // reference comment. while (true) { - let kind = triviaScanner.scan(); + const kind = triviaScanner.scan(); if (kind === SyntaxKind.WhitespaceTrivia || kind === SyntaxKind.NewLineTrivia || kind === SyntaxKind.MultiLineCommentTrivia) { continue; } @@ -5394,14 +5393,14 @@ namespace ts { break; } - let range = { pos: triviaScanner.getTokenPos(), end: triviaScanner.getTextPos(), kind: triviaScanner.getToken() }; + const range = { pos: triviaScanner.getTokenPos(), end: triviaScanner.getTextPos(), kind: triviaScanner.getToken() }; - let comment = sourceText.substring(range.pos, range.end); - let referencePathMatchResult = getFileReferenceFromReferencePath(comment, range); + const comment = sourceText.substring(range.pos, range.end); + const referencePathMatchResult = getFileReferenceFromReferencePath(comment, range); if (referencePathMatchResult) { - let fileReference = referencePathMatchResult.fileReference; + const fileReference = referencePathMatchResult.fileReference; sourceFile.hasNoDefaultLib = referencePathMatchResult.isNoDefaultLib; - let diagnosticMessage = referencePathMatchResult.diagnosticMessage; + const diagnosticMessage = referencePathMatchResult.diagnosticMessage; if (fileReference) { referencedFiles.push(fileReference); } @@ -5410,8 +5409,8 @@ namespace ts { } } else { - let amdModuleNameRegEx = /^\/\/\/\s*createNode(SyntaxKind.JSDocTypeExpression); + const result = createNode(SyntaxKind.JSDocTypeExpression); parseExpected(SyntaxKind.OpenBraceToken); result.type = parseJSDocTopLevelType(); @@ -5536,13 +5535,13 @@ namespace ts { function parseJSDocTopLevelType(): JSDocType { let type = parseJSDocType(); if (token === SyntaxKind.BarToken) { - let unionType = createNode(SyntaxKind.JSDocUnionType, type.pos); + const unionType = createNode(SyntaxKind.JSDocUnionType, type.pos); unionType.types = parseJSDocTypeList(type); type = finishNode(unionType); } if (token === SyntaxKind.EqualsToken) { - let optionalType = createNode(SyntaxKind.JSDocOptionalType, type.pos); + const optionalType = createNode(SyntaxKind.JSDocOptionalType, type.pos); nextToken(); optionalType.type = type; type = finishNode(optionalType); @@ -5556,7 +5555,7 @@ namespace ts { while (true) { if (token === SyntaxKind.OpenBracketToken) { - let arrayType = createNode(SyntaxKind.JSDocArrayType, type.pos); + const arrayType = createNode(SyntaxKind.JSDocArrayType, type.pos); arrayType.elementType = type; nextToken(); @@ -5565,14 +5564,14 @@ namespace ts { type = finishNode(arrayType); } else if (token === SyntaxKind.QuestionToken) { - let nullableType = createNode(SyntaxKind.JSDocNullableType, type.pos); + const nullableType = createNode(SyntaxKind.JSDocNullableType, type.pos); nullableType.type = type; nextToken(); type = finishNode(nullableType); } else if (token === SyntaxKind.ExclamationToken) { - let nonNullableType = createNode(SyntaxKind.JSDocNonNullableType, type.pos); + const nonNullableType = createNode(SyntaxKind.JSDocNonNullableType, type.pos); nonNullableType.type = type; nextToken(); @@ -5621,7 +5620,7 @@ namespace ts { } function parseJSDocThisType(): JSDocThisType { - let result = createNode(SyntaxKind.JSDocThisType); + const result = createNode(SyntaxKind.JSDocThisType); nextToken(); parseExpected(SyntaxKind.ColonToken); result.type = parseJSDocType(); @@ -5629,7 +5628,7 @@ namespace ts { } function parseJSDocConstructorType(): JSDocConstructorType { - let result = createNode(SyntaxKind.JSDocConstructorType); + const result = createNode(SyntaxKind.JSDocConstructorType); nextToken(); parseExpected(SyntaxKind.ColonToken); result.type = parseJSDocType(); @@ -5637,14 +5636,14 @@ namespace ts { } function parseJSDocVariadicType(): JSDocVariadicType { - let result = createNode(SyntaxKind.JSDocVariadicType); + const result = createNode(SyntaxKind.JSDocVariadicType); nextToken(); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocFunctionType(): JSDocFunctionType { - let result = createNode(SyntaxKind.JSDocFunctionType); + const result = createNode(SyntaxKind.JSDocFunctionType); nextToken(); parseExpected(SyntaxKind.OpenParenToken); @@ -5661,20 +5660,20 @@ namespace ts { } function parseJSDocParameter(): ParameterDeclaration { - let parameter = createNode(SyntaxKind.Parameter); + const parameter = createNode(SyntaxKind.Parameter); parameter.type = parseJSDocType(); return finishNode(parameter); } function parseJSDocOptionalType(type: JSDocType): JSDocOptionalType { - let result = createNode(SyntaxKind.JSDocOptionalType, type.pos); + const result = createNode(SyntaxKind.JSDocOptionalType, type.pos); nextToken(); result.type = type; return finishNode(result); } function parseJSDocTypeReference(): JSDocTypeReference { - let result = createNode(SyntaxKind.JSDocTypeReference); + const result = createNode(SyntaxKind.JSDocTypeReference); result.name = parseSimplePropertyName(); while (parseOptional(SyntaxKind.DotToken)) { @@ -5693,7 +5692,7 @@ namespace ts { function parseTypeArguments() { // Move past the < nextToken(); - let typeArguments = parseDelimitedList(ParsingContext.JSDocTypeArguments, parseJSDocType); + const typeArguments = parseDelimitedList(ParsingContext.JSDocTypeArguments, parseJSDocType); checkForTrailingComma(typeArguments); checkForEmptyTypeArgumentList(typeArguments); parseExpected(SyntaxKind.GreaterThanToken); @@ -5703,14 +5702,14 @@ namespace ts { function checkForEmptyTypeArgumentList(typeArguments: NodeArray) { if (parseDiagnostics.length === 0 && typeArguments && typeArguments.length === 0) { - let start = typeArguments.pos - "<".length; - let end = skipTrivia(sourceText, typeArguments.end) + ">".length; + const start = typeArguments.pos - "<".length; + const end = skipTrivia(sourceText, typeArguments.end) + ">".length; return parseErrorAtPosition(start, end - start, Diagnostics.Type_argument_list_cannot_be_empty); } } function parseQualifiedName(left: EntityName): QualifiedName { - let result = createNode(SyntaxKind.QualifiedName, left.pos); + const result = createNode(SyntaxKind.QualifiedName, left.pos); result.left = left; result.right = parseIdentifierName(); @@ -5718,7 +5717,7 @@ namespace ts { } function parseJSDocRecordType(): JSDocRecordType { - let result = createNode(SyntaxKind.JSDocRecordType); + const result = createNode(SyntaxKind.JSDocRecordType); nextToken(); result.members = parseDelimitedList(ParsingContext.JSDocRecordMembers, parseJSDocRecordMember); checkForTrailingComma(result.members); @@ -5727,7 +5726,7 @@ namespace ts { } function parseJSDocRecordMember(): JSDocRecordMember { - let result = createNode(SyntaxKind.JSDocRecordMember); + const result = createNode(SyntaxKind.JSDocRecordMember); result.name = parseSimplePropertyName(); if (token === SyntaxKind.ColonToken) { @@ -5739,14 +5738,14 @@ namespace ts { } function parseJSDocNonNullableType(): JSDocNonNullableType { - let result = createNode(SyntaxKind.JSDocNonNullableType); + const result = createNode(SyntaxKind.JSDocNonNullableType); nextToken(); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocTupleType(): JSDocTupleType { - let result = createNode(SyntaxKind.JSDocTupleType); + const result = createNode(SyntaxKind.JSDocTupleType); nextToken(); result.types = parseDelimitedList(ParsingContext.JSDocTupleTypes, parseJSDocType); checkForTrailingComma(result.types); @@ -5757,13 +5756,13 @@ namespace ts { function checkForTrailingComma(list: NodeArray) { if (parseDiagnostics.length === 0 && list.hasTrailingComma) { - let start = list.end - ",".length; + const start = list.end - ",".length; parseErrorAtPosition(start, ",".length, Diagnostics.Trailing_comma_not_allowed); } } function parseJSDocUnionType(): JSDocUnionType { - let result = createNode(SyntaxKind.JSDocUnionType); + const result = createNode(SyntaxKind.JSDocUnionType); nextToken(); result.types = parseJSDocTypeList(parseJSDocType()); @@ -5775,7 +5774,7 @@ namespace ts { function parseJSDocTypeList(firstType: JSDocType) { Debug.assert(!!firstType); - let types = >[]; + const types = >[]; types.pos = firstType.pos; types.push(firstType); @@ -5788,13 +5787,13 @@ namespace ts { } function parseJSDocAllType(): JSDocAllType { - let result = createNode(SyntaxKind.JSDocAllType); + const result = createNode(SyntaxKind.JSDocAllType); nextToken(); return finishNode(result); } function parseJSDocUnknownOrNullableType(): JSDocUnknownType | JSDocNullableType { - let pos = scanner.getStartPos(); + const pos = scanner.getStartPos(); // skip the ? nextToken(); @@ -5815,11 +5814,11 @@ namespace ts { token === SyntaxKind.EqualsToken || token === SyntaxKind.BarToken) { - let result = createNode(SyntaxKind.JSDocUnknownType, pos); + const result = createNode(SyntaxKind.JSDocUnknownType, pos); return finishNode(result); } else { - let result = createNode(SyntaxKind.JSDocNullableType, pos); + const result = createNode(SyntaxKind.JSDocNullableType, pos); result.type = parseJSDocType(); return finishNode(result); } @@ -5827,15 +5826,15 @@ namespace ts { export function parseIsolatedJSDocComment(content: string, start: number, length: number) { initializeState("file.js", content, ScriptTarget.Latest, /*_syntaxCursor:*/ undefined); - let jsDocComment = parseJSDocComment(/*parent:*/ undefined, start, length); - let diagnostics = parseDiagnostics; + const jsDocComment = parseJSDocComment(/*parent:*/ undefined, start, length); + const diagnostics = parseDiagnostics; clearState(); return jsDocComment ? { jsDocComment, diagnostics } : undefined; } export function parseJSDocComment(parent: Node, start: number, length: number): JSDocComment { - let comment = parseJSDocCommentWorker(start, length); + const comment = parseJSDocCommentWorker(start, length); if (comment) { fixupParentReferences(comment); comment.parent = parent; @@ -5845,9 +5844,9 @@ namespace ts { } export function parseJSDocCommentWorker(start: number, length: number): JSDocComment { - let content = sourceText; + const content = sourceText; start = start || 0; - let end = length === undefined ? content.length : start + length; + const end = length === undefined ? content.length : start + length; length = end - start; Debug.assert(start >= 0); @@ -5874,7 +5873,7 @@ namespace ts { let seenAsterisk = true; for (pos = start + "/**".length; pos < end; ) { - let ch = content.charCodeAt(pos); + const ch = content.charCodeAt(pos); pos++; if (ch === CharacterCodes.at && canParseTag) { @@ -5924,7 +5923,7 @@ namespace ts { return undefined; } - let result = createNode(SyntaxKind.JSDocComment, start); + const result = createNode(SyntaxKind.JSDocComment, start); result.tags = tags; return finishNode(result, end); } @@ -5937,15 +5936,15 @@ namespace ts { function parseTag(): void { Debug.assert(content.charCodeAt(pos - 1) === CharacterCodes.at); - let atToken = createNode(SyntaxKind.AtToken, pos - 1); + const atToken = createNode(SyntaxKind.AtToken, pos - 1); atToken.end = pos; - let tagName = scanIdentifier(); + const tagName = scanIdentifier(); if (!tagName) { return; } - let tag = handleTag(atToken, tagName) || handleUnknownTag(atToken, tagName); + const tag = handleTag(atToken, tagName) || handleUnknownTag(atToken, tagName); addTag(tag); } @@ -5968,7 +5967,7 @@ namespace ts { } function handleUnknownTag(atToken: Node, tagName: Identifier) { - let result = createNode(SyntaxKind.JSDocTag, atToken.pos); + const result = createNode(SyntaxKind.JSDocTag, atToken.pos); result.atToken = atToken; result.tagName = tagName; return finishNode(result, pos); @@ -5993,7 +5992,7 @@ namespace ts { return undefined; } - let typeExpression = parseJSDocTypeExpression(pos, end - pos); + const typeExpression = parseJSDocTypeExpression(pos, end - pos); pos = typeExpression.end; return typeExpression; } @@ -6030,7 +6029,7 @@ namespace ts { typeExpression = tryParseTypeExpression(); } - let result = createNode(SyntaxKind.JSDocParameterTag, atToken.pos); + const result = createNode(SyntaxKind.JSDocParameterTag, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.preParameterName = preName; @@ -6045,7 +6044,7 @@ namespace ts { parseErrorAtPosition(tagName.pos, pos - tagName.pos, Diagnostics._0_tag_already_specified, tagName.text); } - let result = createNode(SyntaxKind.JSDocReturnTag, atToken.pos); + const result = createNode(SyntaxKind.JSDocReturnTag, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeExpression = tryParseTypeExpression(); @@ -6057,7 +6056,7 @@ namespace ts { parseErrorAtPosition(tagName.pos, pos - tagName.pos, Diagnostics._0_tag_already_specified, tagName.text); } - let result = createNode(SyntaxKind.JSDocTypeTag, atToken.pos); + const result = createNode(SyntaxKind.JSDocTypeTag, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeExpression = tryParseTypeExpression(); @@ -6069,20 +6068,20 @@ namespace ts { parseErrorAtPosition(tagName.pos, pos - tagName.pos, Diagnostics._0_tag_already_specified, tagName.text); } - let typeParameters = >[]; + const typeParameters = >[]; typeParameters.pos = pos; while (true) { skipWhitespace(); - let startPos = pos; - let name = scanIdentifier(); + const startPos = pos; + const name = scanIdentifier(); if (!name) { parseErrorAtPosition(startPos, 0, Diagnostics.Identifier_expected); return undefined; } - let typeParameter = createNode(SyntaxKind.TypeParameter, name.pos); + const typeParameter = createNode(SyntaxKind.TypeParameter, name.pos); typeParameter.name = name; finishNode(typeParameter, pos); @@ -6098,7 +6097,7 @@ namespace ts { typeParameters.end = pos; - let result = createNode(SyntaxKind.JSDocTemplateTag, atToken.pos); + const result = createNode(SyntaxKind.JSDocTemplateTag, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeParameters = typeParameters; @@ -6106,9 +6105,9 @@ namespace ts { } function scanIdentifier(): Identifier { - let startPos = pos; + const startPos = pos; for (; pos < end; pos++) { - let ch = content.charCodeAt(pos); + const ch = content.charCodeAt(pos); if (pos === startPos && isIdentifierStart(ch, ScriptTarget.Latest)) { continue; } @@ -6123,7 +6122,7 @@ namespace ts { return undefined; } - let result = createNode(SyntaxKind.Identifier, startPos); + const result = createNode(SyntaxKind.Identifier, startPos); result.text = content.substring(startPos, pos); return finishNode(result, pos); } @@ -6153,16 +6152,16 @@ namespace ts { // This is because we do incremental parsing in-place. i.e. we take nodes from the old // tree and give them new positions and parents. From that point on, trusting the old // tree at all is not possible as far too much of it may violate invariants. - let incrementalSourceFile = sourceFile; + const incrementalSourceFile = sourceFile; Debug.assert(!incrementalSourceFile.hasBeenIncrementallyParsed); incrementalSourceFile.hasBeenIncrementallyParsed = true; - let oldText = sourceFile.text; - let syntaxCursor = createSyntaxCursor(sourceFile); + const oldText = sourceFile.text; + const syntaxCursor = createSyntaxCursor(sourceFile); // Make the actual change larger so that we know to reparse anything whose lookahead // might have intersected the change. - let changeRange = extendToAffectedRange(sourceFile, textChangeRange); + const changeRange = extendToAffectedRange(sourceFile, textChangeRange); checkChangeRange(sourceFile, newText, changeRange, aggressiveChecks); // Ensure that extending the affected range only moved the start of the change range @@ -6174,7 +6173,7 @@ namespace ts { // The is the amount the nodes after the edit range need to be adjusted. It can be // positive (if the edit added characters), negative (if the edit deleted characters) // or zero (if this was a pure overwrite with nothing added/removed). - let delta = textChangeRangeNewSpan(changeRange).length - changeRange.span.length; + const delta = textChangeRangeNewSpan(changeRange).length - changeRange.span.length; // If we added or removed characters during the edit, then we need to go and adjust all // the nodes after the edit. Those nodes may move forward (if we inserted chars) or they @@ -6208,7 +6207,7 @@ namespace ts { // inconsistent tree. Setting the parents on the new tree should be very fast. We // will immediately bail out of walking any subtrees when we can see that their parents // are already correct. - let result = Parser.parseSourceFile(sourceFile.fileName, newText, sourceFile.languageVersion, syntaxCursor, /* setParentNode */ true); + const result = Parser.parseSourceFile(sourceFile.fileName, newText, sourceFile.languageVersion, syntaxCursor, /* setParentNode */ true); return result; } @@ -6254,7 +6253,7 @@ namespace ts { array.pos += delta; array.end += delta; - for (let node of array) { + for (const node of array) { visitNode(node); } } @@ -6382,7 +6381,7 @@ namespace ts { // Check if the element intersects the change range. If it does, then it is not // reusable. Also, we'll need to recurse to see what constituent portions we may // be able to use. - let fullEnd = child.end; + const fullEnd = child.end; if (fullEnd >= changeStart) { child.intersectsChange = true; child._children = undefined; @@ -6411,14 +6410,14 @@ namespace ts { // Check if the element intersects the change range. If it does, then it is not // reusable. Also, we'll need to recurse to see what constituent portions we may // be able to use. - let fullEnd = array.end; + const fullEnd = array.end; if (fullEnd >= changeStart) { array.intersectsChange = true; array._children = undefined; // Adjust the pos or end (or both) of the intersecting array accordingly. adjustIntersectingElement(array, changeStart, changeRangeOldEnd, changeRangeNewEnd, delta); - for (let node of array) { + for (const node of array) { visitNode(node); } return; @@ -6440,7 +6439,7 @@ namespace ts { // (as it does not intersect the actual original change range). Because an edit may // change the token touching it, we actually need to look back *at least* one token so // that the prior token sees that change. - let maxLookahead = 1; + const maxLookahead = 1; let start = changeRange.span.start; @@ -6448,15 +6447,15 @@ namespace ts { // the left by maxLookahead tokens. We only need to do this as long as we're not at the // start of the tree. for (let i = 0; start > 0 && i <= maxLookahead; i++) { - let nearestNode = findNearestNodeStartingBeforeOrAtPosition(sourceFile, start); + const nearestNode = findNearestNodeStartingBeforeOrAtPosition(sourceFile, start); Debug.assert(nearestNode.pos <= start); - let position = nearestNode.pos; + const position = nearestNode.pos; start = Math.max(0, position - 1); } - let finalSpan = createTextSpanFromBounds(start, textSpanEnd(changeRange.span)); - let finalLength = changeRange.newLength + (changeRange.span.start - start); + const finalSpan = createTextSpanFromBounds(start, textSpanEnd(changeRange.span)); + const finalLength = changeRange.newLength + (changeRange.span.start - start); return createTextChangeRange(finalSpan, finalLength); } @@ -6468,7 +6467,7 @@ namespace ts { forEachChild(sourceFile, visit); if (lastNodeEntirelyBeforePosition) { - let lastChildOfLastEntireNodeBeforePosition = getLastChild(lastNodeEntirelyBeforePosition); + const lastChildOfLastEntireNodeBeforePosition = getLastChild(lastNodeEntirelyBeforePosition); if (lastChildOfLastEntireNodeBeforePosition.pos > bestResult.pos) { bestResult = lastChildOfLastEntireNodeBeforePosition; } @@ -6478,7 +6477,7 @@ namespace ts { function getLastChild(node: Node): Node { while (true) { - let lastChild = getLastChildWorker(node); + const lastChild = getLastChildWorker(node); if (lastChild) { node = lastChild; } @@ -6557,17 +6556,17 @@ namespace ts { } function checkChangeRange(sourceFile: SourceFile, newText: string, textChangeRange: TextChangeRange, aggressiveChecks: boolean) { - let oldText = sourceFile.text; + const oldText = sourceFile.text; if (textChangeRange) { Debug.assert((oldText.length - textChangeRange.span.length + textChangeRange.newLength) === newText.length); if (aggressiveChecks || Debug.shouldAssert(AssertionLevel.VeryAggressive)) { - let oldTextPrefix = oldText.substr(0, textChangeRange.span.start); - let newTextPrefix = newText.substr(0, textChangeRange.span.start); + const oldTextPrefix = oldText.substr(0, textChangeRange.span.start); + const newTextPrefix = newText.substr(0, textChangeRange.span.start); Debug.assert(oldTextPrefix === newTextPrefix); - let oldTextSuffix = oldText.substring(textSpanEnd(textChangeRange.span), oldText.length); - let newTextSuffix = newText.substring(textSpanEnd(textChangeRangeNewSpan(textChangeRange)), newText.length); + const oldTextSuffix = oldText.substring(textSpanEnd(textChangeRange.span), oldText.length); + const newTextSuffix = newText.substring(textSpanEnd(textChangeRangeNewSpan(textChangeRange)), newText.length); Debug.assert(oldTextSuffix === newTextSuffix); } } @@ -6669,7 +6668,7 @@ namespace ts { // position was in this array. Search through this array to see if we find a // viable element. for (let i = 0, n = array.length; i < n; i++) { - let child = array[i]; + const child = array[i]; if (child) { if (child.pos === position) { // Found the right node. We're done. diff --git a/src/compiler/program.ts b/src/compiler/program.ts index a22db74c669..4600d489c45 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -10,7 +10,7 @@ namespace ts { /** The version of the TypeScript compiler release */ - let emptyArray: any[] = []; + const emptyArray: any[] = []; export const version = "1.8.0"; @@ -20,7 +20,7 @@ namespace ts { if (sys.fileExists(fileName)) { return fileName; } - let parentPath = getDirectoryPath(searchPath); + const parentPath = getDirectoryPath(searchPath); if (parentPath === searchPath) { break; } @@ -31,13 +31,13 @@ namespace ts { } export function resolveTripleslashReference(moduleName: string, containingFile: string): string { - let basePath = getDirectoryPath(containingFile); - let referencedFileName = isRootedDiskPath(moduleName) ? moduleName : combinePaths(basePath, moduleName); + const basePath = getDirectoryPath(containingFile); + const referencedFileName = isRootedDiskPath(moduleName) ? moduleName : combinePaths(basePath, moduleName); return normalizePath(referencedFileName); } export function resolveModuleName(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost): ResolvedModuleWithFailedLookupLocations { - let moduleResolution = compilerOptions.moduleResolution !== undefined + const moduleResolution = compilerOptions.moduleResolution !== undefined ? compilerOptions.moduleResolution : compilerOptions.module === ModuleKind.CommonJS ? ModuleResolutionKind.NodeJs : ModuleResolutionKind.Classic; @@ -48,11 +48,11 @@ namespace ts { } export function nodeModuleNameResolver(moduleName: string, containingFile: string, host: ModuleResolutionHost): ResolvedModuleWithFailedLookupLocations { - let containingDirectory = getDirectoryPath(containingFile); + const containingDirectory = getDirectoryPath(containingFile); if (getRootLength(moduleName) !== 0 || nameStartsWithDotSlashOrDotDotSlash(moduleName)) { - let failedLookupLocations: string[] = []; - let candidate = normalizePath(combinePaths(containingDirectory, moduleName)); + const failedLookupLocations: string[] = []; + const candidate = normalizePath(combinePaths(containingDirectory, moduleName)); let resolvedFileName = loadNodeModuleFromFile(candidate, failedLookupLocations, host); if (resolvedFileName) { @@ -73,7 +73,7 @@ namespace ts { return forEach(moduleFileExtensions, tryLoad); function tryLoad(ext: string): string { - let fileName = fileExtensionIs(candidate, ext) ? candidate : candidate + ext; + const fileName = fileExtensionIs(candidate, ext) ? candidate : candidate + ext; if (host.fileExists(fileName)) { return fileName; } @@ -85,13 +85,13 @@ namespace ts { } function loadNodeModuleFromDirectory(candidate: string, failedLookupLocation: string[], host: ModuleResolutionHost): string { - let packageJsonPath = combinePaths(candidate, "package.json"); + const packageJsonPath = combinePaths(candidate, "package.json"); if (host.fileExists(packageJsonPath)) { let jsonContent: { typings?: string }; try { - let jsonText = host.readFile(packageJsonPath); + const jsonText = host.readFile(packageJsonPath); jsonContent = jsonText ? <{ typings?: string }>JSON.parse(jsonText) : { typings: undefined }; } catch (e) { @@ -100,7 +100,7 @@ namespace ts { } if (jsonContent.typings) { - let result = loadNodeModuleFromFile(normalizePath(combinePaths(candidate, jsonContent.typings)), failedLookupLocation, host); + const result = loadNodeModuleFromFile(normalizePath(combinePaths(candidate, jsonContent.typings)), failedLookupLocation, host); if (result) { return result; } @@ -115,13 +115,13 @@ namespace ts { } function loadModuleFromNodeModules(moduleName: string, directory: string, host: ModuleResolutionHost): ResolvedModuleWithFailedLookupLocations { - let failedLookupLocations: string[] = []; + const failedLookupLocations: string[] = []; directory = normalizeSlashes(directory); while (true) { - let baseName = getBaseFileName(directory); + const baseName = getBaseFileName(directory); if (baseName !== "node_modules") { - let nodeModulesFolder = combinePaths(directory, "node_modules"); - let candidate = normalizePath(combinePaths(nodeModulesFolder, moduleName)); + const nodeModulesFolder = combinePaths(directory, "node_modules"); + const candidate = normalizePath(combinePaths(nodeModulesFolder, moduleName)); let result = loadNodeModuleFromFile(candidate, failedLookupLocations, host); if (result) { return { resolvedModule: { resolvedFileName: result, isExternalLibraryImport: true }, failedLookupLocations }; @@ -133,7 +133,7 @@ namespace ts { } } - let parentPath = getDirectoryPath(directory); + const parentPath = getDirectoryPath(directory); if (parentPath === directory) { break; } @@ -145,7 +145,7 @@ namespace ts { } function nameStartsWithDotSlashOrDotDotSlash(name: string) { - let i = name.lastIndexOf("./", 1); + const i = name.lastIndexOf("./", 1); return i === 0 || (i === 1 && name.charCodeAt(0) === CharacterCodes.dot); } @@ -159,7 +159,7 @@ namespace ts { let searchPath = getDirectoryPath(containingFile); let searchName: string; - let failedLookupLocations: string[] = []; + const failedLookupLocations: string[] = []; let referencedSourceFile: string; while (true) { @@ -171,7 +171,7 @@ namespace ts { return undefined; } - let candidate = searchName + extension; + const candidate = searchName + extension; if (host.fileExists(candidate)) { return candidate; } @@ -184,7 +184,7 @@ namespace ts { break; } - let parentPath = getDirectoryPath(searchPath); + const parentPath = getDirectoryPath(searchPath); if (parentPath === searchPath) { break; } @@ -205,7 +205,7 @@ namespace ts { }; export function createCompilerHost(options: CompilerOptions, setParentNodes?: boolean): CompilerHost { - let existingDirectories: Map = {}; + const existingDirectories: Map = {}; function getCanonicalFileName(fileName: string): string { // if underlying system can distinguish between two files whose names differs only in cases then file name already in canonical form. @@ -214,12 +214,12 @@ namespace ts { } // returned by CScript sys environment - let unsupportedFileEncodingErrorCode = -2147024809; + const unsupportedFileEncodingErrorCode = -2147024809; function getSourceFile(fileName: string, languageVersion: ScriptTarget, onError?: (message: string) => void): SourceFile { let text: string; try { - let start = new Date().getTime(); + const start = new Date().getTime(); text = sys.readFile(fileName, options.charset); ioReadTime += new Date().getTime() - start; } @@ -248,7 +248,7 @@ namespace ts { function ensureDirectoriesExist(directoryPath: string) { if (directoryPath.length > getRootLength(directoryPath) && !directoryExists(directoryPath)) { - let parentDirectory = getDirectoryPath(directoryPath); + const parentDirectory = getDirectoryPath(directoryPath); ensureDirectoriesExist(parentDirectory); sys.createDirectory(directoryPath); } @@ -256,7 +256,7 @@ namespace ts { function writeFile(fileName: string, data: string, writeByteOrderMark: boolean, onError?: (message: string) => void) { try { - let start = new Date().getTime(); + const start = new Date().getTime(); ensureDirectoriesExist(getDirectoryPath(normalizePath(fileName))); sys.writeFile(fileName, data, writeByteOrderMark); ioWriteTime += new Date().getTime() - start; @@ -284,7 +284,7 @@ namespace ts { } export function getPreEmitDiagnostics(program: Program, sourceFile?: SourceFile, cancellationToken?: CancellationToken): Diagnostic[] { - let diagnostics = program.getOptionsDiagnostics(cancellationToken).concat( + const diagnostics = program.getOptionsDiagnostics(cancellationToken).concat( program.getSyntacticDiagnostics(sourceFile, cancellationToken), program.getGlobalDiagnostics(cancellationToken), program.getSemanticDiagnostics(sourceFile, cancellationToken)); @@ -326,7 +326,7 @@ namespace ts { let program: Program; let files: SourceFile[] = []; let fileProcessingDiagnostics = createDiagnosticCollection(); - let programDiagnostics = createDiagnosticCollection(); + const programDiagnostics = createDiagnosticCollection(); let commonSourceDirectory: string; let diagnosticsProducingTypeChecker: TypeChecker; @@ -335,7 +335,7 @@ namespace ts { let skipDefaultLib = options.noLib; - let start = new Date().getTime(); + const start = new Date().getTime(); host = host || createCompilerHost(options); @@ -344,15 +344,15 @@ namespace ts { ? ((moduleNames: string[], containingFile: string) => host.resolveModuleNames(moduleNames, containingFile)) : ((moduleNames: string[], containingFile: string) => map(moduleNames, moduleName => resolveModuleName(moduleName, containingFile, options, host).resolvedModule)); - let filesByName = createFileMap(); + const filesByName = createFileMap(); // stores 'filename -> file association' ignoring case // used to track cases when two file names differ only in casing - let filesByNameIgnoreCase = host.useCaseSensitiveFileNames() ? createFileMap(fileName => fileName.toLowerCase()) : undefined; + const filesByNameIgnoreCase = host.useCaseSensitiveFileNames() ? createFileMap(fileName => fileName.toLowerCase()) : undefined; if (oldProgram) { // check properties that can affect structure of the program or module resolution strategy // if any of these properties has changed - structure cannot be reused - let oldOptions = oldProgram.getCompilerOptions(); + const oldOptions = oldProgram.getCompilerOptions(); if ((oldOptions.module !== options.module) || (oldOptions.noResolve !== options.noResolve) || (oldOptions.target !== options.target) || @@ -410,7 +410,7 @@ namespace ts { getTypeChecker(); classifiableNames = {}; - for (let sourceFile of files) { + for (const sourceFile of files) { copyMap(sourceFile.classifiableNames, classifiableNames); } } @@ -426,17 +426,17 @@ namespace ts { Debug.assert(!oldProgram.structureIsReused); // there is an old program, check if we can reuse its structure - let oldRootNames = oldProgram.getRootFileNames(); + const oldRootNames = oldProgram.getRootFileNames(); if (!arrayIsEqualTo(oldRootNames, rootNames)) { return false; } // check if program source files has changed in the way that can affect structure of the program - let newSourceFiles: SourceFile[] = []; - let filePaths: Path[] = []; - let modifiedSourceFiles: SourceFile[] = []; + const newSourceFiles: SourceFile[] = []; + const filePaths: Path[] = []; + const modifiedSourceFiles: SourceFile[] = []; - for (let oldSourceFile of oldProgram.getSourceFiles()) { + for (const oldSourceFile of oldProgram.getSourceFiles()) { let newSourceFile = host.getSourceFile(oldSourceFile.fileName, options.target); if (!newSourceFile) { return false; @@ -466,13 +466,13 @@ namespace ts { } if (resolveModuleNamesWorker) { - let moduleNames = map(newSourceFile.imports, name => name.text); - let resolutions = resolveModuleNamesWorker(moduleNames, getNormalizedAbsolutePath(newSourceFile.fileName, currentDirectory)); + const moduleNames = map(newSourceFile.imports, name => name.text); + const resolutions = resolveModuleNamesWorker(moduleNames, getNormalizedAbsolutePath(newSourceFile.fileName, currentDirectory)); // ensure that module resolution results are still correct for (let i = 0; i < moduleNames.length; ++i) { - let newResolution = resolutions[i]; - let oldResolution = getResolvedModule(oldSourceFile, moduleNames[i]); - let resolutionChanged = oldResolution + const newResolution = resolutions[i]; + const oldResolution = getResolvedModule(oldSourceFile, moduleNames[i]); + const resolutionChanged = oldResolution ? !newResolution || oldResolution.resolvedFileName !== newResolution.resolvedFileName || !!oldResolution.isExternalLibraryImport !== !!newResolution.isExternalLibraryImport @@ -504,7 +504,7 @@ namespace ts { files = newSourceFiles; fileProcessingDiagnostics = oldProgram.getFileProcessingDiagnostics(); - for (let modifiedFile of modifiedSourceFiles) { + for (const modifiedFile of modifiedSourceFiles) { fileProcessingDiagnostics.reattachFileDiagnostics(modifiedFile); } oldProgram.structureIsReused = true; @@ -554,11 +554,11 @@ namespace ts { // This is because in the -out scenario all files need to be emitted, and therefore all // files need to be type checked. And the way to specify that all files need to be type // checked is to not pass the file to getEmitResolver. - let emitResolver = getDiagnosticsProducingTypeChecker().getEmitResolver((options.outFile || options.out) ? undefined : sourceFile); + const emitResolver = getDiagnosticsProducingTypeChecker().getEmitResolver((options.outFile || options.out) ? undefined : sourceFile); - let start = new Date().getTime(); + const start = new Date().getTime(); - let emitResult = emitFiles( + const emitResult = emitFiles( emitResolver, getEmitHost(writeFileCallback), sourceFile); @@ -579,7 +579,7 @@ namespace ts { return getDiagnostics(sourceFile, cancellationToken); } - let allDiagnostics: Diagnostic[] = []; + const allDiagnostics: Diagnostic[] = []; forEach(program.getSourceFiles(), sourceFile => { if (cancellationToken) { cancellationToken.throwIfCancellationRequested(); @@ -631,13 +631,13 @@ namespace ts { function getSemanticDiagnosticsForFile(sourceFile: SourceFile, cancellationToken: CancellationToken): Diagnostic[] { return runWithCancellationToken(() => { - let typeChecker = getDiagnosticsProducingTypeChecker(); + const typeChecker = getDiagnosticsProducingTypeChecker(); Debug.assert(!!sourceFile.bindDiagnostics); - let bindDiagnostics = sourceFile.bindDiagnostics; - let checkDiagnostics = typeChecker.getDiagnostics(sourceFile, cancellationToken); - let fileProcessingDiagnosticsInFile = fileProcessingDiagnostics.getDiagnostics(sourceFile.fileName); - let programDiagnosticsInFile = programDiagnostics.getDiagnostics(sourceFile.fileName); + const bindDiagnostics = sourceFile.bindDiagnostics; + const checkDiagnostics = typeChecker.getDiagnostics(sourceFile, cancellationToken); + const fileProcessingDiagnosticsInFile = fileProcessingDiagnostics.getDiagnostics(sourceFile.fileName); + const programDiagnosticsInFile = programDiagnostics.getDiagnostics(sourceFile.fileName); return bindDiagnostics.concat(checkDiagnostics).concat(fileProcessingDiagnosticsInFile).concat(programDiagnosticsInFile); }); @@ -646,23 +646,23 @@ namespace ts { function getDeclarationDiagnosticsForFile(sourceFile: SourceFile, cancellationToken: CancellationToken): Diagnostic[] { return runWithCancellationToken(() => { if (!isDeclarationFile(sourceFile)) { - let resolver = getDiagnosticsProducingTypeChecker().getEmitResolver(sourceFile, cancellationToken); + const resolver = getDiagnosticsProducingTypeChecker().getEmitResolver(sourceFile, cancellationToken); // Don't actually write any files since we're just getting diagnostics. - let writeFile: WriteFileCallback = () => { }; + const writeFile: WriteFileCallback = () => { }; return ts.getDeclarationDiagnostics(getEmitHost(writeFile), resolver, sourceFile); } }); } function getOptionsDiagnostics(): Diagnostic[] { - let allDiagnostics: Diagnostic[] = []; + const allDiagnostics: Diagnostic[] = []; addRange(allDiagnostics, fileProcessingDiagnostics.getGlobalDiagnostics()); addRange(allDiagnostics, programDiagnostics.getGlobalDiagnostics()); return sortAndDeduplicateDiagnostics(allDiagnostics); } function getGlobalDiagnostics(): Diagnostic[] { - let allDiagnostics: Diagnostic[] = []; + const allDiagnostics: Diagnostic[] = []; addRange(allDiagnostics, getDiagnosticsProducingTypeChecker().getGlobalDiagnostics()); return sortAndDeduplicateDiagnostics(allDiagnostics); } @@ -689,7 +689,7 @@ namespace ts { } let imports: LiteralExpression[]; - for (let node of file.statements) { + for (const node of file.statements) { collect(node, /* allowRelativeModuleNames */ true); } @@ -749,7 +749,7 @@ namespace ts { } } else { - let nonTsFile: SourceFile = options.allowNonTsExtensions && findSourceFile(fileName, toPath(fileName, currentDirectory, getCanonicalFileName), isDefaultLib, 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; @@ -797,7 +797,7 @@ namespace ts { } // We haven't looked for this file, do so now and cache result - let file = host.getSourceFile(fileName, options.target, hostErrorMessage => { + const file = host.getSourceFile(fileName, options.target, hostErrorMessage => { if (refFile !== undefined && refPos !== undefined && refEnd !== undefined) { fileProcessingDiagnostics.add(createFileDiagnostic(refFile, refPos, refEnd - refPos, Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage)); @@ -824,7 +824,7 @@ namespace ts { skipDefaultLib = skipDefaultLib || file.hasNoDefaultLib; - let basePath = getDirectoryPath(fileName); + const basePath = getDirectoryPath(fileName); if (!options.noResolve) { processReferencedFiles(file, basePath); } @@ -846,7 +846,7 @@ namespace ts { function processReferencedFiles(file: SourceFile, basePath: string) { forEach(file.referencedFiles, ref => { - let referencedFileName = resolveTripleslashReference(ref.fileName, file.fileName); + const referencedFileName = resolveTripleslashReference(ref.fileName, file.fileName); processSourceFile(referencedFileName, /* isDefaultLib */ false, file, ref.pos, ref.end); }); } @@ -859,21 +859,21 @@ namespace ts { collectExternalModuleReferences(file); if (file.imports.length) { file.resolvedModules = {}; - let moduleNames = map(file.imports, name => name.text); - let resolutions = resolveModuleNamesWorker(moduleNames, getNormalizedAbsolutePath(file.fileName, currentDirectory)); + const moduleNames = map(file.imports, name => name.text); + const resolutions = resolveModuleNamesWorker(moduleNames, getNormalizedAbsolutePath(file.fileName, currentDirectory)); for (let i = 0; i < file.imports.length; ++i) { - let resolution = resolutions[i]; + const resolution = resolutions[i]; setResolvedModule(file, moduleNames[i], resolution); if (resolution && !options.noResolve) { const importedFile = findSourceFile(resolution.resolvedFileName, toPath(resolution.resolvedFileName, currentDirectory, getCanonicalFileName), /* isDefaultLib */ false, file, skipTrivia(file.text, file.imports[i].pos), file.imports[i].end); if (importedFile && resolution.isExternalLibraryImport) { if (!isExternalModule(importedFile)) { - let start = getTokenPosOfNode(file.imports[i], file); + const start = getTokenPosOfNode(file.imports[i], file); fileProcessingDiagnostics.add(createFileDiagnostic(file, start, file.imports[i].end - start, Diagnostics.Exported_external_package_typings_file_0_is_not_a_module_Please_contact_the_package_author_to_update_the_package_definition, importedFile.fileName)); } else if (importedFile.referencedFiles.length) { - let firstRef = importedFile.referencedFiles[0]; + const firstRef = importedFile.referencedFiles[0]; fileProcessingDiagnostics.add(createFileDiagnostic(importedFile, firstRef.pos, firstRef.end - firstRef.pos, Diagnostics.Exported_external_package_typings_file_cannot_contain_tripleslash_references_Please_contact_the_package_author_to_update_the_package_definition)); } } @@ -895,7 +895,7 @@ namespace ts { return; } - let sourcePathComponents = getNormalizedPathComponents(sourceFile.fileName, currentDirectory); + const sourcePathComponents = getNormalizedPathComponents(sourceFile.fileName, currentDirectory); sourcePathComponents.pop(); // The base file name is not part of the common directory path if (!commonPathComponents) { @@ -929,11 +929,11 @@ namespace ts { function checkSourceFilesBelongToPath(sourceFiles: SourceFile[], rootDirectory: string): boolean { let allFilesBelongToPath = true; if (sourceFiles) { - let absoluteRootDirectoryPath = host.getCanonicalFileName(getNormalizedAbsolutePath(rootDirectory, currentDirectory)); + const absoluteRootDirectoryPath = host.getCanonicalFileName(getNormalizedAbsolutePath(rootDirectory, currentDirectory)); for (var sourceFile of sourceFiles) { if (!isDeclarationFile(sourceFile)) { - let absoluteSourceFilePath = host.getCanonicalFileName(getNormalizedAbsolutePath(sourceFile.fileName, currentDirectory)); + const absoluteSourceFilePath = host.getCanonicalFileName(getNormalizedAbsolutePath(sourceFile.fileName, currentDirectory)); if (absoluteSourceFilePath.indexOf(absoluteRootDirectoryPath) !== 0) { programDiagnostics.add(createCompilerDiagnostic(Diagnostics.File_0_is_not_under_rootDir_1_rootDir_is_expected_to_contain_all_source_files, sourceFile.fileName, options.rootDir)); allFilesBelongToPath = false; @@ -998,24 +998,24 @@ namespace ts { return; } - let languageVersion = options.target || ScriptTarget.ES3; - let outFile = options.outFile || options.out; + const languageVersion = options.target || ScriptTarget.ES3; + const outFile = options.outFile || options.out; - let firstExternalModuleSourceFile = forEach(files, f => isExternalModule(f) ? f : undefined); + const firstExternalModuleSourceFile = forEach(files, f => isExternalModule(f) ? f : undefined); if (options.isolatedModules) { if (!options.module && languageVersion < ScriptTarget.ES6) { programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Option_isolatedModules_can_only_be_used_when_either_option_module_is_provided_or_option_target_is_ES2015_or_higher)); } - let firstNonExternalModuleSourceFile = forEach(files, f => !isExternalModule(f) && !isDeclarationFile(f) ? f : undefined); + const firstNonExternalModuleSourceFile = forEach(files, f => !isExternalModule(f) && !isDeclarationFile(f) ? f : undefined); if (firstNonExternalModuleSourceFile) { - let span = getErrorSpanForNode(firstNonExternalModuleSourceFile, firstNonExternalModuleSourceFile); + const span = getErrorSpanForNode(firstNonExternalModuleSourceFile, firstNonExternalModuleSourceFile); programDiagnostics.add(createFileDiagnostic(firstNonExternalModuleSourceFile, span.start, span.length, Diagnostics.Cannot_compile_namespaces_when_the_isolatedModules_flag_is_provided)); } } else if (firstExternalModuleSourceFile && languageVersion < ScriptTarget.ES6 && !options.module) { // We cannot use createDiagnosticFromNode because nodes do not have parents yet - let span = getErrorSpanForNode(firstExternalModuleSourceFile, firstExternalModuleSourceFile.externalModuleIndicator); + const span = getErrorSpanForNode(firstExternalModuleSourceFile, firstExternalModuleSourceFile.externalModuleIndicator); programDiagnostics.add(createFileDiagnostic(firstExternalModuleSourceFile, span.start, span.length, Diagnostics.Cannot_compile_modules_unless_the_module_flag_is_provided)); } diff --git a/src/compiler/scanner.ts b/src/compiler/scanner.ts index a827d755302..4e11e0d6b99 100644 --- a/src/compiler/scanner.ts +++ b/src/compiler/scanner.ts @@ -49,7 +49,7 @@ namespace ts { tryScan(callback: () => T): T; } - let textToToken: Map = { + const textToToken: Map = { "abstract": SyntaxKind.AbstractKeyword, "any": SyntaxKind.AnyKeyword, "as": SyntaxKind.AsKeyword, @@ -191,8 +191,8 @@ namespace ts { Codepoint ranges for ES3 Identifiers are extracted from the Unicode 3.0.0 specification at: http://www.unicode.org/Public/3.0-Update/UnicodeData-3.0.0.txt */ - let 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, ]; - let 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, ]; + const 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, ]; + const 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, ]; /* As per ECMAScript Language Specification 5th Edition, Section 7.6: ISyntaxToken Names and Identifiers @@ -216,8 +216,8 @@ namespace ts { Codepoint ranges for ES5 Identifiers are extracted from the Unicode 6.2 specification at: http://www.unicode.org/Public/6.2.0/ucd/UnicodeData.txt */ - let 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, ]; - let 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, ]; + const 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, ]; + const 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: number, map: number[]): boolean { // Bail out quickly if it couldn't possibly be in the map. @@ -262,8 +262,8 @@ namespace ts { } function makeReverseMap(source: Map): string[] { - let result: string[] = []; - for (let name in source) { + const result: string[] = []; + for (const name in source) { if (source.hasOwnProperty(name)) { result[source[name]] = name; } @@ -271,7 +271,7 @@ namespace ts { return result; } - let tokenStrings = makeReverseMap(textToToken); + const tokenStrings = makeReverseMap(textToToken); export function tokenToString(t: SyntaxKind): string { return tokenStrings[t]; @@ -284,11 +284,11 @@ namespace ts { /* @internal */ export function computeLineStarts(text: string): number[] { - let result: number[] = new Array(); + const result: number[] = new Array(); let pos = 0; let lineStart = 0; while (pos < text.length) { - let ch = text.charCodeAt(pos++); + const ch = text.charCodeAt(pos++); switch (ch) { case CharacterCodes.carriageReturn: if (text.charCodeAt(pos) === CharacterCodes.lineFeed) { @@ -352,7 +352,7 @@ namespace ts { return computeLineAndCharacterOfPosition(getLineStarts(sourceFile), position); } - let hasOwnProperty = Object.prototype.hasOwnProperty; + const hasOwnProperty = Object.prototype.hasOwnProperty; export function isWhiteSpace(ch: number): boolean { // Note: nextLine is in the Zs space, and should be considered to be a whitespace. @@ -400,7 +400,7 @@ namespace ts { export function couldStartTrivia(text: string, pos: number): boolean { // Keep in sync with skipTrivia - let ch = text.charCodeAt(pos); + const ch = text.charCodeAt(pos); switch (ch) { case CharacterCodes.carriageReturn: case CharacterCodes.lineFeed: @@ -427,7 +427,7 @@ namespace ts { export function skipTrivia(text: string, pos: number, stopAfterLineBreak?: boolean): number { // Keep in sync with couldStartTrivia while (true) { - let ch = text.charCodeAt(pos); + const ch = text.charCodeAt(pos); switch (ch) { case CharacterCodes.carriageReturn: if (text.charCodeAt(pos + 1) === CharacterCodes.lineFeed) { @@ -498,14 +498,14 @@ namespace ts { // All conflict markers consist of the same character repeated seven times. If it is // a <<<<<<< or >>>>>>> marker then it is also followd by a space. - let mergeConflictMarkerLength = "<<<<<<<".length; + const mergeConflictMarkerLength = "<<<<<<<".length; function isConflictMarkerTrivia(text: string, pos: number) { Debug.assert(pos >= 0); // Conflict markers must be at the start of a line. if (pos === 0 || isLineBreak(text.charCodeAt(pos - 1))) { - let ch = text.charCodeAt(pos); + const ch = text.charCodeAt(pos); if ((pos + mergeConflictMarkerLength) < text.length) { for (let i = 0, n = mergeConflictMarkerLength; i < n; i++) { @@ -527,8 +527,8 @@ namespace ts { error(Diagnostics.Merge_conflict_marker_encountered, mergeConflictMarkerLength); } - let ch = text.charCodeAt(pos); - let len = text.length; + const ch = text.charCodeAt(pos); + const len = text.length; if (ch === CharacterCodes.lessThan || ch === CharacterCodes.greaterThan) { while (pos < len && !isLineBreak(text.charCodeAt(pos))) { @@ -540,7 +540,7 @@ namespace ts { // Consume everything from the start of the mid-conlict marker to the start of the next // end-conflict marker. while (pos < len) { - let ch = text.charCodeAt(pos); + const ch = text.charCodeAt(pos); if (ch === CharacterCodes.greaterThan && isConflictMarkerTrivia(text, pos)) { break; } @@ -561,7 +561,7 @@ namespace ts { } function scanShebangTrivia(text: string, pos: number) { - let shebang = shebangTriviaRegex.exec(text)[0]; + const shebang = shebangTriviaRegex.exec(text)[0]; pos = pos + shebang.length; return pos; } @@ -581,7 +581,7 @@ namespace ts { let result: CommentRange[]; let collecting = trailing || pos === 0; while (true) { - let ch = text.charCodeAt(pos); + const ch = text.charCodeAt(pos); switch (ch) { case CharacterCodes.carriageReturn: if (text.charCodeAt(pos + 1) === CharacterCodes.lineFeed) { @@ -607,8 +607,8 @@ namespace ts { let nextChar = text.charCodeAt(pos + 1); let hasTrailingNewLine = false; if (nextChar === CharacterCodes.slash || nextChar === CharacterCodes.asterisk) { - let kind = nextChar === CharacterCodes.slash ? SyntaxKind.SingleLineCommentTrivia : SyntaxKind.MultiLineCommentTrivia; - let startPos = pos; + const kind = nextChar === CharacterCodes.slash ? SyntaxKind.SingleLineCommentTrivia : SyntaxKind.MultiLineCommentTrivia; + const startPos = pos; pos += 2; if (nextChar === CharacterCodes.slash) { while (pos < text.length) { @@ -742,7 +742,7 @@ namespace ts { } function scanNumber(): number { - let start = pos; + const start = pos; while (isDigit(text.charCodeAt(pos))) pos++; if (text.charCodeAt(pos) === CharacterCodes.dot) { pos++; @@ -765,7 +765,7 @@ namespace ts { } function scanOctalDigits(): number { - let start = pos; + const start = pos; while (isOctalDigit(text.charCodeAt(pos))) { pos++; } @@ -792,7 +792,7 @@ namespace ts { let digits = 0; let value = 0; while (digits < minCount || scanAsManyAsPossible) { - let ch = text.charCodeAt(pos); + const ch = text.charCodeAt(pos); if (ch >= CharacterCodes._0 && ch <= CharacterCodes._9) { value = value * 16 + ch - CharacterCodes._0; } @@ -815,7 +815,7 @@ namespace ts { } function scanString(): string { - let quote = text.charCodeAt(pos++); + const quote = text.charCodeAt(pos++); let result = ""; let start = pos; while (true) { @@ -825,7 +825,7 @@ namespace ts { error(Diagnostics.Unterminated_string_literal); break; } - let ch = text.charCodeAt(pos); + const ch = text.charCodeAt(pos); if (ch === quote) { result += text.substring(start, pos); pos++; @@ -853,7 +853,7 @@ namespace ts { * a literal component of a TemplateExpression. */ function scanTemplateAndSetTokenValue(): SyntaxKind { - let startedWithBacktick = text.charCodeAt(pos) === CharacterCodes.backtick; + const startedWithBacktick = text.charCodeAt(pos) === CharacterCodes.backtick; pos++; let start = pos; @@ -869,7 +869,7 @@ namespace ts { break; } - let currChar = text.charCodeAt(pos); + const currChar = text.charCodeAt(pos); // '`' if (currChar === CharacterCodes.backtick) { @@ -925,7 +925,7 @@ namespace ts { error(Diagnostics.Unexpected_end_of_text); return ""; } - let ch = text.charCodeAt(pos++); + const ch = text.charCodeAt(pos++); switch (ch) { case CharacterCodes._0: return "\0"; @@ -977,7 +977,7 @@ namespace ts { } function scanHexadecimalEscape(numDigits: number): string { - let escapedValue = scanExactNumberOfHexDigits(numDigits); + const escapedValue = scanExactNumberOfHexDigits(numDigits); if (escapedValue >= 0) { return String.fromCharCode(escapedValue); @@ -989,7 +989,7 @@ namespace ts { } function scanExtendedUnicodeEscape(): string { - let escapedValue = scanMinimumNumberOfHexDigits(1); + const escapedValue = scanMinimumNumberOfHexDigits(1); let isInvalidExtendedEscape = false; // Validate the value of the digit @@ -1030,8 +1030,8 @@ namespace ts { return String.fromCharCode(codePoint); } - let codeUnit1 = Math.floor((codePoint - 65536) / 1024) + 0xD800; - let codeUnit2 = ((codePoint - 65536) % 1024) + 0xDC00; + const codeUnit1 = Math.floor((codePoint - 65536) / 1024) + 0xD800; + const codeUnit2 = ((codePoint - 65536) % 1024) + 0xDC00; return String.fromCharCode(codeUnit1, codeUnit2); } @@ -1040,9 +1040,9 @@ namespace ts { // and return code point value if valid Unicode escape is found. Otherwise return -1. function peekUnicodeEscape(): number { if (pos + 5 < end && text.charCodeAt(pos + 1) === CharacterCodes.u) { - let start = pos; + const start = pos; pos += 2; - let value = scanExactNumberOfHexDigits(4); + const value = scanExactNumberOfHexDigits(4); pos = start; return value; } @@ -1078,9 +1078,9 @@ namespace ts { function getIdentifierToken(): SyntaxKind { // Reserved words are between 2 and 11 characters long and start with a lowercase letter - let len = tokenValue.length; + const len = tokenValue.length; if (len >= 2 && len <= 11) { - let ch = tokenValue.charCodeAt(0); + const ch = tokenValue.charCodeAt(0); if (ch >= CharacterCodes.a && ch <= CharacterCodes.z && hasOwnProperty.call(textToToken, tokenValue)) { return token = textToToken[tokenValue]; } @@ -1096,8 +1096,8 @@ namespace ts { // Similarly valid octalIntegerLiteral must have at least one octal digit following o or O. let numberOfDigits = 0; while (true) { - let ch = text.charCodeAt(pos); - let valueOfCh = ch - CharacterCodes._0; + const ch = text.charCodeAt(pos); + const valueOfCh = ch - CharacterCodes._0; if (!isDigit(ch) || valueOfCh >= base) { break; } @@ -1262,7 +1262,7 @@ namespace ts { let commentClosed = false; while (pos < end) { - let ch = text.charCodeAt(pos); + const ch = text.charCodeAt(pos); if (ch === CharacterCodes.asterisk && text.charCodeAt(pos + 1) === CharacterCodes.slash) { pos += 2; @@ -1504,7 +1504,7 @@ namespace ts { break; } - let ch = text.charCodeAt(p); + const ch = text.charCodeAt(p); if (isLineBreak(ch)) { tokenIsUnterminated = true; error(Diagnostics.Unterminated_regular_expression_literal); @@ -1594,9 +1594,9 @@ namespace ts { // they allow dashes function scanJsxIdentifier(): SyntaxKind { if (tokenIsIdentifierOrKeyword(token)) { - let firstCharPosition = pos; + const firstCharPosition = pos; while (pos < end) { - let ch = text.charCodeAt(pos); + const ch = text.charCodeAt(pos); if (ch === CharacterCodes.minus || ((firstCharPosition === pos) ? isIdentifierStart(ch, languageVersion) : isIdentifierPart(ch, languageVersion))) { pos++; } @@ -1610,13 +1610,13 @@ namespace ts { } function speculationHelper(callback: () => T, isLookahead: boolean): T { - let savePos = pos; - let saveStartPos = startPos; - let saveTokenPos = tokenPos; - let saveToken = token; - let saveTokenValue = tokenValue; - let savePrecedingLineBreak = precedingLineBreak; - let result = callback(); + const savePos = pos; + const saveStartPos = startPos; + const saveTokenPos = tokenPos; + const saveToken = token; + const saveTokenValue = tokenValue; + const savePrecedingLineBreak = precedingLineBreak; + const result = callback(); // If our callback returned something 'falsy' or we're just looking ahead, // then unconditionally restore us to where we were. diff --git a/src/compiler/sys.ts b/src/compiler/sys.ts index 7810d9f710a..3a90ca42fa1 100644 --- a/src/compiler/sys.ts +++ b/src/compiler/sys.ts @@ -51,15 +51,15 @@ namespace ts { function getWScriptSystem(): System { - let fso = new ActiveXObject("Scripting.FileSystemObject"); + const fso = new ActiveXObject("Scripting.FileSystemObject"); - let fileStream = new ActiveXObject("ADODB.Stream"); + const fileStream = new ActiveXObject("ADODB.Stream"); fileStream.Type = 2 /*text*/; - let binaryStream = new ActiveXObject("ADODB.Stream"); + const binaryStream = new ActiveXObject("ADODB.Stream"); binaryStream.Type = 1 /*binary*/; - let args: string[] = []; + const args: string[] = []; for (let i = 0; i < WScript.Arguments.length; i++) { args[i] = WScript.Arguments.Item(i); } @@ -78,7 +78,7 @@ namespace ts { // Load file and read the first two bytes into a string with no interpretation fileStream.Charset = "x-ansi"; fileStream.LoadFromFile(fileName); - let bom = fileStream.ReadText(2) || ""; + const bom = fileStream.ReadText(2) || ""; // Position must be at 0 before encoding can be changed fileStream.Position = 0; // [0xFF,0xFE] and [0xFE,0xFF] mean utf-16 (little or big endian), otherwise default to utf-8 @@ -124,7 +124,7 @@ namespace ts { } function getNames(collection: any): string[] { - let result: string[] = []; + const result: string[] = []; for (let e = new Enumerator(collection); !e.atEnd(); e.moveNext()) { result.push(e.item().Name); } @@ -132,22 +132,22 @@ namespace ts { } function readDirectory(path: string, extension?: string, exclude?: string[]): string[] { - let result: string[] = []; + const result: string[] = []; exclude = map(exclude, s => getCanonicalPath(combinePaths(path, s))); visitDirectory(path); return result; function visitDirectory(path: string) { - let folder = fso.GetFolder(path || "."); - let files = getNames(folder.files); - for (let current of files) { - let name = combinePaths(path, current); + const folder = fso.GetFolder(path || "."); + const files = getNames(folder.files); + for (const current of files) { + const name = combinePaths(path, current); if ((!extension || fileExtensionIs(name, extension)) && !contains(exclude, getCanonicalPath(name))) { result.push(name); } } - let subfolders = getNames(folder.subfolders); - for (let current of subfolders) { - let name = combinePaths(path, current); + const subfolders = getNames(folder.subfolders); + for (const current of subfolders) { + const name = combinePaths(path, current); if (!contains(exclude, getCanonicalPath(name))) { visitDirectory(name); } @@ -212,7 +212,7 @@ namespace ts { } function poll(checkedIndex: number) { - let watchedFile = watchedFiles[checkedIndex]; + const watchedFile = watchedFiles[checkedIndex]; if (!watchedFile) { return; } @@ -252,7 +252,7 @@ namespace ts { } function addFile(fileName: string, callback: (fileName: string, removed?: boolean) => void): WatchedFile { - let file: WatchedFile = { + const file: WatchedFile = { fileName, callback, mtime: getModifiedTime(fileName) @@ -291,7 +291,7 @@ namespace ts { // changes for large reference sets? If so, do we want // to increase the chunk size or decrease the interval // time dynamically to match the large reference set? - let watchedFileSet = createWatchedFileSet(); + const watchedFileSet = createWatchedFileSet(); function isNode4OrLater(): Boolean { return parseInt(process.version.charAt(1)) >= 4; @@ -305,14 +305,14 @@ namespace ts { if (!_fs.existsSync(fileName)) { return undefined; } - let buffer = _fs.readFileSync(fileName); + const buffer = _fs.readFileSync(fileName); let len = buffer.length; if (len >= 2 && buffer[0] === 0xFE && buffer[1] === 0xFF) { // Big endian UTF-16 byte order mark detected. Since big endian is not supported by node.js, // flip all byte pairs and treat as little endian. len &= ~1; for (let i = 0; i < len; i += 2) { - let temp = buffer[i]; + const temp = buffer[i]; buffer[i] = buffer[i + 1]; buffer[i + 1] = temp; } @@ -354,17 +354,17 @@ namespace ts { } function readDirectory(path: string, extension?: string, exclude?: string[]): string[] { - let result: string[] = []; + const result: string[] = []; exclude = map(exclude, s => getCanonicalPath(combinePaths(path, s))); visitDirectory(path); return result; function visitDirectory(path: string) { - let files = _fs.readdirSync(path || ".").sort(); - let directories: string[] = []; - for (let current of files) { - let name = combinePaths(path, current); + const files = _fs.readdirSync(path || ".").sort(); + const directories: string[] = []; + for (const current of files) { + const name = combinePaths(path, current); if (!contains(exclude, getCanonicalPath(name))) { - let stat = _fs.statSync(name); + const stat = _fs.statSync(name); if (stat.isFile()) { if (!extension || fileExtensionIs(name, extension)) { result.push(name); @@ -375,7 +375,7 @@ namespace ts { } } } - for (let current of directories) { + for (const current of directories) { visitDirectory(current); } } @@ -400,7 +400,7 @@ namespace ts { return _fs.watch(fileName, (eventName: string, relativeFileName: string) => callback(fileName)); } - let watchedFile = watchedFileSet.addFile(fileName, callback); + const watchedFile = watchedFileSet.addFile(fileName, callback); return { close: () => watchedFileSet.removeFile(watchedFile) }; diff --git a/src/compiler/tsc.ts b/src/compiler/tsc.ts index 962805d34a0..79158cf4e9d 100644 --- a/src/compiler/tsc.ts +++ b/src/compiler/tsc.ts @@ -9,7 +9,7 @@ namespace ts { let reportDiagnostic = reportDiagnosticSimply; function reportDiagnostics(diagnostics: Diagnostic[], host: CompilerHost): void { - for (let diagnostic of diagnostics) { + for (const diagnostic of diagnostics) { reportDiagnostic(diagnostic, host); } } @@ -19,15 +19,15 @@ namespace ts { * and if it is, attempts to set the appropriate language. */ function validateLocaleAndSetLanguage(locale: string, errors: Diagnostic[]): boolean { - let matchResult = /^([a-z]+)([_\-]([a-z]+))?$/.exec(locale.toLowerCase()); + const matchResult = /^([a-z]+)([_\-]([a-z]+))?$/.exec(locale.toLowerCase()); if (!matchResult) { errors.push(createCompilerDiagnostic(Diagnostics.Locale_must_be_of_the_form_language_or_language_territory_For_example_0_or_1, "en", "ja-jp")); return false; } - let language = matchResult[1]; - let territory = matchResult[3]; + const language = matchResult[1]; + const territory = matchResult[3]; // First try the entire locale, then fall back to just language if that's all we have. if (!trySetLanguageAndTerritory(language, territory, errors) && @@ -41,8 +41,8 @@ namespace ts { } function trySetLanguageAndTerritory(language: string, territory: string, errors: Diagnostic[]): boolean { - let compilerFilePath = normalizePath(sys.getExecutingFilePath()); - let containingDirectoryPath = getDirectoryPath(compilerFilePath); + const compilerFilePath = normalizePath(sys.getExecutingFilePath()); + const containingDirectoryPath = getDirectoryPath(compilerFilePath); let filePath = combinePaths(containingDirectoryPath, language); @@ -85,7 +85,7 @@ namespace ts { } function getDiagnosticText(message: DiagnosticMessage, ...args: any[]): string { - let diagnostic = createCompilerDiagnostic.apply(undefined, arguments); + const diagnostic = createCompilerDiagnostic.apply(undefined, arguments); return diagnostic.messageText; } @@ -102,7 +102,7 @@ namespace ts { output += `${ relativeFileName }(${ line + 1 },${ character + 1 }): `; } - let category = DiagnosticCategory[diagnostic.category].toLowerCase(); + const category = DiagnosticCategory[diagnostic.category].toLowerCase(); output += `${ category } TS${ diagnostic.code }: ${ flattenDiagnosticMessageText(diagnostic.messageText, sys.newLine) }${ sys.newLine }`; sys.write(output); @@ -130,13 +130,13 @@ namespace ts { let output = ""; if (diagnostic.file) { - let { start, length, file } = diagnostic; - let { line: firstLine, character: firstLineChar } = getLineAndCharacterOfPosition(file, start); - let { line: lastLine, character: lastLineChar } = getLineAndCharacterOfPosition(file, start + length); + const { start, length, file } = diagnostic; + const { line: firstLine, character: firstLineChar } = getLineAndCharacterOfPosition(file, start); + const { line: lastLine, character: lastLineChar } = getLineAndCharacterOfPosition(file, start + length); const lastLineInFile = getLineAndCharacterOfPosition(file, file.text.length).line; const relativeFileName = getRelativeFileName(file.fileName, host); - let hasMoreThanFiveLines = (lastLine - firstLine) >= 4; + const hasMoreThanFiveLines = (lastLine - firstLine) >= 4; let gutterWidth = (lastLine + 1 + "").length; if (hasMoreThanFiveLines) { gutterWidth = Math.max(elipsis.length, gutterWidth); @@ -151,8 +151,8 @@ namespace ts { i = lastLine - 1; } - let lineStart = getPositionOfLineAndCharacter(file, i, 0); - let lineEnd = i < lastLineInFile ? getPositionOfLineAndCharacter(file, i + 1, 0) : file.text.length; + const lineStart = getPositionOfLineAndCharacter(file, i, 0); + const lineEnd = i < lastLineInFile ? getPositionOfLineAndCharacter(file, i + 1, 0) : file.text.length; let lineContent = file.text.slice(lineStart, lineEnd); lineContent = lineContent.replace(/\s+$/g, ""); // trim from end lineContent = lineContent.replace("\t", " "); // convert tabs to single spaces @@ -200,7 +200,7 @@ namespace ts { let output = new Date().toLocaleTimeString() + " - "; if (diagnostic.file) { - let loc = getLineAndCharacterOfPosition(diagnostic.file, diagnostic.start); + const loc = getLineAndCharacterOfPosition(diagnostic.file, diagnostic.start); output += `${ diagnostic.file.fileName }(${ loc.line + 1 },${ loc.character + 1 }): `; } @@ -241,7 +241,7 @@ namespace ts { } export function executeCommandLine(args: string[]): void { - let commandLine = parseCommandLine(args); + const commandLine = parseCommandLine(args); let configFileName: string; // Configuration file name (if any) let cachedConfigFileText: string; // Cached configuration file text, used for reparsing (if any) let configFileWatcher: FileWatcher; // Configuration file watcher @@ -302,7 +302,7 @@ namespace ts { } } else if (commandLine.fileNames.length === 0 && isJSONSupported()) { - let searchPath = normalizePath(sys.getCurrentDirectory()); + const searchPath = normalizePath(sys.getCurrentDirectory()); configFileName = findConfigFile(searchPath); } @@ -322,7 +322,7 @@ namespace ts { configFileWatcher = sys.watchFile(configFileName, configFileChanged); } if (sys.watchDirectory && configFileName) { - let directory = ts.getDirectoryPath(configFileName); + const directory = ts.getDirectoryPath(configFileName); directoryWatcher = sys.watchDirectory( // When the configFileName is just "tsconfig.json", the watched directory should be // the current direcotry; if there is a given "project" parameter, then the configFileName @@ -340,16 +340,16 @@ namespace ts { cachedConfigFileText = sys.readFile(configFileName); } catch (e) { - let error = createCompilerDiagnostic(Diagnostics.Cannot_read_file_0_Colon_1, configFileName, e.message); + const error = createCompilerDiagnostic(Diagnostics.Cannot_read_file_0_Colon_1, configFileName, e.message); reportWatchDiagnostic(error); sys.exit(ExitStatus.DiagnosticsPresent_OutputsSkipped); return; } } - let result = parseConfigFileTextToJson(configFileName, cachedConfigFileText); - let configObject = result.config; - let configParseResult = parseJsonConfigFileContent(configObject, sys, getDirectoryPath(configFileName)); + const result = parseConfigFileTextToJson(configFileName, cachedConfigFileText); + const configObject = result.config; + const configParseResult = parseJsonConfigFileContent(configObject, sys, getDirectoryPath(configFileName)); if (configParseResult.errors.length > 0) { reportDiagnostics(configParseResult.errors, /* compilerHost */ undefined); sys.exit(ExitStatus.DiagnosticsPresent_OutputsSkipped); @@ -363,7 +363,7 @@ namespace ts { if (!cachedProgram) { if (configFileName) { - let configParseResult = parseConfigFile(); + const configParseResult = parseConfigFile(); rootFileNames = configParseResult.fileNames; compilerOptions = extend(commandLine.options, configParseResult.options); } @@ -386,7 +386,7 @@ namespace ts { // reset the cache of existing files cachedExistingFiles = {}; - let compileResult = compile(rootFileNames, compilerOptions, compilerHost); + const compileResult = compile(rootFileNames, compilerOptions, compilerHost); if (!compilerOptions.watch) { return sys.exit(compileResult.exitStatus); @@ -406,14 +406,14 @@ namespace ts { function getSourceFile(fileName: string, languageVersion: ScriptTarget, onError?: (message: string) => void) { // Return existing SourceFile object if one is available if (cachedProgram) { - let sourceFile = cachedProgram.getSourceFile(fileName); + const sourceFile = cachedProgram.getSourceFile(fileName); // A modified source file has no watcher and should not be reused if (sourceFile && sourceFile.fileWatcher) { return sourceFile; } } // Use default host function - let sourceFile = hostGetSourceFile(fileName, languageVersion, onError); + const sourceFile = hostGetSourceFile(fileName, languageVersion, onError); if (sourceFile && compilerOptions.watch) { // Attach a file watcher sourceFile.fileWatcher = sys.watchFile(sourceFile.fileName, (fileName: string, removed?: boolean) => sourceFileChanged(sourceFile, removed)); @@ -424,7 +424,7 @@ namespace ts { // Change cached program to the given program function setCachedProgram(program: Program) { if (cachedProgram) { - let newSourceFiles = program ? program.getSourceFiles() : undefined; + const newSourceFiles = program ? program.getSourceFiles() : undefined; forEach(cachedProgram.getSourceFiles(), sourceFile => { if (!(newSourceFiles && contains(newSourceFiles, sourceFile))) { if (sourceFile.fileWatcher) { @@ -442,7 +442,7 @@ namespace ts { sourceFile.fileWatcher.close(); sourceFile.fileWatcher = undefined; if (removed) { - let index = rootFileNames.indexOf(sourceFile.fileName); + const index = rootFileNames.indexOf(sourceFile.fileName); if (index >= 0) { rootFileNames.splice(index, 1); } @@ -473,9 +473,9 @@ namespace ts { } function directoryChangeHandler() { - let parsedCommandLine = parseConfigFile(); - let newFileNames = ts.map(parsedCommandLine.fileNames, compilerHost.getCanonicalFileName); - let canonicalRootFileNames = ts.map(rootFileNames, compilerHost.getCanonicalFileName); + const parsedCommandLine = parseConfigFile(); + const newFileNames = ts.map(parsedCommandLine.fileNames, compilerHost.getCanonicalFileName); + const canonicalRootFileNames = ts.map(rootFileNames, compilerHost.getCanonicalFileName); // We check if the project file list has changed. If so, we just throw away the old program and start fresh. if (!arrayIsEqualTo(newFileNames && newFileNames.sort(), canonicalRootFileNames && canonicalRootFileNames.sort())) { @@ -509,8 +509,8 @@ namespace ts { checkTime = 0; emitTime = 0; - let program = createProgram(fileNames, compilerOptions, compilerHost); - let exitStatus = compileProgram(); + const program = createProgram(fileNames, compilerOptions, compilerHost); + const exitStatus = compileProgram(); if (compilerOptions.listFiles) { forEach(program.getSourceFiles(), file => { @@ -519,7 +519,7 @@ namespace ts { } if (compilerOptions.diagnostics) { - let memoryUsed = sys.getMemoryUsage ? sys.getMemoryUsage() : -1; + const memoryUsed = sys.getMemoryUsage ? sys.getMemoryUsage() : -1; reportCountStatistic("Files", program.getSourceFiles().length); reportCountStatistic("Lines", countLines(program)); reportCountStatistic("Nodes", program.getNodeCount()); @@ -572,7 +572,7 @@ namespace ts { } // Otherwise, emit and report any errors we ran into. - let emitOutput = program.emit(); + const emitOutput = program.emit(); reportDiagnostics(emitOutput.diagnostics, compilerHost); // If the emitter didn't emit anything, then pass that value along. @@ -598,8 +598,8 @@ namespace ts { let output = ""; // We want to align our "syntax" and "examples" commands to a certain margin. - let syntaxLength = getDiagnosticText(Diagnostics.Syntax_Colon_0, "").length; - let examplesLength = getDiagnosticText(Diagnostics.Examples_Colon_0, "").length; + const syntaxLength = getDiagnosticText(Diagnostics.Syntax_Colon_0, "").length; + const examplesLength = getDiagnosticText(Diagnostics.Examples_Colon_0, "").length; let marginLength = Math.max(syntaxLength, examplesLength); // Build up the syntactic skeleton. @@ -610,7 +610,7 @@ namespace ts { output += sys.newLine + sys.newLine; // Build up the list of examples. - let padding = makePadding(marginLength); + const padding = makePadding(marginLength); output += getDiagnosticText(Diagnostics.Examples_Colon_0, makePadding(marginLength - examplesLength) + "tsc hello.ts") + sys.newLine; output += padding + "tsc --out file.js file.ts" + sys.newLine; output += padding + "tsc @args.txt" + sys.newLine; @@ -619,17 +619,17 @@ namespace ts { output += getDiagnosticText(Diagnostics.Options_Colon) + sys.newLine; // Sort our options by their names, (e.g. "--noImplicitAny" comes before "--watch") - let optsList = filter(optionDeclarations.slice(), v => !v.experimental); + const optsList = filter(optionDeclarations.slice(), v => !v.experimental); optsList.sort((a, b) => compareValues(a.name.toLowerCase(), b.name.toLowerCase())); // We want our descriptions to align at the same column in our output, // so we keep track of the longest option usage string. marginLength = 0; - let usageColumn: string[] = []; // Things like "-d, --declaration" go in here. - let descriptionColumn: string[] = []; + const usageColumn: string[] = []; // Things like "-d, --declaration" go in here. + const descriptionColumn: string[] = []; for (let i = 0; i < optsList.length; i++) { - let option = optsList[i]; + const option = optsList[i]; // If an option lacks a description, // it is not officially supported. @@ -655,15 +655,15 @@ namespace ts { } // Special case that can't fit in the loop. - let usageText = " @<" + getDiagnosticText(Diagnostics.file) + ">"; + const usageText = " @<" + getDiagnosticText(Diagnostics.file) + ">"; usageColumn.push(usageText); descriptionColumn.push(getDiagnosticText(Diagnostics.Insert_command_line_options_and_files_from_a_file)); marginLength = Math.max(usageText.length, marginLength); // Print out each row, aligning all the descriptions on the same column. for (let i = 0; i < usageColumn.length; i++) { - let usage = usageColumn[i]; - let description = descriptionColumn[i]; + const usage = usageColumn[i]; + const description = descriptionColumn[i]; output += usage + makePadding(marginLength - usage.length + 2) + description + sys.newLine; } @@ -683,14 +683,14 @@ namespace ts { } function writeConfigFile(options: CompilerOptions, fileNames: string[]) { - let currentDirectory = sys.getCurrentDirectory(); - let file = normalizePath(combinePaths(currentDirectory, "tsconfig.json")); + const currentDirectory = sys.getCurrentDirectory(); + const file = normalizePath(combinePaths(currentDirectory, "tsconfig.json")); if (sys.fileExists(file)) { reportDiagnostic(createCompilerDiagnostic(Diagnostics.A_tsconfig_json_file_is_already_defined_at_Colon_0, file), /* compilerHost */ undefined); } else { - let compilerOptions = extend(options, defaultInitCompilerOptions); - let configurations: any = { + const compilerOptions = extend(options, defaultInitCompilerOptions); + const configurations: any = { compilerOptions: serializeCompilerOptions(compilerOptions), exclude: ["node_modules"] }; @@ -707,12 +707,12 @@ namespace ts { return; function serializeCompilerOptions(options: CompilerOptions): Map { - let result: Map = {}; - let optionsNameMap = getOptionNameMap().optionNameMap; + const result: Map = {}; + const optionsNameMap = getOptionNameMap().optionNameMap; - for (let name in options) { + for (const name in options) { if (hasProperty(options, name)) { - let value = options[name]; + const value = options[name]; switch (name) { case "init": case "watch": @@ -729,8 +729,8 @@ namespace ts { } else { // Enum - let typeMap = >optionDefinition.type; - for (let key in typeMap) { + const typeMap = >optionDefinition.type; + for (const key in typeMap) { if (hasProperty(typeMap, key)) { if (typeMap[key] === value) result[name] = key; diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 10b35ce8a01..aecf8ab76ba 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -16,9 +16,9 @@ namespace ts { } export function getDeclarationOfKind(symbol: Symbol, kind: SyntaxKind): Declaration { - let declarations = symbol.declarations; + const declarations = symbol.declarations; if (declarations) { - for (let declaration of declarations) { + for (const declaration of declarations) { if (declaration.kind === kind) { return declaration; } @@ -43,12 +43,12 @@ namespace ts { } // Pool writers to avoid needing to allocate them for every symbol we write. - let stringWriters: StringSymbolWriter[] = []; + const stringWriters: StringSymbolWriter[] = []; export function getSingleLineStringWriter(): StringSymbolWriter { if (stringWriters.length === 0) { let str = ""; - let writeText: (text: string) => void = text => str += text; + const writeText: (text: string) => void = text => str += text; return { string: () => str, writeKeyword: writeText, @@ -92,7 +92,7 @@ namespace ts { } for (let i = 0; i < array1.length; ++i) { - let equals = equaler ? equaler(array1[i], array2[i]) : array1[i] === array2[i]; + const equals = equaler ? equaler(array1[i], array2[i]) : array1[i] === array2[i]; if (!equals) { return false; } @@ -128,7 +128,7 @@ namespace ts { // A node is considered to contain a parse error if: // a) the parser explicitly marked that it had an error // b) any of it's children reported that it had an error. - let thisNodeOrAnySubNodesHasError = ((node.parserContextFlags & ParserContextFlags.ThisNodeHasError) !== 0) || + const thisNodeOrAnySubNodesHasError = ((node.parserContextFlags & ParserContextFlags.ThisNodeHasError) !== 0) || forEachChild(node, containsParseError); // If so, mark ourselves accordingly. @@ -157,8 +157,8 @@ namespace ts { // This is a useful function for debugging purposes. export function nodePosToString(node: Node): string { - let file = getSourceFileOfNode(node); - let loc = getLineAndCharacterOfPosition(file, node.pos); + const file = getSourceFileOfNode(node); + const loc = getLineAndCharacterOfPosition(file, node.pos); return `${ file.fileName }(${ loc.line + 1 },${ loc.character + 1 })`; } @@ -213,7 +213,7 @@ namespace ts { return ""; } - let text = sourceFile.text; + const text = sourceFile.text; return text.substring(includeTrivia ? node.pos : skipTrivia(text, node.pos), node.end); } @@ -294,14 +294,14 @@ namespace ts { } export function createDiagnosticForNode(node: Node, message: DiagnosticMessage, arg0?: any, arg1?: any, arg2?: any): Diagnostic { - let sourceFile = getSourceFileOfNode(node); - let span = getErrorSpanForNode(sourceFile, node); + const sourceFile = getSourceFileOfNode(node); + const span = getErrorSpanForNode(sourceFile, node); return createFileDiagnostic(sourceFile, span.start, span.length, message, arg0, arg1, arg2); } export function createDiagnosticForNodeFromMessageChain(node: Node, messageChain: DiagnosticMessageChain): Diagnostic { - let sourceFile = getSourceFileOfNode(node); - let span = getErrorSpanForNode(sourceFile, node); + const sourceFile = getSourceFileOfNode(node); + const span = getErrorSpanForNode(sourceFile, node); return { file: sourceFile, start: span.start, @@ -313,9 +313,9 @@ namespace ts { } export function getSpanOfTokenAtPosition(sourceFile: SourceFile, pos: number): TextSpan { - let scanner = createScanner(sourceFile.languageVersion, /*skipTrivia*/ true, sourceFile.languageVariant, sourceFile.text, /*onError:*/ undefined, pos); + const scanner = createScanner(sourceFile.languageVersion, /*skipTrivia*/ true, sourceFile.languageVariant, sourceFile.text, /*onError:*/ undefined, pos); scanner.scan(); - let start = scanner.getTokenPos(); + const start = scanner.getTokenPos(); return createTextSpanFromBounds(start, scanner.getTextPos()); } @@ -351,7 +351,7 @@ namespace ts { return getSpanOfTokenAtPosition(sourceFile, node.pos); } - let pos = nodeIsMissing(errorNode) + const pos = nodeIsMissing(errorNode) ? errorNode.pos : skipTrivia(sourceFile.text, errorNode.pos); @@ -422,7 +422,7 @@ namespace ts { } export function getJsDocComments(node: Node, sourceFileOfNode: SourceFile) { - let commentRanges = (node.kind === SyntaxKind.Parameter || node.kind === SyntaxKind.TypeParameter) ? + const commentRanges = (node.kind === SyntaxKind.Parameter || node.kind === SyntaxKind.TypeParameter) ? concatenate(getTrailingCommentRanges(sourceFileOfNode.text, node.pos), getLeadingCommentRanges(sourceFileOfNode.text, node.pos)) : getLeadingCommentRangesOfNode(node, sourceFileOfNode); @@ -579,7 +579,7 @@ namespace ts { return; default: if (isFunctionLike(node)) { - let name = (node).name; + const name = (node).name; if (name && name.kind === SyntaxKind.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. @@ -1030,7 +1030,7 @@ namespace ts { } export function isInstantiatedModule(node: ModuleDeclaration, preserveConstEnums: boolean) { - let moduleState = getModuleInstanceState(node); + const moduleState = getModuleInstanceState(node); return moduleState === ModuleInstanceState.Instantiated || (preserveConstEnums && moduleState === ModuleInstanceState.ConstEnumOnly); } @@ -1053,7 +1053,7 @@ namespace ts { return (node).moduleSpecifier; } if (node.kind === SyntaxKind.ImportEqualsDeclaration) { - let reference = (node).moduleReference; + const reference = (node).moduleReference; if (reference.kind === SyntaxKind.ExternalModuleReference) { return (reference).expression; } @@ -1088,7 +1088,7 @@ namespace ts { function getJSDocTag(node: Node, kind: SyntaxKind): JSDocTag { if (node && node.jsDocComment) { - for (let tag of node.jsDocComment.tags) { + for (const tag of node.jsDocComment.tags) { if (tag.kind === kind) { return tag; } @@ -1112,14 +1112,14 @@ namespace ts { if (parameter.name && parameter.name.kind === SyntaxKind.Identifier) { // If it's a parameter, see if the parent has a jsdoc comment with an @param // annotation. - let parameterName = (parameter.name).text; + const parameterName = (parameter.name).text; - let docComment = parameter.parent.jsDocComment; + const docComment = parameter.parent.jsDocComment; if (docComment) { return forEach(docComment.tags, t => { if (t.kind === SyntaxKind.JSDocParameterTag) { - let parameterTag = t; - let name = parameterTag.preParameterName || parameterTag.postParameterName; + const parameterTag = t; + const name = parameterTag.preParameterName || parameterTag.postParameterName; if (name.text === parameterName) { return t; } @@ -1140,7 +1140,7 @@ namespace ts { return true; } - let paramTag = getCorrespondingJSDocParameterTag(node); + const paramTag = getCorrespondingJSDocParameterTag(node); if (paramTag && paramTag.typeExpression) { return paramTag.typeExpression.type.kind === SyntaxKind.JSDocVariadicType; } @@ -1270,7 +1270,7 @@ namespace ts { return false; } - let parent = name.parent; + const parent = name.parent; if (parent.kind === SyntaxKind.ImportSpecifier || parent.kind === SyntaxKind.ExportSpecifier) { if ((parent).propertyName) { return true; @@ -1337,23 +1337,23 @@ namespace ts { } export function getClassExtendsHeritageClauseElement(node: ClassLikeDeclaration) { - let heritageClause = getHeritageClause(node.heritageClauses, SyntaxKind.ExtendsKeyword); + const heritageClause = getHeritageClause(node.heritageClauses, SyntaxKind.ExtendsKeyword); return heritageClause && heritageClause.types.length > 0 ? heritageClause.types[0] : undefined; } export function getClassImplementsHeritageClauseElements(node: ClassLikeDeclaration) { - let heritageClause = getHeritageClause(node.heritageClauses, SyntaxKind.ImplementsKeyword); + const heritageClause = getHeritageClause(node.heritageClauses, SyntaxKind.ImplementsKeyword); return heritageClause ? heritageClause.types : undefined; } export function getInterfaceBaseTypeNodes(node: InterfaceDeclaration) { - let heritageClause = getHeritageClause(node.heritageClauses, SyntaxKind.ExtendsKeyword); + const heritageClause = getHeritageClause(node.heritageClauses, SyntaxKind.ExtendsKeyword); return heritageClause ? heritageClause.types : undefined; } export function getHeritageClause(clauses: NodeArray, kind: SyntaxKind) { if (clauses) { - for (let clause of clauses) { + for (const clause of clauses) { if (clause.token === kind) { return clause; } @@ -1365,7 +1365,7 @@ namespace ts { export function tryResolveScriptReference(host: ScriptReferenceHost, sourceFile: SourceFile, reference: FileReference) { if (!host.getCompilerOptions().noResolve) { - let referenceFileName = isRootedDiskPath(reference.fileName) ? reference.fileName : combinePaths(getDirectoryPath(sourceFile.fileName), reference.fileName); + const referenceFileName = isRootedDiskPath(reference.fileName) ? reference.fileName : combinePaths(getDirectoryPath(sourceFile.fileName), reference.fileName); return host.getSourceFile(referenceFileName); } } @@ -1381,8 +1381,8 @@ namespace ts { } export function getFileReferenceFromReferencePath(comment: string, commentRange: CommentRange): ReferencePathMatchResult { - let simpleReferenceRegEx = /^\/\/\/\s*/gim; + const simpleReferenceRegEx = /^\/\/\/\s*/gim; if (simpleReferenceRegEx.exec(comment)) { if (isNoDefaultLibRegEx.exec(comment)) { return { @@ -1390,10 +1390,10 @@ namespace ts { }; } else { - let matchResult = fullTripleSlashReferencePathRegEx.exec(comment); + const matchResult = fullTripleSlashReferencePathRegEx.exec(comment); if (matchResult) { - let start = commentRange.pos; - let end = commentRange.end; + const start = commentRange.pos; + const end = commentRange.end; return { fileReference: { pos: start, @@ -1454,9 +1454,9 @@ namespace ts { return (name).text; } if (name.kind === SyntaxKind.ComputedPropertyName) { - let nameExpression = (name).expression; + const nameExpression = (name).expression; if (isWellKnownSymbolSyntactically(nameExpression)) { - let rightHandSideName = (nameExpression).name.text; + const rightHandSideName = (nameExpression).name.text; return getPropertyNameForKnownSymbolName(rightHandSideName); } } @@ -1493,7 +1493,7 @@ namespace ts { } export function isParameterDeclaration(node: VariableLikeDeclaration) { - let root = getRootDeclaration(node); + const root = getRootDeclaration(node); return root.kind === SyntaxKind.Parameter; } @@ -1510,12 +1510,12 @@ namespace ts { export function cloneEntityName(node: EntityName): EntityName { if (node.kind === SyntaxKind.Identifier) { - let clone = createSynthesizedNode(SyntaxKind.Identifier); + const clone = createSynthesizedNode(SyntaxKind.Identifier); clone.text = (node).text; return clone; } else { - let clone = createSynthesizedNode(SyntaxKind.QualifiedName); + const clone = createSynthesizedNode(SyntaxKind.QualifiedName); clone.left = cloneEntityName((node).left); clone.left.parent = clone; clone.right = cloneEntityName((node).right); @@ -1529,13 +1529,13 @@ namespace ts { } export function createSynthesizedNode(kind: SyntaxKind, startsOnNewLine?: boolean): Node { - let node = createNode(kind, /* pos */ -1, /* end */ -1); + const node = createNode(kind, /* pos */ -1, /* end */ -1); node.startsOnNewLine = startsOnNewLine; return node; } export function createSynthesizedNodeArray(): NodeArray { - let array = >[]; + const array = >[]; array.pos = -1; array.end = -1; return array; @@ -1543,7 +1543,7 @@ namespace ts { export function createDiagnosticCollection(): DiagnosticCollection { let nonFileDiagnostics: Diagnostic[] = []; - let fileDiagnostics: Map = {}; + const fileDiagnostics: Map = {}; let diagnosticsModified = false; let modificationCount = 0; @@ -1565,7 +1565,7 @@ namespace ts { return; } - for (let diagnostic of fileDiagnostics[newFile.fileName]) { + for (const diagnostic of fileDiagnostics[newFile.fileName]) { diagnostic.file = newFile; } } @@ -1599,14 +1599,14 @@ namespace ts { return fileDiagnostics[fileName] || []; } - let allDiagnostics: Diagnostic[] = []; + const allDiagnostics: Diagnostic[] = []; function pushDiagnostic(d: Diagnostic) { allDiagnostics.push(d); } forEach(nonFileDiagnostics, pushDiagnostic); - for (let key in fileDiagnostics) { + for (const key in fileDiagnostics) { if (hasProperty(fileDiagnostics, key)) { forEach(fileDiagnostics[key], pushDiagnostic); } @@ -1623,7 +1623,7 @@ namespace ts { diagnosticsModified = false; nonFileDiagnostics = sortAndDeduplicateDiagnostics(nonFileDiagnostics); - for (let key in fileDiagnostics) { + for (const key in fileDiagnostics) { if (hasProperty(fileDiagnostics, key)) { fileDiagnostics[key] = sortAndDeduplicateDiagnostics(fileDiagnostics[key]); } @@ -1636,8 +1636,8 @@ namespace ts { // the language service. These characters should be escaped when printing, and if any characters are added, // the map below must be updated. Note that this regexp *does not* include the 'delete' character. // There is no reason for this other than that JSON.stringify does not handle it either. - let escapedCharsRegExp = /[\\\"\u0000-\u001f\t\v\f\b\r\n\u2028\u2029\u0085]/g; - let escapedCharsMap: Map = { + const escapedCharsRegExp = /[\\\"\u0000-\u001f\t\v\f\b\r\n\u2028\u2029\u0085]/g; + const escapedCharsMap: Map = { "\0": "\\0", "\t": "\\t", "\v": "\\v", @@ -1668,17 +1668,17 @@ namespace ts { } export function isIntrinsicJsxName(name: string) { - let ch = name.substr(0, 1); + const ch = name.substr(0, 1); return ch.toLowerCase() === ch; } function get16BitUnicodeEscapeSequence(charCode: number): string { - let hexCharCode = charCode.toString(16).toUpperCase(); - let paddedHexCode = ("0000" + hexCharCode).slice(-4); + const hexCharCode = charCode.toString(16).toUpperCase(); + const paddedHexCode = ("0000" + hexCharCode).slice(-4); return "\\u" + paddedHexCode; } - let nonAsciiCharacters = /[^\u0000-\u007F]/g; + const nonAsciiCharacters = /[^\u0000-\u007F]/g; export function escapeNonAsciiCharacters(s: string): string { // Replace non-ASCII characters with '\uNNNN' escapes if any exist. // Otherwise just return the original string. @@ -1702,7 +1702,7 @@ namespace ts { getIndent(): number; } - let indentStrings: string[] = ["", " "]; + const indentStrings: string[] = ["", " "]; export function getIndentString(level: number) { if (indentStrings[level] === undefined) { indentStrings[level] = getIndentString(level - 1) + indentStrings[1]; @@ -1743,7 +1743,7 @@ namespace ts { function writeLiteral(s: string) { if (s && s.length) { write(s); - let lineStartsOfS = computeLineStarts(s); + const lineStartsOfS = computeLineStarts(s); if (lineStartsOfS.length > 1) { lineCount = lineCount + lineStartsOfS.length - 1; linePos = output.length - s.length + lastOrUndefined(lineStartsOfS); @@ -1781,7 +1781,7 @@ namespace ts { } export function getOwnEmitOutputFilePath(sourceFile: SourceFile, host: EmitHost, extension: string) { - let compilerOptions = host.getCompilerOptions(); + const compilerOptions = host.getCompilerOptions(); let emitOutputFilePathWithoutExtension: string; if (compilerOptions.outDir) { emitOutputFilePathWithoutExtension = removeFileExtension(getSourceFilePathInNewDir(sourceFile, host, compilerOptions.outDir)); @@ -1854,8 +1854,8 @@ namespace ts { forEach(declarations, (member: Declaration) => { if ((member.kind === SyntaxKind.GetAccessor || member.kind === SyntaxKind.SetAccessor) && (member.flags & NodeFlags.Static) === (accessor.flags & NodeFlags.Static)) { - let memberName = getPropertyNameForPropertyNameNode(member.name); - let accessorName = getPropertyNameForPropertyNameNode(accessor.name); + const memberName = getPropertyNameForPropertyNameNode(member.name); + const accessorName = getPropertyNameForPropertyNameNode(accessor.name); if (memberName === accessorName) { if (!firstAccessor) { firstAccessor = member; @@ -1938,13 +1938,13 @@ namespace ts { } if (leadingComments) { - let detachedComments: CommentRange[] = []; + const detachedComments: CommentRange[] = []; let lastComment: CommentRange; - for (let comment of leadingComments) { + for (const comment of leadingComments) { if (lastComment) { - let lastCommentLine = getLineOfLocalPosition(currentSourceFile, lastComment.end); - let commentLine = getLineOfLocalPosition(currentSourceFile, comment.pos); + const lastCommentLine = getLineOfLocalPosition(currentSourceFile, lastComment.end); + const commentLine = getLineOfLocalPosition(currentSourceFile, comment.pos); if (commentLine >= lastCommentLine + 2) { // There was a blank line between the last comment and this comment. This @@ -1962,8 +1962,8 @@ namespace ts { // All comments look like they could have been part of the copyright header. Make // sure there is at least one blank line between it and the node. If not, it's not // a copyright header. - let lastCommentLine = getLineOfLocalPosition(currentSourceFile, lastOrUndefined(detachedComments).end); - let nodeLine = getLineOfLocalPosition(currentSourceFile, skipTrivia(currentSourceFile.text, node.pos)); + const lastCommentLine = getLineOfLocalPosition(currentSourceFile, lastOrUndefined(detachedComments).end); + const nodeLine = getLineOfLocalPosition(currentSourceFile, skipTrivia(currentSourceFile.text, node.pos)); if (nodeLine >= lastCommentLine + 2) { // Valid detachedComments emitNewLineBeforeLeadingComments(currentSourceFile, writer, node, leadingComments); @@ -1983,11 +1983,11 @@ namespace ts { export function writeCommentRange(currentSourceFile: SourceFile, writer: EmitTextWriter, comment: CommentRange, newLine: string) { if (currentSourceFile.text.charCodeAt(comment.pos + 1) === CharacterCodes.asterisk) { - let firstCommentLineAndCharacter = getLineAndCharacterOfPosition(currentSourceFile, comment.pos); - let lineCount = getLineStarts(currentSourceFile).length; + const firstCommentLineAndCharacter = getLineAndCharacterOfPosition(currentSourceFile, comment.pos); + const lineCount = getLineStarts(currentSourceFile).length; let firstCommentLineIndent: number; for (let pos = comment.pos, currentLine = firstCommentLineAndCharacter.line; pos < comment.end; currentLine++) { - let nextLineStart = (currentLine + 1) === lineCount + const nextLineStart = (currentLine + 1) === lineCount ? currentSourceFile.text.length + 1 : getStartPositionOfLine(currentLine + 1, currentSourceFile); @@ -1998,7 +1998,7 @@ namespace ts { } // These are number of spaces writer is going to write at current indent - let currentWriterIndentSpacing = writer.getIndent() * getIndentSize(); + const currentWriterIndentSpacing = writer.getIndent() * getIndentSize(); // Number of spaces we want to be writing // eg: Assume writer indent @@ -2014,10 +2014,10 @@ namespace ts { // More right indented comment */ --4 = 8 - 4 + 11 // class c { } // } - let spacesToEmit = currentWriterIndentSpacing - firstCommentLineIndent + calculateIndent(pos, nextLineStart); + const spacesToEmit = currentWriterIndentSpacing - firstCommentLineIndent + calculateIndent(pos, nextLineStart); if (spacesToEmit > 0) { let numberOfSingleSpacesToEmit = spacesToEmit % getIndentSize(); - let indentSizeSpaceString = getIndentString((spacesToEmit - numberOfSingleSpacesToEmit) / getIndentSize()); + const indentSizeSpaceString = getIndentString((spacesToEmit - numberOfSingleSpacesToEmit) / getIndentSize()); // Write indent size string ( in eg 1: = "", 2: "" , 3: string with 8 spaces 4: string with 12 spaces writer.rawWrite(indentSizeSpaceString); @@ -2046,8 +2046,8 @@ namespace ts { } function writeTrimmedCurrentLine(pos: number, nextLineStart: number) { - let end = Math.min(comment.end, nextLineStart - 1); - let currentLineText = currentSourceFile.text.substring(pos, end).replace(/^\s+|\s+$/g, ""); + const end = Math.min(comment.end, nextLineStart - 1); + const currentLineText = currentSourceFile.text.substring(pos, end).replace(/^\s+|\s+$/g, ""); if (currentLineText) { // trimmed forward and ending spaces text writer.write(currentLineText); @@ -2161,7 +2161,7 @@ namespace ts { } export function isEmptyObjectLiteralOrArrayLiteral(expression: Node): boolean { - let kind = expression.kind; + const kind = expression.kind; if (kind === SyntaxKind.ObjectLiteralExpression) { return (expression).properties.length === 0; } @@ -2188,11 +2188,11 @@ namespace ts { * representing the UTF-8 encoding of the character, and return the expanded char code list. */ function getExpandedCharCodes(input: string): number[] { - let output: number[] = []; - let length = input.length; + const output: number[] = []; + const length = input.length; for (let i = 0; i < length; i++) { - let charCode = input.charCodeAt(i); + const charCode = input.charCodeAt(i); // handel utf8 if (charCode < 0x80) { @@ -2228,9 +2228,9 @@ namespace ts { */ export function convertToBase64(input: string): string { let result = ""; - let charCodes = getExpandedCharCodes(input); + const charCodes = getExpandedCharCodes(input); let i = 0; - let length = charCodes.length; + const length = charCodes.length; let byte1: number, byte2: number, byte3: number, byte4: number; while (i < length) { @@ -2304,14 +2304,14 @@ namespace ts { } export function textSpanOverlapsWith(span: TextSpan, other: TextSpan) { - let overlapStart = Math.max(span.start, other.start); - let overlapEnd = Math.min(textSpanEnd(span), textSpanEnd(other)); + const overlapStart = Math.max(span.start, other.start); + const overlapEnd = Math.min(textSpanEnd(span), textSpanEnd(other)); return overlapStart < overlapEnd; } export function textSpanOverlap(span1: TextSpan, span2: TextSpan) { - let overlapStart = Math.max(span1.start, span2.start); - let overlapEnd = Math.min(textSpanEnd(span1), textSpanEnd(span2)); + const overlapStart = Math.max(span1.start, span2.start); + const overlapEnd = Math.min(textSpanEnd(span1), textSpanEnd(span2)); if (overlapStart < overlapEnd) { return createTextSpanFromBounds(overlapStart, overlapEnd); } @@ -2323,13 +2323,13 @@ namespace ts { } export function textSpanIntersectsWith(span: TextSpan, start: number, length: number) { - let end = start + length; + const end = start + length; return start <= textSpanEnd(span) && end >= span.start; } export function decodedTextSpanIntersectsWith(start1: number, length1: number, start2: number, length2: number) { - let end1 = start1 + length1; - let end2 = start2 + length2; + const end1 = start1 + length1; + const end2 = start2 + length2; return start2 <= end1 && end2 >= start1; } @@ -2338,8 +2338,8 @@ namespace ts { } export function textSpanIntersection(span1: TextSpan, span2: TextSpan) { - let intersectStart = Math.max(span1.start, span2.start); - let intersectEnd = Math.min(textSpanEnd(span1), textSpanEnd(span2)); + const intersectStart = Math.max(span1.start, span2.start); + const intersectEnd = Math.min(textSpanEnd(span1), textSpanEnd(span2)); if (intersectStart <= intersectEnd) { return createTextSpanFromBounds(intersectStart, intersectEnd); } @@ -2398,14 +2398,14 @@ namespace ts { // We change from talking about { { oldStart, oldLength }, newLength } to { oldStart, oldEnd, newEnd } // as it makes things much easier to reason about. - let change0 = changes[0]; + const change0 = changes[0]; let oldStartN = change0.span.start; let oldEndN = textSpanEnd(change0.span); let newEndN = oldStartN + change0.newLength; for (let i = 1; i < changes.length; i++) { - let nextChange = changes[i]; + const nextChange = changes[i]; // Consider the following case: // i.e. two edits. The first represents the text change range { { 10, 50 }, 30 }. i.e. The span starting @@ -2487,13 +2487,13 @@ namespace ts { // newEnd3 : Max(newEnd2, newEnd2 + (newEnd1 - oldEnd2)) // } - let oldStart1 = oldStartN; - let oldEnd1 = oldEndN; - let newEnd1 = newEndN; + const oldStart1 = oldStartN; + const oldEnd1 = oldEndN; + const newEnd1 = newEndN; - let oldStart2 = nextChange.span.start; - let oldEnd2 = textSpanEnd(nextChange.span); - let newEnd2 = oldStart2 + nextChange.newLength; + const oldStart2 = nextChange.span.start; + const oldEnd2 = textSpanEnd(nextChange.span); + const newEnd2 = oldStart2 + nextChange.newLength; oldStartN = Math.min(oldStart1, oldStart2); oldEndN = Math.max(oldEnd1, oldEnd1 + (oldEnd2 - newEnd1)); diff --git a/src/harness/compilerRunner.ts b/src/harness/compilerRunner.ts index 108c6f4518a..848f229f109 100644 --- a/src/harness/compilerRunner.ts +++ b/src/harness/compilerRunner.ts @@ -140,7 +140,7 @@ class CompilerBaselineRunner extends RunnerBase { it("Correct sourcemap content for " + fileName, () => { if (options.sourceMap || options.inlineSourceMap) { Harness.Baseline.runBaseline("Correct sourcemap content for " + fileName, justName.replace(/\.tsx?$/, ".sourcemap.txt"), () => { - let record = result.getSourceMapRecord(); + const record = result.getSourceMapRecord(); if (options.noEmitOnError && result.errors.length !== 0 && record === undefined) { // Because of the noEmitOnError option no files are created. We need to return null because baselining isn"t required. return null; @@ -159,7 +159,7 @@ class CompilerBaselineRunner extends RunnerBase { // check js output Harness.Baseline.runBaseline("Correct JS output for " + fileName, justName.replace(/\.tsx?/, ".js"), () => { let tsCode = ""; - let tsSources = otherFiles.concat(toBeCompiled); + const tsSources = otherFiles.concat(toBeCompiled); if (tsSources.length > 1) { tsCode += "//// [" + fileName + "] ////\r\n\r\n"; } @@ -184,7 +184,7 @@ class CompilerBaselineRunner extends RunnerBase { } } - let declFileCompilationResult = harnessCompiler.compileDeclarationFiles(toBeCompiled, otherFiles, result, function (settings) { + const declFileCompilationResult = harnessCompiler.compileDeclarationFiles(toBeCompiled, otherFiles, result, function (settings) { harnessCompiler.setCompilerSettings(tcSettings); }, options); @@ -257,15 +257,15 @@ class CompilerBaselineRunner extends RunnerBase { // These types are equivalent, but depend on what order the compiler observed // certain parts of the program. - let allFiles = toBeCompiled.concat(otherFiles).filter(file => !!program.getSourceFile(file.unitName)); + const allFiles = toBeCompiled.concat(otherFiles).filter(file => !!program.getSourceFile(file.unitName)); - let fullWalker = new TypeWriterWalker(program, /*fullTypeCheck:*/ true); - let pullWalker = new TypeWriterWalker(program, /*fullTypeCheck:*/ false); + const fullWalker = new TypeWriterWalker(program, /*fullTypeCheck:*/ true); + const pullWalker = new TypeWriterWalker(program, /*fullTypeCheck:*/ false); - let fullResults: ts.Map = {}; - let pullResults: ts.Map = {}; + const fullResults: ts.Map = {}; + const pullResults: ts.Map = {}; - for (let sourceFile of allFiles) { + for (const sourceFile of allFiles) { fullResults[sourceFile.unitName] = fullWalker.getTypeAndSymbols(sourceFile.unitName); pullResults[sourceFile.unitName] = fullWalker.getTypeAndSymbols(sourceFile.unitName); } @@ -294,11 +294,11 @@ class CompilerBaselineRunner extends RunnerBase { return; function checkBaseLines(isSymbolBaseLine: boolean) { - let fullBaseLine = generateBaseLine(fullResults, isSymbolBaseLine); - let pullBaseLine = generateBaseLine(pullResults, isSymbolBaseLine); + const fullBaseLine = generateBaseLine(fullResults, isSymbolBaseLine); + const pullBaseLine = generateBaseLine(pullResults, isSymbolBaseLine); - let fullExtension = isSymbolBaseLine ? ".symbols" : ".types"; - let pullExtension = isSymbolBaseLine ? ".symbols.pull" : ".types.pull"; + const fullExtension = isSymbolBaseLine ? ".symbols" : ".types"; + const pullExtension = isSymbolBaseLine ? ".symbols.pull" : ".types.pull"; if (fullBaseLine !== pullBaseLine) { Harness.Baseline.runBaseline("Correct full information for " + fileName, justName.replace(/\.tsx?/, fullExtension), () => fullBaseLine); @@ -310,24 +310,24 @@ class CompilerBaselineRunner extends RunnerBase { } function generateBaseLine(typeWriterResults: ts.Map, isSymbolBaseline: boolean): string { - let typeLines: string[] = []; - let typeMap: { [fileName: string]: { [lineNum: number]: string[]; } } = {}; + const typeLines: string[] = []; + const typeMap: { [fileName: string]: { [lineNum: number]: string[]; } } = {}; allFiles.forEach(file => { - let codeLines = file.content.split("\n"); + const codeLines = file.content.split("\n"); typeWriterResults[file.unitName].forEach(result => { if (isSymbolBaseline && !result.symbol) { return; } - let typeOrSymbolString = isSymbolBaseline ? result.symbol : result.type; - let formattedLine = result.sourceText.replace(/\r?\n/g, "") + " : " + typeOrSymbolString; + const typeOrSymbolString = isSymbolBaseline ? result.symbol : result.type; + const formattedLine = result.sourceText.replace(/\r?\n/g, "") + " : " + typeOrSymbolString; if (!typeMap[file.unitName]) { typeMap[file.unitName] = {}; } let typeInfo = [formattedLine]; - let existingTypeInfo = typeMap[file.unitName][result.line]; + const existingTypeInfo = typeMap[file.unitName][result.line]; if (existingTypeInfo) { typeInfo = existingTypeInfo.concat(typeInfo); } @@ -336,10 +336,10 @@ class CompilerBaselineRunner extends RunnerBase { typeLines.push("=== " + file.unitName + " ===\r\n"); for (let i = 0; i < codeLines.length; i++) { - let currentCodeLine = codeLines[i]; + const currentCodeLine = codeLines[i]; typeLines.push(currentCodeLine + "\r\n"); if (typeMap[file.unitName]) { - let typeInfo = typeMap[file.unitName][i]; + const typeInfo = typeMap[file.unitName][i]; if (typeInfo) { typeInfo.forEach(ty => { typeLines.push(">" + ty + "\r\n"); @@ -367,13 +367,13 @@ class CompilerBaselineRunner extends RunnerBase { public initializeTests() { describe(this.testSuiteName + " tests", () => { describe("Setup compiler for compiler baselines", () => { - let harnessCompiler = Harness.Compiler.getCompiler(); + const harnessCompiler = Harness.Compiler.getCompiler(); this.parseOptions(); }); // this will set up a series of describe/it blocks to run between the setup and cleanup phases if (this.tests.length === 0) { - let testFiles = this.enumerateFiles(this.basePath, /\.tsx?$/, { recursive: true }); + const testFiles = this.enumerateFiles(this.basePath, /\.tsx?$/, { recursive: true }); testFiles.forEach(fn => { fn = fn.replace(/\\/g, "/"); this.checkTestCodeOutput(fn); @@ -392,7 +392,7 @@ class CompilerBaselineRunner extends RunnerBase { this.decl = false; this.output = false; - let opts = this.options.split(","); + const opts = this.options.split(","); for (let i = 0; i < opts.length; i++) { switch (opts[i]) { case "error": diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts index 457ece7e132..bf8b9493829 100644 --- a/src/harness/fourslash.ts +++ b/src/harness/fourslash.ts @@ -102,7 +102,7 @@ namespace FourSlash { export import IndentStyle = ts.IndentStyle; - let entityMap: ts.Map = { + const entityMap: ts.Map = { "&": "&", "\"": """, "'": "'", @@ -118,7 +118,7 @@ namespace FourSlash { // Name of testcase metadata including ts.CompilerOptions properties that will be used by globalOptions // To add additional option, add property into the testOptMetadataNames, refer the property in either globalMetadataNames or fileMetadataNames // Add cases into convertGlobalOptionsToCompilationsSettings function for the compiler to acknowledge such option from meta data - let metadataOptionNames = { + const metadataOptionNames = { baselineFile: "BaselineFile", emitThisFile: "emitThisFile", // This flag is used for testing getEmitOutput feature. It allows test-cases to indicate what file to be output in multiple files project fileName: "Filename", @@ -126,10 +126,10 @@ namespace FourSlash { }; // List of allowed metadata names - let fileMetadataNames = [metadataOptionNames.fileName, metadataOptionNames.emitThisFile, metadataOptionNames.resolveReference]; + const fileMetadataNames = [metadataOptionNames.fileName, metadataOptionNames.emitThisFile, metadataOptionNames.resolveReference]; function convertGlobalOptionsToCompilerOptions(globalOptions: Harness.TestCaseParser.CompilerSettings): ts.CompilerOptions { - let settings: ts.CompilerOptions = { target: ts.ScriptTarget.ES5 }; + const settings: ts.CompilerOptions = { target: ts.ScriptTarget.ES5 }; Harness.Compiler.setCompilerOptionsFromHarnessSetting(globalOptions, settings); return settings; } @@ -224,7 +224,7 @@ namespace FourSlash { // Add input file which has matched file name with the given reference-file path. // This is necessary when resolveReference flag is specified private addMatchedInputFile(referenceFilePath: string) { - let inputFile = this.inputFiles[referenceFilePath]; + const inputFile = this.inputFiles[referenceFilePath]; if (inputFile && !Harness.isLibraryFile(referenceFilePath)) { this.languageServiceAdapterHost.addScript(referenceFilePath, inputFile); } @@ -248,8 +248,8 @@ namespace FourSlash { constructor(private basePath: string, private testType: FourSlashTestType, public testData: FourSlashData) { // Create a new Services Adapter this.cancellationToken = new TestCancellationToken(); - let compilationOptions = convertGlobalOptionsToCompilerOptions(this.testData.globalOptions); - let languageServiceAdapter = this.getLanguageServiceAdapter(testType, this.cancellationToken, compilationOptions); + const compilationOptions = convertGlobalOptionsToCompilerOptions(this.testData.globalOptions); + const languageServiceAdapter = this.getLanguageServiceAdapter(testType, this.cancellationToken, compilationOptions); this.languageServiceAdapterHost = languageServiceAdapter.getHost(); this.languageService = languageServiceAdapter.getLanguageService(); @@ -272,14 +272,14 @@ namespace FourSlash { // Add the entry-point file itself into the languageServiceShimHost this.languageServiceAdapterHost.addScript(startResolveFileRef.fileName, startResolveFileRef.content); - let resolvedResult = languageServiceAdapter.getPreProcessedFileInfo(startResolveFileRef.fileName, startResolveFileRef.content); - let referencedFiles: ts.FileReference[] = resolvedResult.referencedFiles; - let importedFiles: ts.FileReference[] = resolvedResult.importedFiles; + const resolvedResult = languageServiceAdapter.getPreProcessedFileInfo(startResolveFileRef.fileName, startResolveFileRef.content); + const referencedFiles: ts.FileReference[] = resolvedResult.referencedFiles; + const importedFiles: ts.FileReference[] = resolvedResult.importedFiles; // Add triple reference files into language-service host ts.forEach(referencedFiles, referenceFile => { // Fourslash insert tests/cases/fourslash into inputFile.unitName so we will properly append the same base directory to refFile path - let referenceFilePath = this.basePath + "/" + referenceFile.fileName; + const referenceFilePath = this.basePath + "/" + referenceFile.fileName; this.addMatchedInputFile(referenceFilePath); }); @@ -287,7 +287,7 @@ namespace FourSlash { ts.forEach(importedFiles, importedFile => { // Fourslash insert tests/cases/fourslash into inputFile.unitName and import statement doesn't require ".ts" // so convert them before making appropriate comparison - let importedFilePath = this.basePath + "/" + importedFile.fileName + ".ts"; + const importedFilePath = this.basePath + "/" + importedFile.fileName + ".ts"; this.addMatchedInputFile(importedFilePath); }); @@ -324,8 +324,8 @@ namespace FourSlash { }; this.testData.files.forEach(file => { - let fileName = file.fileName.replace(Harness.IO.directoryName(file.fileName), "").substr(1); - let fileNameWithoutExtension = fileName.substr(0, fileName.lastIndexOf(".")); + const fileName = file.fileName.replace(Harness.IO.directoryName(file.fileName), "").substr(1); + const fileNameWithoutExtension = fileName.substr(0, fileName.lastIndexOf(".")); this.scenarioActions.push(""); }); @@ -334,18 +334,18 @@ namespace FourSlash { } private getFileContent(fileName: string): string { - let script = this.languageServiceAdapterHost.getScriptInfo(fileName); + const script = this.languageServiceAdapterHost.getScriptInfo(fileName); return script.content; } // Entry points from fourslash.ts public goToMarker(name = "") { - let marker = this.getMarkerByName(name); + const marker = this.getMarkerByName(name); if (this.activeFile.fileName !== marker.fileName) { this.openFile(marker.fileName); } - let content = this.getFileContent(marker.fileName); + const content = this.getFileContent(marker.fileName); if (marker.position === -1 || marker.position > content.length) { throw new Error(`Marker "${name}" has been invalidated by unrecoverable edits to the file.`); } @@ -356,8 +356,8 @@ namespace FourSlash { public goToPosition(pos: number) { this.currentCaretPosition = pos; - let lineStarts = ts.computeLineStarts(this.getFileContent(this.activeFile.fileName)); - let lineCharPos = ts.computeLineAndCharacterOfPosition(lineStarts, pos); + const lineStarts = ts.computeLineStarts(this.getFileContent(this.activeFile.fileName)); + const lineCharPos = ts.computeLineAndCharacterOfPosition(lineStarts, pos); this.scenarioActions.push(``); } @@ -376,10 +376,10 @@ namespace FourSlash { public openFile(index: number): void; public openFile(name: string): void; public openFile(indexOrName: any) { - let fileToOpen: FourSlashFile = this.findFile(indexOrName); + const fileToOpen: FourSlashFile = this.findFile(indexOrName); fileToOpen.fileName = ts.normalizeSlashes(fileToOpen.fileName); this.activeFile = fileToOpen; - let fileName = fileToOpen.fileName.replace(Harness.IO.directoryName(fileToOpen.fileName), "").substr(1); + const fileName = fileToOpen.fileName.replace(Harness.IO.directoryName(fileToOpen.fileName), "").substr(1); this.scenarioActions.push(``); // Let the host know that this file is now open @@ -387,13 +387,13 @@ namespace FourSlash { } public verifyErrorExistsBetweenMarkers(startMarkerName: string, endMarkerName: string, negative: boolean) { - let startMarker = this.getMarkerByName(startMarkerName); - let endMarker = this.getMarkerByName(endMarkerName); - let predicate = function (errorMinChar: number, errorLimChar: number, startPos: number, endPos: number) { + 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; }; - let exists = this.anyErrorInRange(predicate, startMarker, endMarker); + const exists = this.anyErrorInRange(predicate, startMarker, endMarker); this.taoInvalidReason = "verifyErrorExistsBetweenMarkers NYI"; @@ -413,10 +413,10 @@ namespace FourSlash { } private getDiagnostics(fileName: string): ts.Diagnostic[] { - let syntacticErrors = this.languageService.getSyntacticDiagnostics(fileName); - let semanticErrors = this.languageService.getSemanticDiagnostics(fileName); + const syntacticErrors = this.languageService.getSyntacticDiagnostics(fileName); + const semanticErrors = this.languageService.getSemanticDiagnostics(fileName); - let diagnostics: ts.Diagnostic[] = []; + const diagnostics: ts.Diagnostic[] = []; diagnostics.push.apply(diagnostics, syntacticErrors); diagnostics.push.apply(diagnostics, semanticErrors); @@ -424,9 +424,9 @@ namespace FourSlash { } private getAllDiagnostics(): ts.Diagnostic[] { - let diagnostics: ts.Diagnostic[] = []; + const diagnostics: ts.Diagnostic[] = []; - let fileNames = this.languageServiceAdapterHost.getFilenames(); + const fileNames = this.languageServiceAdapterHost.getFilenames(); for (let i = 0, n = fileNames.length; i < n; i++) { diagnostics.push.apply(this.getDiagnostics(fileNames[i])); } @@ -435,7 +435,7 @@ namespace FourSlash { } public verifyErrorExistsAfterMarker(markerName: string, negative: boolean, after: boolean) { - let marker: Marker = this.getMarkerByName(markerName); + const marker: Marker = this.getMarkerByName(markerName); let predicate: (errorMinChar: number, errorLimChar: number, startPos: number, endPos: number) => boolean; if (after) { @@ -451,8 +451,8 @@ namespace FourSlash { this.taoInvalidReason = "verifyErrorExistsAfterMarker NYI"; - let exists = this.anyErrorInRange(predicate, marker); - let diagnostics = this.getAllDiagnostics(); + const exists = this.anyErrorInRange(predicate, marker); + const diagnostics = this.getAllDiagnostics(); if (exists !== negative) { this.printErrorLog(negative, diagnostics); @@ -462,10 +462,10 @@ namespace FourSlash { private anyErrorInRange(predicate: (errorMinChar: number, errorLimChar: number, startPos: number, endPos: number) => boolean, startMarker: Marker, endMarker?: Marker) { - let errors = this.getDiagnostics(startMarker.fileName); + const errors = this.getDiagnostics(startMarker.fileName); let exists = false; - let startPos = startMarker.position; + const startPos = startMarker.position; let endPos: number = undefined; if (endMarker !== undefined) { endPos = endMarker.position; @@ -496,40 +496,40 @@ namespace FourSlash { } public verifyNumberOfErrorsInCurrentFile(expected: number) { - let errors = this.getDiagnostics(this.activeFile.fileName); - let actual = errors.length; + const errors = this.getDiagnostics(this.activeFile.fileName); + const actual = errors.length; this.scenarioActions.push(``); if (actual !== expected) { this.printErrorLog(false, errors); - let errorMsg = "Actual number of errors (" + actual + ") does not match expected number (" + expected + ")"; + const errorMsg = "Actual number of errors (" + actual + ") does not match expected number (" + expected + ")"; Harness.IO.log(errorMsg); this.raiseError(errorMsg); } } public verifyEval(expr: string, value: any) { - let emit = this.languageService.getEmitOutput(this.activeFile.fileName); + const emit = this.languageService.getEmitOutput(this.activeFile.fileName); if (emit.outputFiles.length !== 1) { throw new Error("Expected exactly one output from emit of " + this.activeFile.fileName); } this.taoInvalidReason = "verifyEval impossible"; - let evaluation = new Function(`${emit.outputFiles[0].text};\r\nreturn (${expr});`)(); + const evaluation = new Function(`${emit.outputFiles[0].text};\r\nreturn (${expr});`)(); if (evaluation !== value) { this.raiseError(`Expected evaluation of expression "${expr}" to equal "${value}", but got "${evaluation}"`); } } public verifyGetEmitOutputForCurrentFile(expected: string): void { - let emit = this.languageService.getEmitOutput(this.activeFile.fileName); + const emit = this.languageService.getEmitOutput(this.activeFile.fileName); if (emit.outputFiles.length !== 1) { throw new Error("Expected exactly one output from emit of " + this.activeFile.fileName); } this.taoInvalidReason = "verifyGetEmitOutputForCurrentFile impossible"; - let actual = emit.outputFiles[0].text; + const actual = emit.outputFiles[0].text; if (actual !== expected) { this.raiseError(`Expected emit output to be "${expected}", but got "${actual}"`); } @@ -543,7 +543,7 @@ namespace FourSlash { this.taoInvalidReason = "verifyMemberListContains only supports the \"symbol\" parameter"; } - let members = this.getMemberListAtCaret(); + const members = this.getMemberListAtCaret(); if (members) { this.assertItemInCompletionList(members.entries, symbol, text, documentation, kind); } @@ -567,10 +567,10 @@ namespace FourSlash { this.scenarioActions.push(``); } - let members = this.getMemberListAtCaret(); + const members = this.getMemberListAtCaret(); if (members) { - let match = members.entries.length === expectedCount; + const match = members.entries.length === expectedCount; if ((!match && !negative) || (match && negative)) { this.raiseError("Member list count was " + members.entries.length + ". Expected " + expectedCount); @@ -585,7 +585,7 @@ namespace FourSlash { this.scenarioActions.push(""); this.scenarioActions.push(``); - let members = this.getMemberListAtCaret(); + const members = this.getMemberListAtCaret(); if (members && members.entries.filter(e => e.name === symbol).length !== 0) { this.raiseError(`Member list did contain ${symbol}`); } @@ -594,8 +594,8 @@ namespace FourSlash { public verifyCompletionListItemsCountIsGreaterThan(count: number, negative: boolean) { this.taoInvalidReason = "verifyCompletionListItemsCountIsGreaterThan NYI"; - let completions = this.getCompletionListAtCaret(); - let itemsCount = completions.entries.length; + const completions = this.getCompletionListAtCaret(); + const itemsCount = completions.entries.length; if (negative) { if (itemsCount > count) { @@ -617,7 +617,7 @@ namespace FourSlash { this.scenarioActions.push(""); } - let members = this.getMemberListAtCaret(); + const members = this.getMemberListAtCaret(); if ((!members || members.entries.length === 0) && negative) { this.raiseError("Member list is empty at Caret"); } @@ -637,7 +637,7 @@ namespace FourSlash { public verifyCompletionListIsEmpty(negative: boolean) { this.scenarioActions.push(""); - let completions = this.getCompletionListAtCaret(); + const completions = this.getCompletionListAtCaret(); if ((!completions || completions.entries.length === 0) && negative) { this.raiseError("Completion list is empty at caret at position " + this.activeFile.fileName + " " + this.currentCaretPosition); } @@ -654,7 +654,7 @@ namespace FourSlash { public verifyCompletionListAllowsNewIdentifier(negative: boolean) { - let completions = this.getCompletionListAtCaret(); + const completions = this.getCompletionListAtCaret(); if ((completions && !completions.isNewIdentifierLocation) && !negative) { this.raiseError("Expected builder completion entry"); @@ -665,7 +665,7 @@ namespace FourSlash { } public verifyCompletionListContains(symbol: string, text?: string, documentation?: string, kind?: string) { - let completions = this.getCompletionListAtCaret(); + const completions = this.getCompletionListAtCaret(); if (completions) { this.assertItemInCompletionList(completions.entries, symbol, text, documentation, kind); } @@ -685,11 +685,11 @@ namespace FourSlash { * @param expectedKind the kind of symbol (see ScriptElementKind) */ public verifyCompletionListDoesNotContain(symbol: string, expectedText?: string, expectedDocumentation?: string, expectedKind?: string) { - let that = this; + const that = this; function filterByTextOrDocumentation(entry: ts.CompletionEntry) { - let details = that.getCompletionEntryDetails(entry.name); - let documentation = ts.displayPartsToString(details.documentation); - let text = ts.displayPartsToString(details.displayParts); + const details = that.getCompletionEntryDetails(entry.name); + const documentation = ts.displayPartsToString(details.documentation); + const text = ts.displayPartsToString(details.displayParts); if (expectedText && expectedDocumentation) { return (documentation === expectedDocumentation && text === expectedText) ? true : false; } @@ -707,7 +707,7 @@ namespace FourSlash { this.scenarioActions.push(""); this.scenarioActions.push(``); - let completions = this.getCompletionListAtCaret(); + const completions = this.getCompletionListAtCaret(); if (completions) { let filterCompletions = completions.entries.filter(e => e.name === symbol); filterCompletions = expectedKind ? filterCompletions.filter(e => e.kind === expectedKind) : filterCompletions; @@ -717,7 +717,7 @@ namespace FourSlash { // then these symbols must meet the criterion for Not supposed to be in the list. So we // raise an error let error = "Completion list did contain \'" + symbol + "\'."; - let details = this.getCompletionEntryDetails(filterCompletions[0].name); + const details = this.getCompletionEntryDetails(filterCompletions[0].name); if (expectedText) { error += "Expected text: " + expectedText + " to equal: " + ts.displayPartsToString(details.displayParts) + "."; } @@ -735,7 +735,7 @@ namespace FourSlash { public verifyCompletionEntryDetails(entryName: string, expectedText: string, expectedDocumentation?: string, kind?: string) { this.taoInvalidReason = "verifyCompletionEntryDetails NYI"; - let details = this.getCompletionEntryDetails(entryName); + const details = this.getCompletionEntryDetails(entryName); assert.equal(ts.displayPartsToString(details.displayParts), expectedText, assertionMessage("completion entry details text")); @@ -751,14 +751,14 @@ namespace FourSlash { public verifyReferencesAtPositionListContains(fileName: string, start: number, end: number, isWriteAccess?: boolean) { this.taoInvalidReason = "verifyReferencesAtPositionListContains NYI"; - let references = this.getReferencesAtCaret(); + const references = this.getReferencesAtCaret(); if (!references || references.length === 0) { this.raiseError("verifyReferencesAtPositionListContains failed - found 0 references, expected at least one."); } for (let i = 0; i < references.length; i++) { - let reference = references[i]; + const reference = references[i]; if (reference && reference.fileName === fileName && reference.textSpan.start === start && ts.textSpanEnd(reference.textSpan) === end) { if (typeof isWriteAccess !== "undefined" && reference.isWriteAccess !== isWriteAccess) { this.raiseError(`verifyReferencesAtPositionListContains failed - item isWriteAccess value does not match, actual: ${reference.isWriteAccess}, expected: ${isWriteAccess}.`); @@ -767,18 +767,18 @@ namespace FourSlash { } } - let missingItem = { fileName: fileName, start: start, end: end, isWriteAccess: isWriteAccess }; + const missingItem = { fileName: fileName, start: start, end: end, isWriteAccess: isWriteAccess }; this.raiseError(`verifyReferencesAtPositionListContains failed - could not find the item: ${JSON.stringify(missingItem)} in the returned list: (${JSON.stringify(references)})`); } public verifyReferencesCountIs(count: number, localFilesOnly = true) { this.taoInvalidReason = "verifyReferences NYI"; - let references = this.getReferencesAtCaret(); + const references = this.getReferencesAtCaret(); let referencesCount = 0; if (localFilesOnly) { - let localFiles = this.testData.files.map(file => file.fileName); + const localFiles = this.testData.files.map(file => file.fileName); // Count only the references in local files. Filter the ones in lib and other files. ts.forEach(references, entry => { if (localFiles.some((fileName) => fileName === entry.fileName)) { @@ -791,7 +791,7 @@ namespace FourSlash { } if (referencesCount !== count) { - let condition = localFilesOnly ? "excluding libs" : "including libs"; + const condition = localFilesOnly ? "excluding libs" : "including libs"; this.raiseError("Expected references count (" + condition + ") to be " + count + ", but is actually " + referencesCount); } } @@ -817,18 +817,18 @@ namespace FourSlash { } public getSyntacticDiagnostics(expected: string) { - let diagnostics = this.languageService.getSyntacticDiagnostics(this.activeFile.fileName); + const diagnostics = this.languageService.getSyntacticDiagnostics(this.activeFile.fileName); this.testDiagnostics(expected, diagnostics); } public getSemanticDiagnostics(expected: string) { - let diagnostics = this.languageService.getSemanticDiagnostics(this.activeFile.fileName); + const diagnostics = this.languageService.getSemanticDiagnostics(this.activeFile.fileName); this.testDiagnostics(expected, diagnostics); } private testDiagnostics(expected: string, diagnostics: ts.Diagnostic[]) { - let realized = ts.realizeDiagnostics(diagnostics, "\r\n"); - let actual = JSON.stringify(realized, null, " "); + const realized = ts.realizeDiagnostics(diagnostics, "\r\n"); + const actual = JSON.stringify(realized, null, " "); assert.equal(actual, expected); } @@ -840,9 +840,9 @@ namespace FourSlash { } }); - let actualQuickInfo = this.languageService.getQuickInfoAtPosition(this.activeFile.fileName, this.currentCaretPosition); - let actualQuickInfoText = actualQuickInfo ? ts.displayPartsToString(actualQuickInfo.displayParts) : ""; - let actualQuickInfoDocumentation = actualQuickInfo ? ts.displayPartsToString(actualQuickInfo.documentation) : ""; + const actualQuickInfo = this.languageService.getQuickInfoAtPosition(this.activeFile.fileName, this.currentCaretPosition); + const actualQuickInfoText = actualQuickInfo ? ts.displayPartsToString(actualQuickInfo.displayParts) : ""; + const actualQuickInfoDocumentation = actualQuickInfo ? ts.displayPartsToString(actualQuickInfo.documentation) : ""; if (negative) { if (expectedText !== undefined) { @@ -888,7 +888,7 @@ namespace FourSlash { return result; } - let actualQuickInfo = this.languageService.getQuickInfoAtPosition(this.activeFile.fileName, this.currentCaretPosition); + const actualQuickInfo = this.languageService.getQuickInfoAtPosition(this.activeFile.fileName, this.currentCaretPosition); assert.equal(actualQuickInfo.kind, kind, this.messageAtLastKnownMarker("QuickInfo kind")); assert.equal(actualQuickInfo.kindModifiers, kindModifiers, this.messageAtLastKnownMarker("QuickInfo kindModifiers")); assert.equal(JSON.stringify(actualQuickInfo.textSpan), JSON.stringify(textSpan), this.messageAtLastKnownMarker("QuickInfo textSpan")); @@ -897,7 +897,7 @@ namespace FourSlash { } public verifyRenameLocations(findInStrings: boolean, findInComments: boolean) { - let renameInfo = this.languageService.getRenameInfo(this.activeFile.fileName, this.currentCaretPosition); + const renameInfo = this.languageService.getRenameInfo(this.activeFile.fileName, this.currentCaretPosition); if (renameInfo.canRename) { let references = this.languageService.findRenameLocations( this.activeFile.fileName, this.currentCaretPosition, findInStrings, findInComments); @@ -919,8 +919,8 @@ namespace FourSlash { references = references.sort((r1, r2) => r1.textSpan.start - r2.textSpan.start); for (let i = 0, n = ranges.length; i < n; i++) { - let reference = references[i]; - let range = ranges[i]; + const reference = references[i]; + const range = ranges[i]; if (reference.textSpan.start !== range.start || ts.textSpanEnd(reference.textSpan) !== range.end) { @@ -937,7 +937,7 @@ namespace FourSlash { public verifyQuickInfoExists(negative: boolean) { this.taoInvalidReason = "verifyQuickInfoExists NYI"; - let actualQuickInfo = this.languageService.getQuickInfoAtPosition(this.activeFile.fileName, this.currentCaretPosition); + const actualQuickInfo = this.languageService.getQuickInfoAtPosition(this.activeFile.fileName, this.currentCaretPosition); if (negative) { if (actualQuickInfo) { this.raiseError("verifyQuickInfoExists failed. Expected quick info NOT to exist"); @@ -953,7 +953,7 @@ namespace FourSlash { public verifyCurrentSignatureHelpIs(expected: string) { this.taoInvalidReason = "verifyCurrentSignatureHelpIs NYI"; - let help = this.getActiveSignatureHelpItem(); + const help = this.getActiveSignatureHelpItem(); assert.equal( ts.displayPartsToString(help.prefixDisplayParts) + help.parameters.map(p => ts.displayPartsToString(p.displayParts)).join(ts.displayPartsToString(help.separatorDisplayParts)) + @@ -963,7 +963,7 @@ namespace FourSlash { public verifyCurrentParameterIsletiable(isVariable: boolean) { this.taoInvalidReason = "verifyCurrentParameterIsletiable NYI"; - let signature = this.getActiveSignatureHelpItem(); + const signature = this.getActiveSignatureHelpItem(); assert.isNotNull(signature); assert.equal(isVariable, signature.isVariadic); } @@ -971,24 +971,24 @@ namespace FourSlash { public verifyCurrentParameterHelpName(name: string) { this.taoInvalidReason = "verifyCurrentParameterHelpName NYI"; - let activeParameter = this.getActiveParameter(); - let activeParameterName = activeParameter.name; + const activeParameter = this.getActiveParameter(); + const activeParameterName = activeParameter.name; assert.equal(activeParameterName, name); } public verifyCurrentParameterSpanIs(parameter: string) { this.taoInvalidReason = "verifyCurrentParameterSpanIs NYI"; - let activeSignature = this.getActiveSignatureHelpItem(); - let activeParameter = this.getActiveParameter(); + const activeSignature = this.getActiveSignatureHelpItem(); + const activeParameter = this.getActiveParameter(); assert.equal(ts.displayPartsToString(activeParameter.displayParts), parameter); } public verifyCurrentParameterHelpDocComment(docComment: string) { this.taoInvalidReason = "verifyCurrentParameterHelpDocComment NYI"; - let activeParameter = this.getActiveParameter(); - let activeParameterDocComment = activeParameter.documentation; + const activeParameter = this.getActiveParameter(); + const activeParameterDocComment = activeParameter.documentation; assert.equal(ts.displayPartsToString(activeParameterDocComment), docComment, assertionMessage("current parameter Help DocComment")); } @@ -1007,7 +1007,7 @@ namespace FourSlash { public verifyCurrentSignatureHelpDocComment(docComment: string) { this.taoInvalidReason = "verifyCurrentSignatureHelpDocComment NYI"; - let actualDocComment = this.getActiveSignatureHelpItem().documentation; + const actualDocComment = this.getActiveSignatureHelpItem().documentation; assert.equal(ts.displayPartsToString(actualDocComment), docComment, assertionMessage("current signature help doc comment")); } @@ -1015,22 +1015,22 @@ namespace FourSlash { this.scenarioActions.push(""); this.scenarioActions.push(``); - let help = this.languageService.getSignatureHelpItems(this.activeFile.fileName, this.currentCaretPosition); - let actual = help && help.items ? help.items.length : 0; + const help = this.languageService.getSignatureHelpItems(this.activeFile.fileName, this.currentCaretPosition); + const actual = help && help.items ? help.items.length : 0; assert.equal(actual, expected); } public verifySignatureHelpArgumentCount(expected: number) { this.taoInvalidReason = "verifySignatureHelpArgumentCount NYI"; - let signatureHelpItems = this.languageService.getSignatureHelpItems(this.activeFile.fileName, this.currentCaretPosition); - let actual = signatureHelpItems.argumentCount; + const signatureHelpItems = this.languageService.getSignatureHelpItems(this.activeFile.fileName, this.currentCaretPosition); + const actual = signatureHelpItems.argumentCount; assert.equal(actual, expected); } public verifySignatureHelpPresent(shouldBePresent = true) { this.taoInvalidReason = "verifySignatureHelpPresent NYI"; - let actual = this.languageService.getSignatureHelpItems(this.activeFile.fileName, this.currentCaretPosition); + const actual = this.languageService.getSignatureHelpItems(this.activeFile.fileName, this.currentCaretPosition); if (shouldBePresent) { if (!actual) { this.raiseError("Expected signature help to be present, but it wasn't"); @@ -1050,7 +1050,7 @@ namespace FourSlash { } public verifyRenameInfoSucceeded(displayName?: string, fullDisplayName?: string, kind?: string, kindModifiers?: string) { - let renameInfo = this.languageService.getRenameInfo(this.activeFile.fileName, this.currentCaretPosition); + const renameInfo = this.languageService.getRenameInfo(this.activeFile.fileName, this.currentCaretPosition); if (!renameInfo.canRename) { this.raiseError("Rename did not succeed"); } @@ -1064,7 +1064,7 @@ namespace FourSlash { this.raiseError("Expected a single range to be selected in the test file."); } - let expectedRange = this.getRanges()[0]; + const expectedRange = this.getRanges()[0]; if (renameInfo.triggerSpan.start !== expectedRange.start || ts.textSpanEnd(renameInfo.triggerSpan) !== expectedRange.end) { this.raiseError("Expected triggerSpan [" + expectedRange.start + "," + expectedRange.end + "). Got [" + @@ -1073,7 +1073,7 @@ namespace FourSlash { } public verifyRenameInfoFailed(message?: string) { - let renameInfo = this.languageService.getRenameInfo(this.activeFile.fileName, this.currentCaretPosition); + const renameInfo = this.languageService.getRenameInfo(this.activeFile.fileName, this.currentCaretPosition); if (renameInfo.canRename) { this.raiseError("Rename was expected to fail"); } @@ -1082,15 +1082,15 @@ namespace FourSlash { } private getActiveSignatureHelpItem() { - let help = this.languageService.getSignatureHelpItems(this.activeFile.fileName, this.currentCaretPosition); - let index = help.selectedItemIndex; + const help = this.languageService.getSignatureHelpItems(this.activeFile.fileName, this.currentCaretPosition); + const index = help.selectedItemIndex; return help.items[index]; } private getActiveParameter(): ts.SignatureHelpParameter { - let help = this.languageService.getSignatureHelpItems(this.activeFile.fileName, this.currentCaretPosition); - let item = help.items[help.selectedItemIndex]; - let currentParam = help.argumentIndex; + const help = this.languageService.getSignatureHelpItems(this.activeFile.fileName, this.currentCaretPosition); + const item = help.items[help.selectedItemIndex]; + const currentParam = help.argumentIndex; return item.parameters[currentParam]; } @@ -1099,8 +1099,8 @@ namespace FourSlash { private spanInfoToString(pos: number, spanInfo: ts.TextSpan, prefixString: string) { let resultString = "SpanInfo: " + JSON.stringify(spanInfo); if (spanInfo) { - let spanString = this.activeFile.content.substr(spanInfo.start, spanInfo.length); - let spanLineMap = ts.computeLineStarts(spanString); + const spanString = this.activeFile.content.substr(spanInfo.start, spanInfo.length); + const spanLineMap = ts.computeLineStarts(spanString); for (let i = 0; i < spanLineMap.length; i++) { if (!i) { resultString += "\n"; @@ -1114,17 +1114,17 @@ namespace FourSlash { } private baselineCurrentFileLocations(getSpanAtPos: (pos: number) => ts.TextSpan): string { - let fileLineMap = ts.computeLineStarts(this.activeFile.content); + const fileLineMap = ts.computeLineStarts(this.activeFile.content); let nextLine = 0; let resultString = ""; let currentLine: string; let previousSpanInfo: string; let startColumn: number; let length: number; - let prefixString = " >"; + const prefixString = " >"; let pos = 0; - let addSpanInfoString = () => { + const addSpanInfoString = () => { if (previousSpanInfo) { resultString += currentLine; let thisLineMarker = repeatString(startColumn, " ") + repeatString(length, "~"); @@ -1147,7 +1147,7 @@ namespace FourSlash { startColumn = 0; length = 0; } - let spanInfo = this.spanInfoToString(pos, getSpanAtPos(pos), prefixString); + const spanInfo = this.spanInfoToString(pos, getSpanAtPos(pos), prefixString); if (previousSpanInfo && previousSpanInfo !== spanInfo) { addSpanInfoString(); previousSpanInfo = spanInfo; @@ -1191,11 +1191,11 @@ namespace FourSlash { public baselineGetEmitOutput() { this.taoInvalidReason = "baselineGetEmitOutput impossible"; // Find file to be emitted - let emitFiles: FourSlashFile[] = []; // List of FourSlashFile that has emitThisFile flag on + const emitFiles: FourSlashFile[] = []; // List of FourSlashFile that has emitThisFile flag on - let allFourSlashFiles = this.testData.files; + const allFourSlashFiles = this.testData.files; for (let idx = 0; idx < allFourSlashFiles.length; ++idx) { - let file = allFourSlashFiles[idx]; + const file = allFourSlashFiles[idx]; if (file.fileOptions[metadataOptionNames.emitThisFile] === "true") { // Find a file with the flag emitThisFile turned on emitFiles.push(file); @@ -1214,20 +1214,20 @@ namespace FourSlash { let resultString = ""; // Loop through all the emittedFiles and emit them one by one emitFiles.forEach(emitFile => { - let emitOutput = this.languageService.getEmitOutput(emitFile.fileName); + const emitOutput = this.languageService.getEmitOutput(emitFile.fileName); // Print emitOutputStatus in readable format resultString += "EmitSkipped: " + emitOutput.emitSkipped + Harness.IO.newLine(); if (emitOutput.emitSkipped) { resultString += "Diagnostics:" + Harness.IO.newLine(); - let diagnostics = ts.getPreEmitDiagnostics(this.languageService.getProgram()); + const diagnostics = ts.getPreEmitDiagnostics(this.languageService.getProgram()); for (let i = 0, n = diagnostics.length; i < n; i++) { resultString += " " + diagnostics[0].messageText + Harness.IO.newLine(); } } emitOutput.outputFiles.forEach((outputFile, idx, array) => { - let fileName = "FileName : " + outputFile.name + Harness.IO.newLine(); + const fileName = "FileName : " + outputFile.name + Harness.IO.newLine(); resultString = resultString + fileName + outputFile.text; }); resultString += Harness.IO.newLine(); @@ -1247,19 +1247,19 @@ namespace FourSlash { } public printCurrentParameterHelp() { - let help = this.languageService.getSignatureHelpItems(this.activeFile.fileName, this.currentCaretPosition); + const help = this.languageService.getSignatureHelpItems(this.activeFile.fileName, this.currentCaretPosition); Harness.IO.log(JSON.stringify(help)); } public printCurrentQuickInfo() { - let quickInfo = this.languageService.getQuickInfoAtPosition(this.activeFile.fileName, this.currentCaretPosition); + const quickInfo = this.languageService.getQuickInfoAtPosition(this.activeFile.fileName, this.currentCaretPosition); Harness.IO.log(JSON.stringify(quickInfo)); } public printErrorList() { - let syntacticErrors = this.languageService.getSyntacticDiagnostics(this.activeFile.fileName); - let semanticErrors = this.languageService.getSemanticDiagnostics(this.activeFile.fileName); - let errorList = syntacticErrors.concat(semanticErrors); + const syntacticErrors = this.languageService.getSyntacticDiagnostics(this.activeFile.fileName); + const semanticErrors = this.languageService.getSemanticDiagnostics(this.activeFile.fileName); + const errorList = syntacticErrors.concat(semanticErrors); Harness.IO.log(`Error list (${errorList.length} errors)`); if (errorList.length) { @@ -1274,8 +1274,8 @@ namespace FourSlash { public printCurrentFileState(makeWhitespaceVisible = false, makeCaretVisible = true) { for (let i = 0; i < this.testData.files.length; i++) { - let file = this.testData.files[i]; - let active = (this.activeFile === file); + const file = this.testData.files[i]; + const active = (this.activeFile === file); Harness.IO.log(`=== Script (${file.fileName}) ${(active ? "(active, cursor at |)" : "")} ===`); let content = this.getFileContent(file.fileName); if (active) { @@ -1289,22 +1289,22 @@ namespace FourSlash { } public printCurrentSignatureHelp() { - let sigHelp = this.getActiveSignatureHelpItem(); + const sigHelp = this.getActiveSignatureHelpItem(); Harness.IO.log(JSON.stringify(sigHelp)); } public printMemberListMembers() { - let members = this.getMemberListAtCaret(); + const members = this.getMemberListAtCaret(); Harness.IO.log(JSON.stringify(members)); } public printCompletionListMembers() { - let completions = this.getCompletionListAtCaret(); + const completions = this.getCompletionListAtCaret(); Harness.IO.log(JSON.stringify(completions)); } public printReferences() { - let references = this.getReferencesAtCaret(); + const references = this.getReferencesAtCaret(); ts.forEach(references, entry => { Harness.IO.log(JSON.stringify(entry)); }); @@ -1318,9 +1318,9 @@ namespace FourSlash { this.scenarioActions.push(``); let offset = this.currentCaretPosition; - let ch = ""; + const ch = ""; - let checkCadence = (count >> 2) + 1; + const checkCadence = (count >> 2) + 1; for (let i = 0; i < count; i++) { // Make the edit @@ -1333,7 +1333,7 @@ namespace FourSlash { // Handle post-keystroke formatting if (this.enableFormatting) { - let edits = this.languageService.getFormattingEditsAfterKeystroke(this.activeFile.fileName, offset, ch, this.formatCodeOptions); + const edits = this.languageService.getFormattingEditsAfterKeystroke(this.activeFile.fileName, offset, ch, this.formatCodeOptions); if (edits.length) { offset += this.applyEdits(this.activeFile.fileName, edits, true); // this.checkPostEditInletiants(); @@ -1360,8 +1360,8 @@ namespace FourSlash { this.scenarioActions.push(``); let offset = this.currentCaretPosition; - let ch = ""; - let checkCadence = (count >> 2) + 1; + const ch = ""; + const checkCadence = (count >> 2) + 1; for (let i = 0; i < count; i++) { offset--; @@ -1375,7 +1375,7 @@ namespace FourSlash { // Handle post-keystroke formatting if (this.enableFormatting) { - let edits = this.languageService.getFormattingEditsAfterKeystroke(this.activeFile.fileName, offset, ch, this.formatCodeOptions); + const edits = this.languageService.getFormattingEditsAfterKeystroke(this.activeFile.fileName, offset, ch, this.formatCodeOptions); if (edits.length) { offset += this.applyEdits(this.activeFile.fileName, edits, true); } @@ -1406,12 +1406,12 @@ namespace FourSlash { // as much as possible private typeHighFidelity(text: string) { let offset = this.currentCaretPosition; - let prevChar = " "; - let checkCadence = (text.length >> 2) + 1; + const prevChar = " "; + const checkCadence = (text.length >> 2) + 1; for (let i = 0; i < text.length; i++) { // Make the edit - let ch = text.charAt(i); + const ch = text.charAt(i); this.languageServiceAdapterHost.editScript(this.activeFile.fileName, offset, offset, ch); this.languageService.getBraceMatchingAtPosition(this.activeFile.fileName, offset); @@ -1435,7 +1435,7 @@ namespace FourSlash { // Handle post-keystroke formatting if (this.enableFormatting) { - let edits = this.languageService.getFormattingEditsAfterKeystroke(this.activeFile.fileName, offset, ch, this.formatCodeOptions); + const edits = this.languageService.getFormattingEditsAfterKeystroke(this.activeFile.fileName, offset, ch, this.formatCodeOptions); if (edits.length) { offset += this.applyEdits(this.activeFile.fileName, edits, true); // this.checkPostEditInletiants(); @@ -1454,7 +1454,7 @@ namespace FourSlash { public paste(text: string) { this.scenarioActions.push(``); - let start = this.currentCaretPosition; + const start = this.currentCaretPosition; let offset = this.currentCaretPosition; this.languageServiceAdapterHost.editScript(this.activeFile.fileName, offset, offset, text); this.updateMarkersForEdit(this.activeFile.fileName, offset, offset, text); @@ -1463,7 +1463,7 @@ namespace FourSlash { // Handle formatting if (this.enableFormatting) { - let edits = this.languageService.getFormattingEditsForRange(this.activeFile.fileName, start, offset, this.formatCodeOptions); + const edits = this.languageService.getFormattingEditsForRange(this.activeFile.fileName, start, offset, this.formatCodeOptions); if (edits.length) { offset += this.applyEdits(this.activeFile.fileName, edits, true); this.checkPostEditInletiants(); @@ -1484,17 +1484,17 @@ namespace FourSlash { return; } - let incrementalSourceFile = this.languageService.getSourceFile(this.activeFile.fileName); + const incrementalSourceFile = this.languageService.getSourceFile(this.activeFile.fileName); Utils.assertInvariants(incrementalSourceFile, /*parent:*/ undefined); - let incrementalSyntaxDiagnostics = incrementalSourceFile.parseDiagnostics; + const incrementalSyntaxDiagnostics = incrementalSourceFile.parseDiagnostics; // Check syntactic structure - let content = this.getFileContent(this.activeFile.fileName); + const content = this.getFileContent(this.activeFile.fileName); - let referenceSourceFile = ts.createLanguageServiceSourceFile( + const referenceSourceFile = ts.createLanguageServiceSourceFile( this.activeFile.fileName, createScriptSnapShot(content), ts.ScriptTarget.Latest, /*version:*/ "0", /*setNodeParents:*/ false); - let referenceSyntaxDiagnostics = referenceSourceFile.parseDiagnostics; + const referenceSyntaxDiagnostics = referenceSourceFile.parseDiagnostics; Utils.assertDiagnosticsEquals(incrementalSyntaxDiagnostics, referenceSyntaxDiagnostics); Utils.assertStructuralEquals(incrementalSourceFile, referenceSourceFile); @@ -1504,7 +1504,7 @@ namespace FourSlash { // The caret can potentially end up between the \r and \n, which is confusing. If // that happens, move it back one character if (this.currentCaretPosition > 0) { - let ch = this.getFileContent(this.activeFile.fileName).substring(this.currentCaretPosition - 1, this.currentCaretPosition); + const ch = this.getFileContent(this.activeFile.fileName).substring(this.currentCaretPosition - 1, this.currentCaretPosition); if (ch === "\r") { this.currentCaretPosition--; } @@ -1517,18 +1517,18 @@ namespace FourSlash { let runningOffset = 0; edits = edits.sort((a, b) => a.span.start - b.span.start); // Get a snapshot of the content of the file so we can make sure any formatting edits didn't destroy non-whitespace characters - let oldContent = this.getFileContent(this.activeFile.fileName); + const oldContent = this.getFileContent(this.activeFile.fileName); for (let j = 0; j < edits.length; j++) { this.languageServiceAdapterHost.editScript(fileName, edits[j].span.start + runningOffset, ts.textSpanEnd(edits[j].span) + runningOffset, edits[j].newText); this.updateMarkersForEdit(fileName, edits[j].span.start + runningOffset, ts.textSpanEnd(edits[j].span) + runningOffset, edits[j].newText); - let change = (edits[j].span.start - ts.textSpanEnd(edits[j].span)) + edits[j].newText.length; + const change = (edits[j].span.start - ts.textSpanEnd(edits[j].span)) + edits[j].newText.length; runningOffset += change; // TODO: Consider doing this at least some of the time for higher fidelity. Currently causes a failure (bug 707150) // this.languageService.getScriptLexicalStructure(fileName); } if (isFormattingEdit) { - let newContent = this.getFileContent(fileName); + const newContent = this.getFileContent(fileName); if (newContent.replace(/\s/g, "") !== oldContent.replace(/\s/g, "")) { this.raiseError("Formatting operation destroyed non-whitespace content"); @@ -1542,7 +1542,7 @@ namespace FourSlash { } public setFormatOptions(formatCodeOptions: ts.FormatCodeOptions): ts.FormatCodeOptions { - let oldFormatCodeOptions = this.formatCodeOptions; + const oldFormatCodeOptions = this.formatCodeOptions; this.formatCodeOptions = formatCodeOptions; return oldFormatCodeOptions; } @@ -1550,7 +1550,7 @@ namespace FourSlash { public formatDocument() { this.scenarioActions.push(""); - let edits = this.languageService.getFormattingEditsForDocument(this.activeFile.fileName, this.formatCodeOptions); + const edits = this.languageService.getFormattingEditsForDocument(this.activeFile.fileName, this.formatCodeOptions); this.currentCaretPosition += this.applyEdits(this.activeFile.fileName, edits, true); this.fixCaretPosition(); } @@ -1558,14 +1558,14 @@ namespace FourSlash { public formatSelection(start: number, end: number) { this.taoInvalidReason = "formatSelection NYI"; - let edits = this.languageService.getFormattingEditsForRange(this.activeFile.fileName, start, end, this.formatCodeOptions); + const edits = this.languageService.getFormattingEditsForRange(this.activeFile.fileName, start, end, this.formatCodeOptions); this.currentCaretPosition += this.applyEdits(this.activeFile.fileName, edits, true); this.fixCaretPosition(); } private updateMarkersForEdit(fileName: string, minChar: number, limChar: number, text: string) { for (let i = 0; i < this.testData.markers.length; i++) { - let marker = this.testData.markers[i]; + const marker = this.testData.markers[i]; if (marker.fileName === fileName) { if (marker.position > minChar) { if (marker.position < limChar) { @@ -1586,7 +1586,7 @@ namespace FourSlash { } public goToEOF() { - let len = this.getFileContent(this.activeFile.fileName).length; + const len = this.getFileContent(this.activeFile.fileName).length; this.goToPosition(len); } @@ -1598,7 +1598,7 @@ namespace FourSlash { this.taoInvalidReason = "GoToDefinition not supported for non-zero definition indices"; } - let definitions = this.languageService.getDefinitionAtPosition(this.activeFile.fileName, this.currentCaretPosition); + const definitions = this.languageService.getDefinitionAtPosition(this.activeFile.fileName, this.currentCaretPosition); if (!definitions || !definitions.length) { this.raiseError("goToDefinition failed - expected to at least one definition location but got 0"); } @@ -1607,7 +1607,7 @@ namespace FourSlash { this.raiseError(`goToDefinition failed - definitionIndex value (${definitionIndex}) exceeds definition list size (${definitions.length})`); } - let definition = definitions[definitionIndex]; + const definition = definitions[definitionIndex]; this.openFile(definition.fileName); this.currentCaretPosition = definition.textSpan.start; } @@ -1620,7 +1620,7 @@ namespace FourSlash { this.taoInvalidReason = "GoToTypeDefinition not supported for non-zero definition indices"; } - let definitions = this.languageService.getTypeDefinitionAtPosition(this.activeFile.fileName, this.currentCaretPosition); + const definitions = this.languageService.getTypeDefinitionAtPosition(this.activeFile.fileName, this.currentCaretPosition); if (!definitions || !definitions.length) { this.raiseError("goToTypeDefinition failed - expected to at least one definition location but got 0"); } @@ -1629,7 +1629,7 @@ namespace FourSlash { this.raiseError(`goToTypeDefinition failed - definitionIndex value (${definitionIndex}) exceeds definition list size (${definitions.length})`); } - let definition = definitions[definitionIndex]; + const definition = definitions[definitionIndex]; this.openFile(definition.fileName); this.currentCaretPosition = definition.textSpan.start; } @@ -1637,9 +1637,9 @@ namespace FourSlash { public verifyDefinitionLocationExists(negative: boolean) { this.taoInvalidReason = "verifyDefinitionLocationExists NYI"; - let definitions = this.languageService.getDefinitionAtPosition(this.activeFile.fileName, this.currentCaretPosition); + const definitions = this.languageService.getDefinitionAtPosition(this.activeFile.fileName, this.currentCaretPosition); - let foundDefinitions = definitions && definitions.length; + const foundDefinitions = definitions && definitions.length; if (foundDefinitions && negative) { this.raiseError(`goToDefinition - expected to 0 definition locations but got ${definitions.length}`); @@ -1650,19 +1650,19 @@ namespace FourSlash { } public verifyDefinitionsCount(negative: boolean, expectedCount: number) { - let assertFn = negative ? assert.notEqual : assert.equal; + const assertFn = negative ? assert.notEqual : assert.equal; - let definitions = this.languageService.getDefinitionAtPosition(this.activeFile.fileName, this.currentCaretPosition); - let actualCount = definitions && definitions.length || 0; + const definitions = this.languageService.getDefinitionAtPosition(this.activeFile.fileName, this.currentCaretPosition); + const actualCount = definitions && definitions.length || 0; assertFn(actualCount, expectedCount, this.messageAtLastKnownMarker("Definitions Count")); } public verifyTypeDefinitionsCount(negative: boolean, expectedCount: number) { - let assertFn = negative ? assert.notEqual : assert.equal; + const assertFn = negative ? assert.notEqual : assert.equal; - let definitions = this.languageService.getTypeDefinitionAtPosition(this.activeFile.fileName, this.currentCaretPosition); - let actualCount = definitions && definitions.length || 0; + const definitions = this.languageService.getTypeDefinitionAtPosition(this.activeFile.fileName, this.currentCaretPosition); + const actualCount = definitions && definitions.length || 0; assertFn(actualCount, expectedCount, this.messageAtLastKnownMarker("Type definitions Count")); } @@ -1670,9 +1670,9 @@ namespace FourSlash { public verifyDefinitionsName(negative: boolean, expectedName: string, expectedContainerName: string) { this.taoInvalidReason = "verifyDefinititionsInfo NYI"; - let definitions = this.languageService.getDefinitionAtPosition(this.activeFile.fileName, this.currentCaretPosition); - let actualDefinitionName = definitions && definitions.length ? definitions[0].name : ""; - let actualDefinitionContainerName = definitions && definitions.length ? definitions[0].containerName : ""; + const definitions = this.languageService.getDefinitionAtPosition(this.activeFile.fileName, this.currentCaretPosition); + const actualDefinitionName = definitions && definitions.length ? definitions[0].name : ""; + const actualDefinitionContainerName = definitions && definitions.length ? definitions[0].containerName : ""; if (negative) { assert.notEqual(actualDefinitionName, expectedName, this.messageAtLastKnownMarker("Definition Info Name")); assert.notEqual(actualDefinitionContainerName, expectedContainerName, this.messageAtLastKnownMarker("Definition Info Container Name")); @@ -1696,7 +1696,7 @@ namespace FourSlash { public verifyCaretAtMarker(markerName = "") { this.taoInvalidReason = "verifyCaretAtMarker NYI"; - let pos = this.getMarkerByName(markerName); + const pos = this.getMarkerByName(markerName); if (pos.fileName !== this.activeFile.fileName) { throw new Error(`verifyCaretAtMarker failed - expected to be in file "${pos.fileName}", but was in file "${this.activeFile.fileName}"`); } @@ -1707,7 +1707,7 @@ namespace FourSlash { private getIndentation(fileName: string, position: number, indentStyle: ts.IndentStyle): number { - let formatOptions = ts.clone(this.formatCodeOptions); + const formatOptions = ts.clone(this.formatCodeOptions); formatOptions.IndentStyle = indentStyle; return this.languageService.getIndentationAtPosition(fileName, position, formatOptions); @@ -1716,8 +1716,8 @@ namespace FourSlash { public verifyIndentationAtCurrentPosition(numberOfSpaces: number, indentStyle: ts.IndentStyle = ts.IndentStyle.Smart) { this.taoInvalidReason = "verifyIndentationAtCurrentPosition NYI"; - let actual = this.getIndentation(this.activeFile.fileName, this.currentCaretPosition, indentStyle); - let lineCol = this.getLineColStringAtPosition(this.currentCaretPosition); + const actual = this.getIndentation(this.activeFile.fileName, this.currentCaretPosition, indentStyle); + const lineCol = this.getLineColStringAtPosition(this.currentCaretPosition); if (actual !== numberOfSpaces) { this.raiseError(`verifyIndentationAtCurrentPosition failed at ${lineCol} - expected: ${numberOfSpaces}, actual: ${actual}`); } @@ -1726,8 +1726,8 @@ namespace FourSlash { public verifyIndentationAtPosition(fileName: string, position: number, numberOfSpaces: number, indentStyle: ts.IndentStyle = ts.IndentStyle.Smart) { this.taoInvalidReason = "verifyIndentationAtPosition NYI"; - let actual = this.getIndentation(fileName, position, indentStyle); - let lineCol = this.getLineColStringAtPosition(position); + const actual = this.getIndentation(fileName, position, indentStyle); + const lineCol = this.getLineColStringAtPosition(position); if (actual !== numberOfSpaces) { this.raiseError(`verifyIndentationAtPosition failed at ${lineCol} - expected: ${numberOfSpaces}, actual: ${actual}`); } @@ -1736,7 +1736,7 @@ namespace FourSlash { public verifyCurrentLineContent(text: string) { this.taoInvalidReason = "verifyCurrentLineContent NYI"; - let actual = this.getCurrentLineContent(); + const actual = this.getCurrentLineContent(); if (actual !== text) { throw new Error("verifyCurrentLineContent\n" + "\tExpected: \"" + text + "\"\n" + @@ -1747,8 +1747,8 @@ namespace FourSlash { public verifyCurrentFileContent(text: string) { this.taoInvalidReason = "verifyCurrentFileContent NYI"; - let actual = this.getFileContent(this.activeFile.fileName); - let replaceNewlines = (str: string) => str.replace(/\r\n/g, "\n"); + const actual = this.getFileContent(this.activeFile.fileName); + const replaceNewlines = (str: string) => str.replace(/\r\n/g, "\n"); if (replaceNewlines(actual) !== replaceNewlines(text)) { throw new Error("verifyCurrentFileContent\n" + "\tExpected: \"" + text + "\"\n" + @@ -1759,7 +1759,7 @@ namespace FourSlash { public verifyTextAtCaretIs(text: string) { this.taoInvalidReason = "verifyCurrentFileContent NYI"; - let actual = this.getFileContent(this.activeFile.fileName).substring(this.currentCaretPosition, this.currentCaretPosition + text.length); + const actual = this.getFileContent(this.activeFile.fileName).substring(this.currentCaretPosition, this.currentCaretPosition + text.length); if (actual !== text) { throw new Error("verifyTextAtCaretIs\n" + "\tExpected: \"" + text + "\"\n" + @@ -1770,14 +1770,14 @@ namespace FourSlash { public verifyCurrentNameOrDottedNameSpanText(text: string) { this.taoInvalidReason = "verifyCurrentNameOrDottedNameSpanText NYI"; - let span = this.languageService.getNameOrDottedNameSpan(this.activeFile.fileName, this.currentCaretPosition, this.currentCaretPosition); + const span = this.languageService.getNameOrDottedNameSpan(this.activeFile.fileName, this.currentCaretPosition, this.currentCaretPosition); if (!span) { this.raiseError("verifyCurrentNameOrDottedNameSpanText\n" + "\tExpected: \"" + text + "\"\n" + "\t Actual: undefined"); } - let actual = this.getFileContent(this.activeFile.fileName).substring(span.start, ts.textSpanEnd(span)); + const actual = this.getFileContent(this.activeFile.fileName).substring(span.start, ts.textSpanEnd(span)); if (actual !== text) { this.raiseError("verifyCurrentNameOrDottedNameSpanText\n" + "\tExpected: \"" + text + "\"\n" + @@ -1815,10 +1815,10 @@ namespace FourSlash { } for (let i = 0; i < expected.length; i++) { - let expectedClassification = expected[i]; - let actualClassification = actual[i]; + const expectedClassification = expected[i]; + const actualClassification = actual[i]; - let expectedType: string = (ts.ClassificationTypeNames)[expectedClassification.classificationType]; + const expectedType: string = (ts.ClassificationTypeNames)[expectedClassification.classificationType]; if (expectedType !== actualClassification.classificationType) { this.raiseError("verifyClassifications failed - expected classifications type to be " + expectedType + ", but was " + @@ -1826,11 +1826,11 @@ namespace FourSlash { jsonMismatchString()); } - let expectedSpan = expectedClassification.textSpan; - let actualSpan = actualClassification.textSpan; + const expectedSpan = expectedClassification.textSpan; + const actualSpan = actualClassification.textSpan; if (expectedSpan) { - let expectedLength = expectedSpan.end - expectedSpan.start; + const expectedLength = expectedSpan.end - expectedSpan.start; if (expectedSpan.start !== actualSpan.start || expectedLength !== actualSpan.length) { this.raiseError("verifyClassifications failed - expected span of text to be " + @@ -1840,7 +1840,7 @@ namespace FourSlash { } } - let actualText = this.activeFile.content.substr(actualSpan.start, actualSpan.length); + const actualText = this.activeFile.content.substr(actualSpan.start, actualSpan.length); if (expectedClassification.text !== actualText) { this.raiseError("verifyClassifications failed - expected classified text to be " + expectedClassification.text + ", but was " + @@ -1858,7 +1858,7 @@ namespace FourSlash { public verifyProjectInfo(expected: string[]) { if (this.testType === FourSlashTestType.Server) { - let actual = (this.languageService).getProjectInfo( + const actual = (this.languageService).getProjectInfo( this.activeFile.fileName, /* needFileNameList */ true ); @@ -1872,14 +1872,14 @@ namespace FourSlash { } public verifySemanticClassifications(expected: { classificationType: string; text: string }[]) { - let actual = this.languageService.getSemanticClassifications(this.activeFile.fileName, + const actual = this.languageService.getSemanticClassifications(this.activeFile.fileName, ts.createTextSpan(0, this.activeFile.content.length)); this.verifyClassifications(expected, actual); } public verifySyntacticClassifications(expected: { classificationType: string; text: string }[]) { - let actual = this.languageService.getSyntacticClassifications(this.activeFile.fileName, + const actual = this.languageService.getSyntacticClassifications(this.activeFile.fileName, ts.createTextSpan(0, this.activeFile.content.length)); this.verifyClassifications(expected, actual); @@ -1888,15 +1888,15 @@ namespace FourSlash { public verifyOutliningSpans(spans: TextSpan[]) { this.taoInvalidReason = "verifyOutliningSpans NYI"; - let actual = this.languageService.getOutliningSpans(this.activeFile.fileName); + const actual = this.languageService.getOutliningSpans(this.activeFile.fileName); if (actual.length !== spans.length) { this.raiseError(`verifyOutliningSpans failed - expected total spans to be ${spans.length}, but was ${actual.length}`); } for (let i = 0; i < spans.length; i++) { - let expectedSpan = spans[i]; - let actualSpan = actual[i]; + const expectedSpan = spans[i]; + const actualSpan = actual[i]; if (expectedSpan.start !== actualSpan.textSpan.start || expectedSpan.end !== ts.textSpanEnd(actualSpan.textSpan)) { this.raiseError(`verifyOutliningSpans failed - span ${(i + 1)} expected: (${expectedSpan.start},${expectedSpan.end}), actual: (${actualSpan.textSpan.start},${ts.textSpanEnd(actualSpan.textSpan)})`); } @@ -1904,7 +1904,7 @@ namespace FourSlash { } public verifyTodoComments(descriptors: string[], spans: TextSpan[]) { - let actual = this.languageService.getTodoComments(this.activeFile.fileName, + const actual = this.languageService.getTodoComments(this.activeFile.fileName, descriptors.map(d => { return { text: d, priority: 0 }; })); if (actual.length !== spans.length) { @@ -1912,9 +1912,9 @@ namespace FourSlash { } for (let i = 0; i < spans.length; i++) { - let expectedSpan = spans[i]; - let actualComment = actual[i]; - let actualCommentSpan = ts.createTextSpan(actualComment.position, actualComment.message.length); + const expectedSpan = spans[i]; + const actualComment = actual[i]; + const actualCommentSpan = ts.createTextSpan(actualComment.position, actualComment.message.length); if (expectedSpan.start !== actualCommentSpan.start || expectedSpan.end !== ts.textSpanEnd(actualCommentSpan)) { this.raiseError(`verifyOutliningSpans failed - span ${(i + 1)} expected: (${expectedSpan.start},${expectedSpan.end}), actual: (${actualCommentSpan.start},${ts.textSpanEnd(actualCommentSpan)})`); @@ -1924,7 +1924,7 @@ namespace FourSlash { public verifyDocCommentTemplate(expected?: ts.TextInsertion) { const name = "verifyDocCommentTemplate"; - let actual = this.languageService.getDocCommentTemplateAtPosition(this.activeFile.fileName, this.currentCaretPosition); + const actual = this.languageService.getDocCommentTemplateAtPosition(this.activeFile.fileName, this.currentCaretPosition); if (expected === undefined) { if (actual) { @@ -1958,7 +1958,7 @@ namespace FourSlash { public verifyMatchingBracePosition(bracePosition: number, expectedMatchPosition: number) { this.taoInvalidReason = "verifyMatchingBracePosition NYI"; - let actual = this.languageService.getBraceMatchingAtPosition(this.activeFile.fileName, bracePosition); + const actual = this.languageService.getBraceMatchingAtPosition(this.activeFile.fileName, bracePosition); if (actual.length !== 2) { this.raiseError(`verifyMatchingBracePosition failed - expected result to contain 2 spans, but it had ${actual.length}`); @@ -1983,7 +1983,7 @@ namespace FourSlash { public verifyNoMatchingBracePosition(bracePosition: number) { this.taoInvalidReason = "verifyNoMatchingBracePosition NYI"; - let actual = this.languageService.getBraceMatchingAtPosition(this.activeFile.fileName, bracePosition); + const actual = this.languageService.getBraceMatchingAtPosition(this.activeFile.fileName, bracePosition); if (actual.length !== 0) { this.raiseError("verifyNoMatchingBracePosition failed - expected: 0 spans, actual: " + actual.length); @@ -1997,7 +1997,7 @@ namespace FourSlash { public verifyNavigationItemsCount(expected: number, searchValue: string, matchKind?: string) { this.taoInvalidReason = "verifyNavigationItemsCount NYI"; - let items = this.languageService.getNavigateToItems(searchValue); + const items = this.languageService.getNavigateToItems(searchValue); let actual = 0; let item: ts.NavigateToItem = null; @@ -2027,14 +2027,14 @@ namespace FourSlash { parentName?: string) { this.taoInvalidReason = "verifyNavigationItemsListContains NYI"; - let items = this.languageService.getNavigateToItems(searchValue); + const items = this.languageService.getNavigateToItems(searchValue); if (!items || items.length === 0) { this.raiseError("verifyNavigationItemsListContains failed - found 0 navigation items, expected at least one."); } for (let i = 0; i < items.length; i++) { - let item = items[i]; + const item = items[i]; if (item && item.name === name && item.kind === kind && (matchKind === undefined || item.matchKind === matchKind) && (fileName === undefined || item.fileName === fileName) && @@ -2045,7 +2045,7 @@ namespace FourSlash { // if there was an explicit match kind specified, then it should be validated. if (matchKind !== undefined) { - let missingItem = { name: name, kind: kind, searchValue: searchValue, matchKind: matchKind, fileName: fileName, parentName: parentName }; + const missingItem = { name: name, kind: kind, searchValue: searchValue, matchKind: matchKind, fileName: fileName, parentName: parentName }; this.raiseError(`verifyNavigationItemsListContains failed - could not find the item: ${JSON.stringify(missingItem)} in the returned list: (${JSON.stringify(items)})`); } } @@ -2053,8 +2053,8 @@ namespace FourSlash { public verifyGetScriptLexicalStructureListCount(expected: number) { this.taoInvalidReason = "verifyNavigationItemsListContains impossible"; - let items = this.languageService.getNavigationBarItems(this.activeFile.fileName); - let actual = this.getNavigationBarItemsCount(items); + const items = this.languageService.getNavigationBarItems(this.activeFile.fileName); + const actual = this.getNavigationBarItemsCount(items); if (expected !== actual) { this.raiseError(`verifyGetScriptLexicalStructureListCount failed - found: ${actual} navigation items, expected: ${expected}.`); @@ -2076,7 +2076,7 @@ namespace FourSlash { public verifyGetScriptLexicalStructureListContains(name: string, kind: string) { this.taoInvalidReason = "verifyGetScriptLexicalStructureListContains impossible"; - let items = this.languageService.getNavigationBarItems(this.activeFile.fileName); + const items = this.languageService.getNavigationBarItems(this.activeFile.fileName); if (!items || items.length === 0) { this.raiseError("verifyGetScriptLexicalStructureListContains failed - found 0 navigation items, expected at least one."); @@ -2086,14 +2086,14 @@ namespace FourSlash { return; } - let missingItem = { name: name, kind: kind }; + const missingItem = { name: name, kind: kind }; this.raiseError(`verifyGetScriptLexicalStructureListContains failed - could not find the item: ${JSON.stringify(missingItem)} in the returned list: (${JSON.stringify(items, null, " ")})`); } private navigationBarItemsContains(items: ts.NavigationBarItem[], name: string, kind: string) { if (items) { for (let i = 0; i < items.length; i++) { - let item = items[i]; + const item = items[i]; if (item && item.text === name && item.kind === kind) { return true; } @@ -2108,25 +2108,25 @@ namespace FourSlash { } public printNavigationItems(searchValue: string) { - let items = this.languageService.getNavigateToItems(searchValue); - let length = items && items.length; + const items = this.languageService.getNavigateToItems(searchValue); + const length = items && items.length; Harness.IO.log(`NavigationItems list (${length} items)`); for (let i = 0; i < length; i++) { - let item = items[i]; + const item = items[i]; Harness.IO.log(`name: ${item.name}, kind: ${item.kind}, parentName: ${item.containerName}, fileName: ${item.fileName}`); } } public printScriptLexicalStructureItems() { - let items = this.languageService.getNavigationBarItems(this.activeFile.fileName); - let length = items && items.length; + const items = this.languageService.getNavigationBarItems(this.activeFile.fileName); + const length = items && items.length; Harness.IO.log(`NavigationItems list (${length} items)`); for (let i = 0; i < length; i++) { - let item = items[i]; + const item = items[i]; Harness.IO.log(`name: ${item.text}, kind: ${item.kind}`); } } @@ -2138,13 +2138,13 @@ namespace FourSlash { public verifyOccurrencesAtPositionListContains(fileName: string, start: number, end: number, isWriteAccess?: boolean) { this.taoInvalidReason = "verifyOccurrencesAtPositionListContains NYI"; - let occurrences = this.getOccurrencesAtCurrentPosition(); + const occurrences = this.getOccurrencesAtCurrentPosition(); if (!occurrences || occurrences.length === 0) { this.raiseError("verifyOccurrencesAtPositionListContains failed - found 0 references, expected at least one."); } - for (let occurrence of occurrences) { + for (const occurrence of occurrences) { if (occurrence && occurrence.fileName === fileName && occurrence.textSpan.start === start && ts.textSpanEnd(occurrence.textSpan) === end) { if (typeof isWriteAccess !== "undefined" && occurrence.isWriteAccess !== isWriteAccess) { this.raiseError(`verifyOccurrencesAtPositionListContains failed - item isWriteAccess value does not match, actual: ${occurrence.isWriteAccess}, expected: ${isWriteAccess}.`); @@ -2153,39 +2153,39 @@ namespace FourSlash { } } - let missingItem = { fileName: fileName, start: start, end: end, isWriteAccess: isWriteAccess }; + const missingItem = { fileName: fileName, start: start, end: end, isWriteAccess: isWriteAccess }; this.raiseError(`verifyOccurrencesAtPositionListContains failed - could not find the item: ${JSON.stringify(missingItem)} in the returned list: (${JSON.stringify(occurrences)})`); } public verifyOccurrencesAtPositionListCount(expectedCount: number) { this.taoInvalidReason = "verifyOccurrencesAtPositionListCount NYI"; - let occurrences = this.getOccurrencesAtCurrentPosition(); - let actualCount = occurrences ? occurrences.length : 0; + const occurrences = this.getOccurrencesAtCurrentPosition(); + const actualCount = occurrences ? occurrences.length : 0; if (expectedCount !== actualCount) { this.raiseError(`verifyOccurrencesAtPositionListCount failed - actual: ${actualCount}, expected:${expectedCount}`); } } private getDocumentHighlightsAtCurrentPosition(fileNamesToSearch: string[]) { - let filesToSearch = fileNamesToSearch.map(name => ts.combinePaths(this.basePath, name)); + const filesToSearch = fileNamesToSearch.map(name => ts.combinePaths(this.basePath, name)); return this.languageService.getDocumentHighlights(this.activeFile.fileName, this.currentCaretPosition, filesToSearch); } public verifyDocumentHighlightsAtPositionListContains(fileName: string, start: number, end: number, fileNamesToSearch: string[], kind?: string) { this.taoInvalidReason = "verifyDocumentHighlightsAtPositionListContains NYI"; - let documentHighlights = this.getDocumentHighlightsAtCurrentPosition(fileNamesToSearch); + const documentHighlights = this.getDocumentHighlightsAtCurrentPosition(fileNamesToSearch); if (!documentHighlights || documentHighlights.length === 0) { this.raiseError("verifyDocumentHighlightsAtPositionListContains failed - found 0 highlights, expected at least one."); } - for (let documentHighlight of documentHighlights) { + for (const documentHighlight of documentHighlights) { if (documentHighlight.fileName === fileName) { - let { highlightSpans } = documentHighlight; + const { highlightSpans } = documentHighlight; - for (let highlight of highlightSpans) { + for (const highlight of highlightSpans) { if (highlight && highlight.textSpan.start === start && ts.textSpanEnd(highlight.textSpan) === end) { if (typeof kind !== "undefined" && highlight.kind !== kind) { this.raiseError(`verifyDocumentHighlightsAtPositionListContains failed - item "kind" value does not match, actual: ${highlight.kind}, expected: ${kind}.`); @@ -2196,15 +2196,15 @@ namespace FourSlash { } } - let missingItem = { fileName: fileName, start: start, end: end, kind: kind }; + const missingItem = { fileName: fileName, start: start, end: end, kind: kind }; this.raiseError(`verifyDocumentHighlightsAtPositionListContains failed - could not find the item: ${JSON.stringify(missingItem)} in the returned list: (${JSON.stringify(documentHighlights)})`); } public verifyDocumentHighlightsAtPositionListCount(expectedCount: number, fileNamesToSearch: string[]) { this.taoInvalidReason = "verifyDocumentHighlightsAtPositionListCount NYI"; - let documentHighlights = this.getDocumentHighlightsAtCurrentPosition(fileNamesToSearch); - let actualCount = documentHighlights + const documentHighlights = this.getDocumentHighlightsAtCurrentPosition(fileNamesToSearch); + const actualCount = documentHighlights ? documentHighlights.reduce((currentCount, { highlightSpans }) => currentCount + highlightSpans.length, 0) : 0; @@ -2215,13 +2215,13 @@ namespace FourSlash { // Get the text of the entire line the caret is currently at private getCurrentLineContent() { - let text = this.getFileContent(this.activeFile.fileName); + const text = this.getFileContent(this.activeFile.fileName); - let pos = this.currentCaretPosition; + const pos = this.currentCaretPosition; let startPos = pos, endPos = pos; while (startPos > 0) { - let ch = text.charCodeAt(startPos - 1); + const ch = text.charCodeAt(startPos - 1); if (ch === ts.CharacterCodes.carriageReturn || ch === ts.CharacterCodes.lineFeed) { break; } @@ -2230,7 +2230,7 @@ namespace FourSlash { } while (endPos < text.length) { - let ch = text.charCodeAt(endPos); + const ch = text.charCodeAt(endPos); if (ch === ts.CharacterCodes.carriageReturn || ch === ts.CharacterCodes.lineFeed) { break; @@ -2251,10 +2251,10 @@ namespace FourSlash { } for (let i = 0; i < items.length; i++) { - let item = items[i]; + const item = items[i]; if (item.name === name) { if (documentation != undefined || text !== undefined) { - let details = this.getCompletionEntryDetails(item.name); + const details = this.getCompletionEntryDetails(item.name); if (documentation !== undefined) { assert.equal(ts.displayPartsToString(details.documentation), documentation, assertionMessage("completion item documentation")); @@ -2272,7 +2272,7 @@ namespace FourSlash { } } - let itemsString = items.map((item) => JSON.stringify({ name: item.name, kind: item.kind })).join(",\n"); + const itemsString = items.map((item) => JSON.stringify({ name: item.name, kind: item.kind })).join(",\n"); this.raiseError(`Expected "${JSON.stringify({ name, text, documentation, kind })}" to be in list [${itemsString}]`); } @@ -2280,7 +2280,7 @@ namespace FourSlash { private findFile(indexOrName: any) { let result: FourSlashFile = null; if (typeof indexOrName === "number") { - let index = indexOrName; + const index = indexOrName; if (index >= this.testData.files.length) { throw new Error(`File index (${index}) in openFile was out of range. There are only ${this.testData.files.length} files in this test.`); } @@ -2294,10 +2294,10 @@ namespace FourSlash { // names are stored in the compiler with this relative path, this allows people to use goTo.file on just the fileName name = name.indexOf("/") === -1 ? (this.basePath + "/" + name) : name; - let availableNames: string[] = []; + const availableNames: string[] = []; let foundIt = false; for (let i = 0; i < this.testData.files.length; i++) { - let fn = this.testData.files[i].fileName; + const fn = this.testData.files[i].fileName; if (fn) { if (fn === name) { result = this.testData.files[i]; @@ -2320,15 +2320,15 @@ namespace FourSlash { } private getLineColStringAtPosition(position: number) { - let pos = this.languageServiceAdapterHost.positionToLineAndCharacter(this.activeFile.fileName, position); + const pos = this.languageServiceAdapterHost.positionToLineAndCharacter(this.activeFile.fileName, position); return `line ${(pos.line + 1)}, col ${pos.character}`; } public getMarkerByName(markerName: string) { - let markerPos = this.testData.markerPositions[markerName]; + const markerPos = this.testData.markerPositions[markerName]; if (markerPos === undefined) { - let markerNames: string[] = []; - for (let m in this.testData.markerPositions) markerNames.push(m); + const markerNames: string[] = []; + for (const m in this.testData.markerPositions) markerNames.push(m); throw new Error(`Unknown marker "${markerName}" Available markers: ${markerNames.map(m => "\"" + m + "\"").join(", ")}`); } else { @@ -2358,12 +2358,12 @@ namespace FourSlash { } // TOOD: should these just use the Harness's stdout/stderr? - let fsOutput = new Harness.Compiler.WriterAggregator(); - let fsErrors = new Harness.Compiler.WriterAggregator(); + const fsOutput = new Harness.Compiler.WriterAggregator(); + const fsErrors = new Harness.Compiler.WriterAggregator(); export let xmlData: TestXmlData[] = []; export function runFourSlashTest(basePath: string, testType: FourSlashTestType, fileName: string) { - let content = Harness.IO.readFile(fileName); - let xml = runFourSlashTestContent(basePath, testType, content, fileName); + const content = Harness.IO.readFile(fileName); + const xml = runFourSlashTestContent(basePath, testType, content, fileName); xmlData.push(xml); } @@ -2371,12 +2371,12 @@ namespace FourSlash { // here we cache the JS output and reuse it for every test. let fourslashJsOutput: string; { - let host = Harness.Compiler.createCompilerHost([{ unitName: Harness.Compiler.fourslashFileName, content: undefined }], + const host = Harness.Compiler.createCompilerHost([{ unitName: Harness.Compiler.fourslashFileName, content: undefined }], (fn, contents) => fourslashJsOutput = contents, ts.ScriptTarget.Latest, Harness.IO.useCaseSensitiveFileNames()); - let program = ts.createProgram([Harness.Compiler.fourslashFileName], { noResolve: true, target: ts.ScriptTarget.ES3 }, host); + const program = ts.createProgram([Harness.Compiler.fourslashFileName], { noResolve: true, target: ts.ScriptTarget.ES3 }, host); program.emit(host.getSourceFile(Harness.Compiler.fourslashFileName, ts.ScriptTarget.ES3)); } @@ -2384,12 +2384,12 @@ namespace FourSlash { export function runFourSlashTestContent(basePath: string, testType: FourSlashTestType, content: string, fileName: string): TestXmlData { // Parse out the files and their metadata - let testData = parseTestData(basePath, content, fileName); + const testData = parseTestData(basePath, content, fileName); currentTestState = new TestState(basePath, testType, testData); let result = ""; - let host = Harness.Compiler.createCompilerHost( + const host = Harness.Compiler.createCompilerHost( [ { unitName: Harness.Compiler.fourslashFileName, content: undefined }, { unitName: fileName, content: content } @@ -2398,11 +2398,11 @@ namespace FourSlash { ts.ScriptTarget.Latest, Harness.IO.useCaseSensitiveFileNames()); - let program = ts.createProgram([Harness.Compiler.fourslashFileName, fileName], { outFile: "fourslashTestOutput.js", noResolve: true, target: ts.ScriptTarget.ES3 }, host); + const program = ts.createProgram([Harness.Compiler.fourslashFileName, fileName], { outFile: "fourslashTestOutput.js", noResolve: true, target: ts.ScriptTarget.ES3 }, host); - let sourceFile = host.getSourceFile(fileName, ts.ScriptTarget.ES3); + const sourceFile = host.getSourceFile(fileName, ts.ScriptTarget.ES3); - let diagnostics = ts.getPreEmitDiagnostics(program, sourceFile); + const diagnostics = ts.getPreEmitDiagnostics(program, sourceFile); if (diagnostics.length > 0) { throw new Error(`Error compiling ${fileName}: ` + diagnostics.map(e => ts.flattenDiagnosticMessageText(e.messageText, Harness.IO.newLine())).join("\r\n")); @@ -2422,13 +2422,13 @@ namespace FourSlash { throw err; } - let xmlData = currentTestState.getTestXmlData(); + const xmlData = currentTestState.getTestXmlData(); xmlData.originalName = fileName; return xmlData; } function chompLeadingSpace(content: string) { - let lines = content.split("\n"); + const lines = content.split("\n"); for (let i = 0; i < lines.length; i++) { if ((lines[i].length !== 0) && (lines[i].charAt(0) !== " ")) { return content; @@ -2440,22 +2440,22 @@ namespace FourSlash { function parseTestData(basePath: string, contents: string, fileName: string): FourSlashData { // Regex for parsing options in the format "@Alpha: Value of any sort" - let optionRegex = /^\s*@(\w+): (.*)\s*/; + const optionRegex = /^\s*@(\w+): (.*)\s*/; // List of all the subfiles we've parsed out - let files: FourSlashFile[] = []; + const files: FourSlashFile[] = []; // Global options - let globalOptions: { [s: string]: string; } = {}; + const globalOptions: { [s: string]: string; } = {}; // Marker positions // Split up the input file by line // Note: IE JS engine incorrectly handles consecutive delimiters here when using RegExp split, so // we have to string-based splitting instead and try to figure out the delimiting chars - let lines = contents.split("\n"); + const lines = contents.split("\n"); - let markerPositions: MarkerMap = {}; - let markers: Marker[] = []; - let ranges: Range[] = []; + const markerPositions: MarkerMap = {}; + const markers: Marker[] = []; + const ranges: Range[] = []; // Stuff related to the subfile we're parsing let currentFileContent: string = null; @@ -2464,7 +2464,7 @@ namespace FourSlash { for (let i = 0; i < lines.length; i++) { let line = lines[i]; - let lineLength = line.length; + const lineLength = line.length; if (lineLength > 0 && line.charAt(lineLength - 1) === "\r") { line = line.substr(0, lineLength - 1); @@ -2486,9 +2486,9 @@ namespace FourSlash { } else if (line.substr(0, 2) === "//") { // Comment line, check for global/file @options and record them - let match = optionRegex.exec(line.substr(2)); + const match = optionRegex.exec(line.substr(2)); if (match) { - let fileMetadataNamesIndex = fileMetadataNames.indexOf(match[1]); + const fileMetadataNamesIndex = fileMetadataNames.indexOf(match[1]); if (fileMetadataNamesIndex === -1) { // Check if the match is already existed in the global options if (globalOptions[match[1]] !== undefined) { @@ -2500,7 +2500,7 @@ namespace FourSlash { if (fileMetadataNamesIndex === fileMetadataNames.indexOf(metadataOptionNames.fileName)) { // Found an @FileName directive, if this is not the first then create a new subfile if (currentFileContent) { - let file = parseFileContent(currentFileContent, currentFileName, markerPositions, markers, ranges); + const file = parseFileContent(currentFileContent, currentFileName, markerPositions, markers, ranges); file.fileOptions = currentFileOptions; // Store result file @@ -2530,7 +2530,7 @@ namespace FourSlash { else { // Empty line or code line, terminate current subfile if there is one if (currentFileContent) { - let file = parseFileContent(currentFileContent, currentFileName, markerPositions, markers, ranges); + const file = parseFileContent(currentFileContent, currentFileName, markerPositions, markers, ranges); file.fileOptions = currentFileOptions; // Store result file @@ -2573,7 +2573,7 @@ namespace FourSlash { } function getNonFileNameOptionInObject(optionObject: { [s: string]: string }): string { - for (let option in optionObject) { + for (const option in optionObject) { if (option !== metadataOptionNames.fileName) { return option; } @@ -2588,7 +2588,7 @@ namespace FourSlash { } function reportError(fileName: string, line: number, col: number, message: string) { - let errorMessage = fileName + "(" + line + "," + col + "): " + message; + const errorMessage = fileName + "(" + line + "," + col + "): " + message; throw new Error(errorMessage); } @@ -2607,7 +2607,7 @@ namespace FourSlash { return null; } - let marker: Marker = { + const marker: Marker = { fileName: fileName, position: location.position, data: markerValue @@ -2624,14 +2624,14 @@ namespace FourSlash { } function recordMarker(fileName: string, location: ILocationInformation, name: string, markerMap: MarkerMap, markers: Marker[]): Marker { - let marker: Marker = { + const marker: Marker = { fileName: fileName, position: location.position }; // Verify markers for uniqueness if (markerMap[name] !== undefined) { - let message = "Marker '" + name + "' is duplicated in the source file contents."; + const message = "Marker '" + name + "' is duplicated in the source file contents."; reportError(marker.fileName, location.sourceLine, location.sourceColumn, message); return null; } @@ -2646,7 +2646,7 @@ namespace FourSlash { content = chompLeadingSpace(content); // Any slash-star comment with a character not in this string is not a marker. - let validMarkerChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz$1234567890_"; + const validMarkerChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz$1234567890_"; /// The file content (minus metacharacters) so far let output = ""; @@ -2655,7 +2655,7 @@ namespace FourSlash { let openMarker: ILocationInformation = null; /// A stack of the open range markers that are still unclosed - let openRanges: IRangeLocationInformation[] = []; + const openRanges: IRangeLocationInformation[] = []; /// A list of ranges we've collected so far */ let localRanges: Range[] = []; @@ -2673,7 +2673,7 @@ namespace FourSlash { let line = 1; let column = 1; - let flush = (lastSafeCharIndex: number) => { + const flush = (lastSafeCharIndex: number) => { if (lastSafeCharIndex === undefined) { output = output + content.substr(lastNormalCharPosition); } @@ -2685,7 +2685,7 @@ namespace FourSlash { if (content.length > 0) { let previousChar = content.charAt(0); for (let i = 1; i < content.length; i++) { - let currentChar = content.charAt(i); + const currentChar = content.charAt(i); switch (state) { case State.none: if (previousChar === "[" && currentChar === "|") { @@ -2703,12 +2703,12 @@ namespace FourSlash { } else if (previousChar === "|" && currentChar === "]") { // found a range end - let rangeStart = openRanges.pop(); + const rangeStart = openRanges.pop(); if (!rangeStart) { reportError(fileName, line, column, "Found range end with no matching start."); } - let range: Range = { + const range: Range = { fileName: fileName, start: rangeStart.position, end: (i - 1) - difference, @@ -2748,8 +2748,8 @@ namespace FourSlash { // Object markers are only ever terminated by |} and have no content restrictions if (previousChar === "|" && currentChar === "}") { // Record the marker - let objectMarkerNameText = content.substring(openMarker.sourcePosition + 2, i - 1).trim(); - let marker = recordObjectMarker(fileName, openMarker, objectMarkerNameText, markerMap, markers); + const objectMarkerNameText = content.substring(openMarker.sourcePosition + 2, i - 1).trim(); + const marker = recordObjectMarker(fileName, openMarker, objectMarkerNameText, markerMap, markers); if (openRanges.length > 0) { openRanges[openRanges.length - 1].marker = marker; @@ -2769,8 +2769,8 @@ namespace FourSlash { if (previousChar === "*" && currentChar === "/") { // Record the marker // start + 2 to ignore the */, -1 on the end to ignore the * (/ is next) - let markerNameText = content.substring(openMarker.sourcePosition + 2, i - 1).trim(); - let marker = recordMarker(fileName, openMarker, markerNameText, markerMap, markers); + const markerNameText = content.substring(openMarker.sourcePosition + 2, i - 1).trim(); + const marker = recordMarker(fileName, openMarker, markerNameText, markerMap, markers); if (openRanges.length > 0) { openRanges[openRanges.length - 1].marker = marker; @@ -2821,7 +2821,7 @@ namespace FourSlash { flush(undefined); if (openRanges.length > 0) { - let openRange = openRanges[0]; + const openRange = openRanges[0]; reportError(fileName, openRange.sourceLine, openRange.sourceColumn, "Unterminated range."); } diff --git a/src/harness/fourslashRunner.ts b/src/harness/fourslashRunner.ts index 867c0d5a4d6..7228f06c20f 100644 --- a/src/harness/fourslashRunner.ts +++ b/src/harness/fourslashRunner.ts @@ -45,10 +45,10 @@ class FourSlashRunner extends RunnerBase { this.tests.forEach((fn: string) => { describe(fn, () => { fn = ts.normalizeSlashes(fn); - let justName = fn.replace(/^.*[\\\/]/, ""); + const justName = fn.replace(/^.*[\\\/]/, ""); // Convert to relative path - let testIndex = fn.indexOf("tests/"); + const testIndex = fn.indexOf("tests/"); if (testIndex >= 0) fn = fn.substr(testIndex); if (justName && !justName.match(/fourslash\.ts$/i) && !justName.match(/\.d\.ts$/i)) { @@ -60,21 +60,21 @@ class FourSlashRunner extends RunnerBase { }); describe("Generate Tao XML", () => { - let invalidReasons: any = {}; + const invalidReasons: any = {}; FourSlash.xmlData.forEach(xml => { if (xml.invalidReason !== null) { invalidReasons[xml.invalidReason] = (invalidReasons[xml.invalidReason] || 0) + 1; } }); - let invalidReport: { reason: string; count: number }[] = []; - for (let reason in invalidReasons) { + const invalidReport: { reason: string; count: number }[] = []; + for (const reason in invalidReasons) { if (invalidReasons.hasOwnProperty(reason)) { invalidReport.push({ reason: reason, count: invalidReasons[reason] }); } } invalidReport.sort((lhs, rhs) => lhs.count > rhs.count ? -1 : lhs.count === rhs.count ? 0 : 1); - let lines: string[] = []; + const lines: string[] = []; lines.push("